summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>1998-01-10 23:00:07 +0000
committercvs2svn <cvs2svn@FreeBSD.org>1998-01-10 23:00:07 +0000
commit7c6e96080c4fb49bf912942804477d202a53396c (patch)
tree876b1afcb203be407dbb2ddfc69653f78b8680c2 /gnu
parent1a06f650e6ca43e02260e8d252597fbed2cea73e (diff)
downloadFreeBSD-src-7c6e96080c4fb49bf912942804477d202a53396c.zip
FreeBSD-src-7c6e96080c4fb49bf912942804477d202a53396c.tar.gz
This commit was manufactured by cvs2svn to create branch 'JB'.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/COPYING339
-rw-r--r--gnu/COPYING.LIB481
-rw-r--r--gnu/Makefile6
-rw-r--r--gnu/gnu2bmake/README36
-rw-r--r--gnu/gnu2bmake/gcc-2.6.0.patch513
-rw-r--r--gnu/gnu2bmake/gcc-2.6.0.tcl259
-rw-r--r--gnu/gnu2bmake/gcc-2.6.1.patch407
-rwxr-xr-xgnu/gnu2bmake/gcc-2.6.1.tcl275
-rw-r--r--gnu/gnu2bmake/gnu2bmake.tcl221
-rw-r--r--gnu/gnu2bmake/libg++-2.6.patch26
-rw-r--r--gnu/gnu2bmake/libg++-2.6.tcl89
-rw-r--r--gnu/include/Makefile9
-rw-r--r--gnu/include/values.h177
-rw-r--r--gnu/lib/Makefile11
-rw-r--r--gnu/lib/Makefile.inc8
-rw-r--r--gnu/lib/libdialog/CHANGES9
-rw-r--r--gnu/lib/libdialog/COPYING339
-rw-r--r--gnu/lib/libdialog/Makefile37
-rw-r--r--gnu/lib/libdialog/README8
-rw-r--r--gnu/lib/libdialog/TESTS/Makefile16
-rw-r--r--gnu/lib/libdialog/TESTS/check1.c82
-rw-r--r--gnu/lib/libdialog/TESTS/check2.c104
-rw-r--r--gnu/lib/libdialog/TESTS/check3.c91
-rw-r--r--gnu/lib/libdialog/TESTS/dselect.c40
-rw-r--r--gnu/lib/libdialog/TESTS/fselect.c43
-rw-r--r--gnu/lib/libdialog/TESTS/gauge.c40
-rw-r--r--gnu/lib/libdialog/TESTS/input1.c44
-rw-r--r--gnu/lib/libdialog/TESTS/input2.c46
-rw-r--r--gnu/lib/libdialog/TESTS/menu1.c95
-rw-r--r--gnu/lib/libdialog/TESTS/menu2.c95
-rw-r--r--gnu/lib/libdialog/TESTS/menu3.c106
-rw-r--r--gnu/lib/libdialog/TESTS/msg.c41
-rw-r--r--gnu/lib/libdialog/TESTS/prgbox.c40
-rw-r--r--gnu/lib/libdialog/TESTS/radio1.c70
-rw-r--r--gnu/lib/libdialog/TESTS/radio2.c88
-rw-r--r--gnu/lib/libdialog/TESTS/radio3.c97
-rw-r--r--gnu/lib/libdialog/TESTS/text.c40
-rw-r--r--gnu/lib/libdialog/TESTS/yesno.c41
-rw-r--r--gnu/lib/libdialog/TODO36
-rw-r--r--gnu/lib/libdialog/checklist.c544
-rw-r--r--gnu/lib/libdialog/colors.h219
-rw-r--r--gnu/lib/libdialog/dialog.3401
-rw-r--r--gnu/lib/libdialog/dialog.h161
-rw-r--r--gnu/lib/libdialog/dialog.priv.h182
-rw-r--r--gnu/lib/libdialog/dir.c549
-rw-r--r--gnu/lib/libdialog/dir.h38
-rw-r--r--gnu/lib/libdialog/fselect.c402
-rw-r--r--gnu/lib/libdialog/gauge.c72
-rw-r--r--gnu/lib/libdialog/help.c194
-rw-r--r--gnu/lib/libdialog/inputbox.c190
-rw-r--r--gnu/lib/libdialog/kernel.c527
-rw-r--r--gnu/lib/libdialog/lineedit.c213
-rw-r--r--gnu/lib/libdialog/menubox.c458
-rw-r--r--gnu/lib/libdialog/msgbox.c344
-rw-r--r--gnu/lib/libdialog/notify.c50
-rw-r--r--gnu/lib/libdialog/prgbox.c148
-rw-r--r--gnu/lib/libdialog/radiolist.c541
-rw-r--r--gnu/lib/libdialog/raw_popen.c160
-rw-r--r--gnu/lib/libdialog/rc.c375
-rw-r--r--gnu/lib/libdialog/rc.h222
-rw-r--r--gnu/lib/libdialog/textbox.c696
-rw-r--r--gnu/lib/libdialog/ui_objects.c829
-rw-r--r--gnu/lib/libdialog/ui_objects.h114
-rw-r--r--gnu/lib/libdialog/yesno.c149
-rw-r--r--gnu/lib/libg++/Makefile51
-rw-r--r--gnu/lib/libg++/doc/Makefile16
-rw-r--r--gnu/lib/libgcc/Makefile95
-rw-r--r--gnu/lib/libgmp/Makefile119
-rw-r--r--gnu/lib/libgmp/Makefile.inc12
-rw-r--r--gnu/lib/libgmp/doc/Makefile9
-rw-r--r--gnu/lib/libmp/Makefile71
-rw-r--r--gnu/lib/libobjc/Makefile33
-rw-r--r--gnu/lib/libreadline/Makefile36
-rw-r--r--gnu/lib/libreadline/config.h139
-rw-r--r--gnu/lib/libreadline/doc/Makefile5
-rw-r--r--gnu/lib/libreadline/doc/history/Makefile14
-rw-r--r--gnu/lib/libreadline/doc/readline/Makefile14
-rw-r--r--gnu/lib/libregex/AUTHORS10
-rw-r--r--gnu/lib/libregex/COPYING339
-rw-r--r--gnu/lib/libregex/ChangeLog3030
-rw-r--r--gnu/lib/libregex/INSTALL117
-rw-r--r--gnu/lib/libregex/Makefile15
-rw-r--r--gnu/lib/libregex/Makefile.gnu99
-rw-r--r--gnu/lib/libregex/Makefile.in98
-rw-r--r--gnu/lib/libregex/NEWS62
-rw-r--r--gnu/lib/libregex/README60
-rw-r--r--gnu/lib/libregex/VERSION3
-rw-r--r--gnu/lib/libregex/config.status59
-rw-r--r--gnu/lib/libregex/configure462
-rw-r--r--gnu/lib/libregex/configure.in23
-rw-r--r--gnu/lib/libregex/doc/Makefile12
-rw-r--r--gnu/lib/libregex/doc/include.awk19
-rw-r--r--gnu/lib/libregex/doc/xregex.texi3021
-rw-r--r--gnu/lib/libregex/regex.c5101
-rw-r--r--gnu/lib/libregex/regex.h517
-rw-r--r--gnu/lib/libregex/test/ChangeLog77
-rw-r--r--gnu/lib/libregex/test/Makefile171
-rw-r--r--gnu/lib/libregex/test/Makefile.in170
-rw-r--r--gnu/lib/libregex/test/alloca.c194
-rw-r--r--gnu/lib/libregex/test/bsd-interf.c38
-rw-r--r--gnu/lib/libregex/test/debugmalloc.c273
-rw-r--r--gnu/lib/libregex/test/emacsmalloc.c844
-rw-r--r--gnu/lib/libregex/test/fileregex.c77
-rw-r--r--gnu/lib/libregex/test/g++malloc.c1288
-rw-r--r--gnu/lib/libregex/test/getpagesize.h25
-rw-r--r--gnu/lib/libregex/test/iregex.c164
-rw-r--r--gnu/lib/libregex/test/main.c49
-rw-r--r--gnu/lib/libregex/test/malloc-test.c47
-rw-r--r--gnu/lib/libregex/test/other.c503
-rw-r--r--gnu/lib/libregex/test/printchar.c14
-rw-r--r--gnu/lib/libregex/test/psx-basic.c253
-rw-r--r--gnu/lib/libregex/test/psx-extend.c1244
-rw-r--r--gnu/lib/libregex/test/psx-generic.c336
-rw-r--r--gnu/lib/libregex/test/psx-group.c440
-rw-r--r--gnu/lib/libregex/test/psx-interf.c624
-rw-r--r--gnu/lib/libregex/test/psx-interv.c140
-rw-r--r--gnu/lib/libregex/test/regexcpp.sed8
-rw-r--r--gnu/lib/libregex/test/syntax.skel74
-rw-r--r--gnu/lib/libregex/test/test.c782
-rw-r--r--gnu/lib/libregex/test/test.h141
-rw-r--r--gnu/lib/libregex/test/tregress.c464
-rw-r--r--gnu/lib/libregex/test/upcase.c39
-rw-r--r--gnu/lib/libregex/test/xmalloc.c21
-rw-r--r--gnu/lib/libstdc++/Makefile291
-rw-r--r--gnu/lib/libstdc++/_G_config.h84
-rw-r--r--gnu/libexec/Makefile5
-rw-r--r--gnu/libexec/Makefile.inc3
-rw-r--r--gnu/libexec/uucp/COPYING339
-rw-r--r--gnu/libexec/uucp/ChangeLog5070
-rw-r--r--gnu/libexec/uucp/Makefile10
-rw-r--r--gnu/libexec/uucp/Makefile.inc32
-rw-r--r--gnu/libexec/uucp/NEWS154
-rw-r--r--gnu/libexec/uucp/README173
-rw-r--r--gnu/libexec/uucp/TODO777
-rw-r--r--gnu/libexec/uucp/VERSION4
-rw-r--r--gnu/libexec/uucp/common_sources/chat.c1466
-rw-r--r--gnu/libexec/uucp/common_sources/config.h472
-rw-r--r--gnu/libexec/uucp/common_sources/conn.c587
-rw-r--r--gnu/libexec/uucp/common_sources/conn.h319
-rw-r--r--gnu/libexec/uucp/common_sources/copy.c236
-rw-r--r--gnu/libexec/uucp/common_sources/cu.h80
-rw-r--r--gnu/libexec/uucp/common_sources/getopt.h133
-rw-r--r--gnu/libexec/uucp/common_sources/log.c775
-rw-r--r--gnu/libexec/uucp/common_sources/policy.h703
-rw-r--r--gnu/libexec/uucp/common_sources/prot.c241
-rw-r--r--gnu/libexec/uucp/common_sources/prot.h270
-rw-r--r--gnu/libexec/uucp/common_sources/sysdep.h563
-rw-r--r--gnu/libexec/uucp/common_sources/system.h994
-rw-r--r--gnu/libexec/uucp/common_sources/trans.h288
-rw-r--r--gnu/libexec/uucp/common_sources/util.c184
-rw-r--r--gnu/libexec/uucp/common_sources/uuconf.h1557
-rw-r--r--gnu/libexec/uucp/common_sources/uucp.h398
-rw-r--r--gnu/libexec/uucp/common_sources/uudefs.h449
-rw-r--r--gnu/libexec/uucp/contrib/Dial.Hayes108
-rw-r--r--gnu/libexec/uucp/contrib/Hangup.Hayes57
-rw-r--r--gnu/libexec/uucp/contrib/Login.LAT137
-rw-r--r--gnu/libexec/uucp/contrib/Login.PortSel133
-rw-r--r--gnu/libexec/uucp/contrib/Login.VMS96
-rw-r--r--gnu/libexec/uucp/contrib/Makefile.uurt40
-rw-r--r--gnu/libexec/uucp/contrib/Makefile.xchat31
-rw-r--r--gnu/libexec/uucp/contrib/README82
-rw-r--r--gnu/libexec/uucp/contrib/README-UURATE21
-rw-r--r--gnu/libexec/uucp/contrib/README-XCHAT42
-rw-r--r--gnu/libexec/uucp/contrib/amiga.c43
-rw-r--r--gnu/libexec/uucp/contrib/dialHDB.c187
-rw-r--r--gnu/libexec/uucp/contrib/savelog.man130
-rwxr-xr-xgnu/libexec/uucp/contrib/savelog.sh247
-rwxr-xr-xgnu/libexec/uucp/contrib/stats.sh27
-rw-r--r--gnu/libexec/uucp/contrib/tstout.c158
-rw-r--r--gnu/libexec/uucp/contrib/uuclean25
-rw-r--r--gnu/libexec/uucp/contrib/uucomp.shar552
-rw-r--r--gnu/libexec/uucp/contrib/uudemon.shar82
-rw-r--r--gnu/libexec/uucp/contrib/uupoll.shar2687
-rwxr-xr-xgnu/libexec/uucp/contrib/uuq.sh125
-rw-r--r--gnu/libexec/uucp/contrib/uurate.c1854
-rw-r--r--gnu/libexec/uucp/contrib/uurate.man280
-rwxr-xr-xgnu/libexec/uucp/contrib/uureroute.perl91
-rw-r--r--gnu/libexec/uucp/contrib/uusnap.c321
-rw-r--r--gnu/libexec/uucp/contrib/uutraf210
-rw-r--r--gnu/libexec/uucp/contrib/uutry43
-rwxr-xr-xgnu/libexec/uucp/contrib/uuxconv50
-rw-r--r--gnu/libexec/uucp/contrib/xc-conf.h-dist38
-rw-r--r--gnu/libexec/uucp/contrib/xchat.c1473
-rw-r--r--gnu/libexec/uucp/contrib/xchat.man628
-rw-r--r--gnu/libexec/uucp/cu/Makefile17
-rw-r--r--gnu/libexec/uucp/cu/cu.1310
-rw-r--r--gnu/libexec/uucp/cu/cu.c2186
-rw-r--r--gnu/libexec/uucp/doc/Makefile4
-rw-r--r--gnu/libexec/uucp/doc/uucp.texi8367
-rw-r--r--gnu/libexec/uucp/libunix/MANIFEST84
-rw-r--r--gnu/libexec/uucp/libunix/Makefile23
-rw-r--r--gnu/libexec/uucp/libunix/access.c83
-rw-r--r--gnu/libexec/uucp/libunix/addbas.c50
-rw-r--r--gnu/libexec/uucp/libunix/app3.c32
-rw-r--r--gnu/libexec/uucp/libunix/app4.c36
-rw-r--r--gnu/libexec/uucp/libunix/basnam.c22
-rw-r--r--gnu/libexec/uucp/libunix/bytfre.c27
-rw-r--r--gnu/libexec/uucp/libunix/chmod.c25
-rw-r--r--gnu/libexec/uucp/libunix/cohtty.c257
-rw-r--r--gnu/libexec/uucp/libunix/corrup.c33
-rw-r--r--gnu/libexec/uucp/libunix/cusub.c1214
-rw-r--r--gnu/libexec/uucp/libunix/cwd.c58
-rw-r--r--gnu/libexec/uucp/libunix/detach.c181
-rw-r--r--gnu/libexec/uucp/libunix/dirent.c123
-rw-r--r--gnu/libexec/uucp/libunix/dup2.c69
-rw-r--r--gnu/libexec/uucp/libunix/efopen.c132
-rw-r--r--gnu/libexec/uucp/libunix/epopen.c85
-rw-r--r--gnu/libexec/uucp/libunix/exists.c16
-rw-r--r--gnu/libexec/uucp/libunix/failed.c26
-rw-r--r--gnu/libexec/uucp/libunix/filnam.c584
-rw-r--r--gnu/libexec/uucp/libunix/fsusg.c332
-rw-r--r--gnu/libexec/uucp/libunix/fsusg.h31
-rw-r--r--gnu/libexec/uucp/libunix/ftw.c254
-rw-r--r--gnu/libexec/uucp/libunix/getcwd.c59
-rw-r--r--gnu/libexec/uucp/libunix/indir.c133
-rw-r--r--gnu/libexec/uucp/libunix/init.c398
-rw-r--r--gnu/libexec/uucp/libunix/isdir.c18
-rw-r--r--gnu/libexec/uucp/libunix/isfork.c25
-rw-r--r--gnu/libexec/uucp/libunix/iswait.c159
-rw-r--r--gnu/libexec/uucp/libunix/jobid.c169
-rw-r--r--gnu/libexec/uucp/libunix/lcksys.c62
-rw-r--r--gnu/libexec/uucp/libunix/link.c38
-rw-r--r--gnu/libexec/uucp/libunix/locfil.c101
-rw-r--r--gnu/libexec/uucp/libunix/lock.c690
-rw-r--r--gnu/libexec/uucp/libunix/loctim.c27
-rw-r--r--gnu/libexec/uucp/libunix/mail.c121
-rw-r--r--gnu/libexec/uucp/libunix/mkdir.c58
-rw-r--r--gnu/libexec/uucp/libunix/mkdirs.c57
-rw-r--r--gnu/libexec/uucp/libunix/mode.c33
-rw-r--r--gnu/libexec/uucp/libunix/move.c162
-rw-r--r--gnu/libexec/uucp/libunix/opensr.c252
-rw-r--r--gnu/libexec/uucp/libunix/pause.c101
-rw-r--r--gnu/libexec/uucp/libunix/picksb.c234
-rw-r--r--gnu/libexec/uucp/libunix/pipe.c294
-rw-r--r--gnu/libexec/uucp/libunix/portnm.c51
-rw-r--r--gnu/libexec/uucp/libunix/priv.c24
-rw-r--r--gnu/libexec/uucp/libunix/proctm.c197
-rw-r--r--gnu/libexec/uucp/libunix/recep.c201
-rw-r--r--gnu/libexec/uucp/libunix/remove.c13
-rw-r--r--gnu/libexec/uucp/libunix/rename.c27
-rw-r--r--gnu/libexec/uucp/libunix/rmdir.c43
-rw-r--r--gnu/libexec/uucp/libunix/run.c113
-rw-r--r--gnu/libexec/uucp/libunix/seq.c126
-rw-r--r--gnu/libexec/uucp/libunix/serial.c3401
-rw-r--r--gnu/libexec/uucp/libunix/signal.c208
-rw-r--r--gnu/libexec/uucp/libunix/sindir.c29
-rw-r--r--gnu/libexec/uucp/libunix/size.c27
-rw-r--r--gnu/libexec/uucp/libunix/sleep.c26
-rw-r--r--gnu/libexec/uucp/libunix/spawn.c453
-rw-r--r--gnu/libexec/uucp/libunix/splcmd.c161
-rw-r--r--gnu/libexec/uucp/libunix/splnam.c19
-rw-r--r--gnu/libexec/uucp/libunix/spool.c427
-rw-r--r--gnu/libexec/uucp/libunix/srmdir.c112
-rw-r--r--gnu/libexec/uucp/libunix/statsb.c634
-rw-r--r--gnu/libexec/uucp/libunix/status.c248
-rw-r--r--gnu/libexec/uucp/libunix/strerr.c24
-rw-r--r--gnu/libexec/uucp/libunix/sync.c42
-rw-r--r--gnu/libexec/uucp/libunix/tcp.c444
-rw-r--r--gnu/libexec/uucp/libunix/time.c32
-rw-r--r--gnu/libexec/uucp/libunix/tli.c628
-rw-r--r--gnu/libexec/uucp/libunix/tmpfil.c84
-rw-r--r--gnu/libexec/uucp/libunix/trunc.c157
-rw-r--r--gnu/libexec/uucp/libunix/uacces.c205
-rw-r--r--gnu/libexec/uucp/libunix/ufopen.c135
-rw-r--r--gnu/libexec/uucp/libunix/uid.c116
-rw-r--r--gnu/libexec/uucp/libunix/ultspl.c21
-rw-r--r--gnu/libexec/uucp/libunix/unknwn.c43
-rw-r--r--gnu/libexec/uucp/libunix/uuto.c31
-rw-r--r--gnu/libexec/uucp/libunix/walk.c58
-rw-r--r--gnu/libexec/uucp/libunix/wldcrd.c213
-rw-r--r--gnu/libexec/uucp/libunix/work.c791
-rw-r--r--gnu/libexec/uucp/libunix/xqtfil.c298
-rw-r--r--gnu/libexec/uucp/libunix/xqtsub.c711
-rw-r--r--gnu/libexec/uucp/libuuconf/COPYING.LIB481
-rw-r--r--gnu/libexec/uucp/libuuconf/MANIFEST94
-rw-r--r--gnu/libexec/uucp/libuuconf/Makefile27
-rw-r--r--gnu/libexec/uucp/libuuconf/README113
-rw-r--r--gnu/libexec/uucp/libuuconf/addblk.c56
-rw-r--r--gnu/libexec/uucp/libuuconf/addstr.c139
-rw-r--r--gnu/libexec/uucp/libuuconf/allblk.c51
-rw-r--r--gnu/libexec/uucp/libuuconf/alloc.c82
-rw-r--r--gnu/libexec/uucp/libuuconf/alloc.h71
-rw-r--r--gnu/libexec/uucp/libuuconf/base.c54
-rw-r--r--gnu/libexec/uucp/libuuconf/bool.c64
-rw-r--r--gnu/libexec/uucp/libuuconf/callin.c195
-rw-r--r--gnu/libexec/uucp/libuuconf/calout.c93
-rw-r--r--gnu/libexec/uucp/libuuconf/chatc.c202
-rw-r--r--gnu/libexec/uucp/libuuconf/cmdarg.c185
-rw-r--r--gnu/libexec/uucp/libuuconf/cmdfil.c106
-rw-r--r--gnu/libexec/uucp/libuuconf/cmdlin.c145
-rw-r--r--gnu/libexec/uucp/libuuconf/debfil.c43
-rw-r--r--gnu/libexec/uucp/libuuconf/deblev.c43
-rw-r--r--gnu/libexec/uucp/libuuconf/diacod.c129
-rw-r--r--gnu/libexec/uucp/libuuconf/dial.c61
-rw-r--r--gnu/libexec/uucp/libuuconf/diasub.c63
-rw-r--r--gnu/libexec/uucp/libuuconf/dnams.c103
-rw-r--r--gnu/libexec/uucp/libuuconf/errno.c46
-rw-r--r--gnu/libexec/uucp/libuuconf/errstr.c241
-rw-r--r--gnu/libexec/uucp/libuuconf/filnam.c44
-rw-r--r--gnu/libexec/uucp/libuuconf/freblk.c63
-rw-r--r--gnu/libexec/uucp/libuuconf/fredia.c44
-rw-r--r--gnu/libexec/uucp/libuuconf/free.c68
-rw-r--r--gnu/libexec/uucp/libuuconf/freprt.c44
-rw-r--r--gnu/libexec/uucp/libuuconf/fresys.c44
-rw-r--r--gnu/libexec/uucp/libuuconf/grdcmp.c76
-rw-r--r--gnu/libexec/uucp/libuuconf/hdial.c187
-rw-r--r--gnu/libexec/uucp/libuuconf/hdnams.c109
-rw-r--r--gnu/libexec/uucp/libuuconf/hinit.c295
-rw-r--r--gnu/libexec/uucp/libuuconf/hlocnm.c84
-rw-r--r--gnu/libexec/uucp/libuuconf/hport.c360
-rw-r--r--gnu/libexec/uucp/libuuconf/hrmunk.c55
-rw-r--r--gnu/libexec/uucp/libuuconf/hsinfo.c637
-rw-r--r--gnu/libexec/uucp/libuuconf/hsnams.c142
-rw-r--r--gnu/libexec/uucp/libuuconf/hsys.c49
-rw-r--r--gnu/libexec/uucp/libuuconf/hunk.c142
-rw-r--r--gnu/libexec/uucp/libuuconf/iniglb.c180
-rw-r--r--gnu/libexec/uucp/libuuconf/init.c74
-rw-r--r--gnu/libexec/uucp/libuuconf/int.c59
-rw-r--r--gnu/libexec/uucp/libuuconf/lckdir.c43
-rw-r--r--gnu/libexec/uucp/libuuconf/lineno.c44
-rw-r--r--gnu/libexec/uucp/libuuconf/llocnm.c73
-rw-r--r--gnu/libexec/uucp/libuuconf/local.c70
-rw-r--r--gnu/libexec/uucp/libuuconf/locnm.c46
-rw-r--r--gnu/libexec/uucp/libuuconf/logfil.c43
-rw-r--r--gnu/libexec/uucp/libuuconf/maxuxq.c86
-rw-r--r--gnu/libexec/uucp/libuuconf/mrgblk.c50
-rw-r--r--gnu/libexec/uucp/libuuconf/paramc.c175
-rw-r--r--gnu/libexec/uucp/libuuconf/port.c77
-rw-r--r--gnu/libexec/uucp/libuuconf/prtsub.c54
-rw-r--r--gnu/libexec/uucp/libuuconf/pubdir.c43
-rw-r--r--gnu/libexec/uucp/libuuconf/rdlocs.c305
-rw-r--r--gnu/libexec/uucp/libuuconf/rdperm.c452
-rw-r--r--gnu/libexec/uucp/libuuconf/reliab.c123
-rw-r--r--gnu/libexec/uucp/libuuconf/remunk.c54
-rw-r--r--gnu/libexec/uucp/libuuconf/runuxq.c77
-rw-r--r--gnu/libexec/uucp/libuuconf/sinfo.c112
-rw-r--r--gnu/libexec/uucp/libuuconf/snams.c133
-rw-r--r--gnu/libexec/uucp/libuuconf/split.c106
-rw-r--r--gnu/libexec/uucp/libuuconf/spool.c43
-rw-r--r--gnu/libexec/uucp/libuuconf/stafil.c43
-rw-r--r--gnu/libexec/uucp/libuuconf/strip.c50
-rw-r--r--gnu/libexec/uucp/libuuconf/syshdr.h140
-rw-r--r--gnu/libexec/uucp/libuuconf/syssub.c524
-rw-r--r--gnu/libexec/uucp/libuuconf/tcalou.c207
-rw-r--r--gnu/libexec/uucp/libuuconf/tdial.c227
-rw-r--r--gnu/libexec/uucp/libuuconf/tdialc.c211
-rw-r--r--gnu/libexec/uucp/libuuconf/tdnams.c119
-rw-r--r--gnu/libexec/uucp/libuuconf/tgcmp.c42
-rw-r--r--gnu/libexec/uucp/libuuconf/thread.c70
-rw-r--r--gnu/libexec/uucp/libuuconf/time.c407
-rw-r--r--gnu/libexec/uucp/libuuconf/tinit.c465
-rw-r--r--gnu/libexec/uucp/libuuconf/tlocnm.c112
-rw-r--r--gnu/libexec/uucp/libuuconf/tport.c299
-rw-r--r--gnu/libexec/uucp/libuuconf/tportc.c505
-rw-r--r--gnu/libexec/uucp/libuuconf/tsinfo.c954
-rw-r--r--gnu/libexec/uucp/libuuconf/tsnams.c84
-rw-r--r--gnu/libexec/uucp/libuuconf/tsys.c49
-rw-r--r--gnu/libexec/uucp/libuuconf/tval.c71
-rw-r--r--gnu/libexec/uucp/libuuconf/ugtlin.c110
-rw-r--r--gnu/libexec/uucp/libuuconf/unk.c70
-rw-r--r--gnu/libexec/uucp/libuuconf/uucnfi.h380
-rw-r--r--gnu/libexec/uucp/libuuconf/val.c46
-rw-r--r--gnu/libexec/uucp/libuuconf/vinit.c112
-rw-r--r--gnu/libexec/uucp/libuuconf/vport.c254
-rw-r--r--gnu/libexec/uucp/libuuconf/vsinfo.c610
-rw-r--r--gnu/libexec/uucp/libuuconf/vsnams.c106
-rw-r--r--gnu/libexec/uucp/libuuconf/vsys.c49
-rw-r--r--gnu/libexec/uucp/libuucp/MANIFEST63
-rw-r--r--gnu/libexec/uucp/libuucp/Makefile15
-rw-r--r--gnu/libexec/uucp/libuucp/bsrch.c54
-rw-r--r--gnu/libexec/uucp/libuucp/buffer.c127
-rw-r--r--gnu/libexec/uucp/libuucp/bzero.c15
-rw-r--r--gnu/libexec/uucp/libuucp/crc.c112
-rw-r--r--gnu/libexec/uucp/libuucp/debug.c173
-rw-r--r--gnu/libexec/uucp/libuucp/escape.c98
-rw-r--r--gnu/libexec/uucp/libuucp/getlin.c81
-rw-r--r--gnu/libexec/uucp/libuucp/getop1.c144
-rw-r--r--gnu/libexec/uucp/libuucp/getopt.c621
-rw-r--r--gnu/libexec/uucp/libuucp/memchr.c149
-rw-r--r--gnu/libexec/uucp/libuucp/memcmp.c19
-rw-r--r--gnu/libexec/uucp/libuucp/memcpy.c18
-rw-r--r--gnu/libexec/uucp/libuucp/parse.c219
-rw-r--r--gnu/libexec/uucp/libuucp/spool.c30
-rw-r--r--gnu/libexec/uucp/libuucp/status.c38
-rw-r--r--gnu/libexec/uucp/libuucp/strcas.c33
-rw-r--r--gnu/libexec/uucp/libuucp/strchr.c16
-rw-r--r--gnu/libexec/uucp/libuucp/strdup.c18
-rw-r--r--gnu/libexec/uucp/libuucp/strncs.c39
-rw-r--r--gnu/libexec/uucp/libuucp/strrch.c24
-rw-r--r--gnu/libexec/uucp/libuucp/strstr.c55
-rw-r--r--gnu/libexec/uucp/libuucp/strtol.c175
-rw-r--r--gnu/libexec/uucp/libuucp/strtou.c21
-rw-r--r--gnu/libexec/uucp/libuucp/xfree.c15
-rw-r--r--gnu/libexec/uucp/libuucp/xmall.c18
-rw-r--r--gnu/libexec/uucp/libuucp/xreall.c23
-rw-r--r--gnu/libexec/uucp/sample/Makefile17
-rw-r--r--gnu/libexec/uucp/sample/call.sample20
-rw-r--r--gnu/libexec/uucp/sample/config.sample88
-rw-r--r--gnu/libexec/uucp/sample/dial.sample39
-rw-r--r--gnu/libexec/uucp/sample/dialcode.sample19
-rw-r--r--gnu/libexec/uucp/sample/passwd.sample18
-rw-r--r--gnu/libexec/uucp/sample/port.sample41
-rw-r--r--gnu/libexec/uucp/sample/sys1.sample44
-rw-r--r--gnu/libexec/uucp/sample/sys2.sample51
-rw-r--r--gnu/libexec/uucp/tstuu.c1603
-rw-r--r--gnu/libexec/uucp/uuchk/Makefile14
-rw-r--r--gnu/libexec/uucp/uuchk/uuchk.846
-rw-r--r--gnu/libexec/uucp/uuchk/uuchk.c1127
-rw-r--r--gnu/libexec/uucp/uucico/Makefile21
-rw-r--r--gnu/libexec/uucp/uucico/prote.c397
-rw-r--r--gnu/libexec/uucp/uucico/protf.c848
-rw-r--r--gnu/libexec/uucp/uucico/protg.c1978
-rw-r--r--gnu/libexec/uucp/uucico/proti.c1699
-rw-r--r--gnu/libexec/uucp/uucico/protj.c672
-rw-r--r--gnu/libexec/uucp/uucico/prott.c331
-rw-r--r--gnu/libexec/uucp/uucico/proty.c660
-rw-r--r--gnu/libexec/uucp/uucico/protz.c2626
-rw-r--r--gnu/libexec/uucp/uucico/rec.c1309
-rw-r--r--gnu/libexec/uucp/uucico/send.c1387
-rw-r--r--gnu/libexec/uucp/uucico/time.c132
-rw-r--r--gnu/libexec/uucp/uucico/trans.c1489
-rw-r--r--gnu/libexec/uucp/uucico/uucico.8291
-rw-r--r--gnu/libexec/uucp/uucico/uucico.c3074
-rw-r--r--gnu/libexec/uucp/uucico/xcmd.c401
-rw-r--r--gnu/libexec/uucp/uuconv/Makefile14
-rw-r--r--gnu/libexec/uucp/uuconv/uuconv.157
-rw-r--r--gnu/libexec/uucp/uuconv/uuconv.c2106
-rw-r--r--gnu/libexec/uucp/uucp/Makefile16
-rw-r--r--gnu/libexec/uucp/uucp/uucp.1212
-rw-r--r--gnu/libexec/uucp/uucp/uucp.c1268
-rw-r--r--gnu/libexec/uucp/uulog/Makefile14
-rw-r--r--gnu/libexec/uucp/uulog/uulog.184
-rw-r--r--gnu/libexec/uucp/uulog/uulog.c492
-rw-r--r--gnu/libexec/uucp/uuname/Makefile17
-rw-r--r--gnu/libexec/uucp/uuname/uuname.145
-rw-r--r--gnu/libexec/uucp/uuname/uuname.c202
-rw-r--r--gnu/libexec/uucp/uupick/Makefile14
-rw-r--r--gnu/libexec/uucp/uupick/uupick.172
-rw-r--r--gnu/libexec/uucp/uupick/uupick.c369
-rw-r--r--gnu/libexec/uucp/uusched/Makefile19
-rw-r--r--gnu/libexec/uucp/uusched/uusched.824
-rw-r--r--gnu/libexec/uucp/uusched/uusched.in13
-rw-r--r--gnu/libexec/uucp/uustat/Makefile18
-rw-r--r--gnu/libexec/uucp/uustat/uustat.1551
-rw-r--r--gnu/libexec/uucp/uustat/uustat.c2441
-rw-r--r--gnu/libexec/uucp/uuto/Makefile19
-rw-r--r--gnu/libexec/uucp/uuto/uuto.141
-rw-r--r--gnu/libexec/uucp/uuto/uuto.in16
-rw-r--r--gnu/libexec/uucp/uux/Makefile16
-rw-r--r--gnu/libexec/uucp/uux/uux.1255
-rw-r--r--gnu/libexec/uucp/uux/uux.c1626
-rw-r--r--gnu/libexec/uucp/uuxqt/Makefile19
-rw-r--r--gnu/libexec/uucp/uuxqt/uuxqt.8103
-rw-r--r--gnu/libexec/uucp/uuxqt/uuxqt.c1766
-rw-r--r--gnu/usr.bin/Makefile11
-rw-r--r--gnu/usr.bin/Makefile.inc3
-rw-r--r--gnu/usr.bin/as/CONTRIBUTORS11
-rw-r--r--gnu/usr.bin/as/COPYING339
-rw-r--r--gnu/usr.bin/as/ChangeLog429
-rw-r--r--gnu/usr.bin/as/Makefile71
-rw-r--r--gnu/usr.bin/as/Makefile.in411
-rw-r--r--gnu/usr.bin/as/NOTES16
-rw-r--r--gnu/usr.bin/as/NOTES.config52
-rw-r--r--gnu/usr.bin/as/README212
-rw-r--r--gnu/usr.bin/as/README-vms248
-rw-r--r--gnu/usr.bin/as/README.coff79
-rw-r--r--gnu/usr.bin/as/README.pic25
-rw-r--r--gnu/usr.bin/as/README.rich144
-rw-r--r--gnu/usr.bin/as/VERSION1
-rw-r--r--gnu/usr.bin/as/app.c746
-rw-r--r--gnu/usr.bin/as/as.1283
-rw-r--r--gnu/usr.bin/as/as.1aout283
-rw-r--r--gnu/usr.bin/as/as.c428
-rw-r--r--gnu/usr.bin/as/as.h426
-rw-r--r--gnu/usr.bin/as/atof-generic.c526
-rw-r--r--gnu/usr.bin/as/bignum-copy.c76
-rw-r--r--gnu/usr.bin/as/bignum.h64
-rw-r--r--gnu/usr.bin/as/bit_fix.h54
-rw-r--r--gnu/usr.bin/as/cond.c219
-rw-r--r--gnu/usr.bin/as/config-gas.com76
-rw-r--r--gnu/usr.bin/as/config/Makefile.hp3007
-rw-r--r--gnu/usr.bin/as/config/Makefile.i3865
-rw-r--r--gnu/usr.bin/as/config/Makefile.pc5327
-rw-r--r--gnu/usr.bin/as/config/Makefile.sparc5
-rw-r--r--gnu/usr.bin/as/config/Makefile.vax4
-rw-r--r--gnu/usr.bin/as/config/aout.h440
-rw-r--r--gnu/usr.bin/as/config/atof-ieee.c525
-rw-r--r--gnu/usr.bin/as/config/atof-ns32k.c437
-rw-r--r--gnu/usr.bin/as/config/atof-tahoe.c428
-rw-r--r--gnu/usr.bin/as/config/atof-vax.c497
-rw-r--r--gnu/usr.bin/as/config/coff.h783
-rw-r--r--gnu/usr.bin/as/config/cplus-dem.c927
-rw-r--r--gnu/usr.bin/as/config/ho-ansi.h29
-rw-r--r--gnu/usr.bin/as/config/ho-decstation.h29
-rw-r--r--gnu/usr.bin/as/config/ho-generic.h30
-rw-r--r--gnu/usr.bin/as/config/ho-hpux.h34
-rw-r--r--gnu/usr.bin/as/config/ho-i386.h30
-rw-r--r--gnu/usr.bin/as/config/ho-i386aix.h24
-rw-r--r--gnu/usr.bin/as/config/ho-rs6000.h22
-rw-r--r--gnu/usr.bin/as/config/ho-sun3.h3
-rw-r--r--gnu/usr.bin/as/config/ho-sun386.h5
-rw-r--r--gnu/usr.bin/as/config/ho-sun4.h3
-rw-r--r--gnu/usr.bin/as/config/ho-sunos.h81
-rw-r--r--gnu/usr.bin/as/config/ho-sysv.h27
-rw-r--r--gnu/usr.bin/as/config/ho-vax.h27
-rw-r--r--gnu/usr.bin/as/config/ho-vms.h30
-rw-r--r--gnu/usr.bin/as/config/mh-i3861
-rw-r--r--gnu/usr.bin/as/config/mh-i386aix5
-rw-r--r--gnu/usr.bin/as/config/mh-i386v41
-rw-r--r--gnu/usr.bin/as/config/mt-ebmon29k6
-rw-r--r--gnu/usr.bin/as/config/mt-h83005
-rw-r--r--gnu/usr.bin/as/config/mt-h8300hds4
-rw-r--r--gnu/usr.bin/as/config/mt-i386aix3
-rw-r--r--gnu/usr.bin/as/config/mt-mips1
-rw-r--r--gnu/usr.bin/as/config/mt-rs60001
-rw-r--r--gnu/usr.bin/as/config/obj-aout.c654
-rw-r--r--gnu/usr.bin/as/config/obj-aout.h305
-rw-r--r--gnu/usr.bin/as/config/obj-bfd-sunos.c71
-rw-r--r--gnu/usr.bin/as/config/obj-bfd-sunos.h69
-rw-r--r--gnu/usr.bin/as/config/obj-bout.c476
-rw-r--r--gnu/usr.bin/as/config/obj-bout.h313
-rw-r--r--gnu/usr.bin/as/config/obj-coff.c1978
-rw-r--r--gnu/usr.bin/as/config/obj-coff.h598
-rw-r--r--gnu/usr.bin/as/config/obj-coffbfd.c2182
-rw-r--r--gnu/usr.bin/as/config/obj-coffbfd.h516
-rw-r--r--gnu/usr.bin/as/config/obj-generic.c41
-rw-r--r--gnu/usr.bin/as/config/obj-generic.h78
-rw-r--r--gnu/usr.bin/as/config/obj-ieee.c539
-rw-r--r--gnu/usr.bin/as/config/obj-ieee.h46
-rw-r--r--gnu/usr.bin/as/config/obj-vms.c5484
-rw-r--r--gnu/usr.bin/as/config/obj-vms.h474
-rw-r--r--gnu/usr.bin/as/config/tc-a29k.c1113
-rw-r--r--gnu/usr.bin/as/config/tc-a29k.h40
-rw-r--r--gnu/usr.bin/as/config/tc-generic.c0
-rw-r--r--gnu/usr.bin/as/config/tc-generic.h37
-rw-r--r--gnu/usr.bin/as/config/tc-h8300.c1295
-rw-r--r--gnu/usr.bin/as/config/tc-h8300.h38
-rw-r--r--gnu/usr.bin/as/config/tc-i386.c2345
-rw-r--r--gnu/usr.bin/as/config/tc-i386.h251
-rw-r--r--gnu/usr.bin/as/config/tc-i860.c1295
-rw-r--r--gnu/usr.bin/as/config/tc-i860.h24
-rw-r--r--gnu/usr.bin/as/config/tc-i960.c2759
-rw-r--r--gnu/usr.bin/as/config/tc-i960.h281
-rw-r--r--gnu/usr.bin/as/config/tc-m68851.h304
-rw-r--r--gnu/usr.bin/as/config/tc-m68k.c4088
-rw-r--r--gnu/usr.bin/as/config/tc-m68k.h62
-rw-r--r--gnu/usr.bin/as/config/tc-m68kmote.h64
-rw-r--r--gnu/usr.bin/as/config/tc-m88k.c1435
-rw-r--r--gnu/usr.bin/as/config/tc-m88k.h35
-rw-r--r--gnu/usr.bin/as/config/tc-mips.c0
-rw-r--r--gnu/usr.bin/as/config/tc-mips.h0
-rw-r--r--gnu/usr.bin/as/config/tc-ns32k.c2015
-rw-r--r--gnu/usr.bin/as/config/tc-ns32k.h66
-rw-r--r--gnu/usr.bin/as/config/tc-rs6000.c0
-rw-r--r--gnu/usr.bin/as/config/tc-rs6000.h0
-rw-r--r--gnu/usr.bin/as/config/tc-sparc.c1803
-rw-r--r--gnu/usr.bin/as/config/tc-sparc.h52
-rw-r--r--gnu/usr.bin/as/config/tc-tahoe.c1924
-rw-r--r--gnu/usr.bin/as/config/tc-tahoe.h36
-rw-r--r--gnu/usr.bin/as/config/tc-vax.c3073
-rw-r--r--gnu/usr.bin/as/config/tc-vax.h26
-rw-r--r--gnu/usr.bin/as/config/te-dpx2.h8
-rw-r--r--gnu/usr.bin/as/config/te-generic.h25
-rw-r--r--gnu/usr.bin/as/config/te-hpux.h99
-rw-r--r--gnu/usr.bin/as/config/te-i386aix.h19
-rw-r--r--gnu/usr.bin/as/config/te-ic960.h46
-rw-r--r--gnu/usr.bin/as/config/te-sco386.h7
-rw-r--r--gnu/usr.bin/as/config/te-sequent.h32
-rw-r--r--gnu/usr.bin/as/config/te-sun3.h49
-rw-r--r--gnu/usr.bin/as/config/te-sysv32.h4
-rw-r--r--gnu/usr.bin/as/config/vax-inst.h77
-rw-r--r--gnu/usr.bin/as/configdos.bat14
-rwxr-xr-xgnu/usr.bin/as/configure.in204
-rw-r--r--gnu/usr.bin/as/debug.c104
-rw-r--r--gnu/usr.bin/as/doc/Makefile5
-rw-r--r--gnu/usr.bin/as/doc/as-all.texinfo4995
-rw-r--r--gnu/usr.bin/as/expr.c1000
-rw-r--r--gnu/usr.bin/as/expr.h85
-rw-r--r--gnu/usr.bin/as/flo-const.c161
-rw-r--r--gnu/usr.bin/as/flo-copy.c70
-rw-r--r--gnu/usr.bin/as/flonum-mult.c203
-rw-r--r--gnu/usr.bin/as/flonum.h125
-rw-r--r--gnu/usr.bin/as/frags.c296
-rw-r--r--gnu/usr.bin/as/frags.h89
-rw-r--r--gnu/usr.bin/as/gas-format.el79
-rw-r--r--gnu/usr.bin/as/hash.c992
-rw-r--r--gnu/usr.bin/as/hash.h65
-rw-r--r--gnu/usr.bin/as/hex-value.c61
-rw-r--r--gnu/usr.bin/as/input-file.c327
-rw-r--r--gnu/usr.bin/as/input-file.h88
-rw-r--r--gnu/usr.bin/as/input-scrub.c420
-rw-r--r--gnu/usr.bin/as/link.cmd10
-rw-r--r--gnu/usr.bin/as/listing.c1079
-rw-r--r--gnu/usr.bin/as/listing.h115
-rw-r--r--gnu/usr.bin/as/make-gas.com86
-rw-r--r--gnu/usr.bin/as/makefile.dos593
-rw-r--r--gnu/usr.bin/as/messages.c595
-rw-r--r--gnu/usr.bin/as/obj.h77
-rw-r--r--gnu/usr.bin/as/obstack.c374
-rw-r--r--gnu/usr.bin/as/obstack.h448
-rw-r--r--gnu/usr.bin/as/opcode/ChangeLog56
-rw-r--r--gnu/usr.bin/as/opcode/a29k.h327
-rw-r--r--gnu/usr.bin/as/opcode/h8300.h266
-rw-r--r--gnu/usr.bin/as/opcode/i386.h880
-rw-r--r--gnu/usr.bin/as/opcode/i860.h495
-rw-r--r--gnu/usr.bin/as/opcode/i960.h434
-rw-r--r--gnu/usr.bin/as/opcode/m68k.h1998
-rw-r--r--gnu/usr.bin/as/opcode/m88k.h282
-rw-r--r--gnu/usr.bin/as/opcode/mips.h363
-rw-r--r--gnu/usr.bin/as/opcode/np1.h422
-rw-r--r--gnu/usr.bin/as/opcode/ns32k.h491
-rw-r--r--gnu/usr.bin/as/opcode/pn.h282
-rw-r--r--gnu/usr.bin/as/opcode/pyr.h287
-rw-r--r--gnu/usr.bin/as/opcode/sparc.h885
-rw-r--r--gnu/usr.bin/as/opcode/tahoe.h247
-rw-r--r--gnu/usr.bin/as/opcode/vax.h382
-rw-r--r--gnu/usr.bin/as/output-file.c122
-rw-r--r--gnu/usr.bin/as/output-file.h40
-rw-r--r--gnu/usr.bin/as/read.c2384
-rw-r--r--gnu/usr.bin/as/read.h158
-rw-r--r--gnu/usr.bin/as/struc-symbol.h134
-rw-r--r--gnu/usr.bin/as/subsegs.c313
-rw-r--r--gnu/usr.bin/as/subsegs.h93
-rw-r--r--gnu/usr.bin/as/symbols.c654
-rw-r--r--gnu/usr.bin/as/symbols.h82
-rw-r--r--gnu/usr.bin/as/tc.h112
-rwxr-xr-xgnu/usr.bin/as/testscripts/doboth20
-rwxr-xr-xgnu/usr.bin/as/testscripts/doobjcmp89
-rwxr-xr-xgnu/usr.bin/as/testscripts/dostriptest15
-rwxr-xr-xgnu/usr.bin/as/testscripts/dotest44
-rwxr-xr-xgnu/usr.bin/as/testscripts/dounsortreloc9
-rwxr-xr-xgnu/usr.bin/as/testscripts/dounsortsymbols9
-rw-r--r--gnu/usr.bin/as/version.c30
-rw-r--r--gnu/usr.bin/as/write.c1224
-rw-r--r--gnu/usr.bin/as/write.h120
-rw-r--r--gnu/usr.bin/as/xmalloc.c75
-rw-r--r--gnu/usr.bin/as/xrealloc.c74
-rw-r--r--gnu/usr.bin/awk/Makefile32
-rw-r--r--gnu/usr.bin/awk/doc/Makefile11
-rw-r--r--gnu/usr.bin/bc/COPYING341
-rw-r--r--gnu/usr.bin/bc/Makefile10
-rw-r--r--gnu/usr.bin/bc/bc.1732
-rw-r--r--gnu/usr.bin/bc/bc.y615
-rw-r--r--gnu/usr.bin/bc/bcdefs.h154
-rw-r--r--gnu/usr.bin/bc/config.h4
-rw-r--r--gnu/usr.bin/bc/const.h91
-rw-r--r--gnu/usr.bin/bc/execute.c785
-rw-r--r--gnu/usr.bin/bc/global.c42
-rw-r--r--gnu/usr.bin/bc/global.h125
-rw-r--r--gnu/usr.bin/bc/load.c333
-rw-r--r--gnu/usr.bin/bc/main.c204
-rw-r--r--gnu/usr.bin/bc/math.h40
-rw-r--r--gnu/usr.bin/bc/number.c1419
-rw-r--r--gnu/usr.bin/bc/number.h60
-rw-r--r--gnu/usr.bin/bc/proto.h160
-rw-r--r--gnu/usr.bin/bc/scan.l196
-rw-r--r--gnu/usr.bin/bc/storage.c963
-rw-r--r--gnu/usr.bin/bc/util.c820
-rw-r--r--gnu/usr.bin/bc/version.h3
-rw-r--r--gnu/usr.bin/binutils/gdb/Makefile117
-rw-r--r--gnu/usr.bin/binutils/gdb/config.h91
-rw-r--r--gnu/usr.bin/binutils/gdb/gdb.1385
-rw-r--r--gnu/usr.bin/binutils/gdb/i386/freebsd-nat.c401
-rw-r--r--gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c970
-rw-r--r--gnu/usr.bin/binutils/gdb/i386/nm.h128
-rw-r--r--gnu/usr.bin/binutils/gdb/i386/tm.h70
-rw-r--r--gnu/usr.bin/binutils/gdb/i386/version.c3
-rw-r--r--gnu/usr.bin/binutils/gdb/i386/xm.h23
-rw-r--r--gnu/usr.bin/binutils/gdb/kvm-fbsd.c970
-rw-r--r--gnu/usr.bin/binutils/gdbreplay/Makefile17
-rw-r--r--gnu/usr.bin/binutils/gdbserver/Makefile17
-rw-r--r--gnu/usr.bin/binutils/gdbserver/low-fbsd.c433
-rw-r--r--gnu/usr.bin/bison/Makefile22
-rw-r--r--gnu/usr.bin/bison/data/Makefile23
-rw-r--r--gnu/usr.bin/bison/doc/Makefile9
-rw-r--r--gnu/usr.bin/cc/Makefile10
-rw-r--r--gnu/usr.bin/cc/Makefile.inc52
-rw-r--r--gnu/usr.bin/cc/c++/Makefile11
-rw-r--r--gnu/usr.bin/cc/c++filt/Makefile55
-rw-r--r--gnu/usr.bin/cc/cc/Makefile22
-rw-r--r--gnu/usr.bin/cc/cc/f2c-specs.h29
-rw-r--r--gnu/usr.bin/cc/cc1/Makefile15
-rw-r--r--gnu/usr.bin/cc/cc1obj/Makefile15
-rw-r--r--gnu/usr.bin/cc/cc1plus/Makefile27
-rw-r--r--gnu/usr.bin/cc/cc_int/Makefile29
-rw-r--r--gnu/usr.bin/cc/cc_tools/Makefile156
-rw-r--r--gnu/usr.bin/cc/cccp/Makefile18
-rw-r--r--gnu/usr.bin/cc/cpp/Makefile18
-rw-r--r--gnu/usr.bin/cc/doc/Makefile17
-rw-r--r--gnu/usr.bin/cc/f77/Makefile9
-rw-r--r--gnu/usr.bin/cc/f77/f77.169
-rw-r--r--gnu/usr.bin/cc/f77/f77.c576
-rw-r--r--gnu/usr.bin/cc/libgcc/Makefile95
-rw-r--r--gnu/usr.bin/cpio/Makefile24
-rw-r--r--gnu/usr.bin/cpio/doc/Makefile15
-rw-r--r--gnu/usr.bin/cvs/Makefile5
-rw-r--r--gnu/usr.bin/cvs/Makefile.inc17
-rw-r--r--gnu/usr.bin/cvs/contrib/Makefile43
-rw-r--r--gnu/usr.bin/cvs/contrib/easy-import.pl403
-rw-r--r--gnu/usr.bin/cvs/cvs/Makefile38
-rw-r--r--gnu/usr.bin/cvs/cvs/options.h268
-rw-r--r--gnu/usr.bin/cvs/cvsbug/Makefile29
-rw-r--r--gnu/usr.bin/cvs/doc/Makefile23
-rw-r--r--gnu/usr.bin/cvs/lib/Makefile26
-rw-r--r--gnu/usr.bin/cvs/lib/config.h227
-rw-r--r--gnu/usr.bin/cvs/lib/config.h.proto227
-rw-r--r--gnu/usr.bin/cvs/tools/Makefile17
-rw-r--r--gnu/usr.bin/dc/COPYING339
-rw-r--r--gnu/usr.bin/dc/Makefile10
-rw-r--r--gnu/usr.bin/dc/dc-array.c105
-rw-r--r--gnu/usr.bin/dc/dc-eval.c569
-rw-r--r--gnu/usr.bin/dc/dc-misc.c224
-rw-r--r--gnu/usr.bin/dc/dc-number.c478
-rw-r--r--gnu/usr.bin/dc/dc-proto.h76
-rw-r--r--gnu/usr.bin/dc/dc-regdef.h38
-rw-r--r--gnu/usr.bin/dc/dc-stack.c367
-rw-r--r--gnu/usr.bin/dc/dc-string.c193
-rw-r--r--gnu/usr.bin/dc/dc-version.h22
-rw-r--r--gnu/usr.bin/dc/dc.1393
-rw-r--r--gnu/usr.bin/dc/dc.h81
-rw-r--r--gnu/usr.bin/dc/doc/Makefile5
-rw-r--r--gnu/usr.bin/dc/doc/dc.texinfo425
-rw-r--r--gnu/usr.bin/dialog/COPYING339
-rw-r--r--gnu/usr.bin/dialog/Makefile12
-rw-r--r--gnu/usr.bin/dialog/README161
-rw-r--r--gnu/usr.bin/dialog/README.lib3
-rwxr-xr-xgnu/usr.bin/dialog/TESTS/checklist33
-rwxr-xr-xgnu/usr.bin/dialog/TESTS/infobox15
-rwxr-xr-xgnu/usr.bin/dialog/TESTS/inputbox28
-rwxr-xr-xgnu/usr.bin/dialog/TESTS/menubox35
-rwxr-xr-xgnu/usr.bin/dialog/TESTS/msgbox14
-rwxr-xr-xgnu/usr.bin/dialog/TESTS/prgbox12
-rwxr-xr-xgnu/usr.bin/dialog/TESTS/radiolist33
-rwxr-xr-xgnu/usr.bin/dialog/TESTS/textbox42
-rwxr-xr-xgnu/usr.bin/dialog/TESTS/yesno23
-rw-r--r--gnu/usr.bin/dialog/dialog.1239
-rw-r--r--gnu/usr.bin/dialog/dialog.c372
-rw-r--r--gnu/usr.bin/diff/Makefile21
-rw-r--r--gnu/usr.bin/diff/diff.1470
-rw-r--r--gnu/usr.bin/diff/doc/Makefile9
-rw-r--r--gnu/usr.bin/diff3/Makefile15
-rw-r--r--gnu/usr.bin/diff3/diff3.1210
-rw-r--r--gnu/usr.bin/gdb/Makefile3
-rw-r--r--gnu/usr.bin/gdb/Makefile.inc14
-rw-r--r--gnu/usr.bin/gdb/bfd/Makefile31
-rw-r--r--gnu/usr.bin/gdb/bfd/bfd.h2479
-rw-r--r--gnu/usr.bin/gdb/bfd/config.h68
-rw-r--r--gnu/usr.bin/gdb/bfd/i386freebsd.h24
-rw-r--r--gnu/usr.bin/gdb/doc/Makefile10
-rw-r--r--gnu/usr.bin/gdb/doc/gdb-cfg.texi120
-rw-r--r--gnu/usr.bin/gdb/doc/inc-hist.texi313
-rw-r--r--gnu/usr.bin/gdb/gdb/Makefile117
-rw-r--r--gnu/usr.bin/gdb/gdb/config.h91
-rw-r--r--gnu/usr.bin/gdb/gdb/freebsd-nat.c401
-rw-r--r--gnu/usr.bin/gdb/gdb/gdb.1385
-rw-r--r--gnu/usr.bin/gdb/gdb/i386freebsd.h23
-rw-r--r--gnu/usr.bin/gdb/gdb/kvm-fbsd.c970
-rw-r--r--gnu/usr.bin/gdb/gdb/nm.h128
-rw-r--r--gnu/usr.bin/gdb/gdb/tm.h70
-rw-r--r--gnu/usr.bin/gdb/gdb/version.c3
-rw-r--r--gnu/usr.bin/gdb/gdb/xm.h23
-rw-r--r--gnu/usr.bin/gdb/gdbreplay/Makefile17
-rw-r--r--gnu/usr.bin/gdb/gdbserver/Makefile17
-rw-r--r--gnu/usr.bin/gdb/gdbserver/low-fbsd.c433
-rw-r--r--gnu/usr.bin/gdb/libiberty/Makefile15
-rw-r--r--gnu/usr.bin/gdb/libiberty/alloca-conf.h16
-rw-r--r--gnu/usr.bin/gdb/libiberty/config.h7
-rw-r--r--gnu/usr.bin/genclass/Makefile53
-rw-r--r--gnu/usr.bin/gperf/Makefile16
-rw-r--r--gnu/usr.bin/gperf/doc/Makefile9
-rw-r--r--gnu/usr.bin/grep/AUTHORS29
-rw-r--r--gnu/usr.bin/grep/COPYING339
-rw-r--r--gnu/usr.bin/grep/Makefile35
-rw-r--r--gnu/usr.bin/grep/NEWS35
-rw-r--r--gnu/usr.bin/grep/PROJECTS15
-rw-r--r--gnu/usr.bin/grep/README28
-rw-r--r--gnu/usr.bin/grep/dfa.c2550
-rw-r--r--gnu/usr.bin/grep/dfa.h360
-rw-r--r--gnu/usr.bin/grep/getopt.c731
-rw-r--r--gnu/usr.bin/grep/getopt.h129
-rw-r--r--gnu/usr.bin/grep/getpagesize.h42
-rw-r--r--gnu/usr.bin/grep/grep.1410
-rw-r--r--gnu/usr.bin/grep/grep.c1103
-rw-r--r--gnu/usr.bin/grep/grep.h53
-rw-r--r--gnu/usr.bin/grep/kwset.c805
-rw-r--r--gnu/usr.bin/grep/kwset.h69
-rw-r--r--gnu/usr.bin/grep/obstack.c454
-rw-r--r--gnu/usr.bin/grep/obstack.h484
-rw-r--r--gnu/usr.bin/grep/search.c481
-rw-r--r--gnu/usr.bin/grep/tests/check.sh24
-rw-r--r--gnu/usr.bin/grep/tests/khadafy.lines32
-rw-r--r--gnu/usr.bin/grep/tests/khadafy.regexp1
-rw-r--r--gnu/usr.bin/grep/tests/scriptgen.awk10
-rw-r--r--gnu/usr.bin/grep/tests/spencer.tests122
-rw-r--r--gnu/usr.bin/groff/Makefile16
-rw-r--r--gnu/usr.bin/groff/Makefile.cfg132
-rw-r--r--gnu/usr.bin/groff/Makefile.dev33
-rw-r--r--gnu/usr.bin/groff/Makefile.inc5
-rw-r--r--gnu/usr.bin/groff/Makefile.tty55
-rw-r--r--gnu/usr.bin/groff/addftinfo/Makefile13
-rw-r--r--gnu/usr.bin/groff/devX100-12/Makefile7
-rw-r--r--gnu/usr.bin/groff/devX100/Makefile7
-rw-r--r--gnu/usr.bin/groff/devX75-12/Makefile7
-rw-r--r--gnu/usr.bin/groff/devX75/Makefile7
-rw-r--r--gnu/usr.bin/groff/devascii/Makefile7
-rw-r--r--gnu/usr.bin/groff/devdvi/Makefile18
-rw-r--r--gnu/usr.bin/groff/devkoi8-r/Makefile6
-rw-r--r--gnu/usr.bin/groff/devlatin1/Makefile6
-rw-r--r--gnu/usr.bin/groff/devlj4/Makefile30
-rw-r--r--gnu/usr.bin/groff/devps/Makefile40
-rw-r--r--gnu/usr.bin/groff/eqn/Makefile26
-rw-r--r--gnu/usr.bin/groff/font/Makefile.dev33
-rw-r--r--gnu/usr.bin/groff/font/Makefile.tty55
-rw-r--r--gnu/usr.bin/groff/font/devkoi8-r/DESC.proto8
-rw-r--r--gnu/usr.bin/groff/font/devkoi8-r/R.proto239
-rw-r--r--gnu/usr.bin/groff/grodvi/Makefile13
-rw-r--r--gnu/usr.bin/groff/groff/Makefile13
-rw-r--r--gnu/usr.bin/groff/grolj4/Makefile13
-rw-r--r--gnu/usr.bin/groff/grops/Makefile13
-rw-r--r--gnu/usr.bin/groff/grotty/Makefile13
-rw-r--r--gnu/usr.bin/groff/include/defs.h9
-rw-r--r--gnu/usr.bin/groff/indxbib/Makefile17
-rw-r--r--gnu/usr.bin/groff/libbib/Makefile13
-rw-r--r--gnu/usr.bin/groff/libdriver/Makefile13
-rw-r--r--gnu/usr.bin/groff/libgroff/Makefile28
-rw-r--r--gnu/usr.bin/groff/lkbib/Makefile13
-rw-r--r--gnu/usr.bin/groff/lookbib/Makefile13
-rw-r--r--gnu/usr.bin/groff/man/Makefile10
-rw-r--r--gnu/usr.bin/groff/mm/Makefile32
-rw-r--r--gnu/usr.bin/groff/nroff/Makefile13
-rw-r--r--gnu/usr.bin/groff/pfbtops/Makefile12
-rw-r--r--gnu/usr.bin/groff/pic/Makefile16
-rw-r--r--gnu/usr.bin/groff/psbb/Makefile10
-rw-r--r--gnu/usr.bin/groff/refer/Makefile14
-rw-r--r--gnu/usr.bin/groff/src/include/defs.h9
-rw-r--r--gnu/usr.bin/groff/src/roff/psroff/psroff.sh2
-rw-r--r--gnu/usr.bin/groff/tbl/Makefile13
-rw-r--r--gnu/usr.bin/groff/tfmtodit/Makefile13
-rw-r--r--gnu/usr.bin/groff/tmac/Makefile48
-rw-r--r--gnu/usr.bin/groff/tmac/hyphen.us-ru4833
-rw-r--r--gnu/usr.bin/groff/troff/Makefile30
-rw-r--r--gnu/usr.bin/gzip/COPYING339
-rw-r--r--gnu/usr.bin/gzip/ChangeLog587
-rw-r--r--gnu/usr.bin/gzip/Makefile44
-rw-r--r--gnu/usr.bin/gzip/NEWS221
-rw-r--r--gnu/usr.bin/gzip/README144
-rw-r--r--gnu/usr.bin/gzip/THANKS276
-rw-r--r--gnu/usr.bin/gzip/TODO58
-rw-r--r--gnu/usr.bin/gzip/algorithm.doc164
-rw-r--r--gnu/usr.bin/gzip/bits.c205
-rw-r--r--gnu/usr.bin/gzip/crypt.c6
-rw-r--r--gnu/usr.bin/gzip/crypt.h12
-rw-r--r--gnu/usr.bin/gzip/deflate.c763
-rw-r--r--gnu/usr.bin/gzip/getopt.c755
-rw-r--r--gnu/usr.bin/gzip/getopt.h127
-rw-r--r--gnu/usr.bin/gzip/gzexe150
-rw-r--r--gnu/usr.bin/gzip/gzexe.143
-rw-r--r--gnu/usr.bin/gzip/gzip.1477
-rw-r--r--gnu/usr.bin/gzip/gzip.c1749
-rw-r--r--gnu/usr.bin/gzip/gzip.h315
-rw-r--r--gnu/usr.bin/gzip/inflate.c956
-rw-r--r--gnu/usr.bin/gzip/lzw.c26
-rw-r--r--gnu/usr.bin/gzip/lzw.h42
-rw-r--r--gnu/usr.bin/gzip/match.S379
-rw-r--r--gnu/usr.bin/gzip/revision.h16
-rw-r--r--gnu/usr.bin/gzip/tailor.h328
-rw-r--r--gnu/usr.bin/gzip/trees.c1075
-rw-r--r--gnu/usr.bin/gzip/unlzh.c401
-rw-r--r--gnu/usr.bin/gzip/unlzw.c377
-rw-r--r--gnu/usr.bin/gzip/unpack.c239
-rw-r--r--gnu/usr.bin/gzip/unzip.c199
-rw-r--r--gnu/usr.bin/gzip/util.c456
-rw-r--r--gnu/usr.bin/gzip/zdiff69
-rw-r--r--gnu/usr.bin/gzip/zdiff.144
-rw-r--r--gnu/usr.bin/gzip/zforce41
-rw-r--r--gnu/usr.bin/gzip/zforce.120
-rw-r--r--gnu/usr.bin/gzip/zgrep72
-rw-r--r--gnu/usr.bin/gzip/zgrep.144
-rw-r--r--gnu/usr.bin/gzip/zgrep.getopt94
-rw-r--r--gnu/usr.bin/gzip/zgrep.libz18
-rw-r--r--gnu/usr.bin/gzip/zip.c117
-rw-r--r--gnu/usr.bin/gzip/zmore51
-rw-r--r--gnu/usr.bin/gzip/zmore.1145
-rw-r--r--gnu/usr.bin/gzip/znew145
-rw-r--r--gnu/usr.bin/gzip/znew.139
-rw-r--r--gnu/usr.bin/ld/Makefile20
-rw-r--r--gnu/usr.bin/ld/PORTING194
-rw-r--r--gnu/usr.bin/ld/dynamic.h380
-rw-r--r--gnu/usr.bin/ld/i386/md-static-funcs.c17
-rw-r--r--gnu/usr.bin/ld/i386/md.c384
-rw-r--r--gnu/usr.bin/ld/i386/md.h245
-rw-r--r--gnu/usr.bin/ld/i386/mdprologue.S93
-rw-r--r--gnu/usr.bin/ld/ld.1293
-rw-r--r--gnu/usr.bin/ld/ld.1aout293
-rw-r--r--gnu/usr.bin/ld/ld.c3825
-rw-r--r--gnu/usr.bin/ld/ld.h387
-rw-r--r--gnu/usr.bin/ld/ldconfig/Makefile13
-rw-r--r--gnu/usr.bin/ld/ldconfig/ldconfig.8147
-rw-r--r--gnu/usr.bin/ld/ldconfig/ldconfig.c581
-rw-r--r--gnu/usr.bin/ld/ldd/Makefile8
-rw-r--r--gnu/usr.bin/ld/ldd/ldd.147
-rw-r--r--gnu/usr.bin/ld/ldd/ldd.c170
-rw-r--r--gnu/usr.bin/ld/ldd/sods.c546
-rw-r--r--gnu/usr.bin/ld/lib.c876
-rw-r--r--gnu/usr.bin/ld/rrs.c1272
-rw-r--r--gnu/usr.bin/ld/rtld/Makefile19
-rw-r--r--gnu/usr.bin/ld/rtld/md-prologue.c39
-rw-r--r--gnu/usr.bin/ld/rtld/rtld.1224
-rw-r--r--gnu/usr.bin/ld/rtld/rtld.c2371
-rw-r--r--gnu/usr.bin/ld/shlib.c342
-rw-r--r--gnu/usr.bin/ld/shlib.h43
-rw-r--r--gnu/usr.bin/ld/sparc/md-static-funcs.c37
-rw-r--r--gnu/usr.bin/ld/sparc/md.c351
-rw-r--r--gnu/usr.bin/ld/sparc/md.h302
-rw-r--r--gnu/usr.bin/ld/sparc/mdprologue.S101
-rw-r--r--gnu/usr.bin/ld/support.c86
-rw-r--r--gnu/usr.bin/ld/support.h35
-rw-r--r--gnu/usr.bin/ld/symbol.c194
-rw-r--r--gnu/usr.bin/ld/symseg.h359
-rw-r--r--gnu/usr.bin/ld/warnings.c805
-rw-r--r--gnu/usr.bin/ld/xbits.c168
-rw-r--r--gnu/usr.bin/man/COPYING339
-rw-r--r--gnu/usr.bin/man/Makefile10
-rw-r--r--gnu/usr.bin/man/Makefile.inc23
-rw-r--r--gnu/usr.bin/man/Makefile.shprog30
-rw-r--r--gnu/usr.bin/man/README134
-rw-r--r--gnu/usr.bin/man/TODO123
-rw-r--r--gnu/usr.bin/man/apropos/Makefile9
-rw-r--r--gnu/usr.bin/man/apropos/apropos.man40
-rw-r--r--gnu/usr.bin/man/apropos/apropos.sh98
-rw-r--r--gnu/usr.bin/man/catman/Makefile7
-rw-r--r--gnu/usr.bin/man/catman/catman.1133
-rw-r--r--gnu/usr.bin/man/catman/catman.perl386
-rw-r--r--gnu/usr.bin/man/lib/Makefile26
-rw-r--r--gnu/usr.bin/man/lib/config.h_dist210
-rw-r--r--gnu/usr.bin/man/lib/gripes.c180
-rw-r--r--gnu/usr.bin/man/lib/gripes.h30
-rw-r--r--gnu/usr.bin/man/lib/util.c160
-rw-r--r--gnu/usr.bin/man/makewhatis/Makefile16
-rw-r--r--gnu/usr.bin/man/makewhatis/makewhatis.1142
-rw-r--r--gnu/usr.bin/man/makewhatis/makewhatis.local.870
-rw-r--r--gnu/usr.bin/man/makewhatis/makewhatis.local.sh58
-rw-r--r--gnu/usr.bin/man/makewhatis/makewhatis.perl519
-rw-r--r--gnu/usr.bin/man/man/Makefile32
-rw-r--r--gnu/usr.bin/man/man/glob.c712
-rw-r--r--gnu/usr.bin/man/man/man.c1544
-rw-r--r--gnu/usr.bin/man/man/man.man139
-rw-r--r--gnu/usr.bin/man/man/ndir.h51
-rw-r--r--gnu/usr.bin/man/man/version.h17
-rw-r--r--gnu/usr.bin/man/manpath/Makefile29
-rw-r--r--gnu/usr.bin/man/manpath/manpath.c525
-rw-r--r--gnu/usr.bin/man/manpath/manpath.config28
-rw-r--r--gnu/usr.bin/man/manpath/manpath.h26
-rw-r--r--gnu/usr.bin/man/manpath/manpath.man67
-rw-r--r--gnu/usr.bin/patch/Makefile16
-rw-r--r--gnu/usr.bin/patch/config.h125
-rw-r--r--gnu/usr.bin/patch/patchlevel.h1
-rw-r--r--gnu/usr.bin/perl/Artistic117
-rw-r--r--gnu/usr.bin/perl/Copying248
-rw-r--r--gnu/usr.bin/perl/Makefile10
-rw-r--r--gnu/usr.bin/perl/README195
-rw-r--r--gnu/usr.bin/perl/VERSION1
-rw-r--r--gnu/usr.bin/perl/Wishlist9
-rw-r--r--gnu/usr.bin/perl/eg/ADB8
-rw-r--r--gnu/usr.bin/perl/eg/README22
-rw-r--r--gnu/usr.bin/perl/eg/changes34
-rw-r--r--gnu/usr.bin/perl/eg/client34
-rw-r--r--gnu/usr.bin/perl/eg/down30
-rw-r--r--gnu/usr.bin/perl/eg/dus22
-rw-r--r--gnu/usr.bin/perl/eg/findcp53
-rw-r--r--gnu/usr.bin/perl/eg/findtar17
-rw-r--r--gnu/usr.bin/perl/eg/g/gcp114
-rw-r--r--gnu/usr.bin/perl/eg/g/gcp.man77
-rw-r--r--gnu/usr.bin/perl/eg/g/ged21
-rw-r--r--gnu/usr.bin/perl/eg/g/ghosts33
-rw-r--r--gnu/usr.bin/perl/eg/g/gsh117
-rw-r--r--gnu/usr.bin/perl/eg/g/gsh.man80
-rw-r--r--gnu/usr.bin/perl/eg/muck141
-rw-r--r--gnu/usr.bin/perl/eg/muck.man21
-rw-r--r--gnu/usr.bin/perl/eg/myrup29
-rw-r--r--gnu/usr.bin/perl/eg/nih10
-rw-r--r--gnu/usr.bin/perl/eg/perlsh15
-rw-r--r--gnu/usr.bin/perl/eg/relink91
-rw-r--r--gnu/usr.bin/perl/eg/rename83
-rw-r--r--gnu/usr.bin/perl/eg/rmfrom7
-rw-r--r--gnu/usr.bin/perl/eg/scan/scan_df51
-rw-r--r--gnu/usr.bin/perl/eg/scan/scan_last57
-rw-r--r--gnu/usr.bin/perl/eg/scan/scan_messages222
-rw-r--r--gnu/usr.bin/perl/eg/scan/scan_passwd30
-rw-r--r--gnu/usr.bin/perl/eg/scan/scan_ps32
-rw-r--r--gnu/usr.bin/perl/eg/scan/scan_sudo54
-rw-r--r--gnu/usr.bin/perl/eg/scan/scan_suid84
-rw-r--r--gnu/usr.bin/perl/eg/scan/scanner87
-rw-r--r--gnu/usr.bin/perl/eg/server27
-rw-r--r--gnu/usr.bin/perl/eg/shmkill24
-rw-r--r--gnu/usr.bin/perl/eg/sysvipc/README9
-rw-r--r--gnu/usr.bin/perl/eg/sysvipc/ipcmsg47
-rw-r--r--gnu/usr.bin/perl/eg/sysvipc/ipcsem46
-rw-r--r--gnu/usr.bin/perl/eg/sysvipc/ipcshm50
-rw-r--r--gnu/usr.bin/perl/eg/travesty46
-rw-r--r--gnu/usr.bin/perl/eg/van/empty45
-rw-r--r--gnu/usr.bin/perl/eg/van/unvanish66
-rw-r--r--gnu/usr.bin/perl/eg/van/vanexp21
-rw-r--r--gnu/usr.bin/perl/eg/van/vanish65
-rw-r--r--gnu/usr.bin/perl/eg/who13
-rw-r--r--gnu/usr.bin/perl/emacs/perl-mode.el631
-rw-r--r--gnu/usr.bin/perl/emacs/perldb.el423
-rw-r--r--gnu/usr.bin/perl/emacs/perldb.pl568
-rw-r--r--gnu/usr.bin/perl/emacs/tedstuff296
-rw-r--r--gnu/usr.bin/perl/h2pl/README71
-rw-r--r--gnu/usr.bin/perl/h2pl/cbreak.pl34
-rw-r--r--gnu/usr.bin/perl/h2pl/cbreak2.pl33
-rw-r--r--gnu/usr.bin/perl/h2pl/eg/sizeof.ph14
-rw-r--r--gnu/usr.bin/perl/h2pl/eg/sys/errno.pl92
-rw-r--r--gnu/usr.bin/perl/h2pl/eg/sys/ioctl.pl186
-rw-r--r--gnu/usr.bin/perl/h2pl/eg/sysexits.pl16
-rw-r--r--gnu/usr.bin/perl/h2pl/getioctlsizes13
-rw-r--r--gnu/usr.bin/perl/h2pl/mksizes42
-rw-r--r--gnu/usr.bin/perl/h2pl/mkvars31
-rw-r--r--gnu/usr.bin/perl/h2pl/tcbreak17
-rw-r--r--gnu/usr.bin/perl/h2pl/tcbreak217
-rw-r--r--gnu/usr.bin/perl/lib/Makefile17
-rw-r--r--gnu/usr.bin/perl/lib/abbrev.pl33
-rw-r--r--gnu/usr.bin/perl/lib/assert.pl52
-rw-r--r--gnu/usr.bin/perl/lib/bigfloat.pl233
-rw-r--r--gnu/usr.bin/perl/lib/bigint.pl271
-rw-r--r--gnu/usr.bin/perl/lib/bigrat.pl148
-rw-r--r--gnu/usr.bin/perl/lib/cacheout.pl40
-rw-r--r--gnu/usr.bin/perl/lib/chat2.pl339
-rw-r--r--gnu/usr.bin/perl/lib/complete.pl110
-rw-r--r--gnu/usr.bin/perl/lib/ctime.pl51
-rw-r--r--gnu/usr.bin/perl/lib/dumpvar.pl37
-rw-r--r--gnu/usr.bin/perl/lib/exceptions.pl54
-rw-r--r--gnu/usr.bin/perl/lib/fastcwd.pl35
-rw-r--r--gnu/usr.bin/perl/lib/find.pl106
-rw-r--r--gnu/usr.bin/perl/lib/finddepth.pl105
-rw-r--r--gnu/usr.bin/perl/lib/flush.pl23
-rw-r--r--gnu/usr.bin/perl/lib/getcwd.pl62
-rw-r--r--gnu/usr.bin/perl/lib/gethostname.pl36
-rw-r--r--gnu/usr.bin/perl/lib/getopt.pl41
-rw-r--r--gnu/usr.bin/perl/lib/getopts.pl50
-rw-r--r--gnu/usr.bin/perl/lib/importenv.pl16
-rw-r--r--gnu/usr.bin/perl/lib/look.pl44
-rw-r--r--gnu/usr.bin/perl/lib/newgetopt.pl271
-rw-r--r--gnu/usr.bin/perl/lib/open2.pl54
-rw-r--r--gnu/usr.bin/perl/lib/perldb.pl598
-rw-r--r--gnu/usr.bin/perl/lib/pwd.pl72
-rw-r--r--gnu/usr.bin/perl/lib/shellwords.pl48
-rw-r--r--gnu/usr.bin/perl/lib/stat.pl31
-rw-r--r--gnu/usr.bin/perl/lib/syslog.pl224
-rw-r--r--gnu/usr.bin/perl/lib/termcap.pl165
-rw-r--r--gnu/usr.bin/perl/lib/timelocal.pl83
-rw-r--r--gnu/usr.bin/perl/lib/validate.pl104
-rw-r--r--gnu/usr.bin/perl/misc/c2ph1071
-rw-r--r--gnu/usr.bin/perl/misc/c2ph.1191
-rw-r--r--gnu/usr.bin/perl/misc/pstruct1071
-rw-r--r--gnu/usr.bin/perl/perl/EXTERN.h29
-rw-r--r--gnu/usr.bin/perl/perl/INTERN.h29
-rw-r--r--gnu/usr.bin/perl/perl/Makefile17
-rw-r--r--gnu/usr.bin/perl/perl/arg.h1001
-rw-r--r--gnu/usr.bin/perl/perl/array.c290
-rw-r--r--gnu/usr.bin/perl/perl/array.h48
-rwxr-xr-xgnu/usr.bin/perl/perl/cflags91
-rw-r--r--gnu/usr.bin/perl/perl/cmd.c1266
-rw-r--r--gnu/usr.bin/perl/perl/cmd.h182
-rw-r--r--gnu/usr.bin/perl/perl/config.H892
-rw-r--r--gnu/usr.bin/perl/perl/config.h771
-rw-r--r--gnu/usr.bin/perl/perl/config.sh268
-rw-r--r--gnu/usr.bin/perl/perl/cons.c1453
-rw-r--r--gnu/usr.bin/perl/perl/consarg.c1302
-rw-r--r--gnu/usr.bin/perl/perl/crypt.c200
-rw-r--r--gnu/usr.bin/perl/perl/doarg.c1856
-rw-r--r--gnu/usr.bin/perl/perl/doio.c2978
-rw-r--r--gnu/usr.bin/perl/perl/dolist.c1976
-rw-r--r--gnu/usr.bin/perl/perl/dump.c379
-rw-r--r--gnu/usr.bin/perl/perl/eval.c3016
-rw-r--r--gnu/usr.bin/perl/perl/form.c422
-rw-r--r--gnu/usr.bin/perl/perl/form.h51
-rw-r--r--gnu/usr.bin/perl/perl/handy.h153
-rw-r--r--gnu/usr.bin/perl/perl/hash.c718
-rw-r--r--gnu/usr.bin/perl/perl/hash.h78
-rw-r--r--gnu/usr.bin/perl/perl/patchlevel.h1
-rw-r--r--gnu/usr.bin/perl/perl/perl.16022
-rw-r--r--gnu/usr.bin/perl/perl/perl.c1484
-rw-r--r--gnu/usr.bin/perl/perl/perl.h1071
-rw-r--r--gnu/usr.bin/perl/perl/perly.c3063
-rw-r--r--gnu/usr.bin/perl/perl/perly.h83
-rw-r--r--gnu/usr.bin/perl/perl/regcomp.c1481
-rw-r--r--gnu/usr.bin/perl/perl/regcomp.h203
-rw-r--r--gnu/usr.bin/perl/perl/regexec.c913
-rw-r--r--gnu/usr.bin/perl/perl/regexp.h56
-rw-r--r--gnu/usr.bin/perl/perl/spat.h49
-rw-r--r--gnu/usr.bin/perl/perl/stab.c1061
-rw-r--r--gnu/usr.bin/perl/perl/stab.h148
-rw-r--r--gnu/usr.bin/perl/perl/str.c1605
-rw-r--r--gnu/usr.bin/perl/perl/str.h174
-rw-r--r--gnu/usr.bin/perl/perl/t/README11
-rwxr-xr-xgnu/usr.bin/perl/perl/t/TEST102
-rwxr-xr-xgnu/usr.bin/perl/perl/t/base/cond.t19
-rwxr-xr-xgnu/usr.bin/perl/perl/t/base/if.t11
-rwxr-xr-xgnu/usr.bin/perl/perl/t/base/lex.t78
-rwxr-xr-xgnu/usr.bin/perl/perl/t/base/pat.t11
-rwxr-xr-xgnu/usr.bin/perl/perl/t/base/term.t42
-rwxr-xr-xgnu/usr.bin/perl/perl/t/cmd/elsif.t25
-rwxr-xr-xgnu/usr.bin/perl/perl/t/cmd/for.t49
-rwxr-xr-xgnu/usr.bin/perl/perl/t/cmd/mod.t33
-rwxr-xr-xgnu/usr.bin/perl/perl/t/cmd/subval.t179
-rwxr-xr-xgnu/usr.bin/perl/perl/t/cmd/switch.t75
-rwxr-xr-xgnu/usr.bin/perl/perl/t/cmd/while.t110
-rwxr-xr-xgnu/usr.bin/perl/perl/t/comp/cmdopt.t83
-rwxr-xr-xgnu/usr.bin/perl/perl/t/comp/cpp.t51
-rwxr-xr-xgnu/usr.bin/perl/perl/t/comp/decl.t49
-rwxr-xr-xgnu/usr.bin/perl/perl/t/comp/multiline.t40
-rwxr-xr-xgnu/usr.bin/perl/perl/t/comp/package.t33
-rwxr-xr-xgnu/usr.bin/perl/perl/t/comp/script.t23
-rwxr-xr-xgnu/usr.bin/perl/perl/t/comp/term.t35
-rwxr-xr-xgnu/usr.bin/perl/perl/t/io/argv.t36
-rwxr-xr-xgnu/usr.bin/perl/perl/t/io/dup.t32
-rwxr-xr-xgnu/usr.bin/perl/perl/t/io/fs.t85
-rwxr-xr-xgnu/usr.bin/perl/perl/t/io/inplace.t21
-rwxr-xr-xgnu/usr.bin/perl/perl/t/io/pipe.t56
-rwxr-xr-xgnu/usr.bin/perl/perl/t/io/print.t32
-rwxr-xr-xgnu/usr.bin/perl/perl/t/io/tell.t44
-rwxr-xr-xgnu/usr.bin/perl/perl/t/lib/big.t280
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/append.t21
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/array.t120
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/auto.t48
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/chop.t30
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/cond.t12
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/dbm.t106
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/delete.t29
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/do.t44
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/each.t53
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/eval.t57
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/exec.t21
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/exp.t27
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/flip.t26
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/fork.t16
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/glob.t22
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/goto.t33
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/groups.t47
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/index.t42
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/int.t17
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/join.t12
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/list.t83
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/local.t45
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/magic.t32
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/mkdir.t15
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/oct.t9
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/ord.t14
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/pack.t20
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/pat.t184
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/push.t44
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/range.t36
-rw-r--r--gnu/usr.bin/perl/perl/t/op/re_tests274
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/read.t20
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/readdir.t20
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/regexp.t35
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/repeat.t42
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/s.t179
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/sleep.t8
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/sort.t48
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/split.t57
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/sprintf.t8
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/stat.t176
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/study.t69
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/substr.t47
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/time.t43
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/undef.t56
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/unshift.t14
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/vec.t24
-rwxr-xr-xgnu/usr.bin/perl/perl/t/op/write.t129
-rw-r--r--gnu/usr.bin/perl/perl/t/printme6
-rw-r--r--gnu/usr.bin/perl/perl/tdoio.c2972
-rw-r--r--gnu/usr.bin/perl/perl/toke.c2785
-rw-r--r--gnu/usr.bin/perl/perl/usersub.c151
-rw-r--r--gnu/usr.bin/perl/perl/util.c1790
-rw-r--r--gnu/usr.bin/perl/perl/util.h64
-rw-r--r--gnu/usr.bin/perl/sperl/Makefile30
-rw-r--r--gnu/usr.bin/perl/tperl/Makefile28
-rw-r--r--gnu/usr.bin/perl/usub/Makefile32
-rw-r--r--gnu/usr.bin/perl/usub/README117
-rw-r--r--gnu/usr.bin/perl/usub/curses.mus813
-rwxr-xr-xgnu/usr.bin/perl/usub/man2mus66
-rwxr-xr-xgnu/usr.bin/perl/usub/mus135
-rwxr-xr-xgnu/usr.bin/perl/usub/pager190
-rw-r--r--gnu/usr.bin/perl/usub/usersub.c77
-rw-r--r--gnu/usr.bin/perl/x2p/EXTERN.h29
-rw-r--r--gnu/usr.bin/perl/x2p/INTERN.h29
-rw-r--r--gnu/usr.bin/perl/x2p/Makefile23
-rw-r--r--gnu/usr.bin/perl/x2p/a2p.1199
-rw-r--r--gnu/usr.bin/perl/x2p/a2p.h344
-rw-r--r--gnu/usr.bin/perl/x2p/a2p.y406
-rw-r--r--gnu/usr.bin/perl/x2p/a2py.c1304
-rwxr-xr-xgnu/usr.bin/perl/x2p/find2perl568
-rwxr-xr-xgnu/usr.bin/perl/x2p/h2ph262
-rwxr-xr-xgnu/usr.bin/perl/x2p/h2ph.141
-rw-r--r--gnu/usr.bin/perl/x2p/handy.h49
-rw-r--r--gnu/usr.bin/perl/x2p/hash.c253
-rw-r--r--gnu/usr.bin/perl/x2p/hash.h63
-rwxr-xr-xgnu/usr.bin/perl/x2p/s2p769
-rw-r--r--gnu/usr.bin/perl/x2p/s2p.1108
-rw-r--r--gnu/usr.bin/perl/x2p/str.c470
-rw-r--r--gnu/usr.bin/perl/x2p/str.h49
-rw-r--r--gnu/usr.bin/perl/x2p/util.c271
-rw-r--r--gnu/usr.bin/perl/x2p/util.h58
-rw-r--r--gnu/usr.bin/perl/x2p/walk.c2089
-rw-r--r--gnu/usr.bin/ptx/COPYING339
-rw-r--r--gnu/usr.bin/ptx/ChangeLog546
-rw-r--r--gnu/usr.bin/ptx/Makefile12
-rw-r--r--gnu/usr.bin/ptx/NEWS53
-rw-r--r--gnu/usr.bin/ptx/README23
-rw-r--r--gnu/usr.bin/ptx/THANKS23
-rw-r--r--gnu/usr.bin/ptx/TODO94
-rw-r--r--gnu/usr.bin/ptx/alloca.c484
-rw-r--r--gnu/usr.bin/ptx/argmatch.c94
-rw-r--r--gnu/usr.bin/ptx/bumpalloc.h58
-rw-r--r--gnu/usr.bin/ptx/check-out65
-rw-r--r--gnu/usr.bin/ptx/config.h57
-rw-r--r--gnu/usr.bin/ptx/diacrit.c148
-rw-r--r--gnu/usr.bin/ptx/diacrit.h16
-rw-r--r--gnu/usr.bin/ptx/doc/Makefile5
-rw-r--r--gnu/usr.bin/ptx/doc/ptx.texinfo554
-rw-r--r--gnu/usr.bin/ptx/error.c117
-rw-r--r--gnu/usr.bin/ptx/examples/README21
-rw-r--r--gnu/usr.bin/ptx/examples/ajay/Makefile28
-rw-r--r--gnu/usr.bin/ptx/examples/ajay/README41
-rw-r--r--gnu/usr.bin/ptx/examples/ajay/footer.tex1
-rw-r--r--gnu/usr.bin/ptx/examples/ajay/header.tex21
-rw-r--r--gnu/usr.bin/ptx/examples/ajay/tip.forgptx10
-rw-r--r--gnu/usr.bin/ptx/examples/ajay/x.pl22
-rw-r--r--gnu/usr.bin/ptx/examples/ignore/README65
-rw-r--r--gnu/usr.bin/ptx/examples/ignore/bix109
-rw-r--r--gnu/usr.bin/ptx/examples/ignore/eign163
-rwxr-xr-xgnu/usr.bin/ptx/examples/include.pl79
-rw-r--r--gnu/usr.bin/ptx/examples/latex/Makefile15
-rw-r--r--gnu/usr.bin/ptx/examples/latex/README10
-rw-r--r--gnu/usr.bin/ptx/examples/latex/latex.tex11
-rw-r--r--gnu/usr.bin/ptx/examples/latex/table.tex65
-rw-r--r--gnu/usr.bin/ptx/examples/luke/README2
-rw-r--r--gnu/usr.bin/ptx/examples/luke/xxroff.sh108
-rw-r--r--gnu/usr.bin/ptx/getopt.c757
-rw-r--r--gnu/usr.bin/ptx/getopt.h129
-rw-r--r--gnu/usr.bin/ptx/getopt1.c187
-rwxr-xr-xgnu/usr.bin/ptx/mkinstalldirs35
-rw-r--r--gnu/usr.bin/ptx/ptx.c2237
-rw-r--r--gnu/usr.bin/ptx/xmalloc.c88
-rw-r--r--gnu/usr.bin/rcs/CREDITS24
-rw-r--r--gnu/usr.bin/rcs/Makefile3
-rw-r--r--gnu/usr.bin/rcs/Makefile.inc7
-rw-r--r--gnu/usr.bin/rcs/NEWS548
-rw-r--r--gnu/usr.bin/rcs/REFS90
-rw-r--r--gnu/usr.bin/rcs/ci/Makefile8
-rw-r--r--gnu/usr.bin/rcs/ci/ci.1898
-rw-r--r--gnu/usr.bin/rcs/ci/ci.c1318
-rw-r--r--gnu/usr.bin/rcs/co/Makefile8
-rw-r--r--gnu/usr.bin/rcs/co/co.1736
-rw-r--r--gnu/usr.bin/rcs/co/co.c826
-rw-r--r--gnu/usr.bin/rcs/doc/rcs.ms1518
-rw-r--r--gnu/usr.bin/rcs/doc/rcs_func.ms95
-rw-r--r--gnu/usr.bin/rcs/ident/Makefile8
-rw-r--r--gnu/usr.bin/rcs/ident/ident.1182
-rw-r--r--gnu/usr.bin/rcs/ident/ident.c270
-rw-r--r--gnu/usr.bin/rcs/lib/Makefile14
-rw-r--r--gnu/usr.bin/rcs/lib/conf.h399
-rw-r--r--gnu/usr.bin/rcs/lib/maketime.c344
-rw-r--r--gnu/usr.bin/rcs/lib/maketime.h39
-rw-r--r--gnu/usr.bin/rcs/lib/merger.c148
-rw-r--r--gnu/usr.bin/rcs/lib/partime.c701
-rw-r--r--gnu/usr.bin/rcs/lib/partime.h71
-rw-r--r--gnu/usr.bin/rcs/lib/rcsbase.h762
-rw-r--r--gnu/usr.bin/rcs/lib/rcsedit.c1952
-rw-r--r--gnu/usr.bin/rcs/lib/rcsfcmp.c354
-rw-r--r--gnu/usr.bin/rcs/lib/rcsfnms.c1127
-rw-r--r--gnu/usr.bin/rcs/lib/rcsgen.c681
-rw-r--r--gnu/usr.bin/rcs/lib/rcskeep.c452
-rw-r--r--gnu/usr.bin/rcs/lib/rcskeys.c186
-rw-r--r--gnu/usr.bin/rcs/lib/rcslex.c1568
-rw-r--r--gnu/usr.bin/rcs/lib/rcsmap.c69
-rw-r--r--gnu/usr.bin/rcs/lib/rcsrev.c911
-rw-r--r--gnu/usr.bin/rcs/lib/rcssyn.c681
-rw-r--r--gnu/usr.bin/rcs/lib/rcstime.c191
-rw-r--r--gnu/usr.bin/rcs/lib/rcsutil.c1398
-rw-r--r--gnu/usr.bin/rcs/lib/version.c2
-rw-r--r--gnu/usr.bin/rcs/merge/Makefile8
-rw-r--r--gnu/usr.bin/rcs/merge/merge.1137
-rw-r--r--gnu/usr.bin/rcs/merge/merge.c113
-rw-r--r--gnu/usr.bin/rcs/rcs/Makefile11
-rw-r--r--gnu/usr.bin/rcs/rcs/rcs.1454
-rw-r--r--gnu/usr.bin/rcs/rcs/rcs.c1629
-rw-r--r--gnu/usr.bin/rcs/rcs/rcsfile.5426
-rw-r--r--gnu/usr.bin/rcs/rcs/rcsintro.1302
-rw-r--r--gnu/usr.bin/rcs/rcsclean/Makefile8
-rw-r--r--gnu/usr.bin/rcs/rcsclean/rcsclean.1203
-rw-r--r--gnu/usr.bin/rcs/rcsclean/rcsclean.c333
-rw-r--r--gnu/usr.bin/rcs/rcsdiff/Makefile8
-rw-r--r--gnu/usr.bin/rcs/rcsdiff/rcsdiff.1158
-rw-r--r--gnu/usr.bin/rcs/rcsdiff/rcsdiff.c480
-rw-r--r--gnu/usr.bin/rcs/rcsfreeze/Makefile8
-rw-r--r--gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.168
-rw-r--r--gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh99
-rw-r--r--gnu/usr.bin/rcs/rcsmerge/Makefile8
-rw-r--r--gnu/usr.bin/rcs/rcsmerge/rcsmerge.1189
-rw-r--r--gnu/usr.bin/rcs/rcsmerge/rcsmerge.c286
-rwxr-xr-xgnu/usr.bin/rcs/rcstest454
-rw-r--r--gnu/usr.bin/rcs/rlog/Makefile8
-rw-r--r--gnu/usr.bin/rcs/rlog/rlog.1318
-rw-r--r--gnu/usr.bin/rcs/rlog/rlog.c1290
-rw-r--r--gnu/usr.bin/sdiff/Makefile16
-rw-r--r--gnu/usr.bin/sdiff/sdiff.1198
-rw-r--r--gnu/usr.bin/send-pr/COPYING339
-rw-r--r--gnu/usr.bin/send-pr/Makefile39
-rw-r--r--gnu/usr.bin/send-pr/README43
-rw-r--r--gnu/usr.bin/send-pr/categories9
-rw-r--r--gnu/usr.bin/send-pr/doc/Makefile4
-rw-r--r--gnu/usr.bin/send-pr/doc/categ.texi123
-rw-r--r--gnu/usr.bin/send-pr/doc/fields.texi518
-rw-r--r--gnu/usr.bin/send-pr/doc/s-usage.texi522
-rw-r--r--gnu/usr.bin/send-pr/doc/send-pr.texi657
-rw-r--r--gnu/usr.bin/send-pr/doc/states.texi53
-rw-r--r--gnu/usr.bin/send-pr/doc/version.texi1
-rwxr-xr-xgnu/usr.bin/send-pr/install-sid.sh82
-rw-r--r--gnu/usr.bin/send-pr/send-pr-el.in744
-rw-r--r--gnu/usr.bin/send-pr/send-pr.1246
-rw-r--r--gnu/usr.bin/send-pr/send-pr.sh552
-rw-r--r--gnu/usr.bin/sort/COPYING339
-rw-r--r--gnu/usr.bin/sort/Makefile6
-rw-r--r--gnu/usr.bin/sort/config.h123
-rw-r--r--gnu/usr.bin/sort/error.c129
-rw-r--r--gnu/usr.bin/sort/error.h44
-rw-r--r--gnu/usr.bin/sort/getopt.c770
-rw-r--r--gnu/usr.bin/sort/getopt.h129
-rw-r--r--gnu/usr.bin/sort/getopt1.c180
-rw-r--r--gnu/usr.bin/sort/long-options.c79
-rw-r--r--gnu/usr.bin/sort/long-options.h10
-rw-r--r--gnu/usr.bin/sort/sort.1231
-rw-r--r--gnu/usr.bin/sort/sort.c2178
-rw-r--r--gnu/usr.bin/sort/system.h205
-rw-r--r--gnu/usr.bin/sort/version.c3
-rw-r--r--gnu/usr.bin/sort/version.h1
-rw-r--r--gnu/usr.bin/sort/xstrtod.c48
-rw-r--r--gnu/usr.bin/sort/xstrtod.h15
-rw-r--r--gnu/usr.bin/tar/COPYING339
-rw-r--r--gnu/usr.bin/tar/ChangeLog1738
-rw-r--r--gnu/usr.bin/tar/Makefile17
-rw-r--r--gnu/usr.bin/tar/Makefile.gnu185
-rw-r--r--gnu/usr.bin/tar/README40
-rw-r--r--gnu/usr.bin/tar/buffer.c1584
-rw-r--r--gnu/usr.bin/tar/create.c1478
-rw-r--r--gnu/usr.bin/tar/diffarch.c759
-rw-r--r--gnu/usr.bin/tar/extract.c946
-rw-r--r--gnu/usr.bin/tar/getdate.y970
-rw-r--r--gnu/usr.bin/tar/getoldopt.c96
-rw-r--r--gnu/usr.bin/tar/getopt.c712
-rw-r--r--gnu/usr.bin/tar/getopt.h125
-rw-r--r--gnu/usr.bin/tar/getopt1.c161
-rw-r--r--gnu/usr.bin/tar/getpagesize.h38
-rw-r--r--gnu/usr.bin/tar/gnu.c677
-rw-r--r--gnu/usr.bin/tar/list.c886
-rw-r--r--gnu/usr.bin/tar/mangle.c270
-rw-r--r--gnu/usr.bin/tar/msd_dir.h44
-rw-r--r--gnu/usr.bin/tar/names.c149
-rw-r--r--gnu/usr.bin/tar/open3.h67
-rw-r--r--gnu/usr.bin/tar/pathmax.h53
-rw-r--r--gnu/usr.bin/tar/port.c1256
-rw-r--r--gnu/usr.bin/tar/port.h215
-rw-r--r--gnu/usr.bin/tar/rmt.h98
-rw-r--r--gnu/usr.bin/tar/rtapelib.c570
-rw-r--r--gnu/usr.bin/tar/tar.1434
-rw-r--r--gnu/usr.bin/tar/tar.c1560
-rw-r--r--gnu/usr.bin/tar/tar.h295
-rw-r--r--gnu/usr.bin/tar/update.c585
-rw-r--r--gnu/usr.bin/tar/version.c1
-rw-r--r--gnu/usr.bin/texinfo/Makefile7
-rw-r--r--gnu/usr.bin/texinfo/Makefile.inc11
-rw-r--r--gnu/usr.bin/texinfo/doc/Makefile7
-rw-r--r--gnu/usr.bin/texinfo/info/Makefile22
-rw-r--r--gnu/usr.bin/texinfo/install-info/Makefile16
-rw-r--r--gnu/usr.bin/texinfo/install-info/install-info.155
-rw-r--r--gnu/usr.bin/texinfo/libtxi/Makefile11
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/Makefile18
-rw-r--r--gnu/usr.sbin/Makefile6
-rw-r--r--gnu/usr.sbin/Makefile.inc3
1383 files changed, 0 insertions, 411985 deletions
diff --git a/gnu/COPYING b/gnu/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/COPYING.LIB b/gnu/COPYING.LIB
deleted file mode 100644
index eb685a5..0000000
--- a/gnu/COPYING.LIB
+++ /dev/null
@@ -1,481 +0,0 @@
- GNU LIBRARY GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the library GPL. It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it. You can use it for
-your libraries, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
-permission to copy, distribute and/or modify the library.
-
- Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library. If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software. To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
- Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs. This
-license, the GNU Library General Public License, applies to certain
-designated libraries. This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
- The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it. Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program. However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
- Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries. We
-concluded that weaker conditions might promote sharing better.
-
- However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves. This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them. (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.) The hope is that this
-will lead to faster development of free libraries.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, while the latter only
-works together with the library.
-
- Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-
- GNU LIBRARY GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License"). Each licensee is
-addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also compile or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- c) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- d) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/gnu/Makefile b/gnu/Makefile
deleted file mode 100644
index 8892540..0000000
--- a/gnu/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# @(#)Makefile 5.33.1.1 (Berkeley) 5/6/91
-# $Id$
-
-SUBDIR= include lib libexec usr.bin usr.sbin
-
-.include <bsd.subdir.mk>
diff --git a/gnu/gnu2bmake/README b/gnu/gnu2bmake/README
deleted file mode 100644
index 3daac9e..0000000
--- a/gnu/gnu2bmake/README
+++ /dev/null
@@ -1,36 +0,0 @@
-This directory contains tools to convert GNU-distributions into bmake-able
-trees to be included in the FreeBSD distribution.
-
-*** If you want to hack and of the GNU-sources, get the real thing !
-*** We only do this because it is easier for us to cut a release when
-*** all directories are "bmakeable".
-
-The tools are written in Tcl, so you need to install that first.
-
-If there is a patch-file, you should apply that to the distribution first.
-
-You should read the tcl-script first, at least the beginning, to see if there
-are any special instructions.
-
-We try to get these patches rolled back into the GNU-distributions, to avoid
-code-drift. Please consider very carefully before doing something which isn't
-general enough to make it back into the GNU-dist.
-
-If you want to create a new script, here are some hints:
-
- Get as much info as you can from the Makefiles macros.
-
- Use this sequence to test:
- make all
- make clean ; make all
- make cleandir ; make depend ; make all ; make install
- make cleandir ; make obj ; make depend ; make all ; make install
- make cleandir
-
- Remember to install man-pages (and .texi files ?)
-
-Thanks to Bruce for the patches to gcc, he knows a LOT more about gcc
-than I do...
-
-Poul-Henning Kamp
-phk@login.dkuug.dk
diff --git a/gnu/gnu2bmake/gcc-2.6.0.patch b/gnu/gnu2bmake/gcc-2.6.0.patch
deleted file mode 100644
index dfcb2d1..0000000
--- a/gnu/gnu2bmake/gcc-2.6.0.patch
+++ /dev/null
@@ -1,513 +0,0 @@
-I have removed the "ljo-Fortran" stuff. It doesn't belong in cc. /phk
-
-From kralizec.zeta.org.au!bde Sat Jul 30 22:53:11 1994
-Return-Path: <bde@kralizec.zeta.org.au>
-Received: from warrane.connect.com.au by tfs.com (smail3.1.28.1) with SMTP
- id m0qUTpa-0003wvC; Sat, 30 Jul 94 22:53 PDT
-Received: from kralizec.zeta.org.au by warrane.connect.com.au with SMTP id AA24021
- (5.67b8/IDA-1.5 for <phk@TFS.COM>); Sun, 31 Jul 1994 15:51:38 +1000
-Received: (from bde@localhost) by kralizec.zeta.org.au (8.6.9/8.6.9) id PAA00298 for phk@TFS.COM; Sun, 31 Jul 1994 15:51:11 +1000
-Date: Sun, 31 Jul 1994 15:51:11 +1000
-From: Bruce Evans <bde@kralizec.zeta.org.au>
-Message-Id: <199407310551.PAA00298@kralizec.zeta.org.au>
-To: phk@tfs.com
-Subject: Re: gcc-2.6.0, diff netbsd/freebsd
-
----
->> I've compiled nothing else with 2.6.0, but it bootstraps fine on my
->> 1.1R system. What's the problem with stddef.h? I haven't had any
->> troubles here with that file.
->Probably nothing serious, but I already has it on my list.
-
-Here are the diffs for my port of gcc-2.6.0. FreeBSD-1.1.5 and 4.4lite
-have an amazing number of bugs in involving namespace pollution from the
-runetype stuff. rune_t should never have been in <stddef.h>. <ctype.h>
-does not compile if _ANSI_SOURCE is defined ...
-
-Bruce
-
-Makefile.in:
- Rip out debugging stuff from libgcc.a the same as FreeBSD does.
-
-final.c:
- o If NO_PROFILE_DATA is defined, don't waste space for unused
- profile data.
-
-config/i386/freebsd.h:
- o Define specs together near the start.
- o For -p and -pg, put -Bstatic in LINK_SPEC instead of in LIB_SPEC
- so that it gets seen early enough when other libraries are used.
- o Update wchar_t stuff. `wchar_t foo[] = "123";' is broken in
- FreeBSD-1.1.5 because wchar_t was changed without changing gcc.
- I guess nothing actually uses wchar_t :-).
- o FUNCTION_PROFILER: don't waste space and time for unused profile
- data and pointer to it. Compatible with FreeBSD-1.x.
- o FUNCTION_PROFILER_EPILOGUE: for accurate profiling if there's
- a readable clock. Incompatible with FreeBSD-1.x (hide it with
- #if 0, or add a dummy mexitcount to the user mcount file and
- a real mexitexit to the kernel mcount file). Need a -mflag for
- this. Want more profiling stuff (profile before function
- prologue...) from osfrose.h.
- o Fixed white space in "svr4" stuff. Actually it's osfrose stuff.
- Formatting now matches osfrose.h.
-
-config/i386/i386.c:
- o Fix bugs: profiling may use the pic register. Need a macro for
- this - it is machine-dependent. It is already fixed in osfrose.h
- by not using the functions in i386.c.
- o Support FUNCTION_PROFILER_EPILOGUE. Avoiding the use of the pic
- register is even more complicated for the epilogue than for the
- prologue. We don't attempt to. See osfrose.h for the prologue.
-
-config/i386/i386.h:
- o Avoid average 1.2% code bloat caused by stupid register allocation.
-
-ginclude/stdarg.h, ginclude/varargs.h:
- o Handle Net/2 _VA_LIST_ and 4.4lite _BSD_VA_LIST_ right.
-
-ginclude/stddef.h:
- o Handle Net/2 _WCHAR_T_ and 4.4lite _BSD_WCHAR_T_ less wrongly than
- before. Copy FreeBSD-1.1.5/4.4lite rune_t brokenness. Remove
- extra underscores in _GCC_*_T_ which stopped the Net/2 _PTRDIFF_T_,
- _SIZE_T_ and _WCHAR_T_ from being undefined. Still need to
- handle the 4.4lite _BSD_PTRDIFF_T_ and _BSD_SIZE_T_. They are too
- hard to handle using ifdefs anyway. stddef.h takes 227 lines to
- define only 3 ANSI typedefs, 1 bogus typedef and 2 ANSI macros.
-
-diff -rc2 gcc-2.6.0/orig/Makefile.in gcc-2.6.0/Makefile.in
-*** gcc-2.6.0/orig/Makefile.in Thu Jul 14 08:46:54 1994
---- gcc-2.6.0/Makefile.in Sun Jul 17 05:36:06 1994
-***************
-*** 212,216 ****
- # we use this here because that should be enough, and also
- # so that -g1 will be tested.
-! LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) -g1
-
- # Additional options to use when compiling libgcc2.a.
---- 213,217 ----
- # we use this here because that should be enough, and also
- # so that -g1 will be tested.
-! LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) # -g1
-
- # Additional options to use when compiling libgcc2.a.
-***************
-*** 714,717 ****
---- 716,720 ----
- if [ $$? -eq 0 ] ; then true; else exit 1; fi; \
- mv libgcc1.o $${name}.o; \
-+ ld -r -x $${name}.o; mv a.out $${name}.o; \
- $(OLDAR) $(OLDAR_FLAGS) tmplibgcc1.a $${name}.o; \
- rm -f $${name}.o; \
-***************
-*** 733,736 ****
---- 736,740 ----
- $(OLDCC) $(CCLIBFLAGS) $(INCLUDES) -c $${file}; \
- if [ $$? -eq 0 ] ; then true; else exit 1; fi; \
-+ ld -r -x $${name}.o; mv a.out $${name}.o; \
- $(OLDAR) $(OLDAR_FLAGS) tmplibgcc1.a $${name}.o; \
- if [ $$? -eq 0 ] ; then true; else exit 1; fi; \
-***************
-*** 794,797 ****
---- 798,802 ----
- $(srcdir)/libgcc2.c -o $${name}.o; \
- if [ $$? -eq 0 ] ; then true; else exit 1; fi; \
-+ ld -r -x $${name}.o; mv a.out $${name}.o; \
- $(AR) $(AR_FLAGS) tmplibgcc2.a $${name}.o; \
- rm -f $${name}.o; \
-***************
-*** 813,816 ****
---- 818,822 ----
- $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES) -c $${file}; \
- if [ $$? -eq 0 ] ; then true; else exit 1; fi; \
-+ ld -r -x $${name}.o; mv a.out $${name}.o; \
- $(AR) $(AR_FLAGS) tmplibgcc2.a $${name}.o; \
- rm -f $${name}.[so]; \
-diff -rc2 gcc-2.6.0/orig/final.c gcc-2.6.0/final.c
-*** gcc-2.6.0/orig/final.c Wed Jul 13 11:30:52 1994
---- gcc-2.6.0/final.c Sun Jul 17 05:49:35 1994
-***************
-*** 954,965 ****
---- 954,969 ----
- FILE *file;
- {
-+ #ifndef NO_PROFILE_DATA
- int align = MIN (BIGGEST_ALIGNMENT, POINTER_SIZE);
-+ #endif /* not NO_PROFILE_DATA */
- int sval = current_function_returns_struct;
- int cxt = current_function_needs_context;
-
-+ #ifndef NO_PROFILE_DATA
- data_section ();
- ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
- ASM_OUTPUT_INTERNAL_LABEL (file, "LP", profile_label_no);
- assemble_integer (const0_rtx, POINTER_SIZE / BITS_PER_UNIT, 1);
-+ #endif /* not NO_PROFILE_DATA */
-
- text_section ();
-diff -rc2 gcc-2.6.0/config/i386/orig/freebsd.h gcc-2.6.0/config/i386/freebsd.h
-*** gcc-2.6.0/config/i386/orig/freebsd.h Fri Jul 15 02:55:14 1994
---- gcc-2.6.0/config/i386/freebsd.h Sun Jul 17 07:33:20 1994
-***************
-*** 40,46 ****
---- 40,52 ----
- }
-
-+ #define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k}"
-+
- /* Like the default, except no -lg. */
- #define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
-
-+ #define LINK_SPEC \
-+ "%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} %{assert*} \
-+ %{p:-Bstatic} %{pg:-Bstatic} %{Z}"
-+
- #undef SIZE_TYPE
- #define SIZE_TYPE "unsigned int"
-***************
-*** 50,77 ****
-
- #undef WCHAR_TYPE
-! #define WCHAR_TYPE "short unsigned int"
-
-! #define WCHAR_UNSIGNED 1
-
- #undef WCHAR_TYPE_SIZE
-! #define WCHAR_TYPE_SIZE 16
-
- #define HAVE_ATEXIT
-
-! /* Redefine this to use %eax instead of %edx. */
- #undef FUNCTION_PROFILER
- #define FUNCTION_PROFILER(FILE, LABELNO) \
- { \
- if (flag_pic) \
-! { \
-! fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n", \
-! LPREFIX, (LABELNO)); \
-! fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \
-! } \
- else \
-! { \
-! fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO)); \
-! fprintf (FILE, "\tcall mcount\n"); \
-! } \
- }
-
---- 56,89 ----
-
- #undef WCHAR_TYPE
-! #define WCHAR_TYPE "int"
-
-! #define WCHAR_UNSIGNED 0
-
- #undef WCHAR_TYPE_SIZE
-! #define WCHAR_TYPE_SIZE BITS_PER_WORD
-
- #define HAVE_ATEXIT
-
-! /* Tell final.c that we don't need a label passed to mcount. */
-!
-! #define NO_PROFILE_DATA
-!
-! /* Redefine this to not pass an unused label in %edx. */
-!
- #undef FUNCTION_PROFILER
- #define FUNCTION_PROFILER(FILE, LABELNO) \
- { \
- if (flag_pic) \
-! fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \
-! else \
-! fprintf (FILE, "\tcall mcount\n"); \
-! }
-!
-! #define FUNCTION_PROFILER_EPILOGUE(FILE) \
-! { \
-! if (flag_pic) \
-! fprintf (FILE, "\tcall *mexitcount@GOT(%%ebx)\n"); \
- else \
-! fprintf (FILE, "\tcall mexitcount\n"); \
- }
-
-***************
-*** 170,174 ****
- if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
- { \
-! size_directive_output = 1; \
- fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
- assemble_name (FILE, NAME); \
---- 182,186 ----
- if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
- { \
-! size_directive_output = 1; \
- fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
- assemble_name (FILE, NAME); \
-***************
-*** 184,202 ****
- by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
-
-! #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
-! do { \
-! char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
-! if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
-! && ! AT_END && TOP_LEVEL \
-! && DECL_INITIAL (DECL) == error_mark_node \
-! && !size_directive_output) \
-! { \
-! fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
-! assemble_name (FILE, name); \
-! fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL)));\
-! } \
- } while (0)
-
--
- /* This is how to declare the size of a function. */
-
---- 196,213 ----
- by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
-
-! #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
-! do { \
-! char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
-! if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
-! && ! AT_END && TOP_LEVEL \
-! && DECL_INITIAL (DECL) == error_mark_node \
-! && !size_directive_output) \
-! { \
-! fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
-! assemble_name (FILE, name); \
-! fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
-! } \
- } while (0)
-
- /* This is how to declare the size of a function. */
-
-***************
-*** 219,226 ****
- } \
- } while (0)
--
-- #define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k}"
-- #define LINK_SPEC \
-- "%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} %{assert*}"
-
- /* This section copied from i386/osfrose.h */
---- 230,233 ----
-diff -rc2 gcc-2.6.0/config/i386/orig/i386.c gcc-2.6.0/config/i386/i386.c
-*** gcc-2.6.0/config/i386/orig/i386.c Tue Apr 12 21:40:35 1994
---- gcc-2.6.0/config/i386/i386.c Sun Jul 17 06:10:00 1994
-***************
-*** 860,864 ****
- rtx xops[4];
- int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
-! || current_function_uses_const_pool);
-
- xops[0] = stack_pointer_rtx;
---- 860,865 ----
- rtx xops[4];
- int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
-! || current_function_uses_const_pool
-! || profile_flag || profile_block_flag);
-
- xops[0] = stack_pointer_rtx;
-***************
-*** 921,926 ****
- int reglimit = (frame_pointer_needed
- ? FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM);
-! int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
-! || current_function_uses_const_pool);
-
- #ifdef NON_SAVING_SETJMP
---- 922,935 ----
- int reglimit = (frame_pointer_needed
- ? FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM);
-!
-! #ifdef FUNCTION_PROFILER_EPILOGUE
-! if (profile_flag)
-! return 0;
-! #endif
-!
-! if (flag_pic && (current_function_uses_pic_offset_table
-! || current_function_uses_const_pool
-! || profile_flag || profile_block_flag))
-! return 0;
-
- #ifdef NON_SAVING_SETJMP
-***************
-*** 933,938 ****
-
- for (regno = reglimit - 1; regno >= 0; regno--)
-! if ((regs_ever_live[regno] && ! call_used_regs[regno])
-! || (regno == PIC_OFFSET_TABLE_REGNUM && pic_reg_used))
- nregs++;
-
---- 942,946 ----
-
- for (regno = reglimit - 1; regno >= 0; regno--)
-! if (regs_ever_live[regno] && ! call_used_regs[regno])
- nregs++;
-
-***************
-*** 955,958 ****
---- 963,971 ----
- int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
- || current_function_uses_const_pool);
-+
-+ #ifdef FUNCTION_PROFILER_EPILOGUE
-+ if (profile_flag)
-+ FUNCTION_PROFILER_EPILOGUE (file);
-+ #endif
-
- /* Compute the number of registers to pop */
-diff -rc2 gcc-2.6.0/config/i386/orig/i386.h gcc-2.6.0/config/i386/i386.h
-*** gcc-2.6.0/config/i386/orig/i386.h Thu Jun 16 20:36:13 1994
---- gcc-2.6.0/config/i386/i386.h Mon Jul 18 19:18:59 1994
-***************
-*** 267,272 ****
-
- #define REG_ALLOC_ORDER \
-! /*dx,cx,ax,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \
-! { 1, 2, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
-
- /* Macro to conditionally modify fixed_regs/call_used_regs. */
---- 267,272 ----
-
- #define REG_ALLOC_ORDER \
-! /*ax,cx,dx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \
-! { 0, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
-
- /* Macro to conditionally modify fixed_regs/call_used_regs. */
-diff -rc2 gcc-2.6.0/ginclude/orig/stdarg.h gcc-2.6.0/ginclude/stdarg.h
-*** gcc-2.6.0/ginclude/orig/stdarg.h Sat Jul 9 12:04:08 1994
---- gcc-2.6.0/ginclude/stdarg.h Mon Jul 18 01:32:16 1994
-***************
-*** 44,47 ****
---- 44,56 ----
- #ifndef __GNUC_VA_LIST
- #define __GNUC_VA_LIST
-+ #if defined (__FreeBSD__)
-+ /* This is the correct way to handle all BSD NET2 and BSD 4.4 systems. */
-+ #include <machine/ansi.h>
-+ #ifdef _BSD_VA_LIST_
-+ typedef _BSD_VA_LIST_ __gnuc_va_list;
-+ #else
-+ typedef _VA_LIST_ __gnuc_va_list;
-+ #endif
-+ #else
- #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX)
- typedef char *__gnuc_va_list;
-***************
-*** 50,53 ****
---- 59,63 ----
- #endif
- #endif
-+ #endif
-
- /* Define the standard macros for the user,
-***************
-*** 113,118 ****
---- 123,133 ----
- #endif
-
-+ #if 0
-+ /* BSD 4.4 actually spells the name _BSD_VA_LIST_ and requires it to be
-+ * defined and usable in place of va_list when the latter name is not
-+ * allowed (e.g., in stdio.h - see above). */
- #ifdef _BSD_VA_LIST
- #undef _BSD_VA_LIST
-+ #endif
- #endif
-
-diff -rc2 gcc-2.6.0/ginclude/orig/stddef.h gcc-2.6.0/ginclude/stddef.h
-*** gcc-2.6.0/ginclude/orig/stddef.h Tue Apr 26 04:13:05 1994
---- gcc-2.6.0/ginclude/stddef.h Sun Jul 17 21:52:12 1994
-***************
-*** 36,40 ****
- #define _PTRDIFF_T
- #endif
-! #ifndef _WCHAR_T_
- #define _WCHAR_T
- #endif
---- 36,40 ----
- #define _PTRDIFF_T
- #endif
-! #if ! defined (_WCHAR_T_) && ! defined (_BSD_WCHAR_T_)
- #define _WCHAR_T
- #endif
-***************
-*** 173,176 ****
---- 173,179 ----
- #define __WCHAR_TYPE__ int
- #endif
-+ #if defined (_ANSI_H_) && defined (_BSD_RUNE_T_)
-+ typedef _BSD_RUNE_T_ rune_t; /* WRONG */
-+ #endif
- typedef __WCHAR_TYPE__ wchar_t;
- #endif
-***************
-*** 189,200 ****
- are already defined. */
- #ifdef _ANSI_H_
-! #ifdef _GCC_PTRDIFF_T_
- #undef _PTRDIFF_T_
- #endif
-! #ifdef _GCC_SIZE_T_
- #undef _SIZE_T_
- #endif
-! #ifdef _GCC_WCHAR_T_
- #undef _WCHAR_T_
- #endif
- #endif /* _ANSI_H_ */
---- 192,204 ----
- are already defined. */
- #ifdef _ANSI_H_
-! #ifdef _GCC_PTRDIFF_T
- #undef _PTRDIFF_T_
- #endif
-! #ifdef _GCC_SIZE_T
- #undef _SIZE_T_
- #endif
-! #ifdef _GCC_WCHAR_T
- #undef _WCHAR_T_
-+ #undef _BSD_WCHAR_T_
- #endif
- #endif /* _ANSI_H_ */
-diff -rc2 gcc-2.6.0/ginclude/orig/varargs.h gcc-2.6.0/ginclude/varargs.h
-*** gcc-2.6.0/ginclude/orig/varargs.h Sat Jul 9 12:04:13 1994
---- gcc-2.6.0/ginclude/varargs.h Mon Jul 18 01:32:02 1994
-***************
-*** 76,79 ****
---- 76,88 ----
- #ifndef __GNUC_VA_LIST
- #define __GNUC_VA_LIST
-+ #if defined (__FreeBSD__)
-+ /* This is the correct way to handle all BSD NET2 and BSD 4.4 systems. */
-+ #include <machine/ansi.h>
-+ #ifdef _BSD_VA_LIST_
-+ typedef _BSD_VA_LIST_ __gnuc_va_list;
-+ #else
-+ typedef _VA_LIST_ __gnuc_va_list;
-+ #endif
-+ #else
- #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX)
- typedef char *__gnuc_va_list;
-***************
-*** 82,85 ****
---- 91,95 ----
- #endif
- #endif
-+ #endif
-
- #define va_start(AP) AP=(char *) &__builtin_va_alist
-***************
-*** 171,175 ****
---- 181,190 ----
- /* The next BSD release (if there is one) wants this symbol to be
- undefined instead of _VA_LIST_. */
-+ #if 0
-+ /* BSD 4.4 actually spells the name _BSD_VA_LIST_ and requires it to be
-+ * defined and usable in place of va_list when the latter name is not
-+ * allowed (e.g., in stdio.h - see ginclude/stdarg.h). */
- #ifdef _BSD_VA_LIST
- #undef _BSD_VA_LIST
-+ #endif
- #endif
diff --git a/gnu/gnu2bmake/gcc-2.6.0.tcl b/gnu/gnu2bmake/gcc-2.6.0.tcl
deleted file mode 100644
index 97181aa..0000000
--- a/gnu/gnu2bmake/gcc-2.6.0.tcl
+++ /dev/null
@@ -1,259 +0,0 @@
-#!/usr/local/bin/tclsh
-#
-# ----------------------------------------------------------------------------
-# "THE BEER-WARE LICENSE" (Revision 42):
-# <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
-# can do whatever you want with this stuff. If we meet some day, and you think
-# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
-# ----------------------------------------------------------------------------
-#
-# $Id$
-#
-
-source gnu2bmake.tcl
-
-#######################################################################
-# Parameters to tweak
-########
-set sdir /a/phk/gcc-2.6.0
-set ddir /a/phk/cc26
-
-#######################################################################
-# Do the stunt
-########
-sh "cd $sdir ; sh configure i386--freebsd"
-
-# .h files on their way to ~/include
-set l_include {config tm pcp tree input c-lex c-tree flags machmode real
- rtl c-parse c-gperf function defaults convert obstack insn-attr
- bytecode bc-emit insn-flags expr insn-codes regs hard-reg-set
- insn-config loop recog bc-typecd bc-opcode bc-optab typeclass
- output basic-block reload integrate conditions bytetypes bi-run
- bc-arity multilib stack}
-
-# other files on their way to ~/include
-set l_include_x {tree.def machmode.def rtl.def modemap.def bc-typecd.def}
-
-# .h files going into ~/include/i386
-set l_include_i386 {perform gstabs gas bsd i386 unix }
-
-# .c source for cpp
-set l_cpp {cccp cexp version}
-
-# .c source for cc1
-set l_cc1 [zap_suffix [makefile_macro C_OBJS $sdir]]
-append l_cc1 " " [zap_suffix [makefile_macro OBJS $sdir]]
-append l_cc1 " " [zap_suffix [makefile_macro BC_OBJS $sdir]]
-
-# .c source for cc
-set l_cc {gcc version}
-append l_cc " " [zap_suffix [makefile_macro OBSTACK $sdir]]
-
-# .c source for c++
-set l_cplus [zap_suffix [makefile_macro OBSTACK $sdir]]
-
-# .c source for c++ from "cp" subdir
-set l_cplus_cp {g++}
-
-# .c source for cc1plus
-set l_cc1plus {c-common}
-append l_cc1plus " " [zap_suffix [makefile_macro OBJS $sdir]]
-append l_cc1plus " " [zap_suffix [makefile_macro BC_OBJS $sdir]]
-
-# .c source for cc1plus from "cp" subdir
-set l_cc1plus_cp {}
-append l_cc1plus_cp " " [zap_suffix [makefile_macro CXX_OBJS $sdir/cp]]
-
-# .h file for cc1plus from "cp" subdir
-set l_cc1plus_h {lex parse cp-tree decl class hash}
-
-# other file for cc1plus from "cp" subdir
-set l_cc1plus_x {tree.def input.c}
-
-# All files used more than once go into the lib.
-set l_common [common_set $l_cpp $l_cc1 $l_cc $l_cc1plus $l_cplus]
-set l_cpp [reduce_by $l_cpp $l_common]
-set l_cc1 [reduce_by $l_cc1 $l_common]
-set l_cc [reduce_by $l_cc $l_common]
-set l_cplus [reduce_by $l_cplus $l_common]
-set l_cc1plus [reduce_by $l_cc1plus $l_common]
-
-# functions in libgcc1
-set l_libgcc1 [makefile_macro LIB1FUNCS $sdir]
-# functions in libgcc2
-set l_libgcc2 [makefile_macro LIB2FUNCS $sdir]
-# .c files in libgcc
-set l_libgcc {libgcc1.c libgcc2.c}
-# .h files in libgcc
-set l_libgcc_h {tconfig longlong glimits gbl-ctors}
-
-set version [makefile_macro version $sdir]
-set target [makefile_macro target $sdir]
-
-# do ~
-sh "rm -rf $ddir"
-sh "mkdir $ddir"
-set f [open $ddir/Makefile.inc w]
-puts $f "#\n# \$FreeBSD\$\n#\n"
-puts $f "CFLAGS+=\t-I\${.CURDIR} -I\${.CURDIR}/../include"
-puts $f "CFLAGS+=\t-Dbsd4_4"
-puts $f "CFLAGS+=\t-DGCC_INCLUDE_DIR=\\\"FOO\\\""
-puts $f "CFLAGS+=\t-DDEFAULT_TARGET_VERSION=\\\"$version\\\""
-puts $f "CFLAGS+=\t-DDEFAULT_TARGET_MACHINE=\\\"$target\\\""
-puts $f "CFLAGS+=\t-DMD_EXEC_PREFIX=\\\"/usr/libexec/\\\""
-puts $f "CFLAGS+=\t-DSTANDARD_STARTFILE_PREFIX=\\\"/usr/lib\\\""
-close $f
-
-set f [open $ddir/Makefile w]
-puts $f "#\n# \$FreeBSD\$\n#\n"
-puts $f "PGMDIR=\tcc_int cpp cc1 cc cc1plus c++ libgcc"
-puts $f "SUBDIR=\t\$(PGMDIR)"
-puts $f "\n.include <bsd.subdir.mk>"
-close $f
-
-# do ~/legal
-sh "mkdir $ddir/legal"
-sh "cp $sdir/gen-*.c $sdir/md $ddir/legal"
-set f [open $ddir/README w]
-puts $f {
-$Id$
-
-This directory contains gcc in a form that uses "bmake" makefiles.
-This is not the place you want to start, if you want to hack gcc.
-we have included everything here which is part of the source-code
-of gcc, but still, don't use this as a hacking-base.
-
-If you suspect a problem with gcc, or just want to hack it in general,
-get a complete gcc-X.Y.Z.tar.gz from somewhere, and use that.
-
-Please look in the directory src/gnu/gnu2bmake to find the tools
-to generate these files.
-
-Thankyou.
-}
-
-# do ~/libgcc
-sh "mkdir $ddir/libgcc"
-set f [open $ddir/libgcc/Makefile w]
-puts $f "#\n# \$FreeBSD\$\n#\n"
-puts $f "LIB=\tgcc"
-puts $f "INSTALL_PIC_ARCHIVE=\tyes"
-puts $f "SHLIB_MAJOR=\t26"
-puts $f "SHLIB_MINOR=\t0"
-puts $f ""
-puts $f "LIB1OBJS=\t[add_suffix $l_libgcc1 .o]"
-puts $f "LIB2OBJS=\t[add_suffix $l_libgcc2 .o]"
-puts $f {
-OBJS= ${LIB1OBJS} ${LIB2OBJS}
-LIB1SOBJS=${LIB1OBJS:.o=.so}
-LIB2SOBJS=${LIB2OBJS:.o=.so}
-P1OBJS=${LIB1OBJS:.o=.po}
-P2OBJS=${LIB2OBJS:.o=.po}
-
-${LIB1OBJS}: libgcc1.c
- ${CC} -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc1.c
- @${LD} -x -r ${.TARGET}
- @mv a.out ${.TARGET}
-
-${LIB2OBJS}: libgcc2.c
- ${CC} -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc2.c
- @${LD} -x -r ${.TARGET}
- @mv a.out ${.TARGET}
-
-.if !defined(NOPIC)
-${LIB1SOBJS}: libgcc1.c
- ${CC} -c -fpic ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc1.c
-
-${LIB2SOBJS}: libgcc2.c
- ${CC} -c -fpic ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc2.c
-.endif
-
-.if !defined(NOPROFILE)
-${P1OBJS}: libgcc1.c
- ${CC} -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc1.c
-
-${P2OBJS}: libgcc2.c
- ${CC} -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc2.c
-.endif
-
-.include <bsd.lib.mk>
-}
-close $f
-copy_c $sdir $ddir/libgcc $l_libgcc
-
-# do ~/include
-sh "mkdir $ddir/include"
-copy_l $sdir $ddir/include [add_suffix $l_include .h]
-copy_l $sdir $ddir/include $l_include_x
-copy_l $sdir $ddir/include [add_suffix $l_libgcc_h .h]
-
-# do ~/include/i386
-sh "mkdir $ddir/include/i386"
-copy_l $sdir/config/i386 $ddir/include/i386 [add_suffix $l_include_i386 .h]
-
-# do ~/cc_int
-mk_lib $ddir cc_int [add_suffix $l_common .c] {
- "NOPROFILE=\t1"
- "\ninstall:\n\t@true"
-}
-copy_c $sdir $ddir/cc_int $l_common
-
-# do ~/cpp
-mk_prog $ddir cpp [add_suffix $l_cpp .c] {
- "BINDIR=\t/usr/libexec"
- "LDDESTDIR+=\t-L\${.CURDIR}/../cc_int/obj"
- "LDDESTDIR+=\t-L\${.CURDIR}/../cc_int"
- "LDADD+=\t-lcc_int"
-}
-copy_c $sdir $ddir/cpp $l_cpp
-cp $sdir/cpp.1 $ddir/cpp/cpp.1
-
-# do ~/c++
-mk_prog $ddir c++ [add_suffix "$l_cplus $l_cplus_cp" .c] {
- "BINDIR=\t/usr/bin"
- "NOMAN=\t1"
- "LDDESTDIR+=\t-L\${.CURDIR}/../cc_int/obj"
- "LDDESTDIR+=\t-L\${.CURDIR}/../cc_int"
- "LDADD+=\t-lcc_int"
-}
-copy_c $sdir $ddir/c++ $l_cplus
-copy_c $sdir/cp $ddir/c++ $l_cplus_cp
-
-# do ~/cc
-mk_prog $ddir cc [add_suffix $l_cc .c] {
- "BINDIR=\t/usr/bin"
- "MLINKS+=cc.1 gcc.1"
- "MLINKS+=cc.1 c++.1"
- "MLINKS+=cc.1 g++.1"
- "LDDESTDIR+=\t-L\${.CURDIR}/../cc_int/obj"
- "LDDESTDIR+=\t-L\${.CURDIR}/../cc_int"
- "LDADD+=\t-lcc_int"
- "\nafterinstall:\n\tcd \$(DESTDIR)\$(BINDIR) ; rm gcc ; ln -s cc gcc"
-}
-copy_c $sdir $ddir/cc $l_cc
-cp $sdir/gcc.1 $ddir/cc/cc.1
-
-# do ~/cc1
-mk_prog $ddir cc1 [add_suffix $l_cc1 .c] {
- "BINDIR=\t/usr/libexec"
- "NOMAN=\t1"
- "LDDESTDIR+=\t-L\${.CURDIR}/../cc_int/obj"
- "LDDESTDIR+=\t-L\${.CURDIR}/../cc_int"
- "LDADD+=\t-lcc_int"
-}
-copy_c $sdir $ddir/cc1 $l_cc1
-
-# do ~/cc1plus
-mk_prog $ddir cc1plus [add_suffix "$l_cc1plus_cp $l_cc1plus" .c] {
- "BINDIR=\t/usr/libexec"
- "NOMAN=\t1"
- "LDDESTDIR+=\t-L\${.CURDIR}/../cc_int/obj"
- "LDDESTDIR+=\t-L\${.CURDIR}/../cc_int"
- "LDADD+=\t-lcc_int"
-}
-copy_l $sdir/cp $ddir/cc1plus $l_cc1plus_x
-copy_c $sdir $ddir/cc1plus $l_cc1plus
-copy_c $sdir/cp $ddir/cc1plus $l_cc1plus_cp
-copy_l $sdir/cp $ddir/cc1plus [add_suffix $l_cc1plus_h .h]
-
-exit 0
diff --git a/gnu/gnu2bmake/gcc-2.6.1.patch b/gnu/gnu2bmake/gcc-2.6.1.patch
deleted file mode 100644
index fb17501..0000000
--- a/gnu/gnu2bmake/gcc-2.6.1.patch
+++ /dev/null
@@ -1,407 +0,0 @@
-# this patch is good for 2.6.1 and 2.6.2
-
-diff -r -c ../../scratch/gcc-2.6.1/cccp.1 ./cccp.1
-*** ../../scratch/gcc-2.6.1/cccp.1 Tue May 31 16:29:50 1994
---- ./cccp.1 Mon Nov 14 19:42:44 1994
-***************
-*** 1,13 ****
- .\" Copyright (c) 1991, 1992, 1993 Free Software Foundation \-*-Text-*-
- .\" See section COPYING for conditions for redistribution
-! .TH cpp 1 "30apr1993" "GNU Tools" "GNU Tools"
- .SH NAME
-! cccp, cpp \- The GNU C-Compatible Compiler Preprocessor.
- .SH SYNOPSIS
- .hy 0
- .na
- .TP
-! .B cccp
- .RB "[\|" \-$ "\|]"
- .RB "[\|" \-A \c
- .I predicate\c
---- 1,13 ----
- .\" Copyright (c) 1991, 1992, 1993 Free Software Foundation \-*-Text-*-
- .\" See section COPYING for conditions for redistribution
-! .TH cpp 1 "30, April 1993" "FreeBSD" "GNU Tools"
- .SH NAME
-! cpp \- Compiler Preprocessor.
- .SH SYNOPSIS
- .hy 0
- .na
- .TP
-! .B cpp
- .RB "[\|" \-$ "\|]"
- .RB "[\|" \-A \c
- .I predicate\c
-***************
-*** 142,154 ****
- Most often when you use the C preprocessor you will not have to invoke it
- explicitly: the C compiler will do so automatically. However, the
- preprocessor is sometimes useful individually.
--
-- When you call the preprocessor individually, either name
-- (\c
-- .B cpp\c
-- \& or \c
-- .B cccp\c
-- \&) will do\(em\&they are completely synonymous.
-
- The C preprocessor expects two file names as arguments, \c
- .I infile\c
---- 142,147 ----
-Only in .: cccp.1.orig
-diff -r -c ../../scratch/gcc-2.6.1/cccp.c ./cccp.c
-*** ../../scratch/gcc-2.6.1/cccp.c Tue Oct 25 15:37:44 1994
---- ./cccp.c Mon Nov 14 19:40:30 1994
-***************
-*** 188,194 ****
- #ifndef VMS
- #ifndef HAVE_STRERROR
- extern int sys_nerr;
-! #if defined(bsd4_4) || defined(__NetBSD__)
- extern const char *const sys_errlist[];
- #else
- extern char *sys_errlist[];
---- 188,194 ----
- #ifndef VMS
- #ifndef HAVE_STRERROR
- extern int sys_nerr;
-! #if defined(bsd4_4) || defined(__NetBSD__) || defined(__FreeBSD__)
- extern const char *const sys_errlist[];
- #else
- extern char *sys_errlist[];
-Only in .: cccp.c.orig
-Only in .: cccp.c.rej
-diff -r -c ../../scratch/gcc-2.6.1/config/i386/freebsd.h ./config/i386/freebsd.h
-*** ../../scratch/gcc-2.6.1/config/i386/freebsd.h Tue Oct 18 17:59:52 1994
---- ./config/i386/freebsd.h Mon Nov 14 19:41:07 1994
-***************
-*** 19,27 ****
- along with GNU CC; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-- /* This goes away when the math-emulator is fixed */
-- #define TARGET_CPU_DEFAULT 0400 /* TARGET_NO_FANCY_MATH_387 */
--
- /* This is tested by i386gas.h. */
- #define YES_UNDERSCORES
-
---- 19,24 ----
-***************
-*** 31,37 ****
- #include "i386/perform.h"
-
- #undef CPP_PREDEFINES
-! #define CPP_PREDEFINES "-Dunix -Di386 -D__FreeBSD__ -D__386BSD__ -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)"
-
- #define INCLUDE_DEFAULTS { \
- { "/usr/include", 0 }, \
---- 28,34 ----
- #include "i386/perform.h"
-
- #undef CPP_PREDEFINES
-! #define CPP_PREDEFINES "-Dunix -Di386 -D__FreeBSD__=2 -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)"
-
- #define INCLUDE_DEFAULTS { \
- { "/usr/include", 0 }, \
-***************
-*** 39,47 ****
---- 36,54 ----
- { 0, 0} \
- }
-
-+ #define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k}"
-+
- /* Like the default, except no -lg. */
- #define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
-
-+ #define LINK_SPEC \
-+ "%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} %{assert*} \
-+ %{p:-Bstatic} %{pg:-Bstatic} %{Z}"
-+
-+ /* This goes away when the math emulator is fixed. */
-+ #undef TARGET_DEFAULT
-+ #define TARGET_DEFAULT (MASK_NO_FANCY_MATH_387 | 0301)
-+
- #undef SIZE_TYPE
- #define SIZE_TYPE "unsigned int"
-
-***************
-*** 49,80 ****
- #define PTRDIFF_TYPE "int"
-
- #undef WCHAR_TYPE
-! #define WCHAR_TYPE "short unsigned int"
-
-! #define WCHAR_UNSIGNED 1
-
- #undef WCHAR_TYPE_SIZE
-! #define WCHAR_TYPE_SIZE 16
-
- #define HAVE_ATEXIT
-
-! /* Redefine this to use %eax instead of %edx. */
- #undef FUNCTION_PROFILER
- #define FUNCTION_PROFILER(FILE, LABELNO) \
- { \
- if (flag_pic) \
-! { \
-! fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n", \
-! LPREFIX, (LABELNO)); \
-! fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \
-! } \
- else \
-! { \
-! fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO)); \
-! fprintf (FILE, "\tcall mcount\n"); \
-! } \
- }
-
- /* There are conflicting reports about whether this system uses
- a different assembler syntax. wilson@cygnus.com says # is right. */
- #undef COMMENT_BEGIN
---- 56,95 ----
- #define PTRDIFF_TYPE "int"
-
- #undef WCHAR_TYPE
-! #define WCHAR_TYPE "int"
-
-! #define WCHAR_UNSIGNED 0
-
- #undef WCHAR_TYPE_SIZE
-! #define WCHAR_TYPE_SIZE BITS_PER_WORD
-
- #define HAVE_ATEXIT
-
-! /* Tell final.c that we don't need a label passed to mcount. */
-!
-! #define NO_PROFILE_DATA
-!
-! /* Redefine this to not pass an unused label in %edx. */
-!
- #undef FUNCTION_PROFILER
- #define FUNCTION_PROFILER(FILE, LABELNO) \
- { \
- if (flag_pic) \
-! fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \
- else \
-! fprintf (FILE, "\tcall mcount\n"); \
- }
-
-+ #if 0 /* not ready for this; it should be decided at compile time */
-+ #define FUNCTION_PROFILER_EPILOGUE(FILE) \
-+ { \
-+ if (flag_pic) \
-+ fprintf (FILE, "\tcall *mexitcount@GOT(%%ebx)\n"); \
-+ else \
-+ fprintf (FILE, "\tcall mexitcount\n"); \
-+ }
-+ #endif
-+
- /* There are conflicting reports about whether this system uses
- a different assembler syntax. wilson@cygnus.com says # is right. */
- #undef COMMENT_BEGIN
-***************
-*** 218,227 ****
- putc ('\n', FILE); \
- } \
- } while (0)
--
-- #define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k}"
-- #define LINK_SPEC \
-- "%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} %{assert*}"
-
- /* This is defined when gcc is compiled in the BSD-directory-tree, and must
- * make up for the gap to all the stuff done in the GNU-makefiles.
---- 233,238 ----
-Only in ./config/i386: freebsd.h.orig
-diff -r -c ../../scratch/gcc-2.6.1/config/i386/i386.c ./config/i386/i386.c
-*** ../../scratch/gcc-2.6.1/config/i386/i386.c Fri Oct 7 12:45:14 1994
---- ./config/i386/i386.c Mon Nov 14 19:41:27 1994
-***************
-*** 1097,1103 ****
- int limit;
- rtx xops[4];
- int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
-! || current_function_uses_const_pool);
-
- xops[0] = stack_pointer_rtx;
- xops[1] = frame_pointer_rtx;
---- 1097,1104 ----
- int limit;
- rtx xops[4];
- int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
-! || current_function_uses_const_pool
-! || profile_flag || profile_block_flag);
-
- xops[0] = stack_pointer_rtx;
- xops[1] = frame_pointer_rtx;
-***************
-*** 1158,1165 ****
- int nregs = 0;
- int reglimit = (frame_pointer_needed
- ? FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM);
-! int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
-! || current_function_uses_const_pool);
-
- #ifdef NON_SAVING_SETJMP
- if (NON_SAVING_SETJMP && current_function_calls_setjmp)
---- 1159,1174 ----
- int nregs = 0;
- int reglimit = (frame_pointer_needed
- ? FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM);
-!
-! #ifdef FUNCTION_PROFILER_EPILOGUE
-! if (profile_flag)
-! return 0;
-! #endif
-!
-! if (flag_pic && (current_function_uses_pic_offset_table
-! || current_function_uses_const_pool
-! || profile_flag || profile_block_flag))
-! return 0;
-
- #ifdef NON_SAVING_SETJMP
- if (NON_SAVING_SETJMP && current_function_calls_setjmp)
-***************
-*** 1170,1177 ****
- return 0;
-
- for (regno = reglimit - 1; regno >= 0; regno--)
-! if ((regs_ever_live[regno] && ! call_used_regs[regno])
-! || (regno == PIC_OFFSET_TABLE_REGNUM && pic_reg_used))
- nregs++;
-
- return nregs == 0 || ! frame_pointer_needed;
---- 1179,1185 ----
- return 0;
-
- for (regno = reglimit - 1; regno >= 0; regno--)
-! if (regs_ever_live[regno] && ! call_used_regs[regno])
- nregs++;
-
- return nregs == 0 || ! frame_pointer_needed;
-***************
-*** 1193,1198 ****
---- 1201,1211 ----
- rtx xops[3];
- int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
- || current_function_uses_const_pool);
-+
-+ #ifdef FUNCTION_PROFILER_EPILOGUE
-+ if (profile_flag)
-+ FUNCTION_PROFILER_EPILOGUE (file);
-+ #endif
-
- /* Compute the number of registers to pop */
-
-Only in ./config/i386: i386.c.orig
-diff -r -c ../../scratch/gcc-2.6.1/cp/g++.c ./cp/g++.c
-*** ../../scratch/gcc-2.6.1/cp/g++.c Sat Oct 29 04:17:44 1994
---- ./cp/g++.c Mon Nov 14 19:41:16 1994
-***************
-*** 84,90 ****
- #endif
-
- extern int sys_nerr;
-! #if defined(bsd4_4) || defined(__NetBSD__)
- extern const char *const sys_errlist[];
- #else
- extern char *sys_errlist[];
---- 84,90 ----
- #endif
-
- extern int sys_nerr;
-! #if defined(bsd4_4) || defined(__NetBSD__) || defined(__FreeBSD__)
- extern const char *const sys_errlist[];
- #else
- extern char *sys_errlist[];
-Only in ./cp: g++.c.orig
-Only in ../../scratch/gcc-2.6.1: cpp.1
-Only in .: cpp.1.orig
-Only in .: cpp.1.rej
-Only in .: cpp.1.rej.orig
-diff -r -c ../../scratch/gcc-2.6.1/final.c ./final.c
-*** ../../scratch/gcc-2.6.1/final.c Tue Sep 20 17:05:03 1994
---- ./final.c Mon Nov 14 19:40:32 1994
-***************
-*** 957,970 ****
---- 957,974 ----
- profile_function (file)
- FILE *file;
- {
-+ #ifndef NO_PROFILE_DATA
- int align = MIN (BIGGEST_ALIGNMENT, POINTER_SIZE);
-+ #endif /* not NO_PROFILE_DATA */
- int sval = current_function_returns_struct;
- int cxt = current_function_needs_context;
-
-+ #ifndef NO_PROFILE_DATA
- data_section ();
- ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
- ASM_OUTPUT_INTERNAL_LABEL (file, "LP", profile_label_no);
- assemble_integer (const0_rtx, POINTER_SIZE / BITS_PER_UNIT, 1);
-+ #endif /* not NO_PROFILE_DATA */
-
- text_section ();
-
-Only in .: final.c.orig
-Only in .: final.c.rej
-diff -r -c ../../scratch/gcc-2.6.1/gcc.c ./gcc.c
-*** ../../scratch/gcc-2.6.1/gcc.c Thu Oct 27 15:49:58 1994
---- ./gcc.c Mon Nov 14 19:41:18 1994
-***************
-*** 166,172 ****
- #endif
-
- extern int sys_nerr;
-! #if defined(bsd4_4) || defined(__NetBSD__)
- extern const char *const sys_errlist[];
- #else
- extern char *sys_errlist[];
---- 166,172 ----
- #endif
-
- extern int sys_nerr;
-! #if defined(bsd4_4) || defined(__NetBSD__) || defined (__FreeBSD__)
- extern const char *const sys_errlist[];
- #else
- extern char *sys_errlist[];
-***************
-*** 711,716 ****
---- 711,745 ----
- %{!S:%{!gnatc:%{!gnats:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
- %{c:%W{o*}%{!o*:-o %w%b.o}}\
- %{!c:-o %d%w%u.o} %{!pipe:%g.s} %A\n}}}}}} "},
-+ /***** ljo's Fortran rule *****/
-+ {".f", "@f2c"},
-+ {"@f2c",
-+ "f2c %{checksubscripts:-C} %{I2} %{onetrip} %{honorcase:-U} %{u} %{w}\
-+ %{ANSIC:-A} %{a} %{C++}\
-+ %{c} %{E} %{ec} %{ext} %{f} %{72} %{g} %{h} %{i2} %{kr}\
-+ %{P} %{p} %{r} %{r8} %{s} %{w8} %{z} %{N*}\
-+ %i %{!pipe: -o %g.c} %{pipe:-o -}|\n",
-+ "cpp -lang-c %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
-+ %{C:%{!E:%eGNU C does not support -C without using -E}}\
-+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
-+ -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
-+ %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\
-+ %{!undef:%{!ansi:%p} %P} %{trigraphs} \
-+ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
-+ %{traditional-cpp:-traditional}\
-+ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*}\
-+ %{pipe:-} %{!pipe:%g.c} %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
-+ "%{!M:%{!MM:%{!E:cc1 %{!pipe:%g.i} %1 \
-+ %{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a}\
-+ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \
-+ %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
-+ %{aux-info*}\
-+ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
-+ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
-+ %{!S:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
-+ %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%u.o}\
-+ %{!pipe:%g.s} %A\n }}}}"},
-+ /***** End of ljo's Fortran rule *****/
- /* Mark end of table */
- {0, 0}
- };
-Only in .: gcc.c.orig
diff --git a/gnu/gnu2bmake/gcc-2.6.1.tcl b/gnu/gnu2bmake/gcc-2.6.1.tcl
deleted file mode 100755
index d2aac48..0000000
--- a/gnu/gnu2bmake/gcc-2.6.1.tcl
+++ /dev/null
@@ -1,275 +0,0 @@
-#!/usr/local/bin/tclsh
-#
-# ----------------------------------------------------------------------------
-# "THE BEER-WARE LICENSE" (Revision 42):
-# <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
-# can do whatever you want with this stuff. If we meet some day, and you think
-# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
-# ----------------------------------------------------------------------------
-#
-# $Id$
-#
-# Good for 2.6.1 and 2.6.2
-
-source gnu2bmake.tcl
-
-#######################################################################
-# Parameters to tweak
-########
-set sdir /freebsd/gcc-2.6.2
-set ddir /freebsd/cc262
-
-#######################################################################
-# Do the stunt
-########
-sh "cd $sdir ; sh configure i386--freebsd"
-
-# .h files on their way to ~/include
-set l_include {config tm pcp tree input c-lex c-tree flags machmode real
- rtl c-parse c-gperf function defaults convert obstack insn-attr
- bytecode bc-emit insn-flags expr insn-codes regs hard-reg-set
- insn-config loop recog bc-typecd bc-opcode bc-optab typeclass
- output basic-block reload integrate conditions bytetypes bi-run
- bc-arity multilib stack}
-
-# other files on their way to ~/include
-set l_include_x {tree.def machmode.def rtl.def modemap.def bc-typecd.def}
-
-# .h files going into ~/include/i386
-set l_include_i386 {perform gstabs gas bsd i386 unix }
-
-# .c source for cpp
-set l_cpp {cccp cexp version}
-
-# .c source for cc1
-set l_cc1 [zap_suffix [makefile_macro C_OBJS $sdir]]
-append l_cc1 " " [zap_suffix [makefile_macro OBJS $sdir]]
-append l_cc1 " " [zap_suffix [makefile_macro BC_OBJS $sdir]]
-
-# .c source for cc
-set l_cc {gcc version}
-append l_cc " " [zap_suffix [makefile_macro OBSTACK $sdir]]
-
-# .c source for c++
-set l_cplus [zap_suffix [makefile_macro OBSTACK $sdir]]
-
-# .c source for c++ from "cp" subdir
-set l_cplus_cp {g++}
-
-# .c source for cc1plus
-set l_cc1plus {c-common}
-append l_cc1plus " " [zap_suffix [makefile_macro OBJS $sdir]]
-append l_cc1plus " " [zap_suffix [makefile_macro BC_OBJS $sdir]]
-
-# .c source for cc1plus from "cp" subdir
-set l_cc1plus_cp {}
-append l_cc1plus_cp " " [zap_suffix [makefile_macro CXX_OBJS $sdir/cp]]
-
-# .h file for cc1plus from "cp" subdir
-set l_cc1plus_h {lex parse cp-tree decl class hash}
-
-# other file for cc1plus from "cp" subdir
-set l_cc1plus_x {tree.def input.c}
-
-# All files used more than once go into the lib.
-set l_common [common_set $l_cpp $l_cc1 $l_cc $l_cc1plus $l_cplus]
-set l_cpp [reduce_by $l_cpp $l_common]
-set l_cc1 [reduce_by $l_cc1 $l_common]
-set l_cc [reduce_by $l_cc $l_common]
-set l_cplus [reduce_by $l_cplus $l_common]
-set l_cc1plus [reduce_by $l_cc1plus $l_common]
-
-# functions in libgcc1
-set l_libgcc1 [makefile_macro LIB1FUNCS $sdir]
-# functions in libgcc2
-set l_libgcc2 [makefile_macro LIB2FUNCS $sdir]
-# .c files in libgcc
-set l_libgcc {libgcc1.c libgcc2.c}
-# .h files in libgcc
-set l_libgcc_h {tconfig longlong glimits gbl-ctors}
-
-set version [makefile_macro version $sdir]
-set target [makefile_macro target $sdir]
-
-# do ~
-sh "rm -rf $ddir"
-sh "mkdir $ddir"
-set f [open $ddir/Makefile.inc w]
-puts $f "#\n# \$Id$\n#\n"
-puts $f "CFLAGS+=\t-I\${.CURDIR} -I\${.CURDIR}/../include"
-puts $f "CFLAGS+=\t-Dbsd4_4"
-puts $f "CFLAGS+=\t-DGCC_INCLUDE_DIR=\\\"FOO\\\""
-puts $f "CFLAGS+=\t-DTOOL_INCLUDE_DIR=\\\"FOO\\\""
-puts $f "CFLAGS+=\t-DGPLUSPLUS_INCLUDE_DIR=\\\"FOO\\\""
-puts $f "CFLAGS+=\t-DDEFAULT_TARGET_VERSION=\\\"$version\\\""
-puts $f "CFLAGS+=\t-DDEFAULT_TARGET_MACHINE=\\\"$target\\\""
-puts $f "CFLAGS+=\t-DMD_EXEC_PREFIX=\\\"/usr/libexec/\\\""
-puts $f "CFLAGS+=\t-DSTANDARD_STARTFILE_PREFIX=\\\"/usr/lib\\\""
-puts $f "CFLAGS+=\t-DGCC_NAME=\\\"cc\\\""
-puts $f ""
-puts $f ".if exists(\${.CURDIR}/../cc_int/obj)"
-puts $f "LIBDESTDIR=\t\${.CURDIR}/../cc_int/obj"
-puts $f ".else"
-puts $f "LIBDESTDIR=\t\${.CURDIR}/../cc_int"
-puts $f ".endif"
-puts $f ""
-
-puts $f "# XXX LDDESTDIR isn't a directory and there is no standard name for the dir"
-puts $f "LDDESTDIR=\t-L\${LIBDESTDIR}"
-puts $f ".if defined(SHARED_LIBCC_INT)"
-puts $f "LIBCC_INT=\t\${LIBDESTDIR}/libcc_int.so.262.0"
-puts $f ".else"
-puts $f "LIBCC_INT=\t\${LIBDESTDIR}/libcc_int.a"
-puts $f ".endif"
-close $f
-
-set f [open $ddir/Makefile w]
-puts $f "#\n# \$Id$\n#\n"
-puts $f "PGMDIR=\tcc_int cpp cc1 cc cc1plus c++ f77 libgcc"
-puts $f "SUBDIR=\t\$(PGMDIR)"
-puts $f "\n.include <bsd.subdir.mk>"
-close $f
-
-# do ~/legal
-sh "mkdir $ddir/legal"
-sh "cp $sdir/gen-*.c $sdir/md $ddir/legal"
-set f [open $ddir/README w]
-puts $f {
-$Id$
-
-This directory contains gcc in a form that uses "bmake" makefiles.
-This is not the place you want to start, if you want to hack gcc.
-we have included everything here which is part of the source-code
-of gcc, but still, don't use this as a hacking-base.
-
-If you suspect a problem with gcc, or just want to hack it in general,
-get a complete gcc-X.Y.Z.tar.gz from somewhere, and use that.
-
-Please look in the directory src/gnu/gnu2bmake to find the tools
-to generate these files.
-
-Thankyou.
-}
-
-# do ~/libgcc
-sh "mkdir $ddir/libgcc"
-set f [open $ddir/libgcc/Makefile w]
-puts $f "#\n# \$Id$\n#\n"
-puts $f "LIB=\tgcc"
-puts $f "INSTALL_PIC_ARCHIVE=\tyes"
-puts $f "SHLIB_MAJOR=\t261"
-puts $f "SHLIB_MINOR=\t0"
-puts $f ""
-puts $f "LIB1OBJS=\t[add_suffix $l_libgcc1 .o]"
-puts $f "LIB2OBJS=\t[add_suffix $l_libgcc2 .o]"
-puts $f {
-OBJS= ${LIB1OBJS} ${LIB2OBJS}
-LIB1SOBJS=${LIB1OBJS:.o=.so}
-LIB2SOBJS=${LIB2OBJS:.o=.so}
-P1OBJS=${LIB1OBJS:.o=.po}
-P2OBJS=${LIB2OBJS:.o=.po}
-
-${LIB1OBJS}: libgcc1.c
- ${CC} -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc1.c
- @${LD} -x -r ${.TARGET}
- @mv a.out ${.TARGET}
-
-${LIB2OBJS}: libgcc2.c
- ${CC} -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc2.c
- @${LD} -x -r ${.TARGET}
- @mv a.out ${.TARGET}
-
-.if !defined(NOPIC)
-${LIB1SOBJS}: libgcc1.c
- ${CC} -c -fpic ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc1.c
-
-${LIB2SOBJS}: libgcc2.c
- ${CC} -c -fpic ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc2.c
-.endif
-
-.if !defined(NOPROFILE)
-${P1OBJS}: libgcc1.c
- ${CC} -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc1.c
-
-${P2OBJS}: libgcc2.c
- ${CC} -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.CURDIR}/libgcc2.c
-.endif
-
-.include <bsd.lib.mk>
-}
-close $f
-copy_c $sdir $ddir/libgcc $l_libgcc
-
-# do ~/include
-sh "mkdir $ddir/include"
-copy_l $sdir $ddir/include [add_suffix $l_include .h]
-copy_l $sdir $ddir/include $l_include_x
-copy_l $sdir $ddir/include [add_suffix $l_libgcc_h .h]
-
-# do ~/include/i386
-sh "mkdir $ddir/include/i386"
-copy_l $sdir/config/i386 $ddir/include/i386 [add_suffix $l_include_i386 .h]
-
-# do ~/cc_int
-mk_lib $ddir cc_int [add_suffix $l_common .c] {
- "NOPROFILE=\tyes"
- ".if defined(SHARED_LIBCC_INT)"
- "INTERNALLIB="
- "SHLIB_MAJOR=262"
- "SHLIB_MINOR=0"
- ".else"
- "\ninstall:\n\t@true"
- ".endif"
-}
-copy_c $sdir $ddir/cc_int $l_common
-
-# do ~/cpp
-mk_prog $ddir cpp [add_suffix $l_cpp .c] {
- "BINDIR=\t/usr/libexec"
- ".PATH:\t\${.CURDIR}/../cc_int"
- "SRCS+=\tobstack.c version.c"
-}
-copy_c $sdir $ddir/cpp $l_cpp
-cp $sdir/cccp.1 $ddir/cpp/cpp.1
-
-# do ~/c++
-mk_prog $ddir c++ [add_suffix "$l_cplus $l_cplus_cp" .c] {
- "BINDIR=\t/usr/bin"
- "LINKS=\t\${BINDIR}/c++ \${BINDIR}/g++"
- "NOMAN=\t1"
-}
-copy_c $sdir $ddir/c++ $l_cplus
-copy_c $sdir/cp $ddir/c++ $l_cplus_cp
-
-# do ~/cc
-mk_prog $ddir cc [add_suffix $l_cc .c] {
- "BINDIR=\t/usr/bin"
- ".PATH: \${.CURDIR}/../cc_int"
- "SRCS+=\tobstack.c version.c"
- "LINKS=\t\${BINDIR}/cc \${BINDIR}/gcc"
-}
-copy_c $sdir $ddir/cc $l_cc
-cp $sdir/gcc.1 $ddir/cc/cc.1
-
-# do ~/cc1
-mk_prog $ddir cc1 [add_suffix $l_cc1 .c] {
- "BINDIR=\t/usr/libexec"
- "NOMAN=\t1"
- "DPADD+=\t\${LIBCC_INT} \${LIBGNUMALLOC}"
- "LDADD+=\t-lcc_int -lgnumalloc"
-}
-copy_c $sdir $ddir/cc1 $l_cc1
-
-# do ~/cc1plus
-mk_prog $ddir cc1plus [add_suffix "$l_cc1plus_cp $l_cc1plus" .c] {
- "BINDIR=\t/usr/libexec"
- "NOMAN=\t1"
- "DPADD+=\t\${LIBCC_INT} \${LIBGNUMALLOC}"
- "LDADD+=\t-lcc_int -lgnumalloc"
-}
-copy_l $sdir/cp $ddir/cc1plus $l_cc1plus_x
-copy_c $sdir $ddir/cc1plus $l_cc1plus
-copy_c $sdir/cp $ddir/cc1plus $l_cc1plus_cp
-copy_l $sdir/cp $ddir/cc1plus [add_suffix $l_cc1plus_h .h]
-
-exit 0
diff --git a/gnu/gnu2bmake/gnu2bmake.tcl b/gnu/gnu2bmake/gnu2bmake.tcl
deleted file mode 100644
index b2ec65f..0000000
--- a/gnu/gnu2bmake/gnu2bmake.tcl
+++ /dev/null
@@ -1,221 +0,0 @@
-#!/usr/local/bin/tcl
-#
-# ----------------------------------------------------------------------------
-# "THE BEER-WARE LICENSE" (Revision 42):
-# <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
-# can do whatever you want with this stuff. If we meet some day, and you think
-# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
-# ----------------------------------------------------------------------------
-#
-# $Id$
-#
-#######################################################################
-# Generic procedures usable in the process of gnu-to-bmake jobs.
-#
-
-#######################################################################
-# sh -- execute command.
-# argv[1] shell command to execute.
-#
-proc sh {cmd} {
- puts stdout "+ $cmd"
- flush stdout
- exec sh -e -c $cmd >&@ stdout
-}
-
-#######################################################################
-# cp -- execute cp(1)
-# argv arguments to cp(1)
-#
-proc cp {args} {
- sh "cp $args"
-}
-
-#######################################################################
-# copy_l -- Copy list of files, try to make(1) them if missing.
-# argv[1] source directory
-# argv[2] destination directory
-# argv[3] list of filenames
-#
-proc copy_l {src dst files} {
- foreach f $files {
- if {![file exists $src/${f}]} {
- sh "cd $src ; set +e ; make ${f}"
- }
- if {![file exists $src/${f}]} {
- error "Couldn't produce ${f} in $src"
- }
- cp $src/${f} $dst
- }
-}
-
-#######################################################################
-# copy_c -- Copy list of .c files, try to make(1) them if missing.
-# argv[1] source directory
-# argv[2] destination directory
-# argv[3] list of filenames, with or without .c suffixes.
-#
-proc copy_c {src dst files} {
- regsub -all {\.c} $files {} files
- foreach f $files {
- if {![file exists $src/${f}.c]} {
- sh "cd $src ; set +e ; make ${f}.c ; exit 0"
- }
- if {![file exists $src/${f}.c]} {
- sh "cd $src ; set +e ; make ${f}.o ; exit 0"
- }
- if {![file exists $src/${f}.c]} {
- error "Couldn't produce ${f}.c in $src"
- }
- cp $src/${f}.c $dst
- }
-}
-
-#######################################################################
-# find_source -- Return a list of sourcefiles.
-# argv[1] source directory
-# argv[2] source list.
-# argv[3] list of extensions
-#
-proc find_source {dir files ext} {
- set l ""
- foreach f $files {
- set k ""
- foreach i $ext {
- if {[file exists $dir/${f}${i}]} { set k ${f}${i} ; break }
- }
- if {$k == ""} {
- error "cannot find source for $f using extensions <$ext>"
- }
- lappend l $k
- }
- return $l
-}
-
-#######################################################################
-# zap_suffix -- remove suffixes from list if filenames
-# argv[1] list of filenames
-# argv[2] (optional) regex matching suffixes to be removed,
-# default removes all known suffixes, (AND warts too!).
-#
-proc zap_suffix {lst {suf {\.cc$|\.[cyolhsxS]$}}} {
- set a ""
- foreach i $lst {
- regsub -all $suf $i {} i
- lappend a $i
- }
- return $a
-}
-
-#######################################################################
-# add_suffix -- add suffixes to list if filenames
-# argv[1] list of filenames
-# argv[2] string to add.
-#
-proc add_suffix {lst suf} {
- set l ""
- foreach i $lst {lappend l ${i}${suf}}
- return $l
-}
-
-#######################################################################
-# add_prefix -- add prefixes to list if filenames
-# argv[1] list of filenames
-# argv[2] string to add.
-#
-proc add_prefix {lst prf} {
- set l ""
- foreach i $lst {lappend l ${prf}${i}}
- return $l
-}
-
-#######################################################################
-# basename -- removes directory-prefixes from list of names.
-# argv[1] list of filenames
-#
-proc basename {lst} {
- set l ""
- foreach i $lst {regsub {.*/} $i {} i ; lappend l $i}
- return $l
-}
-
-#######################################################################
-# makefile_macro -- return the contents of a Makefile macro
-# argv[1] name of macro
-# argv[2] source directory
-# argv[3] (optional) name of makefile
-#
-proc makefile_macro {macro dir {makefile Makefile}} {
- # Nobody will miss a core file, right ?
- sh "cd $dir ; cp $makefile make.core"
- set f [open $dir/make.core a]
- puts $f "\n\nGNU2TCL_test:\n\t@echo \$\{$macro\}"
- close $f
- set a [exec sh -e -c "cd $dir ; make -f make.core GNU2TCL_test"]
- sh "rm -f $dir/make.core"
- return $a
-}
-
-#######################################################################
-# mk_prog -- Make a directory and Makefile for a program.
-# argv[1] name of the parent-directory
-# argv[2] name of the program
-# argv[3] list of .c files (the SRCS macro content).
-# argv[4] (optional) list of lines for the Makefile
-#
-proc mk_prog {ddir name list {make ""}} {
- sh "mkdir $ddir/$name"
- set f [open $ddir/$name/Makefile w]
- puts $f "#\n# \$Id$\n#\n"
- puts $f "PROG =\t$name"
- puts $f "SRCS =\t[lsort $list]"
- foreach i $make {puts $f $i}
- puts $f "\n.include <bsd.prog.mk>"
- close $f
-}
-
-#######################################################################
-# mk_lib -- Make a directory and Makefile for a library
-# argv[1] name of the parent-directory
-# argv[2] name of the library
-# argv[3] list of .c files (the SRCS macro content).
-# argv[4] (optional) list of lines for the Makefile
-#
-proc mk_lib {ddir name list {make ""}} {
- sh "mkdir $ddir/$name"
- set f [open $ddir/$name/Makefile w]
- puts $f "#\n# \$Id$\n#\n"
- puts $f "SRCS =\t[lsort $list]"
- puts $f "LIB =\t$name"
- foreach i $make {puts $f $i}
- puts $f "\n.include <bsd.lib.mk>"
- close $f
-}
-
-#######################################################################
-# common_set -- Return the files common to a list of lists.
-# argv[] lists of filenames
-#
-proc common_set {args} {
- set a(0) 0 ; unset a(0)
- foreach i $args {
- foreach j $i {if {[catch {incr a($j)} k]} {set a($j) 1}}
- }
- set j ""
- foreach i [array names a] {
- if {$a($i) > 1} {lappend j $i}
- }
- return $j
-}
-
-#######################################################################
-# reduce_by -- Remove elements from list, if present in 2nd list.
-# argv[1] lists of filenames
-# argv[2] lists of filenames to be removed.
-#
-proc reduce_by {l1 l2} {
- set a(0) 0 ; unset a(0)
- foreach j $l1 { if {[catch {incr a($j)} k]} {set a($j) 1} }
- foreach j $l2 { catch {unset a($j)} }
- return [array names a]
-}
diff --git a/gnu/gnu2bmake/libg++-2.6.patch b/gnu/gnu2bmake/libg++-2.6.patch
deleted file mode 100644
index 442342e..0000000
--- a/gnu/gnu2bmake/libg++-2.6.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-This patch fixes two things:
-config.guess:
- i[34]86-*-FreeBSD* -> i386--bsd
-
-libio/gen-params:
- We use hex in limits.h
-
-Poul-Henning Kamp
-phk@login.dkuug.dk
-
-diff -C2 -r libg++-2.6.orig/config.guess libg++-2.6/config.guess
-*** libg++-2.6.orig/config.guess Sat Jul 16 12:11:08 1994
---- libg++-2.6/config.guess Sun Jul 31 20:45:59 1994
-***************
-*** 197,201 ****
- exit 0 ;;
- i[34]86:FreeBSD:*:*)
-! echo ${UNAME_MACHINE}-unknown-freebsd${UNAME_RELEASE}
- exit 0 ;;
- i[34]86:NetBSD:*:*)
---- 197,201 ----
- exit 0 ;;
- i[34]86:FreeBSD:*:*)
-! echo ${UNAME_MACHINE}-unknown-bsd
- exit 0 ;;
- i[34]86:NetBSD:*:*)
diff --git a/gnu/gnu2bmake/libg++-2.6.tcl b/gnu/gnu2bmake/libg++-2.6.tcl
deleted file mode 100644
index b5d21c2..0000000
--- a/gnu/gnu2bmake/libg++-2.6.tcl
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/local/bin/tclsh
-#
-# ----------------------------------------------------------------------------
-# "THE BEER-WARE LICENSE" (Revision 42):
-# <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
-# can do whatever you want with this stuff. If we meet some day, and you think
-# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
-# ----------------------------------------------------------------------------
-#
-# $Id$
-#
-
-source gnu2bmake.tcl
-
-#######################################################################
-# Parameters to tweak
-########
-set sdir /a/phk/libg++-2.6
-set ddir /a/phk/libg++26
-
-#######################################################################
-# Do the stunt
-########
-sh "cd $sdir ; sh configure i386--bsd"
-
-sh "cd $sdir/libiberty ; make needed-list"
-set l_ib [find_source $sdir/libiberty \
- [zap_suffix \
- [makefile_macro LIBIBERTY_OBJECTS_TO_GET \
- $sdir/libiberty $sdir/libg++/Makefile] \
- ] \
- {.cc .C .c}]
-set l_io [find_source $sdir/libio [zap_suffix [makefile_macro \
- LIBIOSTREAM_OBJECTS $sdir/libio]] {.cc .C .c}]
-
-set l_plus [find_source $sdir/libg++/src \
- [zap_suffix [makefile_macro OBJS $sdir/libg++/src]] {.cc .C .c}]
-
-set l_ioh ""
-foreach i [zap_suffix $l_io] {
- if {[file exists $sdir/libio/${i}.h]} { lappend l_ioh ${i}.h }
-}
-set l_plush ""
-foreach i [zap_suffix $l_plus] {
- if {[file exists $sdir/libg++/src/${i}.h]} { lappend l_plush ${i}.h }
-}
-
-# do ~
-sh "rm -rf $ddir"
-sh "mkdir $ddir $ddir/libg++ $ddir/libio $ddir/libiberty $ddir/include"
-
-copy_l $sdir/libiberty $ddir/libiberty $l_ib
-copy_l $sdir/libiberty $ddir/include {config.h}
-copy_l $sdir/libio $ddir/libio $l_io
-copy_l $sdir/libio $ddir/include $l_ioh
-copy_l $sdir/libio $ddir/include {_G_config.h libioP.h floatio.h strfile.h
- iostreamP.h libio.h iolibio.h}
-copy_l $sdir/libg++/src $ddir/libg++ $l_plus
-copy_l $sdir/libg++/src $ddir/include $l_plush
-copy_l $sdir/libg++/src $ddir/include {defines.h std.h bitprims.h Integer.hP
- bitdo1.h bitdo2.h Pix.h}
-copy_l $sdir/include $ddir/include {ansidecl.h libiberty.h}
-
-set f [open $ddir/Makefile w]
-puts $f "#\n# \$FreeBSD\$\n#\n"
-puts $f "SRCS=\t$l_ib"
-puts $f "SRCS+=\t$l_io"
-puts $f "SRCS+=\t$l_plus"
-puts $f "LIB=\tlibg++"
-puts $f "NOMAN=\tnoman"
-puts $f "CFLAGS+=\t-nostdinc -I\${.CURDIR}/include -I/usr/include"
-puts $f "CXXFLAGS+=\t-fexternal-templates"
-puts $f ".PATH:\t\${.CURDIR}/libiberty \${.CURDIR}/libio \${.CURDIR}/libg++"
-puts $f {
-beforeinstall:
- @-if [ ! -d ${DESTDIR}/usr/include/g++ ]; then \
- mkdir ${DESTDIR}/usr/include/g++; \
- chown ${BINOWN}.${BINGRP} ${DESTDIR}/usr/include/g++; \
- chmod 755 ${DESTDIR}/usr/include/g++; \
- fi
- @(cd include ; for j in *.h; do \
- cmp -s $$j ${DESTDIR}/usr/include/g++/$$j || \
- install -c -o ${BINOWN} -g ${BINGRP} -m 444 $$j \
- ${DESTDIR}/usr/include/$$j; \
- done)
-}
-puts $f ".include <bsd.lib.mk>"
-close $f
-exit 0
diff --git a/gnu/include/Makefile b/gnu/include/Makefile
deleted file mode 100644
index a6faf89..0000000
--- a/gnu/include/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Id$
-
-NOOBJ= noobj
-
-beforeinstall:
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/values.h \
- ${DESTDIR}/usr/include
-
-.include <bsd.prog.mk>
diff --git a/gnu/include/values.h b/gnu/include/values.h
deleted file mode 100644
index 9ba3e23..0000000
--- a/gnu/include/values.h
+++ /dev/null
@@ -1,177 +0,0 @@
-#if __GNUC__
-#warning "this file includes <values.h> which is obsoleted, use <limits.h> or <float.h> instead"
-#endif
-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library 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 Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-#ifndef _VALUES_H_
-#define _VALUES_H_
-
-#define BITSPERBYTE 8
-#define BITS(type) (BITSPERBYTE * (int)sizeof(type))
-
-#define CHARBITS BITS(char)
-#define SHORTBITS BITS(short)
-#define INTBITS BITS(int)
-#define LONGBITS BITS(long)
-#define PTRBITS BITS(char*)
-#define DOUBLEBITS BITS(double)
-#define FLOATBITS BITS(float)
-
-#define MINSHORT ((short)(1 << (SHORTBITS - 1)))
-#define MININT (1 << (INTBITS - 1))
-#define MINLONG (1L << (LONGBITS - 1))
-
-#define MAXSHORT ((short)~MINSHORT)
-#define MAXINT (~MININT)
-#define MAXLONG (~MINLONG)
-
-#define HIBITS MINSHORT
-#define HIBITL MINLONG
-
-#if defined(sun) || defined(hp300) || defined(hpux) || defined(masscomp) || defined(sgi)
-#ifdef masscomp
-#define MAXDOUBLE \
-({ \
- double maxdouble_val; \
- \
- __asm ("fmove%.d #0x7fefffffffffffff,%0" /* Max double */ \
- : "=f" (maxdouble_val) \
- : /* no inputs */); \
- maxdouble_val; \
-})
-#define MAXFLOAT ((float) 3.40e+38)
-#else
-#define MAXDOUBLE 1.79769313486231470e+308
-#define MAXFLOAT ((float)3.40282346638528860e+38)
-#endif
-#define MINDOUBLE 4.94065645841246544e-324
-#define MINFLOAT ((float)1.40129846432481707e-45)
-#define _IEEE 1
-#define _DEXPLEN 11
-#define _FEXPLEN 8
-#define _HIDDENBIT 1
-#define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
-#define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
-#define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
-#define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
-
-#elif defined(sony)
-#define MAXDOUBLE 1.79769313486231470e+308
-#define MAXFLOAT ((float)3.40282346638528860e+38)
-#define MINDOUBLE 2.2250738585072010e-308
-#define MINFLOAT ((float)1.17549435e-38)
-#define _IEEE 1
-#define _DEXPLEN 11
-#define _FEXPLEN 8
-#define _HIDDENBIT 1
-#define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
-#define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
-#define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
-#define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
-
-#elif defined(sequent)
-extern double _maxdouble, _mindouble;
-extern float _maxfloat, _minfloat;
-#define MAXDOUBLE _maxdouble
-#define MAXFLOAT _maxfloat
-#define MINDOUBLE _mindouble
-#define MINFLOAT _minfloat
-#define _IEEE 1
-#define _DEXPLEN 11
-#define _FEXPLEN 8
-#define _HIDDENBIT 1
-#define DMINEXP (-(DMAXEXP - 3))
-#define FMINEXP (-(FMAXEXP - 3))
-#define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
-#define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
-
-#elif defined(i386)
-#define MAXDOUBLE 1.79769313486231570e+308
-#define MAXFLOAT ((float)3.40282346638528860e+38)
-#define MINDOUBLE 2.22507385850720140e-308
-#define MINFLOAT ((float)1.17549435082228750e-38)
-#define _IEEE 0
-#define _DEXPLEN 11
-#define _FEXPLEN 8
-#define _HIDDENBIT 1
-#define DMINEXP (-DMAXEXP)
-#define FMINEXP (-FMAXEXP)
-#define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
-#define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
-
-/* from Andrew Klossner <andrew%frip.wv.tek.com@relay.cs.net> */
-#elif defined(m88k)
- /* These are "good" guesses ...
- I'll figure out the true mins and maxes later, at the time I find
- out the mins and maxes that the compiler can tokenize. */
-#define MAXDOUBLE 1.79769313486231e+308
-#define MAXFLOAT ((float)3.40282346638528e+38)
-#define MINDOUBLE 2.22507385850720e-308
-#define MINFLOAT ((float)1.17549435082228e-38)
-#define _IEEE 1
-#define _DEXPLEN 11
-#define _FEXPLEN 8
-#define _HIDDENBIT 1
-#define DMINEXP (1-DMAXEXP)
-#define FMINEXP (1-FMAXEXP)
-#define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
-#define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
-
-#elif defined(convex)
-#define MAXDOUBLE 8.9884656743115785e+306
-#define MAXFLOAT ((float) 1.70141173e+38)
-#define MINDOUBLE 5.5626846462680035e-308
-#define MINFLOAT ((float) 2.93873588e-39)
-#define _IEEE 0
-#define _DEXPLEN 11
-#define _FEXPLEN 8
-#define _HIDDENBIT 1
-#define DMINEXP (-DMAXEXP)
-#define FMINEXP (-FMAXEXP)
-#define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
-#define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
-
-/* #elif defined(vax) */
-/* use vax versions by default -- they seem to be the most conservative */
-#else
-
-#define MAXDOUBLE 1.701411834604692293e+38
-#define MINDOUBLE (2.938735877055718770e-39)
-
-#define MAXFLOAT 1.7014117331926443e+38
-#define MINFLOAT 2.9387358770557188e-39
-
-#define _IEEE 0
-#define _DEXPLEN 8
-#define _FEXPLEN 8
-#define _HIDDENBIT 1
-#define DMINEXP (-DMAXEXP)
-#define FMINEXP (-FMAXEXP)
-#define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
-#define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
-#endif
-
-#define DSIGNIF (DOUBLEBITS - _DEXPLEN + _HIDDENBIT - 1)
-#define FSIGNIF (FLOATBITS - _FEXPLEN + _HIDDENBIT - 1)
-#define DMAXPOWTWO ((double)(1L << LONGBITS -2)*(1L << DSIGNIF - LONGBITS +1))
-#define FMAXPOWTWO ((float)(1L << FSIGNIF - 1))
-
-#endif /* !_VALUES_H_ */
-
diff --git a/gnu/lib/Makefile b/gnu/lib/Makefile
deleted file mode 100644
index 9a6b3bf..0000000
--- a/gnu/lib/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id: Makefile,v 1.15 1997/02/22 15:42:33 peter Exp $
-
-SUBDIR= libdialog libg++
-
-.if ${MACHINE} != "alpha"
-SUBDIR+= libgmp libmp
-.endif
-
-SUBDIR+= libobjc libregex libreadline libstdc++
-
-.include <bsd.subdir.mk>
diff --git a/gnu/lib/Makefile.inc b/gnu/lib/Makefile.inc
deleted file mode 100644
index 12f592c..0000000
--- a/gnu/lib/Makefile.inc
+++ /dev/null
@@ -1,8 +0,0 @@
-# $Id$
-
-SHLIB_MAJOR?= 2
-SHLIB_MINOR?= 0
-
-
-# NB: SHLIB major and minor nos. must also be specified in libg++/Makefile.inc
-# (This is due to the deeper tree structure of libg++)
diff --git a/gnu/lib/libdialog/CHANGES b/gnu/lib/libdialog/CHANGES
deleted file mode 100644
index 1467a0e..0000000
--- a/gnu/lib/libdialog/CHANGES
+++ /dev/null
@@ -1,9 +0,0 @@
-- Added two variables to call to dialog_menu() to save the position
- in the menu when choosing a menu-option.
-
-- Added dialog_fselect(), implements a fileselector dialog
-- Added ui-interface objects: Stringobject, Listobject and Buttonobject.
- The fileselector dialog was built using these objects.
-- changed dialog_menu to use PGUP and PGDN
-- Added dialog_mesgbox, which display text given in a char buffer.
--
diff --git a/gnu/lib/libdialog/COPYING b/gnu/lib/libdialog/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/lib/libdialog/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/lib/libdialog/Makefile b/gnu/lib/libdialog/Makefile
deleted file mode 100644
index 167098e..0000000
--- a/gnu/lib/libdialog/Makefile
+++ /dev/null
@@ -1,37 +0,0 @@
-# Makefile for libdialog
-# $Id$
-
-LIB= dialog
-MAN3= dialog.3
-
-SHLIB_MAJOR= 3
-SHLIB_MINOR= 0
-SRCS= kernel.c rc.c checklist.c inputbox.c menubox.c msgbox.c \
- lineedit.c radiolist.c textbox.c yesno.c prgbox.c raw_popen.c \
- fselect.c ui_objects.c dir.c notify.c help.c gauge.c
-
-CFLAGS+= -I${.CURDIR} -Wall -Wstrict-prototypes -DLOCALE
-
-LDADD+= -lncurses -lmytinfo
-DPADD+= ${LIBNCURSES} ${LIBMYTINFO}
-
-beforeinstall:
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/dialog.h \
- ${DESTDIR}/usr/include
-
-MLINKS+=dialog.3 draw_shadow.3 dialog.3 draw_box.3 \
- dialog.3 line_edit.3 dialog.3 strheight.3 \
- dialog.3 strwidth.3 dialog.3 dialog_create_rc.3 \
- dialog.3 dialog_yesno.3 dialog.3 dialog_prgbox.3 \
- dialog.3 dialog_textbox.3 dialog.3 dialog_menu.3 \
- dialog.3 dialog_checklist.3 dialog.3 dialog_radiolist.3 \
- dialog.3 dialog_inputbox.3 dialog.3 dialog_clear_norefresh.3 \
- dialog.3 dialog_clear.3 dialog.3 dialog_update.3 \
- dialog.3 dialog_fselect.3 dialog.3 dialog_notify.3 \
- dialog.3 dialog_mesgbox.3 dialog.3 dialog_gauge.3 \
- dialog.3 init_dialog.3 dialog.3 end_dialog.3 \
- dialog.3 use_helpfile.3 dialog.3 use_helpline.3 \
- dialog.3 get_helpline.3 dialog.3 restore_helpline.3 \
- dialog.3 dialog_msgbox.3
-
-.include <bsd.lib.mk>
diff --git a/gnu/lib/libdialog/README b/gnu/lib/libdialog/README
deleted file mode 100644
index e5e6d56..0000000
--- a/gnu/lib/libdialog/README
+++ /dev/null
@@ -1,8 +0,0 @@
-This library was split out from the `dialog' program for use
-in C programs. For a list of interface functions, see dialog.h.
-For usage examples, see the `dialog' program sources in
-/usr/src/gnu/usr.bin/dialog.
-
-You can additionally use any ncurses functions after init_dialog().
-
- Ache.
diff --git a/gnu/lib/libdialog/TESTS/Makefile b/gnu/lib/libdialog/TESTS/Makefile
deleted file mode 100644
index ed0f2b7..0000000
--- a/gnu/lib/libdialog/TESTS/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Really quick and evil Makefile for building all the tests. I wish that bmake was friendlier to
-# the concept of multiple progs/libs in the same directory.
-# $Id$
-
-PROGS= msg yesno prgbox gauge dselect fselect text menu1 menu2 menu3 \
- input1 input2 check1 check2 check3 radio1 radio2 radio3
-
-CFLAGS+= -Wall -Wstrict-prototypes
-LDFLAGS += -ldialog -lncurses -lmytinfo
-
-all: ${PROGS}
-
-clean:
- rm -f ${PROGS}
-
-.include <bsd.prog.mk>
diff --git a/gnu/lib/libdialog/TESTS/check1.c b/gnu/lib/libdialog/TESTS/check1.c
deleted file mode 100644
index fe4f6c8..0000000
--- a/gnu/lib/libdialog/TESTS/check1.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Hook functions */
-
-static int
-getBool(dialogMenuItem *self)
-{
- if (self->data && *((int *)self->data))
- return TRUE;
- return FALSE;
-}
-
-static int
-setBool(dialogMenuItem *self)
-{
- if (self->data) {
- *((int *)self->data) = !*((int *)self->data);
- return DITEM_SUCCESS;
- }
- return DITEM_FAILURE;
-}
-
-static int german_book, italian_book, slang_book;
-
-static int
-clearBooks(dialogMenuItem *self)
-{
- german_book = italian_book = slang_book = FALSE;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-/* menu2 - A more advanced way of using checked and fire hooks to manipulate the backing-variables directly */
-/* prompt title checked fire sel data */
-static dialogMenuItem menu2[] = {
- { "German", "Buy book on learning German", getBool, setBool, NULL, &german_book},
- { "Italian", "Buy book on learning Italian", getBool, setBool, NULL, &italian_book },
- { "Slang", "Buy book on commonly used insults", getBool, setBool, NULL, &slang_book },
- { "Clear", "Clear book list", NULL, clearBooks, NULL, NULL, ' ', ' ', ' ' },
-};
-
-/* End of hook functions */
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
- retval = dialog_checklist("this is a dialog_checklist() in action, test #1",
- "this checklist menu shows off some of the straight-forward features\n"
- "of the new menu system's check & fire dispatch hooks", -1, -1, 4, -4, menu2, NULL);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_checklist was %d (%d %d %d)\n", retval, german_book, italian_book, slang_book);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/check2.c b/gnu/lib/libdialog/TESTS/check2.c
deleted file mode 100644
index 7e5320e..0000000
--- a/gnu/lib/libdialog/TESTS/check2.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Hook functions */
-
-static int
-getBool(dialogMenuItem *self)
-{
- if (self->data && *((int *)self->data))
- return TRUE;
- return FALSE;
-}
-
-static int
-setBool(dialogMenuItem *self)
-{
- if (self->data) {
- *((int *)self->data) = !*((int *)self->data);
- return DITEM_SUCCESS;
- }
- return DITEM_FAILURE;
-}
-
-static int german_book, italian_book, slang_book;
-
-static int
-clearBooks(dialogMenuItem *self)
-{
- german_book = italian_book = slang_book = FALSE;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-buyBooks(dialogMenuItem *self)
-{
- char foo[256];
-
- if (german_book || italian_book || slang_book) {
- strcpy(foo, "Ok, you're buying books on");
- if (german_book)
- strcat(foo, " german");
- if (italian_book)
- strcat(foo, " italian");
- if (slang_book)
- strcat(foo, " slang");
- }
- else
- strcpy(foo, "You're not buying any books?");
- dialog_mesgbox("This is a direct callback for the `Buy' button", foo, -1, -1);
- return DITEM_SUCCESS;
-}
-
-/* menu3 - Look mom! We can finally use our own OK and Cancel buttons! */
-/* prompt title checked fire sel data */
-static dialogMenuItem menu3[] = {
- { "Buy!", NULL, NULL, buyBooks }, /* New "OK" button */
- { "No Way!", NULL, NULL, NULL }, /* New "Cancel" button */
- { "German", "Buy books on learning German", getBool, setBool, NULL, &german_book },
- { "Italian", "Buy books on learning Italian", getBool, setBool, NULL, &italian_book },
- { "Slang", "Buy books on commonly used insults", getBool, setBool, NULL, &slang_book },
- { "Clear", "Clear book list", NULL, clearBooks, NULL, NULL, ' ', ' ', ' ' },
-};
-
-/* End of hook functions */
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
- retval = dialog_checklist("this is dialog_checklist() in action, test #2",
- "Same as before, but now we relabel the buttons and override the OK action.",
- -1, -1, 4, -4, menu3 + 2, (char *)TRUE);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_checklist was %d\n", retval);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/check3.c b/gnu/lib/libdialog/TESTS/check3.c
deleted file mode 100644
index 8c8f4bf..0000000
--- a/gnu/lib/libdialog/TESTS/check3.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- *
- */
-
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Hook functions */
-
-static int
-getBool(dialogMenuItem *self)
-{
- if (self->data && *((int *)self->data))
- return TRUE;
- return FALSE;
-}
-
-static int
-setBool(dialogMenuItem *self)
-{
- if (self->data) {
- *((int *)self->data) = !*((int *)self->data);
- return DITEM_SUCCESS;
- }
- return DITEM_FAILURE;
-}
-
-static int german_book, italian_book, slang_book;
-static int spending;
-
-static int
-check(dialogMenuItem *self)
-{
- return ((int)self->data == spending);
-}
-
-static int
-spend(dialogMenuItem *self)
-{
- spending = (int)self->data;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-/* menu4 - Show off a simulated compound menu (group at top is checklist, group at bottom radio) */
-/* prompt title checked fire sel, data lbra mark rbra */
-static dialogMenuItem menu4[] = {
- { "German", "Buy books on learning German", getBool, setBool, NULL, &german_book },
- { "Italian","Buy books on learning Italian", getBool, setBool, NULL, &italian_book },
- { "Slang", "Buy books on commonly used insults", getBool, setBool, NULL, &slang_book },
- { "-----", "----------------------------------", NULL, NULL, NULL, NULL, ' ', ' ', ' ' },
- { "1000", "Spend $1,000", check, spend, NULL, (void *)1000, '(', '*', ')' },
- { "500", "Spend $500", check, spend, NULL, (void *)500, '(', '*', ')' },
- { "100", "Spend $100", check, spend, NULL, (void *)100, '(', '*', ')' },
-};
-
-/* End of hook functions */
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
-
- retval = dialog_checklist("this is dialog_checklist() in action, test #3",
- "Now we show off some of the button 'styles' one can create.",
- -1, -1, 7, -7, menu4, NULL);
- dialog_clear();
- fprintf(stderr, "spent $%d on %s%s%s books\n", spending, german_book ? " german" : "",
- italian_book ? " italian" : "", slang_book ? " slang" : "");
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/dselect.c b/gnu/lib/libdialog/TESTS/dselect.c
deleted file mode 100644
index 3196075..0000000
--- a/gnu/lib/libdialog/TESTS/dselect.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
- retval = dialog_dselect(".", "*");
- dialog_clear();
- fprintf(stderr, "returned value for dialog_dselect was %d\n", retval);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/fselect.c b/gnu/lib/libdialog/TESTS/fselect.c
deleted file mode 100644
index d8511ad..0000000
--- a/gnu/lib/libdialog/TESTS/fselect.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- char *retval;
-
- init_dialog();
-
- retval = dialog_fselect(".", "*.[ch]");
- dialog_clear();
- if (retval)
- fprintf(stderr, "returned value for dialog_fselect was %s\n", retval);
- else
- fprintf(stderr, "returned value for dialog_fselect was NULL\n");
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/gauge.c b/gnu/lib/libdialog/TESTS/gauge.c
deleted file mode 100644
index a160bda..0000000
--- a/gnu/lib/libdialog/TESTS/gauge.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int i;
-
- init_dialog();
-
- for (i = 0; i <= 100; i++) {
- dialog_gauge("Gas tank", "When this gets 100% full, you'd better yank out the nozzle!", 10, 1, 7, 70, i);
- usleep(30000);
- }
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/input1.c b/gnu/lib/libdialog/TESTS/input1.c
deleted file mode 100644
index fa4f13f..0000000
--- a/gnu/lib/libdialog/TESTS/input1.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
- unsigned char result[128];
-
- init_dialog();
-
- strcpy(result, "not this!");
- retval = dialog_inputbox("this is dialog_inputbox() in action, test #1",
- "Enter something really profound below, please.",
- -1, -1, result);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_inputbox was %d (%s)\n", retval, result);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/input2.c b/gnu/lib/libdialog/TESTS/input2.c
deleted file mode 100644
index 9c6b2da..0000000
--- a/gnu/lib/libdialog/TESTS/input2.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
- unsigned char result[128];
-
- init_dialog();
-
- result[0]='\0';
- DialogInputAttrs |= DITEM_NO_ECHO;
- retval = dialog_inputbox("this is dialog_inputbox() in action, test #2 (no echo)",
- "Enter something really secret below, please.",
- -1, -1, result);
- DialogInputAttrs &= DITEM_NO_ECHO;
- dialog_clear();
- fprintf(stderr, "returned value for dialog_inputbox was %d (%s)\n", retval, result);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/menu1.c b/gnu/lib/libdialog/TESTS/menu1.c
deleted file mode 100644
index a861c46..0000000
--- a/gnu/lib/libdialog/TESTS/menu1.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Start of hook functions */
-static enum { nowhere, berlin, rome, ny } where;
-
-static int
-_menu1_berlin_action(dialogMenuItem *self)
-{
- if (where == berlin) {
- dialog_mesgbox("excuse me?", "But you're already *in* Berlin!", -1, -1);
- }
- else {
- where = berlin;
- dialog_mesgbox("whoosh!", "Welcome to Berlin! Have a beer!", -1, -1);
- }
- return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
-}
-
-static int
-_menu1_rome_action(dialogMenuItem *self)
-{
- if (where == rome) {
- dialog_mesgbox("The wine must be getting to you..", "You're already in Rome!", -1, -1);
- }
- else {
- where = rome;
- dialog_mesgbox("whoosh!", "Welcome to Rome! Have a coffee!", -1, -1);
- }
- return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
-}
-
-static int
-_menu1_ny_action(dialogMenuItem *self)
-{
- if (where == ny) {
- dialog_mesgbox("Say what?", "You're already there!", -1, -1);
- }
- else {
- where = ny;
- dialog_mesgbox("whoosh!", "Welcome to New York! Now go someplace else!", -1, -1);
- }
- return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
-}
-
-/* menu1 - show off the "fire" action hook */
-/* prompt title checked fire */
-static dialogMenuItem menu1[] = {
- { "Berlin", "Go visit Germany's new capitol", NULL, _menu1_berlin_action },
- { "Rome", "Go visit the Roman ruins", NULL, _menu1_rome_action },
- { "New York", "Go visit the streets of New York", NULL, _menu1_ny_action },
-};
-
-/* End of hook functions */
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
- retval = dialog_menu("this is dialog_menu() in action, test #1",
- "this simple menu shows off some of the straight-forward features\n"
- "of the new menu system's action dispatch hooks. Select Cancel to leave",
- -1, -1, 3, -3, menu1, NULL, NULL, NULL);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_menu was %d\n", retval);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/menu2.c b/gnu/lib/libdialog/TESTS/menu2.c
deleted file mode 100644
index d572b52..0000000
--- a/gnu/lib/libdialog/TESTS/menu2.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Start of hook functions */
-static enum { nowhere, berlin, rome, ny } where;
-
-static int
-_menu1_berlin_action(dialogMenuItem *self)
-{
- if (where == berlin)
- dialog_mesgbox("excuse me?", "But you're already *in* Berlin!", -1, -1);
- else {
- where = berlin;
- dialog_mesgbox("whoosh!", "Welcome to Berlin! Have a beer!", -1, -1);
- }
- return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
-}
-
-static int
-_menu1_rome_action(dialogMenuItem *self)
-{
- if (where == rome)
- dialog_mesgbox("The wine must be getting to you..", "You're already in Rome!", -1, -1);
- else {
- where = rome;
- dialog_mesgbox("whoosh!", "Welcome to Rome! Have a coffee!", -1, -1);
- }
- return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
-}
-
-static int
-_menu1_ny_action(dialogMenuItem *self)
-{
- if (where == ny)
- dialog_mesgbox("Say what?", "You're already there!", -1, -1);
- else {
- where = ny;
- dialog_mesgbox("whoosh!", "Welcome to New York! Now go someplace else!", -1, -1);
- }
- return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
-}
-
-/* menu1 - show off the "fire" action hook */
-/* prompt title checked fire */
-static dialogMenuItem menu1[] = {
- { "Berlin", "Go visit Germany's new capitol", NULL, _menu1_berlin_action },
- { "Rome", "Go visit the Roman ruins", NULL, _menu1_rome_action },
- { "New York", "Go visit the streets of New York", NULL, _menu1_ny_action },
-};
-
-/* End of hook functions */
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
- use_helpfile("menu2.c");
- use_helpline("Type F1 to view the source for this demo");
- retval = dialog_menu("this is dialog_menu() in action, test #2",
- "this simple menu shows off some of the straight-forward features\n"
- "of the new menu system's action dispatch hooks as well as a helpline\n"
- "and a helpfile. Select Cancel to leave",
- -1, -1, 3, -3, menu1, NULL, NULL, NULL);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_menu was %d\n", retval);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/menu3.c b/gnu/lib/libdialog/TESTS/menu3.c
deleted file mode 100644
index 6409f3a..0000000
--- a/gnu/lib/libdialog/TESTS/menu3.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Hook functions */
-
-static int
-stop(dialogMenuItem *self)
-{
- dialog_mesgbox("!", "I'm no idiot!", -1, -1);
- return DITEM_SUCCESS;
-}
-
-static int
-maybe(dialogMenuItem *self)
-{
- dialog_mesgbox("!", "I said don't rush me! I'm THINKING!", -1, -1);
- return DITEM_SUCCESS | DITEM_RESTORE | DITEM_CONTINUE;
-}
-
-/* Dummy menu just to show of the ability */
-static char *insurance[] = {
- "1,000,000", "Mondo insurance policy", "Off",
- "5,000,000", "Mega insurance policy", "Off",
- "10,000,000", "Friend! Most Favored customer!"
-};
-
-static void
-preinsure(dialogMenuItem *self, int is_selected)
-{
- if (is_selected) {
- static WINDOW *w;
-
- /* This has to be here first if you want to see selection traverse properly in the invoking menu */
- refresh();
-
- w = dupwin(newscr);
- DialogX = 1;
- DialogY = 13;
- dialog_radiolist("How much insurance would you like to take out?",
- "If you're really going to do this, we recommend some insurance\n"
- "first! What kind of life insurance policy would you like?",
- -1, -1, 3, 3, insurance, NULL);
- touchwin(w);
- wrefresh(w);
- delwin(w);
- }
-}
-
-/*
- * Show a simple menu that puts up a sub menu when a certain item is traversed to
- */
-
-/* prompt title checked fire sel */
-static dialogMenuItem doit[] = {
- { "Rah!" },
- { "No way!" },
- { "Stop", "No, I'm not going to do that!", NULL, stop, NULL },
- { "Maybe", "I'm still thinking about it, don't rush me!", NULL, maybe, NULL, },
- { "Go", "Yes! Yes! I want to do it!", NULL, NULL, preinsure },
-};
-
-/* End of hook functions */
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
-
- DialogX = 5;
- DialogY = 1;
- retval = dialog_menu("Do you have the GUTS?",
- "C'mon, macho man! Do you have what it takes to do something REALLY\n"
- "dangerous and stupid? WHAT ARE YOU WAITING FOR?!",
- -1, -1, 3, -3, doit + 2, (char *)TRUE, NULL, NULL);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_menu was %d\n", retval);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/msg.c b/gnu/lib/libdialog/TESTS/msg.c
deleted file mode 100644
index 591e69b..0000000
--- a/gnu/lib/libdialog/TESTS/msg.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
- retval = dialog_msgbox("This is dialog_msgbox() in action with pause on", "Hi there. Please press return now.",
- -1, -1, 1);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_msgbox was %d\n", retval);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/prgbox.c b/gnu/lib/libdialog/TESTS/prgbox.c
deleted file mode 100644
index 697f96c..0000000
--- a/gnu/lib/libdialog/TESTS/prgbox.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
- retval = dialog_prgbox("This is dialog_prgbox() in action with cal(1)", "cal", 14, 50, TRUE, TRUE);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_prgbox was %d\n", retval);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/radio1.c b/gnu/lib/libdialog/TESTS/radio1.c
deleted file mode 100644
index e9676ba..0000000
--- a/gnu/lib/libdialog/TESTS/radio1.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Hook functions */
-
-static int spending;
-
-static int
-check(dialogMenuItem *self)
-{
- return ((int)self->data == spending);
-}
-
-static int
-spend(dialogMenuItem *self)
-{
- spending = (int)self->data;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-/* menu5 - Show a simple radiolist menu that inherits the radio appearance by default */
-/* prompt title checked fire sel data */
-static dialogMenuItem menu5[] = {
- { "1000", "Spend $1,000", check, spend, NULL, (void *)1000 },
- { "500", "Spend $500", check, spend, NULL, (void *)500 },
- { "100", "Spend $100", check, spend, NULL, (void *)100 },
-};
-
-/* End of hook functions */
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
-
- retval = dialog_radiolist("this is dialog_radiolist() in action, test #1",
- "this radio menu shows off some of the straight-forward features\n"
- "of the new menu system's check & fire dispatch hooks", -1, -1, 3, -3, menu5, NULL);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_radiolist was %d (money set to %d)\n", retval, spending);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/radio2.c b/gnu/lib/libdialog/TESTS/radio2.c
deleted file mode 100644
index f5436b6..0000000
--- a/gnu/lib/libdialog/TESTS/radio2.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Hook functions */
-
-static char bachelor[10], bachelette[10];
-
-static int
-getBachelor(dialogMenuItem *self)
-{
- return !strcmp(bachelor, self->prompt);
-}
-
-static int
-setBachelor(dialogMenuItem *self)
-{
- strcpy(bachelor, self->prompt);
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-getBachelette(dialogMenuItem *self)
-{
- return !strcmp(bachelette, self->prompt);
-}
-
-static int
-setBachelette(dialogMenuItem *self)
-{
- strcpy(bachelette, self->prompt);
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-/* menu6- More complex radiolist menu that creates two groups in a single menu */
-/* prompt title checked fire */
-static dialogMenuItem menu6[] = {
- { "Tom", "Tom's a dynamic shoe salesman from Tulsa, OK!", getBachelor, setBachelor },
- { "Dick", "Dick's a retired engine inspector from McDonnell-Douglas!", getBachelor, setBachelor },
- { "Harry", "Harry's a professional female impersonator from Las Vegas!", getBachelor, setBachelor },
- { "-----", "----------------------------------", NULL, NULL, NULL, NULL, ' ', ' ', ' ' },
- { "Jane", "Jane's a twice-divorced housewife from Moose, Oregon!", getBachelette, setBachelette },
- { "Sally", "Sally's a shy Human Resources Manager for IBM!", getBachelette, setBachelette },
- { "Mary", "Mary's an energetic serial killer on the lam!", getBachelette, setBachelette },
-};
-
-/* End of hook functions */
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
- retval = dialog_radiolist("this is dialog_radiolist() in action, test #2",
- "Welcome to \"The Love Blender!\" - America's favorite game show\n"
- "where YOU, the contestant, get to choose which of these two\n"
- "fine specimens of humanity will go home together, whether they\n"
- "like it or not!", -1, -1, 7, -7, menu6, NULL);
- dialog_clear();
- fprintf(stderr, "I'm sure that %s and %s will be very happy together!\n", bachelor, bachelette);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/radio3.c b/gnu/lib/libdialog/TESTS/radio3.c
deleted file mode 100644
index 0c7e1fa..0000000
--- a/gnu/lib/libdialog/TESTS/radio3.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Hook functions */
-
-static int spending;
-
-static int
-check(dialogMenuItem *self)
-{
- return ((int)self->data == spending);
-}
-
-static int
-spend(dialogMenuItem *self)
-{
- spending = (int)self->data;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static void
-ask(dialogMenuItem *self, int is_selected)
-{
- if (is_selected) {
- char *str;
-
- if (!strcmp(self->prompt, "1000"))
- str = "You'd better ask both your parents first! ";
- else if (!strcmp(self->prompt, "500"))
- str = "You'd better at least ask your Dad! ";
- else
- str = "Yes, being frugal is probably a good idea!";
- DialogX = 15;
- DialogY = 17;
- dialog_msgbox("Free Advice", str, -1, -1, 0);
- }
-}
-
-/*
- * menu5 - Show a simple radiolist menu that inherits the radio appearance by default and appears at
- * a different location, leaving room for a msg box below it. This shows off the DialogX/DialogY extensions.
- */
-
-/* prompt title checked fire sel data */
-static dialogMenuItem menu5[] = {
- { "1000", "Spend $1,000", check, spend, ask, (void *)1000 },
- { "500", "Spend $500", check, spend, ask, (void *)500 },
- { "100", "Spend $100", check, spend, ask, (void *)100 },
-};
-
-/* End of hook functions */
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
-
- DialogX = 5;
- DialogY = 1;
- retval = dialog_radiolist("this is dialog_radiolist() in action, test #3",
- "This radio menu shows off the ability to put dialog menus and other\n"
- "controls at different locations, as well as the `selected' hook which\n"
- "lets you follow the traversal of the selection bar as well as what's\n"
- "selected.",
- -1, -1, 3, -3, menu5, NULL);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_radiolist was %d (money set to %d)\n", retval, spending);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/text.c b/gnu/lib/libdialog/TESTS/text.c
deleted file mode 100644
index 2f59973..0000000
--- a/gnu/lib/libdialog/TESTS/text.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
- retval = dialog_textbox("This is dialog_textbox() in action with /etc/passwd", "/etc/passwd", 10, 60);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_textbox was %d\n", retval);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TESTS/yesno.c b/gnu/lib/libdialog/TESTS/yesno.c
deleted file mode 100644
index 943ef0e..0000000
--- a/gnu/lib/libdialog/TESTS/yesno.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * small test-driver for new dialog functionality
- *
- * Copyright (c) 1995, Jordan Hubbard
- *
- * All rights reserved.
- *
- * This source code may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of the software nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-/* Kick it off, James! */
-int
-main(int argc, unsigned char *argv[])
-{
- int retval;
-
- init_dialog();
-
- retval = dialog_yesno("This is dialog_yesno() in action",
- "Have you stopped deliberately putting bugs into your code?", -1, -1);
- dialog_clear();
- fprintf(stderr, "returned value for dialog_yesno was %d\n", retval);
-
- end_dialog();
- return 0;
-}
diff --git a/gnu/lib/libdialog/TODO b/gnu/lib/libdialog/TODO
deleted file mode 100644
index 132a4a4..0000000
--- a/gnu/lib/libdialog/TODO
+++ /dev/null
@@ -1,36 +0,0 @@
-- cut off names in the listbox that are to long
-done 27Jan95
- The current behaviour may not be desirable. When browsing through
- long names these, when highlighted, will be shown with the first
- characters cut off, when not highlighted the last characters will
- be cut off.
-
-- look at behaviour of TAB key when browsing through directories.
-done 28Jan95
-
-- make sure the full name of the directory is written to the
- "Directory:"-box
-done 28Jan95
-
-- mark current selections in listbox when initializing the listobject
-Idontknow
-- test and use Notify() when checking for error conditions
-ok
-- test overall
-- adapt color of buttons when changing focus to the button.
-done 28Jan95
-- add shade to dialog_fselect()-window
-done 29Jan95
-- add (nn%) indication to lists.
-done 30Jan95
-- add use_helpfile()
-done 13Feb95
-- add use_helpline()
-
-NOTE: apparently there is a bug (or a strange interaction between pkg_manage
-and dialog_textbox) in dialog_textbox. When I use this routine to display
-the helpfile in display_helpfile() the program gets mysterious segmentation
-faults and bus errors.
-I now use dialog_mesgbox, after I have read the file into a buffer.
-
-
diff --git a/gnu/lib/libdialog/checklist.c b/gnu/lib/libdialog/checklist.c
deleted file mode 100644
index e5f9ddd..0000000
--- a/gnu/lib/libdialog/checklist.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * checklist.c -- implements the checklist box
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * Substantial rennovation: 12/18/95, Jordan K. Hubbard
- *
- * 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
- * of the License, 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.
- */
-
-
-#include <dialog.h>
-#include "dialog.priv.h"
-
-
-static void print_item(WINDOW *win, unsigned char *tag, unsigned char *item, int status, int choice, int selected, dialogMenuItem *me, int list_width, int item_x, int check_x);
-
-#define DREF(di, item) ((di) ? &((di)[(item)]) : NULL)
-
-/*
- * Display a dialog box with a list of options that can be turned on or off
- */
-int
-dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int width,
- int list_height, int cnt, void *it, unsigned char *result)
-{
- int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button, choice,
- l, k, scroll, max_choice, item_no = 0, *status;
- int redraw_menu = FALSE;
- int rval = 0;
- char okButton, cancelButton;
- WINDOW *dialog, *list;
- unsigned char **items = NULL;
- dialogMenuItem *ditems;
- int list_width, check_x, item_x;
-
- /* Allocate space for storing item on/off status */
- if ((status = alloca(sizeof(int) * abs(cnt))) == NULL) {
- endwin();
- fprintf(stderr, "\nCan't allocate memory in dialog_checklist().\n");
- exit(-1);
- }
-
-draw:
- choice = scroll = button = 0;
- /* Previous calling syntax, e.g. just a list of strings? */
- if (cnt >= 0) {
- items = it;
- ditems = NULL;
- item_no = cnt;
- /* Initializes status */
- for (i = 0; i < item_no; i++)
- status[i] = !strcasecmp(items[i*3 + 2], "on");
- }
- /* It's the new specification format - fake the rest of the code out */
- else {
- item_no = abs(cnt);
- ditems = it;
- if (!items)
- items = (unsigned char **)alloca((item_no * 3) * sizeof(unsigned char *));
-
- /* Initializes status */
- for (i = 0; i < item_no; i++) {
- status[i] = ditems[i].checked ? ditems[i].checked(&ditems[i]) : FALSE;
- items[i*3] = ditems[i].prompt;
- items[i*3 + 1] = ditems[i].title;
- items[i*3 + 2] = status[i] ? "on" : "off";
- }
- }
- max_choice = MIN(list_height, item_no);
-
- check_x = 0;
- item_x = 0;
- /* Find length of longest item in order to center checklist */
- for (i = 0; i < item_no; i++) {
- l = strlen(items[i*3]);
- for (j = 0; j < item_no; j++) {
- k = strlen(items[j*3 + 1]);
- check_x = MAX(check_x, l + k + 6);
- }
- item_x = MAX(item_x, l);
- }
- if (height < 0)
- height = strheight(prompt)+list_height+4+2;
- if (width < 0) {
- i = strwidth(prompt);
- j = ((title != NULL) ? strwidth(title) : 0);
- width = MAX(i,j);
- width = MAX(width,check_x+4)+4;
- }
- width = MAX(width,24);
-
- if (width > COLS)
- width = COLS;
- if (height > LINES)
- height = LINES;
- /* center dialog box on screen */
- x = (COLS - width)/2;
- y = (LINES - height)/2;
-
-#ifdef HAVE_NCURSES
- if (use_shadow)
- draw_shadow(stdscr, y, x, height, width);
-#endif
- dialog = newwin(height, width, y, x);
- if (dialog == NULL) {
- endwin();
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width, y, x);
- return -1;
- }
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
- wattrset(dialog, border_attr);
- wmove(dialog, height-3, 0);
- waddch(dialog, ACS_LTEE);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dialog_attr);
- waddch(dialog, ACS_RTEE);
- wmove(dialog, height-2, 1);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ' ');
-
- if (title != NULL) {
- wattrset(dialog, title_attr);
- wmove(dialog, 0, (width - strlen(title))/2 - 1);
- waddch(dialog, ' ');
- waddstr(dialog, title);
- waddch(dialog, ' ');
- }
- wattrset(dialog, dialog_attr);
- wmove(dialog, 1, 2);
- print_autowrap(dialog, prompt, height - 1, width - 2, width, 1, 2, TRUE, FALSE);
-
- list_width = width - 6;
- getyx(dialog, cur_y, cur_x);
- box_y = cur_y + 1;
- box_x = (width - list_width) / 2 - 1;
-
- /* create new window for the list */
- list = subwin(dialog, list_height, list_width, y + box_y + 1, x + box_x + 1);
- if (list == NULL) {
- delwin(dialog);
- endwin();
- fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", list_height, list_width,
- y + box_y + 1, x + box_x + 1);
- return -1;
- }
- keypad(list, TRUE);
-
- /* draw a box around the list items */
- draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, menubox_border_attr, menubox_attr);
-
- check_x = (list_width - check_x) / 2;
- item_x = check_x + item_x + 6;
-
- /* Print the list */
- for (i = 0; i < max_choice; i++)
- print_item(list, items[i * 3], items[i * 3 + 1], status[i], i, i == choice, DREF(ditems, i), list_width, item_x, check_x);
- wnoutrefresh(list);
- print_arrows(dialog, scroll, list_height, item_no, box_x, box_y, check_x + 4, cur_x, cur_y);
-
- display_helpline(dialog, height - 1, width);
-
- x = width / 2 - 11;
- y = height - 2;
- /* Is this a fancy new style argument string where we get to override
- * the buttons, or an old style one where they're fixed?
- */
- if (ditems && result) {
- cancelButton = toupper(ditems[CANCEL_BUTTON].prompt[0]);
- print_button(dialog, ditems[CANCEL_BUTTON].prompt, y, x + strlen(ditems[OK_BUTTON].prompt) + 5,
- ditems[CANCEL_BUTTON].checked ? ditems[CANCEL_BUTTON].checked(&ditems[CANCEL_BUTTON]) : FALSE);
- okButton = toupper(ditems[OK_BUTTON].prompt[0]);
- print_button(dialog, ditems[OK_BUTTON].prompt, y, x,
- ditems[OK_BUTTON].checked ? ditems[OK_BUTTON].checked(&ditems[OK_BUTTON]) : TRUE);
- }
- else {
- cancelButton = 'C';
- print_button(dialog, "Cancel", y, x + 14, FALSE);
- okButton = 'O';
- print_button(dialog, " OK ", y, x, TRUE);
- }
- wrefresh(dialog);
-
- while (key != ESC) {
- key = wgetch(dialog);
-
- /* Shortcut to OK? */
- if (toupper(key) == okButton) {
- if (ditems) {
- if (result && ditems[OK_BUTTON].fire) {
- int st;
- WINDOW *save;
-
- save = dupwin(newscr);
- st = ditems[OK_BUTTON].fire(&ditems[OK_BUTTON]);
- if (st & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- }
- delwin(save);
- }
- }
- else if (result) {
- *result = '\0';
- for (i = 0; i < item_no; i++) {
- if (status[i]) {
- strcat(result, items[i*3]);
- strcat(result, "\n");
- }
- }
- }
- rval = 0;
- key = ESC; /* Lemme out! */
- break;
- }
-
- /* Shortcut to cancel? */
- if (toupper(key) == cancelButton) {
- if (ditems && result && ditems[CANCEL_BUTTON].fire) {
- int st;
- WINDOW *save;
-
- save = dupwin(newscr);
- st = ditems[CANCEL_BUTTON].fire(&ditems[CANCEL_BUTTON]);
- if (st & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- wmove(dialog, cur_y, cur_x);
- }
- delwin(save);
- }
- rval = 1;
- key = ESC; /* I gotta go! */
- break;
- }
-
- /* Check if key pressed matches first character of any item tag in list */
- for (i = 0; i < max_choice; i++)
- if (key < 0x100 && toupper(key) == toupper(items[(scroll+i)*3][0]))
- break;
-
- if (i < max_choice || (key >= '1' && key <= MIN('9', '0'+max_choice)) ||
- KEY_IS_UP(key) || KEY_IS_DOWN(key) || key == ' ') {
-
- if (key >= '1' && key <= MIN('9', '0'+max_choice))
- i = key - '1';
-
- else if (KEY_IS_UP(key)) {
- if (!choice) {
- if (scroll) {
- /* Scroll list down */
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- if (list_height > 1) {
- /* De-highlight current first item before scrolling down */
- print_item(list, items[scroll * 3], items[scroll * 3 + 1], status[scroll], 0,
- FALSE, DREF(ditems, scroll), list_width, item_x, check_x);
- scrollok(list, TRUE);
- wscrl(list, -1);
- scrollok(list, FALSE);
- }
- scroll--;
- print_item(list, items[scroll*3], items[scroll*3 + 1], status[scroll], 0,
- TRUE, DREF(ditems, scroll), list_width, item_x, check_x);
- wnoutrefresh(list);
- print_arrows(dialog, scroll, list_height, item_no, box_x, box_y, check_x + 4, cur_x, cur_y);
- wrefresh(dialog);
- }
- continue; /* wait for another key press */
- }
- else
- i = choice - 1;
- }
- else if (KEY_IS_DOWN(key)) {
- if (choice == max_choice - 1) {
- if (scroll + choice < item_no - 1) {
- /* Scroll list up */
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- if (list_height > 1) {
- /* De-highlight current last item before scrolling up */
- print_item(list, items[(scroll + max_choice - 1) * 3],
- items[(scroll + max_choice - 1) * 3 + 1],
- status[scroll + max_choice - 1], max_choice - 1,
- FALSE, DREF(ditems, scroll + max_choice - 1), list_width, item_x, check_x);
- scrollok(list, TRUE);
- scroll(list);
- scrollok(list, FALSE);
- }
- scroll++;
- print_item(list, items[(scroll + max_choice - 1) * 3],
- items[(scroll + max_choice - 1) * 3 + 1],
- status[scroll + max_choice - 1], max_choice - 1, TRUE,
- DREF(ditems, scroll + max_choice - 1), list_width, item_x, check_x);
- wnoutrefresh(list);
- print_arrows(dialog, scroll, list_height, item_no, box_x, box_y, check_x + 4, cur_x, cur_y);
- wrefresh(dialog);
- }
- continue; /* wait for another key press */
- }
- else
- i = choice + 1;
- }
- else if (key == ' ') { /* Toggle item status */
- char lbra = 0, rbra = 0, mark = 0;
-
- if (ditems) {
- if (ditems[scroll + choice].fire) {
- int st;
- WINDOW *save;
-
- save = dupwin(newscr);
- st = ditems[scroll + choice].fire(&ditems[scroll + choice]); /* Call "fire" action */
- if (st & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- }
- delwin(save);
- if (st & DITEM_REDRAW) {
- wclear(list);
- for (i = 0; i < item_no; i++)
- status[i] = ditems[i].checked ? ditems[i].checked(&ditems[i]) : FALSE;
- for (i = 0; i < max_choice; i++) {
- print_item(list, items[(scroll + i) * 3], items[(scroll + i) * 3 + 1],
- status[scroll + i], i, i == choice, DREF(ditems, scroll + i), list_width, item_x, check_x);
- }
- wnoutrefresh(list);
- print_arrows(dialog, scroll, list_height, item_no, box_x, box_y, check_x + 4,
- cur_x, cur_y);
- wrefresh(dialog);
- }
- if (st & DITEM_LEAVE_MENU) {
- /* Allow a fire action to take us out of the menu */
- key = ESC;
- rval = 0;
- break;
- }
- else if (st & DITEM_RECREATE) {
- delwin(list);
- delwin(dialog);
- dialog_clear();
- goto draw;
- }
- }
- status[scroll + choice] = ditems[scroll + choice].checked ?
- ditems[scroll + choice].checked(&ditems[scroll + choice]) : FALSE;
- lbra = ditems[scroll + choice].lbra;
- rbra = ditems[scroll + choice].rbra;
- mark = ditems[scroll + choice].mark;
- }
- else
- status[scroll + choice] = !status[scroll + choice];
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- wmove(list, choice, check_x);
- wattrset(list, check_selected_attr);
- if (!lbra)
- lbra = '[';
- if (!rbra)
- rbra = ']';
- if (!mark)
- mark = 'X';
- wprintw(list, "%c%c%c", lbra, status[scroll + choice] ? mark : ' ', rbra);
- wnoutrefresh(list);
- wmove(dialog, cur_y, cur_x); /* Restore cursor to previous position */
- wrefresh(dialog);
- continue; /* wait for another key press */
- }
-
- if (i != choice) {
- /* De-highlight current item */
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- print_item(list, items[(scroll + choice) * 3], items[(scroll + choice) * 3 + 1],
- status[scroll + choice], choice, FALSE, DREF(ditems, scroll + choice), list_width, item_x, check_x);
-
- /* Highlight new item */
- choice = i;
- print_item(list, items[(scroll + choice) * 3], items[(scroll + choice) * 3 + 1], status[scroll + choice], choice, TRUE, DREF(ditems, scroll + choice), list_width, item_x, check_x);
- wnoutrefresh(list);
- wmove(dialog, cur_y, cur_x); /* Restore cursor to previous position */
- wrefresh(dialog);
- }
- continue; /* wait for another key press */
- }
-
- switch (key) {
- case KEY_PPAGE: /* can we go up? */
- if (scroll > height - 4)
- scroll -= (height-4);
- else
- scroll = 0;
- redraw_menu = TRUE;
- break;
-
- case KEY_NPAGE: /* can we go down a full page? */
- if (scroll + list_height >= item_no-1 - list_height) {
- scroll = item_no - list_height;
- if (scroll < 0)
- scroll = 0;
- }
- else
- scroll += list_height;
- redraw_menu = TRUE;
- break;
-
- case KEY_HOME: /* go to the top */
- scroll = 0;
- choice = 0;
- redraw_menu = TRUE;
- break;
-
- case KEY_END: /* Go to the bottom */
- scroll = item_no - list_height;
- if (scroll < 0)
- scroll = 0;
- choice = max_choice - 1;
- redraw_menu = TRUE;
- break;
-
- /* swap the selection of OK/Cancel buttons */
- case TAB:
- case KEY_BTAB:
- case KEY_LEFT:
- case KEY_RIGHT:
- button = !button;
- if (ditems && result) {
- print_button(dialog, ditems[CANCEL_BUTTON].prompt, y, x + strlen(ditems[OK_BUTTON].prompt) + 5,
- ditems[CANCEL_BUTTON].checked ? ditems[CANCEL_BUTTON].checked(&ditems[CANCEL_BUTTON]) : button);
- print_button(dialog, ditems[OK_BUTTON].prompt, y, x,
- ditems[OK_BUTTON].checked ? ditems[OK_BUTTON].checked(&ditems[OK_BUTTON]) : !button);
- }
- else {
- print_button(dialog, "Cancel", y, x + 14, button);
- print_button(dialog, " OK ", y, x, !button);
- }
- wrefresh(dialog);
- break;
-
- /* Select either the OK or Cancel button */
- case '\n':
- case '\r':
- if (ditems) {
- if (result && ditems[button ? CANCEL_BUTTON : OK_BUTTON].fire) {
- int st;
- WINDOW *save = dupwin(newscr);
-
- st = ditems[button ? CANCEL_BUTTON : OK_BUTTON].fire(&ditems[button ? CANCEL_BUTTON : OK_BUTTON]);
- if (st & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- }
- delwin(save);
- if (st == DITEM_FAILURE)
- continue;
- }
- }
- else if (result) {
- *result = '\0';
- for (i = 0; i < item_no; i++) {
- if (status[i]) {
- strcat(result, items[i*3]);
- strcat(result, "\n");
- }
- }
- }
- rval = button;
- key = ESC; /* Bail out! */
- break;
-
- /* Let me outta here! */
- case ESC:
- rval = -1;
- break;
-
- /* Help! */
- case KEY_F(1):
- case '?':
- display_helpfile();
- break;
- }
-
- if (redraw_menu) {
- wclear(list);
- for (i = 0; i < max_choice; i++)
- print_item(list, items[(scroll + i) * 3], items[(scroll + i) * 3 + 1], status[scroll + i],
- i, i == choice, DREF(ditems, scroll + i), list_width, item_x, check_x);
- wnoutrefresh(list);
- print_arrows(dialog, scroll, list_height, item_no, box_x, box_y, check_x + 4, cur_x, cur_y);
- wrefresh(dialog);
- redraw_menu = FALSE;
- }
- }
- delwin(list);
- delwin(dialog);
- return rval;
-}
-
-
-/*
- * Print list item
- */
-static void
-print_item(WINDOW *win, unsigned char *tag, unsigned char *item, int status, int choice, int selected, dialogMenuItem *me, int list_width, int item_x, int check_x)
-{
- int i;
-
- /* Clear 'residue' of last item */
- wattrset(win, menubox_attr);
- wmove(win, choice, 0);
- for (i = 0; i < list_width; i++)
- waddch(win, ' ');
- wmove(win, choice, check_x);
- wattrset(win, selected ? check_selected_attr : check_attr);
- wprintw(win, "%c%c%c", me && me->lbra ? me->lbra : '[',
- status ? me && me->mark ? me->mark : 'X' : ' ',
- me && me->rbra ? me->rbra : ']');
- wattrset(win, menubox_attr);
- waddch(win, ' ');
- wattrset(win, selected ? tag_key_selected_attr : tag_key_attr);
- waddch(win, tag[0]);
- wattrset(win, selected ? tag_selected_attr : tag_attr);
- waddstr(win, tag + 1);
- wmove(win, choice, item_x);
- wattrset(win, selected ? item_selected_attr : item_attr);
- waddstr(win, item);
- /* If have a selection handler for this, call it */
- if (me && me->selected) {
- wrefresh(win);
- me->selected(me, selected);
- }
-}
-/* End of print_item() */
diff --git a/gnu/lib/libdialog/colors.h b/gnu/lib/libdialog/colors.h
deleted file mode 100644
index 7cea0a0..0000000
--- a/gnu/lib/libdialog/colors.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * colors.h -- color attribute definitions
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- */
-
-
-/*
- * Default color definitions
- *
- * *_FG = foreground
- * *_BG = background
- * *_HL = highlight?
- */
-#define SCREEN_FG COLOR_CYAN
-#define SCREEN_BG COLOR_BLUE
-#define SCREEN_HL TRUE
-
-#define SHADOW_FG COLOR_BLACK
-#define SHADOW_BG COLOR_BLACK
-#define SHADOW_HL TRUE
-
-#define DIALOG_FG COLOR_BLACK
-#define DIALOG_BG COLOR_WHITE
-#define DIALOG_HL FALSE
-
-#define TITLE_FG COLOR_YELLOW
-#define TITLE_BG COLOR_WHITE
-#define TITLE_HL TRUE
-
-#define BORDER_FG COLOR_WHITE
-#define BORDER_BG COLOR_WHITE
-#define BORDER_HL TRUE
-
-#define BUTTON_ACTIVE_FG COLOR_WHITE
-#define BUTTON_ACTIVE_BG COLOR_BLUE
-#define BUTTON_ACTIVE_HL TRUE
-
-#define BUTTON_INACTIVE_FG COLOR_BLACK
-#define BUTTON_INACTIVE_BG COLOR_WHITE
-#define BUTTON_INACTIVE_HL FALSE
-
-#define BUTTON_KEY_ACTIVE_FG COLOR_WHITE
-#define BUTTON_KEY_ACTIVE_BG COLOR_BLUE
-#define BUTTON_KEY_ACTIVE_HL TRUE
-
-#define BUTTON_KEY_INACTIVE_FG COLOR_RED
-#define BUTTON_KEY_INACTIVE_BG COLOR_WHITE
-#define BUTTON_KEY_INACTIVE_HL FALSE
-
-#define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW
-#define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE
-#define BUTTON_LABEL_ACTIVE_HL TRUE
-
-#define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK
-#define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE
-#define BUTTON_LABEL_INACTIVE_HL TRUE
-
-#define INPUTBOX_FG COLOR_BLACK
-#define INPUTBOX_BG COLOR_WHITE
-#define INPUTBOX_HL FALSE
-
-#define INPUTBOX_BORDER_FG COLOR_BLACK
-#define INPUTBOX_BORDER_BG COLOR_WHITE
-#define INPUTBOX_BORDER_HL FALSE
-
-#define SEARCHBOX_FG COLOR_BLACK
-#define SEARCHBOX_BG COLOR_WHITE
-#define SEARCHBOX_HL FALSE
-
-#define SEARCHBOX_TITLE_FG COLOR_YELLOW
-#define SEARCHBOX_TITLE_BG COLOR_WHITE
-#define SEARCHBOX_TITLE_HL TRUE
-
-#define SEARCHBOX_BORDER_FG COLOR_WHITE
-#define SEARCHBOX_BORDER_BG COLOR_WHITE
-#define SEARCHBOX_BORDER_HL TRUE
-
-#define POSITION_INDICATOR_FG COLOR_YELLOW
-#define POSITION_INDICATOR_BG COLOR_WHITE
-#define POSITION_INDICATOR_HL TRUE
-
-#define MENUBOX_FG COLOR_BLACK
-#define MENUBOX_BG COLOR_WHITE
-#define MENUBOX_HL FALSE
-
-#define MENUBOX_BORDER_FG COLOR_WHITE
-#define MENUBOX_BORDER_BG COLOR_WHITE
-#define MENUBOX_BORDER_HL TRUE
-
-#define ITEM_FG COLOR_BLACK
-#define ITEM_BG COLOR_WHITE
-#define ITEM_HL FALSE
-
-#define ITEM_SELECTED_FG COLOR_WHITE
-#define ITEM_SELECTED_BG COLOR_BLUE
-#define ITEM_SELECTED_HL TRUE
-
-#define TAG_FG COLOR_YELLOW
-#define TAG_BG COLOR_WHITE
-#define TAG_HL TRUE
-
-#define TAG_SELECTED_FG COLOR_YELLOW
-#define TAG_SELECTED_BG COLOR_BLUE
-#define TAG_SELECTED_HL TRUE
-
-#define TAG_KEY_FG COLOR_RED
-#define TAG_KEY_BG COLOR_WHITE
-#define TAG_KEY_HL TRUE
-
-#define TAG_KEY_SELECTED_FG COLOR_RED
-#define TAG_KEY_SELECTED_BG COLOR_BLUE
-#define TAG_KEY_SELECTED_HL TRUE
-
-#define CHECK_FG COLOR_BLACK
-#define CHECK_BG COLOR_WHITE
-#define CHECK_HL FALSE
-
-#define CHECK_SELECTED_FG COLOR_WHITE
-#define CHECK_SELECTED_BG COLOR_BLUE
-#define CHECK_SELECTED_HL TRUE
-
-#define UARROW_FG COLOR_GREEN
-#define UARROW_BG COLOR_WHITE
-#define UARROW_HL TRUE
-
-#define DARROW_FG COLOR_GREEN
-#define DARROW_BG COLOR_WHITE
-#define DARROW_HL TRUE
-
-/* End of default color definitions */
-
-#define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y)))
-#define COLOR_NAME_LEN 10
-#define COLOR_COUNT 8
-
-
-/*
- * Global variables
- */
-
-typedef struct {
- unsigned char name[COLOR_NAME_LEN];
- int value;
-} color_names_st;
-
-
-#ifdef __DIALOG_MAIN__
-
-/*
- * For matching color names with color values
- */
-color_names_st color_names[] = {
- {"BLACK", COLOR_BLACK},
- {"RED", COLOR_RED},
- {"GREEN", COLOR_GREEN},
- {"YELLOW", COLOR_YELLOW},
- {"BLUE", COLOR_BLUE},
- {"MAGENTA", COLOR_MAGENTA},
- {"CYAN", COLOR_CYAN},
- {"WHITE", COLOR_WHITE},
-}; /* color names */
-
-
-/*
- * Table of color values
- */
-int color_table[][3] = {
- {SCREEN_FG, SCREEN_BG, SCREEN_HL },
- {SHADOW_FG, SHADOW_BG, SHADOW_HL },
- {DIALOG_FG, DIALOG_BG, DIALOG_HL },
- {TITLE_FG, TITLE_BG, TITLE_HL },
- {BORDER_FG, BORDER_BG, BORDER_HL },
- {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL },
- {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL },
- {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL },
- {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL },
- {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL },
- {BUTTON_LABEL_INACTIVE_FG,BUTTON_LABEL_INACTIVE_BG,BUTTON_LABEL_INACTIVE_HL},
- {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL },
- {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL },
- {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL },
- {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL },
- {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL },
- {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL },
- {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL },
- {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL },
- {ITEM_FG, ITEM_BG, ITEM_HL },
- {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL },
- {TAG_FG, TAG_BG, TAG_HL },
- {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL },
- {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL },
- {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL },
- {CHECK_FG, CHECK_BG, CHECK_HL },
- {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL },
- {UARROW_FG, UARROW_BG, UARROW_HL },
- {DARROW_FG, DARROW_BG, DARROW_HL },
-}; /* color_table */
-
-#else
-
-extern color_names_st color_names[];
-extern int color_table[][3];
-
-#endif /* __DIALOG_MAIN__ */
diff --git a/gnu/lib/libdialog/dialog.3 b/gnu/lib/libdialog/dialog.3
deleted file mode 100644
index 994fc06..0000000
--- a/gnu/lib/libdialog/dialog.3
+++ /dev/null
@@ -1,401 +0,0 @@
-.\"
-.\" Copyright (c) 1995, Jordan Hubbard
-.\"
-.\" All rights reserved.
-.\"
-.\" This manual page may be used, modified, copied, distributed, and
-.\" sold, in both source and binary form provided that the above
-.\" copyright and these terms are retained, verbatim, as the first
-.\" lines of this file. Under no circumstances is the author
-.\" responsible for the proper functioning of the software described herein
-.\" nor does the author assume any responsibility for damages incurred with
-.\" its use.
-.\"
-.\" $Id: dialog.3,v 1.5 1997/02/22 15:42:35 peter Exp $
-.\"
-.Dd December 18, 1995
-.Dt dialog 3
-.Os FreeBSD 2
-.Sh NAME
-.Nm draw_shadow ,
-.Nm draw_box ,
-.Nm line_edit ,
-.Nm strheight ,
-.Nm strwidth ,
-.Nm dialog_create_rc,
-.Nm dialog_yesno ,
-.Nm dialog_prgbox ,
-.Nm dialog_msgbox ,
-.Nm dialog_textbox ,
-.Nm dialog_menu ,
-.Nm dialog_checklist ,
-.Nm dialog_radiolist ,
-.Nm dialog_inputbox ,
-.Nm dialog_clear_norefresh ,
-.Nm dialog_clear ,
-.Nm dialog_update ,
-.Nm dialog_fselect ,
-.Nm dialog_notify ,
-.Nm dialog_mesgbox ,
-.Nm dialog_gauge ,
-.Nm init_dialog ,
-.Nm end_dialog ,
-.Nm use_helpfile ,
-.Nm use_helpline ,
-.Nm get_helpline ,
-.Nm restore_helpline
-.Nd Provide a simple ncurses-based "GUI" interface.
-.Sh DESCRIPTION
-The dialog library attempts to provide a fairly simplistic set of
-fixed-presentation menus, input boxes, gauges, file requestors and
-other general purpose "GUI" (a bit of a stretch, since it uses
-ncurses) objects. Since the library also had its roots in a
-shell-script writer's utility (see the \fBdialog(1)\fR command), the
-early API was somewhat primitively based on strings being passed in or
-out and parsed. This API was later extended to take either the
-original arguments or arrays of \fBdialogMenuItem\fR structures,
-giving the user much more control over the internal behavior of each
-control. The \fBdialogMenuItem\fR structure internals are public:
-
-.nf
-typedef struct _dmenu_item {
- char *\fBprompt\fR;
- char *\fBtitle\fR;
- int (*\fBchecked\fR)(struct _dmenu_item *self);
- int (*\fBfire\fR)(struct _dmenu_item *self);
- int (*\fBselected\fR)(struct _dmenu_item *self, int is_selected);
- void *\fBdata\fR;
- char \fBlbra\fR, \fBmark\fR, \fBrbra\fR;
-} \fBdialogMenuItem\fR;
-.fi
-
-The \fBprompt\fR and \fBtitle\fR strings are pretty much self-explanatory,
-and the \fBchecked\fR and \fBfire\fR function pointers provide optional
-display and action hooks (the \fBdata\fR variable being available for
-the convenience of those hooks) when more tightly coupled feedback between
-a menu object and user code is required. The \fBselected\fR hook also
-allows you to verify whether or not a given item is selected (the cursor is
-over it) for implementing pretty much any possible context-sensitive
-behavior. A number of clever tricks for simulating various kinds of item
-types can also be done by adjusting the values of \fBlbra\fR
-(default: '['), \fB\mark\fR (default: '*' for radio menus, 'X' for check menus)
-and \fBrbra\fR (default: ']') and declaring a reasonable \fBchecked\fR hook,
-which should return TRUE for the `marked' state and FALSE for `unmarked.'
-If an item has a \fBfire\fR hook associated with it, it will also be called
-whenever the item is "toggled" in some way and should return one of the
-following codes:
-.nf
-
-#define DITEM_SUCCESS 0 /* Successful completion */
-#define DITEM_FAILURE -1 /* Failed to "fire" */
-#define DITEM_LEAVE_MENU -2 /* Treat selection as "Ok" */
-#define DITEM_REDRAW -3 /* Menu has changed, redraw it */
-
-Two special globals also exist for putting a dialog at any arbitrary
-X,Y location (the early designers rather short-sightedly made no provisions
-for this). If set to zero, the default centering behavior will be in
-effect.
-
-.fi
-
-.Sh SYNOPSIS
-.Fd #include <dialog.h>
-.Ft "void"
-.Fn draw_shadow "WINDOW *win" "int y" "int x" "int height" "int width"
-
-Draws a shadow in curses window \fBwin\fR using the dimensions
-of \fBx, y, width\fR and \fBheight\fR. Returns 0 on success, -1 on failure.
-
-.Ft "void"
-.Fn draw_box "WINDOW *win" "int y" "int x" "int height" "int width" "chtype box" "chtype border"
-
-Draws a bordered box using the dimensions of \fBx, y, width\fR and
-\fBheight\fR. The attributes from \fBbox\fR and \fBborder\fR are
-used, if specified, while painting the box and border regions of the
-object.
-
-.Ft "int"
-.Fo line_edit
-.Fa "WINDOW *dialog"
-.Fa "int box_y"
-.Fa "int box_x"
-.Fa "int flen"
-.Fa "int box_width"
-.Fa "chtype attrs"
-.Fa "int first"
-.Fa "unsigned char *result"
-.Fa "int attr_mask"
-.Fc
-
-Invoke a simple line editor with an edit box of dimensions \fBbox_x,
-box_y\fR and \fBbox_width\fR. The field length is constrained by
-\fBflen\fR, starting at the \fBfirst\fR character specified and
-optionally displayed with character attributes \fBattrs\fR. The
-string being edited is stored in \fBresult\fR.
-
-Returns 0 on success, -1 on failure.
-
-.Ft "int"
-.Fn strheight "const char *p"
-
-Returns the height of string in \fBp\fR, counting newlines.
-
-.Ft "int"
-.Fn strwidth "const char *p"
-
-Returns the width of string in \fBp\fR, counting newlines.
-
-.Ft "void"
-.Fn dialog_create_rc "unsigned char *filename"
-
-Dump dialog library settings into \fBfilename\fR for later retreival
-as defaults. Returns 0 on success, -1 on failure.
-
-.Ft "int"
-.Fn dialog_yesno "unsigned char *title" "unsigned char *prompt" "int height" "int width"
-
-Display a text box using \fBtitle\fR and \fBprompt\fR strings of dimensions
-\fBheight\fR and \fBwidth\fR. Also paint a pair of \fBYes\fR and \fBNo\fR
-buttons at the bottom. If the \fBYes\fR button is chosen, return FALSE.
-If \fBNo\fR, return TRUE.
-
-.Ft "int"
-.Fn dialog_prgbox "unsigned char *title" "const unsigned char *line" "int height" "int width" "int pause" "int use_shell"
-
-Display a text box of dimensions \fBheight\fR and \fBwidth\fR
-containing the output of command \fBline\fR. If \fBuse_shell\fR is
-TRUE, \fBline\fR is passed as an argument to \fBsh(1)\fR, otherwise it
-is simply passed to \fBexec(3)\fR. If \fBpause\fR is TRUE, a final
-confirmation requestor will be put up when execution terminates.
-
-Returns 0 on success, -1 on failure.
-
-.Ft "int"
-.Fn dialog_textbox "unsigned char *title" "unsigned char *prompt" "int height" "int width"
-
-Display a text box containing the contents of string \fBprompt\fR of dimensions
-\fBheight\fR and \fBwidth\fR.
-
-Returns 0 on success, -1 on failure.
-
-.Ft "int"
-.Fn dialog_menu "unsigned char *title" "unsigned char *prompt" "int height" "int width" "int menu_height" "int item_no" "void *itptr" "unsigned char *result, int *ch, int *sc"
-
-Display a menu of dimensions \fBheight\fR and \fBwidth\fR with an
-optional internal menu height of \fBmenu_height\fR. The \fBitem_no\fR
-and \fBitptr\fR arguments are of particular importance since they,
-together, determine which of the 2 available APIs to use. To use the
-older and traditional interface, \fBitem_no\fR should be a positive
-integer representing the number of string pointer pairs to find in
-\fBitptr\fR (which should be of type \fBchar **\fR), the strings are
-expected to be in prompt and title order for each item and the
-\fBresult\fR parameter is expected to point to an array where the
-prompt string of the item selected will be copied. To use the newer
-interface, \fBitem_no\fR should be a \fInegative\fR integer
-representing the number of \fBdialogMenuItem\fR structures pointed to
-by \fBitptr\fR (which should be of type \fBdialogMenuItem *\fR), one
-structure per item. In the new interface, the \fBresult\fR variable
-is used as a simple boolean (not a pointer) and should be NULL if
-\fBitptr\fR only points to menu items and the default \fBOK\fR and
-\fBCancel\fR buttons are desired. If \fBresult\fR is non-NULL, then
-\fBitptr\fR is actually expected to point 2 locations \fBpast\fR the
-start of the menu item list. \fBitptr\fR[-1] is then expected to
-point to an item representing the \fBCancel\fR button, from which the
-\fBprompt\fR and \fBfire\fR actions are used to override the default
-behavior, and \fBitptr\fR[-2] to the same for the \fBOK\fR button.
-
-Using either API behavior, the \fBch\fR and \fBsc\fR values may be passed in to preserve current
-item selection and scroll position values across calls.
-
-Returns 0 on success, 1 on Cancel and -1 on failure or ESC.
-
-.Ft "int"
-.Fn dialog_checklist "unsigned char *title" "unsigned char *prompt" "int height" "int width" "int m_height" "int item_no" "void *itptr" "unsigned char *result"
-
-Display a menu of dimensions \fBheight\fR and \fBwidth\fR with an
-optional internal menu height of \fBmenu_height\fR. The \fBitem_no\fR
-and \fBitptr\fR arguments are of particular importance since they,
-together, determine which of the 2 available APIs to use. To use the
-older and traditional interface, \fBitem_no\fR should be a positive
-integer representing the number of string pointer tuples to find in
-\fBitptr\fR (which should be of type \fBchar **\fR), the strings are
-expected to be in prompt, title and state ("on" or "off") order for
-each item and the \fBresult\fR parameter is expected to point to an
-array where the prompt string of the item(s) selected will be
-copied. To use the newer interface, \fBitem_no\fR should be a
-\fInegative\fR integer representing the number of \fBdialogMenuItem\fR
-structures pointed to by \fBitptr\fR (which should be of type
-\fBdialogMenuItem *\fR), one structure per item. In the new interface,
-the \fBresult\fR variable is used as a simple boolean (not a pointer)
-and should be NULL if \fBitptr\fR only points to menu items and the
-default \fBOK\fR and \fBCancel\fR buttons are desired. If
-\fBresult\fR is non-NULL, then \fBitptr\fR is actually expected to
-point 2 locations \fBpast\fR the start of the menu item list.
-\fBitptr\fR[-1] is then expected to point to an item representing the
-\fBCancel\fR button, from which the \fBprompt\fR and \fBfire\fR
-actions are used to override the default behavior, and \fBitptr\fR[-2]
-to the same for the \fBOK\fR button.
-
-In the standard API model, the menu supports the selection of multiple items,
-each of which is marked with an `X' character to denote selection. When
-the OK button is selected, the prompt values for all items selected are
-concatenated into the \fBresult\fR string.
-
-In the new API model, it is not actually necessary to preserve
-"checklist" semantics at all since practically everything about how
-each item is displayed or marked as "selected" is fully configurable.
-You could have a single checklist menu that actually contained a group
-of items with "radio" behavior, "checklist" behavior and standard menu
-item behavior. The only reason to call \fBdialog_checklist\fR over
-\fBdialog_radiolist\fR in the new API model is to inherit the base
-behavior, you're no longer constrained by it.
-
-Returns 0 on success, 1 on Cancel and -1 on failure or ESC.
-
-.Ft "int"
-.Fn dialog_radiolist "unsigned char *title" "unsigned char *prompt" "int height" "int width" "int m_height" "int item_no" "void *it" "unsigned char *result"
-
-Display a menu of dimensions \fBheight\fR and \fBwidth\fR with an
-optional internal menu height of \fBmenu_height\fR. The \fBitem_no\fR
-and \fBitptr\fR arguments are of particular importance since they,
-together, determine which of the 2 available APIs to use. To use the
-older and traditional interface, \fBitem_no\fR should be a positive
-integer representing the number of string pointer tuples to find in
-\fBitptr\fR (which should be of type \fBchar **\fR), the strings are
-expected to be in prompt, title and state ("on" or "off") order for
-each item and the \fBresult\fR parameter is expected to point to an
-array where the prompt string of the item(s) selected will be
-copied. To use the newer interface, \fBitem_no\fR should be a
-\fInegative\fR integer representing the number of \fBdialogMenuItem\fR
-structures pointed to by \fBitptr\fR (which should be of type
-\fBdialogMenuItem *\fR), one structure per item. In the new interface,
-the \fBresult\fR variable is used as a simple boolean (not a pointer)
-and should be NULL if \fBitptr\fR only points to menu items and the
-default \fBOK\fR and \fBCancel\fR buttons are desired. If
-\fBresult\fR is non-NULL, then \fBitptr\fR is actually expected to
-point 2 locations \fBpast\fR the start of the menu item list.
-\fBitptr\fR[-1] is then expected to point to an item representing the
-\fBCancel\fR button, from which the \fBprompt\fR and \fBfire\fR
-actions are used to override the default behavior, and \fBitptr\fR[-2]
-does the same for the traditional \fBOK\fR button.
-
-In the standard API model, the menu supports the selection of only one
-of multiple items, the currently active item marked with an `*'
-character to denote selection. When the OK button is selected, the
-prompt value for this item is copied into the \fBresult\fR string.
-
-In the new API model, it is not actually necessary to preserve
-"radio button" semantics at all since practically everything about how
-each item is displayed or marked as "selected" is fully configurable.
-You could have a single radio menu that actually contained a group
-of items with "checklist" behavior, "radio" behavior and standard menu
-item behavior. The only reason to call \fBdialog_radiolist\fR over
-\fBdialog_checklistlist\fR in the new API model is to inherit the base
-behavior.
-
-Returns 0 on success, 1 on Cancel and -1 on failure or ESC.
-
-.Ft "int"
-.Fn dialog_inputbox "unsigned char *title" "unsigned char *prompt" "int height" "int width" "unsigned char *result"
-
-Displays a single-line text input field in a box displaying \fBtitle\fR and \fBprompt\fR
-of dimensions \fBheight\fR and \fBwidth\fR. The field entered is stored in \fBresult\fR.
-
-Returns 0 on success, -1 on failure or ESC.
-
-.Ft "char *"
-.Fn dialog_fselect "char *dir" "char *fmask"
-
-Brings up a file selector dialog starting at \fBdir\fR and showing only those file names
-matching \fBfmask\fR.
-
-Returns filename selected or NULL.
-
-.Ft "int"
-.Fn dialog_dselect "char *dir" "char *fmask"
-
-Brings up a directory selector dialog starting at \fBdir\fR and showing only those directory names
-matching \fBfmask\fR.
-
-Returns directory name selected or NULL.
-
-.Ft "void"
-.Fn dialog_notify "char *msg"
-
-Bring up a generic "hey, you!" notifier dialog containing \fBmsg\fR.
-
-.Ft "int"
-.Fn dialog_mesgbox "unsigned char *title" "unsigned char *prompt" "int height" "int width"
-
-Like a notifier dialog, but with more control over \fBtitle\fR, \fBprompt\fR, \fBwidth\fR and
-\fBheight\fR. This object will also wait for user confirmation, unlike \fBdialog_notify\fR.
-
-Returns 0 on success, -1 on failure.
-
-.Ft "void"
-.Fn dialog_gauge "char *title" "char *prompt" "int y" "int x" "int height" "int width" "int perc"
-
-Display a horizontal bar-graph style gauge. A value of \fB100\fR for \fBperc\fR constitutes
-a full gauge, a value of \fB0\fR an empty one.
-
-.Ft "void"
-.Fn use_helpfile "char *helpfile"
-
-For any menu supporting context sensitive help, invoke the text box
-object on this file whenever the \fBF1\fR key is pressed.
-
-
-.Ft "void"
-.Fn use_helpline "char *helpline"
-
-Display this line of helpful text below any menu being displayed.
-
-.Ft "char *"
-.Fn get_helpline "void"
-
-Get the current value of the helpful text line.
-
-.Ft "void"
-.Fn dialog_clear_norefresh "void"
-
-Clear the screen back to the dialog background color, but don't refresh the contents
-just yet.
-
-.Ft "void"
-.Fn dialog_clear "void"
-
-Clear the screen back to the dialog background color immediately.
-
-.Ft "void"
-.Fn dialog_update "void"
-
-Do any pending screen refreshes now.
-
-.Ft "void"
-.Fn init_dialog "void"
-
-Initialize the dialog library (call this routine before any other dialog API calls).
-
-.Ft "void"
-.Fn end_dialog "void"
-
-Shut down the dialog library (call this if you need to get back to sanity).
-
-.Sh SEE ALSO
-.Xr dialog 1 ,
-.Xr ncurses 3
-
-.Sh AUTHORS
-The primary author would appear to be Savio Lam <lam836@cs.cuhk.hk> with contributions over
-the years by Stuart Herbert <S.Herbert@sheffield.ac.uk>, Marc van Kempen <wmbfmk@urc.tue.nl>,
-Andrey Chernov <ache@freebsd.org> and Jordan Hubbard <jkh@freebsd.org>.
-
-.Sh HISTORY
-These functions appeared in
-.Em FreeBSD-2.0
-as the \fBdialog(1)\fR command and were soon split into library
-and command by Andrey Chernov. Marc van Kempen implemented most of the
-extra controls and objects and Jordan Hubbard added the dialogMenuItem
-renovations and this man page.
-.Sh BUGS
-Sure!
diff --git a/gnu/lib/libdialog/dialog.h b/gnu/lib/libdialog/dialog.h
deleted file mode 100644
index dace69e..0000000
--- a/gnu/lib/libdialog/dialog.h
+++ /dev/null
@@ -1,161 +0,0 @@
-#ifndef _DIALOG_H_INCLUDE
-#define _DIALOG_H_INCLUDE
-
-/*
- * dialog.h -- common declarations for all dialog modules
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * Substantial rennovation: 12/18/95, Jordan K. Hubbard
- *
- * 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
- * of the License, 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.
- */
-
-#define HAVE_NCURSES
-
-#ifdef HAVE_NCURSES
-#include <ncurses.h>
-
-#else
-
-#ifdef ultrix
-#include <cursesX.h>
-#else
-#include <curses.h>
-#endif
-
-#endif
-
-/* special return codes for `fire' actions */
-#define DITEM_STATUS(flag) ((flag) & 0x0000FFFF)
-#define DITEM_SUCCESS 0
-#define DITEM_FAILURE 1
-
-/* Flags - returned in upper 16 bits of return status */
-#define DITEM_LEAVE_MENU (1 << 16)
-#define DITEM_REDRAW (1 << 17)
-#define DITEM_RECREATE (1 << 18)
-#define DITEM_RESTORE (1 << 19)
-#define DITEM_CONTINUE (1 << 20)
-
-/* Attributes as used by entry fields right now */
-#define DITEM_NO_ECHO 0x0001
-
-
-/* negative offsets for buttons in item lists, if specified */
-#define OK_BUTTON -2
-#define CANCEL_BUTTON -1
-
-/* for use in describing more exotic behaviors */
-typedef struct _dmenu_item {
- char *prompt;
- char *title;
- int (*checked)(struct _dmenu_item *self);
- int (*fire)(struct _dmenu_item *self);
- void (*selected)(struct _dmenu_item *self, int is_selected);
- void *data;
- char lbra, mark, rbra;
- int aux;
-} dialogMenuItem;
-
-#define VERSION "0.4"
-#define MAX_LEN 2048
-
-#ifndef TRUE
-#define TRUE (1)
-#endif
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-extern int DialogX, DialogY, DialogInputAttrs;
-
-/*
- * Attribute names
- */
-#define screen_attr attributes[0]
-#define shadow_attr attributes[1]
-#define dialog_attr attributes[2]
-#define title_attr attributes[3]
-#define border_attr attributes[4]
-#define button_active_attr attributes[5]
-#define button_inactive_attr attributes[6]
-#define button_key_active_attr attributes[7]
-#define button_key_inactive_attr attributes[8]
-#define button_label_active_attr attributes[9]
-#define button_label_inactive_attr attributes[10]
-#define inputbox_attr attributes[11]
-#define inputbox_border_attr attributes[12]
-#define searchbox_attr attributes[13]
-#define searchbox_title_attr attributes[14]
-#define searchbox_border_attr attributes[15]
-#define position_indicator_attr attributes[16]
-#define menubox_attr attributes[17]
-#define menubox_border_attr attributes[18]
-#define item_attr attributes[19]
-#define item_selected_attr attributes[20]
-#define tag_attr attributes[21]
-#define tag_selected_attr attributes[22]
-#define tag_key_attr attributes[23]
-#define tag_key_selected_attr attributes[24]
-#define check_attr attributes[25]
-#define check_selected_attr attributes[26]
-#define uarrow_attr attributes[27]
-#define darrow_attr attributes[28]
-
-/* number of attributes */
-#define ATTRIBUTE_COUNT 29
-
-extern chtype attributes[];
-
-#ifdef HAVE_NCURSES
-extern bool use_shadow;
-void draw_shadow(WINDOW *win, int y, int x, int height, int width);
-#endif
-void draw_box(WINDOW *win, int y, int x, int height, int width, chtype box, chtype border);
-int line_edit(WINDOW *dialog, int box_y, int box_x, int flen, int box_width, chtype attrs, int first, unsigned char *result, int attr_mask);
-int strheight(const char *p);
-int strwidth(const char *p);
-
-void dialog_create_rc(unsigned char *filename);
-int dialog_yesno(unsigned char *title, unsigned char *prompt, int height, int width);
-int dialog_prgbox(unsigned char *title, const unsigned char *line, int height, int width, int pause, int use_shell);
-int dialog_msgbox(unsigned char *title, unsigned char *prompt, int height, int width, int pause);
-int dialog_textbox(unsigned char *title, unsigned char *file, int height, int width);
-int dialog_menu(unsigned char *title, unsigned char *prompt, int height, int width, int menu_height,
- int item_no, void *itptr, unsigned char *result, int *ch, int *sc);
-int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int width, int list_height,
- int item_no, void *itptr, unsigned char *result);
-int dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int width, int list_height,
- int item_no, void *itptr, unsigned char *result);
-int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int width, unsigned char *result);
-void dialog_clear_norefresh(void);
-void dialog_clear(void);
-void dialog_update(void);
-void init_dialog(void);
-void end_dialog(void);
-
-/* Additions to libdialog */
-char *dialog_fselect(char *dir, char *fmask);
-int dialog_dselect(char *dir, char *fmask);
-void dialog_notify(char *msg);
-int dialog_mesgbox(unsigned char *title, unsigned char *prompt, int height, int width);
-void use_helpfile(char *helpfile);
-void use_helpline(char *helpline);
-char *get_helpline(void);
-void restore_helpline(char *helpline);
-void dialog_gauge(char *title, char *prompt, int y, int x, int height, int width, int perc);
-
-#endif /* _DIALOG_H_INCLUDE */
diff --git a/gnu/lib/libdialog/dialog.priv.h b/gnu/lib/libdialog/dialog.priv.h
deleted file mode 100644
index 68b136f..0000000
--- a/gnu/lib/libdialog/dialog.priv.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * dialog.h -- common declarations for all dialog modules
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- */
-
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined(LOCALE)
-#include <locale.h>
-#endif
-
-
-/*
- * Change these if you want
- */
-#define USE_SHADOW TRUE
-#define USE_COLORS TRUE
-
-#define ESC 27
-#define TAB 9
-#define BUF_SIZE (10*1024)
-
-#ifndef MIN
-#define MIN(x,y) (x < y ? x : y)
-#endif
-#ifndef MAX
-#define MAX(x,y) (x > y ? x : y)
-#endif
-
-#ifndef ctrl
-#define ctrl(a) ((a) - 'a' + 1)
-#endif
-
-#ifndef HAVE_NCURSES
-#ifndef ACS_ULCORNER
-#define ACS_ULCORNER '+'
-#endif
-#ifndef ACS_LLCORNER
-#define ACS_LLCORNER '+'
-#endif
-#ifndef ACS_URCORNER
-#define ACS_URCORNER '+'
-#endif
-#ifndef ACS_LRCORNER
-#define ACS_LRCORNER '+'
-#endif
-#ifndef ACS_HLINE
-#define ACS_HLINE '-'
-#endif
-#ifndef ACS_VLINE
-#define ACS_VLINE '|'
-#endif
-#ifndef ACS_LTEE
-#define ACS_LTEE '+'
-#endif
-#ifndef ACS_RTEE
-#define ACS_RTEE '+'
-#endif
-#ifndef ACS_UARROW
-#define ACS_UARROW '^'
-#endif
-#ifndef ACS_DARROW
-#define ACS_DARROW 'v'
-#endif
-#endif /* HAVE_NCURSES */
-
-/* Travel key conventions */
-#define KEY_IS_UP(key) ((key) == KEY_UP || (key) == '-' || key == '\020' /* ^P */)
-#define KEY_IS_DOWN(key) ((key) == KEY_DOWN || (key) == '+' || key == '\016' /* ^N */)
-
-/*
- * Global variables
- */
-#ifdef __DIALOG_MAIN__
-
-#ifdef HAVE_NCURSES
-
-/* use colors by default? */
-bool use_colors = USE_COLORS;
-
-/* shadow dialog boxes by default?
- Note that 'use_shadow' implies 'use_colors' */
-bool use_shadow = USE_SHADOW;
-
-#endif
-
-
-/*
- * Attribute values, default is for mono display
- */
-chtype attributes[] = {
- A_NORMAL, /* screen_attr */
- A_NORMAL, /* shadow_attr */
- A_REVERSE, /* dialog_attr */
- A_REVERSE, /* title_attr */
- A_REVERSE, /* border_attr */
- A_BOLD, /* button_active_attr */
- A_DIM, /* button_inactive_attr */
- A_UNDERLINE, /* button_key_active_attr */
- A_UNDERLINE, /* button_key_inactive_attr */
- A_NORMAL, /* button_label_active_attr */
- A_NORMAL, /* button_label_inactive_attr */
- A_REVERSE, /* inputbox_attr */
- A_REVERSE, /* inputbox_border_attr */
- A_REVERSE, /* searchbox_attr */
- A_REVERSE, /* searchbox_title_attr */
- A_REVERSE, /* searchbox_border_attr */
- A_REVERSE, /* position_indicator_attr */
- A_REVERSE, /* menubox_attr */
- A_REVERSE, /* menubox_border_attr */
- A_REVERSE, /* item_attr */
- A_NORMAL, /* item_selected_attr */
- A_REVERSE, /* tag_attr */
- A_REVERSE, /* tag_selected_attr */
- A_NORMAL, /* tag_key_attr */
- A_BOLD, /* tag_key_selected_attr */
- A_REVERSE, /* check_attr */
- A_REVERSE, /* check_selected_attr */
- A_REVERSE, /* uarrow_attr */
- A_REVERSE /* darrow_attr */
-};
-
-#else
-
-#ifdef HAVE_NCURSES
-extern bool use_colors;
-#endif
-
-#endif /* __DIALOG_MAIN__ */
-
-
-
-#ifdef HAVE_NCURSES
-
-/*
- * Function prototypes
- */
-#ifdef __DIALOG_MAIN__
-
-extern int parse_rc(void);
-
-#endif /* __DIALOG_MAIN__ */
-
-#endif
-
-
-#ifdef HAVE_NCURSES
-void color_setup(void);
-#endif
-
-void attr_clear(WINDOW *win, int height, int width, chtype attr);
-void print_autowrap(WINDOW *win, unsigned char *prompt, int height, int width, int maxwidth,
- int y, int x, int center, int rawmode);
-void print_button(WINDOW *win, unsigned char *label, int y, int x, int selected);
-FILE *raw_popen(const char *program, char * const *argv, const char *type);
-int raw_pclose(FILE *iop);
-void display_helpfile(void);
-void display_helpline(WINDOW *w, int y, int width);
-void print_arrows(WINDOW *dialog, int scroll, int menu_height, int item_no, int box_x,
- int box_y, int tag_x, int cur_x, int cur_y);
-
diff --git a/gnu/lib/libdialog/dir.c b/gnu/lib/libdialog/dir.c
deleted file mode 100644
index 9c2c7b5..0000000
--- a/gnu/lib/libdialog/dir.c
+++ /dev/null
@@ -1,549 +0,0 @@
-/****************************************************************************
- *
- * Program: dir.c
- * Author: Marc van Kempen
- * desc: Directory routines, sorting and reading
- *
- * Copyright (c) 1995, Marc van Kempen
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- ****************************************************************************/
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <unistd.h> /* XXX for _POSIX_VERSION ifdefs */
-
-#if !defined sgi && !defined _POSIX_VERSION
-#include <sys/dir.h>
-#endif
-#if defined __sun__
-#include <sys/dirent.h>
-#endif
-#if defined sgi || defined _POSIX_VERSION
-#include <dirent.h>
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <fnmatch.h>
-#include <sys/param.h>
-#include "dir.h"
-
-/****************************************************************************
- *
- * local prototypes
- *
- ****************************************************************************/
-
-void toggle_dotfiles(void);
-int show_dotfiles(void);
-int dir_alphasort(const void *d1, const void *d2);
-int dir_sizesort(const void *d1, const void *d2);
-int dir_datesort(const void *d1, const void *d2);
-int dir_extsort(const void *d1, const void *d2);
-
-/****************************************************************************
- *
- * global variables
- *
- ****************************************************************************/
-
-
-/* This is user-selectable, I've set them fixed for now however */
-
-void *_sort_func = dir_alphasort;
-static int _showdotfiles = TRUE;
-
-/****************************************************************************
- *
- * Functions
- *
- ****************************************************************************/
-
-int
-dir_select_nd(
-#if defined __linux__
- const struct dirent *d
-#else
- struct dirent *d
-#endif
-)
-/*
- * desc: allways include a directory entry <d>, except
- * for the current directory and other dot-files
- * keep '..' however.
- * pre: <d> points to a dirent
- * post: returns TRUE if d->d_name != "." else FALSE
- */
-{
- if (strcmp(d->d_name, ".")==0 ||
- (d->d_name[0] == '.' && strlen(d->d_name) > 1 && d->d_name[1] != '.')) {
- return(FALSE);
- } else {
- return(TRUE);
- }
-}/* dir_select_nd() */
-
-
-int
-dir_select(
-#ifdef __linux__
- const struct dirent *d
-#else
- struct dirent *d
-#endif
-)
-/*
- * desc: allways include a directory entry <d>, except
- * for the current directory
- * pre: <d> points to a dirent
- * post: returns TRUE if d->d_name != "." else FALSE
- */
-{
- if (strcmp(d->d_name, ".")==0) { /* don't include the current directory */
- return(FALSE);
- } else {
- return(TRUE);
- }
-} /* dir_select() */
-
-int
-dir_select_root_nd(
-#ifdef __linux__
- const struct dirent *d
-#else
- struct dirent *d
-#endif
-)
-/*
- * desc: allways include a directory entry <d>, except
- * for the current directory and the parent directory.
- * Also skip any other dot-files.
- * pre: <d> points to a dirent
- * post: returns TRUE if d->d_name[0] != "." else FALSE
- */
-{
- if (d->d_name[0] == '.') { /* don't include the current directory */
- return(FALSE); /* nor the parent directory */
- } else {
- return(TRUE);
- }
-} /* dir_select_root_nd() */
-
-
-int
-dir_select_root(
-#ifdef __linux__
- const struct dirent *d
-#else
- struct dirent *d
-#endif
-)
-/*
- * desc: allways include a directory entry <d>, except
- * for the current directory and the parent directory
- * pre: <d> points to a dirent
- * post: returns TRUE if d->d_name[0] != "." else FALSE
- */
-{
- if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) {
- return(FALSE);
- } else {
- return(TRUE);
- }
-}/* dir_select_root() */
-
-
-#ifdef NO_ALPHA_SORT
-int
-alphasort(const void *d1, const void *d2)
-/*
- * desc: a replacement for what should be in the library
- */
-{
- return(strcmp(((struct dirent *) d1)->d_name,
- ((struct dirent *) d2)->d_name));
-} /* alphasort() */
-#endif
-
-int
-dir_alphasort(const void *d1, const void *d2)
-/*
- * desc: compare d1 and d2, but put directories always first
- * put '..' always on top
- *
- */
-{
- DirList *f1 = ((DirList *) d1),
- *f2 = ((DirList *) d2);
- struct stat *s1 = &(f1->filestatus);
- struct stat *s2 = &(f2->filestatus);
-
- /* check for '..' */
- if (strcmp(((DirList *) d1)->filename, "..") == 0) {
- return(-1);
- }
- if (strcmp(((DirList *) d2)->filename, "..") == 0) {
- return(1);
- }
-
- /* put directories first */
- if ((s1->st_mode & S_IFDIR) && (s2->st_mode & S_IFDIR)) {
- return(strcmp(f1->filename, f2->filename));
- };
- if (s1->st_mode & S_IFDIR) {
- return(-1);
- }
- if (s2->st_mode & S_IFDIR) {
- return(1);
- }
- return(strcmp(f1->filename, f2->filename));
-
-} /* dir_alphasort() */
-
-
-int
-dir_sizesort(const void *d1, const void *d2)
-/*
- * desc: compare d1 and d2, but put directories always first
- *
- */
-{
- DirList *f1 = ((DirList *) d1),
- *f2 = ((DirList *) d2);
- struct stat *s1 = &(f1->filestatus);
- struct stat *s2 = &(f2->filestatus);
-
- /* check for '..' */
- if (strcmp(((DirList *) d1)->filename, "..") == 0) {
- return(-1);
- }
- if (strcmp(((DirList *) d2)->filename, "..") == 0) {
- return(1);
- }
-
- /* put directories first */
- if ((s1->st_mode & S_IFDIR) && (s2->st_mode & S_IFDIR)) {
- return(s1->st_size < s2->st_size ?
- -1
- :
- s1->st_size >= s2->st_size);
- };
- if (s1->st_mode & S_IFDIR) {
- return(-1);
- }
- if (s2->st_mode & S_IFDIR) {
- return(1);
- }
- return(s1->st_size < s2->st_size ?
- -1
- :
- s1->st_size >= s2->st_size);
-
-} /* dir_sizesort() */
-
-int
-dir_datesort(const void *d1, const void *d2)
-/*
- * desc: compare d1 and d2 on date, but put directories always first
- */
-{
- DirList *f1 = ((DirList *) d1),
- *f2 = ((DirList *) d2);
- struct stat *s1 = &(f1->filestatus);
- struct stat *s2 = &(f2->filestatus);
-
-
- /* check for '..' */
- if (strcmp(((DirList *) d1)->filename, "..") == 0) {
- return(-1);
- }
- if (strcmp(((DirList *) d2)->filename, "..") == 0) {
- return(1);
- }
-
- /* put directories first */
- if ((s1->st_mode & S_IFDIR) && (s2->st_mode & S_IFDIR)) {
- return(s1->st_mtime < s2->st_mtime ?
- -1
- :
- s1->st_mtime >= s2->st_mtime);
- };
- if (s1->st_mode & S_IFDIR) {
- return(-1);
- }
- if (s2->st_mode & S_IFDIR) {
- return(1);
- }
- return(s1->st_mtime < s2->st_mtime ?
- -1
- :
- s1->st_mtime >= s2->st_mtime);
-
-} /* dir_datesort() */
-
-
-int
-null_strcmp(char *s1, char *s2)
-/*
- * desc: compare strings allowing NULL pointers
- */
-{
- if ((s1 == NULL) && (s2 == NULL)) {
- return(0);
- }
- if (s1 == NULL) {
- return(-1);
- }
- if (s2 == NULL) {
- return(1);
- }
- return(strcmp(s1, s2));
-} /* null_strcmp() */
-
-
-int
-dir_extsort(const void *d1, const void *d2)
-/*
- * desc: compare d1 and d2 on extension, but put directories always first
- * extension = "the characters after the last dot in the filename"
- * pre: d1 and d2 are pointers to DirList type records
- * post: see code
- */
-{
- DirList *f1 = ((DirList *) d1),
- *f2 = ((DirList *) d2);
- struct stat *s1 = &(f1->filestatus);
- struct stat *s2 = &(f2->filestatus);
- char *ext1, *ext2;
- int extf, ret;
-
-
- /* check for '..' */
- if (strcmp(((DirList *) d1)->filename, "..") == 0) {
- return(-1);
- }
- if (strcmp(((DirList *) d2)->filename, "..") == 0) {
- return(1);
- }
-
-
- /* find the first extension */
-
- ext1 = f1->filename + strlen(f1->filename);
- extf = FALSE;
- while (!extf && (ext1 > f1->filename)) {
- extf = (*--ext1 == '.');
- }
- if (!extf) {
- ext1 = NULL;
- } else {
- ext1++;
- }
- /* ext1 == NULL if there's no "extension" else ext1 points */
- /* to the first character of the extension string */
-
- /* find the second extension */
-
- ext2 = f2->filename + strlen(f2->filename);
- extf = FALSE;
- while (!extf && (ext2 > f2->filename)) {
- extf = (*--ext2 == '.');
- }
- if (!extf) {
- ext2 = NULL;
- } else {
- ext2++;
- }
- /* idem as for ext1 */
-
- if ((s1->st_mode & S_IFDIR) && (s2->st_mode & S_IFDIR)) {
- ret = null_strcmp(ext1, ext2);
- if (ret == 0) {
- return(strcmp(f1->filename, f2->filename));
- } else {
- return(ret);
- }
- };
- if (s1->st_mode & S_IFDIR) {
- return(-1);
- }
- if (s2->st_mode & S_IFDIR) {
- return(1);
- }
- ret = null_strcmp(ext1, ext2);
- if (ret == 0) {
- return(strcmp(f1->filename, f2->filename));
- } else {
- return(ret);
- }
-
-} /* dir_extsort() */
-
-
-void
-get_dir(char *dirname, char *fmask, DirList **dir, int *n)
-/*
- * desc: get the files in the current directory
- * pre: <dir> == NULL
- * post: <dir> contains <n> dir-entries
- */
-{
- char cwd[MAXPATHLEN];
- char buf[256];
- struct dirent **dire;
- struct stat status;
- int i, j, nb;
- long d;
-
-
- getcwd(cwd, MAXPATHLEN);
- if (strcmp(cwd, "/") == 0) { /* we are in the root directory */
- if (show_dotfiles()) {
- *n = scandir(dirname, &dire, dir_select_root, alphasort);
- } else {
- *n = scandir(dirname, &dire, dir_select_root_nd, alphasort);
- }
- } else {
- if (show_dotfiles()) {
- *n = scandir(dirname, &dire, dir_select, alphasort);
- } else {
- *n = scandir(dirname, &dire, dir_select_nd, alphasort);
- }
- }
-
- /* There is the possibility that we have entered a directory */
- /* which we are not allowed to read, scandir thus returning */
- /* -1 for *n. */
- /* Actually I should also check for lack of memory, but I'll */
- /* let my application happily crash if this is the case */
- /* Solution: */
- /* manually insert the parent directory as the only */
- /* directory entry, and return. */
-
- if (*n == -1) {
- *n = 1;
- *dir = (DirList *) malloc(sizeof(DirList));
- strcpy((*dir)[0].filename, "..");
- lstat("..", &status);
- (*dir)[0].filestatus = status;
- (*dir)[0].link = FALSE;
- return;
- }
-
- *dir = (DirList *) malloc( *n * sizeof(DirList) );
- d = 0;
- i = 0;
- j = 0;
- while (j<*n) {
- lstat(dire[j]->d_name, &status);
- /* check if this file is to be included */
- /* always include directories, the rest is subject to fmask */
- if (S_ISDIR(status.st_mode)
- || fnmatch(fmask, dire[j]->d_name, FNM_NOESCAPE) != FNM_NOMATCH) {
- strcpy((*dir)[i].filename, dire[j]->d_name);
- (*dir)[i].filestatus = status;
- if ((S_IFMT & status.st_mode) == S_IFLNK) { /* handle links */
- (*dir)[i].link = TRUE;
- stat(dire[j]->d_name, &status);
- nb = readlink(dire[j]->d_name, buf, 256);
- if (nb == -1) {
- printf("get_dir(): Error reading link: %s\n", dire[j]->d_name);
- exit(-1);
- } else {
- (*dir)[i].linkname = malloc(sizeof(char) * nb + 1);
- strncpy((*dir)[i].linkname, buf, nb);
- (*dir)[i].linkname[nb] = 0;
- }
- (*dir)[i].filestatus = status;
- } else {
- (*dir)[i].link = FALSE;
- (*dir)[i].linkname = NULL;
- }
- i++;
- } else {
- /* skip this entry */
- }
- j++;
- }
- *n = i;
-
- /* sort the directory with the directory names on top */
- qsort((*dir), *n, sizeof(DirList), _sort_func);
-
- /* Free the allocated memory */
- for (i=0; i<*n; i++) {
- free(dire[i]);
- }
- free(dire);
-
- return;
-}/* get_dir() */
-
-
-void
-FreeDir(DirList *d, int n)
-/*
- * desc: free the dirlist d
- * pre: d != NULL
- * post: memory allocated to d has been released
- */
-{
- int i;
-
- if (d) {
- for (i=0; i<n; i++) {
- if (d[i].linkname) {
- free(d[i].linkname);
- }
- }
- free(d);
- } else {
- printf("dir.c:FreeDir(): d == NULL\n");
- exit(-1);
- }
-
- return;
-} /* FreeDir() */
-
-void
-toggle_dotfiles(void)
-/*
- * desc: toggle visibility of dot-files
- */
-{
- _showdotfiles = !_showdotfiles;
-
- return;
-} /* toggle_dotfiles() */
-
-int
-show_dotfiles(void)
-/*
- * desc: return the value of _showdotfiles
- */
-{
- return(_showdotfiles);
-} /* show_dotfiles() */
-
-void
-set_dotfiles(int b)
-/*
- * desc: set the value of _showdotfiles
- */
-{
- _showdotfiles = b;
-
- return;
-} /* set_dotfiles() */
diff --git a/gnu/lib/libdialog/dir.h b/gnu/lib/libdialog/dir.h
deleted file mode 100644
index eadc0c5..0000000
--- a/gnu/lib/libdialog/dir.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * include file for dir.c
- *
- * Copyright (c) 1995, Marc van Kempen
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/dirent.h>
-
-typedef struct DirList { /* structure to hold the directory entries */
- char filename[MAXNAMLEN]; /* together with the stat-info per file */
- struct stat filestatus; /* filename, or the name to which it points */
- int link; /* is it a link ? */
- char *linkname; /* the name of the file the link points to */
-} DirList;
-
-#ifndef TRUE
-#define TRUE (1)
-#endif
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-void get_dir(char *dirname, char *fmask, DirList **dir, int *n);
-void get_filenames(DirList *d, int n, char ***names, int *nf);
-void FreeDir(DirList *d, int n);
diff --git a/gnu/lib/libdialog/fselect.c b/gnu/lib/libdialog/fselect.c
deleted file mode 100644
index 6669edc..0000000
--- a/gnu/lib/libdialog/fselect.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * program: fselect.c
- * author: Marc van Kempen (wmbfmk@urc.tue.nl)
- * Desc: File selection routine
- *
- * Copyright (c) 1995, Marc van Kempen
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/param.h>
-#include <dialog.h>
-#include "ui_objects.h"
-#include "dir.h"
-#include "dialog.priv.h"
-
-/*
- * Local prototypes
- */
-
-char *dialog_dfselect(char *dir, char *fmask, int is_fselect);
-
-/*
- * Functions
- */
-
-void
-get_directories(DirList *d, int n, char ***names, int *nd)
-/*
- * Desc: return the directorienames in <dir> as an array in
- * <names>, the # of entries in <nd>, memory allocated
- * to *names should be freed when done with it.
- */
-{
- int i;
-
- /* count the directories, which are in front */
- *nd = 0;
- while ((*nd < n) && (S_ISDIR(d[*nd].filestatus.st_mode))) (*nd)++;
- *names = (char **) malloc( *nd * sizeof(char *) );
- for (i=0; i<*nd; i++) {
- (*names)[i] = (char *) malloc( strlen(d[i].filename) + 1);
- strcpy((*names)[i], d[i].filename);
- }
-
- return;
-} /* get_directories() */
-
-void
-get_filenames(DirList *d, int n, char ***names, int *nf)
-/*
- * Desc: return the filenames in <dir> as an arry in
- * <names>, the # of entries in <nf>, memory allocated
- * to *names should be freed when done.
- */
-{
- int nd, i;
-
- /* the # of regular files is the total # of files - # of directories */
- /* count the # of directories */
- nd = 0;
- while ((nd < n) && (S_ISDIR(d[nd].filestatus.st_mode))) nd++;
-
- *names = (char **) malloc( (n-nd) * sizeof(char *) );
- *nf = n - nd;
- for (i=0; i<*nf; i++) {
- (*names)[i] = (char *) malloc( strlen(d[i+nd].filename) + 1);
- strcpy((*names)[i], d[i+nd].filename);
- }
-
- return;
-} /* get_filenames() */
-
-void
-FreeNames(char **names, int n)
-/*
- * Desc: free the space occupied by names
- */
-{
- int i;
-
- /* free the space occupied by names */
- for (i=0; i<n; i++) {
- free(names[i]);
- }
- free(names);
-
- return;
-} /* FreeNames() */
-
-int
-dialog_dselect_old(void)
-/*
- * Desc: starting from the current directory,
- * choose a new current directory
- */
-{
- DirList *d = NULL;
- char **names, old_dir[MAXPATHLEN];
- WINDOW *ds_win;
- ButtonObj *okbut, *cancelbut;
- ListObj *dirs_obj;
- StringObj *dir_obj;
- char o_dir[MAXPATHLEN];
- struct ComposeObj *obj = NULL;
- int n, nd, okbutton, cancelbutton,
- quit, cancel, ret;
-
- ds_win = newwin(LINES-8, COLS-30, 4, 15);
- if (ds_win == NULL) {
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n",
- LINES-8, COLS-30, 4, 15);
- exit(1);
- }
- draw_box(ds_win, 0, 0, LINES-8, COLS-30, dialog_attr, border_attr);
- wattrset(ds_win, dialog_attr);
- mvwaddstr(ds_win, 0, (COLS-30)/2 - 9, " Directory Select ");
- draw_shadow(stdscr, 4, 15, LINES-8, COLS-30);
- display_helpline(ds_win, LINES-9, COLS-30);
-
- /* the Directory string input field */
- getcwd(o_dir, MAXPATHLEN);
- dir_obj = NewStringObj(ds_win, "Directory:", o_dir, 1, 2, COLS-34, MAXPATHLEN-1);
- AddObj(&obj, STRINGOBJ, (void *) dir_obj);
-
- /* the list of directories */
- get_dir(".", "*", &d, &n);
- get_directories(d, n, &names, &nd);
- dirs_obj = NewListObj(ds_win, "Directories:", names, o_dir, 5, 2,
- LINES-15, COLS-48, nd);
- AddObj(&obj, LISTOBJ, (void *) dirs_obj);
-
- /* the Ok-button */
- okbutton = FALSE;
- okbut = NewButtonObj(ds_win, "Continue", &okbutton, 7, COLS-45);
- AddObj(&obj, BUTTONOBJ, (void *) okbut);
-
- /* the Cancel-button */
- cancelbutton = FALSE;
- cancelbut = NewButtonObj(ds_win, "Return", &cancelbutton, 11, COLS-44);
- AddObj(&obj, BUTTONOBJ, (void *) cancelbut);
-
- quit = FALSE;
- cancel = FALSE;
- strcpy(old_dir, o_dir);
- while (!quit) {
- ret = PollObj(&obj);
- switch(ret) {
- case SEL_BUTTON:
- if (okbutton) {
- quit = TRUE;
- }
- if (cancelbutton) {
- quit = TRUE;
- cancel = TRUE;
- }
- break;
- case SEL_CR:
- if (strcmp(old_dir, o_dir)) {
- /* the directory was changed, cd into it */
- if (chdir(o_dir)) {
- dialog_notify("Could not change into directory");
- strcpy(o_dir, old_dir);
- } else {
- getcwd(o_dir, MAXPATHLEN);
- strcpy(old_dir, o_dir);
- }
- RefreshStringObj(dir_obj);
- }
- get_dir(".", "*", &d, &n);
- FreeNames(names, nd);
- get_directories(d, n, &names, &nd);
- UpdateListObj(dirs_obj, names, nd);
- if (((obj->prev)->obj == (void *) dirs_obj)) {
- obj=obj->prev;
- }
- break;
- case SEL_ESC:
- quit = TRUE;
- cancel = TRUE;
- break;
- case KEY_F(1):
- display_helpfile();
- break;
- }
- }
-
- FreeNames(names, nd);
- DelObj(obj);
- delwin(ds_win);
-
- return(cancel);
-
-} /* dialog_dselect() */
-
-int
-dialog_dselect(char *dir, char *fmask)
-/*
- * Desc: Choose a directory
- */
-{
- if (dialog_dfselect(dir, fmask, FALSE)) {
- return(FALSE); /* esc or cancel was pressed */
- } else {
- return(TRUE); /* directory was selected */
- }
-} /* dialog_dselect() */
-
-char *
-dialog_fselect(char *dir, char *fmask)
-/*
- * Desc: Choose a file from a directory
- */
-{
- return(dialog_dfselect(dir, fmask, TRUE));
-} /* dialog_fselect() */
-
-char *
-dialog_dfselect(char *dir, char *fmask, int is_fselect)
-/*
- * Desc: choose a file from the directory <dir>, which
- * initially display files with the mask <filemask>
- * pre: <dir> is the initial directory
- * only files corresponding to the mask <fmask> are displayed
- * post: returns NULL if no file was selected
- * else returns pointer to filename, space is allocated, should
- * be freed after use.
- */
-{
- DirList *d = NULL;
- char msg[512];
- char **fnames, **dnames, *ret_name;
- WINDOW *fs_win;
- int n, nd, nf, ret;
- StringObj *fm_obj, *dir_obj, *sel_obj;
- char o_fm[255], o_dir[MAXPATHLEN], o_sel[MAXPATHLEN];
- char old_fmask[255], old_dir[MAXPATHLEN];
- ListObj *dirs_obj, *files_obj;
- struct ComposeObj *obj = NULL, *o;
- int quit, cancel;
- ButtonObj *okbut_obj, *canbut_obj;
- int ok_button, cancel_button;
-
- if (chdir(dir)) {
- sprintf(msg, "Could not move into specified directory: %s", dir);
- dialog_notify(msg);
- return(NULL);
- }
- getcwd(o_dir, MAXPATHLEN);
-
- /* setup the fileselect-window and initialize its components */
- fs_win = newwin(LINES-2, COLS-20, 1, 10);
- if (fs_win == NULL) {
- endwin();
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n",
- LINES-2, COLS-20, 2, 10);
- exit(1);
- }
- draw_box(fs_win, 0, 0, LINES-2, COLS-20, dialog_attr, border_attr);
- wattrset(fs_win, dialog_attr);
- if (is_fselect) {
- mvwaddstr(fs_win, 0, (COLS-20)/2 - 7, " File Select ");
- } else {
- mvwaddstr(fs_win, 0, (COLS-20)/2 - 9, " Directory Select ");
- }
- draw_shadow(stdscr, 1, 10, LINES-2, COLS-20);
- display_helpline(fs_win, LINES-3, COLS-20);
-
- /* Filemask entry */
- strcpy(o_fm, fmask);
- fm_obj = NewStringObj(fs_win, "Filemask:", o_fm, 1, 2, 19, 255);
- AddObj(&obj, STRINGOBJ, (void *) fm_obj);
-
- /* Directory entry */
- dir_obj = NewStringObj(fs_win, "Directory:", o_dir, 1, 22, COLS-44, 255);
- AddObj(&obj, STRINGOBJ, (void *) dir_obj);
-
- /* Directory list */
- get_dir(".", fmask, &d, &n); /* read the entire directory */
- get_directories(d, n, &dnames, &nd); /* extract the dir-entries */
- if (is_fselect) {
- dirs_obj = NewListObj(fs_win, "Directories:", dnames, o_dir, 5, 2,
- LINES-16, (COLS-20)/2-2, nd);
- } else {
- dirs_obj = NewListObj(fs_win, "Directories:", dnames, o_dir, 5, 2,
- LINES-12, (COLS-20)/2-2, nd);
- }
- AddObj(&obj, LISTOBJ, (void *) dirs_obj);
-
- /* Filenames list */
- get_filenames(d, n, &fnames, &nf); /* extract the filenames */
- if (is_fselect) {
- files_obj = NewListObj(fs_win, "Files:", fnames, o_sel, 5, (COLS-20)/2+1,
- LINES-16, (COLS-20)/2-3, nf);
- } else {
- files_obj = NewListObj(fs_win, "Files:", fnames, o_sel, 5, (COLS-20)/2+1,
- LINES-12, (COLS-20)/2-3, nf);
- }
- AddObj(&obj, LISTOBJ, (void *) files_obj);
-
- if (is_fselect) {
- /* Selection entry */
- o_sel[0] = '\0';
- sel_obj = NewStringObj(fs_win, "Selection:", o_sel, LINES-10, 2, COLS-24, 255);
- AddObj(&obj, STRINGOBJ, (void *) sel_obj);
- }
-
- /* Ok button */
- ok_button = FALSE;
- okbut_obj = NewButtonObj(fs_win, "Ok", &ok_button, LINES-6, 20);
- AddObj(&obj, BUTTONOBJ, (void *) okbut_obj);
-
- /* Cancel button */
- cancel_button = FALSE;
- canbut_obj = NewButtonObj(fs_win, "Cancel", &cancel_button, LINES-6, 30);
- AddObj(&obj, BUTTONOBJ, (void *) canbut_obj);
-
- /* Make sure all objects on the window are drawn */
- wrefresh(fs_win);
- keypad(fs_win, TRUE);
-
- /* Start the reading */
- o = obj;
- strcpy(old_fmask, o_fm);
- strcpy(old_dir, o_dir);
- quit = FALSE;
- cancel = FALSE;
- while (!quit) {
- ret = PollObj(&o);
- switch(ret) {
- case SEL_CR:
- if (strcmp(old_fmask, o_fm) || strcmp(old_dir, o_dir)) {
- /* reread directory and update the listobjects */
- if (strcmp(old_dir, o_dir)) { /* dir entry was changed */
- if (chdir(o_dir)) {
- dialog_notify("Could not change into directory");
- strcpy(o_dir, old_dir);
- } else {
- getcwd(o_dir, MAXPATHLEN);
- strcpy(old_dir, o_dir);
- }
- RefreshStringObj(dir_obj);
- } else { /* fmask entry was changed */
- strcpy(old_fmask, o_fm);
- }
- get_dir(".", o_fm, &d, &n);
- FreeNames(dnames, nd);
- get_directories(d, n, &dnames, &nd);
- UpdateListObj(dirs_obj, dnames, nd);
- FreeNames(fnames, nf);
- get_filenames(d, n, &fnames, &nf);
- UpdateListObj(files_obj, fnames, nf);
- if (((o->prev)->obj == (void *) dirs_obj)) {
- o=o->prev;
- }
- }
- break;
- case SEL_BUTTON:
- /* check which button was pressed */
- if (ok_button) {
- quit = TRUE;
- }
- if (cancel_button) {
- quit = TRUE;
- cancel = TRUE;
- }
- break;
- case SEL_ESC:
- quit = TRUE;
- cancel = TRUE;
- break;
- case KEY_F(1):
- case '?':
- display_helpfile();
- break;
- }
- }
- DelObj(obj);
- FreeNames(dnames, nd);
- FreeNames(fnames, nf);
- delwin(fs_win);
-
- if (cancel || (strlen(o_sel) == 0)) {
- return(NULL);
- } else {
- ret_name = (char *) malloc( strlen(o_sel) + 1 );
- strcpy(ret_name, o_sel);
- return(ret_name);
- }
-} /* dialog_fselect() */
-
diff --git a/gnu/lib/libdialog/gauge.c b/gnu/lib/libdialog/gauge.c
deleted file mode 100644
index a44f969..0000000
--- a/gnu/lib/libdialog/gauge.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * gauge.c
- *
- * progress indicator for libdialog
- *
- *
- * Copyright (c) 1995, Marc van Kempen
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- */
-
-#include "dialog.h"
-
-void
-dialog_gauge(char *title, char *prompt, int y, int x,
- int height, int width, int perc)
-/*
- * Desc: display a progress bar, progress indicated by <perc>
- */
-{
- WINDOW *gw;
- int glen, i;
- char percs[5];
-
- gw = newwin(height, width, y, x);
- if (!gw) {
- fprintf(stderr, "dialog_gauge: Error creating window (%d, %d, %d, %d)",
- height, width, y, x);
- exit(-1);
- }
-
- draw_box(gw, 0, 0, height, width, dialog_attr, border_attr);
- draw_shadow(stdscr, y, x, height, width);
-
- wattrset(gw, title_attr);
- if (title) {
- wmove(gw, 0, (width - strlen(title))/2 - 1);
- waddstr(gw, "[ ");
- waddstr(gw, title);
- waddstr(gw, " ]");
- }
- wattrset(gw, dialog_attr);
- if (prompt) {
- wmove(gw, 1, (width - strlen(prompt))/2 - 1);
- waddstr(gw, prompt);
- }
-
- draw_box(gw, 2, 2, 3, width-4, dialog_attr, border_attr);
- glen = (int) ((float) perc/100 * (width-6));
-
- wattrset(gw, dialog_attr);
- sprintf(percs, "%3d%%", perc);
- wmove(gw, 5, width/2 - 2);
- waddstr(gw, percs);
-
- wattrset(gw, A_BOLD);
- wmove(gw, 3, 3);
- for (i=0; i<glen; i++) waddch(gw, ' ');
-
- wrefresh(gw);
-
- return;
-} /* dialog_gauge() */
-
diff --git a/gnu/lib/libdialog/help.c b/gnu/lib/libdialog/help.c
deleted file mode 100644
index de49c6a..0000000
--- a/gnu/lib/libdialog/help.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/***************************************************************
- *
- * Program: help.c
- * Author: Marc van Kempen
- * Desc: get help
- *
- *
- * Copyright (c) 1995, Marc van Kempen
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- ***************************************************************/
-
-#include <stdlib.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <dialog.h>
-
-static char _helpfilebuf[MAXPATHLEN];
-static char _helplinebuf[77]; /* limit the helpline to 76 characters */
-static char *_helpfile = NULL;
-static char *_helpline = NULL;
-
-/******************************************************************
- *
- * helpfile routines
- *
- ******************************************************************/
-
-void
-use_helpfile(char *hfile)
-/*
- * desc: set the helpfile to be opened on pressing F1 to <helpfile>
- */
-{
- if (hfile != NULL) {
- _helpfile = _helpfilebuf;
- strcpy(_helpfile, hfile);
- } else {
- _helpfile = NULL;
- }
-
- return;
-} /* use_helpfile() */
-
-void
-display_helpfile(void)
-/*
- * desc: display the current helpfile in a window
- */
-{
- WINDOW *w;
- FILE *f;
- struct stat sb;
- char msg[80], *buf;
- static int in_help = FALSE;
- char *savehline = NULL;
-
- if (in_help) return; /* dont call help when you're in help */
-
- if (_helpfile != NULL) {
- if ((w = dupwin(newscr)) == NULL) {
- dialog_notify("No memory to dup previous screen\n");
- return;
- }
- if ((f = fopen(_helpfile, "r")) == NULL) {
- sprintf(msg, "Can't open helpfile : %s\n", _helpfile);
- dialog_notify(msg);
- return;
- }
- if (fstat(fileno(f), &sb)) {
- sprintf(msg, "Can't stat helpfile : %s\n", _helpfile);
- dialog_notify(msg);
- return;
- }
- if ((buf = (char *) malloc( sb.st_size )) == NULL) {
- sprintf(msg, "Could not malloc space for helpfile : %s\n", _helpfile);
- dialog_notify(msg);
- return;
- }
- if (fread(buf, 1, sb.st_size, f) != sb.st_size) {
- sprintf(msg, "Could not read entire help file : %s", _helpfile);
- dialog_notify(msg);
- free(buf);
- return;
- }
- buf[sb.st_size] = 0;
- in_help = TRUE;
- savehline = get_helpline();
- use_helpline("Use arrowkeys, PgUp, PgDn, Home and End to move through text");
- dialog_mesgbox("Online help", buf, LINES-4, COLS-4);
- restore_helpline(savehline);
- in_help = FALSE;
- touchwin(w);
- wrefresh(w);
- delwin(w);
- free(buf);
- } else {
- /* do nothing */
- }
-
- return;
-} /* display_helpfile() */
-
-
-/******************************************************************
- *
- * helpline routines
- *
- ******************************************************************/
-
-void
-use_helpline(char *hline)
-/*
- * desc: set the helpline to printed in dialogs
- */
-{
- if (hline) {
- _helpline = _helplinebuf;
- if (strlen(hline) > 76) {
- /* only display the first 76 characters in the helpline */
- strncpy(_helpline, hline, 76);
- _helpline[76] = 0;
- } else {
- strcpy(_helpline, hline);
- }
- } else {
- _helpline = NULL;
- }
-
- return;
-} /* use_helpline() */
-
-void
-display_helpline(WINDOW *w, int y, int width)
-/*
- * desc: display the helpline at the given coordinates <y, x> in the window <w>
- */
-{
- if (_helpline != NULL) {
- if (strlen(_helpline) > width - 6) {
- _helpline[width - 6] = 0;
- }
- wmove(w, y, (int) (width - strlen(_helpline)- 4) / 2);
- wattrset(w, title_attr);
- waddstr(w, "[ ");
- waddstr(w, _helpline);
- waddstr(w, " ]");
- } else {
- /* do nothing */
- }
-
- return;
-}
-
-char *
-get_helpline(void)
-/*
- * desc: allocate new space, copy the helpline to it and return a pointer to it
- */
-{
- char *hlp;
-
- if (_helpline) {
- hlp = (char *) malloc( strlen(_helpline) + 1 );
- strcpy(hlp, _helpline);
- } else {
- hlp = NULL;
- }
-
- return(hlp);
-} /* get_helpline() */
-
-void
-restore_helpline(char *helpline)
-/*
- * Desc: set the helpline to <helpline> and free the space allocated to it
- */
-{
- use_helpline(helpline);
- free(helpline);
-
- return;
-} /* restore_helpline() */
diff --git a/gnu/lib/libdialog/inputbox.c b/gnu/lib/libdialog/inputbox.c
deleted file mode 100644
index 1f61ed5..0000000
--- a/gnu/lib/libdialog/inputbox.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * inputbox.c -- implements the input box
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- */
-
-
-#include <dialog.h>
-#include "dialog.priv.h"
-
-
-/*
- * Display a dialog box for inputing a string
- */
-int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int width, unsigned char *result)
-{
- int i, j, x, y, box_y, box_x, box_width, first,
- key = 0, button = -1;
- unsigned char instr[MAX_LEN+1];
- WINDOW *dialog;
-
- if (height < 0)
- height = strheight(prompt)+2+4;
- if (width < 0) {
- i = strwidth(prompt);
- j = ((title != NULL) ? strwidth(title) : 0);
- width = MAX(i,j) + 4;
- }
- width = MAX(width,24);
-
- if (width > COLS)
- width = COLS;
- if (height > LINES)
- height = LINES;
- /* center dialog box on screen */
- x = DialogX ? DialogX : (COLS - width)/2;
- y = DialogY ? DialogY : (LINES - height)/2;
-
-#ifdef HAVE_NCURSES
- if (use_shadow)
- draw_shadow(stdscr, y, x, height, width);
-#endif
- dialog = newwin(height, width, y, x);
- if (dialog == NULL) {
- endwin();
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
- exit(1);
- }
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
- wattrset(dialog, border_attr);
- wmove(dialog, height-3, 0);
- waddch(dialog, ACS_LTEE);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dialog_attr);
- waddch(dialog, ACS_RTEE);
- wmove(dialog, height-2, 1);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ' ');
-
- if (title != NULL) {
- wattrset(dialog, title_attr);
- wmove(dialog, 0, (width - strlen(title))/2 - 1);
- waddch(dialog, ' ');
- waddstr(dialog, title);
- waddch(dialog, ' ');
- }
- wattrset(dialog, dialog_attr);
- wmove(dialog, 1, 2);
- print_autowrap(dialog, prompt, height-1, width-2, width, 1, 2, TRUE, FALSE);
-
- /* Draw the input field box */
- box_width = width-6;
- getyx(dialog, y, x);
- box_y = y + 2;
- box_x = (width - box_width)/2;
- draw_box(dialog, y+1, box_x-1, 3, box_width+2, border_attr, dialog_attr);
-
- display_helpline(dialog, height-1, width);
-
- x = width/2-11;
- y = height-2;
- print_button(dialog, "Cancel", y, x+14, FALSE);
- print_button(dialog, " OK ", y, x, TRUE);
-
- first = 1;
- strcpy(instr, result);
- wattrset(dialog, dialog_attr);
-
- while (key != ESC) {
-
- if (button == -1) { /* Input box selected */
- key = line_edit(dialog, box_y, box_x, -1, box_width, inputbox_attr, first, instr, DialogInputAttrs);
- first = 0;
- }
- else
- key = wgetch(dialog);
-
- switch (key) {
- case 'O':
- case 'o':
- delwin(dialog);
- strcpy(result, instr);
- return 0;
- case 'C':
- case 'c':
- delwin(dialog);
- return 1;
- case KEY_UP:
- case KEY_LEFT:
- case KEY_BTAB:
- switch (button) {
- case -1:
- button = 1; /* Indicates "Cancel" button is selected */
- print_button(dialog, " OK ", y, x, FALSE);
- print_button(dialog, "Cancel", y, x+14, TRUE);
- wrefresh(dialog);
- break;
- case 0:
- button = -1; /* Indicates input box is selected */
- print_button(dialog, "Cancel", y, x+14, FALSE);
- print_button(dialog, " OK ", y, x, TRUE);
- break;
- case 1:
- button = 0; /* Indicates "OK" button is selected */
- print_button(dialog, "Cancel", y, x+14, FALSE);
- print_button(dialog, " OK ", y, x, TRUE);
- wrefresh(dialog);
- break;
- }
- break;
- case TAB:
- case KEY_DOWN:
- case KEY_RIGHT:
- switch (button) {
- case -1:
- button = 0; /* Indicates "OK" button is selected */
- print_button(dialog, "Cancel", y, x+14, FALSE);
- print_button(dialog, " OK ", y, x, TRUE);
- wrefresh(dialog);
- break;
- case 0:
- button = 1; /* Indicates "Cancel" button is selected */
- print_button(dialog, " OK ", y, x, FALSE);
- print_button(dialog, "Cancel", y, x+14, TRUE);
- wrefresh(dialog);
- break;
- case 1:
- button = -1; /* Indicates input box is selected */
- print_button(dialog, "Cancel", y, x+14, FALSE);
- print_button(dialog, " OK ", y, x, TRUE);
- break;
- }
- break;
- case ' ':
- case '\n':
- case '\r':
- delwin(dialog);
- if (button < 1)
- strcpy(result, instr);
- return (button == -1 ? 0 : button);
- case ESC:
- break;
- case KEY_F(1):
- case '?':
- display_helpfile();
- break;
- }
- }
-
- delwin(dialog);
- return -1; /* ESC pressed */
-}
-/* End of dialog_inputbox() */
diff --git a/gnu/lib/libdialog/kernel.c b/gnu/lib/libdialog/kernel.c
deleted file mode 100644
index c30e478..0000000
--- a/gnu/lib/libdialog/kernel.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * dialog - Display simple dialog boxes from shell scripts
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- *
- *
- * HISTORY:
- *
- * 17/12/93 - Version 0.1 released.
- *
- * 19/12/93 - menu will now scroll if there are more items than can fit
- * on the screen.
- * - added 'checklist', a dialog box with a list of options that
- * can be turned on or off. A list of options that are on is
- * returned on exit.
- *
- * 20/12/93 - Version 0.15 released.
- *
- * 29/12/93 - Incorporated patch from Patrick J. Volkerding
- * (volkerdi@mhd1.moorhead.msus.edu) that made these changes:
- * - increased MAX_LEN to 2048
- * - added 'infobox', equivalent to a message box without pausing
- * - added option '--clear' that will clear the screen
- * - Explicit line breaking when printing prompt text can be
- * invoked by real newline '\n' besides the string "\n"
- * - an optional parameter '--title <string>' can be used to
- * specify a title string for the dialog box
- *
- * 03/01/94 - added 'textbox', a dialog box for displaying text from a file.
- * - Version 0.2 released.
- *
- * 04/01/94 - some fixes and improvements for 'textbox':
- * - fixed a bug that will cause a segmentation violation when a
- * line is longer than MAX_LEN characters. Lines will now be
- * truncated if they are longer than MAX_LEN characters.
- * - removed wrefresh() from print_line(). This will increase
- * efficiency of print_page() which calls print_line().
- * - display current position in the form of percentage into file.
- * - Version 0.21 released.
- *
- * 05/01/94 - some changes for faster screen update.
- *
- * 07/01/94 - much more flexible color settings. Can use all 16 colors
- * (8 normal, 8 highlight) of the Linux console.
- *
- * 08/01/94 - added run-time configuration using configuration file.
- *
- * 09/01/94 - some minor bug fixes and cleanups for menubox, checklist and
- * textbox.
- *
- * 11/01/94 - added a man page.
- *
- * 13/01/94 - some changes for easier porting to other Unix systems (tested
- * on Ultrix, SunOS and HPUX)
- * - Version 0.3 released.
- *
- * 08/06/94 - Patches by Stuart Herbert - S.Herbert@shef.ac.uk
- * Fixed attr_clear and the textbox stuff to work with ncurses 1.8.5
- * Fixed the wordwrap routine - it'll actually wrap properly now
- * Added a more 3D look to everything - having your own rc file could
- * prove 'interesting' to say the least :-)
- * Added radiolist option
- * - Version 0.4 released.
- */
-
-#define __DIALOG_MAIN__
-
-#include <dialog.h>
-#include "dialog.priv.h"
-#ifdef HAVE_NCURSES
-#include "colors.h"
-#endif
-
-/* These are two "secret" globals that can be fiddled to make a dialog
- * come up someplace other than a "centered" calculation for X,Y
- */
-int DialogX, DialogY;
-
-/* This "secret" global allows you to change the behavior of an input field */
-int DialogInputAttrs;
-
-/*
- * Do some initialization for dialog
- */
-void init_dialog(void)
-{
-#if defined(LOCALE)
- (void) setlocale(LC_ALL, "");
-#endif
-
-#ifdef HAVE_NCURSES
- if (parse_rc() == -1) /* Read the configuration file */
- exit(-1);
-#endif
-
- if (initscr() == NULL) { /* Init curses */
- fprintf(stderr, "\nCurses initialization error.\n");
- exit(-1);
- }
- keypad(stdscr, TRUE);
- cbreak();
- noecho();
-
-#ifdef HAVE_NCURSES
- if (use_colors || use_shadow) /* Set up colors */
- color_setup();
-#endif
-
- /* Set screen to screen attribute */
- dialog_clear_norefresh();
- DialogX = DialogY = 0;
-}
-/* End of init_dialog() */
-
-
-#ifdef HAVE_NCURSES
-/*
- * Setup for color display
- */
-void color_setup(void)
-{
- int i;
-
- if (has_colors()) { /* Terminal supports color? */
- start_color();
-
- /* Initialize color pairs */
- for (i = 0; i < ATTRIBUTE_COUNT; i++)
- init_pair(i+1, color_table[i][0], color_table[i][1]);
-
- /* Setup color attributes */
- for (i = 0; i < ATTRIBUTE_COUNT; i++)
- attributes[i] = C_ATTR(color_table[i][2], i+1);
- }
-}
-/* End of color_setup() */
-#endif
-
-
-/*
- * Set window to attribute 'attr'
- */
-void attr_clear(WINDOW *win, int height, int width, chtype attr)
-{
- int i, j;
-
- wattrset(win, attr); /* Set window to attribute 'attr' */
- for (i = 0; i < height; i++) {
- wmove(win, i, 0);
- for (j = 0; j < width; j++)
- waddch(win, ' ');
- }
-}
-/* End of attr_clear() */
-
-
-/*
- * Print a string of text in a window, automatically wrap around to the
- * next line if the string is too long to fit on one line. Note that the
- * string may contain "\n" to represent a newline character or the real
- * newline '\n', but in that case, auto wrap around will be disabled.
- */
-void print_autowrap(WINDOW *win, unsigned char *prompt, int height, int width, int maxwidth, int y, int x, int center, int rawmode)
-{
- int cur_x, cur_y, i;
- unsigned char tempstr[MAX_LEN+1], *word, *tempptr, *tempptr1;
- chtype ostuff[132], attrs = 0, init_bottom = 0;
-
- wsetscrreg(win, y, height);
- getyx(win, cur_y, cur_x);
-
- strncpy(tempstr, prompt, MAX_LEN);
- tempstr[MAX_LEN] = '\0';
- if ((!rawmode && strstr(tempstr, "\\n") != NULL) ||
- (strchr(tempstr, '\n') != NULL)) { /* Prompt contains "\n" or '\n' */
- word = tempstr;
- while (1) {
- tempptr = rawmode ? NULL : strstr(word, "\\n");
- tempptr1 = strchr(word, '\n');
- if (tempptr == NULL && tempptr1 == NULL)
- break;
- else if (tempptr == NULL) { /* No more "\n" */
- tempptr = tempptr1;
- tempptr[0] = '\0';
- }
- else if (tempptr1 == NULL) { /* No more '\n' */
- tempptr[0] = '\0';
- tempptr++;
- }
- else { /* Prompt contains both "\n" and '\n' */
- if (strlen(tempptr)-2 < strlen(tempptr1)-1) {
- tempptr = tempptr1;
- tempptr[0] = '\0';
- }
- else {
- tempptr[0] = '\0';
- tempptr++;
- }
- }
-
- waddstr(win, word);
- word = tempptr + 1;
- if (++cur_y > height) {
- cur_y--;
- if (!init_bottom) {
- for (i = 0; i < x; i++)
- ostuff[i] = mvwinch(win, cur_y, i);
- for (i = width; i < maxwidth; i++)
- ostuff[i] = mvwinch(win, cur_y, i);
- attrs = getattrs(win);
- init_bottom = 1;
- }
- scrollok(win, TRUE);
- scroll(win);
- scrollok(win, FALSE);
- wmove(win, cur_y, 0);
- for (i = 0; i < x; i++) {
- wattrset(win, ostuff[i]&A_ATTRIBUTES);
- waddch(win, ostuff[i]);
- }
- wattrset(win, attrs);
- for ( ; i < width; i++)
- waddch(win, ' ');
- for ( ; i < maxwidth; i++) {
- wattrset(win, ostuff[i]&A_ATTRIBUTES);
- waddch(win, ostuff[i]);
- }
- wattrset(win, attrs);
- wrefresh(win);
- }
- wmove(win, cur_y, cur_x = x);
- }
- waddstr(win, word);
- }
- else if (center && strlen(tempstr) <= width-x*2) { /* If prompt is short */
- wmove(win, cur_y, (width - strlen(tempstr)) / 2);
- waddstr(win, tempstr);
- }
- else if (!center && strlen(tempstr) <= width-cur_x) { /* If prompt is short */
- waddstr(win, tempstr);
- }
- else {
- char *p = tempstr;
-
- /* Print prompt word by word, wrap around if necessary */
- while ((word = strsep(&p, "\t\n ")) != NULL) {
- int loop;
- unsigned char sc;
-
- if (*word == '\0')
- continue;
- do {
- loop = 0;
- if (cur_x+strlen(word) >= width+1) { /* wrap around to next line */
- if (x+strlen(word) >= width+1) {
- sc = word[width-cur_x-1];
- word[width-cur_x-1] = '\0';
- wmove(win, cur_y, cur_x);
- waddstr(win, word);
- word[width-cur_x-1] = sc;
- word += width-cur_x-1;
- getyx(win, cur_y, cur_x);
- loop = 1;
- }
- cur_y++;
- cur_x = x;
- if (cur_y > height) {
- cur_y--;
- if (!init_bottom) {
- for (i = 0; i < x; i++)
- ostuff[i] = mvwinch(win, cur_y, i);
- for (i = width; i < maxwidth; i++)
- ostuff[i] = mvwinch(win, cur_y, i);
- attrs = getattrs(win);
- init_bottom = 1;
- }
- scrollok(win, TRUE);
- scroll(win);
- scrollok(win, FALSE);
- wmove(win, cur_y, 0);
- for (i = 0; i < x; i++) {
- wattrset(win, ostuff[i]&A_ATTRIBUTES);
- waddch(win, ostuff[i]);
- }
- wattrset(win, attrs);
- for ( ; i < width; i++)
- waddch(win, ' ');
- for ( ; i < maxwidth; i++) {
- wattrset(win, ostuff[i]&A_ATTRIBUTES);
- waddch(win, ostuff[i]);
- }
- wattrset(win, attrs);
- wrefresh(win);
- }
- }
- }
- while(loop);
- wmove(win, cur_y, cur_x);
- waddstr(win, word);
- getyx(win, cur_y, cur_x);
- cur_x++;
- }
- }
-}
-/* End of print_autowrap() */
-
-
-/*
- * Print a button
- */
-void print_button(WINDOW *win, unsigned char *label, int y, int x, int selected)
-{
- int i, temp;
-
- wmove(win, y, x);
- wattrset(win, selected ? button_active_attr : button_inactive_attr);
- waddstr(win, selected ? "[" : " ");
- temp = strspn(label, " ");
- label += temp;
- for (i = 0; i < temp; i++)
- waddch(win, ' ');
- wattrset(win, selected ? button_key_active_attr : button_key_inactive_attr);
- waddch(win, label[0]);
- wattrset(win, selected ? button_active_attr : button_inactive_attr);
- waddstr(win, label+1);
- waddstr(win, selected ? "]" : " ");
- wmove(win, y, x+temp+1);
-}
-/* End of print_button() */
-
-
-/*
- * Draw a rectangular box with line drawing characters
- */
-void draw_box(WINDOW *win, int y, int x, int height, int width, chtype box, chtype border)
-{
- int i, j;
-
- wattrset(win, 0);
- for (i = 0; i < height; i++) {
- wmove(win, y + i, x);
- for (j = 0; j < width; j++)
- if (!i && !j)
- waddch(win, border | ACS_ULCORNER);
- else if (i == height-1 && !j)
- waddch(win, border | ACS_LLCORNER);
- else if (!i && j == width-1)
- waddch(win, box | ACS_URCORNER);
- else if (i == height-1 && j == width-1)
- waddch(win, box | ACS_LRCORNER);
- else if (!i)
- waddch(win, border | ACS_HLINE);
- else if (i == height-1)
- waddch(win, box | ACS_HLINE);
- else if (!j)
- waddch(win, border | ACS_VLINE);
- else if (j == width-1)
- waddch(win, box | ACS_VLINE);
- else
- waddch(win, box | ' ');
- }
-}
-/* End of draw_box() */
-
-
-#ifdef HAVE_NCURSES
-/*
- * Draw shadows along the right and bottom edge to give a more 3D look
- * to the boxes
- */
-void draw_shadow(WINDOW *win, int y, int x, int height, int width)
-{
- int i,sx,sy;
- chtype attrs;
-
- if (has_colors()) { /* Whether terminal supports color? */
- getbegyx(win,sy,sx);
- attrs = getattrs(win);
- if (y+height < getmaxy(win)) {
- /* small touch */
- wattrset(win, A_INVIS);
- wmove(win, y + height, x + 2);
- for (i = 0; i < width; i++)
- if (i+x+2 < getmaxx(win))
- waddch(win, ' ');
- /* end touch */
- wattrset(win, shadow_attr);
- wmove(win, y + height, x + 2);
- for (i = 0; i < width; i++)
- if (i+x+2 < getmaxx(win))
- waddch(win, mvwinch(newscr, sy+y+height, sx+x+2+i) & A_CHARTEXT);
- }
- if (x+width < getmaxx(win)) {
- for (i = y + 1; i < y + height + 1; i++) {
- if (i < getmaxy(win)) {
- /* small touch */
- wattrset(win, A_INVIS);
- wmove(win, i, x + width);
- waddch(win, ' ');
- if (x+width+1 < getmaxx(win))
- waddch(win, ' ');
- /* end touch */
- wattrset(win, shadow_attr);
- wmove(win, i, x + width);
- waddch(win, mvwinch(newscr, sy+i, sx+x+width) & A_CHARTEXT);
- if (x+width+1 < getmaxx(win))
- waddch(win, mvwinch(newscr, sy+i, sx+x+width+1) & A_CHARTEXT);
- }
- }
- }
- wattrset(win, attrs);
- wnoutrefresh(win);
- }
-}
-/* End of draw_shadow() */
-#endif
-
-void dialog_clear_norefresh(void)
-{
- attr_clear(stdscr, LINES, COLS, screen_attr);
- touchwin(stdscr);
- wnoutrefresh(stdscr);
-}
-
-void dialog_clear(void)
-{
- dialog_clear_norefresh();
- doupdate();
-}
-
-void dialog_update(void)
-{
- refresh();
-}
-
-void end_dialog(void)
-{
- endwin();
-}
-
-int strwidth(const char *p)
-{
- int i = 0, len, incr;
- const char *start, *s, *s1, *s2;
-
- for (start = s = p; ; start = (s += incr)) {
- s1 = strchr(s, '\n');
- s2 = strstr(s, "\\n");
- if (s2 == NULL)
- s = s1;
- else if (s1 == NULL)
- s = s2;
- else
- s = MIN(s1, s2);
- if (s == NULL)
- break;
- incr = 1 + (s == s2);
- len = s - start;
- if (len > i)
- i = len;
- }
- len = strlen(start);
- if (len > i)
- i = len;
- return i;
-}
-
-int strheight(const char *p)
-{
- int i = 1, incr;
- const char *s, *s1, *s2;
-
- for (s = p; ; s += incr) {
- s1 = strchr(s, '\n');
- s2 = strstr(s, "\\n");
- if (s2 == NULL)
- s = s1;
- else if (s1 == NULL)
- s = s2;
- else
- s = MIN(s1, s2);
- if (s == NULL)
- break;
- incr = 1 + (s == s2);
- i++;
- }
- return i;
-}
-
-void print_arrows(WINDOW *dialog, int scroll, int menu_height, int item_no,
- int box_x, int box_y, int tag_x, int cur_x, int cur_y)
-{
- wmove(dialog, box_y, box_x + tag_x + 1);
- wattrset(dialog, scroll ? uarrow_attr : menubox_attr);
- waddch(dialog, scroll ? ACS_UARROW : ACS_HLINE);
- wmove(dialog, box_y, box_x + tag_x + 2);
- waddch(dialog, scroll ? '(' : ACS_HLINE);
- wmove(dialog, box_y, box_x + tag_x + 3);
- waddch(dialog, scroll ? '-' : ACS_HLINE);
- wmove(dialog, box_y, box_x + tag_x + 4);
- waddch(dialog, scroll ? ')' : ACS_HLINE);
- wmove(dialog, box_y + menu_height + 1, box_x + tag_x + 1);
- wattrset(dialog, scroll+menu_height < item_no ? darrow_attr : menubox_border_attr);
- waddch(dialog, scroll+menu_height < item_no ? ACS_DARROW : ACS_HLINE);
- wmove(dialog, box_y + menu_height + 1, box_x + tag_x + 2);
- waddch(dialog, scroll+menu_height < item_no ? '(' : ACS_HLINE);
- wmove(dialog, box_y + menu_height + 1, box_x + tag_x + 3);
- waddch(dialog, scroll+menu_height < item_no ? '+' : ACS_HLINE);
- wmove(dialog, box_y + menu_height + 1, box_x + tag_x + 4);
- waddch(dialog, scroll+menu_height < item_no ? ')' : ACS_HLINE);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
-}
-
diff --git a/gnu/lib/libdialog/lineedit.c b/gnu/lib/libdialog/lineedit.c
deleted file mode 100644
index 7bfe0e0..0000000
--- a/gnu/lib/libdialog/lineedit.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Changes Copyright (C) 1995 by Andrey A. Chernov, Moscow
- *
- * Original Copyright:
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- */
-
-
-#include <dialog.h>
-#include "dialog.priv.h"
-
-static void redraw_field(WINDOW *dialog, int box_y, int box_x, int flen, int box_width, unsigned char instr[], int input_x, int scroll, chtype attr, chtype old_attr, int fexit, int attr_mask);
-
-/*
- * Line editor
- */
-int line_edit(WINDOW* dialog, int box_y, int box_x, int flen, int box_width, chtype attr, int first, unsigned char *result, int attr_mask)
-{
- int i, key;
- chtype old_attr;
- static int input_x, scroll;
- static unsigned char instr[MAX_LEN+1];
- unsigned char erase_char = erasechar();
- unsigned char kill_char = killchar();
-#ifdef notyet
- unsignec char werase_char = cur_term->Ottyb.c_cc[VWERASE];
-#endif
-
- old_attr = getattrs(dialog);
- keypad(dialog, TRUE);
-
- if (first) {
- memset(instr, 0, sizeof(instr));
- strcpy(instr, result);
- i = strlen(instr);
-/* input_x = i % box_width;*/
- input_x = (i > box_width) ? box_width - 1 : i;
-/* scroll = i - input_x;*/
- scroll = (i > box_width) ? i - box_width + 1: 0;
- }
- redraw_field(dialog, box_y, box_x, flen, box_width, instr, input_x, scroll, attr, old_attr, FALSE, attr_mask);
-
- for (;;) {
- wattrset(dialog, attr);
- wrefresh(dialog);
- key = wgetch(dialog);
- switch (key) {
- case ctrl('q'):
- goto ret;
- break;
- case KEY_F(1):
- display_helpfile();
- break;
- case TAB:
- case KEY_BTAB:
- case KEY_UP:
- case KEY_DOWN:
- case ESC:
- case '\r':
- case '\n':
- for (i = strlen(instr) - 1; i >= scroll + input_x && instr[i] == ' '; i--)
- instr[i] = '\0';
- if (key == '\r')
- key = '\n';
- goto ret;
- case '\025':
- case '\030':
- kill_it:
- input_x = scroll = 0;
- /* fall through */
- case '\013':
- case KEY_EOL:
- memset(instr + scroll + input_x, '\0', sizeof(instr) - scroll - input_x);
- redraw_field(dialog, box_y, box_x, flen, box_width, instr, input_x, scroll, attr, old_attr, FALSE, attr_mask);
- continue;
- case '\001':
- case KEY_HOME:
- input_x = scroll = 0;
- redraw_field(dialog, box_y, box_x, flen, box_width, instr, input_x, scroll, attr, old_attr, FALSE, attr_mask);
- continue;
- case '\005':
- case KEY_END:
- for (i = strlen(instr) - 1; i >= scroll + input_x && instr[i] == ' '; i--)
- instr[i] = '\0';
- i++;
- input_x = i % box_width;
- scroll = i - input_x;
- redraw_field(dialog, box_y, box_x, flen, box_width, instr, input_x, scroll, attr, old_attr, FALSE, attr_mask);
- continue;
- case '\002':
- case KEY_LEFT:
- if (input_x || scroll) {
- if (!input_x) {
- int oldscroll = scroll;
- scroll = scroll < box_width-1 ? 0 : scroll-(box_width-1);
- input_x = oldscroll - 1 - scroll;
- redraw_field(dialog, box_y, box_x, flen, box_width, instr, input_x, scroll, attr, old_attr, FALSE, attr_mask);
- } else {
- input_x--;
- wmove(dialog, box_y, input_x + box_x);
- }
- } else
- beep();
- continue;
- case '\006':
- case KEY_RIGHT:
- if ( scroll+input_x < MAX_LEN
- && (flen < 0 || scroll+input_x < flen)
- ) {
- if (!instr[scroll+input_x])
- instr[scroll+input_x] = ' ';
- if (input_x == box_width-1) {
- scroll++;
- redraw_field(dialog, box_y, box_x, flen, box_width, instr, input_x, scroll, attr, old_attr, FALSE, attr_mask);
- }
- else {
- wmove(dialog, box_y, input_x + box_x);
- waddch(dialog, instr[scroll+input_x]);
- input_x++;
- }
- } else
- beep(); /* Alarm user about overflow */
- continue;
- case '\b':
- case '\177':
- case KEY_BACKSPACE:
- erase_it:
- if (input_x || scroll) {
- i = strlen(instr);
- memmove(instr+scroll+input_x-1, instr+scroll+input_x, i-(scroll+input_x)+1);
- if (!input_x) {
- int oldscroll = scroll;
- scroll = scroll < box_width-1 ? 0 : scroll-(box_width-1);
- input_x = oldscroll - 1 - scroll;
- } else
- input_x--;
- redraw_field(dialog, box_y, box_x, flen, box_width, instr, input_x, scroll, attr, old_attr, FALSE, attr_mask);
- } else
- beep();
- continue;
- case '\004':
- case KEY_DC:
- for (i = strlen(instr) - 1; i >= scroll + input_x && instr[i] == ' '; i--)
- instr[i] = '\0';
- i++;
- if (i == 0) {
- beep();
- continue;
- }
- memmove(instr+scroll+input_x, instr+scroll+input_x+1, i-(scroll+input_x));
- redraw_field(dialog, box_y, box_x, flen, box_width, instr, input_x, scroll, attr, old_attr, FALSE, attr_mask);
- continue;
- default:
- if (CCEQ(key, erase_char))
- goto erase_it;
- if (CCEQ(key, kill_char))
- goto kill_it;
- if (key < 0x100 && isprint(key)) {
- for (i = strlen(instr) - 1; i >= scroll + input_x && instr[i] == ' '; i--)
- instr[i] = '\0';
- i++;
- if (i < MAX_LEN && (flen < 0 || scroll+input_x < flen)) {
- if (flen < 0 || i < flen)
- memmove(instr+scroll+input_x+1, instr+scroll+input_x, i-(scroll+input_x));
- instr[scroll+input_x] = key;
- if (input_x == box_width-1 && (flen < 0 || i < flen))
- scroll++;
- else
- input_x++;
- redraw_field(dialog, box_y, box_x, flen, box_width, instr, input_x, scroll, attr, old_attr, FALSE, attr_mask);
- } else
- beep(); /* Alarm user about overflow */
- continue;
- }
- }
- }
-ret:
- redraw_field(dialog, box_y, box_x, flen, box_width, instr, input_x, scroll, attr, old_attr, TRUE, attr_mask);
- wrefresh(dialog);
- strcpy(result, instr);
- return key;
-}
-
-static void
-redraw_field(WINDOW *dialog, int box_y, int box_x, int flen, int box_width, unsigned char instr[], int input_x, int scroll, chtype attr, chtype old_attr, int fexit, int attr_mask)
-{
- int i, fix_len;
-
- wattrset(dialog, fexit ? old_attr : attr);
- wmove(dialog, box_y, box_x);
- fix_len = flen >= 0 ? MIN(flen-scroll,box_width) : box_width;
- for (i = 0; i < fix_len; i++)
- waddch(dialog, instr[scroll+i] ? ((attr_mask & DITEM_NO_ECHO) ? '*' : instr[scroll+i]) : ' ');
- wattrset(dialog, old_attr);
- for ( ; i < box_width; i++)
- waddch(dialog, instr[scroll+i] ? ((attr_mask & DITEM_NO_ECHO) ? '*' : instr[scroll+i]) : ' ');
- wmove(dialog, box_y, input_x + box_x);
-}
diff --git a/gnu/lib/libdialog/menubox.c b/gnu/lib/libdialog/menubox.c
deleted file mode 100644
index 73d004a..0000000
--- a/gnu/lib/libdialog/menubox.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- * menubox.c -- implements the menu box
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * Substantial rennovation: 12/18/95, Jordan K. Hubbard
- *
- * 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
- * of the License, 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.
- */
-
-
-#include <dialog.h>
-#include "dialog.priv.h"
-#include <ncurses.h>
-
-static void print_item(WINDOW *win, unsigned char *tag, unsigned char *item, int choice, int selected, dialogMenuItem *me, int menu_width, int tag_x, int item_x);
-
-#define DREF(di, item) ((di) ? &((di)[(item)]) : NULL)
-
-/*
- * Display a menu for choosing among a number of options
- */
-int
-dialog_menu(unsigned char *title, unsigned char *prompt, int height, int width, int menu_height, int cnt, void *it, unsigned char *result, int *ch, int *sc)
-{
- int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button, choice,
- l, k, scroll, max_choice, item_no, redraw_menu = FALSE;
- char okButton, cancelButton;
- int rval = 0;
- WINDOW *dialog, *menu;
- unsigned char **items = NULL;
- dialogMenuItem *ditems;
- int menu_width, tag_x, item_x;
-
-draw:
- choice = ch ? *ch : 0;
- scroll = sc ? *sc : 0;
- button = 0;
-
- /* If item_no is a positive integer, use old item specification format */
- if (cnt >= 0) {
- items = it;
- ditems = NULL;
- item_no = cnt;
- }
- /* It's the new specification format - fake the rest of the code out */
- else {
- item_no = abs(cnt);
- ditems = it;
- if (!items)
- items = (unsigned char **)alloca((item_no * 2) * sizeof(unsigned char *));
-
- /* Initializes status */
- for (i = 0; i < item_no; i++) {
- items[i*2] = ditems[i].prompt;
- items[i*2 + 1] = ditems[i].title;
- }
- }
- max_choice = MIN(menu_height, item_no);
-
- tag_x = 0;
- item_x = 0;
- /* Find length of longest item in order to center menu */
- for (i = 0; i < item_no; i++) {
- l = strlen(items[i * 2]);
- for (j = 0; j < item_no; j++) {
- k = strlen(items[j * 2 + 1]);
- tag_x = MAX(tag_x, l + k + 2);
- }
- item_x = MAX(item_x, l);
- }
- if (height < 0)
- height = strheight(prompt) + menu_height + 4 + 2;
- if (width < 0) {
- i = strwidth(prompt);
- j = ((title != NULL) ? strwidth(title) : 0);
- width = MAX(i, j);
- width = MAX(width, tag_x + 4) + 4;
- }
- width = MAX(width, 24);
-
- if (width > COLS)
- width = COLS;
- if (height > LINES)
- height = LINES;
- /* center dialog box on screen */
- x = DialogX ? DialogX : (COLS - width) / 2;
- y = DialogY ? DialogY : (LINES - height) / 2;
-
-#ifdef HAVE_NCURSES
- if (use_shadow)
- draw_shadow(stdscr, y, x, height, width);
-#endif
- dialog = newwin(height, width, y, x);
- if (dialog == NULL) {
- endwin();
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height, width, y, x);
- return -1;
- }
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
- wattrset(dialog, border_attr);
- wmove(dialog, height - 3, 0);
- waddch(dialog, ACS_LTEE);
- for (i = 0; i < width - 2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dialog_attr);
- waddch(dialog, ACS_RTEE);
- wmove(dialog, height - 2, 1);
- for (i = 0; i < width - 2; i++)
- waddch(dialog, ' ');
-
- if (title != NULL) {
- wattrset(dialog, title_attr);
- wmove(dialog, 0, (width - strlen(title)) / 2 - 1);
- waddch(dialog, ' ');
- waddstr(dialog, title);
- waddch(dialog, ' ');
- }
- wattrset(dialog, dialog_attr);
- wmove(dialog, 1, 2);
- print_autowrap(dialog, prompt, height - 1, width - 2, width, 1, 2, TRUE, FALSE);
-
- menu_width = width - 6;
- getyx(dialog, cur_y, cur_x);
- box_y = cur_y + 1;
- box_x = (width - menu_width) / 2 - 1;
-
- /* create new window for the menu */
- menu = subwin(dialog, menu_height, menu_width, y + box_y + 1, x + box_x + 1);
- if (menu == NULL) {
- delwin(dialog);
- endwin();
- fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", menu_height, menu_width,
- y + box_y + 1, x + box_x + 1);
- return -1;
- }
- keypad(menu, TRUE);
-
- /* draw a box around the menu items */
- draw_box(dialog, box_y, box_x, menu_height+2, menu_width+2, menubox_border_attr, menubox_attr);
-
- tag_x = menu_width > tag_x + 1 ? (menu_width - tag_x) / 2 : 1;
- item_x = menu_width > item_x + 4 ? tag_x + item_x + 2 : menu_width - 3;
-
- /* Print the menu */
- for (i = 0; i < max_choice; i++)
- print_item(menu, items[(scroll + i) * 2], items[(scroll + i) * 2 + 1], i, i == choice, DREF(ditems, scroll + i), menu_width, tag_x, item_x);
- wnoutrefresh(menu);
- print_arrows(dialog, scroll, menu_height, item_no, box_x, box_y, tag_x, cur_x, cur_y);
-
- display_helpline(dialog, height - 1, width);
-
- x = width / 2 - 11;
- y = height - 2;
-
- if (ditems && result) {
- cancelButton = toupper(ditems[CANCEL_BUTTON].prompt[0]);
- print_button(dialog, ditems[CANCEL_BUTTON].prompt, y, x + strlen(ditems[OK_BUTTON].prompt) + 5,
- ditems[CANCEL_BUTTON].checked ? ditems[CANCEL_BUTTON].checked(&ditems[CANCEL_BUTTON]) : FALSE);
- okButton = toupper(ditems[OK_BUTTON].prompt[0]);
- print_button(dialog, ditems[OK_BUTTON].prompt, y, x,
- ditems[OK_BUTTON].checked ? ditems[OK_BUTTON].checked(&ditems[OK_BUTTON]) : TRUE);
- }
- else {
- cancelButton = 'C';
- print_button(dialog, "Cancel", y, x + 14, FALSE);
- okButton = 'O';
- print_button(dialog, " OK ", y, x, TRUE);
- }
-
- wrefresh(dialog);
- while (key != ESC) {
- key = wgetch(dialog);
-
- /* Shortcut to OK? */
- if (toupper(key) == okButton) {
- if (ditems) {
- if (result && ditems[OK_BUTTON].fire) {
- int status;
- WINDOW *save;
-
- save = dupwin(newscr);
- status = ditems[OK_BUTTON].fire(&ditems[OK_BUTTON]);
- if (status & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- }
- delwin(save);
- }
- }
- else if (result)
- strcpy(result, items[(scroll + choice) * 2]);
- rval = 0;
- key = ESC; /* Punt! */
- break;
- }
-
- /* Shortcut to cancel? */
- if (toupper(key) == cancelButton) {
- if (ditems && result && ditems[CANCEL_BUTTON].fire) {
- int status;
- WINDOW *save;
-
- save = dupwin(newscr);
- status = ditems[CANCEL_BUTTON].fire(&ditems[CANCEL_BUTTON]);
- if (status & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- }
- delwin(save);
- }
- rval = 1;
- key = ESC; /* Run away! */
- break;
- }
-
- /* Check if key pressed matches first character of any item tag in menu */
- for (i = 0; i < max_choice; i++)
- if (key < 0x100 && toupper(key) == toupper(items[(scroll + i) * 2][0]))
- break;
-
- if (i < max_choice || (key >= '1' && key <= MIN('9', '0'+max_choice)) || KEY_IS_UP(key) || KEY_IS_DOWN(key)) {
- if (key >= '1' && key <= MIN('9', '0'+max_choice))
- i = key - '1';
- else if (KEY_IS_UP(key)) {
- if (!choice) {
- if (scroll) {
- /* Scroll menu down */
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- if (menu_height > 1) {
- /* De-highlight current first item before scrolling down */
- print_item(menu, items[scroll * 2], items[scroll * 2 + 1], 0, FALSE, DREF(ditems, scroll), menu_width, tag_x, item_x);
- scrollok(menu, TRUE);
- wscrl(menu, -1);
- scrollok(menu, FALSE);
- }
- scroll--;
- print_item(menu, items[scroll * 2], items[scroll * 2 + 1], 0, TRUE, DREF(ditems, scroll), menu_width, tag_x, item_x);
- wnoutrefresh(menu);
- print_arrows(dialog, scroll, menu_height, item_no, box_x, box_y, tag_x, cur_x, cur_y);
- wrefresh(dialog);
- }
- continue; /* wait for another key press */
- }
- else
- i = choice - 1;
- }
- else if (KEY_IS_DOWN(key))
- if (choice == max_choice - 1) {
- if (scroll + choice < item_no - 1) {
- /* Scroll menu up */
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- if (menu_height > 1) {
- /* De-highlight current last item before scrolling up */
- print_item(menu, items[(scroll + max_choice - 1) * 2],
- items[(scroll + max_choice - 1) * 2 + 1],
- max_choice-1, FALSE, DREF(ditems, scroll + max_choice - 1), menu_width, tag_x, item_x);
- scrollok(menu, TRUE);
- scroll(menu);
- scrollok(menu, FALSE);
- }
- scroll++;
- print_item(menu, items[(scroll + max_choice - 1) * 2],
- items[(scroll + max_choice - 1) * 2 + 1],
- max_choice - 1, TRUE, DREF(ditems, scroll + max_choice - 1), menu_width, tag_x, item_x);
- wnoutrefresh(menu);
- print_arrows(dialog, scroll, menu_height, item_no, box_x, box_y, tag_x, cur_x, cur_y);
- wrefresh(dialog);
- }
- continue; /* wait for another key press */
- }
- else
- i = choice + 1;
-
- if (i != choice) {
- /* De-highlight current item */
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- print_item(menu, items[(scroll + choice) * 2], items[(scroll + choice) * 2 + 1], choice, FALSE, DREF(ditems, scroll + choice), menu_width, tag_x, item_x);
-
- /* Highlight new item */
- choice = i;
- print_item(menu, items[(scroll + choice) * 2], items[(scroll + choice) * 2 + 1], choice, TRUE, DREF(ditems, scroll + choice), menu_width, tag_x, item_x);
- wnoutrefresh(menu);
- wmove(dialog, cur_y, cur_x); /* Restore cursor to previous position */
- wrefresh(dialog);
- }
- continue; /* wait for another key press */
- }
-
- switch (key) {
- case KEY_PPAGE:
- if (scroll > height - 4) { /* can we go up? */
- scroll -= (height - 4);
- } else {
- scroll = 0;
- }
- redraw_menu = TRUE;
- break;
-
- case KEY_NPAGE:
- if (scroll + menu_height >= item_no-1 - menu_height) { /* can we go down a full page? */
- scroll = item_no - menu_height;
- if (scroll < 0)
- scroll = 0;
- } else {
- scroll += menu_height;
- }
- redraw_menu = TRUE;
- break;
-
- case KEY_HOME:
- scroll = 0;
- choice = 0;
- redraw_menu = TRUE;
- break;
-
- case KEY_END:
- scroll = item_no - menu_height;
- if (scroll < 0)
- scroll = 0;
- choice = max_choice - 1;
- redraw_menu = TRUE;
- break;
-
- case KEY_BTAB:
- case TAB:
- case KEY_LEFT:
- case KEY_RIGHT:
- button = !button;
- if (ditems && result) {
- print_button(dialog, ditems[CANCEL_BUTTON].prompt, y, x + strlen(ditems[OK_BUTTON].prompt) + 5,
- ditems[CANCEL_BUTTON].checked ? ditems[CANCEL_BUTTON].checked(&ditems[CANCEL_BUTTON]) : button);
- print_button(dialog, ditems[OK_BUTTON].prompt, y, x,
- ditems[OK_BUTTON].checked ? ditems[OK_BUTTON].checked(&ditems[OK_BUTTON]) : !button);
- }
- else {
- print_button(dialog, "Cancel", y, x + 14, button);
- print_button(dialog, " OK ", y, x, !button);
- }
- wrefresh(dialog);
- break;
-
- case ' ':
- case '\r':
- case '\n':
- if (!button) {
- /* A fire routine can do just about anything to the screen, so be prepared
- to accept some hints as to what to do in the aftermath. */
- if (ditems) {
- if (ditems[scroll + choice].fire) {
- int status;
- WINDOW *save;
-
- save = dupwin(newscr);
- status = ditems[scroll + choice].fire(&ditems[scroll + choice]);
- if (status & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- }
- delwin(save);
- if (status & DITEM_CONTINUE)
- continue;
- else if (status & DITEM_LEAVE_MENU) {
- /* Allow a fire action to take us out of the menu */
- key = ESC;
- break;
- }
- else if (status & DITEM_RECREATE) {
- delwin(menu);
- delwin(dialog);
- dialog_clear();
- goto draw;
- }
- }
- }
- else if (result)
- strcpy(result, items[(scroll+choice)*2]);
- }
- rval = button;
- key = ESC;
- break;
-
- case ESC:
- rval = -1;
- break;
-
- case KEY_F(1):
- case '?':
- display_helpfile();
- break;
- }
-
- /* save info about menu item position */
- if (ch)
- *ch = choice;
- if (sc)
- *sc = scroll;
-
- if (redraw_menu) {
- for (i = 0; i < max_choice; i++) {
- print_item(menu, items[(scroll + i) * 2], items[(scroll + i) * 2 + 1], i, i == choice, DREF(ditems, scroll + i), menu_width, tag_x, item_x);
- }
- wnoutrefresh(menu);
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- print_arrows(dialog, scroll, menu_height, item_no, box_x, box_y, tag_x, cur_x, cur_y);
- wmove(dialog, cur_y, cur_x); /* Restore cursor to previous position */
- wrefresh(dialog);
- redraw_menu = FALSE;
- }
- }
- delwin(menu);
- delwin(dialog);
- return rval;
-}
-
-
-/*
- * Print menu item
- */
-static void
-print_item(WINDOW *win, unsigned char *tag, unsigned char *item, int choice, int selected, dialogMenuItem *me, int menu_width, int tag_x, int item_x)
-{
- int i;
-
- /* Clear 'residue' of last item */
- wattrset(win, menubox_attr);
- wmove(win, choice, 0);
- for (i = 0; i < menu_width; i++)
- waddch(win, ' ');
- wmove(win, choice, tag_x);
- wattrset(win, selected ? tag_key_selected_attr : tag_key_attr);
- waddch(win, tag[0]);
- wattrset(win, selected ? tag_selected_attr : tag_attr);
- waddnstr(win, tag + 1, item_x - tag_x - 3);
- wmove(win, choice, item_x);
- wattrset(win, selected ? item_selected_attr : item_attr);
- waddnstr(win, item, menu_width - item_x - 1);
- /* If have a selection handler for this, call it */
- if (me && me->selected) {
- wrefresh(win);
- me->selected(me, selected);
- }
-}
-/* End of print_item() */
diff --git a/gnu/lib/libdialog/msgbox.c b/gnu/lib/libdialog/msgbox.c
deleted file mode 100644
index a544652..0000000
--- a/gnu/lib/libdialog/msgbox.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * msgbox.c -- implements the message box and info box
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- */
-
-
-#include <dialog.h>
-#include "dialog.priv.h"
-
-
-/* local prototypes */
-static int getnlines(unsigned char *buf);
-static void print_page(WINDOW *win, int height, int width, unsigned char *buf, int startline, int hscroll);
-static void print_perc(WINDOW *win, int y, int x, float p);
-
-
-/*
- * Display a message box. Program will pause and display an "OK" button
- * if the parameter 'pause' is non-zero.
- */
-int dialog_msgbox(unsigned char *title, unsigned char *prompt, int height, int width, int pause)
-{
- int i, j, x, y, key = 0;
- WINDOW *dialog;
-
- if (height < 0)
- height = strheight(prompt)+2+2*(!!pause);
- if (width < 0) {
- i = strwidth(prompt);
- j = ((title != NULL) ? strwidth(title) : 0);
- width = MAX(i,j)+4;
- }
- if (pause)
- width = MAX(width,10);
-
- if (width > COLS)
- width = COLS;
- if (height > LINES)
- height = LINES;
- /* center dialog box on screen */
- x = DialogX ? DialogX : (COLS - width)/2;
- y = DialogY ? DialogY : (LINES - height)/2;
-
-#ifdef HAVE_NCURSES
- if (use_shadow)
- draw_shadow(stdscr, y, x, height, width);
-#endif
- dialog = newwin(height, width, y, x);
- if (dialog == NULL) {
- endwin();
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
- exit(1);
- }
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
-
- if (title != NULL) {
- wattrset(dialog, title_attr);
- wmove(dialog, 0, (width - strlen(title))/2 - 1);
- waddch(dialog, ' ');
- waddstr(dialog, title);
- waddch(dialog, ' ');
- }
- wattrset(dialog, dialog_attr);
- wmove(dialog, 1, 2);
- print_autowrap(dialog, prompt, height-1, width-2, width, 1, 2, TRUE, FALSE);
-
- if (pause) {
- wattrset(dialog, border_attr);
- wmove(dialog, height-3, 0);
- waddch(dialog, ACS_LTEE);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dialog_attr);
- waddch(dialog, ACS_RTEE);
- wmove(dialog, height-2, 1);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ' ');
- display_helpline(dialog, height-1, width);
- print_button(dialog, " OK ", height-2, width/2-6, TRUE);
- wrefresh(dialog);
- while (key != ESC && key != '\n' && key != ' ' && key != '\r')
- key = wgetch(dialog);
- if (key == '\r')
- key = '\n';
- }
- else {
- key = '\n';
- wrefresh(dialog);
- }
-
- delwin(dialog);
- return (key == ESC ? -1 : 0);
-}
-/* End of dialog_msgbox() */
-
-int
-dialog_mesgbox(unsigned char *title, unsigned char *prompt, int height, int width)
-/*
- * Desc: basically the same as dialog_msgbox, but ... can use PGUP, PGDN and
- * arrowkeys to move around the text and pause is always enabled
- */
-{
- int i, j, x, y, key=0;
- int theight, startline, hscroll, max_lines;
- WINDOW *dialog;
-
- if (height < 0)
- height = strheight(prompt)+2+2;
- if (width < 0) {
- i = strwidth(prompt);
- j = ((title != NULL) ? strwidth(title) : 0);
- width = MAX(i,j)+4;
- }
- width = MAX(width,10);
-
- if (width > COLS)
- width = COLS;
- if (height > LINES)
- height = LINES;
- /* center dialog box on screen */
- x = (COLS - width)/2;
- y = (LINES - height)/2;
-
-#ifdef HAVE_NCURSES
- if (use_shadow)
- draw_shadow(stdscr, y, x, height, width);
-#endif
- dialog = newwin(height, width, y, x);
- if (dialog == NULL) {
- endwin();
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
- exit(1);
- }
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
-
- if (title != NULL) {
- wattrset(dialog, title_attr);
- wmove(dialog, 0, (width - strlen(title))/2 - 1);
- waddch(dialog, ' ');
- waddstr(dialog, title);
- waddch(dialog, ' ');
- }
-
- wattrset(dialog, border_attr);
- wmove(dialog, height-3, 0);
- waddch(dialog, ACS_LTEE);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dialog_attr);
- waddch(dialog, ACS_RTEE);
- wmove(dialog, height-2, 1);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ' ');
- display_helpline(dialog, height-1, width);
- print_button(dialog, " OK ", height-2, width/2-6, TRUE);
- wattrset(dialog, dialog_attr);
-
- theight = height - 4;
- startline = 0;
- hscroll = 0;
- max_lines = getnlines(prompt);
- print_page(dialog, theight, width, prompt, startline, hscroll);
- print_perc(dialog, height-3, width-9, (float) (startline+theight)/max_lines);
- wmove(dialog, height-2, width/2-3);
- wrefresh(dialog);
- while ((key != ESC) && (key != '\n') && (key != '\r')) {
- key = wgetch(dialog);
- switch(key) {
- case KEY_HOME:
- startline=0;
- hscroll=0;
- break;
- case KEY_END:
- startline = max_lines - theight;
- if (startline < 0) startline = 0;
- break;
- case '\020': /* ^P */
- case KEY_UP:
- if (startline > 0) startline--;
- break;
- case '\016': /* ^N */
- case KEY_DOWN:
- if (startline < max_lines - theight) startline++;
- break;
- case KEY_RIGHT:
- hscroll+=5;
- break;
- case KEY_LEFT:
- if (hscroll > 0) hscroll-=5;
- if (hscroll < 0) hscroll =0;
- break;
- case KEY_PPAGE:
- if (startline - height > 0) {
- startline -= theight;
- } else {
- startline = 0;
- }
- break;
- case KEY_NPAGE:
- if (startline + theight < max_lines - theight) {
- startline += theight;
- } else {
- startline = max_lines - theight;
- if (startline < 0) startline = 0;
- }
- break;
- case KEY_F(1):
- case '?':
- display_helpfile();
- break;
- }
- print_page(dialog, theight, width, prompt, startline, hscroll);
- print_perc(dialog, height-3, width-9, (float) (startline+theight)/max_lines);
- wmove(dialog, height-2, width/2-3);
- wrefresh(dialog);
- }
-
- delwin(dialog);
- return (key == ESC ? -1 : 0);
-
-} /* dialog_mesgbox() */
-
-static void
-print_perc(WINDOW *win, int y, int x, float p)
-/*
- * Desc: print p as a percentage at the coordinates (y,x)
- */
-{
- char ps[10];
-
- if (p>1.0) p=1.0;
- sprintf(ps, "(%3d%%)", (int) (p*100));
- wmove(win, y, x);
- waddstr(win, ps);
-
- return;
-} /* print_perc() */
-
-static int
-getnlines(unsigned char *buf)
-/*
- * Desc: count the # of lines in <buf>
- */
-{
- int i = 0;
-
- if (*buf)
- i++;
- while (*buf) {
- if (*buf == '\n' || *buf == '\r')
- i++;
- buf++;
- }
- return(i);
-} /* getlines() */
-
-
-unsigned char *
-getline(unsigned char *buf, int n)
-/*
- * Desc: return a pointer to the n'th line in <buf> or NULL if its
- * not there
- */
-{
- int i;
-
- if (n<0) {
- return(NULL);
- }
-
- i=0;
- while (*buf && i<n) {
- if (*buf == '\n' || *buf == '\r') {
- i++;
- }
- buf++;
- }
- if (i<n) {
- return(NULL);
- } else {
- return(buf);
- }
-} /* getline() */
-
-static void
-print_page(WINDOW *win, int height, int width, unsigned char *buf, int startline, int hscroll)
-/*
- * Desc: Print a page of text in the current window, starting at line <startline>
- * with a <horizontal> scroll of hscroll from buffer <buf>
- */
-{
- int i, j;
- unsigned char *b;
-
- b = getline(buf, startline);
- for (i=0; i<height; i++) {
- /* clear line */
- wmove(win, 1+i, 1);
- for (j=0; j<width-2; j++) waddnstr(win, " ", 1);
- wmove(win, 1+i, 1);
- j = 0;
- /* scroll to the right */
- while (*b && (*b != '\n') && (*b != '\r') && (j<hscroll)) {
- b++;
- j++;
- }
- /* print new line */
- j = 0;
- while (*b && (*b != '\n') && (*b != '\r') && (j<width-2)) {
- waddnstr(win, b, 1);
- if (*b != '\t') { /* check for tabs */
- j++;
- } else {
- j = ((int) (j+1)/8 + 1) * 8 - 1;
- }
- b++;
- }
- while (*b && (*b != '\n') && (*b != '\r')) b++;
- if (*b) b++; /* skip over '\n', if it exists */
- }
-} /* print_page() */
-
-
-
-
diff --git a/gnu/lib/libdialog/notify.c b/gnu/lib/libdialog/notify.c
deleted file mode 100644
index 052ee8f..0000000
--- a/gnu/lib/libdialog/notify.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * File: notify.c
- * Author: Marc van Kempen
- * Desc: display a notify box with a message
- *
- * Copyright (c) 1995, Marc van Kempen
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- */
-
-
-#include <dialog.h>
-#include <stdio.h>
-
-void
-dialog_notify(char *msg)
-/*
- * Desc: display an error message
- */
-{
- char *tmphlp;
- WINDOW *w;
-
- w = dupwin(newscr);
- if (w == NULL) {
- endwin();
- fprintf(stderr, "\ndupwin(newscr) failed, malloc memory corrupted\n");
- exit(1);
- }
- tmphlp = get_helpline();
- use_helpline("Press enter to continue");
- dialog_mesgbox("Message", msg, -1, -1);
- restore_helpline(tmphlp);
- touchwin(w);
- wrefresh(w);
- delwin(w);
-
- return;
-
-} /* dialog_notify() */
-
diff --git a/gnu/lib/libdialog/prgbox.c b/gnu/lib/libdialog/prgbox.c
deleted file mode 100644
index 80f6ff5..0000000
--- a/gnu/lib/libdialog/prgbox.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * prgbox.c -- implements the message box and info box
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- */
-
-
-#include <dialog.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include "dialog.priv.h"
-
-/*
- * Display a message box. Program will pause and display an "OK" button
- * if the parameter 'pause' is non-zero.
- */
-int dialog_prgbox(unsigned char *title, const unsigned char *line, int height, int width, int pause, int use_shell)
-{
- int i, x, y, key = 0;
- WINDOW *dialog;
- FILE *f;
- const unsigned char *name;
- unsigned char *s, buf[MAX_LEN];
- int status;
-
- if (height < 0 || width < 0) {
- endwin();
- fprintf(stderr, "\nAutosizing is impossible in dialog_prgbox().\n");
- exit(-1);
- }
- width = MAX(width,10);
-
- if (width > COLS)
- width = COLS;
- if (height > LINES)
- height = LINES;
- /* center dialog box on screen */
- x = DialogX ? DialogX : (COLS - width)/2;
- y = DialogY ? DialogY : (LINES - height)/2;
-
-#ifdef HAVE_NCURSES
- if (use_shadow)
- draw_shadow(stdscr, y, x, height, width);
-#endif
- dialog = newwin(height, width, y, x);
- if (dialog == NULL) {
- endwin();
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
- exit(1);
- }
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
-
- if (title != NULL) {
- wattrset(dialog, title_attr);
- wmove(dialog, 0, (width - strlen(title))/2 - 1);
- waddch(dialog, ' ');
- waddstr(dialog, title);
- waddch(dialog, ' ');
- }
- wattrset(dialog, dialog_attr);
- wmove(dialog, 1, 2);
-
- if (!use_shell) {
- char cmdline[MAX_LEN];
- char *av[51], **ap = av, *val, *p;
-
- strcpy(cmdline, line);
- p = cmdline;
- while ((val = strsep(&p," \t")) != NULL) {
- if (*val != '\0')
- *ap++ = val;
- }
- *ap = NULL;
- f = raw_popen(name = av[0], av, "r");
- } else
- f = raw_popen(name = line, NULL, "r");
-
- status = -1;
- if (f == NULL) {
- err:
- sprintf(buf, "%s: %s\n", name, strerror(errno));
- prr:
- print_autowrap(dialog, buf, height-(pause?3:1), width-2, width, 1, 2, FALSE, TRUE);
- wrefresh(dialog);
- } else {
- while (fgets(buf, sizeof(buf), f) != NULL) {
- i = strlen(buf);
- if (buf[i-1] == '\n')
- buf[i-1] = '\0';
- s = buf;
- while ((s = strchr(s, '\t')) != NULL)
- *s++ = ' ';
- print_autowrap(dialog, buf, height-(pause?3:1), width-2, width, 1, 2, FALSE, TRUE);
- print_autowrap(dialog, "\n", height-(pause?3:1), width-2, width, 1, 2, FALSE, FALSE);
- wrefresh(dialog);
- }
- if ((status = raw_pclose(f)) == -1)
- goto err;
- if (WIFEXITED(status) && WEXITSTATUS(status) == 127) {
- sprintf(buf, "%s: program not found\n", name);
- goto prr;
- }
- }
-
- if (pause) {
- wattrset(dialog, border_attr);
- wmove(dialog, height-3, 0);
- waddch(dialog, ACS_LTEE);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dialog_attr);
- waddch(dialog, ACS_RTEE);
- wmove(dialog, height-2, 1);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ' ');
- display_helpline(dialog, height-1, width);
- print_button(dialog, " OK ", height-2, width/2-6, TRUE);
- wrefresh(dialog);
- while (key != ESC && key != '\n' && key != ' ' && key != '\r')
- key = wgetch(dialog);
- if (key == '\r')
- key = '\n';
- }
- else {
- key = '\n';
- wrefresh(dialog);
- }
-
- delwin(dialog);
- return (status);
-}
-/* End of dialog_msgbox() */
diff --git a/gnu/lib/libdialog/radiolist.c b/gnu/lib/libdialog/radiolist.c
deleted file mode 100644
index f894e92..0000000
--- a/gnu/lib/libdialog/radiolist.c
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * radiolist.c -- implements the radiolist box
- *
- * AUTHOR: Stuart Herbert - S.Herbert@sheffield.ac.uk
- * (from checklist.c by Savio Lam (lam836@cs.cuhk.hk))
- *
- * Substantial rennovation: 12/18/95, Jordan K. Hubbard
- *
- * 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
- * of the License, 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.
- */
-
-
-#include <dialog.h>
-#include "dialog.priv.h"
-
-
-static void print_item(WINDOW *win, char *tag, char *item, int status, int choice, int selected, dialogMenuItem *me);
-
-#define DREF(di, item) ((di) ? &((di)[(item)]) : NULL)
-
-static int list_width, check_x, item_x;
-
-
-/*
- * Display a dialog box with a list of options that can be turned on or off
- */
-int
-dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int width, int list_height,
- int cnt, void *it, unsigned char *result)
-{
- int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button, choice,
- l, k, scroll, max_choice, *status, item_no = 0, was_on = 0;
- int redraw_menu = FALSE;
- int rval = 0;
- char okButton, cancelButton;
- WINDOW *dialog, *list;
- unsigned char **items = NULL;
- dialogMenuItem *ditems;
-
- /* Allocate space for storing item on/off status */
- if ((status = alloca(sizeof(int) * abs(cnt))) == NULL) {
- endwin();
- fprintf(stderr, "\nCan't allocate memory in dialog_radiolist().\n");
- exit(-1);
- }
-
-draw:
- button = choice = scroll = 0;
- /* Previous calling syntax, e.g. just a list of strings? */
- if (cnt >= 0) {
- items = it;
- ditems = NULL;
- item_no = cnt;
- /* Initializes status */
- for (i = 0; i < item_no; i++) {
- status[i] = !strcasecmp(items[i*3 + 2], "on");
- if (status[i]) {
- if (was_on)
- status[i] = FALSE;
- else
- was_on = 1;
- }
- }
- }
- /* It's the new specification format - fake the rest of the code out */
- else {
- item_no = abs(cnt);
- ditems = it;
- if (!items)
- items = (unsigned char **)alloca((item_no * 3) * sizeof(unsigned char *));
- /* Initializes status */
- for (i = 0; i < item_no; i++) {
- status[i] = ditems[i].checked ? ditems[i].checked(&ditems[i]) : FALSE;
- if (status[i]) {
- if (was_on)
- status[i] = FALSE;
- else
- was_on = 1;
- }
- items[i*3] = ditems[i].prompt;
- items[i*3 + 1] = ditems[i].title;
- items[i*3 + 2] = status[i] ? "on" : "off";
- }
- }
- max_choice = MIN(list_height, item_no);
-
- check_x = 0;
- item_x = 0;
- /* Find length of longest item in order to center radiolist */
- for (i = 0; i < item_no; i++) {
- l = strlen(items[i * 3]);
- for (j = 0; j < item_no; j++) {
- k = strlen(items[j * 3 + 1]);
- check_x = MAX(check_x, l + k + 6);
- }
- item_x = MAX(item_x, l);
- }
- if (height < 0)
- height = strheight(prompt) + list_height + 4 + 2;
- if (width < 0) {
- i = strwidth(prompt);
- j = ((title != NULL) ? strwidth(title) : 0);
- width = MAX(i, j);
- width = MAX(width, check_x + 4) + 4;
- }
- width = MAX(width, 24);
-
- if (width > COLS)
- width = COLS;
- if (height > LINES)
- height = LINES;
- /* center dialog box on screen */
- x = DialogX ? DialogX : (COLS - width) / 2;
- y = DialogY ? DialogY : (LINES - height) / 2;
-
-#ifdef HAVE_NCURSES
- if (use_shadow)
- draw_shadow(stdscr, y, x, height, width);
-#endif
- dialog = newwin(height, width, y, x);
- if (dialog == NULL) {
- endwin();
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height, width, y, x);
- return -1;
- }
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
- wattrset(dialog, border_attr);
- wmove(dialog, height - 3, 0);
- waddch(dialog, ACS_LTEE);
- for (i = 0; i < width - 2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dialog_attr);
- waddch(dialog, ACS_RTEE);
- wmove(dialog, height - 2, 1);
- for (i = 0; i < width - 2; i++)
- waddch(dialog, ' ');
-
- if (title != NULL) {
- wattrset(dialog, title_attr);
- wmove(dialog, 0, (width - strlen(title)) / 2 - 1);
- waddch(dialog, ' ');
- waddstr(dialog, title);
- waddch(dialog, ' ');
- }
- wattrset(dialog, dialog_attr);
- wmove(dialog, 1, 2);
- print_autowrap(dialog, prompt, height - 1, width - 2, width, 1, 2, TRUE, FALSE);
-
- list_width = width - 6;
- getyx(dialog, cur_y, cur_x);
- box_y = cur_y + 1;
- box_x = (width - list_width) / 2 - 1;
-
- /* create new window for the list */
- list = subwin(dialog, list_height, list_width, y + box_y + 1, x + box_x + 1);
- if (list == NULL) {
- delwin(dialog);
- endwin();
- fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", list_height, list_width,
- y + box_y + 1,x + box_x + 1);
- return -1;
- }
- keypad(list, TRUE);
-
- /* draw a box around the list items */
- draw_box(dialog, box_y, box_x, list_height+2, list_width+2, menubox_border_attr, menubox_attr);
-
- check_x = (list_width - check_x) / 2;
- item_x = check_x + item_x + 6;
-
- /* Print the list */
- for (i = 0; i < max_choice; i++)
- print_item(list, items[i * 3], items[i * 3 + 1], status[i], i, i == choice, DREF(ditems, i));
- wnoutrefresh(list);
- print_arrows(dialog, scroll, list_height, item_no, box_x, box_y, check_x + 4, cur_x, cur_y);
-
- display_helpline(dialog, height-1, width);
-
- x = width/ 2 - 11;
- y = height - 2;
- if (ditems && result) {
- cancelButton = toupper(ditems[CANCEL_BUTTON].prompt[0]);
- print_button(dialog, ditems[CANCEL_BUTTON].prompt, y, x + strlen(ditems[OK_BUTTON].prompt) + 5,
- ditems[CANCEL_BUTTON].checked ? ditems[CANCEL_BUTTON].checked(&ditems[CANCEL_BUTTON]) : FALSE);
- okButton = toupper(ditems[OK_BUTTON].prompt[0]);
- print_button(dialog, ditems[OK_BUTTON].prompt, y, x,
- ditems[OK_BUTTON].checked ? ditems[OK_BUTTON].checked(&ditems[OK_BUTTON]) : TRUE);
- }
- else {
- cancelButton = 'C';
- print_button(dialog, "Cancel", y, x + 14, FALSE);
- okButton = 'O';
- print_button(dialog, " OK ", y, x, TRUE);
- }
-
- wrefresh(dialog);
- while (key != ESC) {
- key = wgetch(dialog);
-
- /* See if its the short-cut to "OK" */
- if (toupper(key) == okButton) {
- if (ditems) {
- if (result && ditems[OK_BUTTON].fire) {
- int st;
- WINDOW *save;
-
- save = dupwin(newscr);
- st = ditems[OK_BUTTON].fire(&ditems[OK_BUTTON]);
- if (st & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- }
- delwin(save);
- }
- }
- else if (result) {
- *result = '\0';
- for (i = 0; i < item_no; i++) {
- if (status[i]) {
- strcat(result, items[i*3]);
- break;
- }
- }
- }
- rval = 0;
- key = ESC;
- break;
- }
-
- /* Shortcut to cancel */
- if (toupper(key) == cancelButton) {
- if (ditems && result && ditems[CANCEL_BUTTON].fire) {
- int st;
- WINDOW *save;
-
- save = dupwin(newscr);
- st = ditems[CANCEL_BUTTON].fire(&ditems[CANCEL_BUTTON]);
- if (st & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- }
- delwin(save);
- }
- rval = 1;
- key = ESC;
- break;
- }
-
- /* Check if key pressed matches first character of any item tag in list */
- for (i = 0; i < max_choice; i++)
- if (toupper(key) == toupper(items[(scroll + i) * 3][0]))
- break;
-
- if (i < max_choice || (key >= '1' && key <= MIN('9', '0' + max_choice)) ||
- KEY_IS_UP(key) || KEY_IS_DOWN(key) || key == ' ') {
- if (key >= '1' && key <= MIN('9', '0' + max_choice))
- i = key - '1';
- else if (KEY_IS_UP(key)) {
- if (!choice) {
- if (scroll) {
- /* Scroll list down */
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- if (list_height > 1) {
- /* De-highlight current first item before scrolling down */
- print_item(list, items[scroll*3], items[scroll*3 + 1], status[scroll], 0,
- FALSE, DREF(ditems, scroll));
- scrollok(list, TRUE);
- wscrl(list, -1);
- scrollok(list, FALSE);
- }
- scroll--;
- print_item(list, items[scroll*3], items[scroll*3 + 1], status[scroll], 0,
- TRUE, DREF(ditems, scroll));
- wnoutrefresh(list);
- print_arrows(dialog, scroll, list_height, item_no, box_x, box_y, check_x + 4, cur_x, cur_y);
- wrefresh(dialog);
- }
- continue; /* wait for another key press */
- }
- else
- i = choice - 1;
- }
- else if (KEY_IS_DOWN(key)) {
- if (choice == max_choice - 1) {
- if (scroll + choice < item_no - 1) {
- /* Scroll list up */
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- if (list_height > 1) {
- /* De-highlight current last item before scrolling up */
- print_item(list, items[(scroll + max_choice - 1) * 3],
- items[(scroll + max_choice - 1) * 3 + 1],
- status[scroll + max_choice - 1], max_choice - 1,
- FALSE, DREF(ditems, scroll + max_choice - 1));
- scrollok(list, TRUE);
- scroll(list);
- scrollok(list, FALSE);
- }
- scroll++;
- print_item(list, items[(scroll + max_choice - 1) * 3],
- items[(scroll + max_choice - 1) * 3 + 1],
- status[scroll + max_choice - 1], max_choice - 1,
- TRUE, DREF(ditems, scroll + max_choice - 1));
- wnoutrefresh(list);
- print_arrows(dialog, scroll, list_height, item_no, box_x, box_y, check_x + 4, cur_x, cur_y);
- wrefresh(dialog);
- }
- continue; /* wait for another key press */
- }
- else
- i = choice + 1;
- }
- else if (key == ' ') { /* Toggle item status */
- if (status[scroll + choice])
- continue;
- else if (ditems) {
- if (ditems[scroll + choice].fire) {
- int st;
- WINDOW *save;
-
- save = dupwin(newscr);
- st = ditems[scroll + choice].fire(&ditems[scroll + choice]);
- if (st & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- }
- delwin(save);
- if (st & DITEM_REDRAW) {
- wclear(list);
- for (i = 0; i < item_no; i++)
- status[i] = ditems[i].checked ? ditems[i].checked(&ditems[i]) : FALSE;
-
- for (i = 0; i < max_choice; i++) {
- print_item(list, items[(scroll + i) * 3], items[(scroll + i) * 3 + 1],
- status[scroll + i], i, i == choice,
- DREF(ditems, scroll + i));
- }
- wnoutrefresh(list);
- wmove(dialog, cur_y, cur_x); /* Restore cursor to previous position */
- wrefresh(dialog);
- }
- if (st & DITEM_LEAVE_MENU) {
- /* Allow a fire action to take us out of the menu */
- key = ESC;
- break;
- }
- else if (st & DITEM_RECREATE) {
- delwin(list);
- delwin(dialog);
- dialog_clear();
- goto draw;
- }
- }
- for (i = 0; i < item_no; i++)
- status[i] = ditems[i].checked ? ditems[i].checked(&ditems[i]) : FALSE;
- }
- else {
- for (i = 0; i < item_no; i++)
- status[i] = 0;
- status[scroll + choice] = TRUE;
- }
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- for (i = 0; i < max_choice; i++)
- print_item(list, items[(scroll + i) * 3], items[(scroll + i) * 3 + 1],
- status[scroll + i], i, i == choice, DREF(ditems, scroll + i));
- wnoutrefresh(list);
- wmove(dialog, cur_y, cur_x); /* Restore cursor to previous position */
- wrefresh(dialog);
- continue; /* wait for another key press */
- }
-
- if (i != choice) {
- /* De-highlight current item */
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
- print_item(list, items[(scroll + choice) * 3], items[(scroll + choice) * 3 +1],
- status[scroll + choice], choice, FALSE, DREF(ditems, scroll + choice));
- /* Highlight new item */
- choice = i;
- print_item(list, items[(scroll + choice) * 3], items[(scroll + choice) * 3 + 1],
- status[scroll + choice], choice, TRUE, DREF(ditems, scroll + choice));
- wnoutrefresh(list);
- wmove(dialog, cur_y, cur_x); /* Restore cursor to previous position */
- wrefresh(dialog);
- }
- continue; /* wait for another key press */
- }
-
- switch (key) {
- case KEY_PPAGE:
- if (scroll > height-4) /* can we go up? */
- scroll -= (height-4);
- else
- scroll = 0;
- redraw_menu = TRUE;
- break;
-
- case KEY_NPAGE:
- if (scroll + list_height >= item_no-1 - list_height) { /* can we go down a full page? */
- scroll = item_no - list_height;
- if (scroll < 0)
- scroll = 0;
- }
- else
- scroll += list_height;
- redraw_menu = TRUE;
- break;
-
- case KEY_HOME:
- scroll = 0;
- choice = 0;
- redraw_menu = TRUE;
- break;
-
- case KEY_END:
- scroll = item_no - list_height;
- if (scroll < 0)
- scroll = 0;
- choice = max_choice - 1;
- redraw_menu = TRUE;
- break;
-
- case KEY_BTAB:
- case TAB:
- case KEY_LEFT:
- case KEY_RIGHT:
- button = !button;
- if (ditems && result) {
- print_button(dialog, ditems[CANCEL_BUTTON].prompt, y, x + strlen(ditems[OK_BUTTON].prompt) + 5,
- ditems[CANCEL_BUTTON].checked ? ditems[CANCEL_BUTTON].checked(&ditems[CANCEL_BUTTON]) : button);
- print_button(dialog, ditems[OK_BUTTON].prompt, y, x,
- ditems[OK_BUTTON].checked ? ditems[OK_BUTTON].checked(&ditems[OK_BUTTON]) : !button);
- }
- else {
- print_button(dialog, "Cancel", y, x + 14, button);
- print_button(dialog, " OK ", y, x, !button);
- }
- wrefresh(dialog);
- break;
-
- case '\r':
- case '\n':
- if (ditems) {
- if (result && ditems[button ? CANCEL_BUTTON : OK_BUTTON].fire) {
- int st;
- WINDOW *save;
-
- save = dupwin(newscr);
- st = ditems[button ? CANCEL_BUTTON : OK_BUTTON].fire(&ditems[button ? CANCEL_BUTTON : OK_BUTTON]);
- if (st & DITEM_RESTORE) {
- touchwin(save);
- wrefresh(save);
- }
- delwin(save);
- }
- }
- else if (result) {
- *result = '\0';
- for (i = 0; i < item_no; i++) {
- if (status[i]) {
- strcpy(result, items[i*3]);
- break;
- }
- }
- }
- rval = button;
- key = ESC;
- break;
-
- case ESC:
- rval = -1;
- break;
-
- case KEY_F(1):
- case '?':
- display_helpfile();
- break;
- }
-
- if (redraw_menu) {
- for (i = 0; i < max_choice; i++)
- print_item(list, items[(scroll + i) * 3], items[(scroll + i) * 3 + 1], status[scroll + i],
- i, i == choice, DREF(ditems, scroll + i));
- wnoutrefresh(list);
- print_arrows(dialog, scroll, list_height, item_no, box_x, box_y, check_x + 4, cur_x, cur_y);
- wrefresh(dialog);
- redraw_menu = FALSE;
- }
- }
-
- delwin(list);
- delwin(dialog);
- return rval; /* ESC pressed */
-}
-
-/*
- * Print list item
- */
-static void
-print_item(WINDOW *win, char *tag, char *item, int status, int choice, int selected, dialogMenuItem *me)
-{
- int i;
-
- /* Clear 'residue' of last item */
- wattrset(win, menubox_attr);
- wmove(win, choice, 0);
- for (i = 0; i < list_width; i++)
- waddch(win, ' ');
- wmove(win, choice, check_x);
- wattrset(win, selected ? check_selected_attr : check_attr);
- wprintw(win, "%c%c%c", me && me->lbra ? me->lbra : '(',
- status ? me && me->mark ? me->mark : '*' : ' ',
- me && me->rbra ? me->rbra : ')');
- wattrset(win, menubox_attr);
- waddch(win, ' ');
- wattrset(win, selected ? tag_key_selected_attr : tag_key_attr);
- waddch(win, tag[0]);
- wattrset(win, selected ? tag_selected_attr : tag_attr);
- waddstr(win, tag + 1);
- wmove(win, choice, item_x);
- wattrset(win, selected ? item_selected_attr : item_attr);
- waddstr(win, item);
- /* If have a selection handler for this, call it */
- if (me && me->selected) {
- wrefresh(win);
- me->selected(me, selected);
- }
-}
-/* End of print_item() */
diff --git a/gnu/lib/libdialog/raw_popen.c b/gnu/lib/libdialog/raw_popen.c
deleted file mode 100644
index fabf91e..0000000
--- a/gnu/lib/libdialog/raw_popen.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software written by Ken Arnold and
- * published in UNIX Review, Vol. 6, No. 8.
- *
- * 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[] = "@(#)popen.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <sys/wait.h>
-
-#include <signal.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <paths.h>
-
-static struct pid {
- struct pid *next;
- FILE *fp;
- pid_t pid;
-} *pidlist;
-
-FILE *
-raw_popen(const char *program, char * const *argv, const char *type)
-{
- struct pid *cur;
- FILE *iop;
- int pdes[2], pid;
-
- if ((*type != 'r' && *type != 'w') || type[1])
- return (NULL);
-
- if ((cur = malloc(sizeof(struct pid))) == NULL)
- return (NULL);
-
- if (pipe(pdes) < 0) {
- (void)free(cur);
- return (NULL);
- }
-
- switch (pid = vfork()) {
- case -1: /* Error. */
- (void)close(pdes[0]);
- (void)close(pdes[1]);
- (void)free(cur);
- return (NULL);
- /* NOTREACHED */
- case 0: /* Child. */
- if (*type == 'r') {
- if (pdes[1] != STDOUT_FILENO) {
- (void)dup2(pdes[1], STDOUT_FILENO);
- (void)close(pdes[1]);
- }
- (void) close(pdes[0]);
- } else {
- if (pdes[0] != STDIN_FILENO) {
- (void)dup2(pdes[0], STDIN_FILENO);
- (void)close(pdes[0]);
- }
- (void)close(pdes[1]);
- }
- if (argv == NULL)
- execl(_PATH_BSHELL, "sh", "-c", program, NULL);
- else
- execvp(program, argv);
- _exit(127);
- /* NOTREACHED */
- }
-
- /* Parent; assume fdopen can't fail. */
- if (*type == 'r') {
- iop = fdopen(pdes[0], type);
- (void)close(pdes[1]);
- } else {
- iop = fdopen(pdes[1], type);
- (void)close(pdes[0]);
- }
-
- /* Link into list of file descriptors. */
- cur->fp = iop;
- cur->pid = pid;
- cur->next = pidlist;
- pidlist = cur;
-
- return (iop);
-}
-
-/*
- * pclose --
- * Pclose returns -1 if stream is not associated with a `popened' command,
- * if already `pclosed', or waitpid returns an error.
- */
-int
-raw_pclose(FILE *iop)
-{
- register struct pid *cur, *last;
- int omask;
- union wait pstat;
- pid_t pid;
-
- (void)fclose(iop);
-
- /* Find the appropriate file pointer. */
- for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
- if (cur->fp == iop)
- break;
- if (cur == NULL)
- return (-1);
-
- /* Get the status of the process. */
- omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
- do {
- pid = waitpid(cur->pid, (int *) &pstat, 0);
- } while (pid == -1 && errno == EINTR);
- (void)sigsetmask(omask);
-
- /* Remove the entry from the linked list. */
- if (last == NULL)
- pidlist = cur->next;
- else
- last->next = cur->next;
- free(cur);
-
- return (pid == -1 ? -1 : pstat.w_status);
-}
diff --git a/gnu/lib/libdialog/rc.c b/gnu/lib/libdialog/rc.c
deleted file mode 100644
index 36631a6..0000000
--- a/gnu/lib/libdialog/rc.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * rc.c -- routines for processing the configuration file
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- */
-
-#include <dialog.h>
-#include "dialog.priv.h"
-#include "colors.h"
-#include "rc.h"
-
-
-static unsigned char *attr_to_str(int fg, int bg, int hl);
-static int str_to_attr(unsigned char *str, int *fg, int *bg, int *hl);
-static int parse_line(unsigned char *line, unsigned char **var, unsigned char **value);
-
-
-/*
- * Create the configuration file
- */
-void dialog_create_rc(unsigned char *filename)
-{
- int i;
- FILE *rc_file;
-
- if ((rc_file = fopen(filename, "wt")) == NULL) {
- fprintf(stderr, "\nError opening file for writing in create_rc().\n");
- exit(-1);
- }
-
- fprintf(rc_file, "#\
-\n# Run-time configuration file for dialog\
-\n#\
-\n# Automatically generated by \"dialog --create-rc <file>\"\
-\n#\
-\n#\
-\n# Types of values:\
-\n#\
-\n# Number - <number>\
-\n# String - \"string\"\
-\n# Boolean - <ON|OFF>\
-\n# Attribute - (foreground,background,highlight?)\
-\n#\n\n");
-
- /* Print an entry for each configuration variable */
- for (i = 0; i < VAR_COUNT; i++) {
- fprintf(rc_file, "\n# %s\n", vars[i].comment); /* print comment */
- switch (vars[i].type) {
- case VAL_INT:
- fprintf(rc_file, "%s = %d\n", vars[i].name, *((int *) vars[i].var));
- break;
- case VAL_STR:
- fprintf(rc_file, "%s = \"%s\"\n", vars[i].name, (unsigned char *) vars[i].var);
- break;
- case VAL_BOOL:
- fprintf(rc_file, "%s = %s\n", vars[i].name, *((bool *) vars[i].var) ? "ON" : "OFF");
- break;
- case VAL_ATTR:
- fprintf(rc_file, "%s = %s\n", vars[i].name, attr_to_str(((int *) vars[i].var)[0], ((int *) vars[i].var)[1], ((int *) vars[i].var)[2]));
- break;
- }
- }
-
- fclose(rc_file);
-}
-/* End of create_rc() */
-
-
-/*
- * Parse the configuration file and set up variables
- */
-int parse_rc(void)
-{
- int i, l = 1, parse, fg, bg, hl;
- unsigned char str[MAX_LEN+1], *var, *value, *tempptr;
- FILE *rc_file;
-
- /*
- *
- * At start, 'dialog' determines the settings to use as follows:
- *
- * a) if environment variable DIALOGRC is set, it's value determines the
- * name of the configuration file.
- *
- * b) if the file in (a) can't be found, use the file $HOME/.dialogrc
- * as the configuration file.
- *
- * c) if the file in (b) can't be found, use compiled in defaults.
- *
- */
-
- if ((tempptr = getenv("DIALOGRC")) != NULL)
- rc_file = fopen(tempptr, "rt");
-
- if (tempptr == NULL || rc_file == NULL) { /* step (a) failed? */
- /* try step (b) */
- if ((tempptr = getenv("HOME")) == NULL)
- return 0; /* step (b) failed, use default values */
-
- if (tempptr[0] == '\0' || lastch(tempptr) == '/')
- sprintf(str, "%s%s", tempptr, DIALOGRC);
- else
- sprintf(str, "%s/%s", tempptr, DIALOGRC);
-
- if ((rc_file = fopen(str, "rt")) == NULL)
- return 0; /* step (b) failed, use default values */
- }
-
- /* Scan each line and set variables */
- while (fgets(str, MAX_LEN, rc_file) != NULL) {
- if (lastch(str) != '\n') { /* ignore rest of file if line too long */
- fprintf(stderr, "\nParse error: line %d of configuration file too long.\n", l);
- fclose(rc_file);
- return -1; /* parse aborted */
- }
- else {
- lastch(str) = '\0';
- parse = parse_line(str, &var, &value); /* parse current line */
-
- switch (parse) {
- case LINE_BLANK: /* ignore blank lines and comments */
- case LINE_COMMENT:
- break;
- case LINE_OK:
- /* search table for matching config variable name */
- for (i = 0; i < VAR_COUNT && strcmp(vars[i].name, var); i++);
-
- if (i == VAR_COUNT) { /* no match */
- fprintf(stderr, "\nParse error: unknown variable at line %d of configuration file.\n", l);
- return -1; /* parse aborted */
- }
- else { /* variable found in table, set run time variables */
- switch (vars[i].type) {
- case VAL_INT:
- *((int *) vars[i].var) = atoi(value);
- break;
- case VAL_STR:
- if (!isquote(value[0]) || !isquote(lastch(value)) || strlen(value) < 2) {
- fprintf(stderr, "\nParse error: string value expected at line %d of configuration file.\n", l);
- return -1; /* parse aborted */
- }
- else {
- /* remove the (") quotes */
- value++;
- lastch(value) = '\0';
- strcpy((unsigned char *) vars[i].var, value);
- }
- break;
- case VAL_BOOL:
- if (!strcasecmp(value, "ON"))
- *((bool *) vars[i].var) = TRUE;
- else if (!strcasecmp(value, "OFF"))
- *((bool *) vars[i].var) = FALSE;
- else {
- fprintf(stderr, "\nParse error: boolean value expected at line %d of configuration file.\n", l);
- return -1; /* parse aborted */
- }
- break;
- case VAL_ATTR:
- if (str_to_attr(value, &fg, &bg, &hl) == -1) {
- fprintf(stderr, "\nParse error: attribute value expected at line %d of configuration file.\n", l);
- return -1; /* parse aborted */
- }
- ((int *) vars[i].var)[0] = fg;
- ((int *) vars[i].var)[1] = bg;
- ((int *) vars[i].var)[2] = hl;
- break;
- }
- }
- break;
- case LINE_ERROR:
- fprintf(stderr, "\nParse error: syntax error at line %d of configuration file.\n", l);
- return -1; /* parse aborted */
- }
- }
-
- l++; /* next line */
- }
-
- fclose(rc_file);
- return 0; /* parse successful */
-}
-/* End of parse_rc() */
-
-
-/*
- * Convert an attribute to a string representation like this:
- *
- * "(foreground,background,highlight)"
- */
-static unsigned char *attr_to_str(int fg, int bg, int hl)
-{
- int i;
- static unsigned char str[MAX_LEN+1];
-
- strcpy(str, "(");
- /* foreground */
- for (i = 0; fg != color_names[i].value; i++);
- strcat(str, color_names[i].name);
- strcat(str, ",");
-
- /* background */
- for (i = 0; bg != color_names[i].value; i++);
- strcat(str, color_names[i].name);
-
- /* highlight */
- strcat(str, hl ? ",ON)" : ",OFF)");
-
- return str;
-}
-/* End of attr_to_str() */
-
-
-/*
- * Extract the foreground, background and highlight values from an attribute
- * represented as a string in this form:
- *
- * "(foreground,background,highlight)"
- */
-static int str_to_attr(unsigned char *str, int *fg, int *bg, int *hl)
-{
- int i = 0, j, get_fg = 1;
- unsigned char tempstr[MAX_LEN+1], *part;
-
- if (str[0] != '(' || lastch(str) != ')')
- return -1; /* invalid representation */
-
- /* remove the parenthesis */
- strcpy(tempstr, str + 1);
- lastch(tempstr) = '\0';
-
-
- /* get foreground and background */
-
- while (1) {
- /* skip white space before fg/bg string */
- while (whitespace(tempstr[i]) && tempstr[i] != '\0') i++;
- if (tempstr[i] == '\0')
- return -1; /* invalid representation */
- part = tempstr + i; /* set 'part' to start of fg/bg string */
-
- /* find end of fg/bg string */
- while(!whitespace(tempstr[i]) && tempstr[i] != ',' && tempstr[i] != '\0') i++;
-
- if (tempstr[i] == '\0')
- return -1; /* invalid representation */
- else if (whitespace(tempstr[i])) { /* not yet ',' */
- tempstr[i++] = '\0';
-
- /* skip white space before ',' */
- while(whitespace(tempstr[i]) && tempstr[i] != '\0') i++;
-
- if (tempstr[i] != ',')
- return -1; /* invalid representation */
- }
-
- tempstr[i++] = '\0'; /* skip the ',' */
- for (j = 0; j < COLOR_COUNT && strcasecmp(part, color_names[j].name); j++);
- if (j == COLOR_COUNT) /* invalid color name */
- return -1;
- if (get_fg) {
- *fg = color_names[j].value;
- get_fg = 0; /* next we have to get the background */
- }
- else {
- *bg = color_names[j].value;
- break;
- }
- } /* got foreground and background */
-
-
- /* get highlight */
-
- /* skip white space before highlight string */
- while (whitespace(tempstr[i]) && tempstr[i] != '\0') i++;
- if (tempstr[i] == '\0')
- return -1; /* invalid representation */
- part = tempstr + i; /* set 'part' to start of highlight string */
-
- /* trim trailing white space from highlight string */
- i = strlen(part) - 1;
- while(whitespace(part[i])) i--;
- part[i+1] = '\0';
-
- if (!strcasecmp(part, "ON"))
- *hl = TRUE;
- else if (!strcasecmp(part, "OFF"))
- *hl = FALSE;
- else
- return -1; /* invalid highlight value */
-
- return 0;
-}
-/* End of str_to_attr() */
-
-
-/*
- * Parse a line in the configuration file
- *
- * Each line is of the form: "variable = value". On exit, 'var' will contain
- * the variable name, and 'value' will contain the value string.
- *
- * Return values:
- *
- * LINE_BLANK - line is blank
- * LINE_COMMENT - line is comment
- * LINE_OK - line is ok
- * LINE_ERROR - syntax error in line
- */
-static int parse_line(unsigned char *line, unsigned char **var, unsigned char **value)
-{
- int i = 0;
-
- /* ignore white space at beginning of line */
- while(whitespace(line[i]) && line[i] != '\0') i++;
-
- if (line[i] == '\0') /* line is blank */
- return LINE_BLANK;
- else if (line[i] == '#') /* line is comment */
- return LINE_COMMENT;
- else if (line[i] == '=') /* variables names can't strart with a '=' */
- return LINE_ERROR;
-
- /* set 'var' to variable name */
- *var = line + i++; /* skip to next character */
-
- /* find end of variable name */
- while(!whitespace(line[i]) && line[i] != '=' && line[i] != '\0') i++;
-
- if (line[i] == '\0') /* syntax error */
- return LINE_ERROR;
- else if (line[i] == '=')
- line[i++] = '\0';
- else {
- line[i++] = '\0';
-
- /* skip white space before '=' */
- while(whitespace(line[i]) && line[i] != '\0') i++;
-
- if (line[i] != '=') /* syntax error */
- return LINE_ERROR;
- else
- i++; /* skip the '=' */
- }
-
- /* skip white space after '=' */
- while(whitespace(line[i]) && line[i] != '\0') i++;
-
- if (line[i] == '\0')
- return LINE_ERROR;
- else
- *value = line + i; /* set 'value' to value string */
-
- /* trim trailing white space from 'value' */
- i = strlen(*value) - 1;
- while(whitespace((*value)[i])) i--;
- (*value)[i+1] = '\0';
-
- return LINE_OK; /* no syntax error in line */
-}
-/* End of parse_line() */
diff --git a/gnu/lib/libdialog/rc.h b/gnu/lib/libdialog/rc.h
deleted file mode 100644
index fc19d03..0000000
--- a/gnu/lib/libdialog/rc.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * rc.h -- declarations for configuration file processing
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- */
-
-
-#define DIALOGRC ".dialogrc"
-#define VAR_LEN 30
-#define COMMENT_LEN 70
-
-/* Types of values */
-#define VAL_INT 0
-#define VAL_STR 1
-#define VAL_BOOL 2
-#define VAL_ATTR 3
-
-/* Type of line in configuration file */
-#define LINE_BLANK 2
-#define LINE_COMMENT 1
-#define LINE_OK 0
-#define LINE_ERROR -1
-
-/* number of configuration variables */
-#define VAR_COUNT (sizeof(vars) / sizeof(vars_st))
-
-/* check if character is white space */
-#define whitespace(c) (c == ' ' || c == '\t')
-
-/* check if character is string quoting characters */
-#define isquote(c) (c == '"' || c == '\'')
-
-/* get last character of string */
-#define lastch(str) str[strlen(str)-1]
-
-/*
- * Configuration variables
- */
-typedef struct {
- unsigned char name[VAR_LEN]; /* name of configuration variable as in DIALOGRC */
- void *var; /* address of actually variable to change */
- int type; /* type of value */
- unsigned char comment[COMMENT_LEN]; /* comment to put in "rc" file */
-} vars_st;
-
-vars_st vars[] = {
- { "use_shadow",
- &use_shadow,
- VAL_BOOL,
- "Shadow dialog boxes? This also turns on color." },
-
- { "use_colors",
- &use_colors,
- VAL_BOOL,
- "Turn color support ON or OFF" },
-
- { "screen_color",
- color_table[0],
- VAL_ATTR,
- "Screen color" },
-
- { "shadow_color",
- color_table[1],
- VAL_ATTR,
- "Shadow color" },
-
- { "dialog_color",
- color_table[2],
- VAL_ATTR,
- "Dialog box color" },
-
- { "title_color",
- color_table[3],
- VAL_ATTR,
- "Dialog box title color" },
-
- { "border_color",
- color_table[4],
- VAL_ATTR,
- "Dialog box border color" },
-
- { "button_active_color",
- color_table[5],
- VAL_ATTR,
- "Active button color" },
-
- { "button_inactive_color",
- color_table[6],
- VAL_ATTR,
- "Inactive button color" },
-
- { "button_key_active_color",
- color_table[7],
- VAL_ATTR,
- "Active button key color" },
-
- { "button_key_inactive_color",
- color_table[8],
- VAL_ATTR,
- "Inactive button key color" },
-
- { "button_label_active_color",
- color_table[9],
- VAL_ATTR,
- "Active button label color" },
-
- { "button_label_inactive_color",
- color_table[10],
- VAL_ATTR,
- "Inactive button label color" },
-
- { "inputbox_color",
- color_table[11],
- VAL_ATTR,
- "Input box color" },
-
- { "inputbox_border_color",
- color_table[12],
- VAL_ATTR,
- "Input box border color" },
-
- { "searchbox_color",
- color_table[13],
- VAL_ATTR,
- "Search box color" },
-
- { "searchbox_title_color",
- color_table[14],
- VAL_ATTR,
- "Search box title color" },
-
- { "searchbox_border_color",
- color_table[15],
- VAL_ATTR,
- "Search box border color" },
-
- { "position_indicator_color",
- color_table[16],
- VAL_ATTR,
- "File position indicator color" },
-
- { "menubox_color",
- color_table[17],
- VAL_ATTR,
- "Menu box color" },
-
- { "menubox_border_color",
- color_table[18],
- VAL_ATTR,
- "Menu box border color" },
-
- { "item_color",
- color_table[19],
- VAL_ATTR,
- "Item color" },
-
- { "item_selected_color",
- color_table[20],
- VAL_ATTR,
- "Selected item color" },
-
- { "tag_color",
- color_table[21],
- VAL_ATTR,
- "Tag color" },
-
- { "tag_selected_color",
- color_table[22],
- VAL_ATTR,
- "Selected tag color" },
-
- { "tag_key_color",
- color_table[23],
- VAL_ATTR,
- "Tag key color" },
-
- { "tag_key_selected_color",
- color_table[24],
- VAL_ATTR,
- "Selected tag key color" },
-
- { "check_color",
- color_table[25],
- VAL_ATTR,
- "Check box color" },
-
- { "check_selected_color",
- color_table[26],
- VAL_ATTR,
- "Selected check box color" },
-
- { "uarrow_color",
- color_table[27],
- VAL_ATTR,
- "Up arrow color" },
-
- { "darrow_color",
- color_table[28],
- VAL_ATTR,
- "Down arrow color" }
-}; /* vars */
-
-
-
-/*
- * Routines to process configuration file
- */
-int parse_rc(void);
diff --git a/gnu/lib/libdialog/textbox.c b/gnu/lib/libdialog/textbox.c
deleted file mode 100644
index 91f43a2..0000000
--- a/gnu/lib/libdialog/textbox.c
+++ /dev/null
@@ -1,696 +0,0 @@
-/*
- * textbox.c -- implements the text box
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- */
-
-
-#include <dialog.h>
-#include "dialog.priv.h"
-
-
-static void back_lines(int n);
-static void print_page(WINDOW *win, int height, int width);
-static void print_line(WINDOW *win, int row, int width);
-static unsigned char *get_line(void);
-static int get_search_term(WINDOW *win, unsigned char *search_term, int height, int width);
-static void print_position(WINDOW *win, int height, int width);
-
-
-static int hscroll = 0, fd, file_size, bytes_read, begin_reached = 1,
- end_reached = 0, page_length;
-static unsigned char *buf, *page;
-
-
-/*
- * Display text from a file in a dialog box.
- */
-int dialog_textbox(unsigned char *title, unsigned char *file, int height, int width)
-{
- int i, x, y, cur_x, cur_y, fpos, key = 0, dir, temp, temp1;
-#ifdef HAVE_NCURSES
- int passed_end;
-#endif
- unsigned char search_term[MAX_LEN+1], *tempptr, *found;
- WINDOW *dialog, *text;
-
- if (height < 0 || width < 0) {
- fprintf(stderr, "\nAutosizing is impossible in dialog_textbox().\n");
- return(-1);
- }
-
- search_term[0] = '\0'; /* no search term entered yet */
-
- /* Open input file for reading */
- if ((fd = open(file, O_RDONLY)) == -1) {
- fprintf(stderr, "\nCan't open input file <%s>in dialog_textbox().\n", file);
- return(-1);
- }
- /* Get file size. Actually, 'file_size' is the real file size - 1,
- since it's only the last byte offset from the beginning */
- if ((file_size = lseek(fd, 0, SEEK_END)) == -1) {
- fprintf(stderr, "\nError getting file size in dialog_textbox().\n");
- return(-1);
- }
- /* Restore file pointer to beginning of file after getting file size */
- if (lseek(fd, 0, SEEK_SET) == -1) {
- fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
- return(-1);
- }
- /* Allocate space for read buffer */
- if ((buf = malloc(BUF_SIZE+1)) == NULL) {
- endwin();
- fprintf(stderr, "\nCan't allocate memory in dialog_textbox().\n");
- exit(-1);
- }
- if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) {
- fprintf(stderr, "\nError reading file in dialog_textbox().\n");
- return(-1);
- }
- buf[bytes_read] = '\0'; /* mark end of valid data */
- page = buf; /* page is pointer to start of page to be displayed */
-
- if (width > COLS)
- width = COLS;
- if (height > LINES)
- height = LINES;
- /* center dialog box on screen */
- x = DialogX ? DialogX : (COLS - width)/2;
- y = DialogY ? DialogY : (LINES - height)/2;
-
-#ifdef HAVE_NCURSES
- if (use_shadow)
- draw_shadow(stdscr, y, x, height, width);
-#endif
- dialog = newwin(height, width, y, x);
- if (dialog == NULL) {
- endwin();
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
- exit(1);
- }
- keypad(dialog, TRUE);
-
- /* Create window for text region, used for scrolling text */
-/* text = newwin(height-4, width-2, y+1, x+1); */
- text = subwin(dialog, height-4, width-2, y+1, x+1);
- if (text == NULL) {
- endwin();
- fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", height-4,width-2,y+1,x+1);
- exit(1);
- }
- keypad(text, TRUE);
-
- draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
-
- wattrset(dialog, border_attr);
- wmove(dialog, height-3, 0);
- waddch(dialog, ACS_LTEE);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dialog_attr);
- waddch(dialog, ACS_RTEE);
- wmove(dialog, height-2, 1);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ' ');
-
- if (title != NULL) {
- wattrset(dialog, title_attr);
- wmove(dialog, 0, (width - strlen(title))/2 - 1);
- waddch(dialog, ' ');
- waddstr(dialog, title);
- waddch(dialog, ' ');
- }
- display_helpline(dialog, height-1, width);
-
- print_button(dialog, " OK ", height-2, width/2-6, TRUE);
- wnoutrefresh(dialog);
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
-
- /* Print first page of text */
- attr_clear(text, height-4, width-2, dialog_attr);
- print_page(text, height-4, width-2);
- print_position(dialog, height, width);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
-
- while ((key != ESC) && (key != '\n') && (key != '\r')) {
- key = wgetch(dialog);
- switch (key) {
- case 'E': /* Exit */
- case 'e':
- delwin(dialog);
- free(buf);
- close(fd);
- return 0;
- case 'g': /* First page */
- case KEY_HOME:
- if (!begin_reached) {
- begin_reached = 1;
- /* First page not in buffer? */
- if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
- exit(-1);
- }
- if (fpos > bytes_read) { /* Yes, we have to read it in */
- if (lseek(fd, 0, SEEK_SET) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
- exit(-1);
- }
- if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) {
- endwin();
- fprintf(stderr, "\nError reading file in dialog_textbox().\n");
- exit(-1);
- }
- buf[bytes_read] = '\0';
- }
- page = buf;
- print_page(text, height-4, width-2);
- print_position(dialog, height, width);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
- break;
- case 'G': /* Last page */
-#ifdef HAVE_NCURSES
- case KEY_END:
-#endif
- end_reached = 1;
- /* Last page not in buffer? */
- if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
- exit(-1);
- }
- if (fpos < file_size) { /* Yes, we have to read it in */
- if (lseek(fd, -BUF_SIZE, SEEK_END) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
- exit(-1);
- }
- if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) {
- endwin();
- fprintf(stderr, "\nError reading file in dialog_textbox().\n");
- exit(-1);
- }
- buf[bytes_read] = '\0';
- }
- page = buf + bytes_read;
- back_lines(height-4);
- print_page(text, height-4, width-2);
- print_position(dialog, height, width);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- break;
- case 'K': /* Previous line */
- case 'k':
- case '\020': /* ^P */
- case KEY_UP:
- if (!begin_reached) {
- back_lines(page_length+1);
-#ifdef HAVE_NCURSES
- /* We don't call print_page() here but use scrolling to ensure
- faster screen update. However, 'end_reached' and 'page_length'
- should still be updated, and 'page' should point to start of
- next page. This is done by calling get_line() in the following
- 'for' loop. */
- scrollok(text, TRUE);
- wscrl(text, -1); /* Scroll text region down one line */
- scrollok(text, FALSE);
- page_length = 0;
- passed_end = 0;
- for (i = 0; i < height-4; i++) {
- if (!i) {
- print_line(text, 0, width-2); /* print first line of page */
- wnoutrefresh(text);
- }
- else
- get_line(); /* Called to update 'end_reached' and 'page' */
- if (!passed_end)
- page_length++;
- if (end_reached && !passed_end)
- passed_end = 1;
- }
-#else
- print_page(text, height-4, width-2);
-#endif
- print_position(dialog, height, width);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
- break;
- case 'B': /* Previous page */
- case 'b':
- case KEY_PPAGE:
- if (!begin_reached) {
- back_lines(page_length + height-4);
- print_page(text, height-4, width-2);
- print_position(dialog, height, width);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
- break;
- case 'J': /* Next line */
- case 'j':
- case '\016': /* ^N */
- case KEY_DOWN:
- if (!end_reached) {
- begin_reached = 0;
- scrollok(text, TRUE);
- scroll(text); /* Scroll text region up one line */
- scrollok(text, FALSE);
- print_line(text, height-5, width-2);
-#ifndef HAVE_NCURSES
- wmove(text, height-5, 0);
- waddch(text, ' ');
- wmove(text, height-5, width-3);
- waddch(text, ' ');
-#endif
- wnoutrefresh(text);
- print_position(dialog, height, width);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
- break;
- case ' ': /* Next page */
- case KEY_NPAGE:
- if (!end_reached) {
- begin_reached = 0;
- print_page(text, height-4, width-2);
- print_position(dialog, height, width);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
- break;
- case '0': /* Beginning of line */
- case 'H': /* Scroll left */
- case 'h':
- case KEY_LEFT:
- if (hscroll > 0) {
- if (key == '0')
- hscroll = 0;
- else
- hscroll--;
- /* Reprint current page to scroll horizontally */
- back_lines(page_length);
- print_page(text, height-4, width-2);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
- break;
- case 'L': /* Scroll right */
- case 'l':
- case KEY_RIGHT:
- if (hscroll < MAX_LEN) {
- hscroll++;
- /* Reprint current page to scroll horizontally */
- back_lines(page_length);
- print_page(text, height-4, width-2);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
- break;
- case '/': /* Forward search */
- case 'n': /* Repeat forward search */
- case '?': /* Backward search */
- case 'N': /* Repeat backward search */
- /* set search direction */
- dir = (key == '/' || key == 'n') ? 1 : 0;
- if (dir ? !end_reached : !begin_reached) {
- if (key == 'n' || key == 'N') {
- if (search_term[0] == '\0') { /* No search term yet */
- fprintf(stderr, "\a"); /* beep */
- break;
- }
- }
- else /* Get search term from user */
- if (get_search_term(text, search_term, height-4, width-2) == -1) {
- /* ESC pressed in get_search_term(). Reprint page to clear box */
- wattrset(text, dialog_attr);
- back_lines(page_length);
- print_page(text, height-4, width-2);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- break;
- }
- /* Save variables for restoring in case search term can't be found */
- tempptr = page;
- temp = begin_reached;
- temp1 = end_reached;
- if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
- exit(-1);
- }
- fpos -= bytes_read;
- /* update 'page' to point to next (previous) line before
- forward (backward) searching */
- back_lines(dir ? page_length-1 : page_length+1);
- found = NULL;
- if (dir) /* Forward search */
- while((found = strstr(get_line(), search_term)) == NULL) {
- if (end_reached)
- break;
- }
- else /* Backward search */
- while((found = strstr(get_line(), search_term)) == NULL) {
- if (begin_reached)
- break;
- back_lines(2);
- }
- if (found == NULL) { /* not found */
- fprintf(stderr, "\a"); /* beep */
- /* Restore program state to that before searching */
- if (lseek(fd, fpos, SEEK_SET) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
- exit(-1);
- }
- if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) {
- endwin();
- fprintf(stderr, "\nError reading file in dialog_textbox().\n");
- exit(-1);
- }
- buf[bytes_read] = '\0';
- page = tempptr;
- begin_reached = temp;
- end_reached = temp1;
- /* move 'page' to point to start of current page in order to
- re-print current page. Note that 'page' always points to
- start of next page, so this is necessary */
- back_lines(page_length);
- }
- else /* Search term found */
- back_lines(1);
- /* Reprint page */
- wattrset(text, dialog_attr);
- print_page(text, height-4, width-2);
- if (found != NULL)
- print_position(dialog, height, width);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
- else /* no need to find */
- fprintf(stderr, "\a"); /* beep */
- break;
- case ESC:
- break;
- case KEY_F(1):
- display_helpfile();
- break;
- }
- }
-
- delwin(dialog);
- free(buf);
- close(fd);
- return -1; /* ESC pressed */
-}
-/* End of dialog_textbox() */
-
-
-/*
- * Go back 'n' lines in text file. Called by dialog_textbox().
- * 'page' will be updated to point to the desired line in 'buf'.
- */
-static void back_lines(int n)
-{
- int i, fpos;
-
- begin_reached = 0;
- /* We have to distinguish between end_reached and !end_reached since at end
- of file, the line is not ended by a '\n'. The code inside 'if' basically
- does a '--page' to move one character backward so as to skip '\n' of the
- previous line */
- if (!end_reached) {
- /* Either beginning of buffer or beginning of file reached? */
- if (page == buf) {
- if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in back_lines().\n");
- exit(-1);
- }
- if (fpos > bytes_read) { /* Not beginning of file yet */
- /* We've reached beginning of buffer, but not beginning of file yet,
- so read previous part of file into buffer. Note that we only
- move backward for BUF_SIZE/2 bytes, but not BUF_SIZE bytes to
- avoid re-reading again in print_page() later */
- /* Really possible to move backward BUF_SIZE/2 bytes? */
- if (fpos < BUF_SIZE/2 + bytes_read) {
- /* No, move less then */
- if (lseek(fd, 0, SEEK_SET) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in back_lines().\n");
- exit(-1);
- }
- page = buf + fpos - bytes_read;
- }
- else { /* Move backward BUF_SIZE/2 bytes */
- if (lseek(fd, -(BUF_SIZE/2 + bytes_read), SEEK_CUR) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in back_lines().\n");
- exit(-1);
- }
- page = buf + BUF_SIZE/2;
- }
- if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) {
- endwin();
- fprintf(stderr, "\nError reading file in back_lines().\n");
- exit(-1);
- }
- buf[bytes_read] = '\0';
- }
- else { /* Beginning of file reached */
- begin_reached = 1;
- return;
- }
- }
- if (*(--page) != '\n') { /* '--page' here */
- /* Something's wrong... */
- endwin();
- fprintf(stderr, "\nInternal error in back_lines().\n");
- exit(-1);
- }
- }
-
- /* Go back 'n' lines */
- for (i = 0; i < n; i++)
- do {
- if (page == buf) {
- if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in back_lines().\n");
- exit(-1);
- }
- if (fpos > bytes_read) {
- /* Really possible to move backward BUF_SIZE/2 bytes? */
- if (fpos < BUF_SIZE/2 + bytes_read) {
- /* No, move less then */
- if (lseek(fd, 0, SEEK_SET) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in back_lines().\n");
- exit(-1);
- }
- page = buf + fpos - bytes_read;
- }
- else { /* Move backward BUF_SIZE/2 bytes */
- if (lseek(fd, -(BUF_SIZE/2 + bytes_read), SEEK_CUR) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in back_lines().\n");
- exit(-1);
- }
- page = buf + BUF_SIZE/2;
- }
- if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) {
- endwin();
- fprintf(stderr, "\nError reading file in back_lines().\n");
- exit(-1);
- }
- buf[bytes_read] = '\0';
- }
- else { /* Beginning of file reached */
- begin_reached = 1;
- return;
- }
- }
- } while (*(--page) != '\n');
- page++;
-}
-/* End of back_lines() */
-
-
-/*
- * Print a new page of text. Called by dialog_textbox().
- */
-static void print_page(WINDOW *win, int height, int width)
-{
- int i, passed_end = 0;
-
- page_length = 0;
- for (i = 0; i < height; i++) {
- print_line(win, i, width);
- if (!passed_end)
- page_length++;
- if (end_reached && !passed_end)
- passed_end = 1;
- }
- wnoutrefresh(win);
-}
-/* End of print_page() */
-
-
-/*
- * Print a new line of text. Called by dialog_textbox() and print_page().
- */
-static void print_line(WINDOW *win, int row, int width)
-{
- int i, y, x;
- unsigned char *line;
-
- line = get_line();
- line += MIN(strlen(line),hscroll); /* Scroll horizontally */
- wmove(win, row, 0); /* move cursor to correct line */
- waddch(win,' ');
-#ifdef HAVE_NCURSES
- waddnstr(win, line, MIN(strlen(line),width-2));
-#else
- line[MIN(strlen(line),width-2)] = '\0';
- waddstr(win, line);
-#endif
-
- getyx(win, y, x);
- /* Clear 'residue' of previous line */
- for (i = 0; i < width-x; i++)
- waddch(win, ' ');
-}
-/* End of print_line() */
-
-
-/*
- * Return current line of text. Called by dialog_textbox() and print_line().
- * 'page' should point to start of current line before calling, and will be
- * updated to point to start of next line.
- */
-static unsigned char *get_line(void)
-{
- int i = 0, fpos;
- static unsigned char line[MAX_LEN+1];
-
- end_reached = 0;
- while (*page != '\n') {
- if (*page == '\0') { /* Either end of file or end of buffer reached */
- if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in get_line().\n");
- exit(-1);
- }
- if (fpos < file_size) { /* Not end of file yet */
- /* We've reached end of buffer, but not end of file yet, so read next
- part of file into buffer */
- if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) {
- endwin();
- fprintf(stderr, "\nError reading file in get_line().\n");
- exit(-1);
- }
- buf[bytes_read] = '\0';
- page = buf;
- }
- else {
- if (!end_reached)
- end_reached = 1;
- break;
- }
- }
- else
- if (i < MAX_LEN)
- line[i++] = *(page++);
- else {
- if (i == MAX_LEN) /* Truncate lines longer than MAX_LEN characters */
- line[i++] = '\0';
- page++;
- }
- }
- if (i <= MAX_LEN)
- line[i] = '\0';
- if (!end_reached)
- page++; /* move pass '\n' */
-
- return line;
-}
-/* End of get_line() */
-
-
-/*
- * Display a dialog box and get the search term from user
- */
-static int get_search_term(WINDOW *win, unsigned char *search_term, int height, int width)
-{
- int x, y, key = 0, first,
- box_height = 3, box_width = 30;
-
- x = (width - box_width)/2;
- y = (height - box_height)/2;
-#ifdef HAVE_NCURSES
- if (use_shadow)
- draw_shadow(win, y, x, box_height, box_width);
-#endif
- draw_box(win, y, x, box_height, box_width, dialog_attr, searchbox_border_attr);
- wattrset(win, searchbox_title_attr);
- wmove(win, y, x+box_width/2-4);
- waddstr(win, " Search ");
- wattrset(win, dialog_attr);
-
- search_term[0] = '\0';
-
- first = 1;
- while (key != ESC) {
- key = line_edit(win, y+1, x+1, -1, box_width-2, searchbox_attr, first, search_term, 0);
- first = 0;
- switch (key) {
- case '\n':
- if (search_term[0] != '\0')
- return 0;
- break;
- case ESC:
- break;
- }
- }
-
- return -1; /* ESC pressed */
-}
-/* End of get_search_term() */
-
-
-/*
- * Print current position
- */
-static void print_position(WINDOW *win, int height, int width)
-{
- int fpos, percent;
-
- if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
- endwin();
- fprintf(stderr, "\nError moving file pointer in print_position().\n");
- exit(-1);
- }
- wattrset(win, position_indicator_attr);
- percent = !file_size ? 100 : ((fpos-bytes_read+page-buf)*100)/file_size;
- wmove(win, height-3, width-9);
- wprintw(win, "(%3d%%)", percent);
-}
-/* End of print_position() */
diff --git a/gnu/lib/libdialog/ui_objects.c b/gnu/lib/libdialog/ui_objects.c
deleted file mode 100644
index dde1513..0000000
--- a/gnu/lib/libdialog/ui_objects.c
+++ /dev/null
@@ -1,829 +0,0 @@
-/*
- * Program: objects.c
- * Author: Marc van Kempen
- * Desc: Implementation of UI-objects:
- * - String input fields
- * - List selection
- * - Buttons
- *
- * Copyright (c) 1995, Marc van Kempen
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- */
-
-#include <stdlib.h>
-#include <sys/param.h>
-#include <ncurses.h>
-#include <dialog.h>
-#include "dialog.priv.h"
-#include "ui_objects.h"
-
-#define ESC 27
-
-/***********************************************************************
- *
- * Obj routines
- *
- ***********************************************************************/
-
-void
-AddObj(ComposeObj **Obj, int objtype, void *obj)
-/*
- * Desc: Add the object <obj> to the list of objects <Obj>
- */
-{
- if (*Obj == NULL) {
- /* Create the root object */
- *Obj = (ComposeObj *) malloc( sizeof(ComposeObj) );
- if (!Obj) {
- printf("AddObj: Error malloc'ing ComposeObj\n");
- exit(-1);
- }
- (*Obj)->objtype = objtype;
- (*Obj)->obj = obj;
- (*Obj)->next = NULL;
- (*Obj)->prev = NULL;
- } else {
- ComposeObj *o = *Obj;
-
- /* create the next object */
- while (o->next) o = (ComposeObj *) o->next;
- o->next = (struct ComposeObj *) malloc( sizeof(ComposeObj) );
- if (!o->next) {
- printf("AddObj: Error malloc'ing o->next\n");
- exit(-1);
- }
- o->next->objtype = objtype;
- o->next->obj = obj;
- o->next->next = NULL;
- o->next->prev = o;
- }
-
- return;
-} /* AddObj() */
-
-void
-FreeObj(ComposeObj *Obj)
-/*
- * Desc: free the memory occupied by *Obj
- */
-{
- ComposeObj *o = Obj;
-
- o = Obj;
- while (o) {
- o = Obj->next;
- free(Obj);
- Obj = o;
- }
-
- return;
-} /* FreeObj() */
-
-
-int
-ReadObj(ComposeObj *Obj)
-/*
- * Desc: navigate through the different objects calling their
- * respective navigation routines as necessary
- * Pre: Obj != NULL
- */
-{
- ComposeObj *o;
- ComposeObj *last; /* the last object in the list */
- int ret; /* the return value from the selection routine */
-
- /* find the last object in the list */
- last = Obj;
- while (last->next) last = last->next;
-
- ret = 0;
- o = Obj;
- while ((ret != SEL_BUTTON) && (ret != SEL_ESC)) {
- switch(o->objtype) {
- case STRINGOBJ:
- ret = SelectStringObj((StringObj *) o->obj);
- break;
- case LISTOBJ:
- ret = SelectListObj((ListObj *) o->obj);
- break;
- case BUTTONOBJ:
- ret = SelectButtonObj((ButtonObj *) o->obj);
- break;
- }
- switch(ret) {
- case KEY_DOWN:
- case SEL_CR:
- case SEL_TAB: /* move to the next object in the list */
- if (o->next != NULL) {
- o = o->next; /* next object */
- } else {
- o = Obj; /* beginning of the list */
- }
- break;
-
- case KEY_UP:
- case SEL_BACKTAB: /* move to the previous object in the list */
- if (o->prev != NULL) {
- o = o->prev; /* previous object */
- } else {
- o = last; /* end of the list */
- }
- break;
-
- case KEY_F(1): /* display help_file */
- case '?':
- display_helpfile();
- break;
- }
- }
-
- return(ret);
-
-} /* ReadObj() */
-
-
-int
-PollObj(ComposeObj **Obj)
-{
- ComposeObj *last; /* the last object in the list */
- ComposeObj *first; /* the first object in the list */
- int ret; /* the return value from the selection routine */
-
- /* find the last object in the list */
- last = *Obj;
- while (last->next) last = last->next;
-
- /* find the first object in the list */
- first = *Obj;
- while (first->prev) first = first->prev;
-
- ret = 0;
- switch((*Obj)->objtype) {
- case STRINGOBJ:
- ret = SelectStringObj((StringObj *) (*Obj)->obj);
- break;
- case LISTOBJ:
- ret = SelectListObj((ListObj *) (*Obj)->obj);
- break;
- case BUTTONOBJ:
- ret = SelectButtonObj((ButtonObj *) (*Obj)->obj);
- break;
- }
- switch(ret) {
- case KEY_DOWN:
- case SEL_CR:
- case SEL_TAB: /* move to the next object in the list */
- if ((*Obj)->next != NULL) {
- *Obj = (*Obj)->next; /* next object */
- } else {
- *Obj = first; /* beginning of the list */
- }
- break;
-
- case KEY_UP:
- case SEL_BACKTAB: /* move to the previous object in the list */
- if ((*Obj)->prev != NULL) {
- *Obj = (*Obj)->prev; /* previous object */
- } else {
- *Obj = last; /* end of the list */
- }
- break;
- }
-
- return(ret);
-
-} /* PollObj() */
-
-
-void
-DelObj(ComposeObj *Obj)
-/*
- * Desc: Free all objects
- */
-{
- ComposeObj *o;
-
- o = Obj;
- while (Obj != NULL) {
- switch(Obj->objtype) {
- case STRINGOBJ:
- DelStringObj((StringObj *) Obj->obj);
- break;
- case LISTOBJ:
- DelListObj((ListObj *) Obj->obj);
- break;
- case BUTTONOBJ:
- DelButtonObj((ButtonObj *) Obj->obj);
- break;
- }
- Obj = Obj->next;
- }
-
- FreeObj(o);
-} /* DelObj() */
-
-/***********************************************************************
- *
- * StringObj routines
- *
- ***********************************************************************/
-
-static void
-outstr(WINDOW *win, char *str, int attrs)
-{
- if (attrs & DITEM_NO_ECHO) {
- char *cpy;
- int n = strlen(str);
-
- cpy = alloca(n + 1);
- memset(cpy, '*', n);
- cpy[n] = '\0';
- waddstr(win, cpy);
- }
- else
- waddstr(win, str);
-}
-
-void
-RefreshStringObj(StringObj *so)
-/*
- * Desc: redraw the object
- */
-{
- char tmp[512];
-
- wmove(so->win, so->y, so->x+1);
- wattrset(so->win, dialog_attr);
- waddstr(so->win, so->title);
-
- draw_box(so->win, so->y+1, so->x, 3, so->w, dialog_attr, border_attr);
- wattrset(so->win, item_attr);
- wmove(so->win, so->y+2, so->x+1);
- if (strlen(so->s) > so->w-2) {
- strncpy(tmp, (char *) so->s + strlen(so->s) - so->w + 2, so->w - 1);
- outstr(so->win, tmp, so->attr_mask);
- } else {
- outstr(so->win, so->s, so->attr_mask);
- }
-
- return;
-} /* RefreshStringObj() */
-
-StringObj *
-NewStringObj(WINDOW *win, char *title, char *s, int y, int x, int w, int len)
-/*
- * Desc: Initialize a new stringobj and return a pointer to it.
- * Draw the object on the screen at the specified coordinates
- */
-{
- StringObj *so;
-
- /* Initialize a new object */
- so = (StringObj *) malloc( sizeof(StringObj) );
- if (!so) {
- printf("NewStringObj: Error malloc'ing StringObj\n");
- exit(-1);
- }
- so->title = (char *) malloc( strlen(title) + 1);
- if (!so->title) {
- printf("NewStringObj: Error malloc'ing so->title\n");
- exit(-1);
- }
- strcpy(so->title, title);
- so->s = s;
- strcpy(so->s, s);
- so->x = x;
- so->y = y;
- so->w = w;
- so->len = len;
- so->win = win;
- so->attr_mask = DialogInputAttrs; /* Grossly use a global to avoid changing API */
-
- /* Draw it on the screen */
- RefreshStringObj(so);
-
- return(so);
-} /* NewStringObj() */
-
-int
-SelectStringObj(StringObj *so)
-/*
- * Desc: get input using the info in <so>
- */
-{
- int key;
- char tmp[so->len+1];
-
- strcpy(tmp, so->s);
- key = line_edit(so->win, so->y+2, so->x+1,
- so->len, so->w-2, inputbox_attr, TRUE, tmp, so->attr_mask);
- if ((key == '\n') || (key == '\r') || (key == '\t') || key == (KEY_BTAB) ) {
- strcpy(so->s, tmp);
- }
- RefreshStringObj(so);
- if (key == ESC) {
- return(SEL_ESC);
- }
- if (key == '\t') {
- return(SEL_TAB);
- }
- if ( (key == KEY_BTAB) || (key == KEY_F(2)) ) {
- return(SEL_BACKTAB);
- }
- if ((key == '\n') || (key == '\r')) {
- return(SEL_CR);
- }
- return(key);
-} /* SelectStringObj() */
-
-
-void
-DelStringObj(StringObj *so)
-/*
- * Desc: Free the space occupied by <so>
- */
-{
- free(so->title);
- free(so);
-
- return;
-}
-
-/***********************************************************************
- *
- * ListObj routines
- *
- ***********************************************************************/
-
-void
-DrawNames(ListObj *lo)
-/*
- * Desc: Just refresh the names, not the surrounding box and title
- */
-{
- int i, j, h, x, y;
- char tmp[MAXPATHLEN];
-
- x = lo->x + 1;
- y = lo->y + 2;
- h = lo->h - 2;
- for (i=lo->scroll; i<lo->n && i<lo->scroll+h; i++) {
- wmove(lo->win, y+i-lo->scroll, x);
- if (lo->seld[i]) {
- wattrset(lo->win, A_BOLD);
- } else {
- wattrset(lo->win, item_attr);
- }
- if (strlen(lo->name[i]) > lo->w-2) {
- strncpy(tmp, lo->name[i], lo->w-2);
- tmp[lo->w - 2] = 0;
- waddstr(lo->win, tmp);
- } else {
- waddstr(lo->win, lo->name[i]);
- for (j=strlen(lo->name[i]); j<lo->w-2; j++) waddstr(lo->win, " ");
- }
- }
- wattrset(lo->win, item_attr);
- while (i<lo->scroll+h) {
- wmove(lo->win, y+i-lo->scroll, x);
- for (j=0; j<lo->w-2; j++) waddstr(lo->win, " ");
- i++;
- }
-
- return;
-} /* DrawNames() */
-
-void
-RefreshListObj(ListObj *lo)
-/*
- * Desc: redraw the list object
- */
-{
- char perc[7];
-
- /* setup the box */
- wmove(lo->win, lo->y, lo->x+1);
- wattrset(lo->win, dialog_attr);
- waddstr(lo->win, lo->title);
- draw_box(lo->win, lo->y+1, lo->x, lo->h, lo->w, dialog_attr, border_attr);
-
- /* draw the names */
- DrawNames(lo);
-
- /* Draw % indication */
- sprintf(perc, "(%3d%%)", MIN(100, (int) (100 * (lo->sel+lo->h-2) / MAX(1, lo->n))));
- wmove(lo->win, lo->y + lo->h, lo->x + lo->w - 8);
- wattrset(lo->win, dialog_attr);
- waddstr(lo->win, perc);
-
-
- return;
-} /* RefreshListObj() */
-
-ListObj *
-NewListObj(WINDOW *win, char *title, char **list, char *listelt, int y, int x,
- int h, int w, int n)
-/*
- * Desc: create a listobj, draw it on the screen and return a pointer to it.
- */
-{
- ListObj *lo;
- int i;
-
- /* Initialize a new object */
- lo = (ListObj *) malloc( sizeof(ListObj) );
- if (!lo) {
- fprintf(stderr, "NewListObj: Error malloc'ing ListObj\n");
- exit(-1);
- }
- lo->title = (char *) malloc( strlen(title) + 1);
- if (!lo->title) {
- fprintf(stderr, "NewListObj: Error malloc'ing lo->title\n");
- exit(-1);
- }
- strcpy(lo->title, title);
- lo->name = list;
- if (n>0) {
- lo->seld = (int *) malloc( n * sizeof(int) );
- if (!lo->seld) {
- fprintf(stderr, "NewListObj: Error malloc'ing lo->seld\n");
- exit(-1);
- }
- for (i=0; i<n; i++) {
- lo->seld[i] = FALSE;
- }
- } else {
- lo->seld = NULL;
- }
- lo->y = y;
- lo->x = x;
- lo->w = w;
- lo->h = h;
- lo->n = n;
- lo->scroll = 0;
- lo->sel = 0;
- lo->elt = listelt;
- lo->win = win;
-
- /* Draw the object on the screen */
- RefreshListObj(lo);
-
- return(lo);
-} /* NewListObj() */
-
-void
-UpdateListObj(ListObj *lo, char **list, int n)
-/*
- * Desc: Update the list in the listobject with the provided list
- * Pre: lo->name "has been freed"
- * "(A i: 0<=i<lo->n: "lo->name[i] has been freed")"
- */
-{
- int i;
-
- if (lo->seld) {
- free(lo->seld);
- }
-
- /* Rewrite the list in the object */
- lo->name = list;
- if (n>0) {
- lo->seld = (int *) malloc( n * sizeof(int) );
- if (!lo->seld) {
- fprintf(stderr, "UpdateListObj: Error malloc'ing lo->seld\n");
- exit(-1);
- }
- for (i=0; i<n; i++) {
- lo->seld[i] = FALSE;
- }
- } else {
- lo->seld = NULL;
- }
- lo->n = n;
- lo->scroll = 0;
- lo->sel = 0;
-
- /* Draw the object on the screen */
- RefreshListObj(lo);
-
- return;
-} /* UpdateListObj() */
-
-int
-SelectListObj(ListObj *lo)
-/*
- * Desc: get a listname (or listnames), TAB to move on, or ESC ESC to exit
- * Pre: lo->n >= 1
- */
-{
- int key, sel_x, sel_y, quit;
- char tmp[MAXPATHLEN];
- char perc[4];
-
- sel_x = lo->x+1;
- sel_y = lo->y + 2 + lo->sel - lo->scroll;
-
- if (lo->n == 0) return(SEL_TAB);
-
- keypad(lo->win, TRUE);
-
- /* Draw current selection in inverse video */
- wmove(lo->win, sel_y, sel_x);
- wattrset(lo->win, item_selected_attr);
- waddstr(lo->win, lo->name[lo->sel]);
-
- key = wgetch(lo->win);
- quit = FALSE;
- while ((key != '\t') && (key != '\n') && (key != '\r')
- && (key != ESC) && (key != KEY_F(1)) && (key != '?') && !quit) {
- /* first draw current item in normal video */
- wmove(lo->win, sel_y, sel_x);
- if (lo->seld[lo->sel]) {
- wattrset(lo->win, A_BOLD);
- } else {
- wattrset(lo->win, item_attr);
- }
- if (strlen(lo->name[lo->sel]) > lo->w - 2) {
- strncpy(tmp, lo->name[lo->sel], lo->w - 2);
- tmp[lo->w - 2] = 0;
- waddstr(lo->win, tmp);
- } else {
- waddstr(lo->win, lo->name[lo->sel]);
- }
-
- switch (key) {
- case KEY_DOWN:
- case ctrl('n'):
- if (sel_y < lo->y + lo->h-1) {
- if (lo->sel < lo->n-1) {
- sel_y++;
- lo->sel++;
- }
- } else {
- if (lo->sel < lo->n-1) {
- lo->sel++;
- lo->scroll++;
- DrawNames(lo);
- wrefresh(lo->win);
- }
- }
- break;
- case KEY_UP:
- case ctrl('p'):
- if (sel_y > lo->y+2) {
- if (lo->sel > 0) {
- sel_y--;
- lo->sel--;
- }
- } else {
- if (lo->sel > 0) {
- lo->sel--;
- lo->scroll--;
- DrawNames(lo);
- wrefresh(lo->win);
- }
- }
- break;
- case KEY_HOME:
- case ctrl('a'):
- lo->sel = 0;
- lo->scroll = 0;
- sel_y = lo->y + 2;
- DrawNames(lo);
- wrefresh(lo->win);
- break;
- case KEY_END:
- case ctrl('e'):
- if (lo->n < lo->h - 3) {
- lo->sel = lo->n-1;
- lo->scroll = 0;
- sel_y = lo->y + 2 + lo->sel - lo->scroll;
- } else {
- /* more than one page of list */
- lo->sel = lo->n-1;
- lo->scroll = lo->n-1 - (lo->h-3);
- sel_y = lo->y + 2 + lo->sel - lo->scroll;
- DrawNames(lo);
- wrefresh(lo->win);
- }
- break;
- case KEY_NPAGE:
- case ctrl('f'):
- lo->sel += lo->h - 2;
- if (lo->sel >= lo->n) lo->sel = lo->n - 1;
- lo->scroll += lo->h - 2;
- if (lo->scroll >= lo->n - 1) lo->scroll = lo->n - 1;
- if (lo->scroll < 0) lo->scroll = 0;
- sel_y = lo->y + 2 + lo->sel - lo->scroll;
- DrawNames(lo);
- wrefresh(lo->win);
- break;
- case KEY_PPAGE:
- case ctrl('b'):
- lo->sel -= lo->h - 2;
- if (lo->sel < 0) lo->sel = 0;
- lo->scroll -= lo->h - 2;
- if (lo->scroll < 0) lo->scroll = 0;
- sel_y = lo->y + 2 + lo->sel - lo->scroll;
- DrawNames(lo);
- wrefresh(lo->win);
- break;
- default:
- quit = TRUE;
- break;
- }
- /* Draw % indication */
- sprintf(perc, "(%3d%%)", MIN(100, (int)
- (100 * (lo->sel+lo->h - 2) / MAX(1, lo->n))));
- wmove(lo->win, lo->y + lo->h, lo->x + lo->w - 8);
- wattrset(lo->win, dialog_attr);
- waddstr(lo->win, perc);
-
- /* draw current item in inverse */
- wmove(lo->win, sel_y, sel_x);
- wattrset(lo->win, item_selected_attr);
- if (strlen(lo->name[lo->sel]) > lo->w - 2) {
- /* when printing in inverse video show the last characters in the */
- /* name that will fit in the window */
- strncpy(tmp,
- lo->name[lo->sel] + strlen(lo->name[lo->sel]) - (lo->w - 2),
- lo->w - 2);
- tmp[lo->w - 2] = 0;
- waddstr(lo->win, tmp);
- } else {
- waddstr(lo->win, lo->name[lo->sel]);
- }
- if (!quit) key = wgetch(lo->win);
- }
-
- if (key == ESC) {
- return(SEL_ESC);
- }
- if (key == '\t') {
- return(SEL_TAB);
- }
- if ((key == KEY_BTAB) || (key == ctrl('b'))) {
- return(SEL_BACKTAB);
- }
- if ((key == '\n') || (key == '\r')) {
- strcpy(lo->elt, lo->name[lo->sel]);
- return(SEL_CR);
- }
- return(key);
-} /* SelectListObj() */
-
-void
-DelListObj(ListObj *lo)
-/*
- * Desc: Free the space occupied by the listobject
- */
-{
- free(lo->title);
- if (lo->seld != NULL) free(lo->seld);
- free(lo);
-
- return;
-} /* DelListObj() */
-
-void
-MarkCurrentListObj(ListObj *lo)
-/*
- * Desc: mark the current item for the selection list
- */
-{
- lo->seld[lo->sel] = !(lo->seld[lo->sel]);
- DrawNames(lo);
-
- return;
-} /* MarkCurrentListObj() */
-
-void
-MarkAllListObj(ListObj *lo)
-/*
- * Desc: mark all items
- */
-{
- int i;
-
- for (i=0; i<lo->n; i++) {
- lo->seld[i] = TRUE;
- }
- DrawNames(lo);
-
- return;
-} /* MarkAllListObj() */
-
-void
-UnMarkAllListObj(ListObj *lo)
-/*
- * Desc: unmark all items
- */
-{
- int i;
-
- for (i=0; i<lo->n; i++) {
- lo->seld[i] = FALSE;
- }
- DrawNames(lo);
-
- return;
-} /* UnMarkAllListObj() */
-
-
-/***********************************************************************
- *
- * ButtonObj routines
- *
- ***********************************************************************/
-
-
-void
-RefreshButtonObj(ButtonObj *bo)
-/*
- * Desc: redraw the button
- */
-{
- draw_box(bo->win, bo->y, bo->x, 3, bo->w, dialog_attr, border_attr);
- print_button(bo->win, bo->title, bo->y+1, bo->x+2, FALSE);
-
- return;
-} /* RefreshButtonObj() */
-
-ButtonObj *
-NewButtonObj(WINDOW *win, char *title, int *pushed, int y, int x)
-/*
- * Desc: Create a new button object
- */
-{
- ButtonObj *bo;
-
- bo = (ButtonObj *) malloc( sizeof(ButtonObj) );
-
- bo->win = win;
- bo->title = (char *) malloc( strlen(title) + 1);
- strcpy(bo->title, title);
- bo->x = x;
- bo->y = y;
- bo->w = strlen(title) + 6;
- bo->h = 3;
- bo->pushed = pushed;
-
- RefreshButtonObj(bo);
-
- return(bo);
-} /* NewButtonObj() */
-
-int
-SelectButtonObj(ButtonObj *bo)
-/*
- * Desc: Wait for buttonpresses or TAB's to move on, or ESC ESC
- */
-{
- int key;
-
- print_button(bo->win, bo->title, bo->y+1, bo->x+2, TRUE);
- wmove(bo->win, bo->y+1, bo->x+(bo->w/2)-1);
- key = wgetch(bo->win);
- print_button(bo->win, bo->title, bo->y+1, bo->x+2, FALSE);
- switch(key) {
- case '\t':
- return(SEL_TAB);
- break;
- case KEY_BTAB:
- case ctrl('b'):
- return(SEL_BACKTAB);
- case '\n':
- case '\r':
- *(bo->pushed) = TRUE;
- return(SEL_BUTTON);
- break;
- case ESC:
- return(SEL_ESC);
- break;
- default:
- return(key);
- break;
- }
-} /* SelectButtonObj() */
-
-void
-DelButtonObj(ButtonObj *bo)
-/*
- * Desc: Free the space occupied by <bo>
- */
-{
- free(bo->title);
- free(bo);
-
- return;
-} /* DelButtonObj() */
diff --git a/gnu/lib/libdialog/ui_objects.h b/gnu/lib/libdialog/ui_objects.h
deleted file mode 100644
index b30feb8..0000000
--- a/gnu/lib/libdialog/ui_objects.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Author: Marc van Kempen
- * Desc: include file for UI-objects
- *
- * Copyright (c) 1995, Marc van Kempen
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- *
- */
-
-#include "dialog.h"
-#include <ncurses.h>
-
-/***********************************************************************
- *
- * Defines
- *
- ***********************************************************************/
-
-#define ctrl(a) ((a) - 'a' + 1)
-
-/* the Object types */
-#define STRINGOBJ 1
-#define LISTOBJ 2
-#define BUTTONOBJ 3
-
-/* the return signals from the selection routines */
-/* 1000 and higher should avoid conflicts with keys pressed */
-#define SEL_CR 1001 /* return was pressed */
-#define SEL_ESC 1002 /* ESC pressed */
-#define SEL_TAB 1003 /* TAB pressed */
-#define SEL_BACKTAB 1004 /* SHIFT-TAB pressed */
-#define SEL_BUTTON 1005 /* a button was pressed */
-
-/***********************************************************************
- *
- * Typedefs
- *
- ***********************************************************************/
-
-typedef struct {
- WINDOW *win; /* the window it's contained in */
- char *title; /* the prompt for the input field */
- char *s; /* initial value of the input field */
- int x, y, w, len; /* the (y, x) position of the upperleft */
- /* corner and the width <w> of the display */
- /* and length <len> of the field */
- int attr_mask; /* special attributes */
-} StringObj;
-
-typedef struct {
- WINDOW *win; /* the windows it's contained in */
- char *title; /* the title of the list */
- char **name; /* the names of the list */
- int *seld; /* the currently selected names */
- char *elt; /* the current element in the list list[sel] */
- int x, y, w, h, n; /* dimensions of list and # of elements (n) */
- int scroll, sel; /* current position in the list */
-} ListObj;
-
-typedef struct {
- WINDOW *win; /* the window it's contained in */
- char *title; /* title for the button */
- int x, y, w, h; /* its dimensions */
- int *pushed; /* boolean that determines wether button was pushed */
-} ButtonObj;
-
-typedef struct ComposeObj {
- int objtype;
- void *obj;
- struct ComposeObj *next, *prev;
-} ComposeObj;
-
-/**********************************************************************
- *
- * Prototypes
- *
- **********************************************************************/
-
-void RefreshStringObj(StringObj *so);
-StringObj *NewStringObj(WINDOW *win, char *title, char *s,
- int y, int x, int w, int len);
-int SelectStringObj(StringObj *so);
-void DelStringObj(StringObj *so);
-
-void RefreshListObj(ListObj *lo);
-ListObj *NewListObj(WINDOW *win, char *title, char **list,
- char *listelt, int y, int x, int h, int w, int n);
-void UpdateListObj(ListObj *lo, char **list, int n);
-int SelectListObj(ListObj *lo);
-void DelListObj(ListObj *obj);
-void MarkCurrentListObj(ListObj *lo);
-void MarkAllListObj(ListObj *lo);
-void UnMarkAllListObj(ListObj *lo);
-
-void RefreshButtonObj(ButtonObj *bo);
-ButtonObj *NewButtonObj(WINDOW *win, char *title, int *pushed,
- int y, int x);
-int SelectButtonObj(ButtonObj *bo);
-void DelButtonObj(ButtonObj *bo);
-void AddObj(ComposeObj **Obj, int objtype, void *obj);
-void FreeObj(ComposeObj *Obj);
-int ReadObj(ComposeObj *Obj);
-int PollObj(ComposeObj **Obj);
-void DelObj(ComposeObj *Obj);
-
diff --git a/gnu/lib/libdialog/yesno.c b/gnu/lib/libdialog/yesno.c
deleted file mode 100644
index 2390821..0000000
--- a/gnu/lib/libdialog/yesno.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * yesno.c -- implements the yes/no box
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- */
-
-
-#include <dialog.h>
-#include "dialog.priv.h"
-
-
-/*
- * Display a dialog box with two buttons - Yes and No
- */
-int dialog_yesno(unsigned char *title, unsigned char * prompt, int height, int width)
-{
- int i, j, x, y, key = 0, button = 0;
- WINDOW *dialog;
- char *tmphlp;
-
- /* disable helpline */
- tmphlp = get_helpline();
- use_helpline(NULL);
-
- if (height < 0)
- height = strheight(prompt)+4;
- if (width < 0) {
- i = strwidth(prompt);
- j = ((title != NULL) ? strwidth(title) : 0);
- width = MAX(i,j)+4;
- }
- width = MAX(width,23);
-
- if (width > COLS)
- width = COLS;
- if (height > LINES)
- height = LINES;
- /* center dialog box on screen */
- x = DialogX ? DialogX : (COLS - width)/2;
- y = DialogY ? DialogY : (LINES - height)/2;
-
-#ifdef HAVE_NCURSES
- if (use_shadow)
- draw_shadow(stdscr, y, x, height, width);
-#endif
- dialog = newwin(height, width, y, x);
- if (dialog == NULL) {
- endwin();
- fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
- exit(1);
- }
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
- wattrset(dialog, border_attr);
- wmove(dialog, height-3, 0);
- waddch(dialog, ACS_LTEE);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dialog_attr);
- waddch(dialog, ACS_RTEE);
- wmove(dialog, height-2, 1);
- for (i = 0; i < width-2; i++)
- waddch(dialog, ' ');
-
- if (title != NULL) {
- wattrset(dialog, title_attr);
- wmove(dialog, 0, (width - strlen(title))/2 - 1);
- waddch(dialog, ' ');
- waddstr(dialog, title);
- waddch(dialog, ' ');
- }
- wattrset(dialog, dialog_attr);
- wmove(dialog, 1, 2);
- print_autowrap(dialog, prompt, height-1, width-2, width, 1, 2, TRUE, FALSE);
-
- display_helpline(dialog, height-1, width);
-
- x = width/2-10;
- y = height-2;
- print_button(dialog, " No ", y, x+13, FALSE);
- print_button(dialog, " Yes ", y, x, TRUE);
- wrefresh(dialog);
-
- while (key != ESC) {
- key = wgetch(dialog);
- switch (key) {
- case 'Y':
- case 'y':
- delwin(dialog);
- restore_helpline(tmphlp);
- return 0;
- case 'N':
- case 'n':
- delwin(dialog);
- restore_helpline(tmphlp);
- return 1;
- case KEY_BTAB:
- case TAB:
- case KEY_UP:
- case KEY_DOWN:
- case KEY_LEFT:
- case KEY_RIGHT:
- if (!button) {
- button = 1; /* Indicates "No" button is selected */
- print_button(dialog, " Yes ", y, x, FALSE);
- print_button(dialog, " No ", y, x+13, TRUE);
- }
- else {
- button = 0; /* Indicates "Yes" button is selected */
- print_button(dialog, " No ", y, x+13, FALSE);
- print_button(dialog, " Yes ", y, x, TRUE);
- }
- wrefresh(dialog);
- break;
- case ' ':
- case '\r':
- case '\n':
- delwin(dialog);
- restore_helpline(tmphlp);
- return button;
- case ESC:
- break;
- case KEY_F(1):
- case '?':
- display_helpfile();
- break;
- }
- }
-
- delwin(dialog);
- restore_helpline(tmphlp);
- return -1; /* ESC pressed */
-}
-/* End of dialog_yesno() */
diff --git a/gnu/lib/libg++/Makefile b/gnu/lib/libg++/Makefile
deleted file mode 100644
index a9199fd..0000000
--- a/gnu/lib/libg++/Makefile
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# $Id: Makefile,v 1.19 1997/05/06 00:49:28 jdp Exp $
-#
-
-GPPDIR= ${.CURDIR}/../../../contrib/libg++
-
-.PATH: ${GPPDIR}/libiberty ${GPPDIR}/libio ${GPPDIR}/libg++/src ${GPPDIR}/librx
-
-SUBDIR+= doc
-
-LIB= g++
-SHLIB_MAJOR= 4
-SHLIB_MINOR= 0
-
-CFLAGS+= -I${GPPDIR}/include -I${DESTDIR}/usr/include/g++
-CXXFLAGS+= -I${GPPDIR}/include -I${GPPDIR}/libio -I${GPPDIR}/libstdc++
-
-# C source
-SRCS= bitand.c bitany.c bitblt.c bitclear.c bitcopy.c bitcount.c \
- bitinvert.c bitlcomp.c bitset1.c bitxor.c timer.c
-
-# C source for librx
-SRCS+= rx.c
-
-# C++ source
-SRCS+= ACG.cc AllocRing.cc Binomial.cc BitSet.cc BitString.cc DLList.cc \
- DiscUnif.cc Erlang.cc Fix.cc Fix16.cc Fix24.cc Geom.cc GetOpt.cc \
- HypGeom.cc Intdouble.cc Integer.cc LogNorm.cc MLCG.cc NegExp.cc \
- Normal.cc Obstack.cc Poisson.cc RNG.cc Random.cc Rational.cc \
- Regex.cc RndInt.cc SLList.cc SmplHist.cc SmplStat.cc String.cc \
- Uniform.cc Weibull.cc \
- builtin.cc compare.cc error.cc fmtq.cc gcd.cc hash.cc ioob.cc \
- lg.cc pow.cc sqrt.cc
-
-# "normal" headers (no CursesW.h[its useless], no bool.h[in stdc++])
-HDRS= ACG.h AllocRing.h Binomial.h BitSet.h BitString.h Complex.h \
- DLList.h DiscUnif.h Erlang.h Fix.h Fix16.h Fix24.h Geom.h GetOpt.h \
- HypGeom.h Incremental.h Integer.h LogNorm.h MLCG.h NegExp.h Normal.h \
- Obstack.h Pix.h Poisson.h RNG.h Random.h Rational.h Regex.h RndInt.h \
- SLList.h SmplHist.h SmplStat.h String.h Uniform.h Weibull.h \
- bitdo1.h bitdo2.h bitprims.h builtin.h compare.h generic.h \
- getpagesize.h libc.h minmax.h osfcn.h std.h strclass.h swap.h \
- sysent.h typemacros.h
-
-beforeinstall:
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${HDRS:S;^;${GPPDIR}/libg++/src/;} \
- ${GPPDIR}/librx/rx.h \
- ${DESTDIR}/usr/include/g++
-
-.include <bsd.lib.mk>
diff --git a/gnu/lib/libg++/doc/Makefile b/gnu/lib/libg++/doc/Makefile
deleted file mode 100644
index 753ea8e..0000000
--- a/gnu/lib/libg++/doc/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# $Id$
-
-INFO = g++FAQ libg++ iostream
-INFOSECTION= "Gcc Documentation"
-INFOENTRY_g++FAQ= "* G++FAQ: (g++FAQ). The GNU G++ FAQ."
-
-.PATH: ${.CURDIR}/../../../../contrib/libg++/libg++
-.PATH: ${.CURDIR}/../../../../contrib/libg++/libio
-
-# HACK ALERT!
-CLEANFILES+= lgpl.texinfo
-libg++.info: lgpl.texinfo
-lgpl.texinfo:
- echo "See the file: /usr/src/gnu/COPYING.LIB" > lgpl.texinfo
-
-.include <bsd.info.mk>
diff --git a/gnu/lib/libgcc/Makefile b/gnu/lib/libgcc/Makefile
deleted file mode 100644
index f9a1c3d..0000000
--- a/gnu/lib/libgcc/Makefile
+++ /dev/null
@@ -1,95 +0,0 @@
-#
-# $Id$
-#
-
-LIB= gcc
-
-# Install libgcc_pic.a, since ld.so uses it.
-INSTALL_PIC_ARCHIVE= yes
-
-#
-# XXX This is a hack, but it seems to work. libgcc1.a is supposed to be
-# compiled by the native compiler, and libgcc2.a is meant to be compiled
-# by *this* version of gcc.
-#
-# Normally, this does not make any difference, since we only have gcc, but
-# when bootstrapping from gcc-2.6.3, we have to use the freshly built 2.7.2
-# compiler for some of the libgcc2.c __attribute__ stuff.
-#
-.if exists(${.OBJDIR}/../cc)
-XCC= ${.OBJDIR}/../cc/cc
-.else
-XCC= ${.CURDIR}/../cc/cc
-.endif
-
-.if exists(${.OBJDIR}/../cc1)
-XCC+= -B${.OBJDIR}/../cc1/
-.else
-XCC+= -B${.CURDIR}/../cc1/
-.endif
-
-.if exists(${.OBJDIR}/../cpp)
-XCC+= -B${.OBJDIR}/../cpp/
-.else
-XCC+= -B${.CURDIR}/../cpp/
-.endif
-
-# Members of libgcc1.a.
-LIB1FUNCS= _mulsi3 _udivsi3 _divsi3 _umodsi3 _modsi3 \
- _lshrsi3 _ashrsi3 _ashlsi3 \
- _divdf3 _muldf3 _negdf2 _adddf3 _subdf3 \
- _fixdfsi _fixsfsi _floatsidf _floatsisf _truncdfsf2 _extendsfdf2 \
- _addsf3 _negsf2 _subsf3 _mulsf3 _divsf3 \
- _eqdf2 _nedf2 _gtdf2 _gedf2 _ltdf2 _ledf2 \
- _eqsf2 _nesf2 _gtsf2 _gesf2 _ltsf2 _lesf2
-
-# Library members defined in libgcc2.c.
-LIB2FUNCS= _muldi3 _divdi3 _moddi3 _udivdi3 _umoddi3 _negdi2 \
- _lshrdi3 _ashldi3 _ashrdi3 _ffsdi2 \
- _udiv_w_sdiv _udivmoddi4 _cmpdi2 _ucmpdi2 _floatdidf _floatdisf \
- _fixunsdfsi _fixunssfsi _fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi \
- _fixxfdi _fixunsxfdi _floatdixf _fixunsxfsi \
- _fixtfdi _fixunstfdi _floatditf \
- __gcc_bcmp _varargs _eprintf _op_new _op_vnew _new_handler \
- _op_delete \
- _op_vdel _bb _shtab _clear_cache _trampoline __main _exit _ctors \
- _eh _pure
-
-LIB1OBJS=${LIB1FUNCS:T:S@$@.o@}
-LIB2OBJS=${LIB2FUNCS:T:S@$@.o@}
-LIB1SOBJS=${LIB1FUNCS:T:S@$@.so@}
-LIB2SOBJS=${LIB2FUNCS:T:S@$@.so@}
-P1OBJS=${LIB1FUNCS:T:S@$@.po@}
-P2OBJS=${LIB2FUNCS:T:S@$@.po@}
-
-OBJS= ${LIB1OBJS} ${LIB2OBJS}
-
-${LIB1OBJS}: libgcc1.c
- ${CC} -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc1.c
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-${LIB2OBJS}: libgcc2.c
- ${XCC} -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc2.c
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-.if !defined(NOPIC)
-${LIB1SOBJS}: libgcc1.c
- ${CC} -c -fpic ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc1.c
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-${LIB2SOBJS}: libgcc2.c
- ${XCC} -c -fpic ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc2.c
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-.endif
-
-.if !defined(NOPROFILE)
-${P1OBJS}: libgcc1.c
- ${CC} -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc1.c
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-
-${P2OBJS}: libgcc2.c
- ${XCC} -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc2.c
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-.endif
-
-.include <bsd.lib.mk>
diff --git a/gnu/lib/libgmp/Makefile b/gnu/lib/libgmp/Makefile
deleted file mode 100644
index c7b0c8a..0000000
--- a/gnu/lib/libgmp/Makefile
+++ /dev/null
@@ -1,119 +0,0 @@
-#
-# $Id: Makefile,v 1.13 1997/08/21 15:51:51 bde Exp $
-#
-
-LIB= gmp
-
-SUBDIR= doc
-
-GMPDIR= ${.CURDIR}/../../../contrib/libgmp
-.PATH: ${GMPDIR} ${GMPDIR}/mpn ${GMPDIR}/mpn/x86 ${GMPDIR}/mpn/generic
-
-CFLAGS+= -I${GMPDIR} -I${GMPDIR}/mpn/generic -I${GMPDIR}/mpn/x86
-
-MPN_SRC_C= inlines.c cmp.c divmod_1.c divrem.c divrem_1.c dump.c \
- mod_1.c mul.c mul_n.c random2.c sqrtrem.c get_str.c set_str.c \
- scan0.c scan1.c popcount.c hamdist.c gcd_1.c pre_mod_1.c \
- perfsqr.c bdivmod.c gcd.c gcdext.c mp_bases.c
-
-MPN_SRC_ASM= add_n.S addmul_1.S lshift.S mul_1.S rshift.S sub_n.S submul_1.S
-
-MPN_SRCS= ${MPN_SRC_C} ${MPN_SRC_ASM}
-
-MPZ_SRCS= mpz/init.c mpz/set.c mpz/set_ui.c mpz/set_si.c mpz/set_str.c \
- mpz/set_d.c mpz/set_f.c mpz/set_q.c mpz/iset.c mpz/iset_ui.c \
- mpz/iset_si.c mpz/iset_str.c mpz/iset_d.c mpz/clear.c \
- mpz/get_ui.c mpz/get_si.c mpz/get_str.c mpz/get_d.c \
- mpz/size.c mpz/sizeinbase.c mpz/add.c mpz/add_ui.c \
- mpz/sub.c mpz/sub_ui.c mpz/mul.c mpz/mul_ui.c mpz/gcd.c \
- mpz/gcd_ui.c mpz/gcdext.c mpz/sqrt.c mpz/sqrtrem.c \
- mpz/powm.c mpz/powm_ui.c mpz/cmp.c mpz/cmp_ui.c mpz/cmp_si.c \
- mpz/mul_2exp.c mpz/fdiv_q_2exp.c mpz/fdiv_r_2exp.c \
- mpz/tdiv_q_2exp.c mpz/tdiv_r_2exp.c mpz/abs.c mpz/neg.c \
- mpz/com.c mpz/and.c mpz/ior.c mpz/inp_raw.c mpz/inp_str.c \
- mpz/out_raw.c mpz/out_str.c mpz/perfsqr.c mpz/random.c \
- mpz/random2.c mpz/pow_ui.c mpz/ui_pow_ui.c mpz/setbit.c \
- mpz/clrbit.c mpz/fac_ui.c mpz/pprime_p.c mpz/realloc.c \
- mpz/getlimbn.c mpz/popcount.c mpz/hamdist.c mpz/cdiv_qr.c \
- mpz/cdiv_q.c mpz/cdiv_r.c mpz/cdiv_qr_ui.c mpz/cdiv_q_ui.c \
- mpz/cdiv_r_ui.c mpz/cdiv_ui.c mpz/fdiv_qr.c mpz/fdiv_q.c \
- mpz/fdiv_r.c mpz/fdiv_qr_ui.c mpz/fdiv_q_ui.c mpz/fdiv_r_ui.c \
- mpz/fdiv_ui.c mpz/tdiv_qr.c mpz/tdiv_q.c mpz/tdiv_r.c \
- mpz/tdiv_qr_ui.c mpz/tdiv_q_ui.c mpz/tdiv_r_ui.c mpz/mod.c \
- mpz/divexact.c mpz/array_init.c mpz/scan0.c mpz/scan1.c \
- mpz/jacobi.c mpz/legendre.c mpz/invert.c
-
-MPF_SRCS= mpf/init.c mpf/init2.c mpf/set.c mpf/set_ui.c mpf/set_si.c \
- mpf/set_str.c mpf/set_d.c mpf/set_z.c mpf/iset.c \
- mpf/iset_ui.c mpf/iset_si.c mpf/iset_str.c mpf/iset_d.c \
- mpf/clear.c mpf/get_str.c mpf/dump.c mpf/size.c mpf/eq.c \
- mpf/reldiff.c mpf/sqrt.c mpf/random2.c mpf/inp_str.c \
- mpf/out_str.c mpf/add.c mpf/add_ui.c mpf/sub.c mpf/sub_ui.c \
- mpf/ui_sub.c mpf/mul.c mpf/mul_ui.c mpf/div.c mpf/div_ui.c \
- mpf/cmp.c mpf/cmp_ui.c mpf/cmp_si.c mpf/mul_2exp.c \
- mpf/div_2exp.c mpf/abs.c mpf/neg.c mpf/set_q.c mpf/get_d.c \
- mpf/set_dfl_prec.c mpf/set_prc.c mpf/set_prc_raw.c \
- mpf/get_prc.c mpf/ui_div.c mpf/sqrt_ui.c
-
-MPQ_SRCS= mpq/add.c mpq/canonicalize.c mpq/clear.c mpq/cmp.c \
- mpq/cmp_ui.c mpq/div.c mpq/get_d.c mpq/get_den.c mpq/get_num.c \
- mpq/init.c mpq/inv.c mpq/mul.c mpq/neg.c mpq/set.c \
- mpq/set_den.c mpq/set_num.c mpq/set_si.c mpq/set_ui.c \
- mpq/sub.c mpq/equal.c mpq/set_z.c
-
-SRCS= memory.c mp_set_fns.c mp_clz_tab.c version.c stack-alloc.c mp_bpl.c \
- extract-double.c insert-double.c \
- ${MPN_SRCS} ${MPZ_SRCS} ${MPF_SRCS} ${MPQ_SRCS}
-
-.if defined(BINFORMAT) && ${BINFORMAT} == elf
-
-sysdep.h: ${GMPDIR}/mpn/sysv.h
- cp ${GMPDIR}/mpn/sysv.h sysdep.h
-
-asm-syntax.h:
- (echo "#define ELF_SYNTAX" ; \
- echo "#include \"syntax.h\"") > asm-syntax.h
-.else
-
-sysdep.h: ${GMPDIR}/mpn/bsd.h
- cp ${GMPDIR}/mpn/bsd.h sysdep.h
-
-asm-syntax.h:
- (echo "#define BSD_SYNTAX" ; \
- echo "#include \"syntax.h\"") > asm-syntax.h
-
-CFLAGS+= -DBROKEN_ALIGN
-
-.endif
-
-beforedepend all: mpz mpf mpq sysdep.h asm-syntax.h
-
-CLEANFILES+= sysdep.h asm-syntax.h
-
-# Grrr. This package contains modules in separate subdirs that have the
-# same name. Nasty hack to keep them from being found by being in
-# .PATH:s
-#
-mpz mpf mpq:
- mkdir ${.TARGET}
-
-CLEANDIRS+= ${.OBJDIR}/mpz ${.CURDIR}/mpz \
- ${.OBJDIR}/mpf ${.CURDIR}/mpf \
- ${.OBJDIR}/mpq ${.CURDIR}/mpq
-
-beforeinstall:
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${GMPDIR}/gmp.h ${DESTDIR}/usr/include
-
-.S.o:
- ${CC} ${SFLAGS} ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET}
-
-.S.po:
- ${CC} -DPROF ${SFLAGS} ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET}
-
-.S.so:
- ${CC} -fpic -DPIC ${SFLAGS} ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-.include "Makefile.inc"
-.include <bsd.lib.mk>
diff --git a/gnu/lib/libgmp/Makefile.inc b/gnu/lib/libgmp/Makefile.inc
deleted file mode 100644
index b60fe3c..0000000
--- a/gnu/lib/libgmp/Makefile.inc
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# $Id$
-#
-
-SHLIB_MAJOR= 3
-SHLIB_MINOR= 0
-
-.if exists(${.OBJDIR})
-CFLAGS+= -I${.OBJDIR}
-.else
-CFLAGS+= -I${.CURDIR}
-.endif
diff --git a/gnu/lib/libgmp/doc/Makefile b/gnu/lib/libgmp/doc/Makefile
deleted file mode 100644
index dde32e5..0000000
--- a/gnu/lib/libgmp/doc/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# $Id$
-#
-INFO = gmp
-INFOSECTION= "Programming & development tools."
-
-SRCDIR= ${.CURDIR}/../../../../contrib/libgmp
-
-.include <bsd.info.mk>
diff --git a/gnu/lib/libmp/Makefile b/gnu/lib/libmp/Makefile
deleted file mode 100644
index 0839f0b..0000000
--- a/gnu/lib/libmp/Makefile
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# $Id: Makefile,v 1.11 1997/04/10 16:33:32 bde Exp $
-#
-
-LIB= mp
-
-GMPDIR= ${.CURDIR}/../../../contrib/libgmp
-.PATH: ${GMPDIR} ${GMPDIR}/mpn ${GMPDIR}/mpn/x86 ${GMPDIR}/mpn/generic \
- ${GMPDIR}/mpbsd
-
-CFLAGS+= -I${GMPDIR} -I${GMPDIR}/mpn/generic -I${GMPDIR}/mpn/x86 \
- -I${GMPDIR}/mpz -DBERKELEY_MP
-
-MPN_SRC_C= inlines.c cmp.c divmod_1.c divrem.c divrem_1.c dump.c \
- mod_1.c mul.c mul_n.c random2.c sqrtrem.c get_str.c set_str.c \
- scan0.c scan1.c popcount.c hamdist.c gcd_1.c pre_mod_1.c \
- perfsqr.c bdivmod.c gcd.c gcdext.c mp_bases.c
-
-MPN_SRC_ASM= add_n.S addmul_1.S lshift.S mul_1.S rshift.S sub_n.S submul_1.S
-
-MPN_SRCS= ${MPN_SRC_C} ${MPN_SRC_ASM}
-
-MPBSD_LINKS= mpz/add.c mpz/cmp.c mpz/gcd.c mpz/mul.c mpz/pow_ui.c \
- mpz/powm.c mpz/sqrtrem.c mpz/sub.c mpz/realloc.c
-MPBSD_SRCS= itom.c mdiv.c mfree.c min.c mout.c move.c mtox.c sdiv.c xtom.c \
- realloc.c $(MPBSD_LINKS)
-
-SRCS= memory.c mp_set_fns.c mp_clz_tab.c version.c stack-alloc.c \
- mp_bpl.c extract-double.c insert-double.c \
- ${MPN_SRCS} ${MPBSD_SRCS}
-
-beforedepend all: mpz sysdep.h asm-syntax.h
-
-.if defined(BINFORMAT) && ${BINFORMAT} == elf
-
-sysdep.h: ${GMPDIR}/mpn/sysv.h
- cp ${GMPDIR}/mpn/sysv.h sysdep.h
-
-asm-syntax.h:
- (echo "#define ELF_SYNTAX" ; \
- echo "#include \"syntax.h\"") > asm-syntax.h
-.else
-
-sysdep.h: ${GMPDIR}/mpn/bsd.h
- cp ${GMPDIR}/mpn/bsd.h sysdep.h
-
-asm-syntax.h:
- (echo "#define BSD_SYNTAX" ; \
- echo "#include \"syntax.h\"") > asm-syntax.h
-
-CFLAGS+= -DBROKEN_ALIGN
-
-.endif
-
-CLEANFILES+= sysdep.h asm-syntax.h
-
-# Grrr. This package contains modules in separate subdirs that have the
-# same name. Nasty hack to keep them from being found by being in
-# .PATH:s
-#
-mpz:
- mkdir ${.TARGET}
-
-CLEANDIRS+= ${.OBJDIR}/mpz ${.CURDIR}/mpz
-
-beforeinstall:
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${GMPDIR}/mp.h ${DESTDIR}/usr/include
-
-.include "../libgmp/Makefile.inc"
-.include <bsd.lib.mk>
diff --git a/gnu/lib/libobjc/Makefile b/gnu/lib/libobjc/Makefile
deleted file mode 100644
index 2083d23..0000000
--- a/gnu/lib/libobjc/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-# Makefile for libobjc
-# $Id$
-
-GCCDIR= ${.CURDIR}/../../../contrib/gcc
-
-.PATH: ${GCCDIR}/objc
-
-LIB= objc
-NOMAN= sorry
-NOPIC= does not work
-
-SRCS= archive.c class.c encoding.c hash.c init.c misc.c \
- my_objects.c sarray.c selector.c my_sendmsg.c \
- NXConstStr.m Object.m Protocol.m
-
-HDRS= encoding.h hash.h list.h objc-api.h objc.h sarray.h typedstream.h \
- NXConstStr.h Object.h Protocol.h
-
-CFLAGS+= -I${GCCDIR}/objc -I${GCCDIR}
-
-beforeinstall:
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${HDRS:S;^;${GCCDIR}/objc/;} ${DESTDIR}/usr/include/objc
-
-my_objects.c: objects.c
- sed -e '/\.\.\/tconfig.h/d' < ${GCCDIR}/objc/objects.c > my_objects.c
-
-my_sendmsg.c: sendmsg.c
- sed -e '/\.\.\/tconfig.h/d' < ${GCCDIR}/objc/sendmsg.c > my_sendmsg.c
-
-CLEANFILES+= my_objects.c my_sendmsg.c
-
-.include <bsd.lib.mk>
diff --git a/gnu/lib/libreadline/Makefile b/gnu/lib/libreadline/Makefile
deleted file mode 100644
index 3630ab4..0000000
--- a/gnu/lib/libreadline/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-# $Id: Makefile,v 1.28 1997/02/22 15:43:04 peter Exp $
-
-SRCDIR= ${.CURDIR}/../../../contrib/libreadline
-.PATH: ${SRCDIR}
-
-SUBDIR= doc
-
-LIB= readline
-SHLIB_MAJOR= 3
-SHLIB_MINOR= 0
-MAN3= readline.3
-
-RL_LIBRARY_VERSION = 2.1
-LOCAL_CFLAGS= -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
-CFLAGS+= -I${.CURDIR} -I${SRCDIR} -DHAVE_CONFIG_H ${LOCAL_CFLAGS}
-
-HISTSRC= history.c histexpand.c histfile.c histsearch.c shell.c
-TILDESRC= tilde.c
-SRCS= readline.c vi_mode.c funmap.c keymaps.c parens.c search.c \
- rltty.c complete.c bind.c isearch.c display.c signals.c \
- util.c kill.c undo.c macro.c input.c callback.c terminal.c \
- nls.c xmalloc.c \
- $(HISTSRC) $(TILDESRC)
-
-INSTALLED_HEADERS= readline.h chardefs.h keymaps.h history.h tilde.h
-
-DPADD+= $(LIBTERMCAP)
-LDADD+= -ltermcap
-
-beforeinstall:
-.for i in ${INSTALLED_HEADERS}
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${SRCDIR}/$i \
- ${DESTDIR}/usr/include/readline
-.endfor
-
-.include <bsd.lib.mk>
diff --git a/gnu/lib/libreadline/config.h b/gnu/lib/libreadline/config.h
deleted file mode 100644
index 08f4a0e..0000000
--- a/gnu/lib/libreadline/config.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define as the return type of signal handlers (int or void). */
-#define RETSIGTYPE void
-
-/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-#define VOID_SIGHANDLER 1
-
-/* Define if you have the lstat function. */
-#define HAVE_LSTAT 1
-
-/* Define if you have the putenv function. */
-#define HAVE_PUTENV 1
-
-/* Define if you have the select function. */
-#define HAVE_SELECT 1
-
-/* Define if you have the setenv function. */
-#define HAVE_SETENV 1
-
-/* Define if you have the strcasecmp function. */
-#define HAVE_STRCASECMP 1
-
-/* Define if you have the setlocale function. */
-#define HAVE_SETLOCALE 1
-
-/* Define if you have the tcgetattr function. */
-#define HAVE_TCGETATTR 1
-
-/* Define if you have the strcoll function. */
-#define HAVE_STRCOLL 1
-
-/* #undef STRCOLL_BROKEN */
-
-/* Define if you have the <dirent.h> header file. */
-#define HAVE_DIRENT_H 1
-
-/* Define if you have the <ndir.h> header file. */
-/* #undef HAVE_NDIR_H */
-
-/* Define if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <sys/dir.h> header file. */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define if you have the <sys/file.h> header file. */
-#define HAVE_SYS_FILE_H 1
-
-/* Define if you have the <sys/ndir.h> header file. */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define if you have the <sys/pte.h> header file. */
-/* #undef HAVE_SYS_PTE_H */
-
-/* Define if you have the <sys/ptem.h> header file. */
-/* #undef HAVE_SYS_PTEM_H */
-
-/* Define if you have the <sys/select.h> header file. */
-#define HAVE_SYS_SELECT_H 1
-
-/* Define if you have the <sys/stream.h> header file. */
-/* #undef HAVE_SYS_STREAM_H */
-
-/* Define if you have the <termcap.h> header file. */
-#define HAVE_TERMCAP_H 1
-
-/* Define if you have the <termio.h> header file. */
-/* #undef HAVE_TERMIO_H */
-
-/* Define if you have the <termios.h> header file. */
-#define HAVE_TERMIOS_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the <varargs.h> header file. */
-#define HAVE_VARARGS_H 1
-
-/* Define if you have the <stdarg.h> header file. */
-#define HAVE_STDARG_H 1
-
-#define HAVE_LOCALE_H 1
-
-/* Definitions pulled in from aclocal.m4. */
-#define VOID_SIGHANDLER 1
-
-#define GWINSZ_IN_SYS_IOCTL 1
-
-#define TIOCSTAT_IN_SYS_IOCTL 1
-
-#define FIONREAD_IN_SYS_IOCTL 1
-
-/* #undef SPEED_T_IN_SYS_TYPES */
-
-#define HAVE_GETPW_DECLS 1
-
-#define STRUCT_DIRENT_HAS_D_INO 1
-
-#define STRUCT_DIRENT_HAS_D_FILENO 1
-
-/* #undef HAVE_BSD_SIGNALS */
-
-#define HAVE_POSIX_SIGNALS 1
-
-/* #undef HAVE_USG_SIGHOLD */
-
-/* #undef MUST_REINSTALL_SIGHANDLERS */
-
-#define HAVE_POSIX_SIGSETJMP 1
-
-/* config.h.bot */
-/* modify settings or make new ones based on what autoconf tells us. */
-
-/* Ultrix botches type-ahead when switching from canonical to
- non-canonical mode, at least through version 4.3 */
-#if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix)
-# define TERMIOS_MISSING
-#endif
-
-#if defined (STRCOLL_BROKEN)
-# define HAVE_STRCOLL 1
-#endif
-
-#if defined (__STDC__) && defined (HAVE_STDARG_H)
-# define PREFER_STDARG
-# define USE_VARARGS
-#else
-# if defined (HAVE_VARARGS_H)
-# define PREFER_VARARGS
-# define USE_VARARGS
-# endif
-#endif
diff --git a/gnu/lib/libreadline/doc/Makefile b/gnu/lib/libreadline/doc/Makefile
deleted file mode 100644
index 3fa54b6..0000000
--- a/gnu/lib/libreadline/doc/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $Id$
-
-SUBDIR = history readline
-
-.include <bsd.subdir.mk>
diff --git a/gnu/lib/libreadline/doc/history/Makefile b/gnu/lib/libreadline/doc/history/Makefile
deleted file mode 100644
index 4b8112a..0000000
--- a/gnu/lib/libreadline/doc/history/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $Id$
-
-SRCDIR= ${.CURDIR}/../../../../../contrib/libreadline/doc
-
-INFO = history
-
-INFOSECTION= "Programming & development tools."
-INFOENTRY_history= "* History: (history). The GNU History library."
-
-SRCS= hist.texinfo
-
-history.info: hist.texinfo hstech.texinfo hsuser.texinfo
-
-.include <bsd.info.mk>
diff --git a/gnu/lib/libreadline/doc/readline/Makefile b/gnu/lib/libreadline/doc/readline/Makefile
deleted file mode 100644
index 8e51041..0000000
--- a/gnu/lib/libreadline/doc/readline/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $Id$
-
-SRCDIR= ${.CURDIR}/../../../../../contrib/libreadline/doc
-
-INFO = readline
-
-INFOSECTION= "Programming & development tools."
-INFOENTRY_readline= "* Readline: (readline). The GNU Readline library"
-
-SRCS= rlman.texinfo
-
-readline.info: rlman.texinfo rltech.texinfo rluser.texinfo
-
-.include <bsd.info.mk>
diff --git a/gnu/lib/libregex/AUTHORS b/gnu/lib/libregex/AUTHORS
deleted file mode 100644
index 058be99..0000000
--- a/gnu/lib/libregex/AUTHORS
+++ /dev/null
@@ -1,10 +0,0 @@
-Richard Stallman -- original version and continuing revisions of
- regex.c and regex.h, and original version of the documentation.
-
-Karl Berry and Kathryn Hargreaves -- extensive modifications to above,
- and all test files.
-
-Jim Blandy -- original version of re_set_registers, revisions to regex.c.
-
-Joe Arceneaux, David MacKenzie, Mike Haertel, Charles Hannum, and
-probably others -- revisions to regex.c.
diff --git a/gnu/lib/libregex/COPYING b/gnu/lib/libregex/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/lib/libregex/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/lib/libregex/ChangeLog b/gnu/lib/libregex/ChangeLog
deleted file mode 100644
index ef919d2..0000000
--- a/gnu/lib/libregex/ChangeLog
+++ /dev/null
@@ -1,3030 +0,0 @@
-Fri Apr 2 17:31:59 1993 Jim Blandy (jimb@totoro.cs.oberlin.edu)
-
- * Released version 0.12.
-
- * regex.c (regerror): If errcode is zero, that's not a valid
- error code, according to POSIX, but return "Success."
-
- * regex.c (regerror): Remember to actually fetch the message
- from re_error_msg.
-
- * regex.c (regex_compile): Don't use the trick for ".*\n" on
- ".+\n". Since the latter involves laying an extra choice
- point, the backward jump isn't adjusted properly.
-
-Thu Mar 25 21:35:18 1993 Jim Blandy (jimb@totoro.cs.oberlin.edu)
-
- * regex.c (regex_compile): In the handle_open and handle_close
- sections, clear pending_exact to zero.
-
-Tue Mar 9 12:03:07 1993 Jim Blandy (jimb@wookumz.gnu.ai.mit.edu)
-
- * regex.c (re_search_2): In the loop which searches forward
- using fastmap, don't forget to cast the character from the
- string to an unsigned before using it as an index into the
- translate map.
-
-Thu Jan 14 15:41:46 1993 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu)
-
- * regex.h: Never define const; let the callers do it.
- configure.in: Don't define USING_AUTOCONF.
-
-Wed Jan 6 20:49:29 1993 Jim Blandy (jimb@geech.gnu.ai.mit.edu)
-
- * regex.c (regerror): Abort if ERRCODE is out of range.
-
-Sun Dec 20 16:19:10 1992 Jim Blandy (jimb@totoro.cs.oberlin.edu)
-
- * configure.in: Arrange to #define USING_AUTOCONF.
- * regex.h: If USING_AUTOCONF is #defined, don't mess with
- `const' at all; autoconf has taken care of it.
-
-Mon Dec 14 21:40:39 1992 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu)
-
- * regex.h (RE_SYNTAX_AWK): Fix typo. From Arnold Robbins.
-
-Sun Dec 13 20:35:39 1992 Jim Blandy (jimb@totoro.cs.oberlin.edu)
-
- * regex.c (compile_range): Fetch the range start and end by
- casting the pattern pointer to an `unsigned char *' before
- fetching through it.
-
-Sat Dec 12 09:41:01 1992 Jim Blandy (jimb@totoro.cs.oberlin.edu)
-
- * regex.c: Undo change of 12/7/92; it's better for Emacs to
- #define HAVE_CONFIG_H.
-
-Fri Dec 11 22:00:34 1992 Jim Meyering (meyering@hal.gnu.ai.mit.edu)
-
- * regex.c: Define and use isascii-protected ctype.h macros.
-
-Fri Dec 11 05:10:38 1992 Jim Blandy (jimb@totoro.cs.oberlin.edu)
-
- * regex.c (re_match_2): Undo Karl's November 10th change; it
- keeps the group in :\(.*\) from matching :/ properly.
-
-Mon Dec 7 19:44:56 1992 Jim Blandy (jimb@wookumz.gnu.ai.mit.edu)
-
- * regex.c: #include config.h if either HAVE_CONFIG_H or emacs
- is #defined.
-
-Tue Dec 1 13:33:17 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
-
- * regex.c [HAVE_CONFIG_H]: Include config.h.
-
-Wed Nov 25 23:46:02 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
-
- * regex.c (regcomp): Add parens around bitwise & for clarity.
- Initialize preg->allocated to prevent segv.
-
-Tue Nov 24 09:22:29 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
-
- * regex.c: Use HAVE_STRING_H, not USG.
- * configure.in: Check for string.h, not USG.
-
-Fri Nov 20 06:33:24 1992 Karl Berry (karl@cs.umb.edu)
-
- * regex.c (SIGN_EXTEND_CHAR) [VMS]: Back out of this change,
- since Roland Roberts now says it was a localism.
-
-Mon Nov 16 07:01:36 1992 Karl Berry (karl@cs.umb.edu)
-
- * regex.h (const) [!HAVE_CONST]: Test another cpp symbol (from
- Autoconf) before zapping const.
-
-Sun Nov 15 05:36:42 1992 Jim Blandy (jimb@wookumz.gnu.ai.mit.edu)
-
- * regex.c, regex.h: Changes for VMS from Roland B Roberts
- <roberts@nsrl31.nsrl.rochester.edu>.
-
-Thu Nov 12 11:31:15 1992 Karl Berry (karl@cs.umb.edu)
-
- * Makefile.in (distfiles): Include INSTALL.
-
-Tue Nov 10 09:29:23 1992 Karl Berry (karl@cs.umb.edu)
-
- * regex.c (re_match_2): At maybe_pop_jump, if at end of string
- and pattern, just quit the matching loop.
-
- * regex.c (LETTER_P): Rename to `WORDCHAR_P'.
-
- * regex.c (AT_STRINGS_{BEG,END}): Take `d' as an arg; change
- callers.
-
- * regex.c (re_match_2) [!emacs]: In wordchar and notwordchar
- cases, advance d.
-
-Wed Nov 4 15:43:58 1992 Karl Berry (karl@hal.gnu.ai.mit.edu)
-
- * regex.h (const) [!__STDC__]: Don't define if it's already defined.
-
-Sat Oct 17 19:28:19 1992 Karl Berry (karl@cs.umb.edu)
-
- * regex.c (bcmp, bcopy, bzero): Only #define if they are not
- already #defined.
-
- * configure.in: Use AC_CONST.
-
-Thu Oct 15 08:39:06 1992 Karl Berry (karl@cs.umb.edu)
-
- * regex.h (const) [!const]: Conditionalize.
-
-Fri Oct 2 13:31:42 1992 Karl Berry (karl@cs.umb.edu)
-
- * regex.h (RE_SYNTAX_ED): New definition.
-
-Sun Sep 20 12:53:39 1992 Karl Berry (karl@cs.umb.edu)
-
- * regex.[ch]: remove traces of `longest_p' -- dumb idea to put
- this into the pattern buffer, as it means parallelism loses.
-
- * Makefile.in (config.status): use sh to run configure --no-create.
-
- * Makefile.in (realclean): OK, don't remove configure.
-
-Sat Sep 19 09:05:08 1992 Karl Berry (karl@hayley)
-
- * regex.c (PUSH_FAILURE_POINT, POP_FAILURE_POINT) [DEBUG]: keep
- track of how many failure points we push and pop.
- (re_match_2) [DEBUG]: declare variables for that, and print results.
- (DEBUG_PRINT4): new macro.
-
- * regex.h (re_pattern_buffer): new field `longest_p' (to
- eliminate backtracking if the user doesn't need it).
- * regex.c (re_compile_pattern): initialize it (to 1).
- (re_search_2): set it to zero if register information is not needed.
- (re_match_2): if it's set, don't backtrack.
-
- * regex.c (re_search_2): update fastmap only after checking that
- the pattern is anchored.
-
- * regex.c (re_match_2): do more debugging at maybe_pop_jump.
-
- * regex.c (re_search_2): cast result of TRANSLATE for use in
- array subscript.
-
-Thu Sep 17 19:47:16 1992 Karl Berry (karl@geech.gnu.ai.mit.edu)
-
- * Version 0.11.
-
-Wed Sep 16 08:17:10 1992 Karl Berry (karl@hayley)
-
- * regex.c (INIT_FAIL_STACK): rewrite as statements instead of a
- complicated comma expr, to avoid compiler warnings (and also
- simplify).
- (re_compile_fastmap, re_match_2): change callers.
-
- * regex.c (POP_FAILURE_POINT): cast pop of regstart and regend
- to avoid compiler warnings.
-
- * regex.h (RE_NEWLINE_ORDINARY): remove this syntax bit, and
- remove uses.
- * regex.c (at_{beg,end}line_loc_p): go the last mile: remove
- the RE_NEWLINE_ORDINARY case which made the ^ in \n^ be an anchor.
-
-Tue Sep 15 09:55:29 1992 Karl Berry (karl@hayley)
-
- * regex.c (at_begline_loc_p): new fn.
- (at_endline_loc_p): simplify at_endline_op_p.
- (regex_compile): in ^/$ cases, call the above.
-
- * regex.c (POP_FAILURE_POINT): rewrite the fn as a macro again,
- as lord's profiling indicates the function is 20% of the time.
- (re_match_2): callers changed.
-
- * configure.in (AC_MEMORY_H): remove, since we never use memcpy et al.
-
-Mon Sep 14 17:49:27 1992 Karl Berry (karl@hayley)
-
- * Makefile.in (makeargs): include MFLAGS.
-
-Sun Sep 13 07:41:45 1992 Karl Berry (karl@hayley)
-
- * regex.c (regex_compile): in \1..\9 case, make it always
- invalid to use \<digit> if there is no preceding <digit>th subexpr.
- * regex.h (RE_NO_MISSING_BK_REF): remove this syntax bit.
-
- * regex.c (regex_compile): remove support for invalid empty groups.
- * regex.h (RE_NO_EMPTY_GROUPS): remove this syntax bit.
-
- * regex.c (FREE_VARIABLES) [!REGEX_MALLOC]: define as alloca (0),
- to reclaim memory.
-
- * regex.h (RE_SYNTAX_POSIX_SED): don't bother with this.
-
-Sat Sep 12 13:37:21 1992 Karl Berry (karl@hayley)
-
- * README: incorporate emacs.diff.
-
- * regex.h (_RE_ARGS) [!__STDC__]: define as empty parens.
-
- * configure.in: add AC_ALLOCA.
-
- * Put test files in subdir test, documentation in subdir doc.
- Adjust Makefile.in and configure.in accordingly.
-
-Thu Sep 10 10:29:11 1992 Karl Berry (karl@hayley)
-
- * regex.h (RE_SYNTAX_{POSIX_,}SED): new definitions.
-
-Wed Sep 9 06:27:09 1992 Karl Berry (karl@hayley)
-
- * Version 0.10.
-
-Tue Sep 8 07:32:30 1992 Karl Berry (karl@hayley)
-
- * xregex.texinfo: put the day of month into the date.
-
- * Makefile.in (realclean): remove Texinfo-generated files.
- (distclean): remove empty sorted index files.
- (clean): remove dvi files, etc.
-
- * configure.in: test for more Unix variants.
-
- * fileregex.c: new file.
- Makefile.in (fileregex): new target.
-
- * iregex.c (main): move variable decls to smallest scope.
-
- * regex.c (FREE_VARIABLES): free reg_{,info_}dummy.
- (re_match_2): check that the allocation for those two succeeded.
-
- * regex.c (FREE_VAR): replace FREE_NONNULL with this.
- (FREE_VARIABLES): call it.
- (re_match_2) [REGEX_MALLOC]: initialize all our vars to NULL.
-
- * tregress.c (do_match): generalize simple_match.
- (SIMPLE_NONMATCH): new macro.
- (SIMPLE_MATCH): change from routine.
-
- * Makefile.in (regex.texinfo): make file readonly, so we don't
- edit it by mistake.
-
- * many files (re_default_syntax): rename to `re_syntax_options';
- call re_set_syntax instead of assigning to the variable where
- possible.
-
-Mon Sep 7 10:12:16 1992 Karl Berry (karl@hayley)
-
- * syntax.skel: don't use prototypes.
-
- * {configure,Makefile}.in: new files.
-
- * regex.c: include <string.h> `#if USG || STDC_HEADERS'; remove
- obsolete test for `POSIX', and test for BSRTING.
- Include <strings.h> if we are not USG or STDC_HEADERS.
- Do not include <unistd.h>. What did we ever need that for?
-
- * regex.h (RE_NO_EMPTY_ALTS): remove this.
- (RE_SYNTAX_AWK): remove from here, too.
- * regex.c (regex_compile): remove the check.
- * xregex.texinfo (Alternation Operator): update.
- * other.c (test_others): remove tests for this.
-
- * regex.h (RE_DUP_MAX): undefine if already defined.
-
- * regex.h: (RE_SYNTAX_POSIX*): redo to allow more operators, and
- define new syntaxes with the minimal set.
-
- * syntax.skel (main): used sscanf instead of scanf.
-
- * regex.h (RE_SYNTAX_*GREP): new definitions from mike.
-
- * regex.c (regex_compile): initialize the upper bound of
- intervals at the beginning of the interval, not the end.
- (From pclink@qld.tne.oz.au.)
-
- * regex.c (handle_bar): rename to `handle_alt', for consistency.
-
- * regex.c ({store,insert}_{op1,op2}): new routines (except the last).
- ({STORE,INSERT}_JUMP{,2}): macros to replace the old routines,
- which took arguments in different orders, and were generally weird.
-
- * regex.c (PAT_PUSH*): rename to `BUF_PUSH*' -- we're not
- appending info to the pattern!
-
-Sun Sep 6 11:26:49 1992 Karl Berry (karl@hayley)
-
- * regex.c (regex_compile): delete the variable
- `following_left_brace', since we never use it.
-
- * regex.c (print_compiled_pattern): don't print the fastmap if
- it's null.
-
- * regex.c (re_compile_fastmap): handle
- `on_failure_keep_string_jump' like `on_failure_jump'.
-
- * regex.c (re_match_2): in `charset{,_not' case, cast the bit
- count to unsigned, not unsigned char, in case we have a full
- 32-byte bit list.
-
- * tregress.c (simple_match): remove.
- (simple_test): rename as `simple_match'.
- (simple_compile): print the error string if the compile failed.
-
- * regex.c (DO_RANGE): rewrite as a function, `compile_range', so
- we can debug it. Change pattern characters to unsigned char
- *'s, and change the range variable to an unsigned.
- (regex_compile): change calls.
-
-Sat Sep 5 17:40:49 1992 Karl Berry (karl@hayley)
-
- * regex.h (_RE_ARGS): new macro to put in argument lists (if
- ANSI) or omit them (if K&R); don't declare routines twice.
-
- * many files (obscure_syntax): rename to `re_default_syntax'.
-
-Fri Sep 4 09:06:53 1992 Karl Berry (karl@hayley)
-
- * GNUmakefile (extraclean): new target.
- (realclean): delete the info files.
-
-Wed Sep 2 08:14:42 1992 Karl Berry (karl@hayley)
-
- * regex.h: doc fix.
-
-Sun Aug 23 06:53:15 1992 Karl Berry (karl@hayley)
-
- * regex.[ch] (re_comp): no const in the return type (from djm).
-
-Fri Aug 14 07:25:46 1992 Karl Berry (karl@hayley)
-
- * regex.c (DO_RANGE): declare variables as unsigned chars, not
- signed chars (from jimb).
-
-Wed Jul 29 18:33:53 1992 Karl Berry (karl@claude.cs.umb.edu)
-
- * Version 0.9.
-
- * GNUmakefile (distclean): do not remove regex.texinfo.
- (realclean): remove it here.
-
- * tregress.c (simple_test): initialize buf.buffer.
-
-Sun Jul 26 08:59:38 1992 Karl Berry (karl@hayley)
-
- * regex.c (push_dummy_failure): new opcode and corresponding
- case in the various routines. Pushed at the end of
- alternatives.
-
- * regex.c (jump_past_next_alt): rename to `jump_past_alt', for
- brevity.
- (no_pop_jump): rename to `jump'.
-
- * regex.c (regex_compile) [DEBUG]: terminate printing of pattern
- with a newline.
-
- * NEWS: new file.
-
- * tregress.c (simple_{compile,match,test}): routines to simplify all
- these little tests.
-
- * tregress.c: test for matching as much as possible.
-
-Fri Jul 10 06:53:32 1992 Karl Berry (karl@hayley)
-
- * Version 0.8.
-
-Wed Jul 8 06:39:31 1992 Karl Berry (karl@hayley)
-
- * regex.c (SIGN_EXTEND_CHAR): #undef any previous definition, as
- ours should always work properly.
-
-Mon Jul 6 07:10:50 1992 Karl Berry (karl@hayley)
-
- * iregex.c (main) [DEBUG]: conditionalize the call to
- print_compiled_pattern.
-
- * iregex.c (main): initialize buf.buffer to NULL.
- * tregress (test_regress): likewise.
-
- * regex.c (alloca) [sparc]: #if on HAVE_ALLOCA_H instead.
-
- * tregress.c (test_regress): didn't have jla's test quite right.
-
-Sat Jul 4 09:02:12 1992 Karl Berry (karl@hayley)
-
- * regex.c (re_match_2): only REGEX_ALLOCATE all the register
- vectors if the pattern actually has registers.
- (match_end): new variable to avoid having to use best_regend[0].
-
- * regex.c (IS_IN_FIRST_STRING): rename to FIRST_STRING_P.
-
- * regex.c: doc fixes.
-
- * tregess.c (test_regress): new fastmap test forwarded by rms.
-
- * tregress.c (test_regress): initialize the fastmap field.
-
- * tregress.c (test_regress): new test from jla that aborted
- in re_search_2.
-
-Fri Jul 3 09:10:05 1992 Karl Berry (karl@hayley)
-
- * tregress.c (test_regress): add tests for translating charsets,
- from kaoru.
-
- * GNUmakefile (common): add alloca.o.
- * alloca.c: new file, copied from bison.
-
- * other.c (test_others): remove var `buf', since it's no longer used.
-
- * Below changes from ro@TechFak.Uni-Bielefeld.DE.
-
- * tregress.c (test_regress): initialize buf.allocated.
-
- * regex.c (re_compile_fastmap): initialize `succeed_n_p'.
-
- * GNUmakefile (regex): depend on $(common).
-
-Wed Jul 1 07:12:46 1992 Karl Berry (karl@hayley)
-
- * Version 0.7.
-
- * regex.c: doc fixes.
-
-Mon Jun 29 08:09:47 1992 Karl Berry (karl@fosse)
-
- * regex.c (pop_failure_point): change string vars to
- `const char *' from `unsigned char *'.
-
- * regex.c: consolidate debugging stuff.
- (print_partial_compiled_pattern): avoid enum clash.
-
-Mon Jun 29 07:50:27 1992 Karl Berry (karl@hayley)
-
- * xmalloc.c: new file.
- * GNUmakefile (common): add it.
-
- * iregex.c (print_regs): new routine (from jimb).
- (main): call it.
-
-Sat Jun 27 10:50:59 1992 Jim Blandy (jimb@pogo.cs.oberlin.edu)
-
- * xregex.c (re_match_2): When we have accepted a match and
- restored d from best_regend[0], we need to set dend
- appropriately as well.
-
-Sun Jun 28 08:48:41 1992 Karl Berry (karl@hayley)
-
- * tregress.c: rename from regress.c.
-
- * regex.c (print_compiled_pattern): improve charset case to ease
- byte-counting.
- Also, don't distinguish between Emacs and non-Emacs
- {not,}wordchar opcodes.
-
- * regex.c (print_fastmap): move here.
- * test.c: from here.
- * regex.c (print_{{partial,}compiled_pattern,double_string}):
- rename from ..._printer. Change calls here and in test.c.
-
- * regex.c: create from xregex.c and regexinc.c for once and for
- all, and change the debug fns to be extern, instead of static.
- * GNUmakefile: remove traces of xregex.c.
- * test.c: put in externs, instead of including regexinc.c.
-
- * xregex.c: move interactive main program and scanstring to iregex.c.
- * iregex.c: new file.
- * upcase.c, printchar.c: new files.
-
- * various doc fixes and other cosmetic changes throughout.
-
- * regexinc.c (compiled_pattern_printer): change variable name,
- for consistency.
- (partial_compiled_pattern_printer): print other info about the
- compiled pattern, besides just the opcodes.
- * xregex.c (regex_compile) [DEBUG]: print the compiled pattern
- when we're done.
-
- * xregex.c (re_compile_fastmap): in the duplicate case, set
- `can_be_null' and return.
- Also, set `bufp->can_be_null' according to a new variable,
- `path_can_be_null'.
- Also, rewrite main while loop to not test `p != NULL', since
- we never set it that way.
- Also, eliminate special `can_be_null' value for the endline case.
- (re_search_2): don't test for the special value.
- * regex.h (struct re_pattern_buffer): remove the definition.
-
-Sat Jun 27 15:00:40 1992 Karl Berry (karl@hayley)
-
- * xregex.c (re_compile_fastmap): remove the `RE_' from
- `REG_RE_MATCH_NULL_AT_END'.
- Also, assert the fastmap in the pattern buffer is non-null.
- Also, reset `succeed_n_p' after we've
- paid attention to it, instead of every time through the loop.
- Also, in the `anychar' case, only clear fastmap['\n'] if the
- syntax says to, and don't return prematurely.
- Also, rearrange cases in some semblance of a rational order.
- * regex.h (REG_RE_MATCH_NULL_AT_END): remove the `RE_' from the name.
-
- * other.c: take bug reports from here.
- * regress.c: new file for them.
- * GNUmakefile (test): add it.
- * main.c (main): new possible test.
- * test.h (test_type): new value in enum.
-
-Thu Jun 25 17:37:43 1992 Karl Berry (karl@hayley)
-
- * xregex.c (scanstring) [test]: new function from jimb to allow some
- escapes.
- (main) [test]: call it (on the string, not the pattern).
-
- * xregex.c (main): make return type `int'.
-
-Wed Jun 24 10:43:03 1992 Karl Berry (karl@hayley)
-
- * xregex.c (pattern_offset_t): change to `int', for the benefit
- of patterns which compile to more than 2^15 bytes.
-
- * xregex.c (GET_BUFFER_SPACE): remove spurious braces.
-
- * xregex.texinfo (Using Registers): put in a stub to ``document''
- the new function.
- * regex.h (re_set_registers) [!__STDC__]: declare.
- * xregex.c (re_set_registers): declare K&R style (also move to a
- different place in the file).
-
-Mon Jun 8 18:03:28 1992 Jim Blandy (jimb@pogo.cs.oberlin.edu)
-
- * regex.h (RE_NREGS): Doc fix.
-
- * xregex.c (re_set_registers): New function.
- * regex.h (re_set_registers): Declaration for new function.
-
-Fri Jun 5 06:55:18 1992 Karl Berry (karl@hayley)
-
- * main.c (main): `return 0' instead of `exit (0)'. (From Paul Eggert)
-
- * regexinc.c (SIGN_EXTEND_CHAR): cast to unsigned char.
- (extract_number, EXTRACT_NUMBER): don't bother to cast here.
-
-Tue Jun 2 07:37:53 1992 Karl Berry (karl@hayley)
-
- * Version 0.6.
-
- * Change copyrights to `1985, 89, ...'.
-
- * regex.h (REG_RE_MATCH_NULL_AT_END): new macro.
- * xregex.c (re_compile_fastmap): initialize `can_be_null' to
- `p==pend', instead of in the test at the top of the loop (as
- it was, it was always being set).
- Also, set `can_be_null'=1 if we would jump to the end of the
- pattern in the `on_failure_jump' cases.
- (re_search_2): check if `can_be_null' is 1, not nonzero. This
- was the original test in rms' regex; why did we change this?
-
- * xregex.c (re_compile_fastmap): rename `is_a_succeed_n' to
- `succeed_n_p'.
-
-Sat May 30 08:09:08 1992 Karl Berry (karl@hayley)
-
- * xregex.c (re_compile_pattern): declare `regnum' as `unsigned',
- not `regnum_t', for the benefit of those patterns with more
- than 255 groups.
-
- * xregex.c: rename `failure_stack' to `fail_stack', for brevity;
- likewise for `match_nothing' to `match_null'.
-
- * regexinc.c (REGEX_REALLOCATE): take both the new and old
- sizes, and copy only the old bytes.
- * xregex.c (DOUBLE_FAILURE_STACK): pass both old and new.
- * This change from Thorsten Ohl.
-
-Fri May 29 11:45:22 1992 Karl Berry (karl@hayley)
-
- * regexinc.c (SIGN_EXTEND_CHAR): define as `(signed char) c'
- instead of relying on __CHAR_UNSIGNED__, to work with
- compilers other than GCC. From Per Bothner.
-
- * main.c (main): change return type to `int'.
-
-Mon May 18 06:37:08 1992 Karl Berry (karl@hayley)
-
- * regex.h (RE_SYNTAX_AWK): typo in RE_RE_UNMATCHED...
-
-Fri May 15 10:44:46 1992 Karl Berry (karl@hayley)
-
- * Version 0.5.
-
-Sun May 3 13:54:00 1992 Karl Berry (karl@hayley)
-
- * regex.h (struct re_pattern_buffer): now it's just `regs_allocated'.
- (REGS_UNALLOCATED, REGS_REALLOCATE, REGS_FIXED): new constants.
- * xregex.c (regexec, re_compile_pattern): set the field appropriately.
- (re_match_2): and use it. bufp can't be const any more.
-
-Fri May 1 15:43:09 1992 Karl Berry (karl@hayley)
-
- * regexinc.c: unconditionally include <sys/types.h>, first.
-
- * regex.h (struct re_pattern_buffer): rename
- `caller_allocated_regs' to `regs_allocated_p'.
- * xregex.c (re_compile_pattern): same change here.
- (regexec): and here.
- (re_match_2): reallocate registers if necessary.
-
-Fri Apr 10 07:46:50 1992 Karl Berry (karl@hayley)
-
- * regex.h (RE_SYNTAX{_POSIX,}_AWK): new definitions from Arnold.
-
-Sun Mar 15 07:34:30 1992 Karl Berry (karl at hayley)
-
- * GNUmakefile (dist): versionize regex.{c,h,texinfo}.
-
-Tue Mar 10 07:05:38 1992 Karl Berry (karl at hayley)
-
- * Version 0.4.
-
- * xregex.c (PUSH_FAILURE_POINT): always increment the failure id.
- (DEBUG_STATEMENT) [DEBUG]: execute the statement even if `debug'==0.
-
- * xregex.c (pop_failure_point): if the saved string location is
- null, keep the current value.
- (re_match_2): at fail, test for a dummy failure point by
- checking the restored pattern value, not string value.
- (re_match_2): new case, `on_failure_keep_string_jump'.
- (regex_compile): output this opcode in the .*\n case.
- * regexinc.c (re_opcode_t): define the opcode.
- (partial_compiled_pattern_pattern): add the new case.
-
-Mon Mar 9 09:09:27 1992 Karl Berry (karl at hayley)
-
- * xregex.c (regex_compile): optimize .*\n to output an
- unconditional jump to the ., instead of pushing failure points
- each time through the loop.
-
- * xregex.c (DOUBLE_FAILURE_STACK): compute the maximum size
- ourselves (and correctly); change callers.
-
-Sun Mar 8 17:07:46 1992 Karl Berry (karl at hayley)
-
- * xregex.c (failure_stack_elt_t): change to `const char *', to
- avoid warnings.
-
- * regex.h (re_set_syntax): declare this.
-
- * xregex.c (pop_failure_point) [DEBUG]: conditionally pass the
- original strings and sizes; change callers.
-
-Thu Mar 5 16:35:35 1992 Karl Berry (karl at claude.cs.umb.edu)
-
- * xregex.c (regnum_t): new type for register/group numbers.
- (compile_stack_elt_t, regex_compile): use it.
-
- * xregex.c (regexec): declare len as `int' to match re_search.
-
- * xregex.c (re_match_2): don't declare p1 twice.
-
- * xregex.c: change `while (1)' to `for (;;)' to avoid silly
- compiler warnings.
-
- * regex.h [__STDC__]: use #if, not #ifdef.
-
- * regexinc.c (REGEX_REALLOCATE): cast the result of alloca to
- (char *), to avoid warnings.
-
- * xregex.c (regerror): declare variable as const.
-
- * xregex.c (re_compile_pattern, re_comp): define as returning a const
- char *.
- * regex.h (re_compile_pattern, re_comp): likewise.
-
-Thu Mar 5 15:57:56 1992 Karl Berry (karl@hal)
-
- * xregex.c (regcomp): declare `syntax' as unsigned.
-
- * xregex.c (re_match_2): try to avoid compiler warnings about
- unsigned comparisons.
-
- * GNUmakefile (test-xlc): new target.
-
- * regex.h (reg_errcode_t): remove trailing comma from definition.
- * regexinc.c (re_opcode_t): likewise.
-
-Thu Mar 5 06:56:07 1992 Karl Berry (karl at hayley)
-
- * GNUmakefile (dist): add version numbers automatically.
- (versionfiles): new variable.
- (regex.{c,texinfo}): don't add version numbers here.
- * regex.h: put in placeholder instead of the version number.
-
-Fri Feb 28 07:11:33 1992 Karl Berry (karl at hayley)
-
- * xregex.c (re_error_msg): declare const, since it is.
-
-Sun Feb 23 05:41:57 1992 Karl Berry (karl at fosse)
-
- * xregex.c (PAT_PUSH{,_2,_3}, ...): cast args to avoid warnings.
- (regex_compile, regexec): return REG_NOERROR, instead
- of 0, on success.
- (boolean): define as char, and #define false and true.
- * regexinc.c (STREQ): cast the result.
-
-Sun Feb 23 07:45:38 1992 Karl Berry (karl at hayley)
-
- * GNUmakefile (test-cc, test-hc, test-pcc): new targets.
-
- * regex.inc (extract_number, extract_number_and_incr) [DEBUG]:
- only define if we are debugging.
-
- * xregex.c [_AIX]: do #pragma alloca first if necessary.
- * regexinc.c [_AIX]: remove the #pragma from here.
-
- * regex.h (reg_syntax_t): declare as unsigned, and redo the enum
- as #define's again. Some compilers do stupid things with enums.
-
-Thu Feb 20 07:19:47 1992 Karl Berry (karl at hayley)
-
- * Version 0.3.
-
- * xregex.c, regex.h (newline_anchor_match_p): rename to
- `newline_anchor'; dumb idea to change the name.
-
-Tue Feb 18 07:09:02 1992 Karl Berry (karl at hayley)
-
- * regexinc.c: go back to original, i.e., don't include
- <string.h> or define strchr.
- * xregex.c (regexec): don't bother with adding characters after
- newlines to the fastmap; instead, just don't use a fastmap.
- * xregex.c (regcomp): set the buffer and fastmap fields to zero.
-
- * xregex.texinfo (GNU r.e. compiling): have to initialize more
- than two fields.
-
- * regex.h (struct re_pattern_buffer): rename `newline_anchor' to
- `newline_anchor_match_p', as we're back to two cases.
- * xregex.c (regcomp, re_compile_pattern, re_comp): change
- accordingly.
- (re_match_2): at begline and endline, POSIX is not a special
- case anymore; just check newline_anchor_match_p.
-
-Thu Feb 13 16:29:33 1992 Karl Berry (karl at hayley)
-
- * xregex.c (*empty_string*): rename to *null_string*, for brevity.
-
-Wed Feb 12 06:36:22 1992 Karl Berry (karl at hayley)
-
- * xregex.c (re_compile_fastmap): at endline, don't set fastmap['\n'].
- (re_match_2): rewrite the begline/endline cases to take account
- of the new field newline_anchor.
-
-Tue Feb 11 14:34:55 1992 Karl Berry (karl at hayley)
-
- * regexinc.c [!USG etc.]: include <strings.h> and define strchr
- as index.
-
- * xregex.c (re_search_2): when searching backwards, declare `c'
- as a char and use casts when using it as an array subscript.
-
- * xregex.c (regcomp): if REG_NEWLINE, set
- RE_HAT_LISTS_NOT_NEWLINE. Set the `newline_anchor' field
- appropriately.
- (regex_compile): compile [^...] as matching a \n according to
- the syntax bit.
- (regexec): if doing REG_NEWLINE stuff, compile a fastmap and add
- characters after any \n's to the newline.
- * regex.h (RE_HAT_LISTS_NOT_NEWLINE): new syntax bit.
- (struct re_pattern_buffer): rename `posix_newline' to
- `newline_anchor', define constants for its values.
-
-Mon Feb 10 07:22:50 1992 Karl Berry (karl at hayley)
-
- * xregex.c (re_compile_fastmap): combine the code at the top and
- bottom of the loop, as it's essentially identical.
-
-Sun Feb 9 10:02:19 1992 Karl Berry (karl at hayley)
-
- * xregex.texinfo (POSIX Translate Tables): remove this, as it
- doesn't match the spec.
-
- * xregex.c (re_compile_fastmap): if we finish off a path, go
- back to the top (to set can_be_null) instead of returning
- immediately.
-
- * xregex.texinfo: changes from bob.
-
-Sat Feb 1 07:03:25 1992 Karl Berry (karl at hayley)
-
- * xregex.c (re_search_2): doc fix (from rms).
-
-Fri Jan 31 09:52:04 1992 Karl Berry (karl at hayley)
-
- * xregex.texinfo (GNU Searching): clarify the range arg.
-
- * xregex.c (re_match_2, at_endline_op_p): add extra parens to
- get rid of GCC 2's (silly, IMHO) warning about && within ||.
-
- * xregex.c (common_op_match_empty_string_p): use
- MATCH_NOTHING_UNSET_VALUE, not -1.
-
-Thu Jan 16 08:43:02 1992 Karl Berry (karl at hayley)
-
- * xregex.c (SET_REGS_MATCHED): only set the registers from
- lowest to highest.
-
- * regexinc.c (MIN): new macro.
- * xregex.c (re_match_2): only check min (num_regs,
- regs->num_regs) when we set the returned regs.
-
- * xregex.c (re_match_2): set registers after the first
- num_regs to -1 before we return.
-
-Tue Jan 14 16:01:42 1992 Karl Berry (karl at hayley)
-
- * xregex.c (re_match_2): initialize max (RE_NREGS, re_nsub + 1)
- registers (from rms).
-
- * xregex.c, regex.h: don't abbreviate `19xx' to `xx'.
-
- * regexinc.c [!emacs]: include <sys/types.h> before <unistd.h>.
- (from ro@thp.Uni-Koeln.DE).
-
-Thu Jan 9 07:23:00 1992 Karl Berry (karl at hayley)
-
- * xregex.c (*unmatchable): rename to `match_empty_string_p'.
- (CAN_MATCH_NOTHING): rename to `REG_MATCH_EMPTY_STRING_P'.
-
- * regexinc.c (malloc, realloc): remove prototypes, as they can
- cause clashes (from rms).
-
-Mon Jan 6 12:43:24 1992 Karl Berry (karl at claude.cs.umb.edu)
-
- * Version 0.2.
-
-Sun Jan 5 10:50:38 1992 Karl Berry (karl at hayley)
-
- * xregex.texinfo: bring more or less up-to-date.
- * GNUmakefile (regex.texinfo): generate from regex.h and
- xregex.texinfo.
- * include.awk: new file.
-
- * xregex.c: change all calls to the fn extract_number_and_incr
- to the macro.
-
- * xregex.c (re_match_2) [emacs]: in at_dot, use PTR_CHAR_POS + 1,
- instead of bf_* and sl_*. Cast d to unsigned char *, to match
- the declaration in Emacs' buffer.h.
- [emacs19]: in before_dot, at_dot, and after_dot, likewise.
-
- * regexinc.c: unconditionally include <sys/types.h>.
-
- * regexinc.c (alloca) [!alloca]: Emacs config files sometimes
- define this, so don't define it if it's already defined.
-
-Sun Jan 5 06:06:53 1992 Karl Berry (karl at fosse)
-
- * xregex.c (re_comp): fix type conflicts with regex_compile (we
- haven't been compiling this).
-
- * regexinc.c (SIGN_EXTEND_CHAR): use `__CHAR_UNSIGNED__', not
- `CHAR_UNSIGNED'.
-
- * regexinc.c (NULL) [!NULL]: define it (as zero).
-
- * regexinc.c (extract_number): remove the temporaries.
-
-Sun Jan 5 07:50:14 1992 Karl Berry (karl at hayley)
-
- * regex.h (regerror) [!__STDC__]: return a size_t, not a size_t *.
-
- * xregex.c (PUSH_FAILURE_POINT, ...): declare `destination' as
- `char *' instead of `void *', to match alloca declaration.
-
- * xregex.c (regerror): use `size_t' for the intermediate values
- as well as the return type.
-
- * xregex.c (regexec): cast the result of malloc.
-
- * xregex.c (regexec): don't initialize `private_preg' in the
- declaration, as old C compilers can't do that.
-
- * xregex.c (main) [test]: declare printchar void.
-
- * xregex.c (assert) [!DEBUG]: define this to do nothing, and
- remove #ifdef DEBUG's from around asserts.
-
- * xregex.c (re_match_2): remove error message when not debugging.
-
-Sat Jan 4 09:45:29 1992 Karl Berry (karl at hayley)
-
- * other.c: test the bizarre duplicate case in re_compile_fastmap
- that I just noticed.
-
- * test.c (general_test): don't test registers beyond the end of
- correct_regs, as well as regs.
-
- * xregex.c (regex_compile): at handle_close, don't assign to
- *inner_group_loc if we didn't push a start_memory (because the
- group number was too big). In fact, don't push or pop the
- inner_group_offset in that case.
-
- * regex.c: rename to xregex.c, since it's not the whole thing.
- * regex.texinfo: likewise.
- * GNUmakefile: change to match.
-
- * regex.c [DEBUG]: only include <stdio.h> if debugging.
-
- * regexinc.c (SIGN_EXTEND_CHAR) [CHAR_UNSIGNED]: if it's already
- defined, don't redefine it.
-
- * regex.c: define _GNU_SOURCE at the beginning.
- * regexinc.c (isblank) [!isblank]: define it.
- (isgraph) [!isgraph]: change conditional to this, and remove the
- sequent stuff.
-
- * regex.c (regex_compile): add `blank' character class.
-
- * regex.c (regex_compile): don't use a uchar variable to loop
- through all characters.
-
- * regex.c (regex_compile): at '[', improve logic for checking
- that we have enough space for the charset.
-
- * regex.h (struct re_pattern_buffer): declare translate as char
- * again. We only use it as an array subscript once, I think.
-
- * regex.c (TRANSLATE): new macro to cast the data character
- before subscripting.
- (num_internal_regs): rename to `num_regs'.
-
-Fri Jan 3 07:58:01 1992 Karl Berry (karl at hayley)
-
- * regex.h (struct re_pattern_buffer): declare `allocated' and
- `used' as unsigned long, since these are never negative.
-
- * regex.c (compile_stack_element): rename to compile_stack_elt_t.
- (failure_stack_element): similarly.
-
- * regexinc.c (TALLOC, RETALLOC): new macros to simplify
- allocation of arrays.
-
- * regex.h (re_*) [__STDC__]: don't declare string args unsigned
- char *; that makes them incompatible with string constants.
- (struct re_pattern_buffer): declare the pattern and translate
- table as unsigned char *.
- * regex.c (most routines): use unsigned char vs. char consistently.
-
- * regex.h (re_compile_pattern): do not declare the length arg as
- const.
- * regex.c (re_compile_pattern): likewise.
-
- * regex.c (POINTER_TO_REG): rename to `POINTER_TO_OFFSET'.
-
- * regex.h (re_registers): declare `start' and `end' as
- `regoff_t', instead of `int'.
-
- * regex.c (regexec): if either of the malloc's for the register
- information fail, return failure.
-
- * regex.h (RE_NREGS): define this again, as 30 (from jla).
- (RE_ALLOCATE_REGISTERS): remove this.
- (RE_SYNTAX_*): remove it from definitions.
- (re_pattern_buffer): remove `return_default_num_regs', add
- `caller_allocated_regs'.
- * regex.c (re_compile_pattern): clear no_sub and
- caller_allocated_regs in the pattern.
- (regcomp): set caller_allocated_regs.
- (re_match_2): do all register allocation at the end of the
- match; implement new semantics.
-
- * regex.c (MAX_REGNUM): new macro.
- (regex_compile): at handle_open and handle_close, if the group
- number is too large, don't push the start/stop memory.
-
-Thu Jan 2 07:56:10 1992 Karl Berry (karl at hayley)
-
- * regex.c (re_match_2): if the back reference is to a group that
- never matched, then goto fail, not really_fail. Also, don't
- test if the pattern can match the empty string. Why did we
- ever do that?
- (really_fail): this label no longer needed.
-
- * regexinc.c [STDC_HEADERS]: use only this to test if we should
- include <stdlib.h>.
-
- * regex.c (DO_RANGE, regex_compile): translate in all cases
- except the single character after a \.
-
- * regex.h (RE_AWK_CLASS_HACK): rename to
- RE_BACKSLASH_ESCAPE_IN_LISTS.
- * regex.c (regex_compile): change use.
-
- * regex.c (re_compile_fastmap): do not translate the characters
- again; we already translated them at compilation. (From ylo@ngs.fi.)
-
- * regex.c (re_match_2): in case for at_dot, invert sense of
- comparison and find the character number properly. (From
- worley@compass.com.)
- (re_match_2) [emacs]: remove the cases for before_dot and
- after_dot, since there's no way to specify them, and the code
- is wrong (judging from this change).
-
-Wed Jan 1 09:13:38 1992 Karl Berry (karl at hayley)
-
- * psx-{interf,basic,extend}.c, other.c: set `t' as the first
- thing, so that if we run them in sucession, general_test's
- kludge to see if we're doing POSIX tests works.
-
- * test.h (test_type): add `all_test'.
- * main.c: add case for `all_test'.
-
- * regexinc.c (partial_compiled_pattern_printer,
- double_string_printer): don't print anything if we're passed null.
-
- * regex.c (PUSH_FAILURE_POINT): do not scan for the highest and
- lowest active registers.
- (re_match_2): compute lowest/highest active regs at start_memory and
- stop_memory.
- (NO_{LOW,HIGH}EST_ACTIVE_REG): new sentinel values.
- (pop_failure_point): return the lowest/highest active reg values
- popped; change calls.
-
- * regex.c [DEBUG]: include <assert.h>.
- (various routines) [DEBUG]: change conditionals to assertions.
-
- * regex.c (DEBUG_STATEMENT): new macro.
- (PUSH_FAILURE_POINT): use it to increment num_regs_pushed.
- (re_match_2) [DEBUG]: only declare num_regs_pushed if DEBUG.
-
- * regex.c (*can_match_nothing): rename to *unmatchable.
-
- * regex.c (re_match_2): at stop_memory, adjust argument reading.
-
- * regex.h (re_pattern_buffer): declare `can_be_null' as a 2-bit
- bit field.
-
- * regex.h (re_pattern_buffer): declare `buffer' unsigned char *;
- no, dumb idea. The pattern can have signed number.
-
- * regex.c (re_match_2): in maybe_pop_jump case, skip over the
- right number of args to the group operators, and don't do
- anything with endline if posix_newline is not set.
-
- * regex.c, regexinc.c (all the things we just changed): go back
- to putting the inner group count after the start_memory,
- because we need it in the on_failure_jump case in re_match_2.
- But leave it after the stop_memory also, since we need it
- there in re_match_2, and we don't have any way of getting back
- to the start_memory.
-
- * regexinc.c (partial_compiled_pattern_printer): adjust argument
- reading for start/stop_memory.
- * regex.c (re_compile_fastmap, group_can_match_nothing): likewise.
-
-Tue Dec 31 10:15:08 1991 Karl Berry (karl at hayley)
-
- * regex.c (bits list routines): remove these.
- (re_match_2): get the number of inner groups from the pattern,
- instead of keeping track of it at start and stop_memory.
- Put the count after the stop_memory, not after the
- start_memory.
- (compile_stack_element): remove `fixup_inner_group' member,
- since we now put it in when we can compute it.
- (regex_compile): at handle_open, don't push the inner group
- offset, and at handle_close, don't pop it.
-
- * regex.c (level routines): remove these, and their uses in
- regex_compile. This was another manifestation of having to find
- $'s that were endlines.
-
- * regex.c (regexec): this does searching, not matching (a
- well-disguised part of the standard). So rewrite to use
- `re_search' instead of `re_match'.
- * psx-interf.c (test_regexec): add tests to, uh, match.
-
- * regex.h (RE_TIGHT_ALT): remove this; nobody uses it.
- * regex.c: remove the code that was supposed to implement it.
-
- * other.c (test_others): ^ and $ never match newline characters;
- RE_CONTEXT_INVALID_OPS doesn't affect anchors.
-
- * psx-interf.c (test_regerror): update for new error messages.
-
- * psx-extend.c: it's now ok to have an alternative be just a $,
- so remove all the tests which supposed that was invalid.
-
-Wed Dec 25 09:00:05 1991 Karl Berry (karl at hayley)
-
- * regex.c (regex_compile): in handle_open, don't skip over ^ and
- $ when checking for an empty group. POSIX has changed the
- grammar.
- * psx-extend.c (test_posix_extended): thus, move (^$) tests to
- valid section.
-
- * regexinc.c (boolean): move from here to test.h and regex.c.
- * test files: declare verbose, omit_register_tests, and
- test_should_match as boolean.
-
- * psx-interf.c (test_posix_c_interface): remove the `c_'.
- * main.c: likewise.
-
- * psx-basic.c (test_posix_basic): ^ ($) is an anchor after
- (before) an open (close) group.
-
- * regex.c (re_match_2): in endline, correct precedence of
- posix_newline condition.
-
-Tue Dec 24 06:45:11 1991 Karl Berry (karl at hayley)
-
- * test.h: incorporate private-tst.h.
- * test files: include test.h, not private-tst.h.
-
- * test.c (general_test): set posix_newline to zero if we are
- doing POSIX tests (unfortunately, it's difficult to call
- regcomp in this case, which is what we should really be doing).
-
- * regex.h (reg_syntax_t): make this an enumeration type which
- defines the syntax bits; renames re_syntax_t.
-
- * regex.c (at_endline_op_p): don't preincrement p; then if it's
- not an empty string op, we lose.
-
- * regex.h (reg_errcode_t): new enumeration type of the error
- codes.
- * regex.c (regex_compile): return that type.
-
- * regex.c (regex_compile): in [, initialize
- just_had_a_char_class to false; somehow I had changed this to
- true.
-
- * regex.h (RE_NO_CONSECUTIVE_REPEATS): remove this, since we
- don't use it, and POSIX doesn't require this behavior anymore.
- * regex.c (regex_compile): remove it from here.
-
- * regex.c (regex_compile): remove the no_op insertions for
- verify_and_adjust_endlines, since that doesn't exist anymore.
-
- * regex.c (regex_compile) [DEBUG]: use printchar to print the
- pattern, so unprintable bytes will print properly.
-
- * regex.c: move re_error_msg back.
- * test.c (general_test): print the compile error if the pattern
- was invalid.
-
-Mon Dec 23 08:54:53 1991 Karl Berry (karl at hayley)
-
- * regexinc.c: move re_error_msg here.
-
- * regex.c (re_error_msg): the ``message'' for success must be
- NULL, to keep the interface to re_compile_pattern the same.
- (regerror): if the msg is null, use "Success".
-
- * rename most test files for consistency. Change Makefile
- correspondingly.
-
- * test.c (most routines): add casts to (unsigned char *) when we
- call re_{match,search}{,_2}.
-
-Sun Dec 22 09:26:06 1991 Karl Berry (karl at hayley)
-
- * regex.c (re_match_2): declare string args as unsigned char *
- again; don't declare non-pointer args const; declare the
- pattern buffer const.
- (re_match): likewise.
- (re_search_2, re_search): likewise, except don't declare the
- pattern const, since we make a fastmap.
- * regex.h [__STDC__]: change prototypes.
-
- * regex.c (regex_compile): return an error code, not a string.
- (re_err_list): new table to map from error codes to string.
- (re_compile_pattern): return an element of re_err_list.
- (regcomp): don't test all the strings.
- (regerror): just use the list.
- (put_in_buffer): remove this.
-
- * regex.c (equivalent_failure_points): remove this.
-
- * regex.c (re_match_2): don't copy the string arguments into
- non-const pointers. We never alter the data.
-
- * regex.c (re_match_2): move assignment to `is_a_jump_n' out of
- the main loop. Just initialize it right before we do
- something with it.
-
- * regex.[ch] (re_match_2): don't declare the int parameters const.
-
-Sat Dec 21 08:52:20 1991 Karl Berry (karl at hayley)
-
- * regex.h (re_syntax_t): new type; declare to be unsigned
- (previously we used int, but since we do bit operations on
- this, unsigned is better, according to H&S).
- (obscure_syntax, re_pattern_buffer): use that type.
- * regex.c (re_set_syntax, regex_compile): likewise.
-
- * regex.h (re_pattern_buffer): new field `posix_newline'.
- * regex.c (re_comp, re_compile_pattern): set to zero.
- (regcomp): set to REG_NEWLINE.
- * regex.h (RE_HAT_LISTS_NOT_NEWLINE): remove this (we can just
- check `posix_newline' instead.)
-
- * regex.c (op_list_type, op_list, add_op): remove these.
- (verify_and_adjust_endlines): remove this.
- (pattern_offset_list_type, *pattern_offset* routines): and these.
- These things all implemented the nonleading/nontrailing position
- code, which was very long, had a few remaining problems, and
- is no longer needed. So...
-
- * regexinc.c (STREQ): new macro to abbreviate strcmp(,)==0, for
- brevity. Change various places in regex.c to use it.
-
- * regex{,inc}.c (enum regexpcode): change to a typedef
- re_opcode_t, for brevity.
-
- * regex.h (re_syntax_table) [SYNTAX_TABLE]: remove this; it
- should only be in regex.c, I think, since we don't define it
- in this case. Maybe it should be conditional on !SYNTAX_TABLE?
-
- * regexinc.c (partial_compiled_pattern_printer): simplify and
- distinguish the emacs/not-emacs (not)wordchar cases.
-
-Fri Dec 20 08:11:38 1991 Karl Berry (karl at hayley)
-
- * regexinc.c (regexpcode) [emacs]: only define the Emacs opcodes
- if we are ifdef emacs.
-
- * regex.c (BUF_PUSH*): rename to PAT_PUSH*.
-
- * regex.c (regex_compile): in $ case, go back to essentially the
- original code for deciding endline op vs. normal char.
- (at_endline_op_p): new routine.
- * regex.h (RE_ANCHORS_ONLY_AT_ENDS, RE_CONTEXT_INVALID_ANCHORS,
- RE_REPEATED_ANCHORS_AWAY, RE_NO_ANCHOR_AT_NEWLINE): remove
- these. POSIX has simplified the rules for anchors in draft
- 11.2.
- (RE_NEWLINE_ORDINARY): new syntax bit.
- (RE_CONTEXT_INDEP_ANCHORS): change description to be compatible
- with POSIX.
- * regex.texinfo (Syntax Bits): remove the descriptions.
-
-Mon Dec 16 08:12:40 1991 Karl Berry (karl at hayley)
-
- * regex.c (re_match_2): in jump_past_next_alt, unconditionally
- goto no_pop. The only register we were finding was one which
- enclosed the whole alternative expression, not one around an
- individual alternative. So we were never doing what we
- thought we were doing, and this way makes (|a) against the
- empty string fail.
-
- * regex.c (regex_compile): remove `highest_ever_regnum', and
- don't restore regnum from the stack; just put it into a
- temporary to put into the stop_memory. Otherwise, groups
- aren't numbered consecutively.
-
- * regex.c (is_in_compile_stack): rename to
- `group_in_compile_stack'; remove unnecessary test for the
- stack being empty.
-
- * regex.c (re_match_2): in on_failure_jump, skip no_op's before
- checking for the start_memory, in case we were called from
- succeed_n.
-
-Sun Dec 15 16:20:48 1991 Karl Berry (karl at hayley)
-
- * regex.c (regex_compile): in duplicate case, use
- highest_ever_regnum instead of regnum, since the latter is
- reverted at stop_memory.
-
- * regex.c (re_match_2): in on_failure_jump, if the * applied to
- a group, save the information for that group and all inner
- groups (by making it active), even though we're not inside it
- yet.
-
-Sat Dec 14 09:50:59 1991 Karl Berry (karl at hayley)
-
- * regex.c (PUSH_FAILURE_ITEM, POP_FAILURE_ITEM): new macros.
- Use them instead of copying the stack manipulating a zillion
- times.
-
- * regex.c (PUSH_FAILURE_POINT, pop_failure_point) [DEBUG]: save
- and restore a unique identification value for each failure point.
-
- * regexinc.c (partial_compiled_pattern_printer): don't print an
- extra / after duplicate commands.
-
- * regex.c (regex_compile): in back-reference case, allow a back
- reference to register `regnum'. Otherwise, even `\(\)\1'
- fails, since regnum is 1 at the back-reference.
-
- * regex.c (re_match_2): in fail, don't examine the pattern if we
- restored to pend.
-
- * test_private.h: rename to private_tst.h. Change includes.
-
- * regex.c (extend_bits_list): compute existing size for realloc
- in bytes, not blocks.
-
- * regex.c (re_match_2): in jump_past_next_alt, the for loop was
- missing its (empty) statement. Even so, some register tests
- still fail, although in a different way than in the previous change.
-
-Fri Dec 13 15:55:08 1991 Karl Berry (karl at hayley)
-
- * regex.c (re_match_2): in jump_past_next_alt, unconditionally
- goto no_pop, since we weren't properly detecting if the
- alternative matched something anyway. No, we need to not jump
- to keep the register values correct; just change to not look at
- register zero and not test RE_NO_EMPTY_ALTS (which is a
- compile-time thing).
-
- * regex.c (SET_REGS_MATCHED): start the loop at 1, since we never
- care about register zero until the very end. (I think.)
-
- * regex.c (PUSH_FAILURE_POINT, pop_failure_point): go back to
- pushing and popping the active registers, instead of only doing
- the registers before a group: (fooq|fo|o)*qbar against fooqbar
- fails, since we restore back into the middle of group 1, yet it
- isn't active, because the previous restore clobbered the active flag.
-
-Thu Dec 12 17:25:36 1991 Karl Berry (karl at hayley)
-
- * regex.c (PUSH_FAILURE_POINT): do not call
- `equivalent_failure_points' after all; it causes the registers
- to be ``wrong'' (according to POSIX), and an infinite loop on
- `((a*)*)*' against `ab'.
-
- * regex.c (re_compile_fastmap): don't push `pend' on the failure
- stack.
-
-Tue Dec 10 10:30:03 1991 Karl Berry (karl at hayley)
-
- * regex.c (PUSH_FAILURE_POINT): if pushing same failure point that
- is on the top of the stack, fail.
- (equivalent_failure_points): new routine.
-
- * regex.c (re_match_2): add debug statements for every opcode we
- execute.
-
- * regex.c (regex_compile/handle_close): restore
- `fixup_inner_group_count' and `regnum' from the stack.
-
-Mon Dec 9 13:51:15 1991 Karl Berry (karl at hayley)
-
- * regex.c (PUSH_FAILURE_POINT): declare `this_reg' as int, so
- unsigned arithmetic doesn't happen when we don't want to save
- the registers.
-
-Tue Dec 3 08:11:10 1991 Karl Berry (karl at hayley)
-
- * regex.c (extend_bits_list): divide size by bits/block.
-
- * regex.c (init_bits_list): remove redundant assignmen to
- `bits_list_ptr'.
-
- * regexinc.c (partial_compiled_pattern_printer): don't do *p++
- twice in the same expr.
-
- * regex.c (re_match_2): at on_failure_jump, use the correct
- pattern positions for getting the stuff following the start_memory.
-
- * regex.c (struct register_info): remove the bits_list for the
- inner groups; make that a separate variable.
-
-Mon Dec 2 10:42:07 1991 Karl Berry (karl at hayley)
-
- * regex.c (PUSH_FAILURE_POINT): don't pass `failure_stack' as an
- arg; change callers.
-
- * regex.c (PUSH_FAILURE_POINT): print items in order they are
- pushed.
- (pop_failure_point): likewise.
-
- * regex.c (main): prompt for the pattern and string.
-
- * regex.c (FREE_VARIABLES) [!REGEX_MALLOC]: declare as nothing;
- remove #ifdefs from around calls.
-
- * regex.c (extract_number, extract_number_and_incr): declare static.
-
- * regex.c: remove the canned main program.
- * main.c: new file.
- * Makefile (COMMON): add main.o.
-
-Tue Sep 24 06:26:51 1991 Kathy Hargreaves (kathy at fosse)
-
- * regex.c (re_match_2): Made `pend' and `dend' not register variables.
- Only set string2 to string1 if string1 isn't null.
- Send address of p, d, regstart, regend, and reg_info to
- pop_failure_point.
- Put in more debug statements.
-
- * regex.c [debug]: Added global variable.
- (DEBUG_*PRINT*): Only print if `debug' is true.
- (DEBUG_DOUBLE_STRING_PRINTER): Changed DEBUG_STRING_PRINTER's
- name to this.
- Changed some comments.
- (PUSH_FAILURE_POINT): Moved and added some debugging statements.
- Was saving regstart on the stack twice instead of saving both
- regstart and regend; remedied this.
- [NUM_REGS_ITEMS]: Changed from 3 to 4, as now save lowest and
- highest active registers instead of highest used one.
- [NUM_NON_REG_ITEMS]: Changed name of NUM_OTHER_ITEMS to this.
- (NUM_FAILURE_ITEMS): Use active registers instead of number 0
- through highest used one.
- (re_match_2): Have pop_failure_point put things in the variables.
- (pop_failure_point): Have it do what the fail case in re_match_2
- did with the failure stack, instead of throwing away the stuff
- popped off. re_match_2 can ignore results when it doesn't
- need them.
-
-
-Thu Sep 5 13:23:28 1991 Kathy Hargreaves (kathy at fosse)
-
- * regex.c (banner): Changed copyright years to be separate.
-
- * regex.c [CHAR_UNSIGNED]: Put __ at both ends of this name.
- [DEBUG, debug_count, *debug_p, DEBUG_PRINT_1, DEBUG_PRINT_2,
- DEBUG_COMPILED_PATTERN_PRINTER ,DEBUG_STRING_PRINTER]:
- defined these for debugging.
- (extract_number): Added this (debuggable) routine version of
- the macro EXTRACT_NUMBER. Ditto for EXTRACT_NUMBER_AND_INCR.
- (re_compile_pattern): Set return_default_num_regs if the
- syntax bit RE_ALLOCATE_REGISTERS is set.
- [REGEX_MALLOC]: Renamed USE_ALLOCA to this.
- (BUF_POP): Got rid of this, as don't ever use it.
- (regex_compile): Made the type of `pattern' not be register.
- If DEBUG, print the pattern to compile.
- (re_match_2): If had a `$' in the pattern before a `^' then
- don't record the `^' as an anchor.
- Put (enum regexpcode) before references to b, as suggested
- [RE_NO_BK_BRACES]: Changed RE_NO_BK_CURLY_BRACES to this.
- (remove_pattern_offset): Removed this unused routine.
- (PUSH_FAILURE_POINT): Changed to only save active registers.
- Put in debugging statements.
- (re_compile_fastmap): Made `pattern' not a register variable.
- Use routine for extracting numbers instead of macro.
- (re_match_2): Made `p', `mcnt' and `mcnt2' not register variables.
- Added `num_regs_pushed' for debugging.
- Only malloc registers if the syntax bit RE_ALLOCATE_REGISTERS is set.
- Put in debug statements.
- Put the macro NOTE_INNER_GROUP's code inline, as it was the
- only called in one place.
- For debugging, extract numbers using routines instead of macros.
- In case fail: only restore pushed active registers, and added
- debugging statements.
- (pop_failure_point): Test for underfull stack.
- (group_can_match_nothing, common_op_can_match_nothing): For
- debugging, extract numbers using routines instead of macros.
- (regexec): Changed formal parameters to not be prototypes.
- Don't initialize `regs' or `private_preg' in their declarations.
-
-Tue Jul 23 18:38:36 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h [RE_CONTEX_INDEP_OPS]: Moved the anchor stuff out of
- this bit.
- [RE_UNMATCHED_RIGHT_PAREN_ORD]: Defined this bit.
- [RE_CONTEXT_INVALID_ANCHORS]: Defined this bit.
- [RE_CONTEXT_INDEP_ANCHORS]: Defined this bit.
- Added RE_CONTEXT_INDEP_ANCHORS to all syntaxes which had
- RE_CONTEXT_INDEP_OPS.
- Took RE_ANCHORS_ONLY_AT_ENDS out of the POSIX basic syntax.
- Added RE_UNMATCHED_RIGHT_PAREN_ORD to the POSIX extended
- syntax.
- Took RE_REPEATED_ANCHORS_AWAY out of the POSIX extended syntax.
- Defined REG_NOERROR (which will probably have to go away again).
- Changed the type `off_t' to `regoff_t'.
-
- * regex.c: Changed some commments.
- (regex_compile): Added variable `had_an_endline' to keep track
- of if hit a `$' since the beginning of the pattern or the last
- alternative (if any).
- Changed RE_CONTEXT_INVALID_OPS and RE_CONTEXT_INDEP_OPS to
- RE_CONTEXT_INVALID_ANCHORS and RE_CONTEXT_INDEP_ANCHORS where
- appropriate.
- Put a `no_op' in the pattern if a repeat is only zero or one
- times; in this case and if it is many times (whereupon a jump
- backwards is pushed instead), keep track of the operator for
- verify_and_adjust_endlines.
- If RE_UNMATCHED_RIGHT_PAREN is set, make an unmatched
- close-group operator match `)'.
- Changed all error exits to exit (1).
- (remove_pattern_offset): Added this routine, but don't use it.
- (verify_and_adjust_endlines): At top of routine, if initialize
- routines run out of memory, return true after setting
- enough_memory false.
- At end of endline, et al. case, don't set *p to no_op.
- Repetition operators also set the level and active groups'
- match statuses, unless RE_REPEATED_ANCHORS_AWAY is set.
- (get_group_match_status): Put a return in front of call to get_bit.
- (re_compile_fastmap): Changed is_a_succeed_n to a boolean.
- If at end of pattern, then if the failure stack isn't empty,
- go back to the failure point.
- In *jump* case, only pop the stack if what's on top of it is
- where we've just jumped to.
- (re_search_2): Return -2 instead of val if val is -2.
- (group_can_match_nothing, alternative_can_match_nothing,
- common_op_can-match_nothing): Now pass in reg_info for the
- `duplicate' case.
- (re_match_2): Don't skip over the next alternative also if
- empty alternatives aren't allowed.
- In fail case, if failed to a backwards jump that's part of a
- repetition loop, pop the current failure point and use the
- next one.
- (pop_failure_point): Check that there's as many register items
- on the failure stack as the stack says there are.
- (common_op_can_match_nothing): Added variables `ret' and
- `reg_no' so can set reg_info for the group encountered.
- Also break without doing anything if hit a no_op or the other
- kinds of `endline's.
- If not done already, set reg_info in start_memory case.
- Put in no_pop_jump for an optimized succeed_n of zero repetitions.
- In succeed_n case, if the number isn't zero, then return false.
- Added `duplicate' case.
-
-Sat Jul 13 11:27:38 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (REG_NOERROR): Added this error code definition.
-
- * regex.c: Took some redundant parens out of macros.
- (enum regexpcode): Added jump_past_next_alt.
- Wrapped some macros in `do..while (0)'.
- Changed some comments.
- (regex_compile): Use `fixup_alt_jump' instead of `fixup_jump'.
- Use `maybe_pop_jump' instead of `maybe_pop_failure_jump'.
- Use `jump_past_next_alt' instead of `no_pop_jump' when at the
- end of an alternative.
- (re_match_2): Used REGEX_ALLOCATE for the registers stuff.
- In stop_memory case: Add more boolean tests to see if the
- group is in a loop.
- Added jump_past_next_alt case, which doesn't jump over the
- next alternative if the last one didn't match anything.
- Unfortunately, to make this work with, e.g., `(a+?*|b)*'
- against `bb', I also had to pop the alternative's failure
- point, which in turn broke backtracking!
- In fail case: Detect a dummy failure point by looking at
- failure_stack.avail - 2, not stack[-2].
- (pop_failure_point): Only pop if the stack isn't empty; don't
- give an error if it is. (Not sure yet this is correct.)
- (group_can_match_nothing): Make it return a boolean instead of int.
- Make it take an argument indicating the end of where it should look.
- If find a group that can match nothing, set the pointer
- argument to past the group in the pattern.
- Took out cases which can share with alternative_can_match_nothing
- and call common_op_can_match_nothing.
- Took ++ out of switch, so could call common_op_can_match_nothing.
- Wrote lots more for on_failure_jump case to handle alternatives.
- Main loop now doesn't look for matching stop_memory, but
- rather the argument END; return true if hit the matching
- stop_memory; this way can call itself for inner groups.
- (alternative_can_match_nothing): Added for alternatives.
- (common_op_can_match_nothing): Added for previous two routines'
- common operators.
- (regerror): Returns a message saying there's no error if gets
- sent REG_NOERROR.
-
-Wed Jul 3 10:43:15 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.c: Removed unnecessary enclosing parens from several macros.
- Put `do..while (0)' around a few.
- Corrected some comments.
- (INIT_FAILURE_STACK_SIZE): Deleted in favor of using
- INIT_FAILURE_ALLOC.
- (INIT_FAILURE_STACK, DOUBLE_FAILURE_STACK, PUSH_PATTERN_OP,
- PUSH_FAILURE_POINT): Made routines of the same name (but with all
- lowercase letters) into these macros, so could use `alloca'
- when USE_ALLOCA is defined. The reason is stated below for
- bits lists. Deleted analogous routines.
- (re_compile_fastmap): Added variable void *destination for
- PUSH_PATTERN_OP.
- (re_match_2): Added variable void *destination for REGEX_REALLOCATE.
- Used the failure stack macros in place of the routines.
- Detected a dummy failure point by inspecting the failure stack's
- (avail - 2)th element, not failure_stack.stack[-2]. This bug
- arose when used the failure stack macros instead of the routines.
-
- * regex.c [USE_ALLOCA]: Put this conditional around previous
- alloca stuff and defined these to work differently depending
- on whether or not USE_ALLOCA is defined:
- (REGEX_ALLOCATE): Uses either `alloca' or `malloc'.
- (REGEX_REALLOCATE): Uses either `alloca' or `realloc'.
- (INIT_BITS_LIST, EXTEND_BITS_LIST, SET_BIT_TO_VALUE): Defined
- macro versions of routines with the same name (only with all
- lowercase letters) so could use `alloc' in re_match_2. This
- is to prevent core leaks when C-g is used in Emacs and to make
- things faster and avoid storage fragmentation. These things
- have to be macros because the results of `alloca' go away with
- the routine by which it's called.
- (BITS_BLOCK_SIZE, BITS_BLOCK, BITS_MASK): Moved to above the
- above-mentioned macros instead of before the routines defined
- below regex_compile.
- (set_bit_to_value): Compacted some code.
- (reg_info_type): Changed inner_groups field to be bits_list_type
- so could be arbitrarily long and thus handle arbitrary nesting.
- (NOTE_INNER_GROUP): Put `do...while (0)' around it so could
- use as a statement.
- Changed code to use bits lists.
- Added variable void *destination for REGEX_REALLOCATE (whose call
- is several levels in).
- Changed variable name of `this_bit' to `this_reg'.
- (FREE_VARIABLES): Only define and use if USE_ALLOCA is defined.
- (re_match_2): Use REGEX_ALLOCATE instead of malloc.
- Instead of setting INNER_GROUPS of reg_info to zero, have to
- use INIT_BITS_LIST and return -2 (and free variables if
- USE_ALLOCA isn't defined) if it fails.
-
-Fri Jun 28 13:45:07 1991 Karl Berry (karl at hayley)
-
- * regex.c (re_match_2): set value of `dend' when we restore `d'.
-
- * regex.c: remove declaration of alloca.
-
- * regex.c (MISSING_ISGRAPH): rename to `ISGRAPH_MISSING'.
-
- * regex.h [_POSIX_SOURCE]: remove these conditionals; always
- define POSIX stuff.
- * regex.c (_POSIX_SOURCE): change conditionals to use `POSIX'
- instead.
-
-Sat Jun 1 16:56:50 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.*: Changed RE_CONTEXTUAL_* to RE_CONTEXT_*,
- RE_TIGHT_VBAR to RE_TIGHT_ALT, RE_NEWLINE_OR to
- RE_NEWLINE_ALT, and RE_DOT_MATCHES_NEWLINE to RE_DOT_NEWLINE.
-
-Wed May 29 09:24:11 1991 Karl Berry (karl at hayley)
-
- * regex.texinfo (POSIX Pattern Buffers): cross-reference the
- correct node name (Match-beginning-of-line, not ..._line).
- (Syntax Bits): put @code around all syntax bits.
-
-Sat May 18 16:29:58 1991 Karl Berry (karl at hayley)
-
- * regex.c (global): add casts to keep broken compilers from
- complaining about malloc and realloc calls.
-
- * regex.c (isgraph) [MISSING_ISGRAPH]: change test to this,
- instead of `#ifndef isgraph', since broken compilers can't
- have both a macro and a symbol by the same name.
-
- * regex.c (re_comp, re_exec) [_POSIX_SOURCE]: do not define.
- (regcomp, regfree, regexec, regerror) [_POSIX_SOURCE && !emacs]:
- only define in this case.
-
-Mon May 6 17:37:04 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (re_search, re_search_2): Changed BUFFER to not be const.
-
- * regex.c (re_compile_pattern): `^' is in a leading position if
- it precedes a newline.
- (various routines): Added or changed header comments.
- (double_pattern_offsets_list): Changed name from
- `extend_pattern_offsets_list'.
- (adjust_pattern_offsets_list): Changed return value from
- unsigned to void.
- (verify_and_adjust_endlines): Now returns `true' and `false'
- instead of 1 and 0.
- `$' is in a leading position if it follows a newline.
- (set_bit_to_value, get_bit_value): Exit with error if POSITION < 0
- so now calling routines don't have to.
- (init_failure_stack, inspect_failure_stack_top,
- pop_failure_stack_top, push_pattern_op, double_failure_stack):
- Now return value unsigned instead of boolean.
- (re_search, re_search_2): Changed BUFP to not be const.
- (re_search_2): Added variable const `private_bufp' to send to
- re_match_2.
- (push_failure_point): Made return value unsigned instead of boolean.
-
-Sat May 4 15:32:22 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (re_compile_fastmap): Added extern for this.
- Changed some comments.
-
- * regex.c (re_compile_pattern): In case handle_bar: put invalid
- pattern test before levels matching stuff.
- Changed some commments.
- Added optimizing test for detecting an empty alternative that
- ends with a trailing '$' at the end of the pattern.
- (re_compile_fastmap): Moved failure_stack stuff to before this
- so could use it. Made its stack dynamic.
- Made it return an int so that it could return -2 if its stack
- couldn't be allocated.
- Added to header comment (about the return values).
- (init_failure_stack): Wrote so both re_match_2 and
- re_compile_fastmap could use it similar stacks.
- (double_failure_stack): Added for above reasons.
- (push_pattern_op): Wrote for re_compile_fastmap.
- (re_search_2): Now return -2 if re_compile_fastmap does.
- (re_match_2): Made regstart and regend type failure_stack_element*.
- (push_failure_point): Made pattern_place and string_place type
- failure_stack_element*.
- Call double_failure_stack now.
- Return true instead of 1.
-
-Wed May 1 12:57:21 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.c (remove_intervening_anchors): Avoid erroneously making
- ops into no_op's by making them no_op only when they're beglines.
- (verify_and_adjust_endlines): Don't make '$' a normal character
- if it's before a newline.
- Look for the endline op in *p, not p[1].
- (failure_stack_element): Added this declaration.
- (failure_stack_type): Added this declaration.
- (INIT_FAILURE_STACK_SIZE, FAILURE_STACK_EMPTY,
- FAILURE_STACK_PTR_EMPTY, REMAINING_AVAIL_SLOTS): Added for
- failure stack.
- (FAILURE_ITEM_SIZE, PUSH_FAILURE_POINT): Deleted.
- (FREE_VARIABLES): Now free failure_stack.stack instead of stackb.
- (re_match_2): deleted variables `initial_stack', `stackb',
- `stackp', and `stacke' and added `failure_stack' to replace them.
- Replaced calls to PUSH_FAILURE_POINT with those to
- push_failure_point.
- (push_failure_point): Added for re_match_2.
- (pop_failure_point): Rewrote to use a failure_stack_type of stack.
- (can_match_nothing): Moved definition to below re_match_2.
- (bcmp_translate): Moved definition to below re_match_2.
-
-Mon Apr 29 14:20:54 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.c (enum regexpcode): Added codes endline_before_newline
- and repeated_endline_before_newline so could detect these
- types of endlines in the intermediate stages of a compiled
- pattern.
- (INIT_FAILURE_ALLOC): Renamed NFAILURES to this and set it to 5.
- (BUF_PUSH): Put `do {...} while 0' around this.
- (BUF_PUSH_2): Defined this to cut down on expansion of EXTEND_BUFFER.
- (regex_compile): Changed some comments.
- Now push endline_before_newline if find a `$' before a newline
- in the pattern.
- If a `$' might turn into an ordinary character, set laststart
- to point to it.
- In '^' case, if syntax bit RE_TIGHT_VBAR is set, then for `^'
- to be in a leading position, it must be first in the pattern.
- Don't have to check in one of the else clauses that it's not set.
- If RE_CONTEXTUAL_INDEP_OPS isn't set but RE_ANCHORS_ONLY_AT_ENDS
- is, make '^' a normal character if it isn't first in the pattern.
- Can only detect at the end if a '$' after an alternation op is a
- trailing one, so can't immediately detect empty alternatives
- if a '$' follows a vbar.
- Added a picture of the ``success jumps'' in alternatives.
- Have to set bufp->used before calling verify_and_adjust_endlines.
- Also do it before returning all error strings.
- (remove_intervening_anchors): Now replaces the anchor with
- repeated_endline_before_newline if it's an endline_before_newline.
- (verify_and_adjust_endlines): Deleted SYNTAX parameter (could
- use bufp's) and added GROUP_FORWARD_MATCH_STATUS so could
- detect back references referring to empty groups.
- Added variable `bend' to point past the end of the pattern buffer.
- Added variable `previous_p' so wouldn't have to reinspect the
- pattern buffer to see what op we just looked at.
- Added endline_before_newline and repeated_endline_before_newline
- cases.
- When checking if in a trailing position, added case where '$'
- has to be at the pattern's end if either of the syntax bits
- RE_ANCHORS_ONLY_AT_ENDS or RE_TIGHT_VBAR are set.
- Since `endline' can have the intermediate form `endline_in_repeat',
- have to change it to `endline' if RE_REPEATED_ANCHORS_AWAY
- isn't set.
- Now disallow empty alternatives with trailing endlines in them
- if RE_NO_EMPTY_ALTS is set.
- Now don't make '$' an ordinary character if it precedes a newline.
- Don't make it an ordinary character if it's before a newline.
- Back references now affect the level matching something only if
- they refer to nonempty groups.
- (can_match_nothing): Now increment p1 in the switch, which
- changes many of the cases, but makes the code more like what
- it was derived from.
- Adjust the return statement to reflect above.
- (struct register_info): Made `can_match_nothing' field an int
- instead of a bit so could have -1 in it if never set.
- (MAX_FAILURE_ITEMS): Changed name from MAX_NUM_FAILURE_ITEMS.
- (FAILURE_ITEM_SIZE): Defined how much space a failure items uses.
- (PUSH_FAILURE_POINT): Changed variable `last_used_reg's name
- to `highest_used_reg'.
- Added variable `num_stack_items' and changed `len's name to
- `stack_length'.
- Test failure stack limit in terms of number of items in it, not
- in terms of its length. rms' fix tested length against number
- of items, which was a misunderstanding.
- Use `realloc' instead of `alloca' to extend the failure stack.
- Use shifts instead of multiplying by 2.
- (FREE_VARIABLES): Free `stackb' instead of `initial_stack', as
- might may have been reallocated.
- (re_match_2): When mallocing `initial_stack', now multiply
- the number of items wanted (what was there before) by
- FAILURE_ITEM_SIZE.
- (pop_failure_point): Need this procedure form of the macro of
- the same name for debugging, so left it in and deleted the
- macro.
- (recomp): Don't free the pattern buffer's translate field.
-
-Mon Apr 15 09:47:47 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_DUP_MAX): Moved to outside of #ifdef _POSIX_SOURCE.
- * regex.c (#include <sys/types.h>): Removed #ifdef _POSIX_SOURCE
- condition.
- (malloc, realloc): Made return type void* #ifdef __STDC__.
- (enum regexpcode): Added endline_in_repeat for the compiler's
- use; this never ends up on the final compiled pattern.
- (INIT_PATTERN_OFFSETS_LIST_SIZE): Initial size for
- pattern_offsets_list_type.
- (pattern_offset_type): Type for pattern offsets.
- (pattern_offsets_list_type): Type for keeping a list of
- pattern offsets.
- (anchor_list_type): Changed to above type.
- (PATTERN_OFFSETS_LIST_PTR_FULL): Tests if a pattern offsets
- list is full.
- (ANCHOR_LIST_PTR_FULL): Changed to above.
- (BIT_BLOCK_SIZE): Changed to BITS_BLOCK_SIZE and moved to
- above bits list routines below regex_compile.
- (op_list_type): Defined to be pattern_offsets_list_type.
- (compile_stack_type): Changed offsets to be
- pattern_offset_type instead of unsigned.
- (pointer): Changed the name of all structure fields from this
- to `avail'.
- (COMPILE_STACK_FULL): Changed so the stack is full if `avail'
- is equal to `size' instead of `size' - 1.
- (GET_BUFFER_SPACE): Changed `>=' to `>' in the while statement.
- (regex_compile): Added variable `enough_memory' so could check
- that routine that verifies '$' positions could return an
- allocation error.
- (group_count): Deleted this variable, as `regnum' already does
- this work.
- (op_list): Added this variable to keep track of operations
- needed for verifying '$' positions.
- (anchor_list): Now initialize using routine
- `init_pattern_offsets_list'.
- Consolidated the three bits_list initializations.
- In case '$': Instead of trying to go past constructs which can
- follow '$', merely detect the special case where it has to be
- at the pattern's end, fix up any fixup jumps if necessary,
- record the anchor if necessary and add an `endline' (and
- possibly two `no-op's) to the pattern; will call a routine at
- the end to verify if it's in a valid position or not.
- (init_pattern_offsets_list): Added to initialize pattern
- offsets lists.
- (extend_anchor_list): Renamed this extend_pattern_offsets_list
- and renamed parameters and internal variables appropriately.
- (add_pattern_offset): Added this routine which both
- record_anchor_position and add_op call.
- (adjust_pattern_offsets_list): Add this routine to adjust by
- some increment all the pattern offsets a list of such after a
- given position.
- (record_anchor_position): Now send in offset instead of
- calculating it and just call add_pattern_offset.
- (adjust_anchor_list): Replaced by above routine.
- (remove_intervening_anchors): If the anchor is an `endline'
- then replace it with `endline_in_repeat' instead of `no_op'.
- (add_op): Added this routine to call in regex_compile
- wherever push something relevant to verifying '$' positions.
- (verify_and_adjust_endlines): Added routine to (1) verify that
- '$'s in a pattern buffer (represented by `endline') were in
- valid positions and (2) whether or not they were anchors.
- (BITS_BLOCK_SIZE): Renamed BIT_BLOCK_SIZE and moved to right
- above bits list routines.
- (BITS_BLOCK): Defines which array element of a bits list the
- bit corresponding to a given position is in.
- (BITS_MASK): Has a 1 where the bit (in a bit list array element)
- for a given position is.
-
-Mon Apr 1 12:09:06 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.c (BIT_BLOCK_SIZE): Defined this for using with
- bits_list_type, abstracted from level_list_type so could use
- for more things than just the level match status.
- (regex_compile): Renamed `level_list' variable to
- `level_match_status'.
- Added variable `group_match_status' of type bits_list_type.
- Kept track of whether or not for all groups any of them
- matched other than the empty string, so detect if a back
- reference in front of a '^' made it nonleading or not.
- Do this by setting a match status bit for all active groups
- whenever leave a group that matches other than the empty string.
- Could detect which groups are active by going through the
- stack each time, but or-ing a bits list of active groups with
- a bits list of group match status is faster, so make a bits
- list of active groups instead.
- Have to check that '^' isn't in a leading position before
- going to normal_char.
- Whenever set level match status of the current level, also set
- the match status of all active groups.
- Increase the group count and make that group active whenever
- open a group.
- When close a group, only set the next level down if the
- current level matches other than the empty string, and make
- the current group inactive.
- At a back reference, only set a level's match status if the
- group to which the back reference refers matches other than
- the empty string.
- (init_bits_list): Added to initialize a bits list.
- (get_level_value): Deleted this. (Made into
- get_level_match_status.)
- (extend_bits_list): Added to extend a bits list. (Made this
- from deleted routine `extend_level_list'.)
- (get_bit): Added to get a bit value from a bits list. (Made
- this from deleted routine `get_level_value'.)
- (set_bit_to_value): Added to set a bit in a bits list. (Made
- this from deleted routine `set_level_value'.)
- (get_level_match_status): Added this to get the match status
- of a given level. (Made from get_level_value.)
- (set_this_level, set_next_lower_level): Made all routines
- which set bits extend the bits list if necessary, thus they
- now return an unsigned value to indicate whether or not the
- reallocation failed.
- (increase_level): No longer extends the level list.
- (make_group_active): Added to mark as active a given group in
- an active groups list.
- (make_group_inactive): Added to mark as inactive a given group
- in an active groups list.
- (set_match_status_of_active_groups): Added to set the match
- status of all currently active groups.
- (get_group_match_status): Added to get a given group's match status.
- (no_levels_match_anything): Removed the paramenter LEVEL.
- (PUSH_FAILURE_POINT): Added rms' bug fix and changed RE_NREGS
- to num_internal_regs.
-
-Sun Mar 31 09:04:30 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_ANCHORS_ONLY_AT_ENDS): Added syntax so could
- constrain '^' and '$' to only be anchors if at the beginning
- and end of the pattern.
- (RE_SYNTAX_POSIX_BASIC): Added the above bit.
-
- * regex.c (enum regexcode): Changed `unused' to `no_op'.
- (this_and_lower_levels_match_nothing): Deleted forward reference.
- (regex_compile): case '^': if the syntax bit RE_ANCHORS_ONLY_AT_ENDS
- is set, then '^' is only an anchor if at the beginning of the
- pattern; only record anchor position if the syntax bit
- RE_REPEATED_ANCHORS_AWAY is set; the '^' is a normal char if
- the syntax bit RE_ANCHORS_ONLY_AT_END is set and we're not at
- the beginning of the pattern (and neither RE_CONTEXTUAL_INDEP_OPS
- nor RE_CONTEXTUAL_INDEP_OPS syntax bits are set).
- Only adjust the anchor list if the syntax bit
- RE_REPEATED_ANCHORS_AWAY is set.
-
- * regex.c (level_list_type): Use to detect when '^' is
- in a leading position.
- (regex_compile): Added level_list_type level_list variable in
- which we keep track of whether or not a grouping level (in its
- current or most recent incarnation) matches anything besides the
- empty string. Set the bit for the i-th level when detect it
- should match something other than the empty string and the bit
- for the (i-1)-th level when leave the i-th group. Clear all
- bits for the i-th and higher levels if none of 0--(i - 1)-th's
- bits are set when encounter an alternation operator on that
- level. If no levels are set when hit a '^', then it is in a
- leading position. We keep track of which level we're at by
- increasing a variable current_level whenever we encounter an
- open-group operator and decreasing it whenever we encounter a
- close-group operator.
- Have to adjust the anchor list contents whenever insert
- something ahead of them (such as on_failure_jump's) in the
- pattern.
- (adjust_anchor_list): Adjusts the offsets in an anchor list by
- a given increment starting at a given start position.
- (get_level_value): Returns the bit setting of a given level.
- (set_level_value): Sets the bit of a given level to a given value.
- (set_this_level): Sets (to 1) the bit of a given level.
- (set_next_lower_level): Sets (to 1) the bit of (LEVEL - 1) for a
- given LEVEL.
- (clear_this_and_higher_levels): Clears the bits for a given
- level and any higher levels.
- (extend_level_list): Adds sizeof(unsigned) more bits to a level list.
- (increase_level): Increases by 1 the value of a given level variable.
- (decrease_level): Decreases by 1 the value of a given level variable.
- (lower_levels_match_nothing): Checks if any levels lower than
- the given one match anything.
- (no_levels_match_anything): Checks if any levels match anything.
- (re_match_2): At case wordbeg: before looking at d-1, check that
- we're not at the string's beginning.
- At case wordend: Added some illuminating parentheses.
-
-Mon Mar 25 13:58:51 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_NO_ANCHOR_AT_NEWLINE): Changed syntax bit name
- from RE_ANCHOR_NOT_NEWLINE because an anchor never matches the
- newline itself, just the empty string either before or after it.
- (RE_REPEATED_ANCHORS_AWAY): Added this syntax bit for ignoring
- anchors inside groups which are operated on by repetition
- operators.
- (RE_DOT_MATCHES_NEWLINE): Added this bit so the match-any-character
- operator could match a newline when it's set.
- (RE_SYNTAX_POSIX_BASIC): Set RE_DOT_MATCHES_NEWLINE in this.
- (RE_SYNTAX_POSIX_EXTENDED): Set RE_DOT_MATCHES_NEWLINE and
- RE_REPEATED_ANCHORS_AWAY in this.
- (regerror): Changed prototypes to new POSIX spec.
-
- * regex.c (anchor_list_type): Added so could null out anchors inside
- repeated groups.
- (ANCHOR_LIST_PTR_FULL): Added for above type.
- (compile_stack_element): Changed name from stack_element.
- (compile_stack_type): Changed name from compile_stack.
- (INIT_COMPILE_STACK_SIZE): Changed name from INIT_STACK_SIZE.
- (COMPILE_STACK_EMPTY): Changed name from STACK_EMPTY.
- (COMPILE_STACK_FULL): Changed name from STACK_FULL.
- (regex_compile): Changed SYNTAX parameter to non-const.
- Changed variable name `stack' to `compile_stack'.
- If syntax bit RE_REPEATED_ANCHORS_AWAY is set, then naively put
- anchors in a list when encounter them and then set them to
- `unused' when detect they are within a group operated on by a
- repetition operator. Need something more sophisticated than
- this, as they should only get set to `unused' if they are in
- positions where they would be anchors. Also need a better way to
- detect contextually invalid anchors.
- Changed some commments.
- (is_in_compile_stack): Changed name from `is_in_stack'.
- (extend_anchor_list): Added to do anchor stuff.
- (record_anchor_position): Added to do anchor stuff.
- (remove_intervening_anchors): Added to do anchor stuff.
- (re_match_2): Now match a newline with the match-any-character
- operator if RE_DOT_MATCHES_NEWLINE is set.
- Compacted some code.
- (regcomp): Added new POSIX newline information to the header
- commment.
- If REG_NEWLINE cflag is set, then now unset RE_DOT_MATCHES_NEWLINE
- in syntax.
- (put_in_buffer): Added to do new POSIX regerror spec. Called
- by regerror.
- (regerror): Changed to take a pattern buffer, error buffer and
- its size, and return type `size_t', the size of the full error
- message, and the first ERRBUF_SIZE - 1 characters of the full
- error message in the error buffer.
-
-Wed Feb 27 16:38:33 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (#include <sys/types.h>): Removed this as new POSIX
- standard has the user include it.
- (RE_SYNTAX_POSIX_BASIC and RE_SYNTAX_POSIX_EXTENDED): Removed
- RE_HAT_LISTS_NOT_NEWLINE as new POSIX standard has the cflag
- REG_NEWLINE now set this. Similarly, added syntax bit
- RE_ANCHOR_NOT_NEWLINE as this is now unset by REG_NEWLINE.
- (RE_SYNTAX_POSIX_BASIC): Removed syntax bit
- RE_NO_CONSECUTIVE_REPEATS as POSIX now allows them.
-
- * regex.c (#include <sys/types.h>): Added this as new POSIX
- standard has the user include it instead of us putting it in
- regex.h.
- (extern char *re_syntax_table): Made into an extern so the
- user could allocate it.
- (DO_RANGE): If don't find a range end, now goto invalid_range_end
- instead of unmatched_left_bracket.
- (regex_compile): Made variable SYNTAX non-const.????
- Reformatted some code.
- (re_compile_fastmap): Moved is_a_succeed_n's declaration to
- inner braces.
- Compacted some code.
- (SET_NEWLINE_FLAG): Removed and put inline.
- (regcomp): Made variable `syntax' non-const so can unset
- RE_ANCHOR_NOT_NEWLINE syntax bit if cflag RE_NEWLINE is set.
- If cflag RE_NEWLINE is set, set the RE_HAT_LISTS_NOT_NEWLINE
- syntax bit and unset RE_ANCHOR_NOT_NEWLINE one of `syntax'.
-
-Wed Feb 20 16:33:38 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_NO_CONSECUTIVE_REPEATS): Changed name from
- RE_NO_CONSEC_REPEATS.
- (REG_ENESTING): Deleted this POSIX return value, as the stack
- is now unbounded.
- (struct re_pattern_buffer): Changed some comments.
- (re_compile_pattern): Changed a comment.
- Deleted check on stack upper bound and corresponding error.
- Now when there's no interval contents and it's the end of the
- pattern, go to unmatched_left_curly_brace instead of end_of_pattern.
- Removed nesting_too_deep error, as the stack is now unbounded.
- (regcomp): Removed REG_ENESTING case, as the stack is now unbounded.
- (regerror): Removed REG_ENESTING case, as the stack is now unbounded.
-
- * regex.c (MAX_STACK_SIZE): Deleted because don't need upper
- bound on array indexed with an unsigned number.
-
-Sun Feb 17 15:50:24 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h: Changed and added some comments.
-
- * regex.c (init_syntax_once): Made `_' a word character.
- (re_compile_pattern): Added a comment.
- (re_match_2): Redid header comment.
- (regexec): With header comment about PMATCH, corrected and
- removed details found regex.h, adding a reference.
-
-Fri Feb 15 09:21:31 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.c (DO_RANGE): Removed argument parentheses.
- Now get untranslated range start and end characters and set
- list bits for the translated (if at all) versions of them and
- all characters between them.
- (re_match_2): Now use regs->num_regs instead of num_regs_wanted
- wherever possible.
- (regcomp): Now build case-fold translate table using isupper
- and tolower facilities so will work on foreign language characters.
-
-Sat Feb 9 16:40:03 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_HAT_LISTS_NOT_NEWLINE): Changed syntax bit name
- from RE_LISTS_NOT_NEWLINE as it only affects nonmatching lists.
- Changed all references to the match-beginning-of-string
- operator to match-beginning-of-line operator, as this is what
- it does.
- (RE_NO_CONSEC_REPEATS): Added this syntax bit.
- (RE_SYNTAX_POSIX_BASIC): Added above bit to this.
- (REG_PREMATURE_END): Changed name to REG_EEND.
- (REG_EXCESS_NESTING): Changed name to REG_ENESTING.
- (REG_TOO_BIG): Changed name to REG_ESIZE.
- (REG_INVALID_PREV_RE): Deleted this return POSIX value.
- Added and changed some comments.
-
- * regex.c (re_compile_pattern): Now sets the pattern buffer's
- `return_default_num_regs' field.
- (typedef struct stack_element, stack_type, INIT_STACK_SIZE,
- MAX_STACK_SIZE, STACK_EMPTY, STACK_FULL): Added for regex_compile.
- (INIT_BUF_SIZE): Changed value from 28 to 32.
- (BUF_PUSH): Changed name from BUFPUSH.
- (MAX_BUF_SIZE): Added so could use in many places.
- (IS_CHAR_CLASS_STRING): Replaced is_char_class with this.
- (regex_compile): Added a stack which could grow dynamically
- and which has struct elements.
- Go back to initializing `zero_times_ok' and `many_time_ok' to
- 0 and |=ing them inside the loop.
- Now disallow consecutive repetition operators if the syntax
- bit RE_NO_CONSEC_REPEATS is set.
- Now detect trailing backslash when the compiler is expecting a
- `?' or a `+'.
- Changed calls to GET_BUFFER_SPACE which asked for 6 to ask for
- 3, as that's all they needed.
- Now check for trailing backslash inside lists.
- Now disallow an empty alternative right before an end-of-line
- operator.
- Now get buffer space before leaving space for a fixup jump.
- Now check if at pattern end when at open-interval operator.
- Added some comments.
- Now check if non-interval repetition operators follow an
- interval one if the syntax bit RE_NO_CONSEC_REPEATS is set.
- Now only check if what precedes an interval repetition
- operator isn't a regular expression which matches one
- character if the syntax bit RE_NO_CONSEC_REPEATS is set.
- Now return "Unmatched [ or [^" instead of "Unmatched [".
- (is_in_stack): Added to check if a given register number is in
- the stack.
- (re_match_2): If initial variable allocations fail, return -2,
- instead of -1.
- Now set reg's `num_regs' field when allocating regs.
- Now before allocating them, free regs->start and end if they
- aren't NULL and return -2 if either allocation fails.
- Now use regs->num_regs instead of num_regs_wanted to control
- regs loops.
- Now increment past the newline when matching it with an
- end-of-line operator.
- (recomp): Added to the header comment.
- Now return REG_ESUBREG if regex_compile returns "Unmatched [
- or [^" instead of doing so if it returns "Unmatched [".
- Now return REG_BADRPT if in addition to returning "Missing
- preceding regular expression", regex_compile returns "Invalid
- preceding regular expression".
- Now return new return value names (see regex.h changes).
- (regexec): Added to header comment.
- Initialize regs structure.
- Now match whole string.
- Now always free regs.start and regs.end instead of just when
- the string matched.
- (regerror): Now return "Regex error: Unmatched [ or [^.\n"
- instead of "Regex error: Unmatched [.\n".
- Now return "Regex error: Preceding regular expression either
- missing or not simple.\n" instead of "Regex error: Missing
- preceding regular expression.\n".
- Removed REG_INVALID_PREV_RE case (it got subsumed into the
- REG_BADRPT case).
-
-Thu Jan 17 09:52:35 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h: Changed a comment.
-
- * regex.c: Changed and added large header comments.
- (re_compile_pattern): Now if detect that `laststart' for an
- interval points to a byte code for a regular expression which
- matches more than one character, make it an internal error.
- (regerror): Return error message, don't print it.
-
-Tue Jan 15 15:32:49 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (regcomp return codes): Added GNU ones.
- Updated some comments.
-
- * regex.c (DO_RANGE): Changed `obscure_syntax' to `syntax'.
- (regex_compile): Added `following_left_brace' to keep track of
- where pseudo interval following a valid interval starts.
- Changed some instances that returned "Invalid regular
- expression" to instead return error strings coinciding with
- POSIX error codes.
- Changed some comments.
- Now consider only things between `[:' and `:]' to be possible
- character class names.
- Now a character class expression can't end a pattern; at
- least a `]' must close the list.
- Now if the syntax bit RE_NO_BK_CURLY_BRACES is set, then a
- valid interval must be followed by yet another to get an error
- for preceding an interval (in this case, the second one) with
- a regular expression that matches more than one character.
- Now if what follows a valid interval begins with a open
- interval operator but doesn't begin a valid interval, then set
- following_left_bracket to it, put it in C and go to
- normal_char label.
- Added some comments.
- Return "Invalid character class name" instead of "Invalid
- character class".
- (regerror): Return messages for all POSIX error codes except
- REG_ECOLLATE and REG_NEWLINE, along with all GNU error codes.
- Added `break's after all cases.
- (main): Call re_set_syntax instead of setting `obscure_syntax'
- directly.
-
-Sat Jan 12 13:37:59 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (Copyright): Updated date.
- (#include <sys/types.h>): Include unconditionally.
- (RE_CANNOT_MATCH_NEWLINE): Deleted this syntax bit.
- (RE_SYNTAX_POSIX_BASIC, RE_SYNTAX_POSIX_EXTENDED): Removed
- setting the RE_ANCHOR_NOT_NEWLINE syntax bit from these.
- Changed and added some comments.
- (struct re_pattern_buffer): Changed some flags from chars to bits.
- Added field `syntax'; holds which syntax pattern was compiled with.
- Added bit flag `return_default_num_regs'.
- (externs for GNU and Berkeley UNIX routines): Added `const's to
- parameter types to be compatible with POSIX.
- (#define const): Added to support old C compilers.
-
- * regex.c (Copyright): Updated date.
- (enum regexpcode): Deleted `newline'.
- (regex_compile): Renamed re_compile_pattern to this, added a
- syntax parameter so it can set the pattern buffer's `syntax'
- field.
- Made `pattern', and `size' `const's so could pass to POSIX
- interface routines; also made `const' whatever interval
- variables had to be to make this work.
- Changed references to `obscure_syntax' to new parameter `syntax'.
- Deleted putting `newline' in buffer when see `\n'.
- Consider invalid character classes which have nothing wrong
- except the character class name; if so, return character-class error.
- (is_char_class): Added routine for regex_compile.
- (re_compile_pattern): added a new one which calls
- regex_compile with `obscure_syntax' as the actual parameter
- for the formal `syntax'.
- Gave this the old routine's header comments.
- Made `pattern', and `size' `const's so could use POSIX interface
- routine parameters.
- (re_search, re_search_2, re_match, re_match_2): Changed
- `pbufp' to `bufp'.
- (re_search_2, re_match_2): Changed `mstop' to `stop'.
- (re_search, re_search_2): Made all parameters except `regs'
- `const's so could use POSIX interface routines parameters.
- (re_search_2): Added private copies of `const' parameters so
- could change their values.
- (re_match_2): Made all parameters except `regs' `const's so
- could use POSIX interface routines parameters.
- Changed `size1' and `size2' parameters to `size1_arg' and
- `size2_arg' and so could change; added local `size1' and
- `size2' and set to these.
- Added some comments.
- Deleted `newline' case.
- `begline' can also possibly match if `d' contains a newline;
- if it does, we have to increment d to point past the newline.
- Replaced references to `obscure_syntax' with `bufp->syntax'.
- (re_comp, re_exec): Made parameter `s' a `const' so could use POSIX
- interface routines parameters.
- Now call regex_compile, passing `obscure_syntax' via the
- `syntax' parameter.
- (re_exec): Made local `len' a `const' so could pass to re_search.
- (regcomp): Added header comment.
- Added local `syntax' to set and pass to regex_compile rather
- than setting global `obscure_syntax' and passing it.
- Call regex_compile with its `syntax' parameter rather than
- re_compile_pattern.
- Return REG_ECTYPE if character-class error.
- (regexec): Don't initialize `regs' to anything.
- Made `private_preg' a nonpointer so could set to what the
- constant `preg' points.
- Initialize `private_preg's `return_default_num_regs' field to
- zero because want to return `nmatch' registers, not however
- many there are subexpressions in the pattern.
- Also test if `nmatch' > 0 to see if should pass re_match `regs'.
-
-Tue Jan 8 15:57:17 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (struct re_pattern_buffer): Reworded comment.
-
- * regex.c (EXTEND_BUFFER): Also reset beg_interval.
- (re_search_2): Return val if val = -2.
- (NUM_REG_ITEMS): Listed items in comment.
- (NUM_OTHER_ITEMS): Defined this for using in > 1 definition.
- (MAX_NUM_FAILURE_ITEMS): Replaced `+ 2' with NUM_OTHER_ITEMS.
- (NUM_FAILURE_ITEMS): As with definition above and added to
- comment.
- (PUSH_FAILURE_POINT): Replaced `* 2's with `<< 1's.
- (re_match_2): Test with equality with 1 to see pbufp->bol and
- pbufp->eol are set.
-
-Fri Jan 4 15:07:22 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (struct re_pattern_buffer): Reordered some fields.
- Updated some comments.
- Added not_bol and not_eol fields.
- (extern regcomp, regexec, regerror): Added return types.
- (extern regfree): Added `extern'.
-
- * regex.c (min): Deleted unused macro.
- (re_match_2): Compacted some code.
- Removed call to macro `min' from `for' loop.
- Fixed so unused registers get filled with -1's.
- Fail if the pattern buffer's `not_bol' field is set and
- encounter a `begline'.
- Fail if the pattern buffer's `not_eol' field is set and
- encounter a `endline'.
- Deleted redundant check for empty stack in fail case.
- Don't free pattern buffer's components in re_comp.
- (regexec): Initialize variable regs.
- Added `private_preg' pattern buffer so could set `not_bol' and
- `not_eol' fields and hand to re_match.
- Deleted naive attempt to detect anchors.
- Set private pattern buffer's `not_bol' and `not_eol' fields
- according to eflags value.
- `nmatch' must also be > 0 for us to bother allocating
- registers to send to re_match and filling pmatch
- with their results after the call to re_match.
- Send private pattern buffer instead of argument to re_match.
- If use the registers, always free them and then set them to NULL.
- (regerror): Added this Posix routine.
- (regfree): Added this Posix routine.
-
-Tue Jan 1 15:02:45 1991 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_NREGS): Deleted this definition, as now the user
- can choose how many registers to have.
- (REG_NOTBOL, REG_NOTEOL): Defined these Posix eflag bits.
- (REG_NOMATCH, REG_BADPAT, REG_ECOLLATE, REG_ECTYPE,
- REG_EESCAPE, REG_ESUBREG, REG_EBRACK, REG_EPAREN, REG_EBRACE,
- REG_BADBR, REG_ERANGE, REG_ESPACE, REG_BADRPT, REG_ENEWLINE):
- Defined these return values for Posix's regcomp and regexec.
- Updated some comments.
- (struct re_pattern_buffer): Now typedef this as regex_t
- instead of the other way around.
- (struct re_registers): Added num_regs field. Made start and
- end fields pointers to char instead of fixed size arrays.
- (regmatch_t): Added this Posix register type.
- (regcomp, regexec, regerror, regfree): Added externs for these
- Posix routines.
-
- * regex.c (enum boolean): Typedefed this.
- (re_pattern_buffer): Reformatted some comments.
- (re_compile_pattern): Updated some comments.
- Always push start_memory and its attendant number whenever
- encounter a group, not just when its number is less than the
- previous maximum number of registers; same for stop_memory.
- Get 4 bytes of buffer space instead of 2 when pushing a
- set_number_at.
- (can_match_nothing): Added this to elaborate on and replace
- code in re_match_2.
- (reg_info_type): Made can_match_nothing field a bit instead of int.
- (MIN): Added for re_match_2.
- (re_match_2 macros): Changed all `for' loops which used
- RE_NREGS to now use num_internal_regs as upper bounds.
- (MAX_NUM_FAILURE_ITEMS): Use num_internal_regs instead of RE_NREGS.
- (POP_FAILURE_POINT): Added check for empty stack.
- (FREE_VARIABLES): Added this to free (and set to NULL)
- variables allocated in re_match_2.
- (re_match_2): Rearranged parameters to be in order.
- Added variables num_regs_wanted (how many registers the user wants)
- and num_internal_regs (how many groups there are).
- Allocated initial_stack, regstart, regend, old_regstart,
- old_regend, reginfo, best_regstart, and best_regend---all
- which used to be fixed size arrays. Free them all and return
- -1 if any fail.
- Free above variables if starting position pos isn't valid.
- Changed all `for' loops which used RE_NREGS to now use
- num_internal_regs as upper bounds---except for the loops which
- fill regs; then use num_regs_wanted.
- Allocate regs if the user has passed it and wants more than 0
- registers filled.
- Set regs->start[i] and regs->end[i] to -1 if either
- regstart[i] or regend[i] equals -1, not just the first.
- Free allocated variables before returning.
- Updated some comments.
- (regcomp): Return REG_ESPACE, REG_BADPAT, REG_EPAREN when
- appropriate.
- Free translate array.
- (regexec): Added this Posix interface routine.
-
-Mon Dec 24 14:21:13 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h: If _POSIX_SOURCE is defined then #include <sys/types.h>.
- Added syntax bit RE_CANNOT_MATCH_NEWLINE.
- Defined Posix cflags: REG_EXTENDED, REG_NEWLINE, REG_ICASE, and
- REG_NOSUB.
- Added fields re_nsub and no_sub to struct re_pattern_buffer.
- Typedefed regex_t to be `struct re_pattern_buffer'.
-
- * regex.c (CHAR_SET_SIZE): Defined this to be 256 and replaced
- incidences of this value with this constant.
- (re_compile_pattern): Added switch case for `\n' and put
- `newline' into the pattern buffer when encounter this.
- Increment the pattern_buffer's `re_nsub' field whenever open a
- group.
- (re_match_2): Match a newline with `newline'---provided the
- syntax bit RE_CANNOT_MATCH_NEWLINE isn't set.
- (regcomp): Added this Posix interface routine.
- (enum test_type): Added interface_test tag.
- (main): Added Posix interface test.
-
-Tue Dec 18 12:58:12 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (struct re_pattern_buffer): reformatted so would fit
- in texinfo documentation.
-
-Thu Nov 29 15:49:16 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_NO_EMPTY_ALTS): Added this bit.
- (RE_SYNTAX_POSIX_EXTENDED): Added above bit.
-
- * regex.c (re_compile_pattern): Disallow empty alternatives only
- when RE_NO_EMPTY_ALTS is set, not when RE_CONTEXTUAL_INVALID_OPS is.
- Changed RE_NO_BK_CURLY_BRACES to RE_NO_BK_PARENS when testing
- for empty groups at label handle_open.
- At label handle_bar: disallow empty alternatives if RE_NO_EMPTY_ALTS
- is set.
- Rewrote some comments.
-
- (re_compile_fastmap): cleaned up code.
-
- (re_search_2): Rewrote comment.
-
- (struct register_info): Added field `inner_groups'; it records
- which groups are inside of the current one.
- Added field can_match_nothing; it's set if the current group
- can match nothing.
- Added field ever_match_something; it's set if current group
- ever matched something.
-
- (INNER_GROUPS): Added macro to access inner_groups field of
- struct register_info.
-
- (CAN_MATCH_NOTHING): Added macro to access can_match_nothing
- field of struct register_info.
-
- (EVER_MATCHED_SOMETHING): Added macro to access
- ever_matched_something field of struct register_info.
-
- (NOTE_INNER_GROUP): Defined macro to record that a given group
- is inside of all currently active groups.
-
- (re_match_2): Added variables *p1 and mcnt2 (multipurpose).
- Added old_regstart and old_regend arrays to hold previous
- register values if they need be restored.
- Initialize added fields and variables.
- case start_memory: Find out if the group can match nothing.
- Save previous register values in old_restart and old_regend.
- Record that current group is inside of all currently active
- groups.
- If the group is inside a loop and it ever matched anything,
- restore its registers to values before the last failed match.
- Restore the registers for the inner groups, too.
- case duplicate: Can back reference to a group that never
- matched if it can match nothing.
-
-Thu Nov 29 11:12:54 1990 Karl Berry (karl at hayley)
-
- * regex.c (bcopy, ...): define these if either _POSIX_SOURCE or
- STDC_HEADERS is defined; same for including <stdlib.h>.
-
-Sat Oct 6 16:04:55 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (struct re_pattern_buffer): Changed field comments.
-
- * regex.c (re_compile_pattern): Allow a `$' to precede an
- alternation operator (`|' or `\|').
- Disallow `^' and/or `$' in empty groups if the syntax bit
- RE_NO_EMPTY_GROUPS is set.
- Wait until have parsed a valid `\{...\}' interval expression
- before testing RE_CONTEXTUAL_INVALID_OPS to see if it's
- invalidated by that.
- Don't use RE_NO_BK_CURLY_BRACES to test whether or not a validly
- parsed interval expression is invalid if it has no preceding re;
- rather, use RE_CONTEXTUAL_INVALID_OPS.
- If an interval parses, but there is no preceding regular
- expression, yet the syntax bit RE_CONTEXTUAL_INDEP_OPS is set,
- then that interval can match the empty regular expression; if
- the bit isn't set, then the characters in the interval
- expression are parsed as themselves (sans the backslashes).
- In unfetch_interval case: Moved PATFETCH to above the test for
- RE_NO_BK_CURLY_BRACES being set, which would force a goto
- normal_backslash; the code at both normal_backsl and normal_char
- expect a character in `c.'
-
-Sun Sep 30 11:13:48 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h: Changed some comments to use the terms used in the
- documentation.
- (RE_CONTEXTUAL_INDEP_OPS): Changed name from `RE_CONTEXT_INDEP_OPS'.
- (RE_LISTS_NOT_NEWLINE): Changed name from `RE_HAT_NOT_NEWLINE.'
- (RE_ANCHOR_NOT_NEWLINE): Added this syntax bit.
- (RE_NO_EMPTY_GROUPS): Added this syntax bit.
- (RE_NO_HYPHEN_RANGE_END): Deleted this syntax bit.
- (RE_SYNTAX_...): Reformatted.
- (RE_SYNTAX_POSIX_BASIC, RE_SYNTAX_EXTENDED): Added syntax bits
- RE_ANCHOR_NOT_NEWLINE and RE_NO_EMPTY_GROUPS, and deleted
- RE_NO_HYPHEN_RANGE_END.
- (RE_SYNTAX_POSIX_EXTENDED): Added syntax bit RE_DOT_NOT_NULL.
-
- * regex.c (bcopy, bcmp, bzero): Define if _POSIX_SOURCE is defined.
- (_POSIX_SOURCE): ifdef this, #include <stdlib.h>
- (#ifdef emacs): Changed comment of the #endif for the its #else
- clause to be `not emacs', not `emacs.'
- (no_pop_jump): Changed name from `jump'.
- (pop_failure_jump): Changed name from `finalize_jump.'
- (maybe_pop_failure_jump): Changed name from `maybe_finalize_jump'.
- (no_pop_jump_n): Changed name from `jump_n.'
- (EXTEND_BUFFER): Use shift instead of multiplication to double
- buf->allocated.
- (DO_RANGE, recompile_pattern): Added macro to set the list bits
- for a range.
- (re_compile_pattern): Fixed grammar problems in some comments.
- Checked that RE_NO_BK_VBAR is set to make `$' valid before a `|'
- and not set to make it valid before a `\|'.
- Checked that RE_NO_BK_PARENS is set to make `$' valid before a ')'
- and not set to make it valid before a `\)'.
- Disallow ranges starting with `-', unless the range is the
- first item in a list, rather than disallowing ranges which end
- with `-'.
- Disallow empty groups if the syntax bit RE_NO_EMPTY_GROUPS is set.
- Disallow nothing preceding `{' and `\{' if they represent the
- open-interval operator and RE_CONTEXTUAL_INVALID_OPS is set.
- (register_info_type): typedef-ed this using `struct register_info.'
- (SET_REGS_MATCHED): Compacted the code.
- (re_match_2): Made it fail if back reference a group which we've
- never matched.
- Made `^' not match a newline if the syntax bit
- RE_ANCHOR_NOT_NEWLINE is set.
- (really_fail): Added this label so could force a final fail that
- would not try to use the failure stack to recover.
-
-Sat Aug 25 14:23:01 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_CONTEXTUAL_OPS): Changed name from RE_CONTEXT_OPS.
- (global): Rewrote comments and rebroke some syntax #define lines.
-
- * regex.c (isgraph): Added definition for sequents.
- (global): Now refer to character set lists as ``lists.''
- Rewrote comments containing ``\('' or ``\)'' to now refer to
- ``groups.''
- (RE_CONTEXTUAL_OPS): Changed name from RE_CONTEXT_OPS.
-
- (re_compile_pattern): Expanded header comment.
-
-Sun Jul 15 14:50:25 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_CONTEX_INDEP_OPS): the comment's sense got turned
- around when we changed how it read; changed it to be correct.
-
-Sat Jul 14 16:38:06 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_NO_EMPTY_BK_REF): changed name to
- RE_NO_MISSING_BK_REF, as this describes it better.
-
- * regex.c (re_compile_pattern): changed RE_NO_EMPTY_BK_REF
- to RE_NO_MISSING_BK_REF, as above.
-
-Thu Jul 12 11:45:05 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h (RE_NO_EMPTY_BRACKETS): removed this syntax bit, as
- bracket expressions should *never* be empty regardless of the
- syntax. Removes this bit from RE_SYNTAX_POSIX_BASIC and
- RE_SYNTAX_POSIX_EXTENDED.
-
- * regex.c (SET_LIST_BIT): in the comment, now refer to character
- sets as (non)matching sets, as bracket expressions can now match
- other things in addition to characters.
- (re_compile_pattern): refer to groups as such instead of `\(...\)'
- or somesuch, because groups can now be enclosed in either plain
- parens or backslashed ones, depending on the syntax.
- In the '[' case, added a boolean just_had_a_char_class to detect
- whether or not a character class begins a range (which is invalid).
- Restore way of breaking out of a bracket expression to original way.
- Add way to detect a range if the last thing in a bracket
- expression was a character class.
- Took out check for c != ']' at the end of a character class in
- the else clause, as it had already been checked in the if part
- that also checked the validity of the string.
- Set or clear just_had_a_char_class as appropriate.
- Added some comments. Changed references to character sets to
- ``(non)matching lists.''
-
-Sun Jul 1 12:11:29 1990 Karl Berry (karl at hayley)
-
- * regex.h (BYTEWIDTH): moved back to regex.c.
-
- * regex.h (re_compile_fastmap): removed declaration; this
- shouldn't be advertised.
-
-Mon May 28 15:27:53 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.c (ifndef Sword): Made comments more specific.
- (global): include <stdio.h> so can write fatal messages on
- standard error. Replaced calls to assert with fprintfs to
- stderr and exit (1)'s.
- (PREFETCH): Reformatted to make more readable.
- (AT_STRINGS_BEG): Defined to test if we're at the beginning of
- the virtual concatenation of string1 and string2.
- (AT_STRINGS_END): Defined to test if at the end of the virtual
- concatenation of string1 and string2.
- (AT_WORD_BOUNDARY): Defined to test if are at a word boundary.
- (IS_A_LETTER(d)): Defined to test if the contents of the pointer D
- is a letter.
- (re_match_2): Rewrote the wordbound, notwordbound, wordbeg, wordend,
- begbuf, and endbuf cases in terms of the above four new macros.
- Called SET_REGS_MATCHED in the matchsyntax, matchnotsyntax,
- wordchar, and notwordchar cases.
-
-Mon May 14 14:49:13 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.c (re_search_2): Fixed RANGE to not ever take STARTPOS
- outside of virtual concatenation of STRING1 and STRING2.
- Updated header comment as to this.
- (re_match_2): Clarified comment about MSTOP in header.
-
-Sat May 12 15:39:00 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.c (re_search_2): Checked for out-of-range STARTPOS.
- Added comments.
- When searching backwards, not only get the character with which
- to compare to the fastmap from string2 if the starting position
- >= size1, but also if size1 is zero; this is so won't get a
- segmentation fault if string1 is null.
- Reformatted code at label advance.
-
-Thu Apr 12 20:26:21 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h: Added #pragma once and #ifdef...endif __REGEXP_LIBRARY.
- (RE_EXACTN_VALUE): Added for search.c to use.
- Reworded some comments.
-
- regex.c: Punctuated some comments correctly.
- (NULL): Removed this.
- (RE_EXACTN_VALUE): Added for search.c to use.
- (<ctype.h>): Moved this include to top of file.
- (<assert.h>): Added this include.
- (struct regexpcode): Assigned 0 to unused and 1 to exactn
- because of RE_EXACTN_VALUE.
- Added comment.
- (various macros): Lined up backslashes near end of line.
- (insert_jump): Cleaned up the header comment.
- (re_search): Corrected the header comment.
- (re_search_2): Cleaned up and completed the header comment.
- (re_max_failures): Updated comment.
- (struct register_info): Constructed as bits so as to save space
- on the stack when pushing register information.
- (IS_ACTIVE): Macro for struct register_info.
- (MATCHED_SOMETHING): Macro for struct register_info.
- (NUM_REG_ITEMS): How many register information items for each
- register we have to push on the stack at each failure.
- (MAX_NUM_FAILURE_ITEMS): If push all the registers on failure,
- this is how many items we push on the stack.
- (PUSH_FAILURE_POINT): Now pushes whether or not the register is
- currently active, and whether or not it matched something.
- Checks that there's enough space allocated to accomodate all the
- items we currently want to push. (Before, a test for an empty
- stack sufficed because we always pushed and popped the same
- number of items).
- Replaced ``2'' with MAX_NUM_FAILURE_POINTS when ``2'' refers
- to how many things get pushed on the stack each time.
- When copy the stack into the newly allocated storage, now only copy
- the area in use.
- Clarified comment.
- (POP_FAILURE_POINT): Defined to use in places where put number
- of registers on the stack into a variable before using it to
- decrement the stack, so as to not confuse the compiler.
- (IS_IN_FIRST_STRING): Defined to check if a pointer points into
- the first string.
- (SET_REGS_MATCHED): Changed to use the struct register_info
- bits; also set the matched-something bit to false if the
- register isn't currently active. (This is a redundant setting.)
- (re_match_2): Cleaned up and completed the header comment.
- Updated the failure stack comment.
- Replaced the ``2'' with MAX_NUM_FAILURE_ITEMS in the static
- allocation of initial_stack, because now more than two (now up
- to MAX_FAILURE_ITEMS) items get pushed on the failure stack each
- time.
- Ditto for stackb.
- Trashed restart_seg1, regend_seg1, best_regstart_seg1, and
- best_regend_seg1 because they could have erroneous information
- in them, such as when matching ``a'' (in string1) and ``ab'' (in
- string2) with ``(a)*ab''; before using IS_IN_FIRST_STRING to see
- whether or not the register starts or ends in string1,
- regstart[1] pointed past the end of string1, yet regstart_seg1
- was 0!
- Added variable reg_info of type struct register_info to keep
- track of currently active registers and whether or not they
- currently match anything.
- Commented best_regs_set.
- Trashed reg_active and reg_matched_something and put the
- information they held into reg_info; saves space on the stack.
- Replaced NULL with '\000'.
- In begline case, compacted the code.
- Used assert to exit if had an internal error.
- In begbuf case, because now force the string we're working on
- into string2 if there aren't two strings, now allow d == string2
- if there is no string1 (and the check for that is size1 == 0!);
- also now succeeds if there aren't any strings at all.
- (main, ifdef canned): Put test type into a variable so could
- change it while debugging.
-
-Sat Mar 24 12:24:13 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.c (GET_UNSIGNED_NUMBER): Deleted references to num_fetches.
- (re_compile_pattern): Deleted num_fetches because could keep
- track of the number of fetches done by saving a pointer into the
- pattern.
- Added variable beg_interval to be used as a pointer, as above.
- Assert that beg_interval points to something when it's used as above.
- Initialize succeed_n's to lower_bound because re_compile_fastmap
- needs to know it.
- (re_compile_fastmap): Deleted unnecessary variable is_a_jump_n.
- Added comment.
- (re_match_2): Put number of registers on the stack into a
- variable before using it to decrement the stack, so as to not
- confuse the compiler.
- Updated comments.
- Used error routine instead of printf and exit.
- In exactn case, restored longer code from ``original'' regex.c
- which doesn't test translate inside a loop.
-
- * regex.h: Moved #define NULL and the enum regexpcode definition
- and to regex.c. Changed some comments.
-
- regex.c (global): Updated comments about compiling and for the
- re_compile_pattern jump routines.
- Added #define NULL and the enum regexpcode definition (from
- regex.h).
- (enum regexpcode): Added set_number_at to reset the n's of
- succeed_n's and jump_n's.
- (re_set_syntax): Updated its comment.
- (re_compile_pattern): Moved its heading comment to after its macros.
- Moved its include statement to the top of the file.
- Commented or added to comments of its macros.
- In start_memory case: Push laststart value before adding
- start_memory and its register number to the buffer, as they
- might not get added.
- Added code to put a set_number_at before each succeed_n and one
- after each jump_n; rewrote code in what seemed a more
- straightforward manner to put all these things in the pattern so
- the succeed_n's would correctly jump to the set_number_at's of
- the matching jump_n's, and so the jump_n's would correctly jump
- to after the set_number_at's of the matching succeed_n's.
- Initialize succeed_n n's to -1.
- (insert_op_2): Added this to insert an operation followed by
- two integers.
- (re_compile_fastmap): Added set_number_at case.
- (re_match_2): Moved heading comment to after macros.
- Added mention of REGS to heading comment.
- No longer turn a succeed_n with n = 0 into an on_failure_jump,
- because n needs to be reset each time through a loop.
- Check to see if a succeed_n's n is set by its set_number_at.
- Added set_number_at case.
- Updated some comments.
- (main): Added another main to run posix tests, which is compiled
- ifdef both test and canned. (Old main is still compiled ifdef
- test only).
-
-Tue Mar 19 09:22:55 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.[hc]: Change all instances of the word ``legal'' to
- ``valid'' and all instances of ``illegal'' to ``invalid.''
-
-Sun Mar 4 12:11:31 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h: Added syntax bit RE_NO_EMPTY_RANGES which is set if
- an ending range point has to collate higher or equal to the
- starting range point.
- Added syntax bit RE_NO_HYPHEN_RANGE_END which is set if a hyphen
- can't be an ending range point.
- Set to two above bits in RE_SYNTAX_POSIX_BASIC and
- RE_SYNTAX_POSIX_EXTENDED.
-
- regex.c: (re_compile_pattern): Don't allow empty ranges if the
- RE_NO_EMPTY_RANGES syntax bit is set.
- Don't let a hyphen be a range end if the RE_NO_HYPHEN_RANGE_END
- syntax bit is set.
- (ESTACK_PUSH_2): renamed this PUSH_FAILURE_POINT and made it
- push all the used registers on the stack, as well as the number
- of the highest numbered register used, and (as before) the two
- failure points.
- (re_match_2): Fixed up comments.
- Added arrays best_regstart[], best_regstart_seg1[], best_regend[],
- and best_regend_seg1[] to keep track of the best match so far
- whenever reach the end of the pattern but not the end of the
- string, and there are still failure points on the stack with
- which to backtrack; if so, do the saving and force a fail.
- If reach the end of the pattern but not the end of the string,
- but there are no more failure points to try, restore the best
- match so far, set the registers and return.
- Compacted some code.
- In stop_memory case, if the subexpression we've just left is in
- a loop, push onto the stack the loop's on_failure_jump failure
- point along with the current pointer into the string (d).
- In finalize_jump case, in addition to popping the failure
- points, pop the saved registers.
- In the fail case, restore the registers, as well as the failure
- points.
-
-Sun Feb 18 15:08:10 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.c: (global): Defined a macro GET_BUFFER_SPACE which
- makes sure you have a specified number of buffer bytes
- allocated.
- Redefined the macro BUFPUSH to use this.
- Added comments.
-
- (re_compile_pattern): Call GET_BUFFER_SPACE before storing or
- inserting any jumps.
-
- (re_match_2): Set d to string1 + pos and dend to end_match_1
- only if string1 isn't null.
- Force exit from a loop if it's around empty parentheses.
- In stop_memory case, if found some jumps, increment p2 before
- extracting address to which to jump. Also, don't need to know
- how many more times can jump_n.
- In begline case, d must equal string1 or string2, in that order,
- only if they are not null.
- In maybe_finalize_jump case, skip over start_memorys' and
- stop_memorys' register numbers, too.
-
-Thu Feb 15 15:53:55 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.c (BUFPUSH): off by one goof in deciding whether to
- EXTEND_BUFFER.
-
-Wed Jan 24 17:07:46 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h: Moved definition of NULL to here.
- Got rid of ``In other words...'' comment.
- Added to some comments.
-
- regex.c: (re_compile_pattern): Tried to bulletproof some code,
- i.e., checked if backward references (e.g., p[-1]) were within
- the range of pattern.
-
- (re_compile_fastmap): Fixed a bug in succeed_n part where was
- getting the amount to jump instead of how many times to jump.
-
- (re_search_2): Changed the name of the variable ``total'' to
- ``total_size.''
- Condensed some code.
-
- (re_match_2): Moved the comment about duplicate from above the
- start_memory case to above duplicate case.
-
- (global): Rewrote some comments.
- Added commandline arguments to testing.
-
-Wed Jan 17 11:47:27 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.c: (global): Defined a macro STORE_NUMBER which stores a
- number into two contiguous bytes. Also defined STORE_NUMBER_AND_INCR
- which does the same thing and then increments the pointer to the
- storage place to point after the number.
- Defined a macro EXTRACT_NUMBER which extracts a number from two
- continguous bytes. Also defined EXTRACT_NUMBER_AND_INCR which
- does the same thing and then increments the pointer to the
- source to point to after where the number was.
-
-Tue Jan 16 12:09:19 1990 Kathy Hargreaves (kathy at hayley)
-
- * regex.h: Incorporated rms' changes.
- Defined RE_NO_BK_REFS syntax bit which is set when want to
- interpret back reference patterns as literals.
- Defined RE_NO_EMPTY_BRACKETS syntax bit which is set when want
- empty bracket expressions to be illegal.
- Defined RE_CONTEXTUAL_ILLEGAL_OPS syntax bit which is set when want
- it to be illegal for *, +, ? and { to be first in an re or come
- immediately after a | or a (, and for ^ not to appear in a
- nonleading position and $ in a nontrailing position (outside of
- bracket expressions, that is).
- Defined RE_LIMITED_OPS syntax bit which is set when want +, ?
- and | to always be literals instead of ops.
- Fixed up the Posix syntax.
- Changed the syntax bit comments from saying, e.g., ``0 means...''
- to ``If this bit is set, it means...''.
- Changed the syntax bit defines to use shifts instead of integers.
-
- * regex.c: (global): Incorporated rms' changes.
-
- (re_compile_pattern): Incorporated rms' changes
- Made it illegal for a $ to appear anywhere but inside a bracket
- expression or at the end of an re when RE_CONTEXTUAL_ILLEGAL_OPS
- is set. Made the same hold for $ except it has to be at the
- beginning of an re instead of the end.
- Made the re "[]" illegal if RE_NO_EMPTY_BRACKETS is set.
- Made it illegal for | to be first or last in an re, or immediately
- follow another | or a (.
- Added and embellished some comments.
- Allowed \{ to be interpreted as a literal if RE_NO_BK_CURLY_BRACES
- is set.
- Made it illegal for *, +, ?, and { to appear first in an re, or
- immediately follow a | or a ( when RE_CONTEXTUAL_ILLEGAL_OPS is set.
- Made back references interpreted as literals if RE_NO_BK_REFS is set.
- Made recursive intervals either illegal (if RE_NO_BK_CURLY_BRACES
- isn't set) or interpreted as literals (if is set), if RE_INTERVALS
- is set.
- Made it treat +, ? and | as literals if RE_LIMITED_OPS is set.
- Cleaned up some code.
-
-Thu Dec 21 15:31:32 1989 Kathy Hargreaves (kathy at hayley)
-
- * regex.c: (global): Moved RE_DUP_MAX to regex.h and made it
- equal 2^15 - 1 instead of 1000.
- Defined NULL to be zero.
- Moved the definition of BYTEWIDTH to regex.h.
- Made the global variable obscure_syntax nonstatic so the tests in
- another file could use it.
-
- (re_compile_pattern): Defined a maximum length (CHAR_CLASS_MAX_LENGTH)
- for character class strings (i.e., what's between the [: and the
- :]'s).
- Defined a macro SET_LIST_BIT(c) which sets the bit for C in a
- character set list.
- Took out comments that EXTEND_BUFFER clobbers C.
- Made the string "^" match itself, if not RE_CONTEXT_IND_OPS.
- Added character classes to bracket expressions.
- Change the laststart pointer saved with the start of each
- subexpression to point to start_memory instead of after the
- following register number. This is because the subexpression
- might be in a loop.
- Added comments and compacted some code.
- Made intervals only work if preceded by an re matching a single
- character or a subexpression.
- Made back references to nonexistent subexpressions illegal if
- using POSIX syntax.
- Made intervals work on the last preceding character of a
- concatenation of characters, e.g., ab{0,} matches abbb, not abab.
- Moved macro PREFETCH to outside the routine.
-
- (re_compile_fastmap): Added succeed_n to work analogously to
- on_failure_jump if n is zero and jump_n to work analogously to
- the other backward jumps.
-
- (re_match_2): Defined macro SET_REGS_MATCHED to set which
- current subexpressions had matches within them.
- Changed some comments.
- Added reg_active and reg_matched_something arrays to keep track
- of in which subexpressions currently have matched something.
- Defined MATCHING_IN_FIRST_STRING and replaced ``dend == end_match_1''
- with it to make code easier to understand.
- Fixed so can apply * and intervals to arbitrarily nested
- subexpressions. (Lots of previous bugs here.)
- Changed so won't match a newline if syntax bit RE_DOT_NOT_NULL is set.
- Made the upcase array nonstatic so the testing file could use it also.
-
- (main.c): Moved the tests out to another file.
-
- (tests.c): Moved all the testing stuff here.
-
-Sat Nov 18 19:30:30 1989 Kathy Hargreaves (kathy at hayley)
-
- * regex.c: (re_compile_pattern): Defined RE_DUP_MAX, the maximum
- number of times an interval can match a pattern.
- Added macro GET_UNSIGNED_NUMBER (used to get below):
- Added variables lower_bound and upper_bound for upper and lower
- bounds of intervals.
- Added variable num_fetches so intervals could do backtracking.
- Added code to handle '{' and "\{" and intervals.
- Added to comments.
-
- (store_jump_n): (Added) Stores a jump with a number following the
- relative address (for intervals).
-
- (insert_jump_n): (Added) Inserts a jump_n.
-
- (re_match_2): Defined a macro ESTACK_PUSH_2 for the error stack;
- it checks for overflow and reallocates if necessary.
-
- * regex.h: Added bits (RE_INTERVALS and RE_NO_BK_CURLY_BRACES)
- to obscure syntax to indicate whether or not
- a syntax handles intervals and recognizes either \{ and
- \} or { and } as operators. Also added two syntaxes
- RE_SYNTAX_POSIX_BASIC and RE_POSIX_EXTENDED and two command codes
- to the enumeration regexpcode; they are succeed_n and jump_n.
-
-Sat Nov 18 19:30:30 1989 Kathy Hargreaves (kathy at hayley)
-
- * regex.c: (re_compile_pattern): Defined INIT_BUFF_SIZE to get rid
- of repeated constants in code. Tested with value 1.
- Renamed PATPUSH as BUFPUSH, since it pushes things onto the
- buffer, not the pattern. Also made this macro extend the buffer
- if it's full (so could do the following):
- Took out code at top of loop that checks to see if buffer is going
- to be full after 10 additions (and reallocates if necessary).
-
- (insert_jump): Rearranged declaration lines so comments would read
- better.
-
- (re_match_2): Compacted exactn code and added more comments.
-
- (main): Defined macros TEST_MATCH and MATCH_SELF to do
- testing; took out loop so could use these instead.
-
-Tue Oct 24 20:57:18 1989 Kathy Hargreaves (kathy at hayley)
-
- * regex.c (re_set_syntax): Gave argument `syntax' a type.
- (store_jump, insert_jump): made them void functions.
-
-Local Variables:
-mode: indented-text
-left-margin: 8
-version-control: never
-End:
diff --git a/gnu/lib/libregex/INSTALL b/gnu/lib/libregex/INSTALL
deleted file mode 100644
index 014e0f7..0000000
--- a/gnu/lib/libregex/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 the X Window System).
-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/gnu/lib/libregex/Makefile b/gnu/lib/libregex/Makefile
deleted file mode 100644
index 60f7bdf..0000000
--- a/gnu/lib/libregex/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $Header: /home/ncvs/src/gnu/lib/libregex/Makefile,v 1.18 1996/08/30 02:12:07 peter Exp $
-
-
-LIB= gnuregex
-CFLAGS+=-I${.CURDIR} -DHAVE_STRING_H=1 -DSTDC_HEADERS=1 -DNO_POSIX_COMPAT=1
-SRCS= regex.c
-NOMAN= noman
-
-SUBDIR+= doc
-
-beforeinstall:
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/regex.h \
- ${DESTDIR}/usr/include/gnuregex.h
-
-.include <bsd.lib.mk>
diff --git a/gnu/lib/libregex/Makefile.gnu b/gnu/lib/libregex/Makefile.gnu
deleted file mode 100644
index b8bc209..0000000
--- a/gnu/lib/libregex/Makefile.gnu
+++ /dev/null
@@ -1,99 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-# Makefile for regex.
-#
-# Copyright (C) 1992, 1993 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.
-
-version = 0.12
-
-# You can define CPPFLAGS on the command line. Aside from system-specific
-# flags, you can define:
-# -DREGEX_MALLOC to use malloc/realloc/free instead of alloca.
-# -DDEBUG to enable the compiled pattern disassembler and execution
-# tracing; code runs substantially slower.
-# -DEXTRACT_MACROS to use the macros EXTRACT_* (as opposed to
-# the corresponding C procedures). If not -DDEBUG, the macros
-# are used.
-CPPFLAGS =
-
-# Likewise, you can override CFLAGS to optimize, use -Wall, etc.
-CFLAGS = -g
-
-# Ditto for LDFLAGS and LOADLIBES.
-LDFLAGS =
-LOADLIBES =
-
-srcdir = .
-VPATH = .
-
-CC = gcc
-DEFS = -DHAVE_STRING_H=1
-
-SHELL = /bin/sh
-
-subdirs = doc test
-
-default all:: regex.o
-.PHONY: default all
-
-regex.o: regex.c regex.h
- $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) -c $<
-
-clean mostlyclean::
- rm -f *.o
-
-distclean:: clean
- rm -f Makefile config.status
-
-extraclean:: distclean
- rm -f patch* *~* *\#* *.orig *.rej *.bak core a.out
-
-configure: configure.in
- autoconf
-
-config.status: configure
- sh configure --no-create
-
-Makefile: Makefile.in config.status
- sh config.status
-
-makeargs = $(MFLAGS) CPPFLAGS='$(CPPFLAGS)' CFLAGS='$(CFLAGS)' CC='$(CC)' \
-DEFS='$(DEFS)' LDFLAGS='$(LDFLAGS)' LOADLIBES='$(LOADLIBES)'
-
-default all install \
-mostlyclean clean distclean extraclean realclean \
-TAGS check::
- for d in $(subdirs); do (cd $$d; $(MAKE) $(makeargs) $@); done
-.PHONY: install mostlyclean clean distclean extraclean realclean TAGS check
-
-# Prevent GNU make 3 from overflowing arg limit on system V.
-.NOEXPORT:
-
-distfiles = AUTHORS ChangeLog COPYING INSTALL NEWS README \
- *.in configure regex.c regex.h
-distdir = regex-$(version)
-distargs = version=$(version) distdir=../$(distdir)/$$d
-dist: TAGS configure
- @echo "Version numbers in: Makefile.in, ChangeLog, NEWS,"
- @echo " regex.c, regex.h,"
- @echo " and doc/xregex.texi (if modified)."
- rm -rf $(distdir)
- mkdir $(distdir)
- ln $(distfiles) $(distdir)
- for d in $(subdirs); do (cd $$d; $(MAKE) $(distargs) dist); done
- tar czhf $(distdir).tar.Z $(distdir)
- rm -rf $(distdir)
-.PHONY: dist
diff --git a/gnu/lib/libregex/Makefile.in b/gnu/lib/libregex/Makefile.in
deleted file mode 100644
index a21f970..0000000
--- a/gnu/lib/libregex/Makefile.in
+++ /dev/null
@@ -1,98 +0,0 @@
-# Makefile for regex.
-#
-# Copyright (C) 1992, 1993 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.
-
-version = 0.12
-
-# You can define CPPFLAGS on the command line. Aside from system-specific
-# flags, you can define:
-# -DREGEX_MALLOC to use malloc/realloc/free instead of alloca.
-# -DDEBUG to enable the compiled pattern disassembler and execution
-# tracing; code runs substantially slower.
-# -DEXTRACT_MACROS to use the macros EXTRACT_* (as opposed to
-# the corresponding C procedures). If not -DDEBUG, the macros
-# are used.
-CPPFLAGS =
-
-# Likewise, you can override CFLAGS to optimize, use -Wall, etc.
-CFLAGS = -g
-
-# Ditto for LDFLAGS and LOADLIBES.
-LDFLAGS =
-LOADLIBES =
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-CC = @CC@
-DEFS = @DEFS@
-
-SHELL = /bin/sh
-
-subdirs = doc test
-
-default all:: regex.o
-.PHONY: default all
-
-regex.o: regex.c regex.h
- $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) -c $<
-
-clean mostlyclean::
- rm -f *.o
-
-distclean:: clean
- rm -f Makefile config.status
-
-extraclean:: distclean
- rm -f patch* *~* *\#* *.orig *.rej *.bak core a.out
-
-configure: configure.in
- autoconf
-
-config.status: configure
- sh configure --no-create
-
-Makefile: Makefile.in config.status
- sh config.status
-
-makeargs = $(MFLAGS) CPPFLAGS='$(CPPFLAGS)' CFLAGS='$(CFLAGS)' CC='$(CC)' \
-DEFS='$(DEFS)' LDFLAGS='$(LDFLAGS)' LOADLIBES='$(LOADLIBES)'
-
-default all install \
-mostlyclean clean distclean extraclean realclean \
-TAGS check::
- for d in $(subdirs); do (cd $$d; $(MAKE) $(makeargs) $@); done
-.PHONY: install mostlyclean clean distclean extraclean realclean TAGS check
-
-# Prevent GNU make 3 from overflowing arg limit on system V.
-.NOEXPORT:
-
-distfiles = AUTHORS ChangeLog COPYING INSTALL NEWS README \
- *.in configure regex.c regex.h
-distdir = regex-$(version)
-distargs = version=$(version) distdir=../$(distdir)/$$d
-dist: TAGS configure
- @echo "Version numbers in: Makefile.in, ChangeLog, NEWS,"
- @echo " regex.c, regex.h,"
- @echo " and doc/xregex.texi (if modified)."
- rm -rf $(distdir)
- mkdir $(distdir)
- ln $(distfiles) $(distdir)
- for d in $(subdirs); do (cd $$d; $(MAKE) $(distargs) dist); done
- tar czhf $(distdir).tar.Z $(distdir)
- rm -rf $(distdir)
-.PHONY: dist
diff --git a/gnu/lib/libregex/NEWS b/gnu/lib/libregex/NEWS
deleted file mode 100644
index b3a899b..0000000
--- a/gnu/lib/libregex/NEWS
+++ /dev/null
@@ -1,62 +0,0 @@
-Version 0.12
-
-* regex.c does not #define bcmp/bcopy/bzero if they already are.
-
-* regex.h does not redefine `const' if it is already defined, even if
- __STDC__ is not defined.
-
-* RE_SYNTAX_ED added (same as POSIX BRE's).
-
-* The following bugs have been fixed, among others:
- * The pattern \w+ doesn't infinite loop.
- * The pattern ".+\n" is compiled correctly.
- * Expressions with more than MAX_REGNUM groups are compiled correctly.
-
-* Patterns that end in a repetition operator (e.g., `*') match
- slightly faster if no looping is actually necessary.
-
-Version 0.11 (17 Sep 92)
-
-* Back-references to nonexistent subexpressions, as in the r.e. `abc\1',
- are always invalid. Previously, they could match the literal digit,
- e.g., the stated r.e. might have matched `abc1'.
-
-* Empty subexpressions are always valid (POSIX leaves this undefined).
-
-* Simplified rules for ^ and $ being anchors.
-
-* One minor speedup (rewriting the C procedure `pop_failure_point' as a
- macro again).
-
-* Bug fixes involving:
- - Declarations in regex.h and non-ANSI compilers.
- - Bracket expressions with characters between 0x80-0xff.
- - Memory leak in re_match_2 on systems requiring `alloca (0)' to
- free alloca'd storage.
-
-* Test and documentation files moved into subdirectories.
-
-Version 0.10 (9 Sep 92)
-
-* `obscure_syntax' is now called `re_default_syntax'.
-
-* `re_comp's return type is no longer `const', for compatibility with BSD.
-
-* POSIX syntaxes now include as much functionality as possible
- (consistent with the standard).
-
-* Compilation conditionals normalized to what the rest of GNU is
- migrating towards these days.
-
-* Bug fixes involving:
- - Ranges with characters between 0x80 and 0xff, e.g., [\001-\377].
- - `re_compile_fastmap' and the sequence `.*\n'.
- - Intervals with exact counts, e.g., a{5}.
-
-* Changed distribution to use a standard Makefile, install the info
- files, use a configure script, etc.
-
-Version 0.9
-
-* The longest match was not always chosen: `a*|ab' didn't match `aab'.
-
diff --git a/gnu/lib/libregex/README b/gnu/lib/libregex/README
deleted file mode 100644
index 918e1a0..0000000
--- a/gnu/lib/libregex/README
+++ /dev/null
@@ -1,60 +0,0 @@
-This directory contains the GNU regex library. It is compliant with
-POSIX.2, except for internationalization features.
-
-See the file NEWS for a list of major changes in the current release.
-
-See the file INSTALL for compilation instructions. (The only thing
-installed is the documentation; regex.c is compiled into regex.o, but
-not installed anywhere.)
-
-The subdirectory `doc' contains a (programmers') manual for the library.
-It's probably out-of-date. Improvements are welcome.
-
-The subdirectory `test' contains the various tests we've written.
-
-We know this code is not as fast as it might be. If you have specific
-suggestions, profiling results, or other such useful information to
-report, please do.
-
-Emacs 18 is not going use this revised regex (but Emacs 19 will). If
-you want to try it with Emacs 18, apply the patch at the end of this
-file first.
-
-Mail bug reports to bug-gnu-utils@prep.ai.mit.edu.
-
-Please include an actual regular expression that fails (and the syntax
-used to compile it); without that, there's no way to reproduce the bug,
-so there's no way we can fix it. Even if you include a patch, also
-include the regular expression in error; otherwise, we can't know for
-sure what you're trying to fix.
-
-Here is the patch to make this version of regex work with Emacs 18.
-
-*** ORIG/search.c Tue Jan 8 13:04:55 1991
---- search.c Sun Jan 5 10:57:00 1992
-***************
-*** 25,26 ****
---- 25,28 ----
- #include "commands.h"
-+
-+ #include <sys/types.h>
- #include "regex.h"
-***************
-*** 477,479 ****
- /* really needed. */
-! && *(searchbuf.buffer) == (char) exactn /* first item is "exact match" */
- && searchbuf.buffer[1] + 2 == searchbuf.used) /*first is ONLY item */
---- 479,482 ----
- /* really needed. */
-! /* first item is "exact match" */
-! && *(searchbuf.buffer) == (char) RE_EXACTN_VALUE
- && searchbuf.buffer[1] + 2 == searchbuf.used) /*first is ONLY item */
-***************
-*** 1273,1275 ****
- searchbuf.allocated = 100;
-! searchbuf.buffer = (char *) malloc (searchbuf.allocated);
- searchbuf.fastmap = search_fastmap;
---- 1276,1278 ----
- searchbuf.allocated = 100;
-! searchbuf.buffer = (unsigned char *) malloc (searchbuf.allocated);
- searchbuf.fastmap = search_fastmap;
diff --git a/gnu/lib/libregex/VERSION b/gnu/lib/libregex/VERSION
deleted file mode 100644
index 7182be2..0000000
--- a/gnu/lib/libregex/VERSION
+++ /dev/null
@@ -1,3 +0,0 @@
-GNU regex version 0.12
-
-complete, unmodified regex sources are available from prep.ai.mit.edu.
diff --git a/gnu/lib/libregex/config.status b/gnu/lib/libregex/config.status
deleted file mode 100644
index 1b276aa..0000000
--- a/gnu/lib/libregex/config.status
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host sun-lamp.cs.berkeley.edu:
-#
-# configure
-
-for arg
-do
- case "$arg" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- exec /bin/sh configure ;;
- *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;;
- esac
-done
-
-trap 'rm -f Makefile doc/Makefile test/Makefile; exit 1' 1 3 15
-CC='gcc'
-INSTALL='/usr/bin/install -c'
-INSTALL_PROGRAM='$(INSTALL)'
-INSTALL_DATA='$(INSTALL) -m 644'
-CPP='${CC-cc} -E'
-ALLOCA=''
-LIBS=''
-srcdir='.'
-DEFS=' -DHAVE_STRING_H=1'
-prefix='/usr'
-exec_prefix='${prefix}'
-prsub='s%^prefix\([ ]*\)=\([ ]*\).*$%prefix\1=\2/usr%
-s%^exec_prefix\([ ]*\)=\([ ]*\).*$%exec_prefix\1=\2${prefix}%'
-
-top_srcdir=$srcdir
-for file in .. Makefile doc/Makefile test/Makefile; do if [ "x$file" != "x.." ]; then
- srcdir=$top_srcdir
- # Remove last slash and all that follows it. Not all systems have dirname.
- dir=`echo $file|sed 's%/[^/][^/]*$%%'`
- if test "$dir" != "$file"; then
- test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
- test ! -d $dir && mkdir $dir
- fi
- echo creating $file
- rm -f $file
- echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file
- sed -e "
-$prsub
-s%@CC@%$CC%g
-s%@INSTALL@%$INSTALL%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@CPP@%$CPP%g
-s%@ALLOCA@%$ALLOCA%g
-s%@LIBS@%$LIBS%g
-s%@srcdir@%$srcdir%g
-s%@DEFS@%$DEFS%
-" $top_srcdir/${file}.in >> $file
-fi; done
-
-exit 0
diff --git a/gnu/lib/libregex/configure b/gnu/lib/libregex/configure
deleted file mode 100644
index 29c5b80..0000000
--- a/gnu/lib/libregex/configure
+++ /dev/null
@@ -1,462 +0,0 @@
-#!/bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf.
-# Copyright (C) 1991, 1992, 1993 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.
-
-# Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [--no-create]
-# [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE] [TARGET]
-# Ignores all args except --srcdir, --prefix, --exec-prefix, --no-create, and
-# --with-PACKAGE unless this script has special code to handle it.
-
-
-for arg
-do
- # Handle --exec-prefix with a space before the argument.
- if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix=
- # Handle --host with a space before the argument.
- elif test x$next_host = xyes; then next_host=
- # Handle --prefix with a space before the argument.
- elif test x$next_prefix = xyes; then prefix=$arg; next_prefix=
- # Handle --srcdir with a space before the argument.
- elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir=
- else
- case $arg in
- # For backward compatibility, also recognize exact --exec_prefix.
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*)
- exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e)
- next_exec_prefix=yes ;;
-
- -gas | --gas | --ga | --g) ;;
-
- -host=* | --host=* | --hos=* | --ho=* | --h=*) ;;
- -host | --host | --hos | --ho | --h)
- next_host=yes ;;
-
- -nfp | --nfp | --nf) ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no)
- no_create=1 ;;
-
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- next_prefix=yes ;;
-
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
- srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s)
- next_srcdir=yes ;;
-
- -with-* | --with-*)
- package=`echo $arg|sed 's/-*with-//'`
- # Delete all the valid chars; see if any are left.
- if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then
- echo "configure: $package: invalid package name" >&2; exit 1
- fi
- eval "with_`echo $package|sed s/-/_/g`=1" ;;
-
- *) ;;
- esac
- fi
-done
-
-trap 'rm -f conftest* core; exit 1' 1 3 15
-
-rm -f conftest*
-compile='${CC-cc} $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
-
-# 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.
-unique_file=regex.c
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- srcdirdefaulted=yes
- # Try the directory containing this script, then `..'.
- prog=$0
- confdir=`echo $prog|sed 's%/[^/][^/]*$%%'`
- test "X$confdir" = "X$prog" && confdir=.
- srcdir=$confdir
- if test ! -r $srcdir/$unique_file; then
- srcdir=..
- fi
-fi
-if test ! -r $srcdir/$unique_file; then
- if test x$srcdirdefaulted = xyes; then
- echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2
- else
- echo "configure: Can not find sources in \`${srcdir}'." 1>&2
- fi
- exit 1
-fi
-# Preserve a srcdir of `.' to avoid automounter screwups with pwd.
-# But we can't avoid them for `..', to make subdirectories work.
-case $srcdir in
- .|/*|~*) ;;
- *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute.
-esac
-
-
-if test -z "$CC"; then
- echo checking for gcc
- saveifs="$IFS"; IFS="${IFS}:"
- for dir in $PATH; do
- test -z "$dir" && dir=.
- if test -f $dir/gcc; then
- CC="gcc"
- break
- fi
- done
- IFS="$saveifs"
-fi
-test -z "$CC" && CC="cc"
-
-# Find out if we are using GNU C, under whatever name.
-cat > conftest.c <<EOF
-#ifdef __GNUC__
- yes
-#endif
-EOF
-${CC-cc} -E conftest.c > conftest.out 2>&1
-if egrep yes conftest.out >/dev/null 2>&1; then
- GCC=1 # For later tests.
-fi
-rm -f conftest*
-
-# Make sure to not get the incompatible SysV /etc/install and
-# /usr/sbin/install, which might be in PATH before a BSD-like install,
-# or the SunOS /usr/etc/install directory, or the AIX /bin/install,
-# or the AFS install, which mishandles nonexistent args. (Sigh.)
-if test -z "$INSTALL"; then
- echo checking for install
- saveifs="$IFS"; IFS="${IFS}:"
- for dir in $PATH; do
- test -z "$dir" && dir=.
- case $dir in
- /etc|/usr/sbin|/usr/etc|/usr/afsws/bin) ;;
- *)
- if test -f $dir/install; then
- if grep dspmsg $dir/install >/dev/null 2>&1; then
- : # AIX
- else
- INSTALL="$dir/install -c"
- INSTALL_PROGRAM='$(INSTALL)'
- INSTALL_DATA='$(INSTALL) -m 644'
- break
- fi
- fi
- ;;
- esac
- done
- IFS="$saveifs"
-fi
-INSTALL=${INSTALL-cp}
-INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'}
-INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'}
-
-
-echo checking for AIX
-echo checking how to run the C preprocessor
-if test -z "$CPP"; then
- CPP='${CC-cc} -E'
- cat > conftest.c <<EOF
-#include <stdio.h>
-EOF
-err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
-if test -z "$err"; then
- :
-else
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-
-cat > conftest.c <<EOF
-#ifdef _AIX
- yes
-#endif
-
-EOF
-eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
-if egrep "yes" conftest.out >/dev/null 2>&1; then
- DEFS="$DEFS -D_ALL_SOURCE=1"
-fi
-rm -f conftest*
-
-
-echo checking for DYNIX/ptx libseq
-cat > conftest.c <<EOF
-#if defined(_SEQUENT_)
- yes
-#endif
-
-EOF
-eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
-if egrep "yes" conftest.out >/dev/null 2>&1; then
- SEQUENT=1
-fi
-rm -f conftest*
-
-test -n "$SEQUENT" && test -f /usr/lib/libseq.a &&
- LIBS="$LIBS -lseq"
-
-echo checking for POSIXized ISC
-if test -d /etc/conf/kconfig.d &&
- grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
-then
- ISC=1 # If later tests want to check for ISC.
- DEFS="$DEFS -D_POSIX_SOURCE=1"
- if test -n "$GCC"; then
- CC="$CC -posix"
- else
- CC="$CC -Xp"
- fi
-fi
-
-echo checking for minix/config.h
-cat > conftest.c <<EOF
-#include <minix/config.h>
-EOF
-err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
-if test -z "$err"; then
- MINIX=1
-fi
-rm -f conftest*
-
-# The Minix shell can't assign to the same variable on the same line!
-if test -n "$MINIX"; then
- DEFS="$DEFS -D_POSIX_SOURCE=1"
- DEFS="$DEFS -D_POSIX_1_SOURCE=2"
- DEFS="$DEFS -D_MINIX=1"
-fi
-
-
-echo checking for ANSI C header files
-cat > conftest.c <<EOF
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-EOF
-err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
-if test -z "$err"; then
- # SunOS string.h does not declare mem*, contrary to ANSI.
-echo '#include <string.h>' > conftest.c
-eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
-if egrep "memchr" conftest.out >/dev/null 2>&1; then
- # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-cat > conftest.c <<EOF
-#include <ctype.h>
-#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 $compile
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- DEFS="$DEFS -DSTDC_HEADERS=1"
-fi
-rm -f conftest*
-fi
-rm -f conftest*
-
-fi
-rm -f conftest*
-
-for hdr in string.h
-do
-trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'`
-echo checking for ${hdr}
-cat > conftest.c <<EOF
-#include <${hdr}>
-EOF
-err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
-if test -z "$err"; then
- DEFS="$DEFS -D${trhdr}=1"
-fi
-rm -f conftest*
-done
-
-
-# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
-# for constant arguments. Useless!
-echo checking for working alloca.h
-cat > conftest.c <<EOF
-#include <alloca.h>
-main() { exit(0); }
-t() { char *p = alloca(2 * sizeof(int)); }
-EOF
-if eval $compile; then
- DEFS="$DEFS -DHAVE_ALLOCA_H=1"
-fi
-rm -f conftest*
-
-decl="#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#else
-#ifdef _AIX
- #pragma alloca
-#else
-char *alloca ();
-#endif
-#endif
-#endif
-"
-echo checking for alloca
-cat > conftest.c <<EOF
-$decl
-main() { exit(0); }
-t() { char *p = (char *) alloca(1); }
-EOF
-if eval $compile; then
- :
-else
- alloca_missing=1
-fi
-rm -f conftest*
-
-if test -n "$alloca_missing"; 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
-fi
-
-prog='/* Ultrix mips cc rejects this. */
-typedef int charset[2]; const charset x;
-/* SunOS 4.1.1 cc rejects this. */
-char const *const *p;
-char **p2;
-/* HPUX 7.0 cc rejects these. */
-++p;
-p2 = (char const* const*) p;'
-echo checking for working const
-cat > conftest.c <<EOF
-
-main() { exit(0); }
-t() { $prog }
-EOF
-if eval $compile; then
- :
-else
- DEFS="$DEFS -Dconst="
-fi
-rm -f conftest*
-
-
-if test -z "$prefix"
-then
- echo checking for gcc to derive installation directory prefix
- saveifs="$IFS"; IFS="$IFS:"
- for dir in $PATH; do
- test -z "$dir" && dir=.
- if test $dir != . && test -f $dir/gcc; then
- # Not all systems have dirname.
- prefix=`echo $dir|sed 's%/[^/][^/]*$%%'`
- break
- fi
- done
- IFS="$saveifs"
-fi
-
-
-if test -n "$prefix"; then
- test -z "$exec_prefix" && exec_prefix='${prefix}'
- prsub="s%^prefix\\([ ]*\\)=\\([ ]*\\).*$%prefix\\1=\\2$prefix%"
-fi
-if test -n "$exec_prefix"; then
- prsub="$prsub
-s%^exec_prefix\\([ ]*\\)=\\([ ]*\\).*$%\
-exec_prefix\\1=\\2$exec_prefix%"
-fi
-
-trap 'rm -f config.status; exit 1' 1 3 15
-echo creating config.status
-rm -f config.status
-cat > config.status <<EOF
-#!/bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null`:
-#
-# $0 $*
-
-for arg
-do
- case "\$arg" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- exec /bin/sh $0 $* ;;
- *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;;
- esac
-done
-
-trap 'rm -f Makefile doc/Makefile test/Makefile; exit 1' 1 3 15
-CC='$CC'
-INSTALL='$INSTALL'
-INSTALL_PROGRAM='$INSTALL_PROGRAM'
-INSTALL_DATA='$INSTALL_DATA'
-CPP='$CPP'
-ALLOCA='$ALLOCA'
-LIBS='$LIBS'
-srcdir='$srcdir'
-DEFS='$DEFS'
-prefix='$prefix'
-exec_prefix='$exec_prefix'
-prsub='$prsub'
-EOF
-cat >> config.status <<\EOF
-
-top_srcdir=$srcdir
-for file in .. Makefile doc/Makefile test/Makefile; do if [ "x$file" != "x.." ]; then
- srcdir=$top_srcdir
- # Remove last slash and all that follows it. Not all systems have dirname.
- dir=`echo $file|sed 's%/[^/][^/]*$%%'`
- if test "$dir" != "$file"; then
- test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
- test ! -d $dir && mkdir $dir
- fi
- echo creating $file
- rm -f $file
- echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file
- sed -e "
-$prsub
-s%@CC@%$CC%g
-s%@INSTALL@%$INSTALL%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@CPP@%$CPP%g
-s%@ALLOCA@%$ALLOCA%g
-s%@LIBS@%$LIBS%g
-s%@srcdir@%$srcdir%g
-s%@DEFS@%$DEFS%
-" $top_srcdir/${file}.in >> $file
-fi; done
-
-exit 0
-EOF
-chmod +x config.status
-test -n "$no_create" || ./config.status
-
diff --git a/gnu/lib/libregex/configure.in b/gnu/lib/libregex/configure.in
deleted file mode 100644
index f0fc780..0000000
--- a/gnu/lib/libregex/configure.in
+++ /dev/null
@@ -1,23 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT(regex.c)
-
-AC_PROG_CC
-AC_PROG_INSTALL
-
-dnl I'm not sure if AC_AIX and AC_DYNIX_SEQ are really necessary. The
-dnl Autoconf documentation isn't specific about which BSD functions they
-dnl provide.
-AC_AIX
-AC_DYNIX_SEQ
-AC_ISC_POSIX
-AC_MINIX
-
-AC_STDC_HEADERS
-AC_HAVE_HEADERS(string.h)
-
-AC_ALLOCA
-AC_CONST
-
-AC_PREFIX(gcc)
-
-AC_OUTPUT(Makefile doc/Makefile test/Makefile)
diff --git a/gnu/lib/libregex/doc/Makefile b/gnu/lib/libregex/doc/Makefile
deleted file mode 100644
index 3deaeb7..0000000
--- a/gnu/lib/libregex/doc/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-INFO = regex
-INFOSECTION= "Programming & development tools."
-INFOENTRY_regex= "* Regex: (regex). Regular expression library."
-
-CLEANFILES += regex.texi
-
-regex.texi: xregex.texi ../regex.h
- awk -f ${.CURDIR}/include.awk -vsource=${.CURDIR}/../regex.h \
- < ${.CURDIR}/xregex.texi \
- | expand >$@
-
-.include <bsd.info.mk>
diff --git a/gnu/lib/libregex/doc/include.awk b/gnu/lib/libregex/doc/include.awk
deleted file mode 100644
index a1df3f8..0000000
--- a/gnu/lib/libregex/doc/include.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-# Assume `source' is set with -vsource=filename on the command line.
-#
-/^\[\[\[/ { inclusion = $2; # name of the thing to include.
- printing = 0;
- while ((getline line < source) > 0)
- {
- if (match (line, "\\[\\[\\[end " inclusion "\\]\\]\\]"))
- printing = 0;
-
- if (printing)
- print line;
-
- if (match (line,"\\[\\[\\[begin " inclusion "\\]\\]\\]"))
- printing = 1;
- }
- close (source);
- next;
- }
- { print }
diff --git a/gnu/lib/libregex/doc/xregex.texi b/gnu/lib/libregex/doc/xregex.texi
deleted file mode 100644
index fe01e4e..0000000
--- a/gnu/lib/libregex/doc/xregex.texi
+++ /dev/null
@@ -1,3021 +0,0 @@
-\input texinfo
-@c %**start of header
-@setfilename regex.info
-@settitle Regex
-@c %**end of header
-
-@c \\{fill-paragraph} works better (for me, anyway) if the text in the
-@c source file isn't indented.
-@paragraphindent 2
-
-@c Define a new index for our magic constants.
-@defcodeindex cn
-
-@c Put everything in one index (arbitrarily chosen to be the concept index).
-@syncodeindex cn cp
-@syncodeindex ky cp
-@syncodeindex pg cp
-@syncodeindex tp cp
-@syncodeindex vr cp
-
-@c Here is what we use in the Info `dir' file:
-@c * Regex: (regex). Regular expression library.
-
-
-@ifinfo
-This file documents the GNU regular expression library.
-
-Copyright (C) 1992, 1993 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of this
-manual provided the copyright notice and this permission notice are
-preserved on all copies.
-
-@ignore
-Permission is granted to process this file through TeX and print the
-results, provided the printed document carries a 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
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that the
-section entitled ``GNU General Public License'' is included exactly as
-in the original, and provided that the entire resulting derived work is
-distributed under the terms of a permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions,
-except that the section entitled ``GNU General Public License'' may be
-included in a translation approved by the Free Software Foundation
-instead of in the original English.
-@end ifinfo
-
-
-@titlepage
-
-@title Regex
-@subtitle edition 0.12a
-@subtitle 19 September 1992
-@author Kathryn A. Hargreaves
-@author Karl Berry
-
-@page
-
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1992 Free Software Foundation.
-
-Permission is granted to make and distribute verbatim copies of this
-manual provided the copyright notice and this permission notice are
-preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that the
-section entitled ``GNU General Public License'' is included exactly as
-in the original, and provided that the entire resulting derived work is
-distributed under the terms of a permission notice identical to this
-one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions,
-except that the section entitled ``GNU General Public License'' may be
-included in a translation approved by the Free Software Foundation
-instead of in the original English.
-
-@end titlepage
-
-
-@ifinfo
-@node Top, Overview, (dir), (dir)
-@top Regular Expression Library
-
-This manual documents how to program with the GNU regular expression
-library. This is edition 0.12a of the manual, 19 September 1992.
-
-The first part of this master menu lists the major nodes in this Info
-document, including the index. The rest of the menu lists all the
-lower level nodes in the document.
-
-@menu
-* Overview::
-* Regular Expression Syntax::
-* Common Operators::
-* GNU Operators::
-* GNU Emacs Operators::
-* What Gets Matched?::
-* Programming with Regex::
-* Copying:: Copying and sharing Regex.
-* Index:: General index.
- --- The Detailed Node Listing ---
-
-Regular Expression Syntax
-
-* Syntax Bits::
-* Predefined Syntaxes::
-* Collating Elements vs. Characters::
-* The Backslash Character::
-
-Common Operators
-
-* Match-self Operator:: Ordinary characters.
-* Match-any-character Operator:: .
-* Concatenation Operator:: Juxtaposition.
-* Repetition Operators:: * + ? @{@}
-* Alternation Operator:: |
-* List Operators:: [...] [^...]
-* Grouping Operators:: (...)
-* Back-reference Operator:: \digit
-* Anchoring Operators:: ^ $
-
-Repetition Operators
-
-* Match-zero-or-more Operator:: *
-* Match-one-or-more Operator:: +
-* Match-zero-or-one Operator:: ?
-* Interval Operators:: @{@}
-
-List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]})
-
-* Character Class Operators:: [:class:]
-* Range Operator:: start-end
-
-Anchoring Operators
-
-* Match-beginning-of-line Operator:: ^
-* Match-end-of-line Operator:: $
-
-GNU Operators
-
-* Word Operators::
-* Buffer Operators::
-
-Word Operators
-
-* Non-Emacs Syntax Tables::
-* Match-word-boundary Operator:: \b
-* Match-within-word Operator:: \B
-* Match-beginning-of-word Operator:: \<
-* Match-end-of-word Operator:: \>
-* Match-word-constituent Operator:: \w
-* Match-non-word-constituent Operator:: \W
-
-Buffer Operators
-
-* Match-beginning-of-buffer Operator:: \`
-* Match-end-of-buffer Operator:: \'
-
-GNU Emacs Operators
-
-* Syntactic Class Operators::
-
-Syntactic Class Operators
-
-* Emacs Syntax Tables::
-* Match-syntactic-class Operator:: \sCLASS
-* Match-not-syntactic-class Operator:: \SCLASS
-
-Programming with Regex
-
-* GNU Regex Functions::
-* POSIX Regex Functions::
-* BSD Regex Functions::
-
-GNU Regex Functions
-
-* GNU Pattern Buffers:: The re_pattern_buffer type.
-* GNU Regular Expression Compiling:: re_compile_pattern ()
-* GNU Matching:: re_match ()
-* GNU Searching:: re_search ()
-* Matching/Searching with Split Data:: re_match_2 (), re_search_2 ()
-* Searching with Fastmaps:: re_compile_fastmap ()
-* GNU Translate Tables:: The `translate' field.
-* Using Registers:: The re_registers type and related fns.
-* Freeing GNU Pattern Buffers:: regfree ()
-
-POSIX Regex Functions
-
-* POSIX Pattern Buffers:: The regex_t type.
-* POSIX Regular Expression Compiling:: regcomp ()
-* POSIX Matching:: regexec ()
-* Reporting Errors:: regerror ()
-* Using Byte Offsets:: The regmatch_t type.
-* Freeing POSIX Pattern Buffers:: regfree ()
-
-BSD Regex Functions
-
-* BSD Regular Expression Compiling:: re_comp ()
-* BSD Searching:: re_exec ()
-@end menu
-@end ifinfo
-@node Overview, Regular Expression Syntax, Top, Top
-@chapter Overview
-
-A @dfn{regular expression} (or @dfn{regexp}, or @dfn{pattern}) is a text
-string that describes some (mathematical) set of strings. A regexp
-@var{r} @dfn{matches} a string @var{s} if @var{s} is in the set of
-strings described by @var{r}.
-
-Using the Regex library, you can:
-
-@itemize @bullet
-
-@item
-see if a string matches a specified pattern as a whole, and
-
-@item
-search within a string for a substring matching a specified pattern.
-
-@end itemize
-
-Some regular expressions match only one string, i.e., the set they
-describe has only one member. For example, the regular expression
-@samp{foo} matches the string @samp{foo} and no others. Other regular
-expressions match more than one string, i.e., the set they describe has
-more than one member. For example, the regular expression @samp{f*}
-matches the set of strings made up of any number (including zero) of
-@samp{f}s. As you can see, some characters in regular expressions match
-themselves (such as @samp{f}) and some don't (such as @samp{*}); the
-ones that don't match themselves instead let you specify patterns that
-describe many different strings.
-
-To either match or search for a regular expression with the Regex
-library functions, you must first compile it with a Regex pattern
-compiling function. A @dfn{compiled pattern} is a regular expression
-converted to the internal format used by the library functions. Once
-you've compiled a pattern, you can use it for matching or searching any
-number of times.
-
-The Regex library consists of two source files: @file{regex.h} and
-@file{regex.c}.
-@pindex regex.h
-@pindex regex.c
-Regex provides three groups of functions with which you can operate on
-regular expressions. One group---the @sc{gnu} group---is more powerful
-but not completely compatible with the other two, namely the @sc{posix}
-and Berkeley @sc{unix} groups; its interface was designed specifically
-for @sc{gnu}. The other groups have the same interfaces as do the
-regular expression functions in @sc{posix} and Berkeley
-@sc{unix}.
-
-We wrote this chapter with programmers in mind, not users of
-programs---such as Emacs---that use Regex. We describe the Regex
-library in its entirety, not how to write regular expressions that a
-particular program understands.
-
-
-@node Regular Expression Syntax, Common Operators, Overview, Top
-@chapter Regular Expression Syntax
-
-@cindex regular expressions, syntax of
-@cindex syntax of regular expressions
-
-@dfn{Characters} are things you can type. @dfn{Operators} are things in
-a regular expression that match one or more characters. You compose
-regular expressions from operators, which in turn you specify using one
-or more characters.
-
-Most characters represent what we call the match-self operator, i.e.,
-they match themselves; we call these characters @dfn{ordinary}. Other
-characters represent either all or parts of fancier operators; e.g.,
-@samp{.} represents what we call the match-any-character operator
-(which, no surprise, matches (almost) any character); we call these
-characters @dfn{special}. Two different things determine what
-characters represent what operators:
-
-@enumerate
-@item
-the regular expression syntax your program has told the Regex library to
-recognize, and
-
-@item
-the context of the character in the regular expression.
-@end enumerate
-
-In the following sections, we describe these things in more detail.
-
-@menu
-* Syntax Bits::
-* Predefined Syntaxes::
-* Collating Elements vs. Characters::
-* The Backslash Character::
-@end menu
-
-
-@node Syntax Bits, Predefined Syntaxes, , Regular Expression Syntax
-@section Syntax Bits
-
-@cindex syntax bits
-
-In any particular syntax for regular expressions, some characters are
-always special, others are sometimes special, and others are never
-special. The particular syntax that Regex recognizes for a given
-regular expression depends on the value in the @code{syntax} field of
-the pattern buffer of that regular expression.
-
-You get a pattern buffer by compiling a regular expression. @xref{GNU
-Pattern Buffers}, and @ref{POSIX Pattern Buffers}, for more information
-on pattern buffers. @xref{GNU Regular Expression Compiling}, @ref{POSIX
-Regular Expression Compiling}, and @ref{BSD Regular Expression
-Compiling}, for more information on compiling.
-
-Regex considers the value of the @code{syntax} field to be a collection
-of bits; we refer to these bits as @dfn{syntax bits}. In most cases,
-they affect what characters represent what operators. We describe the
-meanings of the operators to which we refer in @ref{Common Operators},
-@ref{GNU Operators}, and @ref{GNU Emacs Operators}.
-
-For reference, here is the complete list of syntax bits, in alphabetical
-order:
-
-@table @code
-
-@cnindex RE_BACKSLASH_ESCAPE_IN_LIST
-@item RE_BACKSLASH_ESCAPE_IN_LISTS
-If this bit is set, then @samp{\} inside a list (@pxref{List Operators}
-quotes (makes ordinary, if it's special) the following character; if
-this bit isn't set, then @samp{\} is an ordinary character inside lists.
-(@xref{The Backslash Character}, for what `\' does outside of lists.)
-
-@cnindex RE_BK_PLUS_QM
-@item RE_BK_PLUS_QM
-If this bit is set, then @samp{\+} represents the match-one-or-more
-operator and @samp{\?} represents the match-zero-or-more operator; if
-this bit isn't set, then @samp{+} represents the match-one-or-more
-operator and @samp{?} represents the match-zero-or-one operator. This
-bit is irrelevant if @code{RE_LIMITED_OPS} is set.
-
-@cnindex RE_CHAR_CLASSES
-@item RE_CHAR_CLASSES
-If this bit is set, then you can use character classes in lists; if this
-bit isn't set, then you can't.
-
-@cnindex RE_CONTEXT_INDEP_ANCHORS
-@item RE_CONTEXT_INDEP_ANCHORS
-If this bit is set, then @samp{^} and @samp{$} are special anywhere outside
-a list; if this bit isn't set, then these characters are special only in
-certain contexts. @xref{Match-beginning-of-line Operator}, and
-@ref{Match-end-of-line Operator}.
-
-@cnindex RE_CONTEXT_INDEP_OPS
-@item RE_CONTEXT_INDEP_OPS
-If this bit is set, then certain characters are special anywhere outside
-a list; if this bit isn't set, then those characters are special only in
-some contexts and are ordinary elsewhere. Specifically, if this bit
-isn't set then @samp{*}, and (if the syntax bit @code{RE_LIMITED_OPS}
-isn't set) @samp{+} and @samp{?} (or @samp{\+} and @samp{\?}, depending
-on the syntax bit @code{RE_BK_PLUS_QM}) represent repetition operators
-only if they're not first in a regular expression or just after an
-open-group or alternation operator. The same holds for @samp{@{} (or
-@samp{\@{}, depending on the syntax bit @code{RE_NO_BK_BRACES}) if
-it is the beginning of a valid interval and the syntax bit
-@code{RE_INTERVALS} is set.
-
-@cnindex RE_CONTEXT_INVALID_OPS
-@item RE_CONTEXT_INVALID_OPS
-If this bit is set, then repetition and alternation operators can't be
-in certain positions within a regular expression. Specifically, the
-regular expression is invalid if it has:
-
-@itemize @bullet
-
-@item
-a repetition operator first in the regular expression or just after a
-match-beginning-of-line, open-group, or alternation operator; or
-
-@item
-an alternation operator first or last in the regular expression, just
-before a match-end-of-line operator, or just after an alternation or
-open-group operator.
-
-@end itemize
-
-If this bit isn't set, then you can put the characters representing the
-repetition and alternation characters anywhere in a regular expression.
-Whether or not they will in fact be operators in certain positions
-depends on other syntax bits.
-
-@cnindex RE_DOT_NEWLINE
-@item RE_DOT_NEWLINE
-If this bit is set, then the match-any-character operator matches
-a newline; if this bit isn't set, then it doesn't.
-
-@cnindex RE_DOT_NOT_NULL
-@item RE_DOT_NOT_NULL
-If this bit is set, then the match-any-character operator doesn't match
-a null character; if this bit isn't set, then it does.
-
-@cnindex RE_INTERVALS
-@item RE_INTERVALS
-If this bit is set, then Regex recognizes interval operators; if this bit
-isn't set, then it doesn't.
-
-@cnindex RE_LIMITED_OPS
-@item RE_LIMITED_OPS
-If this bit is set, then Regex doesn't recognize the match-one-or-more,
-match-zero-or-one or alternation operators; if this bit isn't set, then
-it does.
-
-@cnindex RE_NEWLINE_ALT
-@item RE_NEWLINE_ALT
-If this bit is set, then newline represents the alternation operator; if
-this bit isn't set, then newline is ordinary.
-
-@cnindex RE_NO_BK_BRACES
-@item RE_NO_BK_BRACES
-If this bit is set, then @samp{@{} represents the open-interval operator
-and @samp{@}} represents the close-interval operator; if this bit isn't
-set, then @samp{\@{} represents the open-interval operator and
-@samp{\@}} represents the close-interval operator. This bit is relevant
-only if @code{RE_INTERVALS} is set.
-
-@cnindex RE_NO_BK_PARENS
-@item RE_NO_BK_PARENS
-If this bit is set, then @samp{(} represents the open-group operator and
-@samp{)} represents the close-group operator; if this bit isn't set, then
-@samp{\(} represents the open-group operator and @samp{\)} represents
-the close-group operator.
-
-@cnindex RE_NO_BK_REFS
-@item RE_NO_BK_REFS
-If this bit is set, then Regex doesn't recognize @samp{\}@var{digit} as
-the back reference operator; if this bit isn't set, then it does.
-
-@cnindex RE_NO_BK_VBAR
-@item RE_NO_BK_VBAR
-If this bit is set, then @samp{|} represents the alternation operator;
-if this bit isn't set, then @samp{\|} represents the alternation
-operator. This bit is irrelevant if @code{RE_LIMITED_OPS} is set.
-
-@cnindex RE_NO_EMPTY_RANGES
-@item RE_NO_EMPTY_RANGES
-If this bit is set, then a regular expression with a range whose ending
-point collates lower than its starting point is invalid; if this bit
-isn't set, then Regex considers such a range to be empty.
-
-@cnindex RE_UNMATCHED_RIGHT_PAREN_ORD
-@item RE_UNMATCHED_RIGHT_PAREN_ORD
-If this bit is set and the regular expression has no matching open-group
-operator, then Regex considers what would otherwise be a close-group
-operator (based on how @code{RE_NO_BK_PARENS} is set) to match @samp{)}.
-
-@end table
-
-
-@node Predefined Syntaxes, Collating Elements vs. Characters, Syntax Bits, Regular Expression Syntax
-@section Predefined Syntaxes
-
-If you're programming with Regex, you can set a pattern buffer's
-(@pxref{GNU Pattern Buffers}, and @ref{POSIX Pattern Buffers})
-@code{syntax} field either to an arbitrary combination of syntax bits
-(@pxref{Syntax Bits}) or else to the configurations defined by Regex.
-These configurations define the syntaxes used by certain
-programs---@sc{gnu} Emacs,
-@cindex Emacs
-@sc{posix} Awk,
-@cindex POSIX Awk
-traditional Awk,
-@cindex Awk
-Grep,
-@cindex Grep
-@cindex Egrep
-Egrep---in addition to syntaxes for @sc{posix} basic and extended
-regular expressions.
-
-The predefined syntaxes--taken directly from @file{regex.h}---are:
-
-@example
-[[[ syntaxes ]]]
-@end example
-
-@node Collating Elements vs. Characters, The Backslash Character, Predefined Syntaxes, Regular Expression Syntax
-@section Collating Elements vs.@: Characters
-
-@sc{posix} generalizes the notion of a character to that of a
-collating element. It defines a @dfn{collating element} to be ``a
-sequence of one or more bytes defined in the current collating sequence
-as a unit of collation.''
-
-This generalizes the notion of a character in
-two ways. First, a single character can map into two or more collating
-elements. For example, the German
-@tex
-`\ss'
-@end tex
-@ifinfo
-``es-zet''
-@end ifinfo
-collates as the collating element @samp{s} followed by another collating
-element @samp{s}. Second, two or more characters can map into one
-collating element. For example, the Spanish @samp{ll} collates after
-@samp{l} and before @samp{m}.
-
-Since @sc{posix}'s ``collating element'' preserves the essential idea of
-a ``character,'' we use the latter, more familiar, term in this document.
-
-@node The Backslash Character, , Collating Elements vs. Characters, Regular Expression Syntax
-@section The Backslash Character
-
-@cindex \
-The @samp{\} character has one of four different meanings, depending on
-the context in which you use it and what syntax bits are set
-(@pxref{Syntax Bits}). It can: 1) stand for itself, 2) quote the next
-character, 3) introduce an operator, or 4) do nothing.
-
-@enumerate
-@item
-It stands for itself inside a list
-(@pxref{List Operators}) if the syntax bit
-@code{RE_BACKSLASH_ESCAPE_IN_LISTS} is not set. For example, @samp{[\]}
-would match @samp{\}.
-
-@item
-It quotes (makes ordinary, if it's special) the next character when you
-use it either:
-
-@itemize @bullet
-@item
-outside a list,@footnote{Sometimes
-you don't have to explicitly quote special characters to make
-them ordinary. For instance, most characters lose any special meaning
-inside a list (@pxref{List Operators}). In addition, if the syntax bits
-@code{RE_CONTEXT_INVALID_OPS} and @code{RE_CONTEXT_INDEP_OPS}
-aren't set, then (for historical reasons) the matcher considers special
-characters ordinary if they are in contexts where the operations they
-represent make no sense; for example, then the match-zero-or-more
-operator (represented by @samp{*}) matches itself in the regular
-expression @samp{*foo} because there is no preceding expression on which
-it can operate. It is poor practice, however, to depend on this
-behavior; if you want a special character to be ordinary outside a list,
-it's better to always quote it, regardless.} or
-
-@item
-inside a list and the syntax bit @code{RE_BACKSLASH_ESCAPE_IN_LISTS} is set.
-
-@end itemize
-
-@item
-It introduces an operator when followed by certain ordinary
-characters---sometimes only when certain syntax bits are set. See the
-cases @code{RE_BK_PLUS_QM}, @code{RE_NO_BK_BRACES}, @code{RE_NO_BK_VAR},
-@code{RE_NO_BK_PARENS}, @code{RE_NO_BK_REF} in @ref{Syntax Bits}. Also:
-
-@itemize @bullet
-@item
-@samp{\b} represents the match-word-boundary operator
-(@pxref{Match-word-boundary Operator}).
-
-@item
-@samp{\B} represents the match-within-word operator
-(@pxref{Match-within-word Operator}).
-
-@item
-@samp{\<} represents the match-beginning-of-word operator @*
-(@pxref{Match-beginning-of-word Operator}).
-
-@item
-@samp{\>} represents the match-end-of-word operator
-(@pxref{Match-end-of-word Operator}).
-
-@item
-@samp{\w} represents the match-word-constituent operator
-(@pxref{Match-word-constituent Operator}).
-
-@item
-@samp{\W} represents the match-non-word-constituent operator
-(@pxref{Match-non-word-constituent Operator}).
-
-@item
-@samp{\`} represents the match-beginning-of-buffer
-operator and @samp{\'} represents the match-end-of-buffer operator
-(@pxref{Buffer Operators}).
-
-@item
-If Regex was compiled with the C preprocessor symbol @code{emacs}
-defined, then @samp{\s@var{class}} represents the match-syntactic-class
-operator and @samp{\S@var{class}} represents the
-match-not-syntactic-class operator (@pxref{Syntactic Class Operators}).
-
-@end itemize
-
-@item
-In all other cases, Regex ignores @samp{\}. For example,
-@samp{\n} matches @samp{n}.
-
-@end enumerate
-
-@node Common Operators, GNU Operators, Regular Expression Syntax, Top
-@chapter Common Operators
-
-You compose regular expressions from operators. In the following
-sections, we describe the regular expression operators specified by
-@sc{posix}; @sc{gnu} also uses these. Most operators have more than one
-representation as characters. @xref{Regular Expression Syntax}, for
-what characters represent what operators under what circumstances.
-
-For most operators that can be represented in two ways, one
-representation is a single character and the other is that character
-preceded by @samp{\}. For example, either @samp{(} or @samp{\(}
-represents the open-group operator. Which one does depends on the
-setting of a syntax bit, in this case @code{RE_NO_BK_PARENS}. Why is
-this so? Historical reasons dictate some of the varying
-representations, while @sc{posix} dictates others.
-
-Finally, almost all characters lose any special meaning inside a list
-(@pxref{List Operators}).
-
-@menu
-* Match-self Operator:: Ordinary characters.
-* Match-any-character Operator:: .
-* Concatenation Operator:: Juxtaposition.
-* Repetition Operators:: * + ? @{@}
-* Alternation Operator:: |
-* List Operators:: [...] [^...]
-* Grouping Operators:: (...)
-* Back-reference Operator:: \digit
-* Anchoring Operators:: ^ $
-@end menu
-
-@node Match-self Operator, Match-any-character Operator, , Common Operators
-@section The Match-self Operator (@var{ordinary character})
-
-This operator matches the character itself. All ordinary characters
-(@pxref{Regular Expression Syntax}) represent this operator. For
-example, @samp{f} is always an ordinary character, so the regular
-expression @samp{f} matches only the string @samp{f}. In
-particular, it does @emph{not} match the string @samp{ff}.
-
-@node Match-any-character Operator, Concatenation Operator, Match-self Operator, Common Operators
-@section The Match-any-character Operator (@code{.})
-
-@cindex @samp{.}
-
-This operator matches any single printing or nonprinting character
-except it won't match a:
-
-@table @asis
-@item newline
-if the syntax bit @code{RE_DOT_NEWLINE} isn't set.
-
-@item null
-if the syntax bit @code{RE_DOT_NOT_NULL} is set.
-
-@end table
-
-The @samp{.} (period) character represents this operator. For example,
-@samp{a.b} matches any three-character string beginning with @samp{a}
-and ending with @samp{b}.
-
-@node Concatenation Operator, Repetition Operators, Match-any-character Operator, Common Operators
-@section The Concatenation Operator
-
-This operator concatenates two regular expressions @var{a} and @var{b}.
-No character represents this operator; you simply put @var{b} after
-@var{a}. The result is a regular expression that will match a string if
-@var{a} matches its first part and @var{b} matches the rest. For
-example, @samp{xy} (two match-self operators) matches @samp{xy}.
-
-@node Repetition Operators, Alternation Operator, Concatenation Operator, Common Operators
-@section Repetition Operators
-
-Repetition operators repeat the preceding regular expression a specified
-number of times.
-
-@menu
-* Match-zero-or-more Operator:: *
-* Match-one-or-more Operator:: +
-* Match-zero-or-one Operator:: ?
-* Interval Operators:: @{@}
-@end menu
-
-@node Match-zero-or-more Operator, Match-one-or-more Operator, , Repetition Operators
-@subsection The Match-zero-or-more Operator (@code{*})
-
-@cindex @samp{*}
-
-This operator repeats the smallest possible preceding regular expression
-as many times as necessary (including zero) to match the pattern.
-@samp{*} represents this operator. For example, @samp{o*}
-matches any string made up of zero or more @samp{o}s. Since this
-operator operates on the smallest preceding regular expression,
-@samp{fo*} has a repeating @samp{o}, not a repeating @samp{fo}. So,
-@samp{fo*} matches @samp{f}, @samp{fo}, @samp{foo}, and so on.
-
-Since the match-zero-or-more operator is a suffix operator, it may be
-useless as such when no regular expression precedes it. This is the
-case when it:
-
-@itemize @bullet
-@item
-is first in a regular expression, or
-
-@item
-follows a match-beginning-of-line, open-group, or alternation
-operator.
-
-@end itemize
-
-@noindent
-Three different things can happen in these cases:
-
-@enumerate
-@item
-If the syntax bit @code{RE_CONTEXT_INVALID_OPS} is set, then the
-regular expression is invalid.
-
-@item
-If @code{RE_CONTEXT_INVALID_OPS} isn't set, but
-@code{RE_CONTEXT_INDEP_OPS} is, then @samp{*} represents the
-match-zero-or-more operator (which then operates on the empty string).
-
-@item
-Otherwise, @samp{*} is ordinary.
-
-@end enumerate
-
-@cindex backtracking
-The matcher processes a match-zero-or-more operator by first matching as
-many repetitions of the smallest preceding regular expression as it can.
-Then it continues to match the rest of the pattern.
-
-If it can't match the rest of the pattern, it backtracks (as many times
-as necessary), each time discarding one of the matches until it can
-either match the entire pattern or be certain that it cannot get a
-match. For example, when matching @samp{ca*ar} against @samp{caaar},
-the matcher first matches all three @samp{a}s of the string with the
-@samp{a*} of the regular expression. However, it cannot then match the
-final @samp{ar} of the regular expression against the final @samp{r} of
-the string. So it backtracks, discarding the match of the last @samp{a}
-in the string. It can then match the remaining @samp{ar}.
-
-
-@node Match-one-or-more Operator, Match-zero-or-one Operator, Match-zero-or-more Operator, Repetition Operators
-@subsection The Match-one-or-more Operator (@code{+} or @code{\+})
-
-@cindex @samp{+}
-
-If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't recognize
-this operator. Otherwise, if the syntax bit @code{RE_BK_PLUS_QM} isn't
-set, then @samp{+} represents this operator; if it is, then @samp{\+}
-does.
-
-This operator is similar to the match-zero-or-more operator except that
-it repeats the preceding regular expression at least once;
-@pxref{Match-zero-or-more Operator}, for what it operates on, how some
-syntax bits affect it, and how Regex backtracks to match it.
-
-For example, supposing that @samp{+} represents the match-one-or-more
-operator; then @samp{ca+r} matches, e.g., @samp{car} and
-@samp{caaaar}, but not @samp{cr}.
-
-@node Match-zero-or-one Operator, Interval Operators, Match-one-or-more Operator, Repetition Operators
-@subsection The Match-zero-or-one Operator (@code{?} or @code{\?})
-@cindex @samp{?}
-
-If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't
-recognize this operator. Otherwise, if the syntax bit
-@code{RE_BK_PLUS_QM} isn't set, then @samp{?} represents this operator;
-if it is, then @samp{\?} does.
-
-This operator is similar to the match-zero-or-more operator except that
-it repeats the preceding regular expression once or not at all;
-@pxref{Match-zero-or-more Operator}, to see what it operates on, how
-some syntax bits affect it, and how Regex backtracks to match it.
-
-For example, supposing that @samp{?} represents the match-zero-or-one
-operator; then @samp{ca?r} matches both @samp{car} and @samp{cr}, but
-nothing else.
-
-@node Interval Operators, , Match-zero-or-one Operator, Repetition Operators
-@subsection Interval Operators (@code{@{} @dots{} @code{@}} or @code{\@{} @dots{} @code{\@}})
-
-@cindex interval expression
-@cindex @samp{@{}
-@cindex @samp{@}}
-@cindex @samp{\@{}
-@cindex @samp{\@}}
-
-If the syntax bit @code{RE_INTERVALS} is set, then Regex recognizes
-@dfn{interval expressions}. They repeat the smallest possible preceding
-regular expression a specified number of times.
-
-If the syntax bit @code{RE_NO_BK_BRACES} is set, @samp{@{} represents
-the @dfn{open-interval operator} and @samp{@}} represents the
-@dfn{close-interval operator} ; otherwise, @samp{\@{} and @samp{\@}} do.
-
-Specifically, supposing that @samp{@{} and @samp{@}} represent the
-open-interval and close-interval operators; then:
-
-@table @code
-@item @{@var{count}@}
-matches exactly @var{count} occurrences of the preceding regular
-expression.
-
-@item @{@var{min,}@}
-matches @var{min} or more occurrences of the preceding regular
-expression.
-
-@item @{@var{min, max}@}
-matches at least @var{min} but no more than @var{max} occurrences of
-the preceding regular expression.
-
-@end table
-
-The interval expression (but not necessarily the regular expression that
-contains it) is invalid if:
-
-@itemize @bullet
-@item
-@var{min} is greater than @var{max}, or
-
-@item
-any of @var{count}, @var{min}, or @var{max} are outside the range
-zero to @code{RE_DUP_MAX} (which symbol @file{regex.h}
-defines).
-
-@end itemize
-
-If the interval expression is invalid and the syntax bit
-@code{RE_NO_BK_BRACES} is set, then Regex considers all the
-characters in the would-be interval to be ordinary. If that bit
-isn't set, then the regular expression is invalid.
-
-If the interval expression is valid but there is no preceding regular
-expression on which to operate, then if the syntax bit
-@code{RE_CONTEXT_INVALID_OPS} is set, the regular expression is invalid.
-If that bit isn't set, then Regex considers all the characters---other
-than backslashes, which it ignores---in the would-be interval to be
-ordinary.
-
-
-@node Alternation Operator, List Operators, Repetition Operators, Common Operators
-@section The Alternation Operator (@code{|} or @code{\|})
-
-@kindex |
-@kindex \|
-@cindex alternation operator
-@cindex or operator
-
-If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't
-recognize this operator. Otherwise, if the syntax bit
-@code{RE_NO_BK_VBAR} is set, then @samp{|} represents this operator;
-otherwise, @samp{\|} does.
-
-Alternatives match one of a choice of regular expressions:
-if you put the character(s) representing the alternation operator between
-any two regular expressions @var{a} and @var{b}, the result matches
-the union of the strings that @var{a} and @var{b} match. For
-example, supposing that @samp{|} is the alternation operator, then
-@samp{foo|bar|quux} would match any of @samp{foo}, @samp{bar} or
-@samp{quux}.
-
-@ignore
-@c Nobody needs to disallow empty alternatives any more.
-If the syntax bit @code{RE_NO_EMPTY_ALTS} is set, then if either of the regular
-expressions @var{a} or @var{b} is empty, the
-regular expression is invalid. More precisely, if this syntax bit is
-set, then the alternation operator can't:
-
-@itemize @bullet
-@item
-be first or last in a regular expression;
-
-@item
-follow either another alternation operator or an open-group operator
-(@pxref{Grouping Operators}); or
-
-@item
-precede a close-group operator.
-
-@end itemize
-
-@noindent
-For example, supposing @samp{(} and @samp{)} represent the open and
-close-group operators, then @samp{|foo}, @samp{foo|}, @samp{foo||bar},
-@samp{foo(|bar)}, and @samp{(foo|)bar} would all be invalid.
-@end ignore
-
-The alternation operator operates on the @emph{largest} possible
-surrounding regular expressions. (Put another way, it has the lowest
-precedence of any regular expression operator.)
-Thus, the only way you can
-delimit its arguments is to use grouping. For example, if @samp{(} and
-@samp{)} are the open and close-group operators, then @samp{fo(o|b)ar}
-would match either @samp{fooar} or @samp{fobar}. (@samp{foo|bar} would
-match @samp{foo} or @samp{bar}.)
-
-@cindex backtracking
-The matcher usually tries all combinations of alternatives so as to
-match the longest possible string. For example, when matching
-@samp{(fooq|foo)*(qbarquux|bar)} against @samp{fooqbarquux}, it cannot
-take, say, the first (``depth-first'') combination it could match, since
-then it would be content to match just @samp{fooqbar}.
-
-@comment xx something about leftmost-longest
-
-
-@node List Operators, Grouping Operators, Alternation Operator, Common Operators
-@section List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]})
-
-@cindex matching list
-@cindex @samp{[}
-@cindex @samp{]}
-@cindex @samp{^}
-@cindex @samp{-}
-@cindex @samp{\}
-@cindex @samp{[^}
-@cindex nonmatching list
-@cindex matching newline
-@cindex bracket expression
-
-@dfn{Lists}, also called @dfn{bracket expressions}, are a set of one or
-more items. An @dfn{item} is a character,
-@ignore
-(These get added when they get implemented.)
-a collating symbol, an equivalence class expression,
-@end ignore
-a character class expression, or a range expression. The syntax bits
-affect which kinds of items you can put in a list. We explain the last
-two items in subsections below. Empty lists are invalid.
-
-A @dfn{matching list} matches a single character represented by one of
-the list items. You form a matching list by enclosing one or more items
-within an @dfn{open-matching-list operator} (represented by @samp{[})
-and a @dfn{close-list operator} (represented by @samp{]}).
-
-For example, @samp{[ab]} matches either @samp{a} or @samp{b}.
-@samp{[ad]*} matches the empty string and any string composed of just
-@samp{a}s and @samp{d}s in any order. Regex considers invalid a regular
-expression with a @samp{[} but no matching
-@samp{]}.
-
-@dfn{Nonmatching lists} are similar to matching lists except that they
-match a single character @emph{not} represented by one of the list
-items. You use an @dfn{open-nonmatching-list operator} (represented by
-@samp{[^}@footnote{Regex therefore doesn't consider the @samp{^} to be
-the first character in the list. If you put a @samp{^} character first
-in (what you think is) a matching list, you'll turn it into a
-nonmatching list.}) instead of an open-matching-list operator to start a
-nonmatching list.
-
-For example, @samp{[^ab]} matches any character except @samp{a} or
-@samp{b}.
-
-If the @code{posix_newline} field in the pattern buffer (@pxref{GNU
-Pattern Buffers} is set, then nonmatching lists do not match a newline.
-
-Most characters lose any special meaning inside a list. The special
-characters inside a list follow.
-
-@table @samp
-@item ]
-ends the list if it's not the first list item. So, if you want to make
-the @samp{]} character a list item, you must put it first.
-
-@item \
-quotes the next character if the syntax bit @code{RE_BACKSLASH_ESCAPE_IN_LISTS} is
-set.
-
-@ignore
-Put these in if they get implemented.
-
-@item [.
-represents the open-collating-symbol operator (@pxref{Collating Symbol
-Operators}).
-
-@item .]
-represents the close-collating-symbol operator.
-
-@item [=
-represents the open-equivalence-class operator (@pxref{Equivalence Class
-Operators}).
-
-@item =]
-represents the close-equivalence-class operator.
-
-@end ignore
-
-@item [:
-represents the open-character-class operator (@pxref{Character Class
-Operators}) if the syntax bit @code{RE_CHAR_CLASSES} is set and what
-follows is a valid character class expression.
-
-@item :]
-represents the close-character-class operator if the syntax bit
-@code{RE_CHAR_CLASSES} is set and what precedes it is an
-open-character-class operator followed by a valid character class name.
-
-@item -
-represents the range operator (@pxref{Range Operator}) if it's
-not first or last in a list or the ending point of a range.
-
-@end table
-
-@noindent
-All other characters are ordinary. For example, @samp{[.*]} matches
-@samp{.} and @samp{*}.
-
-@menu
-* Character Class Operators:: [:class:]
-* Range Operator:: start-end
-@end menu
-
-@ignore
-(If collating symbols and equivalence class expressions get implemented,
-then add this.)
-
-node Collating Symbol Operators
-subsubsection Collating Symbol Operators (@code{[.} @dots{} @code{.]})
-
-If the syntax bit @code{XX} is set, then you can represent
-collating symbols inside lists. You form a @dfn{collating symbol} by
-putting a collating element between an @dfn{open-collating-symbol
-operator} and an @dfn{close-collating-symbol operator}. @samp{[.}
-represents the open-collating-symbol operator and @samp{.]} represents
-the close-collating-symbol operator. For example, if @samp{ll} is a
-collating element, then @samp{[[.ll.]]} would match @samp{ll}.
-
-node Equivalence Class Operators
-subsubsection Equivalence Class Operators (@code{[=} @dots{} @code{=]})
-@cindex equivalence class expression in regex
-@cindex @samp{[=} in regex
-@cindex @samp{=]} in regex
-
-If the syntax bit @code{XX} is set, then Regex recognizes equivalence class
-expressions inside lists. A @dfn{equivalence class expression} is a set
-of collating elements which all belong to the same equivalence class.
-You form an equivalence class expression by putting a collating
-element between an @dfn{open-equivalence-class operator} and a
-@dfn{close-equivalence-class operator}. @samp{[=} represents the
-open-equivalence-class operator and @samp{=]} represents the
-close-equivalence-class operator. For example, if @samp{a} and @samp{A}
-were an equivalence class, then both @samp{[[=a=]]} and @samp{[[=A=]]}
-would match both @samp{a} and @samp{A}. If the collating element in an
-equivalence class expression isn't part of an equivalence class, then
-the matcher considers the equivalence class expression to be a collating
-symbol.
-
-@end ignore
-
-@node Character Class Operators, Range Operator, , List Operators
-@subsection Character Class Operators (@code{[:} @dots{} @code{:]})
-
-@cindex character classes
-@cindex @samp{[:} in regex
-@cindex @samp{:]} in regex
-
-If the syntax bit @code{RE_CHARACTER_CLASSES} is set, then Regex
-recognizes character class expressions inside lists. A @dfn{character
-class expression} matches one character from a given class. You form a
-character class expression by putting a character class name between an
-@dfn{open-character-class operator} (represented by @samp{[:}) and a
-@dfn{close-character-class operator} (represented by @samp{:]}). The
-character class names and their meanings are:
-
-@table @code
-
-@item alnum
-letters and digits
-
-@item alpha
-letters
-
-@item blank
-system-dependent; for @sc{gnu}, a space or tab
-
-@item cntrl
-control characters (in the @sc{ascii} encoding, code 0177 and codes
-less than 040)
-
-@item digit
-digits
-
-@item graph
-same as @code{print} except omits space
-
-@item lower
-lowercase letters
-
-@item print
-printable characters (in the @sc{ascii} encoding, space
-tilde---codes 040 through 0176)
-
-@item punct
-neither control nor alphanumeric characters
-
-@item space
-space, carriage return, newline, vertical tab, and form feed
-
-@item upper
-uppercase letters
-
-@item xdigit
-hexadecimal digits: @code{0}--@code{9}, @code{a}--@code{f}, @code{A}--@code{F}
-
-@end table
-
-@noindent
-These correspond to the definitions in the C library's @file{<ctype.h>}
-facility. For example, @samp{[:alpha:]} corresponds to the standard
-facility @code{isalpha}. Regex recognizes character class expressions
-only inside of lists; so @samp{[[:alpha:]]} matches any letter, but
-@samp{[:alpha:]} outside of a bracket expression and not followed by a
-repetition operator matches just itself.
-
-@node Range Operator, , Character Class Operators, List Operators
-@subsection The Range Operator (@code{-})
-
-Regex recognizes @dfn{range expressions} inside a list. They represent
-those characters
-that fall between two elements in the current collating sequence. You
-form a range expression by putting a @dfn{range operator} between two
-@ignore
-(If these get implemented, then substitute this for ``characters.'')
-of any of the following: characters, collating elements, collating symbols,
-and equivalence class expressions. The starting point of the range and
-the ending point of the range don't have to be the same kind of item,
-e.g., the starting point could be a collating element and the ending
-point could be an equivalence class expression. If a range's ending
-point is an equivalence class, then all the collating elements in that
-class will be in the range.
-@end ignore
-characters.@footnote{You can't use a character class for the starting
-or ending point of a range, since a character class is not a single
-character.} @samp{-} represents the range operator. For example,
-@samp{a-f} within a list represents all the characters from @samp{a}
-through @samp{f}
-inclusively.
-
-If the syntax bit @code{RE_NO_EMPTY_RANGES} is set, then if the range's
-ending point collates less than its starting point, the range (and the
-regular expression containing it) is invalid. For example, the regular
-expression @samp{[z-a]} would be invalid. If this bit isn't set, then
-Regex considers such a range to be empty.
-
-Since @samp{-} represents the range operator, if you want to make a
-@samp{-} character itself
-a list item, you must do one of the following:
-
-@itemize @bullet
-@item
-Put the @samp{-} either first or last in the list.
-
-@item
-Include a range whose starting point collates strictly lower than
-@samp{-} and whose ending point collates equal or higher. Unless a
-range is the first item in a list, a @samp{-} can't be its starting
-point, but @emph{can} be its ending point. That is because Regex
-considers @samp{-} to be the range operator unless it is preceded by
-another @samp{-}. For example, in the @sc{ascii} encoding, @samp{)},
-@samp{*}, @samp{+}, @samp{,}, @samp{-}, @samp{.}, and @samp{/} are
-contiguous characters in the collating sequence. You might think that
-@samp{[)-+--/]} has two ranges: @samp{)-+} and @samp{--/}. Rather, it
-has the ranges @samp{)-+} and @samp{+--}, plus the character @samp{/}, so
-it matches, e.g., @samp{,}, not @samp{.}.
-
-@item
-Put a range whose starting point is @samp{-} first in the list.
-
-@end itemize
-
-For example, @samp{[-a-z]} matches a lowercase letter or a hyphen (in
-English, in @sc{ascii}).
-
-
-@node Grouping Operators, Back-reference Operator, List Operators, Common Operators
-@section Grouping Operators (@code{(} @dots{} @code{)} or @code{\(} @dots{} @code{\)})
-
-@kindex (
-@kindex )
-@kindex \(
-@kindex \)
-@cindex grouping
-@cindex subexpressions
-@cindex parenthesizing
-
-A @dfn{group}, also known as a @dfn{subexpression}, consists of an
-@dfn{open-group operator}, any number of other operators, and a
-@dfn{close-group operator}. Regex treats this sequence as a unit, just
-as mathematics and programming languages treat a parenthesized
-expression as a unit.
-
-Therefore, using @dfn{groups}, you can:
-
-@itemize @bullet
-@item
-delimit the argument(s) to an alternation operator (@pxref{Alternation
-Operator}) or a repetition operator (@pxref{Repetition
-Operators}).
-
-@item
-keep track of the indices of the substring that matched a given group.
-@xref{Using Registers}, for a precise explanation.
-This lets you:
-
-@itemize @bullet
-@item
-use the back-reference operator (@pxref{Back-reference Operator}).
-
-@item
-use registers (@pxref{Using Registers}).
-
-@end itemize
-
-@end itemize
-
-If the syntax bit @code{RE_NO_BK_PARENS} is set, then @samp{(} represents
-the open-group operator and @samp{)} represents the
-close-group operator; otherwise, @samp{\(} and @samp{\)} do.
-
-If the syntax bit @code{RE_UNMATCHED_RIGHT_PAREN_ORD} is set and a
-close-group operator has no matching open-group operator, then Regex
-considers it to match @samp{)}.
-
-
-@node Back-reference Operator, Anchoring Operators, Grouping Operators, Common Operators
-@section The Back-reference Operator (@dfn{\}@var{digit})
-
-@cindex back references
-
-If the syntax bit @code{RE_NO_BK_REF} isn't set, then Regex recognizes
-back references. A back reference matches a specified preceding group.
-The back reference operator is represented by @samp{\@var{digit}}
-anywhere after the end of a regular expression's @w{@var{digit}-th}
-group (@pxref{Grouping Operators}).
-
-@var{digit} must be between @samp{1} and @samp{9}. The matcher assigns
-numbers 1 through 9 to the first nine groups it encounters. By using
-one of @samp{\1} through @samp{\9} after the corresponding group's
-close-group operator, you can match a substring identical to the
-one that the group does.
-
-Back references match according to the following (in all examples below,
-@samp{(} represents the open-group, @samp{)} the close-group, @samp{@{}
-the open-interval and @samp{@}} the close-interval operator):
-
-@itemize @bullet
-@item
-If the group matches a substring, the back reference matches an
-identical substring. For example, @samp{(a)\1} matches @samp{aa} and
-@samp{(bana)na\1bo\1} matches @samp{bananabanabobana}. Likewise,
-@samp{(.*)\1} matches any (newline-free if the syntax bit
-@code{RE_DOT_NEWLINE} isn't set) string that is composed of two
-identical halves; the @samp{(.*)} matches the first half and the
-@samp{\1} matches the second half.
-
-@item
-If the group matches more than once (as it might if followed
-by, e.g., a repetition operator), then the back reference matches the
-substring the group @emph{last} matched. For example,
-@samp{((a*)b)*\1\2} matches @samp{aabababa}; first @w{group 1} (the
-outer one) matches @samp{aab} and @w{group 2} (the inner one) matches
-@samp{aa}. Then @w{group 1} matches @samp{ab} and @w{group 2} matches
-@samp{a}. So, @samp{\1} matches @samp{ab} and @samp{\2} matches
-@samp{a}.
-
-@item
-If the group doesn't participate in a match, i.e., it is part of an
-alternative not taken or a repetition operator allows zero repetitions
-of it, then the back reference makes the whole match fail. For example,
-@samp{(one()|two())-and-(three\2|four\3)} matches @samp{one-and-three}
-and @samp{two-and-four}, but not @samp{one-and-four} or
-@samp{two-and-three}. For example, if the pattern matches
-@samp{one-and-}, then its @w{group 2} matches the empty string and its
-@w{group 3} doesn't participate in the match. So, if it then matches
-@samp{four}, then when it tries to back reference @w{group 3}---which it
-will attempt to do because @samp{\3} follows the @samp{four}---the match
-will fail because @w{group 3} didn't participate in the match.
-
-@end itemize
-
-You can use a back reference as an argument to a repetition operator. For
-example, @samp{(a(b))\2*} matches @samp{a} followed by two or more
-@samp{b}s. Similarly, @samp{(a(b))\2@{3@}} matches @samp{abbbb}.
-
-If there is no preceding @w{@var{digit}-th} subexpression, the regular
-expression is invalid.
-
-
-@node Anchoring Operators, , Back-reference Operator, Common Operators
-@section Anchoring Operators
-
-@cindex anchoring
-@cindex regexp anchoring
-
-These operators can constrain a pattern to match only at the beginning or
-end of the entire string or at the beginning or end of a line.
-
-@menu
-* Match-beginning-of-line Operator:: ^
-* Match-end-of-line Operator:: $
-@end menu
-
-
-@node Match-beginning-of-line Operator, Match-end-of-line Operator, , Anchoring Operators
-@subsection The Match-beginning-of-line Operator (@code{^})
-
-@kindex ^
-@cindex beginning-of-line operator
-@cindex anchors
-
-This operator can match the empty string either at the beginning of the
-string or after a newline character. Thus, it is said to @dfn{anchor}
-the pattern to the beginning of a line.
-
-In the cases following, @samp{^} represents this operator. (Otherwise,
-@samp{^} is ordinary.)
-
-@itemize @bullet
-
-@item
-It (the @samp{^}) is first in the pattern, as in @samp{^foo}.
-
-@cnindex RE_CONTEXT_INDEP_ANCHORS @r{(and @samp{^})}
-@item
-The syntax bit @code{RE_CONTEXT_INDEP_ANCHORS} is set, and it is outside
-a bracket expression.
-
-@cindex open-group operator and @samp{^}
-@cindex alternation operator and @samp{^}
-@item
-It follows an open-group or alternation operator, as in @samp{a\(^b\)}
-and @samp{a\|^b}. @xref{Grouping Operators}, and @ref{Alternation
-Operator}.
-
-@end itemize
-
-These rules imply that some valid patterns containing @samp{^} cannot be
-matched; for example, @samp{foo^bar} if @code{RE_CONTEXT_INDEP_ANCHORS}
-is set.
-
-@vindex not_bol @r{field in pattern buffer}
-If the @code{not_bol} field is set in the pattern buffer (@pxref{GNU
-Pattern Buffers}), then @samp{^} fails to match at the beginning of the
-string. @xref{POSIX Matching}, for when you might find this useful.
-
-@vindex newline_anchor @r{field in pattern buffer}
-If the @code{newline_anchor} field is set in the pattern buffer, then
-@samp{^} fails to match after a newline. This is useful when you do not
-regard the string to be matched as broken into lines.
-
-
-@node Match-end-of-line Operator, , Match-beginning-of-line Operator, Anchoring Operators
-@subsection The Match-end-of-line Operator (@code{$})
-
-@kindex $
-@cindex end-of-line operator
-@cindex anchors
-
-This operator can match the empty string either at the end of
-the string or before a newline character in the string. Thus, it is
-said to @dfn{anchor} the pattern to the end of a line.
-
-It is always represented by @samp{$}. For example, @samp{foo$} usually
-matches, e.g., @samp{foo} and, e.g., the first three characters of
-@samp{foo\nbar}.
-
-Its interaction with the syntax bits and pattern buffer fields is
-exactly the dual of @samp{^}'s; see the previous section. (That is,
-``beginning'' becomes ``end'', ``next'' becomes ``previous'', and
-``after'' becomes ``before''.)
-
-
-@node GNU Operators, GNU Emacs Operators, Common Operators, Top
-@chapter GNU Operators
-
-Following are operators that @sc{gnu} defines (and @sc{posix} doesn't).
-
-@menu
-* Word Operators::
-* Buffer Operators::
-@end menu
-
-@node Word Operators, Buffer Operators, , GNU Operators
-@section Word Operators
-
-The operators in this section require Regex to recognize parts of words.
-Regex uses a syntax table to determine whether or not a character is
-part of a word, i.e., whether or not it is @dfn{word-constituent}.
-
-@menu
-* Non-Emacs Syntax Tables::
-* Match-word-boundary Operator:: \b
-* Match-within-word Operator:: \B
-* Match-beginning-of-word Operator:: \<
-* Match-end-of-word Operator:: \>
-* Match-word-constituent Operator:: \w
-* Match-non-word-constituent Operator:: \W
-@end menu
-
-@node Non-Emacs Syntax Tables, Match-word-boundary Operator, , Word Operators
-@subsection Non-Emacs Syntax Tables
-
-A @dfn{syntax table} is an array indexed by the characters in your
-character set. In the @sc{ascii} encoding, therefore, a syntax table
-has 256 elements. Regex always uses a @code{char *} variable
-@code{re_syntax_table} as its syntax table. In some cases, it
-initializes this variable and in others it expects you to initialize it.
-
-@itemize @bullet
-@item
-If Regex is compiled with the preprocessor symbols @code{emacs} and
-@code{SYNTAX_TABLE} both undefined, then Regex allocates
-@code{re_syntax_table} and initializes an element @var{i} either to
-@code{Sword} (which it defines) if @var{i} is a letter, number, or
-@samp{_}, or to zero if it's not.
-
-@item
-If Regex is compiled with @code{emacs} undefined but @code{SYNTAX_TABLE}
-defined, then Regex expects you to define a @code{char *} variable
-@code{re_syntax_table} to be a valid syntax table.
-
-@item
-@xref{Emacs Syntax Tables}, for what happens when Regex is compiled with
-the preprocessor symbol @code{emacs} defined.
-
-@end itemize
-
-@node Match-word-boundary Operator, Match-within-word Operator, Non-Emacs Syntax Tables, Word Operators
-@subsection The Match-word-boundary Operator (@code{\b})
-
-@cindex @samp{\b}
-@cindex word boundaries, matching
-
-This operator (represented by @samp{\b}) matches the empty string at
-either the beginning or the end of a word. For example, @samp{\brat\b}
-matches the separate word @samp{rat}.
-
-@node Match-within-word Operator, Match-beginning-of-word Operator, Match-word-boundary Operator, Word Operators
-@subsection The Match-within-word Operator (@code{\B})
-
-@cindex @samp{\B}
-
-This operator (represented by @samp{\B}) matches the empty string within
-a word. For example, @samp{c\Brat\Be} matches @samp{crate}, but
-@samp{dirty \Brat} doesn't match @samp{dirty rat}.
-
-@node Match-beginning-of-word Operator, Match-end-of-word Operator, Match-within-word Operator, Word Operators
-@subsection The Match-beginning-of-word Operator (@code{\<})
-
-@cindex @samp{\<}
-
-This operator (represented by @samp{\<}) matches the empty string at the
-beginning of a word.
-
-@node Match-end-of-word Operator, Match-word-constituent Operator, Match-beginning-of-word Operator, Word Operators
-@subsection The Match-end-of-word Operator (@code{\>})
-
-@cindex @samp{\>}
-
-This operator (represented by @samp{\>}) matches the empty string at the
-end of a word.
-
-@node Match-word-constituent Operator, Match-non-word-constituent Operator, Match-end-of-word Operator, Word Operators
-@subsection The Match-word-constituent Operator (@code{\w})
-
-@cindex @samp{\w}
-
-This operator (represented by @samp{\w}) matches any word-constituent
-character.
-
-@node Match-non-word-constituent Operator, , Match-word-constituent Operator, Word Operators
-@subsection The Match-non-word-constituent Operator (@code{\W})
-
-@cindex @samp{\W}
-
-This operator (represented by @samp{\W}) matches any character that is
-not word-constituent.
-
-
-@node Buffer Operators, , Word Operators, GNU Operators
-@section Buffer Operators
-
-Following are operators which work on buffers. In Emacs, a @dfn{buffer}
-is, naturally, an Emacs buffer. For other programs, Regex considers the
-entire string to be matched as the buffer.
-
-@menu
-* Match-beginning-of-buffer Operator:: \`
-* Match-end-of-buffer Operator:: \'
-@end menu
-
-
-@node Match-beginning-of-buffer Operator, Match-end-of-buffer Operator, , Buffer Operators
-@subsection The Match-beginning-of-buffer Operator (@code{\`})
-
-@cindex @samp{\`}
-
-This operator (represented by @samp{\`}) matches the empty string at the
-beginning of the buffer.
-
-@node Match-end-of-buffer Operator, , Match-beginning-of-buffer Operator, Buffer Operators
-@subsection The Match-end-of-buffer Operator (@code{\'})
-
-@cindex @samp{\'}
-
-This operator (represented by @samp{\'}) matches the empty string at the
-end of the buffer.
-
-
-@node GNU Emacs Operators, What Gets Matched?, GNU Operators, Top
-@chapter GNU Emacs Operators
-
-Following are operators that @sc{gnu} defines (and @sc{posix} doesn't)
-that you can use only when Regex is compiled with the preprocessor
-symbol @code{emacs} defined.
-
-@menu
-* Syntactic Class Operators::
-@end menu
-
-
-@node Syntactic Class Operators, , , GNU Emacs Operators
-@section Syntactic Class Operators
-
-The operators in this section require Regex to recognize the syntactic
-classes of characters. Regex uses a syntax table to determine this.
-
-@menu
-* Emacs Syntax Tables::
-* Match-syntactic-class Operator:: \sCLASS
-* Match-not-syntactic-class Operator:: \SCLASS
-@end menu
-
-@node Emacs Syntax Tables, Match-syntactic-class Operator, , Syntactic Class Operators
-@subsection Emacs Syntax Tables
-
-A @dfn{syntax table} is an array indexed by the characters in your
-character set. In the @sc{ascii} encoding, therefore, a syntax table
-has 256 elements.
-
-If Regex is compiled with the preprocessor symbol @code{emacs} defined,
-then Regex expects you to define and initialize the variable
-@code{re_syntax_table} to be an Emacs syntax table. Emacs' syntax
-tables are more complicated than Regex's own (@pxref{Non-Emacs Syntax
-Tables}). @xref{Syntax, , Syntax, emacs, The GNU Emacs User's Manual},
-for a description of Emacs' syntax tables.
-
-@node Match-syntactic-class Operator, Match-not-syntactic-class Operator, Emacs Syntax Tables, Syntactic Class Operators
-@subsection The Match-syntactic-class Operator (@code{\s}@var{class})
-
-@cindex @samp{\s}
-
-This operator matches any character whose syntactic class is represented
-by a specified character. @samp{\s@var{class}} represents this operator
-where @var{class} is the character representing the syntactic class you
-want. For example, @samp{w} represents the syntactic
-class of word-constituent characters, so @samp{\sw} matches any
-word-constituent character.
-
-@node Match-not-syntactic-class Operator, , Match-syntactic-class Operator, Syntactic Class Operators
-@subsection The Match-not-syntactic-class Operator (@code{\S}@var{class})
-
-@cindex @samp{\S}
-
-This operator is similar to the match-syntactic-class operator except
-that it matches any character whose syntactic class is @emph{not}
-represented by the specified character. @samp{\S@var{class}} represents
-this operator. For example, @samp{w} represents the syntactic class of
-word-constituent characters, so @samp{\Sw} matches any character that is
-not word-constituent.
-
-
-@node What Gets Matched?, Programming with Regex, GNU Emacs Operators, Top
-@chapter What Gets Matched?
-
-Regex usually matches strings according to the ``leftmost longest''
-rule; that is, it chooses the longest of the leftmost matches. This
-does not mean that for a regular expression containing subexpressions
-that it simply chooses the longest match for each subexpression, left to
-right; the overall match must also be the longest possible one.
-
-For example, @samp{(ac*)(c*d[ac]*)\1} matches @samp{acdacaaa}, not
-@samp{acdac}, as it would if it were to choose the longest match for the
-first subexpression.
-
-
-@node Programming with Regex, Copying, What Gets Matched?, Top
-@chapter Programming with Regex
-
-Here we describe how you use the Regex data structures and functions in
-C programs. Regex has three interfaces: one designed for @sc{gnu}, one
-compatible with @sc{posix} and one compatible with Berkeley @sc{unix}.
-
-@menu
-* GNU Regex Functions::
-* POSIX Regex Functions::
-* BSD Regex Functions::
-@end menu
-
-
-@node GNU Regex Functions, POSIX Regex Functions, , Programming with Regex
-@section GNU Regex Functions
-
-If you're writing code that doesn't need to be compatible with either
-@sc{posix} or Berkeley @sc{unix}, you can use these functions. They
-provide more options than the other interfaces.
-
-@menu
-* GNU Pattern Buffers:: The re_pattern_buffer type.
-* GNU Regular Expression Compiling:: re_compile_pattern ()
-* GNU Matching:: re_match ()
-* GNU Searching:: re_search ()
-* Matching/Searching with Split Data:: re_match_2 (), re_search_2 ()
-* Searching with Fastmaps:: re_compile_fastmap ()
-* GNU Translate Tables:: The `translate' field.
-* Using Registers:: The re_registers type and related fns.
-* Freeing GNU Pattern Buffers:: regfree ()
-@end menu
-
-
-@node GNU Pattern Buffers, GNU Regular Expression Compiling, , GNU Regex Functions
-@subsection GNU Pattern Buffers
-
-@cindex pattern buffer, definition of
-@tindex re_pattern_buffer @r{definition}
-@tindex struct re_pattern_buffer @r{definition}
-
-To compile, match, or search for a given regular expression, you must
-supply a pattern buffer. A @dfn{pattern buffer} holds one compiled
-regular expression.@footnote{Regular expressions are also referred to as
-``patterns,'' hence the name ``pattern buffer.''}
-
-You can have several different pattern buffers simultaneously, each
-holding a compiled pattern for a different regular expression.
-
-@file{regex.h} defines the pattern buffer @code{struct} as follows:
-
-@example
-[[[ pattern_buffer ]]]
-@end example
-
-
-@node GNU Regular Expression Compiling, GNU Matching, GNU Pattern Buffers, GNU Regex Functions
-@subsection GNU Regular Expression Compiling
-
-In @sc{gnu}, you can both match and search for a given regular
-expression. To do either, you must first compile it in a pattern buffer
-(@pxref{GNU Pattern Buffers}).
-
-@cindex syntax initialization
-@vindex re_syntax_options @r{initialization}
-Regular expressions match according to the syntax with which they were
-compiled; with @sc{gnu}, you indicate what syntax you want by setting
-the variable @code{re_syntax_options} (declared in @file{regex.h} and
-defined in @file{regex.c}) before calling the compiling function,
-@code{re_compile_pattern} (see below). @xref{Syntax Bits}, and
-@ref{Predefined Syntaxes}.
-
-You can change the value of @code{re_syntax_options} at any time.
-Usually, however, you set its value once and then never change it.
-
-@cindex pattern buffer initialization
-@code{re_compile_pattern} takes a pattern buffer as an argument. You
-must initialize the following fields:
-
-@table @code
-
-@item translate @r{initialization}
-
-@item translate
-@vindex translate @r{initialization}
-Initialize this to point to a translate table if you want one, or to
-zero if you don't. We explain translate tables in @ref{GNU Translate
-Tables}.
-
-@item fastmap
-@vindex fastmap @r{initialization}
-Initialize this to nonzero if you want a fastmap, or to zero if you
-don't.
-
-@item buffer
-@itemx allocated
-@vindex buffer @r{initialization}
-@vindex allocated @r{initialization}
-@findex malloc
-If you want @code{re_compile_pattern} to allocate memory for the
-compiled pattern, set both of these to zero. If you have an existing
-block of memory (allocated with @code{malloc}) you want Regex to use,
-set @code{buffer} to its address and @code{allocated} to its size (in
-bytes).
-
-@code{re_compile_pattern} uses @code{realloc} to extend the space for
-the compiled pattern as necessary.
-
-@end table
-
-To compile a pattern buffer, use:
-
-@findex re_compile_pattern
-@example
-char *
-re_compile_pattern (const char *@var{regex}, const int @var{regex_size},
- struct re_pattern_buffer *@var{pattern_buffer})
-@end example
-
-@noindent
-@var{regex} is the regular expression's address, @var{regex_size} is its
-length, and @var{pattern_buffer} is the pattern buffer's address.
-
-If @code{re_compile_pattern} successfully compiles the regular
-expression, it returns zero and sets @code{*@var{pattern_buffer}} to the
-compiled pattern. It sets the pattern buffer's fields as follows:
-
-@table @code
-@item buffer
-@vindex buffer @r{field, set by @code{re_compile_pattern}}
-to the compiled pattern.
-
-@item used
-@vindex used @r{field, set by @code{re_compile_pattern}}
-to the number of bytes the compiled pattern in @code{buffer} occupies.
-
-@item syntax
-@vindex syntax @r{field, set by @code{re_compile_pattern}}
-to the current value of @code{re_syntax_options}.
-
-@item re_nsub
-@vindex re_nsub @r{field, set by @code{re_compile_pattern}}
-to the number of subexpressions in @var{regex}.
-
-@item fastmap_accurate
-@vindex fastmap_accurate @r{field, set by @code{re_compile_pattern}}
-to zero on the theory that the pattern you're compiling is different
-than the one previously compiled into @code{buffer}; in that case (since
-you can't make a fastmap without a compiled pattern),
-@code{fastmap} would either contain an incompatible fastmap, or nothing
-at all.
-
-@c xx what else?
-@end table
-
-If @code{re_compile_pattern} can't compile @var{regex}, it returns an
-error string corresponding to one of the errors listed in @ref{POSIX
-Regular Expression Compiling}.
-
-
-@node GNU Matching, GNU Searching, GNU Regular Expression Compiling, GNU Regex Functions
-@subsection GNU Matching
-
-@cindex matching with GNU functions
-
-Matching the @sc{gnu} way means trying to match as much of a string as
-possible starting at a position within it you specify. Once you've compiled
-a pattern into a pattern buffer (@pxref{GNU Regular Expression
-Compiling}), you can ask the matcher to match that pattern against a
-string using:
-
-@findex re_match
-@example
-int
-re_match (struct re_pattern_buffer *@var{pattern_buffer},
- const char *@var{string}, const int @var{size},
- const int @var{start}, struct re_registers *@var{regs})
-@end example
-
-@noindent
-@var{pattern_buffer} is the address of a pattern buffer containing a
-compiled pattern. @var{string} is the string you want to match; it can
-contain newline and null characters. @var{size} is the length of that
-string. @var{start} is the string index at which you want to
-begin matching; the first character of @var{string} is at index zero.
-@xref{Using Registers}, for a explanation of @var{regs}; you can safely
-pass zero.
-
-@code{re_match} matches the regular expression in @var{pattern_buffer}
-against the string @var{string} according to the syntax in
-@var{pattern_buffers}'s @code{syntax} field. (@xref{GNU Regular
-Expression Compiling}, for how to set it.) The function returns
-@math{-1} if the compiled pattern does not match any part of
-@var{string} and @math{-2} if an internal error happens; otherwise, it
-returns how many (possibly zero) characters of @var{string} the pattern
-matched.
-
-An example: suppose @var{pattern_buffer} points to a pattern buffer
-containing the compiled pattern for @samp{a*}, and @var{string} points
-to @samp{aaaaab} (whereupon @var{size} should be 6). Then if @var{start}
-is 2, @code{re_match} returns 3, i.e., @samp{a*} would have matched the
-last three @samp{a}s in @var{string}. If @var{start} is 0,
-@code{re_match} returns 5, i.e., @samp{a*} would have matched all the
-@samp{a}s in @var{string}. If @var{start} is either 5 or 6, it returns
-zero.
-
-If @var{start} is not between zero and @var{size}, then
-@code{re_match} returns @math{-1}.
-
-
-@node GNU Searching, Matching/Searching with Split Data, GNU Matching, GNU Regex Functions
-@subsection GNU Searching
-
-@cindex searching with GNU functions
-
-@dfn{Searching} means trying to match starting at successive positions
-within a string. The function @code{re_search} does this.
-
-Before calling @code{re_search}, you must compile your regular
-expression. @xref{GNU Regular Expression Compiling}.
-
-Here is the function declaration:
-
-@findex re_search
-@example
-int
-re_search (struct re_pattern_buffer *@var{pattern_buffer},
- const char *@var{string}, const int @var{size},
- const int @var{start}, const int @var{range},
- struct re_registers *@var{regs})
-@end example
-
-@noindent
-@vindex start @r{argument to @code{re_search}}
-@vindex range @r{argument to @code{re_search}}
-whose arguments are the same as those to @code{re_match} (@pxref{GNU
-Matching}) except that the two arguments @var{start} and @var{range}
-replace @code{re_match}'s argument @var{start}.
-
-If @var{range} is positive, then @code{re_search} attempts a match
-starting first at index @var{start}, then at @math{@var{start} + 1} if
-that fails, and so on, up to @math{@var{start} + @var{range}}; if
-@var{range} is negative, then it attempts a match starting first at
-index @var{start}, then at @math{@var{start} -1} if that fails, and so
-on.
-
-If @var{start} is not between zero and @var{size}, then @code{re_search}
-returns @math{-1}. When @var{range} is positive, @code{re_search}
-adjusts @var{range} so that @math{@var{start} + @var{range} - 1} is
-between zero and @var{size}, if necessary; that way it won't search
-outside of @var{string}. Similarly, when @var{range} is negative,
-@code{re_search} adjusts @var{range} so that @math{@var{start} +
-@var{range} + 1} is between zero and @var{size}, if necessary.
-
-If the @code{fastmap} field of @var{pattern_buffer} is zero,
-@code{re_search} matches starting at consecutive positions; otherwise,
-it uses @code{fastmap} to make the search more efficient.
-@xref{Searching with Fastmaps}.
-
-If no match is found, @code{re_search} returns @math{-1}. If
-a match is found, it returns the index where the match began. If an
-internal error happens, it returns @math{-2}.
-
-
-@node Matching/Searching with Split Data, Searching with Fastmaps, GNU Searching, GNU Regex Functions
-@subsection Matching and Searching with Split Data
-
-Using the functions @code{re_match_2} and @code{re_search_2}, you can
-match or search in data that is divided into two strings.
-
-The function:
-
-@findex re_match_2
-@example
-int
-re_match_2 (struct re_pattern_buffer *@var{buffer},
- const char *@var{string1}, const int @var{size1},
- const char *@var{string2}, const int @var{size2},
- const int @var{start},
- struct re_registers *@var{regs},
- const int @var{stop})
-@end example
-
-@noindent
-is similar to @code{re_match} (@pxref{GNU Matching}) except that you
-pass @emph{two} data strings and sizes, and an index @var{stop} beyond
-which you don't want the matcher to try matching. As with
-@code{re_match}, if it succeeds, @code{re_match_2} returns how many
-characters of @var{string} it matched. Regard @var{string1} and
-@var{string2} as concatenated when you set the arguments @var{start} and
-@var{stop} and use the contents of @var{regs}; @code{re_match_2} never
-returns a value larger than @math{@var{size1} + @var{size2}}.
-
-The function:
-
-@findex re_search_2
-@example
-int
-re_search_2 (struct re_pattern_buffer *@var{buffer},
- const char *@var{string1}, const int @var{size1},
- const char *@var{string2}, const int @var{size2},
- const int @var{start}, const int @var{range},
- struct re_registers *@var{regs},
- const int @var{stop})
-@end example
-
-@noindent
-is similarly related to @code{re_search}.
-
-
-@node Searching with Fastmaps, GNU Translate Tables, Matching/Searching with Split Data, GNU Regex Functions
-@subsection Searching with Fastmaps
-
-@cindex fastmaps
-If you're searching through a long string, you should use a fastmap.
-Without one, the searcher tries to match at consecutive positions in the
-string. Generally, most of the characters in the string could not start
-a match. It takes much longer to try matching at a given position in the
-string than it does to check in a table whether or not the character at
-that position could start a match. A @dfn{fastmap} is such a table.
-
-More specifically, a fastmap is an array indexed by the characters in
-your character set. Under the @sc{ascii} encoding, therefore, a fastmap
-has 256 elements. If you want the searcher to use a fastmap with a
-given pattern buffer, you must allocate the array and assign the array's
-address to the pattern buffer's @code{fastmap} field. You either can
-compile the fastmap yourself or have @code{re_search} do it for you;
-when @code{fastmap} is nonzero, it automatically compiles a fastmap the
-first time you search using a particular compiled pattern.
-
-To compile a fastmap yourself, use:
-
-@findex re_compile_fastmap
-@example
-int
-re_compile_fastmap (struct re_pattern_buffer *@var{pattern_buffer})
-@end example
-
-@noindent
-@var{pattern_buffer} is the address of a pattern buffer. If the
-character @var{c} could start a match for the pattern,
-@code{re_compile_fastmap} makes
-@code{@var{pattern_buffer}->fastmap[@var{c}]} nonzero. It returns
-@math{0} if it can compile a fastmap and @math{-2} if there is an
-internal error. For example, if @samp{|} is the alternation operator
-and @var{pattern_buffer} holds the compiled pattern for @samp{a|b}, then
-@code{re_compile_fastmap} sets @code{fastmap['a']} and
-@code{fastmap['b']} (and no others).
-
-@code{re_search} uses a fastmap as it moves along in the string: it
-checks the string's characters until it finds one that's in the fastmap.
-Then it tries matching at that character. If the match fails, it
-repeats the process. So, by using a fastmap, @code{re_search} doesn't
-waste time trying to match at positions in the string that couldn't
-start a match.
-
-If you don't want @code{re_search} to use a fastmap,
-store zero in the @code{fastmap} field of the pattern buffer before
-calling @code{re_search}.
-
-Once you've initialized a pattern buffer's @code{fastmap} field, you
-need never do so again---even if you compile a new pattern in
-it---provided the way the field is set still reflects whether or not you
-want a fastmap. @code{re_search} will still either do nothing if
-@code{fastmap} is null or, if it isn't, compile a new fastmap for the
-new pattern.
-
-@node GNU Translate Tables, Using Registers, Searching with Fastmaps, GNU Regex Functions
-@subsection GNU Translate Tables
-
-If you set the @code{translate} field of a pattern buffer to a translate
-table, then the @sc{gnu} Regex functions to which you've passed that
-pattern buffer use it to apply a simple transformation
-to all the regular expression and string characters at which they look.
-
-A @dfn{translate table} is an array indexed by the characters in your
-character set. Under the @sc{ascii} encoding, therefore, a translate
-table has 256 elements. The array's elements are also characters in
-your character set. When the Regex functions see a character @var{c},
-they use @code{translate[@var{c}]} in its place, with one exception: the
-character after a @samp{\} is not translated. (This ensures that, the
-operators, e.g., @samp{\B} and @samp{\b}, are always distinguishable.)
-
-For example, a table that maps all lowercase letters to the
-corresponding uppercase ones would cause the matcher to ignore
-differences in case.@footnote{A table that maps all uppercase letters to
-the corresponding lowercase ones would work just as well for this
-purpose.} Such a table would map all characters except lowercase letters
-to themselves, and lowercase letters to the corresponding uppercase
-ones. Under the @sc{ascii} encoding, here's how you could initialize
-such a table (we'll call it @code{case_fold}):
-
-@example
-for (i = 0; i < 256; i++)
- case_fold[i] = i;
-for (i = 'a'; i <= 'z'; i++)
- case_fold[i] = i - ('a' - 'A');
-@end example
-
-You tell Regex to use a translate table on a given pattern buffer by
-assigning that table's address to the @code{translate} field of that
-buffer. If you don't want Regex to do any translation, put zero into
-this field. You'll get weird results if you change the table's contents
-anytime between compiling the pattern buffer, compiling its fastmap, and
-matching or searching with the pattern buffer.
-
-@node Using Registers, Freeing GNU Pattern Buffers, GNU Translate Tables, GNU Regex Functions
-@subsection Using Registers
-
-A group in a regular expression can match a (posssibly empty) substring
-of the string that regular expression as a whole matched. The matcher
-remembers the beginning and end of the substring matched by
-each group.
-
-To find out what they matched, pass a nonzero @var{regs} argument to a
-@sc{gnu} matching or searching function (@pxref{GNU Matching} and
-@ref{GNU Searching}), i.e., the address of a structure of this type, as
-defined in @file{regex.h}:
-
-@c We don't bother to include this directly from regex.h,
-@c since it changes so rarely.
-@example
-@tindex re_registers
-@vindex num_regs @r{in @code{struct re_registers}}
-@vindex start @r{in @code{struct re_registers}}
-@vindex end @r{in @code{struct re_registers}}
-struct re_registers
-@{
- unsigned num_regs;
- regoff_t *start;
- regoff_t *end;
-@};
-@end example
-
-Except for (possibly) the @var{num_regs}'th element (see below), the
-@var{i}th element of the @code{start} and @code{end} arrays records
-information about the @var{i}th group in the pattern. (They're declared
-as C pointers, but this is only because not all C compilers accept
-zero-length arrays; conceptually, it is simplest to think of them as
-arrays.)
-
-The @code{start} and @code{end} arrays are allocated in various ways,
-depending on the value of the @code{regs_allocated}
-@vindex regs_allocated
-field in the pattern buffer passed to the matcher.
-
-The simplest and perhaps most useful is to let the matcher (re)allocate
-enough space to record information for all the groups in the regular
-expression. If @code{regs_allocated} is @code{REGS_UNALLOCATED},
-@vindex REGS_UNALLOCATED
-the matcher allocates @math{1 + @var{re_nsub}} (another field in the
-pattern buffer; @pxref{GNU Pattern Buffers}). The extra element is set
-to @math{-1}, and sets @code{regs_allocated} to @code{REGS_REALLOCATE}.
-@vindex REGS_REALLOCATE
-Then on subsequent calls with the same pattern buffer and @var{regs}
-arguments, the matcher reallocates more space if necessary.
-
-It would perhaps be more logical to make the @code{regs_allocated} field
-part of the @code{re_registers} structure, instead of part of the
-pattern buffer. But in that case the caller would be forced to
-initialize the structure before passing it. Much existing code doesn't
-do this initialization, and it's arguably better to avoid it anyway.
-
-@code{re_compile_pattern} sets @code{regs_allocated} to
-@code{REGS_UNALLOCATED},
-so if you use the GNU regular expression
-functions, you get this behavior by default.
-
-xx document re_set_registers
-
-@sc{posix}, on the other hand, requires a different interface: the
-caller is supposed to pass in a fixed-length array which the matcher
-fills. Therefore, if @code{regs_allocated} is @code{REGS_FIXED}
-@vindex REGS_FIXED
-the matcher simply fills that array.
-
-The following examples illustrate the information recorded in the
-@code{re_registers} structure. (In all of them, @samp{(} represents the
-open-group and @samp{)} the close-group operator. The first character
-in the string @var{string} is at index 0.)
-
-@c xx i'm not sure this is all true anymore.
-
-@itemize @bullet
-
-@item
-If the regular expression has an @w{@var{i}-th}
-group not contained within another group that matches a
-substring of @var{string}, then the function sets
-@code{@w{@var{regs}->}start[@var{i}]} to the index in @var{string} where
-the substring matched by the @w{@var{i}-th} group begins, and
-@code{@w{@var{regs}->}end[@var{i}]} to the index just beyond that
-substring's end. The function sets @code{@w{@var{regs}->}start[0]} and
-@code{@w{@var{regs}->}end[0]} to analogous information about the entire
-pattern.
-
-For example, when you match @samp{((a)(b))} against @samp{ab}, you get:
-
-@itemize @bullet
-@item
-0 in @code{@w{@var{regs}->}start[0]} and 2 in @code{@w{@var{regs}->}end[0]}
-
-@item
-0 in @code{@w{@var{regs}->}start[1]} and 2 in @code{@w{@var{regs}->}end[1]}
-
-@item
-0 in @code{@w{@var{regs}->}start[2]} and 1 in @code{@w{@var{regs}->}end[2]}
-
-@item
-1 in @code{@w{@var{regs}->}start[3]} and 2 in @code{@w{@var{regs}->}end[3]}
-@end itemize
-
-@item
-If a group matches more than once (as it might if followed by,
-e.g., a repetition operator), then the function reports the information
-about what the group @emph{last} matched.
-
-For example, when you match the pattern @samp{(a)*} against the string
-@samp{aa}, you get:
-
-@itemize @bullet
-@item
-0 in @code{@w{@var{regs}->}start[0]} and 2 in @code{@w{@var{regs}->}end[0]}
-
-@item
-1 in @code{@w{@var{regs}->}start[1]} and 2 in @code{@w{@var{regs}->}end[1]}
-@end itemize
-
-@item
-If the @w{@var{i}-th} group does not participate in a
-successful match, e.g., it is an alternative not taken or a
-repetition operator allows zero repetitions of it, then the function
-sets @code{@w{@var{regs}->}start[@var{i}]} and
-@code{@w{@var{regs}->}end[@var{i}]} to @math{-1}.
-
-For example, when you match the pattern @samp{(a)*b} against
-the string @samp{b}, you get:
-
-@itemize @bullet
-@item
-0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]}
-
-@item
-@math{-1} in @code{@w{@var{regs}->}start[1]} and @math{-1} in @code{@w{@var{regs}->}end[1]}
-@end itemize
-
-@item
-If the @w{@var{i}-th} group matches a zero-length string, then the
-function sets @code{@w{@var{regs}->}start[@var{i}]} and
-@code{@w{@var{regs}->}end[@var{i}]} to the index just beyond that
-zero-length string.
-
-For example, when you match the pattern @samp{(a*)b} against the string
-@samp{b}, you get:
-
-@itemize @bullet
-@item
-0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]}
-
-@item
-0 in @code{@w{@var{regs}->}start[1]} and 0 in @code{@w{@var{regs}->}end[1]}
-@end itemize
-
-@ignore
-The function sets @code{@w{@var{regs}->}start[0]} and
-@code{@w{@var{regs}->}end[0]} to analogous information about the entire
-pattern.
-
-For example, when you match the pattern @samp{(a*)} against the empty
-string, you get:
-
-@itemize @bullet
-@item
-0 in @code{@w{@var{regs}->}start[0]} and 0 in @code{@w{@var{regs}->}end[0]}
-
-@item
-0 in @code{@w{@var{regs}->}start[1]} and 0 in @code{@w{@var{regs}->}end[1]}
-@end itemize
-@end ignore
-
-@item
-If an @w{@var{i}-th} group contains a @w{@var{j}-th} group
-in turn not contained within any other group within group @var{i} and
-the function reports a match of the @w{@var{i}-th} group, then it
-records in @code{@w{@var{regs}->}start[@var{j}]} and
-@code{@w{@var{regs}->}end[@var{j}]} the last match (if it matched) of
-the @w{@var{j}-th} group.
-
-For example, when you match the pattern @samp{((a*)b)*} against the
-string @samp{abb}, @w{group 2} last matches the empty string, so you
-get what it previously matched:
-
-@itemize @bullet
-@item
-0 in @code{@w{@var{regs}->}start[0]} and 3 in @code{@w{@var{regs}->}end[0]}
-
-@item
-2 in @code{@w{@var{regs}->}start[1]} and 3 in @code{@w{@var{regs}->}end[1]}
-
-@item
-2 in @code{@w{@var{regs}->}start[2]} and 2 in @code{@w{@var{regs}->}end[2]}
-@end itemize
-
-When you match the pattern @samp{((a)*b)*} against the string
-@samp{abb}, @w{group 2} doesn't participate in the last match, so you
-get:
-
-@itemize @bullet
-@item
-0 in @code{@w{@var{regs}->}start[0]} and 3 in @code{@w{@var{regs}->}end[0]}
-
-@item
-2 in @code{@w{@var{regs}->}start[1]} and 3 in @code{@w{@var{regs}->}end[1]}
-
-@item
-0 in @code{@w{@var{regs}->}start[2]} and 1 in @code{@w{@var{regs}->}end[2]}
-@end itemize
-
-@item
-If an @w{@var{i}-th} group contains a @w{@var{j}-th} group
-in turn not contained within any other group within group @var{i}
-and the function sets
-@code{@w{@var{regs}->}start[@var{i}]} and
-@code{@w{@var{regs}->}end[@var{i}]} to @math{-1}, then it also sets
-@code{@w{@var{regs}->}start[@var{j}]} and
-@code{@w{@var{regs}->}end[@var{j}]} to @math{-1}.
-
-For example, when you match the pattern @samp{((a)*b)*c} against the
-string @samp{c}, you get:
-
-@itemize @bullet
-@item
-0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]}
-
-@item
-@math{-1} in @code{@w{@var{regs}->}start[1]} and @math{-1} in @code{@w{@var{regs}->}end[1]}
-
-@item
-@math{-1} in @code{@w{@var{regs}->}start[2]} and @math{-1} in @code{@w{@var{regs}->}end[2]}
-@end itemize
-
-@end itemize
-
-@node Freeing GNU Pattern Buffers, , Using Registers, GNU Regex Functions
-@subsection Freeing GNU Pattern Buffers
-
-To free any allocated fields of a pattern buffer, you can use the
-@sc{posix} function described in @ref{Freeing POSIX Pattern Buffers},
-since the type @code{regex_t}---the type for @sc{posix} pattern
-buffers---is equivalent to the type @code{re_pattern_buffer}. After
-freeing a pattern buffer, you need to again compile a regular expression
-in it (@pxref{GNU Regular Expression Compiling}) before passing it to
-a matching or searching function.
-
-
-@node POSIX Regex Functions, BSD Regex Functions, GNU Regex Functions, Programming with Regex
-@section POSIX Regex Functions
-
-If you're writing code that has to be @sc{posix} compatible, you'll need
-to use these functions. Their interfaces are as specified by @sc{posix},
-draft 1003.2/D11.2.
-
-@menu
-* POSIX Pattern Buffers:: The regex_t type.
-* POSIX Regular Expression Compiling:: regcomp ()
-* POSIX Matching:: regexec ()
-* Reporting Errors:: regerror ()
-* Using Byte Offsets:: The regmatch_t type.
-* Freeing POSIX Pattern Buffers:: regfree ()
-@end menu
-
-
-@node POSIX Pattern Buffers, POSIX Regular Expression Compiling, , POSIX Regex Functions
-@subsection POSIX Pattern Buffers
-
-To compile or match a given regular expression the @sc{posix} way, you
-must supply a pattern buffer exactly the way you do for @sc{gnu}
-(@pxref{GNU Pattern Buffers}). @sc{posix} pattern buffers have type
-@code{regex_t}, which is equivalent to the @sc{gnu} pattern buffer
-type @code{re_pattern_buffer}.
-
-
-@node POSIX Regular Expression Compiling, POSIX Matching, POSIX Pattern Buffers, POSIX Regex Functions
-@subsection POSIX Regular Expression Compiling
-
-With @sc{posix}, you can only search for a given regular expression; you
-can't match it. To do this, you must first compile it in a
-pattern buffer, using @code{regcomp}.
-
-@ignore
-Before calling @code{regcomp}, you must initialize this pattern buffer
-as you do for @sc{gnu} (@pxref{GNU Regular Expression Compiling}). See
-below, however, for how to choose a syntax with which to compile.
-@end ignore
-
-To compile a pattern buffer, use:
-
-@findex regcomp
-@example
-int
-regcomp (regex_t *@var{preg}, const char *@var{regex}, int @var{cflags})
-@end example
-
-@noindent
-@var{preg} is the initialized pattern buffer's address, @var{regex} is
-the regular expression's address, and @var{cflags} is the compilation
-flags, which Regex considers as a collection of bits. Here are the
-valid bits, as defined in @file{regex.h}:
-
-@table @code
-
-@item REG_EXTENDED
-@vindex REG_EXTENDED
-says to use @sc{posix} Extended Regular Expression syntax; if this isn't
-set, then says to use @sc{posix} Basic Regular Expression syntax.
-@code{regcomp} sets @var{preg}'s @code{syntax} field accordingly.
-
-@item REG_ICASE
-@vindex REG_ICASE
-@cindex ignoring case
-says to ignore case; @code{regcomp} sets @var{preg}'s @code{translate}
-field to a translate table which ignores case, replacing anything you've
-put there before.
-
-@item REG_NOSUB
-@vindex REG_NOSUB
-says to set @var{preg}'s @code{no_sub} field; @pxref{POSIX Matching},
-for what this means.
-
-@item REG_NEWLINE
-@vindex REG_NEWLINE
-says that a:
-
-@itemize @bullet
-
-@item
-match-any-character operator (@pxref{Match-any-character
-Operator}) doesn't match a newline.
-
-@item
-nonmatching list not containing a newline (@pxref{List
-Operators}) matches a newline.
-
-@item
-match-beginning-of-line operator (@pxref{Match-beginning-of-line
-Operator}) matches the empty string immediately after a newline,
-regardless of how @code{REG_NOTBOL} is set (@pxref{POSIX Matching}, for
-an explanation of @code{REG_NOTBOL}).
-
-@item
-match-end-of-line operator (@pxref{Match-beginning-of-line
-Operator}) matches the empty string immediately before a newline,
-regardless of how @code{REG_NOTEOL} is set (@pxref{POSIX Matching},
-for an explanation of @code{REG_NOTEOL}).
-
-@end itemize
-
-@end table
-
-If @code{regcomp} successfully compiles the regular expression, it
-returns zero and sets @code{*@var{pattern_buffer}} to the compiled
-pattern. Except for @code{syntax} (which it sets as explained above), it
-also sets the same fields the same way as does the @sc{gnu} compiling
-function (@pxref{GNU Regular Expression Compiling}).
-
-If @code{regcomp} can't compile the regular expression, it returns one
-of the error codes listed here. (Except when noted differently, the
-syntax of in all examples below is basic regular expression syntax.)
-
-@table @code
-
-@comment repetitions
-@item REG_BADRPT
-For example, the consecutive repetition operators @samp{**} in
-@samp{a**} are invalid. As another example, if the syntax is extended
-regular expression syntax, then the repetition operator @samp{*} with
-nothing on which to operate in @samp{*} is invalid.
-
-@item REG_BADBR
-For example, the @var{count} @samp{-1} in @samp{a\@{-1} is invalid.
-
-@item REG_EBRACE
-For example, @samp{a\@{1} is missing a close-interval operator.
-
-@comment lists
-@item REG_EBRACK
-For example, @samp{[a} is missing a close-list operator.
-
-@item REG_ERANGE
-For example, the range ending point @samp{z} that collates lower than
-does its starting point @samp{a} in @samp{[z-a]} is invalid. Also, the
-range with the character class @samp{[:alpha:]} as its starting point in
-@samp{[[:alpha:]-|]}.
-
-@item REG_ECTYPE
-For example, the character class name @samp{foo} in @samp{[[:foo:]} is
-invalid.
-
-@comment groups
-@item REG_EPAREN
-For example, @samp{a\)} is missing an open-group operator and @samp{\(a}
-is missing a close-group operator.
-
-@item REG_ESUBREG
-For example, the back reference @samp{\2} that refers to a nonexistent
-subexpression in @samp{\(a\)\2} is invalid.
-
-@comment unfinished business
-
-@item REG_EEND
-Returned when a regular expression causes no other more specific error.
-
-@item REG_EESCAPE
-For example, the trailing backslash @samp{\} in @samp{a\} is invalid, as is the
-one in @samp{\}.
-
-@comment kitchen sink
-@item REG_BADPAT
-For example, in the extended regular expression syntax, the empty group
-@samp{()} in @samp{a()b} is invalid.
-
-@comment internal
-@item REG_ESIZE
-Returned when a regular expression needs a pattern buffer larger than
-65536 bytes.
-
-@item REG_ESPACE
-Returned when a regular expression makes Regex to run out of memory.
-
-@end table
-
-
-@node POSIX Matching, Reporting Errors, POSIX Regular Expression Compiling, POSIX Regex Functions
-@subsection POSIX Matching
-
-Matching the @sc{posix} way means trying to match a null-terminated
-string starting at its first character. Once you've compiled a pattern
-into a pattern buffer (@pxref{POSIX Regular Expression Compiling}), you
-can ask the matcher to match that pattern against a string using:
-
-@findex regexec
-@example
-int
-regexec (const regex_t *@var{preg}, const char *@var{string},
- size_t @var{nmatch}, regmatch_t @var{pmatch}[], int @var{eflags})
-@end example
-
-@noindent
-@var{preg} is the address of a pattern buffer for a compiled pattern.
-@var{string} is the string you want to match.
-
-@xref{Using Byte Offsets}, for an explanation of @var{pmatch}. If you
-pass zero for @var{nmatch} or you compiled @var{preg} with the
-compilation flag @code{REG_NOSUB} set, then @code{regexec} will ignore
-@var{pmatch}; otherwise, you must allocate it to have at least
-@var{nmatch} elements. @code{regexec} will record @var{nmatch} byte
-offsets in @var{pmatch}, and set to @math{-1} any unused elements up to
-@math{@var{pmatch}@code{[@var{nmatch}]} - 1}.
-
-@var{eflags} specifies @dfn{execution flags}---namely, the two bits
-@code{REG_NOTBOL} and @code{REG_NOTEOL} (defined in @file{regex.h}). If
-you set @code{REG_NOTBOL}, then the match-beginning-of-line operator
-(@pxref{Match-beginning-of-line Operator}) always fails to match.
-This lets you match against pieces of a line, as you would need to if,
-say, searching for repeated instances of a given pattern in a line; it
-would work correctly for patterns both with and without
-match-beginning-of-line operators. @code{REG_NOTEOL} works analogously
-for the match-end-of-line operator (@pxref{Match-end-of-line
-Operator}); it exists for symmetry.
-
-@code{regexec} tries to find a match for @var{preg} in @var{string}
-according to the syntax in @var{preg}'s @code{syntax} field.
-(@xref{POSIX Regular Expression Compiling}, for how to set it.) The
-function returns zero if the compiled pattern matches @var{string} and
-@code{REG_NOMATCH} (defined in @file{regex.h}) if it doesn't.
-
-@node Reporting Errors, Using Byte Offsets, POSIX Matching, POSIX Regex Functions
-@subsection Reporting Errors
-
-If either @code{regcomp} or @code{regexec} fail, they return a nonzero
-error code, the possibilities for which are defined in @file{regex.h}.
-@xref{POSIX Regular Expression Compiling}, and @ref{POSIX Matching}, for
-what these codes mean. To get an error string corresponding to these
-codes, you can use:
-
-@findex regerror
-@example
-size_t
-regerror (int @var{errcode},
- const regex_t *@var{preg},
- char *@var{errbuf},
- size_t @var{errbuf_size})
-@end example
-
-@noindent
-@var{errcode} is an error code, @var{preg} is the address of the pattern
-buffer which provoked the error, @var{errbuf} is the error buffer, and
-@var{errbuf_size} is @var{errbuf}'s size.
-
-@code{regerror} returns the size in bytes of the error string
-corresponding to @var{errcode} (including its terminating null). If
-@var{errbuf} and @var{errbuf_size} are nonzero, it also returns in
-@var{errbuf} the first @math{@var{errbuf_size} - 1} characters of the
-error string, followed by a null.
-@var{errbuf_size} must be a nonnegative number less than or equal to the
-size in bytes of @var{errbuf}.
-
-You can call @code{regerror} with a null @var{errbuf} and a zero
-@var{errbuf_size} to determine how large @var{errbuf} need be to
-accommodate @code{regerror}'s error string.
-
-@node Using Byte Offsets, Freeing POSIX Pattern Buffers, Reporting Errors, POSIX Regex Functions
-@subsection Using Byte Offsets
-
-In @sc{posix}, variables of type @code{regmatch_t} hold analogous
-information, but are not identical to, @sc{gnu}'s registers (@pxref{Using
-Registers}). To get information about registers in @sc{posix}, pass to
-@code{regexec} a nonzero @var{pmatch} of type @code{regmatch_t}, i.e.,
-the address of a structure of this type, defined in
-@file{regex.h}:
-
-@tindex regmatch_t
-@example
-typedef struct
-@{
- regoff_t rm_so;
- regoff_t rm_eo;
-@} regmatch_t;
-@end example
-
-When reading in @ref{Using Registers}, about how the matching function
-stores the information into the registers, substitute @var{pmatch} for
-@var{regs}, @code{@w{@var{pmatch}[@var{i}]->}rm_so} for
-@code{@w{@var{regs}->}start[@var{i}]} and
-@code{@w{@var{pmatch}[@var{i}]->}rm_eo} for
-@code{@w{@var{regs}->}end[@var{i}]}.
-
-@node Freeing POSIX Pattern Buffers, , Using Byte Offsets, POSIX Regex Functions
-@subsection Freeing POSIX Pattern Buffers
-
-To free any allocated fields of a pattern buffer, use:
-
-@findex regfree
-@example
-void
-regfree (regex_t *@var{preg})
-@end example
-
-@noindent
-@var{preg} is the pattern buffer whose allocated fields you want freed.
-@code{regfree} also sets @var{preg}'s @code{allocated} and @code{used}
-fields to zero. After freeing a pattern buffer, you need to again
-compile a regular expression in it (@pxref{POSIX Regular Expression
-Compiling}) before passing it to the matching function (@pxref{POSIX
-Matching}).
-
-
-@node BSD Regex Functions, , POSIX Regex Functions, Programming with Regex
-@section BSD Regex Functions
-
-If you're writing code that has to be Berkeley @sc{unix} compatible,
-you'll need to use these functions whose interfaces are the same as those
-in Berkeley @sc{unix}.
-
-@menu
-* BSD Regular Expression Compiling:: re_comp ()
-* BSD Searching:: re_exec ()
-@end menu
-
-@node BSD Regular Expression Compiling, BSD Searching, , BSD Regex Functions
-@subsection BSD Regular Expression Compiling
-
-With Berkeley @sc{unix}, you can only search for a given regular
-expression; you can't match one. To search for it, you must first
-compile it. Before you compile it, you must indicate the regular
-expression syntax you want it compiled according to by setting the
-variable @code{re_syntax_options} (declared in @file{regex.h} to some
-syntax (@pxref{Regular Expression Syntax}).
-
-To compile a regular expression use:
-
-@findex re_comp
-@example
-char *
-re_comp (char *@var{regex})
-@end example
-
-@noindent
-@var{regex} is the address of a null-terminated regular expression.
-@code{re_comp} uses an internal pattern buffer, so you can use only the
-most recently compiled pattern buffer. This means that if you want to
-use a given regular expression that you've already compiled---but it
-isn't the latest one you've compiled---you'll have to recompile it. If
-you call @code{re_comp} with the null string (@emph{not} the empty
-string) as the argument, it doesn't change the contents of the pattern
-buffer.
-
-If @code{re_comp} successfully compiles the regular expression, it
-returns zero. If it can't compile the regular expression, it returns
-an error string. @code{re_comp}'s error messages are identical to those
-of @code{re_compile_pattern} (@pxref{GNU Regular Expression
-Compiling}).
-
-@node BSD Searching, , BSD Regular Expression Compiling, BSD Regex Functions
-@subsection BSD Searching
-
-Searching the Berkeley @sc{unix} way means searching in a string
-starting at its first character and trying successive positions within
-it to find a match. Once you've compiled a pattern using @code{re_comp}
-(@pxref{BSD Regular Expression Compiling}), you can ask Regex
-to search for that pattern in a string using:
-
-@findex re_exec
-@example
-int
-re_exec (char *@var{string})
-@end example
-
-@noindent
-@var{string} is the address of the null-terminated string in which you
-want to search.
-
-@code{re_exec} returns either 1 for success or 0 for failure. It
-automatically uses a @sc{gnu} fastmap (@pxref{Searching with Fastmaps}).
-
-
-@node Copying, Index, Programming with Regex, Top
-@appendix GNU GENERAL PUBLIC LICENSE
-@center Version 2, June 1991
-
-@display
-Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
-675 Mass Ave, Cambridge, MA 02139, USA
-
-Everyone is permitted to copy and distribute verbatim copies
-of this license document, but changing it is not allowed.
-@end display
-
-@unnumberedsec Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software---to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
-@iftex
-@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-@end iftex
-@ifinfo
-@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-@end ifinfo
-
-@enumerate
-@item
-This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The ``Program'', below,
-refers to any such program or work, and a ``work based on the Program''
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term ``modification''.) Each licensee is addressed as ``you''.
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-@item
-You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-@item
-You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-@enumerate a
-@item
-You must cause the modified files to carry prominent notices
-stating that you changed the files and the date of any change.
-
-@item
-You must cause any work that you distribute or publish, that in
-whole or in part contains or is derived from the Program or any
-part thereof, to be licensed as a whole at no charge to all third
-parties under the terms of this License.
-
-@item
-If the modified program normally reads commands interactively
-when run, you must cause it, when started running for such
-interactive use in the most ordinary way, to print or display an
-announcement including an appropriate copyright notice and a
-notice that there is no warranty (or else, saying that you provide
-a warranty) and that users may redistribute the program under
-these conditions, and telling the user how to view a copy of this
-License. (Exception: if the Program itself is interactive but
-does not normally print such an announcement, your work based on
-the Program is not required to print an announcement.)
-@end enumerate
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-@item
-You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-@enumerate a
-@item
-Accompany it with the complete corresponding machine-readable
-source code, which must be distributed under the terms of Sections
-1 and 2 above on a medium customarily used for software interchange; or,
-
-@item
-Accompany it with a written offer, valid for at least three
-years, to give any third party, for a charge no more than your
-cost of physically performing source distribution, a complete
-machine-readable copy of the corresponding source code, to be
-distributed under the terms of Sections 1 and 2 above on a medium
-customarily used for software interchange; or,
-
-@item
-Accompany it with the information you received as to the offer
-to distribute corresponding source code. (This alternative is
-allowed only for noncommercial distribution and only if you
-received the program in object code or executable form with such
-an offer, in accord with Subsection b above.)
-@end enumerate
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-@item
-You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-@item
-You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-@item
-Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-@item
-If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-@item
-If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-@item
-The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and ``any
-later version'', you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-@item
-If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-@iftex
-@heading NO WARRANTY
-@end iftex
-@ifinfo
-@center NO WARRANTY
-@end ifinfo
-
-@item
-BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-@item
-IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-@end enumerate
-
-@iftex
-@heading END OF TERMS AND CONDITIONS
-@end iftex
-@ifinfo
-@center END OF TERMS AND CONDITIONS
-@end ifinfo
-
-@page
-@unnumberedsec Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the ``copyright'' line and a pointer to where the full notice is found.
-
-@smallexample
-@var{one line to give the program's name and a brief idea of what it does.}
-Copyright (C) 19@var{yy} @var{name of author}
-
-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 of the License, 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.
-@end smallexample
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-@smallexample
-Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
-Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-This is free software, and you are welcome to redistribute it
-under certain conditions; type `show c' for details.
-@end smallexample
-
-The hypothetical commands @samp{show w} and @samp{show c} should show
-the appropriate parts of the General Public License. Of course, the
-commands you use may be called something other than @samp{show w} and
-@samp{show c}; they could even be mouse-clicks or menu items---whatever
-suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a ``copyright disclaimer'' for the program, if
-necessary. Here is a sample; alter the names:
-
-@example
-Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-`Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-@var{signature of Ty Coon}, 1 April 1989
-Ty Coon, President of Vice
-@end example
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
-
-
-@node Index, , Copying, Top
-@unnumbered Index
-
-@printindex cp
-
-@contents
-
-@bye
diff --git a/gnu/lib/libregex/regex.c b/gnu/lib/libregex/regex.c
deleted file mode 100644
index 335e5d3..0000000
--- a/gnu/lib/libregex/regex.c
+++ /dev/null
@@ -1,5101 +0,0 @@
-/* Extended regular expression matching and search library,
- version 0.12.
- (Implements POSIX draft P10003.2/D11.2, except for
- internationalization features.)
-
- Copyright (C) 1993 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. */
-
-/* AIX requires this to be the first thing in the file. */
-#if defined (_AIX) && !defined (REGEX_MALLOC)
- #pragma alloca
-#endif
-
-#define _GNU_SOURCE
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#if defined(STDC_HEADERS) && !defined(emacs)
-#include <stddef.h>
-#else
-/* We need this for `regex.h', and perhaps for the Emacs include files. */
-#include <sys/types.h>
-#endif
-
-/* The `emacs' switch turns on certain matching commands
- that make sense only in Emacs. */
-#ifdef emacs
-
-#include "lisp.h"
-#include "buffer.h"
-#include "syntax.h"
-
-/* Emacs uses `NULL' as a predicate. */
-#undef NULL
-
-#else /* not emacs */
-
-/* We used to test for `BSTRING' here, but only GCC and Emacs define
- `BSTRING', as far as I know, and neither of them use this code. */
-#if HAVE_STRING_H || STDC_HEADERS
-#include <string.h>
-#ifndef bcmp
-#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
-#endif
-#ifndef bcopy
-#define bcopy(s, d, n) memcpy ((d), (s), (n))
-#endif
-#ifndef bzero
-#define bzero(s, n) memset ((s), 0, (n))
-#endif
-#else
-#include <strings.h>
-#endif
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-char *malloc ();
-char *realloc ();
-#endif
-
-
-/* Define the syntax stuff for \<, \>, etc. */
-
-/* This must be nonzero for the wordchar and notwordchar pattern
- commands in re_match_2. */
-#ifndef Sword
-#define Sword 1
-#endif
-
-#ifdef SYNTAX_TABLE
-
-extern char *re_syntax_table;
-
-#else /* not SYNTAX_TABLE */
-
-/* How many characters in the character set. */
-#define CHAR_SET_SIZE 256
-
-static char re_syntax_table[CHAR_SET_SIZE];
-
-static void
-init_syntax_once ()
-{
- register int c;
- static int done = 0;
-
- if (done)
- return;
-
- bzero (re_syntax_table, sizeof re_syntax_table);
-
- for (c = 'a'; c <= 'z'; c++)
- re_syntax_table[c] = Sword;
-
- for (c = 'A'; c <= 'Z'; c++)
- re_syntax_table[c] = Sword;
-
- for (c = '0'; c <= '9'; c++)
- re_syntax_table[c] = Sword;
-
- re_syntax_table['_'] = Sword;
-
- done = 1;
-}
-
-#endif /* not SYNTAX_TABLE */
-
-#define SYNTAX(c) re_syntax_table[c]
-
-#endif /* not emacs */
-
-/* Get the interface, including the syntax bits. */
-#include "regex.h"
-
-/* isalpha etc. are used for the character classes. */
-#include <ctype.h>
-
-/* Jim Meyering writes:
-
- "... Some ctype macros are valid only for character codes that
- isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
- using /bin/cc or gcc but without giving an ansi option). So, all
- ctype uses should be through macros like ISPRINT... If
- STDC_HEADERS is defined, then autoconf has verified that the ctype
- macros don't need to be guarded with references to isascii. ...
- Defining isascii to 1 should let any compiler worth its salt
- eliminate the && through constant folding." */
-#if ! defined (isascii) || defined (STDC_HEADERS)
-#undef isascii
-#define isascii(c) 1
-#endif
-
-#ifdef isblank
-#define ISBLANK(c) (isascii (c) && isblank (c))
-#else
-#define ISBLANK(c) ((c) == ' ' || (c) == '\t')
-#endif
-#ifdef isgraph
-#define ISGRAPH(c) (isascii (c) && isgraph (c))
-#else
-#define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c))
-#endif
-
-#define ISPRINT(c) (isascii (c) && isprint (c))
-#define ISDIGIT(c) (isascii (c) && isdigit (c))
-#define ISALNUM(c) (isascii (c) && isalnum (c))
-#define ISALPHA(c) (isascii (c) && isalpha (c))
-#define ISCNTRL(c) (isascii (c) && iscntrl (c))
-#define ISLOWER(c) (isascii (c) && islower (c))
-#define ISPUNCT(c) (isascii (c) && ispunct (c))
-#define ISSPACE(c) (isascii (c) && isspace (c))
-#define ISUPPER(c) (isascii (c) && isupper (c))
-#define ISXDIGIT(c) (isascii (c) && isxdigit (c))
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/* We remove any previous definition of `SIGN_EXTEND_CHAR',
- since ours (we hope) works properly with all combinations of
- machines, compilers, `char' and `unsigned char' argument types.
- (Per Bothner suggested the basic approach.) */
-#undef SIGN_EXTEND_CHAR
-#if __STDC__
-#define SIGN_EXTEND_CHAR(c) ((signed char) (c))
-#else /* not __STDC__ */
-/* As in Harbison and Steele. */
-#define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
-#endif
-
-/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we
- use `alloca' instead of `malloc'. This is because using malloc in
- re_search* or re_match* could cause memory leaks when C-g is used in
- Emacs; also, malloc is slower and causes storage fragmentation. On
- the other hand, malloc is more portable, and easier to debug.
-
- Because we sometimes use alloca, some routines have to be macros,
- not functions -- `alloca'-allocated space disappears at the end of the
- function it is called in. */
-
-#ifdef REGEX_MALLOC
-
-#define REGEX_ALLOCATE malloc
-#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize)
-
-#else /* not REGEX_MALLOC */
-
-/* Emacs already defines alloca, sometimes. */
-#ifndef alloca
-
-/* Make alloca work the best possible way. */
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not __GNUC__ */
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#else /* not __GNUC__ or HAVE_ALLOCA_H */
-#ifndef _AIX /* Already did AIX, up at the top. */
-char *alloca ();
-#endif /* not _AIX */
-#endif /* not HAVE_ALLOCA_H */
-#endif /* not __GNUC__ */
-
-#endif /* not alloca */
-
-#define REGEX_ALLOCATE alloca
-
-/* Assumes a `char *destination' variable. */
-#define REGEX_REALLOCATE(source, osize, nsize) \
- (destination = (char *) alloca (nsize), \
- bcopy (source, destination, osize), \
- destination)
-
-#endif /* not REGEX_MALLOC */
-
-
-/* True if `size1' is non-NULL and PTR is pointing anywhere inside
- `string1' or just past its end. This works if PTR is NULL, which is
- a good thing. */
-#define FIRST_STRING_P(ptr) \
- (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
-
-/* (Re)Allocate N items of type T using malloc, or fail. */
-#define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t)))
-#define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t)))
-#define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))
-
-#define BYTEWIDTH 8 /* In bits. */
-
-#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
-
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
-typedef char boolean;
-#define false 0
-#define true 1
-
-/* These are the command codes that appear in compiled regular
- expressions. Some opcodes are followed by argument bytes. A
- command code can specify any interpretation whatsoever for its
- arguments. Zero bytes may appear in the compiled regular expression.
-
- The value of `exactn' is needed in search.c (search_buffer) in Emacs.
- So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of
- `exactn' we use here must also be 1. */
-
-typedef enum
-{
- no_op = 0,
-
- /* Followed by one byte giving n, then by n literal bytes. */
- exactn = 1,
-
- /* Matches any (more or less) character. */
- anychar,
-
- /* Matches any one char belonging to specified set. First
- following byte is number of bitmap bytes. Then come bytes
- for a bitmap saying which chars are in. Bits in each byte
- are ordered low-bit-first. A character is in the set if its
- bit is 1. A character too large to have a bit in the map is
- automatically not in the set. */
- charset,
-
- /* Same parameters as charset, but match any character that is
- not one of those specified. */
- charset_not,
-
- /* Start remembering the text that is matched, for storing in a
- register. Followed by one byte with the register number, in
- the range 0 to one less than the pattern buffer's re_nsub
- field. Then followed by one byte with the number of groups
- inner to this one. (This last has to be part of the
- start_memory only because we need it in the on_failure_jump
- of re_match_2.) */
- start_memory,
-
- /* Stop remembering the text that is matched and store it in a
- memory register. Followed by one byte with the register
- number, in the range 0 to one less than `re_nsub' in the
- pattern buffer, and one byte with the number of inner groups,
- just like `start_memory'. (We need the number of inner
- groups here because we don't have any easy way of finding the
- corresponding start_memory when we're at a stop_memory.) */
- stop_memory,
-
- /* Match a duplicate of something remembered. Followed by one
- byte containing the register number. */
- duplicate,
-
- /* Fail unless at beginning of line. */
- begline,
-
- /* Fail unless at end of line. */
- endline,
-
- /* Succeeds if at beginning of buffer (if emacs) or at beginning
- of string to be matched (if not). */
- begbuf,
-
- /* Analogously, for end of buffer/string. */
- endbuf,
-
- /* Followed by two byte relative address to which to jump. */
- jump,
-
- /* Same as jump, but marks the end of an alternative. */
- jump_past_alt,
-
- /* Followed by two-byte relative address of place to resume at
- in case of failure. */
- on_failure_jump,
-
- /* Like on_failure_jump, but pushes a placeholder instead of the
- current string position when executed. */
- on_failure_keep_string_jump,
-
- /* Throw away latest failure point and then jump to following
- two-byte relative address. */
- pop_failure_jump,
-
- /* Change to pop_failure_jump if know won't have to backtrack to
- match; otherwise change to jump. This is used to jump
- back to the beginning of a repeat. If what follows this jump
- clearly won't match what the repeat does, such that we can be
- sure that there is no use backtracking out of repetitions
- already matched, then we change it to a pop_failure_jump.
- Followed by two-byte address. */
- maybe_pop_jump,
-
- /* Jump to following two-byte address, and push a dummy failure
- point. This failure point will be thrown away if an attempt
- is made to use it for a failure. A `+' construct makes this
- before the first repeat. Also used as an intermediary kind
- of jump when compiling an alternative. */
- dummy_failure_jump,
-
- /* Push a dummy failure point and continue. Used at the end of
- alternatives. */
- push_dummy_failure,
-
- /* Followed by two-byte relative address and two-byte number n.
- After matching N times, jump to the address upon failure. */
- succeed_n,
-
- /* Followed by two-byte relative address, and two-byte number n.
- Jump to the address N times, then fail. */
- jump_n,
-
- /* Set the following two-byte relative address to the
- subsequent two-byte number. The address *includes* the two
- bytes of number. */
- set_number_at,
-
- wordchar, /* Matches any word-constituent character. */
- notwordchar, /* Matches any char that is not a word-constituent. */
-
- wordbeg, /* Succeeds if at word beginning. */
- wordend, /* Succeeds if at word end. */
-
- wordbound, /* Succeeds if at a word boundary. */
- notwordbound /* Succeeds if not at a word boundary. */
-
-#ifdef emacs
- ,before_dot, /* Succeeds if before point. */
- at_dot, /* Succeeds if at point. */
- after_dot, /* Succeeds if after point. */
-
- /* Matches any character whose syntax is specified. Followed by
- a byte which contains a syntax code, e.g., Sword. */
- syntaxspec,
-
- /* Matches any character whose syntax is not that specified. */
- notsyntaxspec
-#endif /* emacs */
-} re_opcode_t;
-
-/* Common operations on the compiled pattern. */
-
-/* Store NUMBER in two contiguous bytes starting at DESTINATION. */
-
-#define STORE_NUMBER(destination, number) \
- do { \
- (destination)[0] = (number) & 0377; \
- (destination)[1] = (number) >> 8; \
- } while (0)
-
-/* Same as STORE_NUMBER, except increment DESTINATION to
- the byte after where the number is stored. Therefore, DESTINATION
- must be an lvalue. */
-
-#define STORE_NUMBER_AND_INCR(destination, number) \
- do { \
- STORE_NUMBER (destination, number); \
- (destination) += 2; \
- } while (0)
-
-/* Put into DESTINATION a number stored in two contiguous bytes starting
- at SOURCE. */
-
-#define EXTRACT_NUMBER(destination, source) \
- do { \
- (destination) = *(source) & 0377; \
- (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \
- } while (0)
-
-#ifdef DEBUG
-static void extract_number _RE_ARGS((int *dest, unsigned char *source));
-static void
-extract_number (dest, source)
- int *dest;
- unsigned char *source;
-{
- int temp = SIGN_EXTEND_CHAR (*(source + 1));
- *dest = *source & 0377;
- *dest += temp << 8;
-}
-
-#ifndef EXTRACT_MACROS /* To debug the macros. */
-#undef EXTRACT_NUMBER
-#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src)
-#endif /* not EXTRACT_MACROS */
-
-#endif /* DEBUG */
-
-/* Same as EXTRACT_NUMBER, except increment SOURCE to after the number.
- SOURCE must be an lvalue. */
-
-#define EXTRACT_NUMBER_AND_INCR(destination, source) \
- do { \
- EXTRACT_NUMBER (destination, source); \
- (source) += 2; \
- } while (0)
-
-#ifdef DEBUG
-static void extract_number_and_incr _RE_ARGS((int *destination,
- unsigned char **source));
-static void
-extract_number_and_incr (destination, source)
- int *destination;
- unsigned char **source;
-{
- extract_number (destination, *source);
- *source += 2;
-}
-
-#ifndef EXTRACT_MACROS
-#undef EXTRACT_NUMBER_AND_INCR
-#define EXTRACT_NUMBER_AND_INCR(dest, src) \
- extract_number_and_incr (&dest, &src)
-#endif /* not EXTRACT_MACROS */
-
-#endif /* DEBUG */
-
-/* If DEBUG is defined, Regex prints many voluminous messages about what
- it is doing (if the variable `debug' is nonzero). If linked with the
- main program in `iregex.c', you can enter patterns and strings
- interactively. And if linked with the main program in `main.c' and
- the other test files, you can run the already-written tests. */
-
-#ifdef DEBUG
-
-/* We use standard I/O for debugging. */
-#include <stdio.h>
-
-/* It is useful to test things that ``must'' be true when debugging. */
-#include <assert.h>
-
-static int debug = 0;
-
-#define DEBUG_STATEMENT(e) e
-#define DEBUG_PRINT1(x) if (debug) printf (x)
-#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2)
-#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3)
-#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4)
-#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \
- if (debug) print_partial_compiled_pattern (s, e)
-#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \
- if (debug) print_double_string (w, s1, sz1, s2, sz2)
-
-
-extern void printchar ();
-
-/* Print the fastmap in human-readable form. */
-
-void
-print_fastmap (fastmap)
- char *fastmap;
-{
- unsigned was_a_range = 0;
- unsigned i = 0;
-
- while (i < (1 << BYTEWIDTH))
- {
- if (fastmap[i++])
- {
- was_a_range = 0;
- printchar (i - 1);
- while (i < (1 << BYTEWIDTH) && fastmap[i])
- {
- was_a_range = 1;
- i++;
- }
- if (was_a_range)
- {
- printf ("-");
- printchar (i - 1);
- }
- }
- }
- putchar ('\n');
-}
-
-
-/* Print a compiled pattern string in human-readable form, starting at
- the START pointer into it and ending just before the pointer END. */
-
-void
-print_partial_compiled_pattern (start, end)
- unsigned char *start;
- unsigned char *end;
-{
- int mcnt, mcnt2;
- unsigned char *p = start;
- unsigned char *pend = end;
-
- if (start == NULL)
- {
- printf ("(null)\n");
- return;
- }
-
- /* Loop over pattern commands. */
- while (p < pend)
- {
- printf ("%d:\t", p - start);
-
- switch ((re_opcode_t) *p++)
- {
- case no_op:
- printf ("/no_op");
- break;
-
- case exactn:
- mcnt = *p++;
- printf ("/exactn/%d", mcnt);
- do
- {
- putchar ('/');
- printchar (*p++);
- }
- while (--mcnt);
- break;
-
- case start_memory:
- mcnt = *p++;
- printf ("/start_memory/%d/%d", mcnt, *p++);
- break;
-
- case stop_memory:
- mcnt = *p++;
- printf ("/stop_memory/%d/%d", mcnt, *p++);
- break;
-
- case duplicate:
- printf ("/duplicate/%d", *p++);
- break;
-
- case anychar:
- printf ("/anychar");
- break;
-
- case charset:
- case charset_not:
- {
- register int c, last = -100;
- register int in_range = 0;
-
- printf ("/charset [%s",
- (re_opcode_t) *(p - 1) == charset_not ? "^" : "");
-
- assert (p + *p < pend);
-
- for (c = 0; c < 256; c++)
- if (c / 8 < *p
- && (p[1 + (c/8)] & (1 << (c % 8))))
- {
- /* Are we starting a range? */
- if (last + 1 == c && ! in_range)
- {
- putchar ('-');
- in_range = 1;
- }
- /* Have we broken a range? */
- else if (last + 1 != c && in_range)
- {
- printchar (last);
- in_range = 0;
- }
-
- if (! in_range)
- printchar (c);
-
- last = c;
- }
-
- if (in_range)
- printchar (last);
-
- putchar (']');
-
- p += 1 + *p;
- }
- break;
-
- case begline:
- printf ("/begline");
- break;
-
- case endline:
- printf ("/endline");
- break;
-
- case on_failure_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/on_failure_jump to %d", p + mcnt - start);
- break;
-
- case on_failure_keep_string_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/on_failure_keep_string_jump to %d", p + mcnt - start);
- break;
-
- case dummy_failure_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/dummy_failure_jump to %d", p + mcnt - start);
- break;
-
- case push_dummy_failure:
- printf ("/push_dummy_failure");
- break;
-
- case maybe_pop_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/maybe_pop_jump to %d", p + mcnt - start);
- break;
-
- case pop_failure_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/pop_failure_jump to %d", p + mcnt - start);
- break;
-
- case jump_past_alt:
- extract_number_and_incr (&mcnt, &p);
- printf ("/jump_past_alt to %d", p + mcnt - start);
- break;
-
- case jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/jump to %d", p + mcnt - start);
- break;
-
- case succeed_n:
- extract_number_and_incr (&mcnt, &p);
- extract_number_and_incr (&mcnt2, &p);
- printf ("/succeed_n to %d, %d times", p + mcnt - start, mcnt2);
- break;
-
- case jump_n:
- extract_number_and_incr (&mcnt, &p);
- extract_number_and_incr (&mcnt2, &p);
- printf ("/jump_n to %d, %d times", p + mcnt - start, mcnt2);
- break;
-
- case set_number_at:
- extract_number_and_incr (&mcnt, &p);
- extract_number_and_incr (&mcnt2, &p);
- printf ("/set_number_at location %d to %d", p + mcnt - start, mcnt2);
- break;
-
- case wordbound:
- printf ("/wordbound");
- break;
-
- case notwordbound:
- printf ("/notwordbound");
- break;
-
- case wordbeg:
- printf ("/wordbeg");
- break;
-
- case wordend:
- printf ("/wordend");
-
-#ifdef emacs
- case before_dot:
- printf ("/before_dot");
- break;
-
- case at_dot:
- printf ("/at_dot");
- break;
-
- case after_dot:
- printf ("/after_dot");
- break;
-
- case syntaxspec:
- printf ("/syntaxspec");
- mcnt = *p++;
- printf ("/%d", mcnt);
- break;
-
- case notsyntaxspec:
- printf ("/notsyntaxspec");
- mcnt = *p++;
- printf ("/%d", mcnt);
- break;
-#endif /* emacs */
-
- case wordchar:
- printf ("/wordchar");
- break;
-
- case notwordchar:
- printf ("/notwordchar");
- break;
-
- case begbuf:
- printf ("/begbuf");
- break;
-
- case endbuf:
- printf ("/endbuf");
- break;
-
- default:
- printf ("?%d", *(p-1));
- }
-
- putchar ('\n');
- }
-
- printf ("%d:\tend of pattern.\n", p - start);
-}
-
-
-void
-print_compiled_pattern (bufp)
- struct re_pattern_buffer *bufp;
-{
- unsigned char *buffer = bufp->buffer;
-
- print_partial_compiled_pattern (buffer, buffer + bufp->used);
- printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated);
-
- if (bufp->fastmap_accurate && bufp->fastmap)
- {
- printf ("fastmap: ");
- print_fastmap (bufp->fastmap);
- }
-
- printf ("re_nsub: %d\t", bufp->re_nsub);
- printf ("regs_alloc: %d\t", bufp->regs_allocated);
- printf ("can_be_null: %d\t", bufp->can_be_null);
- printf ("newline_anchor: %d\n", bufp->newline_anchor);
- printf ("no_sub: %d\t", bufp->no_sub);
- printf ("not_bol: %d\t", bufp->not_bol);
- printf ("not_eol: %d\t", bufp->not_eol);
- printf ("syntax: %d\n", bufp->syntax);
- /* Perhaps we should print the translate table? */
-}
-
-
-void
-print_double_string (where, string1, size1, string2, size2)
- const char *where;
- const char *string1;
- const char *string2;
- int size1;
- int size2;
-{
- unsigned this_char;
-
- if (where == NULL)
- printf ("(null)");
- else
- {
- if (FIRST_STRING_P (where))
- {
- for (this_char = where - string1; this_char < size1; this_char++)
- printchar (string1[this_char]);
-
- where = string2;
- }
-
- for (this_char = where - string2; this_char < size2; this_char++)
- printchar (string2[this_char]);
- }
-}
-
-#else /* not DEBUG */
-
-#undef assert
-#define assert(e)
-
-#define DEBUG_STATEMENT(e)
-#define DEBUG_PRINT1(x)
-#define DEBUG_PRINT2(x1, x2)
-#define DEBUG_PRINT3(x1, x2, x3)
-#define DEBUG_PRINT4(x1, x2, x3, x4)
-#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e)
-#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)
-
-#endif /* not DEBUG */
-
-/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
- also be assigned to arbitrarily: each pattern buffer stores its own
- syntax, so it can be changed between regex compilations. */
-reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS;
-
-
-/* Specify the precise syntax of regexps for compilation. This provides
- for compatibility for various utilities which historically have
- different, incompatible syntaxes.
-
- The argument SYNTAX is a bit mask comprised of the various bits
- defined in regex.h. We return the old syntax. */
-
-reg_syntax_t
-re_set_syntax (syntax)
- reg_syntax_t syntax;
-{
- reg_syntax_t ret = re_syntax_options;
-
- re_syntax_options = syntax;
- return ret;
-}
-
-/* This table gives an error message for each of the error codes listed
- in regex.h. Obviously the order here has to be same as there. */
-
-static const char *re_error_msg[] =
- { NULL, /* REG_NOERROR */
- "No match", /* REG_NOMATCH */
- "Invalid regular expression", /* REG_BADPAT */
- "Invalid collation character", /* REG_ECOLLATE */
- "Invalid character class name", /* REG_ECTYPE */
- "Trailing backslash", /* REG_EESCAPE */
- "Invalid back reference", /* REG_ESUBREG */
- "Unmatched [ or [^", /* REG_EBRACK */
- "Unmatched ( or \\(", /* REG_EPAREN */
- "Unmatched \\{", /* REG_EBRACE */
- "Invalid content of \\{\\}", /* REG_BADBR */
- "Invalid range end", /* REG_ERANGE */
- "Memory exhausted", /* REG_ESPACE */
- "Invalid preceding regular expression", /* REG_BADRPT */
- "Premature end of regular expression", /* REG_EEND */
- "Regular expression too big", /* REG_ESIZE */
- "Unmatched ) or \\)", /* REG_ERPAREN */
- };
-
-/* Subroutine declarations and macros for regex_compile. */
-
-static reg_errcode_t regex_compile _RE_ARGS((const char *pattern, size_t size,
- reg_syntax_t syntax,
- struct re_pattern_buffer *bufp));
-static void store_op1 _RE_ARGS((re_opcode_t op, unsigned char *loc, int arg));
-static void store_op2 _RE_ARGS((re_opcode_t op, unsigned char *loc,
- int arg1, int arg2));
-static void insert_op1 _RE_ARGS((re_opcode_t op, unsigned char *loc,
- int arg, unsigned char *end));
-static void insert_op2 _RE_ARGS((re_opcode_t op, unsigned char *loc,
- int arg1, int arg2, unsigned char *end));
-static boolean at_begline_loc_p _RE_ARGS((const char *pattern, const char *p,
- reg_syntax_t syntax));
-static boolean at_endline_loc_p _RE_ARGS((const char *p, const char *pend,
- reg_syntax_t syntax));
-static reg_errcode_t compile_range _RE_ARGS((const char **p_ptr,
- const char *pend,
- char *translate,
- reg_syntax_t syntax,
- unsigned char *b));
-
-/* Fetch the next character in the uncompiled pattern---translating it
- if necessary. Also cast from a signed character in the constant
- string passed to us by the user to an unsigned char that we can use
- as an array index (in, e.g., `translate'). */
-#define PATFETCH(c) \
- do {if (p == pend) return REG_EEND; \
- c = (unsigned char) *p++; \
- if (translate) c = translate[c]; \
- } while (0)
-
-/* Fetch the next character in the uncompiled pattern, with no
- translation. */
-#define PATFETCH_RAW(c) \
- do {if (p == pend) return REG_EEND; \
- c = (unsigned char) *p++; \
- } while (0)
-
-/* Go backwards one character in the pattern. */
-#define PATUNFETCH p--
-
-
-/* If `translate' is non-null, return translate[D], else just D. We
- cast the subscript to translate because some data is declared as
- `char *', to avoid warnings when a string constant is passed. But
- when we use a character as a subscript we must make it unsigned. */
-#define TRANSLATE(d) (translate ? translate[(unsigned char) (d)] : (d))
-
-
-/* Macros for outputting the compiled pattern into `buffer'. */
-
-/* If the buffer isn't allocated when it comes in, use this. */
-#define INIT_BUF_SIZE 32
-
-/* Make sure we have at least N more bytes of space in buffer. */
-#define GET_BUFFER_SPACE(n) \
- while (b - bufp->buffer + (n) > bufp->allocated) \
- EXTEND_BUFFER ()
-
-/* Make sure we have one more byte of buffer space and then add C to it. */
-#define BUF_PUSH(c) \
- do { \
- GET_BUFFER_SPACE (1); \
- *b++ = (unsigned char) (c); \
- } while (0)
-
-
-/* Ensure we have two more bytes of buffer space and then append C1 and C2. */
-#define BUF_PUSH_2(c1, c2) \
- do { \
- GET_BUFFER_SPACE (2); \
- *b++ = (unsigned char) (c1); \
- *b++ = (unsigned char) (c2); \
- } while (0)
-
-
-/* As with BUF_PUSH_2, except for three bytes. */
-#define BUF_PUSH_3(c1, c2, c3) \
- do { \
- GET_BUFFER_SPACE (3); \
- *b++ = (unsigned char) (c1); \
- *b++ = (unsigned char) (c2); \
- *b++ = (unsigned char) (c3); \
- } while (0)
-
-
-/* Store a jump with opcode OP at LOC to location TO. We store a
- relative address offset by the three bytes the jump itself occupies. */
-#define STORE_JUMP(op, loc, to) \
- store_op1 (op, loc, (int)((to) - (loc) - 3))
-
-/* Likewise, for a two-argument jump. */
-#define STORE_JUMP2(op, loc, to, arg) \
- store_op2 (op, loc, (int)((to) - (loc) - 3), arg)
-
-/* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */
-#define INSERT_JUMP(op, loc, to) \
- insert_op1 (op, loc, (int)((to) - (loc) - 3), b)
-
-/* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */
-#define INSERT_JUMP2(op, loc, to, arg) \
- insert_op2 (op, loc, (int)((to) - (loc) - 3), arg, b)
-
-
-/* This is not an arbitrary limit: the arguments which represent offsets
- into the pattern are two bytes long. So if 2^16 bytes turns out to
- be too small, many things would have to change. */
-/* Any other compiler which, like MSC, has allocation limit below 2^16
- bytes will have to use approach similar to what was done below for
- MSC and drop MAX_BUF_SIZE a bit. Otherwise you may end up
- reallocating to 0 bytes. Such thing is not going to work too well.
- You have been warned!! */
-#ifdef _MSC_VER
-/* Microsoft C 16-bit versions limit malloc to approx 65512 bytes.
- The REALLOC define eliminates a flurry of conversion warnings,
- but is not required. */
-#define MAX_BUF_SIZE 65500L
-#define REALLOC(p,s) realloc((p), (size_t) (s))
-#else
-#define MAX_BUF_SIZE (1L << 16)
-#define REALLOC realloc
-#endif
-
-/* Extend the buffer by twice its current size via realloc and
- reset the pointers that pointed into the old block to point to the
- correct places in the new one. If extending the buffer results in it
- being larger than MAX_BUF_SIZE, then flag memory exhausted. */
-#define EXTEND_BUFFER() \
- do { \
- unsigned char *old_buffer = bufp->buffer; \
- if (bufp->allocated == MAX_BUF_SIZE) \
- return REG_ESIZE; \
- bufp->allocated <<= 1; \
- if (bufp->allocated > MAX_BUF_SIZE) \
- bufp->allocated = MAX_BUF_SIZE; \
- bufp->buffer = (unsigned char *) REALLOC(bufp->buffer, bufp->allocated);\
- if (bufp->buffer == NULL) \
- return REG_ESPACE; \
- /* If the buffer moved, move all the pointers into it. */ \
- if (old_buffer != bufp->buffer) \
- { \
- b = (b - old_buffer) + bufp->buffer; \
- begalt = (begalt - old_buffer) + bufp->buffer; \
- if (fixup_alt_jump) \
- fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\
- if (laststart) \
- laststart = (laststart - old_buffer) + bufp->buffer; \
- if (pending_exact) \
- pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
- } \
- } while (0)
-
-
-/* Since we have one byte reserved for the register number argument to
- {start,stop}_memory, the maximum number of groups we can report
- things about is what fits in that byte. */
-#define MAX_REGNUM 255
-
-/* But patterns can have more than `MAX_REGNUM' registers. We just
- ignore the excess. */
-typedef unsigned regnum_t;
-
-
-/* Macros for the compile stack. */
-
-/* Since offsets can go either forwards or backwards, this type needs to
- be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */
-/* int may be not enough when sizeof(int) == 2 */
-typedef long pattern_offset_t;
-
-typedef struct
-{
- pattern_offset_t begalt_offset;
- pattern_offset_t fixup_alt_jump;
- pattern_offset_t inner_group_offset;
- pattern_offset_t laststart_offset;
- regnum_t regnum;
-} compile_stack_elt_t;
-
-
-typedef struct
-{
- compile_stack_elt_t *stack;
- unsigned size;
- unsigned avail; /* Offset of next open position. */
-} compile_stack_type;
-
-
-#define INIT_COMPILE_STACK_SIZE 32
-
-#define COMPILE_STACK_EMPTY (compile_stack.avail == 0)
-#define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size)
-
-/* The next available element. */
-#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail])
-
-
-/* Set the bit for character C in a list. */
-#define SET_LIST_BIT(c) \
- (b[((unsigned char) (c)) / BYTEWIDTH] \
- |= 1 << (((unsigned char) c) % BYTEWIDTH))
-
-
-/* Get the next unsigned number in the uncompiled pattern. */
-#define GET_UNSIGNED_NUMBER(num) \
- { if (p != pend) \
- { \
- PATFETCH (c); \
- while (ISDIGIT (c)) \
- { \
- if (num < 0) \
- num = 0; \
- num = num * 10 + c - '0'; \
- if (p == pend) \
- break; \
- PATFETCH (c); \
- } \
- } \
- }
-
-#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
-
-#define IS_CHAR_CLASS(string) \
- (STREQ (string, "alpha") || STREQ (string, "upper") \
- || STREQ (string, "lower") || STREQ (string, "digit") \
- || STREQ (string, "alnum") || STREQ (string, "xdigit") \
- || STREQ (string, "space") || STREQ (string, "print") \
- || STREQ (string, "punct") || STREQ (string, "graph") \
- || STREQ (string, "cntrl") || STREQ (string, "blank"))
-
-static boolean group_in_compile_stack _RE_ARGS((compile_stack_type
- compile_stack,
- regnum_t regnum));
-
-#ifdef __FreeBSD__
-static int collate_range_cmp (a, b)
- int a, b;
-{
- int r;
- static char s[2][2];
-
- if ((unsigned char)a == (unsigned char)b)
- return 0;
- s[0][0] = a;
- s[1][0] = b;
- if ((r = strcoll(s[0], s[1])) == 0)
- r = (unsigned char)a - (unsigned char)b;
- return r;
-}
-#endif
-
-/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX.
- Returns one of error codes defined in `regex.h', or zero for success.
-
- Assumes the `allocated' (and perhaps `buffer') and `translate'
- fields are set in BUFP on entry.
-
- If it succeeds, results are put in BUFP (if it returns an error, the
- contents of BUFP are undefined):
- `buffer' is the compiled pattern;
- `syntax' is set to SYNTAX;
- `used' is set to the length of the compiled pattern;
- `fastmap_accurate' is zero;
- `re_nsub' is the number of subexpressions in PATTERN;
- `not_bol' and `not_eol' are zero;
-
- The `fastmap' and `newline_anchor' fields are neither
- examined nor set. */
-
-static reg_errcode_t
-regex_compile (pattern, size, syntax, bufp)
- const char *pattern;
- size_t size;
- reg_syntax_t syntax;
- struct re_pattern_buffer *bufp;
-{
- /* We fetch characters from PATTERN here. Even though PATTERN is
- `char *' (i.e., signed), we declare these variables as unsigned, so
- they can be reliably used as array indices. */
- register unsigned char c, c1;
-
- /* A random tempory spot in PATTERN. */
- const char *p1;
-
- /* Points to the end of the buffer, where we should append. */
- register unsigned char *b;
-
- /* Keeps track of unclosed groups. */
- compile_stack_type compile_stack;
-
- /* Points to the current (ending) position in the pattern. */
- const char *p = pattern;
- const char *pend = pattern + size;
-
- /* How to translate the characters in the pattern. */
- char *translate = bufp->translate;
-
- /* Address of the count-byte of the most recently inserted `exactn'
- command. This makes it possible to tell if a new exact-match
- character can be added to that command or if the character requires
- a new `exactn' command. */
- unsigned char *pending_exact = 0;
-
- /* Address of start of the most recently finished expression.
- This tells, e.g., postfix * where to find the start of its
- operand. Reset at the beginning of groups and alternatives. */
- unsigned char *laststart = 0;
-
- /* Address of beginning of regexp, or inside of last group. */
- unsigned char *begalt;
-
- /* Place in the uncompiled pattern (i.e., the {) to
- which to go back if the interval is invalid. */
- const char *beg_interval;
-
- /* Address of the place where a forward jump should go to the end of
- the containing expression. Each alternative of an `or' -- except the
- last -- ends with a forward jump of this sort. */
- unsigned char *fixup_alt_jump = 0;
-
- /* Counts open-groups as they are encountered. Remembered for the
- matching close-group on the compile stack, so the same register
- number is put in the stop_memory as the start_memory. */
- regnum_t regnum = 0;
-
-#ifdef DEBUG
- DEBUG_PRINT1 ("\nCompiling pattern: ");
- if (debug)
- {
- unsigned debug_count;
-
- for (debug_count = 0; debug_count < size; debug_count++)
- printchar (pattern[debug_count]);
- putchar ('\n');
- }
-#endif /* DEBUG */
-
- /* Initialize the compile stack. */
- compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t);
- if (compile_stack.stack == NULL)
- return REG_ESPACE;
-
- compile_stack.size = INIT_COMPILE_STACK_SIZE;
- compile_stack.avail = 0;
-
- /* Initialize the pattern buffer. */
- bufp->syntax = syntax;
- bufp->fastmap_accurate = 0;
- bufp->not_bol = bufp->not_eol = 0;
-
- /* Set `used' to zero, so that if we return an error, the pattern
- printer (for debugging) will think there's no pattern. We reset it
- at the end. */
- bufp->used = 0;
-
- /* Always count groups, whether or not bufp->no_sub is set. */
- bufp->re_nsub = 0;
-
-#if !defined (emacs) && !defined (SYNTAX_TABLE)
- /* Initialize the syntax table. */
- init_syntax_once ();
-#endif
-
- if (bufp->allocated == 0)
- {
- if (bufp->buffer)
- { /* If zero allocated, but buffer is non-null, try to realloc
- enough space. This loses if buffer's address is bogus, but
- that is the user's responsibility. */
- RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char);
- }
- else
- { /* Caller did not allocate a buffer. Do it for them. */
- bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char);
- }
- if (!bufp->buffer) return REG_ESPACE;
-
- bufp->allocated = INIT_BUF_SIZE;
- }
-
- begalt = b = bufp->buffer;
-
- /* Loop through the uncompiled pattern until we're at the end. */
- while (p != pend)
- {
- PATFETCH (c);
-
- switch (c)
- {
- case '^':
- {
- if ( /* If at start of pattern, it's an operator. */
- p == pattern + 1
- /* If context independent, it's an operator. */
- || syntax & RE_CONTEXT_INDEP_ANCHORS
- /* Otherwise, depends on what's come before. */
- || at_begline_loc_p (pattern, p, syntax))
- BUF_PUSH (begline);
- else
- goto normal_char;
- }
- break;
-
-
- case '$':
- {
- if ( /* If at end of pattern, it's an operator. */
- p == pend
- /* If context independent, it's an operator. */
- || syntax & RE_CONTEXT_INDEP_ANCHORS
- /* Otherwise, depends on what's next. */
- || at_endline_loc_p (p, pend, syntax))
- BUF_PUSH (endline);
- else
- goto normal_char;
- }
- break;
-
-
- case '+':
- case '?':
- if ((syntax & RE_BK_PLUS_QM)
- || (syntax & RE_LIMITED_OPS))
- goto normal_char;
- handle_plus:
- case '*':
- /* If there is no previous pattern... */
- if (!laststart)
- {
- if (syntax & RE_CONTEXT_INVALID_OPS)
- return REG_BADRPT;
- else if (!(syntax & RE_CONTEXT_INDEP_OPS))
- goto normal_char;
- }
-
- {
- /* Are we optimizing this jump? */
- boolean keep_string_p = false;
-
- /* 1 means zero (many) matches is allowed. */
- char zero_times_ok = 0, many_times_ok = 0;
-
- /* If there is a sequence of repetition chars, collapse it
- down to just one (the right one). We can't combine
- interval operators with these because of, e.g., `a{2}*',
- which should only match an even number of `a's. */
-
- for (;;)
- {
- zero_times_ok |= c != '+';
- many_times_ok |= c != '?';
-
- if (p == pend)
- break;
-
- PATFETCH (c);
-
- if (c == '*'
- || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?')))
- ;
-
- else if (syntax & RE_BK_PLUS_QM && c == '\\')
- {
- if (p == pend) return REG_EESCAPE;
-
- PATFETCH (c1);
- if (!(c1 == '+' || c1 == '?'))
- {
- PATUNFETCH;
- PATUNFETCH;
- break;
- }
-
- c = c1;
- }
- else
- {
- PATUNFETCH;
- break;
- }
-
- /* If we get here, we found another repeat character. */
- }
-
- /* Star, etc. applied to an empty pattern is equivalent
- to an empty pattern. */
- if (!laststart)
- break;
-
- /* Now we know whether or not zero matches is allowed
- and also whether or not two or more matches is allowed. */
- if (many_times_ok)
- { /* More than one repetition is allowed, so put in at the
- end a backward relative jump from `b' to before the next
- jump we're going to put in below (which jumps from
- laststart to after this jump).
-
- But if we are at the `*' in the exact sequence `.*\n',
- insert an unconditional jump backwards to the .,
- instead of the beginning of the loop. This way we only
- push a failure point once, instead of every time
- through the loop. */
- assert (p - 1 > pattern);
-
- /* Allocate the space for the jump. */
- GET_BUFFER_SPACE (3);
-
- /* We know we are not at the first character of the pattern,
- because laststart was nonzero. And we've already
- incremented `p', by the way, to be the character after
- the `*'. Do we have to do something analogous here
- for null bytes, because of RE_DOT_NOT_NULL? */
- if (TRANSLATE (*(p - 2)) == TRANSLATE ('.')
- && zero_times_ok
- && p < pend && TRANSLATE (*p) == TRANSLATE ('\n')
- && !(syntax & RE_DOT_NEWLINE))
- { /* We have .*\n. */
- STORE_JUMP (jump, b, laststart);
- keep_string_p = true;
- }
- else
- /* Anything else. */
- STORE_JUMP (maybe_pop_jump, b, laststart - 3);
-
- /* We've added more stuff to the buffer. */
- b += 3;
- }
-
- /* On failure, jump from laststart to b + 3, which will be the
- end of the buffer after this jump is inserted. */
- GET_BUFFER_SPACE (3);
- INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump
- : on_failure_jump,
- laststart, b + 3);
- pending_exact = 0;
- b += 3;
-
- if (!zero_times_ok)
- {
- /* At least one repetition is required, so insert a
- `dummy_failure_jump' before the initial
- `on_failure_jump' instruction of the loop. This
- effects a skip over that instruction the first time
- we hit that loop. */
- GET_BUFFER_SPACE (3);
- INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6);
- b += 3;
- }
- }
- break;
-
-
- case '.':
- laststart = b;
- BUF_PUSH (anychar);
- break;
-
-
- case '[':
- {
- boolean had_char_class = false;
-
- if (p == pend) return REG_EBRACK;
-
- /* Ensure that we have enough space to push a charset: the
- opcode, the length count, and the bitset; 34 bytes in all. */
- GET_BUFFER_SPACE (34);
-
- laststart = b;
-
- /* We test `*p == '^' twice, instead of using an if
- statement, so we only need one BUF_PUSH. */
- BUF_PUSH (*p == '^' ? charset_not : charset);
- if (*p == '^')
- p++;
-
- /* Remember the first position in the bracket expression. */
- p1 = p;
-
- /* Push the number of bytes in the bitmap. */
- BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH);
-
- /* Clear the whole map. */
- bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH);
-
- /* charset_not matches newline according to a syntax bit. */
- if ((re_opcode_t) b[-2] == charset_not
- && (syntax & RE_HAT_LISTS_NOT_NEWLINE))
- SET_LIST_BIT ('\n');
-
- /* Read in characters and ranges, setting map bits. */
- for (;;)
- {
- if (p == pend) return REG_EBRACK;
-
- PATFETCH (c);
-
- /* \ might escape characters inside [...] and [^...]. */
- if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\')
- {
- if (p == pend) return REG_EESCAPE;
-
- PATFETCH (c1);
- SET_LIST_BIT (c1);
- continue;
- }
-
- /* Could be the end of the bracket expression. If it's
- not (i.e., when the bracket expression is `[]' so
- far), the ']' character bit gets set way below. */
- if (c == ']' && p != p1 + 1)
- break;
-
- /* Look ahead to see if it's a range when the last thing
- was a character class. */
- if (had_char_class && c == '-' && *p != ']')
- return REG_ERANGE;
-
- /* Look ahead to see if it's a range when the last thing
- was a character: if this is a hyphen not at the
- beginning or the end of a list, then it's the range
- operator. */
- if (c == '-'
- && !(p - 2 >= pattern && p[-2] == '[')
- && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^')
- && *p != ']')
- {
- reg_errcode_t ret
- = compile_range (&p, pend, translate, syntax, b);
- if (ret != REG_NOERROR) return ret;
- }
-
- else if (p[0] == '-' && p[1] != ']')
- { /* This handles ranges made up of characters only. */
- reg_errcode_t ret;
-
- /* Move past the `-'. */
- PATFETCH (c1);
-
- ret = compile_range (&p, pend, translate, syntax, b);
- if (ret != REG_NOERROR) return ret;
- }
-
- /* See if we're at the beginning of a possible character
- class. */
-
- else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':')
- { /* Leave room for the null. */
- char str[CHAR_CLASS_MAX_LENGTH + 1];
-
- PATFETCH (c);
- c1 = 0;
-
- /* If pattern is `[[:'. */
- if (p == pend) return REG_EBRACK;
-
- for (;;)
- {
- PATFETCH (c);
- if (c == ':' || c == ']' || p == pend
- || c1 == CHAR_CLASS_MAX_LENGTH)
- break;
- str[c1++] = c;
- }
- str[c1] = '\0';
-
- /* If isn't a word bracketed by `[:' and:`]':
- undo the ending character, the letters, and leave
- the leading `:' and `[' (but set bits for them). */
- if (c == ':' && *p == ']')
- {
- int ch;
- boolean is_alnum = STREQ (str, "alnum");
- boolean is_alpha = STREQ (str, "alpha");
- boolean is_blank = STREQ (str, "blank");
- boolean is_cntrl = STREQ (str, "cntrl");
- boolean is_digit = STREQ (str, "digit");
- boolean is_graph = STREQ (str, "graph");
- boolean is_lower = STREQ (str, "lower");
- boolean is_print = STREQ (str, "print");
- boolean is_punct = STREQ (str, "punct");
- boolean is_space = STREQ (str, "space");
- boolean is_upper = STREQ (str, "upper");
- boolean is_xdigit = STREQ (str, "xdigit");
-
- if (!IS_CHAR_CLASS (str)) return REG_ECTYPE;
-
- /* Throw away the ] at the end of the character
- class. */
- PATFETCH (c);
-
- if (p == pend) return REG_EBRACK;
-
- for (ch = 0; ch < 1 << BYTEWIDTH; ch++)
- {
- if ( (is_alnum && ISALNUM (ch))
- || (is_alpha && ISALPHA (ch))
- || (is_blank && ISBLANK (ch))
- || (is_cntrl && ISCNTRL (ch))
- || (is_digit && ISDIGIT (ch))
- || (is_graph && ISGRAPH (ch))
- || (is_lower && ISLOWER (ch))
- || (is_print && ISPRINT (ch))
- || (is_punct && ISPUNCT (ch))
- || (is_space && ISSPACE (ch))
- || (is_upper && ISUPPER (ch))
- || (is_xdigit && ISXDIGIT (ch)))
- SET_LIST_BIT (ch);
- }
- had_char_class = true;
- }
- else
- {
- c1++;
- while (c1--)
- PATUNFETCH;
- SET_LIST_BIT ('[');
- SET_LIST_BIT (':');
- had_char_class = false;
- }
- }
- else
- {
- had_char_class = false;
- SET_LIST_BIT (c);
- }
- }
-
- /* Discard any (non)matching list bytes that are all 0 at the
- end of the map. Decrease the map-length byte too. */
- while ((int) b[-1] > 0 && b[b[-1] - 1] == 0)
- b[-1]--;
- b += b[-1];
- }
- break;
-
-
- case '(':
- if (syntax & RE_NO_BK_PARENS)
- goto handle_open;
- else
- goto normal_char;
-
-
- case ')':
- if (syntax & RE_NO_BK_PARENS)
- goto handle_close;
- else
- goto normal_char;
-
-
- case '\n':
- if (syntax & RE_NEWLINE_ALT)
- goto handle_alt;
- else
- goto normal_char;
-
-
- case '|':
- if (syntax & RE_NO_BK_VBAR)
- goto handle_alt;
- else
- goto normal_char;
-
-
- case '{':
- if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES)
- goto handle_interval;
- else
- goto normal_char;
-
-
- case '\\':
- if (p == pend) return REG_EESCAPE;
-
- /* Do not translate the character after the \, so that we can
- distinguish, e.g., \B from \b, even if we normally would
- translate, e.g., B to b. */
- PATFETCH_RAW (c);
-
- switch (c)
- {
- case '(':
- if (syntax & RE_NO_BK_PARENS)
- goto normal_backslash;
-
- handle_open:
- bufp->re_nsub++;
- regnum++;
-
- if (COMPILE_STACK_FULL)
- {
- RETALLOC (compile_stack.stack, compile_stack.size << 1,
- compile_stack_elt_t);
- if (compile_stack.stack == NULL) return REG_ESPACE;
-
- compile_stack.size <<= 1;
- }
-
- /* These are the values to restore when we hit end of this
- group. They are all relative offsets, so that if the
- whole pattern moves because of realloc, they will still
- be valid. */
- COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer;
- COMPILE_STACK_TOP.fixup_alt_jump
- = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0;
- COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer;
- COMPILE_STACK_TOP.regnum = regnum;
-
- /* We will eventually replace the 0 with the number of
- groups inner to this one. But do not push a
- start_memory for groups beyond the last one we can
- represent in the compiled pattern. */
- if (regnum <= MAX_REGNUM)
- {
- COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2;
- BUF_PUSH_3 (start_memory, regnum, 0);
- }
-
- compile_stack.avail++;
-
- fixup_alt_jump = 0;
- laststart = 0;
- begalt = b;
- /* If we've reached MAX_REGNUM groups, then this open
- won't actually generate any code, so we'll have to
- clear pending_exact explicitly. */
- pending_exact = 0;
- break;
-
-
- case ')':
- if (syntax & RE_NO_BK_PARENS) goto normal_backslash;
-
- if (COMPILE_STACK_EMPTY)
- if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
- goto normal_backslash;
- else
- return REG_ERPAREN;
-
- handle_close:
- if (fixup_alt_jump)
- { /* Push a dummy failure point at the end of the
- alternative for a possible future
- `pop_failure_jump' to pop. See comments at
- `push_dummy_failure' in `re_match_2'. */
- BUF_PUSH (push_dummy_failure);
-
- /* We allocated space for this jump when we assigned
- to `fixup_alt_jump', in the `handle_alt' case below. */
- STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1);
- }
-
- /* See similar code for backslashed left paren above. */
- if (COMPILE_STACK_EMPTY)
- if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
- goto normal_char;
- else
- return REG_ERPAREN;
-
- /* Since we just checked for an empty stack above, this
- ``can't happen''. */
- assert (compile_stack.avail != 0);
- {
- /* We don't just want to restore into `regnum', because
- later groups should continue to be numbered higher,
- as in `(ab)c(de)' -- the second group is #2. */
- regnum_t this_group_regnum;
-
- compile_stack.avail--;
- begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset;
- fixup_alt_jump
- = COMPILE_STACK_TOP.fixup_alt_jump
- ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1
- : 0;
- laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset;
- this_group_regnum = COMPILE_STACK_TOP.regnum;
- /* If we've reached MAX_REGNUM groups, then this open
- won't actually generate any code, so we'll have to
- clear pending_exact explicitly. */
- pending_exact = 0;
-
- /* We're at the end of the group, so now we know how many
- groups were inside this one. */
- if (this_group_regnum <= MAX_REGNUM)
- {
- unsigned char *inner_group_loc
- = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset;
-
- *inner_group_loc = regnum - this_group_regnum;
- BUF_PUSH_3 (stop_memory, this_group_regnum,
- regnum - this_group_regnum);
- }
- }
- break;
-
-
- case '|': /* `\|'. */
- if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR)
- goto normal_backslash;
- handle_alt:
- if (syntax & RE_LIMITED_OPS)
- goto normal_char;
-
- /* Insert before the previous alternative a jump which
- jumps to this alternative if the former fails. */
- GET_BUFFER_SPACE (3);
- INSERT_JUMP (on_failure_jump, begalt, b + 6);
- pending_exact = 0;
- b += 3;
-
- /* The alternative before this one has a jump after it
- which gets executed if it gets matched. Adjust that
- jump so it will jump to this alternative's analogous
- jump (put in below, which in turn will jump to the next
- (if any) alternative's such jump, etc.). The last such
- jump jumps to the correct final destination. A picture:
- _____ _____
- | | | |
- | v | v
- a | b | c
-
- If we are at `b', then fixup_alt_jump right now points to a
- three-byte space after `a'. We'll put in the jump, set
- fixup_alt_jump to right after `b', and leave behind three
- bytes which we'll fill in when we get to after `c'. */
-
- if (fixup_alt_jump)
- STORE_JUMP (jump_past_alt, fixup_alt_jump, b);
-
- /* Mark and leave space for a jump after this alternative,
- to be filled in later either by next alternative or
- when know we're at the end of a series of alternatives. */
- fixup_alt_jump = b;
- GET_BUFFER_SPACE (3);
- b += 3;
-
- laststart = 0;
- begalt = b;
- break;
-
-
- case '{':
- /* If \{ is a literal. */
- if (!(syntax & RE_INTERVALS)
- /* If we're at `\{' and it's not the open-interval
- operator. */
- || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
- || (p - 2 == pattern && p == pend))
- goto normal_backslash;
-
- handle_interval:
- {
- /* If got here, then the syntax allows intervals. */
-
- /* At least (most) this many matches must be made. */
- int lower_bound = -1, upper_bound = -1;
-
- beg_interval = p - 1;
-
- if (p == pend)
- {
- if (syntax & RE_NO_BK_BRACES)
- goto unfetch_interval;
- else
- return REG_EBRACE;
- }
-
- GET_UNSIGNED_NUMBER (lower_bound);
-
- if (c == ',')
- {
- GET_UNSIGNED_NUMBER (upper_bound);
- if (upper_bound < 0) upper_bound = RE_DUP_MAX;
- }
- else
- /* Interval such as `{1}' => match exactly once. */
- upper_bound = lower_bound;
-
- if (lower_bound < 0 || upper_bound > RE_DUP_MAX
- || lower_bound > upper_bound)
- {
- if (syntax & RE_NO_BK_BRACES)
- goto unfetch_interval;
- else
- return REG_BADBR;
- }
-
- if (!(syntax & RE_NO_BK_BRACES))
- {
- if (c != '\\') return REG_EBRACE;
-
- PATFETCH (c);
- }
-
- if (c != '}')
- {
- if (syntax & RE_NO_BK_BRACES)
- goto unfetch_interval;
- else
- return REG_BADBR;
- }
-
- /* We just parsed a valid interval. */
-
- /* If it's invalid to have no preceding re. */
- if (!laststart)
- {
- if (syntax & RE_CONTEXT_INVALID_OPS)
- return REG_BADRPT;
- else if (syntax & RE_CONTEXT_INDEP_OPS)
- laststart = b;
- else
- goto unfetch_interval;
- }
-
- /* If the upper bound is zero, don't want to succeed at
- all; jump from `laststart' to `b + 3', which will be
- the end of the buffer after we insert the jump. */
- if (upper_bound == 0)
- {
- GET_BUFFER_SPACE (3);
- INSERT_JUMP (jump, laststart, b + 3);
- b += 3;
- }
-
- /* Otherwise, we have a nontrivial interval. When
- we're all done, the pattern will look like:
- set_number_at <jump count> <upper bound>
- set_number_at <succeed_n count> <lower bound>
- succeed_n <after jump addr> <succed_n count>
- <body of loop>
- jump_n <succeed_n addr> <jump count>
- (The upper bound and `jump_n' are omitted if
- `upper_bound' is 1, though.) */
- else
- { /* If the upper bound is > 1, we need to insert
- more at the end of the loop. */
- unsigned nbytes = 10 + (upper_bound > 1) * 10;
-
- GET_BUFFER_SPACE (nbytes);
-
- /* Initialize lower bound of the `succeed_n', even
- though it will be set during matching by its
- attendant `set_number_at' (inserted next),
- because `re_compile_fastmap' needs to know.
- Jump to the `jump_n' we might insert below. */
- INSERT_JUMP2 (succeed_n, laststart,
- b + 5 + (upper_bound > 1) * 5,
- lower_bound);
- b += 5;
-
- /* Code to initialize the lower bound. Insert
- before the `succeed_n'. The `5' is the last two
- bytes of this `set_number_at', plus 3 bytes of
- the following `succeed_n'. */
- insert_op2 (set_number_at, laststart, 5, lower_bound, b);
- b += 5;
-
- if (upper_bound > 1)
- { /* More than one repetition is allowed, so
- append a backward jump to the `succeed_n'
- that starts this interval.
-
- When we've reached this during matching,
- we'll have matched the interval once, so
- jump back only `upper_bound - 1' times. */
- STORE_JUMP2 (jump_n, b, laststart + 5,
- upper_bound - 1);
- b += 5;
-
- /* The location we want to set is the second
- parameter of the `jump_n'; that is `b-2' as
- an absolute address. `laststart' will be
- the `set_number_at' we're about to insert;
- `laststart+3' the number to set, the source
- for the relative address. But we are
- inserting into the middle of the pattern --
- so everything is getting moved up by 5.
- Conclusion: (b - 2) - (laststart + 3) + 5,
- i.e., b - laststart.
-
- We insert this at the beginning of the loop
- so that if we fail during matching, we'll
- reinitialize the bounds. */
- insert_op2 (set_number_at, laststart, b - laststart,
- upper_bound - 1, b);
- b += 5;
- }
- }
- pending_exact = 0;
- beg_interval = NULL;
- }
- break;
-
- unfetch_interval:
- /* If an invalid interval, match the characters as literals. */
- assert (beg_interval);
- p = beg_interval;
- beg_interval = NULL;
-
- /* normal_char and normal_backslash need `c'. */
- PATFETCH (c);
-
- if (!(syntax & RE_NO_BK_BRACES))
- {
- if (p > pattern && p[-1] == '\\')
- goto normal_backslash;
- }
- goto normal_char;
-
-#ifdef emacs
- /* There is no way to specify the before_dot and after_dot
- operators. rms says this is ok. --karl */
- case '=':
- BUF_PUSH (at_dot);
- break;
-
- case 's':
- laststart = b;
- PATFETCH (c);
- BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]);
- break;
-
- case 'S':
- laststart = b;
- PATFETCH (c);
- BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]);
- break;
-#endif /* emacs */
-
-
- case 'w':
- if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
- laststart = b;
- BUF_PUSH (wordchar);
- break;
-
-
- case 'W':
- if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
- laststart = b;
- BUF_PUSH (notwordchar);
- break;
-
-
- case '<':
- if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
- BUF_PUSH (wordbeg);
- break;
-
- case '>':
- if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
- BUF_PUSH (wordend);
- break;
-
- case 'b':
- if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
- BUF_PUSH (wordbound);
- break;
-
- case 'B':
- if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
- BUF_PUSH (notwordbound);
- break;
-
- case '`':
- if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
- BUF_PUSH (begbuf);
- break;
-
- case '\'':
- if (re_syntax_options & RE_NO_GNU_OPS)
- goto normal_char;
- BUF_PUSH (endbuf);
- break;
-
- case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- if (syntax & RE_NO_BK_REFS)
- goto normal_char;
-
- c1 = c - '0';
-
- if (c1 > regnum)
- return REG_ESUBREG;
-
- /* Can't back reference to a subexpression if inside of it. */
- if (group_in_compile_stack (compile_stack, (regnum_t)c1))
- goto normal_char;
-
- laststart = b;
- BUF_PUSH_2 (duplicate, c1);
- break;
-
-
- case '+':
- case '?':
- if (syntax & RE_BK_PLUS_QM)
- goto handle_plus;
- else
- goto normal_backslash;
-
- default:
- normal_backslash:
- /* You might think it would be useful for \ to mean
- not to translate; but if we don't translate it
- it will never match anything. */
- c = TRANSLATE (c);
- goto normal_char;
- }
- break;
-
-
- default:
- /* Expects the character in `c'. */
- normal_char:
- /* If no exactn currently being built. */
- if (!pending_exact
-
- /* If last exactn not at current position. */
- || pending_exact + *pending_exact + 1 != b
-
- /* We have only one byte following the exactn for the count. */
- || *pending_exact == (1 << BYTEWIDTH) - 1
-
- /* If followed by a repetition operator. */
- || *p == '*' || *p == '^'
- || ((syntax & RE_BK_PLUS_QM)
- ? *p == '\\' && (p[1] == '+' || p[1] == '?')
- : (*p == '+' || *p == '?'))
- || ((syntax & RE_INTERVALS)
- && ((syntax & RE_NO_BK_BRACES)
- ? *p == '{'
- : (p[0] == '\\' && p[1] == '{'))))
- {
- /* Start building a new exactn. */
-
- laststart = b;
-
- BUF_PUSH_2 (exactn, 0);
- pending_exact = b - 1;
- }
-
- BUF_PUSH (c);
- (*pending_exact)++;
- break;
- } /* switch (c) */
- } /* while p != pend */
-
-
- /* Through the pattern now. */
-
- if (fixup_alt_jump)
- STORE_JUMP (jump_past_alt, fixup_alt_jump, b);
-
- if (!COMPILE_STACK_EMPTY)
- return REG_EPAREN;
-
- free (compile_stack.stack);
-
- /* We have succeeded; set the length of the buffer. */
- bufp->used = b - bufp->buffer;
-
-#ifdef DEBUG
- if (debug)
- {
- DEBUG_PRINT1 ("\nCompiled pattern: \n");
- print_compiled_pattern (bufp);
- }
-#endif /* DEBUG */
-
- return REG_NOERROR;
-} /* regex_compile */
-
-/* Subroutines for `regex_compile'. */
-
-/* Store OP at LOC followed by two-byte integer parameter ARG. */
-
-static void
-store_op1 (op, loc, arg)
- re_opcode_t op;
- unsigned char *loc;
- int arg;
-{
- *loc = (unsigned char) op;
- STORE_NUMBER (loc + 1, arg);
-}
-
-
-/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */
-
-static void
-store_op2 (op, loc, arg1, arg2)
- re_opcode_t op;
- unsigned char *loc;
- int arg1, arg2;
-{
- *loc = (unsigned char) op;
- STORE_NUMBER (loc + 1, arg1);
- STORE_NUMBER (loc + 3, arg2);
-}
-
-
-/* Copy the bytes from LOC to END to open up three bytes of space at LOC
- for OP followed by two-byte integer parameter ARG. */
-
-static void
-insert_op1 (op, loc, arg, end)
- re_opcode_t op;
- unsigned char *loc;
- int arg;
- unsigned char *end;
-{
- register unsigned char *pfrom = end;
- register unsigned char *pto = end + 3;
-
- while (pfrom != loc)
- *--pto = *--pfrom;
-
- store_op1 (op, loc, arg);
-}
-
-
-/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */
-
-static void
-insert_op2 (op, loc, arg1, arg2, end)
- re_opcode_t op;
- unsigned char *loc;
- int arg1, arg2;
- unsigned char *end;
-{
- register unsigned char *pfrom = end;
- register unsigned char *pto = end + 5;
-
- while (pfrom != loc)
- *--pto = *--pfrom;
-
- store_op2 (op, loc, arg1, arg2);
-}
-
-
-/* P points to just after a ^ in PATTERN. Return true if that ^ comes
- after an alternative or a begin-subexpression. We assume there is at
- least one character before the ^. */
-
-static boolean
-at_begline_loc_p (pattern, p, syntax)
- const char *pattern, *p;
- reg_syntax_t syntax;
-{
- const char *prev = p - 2;
- boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
-
- return
- /* After a subexpression? */
- (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash))
- /* After an alternative? */
- || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash));
-}
-
-
-/* The dual of at_begline_loc_p. This one is for $. We assume there is
- at least one character after the $, i.e., `P < PEND'. */
-
-static boolean
-at_endline_loc_p (p, pend, syntax)
- const char *p, *pend;
- reg_syntax_t syntax;
-{
- const char *next = p;
- boolean next_backslash = *next == '\\';
- const char *next_next = p + 1 < pend ? p + 1 : NULL;
-
- return
- /* Before a subexpression? */
- (syntax & RE_NO_BK_PARENS ? *next == ')'
- : next_backslash && next_next && *next_next == ')')
- /* Before an alternative? */
- || (syntax & RE_NO_BK_VBAR ? *next == '|'
- : next_backslash && next_next && *next_next == '|');
-}
-
-
-/* Returns true if REGNUM is in one of COMPILE_STACK's elements and
- false if it's not. */
-
-static boolean
-group_in_compile_stack (compile_stack, regnum)
- compile_stack_type compile_stack;
- regnum_t regnum;
-{
- int this_element;
-
- for (this_element = compile_stack.avail - 1;
- this_element >= 0;
- this_element--)
- if (compile_stack.stack[this_element].regnum == regnum)
- return true;
-
- return false;
-}
-
-
-/* Read the ending character of a range (in a bracket expression) from the
- uncompiled pattern *P_PTR (which ends at PEND). We assume the
- starting character is in `P[-2]'. (`P[-1]' is the character `-'.)
- Then we set the translation of all bits between the starting and
- ending characters (inclusive) in the compiled pattern B.
-
- Return an error code.
-
- We use these short variable names so we can use the same macros as
- `regex_compile' itself. */
-
-static reg_errcode_t
-compile_range (p_ptr, pend, translate, syntax, b)
- const char **p_ptr, *pend;
- char *translate;
- reg_syntax_t syntax;
- unsigned char *b;
-{
- unsigned this_char;
-
- const char *p = *p_ptr;
- int range_start, range_end;
-
- if (p == pend)
- return REG_ERANGE;
-
- /* Even though the pattern is a signed `char *', we need to fetch
- with unsigned char *'s; if the high bit of the pattern character
- is set, the range endpoints will be negative if we fetch using a
- signed char *.
-
- We also want to fetch the endpoints without translating them; the
- appropriate translation is done in the bit-setting loop below. */
- range_start = ((unsigned char *) p)[-2];
- range_end = ((unsigned char *) p)[0];
-
- /* Have to increment the pointer into the pattern string, so the
- caller isn't still at the ending character. */
- (*p_ptr)++;
-
- /* If the start is after the end, the range is empty. */
-#ifdef __FreeBSD__
- if (collate_range_cmp (range_start, range_end) > 0)
-#else
- if (range_start > range_end)
-#endif
- return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
-
-#ifdef __FreeBSD__
- for (this_char = 0; this_char < 1 << BYTEWIDTH; this_char++)
- if ( collate_range_cmp (range_start, this_char) <= 0
- && collate_range_cmp (this_char, range_end) <= 0
- ) {
- SET_LIST_BIT (TRANSLATE (this_char));
- }
-#else
- /* Here we see why `this_char' has to be larger than an `unsigned
- char' -- the range is inclusive, so if `range_end' == 0xff
- (assuming 8-bit characters), we would otherwise go into an infinite
- loop, since all characters <= 0xff. */
- for (this_char = range_start; this_char <= range_end; this_char++)
- {
- SET_LIST_BIT (TRANSLATE (this_char));
- }
-#endif
- return REG_NOERROR;
-}
-
-/* Failure stack declarations and macros; both re_compile_fastmap and
- re_match_2 use a failure stack. These have to be macros because of
- REGEX_ALLOCATE. */
-
-
-/* Number of failure points for which to initially allocate space
- when matching. If this number is exceeded, we allocate more
- space, so it is not a hard limit. */
-#ifndef INIT_FAILURE_ALLOC
-#define INIT_FAILURE_ALLOC 5
-#endif
-
-/* Roughly the maximum number of failure points on the stack. Would be
- exactly that if always used MAX_FAILURE_SPACE each time we failed.
- This is a variable only so users of regex can assign to it; we never
- change it ourselves. */
-int re_max_failures = 2000;
-
-typedef const unsigned char *fail_stack_elt_t;
-
-typedef struct
-{
- fail_stack_elt_t *stack;
- unsigned size;
- unsigned avail; /* Offset of next open position. */
-} fail_stack_type;
-
-#define FAIL_STACK_EMPTY() (fail_stack.avail == 0)
-#define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0)
-#define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size)
-#define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail])
-
-
-/* Initialize `fail_stack'. Do `return -2' if the alloc fails. */
-
-#define INIT_FAIL_STACK() \
- do { \
- fail_stack.stack = (fail_stack_elt_t *) \
- REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \
- \
- if (fail_stack.stack == NULL) \
- return -2; \
- \
- fail_stack.size = INIT_FAILURE_ALLOC; \
- fail_stack.avail = 0; \
- } while (0)
-
-
-/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items.
-
- Return 1 if succeeds, and 0 if either ran out of memory
- allocating space for it or it was already too large.
-
- REGEX_REALLOCATE requires `destination' be declared. */
-
-#define DOUBLE_FAIL_STACK(fail_stack) \
- ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \
- ? 0 \
- : ((fail_stack).stack = (fail_stack_elt_t *) \
- REGEX_REALLOCATE ((fail_stack).stack, \
- (fail_stack).size * sizeof (fail_stack_elt_t), \
- ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \
- \
- (fail_stack).stack == NULL \
- ? 0 \
- : ((fail_stack).size <<= 1, \
- 1)))
-
-
-/* Push PATTERN_OP on FAIL_STACK.
-
- Return 1 if was able to do so and 0 if ran out of memory allocating
- space to do so. */
-#define PUSH_PATTERN_OP(pattern_op, fail_stack) \
- ((FAIL_STACK_FULL () \
- && !DOUBLE_FAIL_STACK (fail_stack)) \
- ? 0 \
- : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \
- 1))
-
-/* This pushes an item onto the failure stack. Must be a four-byte
- value. Assumes the variable `fail_stack'. Probably should only
- be called from within `PUSH_FAILURE_POINT'. */
-#define PUSH_FAILURE_ITEM(item) \
- fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item
-
-/* The complement operation. Assumes `fail_stack' is nonempty. */
-#define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail]
-
-/* Used to omit pushing failure point id's when we're not debugging. */
-#ifdef DEBUG
-#define DEBUG_PUSH PUSH_FAILURE_ITEM
-#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_ITEM ()
-#else
-#define DEBUG_PUSH(item)
-#define DEBUG_POP(item_addr)
-#endif
-
-
-/* Push the information about the state we will need
- if we ever fail back to it.
-
- Requires variables fail_stack, regstart, regend, reg_info, and
- num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be
- declared.
-
- Does `return FAILURE_CODE' if runs out of memory. */
-
-#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \
- do { \
- char *destination; \
- /* Must be int, so when we don't save any registers, the arithmetic \
- of 0 + -1 isn't done as unsigned. */ \
- /* Can't be int, since there is not a shred of a guarantee that int \
- is wide enough to hold a value of something to which pointer can \
- be assigned */ \
- s_reg_t this_reg; \
- \
- DEBUG_STATEMENT (failure_id++); \
- DEBUG_STATEMENT (nfailure_points_pushed++); \
- DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \
- DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\
- DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\
- \
- DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \
- DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \
- \
- /* Ensure we have enough space allocated for what we will push. */ \
- while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \
- { \
- if (!DOUBLE_FAIL_STACK (fail_stack)) \
- return failure_code; \
- \
- DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \
- (fail_stack).size); \
- DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\
- }
-
-#define PUSH_FAILURE_POINT2(pattern_place, string_place, failure_code) \
- /* Push the info, starting with the registers. */ \
- DEBUG_PRINT1 ("\n"); \
- \
- PUSH_FAILURE_POINT_LOOP (); \
- \
- DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\
- PUSH_FAILURE_ITEM (lowest_active_reg); \
- \
- DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\
- PUSH_FAILURE_ITEM (highest_active_reg); \
- \
- DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \
- DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \
- PUSH_FAILURE_ITEM (pattern_place); \
- \
- DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \
- DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \
- size2); \
- DEBUG_PRINT1 ("'\n"); \
- PUSH_FAILURE_ITEM (string_place); \
- \
- DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \
- DEBUG_PUSH (failure_id); \
- } while (0)
-
-/* Pulled out of PUSH_FAILURE_POINT() to shorten the definition
- of that macro. (for VAX C) */
-#define PUSH_FAILURE_POINT_LOOP() \
- for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \
- this_reg++) \
- { \
- DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \
- DEBUG_STATEMENT (num_regs_pushed++); \
- \
- DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \
- PUSH_FAILURE_ITEM (regstart[this_reg]); \
- \
- DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \
- PUSH_FAILURE_ITEM (regend[this_reg]); \
- \
- DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \
- DEBUG_PRINT2 (" match_null=%d", \
- REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \
- DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \
- DEBUG_PRINT2 (" matched_something=%d", \
- MATCHED_SOMETHING (reg_info[this_reg])); \
- DEBUG_PRINT2 (" ever_matched=%d", \
- EVER_MATCHED_SOMETHING (reg_info[this_reg])); \
- DEBUG_PRINT1 ("\n"); \
- PUSH_FAILURE_ITEM (reg_info[this_reg].word); \
- }
-
-/* This is the number of items that are pushed and popped on the stack
- for each register. */
-#define NUM_REG_ITEMS 3
-
-/* Individual items aside from the registers. */
-#ifdef DEBUG
-#define NUM_NONREG_ITEMS 5 /* Includes failure point id. */
-#else
-#define NUM_NONREG_ITEMS 4
-#endif
-
-/* We push at most this many items on the stack. */
-#define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS)
-
-/* We actually push this many items. */
-#define NUM_FAILURE_ITEMS \
- ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \
- + NUM_NONREG_ITEMS)
-
-/* How many items can still be added to the stack without overflowing it. */
-#define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail)
-
-
-/* Pops what PUSH_FAIL_STACK pushes.
-
- We restore into the parameters, all of which should be lvalues:
- STR -- the saved data position.
- PAT -- the saved pattern position.
- LOW_REG, HIGH_REG -- the highest and lowest active registers.
- REGSTART, REGEND -- arrays of string positions.
- REG_INFO -- array of information about each subexpression.
-
- Also assumes the variables `fail_stack' and (if debugging), `bufp',
- `pend', `string1', `size1', `string2', and `size2'. */
-
-#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\
-{ \
- DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \
- s_reg_t this_reg; \
- const unsigned char *string_temp; \
- \
- assert (!FAIL_STACK_EMPTY ()); \
- \
- /* Remove failure points and point to how many regs pushed. */ \
- DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \
- DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \
- DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \
- \
- assert (fail_stack.avail >= NUM_NONREG_ITEMS); \
- \
- DEBUG_POP (&failure_id); \
- DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \
- \
- /* If the saved string location is NULL, it came from an \
- on_failure_keep_string_jump opcode, and we want to throw away the \
- saved NULL, thus retaining our current position in the string. */ \
- string_temp = POP_FAILURE_ITEM (); \
- if (string_temp != NULL) \
- str = (const char *) string_temp; \
- \
- DEBUG_PRINT2 (" Popping string 0x%x: `", str); \
- DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \
- DEBUG_PRINT1 ("'\n"); \
- \
- pat = (unsigned char *) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \
- DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \
- \
- POP_FAILURE_POINT2 (low_reg, high_reg, regstart, regend, reg_info);
-
-/* Pulled out of POP_FAILURE_POINT() to shorten the definition
- of that macro. (for MSC 5.1) */
-#define POP_FAILURE_POINT2(low_reg, high_reg, regstart, regend, reg_info) \
- \
- /* Restore register info. */ \
- high_reg = (active_reg_t) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \
- \
- low_reg = (active_reg_t) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \
- \
- for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \
- { \
- DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \
- \
- reg_info[this_reg].word = POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \
- \
- regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \
- \
- regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \
- } \
- \
- DEBUG_STATEMENT (nfailure_points_popped++); \
-} /* POP_FAILURE_POINT */
-
-
-/* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in
- BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible
- characters can start a string that matches the pattern. This fastmap
- is used by re_search to skip quickly over impossible starting points.
-
- The caller must supply the address of a (1 << BYTEWIDTH)-byte data
- area as BUFP->fastmap.
-
- We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in
- the pattern buffer.
-
- Returns 0 if we succeed, -2 if an internal error. */
-
-int
-re_compile_fastmap (bufp)
- struct re_pattern_buffer *bufp;
-{
- int j, k;
- fail_stack_type fail_stack;
-#ifndef REGEX_MALLOC
- char *destination;
-#endif
- /* We don't push any register information onto the failure stack. */
- unsigned num_regs = 0;
-
- register char *fastmap = bufp->fastmap;
- unsigned char *pattern = bufp->buffer;
- const unsigned char *p = pattern;
- register unsigned char *pend = pattern + bufp->used;
-
- /* Assume that each path through the pattern can be null until
- proven otherwise. We set this false at the bottom of switch
- statement, to which we get only if a particular path doesn't
- match the empty string. */
- boolean path_can_be_null = true;
-
- /* We aren't doing a `succeed_n' to begin with. */
- boolean succeed_n_p = false;
-
- assert (fastmap != NULL && p != NULL);
-
- INIT_FAIL_STACK ();
- bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */
- bufp->fastmap_accurate = 1; /* It will be when we're done. */
- bufp->can_be_null = 0;
-
- while (p != pend || !FAIL_STACK_EMPTY ())
- {
- if (p == pend)
- {
- bufp->can_be_null |= path_can_be_null;
-
- /* Reset for next path. */
- path_can_be_null = true;
-
- p = fail_stack.stack[--fail_stack.avail];
- }
-
- /* We should never be about to go beyond the end of the pattern. */
- assert (p < pend);
-
-#ifdef SWITCH_ENUM_BUG
- switch ((int) ((re_opcode_t) *p++))
-#else
- switch ((re_opcode_t) *p++)
-#endif
- {
-
- /* I guess the idea here is to simply not bother with a fastmap
- if a backreference is used, since it's too hard to figure out
- the fastmap for the corresponding group. Setting
- `can_be_null' stops `re_search_2' from using the fastmap, so
- that is all we do. */
- case duplicate:
- bufp->can_be_null = 1;
- return 0;
-
-
- /* Following are the cases which match a character. These end
- with `break'. */
-
- case exactn:
- fastmap[p[1]] = 1;
- break;
-
-
- case charset:
- for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
- if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))
- fastmap[j] = 1;
- break;
-
-
- case charset_not:
- /* Chars beyond end of map must be allowed. */
- for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++)
- fastmap[j] = 1;
-
- for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
- if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))))
- fastmap[j] = 1;
- break;
-
-
- case wordchar:
- for (j = 0; j < (1 << BYTEWIDTH); j++)
- if (SYNTAX (j) == Sword)
- fastmap[j] = 1;
- break;
-
-
- case notwordchar:
- for (j = 0; j < (1 << BYTEWIDTH); j++)
- if (SYNTAX (j) != Sword)
- fastmap[j] = 1;
- break;
-
-
- case anychar:
- /* `.' matches anything ... */
- for (j = 0; j < (1 << BYTEWIDTH); j++)
- fastmap[j] = 1;
-
- /* ... except perhaps newline. */
- if (!(bufp->syntax & RE_DOT_NEWLINE))
- fastmap['\n'] = 0;
-
- /* Return if we have already set `can_be_null'; if we have,
- then the fastmap is irrelevant. Something's wrong here. */
- else if (bufp->can_be_null)
- return 0;
-
- /* Otherwise, have to check alternative paths. */
- break;
-
-
-#ifdef emacs
- case syntaxspec:
- k = *p++;
- for (j = 0; j < (1 << BYTEWIDTH); j++)
- if (SYNTAX (j) == (enum syntaxcode) k)
- fastmap[j] = 1;
- break;
-
-
- case notsyntaxspec:
- k = *p++;
- for (j = 0; j < (1 << BYTEWIDTH); j++)
- if (SYNTAX (j) != (enum syntaxcode) k)
- fastmap[j] = 1;
- break;
-
-
- /* All cases after this match the empty string. These end with
- `continue'. */
-
-
- case before_dot:
- case at_dot:
- case after_dot:
- continue;
-#endif /* not emacs */
-
-
- case no_op:
- case begline:
- case endline:
- case begbuf:
- case endbuf:
- case wordbound:
- case notwordbound:
- case wordbeg:
- case wordend:
- case push_dummy_failure:
- continue;
-
-
- case jump_n:
- case pop_failure_jump:
- case maybe_pop_jump:
- case jump:
- case jump_past_alt:
- case dummy_failure_jump:
- EXTRACT_NUMBER_AND_INCR (j, p);
- p += j;
- if (j > 0)
- continue;
-
- /* Jump backward implies we just went through the body of a
- loop and matched nothing. Opcode jumped to should be
- `on_failure_jump' or `succeed_n'. Just treat it like an
- ordinary jump. For a * loop, it has pushed its failure
- point already; if so, discard that as redundant. */
- if ((re_opcode_t) *p != on_failure_jump
- && (re_opcode_t) *p != succeed_n)
- continue;
-
- p++;
- EXTRACT_NUMBER_AND_INCR (j, p);
- p += j;
-
- /* If what's on the stack is where we are now, pop it. */
- if (!FAIL_STACK_EMPTY ()
- && fail_stack.stack[fail_stack.avail - 1] == p)
- fail_stack.avail--;
-
- continue;
-
-
- case on_failure_jump:
- case on_failure_keep_string_jump:
- handle_on_failure_jump:
- EXTRACT_NUMBER_AND_INCR (j, p);
-
- /* For some patterns, e.g., `(a?)?', `p+j' here points to the
- end of the pattern. We don't want to push such a point,
- since when we restore it above, entering the switch will
- increment `p' past the end of the pattern. We don't need
- to push such a point since we obviously won't find any more
- fastmap entries beyond `pend'. Such a pattern can match
- the null string, though. */
- if (p + j < pend)
- {
- if (!PUSH_PATTERN_OP (p + j, fail_stack))
- return -2;
- }
- else
- bufp->can_be_null = 1;
-
- if (succeed_n_p)
- {
- EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */
- succeed_n_p = false;
- }
-
- continue;
-
-
- case succeed_n:
- /* Get to the number of times to succeed. */
- p += 2;
-
- /* Increment p past the n for when k != 0. */
- EXTRACT_NUMBER_AND_INCR (k, p);
- if (k == 0)
- {
- p -= 4;
- succeed_n_p = true; /* Spaghetti code alert. */
- goto handle_on_failure_jump;
- }
- continue;
-
-
- case set_number_at:
- p += 4;
- continue;
-
-
- case start_memory:
- case stop_memory:
- p += 2;
- continue;
-
-
- default:
- abort (); /* We have listed all the cases. */
- } /* switch *p++ */
-
- /* Getting here means we have found the possible starting
- characters for one path of the pattern -- and that the empty
- string does not match. We need not follow this path further.
- Instead, look at the next alternative (remembered on the
- stack), or quit if no more. The test at the top of the loop
- does these things. */
- path_can_be_null = false;
- p = pend;
- } /* while p */
-
- /* Set `can_be_null' for the last path (also the first path, if the
- pattern is empty). */
- bufp->can_be_null |= path_can_be_null;
- return 0;
-} /* re_compile_fastmap */
-
-/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
- ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use
- this memory for recording register information. STARTS and ENDS
- must be allocated using the malloc library routine, and must each
- be at least NUM_REGS * sizeof (regoff_t) bytes long.
-
- If NUM_REGS == 0, then subsequent matches should allocate their own
- register data.
-
- Unless this function is called, the first search or match using
- PATTERN_BUFFER will allocate its own register data, without
- freeing the old data. */
-
-void
-re_set_registers (bufp, regs, num_regs, starts, ends)
- struct re_pattern_buffer *bufp;
- struct re_registers *regs;
- unsigned num_regs;
- regoff_t *starts, *ends;
-{
- if (num_regs)
- {
- bufp->regs_allocated = REGS_REALLOCATE;
- regs->num_regs = num_regs;
- regs->start = starts;
- regs->end = ends;
- }
- else
- {
- bufp->regs_allocated = REGS_UNALLOCATED;
- regs->num_regs = 0;
- regs->start = regs->end = 0;
- }
-}
-
-/* Searching routines. */
-
-/* Like re_search_2, below, but only one string is specified, and
- doesn't let you say where to stop matching. */
-
-int
-re_search (bufp, string, size, startpos, range, regs)
- struct re_pattern_buffer *bufp;
- const char *string;
- int size, startpos, range;
- struct re_registers *regs;
-{
- return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
- regs, size);
-}
-
-
-/* Using the compiled pattern in BUFP->buffer, first tries to match the
- virtual concatenation of STRING1 and STRING2, starting first at index
- STARTPOS, then at STARTPOS + 1, and so on.
-
- STRING1 and STRING2 have length SIZE1 and SIZE2, respectively.
-
- RANGE is how far to scan while trying to match. RANGE = 0 means try
- only at STARTPOS; in general, the last start tried is STARTPOS +
- RANGE.
-
- In REGS, return the indices of the virtual concatenation of STRING1
- and STRING2 that matched the entire BUFP->buffer and its contained
- subexpressions.
-
- Do not consider matching one past the index STOP in the virtual
- concatenation of STRING1 and STRING2.
-
- We return either the position in the strings at which the match was
- found, -1 if no match, or -2 if error (such as failure
- stack overflow). */
-
-int
-re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int size1, size2;
- int startpos;
- int range;
- struct re_registers *regs;
- int stop;
-{
- int val;
- register char *fastmap = bufp->fastmap;
- register char *translate = bufp->translate;
- int total_size = size1 + size2;
- int endpos = startpos + range;
-
- /* Check for out-of-range STARTPOS. */
- if (startpos < 0 || startpos > total_size)
- return -1;
-
- /* Fix up RANGE if it might eventually take us outside
- the virtual concatenation of STRING1 and STRING2. */
- if (endpos < -1)
- range = -1 - startpos;
- else if (endpos > total_size)
- range = total_size - startpos;
-
- /* If the search isn't to be a backwards one, don't waste time in a
- search for a pattern that must be anchored. */
- if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0)
- {
- if (startpos > 0)
- return -1;
- else
- range = 1;
- }
-
- /* Update the fastmap now if not correct already. */
- if (fastmap && !bufp->fastmap_accurate)
- if (re_compile_fastmap (bufp) == -2)
- return -2;
-
- /* Loop through the string, looking for a place to start matching. */
- for (;;)
- {
- /* If a fastmap is supplied, skip quickly over characters that
- cannot be the start of a match. If the pattern can match the
- null string, however, we don't need to skip characters; we want
- the first null string. */
- if (fastmap && startpos < total_size && !bufp->can_be_null)
- {
- if (range > 0) /* Searching forwards. */
- {
- register const char *d;
- register int lim = 0;
- int irange = range;
-
- if (startpos < size1 && startpos + range >= size1)
- lim = range - (size1 - startpos);
-
- d = (startpos >= size1 ? string2 - size1 : string1) + startpos;
-
- /* Written out as an if-else to avoid testing `translate'
- inside the loop. */
- if (translate)
- while (range > lim
- && !fastmap[(unsigned char)
- translate[(unsigned char) *d++]])
- range--;
- else
- while (range > lim && !fastmap[(unsigned char) *d++])
- range--;
-
- startpos += irange - range;
- }
- else /* Searching backwards. */
- {
- register char c = (size1 == 0 || startpos >= size1
- ? string2[startpos - size1]
- : string1[startpos]);
-
- if (!fastmap[(unsigned char) TRANSLATE (c)])
- goto advance;
- }
- }
-
- /* If can't match the null string, and that's all we have left, fail. */
- if (range >= 0 && startpos == total_size && fastmap
- && !bufp->can_be_null)
- return -1;
-
- val = re_match_2 (bufp, string1, size1, string2, size2,
- startpos, regs, stop);
- if (val >= 0)
- return startpos;
-
- if (val == -2)
- return -2;
-
- advance:
- if (!range)
- break;
- else if (range > 0)
- {
- range--;
- startpos++;
- }
- else
- {
- range++;
- startpos--;
- }
- }
- return -1;
-} /* re_search_2 */
-
-/* Structure for per-register (a.k.a. per-group) information.
- This must not be longer than one word, because we push this value
- onto the failure stack. Other register information, such as the
- starting and ending positions (which are addresses), and the list of
- inner groups (which is a bits list) are maintained in separate
- variables.
-
- We are making a (strictly speaking) nonportable assumption here: that
- the compiler will pack our bit fields into something that fits into
- the type of `word', i.e., is something that fits into one item on the
- failure stack. */
-
-/* Declarations and macros for re_match_2. */
-
-typedef union
-{
- fail_stack_elt_t word;
- struct
- {
- /* This field is one if this group can match the empty string,
- zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */
-#define MATCH_NULL_UNSET_VALUE 3
- unsigned match_null_string_p : 2;
- unsigned is_active : 1;
- unsigned matched_something : 1;
- unsigned ever_matched_something : 1;
- } bits;
-} register_info_type;
-
-#define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p)
-#define IS_ACTIVE(R) ((R).bits.is_active)
-#define MATCHED_SOMETHING(R) ((R).bits.matched_something)
-#define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something)
-
-static boolean group_match_null_string_p _RE_ARGS((unsigned char **p,
- unsigned char *end,
- register_info_type *reg_info));
-static boolean alt_match_null_string_p _RE_ARGS((unsigned char *p,
- unsigned char *end,
- register_info_type *reg_info));
-static boolean common_op_match_null_string_p _RE_ARGS((unsigned char **p,
- unsigned char *end,
- register_info_type *reg_info));
-static int bcmp_translate _RE_ARGS((const char *s1, const char *s2,
- int len, char *translate));
-
-/* Call this when have matched a real character; it sets `matched' flags
- for the subexpressions which we are currently inside. Also records
- that those subexprs have matched. */
-#define SET_REGS_MATCHED() \
- do \
- { \
- active_reg_t r; \
- for (r = lowest_active_reg; r <= highest_active_reg; r++) \
- { \
- MATCHED_SOMETHING (reg_info[r]) \
- = EVER_MATCHED_SOMETHING (reg_info[r]) \
- = 1; \
- } \
- } \
- while (0)
-
-
-/* This converts PTR, a pointer into one of the search strings `string1'
- and `string2' into an offset from the beginning of that string. */
-#define POINTER_TO_OFFSET(ptr) \
- (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1)
-
-/* Registers are set to a sentinel when they haven't yet matched. */
-#define REG_UNSET_VALUE ((char *) -1)
-#define REG_UNSET(e) ((e) == REG_UNSET_VALUE)
-
-
-/* Macros for dealing with the split strings in re_match_2. */
-
-#define MATCHING_IN_FIRST_STRING (dend == end_match_1)
-
-/* Call before fetching a character with *d. This switches over to
- string2 if necessary. */
-#define PREFETCH() \
- while (d == dend) \
- { \
- /* End of string2 => fail. */ \
- if (dend == end_match_2) \
- goto fail; \
- /* End of string1 => advance to string2. */ \
- d = string2; \
- dend = end_match_2; \
- }
-
-
-/* Test if at very beginning or at very end of the virtual concatenation
- of `string1' and `string2'. If only one string, it's `string2'. */
-#define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2)
-#define AT_STRINGS_END(d) ((d) == end2)
-
-
-/* Test if D points to a character which is word-constituent. We have
- two special cases to check for: if past the end of string1, look at
- the first character in string2; and if before the beginning of
- string2, look at the last character in string1. */
-#define WORDCHAR_P(d) \
- (SYNTAX ((d) == end1 ? *string2 \
- : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \
- == Sword)
-
-/* Test if the character before D and the one at D differ with respect
- to being word-constituent. */
-#define AT_WORD_BOUNDARY(d) \
- (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \
- || WORDCHAR_P (d - 1) != WORDCHAR_P (d))
-
-
-/* Free everything we malloc. */
-#ifdef REGEX_MALLOC
-#define FREE_VAR(var) if (var) free (var); var = NULL
-#define FREE_VARIABLES() \
- do { \
- FREE_VAR (fail_stack.stack); \
- FREE_VAR (regstart); \
- FREE_VAR (regend); \
- FREE_VAR (old_regstart); \
- FREE_VAR (old_regend); \
- FREE_VAR (best_regstart); \
- FREE_VAR (best_regend); \
- FREE_VAR (reg_info); \
- FREE_VAR (reg_dummy); \
- FREE_VAR (reg_info_dummy); \
- } while (0)
-#else /* not REGEX_MALLOC */
-/* Some MIPS systems (at least) want this to free alloca'd storage. */
-#define FREE_VARIABLES() alloca (0)
-#endif /* not REGEX_MALLOC */
-
-
-/* These values must meet several constraints. They must not be valid
- register values; since we have a limit of 255 registers (because
- we use only one byte in the pattern for the register number), we can
- use numbers larger than 255. They must differ by 1, because of
- NUM_FAILURE_ITEMS above. And the value for the lowest register must
- be larger than the value for the highest register, so we do not try
- to actually save any registers when none are active. */
-#define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH)
-#define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1)
-
-/* Matching routines. */
-
-#ifndef emacs /* Emacs never uses this. */
-/* re_match is like re_match_2 except it takes only a single string. */
-
-int
-re_match (bufp, string, size, pos, regs)
- struct re_pattern_buffer *bufp;
- const char *string;
- int size, pos;
- struct re_registers *regs;
- {
- return re_match_2 (bufp, NULL, 0, string, size, pos, regs, size);
-}
-#endif /* not emacs */
-
-
-/* re_match_2 matches the compiled pattern in BUFP against the
- the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1
- and SIZE2, respectively). We start matching at POS, and stop
- matching at STOP.
-
- If REGS is non-null and the `no_sub' field of BUFP is nonzero, we
- store offsets for the substring each group matched in REGS. See the
- documentation for exactly how many groups we fill.
-
- We return -1 if no match, -2 if an internal error (such as the
- failure stack overflowing). Otherwise, we return the length of the
- matched substring. */
-
-int
-re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int size1, size2;
- int pos;
- struct re_registers *regs;
- int stop;
-{
- /* General temporaries. */
- int mcnt;
- unsigned char *p1;
-
- /* Just past the end of the corresponding string. */
- const char *end1, *end2;
-
- /* Pointers into string1 and string2, just past the last characters in
- each to consider matching. */
- const char *end_match_1, *end_match_2;
-
- /* Where we are in the data, and the end of the current string. */
- const char *d, *dend;
-
- /* Where we are in the pattern, and the end of the pattern. */
- unsigned char *p = bufp->buffer;
- register unsigned char *pend = p + bufp->used;
-
- /* We use this to map every character in the string. */
- char *translate = bufp->translate;
-
- /* Failure point stack. Each place that can handle a failure further
- down the line pushes a failure point on this stack. It consists of
- restart, regend, and reg_info for all registers corresponding to
- the subexpressions we're currently inside, plus the number of such
- registers, and, finally, two char *'s. The first char * is where
- to resume scanning the pattern; the second one is where to resume
- scanning the strings. If the latter is zero, the failure point is
- a ``dummy''; if a failure happens and the failure point is a dummy,
- it gets discarded and the next next one is tried. */
- fail_stack_type fail_stack;
-#ifdef DEBUG
- static unsigned failure_id = 0;
- unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0;
-#endif
-
- /* We fill all the registers internally, independent of what we
- return, for use in backreferences. The number here includes
- an element for register zero. */
- size_t num_regs = bufp->re_nsub + 1;
-
- /* The currently active registers. */
- active_reg_t lowest_active_reg = NO_LOWEST_ACTIVE_REG;
- active_reg_t highest_active_reg = NO_HIGHEST_ACTIVE_REG;
-
- /* Information on the contents of registers. These are pointers into
- the input strings; they record just what was matched (on this
- attempt) by a subexpression part of the pattern, that is, the
- regnum-th regstart pointer points to where in the pattern we began
- matching and the regnum-th regend points to right after where we
- stopped matching the regnum-th subexpression. (The zeroth register
- keeps track of what the whole pattern matches.) */
- const char **regstart = 0, **regend = 0;
-
- /* If a group that's operated upon by a repetition operator fails to
- match anything, then the register for its start will need to be
- restored because it will have been set to wherever in the string we
- are when we last see its open-group operator. Similarly for a
- register's end. */
- const char **old_regstart = 0, **old_regend = 0;
-
- /* The is_active field of reg_info helps us keep track of which (possibly
- nested) subexpressions we are currently in. The matched_something
- field of reg_info[reg_num] helps us tell whether or not we have
- matched any of the pattern so far this time through the reg_num-th
- subexpression. These two fields get reset each time through any
- loop their register is in. */
- register_info_type *reg_info = 0;
-
- /* The following record the register info as found in the above
- variables when we find a match better than any we've seen before.
- This happens as we backtrack through the failure points, which in
- turn happens only if we have not yet matched the entire string. */
- unsigned best_regs_set = false;
- const char **best_regstart = 0, **best_regend = 0;
-
- /* Logically, this is `best_regend[0]'. But we don't want to have to
- allocate space for that if we're not allocating space for anything
- else (see below). Also, we never need info about register 0 for
- any of the other register vectors, and it seems rather a kludge to
- treat `best_regend' differently than the rest. So we keep track of
- the end of the best match so far in a separate variable. We
- initialize this to NULL so that when we backtrack the first time
- and need to test it, it's not garbage. */
- const char *match_end = NULL;
-
- /* Used when we pop values we don't care about. */
- const char **reg_dummy = 0;
- register_info_type *reg_info_dummy = 0;
-
-#ifdef DEBUG
- /* Counts the total number of registers pushed. */
- unsigned num_regs_pushed = 0;
-#endif
-
- DEBUG_PRINT1 ("\n\nEntering re_match_2.\n");
-
- INIT_FAIL_STACK ();
-
- /* Do not bother to initialize all the register variables if there are
- no groups in the pattern, as it takes a fair amount of time. If
- there are groups, we include space for register 0 (the whole
- pattern), even though we never use it, since it simplifies the
- array indexing. We should fix this. */
- if (bufp->re_nsub)
- {
- regstart = REGEX_TALLOC (num_regs, const char *);
- regend = REGEX_TALLOC (num_regs, const char *);
- old_regstart = REGEX_TALLOC (num_regs, const char *);
- old_regend = REGEX_TALLOC (num_regs, const char *);
- best_regstart = REGEX_TALLOC (num_regs, const char *);
- best_regend = REGEX_TALLOC (num_regs, const char *);
- reg_info = REGEX_TALLOC (num_regs, register_info_type);
- reg_dummy = REGEX_TALLOC (num_regs, const char *);
- reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type);
-
- if (!(regstart && regend && old_regstart && old_regend && reg_info
- && best_regstart && best_regend && reg_dummy && reg_info_dummy))
- {
- FREE_VARIABLES ();
- return -2;
- }
- }
-#ifdef REGEX_MALLOC
- else
- {
- /* We must initialize all our variables to NULL, so that
- `FREE_VARIABLES' doesn't try to free them. */
- regstart = regend = old_regstart = old_regend = best_regstart
- = best_regend = reg_dummy = NULL;
- reg_info = reg_info_dummy = (register_info_type *) NULL;
- }
-#endif /* REGEX_MALLOC */
-
- /* The starting position is bogus. */
- if (pos < 0 || pos > size1 + size2)
- {
- FREE_VARIABLES ();
- return -1;
- }
-
- /* Initialize subexpression text positions to -1 to mark ones that no
- start_memory/stop_memory has been seen for. Also initialize the
- register information struct. */
- for (mcnt = 1; mcnt < num_regs; mcnt++)
- {
- regstart[mcnt] = regend[mcnt]
- = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE;
-
- REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE;
- IS_ACTIVE (reg_info[mcnt]) = 0;
- MATCHED_SOMETHING (reg_info[mcnt]) = 0;
- EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0;
- }
-
- /* We move `string1' into `string2' if the latter's empty -- but not if
- `string1' is null. */
- if (size2 == 0 && string1 != NULL)
- {
- string2 = string1;
- size2 = size1;
- string1 = 0;
- size1 = 0;
- }
- end1 = string1 + size1;
- end2 = string2 + size2;
-
- /* Compute where to stop matching, within the two strings. */
- if (stop <= size1)
- {
- end_match_1 = string1 + stop;
- end_match_2 = string2;
- }
- else
- {
- end_match_1 = end1;
- end_match_2 = string2 + stop - size1;
- }
-
- /* `p' scans through the pattern as `d' scans through the data.
- `dend' is the end of the input string that `d' points within. `d'
- is advanced into the following input string whenever necessary, but
- this happens before fetching; therefore, at the beginning of the
- loop, `d' can be pointing at the end of a string, but it cannot
- equal `string2'. */
- if (size1 > 0 && pos <= size1)
- {
- d = string1 + pos;
- dend = end_match_1;
- }
- else
- {
- d = string2 + pos - size1;
- dend = end_match_2;
- }
-
- DEBUG_PRINT1 ("The compiled pattern is: ");
- DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend);
- DEBUG_PRINT1 ("The string to match is: `");
- DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2);
- DEBUG_PRINT1 ("'\n");
-
- /* This loops over pattern commands. It exits by returning from the
- function if the match is complete, or it drops through if the match
- fails at this starting point in the input data. */
- for (;;)
- {
- DEBUG_PRINT2 ("\n0x%x: ", p);
-
- if (p == pend)
- { /* End of pattern means we might have succeeded. */
- DEBUG_PRINT1 ("end of pattern ... ");
-
- /* If we haven't matched the entire string, and we want the
- longest match, try backtracking. */
- if (d != end_match_2)
- {
- DEBUG_PRINT1 ("backtracking.\n");
-
- if (!FAIL_STACK_EMPTY ())
- { /* More failure points to try. */
- boolean same_str_p = (FIRST_STRING_P (match_end)
- == MATCHING_IN_FIRST_STRING);
-
- /* If exceeds best match so far, save it. */
- if (!best_regs_set
- || (same_str_p && d > match_end)
- || (!same_str_p && !MATCHING_IN_FIRST_STRING))
- {
- best_regs_set = true;
- match_end = d;
-
- DEBUG_PRINT1 ("\nSAVING match as best so far.\n");
-
- for (mcnt = 1; mcnt < num_regs; mcnt++)
- {
- best_regstart[mcnt] = regstart[mcnt];
- best_regend[mcnt] = regend[mcnt];
- }
- }
- goto fail;
- }
-
- /* If no failure points, don't restore garbage. */
- else if (best_regs_set)
- {
- restore_best_regs:
- /* Restore best match. It may happen that `dend ==
- end_match_1' while the restored d is in string2.
- For example, the pattern `x.*y.*z' against the
- strings `x-' and `y-z-', if the two strings are
- not consecutive in memory. */
- DEBUG_PRINT1 ("Restoring best registers.\n");
-
- d = match_end;
- dend = ((d >= string1 && d <= end1)
- ? end_match_1 : end_match_2);
-
- for (mcnt = 1; mcnt < num_regs; mcnt++)
- {
- regstart[mcnt] = best_regstart[mcnt];
- regend[mcnt] = best_regend[mcnt];
- }
- }
- } /* d != end_match_2 */
-
- DEBUG_PRINT1 ("Accepting match.\n");
-
- /* If caller wants register contents data back, do it. */
- if (regs && !bufp->no_sub)
- {
- /* Have the register data arrays been allocated? */
- if (bufp->regs_allocated == REGS_UNALLOCATED)
- { /* No. So allocate them with malloc. We need one
- extra element beyond `num_regs' for the `-1' marker
- GNU code uses. */
- regs->num_regs = MAX (RE_NREGS, num_regs + 1);
- regs->start = TALLOC (regs->num_regs, regoff_t);
- regs->end = TALLOC (regs->num_regs, regoff_t);
- if (regs->start == NULL || regs->end == NULL)
- return -2;
- bufp->regs_allocated = REGS_REALLOCATE;
- }
- else if (bufp->regs_allocated == REGS_REALLOCATE)
- { /* Yes. If we need more elements than were already
- allocated, reallocate them. If we need fewer, just
- leave it alone. */
- if (regs->num_regs < num_regs + 1)
- {
- regs->num_regs = num_regs + 1;
- RETALLOC (regs->start, regs->num_regs, regoff_t);
- RETALLOC (regs->end, regs->num_regs, regoff_t);
- if (regs->start == NULL || regs->end == NULL)
- return -2;
- }
- }
- else
- {
- /* These braces fend off a "empty body in an else-statement"
- warning under GCC when assert expands to nothing. */
- assert (bufp->regs_allocated == REGS_FIXED);
- }
-
- /* Convert the pointer data in `regstart' and `regend' to
- indices. Register zero has to be set differently,
- since we haven't kept track of any info for it. */
- if (regs->num_regs > 0)
- {
- regs->start[0] = pos;
- regs->end[0] = (MATCHING_IN_FIRST_STRING ? d - string1
- : d - string2 + size1);
- }
-
- /* Go through the first `min (num_regs, regs->num_regs)'
- registers, since that is all we initialized. */
- for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++)
- {
- if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
- regs->start[mcnt] = regs->end[mcnt] = -1;
- else
- {
- regs->start[mcnt] = POINTER_TO_OFFSET (regstart[mcnt]);
- regs->end[mcnt] = POINTER_TO_OFFSET (regend[mcnt]);
- }
- }
-
- /* If the regs structure we return has more elements than
- were in the pattern, set the extra elements to -1. If
- we (re)allocated the registers, this is the case,
- because we always allocate enough to have at least one
- -1 at the end. */
- for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++)
- regs->start[mcnt] = regs->end[mcnt] = -1;
- } /* regs && !bufp->no_sub */
-
- FREE_VARIABLES ();
- DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n",
- nfailure_points_pushed, nfailure_points_popped,
- nfailure_points_pushed - nfailure_points_popped);
- DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed);
-
- mcnt = d - pos - (MATCHING_IN_FIRST_STRING
- ? string1
- : string2 - size1);
-
- DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt);
-
- return mcnt;
- }
-
- /* Otherwise match next pattern command. */
-#ifdef SWITCH_ENUM_BUG
- switch ((int) ((re_opcode_t) *p++))
-#else
- switch ((re_opcode_t) *p++)
-#endif
- {
- /* Ignore these. Used to ignore the n of succeed_n's which
- currently have n == 0. */
- case no_op:
- DEBUG_PRINT1 ("EXECUTING no_op.\n");
- break;
-
-
- /* Match the next n pattern characters exactly. The following
- byte in the pattern defines n, and the n bytes after that
- are the characters to match. */
- case exactn:
- mcnt = *p++;
- DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt);
-
- /* This is written out as an if-else so we don't waste time
- testing `translate' inside the loop. */
- if (translate)
- {
- do
- {
- PREFETCH ();
- if (translate[(unsigned char) *d++] != (char) *p++)
- goto fail;
- }
- while (--mcnt);
- }
- else
- {
- do
- {
- PREFETCH ();
- if (*d++ != (char) *p++) goto fail;
- }
- while (--mcnt);
- }
- SET_REGS_MATCHED ();
- break;
-
-
- /* Match any character except possibly a newline or a null. */
- case anychar:
- DEBUG_PRINT1 ("EXECUTING anychar.\n");
-
- PREFETCH ();
-
- if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n')
- || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000'))
- goto fail;
-
- SET_REGS_MATCHED ();
- DEBUG_PRINT2 (" Matched `%d'.\n", *d);
- d++;
- break;
-
-
- case charset:
- case charset_not:
- {
- register unsigned char c;
- boolean not = (re_opcode_t) *(p - 1) == charset_not;
-
- DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : "");
-
- PREFETCH ();
- c = TRANSLATE (*d); /* The character to match. */
-
- /* Cast to `unsigned' instead of `unsigned char' in case the
- bit list is a full 32 bytes long. */
- if (c < (unsigned) (*p * BYTEWIDTH)
- && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
- not = !not;
-
- p += 1 + *p;
-
- if (!not) goto fail;
-
- SET_REGS_MATCHED ();
- d++;
- break;
- }
-
-
- /* The beginning of a group is represented by start_memory.
- The arguments are the register number in the next byte, and the
- number of groups inner to this one in the next. The text
- matched within the group is recorded (in the internal
- registers data structure) under the register number. */
- case start_memory:
- DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]);
-
- /* Find out if this group can match the empty string. */
- p1 = p; /* To send to group_match_null_string_p. */
-
- if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE)
- REG_MATCH_NULL_STRING_P (reg_info[*p])
- = group_match_null_string_p (&p1, pend, reg_info);
-
- /* Save the position in the string where we were the last time
- we were at this open-group operator in case the group is
- operated upon by a repetition operator, e.g., with `(a*)*b'
- against `ab'; then we want to ignore where we are now in
- the string in case this attempt to match fails. */
- old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
- ? REG_UNSET (regstart[*p]) ? d : regstart[*p]
- : regstart[*p];
- DEBUG_PRINT2 (" old_regstart: %d\n",
- POINTER_TO_OFFSET (old_regstart[*p]));
-
- regstart[*p] = d;
- DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p]));
-
- IS_ACTIVE (reg_info[*p]) = 1;
- MATCHED_SOMETHING (reg_info[*p]) = 0;
-
- /* This is the new highest active register. */
- highest_active_reg = *p;
-
- /* If nothing was active before, this is the new lowest active
- register. */
- if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
- lowest_active_reg = *p;
-
- /* Move past the register number and inner group count. */
- p += 2;
- break;
-
-
- /* The stop_memory opcode represents the end of a group. Its
- arguments are the same as start_memory's: the register
- number, and the number of inner groups. */
- case stop_memory:
- DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]);
-
- /* We need to save the string position the last time we were at
- this close-group operator in case the group is operated
- upon by a repetition operator, e.g., with `((a*)*(b*)*)*'
- against `aba'; then we want to ignore where we are now in
- the string in case this attempt to match fails. */
- old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
- ? REG_UNSET (regend[*p]) ? d : regend[*p]
- : regend[*p];
- DEBUG_PRINT2 (" old_regend: %d\n",
- POINTER_TO_OFFSET (old_regend[*p]));
-
- regend[*p] = d;
- DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p]));
-
- /* This register isn't active anymore. */
- IS_ACTIVE (reg_info[*p]) = 0;
-
- /* If this was the only register active, nothing is active
- anymore. */
- if (lowest_active_reg == highest_active_reg)
- {
- lowest_active_reg = NO_LOWEST_ACTIVE_REG;
- highest_active_reg = NO_HIGHEST_ACTIVE_REG;
- }
- else
- { /* We must scan for the new highest active register, since
- it isn't necessarily one less than now: consider
- (a(b)c(d(e)f)g). When group 3 ends, after the f), the
- new highest active register is 1. */
- unsigned char r = *p - 1;
- while (r > 0 && !IS_ACTIVE (reg_info[r]))
- r--;
-
- /* If we end up at register zero, that means that we saved
- the registers as the result of an `on_failure_jump', not
- a `start_memory', and we jumped to past the innermost
- `stop_memory'. For example, in ((.)*) we save
- registers 1 and 2 as a result of the *, but when we pop
- back to the second ), we are at the stop_memory 1.
- Thus, nothing is active. */
- if (r == 0)
- {
- lowest_active_reg = NO_LOWEST_ACTIVE_REG;
- highest_active_reg = NO_HIGHEST_ACTIVE_REG;
- }
- else
- highest_active_reg = r;
- }
-
- /* If just failed to match something this time around with a
- group that's operated on by a repetition operator, try to
- force exit from the ``loop'', and restore the register
- information for this group that we had before trying this
- last match. */
- if ((!MATCHED_SOMETHING (reg_info[*p])
- || (re_opcode_t) p[-3] == start_memory)
- && (p + 2) < pend)
- {
- boolean is_a_jump_n = false;
-
- p1 = p + 2;
- mcnt = 0;
- switch ((re_opcode_t) *p1++)
- {
- case jump_n:
- is_a_jump_n = true;
- case pop_failure_jump:
- case maybe_pop_jump:
- case jump:
- case dummy_failure_jump:
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- if (is_a_jump_n)
- p1 += 2;
- break;
-
- default:
- /* do nothing */ ;
- }
- p1 += mcnt;
-
- /* If the next operation is a jump backwards in the pattern
- to an on_failure_jump right before the start_memory
- corresponding to this stop_memory, exit from the loop
- by forcing a failure after pushing on the stack the
- on_failure_jump's jump in the pattern, and d. */
- if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump
- && (re_opcode_t) p1[3] == start_memory && p1[4] == *p)
- {
- /* If this group ever matched anything, then restore
- what its registers were before trying this last
- failed match, e.g., with `(a*)*b' against `ab' for
- regstart[1], and, e.g., with `((a*)*(b*)*)*'
- against `aba' for regend[3].
-
- Also restore the registers for inner groups for,
- e.g., `((a*)(b*))*' against `aba' (register 3 would
- otherwise get trashed). */
-
- if (EVER_MATCHED_SOMETHING (reg_info[*p]))
- {
- unsigned r;
-
- EVER_MATCHED_SOMETHING (reg_info[*p]) = 0;
-
- /* Restore this and inner groups' (if any) registers. */
- for (r = *p; r < *p + *(p + 1); r++)
- {
- regstart[r] = old_regstart[r];
-
- /* xx why this test? */
- if ((s_reg_t) old_regend[r] >= (s_reg_t) regstart[r])
- regend[r] = old_regend[r];
- }
- }
- p1++;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- PUSH_FAILURE_POINT (p1 + mcnt, d, -2);
- PUSH_FAILURE_POINT2(p1 + mcnt, d, -2);
-
- goto fail;
- }
- }
-
- /* Move past the register number and the inner group count. */
- p += 2;
- break;
-
-
- /* \<digit> has been turned into a `duplicate' command which is
- followed by the numeric value of <digit> as the register number. */
- case duplicate:
- {
- register const char *d2, *dend2;
- int regno = *p++; /* Get which register to match against. */
- DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno);
-
- /* Can't back reference a group which we've never matched. */
- if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno]))
- goto fail;
-
- /* Where in input to try to start matching. */
- d2 = regstart[regno];
-
- /* Where to stop matching; if both the place to start and
- the place to stop matching are in the same string, then
- set to the place to stop, otherwise, for now have to use
- the end of the first string. */
-
- dend2 = ((FIRST_STRING_P (regstart[regno])
- == FIRST_STRING_P (regend[regno]))
- ? regend[regno] : end_match_1);
- for (;;)
- {
- /* If necessary, advance to next segment in register
- contents. */
- while (d2 == dend2)
- {
- if (dend2 == end_match_2) break;
- if (dend2 == regend[regno]) break;
-
- /* End of string1 => advance to string2. */
- d2 = string2;
- dend2 = regend[regno];
- }
- /* At end of register contents => success */
- if (d2 == dend2) break;
-
- /* If necessary, advance to next segment in data. */
- PREFETCH ();
-
- /* How many characters left in this segment to match. */
- mcnt = dend - d;
-
- /* Want how many consecutive characters we can match in
- one shot, so, if necessary, adjust the count. */
- if (mcnt > dend2 - d2)
- mcnt = dend2 - d2;
-
- /* Compare that many; failure if mismatch, else move
- past them. */
- if (translate
- ? bcmp_translate (d, d2, mcnt, translate)
- : bcmp (d, d2, mcnt))
- goto fail;
- d += mcnt, d2 += mcnt;
- }
- }
- break;
-
-
- /* begline matches the empty string at the beginning of the string
- (unless `not_bol' is set in `bufp'), and, if
- `newline_anchor' is set, after newlines. */
- case begline:
- DEBUG_PRINT1 ("EXECUTING begline.\n");
-
- if (AT_STRINGS_BEG (d))
- {
- if (!bufp->not_bol) break;
- }
- else if (d[-1] == '\n' && bufp->newline_anchor)
- {
- break;
- }
- /* In all other cases, we fail. */
- goto fail;
-
-
- /* endline is the dual of begline. */
- case endline:
- DEBUG_PRINT1 ("EXECUTING endline.\n");
-
- if (AT_STRINGS_END (d))
- {
- if (!bufp->not_eol) break;
- }
-
- /* We have to ``prefetch'' the next character. */
- else if ((d == end1 ? *string2 : *d) == '\n'
- && bufp->newline_anchor)
- {
- break;
- }
- goto fail;
-
-
- /* Match at the very beginning of the data. */
- case begbuf:
- DEBUG_PRINT1 ("EXECUTING begbuf.\n");
- if (AT_STRINGS_BEG (d))
- break;
- goto fail;
-
-
- /* Match at the very end of the data. */
- case endbuf:
- DEBUG_PRINT1 ("EXECUTING endbuf.\n");
- if (AT_STRINGS_END (d))
- break;
- goto fail;
-
-
- /* on_failure_keep_string_jump is used to optimize `.*\n'. It
- pushes NULL as the value for the string on the stack. Then
- `pop_failure_point' will keep the current value for the
- string, instead of restoring it. To see why, consider
- matching `foo\nbar' against `.*\n'. The .* matches the foo;
- then the . fails against the \n. But the next thing we want
- to do is match the \n against the \n; if we restored the
- string value, we would be back at the foo.
-
- Because this is used only in specific cases, we don't need to
- check all the things that `on_failure_jump' does, to make
- sure the right things get saved on the stack. Hence we don't
- share its code. The only reason to push anything on the
- stack at all is that otherwise we would have to change
- `anychar's code to do something besides goto fail in this
- case; that seems worse than this. */
- case on_failure_keep_string_jump:
- DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump");
-
- EXTRACT_NUMBER_AND_INCR (mcnt, p);
- DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt);
-
- PUSH_FAILURE_POINT (p + mcnt, NULL, -2);
- PUSH_FAILURE_POINT2(p + mcnt, NULL, -2);
- break;
-
-
- /* Uses of on_failure_jump:
-
- Each alternative starts with an on_failure_jump that points
- to the beginning of the next alternative. Each alternative
- except the last ends with a jump that in effect jumps past
- the rest of the alternatives. (They really jump to the
- ending jump of the following alternative, because tensioning
- these jumps is a hassle.)
-
- Repeats start with an on_failure_jump that points past both
- the repetition text and either the following jump or
- pop_failure_jump back to this on_failure_jump. */
- case on_failure_jump:
- on_failure:
- DEBUG_PRINT1 ("EXECUTING on_failure_jump");
-
- EXTRACT_NUMBER_AND_INCR (mcnt, p);
- DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt);
-
- /* If this on_failure_jump comes right before a group (i.e.,
- the original * applied to a group), save the information
- for that group and all inner ones, so that if we fail back
- to this point, the group's information will be correct.
- For example, in \(a*\)*\1, we need the preceding group,
- and in \(\(a*\)b*\)\2, we need the inner group. */
-
- /* We can't use `p' to check ahead because we push
- a failure point to `p + mcnt' after we do this. */
- p1 = p;
-
- /* We need to skip no_op's before we look for the
- start_memory in case this on_failure_jump is happening as
- the result of a completed succeed_n, as in \(a\)\{1,3\}b\1
- against aba. */
- while (p1 < pend && (re_opcode_t) *p1 == no_op)
- p1++;
-
- if (p1 < pend && (re_opcode_t) *p1 == start_memory)
- {
- /* We have a new highest active register now. This will
- get reset at the start_memory we are about to get to,
- but we will have saved all the registers relevant to
- this repetition op, as described above. */
- highest_active_reg = *(p1 + 1) + *(p1 + 2);
- if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
- lowest_active_reg = *(p1 + 1);
- }
-
- DEBUG_PRINT1 (":\n");
- PUSH_FAILURE_POINT (p + mcnt, d, -2);
- PUSH_FAILURE_POINT2(p + mcnt, d, -2);
- break;
-
-
- /* A smart repeat ends with `maybe_pop_jump'.
- We change it to either `pop_failure_jump' or `jump'. */
- case maybe_pop_jump:
- EXTRACT_NUMBER_AND_INCR (mcnt, p);
- DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt);
- {
- register unsigned char *p2 = p;
-
- /* Compare the beginning of the repeat with what in the
- pattern follows its end. If we can establish that there
- is nothing that they would both match, i.e., that we
- would have to backtrack because of (as in, e.g., `a*a')
- then we can change to pop_failure_jump, because we'll
- never have to backtrack.
-
- This is not true in the case of alternatives: in
- `(a|ab)*' we do need to backtrack to the `ab' alternative
- (e.g., if the string was `ab'). But instead of trying to
- detect that here, the alternative has put on a dummy
- failure point which is what we will end up popping. */
-
- /* Skip over open/close-group commands. */
- while (p2 + 2 < pend
- && ((re_opcode_t) *p2 == stop_memory
- || (re_opcode_t) *p2 == start_memory))
- p2 += 3; /* Skip over args, too. */
-
- /* If we're at the end of the pattern, we can change. */
- if (p2 == pend)
- {
- /* Consider what happens when matching ":\(.*\)"
- against ":/". I don't really understand this code
- yet. */
- p[-3] = (unsigned char) pop_failure_jump;
- DEBUG_PRINT1
- (" End of pattern: change to `pop_failure_jump'.\n");
- }
-
- else if ((re_opcode_t) *p2 == exactn
- || (bufp->newline_anchor && (re_opcode_t) *p2 == endline))
- {
- register unsigned char c
- = *p2 == (unsigned char) endline ? '\n' : p2[2];
- p1 = p + mcnt;
-
- /* p1[0] ... p1[2] are the `on_failure_jump' corresponding
- to the `maybe_finalize_jump' of this case. Examine what
- follows. */
- if ((re_opcode_t) p1[3] == exactn && p1[5] != c)
- {
- p[-3] = (unsigned char) pop_failure_jump;
- DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n",
- c, p1[5]);
- }
-
- else if ((re_opcode_t) p1[3] == charset
- || (re_opcode_t) p1[3] == charset_not)
- {
- int not = (re_opcode_t) p1[3] == charset_not;
-
- if (c < (unsigned char) (p1[4] * BYTEWIDTH)
- && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
- not = !not;
-
- /* `not' is equal to 1 if c would match, which means
- that we can't change to pop_failure_jump. */
- if (!not)
- {
- p[-3] = (unsigned char) pop_failure_jump;
- DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
- }
- }
- }
- }
- p -= 2; /* Point at relative address again. */
- if ((re_opcode_t) p[-1] != pop_failure_jump)
- {
- p[-1] = (unsigned char) jump;
- DEBUG_PRINT1 (" Match => jump.\n");
- goto unconditional_jump;
- }
- /* Note fall through. */
-
-
- /* The end of a simple repeat has a pop_failure_jump back to
- its matching on_failure_jump, where the latter will push a
- failure point. The pop_failure_jump takes off failure
- points put on by this pop_failure_jump's matching
- on_failure_jump; we got through the pattern to here from the
- matching on_failure_jump, so didn't fail. */
- case pop_failure_jump:
- {
- /* We need to pass separate storage for the lowest and
- highest registers, even though we don't care about the
- actual values. Otherwise, we will restore only one
- register from the stack, since lowest will == highest in
- `pop_failure_point'. */
- active_reg_t dummy_low_reg, dummy_high_reg;
- unsigned char *pdummy;
- const char *sdummy;
-
- DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n");
- POP_FAILURE_POINT (sdummy, pdummy,
- dummy_low_reg, dummy_high_reg,
- reg_dummy, reg_dummy, reg_info_dummy);
- }
- /* Note fall through. */
-
-
- /* Unconditionally jump (without popping any failure points). */
- case jump:
- unconditional_jump:
- EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */
- DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt);
- p += mcnt; /* Do the jump. */
- DEBUG_PRINT2 ("(to 0x%x).\n", p);
- break;
-
-
- /* We need this opcode so we can detect where alternatives end
- in `group_match_null_string_p' et al. */
- case jump_past_alt:
- DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n");
- goto unconditional_jump;
-
-
- /* Normally, the on_failure_jump pushes a failure point, which
- then gets popped at pop_failure_jump. We will end up at
- pop_failure_jump, also, and with a pattern of, say, `a+', we
- are skipping over the on_failure_jump, so we have to push
- something meaningless for pop_failure_jump to pop. */
- case dummy_failure_jump:
- DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n");
- /* It doesn't matter what we push for the string here. What
- the code at `fail' tests is the value for the pattern. */
- PUSH_FAILURE_POINT (0, 0, -2);
- PUSH_FAILURE_POINT2(0, 0, -2);
- goto unconditional_jump;
-
-
- /* At the end of an alternative, we need to push a dummy failure
- point in case we are followed by a `pop_failure_jump', because
- we don't want the failure point for the alternative to be
- popped. For example, matching `(a|ab)*' against `aab'
- requires that we match the `ab' alternative. */
- case push_dummy_failure:
- DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n");
- /* See comments just above at `dummy_failure_jump' about the
- two zeroes. */
- PUSH_FAILURE_POINT (0, 0, -2);
- PUSH_FAILURE_POINT2(0, 0, -2);
- break;
-
- /* Have to succeed matching what follows at least n times.
- After that, handle like `on_failure_jump'. */
- case succeed_n:
- EXTRACT_NUMBER (mcnt, p + 2);
- DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt);
-
- assert (mcnt >= 0);
- /* Originally, this is how many times we HAVE to succeed. */
- if (mcnt > 0)
- {
- mcnt--;
- p += 2;
- STORE_NUMBER_AND_INCR (p, mcnt);
- DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p, mcnt);
- }
- else if (mcnt == 0)
- {
- DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2);
- p[2] = (unsigned char) no_op;
- p[3] = (unsigned char) no_op;
- goto on_failure;
- }
- break;
-
- case jump_n:
- EXTRACT_NUMBER (mcnt, p + 2);
- DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt);
-
- /* Originally, this is how many times we CAN jump. */
- if (mcnt)
- {
- mcnt--;
- STORE_NUMBER (p + 2, mcnt);
- goto unconditional_jump;
- }
- /* If don't have to jump any more, skip over the rest of command. */
- else
- p += 4;
- break;
-
- case set_number_at:
- {
- DEBUG_PRINT1 ("EXECUTING set_number_at.\n");
-
- EXTRACT_NUMBER_AND_INCR (mcnt, p);
- p1 = p + mcnt;
- EXTRACT_NUMBER_AND_INCR (mcnt, p);
- DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt);
- STORE_NUMBER (p1, mcnt);
- break;
- }
-
- case wordbound:
- DEBUG_PRINT1 ("EXECUTING wordbound.\n");
- if (AT_WORD_BOUNDARY (d))
- break;
- goto fail;
-
- case notwordbound:
- DEBUG_PRINT1 ("EXECUTING notwordbound.\n");
- if (AT_WORD_BOUNDARY (d))
- goto fail;
- break;
-
- case wordbeg:
- DEBUG_PRINT1 ("EXECUTING wordbeg.\n");
- if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1)))
- break;
- goto fail;
-
- case wordend:
- DEBUG_PRINT1 ("EXECUTING wordend.\n");
- if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1)
- && (!WORDCHAR_P (d) || AT_STRINGS_END (d)))
- break;
- goto fail;
-
-#ifdef emacs
-#ifdef emacs19
- case before_dot:
- DEBUG_PRINT1 ("EXECUTING before_dot.\n");
- if (PTR_CHAR_POS ((unsigned char *) d) >= point)
- goto fail;
- break;
-
- case at_dot:
- DEBUG_PRINT1 ("EXECUTING at_dot.\n");
- if (PTR_CHAR_POS ((unsigned char *) d) != point)
- goto fail;
- break;
-
- case after_dot:
- DEBUG_PRINT1 ("EXECUTING after_dot.\n");
- if (PTR_CHAR_POS ((unsigned char *) d) <= point)
- goto fail;
- break;
-#else /* not emacs19 */
- case at_dot:
- DEBUG_PRINT1 ("EXECUTING at_dot.\n");
- if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point)
- goto fail;
- break;
-#endif /* not emacs19 */
-
- case syntaxspec:
- DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt);
- mcnt = *p++;
- goto matchsyntax;
-
- case wordchar:
- DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n");
- mcnt = (int) Sword;
- matchsyntax:
- PREFETCH ();
- if (SYNTAX (*d++) != (enum syntaxcode) mcnt)
- goto fail;
- SET_REGS_MATCHED ();
- break;
-
- case notsyntaxspec:
- DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt);
- mcnt = *p++;
- goto matchnotsyntax;
-
- case notwordchar:
- DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n");
- mcnt = (int) Sword;
- matchnotsyntax:
- PREFETCH ();
- if (SYNTAX (*d++) == (enum syntaxcode) mcnt)
- goto fail;
- SET_REGS_MATCHED ();
- break;
-
-#else /* not emacs */
- case wordchar:
- DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n");
- PREFETCH ();
- if (!WORDCHAR_P (d))
- goto fail;
- SET_REGS_MATCHED ();
- d++;
- break;
-
- case notwordchar:
- DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n");
- PREFETCH ();
- if (WORDCHAR_P (d))
- goto fail;
- SET_REGS_MATCHED ();
- d++;
- break;
-#endif /* not emacs */
-
- default:
- abort ();
- }
- continue; /* Successfully executed one pattern command; keep going. */
-
-
- /* We goto here if a matching operation fails. */
- fail:
- if (!FAIL_STACK_EMPTY ())
- { /* A restart point is known. Restore to that state. */
- DEBUG_PRINT1 ("\nFAIL:\n");
- POP_FAILURE_POINT (d, p,
- lowest_active_reg, highest_active_reg,
- regstart, regend, reg_info);
-
- /* If this failure point is a dummy, try the next one. */
- if (!p)
- goto fail;
-
- /* If we failed to the end of the pattern, don't examine *p. */
- assert (p <= pend);
- if (p < pend)
- {
- boolean is_a_jump_n = false;
-
- /* If failed to a backwards jump that's part of a repetition
- loop, need to pop this failure point and use the next one. */
- switch ((re_opcode_t) *p)
- {
- case jump_n:
- is_a_jump_n = true;
- case maybe_pop_jump:
- case pop_failure_jump:
- case jump:
- p1 = p + 1;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- p1 += mcnt;
-
- if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n)
- || (!is_a_jump_n
- && (re_opcode_t) *p1 == on_failure_jump))
- goto fail;
- break;
- default:
- /* do nothing */ ;
- }
- }
-
- if (d >= string1 && d <= end1)
- dend = end_match_1;
- }
- else
- break; /* Matching at this starting point really fails. */
- } /* for (;;) */
-
- if (best_regs_set)
- goto restore_best_regs;
-
- FREE_VARIABLES ();
-
- return -1; /* Failure to match. */
-} /* re_match_2 */
-
-/* Subroutine definitions for re_match_2. */
-
-
-/* We are passed P pointing to a register number after a start_memory.
-
- Return true if the pattern up to the corresponding stop_memory can
- match the empty string, and false otherwise.
-
- If we find the matching stop_memory, sets P to point to one past its number.
- Otherwise, sets P to an undefined byte less than or equal to END.
-
- We don't handle duplicates properly (yet). */
-
-static boolean
-group_match_null_string_p (p, end, reg_info)
- unsigned char **p, *end;
- register_info_type *reg_info;
-{
- int mcnt;
- /* Point to after the args to the start_memory. */
- unsigned char *p1 = *p + 2;
-
- while (p1 < end)
- {
- /* Skip over opcodes that can match nothing, and return true or
- false, as appropriate, when we get to one that can't, or to the
- matching stop_memory. */
-
- switch ((re_opcode_t) *p1)
- {
- /* Could be either a loop or a series of alternatives. */
- case on_failure_jump:
- p1++;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
-
- /* If the next operation is not a jump backwards in the
- pattern. */
-
- if (mcnt >= 0)
- {
- /* Go through the on_failure_jumps of the alternatives,
- seeing if any of the alternatives cannot match nothing.
- The last alternative starts with only a jump,
- whereas the rest start with on_failure_jump and end
- with a jump, e.g., here is the pattern for `a|b|c':
-
- /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6
- /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3
- /exactn/1/c
-
- So, we have to first go through the first (n-1)
- alternatives and then deal with the last one separately. */
-
-
- /* Deal with the first (n-1) alternatives, which start
- with an on_failure_jump (see above) that jumps to right
- past a jump_past_alt. */
-
- while ((re_opcode_t) p1[mcnt-3] == jump_past_alt)
- {
- /* `mcnt' holds how many bytes long the alternative
- is, including the ending `jump_past_alt' and
- its number. */
-
- if (!alt_match_null_string_p (p1, p1 + mcnt - 3,
- reg_info))
- return false;
-
- /* Move to right after this alternative, including the
- jump_past_alt. */
- p1 += mcnt;
-
- /* Break if it's the beginning of an n-th alternative
- that doesn't begin with an on_failure_jump. */
- if ((re_opcode_t) *p1 != on_failure_jump)
- break;
-
- /* Still have to check that it's not an n-th
- alternative that starts with an on_failure_jump. */
- p1++;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- if ((re_opcode_t) p1[mcnt-3] != jump_past_alt)
- {
- /* Get to the beginning of the n-th alternative. */
- p1 -= 3;
- break;
- }
- }
-
- /* Deal with the last alternative: go back and get number
- of the `jump_past_alt' just before it. `mcnt' contains
- the length of the alternative. */
- EXTRACT_NUMBER (mcnt, p1 - 2);
-
- if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info))
- return false;
-
- p1 += mcnt; /* Get past the n-th alternative. */
- } /* if mcnt > 0 */
- break;
-
-
- case stop_memory:
- assert (p1[1] == **p);
- *p = p1 + 2;
- return true;
-
-
- default:
- if (!common_op_match_null_string_p (&p1, end, reg_info))
- return false;
- }
- } /* while p1 < end */
-
- return false;
-} /* group_match_null_string_p */
-
-
-/* Similar to group_match_null_string_p, but doesn't deal with alternatives:
- It expects P to be the first byte of a single alternative and END one
- byte past the last. The alternative can contain groups. */
-
-static boolean
-alt_match_null_string_p (p, end, reg_info)
- unsigned char *p, *end;
- register_info_type *reg_info;
-{
- int mcnt;
- unsigned char *p1 = p;
-
- while (p1 < end)
- {
- /* Skip over opcodes that can match nothing, and break when we get
- to one that can't. */
-
- switch ((re_opcode_t) *p1)
- {
- /* It's a loop. */
- case on_failure_jump:
- p1++;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- p1 += mcnt;
- break;
-
- default:
- if (!common_op_match_null_string_p (&p1, end, reg_info))
- return false;
- }
- } /* while p1 < end */
-
- return true;
-} /* alt_match_null_string_p */
-
-
-/* Deals with the ops common to group_match_null_string_p and
- alt_match_null_string_p.
-
- Sets P to one after the op and its arguments, if any. */
-
-static boolean
-common_op_match_null_string_p (p, end, reg_info)
- unsigned char **p, *end;
- register_info_type *reg_info;
-{
- int mcnt;
- boolean ret;
- int reg_no;
- unsigned char *p1 = *p;
-
- switch ((re_opcode_t) *p1++)
- {
- case no_op:
- case begline:
- case endline:
- case begbuf:
- case endbuf:
- case wordbeg:
- case wordend:
- case wordbound:
- case notwordbound:
-#ifdef emacs
- case before_dot:
- case at_dot:
- case after_dot:
-#endif
- break;
-
- case start_memory:
- reg_no = *p1;
- assert (reg_no > 0 && reg_no <= MAX_REGNUM);
- ret = group_match_null_string_p (&p1, end, reg_info);
-
- /* Have to set this here in case we're checking a group which
- contains a group and a back reference to it. */
-
- if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE)
- REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret;
-
- if (!ret)
- return false;
- break;
-
- /* If this is an optimized succeed_n for zero times, make the jump. */
- case jump:
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- if (mcnt >= 0)
- p1 += mcnt;
- else
- return false;
- break;
-
- case succeed_n:
- /* Get to the number of times to succeed. */
- p1 += 2;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
-
- if (mcnt == 0)
- {
- p1 -= 4;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- p1 += mcnt;
- }
- else
- return false;
- break;
-
- case duplicate:
- if (!REG_MATCH_NULL_STRING_P (reg_info[*p1]))
- return false;
- break;
-
- case set_number_at:
- p1 += 4;
-
- default:
- /* All other opcodes mean we cannot match the empty string. */
- return false;
- }
-
- *p = p1;
- return true;
-} /* common_op_match_null_string_p */
-
-
-/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN
- bytes; nonzero otherwise. */
-
-static int
-bcmp_translate (s1, s2, len, translate)
- const char *s1, *s2;
- register int len;
- char *translate;
-{
- register const unsigned char *p1 = (const unsigned char *) s1,
- *p2 = (const unsigned char *) s2;
- while (len)
- {
- if (translate[*p1++] != translate[*p2++]) return 1;
- len--;
- }
- return 0;
-}
-
-/* Entry points for GNU code. */
-
-/* re_compile_pattern is the GNU regular expression compiler: it
- compiles PATTERN (of length SIZE) and puts the result in BUFP.
- Returns 0 if the pattern was valid, otherwise an error string.
-
- Assumes the `allocated' (and perhaps `buffer') and `translate' fields
- are set in BUFP on entry.
-
- We call regex_compile to do the actual compilation. */
-
-const char *
-re_compile_pattern (pattern, length, bufp)
- const char *pattern;
- size_t length;
- struct re_pattern_buffer *bufp;
-{
- reg_errcode_t ret;
-
- /* GNU code is written to assume at least RE_NREGS registers will be set
- (and at least one extra will be -1). */
- bufp->regs_allocated = REGS_UNALLOCATED;
-
- /* And GNU code determines whether or not to get register information
- by passing null for the REGS argument to re_match, etc., not by
- setting no_sub. */
- bufp->no_sub = 0;
-
- /* Match anchors at newline. */
- bufp->newline_anchor = 1;
-
- ret = regex_compile (pattern, length, re_syntax_options, bufp);
-
- return re_error_msg[(int) ret];
-}
-
-/* Entry points compatible with 4.2 BSD regex library. We don't define
- them if this is an Emacs or POSIX compilation. */
-
-#if !defined (emacs) && !defined (_POSIX_SOURCE)
-
-/* BSD has one and only one pattern buffer. */
-static struct re_pattern_buffer re_comp_buf;
-
-char *
-re_comp (s)
- const char *s;
-{
- reg_errcode_t ret;
-
- if (!s)
- {
- if (!re_comp_buf.buffer)
- return "No previous regular expression";
- return 0;
- }
-
- if (!re_comp_buf.buffer)
- {
- re_comp_buf.buffer = (unsigned char *) malloc (200);
- if (re_comp_buf.buffer == NULL)
- return "Memory exhausted";
- re_comp_buf.allocated = 200;
-
- re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
- if (re_comp_buf.fastmap == NULL)
- return "Memory exhausted";
- }
-
- /* Since `re_exec' always passes NULL for the `regs' argument, we
- don't need to initialize the pattern buffer fields which affect it. */
-
- /* Match anchors at newlines. */
- re_comp_buf.newline_anchor = 1;
-
- ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf);
-
- /* Yes, we're discarding `const' here. */
- return (char *) re_error_msg[(int) ret];
-}
-
-
-int
-re_exec (s)
- const char *s;
-{
- const int len = strlen (s);
- return
- 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0);
-}
-#endif /* not emacs and not _POSIX_SOURCE */
-
-/* POSIX.2 functions. Don't define these for Emacs. */
-
-#ifndef emacs
-#if !NO_POSIX_COMPAT
-
-/* regcomp takes a regular expression as a string and compiles it.
-
- PREG is a regex_t *. We do not expect any fields to be initialized,
- since POSIX says we shouldn't. Thus, we set
-
- `buffer' to the compiled pattern;
- `used' to the length of the compiled pattern;
- `syntax' to RE_SYNTAX_POSIX_EXTENDED if the
- REG_EXTENDED bit in CFLAGS is set; otherwise, to
- RE_SYNTAX_POSIX_BASIC;
- `newline_anchor' to REG_NEWLINE being set in CFLAGS;
- `fastmap' and `fastmap_accurate' to zero;
- `re_nsub' to the number of subexpressions in PATTERN.
-
- PATTERN is the address of the pattern string.
-
- CFLAGS is a series of bits which affect compilation.
-
- If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we
- use POSIX basic syntax.
-
- If REG_NEWLINE is set, then . and [^...] don't match newline.
- Also, regexec will try a match beginning after every newline.
-
- If REG_ICASE is set, then we considers upper- and lowercase
- versions of letters to be equivalent when matching.
-
- If REG_NOSUB is set, then when PREG is passed to regexec, that
- routine will report only success or failure, and nothing about the
- registers.
-
- It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for
- the return codes and their meanings.) */
-
-int
-regcomp (preg, pattern, cflags)
- regex_t *preg;
- const char *pattern;
- int cflags;
-{
- reg_errcode_t ret;
- reg_syntax_t syntax
- = (cflags & REG_EXTENDED) ?
- RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
-
- /* regex_compile will allocate the space for the compiled pattern. */
- preg->buffer = 0;
- preg->allocated = 0;
- preg->used = 0;
-
- /* Don't bother to use a fastmap when searching. This simplifies the
- REG_NEWLINE case: if we used a fastmap, we'd have to put all the
- characters after newlines into the fastmap. This way, we just try
- every character. */
- preg->fastmap = 0;
-
- if (cflags & REG_ICASE)
- {
- unsigned i;
-
- preg->translate = (char *) malloc (CHAR_SET_SIZE);
- if (preg->translate == NULL)
- return (int) REG_ESPACE;
-
- /* Map uppercase characters to corresponding lowercase ones. */
- for (i = 0; i < CHAR_SET_SIZE; i++)
- preg->translate[i] = ISUPPER (i) ? tolower (i) : i;
- }
- else
- preg->translate = NULL;
-
- /* If REG_NEWLINE is set, newlines are treated differently. */
- if (cflags & REG_NEWLINE)
- { /* REG_NEWLINE implies neither . nor [^...] match newline. */
- syntax &= ~RE_DOT_NEWLINE;
- syntax |= RE_HAT_LISTS_NOT_NEWLINE;
- /* It also changes the matching behavior. */
- preg->newline_anchor = 1;
- }
- else
- preg->newline_anchor = 0;
-
- preg->no_sub = !!(cflags & REG_NOSUB);
-
- /* POSIX says a null character in the pattern terminates it, so we
- can use strlen here in compiling the pattern. */
- ret = regex_compile (pattern, strlen (pattern), syntax, preg);
-
- /* POSIX doesn't distinguish between an unmatched open-group and an
- unmatched close-group: both are REG_EPAREN. */
- if (ret == REG_ERPAREN) ret = REG_EPAREN;
-
- return (int) ret;
-}
-
-
-/* regexec searches for a given pattern, specified by PREG, in the
- string STRING.
-
- If NMATCH is zero or REG_NOSUB was set in the cflags argument to
- `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at
- least NMATCH elements, and we set them to the offsets of the
- corresponding matched substrings.
-
- EFLAGS specifies `execution flags' which affect matching: if
- REG_NOTBOL is set, then ^ does not match at the beginning of the
- string; if REG_NOTEOL is set, then $ does not match at the end.
-
- We return 0 if we find a match and REG_NOMATCH if not. */
-
-int
-regexec (preg, string, nmatch, pmatch, eflags)
- const regex_t *preg;
- const char *string;
- size_t nmatch;
- regmatch_t pmatch[];
- int eflags;
-{
- int ret;
- struct re_registers regs;
- regex_t private_preg;
- int len = strlen (string);
- boolean want_reg_info = !preg->no_sub && nmatch > 0;
-
- private_preg = *preg;
-
- private_preg.not_bol = !!(eflags & REG_NOTBOL);
- private_preg.not_eol = !!(eflags & REG_NOTEOL);
-
- /* The user has told us exactly how many registers to return
- information about, via `nmatch'. We have to pass that on to the
- matching routines. */
- private_preg.regs_allocated = REGS_FIXED;
-
- if (want_reg_info)
- {
- regs.num_regs = nmatch;
- regs.start = TALLOC (nmatch, regoff_t);
- regs.end = TALLOC (nmatch, regoff_t);
- if (regs.start == NULL || regs.end == NULL)
- return (int) REG_NOMATCH;
- }
-
- /* Perform the searching operation. */
- ret = re_search (&private_preg, string, len,
- /* start: */ 0, /* range: */ len,
- want_reg_info ? &regs : (struct re_registers *) 0);
-
- /* Copy the register information to the POSIX structure. */
- if (want_reg_info)
- {
- if (ret >= 0)
- {
- unsigned r;
-
- for (r = 0; r < nmatch; r++)
- {
- pmatch[r].rm_so = regs.start[r];
- pmatch[r].rm_eo = regs.end[r];
- }
- }
-
- /* If we needed the temporary register info, free the space now. */
- free (regs.start);
- free (regs.end);
- }
-
- /* We want zero return to mean success, unlike `re_search'. */
- return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
-}
-
-
-/* Returns a message corresponding to an error code, ERRCODE, returned
- from either regcomp or regexec. We don't use PREG here. */
-
-size_t
-regerror (errcode, preg, errbuf, errbuf_size)
- int errcode;
- const regex_t *preg;
- char *errbuf;
- size_t errbuf_size;
-{
- const char *msg;
- size_t msg_size;
-
- if (errcode < 0
- || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0])))
- /* Only error codes returned by the rest of the code should be passed
- to this routine. If we are given anything else, or if other regex
- code generates an invalid error code, then the program has a bug.
- Dump core so we can fix it. */
- abort ();
-
- msg = re_error_msg[errcode];
-
- /* POSIX doesn't require that we do anything in this case, but why
- not be nice. */
- if (! msg)
- msg = "Success";
-
- msg_size = strlen (msg) + 1; /* Includes the null. */
-
- if (errbuf_size != 0)
- {
- if (msg_size > errbuf_size)
- {
- strncpy (errbuf, msg, errbuf_size - 1);
- errbuf[errbuf_size - 1] = 0;
- }
- else
- strcpy (errbuf, msg);
- }
-
- return msg_size;
-}
-
-
-/* Free dynamically allocated space used by PREG. */
-
-void
-regfree (preg)
- regex_t *preg;
-{
- if (preg->buffer != NULL)
- free (preg->buffer);
- preg->buffer = NULL;
-
- preg->allocated = 0;
- preg->used = 0;
-
- if (preg->fastmap != NULL)
- free (preg->fastmap);
- preg->fastmap = NULL;
- preg->fastmap_accurate = 0;
-
- if (preg->translate != NULL)
- free (preg->translate);
- preg->translate = NULL;
-}
-
-#endif /* !NO_POSIX_COMPAT */
-#endif /* not emacs */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/lib/libregex/regex.h b/gnu/lib/libregex/regex.h
deleted file mode 100644
index e42c810..0000000
--- a/gnu/lib/libregex/regex.h
+++ /dev/null
@@ -1,517 +0,0 @@
-/* Definitions for data structures and routines for the regular
- expression library, version 0.12.
-
- Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 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. */
-
-#ifndef __REGEXP_LIBRARY_H__
-#define __REGEXP_LIBRARY_H__
-
-/* Allow the use in C++ code. */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* POSIX says that <sys/types.h> must be included (by the caller) before
- <regex.h>. */
-
-#ifdef VMS
-/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
- should be there. */
-#include <stddef.h>
-#endif
-
-
-/* The following two types have to be signed and unsigned integer type
- wide enough to hold a value of a pointer. For most ANSI compilers
- ptrdiff_t and size_t should be likely OK. Still size of these two
- types is 2 for Microsoft C. Ugh... */
-typedef long s_reg_t;
-typedef unsigned long active_reg_t;
-
-/* The following bits are used to determine the regexp syntax we
- recognize. The set/not-set meanings are chosen so that Emacs syntax
- remains the value 0. The bits are given in alphabetical order, and
- the definitions shifted by one from the previous bit; thus, when we
- add or remove a bit, only one other definition need change. */
-typedef unsigned long reg_syntax_t;
-
-/* If this bit is not set, then \ inside a bracket expression is literal.
- If set, then such a \ quotes the following character. */
-#define RE_BACKSLASH_ESCAPE_IN_LISTS (1L)
-
-/* If this bit is not set, then + and ? are operators, and \+ and \? are
- literals.
- If set, then \+ and \? are operators and + and ? are literals. */
-#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
-
-/* If this bit is set, then character classes are supported. They are:
- [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
- [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
- If not set, then character classes are not supported. */
-#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
-
-/* If this bit is set, then ^ and $ are always anchors (outside bracket
- expressions, of course).
- If this bit is not set, then it depends:
- ^ is an anchor if it is at the beginning of a regular
- expression or after an open-group or an alternation operator;
- $ is an anchor if it is at the end of a regular expression, or
- before a close-group or an alternation operator.
-
- This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
- POSIX draft 11.2 says that * etc. in leading positions is undefined.
- We already implemented a previous draft which made those constructs
- invalid, though, so we haven't changed the code back. */
-#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
-
-/* If this bit is set, then special characters are always special
- regardless of where they are in the pattern.
- If this bit is not set, then special characters are special only in
- some contexts; otherwise they are ordinary. Specifically,
- * + ? and intervals are only special when not after the beginning,
- open-group, or alternation operator. */
-#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
-
-/* If this bit is set, then *, +, ?, and { cannot be first in an re or
- immediately after an alternation or begin-group operator. */
-#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
-
-/* If this bit is set, then . matches newline.
- If not set, then it doesn't. */
-#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
-
-/* If this bit is set, then . doesn't match NUL.
- If not set, then it does. */
-#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
-
-/* If this bit is set, nonmatching lists [^...] do not match newline.
- If not set, they do. */
-#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
-
-/* If this bit is set, either \{...\} or {...} defines an
- interval, depending on RE_NO_BK_BRACES.
- If not set, \{, \}, {, and } are literals. */
-#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
-
-/* If this bit is set, +, ? and | aren't recognized as operators.
- If not set, they are. */
-#define RE_LIMITED_OPS (RE_INTERVALS << 1)
-
-/* If this bit is set, newline is an alternation operator.
- If not set, newline is literal. */
-#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
-
-/* If this bit is set, then `{...}' defines an interval, and \{ and \}
- are literals.
- If not set, then `\{...\}' defines an interval. */
-#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
-
-/* If this bit is set, (...) defines a group, and \( and \) are literals.
- If not set, \(...\) defines a group, and ( and ) are literals. */
-#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
-
-/* If this bit is set, then \<digit> matches <digit>.
- If not set, then \<digit> is a back-reference. */
-#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
-
-/* If this bit is set, then | is an alternation operator, and \| is literal.
- If not set, then \| is an alternation operator, and | is literal. */
-#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
-
-/* If this bit is set, then an ending range point collating higher
- than the starting range point, as in [z-a], is invalid.
- If not set, then when ending range point collates higher than the
- starting range point, the range is ignored. */
-#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
-
-/* If this bit is set, then an unmatched ) is ordinary.
- If not set, then an unmatched ) is invalid. */
-#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
-
-/* If this bit is set, do not process the GNU regex operators.
- IF not set, then the GNU regex operators are recognized. */
-#define RE_NO_GNU_OPS (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
-
-/* This global variable defines the particular regexp syntax to use (for
- some interfaces). When a regexp is compiled, the syntax used is
- stored in the pattern buffer, so changing this does not affect
- already-compiled regexps. */
-extern reg_syntax_t re_syntax_options;
-
-/* Define combinations of the above bits for the standard possibilities.
- (The [[[ comments delimit what gets put into the Texinfo file, so
- don't delete them!) */
-/* [[[begin syntaxes]]] */
-#define RE_SYNTAX_EMACS 0
-
-#define RE_SYNTAX_AWK \
- (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
- | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
- | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
-
-#define RE_SYNTAX_GNU_AWK \
- ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) \
- & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
-
-#define RE_SYNTAX_POSIX_AWK \
- (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
- | RE_INTERVALS | RE_NO_GNU_OPS)
-
-#define RE_SYNTAX_GREP \
- (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
- | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
- | RE_NEWLINE_ALT)
-
-#define RE_SYNTAX_EGREP \
- (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
- | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
- | RE_NO_BK_VBAR)
-
-#define RE_SYNTAX_POSIX_EGREP \
- (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
-
-/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
-#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
-
-#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
-
-/* Syntax bits common to both basic and extended POSIX regex syntax. */
-#define _RE_SYNTAX_POSIX_COMMON \
- (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
- | RE_INTERVALS | RE_NO_EMPTY_RANGES)
-
-#define RE_SYNTAX_POSIX_BASIC \
- (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
-
-/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
- RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
- isn't minimal, since other operators, such as \`, aren't disabled. */
-#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
- (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
-
-#define RE_SYNTAX_POSIX_EXTENDED \
- (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- | RE_UNMATCHED_RIGHT_PAREN_ORD)
-
-/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS
- replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */
-#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
- (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
-/* [[[end syntaxes]]] */
-
-/* Maximum number of duplicates an interval can allow. Some systems
- (erroneously) define this in other header files, but we want our
- value, so remove any previous define. */
-#ifdef RE_DUP_MAX
-#undef RE_DUP_MAX
-#endif
-/* if sizeof(int) == 2, then ((1 << 15) - 1) overflows */
-#define RE_DUP_MAX (0x7fff)
-
-
-/* POSIX `cflags' bits (i.e., information for `regcomp'). */
-
-/* If this bit is set, then use extended regular expression syntax.
- If not set, then use basic regular expression syntax. */
-#define REG_EXTENDED 1
-
-/* If this bit is set, then ignore case when matching.
- If not set, then case is significant. */
-#define REG_ICASE (REG_EXTENDED << 1)
-
-/* If this bit is set, then anchors do not match at newline
- characters in the string.
- If not set, then anchors do match at newlines. */
-#define REG_NEWLINE (REG_ICASE << 1)
-
-/* If this bit is set, then report only success or fail in regexec.
- If not set, then returns differ between not matching and errors. */
-#define REG_NOSUB (REG_NEWLINE << 1)
-
-
-/* POSIX `eflags' bits (i.e., information for regexec). */
-
-/* If this bit is set, then the beginning-of-line operator doesn't match
- the beginning of the string (presumably because it's not the
- beginning of a line).
- If not set, then the beginning-of-line operator does match the
- beginning of the string. */
-#define REG_NOTBOL 1
-
-/* Like REG_NOTBOL, except for the end-of-line. */
-#define REG_NOTEOL (1 << 1)
-
-
-/* If any error codes are removed, changed, or added, update the
- `re_error_msg' table in regex.c. */
-typedef enum
-{
- REG_NOERROR = 0, /* Success. */
- REG_NOMATCH, /* Didn't find a match (for regexec). */
-
- /* POSIX regcomp return error codes. (In the order listed in the
- standard.) */
- REG_BADPAT, /* Invalid pattern. */
- REG_ECOLLATE, /* Not implemented. */
- REG_ECTYPE, /* Invalid character class name. */
- REG_EESCAPE, /* Trailing backslash. */
- REG_ESUBREG, /* Invalid back reference. */
- REG_EBRACK, /* Unmatched left bracket. */
- REG_EPAREN, /* Parenthesis imbalance. */
- REG_EBRACE, /* Unmatched \{. */
- REG_BADBR, /* Invalid contents of \{\}. */
- REG_ERANGE, /* Invalid range end. */
- REG_ESPACE, /* Ran out of memory. */
- REG_BADRPT, /* No preceding re for repetition op. */
-
- /* Error codes we've added. */
- REG_EEND, /* Premature end. */
- REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
- REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
-} reg_errcode_t;
-
-/* This data structure represents a compiled pattern. Before calling
- the pattern compiler, the fields `buffer', `allocated', `fastmap',
- `translate', and `no_sub' can be set. After the pattern has been
- compiled, the `re_nsub' field is available. All other fields are
- private to the regex routines. */
-
-struct re_pattern_buffer
-{
-/* [[[begin pattern_buffer]]] */
- /* Space that holds the compiled pattern. It is declared as
- `unsigned char *' because its elements are
- sometimes used as array indexes. */
- unsigned char *buffer;
-
- /* Number of bytes to which `buffer' points. */
- unsigned long allocated;
-
- /* Number of bytes actually used in `buffer'. */
- unsigned long used;
-
- /* Syntax setting with which the pattern was compiled. */
- reg_syntax_t syntax;
-
- /* Pointer to a fastmap, if any, otherwise zero. re_search uses
- the fastmap, if there is one, to skip over impossible
- starting points for matches. */
- char *fastmap;
-
- /* Either a translate table to apply to all characters before
- comparing them, or zero for no translation. The translation
- is applied to a pattern when it is compiled and to a string
- when it is matched. */
- char *translate;
-
- /* Number of subexpressions found by the compiler. */
- size_t re_nsub;
-
- /* Zero if this pattern cannot match the empty string, one else.
- Well, in truth it's used only in `re_search_2', to see
- whether or not we should use the fastmap, so we don't set
- this absolutely perfectly; see `re_compile_fastmap' (the
- `duplicate' case). */
- unsigned can_be_null : 1;
-
- /* If REGS_UNALLOCATED, allocate space in the `regs' structure
- for `max (RE_NREGS, re_nsub + 1)' groups.
- If REGS_REALLOCATE, reallocate space if necessary.
- If REGS_FIXED, use what's there. */
-#define REGS_UNALLOCATED 0
-#define REGS_REALLOCATE 1
-#define REGS_FIXED 2
- unsigned regs_allocated : 2;
-
- /* Set to zero when `regex_compile' compiles a pattern; set to one
- by `re_compile_fastmap' if it updates the fastmap. */
- unsigned fastmap_accurate : 1;
-
- /* If set, `re_match_2' does not return information about
- subexpressions. */
- unsigned no_sub : 1;
-
- /* If set, a beginning-of-line anchor doesn't match at the
- beginning of the string. */
- unsigned not_bol : 1;
-
- /* Similarly for an end-of-line anchor. */
- unsigned not_eol : 1;
-
- /* If true, an anchor at a newline matches. */
- unsigned newline_anchor : 1;
-
-/* [[[end pattern_buffer]]] */
-};
-
-typedef struct re_pattern_buffer regex_t;
-
-
-/* search.c (search_buffer) in Emacs needs this one opcode value. It is
- defined both in `regex.c' and here. */
-#define RE_EXACTN_VALUE 1
-
-/* Type for byte offsets within the string. POSIX mandates this. */
-typedef int regoff_t;
-
-
-/* This is the structure we store register match data in. See
- regex.texinfo for a full description of what registers match. */
-struct re_registers
-{
- unsigned num_regs;
- regoff_t *start;
- regoff_t *end;
-};
-
-
-/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
- `re_match_2' returns information about at least this many registers
- the first time a `regs' structure is passed. */
-#ifndef RE_NREGS
-#define RE_NREGS 30
-#endif
-
-
-/* POSIX specification for registers. Aside from the different names than
- `re_registers', POSIX uses an array of structures, instead of a
- structure of arrays. */
-typedef struct
-{
- regoff_t rm_so; /* Byte offset from string's start to substring's start. */
- regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
-} regmatch_t;
-
-/* Declarations for routines. */
-
-/* To avoid duplicating every routine declaration -- once with a
- prototype (if we are ANSI), and once without (if we aren't) -- we
- use the following macro to declare argument types. This
- unfortunately clutters up the declarations a bit, but I think it's
- worth it. */
-
-#ifdef __STDC__
-
-#define _RE_ARGS(args) args
-
-#else /* not __STDC__ */
-
-#define _RE_ARGS(args) ()
-
-#endif /* not __STDC__ */
-
-/* Sets the current default syntax to SYNTAX, and return the old syntax.
- You can also simply assign to the `re_syntax_options' variable. */
-extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
-
-/* Compile the regular expression PATTERN, with length LENGTH
- and syntax given by the global `re_syntax_options', into the buffer
- BUFFER. Return NULL if successful, and an error string if not. */
-extern const char *re_compile_pattern
- _RE_ARGS ((const char *pattern, size_t length,
- struct re_pattern_buffer *buffer));
-
-
-/* Compile a fastmap for the compiled pattern in BUFFER; used to
- accelerate searches. Return 0 if successful and -2 if was an
- internal error. */
-extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
-
-
-/* Search in the string STRING (with length LENGTH) for the pattern
- compiled into BUFFER. Start searching at position START, for RANGE
- characters. Return the starting position of the match, -1 for no
- match, or -2 for an internal error. Also return register
- information in REGS (if REGS and BUFFER->no_sub are nonzero). */
-extern int re_search
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
- int length, int start, int range, struct re_registers *regs));
-
-
-/* Like `re_search', but search in the concatenation of STRING1 and
- STRING2. Also, stop searching at index START + STOP. */
-extern int re_search_2
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
- int length1, const char *string2, int length2,
- int start, int range, struct re_registers *regs, int stop));
-
-
-/* Like `re_search', but return how many characters in STRING the regexp
- in BUFFER matched, starting at position START. */
-extern int re_match
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
- int length, int start, struct re_registers *regs));
-
-
-/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
-extern int re_match_2
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
- int length1, const char *string2, int length2,
- int start, struct re_registers *regs, int stop));
-
-
-/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
- ENDS. Subsequent matches using BUFFER and REGS will use this memory
- for recording register information. STARTS and ENDS must be
- allocated with malloc, and must each be at least `NUM_REGS * sizeof
- (regoff_t)' bytes long.
-
- If NUM_REGS == 0, then subsequent matches should allocate their own
- register data.
-
- Unless this function is called, the first search or match using
- PATTERN_BUFFER will allocate its own register data, without
- freeing the old data. */
-extern void re_set_registers
- _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
- unsigned num_regs, regoff_t *starts, regoff_t *ends));
-
-/* 4.2 bsd compatibility. */
-extern char *re_comp _RE_ARGS ((const char *));
-extern int re_exec _RE_ARGS ((const char *));
-
-/* POSIX compatibility. */
-extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags));
-extern int regexec
- _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch,
- regmatch_t pmatch[], int eflags));
-extern size_t regerror
- _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf,
- size_t errbuf_size));
-extern void regfree _RE_ARGS ((regex_t *preg));
-
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
-#endif /* not __REGEXP_LIBRARY_H__ */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/lib/libregex/test/ChangeLog b/gnu/lib/libregex/test/ChangeLog
deleted file mode 100644
index f0265bb..0000000
--- a/gnu/lib/libregex/test/ChangeLog
+++ /dev/null
@@ -1,77 +0,0 @@
-Thu Mar 25 21:23:43 1993 Jim Blandy (jimb@totoro.cs.oberlin.edu)
-
- * debugmalloc.c: #include <string.h>, and remove declaration of
- memcpy.
-
-Sun Dec 13 20:59:32 1992 Jim Blandy (jimb@totoro.cs.oberlin.edu)
-
- * tregress.c (test_regress): Add regression test for matching
- "[a-a]" against "a" with the upcase translation map.
-
- * iregex.c (print_regs): Don't print a newline after the register
- contents.
- (main): Instead, write out newlines here after printing match and
- search results; this way, we get a newline whether or not the
- pattern matched.
-
-Fri Dec 11 03:30:50 1992 Jim Blandy (jimb@totoro.cs.oberlin.edu)
-
- * tregress.c (test_regress): Add new test to catch bug fixed by
- change to regex.c today.
-
- * Makefile.in (dregex.o): Depend on `../regex.[ch]', not `regex.[ch]'.
-
-Sun Nov 15 07:51:40 1992 Karl Berry (karl@cs.umb.edu)
-
- * debugmalloc.c (memcpy): Declare; also, include <assert.h>.
-
- * psx-interf.c (fill_pmatch): Declare offsets as `regoff_t'
- instead of `off_t'.
-
-Thu Nov 12 11:29:58 1992 Karl Berry (karl@cs.umb.edu)
-
- * iregex.c (main): Remove unused variable `c'; initialize
- the char array in C code; only call print_regs if the match and
- search succeeded.
- (strlen): Declare.
-
- * tregress.c (test_regress): Bug from enami.
-
-Tue Nov 10 10:36:53 1992 Karl Berry (karl@cs.umb.edu)
-
- * tregress.c (test_regress): Remove Emacs 19 diff bug from rms, as
- it was never the right thing to test anyway, and the test itself
- had bugs in it.
-
-Mon Nov 9 10:09:40 1992 Karl Berry (karl@cs.umb.edu)
-
- * tregress.c (test_regress): Bug from meyering.
-
-Thu Sep 24 10:48:34 1992 Karl Berry (karl@cs.umb.edu)
-
- * Makefile.in: avoid $< (except in implicit rule).
-
-Sat Sep 19 15:38:29 1992 Karl Berry (karl@hayley)
-
- * Makefile.in (TAGS): include regex.c and regex.h.
-
-Wed Sep 16 09:29:27 1992 Karl Berry (karl@hayley)
-
- * xmalloc.c (xmalloc): use char *, not void *, as some compilers
- bomb out on the latter.
-
- * Makefile.in (LOADLIBES): use LIBS instead, as that what's
- Autoconf wants to define.
-
- * other.c: remove tests for ^/$ around newlines.
-
-Tue Sep 15 11:01:15 1992 Karl Berry (karl@hayley)
-
- * fileregex.c (main): call re_search_2 instead of re_search.
-
- * Makefile.in (regex.o): make target dregex.o, so VPATH doesn't
- find ../regex.o.
-
-Sun Sep 13 06:50:03 1992 Karl Berry (karl@hayley)
-
- * Created.
diff --git a/gnu/lib/libregex/test/Makefile b/gnu/lib/libregex/test/Makefile
deleted file mode 100644
index 977c5d2..0000000
--- a/gnu/lib/libregex/test/Makefile
+++ /dev/null
@@ -1,171 +0,0 @@
-# $Id$
-
-# Generated automatically from Makefile.in by configure.
-# Makefile for regex testing.
-#
-# Copyright (C) 1992 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-CPPFLAGS =
-CFLAGS = -g
-LDFLAGS =
-
-srcdir = .
-VPATH = .:../.
-
-CC = gcc
-DEFS = -DHAVE_STRING_H=1
-LIBS = $(LOADLIBES)
-
-ETAGS = etags
-SHELL = /bin/sh
-
-debug = -DDEBUG
-ALL_CPPFLAGS = -I. -I$(srcdir) -I../$(srcdir) $(DEFS) $(CPPFLAGS) $(debug)
-
-.c.o:
- $(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c $<
-
-
-# Define this as `../regex.o' to get the optimized version.
-regex_o = dregex.o
-test_h = test.h
-test_o = test.o bsd-interf.o other.o tregress.o psx-basic.o psx-extend.o \
- psx-generic.o psx-group.o psx-interf.o psx-interv.o
-common_o = printchar.o upcase.o xmalloc.o $(malloc)
-
-# We have a lot of mallocs we can try when we run afoul of strange bugs.
-malloc =
-#malloc = # the libc malloc
-#malloc = g++malloc.o
-#malloc = debugmalloc.o
-#malloc = emacsmalloc.o
-emacsmallocflags = -Drcheck -Dbotch=abort -DUSG
-
-# default is to do nothing.
-default:
-
-all: regex syntax
-
-regex: $(regex_o) $(common_o) $(test_o) main.o
- $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
-
-# As long as we're doing tests, we enable debugging.
-dregex.o: ../regex.c ../regex.h
- rm -f $@
- $(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c ../$(srcdir)/regex.c
- mv -f regex.o $@
-
-# iregex is the interactive regex.
-iregex: $(common_o) $(regex_o) iregex.o
- $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
-
-# fileregex searches for an r.e. in every line of a given file.
-fileregex_o = fileregex.o printchar.o $(regex_o)
-fileregex: $(fileregex_o)
- $(CC) -o $@ $(LDFLAGS) $(fileregex_o) $(LIBS)
-
-# cppregex is regex with a preprocessed regex.c. Useful when the
-# problem is inside some macro.
-cppregex: regexcpp.o $(common_o) $(test_o) main.o
- $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
-
-regexcpp.o: regexcpp.c
-
-regexcpp.c: regex.c regexcpp.sed
- rm -f regexcpp.c
- $(CC) -E $(ALL_CPPFLAGS) ../$(srcdir)/regex.c \
- | egrep -v '^#|^ *$$' \
- | sed -f regexcpp.sed \
- > regexcpp.c
- chmod a-w regexcpp.c
-
-# Have to give this malloc special flags.
-emacsmalloc.o: emacsmalloc.c
- $(CC) -c $(CFLAGS) $(ALL_CPPFLAGS) $(emacsmallocflags) \
- ../$(srcdir)/test/emacsmalloc.c
-
-syntax: syntax.o
- $(CC) $(CFLAGS) -o $@ syntax.o
-
-syntax.c: syntax.skel bits
- sed '/\[\[\[replace.*\]\]\]/r bits' syntax.skel > $@
-
-bits: regex.h
- sed -n 1,/RE_SYNTAX_EMACS/p ../$(srcdir)/regex.h \
- | grep "#define RE_.*1" \
- | sed 's/^#define \(RE_[A-Z_]*\) .*/ TEST_BIT (\1);/' > $@
-
-check: regex
- ./regex
-
-TAGS: regex.c regex.h *.h *.c
- $(ETAGS) -t $^
-
-depend:
- gcc -MM $(ALL_CPPFLAGS) *.c > /tmp/depend
-.PHONY: depend
-
-install:
-.PHONY: install
-
-clean mostlyclean:
- rm -f *.o regex cppregex iregex fileregex regexcpp.c syntax
-
-distclean: clean
- rm -f bits syntax.c Makefile
-
-extraclean: distclean
- rm -f *~* *\#* patch* *.orig *.rej *.bak core a.out
-
-realclean: distclean
- rm -f TAGS
-
-Makefile: Makefile.in ../config.status
- (cd ..; sh config.status)
-
-# Prevent GNU make 3 from overflowing arg limit on system V.
-.NOEXPORT:
-
-# Assumes $(distdir) is the place to put our files.
-distfiles = ChangeLog TAGS *.in *.c *.h regexcpp.sed syntax.skel
-dist: Makefile TAGS
- mkdir $(distdir)
- ln $(distfiles) $(distdir)
-
-# Automatically-generated dependencies below here.
-alloca.o : alloca.c
-bsd-interf.o : bsd-interf.c
-debugmalloc.o : debugmalloc.c
-emacsmalloc.o : emacsmalloc.c getpagesize.h
-fileregex.o : fileregex.c .././regex.h
-g++malloc.o : g++malloc.c //usr/include/stdio.h getpagesize.h
-iregex.o : iregex.c .././regex.h
-main.o : main.c test.h .././regex.h
-malloc-test.o : malloc-test.c
-other.o : other.c test.h .././regex.h
-printchar.o : printchar.c
-psx-basic.o : psx-basic.c test.h .././regex.h
-psx-extend.o : psx-extend.c test.h .././regex.h
-psx-generic.o : psx-generic.c test.h .././regex.h
-psx-group.o : psx-group.c test.h .././regex.h
-psx-interf.o : psx-interf.c test.h .././regex.h
-psx-interv.o : psx-interv.c test.h .././regex.h
-syntax.o : syntax.c .././regex.h
-test.o : test.c test.h .././regex.h
-tregress.o : tregress.c test.h .././regex.h
-upcase.o : upcase.c
-xmalloc.o : xmalloc.c
diff --git a/gnu/lib/libregex/test/Makefile.in b/gnu/lib/libregex/test/Makefile.in
deleted file mode 100644
index 7b56b32..0000000
--- a/gnu/lib/libregex/test/Makefile.in
+++ /dev/null
@@ -1,170 +0,0 @@
-# $Id$
-
-# Makefile for regex testing.
-#
-# Copyright (C) 1992 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-CPPFLAGS =
-CFLAGS = -g
-LDFLAGS =
-
-srcdir = @srcdir@
-VPATH = @srcdir@:../@srcdir@
-
-CC = @CC@
-DEFS = @DEFS@
-LIBS = @LIBS@ $(LOADLIBES)
-
-ETAGS = etags
-SHELL = /bin/sh
-
-debug = -DDEBUG
-ALL_CPPFLAGS = -I. -I$(srcdir) -I../$(srcdir) $(DEFS) $(CPPFLAGS) $(debug)
-
-.c.o:
- $(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c $<
-
-
-# Define this as `../regex.o' to get the optimized version.
-regex_o = dregex.o
-test_h = test.h
-test_o = test.o bsd-interf.o other.o tregress.o psx-basic.o psx-extend.o \
- psx-generic.o psx-group.o psx-interf.o psx-interv.o
-common_o = printchar.o upcase.o xmalloc.o $(malloc)
-
-# We have a lot of mallocs we can try when we run afoul of strange bugs.
-malloc = @ALLOCA@
-#malloc = # the libc malloc
-#malloc = g++malloc.o
-#malloc = debugmalloc.o
-#malloc = emacsmalloc.o
-emacsmallocflags = -Drcheck -Dbotch=abort -DUSG
-
-# default is to do nothing.
-default:
-
-all: regex syntax
-
-regex: $(regex_o) $(common_o) $(test_o) main.o
- $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
-
-# As long as we're doing tests, we enable debugging.
-dregex.o: ../regex.c ../regex.h
- rm -f $@
- $(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c ../$(srcdir)/regex.c
- mv -f regex.o $@
-
-# iregex is the interactive regex.
-iregex: $(common_o) $(regex_o) iregex.o
- $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
-
-# fileregex searches for an r.e. in every line of a given file.
-fileregex_o = fileregex.o printchar.o $(regex_o)
-fileregex: $(fileregex_o)
- $(CC) -o $@ $(LDFLAGS) $(fileregex_o) $(LIBS)
-
-# cppregex is regex with a preprocessed regex.c. Useful when the
-# problem is inside some macro.
-cppregex: regexcpp.o $(common_o) $(test_o) main.o
- $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
-
-regexcpp.o: regexcpp.c
-
-regexcpp.c: regex.c regexcpp.sed
- rm -f regexcpp.c
- $(CC) -E $(ALL_CPPFLAGS) ../$(srcdir)/regex.c \
- | egrep -v '^#|^ *$$' \
- | sed -f regexcpp.sed \
- > regexcpp.c
- chmod a-w regexcpp.c
-
-# Have to give this malloc special flags.
-emacsmalloc.o: emacsmalloc.c
- $(CC) -c $(CFLAGS) $(ALL_CPPFLAGS) $(emacsmallocflags) \
- ../$(srcdir)/test/emacsmalloc.c
-
-syntax: syntax.o
- $(CC) $(CFLAGS) -o $@ syntax.o
-
-syntax.c: syntax.skel bits
- sed '/\[\[\[replace.*\]\]\]/r bits' syntax.skel > $@
-
-bits: regex.h
- sed -n 1,/RE_SYNTAX_EMACS/p ../$(srcdir)/regex.h \
- | grep "#define RE_.*1" \
- | sed 's/^#define \(RE_[A-Z_]*\) .*/ TEST_BIT (\1);/' > $@
-
-check: regex
- ./regex
-
-TAGS: regex.c regex.h *.h *.c
- $(ETAGS) -t $^
-
-depend:
- gcc -MM $(ALL_CPPFLAGS) *.c > /tmp/depend
-.PHONY: depend
-
-install:
-.PHONY: install
-
-clean mostlyclean:
- rm -f *.o regex cppregex iregex fileregex regexcpp.c syntax
-
-distclean: clean
- rm -f bits syntax.c Makefile
-
-extraclean: distclean
- rm -f *~* *\#* patch* *.orig *.rej *.bak core a.out
-
-realclean: distclean
- rm -f TAGS
-
-Makefile: Makefile.in ../config.status
- (cd ..; sh config.status)
-
-# Prevent GNU make 3 from overflowing arg limit on system V.
-.NOEXPORT:
-
-# Assumes $(distdir) is the place to put our files.
-distfiles = ChangeLog TAGS *.in *.c *.h regexcpp.sed syntax.skel
-dist: Makefile TAGS
- mkdir $(distdir)
- ln $(distfiles) $(distdir)
-
-# Automatically-generated dependencies below here.
-alloca.o : alloca.c
-bsd-interf.o : bsd-interf.c
-debugmalloc.o : debugmalloc.c
-emacsmalloc.o : emacsmalloc.c getpagesize.h
-fileregex.o : fileregex.c .././regex.h
-g++malloc.o : g++malloc.c //usr/include/stdio.h getpagesize.h
-iregex.o : iregex.c .././regex.h
-main.o : main.c test.h .././regex.h
-malloc-test.o : malloc-test.c
-other.o : other.c test.h .././regex.h
-printchar.o : printchar.c
-psx-basic.o : psx-basic.c test.h .././regex.h
-psx-extend.o : psx-extend.c test.h .././regex.h
-psx-generic.o : psx-generic.c test.h .././regex.h
-psx-group.o : psx-group.c test.h .././regex.h
-psx-interf.o : psx-interf.c test.h .././regex.h
-psx-interv.o : psx-interv.c test.h .././regex.h
-syntax.o : syntax.c .././regex.h
-test.o : test.c test.h .././regex.h
-tregress.o : tregress.c test.h .././regex.h
-upcase.o : upcase.c
-xmalloc.o : xmalloc.c
diff --git a/gnu/lib/libregex/test/alloca.c b/gnu/lib/libregex/test/alloca.c
deleted file mode 100644
index d8b6748..0000000
--- a/gnu/lib/libregex/test/alloca.c
+++ /dev/null
@@ -1,194 +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/gnu/lib/libregex/test/bsd-interf.c b/gnu/lib/libregex/test/bsd-interf.c
deleted file mode 100644
index 226a513..0000000
--- a/gnu/lib/libregex/test/bsd-interf.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* bsd-interf.c: test BSD interface. */
-
-#ifndef _POSIX_SOURCE /* whole file */
-
-#include "test.h"
-
-void
-test_berk_search (pattern, string)
- const char *pattern;
- char *string;
-{
- const char *return_value = re_comp (pattern);
-
- if (return_value != 0)
- {
- printf ("This didn't compile: `%s'.\n", pattern);
- printf (" The error message was: `%s'.\n", return_value);
- }
- else
- if (test_should_match && re_exec (string) != strlen (string))
- {
- printf ("Should have matched but didn't:\n");
- printf (" The pattern was: %s.\n", pattern);
- if (string)
- printf (" The string was: `%s'.'n", string);
- else
- printf (" The string was empty.\n");
- }
-}
-
-
-void
-test_bsd_interface ()
-{
- test_berk_search ("a", "ab");
-}
-
-#endif /* _POSIX_SOURCE */
diff --git a/gnu/lib/libregex/test/debugmalloc.c b/gnu/lib/libregex/test/debugmalloc.c
deleted file mode 100644
index 6caeb65..0000000
--- a/gnu/lib/libregex/test/debugmalloc.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/* debugmalloc.c: a malloc for debugging purposes. */
-
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-
-static unsigned trace = 0;
-#define TRACE(s) if (trace) fprintf (stderr, "%s", s)
-#define TRACE1(s, e1) if (trace) fprintf (stderr, s, e1)
-#define TRACE2(s, e1, e2) if (trace) fprintf (stderr, s, e1, e2)
-#define TRACE3(s, e1, e2, e3) if (trace) fprintf (stderr, s, e1, e2, e3)
-#define TRACE4(s, e1, e2, e3, e4) \
- if (trace) fprintf (stderr, s, e1, e2, e3, e4)
-
-typedef char *address;
-
-
-/* Wrap our calls to sbrk. */
-
-address
-xsbrk (incr)
- int incr;
-{
- extern char *sbrk ();
- address ret = sbrk (incr);
-
- if (ret == (address) -1)
- {
- perror ("sbrk"); /* Actually, we should return NULL, not quit. */
- abort ();
- }
-
- return ret;
-}
-
-
-
-typedef struct chunk_struct
-{
- /* This is the size (in bytes) that has actually been actually
- allocated, not the size that the user requested. */
- unsigned alloc_size;
-
- /* This is the size the user requested. */
- unsigned user_size;
-
- /* Points to the next block in one of the lists. */
- struct chunk_struct *next;
-
- /* Now comes the user's memory. */
- address user_mem;
-
- /* After the user's memory is a constant. */
-} *chunk;
-
-#define MALLOC_OVERHEAD 16
-
-/* We might play around with the `user_size' field, but the amount of
- memory that is actually available in the chunk is always the size
- allocated minus the overhead. */
-#define USER_ALLOC(c) ((c)->alloc_size - MALLOC_OVERHEAD)
-
-/* Given a pointer to a malloc-allocated block, the beginning of the
- chunk should always be MALLOC_OVERHEAD - 4 bytes back, since the only
- overhead after the user memory is the constant. */
-
-chunk
-mem_to_chunk (mem)
- address mem;
-{
- return (chunk) (mem - (MALLOC_OVERHEAD - 4));
-}
-
-
-/* The other direction is even easier, since the user's memory starts at
- the `user_mem' member in the chunk. */
-
-address
-chunk_to_mem (c)
- chunk c;
-{
- return (address) &(c->user_mem);
-}
-
-
-
-/* We keep both all the allocated chunks and all the free chunks on
- lists. Since we put the next pointers in the chunk structure, we
- don't need a separate chunk_list structure. */
-chunk alloc_list = NULL, free_list = NULL;
-
-
-/* We always append the new chunk at the beginning of the list. */
-
-void
-chunk_insert (chunk_list, new_c)
- chunk *chunk_list;
- chunk new_c;
-{
- chunk c = *chunk_list; /* old beginning of list */
-
- TRACE3 (" Inserting 0x%x at the beginning of 0x%x, before 0x%x.\n",
- new_c, chunk_list, c);
-
- *chunk_list = new_c;
- new_c->next = c;
-}
-
-
-/* Thus, removing an element means we have to search until we find it.
- Have to delete before we insert, since insertion changes the next
- pointer, which we need to put it on the other list. */
-
-void
-chunk_delete (chunk_list, dead_c)
- chunk *chunk_list;
- chunk dead_c;
-{
- chunk c = *chunk_list;
- chunk prev_c = NULL;
-
- TRACE2 (" Deleting 0x%x from 0x%x:", dead_c, chunk_list);
-
- while (c != dead_c && c != NULL)
- {
- TRACE1 (" 0x%x", c);
- prev_c = c;
- c = c->next;
- }
-
- if (c == NULL)
- {
- fprintf (stderr, "Chunk at 0x%x not found on list.\n", dead_c);
- abort ();
- }
-
- if (prev_c == NULL)
- {
- TRACE1 (".\n Setting head to 0x%x.\n", c->next);
- *chunk_list = c->next;
- }
- else
- {
- TRACE2 (".\n Linking next(0x%x) to 0x%x.\n", prev_c, c->next);
- prev_c->next = c->next;
- }
-}
-
-
-/* See if a list is hunky-dory. */
-
-void
-validate_list (chunk_list)
- chunk *chunk_list;
-{
- chunk c;
-
- TRACE1 (" Validating list at 0x%x:", chunk_list);
-
- for (c = *chunk_list; c != NULL; c = c->next)
- {
- assert (c->user_size < c->alloc_size);
- assert (memcmp (chunk_to_mem (c) + c->user_size, "Karl", 4));
- TRACE2 (" 0x%x/%d", c, c->user_size);
- }
-
- TRACE (".\n");
-}
-
-
-/* See if we have a free chunk of a given size. We'll take the first
- one that is big enough. */
-
-chunk
-free_list_available (needed)
- unsigned needed;
-{
- chunk c;
-
- TRACE1 (" Checking free list for %d bytes:", needed);
-
- if (free_list == NULL)
- {
- return NULL;
- }
-
- c = free_list;
-
- while (c != NULL && USER_ALLOC (c) < needed)
- {
- TRACE2 (" 0x%x/%d", c, USER_ALLOC (c));
- c = c->next;
- }
-
- TRACE1 ("\n Returning 0x%x.\n", c);
- return c;
-}
-
-
-
-
-address
-malloc (n)
- unsigned n;
-{
- address new_mem;
- chunk c;
-
- TRACE1 ("Mallocing %d bytes.\n", n);
-
- validate_list (&free_list);
- validate_list (&alloc_list);
-
- c = free_list_available (n);
-
- if (c == NULL)
- { /* Nothing suitable on free list. Allocate a new chunk. */
- TRACE (" not on free list.\n");
- c = (chunk) xsbrk (n + MALLOC_OVERHEAD);
- c->alloc_size = n + MALLOC_OVERHEAD;
- }
- else
- { /* Found something on free list. Don't split it, just use as is. */
- TRACE (" found on free list.\n");
- chunk_delete (&free_list, c);
- }
-
- /* If we took this from the free list, then the user size might be
- different now, and consequently the constant at the end might be in
- the wrong place. */
- c->user_size = n;
- new_mem = chunk_to_mem (c);
- memcpy (new_mem + n, "Karl", 4);
- chunk_insert (&alloc_list, c);
-
- TRACE2 ("Malloc returning 0x%x (chunk 0x%x).\n", new_mem, c);
- return new_mem;
-}
-
-
-address
-realloc (mem, n)
- address mem;
- unsigned n;
-{
- void free ();
- chunk c = mem_to_chunk (mem);
- address new_mem;
-
- TRACE3 ("Reallocing %d bytes at 0x%x (chunk 0x%x).\n", n, mem, c);
-
- new_mem = malloc (n);
- memcpy (new_mem, mem, c->user_size);
- free (mem);
-
- return new_mem;
-}
-
-
-void
-free (mem)
- address mem;
-{
- chunk c = mem_to_chunk (mem);
-
- TRACE2 ("Freeing memory at 0x%x (chunk at 0x%x).\n", mem, c);
-
- validate_list (&free_list);
- validate_list (&alloc_list);
-
- chunk_delete (&alloc_list, c);
- chunk_insert (&free_list, c);
-}
diff --git a/gnu/lib/libregex/test/emacsmalloc.c b/gnu/lib/libregex/test/emacsmalloc.c
deleted file mode 100644
index ad7c4da..0000000
--- a/gnu/lib/libregex/test/emacsmalloc.c
+++ /dev/null
@@ -1,844 +0,0 @@
-/* dynamic memory allocation for GNU.
- Copyright (C) 1985, 1987 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- 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.
-
-In other words, you are welcome to use, share and improve this program.
-You are forbidden to forbid anyone else to use, share and improve
-what you give them. Help stamp out software-hoarding! */
-
-
-/*
- * @(#)nmalloc.c 1 (Caltech) 2/21/82
- *
- * U of M Modified: 20 Jun 1983 ACT: strange hacks for Emacs
- *
- * Nov 1983, Mike@BRL, Added support for 4.1C/4.2 BSD.
- *
- * This is a very fast storage allocator. It allocates blocks of a small
- * number of different sizes, and keeps free lists of each size. Blocks
- * that don't exactly fit are passed up to the next larger size. In this
- * implementation, the available sizes are (2^n)-4 (or -16) bytes long.
- * This is designed for use in a program that uses vast quantities of
- * memory, but bombs when it runs out. To make it a little better, it
- * warns the user when he starts to get near the end.
- *
- * June 84, ACT: modified rcheck code to check the range given to malloc,
- * rather than the range determined by the 2-power used.
- *
- * Jan 85, RMS: calls malloc_warning to issue warning on nearly full.
- * No longer Emacs-specific; can serve as all-purpose malloc for GNU.
- * You should call malloc_init to reinitialize after loading dumped Emacs.
- * Call malloc_stats to get info on memory stats if MSTATS turned on.
- * realloc knows how to return same block given, just changing its size,
- * if the power of 2 is correct.
- */
-
-/*
- * nextf[i] is the pointer to the next free block of size 2^(i+3). The
- * smallest allocatable block is 8 bytes. The overhead information will
- * go in the first int of the block, and the returned pointer will point
- * to the second.
- *
-#ifdef MSTATS
- * nmalloc[i] is the difference between the number of mallocs and frees
- * for a given block size.
-#endif MSTATS
- */
-
-#ifdef emacs
-/* config.h specifies which kind of system this is. */
-#include "config.h"
-#include <signal.h>
-#else
-
-/* Determine which kind of system this is. */
-#include <sys/types.h>
-#include <signal.h>
-
-#include <string.h>
-#define bcopy(s,d,n) memcpy ((d), (s), (n))
-#define bcmp(s1,s2,n) memcmp ((s1), (s2), (n))
-#define bzero(s,n) memset ((s), 0, (n))
-
-#ifndef SIGTSTP
-#ifndef VMS
-#ifndef USG
-#define USG
-#endif
-#endif /* not VMS */
-#else /* SIGTSTP */
-#ifdef SIGIO
-#define BSD4_2
-#endif /* SIGIO */
-#endif /* SIGTSTP */
-
-#endif /* not emacs */
-
-/* Define getpagesize () if the system does not. */
-#include "getpagesize.h"
-
-#ifdef BSD
-#ifdef BSD4_1
-#include <sys/vlimit.h> /* warn the user when near the end */
-#else /* if 4.2 or newer */
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif /* if 4.2 or newer */
-#endif
-
-#ifdef VMS
-#include "vlimit.h"
-#endif
-
-extern char *start_of_data ();
-
-#ifdef BSD
-#ifndef DATA_SEG_BITS
-#define start_of_data() &etext
-#endif
-#endif
-
-#ifndef emacs
-#define start_of_data() &etext
-#endif
-
-#define ISALLOC ((char) 0xf7) /* magic byte that implies allocation */
-#define ISFREE ((char) 0x54) /* magic byte that implies free block */
- /* this is for error checking only */
-#define ISMEMALIGN ((char) 0xd6) /* Stored before the value returned by
- memalign, with the rest of the word
- being the distance to the true
- beginning of the block. */
-
-extern char etext;
-
-/* These two are for user programs to look at, when they are interested. */
-
-unsigned int malloc_sbrk_used; /* amount of data space used now */
-unsigned int malloc_sbrk_unused; /* amount more we can have */
-
-/* start of data space; can be changed by calling init_malloc */
-static char *data_space_start;
-
-#ifdef MSTATS
-static int nmalloc[30];
-static int nmal, nfre;
-#endif /* MSTATS */
-
-/* If range checking is not turned on, all we have is a flag indicating
- whether memory is allocated, an index in nextf[], and a size field; to
- realloc() memory we copy either size bytes or 1<<(index+3) bytes depending
- on whether the former can hold the exact size (given the value of
- 'index'). If range checking is on, we always need to know how much space
- is allocated, so the 'size' field is never used. */
-
-struct mhead {
- char mh_alloc; /* ISALLOC or ISFREE */
- char mh_index; /* index in nextf[] */
-/* Remainder are valid only when block is allocated */
- unsigned short mh_size; /* size, if < 0x10000 */
-#ifdef rcheck
- unsigned mh_nbytes; /* number of bytes allocated */
- int mh_magic4; /* should be == MAGIC4 */
-#endif /* rcheck */
-};
-
-/* Access free-list pointer of a block.
- It is stored at block + 4.
- This is not a field in the mhead structure
- because we want sizeof (struct mhead)
- to describe the overhead for when the block is in use,
- and we do not want the free-list pointer to count in that. */
-
-#define CHAIN(a) \
- (*(struct mhead **) (sizeof (char *) + (char *) (a)))
-
-#ifdef rcheck
-
-/* To implement range checking, we write magic values in at the beginning and
- end of each allocated block, and make sure they are undisturbed whenever a
- free or a realloc occurs. */
-/* Written in each of the 4 bytes following the block's real space */
-#define MAGIC1 0x55
-/* Written in the 4 bytes before the block's real space */
-#define MAGIC4 0x55555555
-#define ASSERT(p) if (!(p)) botch("p"); else
-#define EXTRA 4 /* 4 bytes extra for MAGIC1s */
-#else
-#define ASSERT(p) if (!(p)) abort (); else
-#define EXTRA 0
-#endif /* rcheck */
-
-
-/* nextf[i] is free list of blocks of size 2**(i + 3) */
-
-static struct mhead *nextf[30];
-
-/* busy[i] is nonzero while allocation of block size i is in progress. */
-
-static char busy[30];
-
-/* Number of bytes of writable memory we can expect to be able to get */
-static unsigned int lim_data;
-
-/* Level number of warnings already issued.
- 0 -- no warnings issued.
- 1 -- 75% warning already issued.
- 2 -- 85% warning already issued.
-*/
-static int warnlevel;
-
-/* Function to call to issue a warning;
- 0 means don't issue them. */
-static void (*warnfunction) ();
-
-/* nonzero once initial bunch of free blocks made */
-static int gotpool;
-
-char *_malloc_base;
-
-static void getpool ();
-
-/* Cause reinitialization based on job parameters;
- also declare where the end of pure storage is. */
-void
-malloc_init (start, warnfun)
- char *start;
- void (*warnfun) ();
-{
- if (start)
- data_space_start = start;
- lim_data = 0;
- warnlevel = 0;
- warnfunction = warnfun;
-}
-
-/* Return the maximum size to which MEM can be realloc'd
- without actually requiring copying. */
-
-int
-malloc_usable_size (mem)
- char *mem;
-{
- struct mhead *p
- = (struct mhead *) (mem - ((sizeof (struct mhead) + 7) & ~7));
- int blocksize = 8 << p->mh_index;
-
- return blocksize - sizeof (struct mhead) - EXTRA;
-}
-
-static void
-morecore (nu) /* ask system for more memory */
- register int nu; /* size index to get more of */
-{
- char *sbrk ();
- register char *cp;
- register int nblks;
- register unsigned int siz;
- int oldmask;
-
-#ifdef BSD
-#ifndef BSD4_1
- int newmask = -1;
- /* Blocking these signals interferes with debugging, at least on BSD on
- the HP 9000/300. */
-#ifdef SIGTRAP
- newmask &= ~(1 << SIGTRAP);
-#endif
-#ifdef SIGILL
- newmask &= ~(1 << SIGILL);
-#endif
-#ifdef SIGTSTP
- newmask &= ~(1 << SIGTSTP);
-#endif
-#ifdef SIGSTOP
- newmask &= ~(1 << SIGSTOP);
-#endif
- oldmask = sigsetmask (newmask);
-#endif
-#endif
-
- if (!data_space_start)
- {
- data_space_start = start_of_data ();
- }
-
- if (lim_data == 0)
- get_lim_data ();
-
- /* On initial startup, get two blocks of each size up to 1k bytes */
- if (!gotpool)
- { getpool (); getpool (); gotpool = 1; }
-
- /* Find current end of memory and issue warning if getting near max */
-
-#ifndef VMS
- /* Maximum virtual memory on VMS is difficult to calculate since it
- * depends on several dynmacially changing things. Also, alignment
- * isn't that important. That is why much of the code here is ifdef'ed
- * out for VMS systems.
- */
- cp = sbrk (0);
- siz = cp - data_space_start;
-
- if (warnfunction)
- switch (warnlevel)
- {
- case 0:
- if (siz > (lim_data / 4) * 3)
- {
- warnlevel++;
- (*warnfunction) ("Warning: past 75% of memory limit");
- }
- break;
- case 1:
- if (siz > (lim_data / 20) * 17)
- {
- warnlevel++;
- (*warnfunction) ("Warning: past 85% of memory limit");
- }
- break;
- case 2:
- if (siz > (lim_data / 20) * 19)
- {
- warnlevel++;
- (*warnfunction) ("Warning: past 95% of memory limit");
- }
- break;
- }
-
- if ((int) cp & 0x3ff) /* land on 1K boundaries */
- sbrk (1024 - ((int) cp & 0x3ff));
-#endif /* not VMS */
-
- /* Take at least 2k, and figure out how many blocks of the desired size
- we're about to get */
- nblks = 1;
- if ((siz = nu) < 8)
- nblks = 1 << ((siz = 8) - nu);
-
- if ((cp = sbrk (1 << (siz + 3))) == (char *) -1)
- {
-#ifdef BSD
-#ifndef BSD4_1
- sigsetmask (oldmask);
-#endif
-#endif
- return; /* no more room! */
- }
- malloc_sbrk_used = siz;
- malloc_sbrk_unused = lim_data - siz;
-
-#ifndef VMS
- if ((int) cp & 7)
- { /* shouldn't happen, but just in case */
- cp = (char *) (((int) cp + 8) & ~7);
- nblks--;
- }
-#endif /* not VMS */
-
- /* save new header and link the nblks blocks together */
- nextf[nu] = (struct mhead *) cp;
- siz = 1 << (nu + 3);
- while (1)
- {
- ((struct mhead *) cp) -> mh_alloc = ISFREE;
- ((struct mhead *) cp) -> mh_index = nu;
- if (--nblks <= 0) break;
- CHAIN ((struct mhead *) cp) = (struct mhead *) (cp + siz);
- cp += siz;
- }
- CHAIN ((struct mhead *) cp) = 0;
-
-#ifdef BSD
-#ifndef BSD4_1
- sigsetmask (oldmask);
-#endif
-#endif
-}
-
-static void
-getpool ()
-{
- register int nu;
- char * sbrk ();
- register char *cp = sbrk (0);
-
- if ((int) cp & 0x3ff) /* land on 1K boundaries */
- sbrk (1024 - ((int) cp & 0x3ff));
-
- /* Record address of start of space allocated by malloc. */
- if (_malloc_base == 0)
- _malloc_base = cp;
-
- /* Get 2k of storage */
-
- cp = sbrk (04000);
- if (cp == (char *) -1)
- return;
-
- /* Divide it into an initial 8-word block
- plus one block of size 2**nu for nu = 3 ... 10. */
-
- CHAIN (cp) = nextf[0];
- nextf[0] = (struct mhead *) cp;
- ((struct mhead *) cp) -> mh_alloc = ISFREE;
- ((struct mhead *) cp) -> mh_index = 0;
- cp += 8;
-
- for (nu = 0; nu < 7; nu++)
- {
- CHAIN (cp) = nextf[nu];
- nextf[nu] = (struct mhead *) cp;
- ((struct mhead *) cp) -> mh_alloc = ISFREE;
- ((struct mhead *) cp) -> mh_index = nu;
- cp += 8 << nu;
- }
-}
-
-char *
-malloc (n) /* get a block */
- unsigned n;
-{
- register struct mhead *p;
- register unsigned int nbytes;
- register int nunits = 0;
-
- /* Figure out how many bytes are required, rounding up to the nearest
- multiple of 8, then figure out which nestf[] area to use.
- Both the beginning of the header and the beginning of the
- block should be on an eight byte boundary. */
- nbytes = (n + ((sizeof *p + 7) & ~7) + EXTRA + 7) & ~7;
- {
- register unsigned int shiftr = (nbytes - 1) >> 2;
-
- while (shiftr >>= 1)
- nunits++;
- }
-
- /* In case this is reentrant use of malloc from signal handler,
- pick a block size that no other malloc level is currently
- trying to allocate. That's the easiest harmless way not to
- interfere with the other level of execution. */
- while (busy[nunits]) nunits++;
- busy[nunits] = 1;
-
- /* If there are no blocks of the appropriate size, go get some */
- /* COULD SPLIT UP A LARGER BLOCK HERE ... ACT */
- if (nextf[nunits] == 0)
- morecore (nunits);
-
- /* Get one block off the list, and set the new list head */
- if ((p = nextf[nunits]) == 0)
- {
- busy[nunits] = 0;
- return 0;
- }
- nextf[nunits] = CHAIN (p);
- busy[nunits] = 0;
-
- /* Check for free block clobbered */
- /* If not for this check, we would gobble a clobbered free chain ptr */
- /* and bomb out on the NEXT allocate of this size block */
- if (p -> mh_alloc != ISFREE || p -> mh_index != nunits)
-#ifdef rcheck
- botch ("block on free list clobbered");
-#else /* not rcheck */
- abort ();
-#endif /* not rcheck */
-
- /* Fill in the info, and if range checking, set up the magic numbers */
- p -> mh_alloc = ISALLOC;
-#ifdef rcheck
- p -> mh_nbytes = n;
- p -> mh_magic4 = MAGIC4;
- {
- /* Get the location n after the beginning of the user's space. */
- register char *m = (char *) p + ((sizeof *p + 7) & ~7) + n;
-
- *m++ = MAGIC1, *m++ = MAGIC1, *m++ = MAGIC1, *m = MAGIC1;
- }
-#else /* not rcheck */
- p -> mh_size = n;
-#endif /* not rcheck */
-#ifdef MSTATS
- nmalloc[nunits]++;
- nmal++;
-#endif /* MSTATS */
- return (char *) p + ((sizeof *p + 7) & ~7);
-}
-
-free (mem)
- char *mem;
-{
- register struct mhead *p;
- {
- register char *ap = mem;
-
- if (ap == 0)
- return;
-
- p = (struct mhead *) (ap - ((sizeof *p + 7) & ~7));
- if (p -> mh_alloc == ISMEMALIGN)
- {
- ap -= p->mh_size;
- p = (struct mhead *) (ap - ((sizeof *p + 7) & ~7));
- }
-
-#ifndef rcheck
- if (p -> mh_alloc != ISALLOC)
- abort ();
-
-#else rcheck
- if (p -> mh_alloc != ISALLOC)
- {
- if (p -> mh_alloc == ISFREE)
- botch ("free: Called with already freed block argument\n");
- else
- botch ("free: Called with bad argument\n");
- }
-
- ASSERT (p -> mh_magic4 == MAGIC4);
- ap += p -> mh_nbytes;
- ASSERT (*ap++ == MAGIC1); ASSERT (*ap++ == MAGIC1);
- ASSERT (*ap++ == MAGIC1); ASSERT (*ap == MAGIC1);
-#endif /* rcheck */
- }
- {
- register int nunits = p -> mh_index;
-
- ASSERT (nunits <= 29);
- p -> mh_alloc = ISFREE;
-
- /* Protect against signal handlers calling malloc. */
- busy[nunits] = 1;
- /* Put this block on the free list. */
- CHAIN (p) = nextf[nunits];
- nextf[nunits] = p;
- busy[nunits] = 0;
-
-#ifdef MSTATS
- nmalloc[nunits]--;
- nfre++;
-#endif /* MSTATS */
- }
-}
-
-char *
-realloc (mem, n)
- char *mem;
- register unsigned n;
-{
- register struct mhead *p;
- register unsigned int tocopy;
- register unsigned int nbytes;
- register int nunits;
-
- if (mem == 0)
- return malloc (n);
- p = (struct mhead *) (mem - ((sizeof *p + 7) & ~7));
- nunits = p -> mh_index;
- ASSERT (p -> mh_alloc == ISALLOC);
-#ifdef rcheck
- ASSERT (p -> mh_magic4 == MAGIC4);
- {
- register char *m = mem + (tocopy = p -> mh_nbytes);
- ASSERT (*m++ == MAGIC1); ASSERT (*m++ == MAGIC1);
- ASSERT (*m++ == MAGIC1); ASSERT (*m == MAGIC1);
- }
-#else /* not rcheck */
- if (p -> mh_index >= 13)
- tocopy = (1 << (p -> mh_index + 3)) - ((sizeof *p + 7) & ~7);
- else
- tocopy = p -> mh_size;
-#endif /* not rcheck */
-
- /* See if desired size rounds to same power of 2 as actual size. */
- nbytes = (n + ((sizeof *p + 7) & ~7) + EXTRA + 7) & ~7;
-
- /* If ok, use the same block, just marking its size as changed. */
- if (nbytes > (4 << nunits) && nbytes <= (8 << nunits))
- {
-#ifdef rcheck
- register char *m = mem + tocopy;
- *m++ = 0; *m++ = 0; *m++ = 0; *m++ = 0;
- p-> mh_nbytes = n;
- m = mem + n;
- *m++ = MAGIC1; *m++ = MAGIC1; *m++ = MAGIC1; *m++ = MAGIC1;
-#else /* not rcheck */
- p -> mh_size = n;
-#endif /* not rcheck */
- return mem;
- }
-
- if (n < tocopy)
- tocopy = n;
- {
- register char *new;
-
- if ((new = malloc (n)) == 0)
- return 0;
- bcopy (mem, new, tocopy);
- free (mem);
- return new;
- }
-}
-
-/* This is in case something linked with Emacs calls calloc. */
-
-char *
-calloc (num, size)
- unsigned num, size;
-{
- register char *mem;
-
- num *= size;
- mem = malloc (num);
- if (mem != 0)
- bzero (mem, num);
- return mem;
-}
-
-#ifndef VMS
-
-char *
-memalign (alignment, size)
- unsigned alignment, size;
-{
- register char *ptr = malloc (size + alignment);
- register char *aligned;
- register struct mhead *p;
-
- if (ptr == 0)
- return 0;
- /* If entire block has the desired alignment, just accept it. */
- if (((int) ptr & (alignment - 1)) == 0)
- return ptr;
- /* Otherwise, get address of byte in the block that has that alignment. */
- aligned = (char *) (((int) ptr + alignment - 1) & -alignment);
-
- /* Store a suitable indication of how to free the block,
- so that free can find the true beginning of it. */
- p = (struct mhead *) (aligned - ((7 + sizeof (struct mhead)) & ~7));
- p -> mh_size = aligned - ptr;
- p -> mh_alloc = ISMEMALIGN;
- return aligned;
-}
-
-#ifndef HPUX
-/* This runs into trouble with getpagesize on HPUX.
- Patching out seems cleaner than the ugly fix needed. */
-char *
-valloc (size)
-{
- return memalign (getpagesize (), size);
-}
-#endif /* not HPUX */
-#endif /* not VMS */
-
-#ifdef MSTATS
-/* Return statistics describing allocation of blocks of size 2**n. */
-
-struct mstats_value
- {
- int blocksize;
- int nfree;
- int nused;
- };
-
-struct mstats_value
-malloc_stats (size)
- int size;
-{
- struct mstats_value v;
- register int i;
- register struct mhead *p;
-
- v.nfree = 0;
-
- if (size < 0 || size >= 30)
- {
- v.blocksize = 0;
- v.nused = 0;
- return v;
- }
-
- v.blocksize = 1 << (size + 3);
- v.nused = nmalloc[size];
-
- for (p = nextf[size]; p; p = CHAIN (p))
- v.nfree++;
-
- return v;
-}
-int
-malloc_mem_used ()
-{
- int i;
- int size_used;
-
- size_used = 0;
-
- for (i = 0; i < 30; i++)
- {
- int allocation_size = 1 << (i + 3);
- struct mhead *p;
-
- size_used += nmalloc[i] * allocation_size;
- }
-
- return size_used;
-}
-
-int
-malloc_mem_free ()
-{
- int i;
- int size_unused;
-
- size_unused = 0;
-
- for (i = 0; i < 30; i++)
- {
- int allocation_size = 1 << (i + 3);
- struct mhead *p;
-
- for (p = nextf[i]; p ; p = CHAIN (p))
- size_unused += allocation_size;
- }
-
- return size_unused;
-}
-#endif /* MSTATS */
-
-/*
- * This function returns the total number of bytes that the process
- * will be allowed to allocate via the sbrk(2) system call. On
- * BSD systems this is the total space allocatable to stack and
- * data. On USG systems this is the data space only.
- */
-
-#ifdef USG
-
-get_lim_data ()
-{
- extern long ulimit ();
-
-#ifdef ULIMIT_BREAK_VALUE
- lim_data = ULIMIT_BREAK_VALUE;
-#else
- lim_data = ulimit (3, 0);
-#endif
-
- lim_data -= (long) data_space_start;
-}
-
-#else /* not USG */
-#if defined (BSD4_1) || defined (VMS)
-
-get_lim_data ()
-{
- lim_data = vlimit (LIM_DATA, -1);
-}
-
-#else /* not BSD4_1 and not VMS */
-
-get_lim_data ()
-{
- struct rlimit XXrlimit;
-
- getrlimit (RLIMIT_DATA, &XXrlimit);
-#ifdef RLIM_INFINITY
- lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
-#else
- lim_data = XXrlimit.rlim_cur; /* soft limit */
-#endif
-}
-
-#endif /* not BSD4_1 and not VMS */
-#endif /* not USG */
-
-#ifdef VMS
-/* There is a problem when dumping and restoring things on VMS. Calls
- * to SBRK don't necessarily result in contiguous allocation. Dumping
- * doesn't work when it isn't. Therefore, we make the initial
- * allocation contiguous by allocating a big chunk, and do SBRKs from
- * there. Once Emacs has dumped there is no reason to continue
- * contiguous allocation, malloc doesn't depend on it.
- *
- * There is a further problem of using brk and sbrk while using VMS C
- * run time library routines malloc, calloc, etc. The documentation
- * says that this is a no-no, although I'm not sure why this would be
- * a problem. In any case, we remove the necessity to call brk and
- * sbrk, by calling calloc (to assure zero filled data) rather than
- * sbrk.
- *
- * VMS_ALLOCATION_SIZE is the size of the allocation array. This
- * should be larger than the malloc size before dumping. Making this
- * too large will result in the startup procedure slowing down since
- * it will require more space and time to map it in.
- *
- * The value for VMS_ALLOCATION_SIZE in the following define was determined
- * by running emacs linked (and a large allocation) with the debugger and
- * looking to see how much storage was used. The allocation was 201 pages,
- * so I rounded it up to a power of two.
- */
-#ifndef VMS_ALLOCATION_SIZE
-#define VMS_ALLOCATION_SIZE (512*256)
-#endif
-
-/* Use VMS RTL definitions */
-#undef sbrk
-#undef brk
-#undef malloc
-int vms_out_initial = 0;
-char vms_initial_buffer[VMS_ALLOCATION_SIZE];
-static char *vms_current_brk = &vms_initial_buffer;
-static char *vms_end_brk = &vms_initial_buffer[VMS_ALLOCATION_SIZE-1];
-
-#include <stdio.h>
-
-char *
-sys_sbrk (incr)
- int incr;
-{
- char *sbrk(), *temp, *ptr;
-
- if (vms_out_initial)
- {
- /* out of initial allocation... */
- if (!(temp = malloc (incr)))
- temp = (char *) -1;
- }
- else
- {
- /* otherwise, go out of our area */
- ptr = vms_current_brk + incr; /* new current_brk */
- if (ptr <= vms_end_brk)
- {
- temp = vms_current_brk;
- vms_current_brk = ptr;
- }
- else
- {
- vms_out_initial = 1; /* mark as out of initial allocation */
- if (!(temp = malloc (incr)))
- temp = (char *) -1;
- }
- }
- return temp;
-}
-#endif /* VMS */
diff --git a/gnu/lib/libregex/test/fileregex.c b/gnu/lib/libregex/test/fileregex.c
deleted file mode 100644
index ba81062..0000000
--- a/gnu/lib/libregex/test/fileregex.c
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <sys/types.h>
-#include <stdio.h>
-#include "regex.h"
-
-#define BYTEWIDTH 8
-
-/* Sorry, but this is just a test program. */
-#define LINE_MAX 500
-
-int
-main (argc, argv)
- int argc;
- char *argv[];
-{
- FILE *f;
- char *filename;
- char pat[500]; /* Sorry for that maximum size, too. */
- char line[LINE_MAX];
- struct re_pattern_buffer buf;
- char fastmap[(1 << BYTEWIDTH)];
- const char *compile_ret;
- unsigned lineno = 1;
- unsigned nfound = 0;
-
- /* Actually, it might be useful to allow the data file to be standard
- input, and to specify the pattern on the command line. */
- if (argc != 2)
- {
- fprintf (stderr, "Usage: %s <filename>.\n", argv[0]);
- exit (1);
- }
-
- filename = argv[1];
- f = fopen (filename, "r");
- if (f == NULL)
- perror (filename);
-
- buf.allocated = 0;
- buf.buffer = NULL;
- buf.fastmap = fastmap;
-
- printf ("Pattern = ", pat);
- gets (pat);
-
- if (feof (stdin))
- {
- putchar ('\n');
- exit (0);
- }
-
- compile_ret = re_compile_pattern (pat, strlen (pat), &buf);
- if (compile_ret != NULL)
- {
- fprintf (stderr, "%s: %s\n", pat, compile_ret);
- exit (1);
- }
-
- while (fgets (line, LINE_MAX, f) != NULL)
- {
- size_t len = strlen (line);
- struct re_registers regs;
- int search_ret
- = re_search_2 (&buf, NULL, 0, line, len, 0, len, &regs, len);
-
- if (search_ret == -2)
- {
- fprintf (stderr, "%s:%d: re_search failed.\n", filename, lineno);
- exit (1);
- }
-
- nfound += search_ret != -1;
- lineno++;
- }
-
- printf ("Matches found: %u (out of %u lines).\n", nfound, lineno - 1);
- return 0;
-}
diff --git a/gnu/lib/libregex/test/g++malloc.c b/gnu/lib/libregex/test/g++malloc.c
deleted file mode 100644
index 88c181c5..0000000
--- a/gnu/lib/libregex/test/g++malloc.c
+++ /dev/null
@@ -1,1288 +0,0 @@
-#define inline
-
-/*
-Copyright (C) 1989 Free Software Foundation
- written by Doug Lea (dl@oswego.edu)
-
-This file is part of GNU CC.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY. No author or distributor
-accepts responsibility to anyone for the consequences of using it
-or for whether it serves any particular purpose or works at all,
-unless he says so in writing. Refer to the GNU CC General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-GNU CC, but only under the conditions described in the
-GNU CC General Public License. A copy of this license is
-supposed to have been given to you along with GNU CC so you
-can know your rights and responsibilities. It should be in a
-file named COPYING. Among other things, the copyright notice
-and this notice must be preserved on all copies.
-*/
-
-
-
-#ifndef NO_LIBGXX_MALLOC /* ignore whole file otherwise */
-
-/* compile with -DMALLOC_STATS to collect statistics */
-/* collecting statistics slows down malloc by at least 15% */
-
-#ifdef MALLOC_STATS
-#define UPDATE_STATS(ARGS) {ARGS;}
-#else
-#define UPDATE_STATS(ARGS)
-#endif
-
-/* History
-
-
- Tue Jan 16 04:54:27 1990 Doug Lea (dl at g.oswego.edu)
-
- version 1 released in libg++
-
- Sun Jan 21 05:52:47 1990 Doug Lea (dl at g.oswego.edu)
-
- bins are now own struct for, sanity.
-
- new victim search strategy: scan up and consolidate.
- Both faster and less fragmentation.
-
- refined when to scan bins for consolidation, via consollink, etc.
-
- realloc: always try to expand chunk, avoiding some fragmentation.
-
- changed a few inlines into macros
-
- hardwired SBRK_UNIT to 4096 for uniformity across systems
-
- Tue Mar 20 14:18:23 1990 Doug Lea (dl at g.oswego.edu)
-
- calloc and cfree now correctly parameterized.
-
- Sun Apr 1 10:00:48 1990 Doug Lea (dl at g.oswego.edu)
-
- added memalign and valloc.
-
- Sun Jun 24 05:46:48 1990 Doug Lea (dl at g.oswego.edu)
-
- #include gepagesize.h only ifndef sun
- cache pagesize after first call
-
- Wed Jul 25 08:35:19 1990 Doug Lea (dl at g.oswego.edu)
-
- No longer rely on a `designated victim':
-
- 1. It sometimes caused splits of large chunks
- when smaller ones would do, leading to
- bad worst-case fragmentation.
-
- 2. Scanning through the av array fast anyway,
- so the overhead isn't worth it.
-
- To compensate, several other minor changes:
-
- 1. Unusable chunks are checked for consolidation during
- searches inside bins, better distributing chunks
- across bins.
-
- 2. Chunks are returned when found in malloc_find_space,
- rather than finishing cleaning everything up, to
- avoid wasted iterations due to (1).
-*/
-
-/*
- A version of malloc/free/realloc tuned for C++ applications.
-
- Here's what you probably want to know first:
-
- In various tests, this appears to be about as fast as,
- and usually substantially less memory-wasteful than BSD/GNUemacs malloc.
-
- Generally, it is slower (by perhaps 20%) than bsd-style malloc
- only when bsd malloc would waste a great deal of space in
- fragmented blocks, which this malloc recovers; or when, by
- chance or design, nearly all requests are near the bsd malloc
- power-of-2 allocation bin boundaries, and as many chunks are
- used as are allocated.
-
- It uses more space than bsd malloc only when, again by chance
- or design, only bsdmalloc bin-sized requests are malloced, or when
- little dynamic space is malloced, since this malloc may grab larger
- chunks from the system at a time than bsd.
-
- In other words, this malloc seems generally superior to bsd
- except perhaps for programs that are specially tuned to
- deal with bsdmalloc's characteristics. But even here, the
- performance differences are slight.
-
-
- This malloc, like any other, is a compromised design.
-
-
- Chunks of memory are maintained using a `boundary tag' method as
- described in e.g., Knuth or Standish. This means that the size of
- the chunk is stored both in the front of the chunk and at the end.
- This makes consolidating fragmented chunks into bigger chunks very fast.
- The size field is also used to hold bits representing whether a
- chunk is free or in use.
-
- Malloced chunks have space overhead of 8 bytes: The preceding
- and trailing size fields. When they are freed, the list pointer
- fields are also needed.
-
- Available chunks are kept in doubly linked lists. The lists are
- maintained in an array of bins using a power-of-two method, except
- that instead of 32 bins (one for each 1 << i), there are 128: each
- power of two is split in quarters. The use of very fine bin sizes
- closely approximates the use of one bin per actually used size,
- without necessitating the overhead of locating such bins. It is
- especially desirable in common C++ applications where large numbers
- of identically-sized blocks are malloced/freed in some dynamic
- manner, and then later are all freed. The finer bin sizes make
- finding blocks fast, with little wasted overallocation. The
- consolidation methods ensure that once the collection of blocks is
- no longer useful, fragments are gathered into bigger chunks awaiting new
- roles.
-
- The bins av[i] serve as heads of the lists. Bins contain a dummy
- header for the chunk lists, and a `dirty' field used to indicate
- whether the list may need to be scanned for consolidation.
-
- On allocation, the bin corresponding to the request size is
- scanned, and if there is a chunk with size >= requested, it
- is split, if too big, and used. Chunks on the list which are
- too small are examined for consolidation during this traversal.
-
- If no chunk exists in the list bigger bins are scanned in search of
- a victim.
-
- If no victim can be found, then smaller bins are examined for
- consolidation in order to construct a victim.
-
- Finally, if consolidation fails to come up with a usable chunk,
- more space is obtained from the system.
-
- After a split, the remainder is placed on
- the back of the appropriate bin list. (All freed chunks are placed
- on fronts of lists. All remaindered or consolidated chunks are
- placed on the rear. Correspondingly, searching within a bin
- starts at the front, but finding victims is from the back. All
- of this approximates the effect of having 2 kinds of lists per
- bin: returned chunks vs unallocated chunks, but without the overhead
- of maintaining 2 lists.)
-
- Deallocation (free) consists only of placing the chunk on
- a list.
-
- Reallocation proceeds in the usual way. If a chunk can be extended,
- it is, else a malloc-copy-free sequence is taken.
-
- memalign requests more than enough space from malloc, finds a
- spot within that chunk that meets the alignment request, and
- then possibly frees the leading and trailing space. Overreliance
- on memalign is a sure way to fragment space.
-
-
- Some other implementation matters:
-
- 8 byte alignment is currently hardwired into the design. Calling
- memalign will return a chunk that is both 8-byte aligned, and
- meets the requested alignment.
-
- The basic overhead of a used chunk is 8 bytes: 4 at the front and
- 4 at the end.
-
- When a chunk is free, 8 additional bytes are needed for free list
- pointers. Thus, the minimum allocatable size is 16 bytes.
-
- The existence of front and back overhead permits some reasonably
- effective fence-bashing checks: The front and back fields must
- be identical. This is checked only within free() and realloc().
- The checks are fast enough to be made non-optional.
-
- The overwriting of parts of freed memory with the freelist pointers
- can also be very effective (albeit in an annoying way) in helping
- users track down dangling pointers.
-
- User overwriting of freed space will often result in crashes
- within malloc or free.
-
- These routines are also tuned to C++ in that free(0) is a noop and
- a failed malloc automatically calls (*new_handler)().
-
- malloc(0) returns a pointer to something of the minimum allocatable size.
-
- Additional memory is gathered from the system (via sbrk) in a
- way that allows chunks obtained across different sbrk calls to
- be consolidated, but does not require contiguous memory: Thus,
- it should be safe to intersperse mallocs with other sbrk calls.
-
- This malloc is NOT designed to work in multiprocessing applications.
- No semaphores or other concurrency control are provided to ensure
- that multiple malloc or free calls don't run at the same time,
- which could be disasterous.
-
- VERY heavy use of inlines is made, for clarity. If this malloc
- is ported via a compiler without inlining capabilities, all
- inlines should be transformed into macros -- making them non-inline
- makes malloc at least twice as slow.
-
-
-*/
-
-
-/* preliminaries */
-
-#ifdef __cplusplus
-#include <stdio.h>
-#else
-#include "//usr/include/stdio.h" /* needed for error reporting */
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef USG
-extern void* memset(void*, int, int);
-extern void* memcpy(void*, const void*, int);
-/*inline void bzero(void* s, int l) { memset(s, 0, l); }*/
-#else
-/*extern void bzero(void*, unsigned int);*/
-#endif
-
-/*extern void bcopy(void*, void*, unsigned int);*/
-
-extern void* sbrk(unsigned int);
-
-/* Put this in instead of commmented out stuff above. */
-#define bcopy(s,d,n) memcpy((d),(s),(n))
-#define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
-#define bzero(s,n) memset((s),0,(n))
-
-
-#ifdef __GNUC__
-extern volatile void abort();
-#else
-extern void abort();
-#endif
-
-#ifdef __cplusplus
-}; /* end of extern "C" */
-#endif
-
-
-/* A good multiple to call sbrk with */
-
-#define SBRK_UNIT 4096
-
-
-
-/* how to die on detected error */
-
-#ifdef __GNUC__
-static volatile void malloc_user_error()
-#else
-static void malloc_user_error()
-#endif
-{
- fputs("malloc/free/realloc: clobbered space detected\n", stderr); abort();
-}
-
-
-
-/* Basic overhead for each malloc'ed chunk */
-
-
-struct malloc_chunk
-{
- unsigned int size; /* Size in bytes, including overhead. */
- /* Or'ed with INUSE if in use. */
-
- struct malloc_chunk* fd; /* double links -- used only if free. */
- struct malloc_chunk* bk;
-
-};
-
-typedef struct malloc_chunk* mchunkptr;
-
-struct malloc_bin
-{
- struct malloc_chunk hd; /* dummy list header */
- unsigned int dirty; /* True if maybe consolidatable */
- /* Wasting a word here makes */
- /* sizeof(bin) a power of 2, */
- /* which makes size2bin() faster */
-};
-
-typedef struct malloc_bin* mbinptr;
-
-
-/* sizes, alignments */
-
-
-#define SIZE_SZ (sizeof(unsigned int))
-#define MALLOC_MIN_OVERHEAD (SIZE_SZ + SIZE_SZ)
-#define MALLOC_ALIGN_MASK (MALLOC_MIN_OVERHEAD - 1)
-
-#define MINSIZE (sizeof(struct malloc_chunk) + SIZE_SZ) /* MUST == 16! */
-
-
-/* pad request bytes into a usable size */
-
-static inline unsigned int request2size(unsigned int request)
-{
- return (request == 0) ? MINSIZE :
- ((request + MALLOC_MIN_OVERHEAD + MALLOC_ALIGN_MASK)
- & ~(MALLOC_ALIGN_MASK));
-}
-
-
-static inline int aligned_OK(void* m)
-{
- return ((unsigned int)(m) & (MALLOC_ALIGN_MASK)) == 0;
-}
-
-
-/* size field or'd with INUSE when in use */
-#define INUSE 0x1
-
-
-
-/* the bins, initialized to have null double linked lists */
-
-#define MAXBIN 120 /* 1 more than needed for 32 bit addresses */
-
-#define FIRSTBIN (&(av[0]))
-
-static struct malloc_bin av[MAXBIN] =
-{
- { { 0, &(av[0].hd), &(av[0].hd) }, 0 },
- { { 0, &(av[1].hd), &(av[1].hd) }, 0 },
- { { 0, &(av[2].hd), &(av[2].hd) }, 0 },
- { { 0, &(av[3].hd), &(av[3].hd) }, 0 },
- { { 0, &(av[4].hd), &(av[4].hd) }, 0 },
- { { 0, &(av[5].hd), &(av[5].hd) }, 0 },
- { { 0, &(av[6].hd), &(av[6].hd) }, 0 },
- { { 0, &(av[7].hd), &(av[7].hd) }, 0 },
- { { 0, &(av[8].hd), &(av[8].hd) }, 0 },
- { { 0, &(av[9].hd), &(av[9].hd) }, 0 },
-
- { { 0, &(av[10].hd), &(av[10].hd) }, 0 },
- { { 0, &(av[11].hd), &(av[11].hd) }, 0 },
- { { 0, &(av[12].hd), &(av[12].hd) }, 0 },
- { { 0, &(av[13].hd), &(av[13].hd) }, 0 },
- { { 0, &(av[14].hd), &(av[14].hd) }, 0 },
- { { 0, &(av[15].hd), &(av[15].hd) }, 0 },
- { { 0, &(av[16].hd), &(av[16].hd) }, 0 },
- { { 0, &(av[17].hd), &(av[17].hd) }, 0 },
- { { 0, &(av[18].hd), &(av[18].hd) }, 0 },
- { { 0, &(av[19].hd), &(av[19].hd) }, 0 },
-
- { { 0, &(av[20].hd), &(av[20].hd) }, 0 },
- { { 0, &(av[21].hd), &(av[21].hd) }, 0 },
- { { 0, &(av[22].hd), &(av[22].hd) }, 0 },
- { { 0, &(av[23].hd), &(av[23].hd) }, 0 },
- { { 0, &(av[24].hd), &(av[24].hd) }, 0 },
- { { 0, &(av[25].hd), &(av[25].hd) }, 0 },
- { { 0, &(av[26].hd), &(av[26].hd) }, 0 },
- { { 0, &(av[27].hd), &(av[27].hd) }, 0 },
- { { 0, &(av[28].hd), &(av[28].hd) }, 0 },
- { { 0, &(av[29].hd), &(av[29].hd) }, 0 },
-
- { { 0, &(av[30].hd), &(av[30].hd) }, 0 },
- { { 0, &(av[31].hd), &(av[31].hd) }, 0 },
- { { 0, &(av[32].hd), &(av[32].hd) }, 0 },
- { { 0, &(av[33].hd), &(av[33].hd) }, 0 },
- { { 0, &(av[34].hd), &(av[34].hd) }, 0 },
- { { 0, &(av[35].hd), &(av[35].hd) }, 0 },
- { { 0, &(av[36].hd), &(av[36].hd) }, 0 },
- { { 0, &(av[37].hd), &(av[37].hd) }, 0 },
- { { 0, &(av[38].hd), &(av[38].hd) }, 0 },
- { { 0, &(av[39].hd), &(av[39].hd) }, 0 },
-
- { { 0, &(av[40].hd), &(av[40].hd) }, 0 },
- { { 0, &(av[41].hd), &(av[41].hd) }, 0 },
- { { 0, &(av[42].hd), &(av[42].hd) }, 0 },
- { { 0, &(av[43].hd), &(av[43].hd) }, 0 },
- { { 0, &(av[44].hd), &(av[44].hd) }, 0 },
- { { 0, &(av[45].hd), &(av[45].hd) }, 0 },
- { { 0, &(av[46].hd), &(av[46].hd) }, 0 },
- { { 0, &(av[47].hd), &(av[47].hd) }, 0 },
- { { 0, &(av[48].hd), &(av[48].hd) }, 0 },
- { { 0, &(av[49].hd), &(av[49].hd) }, 0 },
-
- { { 0, &(av[50].hd), &(av[50].hd) }, 0 },
- { { 0, &(av[51].hd), &(av[51].hd) }, 0 },
- { { 0, &(av[52].hd), &(av[52].hd) }, 0 },
- { { 0, &(av[53].hd), &(av[53].hd) }, 0 },
- { { 0, &(av[54].hd), &(av[54].hd) }, 0 },
- { { 0, &(av[55].hd), &(av[55].hd) }, 0 },
- { { 0, &(av[56].hd), &(av[56].hd) }, 0 },
- { { 0, &(av[57].hd), &(av[57].hd) }, 0 },
- { { 0, &(av[58].hd), &(av[58].hd) }, 0 },
- { { 0, &(av[59].hd), &(av[59].hd) }, 0 },
-
- { { 0, &(av[60].hd), &(av[60].hd) }, 0 },
- { { 0, &(av[61].hd), &(av[61].hd) }, 0 },
- { { 0, &(av[62].hd), &(av[62].hd) }, 0 },
- { { 0, &(av[63].hd), &(av[63].hd) }, 0 },
- { { 0, &(av[64].hd), &(av[64].hd) }, 0 },
- { { 0, &(av[65].hd), &(av[65].hd) }, 0 },
- { { 0, &(av[66].hd), &(av[66].hd) }, 0 },
- { { 0, &(av[67].hd), &(av[67].hd) }, 0 },
- { { 0, &(av[68].hd), &(av[68].hd) }, 0 },
- { { 0, &(av[69].hd), &(av[69].hd) }, 0 },
-
- { { 0, &(av[70].hd), &(av[70].hd) }, 0 },
- { { 0, &(av[71].hd), &(av[71].hd) }, 0 },
- { { 0, &(av[72].hd), &(av[72].hd) }, 0 },
- { { 0, &(av[73].hd), &(av[73].hd) }, 0 },
- { { 0, &(av[74].hd), &(av[74].hd) }, 0 },
- { { 0, &(av[75].hd), &(av[75].hd) }, 0 },
- { { 0, &(av[76].hd), &(av[76].hd) }, 0 },
- { { 0, &(av[77].hd), &(av[77].hd) }, 0 },
- { { 0, &(av[78].hd), &(av[78].hd) }, 0 },
- { { 0, &(av[79].hd), &(av[79].hd) }, 0 },
-
- { { 0, &(av[80].hd), &(av[80].hd) }, 0 },
- { { 0, &(av[81].hd), &(av[81].hd) }, 0 },
- { { 0, &(av[82].hd), &(av[82].hd) }, 0 },
- { { 0, &(av[83].hd), &(av[83].hd) }, 0 },
- { { 0, &(av[84].hd), &(av[84].hd) }, 0 },
- { { 0, &(av[85].hd), &(av[85].hd) }, 0 },
- { { 0, &(av[86].hd), &(av[86].hd) }, 0 },
- { { 0, &(av[87].hd), &(av[87].hd) }, 0 },
- { { 0, &(av[88].hd), &(av[88].hd) }, 0 },
- { { 0, &(av[89].hd), &(av[89].hd) }, 0 },
-
- { { 0, &(av[90].hd), &(av[90].hd) }, 0 },
- { { 0, &(av[91].hd), &(av[91].hd) }, 0 },
- { { 0, &(av[92].hd), &(av[92].hd) }, 0 },
- { { 0, &(av[93].hd), &(av[93].hd) }, 0 },
- { { 0, &(av[94].hd), &(av[94].hd) }, 0 },
- { { 0, &(av[95].hd), &(av[95].hd) }, 0 },
- { { 0, &(av[96].hd), &(av[96].hd) }, 0 },
- { { 0, &(av[97].hd), &(av[97].hd) }, 0 },
- { { 0, &(av[98].hd), &(av[98].hd) }, 0 },
- { { 0, &(av[99].hd), &(av[99].hd) }, 0 },
-
- { { 0, &(av[100].hd), &(av[100].hd) }, 0 },
- { { 0, &(av[101].hd), &(av[101].hd) }, 0 },
- { { 0, &(av[102].hd), &(av[102].hd) }, 0 },
- { { 0, &(av[103].hd), &(av[103].hd) }, 0 },
- { { 0, &(av[104].hd), &(av[104].hd) }, 0 },
- { { 0, &(av[105].hd), &(av[105].hd) }, 0 },
- { { 0, &(av[106].hd), &(av[106].hd) }, 0 },
- { { 0, &(av[107].hd), &(av[107].hd) }, 0 },
- { { 0, &(av[108].hd), &(av[108].hd) }, 0 },
- { { 0, &(av[109].hd), &(av[109].hd) }, 0 },
-
- { { 0, &(av[110].hd), &(av[110].hd) }, 0 },
- { { 0, &(av[111].hd), &(av[111].hd) }, 0 },
- { { 0, &(av[112].hd), &(av[112].hd) }, 0 },
- { { 0, &(av[113].hd), &(av[113].hd) }, 0 },
- { { 0, &(av[114].hd), &(av[114].hd) }, 0 },
- { { 0, &(av[115].hd), &(av[115].hd) }, 0 },
- { { 0, &(av[116].hd), &(av[116].hd) }, 0 },
- { { 0, &(av[117].hd), &(av[117].hd) }, 0 },
- { { 0, &(av[118].hd), &(av[118].hd) }, 0 },
- { { 0, &(av[119].hd), &(av[119].hd) }, 0 }
-};
-
-/*
- indexing into bins
-*/
-
-static inline mbinptr size2bin(unsigned int sz)
-{
- mbinptr b = av;
- while (sz >= (MINSIZE * 2)) { b += 4; sz >>= 1; } /* find power of 2 */
- b += (sz - MINSIZE) >> 2; /* find quadrant */
- return b;
-}
-
-
-
-/* counts maintained if MALLOC_STATS defined */
-
-#ifdef MALLOC_STATS
-
-static unsigned int sbrked_mem;
-static unsigned int requested_mem;
-static unsigned int malloced_mem;
-static unsigned int freed_mem;
-static unsigned int max_used_mem;
-
-static unsigned int n_sbrks;
-static unsigned int n_mallocs;
-static unsigned int n_frees;
-static unsigned int n_reallocs;
-static unsigned int n_reallocs_with_copy;
-static unsigned int n_avail;
-static unsigned int max_inuse;
-
-static unsigned int n_malloc_chunks;
-static unsigned int n_malloc_bins;
-
-static unsigned int n_split;
-static unsigned int n_consol;
-
-
-static void do_malloc_stats(const mchunkptr p)
-{
- ++n_mallocs;
- if ((n_mallocs-n_frees) > max_inuse)
- max_inuse = n_mallocs - n_frees;
- malloced_mem += (p->size & ~(INUSE));
- if (malloced_mem - freed_mem > max_used_mem)
- max_used_mem = malloced_mem - freed_mem;
-}
-
-static void do_free_stats(const mchunkptr p)
-{
- ++n_frees;
- freed_mem += (p->size & ~(INUSE));
-}
-
-#endif
-
-
-
-/* Utilities needed below for memalign */
-/* This is redundant with libg++ support, but not if used stand-alone */
-
-static unsigned int gcd(unsigned int a, unsigned int b)
-{
- unsigned int tmp;
-
- if (b > a)
- {
- tmp = a; a = b; b = tmp;
- }
- for(;;)
- {
- if (b == 0)
- return a;
- else if (b == 1)
- return b;
- else
- {
- tmp = b;
- b = a % b;
- a = tmp;
- }
- }
-}
-
-static inline unsigned int lcm(unsigned int x, unsigned int y)
-{
- return x / gcd(x, y) * y;
-}
-
-
-
-/* maintaining INUSE via size field */
-
-
-#define inuse(p) ((p)->size & INUSE)
-#define set_inuse(p) ((p)->size |= INUSE)
-#define clear_inuse(b) ((p)->size &= ~INUSE)
-
-
-/* operations on malloc_chunk addresses */
-
-
-/* return ptr to next physical malloc_chunk */
-
-#define next_chunk(p) ((mchunkptr)((char*)(p) + (p)->size))
-
-/* return ptr to previous physical malloc_chunk */
-
-#define prev_chunk(p) ((mchunkptr)((char*)(p)-((((int*)(p))[-1]) & ~(INUSE))))
-
-/* place size at front and back of chunk */
-
-
-static inline void set_size(mchunkptr p, unsigned int sz)
-{
- p->size = *((int*)((char*)(p) + sz - SIZE_SZ)) = sz;
-}
-
-
-
-
-/* conversion from malloc headers to user pointers, and back */
-
-static inline void* chunk2mem(mchunkptr p)
-{
- void *mem;
- set_inuse(p);
-mem = (void*)((char*)(p) + SIZE_SZ);
- return mem;
-}
-
-/* xxxx my own */
-mchunkptr sanity_check(void* mem)
-{
- mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ);
-
- /* a quick sanity check */
- unsigned int sz = p->size & ~(INUSE);
- if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ)))
- malloc_user_error();
-
- return p;
-}
-
-
-
-
-static inline mchunkptr mem2chunk(void* mem)
-{
- mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ);
-
- /* a quick sanity check */
- unsigned int sz = p->size & ~(INUSE);
- if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ)))
- malloc_user_error();
-
- p->size = sz; /* clears INUSE */
- return p;
-}
-
-
-
-/* maintaining bins & pointers */
-
-
-/* maximum bin actually used */
-
-static mbinptr malloc_maxbin = FIRSTBIN;
-
-
-/* operations on lists inside bins */
-
-
-/* take a chunk off a list */
-
-static inline void unlink(mchunkptr p)
-{
- mchunkptr b = p->bk;
- mchunkptr f = p->fd;
-
- f->bk = b; b->fd = f;
-
- UPDATE_STATS (--n_avail);
-}
-
-
-
-/* split a chunk and place on the back of a list */
-
-static inline void split(mchunkptr p, unsigned int offset)
-{
- unsigned int room = p->size - offset;
- if (room >= MINSIZE)
- {
- mbinptr bn = size2bin(room); /* new bin */
- mchunkptr h = &(bn->hd); /* its head */
- mchunkptr b = h->bk; /* old back element */
- mchunkptr t = (mchunkptr)((char*)(p) + offset); /* remaindered chunk */
-
- /* set size */
- t->size = *((int*)((char*)(t) + room - SIZE_SZ)) = room;
-
- /* link up */
- t->bk = b; t->fd = h; h->bk = b->fd = t;
-
- /* adjust maxbin (h == b means was empty) */
- if (h == b && bn > malloc_maxbin) malloc_maxbin = bn;
-
- /* adjust size of chunk to be returned */
- p->size = *((int*)((char*)(p) + offset - SIZE_SZ)) = offset;
-
- UPDATE_STATS ((++n_split, ++n_avail));
- }
-}
-
-
-
-/* place a consolidated chunk on the back of a list */
-/* like above, except no split */
-
-static inline void consollink(mchunkptr p)
-{
- mbinptr bn = size2bin(p->size);
- mchunkptr h = &(bn->hd);
- mchunkptr b = h->bk;
-
- p->bk = b; p->fd = h; h->bk = b->fd = p;
-
- if (h == b && bn > malloc_maxbin) malloc_maxbin = bn;
-
- UPDATE_STATS(++n_avail);
-}
-
-
-/* place a freed chunk on the front of a list */
-
-static inline void frontlink(mchunkptr p)
-{
- mbinptr bn = size2bin(p->size);
- mchunkptr h = &(bn->hd);
- mchunkptr f = h->fd;
-
- p->bk = h; p->fd = f; f->bk = h->fd = p;
-
- if (h == f && bn > malloc_maxbin) malloc_maxbin = bn;
-
- bn->dirty = 1;
-
- UPDATE_STATS(++n_avail);
-}
-
-
-
-/* Dealing with sbrk */
-
-
-/* To link consecutive sbrk regions when possible */
-
-static int* last_sbrk_end;
-
-
-/* who to call when sbrk returns failure */
-
-#ifndef NO_NEW_HANDLER
-typedef volatile void (*vfp)();
-#ifdef __cplusplus
-extern "C" vfp __new_handler;
-#else
-extern vfp __new_handler;
-#endif
-#endif
-
-static mchunkptr malloc_from_sys(unsigned nb)
-{
- mchunkptr p;
- unsigned int sbrk_size;
- int* ip;
-
- /* Minimally, we need to pad with enough space */
- /* to place dummy size/use fields to ends if needed */
-
- sbrk_size = ((nb + SBRK_UNIT - 1 + SIZE_SZ + SIZE_SZ)
- / SBRK_UNIT) * SBRK_UNIT;
-
- ip = (int*)(sbrk(sbrk_size));
- if ((char*)ip == (char*)(-1)) /* sbrk returns -1 on failure */
- {
-#ifndef NO_NEW_HANDLER
- (*__new_handler) ();
-#endif
- return 0;
- }
-
- UPDATE_STATS ((++n_sbrks, sbrked_mem += sbrk_size));
-
-
- if (last_sbrk_end != &ip[-1])
- {
- /* It's either first time through or someone else called sbrk. */
- /* Arrange end-markers at front & back */
-
- /* Shouldn't be necessary, but better to be safe */
- while (!aligned_OK(ip)) { ++ip; sbrk_size -= SIZE_SZ; }
-
-
- /* Mark the front as in use to prevent merging. */
- /* Note we can get away with only 1 word, not MINSIZE overhead here */
-
- *ip++ = SIZE_SZ | INUSE;
-
- p = (mchunkptr)ip;
- set_size(p,sbrk_size - (SIZE_SZ + SIZE_SZ));
-
- }
- else
- {
- mchunkptr l;
-
- /* We can safely make the header start at end of prev sbrked chunk. */
- /* We will still have space left at the end from a previous call */
- /* to place the end marker, below */
-
- p = (mchunkptr)(last_sbrk_end);
- set_size(p, sbrk_size);
-
-
- /* Even better, maybe we can merge with last fragment: */
-
- l = prev_chunk(p);
- if (!inuse(l))
- {
- unlink(l);
- set_size(l, p->size + l->size);
- p = l;
- }
-
- }
-
- /* mark the end of sbrked space as in use to prevent merging */
-
- last_sbrk_end = (int*)((char*)p + p->size);
- *last_sbrk_end = SIZE_SZ | INUSE;
-
- UPDATE_STATS((++n_avail, ++n_malloc_chunks));
-
- /* make it safe to unlink in malloc */
- UPDATE_STATS(++n_avail);
- p->fd = p->bk = p;
-
- return p;
-}
-
-
-
-/* Consolidate dirty bins. */
-/* Stop if found a chunk big enough to satisfy current malloc request */
-
-/* (It requires much less bookkeeping to consolidate entire bins */
-/* at once than to keep records of which chunks might be */
-/* consolidatable. So long as the lists are short, which we */
-/* try to ensure via small bin ranges, there is little wasted effort.) */
-
-static mchunkptr malloc_find_space(unsigned int nb)
-{
- mbinptr b;
-
- /* first, re-adjust max used bin */
-
- while (malloc_maxbin >= FIRSTBIN &&
- malloc_maxbin->hd.bk == &(malloc_maxbin->hd))
- {
- malloc_maxbin->dirty = 0;
- --malloc_maxbin;
- }
-
- for (b = malloc_maxbin; b >= FIRSTBIN; --b)
- {
- UPDATE_STATS(++n_malloc_bins);
-
- if (b->dirty)
- {
- mchunkptr h = &(b->hd); /* head of list */
- mchunkptr p = h->fd; /* chunk traverser */
-
- while (p != h)
- {
- mchunkptr nextp = p->fd; /* save, in case of relinks */
- int consolidated = 0; /* only unlink/relink if consolidated */
-
- mchunkptr t;
-
- UPDATE_STATS(++n_malloc_chunks);
-
- while (!inuse(t = prev_chunk(p))) /* consolidate backward */
- {
- if (!consolidated) { consolidated = 1; unlink(p); }
- if (t == nextp) nextp = t->fd;
- unlink(t);
- set_size(t, t->size + p->size);
- p = t;
- UPDATE_STATS (++n_consol);
- }
-
- while (!inuse(t = next_chunk(p))) /* consolidate forward */
- {
- if (!consolidated) { consolidated = 1; unlink(p); }
- if (t == nextp) nextp = t->fd;
- unlink(t);
- set_size(p, p->size + t->size);
- UPDATE_STATS (++n_consol);
- }
-
- if (consolidated)
- {
- if (p->size >= nb)
- {
- /* make it safe to unlink in malloc */
- UPDATE_STATS(++n_avail);
- p->fd = p->bk = p;
- return p;
- }
- else
- consollink(p);
- }
-
- p = nextp;
-
- }
-
- b->dirty = 0;
-
- }
- }
-
- /* nothing available - sbrk some more */
-
- return malloc_from_sys(nb);
-}
-
-
-
-/* Finally, the user-level functions */
-
-void* malloc(unsigned int bytes)
-{
- unsigned int nb = request2size(bytes); /* padded request size */
- mbinptr b = size2bin(nb); /* corresponding bin */
- mchunkptr hd = &(b->hd); /* head of its list */
- mchunkptr p = hd->fd; /* chunk traverser */
-
- UPDATE_STATS((requested_mem+=bytes, ++n_malloc_bins));
-
- /* Try a (near) exact match in own bin */
- /* clean out unusable but consolidatable chunks in bin while traversing */
-
- while (p != hd)
- {
- UPDATE_STATS(++n_malloc_chunks);
- if (p->size >= nb)
- goto found;
- else /* try to consolidate; same code as malloc_find_space */
- {
- mchunkptr nextp = p->fd; /* save, in case of relinks */
- int consolidated = 0; /* only unlink/relink if consolidated */
-
- mchunkptr t;
-
- while (!inuse(t = prev_chunk(p))) /* consolidate backward */
- {
- if (!consolidated) { consolidated = 1; unlink(p); }
- if (t == nextp) nextp = t->fd;
- unlink(t);
- set_size(t, t->size + p->size);
- p = t;
- UPDATE_STATS (++n_consol);
- }
-
- while (!inuse(t = next_chunk(p))) /* consolidate forward */
- {
- if (!consolidated) { consolidated = 1; unlink(p); }
- if (t == nextp) nextp = t->fd;
- unlink(t);
- set_size(p, p->size + t->size);
- UPDATE_STATS (++n_consol);
- }
-
- if (consolidated)
- {
- if (p->size >= nb)
- {
- /* make it safe to unlink again below */
- UPDATE_STATS(++n_avail);
- p->fd = p->bk = p;
- goto found;
- }
- else
- consollink(p);
- }
-
- p = nextp;
-
- }
- }
-
- b->dirty = 0; /* true if got here */
-
- /* Scan bigger bins for a victim */
-
- while (++b <= malloc_maxbin)
- {
- UPDATE_STATS(++n_malloc_bins);
- if ((p = b->hd.bk) != &(b->hd)) /* no need to check size */
- goto found;
- }
-
- /* Consolidate or sbrk */
-
- p = malloc_find_space(nb);
-
- if (p == 0) return 0; /* allocation failure */
-
- found: /* Use what we found */
-
- unlink(p);
- split(p, nb);
- UPDATE_STATS(do_malloc_stats(p));
- return chunk2mem(p);
-}
-
-
-
-
-void free(void* mem)
-{
- if (mem != 0)
- {
- mchunkptr p = mem2chunk(mem);
- UPDATE_STATS(do_free_stats(p));
- frontlink(p);
- }
-}
-
-
-void* calloc(unsigned int n, unsigned int elem_size)
-{
- unsigned int sz = n * elem_size;
- void* p = malloc(sz);
- bzero(p, sz);
- return p;
-};
-
-/* This is here for compatibility with older systems */
-void cfree(void *mem)
-{
- free(mem);
-}
-
-
-unsigned int malloc_usable_size(void* mem)
-{
- if (mem == 0)
- return 0;
- else
- {
- mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ);
- unsigned int sz = p->size & ~(INUSE);
- if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ)))
- return 0;
- else
- return sz - MALLOC_MIN_OVERHEAD;
- }
-}
-
-
-
-void* realloc(void* mem, unsigned int bytes)
-{
- if (mem == 0)
- return malloc(bytes);
- else
- {
- unsigned int nb = request2size(bytes);
- mchunkptr p = mem2chunk(mem);
- unsigned int oldsize = p->size;
- int room;
- mchunkptr nxt;
-
- UPDATE_STATS((++n_reallocs, requested_mem += bytes-oldsize));
-
- /* try to expand (even if already big enough), to clean up chunk */
-
- while (!inuse(nxt = next_chunk(p)))
- {
- UPDATE_STATS ((malloced_mem += nxt->size, ++n_consol));
- unlink(nxt);
- set_size(p, p->size + nxt->size);
- }
-
- room = p->size - nb;
- if (room >= 0)
- {
- split(p, nb);
- UPDATE_STATS(malloced_mem -= room);
- return chunk2mem(p);
- }
- else /* do the obvious */
- {
- void* newmem;
- set_inuse(p); /* don't let malloc consolidate us yet! */
- newmem = malloc(nb);
- bcopy(mem, newmem, oldsize - SIZE_SZ);
- free(mem);
- UPDATE_STATS(++n_reallocs_with_copy);
- return newmem;
- }
- }
-}
-
-
-
-/* return a pointer to space with at least the alignment requested */
-
-void* memalign(unsigned int alignment, unsigned int bytes)
-{
- mchunkptr p;
- unsigned int nb = request2size(bytes);
-
- /* find an alignment that both we and the user can live with: */
- /* least common multiple guarantees mutual happiness */
- unsigned int align = lcm(alignment, MALLOC_MIN_OVERHEAD);
- unsigned int mask = align - 1;
-
- /* call malloc with worst case padding to hit alignment; */
- /* we will give back extra */
-
- unsigned int req = nb + align + MINSIZE;
- void* m = malloc(req);
-
- if (m == 0) return m;
-
- p = mem2chunk(m);
-
- /* keep statistics on track */
-
- UPDATE_STATS(--n_mallocs);
- UPDATE_STATS(malloced_mem -= p->size);
- UPDATE_STATS(requested_mem -= req);
- UPDATE_STATS(requested_mem += bytes);
-
- if (((int)(m) & (mask)) != 0) /* misaligned */
- {
-
- /* find an aligned spot inside chunk */
-
- mchunkptr ap = (mchunkptr)(( ((int)(m) + mask) & -align) - SIZE_SZ);
-
- unsigned int gap = (unsigned int)(ap) - (unsigned int)(p);
- unsigned int room;
-
- /* we need to give back leading space in a chunk of at least MINSIZE */
-
- if (gap < MINSIZE)
- {
- /* This works since align >= MINSIZE */
- /* and we've malloc'd enough total room */
-
- ap = (mchunkptr)( (int)(ap) + align );
- gap += align;
- }
-
- if (gap + nb > p->size) /* can't happen unless chunk sizes corrupted */
- malloc_user_error();
-
- room = p->size - gap;
-
- /* give back leader */
- set_size(p, gap);
- consollink(p);
-
- /* use the rest */
- p = ap;
- set_size(p, room);
- }
-
- /* also give back spare room at the end */
-
- split(p, nb);
- UPDATE_STATS(do_malloc_stats(p));
- return chunk2mem(p);
-
-}
-
-#ifndef sun
-#include "getpagesize.h"
-#endif
-
-static unsigned int malloc_pagesize = 0;
-
-void* valloc(unsigned int bytes)
-{
- if (malloc_pagesize == 0) malloc_pagesize = getpagesize();
- return memalign (malloc_pagesize, bytes);
-}
-
-
-void malloc_stats()
-{
-#ifndef MALLOC_STATS
-}
-#else
- int i;
- mchunkptr p;
- double nm = (double)(n_mallocs + n_reallocs);
-
- fprintf(stderr, "\nmalloc statistics\n\n");
-
- if (n_mallocs != 0)
- fprintf(stderr, "requests = %10u total size = %10u\tave = %10u\n",
- n_mallocs, requested_mem, requested_mem/n_mallocs);
-
- if (n_mallocs != 0)
- fprintf(stderr, "mallocs = %10u total size = %10u\tave = %10u\n",
- n_mallocs, malloced_mem, malloced_mem/n_mallocs);
-
- if (n_frees != 0)
- fprintf(stderr, "frees = %10u total size = %10u\tave = %10u\n",
- n_frees, freed_mem, freed_mem/n_frees);
-
- if (n_mallocs-n_frees != 0)
- fprintf(stderr, "in use = %10u total size = %10u\tave = %10u\n",
- n_mallocs-n_frees, malloced_mem-freed_mem,
- (malloced_mem-freed_mem) / (n_mallocs-n_frees));
-
- if (max_inuse != 0)
- fprintf(stderr, "max in use= %10u total size = %10u\tave = %10u\n",
- max_inuse, max_used_mem, max_used_mem / max_inuse);
-
- if (n_avail != 0)
- fprintf(stderr, "available = %10u total size = %10u\tave = %10u\n",
- n_avail, sbrked_mem - (malloced_mem-freed_mem),
- (sbrked_mem - (malloced_mem-freed_mem)) / n_avail);
-
- if (n_sbrks != 0)
- fprintf(stderr, "sbrks = %10u total size = %10u\tave = %10u\n\n",
- n_sbrks, sbrked_mem, sbrked_mem/ n_sbrks);
-
- if (n_reallocs != 0)
- fprintf(stderr, "reallocs = %10u with copy = %10u\n\n",
- n_reallocs, n_reallocs_with_copy);
-
-
- if (nm != 0)
- {
- fprintf(stderr, "chunks scanned per malloc = %6.3f\n",
- n_malloc_chunks / nm);
- fprintf(stderr, "bins scanned per malloc = %6.3f\n",
- n_malloc_bins / nm);
- fprintf(stderr, "splits per malloc = %6.3f\n",
- n_split / nm);
- fprintf(stderr, "consolidations per malloc = %6.3f\n",
- n_consol / nm);
- }
-
- fprintf(stderr, "\nfree chunks:\n");
- for (i = 0; i < MAXBIN; ++i)
- {
- p = av[i].hd.fd;
- if (p != &(av[i].hd))
- {
- unsigned int count = 1;
- unsigned int sz = p->size;
- for (p = p->fd; p != &(av[i].hd); p = p->fd)
- {
- if (p->size == sz)
- ++count;
- else
- {
- fprintf(stderr, "\tsize = %10u count = %5u\n", sz, count);
- count = 1;
- sz = p->size;
- }
- }
-
- fprintf(stderr, "\tsize = %10u count = %5u\n", sz, count);
-
- }
- }
-}
-#endif /* MALLOC_STATS */
-
-#endif /* NO_LIBGXX_MALLOC */
-
-
diff --git a/gnu/lib/libregex/test/getpagesize.h b/gnu/lib/libregex/test/getpagesize.h
deleted file mode 100644
index 32adae6..0000000
--- a/gnu/lib/libregex/test/getpagesize.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifdef BSD
-#ifndef BSD4_1
-#define HAVE_GETPAGESIZE
-#endif
-#endif
-
-#ifndef HAVE_GETPAGESIZE
-
-#include <sys/param.h>
-
-#ifdef EXEC_PAGESIZE
-#define getpagesize() EXEC_PAGESIZE
-#else
-#ifdef NBPG
-#define getpagesize() NBPG * CLSIZE
-#ifndef CLSIZE
-#define CLSIZE 1
-#endif /* no CLSIZE */
-#else /* no NBPG */
-#define getpagesize() NBPC
-#endif /* no NBPG */
-#endif /* no EXEC_PAGESIZE */
-
-#endif /* not HAVE_GETPAGESIZE */
-
diff --git a/gnu/lib/libregex/test/iregex.c b/gnu/lib/libregex/test/iregex.c
deleted file mode 100644
index 1ff12b6..0000000
--- a/gnu/lib/libregex/test/iregex.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/* Main program for interactive testing. For maximum output, compile
- this and regex.c with -DDEBUG. */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include "regex.h"
-
-/* Don't bother to guess about <string.h> vs <strings.h>, etc. */
-extern int strlen ();
-
-#define BYTEWIDTH 8
-
-extern void printchar ();
-extern char upcase[];
-
-static void scanstring ();
-static void print_regs ();
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int i;
- struct re_pattern_buffer buf;
- char fastmap[(1 << BYTEWIDTH)];
-
- /* Allow a command argument to specify the style of syntax. You can
- use the `syntax' program to decode integer syntax values. */
- if (argc > 1)
- re_set_syntax (atoi (argv[1]));
-
- buf.allocated = 0;
- buf.buffer = NULL;
- buf.fastmap = fastmap;
- buf.translate = upcase;
-
- for (;;)
- {
- char pat[500], str[500];
- struct re_registers regs;
-
- /* Some C compilers don't like `char pat[500] = ""'. */
- pat[0] = 0;
-
- printf ("Pattern (%s) = ", pat);
- gets (pat);
- scanstring (pat);
-
- if (feof (stdin))
- {
- putchar ('\n');
- exit (0);
- }
-
- if (*pat)
- {
- re_compile_pattern (pat, strlen (pat), &buf);
- re_compile_fastmap (&buf);
-#ifdef DEBUG
- print_compiled_pattern (&buf);
-#endif
- }
-
- printf ("String = ");
- gets (str); /* Now read the string to match against */
- scanstring (str);
-
- i = re_match (&buf, str, strlen (str), 0, &regs);
- printf ("Match value %d.\t", i);
- if (i >= 0)
- print_regs (regs);
- putchar ('\n');
-
- i = re_search (&buf, str, strlen (str), 0, strlen (str), &regs);
- printf ("Search value %d.\t", i);
- if (i >= 0)
- print_regs (regs);
- putchar ('\n');
- }
-
- /* We never get here, but what the heck. */
- return 0;
-}
-
-void
-scanstring (s)
- char *s;
-{
- char *write = s;
-
- while (*s != '\0')
- {
- if (*s == '\\')
- {
- s++;
-
- switch (*s)
- {
- case '\0':
- break;
-
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- *write = *s++ - '0';
-
- if ('0' <= *s && *s <= '9')
- {
- *write = (*write << 3) + (*s++ - '0');
- if ('0' <= *s && *s <= '9')
- *write = (*write << 3) + (*s++ - '0');
- }
- write++;
- break;
-
- case 'n':
- *write++ = '\n';
- s++;
- break;
-
- case 't':
- *write++ = '\t';
- s++;
- break;
-
- default:
- *write++ = *s++;
- break;
- }
- }
- else
- *write++ = *s++;
- }
-
- *write++ = '\0';
-}
-
-/* Print REGS in human-readable form. */
-
-void
-print_regs (regs)
- struct re_registers regs;
-{
- int i, end;
-
- printf ("Registers: ");
-
- if (regs.num_regs == 0 || regs.start[0] == -1)
- {
- printf ("(none)");
- }
- else
- {
- /* Find the last register pair that matched. */
- for (end = regs.num_regs - 1; end >= 0; end--)
- if (regs.start[end] != -1)
- break;
-
- printf ("[%d ", regs.start[0]);
- for (i = 1; i <= end; i++)
- printf ("(%d %d) ", regs.start[i], regs.end[i]);
- printf ("%d]", regs.end[0]);
- }
-}
diff --git a/gnu/lib/libregex/test/main.c b/gnu/lib/libregex/test/main.c
deleted file mode 100644
index da4536d..0000000
--- a/gnu/lib/libregex/test/main.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Main routine for running various tests. Meant only to be linked with
- all the auxiliary test source files, with `test' undefined. */
-
-#include "test.h"
-
-test_type t = all_test;
-
-
-/* Use this to run the tests we've thought of. */
-
-int
-main ()
-{
- switch (t)
- {
- case all_test:
- test_regress ();
- test_others ();
- test_posix_basic ();
- test_posix_extended ();
- test_posix_interface ();
- break;
-
- case other_test:
- test_others ();
- break;
-
- case posix_basic_test:
- test_posix_basic ();
- break;
-
- case posix_extended_test:
- test_posix_extended ();
- break;
-
- case posix_interface_test:
- test_posix_interface ();
- break;
-
- case regress_test:
- test_regress ();
- break;
-
- default:
- fprintf (stderr, "Unknown test %d.\n", t);
- }
-
- return 0;
-}
diff --git a/gnu/lib/libregex/test/malloc-test.c b/gnu/lib/libregex/test/malloc-test.c
deleted file mode 100644
index 7e27a15..0000000
--- a/gnu/lib/libregex/test/malloc-test.c
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-typedef struct {
- unsigned *bits;
- unsigned size;
-} bits_list_type;
-
-#define BYTEWIDTH 8
-#define NULL 0
-
-#define BITS_BLOCK_SIZE (sizeof (unsigned) * BYTEWIDTH)
-#define BITS_BLOCK(position) ((position) / BITS_BLOCK_SIZE)
-#define BITS_MASK(position) (1 << ((position) % BITS_BLOCK_SIZE))
-
-static unsigned
-init_bits_list (bits_list_ptr)
- bits_list_type *bits_list_ptr;
-{
- bits_list_ptr->bits = NULL;
- bits_list_ptr->bits = (unsigned *) malloc (sizeof (unsigned));
-
- if (bits_list_ptr->bits == NULL)
- return 0;
-
- bits_list_ptr->bits[0] = (unsigned)0;
- bits_list_ptr->size = BITS_BLOCK_SIZE;
-
- return 1;
-}
-
-
-main()
-{
- bits_list_type dummy;
- bits_list_type dummy_1;
- bits_list_type dummy_2;
- bits_list_type dummy_3;
-
- init_bits_list (&dummy);
-printf("init 1\n");
- init_bits_list (&dummy_1);
-printf("init 2\n");
- init_bits_list (&dummy_2);
-printf("init 3\n");
- init_bits_list (&dummy_3);
-printf("init 4\n");
-}
diff --git a/gnu/lib/libregex/test/other.c b/gnu/lib/libregex/test/other.c
deleted file mode 100644
index 1023fc6..0000000
--- a/gnu/lib/libregex/test/other.c
+++ /dev/null
@@ -1,503 +0,0 @@
-/* other.c: test (not exhaustively) non-POSIX regular expressions. */
-
-#include "test.h"
-
-void
-test_others ()
-{
- struct re_registers regs;
-
- printf ("\nStarting non-POSIX tests.\n");
- t = other_test;
-
- test_should_match = true;
-
- /* The big question: does the group participate in the match, or match
- the empty string? */
- re_set_syntax (RE_NO_BK_PARENS);
- test_match ("(a*)*ab", "ab");
- TEST_REGISTERS ("(a*)*ab", "ab", 0, 2, 0, 0, -1, -1);
- test_match ("(a*)*", "");
- TEST_REGISTERS ("(a*)*ab", "ab", 0, 0, 0, 0, -1, -1);
-
- /* This tests finding the highest and lowest active registers. */
- test_match ("(a(b)c(d(e)f)g)h(i(j)k(l(m)n)o)\\1\\2\\3\\4\\5\\6\\7\\8",
- "abcdefghijklmnoabcdefgbdefeijklmnojlmnm");
-
- /* Test that \< and \> match at the beginning and end of the string. */
- test_match ("\\<abc\\>", "abc");
-
- /* May as well test \` and \' while we're at it. */
- test_match ("\\`abc\\'", "abc");
-
-#if 0
- /* Test backreferencing and the fastmap -- which doesn't work. */
- test_fastmap ("(a)*\\1", "a", 0, 0);
-#endif
-
- /* But at least we shouldn't search improperly. */
- test_search_return (-1, "(a)\\1", "");
-
- re_set_syntax (RE_SYNTAX_EMACS);
-
- MATCH_SELF("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
- MATCH_SELF ("a^");
- MATCH_SELF ("a^b");
- MATCH_SELF ("$a");
- MATCH_SELF ("a$b");
-
- re_set_syntax (RE_BACKSLASH_ESCAPE_IN_LISTS);
- test_match ("[\\^a]", "a");
- test_match ("[\\^a]", "^");
-
- /* These op characters should be ordinary if RE_CONTEXT_INVALID_OPS
- isn't set. */
- re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_BRACES | RE_INTERVALS
- | RE_NO_BK_PARENS);
- MATCH_SELF ("*");
- test_match ("a|*", "*");
- test_match ("(*)", "*");
-
- MATCH_SELF ("+");
- test_match ("a|+", "+");
- test_match ("(+)", "+");
-
- MATCH_SELF ("?");
- test_match ("a|?", "?");
- test_match ("(?)", "?");
-
- MATCH_SELF ("{1}");
- test_match ("a|{1}", "a");
- test_match ("a|{1}", "{1}");
- test_match ("({1})", "{1}");
-
- test_match ("\\{", "{");
-
-
- re_set_syntax (RE_LIMITED_OPS);
- MATCH_SELF ("|");
- MATCH_SELF ("a|");
- MATCH_SELF ("a|");
- MATCH_SELF ("a||");
- MATCH_SELF ("a||");
- MATCH_SELF ("(|)");
-
- re_set_syntax (RE_SYNTAX_EMACS);
- TEST_SEARCH ("^a", "b\na", 0, 3);
- TEST_SEARCH ("b$", "b\na", 0, 3);
-
-#if 0
- /* Newline is no longer special for anchors (16 Sep 92). --karl */
- test_match_2 ("a\n^b", "a", "\nb");
- test_match_2 ("a$\nb", "a\n", "b");
-#endif
-
- /* Test grouping. */
- re_set_syntax (RE_NO_BK_PARENS);
-
- test_match ("()", "");
- test_fastmap ("()", "", 0, 0);
- TEST_REGISTERS ("()", "", 0, 0, 0, 0, -1, -1);
-
- test_match ("((((((((()))))))))", "");
- test_fastmap ("((((((((()))))))))", "", 0, 0);
- test_match ("a()b", "ab");
- TEST_REGISTERS ("a()b", "ab", 0, 2, 1, 1, -1, -1);
-
- test_match ("(((((((((())))))))))", "");
- test_fastmap ("(((((((((())))))))))", "", 0, 0);
-
- test_match ("()*", "");
- TEST_REGISTERS ("()*", "", 0, 0, 0, 0, -1, -1); /* empty string */
- test_match ("(())*", "");
-
- re_set_syntax (RE_CONTEXT_INDEP_OPS);
- test_match ("*", "");
-
- re_set_syntax (RE_INTERVALS | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES);
- test_match ("{1}", ""); /* Should remain an interval. */
- MATCH_SELF ("{1"); /* Not a valid interval. */
-
- re_set_syntax (RE_NEWLINE_ALT);
- test_match ("a\nb", "a");
- test_match ("a\nb", "b");
-
- re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS);
- test_match ("^a", "a");
- test_match ("(^a)", "a");
- test_match ("(a|^b)", "b");
- test_match ("a$", "a");
- test_match ("(a$)", "a");
- test_match ("a$|b", "a");
-
- /* You should be able to have empty alternatives if RE_NO_EMPTY_ALTS
- isn't set. */
- re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS);
-
- test_match ("|", "");
- test_match ("^|a", "");
- test_match ("^|a", "a");
- test_match ("a|", "");
- test_match ("a|", "a");
- test_match ("a|$", "");
- test_match ("a|$", "a");
- test_match ("a||b", "a");
- test_match ("a||b", "");
- test_match ("a||b", "b");
- test_match ("(|a)", "");
- test_match ("(|a)", "a");
- test_match ("(a|)", "");
- test_match ("(a|)", "a");
-
- TEST_SEARCH ("a|$", "xa", 0, 2);
- TEST_SEARCH ("a|$", "x", 0, 1);
- TEST_SEARCH ("$|b", "x", 0, 1);
- TEST_SEARCH ("$|b", "xb", 0, 2);
- TEST_SEARCH ("c(a|$)", "xca", 0, 3);
- TEST_SEARCH ("c(a|$)", "xc", 0, 2);
- TEST_SEARCH ("c($|b)", "xcb", 0, 3);
- TEST_SEARCH ("c($|b)", "xc", 0, 2);
- TEST_SEARCH ("c($|b$)", "xcb", 0, 3);
- TEST_SEARCH ("c($|b$)", "xc", 0, 2);
- TEST_SEARCH ("c(a$|$)", "xca", 0, 3);
- TEST_SEARCH ("c(a$|$)", "xc", 0, 2);
- TEST_SEARCH ("(a$|b$)|$", "x", 0, 1);
- TEST_SEARCH ("(a$|b$)|$", "xa", 0, 2);
- TEST_SEARCH ("(a$|b$)|$", "xb", 0, 2);
- TEST_SEARCH ("(a$|$)|c$", "x", 0, 1);
- TEST_SEARCH ("(a$|$)|c$", "xa", 0, 2);
- TEST_SEARCH ("(a$|$)|c$", "xc", 0, 2);
- TEST_SEARCH ("($|b$)|c$", "x", 0, 1);
- TEST_SEARCH ("($|b$)|c$", "xb", 0, 2);
- TEST_SEARCH ("($|b$)|c$", "xc", 0, 2);
- TEST_SEARCH ("c$|(a$|$)", "x", 0, 1);
- TEST_SEARCH ("c$|(a$|$)", "xa", 0, 2);
- TEST_SEARCH ("c$|(a$|$)", "xc", 0, 2);
- TEST_SEARCH ("c$|($|b$)", "x", 0, 1);
- TEST_SEARCH ("c$|($|b$)", "xb", 0, 2);
- TEST_SEARCH ("c$|($|b$)", "xc", 0, 2);
- TEST_SEARCH ("$|(a$|b$)", "x", 0, 1);
- TEST_SEARCH ("$|(a$|b$)", "xa", 0, 2);
- TEST_SEARCH ("$|(a$|b$)", "xb", 0, 2);
- TEST_SEARCH ("c(a$|b$)|$", "x", 0, 1);
- TEST_SEARCH ("c(a$|b$)|$", "xca", 0, 3);
- TEST_SEARCH ("c(a$|b$)|$", "xcb", 0, 3);
- TEST_SEARCH ("c(a$|$)|d$", "xc", 0, 2);
- TEST_SEARCH ("c(a$|$)|d$", "xca", 0, 3);
- TEST_SEARCH ("c(a$|$)|d$", "xd", 0, 2);
- TEST_SEARCH ("c($|b$)|d$", "xc", 0, 2);
- TEST_SEARCH ("c($|b$)|d$", "xcb", 0, 3);
- TEST_SEARCH ("c($|b$)|d$", "xd", 0, 2);
- TEST_SEARCH ("d(c$|e((a$|$)))", "xdc", 0, 3);
- TEST_SEARCH ("d(c$|e((a$|$)))", "xde", 0, 3);
- TEST_SEARCH ("d(c$|e((a$|$)))", "xdea", 0, 4);
- TEST_SEARCH ("d(c$|e(($|b$)))", "xdc", 0, 3);
- TEST_SEARCH ("d(c$|e(($|b$)))", "xde", 0, 3);
- TEST_SEARCH ("d(c$|e(($|b$)))", "xdeb", 0, 4);
- TEST_SEARCH ("d($|e((a$|b$)))", "xd", 0, 2);
- TEST_SEARCH ("d($|e((a$|b$)))", "xdea", 0, 4);
- TEST_SEARCH ("d($|e((a$|b$)))", "xdeb", 0, 4);
- TEST_SEARCH ("a(b$|c$)|$", "x", 0, 1);
- TEST_SEARCH ("a(b$|c$)|$", "xab", 0, 3);
- TEST_SEARCH ("a(b$|c$)|$", "xac", 0, 3);
- TEST_SEARCH ("a(b$|$)|d$", "xa", 0, 2);
- TEST_SEARCH ("a(b$|$)|d$", "xab", 0, 3);
- TEST_SEARCH ("a(b$|$)|d$", "xd", 0, 2);
- TEST_SEARCH ("a($|c$)|d$", "xa", 0, 2);
- TEST_SEARCH ("a($|c$)|d$", "xac", 0, 3);
- TEST_SEARCH ("a($|c$)|d$", "xd", 0, 2);
- TEST_SEARCH ("d$|a(b$|$)", "xd", 0, 2);
- TEST_SEARCH ("d$|a(b$|$)", "xa", 0, 2);
- TEST_SEARCH ("d$|a(b$|$)", "xab", 0, 3);
- TEST_SEARCH ("d$|a($|c$)", "xd", 0, 2);
- TEST_SEARCH ("d$|a($|c$)", "xa", 0, 2);
- TEST_SEARCH ("d$|a($|c$)", "xac", 0, 3);
- TEST_SEARCH ("$|a(b$|c$)", "x", 0, 1);
- TEST_SEARCH ("$|a(b$|c$)", "xab", 0, 3);
- TEST_SEARCH ("$|a(b$|c$)", "xac", 0, 3);
- TEST_SEARCH ("(a)(b$|c$)|d$", "xab", 0, 3);
- TEST_SEARCH ("(a)(b$|c$)|d$", "xac", 0, 3);
- TEST_SEARCH ("(a)(b$|c$)|d$", "xd", 0, 2);
- TEST_SEARCH ("(a)(b$|$)|d$", "xa", 0, 2);
- TEST_SEARCH ("(a)(b$|$)|d$", "xab", 0, 3);
- TEST_SEARCH ("(a)(b$|$)|d$", "xd", 0, 2);
- TEST_SEARCH ("(a)($|c$)|d$", "xa", 0, 2);
- TEST_SEARCH ("(a)($|c$)|d$", "xac", 0, 3);
- TEST_SEARCH ("(a)($|c$)|d$", "xd", 0, 2);
- TEST_SEARCH ("d$|(a)(b$|$)", "xd", 0, 2);
- TEST_SEARCH ("d$|(a)(b$|$)", "xa", 0, 2);
- TEST_SEARCH ("d$|(a)(b$|$)", "xab", 0, 3);
- TEST_SEARCH ("d$|(a)($|c$)", "xd", 0, 2);
- TEST_SEARCH ("d$|(a)($|c$)", "xa", 0, 2);
- TEST_SEARCH ("d$|(a)($|c$)", "xac", 0, 3);
- TEST_SEARCH ("$|(a)(b$|c$)", "x", 0, 1);
- TEST_SEARCH ("$|(a)(b$|c$)", "xab", 0, 3);
- TEST_SEARCH ("$|(a)(b$|c$)", "xac", 0, 3);
- TEST_SEARCH ("d$|(c$|(a$|$))", "x", 0, 1);
- TEST_SEARCH ("d$|(c$|(a$|$))", "xd", 0, 2);
- TEST_SEARCH ("d$|(c$|(a$|$))", "xc", 0, 2);
- TEST_SEARCH ("d$|(c$|(a$|$))", "xa", 0, 2);
- TEST_SEARCH ("d$|(c$|($|b$))", "x", 0, 1);
- TEST_SEARCH ("d$|(c$|($|b$))", "xd", 0, 2);
- TEST_SEARCH ("d$|(c$|($|b$))", "xc", 0, 2);
- TEST_SEARCH ("d$|(c$|($|b$))", "xb", 0, 2);
- TEST_SEARCH ("d$|($|(a$|b$))", "x", 0, 1);
- TEST_SEARCH ("d$|($|(a$|b$))", "xd", 0, 2);
- TEST_SEARCH ("d$|($|(a$|b$))", "xa", 0, 2);
- TEST_SEARCH ("d$|($|(a$|b$))", "xb", 0, 2);
- TEST_SEARCH ("$|(c$|(a$|b$))", "x", 0, 1);
- TEST_SEARCH ("$|(c$|(a$|b$))", "xc", 0, 2);
- TEST_SEARCH ("$|(c$|(a$|b$))", "xa", 0, 2);
- TEST_SEARCH ("$|(c$|(a$|b$))", "xb", 0, 2);
- TEST_SEARCH ("d$|c(a$|$)", "xd", 0, 2);
- TEST_SEARCH ("d$|c(a$|$)", "xc", 0, 2);
- TEST_SEARCH ("d$|c(a$|$)", "xca", 0, 3);
- TEST_SEARCH ("d$|c($|b$)", "xd", 0, 2);
- TEST_SEARCH ("d$|c($|b$)", "xc", 0, 2);
- TEST_SEARCH ("d$|c($|b$)", "xcb", 0, 3);
- TEST_SEARCH ("$|c(a$|b$)", "x", 0, 1);
- TEST_SEARCH ("$|c(a$|b$)", "xca", 0, 3);
- TEST_SEARCH ("$|c(a$|b$)", "xcb", 0, 3);
- TEST_SEARCH ("e(d$|c((a$|$)))", "xed", 0, 3);
- TEST_SEARCH ("e(d$|c((a$|$)))", "xec", 0, 3);
- TEST_SEARCH ("e(d$|c((a$|$)))", "xeca", 0, 3);
- TEST_SEARCH ("e(d$|c(($|b$)))", "xed", 0, 3);
- TEST_SEARCH ("e(d$|c(($|b$)))", "xec", 0, 3);
- TEST_SEARCH ("e(d$|c(($|b$)))", "xecb", 0, 4);
- TEST_SEARCH ("e($|c((a$|b$)))", "xe", 0, 2);
- TEST_SEARCH ("e($|c((a$|b$)))", "xeca", 0, 4);
- TEST_SEARCH ("e($|c((a$|b$)))", "xecb", 0, 4);
- TEST_SEARCH ("ed$|(c((a$|$)))", "xed", 0, 3);
- TEST_SEARCH ("ed$|(c((a$|$)))", "xc", 0, 2);
- TEST_SEARCH ("ed$|(c((a$|$)))", "xca", 0, 3);
- TEST_SEARCH ("ed$|(c(($|b$)))", "xed", 0, 3);
- TEST_SEARCH ("ed$|(c(($|b$)))", "xc", 0, 2);
- TEST_SEARCH ("ed$|(c(($|b$)))", "xcb", 0, 3);
- TEST_SEARCH ("$|(c((a$|b$)))", "x", 0, 1);
- TEST_SEARCH ("$|(c((a$|b$)))", "xca", 0, 3);
- TEST_SEARCH ("$|(c((a$|b$)))", "xcb", 0, 3);
- TEST_SEARCH ("d$|($|(a|b)$)", "x", 0, 1);
- TEST_SEARCH ("d$|($|(a|b)$)", "xa", 0, 2);
- TEST_SEARCH ("d$|($|(a|b)$)", "xb", 0, 2);
- TEST_SEARCH ("$|(c$|(a|b)$)", "x", 0, 1);
- TEST_SEARCH ("$|(c$|(a|b)$)", "xc", 0, 2);
- TEST_SEARCH ("$|(c$|(a|b)$)", "xa", 0, 2);
- TEST_SEARCH ("$|(c$|(a|b)$)", "xb", 0, 2);
-
- re_set_syntax (0);
- test_match ("[^\n]", "a");
- test_match ("[^a]", "\n");
-
- TEST_SEARCH ("^a", "b\na", 0, 3);
- TEST_SEARCH ("b$", "b\na", 0, 3);
-
- test_case_fold ("[!-`]", "A");
- test_case_fold ("[!-`]", "a");
-
- re_set_syntax (RE_CONTEXT_INDEP_OPS | RE_NO_BK_VBAR | RE_NO_BK_PARENS
- | RE_NO_BK_BRACES | RE_INTERVALS);
- valid_nonposix_pattern ("()^a");
- valid_nonposix_pattern ("()\\1^a");
-
- /* Per Cederqvist (cedar@lysator.liu.se) bug. */
-
- re_set_syntax (RE_SYNTAX_EMACS);
-
- /* One `a' before the \n and 638 a's after it. */
- test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "a\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
-
- /* No a's before the \n and 639 a's after it. */
- test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
-
- /* One `a' before the \n and 639 a's after it. */
- test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "a\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
-
- /* No a's before the \n and 640 a's after it. */
- test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
-
- re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS);
- TEST_SEARCH ("^(^a)", "ab", 0, 2);
- TEST_SEARCH ("(a$)$", "ba", 0, 2);
- test_match ("a|$b", "$b");
-
- /* Mike's curiosity item. */
- re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS);
- test_all_registers ("(foo|foobar)(foo|bar)*\\1(foo|bar)*",
- "foobarfoobar", "",
- 0, 12, 0, 3, 3, 6, 9, 12, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1);
-
- /* Another one from Mike. */
- test_match ("(foo|foobarfoo)(bar)*", "foobarfoo");
-
- /* And another. */
- test_match("(foo|foobar)(bar|barfoo)?\\1", "foobarfoobar");
-
- re_set_syntax (RE_NO_BK_PARENS | RE_INTERVALS | RE_NO_BK_VBAR
- | RE_NO_BK_BRACES); /* xx get new ones from ext.*/
- test_match ("((a{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)*", "bb");
- test_all_registers ("((a{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)*", "", "bb",
- 0, 2, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1);
-
- test_match ("((a+?*{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)", "b");
- test_all_registers ("((a+?*{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)", "", "b",
- 0, 1, 0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1);
-
- /* Valid anchoring. */
- /* See generic_test.c and extended_test.c for more search
- tests. xx Not sure all these tests are represented in the
- search tests. */
-
- re_set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR);
- valid_nonposix_pattern
- ("(((((((((((((((((((((((((((((((((^a)))))))))))))))))))))))))))))))))");
- valid_nonposix_pattern
- ("(((((((((((((((((((((((((((((((((a$)))))))))))))))))))))))))))))))))");
- valid_nonposix_pattern ("\\b\\B\\<\\>\\`\\'^a");
- valid_nonposix_pattern ("a$\\b\\B\\<\\>\\`\\'");
- valid_nonposix_pattern ("(^a)");
- valid_nonposix_pattern ("(a$)");
- valid_nonposix_pattern ("(^a)b");
- valid_nonposix_pattern ("b(a$)");
- valid_nonposix_pattern ("(^a|^b)c");
- valid_nonposix_pattern ("c(a$|b$)");
- valid_nonposix_pattern ("(^a|^b)|^c");
- valid_nonposix_pattern ("(a$|b$)|c$");
- valid_nonposix_pattern ("^c|(^a|^b)");
- valid_nonposix_pattern ("c$|(a$|b$)");
- valid_nonposix_pattern ("(^a|^b)c|^d");
- valid_nonposix_pattern ("c(a$|b$)|d$");
- valid_nonposix_pattern ("(((^a|^b))c|^d)e");
- valid_nonposix_pattern ("(c((a|b))|d)e$");
- valid_nonposix_pattern ("^d(c|e((a|b)))");
- valid_nonposix_pattern ("d(c$|e((a$|b$)))");
- valid_nonposix_pattern ("(((^a|^b))c)|^de");
- valid_nonposix_pattern ("(((a|b))c$)|de$");
-
- valid_nonposix_pattern ("((a$)$)$");
- valid_nonposix_pattern ("^(^(^a))");
-
- valid_nonposix_pattern ("^de|^(c((a|b)))");
- valid_nonposix_pattern ("^de|(^c((a|b)))");
- valid_nonposix_pattern ("de$|(c((a|b)$))");
- valid_nonposix_pattern ("de$|(c((a|b))$)");
- valid_nonposix_pattern ("de$|(c((a|b)))$");
-
- valid_nonposix_pattern ("^a(b|c)|^d");
- valid_nonposix_pattern ("a(b$|c$)|d$");
- valid_nonposix_pattern ("^d|^a(b|c)");
- valid_nonposix_pattern ("d$|a(b$|c$)");
- valid_nonposix_pattern ("^d|^(b|c)a");
- valid_nonposix_pattern ("d$|(b|c)a$");
- valid_nonposix_pattern ("^(a)(b|c)|^d");
- valid_nonposix_pattern ("(a)(b|c)$|d$");
- valid_nonposix_pattern ("(^a)(b|c)|^d");
- valid_nonposix_pattern ("(a)(b$|c$)|d$");
- valid_nonposix_pattern ("^d|^(b|c)(a)");
- valid_nonposix_pattern ("d$|(b|c)(a)$");
- valid_nonposix_pattern ("^d|(^b|^c)(a)");
- valid_nonposix_pattern ("d$|(b|c)(a$)");
- valid_nonposix_pattern ("^d|^(a)(b|c)");
- valid_nonposix_pattern ("^d|(^a)(b|c)");
- valid_nonposix_pattern ("d$|(a)(b$|c$)");
- valid_nonposix_pattern ("((^a|^b)|^c)|^d");
- valid_nonposix_pattern ("d$|(c$|(a$|b$))");
-
-
- /* Tests shouldn't match. */
- test_should_match = false;
-
- /* Test that RE_CONTEXT_INVALID_OPS has precedence over
- RE_CONTEXT_INDEP_OPS. */
-
- re_set_syntax (RE_CONTEXT_INDEP_OPS | RE_CONTEXT_INVALID_OPS
- | RE_NO_BK_VBAR | RE_NO_BK_PARENS
- | RE_NO_BK_BRACES | RE_INTERVALS);
- INVALID_PATTERN ("*");
- INVALID_PATTERN ("^*");
- INVALID_PATTERN ("a|*");
- INVALID_PATTERN ("(*)");
-
- INVALID_PATTERN ("^+");
- INVALID_PATTERN ("+");
- INVALID_PATTERN ("a|+");
- INVALID_PATTERN ("(+)");
-
- INVALID_PATTERN ("^?");
- INVALID_PATTERN ("?");
- INVALID_PATTERN ("a|?");
- INVALID_PATTERN ("(?)");
-
- INVALID_PATTERN ("^{1}");
- INVALID_PATTERN ("{1}");
- INVALID_PATTERN ("a|{1}");
- INVALID_PATTERN ("({1})");
-
-#if 0
- /* No longer have this syntax option -- POSIX says empty alternatives
- are undefined as of draft 11.2. */
-
- /* You can't have empty alternatives if RE_NO_EMPTY_ALTS is set. */
-
- re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_ALTS);
-
- INVALID_PATTERN ("|");
- INVALID_PATTERN ("^|a");
- INVALID_PATTERN ("a|");
- INVALID_PATTERN ("a||");
- INVALID_PATTERN ("a||b");
- INVALID_PATTERN ("(|a)");
- INVALID_PATTERN ("(a|)");
- INVALID_PATTERN ("(a|)");
-
-
- /* Test above with `\(' and `\)'. */
- re_set_syntax (RE_NO_BK_VBAR | RE_NO_EMPTY_ALTS);
- INVALID_PATTERN ("\\(|a\\)");
- INVALID_PATTERN ("\\(a|\\)");
-
- re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_ALTS);
- INVALID_PATTERN ("(|)()$|d$");
-#endif
-
- /* Test grouping. */
- test_match ("()", "a");
-
- /* Test backslashed intervals that are CONTEXTly invalid if have
- nothing on which to operate. */
-
- re_set_syntax (RE_INTERVALS | RE_CONTEXT_INVALID_OPS);
- INVALID_PATTERN ("\\{1\\}");
-
- re_set_syntax (0);
- test_match ("z-a", "a");
-
- re_set_syntax (RE_BK_PLUS_QM);
- INVALID_PATTERN ("a*\\");
-
- re_set_syntax (0);
- INVALID_PATTERN ("a*\\");
-
- re_set_syntax (RE_BACKSLASH_ESCAPE_IN_LISTS);
- INVALID_PATTERN ("[\\");
-
-#if 0
- /* Empty groups are always ok now. (13 Sep 92) */
- re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_GROUPS);
- INVALID_PATTERN ("(|)()$|d$");
-#endif
-
- printf ("\nFinished non-POSIX tests.\n");
-}
-
-
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/lib/libregex/test/printchar.c b/gnu/lib/libregex/test/printchar.c
deleted file mode 100644
index 1b756f4..0000000
--- a/gnu/lib/libregex/test/printchar.c
+++ /dev/null
@@ -1,14 +0,0 @@
-void
-printchar (c)
- char c;
-{
- if (c < 040 || c >= 0177)
- {
- putchar ('\\');
- putchar (((c >> 6) & 3) + '0');
- putchar (((c >> 3) & 7) + '0');
- putchar ((c & 7) + '0');
- }
- else
- putchar (c);
-}
diff --git a/gnu/lib/libregex/test/psx-basic.c b/gnu/lib/libregex/test/psx-basic.c
deleted file mode 100644
index 487c604..0000000
--- a/gnu/lib/libregex/test/psx-basic.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/* psx-basic.c: Test POSIX basic regular expressions. */
-
-#include "test.h"
-
-
-void
-test_posix_basic ()
-{
- /* Intervals can only match up to RE_DUP_MAX occurences of anything. */
- char dup_max_plus_one[6];
- sprintf (dup_max_plus_one, "%d", RE_DUP_MAX + 1);
-
- printf ("\nStarting POSIX basic tests.\n");
- t = posix_basic_test;
-
- re_set_syntax (RE_SYNTAX_POSIX_MINIMAL_BASIC);
-
- test_posix_generic ();
-
- printf ("\nContinuing POSIX basic tests.\n");
-
-/* Grouping tests that are not the same. */
-
- test_should_match = false;
- invalid_pattern (REG_EPAREN, PARENS_TO_OPS ("a)"));
-
- test_should_match = true;
- /* Special characters. */
- MATCH_SELF ("*");
- test_match ("\\(*\\)", "*");
- test_match ("\\(^*\\)", "*");
- test_match ("**", "***");
- test_match ("***", "****");
-
- MATCH_SELF ("{"); /* of extended... */
- MATCH_SELF ("()"); /* also non-Posix. */
- MATCH_SELF ("a+");
- MATCH_SELF ("a?");
- MATCH_SELF ("a|b");
- MATCH_SELF ("a|"); /* No alternations, */
- MATCH_SELF ("|a"); /* so OK if empty. */
- MATCH_SELF ("a||");
- test_match ("\\(|a\\)", "|a");
- test_match ("\\(a|\\)", "a|");
- test_match ("a\\+", "a+");
- test_match ("a\\?", "a?");
- test_match ("a\\|b", "a|b");
- test_match ("^*", "*");
- test_match ("^+", "+");
- test_match ("^?", "?");
- test_match ("^{", "{");
- /* Valid subexpressions
- (empty) in basic only. */
- test_match ("\\(\\)", "");
-
- test_match ("a\\(\\)", "a");
- test_match ("\\(\\)b", "b");
- test_match ("a\\(\\)b", "ab");
- TEST_REGISTERS ("a\\(\\)b", "ab", 0, 2, 1, 1, -1, -1);
-
- test_match ("\\(\\)*", "");
- test_match ("\\(\\(\\)\\)*", "");
- /* Valid back references. */
-
- /* N.B.: back references to subexpressions that include a * are
- undefined in the spec. The tests are in here to see if we handle
- the situation consistently, but if it fails any of them, it doesn't
- matter. */
-
- test_match ("\\(\\)\\1", "");
- TEST_REGISTERS ("\\(\\)\\1", "", 0, 0, 0, 0, -1, -1);
-
- test_match ("\\(\\(\\)\\)\\(\\)\\2", "");
-
- test_match ("\\(a\\)\\1", "aa");
- TEST_REGISTERS ("\\(a\\)\\1", "aa", 0, 2, 0, 1, -1, -1);
- TEST_REGISTERS ("\\(a\\)\\1", "xaax", 1, 3, 1, 2, -1, -1);
-
- test_match ("\\(\\(a\\)\\)\\1", "aa");
- test_match ("\\(a\\)\\(b\\)\\2\\1", "abba");
-
- test_match ("\\(a\\)*\\1", "aa");
- TEST_REGISTERS ("\\(a\\)*\\1", "aa", 0, 2, 0, 1, -1, -1);
- TEST_REGISTERS ("\\(a\\)*\\1", "xaax", 0, 0, -1, -1, -1, -1);
-
- test_match ("\\(\\(a\\)\\2b\\)*", "aab");
- TEST_REGISTERS ("\\(\\(a\\)\\2b\\)*", "aab", 0, 3, 0, 3, 0, 1);
- TEST_REGISTERS ("\\(\\(a\\)\\2b\\)*", "xaabx", 0, 0, -1, -1, -1, -1);
-
- test_match ("\\(a*\\)*\\1", "");
- test_match ("\\(a*\\)*\\1", "aa");
- TEST_REGISTERS ("\\(a*\\)*\\1", "aa", 0, 2, 0, 1, -1, -1);
- TEST_REGISTERS ("\\(a*\\)*\\1", "xaax", 0, 0, 0, 0, -1, -1);
-
- test_match ("\\(a*\\)*\\1", "");
- test_match ("\\(a*\\)*\\1", "aa");
- test_match ("\\(\\(a*\\)*\\)*\\1", "aa");
- test_match ("\\(ab*\\)*\\1", "abab");
- TEST_REGISTERS ("\\(ab*\\)*\\1", "abab", 0, 4, 0, 2, -1, -1);
- TEST_REGISTERS ("\\(ab*\\)*\\1", "xababx", 0, 0, -1, -1, -1, -1);
-
- test_match ("\\(a*\\)ab\\1", "aaba");
- TEST_REGISTERS ("\\(a*\\)ab\\1", "aaba", 0, 4, 0, 1, -1, -1);
- TEST_REGISTERS ("\\(a*\\)ab\\1", "xaabax", 1, 5, 1, 2, -1, -1);
-
- test_match ("\\(a*\\)*ab\\1", "aaba");
- TEST_REGISTERS ("\\(a*\\)*ab\\1", "aaba", 0, 4, 0, 1, -1, -1);
- TEST_REGISTERS ("\\(a*\\)*ab\\1", "xaabax", 1, 5, 1, 2, -1, -1);
-
- test_match ("\\(\\(a*\\)b\\)*\\2", "abb");
- TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "abb", 0, 3, 2, 3, 2, 2);
- TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "xabbx", 0, 0, -1, -1, -1, -1);
-
- /* Different from above. */
- test_match ("\\(\\(a*\\)b*\\)*\\2", "aa");
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aa", 0, 2, 0, 1, 0, 1);
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaax", 0, 0, 0, 0, 0, 0);
-
- test_match ("\\(\\(a*\\)b*\\)*\\2", "aba");
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aba", 0, 3, 0, 2, 0, 1);
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xabax", 0, 0, 0, 0, 0, 0);
-
- test_match ("\\(\\(a*\\)b\\)*\\2", "aababa");
- TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "aababa", 0, 6, 3, 5, 3, 4);
- TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "xaababax", 0, 0, -1, -1, -1, -1);
-
- test_match ("\\(\\(a*\\)b*\\)*\\2", "aabaa");
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aabaa", 0, 5, 0, 3, 0, 2);
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaabaax", 0, 0, 0, 0, 0, 0);
-
- test_match ("\\(\\(a*\\)b*\\)*\\2", "aabbaa");
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aabbaa", 0, 6, 0, 4, 0, 2);
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaabbaax", 0, 0, 0, 0, 0, 0);
-
- test_match ("\\(\\(a*\\)b*\\)*\\2", "abaabaa");
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "abaabaa", 0, 7, 2, 5, 2, 4);
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaababaax", 0, 0, 0, 0, 0, 0);
-
- test_match ("\\(\\(a*\\)b*\\)*a\\2", "aabaaa");
- TEST_REGISTERS ("\\(\\(a*\\)b*a\\)*\\2", "aabaaa", 0, 6, 0, 3, 0, 2);
- TEST_REGISTERS ("\\(\\(a*\\)b*a\\)*\\2", "xaabaax", 0, 0, -1, -1, -1, -1);
-
- test_match ("\\(\\(a*\\)b*\\)*\\2a", "aabaaa");
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2a", "aabaaa", 0, 6, 0, 3, 0, 2);
- TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2a", "xaabaaax", 1, 7, 1, 4, 1, 3);
-
- test_match ("\\(\\(a*\\)b\\)*\\2\\1", "abaabaaaab");
- TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2\\1", "abaabaaaab", 0, 10, 2, 5, 2, 4);
- /* We are matching the empty string here. */
- TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2\\1", "xabaabaaaabx", 0, 0, -1, -1, -1, -1);
-
- test_match ("\\(a*b\\)\\1", "abab");
- test_match ("\\(a\\)\\1\\1", "aaa");
- test_match ("\\(a\\(c\\)d\\)\\1\\2", "acdacdc");
-
- test_match ("\\(a\\)\\1*", "aaa");
- TEST_REGISTERS ("\\(a\\)\\1*", "aaa", 0, 3, 0, 1, -1, -1);
- TEST_REGISTERS ("\\(a\\)\\1*", "xaaax", 1, 4, 1, 2, -1, -1);
-
- test_match ("\\(a\\)\\{1,3\\}b\\1", "aba");
- TEST_REGISTERS ("\\(a\\)\\{1,3\\}b\\1", "aba", 0, 3, 0, 1, -1, -1);
- TEST_REGISTERS ("\\(a\\)\\{1,3\\}b\\1", "xabax", 1, 4, 1, 2, -1, -1);
-
- test_match ("\\(\\(a\\)\\2\\)*", "aaaa"); /* rms? */
- TEST_REGISTERS ("\\(\\(a*b\\)\\2\\)*", "bbabab", 0, 6, 2, 6, 2, 4); /* rms? */
-
- test_match ("\\(\\(a\\)\\1\\)*", "a1a1");
-
- test_match ("\\(\\(a\\)\\2\\)\\1", "aaaa");
-
- test_match ("\\(\\(a*\\)\\2\\)\\1", "aaaa");
- TEST_REGISTERS ("\\(\\(a*\\)\\2\\)\\1", "aaaa", 0, 4, 0, 2, 0, 1);
- TEST_REGISTERS ("\\(\\(a*\\)\\2\\)\\1", "xaaaax", 0, 0, 0, 0, 0, 0);
-
- test_match ("\\{1\\}", "{1}");
- test_match ("^\\{1\\}", "{1}");
-
- test_match ("\\(a\\)\\1\\{1,2\\}", "aaa");
- TEST_REGISTERS ("\\(a\\)\\1\\{1,2\\}", "aaa", 0, 3, 0, 1, -1, -1);
- TEST_REGISTERS ("\\(a\\)\\1\\{1,2\\}", "xaaax", 1, 4, 1, 2, -1, -1);
-
-
- /* Per POSIX D11.1 p. 109, leftmost longest match. */
-
- test_match (PARENS_TO_OPS ("(.*).*\\1"), "abcabc");
-
-
- /* Per POSIX D11.1, p. 125, leftmost longest match. */
-
- test_match (PARENS_TO_OPS ("(ac*)c*d[ac]*\\1"), "acdacaaa");
- TEST_REGISTERS (PARENS_TO_OPS ("(ac*)c*d[ac]*\\1"), "acdacaaa",
- 0, 8, 0, 1, -1, -1);
-
- /* Anchors become ordinary, sometimes. */
- MATCH_SELF ("a^");
- MATCH_SELF ("$a");
- MATCH_SELF ("$^");
- test_fastmap ("$a^", "$", 0, 0);
- test_match ("$^*", "$^^");
- test_match ("\\($^\\)", "$^");
- test_match ("$*", "$$");
- /* xx -- known bug, solution pending test_match ("^^$", "^"); */
- test_match ("$\\{0,\\}", "$$");
- TEST_SEARCH ("^$*", "$$", 0, 2);
- TEST_SEARCH ("^$\\{0,\\}", "$$", 0, 2);
- MATCH_SELF ("2^10");
- MATCH_SELF ("$HOME");
- MATCH_SELF ("$1.35");
-
-
- /* Basic regular expressions, continued; these don't match their strings. */
- test_should_match = false;
-
- invalid_pattern (REG_EESCAPE, "\\(a\\");
- /* Invalid back references. */
- test_match ("\\(a\\)\\1", "ab");
- test_match ("\\(a\\)\\1\\1", "aab");
- test_match ("\\(a\\)\\(b\\)\\2\\1", "abab");
- test_match ("\\(a\\(c\\)d\\)\\1\\2", "acdc");
- test_match ("\\(a*b\\)\\1", "abaab");
- test_match ("\\(a\\)\\1*", "aaaaaaaaaab");
- test_match ("\\(\\(a\\)\\1\\)*", "aaa");
- invalid_pattern (REG_ESUBREG, "\\1");
- invalid_pattern (REG_ESUBREG, "\\(a\\)\\2");
- test_match ("\\(\\(a\\)\\2\\)*", "abaa");
- test_match ("\\(\\(a\\)\\1\\)*", "a");
- test_match ("\\(\\(a\\)\\2\\)\\1", "abaa");
- test_match ("\\(\\(a*\\)\\2\\)\\1", "abaa");
- /* Invalid intervals. */
- invalid_pattern (REG_EBRACE, "a\\{");
-
- invalid_pattern (REG_BADBR, "a\\{-1");
- invalid_pattern (REG_BADBR, concat ("a\\{", (char *)dup_max_plus_one));
- invalid_pattern (REG_BADBR, concat (concat ("a\\{", (char *)dup_max_plus_one), ","));
- invalid_pattern (REG_BADBR, "a\\{1,0");
-
- invalid_pattern (REG_EBRACE, "a\\{1");
- invalid_pattern (REG_EBRACE, "a\\{0,");
- invalid_pattern (REG_EBRACE, "a\\{0,1");
- invalid_pattern (REG_EBRACE, "a\\{0,1}");
-
- printf ("\nFinished POSIX basic tests.\n");
-}
-
-
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/lib/libregex/test/psx-extend.c b/gnu/lib/libregex/test/psx-extend.c
deleted file mode 100644
index 14b8a5e..0000000
--- a/gnu/lib/libregex/test/psx-extend.c
+++ /dev/null
@@ -1,1244 +0,0 @@
-/* psx-extend.c: Test POSIX extended regular expressions. */
-
-#include "test.h"
-
-
-void
-test_posix_extended ()
-{
- /* Intervals can only match up to RE_DUP_MAX occurences of anything. */
- char dup_max_plus_one[6];
- sprintf (dup_max_plus_one, "%d", RE_DUP_MAX + 1);
-
-
- printf ("\nStarting POSIX extended tests.\n");
- t = posix_extended_test;
-
- re_set_syntax (RE_SYNTAX_POSIX_MINIMAL_EXTENDED);
-
- test_posix_generic ();
-
- printf ("\nContinuing POSIX extended tests.\n");
-
- /* Grouping tests that differ from basic's. */
-
- test_should_match = true;
- MATCH_SELF ("a)");
-
- /* Valid use of special characters. */
- test_match ("\\(a", "(a");
- test_match ("a\\+", "a+");
- test_match ("a\\?", "a?");
- test_match ("\\{a", "{a");
- test_match ("\\|a", "|a");
- test_match ("a\\|b", "a|b");
- test_match ("a\\|?", "a");
- test_match ("a\\|?", "a|");
- test_match ("a\\|*", "a");
- test_match ("a\\|*", "a||");
- test_match ("\\(*\\)", ")");
- test_match ("\\(*\\)", "(()");
- test_match ("a\\|+", "a|");
- test_match ("a\\|+", "a||");
- test_match ("\\(+\\)", "()");
- test_match ("\\(+\\)", "(()");
- test_match ("a\\||b", "a|");
- test_match ("\\(?\\)", ")");
- test_match ("\\(?\\)", "()");
-
- test_match ("a+", "a");
- test_match ("a+", "aa");
- test_match ("a?", "");
- test_match ("a?", "a");
-
- /* Bracket expressions. */
- test_match ("[(]", "(");
- test_match ("[+]", "+");
- test_match ("[?]", "?");
- test_match ("[{]", "{");
- test_match ("[|]", "|");
- /* Subexpressions. */
- test_match ("(a+)*", "");
- test_match ("(a+)*", "aa");
- test_match ("(a?)*", "");
- test_match ("(a?)*", "aa");
- /* (No) back references. */
- test_match ("(a)\\1", "a1");
- /* Invalid as intervals,
- but are valid patterns. */
- MATCH_SELF ("{");
- test_match ("^{", "{");
- test_match ("a|{", "{");
- test_match ("({)", "{");
- MATCH_SELF ("a{");
- MATCH_SELF ("a{}");
- MATCH_SELF ("a{-1");
- MATCH_SELF ("a{-1}");
- MATCH_SELF ("a{0");
- MATCH_SELF ("a{0,");
- MATCH_SELF (concat ("a{", dup_max_plus_one));
- MATCH_SELF (concat (concat ("a{", dup_max_plus_one), ","));
- MATCH_SELF ("a{1,0");
- MATCH_SELF ("a{1,0}");
- MATCH_SELF ("a{0,1");
- test_match ("[a{0,1}]", "}");
- test_match ("a{1,3}{-1}", "aaa{-1}");
- test_match (concat ("a{1,3}{", dup_max_plus_one),
- concat ("aaa{", dup_max_plus_one));
- test_match ("a{1,3}{2,1}", "aaa{2,1}");
- test_match ("a{1,3}{1,2", "aaa{1,2");
- /* Valid consecutive repetitions. */
- test_match ("a*+", "a");
- test_match ("a*?", "a");
- test_match ("a++", "a");
- test_match ("a+*", "a");
- test_match ("a+?", "a");
- test_match ("a??", "a");
- test_match ("a?*", "a");
- test_match ("a?+", "a");
-
- test_match ("a{2}?", "");
- test_match ("a{2}?", "aa");
- test_match ("a{2}+", "aa");
- test_match ("a{2}{2}", "aaaa");
-
- test_match ("a{1}?*", "");
- test_match ("a{1}?*", "aa");
-
- test_match ("(a?){0,3}b", "aaab");
- test_fastmap ("(a?){0,3}b", "ab", 0, 0);
- test_match ("(a+){0,3}b", "b");
- test_fastmap ("(a+){0,3}b", "ab", 0, 0);
- test_match ("(a+){0,3}b", "ab");
- test_fastmap ("(a+){0,3}b", "ab", 0, 0);
- test_match ("(a+){1,3}b", "aaab");
- test_match ("(a?){1,3}b", "aaab");
-
- test_match ("\\\\{1}", "\\"); /* Extended only. */
-
- test_match ("(a?)?", "a");
- test_match ("(a?b)?c", "abc");
- test_match ("(a+)*b", "b");
- /* Alternatives. */
- test_match ("a|b", "a");
- test_match ("a|b", "b");
- test_fastmap ("a|b", "ab", 0, 0);
-
- TEST_SEARCH ("a|b", "cb", 0, 2);
- TEST_SEARCH ("a|b", "cb", 0, 2);
-
- test_match ("(a|b|c)", "a");
- test_match ("(a|b|c)", "b");
- test_match ("(a|b|c)", "c");
-
- test_match ("(a|b|c)*", "abccba");
-
- test_match ("(a(b*))|c", "a"); /* xx do registers. */
- test_match ("(a(b*))|c", "ab");
- test_match ("(a(b*))|c", "c");
-
- test_fastmap ("(a+?*|b)", "ab", 0, 0);
- test_match ("(a+?*|b)", "b");
- TEST_REGISTERS ("(a+?*|b)", "b", 0, 1, 0, 1, -1, -1);
-
- test_fastmap ("(a+?*|b)*", "ab", 0, 0);
- test_match ("(a+?*|b)*", "bb");
- TEST_REGISTERS ("(a+?*|b)*", "bb", 0, 2, 1, 2, -1, -1);
-
- test_fastmap ("(a*|b)*", "ab", 0, 0);
- test_match ("(a*|b)*", "bb");
- TEST_REGISTERS ("(a*|b)*", "bb", 0, 2, 1, 2, -1, -1);
-
- test_fastmap ("((a*)|b)*", "ab", 0, 0);
- test_match ("((a*)|b)*", "bb");
- TEST_REGISTERS ("((a*)|b)*", "bb", 0, 2, 1, 2, 1, 1);
-
- test_fastmap ("(a{0,}|b)*", "ab", 0, 0);
- test_match ("(a{0,}|b)*", "bb");
- TEST_REGISTERS ("(a{0,}|b)*", "bb", 0, 2, 1, 2, -1, -1);
-
- test_fastmap ("((a{0,})|b)*", "ab", 0, 0);
- test_match ("((a{0,})|b)*", "bb");
- TEST_REGISTERS ("((a{0,})|b)*", "bb", 0, 2, 1, 2, 1, 1);
-
- /* With c's */
- test_fastmap ("(a+?*|b)c", "abc", 0, 0);
- test_match ("(a+?*|b)c", "bc");
- TEST_REGISTERS ("(a+?*|b)c", "bc", 0, 2, 0, 1, -1, -1);
-
- test_fastmap ("(a+?*|b)*c", "abc", 0, 0);
- test_match ("(a+?*|b)*c", "bbc");
- TEST_REGISTERS ("(a+?*|b)*c", "bbc", 0, 3, 1, 2, -1, -1);
-
- test_fastmap ("(a*|b)*c", "abc", 0, 0);
- test_match ("(a*|b)*c", "bbc");
- TEST_REGISTERS ("(a*|b)*c", "bbc", 0, 3, 1, 2, -1, -1);
-
- test_fastmap ("((a*)|b)*c", "abc", 0, 0);
- test_match ("((a*)|b)*c", "bbc");
- TEST_REGISTERS ("((a*)|b)*c", "bbc", 0, 3, 1, 2, 1, 1);
-
- test_fastmap ("(a{0,}|b)*c", "abc", 0, 0);
- test_match ("(a{0,}|b)*c", "bbc");
- TEST_REGISTERS ("(a{0,}|b)*c", "bbc", 0, 3, 1, 2, -1, -1);
-
- test_fastmap ("((a{0,})|b)*c", "abc", 0, 0);
- test_match ("((a{0,})|b)*c", "bbc");
- TEST_REGISTERS ("((a{0,})|b)*c", "bbc", 0, 3, 1, 2, 1, 1);
-
-
- test_fastmap ("((a{0,}\\b\\<)|b)", "ab", 0, 0);
- test_match ("((a{0,}\\b\\<)|b)", "b");
- TEST_REGISTERS ("((a{0,}\\b\\<)|b)", "b",
- 0, 1, 0, 1, 0, 0);
-
- test_fastmap ("((a{0,}\\b\\<)|b)*", "ab", 0, 0);
- test_match ("((a{0,}\\b\\<)|b)*", "b");
- TEST_REGISTERS ("((a{0,}\\b\\<)|b)*", "b",
- 0, 1, 0, 1, 0, 0);
-
- test_fastmap ("((a+?*{0,1}\\b\\<)|b)", "ab", 0, 0);
- test_match ("((a+?*{0,1}\\b\\<)|b)", "b");
- TEST_REGISTERS ("((a+?*{0,1}\\b\\<)|b)", "b",
- 0, 1, 0, 1, 0, 0);
-
- test_fastmap ("((a+?*{0,2}\\b\\<)|b)", "ab", 0, 0);
- test_match ("((a+?*{0,2}\\b\\<)|b)", "b");
- TEST_REGISTERS ("((a+?*{0,2}\\b\\<)|b)", "b",
- 0, 1, 0, 1, 0, 0);
-
-
- test_fastmap ("((a+?*{0,4095}\\b\\<)|b)", "ab", 0, 0);
- test_match ("((a+?*{0,4095}\\b\\<)|b)", "b");
- TEST_REGISTERS ("((a+?*{0,4095}\\b\\<)|b)", "b",
- 0, 1, 0, 1, 0, 0);
-
- test_fastmap ("((a+?*{0,5119}\\b\\<)|b)", "ab", 0, 0);
- test_match ("((a+?*{0,5119}\\b\\<)|b)", "b");
- TEST_REGISTERS ("((a+?*{0,5119}\\b\\<)|b)", "b",
- 0, 1, 0, 1, 0, 0);
-
- test_fastmap ("((a+?*{0,6143}\\b\\<)|b)", "ab", 0, 0);
- test_match ("((a+?*{0,6143}\\b\\<)|b)", "b");
- TEST_REGISTERS ("((a+?*{0,6143}\\b\\<)|b)", "b",
- 0, 1, 0, 1, 0, 0);
-
- test_fastmap ("((a+?*{0,8191}\\b\\<)|b)", "ab", 0, 0);
- test_match ("((a+?*{0,8191}\\b\\<)|b)", "b");
- TEST_REGISTERS ("((a+?*{0,8191}\\b\\<)|b)", "b",
- 0, 1, 0, 1, 0, 0);
-
- test_fastmap ("((a+?*{0,16383}\\b\\<)|b)", "ab", 0, 0);
- test_match ("((a+?*{0,16383}\\b\\<)|b)", "b");
- TEST_REGISTERS ("((a+?*{0,16383}\\b\\<)|b)", "b",
- 0, 1, 0, 1, 0, 0);
-
-
- test_fastmap ("((a+?*{0,}\\b\\<)|b)", "ab", 0, 0);
- test_match ("((a+?*{0,}\\b\\<)|b)", "b");
- TEST_REGISTERS ("((a+?*{0,}\\b\\<)|b)", "b",
- 0, 1, 0, 1, 0, 0);
-
- test_fastmap ("((a+?*{0,}\\b\\<)|b)*", "ab", 0, 0);
- test_match ("((a+?*{0,}\\b\\<)|b)*", "b");
- TEST_REGISTERS ("((a+?*{0,}\\b\\<)|b)*", "b",
- 0, 1, 0, 1, 0, 0);
-
- test_fastmap ("((a+?*{0,}\\b\\<)|b)*", "ab", 0, 0);
- test_match ("((a+?*{0,}\\b\\<)|b)*", "bb");
- TEST_REGISTERS ("((a+?*{0,}\\b\\<)|b)*", "bb",
- 0, 2, 1, 2, 0, 0);
-
-
- /* `*' after group. */
- test_match ("(a*|b*)*c", "c");
- TEST_REGISTERS ("(a*|b*)*c", "c", 0, 1, 0, 0, -1, -1);
-
- test_match ("(a*|b*)*c", "ac");
- TEST_REGISTERS ("(a*|b*)*c", "ac", 0, 2, 0, 1, -1, -1);
-
- test_match ("(a*|b*)*c", "aac");
- TEST_REGISTERS ("(a*|b*)*c", "aac", 0, 3, 0, 2, -1, -1);
-
- test_match ("(a*|b*)*c", "bbc");
- TEST_REGISTERS ("(a*|b*)*c", "bbc", 0, 3, 0, 2, -1, -1);
-
- test_match ("(a*|b*)*c", "abc");
- TEST_REGISTERS ("(a*|b*)*c", "abc", 0, 3, 1, 2, -1, -1);
-
- /* No `*' after group. */
- test_match ("(a*|b*)c", "c");
- TEST_REGISTERS ("(a*|b*)c", "c", 0, 1, 0, 0, -1, -1);
-
- test_match ("(a*|b*)c", "ac");
- TEST_REGISTERS ("(a*|b*)c", "ac", 0, 2, 0, 1, -1, -1);
-
- test_match ("(a*|b*)c", "bc");
- TEST_REGISTERS ("(a*|b*)c", "bc", 0, 2, 0, 1, -1, -1);
-
- test_match ("(a*|b*)c", "aac");
- TEST_REGISTERS ("(a*|b*)c", "aac", 0, 3, 0, 2, -1, -1);
-
- /* Same as above, but with no `*'s in alternatives.
-
- test_match ("(a|b)*c", "c"); /* `*' after group. */
- TEST_REGISTERS ("(a|b)*c", "c", 0, 1, -1, -1, -1, -1);
-
- test_match ("(a|b)*c", "ac");
- TEST_REGISTERS ("(a|b)*c", "ac", 0, 2, 0, 1, -1, -1);
-
- test_match ("(a|b)*c", "bc");
- TEST_REGISTERS ("(a|b)*c", "bc", 0, 2, 0, 1, -1, -1);
-
- test_match ("(a|b)*c", "abc");
- TEST_REGISTERS ("(a|b)*c", "abc", 0, 3, 1, 2, -1, -1);
-
-
- test_match ("(a*|b*)c", "bbc");
- TEST_REGISTERS ("(a*|b*)c", "bbc", 0, 3, 0, 2, -1, -1);
-
- /* Complicated second alternative. */
-
- test_match ("(a*|(b*)*)*c", "bc");
- TEST_REGISTERS ("(a*|(b*)*)*c", "bc", 0, 2, 0, 1, 0, 1);
-
- test_match ("(a*|(b*|c*)*)*d", "bd");
- TEST_REGISTERS ("(a*|(b*|c*)*)*d", "bd", 0, 2, 0, 1, 0, 1);
-
- test_match ("(a*|(b*|c*)*)*d", "bbd");
- TEST_REGISTERS ("(a*|(b*|c*)*)*d", "bbd", 0, 3, 0, 2, 0, 2);
-
- test_match ("(a*|(b*|c*)*)*d", "cd");
- TEST_REGISTERS ("(a*|(b*|c*)*)*d", "cd", 0, 2, 0, 1, 0, 1);
-
- test_match ("(a*|(b*|c*)*)*d", "ccd");
- TEST_REGISTERS ("(a*|(b*|c*)*)*d", "ccd", 0, 3, 0, 2, 0, 2);
-
- test_match ("(a*|b*|c*)*d", "aad");
- TEST_REGISTERS ("(a*|b*|c*)*d", "aad", 0, 3, 0, 2, 0, 2);
-
- test_match ("(a*|b*|c*)*d", "bbd");
- TEST_REGISTERS ("(a*|b*|c*)*d", "bbd", 0, 3, 0, 2, 0, 2);
-
- test_match ("(a*|b*|c*)*d", "ccd");
- TEST_REGISTERS ("(a*|b*|c*)*d", "ccd", 0, 3, 0, 2, 0, 2);
-
- /* Valid anchoring. */
- valid_pattern ("a^");
- valid_pattern ("a^b");
- valid_pattern ("$a");
- valid_pattern ("a$b");
- valid_pattern ("foo^bar");
- valid_pattern ("foo$bar");
- valid_pattern ("(^)");
- valid_pattern ("($)");
- valid_pattern ("(^$)");
-
- /* These are the same (but valid) as those (invalid) in other_test.c. */
- valid_pattern
- ("(((((((((((((((((((((((((((((((((a^)))))))))))))))))))))))))))))))))");
- valid_pattern
- ("((((((((((((((((((((((((((((((((($a)))))))))))))))))))))))))))))))))");
- valid_pattern ("\\(^a\\)");
- valid_pattern ("a\\|^b");
- valid_pattern ("\\w^a");
- valid_pattern ("\\W^a");
- valid_pattern ("(a^)");
- valid_pattern ("($a)");
- valid_pattern ("a(^b)");
- valid_pattern ("a$(b)");
- valid_pattern ("(a)^b");
- valid_pattern ("(a)$b");
- valid_pattern ("(a)(^b)");
- valid_pattern ("(a$)(b)");
- valid_pattern ("(a|b)^c");
- valid_pattern ("(a|b)$c");
- valid_pattern ("(a$|b)c");
- valid_pattern ("(a|b$)c");
- valid_pattern ("a(b|^c)");
- valid_pattern ("a(^b|c)");
- valid_pattern ("a$(b|c)");
- valid_pattern ("(a)(^b|c)");
- valid_pattern ("(a)(b|^c)");
- valid_pattern ("(b$|c)(a)");
- valid_pattern ("(b|c$)(a)");
- valid_pattern ("(a(^b|c))");
- valid_pattern ("(a(b|^c))");
- valid_pattern ("((b$|c)a)");
- valid_pattern ("((b|c$)a)");
- valid_pattern ("((^a|^b)^c)");
- valid_pattern ("(c$(a$|b$))");
- valid_pattern ("((^a|^b)^c)");
- valid_pattern ("((a$|b$)c)");
- valid_pattern ("(c$(a$|b$))");
- valid_pattern ("((^a|^b)|^c)^d");
- valid_pattern ("((a$|b$)|c$)d$");
- valid_pattern ("d$(c$|(a$|b$))");
- valid_pattern ("((^a|^b)|^c)(^d)");
- valid_pattern ("((a$|b$)|c$)(d$)");
- valid_pattern ("(d$)((a$|b$)|c$)");
- valid_pattern ("((^a|^b)|^c)((^d))");
- valid_pattern ("((a$|b$)|c$)((d$))");
- valid_pattern ("((d$))((a$|b$)|c$)");
- valid_pattern ("(((^a|^b))c|^d)^e");
- valid_pattern ("(((a$|b$))c|d$)$e$");
- valid_pattern ("e$(d$|c((a$|b$)))");
- valid_pattern ("(^a)((^b))");
- valid_pattern ("(a$)((b$))");
- valid_pattern ("((^a))(^b)");
- valid_pattern ("((a$))(b$)");
- valid_pattern ("((^a))((^b))");
- valid_pattern ("((a$))((b$))");
- valid_pattern ("((^a)^b)");
- valid_pattern ("((a$)b$)");
- valid_pattern ("(b$(a$))");
- valid_pattern ("(((^a)b)^c)");
- valid_pattern ("(((a$)b)c$)");
- valid_pattern ("(c$(b(a$)))");
- valid_pattern ("(((^a)b)c)^d");
- valid_pattern ("(((a$)b)c)d$");
- valid_pattern ("d$(c(b(a$)))");
- valid_pattern (".^a");
- valid_pattern ("a$.");
- valid_pattern ("[a]^b");
- valid_pattern ("b$[a]");
- valid_pattern ("\\(a$\\)");
- valid_pattern ("a$\\|b");
- valid_pattern ("(^a|^b)^c");
- valid_pattern ("c$(a$|b$)");
- valid_pattern ("(^a|^b)^|^c");
- valid_pattern ("(a$|b$)$|$c$");
- valid_pattern ("(a$|$b$)$|c$");
- valid_pattern ("($a$|b$)$|c$");
- valid_pattern ("$(a$|b$)$|c$");
- valid_pattern ("^c|d(^a|^b)");
- valid_pattern ("(^a|^b)|d^c");
- valid_pattern ("c$|(a$|b$)d");
- valid_pattern ("c$d|(a$|b$)");
- valid_pattern ("c(^a|^b)|^d");
- valid_pattern ("(a$|b$)c|d$");
- valid_pattern ("c(((^a|^b))|^d)e");
- valid_pattern ("(c((^a|^b))|^d)e");
- valid_pattern ("((c(^a|^b))|^d)e");
- valid_pattern ("(((^a|^b))|c^d)e");
- valid_pattern ("(((^a|^b))|^d)^e");
- valid_pattern ("(c$((a|b))|d)e$");
- valid_pattern ("(c((a$|b$))|d)e$");
- valid_pattern ("(c((a|b)$)|d)e$");
- valid_pattern ("(c((a|b))|d$)e$");
- valid_pattern ("^d(^c|e((a|b)))");
- valid_pattern ("^d(c|^e((a|b)))");
- valid_pattern ("^d(c|e(^(a|b)))");
- valid_pattern ("^d(c|e((^a|b)))");
- valid_pattern ("^d(c|e((a|^b)))");
- valid_pattern ("^d(c|e((a|b^)))");
- valid_pattern ("^d(c|e((a|b)^))");
- valid_pattern ("^d(c|e((a|b))^)");
- valid_pattern ("^d(c|e((a|b)))^");
- valid_pattern ("d$(c$|e((a$|b$)))");
- valid_pattern ("d(c$|e$((a$|b$)))");
- valid_pattern ("(((^a|^b))^c)|^de");
- valid_pattern ("(((^a|^b))c)|^d^e");
- valid_pattern ("(((a$|b))c$)|de$");
- valid_pattern ("(((a|b$))c$)|de$");
- valid_pattern ("(((a|b))c$)|d$e$");
- valid_pattern ("^d^e|^(c((a|b)))");
- valid_pattern ("^de|^(c^((a|b)))");
- valid_pattern ("^de|^(c(^(a|b)))");
- valid_pattern ("^de|^(c((^a|b)))");
- valid_pattern ("^de|^(c((a|^b)))");
- valid_pattern ("^de|(^c(^(a|b)))");
- valid_pattern ("^de|(^c((^a|b)))");
- valid_pattern ("^de|(^c((a|^b)))");
- valid_pattern ("de$|(c($(a|b)$))");
- valid_pattern ("de$|(c$((a|b)$))");
- valid_pattern ("de$|($c((a|b)$))");
- valid_pattern ("de$|$(c((a|b)$))");
- valid_pattern ("de$|(c($(a|b))$)");
- valid_pattern ("de$|(c$((a|b))$)");
- valid_pattern ("de$|$(c((a|b))$)");
- valid_pattern ("de$|(c($(a|b)))$");
- valid_pattern ("de$|(c$((a|b)))$");
- valid_pattern ("de$|($c((a|b)))$");
- valid_pattern ("de$|$(c((a|b)))$");
- valid_pattern ("^a(^b|c)|^d");
- valid_pattern ("^a(b|^c)|^d");
- valid_pattern ("^a(b|c^)|^d");
- valid_pattern ("^a(b|c)^|^d");
- valid_pattern ("a$(b$|c$)|d$");
- valid_pattern ("^d|^a(^b|c)");
- valid_pattern ("^d|^a(b|^c)");
- valid_pattern ("d$|a$(b$|c$)");
- valid_pattern ("^d|^(b|c)^a");
- valid_pattern ("d$|(b|c$)a$");
- valid_pattern ("d$|(b$|c)a$");
- valid_pattern ("^(a)^(b|c)|^d");
- valid_pattern ("^(a)(^b|c)|^d");
- valid_pattern ("^(a)(b|^c)|^d");
- valid_pattern ("(a)$(b|c)$|d$");
- valid_pattern ("(a$)(b|c)$|d$");
- valid_pattern ("(^a)(^b|c)|^d");
- valid_pattern ("(^a)(b|^c)|^d");
- valid_pattern ("(a)$(b$|c$)|d$");
- valid_pattern ("(a$)(b$|c$)|d$");
- valid_pattern ("^d|^(b|c)^(a)");
- valid_pattern ("^d|^(b|c)(^a)");
- valid_pattern ("d$|(b|c$)(a)$");
- valid_pattern ("d$|(b$|c)(a)$");
- valid_pattern ("^d|(^b|^c)^(a)");
- valid_pattern ("^d|(^b|^c)(^a)");
- valid_pattern ("d$|(b|c)$(a$)");
- valid_pattern ("d$|(b|c$)(a$)");
- valid_pattern ("d$|(b$|c)(a$)");
- valid_pattern ("^d|^(a)^(b|c)");
- valid_pattern ("^d|^(a)(^b|c)");
- valid_pattern ("^d|^(a)(b|^c)");
- valid_pattern ("^d|(^a)^(b|c)");
- valid_pattern ("^d|(^a)(^b|c)");
- valid_pattern ("^d|(^a)(b|^c)");
- valid_pattern ("d$|(a)$(b$|c$)");
- valid_pattern ("d$|(a$)(b$|c$)");
- valid_pattern ("((e^a|^b)|^c)|^d");
- valid_pattern ("((^a|e^b)|^c)|^d");
- valid_pattern ("((^a|^b)|e^c)|^d");
- valid_pattern ("((^a|^b)|^c)|e^d");
- valid_pattern ("d$e|(c$|(a$|b$))");
- valid_pattern ("d$|(c$e|(a$|b$))");
- valid_pattern ("d$|(c$|(a$e|b$))");
- valid_pattern ("d$|(c$|(a$|b$e))");
- valid_pattern ("d$|(c$|(a$|b$)e)");
- valid_pattern ("d$|(c$|(a$|b$))e");
- valid_pattern ("(a|b)^|c");
- valid_pattern ("(a|b)|c^");
- valid_pattern ("$(a|b)|c");
- valid_pattern ("(a|b)|$c");
- valid_pattern ("(a^|^b)|^c");
- valid_pattern ("(^a|b^)|^c");
- valid_pattern ("(^a|^b)|c^");
- valid_pattern ("($a|b$)|c$");
- valid_pattern ("(a$|$b)|c$");
- valid_pattern ("(a$|b$)|$c");
- valid_pattern ("c^|(^a|^b)");
- valid_pattern ("^c|(a^|^b)");
- valid_pattern ("^c|(^a|b^)");
- valid_pattern ("$c|(a$|b$)");
- valid_pattern ("c$|($a|b$)");
- valid_pattern ("c$|(a$|$b)");
- valid_pattern ("c^|^(a|b)");
- valid_pattern ("^c|(a|b)^");
- valid_pattern ("$c|(a|b)$");
- valid_pattern ("c$|$(a|b)");
- valid_pattern ("(a^|^b)c|^d");
- valid_pattern ("(^a|b^)c|^d");
- valid_pattern ("(^a|^b)c|d^");
- valid_pattern ("(^a|^b)^c|^d");
- valid_pattern ("(a|b)c$|$d");
- valid_pattern ("(a|b)$c$|d$");
- valid_pattern ("(a|b)$c$|d$");
- valid_pattern ("(a|b$)c$|d$");
- valid_pattern ("(a$|b)c$|d$");
- valid_pattern ("($a|b)c$|d$");
- valid_pattern ("$(a|b)c$|d$");
- valid_pattern ("^d|^c^(a|b)");
- valid_pattern ("^d|^c(^a|b)");
- valid_pattern ("^d|^c(a|^b)");
- valid_pattern ("^d|^c(a|b^)");
- valid_pattern ("^d|^c(a|b)^");
- valid_pattern ("$d|c(a$|b$)");
- valid_pattern ("d$|c($a$|b$)");
- valid_pattern ("d$|c$(a$|b$)");
- valid_pattern ("d$|$c(a$|b$)");
-
- valid_pattern ("(((a^|^b))c|^d)e");
- valid_pattern ("(((^a|b^))c|^d)e");
- valid_pattern ("(((^a|^b))^c|^d)e");
- valid_pattern ("((^(a|b))c|d^)e");
- valid_pattern ("(^((a|b))c|^d)^e");
- valid_pattern ("(^((a|b)^)c|^d)e");
- valid_pattern ("(^((a^|b))c|^d)e");
- valid_pattern ("(^((a|b^))c|^d)e");
- valid_pattern ("(^((a|b)^)c|^d)e");
- valid_pattern ("(^((a|b))^c|^d)e");
- valid_pattern ("(^((a|b))c^|^d)e");
- valid_pattern ("(^((a|b))c|^d^)e");
- valid_pattern ("(^((a|b))c|^d)^e");
- valid_pattern ("(((a|b))c|d)$e$");
- valid_pattern ("(((a|b))c|d$)e$");
- valid_pattern ("(((a|b))c|$d)e$");
- valid_pattern ("(((a|b))c$|d)e$");
- valid_pattern ("(((a|b))$c|d)e$");
- valid_pattern ("(((a|b)$)c|d)e$");
- valid_pattern ("(((a|b$))c|d)e$");
- valid_pattern ("(((a$|b))c|d)e$");
- valid_pattern ("((($a|b))c|d)e$");
- valid_pattern ("(($(a|b))c|d)e$");
- valid_pattern ("($((a|b))c|d)e$");
- valid_pattern ("$(((a|b))c|d)e$");
- valid_pattern ("(^((a|b)^)c|^d)e");
- valid_pattern ("(^((a|b))^c|^d)e");
- valid_pattern ("(^((a|b))c|^d^)e");
- valid_pattern ("(^((a|b))c|^d)^e");
-
- valid_pattern ("^e(^d|c((a|b)))");
- valid_pattern ("^e(d|^c((a|b)))");
- valid_pattern ("^e(d|c^((a|b)))");
- valid_pattern ("^e(d|c(^(a|b)))");
- valid_pattern ("^e(d|c((^a|b)))");
- valid_pattern ("^e(d|c((a|^b)))");
- valid_pattern ("^e(d|c((a|b^)))");
- valid_pattern ("^e(d|c((a|b)^))");
- valid_pattern ("^e(d|c((a|b))^)");
- valid_pattern ("^e(d|c((a|b)))^");
- valid_pattern ("e$(d$|c((a$|b$)))");
- valid_pattern ("e(d$|c$((a$|b$)))");
- valid_pattern ("e(d$|c($(a$|b$)))");
- valid_pattern ("e(d$|c(($a$|b$)))");
- valid_pattern ("e$(d$|c((a|b)$))");
- valid_pattern ("e($d$|c((a|b)$))");
- valid_pattern ("e(d$|$c((a|b)$))");
- valid_pattern ("e(d$|c$((a|b)$))");
- valid_pattern ("e(d$|c($(a|b)$))");
- valid_pattern ("e(d$|c(($a|b)$))");
- valid_pattern ("e(d$|c((a|$b)$))");
- valid_pattern ("e(d$|c((a$|$b$)))");
-
- valid_pattern ("e$(d$|c((a|b))$)");
- valid_pattern ("e($d$|c((a|b))$)");
- valid_pattern ("e(d$|$c((a|b))$)");
- valid_pattern ("e(d$|c$((a|b))$)");
- valid_pattern ("e(d$|c($(a|b))$)");
- valid_pattern ("e(d$|c(($a|b))$)");
- valid_pattern ("e(d$|c((a|$b))$)");
- valid_pattern ("e$(d$|c((a|b)))$");
- valid_pattern ("e($d$|c((a|b)))$");
- valid_pattern ("e(d$|$c((a|b)))$");
- valid_pattern ("e(d$|c$((a|b)))$");
- valid_pattern ("e(d$|c($(a|b)))$");
- valid_pattern ("e(d$|c(($a|b)))$");
- valid_pattern ("e(d$|c((a|$b)))$");
- valid_pattern ("(((^a|^b)^)c)|^de");
- valid_pattern ("(((^a|^b))^c)|^de");
- valid_pattern ("(((^a|^b))c)^|^de");
- valid_pattern ("$(((a|b))c$)|de$");
- valid_pattern ("($((a|b))c$)|de$");
- valid_pattern ("(($(a|b))c$)|de$");
- valid_pattern ("((($a|b))c$)|de$");
- valid_pattern ("(((a|$b))c$)|de$");
- valid_pattern ("(((a|b)$)c$)|de$");
- valid_pattern ("(((a|b))$c$)|de$");
- valid_pattern ("$(((a|b))c)$|de$");
- valid_pattern ("($((a|b))c)$|de$");
- valid_pattern ("(($(a|b))c)$|de$");
- valid_pattern ("((($a|b))c)$|de$");
- valid_pattern ("(((a|$b))c)$|de$");
- valid_pattern ("(((a|b)$)c)$|de$");
- valid_pattern ("(((a|b))$c)$|de$");
- valid_pattern ("^ed|^(c((a|b)))^");
- valid_pattern ("^ed|^(c((a|b))^)");
- valid_pattern ("^ed|^(c((a|b)^))");
- valid_pattern ("^ed|^(c((a|b^)))");
- valid_pattern ("^ed|^(c((a^|b)))");
- valid_pattern ("^ed|^(c((^a|b)))");
- valid_pattern ("^ed|^(c(^(a|b)))");
- valid_pattern ("^ed|^(c^((a|b)))");
- valid_pattern ("^ed|(^c((a|b)))^");
- valid_pattern ("^ed|(^c((a|b))^)");
- valid_pattern ("^ed|(^c((a|b)^))");
- valid_pattern ("^ed|(^c((a|b^)))");
- valid_pattern ("^ed|(^c((a|^b)))");
- valid_pattern ("^ed|(^c((a^|b)))");
- valid_pattern ("^ed|(^c((^a|b)))");
- valid_pattern ("^ed|(^c(^(a|b)))");
- valid_pattern ("^ed|(^c(^(a|b)))");
- valid_pattern ("^ed|(^c^((a|b)))");
- valid_pattern ("ed$|$(c((a|b)))$");
- valid_pattern ("ed$|($c((a|b)))$");
- valid_pattern ("ed$|(c$((a|b)))$");
- valid_pattern ("ed$|(c($(a|b)))$");
- valid_pattern ("ed$|(c(($a|b)))$");
- valid_pattern ("ed$|(c((a|$b)))$");
- valid_pattern ("ed$|$(c((a|b))$)");
- valid_pattern ("ed$|($c((a|b))$)");
- valid_pattern ("ed$|(c$((a|b))$)");
- valid_pattern ("ed$|(c($(a|b))$)");
- valid_pattern ("ed$|(c(($a|b))$)");
- valid_pattern ("ed$|(c((a|$b))$)");
- valid_pattern ("ed$|$(c((a|b)$))");
- valid_pattern ("ed$|($c((a|b)$))");
- valid_pattern ("ed$|(c$((a|b)$))");
- valid_pattern ("ed$|(c($(a|b)$))");
- valid_pattern ("ed$|(c(($a|b)$))");
- valid_pattern ("ed$|(c((a|$b)$))");
- valid_pattern ("ed$|$(c((a|b)$))");
- valid_pattern ("ed$|($c((a|b)$))");
- valid_pattern ("ed$|(c$((a|b)$))");
- valid_pattern ("ed$|(c($(a|b)$))");
- valid_pattern ("ed$|(c(($a|b)$))");
- valid_pattern ("ed$|(c((a|$b)$))");
- valid_pattern ("ed$|$(c((a|b)$))");
- valid_pattern ("ed$|($c((a|b)$))");
- valid_pattern ("ed$|(c$((a|b)$))");
- valid_pattern ("ed$|(c($(a|b)$))");
- valid_pattern ("ed$|(c(($a|b)$))");
- valid_pattern ("ed$|(c((a|$b)$))");
- valid_pattern ("ed$|$(c((a|b)$))");
- valid_pattern ("ed$|($c((a|b)$))");
- valid_pattern ("ed$|(c$((a|b)$))");
- valid_pattern ("ed$|(c($(a|b)$))");
- valid_pattern ("ed$|(c(($a|b)$))");
- valid_pattern ("ed$|(c((a|$b)$))");
- valid_pattern ("ed$|$(c((a|b)$))");
- valid_pattern ("ed$|($c((a|b)$))");
- valid_pattern ("ed$|(c$((a|b)$))");
- valid_pattern ("ed$|(c($(a|b)$))");
- valid_pattern ("ed$|(c(($a|b)$))");
- valid_pattern ("ed$|(c((a|$b)$))");
- valid_pattern ("ed$|$(c((a$|b$)))");
- valid_pattern ("ed$|($c((a$|b$)))");
- valid_pattern ("ed$|(c$((a$|b$)))");
- valid_pattern ("ed$|(c($(a$|b$)))");
- valid_pattern ("ed$|(c(($a$|b$)))");
- valid_pattern ("ed$|(c((a$|$b$)))");
- valid_pattern ("^a(b|c)^|^d");
- valid_pattern ("^a(b|c^)|^d");
- valid_pattern ("^a(b|^c)|^d");
- valid_pattern ("^a(b^|c)|^d");
- valid_pattern ("^a(^b|c)|^d");
- valid_pattern ("^a^(b|c)|^d");
- valid_pattern ("$a(b$|c$)|d$");
- valid_pattern ("a$(b$|c$)|d$");
- valid_pattern ("a($b$|c$)|d$");
- valid_pattern ("a(b$|$c$)|d$");
- valid_pattern ("a(b$|c$)|$d$");
- valid_pattern ("^(a^)(b|c)|^d");
- valid_pattern ("^(a)^(b|c)|^d");
- valid_pattern ("^(a)(^b|c)|^d");
- valid_pattern ("^(a)(b^|c)|^d");
- valid_pattern ("^(a)(b|^c)|^d");
- valid_pattern ("^(a)(b|c^)|^d");
- valid_pattern ("^(a)(b|c)^|^d");
- valid_pattern ("(^a^)(b|c)|^d");
- valid_pattern ("(^a)^(b|c)|^d");
- valid_pattern ("(^a)(^b|c)|^d");
- valid_pattern ("(^a)(b^|c)|^d");
- valid_pattern ("(^a)(b|^c)|^d");
- valid_pattern ("(^a)(b|c^)|^d");
- valid_pattern ("(^a)(b|c)^|^d");
-
- valid_pattern ("(a)(b$|c$)d$");
- valid_pattern ("(a)(b|$c)$|d$");
- valid_pattern ("(a)($b|c)$|d$");
- valid_pattern ("(a)$(b|c)$|d$");
- valid_pattern ("(a$)(b|c)$|d$");
- valid_pattern ("($a)(b|c)$|d$");
- valid_pattern ("$(a)(b|c)$|d$");
- valid_pattern ("(b|c)($a)$|d$");
- valid_pattern ("(b|c)$(a)$|d$");
- valid_pattern ("(b|c$)(a)$|d$");
- valid_pattern ("(b|$c)(a)$|d$");
- valid_pattern ("(b$|c)(a)$|d$");
- valid_pattern ("($b|c)(a)$|d$");
- valid_pattern ("$(b|c)(a)$|d$");
- valid_pattern ("(b|c)($a$)|d$");
- valid_pattern ("(b|c)$(a$)|d$");
- valid_pattern ("(b|c$)(a$)|d$");
- valid_pattern ("(b|$c)(a$)|d$");
- valid_pattern ("(b$|c)(a$)|d$");
- valid_pattern ("($b|c)(a$)|d$");
- valid_pattern ("$(b|c)(a$)|d$");
- valid_pattern ("(a)$(b$|c$)|d$");
- valid_pattern ("(a$)(b$|c$)|d$");
- valid_pattern ("($a)(b$|c$)|d$");
- valid_pattern ("$(a)(b$|c$)|d$");
- valid_pattern ("^d|^(b^|c)(a)");
- valid_pattern ("^d|^(b|c^)(a)");
- valid_pattern ("^d|^(b|c)^(a)");
- valid_pattern ("^d|^(b|c)(^a)");
- valid_pattern ("^d|^(b|c)(a^)");
- valid_pattern ("^d|^(b|c)(a)^");
- valid_pattern ("^d|(^b|^c^)(a)");
- valid_pattern ("^d|(^b|^c)^(a)");
- valid_pattern ("^d|(^b|^c)(^a)");
- valid_pattern ("^d|(^b|^c)(a^)");
- valid_pattern ("^d|(^b|^c)(a)^");
- valid_pattern ("d$|(b|c)($a$)");
- valid_pattern ("d$|(b|c)$(a$)");
- valid_pattern ("d$|(b|c$)(a$)");
- valid_pattern ("d$|(b$|c)(a$)");
- valid_pattern ("d$|($b|c)(a$)");
- valid_pattern ("d$|$(b|c)(a$)");
- valid_pattern ("d$|(b|c)($a)$");
- valid_pattern ("d$|(b|c)$(a)$");
- valid_pattern ("d$|(b|c$)(a)$");
- valid_pattern ("d$|(b$|c)(a)$");
- valid_pattern ("d$|($b|c)(a)$");
- valid_pattern ("d$|$(b|c)(a)$");
- valid_pattern ("^d|^(a^)(b|c)");
- valid_pattern ("^d|^(a)^(b|c)");
- valid_pattern ("^d|^(a)(^b|c)");
- valid_pattern ("^d|^(a)(b^|c)");
- valid_pattern ("^d|^(a)(b|^c)");
- valid_pattern ("^d|^(a)(b|c^)");
- valid_pattern ("^d|^(a)(b|c)^");
- valid_pattern ("^d|(^a^)(b|c)");
- valid_pattern ("^d|(^a)^(b|c)");
- valid_pattern ("^d|(^a)(^b|c)");
- valid_pattern ("^d|(^a)(b^|c)");
- valid_pattern ("^d|(^a)(b|^c)");
- valid_pattern ("^d|(^a)(b|c^)");
- valid_pattern ("^d|(^a)(b|c)^");
- valid_pattern ("d$|(a)$(b$|c$)");
- valid_pattern ("d$|(a$)(b$|c$)");
- valid_pattern ("d$|($a)(b$|c$)");
- valid_pattern ("d$|$(a)(b$|c$)");
- valid_pattern ("d$|(a)(b|$c)$");
- valid_pattern ("d$|(a)($b|c)$");
- valid_pattern ("d$|(a)$(b|c)$");
- valid_pattern ("d$|(a$)(b|c)$");
- valid_pattern ("d$|($a)(b|c)$");
- valid_pattern ("d$|$(a)(b|c)$");
- valid_pattern ("((^a|^b)|^c)|^d^");
- valid_pattern ("((^a|^b)|^c)^|^d");
- valid_pattern ("((^a|^b)|^c^)|^d");
- valid_pattern ("((^a|^b)^|^c)|^d");
- valid_pattern ("((^a|^b^)|^c)|^d");
- valid_pattern ("((^a^|^b)|^c)|^d");
- valid_pattern ("((a|b)|c)|$d$");
- valid_pattern ("((a|b)|$c)|d$");
- valid_pattern ("((a|$b)|c)|d$");
- valid_pattern ("(($a|b)|c)|d$");
- valid_pattern ("($(a|b)|c)|d$");
- valid_pattern ("$((a|b)|c)|d$");
- valid_pattern ("^d^|(c|(a|b))");
- valid_pattern ("^d|(c^|(a|b))");
- valid_pattern ("^d|(c|(a^|b))");
- valid_pattern ("^d|(c|(a|b^))");
- valid_pattern ("^d|(c|(a|b)^)");
- valid_pattern ("^d|(c|(a|b))^");
- valid_pattern ("d$|(c$|(a$|$b$))");
- valid_pattern ("d$|(c$|($a$|b$))");
- valid_pattern ("d$|($c$|(a$|b$))");
- valid_pattern ("d$|$(c$|(a$|b$))");
- valid_pattern ("$d$|(c$|(a$|b$))");
- valid_pattern ("d$|(c$|(a|$b)$)");
- valid_pattern ("d$|(c$|($a|b)$)");
- valid_pattern ("d$|($c$|(a|b)$)");
- valid_pattern ("d$|$(c$|(a|b)$)");
- valid_pattern ("$d$|(c$|(a|b)$)");
- valid_pattern ("d$|(c$|(a|$b))$");
- valid_pattern ("d$|(c$|($a|b))$");
- valid_pattern ("d$|($c$|(a|b))$");
- valid_pattern ("d$|$(c$|(a|b))$");
- valid_pattern ("$d$|(c$|(a|b))$");
- valid_pattern ("^c^|(^a|^b)");
- valid_pattern ("^c|(^a^|^b)");
- valid_pattern ("^c|(^a|^b^)");
- valid_pattern ("^c|(^a|^b)^");
- valid_pattern ("c$|(a$|$b$)");
- valid_pattern ("c$|($a$|b$)");
- valid_pattern ("c$|$(a$|b$)");
- valid_pattern ("$c$|(a$|b$)");
- valid_pattern ("^d^(c|e((a|b)))");
- valid_pattern ("^d(^c|e((a|b)))");
- valid_pattern ("^d(c^|e((a|b)))");
- valid_pattern ("^d(c|^e((a|b)))");
- valid_pattern ("^d(c|e^((a|b)))");
- valid_pattern ("^d(c|e(^(a|b)))");
- valid_pattern ("^d(c|e((^a|b)))");
- valid_pattern ("^d(c|e((a|^b)))");
- valid_pattern ("^d(c|e((a|b^)))");
- valid_pattern ("^d(c|e((a|b)^))");
- valid_pattern ("^d(c|e((a|b))^)");
- valid_pattern ("^d(c|e((a|b)))^");
- valid_pattern ("d(c$|e($(a$|b$)))");
- valid_pattern ("d(c$|e$((a$|b$)))");
- valid_pattern ("d(c$|$e((a$|b$)))");
- valid_pattern ("d($c$|e((a$|b$)))");
- valid_pattern ("d$(c$|e((a$|b$)))");
- valid_pattern ("$d(c$|e((a$|b$)))");
- valid_pattern ("^d|^a^(b|c)");
- valid_pattern ("^d|^a(^b|c)");
- valid_pattern ("^d|^a(b^|c)");
- valid_pattern ("^d|^a(b|^c)");
- valid_pattern ("^d|^a(b|c^)");
- valid_pattern ("^d|^a(b|c)^");
- valid_pattern ("d$|a($b$|c$)");
- valid_pattern ("d$|a$(b$|c$)");
- valid_pattern ("d$|$a(b$|c$)");
- valid_pattern ("$d$|a(b$|c$)");
- valid_pattern ("^d|^(b^|c)a");
- valid_pattern ("^d|^(b|c^)a");
- valid_pattern ("^d|^(b|c)^a");
- valid_pattern ("^d|^(b|c)a^");
- valid_pattern ("d$|(b|c)$a$");
- valid_pattern ("d$|(b|c$)a$");
- valid_pattern ("d$|(b|$c)a$");
- valid_pattern ("d$|(b$|c)a$");
- valid_pattern ("d$|($b|c)a$");
- valid_pattern ("d$|$(b|c)a$");
- valid_pattern ("$d$|(b|c)a$");
-
- /* xx Do these use all the valid_nonposix_pattern ones in other_test.c? */
-
- TEST_SEARCH ("(^a|^b)c", "ac", 0, 2);
- TEST_SEARCH ("(^a|^b)c", "bc", 0, 2);
- TEST_SEARCH ("c(a$|b$)", "ca", 0, 2);
- TEST_SEARCH ("c(a$|b$)", "cb", 0, 2);
- TEST_SEARCH ("^(a|b)|^c", "ad", 0, 2);
- TEST_SEARCH ("^(a|b)|^c", "bd", 0, 2);
- TEST_SEARCH ("(a|b)$|c$", "da", 0, 2);
- TEST_SEARCH ("(a|b)$|c$", "db", 0, 2);
- TEST_SEARCH ("(a|b)$|c$", "dc", 0, 2);
- TEST_SEARCH ("(^a|^b)|^c", "ad", 0, 2);
- TEST_SEARCH ("(^a|^b)|^c", "bd", 0, 2);
- TEST_SEARCH ("(^a|^b)|^c", "cd", 0, 2);
- TEST_SEARCH ("(a$|b$)|c$", "da", 0, 2);
- TEST_SEARCH ("(a$|b$)|c$", "db", 0, 2);
- TEST_SEARCH ("(a$|b$)|c$", "dc", 0, 2);
- TEST_SEARCH ("^c|(^a|^b)", "ad", 0, 2);
- TEST_SEARCH ("^c|(^a|^b)", "bd", 0, 2);
- TEST_SEARCH ("^c|(^a|^b)", "cd", 0, 2);
- TEST_SEARCH ("c$|(a$|b$)", "da", 0, 2);
- TEST_SEARCH ("c$|(a$|b$)", "db", 0, 2);
- TEST_SEARCH ("c$|(a$|b$)", "dc", 0, 2);
- TEST_SEARCH ("^c|^(a|b)", "ad", 0, 2);
- TEST_SEARCH ("^c|^(a|b)", "bd", 0, 2);
- TEST_SEARCH ("^c|^(a|b)", "cd", 0, 2);
- TEST_SEARCH ("c$|(a|b)$", "da", 0, 2);
- TEST_SEARCH ("c$|(a|b)$", "db", 0, 2);
- TEST_SEARCH ("c$|(a|b)$", "dc", 0, 2);
- TEST_SEARCH ("(^a|^b)c|^d", "ace", 0, 3);
- TEST_SEARCH ("(^a|^b)c|^d", "bce", 0, 3);
- TEST_SEARCH ("(^a|^b)c|^d", "de", 0, 2);
- TEST_SEARCH ("(a|b)c$|d$", "eac", 0, 3);
- TEST_SEARCH ("(a|b)c$|d$", "ebc", 0, 3);
- TEST_SEARCH ("(a|b)c$|d$", "ed", 0, 3);
- TEST_SEARCH ("^d|^c(a|b)", "cae", 0, 3);
- TEST_SEARCH ("^d|^c(a|b)", "cbe", 0, 3);
- TEST_SEARCH ("^d|^c(a|b)", "de", 0, 3);
- TEST_SEARCH ("d$|c(a$|b$)", "eca", 0, 3);
- TEST_SEARCH ("d$|c(a$|b$)", "ecb", 0, 3);
- TEST_SEARCH ("d$|c(a$|b$)", "ed", 0, 3);
-
- TEST_SEARCH ("(((^a|^b))c|^d)e", "acef", 0, 4);
- TEST_SEARCH ("(((^a|^b))c|^d)e", "bcef", 0, 4);
- TEST_SEARCH ("(((^a|^b))c|^d)e", "def", 0, 3);
-
- TEST_SEARCH ("((^(a|b))c|^d)e", "acef", 0, 4);
- TEST_SEARCH ("((^(a|b))c|^d)e", "bcef", 0, 4);
- TEST_SEARCH ("((^(a|b))c|^d)e", "def", 0, 3);
-
- TEST_SEARCH ("(^((a|b))c|^d)e", "acef", 0, 4);
- TEST_SEARCH ("(^((a|b))c|^d)e", "bcef", 0, 4);
- TEST_SEARCH ("(^((a|b))c|^d)e", "def", 0, 3);
-
- TEST_SEARCH ("(((a|b))c|d)e$", "face", 0, 4);
- TEST_SEARCH ("(((a|b))c|d)e$", "fbce", 0, 4);
- TEST_SEARCH ("(((a|b))c|d)e$", "fde", 0, 3);
-
- TEST_SEARCH ("^e(d|c((a|b)))", "edf", 0, 3);
- TEST_SEARCH ("^e(d|c((a|b)))", "ecaf", 0, 4);
- TEST_SEARCH ("^e(d|c((a|b)))", "ecbf", 0, 4);
-
- TEST_SEARCH ("e(d$|c((a$|b$)))", "fed", 0, 3);
- TEST_SEARCH ("e(d$|c((a$|b$)))", "feca", 0, 4);
- TEST_SEARCH ("e(d$|c((a$|b$)))", "fecb", 0, 4);
-
- TEST_SEARCH ("e(d$|c((a|b)$))", "fed", 0, 3);
- TEST_SEARCH ("e(d$|c((a|b)$))", "feca", 0, 4);
- TEST_SEARCH ("e(d$|c((a|b)$))", "fecb", 0, 4);
-
- TEST_SEARCH ("e(d$|c((a|b))$)", "fed", 0, 3);
- TEST_SEARCH ("e(d$|c((a|b))$)", "feca", 0, 3);
- TEST_SEARCH ("e(d$|c((a|b))$)", "fecb", 0, 3);
-
- TEST_SEARCH ("e(d$|c((a|b)))$", "fed", 0, 3);
- TEST_SEARCH ("e(d$|c((a|b)))$", "feca", 0, 3);
- TEST_SEARCH ("e(d$|c((a|b)))$", "fecb", 0, 3);
-
- TEST_SEARCH ("(((^a|^b))c)|^de", "acf", 0, 3);
- TEST_SEARCH ("(((^a|^b))c)|^de", "bcf", 0, 3);
- TEST_SEARCH ("(((^a|^b))c)|^de", "def", 0, 3);
-
- TEST_SEARCH ("(((a|b))c$)|de$", "fac", 0, 3);
- TEST_SEARCH ("(((a|b))c$)|de$", "fbc", 0, 3);
- TEST_SEARCH ("(((a|b))c$)|de$", "fde", 0, 3);
-
- TEST_SEARCH ("(((a|b))c)$|de$", "fac", 0, 3);
- TEST_SEARCH ("(((a|b))c)$|de$", "fbc", 0, 3);
- TEST_SEARCH ("(((a|b))c)$|de$", "fde", 0, 3);
-
- TEST_SEARCH ("^ed|^(c((a|b)))", "edf", 0, 3);
- TEST_SEARCH ("^ed|^(c((a|b)))", "caf", 0, 3);
- TEST_SEARCH ("^ed|^(c((a|b)))", "cbf", 0, 3);
-
- TEST_SEARCH ("^ed|(^c((a|b)))", "edf", 0, 3);
- TEST_SEARCH ("^ed|(^c((a|b)))", "caf", 0, 3);
- TEST_SEARCH ("^ed|(^c((a|b)))", "cbf", 0, 3);
-
- TEST_SEARCH ("ed$|(c((a|b)))$", "fed", 0, 3);
- TEST_SEARCH ("ed$|(c((a|b)))$", "fca", 0, 3);
- TEST_SEARCH ("ed$|(c((a|b)))$", "fcb", 0, 3);
-
- TEST_SEARCH ("ed$|(c((a|b))$)", "fed", 0, 3);
- TEST_SEARCH ("ed$|(c((a|b))$)", "fca", 0, 3);
- TEST_SEARCH ("ed$|(c((a|b))$)", "fcb", 0, 3);
-
- TEST_SEARCH ("ed$|(c((a|b)$))", "fed", 0, 3);
- TEST_SEARCH ("ed$|(c((a|b)$))", "fca", 0, 3);
- TEST_SEARCH ("ed$|(c((a|b)$))", "fcb", 0, 3);
-
- TEST_SEARCH ("ed$|(c((a$|b$)))", "fed", 0, 3);
- TEST_SEARCH ("ed$|(c((a$|b$)))", "fca", 0, 3);
- TEST_SEARCH ("ed$|(c((a$|b$)))", "fcb", 0, 3);
-
- TEST_SEARCH ("^a(b|c)|^d", "abe", 0, 3);
- TEST_SEARCH ("^a(b|c)|^d", "ace", 0, 3);
- TEST_SEARCH ("^a(b|c)|^d", "df", 0, 2);
-
- TEST_SEARCH ("a(b$|c$)|d$", "fab", 0, 3);
- TEST_SEARCH ("a(b$|c$)|d$", "fac", 0, 3);
- TEST_SEARCH ("a(b$|c$)|d$", "fd", 0, 2);
-
- TEST_SEARCH ("^(a)(b|c)|^d", "abe", 0, 3);
- TEST_SEARCH ("^(a)(b|c)|^d", "ace", 0, 3);
- TEST_SEARCH ("^(a)(b|c)|^d", "df", 0, 2);
-
- TEST_SEARCH ("(^a)(b|c)|^d", "abe", 0, 3);
- TEST_SEARCH ("(^a)(b|c)|^d", "ace", 0, 3);
- TEST_SEARCH ("(^a)(b|c)|^d", "df", 0, 2);
-
- TEST_SEARCH ("(a)(b|c)$|d$", "fab", 0, 3);
- TEST_SEARCH ("(a)(b|c)$|d$", "fac", 0, 3);
- TEST_SEARCH ("(a)(b|c)$|d$", "fd", 0, 2);
-
- TEST_SEARCH ("(b|c)(a)$|d$", "fba", 0, 3);
- TEST_SEARCH ("(b|c)(a)$|d$", "fca", 0, 3);
- TEST_SEARCH ("(b|c)(a)$|d$", "fd", 0, 2);
-
- TEST_SEARCH ("(b|c)(a$)|d$", "fba", 0, 3);
- TEST_SEARCH ("(b|c)(a$)|d$", "fca", 0, 3);
- TEST_SEARCH ("(b|c)(a$)|d$", "fd", 0, 2);
-
- TEST_SEARCH ("(a)(b$|c$)|d$", "fab", 0, 3);
- TEST_SEARCH ("(a)(b$|c$)|d$", "fac", 0, 3);
- TEST_SEARCH ("(a)(b$|c$)|d$", "fd", 0, 2);
-
- TEST_SEARCH ("^d|^(b|c)(a)", "df", 0, 2);
- TEST_SEARCH ("^d|^(b|c)(a)", "baf", 0, 3);
- TEST_SEARCH ("^d|^(b|c)(a)", "caf", 0, 3);
-
- TEST_SEARCH ("^d|(^b|^c)(a)", "df", 0, 2);
- TEST_SEARCH ("^d|(^b|^c)(a)", "baf", 0, 3);
- TEST_SEARCH ("^d|(^b|^c)(a)", "caf", 0, 3);
-
- TEST_SEARCH ("d$|(b|c)(a$)", "fd", 0, 2);
- TEST_SEARCH ("d$|(b|c)(a$)", "fba", 0, 3);
- TEST_SEARCH ("d$|(b|c)(a$)", "fca", 0, 3);
-
- TEST_SEARCH ("d$|(b|c)(a)$", "fd", 0, 2);
- TEST_SEARCH ("d$|(b|c)(a)$", "fba", 0, 3);
- TEST_SEARCH ("d$|(b|c)(a)$", "fca", 0, 3);
-
- TEST_SEARCH ("d$|(b|c)(a$)", "fd", 0, 2);
- TEST_SEARCH ("d$|(b|c)(a$)", "fba", 0, 3);
- TEST_SEARCH ("d$|(b|c)(a$)", "fca", 0, 3);
-
- TEST_SEARCH ("^d|^(a)(b|c)", "df", 0, 2);
- TEST_SEARCH ("^d|^(a)(b|c)", "abf", 0, 3);
- TEST_SEARCH ("^d|^(a)(b|c)", "acf", 0, 3);
-
- TEST_SEARCH ("^d|(^a)(b|c)", "df", 0, 2);
- TEST_SEARCH ("^d|(^a)(b|c)", "abf", 0, 3);
- TEST_SEARCH ("^d|(^a)(b|c)", "acf", 0, 3);
-
- TEST_SEARCH ("d$|(a)(b$|c$)", "fd", 0, 2);
- TEST_SEARCH ("d$|(a)(b$|c$)", "fab", 0, 3);
- TEST_SEARCH ("d$|(a)(b$|c$)", "fac", 0, 3);
-
- TEST_SEARCH ("d$|(a)(b|c)$", "fd", 0, 2);
- TEST_SEARCH ("d$|(a)(b|c)$", "fab", 0, 3);
- TEST_SEARCH ("d$|(a)(b|c)$", "fac", 0, 3);
-
- TEST_SEARCH ("((^a|^b)|^c)|^d", "ae", 0, 2);
- TEST_SEARCH ("((^a|^b)|^c)|^d", "be", 0, 2);
- TEST_SEARCH ("((^a|^b)|^c)|^d", "ce", 0, 2);
- TEST_SEARCH ("((^a|^b)|^c)|^d", "de", 0, 2);
-
- TEST_SEARCH ("((a|b)|c)|d$", "ed", 0, 2);
- TEST_SEARCH ("((a|b)|c)|d$", "ea", 0, 2);
- TEST_SEARCH ("((a|b)|c)|d$", "eb", 0, 2);
- TEST_SEARCH ("((a|b)|c)|d$", "ec", 0, 2);
-
- TEST_SEARCH ("^d|(c|(a|b))", "de", 0, 2);
-
- TEST_SEARCH ("d$|(c$|(a$|b$))", "ed", 0, 2);
- TEST_SEARCH ("d$|(c$|(a$|b$))", "ec", 0, 2);
- TEST_SEARCH ("d$|(c$|(a$|b$))", "ea", 0, 2);
- TEST_SEARCH ("d$|(c$|(a$|b$))", "eb", 0, 2);
-
- TEST_SEARCH ("d$|(c$|(a|b)$)", "ed", 0, 2);
- TEST_SEARCH ("d$|(c$|(a|b)$)", "ec", 0, 2);
- TEST_SEARCH ("d$|(c$|(a|b)$)", "ea", 0, 2);
- TEST_SEARCH ("d$|(c$|(a|b)$)", "eb", 0, 2);
-
- TEST_SEARCH ("d$|(c$|(a|b))$", "ed", 0, 2);
- TEST_SEARCH ("d$|(c$|(a|b))$", "ec", 0, 2);
- TEST_SEARCH ("d$|(c$|(a|b))$", "ea", 0, 2);
- TEST_SEARCH ("d$|(c$|(a|b))$", "eb", 0, 2);
-
- test_match ("a|^b", "b");
- test_match ("a|b$", "b");
- test_match ("^b|a", "b");
- test_match ("b$|a", "b");
- test_match ("(^a)", "a");
- test_match ("(a$)", "a");
- TEST_SEARCH ("c|^ab", "aba", 0, 3);
- TEST_SEARCH ("c|ba$", "aba", 0, 3);
- TEST_SEARCH ("^ab|c", "aba", 0, 3);
- TEST_SEARCH ("ba$|c", "aba", 0, 3);
- TEST_SEARCH ("(^a)", "ab", 0, 2);
- TEST_SEARCH ("(a$)", "ba", 0, 2);
-
- TEST_SEARCH ("(^a$)", "a", 0, 1);
- TEST_SEARCH ("(^a)", "ab", 0, 2);
- TEST_SEARCH ("(b$)", "ab", 0, 2);
-
- /* Backtracking. */
- /* Per POSIX D11.1 p. 108, leftmost longest match. */
- test_match ("(wee|week)(knights|night)", "weeknights");
-
- test_match ("(fooq|foo)qbar", "fooqbar");
- test_match ("(fooq|foo)(qbarx|bar)", "fooqbarx");
-
- /* Take first alternative that does the longest match. */
- test_all_registers ("(fooq|(foo)|(fo))((qbarx)|(oqbarx)|bar)", "fooqbarx",
- "", 0, 8, 0, 3, 0, 3, -1, -1, 3, 8, 3, 8, -1, -1, -1, -1, -1, -1,
- -1, -1);
-
- test_match ("(fooq|foo)*qbar", "fooqbar");
- test_match ("(fooq|foo)*(qbar)", "fooqbar");
- test_match ("(fooq|foo)*(qbar)*", "fooqbar");
-
- test_match ("(fooq|fo|o)*qbar", "fooqbar");
- test_match ("(fooq|fo|o)*(qbar)", "fooqbar");
- test_match ("(fooq|fo|o)*(qbar)*", "fooqbar");
-
- test_match ("(fooq|fo|o)*(qbar|q)*", "fooqbar");
- test_match ("(fooq|foo)*(qbarx|bar)", "fooqbarx");
- test_match ("(fooq|foo)*(qbarx|bar)*", "fooqbarx");
-
- test_match ("(fooq|fo|o)+(qbar|q)+", "fooqbar");
- test_match ("(fooq|foo)+(qbarx|bar)", "fooqbarx");
- test_match ("(fooq|foo)+(qbarx|bar)+", "fooqbarx");
-
- /* Per Mike Haertel. */
- test_match ("(foo|foobarfoo)(bar)*", "foobarfoo");
-
- /* Combination. */
- test_match ("[ab]?c", "ac");
- test_match ("[ab]*c", "ac");
- test_match ("[ab]+c", "ac");
- test_match ("(a|b)?c", "ac");
- test_match ("(a|b)*c", "ac");
- test_match ("(a|b)+c", "ac");
- test_match ("(a*c)?b", "b");
- test_match ("(a*c)+b", "aacb");
- /* Registers. */
- /* Per David A. Willcox. */
- test_match ("a((b)|(c))d", "acd");
- test_all_registers ("a((b)|(c))d", "acd", "", 0, 3, 1, 2, -1, -1, 1, 2,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
-
- /* Extended regular expressions, continued; these don't match their strings. */
- test_should_match = false;
-
-#if 0
- /* Invalid use of special characters. */
- /* These are not invalid anymore, since POSIX says the behavior is
- undefined, and we prefer context-independent to context-invalid. */
- invalid_pattern (REG_BADRPT, "*");
- invalid_pattern (REG_BADRPT, "a|*");
- invalid_pattern (REG_BADRPT, "(*)");
- invalid_pattern (REG_BADRPT, "^*");
- invalid_pattern (REG_BADRPT, "+");
- invalid_pattern (REG_BADRPT, "a|+");
- invalid_pattern (REG_BADRPT, "(+)");
- invalid_pattern (REG_BADRPT, "^+");
-
- invalid_pattern (REG_BADRPT, "?");
- invalid_pattern (REG_BADRPT, "a|?");
- invalid_pattern (REG_BADRPT, "(?)");
- invalid_pattern (REG_BADRPT, "^?");
-
- invalid_pattern (REG_BADPAT, "|");
- invalid_pattern (REG_BADPAT, "a|");
- invalid_pattern (REG_BADPAT, "a||");
- invalid_pattern (REG_BADPAT, "(|a)");
- invalid_pattern (REG_BADPAT, "(a|)");
-
- invalid_pattern (REG_BADPAT, PARENS_TO_OPS ("(|)"));
-
- invalid_pattern (REG_BADRPT, "{1}");
- invalid_pattern (REG_BADRPT, "a|{1}");
- invalid_pattern (REG_BADRPT, "^{1}");
- invalid_pattern (REG_BADRPT, "({1})");
-
- invalid_pattern (REG_BADPAT, "|b");
-
- invalid_pattern (REG_BADRPT, "^{0,}*");
- invalid_pattern (REG_BADRPT, "$*");
- invalid_pattern (REG_BADRPT, "${0,}*");
-#endif /* 0 */
-
- invalid_pattern (REG_EESCAPE, "\\");
-
- test_match ("a?b", "a");
-
-
- test_match ("a+", "");
- test_match ("a+b", "a");
- test_match ("a?", "b");
-
-#if 0
- /* We make empty groups valid now, since they are undefined in POSIX.
- (13 Sep 92) */
- /* Subexpressions. */
- invalid_pattern (REG_BADPAT, "()");
- invalid_pattern (REG_BADPAT, "a()");
- invalid_pattern (REG_BADPAT, "()b");
- invalid_pattern (REG_BADPAT, "a()b");
- invalid_pattern (REG_BADPAT, "()*");
- invalid_pattern (REG_BADPAT, "(()*");
-#endif
- /* Invalid intervals. */
- test_match ("a{2}*", "aaa");
- test_match ("a{2}?", "aaa");
- test_match ("a{2}+", "aaa");
- test_match ("a{2}{2}", "aaa");
- test_match ("a{1}{1}{2}", "aaa");
- test_match ("a{1}{1}{2}", "a");
- /* Invalid alternation. */
- test_match ("a|b", "c");
-
- TEST_SEARCH ("c|^ba", "aba", 0, 3);
- TEST_SEARCH ("c|ab$", "aba", 0, 3);
- TEST_SEARCH ("^ba|c", "aba", 0, 3);
- TEST_SEARCH ("ab$|c", "aba", 0, 3);
- /* Invalid anchoring. */
- TEST_SEARCH ("(^a)", "ba", 0, 2);
- TEST_SEARCH ("(b$)", "ba", 0, 2);
-
- printf ("\nFinished POSIX extended tests.\n");
-}
-
-
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/lib/libregex/test/psx-generic.c b/gnu/lib/libregex/test/psx-generic.c
deleted file mode 100644
index 8e97f75..0000000
--- a/gnu/lib/libregex/test/psx-generic.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/* psx-generic.c: test POSIX re's independent of us using basic or
- extended syntax. */
-
-#include "test.h"
-
-
-void
-test_posix_generic ()
-{
- int omit_generic_tests = 0; /* reset in debugger to skip */
-
- if (omit_generic_tests)
- return;
- /* Tests somewhat in the order of P1003.2. */
-
- /* Both posix basic and extended; should match. */
-
- printf ("\nStarting generic POSIX tests.\n");
- test_grouping ();
- test_intervals ();
-
- test_should_match = true;
- /* Ordinary characters. */
- printf ("\nContinuing generic POSIX tests.\n");
-
- MATCH_SELF ("");
- test_fastmap ("", "", 0, 0);
- test_fastmap_search ("", "", "", 0, 0, 2, 0, 0);
- TEST_REGISTERS ("", "", 0, 0, -1, -1, -1, -1);
- TEST_SEARCH ("", "", 0, 0);
- TEST_SEARCH_2 ("", "", "", 0, 1, 0);
-
- MATCH_SELF ("abc");
- test_fastmap ("abc", "a", 0, 0);
- TEST_REGISTERS ("abc", "abc", 0, 3, -1, -1, -1, -1);
- TEST_REGISTERS ("abc", "xabcx", 1, 4, -1, -1, -1, -1);
-
- test_match ("\\a","a");
- test_match ("\\0", "0");
-
- TEST_SEARCH ("a", "ab", 0, 2);
- TEST_SEARCH ("b", "ab", 0, 2);
- TEST_SEARCH ("a", "ab", 1, -2);
- TEST_SEARCH_2 ("a", "a", "b", 0, 2, 2);
- TEST_SEARCH_2 ("b", "a", "b", 0, 2, 2);
- TEST_SEARCH_2 ("a", "a", "b", 1, -2, 2);
-
- test_match ("\n", "\n");
- test_match ("a\n", "a\n");
- test_match ("\nb", "\nb");
- test_match ("a\nb", "a\nb");
-
- TEST_SEARCH ("b", "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 236, -237);
- /* Valid use of special characters. */
- test_match ("a*", "aa");
- test_fastmap ("a*", "a", 0, 0);
- TEST_REGISTERS ("a*", "aa", 0, 2, -1, -1, -1, -1);
-
- test_match ("a*b", "aab");
- test_fastmap ("a*b", "ab", 0, 0);
-
- test_match ("a*ab", "aab");
- TEST_REGISTERS ("a*a", "aa", 0, 2, -1, -1, -1, -1);
- TEST_REGISTERS ("a*a", "xaax", 1, 3, -1, -1, -1, -1);
-
- test_match ("\\{", "{");
- test_match ("\\^", "^");
- test_match ("\\.", ".");
- test_match ("\\*", "*");
- test_match ("\\[", "[");
- test_match ("\\$", "$");
- test_match ("\\\\", "\\");
-
- test_match ("ab*", "a");
- test_match ("ab*", "abb");
-
- /* Valid consecutive repetitions. */
- test_match ("a**", "a");
- /* Valid period. */
- test_match (".", "a");
- TEST_REGISTERS (".", "a", 0, 1, -1, -1, -1, -1);
- test_match (".", "\004");
- test_match (".", "\n");
- /* Valid bracket expressions. */
- test_match ("[ab]", "a");
- test_match ("[ab]", "b");
- test_fastmap ("[ab]", "ab", 0, 0);
- TEST_REGISTERS ("[ab]", "a", 0, 1, -1, -1, -1, -1);
- TEST_REGISTERS ("[ab]", "xax", 1, 2, -1, -1, -1, -1);
-
- test_fastmap ("[^ab]", "ab", 1, 1);
- test_match ("[^ab]", "c");
- test_match ("[^a]", "\n");
-
- test_match ("[a]*a", "aa");
-
- test_match ("[[]", "[");
- test_match ("[]]", "]");
- test_match ("[.]", ".");
- test_match ("[*]", "*");
- test_match ("[\\]", "\\");
- test_match ("[\\(]", "(");
- test_match ("[\\)]", ")");
- test_match ("[^]]", "a");
- test_match ("[a^]", "^");
- test_match ("[a$]", "$");
- test_match ("[]a]", "]");
- test_match ("[a][]]", "a]");
- test_match ("[\n]", "\n");
- test_match ("[^a]", "\n");
- test_match ("[a-]", "a");
-
- TEST_REGISTERS ("\\`[ \t\n]*", " karl (Karl Berry)", 0, 1, -1, -1, -1, -1);
- TEST_REGISTERS ("[ \t\n]*\\'", " karl (Karl Berry)", 18, 18, -1, -1, -1, -1);
-
- /* Collating, noncollating,
- equivalence classes aren't
- implemented yet. */
-
-
- /* Character classes. */
- test_match ("[:alpha:]", "p");
- test_match ("[[:alpha:]]", "a");
- test_match ("[[:alpha:]]", "z");
- test_match ("[[:alpha:]]", "A");
- test_match ("[[:alpha:]]", "Z");
- test_match ("[[:upper:]]", "A");
- test_match ("[[:upper:]]", "Z");
- test_match ("[[:lower:]]", "a");
- test_match ("[[:lower:]]", "z");
-
- test_match ("[[:digit:]]", "0");
- test_match ("[[:digit:]]", "9");
- test_fastmap ("[[:digit:]]", "0123456789", 0, 0);
-
- test_match ("[[:alnum:]]", "0");
- test_match ("[[:alnum:]]", "9");
- test_match ("[[:alnum:]]", "a");
- test_match ("[[:alnum:]]", "z");
- test_match ("[[:alnum:]]", "A");
- test_match ("[[:alnum:]]", "Z");
- test_match ("[[:xdigit:]]", "0");
- test_match ("[[:xdigit:]]", "9");
- test_match ("[[:xdigit:]]", "A");
- test_match ("[[:xdigit:]]", "F");
- test_match ("[[:xdigit:]]", "a");
- test_match ("[[:xdigit:]]", "f");
- test_match ("[[:space:]]", " ");
- test_match ("[[:print:]]", " ");
- test_match ("[[:print:]]", "~");
- test_match ("[[:punct:]]", ",");
- test_match ("[[:graph:]]", "!");
- test_match ("[[:graph:]]", "~");
- test_match ("[[:cntrl:]]", "\177");
- test_match ("[[:digit:]a]", "a");
- test_match ("[[:digit:]a]", "2");
- test_match ("[a[:digit:]]", "a");
- test_match ("[a[:digit:]]", "2");
- test_match ("[[:]", "[");
- test_match ("[:]", ":");
- test_match ("[[:a]", "[");
- test_match ("[[:alpha:a]", "[");
- /* Valid ranges. */
- test_match ("[a-a]", "a");
- test_fastmap ("[a-a]", "a", 0, 0);
- TEST_REGISTERS ("[a-a]", "xax", 1, 2, -1, -1, -1, -1);
-
- test_match ("[a-z]", "z");
- test_fastmap ("[a-z]", "abcdefghijklmnopqrstuvwxyz", 0, 0);
- test_match ("[-a]", "-"); /* First */
- test_match ("[-a]", "a");
- test_match ("[a-]", "-"); /* Last */
- test_match ("[a-]", "a");
- test_match ("[--@]", "@"); /* First and starting point. */
-
- test_match ("[%--a]", "%"); /* Ending point. */
- test_match ("[%--a]", "-"); /* Ditto. */
-
- test_match ("[a%--]", "%"); /* Both ending point and last. */
- test_match ("[a%--]", "-");
- test_match ("[%--a]", "a"); /* Ending point only. */
- test_match ("[a-c-f]", "e"); /* Piggyback. */
-
- test_match ("[)-+--/]", "*");
- test_match ("[)-+--/]", ",");
- test_match ("[)-+--/]", "/");
- test_match ("[[:digit:]-]", "-");
- /* Concatenation ????*/
- test_match ("[ab][cd]", "ac");
- test_fastmap ("[ab][cd]", "ab", 0, 0);
- TEST_REGISTERS ("[ab][cd]", "ad", 0, 2, -1, -1, -1, -1);
- TEST_REGISTERS ("[ab][cd]", "xadx", 1, 3, -1, -1, -1, -1);
-
- /* Valid expression anchoring. */
- test_match ("^a", "a");
- test_fastmap ("^a", "a", 0, 0);
- TEST_REGISTERS ("^a", "ax", 0, 1, -1, -1, -1, -1);
-
- test_match ("^", "");
- TEST_REGISTERS ("^", "", 0, 0, -1, -1, -1, -1);
- test_match ("$", "");
- TEST_REGISTERS ("$", "", 0, 0, -1, -1, -1, -1);
-
- test_match ("a$", "a");
- test_fastmap ("a$", "a", 0, 0);
- TEST_REGISTERS ("a$", "xa", 1, 2, -1, -1, -1, -1);
-
- test_match ("^ab$", "ab");
- test_fastmap ("^ab$", "a", 0, 0);
- TEST_REGISTERS ("^a$", "a", 0, 1, -1, -1, -1, -1);
-
- test_fastmap ("^$", "", 0, 0);
- test_match ("^$", "");
- TEST_REGISTERS ("^$", "", 0, 0, -1, -1, -1, -1);
-
- TEST_SEARCH (PARENS_TO_OPS ("(^a)"), "ab", 0, 2);
- TEST_SEARCH (PARENS_TO_OPS ("(a$)"), "ba", 0, 2);
- TEST_SEARCH (PARENS_TO_OPS ("^(^a)"), "ab", 0, 2);
- TEST_SEARCH (PARENS_TO_OPS ("(a$)$"), "ba", 0, 2);
-
- /* Two strings. */
- test_match_2 ("ab", "a", "b");
- TEST_REGISTERS_2 ("ab", "a", "b", 0, 2, -1, -1, -1, -1);
-
- test_match_2 ("a", "", "a");
- test_match_2 ("a", "a", "");
- test_match_2 ("ab", "a", "b");
- /* (start)pos. */
- TEST_POSITIONED_MATCH ("b", "ab", 1);
- /* mstop. */
- TEST_TRUNCATED_MATCH ("a", "ab", 1);
-
-
- /* Both basic and extended, continued; should not match. */
-
- test_should_match = false;
- /* Ordinary characters. */
- test_match ("abc", "ab");
-
- TEST_SEARCH ("c", "ab", 0, 2);
- TEST_SEARCH ("c", "ab", 0, 2);
- TEST_SEARCH ("c", "ab", 1, -2);
- TEST_SEARCH ("c", "ab", 0, 10);
- TEST_SEARCH ("c", "ab", 1, -10);
- TEST_SEARCH_2 ("c", "a", "b", 0, 2, 2);
- TEST_SEARCH_2 ("c", "a", "b", 0, 2, 2);
- TEST_SEARCH_2 ("c", "a", "b", 0, 2, 2);
- TEST_SEARCH_2 ("c", "a", "b", 1, -2, 2);
- TEST_SEARCH_2 ("c", "a", "b", 1, -2, 2);
-
- TEST_SEARCH ("c", "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 236, -237);
-
- /* Invalid use of special characters. */
- invalid_pattern (REG_EESCAPE, "\\");
- invalid_pattern (REG_EESCAPE, "a\\");
- invalid_pattern (REG_EESCAPE, "a*\\");
- /* Invalid period. */
- test_match (".", "");
- /* Invalid bracket expressions. */
- test_match ("[ab]", "c");
- test_match ("[^b]", "b");
- test_match ("[^]]", "]");
-
- invalid_pattern (REG_EBRACK, "[");
- invalid_pattern (REG_EBRACK, "[^");
- invalid_pattern (REG_EBRACK, "[a");
- invalid_pattern (REG_EBRACK, "[]");
- invalid_pattern (REG_EBRACK, "[]a");
- invalid_pattern (REG_EBRACK, "a[]a");
-
-
- test_match ("[:alpha:]", "q"); /* Character classes. */
- test_match ("[[:alpha:]]", "2");
- test_match ("[[:upper:]]", "a");
- test_match ("[[:lower:]]", "A");
- test_match ("[[:digit:]]", "a");
- test_match ("[[:alnum:]]", ":");
- test_match ("[[:xdigit:]]", "g");
- test_match ("[[:space:]]", "a");
- test_match ("[[:print:]]", "\177");
- test_match ("[[:punct:]]", "a");
- test_match ("[[:graph:]]", " ");
- test_match ("[[:cntrl:]]", "a");
- invalid_pattern (REG_EBRACK, "[[:");
- invalid_pattern (REG_EBRACK, "[[:alpha:");
- invalid_pattern (REG_EBRACK, "[[:alpha:]");
- invalid_pattern (REG_ECTYPE, "[[::]]");
- invalid_pattern (REG_ECTYPE, "[[:a:]]");
- invalid_pattern (REG_ECTYPE, "[[:alpo:]]");
- invalid_pattern (REG_ECTYPE, "[[:a:]");
-
- test_match ("[a-z]", "2"); /* Invalid ranges. */
- test_match ("[^-a]", "-");
- test_match ("[^a-]", "-");
- test_match ("[)-+--/]", ".");
- invalid_pattern (REG_ERANGE, "[z-a]"); /* Empty */
- invalid_pattern (REG_ERANGE, "[a--]"); /* Empty */
- invalid_pattern (REG_ERANGE, "[[:digit:]-9]");
- invalid_pattern (REG_ERANGE, "[a-[:alpha:]]");
- invalid_pattern (REG_ERANGE, "[a-");
- invalid_pattern (REG_EBRACK, "[a-z");
-
- test_match ("[ab][cd]", "ae"); /* Concatenation. */
- test_match ("b*c", "b"); /* Star. */
-
- /* Invalid anchoring. */
- test_match ("^", "a");
- test_match ("^a", "ba");
- test_match ("$", "b");
- test_match ("a$", "ab");
- test_match ("^$", "a");
- test_match ("^ab$", "a");
-
- TEST_SEARCH ("^a", "b\na", 0, 3);
- TEST_SEARCH ("b$", "b\na", 0, 3);
-
- test_match_2 ("^a", "\n", "a");
- test_match_2 ("a$", "a", "\n");
-
- TEST_SEARCH (PARENS_TO_OPS ("(^a)"), "ba", 0, 2);
- TEST_SEARCH (PARENS_TO_OPS ("(a$)"), "ab", 0, 2);
- TEST_SEARCH (PARENS_TO_OPS ("^(^a)"), "ba", 0, 2);
- TEST_SEARCH (PARENS_TO_OPS ("(a$)$"), "ab", 0, 2);
-
- printf ("\nFinished generic POSIX tests.\n");
-}
-
-
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/lib/libregex/test/psx-group.c b/gnu/lib/libregex/test/psx-group.c
deleted file mode 100644
index 08ae8a2..0000000
--- a/gnu/lib/libregex/test/psx-group.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/* psx-group.c: test POSIX grouping, both basic and extended. */
-
-#include "test.h"
-
-
-void
-test_grouping ()
-{
- printf ("\nStarting POSIX grouping tests.\n");
-
- test_should_match = true;
-
- test_fastmap (PARENS_TO_OPS ("(a)"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(a)"), "a");
- TEST_REGISTERS (PARENS_TO_OPS ("(a)"), "a", 0, 1, 0, 1, -1, -1);
- TEST_REGISTERS (PARENS_TO_OPS ("(a)"), "xax", 1, 2, 1, 2, -1, -1);
-
- test_match (PARENS_TO_OPS ("((a))"), "a");
- test_fastmap (PARENS_TO_OPS ("((a))"), "a", 0, 0);
- TEST_REGISTERS (PARENS_TO_OPS ("((a))"), "a", 0, 1, 0, 1, 0, 1);
- TEST_REGISTERS (PARENS_TO_OPS ("((a))"), "xax", 1, 2, 1, 2, 1, 2);
-
- test_fastmap (PARENS_TO_OPS ("(a)(b)"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(a)(b)"), "ab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a)(b)"), "ab", 0, 2, 0, 1, 1, 2);
-
- TEST_REGISTERS (PARENS_TO_OPS ("(a)(b)"), "xabx", 1, 3, 1, 2, 2, 3);
-
- test_all_registers (PARENS_TO_OPS ("((a)(b))"), "ab", "", 0, 2, 0, 2, 0, 1,
- 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
-
- /* Test that we simply ignore groups past the 255th. */
- test_match (PARENS_TO_OPS ("((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((a))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))"), "a");
-
-
- /* Per POSIX D11.1, p. 125. */
-
- test_fastmap (PARENS_TO_OPS ("(a)*"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(a)*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("(a)*"), "", 0, 0, -1, -1, -1, -1);
- TEST_REGISTERS (PARENS_TO_OPS ("(a)*"), "aa", 0, 2, 1, 2, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a*)"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(a*)"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)"), "", 0, 0, 0, 0, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a*)"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(a*)"), "a");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)"), "a", 0, 1, 0, 1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a*)b"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("(a*)b"), "b");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)b"), "b", 0, 1, 0, 0, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*)b"), "ab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)b"), "ab", 0, 2, 0, 1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("((a*)b)*"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("((a*)b)*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "", 0, 0, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("((a*)b)*"), "ab");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "ab", 0, 2, 0, 2, 0, 1);
-
- test_match (PARENS_TO_OPS ("((a*)b)*"), "abb");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "abb", 0, 3, 2, 3, 2, 2);
-
- test_match (PARENS_TO_OPS ("((a*)b)*"), "aabab");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "aabab", 0, 5, 3, 5, 3, 4);
-
- test_match (PARENS_TO_OPS ("((a*)b)*"), "abbab");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "abbab", 0, 5, 3, 5, 3, 4);
-
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "xabbabx", 0, 0, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("((a*)b)*"), "abaabaaaab");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "abaabaaab", 0, 9, 5, 9, 5, 8);
-
- test_fastmap (PARENS_TO_OPS ("(ab)*"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(ab)*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("(ab)*"), "", 0, 0, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(ab)*"), "abab");
- TEST_REGISTERS (PARENS_TO_OPS ("(ab)*"), "abab", 0, 4, 2, 4, -1, -1);
-
- /* We match the empty string here. */
- TEST_REGISTERS (PARENS_TO_OPS ("(ab)*"), "xababx", 0, 0, -1, -1, -1, -1);
-
- /* Per David A. Willcox. */
- TEST_REGISTERS (PARENS_TO_OPS ("a(b*)c"), "ac", 0, 2, 1, 1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a)*b"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("(a)*b"), "b");
- TEST_REGISTERS (PARENS_TO_OPS ("(a)*b"), "b", 0, 1, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a)*b"), "ab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a)*b"), "ab", 0, 2, 0, 1, -1, -1);
-
- test_match_2 (PARENS_TO_OPS ("(a)*b"), "a", "ab");
- TEST_REGISTERS_2 (PARENS_TO_OPS ("(a)*b"), "a", "ab", 0, 3, 1, 2, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a)*b"), "aab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a)*b"), "aab", 0, 3, 1, 2, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a)*a"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(a)*a"), "a");
- TEST_REGISTERS (PARENS_TO_OPS ("(a)*a"), "a", 0, 1, -1, -1, -1, -1);
-
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*"), "", 0, 0, 0, 0, 0, 0);
-
- test_match (PARENS_TO_OPS ("((a*))*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*))*"), "", 0, 0, 0, 0, 0, 0);
- test_match (PARENS_TO_OPS ("((a*))*"), "aa");
-
- test_fastmap (PARENS_TO_OPS ("(a*)*b"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("(a*)*b"), "b");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "b", 0, 1, 0, 0, -1, -1);
-
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "xbx", 1, 2, 1, 1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*)*b"), "ab"); /* Per rms. */
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "ab", 0, 2, 0, 1, -1, -1);
-
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "xabx", 1, 3, 1, 2, -1, -1);
-
- /* Test register restores. */
- test_match (PARENS_TO_OPS ("(a*)*b"), "aab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "aab", 0, 3, 0, 2, -1, -1);
-
- TEST_REGISTERS_2 (PARENS_TO_OPS ("(a*)*b"), "a", "ab", 0, 3, 0, 2, -1, -1);
-
- /* We are matching the empty string, with backtracking. */
- test_fastmap (PARENS_TO_OPS ("(a*)a"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(a*)a"), "a");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)a"), "a", 0, 1, 0, 0, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*)a"), "aa");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)a"), "aa", 0, 2, 0, 1, -1, -1);
-
- /* We are matching the empty string, with backtracking. */
-/*fails test_match (PARENS_TO_OPS ("(a*)*a"), "a"); */
- test_match (PARENS_TO_OPS ("(a*)*a"), "aa");
- /* Match the empty string. */
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "a", 0, 1, 0, 0, -1, -1);
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "xax", 1, 2, 1, 1, -1, -1);
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "aa", 0, 2, 0, 1, -1, -1);
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "xaax", 1, 3, 1, 2, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a)*ab"), "a", 0 , 0);
- test_match (PARENS_TO_OPS ("(a)*ab"), "ab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a)*ab"), "ab", 0, 2, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a)*ab"), "aab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a)*ab"), "aab", 0, 3, 0, 1, -1, -1);
-
- TEST_REGISTERS (PARENS_TO_OPS("(a)*ab"), "xaabx", 1, 4, 1, 2, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a*)ab"), "a", 0 , 0);
- test_match (PARENS_TO_OPS ("(a*)ab"), "ab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)ab"), "ab", 0, 2, 0, 0, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*)ab"), "aab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)ab"), "aab", 0, 3, 0, 1, -1, -1);
-
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)ab"), "xaabx", 1, 4, 1, 2, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a*)*ab"), "a", 0 , 0);
- test_match (PARENS_TO_OPS ("(a*)*ab"), "ab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*ab"), "ab", 0, 2, 0, 0, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*)*ab"), "aab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*ab"), "aab", 0, 3, 0, 1, -1, -1);
-
- TEST_REGISTERS (PARENS_TO_OPS("(a*)*ab"), "xaabx", 1, 4, 1, 2, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a*)*b*c"), "abc", 0, 0);
- test_match (PARENS_TO_OPS ("(a*)*b*c"), "c");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b*c"), "c", 0, 1, 0, 0, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a)*(ab)*"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(a)*(ab)*"), "ab");
- /* Register 1 doesn't match at all (vs. matching the empty string)
- because of backtracking, hence -1's. */
- TEST_REGISTERS (PARENS_TO_OPS ("(a)*(ab)*"), "ab", 0, 2, -1, -1, 0, 2);
-
- test_match (PARENS_TO_OPS ("(a*)*(ab)*"), "ab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*(ab)*"), "ab", 0, 2, 0, 0, 0, 2);
-
- test_fastmap (PARENS_TO_OPS ("(a*b)*"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("(a*b)*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*"), "", 0, 0, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b)*"), "b");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*"), "b", 0, 1, 0, 1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b)*"), "baab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*"), "baab", 0, 4, 1, 4, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a*b*)*"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("(a*b*)*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "", 0, 0, 0, 0, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b*)*"), "a");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "a", 0, 1, 0, 1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b*)*"), "ba");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "ba", 0, 2, 1, 2, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b*)*"), "ab");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "ab", 0, 2, 0, 2, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b*)*"), "aa");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "aa", 0, 2, 0, 2, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b*)*"), "bb");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "bb", 0, 2, 0, 2, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b*)*"), "aba");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "aba", 0, 3, 2, 3, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b*)b"), "b");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)b"), "b", 0, 1, 0, 0, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("((a*)*(b*)*)*"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("((a*)*(b*)*)*"), "");
- test_all_registers (PARENS_TO_OPS ("((a*)*(b*)*)*"), "", "", 0, 0, 0, 0,
- 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("((a*)*(b*)*)*"), "aba");
- /* Perhaps register 3 should be 3/3 here? Not sure if standard
- specifies this. xx*/
- test_all_registers (PARENS_TO_OPS ("((a*)*(b*)*)*"), "aba", "", 0, 3, 2, 3,
- 2, 3, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("((a*)(b*))*"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("((a*)(b*))*"), "");
-
- test_all_registers (PARENS_TO_OPS ("((a*)(b*))*"), "", "", 0, 0, 0, 0,
- 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), "");
-
- test_match (PARENS_TO_OPS ("((a*)(b*))*"), "aba");
- test_all_registers (PARENS_TO_OPS ("((a*)(b*))*"), "aba", "", 0, 3, 2, 3,
- 2, 3, 3, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("((a)*(b)*)*"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("((a)*(b)*)*"), "");
- test_all_registers (PARENS_TO_OPS ("((a)*(b)*)*"), "", "", 0, 0, 0, 0,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("((a)*(b)*)*"), "aba");
-
- test_all_registers (PARENS_TO_OPS ("((a)*(b)*)*"), "aba", "", 0, 3, 2, 3,
- 2, 3, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(c(a)*(b)*)*"), "c", 0, 0);
- test_match (PARENS_TO_OPS ("(c(a)*(b)*)*"), "");
- test_all_registers (PARENS_TO_OPS ("(c(a)*(b)*)*"), "", "", 0, 0, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(c(a)*(b)*)*"), "c");
- test_all_registers (PARENS_TO_OPS ("(c(a)*(b)*)*"), "c", "", 0, 1, 0, 1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("c((a)*(b)*)*"), "c", 0, 0);
- test_match (PARENS_TO_OPS ("c((a)*(b)*)*"), "c");
- test_all_registers (PARENS_TO_OPS ("c((a)*(b)*)*"), "c", "", 0, 1, 1, 1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(((a)*(b)*)*)*"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("(((a)*(b)*)*)*"), "");
- test_all_registers (PARENS_TO_OPS ("(((a)*(b)*)*)*"), "", "", 0, 0, 0, 0,
- 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), "");
- test_fastmap (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), "c", 0, 0);
-
- test_all_registers (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), "", "", 0, 0, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("((a)*b)*"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("((a)*b)*"), "");
-
- test_match (PARENS_TO_OPS ("((a)*b)*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "", 0, 0, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("((a)*b)*"), "abb");
- TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "abb", 0, 3, 2, 3, 0, 1); /*zz*/
-
- test_match (PARENS_TO_OPS ("((a)*b)*"), "abbab");
- TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "abbab", 0, 5, 3, 5, 3, 4);
-
- /* We match the empty string here. */
- TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "xabbabx", 0, 0, -1, -1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a*)*"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(a*)*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*"), "", 0, 0, 0, 0, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*)*"), "aa");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*)*"), "aa", 0, 2, 0, 2, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("((a*)*)*"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("((a*)*)*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)*)*"), "", 0, 0, 0, 0, 0, 0);
-
- test_match (PARENS_TO_OPS ("((a*)*)*"), "a");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)*)*"), "a", 0, 1, 0, 1, 0, 1);
-
- test_fastmap (PARENS_TO_OPS ("(ab*)*"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("(ab*)*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*"), "", 0, 0, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(ab*)*"), "aa");
- TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*"), "aa", 0, 2, 1, 2, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(ab*)*c"), "ac", 0, 0);
- test_match (PARENS_TO_OPS ("(ab*)*c"), "c");
- TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*c"), "c", 0, 1, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(ab*)*c"), "abbac");
- TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*c"), "abbac", 0, 5, 3, 4, -1, -1);
-
- test_match (PARENS_TO_OPS ("(ab*)*c"), "abac");
- TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*c"), "abac", 0, 4, 2, 3, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a*b)*c"), "abc", 0, 0);
- test_match (PARENS_TO_OPS ("(a*b)*c"), "c");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "c", 0, 1, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b)*c"), "bbc");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "bbc", 0, 3, 1, 2, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b)*c"), "aababc");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "aababc", 0, 6, 3, 5, -1, -1);
-
- test_match (PARENS_TO_OPS ("(a*b)*c"), "aabaabc");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "aabaabc", 0, 7, 3, 6, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("((a*)b*)"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("((a*)b*)"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)"), "", 0, 0, 0, 0, 0, 0);
-
- test_match (PARENS_TO_OPS ("((a*)b*)"), "a");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)"), "a", 0, 1, 0, 1, 0, 1);
-
- test_match (PARENS_TO_OPS ("((a*)b*)"), "b");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)"), "b", 0, 1, 0, 1, 0, 0);
-
- test_fastmap (PARENS_TO_OPS ("((a)*b*)"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("((a)*b*)"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "", 0, 0, 0, 0, -1, -1);
-
- test_match (PARENS_TO_OPS ("((a)*b*)"), "a");
- TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "a", 0, 1, 0, 1, 0, 1);
-
- test_match (PARENS_TO_OPS ("((a)*b*)"), "b");
- TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "b", 0, 1, 0, 1, -1, -1);
-
- test_match (PARENS_TO_OPS ("((a)*b*)"), "ab");
- TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "ab", 0, 2, 0, 2, 0, 1);
-
- test_fastmap (PARENS_TO_OPS ("((a*)b*)c"), "abc", 0, 0);
- test_match (PARENS_TO_OPS ("((a*)b*)c"), "c");
- TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)c"), "c", 0, 1, 0, 0, 0, 0);
-
- test_fastmap (PARENS_TO_OPS ("((a)*b*)c"), "abc", 0, 0);
- test_match (PARENS_TO_OPS ("((a)*b*)c"), "c");
- TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)c"), "c", 0, 1, 0, 0, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(a*b*)*"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("(a*b*)*"), "");
- TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "", 0, 0, 0, 0, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(((a*))((b*)))*"), "ab", 0, 0);
- test_match (PARENS_TO_OPS ("(((a*))((b*)))*"), "");
- test_all_registers (PARENS_TO_OPS ("(((a*))((b*)))*"), "", "", 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("(c*((a*))d*((b*))e*)*"), "abcde", 0, 0);
- test_match (PARENS_TO_OPS ("(c*((a*))d*((b*))e*)*"), "");
- test_all_registers (PARENS_TO_OPS ("(c*((a*))d*((b*))e*)*"), "", "", 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1);
-
- test_fastmap (PARENS_TO_OPS ("((a)*b)*c"), "abc", 0, 0);
- test_match (PARENS_TO_OPS ("((a)*b)*c"), "c");
- TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*c"), "c", 0, 1, -1, -1, -1, -1);
-
- test_match (PARENS_TO_OPS ("(ab)*"), "");
- test_match (PARENS_TO_OPS ("((ab)*)"), "");
- test_match (PARENS_TO_OPS ("(((ab)*))"), "");
- test_match (PARENS_TO_OPS ("((((ab)*)))"), "");
- test_match (PARENS_TO_OPS ("(((((ab)*))))"), "");
- test_match (PARENS_TO_OPS ("((((((ab)*)))))"), "");
- test_match (PARENS_TO_OPS ("(((((((ab)*))))))"), "");
- test_match (PARENS_TO_OPS ("((((((((ab)*)))))))"), "");
- test_match (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "");
-
-
- test_fastmap (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "a", 0, 0);
- test_match (PARENS_TO_OPS ("((((((((((ab)*)))))))))"), "");
- test_match (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "");
- test_all_registers (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "", NULL,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1);
-
- test_match (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "abab");
- test_all_registers (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "abab", NULL,
- 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 2, 4);
-
-
- test_should_match = false;
-
- invalid_pattern (REG_EPAREN, PARENS_TO_OPS ("(a"));
-
- test_match (PARENS_TO_OPS ("(a)"), "");
- test_match (PARENS_TO_OPS ("((a))"), "b");
- test_match (PARENS_TO_OPS ("(a)(b)"), "ac");
- test_match (PARENS_TO_OPS ("(ab)*"), "acab");
- test_match (PARENS_TO_OPS ("(a*)*b"), "c");
- test_match (PARENS_TO_OPS ("(a*b)*"), "baa");
- test_match (PARENS_TO_OPS ("(a*b)*"), "baabc");
- test_match (PARENS_TO_OPS ("(a*b*)*"), "c");
- test_match (PARENS_TO_OPS ("((a*)*(b*)*)*"), "c");
- test_match (PARENS_TO_OPS ("(a*)*"), "ab");
- test_match (PARENS_TO_OPS ("((a*)*)*"), "ab");
- test_match (PARENS_TO_OPS ("((a*)*)*"), "b");
- test_match (PARENS_TO_OPS ("(ab*)*"), "abc");
- test_match (PARENS_TO_OPS ("(ab*)*c"), "abbad");
- test_match (PARENS_TO_OPS ("(a*c)*b"), "aacaacd");
- test_match (PARENS_TO_OPS ("(a*)"), "b");
- test_match (PARENS_TO_OPS ("((a*)b*)"), "c");
-
- /* Expression anchoring. */
- TEST_SEARCH (PARENS_TO_OPS ("(^b)"), "ab", 0, 2);
- TEST_SEARCH (PARENS_TO_OPS ("(a$)"), "ab", 0, 2);
-
- printf ("\nFinished POSIX grouping tests.\n");
-}
diff --git a/gnu/lib/libregex/test/psx-interf.c b/gnu/lib/libregex/test/psx-interf.c
deleted file mode 100644
index 80498fb..0000000
--- a/gnu/lib/libregex/test/psx-interf.c
+++ /dev/null
@@ -1,624 +0,0 @@
-/* psx-interf.c: test POSIX interface. */
-
-#include <string.h>
-#include <assert.h>
-
-#include "test.h"
-
-#define ERROR_CODE_LENGTH 20
-#define TEST_ERRBUF_SIZE 15
-
-
-void test_compile ();
-
-
-/* ANSWER should be at least ERROR_CODE_LENGTH long. */
-
-static char *
-get_error_string (error_code, answer)
- int error_code;
- char answer[];
-{
- switch (error_code)
- {
- case 0: strcpy (answer, "No error"); break;
- case REG_NOMATCH: strcpy (answer, "REG_NOMATCH"); break;
- case REG_BADPAT: strcpy (answer, "REG_BADPAT"); break;
- case REG_EPAREN: strcpy (answer, "REG_EPAREN"); break;
- case REG_ESPACE: strcpy (answer, "REG_ESPACE"); break;
- case REG_ECOLLATE: strcpy (answer, "REG_ECOLLATE"); break;
- case REG_ECTYPE: strcpy (answer, "REG_ECTYPE"); break;
- case REG_EESCAPE: strcpy (answer, "REG_EESCAPE"); break;
- case REG_ESUBREG: strcpy (answer, "REG_ESUBREG"); break;
- case REG_EBRACK: strcpy (answer, "REG_EBRACK"); break;
- case REG_EBRACE: strcpy (answer, "REG_EBRACE"); break;
- case REG_BADBR: strcpy (answer, "REG_BADBR"); break;
- case REG_ERANGE: strcpy (answer, "REG_ERANGE"); break;
- case REG_BADRPT: strcpy (answer, "REG_BADRPT"); break;
- case REG_EEND: strcpy (answer, "REG_EEND"); break;
- default: strcpy (answer, "Bad error code");
- }
- return answer;
-}
-
-
-/* I don't think we actually need to initialize all these things.
- --karl */
-
-void
-init_pattern_buffer (pattern_buffer_ptr)
- regex_t *pattern_buffer_ptr;
-{
- pattern_buffer_ptr->buffer = NULL;
- pattern_buffer_ptr->allocated = 0;
- pattern_buffer_ptr->used = 0;
- pattern_buffer_ptr->fastmap = NULL;
- pattern_buffer_ptr->fastmap_accurate = 0;
- pattern_buffer_ptr->translate = NULL;
- pattern_buffer_ptr->can_be_null = 0;
- pattern_buffer_ptr->re_nsub = 0;
- pattern_buffer_ptr->no_sub = 0;
- pattern_buffer_ptr->not_bol = 0;
- pattern_buffer_ptr->not_eol = 0;
-}
-
-
-void
-test_compile (valid_pattern, error_code_expected, pattern,
- pattern_buffer_ptr, cflags)
- unsigned valid_pattern;
- int error_code_expected;
- const char *pattern;
- regex_t *pattern_buffer_ptr;
- int cflags;
-{
- int error_code_returned;
- boolean error = false;
- char errbuf[TEST_ERRBUF_SIZE];
-
- init_pattern_buffer (pattern_buffer_ptr);
- error_code_returned = regcomp (pattern_buffer_ptr, pattern, cflags);
-
- if (valid_pattern && error_code_returned)
- {
- printf ("\nShould have been a valid pattern but wasn't.\n");
- regerror (error_code_returned, pattern_buffer_ptr, errbuf,
- TEST_ERRBUF_SIZE);
- printf ("%s", errbuf);
- error = true;
- }
-
- if (!valid_pattern && !error_code_returned)
- {
- printf ("\n\nInvalid pattern compiled as valid:\n");
- error = true;
- }
-
- if (error_code_returned != error_code_expected)
- {
- char expected_error_string[ERROR_CODE_LENGTH];
- char returned_error_string[ERROR_CODE_LENGTH];
-
- get_error_string (error_code_expected, expected_error_string),
- get_error_string (error_code_returned, returned_error_string);
-
- printf (" Expected error code %s but got `%s'.\n",
- expected_error_string, returned_error_string);
-
- error = true;
- }
-
- if (error)
- print_pattern_info (pattern, pattern_buffer_ptr);
-}
-
-
-static void
-test_nsub (sub_count, pattern, cflags)
- unsigned sub_count;
- char *pattern;
- int cflags;
-
-{
- regex_t pattern_buffer;
-
- test_compile (1, 0, pattern, &pattern_buffer, cflags);
-
- if (pattern_buffer.re_nsub != sub_count)
- {
- printf ("\nShould have counted %d subexpressions but counted %d \
-instead.\n", sub_count, pattern_buffer.re_nsub);
- }
-
- regfree (&pattern_buffer);
-}
-
-
-static void
-test_regcomp ()
-{
- regex_t pattern_buffer;
- int cflags = 0;
-
-
- printf ("\nStarting regcomp tests.\n");
-
- cflags = 0;
- test_compile (0, REG_ESUBREG, "\\(a\\)\\2", &pattern_buffer, cflags);
- test_compile (0, REG_EBRACE, "a\\{", &pattern_buffer, cflags);
- test_compile (0, REG_BADBR, "a\\{-1\\}", &pattern_buffer, cflags);
- test_compile (0, REG_EBRACE, "a\\{", &pattern_buffer, cflags);
- test_compile (0, REG_EBRACE, "a\\{1", &pattern_buffer, cflags);
-
- cflags = REG_EXTENDED;
- test_compile (0, REG_ECTYPE, "[[:alpo:]]", &pattern_buffer, cflags);
- test_compile (0, REG_EESCAPE, "\\", &pattern_buffer, cflags);
- test_compile (0, REG_EBRACK, "[a", &pattern_buffer, cflags);
- test_compile (0, REG_EPAREN, "(", &pattern_buffer, cflags);
- test_compile (0, REG_ERANGE, "[z-a]", &pattern_buffer, cflags);
-
- test_nsub (1, "(a)", cflags);
- test_nsub (2, "((a))", cflags);
- test_nsub (2, "(a)(b)", cflags);
-
- cflags = REG_EXTENDED | REG_NOSUB;
- test_nsub (1, "(a)", cflags);
-
- regfree (&pattern_buffer);
-
- printf ("\nFinished regcomp tests.\n");
-}
-
-
-static void
-fill_pmatch (pmatch, start0, end0, start1, end1, start2, end2)
- regmatch_t pmatch[];
- regoff_t start0, end0, start1, end1, start2, end2;
-{
- pmatch[0].rm_so = start0;
- pmatch[0].rm_eo = end0;
- pmatch[1].rm_so = start1;
- pmatch[1].rm_eo = end1;
- pmatch[2].rm_so = start2;
- pmatch[2].rm_eo = end2;
-}
-
-
-static void
-test_pmatch (pattern, string, nmatch, pmatch, correct_pmatch, cflags)
- char *pattern;
- char *string;
- unsigned nmatch;
- regmatch_t pmatch[];
- regmatch_t correct_pmatch[];
- int cflags;
-{
- regex_t pattern_buffer;
- unsigned this_match;
- int error_code_returned;
- boolean found_nonmatch = false;
-
- test_compile (1, 0, pattern, &pattern_buffer, cflags);
- error_code_returned = regexec (&pattern_buffer, string, nmatch, pmatch, 0);
-
- if (error_code_returned == REG_NOMATCH)
- printf ("Matching failed in test_pmatch.\n");
- else
- {
- for (this_match = 0; this_match < nmatch; this_match++)
- {
- if (pmatch[this_match].rm_so != correct_pmatch[this_match].rm_so)
- {
- if (found_nonmatch == false)
- printf ("\n");
-
- printf ("Pmatch start %d wrong: was %d when should have \
-been %d.\n", this_match, pmatch[this_match].rm_so,
- correct_pmatch[this_match].rm_so);
- found_nonmatch = true;
- }
- if (pmatch[this_match].rm_eo != correct_pmatch[this_match].rm_eo)
- {
- if (found_nonmatch == false)
- printf ("\n");
-
- printf ("Pmatch end %d wrong: was %d when should have been \
-%d.\n", this_match, pmatch[this_match].rm_eo,
- correct_pmatch[this_match].rm_eo);
- found_nonmatch = true;
- }
- }
-
- if (found_nonmatch)
- {
- printf (" The number of pmatches requested was: %d.\n", nmatch);
- printf (" The string to match was: `%s'.\n", string);
- print_pattern_info (pattern, &pattern_buffer);
- }
- } /* error_code_returned == REG_NOMATCH */
-
- regfree (&pattern_buffer);
-}
-
-
-static void
-test_eflags (must_match_bol, must_match_eol, pattern, string, cflags, eflags)
- boolean must_match_bol;
- boolean must_match_eol;
- char *pattern;
- char *string;
- int cflags;
- int eflags;
-{
- regex_t pattern_buffer;
- int error_code_returned;
- boolean was_error = false;
-
- test_compile (1, 0, pattern, &pattern_buffer, cflags);
- error_code_returned = regexec (&pattern_buffer, string, 0, 0, eflags);
-
- if (error_code_returned == REG_NOMATCH)
- {
- /* If wasn't true that both 1) the anchored part of the pattern
- had to match this string and 2) this string was a proper
- substring... */
-
- if (!( (must_match_bol && (eflags & REG_NOTBOL))
- || (must_match_eol && (eflags & REG_NOTEOL)) ))
- {
- printf ("\nEflags test failed: didn't match when should have.\n");
- was_error = true;
- }
- }
- else /* We got a match. */
- {
- /* If wasn't true that either 1) the anchored part of the pattern
- didn't have to match this string or 2) this string wasn't a
- proper substring... */
-
- if ((must_match_bol == (eflags & REG_NOTBOL))
- || (must_match_eol == (eflags & REG_NOTEOL)))
- {
- printf ("\nEflags test failed: matched when shouldn't have.\n");
- was_error = true;
- }
- }
-
- if (was_error)
- {
- printf (" The string to match was: `%s'.\n", string);
- print_pattern_info (pattern, &pattern_buffer);
-
- if (eflags & REG_NOTBOL)
- printf (" The eflag REG_BOL was set.\n");
- if (eflags & REG_NOTEOL)
- printf (" The eflag REG_EOL was set.\n");
- }
-
- regfree (&pattern_buffer);
-}
-
-
-static void
-test_ignore_case (should_match, pattern, string, cflags)
- boolean should_match;
- char *pattern;
- char *string;
- int cflags;
-{
- regex_t pattern_buffer;
- int error_code_returned;
-
- test_compile (1, 0, pattern, &pattern_buffer, cflags);
- error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0);
-
- if (should_match && error_code_returned == REG_NOMATCH)
- {
- printf ("\nIgnore-case test failed:\n");
- printf (" The string to match was: `%s'.\n", string);
- print_pattern_info (pattern, &pattern_buffer);
-
- if (cflags & REG_ICASE)
- printf (" The cflag REG_ICASE was set.\n");
- }
-
- regfree (&pattern_buffer);
-}
-
-
-static void
-test_newline (should_match, pattern, string, cflags)
- boolean should_match;
- char *pattern;
- char *string;
- int cflags;
-{
- regex_t pattern_buffer;
- int error_code_returned;
-
- test_compile (1, 0, pattern, &pattern_buffer, cflags);
- error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0);
-
- if (should_match && error_code_returned == REG_NOMATCH)
- {
- printf ("\nNewline test failed:\n");
- printf (" The string to match was: `%s'.\n", string);
- print_pattern_info (pattern, &pattern_buffer);
-
- if (cflags & REG_NEWLINE)
- printf (" The cflag REG_NEWLINE was set.\n");
- else
- printf (" The cflag REG_NEWLINE wasn't set.\n");
- }
-
- regfree (&pattern_buffer);
-}
-
-
-static void
-test_posix_match (should_match, pattern, string, cflags)
- boolean should_match;
- char *pattern;
- char *string;
- int cflags;
-{
- regex_t pattern_buffer;
- int error_code_returned;
- boolean was_error = false;
-
- test_compile (1, 0, pattern, &pattern_buffer, cflags);
- error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0);
-
- if (should_match && error_code_returned == REG_NOMATCH)
- {
- printf ("\nShould have matched but didn't:\n");
- was_error = true;
- }
- else if (!should_match && error_code_returned != REG_NOMATCH)
- {
- printf ("\nShould not have matched but did:\n");
- was_error = true;
- }
-
- if (was_error)
- {
- printf (" The string to match was: `%s'.\n", string);
- print_pattern_info (pattern, &pattern_buffer);
- }
-
- regfree (&pattern_buffer);
-}
-
-
-static void
-test_regexec ()
-{
- regmatch_t pmatch[3];
- regmatch_t correct_pmatch[3];
- int cflags = 0;
- int eflags = 0;
-
- printf ("\nStarting regexec tests.\n");
-
- cflags = REG_NOSUB; /* shouldn't look at any of pmatch. */
- test_pmatch ("a", "a", 0, pmatch, correct_pmatch, cflags);
-
- /* Ask for less `pmatch'es than there are pattern subexpressions.
- (Shouldn't look at pmatch[2]. */
- cflags = REG_EXTENDED;
- fill_pmatch (correct_pmatch, 0, 1, 0, 1, 100, 101);
- test_pmatch ("((a))", "a", 2, pmatch, correct_pmatch, cflags);
-
- /* Ask for same number of `pmatch'es as there are pattern subexpressions. */
- cflags = REG_EXTENDED;
- fill_pmatch(correct_pmatch, 0, 1, 0, 1, -1, -1);
- test_pmatch ("(a)", "a", 2, pmatch, correct_pmatch, cflags);
-
- /* Ask for more `pmatch'es than there are pattern subexpressions. */
- cflags = REG_EXTENDED;
- fill_pmatch (correct_pmatch, 0, 1, -1, -1, -1, -1);
- test_pmatch ("a", "a", 2, pmatch, correct_pmatch, cflags);
-
- eflags = REG_NOTBOL;
- test_eflags (true, false, "^a", "a", cflags, eflags);
- test_eflags (true, false, "(^a)", "a", cflags, eflags);
- test_eflags (true, false, "a|^b", "b", cflags, eflags);
- test_eflags (true, false, "^b|a", "b", cflags, eflags);
-
- eflags = REG_NOTEOL;
- test_eflags (false, true, "a$", "a", cflags, eflags);
- test_eflags (false, true, "(a$)", "a", cflags, eflags);
- test_eflags (false, true, "a|b$", "b", cflags, eflags);
- test_eflags (false, true, "b$|a", "b", cflags, eflags);
-
- eflags = REG_NOTBOL | REG_NOTEOL;
- test_eflags (true, true, "^a$", "a", cflags, eflags);
- test_eflags (true, true, "(^a$)", "a", cflags, eflags);
- test_eflags (true, true, "a|(^b$)", "b", cflags, eflags);
- test_eflags (true, true, "(^b$)|a", "b", cflags, eflags);
-
- cflags = REG_ICASE;
- test_ignore_case (true, "a", "a", cflags);
- test_ignore_case (true, "A", "A", cflags);
- test_ignore_case (true, "A", "a", cflags);
- test_ignore_case (true, "a", "A", cflags);
-
- test_ignore_case (true, "@", "@", cflags);
- test_ignore_case (true, "\\[", "[", cflags);
- test_ignore_case (true, "`", "`", cflags);
- test_ignore_case (true, "{", "{", cflags);
-
- test_ignore_case (true, "[!-`]", "A", cflags);
- test_ignore_case (true, "[!-`]", "a", cflags);
-
- cflags = 0;
- test_ignore_case (false, "a", "a", cflags);
- test_ignore_case (false, "A", "A", cflags);
- test_ignore_case (false, "A", "a", cflags);
- test_ignore_case (false, "a", "A", cflags);
-
- test_ignore_case (true, "@", "@", cflags);
- test_ignore_case (true, "\\[", "[", cflags);
- test_ignore_case (true, "`", "`", cflags);
- test_ignore_case (true, "{", "{", cflags);
-
- test_ignore_case (true, "[!-`]", "A", cflags);
- test_ignore_case (false, "[!-`]", "a", cflags);
-
-
- /* Test newline stuff. */
- cflags = REG_EXTENDED | REG_NEWLINE;
- test_newline (true, "\n", "\n", cflags);
- test_newline (true, "a\n", "a\n", cflags);
- test_newline (true, "\nb", "\nb", cflags);
- test_newline (true, "a\nb", "a\nb", cflags);
-
- test_newline (false, ".", "\n", cflags);
- test_newline (false, "[^a]", "\n", cflags);
-
- test_newline (true, "\n^a", "\na", cflags);
- test_newline (true, "\n(^a|b)", "\na", cflags);
- test_newline (true, "a$\n", "a\n", cflags);
- test_newline (true, "(a$|b)\n", "a\n", cflags);
- test_newline (true, "(a$|b|c)\n", "a\n", cflags);
- test_newline (true, "((a$|b|c)$)\n", "a\n", cflags);
- test_newline (true, "((a$|b|c)$)\n", "b\n", cflags);
- test_newline (true, "(a$|b)\n|a\n", "a\n", cflags);
-
- test_newline (true, "^a", "\na", cflags);
- test_newline (true, "a$", "a\n", cflags);
-
- /* Now test normal behavior. */
- cflags = REG_EXTENDED;
- test_newline (true, "\n", "\n", cflags);
- test_newline (true, "a\n", "a\n", cflags);
- test_newline (true, "\nb", "\nb", cflags);
- test_newline (true, "a\nb", "a\nb", cflags);
-
- test_newline (true, ".", "\n", cflags);
- test_newline (true, "[^a]", "\n", cflags);
-
- test_newline (false, "\n^a", "\na", cflags);
- test_newline (false, "a$\n", "a\n", cflags);
-
- test_newline (false, "^a", "\na", cflags);
- test_newline (false, "a$", "a\n", cflags);
-
-
- /* Test that matches whole string only. */
- cflags = 0;
- test_posix_match (true, "a", "a", cflags);
-
- /* Tests that match substrings. */
- test_posix_match (true, "a", "ab", cflags);
- test_posix_match (true, "b", "ab", cflags);
-
- /* Test that doesn't match. */
- test_posix_match (false, "a", "b", cflags);
-
- printf ("\nFinished regexec tests.\n");
-}
-
-
-static void
-test_error_code_message (error_code, expected_error_message)
- int error_code;
- char *expected_error_message;
-{
- char returned_error_message[TEST_ERRBUF_SIZE];
- char error_code_string[ERROR_CODE_LENGTH];
- size_t expected_error_message_length = strlen (expected_error_message) + 1;
- size_t returned_error_message_length = regerror (error_code, 0,
- returned_error_message,
- TEST_ERRBUF_SIZE);
-
- if (returned_error_message_length != expected_error_message_length)
- {
- printf ("\n\n Testing returned error codes, with expected error \
-message `%s':\n", expected_error_message);
-
- printf ("\n\n and returned error message `%s':\n",
- returned_error_message);
- printf (" should have returned a length of %d but returned %d.\n",
- expected_error_message_length, returned_error_message_length);
- }
-
- if (strncmp (expected_error_message, returned_error_message,
- TEST_ERRBUF_SIZE - 1) != 0)
- {
-
- get_error_string (error_code, error_code_string),
- printf ("\n\n With error code %s (%d), expected error message:\n",
- error_code_string, error_code);
-
- printf (" `%s'\n", expected_error_message);
- printf (" but got:\n");
- printf (" `%s'\n", returned_error_message);
- }
-}
-
-
-static void
-test_error_code_allocation (error_code, expected_error_message)
- int error_code;
- char *expected_error_message;
-{
- char *returned_error_message = NULL;
- char error_code_string[ERROR_CODE_LENGTH];
- size_t returned_error_message_length = regerror (error_code, 0,
- returned_error_message,
- (size_t)0);
-
- returned_error_message = xmalloc (returned_error_message_length + 1);
-
- regerror (error_code, 0, returned_error_message,
- returned_error_message_length);
-
- if (strcmp (expected_error_message, returned_error_message) != 0)
- {
- get_error_string (error_code, error_code_string),
-
- printf ("\n\n Testing error code allocation,\n");
- printf ("with error code %s (%d), expected error message:\n",
- error_code_string, error_code);
- printf (" `%s'\n", expected_error_message);
- printf (" but got:\n");
- printf (" `%s'\n", returned_error_message);
- }
-}
-
-
-static void
-test_regerror ()
-{
- test_error_code_message (REG_NOMATCH, "No match");
- test_error_code_message (REG_BADPAT, "Invalid regular expression");
- test_error_code_message (REG_ECOLLATE, "Invalid collation character");
- test_error_code_message (REG_ECTYPE, "Invalid character class name");
- test_error_code_message (REG_EESCAPE, "Trailing backslash");
- test_error_code_message (REG_ESUBREG, "Invalid back reference");
- test_error_code_message (REG_EBRACK, "Unmatched [ or [^");
- test_error_code_message (REG_EPAREN, "Unmatched ( or \\(");
- test_error_code_message (REG_EBRACE, "Unmatched \\{");
- test_error_code_message (REG_BADBR, "Invalid content of \\{\\}");
- test_error_code_message (REG_ERANGE, "Invalid range end");
- test_error_code_message (REG_ESPACE, "Memory exhausted");
- test_error_code_message (REG_BADRPT, "Invalid preceding regular expression");
- test_error_code_message (REG_EEND, "Premature end of regular expression");
- test_error_code_message (REG_ESIZE, "Regular expression too big");
- test_error_code_allocation (REG_ERPAREN, "Unmatched ) or \\)");
-}
-
-
-void
-test_posix_interface ()
-{
- printf ("\nStarting POSIX interface tests.\n");
- t = posix_interface_test;
-
- test_regcomp ();
- test_regexec ();
- test_regerror ();
-
- printf ("\nFinished POSIX interface tests.\n");
-}
diff --git a/gnu/lib/libregex/test/psx-interv.c b/gnu/lib/libregex/test/psx-interv.c
deleted file mode 100644
index fcdf488..0000000
--- a/gnu/lib/libregex/test/psx-interv.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/* psx-interv.c: test POSIX intervals, both basic and extended. */
-
-#include "test.h"
-
-void
-test_intervals ()
-{
- printf ("\nStarting POSIX interval tests.\n");
-
- test_should_match = true;
- /* Valid intervals. */
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,2}b)*")), "abaab");
- test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,2}b)*")), "a", 0, 0);
- TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,2}b)*")),
- "abaab", 0, 5, 2, 5, -1, -1);
-
- test_match (BRACES_TO_OPS ("a{0}"), "");
- test_fastmap (BRACES_TO_OPS ("a{0}"), "", 0, 0);
- TEST_REGISTERS (BRACES_TO_OPS ("a{0}"), "", 0, 0, -1, -1, -1, -1);
- TEST_REGISTERS (BRACES_TO_OPS ("a{0}"), "x", 0, 0, -1, -1, -1, -1);
-
- test_match (BRACES_TO_OPS ("a{0,}"), "");
- test_match (BRACES_TO_OPS ("a{0,}"), "a");
- test_fastmap (BRACES_TO_OPS ("a{0,}"), "a", 0, 0);
- TEST_REGISTERS (BRACES_TO_OPS ("a{0,}"), "a", 0, 1, -1, -1, -1, -1);
- TEST_REGISTERS (BRACES_TO_OPS ("a{0,}"), "xax", 0, 0, -1, -1, -1, -1);
-
- test_match (BRACES_TO_OPS ("a{1}"), "a");
- test_match (BRACES_TO_OPS ("a{1,}"), "a");
- test_match (BRACES_TO_OPS ("a{1,}"), "aa");
- test_match (BRACES_TO_OPS ("a{0,0}"), "");
- test_match (BRACES_TO_OPS ("a{0,1}"), "");
- test_match (BRACES_TO_OPS ("a{0,1}"), "a");
- test_match (BRACES_TO_OPS ("a{1,3}"), "a");
- test_match (BRACES_TO_OPS ("a{1,3}"), "aa");
- test_match (BRACES_TO_OPS ("a{1,3}"), "aaa");
- TEST_REGISTERS (BRACES_TO_OPS ("a{1,3}"), "aaa", 0, 3, -1, -1, -1, -1);
- TEST_REGISTERS (BRACES_TO_OPS ("a{1,3}"), "xaaax", 1, 4, -1, -1, -1, -1);
-
- test_match (BRACES_TO_OPS ("a{0,3}b"), "b");
- test_match (BRACES_TO_OPS ("a{0,3}b"), "aaab");
- test_fastmap (BRACES_TO_OPS ("a{0,3}b"), "ab", 0, 0);
- TEST_REGISTERS (BRACES_TO_OPS ("a{0,3}b"), "b", 0, 1, -1, -1, -1, -1);
- TEST_REGISTERS (BRACES_TO_OPS ("a{0,3}b"), "xbx", 1, 2, -1, -1, -1, -1);
-
- test_match (BRACES_TO_OPS ("a{1,3}b"), "ab");
- test_match (BRACES_TO_OPS ("a{1,3}b"), "aaab");
- test_match (BRACES_TO_OPS ("ab{1,3}c"), "abbbc");
-
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "b");
- test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "ab", 0, 0);
- TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "b", 0, 1, -1, -1, -1, -1);
- TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "ab", 0, 2, 0, 1, -1, -1);
- TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "xabx", 1, 3, 1, 2, -1, -1);
-
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "ab");
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "aaab");
- TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "aaab", 0, 4, 2, 3, -1, -1);
- TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "xaaabx", 1, 5, 3, 4, -1, -1);
-
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){0,3}b")), "aaaab");
- test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){0,3}b")), "ab", 0, 0);
- TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){0,3}b")), "aaaab", 0, 5, 4, 4, -1, -1);
-
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "b");
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "aaab");
- test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "ab", 0, 0);
-
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,1}ab")), "aaaab");
- TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,1}ab")), "aaaab", 0, 5, 0, 3, -1, -1);
-
- test_match (BRACES_TO_OPS (".{0,3}b"), "b");
- test_match (BRACES_TO_OPS (".{0,3}b"), "ab");
-
- test_match (BRACES_TO_OPS ("[a]{0,3}b"), "b");
- test_match (BRACES_TO_OPS ("[a]{0,3}b"), "aaab");
- test_fastmap (BRACES_TO_OPS ("[a]{0,3}b"), "ab", 0, 0);
- test_match (BRACES_TO_OPS ("[^a]{0,3}b"), "bcdb");
- test_match (BRACES_TO_OPS ("ab{0,3}c"), "abbbc");
- test_match (BRACES_TO_OPS ("[[:digit:]]{0,3}d"), "123d");
- test_fastmap (BRACES_TO_OPS ("[[:digit:]]{0,3}d"), "0123456789d", 0, 0);
-
- test_match (BRACES_TO_OPS ("\\*{0,3}a"), "***a");
- test_match (BRACES_TO_OPS (".{0,3}b"), "aaab");
- test_match (BRACES_TO_OPS ("a{0,3}a"), "aaa");
- /* Backtracking. */
- test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,})*a")), "a", 0, 0);
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,})*a")), "a");
- TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,})*a")), "a", 0, 1, -1, -1, -1, -1);
-
- test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a{2,})*aa")), "aa", 0, 0);
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a{2,})*aa")), "aa");
- TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a{2,})*aa")), "aa", 0, 2, -1, -1, -1, -1);
-
- test_match (BRACES_TO_OPS ("a{2}*"), "");
- test_match (BRACES_TO_OPS ("a{2}*"), "aa");
-
- test_match (BRACES_TO_OPS ("a{1}*"), "");
- test_match (BRACES_TO_OPS ("a{1}*"), "a");
- test_match (BRACES_TO_OPS ("a{1}*"), "aa");
-
- test_match (BRACES_TO_OPS ("a{1}{1}"), "a");
-
- test_match (BRACES_TO_OPS ("a{1}{1}{1}"), "a");
- test_match (BRACES_TO_OPS ("a{1}{1}{2}"), "aa");
-
- test_match (BRACES_TO_OPS ("a{1}{1}*"), "");
- test_match (BRACES_TO_OPS ("a{1}{1}*"), "a");
- test_match (BRACES_TO_OPS ("a{1}{1}*"), "aa");
- test_match (BRACES_TO_OPS ("a{1}{1}*"), "aaa");
-
- test_match (BRACES_TO_OPS ("a{1}{2}"), "aa");
- test_match (BRACES_TO_OPS ("a{2}{1}"), "aa");
-
-
- test_should_match = false;
-
- test_match (BRACES_TO_OPS ("a{0}"), "a");
- test_match (BRACES_TO_OPS ("a{0,}"), "b");
- test_match (BRACES_TO_OPS ("a{1}"), "");
- test_match (BRACES_TO_OPS ("a{1}"), "aa");
- test_match (BRACES_TO_OPS ("a{1,}"), "");
- test_match (BRACES_TO_OPS ("a{1,}"), "b");
- test_match (BRACES_TO_OPS ("a{0,0}"), "a");
- test_match (BRACES_TO_OPS ("a{0,1}"), "aa");
- test_match (BRACES_TO_OPS ("a{0,1}"), "b");
- test_match (BRACES_TO_OPS ("a{1,3}"), "");
- test_match (BRACES_TO_OPS ("a{1,3}"), "aaaa");
- test_match (BRACES_TO_OPS ("a{1,3}"), "b");
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "aaaab");
- test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "bb");
- test_match (BRACES_TO_OPS ("[a]{0,3}"), "aaaa");
- test_match (BRACES_TO_OPS ("[^a]{0,3}b"), "ab");
- test_match (BRACES_TO_OPS ("ab{0,3}c"), "abababc");
- test_match (BRACES_TO_OPS ("[:alpha:]{0,3}d"), "123d");
- test_match (BRACES_TO_OPS ("\\^{1,3}a"), "a");
- test_match (BRACES_TO_OPS (".{0,3}b"), "aaaab");
-
- printf ("\nFinished POSIX interval tests.\n");
-}
diff --git a/gnu/lib/libregex/test/regexcpp.sed b/gnu/lib/libregex/test/regexcpp.sed
deleted file mode 100644
index 082c136..0000000
--- a/gnu/lib/libregex/test/regexcpp.sed
+++ /dev/null
@@ -1,8 +0,0 @@
-/;..*$/s/;/;\
-/g
-/{ .*$/s/{/{\
-/g
-/ \?[^'] /s/?/?\
-/g
-/ : /s/:/:\
-/g
diff --git a/gnu/lib/libregex/test/syntax.skel b/gnu/lib/libregex/test/syntax.skel
deleted file mode 100644
index a3fbf64..0000000
--- a/gnu/lib/libregex/test/syntax.skel
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Print which syntax bits are set. */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include "regex.h"
-
-/* It's coincidental that these two are currently the same. */
-#define LONGEST_BIT_NAME "RE_UNMATCHED_RIGHT_PAREN_ORD"
-#define LAST_BIT RE_UNMATCHED_RIGHT_PAREN_ORD
-
-/* Sum of above, when printed. Assigned in main. */
-static unsigned longest;
-
-
-static void
-test_bit (syntax, bit, name)
- reg_syntax_t syntax;
- unsigned bit;
- char *name;
-{
- char padding[100], test_str[100];
- int padding_count;
-
- sprintf (test_str, "%s (%d=0x%x)", name, bit, bit);
- padding_count = longest - strlen (test_str);
-
- padding[padding_count] = 0;
- while (padding_count--)
- {
- padding[padding_count] = ' ';
- }
-
- printf ("%s%s (%d=0x%x): %c\n",
- name, padding, bit, bit, syntax & bit ? 'y' : 'n');
-}
-
-
-/* Macro to abbreviate the constant arguments. */
-#define TEST_BIT(bit) test_bit (syntax, bit, #bit)
-
-int
-main (argc, argv)
- int argc;
- char *argv[];
-{
- reg_syntax_t syntax;
- char syntax_str[1000], test_str[100];
-
- switch (argc)
- {
- case 1:
- printf ("Syntax? ");
- scanf ("%s", syntax_str);
- break;
-
- case 2:
- strcpy (syntax_str, argv[1]);
- break;
-
- default:
- fprintf (stderr, "Usage: syntax [syntax].\n");
- exit (1);
- }
-
- sscanf (syntax_str, "%i", &syntax);
-
- /* Figure out the longest name, so we can align the output nicely. */
- sprintf (test_str, "%s (%d=0x%x)", LONGEST_BIT_NAME, LAST_BIT, LAST_BIT);
- longest = strlen (test_str);
-
- /* [[[replace with bit tests]]] */
-
- return 0;
-}
diff --git a/gnu/lib/libregex/test/test.c b/gnu/lib/libregex/test/test.c
deleted file mode 100644
index 74b43b2..0000000
--- a/gnu/lib/libregex/test/test.c
+++ /dev/null
@@ -1,782 +0,0 @@
-/* test.c: testing routines for regex.c. */
-
-#include <assert.h>
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-char *malloc ();
-char *realloc ();
-#endif
-
-/* Just to be complete, we make both the system V/ANSI and the BSD
- versions of the string functions available. */
-#if USG || STDC_HEADERS
-#include <string.h>
-#define index strchr
-#define rindex strrchr
-#define bcmp(s1, s2, len) memcmp ((s1), (s2), (len))
-#define bcopy(from, to, len) memcpy ((to), (from), (len))
-#define bzero(s, len) memset ((s), 0, (len))
-#else
-#include <strings.h>
-#define strchr index
-#define strrchr rindex
-#ifndef NEED_MEMORY_H
-#define memcmp(s1, s2, n) bcmp ((s1), (s2), (n))
-#define memcpy(to, from, len) bcopy ((from), (to), (len))
-#endif
-extern char *strtok ();
-extern char *strstr ();
-#endif /* not USG or STDC_HEADERS */
-
-/* SunOS 4.1 declares memchr in <memory.h>, not <string.h>. I don't
- understand why. */
-#if NEED_MEMORY_H
-#include <memory.h>
-#endif
-
-#include "test.h"
-
-#define BYTEWIDTH 8
-
-extern void print_partial_compiled_pattern ();
-extern void print_compiled_pattern ();
-extern void print_double_string ();
-
-/* If nonzero, the results of every test are displayed. */
-boolean verbose = false;
-
-/* If nonzero, don't do register testing. */
-boolean omit_register_tests = true;
-
-/* Says whether the current test should match or fail to match. */
-boolean test_should_match;
-
-
-static void
-set_all_registers (start0, end0, start1, end1,
- start2, end2, start3, end3,
- start4, end4, start5, end5,
- start6, end6, start7, end7,
- start8, end8, start9, end9, regs)
-
- int start0; int end0; int start1; int end1;
- int start2; int end2; int start3; int end3;
- int start4; int end4; int start5; int end5;
- int start6; int end6; int start7; int end7;
- int start8; int end8; int start9; int end9;
- struct re_registers *regs;
-
- {
- unsigned r;
-
- regs->start[0] = start0; regs->end[0] = end0;
- regs->start[1] = start1; regs->end[1] = end1;
- regs->start[2] = start2; regs->end[2] = end2;
- regs->start[3] = start3; regs->end[3] = end3;
- regs->start[4] = start4; regs->end[4] = end4;
- regs->start[5] = start5; regs->end[5] = end5;
- regs->start[6] = start6; regs->end[6] = end6;
- regs->start[7] = start7; regs->end[7] = end7;
- regs->start[8] = start8; regs->end[8] = end8;
- regs->start[9] = start9; regs->end[9] = end9;
- for (r = 10; r < regs->num_regs; r++)
- {
- regs->start[r] = -1;
- regs->end[r] = -1;
- }
- }
-
-
-
-/* Return the concatenation of S1 and S2. This would be a prime place
- to use varargs. */
-
-char *
-concat (s1, s2)
- char *s1;
- char *s2;
-{
- char *answer = xmalloc (strlen (s1) + strlen (s2) + 1);
-
- strcpy (answer, s1);
- strcat (answer, s2);
-
- return answer;
-}
-
-
-#define OK_TO_SEARCH (nonconst_buf.fastmap_accurate && (str1 || str2))
-
-/* We ignore the `can_be_null' argument. Should just be removed. */
-
-void
-general_test (pattern_should_be_valid, match_whole_string,
- pat, str1, str2, start, range, end, correct_fastmap,
- correct_regs, can_be_null)
- unsigned pattern_should_be_valid;
- unsigned match_whole_string;
- const char *pat;
- char *str1, *str2;
- int start, range, end;
- char *correct_fastmap;
- struct re_registers *correct_regs;
- int can_be_null;
-{
- struct re_pattern_buffer nonconst_buf;
- struct re_pattern_buffer old_buf;
- struct re_registers regs;
- const char *r;
- char fastmap[1 << BYTEWIDTH];
- unsigned *regs_correct = NULL;
- unsigned all_regs_correct = 1;
- boolean fastmap_internal_error = false;
- unsigned match = 0;
- unsigned match_1 = 0;
- unsigned match_2 = 0;
- unsigned invalid_pattern = 0;
- boolean internal_error_1 = false;
- boolean internal_error_2 = false;
-
-
- nonconst_buf.allocated = 8;
- nonconst_buf.buffer = xmalloc (nonconst_buf.allocated);
- nonconst_buf.fastmap = fastmap;
- nonconst_buf.translate = 0;
-
- assert (pat != NULL);
- r = re_compile_pattern (pat, strlen (pat), &nonconst_buf);
-
- /* Kludge: if we are doing POSIX testing, we really should have
- called regcomp, not re_compile_pattern. As it happens, the only
- way in which it matters is that re_compile_pattern sets the
- newline/anchor field for matching (part of what happens when
- REG_NEWLINE is given to regcomp). We have to undo that for POSIX
- matching. */
- if (t == posix_basic_test || t == posix_extended_test)
- nonconst_buf.newline_anchor = 0;
-
- invalid_pattern = r != NULL;
-
- if (!r)
- {
- int r;
-
- if (!pattern_should_be_valid)
- printf ("\nShould have been an invalid pattern but wasn't:\n");
- else
- {
- fastmap_internal_error = (re_compile_fastmap (&nonconst_buf) == -2);
-
- if (correct_fastmap)
- nonconst_buf.fastmap_accurate =
- memcmp (nonconst_buf.fastmap, correct_fastmap, 1 << BYTEWIDTH)
- == 0;
-
- if (OK_TO_SEARCH)
- {
- old_buf = nonconst_buf;
- old_buf.buffer = (unsigned char *) xmalloc (nonconst_buf.used);
- memcpy (old_buf.buffer, nonconst_buf.buffer, nonconst_buf.used);
-
- /* If only one string is null, call re_match or re_search,
- which is what the user would probably do. */
- if (str1 == NULL && str2 != NULL
- || str2 == NULL && str1 != NULL)
- {
- char *the_str = str1 == NULL ? str2 : str1;
-
- match_1
- = match_whole_string
- ? (r = re_match (&nonconst_buf, the_str,
- strlen (the_str), start, &regs))
- == strlen (the_str)
- : (r = re_search (&nonconst_buf,
- the_str, strlen (the_str),
- start, range, &regs))
- >= 0;
-
- if (r == -2)
- internal_error_1 = true;
- }
- else
- match_1 = 1;
-
- /* Also call with re_match_2 or re_search_2, as they might
- do this. (Also can check calling with either string1
- or string2 or both null.) */
- if (match_whole_string)
- {
- r = re_match_2 (&nonconst_buf,
- str1, SAFE_STRLEN (str1),
- str2, SAFE_STRLEN (str2),
- start, &regs, end);
- match_2 = r == SAFE_STRLEN (str1) + SAFE_STRLEN (str2);
- }
- else
- {
- r = re_search_2 (&nonconst_buf,
- str1, SAFE_STRLEN (str1),
- str2, SAFE_STRLEN (str2),
- start, range, &regs, end);
- match_2 = r >= 0;
- }
-
- if (r == -2)
- internal_error_2 = true;
-
- match = match_1 & match_2;
-
- if (correct_regs)
- {
- unsigned reg;
- if (regs_correct != NULL)
- free (regs_correct);
-
- regs_correct
- = (unsigned *) xmalloc (regs.num_regs * sizeof (unsigned));
-
- for (reg = 0;
- reg < regs.num_regs && reg < correct_regs->num_regs;
- reg++)
- {
- regs_correct[reg]
- = (regs.start[reg] == correct_regs->start[reg]
- && regs.end[reg] == correct_regs->end[reg])
-#ifdef EMPTY_REGS_CONFUSED
- /* There is confusion in the standard about
- the registers in some patterns which can
- match either the empty string or not match.
- For example, in `((a*))*' against the empty
- string, the two registers can either match
- the empty string (be 0/0), or not match
- (because of the outer *) (be -1/-1). (Or
- one can do one and one can do the other.) */
- || (regs.start[reg] == -1 && regs.end[reg] == -1
- && correct_regs->start[reg]
- == correct_regs->end[reg])
-#endif
- ;
-
- all_regs_correct &= regs_correct[reg];
- }
- }
- } /* OK_TO_SEARCH */
- }
- }
-
- if (fastmap_internal_error)
- printf ("\n\nInternal error in re_compile_fastmap:");
-
- if (internal_error_1)
- {
- if (!fastmap_internal_error)
- printf ("\n");
-
- printf ("\nInternal error in re_match or re_search:");
- }
-
- if (internal_error_2)
- {
- if (!internal_error_1)
- printf ("\n");
-
- printf ("\nInternal error in re_match_2 or re_search_2:");
- }
-
- if ((OK_TO_SEARCH && ((match && !test_should_match)
- || (!match && test_should_match))
- || (correct_regs && !all_regs_correct))
- || !nonconst_buf.fastmap_accurate
- || invalid_pattern
- || !pattern_should_be_valid
- || internal_error_1 || internal_error_2
- || verbose)
- {
- if (OK_TO_SEARCH && match && !test_should_match)
- {
- printf ("\n\nMatched but shouldn't have:\n");
- if (match_1)
- printf ("The single match/search succeeded.\n");
-
- if (match_2)
- printf ("The double match/search succeeded.\n");
- }
- else if (OK_TO_SEARCH && !match && test_should_match)
- {
- printf ("\n\nDidn't match but should have:\n");
- if (!match_1)
- printf ("The single match/search failed.\n");
-
- if (!match_2)
- printf ("The double match/search failed.\n");
- }
- else if (invalid_pattern && pattern_should_be_valid)
- printf ("\n\nInvalid pattern (%s):\n", r);
- else if (!nonconst_buf.fastmap_accurate && pattern_should_be_valid)
- printf ("\n\nIncorrect fastmap:\n");
- else if (OK_TO_SEARCH && correct_regs && !all_regs_correct)
- printf ("\n\nNot all registers were correct:\n");
- else if (verbose)
- printf ("\n\nTest was OK:\n");
-
-
- if ((!(invalid_pattern && !pattern_should_be_valid)) || verbose)
- printf (" Pattern: `%s'.\n", pat);
-
- if (pattern_should_be_valid || verbose
- || internal_error_1 || internal_error_2)
- {
- printf(" Strings: ");
- printf ("`%s' and ", str1 == NULL ? "NULL" : str1);
- printf ("`%s'.\n", str2 == NULL ? "NULL" : str2);
-
- if ((OK_TO_SEARCH || verbose || internal_error_1 || internal_error_2)
- && !invalid_pattern)
- {
- if (memcmp (old_buf.buffer, nonconst_buf.buffer,
- nonconst_buf.used) != 0
- && !invalid_pattern)
- {
- printf(" (%s)\n", r ? r : "Valid regular expression");
- printf ("\n Compiled pattern before matching: ");
- print_compiled_pattern (&old_buf);
- printf ("\n Compiled pattern after matching: ");
- }
- else
- printf ("\n Compiled pattern: ");
-
- print_compiled_pattern (&nonconst_buf);
- }
-
- if (correct_fastmap && (!nonconst_buf.fastmap_accurate || verbose))
- {
- printf ("\n The fastmap should have been: ");
- print_fastmap (correct_fastmap);
-
- printf ("\n Fastmap: ");
- print_fastmap (fastmap);
-
- printf ("\n Compiled pattern before matching: ");
- print_compiled_pattern (&nonconst_buf);
- }
-
- if ((!all_regs_correct || verbose) && correct_regs)
- {
- unsigned this_reg;
- printf ("\n Incorrect registers:");
-
- for (this_reg = 0; this_reg < regs.num_regs; this_reg++)
- {
- if (!regs_correct[this_reg])
- {
- printf ("\n Register %d's start was %2d. ", this_reg,
- regs.start[this_reg]);
- printf ("\tIt should have been %d.\n",
- correct_regs->start[this_reg]);
- printf (" Register %d's end was %2d. ", this_reg,
- regs.end[this_reg]);
- printf ("\tIt should have been %d.\n",
- correct_regs->end[this_reg]);
- }
- }
- }
- }
- }
-
- if (nonconst_buf.buffer != NULL)
- free (nonconst_buf.buffer);
-
- if (OK_TO_SEARCH)
- {
- free (old_buf.buffer);
-
- if (correct_regs)
- free (regs_correct);
-
- }
-
- nonconst_buf.buffer = old_buf.buffer = NULL;
- regs_correct = NULL;
- regs.start = regs.end = NULL;
-
-} /* general_test */
-
-
-void
-test_search_return (match_start_wanted, pattern, string)
- int match_start_wanted;
- const char *pattern;
- char *string;
-{
- struct re_pattern_buffer buf;
- char fastmap[1 << BYTEWIDTH];
- const char *compile_return;
- int match_start;
- static num_times_called = 0;
-
- num_times_called++;
- buf.allocated = 1;
- buf.buffer = xmalloc (buf.allocated);
-
- assert (pattern != NULL);
- buf.translate = 0;
- compile_return = re_compile_pattern (pattern, strlen (pattern), &buf);
-
- if (compile_return)
- {
- printf ("\n\nInvalid pattern in test_match_start:\n");
- printf ("%s\n", compile_return);
- }
- else
- {
- buf.fastmap = fastmap;
- match_start = re_search (&buf, string, strlen (string),
- 0, strlen (string), 0);
-
- if (match_start != match_start_wanted)
- printf ("\nWanted search to start at %d but started at %d.\n",
- match_start, match_start_wanted);
- }
- free (buf.buffer);
- buf.buffer = NULL;
-}
-
-
-#define SET_FASTMAP() \
- { \
- unsigned this_char; \
- \
- memset (correct_fastmap, invert, (1 << BYTEWIDTH)); \
- \
- for (this_char = 0; this_char < strlen (fastmap_string); this_char++)\
- correct_fastmap[fastmap_string[this_char]] = !invert; \
- correct_fastmap['\n'] = match_newline; \
- }
-
-
-void
-test_fastmap (pat, fastmap_string, invert, match_newline)
- const char *pat;
- char *fastmap_string;
- unsigned invert;
- unsigned match_newline;
-{
- char correct_fastmap[(1 << BYTEWIDTH)];
-
- SET_FASTMAP ();
- general_test (1, 0, pat, NULL, NULL, -1, 0, -1, correct_fastmap, 0, -1);
-}
-
-
-void
-test_fastmap_search (pat, str, fastmap_string, invert, match_newline,
- can_be_null, start0, end0)
- const char *pat;
- char *str;
- char *fastmap_string;
- unsigned invert;
- unsigned match_newline;
- int can_be_null;
- int start0;
- int end0;
-{
- char correct_fastmap[(1 << BYTEWIDTH)];
- struct re_registers correct_regs;
-
- correct_regs.num_regs = RE_NREGS;
- correct_regs.start = (int *) xmalloc (RE_NREGS * sizeof (int));
- correct_regs.end = (int *) xmalloc (RE_NREGS * sizeof (int));
-
- set_all_registers (start0, end0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, &correct_regs);
- SET_FASTMAP ();
- general_test (1, 0, pat, str, NULL, 0, SAFE_STRLEN (str), SAFE_STRLEN (str),
- correct_fastmap, &correct_regs, can_be_null);
-
- free (correct_regs.start);
- free (correct_regs.end);
-}
-
-
-
-
-void
-test_all_registers (pat, str1, str2,
- start0, end0, start1, end1,
- start2, end2, start3, end3,
- start4, end4, start5, end5,
- start6, end6, start7, end7,
- start8, end8, start9, end9)
- char *pat; char *str1; char *str2;
- int start0; int end0; int start1; int end1;
- int start2; int end2; int start3; int end3;
- int start4; int end4; int start5; int end5;
- int start6; int end6; int start7; int end7;
- int start8; int end8; int start9; int end9;
-{
- struct re_registers correct_regs;
-
- if (omit_register_tests) return;
-
- correct_regs.num_regs = RE_NREGS;
- correct_regs.start = (int *) xmalloc (RE_NREGS * sizeof (int));
- correct_regs.end = (int *) xmalloc (RE_NREGS * sizeof (int));
-
- set_all_registers (start0, end0, start1, end1, start2, end2, start3, end3,
- start4, end4, start5, end5, start6, end6, start7, end7,
- start8, end8, start9, end9, &correct_regs);
-
- general_test (1, 0, pat, str1, str2, 0,
- SAFE_STRLEN (str1) + SAFE_STRLEN (str2),
- SAFE_STRLEN (str1) + SAFE_STRLEN (str2),
- NULL, &correct_regs, -1);
-
- free (correct_regs.start);
- free (correct_regs.end);
-}
-
-
-void
-invalid_pattern (error_code_expected, pattern)
- int error_code_expected;
- char *pattern;
-{
- regex_t pattern_buffer;
- int cflags
- = re_syntax_options == RE_SYNTAX_POSIX_EXTENDED
- || re_syntax_options == RE_SYNTAX_POSIX_MINIMAL_EXTENDED
- ? REG_EXTENDED : 0;
-
- test_compile (0, error_code_expected, pattern, &pattern_buffer, cflags);
-}
-
-
-void
-valid_pattern (pattern)
- char *pattern;
-{
- regex_t pattern_buffer;
- int cflags
- = re_syntax_options == RE_SYNTAX_POSIX_EXTENDED
- || re_syntax_options == RE_SYNTAX_POSIX_MINIMAL_EXTENDED
- ? REG_EXTENDED : 0;
-
- test_compile (1, 0, pattern, &pattern_buffer, cflags);
-}
-
-
-char *
-delimiters_to_ops (source, left_delimiter, right_delimiter)
- char *source;
- char left_delimiter;
- char right_delimiter;
-{
- static char *answer = NULL;
- char *tmp = NULL;
- boolean double_size = false;
- unsigned source_char;
- unsigned answer_char = 0;
-
- assert (source != NULL);
-
- switch (left_delimiter)
- {
- case '(': if (!(re_syntax_options & RE_NO_BK_PARENS))
- double_size = true;
- break;
- case '{': if (!(re_syntax_options & RE_NO_BK_BRACES))
- double_size = true;
- break;
- default: printf ("Found strange delimiter %c in delimiter_to_ops.\n",
- left_delimiter);
- printf ("The source was `%s'\n", source);
- exit (0);
- }
-
- if (answer == source)
- {
- tmp = (char *) xmalloc (strlen (source) + 1);
- strcpy (tmp, source);
- source = tmp;
- }
-
- if (answer)
- {
- free (answer);
- answer = NULL;
- }
-
- answer = (char *) xmalloc ((double_size
- ? strlen (source) << 1
- : strlen (source))
- + 1);
- if (!double_size)
- strcpy (answer, source);
- else
- {
- for (source_char = 0; source_char < strlen (source); source_char++)
- {
- if (source[source_char] == left_delimiter
- || source[source_char] == right_delimiter)
- answer[answer_char++] = '\\';
-
- answer[answer_char++] = source[source_char];
- }
- answer[answer_char] = 0;
- }
-
- return answer;
-}
-
-
-void
-print_pattern_info (pattern, pattern_buffer_ptr)
- const char *pattern;
- regex_t *pattern_buffer_ptr;
-{
- printf (" Pattern: `%s'.\n", pattern);
- printf (" Compiled pattern: ");
- print_compiled_pattern (pattern_buffer_ptr);
-}
-
-
-void
-valid_nonposix_pattern (pattern)
- char *pattern;
-{
- struct re_pattern_buffer nonconst_buf;
-
- nonconst_buf.allocated = 0;
- nonconst_buf.buffer = NULL;
- nonconst_buf.translate = NULL;
-
- assert (pattern != NULL);
-
- if (re_compile_pattern (pattern, strlen (pattern), &nonconst_buf))
- {
- printf ("Couldn't compile the pattern.\n");
- print_pattern_info (pattern, &nonconst_buf);
- }
-}
-
-
-void
-compile_and_print_pattern (pattern)
- char *pattern;
-{
- struct re_pattern_buffer nonconst_buf;
-
- nonconst_buf.allocated = 0;
- nonconst_buf.buffer = NULL;
-
- if (re_compile_pattern (pattern, strlen (pattern), &nonconst_buf))
- printf ("Couldn't compile the pattern.\n");
-
- print_pattern_info (pattern, &nonconst_buf);
-}
-
-
-void
-test_case_fold (pattern, string)
- const char *pattern;
- char* string;
-{
- struct re_pattern_buffer nonconst_buf;
- const char *ret;
-
- init_pattern_buffer (&nonconst_buf);
- nonconst_buf.translate = upcase;
-
- assert (pattern != NULL);
- ret = re_compile_pattern (pattern, strlen (pattern), &nonconst_buf);
-
- if (ret)
- {
- printf ("\nShould have been a valid pattern but wasn't.\n");
- print_pattern_info (pattern, &nonconst_buf);
- }
- else
- {
- if (test_should_match
- && re_match (&nonconst_buf, string, strlen (string), 0, 0)
- != strlen (string))
- {
- printf ("Match failed for case fold.\n");
- printf (" Pattern: `%s'.\n", pattern);
- printf (" String: `%s'.\n", string == NULL ? "NULL" : string);
- }
- }
-}
-
-
-void
-test_match_n_times (n, pattern, string)
- unsigned n;
- char* pattern;
- char* string;
-{
- struct re_pattern_buffer buf;
- const char *r;
- unsigned match = 0;
- unsigned this_match;
-
- buf.allocated = 0;
- buf.buffer = NULL;
- buf.translate = 0;
-
- assert (pattern != NULL);
-
- r = re_compile_pattern (pattern, strlen (pattern), &buf);
- if (r)
- {
- printf ("Didn't compile.\n");
- printf (" Pattern: %s.\n", pattern);
- }
- else
- {
- for (this_match = 1; this_match <= n; this_match++)
- match = (re_match (&buf, string, strlen (string),
- 0, 0)
- == strlen (string));
-
- if (match && !test_should_match)
- printf ("\n\nMatched but shouldn't have:\n");
- else if (!match && test_should_match)
- printf ("\n\nDidn't match but should have:\n");
-
- if ((match && !test_should_match) || (!match && test_should_match))
- {
- printf(" The string to match was: ");
- if (string)
- printf ("`%s' and ", string);
- else
- printf ("`'");
-
- printf (" Pattern: %s.\n", pattern);
- printf (" Compiled pattern: %s.\n", pattern);
- print_compiled_pattern (&buf);
- }
- }
-}
-
-
-void
-test_match_2 (pat, str1, str2)
- const char *pat;
- char *str1;
- char *str2;
-{
- general_test (1, 1, pat, str1, str2, 0, 1,
- SAFE_STRLEN (str1) + SAFE_STRLEN (str2), NULL, 0, -1);
-}
-
-void
-test_match (pat, str)
- const char *pat;
- char *str;
-{
- test_match_2 (pat, str, NULL);
- test_match_2 (pat, NULL, str);
-}
diff --git a/gnu/lib/libregex/test/test.h b/gnu/lib/libregex/test/test.h
deleted file mode 100644
index e367c93..0000000
--- a/gnu/lib/libregex/test/test.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* test.h: for Regex testing. */
-
-#ifndef TEST_H
-#define TEST_H
-
-#include <stdio.h>
-#include <assert.h>
-
-#include <sys/types.h>
-#include "regex.h"
-
-
-/* A strlen that works even on a null pointer. */
-#define SAFE_STRLEN(s) (s == NULL ? 0 : strlen (s))
-
-typedef enum { false = 0, true = 1 } boolean;
-
-extern boolean test_should_match;
-extern boolean omit_register_tests;
-extern void *xmalloc ();
-
-/* Defined in upcase.c. */
-extern char upcase[];
-
-typedef enum
-{
- all_test,
- other_test,
- posix_basic_test,
- posix_extended_test,
- posix_interface_test,
- regress_test
-} test_type;
-
-extern test_type t;
-
-
-#if __STDC__
-
-extern char *concat (char *, char *);
-
-extern void general_test (unsigned pattern_should_be_valid,
- unsigned match_whole_string,
- const char *pat, char *str1, char *str2,
- int start, int range, int end,
- char *correct_fastmap,
- struct re_registers *correct_regs, int can_be_null);
-
-
-extern void init_pattern_buffer (regex_t *pattern_buffer_ptr);
-
-extern void test_compile (unsigned valid_pattern, int error_code_expected,
- const char *pattern, regex_t *pattern_buffer_ptr,
- int cflags);
-
-extern char *delimiter_to_ops (char *source, char left_delimiter,
- char right_delimiter);
-
-
-extern void test_search_return (int, const char *, char *);
-
-extern void test_berk_search (const char *pattern, char *string);
-
-extern void test_fastmap (const char *pat, char *fastmap_string, unsigned invert,
- unsigned match_newline);
-
-extern void test_fastmap_search (const char *pat, char *str, char *fastmap_string,
- unsigned invert, unsigned match_newline,
- int can_be_null, int start0, int end0);
-
-extern void test_all_registers (char *pat, char *str1, char *str2,
- int start0, int end0, int start1, int end1,
- int start2, int end2, int start3, int end3,
- int start4, int end4, int start5, int end5,
- int start6, int end6, int start7, int end7,
- int start8, int end8, int start9, int end9);
-
-extern void print_pattern_info (const char *pattern, regex_t *pattern_buffer_ptr);
-extern void compile_and_print_pattern (char *pattern);
-
-extern void test_case_fold (const char *pattern, char* string);
-
-extern void test_posix_generic ();
-
-extern void test_grouping ();
-
-extern void invalid_pattern (int error_code_expected, char *pattern);
-extern void valid_nonposix_pattern (char *pattern);
-extern void valid_pattern (char *pattern);
-
-extern void test_match_2 (const char *pat, char *str1, char *str2);
-extern void test_match (const char *pat, char *str);
-
-#endif /* __STDC__ */
-
-
-#define TEST_REGISTERS_2(pat, str1, str2, start0, end0, start1, end1, start2, end2)\
- if (!omit_register_tests) \
- test_all_registers (pat, str1, str2, start0, end0, start1, end1, \
- start2, end2, -1, -1, -1, -1, -1, -1, -1, -1,\
- -1, -1, -1, -1, -1, -1) \
-
-
-#define TEST_REGISTERS(pat, str, start0, end0, start1, end1, start2, end2) \
- TEST_REGISTERS_2 (pat, str, NULL, start0, end0, start1, end1, start2, end2)\
-
-#define BRACES_TO_OPS(string) ((char *) delimiters_to_ops (string, '{', '}'))
-#define PARENS_TO_OPS(string) ((char *) delimiters_to_ops (string, '(', ')'))
-
-#define INVALID_PATTERN(pat) \
- general_test (0, 0, pat, NULL, NULL, -1, 0, -1, NULL, 0, -1)
-
-
-#define MATCH_SELF(p) test_match (p, p)
-
-#define TEST_POSITIONED_MATCH(pat, str, start) \
- general_test (1, 0, pat, str, NULL, start, 1, SAFE_STRLEN (str), \
- NULL, 0, -1)
-
-#define TEST_TRUNCATED_MATCH(pat, str, end) \
- general_test (1, 0, pat, str, NULL, 0, 1, end, NULL, 0, -1)
-
-#define TEST_SEARCH_2(pat, str1, str2, start, range, one_past_end) \
- general_test (1, 0, pat, str1, str2, start, range, one_past_end, \
- NULL, 0, -1)
-
-#define TEST_SEARCH(pat, str, start, range) \
- { \
- TEST_SEARCH_2 (pat, str, NULL, start, range, SAFE_STRLEN (str)); \
- TEST_SEARCH_2 (pat, NULL, str, start, range, SAFE_STRLEN (str)); \
- }
-
-#endif /* TEST_H */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/lib/libregex/test/tregress.c b/gnu/lib/libregex/test/tregress.c
deleted file mode 100644
index b6aa560..0000000
--- a/gnu/lib/libregex/test/tregress.c
+++ /dev/null
@@ -1,464 +0,0 @@
-/* tregress.c: reported bugs. The `t' just makes the filename not have
- a common prefix with `regex.c', so completion works better. */
-
-#include "test.h"
-
-
-boolean pause_at_error = true;
-
-char *
-itoa (i)
- int i;
-{
- char *a = xmalloc (21); /* sign + 19 digits (enough for 64 bits) + null */
-
- sprintf (a, "%d", i);
- return a;
-}
-
-
-static void
-simple_fail (routine, pat, buf, str, ret)
- const char *routine;
- const char *pat;
- struct re_pattern_buffer *buf;
- const char *str;
- char *ret;
-{
- fprintf (stderr, "Failed %s (return = %s).\n", routine, ret);
- if (str && *str) fprintf (stderr, " String = %s\n", str);
- fprintf (stderr, " Pattern = %s\n", pat);
- print_compiled_pattern (buf);
-
- if (pause_at_error)
- {
- fprintf (stderr, "RET to continue: ");
- (void) getchar ();
- }
-}
-
-
-/* Abbreviate the most common calls. */
-
-static void
-simple_compile (pat, buf)
- const char *pat;
- struct re_pattern_buffer *buf;
-{
- const char *ret = re_compile_pattern (pat, strlen (pat), buf);
-
- if (ret != NULL) simple_fail ("compile", pat, buf, NULL, ret);
-}
-
-
-static void
-simple_fastmap (pat)
- const char *pat;
-{
- struct re_pattern_buffer buf;
- char fastmap[256];
- int ret;
-
- buf.allocated = 0;
- buf.buffer = buf.translate = NULL;
- buf.fastmap = fastmap;
-
- simple_compile (pat, &buf);
-
- ret = re_compile_fastmap (&buf);
-
- if (ret != 0) simple_fail ("fastmap compile", pat, &buf, NULL, itoa (ret));
-}
-
-
-#define SIMPLE_MATCH(pat, str) do_match (pat, str, strlen (str))
-#define SIMPLE_NONMATCH(pat, str) do_match (pat, str, -1)
-
-static void
-do_match (pat, str, expected)
- const char *pat, *str;
- int expected;
-{
- int ret;
- unsigned len;
- struct re_pattern_buffer buf;
-
- buf.allocated = 0;
- buf.buffer = buf.translate = buf.fastmap = NULL;
-
- simple_compile (pat, &buf);
-
- len = strlen (str);
-
- ret = re_match_2 (&buf, NULL, 0, str, len, 0, NULL, len);
-
- if (ret != expected) simple_fail ("match", pat, &buf, str, itoa (ret));
-}
-
-
-static void
-simple_search (pat, str, correct_startpos)
- const char *pat, *str;
- int correct_startpos;
-{
- int ret;
- unsigned len;
- struct re_pattern_buffer buf;
-
- buf.allocated = 0;
- buf.buffer = buf.translate = buf.fastmap = NULL;
-
- simple_compile (pat, &buf);
-
- len = strlen (str);
-
- ret = re_search_2 (&buf, NULL, 0, str, len, 0, len, NULL, len);
-
- if (ret != correct_startpos)
- simple_fail ("match", pat, &buf, str, itoa (ret));
-}
-
-/* Past bugs people have reported. */
-
-void
-test_regress ()
-{
- extern char upcase[];
- struct re_pattern_buffer buf;
- unsigned len;
- struct re_registers regs;
- int ret;
- char *fastmap = xmalloc (256);
-
- buf.translate = NULL;
- buf.fastmap = NULL;
- buf.allocated = 0;
- buf.buffer = NULL;
-
- printf ("\nStarting regression tests.\n");
- t = regress_test;
-
- test_should_match = true;
- re_set_syntax (RE_SYNTAX_EMACS);
-
- /* enami@sys.ptg.sony.co.jp 10 Nov 92 15:19:02 JST */
- buf.translate = upcase;
- SIMPLE_MATCH ("[A-[]", "A");
- buf.translate = NULL;
-
- /* meyering@cs.utexas.edu Nov 6 22:34:41 1992 */
- simple_search ("\\w+", "a", 0);
-
- /* jimb@occs.cs.oberlin.edu 10 Sep 92 00:42:33 */
- buf.translate = upcase;
- SIMPLE_MATCH ("[\001-\377]", "\001");
- SIMPLE_MATCH ("[\001-\377]", "a");
- SIMPLE_MATCH ("[\001-\377]", "\377");
- buf.translate = NULL;
-
- /* mike@skinner.cs.uoregon.edu 1 Sep 92 01:45:22 */
- SIMPLE_MATCH ("^^$", "^");
-
- /* pclink@qld.tne.oz.au Sep 7 22:42:36 1992 */
- re_set_syntax (RE_INTERVALS);
- SIMPLE_MATCH ("^a\\{3\\}$", "aaa");
- SIMPLE_NONMATCH ("^a\\{3\\}$", "aa");
- re_set_syntax (RE_SYNTAX_EMACS);
-
- /* pclink@qld.tne.oz.au, 31 Aug 92. (conjecture) */
- re_set_syntax (RE_INTERVALS);
- simple_search ("a\\{1,3\\}b", "aaab", 0);
- simple_search ("a\\{1,3\\}b", "aaaab", 1);
- re_set_syntax (RE_SYNTAX_EMACS);
-
- /* trq@dionysos.thphys.ox.ac.uk, 31 Aug 92. (simplified) */
- simple_fastmap ("^.*\n[ ]*");
-
- /* wind!greg@plains.NoDak.edu, 25 Aug 92. (simplified) */
- re_set_syntax (RE_INTERVALS);
- SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}", "xN0000");
- SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}$", "systemxN0000");
- SIMPLE_MATCH ("\\([a-zA-Z]*\\).\\{5\\}$", "systemxN0000");
- re_set_syntax (RE_SYNTAX_EMACS);
-
- /* jimb, 18 Aug 92. Don't use \000, so `strlen' (in our testing
- routines) will work. (This still tickles the bug jimb reported.) */
- SIMPLE_MATCH ("[\001-\377]", "\001");
- SIMPLE_MATCH ("[\001-\377]", "a");
- SIMPLE_MATCH ("[\001-\377]", "\377");
-
- /* jimb, 13 Aug 92. */
- SIMPLE_MATCH ("[\001-\177]", "\177");
-
- /* Tests based on bwoelfel's below. */
- SIMPLE_MATCH ("\\(a\\|ab\\)*", "aab");
- SIMPLE_MATCH ("\\(a\\|ab\\)+", "aab");
- SIMPLE_MATCH ("\\(a*\\|ab\\)+", "aab");
- SIMPLE_MATCH ("\\(a+\\|ab\\)+", "aab");
- SIMPLE_MATCH ("\\(a?\\|ab\\)+", "aab");
-
- /* bwoelfel@widget.seas.upenn.edu, 25 Jul 92. */
- SIMPLE_MATCH ("^\\([ab]+\\|bc\\)+", "abc");
-
- /* jla, 3 Jul 92. Core dump in re_search_2. */
- buf.fastmap = fastmap;
- buf.translate = upcase;
-#define DATEDUMP_PATTERN " *[0-9]*:"
- if (re_compile_pattern (DATEDUMP_PATTERN, strlen (DATEDUMP_PATTERN), &buf)
- != NULL)
- printf ("date dump compile failed.\n");
- regs.num_regs = 0;
- regs.start = regs.end = NULL;
- if (re_search_2 (&buf, NULL, 0, "Thu Jul 2 18:34:18 1992",
- 24, 3, 21, &regs, 24) != 10)
- printf ("date dump search failed.\n");
- buf.fastmap = 0;
- buf.translate = 0;
-
-
- /* rms, 4 Jul 1992. Pattern is much slower in Emacs 19. Fastmap
- should be only a backslash. */
-#define BEGINEND_PATTERN "\\(\\\\begin\\s *{\\)\\|\\(\\\\end\\s *{\\)"
- test_fastmap (BEGINEND_PATTERN, "\\", false, 0);
-
-
- /* kaoru@is.s.u-tokyo.ac.jp, 27 Jun 1992. Code for [a-z] (in regex.c)
- should translate the whole set. */
- buf.translate = upcase;
-#define CASE_SET_PATTERN "[ -`]"
- if (re_compile_pattern (CASE_SET_PATTERN, strlen (CASE_SET_PATTERN), &buf)
- != NULL)
- printf ("case set compile failed.\n");
- if (re_match_2 (&buf, "K", 1, "", 0, 0, NULL, 1) != 1)
- printf ("case set match failed.\n");
-
-#define CASE_SET_PATTERN2 "[`-|]"
- if (re_compile_pattern (CASE_SET_PATTERN2, strlen (CASE_SET_PATTERN2), &buf)
- != NULL)
- printf ("case set2 compile failed.\n");
- if (re_match_2 (&buf, "K", 1, "", 0, 0, NULL, 1) != 1)
- printf ("case set2 match failed.\n");
-
- buf.translate = NULL;
-
-
- /* jimb, 27 Jun 92. Problems with gaps in the string. */
-#define GAP_PATTERN "x.*y.*z"
- if (re_compile_pattern (GAP_PATTERN, strlen (GAP_PATTERN), &buf) != NULL)
- printf ("gap didn't compile.\n");
- if (re_match_2 (&buf, "x-", 2, "y-z-", 4, 0, NULL, 6) != 5)
- printf ("gap match failed.\n");
-
-
- /* jimb, 19 Jun 92. Since `beginning of word' matches at the
- beginning of the string, then searching ought to find it there.
- If `re_compile_fastmap' is not called, then it works ok. */
- buf.fastmap = fastmap;
-#define BOW_BEG_PATTERN "\\<"
- if (re_compile_pattern (BOW_BEG_PATTERN, strlen (BOW_BEG_PATTERN), &buf)
- != NULL)
- printf ("begword-begstring didn't compile.\n");
- if (re_search (&buf, "foo", 3, 0, 3, NULL) != 0)
- printf ("begword-begstring search failed.\n");
-
- /* Same bug report, different null-matching pattern. */
-#define EMPTY_ANCHOR_PATTERN "^$"
- if (re_compile_pattern (EMPTY_ANCHOR_PATTERN, strlen (EMPTY_ANCHOR_PATTERN),
- &buf) != NULL)
- printf ("empty anchor didn't compile.\n");
- if (re_search (&buf, "foo\n\nbar", 8, 0, 8, NULL) != 4)
- printf ("empty anchor search failed.\n");
-
- /* jimb@occs.cs.oberlin.edu, 21 Apr 92. After we first allocate
- registers for a particular re_pattern_buffer, we might have to
- reallocate more registers on subsequent calls -- and we should be
- reusing the same memory. */
-#define ALLOC_REG_PATTERN "\\(abc\\)"
- free (buf.fastmap);
- buf.fastmap = 0;
- if (re_compile_pattern (ALLOC_REG_PATTERN, strlen (ALLOC_REG_PATTERN), &buf)
- != NULL)
- printf ("register allocation didn't compile.\n");
- if (re_match (&buf, "abc", 3, 0, &regs) != 3)
- printf ("register allocation didn't match.\n");
- if (regs.start[1] != 0 || regs.end[1] != 3)
- printf ("register allocation reg #1 wrong.\n");
-
- {
- int *old_regstart = regs.start;
- int *old_regend = regs.end;
-
- if (re_match (&buf, "abc", 3, 0, &regs) != 3)
- printf ("register reallocation didn't match.\n");
- if (regs.start[1] != 0 || regs.end[1] != 3
- || old_regstart[1] != 0 || old_regend[1] != 3
- || regs.start != old_regstart || regs.end != old_regend)
- printf ("register reallocation registers wrong.\n");
- }
-
- /* jskudlarek@std.MENTORG.COM, 21 Apr 92 (string-match). */
-#define JSKUD_PATTERN "[^/]+\\(/[^/.]+\\)?/[0-9]+$"
- if (re_compile_pattern (JSKUD_PATTERN, strlen (JSKUD_PATTERN), &buf) != NULL)
- printf ("jskud test didn't compile.\n");
- if (re_search (&buf, "a/1", 3, 0, 3, &regs) != 0)
- printf ("jskud test didn't match.\n");
- if (regs.start[1] != -1 || regs.end[1] != -1)
- printf ("jskud test, reg #1 wrong.\n");
-
- /* jla's bug (with string-match), 5 Feb 92. */
- TEST_SEARCH ("\\`[ \t\n]*", "jla@challenger (Joseph Arceneaux)", 0, 100);
-
- /* jwz@lucid.com, 8 March 1992 (re-search-forward). (His is the
- second.) These are not supposed to match. */
-#if 0
- /* This one fails quickly, because we can change the maybe_pop_jump
- from the + to a pop_failure_pop, because of the c's. */
- TEST_SEARCH ("^\\(To\\|CC\\):\\([^c]*\\)+co",
-"To: hbs%titanic@lucid.com (Harlan Sexton)\n\
-Cc: eb@thalidomide, jlm@thalidomide\n\
-Subject: Re: so is this really as horrible an idea as it seems to me?\n\
-In-Reply-To: Harlan Sexton's message of Sun 8-Mar-92 11:00:06 PST <9203081900.AA24794@titanic.lucid>\n\
-References: <9203080736.AA05869@thalidomide.lucid>\n\
- <9203081900.AA24794@titanic.lucid>", 0, 5000);
-
- /* This one takes a long, long time to complete, because we have to
- keep the failure points around because we might backtrack. */
- TEST_SEARCH ("^\\(To\\|CC\\):\\(.*\n.*\\)+co",
- /* "X-Windows: The joke that kills.\n\
-FCC: /u/jwz/VM/inbox\n\
-From: Jamie Zawinski <jwz@lucid.com>\n\ */
-"To: hbs%titanic@lucid.com (Harlan Sexton)\n\
-Cc: eb@thalidomide, jlm@thalidomide\n\
-Subject: Re: so is this really as horrible an idea as it seems to me?\n\
-In-Reply-To: Harlan Sexton's message of Sun 8-Mar-92 11:00:06 PST <9203081900.AA24794@titanic.lucid>\n\
-References: <9203080736.AA05869@thalidomide.lucid>\n\
- <9203081900.AA24794@titanic.lucid>", 0, 5000);
-#endif /* 0 [failed searches] */
-
-
- /* macrakis' bugs. */
- buf.translate = upcase; /* message of 24 Jan 91 */
- if (re_compile_pattern ("[!-`]", 5, &buf) != NULL)
- printf ("Range test didn't compile.\n");
- if (re_match (&buf, "A", 1, 0, NULL) != 1)
- printf ("Range test #1 didn't match.\n");
- if (re_match (&buf, "a", 1, 0, NULL) != 1)
- printf ("Range test #2 didn't match.\n");
-
- buf.translate = 0;
-#define FAO_PATTERN "\\(f\\(.\\)o\\)+"
- if (re_compile_pattern (FAO_PATTERN, strlen (FAO_PATTERN), &buf) != NULL)
- printf ("faofdx test didn't compile.\n");
- if (re_search (&buf, "faofdx", 6, 0, 6, &regs) != 0)
- printf ("faofdx test didn't match.\n");
- if (regs.start[1] != 0 || regs.end[1] != 3)
- printf ("faofdx test, reg #1 wrong.\n");
- if (regs.start[2] != 1 || regs.end[2] != 2)
- printf ("faofdx test, reg #2 wrong.\n");
-
- TEST_REGISTERS ("\\(a\\)*a", "aaa", 0, 3, 1, 2, -1, -1);
- test_fastmap ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)", " \n", 1, 0);
-
- /* 40 lines, 48 a's in each line. */
- test_match ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)",
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:");
-
- /* 640 a's followed by one b, twice. */
- test_match ("\\(.*\\)\\1", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab");
-
- /* 640 a's followed by two b's, twice. */
- test_match ("\\(.*\\)\\1", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabb");
-
-
- /* Dave G. bug: Reference to a subexpression which didn't match.
- Should fail. */
- re_set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR);
- test_match ("(ooooooooooone())-annnnnnnnnnnd-(twooooooooooo\\2)",
- "ooooooooooone-annnnnnnnnnnd-twooooooooooo");
- test_match ("(o|t)", "o");
- test_match ("(o()|t)", "o");
- test_match ("(o|t)", "o");
- test_match ("(ooooooooooooooo|tttttttttttttttt())", "ooooooooooooooo");
- test_match ("(o|t())", "o");
- test_match ("(o()|t())", "o");
- test_match ("(ooooooooooooooooooooooooone()|twooooooooooooooooooooooooo())", "ooooooooooooooooooooooooone");
- test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-t");
- test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-f");
-
- test_should_match = 0;
- test_match ("(foo(bar)|second)\\2", "second");
- test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-t");
- test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-f");
-
- re_set_syntax (RE_SYNTAX_EMACS);
- test_match ("\\(foo\\(bar\\)\\|second\\)\\2", "secondbar");
- test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
- "one-and-four");
- test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
- "two-and-three");
-
- test_should_match = 1;
- re_set_syntax (RE_SYNTAX_EMACS);
- test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
- "one-and-three");
- test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
- "two-and-four");
-
- TEST_REGISTERS (":\\(.*\\)", ":/", 0, 2, 1, 2, -1, -1);
-
- /* Bug with `upcase' translation table, from Nico Josuttis
- <nico@bredex.de> */
- test_should_match = 1;
- test_case_fold ("[a-a]", "a");
-
- printf ("\nFinished regression tests.\n");
-}
-
-
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/lib/libregex/test/upcase.c b/gnu/lib/libregex/test/upcase.c
deleted file mode 100644
index a3c0fbc..0000000
--- a/gnu/lib/libregex/test/upcase.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Indexed by a character, gives the upper case equivalent of the
- character. */
-
-char upcase[0400] =
- { 000, 001, 002, 003, 004, 005, 006, 007,
- 010, 011, 012, 013, 014, 015, 016, 017,
- 020, 021, 022, 023, 024, 025, 026, 027,
- 030, 031, 032, 033, 034, 035, 036, 037,
- 040, 041, 042, 043, 044, 045, 046, 047,
- 050, 051, 052, 053, 054, 055, 056, 057,
- 060, 061, 062, 063, 064, 065, 066, 067,
- 070, 071, 072, 073, 074, 075, 076, 077,
- 0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107,
- 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,
- 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127,
- 0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137,
- 0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107,
- 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,
- 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127,
- 0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177,
- 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207,
- 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,
- 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227,
- 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237,
- 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247,
- 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257,
- 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,
- 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,
- 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307,
- 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317,
- 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327,
- 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,
- 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,
- 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,
- 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,
- 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377
- };
-
-
diff --git a/gnu/lib/libregex/test/xmalloc.c b/gnu/lib/libregex/test/xmalloc.c
deleted file mode 100644
index aa1c6c4..0000000
--- a/gnu/lib/libregex/test/xmalloc.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <stdio.h>
-extern char *malloc ();
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-void *
-xmalloc (size)
- unsigned size;
-{
- char *new_mem = malloc (size);
-
- if (new_mem == NULL)
- {
- fprintf (stderr, "xmalloc: request for %u bytes failed.\n", size);
- abort ();
- }
-
- return new_mem;
-}
diff --git a/gnu/lib/libstdc++/Makefile b/gnu/lib/libstdc++/Makefile
deleted file mode 100644
index 4507b3d..0000000
--- a/gnu/lib/libstdc++/Makefile
+++ /dev/null
@@ -1,291 +0,0 @@
-#
-# $Id: Makefile,v 1.6 1997/05/06 00:49:35 jdp Exp $
-#
-
-GPPDIR= ${.CURDIR}/../../../contrib/libg++
-
-.PATH: ${GPPDIR}/libstdc++ ${GPPDIR}/libstdc++/stl ${GPPDIR}/libio \
- ${GPPDIR}/libiberty
-
-LIB= stdc++
-SHLIB_MAJOR= 2
-SHLIB_MINOR= 0
-
-CFLAGS+= -I${GPPDIR}/include -I${DESTDIR}/usr/include/g++ -I.
-CXXFLAGS+= -I${GPPDIR}/include -I${GPPDIR}/libio -I${GPPDIR}/libstdc++
-CXXFLAGS+= -fno-implicit-templates
-
-DIR= ${GPPDIR}/libstdc++
-
-HDRS= cassert cctype cerrno cfloat ciso646 climits clocale cmath complex \
- csetjmp csignal cstdarg cstddef cstdio cstdlib cstring ctime \
- cwchar cwctype new stddef string exception stdexcept typeinfo \
- algorithm deque list map queue set stack vector utility functional \
- iterator memory numeric \
- complex.h new.h stl.h
-
-SHDRS= bastring.cc bastring.h cassert.h cctype.h cerrno.h cfloat.h cinst.h \
- ciso646.h climits.h clocale.h cmath.h complex.h complext.cc \
- complext.h csetjmp.h csignal.h cstdarg.h cstddef.h cstdio.h \
- cstdlib.h cstring.h ctime.h cwchar.h cwctype.h dcomplex.h exception.h \
- fcomplex.h ldcomplex.h new.h sinst.h stddef.h stdexcept.h straits.h \
- string.h typeinfo.h
-
-STLHDRS=algo.h algobase.h bool.h bvector.h defalloc.h deque.h faralloc.h \
- fdeque.h flist.h fmap.h fmultmap.h fmultset.h fset.h function.h \
- hdeque.h heap.h hlist.h hmap.h hmultmap.h hmultset.h hset.h \
- hugalloc.h hvector.h iterator.h lbvector.h ldeque.h list.h llist.h \
- lmap.h lmultmap.h lmultset.h lngalloc.h lset.h map.h multimap.h \
- multiset.h neralloc.h nmap.h nmultmap.h nmultset.h nset.h pair.h \
- projectn.h set.h stack.h tempbuf.h tree.h vector.h
-
-SRCS+= newi.cc cstringi.cc stddefi.cc typeinfoi.cc exceptioni.cc \
- stdexcepti.cc cstdlibi.cc cmathi.cc
-
-# stl sources.
-SRCS+= tempbuf.cc tree.cc random.cc
-
-# "standard" C parts of libiberty (strerror is a superset of the libc version)
-SRCS+= insque.c strerror.c
-
-# Headers for iostream
-IHDRS= PlotFile.h SFile.h builtinbuf.h editbuf.h floatio.h fstream.h \
- indstream.h iolibio.h iomanip.h iostdio.h iostream.h iostreamP.h \
- istream.h libio.h libioP.h ostream.h parsestream.h pfstream.h \
- procbuf.h stdiostream.h stream.h streambuf.h strfile.h strstream.h
-
-# C++ parts of iostream
-SRCS+= PlotFile.cc SFile.cc builtinbuf.cc editbuf.cc filebuf.cc fstream.cc \
- indstream.cc ioassign.cc ioextend.cc iomanip.cc iostream.cc \
- isgetline.cc isgetsb.cc isscan.cc osform.cc parsestream.cc \
- pfstream.cc procbuf.cc sbform.cc sbgetline.cc sbscan.cc \
- stdiostream.cc stdstrbufs.cc stdstreams.cc stream.cc streambuf.cc \
- streambuf.cc strstream.cc
-
-# C parts of iostream
-SRCS+= cleanup.c filedoalloc.c fileops.c floatconv.c genops.c iofclose.c \
- iofgetpos.c iofread.c iofscanf.c iofsetpos.c iogetdelim.c iogetline.c \
- ioignore.c iopadn.c iopopen.c ioprims.c ioprintf.c ioseekoff.c \
- ioseekpos.c iostrerror.c ioungetc.c iovfprintf.c iovfscanf.c \
- outfloat.c strops.c
-
-
-
-beforedepend: config.h
-strerror.o: config.h
-CLEANFILES+= config.h
-
-config.h:
- touch config.h
-
-beforeinstall:
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${.CURDIR}/_G_config.h \
- ${HDRS:S;^;${GPPDIR}/libstdc++/;} \
- ${IHDRS:S;^;${GPPDIR}/libio/;} \
- ${STLHDRS:S;^;${GPPDIR}/libstdc++/stl/;} \
- ${DESTDIR}/usr/include/g++
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${SHDRS:S;^;${GPPDIR}/libstdc++/std/;} \
- ${DESTDIR}/usr/include/g++/std
-
-# Lots of special cases
-
-# ======== typeinfoi.o, stdexcepti.o ========
-.for file in typeinfoi stdexcepti
-${file}.o: ${file}.cc
- ${CXX} ${CXXFLAGS} -frtti -c ${DIR}/${file}.cc -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-${file}.so: ${file}.cc
- ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} -frtti -c ${DIR}/${file}.cc -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-${file}.po: ${file}.cc
- ${CXX} -p ${CXXFLAGS} -frtti -c ${DIR}/${file}.cc -o ${.TARGET}
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-.endfor
-
-# ======== exceptioni.o ========
-.for file in exceptioni
-${file}.o: ${file}.cc
- ${CXX} ${CXXFLAGS} -O0 -frtti -fhandle-exceptions -c ${DIR}/${file}.cc -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-${file}.so: ${file}.cc
- ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} -O0 -frtti -fhandle-exceptions -c ${DIR}/${file}.cc -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-${file}.po: ${file}.cc
- ${CXX} -p ${CXXFLAGS} -O0 -frtti -fhandle-exceptions -c ${DIR}/${file}.cc -o ${.TARGET}
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-.endfor
-
-# ======== cstrmain.o ========
-CSTRMAIN= -DC
-.for i in REP MAIN TRAITS ADDSS ADDPS ADDCS ADDSP ADDSC EQSS EQPS EQSP NESS \
- NEPS NESP LTSS LTPS LTSP GTSS GTPS GTSP LESS LEPS LESP GESS GEPS GESP
-CSTRMAIN+= -D${i}
-.endfor
-
-OBJS+= cstrmain.o
-
-cstrmain.o: sinst.cc
- ${CXX} ${CXXFLAGS} ${CSTRMAIN} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-cstrmain.so: sinst.cc
- ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} ${CSTRMAIN} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-cstrmain.po: sinst.cc
- ${CXX} -p ${CXXFLAGS} ${CSTRMAIN} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-
-# ======== cstrio.o ========
-CSTRIO= -DC
-.for i in EXTRACT INSERT GETLINE
-CSTRIO+= -D${i}
-.endfor
-
-OBJS+= cstrio.o
-
-cstrio.o: sinst.cc
- ${CXX} ${CXXFLAGS} ${CSTRIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-cstrio.so: sinst.cc
- ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} ${CSTRIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-cstrio.po: sinst.cc
- ${CXX} -p ${CXXFLAGS} ${CSTRIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-
-# ======== fcomplex.o =======
-FCOMPLEX= -DF
-.for i in MAIN ADDCC ADDCF ADDFC SUBCC SUBCF SUBFC MULCC MULCF MULFC DIVCC \
- DIVCF DIVFC PLUS MINUS EQCC EQCF EQFC NECC NECF NEFC ABS ARG POLAR \
- CONJ NORM COS COSH EXP LOG POWCC POWCF POWCI POWFC SIN SINH SQRT
-FCOMPLEX+= -D${i}
-.endfor
-
-OBJS+= fcomplex.o
-
-fcomplex.o: cinst.cc
- ${CXX} ${CXXFLAGS} ${FCOMPLEX} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-fcomplex.so: cinst.cc
- ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} ${FCOMPLEX} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-fcomplex.po: cinst.cc
- ${CXX} -p ${CXXFLAGS} ${FCOMPLEX} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-
-# ======== fcomio.o =======
-FCOMIO= -DF
-.for i in EXTRACT INSERT
-FCOMIO+=-D${i}
-.endfor
-
-OBJS+= fcomio.o
-
-fcomio.o: cinst.cc
- ${CXX} ${CXXFLAGS} ${FCOMIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-fcomio.so: cinst.cc
- ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} ${FCOMIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-fcomio.po: cinst.cc
- ${CXX} -p ${CXXFLAGS} ${FCOMIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-
-# ======== dcomplex.o =======
-DCOMPLEX= -DD
-.for i in MAIN ADDCC ADDCF ADDFC SUBCC SUBCF SUBFC MULCC MULCF MULFC DIVCC \
- DIVCF DIVFC PLUS MINUS EQCC EQCF EQFC NECC NECF NEFC ABS ARG POLAR \
- CONJ NORM COS COSH EXP LOG POWCC POWCF POWCI POWFC SIN SINH SQRT
-DCOMPLEX+= -D${i}
-.endfor
-
-OBJS+= dcomplex.o
-
-dcomplex.o: cinst.cc
- ${CXX} ${CXXFLAGS} ${DCOMPLEX} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-dcomplex.so: cinst.cc
- ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} ${DCOMPLEX} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-dcomplex.po: cinst.cc
- ${CXX} -p ${CXXFLAGS} ${DCOMPLEX} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-
-# ======== dcomio.o =======
-DCOMIO= -DD
-.for i in EXTRACT INSERT
-DCOMIO+=-D${i}
-.endfor
-
-OBJS+= dcomio.o
-
-dcomio.o: cinst.cc
- ${CXX} ${CXXFLAGS} ${DCOMIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-dcomio.so: cinst.cc
- ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} ${DCOMIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-dcomio.po: cinst.cc
- ${CXX} -p ${CXXFLAGS} ${DCOMIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-
-# ======== ldcomplex.o =======
-LDCOMPLEX= -DLD
-.for i in MAIN ADDCC ADDCF ADDFC SUBCC SUBCF SUBFC MULCC MULCF MULFC DIVCC \
- DIVCF DIVFC PLUS MINUS EQCC EQCF EQFC NECC NECF NEFC ABS ARG POLAR \
- CONJ NORM COS COSH EXP LOG POWCC POWCF POWCI POWFC SIN SINH SQRT
-LDCOMPLEX+= -D${i}
-.endfor
-
-OBJS+= ldcomplex.o
-
-ldcomplex.o: cinst.cc
- ${CXX} ${CXXFLAGS} ${LDCOMPLEX} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-ldcomplex.so: cinst.cc
- ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} ${LDCOMPLEX} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-ldcomplex.po: cinst.cc
- ${CXX} -p ${CXXFLAGS} ${LDCOMPLEX} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-
-# ======== ldcomio.o =======
-LDCOMIO= -DLD
-.for i in EXTRACT INSERT
-LDCOMIO+=-D${i}
-.endfor
-
-OBJS+= ldcomio.o
-
-ldcomio.o: cinst.cc
- ${CXX} ${CXXFLAGS} ${LDCOMIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-ldcomio.so: cinst.cc
- ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} ${LDCOMIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-ldcomio.po: cinst.cc
- ${CXX} -p ${CXXFLAGS} ${LDCOMIO} -c ${.ALLSRC} -o ${.TARGET}
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-
-.include <bsd.lib.mk>
diff --git a/gnu/lib/libstdc++/_G_config.h b/gnu/lib/libstdc++/_G_config.h
deleted file mode 100644
index c12cbef..0000000
--- a/gnu/lib/libstdc++/_G_config.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* XXX _G_VTABLE_LABLE_PREFIX is different between ELF and a.out */
-
-/* AUTOMATICALLY GENERATED; DO NOT EDIT! */
-#ifndef _G_config_h
-#define _G_config_h
-#define _G_LIB_VERSION "2.7.2"
-#define _G_NAMES_HAVE_UNDERSCORE 1
-#define _G_VTABLE_LABEL_HAS_LENGTH 1
-#ifdef __ELF__
-#define _G_VTABLE_LABEL_PREFIX "_vt."
-#else
-#define _G_VTABLE_LABEL_PREFIX "__vt$"
-#endif
-#define _G_HAVE_ST_BLKSIZE 1
-typedef unsigned long _G_clock_t;
-typedef unsigned int _G_dev_t;
-typedef long long _G_fpos_t;
-typedef unsigned int _G_gid_t;
-typedef unsigned int _G_ino_t;
-typedef unsigned short _G_mode_t;
-typedef unsigned short _G_nlink_t;
-typedef long long _G_off_t;
-typedef int _G_pid_t;
-#ifndef __PTRDIFF_TYPE__
-#define __PTRDIFF_TYPE__ int
-#endif
-typedef __PTRDIFF_TYPE__ _G_ptrdiff_t;
-typedef unsigned int _G_sigset_t;
-#ifndef __SIZE_TYPE__
-#define __SIZE_TYPE__ unsigned int
-#endif
-typedef __SIZE_TYPE__ _G_size_t;
-typedef long _G_time_t;
-typedef unsigned int _G_uid_t;
-typedef int _G_wchar_t;
-typedef int _G_ssize_t;
-typedef int /* default */ _G_wint_t;
-typedef char * _G_va_list;
-#define _G_signal_return_type void
-#define _G_sprintf_return_type int
-
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
-typedef int _G_int8_t __attribute__((__mode__(__QI__)));
-typedef unsigned int _G_uint8_t __attribute__((__mode__(__QI__)));
-typedef int _G_int16_t __attribute__((__mode__(__HI__)));
-typedef unsigned int _G_uint16_t __attribute__((__mode__(__HI__)));
-typedef int _G_int32_t __attribute__((__mode__(__SI__)));
-typedef unsigned int _G_uint32_t __attribute__((__mode__(__SI__)));
-typedef int _G_int64_t __attribute__((__mode__(__DI__)));
-typedef unsigned int _G_uint64_t __attribute__((__mode__(__DI__)));
-#else
-typedef short _G_int16_t;
-typedef unsigned short _G_uint16_t;
-typedef int _G_int32_t;
-typedef unsigned int _G_uint32_t;
-#endif
-
-#define _G_BUFSIZ 1024
-#define _G_FOPEN_MAX 20
-#define _G_FILENAME_MAX 1024
-#define _G_NULL 0 /* default */
-#if defined (__cplusplus) || defined (__STDC__)
-#define _G_ARGS(ARGLIST) ARGLIST
-#else
-#define _G_ARGS(ARGLIST) ()
-#endif
-#if !defined (__GNUG__) || defined (__STRICT_ANSI__)
-#define _G_NO_NRV
-#endif
-#if !defined (__GNUG__)
-#define _G_NO_EXTERN_TEMPLATES
-#endif
-#define _G_HAVE_ATEXIT 1
-#define _G_HAVE_SYS_RESOURCE 1
-#define _G_HAVE_SYS_TIMES 1
-#define _G_HAVE_SYS_SOCKET 1
-#define _G_HAVE_SYS_CDEFS 1
-#define _G_HAVE_SYS_WAIT 1
-#define _G_HAVE_UNISTD 1
-#define _G_HAVE_DIRENT 1
-#define _G_HAVE_CURSES 1
-#define _G_MATH_H_INLINES 0
-#define _G_HAVE_BOOL 1
-#endif /* !_G_config_h */
diff --git a/gnu/libexec/Makefile b/gnu/libexec/Makefile
deleted file mode 100644
index f90dec2..0000000
--- a/gnu/libexec/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $Id$
-
-SUBDIR= uucp
-
-.include <bsd.subdir.mk>
diff --git a/gnu/libexec/Makefile.inc b/gnu/libexec/Makefile.inc
deleted file mode 100644
index 1ac3dc7..0000000
--- a/gnu/libexec/Makefile.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-# $Id$
-
-BINDIR?= /usr/libexec
diff --git a/gnu/libexec/uucp/COPYING b/gnu/libexec/uucp/COPYING
deleted file mode 100644
index e77696a..0000000
--- a/gnu/libexec/uucp/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/libexec/uucp/ChangeLog b/gnu/libexec/uucp/ChangeLog
deleted file mode 100644
index 9f948fb..0000000
--- a/gnu/libexec/uucp/ChangeLog
+++ /dev/null
@@ -1,5070 +0,0 @@
-Sun Aug 20 15:12:36 1995 Ian Lance Taylor <ian@airs.com>
-
- * Released version 1.06.1.
-
- * uux.c (main): Make sure that the grade is between '0' and '9',
- or 'a' and 'z', or 'A' and 'Z', in case isalnum accepts other
- characters.
- * uucp.c (main): Likewise.
-
-Sat Aug 19 23:15:21 1995 Ian Lance Taylor <ian@airs.com>
-
- * configure.in: Check for seteuid.
- * configure: Rebuild.
- * config.h.in (HAVE_SETEUID): Define.
- * unix/uid.c: If HAVE_SETEUID is defined, use seteuid rather than
- setuid.
- * policy.h: Change HAVE_BROKEN_SETREUID comment to mention that it
- does not work on 4.4BSD-Lite and NetBSD.
-
- * Andrey A. Chernov: uuconf.h (UUCONF_GRADE_LEGAL): Use BUCHAR.
-
-Wed Aug 16 21:23:39 1995 Ian Lance Taylor <ian@airs.com>
-
- * uucico.c (flogin_prompt): Add pzsystem parameter, and pass it to
- faccept_call. Change all callers.
-
- * trans.c (qtransalc): Clear zlog field.
-
- * Makefile.in (VERSION): Change to 1.06.1.
-
-Thu Aug 10 22:42:53 1995 Ian Lance Taylor <ian@airs.com>
-
- * Released version 1.06.
-
- * uuconf/tsinfo.c (_uuconf_itaylor_system_internal): Don't set
- uuconf_fcall merely because uuconf_qtimegrade is not set. Check
- values against _uuconf_unset, not NULL.
-
- * trans.c (fgot_data): Only log when data comes in if fsendfile is
- FALSE.
-
-Wed Aug 9 20:52:29 1995 Ian Lance Taylor <ian@airs.com>
-
- * Makefile.in (VERSION): Change to 1.06.
-
-Tue Aug 1 20:13:36 1995 Ian Lance Taylor <ian@airs.com>
-
- * uuconf/tsinfo.c (_uuconf_itaylor_system_internal): Set the fcall
- field for the first alternate if it has some way of selecting a
- port.
-
- * Ard van Breemen: unix/serial.c (fsserial_hardflow): Add support
- for NCR Tower using IRTS.
-
- * policy.h (FSYNC_ON_CLOSE): Define.
- * system.h (fsysdep_sync): Declare.
- * uucp.h (fstdiosync): Define, twice.
- * unix/sync.c: New file.
- * copy.c (fcopy_open_file): Call fsysdep_sync.
- * cu.c (icutake): Likewise.
- * rec.c (frec_file_end): Likewise.
- (frec_file_end): Call fstdiosync.
- * uucp.c (uccopy): Likewise.
- * uux.c (main): Likewise.
- (uxadd_send_file): Likewise.
- * unix/splcmd.c (zsysdep_spool_commands): Likewise.
- * unix/Makefile.in (OBJS): Add sync.o.
- (sync.o): New target.
-
- * Peter Wemm: unix/filnam.c (fscmd_seq): Increase the delay each
- time an attempt to lock LCK..SEQ fails.
-
- * Peter Wemm: uustat.c (fsnotify): Escape a leading "From " when
- including standard input in a mail message.
-
-Mon Jul 31 22:45:23 1995 Ian Lance Taylor <ian@airs.com>
-
- * unix/serial.c (fsserial_lockfile): In the HAVE_SVR4_LOCKFILES
- case, increase the space allocated to print the major and minor
- numbers.
-
-Sun Jul 30 22:30:51 1995 Ian Lance Taylor <ian@airs.com>
-
- * trans.c (fgot_data): Log a message as soon as anything comes in,
- not just for file data.
-
- * prote.c (feprocess_data): Handle a zero length file.
-
-Wed Jul 19 00:14:46 1995 Ian Lance Taylor <ian@airs.com>
-
- * unix/xqtfil.c (fSone_dir): New static variable.
- (fsysdep_get_xqt_init): Add zsystem argument.
- (zsysdep_get_xqt): Likewise.
- (usysdep_get_xqt_free): Likewise.
- * system.h (fsysdep_get_xqt_init): Update declaration.
- (zsysdep_get_xqt): Likewise.
- (usysdep_get_xqt_free): Likewise.
- * uuxqt.c (main): Pass zdosys for system to get_xqt routines.
- * uustat.c (fsexecutions): Pass NULL for system to get_xqt
- routines.
- (fsquery): Likewise.
-
- * uux.c (main): If we are not starting uucico, and we queued a
- local execution, start uuxqt.
-
-Tue Jul 18 22:33:08 1995 Ian Lance Taylor <ian@airs.com>
-
- * uuxqt.c (REMOVE_QINPUT): Define.
- (uqdo_xqt_file): Set REMOVE_QINPUT if zQinput is in the spool
- directory.
- (isave_files): If REMOVE_QINPUT is set, save the input file.
- (uqcleanup): If REMOVE_QINPUT and REMOVE_NEEDED are set, remove
- the input file.
-
-Mon Jul 17 20:59:20 1995 Ian Lance Taylor <ian@airs.com>
-
- * uuchk.c (ukshow): Add missing \n.
-
-Sun Jul 16 12:02:03 1995 Ian Lance Taylor <ian@airs.com>
-
- * Makefile.in (TEXI2HTML): Define.
- (doc-dist): Depend upon uucp.html; put HTML files in documentation
- distribution.
- (html, uucp.html): New targets.
-
-Mon Jul 10 20:24:48 1995 Ian Lance Taylor <ian@airs.com>
-
- * unix/lcksys.c: Rewrite to not truncate the system name in the
- lock file name, unless HAVE_LONG_FILE_NAMES is 0.
-
-Sat Jul 8 13:41:26 1995 Ian Lance Taylor <ian@airs.com>
-
- * Andrey A. Chernov: cu.c (ucuhelp): Mention -E.
- (fcudo_cmd): Use BUCHAR rather than casting to unsigned int.
- (icuunrecogvar): Likewise.
- (uculist_vars): Likewise.
- (icuunrecogfn): Likewise.
- * lib/getopt.c (_getopt_internal): Likewise.
-
- * Andrey A. Chernov: Makefile.in (infodir): Changed commented out
- setting from share/doc to share/info.
-
- * Godfrey van der Linden: unix/serial.c (fsysdep_conn_io): Base
- select or alarm timeout on connection speed.
-
- * configure.in: Move AC_PREFIX_PROGRAM before AC_PROG_CC.
- * configure: Rebuild.
-
- * policy.h (HAVE_BROKEN_SETLKW): Add new define.
- * unix/filnam.c (USE_POSIX_LOCKS): Don't set if HAVE_BROKEN_SETLKW
- is set.
- (fscmd_seq): If the F_SETLKW call returns EINVAL, revert to using
- lock files.
-
- * unix/spawn.c (ixsspawn): If setreuid is available, use it,
- rather than setuid, to set the real user ID to the effective user
- ID.
-
- * Thomas Mechtersheimer: uuchk.c (main): Correct typo (iret for
- iint).
-
- * Bob Thrush: unix/serial.c (fsserial_hardflow): Correct typo
- (c_cflags for c_cflag).
-
- * configure.in: Check for sys/statvfs.h. Check for memset,
- memcmp, and memcpy with the correct argument types (apparently
- some systems require this).
- * config.h.in (HAVE_SYS_STATVFS_H): Define.
- * configure: Rebuild.
-
-Mon Jul 3 00:26:50 1995 Ian Lance Taylor <ian@airs.com>
-
- * Released version beta 1.06.
-
-Sun Jul 2 10:39:40 1995 Ian Lance Taylor <ian@airs.com>
-
- * configure.in: Add AC_OUTPUT code to touch stamp-h when
- rebuilding config.h.
- * Makefile.in (stamp-h): Remove ``echo > stamp-h''.
-
- * Makefile.in (dist): Fix for srcdir != objdir.
- * unix/Makefile.in (dist): Likewise.
- * uuconf/Makefile.in (dist): Likewise.
- * lib/Makefile.in (dist): Likewise.
-
-Sat Jul 1 13:42:35 1995 Ian Lance Taylor <ian@airs.com>
-
- * configure.in: Check for termios.h.
- * config.h.in (HAVE_TERMIOS_H): Mention.
- * policy.h: Set HAVE_POSIX_TERMIOS if HAVE_TERMIOS_H.
-
-Fri Jun 30 09:24:13 1995 Ian Lance Taylor <ian@airs.com>
-
- * uux.c (zXxqt_name): Remove.
- (fXxqtlocal): New static variable; replaces local fxqtlocal.
- (sXxqtsys): New static variable; replaces local sxqtsys.
- (zXxqtloc): New static variable; replaces local zxqtloc.
- (bXgrade): New static variable; replaces local bgrade.
- (abXxqt_tname): New static variable; replaces local abxqt_tname.
- (abXxqt_xname): New static variable; replaces local abxqt_xname.
- (main): Use new static variables instead of locals. Don't set
- zXxqt_name.
- (uxadd_xqt_line): Get file name here before opening file.
- (uxadd_send_file): Remove parameters qxqtsys, zxqtloc, and bgrade.
- Change all callers.
-
- * unix/filnam.c (usput62): New static function.
- (zscmd_file): When SPOOLDIR_TAYLOR, use a different algorithm
- which does not read the sequence file.
- * unix/splcmd.c (zsysdep_spool_commands): Return value of
- zscmd_file might already exist; handle that case.
- * unix/jobid.c (zsfile_to_jobid): Change jobid format when
- SPOOLDIR_TAYLOR, since sequence number is now much longer.
- (zsjobid_to_file): Corresponding change.
- * unix/work.c (fswork_file): When SPOOLDIR_TAYLOR, don't require
- the the file name to be 7 characters long.
- (bsgrade): Change algorithm used when SPOOLDIR_TAYLOR.
-
- * uustat.c (fsworkfile_show): Correct kill prompt to put program
- name at start of line. Add trailing space after question mark.
- (fsexecutions): Likewise.
-
- * unix/work.c (fsysdep_get_work): Don't call fsysdep_get_work_init
- if no more jobs are found.
-
-Thu Jun 29 15:27:31 1995 Ian Lance Taylor <ian@airs.com>
-
- * fsusg.c: Update with changes from fileutils 3.12.
- * configure.in: Update filesystem space tests to fileutils 3.12.
- * config.h.in: Corresponding changes.
-
- * unix/filnam.c (fscmd_seq): If F_SETLKW fails with ENOMEM,
- ENOSPC, or ENOLCK, sleep and try again.
-
- * Makefile.in (MORECFLAGS): Remove unused SBINDIR definition.
- * unix/Makefile.in (run.o): Add dependency on Makefile and
- ../Makefile, so that it is rebuilt if sbindir changes.
- * uuconf/Makefile.in (callin.o): Add dependency on Makefile and
- ../Makefile, so that it is rebuilt if NEWCONFIGLIB or OLDCONFIGLIB
- change.
- (hinit.o, hrmunk.o, maxuxq.o, rdperm.o, tinit.o): Likewise.
- (vinit.o): Likewise.
-
- * cu.c (main, ucuhelp): Update copyright.
- * tstuu.c (main): Likewise.
- * uuchk.c (main, ukhelp): Likewise.
- * uucico.c (main, uhelp): Likewise.
- * uuconv.c (main, uvhelp): Likewise.
- * uucp.c (main, uchelp): Likewise.
- * uulog.c (main, ulhelp): Likewise.
- * uuname.c (main, unhelp): Likewise.
- * uupick.c (main, uphelp): Likewise.
- * uustat.c (main, ushelp): Likewise.
- * uux.c (main, uxhelp): Likewise.
- * uuxqt.c (main, uqhelp): Likewise.
-
- * Makefile.in (VERSION): Update to beta1.06.
-
-Wed Jun 28 10:36:35 1995 Ian Lance Taylor <ian@airs.com>
-
- * trans.c (struct scharge, sTsend, sTreceive): Remove.
- (qTtiming_rec, iTrecsecs, iTrecmicros): New static variables.
- (fqueue_receive): If adding something to an empty receive queue,
- update iTrecsecs and iTrecmicros.
- (utransfree): Remove references to sTsend and sTreceive. If
- freeing qTtiming_rec, clear it.
- (ftcharge): Remove. Remove all calls to it.
- (fttime): New static function.
- (uclear_queue): Clear qTtiming_rec.
- (floop): Add timing code to replace ftcharge.
- (fgot_data): Likewise.
- (ftadd_cmd): Set s.bcmd to 'H' for a hangup request, for better
- debugging information.
- (ufailed): Remove setting of iTchecktime and calls to ftcharge.
-
- * uuconf.h (UUCONF_STRIP_LOGIN): Define.
- (UUCONF_STRIP_PROTO): Define.
- (uuconf_strip): Declare.
- * uuconf/strip.c: New file, definining uuconf_strip.
- * uuconf/Makefile.in (OBJS): Add strip.o.
- * uuconf/uucnfi.h (struct sprocess): Add new fields fstrip_login
- and fstrip_proto.
- * uuconf/iniglb.c (_uuconf_iinit_global): Initialize new fields.
- * uuconf/tinit.c (asCmds): Add "strip-login" and "strip-proto".
- * uucico.c (fdo_call): Check whether protocol commands should be
- stripped, and pass information to zget_uucp_cmd.
- (faccept_call): Likewise.
- (flogin_prompt): Check whether login commands should be stripped,
- and pass information to zget_typed_line.
- (zget_uucp_cmd): Add fstrip argument, and use it to control
- whether incoming characters are stripped.
- (zget_typed_line): Likewise.
- * uuchk.c (main): Report uuconf_strip information.
-
-Mon Jun 26 17:57:14 1995 Ian Lance Taylor <ian@airs.com>
-
- * uuchk.c (main): Report global configuration information.
-
- * uux.c (main): If an attempt is made to execute an empty command,
- just create a poll file instead.
-
- * uupick.c (main): Mention 'd' as a possible command.
-
-Wed Jun 21 16:16:13 1995 Ian Lance Taylor <ian@airs.com>
-
- * unix/filnam.c (fscmd_seq): If available, use POSIX style locking
- for the sequence file. Use IPRIVATE_FILE_MODE when creating the
- sequene file.
-
- * copy.c (fcopy_file): Add fsignals argument, and pass it to
- fcopy_open_file. Update all callers.
- (fcopy_open_file): Add fsignals argument; if TRUE, check for
- signals while copying the file. Update all callers.
- * uudefs.h (fcopy_file, fcopy_open_file): Update prototypes.
-
-Thu Jun 15 20:34:00 1995 Ian Lance Taylor <ian@airs.com>
-
- * Rob Janssen: getopt.h: Don't fail if P is not defined because
- this file got included by something other than uucp.h.
-
-Tue Jun 6 13:17:14 1995 Ian Lance Taylor <ian@airs.com>
-
- * log.c (ulog): Always open the log file even if zmsg is NULL.
- * unix/detach.c (usysdep_detach): Call ulog with NULL before
- closing stderr.
-
- * log.c (ulog): Print file name correctly under HDB_LOGGING if an
- error occurs.
-
- * Andrey A. Chernov: uucp.h: Use off_t rather than long when
- casting arguments to lseek.
-
- * proti.c (IMAXPACKSIZE): Subtract one.
- (fijstart): Correct iIforced_remote_packsize check.
-
- * unix/filnam.c (zsfile_name): Only use remote system name in
- local filename for SPOOLDIR_SVR4, not for SPOOLDIR_HDB.
-
- * Peter da Silva: cu.c (asCulongopts): Add "escape".
- (main): Handle -E/--escape.
- * cu.1: Document -E/--escape.
- * unix/cusub.c (fsysdep_cu): Don't treat \0 as an escape
- character.
-
- * Takatoshi Ikeda: log.c (ustats): Base 'M' vs. 'S' in HDB_LOGGING
- on fcaller, not on fmaster.
- (zldate_and_time): In HDB_LOGGING, don't zero fill the hour.
- * uudefs.h (ustats): Change argument name in prototype.
- * send.c (fsend_await_confirm): Pass fcaller rather than fmaster
- to ustats.
- * rec.c (frec_file_end): Likewise.
- * trans.c (ufailed): Likewise.
-
- * unix/tcp.c: Include <arpa/inet.h>.
- (ftcp_dial): If gethostbyname fails, try inet_addr.
-
- * Jim Brownfield: unix/detach.c (usysdep_detach): Call TIOCNOTTY
- on /dev/tty, not on file descriptor 0.
-
- * uuchk.c (ukshow): If the system will never be called, say so
- explicitly.
-
- * unix/pause.c (usysdep_pause): When using poll, clear the sdummy
- structure before passing it down.
-
- * unix/bytfre.c (csysdep_bytes_free): Check for overflow.
-
- * C.A. Lademann: cu.c (asCulongopts): Add "nostop".
- (main): Handle --nostop.
- (ucuhelp): Mention --nostop.
- * cu.1: Document --nostop.
-
- * Dean Edmonds: cu.c (fcuset_var): Copy string before calling
- uuconf_cmd_args, and handle UUCONF_CMDTABRET_KEEP correctly.
-
- * Jorge Cwik: Add support for 'y' protocol.
- * proty.c: New file, written by Jorge Cwik.
- * prot.h: Declare 'y' protocol functions.
- * uucico.c (asProtocols): Add entry for 'y' protocol.
- * Makefile.in (UUOBJS): Add proty.o.
- (ALLOBJS): Add proty.o.
- (proty.o): New target.
-
-Mon Jun 5 12:05:22 1995 Ian Lance Taylor <ian@airs.com>
-
- * cu.c (main): Don't clobber user specified ibaud when a specific
- system is being called.
-
- * unix/serial.c (fsysdep_stdin_init): chmod /dev/tty to 0600 to
- prevent other users from writing to it.
-
- * uux.c (main): If the argument is quoted by parentheses, don't
- break it at shell separator characters.
-
- * protg.c (fgprocess_data): Don't treat a duplicate RR as an RJ if
- we are retransmitting packets. Corrects change of May 15, 1993.
-
- * unix/lock.c (fsdo_lock): Log an error message if the LOCKFILES
- define appears to not match the contents of the lock file.
-
-Sun Jun 4 14:25:43 1995 Ian Lance Taylor <ian@airs.com>
-
- * Makefile.in (uucp.info): Use explicit $(srcdir) rather than $<.
- (uucp.dvi): Likewise.
- (uucp.ps): Use uucp.dvi rather than $<.
-
- * Scott Guthridge: cu.c (icutake): Skip \r characters unless
- fCuvar_binary is set.
-
- * unix/status.c (fsysdep_get_status): Ignore double quotes around
- description string in status file.
- (fsysdep_set_status): If SPOOLDIR_SVR4, put double quotes around
- description string.
-
- * uustat.c (fsxqt_file_read): Change second argument from file
- name to open file.
- (fsworkfile_show): Make sure execution file can be opened before
- displaying information in execution file format.
- (fsexecutions): Open file before passing it to fsxqt_file_read.
-
- * uucp.h (ffileioerror): Rename from ffilereaderror.
- * cu.c (icuput): Corresponding change.
- * trans.c (floop): Likewise.
- (fgot_data): Use ffileioerror to decide whether to print message
- using errno.
-
- * uuconv.c (uvwrite_taylor_port): Fix handling of dialer-sequence
- for a modem port to actually print ``dialer-sequence''.
-
- * uuconf/hsinfo.c (_uuconf_ihdb_system_internal): Treat a syntax
- error in the time field as equivalent to ``never''.
- * uuconf/vsinfo.c (_uuconf_iv2_system_internal): Likewise.
-
- * uuchk.c (ukshow): Print max-retries information.
-
- * Don Phillips: Add support for new called-timegrade command.
- * uuconf.h (struct uuconf_system): Add uuconf_qcalledtimegrade
- field.
- * uuconf/tsinfo.c (asIcmds): Add "called-timegrade".
- * uuconf/syssub.c (SYSTEM_TIMESPANS): Add uuconf_qcalledtimegrade.
- * trans.c (fqueue): Check uuconf_qcalledtimegrade.
- * uuchk.c (ukshow): Print called-timegrade and success-wait
- information.
- * uuconv.c (uvwrite_taylor_system): Handled called-timegrade.
-
- * unix/xqtsub.c (fsysdep_lock_uuxqt_dir): Accept EISDIR.
-
- * Damon: unix/mkdirs.c (fsysdep_make_dirs): Accept EROFS.
-
-Sat May 27 09:55:38 1995 Ian Lance Taylor <ian@airs.com>
-
- * unix/detach.c (usysdep_detach): Mention routine name in
- debugging message.
-
- * tstuu.c (main): Exit with an error message if not compiled with
- HAVE_TAYLOR_CONFIG.
-
- * Jim Avera: Makefile.in (install-info): Get the info files from
- the source directory if they aren't in the object directory.
-
- * uuchk.c (main): Accept -s to only print information for a
- specific system.
- (asKlongopts): Add --system as a synonym for -s.
- (ukusage): Mention -s.
- (ukhelp): Likewise.
-
- * Makefile.in (uuconf/libuuconf.a): Depend upon config.h.
- (unix/libunix.a, lib/libuucp.a): Likewise.
-
- * Matthias Urlichs and Olaf Kirch: If an execution fails, save the
- files.
- * sysh.unx (FAILEDDIR): Define.
- * system.h (zsysdep_save_failed_file): Declare.
- * uuxqt.c (uqdo_xqt_file): Call isave_files if an execution fails.
- Move the execution files out of the execution directory on any
- failure, not just a temporary one.
- (isave_files): New function; pass all the execution files to
- zsysdep_save_failed_file, and send mail to OWNER.
- * unix/failed.c: New file.
- * unix/Makefile.in (OBJS): Add failed.o.
- (failed.o): New target.
-
- * Johannes Stille: Remove various race conditions, as follows:
- * rec.c (flocal_rec_send_request): Don't free qtrans if pfsendcmd
- fails.
- (fremote_send_reply): Likewise.
- (fremote_send_fail_send): Move pfsendcmd call to the end of the
- routine, after everything else has been done.
- (frec_file_send_confirm): Likewise.
- * send.c (struct ssendinfo): Add new fields fnever and zconfirm.
- (flocal_send_fail): Remove first argument; change all callers.
- (usfree_send): Free new zconfirm field.
- (flocal_send_file_init): Initialize new zconfirm field.
- (fremote_rec_file_init): Likewise.
- (flocal_send_request): Free qtrans explicitly, rather than
- expecting flocal_send_fail to do it.
- (flocal_send_request): Don't free qtrans if pfsendcmd fails.
- (flocal_send_await_reply): Use new fnever field rather than
- overloading fsent.
- (flocal_send_cancelled): Likewise.
- (flocal_send_await_reply): Set fcmd field to TRUE.
- (fremote_rec_reply): Set fcmd field to TRUE. Set qtrans->zlog
- before calling pfsendcmd. Don't free qtrans if pfsendcmd fails.
- (fremote_rec_fail_send): Move pfsendcmd call to the end of the
- routine, after everything else has been done.
- (fsend_file_end): If zconfirm is set, call fsend_await_confirm.
- Don't bother to set fcmd here.
- (fsend_await_confirm): If fsent is not set, just save command in
- zconfirm and return.
- (fsend_exec_file_init): Free and clear new zconfirm field.
- * xcmd.c (flocal_xcmd_request): Don't free qtrans if pfsendcmd
- fails.
-
- * unix/pause.c: Prefer any of the other choices to nap, since the
- meaning of nap argument varies from system to system, and the user
- may not set HAVE_HUNDREDTHS_NAP correctly.
-
- * unix/cusub.c (fsysdep_shell): When starting up an interactive
- shell, use the environment variable SHELL rather than /bin/sh.
-
-Fri May 26 00:03:46 1995 Ian Lance Taylor <ian@airs.com>
-
- * Chip Salzenberg: uulog.c (main): Set cluser, not clsys, when
- using HAVE_HDB_LOGGING.
-
- * Robert Joop: uuconf/callin.c (uuconf_callin): Improve handling
- of Unix style passwd files.
-
- * uupick.c (main): Don't fail if we can't get system information,
- since uupick is not setuid.
-
- * Stephen Harris: uudefs.h (struct sstatus): Add new field
- zstring.
- * unix/status.c (fsysdep_get_status): Set zstring field.
- * uustat.c (fsquery_show): Print and free zstring field, if set,
- rather than indexing off type.
- (fsmachines): Likewise.
- * uucico.c (fcall): Free sstat.zstring.
-
- * proti.c (cIwindow_timeout): New static variable.
- (fijstart): Initialize cIwindow_timeout based on the window size
- and connection speed. Increment both timeouts in callee.
- (fishutdown): Initialize cIwindow_timeout.
- (fiwindow_wait): Use cIwindow_timeout rather than cItimeout.
-
- * unix/serial.c (fsysdep_conn_io): Try using select before doing a
- blocking write, and use an alarm if we fall back to the blocking
- write, to try to avoid deadlock when both systems fill the pipe.
-
- * Trever Miller: unix/lock.c (fsdo_lock): Fix use of inid where
- inme was intended, in HAVE_QNX_LOCKFILES code.
-
- * unix/lock.c (fsdo_lock): Treat an empty lock file as stale.
-
-Thu May 25 11:46:32 1995 Ian Lance Taylor <ian@airs.com>
-
- * Kenji Rikitake: unix/serial.c (fsserial_hardflow): Handle
- CRTS_IFLOW as used on BSDI.
-
- * Gerriet M. Denkmann: uuconf/vsnams.c (uuconf_v2_system_names):
- Accept continuation lines in L.sys.
- * uuconf/vsinfo.c (_uuconf_iv2_system_internal): Skip comment
- lines in L.cmds. Ignore everything after comma in L.cmds lines.
-
- * Gerriet M. Denkmann: unix/ftw.c (ftw_dir): Initialize newlev to
- avoid warning.
-
- * Paul Pryor: unix/tli.c (ftli_open): Swap real and effective user
- ID's when running as a server, so that root can bind privileged
- ports.
-
- * unix/tcp.c (ftcp_open): Call fsuser_perms and fsuucp_perms
- rather than having the same code inline.
-
- * sysh.unx (fsuser_perms, fsuucp_perms): Declare.
- * unix/ufopen.c (fsuser_perms, fsuucp_perms): Move into uid.c.
- * unix/uid.c: New file.
- * unix/Makefile.in (OBJS): Add uid.o.
- (uid.o): New target.
-
- * unix/tcp.c: Move tcp.c into unix subdirectory.
- * unix/tli.c: Likewise for tli.c.
- * Makefile.in (UUOBJS, CUOBJS, ALLOBJS): Remove tcp.o and tli.o.
- (tcp.o, tli.o): Remove.
- * unix/Makefile.in (OBJS): Add tcp.o and tli.o.
- (tcp.o, tli.o): New targets.
-
- * Paul Pryor: configure.in: Check for -lnsl_s before -lnsl.
-
- * Makefile.in (prefix): Use @prefix@, not /usr/local.
- (exec_prefix): New variable, set to @exec_prefix@.
- (sbindir, bindir): Use $(exec_prefix) rather than $(prefix).
- (CPPFLAGS): New variable, set to @CPPFLAGS@.
- (@SET_MAKE@): New macro used by autoconf 2.
- (MORECFLAGS): Put -I. before -I$(srcdir).
- (MDEFINES): Pass down CPPFLAGS.
- (.c.o): Use CPPFLAGS.
- (uuconv.o): Likewise.
- (distclean): Remove stamp-h, config.log and config.cache.
- (maintainer-clean): New synonym for realclean.
- (configure, config.h, stamp-h, Makefile, config.status): Rewrite
- as suggested by autoconf 2.3.
- (.PHONY): Add maintainer-clean.
- * lib/Makefile.in (CPPFLAGS): New variable, set to @CPPFLAGS@.
- (MORECFLAGS): Put `-I..' before `-I$(srcdir)/..'.
- (maintainer-clean): New synonym for realclean.
- (.c.o): Use CPPFLAGS.
- (Makefile): Just rebuild this Makefile, not the others.
- (.PHONY): Add maintainer-clean.
- * unix/Makefile.in (CPPFLAGS): New variable, set to @CPPFLAGS@.
- (prefix): Removed.
- (sbindir): Use @exec_prefix@ rather than $(prefix).
- (MORECFLAGS): Put `-I..' before `-I$(srcdir)/..'.
- (maintainer-clean): New synonym for realclean.
- (.c.o): Use CPPFLAGS.
- (Makefile): Just rebuild this Makefile, not the others.
- (.PHONY): Add maintainer-clean.
- * uuconf/Makefile.in (prefix): Set to @prefix@, not /usr/local.
- (CPPFLAGS): New variable, set to @CPPFLAGS@.
- (MORECFLAGS): Put `-I.' before `-I$(srcdir)' and `-I..' before
- `-I$(srcdir)/..'.
- (maintainer-clean): New synonym for realclean.
- (.c.o): Use CPPFLAGS.
- (Makefile): Just rebuild this Makefile, not the others.
- (.PHONY): Add maintainer-clean.
-
- * configure.in: Extensive changes for autoconf 2.3.
- * configure: Regenerate using autoconf 2.3.
- * install-sh: New file.
-
-Mon May 22 22:18:59 1995 Ian Lance Taylor <ian@airs.com>
-
- * Mister Flash: chat.c (fcsend): Don't get forget to add 10 in \x.
-
-Tue Jan 17 22:49:05 1995 Ian Lance Taylor <ian@airs.com>
-
- * unix/mkdirs.c (fsysdep_make_dirs): Don't get confused by a
- double slash.
-
-Wed Aug 10 09:25:10 1994 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/hport.c (uuconf_hdb_find_port): Set iret to
- UUCONF_SUCCESS when a port is found.
-
-Tue Aug 2 08:57:05 1994 Ian Lance Taylor (ian@airs.com)
-
- * trans.c (ftadd_cmd): Report a 'P' (poll) command as garbled.
-
-Wed Jul 20 21:53:03 1994 Ian Lance Taylor (ian@airs.com)
-
- * rec.c (flocal_rec_file_init): Set name of local system after
- calling uuconf_system_local.
- * uustat.c (fsexecutions): Likewise.
-
-Sat Jul 16 16:54:12 1994 Ian Lance Taylor (ian@airs.com)
-
- * log.c (ulog): Use strerror in message about being unable to open
- the log file.
-
-Wed Jul 13 00:44:33 1994 Ian Lance Taylor (ian@airs.com)
-
- * rec.c (fremote_send_reply): Set qinfo->freplied before sending
- the command.
-
-Sun Jul 10 23:25:23 1994 Ian Lance Taylor (ian@airs.com)
-
- * Tin Le: lib/debug.c (udebug_buffer): Only compile if DEBUG > 1.
-
-Mon Jun 27 21:06:29 1994 Ian Lance Taylor (ian@airs.com)
-
- * uuconf.h (UUCONF_CMDTABFLAG_NOCOMMENTS): Define.
- * uuconf/cmdlin.c (uuconf_cmd_line): Handle NOCOMMENTS.
- * uuxqt.c (uqdo_xqt_file): Pass NOCOMMENTS to uuconf_cmd_file.
-
-Thu May 19 22:50:37 1994 Ian Lance Taylor (ian@airs.com)
-
- * Ollivier Robert: unix/mkdirs.c: Permit EISDIR.
-
-Wed May 18 23:15:36 1994 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fcall): Reset sDaemon fields each time through the
- loop, not just once.
-
-Thu May 5 23:15:11 1994 Ian Lance Taylor (ian@airs.com)
-
- * Released version 1.05.
-
- * Makefile.in (doc-dist): Put uucp.ps in uucp-doc-$(VERSION).
-
-Sun May 1 23:41:49 1994 Ian Lance Taylor (ian@airs.com)
-
- * uuchk.c (ikshow_port): Show reliability information.
- (ukshow_dialer): Likewise.
- (ukshow_reliable): New function.
-
-Sat Apr 16 22:28:10 1994 Ian Lance Taylor (ian@airs.com)
-
- * Andrew A. Chernov: uucico.c (main): Pass 'z' to getopt.
- (uhelp): Mention -z aka --try-next.
-
- * log.c (ustats): Report failed transfers when HAVE_HDB_LOGGING.
-
-Wed Apr 13 23:07:20 1994 Ian Lance Taylor (ian@airs.com)
-
- * prot.c (fsend_data): If no room in receive buffer, just write
- the data out, don't call fconn_io.
-
-Tue Apr 12 21:55:32 1994 Ian Lance Taylor (ian@airs.com)
-
- * Spider Boardman: unix/serial.c (fsysdep_modem_end_dial): Set
- terminal characteristics of reopened port.
-
-Sun Apr 10 18:05:34 1994 Ian Lance Taylor (ian@airs.com)
-
- * send.c (flocal_send_fail): Always call fsysdep_did_work.
- (flocal_send_await_reply): Don't call flocal_send_fail if we are
- going to call fsend_exec_file_init. Only call
- fsend_exec_file_init if fnever is TRUE. Pass fnever to
- flocal_send_cancelled using the qinfo->fsent flag.
- (flocal_send_cancelled): Only call fsend_exec_file_init if
- qinfo->fsent is TRUE.
-
- * unix/statsb.c (fsysdep_lock_status): If HAVE_QNX_LOCKFILES,
- initialize painid to NULL.
-
-Tue Apr 5 23:09:00 1994 Ian Lance Taylor (ian@airs.com)
-
- * Released version gamma 1.05.
-
- * Makefile.in (VERSION): Changed to gamma1.05.
-
- * uucico.c (fcall): Return TRUE if -C was used and no call was
- made because there was no work.
-
-Mon Apr 4 20:29:30 1994 Ian Lance Taylor (ian@airs.com)
-
- * Chris Lewis: unix/serial.c: Include <sys/ioctl.h> if
- HAVE_TXADDCD. Check for HAVE_TXADDCD rather than ifdef TXADDCD or
- TXDELCD.
-
- * configure.in: Check for TXADDCD in <sys/ioctl.h>.
- * config.h.in (HAVE_TXADDCD): New configuration macro.
-
-Sun Apr 3 14:05:30 1994 Ian Lance Taylor (ian@airs.com)
-
- * send.c (flocal_send_request): Queue stransfer structure up
- before sending any command or data, because sending data may cause
- data to be received for this stransfer, and we must be prepared to
- handle it correctly.
- (fremote_rec_reply): Likewise.
- * rec.c (flocal_rec_send_request, fremote_send_reply): Likewise.
- (fremote_send_fail_send): Likewise.
- * xcmd.c (flocal_xcmd_request): Likewise.
-
- * Chris Lewis: unix/serial.c (fsserial_hardflow): Add support for
- AIX TXADDCD and 3b1 CTSCD.
-
-Sat Apr 2 00:04:30 1994 Ian Lance Taylor (ian@airs.com)
-
- * policy.h (USE_TRADITIONAL_STATUS): Permit this to be defined.
- * lib/status.c: Control initialization of azStatus based on
- USE_TRADITIONAL_STATUS rather than SPOOLDIR_HDB || SPOOLDIR_SVR4.
-
-Fri Apr 1 23:52:09 1994 Ian Lance Taylor (ian@airs.com)
-
- * log.c (ulog): When using HAVE_HDB_LOGGING, force the program
- name to lower case when using it as a file name.
-
- * send.c (flocal_send_await_reply): Correct code to really not
- decrement number of channels to one.
- * rec.c (flocal_rec_await_reply): Likewise.
-
-Wed Mar 30 22:57:30 1994 Ian Lance Taylor (ian@airs.com)
-
- * lib/buffer.c (ubuffree): Change ioff from size_t to int to avoid
- HP/UX compiler bug.
-
- * configure.in: Make sure that <utime.h> defines struct utimbuf
- before assuming that it is present.
-
-Tue Mar 29 23:00:15 1994 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/filnam.c: Use UUCONF_CONST, not const, to match
- declaration in uuconf.h.
-
-Mon Mar 28 20:06:00 1994 Ian Lance Taylor (ian@airs.com)
-
- * Andrew A. Chernov: policy.h: For several macros, add commented
- out values appropriate for some free BSD distributions.
- * Makefile.in: Likewise.
-
- * uucico.c (icallin_cmp): Use pointer, not void *.
- * uuconf/callin.c (struct sinfo, uuconf_callin): Likewise.
-
- * Chris Lewis: uuconv.c (fvperm_string_cmp, fvperm_array_cmp): AIX
- 3.2.5 cc can't handle conditional expressions in if conditions.
-
-Sun Mar 27 15:04:27 1994 Ian Lance Taylor (ian@airs.com)
-
- * send.c (flocal_send_fail): Don't assume that qtrans is not NULL.
-
- * Jeff Ross, Stephen J. Walick: Makefile.in (uusched): Substitute
- for @SBINDIR@, not @BINDIR@.
-
- * configure.in: Make sure that <dirent.h> defines struct dirent
- before assuming that it is present.
-
- * Benoit Grange: unix/detach.c (usysdep_detach): Correct type of
- HAVE_BSD_SETPGRP for HAVE_BSD_PGRP.
-
-Sat Mar 26 12:59:36 1994 Ian Lance Taylor (ian@airs.com)
-
- * Andrew A. Chernov: uucico.c (asLongopts): Add --try-next as
- synonym for -z.
- (main): If -z, call fcall with ftrynext as TRUE.
- (fcall): Add ftrynext argument. If ftrynext is TRUE, try the next
- alternate if a call fails.
-
-Fri Mar 25 22:37:51 1994 Ian Lance Taylor (ian@airs.com)
-
- * lib/parse.c (fparse_cmd): If we get a decimal 666 or 777 for the
- mode, turn it into an octal 0666 or 0777.
-
- * send.c (flocal_send_fail): Accept qdaemon argument rather than
- qsys. Changed all callers. If we are going to send an execution
- file, don't call fsysdep_did_work.
-
- * protg.c (fgstart): Say ``sending'' and ``receiving'' instead of
- ``remote'' and ``local'' in log message.
- * proti.c (fijstart): Likewise.
-
-Thu Mar 24 22:40:49 1994 Ian Lance Taylor (ian@airs.com)
-
- * Gert Doering: uuchk.c (ikshow_port): Don't use qtli for a TCP
- port.
-
- * Makefile.in (uusched, uuto): Fix typo in sed command.
-
- * unix/mail.c (fsysdep_mail): Add casts to avoid warnings.
- * uuconf/runuxq.c (uuconf_runuuxqt): Likewise.
-
- * Emmanuel Mogenet: unix/pipe.c (fspipe_dial): Make consistently
- static.
-
- * unix/serial.c (fsserial_open): Only strip /dev/ from the start
- of a device name, rather than dropping everything before the last
- slash.
-
- * sysh.unx (ftw): Change stat argument to not be const pointer.
- * unix/ftw.c (ftw_dir, ftw): Change stat argument to func argument
- to not be const pointer.
- * unix/srmdir.c (isremove_dir): Change stat argument to not be
- const pointer.
- * unix/walk.c (iswalk_dir): Likewise.
-
-Wed Mar 23 20:02:26 1994 Ian Lance Taylor (ian@airs.com)
-
- * conn.c (fconn_break): Remove incorrect indirection of function
- pointer.
-
- * unix/mkdirs.c (fsysdep_make_dirs): Some systems can return
- EACCES, not EEXIST, when a directory exists.
-
- * configure.in: Fix STAT_STATFS2_FSIZE test.
- * configure: Regenerated.
-
-Tue Mar 22 01:32:21 1994 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (main): Skip a leading dash in argv[0] which is
- probably the result of being invoked by the Unix login program.
-
- * configure.in: Check for sys/time.h.
- * config.h.in (HAVE_SYS_TIME_H): Define.
-
- * unix/serial.c (fsysdep_modem_begin_dial): Correct type of q for
- qsysdep.
-
- * uux.c (main): Check for zXnames being NULL.
-
-Sat Mar 19 14:07:31 1994 Ian Lance Taylor (ian@airs.com)
-
- * Released version beta 1.05.
-
- * Makefile.in (uucp.info): Use -o argument to force info files to
- be created in objdir.
- (doc-dist): Get README-DOC from $(srcdir).
-
- * lib/debug.c (iDebug, azDebug_names, idebug_parse): Only compile
- if DEBUG > 1.
-
-Mon Feb 14 22:46:49 1994 Ian Lance Taylor (ian@airs.com)
-
- * lib/strtou.c: New file, for strtoul.
- * lib/MANIFEST: List strtou.c.
- * configure.in: Check for strtoul, add strtou.o to LIBOBJS if not
- there.
- * config.h.in (HAVE_STRTOUL): Define.
- * uucp.h (strtoul): Declare.
-
-Mon Jan 31 20:17:30 1994 Ian Lance Taylor (ian@airs.com)
-
- * Makefile.in, lib/Makefile.in, unix/Makefile.in,
- uuconf/Makefile.in: Use $(CFLAGS) after all other flags.
-
-Sun Jan 30 14:34:51 1994 Ian Lance Taylor (ian@airs.com)
-
- * Makefile.in (clean, distclean, dist, doc-dist): Remove .tar.gz
- file, not .tar.Z one.
- (dist, doc-dist): Use gzip --best, not compress.
-
- * Makefile.in (VERSION): Set to beta1.05.
-
- * cu.c, uuchk.c, uucico.c, uuconv.c, uucp.c, uulog.c, uuname.c,
- uupick.c, uustat.c, uux.c, uuxqt.c: Updated copyright date.
-
- * conn.c (fconn_init): Added third argument: type of standard
- input port.
- * conn.h (fconn_init): Updated declaration.
- * uucico.c (asLongopts): Added --stdin, synonym for -i.
- (main): Accept -i TLI to set standard input to be of type TLI.
- Pass appropriate additional argument to fconn_init.
- (uhelp): Updated.
- (fconn_call, iuport_lock): Changed all calls to fconn_init.
- * cu.c: Changed all calls to fconn_init.
- * prot.c, protj.c: Include uuconf.h before conn.h.
- * Makefile.in (prot.o, protj.o): Updated.
-
- * unix/serial.c (fsysdep_conn_read): Permit up to two EWOULDBLOCK
- error returns from read before quitting.
-
-Sat Jan 22 16:48:41 1994 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/hinit.c: Don't treat lines with leading whitespace as
- comments in Sysfiles.
-
- * log.c: Don't require ANSI C to use vfprintf, just require
- stdarg.h and prototypes. Required for Alpha cc support.
-
- * configure.in: Check for prototype support. Check for stdarg.h.
- When looking for socket and t_open check for "-lsocket -lnsl"
- after plain "-lnsl".
- * config.h.in (HAVE_PROTOTYPES, HAVE_STDARG_H): New macros.
- * uucp.h: Demand that an ANSI C compiler support prototypes. If
- HAVE_PROTOTYPES is 1 for Classic C, defined P(x) to be x.
-
- * configure: Upgraded to autoconf 1.7.
-
- * protg.c (fgstart): Ensure that window size is reasonable.
-
- * protg.c (fvstart): Change default packet size from 512 to 1024.
-
- * trans.h (struct sdaemon): Added zconfig, irunuuxqt, and
- cxfiles_received fields.
- (fspawn_uuxqt): Declare.
- * uucico.c (fcall, flogin_prompt, faccept_call): Added zconfig and
- fuuxqt arguments; changed all callers.
- (main): Use fspawn_uuxqt to invoke uuxqt, and only do it if
- uuconf_runuuxqt returns UUCONF_RUNUUXQT_ONCE.
- (fcall, faccept_call): Initialize new struct sdaemon fields.
- Spawn uuxqt if uuconf_runuuxqt returned UUCONF_RUNUUXQT_PERCALL or
- if it returned a positive number and execution files have arrived
- since the last time uuxqt was spawned.
- (fspawn_uuxqt): New function.
- * rec.c (frec_file_end): Spawn uuxqt if enough execution files
- have been received.
-
- * uuconf.h (UUCONF_RUNUUXQT_NEVER, UUCONF_RUNUUXQT_ONCE,
- UUCONF_RUNUUXQT_PERCALL): New #define constants.
- (uuconf_runuuxqt): Declare.
- * uuconf/runuxq.c: New file.
- * uuconf/uucnfi.h (struct sprocess); Added zrunuuxqt field.
- * uuconf/tinit.c (asCmds): Added "run-uuxqt".
- * uuconf/iniglb.c (_uuconf_iinit_global): Initialize zrunuuxqt
- field.
- * uuconf/MANIFEST, uuconf/Makefile.in: Handle runuxq.c.
-
- * system.h (fsysdep_run): Added ffork argument.
- * unix/run.c (fsysdep_run): Added ffork argument.
- * uucico.c (main), uux.c (main), uucp.c (main): Changed calls to
- fsysdep_run to pass ffork argument as FALSE.
-
-Fri Jan 14 19:40:20 1994 Ian Lance Taylor (ian@airs.com)
-
- * Chip Salzenberg: unix/splcmd.c (zsysdep_spool_commands): More
- fitting value for size of abtempfile.
-
-Mon Jan 10 22:46:52 1994 Ian Lance Taylor (ian@airs.com)
-
- * unix/recep.c (fsysdep_remember_reception): Create directory with
- mode of 0755, not 0777.
-
-Mon Jan 3 20:34:35 1994 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgprocess_data): Don't believe the ACK of an out of
- order packet.
-
- * uucico.c (asProtocols): Added 'v'.
- * prot.h (fvstart): Declare.
- * protg.c (fvstart): New function.
-
-Sun Jan 2 15:34:12 1994 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (main), uucp.c (main), uux.c (main): Pass -I argument
- to invoked program.
-
- * uustat.c (JOB_REJUVENATE): Define.
- (asLongopts): Add "rejuvenate-all".
- (main, ususage): Handle -R.
- (fsworkfile_show, fsexecutions): Handle JOB_REJUVENATE.
- * system.h (fsysdep_touch_file): Declare.
- * unix/statsb.c (issettime): Rename from ussettime.
- (fsysdep_touch_file): Create.
-
- * Jim Avera: system.h: (INIT_NOCLOSE): Define.
- * unix/init.c (usysdep_initialize): If INIT_NOCLOSE is set, don't
- close all open descriptors.
-
- * Allen Delaney: tli.c: Don't declare t_alloc if we have
- <tiuser.h>, since it can cause conflicts.
-
- * configure.in: Call AC_CONST.
- * config.h.in: Added #undef const for configure to comment out.
- * uucp.h: Don't undefine const here.
-
- * Spider Boardman: uucico.c (main): Correct error message.
- uux.c (main), uucp.c (main): Call uucico with -C option.
-
- * tstuu.c (uprepare_test): Don't put the obsolete pty command into
- the port file.
-
- * spawn.c (ixsspawn): Set close-on-exec flag for both ends of
- new pipe.
-
- * Andrew A. Chernov: unix/serial.c (ICLEAR_IFLAG): Clear IMAXBEL
- if it is defined.
- (ICLEAR_LFLAG): Clear PENDIN if it is defined.
-
- * send.c (flocal_send_file_init): If stat fails, discard the
- command and save the temporary file.
- (flocal_send_fail): Cleaned up zsysdep_save_temp_file call.
-
-Thu Dec 23 00:55:22 1993 Ian Lance Taylor (ian@airs.com)
-
- * Martin Tomes: spawn.c (ixsspawn): On ISC, call __setostype
- before execve.
-
-Wed Dec 22 00:06:25 1993 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/tport.c (ipunknown): Set UUCONF_CMDTABRET_EXIT if an
- error is found.
-
- * uucico.c (asLongopts): Add --login as a synonym for -u.
- (main): Permit a privileged user to use -u to set the login name
- rather than always using zsysdep_login_name ().
- (flogin_prompt): Accept login name as an argument. If non-null,
- use it rather than prompting for one.
- (uhelp): Document new --login option.
- * uucico.8: Document new --login option.
- * unix/priv.c: New file, containing fsysdep_privileged.
- * unix/statsb.c (fsysdep_privileged): Moved to priv.c.
- * unix/MANIFEST, unix/Makefile.in: Support new priv.c file.
-
- * uuchk.c (ikshow_port): Print a note when using the port name as
- a device name.
-
-Tue Dec 21 00:01:40 1993 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fcall): Ignore status file times in the future when
- deciding whether a retry is permitted.
-
- * detach.c (usysdep_detach): If it forks, output a debugging
- message with the old and new process IDs.
-
- * Scott Ballantyne: unix/spawn.c (ixsspawn): If fkeepuid is TRUE,
- try to set the real user and group ID to the effective user and
- group ID. This will not work on System V derived systems, but
- should do no harm.
- * unix/xqtsub.c (fsysdep_execute): Pass fkeepuid as TRUE to
- ixsspawn.
- * unix/epopen.c (espopen): Likewise.
-
- * uucico.c (faccept_call): Use correct default for
- max-remote-debug.
-
- * uuconf/tportc.c (ipdialer): Don't core dump if the port name is
- NULL, as it is for the default port.
-
- * unix/xqtsub.c (fsysdep_xqt_check_file): Do not permit the name
- ``..'', or strings starting with ``../''.
-
- * proti.c (fijstart): Send a fourth byte in the SYNC packet with
- the number of channels.
- (fiprocess_packet): If a SYNC packet has a fourth byte, use it to
- set the number of channels.
-
- * rec.c (flocal_rec_await_reply): Handle RN9 (no channels
- available on remote).
- * send.c (flocal_send_await_reply): Handle SN9 (no channels
- available on remote).
-
- * trans.h (struct sdaemon): Added cchans field.
- * uucico.c (fcall, fdo_call, faccept_call): Initialize cchans.
- * trans.c (utchanalc, fcheck_queue, floop): Use qdaemon->cchans,
- not qdaemon->qproto->cchans.
- * send.c (flocal_send_request, flocal_send_await_reply): Likewise.
- * rec.c (fremote_send_fail): Likewise.
-
-Sun Dec 19 19:44:31 1993 Ian Lance Taylor (ian@airs.com)
-
- * proti.c (cIack_frequency): New static variable.
- (asIproto_params): New protocol parameter ack-frequency.
- (fijstart): If cIack_frequency is not set, set it to half the
- window size.
- (fishutdown): Clear cIack_frequency.
- (fiprocess_data): Use cIack_frequency to determine when to send an
- acknowledgement, rather than always sending one at half the window
- size.
-
- * uuconf/cmdfil.c (uuconf_cmd_file): Free zline.
-
- * uuconf/callin.c (uuconf_callin): Treat colon as a field
- delimiter, for Unix /etc/passwd support.
-
- * unix/xqtsub.c (zsysdep_find_command): If file named with
- absolute path does not exist, give a reasonable error message.
-
- * uuconf/rdperm.c (ihadd_norw): Ignore use of empty string with
- NOREAD or NOWRITE, rather than denying everything.
-
- * Chip Salzenberg: uulog.c (main): Set zluser correctly under
- HAVE_HDB_LOGGING.
-
- * Chip Salzenberg: protz.c (izrecv_hdr): Use %lx, not %x.
-
-Sun Dec 12 19:24:35 1993 Ian Lance Taylor (ian@airs.com)
-
- * uucp.c (uccopy): Null terminate name of forwarding system.
-
-Mon Nov 22 21:12:41 1993 Ian Lance Taylor (ian@airs.com)
-
- * unix/tmpfil.c: Include "uudefs.h".
- * unix/Makefile.in: Changed accordingly.
-
- * log.c (zstpcpy): New function.
- (ulog): Output to log file with a single call to fprintf.
-
- * uucp.c (uccopy): Clarified "not permitted to send" error.
-
- * log.c (ulog): If debugging is on, output all log messages to
- debugging file.
-
- * uucico.c (fdo_call): Changed "Bad initialization string" error
- message.
-
- * unix/lock.c (fsdo_lock): Print date a stale lock was last
- modified.
-
- * uucico.c (uaccept_call_cleanup): Call ulog_system (NULL).
-
-Sun Nov 21 17:04:27 1993 Ian Lance Taylor (ian@airs.com)
-
- * Joe Wells: policy.h: Added new parameter LOG_DEVICE_PREFIX.
- * unix/serial.c (fsserial_open): Use it.
-
- * Makefile.in: Always use CFLAGS as well as LDFLAGS when linking.
-
- * Joe Wells: policy.h: Added new parameter QNX_LOG_NODE_ID.
- * log.c (ulog): Log the QNX node ID if QNX_LOG_NODE_ID is set.
-
- * Joe Wells: unix/serial.c: Support QNX dev_info function for
- serial port locking.
-
- * Joe Wells: unix/fsusg.c: Support QNX disk_space function.
- * unix/Makefile.in: fsusg.o now depends upon uudefs.h.
-
- * Joe Wells: policy.h: Changed PS_PROGRAM default for __QNX__.
- Added HAVE_QNX_LOCKFILES. Rearranged LOCKFILE defines to permit
- some default selections.
- * sysh.unx: Removed LOCKFILES sanity check.
- * unix/lock.c (fsdo_lock, fsqnx_stale), unix/serial.c
- (fsserial_lockfile), unix/statsb.c (fsysdep_lock_status): Added
- support for HAVE_QNX_LOCKFILES.
-
- * configure.in, config.h.in, policy.h: Moved MAIL_PROGRAM to
- policy.h. Added MAIL_PROGRAM_TO_BODY and
- MAIL_PROGRAM_SUBJECT_BODY.
- * unix/mail.c: Updated accordingly.
-
- * uucico.c (main): Don't make -p imply -e.
- (uhelp): Modified accordingly.
- * uucico.8: Modified accordingly.
-
-Mon Nov 1 21:34:36 1993 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (main): Call fconn_close and fconn_open rather than
- calling fconn_reset.
- * conn.h (struct sconncmds): Removed pfreset field.
- (fconn_reset): Removed declaration.
- * conn.c (fconn_reset): Removed.
- * tcp.c (ftcp_reset): Removed.
- (ftcp_open): Save pid in ssysdep_conn information.
- (ftcp_close): If pid has changed, return FALSE.
- * tli.c (ftli_reset): Removed.
- (ftli_open): Save pid in ssysdep_conn information.
- (ftli_close): If pid has changed, return FALSE.
- * unix/pipe.c (fspipe_close): Replaced with fspipe_reset body.
- (fspipe_reset): Removed.
- (fspipe_dial): Call fspipe_close, not fspipe_reset.
- * unix/serial.c (fsserial_reset, fsstdin_reset): Removed.
- (fsysdep_modem_begin_dial): Hangup terminal here, rather than
- calling fconn_reset.
-
- * send.c (fremote_rec_reply): If we want to request hangup, send
- an M after the mode.
- * rec.c (flocal_rec_await_reply): If there an M after the mode,
- the remote is requesting a hangup.
-
-Sun Oct 31 23:43:40 1993 Ian Lance Taylor (ian@airs.com)
-
- * uux.c (zXnames): New static variable to hold list of file names
- being sent.
- (uxadd_name): Function to add a new name.
- (main, uxadd_send_file): Call uxadd_name.
- (main): Include zXnames in log message.
-
-Mon Oct 18 00:23:27 1993 Ian Lance Taylor (ian@airs.com)
-
- * proti.c (fijstart): Ensure that packet size and window size are
- reasonable; restrict window size to 16.
-
- * proti.c (iIforced_remote_winsize): Removed, along with all
- references.
- (asIproto_params): Removed "remote-window".
-
-Sun Oct 17 22:15:14 1993 Ian Lance Taylor (ian@airs.com)
-
- * Mark Delany: protg.c (cGremote_duprrs): New static variable.
- (fgstart): Initialize it.
- (fgshutdown): Count rejects as cGremote_duprrs + cGremote_rejects.
- (fgprocess_data): If cGremote_rejects is non-zero, don't treat
- duplicate RR as reject. Count duplicate RR's in cGremote_duprrs,
- not cGremote_rejects.
-
- * Mark Delany: unix/serial.c (fsdouble_chat, fsysdep_conn_chat):
- After running a chat program, reread the terminal characteristics.
-
-Wed Oct 13 20:46:46 1993 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fdo_call): Fix typo.
-
-Thu Oct 7 22:28:45 1993 Ian Lance Taylor (ian@airs.com)
-
- * unix/app3.c (zsappend3), unix/app4.c (zsappend4), unix/ftw.c
- (ftw), unix/sindir.c (zsysdep_in_dir): Don't duplicate '/'
- character for root directory.
-
- * send.c (flocal_send_await_reply): If an SN comes in while the
- file is being sent, seek to the end rather than setting fsendfile
- to FALSE.
- (flocal_send_cancelled): Don't send an empty packet.
- * trans.c (utransfree): Set e field to EFILECLOSED when debugging.
- (floop): Check for file send cancelled at top of loop, not middle.
-
- * uucp.h (ffileseekend): Define.
-
-Wed Oct 6 00:51:08 1993 Ian Lance Taylor (ian@airs.com)
-
- * proti.c (fisenddata, fiprocess_packet): Report channel numbers
- in debugging messages.
-
-Tue Oct 5 00:00:33 1993 Ian Lance Taylor (ian@airs.com)
-
- * unix/statsb.c (fsysdep_lock_status): Only report the status of a
- particular job once, no matter how many lock files it has.
-
- * uustat.c (fsnotify): Added itime argument. Changed all callers.
- Report time job was queued in mail message.
-
- * unix/cusub.c (fsysdep_terminal_raw): For TERMIO and TERMIOS,
- clear IXON, IXOFF and IXANY (TERMIO only) in c_iflag.
-
- * Lele Gaifax: log.c (ustats): Report device name.
-
- * log.c (ulog): Use zsysdep_base_name of zProgram.
-
- * uuxqt.c (main): Accept local system name and unknown system
- names for -s argument. zsysdep_get_xqt may return an alias.
-
-Wed Sep 29 00:13:39 1993 Ian Lance Taylor (ian@airs.com)
-
- * proti.c (fiprocess_packet): If sending an ACK for a NAK, don't
- also send a packet.
-
- * unix/serial.c (fsysdep_modem_end_dial): If TIOCWONLINE is not
- defined, reopen the port to wait for carrier.
-
- * policy.h: Use __ultrix__ as well as ultrix in check for
- HAVE_STRIP_BUG.
-
-Tue Sep 28 22:25:05 1993 Ian Lance Taylor (ian@airs.com)
-
- * Marcel Waldvogel: uuchk.c (ukshow): Don't die if the call out
- file can not be opened.
-
-Sun Sep 19 00:16:01 1993 Ian Lance Taylor (ian@airs.com)
-
- * Jason Molenda: policy.h (HAVE_SEQUENT_LOCKFILES): New
- configuration parameter.
- * sysh.unx, unix/serial.c: Implement it.
-
- * uulog.c (main): Ignore any errors when trying to canonicalize
- the system name.
-
- * Marcel Waldvogel: uucico.c (faccept_call): If the calling system
- is already locked, and we are using sequence numbers for it,
- increment the local sequence number to keep in synch.
-
- * unix/sleep.c (usysdep_sleep): If usysdep_pause is accurate, use
- it. Otherwise call sleep, but always for at least two seconds.
- * chat.c (fcsend): Call usysdep_sleep with 1, not 2.
-
- * unix/pause.c: Correct USE_SELECT_TIMER to HAVE_SELECT.
-
- * unix/serial.c (fsmodem_open): Only turn on hardware flow control
- for an incoming connection.
- (fsmodem_carrier): Turn on hardware flow control after turning on
- carrier. Turn off hardware flow control before turning off
- carrier.
-
- * uuxqt.c (uqdo_xqt_file): Use known system name, not system name
- from execution file, unless the former is a prefix of the latter.
-
-Sat Sep 18 16:53:41 1993 Ian Lance Taylor (ian@airs.com)
-
- * policy.h: Add HAVE_ENCRYPTED_PASSWORDS configuration parameter.
- * callin.c: Change interface to use a passed in comparison
- function.
- * uuconf.h: Change declaration of uuconf_callin.
- * uucico.c (flogin_prompt): Change call to uuconf_callin.
- (icallin_cmp): New function. Handle HAVE_ENCRYPTED_PASSWORDS.
-
- * Hans-Dieter Doll: chat.c (fchat): Permit \W at the end of an
- expect string to specify a timeout.
-
- * util.c (zremove_local_sys): New function.
- * uudefs.h: Declare zremove_local_sys.
- * uucp.c (main): Read local system information. Ignore local
- system name in front of arguments.
- * uux.c (main): Ignore local system name in front of arguments.
-
- * configure.in: Call AC_HAVE_POUNDBANG, AC_STAT_MACROS_BROKEN,
- AC_TIME_WITH_SYS_TIME, AC_STRUCT_TM. Call AC_SUBST(POUNDBANG).
- Remove HAVE_SYS_TIME_AND_TIME_H check. Rework disk space
- configuration to actually check for the functions. Check for
- function dev_info. Don't confuse HAVE_FTW_H and HAVE_FTW (from
- Joe Wells).
- * config.h.in (STAT_MACROS_BROKEN, TM_IN_SYS_TIME, STAT_DUSTAT,
- STAT_DISK_SPACE, HAVE_DEV_INFO): New macros set by configure.
- (TIME_WITH_SYS_TIME): Renamed from HAVE_SYS_TIME_AND_TIME_H.
- * Makefile.in (POUNDBANG): Set to @POUNDBANG@.
- (uusched, uuto): If POUNDBANG = no, turn #!/bin/sh into :.
- (config.status): Use config.status --recheck.
- (configure): Chdir to $(srcdir) before running autoconf.
- * sysh.unx: If STAT_MACROS_BROKEN, undefine S_ISDIR.
- * log.c, time.c, uustat.c, unix/loctim.c: If TM_IN_SYS_TIME,
- include <sys/time.h>, not <time.h>.
- * tstuu.c, unix/pause.c, unix/proctm.c, unix/serial.c: Rename
- HAVE_SYS_TIME_AND_TIME_H to TIME_WITH_SYS_TIME.
- * fsusg.c: Check STAT_DUSTAT, not _AIX and _I386.
-
- * config.h.in: Renamed from conf.h.in.
- * MANIFEST, configure.in, Makefile.in, lib/Makefile.in,
- unix/Makefile.in, uuconf/Makefile.in, uucp.h: conf.h renamed to
- config.h.
-
-Fri Sep 17 00:36:16 1993 Ian Lance Taylor (ian@airs.com)
-
- * Joe Wells: policy.h: If __QNX__, default to HAVE_POSIX_TERMIOS.
-
- * Joe Wells: Makefile.in (FORCE): Add dummy command to work around
- QNX make bug.
-
- * Makefile.in, lib/Makefile.in, unix/Makefile.in,
- uuconf/Makefile.in: Add .PHONY declaration for appropriate
- commands.
-
- * Joe Wells: Makefile.in (install): Create $(man1dir) and
- $(man8dir) if necessary.
- (install-info): Create $(infodir) if necessary.
-
- * Joe Wells: sysh.unx (bsgrade): Declare as returning int rather
- than char, since it can return a negative number.
- * unix/work.c (bsgrade): Define as returning int.
-
- * Joe Wells: unix/lock.c (fsdo_lock), unix/statsb.c
- (fsysdep_lock_status): Use pid_t rather than int for variables
- that hold pid's. Cast to long when using printf.
-
- * Joe Wells: uucico.c (fcall): Fix test for 24 hour check when too
- many retries.
-
- * Joe Wells: uucico.c (fcall), unix/opensr.c
- (esysdep_open_receive), unix/recep.c (fsysdep_already received):
- Cast values in multiplication to determine seconds per day or per
- week to long, because result is larger than 16 bits.
-
- * Joe Wells: uuconv.c: Add return 0 after exit to avoid warnings.
-
-Thu Sep 16 23:53:58 1993 Ian Lance Taylor (ian@airs.com)
-
- * Joe Wells: configure.in: Set AR from environment, defaulting to
- ar, and substitute it in Makefiles.
- * Makefile.in: Set AR to @AR@. Pass it down in MDEFINES.
- * lib/Makefile.in, unix/Makefile.in, uuconf/Makefile.in: Set AR to
- @AR@. Use $(AR) instead of ar. Use rc instead of qc (POSIX.2
- does not define q).
-
-Wed Sep 15 00:47:33 1993 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/callin.c (uuconf_callin): Take an additional argument: a
- function to call to transform the login name and password. This
- is a hack to avoid requiring escape sequence handling in uuconf.
- * uucico.c (flogin_prompt): Pass cescape to uuconf_callin. This
- is an incompatible change.
- * uuconf.h (uuconf_callin): Update declaration.
- * tstuu.c (uprepare_test): Use \s in password in Call1 and Pass2.
-
- * chat.c (fcsend, fcprogram): Expand escape sequences in callout
- login names and passwords. This is an incompatible change.
-
- * Joe Wells: uustat.c (fsnotify): Add missing break statement.
-
- * Mark Eichin: tstuu.c (main): Add some sleeps in the children to
- make the tests more robust on Linux.
-
- * uulog.c (ulhelp): Clean up general usage message: don't show -F
- for HDB_LOGGING, don't show -x for non HDB_LOGGING. Remove
- mention of numeric debugging levels.
- * uustat.c (ushelp): Remove mention of numeric debugging levels.
-
- * unix/serial.c (ICLEAR_CFLAG): Removed CLOCAL.
- (enum tclocal_setting): New enum.
- (fsserial_lock): Don't call TIOCSCTTY.
- (fsserial_open): Changed flocal argument to tlocal. Use it to
- determine initial CLOCAL setting for TERMIO and TERMIOS. Don't
- call TIOCSCTTY until after setting the terminal state.
- (fsstdin_open): Call fsserial_open with IGNORE_CLOCAL.
- (fsmodem_open): Call fsserial_open with SET_CLOCAL if calling out,
- CLEAR_CLOCAL if waiting for an incoming call.
- (fsdirect_open): Call with SET_CLOCAL or CLEAR_CLOCAL depending
- upon fcarrier setting.
- * uuconf.h (struct uuconf_direct_port): Added fcarrier field.
- * uuconf/tportc.c (asPdirect_cmds): Added ``carrier'' command.
- (_uuconf_iport_cmd): Initialize direct fcarrier field to FALSE.
- * uuconf/hport.c (uuconf_hdb_find_port), uuconf/vport.c
- (uuconf_v2_find_port): Set direct fcarrier field to FALSE.
- * uuchk.c (ikshow_port): Print direct port carrier field.
- * uuconv.c (uvwrite_taylor_port): Likewise.
-
- * uustat.c (main, fsquery, fsquery_systems, fsquery_show): Support
- -o, -y, -s and -S in conjunction with -q.
-
-Tue Sep 14 00:51:50 1993 Ian Lance Taylor (ian@airs.com)
-
- * log.c (ulog): If we can't open the log file, print an error on
- stderr.
-
- * configure.in, conf.h.in: Adjusted for autoconf 1.5.
-
-Sun Sep 12 15:52:29 1993 Ian Lance Taylor (ian@airs.com)
-
- * unix/serial.c (fsserial_open): Add flocal argument. Changed all
- callers. Pass it as TRUE when dialing out on a modem. This is
- supposedly required on 386bsd.
-
- * conn.c (fconn_dial_sequence): New function.
- (fmodem_dial): Use fconn_dial_sequence. Call fsysdep_modem_begin
- only once, before entire sequence, and fsysdep_modem_end only
- once, after entire sequence. Don't call fcdo_dial.
- (fcdo_dial): Removed.
- * conn.h: Declare fconn_dial_sequence.
- * uucico.c (fconn_call): Don't free dialer if fconn_dial fails.
- * uuconf.h (struct uuconf_tcp_port): Add pzdialer field.
- * tcp.c (ftcp_dial): Pass new pzdialer field to
- fconn_dial_sequence.
- * tli.c (ftli_dial): Pass pzdialer to fconn_dial_sequence.
- * uuconf/hport.c (uuconf_hdb_find_port): Add trailing dialer
- sequence to pzdialer field for TCP port.
- * uuconf/tportc.c (asPtcp): Add ``dialer-sequence'' command.
- (_uuconf_iport_cmd): Initialize pzdialer for TCP port.
- * uuconf/vsinfo.c (_uuconf_iv2_system_internal): Initialize
- pzdialer for TCP port.
- * uuchk.c (ikshow_port): Print TCP pzdialer field.
- * uuconv.c (uvwrite_taylor_port, ivwrite_hdb_port): Output TCP
- pzdialer field.
-
-Sat Sep 11 16:30:17 1993 Ian Lance Taylor (ian@airs.com)
-
- * uulog.c, uuname.c (main): Pass INIT_NOCHDIR to
- usysdep_initialize.
-
- * uucp.1, uustat.1, uux.1, uuxqt.8: Remove uses of nonportable .EX
- and .EE macros.
-
- * uuxqt.c (asQcmds, iqout, iqfile, iqrequestor, iquser): Remove
- restrictions on number of arguments to commands in execution file,
- since is there is such a range of buggy UUCP implementations out
- there.
-
- * sysh.unx (CORRUPTDIR): Define.
- * unix/corrup.c: New file for new zsysdep_save_corrupt_file
- function to save a file in CORRUPTDIR.
- * unix/Makefile.in, unix/MANIFEST: Add corrup.
- * system.h: Add declaration of zsysdep_save_corrupt_file.
- * uuxqt.c (uqdo_xqt_file): If execution file has a syntax error,
- save it using zsysdep_save_corrupt_file and notify OWNER.
-
- * uuconf/hsinfo.c (_uuconf_ihdb_system_internal), vsinfo.c
- (_uuconf_iv2_system_internal): Treat a specified time/grade as
- both a timegrade and a call-timegrade.
-
- * rec.c (frec_file_end): If the received file can not be moved to
- the final location, and there is enough disk space, keep the file,
- mentioned the saved name in the error message, and send mail to
- OWNER about it. If the hand created execution file can not be
- moved, delete it.
- * unix/move.c (fsysdep_move_file): Don't delete the original file
- if the move fails.
- * unix/splcmd.c (zsysdep_spool_commands): Remove the temporary
- file if the move fails.
-
-Wed Sep 1 23:29:30 1993 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/tinit.c (itdebug, _uuconf_idebug_cmd): New functions.
- (asCmds): Call itdebug for "debug", to accept spaces between
- options as well as commas.
- * uuconf/tsinfo.c (iidebug): New function.
- (asIcmds): Call iidebug for "debug".
- * uuconf/uucnfi.h: Added prototype for _uuconf_idebug_cmd.
-
-Tue Aug 31 00:09:33 1993 Ian Lance Taylor (ian@airs.com)
-
- * send.c (flocal_send_file_init): Don't set flocal if job was
- requested by a remote user.
- (flocal_send_fail, flocal_send_open_file): Don't save temporary
- file in .Preserve if job was requested by a remote user.
-
- * unix/wldcrd.c (fsysdep_wildcard_start): Don't free zcmd until
- after calling espopen.
-
- * lib/buffer.c (ubuffree): Added debugging code controlled by
- DEBUG_BUFFER macro.
-
-Sun Aug 29 13:33:21 1993 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/tcalou.c: Permit empty password in call file.
-
- * unix/work.c (COMMANDS_PER_SCAN): New macro.
- (fsysdep_get_work_init): Get at most COMMANDS_PER_SCAN new command
- files, to avoid timeouts while reading a large directory.
-
- * rec.c (fremote_send_file_init): Initialize crestart.
-
- * uux.c (main): Changed special handling of single "-" argument to
- call getopt multiple times.
-
- * D.J. James: protg.c (fgsendcmd, fgsenddata), prott.c
- (ftsendcmd): Avoid passing 0 to bzero to avoid SunOS bug.
-
- * protf.c (ffprocess_data): Some systems seem to send characters
- with parity, so strip the parity bit from incoming bytes.
-
- * Kenji Rikitake: uucp.h: Changed order of header files to avoid
- gcc stddef.h vs. sys/stdtypes.h problem on SunOS 4.1.
-
- * Alexander Lehmann: configure.in: Correct misspelling of
- HAVE_GETWD.
-
- * John Hood: unix/filnam.c (ZCHARS): Get the alphabet right.
-
- * Gabor Kiss: tcp.c (ftcp_dial): Use all gethostbyname info before
- calling getservbyname.
-
-Thu Aug 26 23:15:33 1993 Ian Lance Taylor (ian@airs.com)
-
- * uux.c, uuxqt.c: Added long options.
-
- * uucp.c: Added v to getopt_long argument, print help and version
- info to stderr.
-
- * unix/splcmd.c (zsysdep_spool_commands): Create command file via
- temporary file, so that the command file is created atomically.
- * unix/spool.c (zscmd_file): Accept files starting with "TMP".
-
-Sun Jul 25 14:50:41 1993 Ian Lance Taylor (ian@airs.com)
-
- * uupick.c, uustat.c: Added long options.
-
-Mon Jul 19 22:06:19 1993 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c, uuconv.c, uucp.c, uulog.c, uuname.c: Added long
- options.
- * uucico.c (main, fcall): Made -c option not print the ``No work''
- log message.
- * uuname.c (main): Call ulog_uuconf rather than unuuconf_error.
-
-Sun Jul 11 14:29:39 1993 Ian Lance Taylor (ian@airs.com)
-
- * cu.c, uuchk.c: Added long options.
-
- * uudefs.h, log.c (zProgram): Renamed from abProgram.
- * cu.c, uucico.c, uucp.c, uulog.c, uuname.c, uupick.c, uustat.c,
- uux.c, uuxqt.c (main): Initialize zProgram from argv[0].
-
- * Bob Hemedinger: unix/cohtty.c (fscoherent_disable_tty): Almost
- always return TRUE.
- * unix/serial.c (fsserial_lockfile): Skip "LCK.." in string passed
- to lockttyexist and fscoherent_disable_tty.
- * uucico.c (main): If __COHERENT__ is defined, change the meaning
- of -c for backward compatibility with old Coherent UUCP.
-
- * David Nugent: uucico.c (main): Added -C option to only call
- system named by -s or -S if there is work.
-
- * uuconf/syssub.c (_uuconf_isystem_default): Merge in default
- protocol parameters so that setting parameters for one protocol
- does not lose the default settings for other protocols.
-
- * unix/lcksys.c (zssys_lock_name): New function.
- (fsysdep_lock_system, fsysdep_unlock_system): Use it.
-
- * John Plate: uuchk.c (ukshow): Call ukshow_size with the right
- arguments in the called remote case.
-
- * uuconf/remunk.c (uuconf_remote_unknown): use the remote.unknown
- shell script if HDB_CONFIG and no ``unknown'' commands appeared in
- the config file.
-
- * Jim Brownfield: uuconf/vsinfo.c (_uuconf_iv2_system_internal):
- Accept continuation lines in L.sys.
-
- * Marc Evans: unix/serial.c (fsysdep_conn_write, fsysdep_conn_io):
- Add casts to t_snd calls to avoid warnings.
-
- * Julian Stacey: uuchk.c (main): If no information found, say so.
-
- * Ju"rgen Fluk: uulog.c (main): Better error messages for HDB.
-
- * uucico.c (zget_typed_line): If last string ended in \r, ignore
- leading \n.
-
- * Mark E. Mallett: uuconf/time.c (asTdays): Add "none".
-
- * uuconf/hsinfo.c (_uuconf_ihdb_system_internal): Report line
- numbers for syntax errors.
-
-Sat Jul 10 10:28:03 1993 Ian Lance Taylor (ian@airs.com)
-
- Initial hardware flow control support from Peter Wemm:
- * uuconf.h (struct uuconf_modem_port, struct uuconf_direct_port):
- New field uuconf_fhardflow in each structure.
- * unix/serial.c (fsserial_hardflow): New routine. Initially
- supports SunOS and SCO Unix.
- (fsmodem_open, fsdirect_open): Turn on hardware flow control if
- supported by the port.
- (fsserial_set): If CRTFSL is set, don't send XON/XOFF characters.
- * uuconf/hport.c (uuconf_hdb_find_port), uuconf/tportc.c
- (_uuconf_iport_cmd), uuconf/vport.c (uuconf_v2_find_port):
- Initialize uuconf_fhardflow field to TRUE.
- * uuconf/tportc.c (struct asPmodem_cmds, struct asPdirect_cmds):
- Added "hardflow" command.
- * uuchk.c (ikshow_port): Report whether hardware flow control is
- available.
- * uuconv.c (uvwrite_taylor_port): Write out hardware flow control
- information.
-
- * Peter Wemm: protg.c (fgstart), proti.c (fijstart): Report local
- packet and window size as well as remote.
- * rec.c (fremote_send_file_init), send.c (flocal_send_open_file,
- fremote_rec_reply): Report number of bytes being sent or received,
- and restart point if any.
-
- * Peter Wemm: trans.h (struct sdaemon): New fields csent and
- creceived.
- * uucico.c (fcall, faccept_call): Initialize csent and creceived.
- (fdo_call, faccept_call): Report on number of file bytes
- transferred and bytes per second.
- * rec.c (frec_file_end): Record number of bytes received.
- * send.c (fsend_wait_confirm): Record numbers of bytes sent.
- * trans.c (ufailed): Record number of bytes sent or received.
-
- * Peter Wemm: uusched.in, uuto.in: Use #!/bin/sh rather than :.
- Use exec when invoking program.
-
- * uulog.c (main): Don't die if we can't canonicalize the -s
- argument.
-
- * unix/cusub.c (uscu_child): Force the descriptor into blocking
- mode.
-
- Port type pipe support contributed by Marc Boucher:
- * unix/pipe.c: New file. Support routines for pipes.
- * unix/MANIFEST, unix/Makefile.in: Adjusted for new file pipe.c.
- * uuconf.h (enum uuconf_porttype): Added UUCONF_PORTTYPE_PIPE.
- (struct uuconf_pipe_port): New structure.
- (struct uuconf_port): Added uuconf_pipe_port to union.
- * sysh.unx (struct ssysdep_conn): Add fields ord, owr and ipid,
- rename istdout_flags to iwr_flags.
- (fsdouble_{read, write, chat}): New prototypes.
- * conn.h: Prototype for fsysdep_pipe_init.
- * unix/serial.c: Renamed fsstdin_{read, write, chat} to
- fsdouble_{read, write, chat}. Made them non-static. Changed them
- to use ord and owr fields rather than 0 and 1.
- (fsserial_init, fsstdin_open): Initialize ord and owr fields.
- (fsstdin_close, fsblock, fsstdin_reset, fsysdep_conn_io,
- fsstdin_break, fsstdin_set): Use ord and owr fields rather than 0
- and 1.
- * uuconf/tportc.c (asPtype_names): Added "pipe".
- (asPpipe_cmds, CPIPE_CMDS): New array of pipe commands.
- (CCMDS, _uuconf_iport_cmd): Adjusted accordingly.
- * tcp.c (fsysdep_tcp_init), tli.c (fsysdep_tli_init): Initialize
- new ord and owr fields.
- * conn.c (fconn_init): Call fsysdep_pipe_init for
- UUCONF_PORTTYPE_PIPE.
- * unix/cusub.c (zsport_line, uscu_child, fsysdep_shell): Handle
- UUCONF_PORTTYPE_PIPE.
- * uuchk.c (ikshow_port): Report on port type pipe.
- * uuconv.c (uvwrite_taylor_port): Write out port type pipe.
-
- * Marc Boucher: cu.c: (main, ucuabort): Use new variable
- fCuconnprinted to avoid printing ZDISMSG if ZCONNMSG has not been
- printed.
- (main): Call fsysdep_port_access only after we have locked the
- port, to get a better error message on systems with shared lines.
-
- * Marc Boucher: policy.h (HAVE_FULLDUPLEX_PIPES): New macro.
- * unix/spawn.c (ixspawn): Use it.
-
- * Marc Boucher: uucico.c (uusage): Added lines for -c and -D.
-
- * uuconf/time.c (_uuconf_itime_parse): Add casts to avoid a
- compiler warning.
-
- * uustat.c (fsworkfile_show): Don't report non-existent send
- files.
-
- * lib/parse.c (fparse_cmd): Accept any base for the mode argument,
- rather than always using 8. Depend upon the leading zero to
- indicate base 8. Accomodates UFGATE 1.03.
-
-Wed Jun 30 00:27:27 1993 Ian Lance Taylor (ian@airs.com)
-
- * uudefs.h (struct scmd): Changed bdummy field to bgrade.
- * trans.c (fqueue_send): Sort sends by whether they are a command
- and then by grade.
- * unix/work.c (asSwork_files): Renamed from azSwork_files, made
- array of struct ssfilename rather than char *.
- (struct ssfile): Added bgrade field.
- (iswork_cmp, fsysdep_get_work_init, usysdep_get_work_freed):
- Changed accordingly.
- (fsysdep_get_work): Set qcmd->bgrade.
- * uucp.c (uccopy), uux.c (main, uxadd_send_file), uuxqt.c
- (uqdo_xqt_file), xcmd.c (fremote_xcmd_init), lib/parse.c
- (fparse_cmd): Initialize bgrade field of scmd structure.
-
-Sun Jun 27 23:21:33 1993 Ian Lance Taylor (ian@airs.com)
-
- * send.c (flocal_send_await_reply, flocal_send_cancelled): If the
- first D. file being sent for a faked E command fails, send the
- second one anyhow.
-
-Sun Jun 6 23:07:33 1993 Ian Lance Taylor (ian@airs.com)
-
- * proti.c (fiprocess_data): If we get a packet we sent a NAK for,
- forget that sent NAKs for all preceding packets.
- (fiprocess_packet): If we get a NAK for the packet we are about to
- send, and all our packets have been acknowledged, send an ACK.
-
-Thu Jun 3 20:54:55 1993 Ian Lance Taylor (ian@airs.com)
-
- * prot.h (struct sprotocol): Added frestart field.
- * uucico.c (asProtocols): Initialize frestart field.
- * system.h, unix/opensr.c (zsysdep_receive_temp): Added frestart
- argument to zsysdep_receive_temp.
- * rec.c (flocal_rec_send_request, fremote_send_file_init,
- frec_file_end): Pass frestart argument to zsysdep_receive_temp.
- * unix/opensr.c (esysdep_open_receive): Permit pcrestart argument
- to be NULL.
- * rec.c (flocal_rec_await_reply, fremote_send_file_init): Pass
- pcrestart argument to esysdep_open_receive as NULL if file
- tranfers can not be restarted.
-
- * lib/status.c (azStatus): Uwe Doering: If SPOOLDIR_HDB or
- SPOOLDIR_SVR4, use the same strings they use.
- * unix/status.c (aiMapstatus): Uwe Doering: Swap 4 and 20.
-
- * unix/serial.c (fsserial_open): Uwe Doering: Set VTIME to 1.
-
- * uucico.c (faccept_call, uaccept_call_cleanup): Uwe Doering: Free
- and unlock evertyhing after any return from faccept_call.
- (main): Don't need to unlock after faccept_call here any more.
-
- * proti.c (fiprocess_data): Added additional debugging
- information.
-
-Sat May 15 13:55:21 1993 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgprocess_data): Don't treat a duplicate RR as an RJ if
- we are retransmitting packets. If we are treating a duplicate RR
- as an RJ, don't also treat it as an acknowledgement.
-
- * unix/serial.c (fsysdep_conn_io): Typo in debugging message.
-
-Tue May 4 00:03:32 1993 Ian Lance Taylor (ian@airs.com)
-
- * uux.c (main): Andreas Raab: Move aboptions out of local block
- since a pointer to it escapes the scope.
-
- * unix/mkdirs.c: W Christopher Martin: Just try to make the
- directories, and ignore EEXIST errors, rather than first checking
- whether the directory exists.
-
- * send.c (flocal_send_request): Chip Salzenberg: Double check that
- the file still exists before sending the S command.
-
- * uucico.c (zget_uucp_cmd, zget_typed_line), trans.c (fgot_data):
- Matthew Geier: Avoid doing memcpy (z, NULL, 0).
-
-Mon May 3 22:52:46 1993 Ian Lance Taylor (ian@airs.com)
-
- * system.h, unix/locfil.c, unix/cwd.c, unix/picksb.c: Johan
- Vromans: Added pfbadname argument to zsysdep_local_file,
- zsysdep_local_file_cwd, zsysdep_uupick_local_file.
- * Changed all callers.
- * send.c (fremote_rec_file_init), rec.c (fremote_send_file_init):
- If remote system gives bad name, return an error rather than
- aborting the connection.
- * uuxqt.c (uqdo_xqt_file): If bad file name, abort execution
- rather than try again later.
- * uupick.c (main): If bad file name, permit new command rather
- than exiting.
-
- * lib/debug.c: Stephan Niemz: Accept whitespace separated
- debugging types.
-
- * unix/detach.c: Always use setsid if it is available.
-
-Sun May 2 13:23:33 1993 Ian Lance Taylor (ian@airs.com)
-
- * unix/spool.c (zsfind_file): Fix handling of execution file
- names for systems to work with any possible execution file name.
-
- * send.c (flocal_send_open_file): Subtract starting position from
- number of bytes passed to pffile.
-
- * uuconf/rdperm.c: Syd Weinstein: Don't skip lines in Permissions
- with leading whitespace.
-
- * uuconf/vsinfo.c: Gero Kuhlmann: Set default retry time
- correctly.
-
- * unix/lock.c (fsdo_lock): Andrew Vignaux: Handle readonly lock
- files correctly.
-
- * send.c (flocal_send_fail, flocal_send_await_reply): James Van
- Artsdalen: Clarify error messages relating to execution files.
-
- * log.c (ustats): Avoid overflow in bytes/sec calculation.
-
-Sat May 1 17:40:14 1993 Ian Lance Taylor (ian@airs.com)
-
- * trans.c (ftadd_cmd): Don't treat junk at end of command as a
- size if the remote system doesn't support sizes.
-
- * uucico.c (faccept_call): Turn on the protocol before reading the
- queue, in case there are lots of command files.
-
- * unix/cusub.c: Julian Stacey: If SIGUSR2 is not defined, use
- SIGURG instead.
-
- * uuconf/syshdr.unx (MAKE_ABSOLUTE): New macro.
- * uuconf/tinit.c (itaddfile): Renamed from itadd. Use
- MAKE_ABSOLUTE to force absolute pathnames to configuration files.
-
- * conn.c (fconn_close): Steve M. Robbins: Ignore any SIGHUP
- received after closing the connection.
-
- * cu.c (main): Frank Conrad: When an alternate fails, move on to
- the next one.
-
- * uucico.c (faccept_call): Alexei K. Yushin: Supposedly some
- UUCP's send UgG rather than just Ug.
-
- * unix/serial.c (fsserial_lockfile): Bob Hemedinger: Fix error
- message in HAVE_COHERENT_LOCKFILES case.
-
- * unix/mkdir.c: Andy Fyfe: Pass fkeepuid as TRUE to ixsspawn.
-
- * unix/strerr.c: Undefine strerror in case there is a macro
- definition which configure did not pick up.
-
- * configure.in: Andy Fyfe: AT&T 3b1 has sys/mount.h but not
- statfs.
-
- * uudir.c: Andy Fyfe: Include uucp.h.
-
- * unix/fsusg.c: Andy Fyfe: Typos in (untested) STAT_USTAT case.
-
- * unix/filnam.c: Eric Lee Green: Avoid generating filenames that
- only differ in case, to make life easier for bad filesystems.
-
- * uuconf/llocnm.c: Brian J. Murrell: Don't read HDB files if
- ``hdb-files no'' given.
-
-Sat Mar 20 16:10:20 1993 Ian Lance Taylor (ian@airs.com)
-
- * uudefs.h (eSendfile, eRecfile): Deleted obsolete declarations.
-
-Sat Feb 13 15:57:30 1993 Ian Lance Taylor (ian@airs.com)
-
- * Released version 1.04.
-
- * unix/detach.c: Andrew A. Chernov: Don't check return of setsid.
-
-Sun Jan 31 01:45:56 1993 Ian Lance Taylor (ian@airs.com)
-
- * cu.c (main): Pass "cu" to uuconf_init.
-
- * protz.c (fzprocess): Restore ZPAD char before calling getinsync.
-
-Sat Jan 30 22:19:26 1993 Ian Lance Taylor (ian@airs.com)
-
- * Makefile.in (doc-dist): New target.
-
-Wed Jan 27 22:55:26 1993 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgstart): Set iGremote_segsize when using
- remote-packet-size.
-
-Tue Jan 26 01:01:34 1993 Ian Lance Taylor (ian@airs.com)
-
- * proti.c (fiprocess_data): always send an ACK after receiving
- half a window, rather than sometimes resending a packet. Half a
- window of short packets can arrive very quickly.
-
- * tstuu.c (main, cread, fsend): rewrote communication routines to
- avoid deadlock.
-
-Sun Jan 24 01:02:47 1993 Ian Lance Taylor (ian@airs.com)
-
- * trans.c (ufailed): don't report statistics if no bytes
- transferred.
-
- * Makefile.in (install): simplified somewhat.
- (dist): distribute the sample directory.
-
-Sat Jan 23 19:47:12 1993 Ian Lance Taylor (ian@airs.com)
-
- * configure.in, conf.h.in, tli.c: Karl Swarz: check for and use
- <sys/tli.h>.
-
-Fri Jan 22 00:09:37 1993 Ian Lance Taylor (ian@airs.com)
-
- * send.c (flocal_send_request): Alan Judge: don't send C in option
- string when faking an E command as an S command.
-
-Thu Jan 21 00:09:31 1993 Ian Lance Taylor (ian@airs.com)
-
- * uux.c (main): don't use E command if forwarding.
-
-Wed Jan 20 00:22:38 1993 Ian Lance Taylor (ian@airs.com)
-
- * send.c (fsend_exec_file_init), rec.c (frec_file_end), uux.c
- (main): Chip Salzenberg: always put the C line last in an
- execution file, to support Fredmail.
-
-Tue Jan 19 00:09:43 1993 Ian Lance Taylor (ian@airs.com)
-
- * trans.h, trans.c (ftcharge, floop, fgot_data): rewrote timing
- code.
-
- * trans.h, trans.c, send.c, rec.c, xcmd.c, protf.c, protz.c
- (fqueue_local, fqueue_remote, fqueue_send, fqueue_receive): added
- boolean return value and qdaemon argument.
-
-Mon Jan 18 00:01:46 1993 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fdo_call, faccept_call): Ted Lindgreen, Chip
- Salzenberg: wait for remote hangup string before hanging up.
-
- * proti.c (fiprocess_data, fiprocess_packet): stop scanning input
- buffer after a CLOSE packet.
-
-Sat Jan 16 22:44:28 1993 Ian Lance Taylor (ian@airs.com)
-
- * system.h, uucico.c (main), uuxqt.c (main), unix/init.c: Ted
- Lindgreen: eliminated INIT_DAEMON.
-
- * log.c (ulog): don't log SIGINT if fLog_sighup is FALSE.
-
- * unix/move.c (fsysdep_move_file), unix/xqtsub.c
- (fsysdep_move_uuxqt_files): the system call rename seems to fail
- on some systems for arbitrary reasons, so always try to copy the
- file by hand, not just if we get EXDEV.
-
- * policy.h, unix/pause.c: Gregory Gulik: added HAVE_HUNDREDTHS_NAP
- configuration parameter.
-
-Wed Jan 6 21:06:45 1993 Ian Lance Taylor (ian@airs.com)
-
- * unix/serial.c (fsserial_lockfile): create HDB lock files when
- using HAVE_COHERENT_LOCKING.
- unix/cohtty.c (fscoherent_disable_tty): consistently return FALSE
- on error.
-
- * unix/cusub.c (fsysdep_terminal_raw): Andrew A. Chernov: if
- POSIX_TERMIOS, turn of IEXTEN flag.
-
-Sat Jan 2 23:19:27 1993 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgprocess_data): treat a duplicate RR as an RJ.
-
-Fri Jan 1 11:17:30 1993 Ian Lance Taylor (ian@airs.com)
-
- * policy.h, unix/proctm.c: Steven S. Dick: use sysconf
- (_SC_CLK_TCK) for TIMES_TICK if possible.
-
- * uuconf/diacod.c: Gregory Gulik: accept an empty dialcode string.
-
- * system.h, uucico.c (main), uucp.c (main), uux.c (main),
- unix/run.c: Karsten Thygesen: removed ffork argument from
- fsysdep_run.
-
-Wed Dec 30 00:21:55 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/link.c: Andrey G Blochintsev: don't fail just because
- destination directories do not exist.
-
- * send.c (flocal_send_open_file): Scott Ballantyne: record file
- name when logging send of execution command.
-
- * protz.c: Chip Salzenberg: reformatted to 80 columns.
-
-Tue Dec 29 23:50:52 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconv.c (uvwrite_time): scott@geom.umn.edu: handle midnight
- more correctly.
-
-Fri Dec 18 00:49:16 1992 Ian Lance Taylor (ian@airs.com)
-
- * system.h, uucp.c (uccopy), uux.c (main), cu.c (icuput, icutake),
- unix/ufopen.c (esysdep_user_fopen): Doug Evans: open files used
- for %put and %take using esysdep_user_fopen, rather than with
- privileges of uucp. Added frd and fbinary arguments to
- esysdep_user_fopen.
-
-Thu Dec 17 00:04:53 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/picksb.c (zsysdep_uupick): Peter Wemm: allocation error.
-
- * uupick.c (main): Peter Wemm: pass INIT_GETCWD to
- usysdep_initialize; really quit if 'q' is typed.
-
- * uulog.c (main): Peter Wemm: always canonicalize system name, not
- just if using HDB_LOGGING.
-
- * uudefs.h, log.c (ustats), trans.c (ufailed), send.c
- (fsend_await_confirm), rec.c (frec_file_end): Peter Wemm: added
- fmaster argument to ustats, used only in HDB_LOGGING.
-
-Wed Dec 16 23:35:51 1992 Ian Lance Taylor (ian@airs.com)
-
- * uustat.c (main): Marc Unangst: forgot to call strtol for -y.
-
- * policy.h, sysh.unx: Brian J. Murrell: yet another configuration
- parameter: HAVE_BROKEN_SETREUID.
-
-Tue Dec 15 00:13:04 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconv.c (uvwrite_taylor_system): mnichols@pacesetter.com: use
- command-path rather than path.
-
- * trans.c (floop): Marc Unangst: don't clear frequested_hangup if
- we didn't manage to hang up.
-
- * uucp.h, rec.c (fremote_send_file_init): Oleg Girko: patches to
- make code compile if USE_STDIO is 0.
-
- * unix/proctm.c: Tim Peiffer: reverse sense of TIMES_TICK check in
- hopes of avoiding ISC preprocessor bug.
-
- * unix/fsusg.h, unix/fsusg.c, unix/bytfre.c, system.h, conf.h.in,
- configure.in, unix/Makefile.in, unix/MANIFEST: use new disk space
- checking routines from GNU fileutils 3.4.
- * unix/opensr.c (zsysdep_receive_temp): don't check free space
- here any more.
- * policy.h, trans.h, trans.c, rec.c, uucico.c, uudefs.h: Chip
- Salzenberg: check amount of remaining space on disk every
- FREE_SPACE_DELTA bytes, and abort the file transfer if disk space
- gets too low.
-
-Wed Dec 2 00:24:12 1992 Ian Lance Taylor (ian@airs.com)
-
- * policy.h, unix/serial.c (fsserial_set): Frank Conrad: added
- HAVE_PARITY_BUG parameter for the Sony NEWS.
-
-Mon Nov 30 00:06:59 1992 Ian Lance Taylor (ian@airs.com)
-
- * lib/spool.c (fspool_file): Andrew Chernov: accept any
- alphanumeric character in the name, because it could be a grade
- from another system.
-
-Sun Nov 29 22:36:47 1992 Ian Lance Taylor (ian@airs.com)
-
- * lib/buffer.c (ubuffree): scott@geom.umn.edu, Richard Gumpertz:
- use a temporary variable to hold the offsetof result.
-
- * configure.in: scott@geom.umn.edu: define HAVE_SYS_SELECT_H
- correctly.
-
- * protg.c (fgsend_control): Niels Baggesen: report all non-RR
- packets if DEBUG_ABNORMAL.
-
- * unix/cusub.c (uscu_child): Ed Carp: apparently the read and
- write calls can get EAGAIN on some systems.
-
- * unix/status.c (fsysdep_get_status, fsysdep_set_status): Chip
- Salzenberg: map status values when using SPOOLDIR_HDB.
-
- * rec.c (fremote_send_reply): do file restart correctly for E
- commands.
-
-Sun Nov 22 15:09:43 1992 Ian Lance Taylor (ian@airs.com)
-
- * protz.c: Chip Salzenberg: always do bitwise operations on
- unsigned values.
-
- * getopt.h: Chip Salzenberg: don't rely on __STDC__.
-
-Thu Nov 19 00:13:46 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/freblk.c: Niels Baggesen: loop over the right list.
-
- * uulog.c (main): Peter Wemm: added -D, -F and -S options, made -f
- take an argument and default to showing 10 current lines.
- (ulusage): added new options and missing old ones.
-
-Wed Nov 18 22:26:36 1992 Ian Lance Taylor (ian@airs.com)
-
- * rec.c (frec_file_end): Andrey G Blochintsev: call
- fsysdep_remember_reception as soon as the file has been moved to
- the final destination; write fake execution file via a temporary
- file to prevent uuxqt from getting at it early.
- * trans.c (usent_receive_ack): don't call
- fsysdep_remember_reception here.
-
- * unix/tmpfil.c (ZDIGS): don't use '.', since we use it to
- separate parts of the file name.
-
-Sun Nov 15 15:31:49 1992 Ian Lance Taylor (ian@airs.com)
-
- * uustat.c (fsquery_show, csunits_show): Marc Unangst, Chip
- Salzenberg: line up uustat -q output.
-
- * sysh.unx, ftw.c (ftw_dir, ftw), srmdir.c (isremove_dir), walk.c
- (iswalk_dir): Marc Unangst: stat argument to function argument to
- ftw is const.
-
- * unix/serial.c (fsserial_set): Mike Bernson: set CSIZE correctly
- when changing parity.
-
- * uux.c (main): Andrew A. Chernov: check for executions which name
- the local system, to handle dumb mailers.
-
- * uucp.h: Doug Evans: #undef strerror if HAVE_STRERROR is 0, to
- avoid macro definition on Xenix.
-
- * unix/serial.c (fsserial_set): Peter Wemm: only check CRTSCTS if
- HAVE_POSIX_TERMIOS.
-
- * cu.c (main): Peter Wemm: use alternates for systems if a call
- fails.
-
- * tstuu.c (uprepare_test): Gerben Wierda: set execute bits for
- Chat1 and Chat2.
-
- * trans.c (floop): Marc Unangst: don't hang up when requested
- unless the send queue is empty.
-
- * uuxqt.c (iqrequestor): Marc Boucher: new function to accept R
- command with two arguments, as generated by UUPC.
-
- * uucico.c (faccept_call): Christian Seyb: don't free the system
- info until after writing the status.
-
- * configure.in: Marc Boucher: check -lsocket and -lnsl together.
-
- * unix/portnm.c: Stephen J. Walick: it's types.tcp.h, not
- tcp.types.h.
-
- * configure.in: Brian Campbell: check for /usr/bin/mailx.
-
-Sat Nov 14 11:11:04 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/hlocnm.c (uuconf_hdb_login_localname): Christian Seyb:
- check for _uuconf_unset as well as NULL.
-
- * conn.c (fconn_dial): initialize *ptdialerfound.
-
- * many files: rearranged header files to include "sysdep.h" before
- system header files. Also eliminated various pedantic warnings,
- and made _uuconf_unset char * to avoid possible alignment
- problems.
-
-Tue Nov 10 00:16:35 1992 Ian Lance Taylor (ian@airs.com)
-
- * trans.h, uucico.c (fcall, faccept_call), trans.c (uclear_queue,
- floop): Stephen J. Walick: move clean up from end of floop into
- uclear_queue, and call it instead of just doing
- usysdep_get_work_free.
-
- * unix/serial.c (fsserial_lockfile): Marc Unangst: bad #endif
- location for HAVE_SVR4_LOCKFILES.
- (fsserial_init): Doug Evans: null terminate the device name.
-
-Sun Nov 8 10:58:59 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fcall, faccept_call): Stephen J. Walick: call
- usysdep_get_work_free here.
- trans.c (floop): don't call usysdep_get_work free here.
-
-Sun Nov 1 17:05:07 1992 Ian Lance Taylor (ian@airs.com)
-
- * Released gamma version 1.04.
-
- * configure.in: check that sys/select.h and sys/time.h work
- together, since that's how they are currently used.
-
- * cu.c, uustat.c, uuconf/diacod.c: add casts to eliminate
- warnings.
-
- * configure.in: don't add strlwr to LIBOBJS.
-
- * policy.h, unix/cohtty.c: Bob Hemedinger: finish Coherent style
- locking.
-
-Wed Oct 28 00:20:15 1992 Ian Lance Taylor (ian@airs.com)
-
- * tstuu.c: Ralf Stephan: check HAVE_POLL_H and HAVE_STROPTS_H.
-
- * Nickolay Saukh: accept SVR4 style R request file position.
- uudefs.h: added ipos field to struct scmd.
- lib/parse.c: accept SVR4 style R request with file position to
- start from.
- send.c (fremote_rec_file_init): start transferring file from
- requested position.
- uucp.c, uux.c, uuxqt.c, xcmd.c: initialize ipos field.
-
-Sun Oct 25 10:39:23 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/serial.c (fsysdep_conn_write, fsysdep_conn_io): T. William
- Wells: take special care to ensure we don't write after SIGHUP.
-
- * policy.h, sysh.unx, unix/MANIFEST, unix/Makefile.in,
- unix/serial.c (fsserial_lockfile), unix/cohtty.c (new file): Bob
- Hemedinger: added HAVE_COHERENT_LOCKFILES.
-
- * unix/cusub.c (uscu_child): Igor V. Semenyuk: accept a 0 return
- from read until we have read some data at some point.
-
-Thu Oct 22 10:38:32 1992 Ian Lance Taylor (ian@airs.com)
-
- * proti.c: various tweaks for bad connections.
-
- * uucp.h: T. William Wells: rename strcasecmp and strncasecmp, if
- the system doesn't provide them, to avoid the ANSI C name space.
-
- * lib/buffer.c: Bob Hemedinger: put ab in union so that offsetof
- will not take the address of an array.
-
- * uuxqt.c (uqdo_xqt_file): Bob Hemedinger: don't take address of
- array.
-
-Wed Oct 21 00:05:31 1992 Ian Lance Taylor (ian@airs.com)
-
- * uustat.c (fsnotify): Gert Doering: if the file appears to be
- binary, don't include it in any mail message.
-
- * unix/mkdir.c: Michael Yu.Yaroslavtsev: check whether directory
- already exists before spawning /bin/mkdir.
-
- * proti.c: Michael Yu.Yaroslavtsev: iIsendpos and iIrecpos should
- be long.
-
- * send.c (flocal_send_await_reply): Gert Doering: improved error
- messages.
-
- * tli.c, unix/detach.c: include "sysdep.h" before <sys/ioctl.h>.
-
- * configure.in, conf.h.in: added some system specific checks
- provided by autoconf.
-
- * tstuu.c, unix/serial.c: Merlyn LeRoy: check for ENODATA as well
- as EAGAIN and EWOULDBLOCK.
-
- * uucico.c (faccept_call): Zacharias J. Beckman: if calling back,
- clear status first.
-
- * uucico.c (fdo_call, faccept_call): Hans-Dieter Doll: avoid
- overflow when turning ulimit value into bytes.
-
-Tue Oct 20 23:12:26 1992 Ian Lance Taylor (ian@airs.com)
-
- * serial.c (fsmodem_carrier): Hans-Dieter Doll: use IS68K LNOMDM
- bit if available.
-
- * chat.c (fcsend): Hans-Dieter Doll: advance z after EOT.
-
- * cu.c: T. William Wells: beep on connected and disconnected
- messages (only if ANSI_C, to use \a).
-
- * unix/run.c: Peter Wemm: pass fsetuid as TRUE to ixsspawn.
-
-Sun Oct 18 13:58:17 1992 Ian Lance Taylor (ian@airs.com)
-
- * policy.h, unix/serial.c (fsmodem_close): Stephen J. Walick:
- added HAVE_RESET_BUG for SCO Xenix.
-
- * configure.in: Igor V. Semenyuk: avoid looking in -linet for
- getline, since ISC has a different function there by that name.
-
- * unix/ufopen.c: Igor V. Semenyuk: handle unsigned uid_t.
-
-Sat Oct 17 11:00:30 1992 Ian Lance Taylor (ian@airs.com)
-
- * conf.h.in, configure.in, uucp.h, unix/serial.c
- (fsserial_lockfile), lib/MANIFEST: eliminated strlwr.
-
-Fri Oct 16 01:10:56 1992 Ian Lance Taylor (ian@airs.com)
-
- * Igor V. Semenyuk: uuchk.c (ukshow): print max-remote-debug
- correctly.
- lib/debug.c (idebug_parse): accept DEBUG_NONE.
-
-Thu Oct 15 00:49:58 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/cusub.c (fsysdep_terminal_puts): don't modify zalc before
- freeing it up.
-
- * protg.c (fgcheck_errors, fggot_ack, fgprocess_data): Mark E.
- Mallett: better handling of error decay.
-
-Wed Oct 14 22:09:20 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/lock.c: Tomi Vainio: make sure SEEK_SET is defined.
-
- * tcp.c (ftcp_dial): print a better error message if gethostbyname
- doesn't set errno.
-
- * Stephen J. Walick: configure.in, conf.h.in: check for
- <sys/types.tcp.h>.
- tcp.c, unix/opensr.c: include <sys/types.tcp.h> if available.
- lib/debug.c, unix/portnm.c, uuconf/int.c, uuconf/llocnm.c,
- uuconf/time.c: cast more arguments to eliminate more warnings.
-
-Tue Oct 13 00:25:03 1992 Ian Lance Taylor (ian@airs.com)
-
- * prot.h, proti.c (fistart, fijstart), protj.c, uucico.c, tstuu.c
- (uprepare_test), Makefile.in, MANIFEST: added 'j' protocol.
-
-Sun Oct 11 23:45:20 1992 Ian Lance Taylor (ian@airs.com)
-
- * policy.h, unix/serial.c (fsserial_set): added HAVE_STRIP_BUG to
- policy.h to get around stupid Ultrix bug.
-
- * sysh.unx, unix/cusub.c, unix/serial.c (fsserial_open): for
- HAVE_BSD_TTY, keep tchars and ltchars in the sterminal structure,
- and in fsserial_open disable all interrupt characters.
-
-Sat Oct 10 01:18:31 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/tinit.c (itunknown): Gert Doering: don't save "unknown"
- with the other arguments.
-
-Fri Oct 9 00:56:43 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/lock.c: check for running process before doing kill.
-
-Thu Oct 8 00:20:12 1992 Ian Lance Taylor (ian@airs.com)
-
- * chat.c, protf.c, send.c, rec.c, unix/locfil.c: Stephen J.
- Walick: cast arguments to strtol and strcspn to avoid warnings.
-
- * uustat.c (fsnotify): Marc Boucher: don't free string from
- uuconf_localname, and only prepend remote system name to execution
- requests, not to local UUCP commands.
-
- * unix/lock.c (fsdo_lock): Marc Boucher: set fret to TRUE before
- going around the loop again.
-
- * uucico.c: Marc Boucher: use 'a' protocol before 'g'.
-
- * unix/spool.c (zsfind_file): Matthias Zepf: fixed typos for
- SPOOLDIR_BSD*.
-
-Wed Oct 7 00:03:08 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuname.c (main): Marc Boucher: reverse sense of -a, and do not
- display aliases by default.
-
- * uucico.c (fdo_call): Marc Boucher: some systems only provide 14
- characters in the Shere line.
-
- * tstuu.c (main): Marc Boucher: add support for STREAMS ptys.
-
-Tue Oct 6 23:16:15 1992 Ian Lance Taylor (ian@airs.com)
-
- * policy.h: Marc Boucher: improve comments to describe SVR4.
-
- * chat.c (fcsend, fcecho_send, fcecho_send_strip,
- fcecho_send_nostrip): Marc Boucher: don't send CR after BREAK or
- EOT, and let chat-seven-bit apply to echo checking.
-
- * uuname.c (main): Andreas Vogel: usysdep_exit (TRUE) rather than
- usysdep_exit (EXIT_SUCCESS).
-
-Mon Oct 5 22:59:51 1992 Ian Lance Taylor (ian@airs.com)
-
- * sysh.unx, unix/serial.c (fsserial_init): Marc Boucher: avoid
- freeing unallocated string.
-
- * unix/serial.c (fsmodem_carrier): Peter Wemm: eliminated useless
- undeclared variable which only appeared if HAVE_CLOCAL_BUG.
-
- * cu.c (main): don't require carrier when opening a direct line.
- (fcudo_cmd, fcudo_subcmd, uculist_fns, icuunrecogfn): T. William
- Wells: give reasonable error messages.
-
-Sun Oct 4 00:03:10 1992 Ian Lance Taylor (ian@airs.com)
-
- * */Makefile.in: T. William Wells: use ar qc rather than ar rc.
-
- * many: T. William Wells: renamed isysdep_* functions to
- ixsysdep_*, and renamed isfork, isspawn, and isswait similarly, to
- avoid ANSI C namespace restrictions.
-
- * uucp.h: T. William Wells: default size_t to unsigned, not int.
-
- * configure.in: T. William Wells: new definition for
- AC_RETSIGTYPE.
-
- * configure.in: T. William Wells: test for sh builtin echo.
- conf.h.in: default ECHO_PROGRAM to undefined.
-
- * proti.c (fiprocess_data, fiprocess_packet): fix confusion
- between iIremote_winsize and iIrequest_winsize.
-
- * proti.c (fiwindow_wait, fisenddata): wait for a window opening
- before sending SPOS.
-
- * proti.c (fiprocess_data): don't send a NAK for a duplicate of
- the most recent packet.
-
- * configure.in: Stephen J. Walick: don't use AC_PREFIX, check for
- /usr/bin/mail.
-
- * system.h, sysh.unx, send.c (flocal_send_file_init,
- fsend_exec_file_init), rec.c (flocal_rec_file_init,
- fremote_send_file_init, frec_file_end), xcmd.c
- (fremote_xcmd_init), uuxqt.c (uqdo_xqt_file, uqcleanup), uux.c
- (main, uxadd_send_file), uucp.c (main, uccopy), uustat.c
- (fsworkfile_show, fsexecutions, fsnotify), unix/filnam.c
- (zsfile_name, zsysdep_data_file_name, zsysdep_xqt_file_name),
- unix/jobid.c (zsfile_to_jobid, zsjobid_to_file), unix/splcmd.c
- (zsysdep_spool_commands), unix/splnam.c (zsysdep_spool_file_name),
- spool.c (zsfind_file), statsb.c (fskill_or_rejuv,
- isysdep_work_time), work.c (fswork_file, fsysdep_get_work,
- zsysdep_jobid, bsgrade): Marc Unangst, Brian Murrell: Corrected
- support for SPOOLDIR_SVR4, since SVR4 doesn't use grades in file
- names. Changed flocal argument to pseq argument in
- zsysdep_spool_file_name, and changed flocal argument to bgrade
- argument in zfind_file. Added fxqt argument to
- zsysdep_data_file_name. Added bsgrade function. Added bgrade
- argument to zsfile_to_jobid, and pbgrade argument to
- zsjobid_to_file.
-
-Sat Oct 3 11:03:13 1992 Ian Lance Taylor (ian@airs.com)
-
- * MANIFEST, Makefile.in, lib/MANIFEST, lib/Makefile.in,
- lib/parse.c: moved parse.c from main directory to lib.
-
- * system.h, unix/size.c, unix/Makefile.in, unix/MANIFEST: moved
- csysdep_size into its own file, made it return -1 if the file does
- not exist or -2 on other errors.
- uustat.c (fsworkfile_show): handle errors from csysdep_size.
- send.c (flocal_send_file_init): handle errors from csysdep_size,
- removed unneeded calls to fsysdep_file_exists.
-
- * trans.c (flocal_poll_file), tcp.c (ftcp_dial): Bob Cunningham:
- declare functions consistently static.
-
- * Makefile.in: Marc Unangst: don't run config.status
- unnecessarily.
-
- * configure.in: Marc Unangst: check for socket and t_open in
- -lsocket, -lnsl and -lxti.
-
- * uuconf/cmdarg.c: check first character to avoid calls to
- strcmp or strcasecmp.
-
-Thu Oct 1 23:44:24 1992 Ian Lance Taylor (ian@airs.com)
-
- * trans.h, uucico.c (fdo_call, faccept_call), parse.c
- (fparse_cmd), send.c (flocal_send_request): Gert Doering: SVR4
- UUCP uses a dummy string between the notify field and the size,
- for some reason.
-
- * tstuu.c (main, uprepare_test): added -n switch to not destroy
- existing configuration files.
-
-Fri Sep 25 00:16:35 1992 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgsenddata): T. William Wells: clear bytes correctly so
- that resending a packet doesn't get a completely incorrect size.
-
- * send.c (usadd_exec_line): Stephen J. Walick: don't send trailing
- spaces on the created execute file, because it confuses Waffle.
-
-Thu Sep 24 00:25:18 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/jobid.c (zsjobid_to_file): Franc,ois Pinard: if the job ID
- is too short, return NULL rather than dumping core.
- unix/statsb.c (fskill_or_rejuv, isysdep_work_time): handle a NULL
- return from zsjobid_to_file.
-
-Mon Sep 21 09:01:02 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/init.c, uuconf/syssub.c: Lele Gaifax: moved
- declaration of _uuconf_unset from syssub.c to addstr.c because
- NeXT linker does not pull in object files solely because of
- variable declarations.
-
- * sysh.unx: Lele Gaifax: typo in ftw declaration.
-
- * lib/Makefile.in, unix/Makefile.in: Lele Gaifax: bug in clean
- target.
-
-Thu Sep 17 01:01:13 1992 Ian Lance Taylor (ian@airs.com)
-
- * Released beta version 1.04.
-
-Wed Sep 16 01:02:55 1992 Ian Lance Taylor (ian@airs.com)
-
- * uux.c (main): null terminate the options list for an 'E'
- command.
-
- * ustat.c (fsexecutions): allow privileged users to kill remote
- execution files, and handle local executions correctly.
-
- * uuconf/hinit.c: added parens to avoid warning.
-
- * unix/splcmd.c: cast to avoid warning.
-
- * unix/serial.c (fsmodem_close): fixed HAVE_SYSV_TERMIO typo.
-
- * trans.c (uqueue_receive, floop, fgot_data): improved timing code
- to make fewer system calls.
-
- * send.c (fsend_exec_file_init, fsend_exec_file): handle separate
- E file correctly, and make a good statistics file entry for it.
-
- * Makefile.in, unix/Makefile.in, uuconf/Makefile.in,
- lib/Makefile.in: use -I flags to permit compilation in a separate
- directory. Set up clean targets per GNU standards.
-
-Tue Sep 15 00:07:09 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (zget_uucp_cmd): can't set size_t variable to -1.
-
- * Makefile.in (install): don't install info files. Added new
- targets info and install-info.
-
-Mon Sep 14 13:19:42 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuxqt.c (main): Gregory Bond: canonicalize the system name given
- by the -s argument.
-
- * system.h, uuconf.h, uucico.c (faccept_call), unix/unknwn.c,
- unix/Makefile.in, unix/MANIFEST, uuconf/syshdr.unx,
- uuconf/remunk.c, uuconf/hrmunk.c, uuconf/Makefile.in,
- uuconf/MANIFEST: support HDB remote.unknown shell script.
-
- * protg.c (igchecksum, igchecksum2): Inspired by Mark Pizzolato,
- put in new, improved checksum routines.
-
- * uuxqt.c (uqdo_xqt_file): make sure the execution file still
- exists after locking it.
-
- * unix/lock.c (fsdo_lock): don't fail if the lock file is removed
- between the link and the open.
-
- * unix/xqtsub.c (fsysdep_execute, fsysdep_lock_uuxqt_dir,
- fsysdep_unlock_uuxqt_dir, fsysdep_move_uuxqt_files): use .Xqtdir
- for first uuxqt execution, not .Xqtdir0000.
-
-Sun Sep 13 11:51:22 1992 Ian Lance Taylor (ian@airs.com)
-
- * trans.h, uucico.c (fdo_call, faccept_call), send.c
- (flocal_send_request), rec.c (flocal_rec_send_request) parse.c
- (fparse_cmd): send file size in hex for SVR4 compatibility.
- Required new FEATURE_V103 for 1.03 backward compatibility, since
- 1.03 requires decimal size.
-
- * various: eliminated remaining calls to alloca.
-
- * tcp.c (ftcp_open), tli.c (ftli_open): set FD_CLOEXEC for sockets
- and TLI descriptors.
-
- * tcp.c (ftcp_open): switch to real user ID before binding the
- socket when running as a server. This will permit uucico invoked
- by root to open privileged TCP ports. Don't switch to real ID if
- effective ID is already root, to permit an suid root program to be
- invoked by anybody.
-
- * uuxqt.c (uqdo_xqt_file): removed special case for system which
- does not permit any commands: unnecessary and unusual.
-
- * uucico.c (fconn_call): Ed Carp: clear the SIGHUP signal
- indication before opening the modem.
-
- * trans.h, trans.c (fqueue, fcheck_queue, floop, fgot_data),
- send.c (fsend_await_confirm), rec.c (frec_file_send_confirm),
- uucico.c (fcall, faccept_call): recheck the work queue every 10
- minutes. Honor CYM from the remote system. Send CYM if we have
- something to do.
-
-Sat Sep 12 15:47:52 1992 Ian Lance Taylor (ian@airs.com)
-
- * Makefile.in: use $(MAKE) instead of make for recursive calls.
-
- * system.h, uucp.c (main), uux.c (main), unix/ufopen.c,
- unix/MANIFEST, unix/Makefile.in: added esysdep_user_open to open a
- file with user permissions.
-
-Fri Sep 11 00:27:32 1992 Ian Lance Taylor (ian@airs.com)
-
- * uudefs.h, copy.c: added fcopy_open_file.
-
- * policy.h: added HAVE_SAVED_SETUID.
-
- * configure.in, conf.h.in: check for setreuid.
-
-Tue Sep 8 00:11:10 1992 Ian Lance Taylor (ian@airs.com)
-
- * protf.c (ffsendcmd), prott.c (ftsendcmd): eliminate calls to
- alloca.
-
- * uucico.c (main), uuxqt.c (main), uux.c (main), uucp.c (main),
- uustat.c (main), uuchk.c (main), uuconv.c (main), uuname.c (main),
- uulog.c (main), uupick.c (main), cu.c (main), lib/getop1.c,
- lib/Makefile.in, lib/MANIFEST: added getopt_long, and changed all
- calls to getopt to call getopt_long instead.
-
-Mon Sep 7 22:26:51 1992 Ian Lance Taylor (ian@airs.com)
-
- * getopt.h, lib/getopt.c, lib/Makefile.in: bring getopt up to
- glibc 1.04; call malloc instead of alloca in exchange.
-
- * system.h, uucico.c (main), uuxqt.c (main), uux.c (main), uucp.c
- (main), uustat.c (main), cu.c (main), uuname.c (main), unix/init.c
- (usysdep_initialize): added INIT_SUID, for old systems which don't
- do setuid correctly for root.
-
- * cu.c, unix/cusub.c: various minor improvements.
-
-Sun Sep 6 20:25:20 1992 Ian Lance Taylor (ian@airs.com)
-
- * uux.c (uxcopy_stdin): use getchar rather than fread to avoid
- SVR4 bug.
-
- * uucico.c (fsend_uucp_cmd): Niels Baggesen: report message when
- DEBUG_HANDSHAKE.
-
- * protg.c (fgsend_control): Niels Baggesen: report sending an RJ
- when DEBUG_ABNORMAL.
-
-Tue Aug 25 00:07:20 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/time.c: Zacharias Beckman: let user defined time tables
- override the defaults.
-
-Mon Aug 24 00:25:23 1992 Ian Lance Taylor (ian@airs.com)
-
- * system.h, uuxqt.c (uqdo_xqt_file), unix/xqtsub.c
- (zsysdep_xqt_local_file): Jarmo Raiha: expand ~name in uuxqt.c.
-
- * send.c (fremote_rec_reply): SVR4 sends the size of the file with
- the RY string, so we do too. We don't look for it, though.
-
- * uustat.c, uustat.1: Don Phillips: removed all printing of years
- and seconds. Hope nobody complains.
-
- * uucico.c (fdo_call): don't set the status to TALKING until we
- see the Shere string.
-
- * configure.in, conf.h.in, unix/wldcrd.c: if the system has glob,
- use it for wildcards. If it doesn't, quote special characters in
- the wildcard string.
-
- * uucico.c (fdo_call): Zacharias Beckman: don't report ``Login
- successful'' until we see the Shere string.
-
- * prot.c (fsend_data): Don Lewis: bug in crec calculation.
-
- * uustat.c (fsworkfile_show, usworkfile_header, fsnotify): Don
- Lewis: show poll files.
-
- * unix/init.c: check LOGNAME and USER environment variables before
- invoking getlogin.
-
- * unix/serial.c: Brian Campbell: check for B57600, B76800 and
- B115200 in baud rate table.
-
-Sun Aug 23 13:05:28 1992 Ian Lance Taylor (ian@airs.com)
-
- * chat.c (fcsend), tstuu.c (uchild): Chip Salzenberg: call sleep
- (2) instead of sleep (1). Hopefully this won't break any chat
- scripts.
-
- * system.h, parse.c, trans.c (fqueue, flocal_poll_file), uustat.c
- (fsworkfiles_system, fsquery_system), unix/work.c
- (fsysdep_get_work, fsysdep_get_work_init): don't delete poll files
- immediately, but instead return a 'P' command and delete them when
- the command is passed to fsysdep_did_work.
-
- * tstuu.c (uprepare_test): change ``call-request'' to ``request''.
-
- * uuconf/iniglb.c (_uuconf_itimetable): return CMDTABRET_KEEP so
- we don't lose the timetable name and definition.
-
- * uuconf.h, send.c (fremote_rec_file_init), rec.c
- (fremote_send_file_init), uuchk.c (ukshow), uuconv.c
- (uvwrite_taylor_system, uvwrite_hdb_system), uuconf/tsinfo.c
- (iirequest), uuconf/hsinfo.c, uuconf/hunk.c, uuconf/syssub.c:
- added ``send-request'' and ``receive-request'' commands,
- eliminated ``call-request'' and ``called-request'' commands.
-
- * uux.c (main): make sure we are permitted to transfer files
- before queuing requests.
-
- * uuconf.h, uucico.c (fcall), uuconf/tsinfo.c, uuconf/syssub.c:
- David Nugent: added ``success-wait'' command for systems, to set a
- minimum time between successful calls.
-
- * send.c (fremote_rec_file_init): Don Phillips: let a request only
- specify the file base name in the TO argument.
-
- * uucico.c (main): Don Lewis: don't exit with success just because
- we were able to start uuxqt.
-
- * unix/serial.c (fsmodem_close, fsserial_read): always drop DTR
- when closing a modem connection. Also, retry if we time out when
- setting MIN.
-
-Sat Aug 22 22:31:34 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/time.c: Stephen Walick: don't require a comma between
- time strings, since HDB doesn't seem to.
-
- * protg.c (fgcheck_errors): added "error-decay" protocol parameter
- to decay errors as packets are successfully received.
-
- * uustat.c (fsmachines), uustat.1: Chris Lewis: don't display the
- year or seconds for uustat -m. Probably uustat -q should be
- changed as well.
-
- * tstuu.c: Larry Fahnoe: don't report EWOULDBLOCK errors when
- writing to a pty. Also removed functions which are now in lib.
-
- * MANIFEST, Makefile.in, uusched.in: added a simple uusched shell
- script.
-
- * parse.c: Heiko Rupp: don't die if there is trailing garbage in
- an 'R' command.
-
- * policy.h, system.h, sysh.unx, send.c, rec.c, uuxqt.c, uux.c,
- unix/filnam.c, unix/init.c, unix/jobid.c, unix/splnam.c,
- unix/spool.c, unix/statsb.c, unix/tmpfil.c, unix/work.c,
- unix/xqtfil.c: Brian J. Murrell and Don Phillips: added
- SPOOLDIR_SVR4.
-
-Thu Aug 20 00:06:32 1992 Ian Lance Taylor (ian@airs.com)
-
- * sysh.unx: Chiaki Ishikawa: some systems define some but not all
- of the S_ file mode bits.
-
- * uuchk.c (ikshow_port): Chiaki Ishikawa: display lockname.
-
-Wed Aug 19 22:41:39 1992 Ian Lance Taylor (ian@airs.com)
-
- * log.c (ustats): Scott Blachowicz: avoid overflow when reporting
- bytes per second.
-
- * unix/lock.c (fsdo_lock): Chip Salzenberg: sometimes other
- programs create lock files that uucp can't write.
-
- * trans.h, system.h, trans.c (floop, fgot_data, usent_receive_ack,
- uwindow_acked), send.c (flocal_send_await_reply,
- flocal_send_fail), rec.c (fremote_send_fail_send,
- frec_file_send_confirm), prote.c, protf.c, protg.c, proti.c,
- prott.c, protz.c (calls to fgot_data), unix/recep.c,
- unix/MANIFEST, unix/Makefile.in: keep trace of whether we have
- already received a file, in case the other side never sees our
- ack. Added new SN8 rejection, meaning that the file has already
- been received.
-
-Sat Aug 15 11:50:32 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf/time.c (itadd_span): Don Lewis: fixed bug if later span
- overlapped two or more earlier spans.
-
-Thu Aug 13 00:19:50 1992 Ian Lance Taylor (ian@airs.com)
-
- * system.h, rec.c (fremote_send_file_init, fremote_send_reply),
- uucico.c (fdo_call, faccept_call), uucp.c (main), uux.c (main),
- unix/opensr.c (zsysdep_receive_temp, esysdep_open_receive):
- implemented file restart.
-
-Wed Aug 12 23:32:05 1992 Ian Lance Taylor (ian@airs.com)
-
- * proti.c (fiprocess_data): ensure that the first argument to
- fgot_data is always > 0 if the second argument is > 0.
-
-Mon Aug 10 22:43:40 1992 Ian Lance Taylor (ian@airs.com)
-
- * trans.c (floop, ustats_failed): handle half-duplex connections
- and failed calls correctly.
-
-Sun Aug 9 17:56:32 1992 Ian Lance Taylor (ian@airs.com)
-
- * proti.c (firesend, fisenddata, ficheck_errors): made several
- changes to improve performance on a lossy line: can now shrink
- packet size using SYNC packets, avoids multiple bad header errors
- in a sequence of INTRO characters, avoids letting one side lock up
- if a NAK is lost.
-
- * configure.in: set HAVE_LONG_FILE_NAMES to 0 if
- cross-configuring.
-
- * tstuu.c: changed -p option to be mod 1000, not mod 100.
-
- * MANIFEST, Makefile.in, prot.h, uucico.c, protz.c, trans.c: Doug
- Evans: added Doug Evans's zmodem implementation as protocol 'a'.
-
-Wed Aug 5 22:28:14 1992 Ian Lance Taylor (ian@airs.com)
-
- * policy.h, uuconf.h, uucico.c (fcall), uuconf/tsinfo.c,
- uuconf/hsinfo.c, uuconf/syssub.c: added "max-retries" command for
- systems, eliminated CMAXRETRIES configuration parameter, set
- max_retries to 0 for HDB if retry time given, (from Chris Lewis)
- call once a day even if max_retries has been exceeded.
-
- * prot.h, uucico.c (fdo_call, faccept_call), prott.c, prote.c,
- proti.c, protg.c, protf.c: added pzlog argument to pfstart
- protocol entry point, changed handshake successful message to
- display it.
-
-Tue Aug 4 00:04:31 1992 Ian Lance Taylor (ian@airs.com)
-
- * prot.h, uucico.c, protg.c (fbiggstart, cGshort_packets): Chip
- Salzenberg: added support for 'G' protocol. Added "short-packets"
- protocol parameter for 'g' and 'G' protocols.
-
- * uuconf.h, rec.c (flocal_rec_file_init), uucp.c, uux.c, uuxqt.c,
- uuchk.c, uuconv.c, uuconf/local.c, uuconf/tsinfo.c,
- uuconf/syssub.c: support UUCP forwarding. Added "forward-from",
- "forward-to", and "forward" commands for systems.
-
- * unix/spawn.c: don't close the file descriptor after dupping it.
-
-Sun Aug 2 23:04:18 1992 Ian Lance Taylor (ian@airs.com)
-
- * trans.c (fremote_hangup_reply): don't hangup if a file transfer
- is in progress.
-
- * send.c (flocal_send_cancelled): don't pass a NULL buffer to
- pfsenddata.
-
-Sun Jul 26 13:28:27 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/work.c (fsysdep_get_work_init): return TRUE if there is no
- work directory.
-
- * configure.in, sysh.unx: don't run any programs in configure if
- we are cross-configuring; this applies to HAVE_FTIME and
- HAVE_RESTARTABLE_SYSCALLS. The code can cope with the buggy
- ftime. If we are cross-configuring, HAVE_RESTARTABLE_SYSCALLS is
- set to -1, and sysh.unx guesses that if the system has sigvec but
- not sigaction or SV_INTERRUPT it is on 4.2BSD and system calls are
- automatically restarted.
-
- * configure.in, conf.h.in, tstuu.c, unix/serial.c: removed
- COMBINED_UNBLOCK configuration parameter, and changed the code
- which sets O_NONBLOCK and O_NDELAY to drop back to using just
- O_NONBLOCK if it gets an EINVAL error.
-
- * configure.in, conf.h.in, uucp.h, protg.c (fgsenddata), cu.c
- (icutake), chat.c (icexpect), lib/MANIFEST: removed all calls to
- memmove, avoiding the SCO bug and making the 'g' protocol slightly
- more efficient.
-
-Sat Jul 25 14:20:30 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h, uudefs.h, many other files: broke part of uucp.h out
- into uudefs.h, stopped including uuconf.h in uucp.h, fixed up .c
- files to include uudefs.h and uuconf.h as necessary.
-
- * uuconf/syshdr.unx, uuconf/callin.c, uuconf/diacod.c
- uuconf/hdial.c, uuconf/hdnams.c, uuconf/hport.c, uuconf/hsinfo.c,
- uuconf/hsnams.c uuconf/rdlocs.c, uuconf/tcalou.c, uuconf/tdial.c,
- uuconf/tdnams.c, uuconf/tport.c, uuconf/vport.c, uuconf/vsinfo.c,
- uuconf/vsnams.c: changed uuconf library to not return an error if
- a configuration file does not exist; it now acts as though
- whatever it is is not found.
-
- * tstuu.c (main): use perror if execl fails.
-
- * configure.in, conf.h.in, uucp.h, uuconf.h, sysh.unx, conn.h,
- MANIFEST, Makefile.in, tli.c, chat.c (ccescape), conn.c
- (fconn_init), tcp.c, uucico.c (faccept_call), uuconv.c, uuchk.c,
- lib/MANIFEST, lib/Makefile.in, lib/escape.c, unix/cusub.c,
- unix/serial.c, uuconf/hport.c, uuconf/tportc.c: added support for
- TLI connections. Moved ccescape from chat.c to cescape in
- lib/escape.c. Made all connections on Unix use the same
- system dependent structure.
-
-Tue Jul 21 22:08:10 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h, trans.h, uucico.c (fdo_call, faccept_call), uuxqt.c
- (uqdo_xqt_file), uucp.c (main), uux.c (main), uustat.c
- (fsworkfile_show), parse.c (fparse_cmd), trans.c (fqueue,
- fgot_data, ftadd_cmd), send.c, rec.c, xcmd.c, protf.c
- (ffprocess_data), proti.c (fiprocess_data), tstuu.c
- (uprepare_tests), unix/splcmd.c (zsysdep_spool_commands),
- unix/statsb.c (fskill_or_rejuv), unix/work.c (fsysdep_get_work):
- added E request to send file executions which only require reading
- from standard input.
-
-Sat Jul 18 20:22:50 1992 Ian Lance Taylor (ian@airs.com)
-
- * proti.c, Makefile.in, MANIFEST, prot.h, system.h, trans.h,
- uucico.c, prote.c, protf.c, protg.c, prott.c, trans.c, send.c,
- rec.c, xcmd.c, unix/opensr.c: added 'i' protocol. Added local and
- remote channel arguments to protocol sendcmd and senddata entry
- points. Cleaned up send and receive state machines. Removed
- pfgone argument from esysdep_open_send.
-
-Fri Jul 17 09:41:05 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuxqt.c (uqdo_xqt_file): only report base name of execution
- file, not full name.
-
-Thu Jul 16 00:45:06 1992 Ian Lance Taylor (ian@airs.com)
-
- * lib/crc.c: unroll the loop a bit.
-
- * configure.in, conf.h.in, unix/init.c: updated to autoconf 0.120.
-
-Wed Jul 15 14:45:32 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf.h, uuconv.c, uuconf/uucnfi.h, uuconf/reliab.c,
- uuconf/tportc.c, uuconf/tdialc.c, uuconf/diasub.c, uuconf/hport.c,
- uuconf/prtsub.c, uuconf/vsinfo.c: added UUCONF_RELIABLE_FULLDUPLEX
- and "half-duplex" command for ports and dialers.
-
-Mon Jul 13 16:53:04 1992 Ian Lance Taylor (ian@airs.com)
-
- * prot.h, lib/crc.c, lib/Makefile.in, lib/MANIFEST: added icrc
- function to compute 32 bit CRC (from Gary S. Brown, via Doug
- Evans).
-
-Sun Jul 12 21:40:15 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconv.c (uvwrite_time): Chris Lewis: don't output two commas in
- a row.
-
- * uuconv.c (uvwrite_taylor_system, uvwrite_taylor_port): Chris
- Lewis: generate command "protocol", not "protocols".
-
-Sat Jul 11 17:09:09 1992 Ian Lance Taylor (ian@airs.com)
-
- * xcmd.c (fremote_xcmd_init): Chris Lewis: use qdaemon->puuconf,
- since puuconf is not defined.
-
- * uuconf/syshdr.unx, uuconf/hinit.c (uuconf_hdb_init): Chris
- Lewis: added HDB_SEPARATOR to insert between oldconfiglib and
- strings in HDB Sysfiles.
-
- * uuconf/syshdr.unx: Chris Lewis: define strerror as a macro.
-
- * uuconf/freblk.c, uuconf/free.c: Chris Lewis: don't define as
- void when ! UUCONF_ANSI_C.
-
-Thu Jul 9 09:17:55 1992 Ian Lance Taylor (ian@airs.com)
-
- * prot.h, uucico.c (fdo_call, faccept_call), prote.c (festart),
- protf.c (ffstart), protg.c (fgstart), prott.c (ftstart): no need
- to pass fmaster as a separate argument to protocol start routine.
-
- * protf.c (ffawait_ack, ffawait_cksum): don't try to resend if we
- don't have a file.
-
-Wed Jul 8 14:28:23 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/srmdir.c (fsysdep_rmdir), unix/walk.c (usysdep_walk_tree):
- cast to char * to avoid warning.
-
- * cu.c (main): don't compare boolean to NULL.
-
- * unix/serial.c (isblocksigs), unix/signal.c (usset_signal): use
- extra parens to avoid bug in SCO 3.2.2 sys/signal.h header file.
-
- * sysh.unx: always define struct ssysdep_tcp, for the benefit of
- systems for which HAVE_TCP is 0.
-
- * MANIFEST, Makefile.in, unix/Makefile.in, uuconf/Makefile.in,
- lib/Makefile.in: updated automatic distribution code for multiple
- directories.
-
- * unix/cusub.c, unix/serial.c: don't clobber CR when using TERMIO
- or TERMIOS, and default MIN to 1 to the convenience of cu.
-
- * Makefile.in, uucp.h, system.h, prot.h, trans.h, uucico.c,
- trans.c, send.c, rec.c, xcmd.c, prot.c, protg.c, protf.c, prote.c,
- prott.c, log.c, file.c, unix/opensr.c, unix/work.c: rewrote file
- transfer internals to support bidirectional transfers. Keep queue
- of jobs to do, and support connections. Added new files trans.h,
- trans.c, send.c, rec.c, xcmd.c, and removed old file file.c.
-
-Mon Jun 29 15:14:15 1992 Ian Lance Taylor (ian@airs.com)
-
- * Makefile.in: Stephen J. Walick: copy uustat.1 to
- uustat.$(manext), not uucp.($manext). Also try to create
- $(infodir).
-
- * chat.c (fcsend, fcprogram): check for NULL return from
- uuconf_callout.
-
-Thu Jun 18 22:37:28 1992 Ian Lance Taylor (ian@airs.com)
-
- * configure.in, Makefile.in: updated to autoconf 0.118.
-
-Wed Jun 17 14:22:11 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/serial.c (fsserial_init): add /dev if necessary to device
- as well as to port name.
-
- * cu.c (main): set zdevice to NULL when faking line.
-
- * cu.c (main), uucp.c (main), uux.c (main), uuxqt.c (main): don't
- call zsysdep_localname until we've called usysdep_initialize.
-
-Tue Jun 16 17:42:50 1992 Ian Lance Taylor (ian@airs.com)
-
- * unix/signal.c (usset_signal): set SA_INTERRUPT to force system
- calls to be interrupted on SunOS.
-
-Mon Jun 15 15:10:24 1992 Ian Lance Taylor (ian@airs.com)
-
- * everything: integrated uuconf library. Split out lib and unix
- libraries. Made many changes, including defaults for port and
- dialer files, better handling of changed local name, better
- handling of HDB Permissions, new zbufalc routines to manage
- strings on the heap. Incorporated uuconv.
-
-Wed Jun 10 23:51:03 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf.h, uuconf/Makefile.in, uuconf/locnm.c, uuconf/llocnm.c,
- uuconf/hlocnm.c, uuconf/tlocnm.c: renamed uuconf_localname to
- uuconf_login_localname and added new uuconf_localname which
- doesn't need to read system information.
-
-Tue Jun 9 14:19:20 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf.h, uuconf/Makefile.in, uuconf/local.c: wrote
- uuconf_system_local.
-
-Mon Jun 8 14:14:30 1992 Ian Lance Taylor (ian@airs.com)
-
- * policy.h: changed description of LOCKDIR, which now need not
- always be defined.
-
- * uuconf.h, uuconf/uucnfi.h, uuconf/lckdir.c, uuconf/iniglb.c,
- uuconf/tinit.c, uuconf/Makefile.in: added uuconf_lockdir, and
- ``lockdir'' command to config.
-
-Sat Jun 6 22:07:58 1992 Ian Lance Taylor (ian@airs.com)
-
- * configure.in: updated to autoconf 0.115, added code to set
- LIBOBJS.
-
- * uuconf/Makefile.in, uuconf/uucnfi.h: removed references to
- routines now in lib/, changed to include regular UUCP header
- files.
-
-Fri Jun 5 15:31:29 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf.h, uuconf/uucnfi.h, uuconf/syssub.c, uuconf/uuconv.c:
- always set zpubdir for every system, changed uuconf_zpubdir to
- const char *.
-
-Wed Jun 3 15:15:32 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf.h, uuconf/Makefile.in, uuconf/deblev.c, uuconf/maxuxq.c,
- uuconf/pubdir.c, uuconf/spool.c: wrote uuconf_debuglevel,
- uuconf_maxuuxqts, uuconf_pubdir, uuconf_spooldir.
-
- * configure.in: updated to autoconf 0.114.
-
- * uuconf/tportc.c: default TCP ports to being fully reliable.
-
-Mon Jun 1 17:03:22 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf.h, uuconf/prtsub.c: removed uuconf_psysdep from
- uuconf_port.
-
-Sun May 31 00:07:40 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuconf.h, uuconf/Makefile.in, uuconf/diacod.c: wrote
- uuconf_dialcode.
-
- * uuconf.h, uuconf/Makefile.in, uuconf/logfil.c, uuconf/debfil.c,
- uuconf/stafil.c: wrote uuconf_logfile, uuconf_debugfile,
- uuconf_statsfile.
-
- * uuconf.h, uuconf/Makefile.in, uuconf/callin.c: wrote
- uuconf_callin.
-
- * uuconf/chatc.c, uuconf/time.c: Jean Mehat: only call tolower if
- isupper is true.
-
- * uuconf.h, uuconf/Makefile.in, uuconf/val.c, uuconf/tval.c: wrote
- uuconf_validate, uuconf_taylor_validate.
-
-Sat May 30 12:37:02 1992 Ian Lance Taylor (ian@airs.com)
-
- * system.h, sys1.unx: changed zsysdep_local_name to
- zsysdep_localname, and made it fatal out rather than return NULL.
-
- * uuconf.h, uuconf/Makefile.in, uuconf/uucnfi.h, uuconf/iniglb.c,
- uuconf/rdlocs.c, uuconf/locnm.c, uuconf/tlocnm.c, uuconf/hlocnm.c:
- wrote uuconf_localname, uuconf_taylor_localname,
- uuconf_hdb_localname.
-
- * uuconf.h, uuconf/Makefile.in, uuconf/uucnfi.h, uuconf/iniglb.c,
- uuconf/tinit.c, uuconf/tsinfo.c, uuconf/hunk.c, uuconf/unk.c:
- wrote uuconf_system_unknown, uuconf_hdb_system_unknown,
- uuconf_taylor_system_unknown.
-
- * log.c, time.c: always include <sys/types.h> in uucp.h.
-
- * configure.in, conf.h.in: check for size_t, renamed checks for
- time_t.
-
- * configure.in, conf.h.in: check for <stddef.h>.
-
-Fri May 29 00:03:05 1992 Ian Lance Taylor (ian@airs.com)
-
- * sysinf.c (ztranslate_system): Jac Kersing: must xstrdup the
- argument, since it points to a buffer that will be reused.
-
-Thu May 28 12:42:20 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys3.unx (zsysdep_real_file_name): Ted Lindgreen: check return
- value of zstilde_expand.
-
- * copy.c, sys1.unx (usysdep_detach), sys2.unx (fsserial_close),
- sys3.unx, sys5.unx, sys7.unx: opening /dev/tty in usysdep_detach
- confuses the NeXT, so instead we just call TIOCNOTTY on 0. In
- fsserial_close we call TIOCNOTTY on the port before closing it, to
- make sure that we have ditched it under BSD. Also added O_NOCTTY
- to every open call other than opening a port, although there are
- still several fopen calls which should probably have it somehow.
-
- * system.h, uucico.c (fcall), uustat.c (fsquery_system,
- fsquery_show), sys3.unx (fsysdep_get_status), sys7.unx
- (zsysdep_all_status): Bob Izenberg: changed output of uustat -q to
- count number of commands rather than number of files being
- transferred, and to not report a non-existent status. Added
- pfnone argument to fsysdep_get_status, and changed all calls.
-
- * uucico.c, sys1.unx, sys2.unx, sys3.unx, sys5.unx, sys6.unx,
- sys7.unx: Rolf Nerstheimer: cast a bunch of arguments to open,
- creat, stat and chmod to avoid compiler warnings.
-
- * uucp.h, log.c (ulog), port.c (fport_close), prot.c (fgetcmd):
- Chip Salzenberg: don't log a SIGHUP signal while we're closing
- down the connection, since the other side might hang up faster
- than we do (we still react to it correctly, we just don't put it
- in the log file).
-
- * sys1.unx (usysdep_detach), tcp.c (ftcp_open): Petri Helenius:
- update the process ID we log after a fork.
-
- * Makefile.in, sys1.unx: Chip Salzenberg: changed LIBDIR to
- SBINDIR.
-
- * uucp.c (main, uccopy): Andreas Vogel: check local-receive of the
- correct system, rather than always using sLocalsys.
-
- * configure.in, conf.h.in, sys2.unx, tstuu.c: Rob Janssen: look
- for <sys/select.h>, and include it if it exists and we are using
- select.
-
- * protg.c: Rob Janssen: rearrange macros to avoid bug in XENIX
- compiler.
-
- * configure.in: Scott Blachowicz: check WIFEXITED before assuming
- HAVE_UNION_WAIT, to avoid problems on HP/UX.
-
- * configure.in, conf.h.in, sysh.unx, sys1.unx: John Theus: use
- sv_onstack instead of sv_flags in the sigvec structure on 4.2BSD.
-
-Wed May 27 23:23:39 1992 Ian Lance Taylor (ian@airs.com)
-
- * policy.h, sys2.unx (fsysdep_modem_no_carrier): Scott Reynolds:
- added HAVE_CLOCAL_BUG compilation parameter to work around
- problems on some serial ports.
-
-Tue May 26 15:50:17 1992 Ian Lance Taylor (ian@airs.com)
-
- * uustat.c, uustat.1: added a bunch of options to support uuclean:
- -e, -i, -K, -M, -N, -W, -Q.
-
- * system.h, sys7.unx (fsysdep_privileged, fskill_or_rejuv): added
- fsysdep_privileged function.
-
-Thu May 21 13:30:21 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuxqt.c (uqdo_xqt_file): processing of execution file has to be
- case significant; this will change handling of "n" flag, which was
- not correctly handled before.
-
-Wed May 20 14:22:12 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys1.unx (usysdep_detach): close the statistics file when
- detaching.
-
- * policy.h, sys3.unx (fsdo_lock, fsdo_unlock), sys7.unx
- (fsysdep_lock_status): force LOCKDIR to always be defined.
-
- * uucp.h: put in an extern for alloca.
-
- * sysh.unx, sys1.unx, sys5.unx, sys6.unx: defined all the ?_OK
- macros in sysh.unx, which means that <unistd.h> must be included
- before "sysdep.h" when they are both included.
-
- * sys2.unx (fsserial_set): corrected case in termio switch
- expression.
-
- * chat.c (fcsend): simplified expression for old compilers.
-
- * sys1.unx (rmdir): wrote rmdir replacement which invokes
- /bin/rmdir for old systems.
-
- * configure.in, conf.h.in, Makefile.in: updated for autoconf
- 0.112, added checks for ftw, ftw.h, and rmdir.
-
- * sys1.unx: added extern for ctime, removed externs for functions
- returning int, protected externs with ifndefs.
-
- * uucp.h, prot.h, system.h, uucico.c (fuucp), uuxqt.c
- (uqdo_xqt_file), prot.c (freceive_file), file.c (freceived_file),
- sys3.unx (fsysdep_move_file, fsysdep_change_mode), sys4.unx
- (zsysdep_save_temp_file): changed fsysdep_move_file to not set the
- file mode, and added fsysdep_change_mode to do it instead.
-
- * system.h, uucp.c (main, ucdirfile, uccopy), sys6.unx
- (usysdep_walk_tree, isdir, ftw, do_ftw): added -R option to uucp
- to recursively copy directories.
-
-Tue May 19 18:29:32 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys3.unx: changed zsysdep_in_dir to always append the filename
- to the directory, even if the directory did not already exist.
-
- * sysh.unx, sys1.unx, sys3.unx, sys4.unx, sys5.unx: renamed
- fsdirectory_exists to fsysdep_directory.
-
-Mon May 18 14:49:35 1992 Ian Lance Taylor (ian@airs.com)
-
- * system.h, uucp.c (main), sys6.unx (zsysdep_uuto): added -t
- option to uucp to emulate uuto, wrote zsysdep_uuto to do Unix
- dependent destination translation for uuto, added -p option to
- uucp as synonym for -C for uuto compatibility.
-
-Sun May 17 22:04:09 1992 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgexchange_init): permit a second INITB to override the
- segment size given in the first INITB.
-
-Tue May 5 16:03:22 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (main, fdo_call), uucico.8: Chip Salzenberg: added -c
- option to uucico to not warn if invoked when the system may not be
- called.
-
-Tue Apr 28 15:05:01 1992 Ian Lance Taylor (ian@airs.com)
-
- * sysh.unx, sys2.unx (fsserial_open, fsblock): preserve file
- status flags.
-
- * protg.c (fgwait_for_packet): Heiko Rupp: only send RJ packet if
- there are no unacknowledged packets.
-
-Mon Apr 27 18:56:42 1992 Ian Lance Taylor (ian@airs.com)
-
- * system.h: added several routines for cu.
-
- * cu.c, cu.h, sys8.unx: checked into RCS.
-
- * uux.c (main): Jose Manas: dumb bug when checking against
- calloc_args.
-
-Fri Apr 24 20:32:06 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys1.unx: changed HAVE_LONG_NAMES to HAVE_LONG_FILENAMES for new
- version of autoconf.
-
- * sys7.unx: check UTIME_NULL_MISSING with #if rather than #ifdef.
-
- * sys3.unx: check FS_* macros with #if rather than #ifdef.
-
- * uucp.h, sysh.unx: changed standard type definitions for new
- version of autoconf.
-
- * sysh.unx, sys1.unx, sys2.unx, tstuu.c: changed SIGtype to
- RETSIGTYPE for new version of autoconf.
-
- * sys1.unx, tstuu.c: make include of <sys/times.h> optional.
-
- * sys2.unx: get the right versions of major and minor.
-
-Wed Apr 22 11:19:11 1992 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgsenddata, fggot_ack): Michael Haberler: the slow
- start after error code was essentially shrinking the window size.
-
- * sysh.unx, system.h, sys1.unx (usysdep_initialize), uuchk.c,
- uucico.c, uucp.c, uulog.c, uuname.c, uustat.c, uux.c, uuxqt.c:
- changed usysdep_initialize to take a single argument with bit
- flags, added INIT_NOCHDIR as one of the flags.
-
- * uucp.h, log.c (ulog): added pfLstart and pfLend functions for
- ulog, so that cu can use them to restore the terminal settings.
-
- * bnu.c (ubnu_read_systems, fbnu_read_dialer_info), v2.c
- (uv2_read_systems): Michael Richardson: don't core dump if no chat
- script.
-
-Tue Apr 21 00:19:47 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (faccept_call): Chris Lewis: a successful call in
- should clear the number of retries.
-
- * sys2.unx (fsserial_set): set LLITOUT if going to CBREAK mode.
-
- * port.h, prote.c (festart), protf.c (ffstart), protg.c (fgstart),
- prott.c (ftstart), port.c (fport_set), sys2.unx
- (fsysdep_stdin_set, fsysdep_modem_set, fsysdep_direct_set,
- fsserial_set): gave fport_set independent control over output
- parity generation, input parity checking, and XON/XOFF
- handshaking, all to support cu.
-
-Mon Apr 20 11:47:23 1992 Ian Lance Taylor (ian@airs.com)
-
- * port.h, uucico.c (fdo_call), port.c (fport_dial, fmodem_dial),
- tcp.c (ftcp_dial): added separate zphone argument to fport_dial to
- support cu.
-
-Thu Apr 16 01:15:42 1992 Ian Lance Taylor (ian@airs.com)
-
- * bnu.c (ubadd_perm, ubadd_perm_alternate): Chris Lewis: handle a
- combination of Permissions entries which specify just LOGNAME with
- entries that specify both MACHINE and LOGNAME.
-
-Wed Apr 15 16:11:48 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys1.unx (usysdep_initialize, zsysdep_login_name): John Theus:
- don't die if can't get login name, unless it's really needed.
-
-Tue Apr 14 12:39:18 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (main, fcall): Petri Helenius: must relock system after
- detaching from terminal when trying different alternates.
-
- * system.h, uucico.c (fuucp), uustat.c (fsworkfiles_system,
- fsquery_system), sys4.unx (fsysdep_get_work_init,
- fsysdep_get_work): Marty Shannon: uustat would remove empty
- command files.
-
- * bnu.c (ubadd_perm_alternate): John Harkin: permit ALIAS in
- Permissions.
-
- * Makefile.in: John Harkin: add sys?.c dependencies to sys?.o to
- work around old makes which don't handle transitive .SUFFIXES.
-
- * sys2.unx: cast some function calls to void.
-
- * time.c (qttime_parse): cast to void warning.
-
- * sys1.unx (iswait): cast waitpid argument to avoid warning.
-
- * configure.in, policy.h, uucp.h, sys7.unx, tstuu.c: Zacharias
- Beckman: minor touchups for NeXT.
-
- * sys1.unx (usysdep_initialize), sys6.unx (zsysdep_add_cwd), uux.c
- (main): Jarmo Raiha: heuristic for whether to get the current
- directory can fail.
-
- * sys1.unx: pass argument to uudir, cast sigemptyset calls to
- void.
-
- * uucp.texi: Harlan Stenn: correct case of references.
-
-Tue Apr 7 01:02:17 1992 Ian Lance Taylor (ian@airs.com)
-
- * Released version 1.03.
-
-Mon Apr 6 15:49:08 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (faccept_call): Marc Boucher: set *pqsys to NULL.
-
- * bnu.c (ubnu_read_systems, fbnu_find_port): Erik Forsberg:
- support multiple character modem classes.
-
-Fri Apr 3 00:37:25 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys2.unx: Petri Helenius: only clear known bits in termio or
- termios structure; didn't change HAVE_BSD_TTY handling--maybe next
- version.
-
- * configure.in: test TIMES_DECLARATION_OK correctly.
-
- * Makefile.in: update version to 1.03, remove distclean, add
- mostlyclean per GNU standards.
-
- * sys1.unx, chat.c: minor cleanups for gcc 2.1.
-
-Thu Apr 2 17:51:36 1992 Ian Lance Taylor (ian@airs.com)
-
- * tstuu.c: conditionally declare times.
-
- * uucp.h, prot.c, sysinf.c, prtinf.c: added gcc 2.0 format
- checking to ulog, and fixed a few problems it discovered.
-
-Wed Apr 1 16:21:08 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys3.unx (esysdep_open_receive): David J. MacKenzie: some
- USG_STATFS systems use 512 as the block size of f_bfree, despite
- the existence of f_bsize.
-
- * port.c (fport_open): initialize stdin port.
-
- * policy.h, log.c: added CLOSE_LOGFILES configuration parameter.
-
- * sys2.unx: T. William Wells: handle a system without <poll.h> or
- <stropts.h>.
-
- * configure.in: Franc,ois Pinard: warn if none of napms, nap,
- usleep, poll or select are available, since \p will sleep for a
- full second.
-
- * Makefile.in: Gerben Wierda: fixed uninstall to set file owner
- and mode correctly. Also changed install to handle uucp.info-4
- and uustat.1.
-
- * MANIFEST: added uucp.info-4 and uustat.1.
-
- * uustat.1: Wrote.
-
- * uucico.8, uuxqt.8, uucp.1, uux.1: updated -x switch, cleaned up
- a bit.
-
-Tue Mar 31 14:40:06 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys1.unx (usysdep_initialize): use $PWD to get the current
- working directory if it's defined and correct.
-
- * sys1.unx (usysdep_initialize): Brian Antoine: use name from
- getpwname rather than getlogin.
-
- * uucp.texi: David J. MacKenzie: put in a number of corrections.
- Also split sys file and config file nodes, and rearranged several
- nodes.
-
- * protg.c (fgsenddata): Niels Baggesen: packet to retransmit did
- not get reset correctly.
-
-Mon Mar 30 10:03:28 1992 Ian Lance Taylor (ian@airs.com)
-
- * tcp.c (ftcp_reset): Petri Helenius: TCP server never started
- uuxqt, because it exited in ftcp_reset.
-
- * policy.h, sysh.unx, sys2.unx (fsserial_lockfile): added
- HAVE_SVR4_LOCKFILES configuration parameter.
-
- * sys3.unx (esysdep_open_receive): Niels Baggesen: USG statfs has
- an f_bsize field.
-
-Sun Mar 29 23:04:20 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h, sysinf.c, prot.c, prote.c, protf.c, protg.c, prott.c:
- Niels Baggesen: added new debugging types abnormal and uucp-proto.
-
- * uucico.c (fuucp), prot.c (freceive_file), file.c
- (fstore_recfile): Dirk Musstopf: if a file receive fails before it
- starts, perhaps because the file was too large, remember to remove
- the temporary file.
-
- * sys2.unx (fsserial_lock, fsserial_open, fsserial_write,
- fsserial_io): always block and unblock the read and write
- descriptors together.
-
-Sat Mar 28 14:40:50 1992 Ian Lance Taylor (ian@airs.com)
-
- * uustat.c: allow multiple systems and users to be specified at
- once; likewise for kills and rejuvenates. Allow old and young to
- be combined with systems and users. As suggested by Niels
- Baggesen, make machine status output more columnar.
-
- * uucp.h, uucico.c, config.c, sys3.unx: Michael I Bushnell:
- renamed enum tstatus to tstatus_type to avoid conflict with
- <sys/ioctl.h> on some systems.
-
- * config.c, sysinf.c, prtinf.c, chat.c: David J. MacKenzie: allow
- backslash newline quoting in all TAYLOR_CONFIG configuration
- files.
-
- * chat.c (fchat): David J. MacKenzie: handle empty subexpect
- strings correctly.
-
- * uucico.c (main, fcall): Petri Helenius: must dump controlling
- terminal before going to next alternate. Also fixed David J.
- MacKenzie bug in which a signal did not prevent the next
- alternates from being tried. Also made sure qtime was always
- freed up.
-
- * uucp.h, uucico.c (fdo_call), sysinf.c (tialternate), uuchk.c
- (ukshow): Franc,ois Pinard: allow a name to be given to an
- alternate, and display the name when placing a call.
-
- * chat.c (fcprogram), port.c (fport_open, fport_close): David J.
- MacKenzie: send port device rather than port name to a chat
- program using \Y; make sure port device is reset if port open
- fails and when port is closed.
-
- * uucico.c (fuucp), log.c (ulog, ustats, ustats_close): close log
- and statistics file every time master and slave switch roles.
-
-Fri Mar 27 00:31:23 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fdo_call): Mark Mallett: minor cleanup.
-
- * uuname.c (main): Franc,ois Pinard: output aliases, added -a
- switch.
-
- * uucico.8, uuxqt.8, uux.1, uucp.1: David J. MacKenzie: changed
- .TP5 to .TP 5; also updated to 1.03.
-
- * tstuu.c: Roberto Biancardi: if SIGCHLD is not defined, define it
- as SIGCLD.
-
- * config.c: David J. MacKenzie: cMaxuuxqts is independent of
- HAVE_TAYLOR_CONFIG.
-
- * uucp.h: Gerben Wierda: don't always declare bzero.
-
- * sys7.unx (ussettime, fsysdep_lock_status): Niels Baggesen,
- Gerben Wierda: minor patches.
-
- * sys2.unx: Gerben Wierda: minor cleanups.
-
- * uucp.h: Niels Baggesen: simplified debugging message macros to
- avoid broken compilers.
-
- * sys2.unx: don't use TIOCEXCL locking.
-
- * sys2.unx: rework HAVE_UNBLOCKED_WRITES == 0 to work even if
- writes are unblocked. Correct initialization of fwrite_blocking.
-
- * Makefile.in, configure.in: David J. MacKenzie: various cleanups.
- Changed default newconfigdir definition. Supported compilation in
- a different directory. Used symbolic links if available. Changed
- default infodir definition per Franc,ois Pinard.
-
- * policy.h: David J. MacKenzie: various cleanups.
-
-Thu Mar 26 12:17:41 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys3.unx: reduced race condition in fsdo_lock.
-
- * sys1.unx: Gerben Wierda: various cleanups. Also don't set
- sa_flags to SV_INTERRUPT per Chip Salzenberg.
-
-Wed Mar 25 22:20:24 1992 Ian Lance Taylor (ian@airs.com)
-
- * configure.in: Overhauled for readability and functionality as
- suggested by T. William Wells and others. Added bug checks,
- including for SCO memmove and ftime.
-
-Tue Mar 24 12:18:56 1992 Ian Lance Taylor (ian@airs.com)
-
- * sysinf.c (uiread_systems): fixed handling of alternates in
- file-wide defaults.
-
-Wed Mar 18 01:01:25 1992 Ian Lance Taylor (ian@airs.com)
-
- * config.c (tprocess_one_cmd): handle CMDTABTYPE_FULLSTRING
- correctly if there are no arguments.
-
- * Released beta version 1.03
-
- * sys1.unx (usysdep_detach): open the controlling terminal in non
- delay mode since it might be a modem.
-
-Tue Mar 17 00:01:53 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fdo_call, faccept_call): T. William Wells: set current
- time in status file when call completes.
-
- * sys1.unx (iswait), sys2.unx (fsserial_read, fsserial_write,
- fsserial_io): log signals when they occur, even if we continue
- some sort of loop, rather than waiting for the next ulog call.
-
- * sys2.unx (fsserial_lock, fsserial_open): don't block when
- opening the write descriptor.
-
-Mon Mar 16 00:14:43 1992 Ian Lance Taylor (ian@airs.com)
-
- * system.h, uuxqt.c (uqdo_xqt_file), sys5.unx (fsysdep_execute):
- pass command to fsysdep_execute as first element of argument
- array.
-
- * tcp.c: declare _exit.
-
- * uucp.h: move definition of const before use for non ANSI C.
-
- * uucp.h, sys1.unx: undefine remove in uucp.h if the system does
- not have it to avoid conflict with macro definitions.
-
- * uucico.c, uuxqt.c, protf.c, prott.c, prote.c, config.c, chat.c,
- port.c, sys2.unx: miscellaneous cleanups.
-
- * tcp.c (ftcp_open): cast argument to bzero.
-
- * time.c (qtimegrade_parse): cast argument to qttime_parse to
- long.
-
- * file.c: changed iRecmode to unsigned int.
-
- * configure.in, uucp.h: on SCO 3.2.2 sig_atomic_t is defined in
- <sys/types.h> but not <signal.h>.
-
- * sys1.unx: undefined remove before the function definition to
- avoid trouble on systems for which it is a macro.
-
- * Makefile.in: removed dependencies of getopt.o.
-
- * sys1.unx, sys7.unx, tstuu.c: adjusted external declarations.
-
- * getopt.h, getopt.c: get new versions from glibc 1.01.
-
- * sys1.unx: don't declare sigemptyset.
-
- * version.c: updated to beta 1.03.
-
- * chat.c (fcsend): Scott Ballantyne: go ahead and send a character
- for an illegal escape sequence rather than failing out.
-
- * uuxqt.c (uqdo_xqt_file), sys5.unx (zsysdep_find_command): cast
- result of alloca.
-
- * protg.c (fgprocess_data): Niels Baggesen: improved debugging
- information. Also tweaked fgprocess_data code to use memchr to
- find the next DLE rather than searching for it by hand.
-
- * uucico.c (faccept_call, fuucp): accept SVR4 -U flag giving
- maximum file transfer size; accept and ignore SVR4 -R flag meaning
- that the system supports file restart.
-
-Sun Mar 15 00:21:56 1992 Ian Lance Taylor (ian@airs.com)
-
- * sysinf.c (titime, titimegrade): permit a retry time to be
- specified as an optional additional argument.
-
- * uucico.c (zget_uucp_cmd, zget_typed_line): turn off DEBUG_PORT
- when doing DEBUG_HANDSHAKE.
-
- * policy.h, sysh.unx, sys1.unx, sys2.unx (fsblock_writes,
- fsserial_write, fsserial_io): added configuration parameters
- HAVE_UNBLOCKED_WRITES and SINGLE_WRITE. Also blocked signals
- while clearing afSignal in fsysdep_modem_close.
-
- * chat.c (icexpect, fcsend): turn off DEBUG_PORT while doing chat
- script debugging.
-
- * sysh.unx, sys2.unx (fsserial_lock, fsserial_open,
- fsserial_write, fsserial_io, fsysdep_tcp_read, fsysdep_tcp_write,
- fsysdep_tcp_io): T. William Wells: some systems don't support
- unblocked writes, so don't use them.
-
- * port.c (fport_read, fport_write): show calls to fport_read and
- fport_write under DEBUG_PORT.
-
- * bnu.c (fbnu_find_port): Scott Ballantyne: accept "Any" as a
- Device speed.
-
-Sat Mar 14 20:52:11 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h, system.h, sysh.unx, uucico.c (main, zget_typed_line),
- uuxqt.c (main), uucp.c (main), uux.c (main, uxcopy_stdin), tcp.c
- (ftcp_open), log.c (ulog, ulog_close), sys1.unx (ussignal),
- sys2.unx (fsserial_close, fsysdep_modem_end_dial, fsserial_read,
- fsserial_write, fsserial_io, fsysdep_tcp_read, fsysdep_tcp_write,
- fsysdep_tcp_io): T. William Wells and Chip Salzenberg: keep an
- array of signals so that a new signal doesn't obliterate our
- knowledge of an old signal. Johan Vromans: if we get SIGINT
- continue the current session but don't start any new ones.
-
- * sysh.unx, sys1.unx (isspawn, espopen, iswait, fsysdep_mail,
- fsysdep_run, getcwd, mkdir), sys2.unx (fsrun_chat), sys3.unx
- (fsysdep_wildcard_start), sys5.unx (fsysdep_execute), sys7.unx
- (fsysdep_lock_status), uuxqt.c (uqdo_xqt_file), tcp.c (ftcp_open),
- tstuu.c (uchild): added function isspawn, espopen and iswait and
- channeled all execs of new processes and waits through them.
-
-Fri Mar 13 18:00:04 1992 Ian Lance Taylor (ian@airs.com)
-
- * sysinf.c (uset_system_defaults): Chip Salzenberg: changed
- default login script timeout to 10 seconds.
-
- * prot.h, prot.c (freceive_data, breceive_char), protg.c, protf.c,
- prott.c, prote.c: changed breceive_char to go through
- freceive_data rather than calling fport_read directly. Added an
- freport argument to freceive_data, and change all old calls to
- pass it in as FALSE.
-
-Thu Mar 12 14:49:59 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h: added a padding byte to scmd structure, since at least
- one compiler needs it.
-
- * uucp.c (main): use fake local name (from ``myname'' command)
- when generating an execution request intended for the local
- system.
-
- * sysh.unx: corrected readdir prototype.
-
- * sys2.unx: moved local header files ahead of sleep routine
- determination.
-
- * General overhaul to change debugging system. Debugging is now
- done by type rather than by number. iDebug is now interpreted as
- a bit sequence. DEBUG may only be 0 (no checks or debugging), 1
- (checks, no debugging) or 2 (checks and debugging). The debugging
- names are parsed by idebug_parse and tidebug_parse in config.c.
- The debugging types are additive. Many source files changed.
- Inspired by Michael Richardson, Johan Vromans and Peter da Silva.
-
-Wed Mar 11 12:01:03 1992 Ian Lance Taylor (ian@airs.com)
-
- * policy.h, uuxqt.c (uqdo_xqt_file): Chip Salzenberg: support
- Internet mail addresses in uuxqt replies (added configuration
- parameter HAVE_INTERNET_MAIL to control this).
-
- * sys7.unx (fskill_or_rejuv): permit uucp user to delete any job.
-
- * uucp.h, system.h, sysh.unx, config.c, uuxqt.c (main, uqabort),
- sys5.unx (isysdep_lock_uuxqt, fsysdep_unlock_uuxqt), bnu.c
- (ubnu_read_sysfiles): Marty Shannon: added max-uuxqts command,
- along with support for BNU Maxuuxqts, to limit number of
- concurrent uuxqt processes.
-
- * chat.c (icexpect, fcsend), uucico.c (zget_uucp_cmd,
- zget_typed_line): improved debugging by avoiding incredibly long
- lines.
-
- * system.h, sys5.unx (fsysdep_execute), uuxqt.c (uqdo_xqt_file):
- Jon Zeef: if a temporary failure occurs, retry the execution
- later.
-
-Tue Mar 10 12:40:30 1992 Ian Lance Taylor (ian@airs.com)
-
- * sysh.unx, sys1.unx (isfork), sys2.unx, sys5.unx, tcp.c:
- Franc,ois Pinard: retry fork several times before giving up.
-
- * uucp.h, prot.c (fploop, fgot_data), file.c (usendfile_error,
- urecfile_error, frecfile_rewind): Niels Baggesen: if we can't read
- or write a file, treat it as a temporary error rather than a
- permanent error; if we get an error on write, drop the connection
- rather they try to continue.
-
- * uucp.h, system.h, sysh.unx, uucico.c (fuucp), prot.c
- (fsend_file, freceive_file), file.c (fsent_file, usendfile_error,
- freceived_file, urecfile_error, fmail_transfer), sys1.unx
- (usmake_spool_dir), sys4.unx (zsysdep_save_temp_file): if a file
- send fails, save the file away rather than lose it forever.
-
- * uucico.c (main): don't run uuxqt if we got a SIGTERM.
-
- * tcp.c (ftcp_open): Petri Helenius: have server fork twice to
- avoid zombies.
-
- * port.h, prtinf.c, v2.c, bnu.c (fbnu_find_port), uucico.c
- (fdo_call, faccept_call), uuchk.c (fkshow_port): added protocol
- command for ports, mostly to support BNU. Also modified uuchk to
- make the absence of any matching port or dialer more obvious.
-
- * sys3.unx (esysdep_open_receive): check size of destination file
- system as well as temporary file system; handle f_bsize field
- under FS_MNTENT.
-
- * configure.in, sysh.unx: test for including <termios.h> and
- <sys/ioctl.h> in the same file, setting new configuration
- parameter HAVE_TERMIOS_AND_SYS_IOCTL_H accordingly; handle it in
- sysh.unx.
-
-Mon Mar 9 00:06:12 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys2.unx (fsserial_close): Franc,ois Pinard: sleep for a second
- after closing the serial port to give it a chance to settle.
-
- * sysh.unx (fsetterminfodrain), sys2.unx (fsserial_close,
- fsserial_reset, fsserial_set): wait for terminal output to drain
- before closing it, resetting it, or changing its parameters.
-
- * uucico.c (zget_uucp_cmd): Ted Lindgreen: strip parity bit from
- initial handshake strings.
-
- * system.h, sys3.unx (esysdep_open_send), uucico.c (fuucp): Ted
- Lindgreen: don't send a mail message if a file to send has been
- removed, since it might have been sent in a previous session.
-
- * uuchk.c (ukshow): Zacharias Beckman: put list of permitted
- programs and execution path on separate lines.
-
- * uucico.c (fdo_call, faccept_call): only look for hangup string
- in debugging mode, since there's nothing to be done with it
- anyhow.
-
- * uucico.c (faccept_call): Ted Lindgreen: report the minimum
- transfer grade requested during an incoming call in the log file.
-
- * uucp.h, uutime.h, config.c, uucico.c (fcall), time.c
- (ftimespan_match, btimegrade, cmax_size_now): added a new status
- type for ``wrong time to call''. If a system can never be called,
- this status type is not used (if an attempt is made to call the
- system, the status is left unchanged).
-
-Sun Mar 8 11:41:45 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (main, flogin_prompt, faccept_call): Ted Lindgreen: if
- we were asked to call a single system, or if a single system
- called in, then start uuxqt with -s for just that system.
-
- * uucico.c (main): Ted Lindgreen: ignore the -u option.
-
- * tstuu.c: Ted Lindgreen: don't include <sys/ioct.h> if it's not
- there. Also removed the ``ignore this error'' message from the
- chat scripts since it's no longer marked as an error.
-
- * sys2.unx (fsserial_set): Ted Lindgreen: if CRTSCTS is defined
- and turned on, then don't turn on IXOFF.
-
- * uucp.h, log.c, uucico.c (fdo_call, faccept_call): Ted Lindgreen:
- report the port name and (for incoming calls) the login name in
- the log file.
-
-Sat Mar 7 10:00:47 1992 Ian Lance Taylor (ian@airs.com)
-
- * port.h, prtinf.c, sys2.unx (fsserial_lockfile, fsserial_lock):
- Peter da Silva: added ``lockname'' command to ports to permit
- specification of the file name to use when locking.
-
- * sys1.unx (usysdep_detach): let setpgrp fail silently.
-
- * sys2.unx: always include <sys/ioctl.h> if it's present on the
- system.
-
- * time.c (btimegrade, cmax_size_now): removed extraneous
- semicolons.
-
- * sys2.unx (fsserial_lock, fsserial_open, fsserial_close): support
- TIOCEXCL locking.
-
- * sys2.unx (fsserial_open): preserve unknown bits in c_cflag when
- using HAVE_SYSV_TERMIO or HAVE_POSIX_TERMIOS.
-
- * prot.h: never included more than once.
-
-Fri Mar 6 21:53:28 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h: Eric Ziegast: some systems don't define EXIT_SUCCESS or
- EXIT_FAILURE in stdlib.h.
-
- * uucp.h, uutime.h, uucico.c (fuucp), sysinf.c (uinittimetables,
- uaddtimetable), uuchk.c (main, ukshow_size, ukshow_time,
- qcompress_span), time.c (all new): rewrote time routines
- completely for consistency and simplicity. Fixed bug causing
- incorrect maximum possible transfer size. Added new file
- uutime.h.
-
-Wed Mar 4 10:06:13 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys2.unx (fsserial_lockfile, fsserial_lock, fsysdep_modem_open,
- fsysdep_direct_open, fsysdep_modem_close, fsysdep_direct_close):
- Petri Helenius: if the open failed on a serial port, the lock
- files were not removed.
-
- * config.c (igradecmp): the local variables in igradecmp have to
- be integers; signed characters might not work correctly (although
- they would in all normal cases).
-
- * sys4.unx (fsysdep_has_work): Johan Vromans: set *pbgrade
- correctly if we still have work left over that we haven't looked
- at yet.
-
- * tstuu.c (main, uchoose, fwriteable): Roberto Biancardi: use poll
- if we haven't got select.
-
- * uucico.c (zget_uucp_cmd): Michael Haberler: some systems send \n
- after Shere, rather than a null byte.
-
-Tue Mar 3 01:03:22 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuxqt.c (main, uqdo_xqt_file): permit local executions, don't
- get grade out of system dependent file name.
-
- * sys4.unx (fsysdep_get_work): Bob Denny: warn if we can't open a
- command file.
-
- * v2.c (uv2_read_systems): Jeff Putsch: infinite loop when reading
- time string.
-
- * uucp.h, sys1.unx, sys2.unx, sys3.unx, tstuu.c, configure.in:
- Thomas Fischer: some NeXT compatibility stuff: removed externs of
- sleep and alarm, included <libc.h> in uucp.h.
-
- * uucp.h, port.h, uucico.c (zget_uucp_cmd, zget_typed_line),
- port.c (cdebug_char, udebug_buffer), chat.c (icexpect, fcsend,
- fcphone), log.c (ulog): Michael Richardson: added LOG_DEBUG_START,
- LOG_DEBUG_CONTINUE and LOG_DEBUG_END to allow a debugging line in
- the log file to be built character by character. Used this new
- feature in chat script debugging, rather than having each
- character appear on a separate line. Added fPort_debug variable
- to control port debugging.
-
- * uustat.c (fsquery, fsquery_system, fsquery_show): handle
- execution files queued up for the local system correctly when
- using -q option (they still don't show up on any other option).
-
- * uucp.texi, protg.c (fgstart, fgshutdown): Aleksey P. Rudnev:
- added remote-window and remote-packet-size 'g' protocol
- parameters. Reset the parameters to their default values in
- fgshutdown.
-
- * sysh.unx, sys2.unx (fsserial_read, usalarm), sys1.unx
- (usset_signal, usysdep_detach), uucico.c (main): overhauled
- fsserial_read yet again. The timeout passed in is now an absolute
- bound. A special SIGALRM handler does some wierd stuff to avoid
- any possible race.
-
- * config.c (uread_config), sysinf.c (uiread_systems,
- fcallout_login, fcheck_login), prtinf.c (ffind_port,
- fread_dialer_info), chat.c (fctranslate), uucico.c (faccept_call):
- T. William Wells: when using HAVE_TAYLOR_CONFIG in combination
- with V2 or BNU configuration files, don't complain if the
- HAVE_TAYLOR_CONFIG files are missing.
-
-Mon Mar 2 10:21:36 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys2.unx (fsserial_read): T. William Wells: don't arbitrarily
- extend read timeout.
-
- * uux.c (main): check iSignal before entering fread, since the
- user may have hit ^C earlier in the program.
-
-Sun Mar 1 23:39:33 1992 Ian Lance Taylor (ian@airs.com)
-
- * policy.h, uucp.h, sysh.unx, sys2.unx (fsserial_lock,
- fsysdep_modem_close, fsysdep_direct_close), util.c (strlwr),
- configure.in: Marc Unangst: added HAVE_SCO_LOCKFILES configuration
- parameter to force lock file names to lower case.
-
-Fri Feb 28 00:07:12 1992 Ian Lance Taylor (ian@airs.com)
-
- * system.h, uucico.c (faccept_call, fdo_xcmd), uuxqt.c
- (uqdo_xqt_file), uux.c (main), uucp.c (main, ucspool_cmds),
- sys3.unx (zsysdep_spool_cmds), uux.1, uucp.1: added -j switch to
- uucp and uux to display the jobid of the spooled job.
-
- * uucp.h, system.h, sysh.unx, uucico.c (fuucp, fdo_xcmd,
- fok_to_send, fok_to_receive), uuxqt.c (uqdo_xqt_files), uux.c
- (main, uxcopy_stdin), uucp.c (main), file.c (freceived_file),
- config.c (fin_directory_list), sys1.unx (fsysdep_file_exists,
- fsuser_access, fsysdep_in_directory), sys3.unx (esysdep_open_send,
- fsysdep_move_file), sys5.unx (fsysdep_xqt_check_file): Chip
- Salzenberg: recheck file access permissions before sending, to try
- to avoid symbolic link games. Check that the user has search
- access on all directories down to the file, and read or write
- access to the file or directory itself. Check in uucp and uux as
- well as uucico, to provide early messages. Check the standard
- input file in uuxqt. Be more careful about creating files in the
- spool directory. This eliminates all security problems I know of,
- except for a very short race in fsysdep_move_file.
-
- * sys3.unx (esysdep_open_send): give an error message if we try to
- send a directory (used to just fail silently).
-
- * system.h, sysh.unx, sys1.unx (usysdep_detach, ussignal,
- fsysdep_catch, usysdep_start_catch), sys2.unx
- (fsysdep_modem_end_dial, fsserial_read), uux.c (main): T. William
- Wells: fsysdep_catch obviously must be a macro, since it calls
- setjmp. Also TIOCNOTTY sets the process group to 0, so we don't
- have to fork before calling it.
-
-Thu Feb 27 00:08:09 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys1.unx, sys6.unx, sys7.unx: added some extern definitions.
-
- * configure.in, uucp.h, system.h, sysh.unx, uucico.c (main,
- ucatch, uabort, zget_typed_line, zget_uucp_cmd), uuxqt.c (main,
- uqcatch, uqabort), uux.c (main, uxcatch, uxrecord_file, uxabort),
- uucp.c (main, uccatch, ucrecord_file, ucabort), uustat.c (main,
- uscatch), uulog.c (main, ulcatch), uuname.c (main, uncatch),
- uucheck.c (main, ukcatch), log.c (ulog_fatal_fn, ulog,
- ulog_close), tstuu.c (main, uchild, uprepare_test), sys1.unx
- (usysdep_initialize, usysdep_detach, usysdep_signal,
- fsysdep_catch, usysdep_end_catch, ussignal, fsset_signal,
- fsysdep_run, raise), sys2.unx (usalarm, usysdep_pause,
- fsserial_lock, fsserial_open, fsysdep_stdin_close,
- fsysdep_modem_close, fsysdep_modem_end_dial, fsserial_read,
- fsserial_write, fsserial_io), sys5.unx (fsysdep_execute): T.
- William Wells: overhaul to support detaching from the terminal and
- completely reliable signals. uucico now calls usysdep_detach at
- various points; new option -D prevents detaching. The signal
- handling code all goes through usysdep_signal, fsysdep_catch and
- usysdep_end_catch. A signal now just sets iSignal, which is
- checked at various points, notably in the port routines and in the
- main loops in uucico and uuxqt.
-
-Tue Feb 25 10:59:23 1992 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgwait_for_packet): Bob Denny: reset the count of
- timeouts only when data is recognized, so that we aren't fooled by
- a sequence of imperfect echoes.
-
- * sys5.unx (zsysdep_get_xqt): Bob Denny: don't warn if opendir
- gets ENOENT. I think POSIX requires ENOTDIR, but what can you do?
-
-Mon Feb 24 14:37:10 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (main, uusage): don't treat an extra argument as a port
- name.
-
- * sys3.unx (esysdep_truncate): Roberto Biancardi: support F_CHSIZE
- and F_FREESP in esysdep_truncate.
-
- * configure.in, sys2.unx (fsserial_read, usysdep_pause): Roberto
- Biancardi: use poll to sleep less than a second if we haven't got
- anything else.
-
- * v2.c (uv2_read_systems, fv2_find_port), bnu.c
- (ubnu_read_systems, fbnu_find_port, fbnu_read_dialer_info),
- uustat.c (fsworkfile_show): Roberto Biancardi: skip spaces and
- tabs after doing a strtok ((char *) NULL, "").
-
- * copy.c (fcopy_file), sys1.unx (esysdep_fopen), sys2.unx,
- sys3.unx (esysdep_open_receive, esysdep_truncate, fsdo_lock,
- fscmd_seq), sys5.unx (fsysdep_execute), sys7.unx, tstuu.c: John
- Theus: some systems use <sys/file.h> instead of <fcntl.h>. Also
- changed the code to call creat instead of open when appropriate.
- Should now work on V7, with the exception of O_NONBLOCK and
- O_NDELAY in sys2.unx and tstuu.c.
-
- * uucp.h: John Theus: if we don't have vprintf, ulog is defined
- without an ellipsis, so don't declare it with one.
-
-Sun Feb 23 14:45:53 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h, system.h, bnu.c (ubnu_read_systems), config.c
- (fin_directory_list), sys1.unx (fsysdep_in_directory), sys5.unx
- (fsysdep_xqt_check_file), uucp.c (main), uuxqt.c (uqdo_xqt_file),
- uucico.c (fdo_xcmd, fok_to_send, fok_to_receive), tstuu.c
- (uprepare_test): only permit files to be received into directories
- that are world writeable. Check for this in fsysdep_in_directory,
- with a new argument. Changed calls appropriately. In tstuu
- create /usr/tmp/tstuu as world writeable.
-
- * bnu.c (ubadd_perm_alternate): Doug Evans: after all that, I got
- it wrong: WRITE only applies to remote requests.
-
- * uucp.h, uucico.c (fuucp, fdo_xcmd, fok_to_send, fok_to_receive),
- uuxqt.c (uqdo_xqt_file), uuchk.c (ukshow), sysinf.c
- (uset_system_defaults, tialternate), sys5.unx
- (fsysdep_xqt_check_file), bnu.c (ubadd_perm_alternate): fixed READ
- and WRITE handling to match BNU semantics. Added
- zcalled_local_send, zcalled_local_receive, zcalled_remote_send and
- zcalled_remote_receive fields to ssysteminfo structure for this,
- and handled them in all the appropriate places.
-
-Sat Feb 22 22:30:59 1992 Ian Lance Taylor (ian@airs.com)
-
- * Complete overhaul of configuration to use automatic shell
- script. Eliminated conf.h, now generated by configure. Renamed
- Makefile to Makefile.in. Added policy.h for administrative
- decisions and other choices which can not be made automatically.
- Many changes to many source files, none having to do with code.
-
-Thu Feb 20 17:57:55 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fdo_call): Chip Salzenberg: some systems truncate the
- Shere= machine name to 7 characters.
-
-Wed Feb 19 14:36:31 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys7.unx (fskill_or_rejuv): make sure that only the submitter or
- the superuser is permitted to cancel (or rejuvenate) a request.
-
- * system.h, sysh.unx, sys3.unx (zsfile_to_jobid, zsjobid_to_file),
- sys4.unx (zsysdep_jobid), sys7.unx, uustat.c, Makefile, MANIFEST:
- wrote uustat. Changed CSEQLEN in sys3.unx from 5 to 4. Added
- several new system dependent functions, mostly in sys7.unx.
-
- * system.h, sys1.unx, log.c, file.c, chat.c, protg.c, uucico.c:
- rearranged the time functions for the convenience of uustat. Made
- isysdep_time take an optional pimicros arguments. Renamed
- usysdep_full_time to isysdep_process_time, and made clear that it
- need only work within a single process. Changed usysdep_localtime
- to take a time returned by isysdep_time rather than always use the
- current time. Changed the calls as appropriate.
-
-Tue Feb 18 14:03:19 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuxqt.c (main): pass fdaemon argument correctly to
- usysdep_initialize.
-
-Mon Feb 17 17:09:16 1992 Ian Lance Taylor (ian@airs.com)
-
- * uuxqt.c (uqdo_xqt_file): T. William Wells: make sure sh uses
- absolute path of command, rather than relying on PATH.
-
- * sys5.unx (zsysdep_find_command): Michael Nolan: allow full
- command name to be specified by remote system, not just basename,
- if command is not in path.
-
- * log.c (ulog): don't use headers when outputting to terminal.
-
- * sys2.unx (fsrun_chat): Bob Denny: log chat program messages as
- LOG_NORMAL, not LOG_ERROR.
-
-Fri Feb 14 00:17:57 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (ucatch), uuxqt.c (uqcatch): Neils Baggesen: under
- HAVE_BNU_LOGGING, don't lose the system name when dieing.
-
- * uulog.c, Makefile, MANIFEST: wrote uulog.
-
- * uuname.c, Makefile, MANIFEST: wrote uuname.
-
- * bnu.c (ubadd_perm_alternate): T. William Wells: must xstrdup the
- system name before calling uadd_validate.
-
- * log.c (ulog_close): Micheal Nolan: don't refer to eLdebug if the
- DEBUG configuration parameter is 0.
-
- * uucp.c (main): Niels Baggesen: abtname must be copied into
- memory, or it will be overwritten by the next file to be copied.
-
-Sun Feb 9 00:12:58 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fuucp), prot.c (fsend_file, freceive_file): Bob Denny:
- call fmail_transfer before calling fsysdep_did_work, because the
- latter frees up strings used by the former.
-
- * sysh.unx, sys1.unx (mkdir), uudir.c (new file), Makefile: added
- HAVE_MKDIR configuration parameter for systems without the mkdir
- system call. The emulation function in sys1.unx invokes the new
- suid program uudir which sets its uid to uucp and invokes
- /bin/mkdir. Added rules to create uudir to Makefile.
-
-Sat Feb 8 14:25:50 1992 Ian Lance Taylor (ian@airs.com)
-
- * sysh.unx, sys1.unx (opendir, readdir, closedir), sys4.unx,
- sys5.unx: added HAVE_OLD_DIRECTORIES configuration parameter to
- support systems without opendir/readdir/closedir which use
- original Unix directory format.
-
- * sysh.unx, sys1.unx (dup2): added HAVE_DUP2 configuration
- parameter and dup2 emulation function.
-
- * sys1.unx (zsysdep_local_name): put utsname structure on stack
- rather than making it static.
-
- * sysh.unx, sys1.unx (usysdep_initialize, getcwd): if we have
- neither getcwd nor getwd, fork /bin/pwd to get the current working
- directory.
-
- * system.h, uucico.c (main), uuxqt.c (main), uux.c (main), uucp.c
- (main), uuchk.c (main), sys1.unx (usysdep_initialize), sys6.unx
- (fsysdep_needs_cwd, zsysdep_add_cwd): because getting the current
- working directory can be expensive on Unix, since some
- implementation of getcwd fork a shell to execute pwd, only try to
- get the cwd if it is going to be needed by uux or uucp.
-
- * uucico.c (main), uuxqt.c (main), uux.c (main), uucp.c (main),
- uuchk.c (main), log.c (ulog): handle all possible signals raised
- by abort, namely SIGABRT, SIGILL and SIGIOT. In ulog always call
- abort rather than raise (SIGABRT).
-
- * sys4.unx (usysdep_get_work_free): the qSwork_file information
- was freed up incorrectly if a file transfer failed.
-
- * sysh.unx, sys2.unx: Archaic Zilog System III computers use
- setret and longret rather than setjmp and longjmp, so I added a
- HAVE_SETRET configuration option.
-
- * prott.c (ftstart, ftsenddata): shifts of integers by more than
- 15 are not portable.
-
- * prot.c (fsend_file, freceive_file, fploop, fgot_data): I ran
- into an old compiler which couldn't handle the calls to pffile, so
- I simplified them to use a variable.
-
- * port.c (fmodem_dial): cast result of alloca.
-
- * getopt.h, getopt.c: Jay Vassos-Libove: renamed getopt and
- related variables by macro defining them to gnu_*. This avoids
- conflicts with system header files and system libraries.
-
-Fri Feb 7 12:08:42 1992 Ian Lance Taylor (ian@airs.com)
-
- * everything: added HAVE_STRING_H and HAVE_STRINGS_H. Removed
- include of <string.h> in every source file and put it in uucp.h.
- Since I had to change everything anyhow, added 1992 to the
- copyright date.
-
- * uucico.c (fcall): Bob Denny: retry time not reached is not
- really an error, so just make a normal log entry for it.
-
-Sun Feb 2 01:38:47 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucp.c (main): Get the file name for the destination of a local
- copy using zsysdep_real_file_name rather than zsysdep_in_dir,
- since the latter doesn't get the basename of the argument.
-
- * sys3.unx (fsysdep_get_status): Niels Baggesen: cast enum to int
- before comparison.
-
- * system.h, uucp.c (main), uux.c (main), sys6.unx (fsysdep_access,
- fsysdep_daemon_access): Niels Baggesen: check user access to file
- since programs are running setuid. Previously uucp and uux
- permitted a file readable only by uucp to be transferred to
- another system by user request!
-
- * chat.c (fchat): Michael Nolan: portions of a chat string might
- be separated by more than just a single space if they are read
- from a V2 or BNU configuration file.
-
-Fri Jan 31 19:51:57 1992 Ian Lance Taylor (ian@airs.com)
-
- * protg.c: Chip Salzenberg: change default window size to 7.
-
- * sys3.unx (fsdo_unlock): Michael Nolan: cast result of alloca to
- (char *), not that it really matters.
-
- * log.c (ulog): Michael Nolan: if SIGABRT is not defined, just
- call abort.
-
-Thu Jan 30 18:19:33 1992 Ian Lance Taylor (ian@airs.com)
-
- * bnu.c (ubadd_perm): Michael Nolan: debugging check was done
- wrong for entry with LOGNAME but no MACHINE.
-
-Wed Jan 29 13:28:59 1992 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (zget_uucp_cmd): Patrick Smith: only wait a short time
- for the hangup string.
-
- * sys4.unx (iswork_cmp): Patrick Smith: fixed casts to not cast
- away const.
-
-Tue Jan 28 11:06:34 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys1.unx, sys3.unx, tstuu.c: Jay Vassos-Libove: removed some
- declarations of system functions that conflict with system header
- files on BSD/386 alpha.
-
- * Makefile: Jeff Ross: make sure the uninstall target restores the
- original file owner and mode.
-
- * protg.c (fgsendcmd): the previous patch wasn't really correct.
-
-Mon Jan 27 22:30:47 1992 Ian Lance Taylor (ian@airs.com)
-
- * log.c (ustats): Marty Shannon: don't report a failed transfer
- under USE_BNU_LOGGING.
-
- * sys3.unx (zsysdep_real_file_name): Marty Shannon: a trailing '/'
- on the name means that it is a directory, even if the directory
- does not already exist.
-
- * uucico.c (fuucp): Marty Shannon: the -f flag indicating that
- directories should not be created was not being handled correctly.
-
- * uucico.c (fcall): Chip Salzenberg: set .Status correctly if
- wrong time to call.
-
- * protg.c (fgsendcmd): John Antypas: didn't handle null byte at
- end of command which was exactly a power of two in length
- correctly.
-
-Tue Jan 21 14:37:10 1992 Ian Lance Taylor (ian@airs.com)
-
- * Released version 1.02.
-
- * system.h, uucico.c (main), uux.c (main), uucp.c (main,
- zcone_system), sys1.unx (fsysdep_run): Chip Salzenberg: have uucp
- and uux start up uucico -s system rather than uucico -r1.
-
-Mon Jan 20 11:45:38 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys1.unx (fsysdep_make_dirs): don't try to create a directory
- with no name.
-
- * version.c: change version number to 1.02.
-
- * uucico.8, uuxqt.8, uucp.1, uux.1: change version number to 1.02.
-
- * MANIFEST: removed texinfo.tex; it's twice the size of any other
- file, so I think it's just to large to distribute.
-
- * uucico.c (fcall, fdo_call): Marty Shannon: update the time in
- the .Status file if it's the wrong time to call, and upon
- receiving a call.
-
-Sun Jan 19 13:29:23 1992 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgsendcmd, fgsenddata): Dave Platt: if the remote UUCP
- accepts packets larger than 64 bytes, assume it can handle
- differing packet sizes, so if we have a small amount of data to
- send, use a small packet. Besides the two routines mentioned,
- also made minor changes to other routines to get the packet length
- out of the packet data rather than always assuming the same packet
- size.
-
- * conf.h, uucp.h: Matthew Lyle: some systems don't declare errno
- in <errno.h>, so I added HAVE_ERRNO_DECLARATION.
-
- * conf.h, uucp.h, util.c (bsearch): added HAVE_BSEARCH
- configuration parameter.
-
-Sat Jan 18 17:45:28 1992 Ian Lance Taylor (ian@airs.com)
-
- * tstuu.c (utransfer): Mike Park: don't sleep when the input
- buffer is full; it's too slow.
-
- * Makefile: when making a distribution,change the mode of separate
- copies of the configuration files Makefile, conf.h and sysh.unx.
-
- * uucico.c (faccept_call): Marty Shannon: update .Status file on
- incoming calls.
-
- * uucp.h, prot.h, uucico.c (fuucp), prot.c (fsend_file,
- fpsendfile_confirm, freceive_file, fprecfile_confirm, fxcmd,
- ustats_failed), file.c (fsent_file, usendfile_error,
- freceived_file, urecfile_error, frecfile_rewind, fmail_transfer):
- reworked calls to fsydep_did_work and sending of mail messages to
- be more sensible. Now sends mail to requestor if request fails
- permanently and does not remove file if request fails only
- temporarily.
-
-Thu Jan 16 11:33:08 1992 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgsendcmd, fgsenddata): zero out unused bytes in short
- packets.
-
- * prot.c (zgetcmd), protf.c (ffsendcmd), prott.c (ftsendcmd),
- prote.c (fesendcmd): Niels Baggesen: added some debugging
- messages.
-
- * protg.c (fgsendcmd): corrected misspelling in debugging message.
-
- * log.c (ustats): Niels Baggesen: add FAILED to end of xferstats
- line if appropriate.
-
- * uuxqt.c (uqdo_xqt_file): Niels Baggesen: was checking strcmp
- return value incorrectly, so messages to other systems were not
- being sent.
-
- * sys2.unx, tstuu.c: Mike Park: ioctl is sometimes declared
- varadic, so we can't declare it.
-
-Wed Jan 15 02:03:43 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys1.unx: put \n at end of fsysdep_run error message.
-
- * sysh.unx, sys1.unx, sys2.unx, tstuu.c: Mike Park: on some
- systems <sys/time.h> includes <time.h> but <time.h> can only be
- included once; added HAVE_SYS_TIME_AND_TIME_H to sysh.unx.
-
- * tstuu.c: Mike Park: removed prototype for times since some
- systems don't have clock_t.
-
- * conf.h, sys2.unx, util.c: Mike Park: some systems don't have
- <limits.h>. Every macro used from it already had a check to make
- sure it was defined anyhow.
-
- * tstuu.c (uprepare_test): Mike Park: sh on NeXT interprets a
- leading ~, so we have to quote the argument to system(3).
- Incredible.
-
- * conf.h, uucp.h: Mike Park: if HAVE_ALLOCA is 0 when compiling
- with gcc, don't define alloca as a macro. This will let the NeXT
- define it in some header file.
-
- * sysh.unx, sys2.unx, sys5.unx, tstuu.c: Mike Park: handle
- HAVE_UNION_WAIT completely. Assume that system(3) returns an int
- which should be put into the w_status field. Define macros for
- union wait if they are not already defined. Move all this stuff
- into sysh.unx rather than duplicating it in three different files.
-
- * conf.h, uucp.h, sysh.unx, config.c, bnu.c, v2.c, uucico.c,
- uuxqt.c, uux.c, uucp.c, uuchk.c, Makefile: set directory to look
- for configuration files in in Makefile rather than in sysh.unx.
- This forced a number of changes, as now all new style
- configuration files are looked up using NEWCONFIGLIB. Old style
- configuration files are looked up using OLDCONFIGLIB.
-
-Mon Jan 13 00:35:43 1992 Ian Lance Taylor (ian@airs.com)
-
- * sys3.unx: David Nugent: don't declare chmod, since it may be
- prototyped to take an argument that is smaller than an int.
-
- * uucico.c (faccept_call): Chip Salzenberg: only declare sportinfo
- if it will be used (if HAVE_TAYLOR_CONFIG is true).
-
- * sys3.unx (isysdep_get_sequence): Chip Salzenberg: avoid use
- before set warning from gcc.
-
- * protf.c (ffprocess_data): Chip Salzenberg: avoid use before set
- warning from gcc.
-
- * sysh.unx, sys2.unx (fsserial_read, usysdep_pause): Chip
- Salzenberg: added HAVE_USLEEP configuration parameter for the AIX
- usleep routine.
-
- * uuchk.c, prtinf.c, config.c: Chip Salzenberg: strcmp is a macro
- on AIX, so avoid declaring it and undef it in config.c where we
- want to declare it because we want to take its address.
-
- * uucp.h, sys3.unx (fsysdep_get_status, fsysdep_set_status): Chip
- Salzenberg: handle out of range status codes in status files.
-
- * Makefile, sysh.unx: defined LIBDIR in the Makefile, rather than
- forcing the user to define it in two different places.
-
- * sys.unx, tstuu.c: Chip Salzenberg: can't declare execl, since it
- is varadic.
-
- * sys1.unx, sys2.unx, sys3.unx, sys5.unx, tstuu.c: David Nugent:
- can't declare open or fcntl, since they may use ... in header file
- prototype; added declaration for popen; added casts of first mkdir
- argument to char *.
-
- * sysh.unx, tstuu.c (uchild): Mike Park: added HAVE_WAITPID and
- HAVE_WAIT4 configuration parameters to allow the use of wait4 as
- found on the NeXT.
-
- * tstuu.c (uprepare_test): Mike Park: use IPUBLIC_DIRECTORY_MODE
- rather than S_IRWXU | S_IRWXG | S_IRWXO.
-
- * sysinf.c (tisystem): Mike Park: ulog was being passed the wrong
- number of arguments.
-
-Sun Jan 12 14:32:47 1992 Ian Lance Taylor (ian@airs.com)
-
- * Eliminated CONFIG, INSTALL and THANKS. They are now included in
- uucp.texi. Changed README and MANIFEST accordingly. Added
- uucp.info* and texinfo.tex to MANIFEST.
-
- * Makefile, uucp.texi: renamed taylor.texi to uucp.texi.
-
- * uucico.c (fcall, fdo_call): John Antypas: pass in sportinfo
- structure for fdo_call to use for an unknown port.
-
- * log.c (ulog): allocate enough bytes to name file if
- HAVE_BNU_LOGGING is in use but zLogfile has no %s.
-
-Sat Jan 11 12:11:56 1992 Ian Lance Taylor (ian@airs.com)
-
- * Makefile: changed to correspond to GNU standards, according to
- standards.text of 24 Nov 91.
-
- * Makefile: Franc,ois Pinard: use $(INSTALL_PROGRAM) and
- $(INSTALL) rather than cp to install the programs.
-
- * time.c (ftime_now), sys1.unx (usysdep_localtime): John Antypas:
- use memcpy to get the result of localtime rather than relying on
- structure assignment.
-
- * sysh.unx, prtinf.c: Hannu Strang: changed definition of
- SYSDEP_STDIN_CMDS to pass structure instead of address of
- structure to avoid bug in AIX compiler which causes it to fail to
- recognize an address constant containing the -> operator.
-
-Tue Jan 7 10:22:43 1992 Ian Lance Taylor (ian@airs.com)
-
- * Released beta 1.02.
-
- * protg.c (fgcheck_errors): discount out of order packets in the
- total error count, and allow a negative error count to mean that
- any number of errors are accepted.
-
- * sysinf.c (tadd_proto_param): Niels Baggesen: allocate number of
- protocol parameters based on *pc, not sIhold.cproto_params.
-
-Sat Jan 4 16:42:21 1992 Ian Lance Taylor (ian@airs.com)
-
- * log.c (ulog): tweaked HAVE_V2_LOGGING slightly.
-
- * v2.c (uv2_read_systems): set chat script correctly.
-
- * uucp.h, sys3.unx: avoid redefining SEEK_SET if it appears in
- <unistd.h> but not <stdio.h>.
-
- * chat.c (fcsend): made fcsend into a static function.
-
- * uucp.h, uucico.c, uuxqt.c, uux.c, uucp.c, uuchk.c, version.c:
- changed abProgram and abVersion from const char [] to char []
- because the Microsoft compiler on SCO can't handle const char []
- arrays correctly.
-
- * uux.c (main): allocate enough space for log message.
-
- * sys1.unx (usysdep_localtime): to get the current time, we can't
- call usysdep_full_time if the latter uses times.
-
- * sys1.unx, sys3.unx: added a couple more extern definitions for
- SCO 3.2.2.
-
- * uucico.c (main): start uuxqt even if a call fails.
-
- * sysh.unx, system.h, uuxqt.c (uqdo_xqt_file), sys5.unx
- (fsysdep_xqt_check_file): Chip Salzenberg: added configuration
- option ALLOW_FILENAME_ARGUMENTS to permit arguments that look like
- filenames, to allow undoing the patch I just made.
-
-Fri Jan 3 00:44:59 1992 Ian Lance Taylor (ian@airs.com)
-
- * system.h, uuxqt.c (uqdo_xqt_file), sys5.unx
- (fsysdep_xqt_check_file): David J. Fiander: make sure that if an
- argument looks like a filename we are permitted to access it.
-
- * sys3.unx (fsdo_lock): remove temporary file if link fails in
- fsdo_lock.
-
-Thu Jan 2 00:01:53 1992 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgstart, fgshutdown, fgprocess_data): count remote
- rejections separately from resent packets when counting errors.
-
-Tue Dec 31 14:31:38 1991 Ian Lance Taylor (ian@airs.com)
-
- * protg.c (fgstart): Franc,ois Pinard: forgot to initialize
- cGdelayed_packets.
-
- * prot.h, uucico.c, prote.c: added the 'e' protocol, creating the
- new file prote.c
-
- * prot.c (freceive_data), protf.c (fffile), prott.c (ftfile):
- changed pffile protocol entry point to pass number of bytes being
- sent; fixed bug in freceive_data which caused to ask for the wrong
- number of bytes when the buffer was empty.
-
-Mon Dec 30 23:16:48 1991 Ian Lance Taylor (ian@airs.com)
-
- * sys2.unx (fsserial_open): Chip Salzenberg: don't turn on IXON
- and IXOFF initially; after all, the initialization packets might
- contain an XOFF character.
-
-Sun Dec 29 00:00:42 1991 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h, prot.c (fploop): John Theus: check for EOF before
- reading from file to work around bug in Tektronix library.
-
- * protg.c (fprocess_data): don't send RR packets when an error
- occurs; the other side will probably ignore them, and it may
- confuse some Telebit modems.
-
- * sys1.unx (usysdep_localtime): don't take the address of a cast
- value.
-
- * log.c (zldate_and_time): wasn't allocating enough buffer space.
-
-Sat Dec 28 01:09:58 1991 Ian Lance Taylor (ian@airs.com)
-
- * uuxqt.c (uqdo_xqt_file): forgot to initialize zmail.
-
- * uucp.h, time.c, copy.c, sys1.unx, sys2.unx, sys3.unx, sys4.unx,
- sys5.unx, config.c, log.c, uuxqt.c, uux.c, tstuu.c: added a bunch
- of externs to decrease the number of implicit function
- definitions.
-
- * system.h, sys1.unx (usysdep_localtime), log.c (zldate_and_time):
- Lele Gaifax: put the full year in the log file, using the format
- YYYY-MM-DD HH:MM:SS.HH (ending in hundredths of seconds).
-
- * config.c (uprocesscmds): Terry Gardner: allow a # to be quoted
- in a configuration file. Also made uprocesscmds reentrant.
-
- * sysh.unx, sys2.unx (fsrun_chat), sys5.unx (fsysdep_execute),
- tstuu.c (uchild): Monty Solomon: added HAVE_UNION_WAIT
- configuration option to pass a variable of type union wait to the
- wait and waitpid system calls.
-
- * sysh.unx, sys1.unx (usysdep_initialize): John Theus: added
- HAVE_GETWD to use getwd instead of getcwd.
-
- * sysh.unx, sys1.unx (usysdep_full_time): added HAVE_FTIME
- configuration option.
-
- * tstuu.c (uchild): use TIMES_TICK from sysh.unx rather than
- CLK_TCK.
-
- * conf.h, uucp.h, util.c, getopt.c, tstuu.c: added HAVE_STRCHR and
- HAVE_INDEX to conf.h.
-
-Fri Dec 27 01:00:41 1991 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fuucp): set fmasterdone correctly when running as a
- slave.
-
- * port.c (cpshow, upshow, fport_read, fport_write, fport_io):
- cleaned up debugging code by isolating out upshow and by making
- cpshow handle backslash.
-
- * tstuu.c (uprepare_test): create spool directories by hand, to
- make sure test 6 can be done and to test creating needed
- directories.
-
- * conf.h, uucp.h, bnu.c, v2.c, chat.c, protg.c, prott.c, sysinf.c,
- tcp.c, getopt.c, tstuu.c, util.c: added HAVE_MEMFNS and HAVE_BFNS
- to conf.h. Changed memset calls to use bzero.
-
- * protg.c (fgcheck_errors, fgprocess_data): added protocol
- parameter ``errors'' to set maximum number of errors permitted.
- Also made fgprocess_data only reply once per batch of data.
-
-Thu Dec 26 17:54:54 1991 Ian Lance Taylor (ian@airs.com)
-
- * tcp.c (ftcp_dial, itcp_port_number): Monty Solomon: cast
- arguments to avoid prototype errors on NeXT.
-
-Mon Dec 23 00:16:19 1991 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h, sysinf.c, uucico.c (main, flogin_prompt, faccept_call),
- uuchk.c (main): David Nugent: allow debugging level to be set for
- a specific system.
-
-Sun Dec 22 15:51:10 1991 Ian Lance Taylor (ian@airs.com)
-
- * conf.h, uucp.c, sysh.unx, tcp.c, sys1.unx, sys2.unx, sys3.unx,
- sys5.unx, sys6.unx, tstuu.c: Monty Solomon: added HAVE_UNISTD_H to
- conf.h for systems which don't have <unistd.h>. Also added
- externs for all functions from <unistd.h>, which required adding
- definitions for pid_t, uid_t and off_t to sysh.unx.
-
- * config.c, prtinf.c, time.c, uuchk.c: added externs for
- strcasecmp or strncasecmp, to avoid implicit function definitions
- now that I took the prototypes out of uucp.h.
-
- * sys3.unx (fsysdep_get_status): Franc,ois Pinard: the code added
- to avoid scanf had a stupid bug.
-
- * uucp.h: Monty Solomon: removed prototypes for strcasecmp and
- strncasecmp from uucp.h, since they may be in string.h.
-
-Sat Dec 21 16:04:58 1991 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h, uucico.c (ucatch), prot.c (fpsendfile_confirm,
- fprecfile_confirm, ustats_failed), file.c (fsent_file,
- freceived_file), log.c (ustats): Terry Gardner: record failed file
- transfers in the statistics file.
-
- * uucico.c: change protocol ordering to 't', 'g', 'f'.
-
- * uucico.c (faccept_call), tstuu.c (uprepare_test): John Theus:
- don't warn if the port file doesn't exist when the slave mode
- uucico looks up the port.
-
- * sys1.unx, sys5.unx: moved fsysdep_file_exists from sys5.unx to
- sys1.unx so that uucico can call it.
-
- * uux.c: Fran,cois Pinard: remove parentheses from ZSHELLSEPS so
- that they may be used to quote arguments as documented. This
- means that may not be used to start subshell, but that is no great
- loss.
-
- * uux.c (main): use ulog to report illegal grade error message.
-
- * sys1.unx (fsysdep_run): use the real program name from abProgram
- in the error messages in fsysdep_run.
-
-Thu Dec 19 19:02:28 1991 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (fdo_call, faccept_call): Terry Gardner: put the length
- of the conversation in the ``Call complete'' log file message.
-
- * uux.c: added space and tab to ZSHELLSEPS, because otherwise the
- command was parsed to include whitespace.
-
- * protg.c, protf.c: Oleg Tabarovsky: added statistical logging
- messages to the 'g' and 'f' protocols. These go to the main log
- file right now, but I'm not sure if that's appropriate.
-
- * sys2.unx (fsserial_set): don't change terminal settings if we
- don't have to.
-
- * port.c (fport_io): add complete diagnostics for fport_io so we
- can see every byte that goes in or out.
-
- * uucico.c (fuucp): don't give user name in errors produced by
- getting the next command.
-
- * uuxqt.c (main): don't process execute files for unknown systems.
- This is not unreasonable, I hope, and it avoids errors caused by
- an uninitialized sUnknown structure.
-
- * sys4.unx (fsysdep_get_work_init): sort the previously found
- files all together so we can correctly check new files using
- bsearch.
-
- * protf.c (pfprocess, pfprocess_data, pfwait): Franc,ois Pinard:
- don't kill 'f' protocol because of an illegal byte. Also slightly
- optimized the protocol to wait for up to seven characters at a
- time rather than just one.
-
-Wed Dec 18 00:12:42 1991 Ian Lance Taylor (ian@airs.com)
-
- * sysh.unx, sys2.unx, tstuu.c: Terry Gardner: added
- USE_FOR_UNBLOCKED configuration parameter to support systems that
- don't permit O_NONBLOCK and O_NDELAY to both be set.
-
- * tstuu.c (uchild): give the uucico processes a chance to die on
- their own rather than killing them immediately.
-
- * uuxqt.c (main, uqdo_xqt_file): David Nugent: keep rescanning the
- list of execute files until nothing can be done. Also, don't
- remove the execute file if we get some sort of internal error.
-
- * sys4.unx (fsysdep_get_work, usysdep_get_work_free): David
- Nugent: after we've processed all the work files we found
- initially, rescan the work directory to pick up any that may have
- come in in the meantime. Also, reset iSwork_file to 0 in
- usysdep_get_work_free so that we can handle more than one system.
-
- * tstuu.c, uucico.c (main, fwait_for_calls, flogin_prompt): added
- -l option to uucico to prompt for the login name and password once
- and then exit.
-
-Tue Dec 17 00:24:41 1991 Ian Lance Taylor (ian@airs.com)
-
- * uucp.h, uucico.c, uuxqt.c, uux.c, uucp.c, config.c
- (uread_config), log.c (ulog): eliminated ulog_program and added
- abProgram and ulog_to_file. Made log messages output to stderr
- more Unix like.
-
- * log.c (ulog): use a fixed number of fields in a log file message
- by replacing a missing system or user with '-'.
-
- * port.h, chat.c (renamed fchat_send to fcsend), bnu.c
- (fbnu_read_dialer_info), prtinf.c (tpcomplete), sys2.unx
- (fsysdep_modem_close), uuchk.c (ukshow_dialer): T. William Wells:
- change the modem complete and abort strings into chat scripts.
-
- * sys2.unx (fsserial_open): on BSD start in RAW mode to avoid
- dropping characters when we switch over. I originally thought
- being able to use XON/XOFF was worth the risk; I no longer think
- so.
-
- * tstuu.c (uprepare_test): have shell script sleep before printing
- the login name to make sure the second system has finished
- flushing its input buffer.
-
- * protg.c (fginit_sendbuffers), prott.c (ftsendcmd): David Nugent:
- avoid sending confidential information by zeroing out memory
- buffers before using them.
-
- * sysinf.c (tirequest, titransfer), prtinf.c (tpseven_bit,
- tpreliable, tpdtr_toggle): Marc Unangst: several functions did not
- accept true and false as boolean strings, contradicting the
- documentation.
-
- * uucp.h, system.h, sysh.unx, sys1.unx (usysdep_full_time), file.c
- (fstore_sendfile, fsent_file, fstore_recfile, freceived_file),
- log.c (ustats): generate statistics in microseconds instead of
- seconds for more accurate time keeping.
-
- * sys2.unx (fsserial_open): David Nugent: flush pending input
- when a serial port is opened. This will clear out a
- NO\sCARRIER string left by a previous dropped connection.
-
-Mon Dec 16 11:26:17 1991 Ian Lance Taylor (ian@airs.com)
-
- * uucico.c (main), uuxqt.c (main), tstuu.c (main, uchild): David
- Nugent: ignore SIGHUP in uucico and uuxqt, so that they are
- unaffected by the parent shell closing down and by the remote
- terminal dropping the connection.
-
- * bnu.c (ubnu_read_sysfiles, ubnu_read_systems, fbnu_find_port,
- fbnu_read_dialer_info): Mike Bernson: ignore lines that begin with
- whitespace, fix compilation error.
-
-Sat Dec 14 20:59:10 1991 Ian Lance Taylor (ian@airs.com)
-
- * sys2.unx (fsserial_open): don't turn on ISTRIP initially.
-
- * uucp.h, sysinf.c, chat.c (icexpect), uuchk.c (ukshow_chat):
- added chat-seven-bit command to allow control over whether
- parity bits are stripped out of chat scripts.
-
- * uucp.h, port.h, chat.c (fchat, fcprogram),
- config.c (tprocess_one_cmd), prtinf.c,
- sysinf.c (tichat, tprocess_chat_cmd),
- bnu.c (fbnu_read_dialer_info), port.c (fpdo_dial),
- uucico.c (fdo_call, faccept_call) uuchk.c (ukshow_chat):
- changed processing of chat commands to go through
- tprocess_chat_cmd, avoiding repetition. All chat script
- information is now held in an schat_info structure.
- Eliminated the fchat_program function, renaming it fcprogram
- and making it static to chat.c (it is now called via fchat).
- Added CMDTABTYPE_PREFIX. Added INIT_CHAT macro to initialize
- chat script information. Added TTYPE_CMDTABTYPE and
- CARGS_CMDTABTYPE to eliminate hex constants in
- tprocess_one_cmd.
-
- * sys5.unx (zsysdep_get_xqt): Oleg Tabarovsky: don't stop
- processing files just because opendir failed on one; it could just
- be because we don't have read permission.
-
-Fri Dec 13 17:43:52 1991 Ian Lance Taylor (ian@airs.com)
-
- * config.c (uprocesscmds): don't continually allocate and free the
- array of arguments.
-
-Thu Dec 12 12:46:01 1991 Ian Lance Taylor (ian@airs.com)
-
- * prot.c (fgetcmd): Franc,ois Pinard: don't bother to give an
- error if the final HY doesn't come in; apparently the MtXinu UUCP
- doesn't send it.
-
- * chat.c (icexpect, fchat_send): Franc,ois Pinard: add some chat
- script debugging messages.
-
- * log.c (ulog): David Nugent: move ERROR: from the start of the
- line to after the date and time; this makes it easier to use awk
- on log files.
-
- * sys3.unx (fsdo_lock), sys1.unx (usysdep_initialize): do locking
- using link rather than O_CREAT | O_EXCL to avoid race conditions
- and to safely run as the superuser.
-
- * sys3.unx (fsysdep_move_file): fcopyfile now creates the
- destination file with IPRIVATE_MODE, so we don't need to chmod to
- it.
-
- * sys1.unx (usysdep_initialize, fsysdep_other_config): set the
- GID as well as the UID, in case anybody wants to run this as a
- setgid package.
-
-Wed Dec 11 10:03:22 1991 Ian Lance Taylor (ian@airs.com)
-
- * conf.h, uucp.h, util.c (strtol): Mark Powell: added my own
- version of strtol to util.c, for systems which lack it.
-
- * protg.c (fgstart, fgexchange_init): if we start resending
- packets during initialization, don't forget which packets we have
- already seen; otherwise the other side may assume we've already
- seen them while we're looking for them.
-
-Tue Dec 10 15:42:41 1991 Ian Lance Taylor (ian@airs.com)
-
- * conf.h, sysh.unx, log.c (ulog, ustats), tstuu.c (uprepare_test):
- Arne Ludwig: merged in Arne Ludwig's patches to support V2 and BNU
- style logging, with some minor additions and changes.
-
- * sys1.unx, sys3.unx, sys5.unx, uux.c, uucp.c, uucico.c, copy.c,
- uucp.h, system.h: create directories when necessary rather than
- assuming that they exist. Added fmkdirs argument to esysdep_fopen
- and fcopy_file, changing all calls. Added fpublic argument to
- fsysdep_make_dirs, changing all calls. Moved fsysdep_make_dirs
- and fsdirectory_exists from sys3.unx to sys1.unx. Added checks
- for ENOENT in several places in sys3.unx and sys5.unx.
-
- * log.c, port.c (fport_open), sys2.unx (fsserial_open): added
- ulog_device routine to record device name. This is currently only
- used for the BNU statistics file, but more uses might arise later.
-
- * file.c, log.c, uucp.h: moved statistics file routines from
- file.c to log.c in preparation for supporting BNU log file
- routines.
-
-Mon Dec 9 12:00:52 1991 Ian Lance Taylor (ian@airs.com)
-
- * bnu.c (ubnu_read_systems): Arne Ludwig: the device entry for a
- system can be followed by a comma and a list of protocols.
-
- * sysh.unx, sys3.unx (fsdo_lock): Richard Todd: add
- HAVE_V2_LOCKFILES, in which the process ID is written out in
- binary.
-
- * uuxqt.c (uqdo_xqt_file): Richard Todd: the requestor address is
- relative to the requesting system.
-
- * config.c (uprocesscmds, umulti_pushback): Richard Todd: each
- line pushed back because of "#" is local to a particular
- smulti_file structure.
-
- * prtinf.c (asPdialer_cmds): Richard Todd: exit the current dialer
- if the special command "#" is seen. A similar thing should be put
- in for ports, but it's marginally more complex.
-
- * config.c (uprocesscmds): Richard Todd: don't warn if the special
- "#" command is unrecognized.
-
-Sat Dec 7 13:05:40 1991 Ian Lance Taylor (ian@airs.com)
-
- * config.c (uprocesscmds): Franc,ois Pinard: don't limit the
- number of arguments to a command!
-
- * chat.c (fchat): handle a chat script which consists only of a
- single string.
-
-Fri Dec 6 16:11:29 1991 Ian Lance Taylor (ian@airs.com)
-
- * sys5.unx (fsysdep_execute): David J. Fiander: if execve fails
- with ENOEXEC, try using /bin/sh with a quoted argument.
-
- * uux.c (main): split arguments the way /bin/sh does. If any
- shell metacharacters appears, request uuxqt to execute the command
- using /bin/sh.
-
- * tstuu.c (uprepare_test): allow the uux to test to send a failure
- message.
-
- * uuxqt.c (uqdo_xqt_file): don't send mail on successful execution
- unless specifically requested; pay attention to the 'n' line
- which requests mail on success; ignore the 'Z' line because it
- now specifies the default action.
-
- * sys1.unx (usysdep_initialize), sys6.unx (zsysdep_add_cwd):
- Franc,ois Pinard: getcwd may legitimately fail, so only give an
- error if we really need the result.
-
- * chat.c (ccescape): Franc,ois Pinard: ccescape should never
- return a negative number, since the callers don't know how to deal
- with that.
-
-Mon Dec 2 16:26:16 1991 Ian Lance Taylor (ian@airs.com)
-
- * bnu.c (ubnu_read_systems): Dave Buck: time strings with grades
- were parsed in an endless loop!
-
- * sys3.unx (fsdo_lock, fsdo_unlock): the alloca when using LOCKDIR
- was one byte too small.
-
- * config.c (tprocess_one_cmd): pass 10 to strtol rather than 0 to
- avoid surprises if a leading zero is used.
-
- * prtinf.c (tpproto_param, tpdialer_proto_param): Niels Baggesen:
- the ``protocol-parameter'' command didn't work for ports or
- dialers.
-
-Sun Dec 1 09:46:12 1991 Ian Lance Taylor (ian@airs.com)
-
- * tstuu.c: don't use the fd_set typedef at all.
-
- * tstuu.c (uprepare_test): don't read V2 or BNU configuration
- files while testing.
-
- * bnu.c, v2.c, config.c (uread_config): David Nugent: even if the
- code was compiled with HAVE_TAYLOR_CONFIG, read the V2 and BNU
- configuration files if the code was compiled to support them.
-
- * uuchk.c (fkshow_port): Bob Izenberg: report dialer/token pairs
- correctly.
-
-Sat Nov 30 17:40:00 1991 Ian Lance Taylor (ian@airs.com)
-
- * tstuu.c: Bob Izenberg: copied over conditional definitions of
- EAGAIN and EWOULDBLOCK from sys2.unx.
-
- * bnu.c (fbnu_read_dialer_info): Niels Baggesen: accept dialers
- with no substitutions.
-
- * bnu.c (ubnu_read_systems, ubadd_perm): Niels Baggesen: don't
- free up zline in ubadd_perm; in fact, changed the calling sequence
- to not even pass zline in at all.
-
- * bnu.c (ubadd_perm): Niels Baggesen: didn't handle multiple
- MACHINE= and multiple LOGNAME= values in a single Permissions
- line, because it was clobbering the machine name while processing
- the first logname.
-
- * bnu.c: Made zread and zwrite elements of sperm structure const
- char * to avoid warning.
-
- * copy.c, sys1.unx, sys2.unx, sys3.unx, sys5.unx, tstuu.c: Niels
- Baggesen: don't multiply include <unistd.h>. Eventually there
- should be a macro controlling whether it gets included at all, for
- non-POSIX systems.
-
- * sys3.unx (fsysdep_get_status, isysdep_get_sequence): Marty
- Shannon: accept a truncated status file. I also eliminated scanf
- calls in sys3.unx, since that was the only place it was called;
- this was to make the executables smaller for systems which cared.
-
- * bnu.c (ubnu_read_sysfiles): Marty Shannon: accept comment
- characters in Sysfiles.
-
- * sysh.unx, sys3.unx: Marty Shannon: added HAVE_RENAME, put a fake
- rename system call in sys3.unx.
-
- * prtinf.c (ffind_port): Marty Shannon: failed to handle multiple
- ports in the port file since I forgot to reset my pointer
- variable.
-
- * bnu.c (ubnu_read_systems): Marty Shannon: don't initialize the
- auto array abpubdir, since old cc didn't permit initialization of
- auto aggregates.
-
-Mon Nov 25 20:56:39 1991 Ian Lance Taylor (ian@airs.com)
-
- * tstuu.c: Bob Denny: add definitions for FD_SET, FD_ZERO and
- FD_ISSET.
-
- * config.c: Bob Denny: add explicit externs for strcmp and
- strcasecmp.
-
- * sys2.unx: the fread_blocking and fwrite_blocking fields were
- not getting initialized correctly in the TCP support routines.
-
- * sysh.unx, sys2.unx, sys5.unx, tstuu.c: Marty Shannon: added
- configuration option HAVE_SYSWAIT_H.
-
- * bnu.c (fbnu_find_port, fbnu_read_dialer_info), v2.c
- (fv2_find_port): Marty Shannon: the ireliable field of ports
- and dialers was not getting initialized.
-
-Sun Nov 24 15:06:37 1991 Ian Lance Taylor (ian@airs.com)
-
- * tcp.c (itcp_port_number): Michael Haberler: wasn't calling
- htons if passed a numeric string.
-
-Sat Nov 23 13:43:52 1991 Ian Lance Taylor (ian@airs.com)
-
- * Released version 1.01 to alt.sources and uunet
-
diff --git a/gnu/libexec/uucp/Makefile b/gnu/libexec/uucp/Makefile
deleted file mode 100644
index b2b68f6..0000000
--- a/gnu/libexec/uucp/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# This is the Makefile for Taylor UUCP
-# $Id$
-
-# subdir 'sample' called by /usr/src/etc/Makefile
-SUBDIR= libunix libuucp libuuconf \
- doc \
- cu uuchk uucico uuconv uucp uulog uuname uupick uusched \
- uustat uuto uux uuxqt
-
-.include <bsd.subdir.mk>
diff --git a/gnu/libexec/uucp/Makefile.inc b/gnu/libexec/uucp/Makefile.inc
deleted file mode 100644
index 02c2185..0000000
--- a/gnu/libexec/uucp/Makefile.inc
+++ /dev/null
@@ -1,32 +0,0 @@
-.if exists(${.OBJDIR}/../libunix)
-LIBUNIX= $(.OBJDIR)/../libunix/libunix.a
-.else
-LIBUNIX= $(.CURDIR)/../libunix/libunix.a
-.endif
-
-.if exists(${.OBJDIR}/../libuuconf)
-LIBUUCONF= $(.OBJDIR)/../libuuconf/libuuconf.a
-.else
-LIBUUCONF= $(.CURDIR)/../libuuconf/libuuconf.a
-.endif
-
-.if exists(${.OBJDIR}/../libuucp)
-LIBUUCP= $(.OBJDIR)/../libuucp/libuucp.a
-.else
-LIBUUCP= $(.CURDIR)/../libuucp/libuucp.a
-.endif
-
-VERSION= 1.06.1
-owner= uucp
-group= uucp
-bindir= /usr/bin
-sbindir= /usr/sbin
-libxdir= /usr/libexec/uucp
-
-# The directory to look in for new style configuration files (when
-# using HAVE_TAYLOR_CONFIG).
-newconfigdir= /etc/uucp
-
-# The directory to look in for BNU (when using HAVE_BNU_CONFIG) or
-# V2 (when using HAVE_V2_CONFIG) style configuration files.
-oldconfigdir= /etc/uucp
diff --git a/gnu/libexec/uucp/NEWS b/gnu/libexec/uucp/NEWS
deleted file mode 100644
index 738068e..0000000
--- a/gnu/libexec/uucp/NEWS
+++ /dev/null
@@ -1,154 +0,0 @@
-Changes in version 1.06:
-
- As usual, many bugs were fixed.
-
- Support was added for the 'y' protocol, contributed by Jorge Cwik,
- the designer of the protocol.
-
- The name of command files was changed when using SPOOLDIR_TAYLOR;
- they now use a much longer sequence number. This affects the
- jobid strings reported by uustat. The change makes uux and uucp
- more efficient.
-
- Added ``called-timegrade'' command to sys file.
-
- Added --nostop and -E/--escape options to cu.
-
- Added -s option to uuchk.
-
- Added ``strip-login'' and ``strip-proto'' commands to config file.
-
- uux will now create a poll file if invoked as ``uux SYSTEM!''.
-
- If an execution fails, the data file is saved, if there is enough
- free disk space.
-
- uux now uses POSIX file locking, if available, when locking the
- sequence file.
-
- The man pages were incorporated into the Texinfo manual.
-
- The UUCP Internals FAQ was incorporated into the Texinfo manual.
-
- The spool directory layout is now documented in the Texinfo
- manual.
-
-Changes in version 1.05:
-
- As usual, many bugs were fixed.
-
- Support was added for the UUPC/extended 'v' protocol.
-
- Initial hardware flow control support was added, contributed by
- Peter Wemm.
-
- A new port type, ``pipe'', was added; this sends data to a program
- such as rlogin, and was contributed by Marc Boucher.
-
- The programs all now accept long option names with a leading --.
- They all support --help and --version.
-
- uuxqt now saves execution files it can not parse in
- $(SPOOLDIR)/.Corrupt.
-
- If a received file can not be moved to the final location, and
- there is enough disk space, it is kept in the spool directory.
-
- A run-uuxqt command was added to config, to permit specifying when
- uuxqt should be run.
-
- The 'i' protocol has a new ack-frequency protocol parameter. The
- remote-window protocol parameter was removed, as it did not work
- correctly.
-
- Chat scripts now permit /W in an expect string to set the timeout.
-
- TCP ports now support the ``dialer-sequence'' command.
-
- Direct ports now support the ``carrier'' command.
-
- Some support was added to read UUCP passwords from /etc/passwd,
- and to use encrypted passwords.
-
- uucico now accepts a -C argument to only call a system named by -S
- or -s if there is work for it.
-
- uucico accepts a -i TLI argument to use TLI I/O calls on standard
- input.
-
- uucico accepts a -u argument to set the user name.
-
- uucico accepts a -z argument to try the next alternate if a call
- fails.
-
- uustat accepts a -R argument to rejuvenate each listed job.
-
- Mailer configuration was moved from configure checking to
- policy.h.
-
- Support was added for QNX, contributed by Joe Wells.
-
-Changes in version 1.04:
-
-IMPORTANT: the default when talking to another version of 1.04 is to
-use the new bidirectional 'i' protocol. If you are using a
-half-duplex modem, such as a Telebit T2500, you will want to either
-mark the port as half-duplex with the ``half-duplex'' command, or
-force use of the 'g' protocol by using the ``protocol'' command in the
-sys or port file or by adding ``,g'' after the port name in the
-Systems or L.sys or Devices file.
-
- As usual, many bugs were fixed.
-
- Bidirectional transfers are supported with the new 'i' protocol;
- it requires an eight-bit clear datapath.
-
- New programs: uusched, cu, uuto and uupick.
-
- The 'G' protocol and a new Zmodem protocol were added.
-
- A number of uustat options were added to support uuclean, and a
- sample uuclean shell script was added to the contrib directory.
- The uustat output formats were changed slightly.
-
- A protocol extension eliminates transfer of the command file for
- simple commands, such as rmail or rnews, when talking to another
- version of 1.04.
-
- Some TLI support was added.
-
- UUCP forwarding was added, along with the ``forward-to'',
- ``forward-from'' and ``forward'' commands.
-
- If a file transfer fails in the middle, the retry will now start
- from where it left off. The implementation is compatible with
- SVR4.
-
- The work queue is checked every 10 minutes during a conversation;
- if there is new work and a bidirectional protocol is not in use,
- the receiving uucico requests the sender to transfer control.
-
- The amount of free disk space is checked periodically as a file is
- received, and if it drops too low the call is aborted.
-
- The UUCP configuration file reading routines were moved into a
- standalone library, uuconf. All known bugs in V2 and HDB
- configuration file reading were fixed.
-
- The ``half-duplex'' command was added for the port and dialer
- files.
-
- The ``max-retries'', ``success-wait'', ``send-request'' and
- ``receive-request'' commands were added for the sys file. The
- ``call-request'' and ``called-request'' commands were eliminated
- (they did not work correctly anyhow).
-
- \d in chat scripts now calls sleep (2) rather than sleep (1), so
- it will sleep longer (on some systems sleep(1) may delay much less
- than one second).
-
- SPOOLDIR_SVR4 was added for SVR4 style spool directories.
-
- Defaults are now permitted in the port and dialer files.
-
- The ALIAS field is supported in the HDB Permissions file.
diff --git a/gnu/libexec/uucp/README b/gnu/libexec/uucp/README
deleted file mode 100644
index 3297da3..0000000
--- a/gnu/libexec/uucp/README
+++ /dev/null
@@ -1,173 +0,0 @@
-This is the README file for version 1.06 of the Taylor UUCP package.
-
-It was written by Ian Lance Taylor. I can be reached at ian@airs.com,
-or, equivalently, uunet!cygint!airs!ian, or c/o Cygnus Support,
-48 Grove Street, Somerville, MA 02144, USA.
-
-There is a mailing list for discussion of the package. The list is
-hosted by Eric Schnoebelen at cirr.com. To join (or get off) the
-list, send mail to taylor-uucp-request@cirr.com. Mail to this address
-is answered by the majordomo program. To join the list, send the
-message ``subscribe ADDRESS'' where ADDRESS is your e-mail address.
-To send a message to the list, send it to taylor-uucp@cirr.com. The
-old list address, taylor-uucp@gnu.ai.mit.edu, will also work. There
-is an archive of all messages sent to the mailing list at ftp.cirr.com.
-
-This package is covered by the Gnu Public License. See the file
-COPYING for details. If you would like to do something with this
-package that you feel is reasonable but you feel is prohibited by the
-license, contact me to see if we can work it out.
-
-The most recent version may be obtained from any Gnu archive site.
-The canonical site is prep.ai.mit.edu. There are many mirror sites,
-including ftp.uu.net and wuarchive.wustl.edu.
-
-WHAT IT IS
-
-This is the complete source code for a Unix UUCP package. It provides
-everything you need to make a UUCP connection. It includes versions
-of uucico, uusched, uuxqt, uux, uucp, uustat, uulog, uuname, uuto,
-uupick, and cu, as well as uuchk (a program to check configuration
-files), uuconv (a program to convert from one type of configuration
-file to another) and tstuu (a test harness for the package).
-
-This is the standard UUCP package of the Free Software Foundation.
-
-The package currently supports the 'f', 'g' (in all window and packet
-sizes), 'G', 't' and 'e' protocols, as well a Zmodem protocol, the FX
-UUCICO 'y' protocol, and two new bidirectional protocols. If you have
-a Berkeley sockets library, it can make TCP connections. If you have
-TLI libraries, it can make TLI connections. It supports a new
-configuration file mechanism which I like (but other people dislike).
-
-The package has a few advantages over regular UUCP:
-
- You get the source code.
-
- It uses significantly less CPU time than many UUCP packages.
-
- You can specify a chat script to run when a system calls in,
- allowing adjustment of modem parameters on a per system basis.
-
- You can specify failure strings for chat scripts, allowing the
- chat script to fail immediately if the modem returns ``BUSY''.
-
- If you are talking to another instance of the package, you can use
- the new bidirectional protocol for rapid data transfer in both
- directions at once. You can also restrict file transfers by size
- based on the time of day and who placed the call.
-
-On the other hand:
-
- It only runs on Unix. The code is carefully divided into system
- dependent and system independent portions, so it should be
- possible to port it to other systems. It would not be trivial.
-
- You don't get uuclean, uusend, uuq, uusnap, uumonitor, uutry,
- uupoll, etc. If you have current copies of these programs, you
- may be able to use them. Shell scripts versions of uuclean and
- uutry are provided, with most, if not all, of the functionality of
- the usual programs. I believe the supplied uustat program allows
- you to do everything that uuq, uusnap and uumonitor do. uupoll
- could be written as a shell script.
-
- The package does not read modemcap or acucap files, although you
- can use V2 configuration files with a BNU Dialers file or a dialer
- file written in my new configuration file format.
-
- The package cannot use SCO dialer programs directly, although it
- can with a simple shell script interface.
-
-If you start using this package, I suggest that you join the mailing
-list (see above) to keep up to date on patches and new versions. I am
-also open to suggestions for improvements and modifications.
-
-DOCUMENTATION
-
-The documentation is in the file uucp.texi, which is a Texinfo file.
-Texinfo is a format used by the Free Software Foundation. You can
-print the documentation using TeX in combination with the file
-texinfo.tex. DVI, PostScript and info versions of the documentation
-are available in a separate package, uucp-doc-1.06.tar.gz.
-
-See the TODO file for things which should be done. Please feel free
-to do them, although you may want to check with me first. Send me
-suggestions for new things to do.
-
-The compilation instructions are in uucp.texi. Here is a summary.
-
- Edit Makefile.in to set installation directories.
-
- Type ``sh configure''. You can pass a number of arguments in the
- environment (using bash or sh, enter something like ``CC=gcc
- configure''; using csh, enter something like ``setenv CC gcc; sh
- configure''):
- CC: C compiler to use; default is gcc if it exists, else cc
- CFLAGS: Flags to pass to $CC when compiling; default -g
- LDFLAGS: Flags to pass to $CC when only linking; default none
- LIBS: Library arguments to pass to $CC; default none
- INSTALL: Install program; default install -c or cp
- The configure script will compile a number of test programs to see
- what is available on your system, so if your system is at all
- unusual you will need to pass in $CC and $LIBS correctly.
-
- The configure script will create config.h from config.h.in and
- Makefile from Makefile.in. It will also create config.status,
- which is a shell script which actually creates the files. Please
- report any configuration problems, so that they can be fixed in
- later versions.
-
- Igor V. Semenyuk provided this (lightly edited) note about ISC
- Unix 3.0. The configure script will default to passing -posix to
- gcc. However, using -posix changes the environment to POSIX, and
- on ISC 3.0, at least, the default for POSIX_NO_TRUNC is 1. This
- means nothing for uucp, but can lead to a problem when uuxqt
- executes rmail. IDA sendmail has dbm configuration files named
- mailertable.{dir,pag}. Notice these names are 15 characters long.
- When uuxqt compiled with -posix executes rmail, which in turn
- executes sendmail, the later is run under POSIX environment too!
- This leads to sendmail bombing out with 'error opening 'M'
- database: name too long' (mailertable.dir). It's rather obscure
- behaviour, and it took me a day to find out the cause. I don't
- use -posix, instead I run gcc with -D_POSIX_SOURCE, and add
- -lcposix to LIBS.
-
- On some versions of BSDI there is a bug in the shell which causes
- the default value for CFLAGS to be set incorrectly. If ``echo
- ${CFLAGS--g}'' echoes ``g'' rather than ``-g'', then you must set
- CFLAGS in the environment before running configure. There is a
- patch available from BSDI for this bug. (Reported by David
- Vrona).
-
- On AIX 3.2.5, and possibly other versions, cc -E does not work,
- reporting ``Option NOROCONST is not valid.'' Test this before
- running configure by doing something like
- touch /tmp/foo.c
- cc -E /tmp/foo.c
- This may give a warning about the file being empty, but it should
- not give the ``Option NOROCONST'' warning. The workaround is to
- remove the ",noroconst" entry from the "options" clause in the
- "cc" stanza in /etc/xlc.cfg. (Reported by Chris Lewis).
-
- Examine config.h and Makefile to make sure they're right.
-
- Edit policy.h for your local system.
-
- Type ``make''.
-
- Use ``uuchk'' to check configuration files. You can use
- ``uuconv'' to convert between configuration file formats.
-
- Type ``make install'' to install. Note that by default the
- programs are compiled with debugging information, and they are not
- stripped when they are installed. Read the man page for strip for
- more information.
-
- On older System V based systems which do not have the setreuid
- system call, problems may arise if ordinary users can start an
- execution of uuxqt, perhaps indirectly via uucp or uux. UUCP jobs
- may wind up executing with a real user ID of the user who invoked
- uuxqt, which can cause problems if the UUCP job checks the real
- user ID for security purposes. On such systems, it is safest to
- put ``run-uuxqt never'' in the `config' file, so that uucico never
- starts uuxqt, and invoke uuxqt directly from cron.
diff --git a/gnu/libexec/uucp/TODO b/gnu/libexec/uucp/TODO
deleted file mode 100644
index f1bed5f..0000000
--- a/gnu/libexec/uucp/TODO
+++ /dev/null
@@ -1,777 +0,0 @@
-This is a list of things to do for the Taylor UUCP package. Please
-feel free to work on any of them. You may want to check with me first
-to make sure that nobody else is working on them as well.
-
-Some of these are my thoughts, but most are suggestions from other
-people; I have tried to give credit. They are in the order I received
-them; the missing numbers have already been implemented.
-
-Just because something is on the list doesn't mean that I necessarily
-think it is a good idea. It does mean that I think it's worth
-thinking about.
-
-2.
-
-John Cowan <cowan@snark.thyrsus.com> says:
-
->I think you should accept a broader range of time specifications.
->Consider using getdate() (from your handy Usenet news source code)
->with its high-powered yacc parser.
-
-Of course, getdate() accepts a single date, but we want a range. A
-better syntax would be certainly be nice.
-
-9.
-
-Gordon Burditt <gordon@sneaky.lonestar.org> warns about modifications
-to the TZ environment variable, to fool uucico into dialing out at an
-inappropriate time.
-
-10.
-
-Gordon Burditt <gordon@sneaky.lonestar.org> says:
-
->(4) Less important, because few people will have this problem, is a
->port-specific dialcodes file. Why? Well, one system I had was connected
->to 2 inside lines "dial 9 for outside line", and one outside line (which
->doesn't want the 9). A number of the systems called were "inside", so
->you didn't add the 9 on those lines dialing from inside, but you did add
->"390" to the 4-digit number if you dialed it via "outside". Also not
->unheard of are systems with 2 outside lines that are local to different
->area codes, or one local outside line and one WATS line (which MUST
->have an area code).
->Example:
-> inside-line Dialcodes outside-line Dialcodes
-> pbx "" pbx "390"
-> local "9" local ""
-> nyc "9-1212" nyc "1212"
-
-12.
-
-Ralf E. Stranzenbach <ralf@reswi.ruhr.de> says:
-
->It would be nice to also have the option of running a shell script each time
->uucico connects/disconnects a systen. I do not mean shell scripts for dial/in.
->I would like to do some accounting and batching when the connection
->establishes.
-
-13.
-
-les@chinet.chi.il.us (Leslie Mikesell) writes:
-
->>local-send /usr/spool/uucppublic !/usr/spool/uucpublic/private
->>
->>The directories are searched from left to right, and the last one to
->>match determines whether the file may be sent or not. This is
->>slightly more general than NOWRITE, since it permits a public
->>directory within a private directory within a public directory,
->>although probably nobody will ever want that.
->
->Interesting... The obvious enhancement is to generalize to shell-like
->wild cards for the READ/WRITE/COMMANDS entries.
-
-14.
-
-Should there be a way for chat scripts to specify the parity to
-generate? I don't think there's much point to specifying what parity
-to accept.
-
-17.
-
-The -b and -s switches to uux are not implemented by uuxqt.
-
-18.
-
-If we are supposed to call a system back, we should do it immediately
-rather than merely queuing up an empty command file.
-
-22.
-
-Add an ftp port type which uses anonymous ftp rather than any of the
-UUCP protocols to do file transfers. This would allow ftp work to be
-done late at night, and allow neighbors of cooperative Internet sites
-to use UUCP forwarding for anonymous FTP.
-
-32.
-
-It would be nice if uucico could sleep until a line was available.
-This is complicated by the possibility of wanting to wait for any of
-several different lines, and one would really want some sort of
-semaphore function to do it right. If the available lines could be
-sorted, then each could be assigned to a byte in a line lock file.
-Looking for a line could be done by sleeping on a read lock on all
-possible lines. Once it came through, write locks would be attempted.
-If they all failed, somebody else snuck in, so you would sleep on a
-read lock again. This isn't great because a process could be starved,
-but it might be better than nothing.
-
-This could be tied in to uucp and uux, such that they wouldn't
-actually fire up uucico unless a line was known to be available; an
-additional switch would be used to fire up uucico anyhow (or one could
-switch the default behaviour and the switch).
-
-So how do you sort the lines? You could just use the index in the
-port (or Devices) file, but what if multiple ports used the same
-physical device? Hmmm.
-
-43.
-
-David Nugent: it would be nice to be able to set debugging, log, and
-statistics files on a site by site basis.
-Brian Murrell: heck, set those files on a port by port basis as well.
-
-74.
-
-Yanek Martinson: allow each system to independently choose whether to
-permit shell execution.
-
-81.
-
-Marty Shannon: log reason for dial failure (chat-fail string) in
-.Status file.
-
-83.
-
-Switch between 'M' and 'S' correctly in the BNU log file output.
-
-86.
-
-Les Mikesell: allow a separate program to be specified to handle the
-communications with a particular system.
-
-105.
-
-T. William Wells: close and open the Debug file after each file
-transfer. Alternatively, cycle through a series of Debug file names
-every 1000 lines or so.
-
-106.
-
-Marty Shannon: add a time command for ports, to specify when they may
-be used.
-
-115.
-
-T. William Wells: new options for uustat:
- -i display job ids only
-Also, there should perhaps be a configuration option to request uustat
-to only display jobs submitted by the user running uustat, except for
-root and uucp.
-
-117.
-
-Marc Unangst: provide some way to change the debugging level of a
-running uucico. T. William Wells suggests having it read a file to
-change arbitrary configuration information, although obviously one has
-to be careful of what gets changed while a connection is active.
-
-120.
-
-Jarmo Raiha: new chat-fail commands: one to not update the status file
-and require a retry wait, and one to permit the string to occur a few
-times before reporting an error.
-
-124.
-
-Peter da Silva: perhaps there should be a ``chat-end-program'' command
-to let a program be run after the initial handshake has been completed
-and the protocol has been selected and turned on. This would let
-people run stty to change their terminal parameters.
-
-128.
-
-Richard Stallman: have an interactive program to set up a chat script.
-It would let you type directly to the port, recording what you type as
-send strings and recording what comes back from the other side as
-expect strings.
-
-129.
-
-Use POSIX fcntl locks when possible instead of creating a lock file.
-
-138.
-
-T. William Wells: BNU apparently uses a file named A.whatever to hold
-the line number reached in current C. file processing. This is a
-hack, and won't work right with size control anyhow, but
-fsysdep_did_work could, for example, clobber the first byte in the
-line to a # or something to mark that it had been finished. Still a
-hack, but a better one.
-
-139.
-
-Patrick Smith: incorporate patches to generate full debugging traces
-with less debugging file overhead. The debugging file repeats too
-much information at great length right now--not good.
-
-141.
-
-Franc,ois Pinard: batch up pauses and delays in chat scripts and do
-them all at once in a single system call. This is particularly useful
-for pauses on systems which don't support subsecond sleeps. For
-everything else it's a fairly minor optimization.
-
-142.
-
-Franc,ois Pinard: give uustat an option to requeue jobs to another
-system. This only makes a lot of sense for rmail executions, but it's
-fairly easy to do for any type of command. I think uucico does all
-the file checking needed to ensure that this doesn't break security,
-but that should be double-checked.
-
-144.
-
-T. William Wells: add a -g option to uucico to permit specifying the
-maximum grade to be transferred at that time. This could restrict the
-timegrade command further, but should not be permitted to override it.
-
-145.
-
-T. William Wells: if uucico or uuxqt get started with bad arguments,
-put an indication in the log file since stderr may be /dev/null.
-
-146.
-
-Richard Todd: it would be nice to sometimes be able to request the
-other side to turn on debugging.
-
-147.
-
-Bart Schaefer: some more possible options for uucico:
- -R reverse roles (hangup immediately). Not too exciting.
- some method to restrict calling to particular systems.
-
-148.
-
-Jarmo Raiha: some method to control the work queue at the remote end.
-This could get awfully general, though.
-
-149.
-
-The interaction of the time command and defaults can be confusing,
-since any time command in the actual system entry, even a fairly
-specific one, will wipe out the default entry. Not sure what can be
-done about this.
-
-150.
-
-Jarmo Raiha: should there be some way to specify modem initialization
-strings when uucico is hanging on a port with -l or -e? This would
-presumably require a new type of chat script associated with a dialer.
-
-151.
-
-Petri Helenius: log complete CONNECT string reported by modem, so that
-the baud rate is recorded in the log file.
-
-152.
-
-Marc Evans: let the protocol selection be based on the CONNECT string,
-so that different protocols could be selected based on what type of
-connection was made.
-
-153.
-
-Chris Lewis: provide a signal to get a core dump even on systems which
-won't do core dumps if the uid is not the euid. One could catch a
-signal, call setuid (getuid ()), and then raise the signal again.
-Unfortunately the core dump has to wind up in a directory which is
-world writable, so that the process is able to create the core file,
-but is not world readable, since that would permit anybody to read the
-core dump file and extract private information from it.
-
-154.
-
-Les Mikesell: write a new version of dial.o, with provisions for
-running a chat script.
-
-155.
-
-Scott Blachowicz: perhaps there should be some way to telling uucico
-to not log certain errors. This could get fairly complex, though.
-
-156.
-
-Franc,ois Pinard: have uustat -m report the time of the last
-successful conversation when reporting a failure.
-
-158.
-
-Thomas Fischer: should there be a way to completely disable an entry
-in the sys, port or dial file? Such as a ``disable'' command?
-
-159.
-
-Petri Helenius: when uuxqt -s is invoked, lock uuxqt for the system so
-that only one uuxqt is invoked per system. If the -c option is used,
-don't lock on a per system basis, and ignore any per system locks
-(regardless of -s). If neither option is used, respect existing
-system and command locks, and do any other type of file.
-
-161.
-
-Scott Blachowicz: provide some sort of include mechanism for the
-configuration files.
-
-164.
-
-Ed Carp: preserve files if uuxqt execution fails.
-
-165.
-
-Marc Sheldon: use exit codes from <sysexits.h> in uux and uucp.
-
-166.
-
-Chip Salzenberg: allow chat failure strings to specify a retry time.
-
-168.
-
-Jose A. Manas: allow a maximum connect time, after which we try to
-hang up the connection. This requires a protocol extension, since
-there's no way to force the other side to hang up. The best we can do
-without an extension is refuse to send any new jobs ourselves. Of
-course, we could just drop the connection.
-
-169.
-
-Franc,ois Pinard: when given uustat -k00FC, check each possible job ID
-and use it if there is an unambiguous one.
-
-170.
-
-T. William Wells: if ! HAVE_SETREUID && ! HAVE_SAVED_SETUID, fork a
-subprocesses to revoke setuid and read the file over a pipe.
-
-171.
-
-Provide some option to have the internal uuconf functions not start
-with an underscore.
-
-172.
-
-T. William Wells: have some way to configure the parity for cu.
-
-173.
-
-Gert Doering: uuchk should display unknown system information.
-
-175.
-
-T. William Wells:
-Cu will not let itself be interrupted before the connection is
-established. If the chat script doesn't write something, cu does
-something odd, I've forgotten exactly what. Cu takes an
-inordinate amount of time after the line drops to exit. Somebody,
-cu, I think, but maybe uucico, drops dtr twice sometimes. Again,
-somebody will attempt to write after a hangup signal has been
-received. Once a hangup has been received, I/O should not be
-attempted. Among other things this will save the bacon of those
-who have brain damaged serial drivers (FAS, sigh, is among them)
-that don't handle output properly on a dropped line.
-
-Me:
-Note that sometimes you do want to write to a line after receiving a
-hangup signal. For example, you might want to use ATZ to reset a
-modem.
-
-176.
-
-Hans-Dieter Doll: provide some way (another escape sequence) to pass
-the protocol to a chat-program. Or, allow the protocol as an argument
-to the chat script command, which is more general, but maybe a bit too
-fancy.
-
-177.
-
-Nickolay Saukh: use a default port for cu, you can just do ``cu
-number''.
-
-180.
-
-Nickolay Saukh: if we have received a partial file, request the remote
-system to start sending from that point. We currently accept SVR4
-style remote file positioning requests, but we do not generate them.
-
-181.
-
-Mark Powell: provide some way to restrict file transfer by size as
-well as grade? One way would be to let uux select the grade based on
-the file size.
-
-182.
-
-Mark Powell: permit using multiple timetables in a single time
-statement.
-
-183.
-
-Optionally check for interrupts in fcopy_file, since it can take a
-long time to copy a file named in a uucp request.
-
-185.
-
-A syntax error in a command received from the remote system should not
-hold up the queue. Unfortunately, I don't know what can be done
-except deny the command and report it. Reporting a garbled command
-error should report the command correctly, rather than just the first
-character.
-
-186.
-
-Franc,ois Pinard: have an option to control nostop vs. stop on the cu
-command line.
-
-187.
-
-Fix the notion of %nostop to be SVID compatible.
-
-188.
-
-Frank Conrad: provide a means to set the strip mode for a port, to
-make it easy to use it from cu.
-
-189.
-
-Marc Unangst: there should be a way to specify that a system should
-only be called if there are jobs of a certain grade, but if the system
-is called then jobs of any grade should be transferred. This
-basically means splitting the ``timegrade'' command into two commands:
-``place-call-timegrade'' and ``transfer-timegrade''. Or maybe another
-optional argument to ``timegrade'':
- timegrade grade time-string [retry] [transfer-any]
-not to mention
- time time-string [retry] [transfer-any]
-Or maybe a separate command for a system or port like
- transfer-any BOOL
-
-190.
-
-Chip Salzenberg: it would be really nice if uucico could automatically
-figure out when it could use an E command, so that uux didn't have to
-generate it and so that uucico could use with other versions of uux.
-Unfortunately, it would require uucico to read the execution file to
-see if it were suitable; this would be complex, but it would probably
-be worth it since normally the execution file would wind up not being
-sent. Of course, the current method works too; it's just harder to
-combine with other versions of UUCP.
-
-191.
-
-Brian J. Murrell: should there be a way to cu a specific alternate?
-
-192.
-
-Andrew A. Chernov: Perhaps cu -pport system should be able to try
-different alternates for the system, because there might be different
-phone numbers to try.
-
-193.
-
-Brian J. Murrell: it would be nice to be able to ^C a cu chat script
-if you know it's going to fail. Right now you have to use ^\.
-
-194.
-
-Steven S. Dick: have some way to force uucico off the phone at a
-certain time. If that is done, it might be cool to have some way to
-predict how long a file transfer will take, and not do it if it will
-take too long. But, if doing file restart, you can just quit and then
-pick it up later.
-
-195.
-
-Franc,ois Pinard: if the disk fills up, or some other error occurs,
-while receiving a file, perhaps it would make sense to turn the
-connection around immediately and see if the other side had anything
-to do, and then try again later. This would require a protocol
-extension. I don't know if it's worth it. The code should be checked
-to see how well it handles a disk full situation.
-
-197.
-
-Try alternate IP addresses if there are any.
-
-198.
-
-Lele Gaifax: mention the device in Stats, and provide some way to
-associate the entry in Log with the entry in Stats.
-
-199.
-
-Michael Richardson: provide some way to turn on parity for the login
-chat, since some systems apparently require it. Provide some way for
-cu to control parity after connecting.
-
-200.
-
-Chip Salzenberg: add max-remote-debug to config.
-
-201.
-
-Gert Doering: change the timeout message in chat scripts to reflect
-which chat script timed out (dialer or login).
-
-202.
-
-Bill Foote: have uuchk check whether a system is defined more than
-once.
-
-203.
-
-Eric Ziegast: allow specification of the minimum grade to receive, as
-well as the maximum grade. Probably sending a second character after
-the -pM argument would work fine.
-
-204.
-
-Tom Rushworth: perhaps there should be some program which can be used
-to retrieve the current spool directory. Perhaps on option on uustat.
-
-207.
-
-James B. O'Connor: use additional messages in the status file when
-placing a call, such as Dialing, Chatting, and the like. Slightly
-less efficient.
-
-208.
-
-When checking whether a file may be received into a directory, perhaps
-uucico should check using the real user ID rather than insisting that
-the directory be world writable. This should be a policy.h parameter.
-This would enable sites which use different uids for each incoming
-UUCP login to have better control over security.
-
-209.
-
-Jon Vos: add an alias command for ports.
-
-210.
-
-Joe Wells: I'd like to have a way so that if the dial chat fails due
-to "NO CARRIER", in addition to this log message:
-
- ERROR: Chat script failed: Got "NO\sCARRIER"
-
-I would get another log message right next to it that would look like
-this:
-
- ERROR: Chat script failed: 5 "RRING" strings seen
-
-Ian: I doubt this is worth implementing in uucico, but it might make
-sense for an external, or otherwise more independent and controllable,
-chat program.
-
-211.
-
-Joe Wells: In some cases it would be nice to be able to change the set
-of chat-fail strings in the middle of the chat script. Personally, I
-think this is too complex for the simple chat scripts currently
-implemented.
-
-212.
-
-Joe Wells: There should be an option to all programs directing them to
-send all debugging output to the log file. This would just involve
-calling ulog_to_file at some point just after reporting any usage
-messages.
-
-213.
-
-Joe Wells: There should be a way to specify the execution directory
-used by uuxqt. This would avoid certain sorts of permissions
-problems. Some mechanism would still be needed for using multiple
-directories.
-
-214.
-
-Joe Wells: uuto should be documented.
-
-215.
-
-Joe Wells: Perhaps it should be possible to use multiple spool
-directories. It would be a lot of work, though.
-
-216.
-
-Joe Wells: It should be possible to specify only one of complete or
-abort.
-
-217.
-
-Dan Everhart: It would be nice if the chat-fail string could affect
-the error message reported by uustat, so that uustat could say
-something ``Line was busy''.
-
-218.
-
-Andrew A. Chernov: Add a chat-char-delay xx configuration parameter,
-which has the effect of adding \p after each character, with delay xx.
-This is to accommodate modems which can't accept command characters at
-a given baud rate.
-
-219.
-
-Gert Doering: Provide some mechanism for specifying the maximum length
-of a call. Convenient for anonymous UUCP sites.
-
-220.
-
-Joe Wells: There should be some way for "cu" to obey user commands
-during the dial chat. Right now, the only thing the user can do is
-send signals (e.g. type Control-C). This leads to user complaints
-that "cu" is not obeying its documentation.
-
-221.
-
-Joe Wells: Right now, if there is any failure in the dial or login
-chat scripts, the remote system alternate is skipped even though the
-cause of the failure may have been the local serial port or modem.
-"uucico" will not try another modem with the same remote system
-alternate. If the remote system only has one alternate, then it is
-skipped entirely.
-
-Thus, there should be a way to specify that when certain expect
-strings are not seen or certain chat-fail strings are seen that the
-port is skipped instead of the remote system alternate.
-
-222.
-
-Richard H. Gumpertz: Support pipelines in uuxqt. Right now they are
-only supported if uux puts in an 'e' line (which it does) and shell
-executions are permitted (which they normally are not). It would be
-possible to permit restricted pipelines by handling the pipe character
-specially and making sure all commands in the pipeline were permitted.
-
-223.
-
-Bill Sommerfeld: When dialing out, set the status to DIALING rather
-than CONNECTION CLOSED. Setting the status takes a bit of time; it's
-hard to tell where the right break-even point is.
-
-224.
-
-Joe Wells: Keep track of the last successful incoming call separately
-from the last successful outgoing call. Currently the two times are
-both put together in the status file.
-
-225.
-
-Joe Wells: It would be nice if uustat would provide a way to avoid
-bouncing mail that it sent itself, to avoid sending notification
-e-mail for notification e-mail. I can't think of a mechanism, though
-(using a special grade for uustat does not work because most mail
-programs do not provide a mechanism for passing a grade through to
-uux).
-
-226.
-
-Joe Wells: It would be nice if uustat could know whether it had sent
-mail for a particular job, to avoid generating multiple messages for
-the job.
-
-227.
-
-Joe Wells: It would be nice if dialcode suffixes were supported, as
-well as prefixes.
-
-228.
-
-Joe Wells: It would be nice to support another spool directory scheme
-which split stuff up more to avoid very large directories. This would
-be most useful for the files which are named in C. and X. files,
-rather than for the C. and X. files themselves (since C. and X. files
-are rarely looked up by name). Basically, some sort of partition of
-the D. directory is called for.
-
-229.
-
-Joe Wells: ``It would be nice if the exit sequence of "cu", where it
-runs the complete chat script and then disconnects could be aborted
-without disconnecting. (Yes, I know, this is a strange desire.) It
-would be nice to be able to reinvoke the dial chat by user command in
-"cu". It would be nice to be able to invoke an arbitrary named chat
-script in "cu".''
-
-230.
-
-Kevin Johnson: Provide some mechanism such that all requests to a
-particular system were automatically forwarded through some other
-system. This would be useful to hide details of a non-strongly-
-connected network, particularly if the details were subject to change.
-
-231.
-
-Gert Doering: Perhaps it should be possible to -r the default for uucp
-and uux. This would require adding a new option to force the
-invocation of uucico.
-
-232.
-
-Mark Davies: spaces are not handled correctly in the -a argument of
-uux. If an E command is generated, the requestor address is not
-quoted correctly, nor is it parsed correctly. If an execution file is
-generated, the R line is not parsed correctly.
-
-233.
-
-Emmanuel Mogenet: provide some mechanism for a maximum number of
-garbage bytes during a chat script before giving up.
-
-234.
-
-Scott Ballantyne: The address for a TCP port should be separate from
-the phone number, so that a TCP dialer can use \D.
-
-235.
-
-Peter Wemm: The 'i' protocol default parameters do not work at 2400
-baud, because the time it takes to transfer half the packets is less
-than the timeout time. Of course people can always change the
-parameters, but it would be nice if this were dealt with somehow.
-
-236.
-
-Andrew A. Chernov: Perhaps uuxqt should log when it terminates.
-
-237.
-
-dialer-sequence doesn't really do the right thing. There is no way to
-specify both the TCP address and a phone number.
-
-238.
-
-cu -t doesn't work at all. It does nothing.
-
-239.
-
-Paul Pryor: Perhaps a service command should be added to the sys and
-port files. This command would be used as ``service cu'' to indicate
-that the system or port was only available to cu, not to UUCP.
-
-240.
-
-Tim Iverson: The 'g' and 'i' protocol code tends to parse data packet
-headers twice. It processes them once to find out how large the
-packet is, waits for that data to arrive, and then processes the
-header again the second time around. It would be possible to avoid
-this by changing the code to be a simple state machine which
-remembered where it was in the process of parsing the packet.
-
-241.
-
-Klaus Dahlenburg: Log a more precise reason for failure in the .Status
-file: e.g., all ports in use, no matching ports, etc.
-
-242.
-
-Steven S. Dick: It would be helpful if there was a way to get uuchk to
-dump the data from ports/dialers/etc that was NOT picked up from the
-sys file. In other words, add some option to scan the port file and
-the dial file, presumably using uuconf_find_port for the former and
-uuconf_dialer_names for the latter.
-
-243.
-
-Kai Michael Kretschmann: Add a configure option to drop the connection
-if jobs are coming in too slowly, indicating a bad connection.
diff --git a/gnu/libexec/uucp/VERSION b/gnu/libexec/uucp/VERSION
deleted file mode 100644
index 6e1a45b..0000000
--- a/gnu/libexec/uucp/VERSION
+++ /dev/null
@@ -1,4 +0,0 @@
-Version 1.06.1
-
-a complete, unmodified version of this program is available from
-prep.ai.mit.edu.
diff --git a/gnu/libexec/uucp/common_sources/chat.c b/gnu/libexec/uucp/common_sources/chat.c
deleted file mode 100644
index 8328db7..0000000
--- a/gnu/libexec/uucp/common_sources/chat.c
+++ /dev/null
@@ -1,1466 +0,0 @@
-/* chat.c
- Chat routine for the UUCP package.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char chat_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "prot.h"
-#include "system.h"
-
-/* Local functions. */
-
-static int icexpect P((struct sconnection *qconn, int cstrings,
- char **azstrings, size_t *aclens,
- int ctimeout, boolean fstrip));
-static boolean fcsend P((struct sconnection *qconn, pointer puuconf,
- const char *zsend,
- const struct uuconf_system *qsys,
- const struct uuconf_dialer *qdial,
- const char *zphone,
- boolean ftranslate, boolean fstrip));
-static boolean fcecho_send_strip P((struct sconnection *qconn,
- const char *z, size_t clen));
-static boolean fcecho_send_nostrip P((struct sconnection *qconn,
- const char *z, size_t clen));
-static boolean fcecho_send P((struct sconnection *qconn, const char *z,
- size_t clen, boolean fstrip));
-static boolean fcphone P((struct sconnection *qconn,
- pointer puuconf,
- const struct uuconf_dialer *qdial,
- const char *zphone,
- boolean (*pfwrite) P((struct sconnection *qc,
- const char *zwrite,
- size_t cwrite)),
- boolean ftranslate, boolean *pfquote));
-static boolean fctranslate P((pointer puuconf, const char *zphone,
- const char **pzprefix,
- const char **pzsuffix));
-static boolean fcprogram P((struct sconnection *qconn, pointer puuconf,
- char **pzprogram,
- const struct uuconf_system *qsys,
- const struct uuconf_dialer *qdial,
- const char *zphone, const char *zport,
- long ibaud));
-
-/* Run a chat script with the other system. The chat script is a
- series of expect send pairs. We wait for the expect string to show
- up, and then we send the send string. The chat string for a system
- holds the expect and send strings separated by a single space. */
-
-boolean
-fchat (qconn, puuconf, qchat, qsys, qdial, zphone, ftranslate, zport, ibaud)
- struct sconnection *qconn;
- pointer puuconf;
- const struct uuconf_chat *qchat;
- const struct uuconf_system *qsys;
- const struct uuconf_dialer *qdial;
- const char *zphone;
- boolean ftranslate;
- const char *zport;
- long ibaud;
-{
- int cstrings;
- char **azstrings;
- size_t *aclens;
- char **pzchat;
- char *zbuf;
- size_t cbuflen;
- boolean fret;
- int i;
-
- /* First run the program, if any. */
- if (qchat->uuconf_pzprogram != NULL)
- {
- if (! fcprogram (qconn, puuconf, qchat->uuconf_pzprogram, qsys, qdial,
- zphone, zport, ibaud))
- return FALSE;
- }
-
- /* If there's no chat script, we're done. */
- if (qchat->uuconf_pzchat == NULL)
- return TRUE;
-
- if (qchat->uuconf_pzfail == NULL)
- {
- cstrings = 1;
- azstrings = (char **) xmalloc (sizeof (char *));
- aclens = (size_t *) xmalloc (sizeof (size_t));
- }
- else
- {
- char **pz;
-
- /* We leave string number 0 for the chat script. */
- cstrings = 1;
- for (pz = qchat->uuconf_pzfail; *pz != NULL; pz++)
- ++cstrings;
-
- azstrings = (char **) xmalloc (cstrings * sizeof (char *));
- aclens = (size_t *) xmalloc (cstrings * sizeof (size_t));
-
- /* Get the strings into the array, and handle all the escape
- characters. */
- for (cstrings = 1, pz = qchat->uuconf_pzfail;
- *pz != NULL;
- cstrings++, pz++)
- {
- azstrings[cstrings] = zbufcpy (*pz);
- aclens[cstrings] = cescape (azstrings[cstrings]);
- }
- }
-
- cbuflen = 0;
- zbuf = NULL;
- fret = TRUE;
-
- pzchat = qchat->uuconf_pzchat;
-
- while (*pzchat != NULL)
- {
- size_t clen;
-
- /* Loop over subexpects and subsends. */
- while (TRUE)
- {
- char *ztimeout;
- int ctimeout;
-
- /* Copy the expect string into the buffer so that we can
- modify it in cescape. */
- clen = strlen (*pzchat);
- if (clen >= cbuflen)
- {
- ubuffree (zbuf);
- zbuf = zbufalc (clen + 1);
- cbuflen = clen;
- }
- memcpy (zbuf, *pzchat, clen + 1);
-
- azstrings[0] = zbuf;
- if (azstrings[0][0] == '-')
- ++azstrings[0];
-
- /* \Wnum at the end of the string is a timeout. */
- ctimeout = qchat->uuconf_ctimeout;
- ztimeout = strrchr (azstrings[0], '\\');
- if (ztimeout != NULL && ztimeout[1] == 'W')
- {
- char *zend;
- int cval;
-
- cval = (int) strtol (ztimeout + 2, &zend, 10);
- if (zend != ztimeout + 2 && *zend == '\0')
- {
- ctimeout = cval;
- *ztimeout = '\0';
- }
- }
-
- aclens[0] = cescape (azstrings[0]);
-
- if (aclens[0] == 0
- || (aclens[0] == 2
- && strcmp (azstrings[0], "\"\"") == 0))
- {
- /* There is no subexpect sequence. If there is a
- subsend sequence we move on to it. Otherwise we let
- this expect succeed. This is somewhat inconsistent,
- but it seems to be the traditional approach. */
- if (pzchat[1] == NULL || pzchat[1][0] != '-')
- break;
- }
- else
- {
- int istr;
-
- istr = icexpect (qconn, cstrings, azstrings, aclens,
- ctimeout, qchat->uuconf_fstrip);
-
- /* If we found the string, break out of the
- subexpect/subsend loop. */
- if (istr == 0)
- break;
-
- /* If we got an error, return FALSE. */
- if (istr < -1)
- {
- fret = FALSE;
- break;
- }
-
- /* If we found a failure string, log it and get out. */
- if (istr > 0)
- {
- ulog (LOG_ERROR, "Chat script failed: Got \"%s\"",
- qchat->uuconf_pzfail[istr - 1]);
- fret = FALSE;
- break;
- }
-
- /* We timed out; look for a send subsequence. If none,
- the chat script has failed. */
- if (pzchat[1] == NULL || pzchat[1][0] != '-')
- {
- ulog (LOG_ERROR, "Timed out in chat script");
- fret = FALSE;
- break;
- }
- }
-
- /* Send the send subsequence without the leading '-'. A
- \"\" will send nothing. An empty string will send a
- carriage return. */
- ++pzchat;
- if (! fcsend (qconn, puuconf, *pzchat + 1, qsys, qdial, zphone,
- ftranslate, qchat->uuconf_fstrip))
- {
- fret = FALSE;
- break;
- }
-
- /* If there is no expect subsequence, we are done. */
- if (pzchat[1] == NULL || pzchat[1][0] != '-')
- break;
-
- /* Move on to next expect subsequence. */
- ++pzchat;
- }
-
- if (! fret)
- break;
-
- /* Move on to the send string. If there is none, we have
- succeeded. */
- do
- {
- ++pzchat;
- }
- while (*pzchat != NULL && (*pzchat)[0] == '-');
-
- if (*pzchat == NULL)
- break;
-
- if (**pzchat != '\0')
- {
- if (! fcsend (qconn, puuconf, *pzchat, qsys, qdial, zphone,
- ftranslate, qchat->uuconf_fstrip))
- {
- fret = FALSE;
- break;
- }
- }
-
- ++pzchat;
- }
-
- ubuffree (zbuf);
- for (i = 1; i < cstrings; i++)
- ubuffree (azstrings[i]);
- xfree ((pointer) azstrings);
- xfree ((pointer) aclens);
-
- return fret;
-}
-
-/* Read characters and wait for one of a set of memory strings to come
- in. This returns the index into the array of the string that
- arrives, or -1 on timeout, or -2 on error. */
-
-static int
-icexpect (qconn, cstrings, azstrings, aclens, ctimeout, fstrip)
- struct sconnection *qconn;
- int cstrings;
- char **azstrings;
- size_t *aclens;
- int ctimeout;
- boolean fstrip;
-{
- int i;
- size_t cmax;
- char *zhave;
- size_t chave;
- long iendtime;
-#if DEBUG > 1
- int cchars;
- int iolddebug;
-#endif
-
- cmax = aclens[0];
- for (i = 1; i < cstrings; i++)
- if (cmax < aclens[i])
- cmax = aclens[i];
-
- zhave = zbufalc (cmax);
- chave = 0;
-
- iendtime = ixsysdep_time ((long *) NULL) + ctimeout;
-
-#if DEBUG > 1
- cchars = 0;
- iolddebug = iDebug;
- if (FDEBUGGING (DEBUG_CHAT))
- {
- udebug_buffer ("icexpect: Looking for", azstrings[0],
- aclens[0]);
- ulog (LOG_DEBUG_START, "icexpect: Got \"");
- iDebug &=~ (DEBUG_INCOMING | DEBUG_PORT);
- }
-#endif
-
- while (TRUE)
- {
- int bchar;
-
- /* If we have no more time, get out. */
- if (ctimeout <= 0)
- {
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_CHAT))
- {
- ulog (LOG_DEBUG_END, "\" (timed out)");
- iDebug = iolddebug;
- }
-#endif
- ubuffree (zhave);
- return -1;
- }
-
- /* Read one character at a time. We could use a more complex
- algorithm to read in larger batches, but it's probably not
- worth it. If the buffer is full, shift it left; we already
- know that no string matches, and the buffer holds the largest
- string, so this can't lose a match. */
- if (chave >= cmax)
- {
- size_t imove;
-
- for (imove = 0; imove < cmax - 1; imove++)
- zhave[imove] = zhave[imove + 1];
- --chave;
- }
-
- /* The timeout/error return values from breceive_char are the
- same as for this function. */
- bchar = breceive_char (qconn, ctimeout, TRUE);
- if (bchar < 0)
- {
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_CHAT))
- {
- /* If there was an error, it will probably be logged in
- the middle of our string, but this is only debugging
- so it's not a big deal. */
- ulog (LOG_DEBUG_END, "\" (%s)",
- bchar == -1 ? "timed out" : "error");
- iDebug = iolddebug;
- }
-#endif
- ubuffree (zhave);
- return bchar;
- }
-
- /* Strip the parity bit if desired. */
- if (fstrip)
- bchar &= 0x7f;
-
- zhave[chave] = (char) bchar;
- ++chave;
-
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_CHAT))
- {
- char ab[5];
-
- ++cchars;
- if (cchars > 60)
- {
- ulog (LOG_DEBUG_END, "\"");
- ulog (LOG_DEBUG_START, "icexpect: Got \"");
- cchars = 0;
- }
- (void) cdebug_char (ab, bchar);
- ulog (LOG_DEBUG_CONTINUE, "%s", ab);
- }
-#endif
-
- /* See if any of the strings can be found in the buffer. Since
- we read one character at a time, the string can only be found
- at the end of the buffer. */
- for (i = 0; i < cstrings; i++)
- {
- if (aclens[i] <= chave
- && memcmp (zhave + chave - aclens[i], azstrings[i],
- aclens[i]) == 0)
- {
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_CHAT))
- {
- if (i == 0)
- ulog (LOG_DEBUG_END, "\" (found it)");
- else
- {
- ulog (LOG_DEBUG_END, "\"");
- udebug_buffer ("icexpect: Found", azstrings[i],
- aclens[i]);
- }
- iDebug = iolddebug;
- }
-#endif
- ubuffree (zhave);
- return i;
- }
- }
-
- ctimeout = (int) (iendtime - ixsysdep_time ((long *) NULL));
- }
-}
-
-#if DEBUG > 1
-
-/* Debugging function for fcsend. This takes the fquote variable, the
- length of the string (0 if this an informational string which can
- be printed directly) and the string itself. It returns the new
- value for fquote. The fquote variable is TRUE if the debugging
- output is in the middle of a quoted string. */
-
-static size_t cCsend_chars;
-static int iColddebug;
-
-static boolean fcsend_debug P((boolean, size_t, const char *));
-
-static boolean
-fcsend_debug (fquote, clen, zbuf)
- boolean fquote;
- size_t clen;
- const char *zbuf;
-{
- size_t cwas;
-
- if (! FDEBUGGING (DEBUG_CHAT))
- return TRUE;
-
- cwas = cCsend_chars;
- if (clen > 0)
- cCsend_chars += clen;
- else
- cCsend_chars += strlen (zbuf);
- if (cCsend_chars > 60 && cwas > 10)
- {
- ulog (LOG_DEBUG_END, "%s", fquote ? "\"" : "");
- fquote = FALSE;
- ulog (LOG_DEBUG_START, "fcsend: Writing");
- cCsend_chars = 0;
- }
-
- if (clen == 0)
- {
- ulog (LOG_DEBUG_CONTINUE, "%s %s", fquote ? "\"" : "", zbuf);
- return FALSE;
- }
- else
- {
- int i;
-
- if (! fquote)
- ulog (LOG_DEBUG_CONTINUE, " \"");
- for (i = 0; i < clen; i++)
- {
- char ab[5];
-
- (void) cdebug_char (ab, zbuf[i]);
- ulog (LOG_DEBUG_CONTINUE, "%s", ab);
- }
-
- return TRUE;
- }
-}
-
-/* Finish up the debugging information for fcsend. */
-
-static void ucsend_debug_end P((boolean, boolean));
-
-static void
-ucsend_debug_end (fquote, ferr)
- boolean fquote;
- boolean ferr;
-{
- if (! FDEBUGGING (DEBUG_CHAT))
- return;
-
- if (fquote)
- ulog (LOG_DEBUG_CONTINUE, "\"");
-
- if (ferr)
- ulog (LOG_DEBUG_CONTINUE, " (error)");
-
- ulog (LOG_DEBUG_END, "%s", "");
-
- iDebug = iColddebug;
-}
-
-#else /* DEBUG <= 1 */
-
-/* Use macro definitions to make fcsend look neater. */
-
-#define fcsend_debug(fquote, clen, zbuf) TRUE
-
-#define ucsend_debug_end(fquote, ferror)
-
-#endif /* DEBUG <= 1 */
-
-/* Send a string out. This has to parse escape sequences as it goes.
- Note that it handles the dialer escape sequences (\e, \E, \D, \T)
- although they make no sense for chatting with a system. */
-
-static boolean
-fcsend (qconn, puuconf, z, qsys, qdial, zphone, ftranslate, fstrip)
- struct sconnection *qconn;
- pointer puuconf;
- const char *z;
- const struct uuconf_system *qsys;
- const struct uuconf_dialer *qdial;
- const char *zphone;
- boolean ftranslate;
- boolean fstrip;
-{
- boolean fnocr;
- boolean (*pfwrite) P((struct sconnection *, const char *, size_t));
- char *zcallout_login;
- char *zcallout_pass;
- boolean fquote;
-
- if (strcmp (z, "\"\"") == 0)
- return TRUE;
-
- fnocr = FALSE;
- pfwrite = fconn_write;
- zcallout_login = NULL;
- zcallout_pass = NULL;
-
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_CHAT))
- {
- ulog (LOG_DEBUG_START, "fcsend: Writing");
- fquote = FALSE;
- cCsend_chars = 0;
- iColddebug = iDebug;
- iDebug &=~ (DEBUG_OUTGOING | DEBUG_PORT);
- }
-#endif
-
- while (*z != '\0')
- {
- const char *zlook;
- boolean fsend;
- char bsend;
-
- zlook = z + strcspn ((char *) z, "\\BE");
-
- if (zlook > z)
- {
- size_t c;
-
- c = zlook - z;
- fquote = fcsend_debug (fquote, c, z);
- if (! (*pfwrite) (qconn, z, c))
- {
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- }
-
- if (*zlook == '\0')
- break;
-
- z = zlook;
-
- fsend = FALSE;
- switch (*z)
- {
- case 'B':
- if (strncmp (z, "BREAK", 5) == 0)
- {
- fquote = fcsend_debug (fquote, (size_t) 0, "break");
- if (! fconn_break (qconn))
- {
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- fnocr = TRUE;
- z += 5;
- }
- else
- {
- fsend = TRUE;
- bsend = 'B';
- ++z;
- }
- break;
- case 'E':
- if (strncmp (z, "EOT", 3) == 0)
- {
- fsend = TRUE;
- bsend = '\004';
- fnocr = TRUE;
- z += 3;
- }
- else
- {
- fsend = TRUE;
- bsend = 'E';
- ++z;
- }
- break;
- case '\\':
- ++z;
- switch (*z)
- {
- case '-':
- fsend = TRUE;
- bsend = '-';
- break;
- case 'b':
- fsend = TRUE;
- bsend = '\b';
- break;
- case 'c':
- fnocr = TRUE;
- break;
- case 'd':
- fquote = fcsend_debug (fquote, (size_t) 0, "sleep");
- usysdep_sleep (1);
- break;
- case 'e':
- fquote = fcsend_debug (fquote, (size_t) 0, "echo-check-off");
- pfwrite = fconn_write;
- break;
- case 'E':
- fquote = fcsend_debug (fquote, (size_t) 0, "echo-check-on");
- if (fstrip)
- pfwrite = fcecho_send_strip;
- else
- pfwrite = fcecho_send_nostrip;
- break;
- case 'K':
- fquote = fcsend_debug (fquote, (size_t) 0, "break");
- if (! fconn_break (qconn))
- {
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- break;
- case 'n':
- fsend = TRUE;
- bsend = '\n';
- break;
- case 'N':
- fsend = TRUE;
- bsend = '\0';
- break;
- case 'p':
- fquote = fcsend_debug (fquote, (size_t) 0, "pause");
- usysdep_pause ();
- break;
- case 'r':
- fsend = TRUE;
- bsend = '\r';
- break;
- case 's':
- fsend = TRUE;
- bsend = ' ';
- break;
- case 't':
- fsend = TRUE;
- bsend = '\t';
- break;
- case '\0':
- --z;
- /* Fall through. */
- case '\\':
- fsend = TRUE;
- bsend = '\\';
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- fsend = TRUE;
- bsend = *z - '0';
- if (z[1] >= '0' && z[1] <= '7')
- bsend = (char) (8 * bsend + *++z - '0');
- if (z[1] >= '0' && z[1] <= '7')
- bsend = (char) (8 * bsend + *++z - '0');
- break;
- case 'x':
- fsend = TRUE;
- bsend = 0;
- while (isxdigit (BUCHAR (z[1])))
- {
- if (isdigit (BUCHAR (z[1])))
- bsend = (char) (16 * bsend + *++z - '0');
- else if (isupper (BUCHAR (z[1])))
- bsend = (char) (16 * bsend + *++z - 'A' + 10);
- else
- bsend = (char) (16 * bsend + *++z - 'a' + 10);
- }
- break;
- case 'L':
- {
- const char *zlog;
- char *zcopy;
- size_t clen;
-
- if (qsys == NULL)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog (LOG_ERROR, "Illegal use of \\L");
- return FALSE;
- }
- zlog = qsys->uuconf_zcall_login;
- if (zlog == NULL)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog (LOG_ERROR, "No login defined");
- return FALSE;
- }
- if (zlog[0] == '*' && zlog[1] == '\0')
- {
- if (zcallout_login == NULL)
- {
- int iuuconf;
-
- iuuconf = uuconf_callout (puuconf, qsys,
- &zcallout_login,
- &zcallout_pass);
- if (iuuconf == UUCONF_NOT_FOUND
- || zcallout_login == NULL)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog (LOG_ERROR, "No login defined");
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
- }
- zlog = zcallout_login;
- }
- zcopy = zbufcpy (zlog);
- clen = cescape (zcopy);
- fquote = fcsend_debug (fquote, (size_t) 0, "login");
- fquote = fcsend_debug (fquote, clen, zcopy);
- if (! (*pfwrite) (qconn, zcopy, clen))
- {
- ubuffree (zcopy);
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- ubuffree (zcopy);
- }
- break;
- case 'P':
- {
- const char *zpass;
- char *zcopy;
- size_t clen;
-
- if (qsys == NULL)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog (LOG_ERROR, "Illegal use of \\P");
- return FALSE;
- }
- zpass = qsys->uuconf_zcall_password;
- if (zpass == NULL)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog (LOG_ERROR, "No password defined");
- return FALSE;
- }
- if (zpass[0] == '*' && zpass[1] == '\0')
- {
- if (zcallout_pass == NULL)
- {
- int iuuconf;
-
- iuuconf = uuconf_callout (puuconf, qsys,
- &zcallout_login,
- &zcallout_pass);
- if (iuuconf == UUCONF_NOT_FOUND
- || zcallout_pass == NULL)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog (LOG_ERROR, "No password defined");
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
- }
- zpass = zcallout_pass;
- }
- zcopy = zbufcpy (zpass);
- clen = cescape (zcopy);
- fquote = fcsend_debug (fquote, (size_t) 0, "password");
- fquote = fcsend_debug (fquote, clen, zcopy);
- if (! (*pfwrite) (qconn, zcopy, clen))
- {
- ubuffree (zcopy);
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- ubuffree (zcopy);
- }
- break;
- case 'D':
- if (qdial == NULL || zphone == NULL)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog (LOG_ERROR, "Illegal use of \\D");
- return FALSE;
- }
- fquote = fcsend_debug (fquote, (size_t) 0, "\\D");
- if (! fcphone (qconn, puuconf, qdial, zphone, pfwrite,
- ftranslate, &fquote))
- {
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- break;
- case 'T':
- if (qdial == NULL || zphone == NULL)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog (LOG_ERROR, "Illegal use of \\T");
- return FALSE;
- }
- fquote = fcsend_debug (fquote, (size_t) 0, "\\T");
- if (! fcphone (qconn, puuconf, qdial, zphone, pfwrite, TRUE,
- &fquote))
- {
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- break;
- case 'M':
- if (qdial == NULL)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog (LOG_ERROR, "Illegal use of \\M");
- return FALSE;
- }
- fquote = fcsend_debug (fquote, (size_t) 0, "ignore-carrier");
- if (! fconn_carrier (qconn, FALSE))
- {
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- break;
- case 'm':
- if (qdial == NULL)
- {
- ucsend_debug_end (fquote, TRUE);
- ulog (LOG_ERROR, "Illegal use of \\m");
- return FALSE;
- }
- if (qdial->uuconf_fcarrier)
- {
- fquote = fcsend_debug (fquote, (size_t) 0, "need-carrier");
- if (! fconn_carrier (qconn, TRUE))
- {
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- }
- break;
- default:
- /* This error message will screw up any debugging
- information, but it's easily avoidable. */
- ulog (LOG_ERROR,
- "Unrecognized escape sequence \\%c in send string",
- *z);
- fsend = TRUE;
- bsend = *z;
- break;
- }
- ++z;
- break;
-#if DEBUG > 0
- default:
- ulog (LOG_FATAL, "fcsend: Can't happen");
- break;
-#endif
- }
-
- if (fsend)
- {
- fquote = fcsend_debug (fquote, (size_t) 1, &bsend);
- if (! (*pfwrite) (qconn, &bsend, (size_t) 1))
- {
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- }
- }
-
- xfree ((pointer) zcallout_login);
- xfree ((pointer) zcallout_pass);
-
- /* Output a final carriage return, unless there was a \c. Don't
- bother to check for an echo. */
- if (! fnocr)
- {
- char b;
-
- b = '\r';
- fquote = fcsend_debug (fquote, (size_t) 1, &b);
- if (! fconn_write (qconn, &b, (size_t) 1))
- {
- ucsend_debug_end (fquote, TRUE);
- return FALSE;
- }
- }
-
- ucsend_debug_end (fquote, FALSE);
-
- return TRUE;
-}
-
-/* Write out a phone number with optional dialcode translation. The
- pfquote argument is only used for debugging. */
-
-static boolean
-fcphone (qconn, puuconf, qdial, zphone, pfwrite, ftranslate, pfquote)
- struct sconnection *qconn;
- pointer puuconf;
- const struct uuconf_dialer *qdial;
- const char *zphone;
- boolean (*pfwrite) P((struct sconnection *qc, const char *zwrite,
- size_t cwrite));
- boolean ftranslate;
- boolean *pfquote;
-{
- const char *zprefix, *zsuffix;
-
- if (ftranslate)
- {
- if (! fctranslate (puuconf, zphone, &zprefix, &zsuffix))
- return FALSE;
- }
- else
- {
- zprefix = zphone;
- zsuffix = NULL;
- }
-
- while (zprefix != NULL)
- {
- while (TRUE)
- {
- const char *z;
- const char *zstr;
-
- z = zprefix + strcspn ((char *) zprefix, "=-");
- if (z > zprefix)
- {
- size_t clen;
-
- clen = z - zprefix;
- *pfquote = fcsend_debug (*pfquote, clen, zprefix);
- if (! (*pfwrite) (qconn, zprefix, clen))
- return FALSE;
- }
-
- if (*z == '=')
- zstr = qdial->uuconf_zdialtone;
- else if (*z == '-')
- zstr = qdial->uuconf_zpause;
- else /* *z == '\0' */
- break;
-
- if (zstr != NULL)
- {
- *pfquote = fcsend_debug (*pfquote, strlen (zstr), zstr);
- if (! (*pfwrite) (qconn, zstr, strlen (zstr)))
- return FALSE;
- }
-
- zprefix = z + 1;
- }
-
- zprefix = zsuffix;
- zsuffix = NULL;
- }
-
- return TRUE;
-}
-
-/* Given a phone number, run it through dial code translation
- returning two strings. */
-
-static boolean
-fctranslate (puuconf, zphone, pzprefix, pzsuffix)
- pointer puuconf;
- const char *zphone;
- const char **pzprefix;
- const char **pzsuffix;
-{
- int iuuconf;
- char *zdialcode, *zto;
- const char *zfrom;
- char *ztrans;
-
- *pzprefix = zphone;
- *pzsuffix = NULL;
-
- zdialcode = zbufalc (strlen (zphone) + 1);
- zfrom = zphone;
- zto = zdialcode;
- while (*zfrom != '\0' && isalpha (BUCHAR (*zfrom)))
- *zto++ = *zfrom++;
- *zto = '\0';
-
- if (*zdialcode == '\0')
- {
- ubuffree (zdialcode);
- return TRUE;
- }
-
- iuuconf = uuconf_dialcode (puuconf, zdialcode, &ztrans);
-
- ubuffree (zdialcode);
-
- if (iuuconf == UUCONF_NOT_FOUND)
- return TRUE;
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
- else
- {
- /* We really should figure out a way to free up ztrans here. */
- *pzprefix = ztrans;
- *pzsuffix = zfrom;
- return TRUE;
- }
-}
-
-/* Write out a string making sure the each character is echoed back.
- There are two versions of this function, one which strips the
- parity bit from the characters and one which does not. This is so
- that I can use a single function pointer in fcsend, and to avoid
- using any static variables so that I can put chat scripts in a
- library some day. */
-
-static boolean
-fcecho_send_strip (qconn, zwrite, cwrite)
- struct sconnection *qconn;
- const char *zwrite;
- size_t cwrite;
-{
- return fcecho_send (qconn, zwrite, cwrite, TRUE);
-}
-
-static boolean
-fcecho_send_nostrip (qconn, zwrite, cwrite)
- struct sconnection *qconn;
- const char *zwrite;
- size_t cwrite;
-{
- return fcecho_send (qconn, zwrite, cwrite, FALSE);
-}
-
-static boolean
-fcecho_send (qconn, zwrite, cwrite, fstrip)
- struct sconnection *qconn;
- const char *zwrite;
- size_t cwrite;
- boolean fstrip;
-{
- const char *zend;
-
- zend = zwrite + cwrite;
-
- for (; zwrite < zend; zwrite++)
- {
- int b;
- char bwrite;
-
- bwrite = *zwrite;
- if (! fconn_write (qconn, &bwrite, (size_t) 1))
- return FALSE;
- if (fstrip)
- bwrite &= 0x7f;
- do
- {
- /* We arbitrarily wait five seconds for the echo. */
- b = breceive_char (qconn, 5, TRUE);
- /* Now b == -1 on timeout, -2 on error. */
- if (b < 0)
- {
- if (b == -1)
- ulog (LOG_ERROR, "Character not echoed");
- return FALSE;
- }
- if (fstrip)
- b &= 0x7f;
- }
- while (b != BUCHAR (bwrite));
- }
-
- return TRUE;
-}
-
-/* Run a chat program. Expand any escape sequences and call a system
- dependent program to run it. */
-
-static boolean
-fcprogram (qconn, puuconf, pzprogram, qsys, qdial, zphone, zport, ibaud)
- struct sconnection *qconn;
- pointer puuconf;
- char **pzprogram;
- const struct uuconf_system *qsys;
- const struct uuconf_dialer *qdial;
- const char *zphone;
- const char *zport;
- long ibaud;
-{
- size_t cargs;
- char **pzpass, **pzarg;
- char **pz;
- char *zcallout_login;
- char *zcallout_pass;
- boolean fret;
-
- cargs = 1;
- for (pz = pzprogram; *pz != NULL; pz++)
- ++cargs;
-
- pzpass = (char **) xmalloc (cargs * sizeof (char *));
-
- zcallout_login = NULL;
- zcallout_pass = NULL;
- fret = TRUE;
-
- /* Copy the string into memory expanding escape sequences. */
- for (pz = pzprogram, pzarg = pzpass; *pz != NULL; pz++, pzarg++)
- {
- const char *zfrom;
- size_t calc, clen;
- char *zto;
-
- if (strchr (*pz, '\\') == NULL)
- {
- *pzarg = zbufcpy (*pz);
- continue;
- }
-
- *pzarg = NULL;
- zto = NULL;
- calc = 0;
- clen = 0;
-
- for (zfrom = *pz; *zfrom != '\0'; zfrom++)
- {
- const char *zadd = NULL;
- char *zfree = NULL;
- size_t cadd;
- char abadd[15];
-
- if (*zfrom != '\\')
- {
- if (clen + 2 > calc)
- {
- char *znew;
-
- calc = clen + 50;
- znew = zbufalc (calc);
- memcpy (znew, *pzarg, clen);
- ubuffree (*pzarg);
- *pzarg = znew;
- zto = znew + clen;
- }
- *zto++ = *zfrom;
- ++clen;
- continue;
- }
-
- ++zfrom;
- switch (*zfrom)
- {
- case '\0':
- --zfrom;
- /* Fall through. */
- case '\\':
- zadd = "\\";
- break;
- case 'L':
- {
- const char *zlog;
-
- if (qsys == NULL)
- {
- ulog (LOG_ERROR, "chat-program: Illegal use of \\L");
- fret = FALSE;
- break;
- }
- zlog = qsys->uuconf_zcall_login;
- if (zlog == NULL)
- {
- ulog (LOG_ERROR, "chat-program: No login defined");
- fret = FALSE;
- break;
- }
- if (zlog[0] == '*' && zlog[1] == '\0')
- {
- if (zcallout_login == NULL)
- {
- int iuuconf;
-
- iuuconf = uuconf_callout (puuconf, qsys,
- &zcallout_login,
- &zcallout_pass);
- if (iuuconf == UUCONF_NOT_FOUND
- || zcallout_login == NULL)
- {
- ulog (LOG_ERROR,
- "chat-program: No login defined");
- fret = FALSE;
- break;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fret = FALSE;
- break;
- }
- }
- zlog = zcallout_login;
- }
- zfree = zbufcpy (zlog);
- (void) cescape (zfree);
- zadd = zfree;
- }
- break;
- case 'P':
- {
- const char *zpass;
-
- if (qsys == NULL)
- {
- ulog (LOG_ERROR, "chat-program: Illegal use of \\P");
- fret = FALSE;
- break;
- }
- zpass = qsys->uuconf_zcall_password;
- if (zpass == NULL)
- {
- ulog (LOG_ERROR, "chat-program: No password defined");
- fret = FALSE;
- break;
- }
- if (zpass[0] == '*' && zpass[1] == '\0')
- {
- if (zcallout_pass == NULL)
- {
- int iuuconf;
-
- iuuconf = uuconf_callout (puuconf, qsys,
- &zcallout_login,
- &zcallout_pass);
- if (iuuconf == UUCONF_NOT_FOUND
- || zcallout_pass == NULL)
- {
- ulog (LOG_ERROR,
- "chat-program: No password defined");
- fret = FALSE;
- break;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fret = FALSE;
- break;
- }
- }
- zpass = zcallout_pass;
- }
- zfree = zbufcpy (zpass);
- (void) cescape (zfree);
- zadd = zfree;
- }
- break;
- case 'D':
- if (qdial == NULL || zphone == NULL)
- {
- ulog (LOG_ERROR, "chat-program: Illegal use of \\D");
- fret = FALSE;
- break;
- }
- zadd = zphone;
- break;
- case 'T':
- {
- const char *zprefix, *zsuffix;
-
- if (qdial == NULL || zphone == NULL)
- {
- ulog (LOG_ERROR, "chat-program: Illegal use of \\T");
- fret = FALSE;
- break;
- }
-
- if (! fctranslate (puuconf, zphone, &zprefix, &zsuffix))
- {
- fret = FALSE;
- break;
- }
-
- if (zsuffix == NULL)
- zadd = zprefix;
- else
- {
- size_t cprefix;
-
- cprefix = strlen (zprefix);
- if (clen + cprefix + 1 > calc)
- {
- char *znew;
-
- calc = clen + cprefix + 20;
- znew = zbufalc (calc);
- memcpy (znew, *pzarg, clen);
- ubuffree (*pzarg);
- *pzarg = znew;
- zto = znew + clen;
- }
- memcpy (zto, zprefix, cprefix);
- zto += cprefix;
- clen += cprefix;
- zadd = zsuffix;
- }
- }
- break;
- case 'Y':
- if (zLdevice == NULL && zport == NULL)
- {
- ulog (LOG_ERROR, "chat-program: Illegal use of \\Y");
- fret = FALSE;
- break;
- }
- /* zLdevice will generally make more sense than zport, but
- it might not be set yet. */
- zadd = zLdevice;
- if (zadd == NULL)
- zadd = zport;
- break;
- case 'Z':
- if (qsys == NULL)
- {
- ulog (LOG_ERROR, "chat-program: Illegal use of \\Z");
- fret = FALSE;
- break;
- }
- zadd = qsys->uuconf_zname;
- break;
- case 'S':
- {
- if (ibaud == 0)
- {
- ulog (LOG_ERROR, "chat-program: Illegal use of \\S");
- fret = FALSE;
- break;
- }
- sprintf (abadd, "%ld", ibaud);
- zadd = abadd;
- }
- break;
- default:
- {
- ulog (LOG_ERROR,
- "chat-program: Unrecognized escape sequence \\%c",
- *zfrom);
- abadd[0] = *zfrom;
- abadd[1] = '\0';
- zadd = abadd;
- }
- break;
- }
-
- if (! fret)
- break;
-
- cadd = strlen (zadd);
- if (clen + cadd + 1 > calc)
- {
- char *znew;
-
- calc = clen + cadd + 20;
- znew = zbufalc (calc);
- memcpy (znew, *pzarg, clen);
- ubuffree (*pzarg);
- *pzarg = znew;
- zto = znew + clen;
- }
- memcpy (zto, zadd, cadd + 1);
- zto += cadd;
- clen += cadd;
- ubuffree (zfree);
- }
-
- if (! fret)
- break;
-
- *zto++ = '\0';
- ++clen;
- }
-
- *pzarg = NULL;
-
- if (fret)
- fret = fconn_run_chat (qconn, pzpass);
-
- for (pz = pzpass; *pz != NULL; pz++)
- ubuffree (*pz);
- xfree ((pointer) pzpass);
- xfree ((pointer) zcallout_login);
- xfree ((pointer) zcallout_pass);
-
- return fret;
-}
diff --git a/gnu/libexec/uucp/common_sources/config.h b/gnu/libexec/uucp/common_sources/config.h
deleted file mode 100644
index fdd90125..0000000
--- a/gnu/libexec/uucp/common_sources/config.h
+++ /dev/null
@@ -1,472 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* Configuration header file for Taylor UUCP. -*- C -*- */
-
-/* If your compiler does not use const correctly, then undefine it
- here. This #undef is commented out by the configure script if it
- determines that const is supported. */
-/* #undef const */
-
-/* If your compiler supports prototypes, set HAVE_PROTOTYPES to 1. */
-#define HAVE_PROTOTYPES 1
-
-/* Set ECHO_PROGRAM to a program which echoes its arguments; if echo
- is a shell builtin you can just use "echo". */
-#define ECHO_PROGRAM "echo"
-
-/* The following macros indicate what header files you have. Set the
- macro to 1 if you have the corresponding header file, or 0 if you
- do not. */
-#define HAVE_STDDEF_H 1 /* <stddef.h> */
-#define HAVE_STDARG_H 1 /* <stdarg.h> */
-#define HAVE_STRING_H 1 /* <string.h> */
-#define HAVE_STRINGS_H 1 /* <strings.h> */
-#define HAVE_UNISTD_H 1 /* <unistd.h> */
-#define HAVE_STDLIB_H 1 /* <stdlib.h> */
-#define HAVE_LIMITS_H 1 /* <limits.h> */
-#define HAVE_TIME_H 1 /* <time.h> */
-#define HAVE_SYS_WAIT_H 1 /* <sys/wait.h> */
-#define HAVE_SYS_IOCTL_H 1 /* <sys/ioctl.h> */
-#define HAVE_DIRENT_H 1 /* <dirent.h> */
-#define HAVE_MEMORY_H 1 /* <memory.h> */
-#define HAVE_TERMIOS_H 1 /* <termios.h> */
-#define HAVE_SYS_PARAM_H 1 /* <sys/param.h> */
-#define HAVE_UTIME_H 1 /* <utime.h> */
-#define HAVE_FCNTL_H 1 /* <fcntl.h> */
-#define HAVE_SYS_FILE_H 1 /* <sys/file.h> */
-#define HAVE_SYS_TIME_H 1 /* <sys/time.h> */
-#define HAVE_SYS_TIMES_H 1 /* <sys/times.h> */
-#define HAVE_LIBC_H 0 /* <libc.h> */
-#define HAVE_SYSEXITS_H 1 /* <sysexits.h> */
-#define HAVE_POLL_H 0 /* <poll.h> */
-#define HAVE_TIUSER_H 0 /* <tiuser.h> */
-#define HAVE_XTI_H 0 /* <xti.h> */
-#define HAVE_SYS_TLI_H 0 /* <sys/tli.h> */
-#define HAVE_STROPTS_H 0 /* <stropts.h> */
-#define HAVE_FTW_H 0 /* <ftw.h> */
-#define HAVE_GLOB_H 1 /* <glob.h> */
-#define HAVE_SYS_SELECT_H 0 /* <sys/select.h> */
-#define HAVE_SYS_TYPES_TCP_H 0 /* <sys/types.tcp.h> */
-#define HAVE_SYS_MOUNT_H 1 /* <sys/mount.h> */
-#define HAVE_SYS_VFS_H 0 /* <sys/vfs.h> */
-#define HAVE_SYS_FILSYS_H 0 /* <sys/filsys.h> */
-#define HAVE_SYS_STATFS_H 0 /* <sys/statfs.h> */
-#define HAVE_SYS_DUSTAT_H 0 /* <sys/dustat.h> */
-#define HAVE_SYS_FS_TYPES_H 0 /* <sys/fs_types.h> */
-#define HAVE_USTAT_H 0 /* <ustat.h> */
-#define HAVE_SYS_STATVFS_H 0 /* <sys/statvfs.h> */
-
-/* If major and minor are not defined in <sys/types.h>, but are in
- <sys/mkdev.h>, set MAJOR_IN_MKDEV to 1. If they are in
- <sys/sysmacros.h>, set MAJOR_IN_SYSMACROS to 1. */
-#define MAJOR_IN_MKDEV 0
-#define MAJOR_IN_SYSMACROS 0
-
-/* If the macro offsetof is not defined in <stddef.h>, you may give it
- a definition here. If you do not, the code will use a definition
- (in uucp.h) that should be fairly portable. */
-/* #define offsetof */
-
-/* Set RETSIGTYPE to the return type of a signal handler. On newer
- systems this will be void; some older systems use int. */
-#define RETSIGTYPE void
-
-/* If the macro S_ISDIR is defined in <sys/stat.h>, but is incorrect,
- define STAT_MACROS_BROKEN to be 1. This is said to be the case on
- Tektronix UTekV, Amdahl UTS and Motorola System V/88. */
-#define STAT_MACROS_BROKEN 0
-
-/* Set TIME_WITH_SYS_TIME to 1 if <time.h> and <sys/time.h> can both
- be included in a single source file; if you don't have either or
- both of them, it doesn't matter what you set this to. */
-#define TIME_WITH_SYS_TIME 1
-
-/* Set TM_IN_SYS_TIME to 1 if struct tm is defined in <sys/time.h>
- rather than in <time.h>. */
-#define TM_IN_SYS_TIME 0
-
-/* Set HAVE_TERMIOS_AND_SYS_IOCTL_H to 1 if <termios.h> and <sys/ioctl.h>
- can both be included in a single source file; if you don't have either
- or both of them, it doesn't matter what you set this to. */
-#define HAVE_TERMIOS_AND_SYS_IOCTL_H 1
-
-/* If you are configuring by hand, you should set one of the terminal
- driver options in policy.h. If you are autoconfiguring, the script
- will check whether your system defines CBREAK, which is a terminal
- setting; if your system supports CBREAK, and you don't set a terminal
- driver in policy.h, the code will assume that you have a BSD style
- terminal driver. */
-#define HAVE_CBREAK 1
-
-/* The package needs several standard types. If you are using the
- configure script, it will look in standard places for these types,
- and give default definitions for them here if it doesn't find them.
- The default definitions should work on most systems, but you may
- want to check them. If you are configuring by hand, you will have
- to figure out whether the types are defined on your system, and
- what they should be defined to.
-
- Any type that is not defined on your system should get a macro
- definition. The definition should be of the name of the type in
- all capital letters. For example, #define PID_T int. If the type
- is defined in a standard header file, the macro name should not be
- defined. */
-
-/* The type pid_t is used to hold a process ID number. It is normally
- defined in <sys/types.h>. This is the type returned by the
- functions fork or getpid. Usually int will work fine. */
-/* #undef PID_T */
-
-/* The type uid_t is used to hold a user ID number. It is normally
- defined in <sys/types.h>. This is the type returned by the getuid
- function. Usually int will work fine. */
-/* #undef UID_T */
-
-/* The type gid_t is used to hold a group ID number. It is sometimes
- defined in <sys/types.h>. This is the type returned by the getgid
- function. Usually int will work fine. */
-/* #undef GID_T */
-
-/* The type off_t is used to hold an offset in a file. It is sometimes
- defined in <sys/types.h>. This is the type of the second argument to
- the lseek function. Usually long will work fine. */
-/* #undef OFF_T */
-
-/* Set HAVE_SIG_ATOMIC_T_IN_SIGNAL_H if the type sig_atomic_t is defined
- in <signal.h> as required by ANSI C. */
-#define HAVE_SIG_ATOMIC_T_IN_SIGNAL_H 1
-
-/* Set HAVE_SIG_ATOMIC_T_IN_TYPES_H if the type sig_atomic_t is defined
- in <sys/types.h>. This is ignored if HAVE_SIG_ATOMIC_T_IN_SIGNAL_H is
- set to 1. */
-#define HAVE_SIG_ATOMIC_T_IN_TYPES_H 0
-
-/* The type sig_atomic_t is used to hold a value which may be
- referenced in a single atomic operation. If it is not defined in
- either <signal.h> or <sys/types.h>, you may want to give it a
- definition here. If you don't, the code will use char. If your
- compiler does not support sig_atomic_t, there is no type which is
- really correct; fortunately, for this package it does not really
- matter very much. */
-/* #undef SIG_ATOMIC_T */
-
-/* Set HAVE_SIZE_T_IN_STDDEF_H to 1 if the type size_t is defined in
- <stddef.h> as required by ANSI C. */
-#define HAVE_SIZE_T_IN_STDDEF_H 1
-
-/* Set HAVE_SIZE_T_IN_TYPES_H to 1 if the type size_t is defined in
- <sys/types.h>. This is ignored if HAVE_SIZE_T_IN_STDDEF_H is set
- to 1. */
-#define HAVE_SIZE_T_IN_TYPES_H 1
-
-/* The type size_t is used to hold the size of an object. In
- particular, an argument of this type is passed as the size argument
- to the malloc and realloc functions. If size_t is not defined in
- either <stddef.h> or <sys/types.h>, you may want to give it a
- definition here. If you don't, the code will use unsigned. */
-/* #undef SIZE_T */
-
-/* Set HAVE_TIME_T_IN_TIME_H to 1 if the type time_t is defined in
- <time.h>, as required by the ANSI C standard. */
-#define HAVE_TIME_T_IN_TIME_H 1
-
-/* Set HAVE_TIME_T_IN_TYPES_H to 1 if the type time_t is defined in
- <sys/types.h>. This is ignored if HAVE_TIME_T_IN_TIME_H is set to
- 1. */
-#define HAVE_TIME_T_IN_TYPES_H 1
-
-/* When Taylor UUCP is talking to another instance of itself, it will
- tell the other side the size of a file before it is transferred.
- If the package can determine how much disk space is available, it
- will use this information to avoid filling up the disk. Define one
- of the following macros to tell the code how to determine the
- amount of available disk space. It is possible that none of these
- are appropriate; it will do no harm to use none of them, but, of
- course, nothing will then prevent the package from filling up the
- disk. Note that this space check is only useful when talking to
- another instance of Taylor UUCP.
-
- STAT_STATVFS statvfs function
- STAT_STATFS3_OSF1 three argument statfs function (OSF/1)
- STAT_STATFS2_BSIZE two argument statfs function with f_bsize field
- STAT_STATFS2_FSIZE two argument statfs function with f_fsize field
- STAT_STATFS2_FS_DATA two argument statfs function with fd_req field
- STAT_STATFS4 four argument statfs function
- STAT_DISK_SPACE disk_space function (QNX)
- STAT_USTAT the ustat function with 512 byte blocks. */
-#define STAT_STATVFS 0
-#define STAT_STATFS3_OSF1 0
-#define STAT_STATFS2_BSIZE 1
-#define STAT_STATFS2_FSIZE 0
-#define STAT_STATFS2_FS_DATA 0
-#define STAT_STATFS4 0
-#define STAT_DISK_SPACE 0
-#define STAT_USTAT 0
-
-/* Set HAVE_VOID to 1 if the compiler supports declaring functions with
- a return type of void and casting values to void. */
-#define HAVE_VOID 1
-
-/* Set HAVE_UNSIGNED_CHAR to 1 if the compiler supports the type unsigned
- char. */
-#define HAVE_UNSIGNED_CHAR 1
-
-/* Set HAVE_ERRNO_DECLARATION to 1 if errno is declared in <errno.h>. */
-#define HAVE_ERRNO_DECLARATION 1
-
-/* Set HAVE_TXADDCD to 1 if TXADDCD is defined in <sys/ioctl.h>, as it
- is on AIX. */
-#define HAVE_TXADDCD 0
-
-/* There are now a number of functions to check for. For each of
- these, the macro HAVE_FUNC should be set to 1 if your system has
- FUNC. For example, HAVE_VFPRINTF should be set to 1 if your system
- has vfprintf, 0 otherwise. */
-
-/* Taylor UUCP will take advantage of the following functions if they
- are available, but knows how to deal with their absence. */
-#define HAVE_VFPRINTF 1
-#define HAVE_FTRUNCATE 1
-#define HAVE_LTRUNC 0
-#define HAVE_WAITPID 1
-#define HAVE_WAIT4 1
-#define HAVE_GLOB 1
-#define HAVE_SETREUID 1
-#define HAVE_SETEUID 1
-
-/* There are several functions which are replaced in the subdirectory
- lib. If they are missing, the configure script will automatically
- add them to lib/Makefile to force them to be recompiled. If you
- are configuring by hand, you will have to do this yourself. The
- string @LIBOBJS@ in lib/Makefile.in should be replaced by a list of
- object files in lib/Makefile. The following comments tell you
- which object file names to add (they are generally fairly obvious,
- given that the file names have no more than six characters before
- the period). */
-
-/* For each of these functions, if it does not exist, the indicated
- object file should be added to lib/Makefile. */
-#define HAVE_BSEARCH 1 /* bsrch.o */
-#define HAVE_GETLINE 0 /* getlin.o */
-#define HAVE_MEMCHR 1 /* memchr.o */
-#define HAVE_STRDUP 1 /* strdup.o */
-#define HAVE_STRSTR 1 /* strstr.o */
-#define HAVE_STRTOL 1 /* strtol.o */
-#define HAVE_STRTOUL 1 /* strtou.o */
-
-/* If neither of these functions exists, you should add bzero.o to
- lib/Makefile. */
-#define HAVE_BZERO 1
-#define HAVE_MEMSET 1
-
-/* If neither of these functions exists, you should add memcmp.o to
- lib/Makefile. */
-#define HAVE_MEMCMP 1
-#define HAVE_BCMP 1
-
-/* If neither of these functions exists, you should add memcpy.o to
- lib/Makefile. */
-#define HAVE_MEMCPY 1
-#define HAVE_BCOPY 1
-
-/* If neither of these functions exists, you should add strcas.o to
- lib/Makefile. */
-#define HAVE_STRCASECMP 1
-#define HAVE_STRICMP 0
-
-/* If neither of these functions exists, you should add strncs.o to
- lib/Makefile. */
-#define HAVE_STRNCASECMP 1
-#define HAVE_STRNICMP 0
-
-/* If neither of these functions exists, you should add strchr.o to
- lib/Makefile. */
-#define HAVE_STRCHR 1
-#define HAVE_INDEX 1
-
-/* If neither of these functions exists, you should add strrch.o to
- lib/Makefile. */
-#define HAVE_STRRCHR 1
-#define HAVE_RINDEX 1
-
-/* There are also Unix specific functions which are replaced in the
- subdirectory unix. If they are missing, the configure script will
- automatically add them to unix/Makefile to force them to be
- recompiled. If you are configuring by hand, you will have to do
- this yourself. The string @UNIXOBJS@ in unix/Makefile.in should be
- replaced by a list of object files in unix/Makefile. The following
- comments tell you which object file names to add. */
-
-/* For each of these functions, if it does not exist, the indicated
- object file should be added to unix/Makefile. */
-#define HAVE_OPENDIR 1 /* dirent.o */
-#define HAVE_DUP2 1 /* dup2.o */
-#define HAVE_FTW 0 /* ftw.o */
-#define HAVE_REMOVE 1 /* remove.o */
-#define HAVE_RENAME 1 /* rename.o */
-#define HAVE_STRERROR 1 /* strerr.o */
-
-/* The code needs to know how to create directories. If you have the
- mkdir function, set HAVE_MKDIR to 1 and replace @UUDIR@ in
- Makefile.in with '# ' (the configure script will set @UUDIR@
- according to the variable UUDIR). Otherwise, set HAVE_MKDIR to 0,
- remove @UUDIR@ from Makefile.in, set MKDIR_PROGRAM to the name of
- the program which will create a directory named on the command line
- (e.g., "/bin/mkdir"), and add mkdir.o to the @UNIXOBJS@ string in
- unix/Makefile.in. */
-#define HAVE_MKDIR 1
-#define MKDIR_PROGRAM unused
-
-/* The code also needs to know how to remove directories. If you have
- the rmdir function, set HAVE_RMDIR to 1. Otherwise, set
- RMDIR_PROGRAM to the name of the program which will remove a
- directory named on the command line (e.g., "/bin/rmdir") and add
- rmdir.o to the @UNIXOBJS@ string in unix/Makefile.in. */
-#define HAVE_RMDIR 1
-#define RMDIR_PROGRAM unused
-
-/* The code needs to know to how to get the name of the current
- directory. If getcwd is available it will be used, otherwise if
- getwd is available it will be used. Otherwise, set PWD_PROGRAM to
- the name of the program which will print the name of the current
- working directory (e.g., "/bin/pwd") and add getcwd.o to the
- @UNIXOBJS@ string in unix/Makefile.in. */
-#define HAVE_GETCWD 1
-#define HAVE_GETWD 1
-#define PWD_PROGRAM unused
-
-/* If you have either sigsetjmp or setret, it will be used instead of
- setjmp. These functions will only be used if your system restarts
- system calls after interrupts (see HAVE_RESTARTABLE_SYSCALLS,
- below). */
-#define HAVE_SIGSETJMP 1
-#define HAVE_SETRET 0
-
-/* The code needs to know what function to use to set a signal
- handler. If will try to use each of the following functions in
- turn. If none are available, it will use signal, which is assumed
- to always exist. */
-#define HAVE_SIGACTION 1
-#define HAVE_SIGVEC 1
-#define HAVE_SIGSET 0
-
-/* If the code is going to use sigvec (HAVE_SIGACTION is 0 and
- HAVE_SIGVEC is 1), then HAVE_SIGVEC_SV_FLAGS must be set to 1 if
- the sigvec structure contains the sv_flags field, or 0 if the
- sigvec structure contains the sv_onstack field. If the code is not
- going to use sigvec, it doesn't matter what this is set to. */
-#define HAVE_SIGVEC_SV_FLAGS 1
-
-/* The code will try to use each of the following functions in turn
- when blocking signals from delivery. If none are available, a
- relatively unimportant race condition will exist. */
-#define HAVE_SIGPROCMASK 1
-#define HAVE_SIGBLOCK 1
-#define HAVE_SIGHOLD 0
-
-/* If you have either of the following functions, it will be used to
- determine the number of file descriptors which may be open.
- Otherwise, the code will use OPEN_MAX if defined, then NOFILE if
- defined, then 20. */
-#define HAVE_GETDTABLESIZE 1
-#define HAVE_SYSCONF 1
-
-/* The code will use one of the following functions when detaching
- from a terminal. One of these must exist. */
-#define HAVE_SETPGRP 1
-#define HAVE_SETSID 1
-
-/* If you do not specify the local node name in the main configuration
- file, Taylor UUCP will try to use each of the following functions
- in turn. If neither is available, you must specify the local node
- name in the configuration file. */
-#define HAVE_GETHOSTNAME 1
-#define HAVE_UNAME 1
-
-/* The code will try to use each of the following functions in turn to
- determine the current time. If none are available, it will use
- time, which is assumed to always exist. */
-#define HAVE_GETTIMEOFDAY 1
-#define HAVE_FTIME 0
-
-/* If neither gettimeofday nor ftime is available, the code will use
- times (if available) to measure a span of time. See also the
- discussion of TIMES_TICK in policy.h. */
-#define HAVE_TIMES 1
-
-/* When a chat script requests a pause of less than a second with \p,
- Taylor UUCP will try to use each of the following functions in
- turn. If none are available, it will sleep for a full second.
- Also, the (non-portable) tstuu program requires either select or
- poll. */
-#define HAVE_NAPMS 0
-#define HAVE_NAP 0
-#define HAVE_USLEEP 1
-#define HAVE_POLL 0
-#define HAVE_SELECT 1
-
-/* If the getgrent function is available, it will be used to determine
- all the groups a user belongs to when checking file access
- permissions. */
-#define HAVE_GETGRENT 1
-
-/* If the socket function is available, TCP support code will be
- compiled in. */
-#define HAVE_SOCKET 1
-
-/* If the t_open function is available, TLI support code will be
- compiled in. This may require adding a library, such as -lnsl or
- -lxti, to the Makefile variables LIBS. */
-#define HAVE_T_OPEN 0
-
-/* If the dev_info function is available (QNX only), it will be used
- to determine if any other process has the serial port open, and
- that will cause uucico and cu to presume the port is locked. */
-#define HAVE_DEV_INFO 0
-
-/* That's the end of the list of the functions. Now there are a few
- last miscellaneous items. */
-
-/* On some systems the following functions are declared in such a way
- that the code cannot make a simple extern. On other systems, these
- functions are not declared at all, and the extern is required. If
- a declaration of the function, as shown, compiles on your system,
- set the value to 1. Not all functions declared externally are
- listed here, only the ones with which I have had trouble. */
-/* extern long times (); */
-#define TIMES_DECLARATION_OK 0
-/* extern struct passwd *getpwnam (); */
-#define GETPWNAM_DECLARATION_OK 1
-/* extern struct passwd *getpwuid (); */
-#define GETPWUID_DECLARATION_OK 1
-/* extern struct group *getgrent (); */
-#define GETGRENT_DECLARATION_OK 1
-
-/* Set HAVE_BSD_PGRP to 1 if your getpgrp call takes 1 argument and
- your setpgrp calls takes 2 arguments (on System V they generally
- take no arguments). You can safely set this to 1 on System V,
- provided the call will compile without any errors. */
-#define HAVE_BSD_PGRP 0
-
-/* Set HAVE_UNION_WAIT to 1 if union wait is defined in the header
- file <sys/wait.h>. */
-#define HAVE_UNION_WAIT 1
-
-/* Set HAVE_LONG_FILE_NAMES to 1 if the system supports file names
- longer than 14 characters. */
-#define HAVE_LONG_FILE_NAMES 1
-
-/* If slow system calls are restarted after interrupts, set
- HAVE_RESTARTABLE_SYSCALLS to 1. This is ignored if HAVE_SIGACTION
- is 1 or if HAVE_SIGVEC is 1 and HAVE_SIGVEC_SV_FLAGS is 1 and
- SV_INTERRUPT is defined in <signal.h>. In both of these cases
- system calls can be prevented from restarting. */
-#define HAVE_RESTARTABLE_SYSCALLS 1
-
-/* Some systems supposedly need the following macros to be defined.
- These are handled by the configure script. If you are configuring
- by hand, you may add appropriate definitions here, or just add them
- to CFLAGS when running make. */
-/* #undef _ALL_SOURCE */
-/* #undef _POSIX_SOURCE */
-/* #undef _MINIX */
-/* #undef _POSIX_1_SOURCE */
diff --git a/gnu/libexec/uucp/common_sources/conn.c b/gnu/libexec/uucp/common_sources/conn.c
deleted file mode 100644
index ddf0e90..0000000
--- a/gnu/libexec/uucp/common_sources/conn.c
+++ /dev/null
@@ -1,587 +0,0 @@
-/* conn.c
- Connection routines for the Taylor UUCP package.
-
- Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char conn_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-
-/* Create a new connection. This relies on system dependent functions
- to set the qcmds and psysdep fields. If qport is NULL, it opens a
- standard input port, in which case ttype is the type of port to
- use. */
-
-boolean
-fconn_init (qport, qconn, ttype)
- struct uuconf_port *qport;
- struct sconnection *qconn;
- enum uuconf_porttype ttype;
-{
- qconn->qport = qport;
- switch (qport == NULL ? ttype : qport->uuconf_ttype)
- {
- case UUCONF_PORTTYPE_STDIN:
- return fsysdep_stdin_init (qconn);
- case UUCONF_PORTTYPE_MODEM:
- return fsysdep_modem_init (qconn);
- case UUCONF_PORTTYPE_DIRECT:
- return fsysdep_direct_init (qconn);
-#if HAVE_TCP
- case UUCONF_PORTTYPE_TCP:
- return fsysdep_tcp_init (qconn);
-#endif
-#if HAVE_TLI
- case UUCONF_PORTTYPE_TLI:
- return fsysdep_tli_init (qconn);
-#endif
- case UUCONF_PORTTYPE_PIPE:
- return fsysdep_pipe_init (qconn);
- default:
- ulog (LOG_ERROR, "Unknown or unsupported port type");
- return FALSE;
- }
-}
-
-/* Connection dispatch routines. */
-
-/* Free a connection. */
-
-void
-uconn_free (qconn)
- struct sconnection *qconn;
-{
- (*qconn->qcmds->pufree) (qconn);
-}
-
-/* Lock a connection. */
-
-boolean
-fconn_lock (qconn, fin)
- struct sconnection *qconn;
- boolean fin;
-{
- boolean (*pflock) P((struct sconnection *, boolean));
-
- pflock = qconn->qcmds->pflock;
- if (pflock == NULL)
- return TRUE;
- return (*pflock) (qconn, fin);
-}
-
-/* Unlock a connection. */
-
-boolean
-fconn_unlock (qconn)
- struct sconnection *qconn;
-{
- boolean (*pfunlock) P((struct sconnection *));
-
- pfunlock = qconn->qcmds->pfunlock;
- if (pfunlock == NULL)
- return TRUE;
- return (*pfunlock) (qconn);
-}
-
-/* Open a connection. */
-
-boolean
-fconn_open (qconn, ibaud, ihighbaud, fwait)
- struct sconnection *qconn;
- long ibaud;
- long ihighbaud;
- boolean fwait;
-{
- boolean fret;
-
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_PORT))
- {
- char abspeed[20];
-
- if (ibaud == (long) 0)
- strcpy (abspeed, "default speed");
- else
- sprintf (abspeed, "speed %ld", ibaud);
-
- if (qconn->qport == NULL)
- ulog (LOG_DEBUG, "fconn_open: Opening stdin port (%s)",
- abspeed);
- else if (qconn->qport->uuconf_zname == NULL)
- ulog (LOG_DEBUG, "fconn_open: Opening unnamed port (%s)",
- abspeed);
- else
- ulog (LOG_DEBUG, "fconn_open: Opening port %s (%s)",
- qconn->qport->uuconf_zname, abspeed);
- }
-#endif
-
- /* If the system provides a range of baud rates, we select the
- highest baud rate supported by the port. */
- if (ihighbaud != 0 && qconn->qport != NULL)
- {
- struct uuconf_port *qport;
-
- qport = qconn->qport;
- ibaud = ihighbaud;
- if (qport->uuconf_ttype == UUCONF_PORTTYPE_MODEM)
- {
- if (qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud != 0)
- {
- if (qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud < ibaud)
- ibaud = qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud;
- }
- else if (qport->uuconf_u.uuconf_smodem.uuconf_ibaud != 0)
- ibaud = qport->uuconf_u.uuconf_smodem.uuconf_ibaud;
- }
- else if (qport->uuconf_ttype == UUCONF_PORTTYPE_DIRECT)
- {
- if (qport->uuconf_u.uuconf_sdirect.uuconf_ibaud != 0)
- ibaud = qport->uuconf_u.uuconf_sdirect.uuconf_ibaud;
- }
- }
-
- /* This will normally be overridden by the port specific open
- routine. */
- if (qconn->qport == NULL)
- ulog_device ("stdin");
- else
- ulog_device (qconn->qport->uuconf_zname);
-
- fret = (*qconn->qcmds->pfopen) (qconn, ibaud, fwait);
-
- if (! fret)
- ulog_device ((const char *) NULL);
-
- return fret;
-}
-
-/* Close a connection. */
-
-boolean
-fconn_close (qconn, puuconf, qdialer, fsuccess)
- struct sconnection *qconn;
- pointer puuconf;
- struct uuconf_dialer *qdialer;
- boolean fsuccess;
-{
- boolean fret;
-
- DEBUG_MESSAGE0 (DEBUG_PORT, "fconn_close: Closing connection");
-
- /* Don't report hangup signals while we're closing. */
- fLog_sighup = FALSE;
-
- fret = (*qconn->qcmds->pfclose) (qconn, puuconf, qdialer, fsuccess);
-
- /* Ignore any SIGHUP we may have gotten, and make sure any signal
- reporting has been done before we reset fLog_sighup. */
- afSignal[INDEXSIG_SIGHUP] = FALSE;
- ulog (LOG_ERROR, (const char *) NULL);
- fLog_sighup = TRUE;
-
- ulog_device ((const char *) NULL);
-
- return fret;
-}
-
-/* Dial out on the connection. */
-
-boolean
-fconn_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialerfound)
- struct sconnection *qconn;
- pointer puuconf;
- const struct uuconf_system *qsys;
- const char *zphone;
- struct uuconf_dialer *qdialer;
- enum tdialerfound *ptdialerfound;
-{
- struct uuconf_dialer sdialer;
- enum tdialerfound tfound;
- boolean (*pfdial) P((struct sconnection *, pointer,
- const struct uuconf_system *, const char *,
- struct uuconf_dialer *, enum tdialerfound *));
-
- if (qdialer == NULL)
- qdialer = &sdialer;
- if (ptdialerfound == NULL)
- ptdialerfound = &tfound;
-
- qdialer->uuconf_zname = NULL;
- *ptdialerfound = DIALERFOUND_FALSE;
-
- pfdial = qconn->qcmds->pfdial;
- if (pfdial == NULL)
- return TRUE;
- return (*pfdial) (qconn, puuconf, qsys, zphone, qdialer, ptdialerfound);
-}
-
-/* Read data from the connection. */
-
-boolean
-fconn_read (qconn, zbuf, pclen, cmin, ctimeout, freport)
- struct sconnection *qconn;
- char *zbuf;
- size_t *pclen;
- size_t cmin;
- int ctimeout;
- boolean freport;
-{
- boolean fret;
-
- fret = (*qconn->qcmds->pfread) (qconn, zbuf, pclen, cmin, ctimeout,
- freport);
-
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_INCOMING))
- udebug_buffer ("fconn_read: Read", zbuf, *pclen);
- else if (FDEBUGGING (DEBUG_PORT))
- ulog (LOG_DEBUG, "fconn_read: Read %lu", (unsigned long) *pclen);
-#endif
-
- return fret;
-}
-
-/* Write data to the connection. */
-
-boolean
-fconn_write (qconn, zbuf, clen)
- struct sconnection *qconn;
- const char *zbuf;
- size_t clen;
-{
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_OUTGOING))
- udebug_buffer ("fconn_write: Writing", zbuf, clen);
- else if (FDEBUGGING (DEBUG_PORT))
- ulog (LOG_DEBUG, "fconn_write: Writing %lu", (unsigned long) clen);
-#endif
-
- return (*qconn->qcmds->pfwrite) (qconn, zbuf, clen);
-}
-
-/* Read and write data. */
-
-boolean
-fconn_io (qconn, zwrite, pcwrite, zread, pcread)
- struct sconnection *qconn;
- const char *zwrite;
- size_t *pcwrite;
- char *zread;
- size_t *pcread;
-{
- boolean fret;
-#if DEBUG > 1
- size_t cwrite = *pcwrite;
- size_t cread = *pcread;
-
- if (cread == 0 || cwrite == 0)
- ulog (LOG_FATAL, "fconn_io: cread %lu; cwrite %lu",
- (unsigned long) cread, (unsigned long) cwrite);
-#endif
-
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_OUTGOING))
- udebug_buffer ("fconn_io: Writing", zwrite, cwrite);
-#endif
-
- fret = (*qconn->qcmds->pfio) (qconn, zwrite, pcwrite, zread, pcread);
-
- DEBUG_MESSAGE4 (DEBUG_PORT,
- "fconn_io: Wrote %lu of %lu, read %lu of %lu",
- (unsigned long) *pcwrite, (unsigned long) cwrite,
- (unsigned long) *pcread, (unsigned long) cread);
-
-#if DEBUG > 1
- if (*pcread > 0 && FDEBUGGING (DEBUG_INCOMING))
- udebug_buffer ("fconn_io: Read", zread, *pcread);
-#endif
-
- return fret;
-}
-
-/* Send a break character to a connection. Some port types may not
- support break characters, in which case we just return TRUE. */
-
-boolean
-fconn_break (qconn)
- struct sconnection *qconn;
-{
- boolean (*pfbreak) P((struct sconnection *));
-
- pfbreak = qconn->qcmds->pfbreak;
- if (pfbreak == NULL)
- return TRUE;
-
- DEBUG_MESSAGE0 (DEBUG_PORT, "fconn_break: Sending break character");
-
- return (*pfbreak) (qconn);
-}
-
-/* Change the setting of a connection. Some port types may not
- support this, in which case we just return TRUE. */
-
-boolean
-fconn_set (qconn, tparity, tstrip, txonxoff)
- struct sconnection *qconn;
- enum tparitysetting tparity;
- enum tstripsetting tstrip;
- enum txonxoffsetting txonxoff;
-{
- boolean (*pfset) P((struct sconnection *, enum tparitysetting,
- enum tstripsetting, enum txonxoffsetting));
-
- pfset = qconn->qcmds->pfset;
- if (pfset == NULL)
- return TRUE;
-
- DEBUG_MESSAGE3 (DEBUG_PORT,
- "fconn_set: Changing setting to %d, %d, %d",
- (int) tparity, (int) tstrip, (int) txonxoff);
-
- return (*pfset) (qconn, tparity, tstrip, txonxoff);
-}
-
-/* Require or ignore carrier on a connection. */
-
-boolean
-fconn_carrier (qconn, fcarrier)
- struct sconnection *qconn;
- boolean fcarrier;
-{
- boolean (*pfcarrier) P((struct sconnection *, boolean));
-
- pfcarrier = qconn->qcmds->pfcarrier;
- if (pfcarrier == NULL)
- return TRUE;
- return (*pfcarrier) (qconn, fcarrier);
-}
-
-/* Run a chat program on a connection. */
-
-boolean
-fconn_run_chat (qconn, pzprog)
- struct sconnection *qconn;
- char **pzprog;
-{
- return (*qconn->qcmds->pfchat) (qconn, pzprog);
-}
-
-/* Get the baud rate of a connection. */
-
-long
-iconn_baud (qconn)
- struct sconnection *qconn;
-{
- long (*pibaud) P((struct sconnection *));
-
- pibaud = qconn->qcmds->pibaud;
- if (pibaud == NULL)
- return 0;
- return (*pibaud) (qconn);
-}
-
-/* Run through a dialer sequence. The pzdialer argument is a list of
- strings, which are considered in dialer/token pairs. The dialer
- string names a dialer to use. The token string is what \D and \T
- in the chat script expand to. If there is no token for the last
- dialer, the zphone argument is used. The qdialer argument is
- filled in with information for the first dialer, and *ptdialerfound
- is set to whether the information should be freed or not. However,
- if *ptdialerfound is not DIALERFOUND_FALSE when this function is
- called, then the information for the first dialer is already in
- qdialer. */
-
-boolean
-fconn_dial_sequence (qconn, puuconf, pzdialer, qsys, zphone, qdialer,
- ptdialerfound)
- struct sconnection *qconn;
- pointer puuconf;
- char **pzdialer;
- const struct uuconf_system *qsys;
- const char *zphone;
- struct uuconf_dialer *qdialer;
- enum tdialerfound *ptdialerfound;
-{
- const char *zname;
- boolean ffirst, ffreefirst;
-
- if (qconn->qport == NULL)
- zname = NULL;
- else
- zname = qconn->qport->uuconf_zname;
- ffirst = TRUE;
- ffreefirst = FALSE;
- while (*pzdialer != NULL)
- {
- struct uuconf_dialer *q;
- struct uuconf_dialer s;
- const char *ztoken;
- boolean ftranslate;
-
- if (! ffirst)
- q = &s;
- else
- q = qdialer;
-
- if (! ffirst || *ptdialerfound == DIALERFOUND_FALSE)
- {
- int iuuconf;
-
- iuuconf = uuconf_dialer_info (puuconf, *pzdialer, q);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- ulog (LOG_ERROR, "%s: Dialer not found", *pzdialer);
- if (ffreefirst)
- (void) uuconf_dialer_free (puuconf, qdialer);
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- if (ffreefirst)
- (void) uuconf_dialer_free (puuconf, qdialer);
- return FALSE;
- }
-
- if (ffirst)
- {
- *ptdialerfound = DIALERFOUND_FREE;
- ffreefirst = TRUE;
- }
- }
-
- ++pzdialer;
- ztoken = *pzdialer;
-
- ftranslate = FALSE;
- if (ztoken == NULL
- || strcmp (ztoken, "\\D") == 0)
- ztoken = zphone;
- else if (strcmp (ztoken, "\\T") == 0)
- {
- ztoken = zphone;
- ftranslate = TRUE;
- }
-
- if (! fchat (qconn, puuconf, &q->uuconf_schat, qsys, q, ztoken,
- ftranslate, zname, iconn_baud (qconn)))
- {
- if (q == &s)
- (void) uuconf_dialer_free (puuconf, q);
- if (ffreefirst)
- (void) uuconf_dialer_free (puuconf, qdialer);
- return FALSE;
- }
-
- if (ffirst)
- ffirst = FALSE;
- else
- (void) uuconf_dialer_free (puuconf, q);
-
- if (*pzdialer != NULL)
- ++pzdialer;
- }
-
- return TRUE;
-}
-
-/* Modem dialing routine. */
-
-/*ARGSUSED*/
-boolean
-fmodem_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialerfound)
- struct sconnection *qconn;
- pointer puuconf;
- const struct uuconf_system *qsys;
- const char *zphone;
- struct uuconf_dialer *qdialer;
- enum tdialerfound *ptdialerfound;
-{
- char **pzdialer;
-
- *ptdialerfound = DIALERFOUND_FALSE;
-
- pzdialer = qconn->qport->uuconf_u.uuconf_smodem.uuconf_pzdialer;
- if (pzdialer != NULL && *pzdialer != NULL)
- {
- int iuuconf;
- boolean fret;
-
- iuuconf = uuconf_dialer_info (puuconf, *pzdialer, qdialer);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- ulog (LOG_ERROR, "%s: Dialer not found", *pzdialer);
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
-
- *ptdialerfound = DIALERFOUND_FREE;
-
- fret = (fsysdep_modem_begin_dial (qconn, qdialer)
- && fconn_dial_sequence (qconn, puuconf, pzdialer, qsys, zphone,
- qdialer, ptdialerfound)
- && fsysdep_modem_end_dial (qconn, qdialer));
-
- if (! fret)
- (void) uuconf_dialer_free (puuconf, qdialer);
-
- return fret;
- }
- else if (qconn->qport->uuconf_u.uuconf_smodem.uuconf_qdialer != NULL)
- {
- struct uuconf_dialer *q;
- const char *zname;
-
- q = qconn->qport->uuconf_u.uuconf_smodem.uuconf_qdialer;
- *qdialer = *q;
- *ptdialerfound = DIALERFOUND_TRUE;
-
- if (qconn->qport == NULL)
- zname = NULL;
- else
- zname = qconn->qport->uuconf_zname;
-
- return (fsysdep_modem_begin_dial (qconn, q)
- && fchat (qconn, puuconf, &q->uuconf_schat, qsys, q,
- zphone, FALSE, zname, iconn_baud (qconn))
- && fsysdep_modem_end_dial (qconn, q));
- }
- else
- {
- ulog (LOG_ERROR, "No dialer information");
- return FALSE;
- }
-}
diff --git a/gnu/libexec/uucp/common_sources/conn.h b/gnu/libexec/uucp/common_sources/conn.h
deleted file mode 100644
index 09235ea..0000000
--- a/gnu/libexec/uucp/common_sources/conn.h
+++ /dev/null
@@ -1,319 +0,0 @@
-/* conn.h
- Header file for routines which manipulate connections.
-
- Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#ifndef CONN_H
-
-#define CONN_H
-
-#if ANSI_C
-/* These structures are used in prototypes but are not defined in this
- header file. */
-struct uuconf_system;
-struct uuconf_dialer;
-struct uuconf_chat;
-#endif
-
-/* This structure represents a connection. */
-
-struct sconnection
-{
- /* Pointer to command table for this type of connection. */
- const struct sconncmds *qcmds;
- /* Pointer to system dependent information. */
- pointer psysdep;
- /* Pointer to system independent information. */
- struct uuconf_port *qport;
-};
-
-/* Whether fconn_dial got a dialer. */
-
-enum tdialerfound
-{
- /* Did not find a dialer. */
- DIALERFOUND_FALSE,
- /* Found a dialer which does not need to be freed. */
- DIALERFOUND_TRUE,
- /* Found a dialer which does need to be freed. */
- DIALERFOUND_FREE
-};
-
-/* Parity settings to pass to fconn_set. */
-
-enum tparitysetting
-{
- /* Do not change output parity generation. */
- PARITYSETTING_DEFAULT,
- /* No parity (all eight output bits used). */
- PARITYSETTING_NONE,
- /* Even parity. */
- PARITYSETTING_EVEN,
- /* Odd parity. */
- PARITYSETTING_ODD,
- /* Mark parity. */
- PARITYSETTING_MARK,
- /* Space parity. */
- PARITYSETTING_SPACE
-};
-
-/* Type of strip control argument to fconn_set. */
-
-enum tstripsetting
-{
- /* Do not change the stripping of input characters. */
- STRIPSETTING_DEFAULT,
- /* Do not strip input characters to seven bits. */
- STRIPSETTING_EIGHTBITS,
- /* Strip input characters to seven bits. */
- STRIPSETTING_SEVENBITS
-};
-
-/* Type of XON/XOFF control argument to fconn_set. */
-
-enum txonxoffsetting
-{
- /* Do not change XON/XOFF handshake setting. */
- XONXOFF_DEFAULT,
- /* Do not do XON/XOFF handshaking. */
- XONXOFF_OFF,
- /* Do XON/XOFF handshaking. */
- XONXOFF_ON
-};
-
-/* A command table holds the functions which implement actions for
- each different kind of connection. */
-
-struct sconncmds
-{
- /* Free up a connection. */
- void (*pufree) P((struct sconnection *qconn));
- /* Lock the connection. The fin argument is TRUE if the connection
- is to be used for an incoming call. May be NULL. */
- boolean (*pflock) P((struct sconnection *qconn, boolean fin));
- /* Unlock the connection. May be NULL. */
- boolean (*pfunlock) P((struct sconnection *qconn));
- /* Open the connection. */
- boolean (*pfopen) P((struct sconnection *qconn, long ibaud,
- boolean fwait));
- /* Close the connection. */
- boolean (*pfclose) P((struct sconnection *qconn,
- pointer puuconf,
- struct uuconf_dialer *qdialer,
- boolean fsuccess));
- /* Dial a number on a connection. This set *qdialer to the dialer
- used, if any, and sets *ptdialerfound appropriately. The qsys
- and zphone arguments are for the chat script. This field may be
- NULL. */
- boolean (*pfdial) P((struct sconnection *qconn, pointer puuconf,
- const struct uuconf_system *qsys,
- const char *zphone,
- struct uuconf_dialer *qdialer,
- enum tdialerfound *ptdialerfound));
- /* Read data from a connection, with a timeout in seconds. When
- called *pclen is the length of the buffer; on successful return
- *pclen is the number of bytes read into the buffer. The cmin
- argument is the minimum number of bytes to read before returning
- ahead of a timeout. */
- boolean (*pfread) P((struct sconnection *qconn, char *zbuf, size_t *pclen,
- size_t cmin, int ctimeout, boolean freport));
- /* Write data to the connection. */
- boolean (*pfwrite) P((struct sconnection *qconn, const char *zbuf,
- size_t clen));
- /* Read and write data to the connection. This reads and writes
- data until either all passed in data has been written or the read
- buffer has been filled. When called *pcread is the size of the
- read buffer and *pcwrite is the number of bytes to write; on
- successful return *pcread is the number of bytes read and
- *pcwrite is the number of bytes written. */
- boolean (*pfio) P((struct sconnection *qconn, const char *zwrite,
- size_t *pcwrite, char *zread, size_t *pcread));
- /* Send a break character. This field may be NULL. */
- boolean (*pfbreak) P((struct sconnection *qconn));
- /* Change the connection setting. This field may be NULL. */
- boolean (*pfset) P((struct sconnection *qconn,
- enum tparitysetting tparity,
- enum tstripsetting tstrip,
- enum txonxoffsetting txonxoff));
- /* Require or ignore carrer. This field may be NULL. */
- boolean (*pfcarrier) P((struct sconnection *qconn,
- boolean fcarrier));
- /* Run a chat program on a connection. */
- boolean (*pfchat) P((struct sconnection *qconn, char **pzprog));
- /* Get the baud rate of a connection. This field may be NULL. */
- long (*pibaud) P((struct sconnection *qconn));
-};
-
-/* Connection functions. */
-
-/* Initialize a connection. This must be called before any of the
- other connection functions are called. It initializes the fields
- of qconn. If qport is NULL, this opens standard input as a port
- using type ttype. This function returns FALSE on error. */
-extern boolean fconn_init P((struct uuconf_port *qport,
- struct sconnection *qconn,
- enum uuconf_porttype ttype));
-
-/* Free up connection data. */
-extern void uconn_free P((struct sconnection *qconn));
-
-/* Lock a connection. The fin argument is TRUE if the port is to be
- used for an incoming call; certains type of Unix locking need this
- information because they need to open the port. */
-extern boolean fconn_lock P((struct sconnection *qconn, boolean fin));
-
-/* Unlock a connection. */
-extern boolean fconn_unlock P((struct sconnection *qconn));
-
-/* Open a connection. If ibaud is 0, the natural baud rate of the
- port is used. If ihighbaud is not 0, fconn_open chooses the
- highest supported baud rate between ibaud and ihighbaud. If fwait
- is TRUE, this should wait for an incoming call. */
-extern boolean fconn_open P((struct sconnection *qconn, long ibaud,
- long ihighbaud, boolean fwait));
-
-/* Close a connection. The fsuccess argument is TRUE if the
- conversation completed normally, FALSE if it is being aborted. */
-extern boolean fconn_close P((struct sconnection *qconn,
- pointer puuconf,
- struct uuconf_dialer *qdialer,
- boolean fsuccess));
-
-/* Dial out on a connection. The qsys and zphone arguments are for
- the chat scripts; zphone is the phone number to dial. If qdialer
- is not NULL, *qdialer will be set to the dialer information used if
- any; *ptdialerfound will be set appropriately. */
-extern boolean fconn_dial P((struct sconnection *q, pointer puuconf,
- const struct uuconf_system *qsys,
- const char *zphone,
- struct uuconf_dialer *qdialer,
- enum tdialerfound *ptdialerfound));
-
-/* Read from a connection.
- zbuf -- buffer to read bytes into
- *pclen on call -- length of zbuf
- *pclen on successful return -- number of bytes read
- cmin -- minimum number of bytes to read before returning ahead of timeout
- ctimeout -- timeout in seconds, 0 if none
- freport -- whether to report errors. */
-extern boolean fconn_read P((struct sconnection *qconn, char *zbuf,
- size_t *pclen, size_t cmin,
- int ctimeout, boolean freport));
-
-/* Write to a connection. */
-extern boolean fconn_write P((struct sconnection *qconn, const char *zbuf,
- size_t cbytes));
-
-/* Read and write to a connection. This reads and writes data until
- either all passed-in data has been written or the read buffer is
- full.
- zwrite -- buffer to write bytes from
- *pcwrite on call -- number of bytes to write
- *pcwrite on successful return -- number of bytes written
- zread -- buffer to read bytes into
- *pcread on call -- size of read buffer
- *pcread on successful return -- number of bytes read. */
-extern boolean fconn_io P((struct sconnection *qconn, const char *zwrite,
- size_t *pcwrite, char *zread, size_t *pcread));
-
-/* Send a break character to a connection. */
-extern boolean fconn_break P((struct sconnection *qconn));
-
-/* Change the settings of a connection. This allows independent
- control over the parity of output characters, whether to strip
- input characters, and whether to do XON/XOFF handshaking. There is
- no explicit control over parity checking of input characters. This
- function returns FALSE on error. Attempts to set values not
- supported by the hardware are silently ignored. */
-extern boolean fconn_set P((struct sconnection *qconn,
- enum tparitysetting tparity,
- enum tstripsetting tstrip,
- enum txonxoffsetting txonxoff));
-
-/* Get the baud rate of a connection. */
-extern long iconn_baud P((struct sconnection *qconn));
-
-/* Do a chat script with a system. */
-extern boolean fchat P((struct sconnection *qconn, pointer puuconf,
- const struct uuconf_chat *qchat,
- const struct uuconf_system *qsys,
- const struct uuconf_dialer *qdialer,
- const char *zphone, boolean ftranslate,
- const char *zport, long ibaud));
-
-/* Tell the connection to either require or ignore carrier as fcarrier
- is TRUE or FALSE respectively. This is called with fcarrier TRUE
- when \m is encountered in a chat script, and with fcarrier FALSE
- when \M is encountered. */
-extern boolean fconn_carrier P((struct sconnection *qconn,
- boolean fcarrier));
-
-/* Run a chat program on a connection. */
-extern boolean fconn_run_chat P((struct sconnection *qconn,
- char **pzprog));
-
-/* Run through a dialer sequence. This is a support routine for the
- port type specific dialing routines. */
-extern boolean fconn_dial_sequence P((struct sconnection *qconn,
- pointer puuconf, char **pzdialer,
- const struct uuconf_system *qsys,
- const char *zphone,
- struct uuconf_dialer *qdialer,
- enum tdialerfound *ptdialerfound));
-
-/* Dialing out on a modem is partially system independent. This is
- the modem dialing routine. */
-extern boolean fmodem_dial P((struct sconnection *qconn, pointer puuconf,
- const struct uuconf_system *qsys,
- const char *zphone,
- struct uuconf_dialer *qdialer,
- enum tdialerfound *ptdialerfound));
-
-/* Begin dialing out. This should open the dialer device if there is
- one, toggle DTR if requested and possible, and tell the port to
- ignore carrier. It should return FALSE on error. */
-extern boolean fsysdep_modem_begin_dial P((struct sconnection *qconn,
- struct uuconf_dialer *qdial));
-
-/* Finish dialing out on a modem. This should close the dialer device
- if there is one. If the dialer and the port both support carrier,
- the connection should be told to pay attention to carrier. If it
- is possible to wait for carrier to come on, and the dialer and the
- port both the port support carrier, it should wait until carrier
- comes on. */
-extern boolean fsysdep_modem_end_dial P((struct sconnection *qconn,
- struct uuconf_dialer *qdial));
-
-/* System dependent initialization routines. */
-extern boolean fsysdep_stdin_init P((struct sconnection *qconn));
-extern boolean fsysdep_modem_init P((struct sconnection *qconn));
-extern boolean fsysdep_direct_init P((struct sconnection *qconn));
-#if HAVE_TCP
-extern boolean fsysdep_tcp_init P((struct sconnection *qconn));
-#endif
-#if HAVE_TLI
-extern boolean fsysdep_tli_init P((struct sconnection *qconn));
-#endif
-extern boolean fsysdep_pipe_init P((struct sconnection *qconn));
-
-#endif /* ! defined (CONN_H) */
diff --git a/gnu/libexec/uucp/common_sources/copy.c b/gnu/libexec/uucp/common_sources/copy.c
deleted file mode 100644
index 6beddc7..0000000
--- a/gnu/libexec/uucp/common_sources/copy.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/* copy.c
- Copy one file to another for the UUCP package.
-
- Copyright (C) 1991, 1992, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char copy_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "system.h"
-#include "sysdep.h"
-
-#include <stdio.h>
-#include <errno.h>
-
-/* Copy one file to another. */
-
-#if USE_STDIO
-
-boolean
-fcopy_file (zfrom, zto, fpublic, fmkdirs, fsignals)
- const char *zfrom;
- const char *zto;
- boolean fpublic;
- boolean fmkdirs;
- boolean fsignals;
-{
- FILE *efrom;
- boolean fret;
-
- efrom = fopen (zfrom, BINREAD);
- if (efrom == NULL)
- {
- ulog (LOG_ERROR, "fopen (%s): %s", zfrom, strerror (errno));
- return FALSE;
- }
-
- fret = fcopy_open_file (efrom, zto, fpublic, fmkdirs, fsignals);
- (void) fclose (efrom);
- return fret;
-}
-
-boolean
-fcopy_open_file (efrom, zto, fpublic, fmkdirs, fsignals)
- FILE *efrom;
- const char *zto;
- boolean fpublic;
- boolean fmkdirs;
- boolean fsignals;
-{
- FILE *eto;
- char ab[8192];
- int c;
-
- eto = esysdep_fopen (zto, fpublic, FALSE, fmkdirs);
- if (eto == NULL)
- return FALSE;
-
- while ((c = fread (ab, sizeof (char), sizeof ab, efrom)) != 0)
- {
- if (fwrite (ab, sizeof (char), (size_t) c, eto) != c)
- {
- ulog (LOG_ERROR, "fwrite: %s", strerror (errno));
- (void) fclose (eto);
- (void) remove (zto);
- return FALSE;
- }
- if (fsignals && FGOT_SIGNAL ())
- {
- /* Log the signal. */
- ulog (LOG_ERROR, (const char *) NULL);
- (void) fclose (eto);
- (void) remove (zto);
- return FALSE;
- }
- }
-
- if (! fsysdep_sync (eto, zto))
- {
- (void) fclose (eto);
- (void) remove (zto);
- return FALSE;
- }
-
- if (fclose (eto) != 0)
- {
- ulog (LOG_ERROR, "fclose: %s", strerror (errno));
- (void) remove (zto);
- return FALSE;
- }
-
- return TRUE;
-}
-
-#else /* ! USE_STDIO */
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-
-boolean
-fcopy_file (zfrom, zto, fpublic, fmkdirs, fsignals)
- const char *zfrom;
- const char *zto;
- boolean fpublic;
- boolean fmkdirs;
- boolean fsignals;
-{
- int ofrom;
- boolean fret;
-
- ofrom = open (zfrom, O_RDONLY | O_NOCTTY, 0);
- if (ofrom < 0)
- {
- ulog (LOG_ERROR, "open (%s): %s", zfrom, strerror (errno));
- return FALSE;
- }
-
- fret = fcopy_open_file (ofrom, zto, fpublic, fmkdirs, fsignals);
- (void) close (ofrom);
- return fret;
-}
-
-boolean
-fcopy_open_file (ofrom, zto, fpublic, fmkdirs, fsignals)
- int ofrom;
- const char *zto;
- boolean fpublic;
- boolean fmkdirs;
- boolean fsignals;
-{
- int oto;
- char ab[8192];
- int c;
-
- /* These file mode arguments are from the UNIX version of sysdep.h;
- each system dependent header file will need their own
- definitions. */
- oto = creat (zto, fpublic ? IPUBLIC_FILE_MODE : IPRIVATE_FILE_MODE);
- if (oto < 0)
- {
- if (errno == ENOENT && fmkdirs)
- {
- if (! fsysdep_make_dirs (zto, fpublic))
- return FALSE;
- oto = creat (zto,
- fpublic ? IPUBLIC_FILE_MODE : IPRIVATE_FILE_MODE);
- }
- if (oto < 0)
- {
- ulog (LOG_ERROR, "open (%s): %s", zto, strerror (errno));
- return FALSE;
- }
- }
-
- while ((c = read (ofrom, ab, sizeof ab)) > 0)
- {
- if (write (oto, ab, (size_t) c) != c)
- {
- ulog (LOG_ERROR, "write: %s", strerror (errno));
- (void) close (oto);
- (void) remove (zto);
- return FALSE;
- }
- if (fsignals && FGOT_SIGNAL ())
- {
- /* Log the signal. */
- ulog (LOG_ERROR, (const char *) NULL);
- (void) fclose (eto);
- (void) remove (zto);
- return FALSE;
- }
- }
-
- if (! fsysdep_sync (oto, zto))
- {
- (void) close (oto);
- (void) remove (zto);
- return FALSE;
- }
-
- if (close (oto) < 0)
- {
- ulog (LOG_ERROR, "close: %s", strerror (errno));
- (void) remove (zto);
- return FALSE;
- }
-
- if (c < 0)
- {
- ulog (LOG_ERROR, "read: %s", strerror (errno));
- (void) remove (zto);
- return FALSE;
- }
-
- return TRUE;
-}
-
-#endif /* ! USE_STDIO */
diff --git a/gnu/libexec/uucp/common_sources/cu.h b/gnu/libexec/uucp/common_sources/cu.h
deleted file mode 100644
index 8c22670..0000000
--- a/gnu/libexec/uucp/common_sources/cu.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* cu.h
- Header file for cu.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-/* The user settable variables supported by cu. */
-
-/* The escape character used to introduce a special command. The
- escape character is the first character of this string. */
-extern const char *zCuvar_escape;
-
-/* Whether to delay for a second before printing the host name after
- seeing an escape character. */
-extern boolean fCuvar_delay;
-
-/* The input characters which finish a line. The escape character is
- only recognized following one of these characters. */
-extern const char *zCuvar_eol;
-
-/* Whether to transfer binary data (nonprintable characters other than
- newline and tab) when sending a file. If this is FALSE, then
- newline is changed to carriage return. */
-extern boolean fCuvar_binary;
-
-/* A prefix string to use before sending a binary character from a
- file; this is only used if fCuvar_binary is TRUE. */
-extern const char *zCuvar_binary_prefix;
-
-/* Whether to check for echoes of characters sent when sending a file.
- This is ignored if fCuvar_binary is TRUE. */
-extern boolean fCuvar_echocheck;
-
-/* A character to look for after each newline is sent when sending a
- file. The character is the first character in this string, except
- that a '\0' means that no echo check is done. */
-extern const char *zCuvar_echonl;
-
-/* The timeout to use when looking for an character. */
-extern int cCuvar_timeout;
-
-/* The character to use to kill a line if an echo check fails. The
- first character in this string is sent. */
-extern const char *zCuvar_kill;
-
-/* The number of times to try resending a line if the echo check keeps
- failing. */
-extern int cCuvar_resend;
-
-/* The string to send at the end of a file sent with ~>. */
-extern const char *zCuvar_eofwrite;
-
-/* The string to look for to finish a file received with ~<. For tip
- this is a collection of single characters, but I don't want to do
- that because it means that there are characters which cannot be
- received. */
-extern const char *zCuvar_eofread;
-
-/* Whether to provide verbose information when sending or receiving a
- file. */
-extern boolean fCuvar_verbose;
diff --git a/gnu/libexec/uucp/common_sources/getopt.h b/gnu/libexec/uucp/common_sources/getopt.h
deleted file mode 100644
index 61e2954..0000000
--- a/gnu/libexec/uucp/common_sources/getopt.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Declarations for getopt.
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- This file was modified slightly by Ian Lance Taylor, November 1992,
- for Taylor UUCP, and again in June, 1995. */
-
-#ifndef _GETOPT_H
-#define _GETOPT_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Ian Lance Taylor <ian@airs.com> added the following defines for
- Taylor UUCP. This avoids reported conflicts with system getopt
- definitions. */
-#define getopt gnu_getopt
-#define optarg gnu_optarg
-#define optind gnu_optind
-#define opterr gnu_opterr
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
-extern int opterr;
-
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
-struct option
-{
- const char *name;
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'. */
-
-enum _argtype
-{
- no_argument,
- required_argument,
- optional_argument
-};
-
-#ifndef P
-/* On some systems, <stdio.h> includes getopt.h before P is defined by
- uucp.h, and the -I arguments cause this version of getopt.h to be
- included. Work around that here. */
-#define P(x) ()
-#define UNDEFINE_P
-#endif
-
-extern int getopt P((int argc, char *const *argv, const char *shortopts));
-extern int getopt_long P((int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind));
-extern int getopt_long_only P((int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind));
-
-/* Internal only. Users should not call this directly. */
-extern int _getopt_internal P((int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only));
-
-#ifdef UNDEFINE_P
-#undef P
-#undef UNDEFINE_P
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GETOPT_H */
diff --git a/gnu/libexec/uucp/common_sources/log.c b/gnu/libexec/uucp/common_sources/log.c
deleted file mode 100644
index 47f912a..0000000
--- a/gnu/libexec/uucp/common_sources/log.c
+++ /dev/null
@@ -1,775 +0,0 @@
-/* log.c
- Routines to add entries to the log files.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char log_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-#if HAVE_STDARG_H
-#include <stdarg.h>
-#endif
-
-#if TM_IN_SYS_TIME
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-
-/* Local functions. */
-
-__inline__ static char *zstpcpy P((char *zto, const char *zfrom));
-static const char *zldate_and_time P((void));
-
-/* Program name. Set by main function. */
-const char *zProgram;
-
-/* Log file name. */
-static const char *zLogfile;
-
-/* The function to call when a LOG_FATAL error occurs. */
-static void (*pfLfatal) P((void));
-
-/* Whether to go to a file. */
-static boolean fLfile;
-
-/* ID number. */
-static int iLid;
-
-/* The current user name. */
-static char *zLuser;
-
-/* The current system name. */
-static char *zLsystem;
-
-/* The current device name. */
-char *zLdevice;
-
-/* The open log file. */
-static FILE *eLlog;
-
-/* Whether we have tried to open the log file. We need this because
- we don't want to keep trying to open the log file if we failed the
- first time. It can't be static because under HAVE_HDB_LOGGING we
- may have to write to various different log files. */
-static boolean fLlog_tried;
-
-#if DEBUG > 1
-/* Debugging file name. */
-static const char *zLdebugfile;
-
-/* The open debugging file. */
-static FILE *eLdebug;
-
-/* Whether we've tried to open the debugging file. */
-static boolean fLdebug_tried;
-#endif
-
-/* Statistics file name. */
-static const char *zLstatsfile;
-
-/* The open statistics file. */
-static FILE *eLstats;
-
-/* Whether we've tried to open the statistics file. */
-static boolean fLstats_tried;
-
-/* The array of signals. The elements are only set to TRUE by the
- default signal handler. They are only set to FALSE if we don't
- care whether we got the signal or not. */
-volatile sig_atomic_t afSignal[INDEXSIG_COUNT];
-
-/* The array of signals to log. The elements are only set to TRUE by
- the default signal handler. They are set to FALSE when the signal
- is logged in ulog. This means that if a signal comes in at just
- the right time we won't log it (or, rather, we'll log it once
- instead of twice), but that is not a catatrophe. */
-volatile sig_atomic_t afLog_signal[INDEXSIG_COUNT];
-
-/* Flag that indicates SIGHUP is worth logging. */
-boolean fLog_sighup = TRUE;
-
-/* Signal names to use when logging signals. */
-static const char * const azSignal_names[INDEXSIG_COUNT] = INDEXSIG_NAMES;
-
-/* If not NULL, ulog calls this function before outputting anything.
- This is used to support cu. */
-void (*pfLstart) P((void));
-
-/* If not NULL, ulog calls this function after outputting everything.
- This is used to support cu. */
-void (*pfLend) P((void));
-
-/* Set the function to call on a LOG_FATAL error. */
-
-void
-ulog_fatal_fn (pfn)
- void (*pfn) P((void));
-{
- pfLfatal = pfn;
-}
-
-/* Decide whether to send log message to the file or not. */
-
-void
-ulog_to_file (puuconf, ffile)
- pointer puuconf;
- boolean ffile;
-{
- int iuuconf;
-
- iuuconf = uuconf_logfile (puuconf, &zLogfile);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
-#if DEBUG > 1
- iuuconf = uuconf_debugfile (puuconf, &zLdebugfile);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-#endif
-
- iuuconf = uuconf_statsfile (puuconf, &zLstatsfile);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- fLfile = ffile;
-}
-
-/* Set the ID number. This will be called by the usysdep_initialize
- if there is something sensible to set it to. */
-
-void
-ulog_id (i)
- int i;
-{
- iLid = i;
-}
-
-/* Set the user we are making log entries for. The arguments will be
- copied into memory. */
-
-void
-ulog_user (zuser)
- const char *zuser;
-{
- ubuffree (zLuser);
- zLuser = zbufcpy (zuser);
-}
-
-/* Set the system name we are making log entries for. The name is copied
- into memory. */
-
-void
-ulog_system (zsystem)
- const char *zsystem;
-{
- if (zsystem == NULL
- || zLsystem == NULL
- || strcmp (zsystem, zLsystem) != 0)
- {
- ubuffree (zLsystem);
- zLsystem = zbufcpy (zsystem);
-#if HAVE_HDB_LOGGING
- /* Under HDB logging we now must write to a different log file. */
- ulog_close ();
-#endif /* HAVE_HDB_LOGGING */
- }
-}
-
-/* Set the device name. This is copied into memory. */
-
-void
-ulog_device (zdevice)
- const char *zdevice;
-{
- ubuffree (zLdevice);
- zLdevice = zbufcpy (zdevice);
-}
-
-/* A helper function for ulog. */
-
-__inline__ static char *
-zstpcpy (zto, zfrom)
- char *zto;
- const char *zfrom;
-{
- while ((*zto++ = *zfrom++) != '\0')
- ;
- return zto - 1;
-}
-
-/* Make a log entry. We make a token concession to non ANSI_C systems,
- but it clearly won't always work. */
-
-#if ! HAVE_PROTOTYPES || ! HAVE_STDARG_H
-#undef HAVE_VFPRINTF
-#define HAVE_VFPRINTF 0
-#endif
-
-/*VARARGS2*/
-#if HAVE_VFPRINTF
-void
-ulog (enum tlog ttype, const char *zmsg, ...)
-#else
-void
-ulog (ttype, zmsg, a, b, c, d, f, g, h, i, j)
- enum tlog ttype;
- const char *zmsg;
-#endif
-{
-#if HAVE_VFPRINTF
- va_list parg;
-#endif
- FILE *e, *edebug;
- boolean fstart, fend;
- const char *zhdr;
- char *zprefix;
- register char *zset;
- char *zformat;
- char *zfrom;
-
- /* Log any received signal. We do it this way to avoid calling ulog
- from the signal handler. A few routines call ulog to get this
- message out with zmsg == NULL. */
- {
- static boolean fdoing_sigs;
-
- if (! fdoing_sigs)
- {
- int isig;
-
- fdoing_sigs = TRUE;
- for (isig = 0; isig < INDEXSIG_COUNT; isig++)
- {
- if (afLog_signal[isig])
- {
- afLog_signal[isig] = FALSE;
-
- /* Apparently SunOS sends SIGINT rather than SIGHUP
- when hanging up, so we don't log either signal if
- fLog_sighup is FALSE. */
- if ((isig != INDEXSIG_SIGHUP && isig != INDEXSIG_SIGINT)
- || fLog_sighup)
- ulog (LOG_ERROR, "Got %s signal", azSignal_names[isig]);
- }
- }
- fdoing_sigs = FALSE;
- }
- }
-
-#if DEBUG > 1
- /* If we've had a debugging file open in the past, then we want to
- write all log file entries to the debugging file even if it's
- currently closed. */
- if (fLfile
- && eLdebug == NULL
- && ! fLdebug_tried
- && iDebug != 0)
- {
- fLdebug_tried = TRUE;
- eLdebug = esysdep_fopen (zLdebugfile, FALSE, TRUE, TRUE);
- }
-#endif /* DEBUG > 1 */
-
- if (! fLfile)
- e = stderr;
-#if DEBUG > 1
- else if ((int) ttype >= (int) LOG_DEBUG)
- {
- e = eLdebug;
-
- /* If we can't open the debugging file, don't output any
- debugging messages. */
- if (e == NULL)
- return;
- }
-#endif /* DEBUG > 1 */
- else
- {
- if (eLlog == NULL && ! fLlog_tried)
- {
- const char *zprint = NULL;
-
- fLlog_tried = TRUE;
-#if ! HAVE_HDB_LOGGING
- eLlog = esysdep_fopen (zLogfile, TRUE, TRUE, TRUE);
- zprint = zLogfile;
-#else /* HAVE_HDB_LOGGING */
- {
- const char *zsys;
- char *zbase;
- char *zlower;
- char *zfile;
-
- /* We want to write to .Log/program/system, e.g.
- .Log/uucico/uunet. The system name may not be set. */
- if (zLsystem == NULL)
- zsys = "ANY";
- else
- zsys = zLsystem;
-
- zbase = zsysdep_base_name (zProgram);
- if (zbase == NULL)
- zbase = zbufcpy (zProgram);
-
- /* On some systems the native uusched will invoke uucico
- with an upper case argv[0]. We work around that by
- forcing the filename to lower case here. */
- for (zlower = zbase; *zlower != '\0'; zlower++)
- if (isupper (*zlower))
- *zlower = tolower (*zlower);
-
- zfile = zbufalc (strlen (zLogfile)
- + strlen (zbase)
- + strlen (zsys)
- + 1);
- sprintf (zfile, zLogfile, zbase, zsys);
- ubuffree (zbase);
- eLlog = esysdep_fopen (zfile, TRUE, TRUE, TRUE);
- if (eLlog != NULL)
- ubuffree (zfile);
- else
- zprint = zfile;
- }
-#endif /* HAVE_HDB_LOGGING */
-
- if (eLlog == NULL)
- {
- /* We can't open the log file. We report the problem to
- stderr. This is not ideal, since if this is uucico
- running on an inbound call stderr is actually
- connected to a remote system, but is better than
- doing nothing. */
- fprintf (stderr, "%s: %s: can not open log file: %s\n",
- zProgram, zprint, strerror (errno));
- if (pfLfatal != NULL)
- (*pfLfatal) ();
- usysdep_exit (FALSE);
- }
- }
-
- e = eLlog;
-
- /* eLlog might be NULL here because we might try to open the log
- file recursively via esysdep_fopen. */
- if (e == NULL)
- return;
- }
-
- if (zmsg == NULL)
- return;
-
- if (pfLstart != NULL)
- (*pfLstart) ();
-
- edebug = NULL;
-#if DEBUG > 1
- if ((int) ttype < (int) LOG_DEBUG)
- edebug = eLdebug;
-#endif
-
- fstart = TRUE;
- fend = TRUE;
-
- switch (ttype)
- {
- case LOG_NORMAL:
- zhdr = "";
- break;
- case LOG_ERROR:
- zhdr = "ERROR: ";
- break;
- case LOG_FATAL:
- zhdr = "FATAL: ";
- break;
-#if DEBUG > 1
- case LOG_DEBUG:
- zhdr = "DEBUG: ";
- break;
- case LOG_DEBUG_START:
- zhdr = "DEBUG: ";
- fend = FALSE;
- break;
- case LOG_DEBUG_CONTINUE:
- zhdr = NULL;
- fstart = FALSE;
- fend = FALSE;
- break;
- case LOG_DEBUG_END:
- zhdr = NULL;
- fstart = FALSE;
- break;
-#endif
- default:
- zhdr = "???: ";
- break;
- }
-
- if (! fstart)
- zprefix = zbufcpy ("");
- else
- {
- if (! fLfile)
- {
- zprefix = zbufalc (strlen (zProgram) + 3);
- sprintf (zprefix, "%s: ", zProgram);
- }
- else
- {
- zprefix = zbufalc (strlen (zProgram)
- + (zLsystem == NULL ? 1 : strlen (zLsystem))
- + (zLuser == NULL ? 4 : strlen (zLuser))
- + sizeof "1991-12-31 12:00:00.00"
- + strlen (zhdr)
- + 100);
- zset = zprefix;
-#if HAVE_TAYLOR_LOGGING
- {
- char *zbase;
-
- zbase = zsysdep_base_name (zProgram);
- if (zbase == NULL)
- zbase = zbufcpy (zProgram);
- zset = zstpcpy (zset, zbase);
- *zset++ = ' ';
- ubuffree (zbase);
- }
-#else /* ! HAVE_TAYLOR_LOGGING */
- zset = zstpcpy (zset, zLuser == NULL ? "uucp" : zLuser);
- *zset++ = ' ';
-#endif /* HAVE_TAYLOR_LOGGING */
-
- zset = zstpcpy (zset, zLsystem == NULL ? "-" : zLsystem);
- *zset++ = ' ';
-
-#if HAVE_TAYLOR_LOGGING
- zset = zstpcpy (zset, zLuser == NULL ? "-" : zLuser);
- *zset++ = ' ';
-#endif /* HAVE_TAYLOR_LOGGING */
-
- *zset++ = '(';
- zset = zstpcpy (zset, zldate_and_time ());
-
- if (iLid != 0)
- {
-#if ! HAVE_HDB_LOGGING
-#if HAVE_TAYLOR_LOGGING
- sprintf (zset, " %d", iLid);
-#else /* ! HAVE_TAYLOR_LOGGING */
- sprintf (zset, "-%d", iLid);
-#endif /* ! HAVE_TAYLOR_LOGGING */
-#else /* HAVE_HDB_LOGGING */
- /* I assume that the second number here is meant to be
- some sort of file sequence number, and that it should
- correspond to the sequence number in the statistics
- file. I don't have any really convenient way to do
- this, so I won't unless somebody thinks it's very
- important. */
- sprintf (zset, ",%d,%d", iLid, 0);
-#endif /* HAVE_HDB_LOGGING */
-
- zset += strlen (zset);
- }
-
-#if QNX_LOG_NODE_ID
- sprintf (zset, " %ld", (long) getnid ());
- zset += strlen (zset);
-#endif
-
- *zset++ = ')';
- *zset++ = ' ';
-
- strcpy (zset, zhdr);
- }
- }
-
- zformat = zbufalc (2 * strlen (zprefix) + strlen (zmsg) + 2);
-
- zset = zformat;
- zfrom = zprefix;
- while (*zfrom != '\0')
- {
- if (*zfrom == '%')
- *zset++ = '%';
- *zset++ = *zfrom++;
- }
-
- ubuffree (zprefix);
-
- zset = zstpcpy (zset, zmsg);
-
- if (fend)
- {
- *zset++ = '\n';
- *zset = '\0';
- }
-
-#if HAVE_VFPRINTF
- va_start (parg, zmsg);
- vfprintf (e, zformat, parg);
- va_end (parg);
- if (edebug != NULL)
- {
- va_start (parg, zmsg);
- vfprintf (edebug, zformat, parg);
- va_end (parg);
- }
-#else /* ! HAVE_VFPRINTF */
- fprintf (e, zformat, a, b, c, d, f, g, h, i, j);
- if (edebug != NULL)
- fprintf (edebug, zformat, a, b, c, d, f, g, h, i, j);
-#endif /* ! HAVE_VFPRINTF */
-
- ubuffree (zformat);
-
- (void) fflush (e);
- if (edebug != NULL)
- (void) fflush (edebug);
-
- if (pfLend != NULL)
- (*pfLend) ();
-
- if (ttype == LOG_FATAL)
- {
- if (pfLfatal != NULL)
- (*pfLfatal) ();
- usysdep_exit (FALSE);
- }
-
-#if CLOSE_LOGFILES
- ulog_close ();
-#endif
-}
-
-/* Log a uuconf error. */
-
-void
-ulog_uuconf (ttype, puuconf, iuuconf)
- enum tlog ttype;
- pointer puuconf;
- int iuuconf;
-{
- char ab[512];
-
- (void) uuconf_error_string (puuconf, iuuconf, ab, sizeof ab);
- ulog (ttype, "%s", ab);
-}
-
-/* Close the log file. There's nothing useful we can do with errors,
- so we don't check for them. */
-
-void
-ulog_close ()
-{
- /* Make sure we logged any signal we received. */
- ulog (LOG_ERROR, (const char *) NULL);
-
- if (eLlog != NULL)
- {
- (void) fclose (eLlog);
- eLlog = NULL;
- fLlog_tried = FALSE;
- }
-
-#if DEBUG > 1
- if (eLdebug != NULL)
- {
- (void) fclose (eLdebug);
- eLdebug = NULL;
- fLdebug_tried = FALSE;
- }
-#endif
-}
-
-/* Add an entry to the statistics file. We may eventually want to put
- failed file transfers in here, but we currently do not. */
-
-/*ARGSUSED*/
-void
-ustats (fsucceeded, zuser, zsystem, fsent, cbytes, csecs, cmicros, fcaller)
- boolean fsucceeded;
- const char *zuser;
- const char *zsystem;
- boolean fsent;
- long cbytes;
- long csecs;
- long cmicros;
- boolean fcaller;
-{
- long cbps;
-
- /* The seconds and microseconds are now counted independently, so
- they may be out of synch. */
- if (cmicros < 0)
- {
- csecs -= ((- cmicros) / 1000000L) + 1;
- cmicros = 1000000L - ((- cmicros) % 1000000L);
- }
- if (cmicros >= 1000000L)
- {
- csecs += cmicros / 10000000L;
- cmicros = cmicros % 1000000L;
- }
-
- /* On a system which can determine microseconds we might very well
- have both csecs == 0 and cmicros == 0. */
- if (csecs == 0 && cmicros < 1000)
- cbps = 0;
- else
- {
- long cmillis, cdiv, crem;
-
- /* Compute ((csecs * 1000) / cmillis) using integer division.
- Where DIV is integer division, we know
- a = (a DIV b) * b + a % b
- so
- a / b = (a DIV b) + (a % b) / b
- We compute the latter with a as csecs and b as cmillis,
- mixing the multiplication by 1000. */
- cmillis = csecs * 1000 + cmicros / 1000;
- cdiv = (cbytes / cmillis) * 1000;
- crem = (cbytes % cmillis) * 1000;
- cbps = cdiv + (crem / cmillis);
- if (cmillis < 0 || cdiv < 0 || crem < 0 || cbps < 0)
- {
- /* We overflowed using milliseconds, so use seconds. */
- cbps = cbytes / (csecs + ((cmicros > 500000L) ? 1 : 0));
- }
- }
-
- if (eLstats == NULL)
- {
- if (fLstats_tried)
- return;
- fLstats_tried = TRUE;
- eLstats = esysdep_fopen (zLstatsfile, TRUE, TRUE, TRUE);
- if (eLstats == NULL)
- return;
- }
-
-#if HAVE_TAYLOR_LOGGING
- fprintf (eLstats,
- "%s %s (%s) %s%s %ld bytes in %ld.%03ld seconds (%ld bytes/sec) on port %s\n",
- zuser, zsystem, zldate_and_time (),
- fsucceeded ? "" : "failed after ",
- fsent ? "sent" : "received",
- cbytes, csecs, cmicros / 1000, cbps,
- zLdevice == NULL ? "unknown" : zLdevice);
-#endif /* HAVE_TAYLOR_LOGGING */
-#if HAVE_V2_LOGGING
- fprintf (eLstats,
- "%s %s (%s) (%ld) %s %s %ld bytes %ld seconds\n",
- zuser, zsystem, zldate_and_time (),
- (long) time ((time_t *) NULL),
- fsent ? "sent" : "received",
- fsucceeded ? "data" : "failed after",
- cbytes, csecs + cmicros / 500000);
-#endif /* HAVE_V2_LOGGING */
-#if HAVE_HDB_LOGGING
- {
- static int iseq;
-
- /* I don't know what the 'C' means. The sequence number should
- probably correspond to the sequence number in the log file, but
- that is currently always 0; using this fake sequence number
- will still at least reveal which transfers are from different
- calls. */
- ++iseq;
- fprintf (eLstats,
- "%s!%s %c (%s) (C,%d,%d) [%s] %s %ld / %ld.%03ld secs, %ld%s%s\n",
- zsystem, zuser, fcaller ? 'M' : 'S', zldate_and_time (),
- iLid, iseq, zLdevice == NULL ? "unknown" : zLdevice,
- fsent ? "->" : "<-",
- cbytes, csecs, cmicros / 1000, cbps,
- " bytes/sec",
- fsucceeded ? "" : " [PARTIAL FILE]");
- }
-#endif /* HAVE_HDB_LOGGING */
-
- (void) fflush (eLstats);
-
-#if CLOSE_LOGFILES
- ustats_close ();
-#endif
-}
-
-/* Close the statistics file. */
-
-void
-ustats_close ()
-{
- if (eLstats != NULL)
- {
- if (fclose (eLstats) != 0)
- ulog (LOG_ERROR, "fclose: %s", strerror (errno));
- eLstats = NULL;
- fLstats_tried = FALSE;
- }
-}
-
-/* Return the date and time in a form used for a log entry. */
-
-static const char *
-zldate_and_time ()
-{
- long isecs, imicros;
- struct tm s;
-#if HAVE_TAYLOR_LOGGING
- static char ab[sizeof "1991-12-31 12:00:00.00"];
-#endif
-#if HAVE_V2_LOGGING
- static char ab[sizeof "12/31-12:00"];
-#endif
-#if HAVE_HDB_LOGGING
- static char ab[sizeof "12/31-12:00:00"];
-#endif
-
- isecs = ixsysdep_time (&imicros);
- usysdep_localtime (isecs, &s);
-
-#if HAVE_TAYLOR_LOGGING
- sprintf (ab, "%04d-%02d-%02d %02d:%02d:%02d.%02d",
- s.tm_year + 1900, s.tm_mon + 1, s.tm_mday, s.tm_hour,
- s.tm_min, s.tm_sec, (int) (imicros / 10000));
-#endif
-#if HAVE_V2_LOGGING
- sprintf (ab, "%d/%d-%02d:%02d", s.tm_mon + 1, s.tm_mday,
- s.tm_hour, s.tm_min);
-#endif
-#if HAVE_HDB_LOGGING
- sprintf (ab, "%d/%d-%d:%02d:%02d", s.tm_mon + 1, s.tm_mday,
- s.tm_hour, s.tm_min, s.tm_sec);
-#endif
-
- return ab;
-}
diff --git a/gnu/libexec/uucp/common_sources/policy.h b/gnu/libexec/uucp/common_sources/policy.h
deleted file mode 100644
index da118b6..0000000
--- a/gnu/libexec/uucp/common_sources/policy.h
+++ /dev/null
@@ -1,703 +0,0 @@
-/* policy.h
- Configuration file for policy decisions. To be edited on site.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-/* This header file contains macro definitions which must be set by
- each site before compilation. The first few are system
- characteristics that can not be easily discovered by the
- configuration script. Most are configuration decisions that must
- be made by the local administrator. */
-
-/* System characteristics. */
-
-/* This code tries to use several ANSI C features, including
- prototypes, stdarg.h, the const qualifier and the types void
- (including void * pointers) and unsigned char. By default it will
- use these features if the compiler defines __STDC__. If your
- compiler supports these features but does not define __STDC__, you
- should set ANSI_C to 1. If your compiler does not support these
- features but defines __STDC__ (no compiler should do this, in my
- opinion), you should set ANSI_C to 0. In most cases (or if you're
- not sure) just leave the line below commented out. */
-/* #define ANSI_C 1 */
-
-/* Set USE_STDIO to 1 if data files should be read using the stdio
- routines (fopen, fread, etc.) rather than the UNIX unbuffered I/O
- calls (open, read, etc.). Unless you know your stdio is really
- rotten, you should leave this as 1. */
-#define USE_STDIO 1
-
-/* Exactly one of the following macros must be set to 1. Many modern
- systems support more than one of these choices through some form of
- compilation environment, in which case the setting will depend on
- the compilation environment you use. If you have a reasonable
- choice between options, I suspect that TERMIO or TERMIOS will be
- more efficient than TTY, but I have not done any head to head
- comparisons.
-
- If you don't set any of these macros, the code below will guess.
- It will doubtless be wrong on some systems.
-
- HAVE_BSD_TTY -- Use the 4.2BSD tty routines
- HAVE_SYSV_TERMIO -- Use the System V termio routines
- HAVE_POSIX_TERMIOS -- Use the POSIX termios routines
- */
-#define HAVE_BSD_TTY 0
-#define HAVE_SYSV_TERMIO 0
-#define HAVE_POSIX_TERMIOS 1
-
-/* This code tries to guess which terminal driver to use if you did
- not make a choice above. It is in this file to make it easy to
- figure out what's happening if something goes wrong. */
-
-#if HAVE_BSD_TTY + HAVE_SYSV_TERMIO + HAVE_POSIX_TERMIOS == 0
-#if HAVE_TERMIOS_H
-#undef HAVE_POSIX_TERMIOS
-#define HAVE_POSIX_TERMIOS 1
-#else /* ! HAVE_TERMIOS_H */
-#if HAVE_CBREAK
-#undef HAVE_BSD_TTY
-#define HAVE_BSD_TTY 1
-#else /* ! HAVE_CBREAK */
-#undef HAVE_SYSV_TERMIO
-#define HAVE_SYSV_TERMIO 1
-#endif /* ! HAVE_CBREAK */
-#endif /* ! HAVE_TERMIOS_H */
-#endif /* HAVE_BSD_TTY + HAVE_SYSV_TERMIO + HAVE_POSIX_TERMIOS == 0 */
-
-/* On some systems a write to a serial port will block even if the
- file descriptor has been set to not block. File transfer can be
- more efficient if the package knows that a write to the serial port
- will not block; however, if the write does block unexpectedly then
- data loss is possible at high speeds.
-
- If writes to a serial port always block even when requested not to,
- you should set HAVE_UNBLOCKED_WRITES to 0; otherwise you should set
- it to 1. In general on System V releases without STREAMS-based
- ttys (e.g., before SVR4) HAVE_UNBLOCKED_WRITES should be 0 and on
- BSD or SVR4 it should be 1.
-
- If HAVE_UNBLOCKED_WRITES is set to 1 when it should be 0 you may
- see an unexpectedly large number of transmission errors, or, if you
- have hardware handshaking, transfer times may be lower than
- expected (but then, they always are). If HAVE_UNBLOCKED_WRITES is
- set to 0 when it should be 1, file transfer will use more CPU time
- than necessary. If you are unsure, setting HAVE_UNBLOCKED_WRITES
- to 0 should always be safe. */
-#define HAVE_UNBLOCKED_WRITES 1
-
-/* When the code does do a blocking write, it wants to write the
- largest amount of data which the kernel will accept as a single
- unit. On BSD this is typically the value of OBUFSIZ in
- <sys/tty.h>, usually 100. On System V before SVR4 this is
- typically the size of a clist, CLSIZE in <sys/tty.h>, which is
- usually 64. On SVR4, which uses STREAMS-based ttys, 2048 is
- reasonable. Define SINGLE_WRITE to the correct value for your
- system. If SINGLE_WRITE is too large, data loss may occur. If
- SINGLE_WRITE is too small, file transfer will use more CPU time
- than necessary. If you have no idea, 64 should work on most modern
- systems. */
-#define SINGLE_WRITE 100
-
-/* Some tty drivers, such as those from SCO and AT&T's Unix PC, have a
- bug in the implementation of ioctl() that causes CLOCAL to be
- ineffective until the port is opened a second time. If
- HAVE_CLOCAL_BUG is set to 1, code will be added to do this second
- open on the port. Set this if you are getting messages that say
- "Line disconnected" while in the dial chat script after only
- writing the first few characters to the port. This bug causes the
- resetting of CLOCAL to have no effect, so the "\m" (require
- carrier) escape sequence won't function properly in dialer chat
- scripts. */
-#define HAVE_CLOCAL_BUG 0
-
-/* On some systems, such as SCO Xenix, resetting DTR on a port
- apparently prevents getty from working on the port, and thus
- prevents anybody from dialing in. If HAVE_RESET_BUG is set to 1,
- DTR will not be reset when a serial port is closed. */
-#define HAVE_RESET_BUG 0
-
-/* The Sony NEWS reportedly handles no parity by clearing both the odd
- and even parity bits in the sgtty structure, unlike most BSD based
- systems in which no parity is indicated by setting both the odd and
- even parity bits. Setting HAVE_PARITY_BUG to 1 will handle this
- correctly. */
-#define HAVE_PARITY_BUG 0
-
-#if HAVE_BSD_TTY
-#ifdef sony
-#undef HAVE_PARITY_BUG
-#define HAVE_PARITY_BUG 1
-#endif
-#endif
-
-/* On Ultrix 4.0, at least, setting CBREAK causes input characters to
- be stripped, regardless of the setting of LPASS8 and LLITOUT. This
- can be worked around by using the termio call to reset ISTRIP.
- This probably does not apply to any other operating system.
- Setting HAVE_STRIP_BUG to 1 will use this workaround. */
-#define HAVE_STRIP_BUG 0
-
-#if HAVE_BSD_TTY
-#ifdef __ultrix__
-#ifndef ultrix
-#define ultrix
-#endif
-#endif
-#ifdef ultrix
-#undef HAVE_STRIP_BUG
-#define HAVE_STRIP_BUG 1
-#endif
-#endif
-
-/* If your system implements full duplex pipes, set
- HAVE_FULLDUPLEX_PIPES to 1. Everything should work fine if you
- leave it set to 0, but setting it to 1 can be slightly more
- efficient. */
-#define HAVE_FULLDUPLEX_PIPES 0
-
-/* TIMES_TICK is the fraction of a second which times(2) returns (for
- example, if times returns 100ths of a second TIMES_TICK should be
- set to 100). On a true POSIX system (one which has the sysconf
- function and also has _SC_CLK_TCK defined in <unistd.h>) TIMES_TICK
- may simply be left as 0. On some systems the environment variable
- HZ is what you want for TIMES_TICK, but on some other systems HZ
- has the wrong value; check the man page. If you leave this set to
- 0, the code will try to guess; it will doubtless be wrong on some
- non-POSIX systems. If TIMES_TICK is wrong the code may report
- incorrect file transfer times in the statistics file, but on many
- systems times(2) will actually not be used and this value will not
- matter at all. */
-#define TIMES_TICK 0
-
-/* If your system does not support saved set user ID, set
- HAVE_SAVED_SETUID to 0. However, this is ignored if your system
- has the setreuid function. Most modern Unixes have one or the
- other. If your system has the setreuid function, don't worry about
- this define, or about the following discussion.
-
- If you set HAVE_SAVED_SETUID to 0, you will not be able to use uucp
- to transfer files that the uucp user can not read. Basically, you
- will only be able to use uucp on world-readable files. If you set
- HAVE_SAVED_SETUID to 1, but your system does not have saved set
- user ID, uucp will fail with an error message whenever anybody
- other than the uucp user uses it. */
-#define HAVE_SAVED_SETUID 0
-
-/* On some systems, such as 4.4BSD-Lite, NetBSD, the DG Aviion and,
- possibly, the RS/6000, the setreuid function is broken. It should
- be possible to use setreuid to swap the real and effective user
- ID's, but on some systems it will not change the real user ID (I
- believe this is due to a misreading of the POSIX standard). On
- such a system you must set HAVE_BROKEN_SETREUID to 1; if you do
- not, you will get error messages from setreuid. Systems on which
- setreuid exists but is broken pretty much always have saved setuid. */
-#define HAVE_BROKEN_SETREUID 0
-
-/* On a few systems, such as NextStep 3.3, the POSIX macro F_SETLKW is
- defined, but does not work. On such systems, you must set
- HAVE_BROKEN_SETLKW to 1. If you do not, uux will hang, or log
- peculiar error messages, every time it is run. */
-#define HAVE_BROKEN_SETLKW 0
-
-/* On the 3B2, and possibly other systems, nap takes an argument in
- hundredths of a second rather than milliseconds. I don't know of
- any way to test for this. Set HAVE_HUNDREDTHS_NAP to 1 if this is
- true on your system. This does not matter if your system does not
- have the nap function. */
-#define HAVE_HUNDREDTHS_NAP 0
-
-/* Set MAIL_PROGRAM to a program which can be used to send mail. It
- will be used for mail to both local and remote users. Set
- MAIL_PROGRAM_TO_BODY to 1 if the recipient should be specified as a
- To: line in the body of the message; otherwise, the recipient will
- be provided as an argument to MAIL_PROGRAM. Set
- MAIL_PROGRAM_SUBJECT_BODY if the subject should be specified as a
- Subject: line in the body of the message; otherwise, the subject
- will be provided using the -s option to MAIL_PROGRAM (if your mail
- program does not support the -s option, you must set
- MAIL_PROGRAM_SUBJECT_BODY to 1). If your system uses sendmail, use
- the sendmail choice below. Otherwise, select one of the other
- choices as appropriate. */
-#if 1
-#define MAIL_PROGRAM "/usr/sbin/sendmail -t"
-#define MAIL_PROGRAM_TO_BODY 1
-#define MAIL_PROGRAM_SUBJECT_BODY 1
-#endif
-#if 0
-#define MAIL_PROGRAM "/usr/ucb/mail"
-#define MAIL_PROGRAM_TO_BODY 0
-#define MAIL_PROGRAM_SUBJECT_BODY 0
-#endif
-#if 0
-#define MAIL_PROGRAM "/bin/mail"
-#define MAIL_PROGRAM_TO_BODY 0
-#define MAIL_PROGRAM_SUBJECT_BODY 1
-#endif
-
-/* Set PS_PROGRAM to the program to run to get a process status,
- including the arguments to pass it. This is used by ``uustat -p''.
- Set HAVE_PS_MULTIPLE to 1 if a comma separated list of process
- numbers may be appended (e.g. ``ps -flp1,10,100''). Otherwise ps
- will be invoked several times, with a single process number append
- each time. The default definitions should work on most systems,
- although some (such as the NeXT) will complain about the 'p'
- option; for those, use the second set of definitions. The third
- set of definitions are appropriate for System V. To use the second
- or third set of definitions, change the ``#if 1'' to ``#if 0'' and
- change the appropriate ``#if 0'' to ``#if 1''. */
-#if 1
-#define PS_PROGRAM "/bin/ps -lp"
-#define HAVE_PS_MULTIPLE 0
-#endif
-#if 0
-#define PS_PROGRAM "/bin/ps -l"
-#define HAVE_PS_MULTIPLE 0
-#endif
-#if 0
-#define PS_PROGRAM "/bin/ps -flp"
-#define HAVE_PS_MULTIPLE 1
-#endif
-#ifdef __QNX__
-/* Use this for QNX, along with HAVE_QNX_LOCKFILES. */
-#undef PS_PROGRAM
-#undef HAVE_PS_MULTIPLE
-#define PS_PROGRAM "/bin/ps -l -n -p"
-#define HAVE_PS_MULTIPLE 0
-#endif
-
-/* If you use other programs that also lock devices, such as cu or
- uugetty, the other programs and UUCP must agree on whether a device
- is locked. This is typically done by creating a lock file in a
- specific directory; the lock files are generally named
- LCK..something or LK.something. If the LOCKDIR macro is defined,
- these lock files will be placed in the named directory; otherwise
- they will be placed in the default spool directory. On some HDB
- systems the lock files are placed in /etc/locks. On some they are
- placed in /usr/spool/locks. On the NeXT they are placed in
- /usr/spool/uucp/LCK. */
-/* #define LOCKDIR "/usr/spool/uucp" */
-/* #define LOCKDIR "/etc/locks" */
-/* #define LOCKDIR "/usr/spool/locks" */
-/* #define LOCKDIR "/usr/spool/uucp/LCK" */
-#define LOCKDIR "/var/spool/lock"
-
-/* You must also specify the format of the lock files by setting
- exactly one of the following macros to 1. Check an existing lock
- file to decide which of these choices is more appropriate.
-
- The HDB style is to write the locking process ID in ASCII, passed
- to ten characters, followed by a newline.
-
- The V2 style is to write the locking process ID as four binary
- bytes in the host byte order. Many BSD derived systems use this
- type of lock file, including the NeXT.
-
- SCO lock files are similar to HDB lock files, but always lock the
- lowercase version of the tty (i.e., LCK..tty2a is created if you
- are locking tty2A). They are appropriate if you are using Taylor
- UUCP on an SCO Unix, SCO Xenix, or SCO Open Desktop system.
-
- SVR4 lock files are also similar to HDB lock files, but they use a
- different naming convention. The filenames are LK.xxx.yyy.zzz,
- where xxx is the major device number of the device holding the
- special device file, yyy is the major device number of the port
- device itself, and zzz is the minor device number of the port
- device.
-
- Sequent DYNIX/ptx (but perhaps not Dynix 3.x) uses yet another
- naming convention. The lock file for /dev/ttyXA/XAAP is named
- LCK..ttyXAAP.
-
- Coherent use a completely different method of terminal locking.
- See unix/cohtty for details. For locks other than for terminals,
- HDB type lock files are used.
-
- QNX lock files are similar to HDB lock files except that the node
- ID must be stored in addition to the process ID and for serial
- devices the node ID must be included in the lock file name. QNX
- boxes are generally used in bunches, and all of them behave like
- one big machine to some extent. Thus, processes on different
- machines will be sharing the files in the spool directory. To
- detect if a process has died and a lock is thus stale, you need the
- node ID of the process as well as the process ID. The process ID
- is stored as a number written using ASCII digits padded to 10
- characters, followed by a space, followed by the node ID written
- using ASCII digits padded to 10 characters, followed by a newline.
- The format for QNX lock files was made up just for Taylor UUCP.
- QNX doesn't come with a version of UUCP. */
-#define HAVE_V2_LOCKFILES 0
-#define HAVE_HDB_LOCKFILES 1
-#define HAVE_SCO_LOCKFILES 0
-#define HAVE_SVR4_LOCKFILES 0
-#define HAVE_SEQUENT_LOCKFILES 0
-#define HAVE_COHERENT_LOCKFILES 0
-#define HAVE_QNX_LOCKFILES 0
-
-/* This tries to pick a default based on preprocessor definitions.
- Ignore it if you have explicitly set one of the above values. */
-#if HAVE_V2_LOCKFILES + HAVE_HDB_LOCKFILES + HAVE_SCO_LOCKFILES + HAVE_SVR4_LOCKFILES + HAVE_SEQUENT_LOCKFILES + HAVE_COHERENT_LOCKFILES + HAVE_QNX_LOCKFILES == 0
-#ifdef __QNX__
-#undef HAVE_QNX_LOCKFILES
-#define HAVE_QNX_LOCKFILES 1
-#else /* ! defined (__QNX__) */
-#ifdef __COHERENT__
-#undef HAVE_COHERENT_LOCKFILES
-#define HAVE_COHERENT_LOCKFILES 1
-#else /* ! defined (__COHERENT__) */
-#ifdef _SEQUENT_
-#undef HAVE_SEQUENT_LOCKFILES
-#define HAVE_SEQUENT_LOCKFILES 1
-#else /* ! defined (_SEQUENT) */
-#ifdef sco
-#undef HAVE_SCO_LOCKFILES
-#define HAVE_SCO_LOCKFILES 1
-#else /* ! defined (sco) */
-#ifdef __svr4__
-#undef HAVE_SVR4_LOCKFILES
-#define HAVE_SVR4_LOCKFILES 1
-#else /* ! defined (__svr4__) */
-/* Final default is HDB. There's no way to tell V2 from HDB. */
-#undef HAVE_HDB_LOCKFILES
-#define HAVE_HDB_LOCKFILES 1
-#endif /* ! defined (__svr4__) */
-#endif /* ! defined (sco) */
-#endif /* ! defined (_SEQUENT) */
-#endif /* ! defined (__COHERENT__) */
-#endif /* ! defined (__QNX__) */
-#endif /* no LOCKFILES define */
-
-/* If your system supports Internet mail addresses (which look like
- user@host.domain rather than system!user), HAVE_INTERNET_MAIL
- should be set to 1. This is checked by uuxqt and uustat when
- sending notifications to the person who submitted the job.
-
- If your system does not understand addresses of the form user@host,
- you must set HAVE_INTERNET_MAIL to 0.
-
- If your system does not understand addresses of the form host!user,
- which is unlikely, you must set HAVE_INTERNET_MAIL to 1.
-
- If your system sends mail addressed to "A!B@C" to host C (i.e., it
- parses the address as "(A!B)@C"), you must set HAVE_INTERNET_MAIL
- to 1.
-
- If your system sends mail addressed to "A!B@C" to host A (i.e., it
- parses the address as "A!(B@C)"), you must set HAVE_INTERNET_MAIL
- to 0.
-
- Note that in general it is best to avoid addresses of the form
- "A!B@C" because of this ambiguity of precedence. UUCP will not
- intentionally generate addresses of this form, but it can occur in
- certain rather complex cases. */
-#define HAVE_INTERNET_MAIL 1
-
-/* Adminstrative decisions. */
-
-/* Set USE_RCS_ID to 1 if you want the RCS ID strings compiled into
- the executable. Leaving them out will decrease the executable
- size. Leaving them in will make it easier to determine which
- version you are running. */
-#define USE_RCS_ID 1
-
-/* DEBUG controls how much debugging information is compiled into the
- code. If DEBUG is defined as 0, no sanity checks will be done and
- no debugging messages will be compiled in. If DEBUG is defined as
- 1 sanity checks will be done but there will still be no debugging
- messages. If DEBUG is 2 than debugging messages will be compiled
- in. When initially testing, DEBUG should be 2, and you should
- probably leave it at 2 unless a small reduction in the executable
- file size will be very helpful. */
-#define DEBUG 2
-
-/* Set HAVE_ENCRYPTED_PASSWORDS to 1 if you want login passwords to be
- encrypted before comparing them against the values in the file.
- This only applies when uucico is run with the -l or -e switches and
- is doing its own login prompting. Note that the passwords used are
- from the UUCP password file, not the system /etc/passwd file. See
- the documentation for further details. If you set this, you are
- responsible for encrypting the passwords in the UUCP password file.
- The function crypt will be used to do comparisons. */
-#define HAVE_ENCRYPTED_PASSWORDS 0
-
-/* Set the default grade to use for a uucp command if the -g option is
- not used. The grades, from highest to lowest, are 0 to 9, A to Z,
- a to z. */
-#define BDEFAULT_UUCP_GRADE ('N')
-
-/* Set the default grade to use for a uux command if the -g option is
- not used. */
-#define BDEFAULT_UUX_GRADE ('N')
-
-/* To compile in use of the new style of configuration files described
- in the documentation, set HAVE_TAYLOR_CONFIG to 1. */
-#define HAVE_TAYLOR_CONFIG 1
-
-/* To compile in use of V2 style configuration files (L.sys, L-devices
- and so on), set HAVE_V2_CONFIG to 1. To compile in use of HDB
- style configuration files (Systems, Devices and so on) set
- HAVE_HDB_CONFIG to 1. The files will be looked up in the
- oldconfigdir directory as defined in the Makefile.
-
- You may set any or all of HAVE_TAYLOR_CONFIG, HAVE_V2_CONFIG and
- HAVE_HDB_CONFIG to 1 (you must set at least one of the macros).
- When looking something up (a system, a port, etc.) the new style
- configuration files will be read first, followed by the V2
- configuration files, followed by the HDB configuration files. */
-#define HAVE_V2_CONFIG 0
-#define HAVE_HDB_CONFIG 1
-
-/* Exactly one of the following macros must be set to 1. The exact
- format of the spool directories is explained in unix/spool.c.
-
- SPOOLDIR_V2 -- Use a Version 2 (original UUCP) style spool directory
- SPOOLDIR_BSD42 -- Use a BSD 4.2 style spool directory
- SPOOLDIR_BSD43 -- Use a BSD 4.3 style spool directory
- SPOOLDIR_HDB -- Use a HDB (BNU) style spool directory
- SPOOLDIR_ULTRIX -- Use an Ultrix style spool directory
- SPOOLDIR_SVR4 -- Use a System V Release 4 spool directory
- SPOOLDIR_TAYLOR -- Use a new style spool directory
-
- If you are not worried about compatibility with a currently running
- UUCP, use SPOOLDIR_TAYLOR. */
-#define SPOOLDIR_V2 0
-#define SPOOLDIR_BSD42 0
-#define SPOOLDIR_BSD43 0
-#define SPOOLDIR_HDB 0
-#define SPOOLDIR_ULTRIX 0
-#define SPOOLDIR_SVR4 0
-#define SPOOLDIR_TAYLOR 1
-
-/* The status file generated by UUCP can use either the traditional
- HDB upper case comments or new easier to read lower case comments.
- This affects the display of uustat -m or uustat -q. Some
- third-party programs read these status files and expect them to be
- in a certain format. The default is to use the traditional
- comments when using an HDB or SVR4 spool directory, and to use
- lower case comments otherwise. */
-#define USE_TRADITIONAL_STATUS (SPOOLDIR_HDB || SPOOLDIR_SVR4)
-
-/* You must select which type of logging you want by setting exactly
- one of the following to 1. These control output to the log file
- and to the statistics file.
-
- If you define HAVE_TAYLOR_LOGGING, each line in the log file will
- look something like this:
-
- uucico uunet uucp (1991-12-10 09:04:34.45 16390) Receiving uunet/D./D.uunetSwJ72
-
- and each line in the statistics file will look something like this:
-
- uucp uunet (1991-12-10 09:04:40.20) received 2371 bytes in 5 seconds (474 bytes/sec)
-
- If you define HAVE_V2_LOGGING, each line in the log file will look
- something like this:
-
- uucico uunet uucp (12/10-09:04 16390) Receiving uunet/D./D.uunetSwJ72
-
- and each line in the statistics file will look something like this:
-
- uucp uunet (12/10-09:04 16390) (692373862) received data 2371 bytes 5 seconds
-
- If you define HAVE_HDB_LOGGING, each program will by default use a
- separate log file. For uucico talking to uunet, for example, it
- will be /usr/spool/uucp/.Log/uucico/uunet. Each line will look
- something like this:
-
- uucp uunet (12/10-09:04:22,16390,1) Receiving uunet/D./D.uunetSwJ72
-
- and each line in the statistics file will look something like this:
-
- uunet!uucp M (12/10-09:04:22) (C,16390,1) [ttyXX] <- 2371 / 5.000 secs, 474 bytes/sec
-
- The main reason to prefer one format over another is that you may
- have shell scripts which expect the files to have a particular
- format. If you have none, choose whichever format you find more
- appealing. */
-#define HAVE_TAYLOR_LOGGING 1
-#define HAVE_V2_LOGGING 0
-#define HAVE_HDB_LOGGING 0
-
-/* If QNX_LOG_NODE_ID is set to 1, log messages will include the QNX
- node ID just after the process ID. This is a policy decision
- because it changes the log file entry format, which can break other
- programs (e.g., some of the ones in the contrib directory) which
- expect to read the standard log file format. */
-#ifdef __QNX__
-#define QNX_LOG_NODE_ID 1
-#else
-#define QNX_LOG_NODE_ID 0
-#endif
-
-/* If LOG_DEVICE_PREFIX is 1, log messages will give the full
- pathname of a device rather than just the final component. This is
- important because on QNX //2/dev/ser2 refers to a different device
- than //4/dev/ser2. */
-#ifdef __QNX__
-#define LOG_DEVICE_PREFIX 1
-#else
-#define LOG_DEVICE_PREFIX 0
-#endif
-
-/* If you would like the log, debugging and statistics files to be
- closed after each message, set CLOSE_LOGFILES to 1. This will
- permit the log files to be easily moved. If a log file does not
- exist when a new message is written out, it will be created.
- Setting CLOSE_LOGFILES to 1 will obviously require slightly more
- processing time. */
-#define CLOSE_LOGFILES 0
-
-/* The name of the default spool directory. If HAVE_TAYLOR_CONFIG is
- set to 1, this may be overridden by the ``spool'' command in the
- configuration file. */
-/* #define SPOOLDIR "/usr/spool/uucp" */
-#define SPOOLDIR "/var/spool/uucp"
-
-/* The name of the default public directory. If HAVE_TAYLOR_CONFIG is
- set to 1, this may be overridden by the ``pubdir'' command in the
- configuration file. Also, a particular system may be given a
- specific public directory by using the ``pubdir'' command in the
- system file. */
-/* #define PUBDIR "/usr/spool/uucppublic" */
-#define PUBDIR "/var/spool/uucppublic"
-
-/* The default command path. This is a space separated list of
- directories. Remote command executions requested by uux are looked
- up using this path. If you are using HAVE_TAYLOR_CONFIG, the
- command path may be overridden for a particular system. For most
- systems, you should just make sure that the programs rmail and
- rnews can be found using this path. */
-#define CMDPATH "/bin /usr/bin /usr/local/bin"
-
-/* The default amount of free space to require for systems that do not
- specify an amount with the ``free-space'' command. This is only
- used when talking to another instance of Taylor UUCP; if accepting
- a file would not leave at least this many bytes free on the disk,
- it will be refused. */
-#define DEFAULT_FREE_SPACE (50000)
-
-/* While a file is being received, Taylor UUCP will periodically check
- to see if there is enough free space remaining on the disk. If
- there is not enough space available on the disk (as determined by
- DEFAULT_FREE_SPACE, above, or the ``free-space'' command for the
- system) the communication will be aborted. The disk will be
- checked each time FREE_SPACE_DELTA bytes are received. Lower
- values of FREE_SPACE_DELTA are less likely to fill up the disk, but
- will also waste more time checking the amount of free space. To
- avoid checking the disk while the file is being received, set
- FREE_SPACE_DELTA to 0. */
-#define FREE_SPACE_DELTA (10240)
-
-/* It is possible for an execute job to request to be executed using
- sh(1), rather than execve(2). This is such a security risk, it is
- being disabled by default; to allow such jobs, set the following
- macro to 1. */
-#define ALLOW_SH_EXECUTION 0
-
-/* If a command executed on behalf of a remote system takes a filename
- as an argument, a security breach may be possible (note that on my
- system neither of the default commands, rmail and rnews, take
- filename arguments). If you set ALLOW_FILENAME_ARGUMENTS to 0, all
- arguments to a command will be checked; if any argument
- 1) starts with ../
- 2) contains the string /../
- 3) begins with a / but does not name a file that may be sent or
- received (according to the specified ``remote-send'' and
- ``remote-receive'')
- the command will be rejected. By default, any argument is
- permitted. */
-#define ALLOW_FILENAME_ARGUMENTS 1
-
-/* If you set FSYNC_ON_CLOSE to 1, all output files will be forced out
- to disk using the fsync system call when they are closed. This can
- be useful if you can not afford to lose people's mail if the system
- crashes. However, not all systems have the fsync call, and it is
- always less efficient to use it. Note that some versions of SCO
- Unix, and possibly other systems, make fsync a synonym for sync,
- which is extremely inefficient. */
-#define FSYNC_ON_CLOSE 0
-
-#if HAVE_TAYLOR_LOGGING
-
-/* The default log file when using HAVE_TAYLOR_LOGGING. When using
- HAVE_TAYLOR_CONFIG, this may be overridden by the ``logfile''
- command in the configuration file. */
-/* #define LOGFILE "/usr/spool/uucp/Log" */
-#define LOGFILE "/var/spool/uucp/Log"
-
-/* The default statistics file when using HAVE_TAYLOR_LOGGING. When
- using HAVE_TAYLOR_CONFIG, this may be overridden by the
- ``statfile'' command in the configuration file. */
-/* #define STATFILE "/usr/spool/uucp/Stats" */
-#define STATFILE "/var/spool/uucp/Stats"
-
-/* The default debugging file when using HAVE_TAYLOR_LOGGING. When
- using HAVE_TAYLOR_CONFIG, this may be overridden by the
- ``debugfile'' command in the configuration file. */
-/* #define DEBUGFILE "/usr/spool/uucp/Debug" */
-#define DEBUGFILE "/var/spool/uucp/Debug"
-
-#endif /* HAVE_TAYLOR_LOGGING */
-
-#if HAVE_V2_LOGGING
-
-/* The default log file when using HAVE_V2_LOGGING. When using
- HAVE_TAYLOR_CONFIG, this may be overridden by the ``logfile''
- command in the configuration file. */
-#define LOGFILE "/usr/spool/uucp/LOGFILE"
-
-/* The default statistics file when using HAVE_V2_LOGGING. When using
- HAVE_TAYLOR_CONFIG, this may be overridden by the ``statfile''
- command in the configuration file. */
-#define STATFILE "/usr/spool/uucp/SYSLOG"
-
-/* The default debugging file when using HAVE_V2_LOGGING. When using
- HAVE_TAYLOR_CONFIG, this may be overridden by the ``debugfile''
- command in the configuration file. */
-#define DEBUGFILE "/usr/spool/uucp/DEBUG"
-
-#endif /* HAVE_V2_LOGGING */
-
-#if HAVE_HDB_LOGGING
-
-/* The default log file when using HAVE_HDB_LOGGING. When using
- HAVE_TAYLOR_CONFIG, this may be overridden by the ``logfile''
- command in the configuration file. The first %s in the string will
- be replaced by the program name (e.g. uucico); the second %s will
- be replaced by the system name (if there is no appropriate system,
- "ANY" will be used). No other '%' character may appear in the
- string. */
-#define LOGFILE "/usr/spool/uucp/.Log/%s/%s"
-
-/* The default statistics file when using HAVE_HDB_LOGGING. When using
- HAVE_TAYLOR_CONFIG, this may be overridden by the ``statfile''
- command in the configuration file. */
-#define STATFILE "/usr/spool/uucp/.Admin/xferstats"
-
-/* The default debugging file when using HAVE_HDB_LOGGING. When using
- HAVE_TAYLOR_CONFIG, this may be overridden by the ``debugfile''
- command in the configuration file. */
-#define DEBUGFILE "/usr/spool/uucp/.Admin/audit.local"
-
-#endif /* HAVE_HDB_LOGGING */
diff --git a/gnu/libexec/uucp/common_sources/prot.c b/gnu/libexec/uucp/common_sources/prot.c
deleted file mode 100644
index c821c81..0000000
--- a/gnu/libexec/uucp/common_sources/prot.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/* prot.c
- Protocol support routines to move commands and data around.
-
- Copyright (C) 1991, 1992, 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char prot_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "conn.h"
-#include "prot.h"
-
-/* Variables visible to the protocol-specific routines. */
-
-/* Buffer to hold received data. */
-char abPrecbuf[CRECBUFLEN];
-
-/* Index of start of data in abPrecbuf. */
-int iPrecstart;
-
-/* Index of end of data (first byte not included in data) in abPrecbuf. */
-int iPrecend;
-
-/* We want to output and input at the same time, if supported on this
- machine. If we have something to send, we send it all while
- accepting a large amount of data. Once we have sent everything we
- look at whatever we have received. If data comes in faster than we
- can send it, we may run out of buffer space. */
-
-boolean
-fsend_data (qconn, zsend, csend, fdoread)
- struct sconnection *qconn;
- const char *zsend;
- size_t csend;
- boolean fdoread;
-{
- if (! fdoread)
- return fconn_write (qconn, zsend, csend);
-
- while (csend > 0)
- {
- size_t crec, csent;
-
- if (iPrecend < iPrecstart)
- crec = iPrecstart - iPrecend - 1;
- else
- {
- crec = CRECBUFLEN - iPrecend;
- if (iPrecstart == 0)
- --crec;
- }
-
- if (crec == 0)
- return fconn_write (qconn, zsend, csend);
-
- csent = csend;
-
- if (! fconn_io (qconn, zsend, &csent, abPrecbuf + iPrecend, &crec))
- return FALSE;
-
- csend -= csent;
- zsend += csent;
-
- iPrecend = (iPrecend + crec) % CRECBUFLEN;
- }
-
- return TRUE;
-}
-
-/* Read data from the other system when we have nothing to send. The
- argument cneed is the amount of data the caller wants, and ctimeout
- is the timeout in seconds. The function sets *pcrec to the amount
- of data which was actually received, which may be less than cneed
- if there isn't enough room in the receive buffer. If no data is
- received before the timeout expires, *pcrec will be returned as 0.
- If an error occurs, the function returns FALSE. If the freport
- argument is FALSE, no error should be reported. */
-
-boolean
-freceive_data (qconn, cneed, pcrec, ctimeout, freport)
- struct sconnection *qconn;
- size_t cneed;
- size_t *pcrec;
- int ctimeout;
- boolean freport;
-{
- /* Set *pcrec to the maximum amount of data we can read. fconn_read
- expects *pcrec to be the buffer size, and sets it to the amount
- actually received. */
- if (iPrecend < iPrecstart)
- *pcrec = iPrecstart - iPrecend - 1;
- else
- {
- *pcrec = CRECBUFLEN - iPrecend;
- if (iPrecstart == 0)
- --(*pcrec);
- }
-
-#if DEBUG > 0
- /* If we have no room in the buffer, we're in trouble. The
- protocols must be written to ensure that this can't happen. */
- if (*pcrec == 0)
- ulog (LOG_FATAL, "freceive_data: No room in buffer");
-#endif
-
- /* If we don't have room for all the data the caller wants, we
- simply have to expect less. We'll get the rest later. */
- if (*pcrec < cneed)
- cneed = *pcrec;
-
- if (! fconn_read (qconn, abPrecbuf + iPrecend, pcrec, cneed, ctimeout,
- freport))
- return FALSE;
-
- iPrecend = (iPrecend + *pcrec) % CRECBUFLEN;
-
- return TRUE;
-}
-
-/* Read a single character. Get it out of the receive buffer if it's
- there, otherwise ask freceive_data for at least one character.
- This is used because as a protocol is shutting down freceive_data
- may read ahead and eat characters that should be read outside the
- protocol routines. We call freceive_data rather than fconn_read
- with an argument of 1 so that we can get all the available data in
- a single system call. The ctimeout argument is the timeout in
- seconds; the freport argument is FALSE if no error should be
- reported. This returns a character, or -1 on timeout or -2 on
- error. */
-
-int
-breceive_char (qconn, ctimeout, freport)
- struct sconnection *qconn;
- int ctimeout;
- boolean freport;
-{
- char b;
-
- if (iPrecstart == iPrecend)
- {
- size_t crec;
-
- if (! freceive_data (qconn, sizeof (char), &crec, ctimeout, freport))
- return -2;
- if (crec == 0)
- return -1;
- }
-
- b = abPrecbuf[iPrecstart];
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN;
- return BUCHAR (b);
-}
-
-/* Send mail about a file transfer. We send to the given mailing
- address if there is one, otherwise to the user. */
-
-boolean
-fmail_transfer (fsuccess, zuser, zmail, zwhy, zfromfile, zfromsys,
- ztofile, ztosys, zsaved)
- boolean fsuccess;
- const char *zuser;
- const char *zmail;
- const char *zwhy;
- const char *zfromfile;
- const char *zfromsys;
- const char *ztofile;
- const char *ztosys;
- const char *zsaved;
-{
- const char *zsendto;
- const char *az[20];
- int i;
-
- if (zmail != NULL && *zmail != '\0')
- zsendto = zmail;
- else
- zsendto = zuser;
-
- i = 0;
- az[i++] = "The file\n\t";
- if (zfromsys != NULL)
- {
- az[i++] = zfromsys;
- az[i++] = "!";
- }
- az[i++] = zfromfile;
- if (fsuccess)
- az[i++] = "\nwas successfully transferred to\n\t";
- else
- az[i++] = "\ncould not be transferred to\n\t";
- if (ztosys != NULL)
- {
- az[i++] = ztosys;
- az[i++] = "!";
- }
- az[i++] = ztofile;
- az[i++] = "\nas requested by\n\t";
- az[i++] = zuser;
- if (! fsuccess)
- {
- az[i++] = "\nfor the following reason:\n\t";
- az[i++] = zwhy;
- az[i++] = "\n";
- }
- if (zsaved != NULL)
- {
- az[i++] = zsaved;
- az[i++] = "\n";
- }
-
- return fsysdep_mail (zsendto,
- fsuccess ? "UUCP succeeded" : "UUCP failed",
- i, az);
-}
diff --git a/gnu/libexec/uucp/common_sources/prot.h b/gnu/libexec/uucp/common_sources/prot.h
deleted file mode 100644
index 11c3941..0000000
--- a/gnu/libexec/uucp/common_sources/prot.h
+++ /dev/null
@@ -1,270 +0,0 @@
-/* prot.h
- Protocol header file.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-/* We need the definition of uuconf_cmdtab to declare the protocol
- parameter arrays. */
-#ifndef UUCONF_H
-#include "uuconf.h"
-#endif
-
-#if ANSI_C
-/* These structures are used in prototypes but are not defined in this
- header file. */
-struct sdaemon;
-struct sconnection;
-struct stransfer;
-#endif
-
-/* The sprotocol structure holds information and functions for a specific
- protocol (e.g. the 'g' protocol). */
-
-struct sprotocol
-{
- /* The name of the protocol (e.g. 'g'). */
- char bname;
- /* Reliability requirements, an or of UUCONF_RELIABLE_xxx defines
- from uuconf.h. */
- int ireliable;
- /* The maximum number of channels this protocol can support. */
- int cchans;
- /* Whether files may be reliably restarted using this protocol. */
- boolean frestart;
- /* Protocol parameter commands. */
- struct uuconf_cmdtab *qcmds;
- /* A routine to start the protocol. If *pzlog is set to be
- non-NULL, it is an informative message to be logged; it should
- then be passed to ubuffree. */
- boolean (*pfstart) P((struct sdaemon *qdaemon, char **pzlog));
- /* Shutdown the protocol. */
- boolean (*pfshutdown) P((struct sdaemon *qdaemon));
- /* Send a command to the other side. */
- boolean (*pfsendcmd) P((struct sdaemon *qdaemon, const char *z,
- int ilocal, int iremote));
- /* Get buffer to space to fill with data. This should set *pcdata
- to the amount of data desired. */
- char *(*pzgetspace) P((struct sdaemon *qdaemon, size_t *pcdata));
- /* Send data to the other side. The argument z must be a return
- value of pzgetspace. The ipos argument is the file position, and
- is ignored by most protocols. */
- boolean (*pfsenddata) P((struct sdaemon *qdaemon, char *z, size_t c,
- int ilocal, int iremote, long ipos));
- /* Wait for data to come in and call fgot_data with it until
- fgot_data sets *pfexit. */
- boolean (*pfwait) P((struct sdaemon *qdaemon));
- /* Handle any file level actions that need to be taken. If a file
- transfer is starting rather than ending, fstart is TRUE. If the
- file is being sent rather than received, fsend is TRUE. If
- fstart and fsend are both TRUE, cbytes holds the size of the
- file. If *pfhandled is set to TRUE, then the protocol routine
- has taken care of queueing up qtrans for the next action. */
- boolean (*pffile) P((struct sdaemon *qdaemon, struct stransfer *qtrans,
- boolean fstart, boolean fsend, long cbytes,
- boolean *pfhandled));
-};
-
-/* Send data to the other system. If the fread argument is TRUE, this
- will also receive data into the receive buffer abPrecbuf; fread is
- passed as TRUE if the protocol expects data to be coming back, to
- make sure the input buffer does not fill up. Returns FALSE on
- error. */
-extern boolean fsend_data P((struct sconnection *qconn,
- const char *zsend, size_t csend,
- boolean fdoread));
-
-/* Receive data from the other system when there is no data to send.
- The cneed argument is the amount of data desired and the ctimeout
- argument is the timeout in seconds. This will set *pcrec to the
- amount of data received. It will return FALSE on error. If a
- timeout occurs, it will return TRUE with *pcrec set to zero. */
-extern boolean freceive_data P((struct sconnection *qconn, size_t cneed,
- size_t *pcrec, int ctimeout,
- boolean freport));
-
-/* Get one character from the remote system, going through the
- procotol buffering. The ctimeout argument is the timeout in
- seconds, and the freport argument is TRUE if errors should be
- reported (when closing a connection it is pointless to report
- errors). This returns a character or -1 on a timeout or -2 on an
- error. */
-extern int breceive_char P((struct sconnection *qconn,
- int ctimeout, boolean freport));
-
-/* Compute a 32 bit CRC of a data buffer, given an initial CRC. */
-extern unsigned long icrc P((const char *z, size_t c, unsigned long ick));
-
-/* The initial CRC value to use for a new buffer. */
-#if ANSI_C
-#define ICRCINIT (0xffffffffUL)
-#else
-#define ICRCINIT ((unsigned long) 0xffffffffL)
-#endif
-
-/* The size of the receive buffer. */
-#define CRECBUFLEN (16384)
-
-/* Buffer to hold received data. */
-extern char abPrecbuf[CRECBUFLEN];
-
-/* Index of start of data in abPrecbuf. */
-extern int iPrecstart;
-
-/* Index of end of data (first byte not included in data) in abPrecbuf. */
-extern int iPrecend;
-
-/* There are a couple of variables and functions that are shared by
- the 'i' and 'j' protocols (the 'j' protocol is just a wrapper
- around the 'i' protocol). These belong in a separate header file,
- protij.h, but I don't want to create one for just a couple of
- things. */
-
-/* An escape sequence of characters for the 'j' protocol to avoid
- (protocol parameter ``avoid''). */
-extern const char *zJavoid_parameter;
-
-/* Timeout to use when sending the 'i' protocol SYNC packet (protocol
- parameter ``sync-timeout''). */
-extern int cIsync_timeout;
-
-/* Shared startup routine for the 'i' and 'j' protocols. */
-extern boolean fijstart P((struct sdaemon *qdaemon, char **pzlog,
- int imaxpacksize,
- boolean (*pfsend) P((struct sconnection *qconn,
- const char *zsend,
- size_t csend,
- boolean fdoread)),
- boolean (*pfreceive) P((struct sconnection *qconn,
- size_t cneed,
- size_t *pcrec,
- int ctimeout,
- boolean freport))));
-
-/* Prototypes for 'g' protocol functions. */
-
-extern struct uuconf_cmdtab asGproto_params[];
-extern boolean fgstart P((struct sdaemon *qdaemon, char **pzlog));
-extern boolean fbiggstart P((struct sdaemon *qdaemon, char **pzlog));
-extern boolean fvstart P((struct sdaemon *qdaemon, char **pzlog));
-extern boolean fgshutdown P((struct sdaemon *qdaemon));
-extern boolean fgsendcmd P((struct sdaemon *qdaemon, const char *z,
- int ilocal, int iremote));
-extern char *zggetspace P((struct sdaemon *qdaemon, size_t *pcdata));
-extern boolean fgsenddata P((struct sdaemon *qdaemon, char *z, size_t c,
- int ilocal, int iremote, long ipos));
-extern boolean fgwait P((struct sdaemon *qdaemon));
-
-/* Prototypes for 'f' protocol functions. */
-
-extern struct uuconf_cmdtab asFproto_params[];
-extern boolean ffstart P((struct sdaemon *qdaemon, char **pzlog));
-extern boolean ffshutdown P((struct sdaemon *qdaemon));
-extern boolean ffsendcmd P((struct sdaemon *qdaemon, const char *z,
- int ilocal, int iremote));
-extern char *zfgetspace P((struct sdaemon *qdaemon, size_t *pcdata));
-extern boolean ffsenddata P((struct sdaemon *qdaemon, char *z, size_t c,
- int ilocal, int iremote, long ipos));
-extern boolean ffwait P((struct sdaemon *qdaemon));
-extern boolean fffile P((struct sdaemon *qdaemon, struct stransfer *qtrans,
- boolean fstart, boolean fsend, long cbytes,
- boolean *pfhandled));
-
-/* Prototypes for 't' protocol functions. */
-
-extern struct uuconf_cmdtab asTproto_params[];
-extern boolean ftstart P((struct sdaemon *qdaemon, char **pzlog));
-extern boolean ftshutdown P((struct sdaemon *qdaemon));
-extern boolean ftsendcmd P((struct sdaemon *qdaemon, const char *z,
- int ilocal, int iremote));
-extern char *ztgetspace P((struct sdaemon *qdaemon, size_t *pcdata));
-extern boolean ftsenddata P((struct sdaemon *qdaemon, char *z, size_t c,
- int ilocal, int iremote, long ipos));
-extern boolean ftwait P((struct sdaemon *qdaemon));
-extern boolean ftfile P((struct sdaemon *qdaemon, struct stransfer *qtrans,
- boolean fstart, boolean fsend, long cbytes,
- boolean *pfhandled));
-
-/* Prototypes for 'e' protocol functions. */
-
-extern struct uuconf_cmdtab asEproto_params[];
-extern boolean festart P((struct sdaemon *qdaemon, char **pzlog));
-extern boolean feshutdown P((struct sdaemon *qdaemon));
-extern boolean fesendcmd P((struct sdaemon *qdaemon, const char *z,
- int ilocal, int iremote));
-extern char *zegetspace P((struct sdaemon *qdaemon, size_t *pcdata));
-extern boolean fesenddata P((struct sdaemon *qdaemon, char *z, size_t c,
- int ilocal, int iremote, long ipos));
-extern boolean fewait P((struct sdaemon *qdaemon));
-extern boolean fefile P((struct sdaemon *qdaemon, struct stransfer *qtrans,
- boolean fstart, boolean fsend, long cbytes,
- boolean *pfhandled));
-
-/* Prototypes for 'i' protocol functions. */
-
-extern struct uuconf_cmdtab asIproto_params[];
-extern boolean fistart P((struct sdaemon *qdaemon, char **pzlog));
-extern boolean fishutdown P((struct sdaemon *qdaemon));
-extern boolean fisendcmd P((struct sdaemon *qdaemon, const char *z,
- int ilocal, int iremote));
-extern char *zigetspace P((struct sdaemon *qdaemon, size_t *pcdata));
-extern boolean fisenddata P((struct sdaemon *qdaemon, char *z, size_t c,
- int ilocal, int iremote, long ipos));
-extern boolean fiwait P((struct sdaemon *qdaemon));
-
-/* Prototypes for 'j' protocol functions. The 'j' protocol mostly
- uses the 'i' protocol functions, but it has a couple of functions
- of its own. */
-
-extern boolean fjstart P((struct sdaemon *qdaemon, char **pzlog));
-extern boolean fjshutdown P((struct sdaemon *qdaemon));
-
-/* Prototypes for 'a' protocol functions (these use 'z' as the second
- character because 'a' is a modified Zmodem protocol). */
-
-extern struct uuconf_cmdtab asZproto_params[];
-extern boolean fzstart P((struct sdaemon *qdaemon, char **pzlog));
-extern boolean fzshutdown P((struct sdaemon *qdaemon));
-extern boolean fzsendcmd P((struct sdaemon *qdaemon, const char *z,
- int ilocal, int iremote));
-extern char *zzgetspace P((struct sdaemon *qdaemon, size_t *pcdata));
-extern boolean fzsenddata P((struct sdaemon *qdaemon, char *z, size_t c,
- int ilocal, int iremote, long ipos));
-extern boolean fzwait P((struct sdaemon *qdaemon));
-extern boolean fzfile P((struct sdaemon *qdaemon, struct stransfer *qtrans,
- boolean fstart, boolean fsend, long cbytes,
- boolean *pfhandled));
-
-/* Prototypes for 'y' protocol functions. */
-
-extern struct uuconf_cmdtab asYproto_params[];
-extern boolean fystart P((struct sdaemon *qdaemon, char **pzlog));
-extern boolean fyshutdown P((struct sdaemon *qdaemon));
-extern boolean fysendcmd P((struct sdaemon *qdaemon, const char *z,
- int ilocal, int iremote));
-extern char *zygetspace P((struct sdaemon *qdaemon, size_t *pcdata));
-extern boolean fysenddata P((struct sdaemon *qdaemon, char *z, size_t c,
- int ilocal, int iremote, long ipos));
-extern boolean fywait P((struct sdaemon *qdaemon));
-extern boolean fyfile P((struct sdaemon *qdaemon, struct stransfer *qtrans,
- boolean fstart, boolean fsend, long cbytes,
- boolean *pfhandled));
diff --git a/gnu/libexec/uucp/common_sources/sysdep.h b/gnu/libexec/uucp/common_sources/sysdep.h
deleted file mode 100644
index 8b7e279..0000000
--- a/gnu/libexec/uucp/common_sources/sysdep.h
+++ /dev/null
@@ -1,563 +0,0 @@
-/* sysh.unx -*- C -*-
- The header file for the UNIX system dependent routines.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#ifndef SYSH_UNX_H
-
-#define SYSH_UNX_H
-
-#if ANSI_C
-/* These structures are used in prototypes but are not defined in this
- header file. */
-struct uuconf_system;
-struct sconnection;
-#endif
-
-/* SCO, SVR4 and Sequent lockfiles are basically just like HDB
- lockfiles. */
-#if HAVE_SCO_LOCKFILES || HAVE_SVR4_LOCKFILES || HAVE_SEQUENT_LOCKFILES
-#undef HAVE_HDB_LOCKFILES
-#define HAVE_HDB_LOCKFILES 1
-#endif
-
-#if HAVE_BSD_TTY + HAVE_SYSV_TERMIO + HAVE_POSIX_TERMIOS != 1
- #error Terminal driver define not set or duplicated
-#endif
-
-#if SPOOLDIR_V2 + SPOOLDIR_BSD42 + SPOOLDIR_BSD43 + SPOOLDIR_HDB + SPOOLDIR_ULTRIX + SPOOLDIR_SVR4 + SPOOLDIR_TAYLOR != 1
- #error Spool directory define not set or duplicated
-#endif
-
-/* If setreuid is broken, don't use it. */
-#if HAVE_BROKEN_SETREUID
-#undef HAVE_SETREUID
-#define HAVE_SETREUID 0
-#endif
-
-/* Get some standard types from the configuration header file. */
-#ifdef PID_T
-typedef PID_T pid_t;
-#endif
-
-#ifdef UID_T
-typedef UID_T uid_t;
-#endif
-
-#ifdef GID_T
-typedef GID_T gid_t;
-#endif
-
-#ifdef OFF_T
-typedef OFF_T off_t;
-#endif
-
-/* On Unix, binary files are the same as text files. */
-#define BINREAD "r"
-#define BINWRITE "w"
-
-/* If we have sigaction, we can force system calls to not be
- restarted. */
-#if HAVE_SIGACTION
-#undef HAVE_RESTARTABLE_SYSCALLS
-#define HAVE_RESTARTABLE_SYSCALLS 0
-#endif
-
-/* If we have sigvec, and we have HAVE_SIGVEC_SV_FLAGS, and
- SV_INTERRUPT is defined, we can force system calls to not be
- restarted (signal.h is included by uucp.h before this point, so
- SV_INTERRUPT will be defined by now if it it ever is). */
-#if HAVE_SIGVEC && HAVE_SIGVEC_SV_FLAGS
-#ifdef SV_INTERRUPT
-#undef HAVE_RESTARTABLE_SYSCALLS
-#define HAVE_RESTARTABLE_SYSCALLS 0
-#endif
-#endif
-
-/* If we were cross-configured, we will have a value of -1 for
- HAVE_RESTARTABLE_SYSCALLS. In this case, we try to guess what the
- correct value should be. Yuck. If we have sigvec, but neither of
- the above cases applied (which we know because they would have
- changed HAVE_RESTARTABLE_SYSCALLS) then we are probably on 4.2BSD
- and system calls are automatically restarted. Otherwise, assume
- that they are not. */
-#if HAVE_RESTARTABLE_SYSCALLS == -1
-#undef HAVE_RESTARTABLE_SYSCALLS
-#if HAVE_SIGVEC
-#define HAVE_RESTARTABLE_SYSCALLS 1
-#else
-#define HAVE_RESTARTABLE_SYSCALLS 0
-#endif
-#endif /* HAVE_RESTARTABLE_SYSCALLS == -1 */
-
-/* We don't handle sigset in combination with restartable system
- calls, so we check for it although this combination will never
- happen. */
-#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && HAVE_SIGSET
-#if HAVE_RESTARTABLE_SYSCALLS
-#undef HAVE_SIGSET
-#define HAVE_SIGSET 0
-#endif
-#endif
-
-/* If we don't have restartable system calls, we can ignore
- fsysdep_catch, usysdep_start_catch and usysdep_end_catch.
- Otherwise fsysdep_catch has to do a setjmp. */
-
-#if ! HAVE_RESTARTABLE_SYSCALLS
-
-#define fsysdep_catch() (TRUE)
-#define usysdep_start_catch()
-#define usysdep_end_catch()
-#define CATCH_PROTECT
-
-#else /* HAVE_RESTARTABLE_SYSCALLS */
-
-#if HAVE_SETRET && ! HAVE_SIGSETJMP
-#include <setret.h>
-#define setjmp setret
-#define longjmp longret
-#define jmp_buf ret_buf
-#else /* ! HAVE_SETRET || HAVE_SIGSETJMP */
-#include <setjmp.h>
-#if HAVE_SIGSETJMP
-#undef setjmp
-#undef longjmp
-#undef jmp_buf
-#define setjmp(s) sigsetjmp ((s), TRUE)
-#define longjmp siglongjmp
-#define jmp_buf sigjmp_buf
-#endif /* HAVE_SIGSETJMP */
-#endif /* ! HAVE_SETRET || HAVE_SIGSETJMP */
-
-extern volatile sig_atomic_t fSjmp;
-extern volatile jmp_buf sSjmp_buf;
-
-#define fsysdep_catch() (setjmp (sSjmp_buf) == 0)
-
-#define usysdep_start_catch() (fSjmp = TRUE)
-
-#define usysdep_end_catch() (fSjmp = FALSE)
-
-#define CATCH_PROTECT volatile
-
-#endif /* HAVE_RESTARTABLE_SYSCALLS */
-
-/* Get definitions for the terminal driver. */
-
-#if HAVE_BSD_TTY
-#include <sgtty.h>
-struct sbsd_terminal
-{
- struct sgttyb stty;
- struct tchars stchars;
- struct ltchars sltchars;
-};
-typedef struct sbsd_terminal sterminal;
-#define fgetterminfo(o, q) \
- (ioctl ((o), TIOCGETP, &(q)->stty) == 0 \
- && ioctl ((o), TIOCGETC, &(q)->stchars) == 0 \
- && ioctl ((o), TIOCGLTC, &(q)->sltchars) == 0)
-#define fsetterminfo(o, q) \
- (ioctl ((o), TIOCSETN, &(q)->stty) == 0 \
- && ioctl ((o), TIOCSETC, &(q)->stchars) == 0 \
- && ioctl ((o), TIOCSLTC, &(q)->sltchars) == 0)
-#define fsetterminfodrain(o, q) \
- (ioctl ((o), TIOCSETP, &(q)->stty) == 0 \
- && ioctl ((o), TIOCSETC, &(q)->stchars) == 0 \
- && ioctl ((o), TIOCSLTC, &(q)->sltchars) == 0)
-#endif /* HAVE_BSD_TTY */
-
-#if HAVE_SYSV_TERMIO
-#include <termio.h>
-typedef struct termio sterminal;
-#define fgetterminfo(o, q) (ioctl ((o), TCGETA, (q)) == 0)
-#define fsetterminfo(o, q) (ioctl ((o), TCSETA, (q)) == 0)
-#define fsetterminfodrain(o, q) (ioctl ((o), TCSETAW, (q)) == 0)
-#endif /* HAVE_SYSV_TERMIO */
-
-#if HAVE_POSIX_TERMIOS
-#include <termios.h>
-typedef struct termios sterminal;
-#define fgetterminfo(o, q) (tcgetattr ((o), (q)) == 0)
-#define fsetterminfo(o, q) (tcsetattr ((o), TCSANOW, (q)) == 0)
-#define fsetterminfodrain(o, q) (tcsetattr ((o), TCSADRAIN, (q)) == 0)
-
-/* On some systems it is not possible to include both <sys/ioctl.h>
- and <termios.h> in the same source files; I don't really know why.
- On such systems, we pretend that we don't have <sys/ioctl.h>. */
-#if ! HAVE_TERMIOS_AND_SYS_IOCTL_H
-#undef HAVE_SYS_IOCTL_H
-#define HAVE_SYS_IOCTL_H 0
-#endif
-
-#endif /* HAVE_POSIX_TERMIOS */
-
-/* The root directory (this is needed by the system independent stuff
- as the default for local-send). */
-#define ZROOTDIR "/"
-
-/* The name of the execution directory within the spool directory
- (this is need by the system independent uuxqt.c). */
-#define XQTDIR ".Xqtdir"
-
-/* The name of the directory in which we preserve file transfers that
- failed. */
-#define PRESERVEDIR ".Preserve"
-
-/* The name of the directory to which we move corrupt files. */
-#define CORRUPTDIR ".Corrupt"
-
-/* The name of the directory to which we move failed execution files. */
-#define FAILEDDIR ".Failed"
-
-/* The length of the sequence number used in a file name. */
-#define CSEQLEN (4)
-
-/* Get some standard definitions. Avoid including the files more than
- once--some might have been included by uucp.h. */
-#if USE_STDIO && HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if ! USE_TYPES_H
-#include <sys/types.h>
-#endif
-#include <sys/stat.h>
-
-/* Get definitions for the file permission bits. */
-
-#ifndef S_IRWXU
-#define S_IRWXU 0700
-#endif
-#ifndef S_IRUSR
-#define S_IRUSR 0400
-#endif
-#ifndef S_IWUSR
-#define S_IWUSR 0200
-#endif
-#ifndef S_IXUSR
-#define S_IXUSR 0100
-#endif
-
-#ifndef S_IRWXG
-#define S_IRWXG 0070
-#endif
-#ifndef S_IRGRP
-#define S_IRGRP 0040
-#endif
-#ifndef S_IWGRP
-#define S_IWGRP 0020
-#endif
-#ifndef S_IXGRP
-#define S_IXGRP 0010
-#endif
-
-#ifndef S_IRWXO
-#define S_IRWXO 0007
-#endif
-#ifndef S_IROTH
-#define S_IROTH 0004
-#endif
-#ifndef S_IWOTH
-#define S_IWOTH 0002
-#endif
-#ifndef S_IXOTH
-#define S_IXOTH 0001
-#endif
-
-#if STAT_MACROS_BROKEN
-#undef S_ISDIR
-#endif
-
-#ifndef S_ISDIR
-#ifdef S_IFDIR
-#define S_ISDIR(i) (((i) & S_IFMT) == S_IFDIR)
-#else /* ! defined (S_IFDIR) */
-#define S_ISDIR(i) (((i) & 0170000) == 040000)
-#endif /* ! defined (S_IFDIR) */
-#endif /* ! defined (S_ISDIR) */
-
-/* We need the access macros. */
-#ifndef R_OK
-#define R_OK 4
-#define W_OK 2
-#define X_OK 1
-#define F_OK 0
-#endif /* ! defined (R_OK) */
-
-/* We create files with these modes (should this be configurable?). */
-#define IPRIVATE_FILE_MODE (S_IRUSR | S_IWUSR)
-#define IPUBLIC_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
-
-/* We create directories with this mode (should this be configurable?). */
-#define IDIRECTORY_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
-#define IPUBLIC_DIRECTORY_MODE (S_IRWXU | S_IRWXG | S_IRWXO)
-
-#if ! HAVE_OPENDIR
-
-/* Define some structures to use if we don't have opendir, etc. These
- will only work if we have the old Unix filesystem, with a 2 byte
- inode and a 14 byte filename. */
-
-#include <sys/dir.h>
-
-struct dirent
-{
- char d_name[DIRSIZ + 1];
-};
-
-typedef struct
-{
- int o;
- struct dirent s;
-} DIR;
-
-extern DIR *opendir P((const char *zdir));
-extern struct dirent *readdir P((DIR *));
-extern int closedir P((DIR *));
-
-#endif /* ! HAVE_OPENDIR */
-
-#if ! HAVE_FTW_H
-
-/* If there is no <ftw.h>, define the ftw constants. */
-
-#define FTW_F (0)
-#define FTW_D (1)
-#define FTW_DNR (2)
-#define FTW_NS (3)
-
-#endif /* ! HAVE_FTW_H */
-
-/* This structure holds the system dependent information we keep for a
- connection. This is used by the TCP and TLI code. */
-
-struct ssysdep_conn
-{
- /* File descriptor. */
- int o;
- /* File descriptor to read from (used by stdin and pipe port types). */
- int ord;
- /* File descriptor to write to (used by stdin and pipe port types). */
- int owr;
- /* Device name. */
- char *zdevice;
- /* File status flags. */
- int iflags;
- /* File status flags for write descriptor (-1 if not used). */
- int iwr_flags;
- /* Hold the real descriptor when using a dialer device. */
- int ohold;
- /* TRUE if this is a terminal and the remaining fields are valid. */
- boolean fterminal;
- /* TRUE if this is a TLI descriptor. */
- boolean ftli;
- /* Baud rate. */
- long ibaud;
- /* Original terminal settings. */
- sterminal sorig;
- /* Current terminal settings. */
- sterminal snew;
- /* Process ID of currently executing pipe command, or parent process
- of forked TCP or TLI server, or -1. */
- pid_t ipid;
-#if HAVE_COHERENT_LOCKFILES
- /* On Coherent we need to hold on to the real port name which will
- be used to enable the port. Ick. */
- char *zenable;
-#endif
-};
-
-/* These functions do I/O and chat scripts to a port. They are called
- by the TCP and TLI routines. */
-extern boolean fsysdep_conn_read P((struct sconnection *qconn,
- char *zbuf, size_t *pclen,
- size_t cmin, int ctimeout,
- boolean freport));
-extern boolean fsysdep_conn_write P((struct sconnection *qconn,
- const char *zbuf, size_t clen));
-extern boolean fsysdep_conn_io P((struct sconnection *qconn,
- const char *zwrite, size_t *pcwrite,
- char *zread, size_t *pcread));
-extern boolean fsysdep_conn_chat P((struct sconnection *qconn,
- char **pzprog));
-
-/* Set a signal handler. */
-extern void usset_signal P((int isig, RETSIGTYPE (*pfn) P((int)),
- boolean fforce, boolean *pfignored));
-
-/* Default signal handler. This sets the appropriate element of the
- afSignal array. If system calls are automatically restarted, it
- may do a longjmp to an fsysdep_catch. */
-extern RETSIGTYPE ussignal P((int isig));
-
-/* Try to fork, repeating several times. */
-extern pid_t ixsfork P((void));
-
-/* Spawn a job. Returns the process ID of the spawned job or -1 on
- error. The following macros may be passed in aidescs. */
-
-/* Set descriptor to /dev/null. */
-#define SPAWN_NULL (-1)
-/* Set element of aidescs to a pipe for caller to read from. */
-#define SPAWN_READ_PIPE (-2)
-/* Set element of aidescs to a pipe for caller to write to. */
-#define SPAWN_WRITE_PIPE (-3)
-
-extern pid_t ixsspawn P((const char **pazargs, int *aidescs,
- boolean fkeepuid, boolean fkeepenv,
- const char *zchdir, boolean fnosigs,
- boolean fshell, const char *zpath,
- const char *zuu_machine,
- const char *zuu_user));
-
-/* Do a form of popen using ixsspawn. */
-extern FILE *espopen P((const char **pazargs, boolean frd,
- pid_t *pipid));
-
-/* Wait for a particular process to finish, returning the exit status.
- The process ID should be pid_t, but we can't put that in a
- prototype. */
-extern int ixswait P((unsigned long ipid, const char *zreport));
-
-/* Read from a connection using two file descriptors. */
-extern boolean fsdouble_read P((struct sconnection *qconn, char *zbuf,
- size_t *pclen, size_t cmin, int ctimeout,
- boolean freport));
-
-/* Write to a connection using two file descriptors. */
-extern boolean fsdouble_write P((struct sconnection *qconn,
- const char *zbuf, size_t clen));
-
-/* Run a chat program on a connection using two file descriptors. */
-extern boolean fsdouble_chat P((struct sconnection *qconn,
- char **pzprog));
-
-/* Find a spool file in the spool directory. For a local file, the
- bgrade argument is the grade of the file. This is needed for
- SPOOLDIR_SVR4. */
-extern char *zsfind_file P((const char *zsimple, const char *zsystem,
- int bgrade));
-
-/* Return the grade given a sequence number. */
-extern int bsgrade P((pointer pseq));
-
-/* Lock a string. */
-extern boolean fsdo_lock P((const char *, boolean fspooldir,
- boolean *pferr));
-
-/* Unlock a string. */
-extern boolean fsdo_unlock P((const char *, boolean fspooldir));
-
-/* Check access for a particular user name, or NULL to check access
- for any user. */
-extern boolean fsuser_access P((const struct stat *, int imode,
- const char *zuser));
-
-/* Switch to the permissions of the invoking user. This sets the
- argument to a value to pass to fsuucp_perms. */
-extern boolean fsuser_perms P((uid_t *));
-
-/* Switch back to the permissions of the UUCP user ID. This should be
- passed the value returned by fsuser_perms in its argument. */
-extern boolean fsuucp_perms P((long));
-
-/* Stick two directories and a file name together. */
-extern char *zsappend3 P((const char *zdir1, const char *zdir2,
- const char *zfile));
-
-/* Stick three directories and a file name together. */
-extern char *zsappend4 P((const char *zdir1, const char *zdir2,
- const char *zdir3, const char *zfile));
-
-/* Get a temporary file name. */
-extern char *zstemp_file P((const struct uuconf_system *qsys));
-
-/* Get a command file name. */
-extern char *zscmd_file P((const struct uuconf_system *qsys, int bgrade));
-
-/* Get a jobid from a system, a file name, and a grade. */
-extern char *zsfile_to_jobid P((const struct uuconf_system *qsys,
- const char *zfile,
- int bgrade));
-
-/* Get a file name from a jobid. This also returns the associated system
- in *pzsystem and the grade in *pbgrade. */
-extern char *zsjobid_to_file P((const char *zid, char **pzsystem,
- char *pbgrade));
-
-/* See whether there is a spool directory for a system when using
- SPOOLDIR_ULTRIX. */
-extern boolean fsultrix_has_spool P((const char *zsystem));
-
-#if HAVE_COHERENT_LOCKFILES
-/* Lock a coherent tty. */
-extern boolean lockttyexist P((const char *z));
-extern boolean fscoherent_disable_tty P((const char *zdevice,
- char **pzenable));
-#endif
-
-/* Some replacements for standard Unix functions. */
-
-#if ! HAVE_DUP2
-extern int dup2 P((int oold, int onew));
-#endif
-
-#if ! HAVE_FTW
-extern int ftw P((const char *zdir,
- int (*pfn) P((const char *zfile,
- struct stat *qstat,
- int iflag)),
- int cdescriptors));
-#endif
-
-#if ! HAVE_GETCWD && ! HAVE_GETWD
-extern char *getcwd P((char *zbuf, size_t cbuf));
-#endif
-
-#if ! HAVE_MKDIR
-extern int mkdir P((const char *zdir, int imode));
-#endif
-
-#if ! HAVE_RENAME
-extern int rename P((const char *zold, const char *znew));
-#endif
-
-#if ! HAVE_RMDIR
-extern int rmdir P((const char *zdir));
-#endif
-
-/* The working directory from which the program was run (this is set
- by usysdep_initialize if called with INIT_GETCWD). */
-extern char *zScwd;
-
-/* The spool directory name. */
-extern const char *zSspooldir;
-
-/* The lock directory name. */
-extern const char *zSlockdir;
-
-/* The local UUCP name (needed for some spool directory stuff). */
-extern const char *zSlocalname;
-
-#endif /* ! defined (SYSH_UNX_H) */
diff --git a/gnu/libexec/uucp/common_sources/system.h b/gnu/libexec/uucp/common_sources/system.h
deleted file mode 100644
index 5fcc525..0000000
--- a/gnu/libexec/uucp/common_sources/system.h
+++ /dev/null
@@ -1,994 +0,0 @@
-/* system.h
- Header file for system dependent stuff in the Taylor UUCP package.
- This file is not itself system dependent.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#ifndef SYSTEM_H
-
-#define SYSTEM_H
-
-#if ANSI_C
-/* These structures are used in prototypes but are not defined in this
- header file. */
-struct tm;
-struct uuconf_system;
-struct uuconf_port;
-struct sconnection;
-struct sstatus;
-struct scmd;
-#endif
-
-/* Any function which returns an error should also report an error
- message, unless otherwise indicated.
-
- Any function that returns a char *, rather than a const char *, is
- returning a pointer to a buffer allocated by zbufalc which must be
- freed using ubuffree, unless otherwise indicated. */
-
-/* The maximum length of a remote system name. */
-extern size_t cSysdep_max_name_len;
-
-/* Initialize. If something goes wrong, this routine should just
- exit. The flag argument is 0, or a combination of any of the
- following flags. */
-
-/* This program needs to know the current working directory. This is
- used because on Unix it can be expensive to determine the current
- working directory (some versions of getcwd fork a process), but in
- most cases we don't need to know it. However, we are going to
- chdir to the spool directory (unless INIT_CHDIR is set), so we have
- to get the cwd now if we are ever going to get it. Both uucp and
- uux use the function fsysdep_needs_cwd to determine whether they
- will need the current working directory, and pass the argument to
- usysdep_initialize appropriately. There's probably a cleaner way
- to handle this, but this will suffice for now. */
-#define INIT_GETCWD (01)
-
-/* This program should not chdir to the spool directory. This may
- only make sense on Unix. It is set by cu. */
-#define INIT_NOCHDIR (02)
-
-/* This program needs special access to the spool directories. That
- means, on Unix, this program is normally installed setuid. */
-#define INIT_SUID (04)
-
-/* Do not close all open descriptors. This is not used by the UUCP
- code, but it is used by other programs which share some of the
- system dependent libraries. */
-#define INIT_NOCLOSE (010)
-
-extern void usysdep_initialize P((pointer puuconf, int iflags));
-
-/* Exit the program. The fsuccess argument indicates whether to
- return an indication of success or failure to the outer
- environment. This routine should not return. */
-extern void usysdep_exit P((boolean fsuccess));
-
-/* Called when a non-standard configuration file is being used, to
- avoid handing out privileged access. If it returns FALSE, default
- configuration file will be used. This is called before the
- usysdep_initialize function is called. */
-extern boolean fsysdep_other_config P((const char *));
-
-/* Detach from the controlling terminal. This probably only makes
- sense on Unix. It is called by uucico to try to get the modem port
- as a controlling terminal. It is also called by uucico before it
- starts up uuxqt, so that uuxqt will be a complete daemon. */
-extern void usysdep_detach P((void));
-
-/* Get the local node name if it is not specified in the configuration
- files. Returns NULL on error; otherwise the return value should
- point to a static buffer. */
-extern const char *zsysdep_localname P((void));
-
-/* Get the login name. This is used when uucico is started up with no
- arguments in slave mode, which causes it to assume that somebody
- has logged in. It also used by uucp and uux for recording the user
- name. This may not return NULL. The return value should point to
- a static buffer. */
-extern const char *zsysdep_login_name P((void));
-
-/* Set a signal handler for a signal. If the signal occurs, the
- appropriate element of afSignal should be set to the signal number
- (see the declaration of afSignal in uucp.h). This routine might be
- able to just use signal, but Unix requires more complex handling.
- This is called before usysdep_initialize. */
-extern void usysdep_signal P((int isig));
-
-/* Catch a signal. This is actually defined as a macro in the system
- dependent header file, and the prototype here just indicates how it
- should be called. It is called before a routine which must exit if
- a signal occurs, and is expected to set do a setjmp (which is why
- it must be a macro). It is actually only called in one place in
- the system independent code, before the call to read stdin in uux.
- This is needed to handle 4.2 BSD restartable system calls, which
- require a longjmp. On systems which don't need to do
- setjmp/longjmp around system calls, this can be redefined in
- sysdep.h to TRUE. It should return TRUE if the routine should
- proceed, or FALSE if a signal occurred. After having this return
- TRUE, usysdep_start_catch should be used to start catching the
- signal; this basically tells the signal handler that it's OK to do
- the longjmp, if fsysdep_catch did not already do so. */
-#ifndef fsysdep_catch
-extern boolean fsysdep_catch P((void));
-#endif
-
-/* Start catching a signal. This is called after fsysdep_catch to
- tell the signal handler to go ahead and do the longjmp. This may
- be implemented as a macro in sysdep.h. */
-#ifndef usysdep_start_catch
-extern void usysdep_start_catch P((void));
-#endif
-
-/* Stop catching a signal. This is called when it is no longer
- necessary for fsysdep_catch to handle signals. This may be
- implemented as a macro in sysdep.h. */
-#ifndef usysdep_end_catch
-extern void usysdep_end_catch P((void));
-#endif
-
-/* Link two files. On Unix this should attempt the link. If it
- succeeds it should return TRUE with *pfworked set to TRUE. If the
- link fails because it must go across a device, it should return
- TRUE with *pfworked set to FALSE. If the link fails for some other
- reason, it should log an error message and return FALSE. On a
- system which does not support links to files, this should just
- return TRUE with *pfworked set to FALSE. */
-extern boolean fsysdep_link P((const char *zfrom, const char *zto,
- boolean *pfworked));
-
-/* Get the port name. This is used when uucico is started up in slave
- mode to figure out which port was used to call in so that it can
- determine any appropriate protocol parameters. This may return
- NULL if the port cannot be determined, which will just mean that no
- protocol parameters are applied. The name returned should be the
- sort of name that would appear in the port file. This should set
- *pftcp_port to TRUE if it can determine that the port is a TCP
- connection rather than a normal serial port. The return value (if
- not NULL) should point to a static buffer. */
-extern const char *zsysdep_port_name P((boolean *pftcp_port));
-
-/* Expand a file name on the local system. On Unix, if the zfile
- argument begins with ~user/ it goes in that users home directory,
- and if it begins with ~/ it goes in the public directory (the
- public directory is passed to this routine, since each system may
- have its own public directory). Similar conventions may be
- desirable on other systems. This should always return an absolute
- path name, probably in the public directory. It should return NULL
- on error; otherwise the return value should be allocated using
- zbufcpy or zbufalc. If pfbadname is not NULL, then if the function
- returns NULL *pfbadname should be set to TRUE if the error is just
- that the file name is badly specified; *pfbadname should be set to
- FALSE for some sort of internal error. */
-extern char *zsysdep_local_file P((const char *zname,
- const char *zpubdir,
- boolean *pfbadname));
-
-/* Return whether a file name is in a directory, and check for read or
- write access. This should check whether zfile is within zdir (or
- is zdir itself). If it is not, it should return FALSE. If zfile
- is in zdir, then fcheck indicates whether further checking should
- be done. If fcheck is FALSE, no further checking is done.
- Otherwise, if freadable is TRUE the user zuser should have search
- access to all directories from zdir down to zfile and should have
- read access on zfile itself (if zfile does not exist, or is not a
- regular file, this function may return FALSE but does not have to).
- If freadable is FALSE, the user zuser should have search access to
- all directories from zdir down to zfile and should have write
- access on zfile (which may be a directory, or may not actually
- exist, which is acceptable). The zuser argument may be NULL, in
- which case the check should be made for any user, not just zuser.
- There is no way for this function to return error. */
-extern boolean fsysdep_in_directory P((const char *zfile,
- const char *zdir,
- boolean fcheck,
- boolean freadable,
- const char *zuser));
-
-/* Return TRUE if a file exists, FALSE otherwise. There is no way to
- return error. */
-extern boolean fsysdep_file_exists P((const char *zfile));
-
-/* Start up a program. If the ffork argument is true, this should
- spawn a new process and return. If the ffork argument is false,
- this may either return or not. The three string arguments may be
- catenated together to form the program to execute; I did it this
- way to make it easy to call execl(2), and because I never needed
- more than two arguments. The program will always be "uucico" or
- "uuxqt". The return value should be TRUE on success, FALSE on
- error. */
-extern boolean fsysdep_run P((boolean ffork, const char *zprogram,
- const char *zarg1, const char *zarg2));
-
-/* Send a mail message. This function will be passed an array of
- strings. All necessary newlines are already included; the strings
- should simply be concatenated together to form the mail message.
- It should return FALSE on error, although the return value is often
- ignored. */
-extern boolean fsysdep_mail P((const char *zto, const char *zsubject,
- int cstrs, const char **paz));
-
-/* Get the time in seconds since some epoch. The actual epoch is
- unimportant, so long as the time values are consistent across
- program executions and the value is never negative. If the
- pimicros argument is not NULL, it should be set to the number of
- microseconds (if this is not available, *pimicros should be set to
- zero). */
-extern long ixsysdep_time P((long *pimicros));
-
-/* Get the time in seconds and microseconds (millionths of a second)
- since some epoch. The actual epoch is not important, and it may
- change in between program invocations; this is provided because on
- Unix the times function may be used. If microseconds can not be
- determined, *pimicros can just be set to zero. */
-extern long ixsysdep_process_time P((long *pimicros));
-
-/* Parse the value returned by ixsysdep_time into a struct tm. I
- assume that this structure is defined in <time.h>. This is
- basically just localtime, except that the ANSI function takes a
- time_t which may not be what is returned by ixsysdep_time. */
-extern void usysdep_localtime P((long itime, struct tm *q));
-
-/* Sleep for a number of seconds. */
-extern void usysdep_sleep P((int cseconds));
-
-/* Pause for half a second, or 1 second if subsecond sleeps are not
- possible. */
-extern void usysdep_pause P((void));
-
-/* Lock a remote system. This should return FALSE if the system is
- already locked (no error should be reported). */
-extern boolean fsysdep_lock_system P((const struct uuconf_system *qsys));
-
-/* Unlock a remote system. This should return FALSE on error
- (although the return value is generally ignored). */
-extern boolean fsysdep_unlock_system P((const struct uuconf_system *qsys));
-
-/* Get the conversation sequence number for a remote system, and
- increment it for next time. This should return -1 on error. */
-extern long ixsysdep_get_sequence P((const struct uuconf_system *qsys));
-
-/* Get the status of a remote system. This should return FALSE on
- error. Otherwise it should set *qret to the status. If no status
- information is available, this should set *qret to sensible values
- and return TRUE. If pfnone is not NULL, then it should be set to
- TRUE if no status information was available or FALSE otherwise. */
-extern boolean fsysdep_get_status P((const struct uuconf_system *qsys,
- struct sstatus *qret,
- boolean *pfnone));
-
-/* Set the status of a remote system. This should return FALSE on
- error. The system will be locked before this call is made. */
-extern boolean fsysdep_set_status P((const struct uuconf_system *qsys,
- const struct sstatus *qset));
-
-/* See whether a remote system is permitted to log in. This is just
- to support the remote.unknown shell script for HDB. The zscript
- argument is the script name, as return by uuconf_remote_unknown.
- The zsystem argument is the name given by the remote system. If
- the system is not permitted to log in, this function should log an
- error and return FALSE. */
-extern boolean fsysdep_unknown_caller P((const char *zscript,
- const char *zsystem));
-
-/* Check whether there is work for a remote system. It should return
- TRUE if there is work, FALSE otherwise; there is no way to indicate
- an error. */
-extern boolean fsysdep_has_work P((const struct uuconf_system *qsys));
-
-/* Initialize the work scan. This will be called before
- fsysdep_get_work. The bgrade argument is the minimum grade of
- execution files that should be considered (e.g. a bgrade of 'd'
- will allow all grades from 'A' to 'Z' and 'a' to 'd'). This
- function should return FALSE on error. */
-extern boolean fsysdep_get_work_init P((const struct uuconf_system *qsys,
- int bgrade));
-
-/* Get the next command to be executed for a remote system. The
- bgrade argument will be the same as for fsysdep_get_work_init;
- probably only one of these functions will use it, namely the
- function for which it is more convenient. This should return FALSE
- on error. The structure pointed to by qcmd should be filled in.
- The strings may point into a static buffer; they will be copied out
- if necessary. If there is no more work, this should set qcmd->bcmd
- to 'H' and return TRUE. This should set qcmd->pseq to something
- which can be passed to fsysdep_did_work to remove the job from the
- queue when it has been completed. This may set qcmd->bcmd to 'P'
- to represent a poll file; the main code will just pass the pseq
- element of such a structure to fsysdep_did_work if the system is
- called. */
-extern boolean fsysdep_get_work P((const struct uuconf_system *qsys,
- int bgrade, struct scmd *qcmd));
-
-/* Remove a job from the work queue. This must also remove the
- temporary file used for a send command, if there is one. It should
- return FALSE on error. */
-extern boolean fsysdep_did_work P((pointer pseq));
-
-/* Save the temporary file for a send command. This function should
- return a string that will be put into a mail message. On success
- this string should say something like ``The file has been saved as
- ...''. On failure it could say something like ``The file could not
- be saved because ...''. If there is no temporary file, or for some
- reason it's not appropriate to include a message, this function
- should just return NULL. This function is used when a file send
- fails for some reason, to make sure that we don't completely lost
- the file. */
-extern const char *zsysdep_save_temp_file P((pointer pseq));
-
-/* Save a file in a location used to hold corrupt files. This is
- called if a bad execution file is found by uuxqt. This should
- return the new name of the file (allocated by zbufalc), or NULL if
- the move failed (in which the original file should remain). */
-extern char *zsysdep_save_corrupt_file P((const char *zfile));
-
-/* Save a file in a location used to hold failed execution files.
- This is called if a uuxqt execution fails. This should return the
- new name of the file (allocated by zbufalc), or NULL if the move
- failed (in which case the original file should remain). */
-extern char *zsysdep_save_failed_file P((const char *zfile));
-
-/* Cleanup anything left over by fsysdep_get_work_init and
- fsysdep_get_work. This may be called even though
- fsysdep_get_work_init has not been. */
-extern void usysdep_get_work_free P((const struct uuconf_system *qsys));
-
-/* Add a base name to a file if it is a directory. If zfile names a
- directory, then return a string naming a file within the directory
- with the base file name of zname. This should return NULL on
- error. */
-extern char *zsysdep_add_base P((const char *zfile,
- const char *zname));
-
-/* Get a file name from the spool directory. This should return NULL
- on error. The pseq argument is TRUE if the file was found from
- searching the work directory; this is, unfortunately, needed to
- support SVR4 spool directories. */
-extern char *zsysdep_spool_file_name P((const struct uuconf_system *qsys,
- const char *zfile,
- pointer pseq));
-
-/* Make necessary directories. This should create all non-existent
- directories for a file. If the fpublic argument is TRUE, anybody
- should be permitted to create and remove files in the directory;
- otherwise anybody can list the directory, but only the UUCP system
- can create and remove files. It should return FALSE on error. */
-extern boolean fsysdep_make_dirs P((const char *zfile, boolean fpublic));
-
-/* Create a stdio file, setting appropriate protection. If the
- fpublic argument is TRUE, the file is made publically accessible;
- otherwise it is treated as a private data file. If the fappend
- argument is TRUE, the file is opened in append mode; otherwise any
- previously existing file of the same name is removed. If the
- fmkdirs argument is TRUE, then any necessary directories should
- also be created. On a system in which file protections are
- unimportant and the necessary directories exist, this may be
- implemented as
-
- fopen (zfile, fappend ? "a" : "w");
-
- */
-extern FILE *esysdep_fopen P((const char *zfile, boolean fpublic,
- boolean fappend, boolean fmkdirs));
-
-/* Open a file, using the access permission of the user who invoked
- the program. The frd argument is TRUE if the file should be opened
- for reading, and the fbinary argument is TRUE if the file should be
- opened as a binary file (this is ignored on Unix, since there all
- files are binary files). This returns an openfile_t, not a FILE *.
- This is supposed to be able to open a file even if it can not be
- read by the uucp user. This is not possible on some older Unix
- systems. */
-extern openfile_t esysdep_user_fopen P((const char *zfile,
- boolean frd, boolean fbinary));
-
-/* Open a file to send to another system; the qsys argument is the
- system the file is being sent to. If fcheck is TRUE, it should
- make sure that the file is readable by zuser (if zuser is NULL the
- file must be readable by anybody). This is to eliminate a window
- between fsysdep_in_directory and esysdep_open_send. If an error
- occurs, it should return EFILECLOSED. */
-extern openfile_t esysdep_open_send P((const struct uuconf_system *qsys,
- const char *zname,
- boolean fcheck,
- const char *zuser));
-
-/* Return a temporary file name to receive into. This file will be
- opened by esysdep_open_receive. The qsys argument is the system
- the file is coming from, the zto argument is the name the file will
- have after it has been fully received, the ztemp argument, if it is
- not NULL, is from the command sent by the remote system, and the
- frestart argument is TRUE if the protocol and remote system permit
- file transfers to be restarted. The return value must be freed
- using ubuffree. The function should return NULL on error. */
-extern char *zsysdep_receive_temp P((const struct uuconf_system *qsys,
- const char *zfile,
- const char *ztemp,
- boolean frestart));
-
-/* Open a file to receive from another system. The zreceive argument
- is the return value of zsysdep_receive_temp with the same qsys,
- zfile and ztemp arguments. If the function can determine that this
- file has already been partially received, it should set *pcrestart
- to the number of bytes that have been received. If the file has
- not been partially received, *pcrestart should be set to -1.
- pcrestart will be passed in as NULL if file restart is not
- supported by the protocol or the remote system. The function
- should return EFILECLOSED on error. After the file is written,
- fsysdep_move_file will be called to move the file to its final
- destination, and to set the correct file mode. */
-extern openfile_t esysdep_open_receive P((const struct uuconf_system *qsys,
- const char *zto,
- const char *ztemp,
- const char *zreceive,
- long *pcrestart));
-
-/* Move a file. This is used to move a received file to its final
- location. The zto argument is the file to create. The zorig
- argument is the name of the file to move. If fmkdirs is TRUE, then
- any necessary directories are created; fpublic indicates whether
- they should be publically writeable or not. If fcheck is TRUE,
- this should make sure the directory is writeable by the user zuser
- (if zuser is NULL, then it must be writeable by any user); this is
- to avoid a window of vulnerability between fsysdep_in_directory and
- fsysdep_move_file. This function should return FALSE on error, in
- which case the zorig file should still exist. */
-extern boolean fsysdep_move_file P((const char *zorig, const char *zto,
- boolean fmkdirs, boolean fpublic,
- boolean fcheck, const char *zuser));
-
-/* Change the mode of a file. The imode argument is a Unix mode.
- This should return FALSE on error. */
-extern boolean fsysdep_change_mode P((const char *zfile,
- unsigned int imode));
-
-/* Truncate a file which we are receiving into. This may be done by
- closing the original file, removing it and reopening it. This
- should return FALSE on error. */
-extern openfile_t esysdep_truncate P((openfile_t e, const char *zname));
-
-/* Sync a file to disk. If this fails it should log an error using
- the zmsg parameter, and return FALSE. This is controlled by the
- FSYNC_ON_CLOSE macro in policy.h. */
-extern boolean fsysdep_sync P((openfile_t e, const char *zmsg));
-
-/* It is possible for the acknowledgement of a received file to be
- lost. The sending system will then now know that the file was
- correctly received, and will send it again. This can be a problem
- particularly with protocols which support channels, since they may
- send several small files in a single window, all of which may be
- received correctly although the sending system never sees the
- acknowledgement. If these files involve an execution, the
- execution will happen twice, which will be bad.
-
- This function is called when a file is completely received. It is
- supposed to try and remember the reception, in case the connection
- is lost. It is passed the system, the file name to receive to, and
- the temporary file name from the sending system. It should return
- FALSE on error. */
-extern boolean fsysdep_remember_reception P((const struct uuconf_system *qsys,
- const char *zto,
- const char *ztemp));
-
-/* This function is called to see if a file has already been received
- successfully. It gets the same arguments as
- fsysdep_remember_reception. It should return TRUE if the file was
- already received, FALSE otherwise. There is no way to report
- error. */
-extern boolean fsysdep_already_received P((const struct uuconf_system *qsys,
- const char *zto,
- const char *ztemp));
-
-/* This function is called when it is no longer necessary to remember
- that a file has been received. This will be called when the
- protocol knows that the receive message has been acknowledged. It
- gets the same arguments as fsysdep_remember_reception. it should
- return FALSE on error. */
-extern boolean fsysdep_forget_reception P((const struct uuconf_system *qsys,
- const char *zto,
- const char *ztemp));
-
-/* Start expanding a wildcarded file name. This should return FALSE
- on error; otherwise subsequent calls to zsysdep_wildcard should
- return file names. */
-extern boolean fsysdep_wildcard_start P((const char *zfile));
-
-/* Get the next wildcard name. This should return NULL when there are
- no more names to return. The return value should be freed using
- ubuffree. The argument should be the same as that to
- fsysdep_wildcard_start. There is no way to return error. */
-extern char *zsysdep_wildcard P((const char *zfile));
-
-/* Finish getting wildcard names. This may be called before or after
- zsysdep_wildcard has returned NULL. It should return FALSE on
- error. */
-extern boolean fsysdep_wildcard_end P((void));
-
-/* Prepare to execute a bunch of file transfer requests. This should
- make an entry in the spool directory so that the next time uucico
- is started up it will transfer these files. The bgrade argument
- specifies the grade of the commands. The commands themselves are
- in the pascmds array, which has ccmds entries. The function should
- return NULL on error, or the jobid on success. The jobid is a
- string that may be printed or passed to fsysdep_kill_job and
- related functions, but is otherwise uninterpreted. */
-extern char *zsysdep_spool_commands P((const struct uuconf_system *qsys,
- int bgrade, int ccmds,
- const struct scmd *pascmds));
-
-/* Get a file name to use for a data file to be copied to another
- system. The ztname, zdname and zxname arguments will all either be
- NULL or point to an array of CFILE_NAME_LEN characters in length.
- The ztname array should be set to a temporary file name that could
- be passed to zsysdep_spool_file_name to retrieve the return value
- of this function; this will be appropriate for the temporary name
- in a send request. The zdname array should be set to a data file
- name that is appropriate for the spool directory of the other
- system; this will be appropriate for the name of the destination
- file in a send request of a data file for an execution of some
- sort. The zxname array should be set to an execute file name that
- is appropriate for the other system. The zlocalname argument is
- the name of the local system as seen by the remote system, the
- bgrade argument is the grade, and fxqt is TRUE if this file is
- going to become an execution file. This should return NULL on
- error. */
-#define CFILE_NAME_LEN (15)
-
-extern char *zsysdep_data_file_name P((const struct uuconf_system *qsys,
- const char *zlocalname,
- int bgrade, boolean fxqt,
- char *ztname, char *zdname,
- char *zxname));
-
-/* Get a name for a local execute file. This is used by uux for a
- local command with remote files. Returns NULL on error. */
-extern char *zsysdep_xqt_file_name P((void));
-
-/* Beginning getting execute files. To get a list of execute files,
- first fsysdep_get_xqt_init is called, then zsysdep_get_xqt is
- called several times until it returns NULL, then finally
- usysdep_get_xqt_free is called. If the zsystem argument is not
- NULL, it is the name of a system for which execution files are
- desired. */
-extern boolean fsysdep_get_xqt_init P((const char *zsystem));
-
-/* Get the next execute file. This should return NULL when finished
- (with *pferr set to FALSE). The zsystem argument should be the
- same string as that passed to fsysdep_get_xqt_init. On an error
- this should return NULL with *pferr set to TRUE. This should set
- *pzsystem to the name of the system for which the execute file was
- created; this is not guaranteed to match the zsystem argument--that
- must be double checked by the caller. Both the return value and
- *pzsystem should be freed using ubuffree. */
-extern char *zsysdep_get_xqt P((const char *zsystem, char **pzsystem,
- boolean *pferr));
-
-/* Clean up after getting execute files. The zsystem argument should
- be the same string as that passed to fsysdep_get_xqt_init. */
-extern void usysdep_get_xqt_free P((const char *zsystem));
-
-/* Get the absolute pathname of a command to execute. This is given
- the legal list of commands (which may be the special case "ALL")
- and the path. It must return an absolute pathname to the command.
- If it gets an error it should set *pferr to TRUE and return NULL;
- if the command is not found it should set *pferr to FALSE and
- return NULL. */
-extern char *zsysdep_find_command P((const char *zcmd, char **pzcmds,
- char **pzpath, boolean *pferr));
-
-/* Expand file names for uuxqt. This exists because uuxqt on Unix has
- to expand file names which begin with a ~. It does not want to
- expand any other type of file name, and it turns a double ~ into a
- single one without expanding. If this returns NULL, the file does
- not need to be changed; otherwise it returns a zbufalc'ed string.
- There is no way to report error. */
-extern char *zsysdep_xqt_local_file P((const struct uuconf_system *qsys,
- const char *zfile));
-
-#if ! ALLOW_FILENAME_ARGUMENTS
-/* Check an argument to an execution command to make sure that it
- doesn't refer to a file name that may not be accessed. This should
- check the argument to see if it is a filename. If it is, it should
- either reject it out of hand or it should call fin_directory_list
- on the file with both qsys->zremote_receive and qsys->zremote_send.
- If the file is rejected, it should log an error and return FALSE.
- Otherwise it should return TRUE. */
-extern boolean fsysdep_xqt_check_file P((const struct uuconf_system *qsys,
- const char *zfile));
-#endif /* ! ALLOW_FILENAME_ARGUMENTS */
-
-/* Run an execute file. The arguments are:
-
- qsys -- system for which execute file was created
- zuser -- user who requested execution
- pazargs -- list of arguments to command (element 0 is command)
- zfullcmd -- command and arguments stuck together in one string
- zinput -- file name for standard input (may be NULL)
- zoutput -- file name for standard output (may be NULL)
- fshell -- if TRUE, use /bin/sh to execute file
- ilock -- return value of ixsysdep_lock_uuxqt
- pzerror -- set to name of standard error file
- pftemp -- set to TRUE if error is temporary, FALSE otherwise
-
- If fshell is TRUE, the command should be executed with /bin/sh
- (obviously, this can only really be done on Unix systems). If an
- error occurs this should return FALSE and set *pftemp
- appropriately. *pzerror should be freed using ubuffree. */
-extern boolean fsysdep_execute P((const struct uuconf_system *qsys,
- const char *zuser,
- const char **pazargs,
- const char *zfullcmd,
- const char *zinput,
- const char *zoutput,
- boolean fshell,
- int ilock,
- char **pzerror,
- boolean *pftemp));
-
-/* Lock for uuxqt execution. If the cmaxuuxqts argument is not zero,
- this should make sure that no more than cmaxuuxqts uuxqt processes
- are running at once. Also, only one uuxqt may execute a particular
- command (specified by the -c option) at a time. If zcmd is not
- NULL, it is a command that must be locked. This should return a
- nonnegative number which will be passed to other routines,
- including fsysdep_unlock_uuxqt, or -1 on error. */
-extern int ixsysdep_lock_uuxqt P((const char *zcmd,
- int cmaxuuxqts));
-
-/* Unlock a uuxqt process. This is passed the return value of
- ixsysdep_lock_uuxqt, as well as the arguments passed to
- ixsysdep_lock_uuxqt. It may return FALSE on error, but at present
- the return value is ignored. */
-extern boolean fsysdep_unlock_uuxqt P((int iseq, const char *zcmd,
- int cmaxuuxqts));
-
-/* See whether a particular uuxqt command is locked. This should
- return TRUE if the command is locked (because ixsysdep_lock_uuxqt
- was called with it as an argument), FALSE otherwise. There is no
- way to return error. */
-extern boolean fsysdep_uuxqt_locked P((const char *zcmd));
-
-/* Lock an execute file in order to execute it. This should return
- FALSE if the execute file is already locked. There is no way to
- return error. */
-extern boolean fsysdep_lock_uuxqt_file P((const char *zfile));
-
-/* Unlock an execute file. This should return FALSE on error. */
-extern boolean fsysdep_unlock_uuxqt_file P((const char *zfile));
-
-/* Lock the execution directory. The ilock argument is the return
- value of ixsysdep_lock_uuxqt. This should return FALSE if the
- directory is already locked. There is no way to return error. */
-extern boolean fsysdep_lock_uuxqt_dir P((int ilock));
-
-/* Remove all files in the execution directory, and unlock it. This
- should return FALSE on error. */
-extern boolean fsysdep_unlock_uuxqt_dir P((int ilock));
-
-/* Move files into or out of the execution directory. The code will
- already have checked that all the files exist. The elements in the
- pzfrom array will be complete filenames, and the elements in the
- pzto array will be either NULL (in which case the file should not
- be moved) or simple base names. If fto is TRUE, the files in
- pzfrom should be moved to pzto; otherwise, the files in pzto should
- be moved to pzfrom (this is used if a temporary failure occurs, in
- which case the execution will be retried later). If pzinput and
- *pzinput are not NULL, then it is the name of the standard input
- file; if it is the same as any element of pzfrom, then *pzinput
- should be set to the zbufcpy of the corresponding pzto value, if
- any. */
-extern boolean fsysdep_move_uuxqt_files P((int cfiles,
- const char *const *pzfrom,
- const char *const *pzto,
- boolean fto, int ilock,
- char **pzinput));
-
-/* Expand a file name on the local system, defaulting to the current
- directory. This is just like zsysdep_local_file, except that
- relative files are placed in the working directory the program
- started in rather than in the public directory. This should return
- NULL on error. */
-extern char *zsysdep_local_file_cwd P((const char *zname,
- const char *zpubdir,
- boolean *pfbadname));
-
-/* Add the working directory to a file name. The named file is
- actually on a remote system. If the file already has a directory,
- it should not be changed. This should return NULL on error. */
-extern char *zsysdep_add_cwd P((const char *zfile));
-
-/* See whether a file name will need the current working directory
- when zsysdep_local_file_cwd or zsysdep_add_cwd is called on it.
- This will be called before usysdep_initialize. It should just
- check whether the argument is an absolute path. See the comment
- above usysdep_initialize in this file for an explanation of why
- things are done this way. */
-extern boolean fsysdep_needs_cwd P((const char *zfile));
-
-/* Get the base name of a file. The file will be a local file name,
- and this function should return the base file name, ideally in a
- form which will make sense on most systems; it will be used if the
- destination of a uucp is a directory. */
-extern char *zsysdep_base_name P((const char *zfile));
-
-/* Return a filename within a directory. */
-extern char *zsysdep_in_dir P((const char *zdir, const char *zfile));
-
-/* Get the mode of a file. This should return a Unix style file mode.
- It should return 0 on error. */
-extern unsigned int ixsysdep_file_mode P((const char *zfile));
-
-/* See whether the user has access to a file. This is called by uucp
- and uux to prevent copying of a file which uucp can read but the
- user cannot. If access is denied, this should log an error message
- and return FALSE. */
-extern boolean fsysdep_access P((const char *zfile));
-
-/* See whether the daemon has access to a file. This is called by
- uucp and uux when a file is queued up for transfer without being
- copied into the spool directory. It is merely an early error
- check, as the daemon would of course discover the error itself when
- it tried the transfer. If access would be denied, this should log
- an error message and return FALSE. */
-extern boolean fsysdep_daemon_access P((const char *zfile));
-
-/* Translate a destination from system!user to a place in the public
- directory where uupick will get the file. On Unix this produces
- system!~/receive/user/localname, and that's probably what it has to
- produce on any other system as well. Returns NULL on a usage
- error, or otherwise returns string allocated by zbufcpy. */
-extern char *zsysdep_uuto P((const char *zdest,
- const char *zlocalname));
-
-/* Return TRUE if a pathname exists and is a directory. */
-extern boolean fsysdep_directory P((const char *zpath));
-
-/* Walk a directory tree. The zdir argument is the directory to walk.
- The pufn argument is a function to call on each regular file in the
- tree. The first argument to pufn should be the full filename; the
- second argument to pufn should be the filename relative to zdir;
- the third argument to pufn should be the pinfo argument to
- usysdep_walk_tree. The usysdep_walk_tree function should return
- FALSE on error. */
-extern boolean usysdep_walk_tree P((const char *zdir,
- void (*pufn) P((const char *zfull,
- const char *zrelative,
- pointer pinfo)),
- pointer pinfo));
-
-/* Return the jobid of a work file, given the sequence value. On
- error this should log an error and return NULL. The jobid is a
- string which may be printed out and read in and passed to
- fsysdep_kill_job, etc., but is not otherwise interpreted. */
-extern char *zsysdep_jobid P((const struct uuconf_system *qsys,
- pointer pseq));
-
-/* See whether the current user is privileged. Privileged users are
- permitted to kill jobs submitted by another user, and they are
- permitted to use the -u argument to uucico; other uses of this call
- may be added later. This should return TRUE if permission is
- granted, FALSE otherwise. */
-extern boolean fsysdep_privileged P((void));
-
-/* Kill a job, given the jobid. This should remove all associated
- files and in general eliminate the job completely. On error it
- should log an error message and return FALSE. */
-extern boolean fsysdep_kill_job P((pointer puuconf,
- const char *zjobid));
-
-/* Rejuvenate a job, given the jobid. If possible, this should update
- the time associated with the job such that it will not be
- eliminated by uustat -K or similar programs that check the creation
- time. This should affect the return value of ixsysdep_work_time.
- On error it should log an error message and return FALSE. */
-extern boolean fsysdep_rejuvenate_job P((pointer puuconf,
- const char *zjobid));
-
-/* Get the time a job was queued, given the sequence number. There is
- no way to indicate error. The return value must use the same epoch
- as ixsysdep_time. */
-extern long ixsysdep_work_time P((const struct uuconf_system *qsys,
- pointer pseq));
-
-/* Get the time a file was created. This is called by uustat on
- execution files. There is no way to indicate error. The return
- value must use the same epoch as ixsysdep_time. */
-extern long ixsysdep_file_time P((const char *zfile));
-
-/* Touch a file to make it appear as though it was created at the
- current time. This is called by uustat on execution files. On
- error this should log an error message and return FALSE. */
-extern boolean fsysdep_touch_file P((const char *zfile));
-
-/* Get the size in bytes of a file. If this file does not exist, this
- should not give an error message, but should return -1. If some
- other error occurs, this should return -2. */
-extern long csysdep_size P((const char *zfile));
-
-/* Return the amount of free space on the containing the given file
- name (the file may or may not exist). If the amount of free space
- cannot be determined, the function should return -1. */
-extern long csysdep_bytes_free P((const char *zfile));
-
-/* Start getting status information for all systems with available
- status information. There may be status information for unknown
- systems, which is why this series of functions is used. The phold
- argument is used to pass information around, to possibly avoid the
- use of static variables. On error this should log an error and
- return FALSE. */
-extern boolean fsysdep_all_status_init P((pointer *phold));
-
-/* Get status information for the next system. This should return the
- system name and fill in the qstat argument. The phold argument
- will be that set by fsysdep_all_status_init. On error this should
- log an error, set *pferr to TRUE, and return NULL. */
-extern char *zsysdep_all_status P((pointer phold, boolean *pferr,
- struct sstatus *qstat));
-
-/* Free up anything allocated by fsysdep_all_status_init and
- zsysdep_all_status. The phold argument is that set by
- fsysdep_all_status_init. */
-extern void usysdep_all_status_free P((pointer phold));
-
-/* Display the process status of all processes holding lock files.
- This is uustat -p. The return value is passed to usysdep_exit. */
-extern boolean fsysdep_lock_status P((void));
-
-/* Return TRUE if the user has legitimate access to the port. This is
- used by cu to control whether the user can open a port directly,
- rather than merely being able to dial out on it. Opening a port
- directly allows the modem to be reprogrammed. */
-extern boolean fsysdep_port_access P((struct uuconf_port *qport));
-
-/* Return whether the given port could be named by the given line. On
- Unix, the line argument would be something like "ttyd0", and this
- function should return TRUE if the named port is "/dev/ttyd0". */
-extern boolean fsysdep_port_is_line P((struct uuconf_port *qport,
- const char *zline));
-
-/* Set the terminal into raw mode. In this mode no input characters
- should be treated specially, and characters should be made
- available as they are typed. The original terminal mode should be
- saved, so that it can be restored by fsysdep_terminal_restore. If
- flocalecho is TRUE, then local echoing should still be done;
- otherwise echoing should be disabled. This function returns FALSE
- on error. */
-extern boolean fsysdep_terminal_raw P((boolean flocalecho));
-
-/* Restore the terminal back to the original setting, before
- fsysdep_terminal_raw was called. Returns FALSE on error. */
-extern boolean fsysdep_terminal_restore P((void));
-
-/* Read a line from the terminal. The fsysdep_terminal_raw function
- will have been called. This should print the zprompt argument
- (unless it is NULL) and return the line, allocated by zbufcpy, or
- NULL on error. */
-extern char *zsysdep_terminal_line P((const char *zprompt));
-
-/* Write a line to the terminal, ending with a newline. This is
- basically just puts (zline, stdout), except that the terminal will
- be in raw mode, so on ASCII Unix systems the line needs to end with
- \r\n. */
-extern boolean fsysdep_terminal_puts P((const char *zline));
-
-/* If faccept is TRUE, permit the user to generate signals from the
- terminal. If faccept is FALSE, turn signals off again. After
- fsysdep_terminal_raw is called, signals should be off. Return
- FALSE on error. */
-extern boolean fsysdep_terminal_signals P((boolean faccept));
-
-/* The cu program expects the system dependent code to handle the
- details of copying data from the communications port to the
- terminal. This should be set up by fsysdep_cu_init, and done while
- fsysdep_cu is called. It is permissible to do it on a continual
- basis (on Unix a subprocess handles it) so long as the copying can
- be stopped by the fsysdep_cu_copy function.
-
- The fsysdep_cu_init function does any system dependent
- initialization needed for this. */
-extern boolean fsysdep_cu_init P((struct sconnection *qconn));
-
-/* Copy all data from the communications port to the terminal, and all
- data from the terminal to the communications port. Keep this up
- until the escape character *zCuvar_escape is seen. Set *pbcmd to
- the character following the escape character; after the escape
- character, zlocalname should be printed, possibly after a delay.
- If two escape characters are entered in sequence, this function
- should send a single escape character to the port, and not return.
- Returns FALSE on error. */
-extern boolean fsysdep_cu P((struct sconnection *qconn,
- char *pbcmd,
- const char *zlocalname));
-
-/* If fcopy is TRUE, start copying data from the communications port
- to the terminal. If fcopy is FALSE, stop copying data. This
- function may be called several times during a cu session. It
- should return FALSE on error. */
-extern boolean fsysdep_cu_copy P((boolean fcopy));
-
-/* Stop copying data from the communications port to the terminal, and
- generally clean up after fsysdep_cu_init and fsysdep_cu. Returns
- FALSE on error. */
-extern boolean fsysdep_cu_finish P((void));
-
-/* Run a shell command. If zcmd is NULL, or *zcmd == '\0', just
- start up a shell. The second argument is one of the following
- values. This should return FALSE on error. */
-enum tshell_cmd
-{
- /* Attach stdin and stdout to the terminal. */
- SHELL_NORMAL,
- /* Attach stdout to the communications port, stdin to the terminal. */
- SHELL_STDOUT_TO_PORT,
- /* Attach stdin to the communications port, stdout to the terminal. */
- SHELL_STDIN_FROM_PORT,
- /* Attach both stdin and stdout to the communications port. */
- SHELL_STDIO_ON_PORT
-};
-
-extern boolean fsysdep_shell P((struct sconnection *qconn,
- const char *zcmd,
- enum tshell_cmd tcmd));
-
-/* Change directory. If zdir is NULL, or *zdir == '\0', change to the
- user's home directory. Return FALSE on error. */
-extern boolean fsysdep_chdir P((const char *zdir));
-
-/* Suspend the current process. This is only expected to work on Unix
- versions that support SIGTSTP. In general, people can just shell
- out. */
-extern boolean fsysdep_suspend P((void));
-
-/* Start getting files for uupick. The zsystem argument may be NULL
- to get files from all systems, or it may specify a particular
- system. The zpubdir argument is the public directory to use. This
- returns FALSE on error. */
-extern boolean fsysdep_uupick_init P((const char *zsystem,
- const char *zpubdir));
-
-/* Get the next file for uupick. This returns the basic file name.
- It sets *pzfull to the full name, and *pzfrom to the name of the
- system which sent this file over; both should be freed using
- ubuffree. *pzfull should be passed to ubuffree after it is no
- longer needed. The zsystem and zpubdir arguments should be the
- same as the arguments to fsysdep_uupick_init. This returns NULL
- when all files been returned. */
-extern char *zsysdep_uupick P((const char *zsystem, const char *zpubdir,
- char **pzfrom, char **pzfull));
-
-/* Clean up after getting files for uupick. */
-extern boolean fsysdep_uupick_free P((const char *zsystem,
- const char *zpubdir));
-
-/* Translate a local file name for uupick. On Unix this is just like
- zsysdep_local_file_cwd except that a file beginning with ~/ is
- placed in the user's home directory rather than in the public
- directory. */
-extern char *zsysdep_uupick_local_file P((const char *zfile,
- boolean *pfbadname));
-
-/* Remove a directory and all the files in it. */
-extern boolean fsysdep_rmdir P((const char *zdir));
-
-#endif /* ! defined (SYSTEM_H) */
diff --git a/gnu/libexec/uucp/common_sources/trans.h b/gnu/libexec/uucp/common_sources/trans.h
deleted file mode 100644
index d057ab2..0000000
--- a/gnu/libexec/uucp/common_sources/trans.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/* trans.h
- Header file for file and command transfer routines.
-
- Copyright (C) 1992, 1993, 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-/* The maximum possible number of channels. */
-#define IMAX_CHAN (16)
-
-/* The ifeatures field of the sdaemon structure is an or of the
- following values. These values are sent during the uucico
- handshake, and MUST NOT CHANGE. */
-
-/* File size negotiation. */
-#define FEATURE_SIZES (01)
-
-/* File transfer restart. */
-#define FEATURE_RESTART (02)
-
-/* The E (execute) command. */
-#define FEATURE_EXEC (04)
-
-/* Version 1.03: requires decimal size in S and R command. Needless
- to say, this should not be used by any new programs. */
-#define FEATURE_V103 (010)
-
-/* SVR4 UUCP: expects dummy string between notify field and size field
- in send command. There is probably some meaning to this string,
- but I don't know what it is. If I ever find out, this flag will
- still be used to indicate it. */
-#define FEATURE_SVR4 (020)
-
-/* This structure is used to hold information concerning the
- communication link established with the remote system. */
-
-struct sdaemon
-{
- /* Global uuconf pointer. */
- pointer puuconf;
- /* Configuration file name argument (from -I option). */
- const char *zconfig;
- /* How often to spawn uuxqt (from uuconf_runuuxqt). */
- int irunuuxqt;
- /* Remote system information. */
- const struct uuconf_system *qsys;
- /* Local name being used. */
- const char *zlocalname;
- /* Connection structure. */
- struct sconnection *qconn;
- /* Protocol being used. */
- const struct sprotocol *qproto;
- /* Number of channels being used. */
- int cchans;
- /* The largest file size permitted for a local request. */
- long clocal_size;
- /* The largest file size permitted for a remote request. */
- long cremote_size;
- /* The largest file size that may ever be transferred. */
- long cmax_ever;
- /* The remote system ulimit. */
- long cmax_receive;
- /* Number of bytes sent. */
- long csent;
- /* Number of bytes received. */
- long creceived;
- /* Number of execution files received since the last time we spawned
- uuxqt. */
- long cxfiles_received;
- /* Features supported by the remote side. */
- int ifeatures;
- /* TRUE if we should request the remote side to hang up. */
- boolean frequest_hangup;
- /* TRUE if the remote side requested a hangup. */
- boolean fhangup_requested;
- /* TRUE if we are hanging up. */
- boolean fhangup;
- /* TRUE if the local system is currently the master. */
- boolean fmaster;
- /* TRUE if the local system placed the call. */
- boolean fcaller;
- /* UUCONF_RELIABLE_* flags for the connection. */
- int ireliable;
- /* If fcaller is FALSE, the lowest grade which may be transferred
- during this call. */
- char bgrade;
-};
-
-/* This structure is used to hold a file or command transfer which is
- in progress. */
-
-struct stransfer
-{
- /* Next file transfer in queue. */
- struct stransfer *qnext;
- /* Previous file transfer in queue. */
- struct stransfer *qprev;
- /* Points to the queue this structure is on. */
- struct stransfer **pqqueue;
- /* The function to call to send some data. */
- boolean (*psendfn) P((struct stransfer *qtrans, struct sdaemon *qdaemon));
- /* The function to call when data is received. */
- boolean (*precfn) P((struct stransfer *qtrans, struct sdaemon *qdaemon,
- const char *zdata, size_t cdata));
- /* Type specific information. */
- pointer pinfo;
- /* TRUE if we are sending the file e (this is used to avoid a call
- to psendfn). */
- boolean fsendfile;
- /* TRUE if we are receiving the file e (this is used to avoid a call
- to precfn). */
- boolean frecfile;
- /* The file to read or write. */
- openfile_t e;
- /* The position we are at in the file. */
- long ipos;
- /* TRUE if we are waiting for a command string. */
- boolean fcmd;
- /* The command string we have so far. */
- char *zcmd;
- /* The length of the command string we have so far. */
- size_t ccmd;
- /* Local destination number. */
- int ilocal;
- /* Remote destination number. */
- int iremote;
- /* The command. */
- struct scmd s;
- /* A message to log when work starts. */
- char *zlog;
- /* The process time; imicros can be negative. */
- long isecs;
- long imicros;
- /* Number of bytes sent or received. */
- long cbytes;
-};
-
-/* Reasons that a file transfer might fail. */
-
-enum tfailure
-{
- /* No failure. */
- FAILURE_NONE,
- /* No permission for operation. */
- FAILURE_PERM,
- /* Can't open necessary file. */
- FAILURE_OPEN,
- /* Not enough space to receive file. */
- FAILURE_SIZE,
- /* File was received in a previous conversation. */
- FAILURE_RECEIVED
-};
-
-/* The main loop which talks to the remote system, passing transfer
- requests and file back and forth. */
-extern boolean floop P((struct sdaemon *qdaemon));
-
-/* Allocate a new transfer structure. */
-extern struct stransfer *qtransalc P((struct scmd *qcmd));
-
-/* Free a transfer structure. */
-extern void utransfree P((struct stransfer *qtrans));
-
-/* Queue up local requests. If pfany is not NULL, this sets *pfany to
- TRUE if there are, in fact, any local requests which can be done at
- this point. */
-extern boolean fqueue P((struct sdaemon *qdaemon, boolean *pfany));
-
-/* Clear away any queued requests. This may be called more than once
- at the end of a call. */
-extern void uclear_queue P((struct sdaemon *qdaemon));
-
-/* Queue a new transfer request made by the local system. */
-extern boolean fqueue_local P((struct sdaemon *qdaemon,
- struct stransfer *qtrans));
-
-/* Queue a new transfer request made by the remote system. */
-extern boolean fqueue_remote P((struct sdaemon *qdaemon,
- struct stransfer *qtrans));
-
-/* Queue a transfer request which wants to send something. */
-extern boolean fqueue_send P((struct sdaemon *qdaemon,
- struct stransfer *qtrans));
-
-/* Queue a transfer request which wants to receiving something. */
-extern boolean fqueue_receive P((struct sdaemon *qdaemon,
- struct stransfer *qtrans));
-
-/* Prepare to send a file by local or remote request. */
-extern boolean flocal_send_file_init P((struct sdaemon *qdaemon,
- struct scmd *qcmd));
-extern boolean fremote_send_file_init P((struct sdaemon *qdaemon,
- struct scmd *qcmd,
- int iremote));
-
-/* Prepare to receive a file by local or remote request. */
-extern boolean flocal_rec_file_init P((struct sdaemon *qdaemon,
- struct scmd *qcmd));
-extern boolean fremote_rec_file_init P((struct sdaemon *qdaemon,
- struct scmd *qcmd,
- int iremote));
-
-/* Prepare to request work by local or remote request. */
-extern boolean flocal_xcmd_init P((struct sdaemon *qdaemon,
- struct scmd *qcmd));
-extern boolean fremote_xcmd_init P((struct sdaemon *qdaemon,
- struct scmd *qcmd,
- int iremote));
-
-/* We have lost the connection; record any in progress file transfers
- in the statistics file and discard any temporary files. */
-extern void ufailed P((struct sdaemon *qdaemon));
-
-/* Check that there is enough disk space for a file receive. Return
- FALSE if there is not. */
-extern boolean frec_check_free P((struct stransfer *qtrans,
- long cfree_space));
-
-/* Discard the temporary file being used to receive a file, if
- appropriate. */
-extern boolean frec_discard_temp P((struct sdaemon *qdaemon,
- struct stransfer *qtrans));
-
-/* Handle data received by a protocol. This is called by the protocol
- specific routines as data comes in. The data is passed as two
- buffers because that is convenient for packet based protocols, but
- normally csecond will be 0. The ilocal argument is the local
- channel number, and the iremote argument is the remote channel
- number. Either may be -1, if the protocol does not have channels.
- The ipos argument is the position in the file, if the protocol
- knows it; for most protocols, this will be -1. The fallacked
- argument should be set to TRUE if the remote has acknowledged all
- outstanding data; see uwindow_acked, below, for details. This will
- set *pfexit to TRUE if there is something for the main loop to do.
- A file is complete is when a zero length buffer is passed (cfirst
- == 0). A command is complete when data containing a null byte is
- passed. This will return FALSE on error. If the protocol pfwait
- entry point should exit and let the top level loop continue,
- *pfexit will be set to TRUE (if pfexit is not NULL). This will not
- set *pfexit to FALSE, so the caller must do that. */
-extern boolean fgot_data P((struct sdaemon *qdaemon,
- const char *zfirst, size_t cfirst,
- const char *zsecond, size_t csecond,
- int ilocal, int iremote,
- long ipos, boolean fallacked,
- boolean *pfexit));
-
-/* This routine is called when an ack is sent for a file receive. */
-extern void usent_receive_ack P((struct sdaemon *qdaemon,
- struct stransfer *qtrans));
-
-/* A protocol may call this routine to indicate the packets have been
- acknowledged by the remote system. If the fallacked argument is
- TRUE, then all outstanding packets have been acknowledged; for
- convenience, this may also be indicated by passing fallacked as
- TRUE to fgot_data, above. Otherwise this routine should be called
- each time a complete window is acked by the remote system. The
- transfer code uses this information to keep track of when an
- acknowledgement of a file receive has been seen by the other side,
- so that file receives may be handled cleanly if the connection is
- lost. */
-extern void uwindow_acked P((struct sdaemon *qdaemon,
- boolean fallacked));
-
-/* Spawn a uuxqt process. The ffork argument is passed to
- fsysdep_run. If the zsys argument is not NULL, then -s zsys is
- passed to uuxqt. The zconfig argument is the name of the
- configuration file, from the -I option. */
-extern boolean fspawn_uuxqt P((boolean ffork, const char *zsys,
- const char *zconfig));
diff --git a/gnu/libexec/uucp/common_sources/util.c b/gnu/libexec/uucp/common_sources/util.c
deleted file mode 100644
index 0bc063b..0000000
--- a/gnu/libexec/uucp/common_sources/util.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* util.c
- A couple of UUCP utility functions.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char util_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-
-/* Get information for an unknown system. This will leave the name
- allocated on the heap. We could fix this by breaking the
- abstraction and adding the name to qsys->palloc. It makes sure the
- name is not too long, but takes no other useful action. */
-
-boolean
-funknown_system (puuconf, zsystem, qsys)
- pointer puuconf;
- const char *zsystem;
- struct uuconf_system *qsys;
-{
- char *z;
- int iuuconf;
-
- if (strlen (zsystem) <= cSysdep_max_name_len)
- z = zbufcpy (zsystem);
- else
- {
- char **pznames, **pz;
- boolean ffound;
-
- z = zbufalc (cSysdep_max_name_len + 1);
- memcpy (z, zsystem, cSysdep_max_name_len);
- z[cSysdep_max_name_len] = '\0';
-
- iuuconf = uuconf_system_names (puuconf, &pznames, TRUE);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- ffound = FALSE;
- for (pz = pznames; *pz != NULL; pz++)
- {
- if (strcmp (*pz, z) == 0)
- ffound = TRUE;
- xfree ((pointer) *pz);
- }
- xfree ((pointer) pznames);
-
- if (ffound)
- {
- ubuffree (z);
- return FALSE;
- }
- }
-
- iuuconf = uuconf_system_unknown (puuconf, qsys);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- ubuffree (z);
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- for (; qsys != NULL; qsys = qsys->uuconf_qalternate)
- qsys->uuconf_zname = z;
-
- return TRUE;
-}
-
-/* Remove all occurrences of the local system name followed by an
- exclamation point from the front of a string, returning the new
- string. This is used by uucp and uux. */
-
-char *
-zremove_local_sys (qlocalsys, z)
- struct uuconf_system *qlocalsys;
- char *z;
-{
- size_t clen;
- char *zexclam;
-
- clen = strlen (qlocalsys->uuconf_zname);
- zexclam = strchr (z, '!');
- while (zexclam != NULL)
- {
- if (z == zexclam
- || (zexclam - z == clen
- && strncmp (z, qlocalsys->uuconf_zname, clen) == 0))
- ;
- else if (qlocalsys->uuconf_pzalias == NULL)
- break;
- else
- {
- char **pzal;
-
- for (pzal = qlocalsys->uuconf_pzalias; *pzal != NULL; pzal++)
- if (strlen (*pzal) == zexclam - z
- && strncmp (z, *pzal, (size_t) (zexclam - z)) == 0)
- break;
- if (*pzal == NULL)
- break;
- }
- z = zexclam + 1;
- zexclam = strchr (z, '!');
- }
-
- return z;
-}
-
-/* See whether a file is in a directory list, and make sure the user
- has appropriate access. */
-
-boolean
-fin_directory_list (zfile, pzdirs, zpubdir, fcheck, freadable, zuser)
- const char *zfile;
- char **pzdirs;
- const char *zpubdir;
- boolean fcheck;
- boolean freadable;
- const char *zuser;
-{
- boolean fmatch;
- char **pz;
-
- fmatch = FALSE;
-
- for (pz = pzdirs; *pz != NULL; pz++)
- {
- char *zuse;
-
- if (pz[0][0] == '!')
- {
- zuse = zsysdep_local_file (*pz + 1, zpubdir, (boolean *) NULL);
- if (zuse == NULL)
- return FALSE;
-
- if (fsysdep_in_directory (zfile, zuse, FALSE,
- FALSE, (const char *) NULL))
- fmatch = FALSE;
- }
- else
- {
- zuse = zsysdep_local_file (*pz, zpubdir, (boolean *) NULL);
- if (zuse == NULL)
- return FALSE;
-
- if (fsysdep_in_directory (zfile, zuse, fcheck,
- freadable, zuser))
- fmatch = TRUE;
- }
-
- ubuffree (zuse);
- }
-
- return fmatch;
-}
diff --git a/gnu/libexec/uucp/common_sources/uuconf.h b/gnu/libexec/uucp/common_sources/uuconf.h
deleted file mode 100644
index 3909888..0000000
--- a/gnu/libexec/uucp/common_sources/uuconf.h
+++ /dev/null
@@ -1,1557 +0,0 @@
-/* uuconf.h
- Header file for UUCP configuration routines.
-
- Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The use of an object file which uses material from this header
- file, and from no other portion of the uuconf library, is
- unrestricted, as described in paragraph 4 of section 5 of version 2
- of the GNU Library General Public License (this sentence is merely
- informative, and does not modify the License in any way).
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#ifndef UUCONF_H
-
-#define UUCONF_H
-
-#include <stdio.h>
-
-/* The macro UUCONF_ANSI_C may be used to override __STDC__. */
-#ifndef UUCONF_ANSI_C
-#ifdef __STDC__
-#define UUCONF_ANSI_C 1
-#else /* ! defined (__STDC__) */
-#define UUCONF_ANSI_C 0
-#endif /* ! defined (__STDC__) */
-#endif /* ! defined (UUCONF_ANSI_C) */
-
-#if UUCONF_ANSI_C
-#define UUCONF_CONST const
-typedef void *UUCONF_POINTER;
-#include <stddef.h>
-typedef size_t UUCONF_SIZE_T;
-#else
-#define UUCONF_CONST
-typedef char *UUCONF_POINTER;
-typedef unsigned int UUCONF_SIZE_T;
-#endif
-
-/* The field names of each of the following structures begin with
- "uuconf_". This is to avoid any conflicts with user defined
- macros. The first character following the "uuconf_" string
- indicates the type of the field.
-
- z -- a string (char *)
- c -- a count (normally int)
- i -- an integer value (normally int)
- f -- a boolean value (normally int)
- b -- a single character value (char or int)
- t -- an enum (enum XX)
- s -- a structure (struct XX)
- u -- a union (union XX)
- q -- a pointer to a structure (struct XX *)
- p -- a pointer to something other than a string
- */
-
-/* The information which is kept for a chat script. */
-
-struct uuconf_chat
-{
- /* The script itself. This is a NULL terminated list of expect/send
- pairs. The first string is an expect string. A string starting
- with a '-' indicates subsend string; the following strings which
- start with '-' are subexpect/subsend strings. This field may be
- NULL, in which case there is no chat script (but pzprogram may
- hold a program to run). */
- char **uuconf_pzchat;
- /* The chat program to run. This is a NULL terminated list of
- arguments; element 0 if the program. May be NULL, in which case
- there is no program. */
- char **uuconf_pzprogram;
- /* The timeout in seconds to use for expect strings in the chat
- script. */
- int uuconf_ctimeout;
- /* The NULL terminated list of failure strings. If any of these
- strings appear, the chat script is aborted. May be NULL, in
- which case there are no failure strings. */
- char **uuconf_pzfail;
- /* Non-zero if incoming characters should be stripped to seven bits
- (by anding with 0x7f). */
- int uuconf_fstrip;
-};
-
-/* The information which is kept for a time specification. This is a
- linked list of structures. Each element of the list represents a
- span of time, giving a starting time and an ending time. The time
- only depends on the day of the week, not on the day of the month or
- of the year. The time is only specified down to the minute, not
- down to the second or below. The list is sorted by starting time.
-
- The starting and ending time are expressed in minutes since the
- beginning of the week, which is considered to be 12 midnight on
- Sunday. Thus 60 is 1 am on Sunday, 1440 (== 60 * 24) is 12
- midnight on Monday, and the largest possible value is 10080 (== 60
- * 24 * 7) which is 12 midnight on the following Sunday.
-
- Each span of time has a value associated with it. This is the
- lowest grade or the largest file size that may be transferred
- during that time, depending on the source of the time span. When
- time specifications overlap, the value used for the overlap is the
- higher grade or the smaller file size. Thus specifying
- ``call-timegrade z Any'' and ``call-timegrade Z Mo'' means that
- only grade Z or higher may be sent on Monday, since Z is the higer
- grade of the overlapping spans. The final array wil have no
- overlaps.
-
- Each span also has a retry time associated with it. This permits
- different retry times to be used at different times of day. The
- retry time is only relevant if the span came from a ``time'' or
- ``timegrade'' command for a system. */
-
-struct uuconf_timespan
-{
- /* Next element in list. */
- struct uuconf_timespan *uuconf_qnext;
- /* Starting minute (-1 at the end of the array). */
- int uuconf_istart;
- /* Ending minute. */
- int uuconf_iend;
- /* Value for this span (lowest grade or largest file that may be
- transferred at this time). */
- long uuconf_ival;
- /* Retry time. */
- int uuconf_cretry;
-};
-
-/* The information which is kept for protocol parameters. Protocol
- parameter information is stored as an array of the following
- structures. */
-
-struct uuconf_proto_param
-{
- /* The name of the protocol to which this entry applies. This is
- '\0' for the last element of the array. */
- int uuconf_bproto;
- /* Specific entries for this protocol. This points to an array
- ending in an element with a uuconf_cargs field of 0. */
- struct uuconf_proto_param_entry *uuconf_qentries;
-};
-
-/* Each particular protocol parameter entry is one of the following
- structures. */
-
-struct uuconf_proto_param_entry
-{
- /* The number of arguments to the ``protocol-parameter'' command
- (not counting ``protocol-parameter'' itself). This is 0 for the
- last element of the array. */
- int uuconf_cargs;
- /* The actual arguments to the ``protocol-parameter'' command; this
- is an array with cargs entries. */
- char **uuconf_pzargs;
-};
-
-/* The information which is kept for a system. The zname and zalias
- fields will be the same for all alternates. Every other fields is
- specific to the particular alternate in which it appears (although
- most will be the same for all alternates). */
-
-struct uuconf_system
-{
- /* The name of the system. */
- char *uuconf_zname;
- /* A list of aliases for the system. This is a NULL terminated list
- of strings. May be NULL, in which case there are no aliases. */
- char **uuconf_pzalias;
- /* A linked list of alternate call in or call out information. Each
- alternative way to call this system occupies an element of this
- list. May be NULL, in which case there are no alternates. */
- struct uuconf_system *uuconf_qalternate;
- /* The name for this particular alternate. May be NULL, in which
- case this alternate does not have a name. */
- char *uuconf_zalternate;
- /* If non-zero, this alternate may be used for calling out. */
- int uuconf_fcall;
- /* If non-zero, this alternate may be used for accepting a call. */
- int uuconf_fcalled;
- /* The times at which this system may be called. The ival field of
- each uuconf_timespan structure is the lowest grade which may be
- transferred at that time. The cretry field is the number of
- minutes to wait before retrying the call, or 0 if it was not
- specified. May be NULL, in which case the system may never be
- called. */
- struct uuconf_timespan *uuconf_qtimegrade;
- /* The times at which to request a particular grade of the system
- when calling it, and the grades to request. The ival field of
- each uuconf_timespan structure is the lowest grade which the
- other system should transfer at that time. May be NULL, in which
- case there are no grade restrictions. */
- struct uuconf_timespan *uuconf_qcalltimegrade;
- /* The times at which to allow a particular grade of work to be
- transferred to the system, when it calls in. The ival field of
- each uuconf_timespan structure is the lowest grade which should
- be transferred at that time. May be NULL, in which case there
- are no grade restrictions. */
- struct uuconf_timespan *uuconf_qcalledtimegrade;
- /* The maximum number of times to retry calling this system. If
- this is 0, there is no limit. */
- int uuconf_cmax_retries;
- /* The number of minutes to wait between successful calls to a
- system. */
- int uuconf_csuccess_wait;
- /* The size restrictions by time for local requests during a locally
- placed call. The ival field of each uuconf_timespan structure is
- the size in bytes of the largest file which may be transferred at
- that time. May be NULL, in which case there are no size
- restrictions. */
- struct uuconf_timespan *uuconf_qcall_local_size;
- /* The size restrictions by time for remote requests during a
- locally placed call. May be NULL. */
- struct uuconf_timespan *uuconf_qcall_remote_size;
- /* The size restrictions by time for local requests during a
- remotely placed call. May be NULL. */
- struct uuconf_timespan *uuconf_qcalled_local_size;
- /* The size restrictions by time for remote requests during a
- remotely placed call. May be NULL. */
- struct uuconf_timespan *uuconf_qcalled_remote_size;
- /* Baud rate, or speed. Zero means any baud rate. If ihighbaud is
- non-zero, this is the low baud rate of a range. */
- long uuconf_ibaud;
- /* If non-zero, ibaud is the low baud rate of a range and ihighbaud
- is the high baud rate. */
- long uuconf_ihighbaud;
- /* Port name to use. May be NULL. If an HDB configuration file
- contains a modem class (alphabetic characters preceeding the baud
- rate), the class is appended to the port name. */
- char *uuconf_zport;
- /* Specific port information, if the system entry includes port
- information. May be NULL. */
- struct uuconf_port *uuconf_qport;
- /* Phone number to call, or address to use for a TCP connection.
- May be NULL, in which case a dialer script may not use \D or \T
- for this system, and a TCP port will use the system name. */
- char *uuconf_zphone;
- /* Chat script to use when logging in to the system. */
- struct uuconf_chat uuconf_schat;
- /* Login name to use for \L in the login chat script. This should
- normally be accessed via uuconf_callout. If it is "*",
- uuconf_callout will look it up in the call out file. This may be
- NULL, in which case the login script may not use \L. */
- char *uuconf_zcall_login;
- /* Password to use for \P in the login chat script. This should
- normally be accessed via uuconf_callout. If it is "*",
- uuconf_callout will look it up in the call out file. This may be
- NULL, in which case the login script may not use \P. */
- char *uuconf_zcall_password;
- /* The login name this system must use when calling in. This may be
- different for different alternates. This should only be examined
- if uuconf_fcalled is TRUE. If this is NULL or "ANY" then
- uuconf_validate must be called to make sure that whatever login
- name was used is permitted for this machine. */
- char *uuconf_zcalled_login;
- /* If non-zero, then when this system calls in the call should not
- be allowed to proceed and the system should be called back. */
- int uuconf_fcallback;
- /* If non-zero, then conversation sequence numbers should be used
- with this system. */
- int uuconf_fsequence;
- /* A list of protocols to use with this system. Each protocol has a
- single character name. May be NULL, in which case any known
- protocol may be used. */
- char *uuconf_zprotocols;
- /* Array of protocol parameters. Ends in an entry with a
- uuconf_bproto field of '\0'. May be NULL. */
- struct uuconf_proto_param *uuconf_qproto_params;
- /* Chat script to run when called by this system. */
- struct uuconf_chat uuconf_scalled_chat;
- /* Debugging level to set during a conversation. May be NULL. */
- char *uuconf_zdebug;
- /* Maximum remote debugging level this system may request. May be
- NULL. */
- char *uuconf_zmax_remote_debug;
- /* Non-zero if the remote system may request us to send files from
- the local system to the remote. */
- int uuconf_fsend_request;
- /* Non-zero if the remote system may request us to receive files
- from the remote system to the local. */
- int uuconf_frec_request;
- /* Non-zero if local requests are permitted when calling this
- system. */
- int uuconf_fcall_transfer;
- /* Non-zero if local requests are permitted when this system calls
- in. */
- int uuconf_fcalled_transfer;
- /* NULL terminated list of directories from which files may be sent
- by local request. */
- char **uuconf_pzlocal_send;
- /* NULL terminated list of directories from which files may be sent
- by remote request. */
- char **uuconf_pzremote_send;
- /* NULL terminated list of directories into which files may be
- received by local request. */
- char **uuconf_pzlocal_receive;
- /* NULL terminated list of directories into which files may be
- received by remote request. */
- char **uuconf_pzremote_receive;
- /* Path to use for command execution. This is a NULL terminated
- list of directories. */
- char **uuconf_pzpath;
- /* NULL terminated List of commands that may be executed. */
- char **uuconf_pzcmds;
- /* Amount of free space to leave when accepting a file from this
- system, in bytes. */
- long uuconf_cfree_space;
- /* NULL terminated list of systems that this system may forward
- from. May be NULL if there are no systems from which files may
- be forwarded. The list may include "ANY". */
- char **uuconf_pzforward_from;
- /* NULL terminated list of systems that this system may forward to.
- May be NULL if there are no systems to which files may be
- forwarded. The list may include "ANY". */
- char **uuconf_pzforward_to;
- /* The public directory to use for this sytem. */
- const char *uuconf_zpubdir;
- /* The local name to use for this remote system. May be NULL if the
- usual local name should be used. */
- char *uuconf_zlocalname;
- /* Memory allocation block for the system. */
- UUCONF_POINTER uuconf_palloc;
-};
-
-/* Types of ports. */
-
-enum uuconf_porttype
-{
- /* Unknown port type. A port of this type should never be returned
- by the uuconf functions. */
- UUCONF_PORTTYPE_UNKNOWN,
- /* Read from standard input and write to standard output. Not
- normally used. */
- UUCONF_PORTTYPE_STDIN,
- /* A modem port. */
- UUCONF_PORTTYPE_MODEM,
- /* A direct connect port. */
- UUCONF_PORTTYPE_DIRECT,
- /* A TCP port. Not supported on all systems. */
- UUCONF_PORTTYPE_TCP,
- /* A TLI port. Not supported on all systems. */
- UUCONF_PORTTYPE_TLI,
- /* A pipe port. Not supported on all systems. */
- UUCONF_PORTTYPE_PIPE
-};
-
-/* Additional information for a stdin port (there is none). */
-
-struct uuconf_stdin_port
-{
- int uuconf_idummy;
-};
-
-/* Additional information for a modem port. */
-
-struct uuconf_modem_port
-{
- /* The device name. May be NULL, in which case the port name is
- used instead. */
- char *uuconf_zdevice;
- /* The device name to send the dialer chat script to. May be NULL,
- in which case the chat script is sent to the usual device. */
- char *uuconf_zdial_device;
- /* The default baud rate (speed). If zero, there is no default. */
- long uuconf_ibaud;
- /* The low baud rate, if a range is used. If zero, a range is not
- used and ihighbaud should be ignored. */
- long uuconf_ilowbaud;
- /* The high baud rate, if ilowbaud is non-zero. */
- long uuconf_ihighbaud;
- /* Non-zero if the port supports carrier detect. */
- int uuconf_fcarrier;
- /* Non-zero if the port supports hardware flow control. */
- int uuconf_fhardflow;
- /* A NULL terminated sequence of dialer/token pairs (element 0 is a
- dialer name, element 1 is a token, etc.) May be NULL, in which
- case qdialer should not be NULL. */
- char **uuconf_pzdialer;
- /* Specific dialer information. Only used if pzdialer is NULL. */
- struct uuconf_dialer *uuconf_qdialer;
-};
-
-/* Additional information for a direct connect port. */
-
-struct uuconf_direct_port
-{
- /* The device name. May be NULL, in which case the port name is
- used instead. */
- char *uuconf_zdevice;
- /* The baud rate (speed). */
- long uuconf_ibaud;
- /* Non-zero if the port uses carrier detect. */
- int uuconf_fcarrier;
- /* Non-zero if the port supports hardware flow control. */
- int uuconf_fhardflow;
-};
-
-/* Additional information for a TCP port. */
-
-struct uuconf_tcp_port
-{
- /* The TCP port number to use. May be a name or a number. May be
- NULL, in which case "uucp" is looked up using getservbyname. */
- char *uuconf_zport;
- /* A NULL terminated sequence of dialer/token pairs (element 0 is a
- dialer name, element 1 is a token, etc.) May be NULL. */
- char **uuconf_pzdialer;
-};
-
-/* Additional information for a TLI port. */
-
-struct uuconf_tli_port
-{
- /* Device name to open. May be NULL, in which case the port name is
- used. */
- char *uuconf_zdevice;
- /* Whether this port should be turned into a stream, permitting the
- read and write calls instead of the t_rcv and t_send calls. */
- int uuconf_fstream;
- /* A NULL terminated list of modules to push after making the
- connection. May be NULL, in which case if fstream is non-zero,
- then "tirdwr" is pushed onto the stream, and otherwise nothing is
- pushed. */
- char **uuconf_pzpush;
- /* A NULL terminated sequence of dialer/token pairs (element 0 is a
- dialer name, element 1 is a token, etc.) May be NULL. If
- element 0 is TLI or TLIS, element 1 is used as the address to
- connect to; otherwise uuconf_zphone from the system information
- is used. */
- char **uuconf_pzdialer;
- /* Address to use when operating as a server. This may contain
- escape sequences. */
- char *uuconf_zservaddr;
-};
-
-/* Additional information for a pipe port. */
-
-struct uuconf_pipe_port
-{
- /* The command and its arguments. */
- char **uuconf_pzcmd;
-};
-
-/* Information kept for a port. */
-
-struct uuconf_port
-{
- /* The name of the port. */
- char *uuconf_zname;
- /* The type of the port. */
- enum uuconf_porttype uuconf_ttype;
- /* The list of protocols supported by the port. The name of each
- protocol is a single character. May be NULL, in which case any
- protocol is permitted. */
- char *uuconf_zprotocols;
- /* Array of protocol parameters. Ends in an entry with a
- uuconf_bproto field of '\0'. May be NULL. */
- struct uuconf_proto_param *uuconf_qproto_params;
- /* The set of reliability bits. */
- int uuconf_ireliable;
- /* The lock file name to use. */
- char *uuconf_zlockname;
- /* Memory allocation block for the port. */
- UUCONF_POINTER uuconf_palloc;
- /* The type specific information. */
- union
- {
- struct uuconf_stdin_port uuconf_sstdin;
- struct uuconf_modem_port uuconf_smodem;
- struct uuconf_direct_port uuconf_sdirect;
- struct uuconf_tcp_port uuconf_stcp;
- struct uuconf_tli_port uuconf_stli;
- struct uuconf_pipe_port uuconf_spipe;
- } uuconf_u;
-};
-
-/* Information kept about a dialer. */
-
-struct uuconf_dialer
-{
- /* The name of the dialer. */
- char *uuconf_zname;
- /* The chat script to use when dialing out. */
- struct uuconf_chat uuconf_schat;
- /* The string to send when a `=' appears in the phone number. */
- char *uuconf_zdialtone;
- /* The string to send when a `-' appears in the phone number. */
- char *uuconf_zpause;
- /* Non-zero if the dialer supports carrier detect. */
- int uuconf_fcarrier;
- /* The number of seconds to wait for carrier after the chat script
- is complete. Only used if fcarrier is non-zero. Only supported
- on some systems. */
- int uuconf_ccarrier_wait;
- /* If non-zero, DTR should be toggled before dialing. Only
- supported on some systems. */
- int uuconf_fdtr_toggle;
- /* If non-zero, sleep for 1 second after toggling DTR. Ignored if
- fdtr_toggle is zero. */
- int uuconf_fdtr_toggle_wait;
- /* The chat script to use when a call is complete. */
- struct uuconf_chat uuconf_scomplete;
- /* The chat script to use when a call is aborted. */
- struct uuconf_chat uuconf_sabort;
- /* Array of protocol parameters. Ends in an entry with a
- uuconf_bproto field of '\0'. May be NULL. */
- struct uuconf_proto_param *uuconf_qproto_params;
- /* The set of reliability bits. */
- int uuconf_ireliable;
- /* Memory allocation block for the dialer. */
- UUCONF_POINTER uuconf_palloc;
-};
-
-/* Reliability bits for the ireliable field of ports and dialers.
- These bits are used to decide which protocol to run. A given
- protocol will have a set of these bits, and each of them must be
- turned on for the port before we will permit that protocol to be
- used. This will be overridden by the zprotocols field. */
-
-/* Whether a set of reliability bits is given. If this bit is not
- set, then there is no reliability information. */
-#define UUCONF_RELIABLE_SPECIFIED (01)
-
-/* Set if the connection is eight bit transparent. */
-#define UUCONF_RELIABLE_EIGHT (02)
-
-/* Set if the connection is error-free. */
-#define UUCONF_RELIABLE_RELIABLE (04)
-
-/* Set if the connection is end-to-end reliable (e.g. TCP). */
-#define UUCONF_RELIABLE_ENDTOEND (010)
-
-/* Set if the connection is full-duplex; that is, no time consuming
- line turnaround is required before sending data in the reverse
- direction. If the connection is truly half-duplex, in the sense
- that communication can only flow in one direction, UUCP can not be
- used. */
-#define UUCONF_RELIABLE_FULLDUPLEX (020)
-
-/* UUCP grades range from 0 to 9, A to Z, a to z in order from highest
- to lowest (work of higher grades is done before work of lower
- grades). */
-
-/* The highest grade. */
-#define UUCONF_GRADE_HIGH ('0')
-
-/* The lowest grade. */
-#define UUCONF_GRADE_LOW ('z')
-
-/* Whether a character is a legal grade (requires <ctype.h>). */
-#define UUCONF_GRADE_LEGAL(b) (isalnum (BUCHAR (b)))
-
-/* Return < 0 if the first grade should be done before the second
- grade, == 0 if they are the same, or > 0 if the first grade should
- be done after the second grade. On an ASCII system, this can just
- be b1 - b2. */
-#define UUCONF_GRADE_CMP(b1, b2) (uuconf_grade_cmp ((b1), (b2)))
-
-/* Definitions for bits returned by uuconf_strip. */
-#define UUCONF_STRIP_LOGIN (01)
-#define UUCONF_STRIP_PROTO (02)
-
-/* uuconf_runuuxqt returns either a positive number (the number of
- execution files to receive between uuxqt invocations) or one of
- these constant values. */
-#define UUCONF_RUNUUXQT_NEVER (0)
-#define UUCONF_RUNUUXQT_ONCE (-1)
-#define UUCONF_RUNUUXQT_PERCALL (-2)
-
-/* Most of the uuconf functions returns an error code. A value of
- zero (UUCONF_SUCCESS) indicates success. */
-
-/* If this bit is set in the returned error code, then the
- uuconf_errno function may be used to obtain the errno value as set
- by the function which caused the failure. */
-#define UUCONF_ERROR_ERRNO (0x100)
-
-/* If this bit is set in the returned error code, then the
- uuconf_filename function may be used to get the name of a file
- associated with the error. */
-#define UUCONF_ERROR_FILENAME (0x200)
-
-/* If this bit is set in the returned error code, then the
- uuconf_lineno function may be used to get a line number associated
- with the error; normally if this is set UUCONF_ERROR_FILENAME will
- also be set. */
-#define UUCONF_ERROR_LINENO (0x400)
-
-/* There are two UUCONF_CMDTABRET bits that may be set in the return
- value of uuconf_cmd_line or uuconf_cmd_args, described below. They
- do not indicate an error, but instead give instructions to the
- calling function, often uuconf_cmd_file. They may also be set in
- the return value of a user function listed in a uuconf_cmdtab
- table, in which case they will be honored by uuconf_cmd_file. */
-
-/* This bit means that the memory occupied by the arguments passed to
- the function should be preserved, and not overwritten or freed. It
- refers only to the contents of the arguments; the contents of the
- argv array itself may always be destroyed. If this bit is set in
- the return value of uuconf_cmd_line or uuconf_cmd_args, it must be
- honored. It will be honored by uuconf_cmd_file. This may be
- combined with an error code or with UUCONF_CMDTABRET_EXIT, although
- neither uuconf_cmd_file or uuconf_cmd_line will do so. */
-#define UUCONF_CMDTABRET_KEEP (0x800)
-
-/* This bit means that uuconf_cmd_file should exit, rather than go on
- to read and process the next line. If uuconf_cmd_line or
- uuconf_cmd_args encounter an error, the return value will have this
- bit set along with the error code. A user function may set this
- bit with or without an error; the return value of the user function
- will be returned by uuconf_cmd_file, except that the
- UUCONF_CMDTABRET_KEEP and UUCONF_CMDTABRET_EXIT bits will be
- cleared. */
-#define UUCONF_CMDTABRET_EXIT (0x1000)
-
-/* This macro may be used to extract the specific error value. */
-#define UUCONF_ERROR_VALUE(i) ((i) & 0xff)
-
-/* UUCONF_ERROR_VALUE will return one of the following values. */
-
-/* Function succeeded. */
-#define UUCONF_SUCCESS (0)
-/* Named item not found. */
-#define UUCONF_NOT_FOUND (1)
-/* A call to fopen failed. */
-#define UUCONF_FOPEN_FAILED (2)
-/* A call to fseek failed. */
-#define UUCONF_FSEEK_FAILED (3)
-/* A call to malloc or realloc failed. */
-#define UUCONF_MALLOC_FAILED (4)
-/* Syntax error in file. */
-#define UUCONF_SYNTAX_ERROR (5)
-/* Unknown command. */
-#define UUCONF_UNKNOWN_COMMAND (6)
-
-#if UUCONF_ANSI_C
-
-/* For each type of configuration file (Taylor, V2, HDB), there are
- separate routines to read various sorts of information. There are
- also generic routines, which call on the appropriate type specific
- routines. The library can be compiled to read any desired
- combination of the configuration file types. This affects only the
- generic routines, as it determines which type specific routines
- they call. Thus, on a system which, for example, does not have any
- V2 configuration files, there is no need to include the overhead of
- the code to parse the files and the time to look for them.
- However, a program which specifically wants to be able to parse
- them can call the V2 specific routines.
-
- The uuconf functions all take as an argument a pointer to uuconf
- global information. This must be initialized by any the
- initialization routines (the generic one and the three file type
- specific ones) before any of the other uuconf functions may be
- called. */
-
-/* Initialize the configuration file reading routines. The ppglobal
- argument should point to a generic pointer (a void *, or, on older
- compilers, a char *) which will be initialized and may then be
- passed to the other uuconf routines. The zprogram argument is the
- name of the program for which files should be read. A NULL is
- taken as "uucp", and reads the standard UUCP configuration files.
- The only other common argument is "cu", but any string is
- permitted. The zname argument is the name of the Taylor UUCP
- config file; if it is NULL, the default config file will be read.
- If not reading Taylor UUCP configuration information, the argument
- is ignored. This function must be called before any of the other
- uuconf functions.
-
- Note that if the zname argument is obtained from the user running
- the program, the program should be careful to revoke any special
- privileges it may have (e.g. on Unix call setuid (getuid ()) and
- setgid (getgid ())). Otherwise various sorts of spoofing become
- possible. */
-extern int uuconf_init (void **uuconf_ppglobal,
- const char *uuconf_zprogram,
- const char *uuconf_zname);
-
-/* Adjust the configuration file global pointer for a new thread. The
- library is fully reentrant (with the exception of the function
- uuconf_error_string, which calls strerror, which on some systems is
- not reentrant), provided that each new thread that wishes to call
- the library calls this function and uses the new global pointer
- value. The ppglobal argument should be set to the address of the
- global pointer set by any of the init functions; it will be
- modified to become a new global pointer. */
-extern int uuconf_init_thread (void **uuconf_ppglobal);
-
-/* Get the names of all known systems. This sets sets *ppzsystems to
- point to an array of system names. The list of names is NULL
- terminated. The array is allocated using malloc, as is each
- element of the array, and they may all be passed to free when they
- are no longer needed. If the falias argument is 0, the list will
- not include any aliases; otherwise, it will. */
-extern int uuconf_system_names (void *uuconf_pglobal,
- char ***uuconf_ppzsystems,
- int uuconf_falias);
-
-/* Get the information for the system zsystem. This sets the fields
- in *qsys. This will work whether zsystem is the official name of
- the system or merely an alias. */
-extern int uuconf_system_info (void *uuconf_pglobal,
- const char *uuconf_zsystem,
- struct uuconf_system *uuconf_qsys);
-
-/* Get information for an unknown (anonymous) system. The
- uuconf_zname field of the returned system information will be NULL.
- If no information is available for unknown systems, this will
- return UUCONF_NOT_FOUND. This does not run the HDB remote.unknown
- shell script. */
-extern int uuconf_system_unknown (void *uuconf_pglobal,
- struct uuconf_system *uuconf_qsys);
-
-/* Get information for the local system. Normally the local system
- name should first be looked up using uuconf_system_info. If that
- returns UUCONF_NOT_FOUND, this function may be used to get an
- appropriate set of defaults. The uuconf_zname field of the
- returned system information may be NULL. */
-extern int uuconf_system_local (void *uuconf_pglobal,
- struct uuconf_system *uuconf_qsys);
-
-/* Free the memory occupied by system information returned by
- uuconf_system_info, uuconf_system_unknown, uuconf_system_local, or
- any of the configuration file type specific routines described
- below. After this is called, the contents of the structure shall
- not be referred to. */
-extern int uuconf_system_free (void *uuconf_pglobal,
- struct uuconf_system *uuconf_qsys);
-
-#ifdef __OPTIMIZE__
-#define uuconf_system_free(qglob, q) \
- (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
-#endif
-
-/* Find a matching port. This will consider each port in turn.
-
- If the zname argument is not NULL, the port's uuconf_zname field
- must match it.
-
- If the ibaud argument is not zero and the ihighbaud argument is
- zero, the port's baud rate, if defined, must be the same (if the
- port has a range of baud rates, ibaud must be within the range).
- If ibaud and ihighbaud are both not zero, the port's baud rate, if
- defined, must be between ibaud and ihighbaud inclusive (if the port
- has a range of baud rates, the ranges must intersect). If the port
- has no baud rate, either because it is a type of port for which
- baud rate is not defined (e.g. a TCP port) or because the
- uuconf_ibaud field is 0, the ibaud and ihighbaud arguments are
- ignored.
-
- If the pifn argument is not NULL, the port is passed to pifn, along
- with the pinfo argument (which is otherwise ignored). If pifn
- returns UUCONF_SUCCESS, the port matches. If pifn returns
- UUCONF_NOT_FOUND, a new port is sought. Otherwise the return value
- of pifn is returned from uuconf_find_port. The pifn function may
- be used to further restrict the port, such as by modem class or
- device name. It may also be used to lock the port, if appropriate;
- in this case, if the lock fails, pifn may return UUCONF_NOT_FOUND
- to force uuconf_find_port to continue searching for a port.
-
- If the port matches, the information is set into uuconf_qport, and
- uuconf_find_port returns UUCONF_SUCCESS. */
-extern int uuconf_find_port (void *uuconf_pglobal,
- const char *uuconf_zname,
- long uuconf_ibaud,
- long uuconf_ihighbaud,
- int (*uuconf_pifn) (struct uuconf_port *,
- void *uuconf_pinfo),
- void *uuconf_pinfo,
- struct uuconf_port *uuconf_qport);
-
-/* Free the memory occupied by system information returned by
- uuconf_find_port (or any of the configuration file specific
- routines described below). After this is called, the contents of
- the structure shall not be referred to. */
-extern int uuconf_port_free (void *uuconf_pglobal,
- struct uuconf_port *uuconf_qport);
-
-#ifdef __OPTIMIZE__
-#define uuconf_port_free(qglob, q) \
- (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
-#endif
-
-/* Get the names of all known dialers. This sets sets *ppzdialers to
- point to an array of dialer names. The list of names is NULL
- terminated. The array is allocated using malloc, as is each
- element of the array, and they may all be passed to free when they
- are no longer needed. */
-extern int uuconf_dialer_names (void *uuconf_pglobal,
- char ***uuconf_ppzdialers);
-
-/* Get the information for the dialer zdialer. This sets the fields
- in *qdialer. */
-extern int uuconf_dialer_info (void *uuconf_pglobal,
- const char *uuconf_zdialer,
- struct uuconf_dialer *uuconf_qdialer);
-
-/* Free the memory occupied by system information returned by
- uuconf_dialer_info (or any of the configuration file specific
- routines described below). After this is called, the contents of
- the structure shall not be referred to. */
-extern int uuconf_dialer_free (void *uuconf_pglobal,
- struct uuconf_dialer *uuconf_qsys);
-
-#ifdef __OPTIMIZE__
-#define uuconf_dialer_free(qglob, q) \
- (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
-#endif
-
-/* Get the local node name. If the node name is not specified
- (because no ``nodename'' command appeared in the config file) this
- will return UUCONF_NOT_FOUND, and some system dependent function
- must be used to determine the node name. Otherwise it will return
- a pointer to a constant string, which should not be freed. */
-extern int uuconf_localname (void *uuconf_pglobal,
- const char **pzname);
-
-/* Get the local node name that should be used, given a login name.
- This function will check for any special local name that may be
- associated with the login name zlogin (as set by the ``myname''
- command in a Taylor configuration file, or the MYNAME field in a
- Permissions entry). This will set *pzname to the node name. If no
- node name can be determined, *pzname will be set to NULL and the
- function will return UUCONF_NOT_FOUND; in this case some system
- dependent function must be used to determine the node name. If the
- function returns UUCONF_SUCCESS, *pzname will be point to an
- malloced buffer. */
-extern int uuconf_login_localname (void *uuconf_pglobal,
- const char *uuconf_zlogin,
- char **pzname);
-
-/* Get the name of the UUCP spool directory. This will set *pzspool
- to a constant string, which should not be freed. */
-extern int uuconf_spooldir (void *uuconf_pglobal,
- const char **uuconf_pzspool);
-
-/* Get the name of the default UUCP public directory. This will set
- *pzpub to a constant string, which should not be freed. Note that
- particular systems may use a different public directory. */
-extern int uuconf_pubdir (void *uuconf_pglobal,
- const char **uuconf_pzpub);
-
-/* Get the name of the UUCP lock directory. This will set *pzlock to
- a constant string, which should not be freed. */
-extern int uuconf_lockdir (void *uuconf_pglobal,
- const char **uuconf_pzlock);
-
-/* Get the name of the UUCP log file. This will set *pzlog to a
- constant string, which should not be freed. */
-extern int uuconf_logfile (void *uuconf_pglobal,
- const char **uuconf_pzlog);
-
-/* Get the name of the UUCP statistics file. This will set *pzstats
- to a constant string, which should not be freed. */
-extern int uuconf_statsfile (void *uuconf_pglobal,
- const char **uuconf_pzstats);
-
-/* Get the name of the UUCP debugging file. This will set *pzdebug to
- a constant string, which should not be freed. */
-extern int uuconf_debugfile (void *uuconf_pglobal,
- const char **uuconf_pzdebug);
-
-/* Get the default debugging level to use. This basically gets the
- argument of the ``debug'' command from the Taylor UUCP config file.
- It will set *pzdebug to a constant string, which should not be
- freed. */
-extern int uuconf_debuglevel (void *uuconf_pglobal,
- const char **uuconf_pzdebug);
-
-/* Get a combination of UUCONF_STRIP bits indicating what types of
- global information should be stripped on input. */
-extern int uuconf_strip (void *uuconf_pglobal,
- int *uuconf_pistrip);
-
-/* Get the maximum number of simultaneous uuxqt executions. This will
- set *pcmaxuuxqt to the number. Zero indicates no maximum. */
-extern int uuconf_maxuuxqts (void *uuconf_pglobal,
- int *uuconf_pcmaxuuxqt);
-
-/* Get the frequency with which to spawn a uuxqt process. This
- returns an integer. A positive number is the number of execution
- files that should be received between spawns. Other values are one
- of the UUCONF_RUNUUXQT constants listed above. */
-extern int uuconf_runuuxqt (void *uuconf_pglobal,
- int *uuconf_pirunuuxqt);
-
-/* Check a login name and password. This checks the Taylor UUCP
- password file (not /etc/passwd). It will work even if
- uuconf_taylor_init was not called. All comparisons are done via a
- callback function. The first argument to the function will be zero
- when comparing login names, non-zero when comparing passwords. The
- second argument to the function will be the pinfo argument passed
- to uuconf_callin. The third argument will be the login name or
- password from the UUCP password file. The comparison function
- should return non-zero for a match, or zero for a non-match. If
- the login name is found and the password compares correctly,
- uuconf_callin will return UUCONF_SUCCESS. If the login is not
- found, or the password does not compare correctly, uuconf_callin
- will return UUCONF_NOT_FOUND. Other errors are also possible. */
-extern int uuconf_callin (void *uuconf_pglobal,
- int (*uuconf_cmp) (int, void *, const char *),
- void *uuconf_pinfo);
-
-/* Get the callout login name and password for a system. This will
- set both *pzlog and *pzpass to a string allocated by malloc, or to
- NULL if the value is not found. If neither value is found, the
- function will return UUCONF_NOT_FOUND. */
-extern int uuconf_callout (void *uuconf_pglobal,
- const struct uuconf_system *uuconf_qsys,
- char **uuconf_pzlog,
- char **uuconf_pzpass);
-
-/* See if a login name is permitted for a system. This will return
- UUCONF_SUCCESS if it is permitted or UUCONF_NOT_FOUND if it is
- invalid. This simply calls uuconf_taylor_validate or returns
- UUCONF_SUCCESS, depending on the value of HAVE_TAYLOR_CONFIG. */
-extern int uuconf_validate (void *uuconf_pglobal,
- const struct uuconf_system *uuconf_qsys,
- const char *uuconf_zlogin);
-
-/* Get the name of the HDB remote.unknown shell script, if using
- HAVE_HDB_CONFIG. This does not actually run the shell script. If
- the function returns UUCONF_SUCCESS, the name will be in *pzname,
- which will point to an malloced buffer. If it returns
- UUCONF_NOT_FOUND, then there is no script to run. */
-extern int uuconf_remote_unknown (void *uuconf_pglobal,
- char **pzname);
-
-/* Translate a dial code. This sets *pznum to an malloced string.
- This will look up the entire zdial string in the dialcode file, so
- for normal use the alphabetic prefix should be separated. */
-extern int uuconf_dialcode (void *uuconf_pglobal,
- const char *uuconf_zdial,
- char **uuconf_pznum);
-
-/* Compare two grades, returning < 0 if b1 should be executed before
- b2, == 0 if they are the same, or > 0 if b1 should be executed
- after b2. This can not fail, and does not return a standard uuconf
- error code; it is normally called via the macro UUCONF_GRADE_CMP,
- defined above. */
-extern int uuconf_grade_cmp (int uuconf_b1, int uuconf_b2);
-
-#else /* ! UUCONF_ANSI_C */
-
-extern int uuconf_init ();
-extern int uuconf_init_thread ();
-extern int uuconf_system_names ();
-extern int uuconf_system_info ();
-extern int uuconf_system_unknown ();
-extern int uuconf_system_local ();
-extern int uuconf_system_free ();
-extern int uuconf_find_port ();
-extern int uuconf_port_free ();
-extern int uuconf_dialer_names ();
-extern int uuconf_dialer_info ();
-extern int uuconf_dialer_free ();
-extern int uuconf_localname ();
-extern int uuconf_login_localname ();
-extern int uuconf_spooldir ();
-extern int uuconf_lockdir ();
-extern int uuconf_pubdir ();
-extern int uuconf_logfile ();
-extern int uuconf_statsfile ();
-extern int uuconf_debugfile ();
-extern int uuconf_debuglevel ();
-extern int uuconf_maxuuxqts ();
-extern int uuconf_runuuxqt ();
-extern int uuconf_callin ();
-extern int uuconf_callout ();
-extern int uuconf_remote_unknown ();
-extern int uuconf_validate ();
-extern int uuconf_grade_cmp ();
-
-#ifdef __OPTIMIZE__
-#define uuconf_system_free(qglob, q) \
- (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
-#define uuconf_port_free(qglob, q) \
- (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
-#define uuconf_dialer_free(qglob, q) \
- (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
-#endif
-
-#endif /* ! UUCONF_ANSI_C */
-
-#if UUCONF_ANSI_C
-
-/* Initialize the Taylor UUCP configuration file reading routines.
- This must be called before calling any of the Taylor UUCP
- configuration file specific routines. The ppglobal argument should
- point to a generic pointer. Moreover, before calling this function
- the pointer either must be set to NULL, or must have been passed to
- one of the other uuconf init routines. The zprogram argument is
- the name of the program for which files should be read. If NULL,
- it is taken as "uucp", which means to read the standard UUCP files.
- The zname argument is the name of the config file. If it is NULL,
- the default config file will be used.
-
- Note that if the zname argument is obtained from the user running
- the program, the program should be careful to revoke any special
- privileges it may have (e.g. on Unix call setuid (getuid ()) and
- setgid (getgid ())). Otherwise various sorts of spoofing become
- possible. */
-extern int uuconf_taylor_init (void **uuconf_pglobal,
- const char *uuconf_zprogram,
- const char *uuconf_zname);
-
-/* Get the names of all systems listed in the Taylor UUCP
- configuration files. This sets *ppzsystems to point to an array of
- system names. The list of names is NULL terminated. The array is
- allocated using malloc, as is each element of the array. If the
- falias argument is 0, the list will not include any aliases;
- otherwise, it will. */
-extern int uuconf_taylor_system_names (void *uuconf_pglobal,
- char ***uuconf_ppzsystems,
- int uuconf_falias);
-
-/* Get the information for system zsystem from the Taylor UUCP
- configuration files. This will set *qsys. */
-extern int uuconf_taylor_system_info (void *uuconf_pglobal,
- const char *uuconf_zsystem,
- struct uuconf_system *uuconf_qsys);
-
-/* Get information for an unknown (anonymous) system. This returns
- the values set by the ``unknown'' command in the main configuration
- file. If the ``unknown'' command was not used, this will return
- UUCONF_NOT_FOUND. */
-extern int uuconf_taylor_system_unknown (void *uuconf_pglobal,
- struct uuconf_system *uuconf_qsys);
-
-/* Find a port from the Taylor UUCP configuration files. The
- arguments and return values are identical to those of
- uuconf_find_port. */
-extern int uuconf_taylor_find_port (void *uuconf_pglobal,
- const char *uuconf_zname,
- long uuconf_ibaud,
- long uuconf_ihighbaud,
- int (*uuconf_pifn) (struct uuconf_port *,
- void *uuconf_pinfo),
- void *uuconf_pinfo,
- struct uuconf_port *uuconf_qport);
-
-/* Get the names of all dialers listed in the Taylor UUCP
- configuration files. This sets *ppzdialers to point to an array of
- dialer names. The list of names is NULL terminated. The array is
- allocated using malloc, as is each element of the array. */
-extern int uuconf_taylor_dialer_names (void *uuconf_pglobal,
- char ***uuconf_ppzdialers);
-
-/* Get the information for the dialer zdialer from the Taylor UUCP
- configuration files. This sets the fields in *qdialer. */
-extern int uuconf_taylor_dialer_info (void *uuconf_pglobal,
- const char *uuconf_zdialer,
- struct uuconf_dialer *uuconf_qdialer);
-
-/* Get the local node name that should be used, given a login name,
- considering only the ``myname'' command in the Taylor UUCP
- configuration files. If the function returns UUCONF_SUCCESS,
- *pzname will point to an malloced buffer. */
-extern int uuconf_taylor_login_localname (void *uuconf_pglobal,
- const char *uuconf_zlogin,
- char **pzname);
-
-/* Get the callout login name and password for a system from the
- Taylor UUCP configuration files. This will set both *pzlog and
- *pzpass to a string allocated by malloc, or to NULL if the value is
- not found. If neither value is found, the function will return
- UUCONF_NOT_FOUND. */
-extern int uuconf_taylor_callout (void *uuconf_pglobal,
- const struct uuconf_system *uuconf_qsys,
- char **uuconf_pzlog,
- char **uuconf_pzpass);
-
-/* See if a login name is permitted for a system. This will return
- UUCONF_SUCCESS if it is permitted or UUCONF_NOT_FOUND if it is
- invalid. This checks whether the login name appears in a
- called-login command with a list of system which does not include
- the system qsys. */
-extern int uuconf_taylor_validate (void *uuconf_pglobal,
- const struct uuconf_system *uuconf_qsys,
- const char *uuconf_zlogin);
-
-#else /* ! UUCONF_ANSI_C */
-
-extern int uuconf_taylor_init ();
-extern int uuconf_taylor_system_names ();
-extern int uuconf_taylor_system_info ();
-extern int uuconf_taylor_system_unknown ();
-extern int uuconf_taylor_find_port ();
-extern int uuconf_taylor_dialer_names ();
-extern int uuconf_taylor_dialer_info ();
-extern int uuconf_taylor_login_localname ();
-extern int uuconf_taylor_callout ();
-extern int uuconf_taylor_validate ();
-
-#endif /* ! UUCONF_ANSI_C */
-
-#if UUCONF_ANSI_C
-
-/* Initialize the V2 configuration file reading routines. This must
- be called before any of the other V2 routines are called. The
- ppglobal argument should point to a generic pointer. Moreover,
- before calling this function the pointer either must be set to
- NULL, or must have been passed to one of the other uuconf init
- routines. */
-extern int uuconf_v2_init (void **uuconf_ppglobal);
-
-/* Get the names of all systems listed in the V2 configuration files.
- This sets *ppzsystems to point to an array of system names. The
- list of names is NULL terminated. The array is allocated using
- malloc, as is each element of the array. If the falias argument is
- 0, the list will not include any aliases; otherwise, it will. */
-extern int uuconf_v2_system_names (void *uuconf_pglobal,
- char ***uuconf_ppzsystems,
- int uuconf_falias);
-
-/* Get the information for system zsystem from the V2 configuration
- files. This will set *qsys. */
-extern int uuconf_v2_system_info (void *uuconf_pglobal,
- const char *uuconf_zsystem,
- struct uuconf_system *uuconf_qsys);
-
-/* Find a port from the V2 configuration files. The arguments and
- return values are identical to those of uuconf_find_port. */
-extern int uuconf_v2_find_port (void *uuconf_pglobal,
- const char *uuconf_zname,
- long uuconf_ibaud,
- long uuconf_ihighbaud,
- int (*uuconf_pifn) (struct uuconf_port *,
- void *uuconf_pinfo),
- void *uuconf_pinfo,
- struct uuconf_port *uuconf_qport);
-
-#else /* ! UUCONF_ANSI_C */
-
-extern int uuconf_v2_init ();
-extern int uuconf_v2_system_names ();
-extern int uuconf_v2_system_info ();
-extern int uuconf_v2_find_port ();
-
-#endif /* ! UUCONF_ANSI_C */
-
-#if UUCONF_ANSI_C
-
-/* Initialize the HDB configuration file reading routines. This
- should be called before any of the other HDB routines are called.
- The ppglobal argument should point to a generic pointer. Moreover,
- before calling this function the pointer either must be set to
- NULL, or must have been passed to one of the other uuconf init
- routines. The zprogram argument is used to match against a
- "services" string in Sysfiles. A NULL or "uucp" argument is taken
- as "uucico". */
-extern int uuconf_hdb_init (void **uuconf_ppglobal,
- const char *uuconf_zprogram);
-
-/* Get the names of all systems listed in the HDB configuration files.
- This sets *ppzsystems to point to an array of system names. The
- list of names is NULL terminated. The array is allocated using
- malloc, as is each element of the array. If the falias argument is
- 0, the list will not include any aliases; otherwise, it will (an
- alias is created by using the ALIAS= keyword in the Permissions
- file). */
-extern int uuconf_hdb_system_names (void *uuconf_pglobal,
- char ***uuconf_ppzsystems,
- int uuconf_falias);
-
-/* Get the information for system zsystem from the HDB configuration
- files. This will set *qsys. */
-extern int uuconf_hdb_system_info (void *uuconf_pglobal,
- const char *uuconf_zsystem,
- struct uuconf_system *uuconf_qsys);
-
-
-/* Get information for an unknown (anonymous) system. If no
- information is available for unknown systems, this will return
- UUCONF_NOT_FOUND. This does not run the remote.unknown shell
- script. */
-extern int uuconf_hdb_system_unknown (void *uuconf_pglobal,
- struct uuconf_system *uuconf_qsys);
-
-/* Find a port from the HDB configuration files. The arguments and
- return values are identical to those of uuconf_find_port. */
-extern int uuconf_hdb_find_port (void *uuconf_pglobal,
- const char *uuconf_zname,
- long uuconf_ibaud,
- long uuconf_ihighbaud,
- int (*uuconf_pifn) (struct uuconf_port *,
- void *uuconf_pinfo),
- void *uuconf_pinfo,
- struct uuconf_port *uuconf_qport);
-
-/* Get the names of all dialers listed in the HDB configuration files.
- This sets *ppzdialers to point to an array of dialer names. The
- list of names is NULL terminated. The array is allocated using
- malloc, as is each element of the array. */
-extern int uuconf_hdb_dialer_names (void *uuconf_pglobal,
- char ***uuconf_ppzdialers);
-
-/* Get the information for the dialer zdialer from the HDB
- configuration files. This sets the fields in *qdialer. */
-extern int uuconf_hdb_dialer_info (void *uuconf_pglobal,
- const char *uuconf_zdialer,
- struct uuconf_dialer *uuconf_qdialer);
-
-/* Get the local node name that should be used, given a login name,
- considering only the MYNAME field in the HDB Permissions file. If
- the function returns UUCONF_SUCCESS, *pzname will point to an
- malloced buffer. */
-extern int uuconf_hdb_login_localname (void *uuconf_pglobal,
- const char *uuconf_zlogin,
- char **pzname);
-
-/* Get the name of the HDB remote.unknown shell script. This does not
- actually run the shell script. If the function returns
- UUCONF_SUCCESS, the name will be in *pzname, which will point to an
- malloced buffer. */
-extern int uuconf_hdb_remote_unknown (void *uuconf_pglobal,
- char **pzname);
-
-#else /* ! UUCONF_ANSI_C */
-
-extern int uuconf_hdb_init ();
-extern int uuconf_hdb_system_names ();
-extern int uuconf_hdb_system_info ();
-extern int uuconf_hdb_system_unknown ();
-extern int uuconf_hdb_find_port ();
-extern int uuconf_hdb_dialer_names ();
-extern int uuconf_hdb_dialer_info ();
-extern int uuconf_hdb_localname ();
-extern int uuconf_hdb_remote_unknown ();
-
-#endif /* ! UUCONF_ANSI_C */
-
-#if UUCONF_ANSI_C
-
-/* This function will set an appropriate error message into the buffer
- zbuf, given a uuconf error code. The buffer will always be null
- terminated, and will never be accessed beyond the length cbuf.
- This function will return the number of characters needed for the
- complete message, including the null byte. If this is less than
- the cbytes argument, the buffer holds a truncated string. */
-extern int uuconf_error_string (void *uuconf_pglobal, int ierror,
- char *zbuf, UUCONF_SIZE_T cbuf);
-
-/* If UUCONF_ERROR_ERRNO is set in a return value, this function may
- be used to retrieve the errno value. This will be the value of
- errno as set by the system function which failed. However, some
- system functions, notably some stdio routines, may not set errno,
- in which case the value will be meaningless. This function does
- not return a uuconf error code, and it cannot fail. */
-extern int uuconf_error_errno (void *uuconf_pglobal);
-
-/* If UUCONF_ERROR_FILENAME is set in a return value, this function
- may be used to retrieve the file name. This function does not
- return a uuconf error code, and it cannot fail. The string that it
- returns a pointer to is not guaranteed to remain allocated across
- the next call to a uuconf function (other than one of the three
- error retrieving functions). */
-extern const char *uuconf_error_filename (void *uuconf_pglobal);
-
-/* If UUCONF_ERROR_LINENO is set in a return value, this function may
- be used to retrieve the line number. This function does not return
- a uuconf error code, and it cannot fail. */
-extern int uuconf_error_lineno (void *uuconf_pglobal);
-
-#else /* ! UUCONF_ANSI_C */
-
-extern int uuconf_error_string ();
-extern int uuconf_error_errno ();
-extern UUCONF_CONST char *uuconf_error_filename ();
-extern int uuconf_error_lineno ();
-
-#endif /* ! UUCONF_ANSI_C */
-
-/* The uuconf package also provides a few functions which can accept
- commands and parcel them out according to a table. These are
- publically visible, partially in the hopes that they will be
- useful, but mostly because the rest of the Taylor UUCP package uses
- them. */
-
-/* The types of entries allowed in a command table (struct
- uuconf_cmdtab). Each type defines how a particular command is
- interpreted. Each type will either assign a value to a variable or
- call a function. In all cases, a line of input is parsed into
- separate fields, separated by whitespace; comments beginning with
- '#' are discarded, except that a '#' preceeded by a backslash is
- retained. The first field is taken as the command to execute, and
- the remaining fields are its arguments. */
-
-/* A boolean value. Used for a command which accepts a single
- argument, which must begin with 'y', 'Y', 't', or 'T' for true (1)
- or 'n', 'N', 'f', or 'F' for false (0). The corresponding variable
- must be an int. */
-#define UUCONF_CMDTABTYPE_BOOLEAN (0x12)
-
-/* An integer value. Used for a command which accepts a single
- argument, which must be an integer. The corresponding variable
- must be an int. */
-#define UUCONF_CMDTABTYPE_INT (0x22)
-
-/* A long value. Used for a command which accepts a single value,
- which must be an integer. The corresponding variable must be a
- long. */
-#define UUCONF_CMDTABTYPE_LONG (0x32)
-
-/* A string value. Used for a command which accepts a string
- argument. If there is no argument, the variable will be set to
- point to a zero byte. Otherwise the variable will be set to point
- to the string. The corresponding variable must be a char *. The
- memory pointed to by the variable after it is set must not be
- modified. */
-#define UUCONF_CMDTABTYPE_STRING (0x40)
-
-/* A full string value. Used for a command which accepts a series of
- string arguments separated by whitespace. The corresponding
- variable must be a char **. It will be set to an NULL terminated
- array of the arguments. The memory occupied by the array itself,
- and by the strings within it, must not be modified. */
-#define UUCONF_CMDTABTYPE_FULLSTRING (0x50)
-
-/* A function. If this command is encountered, the command and its
- arguments are passed to the corresponding function. They are
- passed as an array of strings, in which the first string is the
- command itself, along with a count of strings. This value may be
- or'red with a specific number of required arguments;
- UUCONF_CMDTABTYPE_FN | 1 accepts no additional arguments besides
- the command itself, UUCONF_CMDTABTYPE_FN | 2 accepts 1 argument,
- etc. UUCONF_CMDTABTYPE_FN | 0, accepts any number of additional
- arguments. */
-#define UUCONF_CMDTABTYPE_FN (0x60)
-
-/* A prefix function. The string in the table is a prefix; if a
- command is encountered with the same prefix, the corresponding
- function will be called as for UUCONF_CMDTABTYPE_FN. The number of
- arguments may be or'red in as with UUCONF_CMDTABTYPE_FN. */
-#define UUCONF_CMDTABTYPE_PREFIX (0x70)
-
-/* This macro will return the particular type of a CMDTABTYPE. */
-#define UUCONF_TTYPE_CMDTABTYPE(i) ((i) & 0x70)
-
-/* This macro will return the required number of arguments of a
- CMDTABTYPE. If it is zero, there is no restriction. */
-#define UUCONF_CARGS_CMDTABTYPE(i) ((i) & 0x0f)
-
-/* When a function is called via UUCONF_CMDTABTYPE_FN or
- UUCONF_CMDTABTYPE_PREFIX, it may return any uuconf error code (see
- above). However, it will normally return one of the following:
-
- UUCONF_CMDTABRET_CONTINUE: Take no special action. In particular,
- the arguments passed to the function may be overwritten or freed.
-
- UUCONF_CMDTABRET_KEEP: The memory occupied by the arguments passed
- to the function must be preserved. Continue processing commands.
-
- UUCONF_CMDTABRET_EXIT: If reading commands from a file, stop
- processing. The arguments passed to the function may be
- overwritten or freed.
-
- UUCONF_CMDTABRET_KEEP_AND_EXIT: Stop processing any file. The
- memory occupied by the arguments passed to the function must be
- preserved.
-
- These values are interpreted by uuconf_cmd_file. The
- uuconf_cmd_line and uuconf_cmd_args functions may return
- UUCONF_CMDTABRET_KEEP. It they get an error, they will return an
- error code with UUCONF_CMDTABRET_EXIT set. Also, of course, they
- may return any value that is returned by one of the user functions
- in the uuconf_cmdtab table. */
-
-/* UUCONF_CMDTABRET_KEEP and UUCONF_CMDTABRET_EXIT are defined above,
- with the error codes. */
-
-#define UUCONF_CMDTABRET_CONTINUE UUCONF_SUCCESS
-#define UUCONF_CMDTABRET_KEEP_AND_EXIT \
- (UUCONF_CMDTABRET_KEEP | UUCONF_CMDTABRET_EXIT)
-
-/* When a function is called via CMDTABTYPE_FN or CMDTABTYPE_PREFIX,
- it is passed five arguments. This is the type of a pointer to such
- a function. The uuconf global information structure is passed in
- for convenience in calling another uuconf function. The arguments
- to the command are passed in (the command itself is the first
- argument) along with a count and the value of the pvar field from
- the uuconf_cmdtab structure in which the function pointer was
- found. The pinfo argument to the function is taken from the
- argument to uuconf_cmd_*. */
-
-#if UUCONF_ANSI_C
-typedef int (*uuconf_cmdtabfn) (void *uuconf_pglobal,
- int uuconf_argc,
- char **uuconf_argv,
- void *uuconf_pvar,
- void *uuconf_pinfo);
-#else
-typedef int (*uuconf_cmdtabfn) ();
-#endif
-
-/* A table of commands is an array of the following structures. The
- final element of the table should have uuconf_zcmd == NULL. */
-
-struct uuconf_cmdtab
-{
- /* Command name. */
- UUCONF_CONST char *uuconf_zcmd;
- /* Command type (one of CMDTABTYPE_*). */
- int uuconf_itype;
- /* If not CMDTABTYPE_FN or CMDTABTYPE_PREFIX, the address of the
- associated variable. Otherwise, a pointer value to pass to the
- function pifn. */
- UUCONF_POINTER uuconf_pvar;
- /* The function to call if CMDTABTYPE_FN or CMDTABTYPE_PREFIX. */
- uuconf_cmdtabfn uuconf_pifn;
-};
-
-/* Bit flags to pass to uuconf_processcmds. */
-
-/* If set, case is significant when checking commands. Normally case
- is ignored. */
-#define UUCONF_CMDTABFLAG_CASE (0x1)
-
-/* If set, a backslash at the end of a line may be used to include the
- next physical line in the logical line. */
-#define UUCONF_CMDTABFLAG_BACKSLASH (0x2)
-
-/* If set, the comment character (#) is treated as a normal character,
- rather than as starting a comment. */
-#define UUCONF_CMDTABFLAG_NOCOMMENTS (0x4)
-
-#if UUCONF_ANSI_C
-
-/* Read commands from a file, look them up in a table, and take the
- appropriate action. This continues reading lines from the file
- until EOF, or until a function returns with UUCONF_CMDTABRET_EXIT
- set, or until an error occurs. The qtab argument must point to a
- table of struct uuconf_cmdtab; the last element in the table should
- have uuconf_zcmd == NULL. When a UUCONF_CMDTABTYPE_FN or
- UUCONF_CMDTABTYPE_PREFIX command is found, the pinfo argument will
- be passed to the called function. If an a command is found that is
- not in the table, then if pfiunknownfn is NULL the unknown command
- is ignored; otherwise it is passed to pfiunknownfn, which should
- return a uuconf return code which is handled as for any other
- function (the pvar argument to pfiunknownfn will always be NULL).
- The iflags argument is any combination of the above
- UUCONF_CMDTABFLAG bits. The pblock argument may also be a memory
- block, as returned by uuconf_malloc_block (described below), in
- which case all memory preserved because of UUCONF_CMDTABRET_KEEP
- will be added to the block so that it may be freed later; it may
- also be NULL, in which case any such memory is permanently lost.
-
- This function initially sets the internal line number to 0, and
- then increments it as each line is read. It is permitted for any
- called function to use the uuconf_lineno function to obtain it. If
- this function is called when not at the start of a file, the value
- returned by uuconf_lineno (which is, in any case, only valid if an
- error code with UUCONF_ERROR_LINENO set is returned) must be
- adjusted by the caller.
-
- This returns a normal uuconf return value, as described above. */
-extern int uuconf_cmd_file (void *uuconf_pglobal,
- FILE *uuconf_e,
- const struct uuconf_cmdtab *uuconf_qtab,
- void *uuconf_pinfo,
- uuconf_cmdtabfn uuconf_pfiunknownfn,
- int uuconf_iflags,
- void *pblock);
-
-/* This utility function is just like uuconf_cmd_file, except that it
- only operates on a single string. If a function is called via
- qtab, its return value will be the return value of this function.
- UUCONF_CMDTABFLAG_BACKSLASH is ignored in iflags. The string z is
- modified in place. The return value may include the
- UUCONF_CMDTABRET_KEEP and, on error, the UUCONF_CMDTABRET_EXIT
- bits, which should be honored by the calling code. */
-extern int uuconf_cmd_line (void *uuconf_pglobal,
- char *uuconf_z,
- const struct uuconf_cmdtab *uuconf_qtab,
- void *uuconf_pinfo,
- uuconf_cmdtabfn uuconf_pfiunknownfn,
- int uuconf_iflags,
- void *pblock);
-
-/* This utility function is just like uuconf_cmd_line, except it is
- given a list of already parsed arguments. */
-extern int uuconf_cmd_args (void *uuconf_pglobal,
- int uuconf_cargs,
- char **uuconf_pzargs,
- const struct uuconf_cmdtab *uuconf_qtab,
- void *uuconf_pinfo,
- uuconf_cmdtabfn uuconf_pfiunknownfn,
- int uuconf_iflags,
- void *pblock);
-
-#else /* ! UUCONF_ANSI_C */
-
-extern int uuconf_cmd_file ();
-extern int uuconf_cmd_line ();
-extern int uuconf_cmd_args ();
-
-#endif /* ! UUCONF_ANSI_C */
-
-#if UUCONF_ANSI_C
-
-/* The uuconf_cmd_file function may allocate memory permanently, as
- for setting a UUCONF_CMDTABTYPE_STRING value, in ways which are
- difficult to free up. A memory block may be used to record all
- allocated memory, so that it can all be freed up at once at some
- later time. These functions do not take a uuconf global pointer,
- and are independent of the rest of the uuconf library. */
-
-/* Allocate a block of memory. If this returns NULL, then malloc
- returned NULL, and errno is whatever malloc set it to. */
-extern void *uuconf_malloc_block (void);
-
-/* Allocate memory within a memory block. If this returns NULL, then
- malloc returned NULL, and errno is whatever malloc set it to. */
-extern void *uuconf_malloc (void *uuconf_pblock,
- UUCONF_SIZE_T uuconf_cbytes);
-
-/* Add a block returned by the generic malloc routine to a memory
- block. This returns zero on success, non-zero on failure. If this
- fails (returns non-zero), then malloc returned NULL, and errno is
- whatever malloc set it to. */
-extern int uuconf_add_block (void *uuconf_pblock, void *uuconf_padd);
-
-/* Free a value returned by uuconf_malloc from a memory block. In the
- current implementation, this will normally not do anything, but it
- doesn't hurt. No errors can occur. */
-extern void uuconf_free (void *uuconf_pblock, void *uuconf_pfree);
-
-/* Free an entire memory block, including all values returned by
- uuconf_malloc from it and all values added to it with
- uuconf_add_block. No errors can occur. */
-extern void uuconf_free_block (void *uuconf_pblock);
-
-#else /* ! UUCONF_ANSI_C */
-
-extern UUCONF_POINTER uuconf_malloc_block ();
-extern UUCONF_POINTER uuconf_malloc ();
-extern int uuconf_add_block ();
-extern /* void */ uuconf_free ();
-extern /* void */ uuconf_free_block ();
-
-#endif /* ! UUCONF_ANSI_C */
-
-#endif /* ! defined (UUCONF_H) */
diff --git a/gnu/libexec/uucp/common_sources/uucp.h b/gnu/libexec/uucp/common_sources/uucp.h
deleted file mode 100644
index 4636910..0000000
--- a/gnu/libexec/uucp/common_sources/uucp.h
+++ /dev/null
@@ -1,398 +0,0 @@
-/* uucp.h
- Header file for the UUCP package.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-/* Get the system configuration parameters. */
-#include "config.h"
-#include "policy.h"
-
-/* Get a definition for ANSI_C if we weren't given one. */
-#ifndef ANSI_C
-#ifdef __STDC__
-#define ANSI_C 1
-#else /* ! defined (__STDC__) */
-#define ANSI_C 0
-#endif /* ! defined (__STDC__) */
-#endif /* ! defined (ANSI_C) */
-
-/* Pass this definition into uuconf.h. */
-#define UUCONF_ANSI_C ANSI_C
-
-/* We always include some standard header files. We need <signal.h>
- to define sig_atomic_t. */
-#include <stdio.h>
-#include <signal.h>
-#if HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-
-/* On some systems we need <sys/types.h> to get sig_atomic_t or
- size_t or time_t. */
-#if ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H && HAVE_SIG_ATOMIC_T_IN_TYPES_H
-#define USE_TYPES_H 1
-#else
-#if ! HAVE_SIZE_T_IN_STDDEF_H && HAVE_SIZE_T_IN_TYPES_H
-#define USE_TYPES_H 1
-#else
-#if ! HAVE_TIME_T_IN_TIME_H && HAVE_TIME_T_IN_TYPES_H
-#define USE_TYPES_H 1
-#endif
-#endif
-#endif
-
-#ifndef USE_TYPES_H
-#define USE_TYPES_H 0
-#endif
-
-#if USE_TYPES_H
-#include <sys/types.h>
-#endif
-
-/* Make sure we have sig_atomic_t. */
-#if ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H && ! HAVE_SIG_ATOMIC_T_IN_TYPES_H
-#ifndef SIG_ATOMIC_T
-/* There is no portable definition for sig_atomic_t. */
-#define SIG_ATOMIC_T char
-#endif /* ! defined (SIG_ATOMIC_T) */
-typedef SIG_ATOMIC_T sig_atomic_t;
-#endif /* ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H && ! HAVE_SIG_ATOMIC_T_IN_TYPES_H */
-
-/* Make sure we have size_t. */
-#if ! HAVE_SIZE_T_IN_STDDEF_H && ! HAVE_SIZE_T_IN_TYPES_H
-#ifndef SIZE_T
-#define SIZE_T unsigned
-#endif /* ! defined (SIZE_T) */
-typedef SIZE_T size_t;
-#endif /* ! HAVE_SIZE_T_IN_STDDEF_H && ! HAVE_SIZE_T_IN_TYPES_H */
-
-/* Make sure we have time_t. We use long as the default. We don't
- bother to let conf.h override this, since on a system which doesn't
- define time_t long must be correct. */
-#if ! HAVE_TIME_T_IN_TIME_H && ! HAVE_TIME_T_IN_TYPES_H
-typedef long time_t;
-#endif
-
-/* Set up some definitions for both ANSI C and Classic C.
-
- P() -- for function prototypes (e.g. extern int foo P((int)) ).
- pointer -- for a generic pointer (i.e. void *).
- constpointer -- for a generic pointer to constant data.
- BUCHAR -- to convert a character to unsigned. */
-#if ANSI_C
-#if ! HAVE_VOID || ! HAVE_UNSIGNED_CHAR || ! HAVE_PROTOTYPES
- #error ANSI C compiler without void or unsigned char or prototypes
-#endif
-#define P(x) x
-typedef void *pointer;
-typedef const void *constpointer;
-#define BUCHAR(b) ((unsigned char) (b))
-#else /* ! ANSI_C */
-/* Handle uses of volatile and void in Classic C. */
-#define volatile
-#if ! HAVE_VOID
-#define void int
-#endif
-#if HAVE_PROTOTYPES
-#define P(x) x
-#else
-#define P(x) ()
-#endif
-typedef char *pointer;
-typedef const char *constpointer;
-#if HAVE_UNSIGNED_CHAR
-#define BUCHAR(b) ((unsigned char) (b))
-#else /* ! HAVE_UNSIGNED_CHAR */
-/* This should work on most systems, but not necessarily all. */
-#define BUCHAR(b) ((b) & 0xff)
-#endif /* ! HAVE_UNSIGNED_CHAR */
-#endif /* ! ANSI_C */
-
-/* Make sure we have a definition for offsetof. */
-#ifndef offsetof
-#define offsetof(type, field) \
- ((size_t) ((char *) &(((type *) 0)->field) - (char *) (type *) 0))
-#endif
-
-/* Only use inline with gcc. */
-#ifndef __GNUC__
-#define __inline__
-#endif
-
-/* Get the string functions, which are used throughout the code. */
-#if HAVE_MEMORY_H
-#include <memory.h>
-#else
-/* We really need a definition for memchr, and this should not
- conflict with anything in <string.h>. I hope. */
-extern pointer memchr ();
-#endif
-
-#if HAVE_STRING_H
-#include <string.h>
-#else /* ! HAVE_STRING_H */
-#if HAVE_STRINGS_H
-#include <strings.h>
-#else /* ! HAVE_STRINGS_H */
-extern char *strcpy (), *strncpy (), *strchr (), *strrchr (), *strtok ();
-extern char *strcat (), *strerror (), *strstr ();
-extern size_t strlen (), strspn (), strcspn ();
-#if ! HAVE_MEMORY_H
-extern pointer memcpy (), memchr ();
-#endif /* ! HAVE_MEMORY_H */
-#endif /* ! HAVE_STRINGS_H */
-#endif /* ! HAVE_STRING_H */
-
-/* Get what we need from <stdlib.h>. */
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#else /* ! HAVE_STDLIB_H */
-extern pointer malloc (), realloc (), bsearch ();
-extern long strtol ();
-extern unsigned long strtoul ();
-extern char *getenv ();
-#endif /* ! HAVE_STDLIB_H */
-
-/* NeXT uses <libc.h> to declare a bunch of functions. */
-#if HAVE_LIBC_H
-#include <libc.h>
-#endif
-
-/* Make sure we have the EXIT_ macros. */
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS (0)
-#endif
-#ifndef EXIT_FAILURE
-#define EXIT_FAILURE (1)
-#endif
-
-/* If we need to declare errno, do so. I don't want to always do
- this, because some system might theoretically have a different
- declaration for errno. On a POSIX system this is sure to work. */
-#if ! HAVE_ERRNO_DECLARATION
-extern int errno;
-#endif
-
-/* If the system has the socket call, guess that we can compile the
- TCP code. */
-#define HAVE_TCP HAVE_SOCKET
-
-/* If the system has the t_open call, guess that we can compile the
- TLI code. */
-#define HAVE_TLI HAVE_T_OPEN
-
-/* The boolean type holds boolean values. */
-typedef int boolean;
-#undef TRUE
-#undef FALSE
-#define TRUE (1)
-#define FALSE (0)
-
-/* The openfile_t type holds an open file. This depends on whether we
- are using stdio or not. */
-#if USE_STDIO
-
-typedef FILE *openfile_t;
-#define EFILECLOSED ((FILE *) NULL)
-#define ffileisopen(e) ((e) != NULL)
-#define ffileeof(e) feof (e)
-#define cfileread(e, z, c) fread ((z), 1, (c), (e))
-#define cfilewrite(e, z, c) fwrite ((z), 1, (c), (e))
-#define ffileioerror(e, c) ferror (e)
-#ifdef SEEK_SET
-#define ffileseek(e, i) (fseek ((e), (long) (i), SEEK_SET) == 0)
-#define ffilerewind(e) (fseek ((e), (long) 0, SEEK_SET) == 0)
-#else
-#define ffileseek(e, i) (fseek ((e), (long) (i), 0) == 0)
-#define ffilerewind(e) (fseek ((e), (long) 0, 0) == 0)
-#endif
-#ifdef SEEK_END
-#define ffileseekend(e) (fseek ((e), (long) 0, SEEK_END) == 0)
-#else
-#define ffileseekend(e) (fseek ((e), (long) 0, 2) == 0)
-#endif
-#define ffileclose(e) (fclose (e) == 0)
-
-#define fstdiosync(e, z) (fsysdep_sync (e, z))
-
-#else /* ! USE_STDIO */
-
-#if ! USE_TYPES_H
-#undef USE_TYPES_H
-#define USE_TYPES_H 1
-#include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef OFF_T
-typedef OFF_T off_t;
-#undef OFF_T
-#endif
-
-typedef int openfile_t;
-#define EFILECLOSED (-1)
-#define ffileisopen(e) ((e) >= 0)
-#define ffileeof(e) (FALSE)
-#define cfileread(e, z, c) read ((e), (z), (c))
-#define cfilewrite(e, z, c) write ((e), (z), (c))
-#define ffileioerror(e, c) ((c) < 0)
-#ifdef SEEK_SET
-#define ffileseek(e, i) (lseek ((e), (off_t) i, SEEK_SET) >= 0)
-#define ffilerewind(e) (lseek ((e), (off_t) 0, SEEK_SET) >= 0)
-#else
-#define ffileseek(e, i) (lseek ((e), (off_t) i, 0) >= 0)
-#define ffilerewind(e) (lseek ((e), (off_t) 0, 0) >= 0)
-#endif
-#ifdef SEEK_END
-#define ffileseekend(e) (lseek ((e), (off_t) 0, SEEK_END) >= 0)
-#else
-#define ffileseekend(e) (lseek ((e), (off_t) 0, 2) >= 0)
-#endif
-#define ffileclose(e) (close (e) >= 0)
-
-#define fstdiosync(e, z) (fsysdep_sync (fileno (e), z))
-
-#endif /* ! USE_STDIO */
-
-/* A prototype for main to avoid warnings from gcc 2.0
- -Wmissing-prototype option. */
-extern int main P((int argc, char **argv));
-
-/* Some standard routines which we only define if they are not present
- on the system we are compiling on. */
-
-#if ! HAVE_GETLINE
-/* Read a line from a file. */
-extern int getline P((char **pz, size_t *pc, FILE *e));
-#endif
-
-#if ! HAVE_REMOVE
-/* Erase a file. */
-#undef remove
-extern int remove P((const char *zfile));
-#endif
-
-#if ! HAVE_STRDUP
-/* Copy a string into memory. */
-extern char *strdup P((const char *z));
-#endif
-
-#if ! HAVE_STRSTR
-/* Look for one string within another. */
-extern char *strstr P((const char *zouter, const char *zinner));
-#endif
-
-#if ! HAVE_STRCASECMP
-#if HAVE_STRICMP
-#define strcasecmp stricmp
-#else /* ! HAVE_STRICMP */
-/* Rename strcasecmp to avoid ANSI C name space. */
-#define strcasecmp xstrcasecmp
-extern int strcasecmp P((const char *z1, const char *z2));
-#endif /* ! HAVE_STRICMP */
-#endif /* ! HAVE_STRCASECMP */
-
-#if ! HAVE_STRNCASECMP
-#if HAVE_STRNICMP
-#define strncasecmp strnicmp
-#else /* ! HAVE_STRNICMP */
-/* Rename strncasecmp to avoid ANSI C name space. */
-#define strncasecmp xstrncasecmp
-extern int strncasecmp P((const char *z1, const char *z2, size_t clen));
-#endif /* ! HAVE_STRNICMP */
-#endif /* ! HAVE_STRNCASECMP */
-
-#if ! HAVE_STRERROR
-/* Get a string corresponding to an error message. */
-#undef strerror
-extern char *strerror P((int ierr));
-#endif
-
-/* Get the appropriate definitions for memcmp, memcpy, memchr and
- bzero. */
-#if ! HAVE_MEMCMP
-#if HAVE_BCMP
-#define memcmp(p1, p2, c) bcmp ((p1), (p2), (c))
-#else /* ! HAVE_BCMP */
-extern int memcmp P((constpointer p1, constpointer p2, size_t c));
-#endif /* ! HAVE_BCMP */
-#endif /* ! HAVE_MEMCMP */
-
-#if ! HAVE_MEMCPY
-#if HAVE_BCOPY
-#define memcpy(pto, pfrom, c) bcopy ((pfrom), (pto), (c))
-#else /* ! HAVE_BCOPY */
-extern pointer memcpy P((pointer pto, constpointer pfrom, size_t c));
-#endif /* ! HAVE_BCOPY */
-#endif /* ! HAVE_MEMCPY */
-
-#if ! HAVE_MEMCHR
-extern pointer memchr P((constpointer p, int b, size_t c));
-#endif
-
-#if ! HAVE_BZERO
-#if HAVE_MEMSET
-#define bzero(p, c) memset ((p), 0, (c))
-#else /* ! HAVE_MEMSET */
-extern void bzero P((pointer p, int c));
-#endif /* ! HAVE_MEMSET */
-#endif /* ! HAVE_BZERO */
-
-/* Look up a character in a string. */
-#if ! HAVE_STRCHR
-#if HAVE_INDEX
-#define strchr index
-extern char *index ();
-#else /* ! HAVE_INDEX */
-extern char *strchr P((const char *z, int b));
-#endif /* ! HAVE_INDEX */
-#endif /* ! HAVE_STRCHR */
-
-#if ! HAVE_STRRCHR
-#if HAVE_RINDEX
-#define strrchr rindex
-extern char *rindex ();
-#else /* ! HAVE_RINDEX */
-extern char *strrchr P((const char *z, int b));
-#endif /* ! HAVE_RINDEX */
-#endif /* ! HAVE_STRRCHR */
-
-/* Turn a string into a long integer. */
-#if ! HAVE_STRTOL
-extern long strtol P((const char *, char **, int));
-#endif
-
-/* Turn a string into a long unsigned integer. */
-#if ! HAVE_STRTOUL
-extern unsigned long strtoul P((const char *, char **, int));
-#endif
-
-/* Lookup a key in a sorted array. */
-#if ! HAVE_BSEARCH
-extern pointer bsearch P((constpointer pkey, constpointer parray,
- size_t celes, size_t cbytes,
- int (*pficmp) P((constpointer, constpointer))));
-#endif
diff --git a/gnu/libexec/uucp/common_sources/uudefs.h b/gnu/libexec/uucp/common_sources/uudefs.h
deleted file mode 100644
index 2b45502..0000000
--- a/gnu/libexec/uucp/common_sources/uudefs.h
+++ /dev/null
@@ -1,449 +0,0 @@
-/* uudefs.h
- Miscellaneous definitions for the UUCP package.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#if ANSI_C
-/* These structures are used in prototypes but are not defined in this
- header file. */
-struct uuconf_system;
-struct uuconf_timespan;
-#endif
-
-/* The tlog enumeration holds the different types of logging. */
-enum tlog
-{
- /* Normal log entry. */
- LOG_NORMAL,
- /* Error log entry. */
- LOG_ERROR,
- /* Fatal log entry. */
- LOG_FATAL
-#if DEBUG > 1
- ,
- /* Debugging log entry. */
- LOG_DEBUG,
- /* Start debugging log entry. */
- LOG_DEBUG_START,
- /* Continue debugging log entry. */
- LOG_DEBUG_CONTINUE,
- /* End debugging log entry. */
- LOG_DEBUG_END
-#endif
-};
-
-/* The tstatus_type enumeration holds the kinds of status information
- we put in the status file. The order of entries here corresponds
- to the order of entries in the azStatus array. */
-enum tstatus_type
-{
- /* Conversation complete. */
- STATUS_COMPLETE,
- /* Port unavailable. */
- STATUS_PORT_FAILED,
- /* Dial failed. */
- STATUS_DIAL_FAILED,
- /* Login failed. */
- STATUS_LOGIN_FAILED,
- /* Handshake failed. */
- STATUS_HANDSHAKE_FAILED,
- /* Failed after logging in. */
- STATUS_FAILED,
- /* Talking to remote system. */
- STATUS_TALKING,
- /* Wrong time to call. */
- STATUS_WRONG_TIME,
- /* Number of status values. */
- STATUS_VALUES
-};
-
-/* An array to convert status entries to strings. If more status entries
- are added, this array must be extended. */
-extern const char *azStatus[];
-
-/* The sstatus structure holds the contents of a system status file. */
-struct sstatus
-{
- /* Current status of conversation. */
- enum tstatus_type ttype;
- /* Number of failed retries. */
- int cretries;
- /* Time of last call in seconds since epoch (determined by
- ixsysdep_time). */
- long ilast;
- /* Number of seconds until a retry is permitted. */
- int cwait;
- /* String in status file. Only used when reading status file, not
- when writing. May be NULL. Should be freed with ubuffree. */
- char *zstring;
-};
-
-/* How long we have to wait for the next call, given the number of retries
- we have already made. This should probably be configurable. */
-#define CRETRY_WAIT(c) ((c) * 10 * 60)
-
-/* The scmd structure holds a complete UUCP command. */
-struct scmd
-{
- /* Command ('S' for send, 'R' for receive, 'X' for execute, 'E' for
- simple execution, 'H' for hangup, 'Y' for hangup confirm, 'N' for
- hangup deny). */
- char bcmd;
- /* Grade of the command ('\0' if from remote system). */
- char bgrade;
- /* Sequence handle for fsysdep_did_work. */
- pointer pseq;
- /* File name to transfer from. */
- const char *zfrom;
- /* File name to transfer to. */
- const char *zto;
- /* User who requested transfer. */
- const char *zuser;
- /* Options. */
- const char *zoptions;
- /* Temporary file name ('S' and 'E'). */
- const char *ztemp;
- /* Mode to give newly created file ('S' and 'E'). */
- unsigned int imode;
- /* User to notify on remote system (optional; 'S' and 'E'). */
- const char *znotify;
- /* File size (-1 if not supplied) ('S', 'E' and 'R'). */
- long cbytes;
- /* Command to execute ('E'). */
- const char *zcmd;
- /* Position to restart from ('R'). */
- long ipos;
-};
-
-#if DEBUG > 1
-
-/* We allow independent control over several different types of
- debugging output, using a bit string with individual bits dedicated
- to particular debugging types. */
-
-/* The bit string is stored in iDebug. */
-extern int iDebug;
-
-/* Debug abnormal events. */
-#define DEBUG_ABNORMAL (01)
-/* Debug chat scripts. */
-#define DEBUG_CHAT (02)
-/* Debug initial handshake. */
-#define DEBUG_HANDSHAKE (04)
-/* Debug UUCP protocol. */
-#define DEBUG_UUCP_PROTO (010)
-/* Debug protocols. */
-#define DEBUG_PROTO (020)
-/* Debug port actions. */
-#define DEBUG_PORT (040)
-/* Debug configuration files. */
-#define DEBUG_CONFIG (0100)
-/* Debug spool directory actions. */
-#define DEBUG_SPOOLDIR (0200)
-/* Debug executions. */
-#define DEBUG_EXECUTE (0400)
-/* Debug incoming data. */
-#define DEBUG_INCOMING (01000)
-/* Debug outgoing data. */
-#define DEBUG_OUTGOING (02000)
-
-/* Maximum possible value for iDebug. */
-#define DEBUG_MAX (03777)
-
-/* Intializer for array of debug names. The index of the name in the
- array is the corresponding bit position in iDebug. We only check
- for prefixes, so these names only need to be long enough to
- distinguish each name from every other. The last entry must be
- NULL. The string "all" is also recognized to turn on all
- debugging. */
-#define DEBUG_NAMES \
- { "a", "ch", "h", "u", "pr", "po", "co", "s", "e", "i", "o", NULL }
-
-/* The prefix to use to turn off all debugging. */
-#define DEBUG_NONE "n"
-
-/* Check whether a particular type of debugging is being done. */
-#define FDEBUGGING(i) ((iDebug & (i)) != 0)
-
-/* These macros are used to output debugging information. I use
- several different macros depending on the number of arguments
- because no macro can take a variable number of arguments and I
- don't want to use double parentheses. */
-#define DEBUG_MESSAGE0(i, z) \
- do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z)); } while (0)
-#define DEBUG_MESSAGE1(i, z, a1) \
- do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z), (a1)); } while (0)
-#define DEBUG_MESSAGE2(i, z, a1, a2) \
- do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z), (a1), (a2)); } while (0)
-#define DEBUG_MESSAGE3(i, z, a1, a2, a3) \
- do \
- { \
- if (FDEBUGGING (i)) \
- ulog (LOG_DEBUG, (z), (a1), (a2), (a3)); \
- } \
- while (0)
-#define DEBUG_MESSAGE4(i, z, a1, a2, a3, a4) \
- do \
- { \
- if (FDEBUGGING (i)) \
- ulog (LOG_DEBUG, (z), (a1), (a2), (a3), (a4)); \
- } \
- while (0)
-
-#else /* DEBUG <= 1 */
-
-/* If debugging information is not being compiled, provide versions of
- the debugging macros which just disappear. */
-#define DEBUG_MESSAGE0(i, z)
-#define DEBUG_MESSAGE1(i, z, a1)
-#define DEBUG_MESSAGE2(i, z, a1, a2)
-#define DEBUG_MESSAGE3(i, z, a1, a2, a3)
-#define DEBUG_MESSAGE4(i, z, a1, a2, a3, a4)
-
-#endif /* DEBUG <= 1 */
-
-/* Functions. */
-
-/* Given an unknown system name, return information for an unknown
- system. If unknown systems are not permitted, this returns FALSE.
- Otherwise, it translates the name as necessary for the spool
- directory, and fills in *qsys. */
-extern boolean funknown_system P((pointer puuconf, const char *zsystem,
- struct uuconf_system *qsys));
-
-/* See whether a file belongs in the spool directory. */
-extern boolean fspool_file P((const char *zfile));
-
-/* See if the current time matches a time span. If not, return FALSE.
- Otherwise, return TRUE and set *pival and *pcretry to the values
- from the matching element of the span. */
-extern boolean ftimespan_match P((const struct uuconf_timespan *qspan,
- long *pival, int *pcretry));
-
-/* Remove all occurrences of the local system name followed by an
- exclamation point from the start of the argument. Return the
- possibly shortened argument. */
-extern char *zremove_local_sys P((struct uuconf_system *qlocalsys,
- char *z));
-
-/* Determine the maximum size that may ever be transferred, given a
- timesize span. If there are any time gaps larger than 1 hour not
- described by the timesize span, this returns -1. Otherwise it
- returns the largest size that may be transferred at some time. */
-extern long cmax_size_ever P((const struct uuconf_timespan *qtimesize));
-
-/* Send mail about a file transfer. */
-extern boolean fmail_transfer P((boolean fok, const char *zuser,
- const char *zmail, const char *zwhy,
- const char *zfrom, const char *zfromsys,
- const char *zto, const char *ztosys,
- const char *zsaved));
-
-/* See whether a file is in one of a list of directories. The zpubdir
- argument is used to pass the directory names to zsysdep_local_file.
- If fcheck is FALSE, this does not check accessibility. Otherwise,
- if freadable is TRUE, the user zuser must have read access to the
- file and all appropriate directories; if freadable is FALSE zuser
- must have write access to the appropriate directories. The zuser
- argument may be NULL, in which case all users must have the
- appropriate access (this is used for a remote request). */
-extern boolean fin_directory_list P((const char *zfile,
- char **pzdirs,
- const char *zpubdir,
- boolean fcheck,
- boolean freadable,
- const char *zuser));
-
-/* Parse a command string. */
-extern boolean fparse_cmd P((char *zcmd, struct scmd *qcmd));
-
-/* Make a log entry. */
-#ifdef __GNUC__
-#define GNUC_VERSION __GNUC__
-#else
-#define GNUC_VERSION 0
-#endif
-
-#if ANSI_C && HAVE_VFPRINTF
-extern void ulog P((enum tlog ttype, const char *zfmt, ...))
-#if GNUC_VERSION > 1
- __attribute__ ((format (printf, 2, 3)))
-#endif
- ;
-#else
-extern void ulog ();
-#endif
-
-#undef GNUC_VERSION
-
-/* Report an error returned by one of the uuconf routines. */
-extern void ulog_uuconf P((enum tlog ttype, pointer puuconf,
- int iuuconf));
-
-/* Set the function to call if a fatal error occurs. */
-extern void ulog_fatal_fn P((void (*pfn) P((void))));
-
-/* If ffile is TRUE, send log entries to the log file rather than to
- stderr. */
-extern void ulog_to_file P((pointer puuconf, boolean ffile));
-
-/* Set the ID number used by the logging functions. */
-extern void ulog_id P((int iid));
-
-/* Set the system name used by the logging functions. */
-extern void ulog_system P((const char *zsystem));
-
-/* Set the system and user name used by the logging functions. */
-extern void ulog_user P((const char *zuser));
-
-/* Set the device name used by the logging functions. */
-extern void ulog_device P((const char *zdevice));
-
-/* Close the log file. */
-extern void ulog_close P((void));
-
-/* Make an entry in the statistics file. */
-extern void ustats P((boolean fsucceeded, const char *zuser,
- const char *zsystem, boolean fsent,
- long cbytes, long csecs, long cmicros,
- boolean fcaller));
-
-/* Close the statistics file. */
-extern void ustats_close P((void));
-
-#if DEBUG > 1
-/* A debugging routine to output a buffer. This outputs zhdr, the
- buffer length clen, and the contents of the buffer in quotation
- marks. */
-extern void udebug_buffer P((const char *zhdr, const char *zbuf,
- size_t clen));
-
-/* A debugging routine to make a readable version of a character.
- This takes a buffer at least 5 bytes long, and returns the length
- of the string it put into it (not counting the null byte). */
-extern size_t cdebug_char P((char *z, int ichar));
-
-/* Parse a debugging option string. This can either be a number or a
- comma separated list of debugging names. This returns a value for
- iDebug. */
-extern int idebug_parse P((const char *));
-
-#endif /* DEBUG <= 1 */
-
-/* Copy one file to another. */
-extern boolean fcopy_file P((const char *zfrom, const char *zto,
- boolean fpublic, boolean fmkdirs,
- boolean fsignals));
-
-/* Copy an open file to another. */
-extern boolean fcopy_open_file P((openfile_t efrom, const char *zto,
- boolean fpublic, boolean fmkdirs,
- boolean fsignals));
-
-/* Translate escape sequences in a buffer, leaving the result in the
- same buffer and returning the length. */
-extern size_t cescape P((char *zbuf));
-
-/* Get a buffer to hold a string of a given size. The buffer should
- be freed with ubuffree. */
-extern char *zbufalc P((size_t csize));
-
-/* Call zbufalc to allocate a buffer and copy a string into it. */
-extern char *zbufcpy P((const char *z));
-
-/* Free up a buffer returned by zbufalc or zbufcpy. */
-extern void ubuffree P((char *z));
-
-/* Allocate memory without fail. */
-extern pointer xmalloc P((size_t));
-
-/* Realloc memory without fail. */
-extern pointer xrealloc P((pointer, size_t));
-
-/* Free memory (accepts NULL pointers, which some libraries erroneously
- do not). */
-extern void xfree P((pointer));
-
-/* Global variables. */
-
-/* The name of the program being run. Set from argv[0]. */
-extern const char *zProgram;
-
-/* When a signal occurs, the signal handlers sets the appropriate
- element of the arrays afSignal and afLog_signal to TRUE. The
- afSignal array is used to check whether a signal occurred. The
- afLog_signal array tells ulog to log the signal; ulog will clear
- the element after logging it, which means that if a signal comes in
- at just the right moment it will not be logged. It will always be
- recorded in afSignal, though. At the moment we handle 5 signals:
- SIGHUP, SIGINT, SIGQUIT, SIGTERM and SIGPIPE (the Unix code also
- handles SIGALRM). If we want to handle more, the afSignal array
- must be extended; I see little point to handling any of the other
- ANSI C or POSIX signals, as they are either unlikely to occur
- (SIGABRT, SIGUSR1) or nearly impossible to handle cleanly (SIGILL,
- SIGSEGV). SIGHUP is only logged if fLog_sighup is TRUE. */
-#define INDEXSIG_SIGHUP (0)
-#define INDEXSIG_SIGINT (1)
-#define INDEXSIG_SIGQUIT (2)
-#define INDEXSIG_SIGTERM (3)
-#define INDEXSIG_SIGPIPE (4)
-#define INDEXSIG_COUNT (5)
-
-extern volatile sig_atomic_t afSignal[INDEXSIG_COUNT];
-extern volatile sig_atomic_t afLog_signal[INDEXSIG_COUNT];
-extern boolean fLog_sighup;
-
-/* The names of the signals to use in error messages, as an
- initializer for an array. */
-#define INDEXSIG_NAMES \
- { "hangup", "interrupt", "quit", "termination", "SIGPIPE" }
-
-/* Check to see whether we've received a signal. It would be nice if
- we could use a single variable for this, but we sometimes want to
- clear our knowledge of a signal and that would cause race
- conditions (clearing a single element of the array is not a race
- assuming that we don't care about a particular signal, even if it
- occurs after we've examined the array). */
-#define FGOT_SIGNAL() \
- (afSignal[INDEXSIG_SIGHUP] || afSignal[INDEXSIG_SIGINT] \
- || afSignal[INDEXSIG_SIGQUIT] || afSignal[INDEXSIG_SIGTERM] \
- || afSignal[INDEXSIG_SIGPIPE])
-
-/* If we get a SIGINT in uucico, we continue the current communication
- session but don't start any new ones. This macros checks for any
- signal other than SIGINT, which means we should get out
- immediately. */
-#define FGOT_QUIT_SIGNAL() \
- (afSignal[INDEXSIG_SIGHUP] || afSignal[INDEXSIG_SIGQUIT] \
- || afSignal[INDEXSIG_SIGTERM] || afSignal[INDEXSIG_SIGPIPE])
-
-/* Device name to log. This is set by fconn_open. It may be NULL. */
-extern char *zLdevice;
-
-/* If not NULL, ulog calls this function before outputting anything.
- This is used to support cu. */
-extern void (*pfLstart) P((void));
-
-/* If not NULL, ulog calls this function after outputting everything.
- This is used to support cu. */
-extern void (*pfLend) P((void));
diff --git a/gnu/libexec/uucp/contrib/Dial.Hayes b/gnu/libexec/uucp/contrib/Dial.Hayes
deleted file mode 100644
index 32eef82..0000000
--- a/gnu/libexec/uucp/contrib/Dial.Hayes
+++ /dev/null
@@ -1,108 +0,0 @@
-#!xchat
-# @(#) dial.hayes V1.1 Tue Sep 1 13:59:58 1992 (Bob Denny)
-#
-# xchat script for dialing a vanilla Hayes modem
-#
-# Usage:
-# xchat dial.hayes telno
-#
-# where telno is the telephone number, subject to pause and wait
-# character modification.
-#
-# Uncomment the first two lines after "start:" to get debugging
-# in file "Dial.Log"
-#
-# Flush input, zero counter, set telephone number if supplied,
-# else fail if no telephone number given.
-#
-start:
-### dbgfile Dial.Log
-### dbgset 15
- zero
- flush
- ifnstr notelno 0
- telno 0
- goto initmodem
-#
-# Missing telephone number.
-#
-notelno:
- logerr No telephone number given
- failed
-#
-# Reset the modem to nonvolatile profile.
-# Allow 3 sec. for response, as some modems are slow to reset.
-#
-initmodem:
- count
- ifgtr cantinit 4
- send ATZ\r
- timeout initmodem 3000
- expect setupmodem OK
-#
-# No response from modem
-#
-cantinit:
- logerr Can't wake modem
- failed
-#
-# Send the stuff needed to initialize the modem to the modes
-# needed for the particular modem flavor. The string below
-# is provided as a vanilla example. Allow 2 sec. for the
-# modem to respond to this command.
-#
-setupmodem:
- sleep 1000
- send ATM0S7=90S11=120\r
- timeout setupfail 2000
- expect setupfail ERROR
- expect dialnumber OK
-#
-# Modem barfed or died on setup command.
-#
-setupfail:
- logerr Error in modem setup string
- failed
-#
-# Dial the supplied number. Handle the various errors that
-# can come back from the modem by logging the error.
-#
-dialnumber:
- sleep 1000
- send ATDT
- dial
- send \r
- flush
- timeout timeout 90000
- expect connected CONNECT
- expect busy BUSY
- expect nocarrier NO CARRIER
- expect noanswer NO ANSWER
- expect nodialtone NO DIALTONE
-#
-# Success!
-#
-connected:
- success
-#
-# Handle modem dial failures
-#
-timeout:
- logerr Modem or carrier timeout.
- failed
-busy:
- logerr BUSY
- failed
-nocarrier:
- logerr NO CARRIER
- failed
-noanswer:
- logerr NO ANSWER
- failed
-nodialtone:
- logerr NO DIALTONE
- failed
-#
-# end
-#
-
diff --git a/gnu/libexec/uucp/contrib/Hangup.Hayes b/gnu/libexec/uucp/contrib/Hangup.Hayes
deleted file mode 100644
index c111c00..0000000
--- a/gnu/libexec/uucp/contrib/Hangup.Hayes
+++ /dev/null
@@ -1,57 +0,0 @@
-#!xchat
-# @(#) Hangup.Hayes V1.1 Tue Sep 1 14:04:25 1992 (Bob Denny)
-#
-# xchat script for hanging up a Hayes-type modem. When used with Taylor
-# UUCP, this script should be run as the dialer-complete and dialer-abort
-# script with xchat.
-#
-# Usage:
-# xchat Hangup.Hayes [ x ]
-#
-# where 'x' is any string. If it is present, this script will log the
-# modem reset as an ABORT reset, otherwise it will not log anything.
-#
-# Uncomment the lines starting with '###' to get debugging log.
-#
-start:
-### dbgfile Hangup.Log
-### dbgset 15
- zero
- sleep 2000 # Wait for trailing garbage
- flush # Toss it out
- ifnstr wakemodem 0 # No abort indicator
- log Hangup on abort
-#
-# Get modem's attention via Hayes 'escape' protocol.
-#
-wakemodem:
- sleep 4000
- send +++
- sleep 4000
- send \r
- timeout reset 2000
- expect reset OK
-#
-# We're (probably) in command mode. Use ATZ (reset) to hang up
-# as some modems don't behave well with ATH0 command.
-#
-reset:
- send ATZ\r
- timeout silent 5000
- expect done OK
-#
-# Finished, modem is back in initial state.
-#
-done:
- success
-#
-# No response to escape protocol. Log the error and force DTR low
-# in an attempt to get control of the modem. Then send ATZ just to
-# make sure.
-#
-silent:
- logerr Hangup: no response from modem
- hangup # Force DTR low as last gasp
- send ATZ\r
- sleep 5000
- failed
diff --git a/gnu/libexec/uucp/contrib/Login.LAT b/gnu/libexec/uucp/contrib/Login.LAT
deleted file mode 100644
index d557f97..0000000
--- a/gnu/libexec/uucp/contrib/Login.LAT
+++ /dev/null
@@ -1,137 +0,0 @@
-#!xchat
-# @(#) login.LAT V1.2 Tue Sep 1 13:25:28 1992
-#
-# xchat script for logging into a VMS system through a LAT
-# terminal server port. If no VMS password parameter supplied,
-# skips password phase of VMS login. If LAT-password supplied,
-# will log into LAT server using that password. NOTE: does not
-# handle the situation where a LAT password is needed but no
-# VMS password is needed.
-#
-# Usage:
-# xchat login.LAT sysname username [ password [ LAT-password ] ]
-#
-# History:
-# rbd Fri Aug 14 13:37:06 1992
-# Changes for Lantronix ETS-16. It says "type help at the Local>
-# prompt..." then it gives the prompt for real! Prompt may need
-# to be something other than "Local>". We match the real Local>
-# prompt by matching the leading newline!
-#
-# rbd Tue Sep 1 13:04:32 1992
-# Remove absolute path name from log file. Now defaults per config.
-#
-start:
- dbgfile Login.Log
- dbgset 15
- sleep 2000 # Wait 2 seconds
- flush # Flush typeahead
- ifnstr svrstart 3 # Skip server password if not given
-#
-# Starting point if server password supplied. Handle situation
-# where the server line may have been left waiting for username
-# or at local> prompt.
-#
-getsvrpwp:
- zero
-l0:
- count # Get server's password prompt
- ifgtr deadmux 5 # die if 5 cr's don't do it
- send \r
- timeout l0 1000 # Wait and try again
- expect dosvrpw ssword>
- expect svrlogin ername>
- expect connect \nLocal>
-#
-# Send server's password. Fail if don't get Username
-# or Local> prompt.
-#
-dosvrpw:
- zero
-l2:
- sendstr 3
- send \r
- timeout badsvrpw 5000 # Die if invalid
- expect svrlogin ername>
- expect connect \nLocal>
-#
-# Starting point if NO server password supplied. Handle situation
-# where the server line may have been left at local> prompt.
-#
-svrstart:
- zero
-l1:
- count # Get username> or local> prompt
- ifgtr deadmux 5 # Die if 5 cr's don't do it
- send \r
- timeout l1 1000 # Wait and try again
- expect svrlogin ername>
- expect connect \nLocal>
-#
-# Server asked for a username. Just give 'uucp'.
-#
-svrlogin:
- send uucp\r
- timeout deadmux 2000
- expect connect \nLocal>
-#
-# At this point, we have the Local> prompt. Send the connect
-# command for the specified LAT host service name, and wait for
-# VMS "Username:" prompt. Die after 10 seconds.
-#
-connect:
- send c\s
- sendstr 0
- send \r
- timeout nologin 10000
- expect gotlogin ername:
-#
-# Got VMS "Username:" prompt. Send the username. If a password
-# was given, wait for the "Password:" prompt. Die after 10 seconds.
-# if no password was given, we're done!
-#
-gotlogin:
- sendstr 1
- send \r
- ifnstr done 2
- timeout nopasswd 10000
- expect gotpasswd ssword:
-#
-# Got VMS "Password:" prompt. Send the password and we're done!
-#
-gotpasswd:
- sendstr 2
- send \r
-#
-# Success!
-#
-done:
- success
-#
-# ERROR HANDLERS
-#
-#
-# LAT server appears dead. Fail.
-#
-deadmux:
- logerr No response from LAT server
- failed
-#
-# The server password was bad. Fail.
-#
-badsvrpw:
- logerr Invalid LAT server password
- failed
-#
-# VMS system appears to be dead. Fail.
-#
-nologin:
- logerr No VMS Username: prompt
- failed
-#
-# Failed to get "Password:" prompt. Fail.
-#
-nopasswd:
- logerr No VMS Password: prompt. Invalid password?
- failed
-
diff --git a/gnu/libexec/uucp/contrib/Login.PortSel b/gnu/libexec/uucp/contrib/Login.PortSel
deleted file mode 100644
index d8c3a66..0000000
--- a/gnu/libexec/uucp/contrib/Login.PortSel
+++ /dev/null
@@ -1,133 +0,0 @@
-#!xchat
-# @(#) Login.PortSelUnix V1.0 Tue Sep 1 14:57:05 1992 (Bob Denny)
-#
-# NOTE: Untested with xchat V1.1. Taken from DECUS UUCP.
-#
-# From: "Kent C. Brodie" <moocow!brodie@CSD4.MILW.WISC.EDU>
-# uucp: {uunet!marque,csd4.milw.wisc.edu}!moocow!brodie
-# special script for "uwmcsd4", have to go through a port selector (and then
-# log in via standard Unix procedures).
-#
-# Also included is the ability to wait in the port selector queue.
-# Be forwarned that the debug log can get pretty big depending on
-# how many times you "wait" in the queue.
-# (C) 1989 Kent C. Brodie - Medical College of Wisconsin
-
-# P0 is systemname , P1 is username, P2 is password.
-
- zero
-
-# send a CR to get the selector's attention. Sleep a little bit
-# due to large login text of selector. It sends "Which System?"
-# when it's ready.
-
-getprtslct:
- count
- ifgtr noprtslct 6
- break
- send \r
- sleep 2000
- flush
- expect prtslctok ystem?
- timeout getprtslct 15000
-
-noprtslct:
- logerr Sent cr, no "Which System?" from port selector
- failed
-
-# Send the system name. We either get "OK" (connected), or we
-# get "No ports available, would you like to wait?" (wait in queue)
-
-prtslctok:
- zero
- sendstr 0
- send \r
- expect connected OK
- expect prtslctwait wait?
- timeout noconnect 10000
-
-# Usually we get "nn Your place in queue" messages. JUST in case we
-# get a free port right away, check for 'Are you ready?' as well.
-
-prtslctwait:
- zero
- send Y\r
- expect prtslctque queue
- expect prtslctrdy ready?
- timeout prtwaitbad 70000
-
-prtwaitbad:
- logerr Sent "Y" to wait in queue, did not get valid response.
- failed
-
-# Here's where we wait in the queue. The port selector sends us a status
-# message about once a minute. We either get "nn Your place in queue"
-# or we get "System Available. Are you Ready?".
-# If something goes wrong, we time out waiting for either response.
-# The reason we don't sleep for 40-50 seconds is because as SOON as the
-# port is ready, it informs us. If we wait too long, it drops us.
-# This setup is laid out for a maximum of 20 "tries" which is ABOUT
-# 20 minutes. Note: This constant retrying can make log files
-# kind of big....
-
-prtslctque:
- count
- ifgtr prtslcttry 20
- expect prtslctque queue
- expect prtslctrdy ready?
- timeout noportwait 70000
-
-prtslcttry:
- logerr Too many (20) wait/retries -- queue too busy.
- failed
-
-prtslctrdy:
- send Y\r
- expect connected OK
- timeout noconnect 20000
-
-
-noportwait:
- logerr Timed out awaiting place in port queue
- failed
-
-noconnect:
- logerr Sent system name, no "OK" from selector
- failed
-
-# standard Unix login stuff. Send cr, expect "ogin:", if no, send a break
-# (which tells Unix to try the next bit rate) and try again.
-
-connected:
- send \r
- zero
- goto waitlogin
-
-sendbreak:
- count
- ifgtr nolgi 6
- flush
- break
-
-waitlogin:
- expect gotlogin ogin:
- timeout sendbreak 5000
-
-nolgi:
- logerr No login: prompt
- failed
-
-gotlogin:
- sendstr 1
- send \r
- expect gotword word:
- timeout nopwd 10000
-
-nopwd:
- logerr No password: prompt
- failed
-
-gotword:
- sendstr 2
- send \r
- success
diff --git a/gnu/libexec/uucp/contrib/Login.VMS b/gnu/libexec/uucp/contrib/Login.VMS
deleted file mode 100644
index d6196cb..0000000
--- a/gnu/libexec/uucp/contrib/Login.VMS
+++ /dev/null
@@ -1,96 +0,0 @@
-#!xchat
-# @(#) Login.VMS V1.1 Tue Sep 1 13:24:54 1992 (Bob Denny)
-#
-#
-# xchat script for logging into a VMS system. If no VMS password
-# parameter supplied, skips password phase of VMS login. If syspass
-# parameter given, will go through steps needed to log into a VMS
-# system where a "system password" was set on the port.
-#
-# Cannot handle situation where system password is required but
-# no password needed.
-#
-#
-# Usage:
-# xchat Login.VMS username [ password [ syspass ] ]
-#
-# Uncomment the lines starting with "###" to get debug logging.
-#
-start:
-### dbgfile Login.Log
-### dbgset 15
- sleep 2000 # Wait 2 seconds
- zero
- flush # Flush typeahead
- ifnstr login 2 # Skip sys passwd if not given
-#
-# Need system password. Send <CR> to get bell.
-# Try 5 times at 2 sec. intervals. Skip to do
-# username if we see "Username:".
-#
-syspass:
- count
- ifgtr nobell 5 # Fail after 5 tries
- send \r
- timeout syspass 2000 # Wait 2 sec. and try again
- expect gotbell \007
- expect gotlogin Username:
-#
-# Got the bell. Send the system password. Repeat 5 times
-# at 2 sec. intervals. Fail if we don't get Username:
-#
-gotbell:
- zero
- sleep 2000
-l1:
- count
- ifgtr nologin 5 # Fail after 5 tries
- sendstr 2
- send \r
- timeout l1 2000 # Wait 2 sec. and try again
- expect gotlogin Username:
-#
-# Start here if no system password supplied.
-# Send <CR> until we get Username: Try 5 times at 2 sec. intervals.
-#
-login:
- count
- ifgtr nologin 5 # Fail after 5 tries
- send \r
- timeout login 2000 # Wait 2 sec. and try again
- expect gotlogin Username:
-#
-# Got VMS "Username:" prompt. Send the username. If a password
-# was given, wait for the "Password:" prompt. Die after 10 seconds.
-# if no password was given, we're done!
-#
-gotlogin:
- sendstr 0
- send \r
- ifnstr done 1
- timeout nopasswd 10000
- expect gotpasswd Password:
-#
-# Got VMS "Password:" prompt. Send the password and we're done!
-#
-gotpasswd:
- sendstr 1
- send \r
-#
-# Success!
-#
-done:
- success
-#
-# ERROR HANDLERS
-#
-nobell:
- logerr No VMS system password prompt (bell)
- failed
-nologin:
- logerr No VMS Username: prompt
- failed
-nopasswd:
- logerr No VMS Password: prompt.
- failed
-
diff --git a/gnu/libexec/uucp/contrib/Makefile.uurt b/gnu/libexec/uucp/contrib/Makefile.uurt
deleted file mode 100644
index 57bf44b..0000000
--- a/gnu/libexec/uucp/contrib/Makefile.uurt
+++ /dev/null
@@ -1,40 +0,0 @@
-# $Id$
-# Makefile for uurate 1.10
-#
-
-# Prefix directory for installation directories.
-prefix = /usr/local
-
-# Directory where the needed .h files are installed (uucp.h ...).
-uucpsrcs = ../
-
-# Where uurate is installed
-BIN=$(prefix)/bin
-# Where uurate's man is installed
-MAN=$(prefix)/man/man1
-
-# The directory to look in for Taylor style configuration files
-newconfigdir = $(prefix)/conf/uucp
-
-# Flags to use when compiling uurate
-CC=gcc -O2
-CFLAGS=-I.. -Wall
-LDFLAGS=-s
-
-SHELL=/bin/sh
-PROGS=uurate
-
-#-----------
-MORECFLAGS= -I. -I$(uucpsrcs) -DNEWCONFIGLIB=\"$(newconfigdir)\"
-
-all: $(PROGS)
-
-uurate: uurate.c
- $(CC) $(CFLAGS) $(MORECFLAGS) $@.c -o $@ $(LDFLAGS)
-
-install: $(PROGS)
- cp $(PROGS) $(BIN)
- cp uurate.man $(MAN)/uurate.1
-
-clean:
- rm -f $(PROGS) core
diff --git a/gnu/libexec/uucp/contrib/Makefile.xchat b/gnu/libexec/uucp/contrib/Makefile.xchat
deleted file mode 100644
index 5e9aaa8..0000000
--- a/gnu/libexec/uucp/contrib/Makefile.xchat
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Makefile for xchat 1.1
-#
-# Bob Denny - Tue Sep 1 15:58:22 1992
-#
-CC=cc
-SHELL=/bin/sh
-BIN=/usr/local/lib/uucp
-PROGS=xchat
-
-#-----------
-
-all: $(PROGS)
-
-install: $(PROGS)
- @for i in $(PROGS) ; do \
- echo "Install $$i into $(BIN)..." ; \
- cp $$i $(BIN) ; \
- echo "Set ownership and protection..." ; \
- /bin/chmod 0555 $(BIN)/$$i ; \
- /bin/chown bin $(BIN)/$$i ; \
- /bin/chgrp bin $(BIN)/$$i ; \
- done
-
-clean:
- rm -f $(PROGS) core
-
-
-
-
-
diff --git a/gnu/libexec/uucp/contrib/README b/gnu/libexec/uucp/contrib/README
deleted file mode 100644
index 8e4651a9..0000000
--- a/gnu/libexec/uucp/contrib/README
+++ /dev/null
@@ -1,82 +0,0 @@
-This is the README file for the Taylor UUCP contrib directory.
-
-This directory contains contributed shell scripts and programs that
-you may find useful.
-
-Not actually included here, but nonetheless useful, is the TUA program
-distributed by Lele Gaifax <lele@nautilus.sublink.org>. It can do
-various sorts of analysis of any type of UUCP log file. It should be
-available from most FTP sites.
-
-xchat.c, xchat.man, README-XCHAT, xc-conf.h-dist, Makefile.xchat:
- A program by Bob Denny that may be invoked by the ``chat-program''
- command for any of the various types of chat scripts. It is
- driven by scripts which are written in its own little language.
- It is a powerful program that can add a lot of flexibility to your
- chat scripts.
-
-Dial.Hayes, Hangup.Hayes, Login.LAT, Login.PortSel, Login.VMS:
- Sample scripts for xchat.
-
-uucomp.shar
- A set of programs which automatically compresses outgoing data in
- the spool directory. The remote system must cooperate when using
- this. It can cut down on phone usage when applicable.
- Contributed by Ed Carp.
-
-uurate.c, uurate.man, README-UURATE, Makefile.uurt:
- A nifty little program by Bob Denny which analyzes the Log and
- Stats file and prints various sorts of reports. This version was
- tweaked by Stephan Niemz and Klaus Dahlenburg.
-
-uutraf:
- Another program to produce neat reports from your log files, this
- one a perl script by Johan Vromans.
-
-savelog.sh, savelog.man:
- A handy shell script to rename a log file and cycle old versions
- through a set of names, throwing away the oldest one. It will
- also optionally compress the old log files. I believe that this
- is originally from smail. It was written by Ronald S. Karr and
- Landon Curt Noll, and was given to me by Bob Denny.
-
-uureroute.perl:
- A perl script to reroute all mail queued up for one host to
- another. Written by Bill Campbell and contributed by Francois
- Pinard.
-
-stats.sh:
- A gawk script by Zacharias Beckman which reads the Stats file and
- prints the last 80 lines as a nicely formatted table.
-
-uuq.sh:
- A uuq workalike shell script by Zacharias Beckman.
-
-uupoll.shar:
- uupoll and autopoll programs contributed by Klaus Dahlenburg.
- uupoll can be used to automatically poll all systems, or a list of
- systems; autopoll will poll and then retry failed calls.
-
-uudemon.shar:
- An implementation of the HDB uudemon.poll script by Donald Burr.
-
-uuxconv:
- A program by Richard E. Nickle to help convert SPOOLDIR_HDB spool
- directories to SPOOLDIR_TAYLOR spool directories (note that it is
- not necessary to convert your spool directories at all; the
- SPOOLDIR_TAYLOR approach may be slightly more efficient).
-
-dialHDB.c:
- A program by Daniel Hagerty which permits using HDB dialer
- programs as chat programs.
-
-amiga.c:
- A wrapper program to run uucico from a cron table under Amiga
- SVR4 (apparently a wrapper is required). This was contributed by
- Lawrence E. Rosenman.
-
-tstout.c:
- A program to remove a user from utmp and wtmp, essentially logging
- them out. I put this together from BSD code. I need it to use
- tstuu with the system UUCP on Ultrix 4.0, for reasons that escape
- me. Most people will have little use for this.
diff --git a/gnu/libexec/uucp/contrib/README-UURATE b/gnu/libexec/uucp/contrib/README-UURATE
deleted file mode 100644
index 0ef6375..0000000
--- a/gnu/libexec/uucp/contrib/README-UURATE
+++ /dev/null
@@ -1,21 +0,0 @@
-uurate V1.10 - Gather and display Taylor UUCP traffic statistics
-
-Bob Denny (denny@alisa.com) - Thu Sep 3 19:47:41 1992 (V1.2.1)
-Klaus Dahlenburg (kdburg@incoahe.hanse.de) - Tue Sep 28 18:11:34 CET 1993
-
-See the man page for documentation.
-
-Installation:
-------------
-
-(1) Copy or sym-link Makefile.uurt to Makefile.
-
-(2) Edit Makefile: set BIN where you want uurate to be installed,
- MAN where the man page should go to, and set CFLAGS to point
- to the directory containing the UUCP sources (this is .. by
- default). Don't forget to set newconfigdir= to point to the
- directory where the (Taylor-uucp)config is stored.
-
-(3) Type ``make'' to compile the program.
-
-(4) Type ``make install'' to install the program.
diff --git a/gnu/libexec/uucp/contrib/README-XCHAT b/gnu/libexec/uucp/contrib/README-XCHAT
deleted file mode 100644
index 5f93a28..0000000
--- a/gnu/libexec/uucp/contrib/README-XCHAT
+++ /dev/null
@@ -1,42 +0,0 @@
-This is xchat V1.1 (Tue Sep 1 15:50:56 1992)
-
-Introduction:
-------------
-
-Xchat is a general-purpose dialing and login program designed for use
-with Taylor UUCP as a "chat-program", taking the place (or augmenting)
-the built-in chat scripting facility. It provides the ability to
-closely control timeouts, multiple simultaneous expect strings with
-separate actions, extended terminal control, modem command character
-pacing, and more.
-
-When used in conjunction with Taylor UUCP's configuration features,
-xchat can provide you the ability to manage the most intricate login,
-dial and hangup needs. The scripts are written in a shell-like (well,
-sort-of) style with labels, commands, and parameters, easing the task
-of writing procedures for complex terminal communications situations.
-
-Installation:
-------------
-
-(1) Copy xc-conf.h-dist to xc-conf.h, then edit xc-conf.h to reflect
- your condifuration. A description of the settings is in that file.
-
-(2) Copy Makefile.xchat to Makefile and edit it to set BIN to where
- you want xchat installed.
-
-(2) Do a 'make' to build xchat.
-
-(3) Do a 'make install' to install it.
-
-(4) Format and print xchat.8, and install it if you want.
-
-(5) Print out copies of the scripts in the ./scripts subdirectory.
-
-(6) Read xchat.8 and the scripts together.
-
-
-Author:
-------
-
-Robert B. Denny (denny@alisa.com)
diff --git a/gnu/libexec/uucp/contrib/amiga.c b/gnu/libexec/uucp/contrib/amiga.c
deleted file mode 100644
index d982364..0000000
--- a/gnu/libexec/uucp/contrib/amiga.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Wrapper code for Taylor UUCP on Amiga Unix (SVR4) for cron invoked UUCP */
-/* processes. */
-
-/* The problem: Cron is not a "licensed" process. any process that grabs a
- controlling terminal needs to be licensed. Taylor UUCP needs controlling
- terminals. Taylor UUCP does relinquish the controlling terminal before
- fork(), so the "UUCP" license is appropriate.
- This simple program does the "right" thing, but *MUST* be SETUID ROOT */
-
-/* Written by: Lawrence E. Rosenman <ler@lerami.lerctr.org> */
-
-#include <sys/sysm68k.h>
-#include <sys/types.h>
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <pwd.h>
-
-int main(int argc,char *argv[],char *envp)
-{
- struct passwd *pw;
- char name[256];
-
- strcpy(name,"/usr/local/lib/uucp/uucico");
- if (sysm68k(_m68k_LIMUSER,EUA_GET_LIC) == 0 ) { /* are we unlicensed? */
- if (sysm68k(_m68k_LIMUSER,EUA_UUCP) == -1) { /* yes, get a "uucp" license */
- fprintf(stderr,"sysm68k failed, errno=%d\n",errno); /* we didn't? crab it */
- exit(errno);
- }
- }
-
- pw = getpwnam("uucp"); /* get the Password Entry for uucp */
- if (pw == NULL)
- {
- fprintf(stderr,"User ID \"uucp\" doesn't exist.\n");
- exit(1);
- }
- setgid(pw->pw_gid); /* set gid to uucp */
- setuid(pw->pw_uid); /* set uid to uucp */
- argv[0]=name; /* have PS not lie... */
- execv("/usr/local/lib/uucp/uucico",argv); /* go to the real program */
- exit(errno);
-}
diff --git a/gnu/libexec/uucp/contrib/dialHDB.c b/gnu/libexec/uucp/contrib/dialHDB.c
deleted file mode 100644
index cb26621..0000000
--- a/gnu/libexec/uucp/contrib/dialHDB.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
-# File: dialHDB.c
-# Author: Daniel Hagerty , hag@eddie.mit.edu
-# Copyright (C) 1993
-# Date: Fri Nov 26 19:22:31 1993
-# Description: Program for using HDB dialers for dialing modems, exiting
- with 0 on success, else failure.
-# Version: 1.0
-# Revision History:
-######
-### 11/26/93 Hag - File creation
-######
-### 1/5/94 Hag - Finally got around to finishing this damn thing.
-######
-*/
-/* Basic theory behind this program-
- dialHDB forks into two processes, a monitor parent, and a child
- that does the exec of the dialer. Child pretty much just execs the
- dialer program, unless there's an exec problem, in which case the
- child sends the parent a SIGUSR1 to indicate failed execution.
-*/
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-
-#define kUsage "Usage:\n\t%s dialerPath device number speed\n\
-%s dialer -h device speed\n"
-
-#define kExitErrFlag 0x80 /* & in with exit code to determine error */
-#define kErrorMask 0x0f /* Mask to determine error code */
-
-/* Error code defines as lifted from an HDB dialer */
-#define RCE_NULL 0 /* general purpose or unknown error code */
-#define RCE_INUSE 1 /* line in use */
-#define RCE_SIG 2 /* signal aborted dialer */
-#define RCE_ARGS 3 /* invalid arguments */
-#define RCE_PHNO 4 /* invalid phone number */
-#define RCE_SPEED 5 /* invalid baud rate -or- bad connect baud */
-#define RCE_OPEN 6 /* can't open line */
-#define RCE_IOCTL 7 /* ioctl error */
-#define RCE_TIMOUT 8 /* timeout */
-#define RCE_NOTONE 9 /* no dial tone */
-#define RCE_BUSY 13 /* phone is busy */
-#define RCE_NOCARR 14 /* no carrier */
-#define RCE_ANSWER 15 /* no answer */
-
-/* Structure definition to map error codes to strings */
-typedef struct
-{
- int errNum;
- char *errString;
-} errTable;
-
-const errTable errors[]=
-{
- { RCE_NULL, "Unknown Error" },
- { RCE_INUSE, "Line is being used" },
- { RCE_SIG, "Recieved fatal signal" },
- { RCE_ARGS, "Bad arguments" },
- { RCE_PHNO, "Invalid phone number" },
- { RCE_SPEED, "Invalid baud rate or bad connection" },
- { RCE_OPEN, "Unable to open line" },
- { RCE_IOCTL, "ioctl error" },
- { RCE_TIMOUT, "Timed out" },
- { RCE_NOTONE, "No dialtone" },
- { RCE_BUSY, "Phone number is busy" },
- { RCE_NOCARR, "No carrier" },
- { RCE_ANSWER, "No answer" },
- { 0,NULL}
-};
-
-/* Function Prototypes */
-int figureStat(int stat);
-char *findInTable(int error);
-void badExec(void);
-
-char *dialerName; /* basename of our dialer program */
-char *dialerPath; /* full path of dialer program */
-
-main(int argc,char *argv[])
-{
- int parent; /* pid of parent process */
- int child; /* pid of child process */
- int stat; /* exit status of child process */
- char *temp; /* used to get basename of dialer */
-
- if(argc!=5)
- {
- fprintf(stderr,kUsage,argv[0],argv[0]);
- exit(1);
- }
-
- dialerPath=argv[1];
- dialerName= (temp=strrchr(argv[1],'/'))!=NULL ? temp+1 : argv[1];
-
- parent=getpid();
-
- signal(SIGUSR1,badExec); /* set up for possible failed exec */
-
- if((child=fork())<0)
- {
- perror("fork");
- exit(2);
- }
- if(child>0) /* We're parent, wait for child to exit */
- {
- /* Set up to ignore signals so we can report them on stderror */
- signal(SIGHUP,SIG_IGN);
- signal(SIGINT,SIG_IGN);
- signal(SIGTERM,SIG_IGN);
-
- wait(&stat); /* wait for child to exit */
- exit(figureStat(stat)); /* figure out our exit code and die */
- }
- else /* child process */
- {
- close(0); /* close of modem file desc, since HDB */
- close(1); /* doesn't use them */
- dup2(2,1); /* and remap stdout to stderr, just in case */
- if(execvp(argv[1],argv+1)<0) /* exec program with argv shifted by 1 */
- { /* if exec fails, send SIGUSR1 to parent */
- kill(parent,SIGUSR1);
- exit(0);
- }
- }
- exit(0);
-}
-
-/* Figure out whether or not dialer ran succesfully, and return
-with 0 if it worked, otherwise error */
-int figureStat(int stat)
-{
- int exit;
- int errFlag;
- int error;
-
- if(WIFSIGNALED(stat)) /* determine if exit was from signal or what */
- {
- fprintf(stderr,"Error: Dialer %s recieved signal %d.\n",dialerName,
- WTERMSIG(stat));
- return(1);
- }
- if(WIFSTOPPED(stat))
- {
- fprintf(stderr,"Error: Dialer %s recieved signal %d.\n",dialerName,
- WSTOPSIG(stat));
- return(1);
- }
- exit=WEXITSTATUS(stat);
-
- errFlag=exit&kExitErrFlag; /* Is the error flag set? */
- if(errFlag)
- {
- char *errString;
-
- error=exit&kErrorMask;
- errString=findInTable(error); /* find it's string, print it on stderr */
- fprintf(stderr,"Error: %s - %s.\n",dialerName,errString); /* and return */
- return(1);
- }
- return(0);
-}
-
-/* Support routine, look up exit code in error table, and return pointer
-to proper string */
-char *findInTable(int error)
-{
- int i=0;
-
- for(i=0;errors[i].errString!=NULL;i++)
- {
- if(errors[i].errNum==error)
- return(errors[i].errString);
- }
- /* Still here, return the top entry, for unknown error */
- return(errors[0].errString);
-}
-
-/* Called by signal if we recieve SIGUSR 1 */
-void badExec(void)
-{
- fprintf(stderr,"Error: %s - Execution problem.\n",dialerPath);
- exit(1);
-}
diff --git a/gnu/libexec/uucp/contrib/savelog.man b/gnu/libexec/uucp/contrib/savelog.man
deleted file mode 100644
index 919b94f..0000000
--- a/gnu/libexec/uucp/contrib/savelog.man
+++ /dev/null
@@ -1,130 +0,0 @@
-.\" @(#)man/man8/savelog.an 1.2 24 Oct 1990 05:18:46
-.de pP
-.if n .sp 1
-.if t .sp .4
-..
-.de tP
-.pP
-.ta \\n(pDu
-.ti -\\n(pDu
-..
-.TH SAVELOG X_MAN8_EXT_X "31 January 1988" "Local"
-.SH NAME
-savelog \- cycle and truncate log files
-.SH SYNOPSIS
-.na
-.B X_UTIL_BIN_DIR_X/savelog
-[
-.B \-m
-.I mode
-] [
-.B \-u
-.I user
-] [
-.B \-g
-.I group
-] [
-.B \-c
-.I cycle
-] [
-.B \-t
-] [
-.B \-l
-]
-.I logfile
-.br
-.ad
-.SH DESCRIPTION
-The
-.I savelog
-command renames and optionally compresses a log file and cycles it
-through a set of names based on the original log file, removing the
-last name in the cycle.
-.SH OPTIONS
-The
-.I savelog
-command accepts the following options:
-.TP
-\fB\-m\fP \fImode\fP
-Change the permissions mode for renamed log files to
-.IR mode .
-By default the mode is unchanged.
-.TP
-\fB\-u\fP \fIuser\fP
-Change the owner for renamed log files to
-.IR user .
-By default the owner is unchanged.
-.TP
-\fB\-g\fP \fIgroup\fP
-Change the group for renamed log files to
-.IR group .
-By default the group is unchanged.
-.TP
-\fB\-c\fP \fIcycle\fP
-Save
-.I cycle
-versions of the logfile, where
-.I cycle
-is a decimal number. The default value is 7.
-.TP
-.B \-l
-Do not compress log files. By default, a compression program is used,
-if one is available.
-.TP
-.B \-t
-Ensure that a new logfile exists when the savelog operation is
-complete. Use of
-.BR \-m ,
-.BR \-u
-or
-.BR \-g
-imply this, ensuring that the logfile will have the designated mode.
-.SH "OPERATION"
-The given logfile is cycled through files named:
-.RS
-
-OLD/\fIfile\fP.\fInumber\fP
-
-.RE
-where
-.I file
-is the basename for the logfile and where
-.I number
-ranges from 0 to one less then the
-.I cycle
-count specified for the command.
-The
-.I OLD
-dirctory is created, as necessary, and is under the same directory as
-the logfile itself.
-.PP
-This cycle operation is accomplished by renaming the file numbered
-.IR cycle -2
-to a file numbered
-.IR cycle -1
-and so on until the file numbered 0 is renamed to the file numbered 1.
-If compression is being used, the first cycle file is compressed after
-being renamed to cycle 1. After the cycle files are moved through the
-various names, the filefile itself is moved to the cycle 0 file.
-This cycle normally occurs once every time
-.I savelog
-is executed.
-If the log file does not exist, savelog ignores it and does
-not cycle the OLD files.
-.PP
-If compression is being used, then compressed log files will have an
-additional suffix appropriate for the compression program that is
-used.
-.SH "SEE ALSO"
-.IR smail (X_MAN5_EXT_X)
-and
-.IR smail (X_MAN8_EXT_X).
-.SH COPYRIGHT
-Copyright(C)1987, 1988 Ronald S. Karr and Landon Curt Noll
-.br
-See a file COPYING,
-distributed with the source code,
-or type
-.I "smail \-bc"
-for distribution rights and restrictions
-associated with this software.
diff --git a/gnu/libexec/uucp/contrib/savelog.sh b/gnu/libexec/uucp/contrib/savelog.sh
deleted file mode 100755
index 64c989f..0000000
--- a/gnu/libexec/uucp/contrib/savelog.sh
+++ /dev/null
@@ -1,247 +0,0 @@
-#! /bin/sh
-# @(#)util/savelog.sh 1.4 26 Oct 1991 22:49:39
-#
-# savelog - save a log file
-#
-# Copyright (C) 1987, 1988 Ronald S. Karr and Landon Curt Noll
-#
-# See the file COPYING, distributed with smail, for restriction
-# and warranty information.
-#
-# usage: savelog [-m mode] [-u user] [-g group] [-t] [-c cycle] [-l] file...
-#
-# -m mode - chmod log files to mode
-# -u user - chown log files to user
-# -g group - chgrp log files to group
-# -c cycle - save cycle versions of the logfile (default: 7)
-# -t - touch file
-# -l - don't compress any log files (default: compress)
-# file - log file names
-#
-# The savelog command saves and optionally compresses old copies of files
-# into an 'dir'/OLD sub-directory. The 'dir' directory is determined from
-# the directory of each 'file'.
-#
-# Older version of 'file' are named:
-#
-# OLD/'file'.<number><compress_suffix>
-#
-# where <number> is the version number, 0 being the newest. By default,
-# version numbers > 0 are compressed (unless -l prevents it). The
-# version number 0 is never compressed on the off chance that a process
-# still has 'file' opened for I/O.
-#
-# If the 'file' does not exist or if it is zero length, no further processing
-# is performed. However if -t was also given, it will be created.
-#
-# For files that do exist and have lengths greater than zero, the following
-# actions are performed.
-#
-# 1) Version numered files are cycled. That is version 6 is moved to
-# version 7, version is moved to becomes version 6, ... and finally
-# version 0 is moved to version 1. Both compressed names and
-# uncompressed names are cycled, regardless of -t. Missing version
-# files are ignored.
-#
-# 2) The new OLD/file.1 is compressed and is changed subject to
-# the -m, -u and -g flags. This step is skipped if the -t flag
-# was given.
-#
-# 3) The main file is moved to OLD/file.0.
-#
-# 4) If the -m, -u, -g or -t flags are given, then file is created
-# (as an empty file) subject to the given flags.
-#
-# 5) The new OLD/file.0 is chanegd subject to the -m, -u and -g flags.
-#
-# Note: If the OLD sub-directory does not exist, it will be created
-# with mode 0755.
-#
-# Note: If no -m, -u or -g flag is given, then the primary log file is
-# not created.
-#
-# Note: Since the version numbers start with 0, version number <cycle>
-# is never formed. The <cycle> count must be at least 2.
-#
-# Bugs: If a process is still writing to the file.0 and savelog
-# moved it to file.1 and compresses it, data could be lost.
-# Smail does not have this problem in general because it
-# restats files often.
-
-# common location
-PATH="X_UTIL_PATH_X:X_SECURE_PATH_X"; export PATH
-COMPRESS="X_COMPRESS_X"
-COMP_FLAG="X_COMP_FLAG_X"
-DOT_Z="X_DOT_Z_X"
-CHOWN="X_CHOWN_X"
-GETOPT="X_UTIL_BIN_DIR_X/getopt"
-
-# parse args
-exitcode=0 # no problems to far
-prog=$0
-mode=
-user=
-group=
-touch=
-count=7
-set -- `$GETOPT m:u:g:c:lt $*`
-if [ $# -eq 0 -o $? -ne 0 ]; then
- echo "usage: $prog [-m mode][-u user][-g group][-t][-c cycle][-l] file ..." 1>&2
- exit 1
-fi
-for i in $*; do
- case $i in
- -m) mode=$2; shift 2;;
- -u) user=$2; shift 2;;
- -g) group=$2; shift 2;;
- -c) count=$2; shift 2;;
- -t) touch=1; shift;;
- -l) COMPRESS=""; shift;;
- --) shift; break;;
- esac
-done
-if [ "$count" -lt 2 ]; then
- echo "$prog: count must be at least 2" 1>&2
- exit 2
-fi
-
-# cycle thru filenames
-while [ $# -gt 0 ]; do
-
- # get the filename
- filename=$1
- shift
-
- # catch bogus files
- if [ -b "$filename" -o -c "$filename" -o -d "$filename" ]; then
- echo "$prog: $filename is not a regular file" 1>&2
- exitcode=3
- continue
- fi
-
- # if not a file or empty, do nothing major
- if [ ! -s $filename ]; then
- # if -t was given and it does not exist, create it
- if [ ! -z "$touch" -a ! -f $filename ]; then
- touch $filename
- if [ "$?" -ne 0 ]; then
- echo "$prog: could not touch $filename" 1>&2
- exitcode=4
- continue
- fi
- if [ ! -z "$user" ]; then
- $CHOWN $user $filename
- fi
- if [ ! -z "$group" ]; then
- chgrp $group $filename
- fi
- if [ ! -z "$mode" ]; then
- chmod $mode $filename
- fi
- fi
- continue
- fi
-
- # be sure that the savedir exists and is writable
- savedir=`expr "$filename" : '\(.*\)/'`
- if [ -z "$savedir" ]; then
- savedir=./OLD
- else
- savedir=$savedir/OLD
- fi
- if [ ! -s $savedir ]; then
- mkdir $savedir
- if [ "$?" -ne 0 ]; then
- echo "$prog: could not mkdir $savedir" 1>&2
- exitcode=5
- continue
- fi
- chmod 0755 $savedir
- fi
- if [ ! -d $savedir ]; then
- echo "$prog: $savedir is not a directory" 1>&2
- exitcode=6
- continue
- fi
- if [ ! -w $savedir ]; then
- echo "$prog: directory $savedir is not writable" 1>&2
- exitcode=7
- continue
- fi
-
- # deterine our uncompressed file names
- newname=`expr "$filename" : '.*/\(.*\)'`
- if [ -z "$newname" ]; then
- newname=$savedir/$filename
- else
- newname=$savedir/$newname
- fi
-
- # cycle the old compressed log files
- cycle=`expr $count - 1`
- rm -f $newname.$cycle $newname.$cycle$DOT_Z
- while [ "$cycle" -gt 1 ]; do
- # --cycle
- oldcycle=$cycle
- cycle=`expr $cycle - 1`
- # cycle log
- if [ -f $newname.$cycle$DOT_Z ]; then
- mv -f $newname.$cycle$DOT_Z $newname.$oldcycle$DOT_Z
- fi
- if [ -f $newname.$cycle ]; then
- # file was not compressed for some reason move it anyway
- mv -f $newname.$cycle $newname.$oldcycle
- fi
- done
-
- # compress the old uncompressed log if needed
- if [ -f $newname.0 ]; then
- if [ -z "$COMPRESS" ]; then
- newfile=$newname.1
- mv $newname.0 $newfile
- else
- newfile=$newname.1$DOT_Z
- $COMPRESS $COMP_FLAG < $newname.0 > $newfile
- rm -f $newname.0
- fi
- if [ ! -z "$user" ]; then
- $CHOWN $user $newfile
- fi
- if [ ! -z "$group" ]; then
- chgrp $group $newfile
- fi
- if [ ! -z "$mode" ]; then
- chmod $mode $newfile
- fi
- fi
-
- # move the file into the file.0 holding place
- mv -f $filename $newname.0
-
- # replace file if needed
- if [ ! -z "$touch" -o ! -z "$user" -o \
- ! -z "$group" -o ! -z "$mode" ]; then
- touch $filename
- fi
- if [ ! -z "$user" ]; then
- $CHOWN $user $filename
- fi
- if [ ! -z "$group" ]; then
- chgrp $group $filename
- fi
- if [ ! -z "$mode" ]; then
- chmod $mode $filename
- fi
-
- # fix the permissions on the holding place file.0 file
- if [ ! -z "$user" ]; then
- $CHOWN $user $newname.0
- fi
- if [ ! -z "$group" ]; then
- chgrp $group $newname.0
- fi
- if [ ! -z "$mode" ]; then
- chmod $mode $newname.0
- fi
-done
-exit $exitcode
diff --git a/gnu/libexec/uucp/contrib/stats.sh b/gnu/libexec/uucp/contrib/stats.sh
deleted file mode 100755
index ac1d0f5..0000000
--- a/gnu/libexec/uucp/contrib/stats.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-#
-# uuspeed - a script to parse a Taylor UUCP Stats file into pretty results.
-# Zacharias J. Beckman.
-
-grep bytes /usr/spool/uucp/Stats | grep -v 'bytes 0.00 secs' | grep -v 'failed after' | tail -80 | \
-gawk '
- BEGIN {
- printf(" UUCP transmission history:\n");
- format=" %8d bytes %8s(%8s) in %7.2f sec = %5.0f baud, %4.1fK / min\n";
- average=0.01;
- samples=0;
- }
-
- {
- if ($6 > 100) {
- printf (format, $6, $5, $2, $9, $6/$9*10, ($6/$9*60)/1000);
-
- average += ($6/$9*10);
- samples += 1;
- }
- }
-
- END {
- printf (" average speed %d baud\n", average/samples);
- }
-'
diff --git a/gnu/libexec/uucp/contrib/tstout.c b/gnu/libexec/uucp/contrib/tstout.c
deleted file mode 100644
index dd82633..0000000
--- a/gnu/libexec/uucp/contrib/tstout.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/* tstout.c
- Put together by Ian Lance Taylor <ian@airs.com>
-
- This program is used to logout a program run by the tstuu program.
- I needed this because on Ultrix 4.0 I can't get the uucp program
- to run without invoking it via /bin/login and having it start up
- as a shell. If I don't do it this way, it gets a SIGSEGV trap
- for some reason. Most systems probably don't need to do things
- this way. It will only work on BSD systems anyhow, I suspect.
-
- The code for this comes from "UNIX Network Programming" by W.
- Richard Stevens, Prentice-Hall 1990. Most of it is from 4.3BSD, as
- noted in the comments.
-
- This program must run suid to root.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <utmp.h>
-
-static int logout P((const char *zdev));
-static void logwtmp P((const char *zdev, const char *zname,
- const char *zhost));
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- char *z;
-
- if (argc != 2
- || strncmp (argv[1], "/dev/", sizeof "/dev/" - 1) != 0)
- {
- fprintf (stderr, "Usage: tstout device\n");
- exit (EXIT_FAILURE);
- }
-
- z = argv[1] + 5;
-
- if (logout (z))
- logwtmp (z, "", "");
-
- chmod (argv[1], 0666);
- chown (argv[1], 0, 0);
-
- *z = 'p';
- chmod (argv[1], 0666);
- chown (argv[1], 0, 0);
-
- exit (EXIT_SUCCESS);
-}
-
-/*
- * Copyright (c) 1988 The 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)logout.c 5.2 (Berkeley) 2/17/89";
-#endif /* LIBC_SCCS and not lint */
-
-#define UTMPFILE "/etc/utmp"
-
-/* 0 on failure, 1 on success */
-
-static int
-logout(line)
- register const char *line;
-{
- register FILE *fp;
- struct utmp ut;
- int rval;
- time_t time();
-
- if (!(fp = fopen(UTMPFILE, "r+")))
- return(0);
- rval = 0;
- while (fread((char *)&ut, sizeof(struct utmp), 1, fp) == 1) {
- if (!ut.ut_name[0] ||
- strncmp(ut.ut_line, line, sizeof(ut.ut_line)))
- continue;
- bzero(ut.ut_name, sizeof(ut.ut_name));
- bzero(ut.ut_host, sizeof(ut.ut_host));
- (void)time((time_t *)&ut.ut_time);
- (void)fseek(fp, (long)-sizeof(struct utmp), L_INCR);
- (void)fwrite((char *)&ut, sizeof(struct utmp), 1, fp);
- (void)fseek(fp, (long)0, L_INCR);
- rval = 1;
- }
- (void)fclose(fp);
- return(rval);
-}
-
-/*
- * Copyright (c) 1988 The 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)logwtmp.c 5.2 (Berkeley) 9/20/88";
-#endif /* LIBC_SCCS and not lint */
-
-#define WTMPFILE "/usr/adm/wtmp"
-
-static void
-logwtmp(line, name, host)
- const char *line, *name, *host;
-{
- struct utmp ut;
- struct stat buf;
- int fd;
- time_t time();
- char *strncpy();
-
- if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
- return;
- if (!fstat(fd, &buf)) {
- (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line));
- (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name));
- (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host));
- (void)time((time_t *)&ut.ut_time);
- if (write(fd, (char *)&ut, sizeof(struct utmp)) !=
- sizeof(struct utmp))
- (void)ftruncate(fd, buf.st_size);
- }
- (void)close(fd);
-}
diff --git a/gnu/libexec/uucp/contrib/uuclean b/gnu/libexec/uucp/contrib/uuclean
deleted file mode 100644
index 1cfb633..0000000
--- a/gnu/libexec/uucp/contrib/uuclean
+++ /dev/null
@@ -1,25 +0,0 @@
-# This is a sample uuclean shell script
-# Copyright (C) 1992 Ian Lance Taylor
-# Do whatever you like with this script.
-#
-# Set some variables
-bindir=/usr/local/bin
-spooldir=/usr/spool/uucp
-#
-# Warn about all mail over two days old
-$(bindir)/uustat -c rmail -o 48 -N -Q -W"Unable to deliver; will try up to one week"
-# Return all mail over a week old
-$(bindir)/uustat -c rmail -o 168 -K -M -N -Q -W"Could not be delivered for over one week"
-# Throw away other requests over a week old
-$(bindir)/uustat -o 168 -K -M -N -Q -W"Over one week old"
-# Throw away any executions over three days old
-$(bindir)/uustat -o 72 -M -N -Q -W"Unable to execute for three days"
-#
-# Now delete any old spool files
-find $(spooldir) -ctime +8 -name '[CDX].*' -print -exec rm -f \{\} \;
-# Delete any old temporary files
-find $(spooldir) -atime +1 -ctime +1 -name 'TM.*' -print -exec rm -f \{\} \;
-# Delete any old preserved files
-find $(spooldir)/.Preserve -atime +14 -ctime +14 -print -exec rm -f \{\} \;
-# Delete any old failed execution files
-find $(spooldir)/.Failed -atime +14 -ctime +14 -print -exec rm -f \{\} \;
diff --git a/gnu/libexec/uucp/contrib/uucomp.shar b/gnu/libexec/uucp/contrib/uucomp.shar
deleted file mode 100644
index da131d0..0000000
--- a/gnu/libexec/uucp/contrib/uucomp.shar
+++ /dev/null
@@ -1,552 +0,0 @@
-#! /bin/sh
-#
-# Created by shar, version 0.5 - 04/10/91
-#
-# This is a shell archive, meaning:
-# 1. Remove everything about the #! /bin/sh line.
-# 2. Save the resulting text in a file.
-# 3. Execute the file with /bin/sh to create:
-#
-# length name
-# ------ -------------------------------------
-# 128 uucomp-1.1/Compress
-# 264 uucomp-1.1/Copyright
-# 410 uucomp-1.1/INTERNALS
-# 1069 uucomp-1.1/Makefile
-# 3528 uucomp-1.1/README
-# 632 uucomp-1.1/crmail.c
-# 632 uucomp-1.1/crnews.c
-# 108 uucomp-1.1/tags
-# 3506 uucomp-1.1/uucomp.c
-# 383 uucomp-1.1/uucomp.h
-#
-
-if test ! -d uucomp-1.1 ; then
- mkdir uucomp-1.1
-fi
-#
-# Archive number 1
-# This archive created Tue Sep 28 20:21:14 1993
-#
-
-echo "shar: extracting uucomp-1.1/Compress - (128 characters)"
-if test -f 'uucomp-1.1/Compress' ; then
- echo shar: will not over-write existing file uucomp-1.1/Compress
-else
-sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/Compress'
-Xfor i in $*
-Xdo
-X if [ -d /usr/spool/uucp/$i ]
-X then
-X# echo Looking at $i
-X cd /usr/spool/uucp/$i
-X /usr/bin/uucomp C.*
-X fi
-Xdone
-SHAR_EOF
-if test 128 -ne "`wc -c < 'uucomp-1.1/Compress'`" ; then
- echo "shar: ***** error transmitting file uucomp-1.1/Compress (should have been 128 characters, but was "`wc -c < 'uucomp-1.1/Compress'`" characters) *****"
-fi
-fi
-
-touch 0715110393 uucomp-1.1/Compress
-chmod 0700 uucomp-1.1/Compress
-
-echo "shar: extracting uucomp-1.1/Copyright - (264 characters)"
-if test -f 'uucomp-1.1/Copyright' ; then
- echo shar: will not over-write existing file uucomp-1.1/Copyright
-else
-sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/Copyright'
-X
-X/*
-X *
-X * Copyright 1993 by Ed Carp (erc@apple.com) All rights reserved.
-X *
-X * Permission is hereby granted for any non-commercial use of this
-X * program, as long as this copyright notice remains intact. Commercial
-X * users may contact me - I'm easy.
-X *
-X */
-X
-SHAR_EOF
-if test 264 -ne "`wc -c < 'uucomp-1.1/Copyright'`" ; then
- echo "shar: ***** error transmitting file uucomp-1.1/Copyright (should have been 264 characters, but was "`wc -c < 'uucomp-1.1/Copyright'`" characters) *****"
-fi
-fi
-
-touch 0715174993 uucomp-1.1/Copyright
-chmod 0600 uucomp-1.1/Copyright
-
-echo "shar: extracting uucomp-1.1/INTERNALS - (410 characters)"
-if test -f 'uucomp-1.1/INTERNALS' ; then
- echo shar: will not over-write existing file uucomp-1.1/INTERNALS
-else
-sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/INTERNALS'
-XThis is the basic workflow for uucomp:
-X
-Xfor (every argv)
-Xdo
-X if not "C." file skip
-X if open fail, skip
-X read 1 line from C. file
-X grab second and 10th field (second is data file name,
-X 10th is command name)
-X if open fail on second field, skip
-X if 10th field isn't "rmail" or "rnews", skip
-X execute "gzip -9" on second field
-X change "rmail" and "rnews" to "crmail" and "crnews", respectively
-X in C. file
-Xdone
-SHAR_EOF
-if test 410 -ne "`wc -c < 'uucomp-1.1/INTERNALS'`" ; then
- echo "shar: ***** error transmitting file uucomp-1.1/INTERNALS (should have been 410 characters, but was "`wc -c < 'uucomp-1.1/INTERNALS'`" characters) *****"
-fi
-fi
-
-touch 0715174693 uucomp-1.1/INTERNALS
-chmod 0600 uucomp-1.1/INTERNALS
-
-echo "shar: extracting uucomp-1.1/Makefile - (1069 characters)"
-if test -f 'uucomp-1.1/Makefile' ; then
- echo shar: will not over-write existing file uucomp-1.1/Makefile
-else
-sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/Makefile'
-X#
-X# Makefile generated with genmake - version 1.1 08/22/92
-X#
-X# genmake is Copyright 1991 by Edwin R. Carp
-X#
-X# GENMAKE -B/usr/bin -tsp [files]
-X#
-X
-XCC = gcc -O6
-XCFLAGS = $(INCLUDE)
-XSOURCES = crmail.c crnews.c uucomp.c
-XOBJECTS = crmail.o crnews.o uucomp.o
-XPROGRAMS = /usr/bin/crmail /usr/bin/crnews /usr/bin/uucomp
-X
-Xall: $(PROGRAMS) tags
-X
-X/usr/bin/crmail: crmail.o
-X $(CC) $(CFLAGS) -o crmail crmail.o $(LDFLAGS) -O
-X strip crmail
-X chmod 755 crmail
-X mv crmail /usr/bin
-X
-X/usr/bin/crnews: crnews.o
-X $(CC) $(CFLAGS) -o crnews crnews.o $(LDFLAGS) -O
-X strip crnews
-X chmod 755 crnews
-X mv crnews /usr/bin
-X
-X/usr/bin/uucomp: uucomp.o
-X $(CC) $(CFLAGS) -o uucomp uucomp.o $(LDFLAGS) -O
-X strip uucomp
-X chmod 755 uucomp
-X mv uucomp /usr/bin
-X
-Xclean:
-X /bin/rm -f $(OBJECTS) MAKELOG eddep makedep
-X
-Xclobber:
-X /bin/rm -f $(OBJECTS) $(PROGRAMS) MAKELOG eddep makedep *~ *.bak *.BAK
-X /bin/rm -f tags
-X
-Xhidden:
-X echo "make all > MAKELOG 2>&1 &"|/bin/sh
-X
-Xmakefile:
-X genmake -B/usr/bin -tsp $(SOURCES) &
-X
-Xmakeall:
-X genmake -B/usr/bin -tsp *.c &
-X
-Xtags: $(SOURCES)
-X ctags $(SOURCES) > tags
-X
-SHAR_EOF
-if test 1069 -ne "`wc -c < 'uucomp-1.1/Makefile'`" ; then
- echo "shar: ***** error transmitting file uucomp-1.1/Makefile (should have been 1069 characters, but was "`wc -c < 'uucomp-1.1/Makefile'`" characters) *****"
-fi
-fi
-
-touch 0714235093 uucomp-1.1/Makefile
-chmod 0600 uucomp-1.1/Makefile
-
-echo "shar: extracting uucomp-1.1/README - (3528 characters)"
-if test -f 'uucomp-1.1/README' ; then
- echo shar: will not over-write existing file uucomp-1.1/README
-else
-sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/README'
-XLike most people these days, I'm looking for ways to make my computing
-Xenvironment more efficient. This environment consists of a 486, a 386,
-Xand a 386SL laptop, all of which run Taylor uucp under Linux. The 386
-Xlaptop gets used a lot, since it goes wherever I go and I answer a lot
-Xof news and email every day. Often, I must use other people's facilities
-X(phone lines and such) to send out replies and post news if I'm not at home.
-XSince it's not fair to the client for them to pay for my zone calls back
-Xto my home in Fremont, I place the calls on my phone card. Unfortunately,
-XPacBell is very proud of the services they offer, especially in regards
-Xto this convenience of automatically charging calls to my house wherever I
-Xmay be. Considering that this can be very expensive to do, I searched for
-Xa way to cut my phone bill down to something I could afford to pay each
-Xmonth without fainting every time I saw the bill.
-X
-XThe first thing I did was to go out and plunk $195 for a 14.4KB modem.
-XThat helped, but C-News is very slow on my laptop, and batching articles
-Xis even slower, and email (of course) isn't batched at all. Even with
-XMNP5 compression turned on, this doesn't make for a very efficient setup,
-Xeven at high speeds.
-X
-XPlaying around with uucp told me that the line turnaround wasn't that much
-Xoverhead, nor was sending the C./X. files (the execute files) - the real
-Xoverhead was sending out uncompressed news and especially email, since
-XI subscribe to several mailing lists and digests can run quite large.
-X
-XI looked at uubatch, but the most current version I could find (1.05) was
-Xnot compatible with Taylor uucp (and I had no other alternative), so I
-Xdecided to write my own. Experiments with "gzip -9" convinced me that
-Xthat was the way to go, since gzip gives email and news 60 to 75 percent
-Xcompression, which would tend to cut one's phone bill significantly.
-X
-XYou hold in your mailbox (or news reader) the end result of that effort.
-XBear in mind that (1) this is a "first cut" and while it is unlikely that
-Xthere are very many bugs, there are certainly places where the programs could
-Xbe improved and tuned. Suggestions and comments are welcome!
-X
-XTo install:
-X
-X 1. Feed this to shar.
-X 2. Look at the Makefile. Make sure that the paths for
-X things are set up correctly.
-X 3. Look at uucomp.h and make sure that the path and
-X options for COMPRESS/UNCOMPRESS are set up properly.
-X 3. Type "make". This will make uucomp, crmail, and crnews
-X and will place them in /usr/bin. Move Compress into
-X /usr/lib/uucp.
-X 4. Make an entry in crontab to do
-X /usr/lib/uucp/Compress site1 site2 site3...
-X occasionally. It is suggested that this be done fairly
-X frequently. Alternately, you could set up a login shell
-X for selected sites to run uucomp every time that site
-X logged in.
-X 5. Don't forget to add /usr/bin/crmail and /usr/bin/crnews
-X to the list of programs allowed to be executed in your
-X Permissions file (if running HDB UUCP), or whatever is
-X appropriate for your version of uucp.
-X
-XEnjoy! Any questions or comments can be sent to erc@apple.com.
-X
-XNote: This is tuned for Taylor uucp, but would not be particularly
-Xdifficult to adapt to other version of uucp. See the file INTERNALS for
-Xdetails of how this works.
-X
-XJuly 15, 1993
-XEd Carp
-Xerc@apple.com
-X------------------------------------------------------------------------------
-XChanges since 1.0:
-X
-X Version Date Description
-X
-X 1.1 08/04/93 Added sanity check in C. file (check that
-X 'E' is first char in file, otherwise skip)
-SHAR_EOF
-if test 3528 -ne "`wc -c < 'uucomp-1.1/README'`" ; then
- echo "shar: ***** error transmitting file uucomp-1.1/README (should have been 3528 characters, but was "`wc -c < 'uucomp-1.1/README'`" characters) *****"
-fi
-fi
-
-touch 0804224993 uucomp-1.1/README
-chmod 0600 uucomp-1.1/README
-
-echo "shar: extracting uucomp-1.1/crmail.c - (632 characters)"
-if test -f 'uucomp-1.1/crmail.c' ; then
- echo shar: will not over-write existing file uucomp-1.1/crmail.c
-else
-sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/crmail.c'
-X/*
-X * crmail - get compressed mail from host, uncompress
-X * WARNING: This may be insecure!
-X */
-X
-X/*
-X *
-X * Copyright 1993 by Ed Carp (erc@apple.com) All rights reserved.
-X *
-X * Permission is hereby granted for any non-commercial use of this
-X * program, as long as this copyright notice remains intact. Commercial
-X * users may contact me - I'm easy.
-X *
-X */
-X
-X#include <stdio.h>
-X#include "uucomp.h"
-Xmain (argc, argv)
-Xint argc;
-Xchar **argv;
-X{
-X char cmd[1024];
-X int i;
-X
-X sprintf (cmd, "%s|%s ", UNCOMPRESS, RMAIL);
-X for (i = 1; i < argc; i++)
-X {
-X strcat (cmd, argv[i]);
-X strcat (cmd, " ");
-X }
-X system (cmd);
-X exit (0);
-X}
-SHAR_EOF
-if test 632 -ne "`wc -c < 'uucomp-1.1/crmail.c'`" ; then
- echo "shar: ***** error transmitting file uucomp-1.1/crmail.c (should have been 632 characters, but was "`wc -c < 'uucomp-1.1/crmail.c'`" characters) *****"
-fi
-fi
-
-touch 0715195493 uucomp-1.1/crmail.c
-chmod 0600 uucomp-1.1/crmail.c
-
-echo "shar: extracting uucomp-1.1/crnews.c - (632 characters)"
-if test -f 'uucomp-1.1/crnews.c' ; then
- echo shar: will not over-write existing file uucomp-1.1/crnews.c
-else
-sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/crnews.c'
-X/*
-X * crnews - get compressed news from host, uncompress
-X * WARNING: This may be insecure!
-X */
-X
-X/*
-X *
-X * Copyright 1993 by Ed Carp (erc@apple.com) All rights reserved.
-X *
-X * Permission is hereby granted for any non-commercial use of this
-X * program, as long as this copyright notice remains intact. Commercial
-X * users may contact me - I'm easy.
-X *
-X */
-X
-X#include <stdio.h>
-X#include "uucomp.h"
-Xmain (argc, argv)
-Xint argc;
-Xchar **argv;
-X{
-X char cmd[1024];
-X int i;
-X
-X sprintf (cmd, "%s|%s ", UNCOMPRESS, RNEWS);
-X for (i = 1; i < argc; i++)
-X {
-X strcat (cmd, argv[i]);
-X strcat (cmd, " ");
-X }
-X system (cmd);
-X exit (0);
-X}
-SHAR_EOF
-if test 632 -ne "`wc -c < 'uucomp-1.1/crnews.c'`" ; then
- echo "shar: ***** error transmitting file uucomp-1.1/crnews.c (should have been 632 characters, but was "`wc -c < 'uucomp-1.1/crnews.c'`" characters) *****"
-fi
-fi
-
-touch 0715195593 uucomp-1.1/crnews.c
-chmod 0600 uucomp-1.1/crnews.c
-
-echo "shar: extracting uucomp-1.1/tags - (108 characters)"
-if test -f 'uucomp-1.1/tags' ; then
- echo shar: will not over-write existing file uucomp-1.1/tags
-else
-sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/tags'
-Xmain crmail.c /^main (argc, argv)$/
-Xmain crnews.c /^main (argc, argv)$/
-Xmain uucomp.c /^main (argc, argv)$/
-SHAR_EOF
-if test 108 -ne "`wc -c < 'uucomp-1.1/tags'`" ; then
- echo "shar: ***** error transmitting file uucomp-1.1/tags (should have been 108 characters, but was "`wc -c < 'uucomp-1.1/tags'`" characters) *****"
-fi
-fi
-
-touch 0804224993 uucomp-1.1/tags
-chmod 0600 uucomp-1.1/tags
-
-echo "shar: extracting uucomp-1.1/uucomp.c - (3506 characters)"
-if test -f 'uucomp-1.1/uucomp.c' ; then
- echo shar: will not over-write existing file uucomp-1.1/uucomp.c
-else
-sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/uucomp.c'
-X/*
-X * uucomp - compress outgoing news/mail
-X *
-X * usage: uucomp C.*
-X *
-X * This works for Taylor uucp (available from prep.ai.mit.edu:/pub/gnu/uucp*),
-X * but I don't promise it works for anyone else's uucp package. Basically, this
-X * is a quick-n-dirty hack to get compressed mail and news to a uucp site. This
-X * becomes important when you're on the other end of a 1200 baud packet radio
-X * link, where the throughput can be 60 CPS (or lower). It also tends to hide
-X * any nasties that people might want to say to you, since the packets *are*
-X * public readable. Yes, I looked at uubatch, but it was too complicated for
-X * me to figure out <grin>, and it didn't work with Taylor-uucp. This is almost
-X * too simple to work...
-X *
-X * To use this little guy, do something like this in the .bashrc or .profile
-X * or .cshrc of the uucp's login shell:
-X *
-X * cd /usr/spool/uucp/<wherever the C. and D. files are kept>
-X * /usr/bin/uucomp C.*
-X * exec /usr/lib/uucp/uucico
-X *
-X * This program was written by Ed Carp (erc@apple.com). It can be used for any
-X * non-commercial purpose. This software is freely redistributable.
-X */
-X
-X/*
-X *
-X * Copyright 1993 by Ed Carp (erc@apple.com) All rights reserved.
-X *
-X * Permission is hereby granted for any non-commercial use of this
-X * program, as long as this copyright notice remains intact. Commercial
-X * users may contact me - I'm easy.
-X *
-X */
-X
-X#include <stdio.h>
-X#include "uucomp.h"
-X#undef NULL
-X#define NULL (0)
-Xmain (argc, argv)
-Xint argc;
-Xchar **argv;
-X{
-X int i, j, sw, ctr = 0, errflag = 0, mctr = 0, nctr = 0, skipctr = 0;
-X char scr[64], rcmd[10], line[1024], lineout[1024];
-X char *strtok (), *ptr, *lineptr, compfile[32];
-X FILE *in;
-X
-X printf ("uucomp 1.1 08/04/93 ... by erc@apple.com\nscanning %d files.", argc - 1);
-X for (i = 1; i < argc; i++)
-X {
-X if (strncmp (argv[i], "C.", 2) != 0)
-X {
-X skipctr++;
-X continue;
-X }
-X if ((in = fopen (argv[i], "r+")) == (FILE *) NULL)
-X {
-X skipctr++;
-X continue;
-X }
-X fgets (line, 1022, in);
-X if(*line != 'E')
-X {
-X skipctr++;
-X continue;
-X }
-X line[strlen (line) - 1] = NULL;
-X rewind (in);
-X *lineout = NULL;
-X lineptr = line;
-X sw = errflag = 0;
-X printf (".");
-X fflush (stdout);
-X for (j = 0;; j++)
-X {
-X ptr = strtok (lineptr, " ");
-X if (ptr == NULL)
-X break;
-X lineptr = NULL;
-X if (j == 1)
-X {
-X if (access (ptr, 4) == EOF)
-X {
-X#ifdef DEBUG
-X printf ("skip: file '%s' doesn't exist\n", ptr);
-X#endif
-X errflag = 1;
-X break; /*
-X * skip it if the data file isn't
-X * there yet
-X */
-X }
-X strcpy (compfile, ptr);
-X }
-X if (j == 9)
-X {
-X if (strcmp (ptr, "rmail") != 0 && strcmp (ptr, "rnews") != 0)
-X {
-X#ifdef DEBUG
-X printf ("skip: '%s' wrong command\n", ptr);
-X#endif
-X errflag = 1;
-X break;
-X }
-X if (strcmp (ptr, "rmail") == 0)
-X mctr++;
-X if (strcmp (ptr, "rnews") == 0)
-X nctr++;
-X sw = 1;
-X strcat (lineout, "c");
-X }
-X strcat (lineout, ptr);
-X strcat (lineout, " ");
-X }
-X if (errflag == 1)
-X {
-X skipctr++;
-X fclose (in);
-X continue;
-X }
-X fprintf (in, "%s\n", lineout);
-X fclose (in);
-X sprintf (line,
-X "%s -fc > /tmp/uucomp.%d < %s;cp /tmp/uucomp.%d %s",
-X COMPRESS, getpid (), compfile, getpid (), compfile);
-X system (line);
-X ctr++;
-X }
-X sprintf (line, "/tmp/uucomp.%d", getpid ());
-X unlink (line);
-X printf ("\n%d skipped, %d compressed (%d mail, %d news).\n",
-X skipctr, ctr, mctr, nctr);
-X exit (0);
-X}
-SHAR_EOF
-if test 3506 -ne "`wc -c < 'uucomp-1.1/uucomp.c'`" ; then
- echo "shar: ***** error transmitting file uucomp-1.1/uucomp.c (should have been 3506 characters, but was "`wc -c < 'uucomp-1.1/uucomp.c'`" characters) *****"
-fi
-fi
-
-touch 0804224693 uucomp-1.1/uucomp.c
-chmod 0600 uucomp-1.1/uucomp.c
-
-echo "shar: extracting uucomp-1.1/uucomp.h - (383 characters)"
-if test -f 'uucomp-1.1/uucomp.h' ; then
- echo shar: will not over-write existing file uucomp-1.1/uucomp.h
-else
-sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/uucomp.h'
-X/*
-X *
-X * Copyright 1993 by Ed Carp (erc@apple.com) All rights reserved.
-X *
-X * Permission is hereby granted for any non-commercial use of this
-X * program, as long as this copyright notice remains intact. Commercial
-X * users may contact me - I'm easy.
-X *
-X */
-X
-X#define COMPRESS "/usr/bin/gzip -9c"
-X#define UNCOMPRESS "/usr/bin/gzip -dc"
-X#define RMAIL "rmail"
-X#define RNEWS "rnews"
-SHAR_EOF
-if test 383 -ne "`wc -c < 'uucomp-1.1/uucomp.h'`" ; then
- echo "shar: ***** error transmitting file uucomp-1.1/uucomp.h (should have been 383 characters, but was "`wc -c < 'uucomp-1.1/uucomp.h'`" characters) *****"
-fi
-fi
-
-touch 0715190293 uucomp-1.1/uucomp.h
-chmod 0600 uucomp-1.1/uucomp.h
-echo End of all shell archives
-exit 0
diff --git a/gnu/libexec/uucp/contrib/uudemon.shar b/gnu/libexec/uucp/contrib/uudemon.shar
deleted file mode 100644
index 31a8fa6..0000000
--- a/gnu/libexec/uucp/contrib/uudemon.shar
+++ /dev/null
@@ -1,82 +0,0 @@
-#! /bin/sh
-# This is a shell archive. Remove anything before this line, then unpack
-# it by saving it into a file and typing "sh file". To overwrite existing
-# files, type "sh file -c". You can also feed this as standard input via
-# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
-# will see the following message at the end:
-# "End of shell archive."
-# Contents: Poll uudemon.poll
-# Wrapped by dburr@sbanet on Fri Jul 23 20:15:18 1993
-PATH=/bin:/usr/bin:/usr/ucb ; export PATH
-if test -f 'Poll' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Poll'\"
-else
-echo shar: Extracting \"'Poll'\" \(244 characters\)
-sed "s/^X//" >'Poll' <<'END_OF_FILE'
-X# HDB-ish poll file
-X#
-X# Format: <site><tab><hour1> <hour2> ...
-X# ONLY ONE TAB BETWEEN FIELDS... more may work, but I have absolutely no
-X# idea if it will work at all.
-X#
-X# comment lines (begin with `#') are ignored.
-X
-Xdschub 20 21 22
-Xgd 20 21 22
-END_OF_FILE
-if test 244 -ne `wc -c <'Poll'`; then
- echo shar: \"'Poll'\" unpacked with wrong size!
-fi
-# end of 'Poll'
-fi
-if test -f 'uudemon.poll' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uudemon.poll'\"
-else
-echo shar: Extracting \"'uudemon.poll'\" \(941 characters\)
-sed "s/^X//" >'uudemon.poll' <<'END_OF_FILE'
-X#!/bin/sh
-X#
-X# This is my impersonation of the HDB uudemon.poll script.
-X# Yes, I know, this is very clumsy and clunky... ahh well, I've always
-X# been better at C/pascal/etc than Shell programming... :(
-X
-X# change LIBDIR to where UUCP library/conf. files are
-X# change SPOOLDIR to the UUCP spool directory. It must be HDB-ish.
-XLIBDIR=/usr/lib/uucp; export LIBDIR
-XSPOOLDIR=/usr/spool/uucp; export SPOOLDIR
-X
-X### no changes needed past here ###
-X
-XHOUR=`date +%H`; export HOUR
-X
-Xif [ -f ${LIBDIR}/Poll ]; then
-X for SYS in `uuname`
-X do
-X CHOICES="`grep "^$SYS[ ]" ${LIBDIR}/Poll | awk -F' ' \
-X '{ print $2 }'`"
-X DOIT="no"
-X for H in $CHOICES
-X do
-X if [ "$HOUR" = "$H" ]; then
-X DOIT="yes"
-X fi
-X done
-X if [ "$DOIT" = "yes" ]; then
-X if [ ! -d ${SPOOLDIR}/${SYS} ]; then
-X mkdir ${SPOOLDIR}/${SYS}
-X fi
-X chmod 755 ${SPOOLDIR}/${SYS}
-X touch ${SPOOLDIR}/${SYS}/C.${SYS}n0000
-X chmod 644 ${SPOOLDIR}/${SYS}/C.${SYS}n0000
-X fi
-X done
-Xfi
-END_OF_FILE
-if test 941 -ne `wc -c <'uudemon.poll'`; then
- echo shar: \"'uudemon.poll'\" unpacked with wrong size!
-fi
-chmod +x 'uudemon.poll'
-# end of 'uudemon.poll'
-fi
-echo shar: End of shell archive.
-exit 0
diff --git a/gnu/libexec/uucp/contrib/uupoll.shar b/gnu/libexec/uucp/contrib/uupoll.shar
deleted file mode 100644
index a85a496..0000000
--- a/gnu/libexec/uucp/contrib/uupoll.shar
+++ /dev/null
@@ -1,2687 +0,0 @@
-#!/bin/sh
-# This is a shell archive (produced by shar 3.49)
-# To extract the files from this archive, save it to a file, remove
-# everything above the "!/bin/sh" line above, and type "sh file_name".
-#
-# made 04/17/1994 02:21 UTC by ian@comton.airs.com
-# Source directory /disk4/ian
-#
-# existing files will NOT be overwritten unless -c is specified
-#
-# This shar contains:
-# length mode name
-# ------ ---------- ------------------------------------------
-# 2602 -r--r--r-- uupoll/Makefile
-# 3636 -r--r--r-- uupoll/README
-# 4718 -r--r--r-- uupoll/autopoll.8c
-# 44031 -r--r--r-- uupoll/autopoll.c
-# 3884 -r--r--r-- uupoll/conf.h
-# 4787 -r--r--r-- uupoll/uupoll.8c
-# 27587 -r--r--r-- uupoll/uupoll.c
-#
-# ============= uupoll/Makefile ==============
-if test ! -d 'uupoll'; then
- echo 'x - creating directory uupoll'
- mkdir 'uupoll'
-fi
-if test -f 'uupoll/Makefile' -a X"$1" != X"-c"; then
- echo 'x - skipping uupoll/Makefile (File already exists)'
-else
-echo 'x - extracting uupoll/Makefile (Text)'
-sed 's/^X//' << 'SHAR_EOF' > 'uupoll/Makefile' &&
-# This is the Makefile for uupoll and autopoll
-# borrowed and hacked from Taylor UUCP 1.04
-X
-# Prefix directory for installation directories.
-prefix = /usr/local
-X
-# The user name/group that should own the resulting executables.
-# Both should run suid.
-owner = uucp.daemon
-X
-# Which mode should the resulting executables have.
-emode = 4111
-X
-# Where to install autopoll. This definition requires $(prefix)/lib to exist.
-lbindir = $(prefix)/lib/uucp
-X
-# Where are the sources from uucp-Taylor uucp.h, uuconf.h, policy.h.
-# the following assumes that our sources are in uucp-1.05/contrib/uupoll
-# and the required .h files are in main directory for uucp-1.05
-uucpsrcs = ../../
-X
-# Where to install uupoll
-bbindir = $(prefix)/bin
-X
-# Where to install man pages. Section 8 for daemons.
-man8dir = $(prefix)/man/man8
-man8ext = .8c
-X
-# Define programs and flags
-CC = gcc
-CFLAGS = -O2
-LDFLAGS = -s
-LIBS =
-X
-INSTALL = /usr/bin/install -c
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_DATA = $(INSTALL) -m 644
-X
-#
-# Nothing else to configure
-#
-X
-SHELL = /bin/sh
-X
-VERSION = 1.00
-X
-MORECFLAGS = -I. -I$(uucpsrcs) -Wall
-X
-PROGRAMS = uupoll autopoll
-X
-UUPOLLOBJS = uupoll.o
-AUTOOBJS = autopoll.o
-X
-ALLOBJS = uupoll.o autopoll.o
-X
-all: $(PROGRAMS)
-X
-install: $(PROGRAMS)
-X if test -d $(lbindir); then true; else mkdir $(lbindir); fi
-X if test -d $(bbindir); then true; else mkdir $(bbindir); fi
-X -if test -f $(lbindir)/autopoll.old; then rm -f $(lbindir)/autopoll; else mv $(lbindir)/autopoll $(lbindir)/autopoll.old; fi
-X -if test -f $(bbindir)/uupoll.old; then rm -f $(bbindir)/uupoll; else mv $(bbindir)/uupoll $(bbindir)/uupoll.old; fi
-X $(INSTALL_PROGRAM) autopoll $(lbindir)/autopoll
-X $(INSTALL_PROGRAM) uupoll $(bbindir)/uupoll
-X chown $(owner) $(lbindir)/autopoll $(bbindir)/uupoll
-X chmod $(emode) $(lbindir)/autopoll $(bbindir)/uupoll
-X $(INSTALL_DATA) uupoll.8c $(man8dir)/uupoll$(man8ext)
-X $(INSTALL_DATA) autopoll.8c $(man8dir)/autopoll$(man8ext)
-X
-uninstall:
-X rm -f $(lbindir)/autopoll $(bbindir)/uupoll
-X rm -f $(man8dir)/autopoll$(man8ext) $(man8dir)/uupoll$(man8ext)
-X -cp $(lbindir)/autopoll.old $(lbindir)/autopoll
-X -cp $(bbindir)/uupoll.old $(bbindir)/uupoll
-X -chown $(owner) $(lbindir)/autopoll $(bbindir)/uupoll
-X -chmod $(emode) $(lbindir)/autopoll $(bbindir)/uupoll
-X
-uupoll: $(UUPOLLOBJS)
-X $(CC) $(LDFLAGS) -o uupoll $(UUPOLLOBJS) $(LIBS)
-X
-autopoll: $(AUTOOBJS)
-X $(CC) $(LDFLAGS) -o autopoll $(AUTOOBJS) $(LIBS)
-X
-.c.o:
-X $(CC) -c $(CFLAGS) $(MORECFLAGS) $<
-X
-X
-clean:
-X rm -f $(ALLOBJS) $(PROGRAMS)
-X
-mostlyclean: clean
-X
-TAGS:
-X etags *.h *.c
-X
-# Header file dependencies. These are maintained by hand.
-X
-$(ALLOBJS): conf.h
-X
-.NOEXPORT:
-SHAR_EOF
-chmod 0444 uupoll/Makefile ||
-echo 'restore of uupoll/Makefile failed'
-Wc_c="`wc -c < 'uupoll/Makefile'`"
-test 2602 -eq "$Wc_c" ||
- echo 'uupoll/Makefile: original size 2602, current size' "$Wc_c"
-fi
-# ============= uupoll/README ==============
-if test -f 'uupoll/README' -a X"$1" != X"-c"; then
- echo 'x - skipping uupoll/README (File already exists)'
-else
-echo 'x - extracting uupoll/README (Text)'
-sed 's/^X//' << 'SHAR_EOF' > 'uupoll/README' &&
-X
-The package consists of the following files:
-X
-X - autopoll.c
-X - autopoll.8c
-X - conf.h
-X - Makefile
-X - README
-X - uupoll.c
-X - uupoll.8c
-X
-CAVEAT:
-uupoll as well as autopoll are created, tested and run on
-a NeXT running NeXTstep 2.1+ only! Autopoll will take the same arguments
-as uucico and may well work with them the same way uucico works but it
-has only been tested to call uucico with the options:
-X
-X -s<site> -S<site> -f -r1 -C -D (as well as the long form of these options)
-X
-so far. All options given to autopoll will be passed verbatim to uucico.
-X
-DESCRIPTION:
-The program uupoll was created to be a full replacement for the vendor
-supplied one on a NeXT computer. That uupoll checked any site name against
-the "hardwired" L.sys and did end with a "Bus error" if the site could not
-be found. There was no source available to modify so it had to be created
-from scratch.
-The program autopoll has no equivalent an the NeXT. The intentions behind
-it was to automate the task of rescheduling any failed call. It may be
-started by an entry in the crontab tables in just the same way uucico is
-started (it will start uucico):
-X
-05 5 * * * uucp /usr/local/lib/uucp/autopoll -r1 >>/tmp/poll.log 2>&1
-X
-Any messages go to stderr or a file (if compiled with that option); in case
-the file could not be opened it will use stdout to tell you just that and quit.
-To catch any output one may place the string
-X
-X >>/tmp/poll.log 2>&1
-X
-into the command line as well. Uupoll as well as autopoll will place only
-a start message into the logfiles in case they are invoked manually from
-the shell.
-If the call fails autopoll will reschedule uucico for a later time by means
-of an AT job.
-The messages given by uupoll and autopoll carry an indicator to inform about
-the nature of an error; they are:
-X
-- (I) informal message; such as ".. started" ".. ended".
-- (W) there might be an error but the program decided to go ahead.
-X The exit code will be at least 4.
-- (E) a severe error was encountered that either aborts the whole run or
-X only the task for one site will be aborted.
-X The exit code will be at least 8.
-- (C) a catastrophic error has been found such as unable to fork. The run
-X is aborted.
-X The exit code will be at least 16.
-The final message will show the exit code the programm has terminated with.
-X
-For more information see the man pages or look into the source.
-X
-INSTALLATION:
-all files should be placed in one folder. Then examine and change the files
-Makefile and conf.h to meet your needs. To compile uupoll some files of
-uucp must be available (see Makefile: uucpsrcs)
-If not already there change to the directory which contain the files and type:
-X
-make
-X
-this should compile UUPOLL and AUTOPOLL. There should only be a warning
-that rcsid is defined but not used.
-Before actually installing you should test the programs to be working as
-desired.
-Then check the Makefile for the final placement of the modules and the man
-pages. Make sure the ownership and setuid is what you need on your machine
-to run the program(s).
-Then su to root and type:
-X
-make install
-X
-which should install the above programs and the man pages in the appropriate
-directories.
-Some word on the coding: have mercy! This is my second project in 'C'; any
-suggestions that may improve the style/coding are welcome however.
-X
-In case of any problems that can't be solved feel free to contact the
-author at:
-X
-Klaus Dahlenburg Timezone : GMT + 2
-P.O.Box 1267 email : kdburg@incoahe.hanse.de
-D-21249 Tostedt Fax : +49 4287 676
-X Germany Voice : +49 4287 681
-X
-Have fun!
-SHAR_EOF
-chmod 0444 uupoll/README ||
-echo 'restore of uupoll/README failed'
-Wc_c="`wc -c < 'uupoll/README'`"
-test 3636 -eq "$Wc_c" ||
- echo 'uupoll/README: original size 3636, current size' "$Wc_c"
-fi
-# ============= uupoll/autopoll.8c ==============
-if test -f 'uupoll/autopoll.8c' -a X"$1" != X"-c"; then
- echo 'x - skipping uupoll/autopoll.8c (File already exists)'
-else
-echo 'x - extracting uupoll/autopoll.8c (Text)'
-sed 's/^X//' << 'SHAR_EOF' > 'uupoll/autopoll.8c' &&
-.\"
-.\" @(#)autopoll.8c 1.4 (incoahe) 5/09/1993
-.\"
-.TH AUTOPOLL 8C "May 09, 1993"
-.UC 6
-.SH NAME
-autopoll \- automatic \s-1UUCP\s+1 file transfer supervisor
-.SH SYNOPSIS
-.B autopoll
-[
-.BI options
-]
-.SH DESCRIPTION
-file transfer requests placed by
-.IR uucp (1)
-or
-.IR uux (1)
-are handled by
-.IR uucico (8C).
-.IR uucico
-will be invoked immediately by the above programs unless the \-r
-option is given which queues the request for later processing. This
-is typically done by entries in the
-.IR crontab
-table(s) which will invoke
-.IR uucico.
-.IR uucico
-can also be invoked by
-.IR uupoll (8C).
-All methods have in common that there is no automatic retry by
-.IR uucico
-itself in case the call failed for some reason.
-Either manual
-intervention or some sort of scripts must be used to overcome this
-limitation.
-.PP
-.IR Autopoll
-can be used to automate up to a certain degree the task of rescheduling
-a call. None of the standard programs already mentioned need to be
-modified to get this working. Also not recommended (see BUGS section)
-.IR uucico
-may be an alias to
-.IR autopoll
-as all arguments passed to
-.IR autopoll
-will be copied verbatim to
-.IR uucico.
-In case this is done by link or other means the original
-.I uucio
-must still be available in a directory outside of the normal search path
-otherwise
-.I autopoll
-can't do what it's intended to do and will form a loop.
-.PP
-When
-.IR autopoll
-is called thre will be a check on the \-s, \-S and \-f option to
-see whether this
-is a specific call or not. Also the \-S and the \-f option must be checked
-to determine the type of call: honor any imposed wait for a site or not.
-Any call to ourself or to an unknown site will be refused. The known sites
-will be obtained by a call to
-.IR uuname(1).
-All other options will not be checked in any way. Next to this
-.IR uucico
-is called and the exit code is checked for a `1' which indicates that the call
-failed for some reason whatsoever. A `0' exit code will be interpreted as
-a success and
-.IR autopoll
-ends immediate. If the call seems to be unsuccessful a new call is scheduled
-for any site whose .Status files have a retry period greater than 0. The
-retry will be scheduled by means of placing an
-.IR at
-job at the time of the failing call plus any wait time given. For those
-sites that have been called with either the \-f or \-S option the retry
-time will be the time of the failing call plus 120 seconds.
-.PP
-In case the time calculated from the values found in a \.Status file is
-lower than the current time, the current time plus 60 seconds will be taken
-as the retry time.
-.PP
-A site will
-.IR not
-be automatically called again if one of the following
-conditions is met:
-.PP
-\-
-.IR uucico
-is terminated by a signal
-.PP
-\- either fork() or exec() failed
-.PP
-\- the
-.IR at
-command failed for any reasons.
-.PP
-\- if no wait should be honored and the retry time is found to be zero.
-(this may indicate a `Wrong time to call' condition.
-.PP
-There are other circumstances that may lead to not reschedule a call or
-not to call
-.IR uucico
-at all, all of which should be accompanied by (a) self explanatory message(s).
-.SH BUGS
-\- invalid options will make
-.IR uucico
-fail. The exit code for this type is the same as for any other failure; this
-can reschedule the call over and over again or never.
-.PP
-\-
-.IR autopoll
-may not work as expected when called with options other than \-r1, \-s,
-\-S or \-f.
-.PP
-\- a rescheduled call may fail with `wrong time to call' the second time
-but will be rescheduled again. The times to call won't be checked by
-.IR autopoll
-and the .Status file may not indicate this in case the \-c option is given.
-.PP
-\- in case the ..._DIR points to an invalid file a `Bus error' my pop up
-during the `exec' call.
-.PP
-\- the `chat-timeout' value may have to be increased when using
-.IR autopoll.
-An indication to do that is that the call fails short after `CONNECT'
-has been received with `Time out in chat script'.
-.PP
-\- the site names given will be checked aginst the output of
-.I uuname
-without any alias expansion done.
-.PP
-\- the text strings whithin the \.Status files will not be used to detect
-a failing call.
-.SH FILES
-.nf
-/usr/local/lib/uucp UUCP internal utilities
-/usr/lib/uucp
-/usr/local/bin UUCP internal utilities
-/usr/bin
-/usr/spool/uucp/.Status/ Status files for each site
-/usr/spool/uucp/ UUCP spool area. one of its sub-
-X directories will hold the null jobs.
-/tmp/poll.log This file is present only if autopoll
-X has been compiled to place the messages
-X into a file. Otherwise all messages will
-X go to stderr. The directory as well as
-X the name may be different.
-.fi
-.SH SEE ALSO
-uucp(1C), uux(1C), uucico(8C), uupoll(8C), uuname(1C), sort(1), uniq(1),
-at(1)
-SHAR_EOF
-chmod 0444 uupoll/autopoll.8c ||
-echo 'restore of uupoll/autopoll.8c failed'
-Wc_c="`wc -c < 'uupoll/autopoll.8c'`"
-test 4718 -eq "$Wc_c" ||
- echo 'uupoll/autopoll.8c: original size 4718, current size' "$Wc_c"
-fi
-# ============= uupoll/autopoll.c ==============
-if test -f 'uupoll/autopoll.c' -a X"$1" != X"-c"; then
- echo 'x - skipping uupoll/autopoll.c (File already exists)'
-else
-echo 'x - extracting uupoll/autopoll.c (Text)'
-sed 's/^X//' << 'SHAR_EOF' > 'uupoll/autopoll.c' &&
-/* ---------------------------------------------------------------------------*
-X
-X Name: autopoll
-X
-X Author: Klaus Dahlenburg <kdburg@incoahe.hanse.de>
-X
-X Status: Public domain
-X
-X Copyright: none; claiming it to be your work will adversly affect
-X your image to be a good programmer.
-X
-X Function: Autopoll may be called just as uucico is called. The difference
-X is that autopoll will call uucico and if the return code is
-X not zero a check is made on the status files to see which site's
-X call failed. Those sites will be called again at that time found
-X in the status file plus any imposed wait. The next call will be
-X scheduled via an at job which in turn is handled by cron.
-X Atrun depends on the scheduling granularity of cron so the
-X actual times may be later than planned.
-X Autopoll will check the options -f and -s (-S) as well as the name
-X of the site passed. All other options will be passed unchecked.
-X The -f and -S options will indicate to autopoll that any wait
-X to call a site should be ignored; if the call fails the next
-X call to those sites will be at the current time plus 120 secs.
-X When the time found plus any wait evaluates to a time that
-X passed already the next call will be the current time plus 60
-X secs. The name of the site if given must be a valid one and not
-X the host itself otherwise it will be ignored.
-X
-X Call: autopoll [ options ]
-X
-X all option that apply to uucico may be given and
-X will be passed verbatim. See man uucico(8).
-X
-X Environment: NeXT 2.1+, Taylor UUCP-1.04+
-X
-X I/O: stdin: unused.
-X stdout: used only when ALOG_DIR is defined and the file
-X can't be opened. It will be a single message to tell
-X just that and the run is aborted.
-X stderr: all messages go here.
-X If ALOG_DIR is defined (see conf.h) all messages will
-X be appended to a file autopoll.msglog in that
-X directory; the file will be created automatically if
-X necessary; a redirection is then no longer possible.
-X Needs access to .Status files (see Comments later on).
-X
-X Called Programs: sort, uniq, uucico, uuname, at
-X
-X Compile: no special options are needed. Compiled with gcc 2.3.3 -O2.
-X Compile with the supplied cc might produce erroneous code
-X for the check options switch case 's' code: the break inside
-X the first if (..) {... break} is ignored.
-X
-X Comments: - should run setuid UUCP or whatever userid is necessary to
-X access (RDONLY) the .Status files and to run the programs
-X named under "Called Programs" above.
-X - No alias expansion is done on the given names for the
-X check against uuname's output..
-X - Invalid arguments will yield in an exit code > 0 as do
-X "normal" failures. It may therefore happen that a site
-X is called at the intervals with the same invalid arguments.
-X - "Wrong time to call" is not handled properly and may
-X call the site at the intervals until the time ban is lifted.
-X - human action is necessary as we can't distinguish between
-X "normal" failures and "errors" such as wrong password,
-X number to dial etc. The logs should be checked periodically.
-X - if CICO_DIR points to a non existent program the run may
-X end with signal 10: Bus Error.
-X - is has been observed that uucico will time out with "Dial
-X failed" when called via autopoll; setting chat-timeout to
-X value of 40 cured that problem.
-X - no rescheduling is done in case uucico fails and this
-X is not reported in the .Status file, one should check
-X the uucico log; this is to the fact that autopoll will
-X not scan the uucico log.
-*/
-X
-X
-#if !defined(lint)
-static char rcsid[] = "$Id: uupoll.shar,v 1.4 1997/02/22 15:27:02 peter Exp $";
-#endif /* not lint */
-X
-X/* Log: uupoll.shar,v
-X * Revision 2.8 1994/04/14 17:22:54 kdburg
-X * corrected misspelled AT_OPTION
-X *
-X * Revision 2.7 1994/04/11 20:15:48 kdburg
-X * major rework done; honor now some of the new option taht came with
-X * uucp-1.05
-X *
-X * Revision 2.6 1994/03/26 17:40:30 kdburg
-X * added support for UNAME_DIR; cleanup of some code; adjusted code after
-X * obtaining sitenames via popen()
-X *
-X * Revision 2.5 1993/07/07 16:49:02 kdburg
-X * when used interactivly only the start msg is put into the msg-log
-X * so far defined (UULOG)
-X *
-X * Revision 2.4 1993/06/26 16:17:51 kdburg
-X * the -S option wasn't propagated to the command passed to the at pgm
-X *
-X * Revision 2.3 1993/05/25 12:05:01 kdburg
-X * added error check on gettimeofday; added comment in the note section;
-X * minor changes not affection code
-X *
-X * Revision 2.2 1993/05/17 20:47:05 kdburg
-X * execution of at cmd also ok always said failed...
-X *
-X * Revision 2.1 1993/05/16 21:49:13 kdburg
-X * changed exit() to _exit() in case the exec fails within child
-X *
-X * Revision 2.0 1993/05/16 14:12:05 kdburg
-X * initial revision
-X * */
-X
-#define CAT 16
-#define SEVERE 8
-#define WARNING 4
-#define OK 0
-/* Boolean types */
-typedef int bool;
-#undef TRUE
-#undef FALSE
-#define TRUE (1)
-#define FALSE (0)
-X
-#include "conf.h"
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <ctype.h>
-#include <pwd.h>
-#include <unistd.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-X
-#ifdef ALOG_FILE
-X static char Msg_Log[] = ALOG_FILE; /* name of msglog filename */
-#endif
-X
-#ifdef UNAME_DIR
-X static char subcmd[] = " | sort | uniq"; /* pipe that follows uuname */
-#else /* ! UNAME_DIR */
-X static char Sort[] = "uuname | sort | uniq"; /* default to obtain site names */
-#endif /*UNAME_DIR */
-X
-#ifdef AT_OPTION
-X static char at_opt[] = AT_OPTION;
-#else
-X static char at_opt[] = "-mc";
-#endif /* AT_OPTION */
-X
-static char at_cmd[] = "at";
-static char cGrade[] = DEF_GRADE; /* grade as defined in conf.h */
-static char dGrade[] = "A"; /* use this if DEF_GRADE is invalid */
-static char Auto_Dir[] = AUTO_DIR; /* we live here */
-static char Cico_Dir[] = CICO_DIR; /* here lives cico */
-X
-struct Sites {
-X char name[MAXHOSTNAMELEN+1]; /* name of site as supplied by uuname */
-X char grade[1]; /* as passed or defaulted */
-X bool flag; /* TRUE: call this site only */
-X bool force; /* TRUE: -S or -f option given */
-X int stat_code;
-X int stat_retries;
-X long stat_lastcall;
-X long stat_delay;
-X char *stat_errtext;
-};
-X struct Common_Stor {
-X int maxtab; /* high-water-mark for site tab */
-X int Single_Site_Tab; /* entry into site tab for a site */
-X /* passed via -s or -S option */
-X bool force_any; /* TRUE: -f option without site */
-X bool one_site; /* TRUE: call for a specific site */
-X bool nodetach; /* TRUE: -D or --nodetach found */
-X bool ifwork; /* TRUE: -C or --ifwork found */
-X char *Grade; /* use this as grade for calls */
-X char *Poll_Pgm; /* our name without path */
-X char *called_as; /* but called by this name */
-X int our_pid; /* our process-id */
-X char *Uucico; /* cico's name without path */
-X char This_Site[MAXHOSTNAMELEN+1]; /* our site name */
-X char Single_Site[MAXHOSTNAMELEN+1]; /* name of site found as arg */
-X union wait *W_Stat;
-X char *Usort; /* will hold uuname + subcmd */
-X struct passwd *pwd;
-X struct timeval tp;
-X struct timezone tzp;
-X struct Sites Sitetab[SITE_MAX];
-X char mon[3];
-X int day, hh, mm, ss;
-X char oname[24];
-X char jname[20];
-X char tstr[20];
-X char ctag[2];
-X char workf[300];
-X char call_args[300];
-X };
-X
-/* copied from taylor uucp "uudefs.h"
-X *
-X **/
-X
-/* The tstatus_type enumeration holds the kinds of status information
-X we put in the status file. The order of entries here corresponds
-X to the order of entries in the azStatus array. */
-enum tstatus_type
-{
-X /* Conversation complete. */
-X STATUS_COMPLETE,
-X /* Port unavailable. */
-X STATUS_PORT_FAILED,
-X /* Dial failed. */
-X STATUS_DIAL_FAILED,
-X /* Login failed. */
-X STATUS_LOGIN_FAILED,
-X /* Handshake failed. */
-X STATUS_HANDSHAKE_FAILED,
-X /* Failed after logging in. */
-X STATUS_FAILED,
-X /* Talking to remote system. */
-X STATUS_TALKING,
-X /* Wrong time to call. */
-X STATUS_WRONG_TIME,
-X /* Number of status values. */
-X STATUS_VALUES
-};
-X
-/* ----end-- copied from taylor uucp "uudefs.h" */
-X
-X
-/* define the prototypes
-X * */
-X
-int set_mlog(FILE **seclog, struct Common_Stor *);
-int get_sites(struct Common_Stor *);
-int Call_Cico(int argc, char *argv[], struct Common_Stor *);
-int get_args(int argc, char *argv[], struct Common_Stor *);
-int Housekeeping(int argc, char *argv[], struct Common_Stor *);
-int Chk_Status(int argc, char *argv[],
-X struct timeval tcc,
-X struct timezone tzcc,
-X struct Common_Stor *);
-int Check_Site(struct Common_Stor *);
-int start_at(char *name, struct Common_Stor *);
-void *storage(unsigned count, char *errloc, int *Rc, struct Common_Stor *);
-X
-extern int gethostname(char *name, int namelen);
-extern int system(char *cmd);
-extern int fork();
-extern int unlink(char *path);
-extern void *malloc(size_t byteSize);
-extern int execve(char *name, char *argv[], char *envp[]);
-extern int execlp(char *name, char *arg0, ...);
-extern int chmod(char *path, int mode);
-extern int getuid();
-extern int getpid();
-extern int isatty(int);
-extern char *ttyname(int);
-extern void free(void *ptr);
-#ifdef __STRICT_ANSI__
-extern FILE *popen(char *command, char *type);
-extern int pclose(FILE *stream);
-extern void _exit(int status);
-#endif /* __STRICT_ANSI__ */
-#ifdef __STRICT_BSD__
-extern int fprintf(FILE *stream, const char *format, ...);
-extern int fclose(FILE *stream);
-extern char *strerror(int errnum);
-extern int fflush(FILE *stream);
-extern void exit(int status);
-extern int fscanf(FILE *stream, const char *format, ...);
-extern int sscanf(char *s, const char *format, ...);
-#endif /* __STRICT_BSD__ */
-X
-/* --------------------------------------------------------------------------*/
-/* Main */
-/* --------------------------------------------------------------------------*/
-X
-int main(int argc, char *argv[])
-{
-X
-X struct Common_Stor *sCom_Sto;
-X int Maxrc = OK; /* Max err-code encountered so far */
-X int k = 0;
-X
-X if ( NULL == (sCom_Sto = malloc(sizeof(struct Common_Stor))) ) {
-X fprintf(stderr,"%s: (C) malloc failed (%s). Reason: %i (%s)\n",
-X AUTO_DIR,"Common_Stor",errno,strerror(errno));
-X exit (CAT);
-X }
-X
-X Maxrc = Housekeeping(argc, argv, sCom_Sto);
-X
-/* If any errors popped up so far they are of such a nature that it is very
-X * questionable to continue; so we better bail out in this case.
-X */
-X if (Maxrc <= WARNING) {
-X if ((sCom_Sto->W_Stat = (union wait *)storage (sizeof(union wait),
-X "W_Stat",&Maxrc,sCom_Sto)) != NULL) {
-X k = Call_Cico(argc, argv, sCom_Sto);
-X Maxrc = Maxrc >= k ? Maxrc:k;
-X free(sCom_Sto->W_Stat);
-X sCom_Sto->W_Stat = NULL;
-X }
-X }
-X k = gettimeofday(&sCom_Sto->tp, &sCom_Sto->tzp);
-X fprintf(stderr,"%s: (I) ended with rc = %i on %s\n",
-X sCom_Sto->called_as,
-X Maxrc,k!=0 ? "time unavailable":ctime(&sCom_Sto->tp.tv_sec));
-X fclose(stderr);
-X free(sCom_Sto);
-X sCom_Sto = NULL;
-X exit (Maxrc);
-}
-X
-/* --------------------------------------------------------------------------*/
-/* Functions */
-/* --------------------------------------------------------------------------*/
-X
-/* --------------------------------------------------------------------
-X * housekeeping
-X */
-X
-int Housekeeping(argc, argv, sCom_Sto)
-X int argc;
-X char *argv[];
-X struct Common_Stor *sCom_Sto; {
-X
-X FILE *seclog = NULL;
-X int Rc = OK;
-X int Rci = OK; /* intermediate rc as returnd by functions */
-X
-X sCom_Sto->our_pid = getpid();
-X
-/*
-X * get our name sans path
-X * */
-X
-X sCom_Sto->called_as = argv[0] + strlen(*argv);
-X for(;sCom_Sto->called_as >= argv[0] && *--sCom_Sto->called_as != '/';)
-X ;
-X sCom_Sto->called_as++;
-X
-/* if defined set up the name of the message log file otherwise
-X * stderr will be used. Setup the cmd string to obtain all known sitenames
-X * which will be sorted in ascending order with duplicates removed
-X * */
-X
-X Rc = set_mlog(&seclog, sCom_Sto);
-X if (Rc > WARNING)
-X return (Rc);
-X
-/* put out the started message including the time and the userid.
-X * */
-X
-X sCom_Sto->pwd = getpwuid(getuid());
-X
-X if ((gettimeofday(&sCom_Sto->tp, &sCom_Sto->tzp)) != 0) { /* unacceptable error */
-X fprintf(stderr,"%s: (C) gettimeofday() failed. Reason: %i (%s)\n",
-X sCom_Sto->called_as,errno,strerror(errno));
-X return (Rc >= CAT ? Rc:CAT);
-X }
-X
-X if (seclog != NULL) {
-X fprintf(seclog,"\n%s: (I) started by `%s' (%s) on %s",
-X sCom_Sto->called_as,
-X (sCom_Sto->pwd==NULL) ? "???":sCom_Sto->pwd->pw_name,
-X ttyname(0),
-X ctime(&sCom_Sto->tp.tv_sec));
-X fclose(seclog);
-X }
-X fprintf(stderr,"\n%s: (I) started by `%s' on %s",
-X sCom_Sto->called_as,
-X (sCom_Sto->pwd==NULL) ? "???":sCom_Sto->pwd->pw_name,
-X ctime(&sCom_Sto->tp.tv_sec));
-X
-/* set up the default grade
-X * */
-X
-X sCom_Sto->Grade = dGrade; /* set default for now */
-X if (strlen(cGrade) != 1) {
-X fprintf(stderr,"%s: (W) grade %s invalid; default `%s' used\n",
-X sCom_Sto->called_as,cGrade,sCom_Sto->Grade);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X }
-X else
-X sCom_Sto->Grade = cGrade; /* Ok, take the one from conf.h */
-X
-/* get the program to actually call the site. This is normally UUCICO.
-X * */
-X
-X sCom_Sto->Uucico = Cico_Dir + strlen(Cico_Dir);
-X for(;sCom_Sto->Uucico >= Cico_Dir && *--sCom_Sto->Uucico != '/';)
-X ;
-X sCom_Sto->Uucico++;
-X
-/* get the path to ourself.
-X * */
-X
-X sCom_Sto->Poll_Pgm = Auto_Dir + strlen(Auto_Dir);
-X for(;sCom_Sto->Poll_Pgm >= Auto_Dir && *--(sCom_Sto->Poll_Pgm) != '/';)
-X ;
-X sCom_Sto->Poll_Pgm++;
-X
-/* obtain our sitename
-X * */
-X
-X if ((gethostname(sCom_Sto->This_Site,MAXHOSTNAMELEN+1)) != 0) {
-X fprintf(stderr,"%s: (W) hostname could not be obtained\n",
-X sCom_Sto->called_as);
-X Rc = (Rc >= WARNING) ? Rc:WARNING;
-X }
-X
-/* obtain all known sitenames
-X * */
-X
-X Rci = get_sites(sCom_Sto);
-X Rc = Rci > Rc ? Rci:Rc;
-X
-/* check the arguments that we are called with
-X * */
-X
-X Rci = get_args(argc, argv, sCom_Sto);
-X Rc = Rci > Rc ? Rci:Rc;
-X
-X return (Rc);
-}
-X
-/* --------------------------------------------------------------------
-X * check all relevant arguments that have been passed to us. Those args
-X * that may be needed for a recall will be copied to a workfield.
-X * */
-X
-int get_args(int argc, char *argv[], struct Common_Stor *sCom_Sto) {
-X
-X int j = 0;
-X int Rc = OK;
-X int Rci = OK;
-X
-X strcpy(sCom_Sto->Single_Site,"");
-X sCom_Sto->force_any = FALSE;
-X sCom_Sto->one_site = FALSE;
-X sCom_Sto->nodetach = FALSE;
-X
-X strcpy(sCom_Sto->call_args,AUTO_DIR); /* specify complete path to us */
-X strcat(sCom_Sto->call_args," "); /* and separate by one space */
-X for (j=1;j<argc;j++) {
-X if (strcmp(argv[j],"--nodetach") == 0 ||
-X strcmp(argv[j],"-D") == 0) {
-X sCom_Sto->nodetach = TRUE;
-X strcat(sCom_Sto->call_args,"-D ");
-X continue;
-X }
-X if (strcmp(argv[j],"--force") == 0 ||
-X strcmp(argv[j],"-f") == 0) {
-X strcat(sCom_Sto->call_args,"-f ");
-X sCom_Sto->force_any = TRUE;
-X continue;
-X }
-X if (strcmp(argv[j],"--ifwork") == 0 ||
-X strcmp(argv[j],"-C") == 0) {
-X sCom_Sto->ifwork = TRUE;
-X continue;
-X }
-X if ( strncmp(argv[j],"-s",2) == 0 ||
-X strncmp(argv[j],"-S",2) == 0 ||
-X strcmp(argv[j],"--system") == 0) {
-X if (strncmp(argv[j],"-S",2) == 0)
-X sCom_Sto->force_any = TRUE;
-X
-X if (strlen(argv[j]) == 2 || strcmp(argv[j],"--system") == 0) {
-X j++;
-X if (j>=argc) {
-X fprintf(stderr,"%s: (E) System to call is missing\n",
-X sCom_Sto->called_as);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X break;
-X }
-X else {
-X strcpy(sCom_Sto->Single_Site,argv[j]);
-X Rci = Check_Site(sCom_Sto);
-X if (! Rci) {
-X sCom_Sto->one_site = TRUE; /* specific call */
-X strcat(sCom_Sto->call_args,argv[j-1]);
-X strcat(sCom_Sto->call_args," ");
-X strcat(sCom_Sto->call_args,argv[j]);
-X strcat(sCom_Sto->call_args," ");
-X }
-X }
-X Rc = Rci <= Rc ? Rc:Rci;
-X }
-X else {
-X strcpy(sCom_Sto->Single_Site,argv[j]+2);
-X Rci = Check_Site(sCom_Sto);
-X if (! Rci) {
-X sCom_Sto->one_site = TRUE; /* specific call */
-X strcat(sCom_Sto->call_args,argv[j]);
-X strcat(sCom_Sto->call_args," ");
-X }
-X Rc = Rci <= Rc ? Rc:Rci;
-X }
-X continue;
-X }
-X strcat(sCom_Sto->call_args,argv[j]);
-X strcat(sCom_Sto->call_args," ");
-X } /* end copy all arguments */
-X
-X if (sCom_Sto->ifwork) {
-X if (sCom_Sto->one_site) {
-X strcat(sCom_Sto->call_args,"-C ");
-X }
-X else {
-X fprintf(stderr,"%s: (W) no site given, '-C' option is ignored\n",
-X sCom_Sto->called_as);
-X sCom_Sto->ifwork = FALSE;
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X }
-X }
-X
-X if (! sCom_Sto->nodetach) {
-X strcat(sCom_Sto->call_args,"-D ");
-X }
-X
-X return (Rc);
-}
-X
-/* --------------------------------------------------------------------
-X * call uucico or whatever programm is necessary to get connected
-X */
-X
-/* Start uucico and wait for completion. In case the return code is '0'
-X * we're finished; otherwise we'll have to check the status files for any
-X * non successful calls (retry time > 0).
-X * Any such site will be called again at the current time plus any wait
-X * Note:
-X * If the '-D' or '--nodetach' option is missing, uucico will
-X * detach immediate. The return-code is 0 in this case and therefore
-X * we can't check whether the call is successful or not. No recall
-X * is scheduled for such an invocation. If we however get control
-X * to schedule a recall we silently add the '-D' option. To add
-X * the '-D' option in any case may be undesirable for a specific
-X * type of run.
-X */
-X
-int Call_Cico(int argc, char *argv[], struct Common_Stor *sCom_Sto) {
-X
-X int W_Ret = 0;
-X int pid = 0;
-X int Rc = OK;
-X struct timeval tcc;
-X struct timezone tzcc;
-X
-X if ((gettimeofday(&tcc, &tzcc)) != 0) { /* unacceptable error */
-X fprintf(stderr,"%s: (C) gettimeofday() failed. Reason: %i (%s)\n",
-X sCom_Sto->called_as,errno,strerror(errno));
-X Rc = Rc >= CAT ? Rc:CAT;
-X }
-X
-X if (Rc > WARNING) {
-X return (Rc);
-X }
-X
-X fflush(stderr);
-X switch(pid = fork()) {
-X case -1:
-X fprintf(stderr,"%s: (C) could not fork(). Reason-code: %i (%s)\n",
-X sCom_Sto->called_as,errno,strerror(errno));
-X return (CAT);
-X case 0:
-X if ((argv[0] = (char *)storage(strlen(sCom_Sto->Uucico)+1,"argv[0]",
-X &Rc,sCom_Sto)) == NULL) {
-X _exit (CAT);
-X }
-X strcpy(argv[0],sCom_Sto->Uucico); /* change name to be uucico */
-X execve(Cico_Dir, argv, NULL);
-X fprintf(stderr,"%s: (C) could not start %s. Reason-code: %i (%s)\n",
-X sCom_Sto->called_as,
-X sCom_Sto->Uucico,errno,strerror(errno));
-X _exit (CAT); /* child: bail out */
-X default:
-X fprintf(stderr,"%s: (I) starting %s [%d]\n\n",
-X sCom_Sto->called_as,sCom_Sto->Uucico,pid);
-X fflush(stderr); /* maybe we come behind uucico's output */
-X /* if any; it's a race condition */
-X W_Ret = wait(sCom_Sto->W_Stat);
-X if (sCom_Sto->W_Stat->w_termsig == 0) {
-X if (sCom_Sto->W_Stat->w_retcode == 0) {
-X fprintf(stderr,"%s: (I) %s [%d] ended normally\n",
-X sCom_Sto->called_as,sCom_Sto->Uucico,pid);
-X return (OK);
-X }
-X if (sCom_Sto->W_Stat->w_retcode != CAT) {
-X fprintf(stderr,"%s: (I) %s's log may contain further information !\n",
-X sCom_Sto->called_as,sCom_Sto->Uucico);
-X fprintf(stderr,"\n%s: (W) %s [%d] ended with rc = %i\n",
-X sCom_Sto->called_as,
-X sCom_Sto->Uucico,pid,
-X sCom_Sto->W_Stat->w_retcode);
-X return (Chk_Status(argc, argv,
-X tcc, tzcc, sCom_Sto));
-X }
-X else
-X return (CAT); /* we where unable to exec */
-X }
-X else {
-X fprintf(stderr,"\n%s: (E) %s [%d] terminated by signal %i\n",
-X sCom_Sto->called_as,
-X sCom_Sto->Uucico,
-X pid,
-X sCom_Sto->W_Stat->w_termsig);
-X return (SEVERE);
-X }
-X } /* switch (pid = fork()) */
-X return (OK); /* Never reached: silence the compiler */
-}
-X
-X
-/* --------------------------------------------------------------------
-X * check the status after the call has completed and the return code
-X * is > zero. The status is checked for all sites found via uuname or
-X * for one site only (option -s, -S or --system given on call)
-X */
-X
-int Chk_Status(int argc, char *argv[],
-X struct timeval tcc,
-X struct timezone tzcc,
-X struct Common_Stor *sCom_Sto) {
-X
-/*
-X * For all sites found in Site_Tab their status files will be checked.
-X * The table scan will be bypassed for a call to a specific site.
-X * If the call failed the wait period is > 0. We will schedule an at-job
-X * to be run at the time found + the delta. In case we find an old entry
-X * where the time + delta is lower than the current time we'll advance
-X * the current time by 60 secs. and use that value instead.
-X * In case we are invoked to call a specific site and either the -f option or
-X * the site was given as -S... indicating to disregard any wait, we'll
-X * use the time found in the status file increased by 120 secs.
-*/
-X
-X FILE *infile;
-X long secs, retries = 0;
-X long add = 0;
-X int errind = 0;
-X int i = 0;
-X int ecnt = 0;
-X int recall_cnt = 0;
-X char curr_site[MAXHOSTNAMELEN+11] = ""; /* keyword + sitename */
-X bool schedule = TRUE; /* FALSE: no more rescheduling: unspec. + force */
-X int Rc = WARNING; /* uucico got rc = 1 otherwise we were not here */
-X int Rs = 0; /* uucico' reason code from .Status file */
-X
-/*
-X * Note
-X * We have to increase the sum of time and wait by at least one minute.
-X * That is because this time denotes the earliest point *after* which
-X * we may call again.
-X * When a site is called at the wrong time the follwing actions are
-X * taken: wait = 0 && ! force --> no further action (indicator: see log)
-X * wait = 0 && force --> (W) message generated; no further action
-X * wait > 0 && ! force --> normal scheduling at time + wait
-X * wait > 0 && force --> normal scheduling at time+120 secs
-X * We can't depend on the string "Wrong time to call" because the .Status
-X * file may not be updated due to the -c switch. This may lead to a
-X * situation where the site will be called over and over again while it's
-X * still the wrong time. (No we don't want to go fishing for a message in
-X * the uucp LOG!)
-X * In case the -s, -S or --system option was given we will only
-X * check that site and schedule a recall for it so far the
-X * conditions are met.
-X * In case the -C or --ifwork switch is given without naming a site a
-X * the option is dropped and only an unspecific call is scheduled.
-X * */
-X
-X if (sCom_Sto->one_site) {
-X i = sCom_Sto->Single_Site_Tab;
-X if (strncmp(sCom_Sto->Sitetab[i].name,
-X sCom_Sto->Single_Site,
-X sizeof(sCom_Sto->Single_Site)) != 0) {
-X fprintf(stderr,"%s: (C) internal index-error (%d): %s found: %s\n",
-X sCom_Sto->called_as,
-X i,
-X sCom_Sto->Single_Site,
-X sCom_Sto->Sitetab[i].name);
-X Rc = Rc >= CAT ? Rc:CAT;
-X return (Rc); /* break unconditionally */
-X }
-X }
-X
-X for (i = sCom_Sto->Single_Site_Tab; i <= sCom_Sto->maxtab; i++) {
-X sprintf(sCom_Sto->workf,"%s%s",STATUS_DIR,sCom_Sto->Sitetab[i].name);
-X if ((infile=fopen(sCom_Sto->workf,"r")) == NULL) {
-X ecnt++;
-X fprintf(stderr,"%s: (W) no access to status file for: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X if (sCom_Sto->one_site) {
-X break;
-X }
-X else {
-X continue;
-X }
-X }
-X
-X fscanf(infile,"%d %d %ld %ld",&errind,&retries,&secs,&add);
-X fclose(infile);
-X
-X /*
-X * in case the .Status file is not updated and we have a call to
-X * a specific site we try to give some clues of what went wrong
-X * (we won't succeed in any case!)
-X */
-X
-X if (sCom_Sto->Sitetab[i].stat_lastcall == secs && sCom_Sto->one_site) {
-X
-X if (errind == 0 && retries == 0 && add == 0)
-X break;
-X
-X if (errind > 0) {
-X if (tcc.tv_sec <= (secs+add) && ! sCom_Sto->Sitetab[i].force) {
-X fprintf(stderr,"%s: (W) retry time not reached for site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X }
-X else {
-X fprintf(stderr,"%s: (E) maybe port/site unavailable site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X }
-X else {
-X if (sCom_Sto->one_site) {
-X fprintf(stderr,"%s: (E) unknown error for call to site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X }
-X fprintf(stderr,"%s: (W) no recall scheduled for site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X break; /* bail out completely */
-X }
-X
-X if (sCom_Sto->Sitetab[i].stat_lastcall == secs) {
-X if (sCom_Sto->one_site)
-X break;
-X else
-X continue;
-X }
-X
-X Rs = OK; /* if Rs is > WARNING we won't schedule a recall */
-X switch(errind) {
-X case STATUS_COMPLETE:
-X if (add != 0 || retries != 0) {
-X fprintf(stderr,"%s: (E) unknown error for call to site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X Rs = Rs >= SEVERE ? Rs:SEVERE;
-X }
-X break;
-X case STATUS_PORT_FAILED:
-X fprintf(stderr,"%s: (E) port was unavailable site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X break;
-X case STATUS_DIAL_FAILED:
-X fprintf(stderr,"%s: (E) dail failed for site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X break;
-X case STATUS_LOGIN_FAILED:
-X fprintf(stderr,"%s: (E) login for site: %s failed\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X Rs = Rs >= SEVERE ? Rs:SEVERE;
-X break;
-X case STATUS_HANDSHAKE_FAILED:
-X fprintf(stderr,"%s: (E) handshake failed site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X break;
-X case STATUS_FAILED:
-X fprintf(stderr,"%s: (E) invalid status after login site: %s \n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X break;
-X case STATUS_TALKING:
-X break;
-X case STATUS_WRONG_TIME:
-X fprintf(stderr,"%s: (W) it's the wrong time to call site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X Rs = Rs >= SEVERE ? Rs:SEVERE;
-X break;
-X default:
-X fprintf(stderr,"%s: (E) unknown error for call to site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X Rs = Rs >= SEVERE ? Rs:SEVERE;
-X break;
-X }
-X Rc = Rs > Rc ? Rs:Rc;
-X if (Rs > WARNING) { /* schedule a recall ? */
-X fprintf(stderr,"%s: (W) no recall scheduled for site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X if (sCom_Sto->one_site)
-X break;
-X else
-X continue;
-X }
-X
-X if (add == 0) {
-X fprintf(stderr,"%s: (W) no delay found for site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X }
-X
-X
-X if (! schedule) {
-X recall_cnt += 1;
-X continue; /* scheduling already done: unspec. + force */
-X }
-X if ((gettimeofday(&sCom_Sto->tp, &sCom_Sto->tzp)) != 0) {
-X fprintf(stderr,"%s: (C) gettimeofday() failed. Reason: %i (%s)\n",
-X sCom_Sto->called_as,errno,strerror(errno));
-X fclose(infile);
-X Rc = Rc >= CAT ? Rc:CAT;
-X break; /* break unconditionally */
-X }
-X
-X if (sCom_Sto->force_any || sCom_Sto->Sitetab[i].force) {
-X add = secs + 120; /* shorten the wait */
-X }
-X else { /* ! force */
-X
-/*
-X * check for an already scheduled recall. For we don't keep
-X * a file of already scheduled recalls the only way to recognize
-X * this, is to check the current time against that of the .Stats file.
-X * In case the current time is >= the .Stats-time + n-secs fuzz value
-X * we assume (99.99% correctness) that we have already scheduled a recall
-X * for this site. If this assumption is incorrect a call will be
-X * scheduled on the next unspecific failing call. This check can't
-X * be done for forced call because the .Stats will be updated.
-X */
-X if (sCom_Sto->tp.tv_sec >= secs+2) {
-X fprintf(stderr,"%s: (W) Retry time not reached for site: %s\n",
-X sCom_Sto->called_as,
-X sCom_Sto->Sitetab[i].name);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X if (sCom_Sto->one_site)
-X break;
-X else
-X continue;
-X }
-X add += secs + 60; /* if not force then take the full wait */
-X } /* force */
-X
-X if (sCom_Sto->tp.tv_sec >= add) {
-X add = sCom_Sto->tp.tv_sec + 60; /* time < current time */
-X }
-X
-X sscanf(ctime(&add),"%*s %s %d %d:%d:%d",sCom_Sto->mon,
-X &sCom_Sto->day,
-X &sCom_Sto->hh,
-X &sCom_Sto->mm,
-X &sCom_Sto->ss);
-X
-X sprintf(sCom_Sto->oname,"/tmp/at.%d.%02d%02d%02d",sCom_Sto->our_pid,
-X sCom_Sto->hh,
-X sCom_Sto->mm,
-X sCom_Sto->ss);
-X if (! sCom_Sto->one_site) {
-X strcpy(curr_site,"-s");
-X strcat(curr_site,sCom_Sto->Sitetab[i].name);
-X }
-X
-X /*
-X * If 'onesite' is FALSE and 'force' is TRUE
-X * we will reschedule one unspecific call an let UUCICO decide
-X * which site should be called (is there any work?)
-X */
-X
-X if ( ! sCom_Sto->one_site && sCom_Sto->force_any) {
-X recall_cnt += 1;
-X schedule = FALSE;
-X continue;
-X }
-X strcat(sCom_Sto->call_args,curr_site);
-X Rs = start_at(sCom_Sto->Sitetab[i].name, sCom_Sto);
-X Rc = Rs >= Rc ? Rs:Rc;
-X unlink(sCom_Sto->oname);
-X if (Rc > SEVERE || sCom_Sto->one_site)
-X break;
-X } /* for (i = Single_Site_Tab; ...) */
-X
-X if (ecnt > sCom_Sto->maxtab) {
-X fprintf(stderr,"%s: (E) no access to status files; no scheduling done\n",
-X sCom_Sto->called_as);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X else {
-X if (! schedule) {
-X if (recall_cnt == 1) {
-X strcat(sCom_Sto->call_args,curr_site);
-X }
-X Rs = start_at("any site", sCom_Sto);
-X Rc = Rs >= Rc ? Rs:Rc;
-X unlink(sCom_Sto->oname);
-X }
-X }
-X return (Rc);
-}
-X
-X /*
-X *
-X */
-X
-int start_at(char *site, struct Common_Stor *sCom_Sto) {
-X
-FILE *outfile;
-int W_Ret = 0;
-int Rc = OK;
-int pid = 0;
-X
-/*
-X * if we can't open the workfile to be passed to AT we'll abandon
-X * this site and set the rc accordingly
-X * */
-X
-X if ((outfile=fopen(sCom_Sto->oname,"w")) == NULL) {
-X fprintf(stderr,"%s: (E) could not open workfile %s. No scheduling for: %s\n",
-X sCom_Sto->called_as,
-X sCom_Sto->oname,
-X site);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X fclose(outfile);
-X unlink(sCom_Sto->oname);
-X return (Rc); /* bail out here */
-X }
-X sprintf(sCom_Sto->jname,"at.%d.%02d%02d%02d",sCom_Sto->our_pid,
-X sCom_Sto->hh,
-X sCom_Sto->mm,
-X sCom_Sto->ss);
-X fprintf(outfile,"%s \n",sCom_Sto->call_args);
-X sprintf(sCom_Sto->tstr,"%02d%02d",sCom_Sto->hh,
-X sCom_Sto->mm);
-X sprintf(sCom_Sto->ctag,"%d",sCom_Sto->day);
-X fclose(outfile);
-X if ((chmod(sCom_Sto->oname,00644)) != 0) {
-X fprintf(stderr,"%s: (W) chmod to %s failed. Reason_code: %i (%s)\n",
-X sCom_Sto->called_as,
-X sCom_Sto->oname,
-X errno,
-X strerror(errno));
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X }
-X
-X switch (pid = fork()) {
-X case -1:
-X fprintf(stderr,"%s: (C) could not fork(). Reason-code: %i (%s)\n",
-X sCom_Sto->called_as,errno,strerror(errno));
-X return (Rc >= CAT ? Rc:CAT);
-X case 0:
-X if (*at_opt == '\0')
-X execlp(at_cmd, at_cmd, sCom_Sto->tstr,
-X sCom_Sto->mon, sCom_Sto->ctag,
-X sCom_Sto->oname, 0);
-X else
-X execlp(at_cmd, at_cmd, at_opt, sCom_Sto->tstr,
-X sCom_Sto->mon, sCom_Sto->ctag,
-X sCom_Sto->oname, 0);
-X
-X fprintf(stderr,"%s: (C) could not start AT-cmd. Reason-code: %i (%s)\n",
-X sCom_Sto->called_as,
-X errno,strerror(errno));
-X _exit (CAT); /* child: bail out */
-X default:
-X fprintf(stderr,"%s: (I) at [%d] started. Job name: %s\n",
-X sCom_Sto->called_as,
-X pid,
-X sCom_Sto->jname);
-X W_Ret = wait(sCom_Sto->W_Stat);
-X if (sCom_Sto->W_Stat->w_termsig == 0) {
-X if (sCom_Sto->W_Stat->w_retcode != 0) {
-X if (sCom_Sto->W_Stat->w_retcode != CAT) {
-X fprintf(stderr,"%s: (E) at-cmd failed for some reason\n",
-X sCom_Sto->called_as);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X else {
-X Rc = Rc >= CAT ? Rc:CAT;
-X }
-X
-X fprintf(stderr,"%s: (I) at [%d] ended with rc = %i\n",
-X sCom_Sto->called_as,
-X pid,
-X sCom_Sto->W_Stat->w_retcode);
-X /* bail out in case wait returned > SEVERE */
-X if (Rc > SEVERE) {
-X return (Rc);
-X }
-X }
-X else {
-X fprintf(stderr,"%s: (I) at-cmd [%d] ended normally\n",
-X sCom_Sto->called_as,
-X pid);
-X }
-X }
-X else {
-X fprintf(stderr,"%s: (E) at [%d] terminated by signal %i\n",
-X sCom_Sto->called_as,
-X pid,
-X sCom_Sto->W_Stat->w_termsig);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X } /* switch (pid = fork()) */
-X return (Rc);
-}
-/* -----------------------------------------------------------------
-X * check the site passed via -s or -S option to be a valid one and
-X * not to be our hostname.
-X * */
-X
-int Check_Site(struct Common_Stor *sCom_Sto) {
-X
-X int i,j = 0;
-X sCom_Sto->Single_Site_Tab = 0;
-X if (strcmp(sCom_Sto->Single_Site,sCom_Sto->This_Site) == 0) {
-X fprintf(stderr,"%s: (E) won't call *ourself* %s\n",
-X sCom_Sto->called_as,sCom_Sto->Single_Site);
-X return(SEVERE);
-X }
-X for(i=0;i<=sCom_Sto->maxtab;i++) {
-X if ((j=strcmp(sCom_Sto->Sitetab[i].name,sCom_Sto->Single_Site)) >= 0) {
-X break;
-X }
-X }
-X if (j != 0) {
-X fprintf(stderr,"%s: (E) unknown site: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Single_Site);
-X return(SEVERE);
-X }
-X sCom_Sto->Single_Site_Tab = i;
-X sCom_Sto->Sitetab[i].flag = TRUE;
-X if (sCom_Sto->force_any) {
-X sCom_Sto->Sitetab[i].force = TRUE;
-X sCom_Sto->force_any = FALSE;
-X }
-X return(OK);
-}
-X
-X /* ------------------------------------------------------------------
-X * storage - get some memory
-X */
-X
-void *storage(unsigned count,
-X char *location,
-X int *Rc,
-X struct Common_Stor *sCom_Sto)
-{
-X void *p;
-X
-X if( NULL == (p= malloc(count)) ) {
-X fprintf(stderr,"%s: (C) malloc failed (%s). Reason: %i (%s)\n",
-X sCom_Sto->called_as,location,errno,strerror(errno));
-X *Rc = *Rc >= CAT ? *Rc:CAT;
-X }
-X return p;
-}
-X
-/* ------------------------------------------------------------------
-X * if defined open the message log file otherwise all mesages will go
-X * to stderr. If UNAME_DIR is defined construct the command to be
-X * passed to popen(); if undefined the deafult will be used
-X * */
-X
-int set_mlog(FILE **seclog, struct Common_Stor *sCom_Sto) {
-X
-X int Rc = 0;
-X
-#ifdef ALOG_FILE
-X if (!isatty(0)) {
-X if ((freopen(Msg_Log,"a",stderr)) == NULL) {
-X fprintf(stdout,"%s: (C) Could not open msglog: %s\n",
-X sCom_Sto->called_as,Msg_Log);
-X return (Rc >= CAT ? Rc:CAT);
-X }
-X }
-X else {
-X if ((*seclog = fopen(Msg_Log,"a")) == NULL) {
-X fprintf(stderr,"%s: (C) Could not open msglog: %s\n",
-X sCom_Sto->called_as,Msg_Log);
-X return (Rc >= CAT ? Rc:CAT);
-X }
-X }
-#endif /* ALOG_FILE */
-X
-/* set up the pipe together with the complete path to uuname */
-X
-#ifdef UNAME_DIR
-X if ((sCom_Sto->Usort = (char *)storage (sizeof(UNAME_DIR)+sizeof(subcmd),
-X "Sort",&Rc, sCom_Sto)) != NULL) {
-X strncpy(sCom_Sto->Usort,UNAME_DIR,strlen(UNAME_DIR)); /* paste in the path */
-X strcat(sCom_Sto->Usort,subcmd); /* chain the pipe to it */
-X }
-#else /* ! UNAME_DIR */
-X sCom_Sto->Usort = &Sort; /* set pointer to uuname + sort */
-#endif /* UNAME_DIR */
-X
-X return (Rc);
-}
-X
-/* ------------------------------------------------------------------
-X * obtain all active sitenames
-X * */
-X
-int get_sites(struct Common_Stor *sCom_Sto) {
-X
-X int i = 0;
-X int n;
-X int Rc = 0;
-X FILE *infile, *statsfile;
-X
-X if ((infile=popen(sCom_Sto->Usort,"r")) != NULL) {
-X while(fgets(sCom_Sto->Sitetab[i].name,MAXHOSTNAMELEN+1,infile)) {
-X if (i > SITE_MAX) { /* let'm run so that we can give */
-X i++; /* the user some guidance */
-X continue; /* we'll tell the user later on */
-X }
-X n = strlen(sCom_Sto->Sitetab[i].name)-1; /* offset: next to last char */
-X sCom_Sto->Sitetab[i].name[n] = '\0'; /* strip trailing newline */
-X sCom_Sto->Sitetab[i].flag = FALSE; /* TRUE: poll this site only*/
-X sCom_Sto->Sitetab[i].force = FALSE; /* TRUE: force call */
-X strcpy(sCom_Sto->Sitetab[i].grade,sCom_Sto->Grade);
-X sprintf(sCom_Sto->workf,"%s%s",STATUS_DIR,sCom_Sto->Sitetab[i].name);
-X if ((statsfile=fopen(sCom_Sto->workf,"r")) == NULL) {
-X fprintf(stderr,"%s: (W) no access to status file for: %s\n",
-X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X }
-X else {
-X fscanf(statsfile,"%d %d %ld %ld %s",
-X &sCom_Sto->Sitetab[i].stat_code,
-X &sCom_Sto->Sitetab[i].stat_retries,
-X &sCom_Sto->Sitetab[i].stat_lastcall,
-X &sCom_Sto->Sitetab[i].stat_delay,
-X sCom_Sto->workf);
-X
-X fclose(statsfile);
-X if ((sCom_Sto->Sitetab[i].stat_errtext =
-X (char *)storage (sizeof(sCom_Sto->workf),
-X "stat_errtext",&Rc, sCom_Sto)) == NULL) {
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X }
-X else
-X strcpy(sCom_Sto->Sitetab[i].stat_errtext,sCom_Sto->workf);
-X }
-X sCom_Sto->maxtab = i++; /* set high-water-mark */
-X }
-X if (ferror(infile) != 0) {
-X fprintf(stderr,"%s: (E) fgets() for sitenames failed reason-code: %i (%s)\n",
-X sCom_Sto->called_as,errno,strerror(errno));
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X pclose(infile);
-X
-X /*
-X * check for an empty table (strange but possible)
-X */
-X
-X if (sCom_Sto->maxtab == 0) {
-X fprintf(stderr,"%s: (E) could not obtain sitenames.\n",
-X sCom_Sto->called_as);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X else {
-X
-X /* in case the internal table overflows we'll now give notice and tell
-X * the user by which amount the table has to be increased to hold all
-X * site-names
-X */
-X
-X if (i > SITE_MAX) {
-X fprintf(stderr,"%s: (E) number of sites > internal tab\n",
-X sCom_Sto->called_as);
-X fprintf(stderr,"%s: (E) increase SITE_MAX to >= %d and recompile\n",
-X sCom_Sto->called_as,i);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X } /* sCom_Sto->maxtab == 0 */
-X
-X }
-X else /* infile == NULL */
-X {
-X fprintf(stderr,"%s: (E) could not sort sitenames. Reason-code: %i (%s)\n",
-X sCom_Sto->called_as,errno,strerror(errno));
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X
-X } /* if ((infile=popen(sCom_Sto->Usort,"r")) ... */
-X
-X return (Rc);
-}
-SHAR_EOF
-chmod 0444 uupoll/autopoll.c ||
-echo 'restore of uupoll/autopoll.c failed'
-Wc_c="`wc -c < 'uupoll/autopoll.c'`"
-test 44031 -eq "$Wc_c" ||
- echo 'uupoll/autopoll.c: original size 44031, current size' "$Wc_c"
-fi
-# ============= uupoll/conf.h ==============
-if test -f 'uupoll/conf.h' -a X"$1" != X"-c"; then
- echo 'x - skipping uupoll/conf.h (File already exists)'
-else
-echo 'x - extracting uupoll/conf.h (Text)'
-sed 's/^X//' << 'SHAR_EOF' > 'uupoll/conf.h' &&
-#ifndef CONF
-X #define CONF
-X
-X/* $Id: uupoll.shar,v 1.4 1997/02/22 15:27:02 peter Exp $ */
-X/* Log: uupoll.shar,v
-X * Revision 1.9 1994/04/14 17:24:58 kdburg
-X * added comment to the AT_OPTION
-X *
-X * Revision 1.8 1994/03/26 17:41:06 kdburg
-X * the location of uuname can now be specified. This was added due to
-X * the fact that cron (NeXT 3.2 and +) now obeys the path that was active
-X * during boot (either /.path or set within /etc/rc) so autopoll/uupoll
-X * always got the wrong uuname when called direct fron cron. This is
-X * not true when called via a script that does a 'su - user -c ...'
-X *
-X * Revision 1.7 1993/06/26 16:21:47 kdburg
-X * default location for logfiles changed
-X *
-X * Revision 1.6 1993/05/14 22:32:05 kdburg
-X * change to HAVE_SPOOLDIR_TAYLOR
-X *
-X * Revision 1.5 1993/05/09 13:16:53 kdburg
-X * make have-autopoll the default
-X *
-X * Revision 1.4 1993/05/08 23:17:34 kdburg
-X * cleanup and to reflect changes made to autopoll/uupoll
-X *
-X * Revision 1.3 1993/04/29 10:46:34 kdburg
-X * added def for STATUS_DIR
-X *
-X * Revision 1.2 1993/04/27 15:31:47 kdburg
-X * rearranged the defs; changed LOG_DIR to ALOG_DIR in case uupoll
-X * will have one too; we need then eventually 2 different dirs.
-X *
-X * Revision 1.1 1993/04/26 21:20:12 kdburg
-X * Initial revision
-X * */
-X
-/* --------- combined config file for uupoll and autopoll */
-/* --------- change the following defines to meet your needs */
-X
-/* define the default grade to be inserted into the pollfile name */
-#define DEF_GRADE "A"
-X
-/* Define the complete path to the uuname program.
-X * If undefined we'll use just the name 'uuname' to call it
-X * */
-#define UNAME_DIR "/usr/local/bin/uuname"
-X
-/* define the path to the directory which does contain uucico */
-#define CICO_DIR "/usr/local/lib/uucp/uucico"
-X
-/* define the path to the directory which holds all the uucp files.
-X * We'll place the poll file in one of it's subdirectories
-X * */
-#define SPOOL_DIR "/usr/spool/uucp"
-X
-/* at least one of the follwing must be defined To use the second or
-X * third set of definitions, change the ``#if 1'' to ``#if 0''
-X * and change the appropriate ``#if 0'' to ``#if 1''.
-X * */
-#if 0
-#define HAVE_SPOOLDIR_BSD
-#endif
-#if 0
-#define HAVE_SPOOLDIR_HDB
-#endif
-#if 1
-#define HAVE_SPOOLDIR_TAYLOR
-#endif
-X
-/* define the maximum number of sites in your config or L.sys */
-#define SITE_MAX 100
-X
-/* define the path to the directory which is to contain the
-X * message log created by uupoll and the file name itself.
-X * change the ``#if 1'' to ``#if 0'' to have the messages on stderr
-X * */
-#if 1
-#define ULOG_FILE "/Logfiles/poll.log"
-#endif
-X
-/* change if to 0 if you don't have autopoll installed. */
-#if 1
-#define AUTO_POLL
-#endif
-X
-/* The following defs are irrelevant if you don't have autopoll */
-X
-/* define the options to be given to the at cmd (-s -c -m). The default
-X * is shown (use csh and send mail after execution) if AT_OPTION is
-X * undefined
-X * */
-#define AT_OPTION "-mc"
-X
-/* Define the complete path to the autopoll program.
-X * This will assure that we get the one we want
-X * The path must be the same as given in Makefile (lbindir)
-X * */
-#define AUTO_DIR "/usr/local/lib/uucp/autopoll"
-X
-/* define the path to the directory which is to contain the
-X * message log created by autopoll and the file name itself.
-X * change the ``#if 1'' to ``#if 0'' to have the messages on stderr
-X * */
-#if 1
-#define ALOG_FILE "/Logfiles/poll.log"
-#endif
-X
-/* define the full path to the directory which holds the status files
-X * The name should be given *except* the sitename. A trailing `/' if any
-X * must be given.
-X * Example: /usr/spool/uucp/.Status/sys.sitename
-X * then specify STATUS_DIR as
-X * "/usr/spool/uucp/.Status/sys."
-X * */
-#define STATUS_DIR "/usr/spool/uucp/.Status/"
-#endif
-SHAR_EOF
-chmod 0444 uupoll/conf.h ||
-echo 'restore of uupoll/conf.h failed'
-Wc_c="`wc -c < 'uupoll/conf.h'`"
-test 3884 -eq "$Wc_c" ||
- echo 'uupoll/conf.h: original size 3884, current size' "$Wc_c"
-fi
-# ============= uupoll/uupoll.8c ==============
-if test -f 'uupoll/uupoll.8c' -a X"$1" != X"-c"; then
- echo 'x - skipping uupoll/uupoll.8c (File already exists)'
-else
-echo 'x - extracting uupoll/uupoll.8c (Text)'
-sed 's/^X//' << 'SHAR_EOF' > 'uupoll/uupoll.8c' &&
-.\" Copyright (c) 1986 Regents of the University of California.
-.\" All rights reserved. The Berkeley software License Agreement
-.\" specifies the terms and conditions for redistribution.
-.\"
-.\" @(#)uupoll.8c 6.1 (Berkeley) 4/24/86
-.\" @(#)uupoll.8c 1.11 (incoahe) 5/09/1993
-.\"
-.TH UUPOLL 8C "Mai 09, 1993"
-.UC 6
-.SH NAME
-uupoll \- poll a remote \s-1UUCP\s+1 site
-.SH SYNOPSIS
-.B uupoll
-[
-.BI \-g grade
-] [
-.B \-n
-] [
-.B \-x
-]
-.I system ... ...
-.SH SUMMARY
-This version of
-.IR uupoll
-can be used to fully replace the vendor supplied
-.IR uupoll
-that comes with the NeXTStep OS. The original version (up to 3.1) had a
-X bug in that
-X an unknown site given as argument would yield in a `Bus error' condition.
-Using any other type of UUCP like Taylor-UUCP with the option of having
-a different file structure as well as a different L.sys will therefore
-make it necessary to do maintenance to the (unused) L.sys as well to keep
-.IR uupoll
-going. This one has been programmed from scratch due to the fact that no
-source code was available. Some enhancements have been incorporated into
-this version:
-.PP
-\- the default grade may now be compiled different from `A'.
-.PP
-\- the options may now be given in any order and the \-g option may be given
-more than once. Any option will be used immediately when encountered and
-will stay in effect unless reset; this does not apply to the \-x and \-n
-option which can't be reset. The processing of options is guaranteed to be
-from left to right so that some grouping may be achieved (see below).
-.PP
-\-
-.IR uupoll
-may be used to call any program instead of
-.IR uucico
-namely
-.IR autopoll
-to ease the task of rescheduling a failed call.
-.SH DESCRIPTION
-.I Uupoll
-is used to force a poll of a remote system. It queues a null job for the
-remote system, unless the \-x option has been given, and then invokes
-either
-.IR uucico (8C)
-or
-.IR autopoll (8C)
-or any other program depending on how
-.IR uupoll
-is customized. If used in conjunction with
-.IR autopoll
-the latter will then invoke
-.IR uucico.
-.SH OPTIONS
-The following options are available:
-.TP 8
-.BI \-g grade
-Only send jobs of grade
-.I grade
-or higher on this call. The
-.I grade
-stays in effect until it is changed by a different \-g option.
-.TP 8
-.B \-n
-Queue the null job, but do not invoke the program that actually calls
-the named site(s).
-The \-n option once given will apply to all sites following to the
-.IR right
-of it.
-.TP 8
-.B \-x
-Do not place a null job for all following sites. This option must be given
-before the \-n option. The \-n option will nullify this. Any grade in effect
-will not be honored because
-.I uucico (Taylor)
-does not carry the \-g option at the moment.
-.PP
-.I Uupoll
-is usually run by
-.IR cron (5)
-or by a user who wants to hurry a job along. A typical entry in
-.I crontab
-could be:
-.PP
-.nf
-X 0 0,8,16 * * * uucp /usr/bin/uupoll ihnp4
-X 0 4,12,20 * * * uucp /usr/bin/uupoll ucbvax
-.fi
-This will poll
-.B ihnp4
-at midnight, 0800, and 1600, and
-.B ucbvax
-at 0400, noon, and 2000.
-.PP
-If the local machine is already running
-.I uucico
-every
-hour and has a limited number of outgoing modems, a better approach
-might be:
-.PP
-.nf
-X 0 0,8,16 * * * uucp /usr/bin/uupoll -n ihnp4
-X 0 4,12,20 * * * uucp /usr/bin/uupoll -n ucbvax
-X 5 * * * * uucp /usr/lib/uucp/uucico -r1 -D -C
-.fi
-This will queue null jobs for the remote sites at the top of the hour; they
-will be processed by
-.I uucico
-when it runs five minutes later (the -C option apply to Taylor
-uucp-1.05 only, the -D option applies to Talor uucp-1.04 and up)
-.SH EXTENDED options
-An example of the options and how they interact is given below. The working
-order while processing the options is left to right:
-.nf
-X uupoll -gC site1 -gB site2 -x site3 -n -gA site4 site5
-.fi
-.PP
-this poll will:
-.PP
-- call immediate site1 with grade C or higher and will place a null job
-.PP
-- call immediate site2 with grade B or higher and will place a null job
-.PP
-- call immediate site3 with grade B or higher without placing a null job
-.PP
-- just placing a null job for site4 and site5 with grade A or higher. These
-sites will be called at the next regular schedule.
-.SH BUGS
-When more than one site is given on the command line and no \-n option is
-given there will be an immediate invocation of
-.IR uucico
-or
-.IR autopoll
-for
-.IR all
-sites given. That may lead to a `No port available' condition.
-.SH FILES
-.ta \w'/usr/spool/uucp/ 'u
-.nf
-/etc/uucp/ UUCP internal files/utilities
-/usr/spool/uucp/ Spool directory
-/tmp/poll.log This file is present only if uupoll has been
-X compiled to place the messages into a file.
-X Otherwise all messages will go to stderr.
-X The directory as well as the name may be
-X different. The name may be defined at compile time.
-.fi
-.SH SEE ALSO
-uucp(1C), uux(1C), uucico(8C), autopoll(8C)
-SHAR_EOF
-chmod 0444 uupoll/uupoll.8c ||
-echo 'restore of uupoll/uupoll.8c failed'
-Wc_c="`wc -c < 'uupoll/uupoll.8c'`"
-test 4787 -eq "$Wc_c" ||
- echo 'uupoll/uupoll.8c: original size 4787, current size' "$Wc_c"
-fi
-# ============= uupoll/uupoll.c ==============
-if test -f 'uupoll/uupoll.c' -a X"$1" != X"-c"; then
- echo 'x - skipping uupoll/uupoll.c (File already exists)'
-else
-echo 'x - extracting uupoll/uupoll.c (Text)'
-sed 's/^X//' << 'SHAR_EOF' > 'uupoll/uupoll.c' &&
-/* ---------------------------------------------------------------------------*
-X
-X Name: uupoll
-X
-X Author: Klaus Dahlenburg <kdburg@incoahe.hanse.de>
-X
-X Status: Public domain
-X
-X Copyright: none
-X
-X Funktion: The main intention behind this program was to get a full
-X replacement of the uupoll supplied by NeXT when using an
-X UUCP or a file structure that is different from that hardwired
-X config in NeXT's uupoll. The lack of source made it impossible
-X to modify the supplied uupoll.
-X
-X Call: uupoll [-n] [-x] [-g[A | 0-9,A-Z,a-z]] site ...
-X
-X -n just place a poll file but do not call uucico;
-X This option can be given only once.
-X -x meaningful only for sites not affected by the -n
-X option. It prevents the creation of a poll file;
-X the default is to place one. In case the poll fails
-X there will be no attempt to poll those sites on
-X the next general (unspecific) poll. If using
-X autopoll the site will be called at the next + 1
-X run of autopoll.
-X -g any grade may be given to meet the criteria for
-X a successful poll. The default being specified
-X in conf.h (A).
-X This option may be given individually for each
-X site to call.
-X site the name of the site to be called. As many sites
-X as necessary may be specified separated by at least
-X one blank.
-X Note: any site will be called with the options currently in
-X effect. The working order is left to right. Example:
-X uupoll -gQ site1 site2 -gZ site3 -n site4
-X site1 and site2 will be called immediate with grade Q
-X site3 will be called immediate with grade Z. Site4 will
-X have a poll file created with grade Z.
-X
-X Environment: NeXT 2.1
-X
-X Called Programs: sort, uniq, uucico (or autopoll), uuname
-X
-X Compile: no special options are needed
-X
-X Comments: - should run setuid UUCP or whatever userid is necessary to
-X write to the spool directory with the proper ownership of
-X the files and to run uucico.
-X - No alias expansion is done on the given names.
-*/
-X
-#if !defined(lint)
-static char rcsid[] = "$Id: uupoll.shar,v 1.4 1997/02/22 15:27:02 peter Exp $";
-#endif /* not lint */
-X
-X/* Log: uupoll.shar,v
-X * Revision 2.7 1994/04/14 17:22:04 kdburg
-X * major rework done
-X *
-X * Revision 2.6 1994/03/26 17:38:41 kdburg
-X * added support for UNAME_DIR; cleanup of some code; adjusted code after
-X * obtaining sitenames via popen()
-X *
-X * Revision 2.5 1994/03/24 19:01:24 kdburg
-X * some minor changes; some calls had their rc not checked
-X *
-X * Revision 2.4 1993/07/08 07:56:26 kdburg
-X * befor invoking autopoll stdin is now closed to avoid blocking of
-X * terminal
-X *
-X * Revision 2.3 1993/07/05 19:43:00 kdburg
-X * when used interactivly only the start msg is put into the msg-log
-X * so far defined (UULOG)
-X *
-X * Revision 2.2 1993/05/20 18:50:52 kdburg
-X * no execute permission to the poll-pgm (uucico/autopoll) was not
-X * reflected in the log; when to start message was not given when -x
-X * option was present
-X *
-X * Revision 2.1 1993/05/16 21:48:15 kdburg
-X * changed exit() to _exit() in case the exec fails within child
-X *
-X * Revision 2.0 1993/05/16 14:11:04 kdburg
-X * initial revision
-X * */
-X
-#define CAT 16
-#define SEVERE 8
-#define WARNING 4
-#define OK 0
-#define P_MODE 00647 /* file-mode for poll-file */
-/* Boolean types */
-typedef int bool;
-#undef TRUE
-#undef FALSE
-#define TRUE (1)
-#define FALSE (0)
-X
-#include "conf.h"
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <ctype.h>
-#include <sys/file.h>
-#include <sys/param.h>
-#include <pwd.h>
-#include <sys/time.h>
-X
-#define X_OK 1 /* access: executable ? */
-X
-#ifdef ALOG_FILE
-X static char Msg_Log[] = ALOG_FILE; /* name of msglog filename */
-#endif
-X
-#ifdef UNAME_DIR
-X static char subcmd[] = " | sort | uniq"; /* pipe that follows uuname */
-#else /* ! UNAME_DIR */
-X static char Sort[] = "uuname | sort | uniq"; /* default to obtain site names */
-#endif /*UNAME_DIR */
-X
-static char cGrade[] = DEF_GRADE; /* grade as defined in conf.h */
-static char dGrade[] = "A"; /* use this if DEF_GRADE is invalid */
-#ifdef AUTO_POLL
-X static char Auto_Dir[] = AUTO_DIR; /* autopoll lives here */
-#else
-X static char Cico_Dir[] = CICO_DIR; /* and here lives cico */
-#endif /* AUTO_POLL */
-X
-struct Sites {
-X char name[MAXHOSTNAMELEN+1]; /* name of site as supplied by uuname */
-X char grade[1]; /* as passed or defaulted */
-X bool flag; /* TRUE this site should be polled */
-X int asap; /* 1 without -n; 2 with -x option */
-};
-X struct Common_Stor {
-X int maxtab; /* high-water-mark for site tab */
-X char *Grade; /* use this as grade for calls */
-X char *Poll_Pgm; /* our name without path */
-X char *called_as; /* but called by this name */
-X int our_pid; /* our process-id */
-X char *Uucico; /* cico's name without path */
-X char This_Site[MAXHOSTNAMELEN+1]; /* our site name */
-X char System[MAXHOSTNAMELEN+1]; /* intermediate to hold sitename */
-X char *Usort; /* will hold uuname + subcmd */
-X struct passwd *pwd;
-X struct timeval tp;
-X struct timezone tzp;
-X struct Sites Sitetab[SITE_MAX];
-X char workf[300];
-X };
-X
-/* define the prototypes
-X * */
-X
-int set_mlog(FILE **seclog, struct Common_Stor *);
-int get_sites(struct Common_Stor *);
-int Check_Args(int argc, char *argv[], struct Common_Stor *);
-int Housekeeping(int argc, char *argv[], struct Common_Stor *);
-int Call_Site(struct Common_Stor *);
-void *storage(unsigned count, char *errloc, int *Rc, struct Common_Stor *);
-X
-extern int getpid();
-extern void free(void *ptr);
-extern int access(char *path, int mode);
-extern int gethostname(char *name, int namelen);
-extern int system(char *cmd);
-extern int fork();
-extern int execlp(char *name, char *arg0, ...);
-extern void *malloc(size_t byteSize);
-extern int getuid();
-extern int isatty(int);
-extern char *ttyname(int);
-extern int open(char *path, int flags, int mode);
-extern int close(int fd);
-#ifdef __STRICT_ANSI__
-extern FILE *popen(char *command, char *type);
-extern int pclose(FILE *stream);
-extern void _exit(int status);
-#endif /* __STRICT_ANSI__ */
-#ifdef __STRICT_BSD__
-extern int fprintf(FILE *stream, const char *format, ...);
-extern int fclose(FILE *stream);
-extern char *strerror(int errnum);
-extern int fflush(FILE *stream);
-extern void exit(int status);
-#endif /* __STRICT_BSD__ */
-X
-/* --------------------------------------------------------------------------*/
-/* Main */
-/* --------------------------------------------------------------------------*/
-X
-int main(int argc, char *argv[])
-{
-X
-X struct Common_Stor *sCom_Sto;
-X int Maxrc = OK; /* Max err-code encountered so far */
-X int k = 0;
-X
-X if ( NULL == (sCom_Sto = malloc(sizeof(struct Common_Stor))) ) {
-X fprintf(stderr,"%s: (C) malloc failed (%s). Reason: %i (%s)\n",
-X argv[0],"Common_Stor",errno,strerror(errno));
-X exit (CAT);
-X }
-X
-X Maxrc = Housekeeping(argc, argv, sCom_Sto);
-X
-/* If any errors popped up so far they are of such a nature that it is very
-X * questionable to continue; so we better bail out in this case.
-X */
-X if (Maxrc <= WARNING) {
-X k = Call_Site(sCom_Sto);
-X Maxrc = Maxrc >= k ? Maxrc:k;
-X }
-X k = gettimeofday(&sCom_Sto->tp, &sCom_Sto->tzp);
-X fprintf(stderr,"%s: (I) ended with rc = %i on %s\n",
-X sCom_Sto->called_as,
-X Maxrc,k!=0 ? "time unavailable":ctime(&sCom_Sto->tp.tv_sec));
-X fclose(stderr);
-X free(sCom_Sto);
-X sCom_Sto = NULL;
-X exit (Maxrc);
-}
-X
-/* --------------------------------------------------------------------------*/
-/* Functions */
-/* --------------------------------------------------------------------------*/
-X
-/* --------------------------------------------------------------------
-X * housekeeping
-X */
-X
-int Housekeeping(argc, argv, sCom_Sto)
-X int argc;
-X char *argv[];
-X struct Common_Stor *sCom_Sto; {
-X
-X FILE *seclog = NULL;
-X int Rc = OK;
-X int Rci = OK; /* intermediate rc as returnd by functions */
-X
-X sCom_Sto->our_pid = getpid();
-X
-/*
-X * get our name sans path
-X * */
-X
-X sCom_Sto->called_as = argv[0] + strlen(*argv);
-X for(;sCom_Sto->called_as >= argv[0] && *--sCom_Sto->called_as != '/';)
-X ;
-X sCom_Sto->called_as++;
-X
-/* if defined set up the name of the message log file otherwise
-X * stderr will be used. Setup the cmd string to obtain all known sitenames
-X * which will be sorted in ascending order with duplicates removed
-X * */
-X
-X Rc = set_mlog(&seclog, sCom_Sto);
-X if (Rc > WARNING)
-X return (Rc);
-X
-/* put out the started message including the time and the userid.
-X * */
-X
-X sCom_Sto->pwd = getpwuid(getuid());
-X
-X if ((gettimeofday(&sCom_Sto->tp, &sCom_Sto->tzp)) != 0) { /* unacceptable error */
-X fprintf(stderr,"%s: (C) gettimeofday() failed. Reason: %i (%s)\n",
-X sCom_Sto->called_as,errno,strerror(errno));
-X return (Rc >= CAT ? Rc:CAT);
-X }
-X
-X if (seclog != NULL) {
-X fprintf(seclog,"\n%s: (I) started by `%s' (%s) on %s",
-X sCom_Sto->called_as,
-X (sCom_Sto->pwd==NULL) ? "???":sCom_Sto->pwd->pw_name,
-X ttyname(0),
-X ctime(&sCom_Sto->tp.tv_sec));
-X fclose(seclog);
-X }
-X fprintf(stderr,"\n%s: (I) started by `%s' on %s",
-X sCom_Sto->called_as,
-X (sCom_Sto->pwd==NULL) ? "???":sCom_Sto->pwd->pw_name,
-X ctime(&sCom_Sto->tp.tv_sec));
-X
-/* set up the default grade
-X * */
-X
-X sCom_Sto->Grade = dGrade; /* set default for now */
-X if (strlen(cGrade) != 1) {
-X fprintf(stderr,"%s: (W) grade %s invalid; default `%s' used\n",
-X sCom_Sto->called_as,cGrade,sCom_Sto->Grade);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X }
-X else
-X sCom_Sto->Grade = cGrade; /* Ok, take the one from conf.h */
-X
-/* get the program to actually call the site. This is either UUCICO
-X * or AUTOPOLL or something completely different.
-X * */
-X
-#ifdef AUTO_POLL
-X sCom_Sto->Uucico = Auto_Dir + strlen(Auto_Dir);
-X for(;sCom_Sto->Uucico >= Auto_Dir && *--sCom_Sto->Uucico != '/';)
-X ;
-X sCom_Sto->Uucico++;
-#else /* ! AUTO_POLL */
-X sCom_Sto->Uucico = Cico_Dir + strlen(Cico_Dir);
-X for(;sCom_Sto->Uucico >= Cico_Dir && *--sCom_Sto->Uucico != '/';)
-X ;
-X sCom_Sto->Uucico++;
-#endif /* AUTO_POLL */
-X
-/* get the path to ourself.
-X * */
-X
-X sCom_Sto->Poll_Pgm = argv[0] + strlen(argv[0]);
-X for(;sCom_Sto->Poll_Pgm >= argv[0] && *--(sCom_Sto->Poll_Pgm) != '/';)
-X ;
-X sCom_Sto->Poll_Pgm++;
-X
-/* obtain our sitename
-X * */
-X
-X if ((gethostname(sCom_Sto->This_Site,MAXHOSTNAMELEN+1)) != 0) {
-X fprintf(stderr,"%s: (W) hostname could not be obtained\n",
-X sCom_Sto->called_as);
-X Rc = (Rc >= WARNING) ? Rc:WARNING;
-X }
-X
-/* obtain all known sitenames
-X * */
-X
-X Rci = get_sites(sCom_Sto);
-X Rc = Rci > Rc ? Rci:Rc;
-X
-/* check the arguments that we are called with
-X * */
-X
-X Rci = Check_Args(argc, argv, sCom_Sto);
-X Rc = Rci > Rc ? Rci:Rc;
-X
-X return (Rc);
-}
-X
-/* --------------------------------------------------------------------
-X * check all relevant arguments that have been passed to us. Those args
-X * that may be needed for a recall will be copied to a workfield.
-X * */
-X
-int Check_Args(int argc, char *argv[], struct Common_Stor *sCom_Sto) {
-X int i,s,k,n = 0;
-X int Rc = OK;
-X int One_Site = 0; /* TRUE: found at least one valid site to call */
-X int poll_file = 1; /* FALSE: after -x option given */
-X int def_flag = 0; /* TRUE: when option -n was encountered */
-X
-X /* --------------------------------------------------------------*/
-X /* check the arguments passed to us */
-X /* */
-X /* These are: -n -> place a POLL file but do not start uucico */
-X /* -x -> do not place a poll file (immed. poll only) */
-X /* -g? -> specify a grade with the POLL file. The ? */
-X /* may be: 0-9, A-Z, a-z */
-X /* (validity not checked!) */
-X /* site name of the site to call. There many be as */
-X /* many as necessary separated by at least one */
-X /* blank */
-X /* Note: all options will stay in effect as long as they are'nt */
-X /* changed by a new setting. The options -n and -x can't */
-X /* be negated once given; that means place all sites */
-X /* that should be immediately polled to the left of the */
-X /* -n option; the same applies to the -x option which must */
-X /* be left of the -n option to come into effect! */
-X /* The working order is left to right! */
-X /* --------------------------------------------------------------*/
-X
-X for (i = 1, s = 0; i < argc; i++) {
-X k = strlen(argv[i]);
-X switch (*argv[i]) {
-X
-X /* ----> handle the options */
-X
-X case '-':
-X n = 1;
-X switch (*(argv[i]+n)) {
-X case 'n':
-X if (k > 2) {
-X fprintf(stderr,"%s: (E) invalid specification %s\n",
-X sCom_Sto->called_as,argv[i]);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X break;
-X }
-X def_flag = 1;
-X break;
-X case 'x':
-X if (k > 2) {
-X fprintf(stderr,"%s: (E) invalid specification %s\n",
-X sCom_Sto->called_as,argv[i]);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X break;
-X }
-X if (def_flag) {
-X fprintf(stderr,"%s: (W) -x after -n has no effect\n",
-X sCom_Sto->called_as);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X }
-X else {
-X poll_file = 0;
-X }
-X break;
-X case 'g':
-X if (k > 3) {
-X fprintf(stderr,"%s: (E) invalid specification %s\n",
-X sCom_Sto->called_as,argv[i]);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X break;
-X }
-X if (*(argv[i]+n+1) == '\0') {
-X fprintf(stderr,"%s: (E) missing grade\n",
-X sCom_Sto->called_as);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X break;
-X }
-X if (isalnum(*(argv[i]+n+1)) == 0) {
-X fprintf(stderr,"%s: (E) invalid grade %s\n",
-X sCom_Sto->called_as,argv[i]);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X break;
-X }
-X strcpy(sCom_Sto->Grade,(argv[i]+n+1));
-X break;
-X default:
-X fprintf(stderr,"%s: (W) missing/unknown option `-%s' ignored\n",
-X sCom_Sto->called_as,argv[i]+n);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X break;
-X } /* end of switch (*(argv[i]+n)) */
-X break;
-X
-X /* ----> handle the sitenames */
-X
-X default:
-X if (strcmp(argv[i],sCom_Sto->This_Site) == 0) {
-X fprintf(stderr,"%s: (W) ignoring to call *ourself* %s\n",
-X sCom_Sto->called_as,argv[i]);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X break;
-X }
-X strcpy(sCom_Sto->System,argv[i]);
-X for(s=0;s<=sCom_Sto->maxtab;s++) {
-X if ((n=strcmp(sCom_Sto->Sitetab[s].name,sCom_Sto->System)) >= 0) {
-X break;
-X }
-X }
-X if (n != 0) {
-X fprintf(stderr,"%s: (W) unknown site (ignored): %s\n",
-X sCom_Sto->called_as,sCom_Sto->System);
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X break;
-X }
-X
-X /* ----> if there was no error we arrive here to save the data */
-X
-X strcpy(sCom_Sto->Sitetab[s].grade,sCom_Sto->Grade);
-X One_Site = sCom_Sto->Sitetab[s].flag = 1; /* poll this site */
-X if (def_flag)
-X sCom_Sto->Sitetab[s].asap = 0; /* poll on next schedule */
-X else {
-X sCom_Sto->Sitetab[s].asap = 1; /* poll immediately */
-X if (! poll_file)
-X sCom_Sto->Sitetab[s].asap++; /* and do not place a poll file */
-X }
-X s++;
-X break;
-X } /* end of switch (*argv[i]) */
-X } /* end of for(...) */
-X
-/* now let's check what we've gotten so far. If no valid data has been */
-/* entered we will indicate that to prevent further processing */
-X
-X if (! One_Site) {
-X fprintf(stderr,"%s: (E) found no site to call\n",
-X sCom_Sto->called_as);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X
-return (Rc);
-}
-X
-int Call_Site(struct Common_Stor *sCom_Sto) {
-X
-/* For all sites that carry the -n flag we will place */
-/* a poll file into the appropriate directory. For all others there will */
-/* be an immediate call to uucico (or autopoll) */
-/* Those sites that have been named on the command have the corresponding */
-/* flag byte set to one. */
-X
-X int fdpoll; /* fildes for the poll file */
-X int mode = P_MODE; /* mode for poll file */
-X int i = 0;
-X int Rc = OK;
-X int pid = 0; /* process-id after fork() */
-X
-X for(i=0;(i<=sCom_Sto->maxtab);i++) {
-X if (sCom_Sto->Sitetab[i].flag == 0) /* should we trigger this one ? */
-X continue; /* nope */
-X
-/* processing done for delayed polls only */
-X
-X if (sCom_Sto->Sitetab[i].asap <= 1) { /* do not place a poll file */
-X /* for sites that will be polled */
-X /* immediate and carry the -x option */
-#ifdef HAVE_SPOOLDIR_TAYLOR
-X sprintf(sCom_Sto->workf,"%s/%s/C./C.%sPOLL",
-X SPOOL_DIR,
-X sCom_Sto->Sitetab[i].name,
-X sCom_Sto->Sitetab[i].grade);
-#endif
-#ifdef HAVE_SPOOLDIR_HDB
-X sprintf(sCom_Sto->workf,"%s/%s/C.%s%sPOLL",
-X SPOOL_DIR,
-X sCom_Sto->Sitetab[i].name,
-X sCom_Sto->Sitetab[i].name,
-X sCom_Sto->Sitetab[i].grade);
-#endif
-#ifdef HAVE_SPOOLDIR_BSD
-X sprintf(sCom_Sto->workf,"%s/C./C.%s%sPOLL",
-X SPOOL_DIR,
-X sCom_Sto->Sitetab[i].name,
-X sCom_Sto->Sitetab[i].grade);
-#endif
-X
-X fflush(stderr);
-X if ((fdpoll=open(sCom_Sto->workf,O_CREAT,mode)) <= 0) {
-X fprintf(stderr,"%s: (E) couldn't place poll file for system: %s. Reason: %s\n",
-X sCom_Sto->called_as,
-X sCom_Sto->Sitetab[i].name,
-X strerror(errno));
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X else {
-X if (close(fdpoll) != 0) {
-X fprintf(stderr,"%s: (W) close failed for poll file; system: %s. Reason: %s\n",
-X sCom_Sto->called_as,
-X sCom_Sto->Sitetab[i].name,
-X strerror(errno));
-X Rc = Rc >= WARNING ? Rc:WARNING;
-X }
-X }
-X }
-X
-/* the following processing is done for immediate polls only
-X * there is no wait for the completion of the called program that actually
-X * calls the site
-X * */
-X
-X fflush(stderr);
-X if (Rc <= WARNING) {
-X fprintf(stderr,"%s: (I) site %s will be called %s\n",
-X sCom_Sto->called_as,
-X sCom_Sto->Sitetab[i].name,
-X sCom_Sto->Sitetab[i].asap == 0 ?
-X "upon next poll":"immediately");
-X if (sCom_Sto->Sitetab[i].asap >= 1)
-X {
-#ifdef AUTO_DIR
-X if ( access(Auto_Dir,X_OK) != 0) /* do we have xecute permission ? */
-#else /* ! AUTO_DIR */
-X if ( access(Cico_Dir,X_OK) != 0) /* do we have xecute permission ? */
-#endif /* AUTO_DIR */
-X {
-X fprintf(stderr,"%s: (C) could not start %s. Reason-code: %i (%s)\n",
-X sCom_Sto->called_as,
-X sCom_Sto->Uucico,
-X errno,strerror(errno));
-X return (Rc >= CAT ? Rc:CAT); /* abandon the run */
-X }
-X switch (pid = fork())
-X {
-X case -1:
-X fprintf(stderr,"%s: (C) could not fork() Reason-code: %i (%s)\n",
-X sCom_Sto->called_as,
-X errno,strerror(errno));
-X return (Rc >= CAT ? Rc:CAT);
-X case 0:
-X if (isatty(0))
-X close(0); /* don't block the terminal by autopoll */
-#ifdef AUTO_DIR
-X execlp(Auto_Dir,
-#else /* ! AUTO_DIR */
-X execlp(Cico_Dir,
-#endif /*AUTO_DIR */
-X sCom_Sto->Uucico,
-X "-D", "-r1", "-s",
-X sCom_Sto->Sitetab[i].name,0);
-X fprintf(stderr,"%s: (C) could not start %s. Reason-code: %i (%s)\n",
-X sCom_Sto->called_as,
-X sCom_Sto->Uucico,
-X errno,strerror(errno));
-X _exit (CAT); /* child: bail out */
-X default:
-X fflush(stderr);
-X fprintf(stderr,"%s: (I) %s [%d] started; site: %s\n",
-X sCom_Sto->called_as,
-X sCom_Sto->Uucico,
-X pid,
-X sCom_Sto->Sitetab[i].name);
-X } /* switch (pid = fork()) */
-X } /* if (Sitetab ...) */
-X } /* if (Rc ...) */
-X } /* for(i=0;(i<= ...)) */
-X return (Rc);
-}
-X
-X /* ------------------------------------------------------------------
-X * storage - get some memory
-X */
-X
-void *storage(unsigned count,
-X char *location,
-X int *Rc,
-X struct Common_Stor *sCom_Sto)
-{
-X void *p;
-X
-X if( NULL == (p= malloc(count)) ) {
-X fprintf(stderr,"%s: (C) malloc failed (%s). Reason: %i (%s)\n",
-X sCom_Sto->called_as,location,errno,strerror(errno));
-X *Rc = *Rc >= CAT ? *Rc:CAT;
-X }
-X return p;
-}
-X
-/* ------------------------------------------------------------------
-X * if defined open the message log file otherwise all mesages will go
-X * to stderr. If UNAME_DIR is defined construct the command to be
-X * passed to popen(); if undefined the default will be used
-X * */
-X
-int set_mlog(FILE **seclog, struct Common_Stor *sCom_Sto) {
-X
-X int Rc = 0;
-X
-#ifdef ALOG_FILE
-X if (!isatty(0)) {
-X if ((freopen(Msg_Log,"a",stderr)) == NULL) {
-X fprintf(stdout,"%s: (C) Could not open msglog: %s\n",
-X sCom_Sto->called_as,Msg_Log);
-X return (Rc >= CAT ? Rc:CAT);
-X }
-X }
-X else {
-X if ((*seclog = fopen(Msg_Log,"a")) == NULL) {
-X fprintf(stderr,"%s: (C) Could not open msglog: %s\n",
-X sCom_Sto->called_as,Msg_Log);
-X return (Rc >= CAT ? Rc:CAT);
-X }
-X }
-#endif /* ALOG_FILE */
-X
-/* set up the pipe together with the complete path to uuname */
-X
-#ifdef UNAME_DIR
-X if ((sCom_Sto->Usort = (char *)storage (sizeof(UNAME_DIR)+sizeof(subcmd),
-X "Sort",&Rc, sCom_Sto)) != NULL) {
-X strncpy(sCom_Sto->Usort,UNAME_DIR,strlen(UNAME_DIR)); /* paste in the path */
-X strcat(sCom_Sto->Usort,subcmd); /* chain the pipe to it */
-X }
-#else /* ! UNAME_DIR */
-X sCom_Sto->Usort = &Sort; /* set pointer to uuname + sort */
-#endif /* UNAME_DIR */
-X
-X return (Rc);
-}
-X
-/* ------------------------------------------------------------------
-X * obtain all active sitenames
-X * */
-X
-int get_sites(struct Common_Stor *sCom_Sto) {
-X
-X int i = 0;
-X int n;
-X int Rc = 0;
-X FILE *infile;
-X
-X if ((infile=popen(sCom_Sto->Usort,"r")) != NULL) {
-X while(fgets(sCom_Sto->Sitetab[i].name,MAXHOSTNAMELEN+1,infile)) {
-X if (i > SITE_MAX) { /* let'm run so that we can give */
-X i++; /* the user some guidance */
-X continue; /* we'll tell the user later on */
-X }
-X n = strlen(sCom_Sto->Sitetab[i].name)-1; /* offset: next to last char */
-X sCom_Sto->Sitetab[i].name[n] = '\0'; /* strip trailing newline */
-X sCom_Sto->Sitetab[i].flag = FALSE; /* TRUE: poll this site */
-X sCom_Sto->Sitetab[i].asap = FALSE; /* TRUE: immediate poll */
-X strcpy(sCom_Sto->Sitetab[i].grade,sCom_Sto->Grade);
-X sprintf(sCom_Sto->workf,"%s%s",STATUS_DIR,sCom_Sto->Sitetab[i].name);
-X sCom_Sto->maxtab = i++; /* set high-water-mark */
-X }
-X if (ferror(infile) != 0) {
-X fprintf(stderr,"%s: (E) fgets() for sitenames failed reason-code: %i (%s)\n",
-X sCom_Sto->called_as,errno,strerror(errno));
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X pclose(infile);
-X
-X /*
-X * check for an empty table (strange but possible)
-X */
-X
-X if (sCom_Sto->maxtab == 0) {
-X fprintf(stderr,"%s: (E) could not obtain sitenames.\n",
-X sCom_Sto->called_as);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X else {
-X
-X /* in case the internal table overflows we'll now give notice and tell
-X * the user by which amount the table has to be increased to hold all
-X * site-names
-X */
-X
-X if (i > SITE_MAX) {
-X fprintf(stderr,"%s: (E) number of sites > internal tab\n",
-X sCom_Sto->called_as);
-X fprintf(stderr,"%s: (E) increase SITE_MAX to >= %d and recompile\n",
-X sCom_Sto->called_as,i);
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X }
-X } /* sCom_Sto->maxtab == 0 */
-X
-X }
-X else /* infile == NULL */
-X {
-X fprintf(stderr,"%s: (E) could not sort sitenames. Reason-code: %i (%s)\n",
-X sCom_Sto->called_as,errno,strerror(errno));
-X Rc = Rc >= SEVERE ? Rc:SEVERE;
-X
-X } /* if ((infile=popen(sCom_Sto->Usort,"r")) ... */
-X
-X return (Rc);
-}
-SHAR_EOF
-chmod 0444 uupoll/uupoll.c ||
-echo 'restore of uupoll/uupoll.c failed'
-Wc_c="`wc -c < 'uupoll/uupoll.c'`"
-test 27587 -eq "$Wc_c" ||
- echo 'uupoll/uupoll.c: original size 27587, current size' "$Wc_c"
-fi
-exit 0
diff --git a/gnu/libexec/uucp/contrib/uuq.sh b/gnu/libexec/uucp/contrib/uuq.sh
deleted file mode 100755
index a5d88e9..0000000
--- a/gnu/libexec/uucp/contrib/uuq.sh
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/bin/sh
-#
-# uuq - a script to examine and display the Taylor spool directory contents.
-# note - uses the uuname script or similar functionality.
-# Zacharias Beckman
-
-SPOOLDIR="/usr/spool/uucp"
-SYSTEMS=`uuname`
-TMPFILE="/tmp/uuq.tmp"
-FORSYSTEM=""
-DELETE=""
-LONG=0
-SINGLE=0
-
-while [ "$1" != "" ]
-do
- case $1 in
- -l) LONG=1
- shift
- ;;
- -s) shift
- SYSTEMS=$argv[1]
- SINGLE=1
- shift
- ;;
- -d) shift
- DELETE=$argv[1]
- shift
- ;;
- -h) echo "uuq: usage uuq [options]"
- echo " -l long listing (may take a while)"
- echo " -s n run uuq only for system n"
- echo " -d n delete item n from the queue (required -s)"
- exit 1
- ;;
- *) echo "uuq: invalid option"
- exit 1
- ;;
- esac
-done
-
-if [ "${DELETE}" != "" ] && [ ${SINGLE} != 1 ] ; then
- echo "uuq: you must specify a system to delete the job from:"
- echo " uuq -s wizard -d D.0004"
- exit 1
-fi
-
-cd ${SPOOLDIR}
-
-# if we are deleting a job, then do that first and exit without showing
-# any other queue information
-
-if [ "${DELETE}" != "" ] ; then
- if [ -d ${SYSTEMS}/D. ] ; then
- cd ${SYSTEMS}/C.
- PACKET=${DELETE}
- if [ -f ${PACKET} ] ; then
- EXFILE=../D.X/`awk '{if (NR == 2) print $2}' ${PACKET}`
- DFILE=../D./`awk '{if (NR == 1) print $2}' ${PACKET}`
- echo "deleting job ${PACKET}"
- rm ${PACKET}
- rm ${EXFILE}
- rm ${DFILE}
- else
- echo "uuq: job ${PACKET} not found"
- exit 1
- fi
- else
- echo "uuq: system ${SYSTEMS} not found"
- fi
-
- exit 1
-fi
-
-# use the 'uuname' script to obtain a list of systems for the 'sys' file,
-# then step through each directory looking for appropriate information.
-
-if [ ${LONG} -gt 0 ] ; then
- echo "system"
- echo -n "job# act size command"
-fi
-
-for DESTSYSTEM in ${SYSTEMS} ; do
- # if there is an existing directory for the named system, cd into it and
- # "do the right thing."
-
- if [ -d ${DESTSYSTEM} ] ; then
- cd ${DESTSYSTEM}/C.
-
- PACKET=`ls`
-
- if [ "${PACKET}" != "" ] ; then
- # if a long listing has been required, extra information is printed
-
- echo ""
- echo "${DESTSYSTEM}:"
-
- # now each packet must be examined and appropriate information is
- # printed for this system
-
- if [ ${LONG} -gt 0 ] ; then
- for PACKET in * ; do
- EXFILE=../D.X/`awk '{if (NR == 2) print $2}' ${PACKET}`
- DFILE=../D./`awk '{if (NR == 1) print $2}' ${PACKET}`
- echo -n "${PACKET} " > ${TMPFILE}
- gawk '{if (NR == 2) printf(" %s ", $1);}' ${PACKET} >> ${TMPFILE}
- ls -l ${DFILE}|awk '{printf("%-10d ", $4)}' >> ${TMPFILE}
- if [ -f ${EXFILE} ] ; then
- gawk '/U / {printf("(%s)", $2);}\
- /C / {print substr($0,2,length($0));}' ${EXFILE} >> ${TMPFILE}
- else
- echo "---" >> ${TMPFILE}
- fi
-
- cat ${TMPFILE}
- done
- cat ${SPOOLDIR}/.Status/${DESTSYSTEM}
- else
- ls
- fi
- fi
- fi
-
- cd ${SPOOLDIR}
-done
diff --git a/gnu/libexec/uucp/contrib/uurate.c b/gnu/libexec/uucp/contrib/uurate.c
deleted file mode 100644
index 3bcc565..0000000
--- a/gnu/libexec/uucp/contrib/uurate.c
+++ /dev/null
@@ -1,1854 +0,0 @@
-/*
- * @(#)uurate.c 1.2 - Thu Sep 3 18:32:46 1992
- *
- * This program digests log and stats files in the "Taylor" format
- * and outputs various statistical data to standard out.
- *
- * Author:
- * Bob Denny (denny@alisa.com)
- * Fri Feb 7 13:38:36 1992
- *
- * Original author:
- * Mark Pizzolato mark@infopiz.UUCP
- *
- * Edits:
- * Bob Denny - Fri Feb 7 15:04:54 1992
- * Heavy rework for Taylor UUCP. This was the (very old) uurate from
- * DECUS UUCP, which had a single logfile for activity and stats.
- * Personally, I would have done things differently, with tables
- * and case statements, but in the interest of time, I preserved
- * Mark Pizzolato's techniques and style.
- *
- * Bob Denny - Sun Aug 30 14:18:50 1992
- * Changes to report format suggested by Francois Pinard and others.
- * Add summary report, format from uutraf.pl (perl script), again
- * thanks to Francois. Integrate and checkout with 1.03 of Taylor UUCP.
- *
- * Stephan Niemz <stephan@sunlab.ka.sub.org> - Fri Apr 9 1993
- * - Print totals in summary report,
- * - show all commands in execution report,
- * - count incoming calls correctly,
- * - suppress empty tables,
- * - don't divide by zero in efficiency report,
- * - limit the efficiency to 100% (could be more with the i-protocol),
- * - suppress some zeros to improve readability,
- * - check for failure of calloc,
- * - -h option changed to -s for consistency with all other uucp commands
- * (but -h was left in for comptibility).
- *
- * Scott Boyd <scott@futures.com> - Thu Aug 26 13:21:34 PDT 1993
- * - Changed hosts linked-list insertion routine so that hosts
- * are always listed in alphabetical order on reports.
- *
- * Klaus Dahlenburg <kdburg@incoahe.hanse.de> - Fri Jun 18 1993 (1.2.2)
- * - redesigned the printed layout (sticked to those 80 column tubes).
- * - 'Retry time not ...' and ' ERROR: All matching ports ...' will now be
- * counted as calls and will raise the failed-call counter.
- * - times now shown as hh:mm:ss; the fields may hold up to 999 hrs
- * (a month equals 744 hrs at max). Printing will be as follows:
- *
- * hrs > 0 hh:mm:ss
- * min > 0 mm:ss
- * sec > 0 ss
- * leading zeroes are suppressed.
- *
- * - the bytes xfered will be given in thousands only (we're counting
- * so 1K is 1000 bytes!). Sums up to 9,999,999.9 thousand can be shown.
- * - dropped the fractions of a byte in columns: bytes/second (avg cps).
- * - File statistic changed to display in/out in one row instead of 2
- * separate reports.
- * - eliminated the goto in command report and tightened the code; also
- * the 'goto usage' has been replaced by a call to void usage() with no
- * return (exit 1).
- * - a totaling is done for all reports now; the total values are held
- * within the structure; after finishing read there will be an alloc
- * for a site named 'Total' so that the totals line will be printed
- * more or less automatically.
- * - option -t implemented: that is every possible report will be given.
- * - the start and end date/time of the input files are printed; can be
- * dropped by the -q option at run time.
- * - it is now possible to use Log/Stats files from V2_LOGGING configs.
- * They must however not be mixed together (with each other).
- * - the Log/Stats files are taken from config which is passed via
- * Makefile at compile time. Variable to set is: newconfigdir. If the
- * default config can't be read the default values are used
- * (the config is optional!).
- * Note: keyword/filename must be on the same line (no continuation).
- * - -I option implemented to run with a different config file. In case
- * the file can't be opened the run is aborted!
- * - -q option implemented to run without environment report (default is
- * FALSE: print the report).
- * - -p option added to print protocol statistics: one for the packets
- * and one for the errors encountered
- * - reapplied patch by Scott Boyd <scott@futures.com> that I did not
- * get knowledge of
- */
-/* Log: uurate.c,v
- * Revision 1.15 1994/04/07 21:47:11 kdburg
- * printed 'no data avail' while there was data; layout chnaged
- * (cosmetic only)
- *
- * Revision 1.14 1994/04/07 21:16:32 kdburg
- * the layout of the protocol-used line within the LOGFILE changed
- * from 1.04 to 1.05; both formats may be used together; output
- * changed for packet report (columns adjusted)
- *
- * Revision 1.13 1994/04/04 10:04:35 kdburg
- * cosmetic change to the packet-report (separator lines)
- *
- * Revision 1.12 1994/03/30 19:52:04 kdburg
- * incorporated patch by Scott Boyd which was missing from this version
- * of uurate.c. Left the comment in cronological order.
- *
- * Revision 1.11 1994/03/28 18:53:22 kdburg
- * config not checked properly for 'logfile/statsfile' overwrites, bail-out
- * possible; wrong file name written to log for statsfile when found
- *
- * Revision 1.10 1993/09/28 16:46:51 kdburg
- * transmission failures denoted by: failed after ... in stats file
- * have not been counted at all.
- *
- * Revision 1.9 1993/08/17 23:38:36 kdburg
- * sometimes a line(site) was missing from the protocol stats due
- * to a missing +; added option -d and -v reassing option -h to print
- * the help; a zero was returned instead of a null-pointer by
- * prot_sum
- *
- * Revision 1.8 1993/07/03 06:58:55 kdburg
- * empty input not handled properly; assigned some buffer to input; msg
- * not displayed when no protocol data was available
- *
- * Revision 1.7 1993/06/27 10:31:53 kdburg
- * rindex was replaced by strchr must be strrchr
- *
- * Revision 1.6 1993/06/26 06:59:18 kdburg
- * switch hdr_done not reset at beginning of protocol report
- *
- * Revision 1.5 1993/06/25 22:22:30 kdburg
- * changed rindex to strchr; if there is no NEWCONFIG defined take
- * appropriate action
- *
- * Revision 1.4 1993/06/25 20:04:07 kdburg
- * added comment about -p option; inserted proto for rindex
- *
- * Revision 1.3 1993/06/25 19:31:14 kdburg
- * major rework done; added protocol reports (normal/errors)
- *
- * Revision 1.2 1993/06/21 19:53:54 kdburg
- * init
- * */
-
-char version[] = "@(#) Taylor UUCP Log File Summary Filter, Version 1.2.2";
-static char rcsid[] = "$Id: uurate.c,v 1.6 1997/02/22 15:27:02 peter Exp $";
-#include <ctype.h> /* Character Classification */
-#include <math.h>
-#include "uucp.h"
-/* uucp.h includes string.h or strings.h, no include here. */
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#define _DEBUG_ 0
-
-/*
- * Direction of Calling and Data Transmission
- */
-
-#define IN 0 /* Inbound */
-#define OUT 1 /* Outbound */
-
-/*
- * define some limits
- */
-#define MAXCOLS 8 /* report has this # of columns incl. 'name' */
-#define MAXREP 6 /* number of reports available */
-#define MAXFNAME 64 /* max input file name length incl. path*/
-#define MAXDNAME 8 /* max display (Hostname) name length */
-
-/*
- * Data structures used to collect information
- */
-struct File_Stats
- {
- int files; /* Files Transferred */
- unsigned long bytes; /* Data Size Transferred*/
- double time; /* Transmission Time */
- };
-
-struct Phone_Call
- {
- int calls; /* Call Count */
- int succs; /* Successful calls */
- double connect_time; /* Connect Time Spent */
- struct File_Stats flow[2]; /* Rcvd & Sent Data */
- };
-
-struct Execution_Command
- {
- struct Execution_Command *next;
- char Commandname[64];
- int count;
- };
-
-struct Protocol_Summary
- {
- struct Protocol_Summary *next;
- char type[3];
- long int pr_cnt;
- long int pr_psent;
- long int pr_present;
- long int pr_preceived;
- long int pr_eheader;
- long int pr_echksum;
- long int pr_eorder;
- long int pr_ereject;
- long int pr_pwinmin;
- long int pr_pwinmax;
- long int pr_psizemin;
- long int pr_psizemax;
- };
-
-struct Host_entry
- {
- struct Host_entry *next;
- char Hostname[32];
- struct Execution_Command *cmds; /* Local Activities */
- struct Phone_Call call[2]; /* In & Out Activities */
- struct Protocol_Summary *proto;
- };
-
- struct Host_entry *hosts = NULL;
- struct Host_entry *tot = NULL;
- struct Host_entry *cur = NULL;
- struct Execution_Command *cmd, *t_cmds = NULL;
- struct Protocol_Summary *prot, *t_prot, *s_prot, *ss_prot = NULL;
-/*
- * Stuff for getopt()
- */
-
-extern int optind; /* GETOPT : Option Index */
-extern char *optarg; /* GETOPT : Option Value */
-#if ! HAVE_STDLIB_H
- extern pointer *calloc();
-#endif /* HAVE_STDLIB_H */
-/*
- * Default files to read. Taken from Taylor compile-time configuration.
- * def_logs must look like an argvec, hence the dummy argv[0].
- * Maybe later modified by scanning the config
- */
-
-static char *def_logs[3] = { NULL, NULL, NULL};
-char *I_conf = NULL; /* points to config lib given by -I option */
-char *D_conf = NULL; /* points to config lib from makefile */
-char *Tlog = NULL; /* points to Log-file */
-char *Tstat = NULL; /* points to Stats-file */
-char Pgm_name[64]; /* our pgm-name */
-char logline[BUFSIZ+1]; /* input area */
-char noConf[] = "- not defined -";
-char buff[16*BUFSIZ];
-char sbuff[2*BUFSIZ];
-
-/*
- * Boolean switches for various decisions
- */
-
- int p_done = FALSE; /* TRUE: start date/time of file printed */
- int hdr_done = FALSE; /* TRUE: report header printed */
- int show_files = FALSE; /* TRUE: -f option given */
- int show_calls = FALSE; /* TRUE: -c option given */
- int show_commands = FALSE; /* TRUE: -x option given */
- int show_efficiency = FALSE; /* TRUE: -e option given */
- int show_all = FALSE; /* TRUE: -t option given */
- int show_proto = FALSE; /* TRUE: -p option given */
- int use_stdin = FALSE; /* TRUE: -i option given */
- int be_quiet = FALSE; /* TRUE: -q option given */
- int have_files[2]; /* TRUE: [IN] or [OUT] files found */
- int have_calls = FALSE; /* TRUE: in/out calls found */
- int have_commands = FALSE; /* TRUE: found uuxqt records */
- int have_proto = FALSE; /* TRUE: protocol data found */
- int no_records = TRUE; /* FALSE: got one record from file */
-
-/*
- * protos
- */
-
-static pointer *getmem(unsigned n);
-static void inc_cmd(struct Execution_Command **, char *name);
-static void fmtime(double sec, char *buf);
-static void fmbytes(unsigned long n, char *buf);
-static void usage();
-static int chk_config(char *conf, int n, int type);
-static void hdrprt(char c, int bot);
-struct Protocol_Summary *prot_sum(struct Protocol_Summary **, char *, int);
-
-/*
- * BEGIN EXECUTION
- */
-
-int main(argc, argv)
- int argc;
- char *argv[];
-{
- FILE *Log = NULL;
- int c;
- char *p, *s, *stt, *flq = NULL;
- char Hostname[MAXHOSTNAMELEN]; /* def taken from <sys/param.h> */
- char Filename[15]; /* filename to be printed */
- char in_date[14]; /* holds the date info of record read*/
- char in_time[14]; /* holds the time info of record read */
- char dt_info[31]; /* holds the date info from the last record read */
- char *logmsg;
- int sent, called = IN;
- int report = 0; /* if <= 0 give msg that no report was avail. */
- int junk;
-
- /* --------------------------------------------------------------------
- * P r o l o g
- * --------------------------------------------------------------------
- */
-
- Hostname[0] = '\0';
- have_files[IN]= have_files[OUT]= FALSE;
- setvbuf(stdout,sbuff,_IOFBF,sizeof(sbuff));
-
- /*
- * get how we've been called isolate the name from the path
- */
-
- if ((stt = strrchr(argv[0],'/')) != NULL)
- strcpy(Pgm_name,++stt);
- else
- strcpy(Pgm_name,argv[0]);
- def_logs[0] = Pgm_name;
-
- /*
- * I wish the compiler had the #error directive!
- */
-
-#if !HAVE_TAYLOR_LOGGING && !HAVE_V2_LOGGING
- fprintf(stderr,"\a%s: (E) %s\n",Pgm_name,"Your config of Taylor UUCP is not yet supported.");
- fprintf(stderr,"%s: (E) %s\n",Pgm_name,"Current support is for V2 or TAYLOR logging only.");
- puts(" Run aborted due to errors\n")
- exit(1);
-#endif
-
- /*
- * get some mem to store the default config name (def's are in
- * policy.h )
- */
-
- if (sizeof(NEWCONFIGLIB) > 1) /* defined at compile time */
- {
- D_conf = (char *)getmem((sizeof(NEWCONFIGLIB) + sizeof("/config")));
- strcpy(D_conf,NEWCONFIGLIB); /* passed by makefile */
- strcat(D_conf,"/config");
- }
- Tlog = (char *)getmem(sizeof(LOGFILE));
- Tstat = (char *)getmem(sizeof(STATFILE));
- Tlog = LOGFILE;
- Tstat = STATFILE;
-
- /*
- * Process the command line arguments
- */
-
- while((c = getopt(argc, argv, "I:s:cfdexaitphv")) != EOF)
- {
- switch(c)
- {
- case 'h':
- (void) usage();
- case 's':
- strcpy(Hostname, optarg);
- break;
- case 'c':
- show_calls = TRUE;
- ++report;
- break;
- case 'd':
- printf("%s: (I) config-file default: %s\n",Pgm_name,D_conf);
- exit (0);
- break;
- case 'f':
- show_files = TRUE;
- ++report;
- break;
- case 'x':
- show_commands = TRUE;
- ++report;
- break;
- case 'e':
- show_efficiency = TRUE;
- ++report;
- break;
- case 'a':
- show_calls = show_files = show_commands = show_efficiency = TRUE;
- report = 4;
- break;
- case 'i':
- use_stdin = TRUE;
- break;
- case 't':
- show_all = TRUE;
- report = MAXREP;
- break;
- case 'p':
- show_proto = TRUE;
- ++report;
- break;
- case 'I':
- I_conf = (char *)getmem(sizeof(optarg));
- I_conf = optarg;
- break;
- case 'q':
- be_quiet = TRUE;
- break;
- case 'v':
- printf("%s\n",rcsid);
- exit (0);
- default :
- (void) usage();
- }
- }
- if (report == 0) /* no options given */
- ++report; /* at least summary can be printed */
- if (! be_quiet)
- hdrprt('i',0); /* print header for environment info */
-
- /*
- * Adjust argv and argc to account for the args processed above.
- */
-
- argc -= (optind - 1);
- argv += (optind - 1);
-
- /*
- * If further args present, Assume rest are logfiles for us to process
- * which should be given in pairs (log plus stat) otherwise the results may
- * not come out as expected! If no further args are present take input from
- * Log and Stat files provided in the compilation environment of Taylor UUCP.
- * If -i was given, Log already points to stdin and no file args are accepted.
- */
-
- if (use_stdin) /* If -i, read from stdin */
- {
- if (argc != 1) /* No file arguments allowed */
- {
- fprintf(stderr,"\a%s: (E) %s\n",Pgm_name,
- "it's not posssible to give file args with '-i'");
- (void) usage();
- }
- else
- {
- argc = 2;
- Log = stdin;
- if (! be_quiet)
- puts(" Input from stdin; no other files will be used\n");
- }
- }
- else
- {
- if (argc != 1) /* file arguments are present */
- {
- if (! be_quiet)
- puts(" No defaults used; will use passed file arguments\n");
- }
- else /* Read from current logs */
- {
- def_logs[1] = Tlog; /* prime the */
- def_logs[2] = Tstat; /* file names */
- if (! be_quiet)
- printf(" Config for this run: ");
-
- if (I_conf != NULL)
- {
- junk = 0;
- if (! be_quiet)
- printf("%s\n",I_conf);
- if (0 != (chk_config(I_conf,be_quiet,junk)))
- return (8);
- }
- else
- {
- if (D_conf != NULL)
- {
- junk = 1; /* indicate default (compiled) config */
- if (! be_quiet)
- printf("%s\n",D_conf);
- chk_config(D_conf,be_quiet,junk);
- }
- else
- if (! be_quiet)
- printf("%s\n",noConf);
- }
- def_logs[1] = Tlog; /* final setting of */
- def_logs[2] = Tstat; /* file names */
- argv = def_logs; /* Bash argvec to log/stat files */
- argc = sizeof(def_logs) / sizeof(def_logs[0]);
- }
- }
-
- /* --------------------------------------------------------------------
- * MAIN LOGFILE PROCESSING LOOP
- * --------------------------------------------------------------------
- */
-
- if (!use_stdin)
- {
- if (argc < 3 && ! be_quiet)
- {
- puts(" (W) there is only one input file!");
- puts(" (W) some reports may not be printed");
- }
- if (! be_quiet)
- hdrprt('d',0); /* give subheaderline */
- }
-
- while (argc > 1)
- {
- if (!use_stdin && (Log = fopen(argv[1], "r")) == NULL)
- {
- perror(argv[1]);
- exit (8);
- }
- setvbuf(Log,buff,_IOFBF,sizeof(buff));
- if ((flq = strrchr(argv[1], '/')) == NULL)
- strncpy(Filename,argv[1],sizeof(Filename)-1);
- else
- strncpy(Filename,++flq,sizeof(Filename)-1);
-
- strcpy(in_date," n/a");
- strcpy(in_time," n/a");
- p_done = FALSE; /* no info printed yet */
- no_records = TRUE; /* not read any record yet */
-
- /*
- * Read each line of the logfile and collect information
- */
-
- while (fgets(logline, sizeof(logline), Log))
- {
- /*
- * The host name of the other end of the connection is
- * always the second field of the log line, whether we
- * are reading a Log file or a Stats file. Set 'p' to
- * point to the second field, null-terminated. Skip
- * the line if something is funny. V2 and Taylor ar identical
- * up to this part. Put out the start/end date of the files read;
- */
-
- if (NULL == (p = strchr(logline, ' ')))
- continue;
- no_records = FALSE; /* got one (usable) record at least */
- ++p;
-
- if (NULL != (stt = strchr(p, '(')))
- {
- if (! p_done && ! use_stdin && ! be_quiet)
- {
-
-#if HAVE_TAYLOR_LOGGING
- sscanf(++stt,"%s%*c%[^.]",in_date,in_time);
-#endif /* HAVE_TAYLOR_LOGGING */
-
-#if HAVE_V2_LOGGING
- sscanf(++stt,"%[^-]%*c%[1234567890:]",in_date,in_time);
-#endif /* HAVE_V2_LOGGING */
-
- printf(" %-14s %10s %8s",Filename, in_date, in_time);
- strcpy(in_date," n/a"); /* reset to default */
- strcpy(in_time," n/a");
- p_done = TRUE;
- }
- else
- {
- if (! use_stdin && ! be_quiet) /* save for last time stamp prt. */
- strncpy(dt_info,++stt,sizeof(dt_info)-1);
- }
- }
-
- if (NULL != (s = strchr(p, ' ')))
- *s = '\0';
- for (s = p; *s; ++s)
- if (isupper(*s))
- *s = tolower(*s);
-
- /*
- * Skip this line if we got -s <host> and
- * this line does not contain that host name.
- * Don't skip the `incoming call' line with the system name `-'.
- */
-
- if (Hostname[0] != '\0')
- if ( (p[0] != '-' || p[1] != '\0') && 0 != strcmp(p, Hostname) )
- continue;
-
- /*
- * We are within a call block now. If this line is a file
- * transfer record, determine the direction. If not then
- * skip the line if it is not interesting.
- */
-
- if ((s = strchr(++s, ')')) == NULL)
- continue;
-
-#if ! HAVE_TAYLOR_LOGGING
-#if HAVE_V2_LOGGING
- if ((strncmp(s,") (",3)) == 0) /* are we in stats file ?) */
- if ((s = strchr(++s, ')')) == NULL)
- continue; /* yes but strange layout */
-#endif /* HAVE_V2_LOGGING */
-#endif /* ! HAVE_TAYLOR_LOGGING */
-
- logmsg = s + 2; /* Message is 2 characters after ')' */
- if ((0 != strncmp(logmsg, "Call complete", 13)) &&
- (0 != strncmp(logmsg, "Calling system", 14)) &&
- (0 != strncmp(logmsg, "Incoming call", 13)) &&
- (0 != strncmp(logmsg, "Handshake successful", 20)) &&
- (0 != strncmp(logmsg, "Retry time not", 14)) &&
- (0 != strncmp(logmsg, "ERROR: All matching ports", 25)) &&
- (0 != strncmp(logmsg, "Executing", 9)) &&
- (0 != strncmp(logmsg, "Protocol ", 9)) &&
- (0 != strncmp(logmsg, "sent ", 5)) &&
- (0 != strncmp(logmsg, "received ", 9)) &&
- (0 != strncmp(logmsg, "failed after ", 13)) &&
- (0 != strncmp(logmsg, "Errors: ", 8)))
- continue;
-
- /*
- * Find the Host_entry for this host, or create a new
- * one and link it on to the list.
- */
-
- if ((cur == NULL) || (0 != strcmp(p, cur->Hostname)))
- {
- struct Host_entry *e, *last;
-
- for (e= cur= hosts; cur != NULL ; e= cur, cur= cur->next)
- if (0 == strcmp(cur->Hostname, p))
- break;
- if (cur == NULL)
- {
- cur= (struct Host_entry *)getmem(sizeof(*hosts));
- strcpy(cur->Hostname, p);
- if (hosts == NULL)
- e= hosts= cur;
- else {
- e = hosts;
- last = NULL;
- while (e != NULL) {
- if (strcmp(e->Hostname, cur->Hostname) <= 0) {
- if (e->next == NULL) {
- e->next = cur;
- break;
- }
- last = e;
- e = e->next;
- }
- else {
- cur->next = e;
- if (last == NULL)
- hosts = cur;
- else
- last->next = cur;
- break;
- }
- } /* while (e != NULL) */
- } /* hosts == NULL */
- } /* cur == NULL */
- }
-
- /*
- * OK, if this is a uuxqt record, find the Execution_Command
- * structure for the command being executed, or create a new
- * one. Then count an execution of this command.
- * (Log file only)
- */
-
- if (0 == strncmp(logmsg, "Executing", 9))
- {
- if (NULL == (p = strchr(logmsg, '(')))
- continue;
- if ((s = strpbrk(++p, " )")) == NULL)
- continue;
- *s = '\0';
- inc_cmd(&cur->cmds, p);
- inc_cmd(&t_cmds, p);
- have_commands = TRUE;
- continue;
- }
-
- /*
- * Count start of outgoing call.
- */
-
- if ((0 == strncmp(logmsg, "Calling system", 14)) ||
- (0 == strncmp(logmsg, "Retry time not", 14)) ||
- (0 == strncmp(logmsg, "ERROR: All matching ports", 25)))
- {
- called = OUT;
- cur->call[OUT].calls++;
- have_calls = TRUE;
- s_prot = NULL; /* destroy pointer to protocol */
- continue;
- }
-
- /*
- * Count start of incoming call.
- */
-
- if (0 == strncmp(logmsg, "Incoming call", 13))
- {
- called = IN;
- s_prot = NULL; /* destroy pointer to protocol */
- continue;
- }
-
- /*
- * On an incoming call, get system name from the second line.
- * Get protocol type and size/window too
- */
-
- if (0 == strncmp(logmsg, "Handshake successful", 20))
- {
- if ( called==IN )
- cur->call[IN].calls++;
- have_calls = TRUE;
- s_prot = NULL; /* destroy pointer to protocol */
- if (NULL == (p = strchr(logmsg, '(')))
- continue;
- if (0 == strncmp(p, "(protocol ", 10))
- {
- if (NULL == (p = strchr(p, '\'')))
- continue;
- ss_prot = prot_sum(&cur->proto, ++p, 1);
- s_prot = prot_sum(&t_prot, p, 1);
- continue;
- }
- }
-
- /*
- * check protocol type and get stats
- *
- */
-
- if (0 == strncmp(logmsg, "Protocol ", 9))
- {
- s_prot = NULL; /* destroy pointer to protocol */
- if (NULL == (p = strchr(logmsg, '\'')))
- continue;
- ss_prot = prot_sum(&cur->proto, ++p, 2);
- s_prot = prot_sum(&t_prot, p, 2);
- continue;
- }
-
- /*
- * check protocol errors. Unfortunately the line does not contain
- * the used protocol, so if any previous line did contain that
- * information and we did process that line we will save the pointer
- * to that particular segment into s_prot. If this pointer is not set
- * the error info is lost for we don't know where to store.
- *
- */
-
- if ((0 == strncmp(logmsg, "Errors: header", 14)) && s_prot != NULL)
- {
- int i1,i2,i3,i4 = 0;
- sscanf(logmsg,"%*s %*s %d%*c%*s %d%*c%*s %d%*c%*s %*s%*c %d",&i1,&i2,&i3,&i4);
- ss_prot->pr_eheader += i1;
- ss_prot->pr_echksum += i2;
- ss_prot->pr_eorder += i3;
- ss_prot->pr_ereject += i4;
- s_prot->pr_eheader += i1;
- s_prot->pr_echksum += i2;
- s_prot->pr_eorder += i3;
- s_prot->pr_ereject += i4;
- s_prot = NULL;
- continue;
- }
-
- /*
- * Handle end of call. Pick up the connect time.
- * position is on the closing paren of date/time info
- * i.e: ) text....
- */
-
- if (0 == strncmp(logmsg, "Call complete", 13))
- {
- cur->call[called].succs++;
- s_prot = NULL; /* destroy pointer to protocol */
- if (NULL == (s = strchr(logmsg, '(')))
- continue;
- cur->call[called].connect_time += atof(s+1);
- continue;
- }
-
- /*
- * We are definitely in a Stats file now.
- * If we reached here, this must have been a file transfer
- * record. Count it in the field corresponding to the
- * direction of the transfer. Count bytes transferred and
- * the time to transfer as well.
- * Position within the record is at the word 'received' or 'sent'
- * depending on the direction.
- */
-
- sent = IN; /* give it an initial value */
- if (0 == strncmp(logmsg, "failed after ",13))
- logmsg += 13; /* the transmission failed for any reason */
- /* so advance pointer */
- if (0 == strncmp(logmsg, "sent", 4))
- sent = OUT;
- else if (0 == strncmp(logmsg, "received", 8))
- sent = IN;
- have_files[sent] = TRUE;
- cur->call[called].flow[sent].files++;
- if (NULL == (s = strchr(logmsg, ' '))) /* point past keyword */
- continue; /* nothing follows */
- /* we should be at the bytes column now*/
-#if HAVE_TAYLOR_LOGGING
- cur->call[called].flow[sent].bytes += atol(++s);
-#endif /* HAVE_TAYLOR_LOGGING */
-#if HAVE_V2_LOGGING
- if (NULL == (s = strpbrk(s, "0123456789"))) /* point to # bytes */
- continue;
- cur->call[called].flow[sent].bytes += atol(s);
-#endif /* HAVE_V2_LOGGING */
- if (NULL == (s = strchr(s, ' '))) /* point past # of bytes */
- continue;
- if (NULL == (s = strpbrk(s, "0123456789"))) /* point to # of seconds */
- continue;
- cur->call[called].flow[sent].time += atof(s);
-
- } /* end of while (fgets(logline...)) */
-
- if (stt != NULL && ! use_stdin && ! be_quiet && ! no_records)
- {
-
-#if HAVE_TAYLOR_LOGGING
- sscanf(dt_info,"%s%*c%[^.]",in_date,in_time);
-#endif /* HAVE_TAYLOR_LOGGING */
-
-#if HAVE_V2_LOGGING
- sscanf(dt_info,"%[^-]%*c%[1234567890:]",in_date,in_time);
-#endif /* HAVE_V2_LOGGING */
-
- printf(" %10s %8s\n",in_date, in_time);
- p_done = FALSE;
- }
- if (Log != stdin)
- {
- if (0 != ferror(Log))
- {
- if (! be_quiet)
- printf(" %-14s data is incomplete; read error"," ");
- else
- fprintf(stderr,"%s (W) data is incomplete; read error on %s\n",
- Pgm_name,argv[1]);
- }
- else
- {
- if (! be_quiet && no_records)
- printf(" %-14s %10s\n",Filename, " is empty ");
- }
- }
- fclose(Log);
-
- argc--;
- argv++;
- } /* end of while (for (argv ....) */
-
- /*
- * do we have *any* data ?
- */
-
- if (cur == NULL)
- {
- puts("\n(I) Sorry! No data is available for any requested report\n");
- exit(0);
- }
-
- /*
- * truncate hostname, alloc the structure holding the totals and
- * collect the totals data
- */
-
- for (cur = hosts; cur != NULL;cur = cur->next)
- {
- cur->Hostname[MAXDNAME] = '\0';
- if (cur->next == NULL) /* last so will have to alloc totals */
- {
- cur->next = (struct Host_entry *)getmem(sizeof(*hosts));
- strcpy(cur->next->Hostname,"Totals");
- tot = cur->next;
- for (cur = hosts; cur != NULL; cur = cur->next)
- {
- if (cur->next != NULL) /* don't count totals to totals */
- {
- tot->call[IN].flow[IN].bytes += cur->call[IN].flow[IN].bytes;
- tot->call[OUT].flow[IN].bytes += cur->call[OUT].flow[IN].bytes;
- tot->call[IN].flow[OUT].bytes += cur->call[IN].flow[OUT].bytes;
- tot->call[OUT].flow[OUT].bytes += cur->call[OUT].flow[OUT].bytes;
- tot->call[IN].flow[IN].time += cur->call[IN].flow[IN].time;
- tot->call[OUT].flow[IN].time += cur->call[OUT].flow[IN].time;
- tot->call[IN].flow[OUT].time += cur->call[IN].flow[OUT].time;
- tot->call[OUT].flow[OUT].time += cur->call[OUT].flow[OUT].time;
- tot->call[IN].flow[IN].files += cur->call[IN].flow[IN].files;
- tot->call[OUT].flow[IN].files += cur->call[OUT].flow[IN].files;
- tot->call[IN].flow[OUT].files += cur->call[IN].flow[OUT].files;
- tot->call[OUT].flow[OUT].files += cur->call[OUT].flow[OUT].files;
- tot->call[OUT].succs += cur->call[OUT].succs;
- tot->call[OUT].calls += cur->call[OUT].calls;
- tot->call[OUT].connect_time += cur->call[OUT].connect_time;
- tot->call[IN].succs += cur->call[IN].succs;
- tot->call[IN].calls += cur->call[IN].calls;
- tot->call[IN].connect_time += cur->call[IN].connect_time;
- }
- }
- break; /* totals is last in Host_Entry */
- }
- }
-
- /*
- * ***********
- * * REPORTS *
- * ***********
- */
-
-#if _DEBUG_
- putchar('\n');
-#endif
-
- /* ------------------------------------------------------------------
- *
- * Summary report only when no other report except option -t is given
- *
- * I know, this code could be tightened (rbd)...
- * ------------------------------------------------------------------
- */
-
- if ( !(show_calls || show_files ||
- show_efficiency || show_commands || show_proto) || show_all)
- {
- if (have_calls || have_files[IN] || have_files[OUT])
- {
- char t1[32], t2[32], t3[32], t4[32], t5[32];
- long ib, ob, b, rf, sf;
- double it, ot, ir, or;
-
- hdr_done = FALSE;
- for (cur = hosts; cur != NULL; cur = cur->next)
- {
- ib = (cur->call[IN].flow[IN].bytes +
- cur->call[OUT].flow[IN].bytes);
- fmbytes(ib, t1);
-
- ob = (cur->call[IN].flow[OUT].bytes +
- cur->call[OUT].flow[OUT].bytes);
- fmbytes(ob, t2);
-
- /* Don't print null-lines. */
- if (( b= ib+ob ) == 0 )
- continue;
- /* Don't print the header twice. */
- if (! hdr_done)
- {
- hdrprt('s',0); /* print the header line(s) */
- hdr_done = TRUE;
- }
-
- fmbytes(b, t3);
-
- it = cur->call[IN].flow[IN].time +
- cur->call[OUT].flow[IN].time;
- fmtime(it, t4);
-
- ot = cur->call[IN].flow[OUT].time +
- cur->call[OUT].flow[OUT].time;
- fmtime(ot, t5);
-
- rf = cur->call[IN].flow[IN].files +
- cur->call[OUT].flow[IN].files;
-
- sf = cur->call[IN].flow[OUT].files +
- cur->call[OUT].flow[OUT].files;
-
- ir = (it == 0.0) ? 0.0 : (ib / it);
- or = (ot == 0.0) ? 0.0 : (ob / ot);
-
- if (cur->next == NULL) /* totals line reached ? */
- hdrprt('s',1); /* print the separator line */
-
- printf("%-8s %4d %4d %9s %9s %9s %9s %9s %5.0f %5.0f\n",
- cur->Hostname, rf, sf,
- t1, t2, t3, t4, t5,
- ir, or);
- }
- if (! hdr_done)
- {
- puts("\n(I) No data found to print Compact summary report");
- }
- }
- else
- {
- puts("\n(I) No data available for Compact summary report");
- --report;
- }
- }
-
- /* ------------------------------------------------------------------
- * Protocol statistics report
- * ------------------------------------------------------------------
- */
-
- if (show_proto || show_all)
- {
- if (have_proto)
- {
- /* --------------------- */
- /* protocol packet report */
- /* --------------------- */
-
- char *type = NULL;
- hdr_done = FALSE;
- for (cur = hosts; cur != NULL; cur = cur->next)
- {
- type = cur->Hostname;
- if (cur->next == NULL)
- {
- if (hdr_done)
- puts("-------------------------------------------------------------------");
- cur->proto = t_prot;
- }
- for (prot = cur->proto; prot != NULL; prot = prot->next)
- {
- if (! hdr_done)
- {
- hdrprt('p',0); /* print the header line(s) */
- hdr_done = TRUE;
- }
- printf("%-8s %3s %4d %4d %5d %4d %10d %7d %10d\n",
- type == NULL ? " ":cur->Hostname,
- prot->type,
- prot->pr_psizemin,
- prot->pr_psizemax,
- prot->pr_pwinmin,
- prot->pr_pwinmax,
- prot->pr_psent,
- prot->pr_present,
- prot->pr_preceived);
- type = NULL;
- }
- }
- if (! hdr_done)
- puts("\n(I) No data found to print Protocol packet report");
-
- /* --------------------- */
- /* protocol error report */
- /* --------------------- */
-
- type = NULL;
- hdr_done = FALSE;
- if (t_prot != NULL)
- {
- for (cur = hosts; cur != NULL; cur = cur->next)
- {
- type = cur->Hostname;
- if (cur->next == NULL)
- {
- if (hdr_done)
- puts("--------------------------------------------------------------");
- cur->proto = t_prot;
- }
-
- for (prot = cur->proto; prot != NULL; prot = prot->next)
- {
- if ((prot->pr_eheader + prot->pr_echksum +
- prot->pr_eorder + prot->pr_ereject) != 0)
- {
- if (! hdr_done)
- {
- hdrprt('p',1); /* print the header line(s) */
- hdr_done = TRUE;
- }
- printf("%-8s %3s %11d %11d %11d %11d\n",
- type == NULL ? " ":cur->Hostname,
- prot->type,
- prot->pr_eheader,
- prot->pr_echksum,
- prot->pr_eorder,
- prot->pr_ereject);
- type = NULL;
- }
- }
- }
- }
- if (! hdr_done)
- puts("\n(I) No data found to print Protocol error report");
- }
- else
- {
- puts("\n(I) No data available for Protocol reports");
- --report;
- }
- }
-
- /* ------------------------------------------------------------------
- * Call statistics report
- * ------------------------------------------------------------------
- */
-
- if (show_calls || show_all)
- {
- if (have_calls)
- {
- char t1[32], t2[32];
-
- hdr_done = FALSE;
- for (cur = hosts; cur != NULL; cur = cur->next)
- {
- if (cur->next == NULL)
- {
- if (hdr_done)
- hdrprt('c',1); /* print the separator line */
- }
- else
- {
- /* Don't print null-lines on deatail lines */
- if ( cur->call[OUT].calls + cur->call[IN].calls == 0 )
- continue;
-
- /* Don't print the header twice. */
- if (! hdr_done)
- {
- hdrprt('c',0); /* print the header line(s) */
- hdr_done = TRUE;
- }
- }
- if ( cur->call[OUT].calls > 0 || cur->next == NULL)
- {
- fmtime(cur->call[OUT].connect_time, t1);
- printf( " %-8s %7d %7d %7d %9s",
- cur->Hostname,
- cur->call[OUT].succs,
- cur->call[OUT].calls - cur->call[OUT].succs,
- cur->call[OUT].calls,
- t1 );
- }
- else
- {
- printf( " %-42s", cur->Hostname );
- }
- if ( cur->call[IN].calls > 0 || cur->next == NULL )
- {
- fmtime(cur->call[IN].connect_time, t2);
- printf( " %7d %7d %7d %9s",
- cur->call[IN].succs,
- cur->call[IN].calls - cur->call[IN].succs,
- cur->call[IN].calls,
- t2 );
- }
- putchar('\n');
- }
- if (! hdr_done)
- {
- puts("\n(I) No data found to print Call statistics report");
- }
- }
- else
- {
- puts("\n(I) No data available for Call statistics report");
- --report;
- }
- }
-
- /* ------------------------------------------------------------------
- * File statistics report
- * ------------------------------------------------------------------
- */
-
- if (show_files || show_all)
- {
- if (have_files[IN] || have_files[OUT])
- {
- char t1[32], t2[32];
- double rate = 0, time = 0;
- int b = 0;
- int lineOut = 0;
-
- hdr_done = FALSE;
- for (cur = hosts; cur != NULL; cur = cur->next)
- {
- lineOut = 0;
- for (sent= IN; sent <= OUT; ++sent)
- {
- b = cur->call[IN].flow[sent].bytes +
- cur->call[OUT].flow[sent].bytes;
- time = cur->call[IN].flow[sent].time +
- cur->call[OUT].flow[sent].time;
-
- /* Don't print null-lines on detail lines. */
- if ( (b != 0 && time != 0.0) || cur->next == NULL)
- {
- /* Don't print the header twice. */
- if (! hdr_done)
- {
- hdrprt('f',0); /* print the header line(s) */
- hdr_done = TRUE;
- }
- fmbytes(b, t1);
- rate = (cur->call[IN].flow[sent].bytes +
- cur->call[OUT].flow[sent].bytes) / time;
- fmtime((cur->call[IN].flow[sent].time +
- cur->call[OUT].flow[sent].time), t2);
-
- if (lineOut == 0) /* first half not printed yet ? */
- {
- if (cur->next == NULL) /* totals line ? */
- hdrprt('f',1); /* print the separator line */
- printf(" %-8s", cur->Hostname);
- if (sent == OUT) /* can't happen whith totals line */
- printf("%34s", " ");
- }
-
- printf(" %5d %11s %9s %5.0f",
- cur->call[IN].flow[sent].files +
- cur->call[OUT].flow[sent].files,
- t1, t2, rate);
- lineOut = 1;
- }
- } /* end: for (sent ... ) */
- if (lineOut)
- printf("\n");
- } /* end: for (cur= ... ) */
- if (! hdr_done)
- {
- puts("\n(I) No data found to print File statistics report");
- }
- }
- else
- {
- puts("\n(I) No data available for File statistics report");
- --report;
- }
- }
-
- /* ------------------------------------------------------------------
- * Efficiency report
- * ------------------------------------------------------------------
- */
-
- if (show_efficiency || show_all)
- {
- if (have_files[IN] || have_files[OUT])
- {
- char t1[32], t2[32], t3[32];
- double total, flow;
-
- hdr_done = FALSE;
- for (cur = hosts; cur != NULL; cur = cur->next)
- {
- /* Don't print null-lines. */
- if ( 0 == cur->call[IN].flow[IN].files +
- cur->call[IN].flow[OUT].files +
- cur->call[OUT].flow[IN].files +
- cur->call[OUT].flow[OUT].files ||
- 0.0 == (total= cur->call[IN].connect_time +
- cur->call[OUT].connect_time))
- {
- continue;
- }
-
- if (! hdr_done)
- {
- hdrprt('e',0); /* print the header line(s) */
- hdr_done = TRUE;
- }
-
- flow = cur->call[IN].flow[IN].time +
- cur->call[IN].flow[OUT].time +
- cur->call[OUT].flow[IN].time +
- cur->call[OUT].flow[OUT].time;
- fmtime(total, t1);
- fmtime(flow, t2);
- fmtime(total-flow, t3);
-
- if (cur->next == NULL)
- hdrprt('e',1); /* print the separator line */
-
- printf(" %-8s %10s %10s %10s %7.2f\n",
- cur->Hostname, t1, t2, t3,
- flow >= total ? 100.0: flow*100.0/total);
- } /* end: for (cur= .. */
- if (! hdr_done)
- {
- puts("\n(I) No data found to print Efficiency report");
- }
- }
- else
- {
- puts("\n(I) No data available for Efficiency report");
- --report;
- }
- }
-
- /* ------------------------------------------------------------------
- * Command execution report
- * ------------------------------------------------------------------
- */
-
- if (show_commands || show_all)
- {
- if (have_commands)
- {
- int ncmds, i, match;
-
- /*
- * layout the header line. The column's header is the command name
- */
-
- hdr_done = FALSE;
- for (ncmds= 0, cmd= t_cmds;
- cmd != NULL && ncmds <= MAXCOLS-1;
- ncmds++, cmd= cmd->next)
- {
- if (! hdr_done)
- {
- puts("\nCommand executions:");
- puts("-------------------");
- puts(" Name of ");
- fputs(" site ", stdout);
- hdr_done = TRUE;
- }
- printf(" %7s", cmd->Commandname);
- }
- if (! hdr_done)
- {
- puts("\n(I) No data found to print Command execution report");
- }
- else
- {
- fputs("\n --------", stdout);
- for (i= 0; i<ncmds; i++)
- fputs(" ------", stdout);
- putchar('\n');
-
- /*
- * print out the number of executions for each host/command
- */
-
- for (cur= hosts; cur != NULL; cur= cur->next)
- {
- if (cur->next == NULL)
- break;
-
- /* Don't print null-lines. */
-
- if (cur->cmds == NULL)
- continue;
-
- printf(" %-8s", cur->Hostname);
- for (cmd= t_cmds; cmd != NULL; cmd= cmd->next)
- {
- struct Execution_Command *ec;
- match = FALSE;
- for(ec= cur->cmds; ec != NULL; ec= ec->next)
- {
- if ( 0 == strcmp(cmd->Commandname, ec->Commandname) )
- {
- printf(" %7d", ec->count);
- match = TRUE;
- break;
- }
- }
- if (! match)
- printf("%8s"," "); /* blank out column */
- }
- putchar('\n');
- }
-
- /*
- * print the totals line
- */
-
- fputs(" --------", stdout);
- for (i= 0; i<ncmds; i++)
- fputs("--------", stdout);
- printf("\n %-8s", cur->Hostname);
- for (cmd= t_cmds; cmd != NULL; cmd= cmd->next)
- {
- printf(" %7d", cmd->count);
- }
- putchar('\n');
- }
- }
- else
- {
- puts("\n(I) No data available for Command execution report");
- --report;
- }
- }
- if (report <= 0 ) /* any reports ? */
- {
- puts("\n(I) Sorry! No data is available for any requested report\n");
- exit(1);
- }
-
- puts("\n(I) End of reports\n");
- exit (0);
-} /* end of main */
-
- /* ------------------------------------------------------------------
- * * Functions *
- * ------------------------------------------------------------------
- */
-
- /* ------------------------------------------------------------------
- * display the help
- * ------------------------------------------------------------------
- */
-
-void usage()
-{
- fprintf(stderr,"Usage uurate [-acdefhiptvx] [-s hostname] [-I config file] [logfile(s) ... logfile(s)]\n");
- fprintf(stderr,"where:\t-a\tPrint reports c,e,f,x\n");
- fprintf(stderr,"\t-c\tReport call statistics\n");
- fprintf(stderr,"\t-d\tPrint the name of the default config file\n");
- fprintf(stderr,"\t-e\tReport efficiency statistics\n");
- fprintf(stderr,"\t-f\tReport file transfer statistics\n");
- fprintf(stderr,"\t-h\tPrint this help\n");
- fprintf(stderr,"\t-i\tRead log info from standard input\n");
- fprintf(stderr,"\t-p\tReport protocol statistics\n");
- fprintf(stderr,"\t-t\tAll available reports plus compact summary report\n");
- fprintf(stderr,"\t-v\tPrint version number\n");
- fprintf(stderr,"\t-x\tReport command execution statistics\n");
- fprintf(stderr,"\t-s host\tReport activities involving HOST only\n");
- fprintf(stderr,"\t-I config Use config instead of standard config file\n");
- fprintf(stderr,"If no report options given, a compact summary report is printed.\n");
- fprintf(stderr,"log files should be given as pairs that is Log/Stats ... .\n");
- fprintf(stderr,"If neither -i nor logfiles given, those names found in config will be used\n");
-
- exit (1);
-}
-
- /* ------------------------------------------------------------------
- * getmem - get some memory
- * ------------------------------------------------------------------
- */
-
-static pointer *getmem(n)
- unsigned n;
-{
- pointer *p;
-
- if( NULL== (p= calloc(1, n)) )
- {
- fprintf(stderr,"\a%s (C) %s\n",Pgm_name, "out of memory\n");
- exit (8);
- }
- return p;
-}
-
- /* ------------------------------------------------------------------
- * inc_cmd - increment command count
- * ------------------------------------------------------------------
- */
-
-static void inc_cmd(cmds, name)
- struct Execution_Command **cmds;
- char *name;
-{
- int cnt = 0;
- struct Execution_Command *cmd, *ec;
-
- for (ec = cmd = *cmds; cmd != NULL; ec= cmd, cmd= cmd->next, cnt++)
- if ( (0 == strcmp(cmd->Commandname, name)) ||
- (0 == strcmp(cmd->Commandname, "Misc.")) )
- break;
- if (cmd == NULL)
- {
- cmd= (struct Execution_Command *)getmem(sizeof(*cmd));
- if (cnt <= MAXCOLS-1) /* first col prints site name therefore < max-1 */
- {
- strcpy(cmd->Commandname, name);
- if (*cmds == NULL)
- ec = *cmds = cmd;
- else
- ec->next= cmd;
- }
- else
- {
- strcpy(ec->Commandname, "Misc."); /* reached high-water-mark */
- cmd = ec; /* backtrack */
- }
- }
- cmd->count++;
-}
-
-
- /* ------------------------------------------------------------------
- * prot_sum - collect protocol data
- * ------------------------------------------------------------------
- */
-
- struct Protocol_Summary *
- prot_sum(proto, ptype, ind)
- struct Protocol_Summary **proto;
- char *ptype;
- int ind;
-{
- int cnt = 0;
- int i1, i2, i3 = 0;
- struct Protocol_Summary *cur, *first;
-
- for (first = cur = *proto; cur != NULL; first= cur, cur= cur->next, cnt++)
- {
- if ( (0 == strncmp(cur->type, ptype,strlen(cur->type))))
- break;
- }
- if (cur == NULL)
- {
- cur= (struct Protocol_Summary *)getmem(sizeof(*cur));
- sscanf(ptype,"%[^\' ]3",cur->type);
- if (*proto == NULL)
- first = *proto = cur;
- else
- first->next= cur;
- }
- if (NULL == (ptype = strchr(ptype, ' ')))
- return (NULL);
- cur->pr_cnt++;
- have_proto = TRUE;
- ++ptype;
- switch(ind)
- {
- case 1: /* used protocol line */
- /*
- * uucp-1.04 format: .... packet size ssss window ww)
- * uucp-1.05 format: .... remote packet/window ssss/ww local ssss/ww)
- * (the remote packet/window will be used!)
- */
-
- i1 = i2 = 0; /* reset */
-
- if (NULL == (strchr(ptype, '/')))
- sscanf(ptype,"%*s %*s %d %*s %d",&i1,&i2);
- else
- sscanf(ptype,"%*s %*s %d/%d",&i1,&i2);
-
- if (i1 > cur->pr_psizemax)
- cur->pr_psizemax = i1;
- if (i1 < cur->pr_psizemin || cur->pr_psizemin == 0)
- cur->pr_psizemin = i1;
-
- if (i2 > cur->pr_pwinmax)
- cur->pr_pwinmax = i2;
- if (i2 < cur->pr_pwinmin || cur->pr_pwinmin == 0)
- cur->pr_pwinmin = i2;
- break;
- case 2: /* protocol statistics line */
- i1 = i2 = i3 = 0; /* reset */
- sscanf(ptype,"%*s %*s %d%*c %*s %d%*c %*s %d",&i1,&i2,&i3);
- cur->pr_psent += i1;
- cur->pr_present += i2;
- cur->pr_preceived += i3;
- break;
- default:
- break;
- }
- return (cur);
-}
- /* ------------------------------------------------------------------
- * fmtime() - Format time in hours & minutes & seconds;
- * ------------------------------------------------------------------
- */
-
-static void fmtime(dsec, buf)
- double dsec;
- char *buf;
-{
- long hrs, min, lsec;
-
- if( dsec <= 0 )
- {
- strcpy(buf, "0" );
- return;
- }
- lsec = fmod(dsec+0.5, 60L); /* round to the next full second */
- hrs = dsec / 3600L;
- min = ((long)dsec / 60L) % 60L;
- if (hrs == 0)
- if (min == 0)
- sprintf(buf,"%6s%2ld"," ",lsec);
- else
- sprintf(buf,"%3s%2ld:%02ld"," ",min,lsec);
- else
- sprintf(buf,"%2ld:%02ld:%02ld",hrs,min,lsec);
-
-}
-
- /* ------------------------------------------------------------------
- * fmbytes - Format size in bytes
- * ------------------------------------------------------------------
- */
-
-static void fmbytes(n, buf)
- unsigned long n;
- char *buf;
-{
- if ( n == 0 )
- {
- strcpy( buf, "0.0" );
- return;
- }
- sprintf(buf, "%.1f", (double)n / 1000.0); /* Display in Kilobytes */
-}
-
-
- /* ------------------------------------------------------------------
- * chk_config - Read the config file
- * check on keywords: logfile and statfile. When found override
- * the corresponding default
- * ------------------------------------------------------------------
- */
-
-int chk_config(char *T_conf,int be_quiet, int type)
-{
- FILE *Conf;
- char keywrd[9];
- char name[MAXPATHLEN+1];
- char *pos1, *pos2;
- int i = 0;
- int logf = FALSE;
- int statf = FALSE;
-
- if ((Conf = fopen(T_conf, "r")) == NULL)
- {
- if (! be_quiet)
- {
- puts(" Could not open config");
- if (type == 0)
- {
- puts(" The run will be aborted\n");
- return (8);
- }
- }
- else
- {
- fprintf(stderr,"%s (E) %s %s \n",Pgm_name,
- "could not open config:",
- T_conf);
- if (type != 0)
- fprintf(stderr,"%s (W) defaults used for all files\n",
- Pgm_name);
- else
- {
- fprintf(stderr,"%s (C) ended due to errors\n",
- Pgm_name);
- return (8);
- }
- }
- }
- else
- {
- while (fgets(logline, sizeof(logline), Conf))
- {
- if (logline[0] == '#')
- continue;
- sscanf(logline,"%8s %s",keywrd,name);
- if (0 == strncmp(keywrd,"logfile",7))
- {
- pos1 = pos2 = name;
- for (i=0;(i<=MAXPATHLEN && *pos1 != '\0');pos1++,pos2++,i++)
- {
- if (*pos1 == '#') /* name immed followed by comment */
- break;
- if (*pos1 == '\\') /* quoted comment (filename has #) */
- {
- ++pos1; /* skip escape char */
- if (*pos1 != '#') /* continuation ? */
- {
- puts(" Config error:");
- puts(" Found filename continuation; bailing out\n");
- exit (8);
- }
- }
- *pos2 = *pos1; /* move char */
- }
- *pos2 = '\0'; /* terminate string */
- Tlog = (char *)getmem(strlen(name)+1);
- strcpy(Tlog,name);
- if (! be_quiet)
- printf(" logfile used: %s\n",Tlog);
- logf = TRUE;
- if (statf) /* statsfile still to come ? */
- break; /* no finished */
- continue;
- }
-
- if (0 == strncmp(keywrd,"statfile",8))
- {
- pos1 = pos2 = name;
- for (i=0;(i<=MAXPATHLEN && *pos1 != '\0');pos1++,pos2++,i++)
- {
- if (*pos1 == '#') /* name immed followed by comment */
- break;
- if (*pos1 == '\\') /* quoted comment (filename has #) */
- {
- ++pos1; /* skip escape char */
- if (*pos1 != '#') /* continuation ? */
- {
- puts(" Config error:");
- puts(" Found filename continuation; bailing out\n");
- exit (8);
- }
- }
- *pos2 = *pos1; /* move char */
- }
- *pos2 = '\0'; /* terminate string */
- Tstat = (char *)getmem(strlen(name)+1);
- strcpy(Tstat,name);
- if (! be_quiet)
- printf(" statfile used: %s\n",Tstat);
- statf = TRUE;
- if (logf) /* logfile still to come ? */
- break; /* no finished */
- continue;
- }
- }
- fclose(Conf);
- }
-
- if (! be_quiet)
- {
- if (! logf)
- puts(" logfile used: - default -");
- if (! statf)
- puts(" statfile used: - default -");
- }
-
-return 0;
-}
-
-
- /* ------------------------------------------------------------------
- * hdrprt - Print Header/Trailer lines (constant data)
- * ------------------------------------------------------------------
- */
-
-static void hdrprt(char head, int bot)
-{
- switch(head)
- {
- case('s'): /* standard summary report */
- if (bot == 0)
- {
- puts("\nCompact summary:");
- puts("----------------");
- puts("\
-Name of + Files + +------- Bytes/1000 --------+ +------ Time -----+ + Avg CPS +\n\
-site in out inbound outbound total inbound outbound in out\n\
--------- ---- ---- --------- --------- --------- --------- --------- ----- -----");
- }
- else
- puts("\
---------------------------------------------------------------------------------");
- break;
-
-
- case('f'): /* file statistic report */
- if (bot == 0)
- {
- puts("\nFile statistics:");
- puts("----------------");
- puts(" Name of +----------- Inbound -----------+ +---------- Outbound -----------+");
- puts(" site files Bytes/1000 xfr time B/sec files Bytes/1000 xfr time B/sec");
- puts(" -------- ----- ----------- --------- ----- ----- ----------- --------- -----");
- }
- else
- puts("\
- ----------------------------------------------------------------------------");
- break;
-
-
- case('c'): /* calls statistic report */
- if (bot == 0)
- {
- puts("\nCall statistics:");
- puts("----------------");
- puts(" Name of +------- Outbound Calls -------+ +-------- Inbound Calls ------+");
- puts(" site succ. failed total time succ. failed total time");
- puts(" -------- ------ ------ ------ --------- ------ ------ ------ ---------");
- }
- else
- puts("\
- ----------------------------------------------------------------------------");
- break;
-
-
- case('e'): /* efficiency statistic report */
- if (bot == 0)
- {
- puts("\nEfficiency:");
- puts("-----------");
- puts(" Name of +------ Times inbound/outbound -------+");
- puts(" site connected xfr time overhead eff. %");
- puts(" -------- --------- --------- --------- ------");
- }
- else
- puts(" -------------------------------------------------");
- break;
-
- case('i'): /* Environment information */
- if (bot == 0)
- {
- puts("\nEnvironment Information:");
- puts("------------------------");
- printf(" Default config: %s\n",D_conf == NULL ?
- noConf:D_conf);
- printf(" Default logfile: %s\n",Tlog);
- printf(" Default statfile: %s\n\n",Tstat);
- }
- break;
-
- case('d'): /* Date/time coverage */
- if (bot == 0)
- {
- puts("\n Date coverage of input files:");
- puts(" Name of +----- Start -----+ +------ End ------+");
- puts(" file date time date time");
- puts(" -------- ---------- -------- ---------- --------");
- }
- break;
-
- case('p'): /* Protocol stats */
- if (bot == 0)
- {
- puts("\nProtocol packet report:");
- puts("-----------------------");
- puts(" +------- protocol -----+ +--------- Packets ----------+");
- puts("Name of packet window ");
- puts("site typ min max min max sent resent received");
- puts("-------- --- ---- ---- ---- ---- ----------- ------- ----------");
- }
- else
- {
- puts("\nProtocol error report:");
- puts("----------------------");
- puts("Name of +----------------- Error Types --------------------+");
- puts("site typ header checksum order rem-reject");
- puts("-------- --- ----------- ---------- ----------- ----------");
- }
- break;
-
- default:
- if (bot == 0)
- {
- puts("\nNo header for this report defined:");
- }
- else
- puts(" ");
- break;
- }
-}
diff --git a/gnu/libexec/uucp/contrib/uurate.man b/gnu/libexec/uucp/contrib/uurate.man
deleted file mode 100644
index 4badee9..0000000
--- a/gnu/libexec/uucp/contrib/uurate.man
+++ /dev/null
@@ -1,280 +0,0 @@
-''' $Id$
-.TH uurate 1
-.SH NAME
-uurate \- Report Taylor UUCP statistics
-.SH SYNOPSIS
-.BR uurate " [ " "\-acdefhipqtvx" " ] [ " "\-s "
-.I host
-.RI " ] [ " "\-I "
-.I config
-.RI " ][ " "logfile..." " ] "
-.PP
-or simply,
-.PP
-.B uurate
-.PP
-for a traffic summary report.
-.SH DESCRIPTION
-The
-.I uurate
-command provides tabular summary reports on the operation of the
-Taylor UUCP system. Data is taken from the currently active log
-files, standard input, or from a list of log files given on the
-command line. Output is in the form of tabular reports summarizing
-call, file transfer, and command execution
-.RI "(" "uuxqt" ")"
-activity.
-.PP
-The log and stats files given to
-.I uurate
-must be in the ``Taylor'' or ``V2'' format. Also, note that call and file
-transfer activities are logged in separate files, nominally called
-.I Log
-and
-.I Stats,
-respectively. For reports to be meaningful, the
-.I Log
-and
-.I Stats
-files should be given to
-.I uurate
-together, and cover the same time period.
-.PP
-If neither the
-.B \-i
-or
-.B \-I
-option nor any
-.I logfile
-options are given,
-.I uurate
-defaults to taking its input from the current Taylor
-.I Log
-and
-.I Stats
-files. The names are either as defined at compilation time, in case
-there is no config file, or taken from the arguments of the keywords
-.I logfile
-and
-.I statfile
-when encountered in the config file.
-This is the normal mode of operation.
-.PP
-The reporting options described below can be used to select
-the set of reports desired. If no options are given, a summary
-report is displayed. If there is no relevant data for a particular
-report or host, that report or host will be suppressed.
-.SH OPTIONS
-The following options may be given to
-.I uurate:
-.TP 5
-.B \-a
-All reports. Identical to
-.B \-cfexp.
-.TP 5
-.B \-c
-Report on call statistics. Requires data from a
-.I Log
-file.
-.TP 5
-.B \-d
-will print the default config file to be used.
-.TP 5
-.B \-e
-Report on efficiency (total connect time versus time spent transferring
-files). Requires data from both a
-.I Log
-and a
-.I Stats
-file, and they must span the same time period.
-.TP 5
-.B \-f
-Report on file transfer statistics. Requires data from a
-.I Stats
-file.
-.TP 5
-.B \-h
-will print a short help information.
-.TP 5
-.B \-i
-tells uurate to read any logfile information from standard input.
-.TP 5
-.B \-p
-report on protocol errors and packets sent/received
-.TP 5
-.B \-q
-do not print the Environment information,
-.TP 5
-.B \-t
-All reports. Identical to
-.B \-cfexp.
-plus the
-.B Compact summary.
-.TP 5
-.B \-v
-will print the version id string
-.TP 5
-.B \-x
-Report on remote execution requests (e.g.,
-.IR rmail ")."
-Requires data from a
-.I Log
-file.
-.TP 5
-.BI "\-s " "host"
-Restrict report output to
-.I host.
-.TP 5
-.BI "\-I " "config file"
-an alternate config file may be passed by this option.
-.SH "DESCRIPTION OF REPORTS"
-There are four reports available: the call, file transfer, efficiency,
-and remote execution reports. Each may be selected by a command line
-option. All reports may be selected via the options
-.B \-a
-or
-.B \-t.
-If no report selection options are given,
-.I uurate
-displays a compact traffic summary report (see below).
-.SS "Summary report"
-If no report options are given,
-.I uurate
-displays a traffic summary report. This is particularly useful in daily
-.I cron
-jobs which report on errors and the like. Traffic statistics for each
-active system is reported on a single line. If more than one system was
-active, a 'totals' line is included at the end of the report.
-.SS "Protocol packet report"
-The protocol report gives statistics on min/max packet and window sizes
-used during transmission. Further on data is collected for packets
-transferred. The data is collected for each host/protocol type.
-The fields are described below:
-.PP
-.br
-.nf
-.in +.3i
-.ta 1.0i
-.BR "site " "UUCP node name of neighbor host system,"
-.BR "typ " "Type of protocol used"
-.BR "Min " "minimum packet/window size"
-.BR "Max " "maximum packet/window size"
-.BR "sent " "packets sent"
-.BR "resent " "packets resent"
-.BR "received " "packets received"
-.in -.3
-.SS "Protocol error report"
-The protocol report gives statistics on packet errors
-during transmission. The data is collected for each host/protocol type.
-The fields are described below:
-.PP
-.br
-.nf
-.in +.3i
-.ta 1.5i
-.BR "site " "UUCP node name of neighbor host system,"
-.BR "typ " "Type of protocol used"
-.BR "header " "number of errors in header"
-.BR "checksum " "number of checksum errors"
-.BR "order " "number of order errors"
-.BR "resent " "number packets resent"
-.BR "rem-reject " "packets that the remote site rejected"
-.in -.3
-.SS "Call report"
-The call report gives statistics on inbound and outbound calls for
-each active host system. The fields are described below:
-.PP
-.br
-.nf
-.in +.3i
-.ta 1.0i
-.BR "site " "UUCP node name of neighbor host system,"
-.BR "succ. " "Successful calls attempted to/by that system,"
-.BR "failed " "Failed calls to/by that system,"
-.BR "total " "Total calls to/by that system,"
-.BR "time " "Collected connect time (hh:mm:ss) for all calls,"
-.in -.3
-.SS "File transfer reports"
-The file transfer reports give statistics on inbound and
-outbound file transfers (regardless of which end initiated the transfer)
-for each active host system. There are two reports, one for files
-sent to the remote system and one for files received from the remote
-system. The fields in each report are described below:
-.PP
-.br
-.nf
-.in +.3i
-.ta 1.0i
-.BR "site " "UUCP node name of neighbor host system"
-.BR "files " "Number of files transferred"
-.BR "Bytes/1000 " "Total size of files transferred given in thousands"
-.BR "xfr time " "Total time (hh:mm:ss) spent on transfer the files,"
-.BR "B/sec " "Average transfer rate (bytes/sec)."
-.in -.3
-.SS "Efficiency report"
-The efficiency report describes the utilization of the links
-to each active remote system, giving the ratio of total connect time
-to the time spent actually transferring files.
-The fields are described below:
-.PP
-.br
-.nf
-.in +.3i
-.ta 1.0i
-.BR "site " "UUCP node name of neighbor host system"
-.BR "connected " "Total connect time for that system (turn-around)"
-.BR "xfr time " "Total file transfer time for that system"
-.BR "overhead " "Connect time not used to transfer files,"
-.BR "eff. % " "Ratio of connect time to transfer time (xfer*100/conn)"
-.in -.3
-.SS "Command executions report"
-The remote execution report describes remotely
-requested command executions from each active host system, like
-.I rmail
-and
-.IR rnews "."
-Up to eight command names are displayed. If there are more, the
-rest will be put together in an `Misc.' column.
-The fields are described below:
-.PP
-.br
-.nf
-.in +.3i
-.ta 1.0i
-.BR "site " "UUCP node name of neighbor host system,"
-.BR "(command) " "Number of requests of this command,"
-.BR "Misc. " "Number of other requests, if more than eight."
-.in -.3i
-.SS FILES
-The file names below may be changed at compilation time or by the
-configuration file, so these are only approximations.
-.br
-.nf
-.in +.3in
-.ta 2.2i
-.IR "/usr/spool/uucp/Log " "V2/Taylor format call/execution log,"
-.IR "/usr/spool/uucp/Stats " "V2/Taylor format file transfer log."
-.SS "SEE ALSO"
-.IR uucico "(8)"
-.SS BUGS
-Does not understand other than V2/TAYLOR logging formats. Anyone care to
-volunteer to add the not mentioned?
-.PP
-Scanning the arguments of logfile and statfile keywords
-in config should handle lines continued with the backslash as well.
-.PP
-The
-.B failfm
-field in the call statistics table is always zero, unless
-something really serious happens, e.g. uucico got SIGQUIT or
-the whole system crashed.
-.SS AUTHOR
-Robert B. Denny (denny@alisa.com).
-.br
-Loosely based on the DECUS UUCP program
-.I uurate
-by Mark Pizzolato.
-.br
-Modified by Stephan Niemz (stephan@sunlab.ka.sub.org).
-.br
-Modified by Klaus Dahlenburg (kdburg@incoahe.hanse.de).
diff --git a/gnu/libexec/uucp/contrib/uureroute.perl b/gnu/libexec/uucp/contrib/uureroute.perl
deleted file mode 100755
index 3eeb654..0000000
--- a/gnu/libexec/uucp/contrib/uureroute.perl
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/local/bin/perl
-eval ' exec /usr/local/bin/perl $0 "$@" '
- if $running_under_some_shell;
-
-# From a script by <Bill.Campbell@celestial.com>
-# Newsgroups: comp.sources.misc
-# Subject: v28i073: uureroute - Reroute HDB queued mail, Part01/01
-# Date: 26 Feb 92 02:28:37 GMT
-#
-# This is a Honey DanBer specific routine written in perl to reroute all
-# mail queued up for a specific host. It needs to be run as "root" since
-# uucp will not allow itself to remove others requests.
-#
-# Revision *** 92/21/09: Francois Pinard <pinard@iro.umontreal.ca>
-# 1. adapted for Taylor UUCP
-#
-# Revision 1.3 91/10/08 09:01:21 src
-# 1. Rewritten in perl
-# 2. Add -v option for debugging.
-#
-# Revision 1.2 91/10/07 23:57:42 root
-# 1. Fix mail program path.
-# 2. Truncate directory name to 7 characters
-
-($progname = $0) =~ s!.*/!!; # save this very early
-
-$USAGE = "
-# Reroute uucp mail
-#
-# Usage: $progname [-v] host [host...]
-#
-# Options Argument Description
-# -v Verbose (doesn't execute /bin/sh)
-#
-";
-
-$UUSTAT = "/usr/local/bin/uustat";
-$SHELL = "/bin/sh";
-$SMAIL = "/bin/smail";
-
-sub usage
-{
- die join ("\n", @_) . "\n$USAGE\n";
-}
-
-do "getopts.pl";
-
-&usage ("Invalid Option") unless do Getopts ("vV");
-
-$verbose = ($opt_v ? '-v' : ());
-$suffix = ($verbose ? '' : $$);
-
-&usage ("No system specified") if $#ARGV < 0;
-
-if (!$verbose)
-{
- open (SHELL, "| $SHELL");
- select SHELL;
-}
-
-while ($system = shift)
-{
- $sysprefix = substr ($system, 0, 7);
- $directory = "/usr/spool/uucp/$sysprefix";
- open (UUSTAT, "$UUSTAT -s $system -c rmail |");
- print "set -ex\n";
- while (<UUSTAT>)
- {
- ($jobid, ) = split;
- ($cfile) = substr ($jobid, length ($jobid) - 5);
- $cfilename = "$directory/C./C.$cfile";
- open (CFILE, $cfilename) || die "Cannot open $cfilename\n";
- $_ = <CFILE>;
- close CFILE;
- if (/^E D\.(....) [^ ]+ [^ ]+ -CR D\.\1 0666 [^ ]+ 0 rmail (.*)/)
- {
- $datafile = "$directory/D./D.$1";
- $address = $2;
- }
- else
- {
- print STDERR;
- die "Cannot parse previous line from $cfilename\n";
- }
- print "$SMAIL -R $system!$address < $datafile && $UUSTAT -k $jobid\n";
- }
- close UUSTAT;
-}
-close SHELL unless $verbose;
-
-exit 0;
diff --git a/gnu/libexec/uucp/contrib/uusnap.c b/gnu/libexec/uucp/contrib/uusnap.c
deleted file mode 100644
index d6fa323..0000000
--- a/gnu/libexec/uucp/contrib/uusnap.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/* uusnap.c
- (c) 1992 Heiko W.Rupp hwr@pilhuhn.ka.sub.org
- uusnap is a tool to display the activities of the connected
- systems.
-
- Put a file uusnap.systems in NEWCONFIGDIR (see Makefile), in which
- the systems, you want to monitor are listed, one on a single line.
- The sequence of the files there determine the sequence of the
- listing.
-
- At the moment it only works with taylor config and taylor dirs
-
- compile it form the Makefile or:
- cc -c -g -pipe -O -I. -I. -DNEWCONFIGLIB=\"/usr/local/lib/uucp\" uusnap.c
- cc -o uusnap uusnap.o
- For this, uusnap.[ch] must be in the same directory as uucp.h and so.
-
- uusnap must have read access to SPOOLDIR/.Status in order to work.
-*/
-
-#define MAXSYS 30 /* maximum number of systems */
-#define WAIT_NORMAL 10 /* wait period if noone is talking */
-#define WAIT_TALKING 2 /* refresh display every second if */
- /* someone is talking with us */
-
-#include "uucp.h"
-#if USE_RCS_ID
-char uusnap_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/dir.h>
-
-extern char *ctime(time_t*);
-
-struct sysInfo {
- char sysname[10]; /* name of the system to watch */
- char *statfile; /* name of its status file */
- char *spooldir; /* root of its spooldir */
- int in; /* number of unprocessed in-files */
- int out; /* number of files to send them */
- time_t last; /* last poll time */
- time_t next; /* time of next poll */
- time_t lastidir; /* time of last in-spooldir access */
- time_t lastodir; /* time of last outgoing spd acc */
- time_t laststat; /* time of last status file access */
- int status; /* status of the system */
- int num_retries; /* number of retries */
-};
-
-struct sysInfo Systems[MAXSYS];
-
-
-/* I have extend the system status. If time for the specified system
- is Never, I say so. To get this to work, one also should extend
- uucico.c. It is not important to do this. With the normal uucico,
- one only gets no status.
-*/
-
-const char *azStatus[] = /* Status codes as defined by uucico */
-{ /* listing them here instead of */
- "Conversation complete", /* including the appropriate file */
- "Port unavailable", /* reduces the size of the executable */
- "Dial failed",
- "Login failed",
- "Handshake failed",
- "Call failed",
- "Talking",
- "Wrong time to call",
- "Time to call = Never !"
-};
-
-main()
-{
- int i;
- i=get_systems();
- display_info(i);
-
- exit(0);
-}
-
-int
-get_systems()
-{
- char filename[1024];
- char fn[1024];
- char line[80];
- FILE *fp;
- int i=0;
- int j;
- struct stat stbuf;
- struct sysInfo sys;
-
- strcpy(filename,NEWCONFIGLIB);
- strcat(filename,"/uusnap.systems");
- if ((fp=fopen(filename,"r"))!=NULL) {
- while (fgets(line,80,fp)!=NULL) {
- *(rindex(line,'\n'))='\0';
- strcpy(sys.sysname,line); /* get the name of the system */
- strcpy(fn,SPOOLDIR); /* get the name of the statusfile */
- strcat(fn,"/.Status/");
- strcat(fn,line);
- sys.statfile=malloc(strlen(fn)+1);
- strcpy(sys.statfile,fn);
- strcpy(fn,SPOOLDIR); /* get the name of the spooldir */
- strcat(fn,"/");
- strcat(fn,line);
- sys.spooldir=malloc(strlen(fn)+1);
- strcpy(sys.spooldir,fn);
- sys.laststat=0;
- sys.lastidir=sys.lastodir=0;
- Systems[i]=sys; /* get_stat_for_system needs it */
- get_stat_for_system(i); /* now get the system status */
- get_inq_num(i,TRUE); /* number of unprocessed files */
- get_outq_num(i,TRUE); /* number of files to send */
- i++;
- }
- fclose(fp);
- }
- else {
- fprintf(stderr,"Can't open %s \n",filename);
- exit(1);
- }
- return i;
-}
-
-
-
-display_info(int numSys)
-{
- char *filename;
- int sysnum;
- FILE *fp;
- char contentline[80];
- char isTalking=FALSE;
- struct stat stbuf;
- struct sysInfo sys;
- time_t time;
-
- filename = (char*)malloc(1024);
- if (filename == NULL) {
- fprintf(stderr, "Can't malloc 1024 bytes");
- exit(1);
- }
-
- while(TRUE) {
- display_headline();
- for (sysnum=0;sysnum<numSys;sysnum++) {
- sys = Systems[sysnum];
- stat(sys.statfile,&stbuf);
- if ((time=stbuf.st_atime) > sys.laststat) {
- get_stat_for_system(sysnum);
- }
- if(display_status_line(sysnum)==1)
- isTalking=TRUE;
- }
- if (isTalking) {
- sleep(WAIT_TALKING);
- isTalking = FALSE;
- }
- else
- sleep(WAIT_NORMAL); /* wait a bit */
- }
- return 0;
-}
-
-int
-display_status_line(int sn)
-{
- char *time_s;
-
- int sys_stat,num_retries,wait;
- int i;
- time_t last_time;
- time_t next_time;
-
- struct sysInfo sys;
-
- sys = Systems[sn];
-
- printf("%10s ",sys.sysname);
- get_inq_num(sn);
- if (sys.in==0)
- printf(" ");
- else
- printf("%3d ",sys.in);
- get_outq_num(sn);
- if (sys.out==0)
- printf(" ");
- else
- printf("%3d ",sys.out);
- time_s = ctime(&sys.last);
- time_s = time_s + 11;
- *(time_s+8)='\0';
- printf("%8s ",time_s); /* time of last poll */
- time_s = ctime(&sys.next);
- time_s = time_s + 11;
- *(time_s+8)='\0';
- if (sys.last == sys.next)
- printf(" ");
- else
- printf("%8s ",time_s); /* time of next poll */
- if (sys.num_retries==0)
- printf(" ");
- else
- printf("%2d ",sys.num_retries);
- if (sys_stat==6) /* system is talking */
- printf("\E[7m"); /* reverse video on */
- printf("%s",azStatus[sys.status]);
- if (sys.status==6) {
- printf("\E[m\n"); /* reverse video off */
- return 1;
- }
- else {
- printf("\n");
- return 0;
- }
-}
-
-
-display_headline()
-{
- printf("\E[;H\E[2J"); /* clear screen */
- printf("\E[7muusnap (press CTRL-C to escape)\E[m \n\n");
- printf(" System #in #out last next #ret Status\n");
- return 0;
-}
-
-get_inq_num(int num,char firstTime)
-{
- int i=0;
- char filename[1024];
- struct stat stbuf;
- DIR *dirp;
-
- strcpy(filename,Systems[num].spooldir);
- strcat(filename,"/X./.");
- stat(filename,&stbuf);
- if ((stbuf.st_mtime > Systems[num].lastidir) || (firstTime)) {
- if ((dirp=opendir(filename))!=NULL) {
- while(readdir(dirp))
- i++;
- closedir(dirp);
- stat(filename,&stbuf);
- Systems[num].lastidir=stbuf.st_mtime;
- }
- else {
- fprintf(stderr,"Can't open %s \n",filename);
- exit(1);
- }
- if (i>=2)
- i-=2; /* correct . and .. */
- Systems[num].in=i;
- }
- return 0;
-}
-
-get_outq_num(int sys,char firstTime)
-{
- int i=0;
- char filename[1024];
- struct stat stbuf;
- DIR *dirp;
-
- strcpy(filename,Systems[sys].spooldir);
- strcat(filename,"/C./.");
- stat(filename,&stbuf);
- if ((stbuf.st_mtime > Systems[sys].lastodir) || (firstTime)) {
- if ((dirp=opendir(filename))!=NULL) {
- while(readdir(dirp))
- i++;
- closedir(dirp);
- stat(filename,&stbuf);
- Systems[sys].lastodir=stbuf.st_mtime;
- }
- else {
- fprintf(stderr,"Can't open %s \n",filename);
- exit(1);
- }
- if (i>=2)
- i-=2; /* correct . and .. */
- Systems[sys].out=i;
- }
- return 0;
-}
-
-get_stat_for_system(int i)
-{
- char fn[80];
- struct sysInfo sys;
- struct stat stbuf;
- FILE *fp;
- time_t wait;
-
- sys = Systems[i];
- stat(sys.statfile,&stbuf);
- if (stbuf.st_atime > sys.laststat) {
- if ((fp=fopen(sys.statfile,"r"))!=NULL) {
- fgets(fn,80,fp);
- fclose(fp);
- sscanf(fn,"%d %d %ld %d",
- &sys.status,
- &sys.num_retries,
- &sys.last,
- &wait);
- sys.next=sys.last+wait;
- }
- else {
- sys.status=0;
- sys.num_retries=0;
- sys.last=0;
- sys.next=0;
- }
- stat(sys.statfile,&stbuf);
- sys.laststat=stbuf.st_atime;
- }
- Systems[i] = sys;
- return 0;
-}
diff --git a/gnu/libexec/uucp/contrib/uutraf b/gnu/libexec/uucp/contrib/uutraf
deleted file mode 100644
index 00e4b03..0000000
--- a/gnu/libexec/uucp/contrib/uutraf
+++ /dev/null
@@ -1,210 +0,0 @@
-#!/usr/bin/perl
-# uutraf.pl -- UUCP Traffic Analyzer
-# SCCS Status : @(#)@ uutraf 1.8
-# Author : Johan Vromans
-# Created On : ***
-# Last Modified By: Johan Vromans
-# Last Modified On: Mon Aug 30 15:02:22 1993
-# Update Count : 6
-# Status : OK
-# Requires: : Perl V4 or later
-
-# Reads UUCP syslog, and generates a report from it.
-#
-# Created by Johan Vromans <jv@mh.nl>
-# Loosely based on an idea by Greg Hackney (hack@texbell.swbt.com)
-
-# Usage: uutraf [-taylor|-hdb|-bnu|-bsd] [syslog]
-
-# Logfile formats:
-#
-# BSD:
-#
-# jv mhres (2/23-5:18) (698818735) received 135 b 2 secs
-# root mhres (2/23-5:19) (698818742) sent 2365 b 3 secs, Pk: 38, Rxmt: 0
-#
-# HDB:
-#
-# uunet!uucp M (12/10-09:04:22) (C,16390,1) [ttyXX] <- 2371 / 5.000 secs, \
-# 474 bytes/sec
-#
-# Taylor:
-#
-# jv mhres (1992-02-24 20:49:04.06) sent 16234 bytes in 148.780 seconds \
-# (109 bytes/sec)
-# jv mhres (1992-02-24 21:04:05.76) received 449 bytes in 6.550 seconds \
-# (68 bytes/sec)
-
-$uucp_type = "gnu";
-
-%hosts = (); # hosts seen
-%bytes_in = (); # of bytes received from host
-%bytes_out = (); # of bytes sent to host
-%secs_in = (); # of seconds connect for recving
-%secs_out = (); # of seconds connect for sending
-%files_in = (); # of input requests
-%files_out = (); # of output requests
-
-# read info, break the lines and tally
-
-if ( $ARGV[0] =~ /^-/ ) {
- ($uucp_type = substr (shift (@ARGV), 1)) =~ tr/A-Z/a-z/;
-}
-
-if ( $uucp_type eq "taylor" || $uucp_type eq "gnu" ) {
- @ARGV = ("/usr/local/spool/uucp/Stats") unless $#ARGV >= 0;
- $pat = "^[^ ]+ ([^ ]+) \\(([-0-9:\\/ .]+)\\) " .
- "(sent|received) (\\d+) bytes in (\\d+)\\.(\\d+) seconds";
- $uucp_type = 0;
- $recv = "received";
-}
-elsif ( $uucp_type eq "hdb" || $uucp_type eq "bnu" ) {
- @ARGV = ("/usr/spool/uucp/.Admin/xferstats") unless $#ARGV >= 0;
- $pat = "^([^!]+)![^(]+\\(([-0-9:\\/]+)\\).+([<>])-? " .
- "(\\d+) \\/ (\\d+)\\.(\\d+) secs";
- $uucp_type = 1;
- $recv = "<";
-}
-elsif ( $uucp_type eq "bsd" || $uucp_type eq "v7" ) {
- @ARGV = ("/usr/spool/uucp/SYSLOG") unless $#ARGV >= 0;
- $pat = "^[^ ]+ ([^ ]+) \\(([-0-9:\\/]+)\\) \\([^)]+\\) " .
- "(sent|received) (\\d+) b (\\d+) secs";
- $uucp_type = 2;
- $recv = "received";
-}
-else {
- die ("FATAL: Unknown UUCP type: $uucp_type\n");
-}
-
-$garbage = 0;
-
-while ( <> ) {
- unless ( /$pat/o ) {
- print STDERR "$_";
- next if /failed/;
- if ( $garbage++ > 10 ) {
- die ("FATAL: Too much garbage; wrong UUCP type?\n");
- }
- next;
- }
-
- # gather timestamps
- $last_date = $2;
- $first_date = $last_date unless defined $first_date;
-
- # initialize new hosts
- unless ( defined $hosts{$1} ) {
- $hosts{$1} = $files_in{$1} = $files_out{$1} =
- $bytes_in{$1} = $bytes_out{$1} =
- $secs_in{$1} = $secs_out{$1} = 0;
- }
-
- # Taylor and HDB have milliseconds, BSD has not.
- $secs = ($uucp_type == 2) ? ($5 + ($5 == 0 ? 0.5 : 0)) : ($5 + $6/1000);
-
- # tally
- if ( $3 eq $recv ) { # recv
- $bytes_in{$1} += $4;
- $files_in{$1}++;
- $secs_in{$1} += $secs;
- }
- else { # xmit
- $bytes_out{$1} += $4;
- $files_out{$1}++;
- $secs_out{$1} += $secs;
- }
- $garbage = 0;
-}
-
-@hosts = keys (%hosts);
-die ("No info found, stopped\n") if $#hosts < 0;
-
-################ report section ################
-
-$thishost = &gethostname();
-$thishost = (defined $thishost) ? "on node $thishost" : "report";
-
-if ( $uucp_type eq 0 ) { # Taylor UUCP
- substr ($first_date, 16) = "";
- substr ($last_date, 16) = "";
-}
-
-format std_head =
-@|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-"UUCP traffic $thishost from $first_date to $last_date"
-
-Remote -----------K-Bytes----------- ----Hours---- --Avg CPS-- --Files--
- Host Recv Sent Total Recv Sent Recv Sent Recv Sent
-.
-format std_out =
-@<<<<<<< @>>>>>>>> @>>>>>>>> @>>>>>>>> @>>>>> @>>>>> @>>>> @>>>> @>>> @>>>
-$Zhost, $Zi_bytes, $Zo_bytes, $Zt_bytes, $Zi_hrs, $Zo_hrs, $Zi_acps, $Zo_acps, $Zi_count, $Zo_count
-.
-
-$^ = "std_head";
-$~ = "std_out";
-
-&print_dashes ();
-
-reset "T"; # reset totals
-
-foreach $host (@hosts) {
- &print_line ($host, $bytes_in{$host}, $bytes_out{$host},
- $secs_in{$host}, $secs_out{$host},
- $files_in{$host}, $files_out{$host});
-
-}
-
-&print_dashes ();
-&print_line ("Total", $Ti_bytes, $To_bytes,
- $Ti_secs, $To_secs, $Ti_count, $To_count);
-
-################ that's it ################
-
-sub print_line {
- reset "Z"; # reset print fields
- local ($Zhost,
- $Zi_bytes, $Zo_bytes,
- $Zi_secs, $Zo_secs,
- $Zi_count, $Zo_count) = @_;
- $Ti_bytes += $Zi_bytes;
- $To_bytes += $Zo_bytes;
- $Zt_bytes = $Zi_bytes + $Zo_bytes;
- $Tt_bytes += $Zt_bytes;
- $Zi_acps = ($Zi_secs > 0) ? sprintf ("%.0f", $Zi_bytes/$Zi_secs) : "0";
- $Zo_acps = ($Zo_secs > 0) ? sprintf ("%.0f", $Zo_bytes/$Zo_secs) : "0";
- $Zi_bytes = sprintf ("%.1f", $Zi_bytes/1000);
- $Zo_bytes = sprintf ("%.1f", $Zo_bytes/1000);
- $Zt_bytes = sprintf ("%.1f", $Zt_bytes/1000);
- $Zi_hrs = sprintf ("%.1f", $Zi_secs/3600);
- $Zo_hrs = sprintf ("%.1f", $Zo_secs/3600);
- $Ti_secs += $Zi_secs;
- $To_secs += $Zo_secs;
- $Ti_count += $Zi_count;
- $To_count += $Zo_count;
- write;
-}
-
-sub print_dashes {
- $Zhost = $Zi_bytes = $Zo_bytes = $Zt_bytes =
- $Zi_hrs = $Zo_hrs = $Zi_acps = $Zo_acps = $Zi_count = $Zo_count =
- "------------";
- write;
- # easy, isn't it?
-}
-
-################ missing ################
-
-sub gethostname {
- $ENV{"SHELL"} = "/bin/sh";
- $try = `(hostname) 2>/dev/null`;
- chop $try;
- return $+ if $try =~ /^[-.\w]+$/;
- $try = `uname -n 2>/dev/null`;
- chop $try;
- return $+ if $try =~ /^[-.\w]+$/;
- $try = `uuname -l 2>/dev/null`;
- chop $try;
- return $+ if $try =~ /^[-.\w]+$/;
- return undef;
-}
diff --git a/gnu/libexec/uucp/contrib/uutry b/gnu/libexec/uucp/contrib/uutry
deleted file mode 100644
index 258bb30..0000000
--- a/gnu/libexec/uucp/contrib/uutry
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh
-#
-# This script was hacked together by Marc Evans (marc@Synergytics.Com)
-# I claim no copyright to it and don't really care what people do
-# with it, hence, it is public domain. I take no responsibility for
-# for happens if you use this script, providing no warentee. This
-# section of the comments may be removed if you so desire.
-#
-# Usage:
-# uutry [-x#] systemname
-# where '-x#' has the value [0-9], higher values providing more detail
-
-#
-# The following variables should be gropped from the configuration
-# files rather then being hard coded here.
-#
-Spool=/usr/spool/uucp
-Lib=/usr/local/lib/uucp
-Status=$Spool/.Status
-Debug=$Spool/Debug
-Uucico=$Lib/uucico
-#
-# Default option values
-#
-x="-x5"
-s=""
-
-for i in $* ; do
- case $i in
- -x*) x="$i" ;;
- *) s="$i" ;;
- esac
-done
-
-if [ x$s != x ]; then
- rm -f $Status/$s
- $Uucico -r1 $x -s$s &
- >$Debug
- tail -f $Debug
-else
- echo "Usage: uutry systemname"
- exit 1
-fi
diff --git a/gnu/libexec/uucp/contrib/uuxconv b/gnu/libexec/uucp/contrib/uuxconv
deleted file mode 100755
index 843f9e0..0000000
--- a/gnu/libexec/uucp/contrib/uuxconv
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh
-#
-# uuxconv
-#
-# After converting to Taylor from SVR4.03 UUCP, I still had a lot of
-# jobs queued up to go out.
-#
-# This script is a one-shot to mass-requeue a site's spool.
-#
-# It doesn't go and do your whole spool, nor even all grades.
-# you need to go into each grade directory for each site and
-# execute this.
-#
-# i.e.: You have a site named 'foo'
-# cd /var/spool/uucp/foo/Z
-# uuxconv foo
-#
-# it does delete the 'D' & 'X' after requeing them, but doesn't remove
-# the 'C' files.
-#
-# I foolishly went and ran this script on all my queued jobs, without
-# adding the improvements to recursively go through the entire UUCP spool,
-# so now I'm out of files to test with. I don't want to add the code
-# to do that since I can't test it, and this worked.
-#
-# I hereby give this (trivial :-)) program to the GNU Project/FSF
-# and Ian Taylor in it's entirety, so that it can be placed in
-# the contrib directory of taylor-uucp, and save others the pain
-# of rewriting it.
-#
-# Richard Nickle (rick@trystro.uucp, rnickle@gnu.ai.mit.edu)
-# May 27, 1993
-#
-if [ $# -eq 0 ]
-then
- echo "Usage: $0 sitename"
- exit 1
-fi
-exit 0
-site=$1
-tsite=`echo $site | cut -c1-5`
-find . -name "D.$tsite*" -print |
-while read file
-do
- control=`egrep "^C" $file | cut -c3-`
- input=`egrep "^I" $file | cut -c3-`
- (uux - -r -z $site!$control < $input) && (rm $file $input)
- echo "$site!$control < $input"
-done
-exit 0
diff --git a/gnu/libexec/uucp/contrib/xc-conf.h-dist b/gnu/libexec/uucp/contrib/xc-conf.h-dist
deleted file mode 100644
index 8810dd7..0000000
--- a/gnu/libexec/uucp/contrib/xc-conf.h-dist
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * *************
- * * XC-CONF.H *
- * *************
- *
- * Configuration file for xchat 1.1. Edit this file prior to make-ing
- * xchat.
- *
- * History:
- * Bob Denny - Tue Sep 1 11:42:54 1992
- */
-
-/*
- * Edit this to reflect the relative location of xchat sources to
- * the main Taylor UUCP source directory. As distributed, xchat
- * is in the ./contrib sub-directory under the main Taylor UUCP
- * directory. Therefore, Taylor's conf.h is in our parent directory.
- */
-#include "../conf.h"
-
-/*
- * The following definition establishes the default path to the
- * scripts used by xchat. You may lleave this blank (""), but
- * the command line given to xchat (e.g., in the 'sys' file entry)
- * must specify a full (absolute) path name to the script to be
- * executed. Normally, this is the same place you put your config
- * and system files for UUCP.
- */
-#define SCRIPT_DIR "/usr/local/conf/uucp/" /* MUST HAVE TRAILING "/" */
-
-/*
- * The following definition establishes the default path to the
- * log files that are produced by the 'dbgfile' statement. Normally
- * this is the same location you configured Taylor UUCP to put its
- * log files.
- */
-#define LOG_DIR "/usr/spool/uucp/" /* MUST HAVE TRAILING "/" */
-
diff --git a/gnu/libexec/uucp/contrib/xchat.c b/gnu/libexec/uucp/contrib/xchat.c
deleted file mode 100644
index b44549e..0000000
--- a/gnu/libexec/uucp/contrib/xchat.c
+++ /dev/null
@@ -1,1473 +0,0 @@
-/*
- * ***********
- * * XCHAT.C *
- * ***********
- *
- * Extended chat processor for Taylor UUCP. See accompanying documentation.
- *
- * Written by:
- * Bob Denny (denny@alisa.com)
- * Based on code in DECUS UUCP (for VAX/VMS)
- *
- * Small modification by:
- * Daniel Hagerty (hag@eddie.mit.edu)
- *
- * History:
- * Version 1.0 shipped with Taylor 1.03. No configuration info inside.
- *
- * Bob Denny - Sun Aug 30 18:41:30 1992
- * V1.1 - long overdue changes for other systems. Rip out interval
- * timer code, use timer code from Taylor UUCP, use select()
- * for timed reads. Use Taylor UUCP "conf.h" file to set
- * configuration for this program. Add defaulting of script
- * and log file paths.
- *
- * Daniel Hagerty - Mon Nov 22 18:17:38 1993
- * V1.2 - Added a new opcode to xchat. "expectstr" is a cross between
- * sendstr and expect, looking for a parameter supplied string.
- * Useful where a prompt could change for different dial in
- * lines and such.
- *
- * Bugs:
- * Does not support BSD terminal I/O. Anyone care to add it?
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <signal.h>
-#include <time.h>
-#include <sys/ioctl.h>
-#include <sys/termio.h>
-
-#include "xc-conf.h"
-
-/*
- * Pick a timing routine to use, as done in Taylor UUCP.
- */
-#if HAVE_USLEEP || HAVE_NAP || HAVE_NAPMS || HAVE_POLL
-#define USE_SELECT_TIMER 0
-#else
-#define USE_SELECT_TIMER HAVE_SELECT
-#if USE_SELECT_TIMER
-#include <sys/time.h>
-#endif
-#endif
-
-#if HAVE_USLEEP || HAVE_NAP || HAVE_NAPMS
-#undef HAVE_POLL
-#define HAVE_POLL 0
-#endif
-
-#if HAVE_USLEEP || HAVE_NAP
-#undef HAVE_NAPMS
-#define HAVE_NAPMS 0
-#endif
-
-#if HAVE_USLEEP
-#undef HAVE_NAP
-#define HAVE_NAP 0
-#endif
-
-static int ttblind();
-static int ttcd();
-
-/* script entry -- "compiled" form of dial, hangup, or login script */
-
-struct script {
- struct script *next; /* pointer to next entry, or null */
- int opcode; /* numeric opcode */
- char *strprm; /* pointer to string param */
- long intprm; /* integer parameter */
- char *newstate; /* new state name */
-};
-
-/* opcode definition array element -- one for each possible opcode */
-
-struct script_opdef {
- char *opname;
- int opcode; /* numeric opcode -- same as array index */
- int prmtype; /* one of SC_NONE, SC_STR, SC_XSTR, SC_INT */
- int newstate; /* one of SC_NONE, SC_NWST */
-};
-
- /* values for opcode */
-
-#define SC_LABEL 0 /* "label" (state name) */
-#define SC_CDLY 1 /* set char output delay in msec */
-#define SC_PCHR 2 /* pause char for dial string (from P in input) */
-#define SC_PTIM 3 /* seconds to allow for pause char */
-#define SC_WCHR 4 /* wait char for dial string (from W in input) */
-#define SC_WTIM 5 /* seconds to allow for wait char */
-#define SC_ZERO 6 /* zero counter */
-#define SC_INCR 7 /* increment counter */
-#define SC_IFGT 8 /* change state if counter > int param */
-#define SC_WAIT 9 /* wait for int param seconds */
-#define SC_GOTO 10 /* unconditional change to new state */
-#define SC_SEND 11 /* send strparam (after sprintf substitutions) */
-#define SC_BRK 12 /* send a break */
-#define SC_HANG 13 /* drop DTR */
-#define SC_DIAL 14 /* send telno string (after subst PCHR & WCHR) */
-#define SC_DTIM 15 /* time in msec per digit (for timeout calculations) */
- /* default = 100 (one tenth second) */
-#define SC_CTIM 16 /* additional time (in seconds) to wait for carrier */
- /* default = 45 seconds */
-#define SC_EXIT 17 /* script done, success */
-#define SC_FAIL 18 /* script done, failure */
-#define SC_LOG 19 /* write strparam to uucp.log */
-#define SC_LOGE 20 /* write strparam to uucp.log w/error ind */
-#define SC_DBG 21 /* write strparam to debug log if debug lvl = LGI */
-#define SC_DBGE 22 /* write strparam to debug log if debug lvl = LGIE */
-#define SC_DBST 23 /* 'or' intparam into debug mask */
-#define SC_DBCL 24 /* 'bicl' intparam into debug mask */
-#define SC_TIMO 25 /* newstate if no match in intparam secs */
- /* (uses calculated dial time if intparam is 0) */
-#define SC_XPCT 26 /* wait for strparam, goto _newstate if found */
-#define SC_CARR 27 /* goto _newstate if carrier detected */
-#define SC_FLSH 28 /* flush typeahead buffer */
-#define SC_IFBL 29 /* change state if controller is blind w/o CD */
-#define SC_IFBG 30 /* chg state if ctlr is blind and counter > intprm */
-#define SC_SNDP 31 /* send parameter n */
-#define SC_IF1P 32 /* if parameter n present */
-#define SC_IF0P 33 /* if parameter n absent */
-#define SC_DBOF 34 /* open debugging file */
-#define SC_TELN 35 /* Set telno from parameter n */
-#define SC_7BIT 36 /* Set port to 7-bit stripping */
-#define SC_8BIT 37 /* Set port for 8-bit characters */
-#define SC_PNON 38 /* Set port for 8-bit, no parity */
-#define SC_PEVN 39 /* Set port for 7-bit, even parity */
-#define SC_PODD 40 /* Set port for 7-bit, odd parity */
-#define SC_HUPS 41 /* Change state on HUP signal */
-#define SC_XPST 42 /* Expect a param string */
-#define SC_END 43 /* end of array */
-
- /* values for prmtype, prm2type */
-
-#define SC_NONE 0 /* no parameter */
-#define SC_STR 1 /* simple string */
-#define SC_INT 2 /* integer */
-#define SC_NWST 3 /* new state name */
-#define SC_XSTR 4 /* translated string */
-
-/* opcode definition table for dial/login/hangup scripts */
-
-static struct script_opdef sc_opdef[] =
- {
- {"label", SC_LABEL, SC_NONE, SC_NONE},
- {"chrdly", SC_CDLY, SC_INT, SC_NONE},
- {"pchar", SC_PCHR, SC_STR, SC_NONE},
- {"ptime", SC_PTIM, SC_INT, SC_NONE},
- {"wchar", SC_WCHR, SC_STR, SC_NONE},
- {"wtime", SC_WTIM, SC_INT, SC_NONE},
- {"zero", SC_ZERO, SC_NONE, SC_NONE},
- {"count", SC_INCR, SC_NONE, SC_NONE},
- {"ifgtr", SC_IFGT, SC_INT, SC_NWST},
- {"sleep", SC_WAIT, SC_INT, SC_NONE},
- {"goto", SC_GOTO, SC_NONE, SC_NWST},
- {"send", SC_SEND, SC_XSTR, SC_NONE},
- {"break", SC_BRK, SC_NONE, SC_NONE},
- {"hangup", SC_HANG, SC_NONE, SC_NONE},
- {"7bit", SC_7BIT, SC_NONE, SC_NONE},
- {"8bit", SC_8BIT, SC_NONE, SC_NONE},
- {"nopar", SC_PNON, SC_NONE, SC_NONE},
- {"evenpar", SC_PEVN, SC_NONE, SC_NONE},
- {"oddpar", SC_PODD, SC_NONE, SC_NONE},
- {"telno", SC_TELN, SC_INT, SC_NONE},
- {"dial", SC_DIAL, SC_NONE, SC_NONE},
- {"dgttime", SC_DTIM, SC_INT, SC_NONE},
- {"ctime", SC_CTIM, SC_INT, SC_NONE},
- {"success", SC_EXIT, SC_NONE, SC_NONE},
- {"failed", SC_FAIL, SC_NONE, SC_NONE},
- {"log", SC_LOG, SC_XSTR, SC_NONE},
- {"logerr", SC_LOGE, SC_XSTR, SC_NONE},
- {"debug", SC_DBG, SC_XSTR, SC_NONE},
- {"debuge", SC_DBGE, SC_XSTR, SC_NONE},
- {"dbgset", SC_DBST, SC_INT, SC_NONE},
- {"dbgclr", SC_DBCL, SC_INT, SC_NONE},
- {"dbgfile", SC_DBOF, SC_XSTR, SC_NONE},
- {"timeout", SC_TIMO, SC_INT, SC_NWST},
- {"expect", SC_XPCT, SC_XSTR, SC_NWST},
- {"ifcarr", SC_CARR, SC_NONE, SC_NWST},
- {"ifhang", SC_HUPS, SC_NONE, SC_NWST},
- {"flush", SC_FLSH, SC_NONE, SC_NONE},
- {"ifblind", SC_IFBL, SC_NONE, SC_NWST},
- {"ifblgtr", SC_IFBG, SC_INT, SC_NWST},
- {"sendstr", SC_SNDP, SC_INT, SC_NONE},
- {"ifstr", SC_IF1P, SC_INT, SC_NWST},
- {"ifnstr", SC_IF0P, SC_INT, SC_NWST},
- {"expectstr", SC_XPST, SC_INT, SC_NWST},
- {"table end", SC_END, SC_NONE, SC_NONE}
- };
-
-#define SUCCESS 0
-#define FAIL 1
-#define ERROR -1
-#define MAX_SCLINE 255 /* max length of a line in a script file */
-#define MAX_EXPCT 127 /* max length of an expect string */
-#define CTL_DELIM " \t\n\r" /* Delimiters for tokens */
-#define SAME 0 /* if (strcmp(a,b) == SAME) ... */
-#define SLOP 10 /* Slop space on arrays */
-#define MAX_STRING 200 /* Max length string to send/expect */
-
-#define DEBUG_LEVEL(level) \
- (Debug & (1 << level))
-
-#define DB_LOG 0 /* error messages and a copy of the LOGFILE output */
-#define DB_LGIE 1 /* dial,login,init trace -- errors only */
-#define DB_LGI 2 /* dial,login,init trace -- nonerrors (incl chr I/O) */
-#define DB_LGII 3 /* script processing internals */
-
-#define TRUE 1
-#define FALSE 0
-
-#define NONE 0
-#define EVEN 1
-#define ODD 2
-
-#define logit(m, p1) fprintf(stderr, "%s %s\n", m, p1)
-
-static char **paramv; /* Parameter vector */
-static int paramc; /* Parameter count */
-static char telno[64]; /* Telephone number w/meta-chars */
-static int Debug;
-static int fShangup = FALSE; /* TRUE if HUP signal received */
-static FILE *dbf = NULL;
-static struct termio old, new;
-
-extern int usignal();
-extern int uhup();
-
-static struct siglist
-{
- int signal;
- int (*o_catcher) ();
- int (*n_catcher) ();
-} sigtbl[] = {
- { SIGHUP, NULL, uhup },
- { SIGINT, NULL, usignal },
- { SIGIOT, NULL, usignal },
- { SIGQUIT, NULL, usignal },
- { SIGTERM, NULL, usignal },
- { SIGALRM, NULL, usignal },
- { 0, NULL, NULL } /* Table end */
- };
-
-extern struct script *read_script();
-extern void msleep();
-extern char xgetc();
-extern void charlog();
-extern void setup_tty();
-extern void restore_tty();
-extern void ttoslow();
-extern void ttflui();
-extern void tthang();
-extern void ttbreak();
-extern void tt7bit();
-extern void ttpar();
-extern void DEBUG();
-
-extern void *malloc();
-
-
-/*
- * **********************************
- * * BEGIN EXECUTION - MAIN PROGRAM *
- * **********************************
- *
- * This program is called by Taylor UUCP with a list of
- * arguments in argc/argv, and stdin/stdout mapped to the
- * tty device, and stderr mapped to the Taylor logfile, where
- * anything written to stdout will be logged as an error.
- *
- */
-int main(argc, argv)
-int argc;
-char *argv[];
-{
- int i, stat;
- FILE *sf;
- char sfname[256];
- struct script *script;
- struct siglist *sigs;
-
- /*
- * The following is needed because my cpp does not have the
- * #error directive...
- */
-#if ! HAVE_SELECT
- no_select_sorry(); /* Sad way to fail make */
-#endif
-
- paramv = &argv[2]; /* Parameters start at 2nd arg */
- paramc = argc - 2; /* Number of live parameters */
-
- telno[0] = '\0';
-
- if (argc < 2)
- {
- fprintf(stderr, "%s: no script file supplied\n", argv[0]);
- exit(FAIL);
- }
-
- /*
- * If the script file argument begins with '/', then we assume
- * it is an absolute pathname, otherwise, we prepend the
- * SCRIPT_DIR path.
- */
- *sfname = '\0'; /* Empty name string */
- if(argv[1][0] != '/') /* If relative path */
- strcat(sfname, SCRIPT_DIR); /* Prepend the default dir. */
- strcat(sfname, argv[1]); /* Add the script file name */
-
- /*
- * Now open the script file.
- */
- if ((sf = fopen(sfname, "r")) == NULL)
- {
- fprintf(stderr, "%s: Failed to open script %s\n", argv[0], sfname);
- perror(" ");
- exit(FAIL);
- }
-
- /*
- * COMPILE SCRIPT
- */
- if ((script = read_script(sf)) == NULL)
- {
- fprintf(stderr, "%s: script error in \"%s\"\n", argv[0], argv[1]);
- exit(FAIL);
- }
-
- /*
- * Set up a signal catcher so the line can be returned to
- * it's current state if something nasty happens.
- */
- sigs = &sigtbl[0];
- while(sigs->signal)
- {
- sigs->o_catcher = (int (*) ())signal(sigs->signal, sigs->n_catcher);
- sigs += 1;
- }
-
- /*
- * Save current tty settings, then set up raw, single
- * character input processing, with 7-bit stripping.
- */
- setup_tty();
-
- /*
- * EXECUTE SCRIPT
- */
- if ((stat = do_script(script)) != SUCCESS)
- fprintf(stderr, "%s: script %s failed.\n", argv[0], argv[1]);
-
- /*
- * Clean up and exit.
- */
- restore_tty();
-#ifdef FIXSIGS
- sigs = &sigtbl[0];
- while(sigs->signal)
- if(sigs->o_catcher != -1)
- signal(sigs->signal, sigs->o_catcher);
-#endif
- exit(stat);
-}
-
-/*
- * deal_script - deallocate a script and all strings it points to
- */
-int deal_script(loc)
-struct script *loc;
-{
- /*
- * If pointer is null, just exit
- */
- if (loc == (struct script *)NULL)
- return SUCCESS;
-
- /*
- * Deallocate the rest of the script
- */
- deal_script(loc->next);
-
- /*
- * Deallocate the string parameter, if any
- */
- if (loc->strprm != (char *)NULL)
- free(loc->strprm);
-
- /*
- * Deallocate the new state name parameter, if any
- */
- if (loc->newstate != (char *)NULL)
- free(loc->newstate);
-
- /*
- * Deallocate this entry
- */
- free(loc);
-
- return SUCCESS;
-}
-
-
-/*
- * read_script
- *
- * Read & compile a script, return pointer to first entry, or null if bad
- */
-struct script *read_script(fd)
- FILE *fd;
-{
- struct script *this = NULL;
- struct script *prev = NULL;
- struct script *first = NULL;
- long len, i;
- char inpline[MAX_SCLINE];
- char inpcopy[MAX_SCLINE];
- char *c, *cln, *opc, *cp;
-
- /*
- * MAIN COMPILATION LOOP
- */
- while ((c = fgets(inpline, (sizeof inpline - 1), fd)) != (char *)NULL)
- {
- /*
- * Skip comments and blank lines
- */
- if (*c == '#' || *c == '\n')
- continue;
-
- /*
- * Get rid of the trailing newline, and copy the string
- */
- inpline[strlen(inpline)-1] = '\0';
- strcpy(inpcopy, inpline);
-
- /*
- * Look for text starting in the first col (a label)
- */
- if ((!isspace(inpline[0])) &&
- (cln = strchr (inpline, ':')) != (char *)NULL) {
- this = (struct script *)malloc (sizeof (struct script));
- if (prev != (struct script *)NULL)
- prev->next = this;
- prev = this;
- if (first == (struct script *)NULL)
- first = this;
- this->next = (struct script *)NULL;
- this->opcode = SC_LABEL;
- len = cln - c;
- this->strprm = (char *)malloc(len+1);
- strncpy(this->strprm, c, len);
- (this->strprm)[len] = '\0';
- this->intprm = 0;
- this->newstate = (char *)NULL;
- c = cln + 1;
- }
-
- /*
- * Now handle the opcode. Fold it to lower case.
- */
- opc = strtok(c, CTL_DELIM);
- if (opc == (char *)NULL) /* If no opcode... */
- continue; /* ...read the next line */
- cp = opc;
- while(*cp)
- tolower(*cp++);
-
- /*
- * If we have an opcode but we haven't seen anything
- * else (like a label) yet, i.e., this is the first
- * entry, and there was no label. We need to
- * cobble up a label so that read_script is happy
- */
- if (first == (struct script *)NULL)
- {
- this = (struct script *)malloc (sizeof (struct script));
- prev = this;
- first = this;
- this->next = (struct script *)NULL;
- this->opcode = SC_LABEL;
- this->strprm = (char *)malloc(2);
- strcpy(this->strprm, ":");
- this->intprm = 0;
- this->newstate = (char *)NULL;
- }
-
- /*
- * Find opcode - ndex through the opcode definition table
- */
- for (i=1; sc_opdef[i].opcode != SC_END; i++)
- if (strcmp(opc, sc_opdef[i].opname) == SAME)
- break;
- if ((sc_opdef[i].opcode) == SC_END)
- {
- logit ("Bad opcode in script", opc);
- deal_script(first);
- return (struct script *)NULL;
- }
-
- /*
- * Found opcode. Allocate a new command node and initialize
- */
- this = (struct script *)malloc(sizeof (struct script));
- prev->next = this;
- prev = this;
- this->next = (struct script *)NULL;
- this->opcode = sc_opdef[i].opcode;
- this->strprm = (char *)NULL;
- this->intprm = 0;
- this->newstate = (char *)NULL;
-
- /*
- * Pick up new state parameter, if any
- */
- if (sc_opdef[i].newstate == SC_NWST)
- {
- c = strtok((char *)NULL, CTL_DELIM);
- if (c == (char *)NULL)
- {
- logit("Missing new state", opc);
- deal_script(first);
- return (struct script *)NULL;
- }
- else
- {
- this->newstate = (char *)malloc(strlen(c)+1);
- strcpy(this->newstate, c);
- }
- }
-
- /*
- * Pick up the string or integer parameter. Handle missing
- * parameter gracefully.
- */
- switch (sc_opdef[i].prmtype)
- {
- /*
- * INT parameter - convert and store in node
- */
- case SC_INT:
- c = strtok((char *)NULL, CTL_DELIM);
- if (c == (char *)NULL)
- {
- logit("Missing script param", opc);
- deal_script(first);
- return (struct script *)NULL;
- }
- /*
- * If this is the parameter to DBST or DBCL, force
- * base-10 conversion, else convert per parameter.
- */
- if (sc_opdef[i].opcode == SC_DBST ||
- sc_opdef[i].opcode == SC_DBCL)
- this->intprm = strtol(c, (char **)NULL, 0);
- else
- this->intprm = strtol(c, (char **)NULL, 10);
- break;
-
- /*
- * STR/XSTR strings.
- */
- case SC_STR:
- case SC_XSTR:
- c = strtok((char *)NULL, CTL_DELIM);
- if (c == (char *)NULL)
- {
- logit("Missing script param", opc);
- deal_script(first);
- return (struct script *)NULL;
- }
- /*
- * For XSTR opcode, use c to find out where
- * the string param begins in the copy of the
- * input line, and pick up all that's left of
- * the line (to allow imbedded blanks, etc.).
- */
- if (sc_opdef[i].prmtype == SC_XSTR)
- c = &inpcopy[0] + (c - &inpline[0]);
-
- /*
- * Allocate a buffer for the string parameter
- */
- this->strprm = (char *)malloc(strlen(c)+1);
-
- /*
- * For XSTR, Translate the string and store its
- * length. Note that, after escape sequences are
- * compressed, the resulting string may well be a
- * few bytes shorter than the input string (whose
- * length was the basis for the malloc above),
- * but it will never be longer.
- */
- if (sc_opdef[i].prmtype == SC_XSTR)
- {
- this->intprm = xlat_str(this->strprm, c);
- this->strprm[this->intprm] = '\0';
- }
- else
- strcpy(this->strprm, c);
- break;
-
- }
- }
-
- /*
- * EOF
- */
- return first;
-}
-
-
-/*
- * xlat_str
- *
- * Translate embedded escape characters in a "send" or "expect" string.
- *
- * Called by read_script(), above.
- *
- * Returns the actual length of the resulting string. Note that imbedded
- * nulls (specified by \000 in the input) ARE allowed in the result.
- */
-xlat_str(out, in)
- char *out, *in;
-{
- register int i = 0, j = 0;
- int byte, k;
-
- while (in[i])
- {
- if (in[i] != '\\')
- {
- out[j++] = in[i++];
- }
- else
- {
- switch (in[++i])
- {
- case 'd': /* EOT */
- out[j++] = 0x04;
- break;
- case 'N': /* null */
- out[j++] = 0x00;
- break;
- case 'n': /* line feed */
- out[j++] = 0x0a;
- break;
- case 'r': /* carriage return */
- out[j++] = 0x0d;
- break;
- case 's': /* space */
- out[j++] = ' ';
- break;
- case 't': /* tab */
- out[j++] = '\t';
- break;
- case '-': /* hyphen */
- out[j++] = '-';
- break;
- case '\\': /* back slash */
- out[j++] = '\\';
- break;
- case '0': /* '\nnn' format */
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- byte = in[i] - '0';
- k = 0;
-
- while (3 > ++k)
- if ((in[i+1] < '0') || (in[i+1] > '7'))
- break;
- else
- {
- byte = (byte<<3) + in[i+1] - '0';
- ++i;
- }
- out[j++] = byte;
- break;
- default: /* don't know so skip it */
- break;
- }
- ++i;
- }
- }
- return j;
-}
-
-
-/* find a state within a script */
-
-struct script *
- find_state(begin, newstate)
-struct script *begin;
-char *newstate;
-{
- struct script *here;
-
- for (here=begin; here != (struct script *)NULL; here=here->next) {
- if (here->opcode == SC_LABEL &&
- strcmp(here->strprm, newstate) == SAME)
- return here;
- }
- return (struct script *)NULL;
-}
-
-
-/*
- * do_script() - execute a script
- */
-int do_script(begin)
- struct script *begin;
-{
- struct script *curstate, *newstate, *curscr;
- int dbgsave;
- char tempstr[MAX_SCLINE];
- char dfname[256];
- char *c, chr;
- int prmlen;
- int dbfd;
-
- time_t sc_carrtime = 45000; /* time to wf carr after dial */
- time_t sc_chrdly = 100; /* delay time for ttoslow */
- time_t sc_ptime = 2000; /* time to allow for pause char */
- time_t sc_wtime = 10000; /* time to allow for wait char */
- time_t sc_dtime = 100; /* time to allow for each digit */
- time_t sc_dtmo; /* total time to dial number */
- int sc_counter; /* random counter */
- char sc_pchar = ','; /* modem pause character */
- char sc_wchar = 'W'; /* modem wait-for-dialtone character */
- time_t sc_begwait; /* time at beg of wait */
- time_t sc_secs; /* timeout period */
-
- int expcnt;
- int expin;
- static char expbuf[MAX_EXPCT];
-
- dbgsave = Debug;
- curstate = begin;
-
- if (curstate == (struct script *)NULL)
- return SUCCESS;
-
- _newstate:
- /*
- * do all of curstate's actions. Enter with curstate pointing
- * to a label entry
- */
- expin = 0;
-
- for (curscr = curstate->next; /* point to 1st scr after label */
- (curscr != (struct script *)NULL) && /* do until end of scr */
- (curscr->opcode != SC_LABEL); /* or next label */
- curscr = curscr->next)
- {
- expcnt = 0;
- switch (curscr->opcode)
- {
- case SC_LABEL:
- logit("Script proc err", curstate->strprm);
- return FAIL;
-
- case SC_FLSH:
- DEBUG(DB_LGII, "Flushing typeahead buffer\n", 0);
- ttflui();
- break;
-
- case SC_CDLY:
- sc_chrdly = curscr->intprm;
- DEBUG(DB_LGII, "Set chrdly to %d\n", sc_chrdly);
- break;
-
- case SC_PCHR:
- sc_pchar = *(curscr->strprm);
- DEBUG(DB_LGII, "Set pause char to %c\n", sc_pchar);
- break;
-
- case SC_PTIM:
- sc_ptime = curscr->intprm;
- DEBUG(DB_LGII, "Set pause time to %d\n", sc_ptime);
- break;
-
- case SC_WCHR:
- sc_wchar = *(curscr->strprm);
- DEBUG(DB_LGII, "Set wait char to %c\n", sc_wchar);
- break;
-
- case SC_WTIM:
- sc_wtime = curscr->intprm;
- DEBUG(DB_LGII, "Set wait time to %d\n", sc_wtime);
- break;
-
- case SC_ZERO:
- sc_counter = 0;
- DEBUG(DB_LGII, "Set counter to %d\n", sc_counter);
- break;
-
- case SC_INCR:
- sc_counter++;
- DEBUG(DB_LGII, "Incr counter to %d\n", sc_counter);
- break;
-
- case SC_WAIT:
- DEBUG(DB_LGII, "Sleeping %d tenth-secs\n", curscr->intprm);
- msleep(curscr->intprm);
- break;
-
- case SC_DTIM:
- sc_dtime = curscr->intprm;
- DEBUG(DB_LGII, "Digit time is %d\n", sc_dtime);
- break;
-
- case SC_CTIM:
- sc_carrtime = curscr->intprm;
- DEBUG(DB_LGII, "Carrier time is %d\n", sc_carrtime);
- break;
-
- case SC_EXIT:
- Debug = dbgsave;
- DEBUG(DB_LGI, "Script ended successfully\n", 0);
- return SUCCESS;
-
- case SC_FAIL:
- Debug = dbgsave;
- if (DEBUG_LEVEL(DB_LGI) && dbf != NULL)
- fprintf(dbf, "Script failed\n");
- else if (expin)
- charlog(expbuf, expin, DB_LOG,
- "Script failed. Last received data");
- return FAIL;
-
- case SC_LOG:
- logit(curscr->strprm, "");
- break;
-
- case SC_LOGE:
- logit("ERROR: ", curscr->strprm);
- break;
-
- case SC_DBOF:
- /*
- * If the debug file name does not begin with "/", then
- * we prepend the LOG_DIR to the string. Then CREATE the
- * file. This WIPES OUT previous logs.
- */
- *dfname = '\0'; /* Zero name string */
- if(curscr->strprm[0] != '/')
- strcat(dfname, LOG_DIR); /* Prepend default directory */
- strcat(dfname, curscr->strprm); /* Add given string */
- DEBUG(DB_LGII, "Open debug file %s\n", dfname);
- if ((dbfd = creat (dfname, 0600)) <= 0)
- {
- logit("Failed to create debug log %s", dfname);
- perror("");
- return FAIL;
- }
- if ((dbf = fdopen(dbfd, "w")) == NULL)
- {
- logit("Failed to open debug log fildes.", "");
- perror("");
- return FAIL;
- }
- break;
-
- case SC_DBG:
- DEBUG(DB_LGI, "<%s>\n", curscr->strprm);
- break;
-
- case SC_DBGE:
- DEBUG(DB_LGIE, "ERROR: <%s>\n", curscr->strprm);
- break;
-
- case SC_DBST:
- Debug |= curscr->intprm;
- DEBUG(DB_LGII, "Debug mask set to %04o (octal)\n", Debug);
- break;
-
- case SC_DBCL:
- Debug &= ~(curscr->intprm);
- DEBUG(DB_LGII, "Debug mask set to %04o (octal)\n", Debug);
- break;
-
- case SC_BRK:
- DEBUG(DB_LGI, "Sending break\n", 0);
- ttbreak();
- break;
-
- case SC_HANG:
- DEBUG(DB_LGI, "Dropping DTR\n", 0);
- tthang();
- break;
-
- case SC_7BIT:
- DEBUG(DB_LGI, "Enabling 7-bit stripping\n", 0);
- tt7bit(TRUE);
- break;
-
- case SC_8BIT:
- DEBUG(DB_LGI, "Disabling 7-bit stripping\n", 0);
- tt7bit(FALSE);
- break;
-
- case SC_PNON:
- DEBUG(DB_LGI, "Setting 8-bit, no parity\n", 0);
- ttpar(NONE);
- break;
-
- case SC_PEVN:
- DEBUG(DB_LGI, "Setting 7-bit, even parity\n", 0);
- ttpar(EVEN);
- break;
-
- case SC_PODD:
- DEBUG(DB_LGI, "Setting 7-bit, odd parity\n", 0);
- ttpar(ODD);
- break;
-
- case SC_IFBL:
- if (ttblind())
- {
- DEBUG(DB_LGI, "Blind mux,\n", 0);
- goto _chgstate;
- }
- break;
-
- case SC_IFBG:
- if (ttblind() && sc_counter > curscr->intprm)
- {
- DEBUG(DB_LGI, "Blind mux & ctr > %d\n",
- curscr->intprm);
- goto _chgstate;
- }
- break;
-
- case SC_IFGT:
- if (sc_counter > curscr->intprm)
- {
- DEBUG(DB_LGI, "Counter > %d\n", curscr->intprm);
- goto _chgstate;
- }
- break;
-
- case SC_GOTO:
- _chgstate:
- DEBUG(DB_LGI, "Changing to state %s\n",
- curscr->newstate);
- curstate = find_state(begin, curscr->newstate);
- if (curstate == NULL)
- {
- logit("New state not found",
- curscr->newstate);
- return FAIL;
- }
- goto _newstate;
-
- case SC_SEND:
- ttoslow(curscr->strprm, curscr->intprm, sc_chrdly);
- break;
-
- case SC_TELN:
- if (curscr->intprm > paramc - 1)
- {
- sprintf(tempstr, "telno - param #%d", curscr->intprm);
- logit(tempstr, " not present");
- return FAIL;
- }
- strcpy(telno, paramv[curscr->intprm]);
- DEBUG(DB_LGII, "telno set to %s\n", telno);
- break;
-
- case SC_SNDP:
- if (curscr->intprm > paramc - 1)
- {
- sprintf(tempstr, "sendstr - param #%d", curscr->intprm);
- logit(tempstr, " not present");
- return FAIL;
- }
- prmlen = xlat_str(tempstr, paramv[curscr->intprm]);
- ttoslow(tempstr, prmlen, sc_chrdly);
- break;
-
- case SC_IF1P:
- if (curscr->intprm < paramc)
- goto _chgstate;
- break;
-
- case SC_IF0P:
- if (curscr->intprm >= paramc)
- goto _chgstate;
- break;
-
- case SC_DIAL:
- if(telno[0] == '\0')
- {
- logit("telno not set", "");
- return(FAIL);
- }
- /*
- * Compute and set a default timeout for the 'timeout'
- * command. Some parameters in this computation may be
- * changed by the script. See the man page xchat(8) for
- * details.
- */
- sc_dtmo = (sc_dtime+sc_chrdly)*strlen(telno)
- + sc_carrtime;
- c=strcpy(tempstr, telno);
- for (; *c!='\0'; c++)
- {
- if (*c == 'W')
- {
- *c = sc_wchar;
- sc_dtmo += sc_wtime;
- }
- else if (*c == 'P')
- {
- *c = sc_pchar;
- sc_dtmo += sc_ptime;
- }
- }
- DEBUG(DB_LGI, "Dialing, default timeout is %d millisecs\n", sc_dtmo);
- ttoslow(tempstr, 0, sc_chrdly);
- break;
-
- case SC_TIMO: /* these are "expects", don't bother */
- case SC_XPCT: /* with them yet, other than noting that */
- case SC_CARR: /* they exist */
- case SC_XPST:
- expcnt++;
- break;
- }
-
- }
-
- /* we've done the current state's actions, now do its expects, if any */
-
- if (expcnt == 0)
- {
- if (curscr != (struct script *)NULL &&
- (curscr->opcode == SC_LABEL))
- {
- curstate = curscr;
- DEBUG(DB_LGI, "Fell through to state %s\n",
- curstate->strprm);
- goto _newstate;
- }
- else
- {
- logit("No way out of state", curstate->strprm);
- return FAIL;
- }
- }
-
- time(&sc_begwait); /* log time at beg of expect */
- DEBUG(DB_LGI, "Doing expects for state %s\n", curstate->strprm);
- charlog((char *)NULL, 0, DB_LGI, "Received");
-
- while (1)
- {
- chr = xgetc(1); /* Returns upon char input or 1 sec. tmo */
-
- charlog(&chr, 1, DB_LGI, (char *)NULL);
-
- if (chr != EOF)
- {
- if (expin < MAX_EXPCT)
- {
- expbuf[expin++] = chr & 0x7f;
- }
- else
- {
- strncpy(expbuf, &expbuf[1], MAX_EXPCT-1);
- expbuf[MAX_EXPCT-1] = chr & 0x7f;
- }
- }
-
- /* for each entry in the current state... */
-
- for (curscr = curstate->next;
- (curscr != (struct script *)NULL) &&
- (curscr->opcode != SC_LABEL);
- curscr = curscr->next)
- {
-
- switch (curscr->opcode)
- {
- case SC_TIMO:
- sc_secs = curscr->intprm;
- if (sc_secs == 0)
- sc_secs = sc_dtmo;
- sc_secs /= 1000;
- if (time(NULL)-sc_begwait > sc_secs)
- {
- DEBUG(DB_LGI,
- "\nTimed out (%d secs)\n", sc_secs);
- goto _chgstate;
- }
- break;
-
- case SC_CARR:
- if (ttcd())
- {
- DEBUG(DB_LGI, "\nGot carrier\n", 0);
- goto _chgstate;
- }
- break;
-
- case SC_HUPS:
- if (fShangup)
- {
- DEBUG(DB_LGI, "\nGot data set hangup\n", 0);
- goto _chgstate;
- }
- break;
-
- case SC_XPCT:
- if ((expin >= curscr->intprm) &&
- (strncmp(curscr->strprm,
- &expbuf[expin - curscr->intprm],
- curscr->intprm) == SAME))
- {
- charlog(curscr->strprm, curscr->intprm,
- DB_LGI, "Matched");
- goto _chgstate;
- }
- break;
-
- }
- }
- }
-}
- /* New opcode added by hag@eddie.mit.edu for expecting a
- parameter supplied string */
- case SC_XPST:
- if(curscr->intprm >paramc-1)
- {
- sprintf(tempstr,"expectstr - param#%d",curscr->intprm);
- logit(tempstr, " not present");
- return(FAIL);
- }
- prmlen=xlat_str(tempstr,paramv[curscr->intprm]);
- if((expin >= prmlen) &&
- (strncmp(tempstr,&expbuf[expin-prmlen],
- prmlen) == SAME))
- {
- charlog(tempstr,prmlen,DB_LGI, "Matched");
- goto _chgstate;
- }
- break;
-/*
- * SIGNAL HANDLERS
- */
-
-/*
- * usignal - generic signal catcher
- */
-static int usignal(isig)
- int isig;
-{
- DEBUG(DB_LOG, "Caught signal %d. Exiting...\n", isig);
- restore_tty();
- exit(FAIL);
-}
-
-/*
- * uhup - HUP catcher
- */
-static int uhup(isig)
- int isig;
-{
- DEBUG(DB_LOG, "Data set hangup.\n");
- fShangup = TRUE;
-}
-
-/*
- * TERMINAL I/O ROUTINES
- */
-
-/*
- * xgetc - get a character with timeout
- *
- * Assumes that stdin is opened on a terminal or TCP socket
- * with O_NONBLOCK.
- */
-static char xgetc(tmo)
-int tmo; /* Timeout, seconds */
-{
- char c;
- struct timeval s;
- int f = 1; /* Select on stdin */
- int result;
-
- if(read(0, &c, 1) <= 0) /* If no data available */
- {
- s.tv_sec = (long)tmo;
- s.tv_usec = 0L;
- if(select (1, &f, (int *) NULL, &f, &s) == 1)
- read(0, &c, 1);
- else
- c = '\377';
- }
-
- return(c);
-}
-
-/*
- * Pause for an interval in milliseconds
- */
-void msleep(msec)
-long msec;
-{
-
-#if HAVE_USLEEP
- if(msec == 0) /* Skip all of this if delay = 0 */
- return;
- usleep (msec * (long)1000);
-#endif /* HAVE_USLEEP */
-
-#if HAVE_NAPMS
- if(msec == 0) /* Skip all of this if delay = 0 */
- return;
- napms (msec);
-#endif /* HAVE_NAPMS */
-
-#if HAVE_NAP
- if(msec == 0) /* Skip all of this if delay = 0 */
- return;
- nap (msec);
-#endif /* HAVE_NAP */
-
-#if HAVE_POLL
- struct pollfd sdummy;
-
- if(msec == 0)
- return;
- /*
- * We need to pass an unused pollfd structure because poll checks
- * the address before checking the number of elements.
- */
- poll (&sdummy, 0, msec);
-#endif /* HAVE_POLL */
-
-#if USE_SELECT_TIMER
- struct timeval s;
-
- if(msec == 0)
- return;
- s.tv_sec = msec / 1000L;
- s.tv_usec = (msec % 1000L) * 1000L;
- select (0, (int *) NULL, (int *) NULL, (int *) NULL, &s);
-#endif /* USE_SELECT_TIMER */
-
-#if ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP && \
- ! HAVE_POLL && ! USE_SELECT_TIMER
- if(msec == 0)
- return;
- sleep (1); /* Sleep for a whole second (UGH!) */
-#endif /* HAVE_ and USE_ nothing */
-}
-
-/*
- * Debugging output
- */
-static void DEBUG(level, msg1, msg2)
-int level;
-char *msg1, *msg2;
-{
- if ((dbf != NULL) && DEBUG_LEVEL(level))
- fprintf(dbf, msg1, msg2);
-}
-
-/*
- * charlog - log a string of characters
- *
- * SPECIAL CASE: msg=NULL, len=1 and msg[0]='\377' gets logged
- * when read does its 1 sec. timeout. Log "<1 sec.>"
- * so user can see elapsed time
- */
-static void charlog(buf, len, mask, msg)
-char *buf;
-int len, mask;
-char *msg;
-{
- char tbuf[256];
-
- if (DEBUG_LEVEL(mask) && dbf != NULL)
- {
- if(msg == (char *)NULL)
- msg = "";
- strncpy(tbuf, buf, len);
- tbuf[len] = '\0';
- if(len == 1 && tbuf[0] == '\377')
- strcpy(tbuf, "<1 sec.>");
- fprintf(dbf, "%s %s\n", msg, tbuf);
- }
-}
-
-/*
- * setup_tty()
- *
- * Save current tty settings, then set up raw, single
- * character input processing, with 7-bit stripping.
- */
-static void setup_tty()
-{
- register int i;
-
- ioctl(0, TCGETA, &old);
-
- new = old;
-
- for(i = 0; i < 7; i++)
- new.c_cc[i] = '\0';
- new.c_cc[VMIN] = 0; /* MIN = 0, use requested count */
- new.c_cc[VTIME] = 10; /* TIME = 1 sec. */
- new.c_iflag = ISTRIP; /* Raw mode, 7-bit stripping */
- new.c_lflag = 0; /* No special line discipline */
-
- ioctl(0, TCSETA, &new);
-}
-
-/*
- * restore_tty() - restore signal handlers and tty modes on exit.
- */
-static void restore_tty(sig)
-int sig;
-{
- ioctl(0, TCSETA, &old);
- return;
-}
-
-/*
- * ttoslow() - Send characters with pacing delays
- */
-static void ttoslow(s, len, delay)
- char *s;
- int len;
- time_t delay;
-{
- int i;
-
- if (len == 0)
- len = strlen(s);
-
- charlog (s, len, DB_LGI, "Sending slowly");
-
- for (i = 0; i < len; i++, s++)
- {
- write(1, s, 1);
- msleep(delay);
- }
-}
-
-/*
- * ttflui - flush input buffer
- */
-static void ttflui()
-{
- if(isatty(0))
- (void) ioctl ( 0, TCFLSH, 0);
-}
-
-/*
- * ttcd - Test if carrier is present
- *
- * NOT IMPLEMENTED. I don't know how!!!
- */
-static int ttcd()
-{
- return TRUE;
-}
-
-/*
- * tthang - Force DTR low for 1-2 sec.
- */
-static void tthang()
-{
- if(!isatty())
- return;
-
-#ifdef TCCLRDTR
- (void) ioctl (1, TCCLRDTR, 0);
- sleep (2);
- (void) ioctl (1, TCSETDTR, 0);
-#endif
-
- return;
-}
-
-/*
- * ttbreak - Send a "break" on the line
- */
-static void ttbreak()
-{
- (void) ioctl (1, TCSBRK, 0);
-}
-
-/*
- * ttblind - return TRUE if tty is "blind"
- *
- * NOT IMPLEMENTED - Don't know how!!!
- */
-static int ttblind()
-{
- return FALSE;
-}
-
-/*
- * tt7bit - enable/disable 7-bit stripping on line
- */
-static void tt7bit(enable)
- int enable;
-{
- if(enable)
- new.c_iflag |= ISTRIP;
- else
- new.c_iflag &= ~ISTRIP;
-
- ioctl(0, TCSETA, &new);
-}
-
-/*
- * ttpar - Set parity mode on line. Ignore parity errors on input.
- */
-static void ttpar(mode)
- int mode;
-{
- switch(mode)
- {
- case NONE:
- new.c_iflag &= ~(INPCK | IGNPAR);
- new.c_cflag &= ~(CSIZE | PARENB | PARODD);
- new.c_cflag |= CS8;
- break;
-
- case EVEN:
- new.c_iflag |= (INPCK | IGNPAR);
- new.c_cflag &= ~(CSIZE | PARODD);
- new.c_cflag |= (CS7 | PARENB);
-
- break;
-
- case ODD:
- new.c_iflag |= (INPCK | IGNPAR);
- new.c_cflag &= ~(CSIZE);
- new.c_cflag |= (CS7 | PARENB | PARODD);
- break;
- }
-
- ioctl(0, TCSETA, &new);
-}
-
-
-
-
-
-
-
diff --git a/gnu/libexec/uucp/contrib/xchat.man b/gnu/libexec/uucp/contrib/xchat.man
deleted file mode 100644
index 55537be..0000000
--- a/gnu/libexec/uucp/contrib/xchat.man
+++ /dev/null
@@ -1,628 +0,0 @@
-.TH xchat 8
-.SH NAME
-xchat - Extended chat processor
-.SH SYNOPSIS
-.BI "xchat " "scriptfile"
-.RI " [ " parameter... " ] "
-.PP
-where
-.I scriptfile
-is the name of a file containing an
-.I xchat
-script. If
-.I scriptfile
-begins with ``/'', then it is assumed to be a full path name for the
-script file. If not, a configuration-dependent default directory path
-(usually
-.B "/usr/local/conf/uucp/"
-) is prepended to the script file name. Normally, the default path
-is the same as that for the Taylor UUCP configuration files.
-.SH DESCRIPTION
-.I Xchat
-is a general-purpose dialing and login program designed for use
-with Taylor UUCP as a ``chat-program'', taking the place (or
-augmenting) the built-in chat scripting facility. It provides the
-ability to closely control timeouts, multiple simultaneous ``expect''
-strings with separate actions, extended terminal control, modem
-command character pacing, and more.
-.PP
-When used in conjunction with Taylor UUCP's
-configuration features,
-.I xchat
-can provide you the ability to manage the most intricate login,
-dial and hangup needs. The scripts are written in a shell-like (well,
-sort-of) style with labels, commands, and parameters, easing the task
-of writing procedures for complex terminal communications situations.
-.PP
-Because
-.I xchat
-assumes that it is connected to the terminal device via stdin/stdout,
-you can easily debug scripts by invoking it from the shell and
-responding to the script from the keyboard. A debug logging facility
-is included, with the debug output going to a separate user-specified
-file. This makes it easy to debug connection problems without wading
-through large
-.I uucico
-log and debug files.
-.PP
-Formally, a script describes a state machine;
-.I xchat
-interprets the script and does what the state machine
-tells it to. This section will be much easier to understand
-if you obtain listings of the script files supplied with
-.I xchat.
-.SH "SCRIPT FILE FORMAT"
-Script files are ordinary text files containing comments, labels,
-and statements. Blank lines are ignored.
-Comments are denoted by leading ``#''
-characters. Some statements (those which do not end with an
-``extended string'' argument; see below) can also have trailing
-comments.
-.PP
-.I Labels
-begin in column one and are ended by colons (:). A label
-specifies a state name. All lines between a pair of labels are
-the statements for a single state.
-.PP
-Processing always begins at the head of the script (no leading
-state name is necessary).
-.PP
-.I Statements
-are divided into two categories, ``action'' and ``expect''.
-When a state is entered, all of its actions are performed in the
-order in which they appear in the file.
-.PP
-A
-.I transition
-to another state may occur for any of three reasons:
-.IP (1) 5
-One of the actions may cause a transition to
-another state, in which case the rest of the
-current state's actions are skipped.
-Processing resumes with the first action
-statement of the new state.
-.IP (2) 5
-If none of the actions cause a state
-transition, and there are no expects in the
-state, processing ``falls through'' to the next
-state in the file.
-.IP (3) 5
-If none of the actions cause a state
-transition, but there are expects in the
-state, the state machine pauses until one of
-the expects is ``satisfied''. It then transitions
-to the state named in the expect
-statement.
-.PP
-Finally, there are two action statements which, when executed,
-cause the script to exit.
-.SH "SCRIPT FILE STATEMENTS"
-This section describes all of the statements that may appear in script
-files, except for a few special action statements. Those are described
-in a later section, ``Overriding Defaults''.
-.PP
-Some statements accept one or two arguments, referred to in the
-following descriptions as
-.IR int ", " ns ", " str ", or "
-.IR xstr ", to"
-indicate whether the argument is an integer, a new state name, a
-string, or an ``extended string'' (described in a later section).
-.PP
-For all statements that accept two arguments, the first is the
-name of a new state, and the second specifies a condition or
-reason for changing to the new state.
-.SS "Termination And Informational Statements"
-These statements are used to place entries into the Taylor UUCP
-.I Log
-file, and to cause
-.I xchat
-to exit with successful or failure status. It is also possible to open a
-separate
-.I debug
-log file and control the level of tracing and error reporting that will go
-into that log file. This is very useful in debugging
-.I xchat
-scripts.
-.br
-.ta 1.0i 1.5i 2.0i
-.TP 2.0i
-.B failed
-Exit script with ``failed'' status. This causes
-.I xchat
-to exit with status 0.
-.TP 2.0i
-.B success
-Exit script with ``success'' status. This causes
-.I xchat
-to exit with status 1.
-.TP 2.0i
-.BI "log " xstr
-Send informational message
-.I xstr
-to standard error. When used with Taylor UUCP, this is the
-.I Log
-file for the
-.I uucico
-program.
-.TP 2.0i
-.BI "logerr " xstr
-Send message
-.I xstr
-to standard error, with ``ERROR:'' indicator. When used
-with Taylor UUCP, this is the
-.I Log
-file for the
-.I uucico
-program.
-.TP 2.0i
-.BI "dbgfile " xstr
-Open script debugging file
-.I xstr.
-If
-.I xstr
-begins with ``/'', it is assumed to be an absolute path name for the
-debugging file. If not, then a configuration-dependent default directory
-path (usually
-.B "/usr/spool/uucp"
-) is prepended to
-.I xstr.
-Normally the default path is that of the directory where Taylor UUCP
-puts its log files.
-The debugging file is used to capture a detailed log of the data sent
-and received, errors encountered, and a trace of script execution.
-The various types of logging are controlled by the
-.I "debug mask,"
-described next.
-.B Note:
-A new log file is created each time
-.I xchat
-runs. Use the
-.B log
-and
-.B loge
-commands to log
-continuous information onto standard out, which is connected
-to the Taylor UUCP
-.I Log
-file when
-.I xchat
-is run by the Taylor
-.I uucico.
-.TP 2.0i
-.BI "dbgset " int
-Set the bits specified in
-.I int
-in the debugging mask. The value in
-.I int
-is ``or''ed into the mask. Set bit 0 (value \= 1) for error messages,
-bit 1 (value \= 2) for dial, login and init errors, bit 2 (value \= 4)
-for dial, login and init trace with character I/O, and bit 3 (value \= 8)
-for script processing internals. Normally, you will just turn it all on
-with a value of 15.
-.TP 2.0i
-.BI "dbgclr " int
-Clear the bits specified in
-.I int
-from the debugging mask.
-.TP 2.0i
-.BI "debug " xstr
-Write
-.I
-xstr
-into the debug log. The entry will be enclosed in angle brackets.
-.TP 2.0i
-.BI "debuge " xstr
-Write
-.I xstr
-into the debug log with ``ERROR: '' prepended. The entry will be enclosed
-in angle brackets.
-.SS "Sending Data"
-These statements are used to transmit data to standard out (the tty or TCP
-port when used with Taylor UUCP).
-.I
-No implied carriage returns are sent.
-You must include a \\r if you want a carriage return in the string
-sent by the
-.B send
-command. If you want a return sent after
-.B dial
-or
-.B sendstr,
-you must send it with a separate
-.B send
-command.
-.TP 2.0i
-.B dial
-Send the string previously set by the
-.B telno
-command to the serial port.
-.B W
-and
-.B P
-characters in the phone number are
-converted as described under
-.B
-Dial Strings,
-below. This statement also sets a default
-timeout value, as described under the
-.B timeout
-statement.
-.TP 2.0i
-.BI "send " xstr
-Send the string
-.I xstr
-to the serial port.
-.TP 2.0i
-.BI "sendstr " int
-The argument of this statement is a digit from 0
-through 7. Send the corresponding string
-parameter as passed to
-.I xchat
-following the script file name. The parameter is interpreted
-as an extended string.
-.SS "Special Terminal Control Statements"
-These statements are used to cause the terminal port to perform some special action, or to change the mode of the port.
-.I
-The modes of the port are restored to their original settings
-.I
-by xchat before it exits.
-.TP 2.0i
-.B flush
-Flush the terminal port's input buffer.
-.TP 2.0i
-.B break
-Send a break signal.
-.TP 2.0i
-.B hangup
-Momentarily drop Data Terminal Ready (DTR) on the
-serial port, causing the modem to hang up. (Not
-usually needed, since
-.I uucico
-does this at the end of each call.)
-.TP 2.0i
-.B 7bit
-Change the port to strip incoming characters to 7 bits.
-.I
-This is the default mode.
-This mode
-is implied when the port has parity enabled, since parity characters
-are 7-bits wide.
-.TP 2.0i
-.B 8bit
-Change the port to allow incoming 8-bit characters to be passed
-to the script processor. This mode has no effect if parity is
-enabled, since parity characters are 7-bits wide.
-.TP 2.0i
-.B nopar
-Change the port to 8-bits, no parity.
-.I
-This is the default mode.
-.TP 2.0i
-.B evenpar
-Change the port to 7-bits, even parity.
-.I
-Incoming characters with parity errors are discarded.
-.TP 2.0i
-.B oddpar
-Change the port to 7-bits, odd parity.
-.I
-Incoming characters with parity errors are discarded.
-.SS "Counting, Branching, Timing and Testing Statements"
-These statements are used to control the flow of the
-.I xchat
-script itself, including branching, delays, and counter manipulation.
-.TP 2.0i
-.BI "sleep " int
-Delay for
-.I int
-milliseconds.
-.TP 2.0i
-.B zero
-Clear the counter.
-.TP 2.0i
-.B count
-Add one to the counter.
-.TP 2.0i
-.BI "ifgtr " "ns int"
-Go to state
-.I ns
-if counter greater than
-.I int.
-.TP 2.0i
-.BI "goto " ns
-Go to state
-.I ns
-unconditionally.
-.TP 2.0i
-.BI "ifstr " "ns int"
-Go to state
-.I ns
-if string parameter
-.I int
-is nonempty.
-.TP 2.0i
-.BI "ifnstr " "ns int"
-Go to state
-.I ns
-if string parameter
-.I int
-is empty.
-.TP 2.0i
-.BI "ifblind " ns
-Change to state
-.I ns
-if the port is ``blind'' without carrier (CD) asserted.
-.I
-This is not yet implemented, the test always fails.
-.TP 2.0i
-.BI "ifblgtr " "ns int"
-Change to state
-.I ns
-if the port is ``blind'' without carrier (CD) asserted, and counter
-is greater then
-.I int.
-.I
-This is not yet implemented, the test always fails.
-.SS "Expect Statements"
-Expect statements are usually the last statements that appear in a
-given state, though in fact they can appear anywhere within the
-state. Even if they appear at the beginning, the script processor
-always does all of the action statements first. As a practical
-matter, the order of these statements is not significant; they are
-all interpreted ``in parallel''.
-.TP 2.0i
-.BI "expect " "ns xstr"
-Change to state
-.I ns
-if the string specified by
-.I xstr
-is received from standard input (usually the serial port).
-Case is significant, but high-order bits are not
-checked.
-.TP 2.0i
-.BI "expectstr " "ns int"
-Change to state
-.I ns
-if the string specified in parameter
-.I int
-is received from standard input (usually the serial port).
-.I int
-must be in the range 0 to 7.
-Case is significant, but high-order bits are not
-checked.
-Useful where a prompt can change in different dial-in lines.
-.TP 2.0i
-.BI "ifcarr " ns
-Change to state
-.I ns
-if Carrier Detect (CD) is true.
-.I
-Not currently implemented. Always changes state.
-.TP 2.0i
-.BI "ifhang " ns
-Change to state
-.I ns
-if a data set hangup occurs (SIGHUP signal received).
-.TP 2.0i
-.BI "timeout " "ns int"
-Change to state
-.I ns
-if the time (in milliseconds)
-given by
-.I int
-has elapsed without satisfying any
-expects. If the time specified is 0, a default
-timeout value (calculated from the length and
-other characteristics of the most recent dial
-string) is used.
-.SH "SCRIPT PROCESSING DETAILS"
-.SS "Extended Strings"
-In the statements that accept string arguments, the strings are
-interpreted as
-.I
-extended strings.
-Extended strings begin with
-the first nonblank character and continue, including all imbedded
-and trailing blanks and other whitespace, until (but not
-including) the end of the line in the script file. (There is no
-provision for line continuation.) No trailing spaces should be
-present between the last ``desired'' character of the string and the
-end of the line, as they will be included in the stored string and
-sent or expected, just as they appear in the script file. And,
-obviously, no trailing comments are permitted! They will just be
-stored as part of the string.
-.PP
-Within an extended string, the following ``escape sequences'' will
-be converted as indicated before being sent or expected:
-.br
-.nf
-.in +0.5i
-\fB\\d\fR EOT character (control-D)
-\fB\\N\fR null character
-\fB\\n\fR line feed
-\fB\\r\fR carriage return
-\fB\\s\fR space
-\fB\\t\fR tab
-\fB\\\-\fR hyphen
-\fB\\\\\fR backslash
-\fB\\ooo\fR character with value ooo (in octal)
-.in -0.5i
-.fi
-.PP
-Since extended strings in scripts can include embedded spaces,
-tabs, etc., these escape sequences are only required in strings
-appearing in systems entries, though they may be used in script
-files to improve readability.
-.PP
-The octal-character specification (\\ooo) may have from one to
-three octal digits; it is terminated either after the third digit
-or when a non-octal character is encountered. But if you want to
-specify one of these followed by something that happens to be a
-valid octal character (for example, a control-A followed by a 7)
-make sure to include all three digits after the \\ . So \\0017
-would become a control-A followed by the Ascii character ``7'', but
-\\17 or \\017 would become a control-Y (decimal value 25). \\1S
-would convert to a control-A followed by an ``S''.
-.PP
-Extended strings are stored without a trailing carriage return
-unless one is explicitly present in the string (via \\r).
-.SS "String Parameters"
-The
-.B sendstr
-statement sends (after conversion from extended string
-format) one of the parameters given on the
-.I xchat
-command line following the script file name.
-The parameter is selected by the integer
-argument of the statement.
-.PP
-This allows ``generic'' script files to serve
-for many different systems; the string parameters
-provide the phone number, username, password, etc. Character
-substitutions described under ``extended strings'' above are
-performed on these strings.
-.PP
-The ifstr and ifnstr statements allow further generality in script
-files, by testing whether a particular parameter is present in the
-systems entry. For example, a single script can be
-used both for those systems that require a password and
-those that do not. The password is specified as the last argument
-in the
-.xchat
-command; the script can test for this
-parameter's existence and skip the password sequence if
-the parameter is empty.
-.SS "``Wait'' And ``Pause'' Characters In Dial Strings"
-An additional conversion is performed on dial strings. Dial strings
-are interpreted as extended strings. Then the characters
-.B W
-and
-.B P
-within a dial string are interpreted as ``wait for dial
-tone'' and ``pause'', and may be converted to other characters. By
-default,
-.B W
-is left alone, and
-.B P
-is converted to a comma (,);
-these are appropriate for Hayes-type modems. The script may
-specify other substitutions (see below).
-.PP
-.B NOTE:
-The Taylor UUCP documentation states that the ``wait'' and ``pause''
-characters are ``='' and ``-'', respectively. These are actual characters
-understood by some modems. When using
-.I xchat
-you should put
-.B W
-and
-.B P
-in the dial strings you specify in the Taylor configuration files.
-This way, the
-.I xchat
-processor can make the substitution appropriate for the particular
-modem in use. Make a separate
-.I xchat
-script for each modem type, e.g.,
-.I "dial.hayes"
-and specify the translation there. This way, the phone number strings
-in the Taylor configuration files can be used with a variety of modems.
-.SS "Default Timeouts For Dial Strings"
-When a
-.B dial
-statement is executed, a default timeout value is set.
-This is the timeout value used by a subsequent timeout statement
-if the statement specifies a timeout value of 0.
-.PP
-The default timeout is given by:
-.br
-.nf
-.in +2
-\fIctime\fR + (\fIndigits\fR * \fIdgttime\fR) + (\fInwchar\fR * \fIwtime\fR) + (\fInpchar\fR * \fI ptime\fR)
-.in -2
-.fi
-.PP
-where
-.I
-ndigits, nwchar,
-and
-.I npchar
-are the number of digits, wait characters, and pause characters in
-the dial string, and
-.I ctime, dgttime, wtime,
-and
-.I ptime
-are 45 seconds, 0.1 seconds, 10 seconds, and 2 seconds,
-respectively.
-All of these times may be changed as specified below under
-``Overriding Defaults.''
-.SS "Trailing Carriage Returns Not Assumed"
-In the
-.B dial
-and
-.B sendstr
-statements, the dial string or
-parameter is sent with no trailing carriage return;
-if a carriage return must be sent after one of these, a separate
-send statement must provide it.
-.SH "OVERRIDING DEFAULTS"
-The script processor sets several default values. The following
-statements, which override these defaults, may be useful in
-certain circumstances.
-.TP 2.0i
-.BI "chrdly " int
-Since many modems cannot accept dialing commands
-at full ``computer speed'', the script processor
-sends all strings with a brief inter-character
-delay. This statement specifies the delay time,
-in milliseconds. The default is 100 (0.1 second).
-.TP 2.0i
-.BI "pchar " str
-Specifies the character to which
-.BR P s
-in the
-dial string should be converted. Default is
-``,'', for use with Hayes-type modems.
-.TP 2.0i
-.BI "ptime " int
-Specifies the time, in milliseconds, to allow in
-the default timeout for each pause character in
-the dial string. Default is 2000 (2 seconds).
-.TP 2.0i
-.BI "wchar " str
-Specifies the character to which
-.BR W s
-in the
-dial string should be converted. Default is
-``W'', for Hayes modems.
-.TP 2.0i
-.BI "wtime " int
-Specifies the time, in milliseconds, to allow in
-the default timeout for each wait-for-dialtone
-character in the dial string. Default is 10000
-(10 seconds).
-.TP 2.0i
-.BI "dgttime " int
-Specifies the time, in milliseconds, to allow in
-the default timeout for each digit character in
-the dial string. Default is 100 (0.1 second).
-.TP 2.0i
-.BI "ctime " int
-Specifies the time, in milliseconds, to allow in
-the default timeout for carrier to appear after
-the dial string is sent. Default is 45000 (45
-seconds).
-.SH "SEE ALSO"
-uucico(8) for Taylor UUCP, and documentation for Taylor UUCP.
-.SH AUTHOR
-Robert B. Denny (denny@alisa.com)
-.SH CONTRIBUTORS
-Daniel Hagerty (hag@eddie.mit.edu)
-.SH HISTORY
-This program is an adaptation of the dial/login script processing
-code that is a part of DECUS UUCP for VAX/VMS, written by Jamie
-Hanrahan, et. al.
-.SH BUGS
-This version (1.1) does not support BSD terminal facilities. Anyone
-volunteer to add this?
-
diff --git a/gnu/libexec/uucp/cu/Makefile b/gnu/libexec/uucp/cu/Makefile
deleted file mode 100644
index b58cd0c2..0000000
--- a/gnu/libexec/uucp/cu/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# Makefile for cu
-# $Id$
-
-BINDIR= $(bindir)
-BINOWN= $(owner)
-BINGRP= dialer
-BINMODE= 6555
-
-PROG= cu
-SRCS= cu.c prot.c log.c chat.c conn.c copy.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -DVERSION=\"$(VERSION)\"
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../common_sources
diff --git a/gnu/libexec/uucp/cu/cu.1 b/gnu/libexec/uucp/cu/cu.1
deleted file mode 100644
index 910ab0a..0000000
--- a/gnu/libexec/uucp/cu/cu.1
+++ /dev/null
@@ -1,310 +0,0 @@
-''' $Id$
-.TH cu 1 "Taylor UUCP 1.06"
-.SH NAME
-cu \- Call up another system
-.SH SYNOPSIS
-.B cu
-[ options ] [ system | phone | "dir" ]
-.SH DESCRIPTION
-The
-.I cu
-command is used to call up another system and act as a dial in
-terminal. It can also do simple file transfers with no error
-checking.
-
-.I cu
-takes a single argument, besides the options. If the argument is the
-string "dir" cu will make a direct connection to the port. This may
-only be used by users with write access to the port, as it permits
-reprogramming the modem.
-
-Otherwise, if the argument begins with a digit, it is taken to be a
-phone number to call. Otherwise, it is taken to be the name of a
-system to call. The
-.B \-z
-or
-.B \-\-system
-option may be used to name a system beginning with a digit, and the
-.B \-c
-or
-.B \-\-phone
-option may be used to name a phone number that does not begin with a
-digit.
-
-.I cu
-locates a port to use in the UUCP configuration files. If a simple
-system name is given, it will select a port appropriate for that
-system. The
-.B \-p, \-\-port, \-l, \-\-line, \-s
-and
-.B \-\-speed
-options may be used to control the port selection.
-
-When a connection is made to the remote system,
-.I cu
-forks into two processes. One reads from the port and writes to the
-terminal, while the other reads from the terminal and writes to the
-port.
-
-.I cu
-provides several commands that may be used during the conversation.
-The commands all begin with an escape character, initially
-.B ~
-(tilde). The escape character is only recognized at the beginning of
-a line. To send an escape character to the remote system at the start
-of a line, it must be entered twice. All commands are either a single
-character or a word beginning with
-.B %
-(percent sign).
-
-.I cu
-recognizes the following commands:
-
-.TP 5
-.B ~.
-Terminate the conversation.
-.TP 5
-.B ~! command
-Run command in a shell. If command is empty, starts up a shell.
-.TP 5
-.B ~$ command
-Run command, sending the standard output to the remote system.
-.TP 5
-.B ~| command
-Run command, taking the standard input from the remote system.
-.TP 5
-.B ~+ command
-Run command, taking the standard input from the remote system and
-sending the standard output to the remote system.
-.TP 5
-.B ~#, ~%break
-Send a break signal, if possible.
-.TP 5
-.B ~c directory, ~%cd directory
-Change the local directory.
-.TP 5
-.B ~> file
-Send a file to the remote system. This just dumps the file over the
-communication line. It is assumed that the remote system is expecting
-it.
-.TP 5
-.B ~<
-Receive a file from the remote system. This prompts for the local
-file name and for the remote command to execute to begin the file
-transfer. It continues accepting data until the contents of the
-.B eofread
-variable are seen.
-.TP 5
-.B ~p from to, ~%put from to
-Send a file to a remote Unix system. This runs the appropriate
-commands on the remote system.
-.TP 5
-.B ~t from to, ~%take from to
-Retrieve a file from a remote Unix system. This runs the appropriate
-commands on the remote system.
-.TP 5
-.B ~s variable value
-Set a
-.I cu
-variable to the given value. If value is not given, the variable is
-set to
-.B true.
-.TP 5
-.B ~! variable
-Set a
-.I cu
-variable to
-.B false.
-.TP 5
-.B ~z
-Suspend the cu session. This is only supported on some systems. On
-systems for which ^Z may be used to suspend a job,
-.B ~^Z
-will also suspend the session.
-.TP 5
-.B ~%nostop
-Turn off XON/XOFF handling.
-.TP 5
-.B ~%stop
-Turn on XON/XOFF handling.
-.TP 5
-.B ~v
-List all the variables and their values.
-.TP 5
-.B ~?
-List all commands.
-
-.I cu
-also supports several variables. They may be listed with the
-.B ~v
-command, and set with the
-.B ~s
-or
-.B ~!
-commands.
-
-.TP 5
-.B escape
-The escape character. Initially
-.B ~
-(tilde).
-.TP 5
-.B delay
-If this variable is true,
-.I cu
-will delay for a second after recognizing the escape character before
-printing the name of the local system. The default is true.
-.TP 5
-.B eol
-The list of characters which are considered to finish a line. The
-escape character is only recognized after one of these is seen. The
-default is carriage return, ^U, ^C, ^O, ^D, ^S, ^Q, ^R.
-.TP 5
-.B binary
-Whether to transfer binary data when sending a file. If this is
-false, then newlines in the file being sent are converted to carriage
-returns. The default is false.
-.TP 5
-.B binary-prefix
-A string used before sending a binary character in a file transfer, if
-the
-.B binary
-variable is true. The default is ^V.
-.TP 5
-.B echo-check
-Whether to check file transfers by examining what the remote system
-echoes back. This probably doesn't work very well. The default is
-false.
-.TP 5
-.B echonl
-The character to look for after sending each line in a file. The
-default is carriage return.
-.TP 5
-.B timeout
-The timeout to use, in seconds, when looking for a character, either
-when doing echo checking or when looking for the
-.B echonl
-character. The default is 30.
-.TP 5
-.B kill
-The character to use delete a line if the echo check fails. The
-default is ^U.
-.TP 5
-.B resend
-The number of times to resend a line if the echo check continues to
-fail. The default is 10.
-.TP 5
-.B eofwrite
-The string to write after sending a file with the
-.B ~>
-command. The default is ^D.
-.TP 5
-.B eofread
-The string to look for when receiving a file with the
-.B ~<
-command. The default is $, which is intended to be a typical shell
-prompt.
-.TP 5
-.B verbose
-Whether to print accumulated information during a file transfer. The
-default is true.
-.SH OPTIONS
-The following options may be given to
-.I cu.
-.TP 5
-.B \-e, \-\-parity=even
-Use even parity.
-.TP 5
-.B \-o, \-\-parity=odd
-Use odd parity.
-.TP 5
-.B \-\-parity=none
-Use no parity. No parity is also used if both
-.B \-e
-and
-.B \-o
-are given.
-.TP 5
-.B \-h, \-\-halfduplex
-Echo characters locally (half-duplex mode).
-.TP 5
-.B \-\-nostop
-Turn off XON/XOFF handling (it is on by default).
-.TP 5
-.B \-E char, \-\-escape char
-Set the escape character. Initially
-.B ~
-(tilde). To eliminate the escape character, use
-.B -E ''.
-.TP 5
-.B \-z system, \-\-system system
-The system to call.
-.TP 5
-.B \-c phone-number, \-\-phone phone-number
-The phone number to call.
-.TP 5
-.B \-p port, \-\-port port
-Name the port to use.
-.TP 5
-.B \-a port
-Equivalent to
-.B \-\-port port.
-.TP 5
-.B \-l line, \-\-line line
-Name the line to use by giving a device name. This may be used to
-dial out on ports that are not listed in the UUCP configuration files.
-Write access to the device is required.
-.TP 5
-.B \-s speed, \-\-speed speed
-The speed (baud rate) to use.
-.TP 5
-.B \-#
-Where # is a number, equivalent to
-.B \-\-speed #.
-.TP 5
-.B \-n, \-\-prompt
-Prompt for the phone number to use.
-.TP 5
-.B \-d
-Enter debugging mode. Equivalent to
-.B \-\-debug all.
-.TP 5
-.B \-x type, \-\-debug type
-Turn on particular debugging types. The following types are
-recognized: abnormal, chat, handshake, uucp-proto, proto, port,
-config, spooldir, execute, incoming, outgoing. Only abnormal, chat,
-handshake, port, config, incoming and outgoing are meaningful for
-.I cu.
-
-Multiple types may be given, separated by commas, and the
-.B \-\-debug
-option may appear multiple times. A number may also be given, which
-will turn on that many types from the foregoing list; for example,
-.B \-\-debug 2
-is equivalent to
-.B \-\-debug abnormal,chat.
-.B \-\-debug all
-may be used to turn on all debugging options.
-.TP 5
-.B \-I file, \-\-config file
-Set configuration file to use. This option may not be available,
-depending upon how
-.I cu
-was compiled.
-.TP 5
-.B \-v, \-\-version
-Report version information and exit.
-.TP 5
-.B \-\-help
-Print a help message and exit.
-.SH BUGS
-This program does not work very well.
-.SH FILES
-The file name may be changed at compilation time, so this is only an
-approximation.
-
-.br
-/etc/uucp/config - Configuration file.
-.SH AUTHOR
-Ian Lance Taylor
-<ian@airs.com>
diff --git a/gnu/libexec/uucp/cu/cu.c b/gnu/libexec/uucp/cu/cu.c
deleted file mode 100644
index eb5d411..0000000
--- a/gnu/libexec/uucp/cu/cu.c
+++ /dev/null
@@ -1,2186 +0,0 @@
-/* cu.c
- Call up a remote system.
-
- Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char cu_rcsid[] = "$Id$";
-#endif
-
-#include "cu.h"
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "prot.h"
-#include "system.h"
-#include "sysdep.h"
-#include "getopt.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
-
-/* Here are the user settable variables. The user is permitted to
- change these while running the program, using ~s. */
-
-/* The escape character used to introduce a special command. The
- escape character is the first character of this string. */
-const char *zCuvar_escape = "~";
-
-/* Whether to delay for a second before printing the host name after
- seeing an escape character. */
-boolean fCuvar_delay = TRUE;
-
-/* The input characters which finish a line. The escape character is
- only recognized following one of these characters. The default is
- carriage return, ^U, ^C, ^O, ^D, ^S, ^Q, ^R, which I got from the
- Ultrix /etc/remote file. */
-const char *zCuvar_eol = "\r\025\003\017\004\023\021\022";
-
-/* Whether to transfer binary data (nonprintable characters other than
- newline and tab) when sending a file. If this is FALSE, then
- newline is changed to carriage return. */
-boolean fCuvar_binary = FALSE;
-
-/* A prefix string to use before sending a binary character from a
- file; this is only used if fCuvar_binary is TRUE. The default is
- ^V. */
-const char *zCuvar_binary_prefix = "\026";
-
-/* Whether to check for echoes of characters sent when sending a file.
- This is ignored if fCuvar_binary is TRUE. */
-boolean fCuvar_echocheck = FALSE;
-
-/* A character to look for after each newline is sent when sending a
- file. The character is the first character in this string, except
- that a '\0' means that no echo check is done. */
-const char *zCuvar_echonl = "\r";
-
-/* The timeout to use when looking for an character. */
-int cCuvar_timeout = 30;
-
-/* The character to use to kill a line if an echo check fails. The
- first character in this string is sent. The default is ^U. */
-const char *zCuvar_kill = "\025";
-
-/* The number of times to try resending a line if the echo check keeps
- failing. */
-int cCuvar_resend = 10;
-
-/* The string to send at the end of a file sent with ~>. The default
- is ^D. */
-const char *zCuvar_eofwrite = "\004";
-
-/* The string to look for to finish a file received with ~<. For tip
- this is a collection of single characters, but I don't want to do
- that because it means that there are characters which cannot be
- received. The default is a guess at a typical shell prompt. */
-const char *zCuvar_eofread = "$";
-
-/* Whether to provide verbose information when sending or receiving a
- file. */
-boolean fCuvar_verbose = TRUE;
-
-/* The table used to give a value to a variable, and to print all the
- variable values. */
-
-static const struct uuconf_cmdtab asCuvars[] =
-{
- { "escape", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_escape, NULL },
- { "delay", UUCONF_CMDTABTYPE_BOOLEAN, (pointer) &fCuvar_delay, NULL },
- { "eol", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_eol, NULL },
- { "binary", UUCONF_CMDTABTYPE_BOOLEAN, (pointer) &fCuvar_binary, NULL },
- { "binary-prefix", UUCONF_CMDTABTYPE_STRING,
- (pointer) &zCuvar_binary_prefix, NULL },
- { "echocheck", UUCONF_CMDTABTYPE_BOOLEAN,
- (pointer) &fCuvar_echocheck, NULL },
- { "echonl", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_echonl, NULL },
- { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cCuvar_timeout, NULL },
- { "kill", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_kill, NULL },
- { "resend", UUCONF_CMDTABTYPE_INT, (pointer) &cCuvar_resend, NULL },
- { "eofwrite", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_eofwrite, NULL },
- { "eofread", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_eofread, NULL },
- { "verbose", UUCONF_CMDTABTYPE_BOOLEAN, (pointer) &fCuvar_verbose, NULL },
- { NULL, 0, NULL, NULL}
-};
-
-/* The string printed at the initial connect. */
-#if ANSI_C
-#define ZCONNMSG "\aConnected."
-#else
-#define ZCONNMSG "Connected."
-#endif
-
-/* The string printed when disconnecting. */
-#if ANSI_C
-#define ZDISMSG "\aDisconnected."
-#else
-#define ZDISMSG "Disconnected."
-#endif
-
-/* Local variables. */
-
-/* The string we print when the user is once again connected to the
- port after transferring a file or taking some other action. */
-static const char abCuconnected[]
-#if ANSI_C
- = "\a[connected]";
-#else
- = "[connected]";
-#endif
-
-/* Global uuconf pointer. */
-static pointer pCuuuconf;
-
-/* Connection. */
-static struct sconnection *qCuconn;
-
-/* Whether to close the connection. */
-static boolean fCuclose_conn;
-
-/* Dialer used to dial out. */
-static struct uuconf_dialer *qCudialer;
-
-/* Whether we need to restore the terminal. */
-static boolean fCurestore_terminal;
-
-/* Whether we are doing local echoing. */
-static boolean fCulocalecho;
-
-/* Whether we need to call fsysdep_cu_finish. */
-static boolean fCustarted;
-
-/* Whether ZCONNMSG has been printed yet. */
-static boolean fCuconnprinted = FALSE;
-
-/* A structure used to pass information to icuport_lock. */
-struct sconninfo
-{
- boolean fmatched;
- boolean flocked;
- struct sconnection *qconn;
- const char *zline;
-};
-
-/* Local functions. */
-
-static void ucuusage P((void));
-static void ucuhelp P((void));
-static void ucuabort P((void));
-static void uculog_start P((void));
-static void uculog_end P((void));
-static int icuport_lock P((struct uuconf_port *qport, pointer pinfo));
-static boolean fcudo_cmd P((pointer puuconf, struct sconnection *qconn,
- int bcmd));
-static boolean fcuset_var P((pointer puuconf, char *zline));
-static int icuunrecogvar P((pointer puuconf, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int icuunrecogfn P((pointer puuconf, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static void uculist_vars P((void));
-static void uculist_fns P((const char *zescape));
-static boolean fcudo_subcmd P((pointer puuconf, struct sconnection *qconn,
- char *zline));
-static boolean fcusend_buf P((struct sconnection *qconn, const char *zbuf,
- size_t cbuf));
-
-#define ucuputs(zline) \
- do { if (! fsysdep_terminal_puts (zline)) ucuabort (); } while (0)
-
-/* Long getopt options. */
-static const struct option asCulongopts[] =
-{
- { "phone", required_argument, NULL, 'c' },
- { "escape", required_argument, NULL, 'E' },
- { "parity", required_argument, NULL, 2 },
- { "halfduplex", no_argument, NULL, 'h' },
- { "prompt", no_argument, NULL, 'n' },
- { "line", required_argument, NULL, 'l' },
- { "port", required_argument, NULL, 'p' },
- { "speed", required_argument, NULL, 's' },
- { "baud", required_argument, NULL, 's' },
- { "mapcr", no_argument, NULL, 't' },
- { "nostop", no_argument, NULL, 3 },
- { "system", required_argument, NULL, 'z' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'x' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- /* -c: phone number. */
- char *zphone = NULL;
- /* -e: even parity. */
- boolean feven = FALSE;
- /* -l: line. */
- char *zline = NULL;
- /* -n: prompt for phone number. */
- boolean fprompt = FALSE;
- /* -o: odd parity. */
- boolean fodd = FALSE;
- /* -p: port name. */
- const char *zport = NULL;
- /* -s: speed. */
- long ibaud = 0L;
- /* -t: map cr to crlf. */
- boolean fmapcr = FALSE;
- /* -z: system. */
- const char *zsystem = NULL;
- /* --nostop: turn off XON/XOFF. */
- enum txonxoffsetting txonxoff = XONXOFF_ON;
- /* -I: configuration file name. */
- const char *zconfig = NULL;
- int iopt;
- pointer puuconf;
- int iuuconf;
- const char *zlocalname;
- int i;
- struct uuconf_system ssys;
- const struct uuconf_system *qsys = NULL;
- boolean flooped;
- struct uuconf_port sport;
- struct sconnection sconn;
- struct sconninfo sinfo;
- long ihighbaud;
- struct uuconf_dialer sdialer;
- struct uuconf_dialer *qdialer;
- char bcmd;
-
- zProgram = argv[0];
-
- /* We want to accept -# as a speed. It's easiest to look through
- the arguments, replace -# with -s#, and let getopt handle it. */
- for (i = 1; i < argc; i++)
- {
- if (argv[i][0] == '-'
- && isdigit (BUCHAR (argv[i][1])))
- {
- size_t clen;
- char *z;
-
- clen = strlen (argv[i]);
- z = zbufalc (clen + 2);
- z[0] = '-';
- z[1] = 's';
- memcpy (z + 2, argv[i] + 1, clen);
- argv[i] = z;
- }
- }
-
- while ((iopt = getopt_long (argc, argv, "a:c:deE:hnI:l:op:s:tvx:z:",
- asCulongopts, (int *) NULL)) != EOF)
- {
- switch (iopt)
- {
- case 'c':
- /* Phone number. */
- zphone = optarg;
- break;
-
- case 'd':
- /* Set debugging level to maximum. */
-#if DEBUG > 1
- iDebug = DEBUG_MAX;
-#endif
- break;
-
- case 'e':
- /* Even parity. */
- feven = TRUE;
- break;
-
- case 'E':
- /* Escape character. */
- zCuvar_escape = optarg;
- break;
-
- case 'h':
- /* Local echo. */
- fCulocalecho = TRUE;
- break;
-
- case 'n':
- /* Prompt for phone number. */
- fprompt = TRUE;
- break;
-
- case 'l':
- /* Line name. */
- zline = optarg;
- break;
-
- case 'o':
- /* Odd parity. */
- fodd = TRUE;
- break;
-
- case 'p':
- case 'a':
- /* Port name (-a is for compatibility). */
- zport = optarg;
- break;
-
- case 's':
- /* Speed. */
- ibaud = strtol (optarg, (char **) NULL, 10);
- break;
-
- case 't':
- /* Map cr to crlf. */
- fmapcr = TRUE;
- break;
-
- case 'z':
- /* System name. */
- zsystem = optarg;
- break;
-
- case 'I':
- /* Configuration file name. */
- if (fsysdep_other_config (optarg))
- zconfig = optarg;
- break;
-
- case 'x':
-#if DEBUG > 1
- /* Set debugging level. */
- iDebug |= idebug_parse (optarg);
-#endif
- break;
-
- case 'v':
- /* Print version and exit. */
- fprintf
- (stderr,
- "%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zProgram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 2:
- /* --parity. */
- if (strncmp (optarg, "even", strlen (optarg)) == 0)
- feven = TRUE;
- else if (strncmp (optarg, "odd", strlen (optarg)) == 0)
- fodd = TRUE;
- else if (strncmp (optarg, "none", strlen (optarg)) == 0)
- {
- feven = TRUE;
- fodd = TRUE;
- }
- else
- {
- fprintf (stderr, "%s: --parity requires even, odd or none\n",
- zProgram);
- ucuusage ();
- }
- break;
-
- case 3:
- /* --nostop. */
- txonxoff = XONXOFF_OFF;
- break;
-
- case 1:
- /* --help. */
- ucuhelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found and flag set. */
- break;
-
- default:
- ucuusage ();
- /*NOTREACHED*/
- }
- }
-
- /* There can be one more argument, which is either a system name, a
- phone number, or "dir". We decide which it is based on the first
- character. To call a UUCP system whose name begins with a digit,
- or one which is named "dir", you must use -z. */
- if (optind != argc)
- {
- if (optind != argc - 1
- || zsystem != NULL
- || zphone != NULL)
- {
- fprintf (stderr, "%s: too many arguments\n", zProgram);
- ucuusage ();
- }
- if (strcmp (argv[optind], "dir") != 0)
- {
- if (isdigit (BUCHAR (argv[optind][0])))
- zphone = argv[optind];
- else
- zsystem = argv[optind];
- }
- }
-
- /* If the user doesn't give a system, port, line or speed, then
- there's no basis on which to select a port. */
- if (zsystem == NULL
- && zport == NULL
- && zline == NULL
- && ibaud == 0L)
- {
- fprintf (stderr, "%s: must specify system, line, port or speed\n",
- zProgram);
- ucuusage ();
- }
-
- if (fprompt)
- {
- size_t cphone;
-
- printf ("Phone number: ");
- (void) fflush (stdout);
- zphone = NULL;
- cphone = 0;
- if (getline (&zphone, &cphone, stdin) <= 0
- || *zphone == '\0')
- {
- fprintf (stderr, "%s: no phone number entered\n", zProgram);
- exit (EXIT_FAILURE);
- }
- }
-
- iuuconf = uuconf_init (&puuconf, "cu", zconfig);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- pCuuuconf = puuconf;
-
-#if DEBUG > 1
- {
- const char *zdebug;
-
- iuuconf = uuconf_debuglevel (puuconf, &zdebug);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (zdebug != NULL)
- iDebug |= idebug_parse (zdebug);
- }
-#endif
-
- usysdep_initialize (puuconf, INIT_NOCHDIR | INIT_SUID);
-
- iuuconf = uuconf_localname (puuconf, &zlocalname);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- zlocalname = zsysdep_localname ();
- if (zlocalname == NULL)
- exit (EXIT_FAILURE);
- }
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- ulog_fatal_fn (ucuabort);
- pfLstart = uculog_start;
- pfLend = uculog_end;
-
-#ifdef SIGINT
- usysdep_signal (SIGINT);
-#endif
-#ifdef SIGHUP
- usysdep_signal (SIGHUP);
-#endif
-#ifdef SIGQUIT
- usysdep_signal (SIGQUIT);
-#endif
-#ifdef SIGTERM
- usysdep_signal (SIGTERM);
-#endif
-#ifdef SIGPIPE
- usysdep_signal (SIGPIPE);
-#endif
-
- if (zsystem != NULL)
- {
- iuuconf = uuconf_system_info (puuconf, zsystem, &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- ulog (LOG_FATAL, "%s: System not found", zsystem);
- }
- qsys = &ssys;
- }
-
- /* This loop is used if a system is specified. It loops over the
- various alternates until it finds one for which the dial
- succeeds. This is an ugly spaghetti construction, and it should
- be broken up into different functions someday. */
- flooped = FALSE;
- while (TRUE)
- {
- enum tparitysetting tparity;
- enum tstripsetting tstrip;
- long iusebaud;
-
- /* The uuconf_find_port function only selects directly on a port
- name and a speed. To select based on the line name, we use a
- function. If we can't find any defined port, and the user
- specified a line name but did not specify a port name or a
- system or a phone number, then we fake a direct port with
- that line name (we don't fake a port if a system or phone
- number were given because if we fake a port we have no way to
- place a call; perhaps we should automatically look up a
- particular dialer). This permits users to say cu -lttyd0
- without having to put ttyd0 in the ports file, provided they
- have read and write access to the port. */
- sinfo.fmatched = FALSE;
- sinfo.flocked = FALSE;
- sinfo.qconn = &sconn;
- sinfo.zline = zline;
- if (zport != NULL || zline != NULL || ibaud != 0L)
- {
- iuuconf = uuconf_find_port (puuconf, zport, ibaud, 0L,
- icuport_lock, (pointer) &sinfo,
- &sport);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- {
- if (sinfo.flocked)
- {
- (void) fconn_unlock (&sconn);
- uconn_free (&sconn);
- }
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- }
- if (zline == NULL
- || zport != NULL
- || zphone != NULL
- || qsys != NULL)
- {
- if (sinfo.fmatched)
- ulog (LOG_FATAL, "All matching ports in use");
- else
- ulog (LOG_FATAL, "No matching ports");
- }
-
- sport.uuconf_zname = zline;
- sport.uuconf_ttype = UUCONF_PORTTYPE_DIRECT;
- sport.uuconf_zprotocols = NULL;
- sport.uuconf_qproto_params = NULL;
- sport.uuconf_ireliable = 0;
- sport.uuconf_zlockname = NULL;
- sport.uuconf_palloc = NULL;
- sport.uuconf_u.uuconf_sdirect.uuconf_zdevice = NULL;
- sport.uuconf_u.uuconf_sdirect.uuconf_ibaud = ibaud;
-
- if (! fconn_init (&sport, &sconn, UUCONF_PORTTYPE_UNKNOWN))
- ucuabort ();
-
- if (! fconn_lock (&sconn, FALSE))
- ulog (LOG_FATAL, "%s: Line in use", zline);
-
- qCuconn = &sconn;
-
- /* Check user access after locking the port, because on
- some systems shared lines affect the ownership and
- permissions. In such a case ``Line in use'' is more
- clear than ``Permission denied.'' */
- if (! fsysdep_port_access (&sport))
- ulog (LOG_FATAL, "%s: Permission denied", zline);
- }
- iusebaud = ibaud;
- ihighbaud = 0L;
- }
- else
- {
- for (; qsys != NULL; qsys = qsys->uuconf_qalternate)
- {
- if (! qsys->uuconf_fcall)
- continue;
- if (qsys->uuconf_qport != NULL)
- {
- if (fconn_init (qsys->uuconf_qport, &sconn,
- UUCONF_PORTTYPE_UNKNOWN))
- {
- if (fconn_lock (&sconn, FALSE))
- {
- qCuconn = &sconn;
- break;
- }
- uconn_free (&sconn);
- }
- }
- else
- {
- sinfo.fmatched = FALSE;
- sinfo.flocked = FALSE;
- sinfo.qconn = &sconn;
- iuuconf = uuconf_find_port (puuconf, qsys->uuconf_zport,
- qsys->uuconf_ibaud,
- qsys->uuconf_ihighbaud,
- icuport_lock,
- (pointer) &sinfo,
- &sport);
- if (iuuconf == UUCONF_SUCCESS)
- break;
- if (iuuconf != UUCONF_NOT_FOUND)
- {
- if (sinfo.flocked)
- {
- (void) fconn_unlock (&sconn);
- uconn_free (&sconn);
- }
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- }
- }
- }
-
- if (qsys == NULL)
- {
- const char *zrem;
-
- if (flooped)
- zrem = "remaining ";
- else
- zrem = "";
- if (sinfo.fmatched)
- ulog (LOG_FATAL, "%s: All %smatching ports in use",
- zsystem, zrem);
- else
- ulog (LOG_FATAL, "%s: No %smatching ports", zsystem, zrem);
- }
-
- iusebaud = qsys->uuconf_ibaud;
- ihighbaud = qsys->uuconf_ihighbaud;
- }
-
- /* Here we have locked a connection to use. */
- if (! fconn_open (&sconn, iusebaud, ihighbaud, FALSE))
- ucuabort ();
-
- fCuclose_conn = TRUE;
-
- if (FGOT_SIGNAL ())
- ucuabort ();
-
- /* Set up the connection. */
- if (fodd && feven)
- {
- tparity = PARITYSETTING_NONE;
- tstrip = STRIPSETTING_SEVENBITS;
- }
- else if (fodd)
- {
- tparity = PARITYSETTING_ODD;
- tstrip = STRIPSETTING_SEVENBITS;
- }
- else if (feven)
- {
- tparity = PARITYSETTING_EVEN;
- tstrip = STRIPSETTING_SEVENBITS;
- }
- else
- {
- tparity = PARITYSETTING_DEFAULT;
- tstrip = STRIPSETTING_DEFAULT;
- }
-
- if (! fconn_set (&sconn, tparity, tstrip, txonxoff))
- ucuabort ();
-
- if (qsys != NULL)
- zphone = qsys->uuconf_zphone;
-
- if (qsys != NULL || zphone != NULL)
- {
- enum tdialerfound tdialer;
-
- if (! fconn_dial (&sconn, puuconf, qsys, zphone, &sdialer,
- &tdialer))
- {
- if (zport != NULL
- || zline != NULL
- || ibaud != 0L
- || qsys == NULL)
- ucuabort ();
-
- qsys = qsys->uuconf_qalternate;
- if (qsys == NULL)
- ulog (LOG_FATAL, "%s: No remaining alternates", zsystem);
-
- fCuclose_conn = FALSE;
- (void) fconn_close (&sconn, pCuuuconf, qCudialer, FALSE);
- qCuconn = NULL;
- (void) fconn_unlock (&sconn);
- uconn_free (&sconn);
-
- /* Loop around and try another alternate. */
- flooped = TRUE;
- continue;
- }
- if (tdialer == DIALERFOUND_FALSE)
- qdialer = NULL;
- else
- qdialer = &sdialer;
- }
- else
- {
- /* If no system or phone number was specified, we connect
- directly to the modem. We only permit this if the user
- has access to the port, since it permits various
- shenanigans such as reprogramming the automatic
- callbacks. */
- if (! fsysdep_port_access (sconn.qport))
- ulog (LOG_FATAL, "Access to port denied");
- qdialer = NULL;
- if (! fconn_carrier (&sconn, FALSE))
- ulog (LOG_FATAL, "Can't turn off carrier");
- }
-
- break;
- }
-
- qCudialer = qdialer;
-
- if (FGOT_SIGNAL ())
- ucuabort ();
-
- /* Here we have connected, and can start the main cu protocol. The
- program spends most of its time in system dependent code, and
- only comes out when a special command is received from the
- terminal. */
- printf ("%s\n", ZCONNMSG);
- fCuconnprinted = TRUE;
-
- if (! fsysdep_terminal_raw (fCulocalecho))
- ucuabort ();
-
- fCurestore_terminal = TRUE;
-
- if (! fsysdep_cu_init (&sconn))
- ucuabort ();
-
- fCustarted = TRUE;
-
- while (fsysdep_cu (&sconn, &bcmd, zlocalname))
- if (! fcudo_cmd (puuconf, &sconn, bcmd))
- break;
-
- fCustarted = FALSE;
- if (! fsysdep_cu_finish ())
- ucuabort ();
-
- fCurestore_terminal = FALSE;
- (void) fsysdep_terminal_restore ();
-
- (void) fconn_close (&sconn, puuconf, qdialer, TRUE);
- (void) fconn_unlock (&sconn);
- uconn_free (&sconn);
-
- if (fCuconnprinted)
- printf ("\n%s\n", ZDISMSG);
-
- ulog_close ();
-
- usysdep_exit (TRUE);
-
- /* Avoid errors about not returning a value. */
- return 0;
-}
-
-/* Print a usage message and die. */
-
-static void
-ucuusage ()
-{
- fprintf (stderr, "Usage: %s [options] [system or phone-number]\n",
- zProgram);
- fprintf (stderr, "Use %s --help for help\n", zProgram);
- exit (EXIT_FAILURE);
-}
-
-/* Print a help message. */
-
-static void
-ucuhelp ()
-{
- fprintf (stderr,
- "Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- fprintf (stderr,
- "Usage: %s [options] [system or phone-number]\n", zProgram);
- fprintf (stderr,
- " -a,-p,--port port: Use named port\n");
- fprintf (stderr,
- " -l,--line line: Use named device (e.g. tty0)\n");
- fprintf (stderr,
- " -s,--speed,--baud speed, -#: Use given speed\n");
- fprintf (stderr,
- " -c,--phone phone: Phone number to call\n");
- fprintf (stderr,
- " -z,--system system: System to call\n");
- fprintf (stderr,
- " -e: Set even parity\n");
- fprintf (stderr,
- " -o: Set odd parity\n");
- fprintf (stderr,
- " --parity={odd,even}: Set parity\n");
- fprintf (stderr,
- " -E,--escape char: Set escape character\n");
- fprintf (stderr,
- " -h,--halfduplex: Echo locally\n");
- fprintf (stderr,
- " --nostop: Turn off XON/XOFF handling\n");
- fprintf (stderr,
- " -t,--mapcr: Map carriage return to carriage return/linefeed\n");
- fprintf (stderr,
- " -n,--prompt: Prompt for phone number\n");
- fprintf (stderr,
- " -d: Set maximum debugging level\n");
- fprintf (stderr,
- " -x,--debug debug: Set debugging type\n");
-#if HAVE_TAYLOR_CONFIG
- fprintf (stderr,
- " -I,--config file: Set configuration file to use\n");
-#endif /* HAVE_TAYLOR_CONFIG */
- fprintf (stderr,
- " -v,--version: Print version and exit\n");
- fprintf (stderr,
- " --help: Print help and exit\n");
-}
-
-/* This function is called when a fatal error occurs. */
-
-static void
-ucuabort ()
-{
- if (fCustarted)
- {
- fCustarted = FALSE;
- (void) fsysdep_cu_finish ();
- }
-
- if (fCurestore_terminal)
- {
- fCurestore_terminal = FALSE;
- (void) fsysdep_terminal_restore ();
- }
-
- if (qCuconn != NULL)
- {
- struct sconnection *qconn;
-
- if (fCuclose_conn)
- {
- fCuclose_conn = FALSE;
- (void) fconn_close (qCuconn, pCuuuconf, qCudialer, FALSE);
- }
- qconn = qCuconn;
- qCuconn = NULL;
- (void) fconn_unlock (qconn);
- uconn_free (qconn);
- }
-
- ulog_close ();
-
- if (fCuconnprinted)
- printf ("\n%s\n", ZDISMSG);
-
- usysdep_exit (FALSE);
-}
-
-/* This variable is just used to communicate between uculog_start and
- uculog_end. */
-static boolean fCulog_restore;
-
-/* This function is called by ulog before it output anything. We use
- it to restore the terminal, if necessary. ulog is only called for
- errors or debugging in cu, so it's not too costly to do this. If
- we didn't do it, then at least on Unix each line would leave the
- cursor in the same column rather than wrapping back to the start,
- since CRMOD will not be on. */
-
-static void
-uculog_start ()
-{
- if (! fCurestore_terminal)
- fCulog_restore = FALSE;
- else
- {
- fCulog_restore = TRUE;
- fCurestore_terminal = FALSE;
- if (! fsysdep_terminal_restore ())
- ucuabort ();
- }
-}
-
-/* This function is called by ulog after everything is output. It
- sets the terminal back, if necessary. */
-
-static void
-uculog_end ()
-{
- if (fCulog_restore)
- {
- if (! fsysdep_terminal_raw (fCulocalecho))
- ucuabort ();
- fCurestore_terminal = TRUE;
- }
-}
-
-/* Check to see if this port has the desired line, to handle the -l
- option. If it does, or if no line was specified, set up a
- connection and lock it. */
-
-static int
-icuport_lock (qport, pinfo)
- struct uuconf_port *qport;
- pointer pinfo;
-{
- struct sconninfo *q = (struct sconninfo *) pinfo;
-
- if (q->zline != NULL
- && ! fsysdep_port_is_line (qport, q->zline))
- return UUCONF_NOT_FOUND;
-
- q->fmatched = TRUE;
-
- if (! fconn_init (qport, q->qconn, UUCONF_PORTTYPE_UNKNOWN))
- return UUCONF_NOT_FOUND;
- else if (! fconn_lock (q->qconn, FALSE))
- {
- uconn_free (q->qconn);
- return UUCONF_NOT_FOUND;
- }
- else
- {
- qCuconn = q->qconn;
- q->flocked = TRUE;
- return UUCONF_SUCCESS;
- }
-}
-
-/* Execute a cu escape command. Return TRUE if the connection should
- continue, or FALSE if the connection should be terminated. */
-
-static boolean
-fcudo_cmd (puuconf, qconn, bcmd)
- pointer puuconf;
- struct sconnection *qconn;
- int bcmd;
-{
- char *zline;
- char *z;
- char abescape[5];
- boolean fret;
- size_t clen;
- char abbuf[100];
-
- /* Some commands take a string up to the next newline character. */
- switch (bcmd)
- {
- default:
- zline = NULL;
- break;
- case '!':
- case '$':
- case '|':
- case '+':
- case '%':
- case 'c':
- case '>':
- case '<':
- case 'p':
- case 't':
- case 's':
- {
- zline = zsysdep_terminal_line ((const char *) NULL);
- if (zline == NULL)
- ucuabort ();
- zline[strcspn (zline, "\n")] = '\0';
- }
- break;
- }
-
- switch (bcmd)
- {
- default:
- if (! isprint (*zCuvar_escape))
- sprintf (abescape, "\\%03o", BUCHAR (*zCuvar_escape));
- else
- {
- abescape[0] = *zCuvar_escape;
- abescape[1] = '\0';
- }
- sprintf (abbuf, "[Unrecognized. Use %s%s to send %s]",
- abescape, abescape, abescape);
- ucuputs (abbuf);
- return TRUE;
-
- case '.':
- /* Hangup. */
- return FALSE;
-
- case '!':
- case '$':
- case '|':
- case '+':
- /* Shell out. */
- if (! fsysdep_cu_copy (FALSE)
- || ! fsysdep_terminal_restore ())
- ucuabort ();
- fCurestore_terminal = FALSE;
- {
- enum tshell_cmd t;
-
- switch (bcmd)
- {
- default:
- case '!': t = SHELL_NORMAL; break;
- case '$': t = SHELL_STDOUT_TO_PORT; break;
- case '|': t = SHELL_STDIN_FROM_PORT; break;
- case '+': t = SHELL_STDIO_ON_PORT; break;
- }
-
- (void) fsysdep_shell (qconn, zline, t);
- }
- if (! fsysdep_cu_copy (TRUE)
- || ! fsysdep_terminal_raw (fCulocalecho))
- ucuabort ();
- fCurestore_terminal = TRUE;
- ubuffree (zline);
- return TRUE;
-
- case '%':
- fret = fcudo_subcmd (puuconf, qconn, zline);
- ubuffree (zline);
- return fret;
-
- case '#':
- if (! fconn_break (qconn))
- ucuabort ();
- return TRUE;
-
- case 'c':
- (void) fsysdep_chdir (zline);
- ubuffree (zline);
- return TRUE;
-
- case '>':
- case '<':
- case 'p':
- case 't':
- clen = strlen (zline);
- z = zbufalc (clen + 3);
- z[0] = bcmd;
- z[1] = ' ';
- memcpy (z + 2, zline, clen + 1);
- ubuffree (zline);
- fret = fcudo_subcmd (puuconf, qconn, z);
- ubuffree (z);
- return fret;
-
- case 'z':
- if (! fsysdep_cu_copy (FALSE)
- || ! fsysdep_terminal_restore ())
- ucuabort ();
- fCurestore_terminal = FALSE;
- if (! fsysdep_suspend ())
- ucuabort ();
- if (! fsysdep_cu_copy (TRUE)
- || ! fsysdep_terminal_raw (fCulocalecho))
- ucuabort ();
- fCurestore_terminal = TRUE;
- return TRUE;
-
- case 's':
- fret = fcuset_var (puuconf, zline);
- ubuffree (zline);
- return fret;
-
- case 'v':
- uculist_vars ();
- return TRUE;
-
- case '?':
- if (! isprint (*zCuvar_escape))
- sprintf (abescape, "\\%03o", BUCHAR (*zCuvar_escape));
- else
- {
- abescape[0] = *zCuvar_escape;
- abescape[1] = '\0';
- }
- ucuputs ("");
- ucuputs ("[Escape sequences]");
- sprintf (abbuf,
- "[%s. hangup] [%s!CMD run shell]",
- abescape, abescape);
- ucuputs (abbuf);
- sprintf (abbuf,
- "[%s$CMD stdout to remote] [%s|CMD stdin from remote]",
- abescape, abescape);
- ucuputs (abbuf);
- sprintf (abbuf,
- "[%s+CMD stdin and stdout to remote]",
- abescape);
- ucuputs (abbuf);
- sprintf (abbuf,
- "[%s# send break] [%scDIR change directory]",
- abescape, abescape);
- ucuputs (abbuf);
- sprintf (abbuf,
- "[%s> send file] [%s< receive file]",
- abescape, abescape);
- ucuputs (abbuf);
- sprintf (abbuf,
- "[%spFROM TO send to Unix] [%stFROM TO receive from Unix]",
- abescape, abescape);
- ucuputs (abbuf);
- sprintf (abbuf,
- "[%ssVAR VAL set variable] [%ssVAR set boolean]",
- abescape, abescape);
- ucuputs (abbuf);
- sprintf (abbuf,
- "[%ss!VAR unset boolean] [%sv list variables]",
- abescape, abescape);
- ucuputs (abbuf);
-#ifdef SIGTSTP
- sprintf (abbuf,
- "[%sz suspend]",
- abescape);
- ucuputs (abbuf);
-#endif
- uculist_fns (abescape);
- return TRUE;
- }
-}
-
-/* List ~% functions. */
-
-static void
-uculist_fns (zescape)
- const char *zescape;
-{
- char abbuf[100];
-
- sprintf (abbuf,
- "[%s%%break send break] [%s%%cd DIR change directory]",
- zescape, zescape);
- ucuputs (abbuf);
- sprintf (abbuf,
- "[%s%%put FROM TO send file] [%s%%take FROM TO receive file]",
- zescape, zescape);
- ucuputs (abbuf);
- sprintf (abbuf,
- "[%s%%nostop no XON/XOFF] [%s%%stop use XON/XOFF]",
- zescape, zescape);
- ucuputs (abbuf);
-}
-
-/* Set a variable. */
-
-static boolean
-fcuset_var (puuconf, zline)
- pointer puuconf;
- char *zline;
-{
- char *zvar, *zval;
- char *azargs[2];
- int iuuconf;
-
- zvar = strtok (zline, "= \t");
- if (zvar == NULL)
- {
- ucuputs (abCuconnected);
- return TRUE;
- }
-
- zval = strtok ((char *) NULL, " \t");
-
- if (zval == NULL)
- {
- azargs[0] = zvar;
- if (azargs[0][0] != '!')
- azargs[1] = zbufcpy ("t");
- else
- {
- ++azargs[0];
- azargs[1] = zbufcpy ("f");
- }
- }
- else
- {
- azargs[0] = zvar;
- azargs[1] = zbufcpy (zval);
- }
-
- iuuconf = uuconf_cmd_args (puuconf, 2, azargs, asCuvars,
- (pointer) NULL, icuunrecogvar, 0,
- (pointer) NULL);
-
- if ((iuuconf & UUCONF_CMDTABRET_KEEP) == 0)
- ubuffree (azargs[1]);
-
- if ((iuuconf &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS)
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
-
- return TRUE;
-}
-
-/* Warn about an unknown variable. */
-
-/*ARGSUSED*/
-static int
-icuunrecogvar (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- char abescape[5];
-
- if (! isprint (*zCuvar_escape))
- sprintf (abescape, "\\%03o", BUCHAR (*zCuvar_escape));
- else
- {
- abescape[0] = *zCuvar_escape;
- abescape[1] = '\0';
- }
- ulog (LOG_ERROR, "%s: unknown variable (%sv lists variables)",
- argv[0], abescape);
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* List all the variables with their values. */
-
-static void
-uculist_vars ()
-{
- const struct uuconf_cmdtab *q;
- char abbuf[100];
-
- ucuputs ("");
- for (q = asCuvars; q->uuconf_zcmd != NULL; q++)
- {
- switch (UUCONF_TTYPE_CMDTABTYPE (q->uuconf_itype))
- {
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_BOOLEAN):
- if (*(boolean *) q->uuconf_pvar)
- sprintf (abbuf, "%s true", q->uuconf_zcmd);
- else
- sprintf (abbuf, "%s false", q->uuconf_zcmd);
- break;
-
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_INT):
- sprintf (abbuf, "%s %d", q->uuconf_zcmd, *(int *) q->uuconf_pvar);
- break;
-
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_LONG):
- sprintf (abbuf, "%s %ld", q->uuconf_zcmd,
- *(long *) q->uuconf_pvar);
- break;
-
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_STRING):
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_FULLSTRING):
- {
- const char *z;
- char abchar[5];
- size_t clen;
-
- sprintf (abbuf, "%s ", q->uuconf_zcmd);
- clen = strlen (abbuf);
- for (z = *(const char **) q->uuconf_pvar; *z != '\0'; z++)
- {
- int cchar;
-
- if (! isprint (*z))
- {
- sprintf (abchar, "\\%03o", BUCHAR (*z));
- cchar = 4;
- }
- else
- {
- abchar[0] = *z;
- abchar[1] = '\0';
- cchar = 1;
- }
- if (clen + cchar < sizeof (abbuf))
- strcat (abbuf, abchar);
- clen += cchar;
- }
- }
- break;
-
- default:
- sprintf (abbuf, "%s [unprintable type]", q->uuconf_zcmd);
- break;
- }
-
- ucuputs (abbuf);
- }
-}
-
-/* Subcommands. These are commands that begin with ~%. */
-
-/* This variable is only used so that we can pass a non-NULL address
- in pvar. It is never assigned to or examined. */
-
-static char bCutype;
-
-/* The command table for the subcommands. */
-
-static int icubreak P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int icudebug P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int icuchdir P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int icuput P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int icutake P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int icunostop P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-
-static const struct uuconf_cmdtab asCucmds[] =
-{
- { "break", UUCONF_CMDTABTYPE_FN | 1, NULL, icubreak },
- { "b", UUCONF_CMDTABTYPE_FN | 1, NULL, icubreak },
- { "cd", UUCONF_CMDTABTYPE_FN | 0, NULL, icuchdir },
- { "d", UUCONF_CMDTABTYPE_FN | 1, NULL, icudebug },
- { "put", UUCONF_CMDTABTYPE_FN | 0, NULL, icuput },
- { "take", UUCONF_CMDTABTYPE_FN | 0, NULL, icutake },
- { "nostop", UUCONF_CMDTABTYPE_FN | 1, NULL, icunostop },
- { "stop", UUCONF_CMDTABTYPE_FN | 1, &bCutype, icunostop },
- { ">", UUCONF_CMDTABTYPE_FN | 0, &bCutype, icuput },
- { "<", UUCONF_CMDTABTYPE_FN | 0, &bCutype, icutake },
- { "p", UUCONF_CMDTABTYPE_FN | 0, NULL, icuput },
- { "t", UUCONF_CMDTABTYPE_FN | 0, NULL, icutake },
- { NULL, 0, NULL, NULL }
-};
-
-/* Do a subcommand. This is called by commands beginning with ~%. */
-
-static boolean
-fcudo_subcmd (puuconf, qconn, zline)
- pointer puuconf;
- struct sconnection *qconn;
- char *zline;
-{
- char *azargs[3];
- int iarg;
- int iuuconf;
-
- for (iarg = 0; iarg < 3; iarg++)
- {
- azargs[iarg] = strtok (iarg == 0 ? zline : (char *) NULL, " \t\n");
- if (azargs[iarg] == NULL)
- break;
- }
-
- if (iarg == 0)
- {
- ucuputs (abCuconnected);
- return TRUE;
- }
-
- iuuconf = uuconf_cmd_args (puuconf, iarg, azargs, asCucmds,
- (pointer) qconn, icuunrecogfn,
- 0, (pointer) NULL);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
-
- return TRUE;
-}
-
-/* Warn about an unknown function. */
-
-/*ARGSUSED*/
-static int
-icuunrecogfn (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- char abescape[5];
-
- if (! isprint (*zCuvar_escape))
- sprintf (abescape, "\\%03o", BUCHAR (*zCuvar_escape));
- else
- {
- abescape[0] = *zCuvar_escape;
- abescape[1] = '\0';
- }
- if (argv[0][0] == '?')
- uculist_fns (abescape);
- else
- ulog (LOG_ERROR, "%s: unknown (%s%%? lists choices)",
- argv[0], abescape);
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Send a break. */
-
-/*ARGSUSED*/
-static int
-icubreak (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sconnection *qconn = (struct sconnection *) pinfo;
-
- if (! fconn_break (qconn))
- ucuabort ();
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Change directories. */
-
-/*ARGSUSED*/
-static int
-icuchdir (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- const char *zarg;
-
- if (argc <= 1)
- zarg = NULL;
- else
- zarg = argv[1];
- (void) fsysdep_chdir (zarg);
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Toggle debugging. */
-
-/*ARGSUSED*/
-static int
-icudebug (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
-#if DEBUG > 1
- if (iDebug != 0)
- iDebug = 0;
- else
- iDebug = DEBUG_MAX;
-#else
- ucuputs ("[compiled without debugging]");
-#endif
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Control whether the port does xon/xoff handshaking. If pvar is not
- NULL, this is "stop"; otherwise it is "nostop". */
-
-/*ARGSUSED*/
-static int
-icunostop (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sconnection *qconn = (struct sconnection *) pinfo;
-
- if (! fconn_set (qconn, PARITYSETTING_DEFAULT, STRIPSETTING_DEFAULT,
- pvar == NULL ? XONXOFF_OFF : XONXOFF_ON))
- ucuabort ();
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Send a file to the remote system. The first argument is the file
- to send. If that argument is not present, it is prompted for. The
- second argument is to file name to use on the remote system. If
- that argument is not present, the basename of the local filename is
- used. If pvar is not NULL, then this is ~>, which is used to send
- a command to a non-Unix system. We treat is the same as ~%put,
- except that we assume the user has already entered the appropriate
- command (for ~%put, we force ``cat >to'' to the other side). */
-
-/*ARGSUSED*/
-static int
-icuput (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sconnection *qconn = (struct sconnection *) pinfo;
- char *zfrom;
- char *zto = NULL;
- char *zalc;
- openfile_t e;
- int cline;
- char *zbuf;
- size_t cbuf;
-
- if (argc > 1)
- zfrom = zbufcpy (argv[1]);
- else
- {
- zfrom = zsysdep_terminal_line ("File to send: ");
- if (zfrom == NULL)
- ucuabort ();
- zfrom[strcspn (zfrom, " \t\n")] = '\0';
-
- if (*zfrom == '\0')
- {
- ubuffree (zfrom);
- ucuputs (abCuconnected);
- return UUCONF_CMDTABRET_CONTINUE;
- }
- }
-
- if (pvar == NULL)
- {
- if (argc > 2)
- zto = zbufcpy (argv[2]);
- else
- {
- char *zbase;
- char *zprompt;
-
- zbase = zsysdep_base_name (zfrom);
- if (zbase == NULL)
- ucuabort ();
-
- zprompt = zbufalc (sizeof "Remote file name []: " +
- strlen (zbase));
- sprintf (zprompt, "Remote file name [%s]: ", zbase);
- zto = zsysdep_terminal_line (zprompt);
- ubuffree (zprompt);
- if (zto == NULL)
- ucuabort ();
-
- zto[strcspn (zto, " \t\n")] = '\0';
- if (*zto != '\0')
- ubuffree (zbase);
- else
- {
- ubuffree (zto);
- zto = zbase;
- }
- }
- }
-
- e = esysdep_user_fopen (zfrom, TRUE, fCuvar_binary);
- if (! ffileisopen (e))
- {
- const char *zerrstr;
-
- if (pvar == NULL)
- ubuffree (zto);
- zerrstr = strerror (errno);
- zalc = zbufalc (strlen (zfrom) + sizeof ": " + strlen (zerrstr));
- sprintf (zalc, "%s: %s", zfrom, zerrstr);
- ubuffree (zfrom);
- ucuputs (zalc);
- ubuffree (zalc);
- ucuputs (abCuconnected);
- return UUCONF_CMDTABRET_CONTINUE;
- }
-
- ubuffree (zfrom);
-
- /* Tell the system dependent layer to stop copying data from the
- port to the terminal. We want to read the echoes ourself. Also
- permit the local user to generate signals. */
- if (! fsysdep_cu_copy (FALSE)
- || ! fsysdep_terminal_signals (TRUE))
- ucuabort ();
-
- /* If pvar is NULL, then we are sending a file to a Unix system. We
- send over the command "cat > TO" to prepare it to receive. If
- pvar is not NULL, the user is assumed to have set up whatever
- action was needed to receive the file. */
- if (pvar == NULL)
- {
- boolean fret;
-
- zalc = zbufalc (sizeof "cat > \n" + strlen (zto));
- sprintf (zalc, "cat > %s\n", zto);
- ubuffree (zto);
- fret = fcusend_buf (qconn, zalc, strlen (zalc));
- ubuffree (zalc);
- if (! fret)
- {
- (void) ffileclose (e);
- if (! fsysdep_cu_copy (TRUE)
- || ! fsysdep_terminal_signals (FALSE))
- ucuabort ();
- ucuputs (abCuconnected);
- return UUCONF_CMDTABRET_CONTINUE;
- }
- }
-
- cline = 0;
-
- zbuf = NULL;
- cbuf = 0;
-
- while (TRUE)
- {
- char abbuf[512];
- size_t c;
-
-#if USE_STDIO
- if (fCuvar_binary)
-#endif
- {
- if (ffileeof (e))
- break;
- c = cfileread (e, abbuf, sizeof abbuf);
- if (ffileioerror (e, c))
- {
- ucuputs ("[file read error]");
- break;
- }
- if (c == 0)
- break;
- zbuf = abbuf;
- }
-#if USE_STDIO
- else
- {
- if (getline (&zbuf, &cbuf, e) <= 0)
- {
- xfree ((pointer) zbuf);
- break;
- }
- c = strlen (zbuf);
- }
-#endif
-
- if (fCuvar_verbose)
- {
- ++cline;
- printf ("%d ", cline);
- (void) fflush (stdout);
- }
-
- if (! fcusend_buf (qconn, zbuf, c))
- {
- if (! fCuvar_binary)
- xfree ((pointer) zbuf);
- (void) fclose (e);
- if (! fsysdep_cu_copy (TRUE)
- || ! fsysdep_terminal_signals (FALSE))
- ucuabort ();
- ucuputs (abCuconnected);
- return UUCONF_CMDTABRET_CONTINUE;
- }
- }
-
- (void) ffileclose (e);
-
- if (pvar == NULL)
- {
- char beof;
-
- beof = '\004';
- if (! fconn_write (qconn, &beof, 1))
- ucuabort ();
- }
- else
- {
- if (*zCuvar_eofwrite != '\0')
- {
- if (! fconn_write (qconn, zCuvar_eofwrite,
- strlen (zCuvar_eofwrite)))
- ucuabort ();
- }
- }
-
- if (fCuvar_verbose)
- ucuputs ("");
-
- ucuputs ("[file transfer complete]");
-
- if (! fsysdep_cu_copy (TRUE)
- || ! fsysdep_terminal_signals (FALSE))
- ucuabort ();
-
- ucuputs (abCuconnected);
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Get a file from the remote side. This is ~%take, or ~t, or ~<.
- The first two are assumed to be taking the file from a Unix system,
- so we force the command "cat FROM; echo */
-
-/*ARGSUSED*/
-static int
-icutake (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sconnection *qconn = (struct sconnection *) pinfo;
- const char *zeof;
- char *zfrom, *zto, *zcmd;
- char *zalc;
- openfile_t e;
- char bcr;
- size_t ceoflen;
- char *zlook = NULL;
- size_t ceofhave;
- boolean ferr;
-
- if (argc > 1)
- zfrom = zbufcpy (argv[1]);
- else
- {
- zfrom = zsysdep_terminal_line ("Remote file to retreive: ");
- if (zfrom == NULL)
- ucuabort ();
- zfrom[strcspn (zfrom, " \t\n")] = '\0';
- if (*zfrom == '\0')
- {
- ubuffree (zfrom);
- ucuputs (abCuconnected);
- return UUCONF_CMDTABRET_CONTINUE;
- }
- }
-
- if (argc > 2)
- zto = zbufcpy (argv[2]);
- else
- {
- char *zbase;
- char *zprompt;
-
- zbase = zsysdep_base_name (zfrom);
- if (zbase == NULL)
- ucuabort ();
-
- zprompt = zbufalc (sizeof "Local file name []: " + strlen (zbase));
- sprintf (zprompt, "Local file name [%s]: ", zbase);
- zto = zsysdep_terminal_line (zprompt);
- ubuffree (zprompt);
- if (zto == NULL)
- ucuabort ();
-
- zto[strcspn (zto, " \t\n")] = '\0';
- if (*zto != '\0')
- ubuffree (zbase);
- else
- {
- ubuffree (zto);
- zto = zbase;
- }
- }
-
- if (pvar != NULL)
- {
- zcmd = zsysdep_terminal_line ("Remote command to execute: ");
- if (zcmd == NULL)
- ucuabort ();
- zcmd[strcspn (zcmd, "\n")] = '\0';
- zeof = zCuvar_eofread;
- }
- else
- {
- zcmd = zbufalc (sizeof "cat ; echo; echo ////cuend////"
- + strlen (zfrom));
- sprintf (zcmd, "cat %s; echo; echo ////cuend////", zfrom);
- zeof = "\n////cuend////\n";
- }
-
- ubuffree (zfrom);
-
- e = esysdep_user_fopen (zto, FALSE, fCuvar_binary);
- if (! ffileisopen (e))
- {
- const char *zerrstr;
-
- ubuffree (zcmd);
- zerrstr = strerror (errno);
- zalc = zbufalc (strlen (zto) + sizeof ": " + strlen (zerrstr));
- sprintf (zalc, "%s: %s\n", zto, zerrstr);
- ucuputs (zalc);
- ubuffree (zalc);
- ucuputs (abCuconnected);
- ubuffree (zto);
- return UUCONF_CMDTABRET_CONTINUE;
- }
-
- if (! fsysdep_cu_copy (FALSE)
- || ! fsysdep_terminal_signals (TRUE))
- ucuabort ();
-
- if (! fconn_write (qconn, zcmd, strlen (zcmd)))
- ucuabort ();
- bcr = '\r';
- if (! fconn_write (qconn, &bcr, 1))
- ucuabort ();
-
- ubuffree (zcmd);
-
- /* Eliminated any previously echoed data to avoid confusion. */
- iPrecstart = 0;
- iPrecend = 0;
-
- /* If we're dealing with a Unix system, we can reliably discard the
- command. Otherwise, the command will probably wind up in the
- file; too bad. */
- if (pvar == NULL)
- {
- int b;
-
- while ((b = breceive_char (qconn, cCuvar_timeout, TRUE)) != '\n')
- {
- if (b == -2)
- ucuabort ();
- if (b < 0)
- {
- ucuputs ("[timed out waiting for newline]");
- ucuputs (abCuconnected);
- ubuffree (zto);
- return UUCONF_CMDTABRET_CONTINUE;
- }
- }
- }
-
- ceoflen = strlen (zeof);
- zlook = zbufalc (ceoflen);
- ceofhave = 0;
- ferr = FALSE;
-
- while (TRUE)
- {
- int b;
-
- if (FGOT_SIGNAL ())
- {
- /* Make sure the signal is logged. */
- ulog (LOG_ERROR, (const char *) NULL);
- ucuputs ("[file receive aborted]");
- /* Reset the SIGINT flag so that it does not confuse us in
- the future. */
- afSignal[INDEXSIG_SIGINT] = FALSE;
- break;
- }
-
- b = breceive_char (qconn, cCuvar_timeout, TRUE);
- if (b == -2)
- ucuabort ();
- if (b < 0)
- {
- if (ceofhave > 0)
- (void) fwrite (zlook, sizeof (char), ceofhave, e);
- ucuputs ("[timed out]");
- break;
- }
-
- if (b == '\r' && ! fCuvar_binary)
- continue;
-
- if (ceoflen == 0)
- {
- if (cfilewrite (e, &b, 1) != 1)
- {
- ferr = TRUE;
- break;
- }
- }
- else
- {
- zlook[ceofhave] = b;
- ++ceofhave;
- if (ceofhave == ceoflen)
- {
- size_t cmove;
- char *zmove;
-
- if (memcmp (zeof, zlook, ceoflen) == 0)
- {
- ucuputs ("[file transfer complete]");
- break;
- }
-
- if (cfilewrite (e, zlook, 1) != 1)
- {
- ferr = TRUE;
- break;
- }
-
- zmove = zlook;
- for (cmove = ceoflen - 1, zmove = zlook;
- cmove > 0;
- cmove--, zmove++)
- zmove[0] = zmove[1];
-
- --ceofhave;
- }
- }
- }
-
- ubuffree (zlook);
-
- if (! fsysdep_sync (e, zto))
- {
- (void) ffileclose (e);
- ferr = TRUE;
- }
- else
- {
- if (! ffileclose (e))
- ferr = TRUE;
- }
- if (ferr)
- ucuputs ("[file write error]");
-
- if (! fsysdep_cu_copy (TRUE)
- || ! fsysdep_terminal_signals (FALSE))
- ucuabort ();
-
- ucuputs (abCuconnected);
-
- ubuffree (zto);
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Send a buffer to the remote system. If fCuvar_binary is FALSE,
- each buffer passed in will be a single line; in this case we can
- check the echoed characters and kill the line if they do not match.
- This returns FALSE if an echo check fails. If a port error
- occurrs, it calls ucuabort. */
-
-static boolean
-fcusend_buf (qconn, zbufarg, cbufarg)
- struct sconnection *qconn;
- const char *zbufarg;
- size_t cbufarg;
-{
- const char *zbuf;
- size_t cbuf;
- int ctries;
- size_t cbplen;
- char *zsendbuf;
-
- zbuf = zbufarg;
- cbuf = cbufarg;
- ctries = 0;
-
- if (fCuvar_binary)
- cbplen = strlen (zCuvar_binary_prefix);
- else
- cbplen = 1;
- zsendbuf = zbufalc (64 * (cbplen + 1));
-
- /* Loop while we still have characters to send. The value of cbuf
- will be reset to cbufarg if an echo failure occurs while sending
- a line in non-binary mode. */
- while (cbuf > 0)
- {
- int csend;
- char *zput;
- const char *zget;
- boolean fnl;
- int i;
-
- if (FGOT_SIGNAL ())
- {
- /* Make sure the signal is logged. */
- ubuffree (zsendbuf);
- ulog (LOG_ERROR, (const char *) NULL);
- ucuputs ("[file send aborted]");
- /* Reset the SIGINT flag so that it does not confuse us in
- the future. */
- afSignal[INDEXSIG_SIGINT] = FALSE;
- return FALSE;
- }
-
- /* Discard anything we've read from the port up to now, to avoid
- confusing the echo checking. */
- iPrecstart = 0;
- iPrecend = 0;
-
- /* Send all characters up to a newline before actually sending
- the newline. This makes it easier to handle the special
- newline echo checking. Send up to 64 characters at a time
- before doing echo checking. */
- if (*zbuf == '\n')
- csend = 1;
- else
- {
- const char *znl;
-
- znl = memchr (zbuf, '\n', cbuf);
- if (znl == NULL)
- csend = cbuf;
- else
- csend = znl - zbuf;
- if (csend > 64)
- csend = 64;
- }
-
- /* Translate this part of the buffer. If we are not in binary
- mode, we translate \n to \r, and ignore any nonprintable
- characters. */
- zput = zsendbuf;
- fnl = FALSE;
- for (i = 0, zget = zbuf; i < csend; i++, zget++)
- {
- if (isprint (*zget)
- || *zget == '\t')
- *zput++ = *zget;
- else if (*zget == '\n')
- {
- if (fCuvar_binary)
- *zput++ = '\n';
- else
- *zput++ = '\r';
- fnl = TRUE;
- }
- else if (fCuvar_binary)
- {
- strcpy (zput, zCuvar_binary_prefix);
- zput += cbplen;
- *zput++ = *zget;
- }
- }
-
- zbuf += csend;
- cbuf -= csend;
-
- if (zput == zsendbuf)
- continue;
-
- /* Send the data over the port. */
- if (! fsend_data (qconn, zsendbuf, (size_t) (zput - zsendbuf), TRUE))
- ucuabort ();
-
- /* We do echo checking if requested, unless we are in binary
- mode. Echo checking of a newline is different from checking
- of normal characters; when we send a newline we look for
- *zCuvar_echonl. */
- if ((fCuvar_echocheck && ! fCuvar_binary)
- || (fnl && *zCuvar_echonl != '\0'))
- {
- long iend;
-
- iend = ixsysdep_time ((long *) NULL) + (long) cCuvar_timeout;
- for (zget = zsendbuf; zget < zput; zget++)
- {
- int bread;
- int bwant;
-
- if (fCuvar_binary ? *zget == '\n' : *zget == '\r')
- {
- bwant = *zCuvar_echonl;
- if (bwant == '\0')
- continue;
- }
- else
- {
- if (! fCuvar_echocheck || ! isprint (*zget))
- continue;
- bwant = *zget;
- }
-
- do
- {
- if (FGOT_SIGNAL ())
- {
- /* Make sure the signal is logged. */
- ubuffree (zsendbuf);
- ulog (LOG_ERROR, (const char *) NULL);
- ucuputs ("[file send aborted]");
- /* Reset the SIGINT flag so that it does not
- confuse us in the future. */
- afSignal[INDEXSIG_SIGINT] = FALSE;
- return FALSE;
- }
-
- bread = breceive_char (qconn,
- iend - ixsysdep_time ((long *) NULL),
- TRUE);
- if (bread < 0)
- {
- if (bread == -2)
- ucuabort ();
-
- /* If we timed out, and we're not in binary
- mode, we kill the line and try sending it
- again from the beginning. */
- if (! fCuvar_binary && *zCuvar_kill != '\0')
- {
- ++ctries;
- if (ctries < cCuvar_resend)
- {
- if (fCuvar_verbose)
- {
- printf ("R ");
- (void) fflush (stdout);
- }
- if (! fsend_data (qconn, zCuvar_kill, 1,
- TRUE))
- ucuabort ();
- zbuf = zbufarg;
- cbuf = cbufarg;
- break;
- }
- }
- ubuffree (zsendbuf);
- ucuputs ("[timed out looking for echo]");
- return FALSE;
- }
- }
- while (bread != *zget);
-
- if (bread < 0)
- break;
- }
- }
- }
-
- ubuffree (zsendbuf);
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/doc/Makefile b/gnu/libexec/uucp/doc/Makefile
deleted file mode 100644
index 8066a9b..0000000
--- a/gnu/libexec/uucp/doc/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-INFO= uucp
-INFOSECTION= "System Utilities"
-
-.include <bsd.info.mk>
diff --git a/gnu/libexec/uucp/doc/uucp.texi b/gnu/libexec/uucp/doc/uucp.texi
deleted file mode 100644
index 50ff556..0000000
--- a/gnu/libexec/uucp/doc/uucp.texi
+++ /dev/null
@@ -1,8367 +0,0 @@
-\input texinfo @c -*-texinfo-*-
-@c %**start of header
-@setfilename uucp.info
-@settitle Taylor UUCP
-@setchapternewpage odd
-@c %**end of header
-
-@iftex
-@finalout
-@end iftex
-
-@ifinfo
-@format
-START-INFO-DIR-ENTRY
-* UUCP: (uucp). Transfer mail and news across phone lines.
-END-INFO-DIR-ENTRY
-@end format
-
-This file documents Taylor UUCP, version 1.06.
-
-Copyright @copyright{} 1992, 1993, 1994, 1995 Ian Lance Taylor
-
-Permission is granted to make and distribute verbatim copies of this
-manual provided the copyright notice and this permission notice are
-preserved on all copies.
-
-@ignore
-Permission is granted to process this file through TeX and print the
-results, provided the printed document carries a 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
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that the
-section entitled ``Copying'' are included exactly as in the original, and
-provided that the entire resulting derived work is distributed under the
-terms of a permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions,
-except that the section entitled ``Copying'' may be included in a
-translation approved by the author instead of in the original English.
-@end ifinfo
-
-@titlepage
-@title Taylor UUCP
-@subtitle Version 1.06
-@author Ian Lance Taylor @code{<ian@@airs.com>}
-
-@page
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1992, 1993, 1994, 1995 Ian Lance Taylor
-
-Published by Ian Lance Taylor @code{<ian@@airs.com>}.
-
-Permission is granted to make and distribute verbatim copies of this
-manual provided the copyright notice and this permission notice are
-preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that the
-section entitled ``Copying'' are included exactly as in the original, and
-provided that the entire resulting derived work is distributed under the
-terms of a permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions,
-except that the section entitled ``Copying'' may be included in a
-translation approved by the author instead of in the original English.
-@end titlepage
-
-@node Top, Copying, (dir), (dir)
-@top Taylor UUCP 1.06
-
-This is the documentation for the Taylor UUCP package, version 1.06.
-The programs were written by Ian Lance Taylor. The author can be
-reached at @code{<ian@@airs.com>}, or at
-@display
-Ian Lance Taylor
-c/o Cygnus Support
-48 Grove Street
-Somerville, MA 02144
-USA
-@end display
-
-There is a mailing list for discussion of the package. The list is
-hosted by Eric Schnoebelen at @code{cirr.com}. To join (or get off) the
-list, send mail to @code{taylor-uucp-request@@cirr.com}. Mail to this
-address is answered by the majordomo program. To join the list, send
-the message @samp{subscribe @var{address}} where @var{address} is your
-e-mail address. To send a message to the list, send it to
-@code{taylor-uucp@@cirr.com}. The old list address,
-@code{taylor-uucp@@gnu.ai.mit.edu}, will also work. There is an archive
-of all messages sent to the mailing list at @code{ftp.cirr.com}.
-
-@menu
-* Copying:: Taylor UUCP Copying Conditions
-* Introduction:: Introduction to Taylor UUCP
-* Invoking the UUCP Programs:: Invoking the UUCP Programs
-* Installing Taylor UUCP:: Installing Taylor UUCP
-* Using Taylor UUCP:: Using Taylor UUCP
-* Configuration Files:: Taylor UUCP Configuration Files
-* Protocols:: UUCP Protocol Descriptions
-* Hacking:: Hacking Taylor UUCP
-* Acknowledgements:: Acknowledgements
-
-* Index (concepts):: Concept Index
-* Index (configuration file):: Index to New Configuration Files
-
- --- The Detailed Node Listing ---
-
-Invoking the UUCP Programs
-
-* Standard Options:: Standard Options for the UUCP Programs
-* Invoking uucp:: Invoking uucp
-* Invoking uux:: Invoking uux
-* Invoking uustat:: Invoking uustat
-* Invoking uuname:: Invoking uuname
-* Invoking uulog:: Invoking uulog
-* Invoking uuto:: Invoking uuto
-* Invoking uupick:: Invoking uupick
-* Invoking cu:: Invoking cu
-* Invoking uucico:: Invoking uucico
-* Invoking uuxqt:: Invoking uuxqt
-* Invoking uuchk:: Invoking uuchk
-* Invoking uuconv:: Invoking uuconv
-* Invoking uusched:: Invoking uusched
-
-Invoking uucp
-
-* uucp Description:: Description of uucp
-* uucp Options:: Options Supported by uucp
-
-Invoking uux
-
-* uux Description:: Description of uux
-* uux Options:: Options Supported by uux
-* uux Examples:: Examples of uux Usage
-
-Invoking uustat
-
-* uustat Description:: Description of uustat
-* uustat Options:: Options Supported by uustat
-* uustat Examples:: Examples of uustat Usage
-
-Invoking cu
-
-* cu Description:: Description of cu
-* cu Commands:: Commands Supported by cu
-* cu Variables:: Variables Supported by cu
-* cu Options:: Options Supported by cu
-
-Invoking uucico
-
-* uucico Description:: Description of uucico
-* uucico Options:: Options Supported by uucico
-
-Installing Taylor UUCP
-
-* Compilation:: Compiling Taylor UUCP
-* Testing the Compilation:: Testing the Compilation
-* Installing the Binaries:: Installing the Binaries
-* Configuration:: Configuring Taylor UUCP
-* Testing the Installation:: Testing the Installation
-
-Using Taylor UUCP
-
-* Calling Other Systems:: Calling Other Systems
-* Accepting Calls:: Accepting Calls
-* Mail and News:: Using UUCP for Mail and News
-* The Spool Directory Layout:: The Spool Directory Layout
-* Spool Directory Cleaning:: Cleaning the UUCP Spool Directory
-
-Using UUCP for Mail and News.
-
-* Sending mail or news:: Sending mail or news via UUCP
-* Receiving mail or news:: Receiving mail or news via UUCP
-
-The Spool Directory Layout
-
-* System Spool Directories:: System Spool Directories
-* Status Directory:: Status Spool Directory
-* Execution Subdirectories:: Execution Spool Subdirectories
-* Other Spool Subdirectories:: Other Spool Subdirectories
-* Spool Lock Files:: Spool Directory Lock Files
-
-Taylor UUCP Configuration Files
-
-* Configuration Overview:: Configuration File Overview
-* Configuration File Format:: Configuration File Format
-* Configuration Examples:: Examples of Configuration Files
-* Time Strings:: How to Write Time Strings
-* Chat Scripts:: How to Write Chat Scripts
-* config File:: The Main Configuration File
-* sys File:: The System Configuration File
-* port File:: The Port Configuration Files
-* dial File:: The Dialer Configuration Files
-* UUCP Over TCP:: UUCP Over TCP
-* Security:: Security Issues
-
-Examples of Configuration Files
-
-* config File Examples:: Examples of the Main Configuration File
-* Leaf Example:: Call a Single Remote Site
-* Gateway Example:: The Gateway for Several Local Systems
-
-The Main Configuration File
-
-* Miscellaneous (config):: Miscellaneous config File Commands
-* Configuration File Names:: Using Different Configuration Files
-* Log File Names:: Using Different Log Files
-* Debugging Levels:: Debugging Levels
-
-The System Configuration File
-
-* Defaults and Alternates:: Using Defaults and Alternates
-* Naming the System:: Naming the System
-* Calling Out:: Calling Out
-* Accepting a Call:: Accepting a Call
-* Protocol Selection:: Protocol Selection
-* File Transfer Control:: File Transfer Control
-* Miscellaneous (sys):: Miscellaneous sys File Commands
-* Default sys File Values:: Default Values
-
-Calling Out
-
-* When to Call:: When to Call
-* Placing the Call:: Placing the Call
-* Logging In:: Logging In
-
-UUCP Over TCP
-
-* TCP Client:: Connecting to Another System Over TCP
-* TCP Server:: Running a TCP Server
-
-UUCP Protocol Internals
-
-* UUCP Protocol Sources:: Sources for UUCP Protocol Information
-* UUCP Grades:: UUCP Grades
-* UUCP Lock Files:: UUCP Lock Files
-* Execution File Format:: Execution File Format
-* UUCP Protocol:: UUCP Protocol
-* g Protocol:: g protocol
-* f Protocol:: f protocol
-* t Protocol:: t protocol
-* e Protocol:: e protocol
-* Big G Protocol:: G protocol
-* i Protocol:: i protocol
-* j Protocol:: j protocol
-* x Protocol:: x protocol
-* y Protocol:: y protocol
-* d Protocol:: d protocol
-* h Protocol:: h protocol
-* v Protocol:: v protocol
-
-UUCP Protocol
-
-* The Initial Handshake:: The Initial Handshake
-* UUCP Protocol Commands:: UUCP Protocol Commands
-* The Final Handshake:: The Final Handshake
-
-UUCP Protocol Commands
-
-* The S Command:: The S Command
-* The R Command:: The R Command
-* The X Command:: The X Command
-* The E Command:: The E Command
-* The H Command:: The H Command
-
-Hacking Taylor UUCP
-
-* System Dependence:: System Dependence
-* Naming Conventions:: Naming Conventions
-* Patches:: Patches
-@end menu
-
-@node Copying, Introduction, Top, Top
-@unnumbered Taylor UUCP Copying Conditions
-
-This package is covered by the GNU Public License. See the file
-@file{COPYING} for details. If you would like to do something with this
-package that you feel is reasonable, but you feel is prohibited by the
-license, contact me to see if we can work it out.
-
-The rest of this section is some descriptive text from the Free Software
-Foundation.
-
-All the programs, scripts and documents relating to Taylor UUCP are
-@dfn{free}; this means that everyone is free to use them and free to
-redistribute them on a free basis. The Taylor UUCP-related programs are
-not in the public domain; they are copyrighted and there are
-restrictions on their distribution, but these restrictions are designed
-to permit everything that a good cooperating citizen would want to do.
-What is not allowed is to try to prevent others from further sharing any
-version of these programs that they might get from you.
-
-Specifically, we want to make sure that you have the right to give away
-copies of the programs that relate to Taylor UUCP, that you receive
-source code or else can get it if you want it, that you can change these
-programs or use pieces of them in new free programs, and that you know
-you can do these things.
-
-To make sure that everyone has such rights, we have to forbid you to
-deprive anyone else of these rights. For example, if you distribute
-copies of the Taylor UUCP related programs, you must give the recipients
-all the rights that you have. You must make sure that they, too,
-receive or can get the source code. And you must tell them their
-rights.
-
-Also, for our own protection, we must make certain that everyone finds
-out that there is no warranty for the programs that relate to Taylor
-UUCP. If these programs are modified by someone else and passed on, we
-want their recipients to know that what they have is not what we
-distributed, so that any problems introduced by others will not reflect
-on our reputation.
-
-The precise conditions of the licenses for the programs currently being
-distributed that relate to Taylor UUCP are found in the General Public
-Licenses that accompany them.
-
-@node Introduction, Invoking the UUCP Programs, Copying, Top
-@chapter Introduction to Taylor UUCP
-
-General introductions to UUCP are available, and perhaps one day I will
-write one. In the meantime, here is a very brief one that concentrates
-on the programs provided by Taylor UUCP.
-
-Taylor UUCP is a complete UUCP package. It is covered by the GNU Public
-License, which means that the source code is always available. It is
-composed of several programs; most of the names of these programs are
-based on earlier UUCP packages.
-
-@table @code
-
-@item uucp
-
-The @code{uucp} program is used to copy file between systems. It is
-similar to the standard Unix @code{cp} program, except that you can
-refer to a file on a remote system by using @samp{system!} before the
-file name. For example, to copy the file @file{notes.txt} to the system
-@samp{airs}, you would say @samp{uucp notes.txt airs!~/notes.txt}. In
-this example @samp{~} is used to name the UUCP public directory on
-@samp{airs}. For more details, see @ref{Invoking uucp, uucp}.
-
-@item uux
-
-The @code{uux} program is used to request the execution of a program on
-a remote system. This is how mail and news are transferred over UUCP.
-As with @code{uucp}, programs and files on remote systems may be named
-by using @samp{system!}. For example, to run the @code{rnews} program
-on @samp{airs}, passing it standard input, you would say @samp{uux -
-airs!rnews}. The @samp{-} means to read standard input and set things
-up such that when @code{rnews} runs on @samp{airs} it will receive the
-same standard input. For more details, see @ref{Invoking uux, uux}.
-
-@end table
-
-Neither @code{uucp} nor @code{uux} actually do any work immediately.
-Instead, they queue up requests for later processing. They then start a
-daemon process which processes the requests and calls up the appropriate
-systems. Normally the system will also start the daemon periodically to
-check if there is any work to be done. The advantage of this approach
-is that it all happens automatically. You don't have to sit around
-waiting for the files to be transferred. The disadvantage is that if
-anything goes wrong it might be a while before anybody notices.
-
-@table @code
-
-@item uustat
-
-The @code{uustat} program does many things. By default it will simply
-list all the jobs you have queued with @code{uucp} or @code{uux} that
-have not yet been processed. You can use @code{uustat} to remove any of
-your jobs from the queue. You can also it use it to show the status of
-the UUCP system in various ways, such as showing the connection status
-of all the remote systems your system knows about. The system
-administrator can use @code{uustat} to automatically discard old jobs
-while sending mail to the user who requested them. For more details,
-see @ref{Invoking uustat, uustat}.
-
-@item uuname
-
-The @code{uuname} program by default lists all the remote systems your
-system knows about. You can also use it to get the name of your local
-system. It is mostly useful for shell scripts. For more details, see
-@ref{Invoking uuname, uuname}.
-
-@item uulog
-
-The @code{uulog} program can be used to display entries in the UUCP log
-file. It can select the entries for a particular system or a particular
-user. You can use it to see what has happened to your queued jobs in
-the past. For more details, see @ref{Invoking uulog, uulog}.
-
-@item uuto
-@item uupick
-
-@code{uuto} is a simple shell script interface to @code{uucp}. It will
-transfer a file, or the contents of a directory, to a remote system, and
-notify a particular user on the remote system when it arrives. The
-remote user can then retrieve the file(s) with @code{uupick}. For more
-details, see @ref{Invoking uuto, uuto}, and see @ref{Invoking uupick,
-uupick}.
-
-@item cu
-
-The @code{cu} program can be used to call up another system and
-communicate with it as though you were directly connected. It can also
-do simple file transfers, though it does not provide any error checking.
-For more details, @ref{Invoking cu, cu}.
-
-@end table
-
-These eight programs just described, @code{uucp}, @code{uux},
-@code{uuto}, @code{uupick}, @code{uustat}, @code{uuname}, @code{uulog},
-and @code{cu} are the user programs provided by Taylor UUCP@.
-@code{uucp}, @code{uux}, and @code{uuto} add requests to the work queue,
-@code{uupick} extracts files from the UUCP public directory,
-@code{uustat} examines the work queue, @code{uuname} examines the
-configuration files, @code{uulog} examines the log files, and @code{cu}
-just uses the UUCP configuration files.
-
-The real work is actually done by two daemon processes, which are
-normally run automatically rather than by a user.
-
-@table @code
-
-@item uucico
-
-The @code{uucico} daemon is the program which actually calls the remote
-system and transfers files and requests. @code{uucico} is normally
-started automatically by @code{uucp} and @code{uux}. Most systems will
-also start it periodically to make sure that all work requests are
-handled. @code{uucico} checks the queue to see what work needs to be
-done, and then calls the appropriate systems. If the call fails,
-perhaps because the phone line is busy, @code{uucico} leaves the
-requests in the queue and goes on to the next system to call. It is
-also possible to force @code{uucico} to call a remote system even if
-there is no work to be done for it, so that it can pick up any work that
-may be queued up remotely. For more details, see @ref{Invoking uucico,
-uucico}.
-
-@need 1000
-@item uuxqt
-
-The @code{uuxqt} daemon processes execution requests made by the
-@code{uux} program on remote systems. It also processes requests made
-on the local system which require files from a remote system. It is
-normally started by @code{uucico}. For more details, see @ref{Invoking
-uuxqt, uuxqt}.
-
-@end table
-
-Suppose you, on the system @samp{bantam}, want to copy a file to the
-system @samp{airs}. You would run the @code{uucp} command locally, with
-a command like @samp{uucp notes.txt airs!~/notes.txt}. This would queue
-up a request on @samp{bantam} for @samp{airs}, and would then start the
-@code{uucico} daemon. @code{uucico} would see that there was a request
-for @samp{airs} and attempt to call it. When the call succeeded,
-another copy of @code{uucico} would be started on @samp{airs}. The two
-copies of @code{uucico} would tell each other what they had to do and
-transfer the file from @samp{bantam} to @samp{airs}. When the file
-transfer was complete the @code{uucico} on @samp{airs} would move it
-into the UUCP public directory.
-
-UUCP is often used to transfer mail. This is normally done
-automatically by mailer programs. When @samp{bantam} has a mail message
-to send to @samp{ian} at @samp{airs}, it executes @samp{uux - airs!rmail
-ian} and writes the mail message to the @code{uux} process as standard
-input. The @code{uux} program, running on @samp{bantam}, will read the
-standard input and store it, as well as the @code{rmail} request itself,
-on the work queue for @samp{airs}. @code{uux} will then start the
-@code{uucico} daemon. The @code{uucico} daemon will call up
-@samp{airs}, just as in the @code{uucp} example, and transfer the work
-request and the mail message. The @code{uucico} daemon on @samp{airs}
-will put the files on a local work queue. When the communication
-session is over, the @code{uucico} daemon on @samp{airs} will start the
-@code{uuxqt} daemon. @code{uuxqt} will see the request on the work
-queue, and will run @samp{rmail ian} with the mail message as standard
-input. The @code{rmail} program, which is not part of the UUCP package,
-is then responsible for either putting the message in the right mailbox
-on @samp{airs} or forwarding the message on to another system.
-
-Taylor UUCP comes with a few other programs that are useful when
-installing and configuring UUCP.
-
-@table @code
-
-@item uuchk
-
-The @code{uuchk} program reads the UUCP configuration files and displays
-a rather lengthy description of what it finds. This is useful when
-configuring UUCP to make certain that the UUCP package will do what you
-expect it to do. For more details, see @ref{Invoking uuchk, uuchk}.
-
-@item uuconv
-
-The @code{uuconv} program can be used to convert UUCP configuration
-files from one format to another. This can be useful for administrators
-converting from an older UUCP package. Taylor UUCP is able to read and
-use old configuration file formats, but some new features can not be
-selected using the old formats. For more details, see @ref{Invoking
-uuconv, uuconv}.
-
-@item uusched
-
-The @code{uusched} script is provided for compatibility with older UUCP
-releases. It starts @code{uucico} to call, one at a time, all the
-systems for which work has been queued. For more details, see
-@ref{Invoking uusched, uusched}.
-
-@item tstuu
-
-The @code{tstuu} program is a test harness for the UUCP package; it can
-help check that the package has been configured and compiled correctly.
-However, it uses pseudo-terminals, which means that it is less portable
-than the rest of the package. If it works, it can be useful when
-initially installing Taylor UUCP. For more details, see @ref{Testing
-the Compilation, tstuu}.
-
-@end table
-
-@node Invoking the UUCP Programs, Installing Taylor UUCP, Introduction, Top
-@chapter Invoking the UUCP Programs
-
-This chapter describes how to run the UUCP programs.
-
-@menu
-* Standard Options:: Standard Options for the UUCP Programs
-* Invoking uucp:: Invoking uucp
-* Invoking uux:: Invoking uux
-* Invoking uustat:: Invoking uustat
-* Invoking uuname:: Invoking uuname
-* Invoking uulog:: Invoking uulog
-* Invoking uuto:: Invoking uuto
-* Invoking uupick:: Invoking uupick
-* Invoking cu:: Invoking cu
-* Invoking uucico:: Invoking uucico
-* Invoking uuxqt:: Invoking uuxqt
-* Invoking uuchk:: Invoking uuchk
-* Invoking uuconv:: Invoking uuconv
-* Invoking uusched:: Invoking uusched
-@end menu
-
-@node Standard Options, Invoking uucp, Invoking the UUCP Programs, Invoking the UUCP Programs
-@section Standard Options
-
-All of the UUCP programs support a few standard options.
-
-@table @samp
-@item -x type
-@itemx --debug type
-Turn on particular debugging types. The following types are recognized:
-@samp{abnormal}, @samp{chat}, @samp{handshake}, @samp{uucp-proto},
-@samp{proto}, @samp{port}, @samp{config}, @samp{spooldir},
-@samp{execute}, @samp{incoming}, @samp{outgoing}. Not all types of
-debugging are effective for all programs. See the @code{debug}
-configuration command for details (@pxref{Debugging Levels}).
-
-Multiple types may be given, separated by commas, and the @samp{--debug}
-option may appear multiple times. A number may also be given, which
-will turn on that many types from the foregoing list; for example,
-@samp{--debug 2} is equivalent to @samp{--debug abnormal,chat}. To turn
-on all types of debugging, use @samp{-x all}.
-
-The @code{uulog} program uses @samp{-X} rather than @samp{-x} to select
-the debugging type; for @code{uulog}, @samp{-x} has a different meaning,
-for reasons of historical compatibility.
-
-@item -I file
-@itemx --config file
-Set the main configuration file to use. @xref{config File}. When this
-option is used, the programs will revoke any setuid privileges.
-
-@item -v
-@itemx --version
-Report version information and exit.
-
-@item --help
-Print a help message and exit.
-@end table
-
-@need 2000
-@node Invoking uucp, Invoking uux, Standard Options, Invoking the UUCP Programs
-@section Invoking uucp
-
-@menu
-* uucp Description:: Description of uucp
-* uucp Options:: Options Supported by uucp
-@end menu
-
-@node uucp Description, uucp Options, Invoking uucp, Invoking uucp
-@subsection uucp Description
-
-@example
-uucp [options] @file{source-file} @file{destination-file}
-uucp [options] @file{source-file}... @file{destination-directory}
-@end example
-
-The @code{uucp} command copies files between systems. Each @file{file}
-argument is either a file name on the local machine or is of the form
-@samp{system!file}. The latter is interpreted as being on a remote
-system.
-
-When @code{uucp} is used with two non-option arguments, the contents of
-the first file are copied to the second. With more than two non-option
-arguments, each source file is copied into the destination directory.
-
-A file may be transferred to or from @samp{system2} via @samp{system1}
-by using @samp{system1!system2!file}.
-
-Any file name that does not begin with @samp{/} or @samp{~} will be
-prepended with the current directory (unless the @samp{-W} or
-@samp{--noexpand} options are used). For example, if you are in the
-directory @samp{/home/ian}, then @samp{uucp foo remote!bar} is
-equivalent to @samp{uucp /home/ian/foo remote!/home/ian/bar}. Note that
-the resulting file name may not be valid on a remote system.
-
-A file name beginning with a simple @samp{~} starts at the UUCP public
-directory; a file name beginning with @samp{~name} starts at the home
-directory of the named user. The @samp{~} is interpreted on the
-appropriate system. Note that some shells will interpret an initial
-@samp{~} before @code{uucp} sees it; to avoid this the @samp{~} must be
-quoted.
-
-The shell metacharacters @samp{?} @samp{*} @samp{[} and @samp{]} are
-interpreted on the appropriate system, assuming they are quoted to
-prevent the shell from interpreting them first.
-
-The file copy does not take place immediately, but is queued up for the
-@code{uucico} daemon; the daemon is started immediately unless the
-@samp{-r} or @samp{--nouucico} option is given. The next time the
-remote system is called, the file(s) will be copied. @xref{Invoking
-uucico}.
-
-The file mode is not preserved, except for the execute bit. The
-resulting file is owned by the uucp user.
-
-@node uucp Options, , uucp Description, Invoking uucp
-@subsection uucp Options
-
-The following options may be given to @code{uucp}.
-
-@table @samp
-@item -c
-@itemx --nocopy
-Do not copy local source files to the spool directory. If they are
-removed before being processed by the @code{uucico} daemon, the copy
-will fail. The files must be readable by the @code{uucico} daemon, and
-by the invoking user.
-
-@item -C
-@itemx --copy
-Copy local source files to the spool directory. This is the default.
-
-@item -d
-@itemx --directories
-Create all necessary directories when doing the copy. This is the
-default.
-
-@item -f
-@itemx --nodirectories
-If any necessary directories do not exist for the destination file name,
-abort the copy.
-
-@item -R
-@itemx --recursive
-If any of the source file names are directories, copy their contents
-recursively to the destination (which must itself be a directory).
-
-@item -g grade
-@itemx --grade grade
-Set the grade of the file transfer command. Jobs of a higher grade are
-executed first. Grades run @kbd{0} to @kbd{9}, @kbd{A} to @kbd{Z},
-@kbd{a} to @kbd{z}, from high to low. @xref{When to Call}.
-
-@item -m
-@itemx --mail
-Report completion or failure of the file transfer by sending mail.
-
-@item -n user
-@itemx --notify user
-Report completion or failure of the file transfer by sending mail to the
-named user on the destination system.
-
-@item -r
-@itemx --nouucico
-Do not start the @code{uucico} daemon immediately; merely queue up the
-file transfer for later execution.
-
-@item -j
-@itemx --jobid
-Print the jobid on standard output. The job may be later cancelled by
-passing this jobid to the @samp{-kill} switch of @code{uustat}.
-@xref{Invoking uustat}.
-
-It is possible for some complex operations to produce more than one
-jobid, in which case each will be printed on a separate line. For
-example
-@example
-uucp sys1!~user1/file1 sys2!~user2/file2 ~user3
-@end example
-will generate two separate jobs, one for the system @samp{sys1} and one
-for the system @samp{sys2}.
-
-@item -W
-@itemx --noexpand
-Do not prepend remote relative file names with the current directory.
-
-@item -t
-@itemx --uuto
-This option is used by the @code{uuto} shell script; see @ref{Invoking
-uuto}. It causes @code{uucp} to interpret the final argument as
-@samp{system!user}. The file(s) are sent to
-@samp{~/receive/@var{user}/@var{local}} on the remote system, where
-@var{user} is from the final argument and @var{local} is the local UUCP
-system name. Also, @code{uucp} will act as though @samp{--notify user}
-were specified.
-
-@item -x type
-@itemx --debug type
-@itemx -I file
-@itemx --config file
-@itemx -v
-@itemx --version
-@itemx --help
-@xref{Standard Options}.
-@end table
-
-@node Invoking uux, Invoking uustat, Invoking uucp, Invoking the UUCP Programs
-@section Invoking uux
-
-@menu
-* uux Description:: Description of uux
-* uux Options:: Options Supported by uux
-* uux Examples:: Examples of uux Usage
-@end menu
-
-@node uux Description, uux Options, Invoking uux, Invoking uux
-@subsection uux Description
-
-@example
-uux [options] command
-@end example
-
-The @code{uux} command is used to execute a command on a remote system,
-or to execute a command on the local system using files from remote
-systems. The command is not executed immediately; the request is queued
-until the @code{uucico} daemon calls the system and transfers the
-necessary files. The daemon is started automatically unless one of the
-@samp{-r} or @samp{--nouucico} options is given.
-
-The actual command execution is done by the @code{uuxqt} daemon on the
-appropriate system.
-
-File arguments can be gathered from remote systems to the execution
-system, as can standard input. Standard output may be directed to a
-file on a remote system.
-
-The command name may be preceded by a system name followed by an
-exclamation point if it is to be executed on a remote system. An empty
-system name is taken as the local system.
-
-Each argument that contains an exclamation point is treated as naming a
-file. The system which the file is on is before the exclamation point,
-and the file name on that system follows it. An empty system name is
-taken as the local system; this form must be used to transfer a file to
-a command being executed on a remote system. If the file name is not
-absolute, the current working directory will be prepended to it; the
-result may not be meaningful on the remote system. A file name may
-begin with @samp{~/}, in which case it is relative to the UUCP public
-directory on the appropriate system. A file name may begin with
-@samp{~name/}, in which case it is relative to the home directory of the
-named user on the appropriate system.
-
-Standard input and output may be redirected as usual; the file names
-used may contain exclamation points to indicate that they are on remote
-systems. Note that the redirection characters must be quoted so that
-they are passed to @code{uux} rather than interpreted by the shell.
-Append redirection (@samp{>>}) does not work.
-
-All specified files are gathered together into a single directory
-before execution of the command begins. This means that each file
-must have a distinct name. For example,
-@example
-uux 'sys1!diff sys2!~user1/foo sys3!~user2/foo >!foo.diff'
-@end example
-will fail because both files will be copied to @samp{sys1} and stored
-under the name @file{foo}.
-
-Arguments may be quoted by parentheses to avoid interpretation of
-exclamation points. This is useful when executing the @code{uucp}
-command on a remote system.
-
-Most systems restrict the commands which may be executed using
-@samp{uux}. Many permit only the execution of @samp{rmail} and
-@samp{rnews}.
-
-A request to execute an empty command (e.g., @samp{uux sys!}) will
-create a poll file for the specified system; see @ref{Calling Other
-Systems} for an example of why this might be useful.
-
-@node uux Options, uux Examples, uux Description, Invoking uux
-@subsection uux Options
-
-The following options may be given to @code{uux}.
-
-@table @samp
-@item -
-@itemx -p
-@itemx --stdin
-Read standard input up to end of file, and use it as the standard input
-for the command to be executed.
-
-@item -c
-@itemx --nocopy
-Do not copy local files to the spool directory. This is the default.
-If they are removed before being processed by the @code{uucico} daemon,
-the copy will fail. The files must be readable by the @code{uucico}
-daemon, as well as the by the invoker of @code{uux}.
-
-@item -C
-@itemx --copy
-Copy local files to the spool directory.
-
-@item -l
-@itemx --link
-Link local files into the spool directory. If a file can not be linked
-because it is on a different device, it will be copied unless one of the
-@samp{-c} or @samp{--nocopy} options also appears (in other words, use
-of @samp{--link} switches the default from @samp{--nocopy} to
-@samp{--copy}). If the files are changed before being processed by the
-@code{uucico} daemon, the changed versions will be used. The files must
-be readable by the @code{uucico} daemon, as well as by the invoker of
-@code{uux}.
-
-@item -g grade
-@itemx --grade grade
-Set the grade of the file transfer command. Jobs of a higher grade are
-executed first. Grades run @kbd{0} to @kbd{9}, @kbd{A} to @kbd{Z},
-@kbd{a} to @kbd{z}, from high to low. @xref{When to Call}.
-
-@item -n
-@itemx --notification=no
-Do not send mail about the status of the job, even if it fails.
-
-@item -z
-@itemx --notification=error
-Send mail about the status of the job if an error occurs. For many
-@code{uuxqt} daemons, including the Taylor UUCP @code{uuxqt}, this is
-the default action; for those, @samp{--notification=error} will have no
-effect. However, some @code{uuxqt} daemons will send mail if the job
-succeeds, unless the @samp{--notification=error} option is used. Some
-other @code{uuxqt} daemons will not send mail even if the job fails,
-unless the @samp{--notification=error} option is used.
-
-@item -a address
-@itemx --requestor address
-Report job status, as controlled by the @samp{--notification} option, to
-the specified mail address.
-
-@item -r
-@itemx --nouucico
-Do not start the @code{uucico} daemon immediately; merely queue up the
-execution request for later processing.
-
-@item -j
-@itemx --jobid
-Print the jobid on standard output. A jobid will be generated for each
-file copy operation required to execute the command. These file copies
-may be later cancelled by passing the jobid to the @samp{-kill} switch
-of @code{uustat}. @xref{Invoking uustat}. Cancelling any file copies
-will make it impossible to complete execution of the job.
-
-@item -x type
-@itemx --debug type
-@itemx -v
-@itemx --version
-@itemx --help
-@xref{Standard Options}.
-@end table
-
-@node uux Examples, , uux Options, Invoking uux
-@subsection uux Examples
-
-Here are some examples of using @code{uux}.
-
-@example
-uux -z - sys1!rmail user1
-@end example
-This will execute the command @samp{rmail user1} on the system
-@samp{sys1}, giving it as standard input whatever is given to @code{uux}
-as standard input. If a failure occurs, mail will be sent to the user
-who ran the command.
-
-@example
-uux 'diff -c sys1!~user1/file1 sys2!~user2/file2 >!file.diff'
-@end example
-This will fetch the two named files from system @samp{sys1} and system
-@samp{sys2} and execute @samp{diff}, putting the result in
-@file{file.diff} in the current directory on the local system. The
-current directory must be writable by the @code{uuxqt} daemon for this
-to work.
-
-@example
-uux 'sys1!uucp ~user1/file1 (sys2!~user2/file2)'
-@end example
-Execute @code{uucp} on the system @samp{sys1} copying @file{file1} (on
-system @samp{sys1}) to @samp{sys2}. This illustrates the use of
-parentheses for quoting.
-
-@node Invoking uustat, Invoking uuname, Invoking uux, Invoking the UUCP Programs
-@section Invoking uustat
-
-@menu
-* uustat Description:: Description of uustat
-* uustat Options:: Options Supported by uustat
-* uustat Examples:: Examples of uustat Usage
-@end menu
-
-@node uustat Description, uustat Options, Invoking uustat, Invoking uustat
-@subsection uustat Description
-
-@example
-uustat -a
-uustat --all
-uustat [-eKRiMNQ] [-sS system] [-uU user] [-cC command] [-oy hours]
- [-B lines] [--executions] [--kill-all] [--rejuvenate-all]
- [--prompt] [--mail] [--notify] [--no-list] [--system system]
- [--not-system system] [--user user] [--not-user user]
- [--command command] [--not-command command] [--older-than hours]
- [--younger-than hours] [--mail-lines lines]
-uustat [-kr jobid] [--kill jobid] [--rejuvenate jobid]
-uustat -q [-sS system] [-oy hours] [--system system]
- [--not-system system ] [--older-than hours] [--younger-than hours]
-uustat --list [-sS system] [-oy hours] [--system system ]
- [--not-system system] [--older-than hours] [--younger-than hours]
-uustat -m
-uustat --status
-uustat -p
-uustat --ps
-@end example
-
-The @code{uustat} command can display various types of status
-information about the UUCP system. It can also be used to cancel or
-rejuvenate requests made by @code{uucp} or @code{uux}.
-
-With no options, @code{uustat} displays all jobs queued up for the
-invoking user, as if given the @samp{--user} option with the appropriate
-argument.
-
-If any of the @samp{-a}, @samp{--all}, @samp{-e}, @samp{--executions},
-@samp{-s}, @samp{--system}, @samp{-S}, @samp{--not-system}, @samp{-u},
-@samp{--user}, @samp{-U}, @samp{--not-user}, @samp{-c},
-@samp{--command}, @samp{-C}, @samp{--not-command}, @samp{-o},
-@samp{--older-than}, @samp{-y}, or @samp{--younger-than} options are
-given, then all jobs which match the combined specifications are
-displayed.
-
-The @samp{-K} or @samp{--kill-all} option may be used to kill off a
-selected group of jobs, such as all jobs more than 7 days old.
-
-@node uustat Options, uustat Examples, uustat Description, Invoking uustat
-@subsection uustat Options
-
-The following options may be given to @code{uustat}.
-
-@table @samp
-@item -a
-@itemx --all
-List all queued file transfer requests.
-
-@item -e
-@itemx --executions
-List queued execution requests rather than queued file transfer
-requests. Queued execution requests are processed by @code{uuxqt}
-rather than @code{uucico}. Queued execution requests may be waiting for
-some file to be transferred from a remote system. They are created by
-an invocation of @code{uux}.
-
-@item -s system
-@itemx --system system
-List all jobs queued up for the named system. These options may be
-specified multiple times, in which case all jobs for all the named
-systems will be listed. If used with @samp{--list}, only the systems
-named will be listed.
-
-@item -S system
-@itemx --not-system system
-List all jobs queued for systems other than the one named. These
-options may be specified multiple times, in which case no jobs from any
-of the specified systems will be listed. If used with @samp{--list},
-only the systems not named will be listed. These options may not be
-used with @samp{-s} or @samp{--system}.
-
-@item -u user
-@itemx --user user
-List all jobs queued up for the named user. These options may be
-specified multiple times, in which case all jobs for all the named users
-will be listed.
-
-@item -U user
-@itemx --not-user user
-List all jobs queued up for users other than the one named. These
-options may be specified multiple times, in which case no jobs from any
-of the specified users will be listed. These options may not be used
-with @samp{-u} or @samp{--user}.
-
-@item -c command
-@itemx --command command
-List all jobs requesting the execution of the named command. If
-@samp{command} is @samp{ALL} this will list all jobs requesting the
-execution of some command (as opposed to simply requesting a file
-transfer). These options may be specified multiple times, in which case
-all jobs requesting any of the commands will be listed.
-
-@item -C command
-@itemx --not-command command
-List all jobs requesting execution of some command other than the named
-command, or, if @samp{command} is @samp{ALL}, list all jobs that simply
-request a file transfer (as opposed to requesting the execution of some
-command). These options may be specified multiple times, in which case
-no job requesting one of the specified commands will be listed. These
-options may not be used with @samp{-c} or @samp{--command}.
-
-@item -o hours
-@itemx --older-than hours
-List all queued jobs older than the given number of hours. If used with
-@samp{--list}, only systems whose oldest job is older than the given
-number of hours will be listed.
-
-@item -y hours
-@itemx --younger-than hours
-List all queued jobs younger than the given number of hours. If used
-with @samp{--list}, only systems whose oldest job is younger than the
-given number of hours will be listed.
-
-@item -k jobid
-@itemx --kill jobid
-Kill the named job. The job id is shown by the default output format,
-as well as by the @samp{-j} or @samp{--jobid} options to @code{uucp} or
-@code{uux}. A job may only be killed by the user who created the job,
-or by the UUCP administrator, or the superuser. The @samp{-k} or
-@samp{--kill} options may be used multiple times on the command line to
-kill several jobs.
-
-@item -r jobid
-@itemx --rejuvenate jobid
-Rejuvenate the named job. This will mark it as having been invoked at
-the current time, affecting the output of the @samp{-o},
-@samp{--older-than}, @samp{-y}, or @samp{--younger-than} options,
-possibly preserving it from any automated cleanup daemon. The job id is
-shown by the default output format, as well as by the @samp{-j} or
-@samp{--jobid} options to @code{uucp} or @code{uux}. A job may only be
-rejuvenated by the user who created the job, or by the UUCP
-administrator, or the superuser. The @samp{-r} or @samp{--rejuvenate}
-options may be used multiple times on the command line to rejuvenate
-several jobs.
-
-@item -q
-@itemx --list
-Display the status of commands, executions and conversations for all
-remote systems for which commands or executions are queued. The
-@samp{-s}, @samp{--system}, @samp{-S}, @samp{--not-system}, @samp{-o},
-@samp{--older-than}, @samp{-y}, and @samp{--younger-than} options may be
-used to restrict the systems which are listed. Systems for which no
-commands or executions are queued will never be listed.
-
-@item -m
-@itemx --status
-Display the status of conversations for all remote systems.
-
-@item -p
-@itemx --ps
-Display the status of all processes holding UUCP locks on systems or
-ports.
-
-@need 500
-@item -i
-@itemx --prompt
-For each listed job, prompt whether to kill the job or not. If the
-first character of the input line is @kbd{y} or @kbd{Y}, the job will be
-killed.
-
-@item -K
-@itemx --kill-all
-Automatically kill each listed job. This can be useful for automatic
-cleanup scripts, in conjunction with the @samp{--mail} and
-@samp{--notify} options.
-
-@item -R
-@itemx --rejuvenate-all
-Automatically rejuvenate each listed job. This may not be used with
-@samp{--kill-all}.
-
-@item -M
-@itemx --mail
-For each listed job, send mail to the UUCP administrator. If the job is
-killed (due to @samp{--kill-all}, or @samp{--prompt} with an affirmative
-response) the mail will indicate that. A comment specified by the
-@samp{--comment} option may be included. If the job is an execution,
-the initial portion of its standard input will be included in the mail
-message; the number of lines to include may be set with the
-@samp{--mail-lines} option (the default is 100). If the standard input
-contains null characters, it is assumed to be a binary file and is not
-included.
-
-@item -N
-@itemx --notify
-For each listed job, send mail to the user who requested the job. The
-mail is identical to that sent by the @samp{-M} or @samp{--mail}
-options.
-
-@item -W comment
-@itemx --comment comment
-Specify a comment to be included in mail sent with the @samp{-M},
-@samp{--mail}, @samp{-N}, or @samp{--notify} options.
-
-@item -B lines
-@itemx --mail-lines lines
-When the @samp{-M}, @samp{--mail}, @samp{-N}, or @samp{--notify} options
-are used to send mail about an execution with standard input, this
-option controls the number of lines of standard input to include in the
-message. The default is 100.
-
-@item -Q
-@itemx --no-list
-Do not actually list the job, but only take any actions indicated by the
-@samp{-i}, @samp{--prompt}, @samp{-K}, @samp{--kill-all}, @samp{-M},
-@samp{--mail}, @samp{-N} or @samp{--notify} options.
-
-@item -x type
-@itemx --debug type
-@itemx -I file
-@itemx --config file
-@itemx -v
-@itemx --version
-@itemx --help
-@xref{Standard Options}.
-@end table
-
-@node uustat Examples, , uustat Options, Invoking uustat
-@subsection uustat Examples
-
-@example
-uustat --all
-@end example
-Display status of all jobs. A sample output line is as follows:
-@smallexample
-bugsA027h bugs ian 04-01 13:50 Executing rmail ian@@airs.com (sending 12 bytes)
-@end smallexample
-The format is
-@example
-jobid system user queue-date command (size)
-@end example
-The jobid may be passed to the @samp{--kill} or @samp{--rejuvenate}
-options. The size indicates how much data is to be transferred to the
-remote system, and is absent for a file receive request. The
-@samp{--system}, @samp{--not-system}, @samp{--user}, @samp{--not-user},
-@samp{--command}, @samp{--not-command}, @samp{--older-than}, and
-@samp{--younger-than} options may be used to control which jobs are
-listed.
-
-@example
-uustat --executions
-@end example
-Display status of queued up execution requests. A sample output line
-is as follows:
-@smallexample
-bugs bugs!ian 05-20 12:51 rmail ian
-@end smallexample
-The format is
-@example
-system requestor queue-date command
-@end example
-The @samp{--system}, @samp{--not-system}, @samp{--user},
-@samp{--not-user}, @samp{--command}, @samp{--not-command},
-@samp{--older-than}, and @samp{--younger-than} options may be used to
-control which requests are listed.
-
-@example
-uustat --list
-@end example
-Display status for all systems with queued up commands. A sample
-output line is as follows:
-@smallexample
-bugs 4C (1 hour) 0X (0 secs) 04-01 14:45 Dial failed
-@end smallexample
-This indicates the system, the number of queued commands, the age of the
-oldest queued command, the number of queued local executions, the age of
-the oldest queued execution, the date of the last conversation, and the
-status of that conversation.
-
-@example
-uustat --status
-@end example
-Display conversation status for all remote systems. A sample output
-line is as follows:
-@smallexample
-bugs 04-01 15:51 Conversation complete
-@end smallexample
-This indicates the system, the date of the last conversation, and the
-status of that conversation. If the last conversation failed,
-@code{uustat} will indicate how many attempts have been made to call the
-system. If the retry period is currently preventing calls to that
-system, @code{uustat} also displays the time when the next call will be
-permitted.
-
-@example
-uustat --ps
-@end example
-Display the status of all processes holding UUCP locks. The output
-format is system dependent, as @code{uustat} simply invokes @code{ps} on
-each process holding a lock.
-
-@example
-uustat -c rmail -o 168 -K -Q -M -N -W "Queued for over 1 week"
-@end example
-This will kill all @samp{rmail} commands that have been queued up
-waiting for delivery for over 1 week (168 hours). For each such
-command, mail will be sent both to the UUCP administrator and to the
-user who requested the rmail execution. The mail message sent will
-include the string given by the @samp{-W} option. The @samp{-Q} option
-prevents any of the jobs from being listed on the terminal, so any
-output from the program will be error messages.
-
-@node Invoking uuname, Invoking uulog, Invoking uustat, Invoking the UUCP Programs
-@section Invoking uuname
-
-@example
-uuname [-a] [--aliases]
-uuname -l
-uuname --local
-@end example
-
-By default, the @code{uuname} program simply lists the names of all the
-remote systems mentioned in the UUCP configuration files.
-
-The @code{uuname} program may also be used to print the UUCP name of the
-local system.
-
-The @code{uuname} program is mainly for use by shell scripts.
-
-The following options may be given to @code{uuname}.
-
-@table @samp
-@item -a
-@itemx --aliases
-List all aliases for remote systems, as well as their canonical names.
-Aliases may be specified in the @file{sys} file (@pxref{Naming the
-System}).
-
-@item -l
-@itemx --local
-Print the UUCP name of the local system, rather than listing the names
-of all the remote systems.
-
-@item -x type
-@itemx --debug type
-@itemx -I file
-@itemx --config file
-@itemx -v
-@itemx --version
-@itemx --help
-@xref{Standard Options}.
-@end table
-
-@node Invoking uulog, Invoking uuto, Invoking uuname, Invoking the UUCP Programs
-@section Invoking uulog
-
-@example
-uulog [-#] [-n lines] [-sf system] [-u user] [-DSF] [--lines lines]
- [--system system] [--user user] [--debuglog] [--statslog]
- [--follow] [--follow=system]
-@end example
-
-The @code{uulog} program may be used to display the UUCP log file.
-Different options may be used to select which parts of the file to
-display.
-
-@table @samp
-@item -#
-@itemx -n lines
-@itemx --lines lines
-Here @samp{#} is a number; e.g., @samp{-10}. The specified number of
-lines is displayed from the end of the log file. The default is to
-display the entire log file, unless the @samp{-f}, @samp{-F}, or
-@samp{--follow} options are used, in which case the default is to
-display 10 lines.
-
-@item -s system
-@itemx --system system
-Display only log entries pertaining to the specified system.
-
-@item -u user
-@itemx --user user
-Display only log entries pertaining to the specified user.
-
-@item -D
-@itemx --debuglog
-Display the debugging log file.
-
-@item -S
-@itemx --statslog
-Display the statistics log file.
-
-@item -F
-@itemx --follow
-Keep displaying the log file forever, printing new lines as they are
-appended to the log file.
-
-@item -f system
-@itemx --follow=system
-Keep displaying the log file forever, displaying only log entries
-pertaining to the specified system.
-
-@item -X type
-@itemx --debug type
-@itemx -I file
-@itemx --config file
-@itemx -v
-@itemx --version
-@itemx --help
-@xref{Standard Options}. Note that @code{uulog} specifies the debugging
-type using @samp{-X} rather than the usual @samp{-x}.
-@end table
-
-The operation of @code{uulog} depends to some degree upon the type of
-log files generated by the UUCP programs. This is a compile time
-option. If the UUCP programs have been compiled to use HDB style log
-files, @code{uulog} changes in the following ways:
-
-@itemize @bullet
-@item
-The new options @samp{-x} and @samp{--uuxqtlog} may be used to list the
-@code{uuxqt} log file.
-
-@item
-It is no longer possible to omit all arguments: one of @samp{-s},
-@samp{--system}, @samp{-f}, @samp{--follow=system}, @samp{-D},
-@samp{--debuglog}, @samp{-S}, @samp{--statslog}, @samp{-x}, or
-@samp{--uuxqtlog} must be used.
-
-@item
-The option @samp{--system ANY} may be used to list log file entries
-which do not pertain to any particular system.
-@end itemize
-
-@node Invoking uuto, Invoking uupick, Invoking uulog, Invoking the UUCP Programs
-@section Invoking uuto
-
-@example
-uuto files... system!user
-@end example
-
-The @code{uuto} program may be used to conveniently send files to a
-particular user on a remote system. It will arrange for mail to be sent
-to the remote user when the files arrive on the remote system, and he or
-she may easily retrieve the files using the @code{uupick} program
-(@pxref{Invoking uupick}). Note that @code{uuto} does not provide any
-security---any user on the remote system can examine the files.
-
-The last argument specifies the system and user name to which to send
-the files. The other arguments are the files or directories to be sent.
-
-The @code{uuto} program is actually just a trivial shell script which
-invokes the @code{uucp} program with the appropriate arguments. Any
-option which may be given to @code{uucp} may also be given to
-@code{uuto}. @xref{Invoking uucp}.
-
-@need 2000
-@node Invoking uupick, Invoking cu, Invoking uuto, Invoking the UUCP Programs
-@section Invoking uupick
-
-@example
-uupick [-s system] [--system system]
-@end example
-
-The @code{uupick} program is used to conveniently retrieve files
-transferred by the @code{uuto} program.
-
-For each file transferred by @code{uuto}, @code{uupick} will display the
-source system, the file name, and whether the name refers to a regular
-file or a directory. It will then wait for the user to specify an
-action to take. One of the following commands must be entered:
-
-@table @samp
-@item q
-Quit out of @code{uupick}.
-
-@item RETURN
-Skip the file.
-
-@item m [directory]
-Move the file or directory to the specified directory. If no directory
-is specified, the file is moved to the current directory.
-
-@item a [directory]
-Move all files from this system to the specified directory. If no
-directory is specified, the files are moved to the current directory.
-
-@item p
-List the file on standard output.
-
-@item d
-Delete the file.
-
-@item ! [command]
-Execute @samp{command} as a shell escape.
-@end table
-
-The @samp{-s} or @samp{--system} option may be used to restrict
-@code{uupick} to only present files transferred from a particular
-system. The @code{uupick} program also supports the standard UUCP
-program options; see @ref{Standard Options}.
-
-@need 2000
-@node Invoking cu, Invoking uucico, Invoking uupick, Invoking the UUCP Programs
-@section Invoking cu
-
-@menu
-* cu Description:: Description of cu
-* cu Commands:: Commands Supported by cu
-* cu Variables:: Variables Supported by cu
-* cu Options:: Options Supported by cu
-@end menu
-
-@node cu Description, cu Commands, Invoking cu, Invoking cu
-@subsection cu Description
-
-@example
-cu [options] [system | phone | "dir"]
-@end example
-
-The @code{cu} program is used to call up another system and act as a
-dial in terminal. It can also do simple file transfers with no error
-checking.
-
-The @code{cu} program takes a single non-option argument.
-
-If the argument is the string @samp{dir} cu will make a direct
-connection to the port. This may only be used by users with write
-access to the port, as it permits reprogramming the modem.
-
-Otherwise, if the argument begins with a digit, it is taken to be a
-phone number to call.
-
-Otherwise, it is taken to be the name of a system to call.
-
-The @samp{-z} or @samp{--system} options may be used to name a system
-beginning with a digit, and the @samp{-c} or @samp{--phone} options may
-be used to name a phone number that does not begin with a digit.
-
-The @code{cu} program locates a port to use in the UUCP configuration
-files. If a simple system name is given, it will select a port
-appropriate for that system. The @samp{-p}, @samp{--port}, @samp{-l},
-@samp{--line}, @samp{-s}, and @samp{--speed} options may be used to
-control the port selection.
-
-When a connection is made to the remote system, @code{cu} forks into two
-processes. One reads from the port and writes to the terminal, while
-the other reads from the terminal and writes to the port.
-
-@node cu Commands, cu Variables, cu Description, Invoking cu
-@subsection cu Commands
-
-The @code{cu} program provides several commands that may be used during
-the conversation. The commands all begin with an escape character,
-which by default is @kbd{~} (tilde). The escape character is only
-recognized at the beginning of a line. To send an escape character to
-the remote system at the start of a line, it must be entered twice. All
-commands are either a single character or a word beginning with @kbd{%}
-(percent sign).
-
-The @code{cu} program recognizes the following commands.
-
-@table @samp
-@item ~.
-Terminate the conversation.
-
-@item ~! command
-Run command in a shell. If command is empty, starts up a shell.
-
-@item ~$ command
-Run command, sending the standard output to the remote system.
-
-@item ~| command
-Run command, taking the standard input from the remote system.
-
-@item ~+ command
-Run command, taking the standard input from the remote system and
-sending the standard output to the remote system.
-
-@item ~#, ~%break
-Send a break signal, if possible.
-
-@item ~c directory, ~%cd directory
-Change the local directory.
-
-@item ~> file
-Send a file to the remote system. This just dumps the file over the
-communication line. It is assumed that the remote system is expecting
-it.
-
-@item ~<
-Receive a file from the remote system. This prompts for the local file
-name and for the remote command to execute to begin the file transfer.
-It continues accepting data until the contents of the @samp{eofread}
-variable are seen.
-
-@item ~p from to
-@itemx ~%put from to
-Send a file to a remote Unix system. This runs the appropriate
-commands on the remote system.
-
-@item ~t from to
-@itemx ~%take from to
-Retrieve a file from a remote Unix system. This runs the appropriate
-commands on the remote system.
-
-@item ~s variable value
-Set a @code{cu} variable to the given value. If value is not given, the
-variable is set to @samp{true}.
-
-@item ~! variable
-Set a @code{cu} variable to @samp{false}.
-
-@item ~z
-Suspend the cu session. This is only supported on some systems. On
-systems for which @kbd{^Z} may be used to suspend a job, @samp{~^Z} will
-also suspend the session.
-
-@item ~%nostop
-Turn off XON/XOFF handling.
-
-@item ~%stop
-Turn on XON/XOFF handling.
-
-@item ~v
-List all the variables and their values.
-
-@item ~?
-List all commands.
-@end table
-
-@node cu Variables, cu Options, cu Commands, Invoking cu
-@subsection cu Variables
-
-The @code{cu} program also supports several variables. They may be
-listed with the @samp{~v} command, and set with the @samp{~s} or
-@samp{~!} commands.
-
-@table @samp
-@item escape
-The escape character. The default is @kbd{~} (tilde).
-
-@item delay
-If this variable is true, @code{cu} will delay for a second, after
-recognizing the escape character, before printing the name of the local
-system. The default is true.
-
-@item eol
-The list of characters which are considered to finish a line. The
-escape character is only recognized after one of these is seen. The
-default is @kbd{carriage return}, @kbd{^U}, @kbd{^C}, @kbd{^O},
-@kbd{^D}, @kbd{^S}, @kbd{^Q}, @kbd{^R}.
-
-@item binary
-Whether to transfer binary data when sending a file. If this is false,
-then newlines in the file being sent are converted to carriage returns.
-The default is false.
-
-@item binary-prefix
-A string used before sending a binary character in a file transfer, if
-the @samp{binary} variable is true. The default is @samp{^V}.
-
-@item echo-check
-Whether to check file transfers by examining what the remote system
-echoes back. This probably doesn't work very well. The default is
-false.
-
-@item echonl
-The character to look for after sending each line in a file. The
-default is carriage return.
-
-@item timeout
-The timeout to use, in seconds, when looking for a character, either
-when doing echo checking or when looking for the @samp{echonl}
-character. The default is 30.
-
-@item kill
-The character to use delete a line if the echo check fails. The default
-is @kbd{^U}.
-
-@item resend
-The number of times to resend a line if the echo check continues to
-fail. The default is 10.
-
-@item eofwrite
-The string to write after sending a file with the @samp{~>} command.
-The default is @samp{^D}.
-
-@item eofread
-The string to look for when receiving a file with the @samp{ ~<}
-command. The default is @samp{$}, which is intended to be a typical
-shell prompt.
-
-@item verbose
-Whether to print accumulated information during a file transfer. The
-default is true.
-@end table
-
-@node cu Options, , cu Variables, Invoking cu
-@subsection cu Options
-
-The following options may be given to @code{cu}.
-
-@table @samp
-@item -e
-@itemx --parity=even
-Use even parity.
-
-@item -o
-@itemx --parity=odd
-Use odd parity.
-
-@item --parity=none
-Use no parity. No parity is also used if both @samp{-e} and @samp{-o}
-are given.
-
-@item -h
-@itemx --halfduplex
-Echo characters locally (half-duplex mode).
-
-@item --nostop
-Turn off XON/XOFF handling (it is on by default).
-
-@item -E char
-@itemx --escape char
-Set the escape character. Initially @kbd{~} (tilde). To eliminate the
-escape character, use @samp{-E ''}.
-
-@item -z system
-@itemx --system system
-The system to call.
-
-@item -c phone-number
-@itemx --phone phone-number
-The phone number to call.
-
-@item -p port
-@itemx -a port
-@itemx --port port
-Name the port to use.
-
-@item -l line
-@itemx --line line
-Name the line to use by giving a device name. This may be used to dial
-out on ports that are not listed in the UUCP configuration files. Write
-access to the device is required.
-
-@item -s speed
-@itemx -#
-@itemx --speed speed
-The speed (baud rate) to use. Here, @samp{-#} means an actual number;
-e.g., @samp{-9600}.
-
-@item -n
-@itemx --prompt
-Prompt for the phone number to use.
-
-@item -d
-Enter debugging mode. Equivalent to @samp{--debug all}.
-
-@item -x type
-@itemx --debug type
-@itemx -I file
-@itemx --config file
-@itemx -v
-@itemx --version
-@itemx --help
-@xref{Standard Options}.
-@end table
-
-@node Invoking uucico, Invoking uuxqt, Invoking cu, Invoking the UUCP Programs
-@section Invoking uucico
-
-@menu
-* uucico Description:: Description of uucico
-* uucico Options:: Options Supported by uucico
-@end menu
-
-@node uucico Description, uucico Options, Invoking uucico, Invoking uucico
-@subsection uucico Description
-
-@example
-uucico [options]
-@end example
-
-The @code{uucico} daemon processes file transfer requests queued by
-@code{uucp} and @code{uux}. It is started when @code{uucp} or
-@code{uux} is run (unless they are given the @samp{-r} or
-@samp{--nouucico} options). It is also typically started periodically
-using entries in the @file{crontab} table(s).
-
-When @code{uucico} is invoked with @samp{-r1}, @samp{--master},
-@samp{-s}, @samp{--system}, or @samp{-S}, the daemon will place a call
-to a remote system, running in master mode. Otherwise the daemon will
-start in slave mode, accepting a call from a remote system. Typically a
-special login name will be set up for UUCP which automatically invokes
-@code{uucico} when a remote system calls in and logs in under that name.
-
-When @code{uucico} terminates, it invokes the @code{uuxqt} daemon,
-unless the @samp{-q} or @samp{--nouuxqt} options were given;
-@code{uuxqt} executes any work orders created by @code{uux} on a remote
-system, and any work orders created locally which have received remote
-files for which they were waiting.
-
-If a call fails, @code{uucico} will normally refuse to retry the call
-until a certain (configurable) amount of time has passed. This may be
-overriden by the @samp{-f}, @samp{--force}, or @samp{-S} options.
-
-The @samp{-l}, @samp{--prompt}, @samp{-e}, or @samp{--loop} options may
-be used to force @code{uucico} to produce its own prompts of
-@samp{login: } and @samp{Password:}. When another @code{uucico} daemon
-calls in, it will see these prompts and log in as usual. The login name
-and password will normally be checked against a separate list kept
-specially for @code{uucico}, rather than the @file{/etc/passwd} file
-(@pxref{Configuration File Names}). It is possible, on some systems, to
-configure @code{uucico} to use @file{/etc/passwd}. The @samp{-l} or
-@samp{--prompt} options will prompt once and then exit; in this mode the
-UUCP administrator, or the superuser, may use the @samp{-u} or
-@samp{--login} option to force a login name, in which case @code{uucico}
-will not prompt for one. The @samp{-e} or @samp{--loop} options will
-prompt again after the first session is over; in this mode @code{uucico}
-will permanently control a port.
-
-If @code{uucico} receives a @code{SIGQUIT}, @code{SIGTERM} or
-@code{SIGPIPE} signal, it will cleanly abort any current conversation
-with a remote system and exit. If it receives a @code{SIGHUP} signal it
-will abort any current conversation, but will continue to place calls to
-(if invoked with @samp{-r1} or @samp{--master}) and accept calls from
-(if invoked with @samp{-e} or @samp{--loop}) other systems. If it
-receives a @code{SIGINT} signal it will finish the current conversation,
-but will not place or accept any more calls.
-
-@node uucico Options, , uucico Description, Invoking uucico
-@subsection uucico Options
-
-The following options may be given to @code{uucico}.
-
-@table @samp
-@item -r1
-@itemx --master
-Start in master mode: call out to a remote system. Implied by
-@samp{-s}, @samp{--system}, or @samp{-S}. If no system is specified,
-sequentially call every system for which work is waiting to be done.
-
-@item -r0
-@itemx --slave
-Start in slave mode. This is the default.
-
-@item -s system
-@itemx --system system
-Call the specified system.
-
-@item -S system
-Call the specified system, ignoring any required wait. This is
-equivalent to @samp{-s system -f}.
-
-@item -f
-@itemx --force
-Ignore any required wait for any systems to be called.
-
-@item -l
-@itemx --prompt
-Prompt for login name and password using @samp{login: } and
-@samp{Password:}. This allows @code{uucico} to be easily run from
-@code{inetd}. The login name and password are checked against the UUCP
-password file, which need not be @file{/etc/passwd}. The @samp{--login}
-option may be used to force a login name, in which cause @code{uucico}
-will only prompt for a password.
-
-@item -p port
-@itemx --port port
-Specify a port to call out on or to listen to.
-
-@item -e
-@itemx --loop
-Enter an endless loop of login/password prompts and slave mode daemon
-execution. The program will not stop by itself; you must use
-@code{kill} to shut it down.
-
-@item -w
-@itemx --wait
-After calling out (to a particular system when @samp{-s},
-@samp{--system}, or @samp{-S} is specifed, or to all systems which have
-work when just @samp{-r1} or @samp{--master} is specifed), begin an
-endless loop as with @samp{--loop}.
-
-@item -q
-@itemx --nouuxqt
-Do not start the @code{uuxqt} daemon when finished.
-
-@item -c
-@itemx --quiet
-If no calls are permitted at this time, then don't make the call, but
-also do not put an error message in the log file and do not update the
-system status (as reported by @code{uustat}). This can be convenient
-for automated polling scripts, which may want to simply attempt to call
-every system rather than worry about which particular systems may be
-called at the moment. This option also suppresses the log message
-indicating that there is no work to be done.
-
-@item -C
-@itemx --ifwork
-Only call the system named by @samp{-s}, @samp{--system}, or @samp{-S}
-if there is work for that system.
-
-@item -D
-@itemx --nodetach
-Do not detach from the controlling terminal. Normally @code{uucico}
-detaches from the terminal before each call out to another system and
-before invoking @code{uuxqt}. This option prevents this.
-
-@item -u name
-@itemx --login name
-Set the login name to use instead of that of the invoking user. This
-option may only be used by the UUCP administrator or the superuser. If
-used with @samp{--prompt}, this will cause @code{uucico} to prompt only
-for the password, not the login name.
-
-@item -z
-@itemx --try-next
-If a call fails after the remote system is reached, try the next
-alternate rather than simply exiting.
-
-@item -i type
-@itemx --stdin type
-Set the type of port to use when using standard input. The only
-supported port type is TLI, and this is only available on machines which
-support the TLI networking interface. Specifying @samp{-i TLI} causes
-@code{uucico} to use TLI calls to perform I/O.
-
-@item -X type
-Same as the standard option @samp{-x type}. Provided for historical
-compatibility.
-
-@item -x type
-@itemx --debug type
-@itemx -I file
-@itemx --config file
-@itemx -v
-@itemx --version
-@itemx --help
-@xref{Standard Options}.
-@end table
-
-@node Invoking uuxqt, Invoking uuchk, Invoking uucico, Invoking the UUCP Programs
-@section Invoking uuxqt
-
-@example
-uuxqt [-c command] [-s system] [--command command] [--system system]
-@end example
-
-The @code{uuxqt} daemon executes commands requested by @code{uux} from
-either the local system or from remote systems. It is started
-automatically by the @code{uucico} daemon (unless @code{uucico} is given
-the @samp{-q} or @samp{--nouuxqt} options).
-
-There is normally no need to run @code{uuxqt}, since it will be invoked
-by @code{uucico}. However, @code{uuxqt} can be invoked directly to
-provide greater control over the processing of the work queue.
-
-Multiple invocations of @code{uuxqt} may be run at once, as controlled
-by the @code{max-uuxqts} configuration command; see @ref{Miscellaneous
-(config)}.
-
-The following options may be given to @code{uuxqt}.
-
-@table @samp
-@item -c command
-@itemx --command command
-Only execute requests for the specified command. For example,
-@samp{uuxqt --command rmail}.
-
-@item -s system
-@itemx --system system
-Only execute requests originating from the specified system.
-
-@item -x type
-@itemx --debug type
-@itemx -I file
-@itemx --config
-@itemx -v
-@itemx --version
-@itemx --help
-@xref{Standard Options}.
-@end table
-
-@node Invoking uuchk, Invoking uuconv, Invoking uuxqt, Invoking the UUCP Programs
-@section Invoking uuchk
-
-@example
-uuchk [-s system] [--system system]
-@end example
-
-The @code{uuchk} program displays information read from the UUCP
-configuration files. It should be used to ensure that UUCP has been
-configured correctly.
-
-The @samp{-s} or @samp{--system} options may be used to display the
-configuration for just the specified system, rather than for all
-systems. The @code{uuchk} program also supports the standard UUCP
-program options; see @ref{Standard Options}.
-
-@need 2000
-@node Invoking uuconv, Invoking uusched, Invoking uuchk, Invoking the UUCP Programs
-@section Invoking uuconv
-
-@example
-uuconv -i type -o type [-p program] [--program program]
-uuconv --input type --output type [-p program] [--program program]
-@end example
-
-The @code{uuconv} program converts UUCP configuration files from one
-format to another. The type of configuration file to read is specified
-using the @samp{-i} or @samp{--input} options. The type of
-configuration file to write is specified using the @samp{-o} or
-@samp{--output} options.
-
-The supported configuration file types are @samp{taylor}, @samp{v2}, and
-@samp{hdb}. For a description of the @samp{taylor} configuration files,
-see @ref{Configuration Files}. The other types of configuration files
-are used by traditional UUCP packages, and are not described in this
-manual.
-
-An input configuration of type @samp{v2} or @samp{hdb} is read from a
-compiled in directory (specified by @samp{oldconfigdir} in
-@file{Makefile}). An input configuration of type @samp{taylor} is read
-from a compiled in directory by default, but may be overridden with the
-standard @samp{-I} or @samp{--config} options (@pxref{Standard
-Options}).
-
-The output configuration is written to files in the directory in which
-@code{uuconv} is run.
-
-Some information in the input files may not be representable in the
-desired output format, in which case @code{uuconv} will silently discard
-it. The output of @code{uuconv} should be carefully checked before it
-is used. The @code{uuchk} program may be used for this purpose; see
-@ref{Invoking uuchk}.
-
-The @samp{-p} or @samp{--program} option may be used to convert specific
-@code{cu} configuration information, rather than the default of only
-converting the @code{uucp} configuration information; see @ref{config
-File}.
-
-The @code{uuchk} program also supports the standard UUCP program
-options; see @ref{Standard Options}.
-
-@node Invoking uusched, , Invoking uuconv, Invoking the UUCP Programs
-@section Invoking uusched
-
-The @code{uusched} program is actually just a shell script which invokes
-the @code{uucico} daemon. It is provided for backward compatibility.
-It causes @code{uucico} to call all systems for which there is work.
-Any option which may be given to @code{uucico} may also be given to
-@code{uusched}. @xref{Invoking uucico}.
-
-@node Installing Taylor UUCP, Using Taylor UUCP, Invoking the UUCP Programs, Top
-@chapter Installing Taylor UUCP
-
-These are the installation instructions for the Taylor UUCP package.
-
-@menu
-* Compilation:: Compiling Taylor UUCP
-* Testing the Compilation:: Testing the Compilation
-* Installing the Binaries:: Installing the Binaries
-* Configuration:: Configuring Taylor UUCP
-* Testing the Installation:: Testing the Installation
-@end menu
-
-@node Compilation, Testing the Compilation, Installing Taylor UUCP, Installing Taylor UUCP
-@section Compiling Taylor UUCP
-
-If you have a source code distribution, you must first compile it for
-your system. Free versions of Unix, such as Linux, NetBSD, or FreeBSD,
-often come with pre-compiled binary distributions of UUCP. If you are
-using a binary distribution, you may skip to the configuration section
-(@pxref{Configuration}).
-
-Follow these steps to compile the source code.
-
-@enumerate
-
-@item
-Take a look at the top of @file{Makefile.in} and set the appropriate
-values for your system. These control where the programs are installed
-and which user on the system owns them (normally they will be owned by a
-special user @code{uucp} rather than a real person; they should probably
-not be owned by @code{root}).
-
-@item
-Run the shell script @code{configure}. This script was generated using
-the @code{autoconf} program written by David MacKenzie of the Free
-Software Foundation. It takes a while to run. It will generate the
-file @file{config.h} based on @file{config.h.in}, and, for each source
-code directory, will generate @file{Makefile} based on
-@file{Makefile.in}.
-
-You can pass certain arguments to @code{configure} in the environment.
-Because @code{configure} will compile little test programs to see what
-is available on your system, you must tell it how to run your compiler.
-It recognizes the following environment variables:
-
-@table @samp
-@item CC
-The C compiler. If this is not set, then if @code{configure} can find
-@samp{gcc} it will use it, otherwise it will use @samp{cc}.
-@item CFLAGS
-Flags to pass to the C compiler when compiling the actual code. If this
-is not set, @code{configure} will use @samp{-g}.
-@item LDFLAGS
-Flags to pass to the C compiler when only linking, not compiling. If
-this is not set, @code{configure} will use the empty string.
-@item LIBS
-Libraries to pass to the C compiler. If this is not set,
-@code{configure} will use the empty string.
-@item INSTALL
-The program to run to install UUCP in the binary directory. If this is
-not set, then if @code{configure} finds the BSD @code{install} program,
-it will set this to @samp{install -c}; otherwise, it will use @samp{cp}.
-@end table
-
-Suppose, for example, you want to set the environment variable @samp{CC}
-to @samp{rcc}. If you are using @code{sh}, @code{bash}, or @code{ksh},
-invoke @code{configure} as @samp{CC=rcc configure}. If you are using
-@code{csh}, do @samp{setenv CC rcc; sh configure}.
-
-On some systems you will want to use @samp{LIBS=-lmalloc}. On Xenix
-derived versions of Unix do not use @samp{LIBS=-lx} because this will
-bring in the wrong versions of certain routines; if you want to use
-@samp{-lx} you must specify @samp{LIBS=-lc -lx}.
-
-If @code{configure} fails for some reason, or if you have a very weird
-system, you may have to configure the package by hand. To do this, copy
-the file @file{config.h.in} to @file{config.h} and edit it for your
-system. Then for each source directory (the top directory, and the
-subdirectories @file{lib}, @file{unix}, and @file{uuconf}) copy
-@file{Makefile.in} to @file{Makefile}, find the words within @kbd{@@}
-characters, and set them correctly for your system.
-
-@item
-Igor V. Semenyuk provided this (lightly edited) note about ISC Unix 3.0.
-The @code{configure} script will default to passing @samp{-posix} to
-@code{gcc}. However, using @samp{-posix} changes the environment to
-POSIX, and on ISC 3.0, at least, the default for @code{POSIX_NO_TRUNC}
-is 1. This can lead to a problem when @code{uuxqt} executes
-@code{rmail}. @code{IDA sendmail} has dbm configuration files named
-@file{mailertable.@{dir,pag@}}. Notice these names are 15 characters
-long. When @code{uuxqt} compiled with the @samp{-posix} executes
-@code{rmail}, which in turn executes @code{sendmail}, the later is run
-under the POSIX environment too. This leads to @code{sendmail} bombing
-out with @samp{'error opening 'M' database: name too long'
-(mailertable.dir)}. It's rather obscure behaviour, and it took me a day
-to find out the cause. I don't use the @samp{-posix} switch; instead, I
-run @code{gcc} with @samp{-D_POSIX_SOURCE}, and add @samp{-lcposix} to
-@samp{LIBS}.
-
-@item
-On some versions of BSDI there is a bug in the shell which causes the
-default value for @samp{CFLAGS} to be set incorrectly. If @samp{echo
-$@{CFLAGS--g@}} echoes @samp{g} rather than @samp{-g}, then you must set
-@samp{CFLAGS} in the environment before running configure. There is a
-patch available from BSDI for this bug. (Reported by David Vrona).
-
-@item
-On AIX 3.2.5, and possibly other versions, @samp{cc -E} does not work,
-reporting @samp{Option NOROCONST is not valid}. Test this before
-running configure by doing something like @samp{touch /tmp/foo.c; cc -E
-/tmp/foo.c}. This may give a warning about the file being empty, but it
-should not give the @samp{Option NOROCONST} warning. The workaround is
-to remove the @samp{,noroconst} entry from the @samp{options} clause in
-the @samp{cc} stanza in @file{/etc/xlc.cfg}. (Reported by Chris Lewis).
-
-@item
-You should verify that @code{configure} worked correctly by checking
-@file{config.h} and the instances of @file{Makefile}.
-
-@item
-Edit @file{policy.h} for your local system. The comments explain the
-various choices. The default values are intended to be reasonable, so
-you may not have to make any changes.
-
-You must decide what type of configuration files to use; for more
-information on the choices, see @ref{Configuration}.
-
-You must also decide what sort of spool directory you want to use. If
-this is a new installation, I recommend @samp{SPOOLDIR_TAYLOR};
-otherwise, select the spool directory corresponding to your existing
-UUCP package.
-
-@item
-Type @samp{make} to compile everything.
-
-The @file{tstuu.c} file is not particularly portable; if you can't
-figure out how to compile it you can safely ignore it, as it is only
-used for testing. To use STREAMS pseudo-terminals, tstuu.c must be
-compiled with @samp{-DHAVE_STREAMS_PTYS}; this is not determined by the
-configure script.
-
-If you have any other problems there is probably a bug in the
-@code{configure} script.
-
-@item
-Please report any problems you have. That is the only way they will get
-fixed for other people. Supply a patch if you can (@pxref{Patches}), or
-just ask for help.
-
-@end enumerate
-
-@node Testing the Compilation, Installing the Binaries, Compilation, Installing Taylor UUCP
-@section Testing the Compilation
-
-If your system supports pseudo-terminals, and you compiled the code to
-support the new style of configuration files (@code{HAVE_TAYLOR_CONFIG}
-was set to 1 in @file{policy.h}), you should be able to use the
-@code{tstuu} program to test the @code{uucico} daemon. If your system
-supports STREAMS based pseudo-terminals, you must compile tstuu.c with
-@samp{-DHAVE_STREAMS_PTYS}. (The STREAMS based code was contributed by
-Marc Boucher).
-
-To run @code{tstuu}, just type @samp{tstuu} with no arguments. You must
-run it in the compilation directory, since it runs @file{./uucp},
-@file{./uux} and @file{./uucico}. The @code{tstuu} program will run a
-lengthy series of tests (it takes over ten minutes on a slow VAX). You
-will need a fair amount of space available in @file{/usr/tmp}. You will
-probably want to put it in the background. Do not use @kbd{^Z}, because
-the program traps on @code{SIGCHLD} and winds up dying. The
-@code{tstuu} program will create a directory @file{/usr/tmp/tstuu} and
-fill it with configuration files, and create spool directories
-@file{/usr/tmp/tstuu/spool1} and @file{/usr/tmp/tstuu/spool2}.
-
-If your system does not support the @code{FIONREAD} call, the
-@samp{tstuu} program will run very slowly. This may or may not get
-fixed in a later version.
-
-The @code{tstuu} program will finish with an execute file named
-@file{X.@var{something}} and a data file named @file{D.@var{something}}
-in the directory @file{/usr/tmp/tstuu/spool1} (or, more likely, in
-subdirectories, depending on the choice of @code{SPOOLDIR} in
-@file{policy.h}). Two log files will be created in the directory
-@file{/usr/tmp/tstuu}. They will be named @file{Log1} and @file{Log2},
-or, if you have selected @code{HAVE_HDB_LOGGING} in @file{policy.h},
-@file{Log1/uucico/test2} and @file{Log2/uucico/test1}. There should be
-no errors in the log files.
-
-You can test @code{uuxqt} with @samp{./uuxqt -I /usr/tmp/tstuu/Config1}.
-This should leave a command file @file{C.@var{something}} and a data
-file @file{D.@var{something}} in @file{/usr/tmp/tstuu/spool1} or in
-subdirectories. Again, there should be no errors in the log file.
-
-Assuming you compiled the code with debugging enabled, the @samp{-x}
-switch can be used to set debugging modes; see the @code{debug} command
-for details (@pxref{Debugging Levels}). Use @samp{-x all} to turn on
-all debugging and generate far more output than you will ever want to
-see. The @code{uucico} daemons will put debugging output in the files
-@file{Debug1} and @file{Debug2} in the directory @file{/usr/tmp/tstuu}.
-After that, you're pretty much on your own.
-
-On some systems you can also use @code{tstuu} to test @code{uucico}
-against the system @code{uucico}, by using the @samp{-u} switch. For
-this to work, change the definitions of @code{ZUUCICO_CMD} and
-@code{UUCICO_EXECL} at the top of @file{tstuu.c} to something
-appropriate for your system. The definitions in @file{tstuu.c} are what
-I used for Ultrix 4.0, on which @file{/usr/lib/uucp/uucico} is
-particularly obstinate about being run as a child; I was only able to
-run it by creating a login name with no password whose shell was
-@file{/usr/lib/uucp/uucico}. Calling login in this way will leave fake
-entries in @file{wtmp} and @file{utmp}; if you compile @file{tstout.c}
-(in the @file{contrib} directory) as a setuid @code{root} program,
-@code{tstuu} will run it to clear those entries out. On most systems,
-such hackery should not be necessary, although on SCO I had to su to
-@code{root} (@code{uucp} might also have worked) before I could run
-@file{/usr/lib/uucp/uucico}.
-
-You can test @code{uucp} and @code{uux} (give them the @samp{-r} switch
-to keep them from starting @code{uucico}) to make sure they create the
-right sorts of files. Unfortunately, if you don't know what the right
-sorts of files are, I'm not going to tell you here.
-
-If you can not run @code{tstuu}, or if it fails inexplicably, don't
-worry about it too much. On some systems @code{tstuu} will fail because
-of problems using pseudo terminals, which will not matter in normal use.
-The real test of the package is talking to another system.
-
-@node Installing the Binaries, Configuration, Testing the Compilation, Installing Taylor UUCP
-@section Installing the Binaries
-
-You can install the executable files by becoming @code{root} and typing
-@samp{make install}. Or you can look at what @samp{make install} does
-and do it by hand. It tries to preserve your old programs, if any, but
-it only does this the first time Taylor UUCP is installed (so that if
-you install several versions of Taylor UUCP, you can still go back to
-your original UUCP programs). You can retrieve the original programs by
-typing @samp{make uninstall}.
-
-Note that by default the programs are compiled with debugging
-information, and they are not stripped when they are installed. You may
-want to strip the installed programs to save disk space. For more
-information, see your system documentation for the @code{strip} program.
-
-Of course, simply installing the executable files is not enough. You
-must also arrange for them to be used correctly.
-
-@node Configuration, Testing the Installation, Installing the Binaries, Installing Taylor UUCP
-@section Configuring Taylor UUCP
-
-You will have to decide what types of configuration files you want to
-use. This package supports a new sort of configuration file; see
-@ref{Configuration Files}. It also supports V2 configuration files
-(@file{L.sys}, @file{L-devices}, etc.) and HDB configuration files
-(@file{Systems}, @file{Devices}, etc.). No documentation is provided
-for V2 or HDB configuration files. All types of configuration files can
-be used at once, if you are so inclined. Currently using just V2
-configuration files is not really possible, because there is no way to
-specify a dialer (there are no built in dialers, and the program does
-not know how to read @file{acucap} or @file{modemcap}); however, V2
-configuration files can be used with a new style dial file (@pxref{dial
-File}), or with a HDB @file{Dialers} file.
-
-Use of HDB configuration files has two known bugs. A blank line in the
-middle of an entry in the @file{Permissions} file will not be ignored as
-it should be. Dialer programs, as found in some versions of HDB, are
-not recognized directly. If you must use a dialer program, rather than
-an entry in @file{Devices}, you must use the @code{chat-program} command
-in a new style dial file; see @ref{dial File}. You will have to invoke
-the dialer program via a shell script or another program, since an exit
-code of 0 is required to recognize success; the @code{dialHDB} program
-in the @file{contrib} directory may be used for this purpose.
-
-The @code{uuconv} (@pxref{Invoking uuconv}) program can be used to
-convert from V2 or HDB configuration files to the new style (it can also
-do the reverse translation, if you are so inclined). It will not do all
-of the work, and the results should be carefully checked, but it can be
-quite useful.
-
-If you are installing a new system, you will, of course, have to write
-the configuration files; see @ref{Configuration Files} for details on
-how to do this.
-
-After writing the configuration files, use the @code{uuchk} program to
-verify that they are what you expect; see @ref{Invoking uuchk}.
-
-@node Testing the Installation, , Configuration, Installing Taylor UUCP
-@section Testing the Installation
-
-After you have written the configuration files, and verified them with
-the @code{uuchk} program (@pxref{Invoking uuchk}), you must check that
-UUCP can correctly contact another system.
-
-Tell @code{uucico} to dial out to the system by using the @samp{-s}
-system switch (e.g., @samp{uucico -s uunet}). The log file should tell
-you what happens. The exact location of the log file depends upon the
-settings in @file{policy.h} when you compiled the program, and on the
-use of the @code{logfile} command in the @file{config} file. Typical
-locations are @file{/usr/spool/uucp/Log} or a subdirectory under
-@file{/usr/spool/uucp/.Log}.
-
-If you compiled the code with debugging enabled, you can use debugging
-mode to get a great deal of information about what sort of data is
-flowing back and forth; the various possibilities are described with the
-@code{debug} command (@pxref{Debugging Levels}). When initially setting
-up a connection @samp{-x chat} is probably the most useful (e.g.,
-@samp{uucico -s uunet -x chat}); you may also want to use @samp{-x
-handshake,incoming,outgoing}. You can use @samp{-x} multiple times on
-one command line, or you can give it comma separated arguments as in the
-last example. Use @samp{-x all} to turn on all possible debugging
-information.
-
-The debugging information is written to a file, normally
-@file{/usr/spool/uucp/Debug}, although the default can be changed in
-@file{policy.h}, and the @file{config} file can override the default
-with the @code{debugfile} command. The debugging file may contain
-passwords and some file contents as they are transmitted over the line,
-so the debugging file is only readable by the @code{uucp} user.
-
-You can use the @samp{-f} switch to force @code{uucico} to call out even
-if the last call failed recently; using @samp{-S} when naming a system
-has the same effect. Otherwise the status file (in the @file{.Status}
-subdirectory of the main spool directory, normally
-@file{/usr/spool/uucp}) (@pxref{Status Directory}) will prevent too many
-attempts from occurring in rapid succession.
-
-On older System V based systems which do not have the @code{setreuid}
-system call, problems may arise if ordinary users can start an execution
-of @code{uuxqt}, perhaps indirectly via @code{uucp} or @code{uux}. UUCP
-jobs may wind up executing with a real user ID of the user who invoked
-@code{uuxqt}, which can cause problems if the UUCP job checks the real
-user ID for security purposes. On such systems, it is safest to put
-@samp{run-uuxqt never} (@pxref{Miscellaneous (config)}) in the
-@file{config} file, so that @code{uucico} never starts @code{uuxqt}, and
-invoke @code{uuxqt} directly from a @file{crontab} file.
-
-Please let me know about any problems you have and how you got around
-them. If you do report a problem, please include the version number of
-the package you are using, the operating system you are running it on,
-and a sample of the debugging file showing the problem (debugging
-information is usually what is needed, not just the log file). General
-questions such as ``why doesn't @code{uucico} dial out'' are impossible
-to answer without much more information.
-
-@node Using Taylor UUCP, Configuration Files, Installing Taylor UUCP, Top
-@chapter Using Taylor UUCP
-
-@menu
-* Calling Other Systems:: Calling Other Systems
-* Accepting Calls:: Accepting Calls
-* Mail and News:: Using UUCP for Mail and News
-* The Spool Directory Layout:: The Spool Directory Layout
-* Spool Directory Cleaning:: Cleaning the UUCP Spool Directory
-@end menu
-
-@node Calling Other Systems, Accepting Calls, Using Taylor UUCP, Using Taylor UUCP
-@section Calling Other Systems
-@cindex calling out
-
-By default @code{uucp} and @code{uux} will automatically start up
-@code{uucico} to call another system whenever work is queued up.
-However, the call may fail, or you may have put in time restrictions
-which prevent the call at that time (perhaps because telephone rates are
-high) (@pxref{When to Call}). Also, a remote system may have work
-queued up for your system, but may not be calling you for some reason
-(perhaps you have agreed that your system should always place the call).
-To make sure that work gets transferred between the systems withing a
-reasonable time period, you should arrange to periodically invoke
-@code{uucico}.
-
-These periodic invocations are normally triggered by entries in the
-@file{crontab} file. The exact format of @file{crontab} files, and how
-new entries are added, varies from system to system; check your local
-documentation (try @samp{man cron}).
-
-To attempt to call all systems with outstanding work, use the command
-@samp{uucico -r1}. To attempt to call a particular system, use the
-command @samp{uucico -s @var{system}}. To attempt to call a particular
-system, but only if there is work for it, use the command @samp{uucico
--C -s @var{system}}. (@pxref{Invoking uucico}).
-
-A common case is to want to try to call a system at a certain time, with
-periodic retries if the call fails. A simple way to do this is to
-create an empty UUCP command file, known as a @dfn{poll file}. If a
-poll file exists for a system, then @samp{uucico -r1} will place a call
-to it. If the call succeeds, the poll file will be deleted.
-
-A poll file can be easily created using the @samp{uux} command, by
-requesting the execution of an empty command. To create a poll file for
-@var{system}, just do something like this:
-@example
-uux -r @var{system}!
-@end example
-The @samp{-r} tells @samp{uux} to not start up @samp{uucico}
-immediately. Of course, if you do want @samp{uucico} to start up right
-away, omit the @samp{-r}; if the call fails, the poll file will be left
-around to cause a later call.
-
-For example, I use the following crontab entries locally:
-
-@example
-45 * * * * /bin/echo /usr/lib/uucp/uucico -r1 | /bin/su uucpa
-40 4,10,15 * * * /usr/bin/uux -r uunet!
-@end example
-
-Every hour, at 45 minutes past, this will check if there is any work to
-be done, and, if there is, will call the appropriate system. Also, at
-4:40am, 10:40am, and 3:40pm, this will create a poll file file for
-@samp{uunet}, forcing the next run of @code{uucico} to call
-@samp{uunet}.
-
-@node Accepting Calls, Mail and News, Calling Other Systems, Using Taylor UUCP
-@section Accepting Calls
-@cindex calling in
-@cindex accepting calls
-
-To accept calls from another system, you must arrange matters such that
-when that system calls in, it automatically invokes @code{uucico} on
-your system.
-
-The most common arrangement is to create a special user name and
-password for incoming UUCP calls. This user name typically uses the
-same user ID as the regular @code{uucp} user (Unix permits several user
-names to share the same user ID). The shell for this user name should
-be set to @code{uucico}.
-
-Here is a sample @file{/etc/passwd} line to accept calls from a remote
-system named airs:
-@example
-Uairs:@var{password}:4:8:airs UUCP:/usr/spool/uucp:/usr/lib/uucp/uucico
-@end example
-The details may vary on your system. You must use reasonable user and
-group ID's. You must use the correct file name for @code{uucico}. The
-@var{password} must appear in the UUCP configuration files on the remote
-system, but will otherwise never be seen or typed by a human.
-
-Note that @code{uucico} appears as the login shell, and that it will be
-run with no arguments. This means that it will start in slave mode and
-accept an incoming connection. @xref{Invoking uucico}.
-
-On some systems, creating an empty file named @file{.hushlogin} in the
-home directory will skip the printing of various bits of information
-when the remote @code{uucico} logs in, speeding up the UUCP connection
-process.
-
-For the greatest security, each system which calls in should use a
-different user name, each with a different password, and the
-@code{called-login} command should be used in the @file{sys} file to
-ensure that the correct login name is used. @xref{Accepting a Call},
-and see @ref{Security}.
-
-If you never need to dial out from your system, but only accept incoming
-calls, you can arrange for @code{uucico} to handle logins itself,
-completely controlling the port, by using the @samp{--endless} option.
-@xref{Invoking uucico}.
-
-@node Mail and News, The Spool Directory Layout, Accepting Calls, Using Taylor UUCP
-@section Using UUCP for Mail and News.
-@cindex mail
-@cindex news
-
-Taylor UUCP does not include a mail package. All Unix systems come with
-some sort of mail delivery agent, typically @code{sendmail} or
-@code{MMDF}. Source code is available for some alternative mail
-delivery agents, such as @code{IDA sendmail} and @code{smail}.
-
-Taylor UUCP also does not include a news package. The two major Unix
-news packages are @code{C-news} and @code{INN}. Both are available in
-source code form.
-
-Configuring and using mail delivery agents is a notoriously complex
-topic, and I will not be discussing it here. Configuring news systems
-is usually simpler, but I will not be discussing that either. I will
-merely describe the interactions between the mail and news systems and
-UUCP.
-
-A mail or news system interacts with UUCP in two ways: sending and
-receiving.
-
-@menu
-* Sending mail or news:: Sending mail or news via UUCP
-* Receiving mail or news:: Receiving mail or news via UUCP
-@end menu
-
-@node Sending mail or news, Receiving mail or news, Mail and News, Mail and News
-@subsection Sending mail or news via UUCP
-
-When mail is to be sent from your machine to another machine via UUCP,
-the mail delivery agent will invoke @code{uux}. It will generally run a
-command such as @samp{uux - @var{system}!rmail @var{address}}, where
-@var{system} is the remote system to which the mail is being sent. It
-may pass other options to @code{uux}, such as @samp{-r} or @samp{-g}
-(@pxref{Invoking uux}).
-
-The news system also invokes @code{uux} in order to transfer articles to
-another system. The only difference is that news will use @code{uux} to
-invoke @code{rnews} on the remote system, rather than @code{rmail}.
-
-You should arrange for your mail and news systems to invoke the Taylor
-UUCP version of @code{uux}. If you only have Taylor UUCP, or if you
-simply replace any existing version of @code{uux} with the Taylor UUCP
-version, this will probably happen automatically. However, if you have
-two UUCP packages installed on your system, you will probably have to
-modify the mail and news configuration files in some way.
-
-Actually, if both the system UUCP and Taylor UUCP are using the same
-spool directory format, the system @code{uux} will probably work fine
-with the Taylor @code{uucico} (the reverse is not the case: the Taylor
-@code{uux} requires the Taylor @code{uucico}). However, data transfer
-will be somewhat more efficient if the Taylor @code{uux} is used.
-
-@node Receiving mail or news, , Sending mail or news, Mail and News
-@subsection Receiving mail or news via UUCP
-
-To receive mail, all that is necessary is for UUCP to invoke
-@code{rmail}. Any mail delivery agent will provide an appropriate
-version of @code{rmail}; you must simply make sure that it is in the
-command path used by UUCP (it almost certainly already is). The default
-command path is set in @file{policy.h}, and it may be overridden for a
-particular system by the @code{command-path} command
-(@pxref{Miscellaneous (sys)}).
-
-Similarly, for news UUCP must be able to invoke @code{rnews}. Any news
-system will provide a version of @code{rnews}, and you must ensure that
-is in a directory on the path that UUCP will search.
-
-@node The Spool Directory Layout, Spool Directory Cleaning, Mail and News, Using Taylor UUCP
-@section The Spool Directory Layout
-@cindex spool directory
-
-In general, the layout of the spool directory may be safely ignored.
-However, it is documented here for the curious. This description only
-covers the @code{SPOOLDIR_TAYLOR} layout. The ways in which the other
-spool directory layouts differ are described in the source file
-@file{unix/spool.c}.
-
-Directories and files are only created when they are needed, so a
-typical system will not have all of the entries described here.
-
-@menu
-* System Spool Directories:: System Spool Directories
-* Status Directory:: Status Spool Directory
-* Execution Subdirectories:: Execution Spool Subdirectories
-* Other Spool Subdirectories:: Other Spool Subdirectories
-* Spool Lock Files:: Spool Directory Lock Files
-@end menu
-
-@node System Spool Directories, Status Directory, The Spool Directory Layout, The Spool Directory Layout
-@subsection System Spool Directories
-@cindex system spool directories
-
-@table @file
-@item @var{system}
-There is a subdirectory of the main spool directory for each remote
-system.
-
-@item @var{system}/C.
-This directory stores files describing file transfer commands to be sent
-to the @var{system}. Each file name starts with @file{C.@var{g}}, where
-@var{g} is the job grade. Each file contains one or more commands. For
-details of the commands, see @ref{UUCP Protocol Commands}.
-
-@item @var{system}/D.
-This directory stores data files. Files with names like
-@file{D.@var{g}@var{ssss}}, where @var{g} is the grade and @var{ssss} is
-a sequence number, are waiting to be transferred to the @var{system}, as
-directed by the files in the @file{@var{system}/C.} directory. Files
-with other names, typically @file{D.@var{system}@var{g}@var{ssss}}, have
-been received from @var{system} and are waiting to be processed by an
-execution file in the @file{@var{system}/X.} directory.
-
-@item @var{system}/D.X
-This directory stores data files which will become execution files on
-the remote system. In current practice, this directory rarely exists,
-because most simple executions, including typical uses of @code{rmail}
-and @code{rnews}, send an @samp{E} command rather than an execution file
-(@pxref{The E Command}).
-
-@item @var{system}/X.
-This directory stores execution files which have been received from
-@var{system}. This directory normally exists, even though the
-corresponding @file{D.X} directory does not, because @code{uucico} will
-create an execution file on the fly when it receives an @samp{E}
-command.
-
-@item @var{system}/SEQF
-This file holds the sequence number of the last job sent to
-@var{system}. The sequence number is used to ensure that file names are
-unique in the remote system spool directory. The file is four bytes
-long. Sequence numbers are composed of digits and the upper case
-letters.
-@end table
-
-@node Status Directory, Execution Subdirectories, System Spool Directories, The Spool Directory Layout
-@subsection Status Directory
-
-@table @file
-@item .Status
-@cindex .Status
-@cindex status files
-This directory holds status files for each remote system. The name of
-the status file is the name of the system which it describes. Each
-status file describes the last conversation with the system. Running
-@code{uustat --status} basically just formats and prints the contents of
-the status files (@pxref{uustat Examples}).
-
-Each status file has a single text line with six fields.
-
-@table @asis
-@item code
-A code indicating the status of the last conversation. The following
-values are defined, though not all are actually used.
-@table @samp
-@item 0
-Conversation completed normally.
-@item 1
-@code{uucico} was unable to open the port.
-@item 2
-The last call to the system failed while dailing.
-@item 3
-The last call to the system failed while logging in.
-@item 4
-The last call to the system failed during the initial UUCP protocol
-handshake (@pxref{The Initial Handshake}).
-@item 5
-The last call to the system failed after the initial handshake.
-@item 6
-@code{uucico} is currently talking to the system.
-@item 7
-The last call to the system failed because it was the wrong time to call
-(this is not used if calling the system is never permitted).
-@end table
-
-@item retries
-The number of retries since the last successful call.
-
-@item time of last call
-The time of the last call, in seconds since the epoch (as returned by
-the @code{time} system call).
-
-@item wait
-If the last call failed, this is the number of seconds since the last
-call before @code{uucico} may attempt another call. This is set based
-on the retry time; see @ref{When to Call}. The @samp{-f} or @samp{-S}
-options to @code{uucico} direct it to ignore this wait time; see
-@ref{Invoking uucico}.
-
-@item description
-A text description of the status, corresponding to the code in the first
-field. This may contain spaces.
-
-@item system name
-The name of the remote system.
-@end table
-@end table
-
-@node Execution Subdirectories, Other Spool Subdirectories, Status Directory, The Spool Directory Layout
-@subsection Execution Subdirectories
-
-@table @file
-@item .Xqtdir
-@cindex .Xqtdir
-When @code{uuxqt} executes a job requested by @code{uux}, it first
-changes the working directory to the @file{.Xqtdir} subdirectory. This
-permits the job to create any sort of temporary file without worrying
-about overwriting other files in the spool directory. Any files left
-in the @file{.Xqtdir} subdirectory are removed after each execution is
-complete.
-
-@item .Xqtdir@var{nnnn}
-When several instances of @code{uuxqt} are executing simultaneously,
-each one executes jobs in a separate directory. The first uses
-@file{.Xqtdir}, the second uses @file{.Xqtdir0001}, the third uses
-@file{.Xqtdir0002}, and so forth.
-
-@item .Corrupt
-@cindex .Corrupt
-If @code{uuxqt} encounters an execution file which it is unable to
-parse, it saves it in the @file{.Corrupt} directory, and sends mail
-about it to the UUCP administrator.
-
-@item .Failed
-@cindex .Failed
-If @code{uuxqt} executes a job, and the job fails, and there is enough
-disk space to hold the command file and all the data files, then
-@code{uuxqt} saves the files in the @file{.Failed} directory, and sends
-mail about it to the UUCP administrator.
-@end table
-
-@node Other Spool Subdirectories, Spool Lock Files, Execution Subdirectories, The Spool Directory Layout
-@subsection Other Spool Subdirectories
-
-@table @file
-@item .Sequence
-@cindex .Sequence
-This directory holds conversation sequence number files. These are used
-if the @code{sequence} command is used for a system
-(@pxref{Miscellaneous (sys)}). The sequence number for the system
-@var{system} is stored in the file @file{.Sequence/@var{system}}. It is
-simply stored as a printable number.
-
-@item .Temp
-@cindex .Temp
-This directory holds data files as they are being received from a remote
-system, before they are moved to their final destination. For file send
-requests which use a valid temporary file name in the @var{temp} field
-of the @samp{S} or @samp{E} command (@pxref{The S Command}),
-@code{uucico} receives the file into
-@file{.Temp/@var{system}/@var{temp}}, where @var{system} is the name of
-the remote system, and @var{temp} is the temporary file name. If a
-conversation fails during a file transfer, these files are used to
-automatically restart the file transfer from the point of failure.
-
-If the @samp{S} or @samp{E} command does not include a temporary file
-name, automatic restart is not possible. In this case, the files are
-received into a randomly named file in the @file{.Temp} directory
-itself.
-
-@item .Preserve
-@cindex .Preserve
-This directory holds data files which could not be transferred to a
-remote system for some reason (for example, the data file might be
-large, and exceed size restrictions imposed by the remote system). When
-a locally requested file transfer fails, @code{uucico} will store the
-data file in the @file{.Preserve} directory, and send mail to the
-requestor describing the failure and naming the saved file.
-
-@item .Received
-@cindex .Received
-This directory records which files have been received. If a
-conversation fails just after @code{uucico} acknowledges receipt of a
-file, it is possible for the acknowledgement to be lost. If this
-happens, the remote system will resend the file. If the file were an
-execution request, and @code{uucico} did not keep track of which files
-it had already received, this could lead to the execution being
-performed twice.
-
-To avoid this problem, when a conversation fails, @code{uucico} records
-each file that has been received, but for which the remote system may
-not have received the acknowledgement. It records this information by
-creating an empty file with the name
-@file{.Received/@var{system}/@var{temp}}, where @var{system} is the name
-of the remote system, and @var{temp} is the @var{temp} field of the
-@samp{S} or @samp{E} command from the remote system (@pxref{The S
-Command}). Then, if the remote system offers the file again in the next
-conversation, @code{uucico} refuses the send request and deletes the
-record in the @file{.Received} directory. This approach only works for
-file sends which use a temporary file name, but this is true of all
-execution requests.
-@end table
-
-@node Spool Lock Files, , Other Spool Subdirectories, The Spool Directory Layout
-@subsection Lock Files in the Spool Directory
-@cindex lock files in spool directory
-
-Lock files for devices and systems are stored in the lock directory,
-which may or may not be the same as the spool directory. The lock
-directory is set at compilation time by @code{LOCKDIR} in
-@file{policy.h}, which may be overridden by the @code{lockdir} command
-in the @file{config} file (@pxref{Miscellaneous (config)}).
-
-For a description of the names used for device lock files, and the
-format of the contents of a lock file, see @ref{UUCP Lock Files}.
-
-@table @file
-@item LCK..@var{sys}
-@cindex LCK..@var{sys}
-@cindex system lock files
-A lock file for a system, where @var{sys} is the system name. As noted
-above, these lock files are kept in the lock directory, which may not be
-the spool directory. These lock files are created by @code{uucico}
-while talking to a remote system, and are used to prevent multiple
-simultaneous conversations with a system.
-
-On systems which limit file names to 14 characters, only the first eight
-characters of the system name are used in the lock file name. This
-requires that the names of each directly connected remote system be
-unique in the first eight characters.
-
-@item LCK.XQT.@var{NN}
-@cindex LCK.XQT.@var{NN}
-When @code{uuxqt} starts up, it uses lock files to determine how many
-other @code{uuxqt} daemons are currently running. It first tries to
-lock @file{LCK.XQT.0}, then @file{LCK.XQT.1}, and so forth. This is
-used to implement the @code{max-uuxqts} command (@pxref{Miscellaneous
-(config)}). It is also used to parcel out the @file{.Xqtdir}
-subdirectories (@pxref{Execution Subdirectories}).
-
-@item LXQ.@var{cmd}
-@cindex LXQ.@var{cmd}
-When @code{uuxqt} is invoked with the @samp{-c} or @samp{--command}
-option (@pxref{Invoking uuxqt}), it creates a lock file named after the
-command it is executing. For example, @samp{uuxqt -c rmail} will create
-the lock file @file{LXQ.rmail}. This prevents other @code{uuxqt}
-daemons from executing jobs of the specified type.
-
-@item @var{system}/X./L.@var{xxx}
-@cindex L.@var{xxx}
-While @code{uuxqt} is executing a particular job, it creates a lock file
-with the same name as the @file{X.} file describing the job, but
-replacing the initial @samp{X} with @samp{L}. This ensures that if
-multiple @code{uuxqt} daemons are running, they do not simultaneously
-execute the same job.
-
-@item LCK..SEQ
-This lock file is used to control access to the sequence files for each
-system (@pxref{System Spool Directories}). It is only used on systems
-which do not support POSIX file locking using the @code{fcntl} system
-call.
-@end table
-
-@node Spool Directory Cleaning, , The Spool Directory Layout, Using Taylor UUCP
-@section Cleaning the Spool Directory
-@cindex spool directory, cleaning
-@cindex cleaning the spool directory
-
-The spool directory may need to be cleaned up periodically. Under some
-circumstances, files may accumulate in various subdirectories, such as
-@file{.Preserve} (@pxref{Other Spool Subdirectories}) or @file{.Corrupt}
-(@pxref{Execution Subdirectories}).
-
-Also, if a remote system stops calling in, you may want to arrange for
-any queued up mail to be returned to the sender. This can be done using
-the @code{uustat} command (@pxref{Invoking uustat}).
-
-The @file{contrib} directory includes a simple @file{uuclean} script
-which may be used as an example of a clean up script. It can be run
-daily out of @file{crontab}.
-
-You should periodically trim the UUCP log files, as they will otherwise
-grow without limit. The names of the log files are set in
-@file{policy.h}, and may be overridden in the configuration file
-(@pxref{config File}). By default they are are
-@file{/usr/spool/uucp/Log} and @file{/usr/spool/uucp/Stats}. You may
-find the @code{savelog} program in the @file{contrib} directory to be of
-use. There is a manual page for it in @file{contrib} as well.
-
-@node Configuration Files, Protocols, Using Taylor UUCP, Top
-@chapter Taylor UUCP Configuration Files
-
-This chapter describes the configuration files accepted by the Taylor
-UUCP package if compiled with @code{HAVE_TAYLOR_CONFIG} set to 1 in
-@file{policy.h}.
-
-The configuration files are normally found in the directory
-@var{newconfigdir}, which is defined by the @file{Makefile} variable
-@file{newconfigdir}; by default @var{newconfigdir} is
-@file{/usr/local/conf/uucp}. However, the main configuration file,
-@file{config}, is the only one which must be in that directory, since it
-may specify a different location for any or all of the other files. You
-may run any of the UUCP programs with a different main configuration
-file by using the @samp{-I} or @samp{--config} option; this can be
-useful when testing a new configuration. When you use the @samp{-I}
-option the programs will revoke any setuid privileges.
-
-@menu
-* Configuration Overview:: Configuration File Overview
-* Configuration File Format:: Configuration File Format
-* Configuration Examples:: Examples of Configuration Files
-* Time Strings:: How to Write Time Strings
-* Chat Scripts:: How to Write Chat Scripts
-* config File:: The Main Configuration File
-* sys File:: The System Configuration File
-* port File:: The Port Configuration Files
-* dial File:: The Dialer Configuration Files
-* UUCP Over TCP:: UUCP Over TCP
-* Security:: Security Issues
-@end menu
-
-@node Configuration Overview, Configuration File Format, Configuration Files, Configuration Files
-@section Configuration File Overview
-
-UUCP uses several different types of configuration files, each
-describing a different kind of information. The commands permitted in
-each file are described in detail below. This section is a brief
-description of some of the different types of files.
-
-The @file{config} file is the main configuration file. It describes
-general information not associated with a particular remote system, such
-as the location of various log files. There are reasonable defaults for
-everything that may be specified in the @file{config} file, so you may
-not actually need one on your system.
-
-There may be only one @file{config} file, but there may be one or more
-of each other type of file. The default is one file for each type, but
-more may be listed in the @file{config} file.
-
-The @file{sys} files are used to describe remote systems. Each remote
-system to which you connect must be listed in a @file{sys} file. A
-@file{sys} file will include information for a system, such as the speed
-(baud rate) to use, or when to place calls.
-
-For each system you wish to call, you must describe one or more ports;
-these ports may be defined directly in the @file{sys} file, or they may
-be defined in a @file{port} file.
-
-The @file{port} files are used to describe ports. A port is a
-particular hardware connection on your computer. You would normally
-define as many ports as there are modems attached to your computer. A
-TCP connection is also described using a port.
-
-The @file{dial} files are used to describe dialers. Dialer is
-essentially another word for modem. The @file{dial} file describes the
-commands UUCP should use to dial out on a particular type of modem. You
-would normally define as many dialers as there are types of modems
-attached to your computer. For example, if you have three Telebit
-modems used for UUCP, you would probably define three ports and one
-dialer.
-
-There are other types of configuration files, but these are the
-important ones. The other types are described below.
-
-@node Configuration File Format, Configuration Examples, Configuration Overview, Configuration Files
-@section Configuration File Format
-
-All the configuration files follow a simple line-oriented
-@samp{@var{keyword} @var{value}} format. Empty lines are ignored, as
-are leading spaces; unlike HDB, lines with leading spaces are read. The
-first word on each line is a keyword. The rest of the line is
-interpreted according to the keyword. Most keywords are followed by
-numbers, boolean values or simple strings with no embedded spaces.
-
-The @kbd{#} character is used for comments. Everything from a @kbd{#}
-to the end of the line is ignored unless the @kbd{#} is preceded by a
-@kbd{\} (backslash); if the @kbd{#} is preceeded by a @kbd{\}, the
-@kbd{\} is removed but the @kbd{#} remains in the line. This can be
-useful for a phone number containing a @kbd{#}. To enter the sequence
-@samp{\#}, use @samp{\\#}.
-
-The backslash character may be used to continue lines. If the last
-character in a line is a backslash, the backslash is removed and the
-line is continued by the next line. The second line is attached to the
-first with no intervening characters; if you want any whitespace between
-the end of the first line and the start of the second line, you must
-insert it yourself.
-
-However, the backslash is not a general quoting character. For example,
-you cannot use it to get an embedded space in a string argument.
-
-Everything after the keyword must be on the same line. A @var{boolean}
-may be specified as @kbd{y}, @kbd{Y}, @kbd{t}, or @kbd{T} for true and
-@kbd{n}, @kbd{N}, @kbd{f}, or @kbd{F} for false; any trailing characters
-are ignored, so @code{true}, @code{false}, etc., are also acceptable.
-
-@node Configuration Examples, Time Strings, Configuration File Format, Configuration Files
-@section Examples of Configuration Files
-
-This section provides few typical examples of configuration files.
-There are also sample configuration files in the @file{sample}
-subdirectory of the distribution.
-
-@menu
-* config File Examples:: Examples of the Main Configuration File
-* Leaf Example:: Call a Single Remote Site
-* Gateway Example:: The Gateway for Several Local Systems
-@end menu
-
-@node config File Examples, Leaf Example, Configuration Examples, Configuration Examples
-@subsection config File Examples
-@cindex config file examples
-
-To start with, here are some examples of uses of the main configuration
-file, @file{config}. For a complete description of the commands that
-are permitted in @file{config}, see @ref{config File}.
-
-In many cases you will not need to create a @file{config} file at all.
-The most common reason to create one is to give your machine a special
-UUCP name. Other reasons might be to change the UUCP spool directory,
-or to permit any remote system to call in.
-
-If you have an internal network of machines, then it is likely that the
-internal name of your UUCP machine is not the name you want to use when
-calling other systems. For example, here at @file{airs.com} our
-mail/news gateway machine is named @file{elmer.airs.com} (it is one of
-several machines all named @file{@var{localname}.airs.com}). If we did
-not provide a @file{config} file, then our UUCP name would be
-@file{elmer}; however, we actually want it to be @file{airs}.
-Therefore, we use the following line in @file{config}:
-
-@example
-nodename airs
-@end example
-
-@cindex changing spool directory
-@cindex spool directory, changing
-The UUCP spool directory name is set in @file{policy.h} when the code is
-compiled. You might at some point decide that it is appropriate to move
-the spool directory, perhaps to put it on a different disk partition.
-You would use the following commands in @file{config} to change to
-directories on the partition @file{/uucp}:
-
-@example
-spool /uucp/spool
-pubdir /uucp/uucppublic
-logfile /uucp/spool/Log
-debugfile /uucp/spool/Debug
-@end example
-
-You would then move the contents of the current spool directory to
-@file{/uucp/spool}. If you do this, make sure that no UUCP processes
-are running while you change @file{config} and move the spool directory.
-
-@cindex anonymous UUCP
-Suppose you wanted to permit any system to call in to your system and
-request files. This is generally known as @dfn{anonymous UUCP}, since
-the systems which call in are effectively anonymous. By default,
-unknown systems are not permitted to call in. To permit this you must
-use the @code{unknown} command in @file{config}. The @code{unknown}
-command is followed by any command that may appear in the system file;
-for full details, see @ref{sys File}.
-
-I will show two possible anonymous UUCP configurations. The first will
-let any system call in and download files, but will not permit them to
-upload files to your system.
-
-@example
-# No files may be transferred to this system
-unknown receive-request no
-# The public directory is /usr/spool/anonymous
-unknown pubdir /usr/spool/anonymous
-# Only files in the public directory may be sent (the default anyhow)
-unknown remote-send ~
-@end example
-
-@noindent
-Setting the public directory is convenient for the systems which call
-in. It permits to request a file by prefixing it with @file{~/}. For
-example, assuming your system is known as @samp{server}, then to
-retrieve the file @file{/usr/spool/anonymous/INDEX} a user on a remote
-site could just enter @samp{uucp server!~/INDEX ~}; this would transfer
-@file{INDEX} from @samp{server}'s public directory to the user's local
-public directory. Note that when using @samp{csh} or @samp{bash} the
-@kbd{!} and the second @kbd{~} must be quoted.
-
-The next example will permit remote systems to upload files to a special
-directory named @file{/usr/spool/anonymous/upload}. Permitting a remote
-system to upload files permits it to send work requests as well; this
-example is careful to prohibit commands from unknown systems.
-
-@example
-# No commands may be executed (the list of permitted commands is empty)
-unknown commands
-# The public directory is /usr/spool/anonymous
-unknown pubdir /usr/spool/anonymous
-# Only files in the public directory may be sent; users may not download
-# files from the upload directory
-unknown remote-send ~ !~/upload
-# May only upload files into /usr/spool/anonymous/upload
-unknown remote-receive ~/upload
-@end example
-
-@node Leaf Example, Gateway Example, config File Examples, Configuration Examples
-@subsection Leaf Example
-
-@cindex leaf site
-@cindex sys file example (leaf)
-A relatively common simple case is a @dfn{leaf site}, a system which
-only calls or is called by a single remote site. Here is a typical
-@file{sys} file that might be used in such a case. For full details on
-what commands can appear in the @file{sys} file, see @ref{sys File}.
-
-This is the @file{sys} file that is used at @file{airs.com}. We use a
-single modem to dial out to @file{uunet}. This example shows how you
-can specify the port and dialer information directly in the @file{sys}
-file for simple cases. It also shows the use of the following:
-
-@table @code
-
-@item call-login
-Using @code{call-login} and @code{call-password} allows the default
-login chat script to be used. In this case, the login name is specified
-in the call-out login file (@pxref{Configuration File Names}).
-
-@item call-timegrade
-@file{uunet} is requested to not send us news during the daytime.
-
-@item chat-fail
-If the modem returns @samp{BUSY} or @samp{NO CARRIER} the call is
-immediately aborted.
-
-@item protocol-parameter
-Since @file{uunet} tends to be slow, the default timeout has been
-increased.
-
-@end table
-
-This @file{sys} file relies on certain defaults. It will allow
-@file{uunet} to queue up @samp{rmail} and @samp{rnews} commands. It
-will allow users to request files from @file{uunet} into the UUCP public
-directory. It will also allow @file{uunet} to request files from the
-UUCP public directory; in fact @file{uunet} never requests files, but
-for additional security we could add the line @samp{request false}.
-
-@example
-# The following information is for uunet
-system uunet
-
-# The login name and password are kept in the callout password file
-call-login *
-call-password *
-
-# We can send anything at any time.
-time any
-
-# During the day we only accept grade `Z' or above; at other times
-# (not mentioned here) we accept all grades. uunet queues up news
-# at grade `d', which is lower than `Z'.
-call-timegrade Z Wk0755-2305,Su1655-2305
-
-# The phone number.
-phone 7389449
-
-# uunet tends to be slow, so we increase the timeout
-chat-timeout 120
-
-# We are using a preconfigured Telebit 2500.
-port type modem
-port device /dev/ttyd0
-port speed 19200
-port carrier true
-port dialer chat "" ATZ\r\d\c OK ATDT\D CONNECT
-port dialer chat-fail BUSY
-port dialer chat-fail NO\sCARRIER
-port dialer complete \d\d+++\d\dATH\r\c
-port dialer abort \d\d+++\d\dATH\r\c
-
-# Increase the timeout and the number of retries.
-protocol-parameter g timeout 20
-protocol-parameter g retries 10
-@end example
-
-@node Gateway Example, , Leaf Example, Configuration Examples
-@subsection Gateway Example
-
-@cindex gateway
-@cindex sys file example (gateway)
-Many organizations have several local machines which are connected by
-UUCP, and a single machine which connects to the outside world. This
-single machine is often referred to as a @dfn{gateway} machine.
-
-For this example I will assume a fairly simple case. It should still
-provide a good general example. There are three machines, @file{elmer},
-@file{comton} and @file{bugs}. @file{elmer} is the gateway machine for
-which I will show the configuration file. @file{elmer} calls out to
-@file{uupsi}. As an additional complication, @file{uupsi} knows
-@file{elmer} as @file{airs}; this will show how a machine can have one
-name on an internal network but a different name to the external world.
-@file{elmer} has two modems. It also has an TCP connection to
-@file{uupsi}, but since that is supposed to be reserved for interactive
-work (it is, perhaps, only a 9600 baud SLIP line) it will only use it if
-the modems are not available.
-
-A network this small would normally use a single @file{sys} file.
-However, for pedagogical purposes I will show two separate @file{sys}
-files, one for the local systems and one for @file{uupsi}. This is done
-with the @code{sysfile} command in the @file{config} file. Here is the
-@file{config} file.
-
-@example
-# This is config
-# The local sys file
-sysfile /usr/local/lib/uucp/sys.local
-# The remote sys file
-sysfile /usr/local/lib/uucp/sys.remote
-@end example
-
-Using the defaults feature of the @file{sys} file can greatly simplify
-the listing of local systems. Here is @file{sys.local}. Note that this
-assumes that the local systems are trusted; they are permited to request
-any world readable file and to write files into any world writable
-directory.
-
-@example
-# This is sys.local
-# Get the login name and password to use from the call-out file
-call-login *
-call-password *
-
-# The systems must use a particular login
-called-login Ulocal
-
-# Permit sending any world readable file
-local-send /
-remote-send /
-
-# Permit receiving into any world writable directory
-local-receive /
-remote-receive /
-
-# Call at any time
-time any
-
-# Use port1, then port2
-port port1
-
-alternate
-
-port port2
-
-# Now define the systems themselves. Because of all the defaults we
-# used, there is very little to specify for the systems themselves.
-
-system comton
-phone 5551212
-
-system bugs
-phone 5552424
-@end example
-
-The @file{sys.remote} file describes the @file{uupsi} connection. The
-@code{myname} command is used to change the UUCP name to @file{airs}
-when talking to @file{uupsi}.
-
-@example
-# This is sys.remote
-# Define uupsi
-system uupsi
-
-# The login name and password are in the call-out file
-call-login *
-call-password *
-
-# We can call out at any time
-time any
-
-# uupsi uses a special login name
-called-login Uuupsi
-
-# uuspi thinks of us as `airs'
-myname airs
-
-# The phone number
-phone 5554848
-
-# We use port2 first, then port1, then TCP
-
-port port2
-
-alternate
-
-port port1
-
-alternate
-
-# We don't bother to make a special entry in the port file for TCP, we
-# just describe the entire port right here. We use a special chat
-# script over TCP because the usual one confuses some TCP servers.
-port type TCP
-address uu.psi.com
-chat ogin: \L word: \P
-@end example
-
-The ports are defined in the file @file{port} (@pxref{port File}). For
-this example they are both connected to the same type of 2400 baud
-Hayes-compatible modem.
-
-@example
-# This is port
-
-port port1
-type modem
-device /dev/ttyd0
-dialer hayes
-speed 2400
-
-port port2
-type modem
-device /dev/ttyd1
-dialer hayes
-speed 2400
-@end example
-
-Dialers are described in the @file{dial} file (@pxref{dial File}).
-
-@example
-# This is dial
-
-dialer hayes
-
-# The chat script used to dial the phone. \D is the phone number.
-chat "" ATZ\r\d\c OK ATDT\D CONNECT
-
-# If we get BUSY or NO CARRIER we abort the dial immediately
-chat-fail BUSY
-chat-fail NO\sCARRIER
-
-# When the call is over we make sure we hangup the modem.
-complete \d\d+++\d\dATH\r\c
-abort \d\d+++\d\dATH\r\c
-@end example
-
-@node Time Strings, Chat Scripts, Configuration Examples, Configuration Files
-@section Time Strings
-@cindex time strings
-
-Several commands use time strings to specify a range of times. This
-section describes how to write time strings.
-
-A time string may be a list of simple time strings separated with a
-vertical bar @samp{|} or a comma @samp{,}.
-
-Each simple time string must begin with @samp{Su}, @samp{Mo}, @samp{Tu},
-@samp{We}, @samp{Th}, @samp{Fr}, or @samp{Sa}, or @samp{Wk} for any
-weekday, or @samp{Any} for any day.
-
-Following the day may be a range of hours separated with a hyphen using
-24 hour time. The range of hours may cross 0; for example
-@samp{2300-0700} means any time except 7 AM to 11 PM. If no time is
-given, calls may be made at any time on the specified day(s).
-
-The time string may also be the single word @samp{Never}, which does not
-match any time. The time string may also be a single word with a name
-defined in a previous @code{timetable} command (@pxref{Miscellaneous
-(config)}).
-
-Here are a few sample time strings with an explanation of what they
-mean.
-
-@table @samp
-
-@item Wk2305-0855,Sa,Su2305-1655
-
-This means weekdays before 8:55 AM or after 11:05 PM, any time Saturday,
-or Sunday before 4:55 PM or after 11:05 PM. These are approximately the
-times during which night rates apply to phone calls in the U.S.A. Note
-that this time string uses, for example, @samp{2305} rather than
-@samp{2300}; this will ensure a cheap rate phone call even if the
-computer clock is running up to five minutes ahead of the real time.
-
-@item Wk0905-2255,Su1705-2255
-
-This means weekdays from 9:05 AM to 10:55 PM, or Sunday from 5:05 PM to
-10:55 PM. This is approximately the opposite of the previous example.
-
-@item Any
-
-This means any day. Since no time is specified, it means any time on
-any day.
-
-@end table
-
-@node Chat Scripts, config File, Time Strings, Configuration Files
-@section Chat Scripts
-@cindex chat scripts
-
-Chat scripts are used in several different places, such as dialing out
-on modems or logging in to remote systems. Chat scripts are made up of
-pairs of strings. The program waits until it sees the first string,
-known as the @dfn{expect} string, and then sends out the second string,
-the @dfn{send} string.
-
-Each chat script is defined using a set of commands. These commands
-always end in a string beginning with @code{chat}, but may start with
-different strings. For example, in the @file{sys} file there is one set
-of commands beginning with @code{chat} and another set beginning with
-@code{called-chat}. The prefixes are only used to disambiguate
-different types of chat scripts, and this section ignores the prefixes
-when describing the commands.
-
-@table @code
-
-@item chat @var{strings}
-@findex chat
-
-Specify a chat script. The arguments to the @code{chat} command are
-pairs of strings separated by whitespace. The first string of each pair
-is an expect string, the second is a send string. The program will wait
-for the expect string to appear; when it does, the program will send the
-send string. If the expect string does not appear within a certain
-number of seconds (as set by the @code{chat-timeout} command), the chat
-script fails and, typically, the call is aborted. If the final expect
-string is seen (and the optional final send string has been sent), the
-chat script is successful.
-
-An expect string may contain additional subsend and subexpect strings,
-separated by hyphens. If the expect string is not seen, the subsend
-string is sent and the chat script continues by waiting for the
-subexpect string. This means that a hyphen may not appear in an expect
-string; on an ASCII system, use @samp{\055} instead.
-
-An expect string may simply be @samp{""}, meaning to skip the expect
-phase. Otherwise, the following escape characters may appear in expect
-strings:
-
-@table @samp
-@item \b
-a backspace character
-@item \n
-a newline or line feed character
-@item \N
-a null character (for HDB compatibility)
-@item \r
-a carriage return character
-@item \s
-a space character
-@item \t
-a tab character
-@item \\
-a backslash character
-@item \@var{ddd}
-character @var{ddd}, where @var{ddd} are up to three octal digits
-@item \x@var{ddd}
-character @var{ddd}, where @var{ddd} are hexadecimal digits.
-@end table
-
-As in C, there may be up to three octal digits following a backslash,
-but the hexadecimal escape sequence continues as far as possible. To
-follow a hexadecimal escape sequence with a hex digit, interpose a send
-string of @samp{""}.
-
-A chat script expect string may also specify a timeout. This is done by
-using the escape sequence @samp{\W@var{seconds}}. This escape sequence
-may only appear at the very end of the expect string. It temporarily
-overrides the timeout set by @code{chat-timeout} (described below) only
-for the expect string to which it is attached.
-
-A send string may simply be @samp{""} to skip the send phase.
-Otherwise, all of the escape characters legal for expect strings may be
-used, and the following escape characters are also permitted:
-
-@table @samp
-@item EOT
-send an end of transmission character (@kbd{^D})
-@item BREAK
-send a break character (may not work on all systems)
-@item \c
-suppress trailing carriage return at end of send string
-@item \d
-delay sending for 1 or 2 seconds
-@item \e
-disable echo checking
-@item \E
-enable echo checking
-@item \K
-same as @samp{BREAK} (for HDB compatibility)
-@item \p
-pause sending for a fraction of a second
-@end table
-
-Some specific types of chat scripts also define additional escape
-sequences that may appear in the send string. For example, the login
-chat script defines @samp{\L} and @samp{\P} to send the login name and
-password, respectively.
-
-A carriage return will be sent at the end of each send string, unless
-the @kbd{\c} escape sequence appears in the string. Note that some UUCP
-packages use @kbd{\b} for break, but here it means backspace.
-
-Echo checking means that after writing each character the program will
-wait until the character is echoed. Echo checking must be turned on
-separately for each send string for which it is desired; it will be
-turned on for characters following @kbd{\E} and turned off for characters
-following @kbd{\e}.
-
-@item chat-timeout @var{number}
-@findex chat-timeout
-
-The number of seconds to wait for an expect string in the chat script,
-before timing out and sending the next subsend, or failing the chat
-script entirely. The default value is 10 for a login chat or 60 for any
-other type of chat.
-
-@item chat-fail @var{string}
-@findex chat-fail
-
-If the @var{string} is seen at any time during a chat script, the chat
-script is aborted. The string may not contain any whitespace
-characters: escape sequences must be used for them. Multiple
-@code{chat-fail} commands may appear in a single chat script. The
-default is to have none.
-
-This permits a chat script to be quickly aborted if an error string is
-seen. For example, a script used to dial out on a modem might use the
-command @samp{chat-fail BUSY} to stop the chat script immediately if the
-string @samp{BUSY} was seen.
-
-The @code{chat-fail} strings are considered in the order they are
-listed, so if one string is a suffix of another the longer one should be
-listed first. This affects the error message which will be logged. Of
-course, if one string is contained within another, but is not a suffix,
-the smaller string will always be found before the larger string could
-match.
-
-@item chat-seven-bit @var{boolean}
-@findex chat-seven-bit
-
-If the argument is true, all incoming characters are stripped to seven
-bits when being compared to the expect string. Otherwise all eight bits
-are used in the comparison. The default is true, because some Unix
-systems generate parity bits during the login prompt which must be
-ignored while running a chat script. This has no effect on any
-@code{chat-program}, which must ignore parity by itself if necessary.
-
-@item chat-program @var{strings}
-@findex chat-program
-
-Specify a program to run before executing the chat script. This program
-could run its own version of a chat script, or it could do whatever it
-wants. If both @code{chat-program} and @code{chat} are specified, the
-program is executed first followed by the chat script.
-
-The first argument to the @code{chat-program} command is the program
-name to run. The remaining arguments are passed to the program. The
-following escape sequences are recognized in the arguments:
-
-@table @kbd
-@item \Y
-port device name
-@item \S
-port speed
-@item \\
-backslash
-@end table
-
-Some specific uses of @code{chat-program} define additional escape
-sequences.
-
-Arguments other than escape sequences are passed exactly as they appear
-in the configuration file, except that sequences of whitespace are
-compressed to a single space character (this exception may be removed in
-the future).
-
-If the @code{chat-program} command is not used, no program is run.
-
-On Unix, the standard input and standard output of the program will be
-attached to the port in use. Anything the program writes to standard
-error will be written to the UUCP log file. No other file descriptors
-will be open. If the program does not exit with a status of 0, it will
-be assumed to have failed. This means that the dialing programs used by
-some versions of HDB may not be used directly, but you may be able to
-run them via the @code{dialHDB} program in the @file{contrib} directory.
-
-The program will be run as the @code{uucp} user, and the environment
-will be that of the process that started @code{uucico}, so care must be
-taken to maintain security.
-
-No search path is used to find the program; a full file name must be
-given. If the program is an executable shell script, it will be passed
-to @file{/bin/sh} even on systems which are unable to execute shell
-scripts.
-
-@end table
-
-Here is a simple example of a chat script that might be used to reset a
-Hayes compatible modem.
-
-@example
-chat "" ATZ OK-ATZ-OK
-@end example
-
-The first expect string is @samp{""}, so it is ignored. The chat script
-then sends @samp{ATZ}. If the modem responds with @samp{OK}, the chat
-script finishes. If 60 seconds (the default timeout) pass before seeing
-@samp{OK}, the chat script sends another @samp{ATZ}. If it then sees
-@samp{OK}, the chat script succeeds. Otherwise, the chat script fails.
-
-For a more complex chat script example, see @ref{Logging In}.
-
-@node config File, sys File, Chat Scripts, Configuration Files
-@section The Main Configuration File
-@cindex config file
-@cindex main configuration file
-@cindex configuration file (config)
-
-The main configuration file is named @file{config}.
-
-Since all the values that may be specified in the main configuration
-file also have defaults, there need not be a main configuration file at
-all.
-
-Each command in @file{config} may have a program prefix, which is a
-separate word appearing at the beginning of the line. The currently
-supported prefixes are @samp{uucp} and @samp{cu}. Any command prefixed
-by @samp{uucp} will not be read by the @code{cu} program. Any command
-prefixed by @samp{cu} will only be read by the @code{cu} program. For
-example, to use a list of systems known only to @code{cu}, list them in
-a separate file @file{@var{file}} and put @samp{cu sysfile
-@file{@var{file}}} in @file{config}.
-
-@menu
-* Miscellaneous (config):: Miscellaneous config File Commands
-* Configuration File Names:: Using Different Configuration Files
-* Log File Names:: Using Different Log Files
-* Debugging Levels:: Debugging Levels
-@end menu
-
-@node Miscellaneous (config), Configuration File Names, config File, config File
-@subsection Miscellaneous config File Commands
-
-@table @code
-
-@item nodename @var{string}
-@findex nodename
-@itemx hostname @var{string}
-@findex hostname
-@itemx uuname @var{string}
-@findex uuname
-@cindex UUCP system name
-@cindex system name
-
-These keywords are equivalent. They specify the UUCP name of the local
-host. If there is no configuration file, an appropriate system function
-will be used to get the host name, if possible.
-
-@item spool @var{string}
-@findex spool
-@cindex spool directory, setting
-@cindex /usr/spool/uucp
-
-Specify the spool directory. The default is from @file{policy.h}. This
-is where UUCP files are queued. Status files and various sorts of
-temporary files are also stored in this directory and subdirectories of
-it.
-
-@item pubdir @var{string}
-@findex pubdir in config file
-@cindex public directory
-@cindex uucppublic
-@cindex /usr/spool/uucppublic
-
-Specify the public directory. The default is from @file{policy.h}.
-When a file is named using a leading @kbd{~/}, it is taken from or to
-the public directory. Each system may use a separate public directory
-by using the @code{pubdir} command in the system configuration file; see
-@ref{Miscellaneous (sys)}.
-
-@item lockdir @var{string}
-@findex lockdir
-@cindex lock directory
-
-Specify the directory to place lock files in. The default is from
-@file{policy.h}; see the information in that file. Normally the lock
-directory should be set correctly in @file{policy.h}, and not changed
-here. However, changing the lock directory is sometimes useful for
-testing purposes. This only affects lock files for devices and systems;
-it does not affect certain internal lock files which are stored in the
-spool directory (@pxref{Spool Lock Files}).
-
-@item unknown @var{string} @dots{}
-@findex unknown
-@cindex unknown systems
-
-The @var{string} and subsequent arguments are treated as though they
-appeared in the system file (@pxref{sys File}). They are used to apply
-to any unknown systems that may call in, probably to set file transfer
-permissions and the like. If the @code{unknown} command is not used,
-unknown systems are not permitted to call in.
-
-@item strip-login @var{boolean}
-@findex strip-login
-@cindex parity in login names
-
-If the argument is true, then, when @code{uucico} is doing its own login
-prompting with the @samp{-e}, @samp{-l}, or @samp{-w} switches, it will
-strip the parity bit when it reads the login name and password.
-Otherwise all eight bits will be used when checking the strings against
-the UUCP password file. The default is true, since some other UUCP
-packages send parity bits with the login name and password, and few
-systems use eight bit characters in the password file.
-
-@item strip-proto @var{boolean}
-@findex strip-proto
-
-If the argument is true, then @code{uucico} will strip the parity bit
-from incoming UUCP protocol commands. Otherwise all eight bits will be
-used. This only applies to commands which are not encapsulated in a
-link layer protocol. The default is true, which should always be
-correct unless your UUCP system names use eight bit characters.
-
-@item max-uuxqts @var{number}
-@findex max-uuxqts
-
-Specify the maximum number of @code{uuxqt} processes which may run at
-the same time. Having several @code{uuxqt} processes running at once
-can significantly slow down a system, but, since @code{uuxqt} is
-automatically started by @code{uucico}, it can happen quite easily. The
-default for @code{max-uuxqts} is 0, which means that there is no limit.
-If HDB configuration files are being read and the code was compiled
-without @code{HAVE_TAYLOR_CONFIG}, then, if the file @file{Maxuuxqts} in
-the configuration directory contains a readable number, it will be used
-as the value for @code{max-uuxqts}.
-
-@item run-uuxqt @var{string} or @var{number}
-@findex run-uuxqt
-
-Specify when @code{uuxqt} should be run by @code{uucico}. This may be a
-positive number, in which case @code{uucico} will start a @code{uuxqt}
-process whenever it receives the given number of execution files from
-the remote system, and, if necessary, at the end of the call. The
-argument may also be one of the strings @samp{once}, @samp{percall}, or
-@samp{never}. The string @samp{once} means that @code{uucico} will
-start @code{uuxqt} once at the end of execution. The string
-@samp{percall} means that @code{uucico} will start @code{uuxqt} once per
-call that it makes (this is only different from @code{once} when
-@code{uucico} is invoked in a way that causes it to make multiple calls,
-such as when the @samp{-r1} option is used without the @samp{-s}
-option). The string @samp{never} means that @code{uucico} will never
-start @code{uuxqt}, in which case @code{uuxqt} should be periodically
-run via some other mechanism. The default depends upon which type of
-configuration files are being used; if @code{HAVE_TAYLOR_CONFIG} is used
-the default is @samp{once}, otherwise if @code{HAVE_HDB_CONFIG} is used
-the default is @samp{percall}, and otherwise, for @code{HAVE_V2_CONFIG},
-the default is @samp{10}.
-
-@item timetable @var{string} @var{string}
-@findex timetable
-
-The @code{timetable} defines a timetable that may be used in
-subsequently appearing time strings; see @ref{Time Strings}. The first
-string names the timetable entry; the second is a time string.
-
-The following @code{timetable} commands are predefined. The NonPeak
-timetable is included for compatibility. It originally described the
-offpeak hours of Tymnet and Telenet, but both have since changed their
-schedules.
-
-@example
-timetable Evening Wk1705-0755,Sa,Su
-timetable Night Wk2305-0755,Sa,Su2305-1655
-timetable NonPeak Wk1805-0655,Sa,Su
-@end example
-
-If this command does not appear, then, obviously, no additional
-timetables will be defined.
-
-@item v2-files @var{boolean}
-@findex v2-files
-
-If the code was compiled to be able to read V2 configuration files, a
-false argument to this command will prevent them from being read.
-This can be useful while testing. The default is true.
-
-@item hdb-files @var{boolean}
-@findex hdb-files
-
-If the code was compiled to be able to read HDB configuration files, a
-false argument to this command will prevent them from being read.
-This can be useful while testing. The default is true.
-
-@end table
-
-@node Configuration File Names, Log File Names, Miscellaneous (config), config File
-@subsection Configuration File Names
-
-@table @code
-
-@item sysfile @var{strings}
-@findex sysfile
-
-Specify the system file(s). The default is the file @file{sys} in the
-directory @var{newconfigdir}. These files hold information about other
-systems with which this system communicates; see @ref{sys File}.
-Multiple system files may be given on the line, and the @code{sysfile}
-command may be repeated; each system file has its own set of defaults.
-
-@item portfile @var{strings}
-@findex portfile
-
-Specify the port file(s). The default is the file @file{port} in the
-directory @var{newconfigdir}. These files describe ports which are used
-to call other systems and accept calls from other systems; see @ref{port
-File}. No port files need be named at all. Multiple port files may be
-given on the line, and the @code{portfile} command may be repeated.
-
-@item dialfile @var{strings}
-@findex dialfile
-
-Specify the dial file(s). The default is the file @file{dial} in the
-directory @var{newconfigdir}. These files describe dialing devices
-(modems); see @ref{dial File}. No dial files need be named at all.
-Multiple dial files may be given on the line, and the @code{dialfile}
-command may be repeated.
-
-@item dialcodefile @var{strings}
-@findex dialcodefile
-@cindex configuration file (dialcode)
-@cindex dialcode file
-@cindex dialcode configuration file
-
-Specify the dialcode file(s). The default is the file @file{dialcode}
-in the directory @var{newconfigdir}. These files specify dialcodes that
-may be used when sending phone numbers to a modem. This permits using
-the same set of phone numbers in different area-codes or with different
-phone systems, by using dialcodes to specify the calling sequence. When
-a phone number goes through dialcode translation, the leading alphabetic
-characters are stripped off. The dialcode files are read line by line,
-just like any other configuration file, and when a line is found whose
-first word is the same as the leading characters from the phone number,
-the second word on the line (which would normally consist of numbers)
-replaces the dialcode in the phone number. No dialcode file need be
-used. Multiple dialcode files may be specified on the line, and the
-@code{dialcodefile} command may be repeated; all the dialcode files will
-be read in turn until a dialcode is located.
-
-@item callfile @var{strings}
-@findex callfile
-@cindex call out file
-@cindex call configuration file
-@cindex call out login name
-@cindex call out password
-@cindex configuration file (call)
-
-Specify the call out login name and password file(s). The default is
-the file @file{call} in the directory @var{newconfigdir}. If the call
-out login name or password for a system are given as @kbd{*}
-(@pxref{Logging In}), these files are read to get the real login name or
-password. Each line in the file(s) has three words: the system name,
-the login name, and the password. The login name and password may
-contain escape sequences like those in a chat script expect string
-(@pxref{Chat Scripts}). This file is only used when placing calls to
-remote systems; the password file described under @code{passwdfile}
-below is used for incoming calls. The intention of the call out file is
-to permit the system file to be publically readable; the call out files
-must obviously be kept secure. These files need not be used. Multiple
-call out files may be specified on the line, and the @code{callfile}
-command may be repeated; all the files will be read in turn until the
-system is found.
-
-@item passwdfile @var{strings}
-@findex passwdfile
-@cindex passwd file
-@cindex passwd configuration file
-@cindex configuration file (passwd)
-@cindex call in login name
-@cindex call in password
-
-Specify the password file(s) to use for login names when @code{uucico}
-is doing its own login prompting, which it does when given the
-@samp{-e}, @samp{-l} or @samp{-w} switches. The default is the file
-@file{passwd} in the directory @var{newconfigdir}. Each line in the
-file(s) has two words: the login name and the password (e.g., @code{Ufoo
-foopas}). They may contain escape sequences like those in a chat script
-expect string (@pxref{Chat Scripts}). The login name is accepted before
-the system name is known, so these are independent of which system is
-calling in; a particular login may be required for a system by using the
-@code{called-login} command in the system file (@pxref{Accepting a
-Call}). These password files are optional, although one must exist if
-@code{uucico} is to present its own login prompts.
-
-As a special exception, a colon may be used to separate the login name
-from the password, and a colon may be used to terminate the password.
-This means that the login name and password may not contain a colon.
-This feature, in conjunction with the @code{HAVE_ENCRYPTED_PASSWORDS}
-macro in @file{policy.h}, permits using a standard Unix
-@file{/etc/passwd} as a UUCP password file, providing the same set of
-login names and passwords for both @code{getty} and @code{uucico}.
-
-Multiple password files may be specified on the line, and the
-@code{passwdfile} command may be repeated; all the files will be read in
-turn until the login name is found.
-
-@end table
-
-@node Log File Names, Debugging Levels, Configuration File Names, config File
-@subsection Log File Names
-
-@table @code
-
-@item logfile @var{string}
-@findex logfile
-@cindex log file
-
-Name the log file. The default is from @file{policy.h}. Logging
-information is written to this file. If @code{HAVE_HDB_LOGGING} is
-defined in @file{policy.h}, then by default a separate log file is used
-for each system; using this command to name a log file will cause all
-the systems to use it.
-
-@item statfile @var{string}
-@findex statfile
-@cindex statistics file
-
-Name the statistics file. The default is from @file{policy.h}.
-Statistical information about file transfers is written to this file.
-
-@item debugfile @var{string}
-@findex debugfile
-@cindex debugging file
-
-Name the file to which all debugging information is written. The
-default is from @file{policy.h}. This command is only effective if the
-code has been compiled to include debugging (this is controlled by the
-@code{DEBUG} macro in @file{policy.h}). If debugging is on, messages
-written to the log file are also written to the debugging file to make
-it easier to keep the order of actions straight. The debugging file is
-different from the log file because information such as passwords can
-appear in it, so it must be not be publically readable.
-
-@end table
-
-@node Debugging Levels, , Log File Names, config File
-@subsection Debugging Levels
-
-@table @code
-
-@item debug @var{string} @dots{}
-@findex debug in config file
-
-Set the debugging level. This command is only effective if the code has
-been compiled to include debugging. The default is to have no
-debugging. The arguments are strings which name the types of debugging
-to be turned on. The following types of debugging are defined:
-
-@table @samp
-@item abnormal
-Output debugging messages for abnormal situations, such as recoverable errors.
-@item chat
-Output debugging messages for chat scripts.
-@item handshake
-Output debugging messages for the initial handshake.
-@item uucp-proto
-Output debugging messages for the UUCP session protocol.
-@item proto
-Output debugging messages for the individual link protocols.
-@item port
-Output debugging messages for actions on the communication port.
-@item config
-Output debugging messages while reading the configuration files.
-@item spooldir
-Output debugging messages for actions in the spool directory.
-@item execute
-Output debugging messages whenever another program is executed.
-@item incoming
-List all incoming data in the debugging file.
-@item outgoing
-List all outgoing data in the debugging file.
-@item all
-All of the above.
-@end table
-
-The debugging level may also be specified as a number. A 1 will set
-@samp{chat} debugging, a 2 will set both @samp{chat} and
-@samp{handshake} debugging, and so on down the possibilities. Currently
-an 11 will turn on all possible debugging, since there are 11 types of
-debugging messages listed above; more debugging types may be added in
-the future. The @code{debug} command may be used several times in the
-configuration file; every debugging type named will be turned on. When
-running any of the programs, the @samp{-x} switch (actually, for
-@code{uulog} it's the @samp{-X} switch) may be used to turn on
-debugging. The argument to the @samp{-x} switch is one of the strings
-listed above, or a number as described above, or a comma separated list
-of strings (e.g., @samp{-x chat,handshake}). The @samp{-x} switch may
-also appear several times on the command line, in which case all named
-debugging types will be turned on. The @samp{-x} debugging is in
-addition to any debugging specified by the @code{debug} command; there
-is no way to cancel debugging information. The debugging level may also
-be set specifically for calls to or from a specific system with the
-@code{debug} command in the system file (@pxref{Miscellaneous (sys)}).
-
-The debugging messages are somewhat idiosyncratic; it may be necessary
-to refer to the source code for additional information in some cases.
-
-@end table
-
-@node sys File, port File, config File, Configuration Files
-@section The System Configuration File
-@cindex sys file
-@cindex system configuration file
-@cindex configuration file (sys)
-
-By default there is a single system configuration, named @file{sys} in
-the directory @var{newconfigdir}. This may be overridden by the
-@code{sysfile} command in the main configuration file; see
-@ref{Configuration File Names}.
-
-These files describe all remote systems known to the UUCP package.
-
-@menu
-* Defaults and Alternates:: Using Defaults and Alternates
-* Naming the System:: Naming the System
-* Calling Out:: Calling Out
-* Accepting a Call:: Accepting a Call
-* Protocol Selection:: Protocol Selection
-* File Transfer Control:: File Transfer Control
-* Miscellaneous (sys):: Miscellaneous sys File Commands
-* Default sys File Values:: Default Values
-@end menu
-
-@node Defaults and Alternates, Naming the System, sys File, sys File
-@subsection Defaults and Alternates
-
-The first set of commands in the file, up to the first @code{system}
-command, specify defaults to be used for all systems in that file. Each
-@file{sys} file uses a different set of defaults.
-
-Subsequently, each set of commands from @code{system} up to the next
-@code{system} command describe a particular system. Default values may
-be overridden for specific systems.
-
-Each system may then have a series of alternate choices to use when
-calling out or calling in. The first set of commands for a particular
-system, up to the first @code{alternate} command, provide the first
-choice. Subsequently, each set of commands from @code{alternate} up to
-the next @code{alternate} command describe an alternate choice for
-calling out or calling in.
-
-When a system is called, the commands before the first @code{alternate}
-are used to select a phone number, port, and so forth; if the call fails
-for some reason, the commands between the first @code{alternate} and the
-second are used, and so forth. Well, not quite. Actually, each
-succeeding alternate will only be used if it is different in some
-relevant way (different phone number, different chat script, etc.). If
-you want to force the same alternate to be used again (to retry a phone
-call more than once, for example), enter the phone number (or any other
-relevant field) again to make it appear different.
-
-The alternates can also be used to give different permissions to an
-incoming call based on the login name. This will only be done if the
-first set of commands, before the first @code{alternate} command, uses
-the @code{called-login} command. The list of alternates will be
-searched, and the first alternate with a matching @code{called-login}
-command will be used. If no alternates match, the call will be
-rejected.
-
-The @code{alternate} command may also be used in the file-wide defaults
-(the set of commands before the first @code{system} command). This
-might be used to specify a list of ports which are available for all
-systems (for an example of this, see @ref{Gateway Example}) or to
-specify permissions based on the login name used by the remote system
-when it calls in. The first alternate for each system will default to
-the first alternate for the file-wide defaults (as modified by the
-commands used before the first @code{alternate} command for this
-system), the second alternate for each system to the second alternate
-for the file-wide defaults (as modified the same way), and so forth. If
-a system specifies more alternates than the file-wide defaults, the
-trailing ones will default to the last file-wide default alternate. If
-a system specifies fewer alternates than the file-wide defaults, the
-trailing file-wide default alternates will be used unmodified. The
-@code{default-alternates} command may be used to modify this behaviour.
-
-This can all get rather confusing, although it's easier to use than to
-describe concisely; the @code{uuchk} program may be used to ensure that
-you are getting what you want.
-
-@need 2000
-@node Naming the System, Calling Out, Defaults and Alternates, sys File
-@subsection Naming the System
-
-@table @code
-
-@item system @var{string}
-@findex system
-
-Specify the remote system name. Subsequent commands up to the next
-@code{system} command refer to this system.
-
-@item alternate [@var{string}]
-@findex alternate
-
-Start an alternate set of commands (@pxref{Defaults and Alternates}).
-An optional argument may be used to name the alternate. This name will
-be recorded in the log file if the alternate is used to call the system.
-There is no way to name the first alternate (the commands before the
-first @code{alternate} command).
-
-@item default-alternates @var{boolean}
-@findex default-alternates
-
-If the argument is false, any remaining default alternates (from the
-defaults specified at the top of the current system file) will not be
-used. The default is true.
-
-@item alias @var{string}
-@findex alias
-
-Specify an alias for the current system. The alias may be used by local
-@code{uucp} and @code{uux} commands, as well as by the remote system
-(which can be convenient if a remote system changes its name). The
-default is to have no aliases.
-
-@item myname @var{string}
-@findex myname
-
-Specifies a different system name to use when calling the remote system.
-Also, if @code{called-login} is used and is not @samp{ANY}, then, when a
-system logs in with that login name, @var{string} is used as the local
-system name. Because the local system name must be determined before
-the remote system has identified itself, using @code{myname} and
-@code{called-login} together for any system will set the local name for
-that login; this means that each locally used system name must have a
-unique login name associated with it. This allows a system to have
-different names for an external and an internal network. The default is
-to not use a special local name.
-
-@end table
-
-@node Calling Out, Accepting a Call, Naming the System, sys File
-@subsection Calling Out
-
-This section describes commands used when placing a call to another
-system.
-
-@menu
-* When to Call:: When to Call
-* Placing the Call:: Placing the Call
-* Logging In:: Logging In
-@end menu
-
-@need 2000
-@node When to Call, Placing the Call, Calling Out, Calling Out
-@subsubsection When to Call
-
-@table @code
-
-@item time @var{string} [@var{number}]
-@findex time
-
-Specify when the system may be called. The first argument is a time
-string; see @ref{Time Strings}. The optional second argument specifies
-a retry time in minutes. If a call made during a time that matches the
-time string fails, no more calls are permitted until the retry time has
-passed. By default an exponentially increasing retry time is used:
-after each failure the next retry period is longer. A retry time
-specified in the @code{time} command is always a fixed amount of time.
-
-The @code{time} command may appear multiple times in a single alternate,
-in which case if any time string matches the system may be called. When
-the @code{time} command is used for a particular system, any @code{time}
-or @code{timegrade} commands that appeared in the system defaults are
-ignored.
-
-The default time string is @samp{Never}.
-
-@item timegrade @var{character} @var{string} [@var{number}]
-@findex timegrade
-@cindex grades
-
-The @var{character} specifies a grade. It must be a single letter or
-digit. The @var{string} is a time string (@pxref{Time Strings}). All
-jobs of grade @var{character} or higher (where @kbd{0} > @kbd{9} >
-@kbd{A} > @kbd{Z} > @kbd{a} > @kbd{z}) may be run at the specified time.
-An ordinary @code{time} command is equivalent to using @code{timegrade}
-with a grade of @kbd{z}, permitting all jobs. If there are no jobs of a
-sufficiently high grade according to the time string, the system will
-not be called. Giving the @samp{-s} switch to @code{uucico} to force it
-to call a system causes it to assume there is a job of grade @kbd{0}
-waiting to be run.
-
-The optional third argument specifies a retry time in minutes. See the
-@code{time} command, above, for more details.
-
-Note that the @code{timegrade} command serves two purposes: 1) if there
-is no job of sufficiently high grade the system will not be called, and
-2) if the system is called anyway (because the @samp{-s} switch was
-given to @code{uucico}) only jobs of sufficiently high grade will be
-transferred. However, if the other system calls in, the
-@code{timegrade} commands are ignored, and jobs of any grade may be
-transferred (but see @code{call-timegrade} and @code{called-timegrade},
-below). Also, the @code{timegrade} command will not prevent the other
-system from transferring any job it chooses, regardless of who placed
-the call.
-
-The @code{timegrade} command may appear multiple times without using
-@code{alternate}. When the @code{timegrade} command is used for a
-particular system, any @code{time} or @code{timegrade} commands that
-appeared in the system defaults are ignored.
-
-If this command does not appear, there are no restrictions on what grade
-of work may be done at what time.
-
-@item max-retries @var{number}
-@findex max-retries
-
-Gives the maximum number of times this system may be retried. If this
-many calls to the system fail, it will be called at most once a day
-whatever the retry time is. The default is 26.
-
-@item success-wait @var{number}
-
-A retry time, in seconds, which applies after a successful call. This
-can be used to put a limit on how frequently the system is called. For
-example, an argument of 1800 means that the system will not be called
-more than once every half hour. The default is 0, which means that
-there is no limit.
-
-@item call-timegrade @var{character} @var{string}
-@findex call-timegrade
-
-The @var{character} is a single character @kbd{A} to @kbd{Z}, @kbd{a} to
-@kbd{z}, or @kbd{0} to @kbd{9} and specifies a grade. The @var{string}
-is a time string (@pxref{Time Strings}). If a call is placed to the
-other system during a time which matches the time string, the remote
-system will be requested to only run jobs of grade @var{character} or
-higher. Unfortunately, there is no way to guarantee that the other
-system will obey the request (this UUCP package will, but there are
-others which will not); moreover, job grades are historically somewhat
-arbitrary, so specifying a grade will only be meaningful if the other
-system cooperates in assigning grades. This grade restriction only
-applies when the other system is called, not when the other system calls
-in.
-
-The @code{call-timegrade} command may appear multiple times without
-using @code{alternate}. If this command does not appear, or if none of
-the time strings match, the remote system will be allowed to send
-whatever grades of work it chooses.
-
-@item called-timegrade @var{character} @var{string}
-@findex called-timegrade
-
-The @var{character} is a single character @kbd{A} to @kbd{Z}, @kbd{a} to
-@kbd{z}, or @kbd{0} to @kbd{9} and specifies a grade. The @var{string}
-is a time string (@pxref{Time Strings}). If a call is received from the
-other system during a time which matches the time string, only jobs of
-grade @var{character} or higher will be sent to the remote system. This
-allows the job grade to be set for incoming calls, overriding any
-request made by the remote uucico. As noted above, job grades are
-historically somewhat arbitrary, so specifying a grade will only be
-meaningful if the other system cooperates in assigning grades. This
-grade restriction only applies to jobs on the local system; it does not
-affect the jobs transferred by the remote system. This grade
-restriction only applies when the other system calls in, not when the
-other system is called.
-
-The @code{called-timegrade} command may appear multiple times. If this
-command does not appear, or if none of the time strings match, any grade
-may be sent to the remote system upon receiving a call.
-
-@end table
-
-@need 2000
-@node Placing the Call, Logging In, When to Call, Calling Out
-@subsubsection Placing the Call
-
-@table @code
-
-@itemx speed @var{number}
-@findex speed in sys file
-@item baud @var{number}
-@findex baud in sys file
-
-Specify the speed (the term @dfn{baud} is technically incorrect, but
-widely understood) at which to call the system. This will try all
-available ports with that speed until an unlocked port is found. The
-ports are defined in the port file. If both @code{speed} and
-@code{port} commands appear, both are used when selecting a port. To
-allow calls at more than one speed, the @code{alternate} command must be
-used (@pxref{Defaults and Alternates}). If this command does not
-appear, there is no default; the speed may be specified in the port
-file, but if it is not then the natural speed of the port will be used
-(whatever that means on the system). Specifying an explicit speed of 0
-will request the natural speed of the port (whatever the system sets it
-to), overriding any default speed from the defaults at the top of the
-file.
-
-@item port @var{string}
-@findex port in sys file
-
-Name a particular port or type of port to use when calling the system.
-The information for this port is obtained from the port file. If this
-command does not appear, there is no default; a port must somehow be
-specified in order to call out (it may be specified implicitly using the
-@code{speed} command or explicitly using the next version of
-@code{port}). There may be many ports with the same name; each will be
-tried in turn until an unlocked one is found which matches the desired
-speed.
-
-@item port @var{string} @dots{}
-
-If more than one string follows the @code{port} command, the strings are
-treated as a command that might appear in the port file (@pxref{port
-File}). If a port is named (by using a single string following
-@code{port}) these commands are ignored; their purpose is to permit
-defining the port completely in the system file rather than always
-requiring entries in two different files. In order to call out, a port
-must be specified using some version of the @code{port} command, or by
-using the @code{speed} command to select ports from the port file.
-
-@item phone @var{string}
-@findex phone
-@itemx address @var{string}
-@findex address
-
-Give a phone number to call (when using a modem port) or a remote host
-to contact (when using a TCP or TLI port). The commands @code{phone}
-and @code{address} are equivalent; the duplication is intended to
-provide a mnemonic choice depending on the type of port in use.
-
-When used with a modem port, an @kbd{=} character in the phone number
-means to wait for a secondary dial tone (although only some modems
-support this); a @kbd{-} character means to pause while dialing for 1
-second (again, only some modems support this). If the system has more
-than one phone number, each one must appear in a different alternate.
-The @code{phone} command must appear in order to call out on a modem;
-there is no default.
-
-When used with a TCP port, the string names the host to contact. It may
-be a domain name or a numeric Internet address. If no address is
-specified, the system name is used.
-
-When used with a TLI port, the string is treated as though it were an
-expect string in a chat script, allowing the use of escape characters
-(@pxref{Chat Scripts}). The @code{dialer-sequence} command in the port
-file may override this address (@pxref{port File}).
-
-When used with a port that not a modem or TCP or TLI, this command is
-ignored.
-
-@end table
-
-@node Logging In, , Placing the Call, Calling Out
-@subsubsection Logging In
-@table @code
-
-@item chat @var{strings}
-@findex chat in sys file
-@item chat-timeout @var{number}
-@findex chat-timeout in sys file
-@item chat-fail @var{string}
-@findex chat-fail in sys file
-@item chat-seven-bit @var{boolean}
-@findex chat-seven-bit in sys file
-@item chat-program @var{strings}
-@findex chat-program in sys file
-
-These commands describe a chat script to use when logging on to a remote
-system. This login chat script is run after any chat script defined in
-the @file{dial} file (@pxref{dial File}). Chat scripts are explained in
-@ref{Chat Scripts}.
-
-Two additional escape sequences may be used in send strings.
-
-@table @samp
-@item \L
-Send the login name, as set by the @code{call-login} command.
-@item \P
-Send the password, as set by the @code{call-password} command.
-@end table
-
-Three additional escape sequences may be used with the
-@code{chat-program} command. These are @samp{\L} and @samp{\P}, which
-become the login name and password, respectively, and @samp{\Z}, which
-becomes the name of the system of being called.
-
-The default chat script is:
-
-@example
-chat "" \r\c ogin:-BREAK-ogin:-BREAK-ogin: \L word: \P
-@end example
-
-This will send a carriage return (the @kbd{\c} suppresses the additional
-trailing carriage return that would otherwise be sent) and waits for the
-string @samp{ogin:} (which would be the last part of the @samp{login:}
-prompt supplied by a Unix system). If it doesn't see @samp{ogin:}, it
-sends a break and waits for @samp{ogin:} again. If it still doesn't see
-@samp{ogin:}, it sends another break and waits for @samp{ogin:} again.
-If it still doesn't see @samp{ogin:}, the chat script aborts and hangs
-up the phone. If it does see @samp{ogin:} at some point, it sends the
-login name (as specified by the @code{call-login} command) followed by a
-carriage return (since all send strings are followed by a carriage
-return unless @kbd{\c} is used) and waits for the string @samp{word:}
-(which would be the last part of the @samp{Password:} prompt supplied by
-a Unix system). If it sees @samp{word:}, it sends the password and a
-carriage return, completing the chat script. The program will then
-enter the handshake phase of the UUCP protocol.
-
-This chat script will work for most systems, so you will only be
-required to use the @code{call-login} and @code{call-password} commands.
-In fact, in the file-wide defaults you could set defaults of
-@samp{call-login *} and @samp{call-password *}; you would then just have
-to make an entry for each system in the call-out login file.
-
-Some systems seem to flush input after the @samp{login:} prompt, so they
-may need a version of this chat script with a @kbd{\d} before the
-@kbd{\L}. When using UUCP over TCP, some servers will not be handle the
-initial carriage return sent by this chat script; in this case you may
-have to specify the simple chat script @samp{ogin: \L word: \P}.
-
-@item call-login @var{string}
-@findex call-login
-
-Specify the login name to send with @kbd{\L} in the chat script. If the
-string is @samp{*} (e.g., @samp{call-login *}) the login name will be
-fetched from the call out login name and password file
-(@pxref{Configuration File Names}). The string may contain escape
-sequences as though it were an expect string in a chat script
-(@pxref{Chat Scripts}). There is no default.
-
-@item call-password @var{string}
-@findex call-password
-
-Specify the password to send with @kbd{\P} in the chat script. If the
-string is @samp{*} (e.g., @samp{call-password *}) the password will be
-fetched from the call-out login name and password file
-(@pxref{Configuration File Names}). The string may contain escape
-sequences as though it were an expect string in a chat script
-(@pxref{Chat Scripts}). There is no default.
-
-@end table
-
-@node Accepting a Call, Protocol Selection, Calling Out, sys File
-@subsection Accepting a Call
-
-@table @code
-
-@item called-login @var{strings}
-@findex called-login
-
-The first @var{string} specifies the login name that the system must use
-when calling in. If it is @samp{ANY} (e.g., @samp{called-login ANY}) any
-login name may be used; this is useful to override a file-wide default
-and to indicate that future alternates may have different login names.
-Case is significant. The default value is @samp{ANY}.
-
-Different alternates (@pxref{Defaults and Alternates}) may use different
-@code{called-login} commands, in which case the login name will be used
-to select which alternate is in effect; this will only work if the first
-alternate (before the first @code{alternate} command) uses the
-@code{called-login} command.
-
-Additional strings may be specified after the login name; they are a
-list of which systems are permitted to use this login name. If this
-feature is used, then normally the login name will only be given in a
-single @code{called-login} command. Only systems which appear on the
-list, or which use an explicit @code{called-login} command, will be
-permitted to use that login name. If the same login name is used more
-than once with a list of systems, all the lists are concatenated
-together. This feature permits you to restrict a login name to a
-particular set of systems without requiring you to use the
-@code{called-login} command for every single system; you can achieve a
-similar effect by using a different system file for each permitted login
-name with an appropriate @code{called-login} command in the file-wide
-defaults.
-
-@item callback @var{boolean}
-@findex callback
-
-If @var{boolean} is true, then when the remote system calls
-@code{uucico} will hang up the connection and prepare to call it back.
-The default is false.
-
-@item called-chat @var{strings}
-@findex called-chat
-@item called-chat-timeout @var{number}
-@findex called-chat-timeout
-@item called-chat-fail @var{string}
-@findex called-chat-fail
-@item called-chat-seven-bit @var{boolean}
-@findex called-chat-seven-bit
-@item called-chat-program @var{strings}
-@findex called-chat-program
-
-These commands may be used to define a chat script (@pxref{Chat
-Scripts}) that is run whenever the local system is called by the system
-being defined. The chat script defined by the @code{chat} command
-(@pxref{Logging In}), on the other hand, is used when the remote system
-is called. This called chat script might be used to set special modem
-parameters that are appropriate to a particular system. It is run after
-protocol negotiation is complete, but before the protocol has been
-started. For additional escape sequence which may be used besides those
-defined for all chat scripts, see @ref{Logging In}. There is no default
-called chat script. If the called chat script fails, the incoming call
-will be aborted.
-
-@end table
-
-@node Protocol Selection, File Transfer Control, Accepting a Call, sys File
-@subsection Protocol Selection
-
-@table @code
-
-@item protocol @var{string}
-@findex protocol in sys file
-
-Specifies which protocols to use for the other system, and in which
-order to use them. This would not normally be used. For example,
-@samp{protocol tfg}.
-
-The default depends on the characteristics of the port and the dialer,
-as specified by the @code{seven-bit} and @code{reliable} commands. If
-neither the port nor the dialer use either of these commands, the
-default is to assume an eight-bit reliable connection. The commands
-@samp{seven-bit true} or @samp{reliable false} might be used in either
-the port or the dialer to change this. Each protocol has particular
-requirements that must be met before it will be considered during
-negotiation with the remote side.
-
-The @samp{t} and @samp{e} protocols are intended for use over TCP or
-some other communication path with end to end reliability, as they do no
-checking of the data at all. They will only be considered on a TCP port
-which is both reliable and eight bit. For technical details, see @ref{t
-Protocol}, and @ref{e Protocol}.
-
-The @samp{i} protocol is a bidirectional protocol. It requires an
-eight-bit connection. It will run over a half-duplex link, such as
-Telebit modems in PEP mode, but for efficient use of such a connection
-you must use the @code{half-duplex} command (@pxref{port File}).
-@xref{i Protocol}.
-
-The @samp{g} protocol is robust, but requires an eight-bit connection.
-@xref{g Protocol}.
-
-The @samp{G} protocol is the System V Release 4 version of the @samp{g}
-protocol. @xref{Big G Protocol}.
-
-The @samp{a} protocol is a Zmodem like protocol, contributed by Doug
-Evans. It requires an eight-bit connection, but unlike the @samp{g} or
-@samp{i} protocol it will work if certain control characters may not be
-transmitted.
-
-The @samp{j} protocol is a variant of the @samp{i} protocol which can
-avoid certain control characters. The set of characters it avoids can
-be set by a parameter. While it technically does not require an eight
-bit connection (it could be configured to avoid all characters with the
-high bit set) it would be very inefficient to use it over one. It is
-useful over a eight-bit connection that will not transmit certain
-control characters. @xref{j Protocol}.
-
-The @samp{f} protocol is intended for use with X.25 connections; it
-checksums each file as a whole, so any error causes the entire file to
-be retransmitted. It requires a reliable connection, but only uses
-seven-bit transmissions. It is a streaming protocol, so, while it can
-be used on a serial port, the port must be completely reliable and flow
-controlled; many aren't. @xref{f Protocol}.
-
-The @samp{v} protocol is the @samp{g} protocol as used by the DOS
-program UUPC/Extended. It is provided only so that UUPC/Extended users
-can use it; there is no particular reason to select it. @xref{v
-Protocol}.
-
-The @samp{y} protocol is an efficient streaming protocol. It does error
-checking, but when it detects an error it immediately aborts the
-connection. This requires a reliable, flow controlled, eight-bit
-connection. In practice, it is only useful on a connection that is
-nearly always error-free. Unlike the @samp{t} and @samp{e} protocols,
-the connection need not be entirely error-free, so the @samp{y} protocol
-can be used on a serial port. @xref{y Protocol}.
-
-The protocols will be considered in the order shown above. This means
-that if neither the @code{seven-bit} nor the @code{reliable} command are
-used, the @samp{t} protocol will be used over a TCP connection and the
-@samp{i} protocol will be used over any other type of connection
-(subject, of course, to what is supported by the remote system; it may
-be assumed that all systems support the @samp{g} protocol).
-
-Note that currently specifying both @samp{seven-bit true} and
-@samp{reliable false} will not match any protocol. If this occurs
-through a combination of port and dialer specifications, you will have
-to use the @code{protocol} command for the system or no protocol will be
-selected at all (the only reasonable choice would be @samp{protocol f}).
-
-A protocol list may also be specified for a port (@pxref{port File}),
-but, if there is a list for the system, the list for the port is
-ignored.
-
-@item protocol-parameter @var{character} @var{string} @dots{}
-@findex protocol-parameter in sys file
-
-@var{character} is a single character specifying a protocol. The
-remaining strings are a command specific to that protocol which will be
-executed if that protocol is used. A typical command is something like
-@samp{window 7}. The particular commands are protocol specific.
-
-The @samp{i} protocol supports the following commands, all of which take
-numeric arguments:
-
-@table @code
-@item window
-The window size to request the remote system to use. This must be
-between 1 and 16 inclusive. The default is 16.
-@item packet-size
-The packet size to request the remote system to use. This must be
-between 1 and 4095 inclusive. The default is 1024.
-@item remote-packet-size
-If this is between 1 and 4095 inclusive, the packet size requested by
-the remote system is ignored, and this is used instead. The default is
-0, which means that the remote system's request is honored.
-@item sync-timeout
-The length of time, in seconds, to wait for a SYNC packet from the remote
-system. SYNC packets are exchanged when the protocol is started. The
-default is 10.
-@item sync-retries
-The number of times to retry sending a SYNC packet before giving up.
-The default is 6.
-@item timeout
-The length of time, in seconds, to wait for an incoming packet before
-sending a negative acknowledgement. The default is 10.
-@item retries
-The number of times to retry sending a packet or a negative
-acknowledgement before giving up and closing the connection. The
-default is 6.
-@item errors
-The maximum number of errors to permit before closing the connection.
-The default is 100.
-@item error-decay
-The rate at which to ignore errors. Each time this many packets are
-received, the error count is decreased by one, so that a long connection
-with an occasional error will not exceed the limit set by @code{errors}.
-The default is 10.
-@item ack-frequency
-The number of packets to receive before sending an acknowledgement. The
-default is half the requested window size, which should provide good
-performance in most cases.
-@end table
-
-The @samp{g}, @samp{G} and @samp{v} protocols support the following
-commands, all of which take numeric arguments, except
-@code{short-packets} which takes a boolean argument:
-
-@table @code
-@item window
-The window size to request the remote system to use. This must be
-between 1 and 7 inclusive. The default is 7.
-@item packet-size
-The packet size to request the remote system to use. This must be a
-power of 2 between 32 and 4096 inclusive. The default is 64 for the
-@samp{g} and @samp{G} protocols and 1024 for the @samp{v} protocol.
-Many older UUCP packages do not support packet sizes larger than 64, and
-many others do not support packet sizes larger than 128. Some UUCP
-packages will even dump core if a larger packet size is requested. The
-packet size is not a negotiation, and it may be different in each
-direction. If you request a packet size larger than the remote system
-supports, you will not be able to send any files.
-@item startup-retries
-The number of times to retry the initialization sequence. The default
-is 8.
-@item init-retries
-The number of times to retry one phase of the initialization sequence
-(there are three phases). The default is 4.
-@item init-timeout
-The timeout in seconds for one phase of the initialization sequence. The
-default is 10.
-@item retries
-The number of times to retry sending either a data packet or a request
-for the next packet. The default is 6.
-@item timeout
-The timeout in seconds when waiting for either a data packet or an
-acknowledgement. The default is 10.
-@item garbage
-The number of unrecognized bytes to permit before dropping the
-connection. This must be larger than the packet size. The default is
-10000.
-@item errors
-The number of errors (malformed packets, out of order packets, bad
-checksums, or packets rejected by the remote system) to permit before
-dropping the connection. The default is 100.
-@item error-decay
-The rate at which to ignore errors. Each time this many packets are
-received, the error count is decreased by one, so that a long connection
-with an occasional error will not exceed the limit set by @code{errors}.
-The default is 10.
-@item remote-window
-If this is between 1 and 7 inclusive, the window size requested by the
-remote system is ignored and this is used instead. This can be useful
-when dealing with some poor UUCP packages. The default is 0, which
-means that the remote system's request is honored.
-@item remote-packet-size
-If this is between 32 and 4096 inclusive the packet size requested by
-the remote system is ignored and this is used instead. There is
-probably no good reason to use this. The default is 0, which means that
-the remote system's request is honored.
-@item short-packets
-If this is true, then the code will optimize by sending shorter packets
-when there is less data to send. This confuses some UUCP packages, such
-as System V Release 4 (when using the @samp{G} protocol) and Waffle;
-when connecting to such a package, this parameter must be set to false.
-The default is true for the @samp{g} and @samp{v} protocols and false
-for the @samp{G} protocol.
-@end table
-
-The @samp{a} protocol is a Zmodem like protocol contributed by Doug
-Evans. It supports the following commands, all of which take numeric
-arguments except for @code{escape-control}, which takes a boolean
-argument:
-
-@table @code
-@item timeout
-Number of seconds to wait for a packet to arrive. The default is 10.
-@item retries
-The number of times to retry sending a packet. The default is 10.
-@item startup-retries
-The number of times to retry sending the initialization packet. The
-default is 4.
-@item garbage
-The number of garbage characters to accept before closing the
-connection. The default is 2400.
-@item send-window
-The number of characters that may be sent before waiting for an
-acknowledgement. The default is 1024.
-@item escape-control
-Whether to escape control characters. If this is true, the protocol may
-be used over a connection which does not transmit certain control
-characters, such as @code{XON} or @code{XOFF}. The connection must
-still transmit eight bit characters other than control characters. The
-default is false.
-@end table
-
-The @samp{j} protocol can be used over an eight bit connection that will
-not transmit certain control characters. It accepts the same protocol
-parameters that the @samp{i} protocol accepts, as well as one more:
-
-@table @code
-@item avoid
-A list of characters to avoid. This is a string which is interpreted as
-an escape sequence (@pxref{Chat Scripts}). The protocol does not have a
-way to avoid printable ASCII characters (byte values from 32 to 126,
-inclusive); only ASCII control characters and eight-bit characters may
-be avoided. The default value is @samp{\021\023}; these are the
-characters @code{XON} and @code{XOFF}, which many connections use for
-flow control. If the package is configured to use @code{HAVE_BSD_TTY},
-then on some versions of Unix you may have to avoid @samp{\377} as well,
-due to the way some implementations of the BSD terminal driver handle
-signals.
-@end table
-
-The @samp{f} protocol is intended for use with error-correcting modems
-only; it checksums each file as a whole, so any error causes the entire
-file to be retransmitted. It supports the following commands, both of
-which take numeric arguments:
-
-@table @code
-@item timeout
-The timeout in seconds before giving up. The default is 120.
-@item retries
-How many times to retry sending a file. The default is 2.
-@end table
-
-The @samp{t} and @samp{e} protocols are intended for use over TCP or
-some other communication path with end to end reliability, as they do no
-checking of the data at all. They both support a single command, which
-takes a numeric argument:
-
-@table @code
-@item timeout
-The timeout in seconds before giving up. The default is 120.
-@end table
-
-The @samp{y} protocol is a streaming protocol contributed by Jorge Cwik.
-It supports the following commands, both of which take numeric
-arguments:
-
-@table @code
-@item timeout
-The timeout in seconds when waiting for a packet. The default is 60.
-@item packet-size
-The packet size to use. The default is 1024.
-@end table
-
-The protocol parameters are reset to their default values after each
-call.
-
-@end table
-
-@node File Transfer Control, Miscellaneous (sys), Protocol Selection, sys File
-@subsection File Transfer Control
-
-@table @code
-
-@item send-request @var{boolean}
-@findex send-request
-
-The @var{boolean} determines whether the remote system is permitted to
-request files from the local system. The default is yes.
-
-@item receive-request @var{boolean}
-@findex receive-request
-
-The @var{boolean} determines whether the remote system is permitted to
-send files to the local system. The default is yes.
-
-@item request @var{boolean}
-@findex request
-
-A shorthand command, equivalent to specifying both @samp{send-request
-@var{boolean}} and @samp{receive-request @var{boolean}}.
-
-@item call-transfer @var{boolean}
-@findex call-transfer
-
-The @var{boolean} is checked when the local system places the call. It
-determines whether the local system may do file transfers queued up for
-the remote system. The default is yes.
-
-@item called-transfer @var{boolean}
-@findex called-transfer
-
-The @var{boolean} is checked when the remote system calls in. It
-determines whether the local system may do file transfers queued up for
-the remote system. The default is yes.
-
-@item transfer @var{boolean}
-@findex transfer
-
-A shorthand command, equivalent to specifying both @samp{call-transfer
-@var{boolean}} and @samp{called-transfer @var{boolean}}.
-
-@item call-local-size @var{number} @var{string}
-@findex call-local-size
-
-The @var{string} is a time string (@pxref{Time Strings}). The
-@var{number} is the size in bytes of the largest file that should be
-transferred at a time matching the time string, if the local system
-placed the call and the request was made by the local system. This
-command may appear multiple times in a single alternate. If this
-command does not appear, or if none of the time strings match, there are
-no size restrictions.
-
-With all the size control commands, the size of a file from the remote
-system (as opposed to a file from the local system) will only be checked
-if the other system is running this package: other UUCP packages will
-not understand a maximum size request, nor will they provide the size of
-remote files.
-
-@item call-remote-size @var{number} @var{string}
-@findex call-remote-size
-
-Specify the size in bytes of the largest file that should be transferred
-at a given time by remote request, when the local system placed the
-call. This command may appear multiple times in a single alternate. If
-this command does not appear, there are no size restrictions.
-
-@item called-local-size @var{number} @var{string}
-@findex called-local-size
-
-Specify the size in bytes of the largest file that should be transferred
-at a given time by local request, when the remote system placed the
-call. This command may appear multiple times in a single alternate. If
-this command does not appear, there are no size restrictions.
-
-@item called-remote-size @var{number} @var{string}
-@findex called-remote-size
-
-Specify the size in bytes of the largest file that should be transferred
-at a given time by remote request, when the remote system placed the
-call. This command may appear multiple times in a single alternate. If
-this command does not appear, there are no size restrictions.
-
-@item local-send @var{strings}
-@findex local-send
-
-Specifies that files in the directories named by the @var{strings} may
-be sent to the remote system when requested locally (using @code{uucp}
-or @code{uux}). The directories in the list should be separated by
-whitespace. A @samp{~} may be used for the public directory. On a Unix
-system, this is typically @file{/usr/spool/uucppublic}; the public
-directory may be set with the @code{pubdir} command. Here is an example
-of @code{local-send}:
-
-@example
-local-send ~ /usr/spool/ftp/pub
-@end example
-
-Listing a directory allows all files within the directory and all
-subdirectories to be sent. Directories may be excluded by preceding
-them with an exclamation point. For example:
-
-@example
-local-send /usr/ftp !/usr/ftp/private ~
-@end example
-
-@noindent
-means that all files in @file{/usr/ftp} or the public directory may be
-sent, except those files in @file{/usr/ftp/private}. The list of
-directories is read from left to right, and the last directory to apply
-takes effect; this means that directories should be listed from top
-down. The default is the root directory (i.e., any file at all may be
-sent by local request).
-
-@item remote-send @var{strings}
-@findex remote-send
-
-Specifies that files in the named directories may be sent to the remote
-system when requested by the remote system. The default is @samp{~}.
-
-@item local-receive @var{strings}
-@findex local-receive
-
-Specifies that files may be received into the named directories when
-requested by a local user. The default is @samp{~}.
-
-@item remote-receive @var{strings}
-@findex remote-receive
-
-Specifies that files may be received into the named directories when
-requested by the remote system. The default is @samp{~}. On Unix, the
-remote system may only request that files be received into directories
-that are writeable by the world, regardless of how this is set.
-
-@item forward-to @var{strings}
-@findex forward-to
-
-Specifies a list of systems to which files may be forwarded. The remote
-system may forward files through the local system on to any of the
-systems in this list. The string @samp{ANY} may be used to permit
-forwarding to any system. The default is to not permit forwarding to
-other systems. Note that if the remote system is permitted to execute
-the @code{uucp} command, it effectively has the ability to forward to
-any system.
-
-@item forward-from @var{strings}
-@findex forward-from
-
-Specifies a list of systems from which files may be forwarded. The
-remote system may request files via the local system from any of the
-systems in this list. The string @samp{ANY} may be used to permit
-forwarding to any system. The default is to not permit forwarding from
-other systems. Note that if a remote system is permitted to execute the
-@code{uucp} command, it effectively has the ability to request files
-from any system.
-
-@item forward @var{strings}
-@findex forward
-
-Equivalent to specifying both @samp{forward-to @var{strings}} and
-@samp{forward-from @var{strings}}. This would normally be used rather
-than either of the more specific commands.
-
-@end table
-
-@node Miscellaneous (sys), Default sys File Values, File Transfer Control, sys File
-@subsection Miscellaneous sys File Commands
-
-@table @code
-
-@item sequence @var{boolean}
-@findex sequence
-
-If @var{boolean} is true, then conversation sequencing is automatically
-used for the remote system, so that if somebody manages to spoof as the
-remote system, it will be detected the next time the remote system
-actually calls. This is false by default.
-
-@item command-path @var{strings}
-@findex command-path
-
-Specifies the path (a list of whitespace separated directories) to be
-searched to locate commands to execute. This is only used for commands
-requested by @code{uux}, not for chat programs. The default is from
-@file{policy.h}.
-
-@item commands @var{strings}
-@findex commands
-
-The list of commands which the remote system is permitted to execute
-locally. For example: @samp{commands rnews rmail}. If the value is
-@samp{ALL} (case significant), all commands may be executed. The
-default is @samp{rnews rmail}.
-
-@item free-space @var{number}
-@findex free-space
-
-Specify the minimum amount of file system space (in bytes) to leave free
-after receiving a file. If the incoming file will not fit, it will be
-rejected. This initial rejection will only work when talking to another
-instance of this package, since older UUCP packages do not provide the
-file size of incoming files. Also, while a file is being received,
-@code{uucico} will periodically check the amount of free space. If it
-drops below the amount given by the @code{free-space} command, the file
-transfer will be aborted. The default amount of space to leave free is
-from @file{policy.h}. This file space checking may not work on all
-systems.
-
-@item pubdir @var{string}
-@findex pubdir in sys file
-
-Specifies the public directory that is used when @samp{~} is specifed in
-a file transfer or a list of directories. This essentially overrides
-the public directory specified in the main configuration file for this
-system only. The default is the public directory specified in the main
-configuration file (which defaults to a value from @file{policy.h}).
-
-@item debug @var{string} @dots{}
-@findex debug in sys file
-
-Set additional debugging for calls to or from the system. This may be
-used to debug a connection with a specific system. It is particularly
-useful when debugging incoming calls, since debugging information will
-be generated whenever the call comes in. See the @code{debug} command
-in the main configuration file (@pxref{Debugging Levels}) for more
-details. The debugging information specified here is in addition to
-that specified in the main configuration file or on the command line.
-
-@item max-remote-debug @var{string} @dots{}
-@findex max-remote-debug
-
-When the system calls in, it may request that the debugging level be set
-to a certain value. The @code{max-remote-debug} command may be used to
-put a limit on the debugging level which the system may request, to
-avoid filling up the disk with debugging information. Only the
-debugging types named in the @code{max-remote-debug} command may be
-turned on by the remote system. To prohibit any debugging, use
-@samp{max-remote-debug none}.
-
-@end table
-
-@node Default sys File Values, , Miscellaneous (sys), sys File
-@subsection Default sys File Values
-
-The following are used as default values for all systems; they can be
-considered as appearing before the start of the file.
-
-@example
-time Never
-chat "" \r\c ogin:-BREAK-ogin:-BREAK-ogin: \L word: \P
-chat-timeout 10
-callback n
-sequence n
-request y
-transfer y
-local-send /
-remote-send ~
-local-receive ~
-remove-receive ~
-command-path [ from @file{policy.h} ]
-commands rnews rmail
-max-remote-debug abnormal,chat,handshake
-@end example
-
-@node port File, dial File, sys File, Configuration Files
-@section The Port Configuration File
-@cindex port file
-@cindex port configuration file
-@cindex configuration file (port)
-
-The port files may be used to name and describe ports. By default there
-is a single port file, named @file{port} in the directory
-@var{newconfigdir}. This may be overridden by the @code{portfile}
-command in the main configuration file; see @ref{Configuration File
-Names}.
-
-Any commands in a port file before the first @code{port} command specify
-defaults for all ports in the file; however, since the @code{type}
-command must appear before all other commands for a port, the defaults
-are only useful if all ports in the file are of the same type (this
-restriction may be lifted in a later version). All commands after a
-@code{port} command up to the next @code{port} command then describe
-that port. There are different types of ports; each type supports its
-own set of commands. Each command indicates which types of ports
-support it. There may be many ports with the same name; if a system
-requests a port by name then each port with that name will be tried
-until an unlocked one is found.
-
-@table @code
-
-@item port @var{string}
-@findex port in port file
-
-Introduces and names a port.
-
-@item type @var{string}
-@findex type
-
-Define the type of port. The default is @samp{modem}. If this command
-appears, it must immediately follow the @code{port} command. The type defines
-what commands are subsequently allowed. Currently the types are:
-
-@table @samp
-@item modem
-For a modem hookup.
-@item stdin
-For a connection through standard input and standard output, as when
-@code{uucico} is run as a login shell.
-@item direct
-For a direct connection to another system.
-@item tcp
-For a connection using TCP.
-@item tli
-For a connection using TLI.
-@item pipe
-For a connection through a pipe running another program.
-@end table
-
-@item protocol @var{string}
-@findex protocol in port file
-
-Specify a list of protocols to use for this port. This is just like the
-corresponding command for a system (@pxref{Protocol Selection}). A
-protocol list for a system takes precedence over a list for a port.
-
-@item protocol-parameter @var{character} @var{strings} [ any type ]
-@findex protocol-parameter in port file
-
-The same command as the @code{protocol-parameter} command used for
-systems (@pxref{Protocol Selection}). This one takes precedence.
-
-@item seven-bit @var{boolean} [ any type ]
-@findex seven-bit in port file
-
-This is only used during protocol negotiation; if the argument is true,
-it forces the selection of a protocol which works across a seven-bit
-link. It does not prevent eight bit characters from being transmitted.
-The default is false.
-
-@item reliable @var{boolean} [ any type ]
-@findex reliable in port file
-
-This is only used during protocol negotiation; if the argument is
-false, it forces the selection of a protocol which works across
-an unreliable communication link. The default is true. It would
-be more common to specify this for a dialer rather than a port.
-
-@item half-duplex @var{boolean} [ any type ]
-@findex half-duplex in port file
-
-If the argument is true, it means that the port only supports
-half-duplex connections. This only affects bidirectional protocols, and
-causes them to not do bidirectional transfers.
-
-@item device @var{string} [ modem, direct and tli only ]
-@findex device
-
-Names the device associated with this port. If the device is not named,
-the port name is taken as the device. Device names are system
-dependent. On Unix, a modem or direct connection might be something
-like @file{/dev/ttyd0}; a TLI port might be @file{/dev/inet/tcp}.
-
-@itemx speed @var{number} [modem and direct only ]
-@findex speed in port file
-@item baud @var{number} [ modem and direct only ]
-@findex baud in port file
-
-The speed this port runs at. If a system specifies a speed but no port
-name, then all ports which match the speed will be tried in order. If
-the speed is not specified here and is not specified by the system, the
-natural speed of the port will be used by default.
-
-@itemx speed-range @var{number} @var{number} [ modem only ]
-@findex speed-range
-@item baud-range @var{number} @var{number} [ modem only ]
-@findex baud-range
-
-Specify a range of speeds this port can run at. The first number is the
-minimum speed, the second number is the maximum speed. These numbers
-will be used when matching a system which specifies a desired speed.
-The simple @code{speed} (or @code{baud}) command is still used to
-determine the speed to run at if the system does not specify a speed.
-For example, the command @samp{speed-range 300 19200} means that the
-port will match any system which uses a speed from 300 to 19200 baud
-(and will use the speed specified by the system); this could be combined
-with @samp{speed 2400}, which means that when this port is used with a
-system that does not specify a speed, the port will be used at 2400
-baud.
-
-@item carrier @var{boolean} [ modem and direct only ]
-@findex carrier in port file
-
-The argument indicates whether the port supports carrier.
-
-If a modem port does not support carrier, the carrier detect signal will
-never be required on this port, regardless of what the modem chat script
-indicates. The default for a modem port is true.
-
-If a direct port supports carrier, the port will be set to expect
-carrier whenever it is used. The default for a direct port is false.
-
-@item hardflow @var{boolean} [ modem and direct only ]
-@findex hardflow
-
-The argument indicates whether the port supports hardware flow control.
-If it does not, hardware flow control will not be turned on for this
-port. The default is true. Hardware flow control is only supported on
-some systems.
-
-@item dial-device @var{string} [ modem only ]
-@findex dial-device
-
-Dialing instructions should be output to the named device, rather than
-to the normal port device. The default is to output to the normal port
-device.
-
-@item dialer @var{string} [ modem only ]
-@findex dialer in port file
-
-Name a dialer to use. The information is looked up in the dial file.
-There is no default. Some sort of dialer information must be specified
-to call out on a modem.
-
-@item dialer @var{string} @dots{} [ modem only ]
-
-If more than one string follows the @code{dialer} command, the strings
-are treated as a command that might appear in the dial file (@pxref{dial
-File}). If a dialer is named (by using the first form of this command,
-described just above), these commands are ignored. They may be used to
-specify dialer information directly in simple situations without needing
-to go to a separate file. There is no default. Some sort of dialer
-information must be specified to call out on a modem.
-
-@item dialer-sequence @var{strings} [ modem or tcp or tli only ]
-@findex dialer-sequence
-
-Name a sequence of dialers and tokens (phone numbers) to use. The first
-argument names a dialer, and the second argument names a token. The
-third argument names another dialer, and so on. If there are an odd
-number of arguments, the phone number specified with a @code{phone}
-command in the system file is used as the final token. The token is
-what is used for @kbd{\D} or @kbd{\T} in the dialer chat script. If the
-token in this string is @kbd{\D}, the system phone number will be used;
-if it is @kbd{\T}, the system phone number will be used after undergoing
-dialcodes translation. A missing final token is taken as @kbd{\D}.
-
-This command currently does not work if @code{dial-device} is specified;
-to handle this correctly will require a more systematic notion of chat
-scripts. Moreover, the @code{complete} and @code{abort} chat scripts,
-the protocol parameters, and the @code{carrier} and @code{dtr-toggle}
-commands are ignored for all but the first dialer.
-
-This command basically lets you specify a sequence of chat scripts to
-use. For example, the first dialer might get you to a local network and
-the second dialer might describe how to select a machine from the local
-network. This lets you break your dialing sequence into simple modules,
-and may make it easier to share dialer entries between machines.
-
-This command is to only way to use a chat script with a TCP port. This
-can be useful when using a modem which is accessed via TCP.
-
-When this command is used with a TLI port, then if the first dialer is
-@samp{TLI} or @samp{TLIS} the first token is used as the address to
-connect to. If the first dialer is something else, or if there is no
-token, the address given by the @code{address} command is used
-(@pxref{Placing the Call}). Escape sequences in the address are
-expanded as they are for chat script expect strings (@pxref{Chat
-Scripts}). The different between @samp{TLI} and @samp{TLIS} is that the
-latter implies the command @samp{stream true}. These contortions are
-all for HDB compatibility. Any subsequent dialers are treated as they
-are for a TCP port.
-
-@item lockname @var{string} [ modem and direct only ]
-@findex lockname
-
-Give the name to use when locking this port. On Unix, this is the name
-of the file that will be created in the lock directory. It is used as
-is, so on Unix it should generally start with @samp{LCK..}. For
-example, if a single port were named both @file{/dev/ttycu0} and
-@file{/dev/tty0} (perhaps with different characteristics keyed on the
-minor device number), then the command @code{lockname LCK..ttycu0} could
-be used to force the latter to use the same lock file name as the
-former.
-
-@item service @var{string} [ tcp only ]
-@findex service
-
-Name the TCP port number to use. This may be a number. If not, it will
-be looked up in @file{/etc/services}. If this is not specified, the
-string @samp{uucp} is looked up in @file{/etc/services}. If it is not
-found, port number 540 (the standard UUCP-over-TCP port number) will be
-used.
-
-@item push @var{strings} [ tli only ]
-@findex push
-
-Give a list of modules to push on to the TLI stream.
-
-@item stream @var{boolean} [ tli only ]
-@findex stream
-
-If this is true, and the @code{push} command was not used, the
-@samp{tirdwr} module is pushed on to the TLI stream.
-
-@item server-address @var{string} [ tli only ]
-@findex server-address
-
-Give the address to use when running as a TLI server. Escape sequences
-in the address are expanded as they are for chat script expect strings
-(@pxref{Chat Scripts}).
-
-The string is passed directly to the TLI @code{t_bind} function. The
-value needed may depend upon your particular TLI implementation. Check
-the manual pages, and, if necessary, try writing some sample programs.
-
-For AT&T 3B2 System V Release 3 using the Wollongong TCP/IP stack, which
-is probably typical, the format of TLI string is @samp{SSPPIIII}, where
-@samp{SS} is the service number (for TCP, this is 2), @samp{PP} is the
-TCP port number, and @samp{IIII} is the Internet address. For example,
-to accept a connection from on port 540 from any interface, use
-@samp{server-address \x00\x02\x02\x1c\x00\x00\x00\x00}. To only accept
-connections from a particular interface, replace the last four digits
-with the network address of the interface. (Thanks to Paul Pryor for
-the information in this paragraph).
-
-@item command @var{strings} [ pipe only ]
-@findex command
-
-Give the command, with arguments, to run when using a pipe port type.
-When a port of this type is used, the command is executed and
-@code{uucico} communicates with it over a pipe. This permits
-@code{uucico} or @code{cu} to communicate with another system which can
-only be reached through some unusual means. A sample use might be
-@samp{command /bin/rlogin -E -8 -l @var{login} @var{system}}. The
-command is run with the full privileges of UUCP; it is responsible for
-maintaining security.
-
-@end table
-
-@node dial File, UUCP Over TCP, port File, Configuration Files
-@section The Dialer Configuration File
-@cindex dial file
-@cindex dialer configuration file
-@cindex configuration file (dial)
-
-The dialer configuration files define dialers. By default there is a
-single dialer file, named @file{dial} in the directory
-@var{newconfigdir}. This may be overridden by the @code{dialfile}
-command in the main configuration file; see @ref{Configuration File
-Names}.
-
-Any commands in the file before the first @code{dialer} command specify
-defaults for all the dialers in the file. All commands after a
-@code{dialer} command up to the next @code{dialer} command are
-associated with the named dialer.
-
-@table @code
-
-@item dialer @var{string}
-@findex dialer in dial file
-
-Introduces and names a dialer.
-
-@item chat @var{strings}
-@findex chat in dial file
-@item chat-timeout @var{number}
-@findex chat-timeout in dial file
-@item chat-fail @var{string}
-@findex chat-fail in dial file
-@item chat-seven-bit @var{boolean}
-@findex chat-seven-bit in dial file
-@item chat-program @var{strings}
-@findex chat-program in dial file
-
-Specify a chat script to be used to dial the phone. This chat script is
-used before the login chat script in the @file{sys} file, if any
-(@pxref{Logging In}). For full details on chat scripts, see @ref{Chat
-Scripts}.
-
-The @code{uucico} daemon will sleep for one second between attempts to
-dial out on a modem. If your modem requires a longer wait period, you
-must start your chat script with delays (@samp{\d} in a send string).
-
-The chat script will be read from and sent to the port specified by the
-@code{dial-device} command for the port, if there is one.
-
-The following escape addition escape sequences may appear in send
-strings:
-
-@table @kbd
-@item \D
-send phone number without dialcode translation
-@item \T
-send phone number with dialcode translation
-@item \M
-do not require carrier
-@item \m
-require carrier (fail if not present)
-@end table
-
-See the description of the dialcodes file (@pxref{Configuration File
-Names}) for a description of dialcode translation. If the port does not
-support carrier, as set by the @code{carrier} command in the port file,
-@kbd{\M} and @kbd{\m} are ignored. If both the port and the dialer
-support carrier, as set by the @code{carrier} command in the port file
-and the @code{carrier} command in the dialer file, then every chat
-script implicitly begins with @kbd{\M} and ends with @kbd{\m}. There is
-no default chat script for dialers.
-
-The following additional escape sequences may be used in
-@code{chat-program}:
-
-@table @kbd
-@item \D
-phone number without dialcode translation
-@item \T
-phone number with dialcode translation
-@end table
-
-If the program changes the port in any way (e.g., sets parity) the
-changes will be preserved during protocol negotiation, but once the
-protocol is selected it will change the port settings.
-
-@item dialtone @var{string}
-@findex dialtone
-
-A string to output when dialing the phone number which causes the modem
-to wait for a secondary dial tone. This is used to translate the
-@kbd{=} character in a phone number. The default is a comma.
-
-@item pause @var{string}
-@findex pause
-
-A string to output when dialing the phone number which causes the modem
-to wait for 1 second. This is used to translate the @kbd{-} character
-in a phone number. The default is a comma.
-
-@item carrier @var{boolean}
-@findex carrier in dial file
-
-An argument of true means that the dialer supports the modem carrier
-signal. After the phone number is dialed, @code{uucico} will require
-that carrier be on. One some systems, it will be able to wait for it.
-If the argument is false, carrier will not be required. The default is
-true.
-
-@item carrier-wait @var{number}
-@findex carrier-wait
-
-If the port is supposed to wait for carrier, this may be used to
-indicate how many seconds to wait. The default is 60 seconds. Only
-some systems support waiting for carrier.
-
-@item dtr-toggle @var{boolean} @var{boolean}
-@findex dtr-toggle
-
-If the first argument is true, then DTR is toggled before using
-the modem. This is only supported on some systems and some ports. The
-second @var{boolean} need not be present; if it is, and it is
-true, the program will sleep for 1 second after toggling DTR.
-The default is to not toggle DTR.
-
-@need 500
-@item complete-chat @var{strings}
-@findex complete-chat
-@item complete-chat-timeout @var{number}
-@findex complete-chat-timeout
-@item complete-chat-fail @var{string}
-@findex complete-chat-fail
-@item complete-chat-seven-bit @var{boolean}
-@findex complete-chat-seven-bit
-@item complete-chat-program @var{strings}
-@findex complete-chat-program
-
-These commands define a chat script (@pxref{Chat Scripts}) which is run
-when a call is finished normally. This allows the modem to be reset.
-There is no default. No additional escape sequences may be used.
-
-@item complete @var{string}
-@findex complete
-
-This is a simple use of @code{complete-chat}. It is equivalent to
-@code{complete-chat "" @var{string}}; this has the effect of sending
-@var{string} to the modem when a call finishes normally.
-
-@item abort-chat @var{strings}
-@findex abort-chat
-@item abort-chat-timeout @var{number}
-@findex abort-chat-timeout
-@item abort-chat-fail @var{string}
-@findex abort-chat-fail
-@item abort-chat-seven-bit @var{boolean}
-@findex abort-chat-seven-bit
-@item abort-chat-program @var{strings}
-@findex abort-chat-program
-
-These commands define a chat script (@pxref{Chat Scripts}) to be run
-when a call is aborted. They may be used to interrupt and reset the
-modem. There is no default. No additional escape sequences may be
-used.
-
-@item abort @var{string}
-@findex abort
-
-This is a simple use of @code{abort-chat}. It is equivalent to
-@code{abort-chat "" @var{string}}; this has the effect of sending
-@var{string} to the modem when a call is aborted.
-
-@item protocol-parameter @var{character} @var{strings}
-@findex protocol-parameter in dial file
-
-Set protocol parameters, just like the @code{protocol-parameter} command
-in the system configuration file or the port configuration file; see
-@ref{Protocol Selection}. These parameters take precedence, then those
-for the port, then those for the system.
-
-@item seven-bit @var{boolean}
-@findex seven-bit in dial file
-
-This is only used during protocol negotiation; if it is true, it
-forces selection of a protocol which works across a seven-bit link. It
-does not prevent eight bit characters from being transmitted. The
-default is false. It would be more common to specify this for a
-port than for a dialer.
-
-@item reliable @var{boolean}
-@findex reliable in dial file
-
-This is only used during protocol negotiation; if it is false, it
-forces selection of a protocol which works across an unreliable
-communication link. The default is true.
-
-@item half-duplex @var{boolean} [ any type ]
-@findex half-duplex in dial file
-
-If the argument is true, it means that the dialer only supports
-half-duplex connections. This only affects bidirectional protocols, and
-causes them to not do bidirectional transfers.
-
-@end table
-
-@node UUCP Over TCP, Security, dial File, Configuration Files
-@section UUCP Over TCP
-
-If your system has a Berkeley style socket library, or a System V style
-TLI interface library, you can compile the code to permit making
-connections over TCP. Specifying that a system should be reached via
-TCP is easy, but nonobvious.
-
-@menu
-* TCP Client:: Connecting to Another System Over TCP
-* TCP Server:: Running a TCP Server
-@end menu
-
-@node TCP Client, TCP Server, UUCP Over TCP, UUCP Over TCP
-@subsection Connecting to Another System Over TCP
-
-If you are using the new style configuration files (@pxref{Configuration
-Files}), add the line @samp{port type tcp} to the entry in the
-@file{sys} file. By default UUCP will get the port number by looking up
-@samp{uucp} in @file{/etc/services}; if the @samp{uucp} service is not
-defined, port 540 will be used. You can set the port number to use with
-the command @samp{port service @var{xxx}}, where @var{xxx} can be either
-a number or a name to look up in @file{/etc/services}. You can specify
-the address of the remote host with @samp{address @var{a.b.c}}; if you
-don't give an address, the remote system name will be used. You should
-give an explicit chat script for the system when you use TCP; the
-default chat script begins with a carriage return, which will not work
-with some UUCP TCP servers.
-
-If you are using V2 configuration files, add a line like this to
-@file{L.sys}:
-@example
-@var{sys} Any TCP uucp @var{host}.@var{domain} chat-script
-@end example
-This will make an entry for system @var{sys}, to be called at any time,
-over TCP, using port number @samp{uucp} (as found in
-@file{/etc/services}; this may be specified as a number), using remote
-host @file{@var{host}.@var{domain}}, with some chat script.
-
-If you are using HDB configuration files, add a line like this to
-Systems:
-@example
-@var{sys} Any TCP - @var{host}.@var{domain} chat-script
-@end example
-and a line like this to @file{Devices}:
-@example
-TCP uucp - -
-@end example
-You only need one line in @file{Devices} regardless of how many systems
-you contact over TCP. This will make an entry for system @var{sys}, to
-be called at any time, over TCP, using port number @samp{uucp} (as found
-in @file{/etc/services}; this may be specified as a number), using
-remote host @file{@var{host}.@var{domain}}, with some chat script.
-
-@node TCP Server, , TCP Client, UUCP Over TCP
-@subsection Running a TCP Server
-
-The @code{uucico} daemon may be run as a TCP server. To use the default
-port number, which is a reserved port, @code{uucico} must be invoked by
-the superuser (or it must be set user ID to the superuser, but I don't
-recommend doing that).
-
-You must define a port, either using the port file (@pxref{port File}),
-if you are using the new configuration method, or with an entry in
-@file{Devices} if you are using HDB; there is no way to define a port
-using V2. If you are using HDB the port must be named @samp{TCP}; a
-line as shown above will suffice. You can then start @code{uucico} as
-@samp{uucico -p TCP} (after the @samp{-p}, name the port; in HDB it must
-be @samp{TCP}). This will wait for incoming connections, and fork off a
-child for each one. Each connection will be prompted with @samp{login:}
-and @samp{Password:}; the results will be checked against the UUCP (not
-the system) password file (@pxref{Configuration File Names}).
-
-Another way to run a UUCP TCP server is to use the BSD @code{uucpd}
-program.
-
-Yet another way to run a UUCP TCP server is to use @code{inetd}.
-Arrange for @code{inetd} to start up @code{uucico} with the @samp{-l}
-switch. This will cause @code{uucico} to prompt with @samp{login:} and
-@samp{Password:} and check the results against the UUCP (not the system)
-password file (you may want to also use the @samp{-D} switch to avoid a
-fork, which in this case is unnecessary).
-
-@node Security, , UUCP Over TCP, Configuration Files
-@section Security
-
-This discussion of UUCP security applies only to Unix. It is a bit
-cursory; suggestions for improvement are solicited.
-
-UUCP is traditionally not very secure. Taylor UUCP addresses some
-security issues, but is still far from being a secure system.
-
-If security is very important to you, then you should not permit any
-external access to your computer, including UUCP. Any opening to the
-outside world is a potential security risk.
-
-When local users use UUCP to transfer files, Taylor UUCP can do little
-to secure them from each other. You can allow somewhat increased
-security by putting the owner of the UUCP programs (normally
-@code{uucp}) into a separate group; the use of this is explained in the
-following paragraphs, which refer to this separate group as
-@code{uucp-group}.
-
-When the @code{uucp} program is invoked to copy a file to a remote
-system, it will, by default, copy the file into the UUCP spool
-directory. When the @code{uux} program is used, the @samp{-C} switch
-must be used to copy the file into the UUCP spool directory. In any
-case, once the file has been copied into the spool directory, other
-local users will not be able to access it.
-
-When a file is requested from a remote system, UUCP will only permit it
-to be placed in a directory which is writable by the requesting user.
-The directory must also be writable by UUCP. A local user can create a
-directory with a group of @code{uucp-group} and set the mode to permit
-group write access. This will allow the file be requested without
-permitting it to be viewed by any other user.
-
-There is no provision for security for @code{uucp} requests (as opposed
-to @code{uux} requests) made by a user on a remote system. A file sent
-over by a remote request may only be placed in a directory which is
-world writable, and the file will be world readable and writable. This
-will permit any local user to destroy or replace the contents of the
-file. A file requested by a remote system must be world readable, and
-the directory it is in must be world readable. Any local user will be
-able to examine, although not necessarily modify, the file before it is
-sent.
-
-There are some security holes and race conditions that apply to the
-above discussion which I will not elaborate on. They are not hidden
-from anybody who reads the source code, but they are somewhat technical
-and difficult (though scarcely impossible) to exploit. Suffice it to
-say that even under the best of conditions UUCP is not completely
-secure.
-
-For many sites, security from remote sites is a more important
-consideration. Fortunately, Taylor UUCP does provide some support in
-this area.
-
-The greatest security is provided by always dialing out to the other
-site. This prevents anybody from pretending to be the other site. Of
-course, only one side of the connection can do this.
-
-If remote dialins must be permitted, then it is best if the dialin line
-is used only for UUCP. If this is the case, then you should create a
-call-in password file (@pxref{Configuration File Names}) and let
-@code{uucico} do its own login prompting. For example, to let remote
-sites log in on a port named @samp{entry} in the port file (@pxref{port
-File}), you might invoke @samp{uucico -e -p entry}. This would cause
-@code{uucico} to enter an endless loop of login prompts and daemon
-executions. The advantage of this approach is that even if remote users
-break into the system by guessing or learning the password, they will
-only be able to do whatever @code{uucico} permits them to do. They will
-not be able to start a shell on your system.
-
-If remote users can dial in and log on to your system, then you have a
-security hazard more serious than that posed by UUCP. But then, you
-probably knew that already.
-
-Once your system has connected with the remote UUCP, there is a fair
-amount of control you can exercise. You can use the @code{remote-send}
-and @code{remote-receive} commands to control the directories the remote
-UUCP can access. You can use the @code{request} command to prevent the
-remote UUCP from making any requests of your system at all; however, if
-you do this it will not even be able to send you mail or news. If you
-do permit remote requests, you should be careful to restrict what
-commands may be executed at the remote system's request. The default is
-@code{rmail} and @code{rnews}, which will suffice for most systems.
-
-If different remote systems call in and they must be granted different
-privileges (perhaps some systems are within the same organization and
-some are not) then the @code{called-login} command should be used for
-each system to require that they use different login names. Otherwise,
-it would be simple for a remote system to use the @code{myname} command
-and pretend to be a different system. The @code{sequence} command can
-be used to detect when one system pretended to be another, but, since
-the sequence numbers must be reset manually after a failed handshake,
-this can sometimes be more trouble than it's worth.
-
-@c START-OF-FAQ
-@ignore
-This chapter is used to generate the comp.mail.uucp UUCP Internals FAQ,
-as well as being part of the Taylor UUCP manual. Text that should
-appear only in the manual is bracketed by ifclear faq. Text that should
-appear only in the FAQ is bracketed by ifset faq.
-@end ignore
-
-@ifset faq
-@paragraphindent asis
-@format
-Subject: UUCP Internals Frequently Asked Questions
-Newsgroups: comp.mail.uucp,comp.answers,news.answers
-Followup-To: comp.mail.uucp
-Reply-To: ian@@airs.com (Ian Lance Taylor)
-Keywords: UUCP, protocol, FAQ
-Approved: news-answers-request@@MIT.Edu
-
-Archive-name: uucp-internals
-Version: $Revision: 1.2 $
-Last-modified: $Date: 1995/08/19 21:24:55 $
-@end format
-@end ifset
-
-@node Protocols, Hacking, Configuration Files, Top
-@chapter UUCP Protocol Internals
-
-@ifclear faq
-This chapter describes how the various UUCP protocols work, and
-discusses some other internal UUCP issues.
-
-This chapter is quite technical. You do not need to understand it, or
-even read it, in order to use Taylor UUCP. It is intended for people
-who are interested in how the UUCP code works.
-
-The information in this chapter is posted monthly to the Usenet
-newsgroups @samp{comp.mail.uucp}, @samp{news.answers}, and
-@samp{comp.answers}. The posting is available from any
-@samp{news.answers} archive site, such as @samp{rtfm.mit.edu}. If you
-plan to use this information to write a UUCP program, please make sure
-you get the most recent version of the posting, in case there have been
-any corrections.
-@end ifclear
-
-@ifset faq
-Recent changes:
-@itemize @bullet
-@item Conversion to Texinfo format.
-@item Description of the @samp{E} command.
-@item Description of optional number following @samp{-N} and @samp{ROKN}
-in UUCP protocol startup.
-@item Detailed description of the @samp{y} protocol.
-@item Mention the name uuxqt uses for lock files.
-@end itemize
-
-This article was written by Ian Lance Taylor @samp{<ian@@airs.com>} and
-I may even update it periodically. Please send me mail about
-suggestions or inaccuracies.
-
-This article describes how the various UUCP protocols work, and
-discusses some other internal UUCP issues. It does not describe how to
-configure UUCP, nor how to solve UUCP connection problems, nor how to
-deal with UUCP mail. I do not know of any FAQ postings on these topics.
-There are some documents on the net describing UUCP configuration, but I
-can not keep an up to date list here; try using archie.
-
-If you haven't read the @samp{news.announce.newusers} articles, read
-them.
-
-This article is in digest format. Some newsreaders will be able to
-break it apart into separate articles. Please don't ask me how to do
-this, though.
-
-This article covers the following topics. If questions about one of
-these topics is posted to @samp{comp.mail.uucp}, please send mail to the
-poster referring her or him to this FAQ. There is no reason to post a
-followup, as most of us know the answer already.
-@end ifset
-
-@menu
-* UUCP Protocol Sources:: Sources for UUCP Protocol Information
-* UUCP Grades:: UUCP Grades
-* UUCP Lock Files:: UUCP Lock Files
-* Execution File Format:: Execution File Format
-* UUCP Protocol:: UUCP Protocol
-* g Protocol:: g protocol
-* f Protocol:: f protocol
-* t Protocol:: t protocol
-* e Protocol:: e protocol
-* Big G Protocol:: G protocol
-* i Protocol:: i protocol
-* j Protocol:: j protocol
-* x Protocol:: x protocol
-* y Protocol:: y protocol
-* d Protocol:: d protocol
-* h Protocol:: h protocol
-* v Protocol:: v protocol
-@end menu
-
-@ifset faq
-@format
-UUCP Protocol Sources
-Alarm in Debugging Output
-UUCP Grades
-UUCP Lock Files
-Execution File Format
-UUCP Protocol
-UUCP @samp{g} Protocol
-UUCP @samp{f} Protocol
-UUCP @samp{t} Protocol
-UUCP @samp{e} Protocol
-UUCP @samp{G} Protocol
-UUCP @samp{i} Protocol
-UUCP @samp{j} Protocol
-UUCP @samp{x} Protocol
-UUCP @samp{y} Protocol
-UUCP @samp{d} Protocol
-UUCP @samp{h} Protocol
-UUCP @samp{v} Protocol
-Thanks
-
-----------------------------------------------------------------------
-
-From: UUCP Protocol Sources
-Subject: UUCP Protocol Sources
-
-@end format
-@end ifset
-
-@node UUCP Protocol Sources, UUCP Grades, Protocols, Protocols
-@section UUCP Protocol Sources
-
-@quotation
-``Unix-to-Unix Copy Program,'' said PDP-1. ``You will never find a more
-wretched hive of bugs and flamers. We must be cautious.''
-@flushright
----DECWars
-@end flushright
-@end quotation
-
-I took a lot of the information from Jamie E. Hanrahan's paper in the
-Fall 1990 DECUS Symposium, and from @cite{Managing UUCP and Usenet} by Tim
-O'Reilly and Grace Todino (with contributions by several other
-people). The latter includes most of the former, and is published by
-@example
-O'Reilly & Associates, Inc.
-103 Morris Street, Suite A
-Sebastopol, CA 95472
-@end example
-It is currently in its tenth edition. The ISBN number is
-@samp{0-937175-93-5}.
-
-Some information is originally due to a Usenet article by Chuck Wegrzyn.
-The information on execution files comes partially from Peter Honeyman.
-The information on the @samp{g} protocol comes partially from a paper by
-G.L.@: Chesson of Bell Laboratories, partially from Jamie E. Hanrahan's
-paper, and partially from source code by John Gilmore. The information
-on the @samp{f} protocol comes from the source code by Piet Berteema.
-The information on the @samp{t} protocol comes from the source code by
-Rick Adams. The information on the @samp{e} protocol comes from a
-Usenet article by Matthias Urlichs. The information on the @samp{d}
-protocol comes from Jonathan Clark, who also supplied information about
-QFT. The UUPlus information comes straight from Christopher J. Ambler,
-of UUPlus Development; it applies to version 1.52 and up of the
-shareware version of UUPlus Utilities, called FSUUCP 1.52, but referred
-to in this article as UUPlus.
-
-Although there are few books about UUCP, there are many about networks
-and protocols in general. I recommend two non-technical books which
-describe the sorts of things that are available on the network:
-@cite{The Whole Internet}, by Ed Krol, and @cite{Zen and the Art of the
-Internet}, by Brendan P. Kehoe. Good technical discussions of
-networking issues can be found in @cite{Internetworking with TCP/IP}, by
-Douglas E. Comer and David L. Stevens and in @cite{Design and Validation
-of Computer Protocols} by Gerard J. Holzmann.
-
-@ifset faq
-@c Note that this section is only in the FAQ, since it does not fit in
-@c here in the manual.
-@format
-------------------------------
-
-From: Alarm in Debugging Output
-Subject: Alarm in Debugging Output
-
-Alarm in Debugging Output
-=========================
-@end format
-
-The debugging output of many versions of UUCP will include messages like
-@samp{alarm 1} or @samp{pkcget: alarm 1}. Taylor UUCP does not use the
-word @samp{alarm}, but will instead log messages like @samp{Timed out
-waiting for packet}.
-
-These types of messages mean that the UUCP package has timed out while
-waiting for some sort of response from the remote system. If it happens
-consistently when trying to transfer a particular file, then the most
-likely problem is that one of the modems will not transmit the XON or
-XOFF characters. Several UUCP protocols require an eight bit clean
-connection, which means that the modems must treat XON or XOFF as normal
-data characters, not as flow control signals. This should always be
-checked first.
-
-Other possible problems are that the modems have simply dropped their
-connection, or perhaps on one side or the other the serial buffer is
-overflowing and dropping characters. Another possibility is that the
-UUCP packages disagree about some aspect of the UUCP protocol, which is
-uncommon but does happen occasionally.
-
-Using the information in the following sections, you should be able to
-figure out what type of data your UUCP was expecting to receive. This
-may give some indication as to exactly what the problem is. It is
-difficult to be more specific, since there are many possiblities.
-
-@format
-------------------------------
-
-From: UUCP Grades
-Subject: UUCP Grades
-@end format
-@end ifset
-
-@node UUCP Grades, UUCP Lock Files, UUCP Protocol Sources, Protocols
-@section UUCP Grades
-@cindex grades implementation
-
-Modern UUCP packages support a priority grade for each command. The
-grades generally range from @kbd{A} (the highest) to @kbd{Z} followed by
-@kbd{a} to @kbd{z}. Some UUCP packages (including Taylor UUCP) also
-support @kbd{0} to @kbd{9} before @kbd{A}. Some UUCP packages may
-permit any ASCII character as a grade.
-
-On Unix, these grades are encoded in the name of the command file
-created by @code{uucp} or @code{uux}. A command file name generally has
-the form @file{C.nnnngssss} where @samp{nnnn} is the remote system name
-for which the command is queued, @samp{g} is a single character grade,
-and @samp{ssss} is a four character sequence number. For example, a
-command file created for the system @samp{airs} at grade @samp{Z} might
-be named @file{C.airsZ2551}.
-
-The remote system name will be truncated to seven characters, to
-ensure that the command file name will fit in the 14 character file
-name limit of the traditional Unix file system. UUCP packages which
-have no other means of distinguishing which command files are intended
-for which systems thus require all systems they connect to to have
-names that are unique in the first seven characters. Some UUCP
-packages use a variant of this format which truncates the system name
-to six characters. HDB and Taylor UUCP use a different spool
-directory format, which allows up to fourteen characters to be used
-for each system name.
-
-The sequence number in the command file name may be a decimal integer,
-or it may be a hexadecimal integer, or it may contain any alphanumeric
-character. Different UUCP packages are different.
-@ifclear faq
-Taylor UUCP uses any alphanumeric character.
-@end ifclear
-
-UUPlus Utilities (as FSUUCP, a shareware DOS based UUCP and news
-package) uses up to 8 characters for file names in the spool (this is a
-DOS file system limitation; actually, with the extension, 11 characters
-are available, but FSUUCP reserves that for future use). FSUUCP
-defaults mail to grade @samp{D}, and news to grade @samp{N}, except that
-when the grade of incoming mail can be determined, that grade is
-preserved if the mail is forwarded to another system. The default grades
-may be changed by editing the @file{LIB/MAILRC} file for mail, or the
-@file{UUPLUS.CFG} file for news.
-
-UUPC/extended for DOS, OS/2 and Windows NT handles mail at grade
-@samp{C}, news at grade @samp{d}, and file transfers at grade @samp{n}.
-The UUPC/extended @code{UUCP} and @code{RMAIL} commands accept grades to
-override the default, the others do not.
-
-I do not know how command grades are handled in other non-Unix UUCP
-packages.
-
-Modern UUCP packages allow you to restrict file transfer by grade
-depending on the time of day. Typically this is done with a line in
-the @file{Systems} (or @file{L.sys}) file like this:
-@example
- airs Any/Z,Any2305-0855 ...
-@end example
-This allows grades @samp{Z} and above to be transferred at any time.
-Lower grades may only be transferred at night. I believe that this
-grade restriction applies to local commands as well as to remote
-commands, but I am not sure. It may only apply if the UUCP package
-places the call, not if it is called by the remote system.
-
-Taylor UUCP can use the @code{timegrade} and @code{call-timegrade}
-commands to achieve the same effect.
-@ifclear faq
-@xref{When to Call}.
-@end ifclear
-It supports the above format when reading @file{Systems} or
-@file{L.sys}.
-
-UUPC/extended provides the @code{symmetricgrades} option to announce the
-current grade in effect when calling the remote system.
-
-UUPlus allows specification of the highest grade accepted on a per-call
-basis with the @samp{-g} option in @code{UUCICO}.
-
-This sort of grade restriction is most useful if you know what grades
-are being used at the remote site. The default grades used depend on
-the UUCP package. Generally @code{uucp} and @code{uux} have different
-defaults. A particular grade can be specified with the @samp{-g} option
-to @code{uucp} or @code{uux}. For example, to request execution of
-@samp{rnews} on @samp{airs} with grade @samp{d}, you might use something
-like
-@example
- uux -gd - airs!rnews < article
-@end example
-
-Uunet queues up mail at grade @samp{C}, but increases the grade based on
-the size. News is queued at grade @samp{d}, and file transfers at grade
-@samp{n}. The example above would allow mail (below some large size) to
-be received at any time, but would only permit news to be transferred at
-night.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP Lock Files
-Subject: UUCP Lock Files
-@end format
-@end ifset
-
-@node UUCP Lock Files, Execution File Format, UUCP Grades, Protocols
-@section UUCP Lock Files
-@cindex lock files
-
-This discussion applies only to Unix. I have no idea how UUCP locks
-ports on other systems.
-
-UUCP creates files to lock serial ports and systems. On most, if not
-all, systems, these same lock files are also used by @code{cu} to
-coordinate access to serial ports. On some systems @code{getty} also
-uses these lock files, often under the name @code{uugetty}.
-
-The lock file normally contains the process ID of the locking process.
-This makes it easy to determine whether a lock is still valid. The
-algorithm is to create a temporary file and then link it to the name
-that must be locked. If the link fails because a file with that name
-already exists, the existing file is read to get the process ID. If the
-process still exists, the lock attempt fails. Otherwise the lock file
-is deleted and the locking algorithm is retried.
-
-Older UUCP packages put the lock files in the main UUCP spool directory,
-@file{/usr/spool/uucp}. HDB UUCP generally puts the lock files in a
-directory of their own, usually @file{/usr/spool/locks} or
-@file{/etc/locks}.
-
-The original UUCP lock file format encodes the process ID as a four byte
-binary number. The order of the bytes is host-dependent. HDB UUCP
-stores the process ID as a ten byte ASCII decimal number, with a
-trailing newline. For example, if process 1570 holds a lock file, it
-would contain the eleven characters space, space, space, space, space,
-space, one, five, seven, zero, newline. Some versions of UUCP add a
-second line indicating which program created the lock (@code{uucp},
-@code{cu}, or @code{getty/uugetty}). I have also seen a third type of
-UUCP lock file which does not contain the process ID at all.
-
-The name of the lock file is traditionally @file{LCK..} followed by the
-base name of the device. For example, to lock @file{/dev/ttyd0} the
-file @file{LCK..ttyd0} would be created. On SCO Unix, the lock file
-name is always forced to lower case even if the device name has upper
-case letters.
-
-System V Release 4 UUCP names the lock file using the major and minor
-device numbers rather than the device name. The file is named
-@file{LK.@var{XXX}.@var{YYY}.@var{ZZZ}}, where @var{XXX}, @var{YYY} and
-@var{ZZZ} are all three digit decimal numbers. @var{XXX} is the major
-device number of the device holding the directory holding the device
-file (e.g., @file{/dev}). @var{YYY} is the major device number of the
-device file itself. @var{ZZZ} is the minor device number of the device
-file itself. If @code{s} holds the result of passing the device to the
-stat system call (e.g., @code{stat ("/dev/ttyd0", &s)}), the following
-line of C code will print out the corresponding lock file name:
-@example
- printf ("LK.%03d.%03d.%03d", major (s.st_dev),
- major (s.st_rdev), minor (s.st_rdev));
-@end example
-The advantage of this system is that even if there are several links to
-the same device, they will all use the same lock file name.
-
-When two or more instances of @code{uuxqt} are executing, some sort of
-locking is needed to ensure that a single execution job is only started
-once. I don't know how most UUCP packages deal with this. Taylor UUCP
-uses a lock file for each execution job. The name of the lock file is
-the same as the name of the @file{X.*} file, except that the initial
-@samp{X} is changed to an @samp{L}. The lock file holds the process ID
-as described above.
-
-@ifset faq
-@format
-------------------------------
-
-From: Execution File Format
-Subject: Execution File Format
-@end format
-@end ifset
-
-@node Execution File Format, UUCP Protocol, UUCP Lock Files, Protocols
-@section Execution File Format
-@cindex execution file format
-@cindex @file{X.*} file format
-
-UUCP @file{X.*} files control program execution. They are created by
-@code{uux}. They are transferred between systems just like any other
-file. The @code{uuxqt} daemon reads them to figure out how to execute
-the job requested by @code{uux}.
-
-An @file{X.*} file is simply a text file. The first character of each
-line is a command, and the remainder of the line supplies arguments.
-The following commands are defined:
-
-@table @samp
-@item C command
-This gives the command to execute, including the program and all
-arguments. For example, @samp{rmail ian@@airs.com}.
-
-@item U user system
-This names the user who requested the command, and the system from which
-the request came.
-
-@item I standard-input
-This names the file from which standard input is taken. If no standard
-input file is given, the standard input will probably be attached to
-@file{/dev/null}. If the standard input file is not from the system on
-which the execution is to occur, it will also appear in an @samp{F}
-command.
-
-@item O standard-output [system]
-This names the standard output file. The optional second argument names
-the system to which the file should be sent. If there is no second
-argument, the file should be created on the executing system.
-
-@item F required-file [filename-to-use]
-The @samp{F} command can appear multiple times. Each @samp{F} command
-names a file which must exist before the execution can proceed. This
-will usually be a file which is transferred from the system on which
-@code{uux} was executed, but it can also be a file from the local system
-or some other system. If the file is not from the local system, then
-the command will usually name a file in the spool directory. If the
-optional second argument appears, then the file should be copied to the
-execution directory under that name. This is necessary for any file
-other than the standard input file. If the standard input file is not
-from the local system, it will appear in both an @samp{F} command and an
-@samp{I} command.
-
-@item R requestor-address
-This is the address to which mail about the job should be sent. It is
-relative to the system named in the @samp{U} command. If the @samp{R}
-command does not appear, then mail is sent to the user named in the
-@samp{U} command.
-
-@item Z
-This command takes no arguments. It means that a mail message should be
-sent if the command failed. This is the default behaviour for most
-modern UUCP packages, and for them the @samp{Z} command does not
-actually do anything.
-
-@item N
-This command takes no arguments. It means that no mail message should
-be sent, even if the command failed.
-
-@item n
-This command takes no arguments. It means that a mail message should be
-sent if the command succeeded. Normally a message is sent only if the
-command failed.
-
-@item B
-This command takes no arguments. It means that the standard input
-should be returned with any error message. This can be useful in cases
-where the input would otherwise be lost.
-
-@item e
-This command takes no arguments. It means that the command should be
-processed with @file{/bin/sh}. For some packages this is the default
-anyhow. Most packages will refuse to execute complex commands or
-commands containing wildcards, because of the security holes this opens.
-
-@item E
-This command takes no arguments. It means that the command should be
-processed with the @code{execve} system call. For some packages this is
-the default anyhow.
-
-@item M status-file
-This command means that instead of mailing a message, the message should
-be copied to the named file on the system named by the @samp{U} command.
-
-@item # comment
-This command is ignored, as is any other unrecognized command.
-@end table
-
-Here is an example. Given the following command executed on system
-test1
-@example
- uux - test2!cat - test2!~ian/bar !qux '>~/gorp'
-@end example
-(this is only an example, as most UUCP systems will not permit the cat
-command to be executed) Taylor UUCP will produce something like the
-following @file{X.} file:
-@example
-U ian test1
-F D.test1N003r qux
-O /usr/spool/uucppublic test1
-F D.test1N003s
-I D.test1N003s
-C cat - ~ian/bar qux
-@end example
-The standard input will be read into a file and then transferred to the
-file @file{D.test1N003s} on system @samp{test2}. The file @file{qux}
-will be transferred to @file{D.test1N003r} on system @samp{test2}. When
-the command is executed, the latter file will be copied to the execution
-directory under the name @samp{qux}. Note that since the file
-@file{~ian/bar} is already on the execution system, no action need be
-taken for it. The standard output will be collected in a file, then
-copied to the directory @file{/usr/spool/uucppublic} on the system
-@samp{test1}.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP Protocol
-Subject: UUCP Protocol
-@end format
-@end ifset
-
-@node UUCP Protocol, g Protocol, Execution File Format, Protocols
-@section UUCP Protocol
-@cindex UUCP protocol
-@cindex protocol, UUCP
-
-The UUCP protocol is a conversation between two UUCP packages. A UUCP
-conversation consists of three parts: an initial handshake, a series of
-file transfer requests, and a final handshake.
-
-@menu
-* The Initial Handshake:: The Initial Handshake
-* UUCP Protocol Commands:: UUCP Protocol Commands
-* The Final Handshake:: The Final Handshake
-@end menu
-
-@node The Initial Handshake, UUCP Protocol Commands, UUCP Protocol, UUCP Protocol
-@subsection The Initial Handshake
-@cindex initial handshake
-
-Before the initial handshake, the caller will usually have logged in the
-called machine and somehow started the UUCP package there. On Unix this
-is normally done by setting the shell of the login name used to
-@file{/usr/lib/uucp/uucico}.
-
-All messages in the initial handshake begin with a @kbd{^P} (a byte with
-the octal value @samp{\020}) and end with a null byte (@samp{\000}). A
-few systems end these messages with a line feed character (@samp{\012})
-instead of a null byte; the examples below assume a null byte is being
-used.
-
-Some options below are supported by QFT, which stands for Queued File
-Transfer, and is (or was) an internal Bell Labs version of UUCP.
-
-Taylor UUCP size negotiation was introduced by Taylor UUCP, and is
-also supported by DOS based UUPlus and Amiga based wUUCP and
-UUCP-1.17.
-
-The initial handshake goes as follows. It is begun by the called
-machine.
-
-@table @asis
-@item called: @samp{\020Shere=hostname\000}
-The hostname is the UUCP name of the called machine. Older UUCP
-packages do not output it, and simply send @samp{\020Shere\000}.
-
-@item caller: @samp{\020Shostname options\000}
-The hostname is the UUCP name of the calling machine. The following
-options may appear (or there may be none):
-
-@table @samp
-@item -QSEQ
-Report sequence number for this conversation. The sequence number is
-stored at both sites, and incremented after each call. If there is a
-sequence number mismatch, something has gone wrong (somebody may have
-broken security by pretending to be one of the machines) and the call is
-denied. If the sequence number changes on one of the machines, perhaps
-because of an attempted breakin or because a disk backup was restored,
-the sequence numbers on the two machines must be reconciled manually.
-
-@item -xLEVEL
-Requests the called system to set its debugging level to the specified
-value. This is not supported by all systems.
-
-@item -pGRADE
-@itemx -vgrade=GRADE
-Requests the called system to only transfer files of the specified grade
-or higher. This is not supported by all systems. Some systems support
-@samp{-p}, some support @samp{-vgrade=}. UUPlus allows either @samp{-p}
-or @samp{-v} to be specified on a per-system basis in the @file{SYSTEMS}
-file (@samp{gradechar} option).
-
-@item -R
-Indicates that the calling UUCP understands how to restart failed file
-transmissions. Supported only by System V Release 4 UUCP, QFT, and
-Taylor UUCP.
-
-@item -ULIMIT
-Reports the ulimit value of the calling UUCP. The limit is specified as
-a base 16 number in C notation (e.g., @samp{-U0x1000000}). This number
-is the number of 512 byte blocks in the largest file which the calling
-UUCP can create. The called UUCP may not transfer a file larger than
-this. Supported only by System V Release 4 UUCP, QFT and UUPlus.
-UUPlus reports the lesser of the available disk space on the spool
-directory drive and the ulimit variable in @file{UUPLUS.CFG}. Taylor
-UUCP understands this option, but does not generate it.
-
-@item -N[NUMBER]
-Indicates that the calling UUCP understands the Taylor UUCP size
-negotiation extension. Not supported by traditional UUCP packages.
-Supported by UUPlus. The optional number is a bitmask of features
-supported by the calling UUCP, and is described below.
-@end table
-
-@item called: @samp{\020ROK\000}
-There are actually several possible responses.
-@table @samp
-@item ROK
-The calling UUCP is acceptable, and the handshake proceeds to the
-protocol negotiation. Some options may also appear; see below.
-@item ROKN[NUMBER]
-The calling UUCP is acceptable, it specified @samp{-N}, and the called
-UUCP also understands the Taylor UUCP size limiting extensions. The
-optional number is a bitmask of features supported by the called UUCP,
-and is described below.
-@item RLCK
-The called UUCP already has a lock for the calling UUCP, which normally
-indicates the two machines are already communicating.
-@item RCB
-The called UUCP will call back. This may be used to avoid impostors
-(but only one machine out of each pair should call back, or no
-conversation will ever begin).
-@item RBADSEQ
-The call sequence number is wrong (see the @samp{-Q} discussion above).
-@item RLOGIN
-The calling UUCP is using the wrong login name.
-@item RYou are unknown to me
-The calling UUCP is not known to the called UUCP, and the called UUCP
-does not permit connections from unknown systems. Some versions of UUCP
-just drop the line rather than sending this message.
-@end table
-
-If the response is @samp{ROK}, the following options are supported by
-System V Release 4 UUCP and QFT.
-@table @samp
-@item -R
-The called UUCP knows how to restart failed file transmissions.
-@item -ULIMIT
-Reports the ulimit value of the called UUCP. The limit is specified as
-a base 16 number in C notation. This number is the number of 512 byte
-blocks in the largest file which the called UUCP can create. The
-calling UUCP may not send a file larger than this. Also supported by
-UUPlus. Taylor UUCP understands this option, but does not generate it.
-@item -xLEVEL
-I'm not sure just what this means. It may request the
-calling UUCP to set its debugging level to the specified
-value.
-@end table
-
-If the response is not @samp{ROK} (or @samp{ROKN}) both sides hang up
-the phone, abandoning the call.
-
-@item called: @samp{\020Pprotocols\000}
-Note that the called UUCP outputs two strings in a row. The protocols
-string is a list of UUCP protocols supported by the caller. Each UUCP
-protocol has a single character name. These protocols are discussed in
-more detail later in this document. For example, the called UUCP might
-send @samp{\020Pgf\000}.
-
-@item caller: @samp{\020Uprotocol\000}
-The calling UUCP selects which protocol to use out of the protocols
-offered by the called UUCP. If there are no mutually supported
-protocols, the calling UUCP sends @samp{\020UN\000} and both sides hang
-up the phone. Otherwise the calling UUCP sends something like
-@samp{\020Ug\000}.
-@end table
-
-Most UUCP packages will consider each locally supported protocol in turn
-and select the first one supported by the called UUCP. With some
-versions of HDB UUCP, this can be modified by giving a list of protocols
-after the device name in the @file{Devices} file or the @file{Systems}
-file. For example, to select the @samp{e} protocol in @file{Systems},
-@example
- airs Any ACU,e ...
-@end example
-or in Devices,
-@example
- ACU,e ttyXX ...
-@end example
-Taylor UUCP provides the @code{protocol}
-command which may be used either
-for a system
-@ifclear faq
-(@pxref{Protocol Selection})
-@end ifclear
-or a
-@ifclear faq
-port (@pxref{port File}).
-@end ifclear
-@ifset faq
-port.
-@end ifset
-UUPlus allows specification of the protocol string on a per-system basis
-in the @file{SYSTEMS} file.
-
-The optional number following a @samp{-N} sent by the calling system, or
-an @samp{ROKN} sent by the called system, is a bitmask of features
-supported by the UUCP package. The optional number was introduced in
-Taylor UUCP version 1.04. The number is sent as an octal number with a
-leading zero. The following bits are currently defined. A missing
-number should be taken as @samp{011}.
-
-@table @samp
-@item 01
-UUCP supports size negotiation.
-
-@item 02
-UUCP supports file restart.
-
-@item 04
-UUCP supports the @samp{E} command.
-
-@item 010
-UUCP requires the file size in the @samp{S} and @samp{R} commands to be
-in base 10. This bit is used by default if no number appears, but
-should not be explicitly sent.
-
-@item 020
-UUCP expects a dummy string between the notify field and the size field
-in an @samp{S} command. This is true of SVR4 UUCP. This bit should not
-be used.
-@end table
-
-After the protocol has been selected and the initial handshake has been
-completed, both sides turn on the selected protocol. For some protocols
-(notably @samp{g}) a further handshake is done at this point.
-
-@node UUCP Protocol Commands, The Final Handshake, The Initial Handshake, UUCP Protocol
-@subsection UUCP Protocol Commands
-
-Each protocol supports a method for sending a command to the remote
-system. This method is used to transmit a series of commands between
-the two UUCP packages. At all times, one package is the master and the
-other is the slave. Initially, the calling UUCP is the master.
-
-If a protocol error occurs during the exchange of commands, both sides
-move immediately to the final handshake.
-
-The master will send one of five commands: @samp{S}, @samp{R}, @samp{X},
-@samp{E}, or @samp{H}.
-
-Any file name referred to below is either an absolute file name
-beginning with @file{/}, a public directory file name beginning with
-@file{~/}, a file name relative to a user's home directory beginning
-with @file{~@var{USER}/}, or a spool directory file name. File names in
-the spool directory are not absolute, but instead are converted to file
-names within the spool directory by UUCP. They always begin with
-@file{C.} (for a command file created by @code{uucp} or @code{uux}),
-@file{D.} (for a data file created by @code{uucp}, @code{uux} or by an
-execution, or received from another system for an execution), or
-@file{X.} (for an execution file created by @code{uux} or received from
-another system).
-
-@menu
-* The S Command:: The S Command
-* The R Command:: The R Command
-* The X Command:: The X Command
-* The E Command:: The E Command
-* The H Command:: The H Command
-@end menu
-
-@node The S Command, The R Command, UUCP Protocol Commands, UUCP Protocol Commands
-@subsubsection The S Command
-@cindex S UUCP protocol command
-@cindex UUCP protocol S command
-
-@table @asis
-@item master: @samp{S @var{from} @var{to} @var{user} -@var{options} @var{temp} @var{mode} @var{notify} @var{size}}
-The @samp{S} and the @samp{-} are literal characters. This is a request
-by the master to send a file to the slave.
-
-@table @var
-@item from
-The name of the file to send. If the @samp{C} option does not appear in
-@var{options}, the master will actually open and send this file.
-Otherwise the file has been copied to the spool directory, where it is
-named @var{temp}. The slave ignores this field unless @var{to} is a
-directory, in which case the basename of @var{from} will be used as the
-file name. If @var{from} is a spool directory filename, it must be a
-data file created for or by an execution, and must begin with @file{D.}.
-
-@item to
-The name to give the file on the slave. If this field names a directory
-the file is placed within that directory with the basename of
-@var{from}. A name ending in @samp{/} is taken to be a directory even
-if one does not already exist with that name. If @var{to} begins with
-@file{X.}, an execution file will be created on the slave. Otherwise,
-if @var{to} begins with @file{D.} it names a data file to be used by
-some execution file. Otherwise, @var{to} should not be in the spool
-directory.
-
-@item user
-The name of the user who requested the transfer.
-
-@item options
-A list of options to control the transfer. The following
-options are defined (all options are single characters):
-@table @samp
-@item C
-The file has been copied to the spool directory
-(the master should use @var{temp} rather than @var{from}).
-@item c
-The file has not been copied to the spool directory (this is the
-default).
-@item d
-The slave should create directories as necessary (this is the default).
-@item f
-The slave should not create directories if necessary, but should fail
-the transfer instead.
-@item m
-The master should send mail to @var{user} when the transfer is complete.
-@item n
-The slave should send mail to @var{notify} when the transfer is
-complete.
-@end table
-
-@item temp
-If the @samp{C} option appears in @var{options}, this names the file to
-be sent. Otherwise if @var{from} is in the spool directory, @var{temp}
-is the same as @var{from}. Otherwise @var{temp} may be a dummy string,
-such as @file{D.0}. After the transfer has been succesfully completed,
-the master will delete the file @var{temp}.
-
-@item mode
-This is an octal number giving the mode of the file on the master. If
-the file is not in the spool directory, the slave will always create it
-with mode 0666, except that if (@var{mode} & 0111) is not zero (the file
-is executable), the slave will create the file with mode 0777. If the
-file is in the spool directory, some UUCP packages will use the
-algorithm above and some will always create the file with mode 0600.
-This field is ignored by UUPlus, since it is meaningless on DOS; UUPlus
-uses 0666 for outgoing files.
-
-@item notify
-This field may not be present, and in any case is only meaningful if the
-@samp{n} option appears in @var{options}. If the @samp{n} option
-appears, then, when the transfer is successfully completed, the slave
-will send mail to @var{notify}, which must be a legal mailing address on
-the slave. If a @var{size} field will appear but the @samp{n} option
-does not appear, @var{notify} will always be present, typically as the
-string @samp{dummy} or simply a pair of double quotes.
-
-@item size
-This field is only present when doing Taylor UUCP or SVR4 UUCP size
-negotiation. It is the size of the file in bytes. Taylor UUCP version
-1.03 sends the size as a decimal integer, while versions 1.04 and up,
-and all other UUCP packages that support size negotiation, send the size
-in base 16 with a leading 0x.
-@end table
-
-The slave then responds with an @samp{S} command response.
-
-@table @samp
-@item SY @var{start}
-The slave is willing to accept the file, and file transfer begins. The
-@var{start} field will only be present when using file restart. It
-specifies the byte offset into the file at which to start sending. If
-this is a new file, @var{start} will be 0x0.
-
-@item SN2
-The slave denies permission to transfer the file. This can mean that
-the destination directory may not be accessed, or that no requests are
-permitted. It implies that the file transfer will never succeed.
-
-@item SN4
-The slave is unable to create the necessary temporary file. This
-implies that the file transfer might succeed later.
-
-@item SN6
-This is only used by Taylor UUCP size negotiation. It means that the
-slave considers the file too large to transfer at the moment, but it may
-be possible to transfer it at some other time.
-
-@item SN7
-This is only used by Taylor UUCP size negotiation. It means that the
-slave considers the file too large to ever transfer.
-
-@item SN8
-This is only used by Taylor UUCP. It means that the file was already
-received in a previous conversation. This can happen if the receive
-acknowledgement was lost after it was sent by the receiver but before it
-was received by the sender.
-
-@item SN9
-This is only used by Taylor UUCP (versions 1.05 and up) and UUPlus
-(versions 2.0 and up). It means that the remote system was unable to
-open another channel (see the discussion of the @samp{i} protocol for
-more information about channels). This implies that the file transfer
-might succeed later.
-
-@item SN10
-This is reportedly used by SVR4 UUCP to mean that the file size is too
-large.
-@end table
-
-If the slave responds with @samp{SY}, a file transfer begins. When the
-file transfer is complete, the slave sends a @samp{C} command response.
-
-@table @samp
-@item CY
-The file transfer was successful.
-@item CYM
-The file transfer was successful, and the slave wishes to become the
-master; the master should send an @samp{H} command, described below.
-@item CN5
-The temporary file could not be moved into the final location. This
-implies that the file transfer will never succeed.
-@end table
-@end table
-
-After the @samp{C} command response has been received (in the @samp{SY}
-case) or immediately (in an @samp{SN} case) the master will send another
-command.
-
-@node The R Command, The X Command, The S Command, UUCP Protocol Commands
-@subsubsection The R Command
-@cindex R UUCP protocol command
-@cindex UUCP protocol R command
-
-@table @asis
-@item master: @samp{R @var{from} @var{to} @var{user} -@var{options} @var{size}}
-The @samp{R} and the @samp{-} are literal characters. This is a request
-by the master to receive a file from the slave. I do not know how SVR4
-UUCP or QFT implement file transfer restart in this case.
-
-@table @var
-@item from
-This is the name of the file on the slave which the master wishes to
-receive. It must not be in the spool directory, and it may not contain
-any wildcards.
-
-@item to
-This is the name of the file to create on the master. I do not believe
-that it can be a directory. It may only be in the spool directory if
-this file is being requested to support an execution either on the
-master or on some system other than the slave.
-
-@item user
-The name of the user who requested the transfer.
-
-@item options
-A list of options to control the transfer. The following
-options are defined (all options are single characters):
-@table @samp
-@item d
-The master should create directories as necessary (this is the default).
-@item f
-The master should not create directories if necessary, but should fail
-the transfer instead.
-@item m
-The master should send mail to @var{user} when the transfer is complete.
-@end table
-
-@item size
-This only appears if Taylor UUCP size negotiation is being used. It
-specifies the largest file which the master is prepared to accept (when
-using SVR4 UUCP or QFT, this was specified in the @samp{-U} option
-during the initial handshake).
-@end table
-
-The slave then responds with an @samp{R} command response. UUPlus does
-not support @samp{R} requests, and always responds with @samp{RN2}.
-
-@table @samp
-@item RY @var{mode} [@var{size}]
-The slave is willing to send the file, and file transfer begins. The
-@var{mode} argument is the octal mode of the file on the slave. The
-master treats this just as the slave does the @var{mode} argument in the
-send command, q.v. I am told that SVR4 UUCP sends a trailing @var{size}
-argument. For some versions of BSD UUCP, the @var{mode} argument may
-have a trailing @samp{M} character (e.g., @samp{RY 0666M}). This means
-that the slave wishes to become the master.
-
-@item RN2
-The slave is not willing to send the file, either because it is not
-permitted or because the file does not exist. This implies that the
-file request will never succeed.
-
-@item RN6
-This is only used by Taylor UUCP size negotiation. It means that the
-file is too large to send, either because of the size limit specifies by
-the master or because the slave considers it too large. The file
-transfer might succeed later, or it might not (this may be cleared up in
-a later release of Taylor UUCP).
-
-@item RN9
-This is only used by Taylor UUCP (versions 1.05 and up) and FSUUCP
-(versions 1.5 and up). It means that the remote system was unable to
-open another channel (see the discussion of the @samp{i} protocol for
-more information about channels). This implies that the file transfer
-might succeed later.
-@end table
-
-If the slave responds with @samp{RY}, a file transfer begins. When the
-file transfer is complete, the master sends a @samp{C} command. The
-slave pretty much ignores this, although it may log it.
-
-@table @samp
-@item CY
-The file transfer was successful.
-@item CN5
-The temporary file could not be moved into the final location.
-@end table
-
-After the @samp{C} command response has been sent (in the @samp{RY}
-case) or immediately (in an @samp{RN} case) the master will send another
-command.
-@end table
-
-@node The X Command, The E Command, The R Command, UUCP Protocol Commands
-@subsubsection The X Command
-@cindex X UUCP protocol command
-@cindex UUCP protocol X command
-
-@table @asis
-@item master: @samp{X @var{from} @var{to} @var{user} -@var{options}}
-The @samp{X} and the @samp{-} are literal characters. This is a request
-by the master to, in essence, execute uucp on the slave. The slave
-should execute @samp{uucp @var{from} @var{to}}.
-
-@table @var
-@item from
-This is the name of the file or files on the slave which the master
-wishes to transfer. Any wildcards are expanded on the slave. If the
-master is requesting that the files be transferred to itself, the
-request would normally contain wildcard characters, since otherwise an
-@samp{R} command would suffice. The master can also use this command to
-request that the slave transfer files to a third system.
-
-@item to
-This is the name of the file or directory to which the files should be
-transferred. This will normally use a UUCP name. For example, if the
-master wishes to receive the files itself, it would use
-@samp{master!path}.
-
-@item user
-The name of the user who requested the transfer.
-
-@item options
-A list of options to control the transfer. It is not clear which, if
-any, options are supported by most UUCP packages.
-@end table
-
-The slave then responds with an @samp{X} command response. FSUUCP does
-not support @samp{X} requests, and always responds with @samp{XN}.
-
-@table @samp
-@item XY
-The request was accepted, and the appropriate file transfer commands
-have been queued up for later processing.
-
-@item XN
-The request was denied. No particular reason is given.
-@end table
-
-In either case, the master will then send another command.
-@end table
-
-@node The E Command, The H Command, The X Command, UUCP Protocol Commands
-@subsubsection The E Command
-@cindex E UUCP protocol command
-@cindex UUCP protocol E command
-
-@table @asis
-@item master: @samp{E @var{from} @var{to} @var{user} -@var{options} @var{temp} @var{mode} @var{notify} @var{size} @var{command}}
-The @samp{E} command is only supported by Taylor UUCP 1.04 and up. It
-is used to make an execution request without requiring a separate
-@file{X.*} file.
-@ifclear faq
-@xref{Execution File Format}.
-@end ifclear
-It is only used when the command to be executed requires a single input
-file which is passed to it as standard input.
-
-All the fields have the same meaning as they do for an @samp{S} command,
-except for @var{options} and @var{command}.
-
-@table @var
-@item options
-A list of options to control the transfer. The following options are
-defined (all options are single characters):
-@table @samp
-@item C
-The file has been copied to the spool directory (the master should use
-@var{temp} rather than @var{from}).
-@item c
-The file has not been copied to the spool directory (this is the
-default).
-@item N
-No mail message should be sent, even if the command fails. This is the
-equivalent of the @samp{N} command in an @file{X.*} file.
-@item Z
-A mail message should be sent if the command fails (this is generally
-the default in any case). This is the equivalent of the @samp{Z}
-command in an @file{X.*} file.
-@item R
-Mail messages about the execution should be sent to the address in the
-@var{notify} field. This is the equivalent of the @samp{R} command in
-an @file{X.*} file.
-@item e
-The execution should be done with @file{/bin/sh}. This is the
-equivalent of the @samp{e} command in an @file{X.*} file.
-@end table
-
-@item command
-The command which should be executed. This is the equivalent of the
-@samp{C} command in an @file{X.*} file.
-@end table
-
-The slave then responds with an @samp{E} command response. These are
-the same as the @samp{S} command responses, but the initial character is
-@samp{E} rather than @samp{S}.
-
-If the slave responds with @samp{EY}, the file transfer begins. When
-the file transfer is complete, the slave sends a @samp{C} command
-response, just as for the @samp{S} command. After a successful file
-transfer, the slave is responsible for arranging for the command to be
-executed. The transferred file is passed as standard input, as though
-it were named in the @samp{I} and @samp{F} commands of an @file{X.*}
-file.
-
-After the @samp{C} command response has been received (in the @samp{EY}
-case) or immediately (in an @samp{EN} case) the master will send another
-command.
-@end table
-
-@node The H Command, , The E Command, UUCP Protocol Commands
-@subsubsection The H Command
-@cindex H UUCP protocol command
-@cindex UUCP protocol H command
-
-@table @asis
-@item master: @samp{H}
-This is used by the master to hang up the connection. The slave will
-respond with an @samp{H} command response.
-
-@table @samp
-@item HY
-The slave agrees to hang up the connection. In this case the master
-sends another @samp{HY} command. In some UUCP packages the slave will
-then send a third @samp{HY} command. At this point the protocol is shut
-down, and the final handshake is begun.
-@item HN
-The slave does not agree to hang up. In this case the master and the
-slave exchange roles. The next command will be sent by the former
-slave, which is the new master. The roles may be reversed several times
-during a single connection.
-@end table
-@end table
-
-@node The Final Handshake, , UUCP Protocol Commands, UUCP Protocol
-@subsection The Final Handshake
-@cindex final handshake
-
-After the protocol has been shut down, the final handshake is performed.
-This handshake has no real purpose, and some UUCP packages simply drop
-the connection rather than do it (in fact, some will drop the connection
-immediately after both sides agree to hangup, without even closing down
-the protocol).
-
-@table @asis
-@item caller: @samp{\020OOOOOO\000}
-
-@item called: @samp{\020OOOOOOO\000}
-@end table
-
-That is, the calling UUCP sends six @samp{O} characters and the called
-UUCP replies with seven @samp{O} characters. Some UUCP packages always
-send six @samp{O} characters.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{g} Protocol
-Subject: UUCP @samp{g} Protocol
-@end format
-@end ifset
-
-@node g Protocol, f Protocol, UUCP Protocol, Protocols
-@section UUCP @samp{g} Protocol
-@cindex @samp{g} protocol
-@cindex protocol @samp{g}
-
-The @samp{g} protocol is a packet based flow controlled error correcting
-protocol that requires an eight bit clear connection. It is the
-original UUCP protocol, and is supported by all UUCP implementations.
-Many implementations of it are only able to support small window and
-packet sizes, specifically a window size of 3 and a packet size of 64
-bytes, but the protocol itself can support up to a window size of 7 and
-a packet size of 4096 bytes. Complaints about the inefficiency of the
-@samp{g} protocol generally refer to specific implementations, rather
-than to the correctly implemented protocol.
-
-The @samp{g} protocol was originally designed for general packet
-drivers, and thus contains some features that are not used by UUCP,
-including an alternate data channel and the ability to renegotiate
-packet and window sizes during the communication session.
-
-The @samp{g} protocol is spoofed by many Telebit modems. When spoofing
-is in effect, each Telebit modem uses the @samp{g} protocol to
-communicate with the attached computer, but the data between the modems
-is sent using a Telebit proprietary error correcting protocol. This
-allows for very high throughput over the Telebit connection, which,
-because it is half-duplex, would not normally be able to handle the
-@samp{g} protocol very well at all. When a Telebit is spoofing the
-@samp{g} protocol, it forces the packet size to be 64 bytes and the
-window size to be 3.
-
-This discussion of the @samp{g} protocol explains how it works, but does
-not discuss useful error handling techniques. Some discussion of this
-can be found in Jamie E. Hanrahan's paper, cited
-@ifclear faq
-above (@pxref{UUCP Protocol Sources}).
-@end ifclear
-@ifset faq
-above.
-@end ifset
-
-All @samp{g} protocol communication is done with packets. Each packet
-begins with a six byte header. Control packets consist only of the
-header. Data packets contain additional data.
-
-The header is as follows:
-
-@table @asis
-@item @samp{\020}
-Every packet begins with a @kbd{^P}.
-
-@item @var{k} (1 <= @var{k} <= 9)
-The @var{k} value is always 9 for a control packet. For a data packet,
-the @var{k} value indicates how much data follows the six byte header.
-The amount of data is
-@ifinfo
-2 ** (@var{k} + 4), where ** indicates exponentiation.
-@end ifinfo
-@iftex
-@tex
-$2^{k + 4}$.
-@end tex
-@end iftex
-Thus a @var{k} value of 1 means 32 data bytes and a
-@var{k} value of 8 means 4096 data bytes. The @var{k} value for a data
-packet must be between 1 and 8 inclusive.
-
-@item checksum low byte
-@itemx checksum high byte
-The checksum value is described below.
-
-@item control byte
-The control byte indicates the type of packet, and is described below.
-
-@item xor byte
-This byte is the xor of @var{k}, the checksum low byte, the checksum
-high byte and the control byte (i.e., the second, third, fourth and
-fifth header bytes). It is used to ensure that the header data is
-valid.
-@end table
-
-The control byte in the header is composed of three bit fields, referred
-to here as @var{tt} (two bits), @var{xxx} (three bits) and @var{yyy}
-(three bits). The control is @var{tt}@var{xxx}@var{yyy}, or @code{(@var{tt}
-<< 6) + (@var{xxx} << 3) + @var{yyy}}.
-
-The @var{TT} field takes on the following values:
-
-@table @samp
-@item 0
-This is a control packet. In this case the @var{k} byte in the
-header must be 9. The @var{xxx} field indicates the type of control
-packet; these types are described below.
-
-@item 1
-This is an alternate data channel packet. This is not used by UUCP.
-
-@item 2
-This is a data packet, and the entire contents of the attached data
-field (whose length is given by the @var{k} byte in the header) are
-valid. The @var{xxx} and @var{yyy} fields are described below.
-
-@item 3
-This is a short data packet. Let the length of the data field (as given
-by the @var{k} byte in the header) be @var{l}. Let the first byte in
-the data field be @var{b1}. If @var{b1} is less than 128 (if the most
-significant bit of @var{b1} is 0), then there are @code{@var{l} -
-@var{b1}} valid bytes of data in the data field, beginning with the
-second byte. If @code{@var{b1} >= 128}, let @var{b2} be the second byte
-in the data field. Then there are @code{@var{l} - ((@var{b1} & 0x7f) +
-(@var{b2} << 7))} valid bytes of data in the data field, beginning with
-the third byte. In all cases @var{l} bytes of data are sent (and all
-data bytes participate in the checksum calculation) but some of the
-trailing bytes may be dropped by the receiver. The @var{xxx} and
-@var{yyy} fields are described below.
-@end table
-
-In a data packet (short or not) the @var{xxx} field gives the sequence
-number of the packet. Thus sequence numbers can range from 0 to 7,
-inclusive. The @var{yyy} field gives the sequence number of the last
-correctly received packet.
-
-Each communication direction uses a window which indicates how many
-unacknowledged packets may be transmitted before waiting for an
-acknowledgement. The window may range from 1 to 7, and may be different
-in each direction. For example, if the window is 3 and the last packet
-acknowledged was packet number 6, packet numbers 7, 0 and 1 may be sent
-but the sender must wait for an acknowledgement before sending packet
-number 2. This acknowledgement could come as the @var{yyy} field of a
-data packet, or as the @var{yyy} field of a @samp{RJ} or @samp{RR}
-control packet (described below).
-
-Each packet must be transmitted in order (the sender may not skip
-sequence numbers). Each packet must be acknowledged, and each packet
-must be acknowledged in order.
-
-In a control packet, the @var{xxx} field takes on the following values:
-
-@table @asis
-@item 1 @samp{CLOSE}
-The connection should be closed immediately. This is typically sent
-when one side has seen too many errors and wants to give up. It is also
-sent when shutting down the protocol. If an unexpected @samp{CLOSE}
-packet is received, a @samp{CLOSE} packet should be sent in reply and
-the @samp{g} protocol should halt, causing UUCP to enter the final
-handshake.
-
-@item 2 @samp{RJ} or @samp{NAK}
-The last packet was not received correctly. The @var{yyy} field
-contains the sequence number of the last correctly received packet.
-
-@item 3 @samp{SRJ}
-Selective reject. The @var{yyy} field contains the sequence number of a
-packet that was not received correctly, and should be retransmitted.
-This is not used by UUCP, and most implementations will not recognize
-it.
-
-@item 4 @samp{RR} or @samp{ACK}
-Packet acknowledgement. The @var{yyy} field contains the sequence
-number of the last correctly received packet.
-
-@item 5 @samp{INITC}
-Third initialization packet. The @var{yyy} field contains the maximum
-window size to use.
-
-@item 6 @samp{INITB}
-Second initialization packet. The @var{yyy} field contains the
-packet size to use. It requests a size of
-@ifinfo
-2 ** (@var{yyy} + 5).
-@end ifinfo
-@iftex
-@tex
-$2^{yyy + 5}$.
-@end tex
-@end iftex
-Note that this is not the same coding used for the @var{k} byte in the
-packet header (it is 1 less). Most UUCP implementations that request a
-packet size larger than 64 bytes can handle any packet size up to that
-specified.
-
-@item 7 @samp{INITA}
-First initialization packet. The @var{yyy} field contains the maximum
-window size to use.
-@end table
-
-To compute the checksum, call the control byte (the fifth byte in the
-header) @var{c}.
-
-The checksum of a control packet is simply @code{0xaaaa - @var{c}}.
-
-The checksum of a data packet is @code{0xaaaa - (@var{check} ^
-@var{c})}, where @code{^} denotes exclusive or, and @var{check} is the
-result of the following routine as run on the contents of the data field
-(every byte in the data field participates in the checksum, even for a
-short data packet). Below is the routine used by an early version of
-Taylor UUCP; it is a slightly modified version of a routine which John
-Gilmore patched from G.L.@: Chesson's original paper. The @code{z}
-argument points to the data and the @code{c} argument indicates how much
-data there is.
-
-@example
-int
-igchecksum (z, c)
- register const char *z;
- register int c;
-@{
- register unsigned int ichk1, ichk2;
-
- ichk1 = 0xffff;
- ichk2 = 0;
-
- do
- @{
- register unsigned int b;
-
- /* Rotate ichk1 left. */
- if ((ichk1 & 0x8000) == 0)
- ichk1 <<= 1;
- else
- @{
- ichk1 <<= 1;
- ++ichk1;
- @}
-
- /* Add the next character to ichk1. */
- b = *z++ & 0xff;
- ichk1 += b;
-
- /* Add ichk1 xor the character position in the buffer counting from
- the back to ichk2. */
- ichk2 += ichk1 ^ c;
-
- /* If the character was zero, or adding it to ichk1 caused an
- overflow, xor ichk2 to ichk1. */
- if (b == 0 || (ichk1 & 0xffff) < b)
- ichk1 ^= ichk2;
- @}
- while (--c > 0);
-
- return ichk1 & 0xffff;
-@}
-@end example
-
-When the @samp{g} protocol is started, the calling UUCP sends an
-@samp{INITA} control packet with the window size it wishes the called
-UUCP to use. The called UUCP responds with an @samp{INITA} packet with
-the window size it wishes the calling UUCP to use. Pairs of
-@samp{INITB} and @samp{INITC} packets are then similarly exchanged.
-When these exchanges are completed, the protocol is considered to have
-been started.
-
-Note that the window and packet sizes are not a negotiation. Each
-system announces the window and packet size which the other system
-should use. It is possible that different window and packet sizes will
-be used in each direction. The protocol works this way on the theory
-that each system knows how much data it can accept without getting
-overrun. Therefore, each system tells the other how much data to send
-before waiting for an acknowledgement.
-
-When a UUCP package transmits a command, it sends one or more data
-packets. All the data packets will normally be complete, although some
-UUCP packages may send the last one as a short packet. The command
-string is sent with a trailing null byte, to let the receiving package
-know when the command is finished. Some UUCP packages require the last
-byte of the last packet sent to be null, even if the command ends
-earlier in the packet. Some packages may require all the trailing bytes
-in the last packet to be null, but I have not confirmed this.
-
-When a UUCP package sends a file, it will send a sequence of data
-packets. The end of the file is signalled by a short data packet
-containing zero valid bytes (it will normally be preceeded by a short
-data packet containing the last few bytes in the file).
-
-Note that the sequence numbers cover the entire communication session,
-including both command and file data.
-
-When the protocol is shut down, each UUCP package sends a @samp{CLOSE}
-control packet.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{f} Protocol
-Subject: UUCP @samp{f} Protocol
-@end format
-@end ifset
-
-@node f Protocol, t Protocol, g Protocol, Protocols
-@section UUCP @samp{f} Protocol
-@cindex @samp{f} protocol
-@cindex protocol @samp{f}
-
-The @samp{f} protocol is a seven bit protocol which checksums an entire
-file at a time. It only uses the characters between @samp{\040} and
-@samp{\176} (ASCII @kbd{space} and @kbd{~}) inclusive, as well as the
-carriage return character. It can be very efficient for transferring
-text only data, but it is very inefficient at transferring eight bit
-data (such as compressed news). It is not flow controlled, and the
-checksum is fairly insecure over large files, so using it over a serial
-connection requires handshaking (XON/XOFF can be used) and error
-correcting modems. Some people think it should not be used even under
-those circumstances.
-
-I believe that the @samp{f} protocol originated in BSD versions of UUCP.
-It was originally intended for transmission over X.25 PAD links.
-
-The @samp{f} protocol has no startup or finish protocol. However, both
-sides typically sleep for a couple of seconds before starting up,
-because they switch the terminal into XON/XOFF mode and want to allow
-the changes to settle before beginning transmission.
-
-When a UUCP package transmits a command, it simply sends a string
-terminated by a carriage return.
-
-When a UUCP package transmits a file, each byte @var{b} of the file is
-translated according to the following table:
-
-@example
- 0 <= @var{b} <= 037: 0172, @var{b} + 0100 (0100 to 0137)
- 040 <= @var{b} <= 0171: @var{b} ( 040 to 0171)
- 0172 <= @var{b} <= 0177: 0173, @var{b} - 0100 ( 072 to 077)
- 0200 <= @var{b} <= 0237: 0174, @var{b} - 0100 (0100 to 0137)
- 0240 <= @var{b} <= 0371: 0175, @var{b} - 0200 ( 040 to 0171)
- 0372 <= @var{b} <= 0377: 0176, @var{b} - 0300 ( 072 to 077)
-@end example
-
-That is, a byte between @samp{\040} and @samp{\171} inclusive is
-transmitted as is, and all other bytes are prefixed and modified as
-shown.
-
-When all the file data is sent, a seven byte sequence is sent: two bytes
-of @samp{\176} followed by four ASCII bytes of the checksum as printed
-in base 16 followed by a carriage return. For example, if the checksum
-was 0x1234, this would be sent: @samp{\176\1761234\r}.
-
-The checksum is initialized to 0xffff. For each byte that is sent it is
-modified as follows (where @var{b} is the byte before it has been
-transformed as described above):
-
-@example
- /* Rotate the checksum left. */
- if ((ichk & 0x8000) == 0)
- ichk <<= 1;
- else
- @{
- ichk <<= 1;
- ++ichk;
- @}
-
- /* Add the next byte into the checksum. */
- ichk += @var{b};
-@end example
-
-When the receiving UUCP sees the checksum, it compares it against its
-own calculated checksum and replies with a single character followed
-by a carriage return.
-
-@table @samp
-@item G
-The file was received correctly.
-
-@item R
-The checksum did not match, and the file should be resent from the
-beginning.
-
-@item Q
-The checksum did not match, but too many retries have occurred and the
-communication session should be abandoned.
-@end table
-
-The sending UUCP checks the returned character and acts accordingly.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{t} Protocol
-Subject: UUCP @samp{t} Protocol
-@end format
-@end ifset
-
-@node t Protocol, e Protocol, f Protocol, Protocols
-@section UUCP @samp{t} Protocol
-@cindex @samp{t} protocol
-@cindex protocol @samp{t}
-
-The @samp{t} protocol is intended for use on links which provide
-reliable end-to-end connections, such as TCP. It does no error checking
-or flow control, and requires an eight bit clear channel.
-
-I believe the @samp{t} protocol originated in BSD versions of UUCP.
-
-When a UUCP package transmits a command, it first gets the length of the
-command string, @var{c}. It then sends @code{((@var{c} / 512) + 1) *
-512} bytes (the smallest multiple of 512 which can hold @var{c} bytes
-plus a null byte) consisting of the command string itself followed by
-trailing null bytes.
-
-When a UUCP package sends a file, it sends it in blocks. Each block
-contains at most 1024 bytes of data. Each block consists of four bytes
-containing the amount of data in binary (most significant byte first,
-the same format as used by the Unix function @code{htonl}) followed by
-that amount of data. The end of the file is signalled by a block
-containing zero bytes of data.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{e} Protocol
-Subject: UUCP @samp{e} Protocol
-@end format
-@end ifset
-
-@node e Protocol, Big G Protocol, t Protocol, Protocols
-@section UUCP @samp{e} Protocol
-@cindex @samp{e} protocol
-@cindex protocol @samp{e}
-
-The @samp{e} protocol is similar to the @samp{t} protocol. It does no
-flow control or error checking and is intended for use over networks
-providing reliable end-to-end connections, such as TCP.
-
-The @samp{e} protocol originated in versions of HDB UUCP.
-
-When a UUCP package transmits a command, it simply sends the command
-as an ASCII string terminated by a null byte.
-
-When a UUCP package transmits a file, it sends the complete size of the
-file as an ASCII decimal number. The ASCII string is padded out to 20
-bytes with null bytes (i.e. if the file is 1000 bytes long, it sends
-@samp{1000\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0}). It then sends the entire
-file.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{G} Protocol
-Subject: UUCP @samp{G} Protocol
-@end format
-@end ifset
-
-@node Big G Protocol, i Protocol, e Protocol, Protocols
-@section UUCP @samp{G} Protocol
-@cindex @samp{G} protocol
-@cindex protocol @samp{G}
-
-The @samp{G} protocol is used by SVR4 UUCP. It is identical to the
-@samp{g} protocol, except that it is possible to modify the window and
-packet sizes. The SVR4 implementation of the @samp{g} protocol
-reportedly is fixed at a packet size of 64 and a window size of 7.
-Supposedly SVR4 chose to implement a new protocol using a new letter to
-avoid any potential incompatibilities when using different packet or
-window sizes.
-
-Most implementations of the @samp{g} protocol that accept packets larger
-than 64 bytes will also accept packets smaller than whatever they
-requested in the @samp{INITB} packet. The SVR4 @samp{G} implementation
-is an exception; it will only accept packets of precisely the size it
-requests in the INITB packet.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{i} Protocol
-Subject: UUCP @samp{i} Protocol
-@end format
-@end ifset
-
-@node i Protocol, j Protocol, Big G Protocol, Protocols
-@section UUCP @samp{i} Protocol
-@cindex @samp{i} protocol
-@cindex protocol @samp{i}
-
-The @samp{i} protocol was written by Ian Lance Taylor (who also wrote
-this
-@ifclear faq
-manual).
-@end ifclear
-@ifset faq
-FAQ).
-@end ifset
-It was first used by Taylor UUCP version 1.04.
-
-It is a sliding window packet protocol, like the @samp{g} protocol, but
-it supports bidirectional transfers (i.e., file transfers in both
-directions simultaneously). It requires an eight bit clear connection.
-Several ideas for the protocol were taken from the paper @cite{A
-High-Throughput Message Transport System} by P.@: Lauder. I don't know
-where the paper was published, but the author's e-mail address is
-@code{piers@@cs.su.oz.au}. The @samp{i} protocol does not adopt his
-main idea, which is to dispense with windows entirely. This is because
-some links still do require flow control and, more importantly, because
-using windows sets a limit to the amount of data which the protocol must
-be able to resend upon request. To reduce the costs of window
-acknowledgements, the protocol uses a large window and only requires an
-ack at the halfway point.
-
-Each packet starts with a six byte header, optionally followed by data
-bytes with a four byte checksum. There are currently five defined
-packet types (@samp{DATA}, @samp{SYNC}, @samp{ACK}, @samp{NAK},
-@samp{SPOS}, @samp{CLOSE}) which are described below. Although any
-packet type may include data, any data provided with an @samp{ACK},
-@samp{NAK} or @samp{CLOSE} packet is ignored.
-
-Every @samp{DATA}, @samp{SPOS} and @samp{CLOSE} packet has a sequence
-number. The sequence numbers are independent for each side. The first
-packet sent by each side is always number 1. Each packet is numbered
-one greater than the previous packet, modulo 32.
-
-Every packet has a local channel number and a remote channel number.
-For all packets at least one channel number is zero. When a UUCP
-command is sent to the remote system, it is assigned a non-zero local
-channel number. All packets associated with that UUCP command sent by
-the local system are given the selected local channel number. All
-associated packets sent by the remote system are given the selected
-number as the remote channel number. This permits each UUCP command
-to be uniquely identified by the channel number on the originating
-system, and therefore each UUCP package can associate all file data
-and UUCP command responses with the appropriate command. This is a
-requirement for bidirectional UUCP transfers.
-
-The protocol maintains a single global file position, which starts at 0.
-For each incoming packet, any associated data is considered to occur at
-the current file position, and the file position is incremented by the
-amount of data contained. The exception is a packet of type
-@samp{SPOS}, which is used to change the file position. The reason for
-keeping track of the file position is described below.
-
-The header is as follows:
-
-@table @asis
-@item @samp{\007}
-Every packet begins with @kbd{^G}.
-
-@item @code{(@var{packet} << 3) + @var{locchan}}
-The five bit packet number combined with the three bit local channel
-number. @samp{DATA}, @samp{SPOS} and @samp{CLOSE} packets use the
-packet sequence number for the @var{packet} field. @samp{NAK} packet
-types use the @var{packet} field for the sequence number to be resent.
-@samp{ACK} and @samp{SYNC} do not use the @var{packet} field, and
-generally leave it set to 0. Packets which are not associated with a
-UUCP command from the local system use a local channel number of 0.
-
-@item @code{(@var{ack} << 3) + @var{remchan}}
-The five bit packet acknowledgement combined with the three bit remote
-channel number. The packet acknowledgement is the number of the last
-packet successfully received; it is used by all packet types. Packets
-which are not sent in response to a UUCP command from the remote system
-use a remote channel number of 0.
-
-@item @code{(@var{type} << 5) + (@var{caller} << 4) + @var{len1}}
-The three bit packet type combined with the one bit packet direction
-combined with the upper four bits of the data length. The packet
-direction bit is always 1 for packets sent by the calling UUCP, and 0
-for packets sent by the called UUCP. This prevents confusion caused by
-echoed packets.
-
-@item @var{len2}
-The lower eight bits of the data length. The twelve bits of data length
-permit packets ranging in size from 0 to 4095 bytes.
-
-@item @var{check}
-The exclusive or of the second through fifth bytes of the header. This
-provides an additional check that the header is valid.
-@end table
-
-If the data length is non-zero, the packet is immediately followed by
-the specified number of data bytes. The data bytes are followed by a
-four byte CRC 32 checksum, with the most significant byte first. The
-CRC is calculated over the contents of the data field.
-
-The defined packet types are as follows:
-
-@table @asis
-@item 0 @samp{DATA}
-This is a plain data packet.
-
-@item 1 @samp{SYNC}
-@samp{SYNC} packets are exchanged when the protocol is initialized, and
-are described further below. @samp{SYNC} packets do not carry sequence
-numbers (that is, the @var{packet} field is ignored).
-
-@item 2 @samp{ACK}
-This is an acknowledgement packet. Since @samp{DATA} packets also carry
-packet acknowledgements, @samp{ACK} packets are only used when one side
-has no data to send. @samp{ACK} packets do not carry sequence numbers.
-
-@item 3 @samp{NAK}
-This is a negative acknowledgement. This is sent when a packet is
-received incorrectly, and means that the packet number appearing in the
-@var{packet} field must be resent. @samp{NAK} packets do not carry
-sequence numbers (the @var{packet} field is already used).
-
-@item 4 @samp{SPOS}
-This packet changes the file position. The packet contains four bytes
-of data holding the file position, most significant byte first. The
-next packet received will be considered to be at the named file
-position.
-
-@item 5 @samp{CLOSE}
-When the protocol is shut down, each side sends a @samp{CLOSE} packet.
-This packet does have a sequence number, which could be used to ensure
-that all packets were correctly received (this is not needed by UUCP,
-however, which uses the higher level @samp{H} command with an @samp{HY}
-response).
-@end table
-
-When the protocol starts up, both systems send a @samp{SYNC} packet.
-The @samp{SYNC} packet includes at least three bytes of data. The first
-two bytes are the maximum packet size the remote system should send,
-most significant byte first. The third byte is the window size the
-remote system should use. The remote system may send packets of any
-size up to the maximum. If there is a fourth byte, it is the number of
-channels the remote system may use (this must be between 1 and 7,
-inclusive). Additional data bytes may be defined in the future.
-
-The window size is the number of packets that may be sent before a
-packet is acknowledged. There is no requirement that every packet be
-acknowledged; any acknowledgement is considered to acknowledge all
-packets through the number given. In the current implementation, if one
-side has no data to send, it sends an @samp{ACK} when half the window is
-received.
-
-Note that the @samp{NAK} packet corresponds to the unused @samp{g}
-protocol @samp{SRJ} packet type, rather than to the @samp{RJ} packet
-type. When a @samp{NAK} is received, only the named packet should be
-resent, not any subsequent packets.
-
-Note that if both sides have data to send, but a packet is lost, it is
-perfectly reasonable for one side to continue sending packets, all of
-which will acknowledge the last packet correctly received, while the
-system whose packet was lost will be unable to send a new packet because
-the send window will be full. In this circumstance, neither side will
-time out and one side of the communication will be effectively shut down
-for a while. Therefore, any system with outstanding unacknowledged
-packets should arrange to time out and resend a packet even if data is
-being received.
-
-Commands are sent as a sequence of data packets with a non-zero local
-channel number. The last data packet for a command includes a trailing
-null byte (normally a command will fit in a single data packet). Files
-are sent as a sequence of data packets ending with one of length zero.
-
-The channel numbers permit a more efficient implementation of the UUCP
-file send command. Rather than send the command and then wait for the
-@samp{SY} response before sending the file, the file data is sent
-beginning immediately after the @samp{S} command is sent. If an
-@samp{SN} response is received, the file send is aborted, and a final
-data packet of length zero is sent to indicate that the channel number
-may be reused. If an @samp{SY} reponse with a file position indicator
-is received, the file send adjusts to the file position; this is why the
-protocol maintains a global file position.
-
-Note that the use of channel numbers means that each UUCP system may
-send commands and file data simultaneously. Moreover, each UUCP system
-may send multiple files at the same time, using the channel number to
-disambiguate the data. Sending a file before receiving an
-acknowledgement for the previous file helps to eliminate the round trip
-delays inherent in other UUCP protocols.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{j} Protocol
-Subject: UUCP @samp{j} Protocol
-@end format
-@end ifset
-
-@node j Protocol, x Protocol, i Protocol, Protocols
-@section UUCP @samp{j} Protocol
-@cindex @samp{j} protocol
-@cindex protocol @samp{j}
-
-The @samp{j} protocol is a variant of the @samp{i} protocol. It was
-also written by Ian Lance Taylor, and first appeared in Taylor UUCP
-version 1.04.
-
-The @samp{j} protocol is a version of the @samp{i} protocol designed for
-communication links which intercept a few characters, such as XON or
-XOFF. It is not efficient to use it on a link which intercepts many
-characters, such as a seven bit link. The @samp{j} protocol performs no
-error correction or detection; that is presumed to be the responsibility
-of the @samp{i} protocol.
-
-When the @samp{j} protocol starts up, each system sends a printable
-ASCII string indicating which characters it wants to avoid using. The
-string begins with the ASCII character @kbd{^} (octal 136) and ends with
-the ASCII character @kbd{~} (octal 176). After sending this string,
-each system looks for the corresponding string from the remote system.
-The strings are composed of escape sequences: @samp{\ooo}, where
-@samp{o} is an octal digit. For example, sending the string
-@samp{^\021\023~} means that the ASCII XON and XOFF characters should be
-avoided. The union of the characters described in both strings (the
-string which is sent and the string which is received) is the set of
-characters which must be avoided in this conversation. Avoiding a
-printable ASCII character (octal 040 to octal 176, inclusive) is not
-permitted.
-
-After the exchange of characters to avoid, the normal @samp{i} protocol
-start up is done, and the rest of the conversation uses the normal
-@samp{i} protocol. However, each @samp{i} protocol packet is wrapped to
-become a @samp{j} protocol packet.
-
-Each @samp{j} protocol packet consists of a seven byte header, followed
-by data bytes, followed by index bytes, followed by a one byte trailer.
-The packet header looks like this:
-
-@table @asis
-@item @kbd{^}
-Every packet begins with the ASCII character @kbd{^}, octal 136.
-
-@item @var{high}
-@itemx @var{low}
-These two characters give the total number of bytes in the packet. Both
-@var{high} and @var{low} are printable ASCII characters. The length of
-the packet is @code{(@var{high} - 040) * 0100 + (@var{low} - 040)},
-where @code{040 <= @var{high} < 0177} and @code{040 <= @var{low} <
-0140}. This permits a length of 6079 bytes, but there is a further
-restriction on packet size described below.
-
-@item @kbd{=}
-The ASCII character @kbd{=}, octal 075.
-
-@item @var{data-high}
-@itemx @var{data-low}
-These two characters give the total number of data bytes in the packet.
-The encoding is as described for @var{high} and @var{low}. The number
-of data bytes is the size of the @samp{i} protocol packet wrapped inside
-this @samp{j} protocol packet.
-
-@item @kbd{@@}
-The ASCII character @kbd{@@}, octal 100.
-@end table
-
-The header is followed by the number of data bytes given in
-@var{data-high} and @var{data-low}. These data bytes are the @samp{i}
-protocol packet which is being wrapped in the @samp{j} protocol packet.
-However, each character in the @samp{i} protocol packet which the
-@samp{j} protocol must avoid is transformed into a printable ASCII
-character (recall that avoiding a printable ASCII character is not
-permitted). Two index bytes are used for each character which must be
-transformed.
-
-The index bytes immediately follow the data bytes. The index bytes are
-created in pairs. Each pair of index bytes encodes the location of a
-character in the @samp{i} protocol packet which was transformed to
-become a printable ASCII character. Each pair of index bytes also
-encodes the precise transformation which was performed.
-
-When the sender finds a character which must be avoided, it will
-transform it using one or two operations. If the character is 0200 or
-greater, it will subtract 0200. If the resulting character is less than
-020, or is equal to 0177, it will xor by 020. The result is a printable
-ASCII character.
-
-The zero based byte index of the character within the @samp{i} protocol
-packet is determined. This index is turned into a two byte printable
-ASCII index, @var{index-high} and @var{index-low}, such that the index
-is @code{(@var{index-high} - 040) * 040 + (@var{index-low} - 040)}.
-@var{index-low} is restricted such that @code{040 <= @var{index-low} <
-0100}. @var{index-high} is not permitted to be 0176, so @code{040 <=
-@var{index-high} < 0176}. @var{index-low} is then modified to encode
-the transformation:
-
-@itemize @bullet
-@item If the character transformation only had to subtract 0200, then
-@var{index-low} is used as is.
-
-@item If the character transformation only had to xor by 020, then 040
-is added to @var{index-low}.
-
-@item If both operations had to be performed, then 0100 is added to
-@var{index-low}. However, if the value of @var{index-low} was initially
-077, then adding 0100 would result in 0177, which is not a printable
-ASCII character. For that special case, @var{index-high} is set to
-0176, and @var{index-low} is set to the original value of
-@var{index-high}.
-@end itemize
-
-The receiver decodes the index bytes as follows (this is the reverse of
-the operations performed by the sender, presented here for additional
-clarity):
-
-@itemize @bullet
-@item The first byte in the index is @var{index-high}, and the second is
-@var{index-low}.
-
-@item If @code{040 <= @var{index-high} < 0176}, the index refers to the
-data byte at position @code{(@var{index-high} - 040) * 040 +
-@var{index-low} % 040}.
-
-@item If @code{040 <= @var{index-low} < 0100}, then 0200 must be added
-to indexed byte.
-
-@item If @code{0100 <= @var{index-low} < 0140}, then 020 must be xor'ed
-to the indexed byte.
-
-@item If @code{0140 <= @var{index-low} < 0177}, then 0200 must be added
-to the indexed byte, and 020 must be xor'ed to the indexed byte.
-
-@item If @code{@var{index-high} == 0176}, the index refers to the data
-byte at position @code{(@var{index-low} - 040) * 040 + 037}. 0200 must
-be added to the indexed byte, and 020 must be xor'ed to the indexed
-byte.
-@end itemize
-
-This means the largest @samp{i} protocol packet which may be wrapped
-inside a @samp{j} protocol packet is @code{(0175 - 040) * 040 + (077 -
-040) == 3007} bytes.
-
-The final character in a @samp{j} protocol packet, following the index
-bytes, is the ASCII character @kbd{~} (octal 176).
-
-The motivation behind using an indexing scheme, rather than escape
-characters, is to avoid data movement. The sender may simply add a
-header and a trailer to the @samp{i} protocol packet. Once the receiver
-has loaded the @samp{j} protocol packet, it may scan the index bytes,
-transforming the data bytes, and then pass the data bytes directly on to
-the @samp{i} protocol routine.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{x} Protocol
-Subject: UUCP @samp{x} Protocol
-@end format
-@end ifset
-
-@node x Protocol, y Protocol, j Protocol, Protocols
-@section UUCP @samp{x} Protocol
-@cindex @samp{x} protocol
-@cindex protocol @samp{x}
-
-The @samp{x} protocol is used in Europe (and probably elsewhere) with
-machines that contain an builtin X.25 card and can send eight bit data
-transparently across X.25 circuits, without interference from the X.28
-or X.29 layers. The protocol sends packets of 512 bytes, and relies on
-a write of zero bytes being read as zero bytes without stopping
-communication. It first appeared in the original System V UUCP
-implementation.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{y} Protocol
-Subject: UUCP @samp{y} Protocol
-@end format
-@end ifset
-
-@node y Protocol, d Protocol, x Protocol, Protocols
-@section UUCP @samp{y} Protocol
-@cindex @samp{y} protocol
-@cindex protocol @samp{y}
-
-The @samp{y} protocol was developed by Jorge Cwik for use in FX UUCICO,
-a PC uucico program. It is designed for communication lines which
-handle error correction and flow control. It requires an eight bit
-clean connection. It performs error detection, but not error
-correction: when an error is detected, the line is dropped. It is a
-streaming protocol, like the @samp{f} protocol; there are no packet
-acknowledgements, so the protocol is efficient over a half-duplex
-communication line such as PEP.
-
-Every packet contains a six byte header:
-
-@table @asis
-@item sequence low byte
-@itemx sequence high byte
-A two byte sequence number, in little endian order. The first sequence
-number is 0. Since the first packet is always a sync packet (described
-below) the sequence number of the first data packet is always 1. Each
-system counts sequence numbers independently.
-
-@item length low byte
-@itemx length high byte
-A two byte data length, in little endian order. If the high bit of the
-sixteen bit field is clear, this is the number of data bytes which
-follow the six byte header. If the high bit is set, there is no data,
-and the length field is a type of control packet.
-
-@item checksum low byte
-@itemx checksum high byte
-A two byte checksum, in little endian order. The checksum is computed
-over the data bytes. The checksum algorithm is described below. If
-there are no data bytes, the checksum is sent as 0.
-@end table
-
-When the protocol starts up, each side must send a sync packet. This is
-a packet with a normal six byte header followed by data. The sequence
-number of the sync packet should be 0. Currently at least four bytes of
-data must be sent with the sync packet. Additional bytes should be
-ignored. They are defined as follows:
-
-@table @asis
-@item version
-The version number of the protocol. Currently this must be 1. Larger
-numbers should be ignored; it is the responsibility of the newer version
-to accommodate the older one.
-
-@item packet size
-The maximum data length to use divided by 256. This is sent as a single
-byte. The maximum data length permitted is 32768, which would be sent
-as 128. Customarily both systems will use the same maximum data length,
-the lower of the two requested.
-
-@item flags low byte
-@itemx flags high byte
-Two bytes of flags. None are currently defined. These bytes should be
-sent as 0, and ignored by the receiver.
-@end table
-
-A length field with the high bit set is a control packet. The
-following control packet types are defined:
-
-@table @asis
-@item 0xfffe @samp{YPKT_ACK}
-Acknowledges correct receipt of a file.
-
-@item 0xfffd @samp{YPKT_ERR}
-Indicates an incorrect checksum.
-
-@item 0xfffc @samp{YPKT_BAD}
-Indicates a bad sequence number, an invalid length, or some other error.
-@end table
-
-If a control packet other than @samp{YPKT_ACK} is received, the
-connection is dropped. If a checksum error is detected for a received
-packet, a @samp{YPKT_ERR} control packet is sent, and the connection is
-dropped. If a packet is received out of sequence, a @samp{YPKT_BAD}
-control packet is sent, and the connection is dropped.
-
-The checksum is initialized to 0xffff. For each data byte in a packet
-it is modified as follows (where @var{b} is the byte before it has been
-transformed as described above):
-
-@example
- /* Rotate the checksum left. */
- if ((ichk & 0x8000) == 0)
- ichk <<= 1;
- else
- @{
- ichk <<= 1;
- ++ichk;
- @}
-
- /* Add the next byte into the checksum. */
- ichk += @var{b};
-@end example
-
-This is the same algorithm as that used by the @samp{f} protocol.
-
-A command is sent as a sequence of data packets followed by a null byte.
-In the normal case, a command will fit into a single packet. The packet
-should be exactly the length of the command plus a null byte. If the
-command is too long, more packets are sent as required.
-
-A file is sent as a sequence of data packets, ending with a zero length
-packet. The data packets may be of any length greater than zero and
-less than or equal to the maximum permitted packet size specified in the
-initial sync packet.
-
-After the zero length packet ending a file transfer has been received,
-the receiving system sends a @samp{YPKT_ACK} control packet. The
-sending system waits for the @samp{YPKT_ACK} control packet before
-continuing; this wait should be done with a large timeout, since there
-may be a considerable amount of data buffered on the communication path.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{d} Protocol
-Subject: UUCP @samp{d} Protocol
-@end format
-@end ifset
-
-@node d Protocol, h Protocol, y Protocol, Protocols
-@section UUCP @samp{d} Protocol
-@cindex @samp{d} protocol
-@cindex protocol @samp{d}
-
-The @samp{d} protocol is apparently used for DataKit muxhost (not
-RS-232) connections. No file size is sent. When a file has been
-completely transferred, a write of zero bytes is done; this must be read
-as zero bytes on the other end.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{h} Protocol
-Subject: UUCP @samp{h} Protocol
-@end format
-@end ifset
-
-@node h Protocol, v Protocol, d Protocol, Protocols
-@section UUCP @samp{h} Protocol
-@cindex @samp{h} protocol
-@cindex protocol @samp{h}
-
-The @samp{h} protocol is apparently used in some places with HST modems.
-It does no error checking, and is not that different from the @samp{t}
-protocol. I don't know the details.
-
-@ifset faq
-@format
-------------------------------
-
-From: UUCP @samp{v} Protocol
-Subject: UUCP @samp{v} Protocol
-@end format
-@end ifset
-
-@node v Protocol, , h Protocol, Protocols
-@section UUCP @samp{v} Protocol
-@cindex @samp{v} protocol
-@cindex protocol @samp{v}
-
-The @samp{v} protocol is used by UUPC/extended, a PC UUCP program. It
-is simply a version of the @samp{g} protocol which supports packets of
-any size, and also supports sending packets of different sizes during
-the same conversation. There are many @samp{g} protocol implementations
-which support both, but there are also many which do not. Using
-@samp{v} ensures that everything is supported.
-
-@ifset faq
-@format
-------------------------------
-
-From: Thanks
-Subject: Thanks
-@end format
-
-Besides the papers and information acknowledged at the top of this
-article, the following people have contributed help, advice,
-suggestions and information:
-@format
- Earle Ake 513-429-6500 <ake@@Dayton.SAIC.COM>
- chris@@uuplus.com (Christopher J. Ambler)
- jhc@@iscp.bellcore.com (Jonathan Clark)
- jorge@@laser.satlink.net (Jorge Cwik)
- celit!billd@@UCSD.EDU (Bill Davidson)
- "Drew Derbyshire" <ahd@@kew.com>
- erik@@pdnfido.fidonet.org
- Matthew Farwell <dylan@@ibmpcug.co.uk>
- dgilbert@@gamiga.guelphnet.dweomer.org (David Gilbert)
- kherron@@ms.uky.edu (Kenneth Herron)
- Mike Ipatow <mip@@fido.itc.e-burg.su>
- Romain Kang <romain@@pyramid.com>
- "Jonathan I. Kamens" <jik@@GZA.COM>
- "David J. MacKenzie" <djm@@eng.umd.edu>
- jum@@helios.de (Jens-Uwe Mager)
- peter@@xpoint.ruessel.sub.org (Peter Mandrella)
- david nugent <david@@csource.oz.au>
- Stephen.Page@@prg.oxford.ac.uk
- joey@@tessi.UUCP (Joey Pruett)
- James Revell <revell@@uunet.uu.net>
- Larry Rosenman <ler@@lerami.lerctr.org>
- Rich Salz <rsalz@@bbn.com>
- evesg@@etlrips.etl.go.jp (Gjoen Stein)
- kls@@ditka.Chicago.COM (Karl Swartz)
- Dima Volodin <dvv@@hq.demos.su>
- John.Woods@@proteon.com (John Woods)
- jon@@console.ais.org (Jon Zeeff)
- Eric Ziegast <ziegast@@uunet.uu.net>
-
-------------------------------
-
-End of UUCP Internals Frequently Asked Questions
-******************************
-@end format
-@end ifset
-@c END-OF-FAQ
-
-@node Hacking, Acknowledgements, Protocols, Top
-@chapter Hacking Taylor UUCP
-
-This chapter provides the briefest of guides to the Taylor UUCP source
-code itself.
-
-@menu
-* System Dependence:: System Dependence
-* Naming Conventions:: Naming Conventions
-* Patches:: Patches
-@end menu
-
-@node System Dependence, Naming Conventions, Hacking, Hacking
-@section System Dependence
-
-The code is carefully segregated into a system independent portion and a
-system dependent portion. The system dependent code is in the
-@file{unix} subdirectory, and also in the file @file{sysh.unx} (also
-known as @file{sysdep.h}).
-
-With the right configuration parameters, the system independent code
-calls only ANSI C functions. Some of the less common ANSI C functions
-are also provided in the @file{lib} directory. The replacement function
-@code{strtol} in @file{lib/strtol.c} assumes that the characters @kbd{A}
-to @kbd{F} and @kbd{a} to @kbd{f} appear in strictly sequential order.
-The function @code{igradecmp} in @file{uuconf/grdcmp.c} assumes that the
-upper and lower case letters appear in order. Both assumptions are true
-for ASCII and EBCDIC, but neither is guaranteed by ANSI C. Disregarding
-these caveats, I believe that the system independent portion of the code
-is strictly conforming.
-
-That's not too exciting, since all the work is done in the system
-dependent code. I think that this code can conform to POSIX 1003.1,
-given the right compilation parameters. I'm a bit less certain about
-this, though.
-
-The code has been used on a 16 bit segmented system with no function
-prototypes, so I'm fairly certain that all casts to long and pointers
-are done when necessary.
-
-@node Naming Conventions, Patches, System Dependence, Hacking
-@section Naming Conventions
-
-I use a modified Hungarian naming convention for my variables and
-functions. As with all naming conventions, the code is rather opaque if
-you are not familiar with it, but becomes clear and easy to use with
-time.
-
-The first character indicates the type of the variable (or function
-return value). Sometimes additional characters are used. I use the
-following type prefixes:
-
-@table @samp
-@item a
-array; the next character is the type of an element
-@item b
-byte or character
-@item c
-count of something
-@item e
-stdio FILE *
-@item f
-boolean
-@item i
-generic integer
-@item l
-double
-@item o
-file descriptor (as returned by open, creat, etc.)
-@item p
-generic pointer
-@item q
-pointer to structure
-@item s
-structure
-@item u
-void (function return values only)
-@item z
-character string
-@end table
-
-A generic pointer (@code{p}) is sometimes a @code{void *}, sometimes a
-function pointer in which case the prefix is pf, and sometimes a pointer
-to another type, in which case the next character is the type to which
-it points (pf is overloaded).
-
-An array of strings (@code{char *[]}) would be named @code{az} (array of
-string). If this array were passed to a function, the function
-parameter would be named @code{paz} (pointer to array of string).
-
-Note that the variable name prefixes do not necessarily indicate the
-type of the variable. For example, a variable prefixed with @kbd{i} may
-be int, long or short. Similarly, a variable prefixed with @kbd{b} may
-be a char or an int; for example, the return value of @code{getchar}
-would be caught in an int variable prefixed with @kbd{b}.
-
-For a non-local variable (extern or file static), the first character
-after the type prefix is capitalized.
-
-Most static variables and functions use another letter after the type
-prefix to indicate which module they come from. This is to help
-distinguish different names in the debugger. For example, all static
-functions in @file{protg.c}, the @samp{g} protocol source code, use a
-module prefix of @samp{g}. This isn't too useful, as a number of
-modules use a module prefix of @samp{s}.
-
-@node Patches, , Naming Conventions, Hacking
-@section Patches
-
-I am always grateful for any patches sent in. Much of the flexibility
-and portability of the code is due to other people. Please do not
-hesitate to send me any changes you have found necessary or useful.
-
-When sending a patch, please send the output of the Unix @code{diff}
-program invoked with the @samp{-c} option (if you have the GNU version
-of @code{diff}, use the @samp{-p} option). Always invoke @code{diff}
-with the original file first and the modified file second.
-
-If your @code{diff} does not support @samp{-c} (or you don't have
-@code{diff}), send a complete copy of the modified file (if you have
-just changed a single function, you can just send the new version of the
-function). In particular, please do not send @code{diff} output without
-the @samp{-c} option, as it is useless.
-
-If you have made a number of changes, it is very convenient for me if
-you send each change as a separate mail message. Sometimes I will think
-that one change is useful but another one is not. If they are in
-different messages it is much easier for me to apply one but not the
-other.
-
-I rarely apply the patches directly. Instead I work my way through the
-hunks and apply each one separately. This ensures that the naming
-remains consistent, and that I understand all the code.
-
-If you can not follow all these rules, then don't. But if you do, it
-makes it more likely that I will incorporate your changes. I am not
-paid for my UUCP work, and my available time is unfortunately very
-restricted. The package is important to me, and I do what I can, but I
-can not do all that I would like, much less all that everybody else
-would like.
-
-Finally, please do not be offended if I do not reply to messages for
-some time, even a few weeks. I am often behind on my mail, and if I
-think your message deserves a considered reply I will often put it aside
-until I have time to deal with it.
-
-@node Acknowledgements, Index (concepts), Hacking, Top
-@chapter Acknowledgements
-
-This is a list of people who gave help or suggestions while I was
-working on the Taylor UUCP project. Appearance on this list does not
-constitute endorsement of the program, particularly since some of the
-comments were criticisms. I've probably left some people off, and I
-apologize for any oversight; it does not mean your contribution was
-unappreciated.
-
-First of all, I would like to thank the people at Infinity Development
-Systems (formerly AIRS, which lives on in the domain name) for
-permitting me to use their computers and @file{uunet} access. I would
-also like to thank Richard Stallman @code{<rms@@gnu.ai.mit.edu>} for
-founding the Free Software Foundation, and John Gilmore
-@code{<gnu@@cygnus.com>} for writing the initial version of gnuucp which
-was a direct inspiration for this somewhat larger project. Chip
-Salzenberg @code{<chip@@tct.com>} has contributed many patches.
-@ifinfo
-Franc,ois
-@end ifinfo
-@iftex
-@tex
-Fran\c cois
-@end tex
-@end iftex
-Pinard @code{<pinard@@iro.umontreal.ca>} tirelessly tested the code and
-suggested many improvements. He also put together the initial version
-of this manual. Doug Evans contributed the zmodem protocol. Marc
-Boucher @code{<marc@@CAM.ORG>} contributed the code supporting the pipe
-port type. Jorge Cwik @code{jorge@@laser.satlink.net} contributed the
-@samp{y} protocol code. Finally, Verbus M. Counts
-@code{<verbus@@westmark.com>} and Centel Federal Systems, Inc., deserve
-special thanks, since they actually paid me money to port this code to
-System III.
-
-In alphabetical order:
-
-@example
-"Earle F. Ake - SAIC" @code{<ake@@Dayton.SAIC.COM>}
-@code{mra@@searchtech.com} (Michael Almond)
-@code{cambler@@zeus.calpoly.edu} (Christopher J. Ambler)
-Brian W. Antoine @code{<briana@@tau-ceti.isc-br.com>}
-@code{jantypas@@soft21.s21.com} (John Antypas)
-@code{james@@bigtex.cactus.org} (James Van Artsdalen)
-@code{jima@@netcom.com} (Jim Avera)
-@code{nba@@sysware.DK} (Niels Baggesen)
-@code{uunet!hotmomma!sdb} (Scott Ballantyne)
-Zacharias Beckman @code{<zac@@dolphin.com>}
-@code{mike@@mbsun.ann-arbor.mi.us} (Mike Bernson)
-@code{bob@@usixth.sublink.org} (Roberto Biancardi)
-@code{statsci!scott@@coco.ms.washington.edu} (Scott Blachowicz)
-@code{bag%wood2.cs.kiev.ua@@relay.ussr.eu.net} (Andrey G Blochintsev)
-@code{spider@@Orb.Nashua.NH.US} (Spider Boardman)
-Gregory Bond @code{<gnb@@bby.com.au>}
-Marc Boucher @code{<marc@@CAM.ORG>}
-Ard van Breemen @code{<ard@@cstmel.hobby.nl>}
-@code{dean@@coplex.com} (Dean Brooks)
-@code{jbrow@@radical.com} (Jim Brownfield)
-@code{dave@@dlb.com} (Dave Buck)
-@code{gordon@@sneaky.lonestar.org} (Gordon Burditt)
-@code{dburr@@sbphy.physics.ucsb.edu} (Donald Burr)
-@code{mib@@gnu.ai.mit.edu} (Michael I Bushnell)
-Brian Campbell @code{<brianc@@quantum.on.ca>}
-Andrew A. Chernov @code{<ache@@astral.msk.su>}
-@code{jhc@@iscp.bellcore.com} (Jonathan Clark)
-@code{mafc!frank@@bach.helios.de} (Frank Conrad)
-Ed Carp @code{<erc@@apple.com>}
-@code{mpc@@mbs.linet.org} (Mark Clements)
-@code{verbus@@westmark.westmark.com} (Verbus M. Counts)
-@code{cbmvax!snark.thyrsus.com!cowan} (John Cowan)
-Bob Cunningham @code{<bob@@soest.hawaii.edu>}
-@code{jorge@@laser.satlink.net} (Jorge Cwik)
-@code{kdburg@@incoahe.hanse.de} (Klaus Dahlenburg)
-Damon @code{<d@@exnet.co.uk>}
-@code{celit!billd@@UCSD.EDU} (Bill Davidson)
-@code{hubert@@arakis.fdn.org} (Hubert Delahaye)
-@code{markd@@bushwire.apana.org.au} (Mark Delany)
-Allen Delaney @code{<allen@@brc.ubc.ca>}
-Gerriet M. Denkmann @code{gerriet@@hazel.north.de}
-@code{denny@@dakota.alisa.com} (Bob Denny)
-Drew Derbyshire @code{<ahd@@kew.com>}
-@code{ssd@@nevets.oau.org} (Steven S. Dick)
-@code{gert@@greenie.gold.sub.org} (Gert Doering)
-@code{gemini@@geminix.in-berlin.de} (Uwe Doering)
-Hans-Dieter Doll @code{<hd2@@Insel.DE>}
-@code{deane@@deane.teleride.on.ca} (Dean Edmonds)
-Mark W. Eichin @code{<eichin@@cygnus.com>}
-@code{erik@@pdnfido.fidonet.org}
-Andrew Evans @code{<andrew@@airs.com>}
-@code{dje@@cygnus.com} (Doug Evans)
-Marc Evans @code{<marc@@synergytics.com>}
-Dan Everhart @code{<dan@@dyndata.com>}
-@code{kksys!kegworks!lfahnoe@@cs.umn.edu} (Larry Fahnoe)
-Matthew Farwell @code{<dylan@@ibmpcug.co.uk>}
-@code{fenner@@jazz.psu.edu} (Bill Fenner)
-@code{jaf@@inference.com} (Jose A. Fernandez)
-"David J. Fiander" @code{<golem!david@@news.lsuc.on.ca>}
-Thomas Fischer @code{<batman@@olorin.dark.sub.org>}
-Mister Flash @code{<flash@@sam.imash.ras.ru>}
-@code{louis@@marco.de} (Ju"rgen Fluk)
-@code{erik@@eab.retix.com} (Erik Forsberg)
-@code{andy@@scp.caltech.edu} (Andy Fyfe)
-Lele Gaifax @code{<piggy@@idea.sublink.org>}
-@code{Peter.Galbavy@@micromuse.co.uk}
-@code{hunter@@phoenix.pub.uu.oz.au} (James Gardiner [hunter])
-Terry Gardner @code{<cphpcom!tjg01>}
-@code{dgilbert@@gamiga.guelphnet.dweomer.org} (David Gilbert)
-@code{ol@@infopro.spb.su} (Oleg Girko)
-@code{jimmy@@tokyo07.info.com} (Jim Gottlieb)
-Benoit Grange @code{<ben@@fizz.fdn.org>}
-@code{elg@@elgamy.jpunix.com} (Eric Lee Green)
-@code{ryan@@cs.umb.edu} (Daniel R. Guilderson)
-@code{greg@@gagme.chi.il.us} (Gregory Gulik)
-Richard H. Gumpertz @code{<rhg@@cps.com>}
-Scott Guthridge @code{<scooter@@cube.rain.com>}
-Michael Haberler @code{<mah@@parrot.prv.univie.ac.at>}
-Daniel Hagerty @code{<hag@@eddie.mit.edu>}
-@code{jh@@moon.nbn.com} (John Harkin)
-@code{guy@@auspex.auspex.com} (Guy Harris)
-@code{hsw1@@papa.attmail.com} (Stephen Harris)
-Petri Helenius @code{<pete@@fidata.fi>}
-@code{gabe@@edi.com} (B. Gabriel Helou)
-Bob Hemedinger @code{<bob@@dalek.mwc.com>}
-Andrew Herbert @code{<andrew@@werple.pub.uu.oz.au>}
-@code{kherron@@ms.uky.edu} (Kenneth Herron)
-Peter Honeyman @code{<honey@@citi.umich.edu>}
-@code{jhood@@smoke.marlboro.vt.us} (John Hood)
-Mike Ipatow @code{<mip@@fido.itc.e-burg.su>}
-Bill Irwin @code{<bill@@twg.bc.ca>}
-@code{pmcgw!personal-media.co.jp!ishikawa} (Chiaki Ishikawa)
-@code{ai@@easy.in-chemnitz.de} (Andreas Israel)
-@code{iverson@@lionheart.com} (Tim Iverson)
-@code{bei@@dogface.austin.tx.us} (Bob Izenberg)
-@code{djamiga!djjames@@fsd.com} (D.J.James)
-Rob Janssen @code{<cmgit!rob@@relay.nluug.nl>}
-@code{harvee!esj} (Eric S Johansson)
-Kevin Johnson @code{<kjj@@pondscum.phx.mcd.mot.com>}
-@code{rj@@rainbow.in-berlin.de} (Robert Joop)
-Alan Judge @code{<aj@@dec4ie.IEunet.ie>}
-@code{chris@@cj_net.in-berlin.de} (Christof Junge)
-Romain Kang @code{<romain@@pyramid.com>}
-@code{tron@@Veritas.COM} (Ronald S. Karr)
-Brendan Kehoe @code{<brendan@@cs.widener.edu>}
-@code{warlock@@csuchico.edu} (John Kennedy)
-@code{kersing@@nlmug.nl.mugnet.org} (Jac Kersing)
-@code{ok@@daveg.PFM-Mainz.de} (Olaf Kirch)
-Gabor Kiss @code{<kissg@@sztaki.hu>}
-@code{gero@@gkminix.han.de} (Gero Kuhlmann)
-@code{rob@@pact.nl} (Rob Kurver)
-"C.A. Lademann" @code{<cal@@zls.gtn.com>}
-@code{kent@@sparky.IMD.Sterling.COM} (Kent Landfield)
-Tin Le @code{<tin@@saigon.com>}
-@code{lebaron@@inrs-telecom.uquebec.ca} (Gregory LeBaron)
-@code{karl@@sugar.NeoSoft.Com} (Karl Lehenbauer)
-@code{alex@@hal.rhein-main.de} (Alexander Lehmann)
-@code{merlyn@@digibd.com} (Merlyn LeRoy)
-@code{clewis@@ferret.ocunix.on.ca} (Chris Lewis)
-@code{gdonl@@ssi1.com} (Don Lewis)
-@code{libove@@libove.det.dec.com} (Jay Vassos-Libove)
-@code{bruce%blilly@@Broadcast.Sony.COM} (Bruce Lilly)
-Godfrey van der Linden @code{<Godfrey_van_der_Linden@@NeXT.COM>}
-Ted Lindgreen @code{<tlindgreen@@encore.nl>}
-@code{andrew@@cubetech.com} (Andrew Loewenstern)
-"Arne Ludwig" @code{<arne@@rrzbu.hanse.de>}
-Matthew Lyle @code{<matt@@mips.mitek.com>}
-@code{djm@@eng.umd.edu} (David J. MacKenzie)
-John R MacMillan @code{<chance!john@@sq.sq.com>}
-@code{jum@@helios.de} (Jens-Uwe Mager)
-Giles D Malet @code{<shrdlu!gdm@@provar.kwnet.on.ca>}
-@code{mem@@mv.MV.COM} (Mark E. Mallett)
-@code{pepe@@dit.upm.es} (Jose A. Manas)
-@code{peter@@xpoint.ruessel.sub.org} (Peter Mandrella)
-@code{martelli@@cadlab.sublink.org} (Alex Martelli)
-W Christopher Martin @code{<wcm@@geek.ca.geac.com>}
-Yanek Martinson @code{<yanek@@mthvax.cs.miami.edu>}
-@code{thomasm@@mechti.wupper.de} (Thomas Mechtersheimer)
-@code{jm@@aristote.univ-paris8.fr} (Jean Mehat)
-@code{me@@halfab.freiburg.sub.org} (Udo Meyer)
-@code{les@@chinet.chi.il.us} (Leslie Mikesell)
-@code{bug@@cyberdex.cuug.ab.ca} (Trever Miller)
-@code{mmitchel@@digi.lonestar.org} (Mitch Mitchell)
-Emmanuel Mogenet @code{<mgix@@krainte.jpn.thomson-di.fr>}
-@code{rmohr@@infoac.rmi.de} (Rupert Mohr)
-Jason Molenda @code{<molenda@@sequent.com>}
-@code{ianm@@icsbelf.co.uk} (Ian Moran)
-@code{jmorriso@@bogomips.ee.ubc.ca} (John Paul Morrison)
-@code{brian@@ilinx.wimsey.bc.ca} (Brian J. Murrell)
-@code{service@@infohh.rmi.de} (Dirk Musstopf)
-@code{lyndon@@cs.athabascau.ca} (Lyndon Nerenberg)
-@code{rolf@@saans.north.de} (Rolf Nerstheimer)
-@code{tom@@smart.bo.open.de} (Thomas Neumann)
-@code{mnichols@@pacesetter.com}
-Richard E. Nickle @code{<trystro!rick@@Think.COM>}
-@code{stephan@@sunlab.ka.sub.org} (Stephan Niemz)
-@code{nolan@@helios.unl.edu} (Michael Nolan)
-david nugent @code{<david@@csource.oz.au>}
-Jim O'Connor @code{<jim@@bahamut.fsc.com>}
-@code{kevin%kosman.uucp@@nrc.com} (Kevin O'Gorman)
-Petri Ojala @code{<ojala@@funet.fi>}
-@code{oneill@@cs.ulowell.edu} (Brian 'Doc' O'Neill)
-@code{Stephen.Page@@prg.oxford.ac.uk}
-@code{abekas!dragoman!mikep@@decwrl.dec.com} (Mike Park)
-Tim Peiffer @code{peiffer@@cs.umn.edu}
-@code{don@@blkhole.resun.com} (Don Phillips)
-"Mark Pizzolato 415-369-9366" @code{<mark@@infocomm.com>}
-John Plate @code{<plate@@infotek.dk>}
-@code{dplatt@@ntg.com} (Dave Platt)
-@code{eldorado@@tharr.UUCP} (Mark Powell)
-Mark Powell @code{<mark@@inet-uk.co.uk>}
-@code{pozar@@kumr.lns.com} (Tim Pozar)
-@code{joey@@tessi.UUCP} (Joey Pruett)
-Paul Pryor @code{ptp@@fallschurch-acirs2.army.mil}
-@code{putsch@@uicc.com} (Jeff Putsch)
-@code{ar@@nvmr.robin.de} (Andreas Raab)
-Jarmo Raiha @code{<jarmo@@ksvltd.FI>}
-James Revell @code{<revell@@uunet.uu.net>}
-Scott Reynolds @code{<scott@@clmqt.marquette.Mi.US>}
-@code{mcr@@Sandelman.OCUnix.On.Ca} (Michael Richardson)
-Kenji Rikitake @code{<kenji@@rcac.astem.or.jp>}
-@code{arnold@@cc.gatech.edu} (Arnold Robbins)
-@code{steve@@Nyongwa.cam.org} (Steve M. Robbins)
-Ollivier Robert @code{<Ollivier.Robert@@keltia.frmug.fr.net>}
-Serge Robyns @code{<sr@@denkart.be>}
-Lawrence E. Rosenman @code{<ler@@lerami.lerctr.org>}
-Jeff Ross @code{<jeff@@wisdom.bubble.org>}
-Aleksey P. Rudnev @code{<alex@@kiae.su>}
-"Heiko W.Rupp" @code{<hwr@@pilhuhn.ka.sub.org>}
-@code{wolfgang@@wsrcc.com} (Wolfgang S. Rupprecht)
-@code{tbr@@tfic.bc.ca} (Tom Rushworth)
-@code{jsacco@@ssl.com} (Joseph E. Sacco)
-@code{rsalz@@bbn.com} (Rich Salz)
-Curt Sampson @code{<curt@@portal.ca>}
-@code{sojurn!mike@@hobbes.cert.sei.cmu.edu} (Mike Sangrey)
-Nickolay Saukh @code{<nms@@ussr.EU.net>}
-@code{heiko@@lotte.sax.de} (Heiko Schlittermann)
-Eric Schnoebelen @code{<eric@@cirr.com>}
-@code{russell@@alpha3.ersys.edmonton.ab.ca} (Russell Schulz)
-@code{scott@@geom.umn.edu}
-Igor V. Semenyuk @code{<iga@@argrd0.argonaut.su>}
-Christopher Sawtell @code{<chris@@gerty.equinox.gen.nz>}
-@code{schuler@@bds.sub.org} (Bernd Schuler)
-@code{uunet!gold.sub.org!root} (Christian Seyb)
-@code{s4mjs!mjs@@nirvo.nirvonics.com} (M. J. Shannon Jr.)
-@code{shields@@tembel.org} (Michael Shields)
-@code{peter@@ficc.ferranti.com} (Peter da Silva)
-@code{vince@@victrola.sea.wa.us} (Vince Skahan)
-@code{frumious!pat} (Patrick Smith)
-@code{roscom!monty@@bu.edu} (Monty Solomon)
-@code{sommerfeld@@orchard.medford.ma.us} (Bill Sommerfeld)
-Julian Stacey @code{<stacey@@guug.de>}
-@code{evesg@@etlrips.etl.go.jp} (Gjoen Stein)
-Harlan Stenn @code{<harlan@@mumps.pfcs.com>}
-Ralf Stephan @code{<ralf@@ark.abg.sub.org>}
-@code{johannes@@titan.westfalen.de} (Johannes Stille)
-@code{chs@@antic.apu.fi} (Hannu Strang)
-@code{ralf@@reswi.ruhr.de} (Ralf E. Stranzenbach)
-@code{sullivan@@Mathcom.com} (S. Sullivan)
-Shigeya Suzuki @code{<shigeya@@dink.foretune.co.jp>}
-@code{kls@@ditka.Chicago.COM} (Karl Swartz)
-@code{swiers@@plains.NoDak.edu}
-Oleg Tabarovsky @code{<olg@@olghome.pccentre.msk.su>}
-@code{ikeda@@honey.misystems.co.jp} (Takatoshi Ikeda)
-John Theus @code{<john@@theus.rain.com>}
-@code{rd@@aii.com} (Bob Thrush)
-ppKarsten Thygesen @code{<karthy@@dannug.dk>}
-Graham Toal @code{<gtoal@@pizzabox.demon.co.uk>}
-@code{rmtodd@@servalan.servalan.com} (Richard Todd)
-Martin Tomes @code{<mt00@@controls.eurotherm.co.uk>}
-Len Tower @code{<tower-prep@@ai.mit.edu>}
-Mark Towfiq @code{<justice!towfiq@@Eingedi.Newton.MA.US>}
-@code{mju@@mudos.ann-arbor.mi.us} (Marc Unangst)
-Matthias Urlichs @code{<urlichs@@smurf.noris.de>}
-Tomi Vainio @code{<tomppa@@fidata.fi>}
-@code{a3@@a3.xs4all.nl} (Adri Verhoef)
-Andrew Vignaux @code{<ajv@@ferrari.datamark.co.nz>}
-@code{vogel@@omega.ssw.de} (Andreas Vogel)
-Dima Volodin @code{<dvv@@hq.demos.su>}
-@code{jos@@bull.nl} (Jos Vos)
-@code{jv@@nl.net} (Johan Vromans)
-David Vrona @code{<dave@@sashimi.wwa.com>}
-@code{Marcel.Waldvogel@@nice.usergroup.ethz.ch} (Marcel Waldvogel)
-@code{steve@@nshore.org} (Stephen J. Walick)
-@code{syd@@dsinc.dsi.com} (Syd Weinstein)
-@code{gerben@@rna.indiv.nluug.nl} (Gerben Wierda)
-@code{jbw@@cs.bu.edu} (Joe Wells)
-@code{frnkmth!twwells.com!bill} (T. William Wells)
-Peter Wemm @code{<Peter_Wemm@@zeus.dialix.oz.au>}
-@code{mauxci!eci386!woods@@apple.com} (Greg A. Woods)
-@code{John.Woods@@proteon.com} (John Woods)
-Michael Yu.Yaroslavtsev @code{<mike@@yaranga.ipmce.su>}
-Alexei K. Yushin @code{<root@@july.elis.crimea.ua>}
-@code{jon@@console.ais.org} (Jon Zeeff)
-Matthias Zepf @code{<agnus@@amylnd.stgt.sub.org>}
-Eric Ziegast @code{<uunet!ziegast>}
-@end example
-
-@node Index (concepts), Index (configuration file), Acknowledgements, Top
-@unnumbered Concept Index
-
-@printindex cp
-
-@node Index (configuration file), , Index (concepts), Top
-@unnumbered Configuration File Index
-
-@printindex fn
-
-@contents
-@bye
diff --git a/gnu/libexec/uucp/libunix/MANIFEST b/gnu/libexec/uucp/libunix/MANIFEST
deleted file mode 100644
index 342650a..0000000
--- a/gnu/libexec/uucp/libunix/MANIFEST
+++ /dev/null
@@ -1,84 +0,0 @@
-Makefile.in
-MANIFEST
-access.c
-addbas.c
-app3.c
-app4.c
-basnam.c
-bytfre.c
-chmod.c
-cohtty.c
-corrup.c
-cusub.c
-cwd.c
-detach.c
-dirent.c
-dup2.c
-efopen.c
-epopen.c
-exists.c
-failed.c
-filnam.c
-fsusg.c
-fsusg.h
-ftw.c
-getcwd.c
-indir.c
-init.c
-isdir.c
-isfork.c
-iswait.c
-jobid.c
-lcksys.c
-link.c
-locfil.c
-lock.c
-loctim.c
-mail.c
-mkdir.c
-mkdirs.c
-mode.c
-move.c
-opensr.c
-pause.c
-picksb.c
-pipe.c
-portnm.c
-priv.c
-proctm.c
-recep.c
-remove.c
-rename.c
-rmdir.c
-run.c
-seq.c
-serial.c
-signal.c
-sindir.c
-size.c
-sleep.c
-splcmd.c
-splnam.c
-spool.c
-spawn.c
-srmdir.c
-statsb.c
-status.c
-strerr.c
-sync.c
-tcp.c
-time.c
-tli.c
-tmpfil.c
-trunc.c
-uacces.c
-ufopen.c
-uid.c
-ultspl.c
-unknwn.c
-uuto.c
-walk.c
-wldcrd.c
-work.c
-xqtfil.c
-xqtsub.c
diff --git a/gnu/libexec/uucp/libunix/Makefile b/gnu/libexec/uucp/libunix/Makefile
deleted file mode 100644
index acdb62e..0000000
--- a/gnu/libexec/uucp/libunix/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# This subdirectory contains Unix specific support functions.
-# $Id$
-
-LIB= unix
-SRCS = access.c addbas.c app3.c app4.c basnam.c bytfre.c corrup.c \
- chmod.c cohtty.c cusub.c cwd.c detach.c efopen.c epopen.c \
- exists.c failed.c filnam.c fsusg.c indir.c init.c isdir.c \
- isfork.c iswait.c jobid.c lcksys.c link.c locfil.c lock.c \
- loctim.c mail.c mkdirs.c mode.c move.c opensr.c pause.c \
- picksb.c pipe.c portnm.c priv.c proctm.c recep.c run.c seq.c \
- serial.c signal.c sindir.c size.c sleep.c spawn.c splcmd.c \
- splnam.c spool.c srmdir.c statsb.c status.c sync.c tcp.c \
- time.c tli.c tmpfil.c trunc.c uacces.c ufopen.c uid.c ultspl.c \
- unknwn.c uuto.c walk.c wldcrd.c work.c xqtfil.c xqtsub.c ftw.c
-CFLAGS+= -I$(.CURDIR)/../common_sources \
- -DOWNER=\"$(owner)\" -DSBINDIR=\"$(libxdir)\"
-
-NOMAN= noman
-NOPROFILE= noprofile
-
-install:
-
-.include <bsd.lib.mk>
diff --git a/gnu/libexec/uucp/libunix/access.c b/gnu/libexec/uucp/libunix/access.c
deleted file mode 100644
index c2c0eef..0000000
--- a/gnu/libexec/uucp/libunix/access.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* access.c
- Check access to files by the user and by the daemon. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-/* See if the user has access to a file, to prevent the setuid uucp
- and uux programs handing out unauthorized access. */
-
-boolean
-fsysdep_access (zfile)
- const char *zfile;
-{
- if (access (zfile, R_OK) == 0)
- return TRUE;
- ulog (LOG_ERROR, "%s: %s", zfile, strerror (errno));
- return FALSE;
-}
-
-/* See if the daemon has access to a file. This is called if a file
- is not being transferred to the spool directory, since if the
- daemon does not have access the later transfer will fail. We
- assume that the daemon will have the same euid (or egid) as the one
- we are running under. If our uid (gid) and euid (egid) are the
- same, we assume that we have access. Note that is not important
- for security, since the check will be (implicitly) done again when
- the daemon tries to transfer the file. This routine should work
- whether the UUCP programs are installed setuid or setgid. */
-
-boolean
-fsysdep_daemon_access (zfile)
- const char *zfile;
-{
- struct stat s;
- uid_t ieuid, iuid, iegid, igid;
- boolean fok;
-
- ieuid = geteuid ();
- if (ieuid == 0)
- return TRUE;
- iuid = getuid ();
- iegid = getegid ();
- igid = getgid ();
-
- /* If our effective uid and gid are the same as our real uid and
- gid, we assume the daemon will have access to the file. */
- if (ieuid == iuid && iegid == igid)
- return TRUE;
-
- if (stat ((char *) zfile, &s) != 0)
- {
- ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno));
- return FALSE;
- }
-
- /* If our euid is not our uid, but it is the file's uid, see if the
- owner has read access. Otherwise, if our egid is not our gid,
- but it is the file's gid, see if the group has read access.
- Otherwise, see if the world has read access. We know from the
- above check that at least one of our euid and egid are different,
- so that is the only one we want to check. This check could fail
- if the UUCP programs were both setuid and setgid, but why would
- they be? */
- if (ieuid != iuid && ieuid == s.st_uid)
- fok = (s.st_mode & S_IRUSR) != 0;
- else if (iegid != igid && iegid == s.st_gid)
- fok = (s.st_mode & S_IRGRP) != 0;
- else
- fok = (s.st_mode & S_IROTH) != 0;
-
- if (! fok)
- {
- ulog (LOG_ERROR, "%s: cannot be read by daemon", zfile);
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/addbas.c b/gnu/libexec/uucp/libunix/addbas.c
deleted file mode 100644
index 8597918..0000000
--- a/gnu/libexec/uucp/libunix/addbas.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* addbas.c
- If we have a directory, add in a base name. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-/* If we have a directory, add a base name. */
-
-char *
-zsysdep_add_base (zfile, zname)
- const char *zfile;
- const char *zname;
-{
- size_t clen;
- const char *zlook;
- char *zfree;
- char *zret;
-
-#if DEBUG > 0
- if (*zfile != '/')
- ulog (LOG_FATAL, "zsysdep_add_base: %s: Can't happen", zfile);
-#endif
-
- clen = strlen (zfile);
-
- if (zfile[clen - 1] != '/')
- {
- if (! fsysdep_directory (zfile))
- return zbufcpy (zfile);
- zfree = NULL;
- }
- else
- {
- /* Trim out the trailing '/'. */
- zfree = zbufcpy (zfile);
- zfree[clen - 1] = '\0';
- zfile = zfree;
- }
-
- zlook = strrchr (zname, '/');
- if (zlook != NULL)
- zname = zlook + 1;
-
- zret = zsysdep_in_dir (zfile, zname);
- ubuffree (zfree);
- return zret;
-}
diff --git a/gnu/libexec/uucp/libunix/app3.c b/gnu/libexec/uucp/libunix/app3.c
deleted file mode 100644
index f3c3555..0000000
--- a/gnu/libexec/uucp/libunix/app3.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* app3.c
- Stick two directories and a file name together. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-
-char *
-zsappend3 (zdir1, zdir2, zfile)
- const char *zdir1;
- const char *zdir2;
- const char *zfile;
-{
- size_t cdir1, cdir2, cfile;
- char *zret;
-
- cdir1 = strlen (zdir1);
- cdir2 = strlen (zdir2);
- cfile = strlen (zfile);
- zret = zbufalc (cdir1 + cdir2 + cfile + 3);
- if (cdir1 == 1 && *zdir1 == '/')
- cdir1 = 0;
- else
- memcpy (zret, zdir1, cdir1);
- memcpy (zret + cdir1 + 1, zdir2, cdir2);
- memcpy (zret + cdir1 + cdir2 + 2, zfile, cfile);
- zret[cdir1] = '/';
- zret[cdir1 + cdir2 + 1] = '/';
- zret[cdir1 + cdir2 + cfile + 2] = '\0';
- return zret;
-}
diff --git a/gnu/libexec/uucp/libunix/app4.c b/gnu/libexec/uucp/libunix/app4.c
deleted file mode 100644
index d3a243f..0000000
--- a/gnu/libexec/uucp/libunix/app4.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* app4.c
- Stick three directories and a file name together. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-
-char *
-zsappend4 (zdir1, zdir2, zdir3, zfile)
- const char *zdir1;
- const char *zdir2;
- const char *zdir3;
- const char *zfile;
-{
- size_t cdir1, cdir2, cdir3, cfile;
- char *zret;
-
- cdir1 = strlen (zdir1);
- cdir2 = strlen (zdir2);
- cdir3 = strlen (zdir3);
- cfile = strlen (zfile);
- zret = zbufalc (cdir1 + cdir2 + cdir3 + cfile + 4);
- if (cdir1 == 1 && *zdir1 == '/')
- cdir1 = 0;
- else
- memcpy (zret, zdir1, cdir1);
- memcpy (zret + cdir1 + 1, zdir2, cdir2);
- memcpy (zret + cdir1 + cdir2 + 2, zdir3, cdir3);
- memcpy (zret + cdir1 + cdir2 + cdir3 + 3, zfile, cfile);
- zret[cdir1] = '/';
- zret[cdir1 + cdir2 + 1] = '/';
- zret[cdir1 + cdir2 + cdir3 + 2] = '/';
- zret[cdir1 + cdir2 + cdir3 + cfile + 3] = '\0';
- return zret;
-}
diff --git a/gnu/libexec/uucp/libunix/basnam.c b/gnu/libexec/uucp/libunix/basnam.c
deleted file mode 100644
index c61fcaa..0000000
--- a/gnu/libexec/uucp/libunix/basnam.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* basnam.c
- Get the base name of a file. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-/* Get the base name of a file name. */
-
-char *
-zsysdep_base_name (zfile)
- const char *zfile;
-{
- const char *z;
-
- z = strrchr (zfile, '/');
- if (z != NULL)
- return zbufcpy (z + 1);
- return zbufcpy (zfile);
-}
diff --git a/gnu/libexec/uucp/libunix/bytfre.c b/gnu/libexec/uucp/libunix/bytfre.c
deleted file mode 100644
index 3091e7a..0000000
--- a/gnu/libexec/uucp/libunix/bytfre.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* bytfre.c
- Get the number of bytes free on a file system. */
-
-#include "uucp.h"
-
-#include "system.h"
-#include "sysdep.h"
-#include "fsusg.h"
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#else
-#define LONG_MAX 2147483647
-#endif
-
-long
-csysdep_bytes_free (zfile)
- const char *zfile;
-{
- struct fs_usage s;
-
- if (get_fs_usage ((char *) zfile, (char *) NULL, &s) < 0)
- return -1;
- if (s.fsu_bavail >= LONG_MAX / (long) 512)
- return LONG_MAX;
- return s.fsu_bavail * (long) 512;
-}
diff --git a/gnu/libexec/uucp/libunix/chmod.c b/gnu/libexec/uucp/libunix/chmod.c
deleted file mode 100644
index cf69f3e..0000000
--- a/gnu/libexec/uucp/libunix/chmod.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* chmod.c
- Change the mode of a file. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-/* Change the mode of a file. */
-
-boolean
-fsysdep_change_mode (zfile, imode)
- const char *zfile;
- unsigned int imode;
-{
- if (chmod ((char *) zfile, imode) < 0)
- {
- ulog (LOG_ERROR, "chmod (%s): %s", zfile, strerror (errno));
- return FALSE;
- }
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/cohtty.c b/gnu/libexec/uucp/libunix/cohtty.c
deleted file mode 100644
index 5a52df9..0000000
--- a/gnu/libexec/uucp/libunix/cohtty.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/* Coherent tty locking support. This file was contributed by Bob
- Hemedinger <bob@dalek.mwc.com> of Mark Williams Corporation and
- lightly edited by Ian Lance Taylor. */
-
-/* The bottom part of this file is lock.c.
- * This is a hacked lock.c. A full lock.c can be found in the libmisc sources
- * under /usr/src/misc.tar.Z.
- *
- * These are for checking for the existence of locks:
- * lockexist(resource)
- * lockttyexist(ttyname)
- */
-
-#include "uucp.h"
-
-#if HAVE_COHERENT_LOCKFILES
-
-/* cohtty.c: Given a serial device name, read /etc/ttys and determine if
- * the device is already enabled. If it is, disable the
- * device and return a string so that it can be re-enabled
- * at the completion of the uucico session as part of the
- * function that resets the serial device before uucico
- * terminates.
- *
- */
-
-#include "uudefs.h"
-#include "sysdep.h"
-
-#include <ctype.h>
-#include <access.h>
-
-/* fscoherent_disable_tty() is a COHERENT specific function. It takes the name
- * of a serial device and then scans /etc/ttys for a match. If it finds one,
- * it checks the first field of the entry. If it is a '1', then it will disable
- * the port and set a flag. The flag will be checked later when uucico wants to
- * reset the serial device to see if the device needs to be re-enabled.
- */
-
-/* May 10, 1993: This function will always return true for the following
- * reasons:
- * 1) lock files have already been dealt with
- * 2) if someone else already has the port open, uucico should fail anyways
- * 3) Coherent's disable command return can return '0' or '1', but will
- * succeed in any event.
- * 4) It doesn't matter if there is a ttys entry for the port in question.
- * /etc/ttys generally only lists devices that MAY be enabled for logins.
- * If a device will never be used for logins, then there may not be a
- * ttys entry, in which case, disable won't be called anyways.
- * ---bob@mwc.com
- */
-
-boolean
-fscoherent_disable_tty (zdevice, pzenable)
- const char *zdevice;
- char **pzenable;
-{
-
-
-struct ttyentry{ /* this is an /etc/ttys entry */
- char enable_disable[1];
- char remote_local[1];
- char baud_rate[1];
- char tty_device[16];
-};
-
-struct ttyentry sought_tty;
-
-int x,y,z; /* dummy */
-FILE * infp; /* this will point to /etc/ttys */
-char disable_command[66]; /* this will be the disable command
- * passed to the system.
- */
-char enable_device[16]; /* this will hold our device name
- * to enable.
- */
-
- *pzenable = NULL;
-
- strcpy(enable_device,""); /* initialize our strings */
- strcpy(sought_tty.tty_device,"");
-
- if( (infp = fopen("/etc/ttys","r")) == NULL){
- ulog(LOG_ERROR,"Error: check_disable_tty: failed to open /etc/ttys\n");
- return FALSE;
- }
-
- while (NULL !=(fgets(&sought_tty, sizeof (sought_tty), infp ))){
- sought_tty.tty_device[strlen(sought_tty.tty_device) -1] = '\0';
- strcpy(enable_device,sought_tty.tty_device);
-
- /* we must strip away the suffix to the com port name or
- * we will never find a match. For example, if we are passed
- * /dev/com4l to call out with and the port is already enabled,
- * 9/10 the port enabled will be com4r. After we strip away the
- * suffix of the port found in /etc/ttys, then we can test
- * if the base port name appears in the device name string
- * passed to us.
- */
-
- for(z = strlen(sought_tty.tty_device) ; z > 0 ; z--){
- if(isdigit(sought_tty.tty_device[z])){
- break;
- }
- }
- y = strlen(sought_tty.tty_device);
- for(x = z+1 ; x <= y; x++){
- sought_tty.tty_device[x] = '\0';
- }
-
-
-/* ulog(LOG_NORMAL,"found device {%s}\n",sought_tty.tty_device); */
- if(strstr(zdevice, sought_tty.tty_device)){
- if(sought_tty.enable_disable[0] == '1'){
- ulog(LOG_NORMAL, "coh_tty: Disabling device %s {%s}\n",
- zdevice, sought_tty.tty_device);
- sprintf(disable_command, "/etc/disable %s",enable_device);
- {
- pid_t ipid;
- const char *azargs[3];
- int aidescs[3];
-
- azargs[0] = "/etc/disable";
- azargs[1] = enable_device;
- azargs[2] = NULL;
- aidescs[0] = SPAWN_NULL;
- aidescs[1] = SPAWN_NULL;
- aidescs[2] = SPAWN_NULL;
- ipid = ixsspawn (azargs, aidescs, TRUE,
- FALSE,
- (const char *) NULL, TRUE,
- TRUE,
- (const char *) NULL,
- (const char *) NULL,
- (const char *) NULL);
- if (ipid < 0)
- x = 1;
- else
- x = ixswait ((unsigned long) ipid,
- (const char *) NULL);
- }
- *pzenable = zbufalc (sizeof "/dev/"
- + strlen (enable_device));
- sprintf(*pzenable,"/dev/%s", enable_device);
-/* ulog(LOG_NORMAL,"Enable string is {%s}",*pzenable); */
- return TRUE;
- }else{
- /* device not enabled */
- return TRUE;
- }
- }
- }
- return TRUE; /* no ttys entry found */
-}
-
-/* The following is COHERENT 4.0 specific. It is used to test for any
- * existing lockfiles on a port which would have been created by init
- * when a user logs into a port.
- */
-
-#define LOCKSIG 9 /* Significant Chars of Lockable Resources. */
-#define LOKFLEN 64 /* Max Length of UUCP Lock File Name. */
-
-#define LOCKPRE "LCK.."
-#define PIDLEN 6 /* Maximum length of string representing a pid. */
-
-#ifndef LOCKDIR
-#define LOCKDIR SPOOLDIR
-#endif
-
-/* There is a special version of DEVMASK for the PE multiport driver
- * because of the peculiar way it uses the minor device number. For
- * all other drivers, the lower 5 bits describe the physical port--
- * the upper 3 bits give attributes for the port.
- */
-
-#define PE_DRIVER 21 /* Major device number for the PE driver. */
-#define PE_DEVMASK 0x3f /* PE driver minor device mask. */
-#define DEVMASK 0x1f /* Minor device mask. */
-
-/*
- * Generates a resource name for locking, based on the major number
- * and the lower 4 bits of the minor number of the tty device.
- *
- * Builds the name in buff as two "." separated decimal numbers.
- * Returns NULL on failure, buff on success.
- */
-static char *
-gen_res_name(path, buff)
-char *path;
-char *buff;
-{
- struct stat sbuf;
- int status;
-
- if (0 != (status = stat(path, &sbuf))) {
- /* Can't stat the file. */
- return (NULL);
- }
-
- if (PE_DRIVER == major(sbuf.st_rdev)) {
- sprintf(buff, "%d.%d", major(sbuf.st_rdev),
- PE_DEVMASK & minor(sbuf.st_rdev));
- } else {
- sprintf(buff, "%d.%d", major(sbuf.st_rdev),
- DEVMASK & minor(sbuf.st_rdev));
- }
-
- return(buff);
-} /* gen_res_name */
-
-/*
- * lockexist(resource) char *resource;
- *
- * Test for existance of a lock on the given resource.
- *
- * Returns: (1) Resource is locked.
- * (0) Resource is not locked.
- */
-
-static boolean
-lockexist(resource)
-const char *resource;
-{
- char lockfn[LOKFLEN];
-
- if ( resource == NULL )
- return(0);
- sprintf(lockfn, "%s/%s%.*s", LOCKDIR, LOCKPRE, LOCKSIG, resource);
-
- return (!access(lockfn, AEXISTS));
-} /* lockexist() */
-
-/*
- * lockttyexist(ttyname) char *ttyname;
- *
- * Test for existance of a lock on the given tty.
- *
- * Returns: (1) Resource is locked.
- * (0) Resource is not locked.
- */
-boolean
-lockttyexist(ttyn)
-const char *ttyn;
-{
- char resource[LOKFLEN];
- char filename[LOKFLEN];
-
- sprintf(filename, "/dev/%s", ttyn);
- if (NULL == gen_res_name(filename, resource)){
- return(0); /* Non-existent tty can not be locked :-) */
- }
-
- return(lockexist(resource));
-} /* lockttyexist() */
-
-#endif /* HAVE_COHERENT_LOCKFILES */
diff --git a/gnu/libexec/uucp/libunix/corrup.c b/gnu/libexec/uucp/libunix/corrup.c
deleted file mode 100644
index 87f19e6..0000000
--- a/gnu/libexec/uucp/libunix/corrup.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* corrup.c
- Save a file in the .Corrupt directory. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-#include "uudefs.h"
-#include "system.h"
-
-char *
-zsysdep_save_corrupt_file (zfile)
- const char *zfile;
-{
- const char *zslash;
- char *zto;
-
- zslash = strrchr (zfile, '/');
- if (zslash == NULL)
- zslash = zfile;
- else
- ++zslash;
-
- zto = zsappend3 (zSspooldir, CORRUPTDIR, zslash);
-
- if (! fsysdep_move_file (zfile, zto, TRUE, FALSE, FALSE,
- (const char *) NULL))
- {
- ubuffree (zto);
- return NULL;
- }
-
- return zto;
-}
diff --git a/gnu/libexec/uucp/libunix/cusub.c b/gnu/libexec/uucp/libunix/cusub.c
deleted file mode 100644
index 503708a..0000000
--- a/gnu/libexec/uucp/libunix/cusub.c
+++ /dev/null
@@ -1,1214 +0,0 @@
-/* cusub.c
- System dependent routines for cu.
-
- Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char cusub_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "sysdep.h"
-#include "system.h"
-#include "cu.h"
-#include "conn.h"
-#include "prot.h"
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-/* Get definitions for both O_NONBLOCK and O_NDELAY. */
-#ifndef O_NDELAY
-#ifdef FNDELAY
-#define O_NDELAY FNDELAY
-#else /* ! defined (FNDELAY) */
-#define O_NDELAY 0
-#endif /* ! defined (FNDELAY) */
-#endif /* ! defined (O_NDELAY) */
-
-#ifndef O_NONBLOCK
-#ifdef FNBLOCK
-#define O_NONBLOCK FNBLOCK
-#else /* ! defined (FNBLOCK) */
-#define O_NONBLOCK 0
-#endif /* ! defined (FNBLOCK) */
-#endif /* ! defined (O_NONBLOCK) */
-
-#include <errno.h>
-
-/* 4.2 systems don't define SIGUSR2. This should work for them. On
- systems which are missing SIGUSR1, or SIGURG, you must find two
- signals which you can safely use. */
-#ifndef SIGUSR2
-#define SIGUSR2 SIGURG
-#endif
-
-/* Get definitions for EAGAIN, EWOULDBLOCK and ENODATA. */
-#ifndef EAGAIN
-#ifndef EWOULDBLOCK
-#define EAGAIN (-1)
-#define EWOULDBLOCK (-1)
-#else /* defined (EWOULDBLOCK) */
-#define EAGAIN EWOULDBLOCK
-#endif /* defined (EWOULDBLOCK) */
-#else /* defined (EAGAIN) */
-#ifndef EWOULDBLOCK
-#define EWOULDBLOCK EAGAIN
-#endif /* ! defined (EWOULDBLOCK) */
-#endif /* defined (EAGAIN) */
-
-#ifndef ENODATA
-#define ENODATA EAGAIN
-#endif
-
-/* Local variables. */
-
-/* The EOF character, as set by fsysdep_terminal_raw. */
-static char bSeof;
-
-/* The SUSP character, as set by fsysdep_terminal_raw. */
-static char bStstp;
-
-/* Local functions. */
-
-static const char *zsport_line P((const struct uuconf_port *qport));
-static void uscu_child P((struct sconnection *qconn, int opipe));
-static RETSIGTYPE uscu_child_handler P((int isig));
-static RETSIGTYPE uscu_alarm P((int isig));
-static int cscu_escape P((char *pbcmd, const char *zlocalname));
-static RETSIGTYPE uscu_alarm_kill P((int isig));
-
-/* Return the device name for a port, or NULL if none. */
-
-static const char *
-zsport_line (qport)
- const struct uuconf_port *qport;
-{
- const char *zline;
-
- if (qport == NULL)
- return NULL;
-
- switch (qport->uuconf_ttype)
- {
- default:
- case UUCONF_PORTTYPE_STDIN:
- return NULL;
- case UUCONF_PORTTYPE_MODEM:
- zline = qport->uuconf_u.uuconf_smodem.uuconf_zdevice;
- break;
- case UUCONF_PORTTYPE_DIRECT:
- zline = qport->uuconf_u.uuconf_sdirect.uuconf_zdevice;
- break;
- case UUCONF_PORTTYPE_TCP:
- case UUCONF_PORTTYPE_TLI:
- case UUCONF_PORTTYPE_PIPE:
- return NULL;
- }
-
- if (zline == NULL)
- zline = qport->uuconf_zname;
- return zline;
-}
-
-/* Check whether the user has legitimate access to a port. */
-
-boolean
-fsysdep_port_access (qport)
- struct uuconf_port *qport;
-{
- const char *zline;
- char *zfree;
- boolean fret;
-
- zline = zsport_line (qport);
- if (zline == NULL)
- return TRUE;
-
- zfree = NULL;
- if (*zline != '/')
- {
- zfree = zbufalc (sizeof "/dev/" + strlen (zline));
- sprintf (zfree, "/dev/%s", zline);
- zline = zfree;
- }
-
- fret = access (zline, R_OK | W_OK) == 0;
- ubuffree (zfree);
- return fret;
-}
-
-/* Return whether the given port is named by the given line. */
-
-boolean
-fsysdep_port_is_line (qport, zline)
- struct uuconf_port *qport;
- const char *zline;
-{
- const char *zpline;
- char *zfree1, *zfree2;
- boolean fret;
-
- zpline = zsport_line (qport);
- if (zpline == NULL)
- return FALSE;
-
- if (strcmp (zline, zpline) == 0)
- return TRUE;
-
- zfree1 = NULL;
- zfree2 = NULL;
- if (*zline != '/')
- {
- zfree1 = zbufalc (sizeof "/dev/" + strlen (zline));
- sprintf (zfree1, "/dev/%s", zline);
- zline = zfree1;
- }
- if (*zpline != '/')
- {
- zfree2 = zbufalc (sizeof "/dev/" + strlen (zpline));
- sprintf (zfree2, "/dev/%s", zpline);
- zpline = zfree2;
- }
-
- fret = strcmp (zline, zpline) == 0;
- ubuffree (zfree1);
- ubuffree (zfree2);
- return fret;
-}
-
-/* The cu program wants the system dependent layer to handle the
- details of copying data from the communications port to the
- terminal. This copying need only be done while executing
- fsysdep_cu. On Unix, however, we set up a subprocess to do it all
- the time. This subprocess must be controllable via the
- fsysdep_cu_copy function.
-
- We keep a pipe open to the subprocess. When we want it to stop we
- send it a signal, and then wait for it to write a byte to us over
- the pipe. */
-
-/* The subprocess pid. */
-static volatile pid_t iSchild;
-
-/* The pipe from the subprocess. */
-static int oSpipe;
-
-/* When we tell the child to stop, it sends this. */
-#define CHILD_STOPPED ('S')
-
-/* When we tell the child to start, it sends this. */
-#define CHILD_STARTED ('G')
-
-/* Initialize the subprocess, and have it start copying data. */
-
-boolean
-fsysdep_cu_init (qconn)
- struct sconnection *qconn;
-{
- int ai[2];
-
- /* Write out anything we may have buffered up during the chat
- script. We do this before forking the child only to make it easy
- to move the child into a separate executable. */
- while (iPrecend != iPrecstart)
- {
- char *z;
- int c;
-
- z = abPrecbuf + iPrecstart;
- if (iPrecend > iPrecstart)
- c = iPrecend - iPrecstart;
- else
- c = CRECBUFLEN - iPrecstart;
-
- iPrecstart = (iPrecstart + c) % CRECBUFLEN;
-
- while (c > 0)
- {
- int cwrote;
-
- cwrote = write (1, z, c);
- if (cwrote <= 0)
- {
- if (cwrote < 0)
- ulog (LOG_ERROR, "write: %s", strerror (errno));
- else
- ulog (LOG_ERROR, "Line disconnected");
- return FALSE;
- }
- c -= cwrote;
- z += cwrote;
- }
- }
-
- if (pipe (ai) < 0)
- {
- ulog (LOG_ERROR, "pipe: %s", strerror (errno));
- return FALSE;
- }
-
- iSchild = ixsfork ();
- if (iSchild < 0)
- {
- ulog (LOG_ERROR, "fork: %s", strerror (errno));
- return FALSE;
- }
-
- if (iSchild == 0)
- {
- (void) close (ai[0]);
- uscu_child (qconn, ai[1]);
- /*NOTREACHED*/
- }
-
- (void) close (ai[1]);
-
- oSpipe = ai[0];
-
- return TRUE;
-}
-
-/* Copy all data from the terminal to the communications port. If we
- see an escape character following a newline character, read the
- next character and return it. */
-
-boolean
-fsysdep_cu (qconn, pbcmd, zlocalname)
- struct sconnection *qconn;
- char *pbcmd;
- const char *zlocalname;
-{
- boolean fstart;
- char b;
- int c;
-
- fstart = TRUE;
-
- while (TRUE)
- {
- if (fsysdep_catch ())
- usysdep_start_catch ();
- else
- {
- ulog (LOG_ERROR, (const char *) NULL);
- return FALSE;
- }
-
- c = read (0, &b, 1);
-
- usysdep_end_catch ();
-
- if (c <= 0)
- break;
-
- if (fstart && b == *zCuvar_escape && b != '\0')
- {
- c = cscu_escape (pbcmd, zlocalname);
- if (c <= 0)
- break;
- if (*pbcmd != b)
- {
- write (1, pbcmd, 1);
-
- /* For Unix, we let the eof character be the same as
- '.', and we let the suspend character (if any) be the
- same as 'z'. */
- if (*pbcmd == bSeof)
- *pbcmd = '.';
- if (*pbcmd == bStstp)
- *pbcmd = 'z';
- return TRUE;
- }
- }
- if (! fconn_write (qconn, &b, (size_t) 1))
- return FALSE;
- fstart = strchr (zCuvar_eol, b) != NULL;
- }
-
- if (c < 0)
- {
- if (errno != EINTR)
- ulog (LOG_ERROR, "read: %s", strerror (errno));
- else
- ulog (LOG_ERROR, (const char *) NULL);
- return FALSE;
- }
-
- /* I'm not sure what's best in this case. */
- ulog (LOG_ERROR, "End of file on terminal");
- return FALSE;
-}
-
-/* A SIGALRM handler that sets fScu_alarm and optionally longjmps. */
-
-volatile sig_atomic_t fScu_alarm;
-
-static RETSIGTYPE
-uscu_alarm (isig)
- int isig;
-{
-#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET
- (void) signal (isig, uscu_alarm);
-#endif
-
- fScu_alarm = TRUE;
-
-#if HAVE_RESTARTABLE_SYSCALLS
- if (fSjmp)
- longjmp (sSjmp_buf, 1);
-#endif
-}
-
-/* We've just seen an escape character. We print the host name,
- optionally after a 1 second delay. We read the next character from
- the terminal and return it. The 1 second delay on the host name is
- mostly to be fancy; it lets ~~ look smoother. */
-
-static int
-cscu_escape (pbcmd, zlocalname)
- char *pbcmd;
- const char *zlocalname;
-{
- CATCH_PROTECT int c;
-
- write (1, zCuvar_escape, 1);
-
- fScu_alarm = FALSE;
- usset_signal (SIGALRM, uscu_alarm, TRUE, (boolean *) NULL);
-
- if (fsysdep_catch ())
- {
- usysdep_start_catch ();
- alarm (1);
- }
-
- c = 0;
-
- while (TRUE)
- {
- if (fScu_alarm)
- {
- char b;
-
- fScu_alarm = FALSE;
- b = '[';
- write (1, &b, 1);
- write (1, zlocalname, strlen (zlocalname));
- b = ']';
- write (1, &b, 1);
- }
-
- if (c <= 0)
- c = read (0, pbcmd, 1);
- if (c >= 0 || errno != EINTR)
- {
- usysdep_end_catch ();
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- alarm (0);
- return c;
- }
- }
-}
-
-/* A SIGALRM handler which does nothing but send a signal to the child
- process and schedule another alarm. POSIX.1 permits kill and alarm
- from a signal handler. The reference to static data may or may not
- be permissible. */
-
-static volatile sig_atomic_t iSsend_sig;
-
-static RETSIGTYPE
-uscu_alarm_kill (isig)
- int isig;
-{
-#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET
- (void) signal (isig, uscu_alarm_kill);
-#endif
-
- (void) kill (iSchild, iSsend_sig);
-
- alarm (1);
-}
-
-/* Start or stop copying data from the communications port to the
- terminal. We send a signal to the child process to tell it what to
- do. Unfortunately, there are race conditions in the child, so we
- keep sending it a signal once a second until it responds. We send
- SIGUSR1 to make it start copying, and SIGUSR2 to make it stop. */
-
-boolean
-fsysdep_cu_copy (fcopy)
- boolean fcopy;
-{
- int ierr;
- int c;
-
- usset_signal (SIGALRM, uscu_alarm_kill, TRUE, (boolean *) NULL);
- if (fcopy)
- iSsend_sig = SIGUSR1;
- else
- iSsend_sig = SIGUSR2;
-
- uscu_alarm_kill (SIGALRM);
-
- alarm (1);
-
- while (TRUE)
- {
- char b;
-
- c = read (oSpipe, &b, 1);
-
-#if DEBUG > 1
- if (c > 0)
- DEBUG_MESSAGE1 (DEBUG_INCOMING,
- "fsysdep_cu_copy: Got '%d'", b);
-#endif
-
- if ((c < 0 && errno != EINTR)
- || c == 0
- || (c > 0 && b == (fcopy ? CHILD_STARTED : CHILD_STOPPED)))
- break;
-
- /* If none of the above conditions were true, then we either got
- an EINTR error, in which case we probably timed out and the
- SIGALRM handler resent the signal, or we read the wrong
- character, in which case we will just read again from the
- pipe. */
- }
-
- ierr = errno;
-
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- alarm (0);
-
- if (c > 0)
- return TRUE;
-
- if (c == 0)
- ulog (LOG_ERROR, "EOF on child pipe");
- else
- ulog (LOG_ERROR, "read: %s", strerror (ierr));
-
- return FALSE;
-}
-
-/* Shut down cu by killing the child process. */
-
-boolean
-fsysdep_cu_finish ()
-{
- (void) close (oSpipe);
-
- /* We hit the child with SIGTERM, give it two seconds to die, and
- then send a SIGKILL. */
- if (kill (iSchild, SIGTERM) < 0)
- {
- /* Don't give an error if the child has already died. */
- if (errno != ESRCH)
- ulog (LOG_ERROR, "kill: %s", strerror (errno));
- }
-
- usset_signal (SIGALRM, uscu_alarm_kill, TRUE, (boolean *) NULL);
- iSsend_sig = SIGKILL;
- alarm (2);
-
- (void) ixswait ((unsigned long) iSchild, "child");
-
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- alarm (0);
-
- return TRUE;
-}
-
-/* Code for the child process. */
-
-/* This signal handler just records the signal. In this case we only
- care about which signal we received most recently. */
-
-static volatile sig_atomic_t iSchild_sig;
-
-static RETSIGTYPE
-uscu_child_handler (isig)
- int isig;
-{
-#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET
- (void) signal (isig, uscu_child_handler);
-#endif
-
- iSchild_sig = isig;
-
-#if HAVE_RESTARTABLE_SYSCALLS
- if (fSjmp)
- longjmp (sSjmp_buf, 1);
-#endif /* HAVE_RESTARTABLE_SYSCALLS */
-}
-
-/* The child process. This copies the port to the terminal, except
- when it is stopped by a signal. It would be reasonable to write a
- separate program for this, probably passing it the port on stdin.
- This would reduce the memory requirements, since we wouldn't need a
- second process holding all the configuration stuff, and also let it
- work reasonably on 680x0 versions of MINIX. */
-
-static void
-uscu_child (qconn, opipe)
- struct sconnection *qconn;
- int opipe;
-{
- CATCH_PROTECT int oport;
- CATCH_PROTECT boolean fstopped, fgot;
- CATCH_PROTECT int cwrite;
- CATCH_PROTECT char abbuf[1024];
-
- fgot = FALSE;
-
- /* It would be nice if we could just use fsysdep_conn_read, but that
- will log signals that we don't want logged. There should be a
- generic way to extract the file descriptor from the port. */
- if (qconn->qport == NULL)
- oport = 0;
- else
- {
- switch (qconn->qport->uuconf_ttype)
- {
-#if DEBUG > 0
- default:
- ulog (LOG_FATAL, "uscu_child: Can't happen");
- oport = -1;
- break;
-#endif
- case UUCONF_PORTTYPE_PIPE:
- /* A read of 0 on a pipe always means EOF (see below). */
- fgot = TRUE;
- /* Fall through. */
- case UUCONF_PORTTYPE_STDIN:
- oport = ((struct ssysdep_conn *) qconn->psysdep)->ord;
- break;
- case UUCONF_PORTTYPE_MODEM:
- case UUCONF_PORTTYPE_DIRECT:
- case UUCONF_PORTTYPE_TCP:
- case UUCONF_PORTTYPE_TLI:
- oport = ((struct ssysdep_conn *) qconn->psysdep)->o;
- break;
- }
- }
-
- /* Force the descriptor into blocking mode. */
- (void) fcntl (oport, F_SETFL,
- fcntl (oport, F_GETFL, 0) &~ (O_NDELAY | O_NONBLOCK));
-
- usset_signal (SIGUSR1, uscu_child_handler, TRUE, (boolean *) NULL);
- usset_signal (SIGUSR2, uscu_child_handler, TRUE, (boolean *) NULL);
- usset_signal (SIGINT, SIG_IGN, TRUE, (boolean *) NULL);
- usset_signal (SIGQUIT, SIG_IGN, TRUE, (boolean *) NULL);
- usset_signal (SIGPIPE, SIG_DFL, TRUE, (boolean *) NULL);
- usset_signal (SIGTERM, uscu_child_handler, TRUE, (boolean *) NULL);
-
- fstopped = FALSE;
- iSchild_sig = 0;
- cwrite = 0;
-
- if (fsysdep_catch ())
- usysdep_start_catch ();
-
- while (TRUE)
- {
- int isig;
- int c;
-
- /* There is a race condition here between checking the signal
- and receiving a new and possibly different one. This is
- solved by having the parent resend the signal until it gets a
- response. */
- isig = iSchild_sig;
- iSchild_sig = 0;
- if (isig != 0)
- {
- char b;
-
- if (isig == SIGTERM)
- exit (EXIT_SUCCESS);
-
- if (isig == SIGUSR1)
- {
- fstopped = FALSE;
- b = CHILD_STARTED;
- }
- else
- {
- fstopped = TRUE;
- b = CHILD_STOPPED;
- cwrite = 0;
- }
-
- c = write (opipe, &b, 1);
-
- /* Apparently on some systems we can get EAGAIN here. */
- if (c < 0 &&
- (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENODATA))
- c = 0;
-
- if (c <= 0)
- {
- /* Should we give an error message here? */
- (void) kill (getppid (), SIGHUP);
- exit (EXIT_FAILURE);
- }
- }
-
- if (fstopped)
- pause ();
- else if (cwrite > 0)
- {
- char *zbuf;
-
- zbuf = abbuf;
- while (cwrite > 0)
- {
- c = write (1, zbuf, cwrite);
-
- /* Apparently on some systems we can get EAGAIN here. */
- if (c < 0 &&
- (errno == EAGAIN
- || errno == EWOULDBLOCK
- || errno == ENODATA))
- c = 0;
-
- if (c < 0 && errno == EINTR)
- break;
- if (c <= 0)
- {
- /* Should we give an error message here? */
- (void) kill (getppid (), SIGHUP);
- exit (EXIT_FAILURE);
- }
- cwrite -= c;
- zbuf += c;
- }
- }
- else
- {
- /* On some systems apparently read will return 0 until
- something has been written to the port. We therefore
- accept a 0 return until after we have managed to read
- something. Setting errno to 0 apparently avoids a
- problem on Coherent. */
- errno = 0;
- c = read (oport, abbuf, sizeof abbuf);
-
- /* Apparently on some systems we can get EAGAIN here. */
- if (c < 0 &&
- (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENODATA))
- c = 0;
-
- if ((c == 0 && fgot)
- || (c < 0 && errno != EINTR))
- {
- /* This can be a normal way to exit, depending on just
- how the connection is dropped. */
- (void) kill (getppid (), SIGHUP);
- exit (EXIT_SUCCESS);
- }
- if (c > 0)
- {
- fgot = TRUE;
- cwrite = c;
- }
- }
- }
-}
-
-/* Terminal control routines. */
-
-/* Whether file descriptor 0 is attached to a terminal or not. */
-static boolean fSterm;
-
-/* Whether we are doing local echoing. */
-static boolean fSlocalecho;
-
-/* The original state of the terminal. */
-static sterminal sSterm_orig;
-
-/* The new state of the terminal. */
-static sterminal sSterm_new;
-
-#if ! HAVE_BSD_TTY
-#ifdef SIGTSTP
-/* Whether SIGTSTP is being ignored. */
-static boolean fStstp_ignored;
-#endif
-#endif
-
-/* Set the terminal into raw mode. */
-
-boolean
-fsysdep_terminal_raw (flocalecho)
- boolean flocalecho;
-{
- fSlocalecho = flocalecho;
-
- /* This defaults may be overriden below. */
- bSeof = '\004';
- bStstp = '\032';
-
- if (! fgetterminfo (0, &sSterm_orig))
- {
- fSterm = FALSE;
- return TRUE;
- }
-
- fSterm = TRUE;
-
- sSterm_new = sSterm_orig;
-
-#if HAVE_BSD_TTY
-
- /* We use CBREAK mode rather than RAW mode, because RAW mode turns
- off all output processing, which we don't want to do. This means
- that we have to disable the interrupt characters, which we do by
- setting them to -1. */
- bSeof = sSterm_orig.stchars.t_eofc;
-
- sSterm_new.stchars.t_intrc = -1;
- sSterm_new.stchars.t_quitc = -1;
- sSterm_new.stchars.t_startc = -1;
- sSterm_new.stchars.t_stopc = -1;
- sSterm_new.stchars.t_eofc = -1;
- sSterm_new.stchars.t_brkc = -1;
-
- bStstp = sSterm_orig.sltchars.t_suspc;
-
- sSterm_new.sltchars.t_suspc = -1;
- sSterm_new.sltchars.t_dsuspc = -1;
- sSterm_new.sltchars.t_rprntc = -1;
- sSterm_new.sltchars.t_flushc = -1;
- sSterm_new.sltchars.t_werasc = -1;
- sSterm_new.sltchars.t_lnextc = -1;
-
- if (! flocalecho)
- {
- sSterm_new.stty.sg_flags |= (CBREAK | ANYP);
- sSterm_new.stty.sg_flags &=~ (ECHO | CRMOD | TANDEM);
- }
- else
- {
- sSterm_new.stty.sg_flags |= (CBREAK | ANYP | ECHO);
- sSterm_new.stty.sg_flags &=~ (CRMOD | TANDEM);
- }
-
-#endif /* HAVE_BSD_TTY */
-
-#if HAVE_SYSV_TERMIO
-
- bSeof = sSterm_new.c_cc[VEOF];
- if (! flocalecho)
- sSterm_new.c_lflag &=~ (ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHONL);
- else
- sSterm_new.c_lflag &=~ (ICANON | ISIG);
- sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL | IXON | IXOFF | IXANY);
- sSterm_new.c_oflag &=~ (OPOST);
- sSterm_new.c_cc[VMIN] = 1;
- sSterm_new.c_cc[VTIME] = 0;
-
-#endif /* HAVE_SYSV_TERMIO */
-
-#if HAVE_POSIX_TERMIOS
-
- bSeof = sSterm_new.c_cc[VEOF];
- bStstp = sSterm_new.c_cc[VSUSP];
- if (! flocalecho)
- sSterm_new.c_lflag &=~
- (ICANON | IEXTEN | ISIG | ECHO | ECHOE | ECHOK | ECHONL);
- else
- sSterm_new.c_lflag &=~ (ICANON | IEXTEN | ISIG);
- sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL | IXON | IXOFF);
- sSterm_new.c_oflag &=~ (OPOST);
- sSterm_new.c_cc[VMIN] = 1;
- sSterm_new.c_cc[VTIME] = 0;
-
-#endif /* HAVE_POSIX_TERMIOS */
-
- if (! fsetterminfo (0, &sSterm_new))
- {
- ulog (LOG_ERROR, "Can't set terminal settings: %s", strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Restore the terminal to its original setting. */
-
-boolean
-fsysdep_terminal_restore ()
-{
- if (! fSterm)
- return TRUE;
-
- if (! fsetterminfo (0, &sSterm_orig))
- {
- ulog (LOG_ERROR, "Can't restore terminal: %s", strerror (errno));
- return FALSE;
- }
- return TRUE;
-}
-
-/* Read a line from the terminal. This will be called after
- fsysdep_terminal_raw has been called. */
-
-char *
-zsysdep_terminal_line (zprompt)
- const char *zprompt;
-{
- CATCH_PROTECT size_t cbuf = 0;
- CATCH_PROTECT char *zbuf = NULL;
- CATCH_PROTECT size_t cgot = 0;
-
- if (zprompt != NULL && *zprompt != '\0')
- (void) write (1, zprompt, strlen (zprompt));
-
- /* Forgot about any previous SIGINT or SIGQUIT signals we may have
- received. We don't worry about the race condition here, since we
- can't get these signals from the terminal at the moment and it's
- not too likely that somebody else will be sending them to us. */
- afSignal[INDEXSIG_SIGINT] = 0;
- afSignal[INDEXSIG_SIGQUIT] = 0;
-
- if (! fsysdep_terminal_restore ())
- return NULL;
-
- if (fsysdep_catch ())
- {
- usysdep_start_catch ();
- cbuf = 0;
- zbuf = NULL;
- cgot = 0;
- }
-
- while (TRUE)
- {
- char b;
- int c;
-
- if (afSignal[INDEXSIG_SIGINT]
- || afSignal[INDEXSIG_SIGQUIT])
- {
- usysdep_end_catch ();
- /* Make sure the signal is logged. */
- ulog (LOG_ERROR, (const char *) NULL);
- /* Return an empty string. */
- cgot = 0;
- break;
- }
-
- /* There's a race here between checking the signals and calling
- read. It just means that the user will have to hit ^C more
- than once. */
-
- c = read (0, &b, 1);
- if (c < 0)
- {
- if (errno == EINTR)
- continue;
- usysdep_end_catch ();
- ulog (LOG_ERROR, "read: %s", strerror (errno));
- (void) fsysdep_terminal_raw (fSlocalecho);
- return NULL;
- }
- if (c == 0)
- {
- /* I'm not quite sure what to do here. */
- usysdep_end_catch ();
- ulog (LOG_ERROR, "EOF on terminal");
- (void) fsysdep_terminal_raw (fSlocalecho);
- return NULL;
- }
-
- if (cgot >= cbuf)
- {
- char *znew;
-
- cbuf += 64;
- znew = zbufalc (cbuf);
- if (zbuf != NULL)
- {
- memcpy (znew, zbuf, cgot);
- ubuffree (zbuf);
- }
- zbuf = znew;
- }
-
- zbuf[cgot] = b;
-
- ++cgot;
-
- if (b == '\n')
- {
- usysdep_end_catch ();
- break;
- }
- }
-
- if (cgot >= cbuf)
- {
- char *znew;
-
- ++cbuf;
- znew = zbufalc (cbuf);
- if (zbuf != NULL)
- {
- memcpy (znew, zbuf, cgot);
- ubuffree (zbuf);
- }
- zbuf = znew;
- }
-
- zbuf[cgot] = '\0';
-
- if (! fsysdep_terminal_raw (fSlocalecho))
- return NULL;
-
- return zbuf;
-}
-
-/* Write a line to the terminal with a trailing newline. */
-
-boolean
-fsysdep_terminal_puts (zline)
- const char *zline;
-{
- char *zalc, *zprint;
- size_t clen;
-
- if (zline == NULL)
- {
- zalc = zbufalc (2);
- clen = 0;
- }
- else
- {
- clen = strlen (zline);
- zalc = zbufalc (clen + 2);
- memcpy (zalc, zline, clen);
- }
-
- if (fSterm)
- {
- zalc[clen] = '\r';
- ++clen;
- }
- zalc[clen] = '\n';
- ++clen;
-
- zprint = zalc;
- while (clen > 0)
- {
- int c;
-
- c = write (1, zprint, clen);
- if (c <= 0)
- {
- ubuffree (zalc);
- ulog (LOG_ERROR, "write: %s", strerror (errno));
- return FALSE;
- }
- clen -= c;
- zprint += c;
- }
-
- ubuffree (zalc);
-
- return TRUE;
-}
-
-/* Allow or disallow signals from the terminal. */
-
-boolean
-fsysdep_terminal_signals (faccept)
- boolean faccept;
-{
-#if HAVE_BSD_TTY
-
- if (faccept)
- {
- sSterm_new.stchars.t_intrc = sSterm_orig.stchars.t_intrc;
- sSterm_new.stchars.t_quitc = sSterm_orig.stchars.t_quitc;
- }
- else
- {
- sSterm_new.stchars.t_intrc = -1;
- sSterm_new.stchars.t_quitc = -1;
- }
-
-#else /* ! HAVE_BSD_TTY */
-
- if (faccept)
- sSterm_new.c_lflag |= ISIG;
- else
- sSterm_new.c_lflag &=~ ISIG;
-
-#ifdef SIGTSTP
- /* We only want to get SIGINT and SIGQUIT, not SIGTSTP. This
- function will be called with faccept TRUE before it is called
- with faccept FALSE, so fStstp_ignored will be correctly
- initialized. */
- if (faccept)
- usset_signal (SIGTSTP, SIG_IGN, FALSE, &fStstp_ignored);
- else if (! fStstp_ignored)
- usset_signal (SIGTSTP, SIG_DFL, TRUE, (boolean *) NULL);
-#endif
-
-#endif /* ! HAVE_BSD_TTY */
-
- if (! fsetterminfo (0, &sSterm_new))
- {
- ulog (LOG_ERROR, "Can't set terminal: %s", strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Start up a command, or possibly just a shell. Optionally attach
- stdin or stdout to the port. We attach directly to the port,
- rather than copying the data ourselves. */
-
-boolean
-fsysdep_shell (qconn, zcmd, tcmd)
- struct sconnection *qconn;
- const char *zcmd;
- enum tshell_cmd tcmd;
-{
- const char *azargs[4];
- int oread, owrite;
- int aidescs[3];
- pid_t ipid;
-
- if (tcmd != SHELL_NORMAL)
- azargs[0] = "/bin/sh";
- else
- {
- azargs[0] = getenv ("SHELL");
- if (azargs[0] == NULL)
- azargs[0] = "/bin/sh";
- }
- if (zcmd == NULL || *zcmd == '\0')
- azargs[1] = NULL;
- else
- {
- azargs[1] = "-c";
- azargs[2] = zcmd;
- azargs[3] = NULL;
- }
-
- if (qconn->qport == NULL)
- {
- oread = 0;
- owrite = 1;
- }
- else
- {
- switch (qconn->qport->uuconf_ttype)
- {
- default:
- oread = owrite = -1;
- break;
- case UUCONF_PORTTYPE_STDIN:
- case UUCONF_PORTTYPE_PIPE:
- oread = ((struct ssysdep_conn *) qconn->psysdep)->ord;
- owrite = ((struct ssysdep_conn *) qconn->psysdep)->owr;
- break;
- case UUCONF_PORTTYPE_MODEM:
- case UUCONF_PORTTYPE_DIRECT:
- case UUCONF_PORTTYPE_TCP:
- case UUCONF_PORTTYPE_TLI:
- oread = owrite = ((struct ssysdep_conn *) qconn->psysdep)->o;
- break;
- }
- }
-
- aidescs[0] = 0;
- aidescs[1] = 1;
- aidescs[2] = 2;
-
- if (tcmd == SHELL_STDIN_FROM_PORT || tcmd == SHELL_STDIO_ON_PORT)
- aidescs[0] = oread;
- if (tcmd == SHELL_STDOUT_TO_PORT || tcmd == SHELL_STDIO_ON_PORT)
- aidescs[1] = owrite;
-
- ipid = ixsspawn (azargs, aidescs, FALSE, TRUE, (const char *) NULL,
- FALSE, FALSE, (const char *) NULL,
- (const char *) NULL, (const char *) NULL);
- if (ipid < 0)
- {
- ulog (LOG_ERROR, "ixsspawn (/bin/sh): %s", strerror (errno));
- return FALSE;
- }
-
- return ixswait ((unsigned long) ipid, "shell") == 0;
-}
-
-/* Change directories. */
-
-boolean
-fsysdep_chdir (zdir)
- const char *zdir;
-{
- if (zdir == NULL || *zdir == '\0')
- {
- zdir = getenv ("HOME");
- if (zdir == NULL)
- {
- ulog (LOG_ERROR, "HOME not defined");
- return FALSE;
- }
- }
- if (chdir (zdir) < 0)
- {
- ulog (LOG_ERROR, "chdir (%s): %s", zdir, strerror (errno));
- return FALSE;
- }
- return TRUE;
-}
-
-/* Suspend the current process. */
-
-boolean
-fsysdep_suspend ()
-{
-#ifndef SIGTSTP
- return fsysdep_terminal_puts ("[process suspension not supported]");
-#else
- return kill (getpid (), SIGTSTP) == 0;
-#endif
-}
diff --git a/gnu/libexec/uucp/libunix/cwd.c b/gnu/libexec/uucp/libunix/cwd.c
deleted file mode 100644
index 71d05d1..0000000
--- a/gnu/libexec/uucp/libunix/cwd.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* cwd.c
- Routines dealing with the current working directory. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-/* See whether running this file through zsysdep_add_cwd would require
- knowing the current working directory. This is used to avoid
- determining the cwd if it will not be needed. */
-
-boolean
-fsysdep_needs_cwd (zfile)
- const char *zfile;
-{
- return *zfile != '/' && *zfile != '~';
-}
-
-/* Expand a local file, putting relative pathnames in the current
- working directory. Note that ~/file is placed in the public
- directory, rather than in the user's home directory. This is
- consistent with other UUCP packages. */
-
-char *
-zsysdep_local_file_cwd (zfile, zpubdir, pfbadname)
- const char *zfile;
- const char *zpubdir;
- boolean *pfbadname;
-{
- if (pfbadname != NULL)
- *pfbadname = FALSE;
- if (*zfile == '/')
- return zbufcpy (zfile);
- else if (*zfile == '~')
- return zsysdep_local_file (zfile, zpubdir, pfbadname);
- else
- return zsysdep_add_cwd (zfile);
-}
-
-/* Add the current working directory to a remote file name. */
-
-char *
-zsysdep_add_cwd (zfile)
- const char *zfile;
-{
- if (*zfile == '/' || *zfile == '~')
- return zbufcpy (zfile);
-
- if (zScwd == NULL)
- {
- ulog (LOG_ERROR, "Can't determine current directory");
- return NULL;
- }
-
- return zsysdep_in_dir (zScwd, zfile);
-}
diff --git a/gnu/libexec/uucp/libunix/detach.c b/gnu/libexec/uucp/libunix/detach.c
deleted file mode 100644
index 88becf1..0000000
--- a/gnu/libexec/uucp/libunix/detach.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/* detach.c
- Detach from the controlling terminal.
-
- Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "system.h"
-#include "sysdep.h"
-
-#include <errno.h>
-
-#if HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-#ifdef TIOCNOTTY
-#define HAVE_TIOCNOTTY 1
-#else
-#define HAVE_TIOCNOTTY 0
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#if HAVE_BROKEN_SETSID
-#undef HAVE_SETSID
-#define HAVE_SETSID 0
-#endif
-
-/* Detach from the controlling terminal. This is called by uucico if
- it is calling out to another system, so that it can receive SIGHUP
- signals from the port it calls out on. It is also called by uucico
- just before it starts uuxqt, so that uuxqt is completely
- independent of the terminal. */
-
-void
-usysdep_detach ()
-{
- pid_t igrp;
-
- /* Make sure that we can open the log file. We do this now so that,
- if we can't, a message will be written to stderr. After we leave
- this routine, stderr will be closed. */
- ulog (LOG_NORMAL, (const char *) NULL);
-
- /* Make sure we are not a process group leader. */
-#if HAVE_BSD_PGRP
- igrp = getpgrp (0);
-#else
- igrp = getpgrp ();
-#endif
-
- if (igrp == getpid ())
- {
- boolean fignored;
- pid_t ipid;
-
- /* Ignore SIGHUP, since our process group leader is about to
- die. */
- usset_signal (SIGHUP, SIG_IGN, FALSE, &fignored);
-
- ipid = ixsfork ();
- if (ipid < 0)
- ulog (LOG_FATAL, "fork: %s", strerror (errno));
-
- if (ipid != 0)
- _exit (EXIT_SUCCESS);
-
- /* We'll always wind up as a child of process number 1, right?
- Right? We have to wait for our parent to die before
- reenabling SIGHUP. */
- while (getppid () != 1)
- sleep (1);
-
- ipid = getpid ();
- ulog_id (ipid);
-
- /* Restore SIGHUP catcher if it wasn't being ignored. */
- if (! fignored)
- usset_signal (SIGHUP, ussignal, TRUE, (boolean *) NULL);
-
- DEBUG_MESSAGE2 (DEBUG_PORT,
- "usysdep_detach: Forked; old PID %ld, new pid %ld",
- (long) igrp, (long) ipid);
- }
-
-#if ! HAVE_SETSID && HAVE_TIOCNOTTY
- /* Lose the original controlling terminal as well as our process
- group. */
- {
- int o;
-
- o = open ((char *) "/dev/tty", O_RDONLY);
- if (o >= 0)
- {
- (void) ioctl (o, TIOCNOTTY, (char *) NULL);
- (void) close (o);
- }
- }
-#endif /* ! HAVE_SETSID && HAVE_TIOCNOTTY */
-
- /* Close stdin, stdout and stderr and reopen them on /dev/null, to
- make sure we have no connection at all to the terminal. */
- (void) close (0);
- (void) close (1);
- (void) close (2);
- if (open ((char *) "/dev/null", O_RDONLY) != 0
- || open ((char *) "/dev/null", O_WRONLY) != 1
- || open ((char *) "/dev/null", O_WRONLY) != 2)
- ulog (LOG_FATAL, "open (/dev/null): %s", strerror (errno));
-
-#if HAVE_SETSID
-
- /* Under POSIX the setsid call creates a new session for which we
- are the process group leader. It also detaches us from our
- controlling terminal. */
- if (setsid () < 0)
- ulog (LOG_ERROR, "setsid: %s", strerror (errno));
-
-#else /* ! HAVE_SETSID */
-
-#if ! HAVE_SETPGRP
- #error Cannot detach from controlling terminal
-#endif
-
- /* If we don't have setsid, we must use setpgrp. On an old System V
- system setpgrp will make us the leader of a new process group and
- detach the controlling terminal. On an old BSD system the call
- setpgrp (0, 0) will set our process group to 0 so that we can
- acquire a new controlling terminal (TIOCNOTTY may or may not have
- already done that anyhow). */
-#if HAVE_BSD_PGRP
- if (setpgrp (0, 0) < 0)
-#else
- if (setpgrp () < 0)
-#endif
- {
- /* Some systems seem to give EPERM errors inappropriately. */
- if (errno != EPERM)
- ulog (LOG_ERROR, "setpgrp: %s", strerror (errno));
- }
-
-#endif /* ! HAVE_SETSID */
-
- /* At this point we have completely detached from our controlling
- terminal. The next terminal device we open will probably become
- our controlling terminal. */
-}
diff --git a/gnu/libexec/uucp/libunix/dirent.c b/gnu/libexec/uucp/libunix/dirent.c
deleted file mode 100644
index 7ad0ec6..0000000
--- a/gnu/libexec/uucp/libunix/dirent.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* dirent.c
- Replacements for opendir, readdir and closedir for the original
- Unix filesystem only.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
-
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-/* Simple emulations of opendir/readdir/closedir for systems which
- have the original format of Unix directories. It's probably better
- to get Doug Gwyn's public domain set of emulation functions. */
-
-DIR *
-opendir (zdir)
- const char *zdir;
-{
- int o;
- struct stat s;
- DIR *qret;
-
- o = open ((char *) zdir, O_RDONLY | O_NOCTTY, 0);
- if (o < 0)
- return NULL;
- if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0
- || fstat (o, &s) < 0)
- {
- int isave;
-
- isave = errno;
- (void) close (o);
- errno = isave;
- return NULL;
- }
- if (! S_ISDIR (s.st_mode))
- {
- (void) close (o);
- errno = ENOTDIR;
- return NULL;
- }
- qret = (DIR *) xmalloc (sizeof (DIR));
- qret->o = o;
- return qret;
-}
-
-struct dirent *
-readdir (q)
- DIR *q;
-{
- struct direct sdir;
- int cgot;
-
- do
- {
- cgot = read (q->o, &sdir, sizeof (struct direct));
- if (cgot <= 0)
- return NULL;
- if (cgot != sizeof (struct direct))
- {
- errno = ENOENT;
- return NULL;
- }
- }
- while (sdir.d_ino == 0);
-
- strncpy (q->s.d_name, sdir.d_name, DIRSIZ);
- q->s.d_name[DIRSIZ] = '\0';
- return &q->s;
-}
-
-int
-closedir (q)
- DIR *q;
-{
- int o;
-
- o = q->o;
- xfree (q);
- return close (o);
-}
diff --git a/gnu/libexec/uucp/libunix/dup2.c b/gnu/libexec/uucp/libunix/dup2.c
deleted file mode 100644
index a3fcea5..0000000
--- a/gnu/libexec/uucp/libunix/dup2.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* dup2.c
- The Unix dup2 function, for systems which only have dup.
-
- Copyright (C) 1985, 1986, 1987, 1988, 1990 Free Software Foundation, Inc.
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-#include "sysdep.h"
-
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-/* I basically took this from the emacs 18.57 distribution, although I
- cleaned it up a bit and made it POSIX compliant. */
-
-int
-dup2 (oold, onew)
- int oold;
- int onew;
-{
- if (oold == onew)
- return onew;
- (void) close (onew);
-
-#ifdef F_DUPFD
- return fcntl (oold, F_DUPFD, onew);
-#else
- {
- int onext, oret, isave;
-
- onext = dup (oold);
- if (onext == onew)
- return onext;
- if (onext < 0)
- return -1;
- oret = dup2 (oold, onew);
- isave = errno;
- (void) close (onext);
- errno = isave;
- return oret;
- }
-#endif
-}
diff --git a/gnu/libexec/uucp/libunix/efopen.c b/gnu/libexec/uucp/libunix/efopen.c
deleted file mode 100644
index 7e360b6..0000000
--- a/gnu/libexec/uucp/libunix/efopen.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* efopen.c
- Open a stdio file with appropriate permissions. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef O_APPEND
-#ifdef FAPPEND
-#define O_APPEND FAPPEND
-#endif
-#endif
-
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-FILE *
-esysdep_fopen (zfile, fpublic, fappend, fmkdirs)
- const char *zfile;
- boolean fpublic;
- boolean fappend;
- boolean fmkdirs;
-{
- int imode;
- int o;
- FILE *e;
-
- if (fpublic)
- imode = IPUBLIC_FILE_MODE;
- else
- imode = IPRIVATE_FILE_MODE;
-
- if (! fappend)
- o = creat ((char *) zfile, imode);
- else
- {
-#ifdef O_CREAT
- o = open ((char *) zfile,
- O_WRONLY | O_APPEND | O_CREAT | O_NOCTTY,
- imode);
-#else
- o = open ((char *) zfile, O_WRONLY | O_NOCTTY);
- if (o < 0 && errno == ENOENT)
- o = creat ((char *) zfile, imode);
-#endif /* ! defined (O_CREAT) */
- }
-
- if (o < 0)
- {
- if (errno == ENOENT && fmkdirs)
- {
- if (! fsysdep_make_dirs (zfile, fpublic))
- return NULL;
- if (! fappend)
- o = creat ((char *) zfile, imode);
- else
- {
-#ifdef O_CREAT
- o = open ((char *) zfile,
- O_WRONLY | O_APPEND | O_CREAT | O_NOCTTY,
- imode);
-#else
- o = creat ((char *) zfile, imode);
-#endif
- }
- }
- if (o < 0)
- {
- ulog (LOG_ERROR, "open (%s): %s", zfile, strerror (errno));
- return NULL;
- }
- }
-
-#ifndef O_CREAT
-#ifdef O_APPEND
- if (fappend)
- {
- if (fcntl (o, F_SETFL, O_APPEND) < 0)
- {
- ulog (LOG_ERROR, "fcntl (%s, O_APPEND): %s", zfile,
- strerror (errno));
- (void) close (o);
- return NULL;
- }
- }
-#endif /* defined (O_APPEND) */
-#endif /* ! defined (O_CREAT) */
-
- if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (%s, FD_CLOEXEC): %s", zfile,
- strerror (errno));
- (void) close (o);
- return NULL;
- }
-
- if (fappend)
- e = fdopen (o, (char *) "a");
- else
- e = fdopen (o, (char *) "w");
-
- if (e == NULL)
- {
- ulog (LOG_ERROR, "fdopen: %s", strerror (errno));
- (void) close (o);
- }
-
- return e;
-}
diff --git a/gnu/libexec/uucp/libunix/epopen.c b/gnu/libexec/uucp/libunix/epopen.c
deleted file mode 100644
index 1873c5c..0000000
--- a/gnu/libexec/uucp/libunix/epopen.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* epopen.c
- A version of popen that goes through ixsspawn.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-
-#include <errno.h>
-
-/* A version of popen that goes through ixsspawn. This actually takes
- an array of arguments rather than a string, and takes a boolean
- read/write value rather than a string. It sets *pipid to the
- process ID of the child. */
-
-FILE *
-espopen (pazargs, frd, pipid)
- const char **pazargs;
- boolean frd;
- pid_t *pipid;
-{
- int aidescs[3];
- pid_t ipid;
- FILE *eret;
-
- if (frd)
- {
- aidescs[0] = SPAWN_NULL;
- aidescs[1] = SPAWN_READ_PIPE;
- }
- else
- {
- aidescs[0] = SPAWN_WRITE_PIPE;
- aidescs[1] = SPAWN_NULL;
- }
- aidescs[2] = SPAWN_NULL;
-
- ipid = ixsspawn (pazargs, aidescs, TRUE, FALSE,
- (const char *) NULL, FALSE, TRUE,
- (const char *) NULL, (const char *) NULL,
- (const char *) NULL);
- if (ipid < 0)
- return NULL;
-
- if (frd)
- eret = fdopen (aidescs[1], (char *) "r");
- else
- eret = fdopen (aidescs[0], (char *) "w");
- if (eret == NULL)
- {
- int ierr;
-
- ierr = errno;
- (void) close (frd ? aidescs[1] : aidescs[0]);
- (void) kill (ipid, SIGKILL);
- (void) ixswait ((unsigned long) ipid, (const char *) NULL);
- errno = ierr;
- return NULL;
- }
-
- *pipid = ipid;
-
- return eret;
-}
diff --git a/gnu/libexec/uucp/libunix/exists.c b/gnu/libexec/uucp/libunix/exists.c
deleted file mode 100644
index 9473922..0000000
--- a/gnu/libexec/uucp/libunix/exists.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* exists.c
- Check whether a file exists. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-#include "system.h"
-
-boolean
-fsysdep_file_exists (zfile)
- const char *zfile;
-{
- struct stat s;
-
- return stat ((char *) zfile, &s) == 0;
-}
diff --git a/gnu/libexec/uucp/libunix/failed.c b/gnu/libexec/uucp/libunix/failed.c
deleted file mode 100644
index 66c98a8..0000000
--- a/gnu/libexec/uucp/libunix/failed.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* failed.c
- Save a file in the .Failed directory. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-#include "uudefs.h"
-#include "system.h"
-
-char *
-zsysdep_save_failed_file (zfile)
- const char *zfile;
-{
- char *zto;
-
- zto = zsappend3 (zSspooldir, FAILEDDIR, zfile);
-
- if (! fsysdep_move_file (zfile, zto, TRUE, FALSE, FALSE,
- (const char *) NULL))
- {
- ubuffree (zto);
- return NULL;
- }
-
- return zto;
-}
diff --git a/gnu/libexec/uucp/libunix/filnam.c b/gnu/libexec/uucp/libunix/filnam.c
deleted file mode 100644
index 6f804bb..0000000
--- a/gnu/libexec/uucp/libunix/filnam.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/* filnam.c
- Get names to use for UUCP files.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-
-/* We need a definition for SEEK_SET. */
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-/* We use POSIX style fcntl locks if they are available, unless
- O_CREAT is not defined. We could use them in the latter case, but
- the code would have to become more complex to avoid races
- concerning the use of creat. It is very unlikely that there is any
- system which does have POSIX style locking but does not have
- O_CREAT. */
-#if ! HAVE_BROKEN_SETLKW
-#ifdef F_SETLKW
-#ifdef O_CREAT
-#define USE_POSIX_LOCKS 1
-#endif
-#endif
-#endif
-#ifndef USE_POSIX_LOCKS
-#define USE_POSIX_LOCKS 0
-#endif
-
-/* External functions. */
-#ifndef lseek
-extern off_t lseek ();
-#endif
-
-#define ZCHARS \
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-
-/* Local functions. */
-
-static boolean fscmd_seq P((const char *zsystem, char *zseq));
-static char *zsfile_name P((int btype, const char *zsystem,
- const char *zlocalname, int bgrade,
- boolean fxqt, char *ztname, char *zdname,
- char *zxname));
-
-/* Get a new command sequence number (this is not a sequence number to
- be used for communicating with another system, but a sequence
- number to be used when generating the name of a command file).
- The sequence number is placed into zseq, which should be five
- characters long. */
-
-static boolean
-fscmd_seq (zsystem, zseq)
- const char *zsystem;
- char *zseq;
-{
- int cdelay;
- char *zfree;
- const char *zfile;
- int o;
- boolean flockfile;
- int i;
- boolean fret;
-
- cdelay = 5;
-
-#if ! USE_POSIX_LOCKS
- {
- boolean ferr;
-
- /* Lock the sequence file. */
- while (! fsdo_lock ("LCK..SEQ", TRUE, &ferr))
- {
- if (ferr || FGOT_SIGNAL ())
- return FALSE;
- sleep (cdelay);
- if (cdelay < 60)
- ++cdelay;
- }
- }
-#endif
-
- zfree = NULL;
-
-#if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43
- zfile = "SEQF";
-#endif
-#if SPOOLDIR_HDB || SPOOLDIR_SVR4
- zfree = zsysdep_in_dir (".Sequence", zsystem);
- zfile = zfree;
-#endif
-#if SPOOLDIR_ULTRIX
- if (! fsultrix_has_spool (zsystem))
- zfile = "sys/DEFAULT/.SEQF";
- else
- {
- zfree = zsappend3 ("sys", zsystem, ".SEQF");
- zfile = zfree;
- }
-#endif /* SPOOLDIR_ULTRIX */
-#if SPOOLDIR_TAYLOR
- zfree = zsysdep_in_dir (zsystem, "SEQF");
- zfile = zfree;
-#endif /* SPOOLDIR_TAYLOR */
-
-#ifdef O_CREAT
- o = open ((char *) zfile, O_RDWR | O_CREAT | O_NOCTTY, IPRIVATE_FILE_MODE);
-#else
- o = open ((char *) zfile, O_RDWR | O_NOCTTY);
- if (o < 0 && errno == ENOENT)
- {
- o = creat ((char *) zfile, IPRIVATE_FILE_MODE);
- if (o >= 0)
- {
- (void) close (o);
- o = open ((char *) zfile, O_RDWR | O_NOCTTY);
- }
- }
-#endif
-
- if (o < 0)
- {
- if (errno == ENOENT)
- {
- if (! fsysdep_make_dirs (zfile, FALSE))
- {
-#if ! USE_POSIX_LOCKS
- (void) fsdo_unlock ("LCK..SEQ", TRUE);
-#endif
- return FALSE;
- }
-#ifdef O_CREAT
- o = open ((char *) zfile,
- O_RDWR | O_CREAT | O_NOCTTY,
- IPRIVATE_FILE_MODE);
-#else
- o = creat ((char *) zfile, IPRIVATE_FILE_MODE);
- if (o >= 0)
- {
- (void) close (o);
- o = open ((char *) zfile, O_RDWR | O_NOCTTY);
- }
-#endif
- }
- if (o < 0)
- {
- ulog (LOG_ERROR, "open (%s): %s", zfile, strerror (errno));
-#if ! USE_POSIX_LOCKS
- (void) fsdo_unlock ("LCK..SEQ", TRUE);
-#endif
- return FALSE;
- }
- }
-
-#if ! USE_POSIX_LOCKS
- flockfile = TRUE;
-#else
- {
- struct flock slock;
-
- flockfile = FALSE;
-
- slock.l_type = F_WRLCK;
- slock.l_whence = SEEK_SET;
- slock.l_start = 0;
- slock.l_len = 0;
- while (fcntl (o, F_SETLKW, &slock) == -1)
- {
- boolean fagain;
-
- /* Some systems define F_SETLKW, but it does not work. We try
- to catch those systems at runtime, and revert to using a
- lock file. */
- if (errno == EINVAL)
- {
- boolean ferr;
-
- /* Lock the sequence file. */
- while (! fsdo_lock ("LCK..SEQ", TRUE, &ferr))
- {
- if (ferr || FGOT_SIGNAL ())
- {
- (void) close (o);
- return FALSE;
- }
- sleep (cdelay);
- if (cdelay < 60)
- ++cdelay;
- }
-
- flockfile = TRUE;
-
- break;
- }
-
- fagain = FALSE;
- if (errno == ENOMEM)
- fagain = TRUE;
-#ifdef ENOLCK
- if (errno == ENOLCK)
- fagain = TRUE;
-#endif
-#ifdef ENOSPC
- if (errno == ENOSPC)
- fagain = TRUE;
-#endif
- if (fagain)
- {
- sleep (cdelay);
- if (cdelay < 60)
- ++cdelay;
- continue;
- }
- ulog (LOG_ERROR, "Locking %s: %s", zfile, strerror (errno));
- (void) close (o);
- return FALSE;
- }
- }
-#endif
-
- if (read (o, zseq, CSEQLEN) != CSEQLEN)
- strcpy (zseq, "0000");
- zseq[CSEQLEN] = '\0';
-
- /* We must add one to the sequence number and return the new value.
- On Ultrix, arbitrary characters are allowed in the sequence
- number. On other systems, the sequence number apparently must be
- in hex. */
-#if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43 || SPOOLDIR_HDB || SPOOLDIR_SVR4
- i = (int) strtol (zseq, (char **) NULL, 16);
- ++i;
- if (i > 0xffff)
- i = 0;
- /* The sprintf argument has CSEQLEN built into it. */
- sprintf (zseq, "%04x", (unsigned int) i);
-#endif
-#if SPOOLDIR_ULTRIX || SPOOLDIR_TAYLOR
- for (i = CSEQLEN - 1; i >= 0; i--)
- {
- const char *zdig;
-
- zdig = strchr (ZCHARS, zseq[i]);
- if (zdig == NULL || zdig[0] == '\0' || zdig[1] == '\0')
- zseq[i] = '0';
- else
- {
- zseq[i] = zdig[1];
- break;
- }
- }
-#endif /* SPOOLDIR_ULTRIX || SPOOLDIR_TAYLOR */
-
- fret = TRUE;
-
- if (lseek (o, (off_t) 0, SEEK_SET) < 0
- || write (o, zseq, CSEQLEN) != CSEQLEN
- || close (o) < 0)
- {
- ulog (LOG_ERROR, "lseek or write or close %s: %s",
- zfile, strerror (errno));
- (void) close (o);
- fret = FALSE;
- }
-
- if (flockfile)
- (void) fsdo_unlock ("LCK..SEQ", TRUE);
-
- ubuffree (zfree);
-
- return fret;
-}
-
-/* Get the name of a command or data file for a remote system. The
- btype argument should be C for a command file or D for a data file.
- If the grade of a data file is X, it is assumed that this is going
- to become an execute file on some other system. The zsystem
- argument is the system that the file will be transferred to. The
- ztname argument will be set to a file name that could be passed to
- zsysdep_spool_file_name. The zdname argument, if not NULL, will be
- set to a data file name appropriate for the remote system. The
- zxname argument, if not NULL, will be set to the name of an execute
- file on the remote system. None of the names will be more than 14
- characters long. */
-
-/*ARGSUSED*/
-static char *
-zsfile_name (btype, zsystem, zlocalname, bgrade, fxqt, ztname, zdname, zxname)
- int btype;
- const char *zsystem;
- const char *zlocalname;
- int bgrade;
- boolean fxqt;
- char *ztname;
- char *zdname;
- char *zxname;
-{
- char abseq[CSEQLEN + 1];
- char absimple[11 + CSEQLEN];
- char *zname;
-
- if (zlocalname == NULL)
- zlocalname = zSlocalname;
-
- while (TRUE)
- {
- if (! fscmd_seq (zsystem, abseq))
- return NULL;
-
- if (btype == 'C')
- {
-#if ! SPOOLDIR_TAYLOR
- sprintf (absimple, "C.%.7s%c%s", zsystem, bgrade, abseq);
-#else
- sprintf (absimple, "C.%c%s", bgrade, abseq);
-#endif
- }
- else if (btype == 'D')
- {
- /* This name doesn't really matter that much; it's just the
- name we use on the local system. The name we use on the
- remote system, which we return in zdname, should contain
- our system name so that remote UUCP's running SPOOLDIR_V2
- and the like can distinguish while files come from which
- systems. */
-#if SPOOLDIR_SVR4
- sprintf (absimple, "D.%.7s%c%s", zsystem, bgrade, abseq);
-#else /* ! SPOOLDIR_SVR4 */
-#if ! SPOOLDIR_TAYLOR
- sprintf (absimple, "D.%.7s%c%s", zlocalname, bgrade, abseq);
-#else /* SPOOLDIR_TAYLOR */
- if (fxqt)
- sprintf (absimple, "D.X%s", abseq);
- else
- sprintf (absimple, "D.%s", abseq);
-#endif /* SPOOLDIR_TAYLOR */
-#endif /* ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 */
- }
-#if DEBUG > 0
- else
- ulog (LOG_FATAL, "zsfile_name: Can't happen");
-#endif
-
- zname = zsfind_file (absimple, zsystem, bgrade);
- if (zname == NULL)
- return NULL;
-
- if (! fsysdep_file_exists (zname))
- break;
-
- ubuffree (zname);
- }
-
- if (ztname != NULL)
- strcpy (ztname, absimple);
-
- if (zdname != NULL)
- sprintf (zdname, "D.%.7s%c%s", zlocalname, bgrade, abseq);
-
- if (zxname != NULL)
- sprintf (zxname, "X.%.7s%c%s", zlocalname, bgrade, abseq);
-
- return zname;
-}
-
-/* Return a name to use for a data file to be copied to another
- system. The name returned will be for a real file. The zlocalname
- argument is the local name as seen by the remote system, the bgrade
- argument is the file grade, and the fxqt argument is TRUE if this
- file will become an execution file. The ztname argument, if not
- NULL, will be set to a name that could be passed to
- zsysdep_spool_file_name to get back the return value of this
- function. The zdname argument, if not NULL, will be set to a name
- that the file could be given on another system. The zxname
- argument, if not NULL, will be set to a name for an execute file on
- another system. */
-
-char *
-zsysdep_data_file_name (qsys, zlocalname, bgrade, fxqt, ztname, zdname,
- zxname)
- const struct uuconf_system *qsys;
- const char *zlocalname;
- int bgrade;
- boolean fxqt;
- char *ztname;
- char *zdname;
- char *zxname;
-{
- return zsfile_name ('D', qsys->uuconf_zname, zlocalname, bgrade, fxqt,
- ztname, zdname, zxname);
-}
-
-#if SPOOLDIR_TAYLOR
-
-/* Write out a number in base 62 into a given number of characters,
- right justified with zero fill. This is used by zscmd_file if
- SPOOLDIR_TAYLOR. */
-
-static void usput62 P((long i, char *, int c));
-
-static void
-usput62 (i, z, c)
- long i;
- char *z;
- int c;
-{
- for (--c; c >= 0; --c)
- {
- int d;
-
- d = i % 62;
- i /= 62;
- if (d < 26)
- z[c] = 'A' + d;
- else if (d < 52)
- z[c] = 'a' + d - 26;
- else
- z[c] = '0' + d - 52;
- }
-}
-
-#endif /* SPOOLDIR_TAYLOR */
-
-/* Get a command file name. */
-
-char *
-zscmd_file (qsys, bgrade)
- const struct uuconf_system *qsys;
- int bgrade;
-{
-#if ! SPOOLDIR_TAYLOR
- return zsfile_name ('C', qsys->uuconf_zname, (const char *) NULL,
- bgrade, FALSE, (char *) NULL, (char *) NULL,
- (char *) NULL);
-#else
- char *zname;
- long isecs, imicros;
- pid_t ipid;
-
- /* This file name is never seen by the remote system, so we don't
- actually need to get a sequence number for it. We just need to
- get a file name which is unique for this system. We don't try
- this optimization for other spool directory formats, mainly due
- to compatibility concerns. It would be possible for HDB and SVR4
- spool directory formats.
-
- We get a unique name by combining the process ID and the current
- time. The file name must start with C.g, where g is the grade.
- Note that although it is likely that this name will be unique, it
- is not guaranteed, so the caller must be careful. */
-
- isecs = ixsysdep_time (&imicros);
- ipid = getpid ();
-
- /* We are going to represent the file name as a series of numbers in
- base 62 (using the alphanumeric characters). The maximum file
- name length is 14 characters, so we may use 11. We use 3 for the
- seconds within the day, 3 for the microseconds, and 5 for the
- process ID. */
-
- /* Cut the seconds down to a number within a day (maximum value
- 86399 < 62 ** 3 == 238328). */
- isecs %= (long) 24 * (long) 60 * (long) 60;
- /* Divide the microseconds (max 999999) by 5 to make sure they are
- less than 62 ** 3. */
- imicros %= 1000000;
- imicros /= 5;
-
- while (TRUE)
- {
- char ab[15];
-
- ab[0] = 'C';
- ab[1] = '.';
- ab[2] = bgrade;
- usput62 (isecs, ab + 3, 3);
- usput62 (imicros, ab + 6, 3);
- usput62 ((long) ipid, ab + 9, 5);
- ab[14] = '\0';
-
- zname = zsfind_file (ab, qsys->uuconf_zname, bgrade);
- if (zname == NULL)
- return NULL;
-
- if (! fsysdep_file_exists (zname))
- break;
-
- ubuffree (zname);
-
- /* We hit a duplicate. Move backward in time until we find an
- available name. Note that there is still a theoretical race
- condition, since 5 base 62 digits might not be enough for the
- process ID, and some other process might be running these
- checks at the same time as we are. The caller must deal with
- this. */
- if (imicros == 0)
- {
- imicros = (long) 62 * (long) 62 * (long) 62;
- if (isecs == 0)
- isecs = (long) 62 * (long) 62 * (long) 62;
- --isecs;
- }
- --imicros;
- }
-
- return zname;
-
-#endif
-}
-
-/* Return a name for an execute file to be created locally. This is
- used by uux to execute a command locally with remote files. */
-
-char *
-zsysdep_xqt_file_name ()
-{
- char abseq[CSEQLEN + 1];
- char absx[11 + CSEQLEN];
- char *zname;
-
- while (TRUE)
- {
- if (! fscmd_seq (zSlocalname, abseq))
- return NULL;
-
- sprintf (absx, "X.%.7sX%s", zSlocalname, abseq);
-
- zname = zsfind_file (absx, zSlocalname, -1);
- if (zname == NULL)
- return NULL;
-
- if (! fsysdep_file_exists (zname))
- break;
-
- ubuffree (zname);
- }
-
- return zname;
-}
diff --git a/gnu/libexec/uucp/libunix/fsusg.c b/gnu/libexec/uucp/libunix/fsusg.c
deleted file mode 100644
index 9189193..0000000
--- a/gnu/libexec/uucp/libunix/fsusg.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/* fsusage.c -- return space usage of mounted filesystems
- Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- This file was modified slightly by Ian Lance Taylor, December 1992,
- and again July 1995, for use with Taylor UUCP. */
-
-#include "uucp.h"
-#include "uudefs.h"
-#include "sysdep.h"
-#include "fsusg.h"
-
-int statfs ();
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#if HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-
-#if HAVE_SYS_VFS_H
-#include <sys/vfs.h>
-#endif
-
-#if HAVE_SYS_FILSYS_H
-#include <sys/filsys.h> /* SVR2. */
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#if HAVE_SYS_STATFS_H
-#include <sys/statfs.h>
-#endif
-
-#if HAVE_SYS_DUSTAT_H /* AIX PS/2. */
-#include <sys/dustat.h>
-#endif
-
-#if HAVE_SYS_STATVFS_H /* SVR4. */
-#include <sys/statvfs.h>
-int statvfs ();
-#endif
-
-#if HAVE_USTAT_H /* SVR2 and others. */
-#include <ustat.h>
-#endif
-
-#if STAT_DISK_SPACE /* QNX. */
-#include <sys/disk.h>
-#include <errno.h>
-#endif
-
-#define STAT_NONE 0
-
-#if ! STAT_STATFS3_OSF1
-#if ! STAT_STATFS2_FS_DATA
-#if ! STAT_STATFS2_BSIZE
-#if ! STAT_STATFS2_FSIZE
-#if ! STAT_STATFS4
-#if ! STAT_STATVFS
-#if ! STAT_DISK_SPACE
-#if ! STAT_USTAT
-#undef STAT_NONE
-#define STAT_NONE 1
-#endif
-#endif
-#endif
-#endif
-#endif
-#endif
-#endif
-#endif
-
-#if ! STAT_NONE
-
-static long adjust_blocks P((long blocks, int fromsize, int tosize));
-
-/* Return the number of TOSIZE-byte blocks used by
- BLOCKS FROMSIZE-byte blocks, rounding away from zero.
- TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */
-
-static long
-adjust_blocks (blocks, fromsize, tosize)
- long blocks;
- int fromsize, tosize;
-{
- if (tosize <= 0)
- abort ();
- if (fromsize <= 0)
- return -1;
-
- if (fromsize == tosize) /* E.g., from 512 to 512. */
- return blocks;
- else if (fromsize > tosize) /* E.g., from 2048 to 512. */
- return blocks * (fromsize / tosize);
- else /* E.g., from 256 to 512. */
- return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize);
-}
-
-#endif
-
-/* Fill in the fields of FSP with information about space usage for
- the filesystem on which PATH resides.
- DISK is the device on which PATH is mounted, for space-getting
- methods that need to know it.
- Return 0 if successful, -1 if not. */
-
-int
-get_fs_usage (path, disk, fsp)
- char *path, *disk;
- struct fs_usage *fsp;
-{
-#if STAT_NONE
- return -1;
-#endif
-
-#if STAT_STATFS3_OSF1
- struct statfs fsd;
-
- if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
- return -1;
-#define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_fsize, 512)
-#endif /* STAT_STATFS3_OSF1 */
-
-#if STAT_STATFS2_FS_DATA /* Ultrix. */
- struct fs_data fsd;
-
- if (statfs (path, &fsd) != 1)
- return -1;
-#define CONVERT_BLOCKS(b) adjust_blocks ((long) (b), 1024, 512)
- fsp->fsu_blocks = CONVERT_BLOCKS (fsd.fd_req.btot);
- fsp->fsu_bfree = CONVERT_BLOCKS (fsd.fd_req.bfree);
- fsp->fsu_bavail = CONVERT_BLOCKS (fsd.fd_req.bfreen);
- fsp->fsu_files = fsd.fd_req.gtot;
- fsp->fsu_ffree = fsd.fd_req.gfree;
-#endif
-
-#if STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX. */
- struct statfs fsd;
-
- if (statfs (path, &fsd) < 0)
- return -1;
-#define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_bsize, 512)
-#endif
-
-#if STAT_STATFS2_FSIZE /* 4.4BSD. */
- struct statfs fsd;
-
- if (statfs (path, &fsd) < 0)
- return -1;
-#define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_fsize, 512)
-#endif
-
-#if STAT_STATFS4 /* SVR3, Dynix, Irix. */
- struct statfs fsd;
-
- if (statfs (path, &fsd, sizeof fsd, 0) < 0)
- return -1;
- /* Empirically, the block counts on most SVR3 and SVR3-derived
- systems seem to always be in terms of 512-byte blocks,
- no matter what value f_bsize has. */
-# if _AIX
-# define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_bsize, 512)
-# else
-# define CONVERT_BLOCKS(b) (b)
-# ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx. */
-# ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */
-# define f_bavail f_bfree
-# endif
-# endif
-# endif
-#endif
-
-#if STAT_STATVFS /* SVR4. */
- struct statvfs fsd;
-
- if (statvfs (path, &fsd) < 0)
- return -1;
- /* f_frsize isn't guaranteed to be supported. */
-#define CONVERT_BLOCKS(b) \
- adjust_blocks ((b), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512)
-#endif
-
-#if STAT_DISK_SPACE /* QNX. */
- int o;
- int iret;
- long cfree_blocks, ctotal_blocks;
- char *zpath;
- char *zslash;
-
- zpath = zbufcpy (path);
- while ((o = open (zpath, O_RDONLY, 0)) == -1
- && errno == ENOENT)
- {
- /* The named file doesn't exist, so we can't open it. Try the
- directory containing it. */
- if ((strcmp ("/", zpath) == 0)
- || (strcmp (zpath, ".") == 0)
- || (strcmp (zpath, "") == 0)
- /* QNX peculiarity: "//2" means root on node 2 */
- || ((strncmp (zpath, "//", 2) == 0)
- && (strchr (zpath + 2, '/') == NULL)))
- {
- /* We can't shorten this! */
- break;
- }
-
- /* Shorten the pathname by one component and try again. */
- zslash = strrchr (zpath, '/');
- if (zslash == NULL)
- {
- /* Try the current directory. We can open directories. */
- zpath[0] = '.';
- zpath[1] = '\0';
- }
- else if (zslash == zpath)
- {
- /* Try the root directory. */
- zpath[0] = '/';
- zpath[1] = '\0';
- }
- else
- {
- /* Chop off last path component. */
- zslash[0] = '\0';
- }
- }
- if (o == -1)
- {
- ulog (LOG_ERROR, "get_fs_usage: open (%s) failed: %s", zpath,
- strerror (errno));
- ubuffree (zpath);
- return -1;
- }
- ubuffree (zpath);
-
- iret = disk_space (o, &cfree_blocks, &ctotal_blocks);
- (void) close (o);
- if (iret == -1)
- {
- ulog (LOG_ERROR, "get_fs_usage: disk_space failed: %s",
- strerror (errno));
- return -1;
- }
-
- fsp->fsu_blocks = ctotal_blocks;
- fsp->fsu_bfree = cfree_blocks;
- fsp->fsu_bavail = cfree_blocks;
-
- /* QNX has no limit on the number of inodes. Most inodes are stored
- directly in the directory entry. */
- fsp->fsu_files = -1;
- fsp->fsu_ffree = -1;
-#endif /* STAT_DISK_SPACE */
-
-#if STAT_USTAT
- struct stat sstat;
- struct ustat s;
-
- if (stat (path, &sstat) < 0
- || ustat (sstat.st_dev, &s) < 0)
- return -1;
- fsp->fsu_blocks = -1;
- fsp->fsu_bfree = s.f_tfree;
- fsp->fsu_bavail = s.f_tfree;
- fsp->fsu_files = -1;
- fsp->fsu_ffree = -1;
-#endif
-
-#if ! STAT_STATFS2_FS_DATA /* ! Ultrix */
-#if ! STAT_DISK_SPACE
-#if ! STAT_USTAT
-#if ! STAT_NONE
- fsp->fsu_blocks = CONVERT_BLOCKS (fsd.f_blocks);
- fsp->fsu_bfree = CONVERT_BLOCKS (fsd.f_bfree);
- fsp->fsu_bavail = CONVERT_BLOCKS (fsd.f_bavail);
- fsp->fsu_files = fsd.f_files;
- fsp->fsu_ffree = fsd.f_ffree;
-#endif
-#endif
-#endif
-#endif
-
- return 0;
-}
-
-#ifdef _AIX
-#ifdef _I386
-/* AIX PS/2 does not supply statfs. */
-
-int
-statfs (path, fsb)
- char *path;
- struct statfs *fsb;
-{
- struct stat stats;
- struct dustat fsd;
-
- if (stat (path, &stats))
- return -1;
- if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd)))
- return -1;
- fsb->f_type = 0;
- fsb->f_bsize = fsd.du_bsize;
- fsb->f_blocks = fsd.du_fsize - fsd.du_isize;
- fsb->f_bfree = fsd.du_tfree;
- fsb->f_bavail = fsd.du_tfree;
- fsb->f_files = (fsd.du_isize - 2) * fsd.du_inopb;
- fsb->f_ffree = fsd.du_tinode;
- fsb->f_fsid.val[0] = fsd.du_site;
- fsb->f_fsid.val[1] = fsd.du_pckno;
- return 0;
-}
-#endif /* _I386 */
-#endif /* _AIX */
diff --git a/gnu/libexec/uucp/libunix/fsusg.h b/gnu/libexec/uucp/libunix/fsusg.h
deleted file mode 100644
index 2b9ddd5..0000000
--- a/gnu/libexec/uucp/libunix/fsusg.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* fsusage.h -- declarations for filesystem space usage info
- Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- This files was modified slightly by Ian Lance Taylor for use with
- Taylor UUCP. */
-
-/* Space usage statistics for a filesystem. Blocks are 512-byte. */
-struct fs_usage
-{
- long fsu_blocks; /* Total blocks. */
- long fsu_bfree; /* Free blocks available to superuser. */
- long fsu_bavail; /* Free blocks available to non-superuser. */
- long fsu_files; /* Total file nodes. */
- long fsu_ffree; /* Free file nodes. */
-};
-
-extern int get_fs_usage P((char *path, char *disk, struct fs_usage *fsp));
diff --git a/gnu/libexec/uucp/libunix/ftw.c b/gnu/libexec/uucp/libunix/ftw.c
deleted file mode 100644
index f7af66f..0000000
--- a/gnu/libexec/uucp/libunix/ftw.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-Contributed by Ian Lance Taylor (ian@airs.com).
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place -
-Suite 330, Boston, MA 02111-1307, USA.
-
-Modified by Ian Lance Taylor for Taylor UUCP, June 1992, and October 1993. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-
-#include <errno.h>
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#if HAVE_OPENDIR
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#else /* ! HAVE_DIRENT_H */
-#include <sys/dir.h>
-#define dirent direct
-#endif /* ! HAVE_DIRENT_H */
-#endif /* HAVE_OPENDIR */
-
-#if HAVE_FTW_H
-#include <ftw.h>
-#endif
-
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-
-/* Traverse one level of a directory tree. */
-
-static int
-ftw_dir (dirs, level, descriptors, dir, len, func)
- DIR **dirs;
- int level;
- int descriptors;
- char *dir;
- size_t len;
- int (*func) P((const char *file, struct stat *status, int flag));
-{
- int got;
- struct dirent *entry;
-
- got = 0;
-
- errno = 0;
-
- while ((entry = readdir (dirs[level])) != NULL)
- {
- size_t namlen;
- struct stat s;
- int flag, ret, newlev = 0;
-
- ++got;
-
- namlen = strlen (entry->d_name);
- if (entry->d_name[0] == '.'
- && (namlen == 1 ||
- (namlen == 2 && entry->d_name[1] == '.')))
- {
- errno = 0;
- continue;
- }
-
- if (namlen + len + 1 > PATH_MAX)
- {
-#ifdef ENAMETOOLONG
- errno = ENAMETOOLONG;
-#else
- errno = ENOMEM;
-#endif
- return -1;
- }
-
- dir[len] = '/';
- memcpy ((dir + len + 1), entry->d_name, namlen + 1);
-
- if (stat (dir, &s) < 0)
- {
- if (errno != EACCES)
- return -1;
- flag = FTW_NS;
- }
- else if (S_ISDIR (s.st_mode))
- {
- newlev = (level + 1) % descriptors;
-
- if (dirs[newlev] != NULL)
- closedir (dirs[newlev]);
-
- dirs[newlev] = opendir (dir);
- if (dirs[newlev] != NULL)
- flag = FTW_D;
- else
- {
- if (errno != EACCES)
- return -1;
- flag = FTW_DNR;
- }
- }
- else
- flag = FTW_F;
-
- ret = (*func) (dir, &s, flag);
-
- if (flag == FTW_D)
- {
- if (ret == 0)
- ret = ftw_dir (dirs, newlev, descriptors, dir,
- namlen + len + 1, func);
- if (dirs[newlev] != NULL)
- {
- int save;
-
- save = errno;
- closedir (dirs[newlev]);
- errno = save;
- dirs[newlev] = NULL;
- }
- }
-
- if (ret != 0)
- return ret;
-
- if (dirs[level] == NULL)
- {
- int skip;
-
- dir[len] = '\0';
- dirs[level] = opendir (dir);
- if (dirs[level] == NULL)
- return -1;
- skip = got;
- while (skip-- != 0)
- {
- errno = 0;
- if (readdir (dirs[level]) == NULL)
- return errno == 0 ? 0 : -1;
- }
- }
-
- errno = 0;
- }
-
- return errno == 0 ? 0 : -1;
-}
-
-/* Call a function on every element in a directory tree. */
-
-int
-ftw (dir, func, descriptors)
- const char *dir;
- int (*func) P((const char *file, struct stat *status, int flag));
- int descriptors;
-{
- DIR **dirs;
- int c;
- DIR **p;
- size_t len;
- char buf[PATH_MAX + 1];
- struct stat s;
- int flag, ret;
-
- if (descriptors <= 0)
- descriptors = 1;
-
- dirs = (DIR **) malloc (descriptors * sizeof (DIR *));
- if (dirs == NULL)
- return -1;
- c = descriptors;
- p = dirs;
- while (c-- != 0)
- *p++ = NULL;
-
- len = strlen (dir);
- memcpy (buf, dir, len + 1);
-
- if (stat (dir, &s) < 0)
- {
- if (errno != EACCES)
- {
- free ((pointer) dirs);
- return -1;
- }
- flag = FTW_NS;
- }
- else if (S_ISDIR (s.st_mode))
- {
- dirs[0] = opendir (dir);
- if (dirs[0] != NULL)
- flag = FTW_D;
- else
- {
- if (errno != EACCES)
- {
- free ((pointer) dirs);
- return -1;
- }
- flag = FTW_DNR;
- }
- }
- else
- flag = FTW_F;
-
- ret = (*func) (buf, &s, flag);
-
- if (flag == FTW_D)
- {
- if (ret == 0)
- {
- if (len == 1 && *buf == '/')
- len = 0;
- ret = ftw_dir (dirs, 0, descriptors, buf, len, func);
- }
- if (dirs[0] != NULL)
- {
- int save;
-
- save = errno;
- closedir (dirs[0]);
- errno = save;
- }
- }
-
- free ((pointer) dirs);
- return ret;
-}
diff --git a/gnu/libexec/uucp/libunix/getcwd.c b/gnu/libexec/uucp/libunix/getcwd.c
deleted file mode 100644
index d3623bd..0000000
--- a/gnu/libexec/uucp/libunix/getcwd.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* getcwd.c
- Replacement for the getcwd function that just calls /bin/pwd. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-
-#include <errno.h>
-
-char *
-getcwd (zbuf, cbuf)
- char *zbuf;
- size_t cbuf;
-{
- const char *azargs[2];
- FILE *e;
- pid_t ipid;
- int cread;
- int ierr;
-
- azargs[0] = PWD_PROGRAM;
- azargs[1] = NULL;
- e = espopen (azargs, TRUE, &ipid);
- if (e == NULL)
- return NULL;
-
- ierr = 0;
-
- cread = fread (zbuf, sizeof (char), cbuf, e);
- if (cread == 0)
- ierr = errno;
-
- (void) fclose (e);
-
- if (ixswait ((unsigned long) ipid, (const char *) NULL) != 0)
- {
- ierr = EACCES;
- cread = 0;
- }
-
- if (cread != 0)
- {
- if (zbuf[cread - 1] == '\n')
- zbuf[cread - 1] = '\0';
- else
- {
- ierr = ERANGE;
- cread = 0;
- }
- }
-
- if (cread == 0)
- {
- errno = ierr;
- return NULL;
- }
-
- return zbuf;
-}
diff --git a/gnu/libexec/uucp/libunix/indir.c b/gnu/libexec/uucp/libunix/indir.c
deleted file mode 100644
index 88cdb0e..0000000
--- a/gnu/libexec/uucp/libunix/indir.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* indir.c
- See if a file is in a directory.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-/* See whether a file is in a directory, and optionally check access. */
-
-boolean
-fsysdep_in_directory (zfile, zdir, fcheck, freadable, zuser)
- const char *zfile;
- const char *zdir;
- boolean fcheck;
- boolean freadable;
- const char *zuser;
-{
- size_t c;
- char *zcopy, *zslash;
- struct stat s;
-
- if (*zfile != '/')
- return FALSE;
- c = strlen (zdir);
- if (c > 0 && zdir[c - 1] == '/')
- c--;
- if (strncmp (zfile, zdir, c) != 0
- || (zfile[c] != '/' && zfile[c] != '\0'))
- return FALSE;
- if (strstr (zfile + c, "/../") != NULL)
- return FALSE;
-
- /* If we're not checking access, get out now. */
- if (! fcheck)
- return TRUE;
-
- zcopy = zbufcpy (zfile);
-
- /* Start checking directories after zdir. Otherwise, we would
- require that all directories down to /usr/spool/uucppublic be
- publically searchable; they probably are but it should not be a
- requirement. */
- zslash = zcopy + c;
- do
- {
- char b;
- struct stat shold;
-
- b = *zslash;
- *zslash = '\0';
-
- shold = s;
- if (stat (zcopy, &s) != 0)
- {
- if (errno != ENOENT)
- {
- ulog (LOG_ERROR, "stat (%s): %s", zcopy, strerror (errno));
- ubuffree (zcopy);
- return FALSE;
- }
-
- /* If this is the top directory, any problems will be caught
- later when we try to open it. */
- if (zslash == zcopy + c)
- {
- ubuffree (zcopy);
- return TRUE;
- }
-
- /* Go back and check the last directory for read or write
- access. */
- s = shold;
- break;
- }
-
- /* If this is not a directory, get out of the loop. */
- if (! S_ISDIR (s.st_mode))
- break;
-
- /* Make sure the directory is searchable. */
- if (! fsuser_access (&s, X_OK, zuser))
- {
- ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES));
- ubuffree (zcopy);
- return FALSE;
- }
-
- /* If we've reached the end of the string, get out. */
- if (b == '\0')
- break;
-
- *zslash = b;
- }
- while ((zslash = strchr (zslash + 1, '/')) != NULL);
-
- /* At this point s holds a stat on the last component of the path.
- We must check it for readability or writeability. */
- if (! fsuser_access (&s, freadable ? R_OK : W_OK, zuser))
- {
- ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES));
- ubuffree (zcopy);
- return FALSE;
- }
-
- ubuffree (zcopy);
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/init.c b/gnu/libexec/uucp/libunix/init.c
deleted file mode 100644
index 8a3c416..0000000
--- a/gnu/libexec/uucp/libunix/init.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/* init.c
- Initialize the system dependent routines.
-
- Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "sysdep.h"
-
-#include <errno.h>
-#include <pwd.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#if ! HAVE_GETHOSTNAME && HAVE_UNAME
-#include <sys/utsname.h>
-#endif
-
-/* Use getcwd in preference to getwd; if we have neither, we will be
- using a getcwd replacement. */
-#if HAVE_GETCWD
-#undef HAVE_GETWD
-#define HAVE_GETWD 0
-#else /* ! HAVE_GETCWD */
-#if ! HAVE_GETWD
-#undef HAVE_GETCWD
-#define HAVE_GETCWD 1
-#endif /* ! HAVE_GETWD */
-#endif /* ! HAVE_GETCWD */
-
-#if HAVE_GETWD
-/* Get a value for MAXPATHLEN. */
-#if HAVE_SYS_PARAMS_H
-#include <sys/params.h>
-#endif
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#ifndef MAXPATHLEN
-#ifdef PATH_MAX
-#define MAXPATHLEN PATH_MAX
-#else /* ! defined (PATH_MAX) */
-#define MAXPATHLEN 1024
-#endif /* ! defined (PATH_MAX) */
-#endif /* ! defined (MAXPATHLEN) */
-#endif /* HAVE_GETWD */
-
-/* External functions. */
-#ifndef getlogin
-extern char *getlogin ();
-#endif
-#if GETPWNAM_DECLARATION_OK
-#ifndef getpwnam
-extern struct passwd *getpwnam ();
-#endif
-#endif
-#if GETPWUID_DECLARATION_OK
-#ifndef getpwuid
-extern struct passwd *getpwuid ();
-#endif
-#endif
-#if HAVE_GETCWD
-#ifndef getcwd
-extern char *getcwd ();
-#endif
-#endif
-#if HAVE_GETWD
-#ifndef getwd
-extern char *getwd ();
-#endif
-#endif
-#if HAVE_SYSCONF
-#ifndef sysconf
-extern long sysconf ();
-#endif
-#endif
-
-/* Initialize the system dependent routines. We will probably be running
- suid to uucp, so we make sure that nothing is obviously wrong. We
- save the login name since we will be losing the real uid. */
-static char *zSlogin;
-
-/* The UUCP spool directory. */
-const char *zSspooldir;
-
-/* The UUCP lock directory. */
-const char *zSlockdir;
-
-/* The local UUCP name. */
-const char *zSlocalname;
-
-/* We save the current directory since we will do a chdir to the
- spool directory. */
-char *zScwd;
-
-/* The maximum length of a system name is controlled by the type of spool
- directory we use. */
-#if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43 || SPOOLDIR_ULTRIX
-size_t cSysdep_max_name_len = 7;
-#endif
-#if SPOOLDIR_HDB || SPOOLDIR_SVR4
-size_t cSysdep_max_name_len = 14;
-#endif
-#if SPOOLDIR_TAYLOR
-#if HAVE_LONG_FILE_NAMES
-size_t cSysdep_max_name_len = 255;
-#else /* ! HAVE_LONG_FILE_NAMES */
-size_t cSysdep_max_name_len = 14;
-#endif /* ! HAVE_LONG_FILE_NAMES */
-#endif /* SPOOLDIR_TAYLOR */
-
-/* Initialize the system dependent routines. */
-
-void
-usysdep_initialize (puuconf,iflags)
- pointer puuconf;
- int iflags;
-{
- int iuuconf;
- char *z;
- struct passwd *q;
-
- ulog_id (getpid ());
-
- if ((iflags & INIT_NOCLOSE) == 0)
- {
- int cdescs;
- int o;
-
- /* Close everything but stdin, stdout and stderr. */
-#if HAVE_GETDTABLESIZE
- cdescs = getdtablesize ();
-#else
-#if HAVE_SYSCONF
- cdescs = sysconf (_SC_OPEN_MAX);
-#else
-#ifdef OPEN_MAX
- cdescs = OPEN_MAX;
-#else
-#ifdef NOFILE
- cdescs = NOFILE;
-#else
- cdescs = 20;
-#endif /* ! defined (NOFILE) */
-#endif /* ! defined (OPEN_MAX) */
-#endif /* ! HAVE_SYSCONF */
-#endif /* ! HAVE_GETDTABLESIZE */
-
- for (o = 3; o < cdescs; o++)
- (void) close (o);
- }
-
- /* Make sure stdin, stdout and stderr are open. */
- if (fcntl (0, F_GETFD, 0) < 0
- && open ((char *) "/dev/null", O_RDONLY, 0) != 0)
- exit (EXIT_FAILURE);
- if (fcntl (1, F_GETFD, 0) < 0
- && open ((char *) "/dev/null", O_WRONLY, 0) != 1)
- exit (EXIT_FAILURE);
- if (fcntl (2, F_GETFD, 0) < 0
- && open ((char *) "/dev/null", O_WRONLY, 0) != 2)
- exit (EXIT_FAILURE);
-
- iuuconf = uuconf_spooldir (puuconf, &zSspooldir);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- iuuconf = uuconf_lockdir (puuconf, &zSlockdir);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- iuuconf = uuconf_localname (puuconf, &zSlocalname);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
-#if HAVE_GETHOSTNAME
- char ab[256];
-
- if (gethostname (ab, sizeof ab - 1) < 0)
- ulog (LOG_FATAL, "gethostname: %s", strerror (errno));
- ab[sizeof ab - 1] = '\0';
- ab[strcspn (ab, ".")] = '\0';
- zSlocalname = zbufcpy (ab);
-#else /* ! HAVE_GETHOSTNAME */
-#if HAVE_UNAME
- struct utsname s;
-
- if (uname (&s) < 0)
- ulog (LOG_FATAL, "uname: %s", strerror (errno));
- zSlocalname = zbufcpy (s.nodename);
-#else /* ! HAVE_UNAME */
- ulog (LOG_FATAL, "Don't know how to get local node name");
-#endif /* ! HAVE_UNAME */
-#endif /* ! HAVE_GETHOSTNAME */
- }
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- /* We always set our file modes to exactly what we want. */
- umask (0);
-
- /* Get the login name, making sure that it matches the uid. Many
- systems truncate the getlogin return value to 8 characters, but
- keep the full name in the password file, so we prefer the name in
- the password file. */
- z = getenv ("LOGNAME");
- if (z == NULL)
- z = getenv ("USER");
- if (z == NULL)
- z = getlogin ();
- if (z == NULL)
- q = NULL;
- else
- {
- q = getpwnam (z);
- if (q != NULL)
- z = q->pw_name;
- }
- if (q == NULL || q->pw_uid != getuid ())
- {
- q = getpwuid (getuid ());
- if (q == NULL)
- z = NULL;
- else
- z = q->pw_name;
- }
- if (z != NULL)
- zSlogin = zbufcpy (z);
-
- /* On some old systems, an suid program run by root is started with
- an euid of 0. If this happens, we look up the uid we should have
- and set ourselves to it manually. This means that on such a
- system root will not be able to uucp or uux files that are not
- readable by uucp. */
- if ((iflags & INIT_SUID) != 0
- && geteuid () == 0)
- {
- q = getpwnam (OWNER);
- if (q != NULL)
- setuid (q->pw_uid);
- }
-
- if ((iflags & INIT_GETCWD) != 0)
- {
- const char *zenv;
- struct stat senv, sdot;
-
- /* Get the current working directory. We have to get it now,
- since we're about to do a chdir. We use PWD if it's defined
- and if it really names the working directory, since if it's
- not the same as whatever getcwd returns it's probably more
- appropriate. */
- zenv = getenv ("PWD");
- if (zenv != NULL
- && stat ((char *) zenv, &senv) == 0
- && stat ((char *) ".", &sdot) == 0
- && senv.st_ino == sdot.st_ino
- && senv.st_dev == sdot.st_dev)
- zScwd = zbufcpy (zenv);
- else
- {
-
-#if HAVE_GETCWD
- {
- size_t c;
-
- c = 128;
- while (TRUE)
- {
- zScwd = (char *) xmalloc (c);
- if (getcwd (zScwd, c) != NULL)
- break;
- xfree ((pointer) zScwd);
- zScwd = NULL;
- if (errno != ERANGE)
- break;
- c <<= 1;
- }
- }
-#endif /* HAVE_GETCWD */
-
-#if HAVE_GETWD
- zScwd = (char *) xmalloc (MAXPATHLEN);
- if (getwd (zScwd) == NULL)
- {
- xfree ((pointer) zScwd);
- zScwd = NULL;
- }
-#endif /* HAVE_GETWD */
-
- if (zScwd != NULL)
- zScwd = (char *) xrealloc ((pointer) zScwd,
- strlen (zScwd) + 1);
- }
- }
-
- if ((iflags & INIT_NOCHDIR) == 0)
- {
- /* Connect to the spool directory, and create it if it doesn't
- exist. */
- if (chdir (zSspooldir) < 0)
- {
- if (errno == ENOENT
- && mkdir ((char *) zSspooldir, IDIRECTORY_MODE) < 0)
- ulog (LOG_FATAL, "mkdir (%s): %s", zSspooldir,
- strerror (errno));
- if (chdir (zSspooldir) < 0)
- ulog (LOG_FATAL, "chdir (%s): %s", zSspooldir,
- strerror (errno));
- }
- }
-}
-
-/* Exit the program. */
-
-void
-usysdep_exit (fsuccess)
- boolean fsuccess;
-{
- exit (fsuccess ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-/* This is called when a non-standard configuration file is used, to
- make sure the program doesn't hand out privileged file access.
- This means that to test non-standard configuration files, you
- should be logged in as uucp. This is called before
- usysdep_initialize. It ensures that someone can't simply use an
- alternate configuration file to steal UUCP transfers from other
- systems. This will still permit people to set up their own
- configuration file and pretend to be whatever system they choose.
- The only real security is to use a high level of protection on the
- modem ports. */
-
-/*ARGSUSED*/
-boolean fsysdep_other_config (z)
- const char *z;
-{
- (void) setuid (getuid ());
- (void) setgid (getgid ());
- return TRUE;
-}
-
-/* Get the node name to use if it was not specified in the configuration
- file. */
-
-const char *
-zsysdep_localname ()
-{
- return zSlocalname;
-}
-
-/* Get the login name. We actually get the login name in
- usysdep_initialize, because after that we may switch away from the
- real uid. */
-
-const char *
-zsysdep_login_name ()
-{
- if (zSlogin == NULL)
- ulog (LOG_FATAL, "Can't get login name");
- return zSlogin;
-}
diff --git a/gnu/libexec/uucp/libunix/isdir.c b/gnu/libexec/uucp/libunix/isdir.c
deleted file mode 100644
index fc95e52..0000000
--- a/gnu/libexec/uucp/libunix/isdir.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/* isdir.c
- See whether a file exists and is a directory. */
-
-#include "uucp.h"
-
-#include "system.h"
-#include "sysdep.h"
-
-boolean
-fsysdep_directory (z)
- const char *z;
-{
- struct stat s;
-
- if (stat ((char *) z, &s) < 0)
- return FALSE;
- return S_ISDIR (s.st_mode);
-}
diff --git a/gnu/libexec/uucp/libunix/isfork.c b/gnu/libexec/uucp/libunix/isfork.c
deleted file mode 100644
index f067d07..0000000
--- a/gnu/libexec/uucp/libunix/isfork.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* isfork.c
- Retry fork several times before giving up. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-
-#include <errno.h>
-
-pid_t
-ixsfork ()
-{
- int i;
- pid_t iret;
-
- for (i = 0; i < 10; i++)
- {
- iret = fork ();
- if (iret >= 0 || errno != EAGAIN)
- return iret;
- sleep (5);
- }
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libunix/iswait.c b/gnu/libexec/uucp/libunix/iswait.c
deleted file mode 100644
index d13db6e..0000000
--- a/gnu/libexec/uucp/libunix/iswait.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* iswait.c
- Wait for a process to finish.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-
-#include <errno.h>
-
-#if HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-/* We use a typedef wait_status for wait (waitpid, wait4) to put
- results into. We define the POSIX examination functions we need if
- they are not already defined (if they aren't defined, I assume that
- we have a standard wait status). */
-
-#if HAVE_UNION_WAIT
-typedef union wait wait_status;
-#ifndef WIFEXITED
-#define WIFEXITED(u) ((u).w_termsig == 0)
-#endif
-#ifndef WEXITSTATUS
-#define WEXITSTATUS(u) ((u).w_retcode)
-#endif
-#ifndef WTERMSIG
-#define WTERMSIG(u) ((u).w_termsig)
-#endif
-#else /* ! HAVE_UNION_WAIT */
-typedef int wait_status;
-#ifndef WIFEXITED
-#define WIFEXITED(i) (((i) & 0xff) == 0)
-#endif
-#ifndef WEXITSTATUS
-#define WEXITSTATUS(i) (((i) >> 8) & 0xff)
-#endif
-#ifndef WTERMSIG
-#define WTERMSIG(i) ((i) & 0x7f)
-#endif
-#endif /* ! HAVE_UNION_WAIT */
-
-/* Wait for a particular process to finish. The ipid argument should
- be pid_t, but then we couldn't have a prototype. If the zreport
- argument is not NULL, then a wait error will be logged, and if the
- exit status is non-zero it will be logged with zreport as the
- header of the log message. If the zreport argument is NULL, no
- errors will be logged. This function returns the exit status if
- the process exited normally, or -1 on error or if the process was
- killed by a signal (I don't just always return the exit status
- because then the calling code would have to prepared to handle
- union wait status vs. int status, and none of the callers care
- which signal killed the program anyhow).
-
- This functions keeps waiting until the process finished, even if it
- is interrupted by a signal. I think this is right for all uses.
- The controversial one would be when called from uuxqt to wait for a
- requested process. Hitting uuxqt with SIGKILL will approximate the
- actions taken if we return from here with an error anyhow. If we
- do get a signal, we call ulog with a NULL argument to get it in the
- log file at about the right time. */
-
-int
-ixswait (ipid, zreport)
- unsigned long ipid;
- const char *zreport;
-{
- wait_status istat;
-
-#if HAVE_WAITPID
- while (waitpid ((pid_t) ipid, (pointer) &istat, 0) < 0)
- {
- if (errno != EINTR)
- {
- if (zreport != NULL)
- ulog (LOG_ERROR, "waitpid: %s", strerror (errno));
- return -1;
- }
- ulog (LOG_ERROR, (const char *) NULL);
- }
-#else /* ! HAVE_WAITPID */
-#if HAVE_WAIT4
- while (wait4 ((pid_t) ipid, (pointer) &istat, 0,
- (struct rusage *) NULL) < 0)
- {
- if (errno != EINTR)
- {
- if (zreport != NULL)
- ulog (LOG_ERROR, "wait4: %s", strerror (errno));
- return -1;
- }
- ulog (LOG_ERROR, (const char *) NULL);
- }
-#else /* ! HAVE_WAIT4 */
- pid_t igot;
-
- /* We could theoretically get the wrong child here if we're in some
- kind of weird pipeline, so we don't give any error messages for
- it. */
- while ((igot = wait ((pointer) &istat)) != (pid_t) ipid)
- {
- if (igot < 0)
- {
- if (errno != EINTR)
- {
- if (zreport != NULL)
- ulog (LOG_ERROR, "wait: %s", strerror (errno));
- return -1;
- }
- ulog (LOG_ERROR, (const char *) NULL);
- }
- }
-#endif /* ! HAVE_WAIT4 */
-#endif /* ! HAVE_WAITPID */
-
- DEBUG_MESSAGE2 (DEBUG_EXECUTE, "%s %d",
- WIFEXITED (istat) ? "Exit status" : "Signal",
- WIFEXITED (istat) ? WEXITSTATUS (istat) : WTERMSIG (istat));
-
- if (WIFEXITED (istat) && WEXITSTATUS (istat) == 0)
- return 0;
-
- if (zreport != NULL)
- {
- if (! WIFEXITED (istat))
- ulog (LOG_ERROR, "%s: Got signal %d", zreport, WTERMSIG (istat));
- else
- ulog (LOG_ERROR, "%s: Exit status %d", zreport,
- WEXITSTATUS (istat));
- }
-
- if (WIFEXITED (istat))
- return WEXITSTATUS (istat);
- else
- return -1;
-}
diff --git a/gnu/libexec/uucp/libunix/jobid.c b/gnu/libexec/uucp/libunix/jobid.c
deleted file mode 100644
index b7f9145..0000000
--- a/gnu/libexec/uucp/libunix/jobid.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* jobid.c
- Convert file names to jobids and vice versa.
-
- Copyright (C) 1991, 1992, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uuconf.h"
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-/* Translate a file name and an associated system into a job id.
- These job ids are used by uustat. */
-
-char *
-zsfile_to_jobid (qsys, zfile, bgrade)
- const struct uuconf_system *qsys;
- const char *zfile;
- int bgrade;
-{
- size_t clen;
- char *zret;
-
- clen = strlen (qsys->uuconf_zname);
-
-#if ! SPOOLDIR_TAYLOR
-
- /* We use the system name attached to the grade and sequence number.
- This won't work correctly if the file name was actually created
- by some other version of uucp that uses a different length for
- the sequence number. Too bad. */
-
- zret = zbufalc (clen + CSEQLEN + 2);
- memcpy (zret, qsys->uuconf_zname, clen);
- zret[clen] = bgrade;
- memcpy (zret + clen + 1, zfile + strlen (zfile) - CSEQLEN, CSEQLEN + 1);
-
-#else
-
- /* We use the system name followed by a dot, the grade, and the
- sequence number. In this case, the sequence number is a long
- string. */
-
- {
- size_t cseqlen;
-
- /* zfile is SYS/C./C.gseq. */
- zfile = strrchr (zfile, '/');
-
-#if DEBUG > 0
- if (zfile == NULL
- || zfile[1] != 'C'
- || zfile[2] != '.'
- || zfile[3] == '\0')
- ulog (LOG_FATAL, "zsfile_to_jobid: Can't happen");
-#endif
-
- /* Make zfile point at .gseq. */
- zfile += 2;
-
- cseqlen = strlen (zfile);
- zret = zbufalc (clen + cseqlen + 1);
- memcpy (zret, qsys->uuconf_zname, clen);
- memcpy (zret + clen, zfile, cseqlen + 1);
- }
-
-#endif
-
- return zret;
-}
-
-/* Turn a job id back into a file name. */
-
-char *
-zsjobid_to_file (zid, pzsystem, pbgrade)
- const char *zid;
- char **pzsystem;
- char *pbgrade;
-{
-#if ! SPOOLDIR_TAYLOR
- size_t clen;
- const char *zend;
- char *zsys;
- char abname[CSEQLEN + 11];
- char *zret;
-
- clen = strlen (zid);
- if (clen <= CSEQLEN)
- {
- ulog (LOG_ERROR, "%s: Bad job id", zid);
- return NULL;
- }
-
- zend = zid + clen - CSEQLEN - 1;
-
- zsys = zbufalc (clen - CSEQLEN);
- memcpy (zsys, zid, clen - CSEQLEN - 1);
- zsys[clen - CSEQLEN - 1] = '\0';
-
- /* This must correspond to zsfile_name. */
- sprintf (abname, "C.%.7s%s", zsys, zend);
-
- zret = zsfind_file (abname, zsys, *zend);
-
- if (zret != NULL && pzsystem != NULL)
- *pzsystem = zsys;
- else
- ubuffree (zsys);
-
- if (pbgrade != NULL)
- *pbgrade = *zend;
-
- return zret;
-#else /* SPOOLDIR_TAYLOR */
- char *zdot;
- size_t csyslen;
- char *zsys;
- char ab[15];
- char *zret;
-
- zdot = strrchr (zid, '.');
- if (zdot == NULL)
- {
- ulog (LOG_ERROR, "%s: Bad job id", zid);
- return NULL;
- }
-
- csyslen = zdot - zid;
- zsys = zbufalc (csyslen + 1);
- memcpy (zsys, zid, csyslen);
- zsys[csyslen] = '\0';
-
- ab[0] = 'C';
- strcpy (ab + 1, zdot);
-
- zret = zsfind_file (ab, zsys, zdot[1]);
-
- if (zret != NULL && pzsystem != NULL)
- *pzsystem = zsys;
- else
- ubuffree (zsys);
-
- if (pbgrade != NULL)
- *pbgrade = zdot[1];
-
- return zret;
-#endif /* SPOOLDIR_TAYLOR */
-}
diff --git a/gnu/libexec/uucp/libunix/lcksys.c b/gnu/libexec/uucp/libunix/lcksys.c
deleted file mode 100644
index ab2e2c8..0000000
--- a/gnu/libexec/uucp/libunix/lcksys.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* lcksys.c
- Lock and unlock a remote system. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "sysdep.h"
-#include "system.h"
-
-/* Do the actual lock or unlock. */
-
-static boolean fslock_sys P((boolean, const char *));
-
-static boolean
-fslock_sys (flock, zname)
- boolean flock;
- const char *zname;
-{
- size_t clen;
- char *z;
- boolean fret;
-
- clen = strlen (zname);
-
-#if ! HAVE_LONG_FILE_NAMES
- if (clen > 8)
- clen = 8;
-#endif
-
- z = zbufalc (sizeof "LCK.." + clen);
- memcpy (z, "LCK..", sizeof "LCK.." - 1);
- memcpy (z + sizeof "LCK.." - 1, zname, clen);
- z[sizeof "LCK.." - 1 + clen] = '\0';
-
- if (flock)
- fret = fsdo_lock (z, FALSE, (boolean *) NULL);
- else
- fret = fsdo_unlock (z, FALSE);
-
- ubuffree (z);
-
- return fret;
-}
-
-/* Lock a remote system. */
-
-boolean
-fsysdep_lock_system (qsys)
- const struct uuconf_system *qsys;
-{
- return fslock_sys (TRUE, qsys->uuconf_zname);
-}
-
-/* Unlock a remote system. */
-
-boolean
-fsysdep_unlock_system (qsys)
- const struct uuconf_system *qsys;
-{
- return fslock_sys (FALSE, qsys->uuconf_zname);
-}
diff --git a/gnu/libexec/uucp/libunix/link.c b/gnu/libexec/uucp/libunix/link.c
deleted file mode 100644
index 4550c76..0000000
--- a/gnu/libexec/uucp/libunix/link.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* link.c
- Link two files. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-boolean
-fsysdep_link (zfrom, zto, pfworked)
- const char *zfrom;
- const char *zto;
- boolean *pfworked;
-{
- *pfworked = FALSE;
- if (link (zfrom, zto) == 0)
- {
- *pfworked = TRUE;
- return TRUE;
- }
- if (errno == ENOENT)
- {
- if (! fsysdep_make_dirs (zto, TRUE))
- return FALSE;
- if (link (zfrom, zto) == 0)
- {
- *pfworked = TRUE;
- return TRUE;
- }
- }
- if (errno == EXDEV)
- return TRUE;
- ulog (LOG_ERROR, "link (%s, %s): %s", zfrom, zto, strerror (errno));
- return FALSE;
-}
diff --git a/gnu/libexec/uucp/libunix/locfil.c b/gnu/libexec/uucp/libunix/locfil.c
deleted file mode 100644
index 47581cf..0000000
--- a/gnu/libexec/uucp/libunix/locfil.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* locfil.c
- Expand a file name on the local system.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <pwd.h>
-
-#if GETPWNAM_DECLARATION_OK
-#ifndef getpwnam
-extern struct passwd *getpwnam ();
-#endif
-#endif
-
-/* Turn a file name into an absolute path, by doing tilde expansion
- and moving any other type of file into the public directory. */
-
-char *
-zsysdep_local_file (zfile, zpubdir, pfbadname)
- const char *zfile;
- const char *zpubdir;
- boolean *pfbadname;
-{
- const char *zdir;
-
- if (pfbadname != NULL)
- *pfbadname = FALSE;
-
- if (*zfile == '/')
- return zbufcpy (zfile);
-
- if (*zfile != '~')
- zdir = zpubdir;
- else
- {
- if (zfile[1] == '\0')
- return zbufcpy (zpubdir);
-
- if (zfile[1] == '/')
- {
- zdir = zpubdir;
- zfile += 2;
- }
- else
- {
- size_t cuserlen;
- char *zcopy;
- struct passwd *q;
-
- ++zfile;
- cuserlen = strcspn ((char *) zfile, "/");
- zcopy = zbufalc (cuserlen + 1);
- memcpy (zcopy, zfile, cuserlen);
- zcopy[cuserlen] = '\0';
-
- q = getpwnam (zcopy);
- if (q == NULL)
- {
- ulog (LOG_ERROR, "User %s not found", zcopy);
- ubuffree (zcopy);
- if (pfbadname != NULL)
- *pfbadname = TRUE;
- return NULL;
- }
- ubuffree (zcopy);
-
- if (zfile[cuserlen] == '\0')
- return zbufcpy (q->pw_dir);
-
- zdir = q->pw_dir;
- zfile += cuserlen + 1;
- }
- }
-
- return zsysdep_in_dir (zdir, zfile);
-}
diff --git a/gnu/libexec/uucp/libunix/lock.c b/gnu/libexec/uucp/libunix/lock.c
deleted file mode 100644
index 1e2781f..0000000
--- a/gnu/libexec/uucp/libunix/lock.c
+++ /dev/null
@@ -1,690 +0,0 @@
-/* lock.c
- Lock and unlock a file name.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char lock_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-#include <ctype.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#if TM_IN_SYS_TIME
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-
-#if HAVE_QNX_LOCKFILES
-#include <sys/kernel.h>
-#include <sys/psinfo.h>
-#include <sys/seginfo.h>
-#include <sys/vc.h>
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-#ifndef localtime
-extern struct tm *localtime ();
-#endif
-
-#if HAVE_QNX_LOCKFILES
-static boolean fsqnx_stale P((unsigned long ipid, unsigned long inme,
- unsigned long inid, boolean *pferr));
-#endif
-
-/* Lock something. If the fspooldir argument is TRUE, the argument is
- a file name relative to the spool directory; otherwise the argument
- is a simple file name which should be created in the system lock
- directory (under HDB this is /etc/locks). */
-
-boolean
-fsdo_lock (zlock, fspooldir, pferr)
- const char *zlock;
- boolean fspooldir;
- boolean *pferr;
-{
- char *zfree;
- const char *zpath, *zslash;
- size_t cslash;
- pid_t ime;
- char *ztempfile;
- char abtempfile[sizeof "TMP12345678901234567890"];
- int o;
-#if HAVE_QNX_LOCKFILES
- nid_t inme;
- char ab[23];
- char *zend;
-#else
-#if HAVE_V2_LOCKFILES
- int i;
-#else
- char ab[12];
-#endif
-#endif
- int cwrote;
- const char *zerr;
- boolean fret;
-
- if (pferr != NULL)
- *pferr = TRUE;
-
- if (fspooldir)
- {
- zfree = NULL;
- zpath = zlock;
- }
- else
- {
- zfree = zsysdep_in_dir (zSlockdir, zlock);
- zpath = zfree;
- }
-
- ime = getpid ();
-#if HAVE_QNX_LOCKFILES
- inme = getnid ();
-#endif
-
- /* We do the actual lock by creating a file and then linking it to
- the final file name we want. This avoids race conditions due to
- one process checking the file before we have finished writing it,
- and also works even if we are somehow running as root.
-
- First, create the file in the right directory (we must create the
- file in the same directory since otherwise we might attempt a
- cross-device link). */
- zslash = strrchr (zpath, '/');
- if (zslash == NULL)
- cslash = 0;
- else
- cslash = zslash - zpath + 1;
-
-#if HAVE_QNX_LOCKFILES
- sprintf (abtempfile, "TMP%010lx%010lx", (unsigned long) ime,
- (unsigned long) inme);
-#else
- sprintf (abtempfile, "TMP%010lx", (unsigned long) ime);
-#endif
- ztempfile = zbufalc (cslash + sizeof abtempfile);
- memcpy (ztempfile, zpath, cslash);
- memcpy (ztempfile + cslash, abtempfile, sizeof abtempfile);
-
- o = creat (ztempfile, IPUBLIC_FILE_MODE);
- if (o < 0)
- {
- if (errno == ENOENT)
- {
- if (! fsysdep_make_dirs (ztempfile, FALSE))
- {
- ubuffree (zfree);
- ubuffree (ztempfile);
- return FALSE;
- }
- o = creat (ztempfile, IPUBLIC_FILE_MODE);
- }
- if (o < 0)
- {
- ulog (LOG_ERROR, "creat (%s): %s", ztempfile, strerror (errno));
- ubuffree (zfree);
- ubuffree (ztempfile);
- return FALSE;
- }
- }
-
-#if HAVE_QNX_LOCKFILES
- sprintf (ab, "%10ld %10ld\n", (long) ime, (long) inme);
- cwrote = write (o, ab, strlen (ab));
-#else
-#if HAVE_V2_LOCKFILES
- i = (int) ime;
- cwrote = write (o, &i, sizeof i);
-#else
- sprintf (ab, "%10ld\n", (long) ime);
- cwrote = write (o, ab, strlen (ab));
-#endif
-#endif
-
- zerr = NULL;
- if (cwrote < 0)
- zerr = "write";
- if (close (o) < 0)
- zerr = "close";
- if (zerr != NULL)
- {
- ulog (LOG_ERROR, "%s (%s): %s", zerr, ztempfile, strerror (errno));
- (void) remove (ztempfile);
- ubuffree (zfree);
- ubuffree (ztempfile);
- return FALSE;
- }
-
- /* Now try to link the file we just created to the lock file that we
- want. If it fails, try reading the existing file to make sure
- the process that created it still exists. We do this in a loop
- to make it easy to retry if the old locking process no longer
- exists. */
- fret = TRUE;
- if (pferr != NULL)
- *pferr = FALSE;
- o = -1;
- zerr = NULL;
-
- while (link (ztempfile, zpath) != 0)
- {
- int cgot;
- pid_t ipid;
- boolean freadonly;
- struct stat st;
- char abtime[sizeof "1991-12-31 12:00:00"];
-#if HAVE_QNX_LOCKFILES
- nid_t inid;
-#endif
-
- fret = FALSE;
-
- if (errno != EEXIST)
- {
- ulog (LOG_ERROR, "link (%s, %s): %s", ztempfile, zpath,
- strerror (errno));
- if (pferr != NULL)
- *pferr = TRUE;
- break;
- }
-
- freadonly = FALSE;
- o = open ((char *) zpath, O_RDWR | O_NOCTTY, 0);
- if (o < 0)
- {
- if (errno == EACCES)
- {
- freadonly = TRUE;
- o = open ((char *) zpath, O_RDONLY, 0);
- }
- if (o < 0)
- {
- if (errno == ENOENT)
- {
- /* The file was presumably removed between the link
- and the open. Try the link again. */
- fret = TRUE;
- continue;
- }
- zerr = "open";
- break;
- }
- }
-
- /* The race starts here. See below for a discussion. */
-
-#if HAVE_V2_LOCKFILES
- cgot = read (o, &i, sizeof i);
-#else
- cgot = read (o, ab, sizeof ab - 1);
-#endif
-
- if (cgot < 0)
- {
- zerr = "read";
- break;
- }
-
-#if DEBUG > 0
-#if HAVE_V2_LOCKFILES
- {
- char ab[10];
-
- if (read (o, ab, sizeof ab) > 4
- && isdigit (BUCHAR (ab[0])))
- ulog (LOG_ERROR,
- "Lock file %s may be HDB format; check LOCKFILES in policy.h",
- zpath);
- }
-#else
- if (cgot == 4)
- ulog (LOG_ERROR,
- "Lock file %s may be V2 format; check LOCKFILES in policy.h",
- zpath);
-#endif
-#endif /* DEBUG > 0 */
-
-#if HAVE_QNX_LOCKFILES
- ab[cgot] = '\0';
- ipid = (pid_t) strtol (ab, &zend, 10);
- inid = (nid_t) strtol (zend, (char **) NULL, 10);
-#else
-#if HAVE_V2_LOCKFILES
- ipid = (pid_t) i;
-#else
- ab[cgot] = '\0';
- ipid = (pid_t) strtol (ab, (char **) NULL, 10);
-#endif
-#endif
-
- /* On NFS, the link might have actually succeeded even though we
- got a failure return. This can happen if the original
- acknowledgement was lost or delayed and the operation was
- retried. In this case the pid will be our own. This
- introduces a rather improbable race condition: if a stale
- lock was left with our process ID in it, and another process
- just did the kill, below, but has not yet changed the lock
- file to hold its own process ID, we could start up and make
- it all the way to here and think we have the lock. I'm not
- going to worry about this possibility. */
- if (ipid == ime)
- {
-#if HAVE_QNX_LOCKFILES
- if (inid == inme)
-#endif
- {
- fret = TRUE;
- break;
- }
- }
-
- /* If the lock file is empty (cgot == 0), we assume that it is
- stale. This can happen if the system crashed after the lock
- file was created but before the process ID was written out. */
- if (cgot > 0)
- {
-#if HAVE_QNX_LOCKFILES
- if (! fsqnx_stale ((unsigned long) ipid, (unsigned long) inme,
- (unsigned long) inid, pferr))
- break;
-#else
- /* If the process still exists, we will get EPERM rather
- than ESRCH. We then return FALSE to indicate that we
- cannot make the lock. */
- if (kill (ipid, 0) == 0 || errno == EPERM)
- break;
-#endif
- }
-
- if (fstat (o, &st) < 0)
- strcpy (abtime, "unknown");
- else
- {
- time_t itm;
- struct tm *q;
-
- itm = (time_t) st.st_mtime;
- q = localtime (&itm);
- sprintf (abtime, "%04d-%02d-%02d %02d:%02d:%02d",
- q->tm_year + 1900, q->tm_mon + 1, q->tm_mday, q->tm_hour,
- q->tm_min, q->tm_sec);
- }
-
-#if HAVE_QNX_LOCKFILES
- ulog (LOG_ERROR,
- "Stale lock %s held by process %ld on node %ld created %s",
- zpath, (long) ipid, (long) inid, abtime);
-#else
- ulog (LOG_ERROR, "Stale lock %s held by process %ld created %s",
- zpath, (long) ipid, abtime);
-#endif
-
- /* This is a stale lock, created by a process that no longer
- exists.
-
- Now we could remove the file (and, if the file mode disallows
- writing, that's what we have to do), but we try to avoid
- doing so since it causes a race condition. If we remove the
- file, and are interrupted any time after we do the read until
- we do the remove, another process could get in, open the
- file, find that it was a stale lock, remove the file and
- create a new one. When we regained control we would remove
- the file the other process just created.
-
- These files are being generated partially for the benefit of
- cu, and it would be nice to avoid the race however cu avoids
- it, so that the programs remain compatible. Unfortunately,
- nobody seems to know how cu avoids the race, or even if it
- tries to avoid it at all.
-
- There are a few ways to avoid the race. We could use kernel
- locking primitives, but they may not be available. We could
- link to a special file name, but if that file were left lying
- around then no stale lock could ever be broken (Henry Spencer
- would think this was a good thing).
-
- Instead I've implemented the following procedure: seek to the
- start of the file, write our pid into it, sleep for five
- seconds, and then make sure our pid is still there. Anybody
- who checks the file while we're asleep will find our pid
- there and fail the lock. The only race will come from
- another process which has done the read by the time we do our
- write. That process will then have five seconds to do its
- own write. When we wake up, we'll notice that our pid is no
- longer in the file, and retry the lock from the beginning.
-
- This relies on the atomicity of write(2). If it possible for
- the writes of two processes to be interleaved, the two
- processes could livelock. POSIX unfortunately leaves this
- case explicitly undefined; however, given that the write is
- of less than a disk block, it's difficult to imagine an
- interleave occurring.
-
- Note that this is still a race. If it takes the second
- process more than five seconds to do the kill, the lseek, and
- the write, both processes will think they have the lock.
- Perhaps the length of time to sleep should be configurable.
- Even better, perhaps I should add a configuration option to
- use a permanent lock file, which eliminates any race and
- forces the installer to be aware of the existence of the
- permanent lock file.
-
- We stat the file after the sleep, to make sure some other
- program hasn't deleted it for us. */
- if (freadonly)
- {
- (void) close (o);
- o = -1;
- (void) remove (zpath);
- fret = TRUE;
- continue;
- }
-
- if (lseek (o, (off_t) 0, SEEK_SET) != 0)
- {
- zerr = "lseek";
- break;
- }
-
-#if HAVE_QNX_LOCKFILES
- sprintf (ab, "%10ld %10ld\n", (long) ime, (long) inme);
- cwrote = write (o, ab, strlen (ab));
-#else
-#if HAVE_V2_LOCKFILES
- i = (int) ime;
- cwrote = write (o, &i, sizeof i);
-#else
- sprintf (ab, "%10ld\n", (long) ime);
- cwrote = write (o, ab, strlen (ab));
-#endif
-#endif
-
- if (cwrote < 0)
- {
- zerr = "write";
- break;
- }
-
- (void) sleep (5);
-
- if (lseek (o, (off_t) 0, SEEK_SET) != 0)
- {
- zerr = "lseek";
- break;
- }
-
-#if HAVE_V2_LOCKFILES
- cgot = read (o, &i, sizeof i);
-#else
- cgot = read (o, ab, sizeof ab - 1);
-#endif
-
- if (cgot < 0)
- {
- zerr = "read";
- break;
- }
-
-#if HAVE_QNX_LOCKFILES
- ab[cgot] = '\0';
- ipid = (pid_t) strtol (ab, &zend, 10);
- inid = (nid_t) strtol (zend, (char **) NULL, 10);
-#else
-#if HAVE_V2_LOCKFILES
- ipid = (pid_t) i;
-#else
- ab[cgot] = '\0';
- ipid = (pid_t) strtol (ab, (char **) NULL, 10);
-#endif
-#endif
-
- if (ipid == ime)
- {
-#if HAVE_QNX_LOCKFILES
- if (inid == inme)
-#endif
- {
- struct stat sfile, sdescriptor;
-
- /* It looks like we have the lock. Do the final stat
- check. */
- if (stat ((char *) zpath, &sfile) < 0)
- {
- if (errno != ENOENT)
- {
- zerr = "stat";
- break;
- }
- /* Loop around and try again. */
- }
- else
- {
- if (fstat (o, &sdescriptor) < 0)
- {
- zerr = "fstat";
- break;
- }
-
- if (sfile.st_ino == sdescriptor.st_ino
- && sfile.st_dev == sdescriptor.st_dev)
- {
- /* Close the file before assuming we've
- succeeded to pick up any trailing errors. */
- if (close (o) < 0)
- {
- zerr = "close";
- break;
- }
-
- o = -1;
-
- /* We have the lock. */
- fret = TRUE;
- break;
- }
- }
- }
- }
-
- /* Loop around and try the lock again. We keep doing this until
- the lock file holds a pid that exists. */
- (void) close (o);
- o = -1;
- fret = TRUE;
- }
-
- if (zerr != NULL)
- {
- ulog (LOG_ERROR, "%s (%s): %s", zerr, zpath, strerror (errno));
- if (pferr != NULL)
- *pferr = TRUE;
- }
-
- if (o >= 0)
- (void) close (o);
-
- ubuffree (zfree);
-
- /* It would be nice if we could leave the temporary file around for
- future calls, but considering that we create lock files in
- various different directories it's probably more trouble than
- it's worth. */
- if (remove (ztempfile) != 0)
- ulog (LOG_ERROR, "remove (%s): %s", ztempfile, strerror (errno));
-
- ubuffree (ztempfile);
-
- return fret;
-}
-
-/* Unlock something. The fspooldir argument is as in fsdo_lock. */
-
-boolean
-fsdo_unlock (zlock, fspooldir)
- const char *zlock;
- boolean fspooldir;
-{
- char *zfree;
- const char *zpath;
-
- if (fspooldir)
- {
- zfree = NULL;
- zpath = zlock;
- }
- else
- {
- zfree = zsysdep_in_dir (zSlockdir, zlock);
- zpath = zfree;
- }
-
- if (remove (zpath) == 0
- || errno == ENOENT)
- {
- ubuffree (zfree);
- return TRUE;
- }
- else
- {
- ulog (LOG_ERROR, "remove (%s): %s", zpath, strerror (errno));
- ubuffree (zfree);
- return FALSE;
- }
-}
-
-#if HAVE_QNX_LOCKFILES
-
-/* Return TRUE if the lock is stale. */
-
-static boolean
-fsqnx_stale (ipid, inme, inid, pferr)
- unsigned long ipid;
- unsigned long inme;
- unsigned long inid;
- boolean *pferr;
-{
- /* A virtual process ID. This virtual process ID, which will exist
- on the local node, will represent the process ID of the process
- manager process (Proc) on the remote node. */
- pid_t ivid;
- /* The return value of the qnx_psinfo function. This is either a
- process ID which might or might not be the same as the process
- being looked for, or -1 to indicate no process found. */
- pid_t ifound_pid;
- /* This holds the actual result of qnx_psinfo. We will ignore
- almost all the fields since we're just checking for existence. */
- struct _psinfo spsdata;
-
- /* Establish connection with a remote process manager if necessary. */
- if (inid != inme)
- {
- ivid = qnx_vc_attach (inid /* remote node ID */,
- PROC_PID /* pid of process manager */,
- 1000 /* initial buffer size */,
- 0 /* flags */);
- if (ivid < 0)
- {
- ulog (LOG_ERROR, "qnx_vc_attach (%lu, PROC_PID): %s",
- inid, strerror (errno));
- if (pferr != NULL)
- *pferr = TRUE;
- return FALSE;
- }
- }
- else
- {
- /* Use the local pid of the local process manager. */
- ivid = PROC_PID;
- }
-
- /* Request the process information. */
- ifound_pid = qnx_psinfo (ivid /* process manager handling request */,
- ipid /* get info on this process */,
- &spsdata /* put info in this struct */,
- 0 /* unused */,
- (struct _seginfo *) NULL /* unused */);
-
- /* Deallocate the virtual connection before continuing. */
- {
- int isaved_errno = errno;
- if (qnx_vc_detach (ivid) < 0)
- ulog (LOG_ERROR, "qnx_vd_detach (%ld): %s", (long) ivid,
- strerror (errno));
- errno = isaved_errno;
- }
-
- /* If the returned pid matches then the process still holds the lock. */
- if ((ifound_pid == ipid) && (spsdata.pid == ipid))
- return FALSE;
-
- /* If the returned pid is positive and doesn't match, then the
- process doesn't exist and the lock is stale. Continue. */
-
- /* If the returned pid is negative (-1) and errno is EINVAL (or ESRCH
- in older versions of QNX), then the process doesn't exist and the
- lock is stale. Continue. */
-
- /* Check for impossible errors. */
- if ((ifound_pid < 0) && (errno != ESRCH) && (errno != EINVAL))
- {
- ulog (LOG_ERROR, "qnx_psinfo (%ld, %ld): %s", (long) ivid,
- (long) ipid, strerror (errno));
- /* Since we don't know what the hell this means, and we don't
- want our system to freeze, we treat this case as a stale
- lock. Continue on. */
- }
-
- return TRUE;
-}
-
-#endif /* HAVE_QNX_LOCKFILES */
diff --git a/gnu/libexec/uucp/libunix/loctim.c b/gnu/libexec/uucp/libunix/loctim.c
deleted file mode 100644
index 7f1f87a..0000000
--- a/gnu/libexec/uucp/libunix/loctim.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* loctim.c
- Turn a time epoch into a struct tm. This is trivial on Unix. */
-
-#include "uucp.h"
-
-#if TM_IN_SYS_TIME
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-
-#include "system.h"
-
-#ifndef localtime
-extern struct tm *localtime ();
-#endif
-
-void
-usysdep_localtime (itime, q)
- long itime;
- struct tm *q;
-{
- time_t i;
-
- i = (time_t) itime;
- *q = *localtime (&i);
-}
diff --git a/gnu/libexec/uucp/libunix/mail.c b/gnu/libexec/uucp/libunix/mail.c
deleted file mode 100644
index 634a593..0000000
--- a/gnu/libexec/uucp/libunix/mail.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* mail.c
- Send mail to a user.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_TIME_H
-#include <time.h>
-#endif
-
-#ifndef ctime
-extern char *ctime ();
-#endif
-
-/* Mail a message to a user. */
-
-boolean
-fsysdep_mail (zto, zsubject, cstrs, paz)
- const char *zto;
- const char *zsubject;
- int cstrs;
- const char **paz;
-{
- char **pazargs;
- char *zcopy, *ztok;
- size_t cargs, iarg;
- FILE *e;
- pid_t ipid;
- time_t itime;
- int i;
-
- /* Parse MAIL_PROGRAM into an array of arguments. */
- zcopy = zbufcpy (MAIL_PROGRAM);
-
- cargs = 0;
- for (ztok = strtok (zcopy, " \t");
- ztok != NULL;
- ztok = strtok ((char *) NULL, " \t"))
- ++cargs;
-
- pazargs = (char **) xmalloc ((cargs + 4) * sizeof (char *));
-
- memcpy (zcopy, MAIL_PROGRAM, sizeof MAIL_PROGRAM);
- for (ztok = strtok (zcopy, " \t"), iarg = 0;
- ztok != NULL;
- ztok = strtok ((char *) NULL, " \t"), ++iarg)
- pazargs[iarg] = ztok;
-
-#if ! MAIL_PROGRAM_SUBJECT_BODY
- pazargs[iarg++] = (char *) "-s";
- pazargs[iarg++] = (char *) zsubject;
-#endif
-
-#if ! MAIL_PROGRAM_TO_BODY
- pazargs[iarg++] = (char *) zto;
-#endif
-
- pazargs[iarg] = NULL;
-
- e = espopen ((const char **) pazargs, FALSE, &ipid);
-
- ubuffree (zcopy);
- xfree ((pointer) pazargs);
-
- if (e == NULL)
- {
- ulog (LOG_ERROR, "espopen (%s): %s", MAIL_PROGRAM,
- strerror (errno));
- return FALSE;
- }
-
-#if MAIL_PROGRAM_TO_BODY
- fprintf (e, "To: %s\n", zto);
-#endif
-#if MAIL_PROGRAM_SUBJECT_BODY
- fprintf (e, "Subject: %s\n", zsubject);
-#endif
-
-#if MAIL_PROGRAM_TO_BODY || MAIL_PROGRAM_SUBJECT_BODY
- fprintf (e, "\n");
-#endif
-
- (void) time (&itime);
- /* Remember that ctime includes a \n, so this skips a line. */
- fprintf (e, "Message from UUCP on %s %s\n", zSlocalname,
- ctime (&itime));
-
- for (i = 0; i < cstrs; i++)
- fputs (paz[i], e);
-
- (void) fclose (e);
-
- return ixswait ((unsigned long) ipid, MAIL_PROGRAM) == 0;
-}
diff --git a/gnu/libexec/uucp/libunix/mkdir.c b/gnu/libexec/uucp/libunix/mkdir.c
deleted file mode 100644
index 2546cbf..0000000
--- a/gnu/libexec/uucp/libunix/mkdir.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* mkdir.c
- Create a directory. We must go through a subsidiary program to
- force our real uid to be the uucp owner before invoking the setuid
- /bin/mkdir program. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-
-#include <errno.h>
-
-int
-mkdir (zdir, imode)
- const char *zdir;
- int imode;
-{
- struct stat s;
- const char *azargs[3];
- int aidescs[3];
- pid_t ipid;
-
- /* Make sure the directory does not exist, since we will otherwise
- get the wrong errno value. */
- if (stat (zdir, &s) == 0)
- {
- errno = EEXIST;
- return -1;
- }
-
- /* /bin/mkdir will create the directory with mode 777, so we set our
- umask to get the mode we want. */
- (void) umask ((~ imode) & (S_IRWXU | S_IRWXG | S_IRWXO));
-
- azargs[0] = UUDIR_PROGRAM;
- azargs[1] = zdir;
- azargs[2] = NULL;
- aidescs[0] = SPAWN_NULL;
- aidescs[1] = SPAWN_NULL;
- aidescs[2] = SPAWN_NULL;
-
- ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, (const char *) NULL,
- TRUE, FALSE, (const char *) NULL,
- (const char *) NULL, (const char *) NULL);
-
- (void) umask (0);
-
- if (ipid < 0)
- return -1;
-
- if (ixswait ((unsigned long) ipid, (const char *) NULL) != 0)
- {
- /* Make up an errno value. */
- errno = EACCES;
- return -1;
- }
-
- return 0;
-}
diff --git a/gnu/libexec/uucp/libunix/mkdirs.c b/gnu/libexec/uucp/libunix/mkdirs.c
deleted file mode 100644
index df4f987..0000000
--- a/gnu/libexec/uucp/libunix/mkdirs.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* mkdirs.c
- Create any directories needed for a file name. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-boolean
-fsysdep_make_dirs (zfile, fpublic)
- const char *zfile;
- boolean fpublic;
-{
- char *zcopy, *z;
- int imode;
-
- zcopy = zbufcpy (zfile);
-
- if (fpublic)
- imode = IPUBLIC_DIRECTORY_MODE;
- else
- imode = IDIRECTORY_MODE;
-
- for (z = zcopy; *z != '\0'; z++)
- {
- if (*z == '/' && z != zcopy)
- {
- /* Some versions of uuto will send a double slash. Some
- systems will fail to create a directory ending in a
- slash. */
- if (z[-1] == '/')
- continue;
- *z = '\0';
- if (mkdir (zcopy, imode) != 0
- && errno != EEXIST
- && errno != EISDIR
-#ifdef EROFS
- && errno != EROFS
-#endif
- && (errno != EACCES || ! fsysdep_directory (zcopy)))
- {
- ulog (LOG_ERROR, "mkdir (%s): %s", zcopy,
- strerror (errno));
- ubuffree (zcopy);
- return FALSE;
- }
- *z = '/';
- }
- }
-
- ubuffree (zcopy);
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/mode.c b/gnu/libexec/uucp/libunix/mode.c
deleted file mode 100644
index 53f74ec..0000000
--- a/gnu/libexec/uucp/libunix/mode.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* mode.c
- Get the Unix file mode of a file. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-unsigned int
-ixsysdep_file_mode (zfile)
- const char *zfile;
-{
- struct stat s;
-
- if (stat ((char *) zfile, &s) != 0)
- {
- ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno));
- return 0;
- }
-
-#if S_IRWXU != 0700
- #error Files modes need to be translated
-#endif
-
- /* We can't return 0, since that indicate an error. */
- if ((s.st_mode & 0777) == 0)
- return 0400;
-
- return s.st_mode & 0777;
-}
diff --git a/gnu/libexec/uucp/libunix/move.c b/gnu/libexec/uucp/libunix/move.c
deleted file mode 100644
index 19828c2..0000000
--- a/gnu/libexec/uucp/libunix/move.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* move.c
- Move a file.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-/* Move (rename) a file from one name to another. This routine will
- optionally create necessary directories, and fpublic indicates
- whether the new directories should be publically accessible or not.
- If fcheck is true, it will try to determine whether the named user
- has write access to the new file. */
-
-boolean
-fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser)
- const char *zorig;
- const char *zto;
- boolean fmkdirs;
- boolean fpublic;
- boolean fcheck;
- const char *zuser;
-{
- struct stat s;
- int o;
-
- DEBUG_MESSAGE2 (DEBUG_SPOOLDIR,
- "fsysdep_move_file: Moving %s to %s", zorig, zto);
-
- /* Optionally make sure that zuser has write access on the
- directory. */
- if (fcheck)
- {
- char *zcopy;
- char *zslash;
-
- zcopy = zbufcpy (zto);
- zslash = strrchr (zcopy, '/');
- if (zslash == zcopy)
- zslash[1] = '\0';
- else
- *zslash = '\0';
-
- if (stat (zcopy, &s) != 0)
- {
- ulog (LOG_ERROR, "stat (%s): %s", zcopy, strerror (errno));
- ubuffree (zcopy);
- return FALSE;
- }
- if (! fsuser_access (&s, W_OK, zuser))
- {
- ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES));
- ubuffree (zcopy);
- return FALSE;
- }
- ubuffree (zcopy);
-
- /* A malicious user now has a few milliseconds to change a
- symbolic link to a directory uucp has write permission on but
- the user does not (the obvious choice being /usr/lib/uucp).
- The only certain method I can come up with to close this race
- is to fork an suid process which takes on the users identity
- and does the actual copy. This is sufficiently high overhead
- that I'm not going to do it. */
- }
-
- /* We try to use rename to move the file. */
-
- if (rename (zorig, zto) == 0)
- return TRUE;
-
- if (fmkdirs && errno == ENOENT)
- {
- if (! fsysdep_make_dirs (zto, fpublic))
- return FALSE;
- if (rename (zorig, zto) == 0)
- return TRUE;
- }
-
-#if HAVE_RENAME
- /* On some systems the system call rename seems to fail for
- arbitrary reasons. To get around this, we always try to copy the
- file by hand if the rename failed. */
- errno = EXDEV;
-#endif
-
- /* If we can't link across devices, we must copy the file by hand. */
- if (errno != EXDEV)
- {
- ulog (LOG_ERROR, "rename (%s, %s): %s", zorig, zto,
- strerror (errno));
- return FALSE;
- }
-
- /* Copy the file. */
- if (stat ((char *) zorig, &s) < 0)
- {
- ulog (LOG_ERROR, "stat (%s): %s", zorig, strerror (errno));
- return FALSE;
- }
-
- /* Make sure the file gets the right mode by creating it before we
- call fcopy_file. */
- (void) remove (zto);
- o = creat ((char *) zto, s.st_mode);
- if (o < 0)
- {
- if (fmkdirs && errno == ENOENT)
- {
- if (! fsysdep_make_dirs (zto, fpublic))
- return FALSE;
- o = creat ((char *) zto, s.st_mode);
- }
- if (o < 0)
- {
- ulog (LOG_ERROR, "creat (%s): %s", zto, strerror (errno));
- return FALSE;
- }
- }
- (void) close (o);
-
- if (! fcopy_file (zorig, zto, fpublic, fmkdirs, FALSE))
- return FALSE;
-
- if (remove (zorig) != 0)
- ulog (LOG_ERROR, "remove (%s): %s", zorig, strerror (errno));
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/opensr.c b/gnu/libexec/uucp/libunix/opensr.c
deleted file mode 100644
index 5217741..0000000
--- a/gnu/libexec/uucp/libunix/opensr.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/* opensr.c
- Open files for sending and receiving.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "sysdep.h"
-
-#include <errno.h>
-
-#if HAVE_TIME_H
-#include <time.h>
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-#ifndef time
-extern time_t time ();
-#endif
-
-/* Open a file to send to another system, and return the mode and
- the size. */
-
-openfile_t
-esysdep_open_send (qsys, zfile, fcheck, zuser)
- const struct uuconf_system *qsys;
- const char *zfile;
- boolean fcheck;
- const char *zuser;
-{
- struct stat s;
- openfile_t e;
- int o;
-
- if (fsysdep_directory (zfile))
- {
- ulog (LOG_ERROR, "%s: is a directory", zfile);
- return EFILECLOSED;
- }
-
-#if USE_STDIO
- e = fopen (zfile, BINREAD);
- if (e == NULL)
- {
- ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno));
- return NULL;
- }
- o = fileno (e);
-#else
- e = open ((char *) zfile, O_RDONLY | O_NOCTTY, 0);
- if (e == -1)
- {
- ulog (LOG_ERROR, "open (%s): %s", zfile, strerror (errno));
- return -1;
- }
- o = e;
-#endif
-
- if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- (void) ffileclose (e);
- return EFILECLOSED;
- }
-
- if (fstat (o, &s) == -1)
- {
- ulog (LOG_ERROR, "fstat: %s", strerror (errno));
- s.st_mode = 0666;
- }
-
- /* We have to recheck the file permission, although we probably
- checked it already, because otherwise there would be a window in
- which somebody could change the contents of a symbolic link to
- point to some file which was only readable by uucp. */
- if (fcheck)
- {
- if (! fsuser_access (&s, R_OK, zuser))
- {
- ulog (LOG_ERROR, "%s: %s", zfile, strerror (EACCES));
- (void) ffileclose (e);
- return EFILECLOSED;
- }
- }
-
- return e;
-}
-
-/* Get a temporary file name to receive into. We use the ztemp
- argument to pick the file name, so that we restart the file if the
- transmission is aborted. */
-
-char *
-zsysdep_receive_temp (qsys, zto, ztemp, frestart)
- const struct uuconf_system *qsys;
- const char *zto;
- const char *ztemp;
- boolean frestart;
-{
- if (frestart
- && ztemp != NULL
- && *ztemp == 'D'
- && strcmp (ztemp, "D.0") != 0)
- return zsappend3 (".Temp", qsys->uuconf_zname, ztemp);
- else
- return zstemp_file (qsys);
-}
-
-/* The number of seconds in one week. We must cast to long for this
- to be calculated correctly on a machine with 16 bit ints. */
-#define SECS_PER_WEEK ((long) 7 * (long) 24 * (long) 60 * (long) 60)
-
-/* Open a temporary file to receive into. This should, perhaps, check
- that we have write permission on the receiving directory, but it
- doesn't. */
-
-openfile_t
-esysdep_open_receive (qsys, zto, ztemp, zreceive, pcrestart)
- const struct uuconf_system *qsys;
- const char *zto;
- const char *ztemp;
- const char *zreceive;
- long *pcrestart;
-{
- int o;
- openfile_t e;
-
- /* If we used the ztemp argument in zsysdep_receive_temp, above,
- then we will have a name consistent across conversations. In
- that case, we may have already received some portion of this
- file. */
- o = -1;
- if (pcrestart != NULL)
- *pcrestart = -1;
- if (pcrestart != NULL
- && ztemp != NULL
- && *ztemp == 'D'
- && strcmp (ztemp, "D.0") != 0)
- {
- o = open ((char *) zreceive, O_WRONLY);
- if (o >= 0)
- {
- struct stat s;
-
- /* For safety, we insist on the file being less than 1 week
- old. This can still catch people, unfortunately. I
- don't know of any good solution to the problem of old
- files hanging around. If anybody has a file they want
- restarted, and they know about this issue, they can touch
- it to bring it up to date. */
- if (fstat (o, &s) < 0
- || s.st_mtime + SECS_PER_WEEK < time ((time_t *) NULL))
- {
- (void) close (o);
- o = -1;
- }
- else
- {
- DEBUG_MESSAGE1 (DEBUG_SPOOLDIR,
- "esysdep_open_receive: Reusing %s",
- zreceive);
- *pcrestart = (long) s.st_size;
- }
- }
- }
-
- if (o < 0)
- o = creat ((char *) zreceive, IPRIVATE_FILE_MODE);
-
- if (o < 0)
- {
- if (errno == ENOENT)
- {
- if (! fsysdep_make_dirs (zreceive, FALSE))
- return EFILECLOSED;
- o = creat ((char *) zreceive, IPRIVATE_FILE_MODE);
- }
- if (o < 0)
- {
- ulog (LOG_ERROR, "creat (%s): %s", zreceive, strerror (errno));
- return EFILECLOSED;
- }
- }
-
- if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- (void) close (o);
- (void) remove (zreceive);
- return EFILECLOSED;
- }
-
-#if USE_STDIO
- e = fdopen (o, (char *) BINWRITE);
-
- if (e == NULL)
- {
- ulog (LOG_ERROR, "fdopen (%s): %s", zreceive, strerror (errno));
- (void) close (o);
- (void) remove (zreceive);
- return EFILECLOSED;
- }
-#else
- e = o;
-#endif
-
- return e;
-}
diff --git a/gnu/libexec/uucp/libunix/pause.c b/gnu/libexec/uucp/libunix/pause.c
deleted file mode 100644
index 8b2b698..0000000
--- a/gnu/libexec/uucp/libunix/pause.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* pause.c
- Pause for half a second. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-#include "system.h"
-
-/* Pick a timing routine to use. I somewhat arbitrarily picked usleep
- above napms above poll above select above nap. The nap function is
- last because on different systems the argument has different
- meanings. */
-#if HAVE_USLEEP || HAVE_NAPMS || HAVE_POLL || HAVE_SELECT
-#undef HAVE_NAP
-#define HAVE_NAP 0
-#endif
-
-#if HAVE_USLEEP || HAVE_NAPMS || HAVE_POLL
-#undef HAVE_SELECT
-#define HAVE_SELECT 0
-#endif
-
-#if HAVE_USLEEP || HAVE_NAPMS
-#undef HAVE_POLL
-#define HAVE_POLL 0
-#endif
-
-#if HAVE_USLEEP
-#undef HAVE_NAPMS
-#define HAVE_NAPMS 0
-#endif
-
-#if HAVE_SELECT
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#if HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-#endif
-
-#if HAVE_POLL
-#if HAVE_STROPTS_H
-#include <stropts.h>
-#endif
-#if HAVE_POLL_H
-#include <poll.h>
-#endif
-#if ! HAVE_STROPTS_H && ! HAVE_POLL_H
-/* We need a definition for struct pollfd, although it doesn't matter
- what it contains. */
-struct pollfd
-{
- int idummy;
-};
-#endif /* ! HAVE_STROPTS_H && ! HAVE_POLL_H */
-#endif /* HAVE_POLL */
-
-#if HAVE_TIME_H
-#if ! HAVE_SYS_TIME_H || ! HAVE_SELECT || TIME_WITH_SYS_TIME
-#include <time.h>
-#endif
-#endif
-
-void
-usysdep_pause ()
-{
-#if HAVE_NAPMS
- napms (500);
-#endif /* HAVE_NAPMS */
-#if HAVE_NAP
-#if HAVE_HUNDREDTHS_NAP
- nap (50L);
-#else
- nap (500L);
-#endif /* ! HAVE_HUNDREDTHS_NAP */
-#endif /* HAVE_NAP */
-#if HAVE_USLEEP
- usleep (500 * (long) 1000);
-#endif /* HAVE_USLEEP */
-#if HAVE_POLL
- struct pollfd sdummy;
-
- /* We need to pass an unused pollfd structure because poll checks
- the address before checking the number of elements. */
- memset (&sdummy, 0, sizeof sdummy);
- poll (&sdummy, 0, 500);
-#endif /* HAVE_POLL */
-#if HAVE_SELECT
- struct timeval s;
-
- s.tv_sec = 0;
- s.tv_usec = 500 * (long) 1000;
- select (0, (pointer) NULL, (pointer) NULL, (pointer) NULL, &s);
-#endif /* HAVE_SELECT */
-#if ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP
-#if ! HAVE_SELECT && ! HAVE_POLL
- sleep (1);
-#endif /* ! HAVE_SELECT && ! HAVE_POLL */
-#endif /* ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP */
-}
diff --git a/gnu/libexec/uucp/libunix/picksb.c b/gnu/libexec/uucp/libunix/picksb.c
deleted file mode 100644
index 563748b..0000000
--- a/gnu/libexec/uucp/libunix/picksb.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/* picksb.c
- System dependent routines for uupick.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char picksb_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "system.h"
-#include "sysdep.h"
-
-#include <errno.h>
-#include <pwd.h>
-
-#if HAVE_OPENDIR
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#else /* ! HAVE_DIRENT_H */
-#include <sys/dir.h>
-#define dirent direct
-#endif /* ! HAVE_DIRENT_H */
-#endif /* HAVE_OPENDIR */
-
-#if GETPWUID_DECLARATION_OK
-#ifndef getpwuid
-extern struct passwd *getpwuid ();
-#endif
-#endif
-
-/* Local variables. */
-
-/* Directory of ~/receive/USER. */
-static DIR *qStopdir;
-
-/* Name of ~/receive/USER. */
-static char *zStopdir;
-
-/* Directory of ~/receive/USER/SYSTEM. */
-static DIR *qSsysdir;
-
-/* Name of system. */
-static char *zSsysdir;
-
-/* Prepare to get a list of all the file to uupick for this user. */
-
-/*ARGSUSED*/
-boolean
-fsysdep_uupick_init (zsystem, zpubdir)
- const char *zsystem;
- const char *zpubdir;
-{
- const char *zuser;
-
- zuser = zsysdep_login_name ();
-
- zStopdir = (char *) xmalloc (strlen (zpubdir)
- + sizeof "/receive/"
- + strlen (zuser));
- sprintf (zStopdir, "%s/receive/%s", zpubdir, zuser);
-
- qStopdir = opendir (zStopdir);
- if (qStopdir == NULL && errno != ENOENT)
- {
- ulog (LOG_ERROR, "opendir (%s): %s", zStopdir,
- strerror (errno));
- return FALSE;
- }
-
- qSsysdir = NULL;
-
- return TRUE;
-}
-
-/* Return the next file from the uupick directories. */
-
-/*ARGSUSED*/
-char *
-zsysdep_uupick (zsysarg, zpubdir, pzfrom, pzfull)
- const char *zsysarg;
- const char *zpubdir;
- char **pzfrom;
- char **pzfull;
-{
- struct dirent *qentry;
-
- while (TRUE)
- {
- while (qSsysdir == NULL)
- {
- const char *zsystem;
- char *zdir;
-
- if (qStopdir == NULL)
- return NULL;
-
- if (zsysarg != NULL)
- {
- closedir (qStopdir);
- qStopdir = NULL;
- zsystem = zsysarg;
- }
- else
- {
- do
- {
- qentry = readdir (qStopdir);
- if (qentry == NULL)
- {
- closedir (qStopdir);
- qStopdir = NULL;
- return NULL;
- }
- }
- while (strcmp (qentry->d_name, ".") == 0
- || strcmp (qentry->d_name, "..") == 0);
-
- zsystem = qentry->d_name;
- }
-
- zdir = zbufalc (strlen (zStopdir) + strlen (zsystem) + sizeof "/");
- sprintf (zdir, "%s/%s", zStopdir, zsystem);
-
- qSsysdir = opendir (zdir);
- if (qSsysdir == NULL)
- {
- if (errno != ENOENT && errno != ENOTDIR)
- ulog (LOG_ERROR, "opendir (%s): %s", zdir, strerror (errno));
- }
- else
- {
- ubuffree (zSsysdir);
- zSsysdir = zbufcpy (zsystem);
- }
-
- ubuffree (zdir);
- }
-
- qentry = readdir (qSsysdir);
- if (qentry == NULL)
- {
- closedir (qSsysdir);
- qSsysdir = NULL;
- continue;
- }
-
- if (strcmp (qentry->d_name, ".") == 0
- || strcmp (qentry->d_name, "..") == 0)
- continue;
-
- *pzfrom = zbufcpy (zSsysdir);
- *pzfull = zsappend3 (zStopdir, zSsysdir, qentry->d_name);
- return zbufcpy (qentry->d_name);
- }
-}
-
-/*ARGSUSED*/
-boolean
-fsysdep_uupick_free (zsystem, zpubdir)
- const char *zsystem;
- const char *zpubdir;
-{
- xfree ((pointer) zStopdir);
- if (qStopdir != NULL)
- {
- closedir (qStopdir);
- qStopdir = NULL;
- }
- ubuffree (zSsysdir);
- zSsysdir = NULL;
- if (qSsysdir != NULL)
- {
- closedir (qSsysdir);
- qSsysdir = NULL;
- }
-
- return TRUE;
-}
-
-/* Expand a local file name for uupick. */
-
-char *
-zsysdep_uupick_local_file (zfile, pfbadname)
- const char *zfile;
- boolean *pfbadname;
-{
- struct passwd *q;
-
- if (pfbadname != NULL)
- *pfbadname = FALSE;
-
- /* If this does not start with a simple ~, pass it to
- zsysdep_local_file_cwd; as it happens, zsysdep_local_file_cwd
- only uses the zpubdir argument if the file starts with a simple
- ~, so it doesn't really matter what we pass for zpubdir. */
- if (zfile[0] != '~'
- || (zfile[1] != '/' && zfile[1] != '\0'))
- return zsysdep_local_file_cwd (zfile, (const char *) NULL, pfbadname);
-
- q = getpwuid (getuid ());
- if (q == NULL)
- {
- ulog (LOG_ERROR, "Can't get home directory");
- return NULL;
- }
-
- if (zfile[1] == '\0')
- return zbufcpy (q->pw_dir);
-
- return zsysdep_in_dir (q->pw_dir, zfile + 2);
-}
diff --git a/gnu/libexec/uucp/libunix/pipe.c b/gnu/libexec/uucp/libunix/pipe.c
deleted file mode 100644
index 71adfa3..0000000
--- a/gnu/libexec/uucp/libunix/pipe.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/* pipe.c
- The pipe port communication routines for Unix.
- Contributed by Marc Boucher <marc@CAM.ORG>.
-
- Copyright (C) 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char pipe_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "conn.h"
-#include "sysdep.h"
-
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-/* Local functions. */
-
-static void uspipe_free P((struct sconnection *qconn));
-static boolean fspipe_open P((struct sconnection *qconn, long ibaud,
- boolean fwait));
-static boolean fspipe_close P((struct sconnection *qconn,
- pointer puuconf,
- struct uuconf_dialer *qdialer,
- boolean fsuccess));
-static boolean fspipe_dial P((struct sconnection *qconn, pointer puuconf,
- const struct uuconf_system *qsys,
- const char *zphone,
- struct uuconf_dialer *qdialer,
- enum tdialerfound *ptdialer));
-
-/* The command table for standard input ports. */
-
-static const struct sconncmds spipecmds =
-{
- uspipe_free,
- NULL, /* pflock */
- NULL, /* pfunlock */
- fspipe_open,
- fspipe_close,
- fspipe_dial,
- fsdouble_read,
- fsdouble_write,
- fsysdep_conn_io,
- NULL, /* pfbreak */
- NULL, /* pfset */
- NULL, /* pfcarrier */
- fsdouble_chat,
- NULL /* pibaud */
-};
-
-/* Initialize a pipe connection. */
-
-boolean
-fsysdep_pipe_init (qconn)
- struct sconnection *qconn;
-{
- struct ssysdep_conn *q;
-
- q = (struct ssysdep_conn *) xmalloc (sizeof (struct ssysdep_conn));
- q->o = -1;
- q->ord = -1;
- q->owr = -1;
- q->zdevice = NULL;
- q->iflags = -1;
- q->iwr_flags = -1;
- q->fterminal = FALSE;
- q->ftli = FALSE;
- q->ibaud = 0;
- q->ipid = -1;
- qconn->psysdep = (pointer) q;
- qconn->qcmds = &spipecmds;
- return TRUE;
-}
-
-static void
-uspipe_free (qconn)
- struct sconnection *qconn;
-{
- xfree (qconn->psysdep);
-}
-
-/* Open a pipe port. */
-
-/*ARGSUSED*/
-static boolean
-fspipe_open (qconn, ibaud, fwait)
- struct sconnection *qconn;
- long ibaud;
- boolean fwait;
-{
- /* We don't do incoming waits on pipes. */
- if (fwait)
- return FALSE;
-
- return TRUE;
-}
-
-/* Close a pipe port. */
-
-/*ARGSUSED*/
-static boolean
-fspipe_close (qconn, puuconf, qdialer, fsuccess)
- struct sconnection *qconn;
- pointer puuconf;
- struct uuconf_dialer *qdialer;
- boolean fsuccess;
-{
- struct ssysdep_conn *qsysdep;
- boolean fret;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- fret = TRUE;
-
- /* Close our sides of the pipe. */
- if (qsysdep->ord >= 0 && close (qsysdep->ord) < 0)
- {
- ulog (LOG_ERROR, "fspipe_close: close read fd: %s", strerror (errno));
- fret = FALSE;
- }
- if (qsysdep->owr != qsysdep->ord
- && qsysdep->owr >= 0
- && close (qsysdep->owr) < 0)
- {
- ulog (LOG_ERROR, "fspipe_close: close write fd: %s", strerror (errno));
- fret = FALSE;
- }
- qsysdep->ord = -1;
- qsysdep->owr = -1;
-
- /* Kill dangling child process. */
- if (qsysdep->ipid >= 0)
- {
- if (kill (qsysdep->ipid, SIGHUP) == 0)
- usysdep_sleep (2);
-#ifdef SIGPIPE
- if (kill (qsysdep->ipid, SIGPIPE) == 0)
- usysdep_sleep (2);
-#endif
- if (kill (qsysdep->ipid, SIGKILL) < 0 && errno == EPERM)
- {
- ulog (LOG_ERROR, "fspipe_close: Cannot kill child pid %lu: %s",
- (unsigned long) qsysdep->ipid, strerror (errno));
- fret = FALSE;
- }
- else
- (void) ixswait ((unsigned long) qsysdep->ipid, (const char *) NULL);
- }
- qsysdep->ipid = -1;
- return fret;
-}
-
-/* Dial out on a pipe port, so to speak: launch connection program
- under us. The code alternates q->o between q->ord and q->owr as
- appropriate. It is always q->ord before any call to fsblock. */
-
-/*ARGSUSED*/
-static boolean
-fspipe_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialer)
- struct sconnection *qconn;
- pointer puuconf;
- const struct uuconf_system *qsys;
- const char *zphone;
- struct uuconf_dialer *qdialer;
- enum tdialerfound *ptdialer;
-{
- struct ssysdep_conn *q;
- int aidescs[3];
- const char **pzprog;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
-
- *ptdialer = DIALERFOUND_FALSE;
-
- pzprog = (const char **) qconn->qport->uuconf_u.uuconf_spipe.uuconf_pzcmd;
-
- if (pzprog == NULL)
- {
- ulog (LOG_ERROR, "No command for pipe connection");
- return FALSE;
- }
-
- aidescs[0] = SPAWN_WRITE_PIPE;
- aidescs[1] = SPAWN_READ_PIPE;
- aidescs[2] = SPAWN_NULL;
-
- /* Pass fkeepuid, fkeepenv and fshell as TRUE. This puts the
- responsibility of security on the connection program. */
- q->ipid = ixsspawn (pzprog, aidescs, TRUE, TRUE, (const char *) NULL,
- FALSE, TRUE, (const char *) NULL,
- (const char *) NULL, (const char *) NULL);
- if (q->ipid < 0)
- {
- ulog (LOG_ERROR, "ixsspawn (%s): %s", pzprog[0], strerror (errno));
- return FALSE;
- }
-
- q->owr = aidescs[0];
- q->ord = aidescs[1];
- q->o = q->ord;
-
- q->iflags = fcntl (q->ord, F_GETFL, 0);
- q->iwr_flags = fcntl (q->owr, F_GETFL, 0);
- if (q->iflags < 0 || q->iwr_flags < 0)
- {
- ulog (LOG_ERROR, "fspipe_dial: fcntl: %s", strerror (errno));
- (void) fspipe_close (qconn, puuconf, qdialer, FALSE);
- return FALSE;
- }
-
- return TRUE;
-}
-
-#if 0
-
-/* Marc Boucher's contributed code used an alarm to avoid waiting too
- long when closing the pipe. However, I believe that it is not
- possible for the kernel to sleep when closing a pipe; it is only
- possible when closing a device. Therefore, I have removed the
- code, but am preserving it in case I am wrong. To reenable it, the
- two calls to close in fspipe_close should be changed to call
- fspipe_alarmclose. */
-
-static RETSIGTYPE
-usalarm (isig)
- int isig;
-{
-#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET
- (void) signal (isig, usalarm);
-#endif
-
-#if HAVE_RESTARTABLE_SYSCALLS
- longjmp (sSjmp_buf, 1);
-#endif
-}
-
-static int
-fspipe_alarmclose (fd)
- int fd;
-{
- int iret = -1;
- int ierrno = 0;
-
- if (fsysdep_catch ())
- {
- usysdep_start_catch ();
- usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL);
- (void) alarm (30);
-
- iret = close (fd);
- ierrno = errno;
- }
-
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- (void) alarm (0);
- usysdep_end_catch ();
-
- errno = ierrno;
- return iret;
-}
-
-#endif /* 0 */
diff --git a/gnu/libexec/uucp/libunix/portnm.c b/gnu/libexec/uucp/libunix/portnm.c
deleted file mode 100644
index 9eda4ab..0000000
--- a/gnu/libexec/uucp/libunix/portnm.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* portnm.c
- Get the port name of stdin. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-#include "system.h"
-
-#if HAVE_TCP
-#if HAVE_SYS_TYPES_TCP_H
-#include <sys/types.tcp.h>
-#endif
-#include <sys/socket.h>
-#endif
-
-#ifndef ttyname
-extern char *ttyname ();
-#endif
-
-/* Get the port name of standard input. I assume that Unix systems
- generally support ttyname. If they don't, this function can just
- return NULL. It uses getsockname to see whether standard input is
- a TCP connection. */
-
-const char *
-zsysdep_port_name (ftcp_port)
- boolean *ftcp_port;
-{
- const char *z;
-
- *ftcp_port = FALSE;
-
-#if HAVE_TCP
- {
- size_t clen;
- struct sockaddr s;
-
- clen = sizeof (struct sockaddr);
- if (getsockname (0, &s, &clen) == 0)
- *ftcp_port = TRUE;
- }
-#endif /* HAVE_TCP */
-
- z = ttyname (0);
- if (z == NULL)
- return NULL;
- if (strncmp (z, "/dev/", sizeof "/dev/" - 1) == 0)
- return z + sizeof "/dev/" - 1;
- else
- return z;
-}
diff --git a/gnu/libexec/uucp/libunix/priv.c b/gnu/libexec/uucp/libunix/priv.c
deleted file mode 100644
index 207bd3d..0000000
--- a/gnu/libexec/uucp/libunix/priv.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* priv.c
- See if a user is privileged. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-#include "system.h"
-
-/* See whether the user is privileged (for example, only privileged
- users are permitted to kill arbitrary jobs with uustat). This is
- true only for root and uucp. We check for uucp by seeing if the
- real user ID and the effective user ID are the same; this works
- because we should be suid to uucp, so our effective user ID will
- always be uucp while our real user ID will be whoever ran the
- program. */
-
-boolean
-fsysdep_privileged ()
-{
- uid_t iuid;
-
- iuid = getuid ();
- return iuid == 0 || iuid == geteuid ();
-}
diff --git a/gnu/libexec/uucp/libunix/proctm.c b/gnu/libexec/uucp/libunix/proctm.c
deleted file mode 100644
index 912b11b..0000000
--- a/gnu/libexec/uucp/libunix/proctm.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/* proctm.c
- Get the time spent in the process.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-#include "system.h"
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-/* Prefer gettimeofday to ftime to times. */
-
-#if HAVE_GETTIMEOFDAY || HAVE_FTIME
-#undef HAVE_TIMES
-#define HAVE_TIMES 0
-#endif
-
-#if HAVE_GETTIMEOFDAY
-#undef HAVE_FTIME
-#define HAVE_FTIME 0
-#endif
-
-#if HAVE_TIME_H && (TIME_WITH_SYS_TIME || ! HAVE_GETTIMEOFDAY)
-#include <time.h>
-#endif
-
-#if HAVE_GETTIMEOFDAY
-#include <sys/time.h>
-#endif
-
-#if HAVE_FTIME
-#include <sys/timeb.h>
-#endif
-
-#if HAVE_TIMES
-
-#if HAVE_SYS_TIMES_H
-#include <sys/times.h>
-#endif
-
-#if TIMES_DECLARATION_OK
-/* We use a macro to protect this because times really returns clock_t
- and on some systems, such as Ultrix 4.0, clock_t is int. We don't
- leave it out entirely because on some systems, such as System III,
- the declaration is necessary for correct compilation. */
-#ifndef times
-extern long times ();
-#endif
-#endif /* TIMES_DECLARATION_OK */
-
-#ifdef _SC_CLK_TCK
-#define HAVE_SC_CLK_TCK 1
-#else
-#define HAVE_SC_CLK_TCK 0
-#endif
-
-/* TIMES_TICK may have been set in policy.h, or we may be able to get
- it using sysconf. If neither is the case, try to find a useful
- definition from the system header files. */
-#if TIMES_TICK == 0 && (! HAVE_SYSCONF || ! HAVE_SC_CLK_TCK)
-#ifdef CLK_TCK
-#undef TIMES_TICK
-#define TIMES_TICK CLK_TCK
-#else /* ! defined (CLK_TCK) */
-#ifdef HZ
-#undef TIMES_TICK
-#define TIMES_TICK HZ
-#endif /* defined (HZ) */
-#endif /* ! defined (CLK_TCK) */
-#endif /* TIMES_TICK == 0 && (! HAVE_SYSCONF || ! HAVE_SC_CLK_TCK) */
-
-#endif /* HAVE_TIMES */
-
-#ifndef time
-extern time_t time ();
-#endif
-#if HAVE_SYSCONF
-#ifndef sysconf
-extern long sysconf ();
-#endif
-#endif
-
-/* Get the time in seconds and microseconds; this need only work
- within the process when called from the system independent code.
- It is also called by ixsysdep_time. */
-
-long
-ixsysdep_process_time (pimicros)
- long *pimicros;
-{
-#if HAVE_GETTIMEOFDAY
- struct timeval stime;
- struct timezone stz;
-
- (void) gettimeofday (&stime, &stz);
- if (pimicros != NULL)
- *pimicros = (long) stime.tv_usec;
- return (long) stime.tv_sec;
-#endif /* HAVE_GETTIMEOFDAY */
-
-#if HAVE_FTIME
- static boolean fbad;
-
- if (! fbad)
- {
- struct timeb stime;
- static struct timeb slast;
-
- (void) ftime (&stime);
-
- /* On some systems, such as SCO 3.2.2, ftime can go backwards in
- time. If we detect this, we switch to using time. */
- if (slast.time != 0
- && (stime.time < slast.time
- || (stime.time == slast.time &&
- stime.millitm < slast.millitm)))
- fbad = TRUE;
- else
- {
- slast = stime;
- if (pimicros != NULL)
- *pimicros = (long) stime.millitm * (long) 1000;
- return (long) stime.time;
- }
- }
-
- if (pimicros != NULL)
- *pimicros = 0;
- return (long) time ((time_t *) NULL);
-#endif /* HAVE_FTIME */
-
-#if HAVE_TIMES
- struct tms s;
- long i;
- static int itick;
-
- if (itick == 0)
- {
-#if TIMES_TICK == 0
-#if HAVE_SYSCONF && HAVE_SC_CLK_TCK
- itick = (int) sysconf (_SC_CLK_TCK);
-#else /* ! HAVE_SYSCONF || ! HAVE_SC_CLK_TCK */
- const char *z;
-
- z = getenv ("HZ");
- if (z != NULL)
- itick = (int) strtol (z, (char **) NULL, 10);
-
- /* If we really couldn't get anything, just use 60. */
- if (itick == 0)
- itick = 60;
-#endif /* ! HAVE_SYSCONF || ! HAVE_SC_CLK_TCK */
-#else /* TIMES_TICK != 0 */
- itick = TIMES_TICK;
-#endif /* TIMES_TICK == 0 */
- }
-
- i = (long) times (&s);
- if (pimicros != NULL)
- *pimicros = (i % (long) itick) * ((long) 1000000 / (long) itick);
- return i / (long) itick;
-#endif /* HAVE_TIMES */
-
-#if ! HAVE_GETTIMEOFDAY && ! HAVE_FTIME && ! HAVE_TIMES
- if (pimicros != NULL)
- *pimicros = 0;
- return (long) time ((time_t *) NULL);
-#endif /* ! HAVE_GETTIMEOFDAY && ! HAVE_FTIME && ! HAVE_TIMES */
-}
diff --git a/gnu/libexec/uucp/libunix/recep.c b/gnu/libexec/uucp/libunix/recep.c
deleted file mode 100644
index a1f893d..0000000
--- a/gnu/libexec/uucp/libunix/recep.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/* recep.c
- See whether a file has already been received.
-
- Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_TIME_H
-#include <time.h>
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-static char *zsreceived_name P((const struct uuconf_system *qsys,
- const char *ztemp));
-
-/* These routines are used to see whether we have already received a
- file in a previous UUCP connection. It is possible for the
- acknowledgement of a received file to be lost. The sending system
- will then not know that the file was correctly received, and will
- send it again. This can be a problem particularly with protocols
- which support channels, since they may send several small files in
- a single window, all of which may be received correctly although
- the sending system never sees the acknowledgement. If these files
- involve an execution, the execution will happen twice, which will
- be bad.
-
- We use a simple system. For each file we want to remember, we
- create an empty file names .Received/SYS/TEMP, where SYS is the
- name of the system and TEMP is the name of the temporary file used
- by the sender. If no temporary file is used by the sender, we
- don't remember that we received the file. This is not perfect, but
- execution files will always have a temporary file, so the most
- important case is handled. Also, any file received from Taylor
- UUCP 1.04 or greater will always have a temporary file. */
-
-/* Return the name we are going use for the marker, or NULL if we have
- no name. */
-
-static char *
-zsreceived_name (qsys, ztemp)
- const struct uuconf_system *qsys;
- const char *ztemp;
-{
- if (ztemp != NULL
- && *ztemp == 'D'
- && strcmp (ztemp, "D.0") != 0)
- return zsappend3 (".Received", qsys->uuconf_zname, ztemp);
- else
- return NULL;
-}
-
-/* Remember that we have already received a file. */
-
-/*ARGSUSED*/
-boolean
-fsysdep_remember_reception (qsys, zto, ztemp)
- const struct uuconf_system *qsys;
- const char *zto;
- const char *ztemp;
-{
- char *zfile;
- int o;
-
- zfile = zsreceived_name (qsys, ztemp);
- if (zfile == NULL)
- return TRUE;
- o = creat (zfile, IPUBLIC_FILE_MODE);
- if (o < 0)
- {
- if (errno == ENOENT)
- {
- if (fsysdep_make_dirs (zfile, FALSE))
- {
- ubuffree (zfile);
- return FALSE;
- }
- o = creat (zfile, IPUBLIC_FILE_MODE);
- }
- if (o < 0)
- {
- ulog (LOG_ERROR, "creat (%s): %s", zfile, strerror (errno));
- ubuffree (zfile);
- return FALSE;
- }
- }
-
- ubuffree (zfile);
-
- /* We don't have to actually put anything in the file; we just use
- the name. This is more convenient than keeping a file with a
- list of names. */
- if (close (o) < 0)
- {
- ulog (LOG_ERROR, "fsysdep_remember_reception: close: %s",
- strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* The number of seconds in one week. We must cast to long for this
- to be calculated correctly on a machine with 16 bit ints. */
-#define SECS_PER_WEEK ((long) 7 * (long) 24 * (long) 60 * (long) 60)
-
-/* See if we have already received a file. Note that don't delete the
- marker file here, because we need to know that the sending system
- has received our denial first. This function returns TRUE if the
- file has already been received, FALSE if it has not. */
-
-/*ARGSUSED*/
-boolean
-fsysdep_already_received (qsys, zto, ztemp)
- const struct uuconf_system *qsys;
- const char *zto;
- const char *ztemp;
-{
- char *zfile;
- struct stat s;
- boolean fret;
-
- zfile = zsreceived_name (qsys, ztemp);
- if (zfile == NULL)
- return FALSE;
- if (stat (zfile, &s) < 0)
- {
- if (errno != ENOENT)
- ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno));
- ubuffree (zfile);
- return FALSE;
- }
-
- /* Ignore the file (return FALSE) if it is over one week old. */
- fret = s.st_mtime + SECS_PER_WEEK >= time ((time_t *) NULL);
-
- if (fret)
- DEBUG_MESSAGE1 (DEBUG_SPOOLDIR, "fsysdep_already_received: Found %s",
- zfile);
-
- ubuffree (zfile);
-
- return fret;
-}
-
-/* Forget that we have received a file. */
-
-/*ARGSUSED*/
-boolean
-fsysdep_forget_reception (qsys, zto, ztemp)
- const struct uuconf_system *qsys;
- const char *zto;
- const char *ztemp;
-{
- char *zfile;
-
- zfile = zsreceived_name (qsys, ztemp);
- if (zfile == NULL)
- return TRUE;
- if (remove (zfile) < 0
- && errno != ENOENT)
- {
- ulog (LOG_ERROR, "remove (%s): %s", zfile, strerror (errno));
- ubuffree (zfile);
- return FALSE;
- }
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/remove.c b/gnu/libexec/uucp/libunix/remove.c
deleted file mode 100644
index b695888..0000000
--- a/gnu/libexec/uucp/libunix/remove.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* remove.c
- Remove a file (Unix specific implementation). */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-
-int
-remove (z)
- const char *z;
-{
- return unlink (z);
-}
diff --git a/gnu/libexec/uucp/libunix/rename.c b/gnu/libexec/uucp/libunix/rename.c
deleted file mode 100644
index 0947ef5..0000000
--- a/gnu/libexec/uucp/libunix/rename.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* rename.c
- Rename a file to a new name (Unix specific implementation). */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-
-#include <errno.h>
-
-/* This implementation will not work on directories, but fortunately
- we never want to rename directories. */
-
-int
-rename (zfrom, zto)
- const char *zfrom;
- const char *zto;
-{
- if (link (zfrom, zto) < 0)
- {
- if (errno != EEXIST)
- return -1;
- if (unlink (zto) < 0
- || link (zfrom, zto) < 0)
- return -1;
- }
- return unlink (zfrom);
-}
diff --git a/gnu/libexec/uucp/libunix/rmdir.c b/gnu/libexec/uucp/libunix/rmdir.c
deleted file mode 100644
index 12a7b9e..0000000
--- a/gnu/libexec/uucp/libunix/rmdir.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* rmdir.c
- Remove a directory on a system which doesn't have the rmdir system
- call. This is only called by uupick, which is not setuid, so we
- don't have to worry about the problems of invoking the setuid
- /bin/rmdir program. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-
-#include <errno.h>
-
-int
-rmdir (zdir)
- const char *zdir;
-{
- const char *azargs[3];
- int aidescs[3];
- pid_t ipid;
-
- azargs[0] = RMDIR_PROGRAM;
- azargs[1] = zdir;
- azargs[2] = NULL;
- aidescs[0] = SPAWN_NULL;
- aidescs[1] = SPAWN_NULL;
- aidescs[2] = SPAWN_NULL;
-
- ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, (const char *) NULL,
- TRUE, TRUE, (const char *) NULL,
- (const char *) NULL, (const char *) NULL);
-
- if (ipid < 0)
- return -1;
-
- if (ixswait ((unsigned long) ipid, (const char *) NULL) != 0)
- {
- /* Make up an errno value. */
- errno = EBUSY;
- return -1;
- }
-
- return 0;
-}
diff --git a/gnu/libexec/uucp/libunix/run.c b/gnu/libexec/uucp/libunix/run.c
deleted file mode 100644
index d789d37..0000000
--- a/gnu/libexec/uucp/libunix/run.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* run.c
- Run a program.
-
- Copyright (C) 1992, 1993, 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-/* Start up a new program. */
-
-boolean
-fsysdep_run (ffork, zprogram, zarg1, zarg2)
- boolean ffork;
- const char *zprogram;
- const char *zarg1;
- const char *zarg2;
-{
- char *zlib;
- const char *azargs[4];
- int aidescs[3];
- pid_t ipid;
-
- /* If we are supposed to fork, fork and then spawn so that we don't
- have to worry about zombie processes. */
- if (ffork)
- {
- ipid = ixsfork ();
- if (ipid < 0)
- {
- ulog (LOG_ERROR, "fork: %s", strerror (errno));
- return FALSE;
- }
-
- if (ipid != 0)
- {
- /* This is the parent. Wait for the child we just forked to
- exit (below) and return. */
- (void) ixswait ((unsigned long) ipid, (const char *) NULL);
-
- /* Force the log files to be reopened in case the child just
- output any error messages and stdio doesn't handle
- appending correctly. */
- ulog_close ();
-
- return TRUE;
- }
-
- /* This is the child. Detach from the terminal to avoid any
- unexpected SIGHUP signals. At this point we are definitely
- not a process group leader, so usysdep_detach will not fork
- again. */
- usysdep_detach ();
-
- /* Now spawn the program and then exit. */
- }
-
- zlib = zbufalc (sizeof SBINDIR + sizeof "/" + strlen (zprogram));
- sprintf (zlib, "%s/%s", SBINDIR, zprogram);
-
- azargs[0] = zlib;
- azargs[1] = zarg1;
- azargs[2] = zarg2;
- azargs[3] = NULL;
-
- aidescs[0] = SPAWN_NULL;
- aidescs[1] = SPAWN_NULL;
- aidescs[2] = SPAWN_NULL;
-
- /* We pass fsetuid and fshell as TRUE, which permits uucico and
- uuxqt to be replaced by (non-setuid) shell scripts. */
- ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, (const char *) NULL,
- FALSE, TRUE, (const char *) NULL,
- (const char *) NULL, (const char *) NULL);
- ubuffree (zlib);
-
- if (ipid < 0)
- {
- ulog (LOG_ERROR, "ixsspawn: %s", strerror (errno));
- if (ffork)
- _exit (EXIT_FAILURE);
- return FALSE;
- }
-
- if (ffork)
- _exit (EXIT_SUCCESS);
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/seq.c b/gnu/libexec/uucp/libunix/seq.c
deleted file mode 100644
index 321ed74..0000000
--- a/gnu/libexec/uucp/libunix/seq.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* seq.c
- Get and increment the conversation sequence number for a system.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-/* Get the current conversation sequence number for a remote system,
- and increment it for next time. The conversation sequence number
- is kept in a file named for the system in the directory .Sequence
- in the spool directory. This is not compatible with other versions
- of UUCP, but it makes more sense to me. The sequence file is only
- used if specified in the information for that system. */
-
-long
-ixsysdep_get_sequence (qsys)
- const struct uuconf_system *qsys;
-{
- FILE *e;
- char *zname;
- struct stat s;
- long iseq;
-
- /* This will only be called when the system is locked anyhow, so there
- is no need to use a separate lock for the conversation sequence
- file. */
- zname = zsysdep_in_dir (".Sequence", qsys->uuconf_zname);
-
- iseq = 0;
- if (stat (zname, &s) == 0)
- {
- boolean fok;
- char *zline;
- size_t cline;
-
- /* The file should only be readable and writable by uucp. */
- if ((s.st_mode & (S_IRWXG | S_IRWXO)) != 0)
- {
- ulog (LOG_ERROR,
- "Bad file protection for conversation sequence file");
- ubuffree (zname);
- return -1;
- }
-
- e = fopen (zname, "r+");
- if (e == NULL)
- {
- ulog (LOG_ERROR, "fopen (%s): %s", zname, strerror (errno));
- ubuffree (zname);
- return -1;
- }
-
- ubuffree (zname);
-
- fok = TRUE;
- zline = NULL;
- cline = 0;
- if (getline (&zline, &cline, e) <= 0)
- fok = FALSE;
- else
- {
- char *zend;
-
- iseq = strtol (zline, &zend, 10);
- if (zend == zline)
- fok = FALSE;
- }
-
- xfree ((pointer) zline);
-
- if (! fok)
- {
- ulog (LOG_ERROR, "Bad format for conversation sequence file");
- (void) fclose (e);
- return -1;
- }
-
- rewind (e);
- }
- else
- {
- e = esysdep_fopen (zname, FALSE, FALSE, TRUE);
- ubuffree (zname);
- if (e == NULL)
- return -1;
- }
-
- ++iseq;
-
- fprintf (e, "%ld", iseq);
-
- if (fclose (e) != 0)
- {
- ulog (LOG_ERROR, "fclose: %s", strerror (errno));
- return -1;
- }
-
- return iseq;
-}
diff --git a/gnu/libexec/uucp/libunix/serial.c b/gnu/libexec/uucp/libunix/serial.c
deleted file mode 100644
index f10be4c..0000000
--- a/gnu/libexec/uucp/libunix/serial.c
+++ /dev/null
@@ -1,3401 +0,0 @@
-/* serial.c
- The serial port communication routines for Unix.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char serial_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "conn.h"
-#include "sysdep.h"
-
-#include <errno.h>
-#include <ctype.h>
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#if HAVE_TLI
-#if HAVE_TIUSER_H
-#include <tiuser.h>
-#else /* ! HAVE_TIUSER_H */
-#if HAVE_XTI_H
-#include <xti.h>
-#endif /* HAVE_XTI_H */
-#endif /* ! HAVE_TIUSER_H */
-#endif /* HAVE_TLI */
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-#if HAVE_SYS_IOCTL_H || HAVE_TXADDCD
-#include <sys/ioctl.h>
-#endif
-
-#if HAVE_SELECT
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#if HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-#endif
-
-#if HAVE_TIME_H
-#if ! HAVE_SYS_TIME_H || ! HAVE_SELECT || TIME_WITH_SYS_TIME
-#include <time.h>
-#endif
-#endif
-
-#if HAVE_STRIP_BUG && HAVE_BSD_TTY
-#include <termio.h>
-#endif
-
-#if HAVE_SVR4_LOCKFILES
-/* Get the right definitions for major and minor. */
-#if MAJOR_IN_MKDEV
-#include <sys/mkdev.h>
-#endif /* MAJOR_IN_MKDEV */
-#if MAJOR_IN_SYSMACROS
-#include <sys/sysmacros.h>
-#endif /* MAJOR_IN_SYSMACROS */
-#if ! MAJOR_IN_MKDEV && ! MAJOR_IN_SYSMACROS
-#ifndef major
-#define major(i) (((i) >> 8) & 0xff)
-#endif
-#ifndef minor
-#define minor(i) ((i) & 0xff)
-#endif
-#endif /* ! MAJOR_IN_MKDEV && ! MAJOR_IN_SYSMACROS */
-#endif /* HAVE_SVR4_LOCKFILES */
-
-#if HAVE_DEV_INFO
-#include <sys/dev.h>
-#endif
-
-/* Get definitions for both O_NONBLOCK and O_NDELAY. */
-#ifndef O_NDELAY
-#ifdef FNDELAY
-#define O_NDELAY FNDELAY
-#else /* ! defined (FNDELAY) */
-#define O_NDELAY 0
-#endif /* ! defined (FNDELAY) */
-#endif /* ! defined (O_NDELAY) */
-
-#ifndef O_NONBLOCK
-#ifdef FNBLOCK
-#define O_NONBLOCK FNBLOCK
-#else /* ! defined (FNBLOCK) */
-#define O_NONBLOCK 0
-#endif /* ! defined (FNBLOCK) */
-#endif /* ! defined (O_NONBLOCK) */
-
-#if O_NDELAY == 0 && O_NONBLOCK == 0
- #error No way to do nonblocking I/O
-#endif
-
-/* Get definitions for EAGAIN, EWOULDBLOCK and ENODATA. */
-#ifndef EAGAIN
-#ifndef EWOULDBLOCK
-#define EAGAIN (-1)
-#define EWOULDBLOCK (-1)
-#else /* defined (EWOULDBLOCK) */
-#define EAGAIN EWOULDBLOCK
-#endif /* defined (EWOULDBLOCK) */
-#else /* defined (EAGAIN) */
-#ifndef EWOULDBLOCK
-#define EWOULDBLOCK EAGAIN
-#endif /* ! defined (EWOULDBLOCK) */
-#endif /* defined (EAGAIN) */
-
-#ifndef ENODATA
-#define ENODATA EAGAIN
-#endif
-
-/* Make sure we have a definition for MAX_INPUT. */
-#ifndef MAX_INPUT
-#define MAX_INPUT (256)
-#endif
-
-/* If we have the TIOCSINUSE ioctl call, we use it to lock a terminal.
- Otherwise, if we have the TIOCEXCL ioctl call, we have to open the
- terminal before we know that it is unlocked. */
-#ifdef TIOCSINUSE
-#define HAVE_TIOCSINUSE 1
-#else
-#ifdef TIOCEXCL
-#define HAVE_TIOCEXCL 1
-#endif
-#endif
-
-#if HAVE_TLI
-extern int t_errno;
-extern char *t_errlist[];
-extern int t_nerr;
-#endif
-
-/* Determine bits to clear for the various terminal control fields for
- HAVE_SYSV_TERMIO and HAVE_POSIX_TERMIOS. */
-
-/* These fields are defined on some systems, and I am told that it
- does not hurt to clear them, and it sometimes helps. */
-#ifndef IMAXBEL
-#define IMAXBEL 0
-#endif
-
-#ifndef PENDIN
-#define PENDIN 0
-#endif
-
-#if HAVE_SYSV_TERMIO
-#define ICLEAR_IFLAG (IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK \
- | ISTRIP | INLCR | IGNCR | ICRNL | IUCLC \
- | IXON | IXANY | IXOFF | IMAXBEL)
-#define ICLEAR_OFLAG (OPOST | OLCUC | ONLCR | OCRNL | ONOCR | ONLRET \
- | OFILL | OFDEL | NLDLY | CRDLY | TABDLY | BSDLY \
- | VTDLY | FFDLY)
-#define ICLEAR_CFLAG (CBAUD | CSIZE | PARENB | PARODD)
-#define ISET_CFLAG (CS8 | CREAD | HUPCL)
-#define ICLEAR_LFLAG (ISIG | ICANON | XCASE | ECHO | ECHOE | ECHOK \
- | ECHONL | NOFLSH | PENDIN)
-#endif
-#if HAVE_POSIX_TERMIOS
-#define ICLEAR_IFLAG (BRKINT | ICRNL | IGNBRK | IGNCR | IGNPAR \
- | INLCR | INPCK | ISTRIP | IXOFF | IXON \
- | PARMRK | IMAXBEL)
-#define ICLEAR_OFLAG (OPOST)
-#define ICLEAR_CFLAG (CSIZE | PARENB | PARODD)
-#define ISET_CFLAG (CS8 | CREAD | HUPCL)
-#define ICLEAR_LFLAG (ECHO | ECHOE | ECHOK | ECHONL | ICANON | IEXTEN \
- | ISIG | NOFLSH | TOSTOP | PENDIN)
-#endif
-
-enum tclocal_setting
-{
- SET_CLOCAL,
- CLEAR_CLOCAL,
- IGNORE_CLOCAL
-};
-
-/* Local functions. */
-
-static RETSIGTYPE usalarm P((int isig));
-static boolean fsserial_init P((struct sconnection *qconn,
- const struct sconncmds *qcmds,
- const char *zdevice));
-static void usserial_free P((struct sconnection *qconn));
-static boolean fsserial_lockfile P((boolean flok,
- const struct sconnection *));
-static boolean fsserial_lock P((struct sconnection *qconn,
- boolean fin));
-static boolean fsserial_unlock P((struct sconnection *qconn));
-static boolean fsserial_open P((struct sconnection *qconn, long ibaud,
- boolean fwait, enum tclocal_setting tlocal));
-static boolean fsstdin_open P((struct sconnection *qconn, long ibaud,
- boolean fwait));
-static boolean fsmodem_open P((struct sconnection *qconn, long ibaud,
- boolean fwait));
-static boolean fsdirect_open P((struct sconnection *qconn, long ibaud,
- boolean fwait));
-static boolean fsblock P((struct ssysdep_conn *q, boolean fblock));
-static boolean fsserial_close P((struct ssysdep_conn *q));
-static boolean fsstdin_close P((struct sconnection *qconn,
- pointer puuconf,
- struct uuconf_dialer *qdialer,
- boolean fsuccess));
-static boolean fsmodem_close P((struct sconnection *qconn,
- pointer puuconf,
- struct uuconf_dialer *qdialer,
- boolean fsuccess));
-static boolean fsdirect_close P((struct sconnection *qconn,
- pointer puuconf,
- struct uuconf_dialer *qdialer,
- boolean fsuccess));
-static boolean fsserial_break P((struct sconnection *qconn));
-static boolean fsstdin_break P((struct sconnection *qconn));
-static boolean fsserial_set P((struct sconnection *qconn,
- enum tparitysetting tparity,
- enum tstripsetting tstrip,
- enum txonxoffsetting txonxoff));
-static boolean fsstdin_set P((struct sconnection *qconn,
- enum tparitysetting tparity,
- enum tstripsetting tstrip,
- enum txonxoffsetting txonxoff));
-static boolean fsmodem_carrier P((struct sconnection *qconn,
- boolean fcarrier));
-static boolean fsserial_hardflow P((struct sconnection *qconn,
- boolean fhardflow));
-static boolean fsrun_chat P((int oread, int owrite, char **pzprog));
-static long isserial_baud P((struct sconnection *qconn));
-
-/* The command table for standard input ports. */
-
-static const struct sconncmds sstdincmds =
-{
- usserial_free,
- NULL, /* pflock */
- NULL, /* pfunlock */
- fsstdin_open,
- fsstdin_close,
- NULL, /* pfdial */
- fsdouble_read,
- fsdouble_write,
- fsysdep_conn_io,
- fsstdin_break,
- fsstdin_set,
- NULL, /* pfcarrier */
- fsdouble_chat,
- isserial_baud
-};
-
-/* The command table for modem ports. */
-
-static const struct sconncmds smodemcmds =
-{
- usserial_free,
- fsserial_lock,
- fsserial_unlock,
- fsmodem_open,
- fsmodem_close,
- fmodem_dial,
- fsysdep_conn_read,
- fsysdep_conn_write,
- fsysdep_conn_io,
- fsserial_break,
- fsserial_set,
- fsmodem_carrier,
- fsysdep_conn_chat,
- isserial_baud
-};
-
-/* The command table for direct ports. */
-
-static const struct sconncmds sdirectcmds =
-{
- usserial_free,
- fsserial_lock,
- fsserial_unlock,
- fsdirect_open,
- fsdirect_close,
- NULL, /* pfdial */
- fsysdep_conn_read,
- fsysdep_conn_write,
- fsysdep_conn_io,
- fsserial_break,
- fsserial_set,
- NULL, /* pfcarrier */
- fsysdep_conn_chat,
- isserial_baud
-};
-
-/* If the system will let us set both O_NDELAY and O_NONBLOCK, we do
- so. This is because some ancient drivers on some systems appear to
- look for one but not the other. Some other systems will give an
- EINVAL error if we attempt to set both, so we use a static global
- to hold the value we want to set. If we get EINVAL, we change the
- global and try again (if some system gives an error other than
- EINVAL, the code will have to be modified). */
-static int iSunblock = O_NDELAY | O_NONBLOCK;
-
-/* This code handles SIGALRM. See the discussion above
- fsysdep_conn_read. Normally we ignore SIGALRM, but the handler
- will temporarily be set to this function, which should set fSalarm
- and then either longjmp or schedule another SIGALRM. fSalarm is
- never referred to outside of this file, but we don't make it static
- to try to fool compilers which don't understand volatile. */
-
-volatile sig_atomic_t fSalarm;
-
-static RETSIGTYPE
-usalarm (isig)
- int isig;
-{
-#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET
- (void) signal (isig, usalarm);
-#endif
-
- fSalarm = TRUE;
-
-#if HAVE_RESTARTABLE_SYSCALLS
- longjmp (sSjmp_buf, 1);
-#else
- alarm (1);
-#endif
-}
-
-/* We need a simple routine to block SIGINT, SIGQUIT, SIGTERM and
- SIGPIPE and another to restore the original state. When these
- functions are called (in fsysdep_modem_close) SIGHUP is being
- ignored. The routines are isblocksigs, which returns a value of
- type HELD_SIG_MASK and usunblocksigs which takes a single argument
- of type HELD_SIG_MASK. */
-
-#if HAVE_SIGPROCMASK
-
-/* Use the POSIX sigprocmask call. */
-
-#define HELD_SIG_MASK sigset_t
-
-static sigset_t isblocksigs P((void));
-
-static sigset_t
-isblocksigs ()
-{
- sigset_t sblock, sold;
-
- /* These expressions need an extra set of parentheses to avoid a bug
- in SCO 3.2.2. */
- (void) (sigemptyset (&sblock));
- (void) (sigaddset (&sblock, SIGINT));
- (void) (sigaddset (&sblock, SIGQUIT));
- (void) (sigaddset (&sblock, SIGTERM));
- (void) (sigaddset (&sblock, SIGPIPE));
-
- (void) sigprocmask (SIG_BLOCK, &sblock, &sold);
- return sold;
-}
-
-#define usunblocksigs(s) \
- ((void) sigprocmask (SIG_SETMASK, &(s), (sigset_t *) NULL))
-
-#else /* ! HAVE_SIGPROCMASK */
-#if HAVE_SIGBLOCK
-
-/* Use the BSD sigblock and sigsetmask calls. */
-
-#define HELD_SIG_MASK int
-
-#ifndef sigmask
-#define sigmask(i) (1 << ((i) - 1))
-#endif
-
-#define isblocksigs() \
- sigblock (sigmask (SIGINT) | sigmask (SIGQUIT) \
- | sigmask (SIGTERM) | sigmask (SIGPIPE))
-
-#define usunblocksigs(i) ((void) sigsetmask (i))
-
-#else /* ! HAVE_SIGBLOCK */
-
-#if HAVE_SIGHOLD
-
-/* Use the SVR3 sighold and sigrelse calls. */
-
-#define HELD_SIG_MASK int
-
-static int isblocksigs P((void));
-
-static int
-isblocksigs ()
-{
- sighold (SIGINT);
- sighold (SIGQUIT);
- sighold (SIGTERM);
- sighold (SIGPIPE);
- return 0;
-}
-
-static void usunblocksigs P((int));
-
-/*ARGSUSED*/
-static void
-usunblocksigs (i)
- int i;
-{
- sigrelse (SIGINT);
- sigrelse (SIGQUIT);
- sigrelse (SIGTERM);
- sigrelse (SIGPIPE);
-}
-
-#else /* ! HAVE_SIGHOLD */
-
-/* We have no way to block signals. This system will suffer from a
- race condition in fsysdep_modem_close. */
-
-#define HELD_SIG_MASK int
-
-#define isblocksigs() 0
-
-#define usunblocksigs(i)
-
-#endif /* ! HAVE_SIGHOLD */
-#endif /* ! HAVE_SIGBLOCK */
-#endif /* ! HAVE_SIGPROCMASK */
-
-/* Initialize a connection for use on a serial port. */
-
-static boolean
-fsserial_init (qconn, qcmds, zdevice)
- struct sconnection *qconn;
- const struct sconncmds *qcmds;
- const char *zdevice;
-{
- struct ssysdep_conn *q;
-
- q = (struct ssysdep_conn *) xmalloc (sizeof (struct ssysdep_conn));
- if (zdevice == NULL
- && qconn->qport != NULL
- && qconn->qport->uuconf_ttype != UUCONF_PORTTYPE_STDIN)
- zdevice = qconn->qport->uuconf_zname;
- if (zdevice == NULL)
- q->zdevice = NULL;
- else if (*zdevice == '/')
- q->zdevice = zbufcpy (zdevice);
- else
- {
- size_t clen;
-
- clen = strlen (zdevice);
- q->zdevice = zbufalc (sizeof "/dev/" + clen);
- memcpy (q->zdevice, "/dev/", sizeof "/dev/" - 1);
- memcpy (q->zdevice + sizeof "/dev/" - 1, zdevice, clen);
- q->zdevice[sizeof "/dev/" + clen - 1] = '\0';
- }
- q->o = -1;
- q->ord = -1;
- q->owr = -1;
- q->ftli = FALSE;
- qconn->psysdep = (pointer) q;
- qconn->qcmds = qcmds;
- return TRUE;
-}
-
-/* Initialize a connection for use on standard input. */
-
-boolean
-fsysdep_stdin_init (qconn)
- struct sconnection *qconn;
-{
- /* chmod /dev/tty to prevent other users from writing messages to
- it. This is essentially `mesg n'. */
- (void) chmod ("/dev/tty", S_IRUSR | S_IWUSR);
- return fsserial_init (qconn, &sstdincmds, (const char *) NULL);
-}
-
-/* Initialize a connection for use on a modem port. */
-
-boolean
-fsysdep_modem_init (qconn)
- struct sconnection *qconn;
-{
- return fsserial_init (qconn, &smodemcmds,
- qconn->qport->uuconf_u.uuconf_smodem.uuconf_zdevice);
-}
-
-/* Initialize a connection for use on a direct port. */
-
-boolean
-fsysdep_direct_init (qconn)
- struct sconnection *qconn;
-{
- return fsserial_init (qconn, &sdirectcmds,
- qconn->qport->uuconf_u.uuconf_sdirect.uuconf_zdevice);
-}
-
-/* Free up a serial port. */
-
-static void
-usserial_free (qconn)
- struct sconnection *qconn;
-{
- struct ssysdep_conn *qsysdep;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- ubuffree (qsysdep->zdevice);
- xfree ((pointer) qsysdep);
- qconn->psysdep = NULL;
-}
-
-#if HAVE_SEQUENT_LOCKFILES
-#define LCK_TEMPLATE "LCK..tty"
-#else
-#define LCK_TEMPLATE "LCK.."
-#endif
-
-/* This routine is used for both locking and unlocking. It is the
- only routine which knows how to translate a device name into the
- name of a lock file. If it can't figure out a name, it does
- nothing and returns TRUE. */
-
-static boolean
-fsserial_lockfile (flok, qconn)
- boolean flok;
- const struct sconnection *qconn;
-{
- struct ssysdep_conn *qsysdep;
- const char *z;
- char *zalc;
- boolean fret;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- if (qconn->qport == NULL)
- z = NULL;
- else
- z = qconn->qport->uuconf_zlockname;
- zalc = NULL;
- if (z == NULL)
- {
-#if HAVE_QNX_LOCKFILES
- {
- nid_t idevice_nid;
- char abdevice_nid[13]; /* length of long, a period, and a NUL */
- size_t cdevice_nid;
- const char *zbase;
- size_t clen;
-
- /* If the node ID is explicitly specified as part of the
- pathname to the device, use that. Otherwise, presume the
- device is local to the current node. */
- if (qsysdep->zdevice[0] == '/' && qsysdep->zdevice[1] == '/')
- idevice_nid = (nid_t) strtol (qsysdep->zdevice + 2,
- (char **) NULL, 10);
- else
- idevice_nid = getnid ();
-
- sprintf (abdevice_nid, "%ld.", (long) idevice_nid);
- cdevice_nid = strlen (abdevice_nid);
-
- zbase = strrchr (qsysdep->zdevice, '/') + 1;
- clen = strlen (zbase);
-
- zalc = zbufalc (sizeof LCK_TEMPLATE + cdevice_nid + clen);
-
- memcpy (zalc, LCK_TEMPLATE, sizeof LCK_TEMPLATE - 1);
- memcpy (zalc + sizeof LCK_TEMPLATE - 1, abdevice_nid, cdevice_nid);
- memcpy (zalc + sizeof LCK_TEMPLATE - 1 + cdevice_nid,
- zbase, clen + 1);
-
- z = zalc;
- }
-#else /* ! HAVE_QNX_LOCKFILES */
-#if ! HAVE_SVR4_LOCKFILES
- {
- const char *zbase;
- size_t clen;
-
- zbase = strrchr (qsysdep->zdevice, '/') + 1;
- clen = strlen (zbase);
- zalc = zbufalc (sizeof LCK_TEMPLATE + clen);
- memcpy (zalc, LCK_TEMPLATE, sizeof LCK_TEMPLATE - 1);
- memcpy (zalc + sizeof LCK_TEMPLATE - 1, zbase, clen + 1);
-#if HAVE_SCO_LOCKFILES
- {
- char *zl;
-
- for (zl = zalc + sizeof LCK_TEMPLATE - 1; *zl != '\0'; zl++)
- if (isupper (*zl))
- *zl = tolower (*zl);
- }
-#endif
- z = zalc;
- }
-#else /* HAVE_SVR4_LOCKFILES */
- {
- struct stat s;
-
- if (stat (qsysdep->zdevice, &s) != 0)
- {
- ulog (LOG_ERROR, "stat (%s): %s", qsysdep->zdevice,
- strerror (errno));
- return FALSE;
- }
- zalc = zbufalc (sizeof "LK.1234567890.1234567890.1234567890");
- sprintf (zalc, "LK.%03d.%03d.%03d", major (s.st_dev),
- major (s.st_rdev), minor (s.st_rdev));
- z = zalc;
- }
-#endif /* HAVE_SVR4_LOCKFILES */
-#endif /* ! HAVE_QNX_LOCKFILES */
- }
-
- if (flok)
- fret = fsdo_lock (z, FALSE, (boolean *) NULL);
- else
- fret = fsdo_unlock (z, FALSE);
-
-#if HAVE_COHERENT_LOCKFILES
- if (fret)
- {
- if (flok)
- {
- if (lockttyexist (z + sizeof LCK_TEMPLATE - 1))
- {
- ulog (LOG_NORMAL, "%s: port already locked",
- z + sizeof LCK_TEMPLATE - 1);
- fret = FALSE;
- }
- else
- fret = fscoherent_disable_tty (z + sizeof LCK_TEMPLATE - 1,
- &qsysdep->zenable);
- }
- else
- {
- fret = TRUE;
- if (qsysdep->zenable != NULL)
- {
- const char *azargs[3];
- int aidescs[3];
- pid_t ipid;
-
- azargs[0] = "/etc/enable";
- azargs[1] = qsysdep->zenable;
- azargs[2] = NULL;
- aidescs[0] = SPAWN_NULL;
- aidescs[1] = SPAWN_NULL;
- aidescs[2] = SPAWN_NULL;
-
- ipid = ixsspawn (azargs, aidescs, TRUE, FALSE,
- (const char *) NULL, TRUE, TRUE,
- (const char *) NULL, (const char *) NULL,
- (const char *) NULL);
- if (ipid < 0)
- {
- ulog (LOG_ERROR, "ixsspawn (/etc/enable %s): %s",
- qsysdep->zenable, strerror (errno));
- fret = FALSE;
- }
- else
- {
- if (ixswait ((unsigned long) ipid, (const char *) NULL)
- == 0)
- fret = TRUE;
- else
- fret = FALSE;
- }
- ubuffree (qsysdep->zenable);
- qsysdep->zenable = NULL;
- }
- }
- }
-#endif /* HAVE_COHERENT_LOCKFILES */
-
- ubuffree (zalc);
- return fret;
-}
-
-/* If we can mark a modem line in use, then when we lock a port we
- must open it and mark it in use. We can't wait until the actual
- open because we can't fail out if it is locked then. */
-
-static boolean
-fsserial_lock (qconn, fin)
- struct sconnection *qconn;
- boolean fin;
-{
- if (! fsserial_lockfile (TRUE, qconn))
- return FALSE;
-
-#if HAVE_TIOCSINUSE || HAVE_TIOCEXCL || HAVE_DEV_INFO
- /* Open the line and try to mark it in use. */
- {
- struct ssysdep_conn *qsysdep;
- int iflag;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
-
- if (fin)
- iflag = 0;
- else
- iflag = iSunblock;
-
- qsysdep->o = open (qsysdep->zdevice, O_RDWR | iflag);
- if (qsysdep->o < 0)
- {
-#if O_NONBLOCK != 0
- if (! fin && iSunblock != O_NONBLOCK && errno == EINVAL)
- {
- iSunblock = O_NONBLOCK;
- qsysdep->o = open (qsysdep->zdevice,
- O_RDWR | O_NONBLOCK);
- }
-#endif
- if (qsysdep->o < 0)
- {
- if (errno != EBUSY)
- ulog (LOG_ERROR, "open (%s): %s", qsysdep->zdevice,
- strerror (errno));
- (void) fsserial_lockfile (FALSE, qconn);
- return FALSE;
- }
- }
-
-#if HAVE_TIOCSINUSE
- /* If we can't mark it in use, return FALSE to indicate that the
- lock failed. */
- if (ioctl (qsysdep->o, TIOCSINUSE, 0) < 0)
- {
- if (errno != EALREADY)
- ulog (LOG_ERROR, "ioctl (TIOCSINUSE): %s", strerror (errno));
-#ifdef TIOCNOTTY
- (void) ioctl (qsysdep->o, TIOCNOTTY, (char *) NULL);
-#endif
- (void) close (qsysdep->o);
- qsysdep->o = -1;
- (void) fsserial_lockfile (FALSE, qconn);
- return FALSE;
- }
-#endif
-
-#if HAVE_DEV_INFO
- /* QNX programs "lock" a serial port by simply opening it and
- checking if some other program also has the port open. If the
- count of openers is greater than one, the program presumes the
- port is "locked" and backs off. This isn't really "locking" of
- course, but it pretty much seems to work. This can result in
- dropping incoming connections if an outgoing connection is
- started at exactly the same time. It would probably be better
- to stop using the lock files at all for this case, but that
- would involve more complex changes to the code, and I'm afraid
- I would break something. -- Joe Wells <jbw@cs.bu.edu> */
- {
- struct _dev_info_entry sdevinfo;
-
- if (dev_info (qsysdep->o, &sdevinfo) == -1)
- {
- ulog (LOG_ERROR, "dev_info: %s", strerror (errno));
- sdevinfo.open_count = 2; /* force presumption of "locked" */
- }
- if (sdevinfo.open_count != 1)
- {
-#ifdef TIOCNOTTY
- (void) ioctl (qsysdep->o, TIOCNOTTY, (char *) NULL);
-#endif /* TIOCNOTTY */
- (void) close (qsysdep->o);
- qsysdep->o = -1;
- (void) fsserial_lockfile (FALSE, qconn);
- return FALSE;
- }
- }
-#endif /* HAVE_DEV_INFO */
-
- if (fcntl (qsysdep->o, F_SETFD,
- fcntl (qsysdep->o, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
-#ifdef TIOCNOTTY
- (void) ioctl (qsysdep->o, TIOCNOTTY, (char *) NULL);
-#endif
- (void) close (qsysdep->o);
- qsysdep->o = -1;
- (void) fsserial_lockfile (FALSE, qconn);
- return FALSE;
- }
- }
-#endif /* HAVE_TIOCSINUSE || HAVE_TIOCEXCL */
-
- return TRUE;
-}
-
-/* Unlock a modem or direct port. */
-
-static boolean
-fsserial_unlock (qconn)
- struct sconnection *qconn;
-{
- boolean fret;
- struct ssysdep_conn *qsysdep;
-
- fret = TRUE;
-
- /* The file may have been opened by fsserial_lock, so close it here
- if necessary. */
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- if (qsysdep->o >= 0)
- {
-#ifdef TIOCNOTTY
- (void) ioctl (qsysdep->o, TIOCNOTTY, (char *) NULL);
-#endif
- if (close (qsysdep->o) < 0)
- {
- ulog (LOG_ERROR, "close: %s", strerror (errno));
- fret = FALSE;
- }
- qsysdep->o = -1;
- }
-
- if (! fsserial_lockfile (FALSE, qconn))
- fret = FALSE;
-
- return fret;
-}
-
-/* A table to map baud rates into index numbers. */
-
-#if HAVE_POSIX_TERMIOS
-typedef speed_t baud_code;
-#else
-typedef int baud_code;
-#endif
-
-static struct sbaud_table
-{
- baud_code icode;
- long ibaud;
-} asSbaud_table[] =
-{
- { B50, 50 },
- { B75, 75 },
- { B110, 110 },
- { B134, 134 },
- { B150, 150 },
- { B200, 200 },
- { B300, 300 },
- { B600, 600 },
- { B1200, 1200 },
- { B1800, 1800 },
- { B2400, 2400 },
- { B4800, 4800 },
- { B9600, 9600 },
-#ifdef B19200
- { B19200, 19200 },
-#else /* ! defined (B19200) */
-#ifdef EXTA
- { EXTA, 19200 },
-#endif /* EXTA */
-#endif /* ! defined (B19200) */
-#ifdef B38400
- { B38400, 38400 },
-#else /* ! defined (B38400) */
-#ifdef EXTB
- { EXTB, 38400 },
-#endif /* EXTB */
-#endif /* ! defined (B38400) */
-#ifdef B57600
- { B57600, 57600 },
-#endif
-#ifdef B76800
- { B76800, 76800 },
-#endif
-#ifdef B115200
- { B115200, 115200 },
-#endif
-#ifdef B230400
- { B230400, 230400 },
-#endif
- { B0, 0 }
-};
-
-#define CBAUD_TABLE (sizeof asSbaud_table / sizeof asSbaud_table[0])
-
-#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
-/* Hold the MIN value for the terminal to avoid setting it
- unnecessarily. */
-static int cSmin;
-#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
-
-/* Open a serial line. This sets the terminal settings. We begin in
- seven bit mode and let the protocol change if necessary. If fwait
- is FALSE we open the terminal in non-blocking mode. If flocal is
- TRUE we set CLOCAL on the terminal when using termio[s]; this is
- supposedly required on some versions of BSD/386. */
-
-static boolean
-fsserial_open (qconn, ibaud, fwait, tlocal)
- struct sconnection *qconn;
- long ibaud;
- boolean fwait;
- enum tclocal_setting tlocal;
-{
- struct ssysdep_conn *q;
- baud_code ib;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
-
- if (q->zdevice != NULL)
- {
-#if LOG_DEVICE_PREFIX
- ulog_device (q->zdevice);
-#else
- const char *z;
-
- if (strncmp (q->zdevice, "/dev/", sizeof "/dev/" - 1) == 0)
- z = q->zdevice + sizeof "/dev/" - 1;
- else
- z = q->zdevice;
- ulog_device (z);
-#endif
- }
- else
- {
- const char *zport;
- boolean fdummy;
-
-#if DEBUG > 0
- if (qconn->qport != NULL &&
- qconn->qport->uuconf_ttype != UUCONF_PORTTYPE_STDIN)
- ulog (LOG_FATAL, "fsserial_open: Can't happen");
-#endif
- zport = zsysdep_port_name (&fdummy);
- if (zport != NULL)
- ulog_device (zport);
- }
-
- ib = B0;
- if (ibaud != 0)
- {
- int i;
-
- for (i = 0; i < CBAUD_TABLE; i++)
- if (asSbaud_table[i].ibaud == ibaud)
- break;
- if (i >= CBAUD_TABLE)
- {
- ulog (LOG_ERROR, "Unsupported baud rate %ld", ibaud);
- return FALSE;
- }
- ib = asSbaud_table[i].icode;
- }
-
- /* The port may have already been opened by the locking routine. */
- if (q->o < 0)
- {
- int iflag;
-
- if (fwait)
- iflag = 0;
- else
- iflag = iSunblock;
-
- q->o = open (q->zdevice, O_RDWR | iflag);
- if (q->o < 0)
- {
-#if O_NONBLOCK != 0
- if (! fwait && iSunblock != O_NONBLOCK && errno == EINVAL)
- {
- iSunblock = O_NONBLOCK;
- q->o = open (q->zdevice, O_RDWR | O_NONBLOCK);
- }
-#endif
- if (q->o < 0)
- {
- ulog (LOG_ERROR, "open (%s): %s", q->zdevice,
- strerror (errno));
- return FALSE;
- }
- }
-
- if (fcntl (q->o, F_SETFD, fcntl (q->o, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- return FALSE;
- }
- }
-
- /* Get the port flags, and make sure the ports are blocking. */
-
- q->iflags = fcntl (q->o, F_GETFL, 0);
- if (q->iflags < 0)
- {
- ulog (LOG_ERROR, "fcntl: %s", strerror (errno));
- return FALSE;
- }
- q->iwr_flags = -1;
-
- if (! fgetterminfo (q->o, &q->sorig))
- {
- q->fterminal = FALSE;
- return TRUE;
- }
-
- q->fterminal = TRUE;
-
- q->snew = q->sorig;
-
-#if HAVE_BSD_TTY
-
- q->snew.stty.sg_flags = RAW | ANYP;
- if (ibaud == 0)
- ib = q->snew.stty.sg_ospeed;
- else
- {
- q->snew.stty.sg_ispeed = ib;
- q->snew.stty.sg_ospeed = ib;
- }
-
- /* We don't want to receive any interrupt characters. */
- q->snew.stchars.t_intrc = -1;
- q->snew.stchars.t_quitc = -1;
- q->snew.stchars.t_eofc = -1;
- q->snew.stchars.t_brkc = -1;
- q->snew.sltchars.t_suspc = -1;
- q->snew.sltchars.t_rprntc = -1;
- q->snew.sltchars.t_dsuspc = -1;
- q->snew.sltchars.t_flushc = -1;
- q->snew.sltchars.t_werasc = -1;
- q->snew.sltchars.t_lnextc = -1;
-
-#ifdef NTTYDISC
- /* We want to use the ``new'' terminal driver so that we can use the
- local mode bits to control XON/XOFF. */
- {
- int iparam;
-
- if (ioctl (q->o, TIOCGETD, &iparam) >= 0
- && iparam != NTTYDISC)
- {
- iparam = NTTYDISC;
- (void) ioctl (q->o, TIOCSETD, &iparam);
- }
- }
-#endif
-
-#ifdef TIOCHPCL
- /* When the file is closed, hang up the line. This is a safety
- measure in case the program crashes. */
- (void) ioctl (q->o, TIOCHPCL, 0);
-#endif
-
-#ifdef TIOCFLUSH
- {
- int iparam;
-
- /* Flush pending input. */
-#ifdef FREAD
- iparam = FREAD;
-#else
- iparam = 0;
-#endif
- (void) ioctl (q->o, TIOCFLUSH, &iparam);
- }
-#endif /* TIOCFLUSH */
-
-#endif /* HAVE_BSD_TTY */
-
-#if HAVE_SYSV_TERMIO
-
- if (ibaud == 0)
- ib = q->snew.c_cflag & CBAUD;
-
- q->snew.c_iflag &=~ ICLEAR_IFLAG;
- q->snew.c_oflag &=~ ICLEAR_OFLAG;
- q->snew.c_cflag &=~ ICLEAR_CFLAG;
- q->snew.c_cflag |= ib | ISET_CFLAG;
- q->snew.c_lflag &=~ ICLEAR_LFLAG;
- cSmin = 1;
- q->snew.c_cc[VMIN] = cSmin;
- q->snew.c_cc[VTIME] = 1;
-
-#ifdef TCFLSH
- /* Flush pending input. */
- (void) ioctl (q->o, TCFLSH, 0);
-#endif
-
-#endif /* HAVE_SYSV_TERMIO */
-
-#if HAVE_POSIX_TERMIOS
-
- if (ibaud == 0)
- ib = cfgetospeed (&q->snew);
-
- q->snew.c_iflag &=~ ICLEAR_IFLAG;
- q->snew.c_oflag &=~ ICLEAR_OFLAG;
- q->snew.c_cflag &=~ ICLEAR_CFLAG;
- q->snew.c_cflag |= ISET_CFLAG;
- q->snew.c_lflag &=~ ICLEAR_LFLAG;
- cSmin = 1;
- q->snew.c_cc[VMIN] = cSmin;
- q->snew.c_cc[VTIME] = 1;
-
- (void) cfsetospeed (&q->snew, ib);
- (void) cfsetispeed (&q->snew, ib);
-
- /* Flush pending input. */
- (void) tcflush (q->o, TCIFLUSH);
-
-#endif /* HAVE_POSIX_TERMIOS */
-
-#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
- switch (tlocal)
- {
- case SET_CLOCAL:
- q->snew.c_cflag |= CLOCAL;
- break;
- case CLEAR_CLOCAL:
- q->snew.c_cflag &=~ CLOCAL;
- break;
- case IGNORE_CLOCAL:
- break;
- }
-#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
-
- if (! fsetterminfo (q->o, &q->snew))
- {
- ulog (LOG_ERROR, "Can't set terminal settings: %s", strerror (errno));
- return FALSE;
- }
-
-#ifdef TIOCSCTTY
- /* On BSD 4.4, make it our controlling terminal. */
- (void) ioctl (q->o, TIOCSCTTY, 0);
-#endif
-
- if (ibaud != 0)
- q->ibaud = ibaud;
- else
- {
- int i;
-
- q->ibaud = (long) 1200;
- for (i = 0; i < CBAUD_TABLE; i++)
- {
- if (asSbaud_table[i].icode == ib)
- {
- q->ibaud = asSbaud_table[i].ibaud;
- break;
- }
- }
-
- DEBUG_MESSAGE1 (DEBUG_PORT,
- "fsserial_open: Baud rate is %ld", q->ibaud);
- }
-
- return TRUE;
-}
-
-/* Open a standard input port. The code alternates q->o between
- q->ord and q->owr as appropriate. It is always q->ord before any
- call to fsblock. */
-
-static boolean
-fsstdin_open (qconn, ibaud, fwait)
- struct sconnection *qconn;
- long ibaud;
- boolean fwait;
-{
- struct ssysdep_conn *q;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
- q->ord = 0;
- q->owr = 1;
-
- q->o = q->ord;
- if (! fsserial_open (qconn, ibaud, fwait, IGNORE_CLOCAL))
- return FALSE;
- q->iwr_flags = fcntl (q->owr, F_GETFL, 0);
- if (q->iwr_flags < 0)
- {
- ulog (LOG_ERROR, "fcntl: %s", strerror (errno));
- return FALSE;
- }
- return TRUE;
-}
-
-/* Open a modem port. */
-
-static boolean
-fsmodem_open (qconn, ibaud, fwait)
- struct sconnection *qconn;
- long ibaud;
- boolean fwait;
-{
- struct uuconf_modem_port *qm;
-
- qm = &qconn->qport->uuconf_u.uuconf_smodem;
- if (ibaud == (long) 0)
- ibaud = qm->uuconf_ibaud;
-
- if (! fsserial_open (qconn, ibaud, fwait,
- fwait ? CLEAR_CLOCAL : SET_CLOCAL))
- return FALSE;
-
- /* If we are waiting for carrier, then turn on hardware flow
- control. We don't turn on hardware flow control when dialing
- out, because some modems don't assert the necessary signals until
- they see carrier. Instead, we turn on hardware flow control in
- fsmodem_carrier. */
- if (fwait
- && ! fsserial_hardflow (qconn, qm->uuconf_fhardflow))
- return FALSE;
-
- return TRUE;
-}
-
-/* Open a direct port. */
-
-static boolean
-fsdirect_open (qconn, ibaud, fwait)
- struct sconnection *qconn;
- long ibaud;
- boolean fwait;
-{
- struct uuconf_direct_port *qd;
-
- qd = &qconn->qport->uuconf_u.uuconf_sdirect;
- if (ibaud == (long) 0)
- ibaud = qd->uuconf_ibaud;
- if (! fsserial_open (qconn, ibaud, fwait,
- qd->uuconf_fcarrier ? CLEAR_CLOCAL : SET_CLOCAL))
- return FALSE;
-
- /* Always turn on hardware flow control for a direct port when it is
- opened. There is no other sensible time to turn it on. */
- return fsserial_hardflow (qconn, qd->uuconf_fhardflow);
-}
-
-/* Change the blocking status of the port. We keep track of the
- current blocking status to avoid calling fcntl unnecessarily; fcntl
- turns out to be surprisingly expensive, at least on Ultrix. */
-
-static boolean
-fsblock (qs, fblock)
- struct ssysdep_conn *qs;
- boolean fblock;
-{
- int iwant;
- int isys;
-
- if (fblock)
- iwant = qs->iflags &~ (O_NDELAY | O_NONBLOCK);
- else
- iwant = qs->iflags | iSunblock;
-
- if (iwant == qs->iflags)
- return TRUE;
-
- isys = fcntl (qs->o, F_SETFL, iwant);
- if (isys < 0)
- {
-#if O_NONBLOCK != 0
- if (! fblock && iSunblock != O_NONBLOCK && errno == EINVAL)
- {
- iSunblock = O_NONBLOCK;
- iwant = qs->iflags | O_NONBLOCK;
- isys = fcntl (qs->o, F_SETFL, iwant);
- }
-#endif
- if (isys < 0)
- {
- ulog (LOG_ERROR, "fcntl: %s", strerror (errno));
- return FALSE;
- }
- }
-
- qs->iflags = iwant;
-
- if (qs->iwr_flags >= 0 && qs->ord != qs->owr)
- {
- if (fblock)
- iwant = qs->iwr_flags &~ (O_NDELAY | O_NONBLOCK);
- else
- iwant = qs->iwr_flags | iSunblock;
-
- if (fcntl (qs->owr, F_SETFL, iwant) < 0)
- {
- /* We don't bother to fix up iSunblock here, since we
- succeeded above. */
- ulog (LOG_ERROR, "fcntl: %s", strerror (errno));
- return FALSE;
- }
-
- qs->iwr_flags = iwant;
- }
-
- return TRUE;
-}
-
-/* Close a serial port. */
-
-static boolean
-fsserial_close (q)
- struct ssysdep_conn *q;
-{
- if (q->o >= 0)
- {
- /* Use a 30 second timeout to avoid hanging while draining
- output. */
- if (q->fterminal)
- {
- fSalarm = FALSE;
-
- if (fsysdep_catch ())
- {
- usysdep_start_catch ();
- usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL);
- (void) alarm (30);
-
- (void) fsetterminfodrain (q->o, &q->sorig);
- }
-
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- (void) alarm (0);
- usysdep_end_catch ();
-
- /* If we timed out, use the non draining call. Hopefully
- this can't hang. */
- if (fSalarm)
- (void) fsetterminfo (q->o, &q->sorig);
- }
-
-#ifdef TIOCNOTTY
- /* We don't want this as our controlling terminal any more, so
- get rid of it. This is necessary because we don't want to
- open /dev/tty, since that can confuse the serial port locking
- on some computers. */
- (void) ioctl (q->o, TIOCNOTTY, (char *) NULL);
-#endif
-
- (void) close (q->o);
- q->o = -1;
-
- /* Sleep to give the terminal a chance to settle, in case we are
- about to call out again. */
- sleep (2);
- }
-
- return TRUE;
-}
-
-/* Close a stdin port. */
-
-/*ARGSUSED*/
-static boolean
-fsstdin_close (qconn, puuconf, qdialer, fsuccess)
- struct sconnection *qconn;
- pointer puuconf;
- struct uuconf_dialer *qdialer;
- boolean fsuccess;
-{
- struct ssysdep_conn *qsysdep;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- (void) close (qsysdep->owr);
- (void) close (2);
- qsysdep->o = qsysdep->ord;
- return fsserial_close (qsysdep);
-}
-
-/* Close a modem port. */
-
-static boolean
-fsmodem_close (qconn, puuconf, qdialer, fsuccess)
- struct sconnection *qconn;
- pointer puuconf;
- struct uuconf_dialer *qdialer;
- boolean fsuccess;
-{
- struct ssysdep_conn *qsysdep;
- boolean fret;
- struct uuconf_dialer sdialer;
- const struct uuconf_chat *qchat;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
-
- fret = TRUE;
-
- /* Figure out the dialer so that we can run the complete or abort
- chat scripts. */
- if (qdialer == NULL)
- {
- if (qconn->qport->uuconf_u.uuconf_smodem.uuconf_pzdialer != NULL)
- {
- const char *zdialer;
- int iuuconf;
-
- zdialer = qconn->qport->uuconf_u.uuconf_smodem.uuconf_pzdialer[0];
- iuuconf = uuconf_dialer_info (puuconf, zdialer, &sdialer);
- if (iuuconf == UUCONF_SUCCESS)
- qdialer = &sdialer;
- else
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fret = FALSE;
- }
- }
- else
- qdialer = qconn->qport->uuconf_u.uuconf_smodem.uuconf_qdialer;
- }
-
- /* Get the complete or abort chat script to use. */
- qchat = NULL;
- if (qdialer != NULL)
- {
- if (fsuccess)
- qchat = &qdialer->uuconf_scomplete;
- else
- qchat = &qdialer->uuconf_sabort;
- }
-
- if (qchat != NULL
- && (qchat->uuconf_pzprogram != NULL
- || qchat->uuconf_pzchat != NULL))
- {
- boolean fsighup_ignored;
- HELD_SIG_MASK smask;
- int i;
- sig_atomic_t afhold[INDEXSIG_COUNT];
-
- /* We're no longer interested in carrier. */
- (void) fsmodem_carrier (qconn, FALSE);
-
- /* The port I/O routines check whether any signal has been
- received, and abort if one has. While we are closing down
- the modem, we don't care if we received a signal in the past,
- but we do care if we receive a new signal (otherwise it would
- be difficult to kill a uucico which was closing down a
- modem). We never care if we get SIGHUP at this point. So we
- turn off SIGHUP, remember what signals we've already seen,
- and clear our notion of what signals we've seen. We have to
- block the signals while we remember and clear the array,
- since we might otherwise miss a signal which occurred between
- the copy and the clear (old systems can't block signals; they
- will just have to suffer the race). */
- usset_signal (SIGHUP, SIG_IGN, FALSE, &fsighup_ignored);
- smask = isblocksigs ();
- for (i = 0; i < INDEXSIG_COUNT; i++)
- {
- afhold[i] = afSignal[i];
- afSignal[i] = FALSE;
- }
- usunblocksigs (smask);
-
- if (! fchat (qconn, puuconf, qchat, (const struct uuconf_system *) NULL,
- (const struct uuconf_dialer *) NULL, (const char *) NULL,
- FALSE, qconn->qport->uuconf_zname,
- qsysdep->ibaud))
- fret = FALSE;
-
- /* Restore the old signal array and the SIGHUP handler. It is
- not necessary to block signals here, since all we are doing
- is exactly what the signal handler itself would do if the
- signal occurred. */
- for (i = 0; i < INDEXSIG_COUNT; i++)
- if (afhold[i])
- afSignal[i] = TRUE;
- if (! fsighup_ignored)
- usset_signal (SIGHUP, ussignal, TRUE, (boolean *) NULL);
- }
-
- if (qdialer != NULL
- && qdialer == &sdialer)
- (void) uuconf_dialer_free (puuconf, &sdialer);
-
-#if ! HAVE_RESET_BUG
- /* Reset the terminal to make sure we drop DTR. It should be
- dropped when we close the descriptor, but that doesn't seem to
- happen on some systems. Use a 30 second timeout to avoid hanging
- while draining output. */
- if (qsysdep->fterminal)
- {
-#if HAVE_BSD_TTY
- qsysdep->snew.stty.sg_ispeed = B0;
- qsysdep->snew.stty.sg_ospeed = B0;
-#endif
-#if HAVE_SYSV_TERMIO
- qsysdep->snew.c_cflag = (qsysdep->snew.c_cflag &~ CBAUD) | B0;
-#endif
-#if HAVE_POSIX_TERMIOS
- (void) cfsetospeed (&qsysdep->snew, B0);
-#endif
-
- fSalarm = FALSE;
-
- if (fsysdep_catch ())
- {
- usysdep_start_catch ();
- usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL);
- (void) alarm (30);
-
- (void) fsetterminfodrain (qsysdep->o, &qsysdep->snew);
- }
-
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- (void) alarm (0);
- usysdep_end_catch ();
-
- /* Let the port settle. */
- sleep (2);
- }
-#endif /* ! HAVE_RESET_BUG */
-
- if (! fsserial_close (qsysdep))
- fret = FALSE;
-
- return fret;
-}
-
-/* Close a direct port. */
-
-/*ARGSUSED*/
-static boolean
-fsdirect_close (qconn, puuconf, qdialer, fsuccess)
- struct sconnection *qconn;
- pointer puuconf;
- struct uuconf_dialer *qdialer;
- boolean fsuccess;
-{
- return fsserial_close ((struct ssysdep_conn *) qconn->psysdep);
-}
-
-/* Begin dialing out on a modem port. This opens the dialer device if
- there is one. */
-
-boolean
-fsysdep_modem_begin_dial (qconn, qdial)
- struct sconnection *qconn;
- struct uuconf_dialer *qdial;
-{
- struct ssysdep_conn *qsysdep;
- const char *z;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
-
-#ifdef TIOCMODEM
- /* If we can tell the modem to obey modem control, do so. */
- {
- int iperm;
-
- iperm = 0;
- (void) ioctl (qsysdep->o, TIOCMODEM, &iperm);
- }
-#endif /* TIOCMODEM */
-
- /* If we supposed to toggle DTR, do so. */
-
- if (qdial->uuconf_fdtr_toggle)
- {
-#ifdef TIOCCDTR
- (void) ioctl (qsysdep->o, TIOCCDTR, 0);
- sleep (2);
- (void) ioctl (qsysdep->o, TIOCSDTR, 0);
-#else /* ! defined (TIOCCDTR) */
- if (qsysdep->fterminal)
- {
- sterminal sbaud;
-
- sbaud = qsysdep->snew;
-
-#if HAVE_BSD_TTY
- sbaud.stty.sg_ispeed = B0;
- sbaud.stty.sg_ospeed = B0;
-#endif
-#if HAVE_SYSV_TERMIO
- sbaud.c_cflag = (sbaud.c_cflag &~ CBAUD) | B0;
-#endif
-#if HAVE_POSIX_TERMIOS
- (void) cfsetospeed (&sbaud, B0);
-#endif
-
- (void) fsetterminfodrain (qsysdep->o, &sbaud);
- sleep (2);
- (void) fsetterminfo (qsysdep->o, &qsysdep->snew);
- }
-#endif /* ! defined (TIOCCDTR) */
-
- if (qdial->uuconf_fdtr_toggle_wait)
- sleep (2);
- }
-
- if (! fsmodem_carrier (qconn, FALSE))
- return FALSE;
-
- /* Open the dial device if there is one. */
- z = qconn->qport->uuconf_u.uuconf_smodem.uuconf_zdial_device;
- if (z != NULL)
- {
- char *zfree;
- int o;
-
- qsysdep->ohold = qsysdep->o;
-
- zfree = NULL;
- if (*z != '/')
- {
- zfree = zbufalc (sizeof "/dev/" + strlen (z));
- sprintf (zfree, "/dev/%s", z);
- z = zfree;
- }
-
- o = open ((char *) z, O_RDWR | O_NOCTTY);
- if (o < 0)
- {
- ulog (LOG_ERROR, "open (%s): %s", z, strerror (errno));
- ubuffree (zfree);
- return FALSE;
- }
- ubuffree (zfree);
-
- if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- (void) close (o);
- return FALSE;
- }
-
- qsysdep->o = o;
- }
-
- return TRUE;
-}
-
-/* Tell the port to require or not require carrier. On BSD this uses
- TIOCCAR and TIOCNCAR, which I assume are generally supported (it
- can also use the LNOMDM bit supported by IS68K Unix). On System V
- it resets or sets CLOCAL. We only require carrier if the port
- supports it. This will only be called with fcarrier TRUE if the
- dialer supports carrier. */
-
-static boolean
-fsmodem_carrier (qconn, fcarrier)
- struct sconnection *qconn;
- boolean fcarrier;
-{
- register struct ssysdep_conn *q;
- struct uuconf_modem_port *qm;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
-
- if (! q->fterminal)
- return TRUE;
-
- qm = &qconn->qport->uuconf_u.uuconf_smodem;
- if (fcarrier)
- {
- if (qm->uuconf_fcarrier)
- {
-#ifdef TIOCCAR
- /* Tell the modem to pay attention to carrier. */
- if (ioctl (q->o, TIOCCAR, 0) < 0)
- {
- ulog (LOG_ERROR, "ioctl (TIOCCAR): %s", strerror (errno));
- return FALSE;
- }
-#endif /* TIOCCAR */
-
-#if HAVE_BSD_TTY
-#ifdef LNOMDM
- /* IS68K Unix uses a local LNOMDM bit. */
- {
- int iparam;
-
- iparam = LNOMDM;
- if (ioctl (q->o, TIOCLBIC, &iparam) < 0)
- {
- ulog (LOG_ERROR, "ioctl (TIOCLBIC, LNOMDM): %s",
- strerror (errno));
- return FALSE;
- }
- }
-#endif /* LNOMDM */
-#endif /* HAVE_BSD_TTY */
-
-#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
- /* Put the modem into nonlocal mode. */
- q->snew.c_cflag &=~ CLOCAL;
- if (! fsetterminfo (q->o, &q->snew))
- {
- ulog (LOG_ERROR, "Can't clear CLOCAL: %s", strerror (errno));
- return FALSE;
- }
-#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
- }
-
- /* Turn on hardware flow control after turning on carrier. We
- don't do it until now because some modems don't assert the
- right signals until they see carrier. */
- if (! fsserial_hardflow (qconn, qm->uuconf_fhardflow))
- return FALSE;
- }
- else
- {
- /* Turn off any hardware flow control before turning off
- carrier. */
- if (! fsserial_hardflow (qconn, FALSE))
- return FALSE;
-
-#ifdef TIOCNCAR
- /* Tell the modem to ignore carrier. */
- if (ioctl (q->o, TIOCNCAR, 0) < 0)
- {
- ulog (LOG_ERROR, "ioctl (TIOCNCAR): %s", strerror (errno));
- return FALSE;
- }
-#endif /* TIOCNCAR */
-
-#if HAVE_BSD_TTY
-#ifdef LNOMDM
- /* IS68K Unix uses a local LNOMDM bit. */
- {
- int iparam;
-
- iparam = LNOMDM;
- if (ioctl (q->o, TIOCLBIS, &iparam) < 0)
- {
- ulog (LOG_ERROR, "ioctl (TIOCLBIS, LNOMDM): %s",
- strerror (errno));
- return FALSE;
- }
- }
-#endif /* LNOMDM */
-#endif /* HAVE_BSD_TTY */
-
-#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
- /* Put the modem into local mode (ignore carrier) to start the chat
- script. */
- q->snew.c_cflag |= CLOCAL;
- if (! fsetterminfo (q->o, &q->snew))
- {
- ulog (LOG_ERROR, "Can't set CLOCAL: %s", strerror (errno));
- return FALSE;
- }
-
-#if HAVE_CLOCAL_BUG
- /* On SCO and AT&T UNIX PC you have to reopen the port. */
- {
- int onew;
-
- onew = open (q->zdevice, O_RDWR);
- if (onew < 0)
- {
- ulog (LOG_ERROR, "open (%s): %s", q->zdevice, strerror (errno));
- return FALSE;
- }
-
- if (fcntl (onew, F_SETFD,
- fcntl (onew, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- (void) close (onew);
- return FALSE;
- }
-
- (void) close (q->o);
- q->o = onew;
- }
-#endif /* HAVE_CLOCAL_BUG */
-
-#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
- }
-
- return TRUE;
-}
-
-/* Tell the port to use hardware flow control. There is no standard
- mechanism for controlling this. This implementation supports
- CRTSCTS on SunOS, RTS/CTSFLOW on 386(ish) unix, CTSCD on the 3b1,
- CCTS_OFLOW/CRTS_IFLOW on BSDI, TXADDCD/TXDELCD on AIX, and IRTS on
- NCR Tower. If you know how to do it on other systems, please
- implement it and send me the patches. */
-
-static boolean
-fsserial_hardflow (qconn, fhardflow)
- struct sconnection *qconn;
- boolean fhardflow;
-{
- register struct ssysdep_conn *q;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
-
- if (! q->fterminal)
- return TRUE;
-
- /* Don't do anything if we don't know what to do. */
-#if HAVE_BSD_TTY
-#define HAVE_HARDFLOW 0
-#endif
-#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
-#if ! HAVE_TXADDCD
-#ifndef CRTSFL
-#ifndef CRTSCTS
-#ifndef CTSCD
-#ifndef CCTS_OFLOW
-#ifndef IRTS
-#define HAVE_HARDFLOW 0
-#endif
-#endif
-#endif
-#endif
-#endif
-#endif
-#endif
-
-#ifndef HAVE_HARDFLOW
-#define HAVE_HARDFLOW 1
-#endif
-
-#if HAVE_HARDFLOW
- if (fhardflow)
- {
-#if HAVE_TXADDCD
- /* The return value does not reliably indicate whether this
- actually succeeded. */
- (void) ioctl (q->o, TXADDCD, "rts");
-#else /* ! HAVE_TXADDCD */
-#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
-#ifdef CRTSFL
- q->snew.c_cflag |= CRTSFL;
- q->snew.c_cflag &=~ (RTSFLOW | CTSFLOW);
-#endif /* defined (CRTSFL) */
-#ifdef CRTSCTS
- q->snew.c_cflag |= CRTSCTS;
-#endif /* defined (CRTSCTS) */
-#ifdef CTSCD
- q->snew.c_cflag |= CTSCD;
-#endif /* defined (CTSCD) */
-#ifdef CCTS_OFLOW
- q->snew.c_cflag |= CCTS_OFLOW | CRTS_IFLOW;
-#endif
-#ifdef IRTS
- q->snew.c_iflag |= IRTS;
-#endif
-#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
- if (! fsetterminfo (q->o, &q->snew))
- {
- ulog (LOG_ERROR, "Can't enable hardware flow control: %s",
- strerror (errno));
- return FALSE;
- }
-#endif /* ! HAVE_TXADDCD */
- }
- else
- {
-#if HAVE_TXADDCD
- /* The return value does not reliably indicate whether this
- actually succeeded. */
- (void) ioctl (q->o, TXDELCD, "rts");
-#else /* ! HAVE_TXADDCD */
-#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
-#ifdef CRTSFL
- q->snew.c_cflag &=~ CRTSFL;
- q->snew.c_cflag &=~ (RTSFLOW | CTSFLOW);
-#endif /* defined (CRTSFL) */
-#ifdef CRTSCTS
- q->snew.c_cflag &=~ CRTSCTS;
-#endif /* defined (CRTSCTS) */
-#ifdef CTSCD
- q->snew.c_cflag &=~ CTSCD;
-#endif /* defined (CTSCD) */
-#ifdef CCTS_OFLOW
- q->snew.c_cflag &=~ (CCTS_OFLOW | CRTS_IFLOW);
-#endif
-#ifdef IRTS
- q->snew.c_iflag &=~ IRTS;
-#endif
-#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
- if (! fsetterminfo (q->o, &q->snew))
- {
- ulog (LOG_ERROR, "Can't disable hardware flow control: %s",
- strerror (errno));
- return FALSE;
- }
-#endif /* ! HAVE_TXADDCD */
- }
-#endif /* HAVE_HARDFLOW */
-
- return TRUE;
-}
-
-/* Finish dialing out on a modem by closing any dialer device and waiting
- for carrier. */
-
-boolean
-fsysdep_modem_end_dial (qconn, qdial)
- struct sconnection *qconn;
- struct uuconf_dialer *qdial;
-{
- struct ssysdep_conn *q;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
-
- if (qconn->qport->uuconf_u.uuconf_smodem.uuconf_zdial_device != NULL)
- {
- (void) close (q->o);
- q->o = q->ohold;
- }
-
- if (qconn->qport->uuconf_u.uuconf_smodem.uuconf_fcarrier
- && qdial->uuconf_fcarrier)
- {
- /* Tell the port that we need carrier. */
- if (! fsmodem_carrier (qconn, TRUE))
- return FALSE;
-
-#ifdef TIOCWONLINE
-
- /* We know how to wait for carrier, so do so. */
-
- /* If we already got a signal, just quit now. */
- if (FGOT_QUIT_SIGNAL ())
- return FALSE;
-
- /* This bit of code handles signals just like fsysdep_conn_read
- does. See that function for a longer explanation. */
-
- /* Use fsysdep_catch to handle a longjmp from the signal
- handler. */
-
- fSalarm = FALSE;
-
- if (fsysdep_catch ())
- {
- /* Start catching SIGALRM; normally we ignore it. */
- usysdep_start_catch ();
- usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL);
- (void) alarm (qdial->uuconf_ccarrier_wait);
-
- /* We really don't care if we get an error, since that will
- probably just mean that TIOCWONLINE isn't supported in
- which case there's nothing we can do anyhow. If we get
- SIGINT we want to keep waiting for carrier, because
- SIGINT just means don't start any new sessions. We don't
- handle SIGINT correctly if we do a longjmp in the signal
- handler; too bad. */
- while (ioctl (q->o, TIOCWONLINE, 0) < 0
- && errno == EINTR)
- {
- /* Log the signal. */
- ulog (LOG_ERROR, (const char *) NULL);
- if (FGOT_QUIT_SIGNAL () || fSalarm)
- break;
- }
- }
-
- /* Turn off the pending SIGALRM and ignore SIGALARM again. */
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- (void) alarm (0);
- usysdep_end_catch ();
-
- /* If we got a random signal, just return FALSE. */
- if (FGOT_QUIT_SIGNAL ())
- return FALSE;
-
- /* If we timed out, give an error. */
- if (fSalarm)
- {
- ulog (LOG_ERROR, "Timed out waiting for carrier");
- return FALSE;
- }
-
-#else /* ! defined (TIOCWONLINE) */
-
- /* Try to open the port again without using O_NDELAY. In
- principle, the open should delay until carrier is available.
- This may not work on some systems, so we just ignore any
- errors. */
- {
- int onew;
-
- onew = open (q->zdevice, O_RDWR);
- if (onew >= 0)
- {
- boolean fbad;
- int iflags;
-
- fbad = FALSE;
-
- if (fcntl (onew, F_SETFD,
- fcntl (onew, F_GETFD, 0) | FD_CLOEXEC) < 0)
- fbad = TRUE;
-
- if (! fbad)
- {
- iflags = fcntl (onew, F_GETFL, 0);
- if (iflags < 0
- || ! fsetterminfo (onew, &q->snew))
- fbad = TRUE;
- }
-
- if (fbad)
- (void) close (onew);
- else
- {
- (void) close (q->o);
- q->o = onew;
- q->iflags = iflags;
-#if HAVE_TIOCSINUSE
- (void) ioctl (onew, TIOCSINUSE, 0);
-#endif
- }
- }
- }
-
-#endif /* ! defined (TIOCWONLINE) */
- }
-
- return TRUE;
-}
-
-/* Read data from a connection, with a timeout. This routine handles
- all types of connections, including TLI.
-
- This function should return when we have read cmin characters or
- the timeout has occurred. We have to work a bit to get Unix to do
- this efficiently on a terminal. The simple implementation
- schedules a SIGALRM signal and then calls read; if there is a
- single character available, the call to read will return
- immediately, so there must be a loop which terminates when the
- SIGALRM is delivered or the correct number of characters has been
- read. This can be very inefficient with a fast CPU or a low baud
- rate (or both!), since each call to read may return only one or two
- characters.
-
- Under POSIX or System V, we can specify a minimum number of
- characters to read, so there is no serious trouble.
-
- Under BSD, we figure out how many characters we have left to read,
- how long it will take for them to arrive at the current baud rate,
- and sleep that long.
-
- Doing this with a timeout and avoiding all possible race conditions
- get very hairy, though. Basically, we're going to schedule a
- SIGALRM for when the timeout expires. I don't really want to do a
- longjmp in the SIGALRM handler, though, because that may lose data.
- Therefore, I have the signal handler set a variable. However, this
- means that there will be a span of time between the time the code
- checks the variable and the time it calls the read system call; if
- the SIGALRM occurs during that time, the read might hang forever.
- To avoid this, the SIGALRM handler not only sets a global variable,
- it also schedules another SIGALRM for one second in the future
- (POSIX specifies that a signal handler is permitted to safely call
- alarm). To avoid getting a continual sequence of SIGALRM
- interrupts, we change the signal handler to ignore SIGALRM when
- we're about to exit the function. This means that every time we
- execute fsysdep_conn_read we make at least five system calls. It's
- the best I've been able to come up with, though.
-
- When fsysdep_conn_read finishes, there will be no SIGALRM scheduled
- and SIGALRM will be ignored. */
-
-boolean
-fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport)
- struct sconnection *qconn;
- char *zbuf;
- size_t *pclen;
- size_t cmin;
- int ctimeout;
- boolean freport;
-{
- CATCH_PROTECT size_t cwant;
- boolean fret;
- register struct ssysdep_conn * const q
- = (struct ssysdep_conn *) qconn->psysdep;
- int cwouldblock;
-
- cwant = *pclen;
- *pclen = 0;
-
- /* Guard against a bad timeout. We return TRUE when a timeout
- expires. It is possible to get a negative timeout here because
- the calling code does not check user supplied timeouts for
- plausibility. */
- if (ctimeout <= 0)
- return TRUE;
-
- /* We want to do a blocking read. */
- if (! fsblock (q, TRUE))
- return FALSE;
-
- fSalarm = FALSE;
-
- /* We're going to set up an alarm signal to last for the entire
- read. If the read system call cannot be interrupted, the signal
- handler will do a longjmp causing fsysdep_catch (a macro) to
- return FALSE. We handle that here. If read can be interrupted,
- fsysdep_catch will be defined to TRUE. */
- if (fsysdep_catch ())
- {
- /* Prepare to catch SIGALRM and schedule the signal. */
- usysdep_start_catch ();
- usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL);
- alarm (ctimeout);
- }
- else
- {
- /* We caught a signal. We don't actually have to do anything,
- as all the appropriate checks are made at the start of the
- following loop. */
- }
-
- fret = FALSE;
-
- cwouldblock = 0;
- while (TRUE)
- {
- int cgot;
-
-#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
- /* If we can tell the terminal not to return until we have a
- certain number of characters, do so. */
- if (q->fterminal)
- {
- int csetmin;
-
- /* I'm not that confident about setting MIN to values larger
- than 127, although up to 255 would probably work. */
- if (cmin < 127)
- csetmin = cmin;
- else
- csetmin = 127;
-
- if (csetmin != cSmin)
- {
- q->snew.c_cc[VMIN] = csetmin;
- while (! fsetterminfo (q->o, &q->snew))
- {
- if (errno != EINTR
- || FGOT_QUIT_SIGNAL ())
- {
- int ierr;
-
- /* We turn off the signal before reporting the
- error to minimize any problems with
- interrupted system calls. */
- ierr = errno;
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- alarm (0);
- usysdep_end_catch ();
- ulog (LOG_ERROR, "Can't set MIN for terminal: %s",
- strerror (ierr));
- return FALSE;
- }
-
- if (fSalarm)
- {
- ulog (LOG_ERROR,
- "Timed out when setting MIN to %d; retrying",
- csetmin);
- fSalarm = FALSE;
- alarm (ctimeout);
- }
- }
- cSmin = csetmin;
- }
- }
-#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
-
- /* If we've received a signal, get out now. */
- if (FGOT_QUIT_SIGNAL ())
- break;
-
- /* If we've already gotten a SIGALRM, get out with whatever
- we've accumulated. */
- if (fSalarm)
- {
- fret = TRUE;
- break;
- }
-
- /* Right here is the race condition which we avoid by having the
- SIGALRM handler schedule another SIGALRM. */
-#if HAVE_TLI
- if (q->ftli)
- {
- int iflags;
-
- cgot = t_rcv (q->o, zbuf, cwant, &iflags);
- if (cgot < 0 && t_errno != TSYSERR)
- {
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- alarm (0);
- usysdep_end_catch ();
-
- if (freport)
- ulog (LOG_ERROR, "t_rcv: %s",
- (t_errno >= 0 && t_errno < t_nerr
- ? t_errlist[t_errno]
- : "unknown TLI error"));
-
- return FALSE;
- }
- }
- else
-#endif
- cgot = read (q->o, zbuf, cwant);
-
- /* If the read returned an error, check for signals. */
- if (cgot < 0)
- {
- if (errno == EINTR)
- {
- /* Log the signal. */
- ulog (LOG_ERROR, (const char *) NULL);
- }
- if (fSalarm)
- {
- fret = TRUE;
- break;
- }
- if (FGOT_QUIT_SIGNAL ())
- break;
- }
-
- /* If read returned an error, get out. We just ignore EINTR
- here, since it must be from some signal we don't care about.
- If the read returned 0 then the line must have been hung up
- (normally we would have received SIGHUP, but we can't count
- on that). We turn off the signals before calling ulog to
- reduce problems with interrupted system calls. */
- if (cgot > 0)
- cwouldblock = 0;
- else
- {
- if (cgot < 0 && errno == EINTR)
- cgot = 0;
- else if (cgot < 0
- && (errno == EAGAIN || errno == EWOULDBLOCK)
- && cwouldblock < 2)
- {
- /* Incomprehensibly, on some systems the read will
- return EWOULDBLOCK even though the descriptor has
- been set to blocking mode. We permit the read call
- to do this twice in a row, and then error out. We
- don't want to permit an arbitrary number of
- EWOULDBLOCK errors, since that could hang us up
- indefinitely. */
- ++cwouldblock;
- cgot = 0;
- }
- else
- {
- int ierr;
-
- ierr = errno;
-
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- alarm (0);
- usysdep_end_catch ();
-
- if (freport)
- {
- if (cgot == 0)
- ulog (LOG_ERROR, "Line disconnected");
- else
- ulog (LOG_ERROR, "read: %s", strerror (ierr));
- }
-
- return FALSE;
- }
- }
-
- cwant -= cgot;
- if (cgot >= cmin)
- cmin = 0;
- else
- cmin -= cgot;
- zbuf += cgot;
- *pclen += cgot;
-
- /* If we have enough data, get out now. */
- if (cmin == 0)
- {
- fret = TRUE;
- break;
- }
-
-#if HAVE_BSD_TTY
- /* We still want more data, so sleep long enough for the rest of
- it to arrive. We don't this for System V or POSIX because
- setting MIN is good enough (we can't sleep longer than it
- takes to get MAX_INPUT characters anyhow).
-
- The baud rate is approximately 10 times the number of
- characters which will arrive in one second, so the number of
- milliseconds to sleep ==
- characters * (milliseconds / character) ==
- characters * (1000 * (seconds / character)) ==
- characters * (1000 * (1 / (baud / 10))) ==
- characters * (10000 / baud)
-
- We arbitrarily reduce the sleep amount by 10 milliseconds to
- attempt to account for the amount of time it takes to set up
- the sleep. This is how long it takes to get half a character
- at 19200 baud. We then don't bother to sleep for less than
- 10 milliseconds. We don't sleep if the read was interrupted.
-
- We use select to sleep. It would be easy to use poll as
- well, but it's unlikely that any system with BSD ttys would
- have poll but not select. Using select avoids hassles with
- the pending SIGALRM; if it hits the select will be
- interrupted, and otherwise the select will not affect it. */
-
-#if ! HAVE_SELECT
- #error This code requires select; feel free to extend it
-#endif
-
- if (q->fterminal && cmin > 1 && cgot > 0)
- {
- int csleepchars;
- int isleep;
-
- /* We don't try to read all the way up to MAX_INPUT,
- since that might drop a character. */
- if (cmin <= MAX_INPUT - 10)
- csleepchars = cmin;
- else
- csleepchars = MAX_INPUT - 10;
-
- isleep = (int) (((long) csleepchars * 10000L) / (q->ibaud? q->ibaud: (long)1200));
- isleep -= 10;
-
- if (isleep > 10)
- {
- struct timeval s;
-
- s.tv_sec = isleep / 1000;
- s.tv_usec = (isleep % 1000) * 1000;
-
- /* Some versions of select take a pointer to an int,
- while some take a pointer to an fd_set. I just cast
- the arguments to a generic pointer, and assume that
- any machine which distinguishes int * from fd_set *
- (I would be amazed if there are any such machines)
- have an appropriate prototype somewhere or other. */
- (void) select (0, (pointer) NULL, (pointer) NULL,
- (pointer) NULL, &s);
-
- /* Here either the select finished sleeping or we got a
- SIGALRM. If the latter occurred, fSalarm was set to
- TRUE; it will be checked at the top of the loop. */
- }
- }
-#endif /* HAVE_BSD_TTY */
- }
-
- /* Turn off the pending SIGALRM and return. */
-
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- alarm (0);
- usysdep_end_catch ();
-
- return fret;
-}
-
-/* Read from a port with separate read/write file descriptors. */
-
-boolean
-fsdouble_read (qconn, zbuf, pclen, cmin, ctimeout, freport)
- struct sconnection *qconn;
- char *zbuf;
- size_t *pclen;
- size_t cmin;
- int ctimeout;
- boolean freport;
-{
- struct ssysdep_conn *qsysdep;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- qsysdep->o = qsysdep->ord;
- return fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport);
-}
-
-/* Write data to a connection. This routine handles all types of
- connections, including TLI. */
-
-boolean
-fsysdep_conn_write (qconn, zwrite, cwrite)
- struct sconnection *qconn;
- const char *zwrite;
- size_t cwrite;
-{
- struct ssysdep_conn *q;
- int czero;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
-
- /* We want blocking writes here. */
- if (! fsblock (q, TRUE))
- return FALSE;
-
- czero = 0;
-
- while (cwrite > 0)
- {
- int cdid;
-
- /* Loop until we don't get an interrupt. */
- while (TRUE)
- {
- /* If we've received a signal, don't continue. */
- if (FGOT_QUIT_SIGNAL ())
- return FALSE;
-
-#if HAVE_TLI
- if (q->ftli)
- {
- cdid = t_snd (q->o, (char *) zwrite, cwrite, 0);
- if (cdid < 0 && t_errno != TSYSERR)
- {
- ulog (LOG_ERROR, "t_snd: %s",
- (t_errno >= 0 && t_errno < t_nerr
- ? t_errlist[t_errno]
- : "unknown TLI error"));
- return FALSE;
- }
- }
- else
-#endif
- cdid = write (q->o, zwrite, cwrite);
-
- if (cdid >= 0)
- break;
- if (errno != EINTR)
- break;
-
- /* We were interrupted by a signal. Log it. */
- ulog (LOG_ERROR, (const char *) NULL);
- }
-
- if (cdid < 0)
- {
- if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENODATA)
- {
- ulog (LOG_ERROR, "write: %s", strerror (errno));
- return FALSE;
- }
- cdid = 0;
- }
-
- if (cdid == 0)
- {
- /* On some systems write will return 0 if carrier is lost.
- If we fail to write anything ten times in a row, we
- assume that this has happened. This is hacked in like
- this because there seems to be no reliable way to tell
- exactly why the write returned 0. */
- ++czero;
- if (czero >= 10)
- {
- ulog (LOG_ERROR, "Line disconnected");
- return FALSE;
- }
- }
- else
- {
- czero = 0;
-
- cwrite -= cdid;
- zwrite += cdid;
- }
- }
-
- return TRUE;
-}
-
-/* Write to a port with separate read/write file descriptors. */
-
-boolean
-fsdouble_write (qconn, zwrite, cwrite)
- struct sconnection *qconn;
- const char *zwrite;
- size_t cwrite;
-{
- struct ssysdep_conn *qsysdep;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- qsysdep->o = qsysdep->ord;
- if (! fsblock (qsysdep, TRUE))
- return FALSE;
- qsysdep->o = qsysdep->owr;
- return fsysdep_conn_write (qconn, zwrite, cwrite);
-}
-
-/* The fsysdep_conn_io routine is supposed to both read and write data
- until it has either filled its read buffer or written out all the
- data it was given. This lets us write out large packets without
- losing incoming data. It handles all types of connections,
- including TLI. */
-
-boolean
-fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread)
- struct sconnection *qconn;
- const char *zwrite;
- size_t *pcwrite;
- char *zread;
- size_t *pcread;
-{
- struct ssysdep_conn *q;
- size_t cwrite, cread;
- int czero;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
-
- cwrite = *pcwrite;
- *pcwrite = 0;
- cread = *pcread;
- *pcread = 0;
-
- czero = 0;
-
- while (TRUE)
- {
- int cgot, cdid;
- size_t cdo;
-
- /* This used to always use nonblocking writes, but it turns out
- that some systems don't support them on terminals.
-
- The current algorithm is:
- loop:
- unblocked read
- if read buffer full, return
- if nothing to write, return
- if HAVE_UNBLOCKED_WRITES
- write all data
- else
- write up to SINGLE_WRITE bytes
- if all data written, return
- if no data written
- if select works
- select on the write descriptor with a ten second timeout
- else
- blocked write of one byte with a ten second alarm
-
- This algorithm should work whether the system supports
- unblocked writes on terminals or not. If the system supports
- unblocked writes but HAVE_UNBLOCKED_WRITES is 0, then it will
- call write more often than it needs to. If the system does
- not support unblocked writes but HAVE_UNBLOCKED_WRITES is 1,
- then the write may hang so long that incoming data is lost.
- This is actually possible at high baud rates on any system
- when a blocking write is done; there is no solution, except
- hardware handshaking.
-
- If we were not able to write any data, then we need to block
- until we can write something. The code used to simply do a
- blocking write. However, that fails when a bidirectional
- protocol is permitted to push out enough bytes to fill the
- entire pipe between the two communicating uucico processes.
- They can both block on writing, because neither is reading.
-
- In this case, we use select. We could select on both the
- read and write descriptor, but on some systems that would
- lead to calling read on each byte, which would be very
- inefficient. Instead, we select only on the write
- descriptor. After the select succeeds or times out, we retry
- the read.
-
- Of course, some systems don't have select, and on some
- systems that have it it doesn't work on terminal devices. If
- we can't use select, then we do a blocked write of a single
- byte after setting an alarm. We only write a single byte to
- avoid any confusion as to whether or not the byte was
- actually written. */
-
- /* If we are running on standard input, we switch the file
- descriptors by hand. */
- if (q->ord >= 0)
- q->o = q->ord;
-
- /* Do an unblocked read. */
- if (! fsblock (q, FALSE))
- return FALSE;
-
- /* Loop until we get something (error or data) other than an
- acceptable EINTR. */
- while (TRUE)
- {
- /* If we've received a signal, don't continue. */
- if (FGOT_QUIT_SIGNAL ())
- return FALSE;
-
-#if HAVE_TLI
- if (q->ftli)
- {
- int iflags;
-
- cgot = t_rcv (q->o, zread, cread, &iflags);
- if (cgot < 0)
- {
- if (t_errno == TNODATA)
- errno = EAGAIN;
- else if (t_errno != TSYSERR)
- {
- ulog (LOG_ERROR, "t_rcv: %s",
- (t_errno >= 0 && t_errno < t_nerr
- ? t_errlist[t_errno]
- : "unknown TLI error"));
- return FALSE;
- }
- }
- }
- else
-#endif
- cgot = read (q->o, zread, cread);
-
- if (cgot >= 0)
- break;
- if (errno != EINTR)
- break;
-
- /* We got interrupted by a signal. Log it. */
- ulog (LOG_ERROR, (const char *) NULL);
- }
-
- if (cgot < 0)
- {
- if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENODATA)
- {
- ulog (LOG_ERROR, "read: %s", strerror (errno));
- return FALSE;
- }
- cgot = 0;
- }
-
- cread -= cgot;
- zread += cgot;
- *pcread += cgot;
-
- /* If we've filled the read buffer, or we have nothing left to
- write, return out. */
- if (cread == 0 || cwrite == 0)
- return TRUE;
-
- /* The port is currently unblocked. Do a write. */
- cdo = cwrite;
-
-#if ! HAVE_UNBLOCKED_WRITES
- if (q->fterminal && cdo > SINGLE_WRITE)
- cdo = SINGLE_WRITE;
-#endif
-
- if (q->owr >= 0)
- q->o = q->owr;
-
- /* Loop until we get something besides EINTR. */
- while (TRUE)
- {
- /* If we've received a signal, don't continue. */
- if (FGOT_QUIT_SIGNAL ())
- return FALSE;
-
-#if HAVE_TLI
- if (q->ftli)
- {
- cdid = t_snd (q->o, (char *) zwrite, cdo, 0);
- if (cdid < 0)
- {
- if (t_errno == TFLOW)
- errno = EAGAIN;
- else if (t_errno != TSYSERR)
- {
- ulog (LOG_ERROR, "t_snd: %s",
- (t_errno >= 0 && t_errno < t_nerr
- ? t_errlist[t_errno]
- : "unknown TLI error"));
- return FALSE;
- }
- }
- }
- else
-#endif
- cdid = write (q->o, zwrite, cdo);
-
- if (cdid >= 0)
- break;
- if (errno != EINTR)
- break;
-
- /* We got interrupted by a signal. Log it. */
- ulog (LOG_ERROR, (const char *) NULL);
- }
-
- if (cdid < 0)
- {
- if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENODATA)
- {
- ulog (LOG_ERROR, "write: %s", strerror (errno));
- return FALSE;
- }
- cdid = 0;
- }
-
- if (cdid > 0)
- {
- /* We wrote some data. If we wrote everything, return out.
- Otherwise loop around and do another read. */
- cwrite -= cdid;
- zwrite += cdid;
- *pcwrite += cdid;
-
- if (cwrite == 0)
- return TRUE;
-
- czero = 0;
- }
- else
- {
-#if HAVE_SELECT
- struct timeval stime;
- int imask;
- int c;
-
- /* We didn't write any data. Call select. We use a timeout
- long enough for 1024 bytes to be sent.
- secs/kbyte == (1024 bytes/kbyte * 10 bits/byte) / baud bits/sec
- usecs/kbyte == (((1024 bytes/kbyte * 1000000 usecs/sec)
- / baud bits/sec)
- * 10 bits/byte)
- */
- stime.tv_sec = (long) 10240 / (q->ibaud? q->ibaud: (long)1200);
- stime.tv_usec = ((((long) 1024000000 / (q->ibaud? q->ibaud: (long)1200)) * (long) 10)
- % (long) 1000000);
-
- imask = 1 << q->o;
- if (imask == 0)
- ulog (LOG_FATAL, "fsysdep_conn_io: File descriptors too large");
-
- /* If we've received a signal, don't continue. */
- if (FGOT_QUIT_SIGNAL ())
- return FALSE;
-
- DEBUG_MESSAGE0 (DEBUG_PORT, "fsysdep_conn_io: Calling select");
-
- /* We don't bother to loop on EINTR. If we get a signal, we
- just loop around and try the read and write again. */
- c = select (q->o + 1, (pointer) NULL, (pointer) &imask,
- (pointer) NULL, &stime);
- if (c < 0 && errno == EINTR)
- {
- /* We got interrupted by a signal. Log it. */
- ulog (LOG_ERROR, (const char *) NULL);
- }
- else if (c >= 0)
- {
- /* The select either discovered that we could write
- something, or it timed out. Either way, we go around
- the main read/write loop again. */
- }
- else
-#endif /* HAVE_SELECT */
- {
- int ierr;
-
- /* Either the select failed for some reason other than
- EINTR, or the system does not support select at all.
- Fall back on a timed write. We don't worry about why
- the select might have failed, we just assume that it
- will not succeed on this descriptor. */
-
-#if HAVE_RESTARTABLE_SYSCALLS
- /* If HAVE_RESTARTABLE_SYSCALLS, then receiving an alarm
- signal in the middle of a write will not cause the
- write to return EINTR, and the only way to interrupt
- the write is to longjmp out of it (see sysh.unx).
- That is unreliable, because it means that we won't
- know whether the byte was actually written or not.
- However, I believe that the only system on which we
- need to do this longjmp is BSD 4.2, and that system
- supports select, so we should never execute this
- case. */
- ulog (LOG_FATAL, "fsysdep_conn_io: Unsupported case; see code");
-#endif
-
- if (q->ord >= 0)
- q->o = q->ord;
-
- if (! fsblock (q, TRUE))
- return FALSE;
-
- DEBUG_MESSAGE0 (DEBUG_PORT, "fsysdep_conn_io: Blocking write");
-
- if (q->owr >= 0)
- q->o = q->owr;
-
- /* If we've received a signal, don't continue. */
- if (FGOT_QUIT_SIGNAL ())
- return FALSE;
-
- /* Start up an alarm to interrupt the write. Note that
- we don't need to use the catch stuff, since we know
- that HAVE_RESTARTABLE_SYSCALLS is 0. */
- usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL);
- alarm ((int) ((long) 10240 / (q->ibaud? q->ibaud: (long)1200)) + 1);
-
- /* There is a race condition here: on a severely loaded
- system, we could get the alarm before we start the
- write call. This would not be a disaster; often the
- write will succeed anyhow. */
-#if HAVE_TLI
- if (q->ftli)
- {
- cdid = t_snd (q->o, (char *) zwrite, 1, 0);
- if (cdid < 0 && t_errno != TSYSERR)
- {
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- alarm (0);
- ulog (LOG_ERROR, "t_snd: %s",
- (t_errno >= 0 && t_errno < t_nerr
- ? t_errlist[t_errno]
- : "unknown TLI error"));
- return FALSE;
- }
- }
- else
-#endif
- cdid = write (q->o, zwrite, 1);
-
- ierr = errno;
-
- /* Note that we don't really care whether the write
- finished because the byte was written out or whether
- it finished because the alarm was triggered. Either
- way, we are going to loop around and try another
- read. */
-
- usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
- alarm (0);
-
- if (cdid < 0)
- {
- if (ierr == EINTR)
- {
- /* We got interrupted by a signal. Log it. */
- ulog (LOG_ERROR, (const char *) NULL);
- }
- else
- {
- ulog (LOG_ERROR, "write: %s", strerror (ierr));
- return FALSE;
- }
- }
- else if (cdid == 0)
- {
- /* On some systems write will return 0 if carrier is
- lost. If we fail to write anything ten times in
- a row, we assume that this has happened. This is
- hacked in like this because there seems to be no
- reliable way to tell exactly why the write
- returned 0. */
- ++czero;
- if (czero >= 10)
- {
- ulog (LOG_ERROR, "Line disconnected");
- return FALSE;
- }
- }
- else
- {
- cwrite -= cdid;
- zwrite += cdid;
- *pcwrite += cdid;
- czero = 0;
- }
- }
- }
- }
-}
-
-/* Send a break character to a serial port. */
-
-static boolean
-fsserial_break (qconn)
- struct sconnection *qconn;
-{
- struct ssysdep_conn *q;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
-
-#if HAVE_BSD_TTY
- (void) ioctl (q->o, TIOCSBRK, 0);
- sleep (2);
- (void) ioctl (q->o, TIOCCBRK, 0);
- return TRUE;
-#endif /* HAVE_BSD_TTY */
-#if HAVE_SYSV_TERMIO
- (void) ioctl (q->o, TCSBRK, 0);
- return TRUE;
-#endif /* HAVE_SYSV_TERMIO */
-#if HAVE_POSIX_TERMIOS
- return tcsendbreak (q->o, 0) == 0;
-#endif /* HAVE_POSIX_TERMIOS */
-}
-
-/* Send a break character to a stdin port. */
-
-static boolean
-fsstdin_break (qconn)
- struct sconnection *qconn;
-{
- struct ssysdep_conn *qsysdep;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- qsysdep->o = qsysdep->owr;
- return fsserial_break (qconn);
-}
-
-/* Change the setting of a serial port. */
-
-/*ARGSUSED*/
-static boolean
-fsserial_set (qconn, tparity, tstrip, txonxoff)
- struct sconnection *qconn;
- enum tparitysetting tparity;
- enum tstripsetting tstrip;
- enum txonxoffsetting txonxoff;
-{
- register struct ssysdep_conn *q;
- boolean fchanged, fdo;
- int iset = 0;
- int iclear = 0;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
-
- if (! q->fterminal)
- return TRUE;
-
- fchanged = FALSE;
-
- /* Set the parity for output characters. */
-
-#if HAVE_BSD_TTY
-
- /* This will also cause parity detection on input characters. */
-
- fdo = FALSE;
- switch (tparity)
- {
- case PARITYSETTING_DEFAULT:
- break;
- case PARITYSETTING_NONE:
-#if HAVE_PARITY_BUG
- /* The Sony NEWS mishandles this for some reason. */
- iset = 0;
- iclear = ANYP;
-#else
- iset = ANYP;
- iclear = 0;
-#endif
- fdo = TRUE;
- break;
- case PARITYSETTING_EVEN:
- iset = EVENP;
- iclear = ODDP;
- fdo = TRUE;
- break;
- case PARITYSETTING_ODD:
- iset = ODDP;
- iclear = EVENP;
- fdo = TRUE;
- break;
- case PARITYSETTING_MARK:
- case PARITYSETTING_SPACE:
- /* Not supported. */
- break;
- }
-
- if (fdo)
- {
- if ((q->snew.stty.sg_flags & iset) != iset
- || (q->snew.stty.sg_flags & iclear) != 0)
- {
- q->snew.stty.sg_flags |= iset;
- q->snew.stty.sg_flags &=~ iclear;
- fchanged = TRUE;
- }
- }
-
-#else /* ! HAVE_BSD_TTY */
-
- fdo = FALSE;
- switch (tparity)
- {
- case PARITYSETTING_DEFAULT:
- break;
- case PARITYSETTING_NONE:
- iset = CS8;
- iclear = PARENB | PARODD | (CSIZE &~ CS8);
- fdo = TRUE;
- break;
- case PARITYSETTING_EVEN:
- iset = PARENB | CS7;
- iclear = PARODD | (CSIZE &~ CS7);
- fdo = TRUE;
- break;
- case PARITYSETTING_ODD:
- iset = PARENB | PARODD | CS7;
- iclear = CSIZE &~ CS7;
- fdo = TRUE;
- break;
- case PARITYSETTING_MARK:
- case PARITYSETTING_SPACE:
- /* Not supported. */
- break;
- }
-
- if (fdo)
- {
- if ((q->snew.c_cflag & iset) != iset
- || (q->snew.c_cflag & iclear) != 0)
- {
- q->snew.c_cflag |= iset;
- q->snew.c_cflag &=~ iclear;
- fchanged = TRUE;
- }
- }
-
-#endif /* ! HAVE_BSD_TTY */
-
- /* Set whether input characters are stripped to seven bits. */
-
-#if HAVE_BSD_TTY
-
-#ifdef LPASS8
- {
- int i;
-
- i = LPASS8;
- if (tstrip == STRIPSETTING_EIGHTBITS)
- {
- i = LPASS8;
- (void) ioctl (q->o, TIOCLBIS, &i);
- }
- else if (tstrip == STRIPSETTING_SEVENBITS)
- {
- i = LPASS8;
- (void) ioctl (q->o, TIOCLBIC, &i);
- }
- }
-#endif
-
-#else /* ! HAVE_BSD_TTY */
-
- fdo = FALSE;
- switch (tstrip)
- {
- case STRIPSETTING_DEFAULT:
- break;
- case STRIPSETTING_EIGHTBITS:
- iset = 0;
- iclear = ISTRIP;
- fdo = TRUE;
- break;
- case STRIPSETTING_SEVENBITS:
- iset = ISTRIP;
- iclear = 0;
- fdo = TRUE;
- break;
- }
-
- if (fdo)
- {
- if ((q->snew.c_iflag & iset) != iset
- || (q->snew.c_iflag & iclear) != 0)
- {
- q->snew.c_iflag |= iset;
- q->snew.c_iflag &=~ iclear;
- fchanged = TRUE;
- }
- }
-
-#endif /* ! HAVE_BSD_TTY */
-
- /* Set XON/XOFF handshaking. */
-
-#if HAVE_BSD_TTY
-
- fdo = FALSE;
- switch (txonxoff)
- {
- case XONXOFF_DEFAULT:
- break;
- case XONXOFF_OFF:
- iset = RAW;
- iclear = TANDEM | CBREAK;
- fdo = TRUE;
- break;
- case XONXOFF_ON:
- iset = CBREAK | TANDEM;
- iclear = RAW;
- fdo = TRUE;
- break;
- }
-
- if (fdo)
- {
- if ((q->snew.stty.sg_flags & iset) != iset
- || (q->snew.stty.sg_flags & iclear) != 0)
- {
- q->snew.stty.sg_flags |= iset;
- q->snew.stty.sg_flags &=~ iclear;
- fchanged = TRUE;
- }
- }
-
-#else /* ! HAVE_BSD_TTY */
-
- fdo = FALSE;
- switch (txonxoff)
- {
- case XONXOFF_DEFAULT:
- break;
- case XONXOFF_OFF:
- iset = 0;
- iclear = IXON | IXOFF;
- fdo = TRUE;
- break;
- case XONXOFF_ON:
-#ifdef CRTSCTS
-#if HAVE_POSIX_TERMIOS
- /* This is system dependent, but I haven't figured out a good
- way around it yet. If we are doing hardware flow control, we
- don't send XON/XOFF characters but we do recognize them. */
- if ((q->snew.c_cflag & CRTSCTS) != 0)
- {
- iset = IXON;
- iclear = IXOFF;
- fdo = TRUE;
- break;
- }
-#endif /* HAVE_POSIX_TERMIOS */
-#endif /* defined (CRTSCTS) */
-#ifdef CRTSFL
- if ((q->snew.c_cflag & CRTSFL) != 0)
- {
- iset = IXON;
- iclear = IXOFF;
- /* SCO says we cant have CRTSFL **and** RTSFLOW/CTSFLOW */
-#ifdef RTSFLOW
- iclear |= RTSFLOW;
-#endif
-#ifdef CTSFLOW
- iclear |= CTSFLOW;
-#endif
- fdo = TRUE;
- break;
- }
-#endif /* defined(CRTSFL) */
- iset = IXON | IXOFF;
- iclear = 0;
- fdo = TRUE;
- break;
- }
-
- if (fdo)
- {
- if ((q->snew.c_iflag & iset) != iset
- || (q->snew.c_iflag & iclear) != 0)
- {
- q->snew.c_iflag |= iset;
- q->snew.c_iflag &=~ iclear;
- fchanged = TRUE;
- }
- }
-
-#endif /* ! HAVE_BSD_TTY */
-
- if (fchanged)
- {
- if (! fsetterminfodrain (q->o, &q->snew))
- {
- ulog (LOG_ERROR, "Can't change terminal settings: %s",
- strerror (errno));
- return FALSE;
- }
- }
-
-#if HAVE_BSD_TTY
- if (txonxoff == XONXOFF_ON
- && (q->snew.stty.sg_flags & ANYP) == ANYP)
- {
- int i;
-
- /* At least on Ultrix, we seem to have to set LLITOUT and
- LPASS8. This shouldn't foul things up anywhere else. As far
- as I can tell, this has to be done after setting the terminal
- into cbreak mode, not before. */
-#ifndef LLITOUT
-#define LLITOUT 0
-#endif
-#ifndef LPASS8
-#define LPASS8 0
-#endif
-#ifndef LAUTOFLOW
-#define LAUTOFLOW 0
-#endif
- i = LLITOUT | LPASS8 | LAUTOFLOW;
- (void) ioctl (q->o, TIOCLBIS, &i);
-
-#if HAVE_STRIP_BUG
- /* Ultrix 4.0 has a peculiar problem: setting CBREAK always
- causes input characters to be stripped. I hope this does not
- apply to other BSD systems. It is possible to work around
- this by using the termio call. I wish this sort of stuff was
- not necessary!!! */
- {
- struct termio s;
-
- if (ioctl (q->o, TCGETA, &s) >= 0)
- {
- s.c_iflag &=~ ISTRIP;
- (void) ioctl (q->o, TCSETA, &s);
- }
- }
-#endif /* HAVE_STRIP_BUG */
- }
-#endif /* HAVE_BSD_TTY */
-
- return TRUE;
-}
-
-/* Change settings of a stdin port. */
-
-static boolean
-fsstdin_set (qconn, tparity, tstrip, txonxoff)
- struct sconnection *qconn;
- enum tparitysetting tparity;
- enum tstripsetting tstrip;
- enum txonxoffsetting txonxoff;
-{
- struct ssysdep_conn *qsysdep;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- qsysdep->o = qsysdep->ord;
- return fsserial_set (qconn, tparity, tstrip, txonxoff);
-}
-
-/* Run a chat program. */
-
-static boolean
-fsrun_chat (oread, owrite, pzprog)
- int oread;
- int owrite;
- char **pzprog;
-{
- int aidescs[3];
- FILE *e;
- pid_t ipid;
- char *z;
- size_t c;
-
- aidescs[0] = oread;
- aidescs[1] = owrite;
- aidescs[2] = SPAWN_READ_PIPE;
-
- /* Pass fkeepuid, fkeepenv and fshell as TRUE. This puts the
- responsibility of maintaing security on the chat program. */
- ipid = ixsspawn ((const char **) pzprog, aidescs, TRUE, TRUE,
- (const char *) NULL, FALSE, TRUE, (const char *) NULL,
- (const char *) NULL, (const char *) NULL);
- if (ipid < 0)
- {
- ulog (LOG_ERROR, "ixsspawn (%s): %s", pzprog[0], strerror (errno));
- return FALSE;
- }
-
- e = fdopen (aidescs[2], (char *) "r");
- if (e == NULL)
- {
- ulog (LOG_ERROR, "fdopen: %s", strerror (errno));
- (void) close (aidescs[2]);
- (void) kill (ipid, SIGKILL);
- (void) ixswait ((unsigned long) ipid, (const char *) NULL);
- return FALSE;
- }
-
- /* The FILE e now is attached to stderr of the program. Forward
- every line the program outputs to the log file. */
- z = NULL;
- c = 0;
- while (getline (&z, &c, e) > 0)
- {
- size_t clen;
-
- clen = strlen (z);
- if (z[clen - 1] == '\n')
- z[clen - 1] = '\0';
- if (*z != '\0')
- ulog (LOG_NORMAL, "chat: %s", z);
- }
-
- xfree ((pointer) z);
- (void) fclose (e);
-
- return ixswait ((unsigned long) ipid, "Chat program") == 0;
-}
-
-/* Run a chat program on a port using separate read/write file
- descriptors. */
-
-boolean
-fsdouble_chat (qconn, pzprog)
- struct sconnection *qconn;
- char **pzprog;
-{
- struct ssysdep_conn *qsysdep;
- boolean fret;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- fret = fsrun_chat (qsysdep->ord, qsysdep->owr, pzprog);
- if (qsysdep->fterminal)
- (void) fgetterminfo (qsysdep->ord, &qsysdep->snew);
- return fret;
-}
-
-/* Run a chat program on any general type of connection. */
-
-boolean
-fsysdep_conn_chat (qconn, pzprog)
- struct sconnection *qconn;
- char **pzprog;
-{
- struct ssysdep_conn *qsysdep;
- boolean fret;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- fret = fsrun_chat (qsysdep->o, qsysdep->o, pzprog);
- if (qsysdep->fterminal)
- (void) fgetterminfo (qsysdep->o, &qsysdep->snew);
- return fret;
-}
-
-/* Return baud rate of a serial port. */
-
-static long
-isserial_baud (qconn)
- struct sconnection *qconn;
-{
- struct ssysdep_conn *qsysdep;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- return qsysdep->ibaud;
-}
diff --git a/gnu/libexec/uucp/libunix/signal.c b/gnu/libexec/uucp/libunix/signal.c
deleted file mode 100644
index 6aa899b..0000000
--- a/gnu/libexec/uucp/libunix/signal.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/* signal.c
- Signal handling routines.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-/* Signal handling routines. When we catch a signal, we want to set
- the appropriate elements of afSignal and afLog_signal to TRUE. If
- we are on a system which restarts system calls, we may also want to
- longjmp out. On a system which does not restart system calls,
- these signal handling routines are well-defined by ANSI C. */
-
-#if HAVE_RESTARTABLE_SYSCALLS
-volatile sig_atomic_t fSjmp;
-volatile jmp_buf sSjmp_buf;
-#endif /* HAVE_RESTARTABLE_SYSCALLS */
-
-/* Some systems, such as SunOS, have a SA_INTERRUPT bit that must be
- set in the sigaction structure to force system calls to be
- interrupted. */
-#ifndef SA_INTERRUPT
-#define SA_INTERRUPT 0
-#endif
-
-/* The SVR3 sigset function can be called just like signal, unless
- system calls are restarted which is extremely unlikely; we prevent
- this case in sysh.unx. */
-#if HAVE_SIGSET && ! HAVE_SIGACTION && ! HAVE_SIGVEC
-#define signal sigset
-#endif
-
-/* The sigvec structure changed from 4.2BSD to 4.3BSD. These macros
- make the 4.3 code backward compatible. */
-#ifndef SV_INTERRUPT
-#define SV_INTERRUPT 0
-#endif
-#if ! HAVE_SIGVEC_SV_FLAGS
-#define sv_flags sv_onstack
-#endif
-
-/* Catch a signal. Reinstall the signal handler if necessary, set the
- appropriate variables, and do a longjmp if necessary. */
-
-RETSIGTYPE
-ussignal (isig)
- int isig;
-{
- int iindex;
-
-#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET
- (void) signal (isig, ussignal);
-#endif
-
- switch (isig)
- {
- default: iindex = INDEXSIG_SIGHUP; break;
-#ifdef SIGINT
- case SIGINT: iindex = INDEXSIG_SIGINT; break;
-#endif
-#ifdef SIGQUIT
- case SIGQUIT: iindex = INDEXSIG_SIGQUIT; break;
-#endif
-#ifdef SIGTERM
- case SIGTERM: iindex = INDEXSIG_SIGTERM; break;
-#endif
-#ifdef SIGPIPE
- case SIGPIPE: iindex = INDEXSIG_SIGPIPE; break;
-#endif
- }
-
- afSignal[iindex] = TRUE;
- afLog_signal[iindex] = TRUE;
-
-#if HAVE_RESTARTABLE_SYSCALLS
- if (fSjmp)
- longjmp (sSjmp_buf, 1);
-#endif /* HAVE_RESTARTABLE_SYSCALLS */
-}
-
-/* Prepare to catch a signal. This is basically the ANSI C routine
- signal, but it uses sigaction or sigvec instead if they are
- available. If fforce is FALSE, we do not set the signal if it is
- currently being ignored. If pfignored is not NULL and fforce is
- FALSE, then *pfignored will be set to TRUE if the signal was
- previously being ignored (if fforce is TRUE the value returned in
- *pfignored is meaningless). If we can't change the signal handler
- we give a fatal error. */
-
-void
-usset_signal (isig, pfn, fforce, pfignored)
- int isig;
- RETSIGTYPE (*pfn) P((int));
- boolean fforce;
- boolean *pfignored;
-{
-#if HAVE_SIGACTION
-
- struct sigaction s;
-
- if (! fforce)
- {
- (void) (sigemptyset (&s.sa_mask));
- if (sigaction (isig, (struct sigaction *) NULL, &s) != 0)
- ulog (LOG_FATAL, "sigaction (%d): %s", isig, strerror (errno));
-
- if (s.sa_handler == SIG_IGN)
- {
- if (pfignored != NULL)
- *pfignored = TRUE;
- return;
- }
-
- if (pfignored != NULL)
- *pfignored = FALSE;
- }
-
- s.sa_handler = pfn;
- (void) (sigemptyset (&s.sa_mask));
- s.sa_flags = SA_INTERRUPT;
-
- if (sigaction (isig, &s, (struct sigaction *) NULL) != 0)
- ulog (LOG_FATAL, "sigaction (%d): %s", isig, strerror (errno));
-
-#else /* ! HAVE_SIGACTION */
-#if HAVE_SIGVEC
-
- struct sigvec s;
-
- if (! fforce)
- {
- if (sigvec (isig, (struct sigvec *) NULL, &s) != 0)
- ulog (LOG_FATAL, "sigvec (%d): %s", isig, strerror (errno));
-
- if (s.sv_handler == SIG_IGN)
- {
- if (pfignored != NULL)
- *pfignored = TRUE;
- return;
- }
-
- if (pfignored != NULL)
- *pfignored = FALSE;
- }
-
- s.sv_handler = pfn;
- s.sv_mask = 0;
- s.sv_flags = SV_INTERRUPT;
-
- if (sigvec (isig, &s, (struct sigvec *) NULL) != 0)
- ulog (LOG_FATAL, "sigvec (%d): %s", isig, strerror (errno));
-
-#else /* ! HAVE_SIGVEC */
-
- if (! fforce)
- {
- if (signal (isig, SIG_IGN) == SIG_IGN)
- {
- if (pfignored != NULL)
- *pfignored = TRUE;
- return;
- }
-
- if (pfignored != NULL)
- *pfignored = FALSE;
- }
-
- (void) signal (isig, pfn);
-
-#endif /* ! HAVE_SIGVEC */
-#endif /* ! HAVE_SIGACTION */
-}
-
-/* The routine called by the system independent code, which always
- uses the same signal handler. */
-
-void
-usysdep_signal (isig)
- int isig;
-{
- usset_signal (isig, ussignal, FALSE, (boolean *) NULL);
-}
diff --git a/gnu/libexec/uucp/libunix/sindir.c b/gnu/libexec/uucp/libunix/sindir.c
deleted file mode 100644
index 7c9da50..0000000
--- a/gnu/libexec/uucp/libunix/sindir.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* sindir.c
- Stick a directory and file name together. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-char *
-zsysdep_in_dir (zdir, zfile)
- const char *zdir;
- const char *zfile;
-{
- size_t cdir, cfile;
- char *zret;
-
- cdir = strlen (zdir);
- cfile = strlen (zfile);
- zret = zbufalc (cdir + cfile + 2);
- if (cdir == 1 && *zdir == '/')
- cdir = 0;
- else
- memcpy (zret, zdir, cdir);
- memcpy (zret + cdir + 1, zfile, cfile);
- zret[cdir] = '/';
- zret[cdir + cfile + 1] = '\0';
- return zret;
-}
diff --git a/gnu/libexec/uucp/libunix/size.c b/gnu/libexec/uucp/libunix/size.c
deleted file mode 100644
index 8d021db..0000000
--- a/gnu/libexec/uucp/libunix/size.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* size.c
- Get the size in bytes of a file. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-long
-csysdep_size (zfile)
- const char *zfile;
-{
- struct stat s;
-
- if (stat ((char *) zfile, &s) < 0)
- {
- if (errno == ENOENT)
- return -1;
- ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno));
- return -2;
- }
-
- return s.st_size;
-}
diff --git a/gnu/libexec/uucp/libunix/sleep.c b/gnu/libexec/uucp/libunix/sleep.c
deleted file mode 100644
index 910c929..0000000
--- a/gnu/libexec/uucp/libunix/sleep.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* sleep.c
- Sleep for a number of seconds. */
-
-#include "uucp.h"
-
-#include "sysdep.h"
-#include "system.h"
-
-void
-usysdep_sleep (c)
- int c;
-{
-#if HAVE_NAPMS || HAVE_NAP || HAVE_USLEEP || HAVE_SELECT || HAVE_POLL
- int i;
-
- /* In this case, usysdep_pause is accurate. */
- for (i = 2 * c; i > 0; i--)
- usysdep_pause ();
-#else
- /* On some system sleep (1) may not sleep at all. Avoid this sort
- of problem by always doing at least sleep (2). */
- if (c < 2)
- c = 2;
- (void) sleep (c);
-#endif
-}
diff --git a/gnu/libexec/uucp/libunix/spawn.c b/gnu/libexec/uucp/libunix/spawn.c
deleted file mode 100644
index d39e2ba..0000000
--- a/gnu/libexec/uucp/libunix/spawn.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/* spawn.c
- Spawn a program securely.
-
- Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-#ifndef environ
-extern char **environ;
-#endif
-
-/* Spawn a child in a fairly secure fashion. This returns the process
- ID of the child or -1 on error. It takes far too many arguments:
-
- pazargs -- arguments (element 0 is command)
- aidescs -- file descriptors for stdin, stdout and stderr
- fkeepuid -- TRUE if euid should be left unchanged
- fkeepenv -- TRUE if environment should be left unmodified
- zchdir -- directory to chdir to
- fnosigs -- TRUE if child should ignore SIGHUP, SIGINT and SIGQUIT
- fshell -- TRUE if should try /bin/sh if execve gets ENOEXEC
- zpath -- value for environment variable PATH
- zuu_machine -- value for environment variable UU_MACHINE
- zuu_user -- value for environment variable UU_USER
-
- The aidescs array is three elements long. 0 is stdin, 1 is stdout
- and 2 is stderr. The array may contain either file descriptor
- numbers to dup appropriately, or one of the following:
-
- SPAWN_NULL -- set descriptor to /dev/null
- SPAWN_READ_PIPE -- set aidescs element to pipe for parent to read
- SPAWN_WRITE_PIPE -- set aidescs element to pipe for parent to write
-
- If fkeepenv is FALSE, a standard environment is created. The
- environment arguments (zpath, zuu_machine and zuu_user) are only
- used if fkeepenv is FALSE; any of them may be NULL.
-
- This routine expects that all file descriptors have been set to
- close-on-exec, so it doesn't have to worry about closing them
- explicitly. It sets the close-on-exec flag for the new pipe
- descriptors it returns. */
-
-pid_t
-ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell,
- zpath, zuu_machine, zuu_user)
- const char **pazargs;
- int aidescs[3];
- boolean fkeepuid;
- boolean fkeepenv;
- const char *zchdir;
- boolean fnosigs;
- boolean fshell;
- const char *zpath;
- const char *zuu_machine;
- const char *zuu_user;
-{
- char *zshcmd;
- int i;
- char *azenv[9];
- char **pazenv;
- boolean ferr;
-#if HAVE_FULLDUPLEX_PIPES
- boolean ffullduplex;
-#endif
- int ierr = 0;
- int onull;
- int aichild_descs[3];
- int cpar_close;
- int aipar_close[4];
- int cchild_close;
- int aichild_close[3];
- pid_t iret = 0;
- const char *zcmd;
-
- /* If we might have to use the shell, allocate enough space for the
- quoted command before forking. Otherwise the allocation would
- modify the data segment and we could not safely use vfork. */
- zshcmd = NULL;
- if (fshell)
- {
- size_t clen;
-
- clen = 0;
- for (i = 0; pazargs[i] != NULL; i++)
- clen += strlen (pazargs[i]);
- zshcmd = zbufalc (2 * clen + i);
- }
-
- /* Set up a standard environment. This is again done before forking
- because it will modify the data segment. */
- if (fkeepenv)
- pazenv = environ;
- else
- {
- const char *zterm, *ztz;
- char *zspace;
- int ienv;
-
- if (zpath == NULL)
- zpath = CMDPATH;
-
- azenv[0] = zbufalc (sizeof "PATH=" + strlen (zpath));
- sprintf (azenv[0], "PATH=%s", zpath);
- zspace = azenv[0] + sizeof "PATH=" - 1;
- while ((zspace = strchr (zspace, ' ')) != NULL)
- *zspace = ':';
-
- azenv[1] = zbufalc (sizeof "HOME=" + strlen (zSspooldir));
- sprintf (azenv[1], "HOME=%s", zSspooldir);
-
- zterm = getenv ("TERM");
- if (zterm == NULL)
- zterm = "unknown";
- azenv[2] = zbufalc (sizeof "TERM=" + strlen (zterm));
- sprintf (azenv[2], "TERM=%s", zterm);
-
- azenv[3] = zbufcpy ("SHELL=/bin/sh");
-
- azenv[4] = zbufalc (sizeof "USER=" + strlen (OWNER));
- sprintf (azenv[4], "USER=%s", OWNER);
-
- ienv = 5;
-
- ztz = getenv ("TZ");
- if (ztz != NULL)
- {
- azenv[ienv] = zbufalc (sizeof "TZ=" + strlen (ztz));
- sprintf (azenv[ienv], "TZ=%s", ztz);
- ++ienv;
- }
-
- if (zuu_machine != NULL)
- {
- azenv[ienv] = zbufalc (sizeof "UU_MACHINE="
- + strlen (zuu_machine));
- sprintf (azenv[ienv], "UU_MACHINE=%s", zuu_machine);
- ++ienv;
- }
-
- if (zuu_user != NULL)
- {
- azenv[ienv] = zbufalc (sizeof "UU_USER="
- + strlen (zuu_user));
- sprintf (azenv[ienv], "UU_USER=%s", zuu_user);
- ++ienv;
- }
-
- azenv[ienv] = NULL;
- pazenv = azenv;
- }
-
- /* Set up any needed pipes. */
-
- ferr = FALSE;
- onull = -1;
- cpar_close = 0;
- cchild_close = 0;
-
-#if HAVE_FULLDUPLEX_PIPES
- ffullduplex = (aidescs[0] == SPAWN_WRITE_PIPE
- && aidescs[1] == SPAWN_READ_PIPE);
-#endif
-
- for (i = 0; i < 3; i++)
- {
- if (aidescs[i] == SPAWN_NULL)
- {
- if (onull < 0)
- {
- onull = open ((char *) "/dev/null", O_RDWR);
- if (onull < 0
- || fcntl (onull, F_SETFD,
- fcntl (onull, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ierr = errno;
- (void) close (onull);
- ferr = TRUE;
- break;
- }
- aipar_close[cpar_close] = onull;
- ++cpar_close;
- }
- aichild_descs[i] = onull;
- }
- else if (aidescs[i] != SPAWN_READ_PIPE
- && aidescs[i] != SPAWN_WRITE_PIPE)
- aichild_descs[i] = aidescs[i];
- else
- {
- int aipipe[2];
-
-#if HAVE_FULLDUPLEX_PIPES
- if (ffullduplex && i == 1)
- {
- /* Just use the fullduplex pipe. */
- aidescs[i] = aidescs[0];
- aichild_descs[i] = aichild_descs[0];
- continue;
- }
-#endif
-
- if (pipe (aipipe) < 0)
- {
- ierr = errno;
- ferr = TRUE;
- break;
- }
-
- if (aidescs[i] == SPAWN_READ_PIPE)
- {
- aidescs[i] = aipipe[0];
- aichild_close[cchild_close] = aipipe[0];
- aichild_descs[i] = aipipe[1];
- aipar_close[cpar_close] = aipipe[1];
- }
- else
- {
- aidescs[i] = aipipe[1];
- aichild_close[cchild_close] = aipipe[1];
- aichild_descs[i] = aipipe[0];
- aipar_close[cpar_close] = aipipe[0];
- }
-
- ++cpar_close;
- ++cchild_close;
-
- if (fcntl (aipipe[0], F_SETFD,
- fcntl (aipipe[0], F_GETFD, 0) | FD_CLOEXEC) < 0
- || fcntl (aipipe[1], F_SETFD,
- fcntl (aipipe[1], F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ierr = errno;
- ferr = TRUE;
- break;
- }
- }
- }
-
-#if DEBUG > 1
- if (! ferr && FDEBUGGING (DEBUG_EXECUTE))
- {
- ulog (LOG_DEBUG_START, "Forking %s", pazargs[0]);
- for (i = 1; pazargs[i] != NULL; i++)
- ulog (LOG_DEBUG_CONTINUE, " %s", pazargs[i]);
- ulog (LOG_DEBUG_END, "%s", "");
- }
-#endif
-
- if (! ferr)
- {
- /* This should really be vfork if available. */
- iret = ixsfork ();
- if (iret < 0)
- {
- ferr = TRUE;
- ierr = errno;
- }
- }
-
- if (ferr)
- {
- for (i = 0; i < cchild_close; i++)
- (void) close (aichild_close[i]);
- iret = -1;
- }
-
- if (iret != 0)
- {
- /* The parent. Close the child's ends of the pipes and return
- the process ID, or an error. */
- for (i = 0; i < cpar_close; i++)
- (void) close (aipar_close[i]);
- ubuffree (zshcmd);
- if (! fkeepenv)
- {
- char **pz;
-
- for (pz = azenv; *pz != NULL; pz++)
- ubuffree (*pz);
- }
- errno = ierr;
- return iret;
- }
-
- /* The child. */
-
-#ifdef STDIN_FILENO
-#if STDIN_FILENO != 0 || STDOUT_FILENO != 1 || STDERR_FILENO != 2
- #error The following code makes invalid assumptions
-#endif
-#endif
-
- for (i = 0; i < 3; i++)
- {
- if (aichild_descs[i] != i)
- (void) dup2 (aichild_descs[i], i);
- /* This should only be necessary if aichild_descs[i] == i, but
- some systems copy the close-on-exec flag for a dupped
- descriptor, which is wrong according to POSIX. */
- (void) fcntl (i, F_SETFD, fcntl (i, F_GETFD, 0) &~ FD_CLOEXEC);
- }
-
- zcmd = pazargs[0];
- pazargs[0] = strrchr (zcmd, '/');
- if (pazargs[0] == NULL)
- pazargs[0] = zcmd;
- else
- ++pazargs[0];
-
- if (! fkeepuid)
- {
- /* Return to the uid of the invoking user. */
- (void) setuid (getuid ());
- (void) setgid (getgid ());
- }
- else
- {
- /* Try to force the UUCP uid to be both real and effective user
- ID, in order to present a consistent environment regardless
- of the invoking user. This won't work on older System V
- based systems, where it can cause trouble if ordinary users
- wind up executing uuxqt, perhaps via uucico; any program
- which uuxqt executes will have an arbitrary real user ID, so
- if the program is itself a setuid program, any security
- checks it does based on the real user ID will be incorrect.
- Fixing this problem would seem to require a special setuid
- root program; I have not used this approach because
- modern systems should not suffer from it. */
-#if HAVE_SETREUID
- (void) setreuid (geteuid (), -1);
- (void) setregid (getegid (), -1);
-#else
- (void) setuid (geteuid ());
- (void) setgid (getegid ());
-#endif
- }
-
- if (zchdir != NULL)
- (void) chdir (zchdir);
-
- if (fnosigs)
- {
-#ifdef SIGHUP
- (void) signal (SIGHUP, SIG_IGN);
-#endif
-#ifdef SIGINT
- (void) signal (SIGINT, SIG_IGN);
-#endif
-#ifdef SIGQUIT
- (void) signal (SIGQUIT, SIG_IGN);
-#endif
- }
-
-#ifdef isc386
-#ifdef _POSIX_SOURCE
- /* ISC has a remarkably stupid notion of environments. If a program
- is compiled in the POSIX environment, it sets a process state.
- If you then exec a program which expects the USG environment, the
- process state is not reset, so the execed program fails. The
- __setostype call is required to change back to the USG
- environment. This ought to be a switch in policy.h, but it seems
- too trivial, so I will leave this code here and wait for it to
- break in some fashion in the next version of ISC. */
- __setostype (0);
-#endif
-#endif
-
- (void) execve ((char *) zcmd, (char **) pazargs, pazenv);
-
- /* The exec failed. If permitted, try using /bin/sh to execute a
- shell script. */
- if (errno == ENOEXEC && fshell)
- {
- char *zto;
- const char *azshargs[4];
-
- pazargs[0] = zcmd;
- zto = zshcmd;
- for (i = 0; pazargs[i] != NULL; i++)
- {
- const char *zfrom;
-
- for (zfrom = pazargs[i]; *zfrom != '\0'; zfrom++)
- {
- /* Some versions of /bin/sh appear to have a bug such
- that quoting a '/' sometimes causes an error. I
- don't know exactly when this happens (I can recreate
- it on Ultrix 4.0), but in any case it is harmless to
- not quote a '/'. */
- if (*zfrom != '/')
- *zto++ = '\\';
- *zto++ = *zfrom;
- }
- *zto++ = ' ';
- }
- *(zto - 1) = '\0';
-
- azshargs[0] = "sh";
- azshargs[1] = "-c";
- azshargs[2] = zshcmd;
- azshargs[3] = NULL;
-
- (void) execve ((char *) "/bin/sh", (char **) azshargs, pazenv);
- }
-
- _exit (EXIT_FAILURE);
-
- /* Avoid compiler warning. */
- return -1;
-}
diff --git a/gnu/libexec/uucp/libunix/splcmd.c b/gnu/libexec/uucp/libunix/splcmd.c
deleted file mode 100644
index d085cee..0000000
--- a/gnu/libexec/uucp/libunix/splcmd.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* splcmd.c
- Spool a command.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-#include <ctype.h>
-
-/* Given a set of commands to execute for a remote system, create a
- command file holding them. This creates a single command file
- holding all the commands passed in. It returns a jobid. */
-
-char *
-zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds)
- const struct uuconf_system *qsys;
- int bgrade;
- int ccmds;
- const struct scmd *pascmds;
-{
- char abtempfile[sizeof "TMP1234567890"];
- char *ztemp;
- FILE *e;
- int i;
- const struct scmd *q;
- char *z;
- char *zjobid;
-
-#if DEBUG > 0
- if (! UUCONF_GRADE_LEGAL (bgrade))
- ulog (LOG_FATAL, "Bad grade %d", bgrade);
-#endif
-
- /* Write the commands into a temporary file and then rename it to
- avoid a race with uucico reading the file. */
- sprintf (abtempfile, "TMP%010lx", (unsigned long) getpid ());
- ztemp = zsfind_file (abtempfile, qsys->uuconf_zname, bgrade);
- if (ztemp == NULL)
- return NULL;
-
- e = esysdep_fopen (ztemp, FALSE, FALSE, TRUE);
- if (e == NULL)
- {
- ubuffree (ztemp);
- return NULL;
- }
-
- for (i = 0, q = pascmds; i < ccmds; i++, q++)
- {
- switch (q->bcmd)
- {
- case 'S':
- fprintf (e, "S %s %s %s -%s %s 0%o %s\n", q->zfrom, q->zto,
- q->zuser, q->zoptions, q->ztemp, q->imode,
- q->znotify == NULL ? (const char *) "" : q->znotify);
- break;
- case 'R':
- fprintf (e, "R %s %s %s -%s\n", q->zfrom, q->zto, q->zuser,
- q->zoptions);
- break;
- case 'X':
- fprintf (e, "X %s %s %s -%s\n", q->zfrom, q->zto, q->zuser,
- q->zoptions);
- break;
- case 'E':
- fprintf (e, "E %s %s %s -%s %s 0%o %s 0 %s\n", q->zfrom, q->zto,
- q->zuser, q->zoptions, q->ztemp, q->imode,
- q->znotify, q->zcmd);
- break;
- default:
- ulog (LOG_ERROR,
- "zsysdep_spool_commands: Unrecognized type %d",
- q->bcmd);
- (void) fclose (e);
- (void) remove (ztemp);
- ubuffree (ztemp);
- return NULL;
- }
- }
-
- if (! fstdiosync (e, ztemp))
- {
- (void) fclose (e);
- (void) remove (ztemp);
- ubuffree (ztemp);
- return NULL;
- }
-
- if (fclose (e) != 0)
- {
- ulog (LOG_ERROR, "fclose: %s", strerror (errno));
- (void) remove (ztemp);
- ubuffree (ztemp);
- return NULL;
- }
-
- /* The filename returned by zscmd_file is subject to some unlikely
- race conditions, so keep trying the link until the destination
- file does not already exist. Each call to zscmd_file should
- return a file name which does not already exist, so we don't have
- to do anything special before calling it again. */
- while (TRUE)
- {
- z = zscmd_file (qsys, bgrade);
- if (z == NULL)
- {
- (void) remove (ztemp);
- ubuffree (ztemp);
- return NULL;
- }
-
- if (link (ztemp, z) >= 0)
- break;
-
- if (errno != EEXIST)
- {
- ulog (LOG_ERROR, "link (%s, %s): %s", ztemp, z, strerror (errno));
- (void) remove (ztemp);
- ubuffree (ztemp);
- ubuffree (z);
- return NULL;
- }
-
- ubuffree (z);
- }
-
- (void) remove (ztemp);
- ubuffree (ztemp);
-
- zjobid = zsfile_to_jobid (qsys, z, bgrade);
- if (zjobid == NULL)
- (void) remove (z);
- ubuffree (z);
- return zjobid;
-}
diff --git a/gnu/libexec/uucp/libunix/splnam.c b/gnu/libexec/uucp/libunix/splnam.c
deleted file mode 100644
index 06ce360..0000000
--- a/gnu/libexec/uucp/libunix/splnam.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* splnam.c
- Get the full name of a file in the spool directory. */
-
-#include "uucp.h"
-
-#include "uuconf.h"
-#include "sysdep.h"
-#include "system.h"
-
-/* Get the real name of a spool file. */
-
-char *
-zsysdep_spool_file_name (qsys, zfile, pseq)
- const struct uuconf_system *qsys;
- const char *zfile;
- pointer pseq;
-{
- return zsfind_file (zfile, qsys->uuconf_zname, bsgrade (pseq));
-}
diff --git a/gnu/libexec/uucp/libunix/spool.c b/gnu/libexec/uucp/libunix/spool.c
deleted file mode 100644
index 9b0fa15..0000000
--- a/gnu/libexec/uucp/libunix/spool.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/* spool.c
- Find a file in the spool directory.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char spool_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-/* There are several types of files that go in the spool directory,
- and they go into various different subdirectories. Whenever the
- system name LOCAL appears below, it means whatever the local system
- name is.
-
- Command files
- These contain instructions for uucico indicating what files to transfer
- to and from what systems. Each line of a work file is a command
- beginning with S, R, X, or E.
- #if ! SPOOLDIR_TAYLOR
- They are named C.ssssssgqqqq, where ssssss is the system name to
- transfer to or from, g is the grade and qqqq is the sequence number.
- #if SPOOLDIR_V2
- They are put in the spool directory.
- #elif SPOOLDIR_BSD42 || SPOOLDIR_BSD43
- They are put in the directory "C.".
- #elif SPOOLDIR_HDB
- They are put in a directory named for the system for which they were
- created.
- #elif SPOOLDIR_ULTRIX
- If the directory sys/ssssss exists, they are put in the directory
- sys/ssssss/C; otherwise, they are put in the directory sys/DEFAULT/C.
- #elif SPOOLDIR_SVR4
- They are put in the directory sys/g, where sys is the system name
- and g is the grade.
- #endif
- #else SPOOLDIR_TAYLOR
- They are named C.gqqqq, where g is the grade and qqqq is the
- sequence number, and are placed in the directory ssssss/C. where
- ssssss is the system name to transfer to or from. The sequence
- number for a C. file is actually a long string; it is not based on
- the sequence number file, but is generated via a process which
- attempts to produce a unique string each time it is run.
- #endif
-
- Data files
- There are files to be transferred to other systems. Some files to
- be transferred may not be in the spool directory, depending on how
- uucp was invoked. Data files are named in work files, so it is
- never necessary to look at them directly (except to remove old ones);
- it is only necessary to create them. These means that the many
- variations in naming are inconsequential.
- #if ! SPOOLDIR_TAYLOR
- They are named D.ssssssgqqqq where ssssss is a system name (which
- may be LOCAL for locally initiated transfers or a remote system for
- remotely initiated transfers, except that HDB appears to use the
- system the file is being transferred to), g is the grade and qqqq
- is the sequence number. Some systems use a trailing subjob ID
- number, but we currently do not. The grade is not important, and
- some systems do not use it. If the data file is to become an
- execution file on another system the grade (if present) will be
- 'X'. Otherwise Ultrix appears to use 'b'; the uux included with
- gnuucp 1.0 appears to use 'S'; SCO does not appear to use a grade,
- although it does use a subjob ID number.
- #if SPOOLDIR_V2
- They are put in the spool directory.
- #elif SPOOLDIR_BSD42
- If the name begins with D.LOCAL, the file is put in the directory
- D.LOCAL. Otherwise the file is put in the directory D..
- #elif SPOOLDIR_BSD43
- If the name begins with D.LOCALX, the file is put in the directory
- D.LOCALX. Otherwise if the name begins with D.LOCAL, the file is
- put in the directory D.LOCAL Otherwise the file is put in the
- directory "D.".
- #elif SPOOLDIR_HDB
- They are put in a directory named for the system for which they
- were created.
- #elif SPOOLDIR_ULTRIX
- Say the file is being transferred to system REMOTE. If the
- directory sys/REMOTE exists, then if the file begins with D.LOCALX
- it is put in sys/REMOTE/D.LOCALX, if the file begins with D.LOCAL
- it is put in sys/REMOTE/D.LOCAL, and otherwise it is put in
- "sys/REMOTE/D.". If the directory sys/REMOTE does not exist, the
- same applies except that DEFAULT is used instead of REMOTE.
- #elif SPOOLDIR_SVR4
- They are put in the directory sys/g, where sys is the system name
- and g is the grade.
- #endif
- #else SPOOLDIR_TAYLOR
- If the file is to become an executable file on another system it is
- named D.Xqqqq, otherwise it is named D.qqqq where in both cases
- qqqq is a sequence number. If the corresponding C. file is in
- directory ssssss/C., a D.X file is placed in ssssss/D.X and a D.
- file is placed in "ssssss/D.".
- #endif
-
- Execute files
- These are files that specify programs to be executed. They are
- created by uux, perhaps as run on another system. These names are
- important, because a file transfer done to an execute file name
- causes an execution to occur. The name is X.ssssssgqqqq, where
- ssssss is the requesting system, g is the grade, and qqqq is a
- sequence number.
- #if SPOOLDIR_V2 || SPOOLDIR_BSD42
- These files are placed in the spool directory.
- #elif SPOOLDIR_BSD43
- These files are placed in the directory X..
- #elif SPOOLDIR_HDB || SPOOLDIR_SVR4
- These files are put in a directory named for the system for which
- the files were created.
- #elif SPOOLDIR_ULTRIX
- If there is a spool directory (sys/ssssss) for the requesting
- system, the files are placed in sys/ssssss/X.; otherwise, the files
- are placed in "sys/DEFAULT/X.".
- #elif SPOOLDIR_TAYLOR
- The system name is automatically truncated to seven characters when
- a file is created. The files are placed in the subdirectory X. of
- a directory named for the system for which the files were created.
- #endif
-
- Temporary receive files
- These are used when receiving files from another system. They are
- later renamed to the final name. The actual name is unimportant,
- although it generally begins with TM..
- #if SPOOLDIR_V2 || SPOOLDIR_BSD42
- These files are placed in the spool directory.
- #elif SPOOLDIR_BSD43 || SPOOLDIR_ULTRIX || SPOOLDIR_TAYLOR
- These files are placed in the directory .Temp.
- #elif SPOOLDIR_HDB || SPOOLDIR_SVR4
- These files are placed in a directory named for the system for
- which they were created.
- #endif
-
- System status files
- These are used to record when the last call was made to the system
- and what the status is. They are used to prevent frequent recalls
- to a system which is not responding. I will not attempt to
- recreate the format of these exactly, since they are not all that
- important. They will be put in the directory .Status, as in HDB,
- and they use the system name as the name of the file.
-
- Sequence file
- This is used to generate a unique sequence number. It contains an
- ASCII number.
- #if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43
- The file is named SEQF and is kept in the spool directory.
- #elif SPOOLDIR_HDB || SPOOLDIR_SVR4
- A separate sequence file is kept for each system in the directory
- .Sequence with the name of the system.
- #elif SPOOLDIR_ULTRIX
- Each system with a file sys/ssssss has a sequence file in
- sys/ssssss/.SEQF. Other systems use sys/DEFAULT/.SEQF.
- #else SPOOLDIR_TAYLOR
- A sequence file named SEQF is kept in the directory ssssss for each
- system.
- #endif
- */
-
-/* Given the name of a file as specified in a UUCP command, and the
- system for which this file has been created, return where to find
- it in the spool directory. The file will begin with C. (a command
- file), D. (a data file) or X. (an execution file). Under
- SPOOLDIR_SVR4 we need to know the grade of the file created by the
- local system; this is the bgrade argument, which is -1 for a file
- from a remote system. */
-
-/*ARGSUSED*/
-char *
-zsfind_file (zsimple, zsystem, bgrade)
- const char *zsimple;
- const char *zsystem;
- int bgrade;
-{
- /* zsysdep_spool_commands calls this with TMPXXX which we must treat
- as a C. file. */
- if ((zsimple[0] != 'T'
- || zsimple[1] != 'M'
- || zsimple[2] != 'P')
- && ! fspool_file (zsimple))
- {
- ulog (LOG_ERROR, "Unrecognized file name %s", zsimple);
- return NULL;
- }
-
-#if ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 && ! SPOOLDIR_TAYLOR
- if (*zsimple == 'X')
- {
- static char *zbuf;
- static size_t cbuf;
- size_t clen, cwant;
-
- /* Files beginning with X. are execute files. It is important
- for security reasons that we know the system which created
- the X. file. This is easy under SPOOLDIR_HDB or
- SPOOLDIR_SVR4 SPOOLDIR_TAYLOR, because the file will be in a
- directory named for the system. Under other schemes, we must
- get the system name from the X. file name. To prevent
- security violations, we set the system name directly here;
- this will cause problems if the maximum file name length is
- too short, but hopefully no problem will occur since any
- System V systems will be using HDB or SVR4 or TAYLOR. */
- clen = strlen (zsimple);
- if (clen < 5)
- {
- ulog (LOG_ERROR, "Bad file name (too short) %s", zsimple);
- return NULL;
- }
- cwant = strlen (zsystem) + 8;
- if (cwant > cbuf)
- {
- zbuf = (char *) xrealloc ((pointer) zbuf, cwant);
- cbuf = cwant;
- }
- sprintf (zbuf, "X.%s%s", zsystem, zsimple + clen - 5);
- zsimple = zbuf;
- }
-#endif /* ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 && ! SPOOLDIR_TAYLOR */
-
-#if SPOOLDIR_V2
- /* V2 never uses subdirectories. */
- return zbufcpy (zsimple);
-#endif /* SPOOLDIR_V2 */
-
-#if SPOOLDIR_HDB
- /* HDB always uses the system name as a directory. */
- return zsysdep_in_dir (zsystem, zsimple);
-#endif /* SPOOLDIR_HDB */
-
-#if SPOOLDIR_SVR4
- /* SVR4 uses grade directories within the system directory for local
- command and data files. */
- if (bgrade < 0 || *zsimple == 'X')
- return zsysdep_in_dir (zsystem, zsimple);
- else
- {
- char abgrade[2];
-
- abgrade[0] = bgrade;
- abgrade[1] = '\0';
- return zsappend3 (zsystem, abgrade, zsimple);
- }
-#endif /* SPOOLDIR_SVR4 */
-
-#if ! SPOOLDIR_V2 && ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4
- switch (*zsimple)
- {
- case 'C':
- case 'T':
-#if SPOOLDIR_BSD42 || SPOOLDIR_BSD43
- return zsysdep_in_dir ("C.", zsimple);
-#endif /* SPOOLDIR_BSD42 || SPOOLDIR_BSD43 */
-#if SPOOLDIR_ULTRIX
- if (fsultrix_has_spool (zsystem))
- return zsappend4 ("sys", zsystem, "C.", zsimple);
- else
- return zsappend4 ("sys", "DEFAULT", "C.", zsimple);
-#endif /* SPOOLDIR_ULTRIX */
-#if SPOOLDIR_TAYLOR
- return zsappend3 (zsystem, "C.", zsimple);
-#endif /* SPOOLDIR_TAYLOR */
-
- case 'D':
-#if SPOOLDIR_BSD42 || SPOOLDIR_BSD43
- {
- size_t c;
- boolean ftruncated;
-
- /* D.LOCAL in D.LOCAL/, others in D./. If BSD43, D.LOCALX in
- D.LOCALX/. */
- ftruncated = TRUE;
- if (strncmp (zsimple + 2, zSlocalname, strlen (zSlocalname)) == 0)
- {
- c = strlen (zSlocalname);
- ftruncated = FALSE;
- }
- else if (strncmp (zsimple + 2, zSlocalname, 7) == 0)
- c = 7;
- else if (strncmp (zsimple + 2, zSlocalname, 6) == 0)
- c = 6;
- else
- c = 0;
-#if SPOOLDIR_BSD43
- if (c > 0 && zsimple[c + 2] == 'X')
- c++;
-#endif /* SPOOLDIR_BSD43 */
- if (c > 0)
- {
- char *zalloc;
-
- zalloc = zbufalc (c + 3);
- memcpy (zalloc, zsimple, c + 2);
- zalloc[c + 2] = '\0';
-
- /* If we truncated the system name, and there is no existing
- directory with the truncated name, then just use D.. */
- if (! ftruncated || fsysdep_directory (zalloc))
- {
- char *zret;
-
- zret = zsysdep_in_dir (zalloc, zsimple);
- ubuffree (zalloc);
- return zret;
- }
- ubuffree (zalloc);
- }
- return zsysdep_in_dir ("D.", zsimple);
- }
-#endif /* SPOOLDIR_BSD42 || SPOOLDIR_BSD43 */
-#if SPOOLDIR_ULTRIX
- {
- size_t c;
- boolean ftruncated;
- char *zfree;
- const char *zdir;
- char *zret;
-
- /* D.LOCALX in D.LOCALX/, D.LOCAL in D.LOCAL/, others in D./. */
- ftruncated = TRUE;
- if (strncmp (zsimple + 2, zSlocalname, strlen (zSlocalname)) == 0)
- {
- c = strlen (zSlocalname);
- ftruncated = FALSE;
- }
- else if (strncmp (zsimple + 2, zSlocalname, 7) == 0)
- c = 7;
- else if (strncmp (zsimple + 2, zSlocalname, 6) == 0)
- c = 6;
- else
- c = 0;
- if (c > 0 && zsimple[c + 2] == 'X')
- ++c;
- if (c > 0)
- {
- zfree = zbufalc (c + 3);
- memcpy (zfree, zsimple, c + 2);
- zfree[c + 2] = '\0';
- zdir = zfree;
-
- /* If we truncated the name, and there is no directory for
- the truncated name, then don't use it. */
- if (ftruncated)
- {
- char *zlook;
-
- zlook = zsappend3 ("sys",
- (fsultrix_has_spool (zsystem)
- ? zsystem
- : "DEFAULT"),
- zdir);
- if (! fsysdep_directory (zlook))
- zdir = "D.";
- ubuffree (zlook);
- }
- }
- else
- {
- zfree = NULL;
- zdir = "D.";
- }
-
- zret = zsappend4 ("sys",
- (fsultrix_has_spool (zsystem)
- ? zsystem
- : "DEFAULT"),
- zdir,
- zsimple);
- ubuffree (zfree);
- return zret;
- }
-#endif /* SPOOLDIR_ULTRIX */
-#if SPOOLDIR_TAYLOR
- if (zsimple[2] == 'X')
- return zsappend3 (zsystem, "D.X", zsimple);
- else
- return zsappend3 (zsystem, "D.", zsimple);
-#endif /* SPOOLDIR_TAYLOR */
-
-
- case 'X':
-#if SPOOLDIR_BSD42
- return zbufcpy (zsimple);
-#endif
-#if SPOOLDIR_BSD43
- return zsysdep_in_dir ("X.", zsimple);
-#endif
-#if SPOOLDIR_ULTRIX
- return zsappend4 ("sys",
- (fsultrix_has_spool (zsystem)
- ? zsystem
- : "DEFAULT"),
- "X.",
- zsimple);
-#endif
-#if SPOOLDIR_TAYLOR
- return zsappend3 (zsystem, "X.", zsimple);
-#endif
- }
-
- /* This is just to avoid warnings; it will never be executed. */
- return NULL;
-#endif /* ! SPOOLDIR_V2 && ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 */
-}
diff --git a/gnu/libexec/uucp/libunix/srmdir.c b/gnu/libexec/uucp/libunix/srmdir.c
deleted file mode 100644
index e143cdf..0000000
--- a/gnu/libexec/uucp/libunix/srmdir.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* srmdir.c
- Remove a directory and all its contents.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_FTW_H
-#include <ftw.h>
-#endif
-
-static int isremove_dir P((const char *, struct stat *, int));
-
-/* Keep a list of directories to be removed. */
-
-struct sdirlist
-{
- struct sdirlist *qnext;
- char *zdir;
-};
-
-static struct sdirlist *qSdirlist;
-
-/* Remove a directory and all files in it. */
-
-boolean
-fsysdep_rmdir (zdir)
- const char *zdir;
-{
- boolean fret;
- struct sdirlist *q;
-
- qSdirlist = NULL;
-
- fret = TRUE;
- if (ftw ((char *) zdir, isremove_dir, 5) != 0)
- {
- ulog (LOG_ERROR, "ftw: %s", strerror (errno));
- fret = FALSE;
- }
-
- q = qSdirlist;
- while (q != NULL)
- {
- struct sdirlist *qnext;
-
- if (rmdir (q->zdir) != 0)
- {
- ulog (LOG_ERROR, "rmdir (%s): %s", q->zdir, strerror (errno));
- fret = FALSE;
- }
- ubuffree (q->zdir);
- qnext = q->qnext;
- xfree ((pointer) q);
- q = qnext;
- }
-
- return fret;
-}
-
-/* Remove a file in a directory. */
-
-/*ARGSUSED*/
-static int
-isremove_dir (zfile, qstat, iflag)
- const char *zfile;
- struct stat *qstat;
- int iflag;
-{
- if (iflag == FTW_D || iflag == FTW_DNR)
- {
- struct sdirlist *q;
-
- q = (struct sdirlist *) xmalloc (sizeof (struct sdirlist));
- q->qnext = qSdirlist;
- q->zdir = zbufcpy (zfile);
- qSdirlist = q;
- }
- else
- {
- if (remove (zfile) != 0)
- ulog (LOG_ERROR, "remove (%s): %s", zfile, strerror (errno));
- }
-
- return 0;
-}
diff --git a/gnu/libexec/uucp/libunix/statsb.c b/gnu/libexec/uucp/libunix/statsb.c
deleted file mode 100644
index 877f686..0000000
--- a/gnu/libexec/uucp/libunix/statsb.c
+++ /dev/null
@@ -1,634 +0,0 @@
-/* statsb.c
- System dependent routines for uustat.
-
- Copyright (C) 1992, 1993, 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char statsb_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-
-#if HAVE_OPENDIR
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#else /* ! HAVE_DIRENT_H */
-#include <sys/dir.h>
-#define dirent direct
-#endif /* ! HAVE_DIRENT_H */
-#endif /* HAVE_OPENDIR */
-
-#if HAVE_TIME_H
-#include <time.h>
-#endif
-
-#if HAVE_UTIME_H
-#include <utime.h>
-#endif
-
-/* Local functions. */
-
-static int issettime P((const char *z, time_t inow));
-static boolean fskill_or_rejuv P((pointer puuconf, const char *zid,
- boolean fkill));
-
-/* Set file access time to the present. On many systems this could be
- done by passing NULL to utime, but on some that doesn't work. This
- routine is not time critical, so we never rely on NULL. */
-
-static int
-issettime(z, inow)
- const char *z;
- time_t inow;
-{
-#if HAVE_UTIME_H
- struct utimbuf s;
-
- s.actime = inow;
- s.modtime = inow;
- return utime ((char *) z, &s);
-#else
- time_t ai[2];
-
- ai[0] = inow;
- ai[1] = inow;
- return utime ((char *) z, ai);
-#endif
-}
-
-/* Kill a job, given the jobid. */
-
-boolean
-fsysdep_kill_job (puuconf, zid)
- pointer puuconf;
- const char *zid;
-{
- return fskill_or_rejuv (puuconf, zid, TRUE);
-}
-
-/* Rejuvenate a job, given the jobid. */
-
-boolean
-fsysdep_rejuvenate_job (puuconf, zid)
- pointer puuconf;
- const char *zid;
-{
- return fskill_or_rejuv (puuconf, zid, FALSE);
-}
-
-/* Kill or rejuvenate a job, given the jobid. */
-
-static boolean
-fskill_or_rejuv (puuconf, zid, fkill)
- pointer puuconf;
- const char *zid;
- boolean fkill;
-{
- char *zfile;
- char *zsys;
- char bgrade;
- time_t inow = 0;
- int iuuconf;
- struct uuconf_system ssys;
- FILE *e;
- boolean fret;
- char *zline;
- size_t cline;
- int isys;
-
- zfile = zsjobid_to_file (zid, &zsys, &bgrade);
- if (zfile == NULL)
- return FALSE;
-
- if (! fkill)
- inow = time ((time_t *) NULL);
-
- iuuconf = uuconf_system_info (puuconf, zsys, &ssys);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- if (! funknown_system (puuconf, zsys, &ssys))
- {
- ulog (LOG_ERROR, "%s: Bad job id", zid);
- ubuffree (zfile);
- ubuffree (zsys);
- return FALSE;
- }
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- ubuffree (zfile);
- ubuffree (zsys);
- return FALSE;
- }
-
- e = fopen (zfile, "r");
- if (e == NULL)
- {
- if (errno == ENOENT)
- ulog (LOG_ERROR, "%s: Job not found", zid);
- else
- ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno));
- (void) uuconf_system_free (puuconf, &ssys);
- ubuffree (zfile);
- ubuffree (zsys);
- return FALSE;
- }
-
- /* Now we have to read through the file to identify any temporary
- files. */
- fret = TRUE;
- zline = NULL;
- cline = 0;
- while (getline (&zline, &cline, e) > 0)
- {
- struct scmd s;
-
- if (! fparse_cmd (zline, &s))
- {
- ulog (LOG_ERROR, "Bad line in command file %s", zfile);
- fret = FALSE;
- continue;
- }
-
- /* You are only permitted to delete a job if you submitted it or
- if you are root or uucp. */
- if (strcmp (s.zuser, zsysdep_login_name ()) != 0
- && ! fsysdep_privileged ())
- {
- ulog (LOG_ERROR, "%s: Not submitted by you", zid);
- xfree ((pointer) zline);
- (void) fclose (e);
- (void) uuconf_system_free (puuconf, &ssys);
- ubuffree (zfile);
- ubuffree (zsys);
- return FALSE;
- }
-
- if (s.bcmd == 'S' || s.bcmd == 'E')
- {
- char *ztemp;
-
- ztemp = zsfind_file (s.ztemp, ssys.uuconf_zname, bgrade);
- if (ztemp == NULL)
- fret = FALSE;
- else
- {
- if (fkill)
- isys = remove (ztemp);
- else
- isys = issettime (ztemp, inow);
-
- if (isys != 0 && errno != ENOENT)
- {
- ulog (LOG_ERROR, "%s (%s): %s",
- fkill ? "remove" : "utime", ztemp,
- strerror (errno));
- fret = FALSE;
- }
-
- ubuffree (ztemp);
- }
- }
- }
-
- xfree ((pointer) zline);
- (void) fclose (e);
- (void) uuconf_system_free (puuconf, &ssys);
- ubuffree (zsys);
-
- if (fkill)
- isys = remove (zfile);
- else
- isys = issettime (zfile, inow);
-
- if (isys != 0 && errno != ENOENT)
- {
- ulog (LOG_ERROR, "%s (%s): %s", fkill ? "remove" : "utime",
- zfile, strerror (errno));
- fret = FALSE;
- }
-
- ubuffree (zfile);
-
- return fret;
-}
-
-/* Get the time a work job was queued. */
-
-long
-ixsysdep_work_time (qsys, pseq)
- const struct uuconf_system *qsys;
- pointer pseq;
-{
- char *zjobid, *zfile;
- long iret;
-
- zjobid = zsysdep_jobid (qsys, pseq);
- zfile = zsjobid_to_file (zjobid, (char **) NULL, (char *) NULL);
- if (zfile == NULL)
- return 0;
- ubuffree (zjobid);
- iret = ixsysdep_file_time (zfile);
- ubuffree (zfile);
- return iret;
-}
-
-/* Get the time a file was created (actually, the time it was last
- modified). */
-
-long
-ixsysdep_file_time (zfile)
- const char *zfile;
-{
- struct stat s;
-
- if (stat ((char *) zfile, &s) < 0)
- {
- if (errno != ENOENT)
- ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno));
- return ixsysdep_time ((long *) NULL);
- }
-
- return (long) s.st_mtime;
-}
-
-/* Set the time of a file to the current time. */
-
-boolean
-fsysdep_touch_file (zfile)
- const char *zfile;
-{
- if (issettime (zfile, time ((time_t *) NULL)) != 0)
- {
- ulog (LOG_ERROR, "utime (%s): %s", zfile, strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Start getting the status files. */
-
-boolean
-fsysdep_all_status_init (phold)
- pointer *phold;
-{
- DIR *qdir;
-
- qdir = opendir ((char *) ".Status");
- if (qdir == NULL)
- {
- ulog (LOG_ERROR, "opendir (.Status): %s", strerror (errno));
- return FALSE;
- }
-
- *phold = (pointer) qdir;
- return TRUE;
-}
-
-/* Get the next status file. */
-
-char *
-zsysdep_all_status (phold, pferr, qstat)
- pointer phold;
- boolean *pferr;
- struct sstatus *qstat;
-{
- DIR *qdir = (DIR *) phold;
- struct dirent *qentry;
-
- while (TRUE)
- {
- errno = 0;
- qentry = readdir (qdir);
- if (qentry == NULL)
- {
- if (errno == 0)
- *pferr = FALSE;
- else
- {
- ulog (LOG_ERROR, "readdir: %s", strerror (errno));
- *pferr = TRUE;
- }
- return NULL;
- }
-
- if (qentry->d_name[0] != '.')
- {
- struct uuconf_system ssys;
-
- /* Hack seriously; fsysdep_get_status only looks at the
- zname element of the qsys argument, so if we fake that we
- can read the status file. This should really be done
- differently. */
- ssys.uuconf_zname = qentry->d_name;
- if (fsysdep_get_status (&ssys, qstat, (boolean *) NULL))
- return zbufcpy (qentry->d_name);
-
- /* If fsysdep_get_status fails, it will output an error
- message. We just continue with the next entry, so that
- most of the status files will be displayed. */
- }
- }
-}
-
-/* Finish getting the status file. */
-
-void
-usysdep_all_status_free (phold)
- pointer phold;
-{
- DIR *qdir = (DIR *) phold;
-
- (void) closedir (qdir);
-}
-
-/* Get the status of all processes holding lock files. We do this by
- invoking ps after we've figured out the process entries to use. */
-
-boolean
-fsysdep_lock_status ()
-{
- DIR *qdir;
- struct dirent *qentry;
- int calc;
- pid_t *pai;
-#if HAVE_QNX_LOCKFILES
- nid_t *painid;
-#endif
- int cgot;
- int aidescs[3];
- char *zcopy, *ztok;
- int cargs, iarg;
- char **pazargs;
-
- qdir = opendir ((char *) zSlockdir);
- if (qdir == NULL)
- {
- ulog (LOG_ERROR, "opendir (%s): %s", zSlockdir, strerror (errno));
- return FALSE;
- }
-
- /* We look for entries that start with "LCK.." and ignore everything
- else. This won't find all possible lock files, but it should
- find all the locks on terminals and systems. */
-
- calc = 0;
- pai = NULL;
- cgot = 0;
-#if HAVE_QNX_LOCKFILES
- painid = NULL;
-#endif
- while ((qentry = readdir (qdir)) != NULL)
- {
- char *zname;
- int o;
-#if HAVE_QNX_LOCKFILES
- nid_t inid;
- char ab[23];
- char *zend;
-#else
-#if HAVE_V2_LOCKFILES
- int i;
-#else
- char ab[12];
-#endif
-#endif
- int cread;
- int ierr;
- pid_t ipid;
- int icheck;
-
- if (strncmp (qentry->d_name, "LCK..", sizeof "LCK.." - 1) != 0)
- continue;
-
- zname = zsysdep_in_dir (zSlockdir, qentry->d_name);
- o = open ((char *) zname, O_RDONLY | O_NOCTTY, 0);
- if (o < 0)
- {
- if (errno != ENOENT)
- ulog (LOG_ERROR, "open (%s): %s", zname, strerror (errno));
- ubuffree (zname);
- continue;
- }
-
-#if HAVE_V2_LOCKFILES
- cread = read (o, &i, sizeof i);
-#else
- cread = read (o, ab, sizeof ab - 1);
-#endif
-
- ierr = errno;
- (void) close (o);
-
- if (cread < 0)
- {
- ulog (LOG_ERROR, "read %s: %s", zname, strerror (ierr));
- ubuffree (zname);
- continue;
- }
-
- ubuffree (zname);
-
-#if HAVE_QNX_LOCKFILES
- ab[cread] = '\0';
- ipid = (pid_t) strtol (ab, &zend, 10);
- inid = (nid_t) strtol (zend, (char **) NULL, 10);
-#else
-#if HAVE_V2_LOCKFILES
- ipid = (pid_t) i;
-#else
- ab[cread] = '\0';
- ipid = (pid_t) strtol (ab, (char **) NULL, 10);
-#endif
-#endif
-
-#if HAVE_QNX_LOCKFILES
- printf ("%s: %ld %ld\n", qentry->d_name, (long) inid, (long) ipid);
-#else
- printf ("%s: %ld\n", qentry->d_name, (long) ipid);
-#endif
-
- for (icheck = 0; icheck < cgot; icheck++)
- if (pai[icheck] == ipid)
- break;
- if (icheck < cgot)
- continue;
-
- if (cgot >= calc)
- {
- calc += 10;
- pai = (pid_t *) xrealloc ((pointer) pai, calc * sizeof (pid_t));
-#if HAVE_QNX_LOCKFILES
- painid = (nid_t *) xrealloc ((pointer) painid,
- calc * sizeof (nid_t));
-#endif
- }
-
- pai[cgot] = ipid;
-#if HAVE_QNX_LOCKFILES
- painid[cgot] = inid;
-#endif
- ++cgot;
- }
-
- if (cgot == 0)
- return TRUE;
-
- aidescs[0] = SPAWN_NULL;
- aidescs[1] = 1;
- aidescs[2] = 2;
-
- /* Parse PS_PROGRAM into an array of arguments. */
- zcopy = zbufcpy (PS_PROGRAM);
-
- cargs = 0;
- for (ztok = strtok (zcopy, " \t");
- ztok != NULL;
- ztok = strtok ((char *) NULL, " \t"))
- ++cargs;
-
- pazargs = (char **) xmalloc ((cargs + 1) * sizeof (char *));
-
- memcpy (zcopy, PS_PROGRAM, sizeof PS_PROGRAM);
- for (ztok = strtok (zcopy, " \t"), iarg = 0;
- ztok != NULL;
- ztok = strtok ((char *) NULL, " \t"), ++iarg)
- pazargs[iarg] = ztok;
- pazargs[iarg] = NULL;
-
-#if ! HAVE_PS_MULTIPLE
- /* We have to invoke ps multiple times. */
- {
- int i;
- char *zlast, *zset;
-#if HAVE_QNX_LOCKFILES
- char *zpenultimate, *zsetnid;
-#endif /* HAVE_QNX_LOCKFILES */
-
- zlast = pazargs[cargs - 1];
- zset = zbufalc (strlen (zlast) + 20);
-
-#if HAVE_QNX_LOCKFILES
- /* We assume in this case that PS_PROGRAM ends with " -n -p".
- Thus, the last argument is "-p" and the second-to-last
- (penultimate) argument is "-n". We modify them to read "-n###"
- and "-p###" where "###" is the node ID and the process ID,
- respectively. This seems like quite a roundabout way of doing
- things. Why don't we just leave the " -n -p" part out of
- PS_PROGRAM and construct the "-n###" and "-p###" arguments here
- from scratch? Because that would not fit as well with how the
- code works for the other systems and would require larger
- changes. */
- zpenultimate = pazargs[cargs - 2];
- zsetnid = zbufalc (strlen (zpenultimate) + 20);
-#endif
-
- for (i = 0; i < cgot; i++)
- {
- pid_t ipid;
-
- sprintf (zset, "%s%ld", zlast, (long) pai[i]);
- pazargs[cargs - 1] = zset;
-
-#if HAVE_QNX_LOCKFILES
- sprintf (zsetnid, "%s%ld", zpenultimate, (long) painid[i]);
- pazargs[cargs - 2] = zsetnid;
-#endif
-
- ipid = ixsspawn ((const char **) pazargs, aidescs, FALSE, FALSE,
- (const char *) NULL, FALSE, TRUE,
- (const char *) NULL, (const char *) NULL,
- (const char *) NULL);
- if (ipid < 0)
- ulog (LOG_ERROR, "ixsspawn: %s", strerror (errno));
- else
- (void) ixswait ((unsigned long) ipid, PS_PROGRAM);
- }
- ubuffree (zset);
-#if HAVE_QNX_LOCKFILES
- ubuffree (zsetnid);
-#endif
- }
-#else
- {
- char *zlast;
- int i;
- pid_t ipid;
-
- zlast = zbufalc (strlen (pazargs[cargs - 1]) + cgot * 20 + 1);
- strcpy (zlast, pazargs[cargs - 1]);
- for (i = 0; i < cgot; i++)
- {
- char ab[20];
-
- sprintf (ab, "%ld", (long) pai[i]);
- strcat (zlast, ab);
- if (i + 1 < cgot)
- strcat (zlast, ",");
- }
- pazargs[cargs - 1] = zlast;
-
- ipid = ixsspawn ((const char **) pazargs, aidescs, FALSE, FALSE,
- (const char *) NULL, FALSE, TRUE,
- (const char *) NULL, (const char *) NULL,
- (const char *) NULL);
- if (ipid < 0)
- ulog (LOG_ERROR, "ixsspawn: %s", strerror (errno));
- else
- (void) ixswait ((unsigned long) ipid, PS_PROGRAM);
- ubuffree (zlast);
- }
-#endif
-
- ubuffree (zcopy);
- xfree ((pointer) pazargs);
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/status.c b/gnu/libexec/uucp/libunix/status.c
deleted file mode 100644
index 66e1d385..0000000
--- a/gnu/libexec/uucp/libunix/status.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/* status.c
- Routines to get and set the status for a system.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-#include <ctype.h>
-
-#if SPOOLDIR_HDB || SPOOLDIR_SVR4
-
-/* If we are using HDB spool layout, store status using HDB status
- values. SVR4 is a variant of HDB. */
-
-#define MAP_STATUS 1
-
-static const int aiMapstatus[] =
-{
- 0, 13, 7, 6, 20, 4, 3, 2
-};
-#define CMAPENTRIES (sizeof (aiMapstatus) / sizeof (aiMapstatus[0]))
-
-#else /* ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 */
-
-#define MAP_STATUS 0
-
-#endif /* ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 */
-
-/* Get the status of a system. This assumes that we are in the spool
- directory. */
-
-boolean
-fsysdep_get_status (qsys, qret, pfnone)
- const struct uuconf_system *qsys;
- struct sstatus *qret;
- boolean *pfnone;
-{
- char *zname;
- FILE *e;
- char *zline;
- char *zend, *znext;
- boolean fbad;
- int istat;
-
- if (pfnone != NULL)
- *pfnone = FALSE;
-
- zname = zsysdep_in_dir (".Status", qsys->uuconf_zname);
- e = fopen (zname, "r");
- if (e == NULL)
- {
- if (errno != ENOENT)
- {
- ulog (LOG_ERROR, "fopen (%s): %s", zname, strerror (errno));
- ubuffree (zname);
- return FALSE;
- }
- zline = NULL;
- }
- else
- {
- size_t cline;
-
- zline = NULL;
- cline = 0;
- if (getline (&zline, &cline, e) <= 0)
- {
- xfree ((pointer) zline);
- zline = NULL;
- }
- (void) fclose (e);
- }
-
- if (zline == NULL)
- {
- /* There is either no status file for this system, or it's been
- truncated, so fake a good status. */
- qret->ttype = STATUS_COMPLETE;
- qret->cretries = 0;
- qret->ilast = 0;
- qret->cwait = 0;
- qret->zstring = NULL;
- if (pfnone != NULL)
- *pfnone = TRUE;
- ubuffree (zname);
- return TRUE;
- }
-
- /* It turns out that scanf is not used much in this program, so for
- the benefit of small computers we avoid linking it in. This is
- basically
-
- sscanf (zline, "%d %d %ld %d", &qret->ttype, &qret->cretries,
- &qret->ilast, &qret->cwait);
-
- except that it's done with strtol. */
-
- fbad = FALSE;
- istat = (int) strtol (zline, &zend, 10);
- if (zend == zline)
- fbad = TRUE;
-
-#if MAP_STATUS
- /* On some systems it may be appropriate to map system dependent status
- values on to our status values. */
- {
- int i;
-
- for (i = 0; i < CMAPENTRIES; ++i)
- {
- if (aiMapstatus[i] == istat)
- {
- istat = i;
- break;
- }
- }
- }
-#endif /* MAP_STATUS */
-
- if (istat < 0 || istat >= (int) STATUS_VALUES)
- istat = (int) STATUS_COMPLETE;
- qret->ttype = (enum tstatus_type) istat;
- znext = zend;
- qret->cretries = (int) strtol (znext, &zend, 10);
- if (zend == znext)
- fbad = TRUE;
- znext = zend;
- qret->ilast = strtol (znext, &zend, 10);
- if (zend == znext)
- fbad = TRUE;
- znext = zend;
- qret->cwait = (int) strtol (znext, &zend, 10);
- if (zend == znext)
- fbad = TRUE;
-
- if (! fbad)
- {
- znext = zend;
- while (isspace (BUCHAR (*znext)))
- ++znext;
- if (*znext == '\0')
- qret->zstring = NULL;
- else
- {
- if (*znext == '"')
- ++znext;
- qret->zstring = zbufcpy (znext);
- zend = qret->zstring + strlen (qret->zstring);
- while (zend != qret->zstring && *zend != ' ')
- --zend;
- if (*zend == '"' && zend != qret->zstring)
- --zend;
- if (zend != qret->zstring)
- *zend = '\0';
- else
- {
- ubuffree (qret->zstring);
- qret->zstring = NULL;
- }
- }
- }
-
- xfree ((pointer) zline);
-
- if (fbad)
- {
- ulog (LOG_ERROR, "%s: Bad status file format", zname);
- ubuffree (zname);
- return FALSE;
- }
-
- ubuffree (zname);
-
- return TRUE;
-}
-
-/* Set the status of a remote system. This assumes the system is
- locked when this is called, and that the program is in the spool
- directory. */
-
-boolean
-fsysdep_set_status (qsys, qset)
- const struct uuconf_system *qsys;
- const struct sstatus *qset;
-{
- char *zname;
- FILE *e;
- int istat;
-
- zname = zsysdep_in_dir (".Status", qsys->uuconf_zname);
-
- e = esysdep_fopen (zname, TRUE, FALSE, TRUE);
- ubuffree (zname);
- if (e == NULL)
- return FALSE;
- istat = (int) qset->ttype;
-
-#if MAP_STATUS
- /* On some systems it may be appropriate to map istat onto a system
- dependent number. */
- if (istat >= 0 && istat < CMAPENTRIES)
- istat = aiMapstatus[istat];
-#endif /* MAP_STATUS */
-
- fprintf (e, "%d %d %ld %d ", istat, qset->cretries, qset->ilast,
- qset->cwait);
-
-#if SPOOLDIR_SVR4
- fprintf (e, "\"%s\"", azStatus[(int) qset->ttype]);
-#else
- fprintf (e, "%s", azStatus[(int) qset->ttype]);
-#endif
-
- fprintf (e, " %s\n", qsys->uuconf_zname);
- if (fclose (e) != 0)
- {
- ulog (LOG_ERROR, "fclose: %s", strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/strerr.c b/gnu/libexec/uucp/libunix/strerr.c
deleted file mode 100644
index 8e7480f..0000000
--- a/gnu/libexec/uucp/libunix/strerr.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* strerr.c
- Return a string for a Unix errno value. */
-
-#include "uucp.h"
-
-#include <errno.h>
-
-#ifndef sys_nerr
-extern int sys_nerr;
-#endif
-#ifndef sys_errlist
-extern char *sys_errlist[];
-#endif
-
-#undef strerror
-
-char *
-strerror (ierr)
- int ierr;
-{
- if (ierr >= 0 && ierr < sys_nerr)
- return sys_errlist[ierr];
- return (char *) "unknown error";
-}
diff --git a/gnu/libexec/uucp/libunix/sync.c b/gnu/libexec/uucp/libunix/sync.c
deleted file mode 100644
index c346c58..0000000
--- a/gnu/libexec/uucp/libunix/sync.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* sync.c
- Sync a file to disk, if FSYNC_ON_CLOSE is set. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-boolean
-fsysdep_sync (e, zmsg)
- openfile_t e;
- const char *zmsg;
-{
- int o;
-
-#if USE_STDIO
- if (fflush (e) == EOF)
- {
- ulog (LOG_ERROR, "%s: fflush: %s", zmsg, strerror (errno));
- return FALSE;
- }
-#endif
-
-#if USE_STDIO
- o = fileno (e);
-#else
- o = e;
-#endif
-
-#if FSYNC_ON_CLOSE
- if (fsync (o) < 0)
- {
- ulog (LOG_ERROR, "%s: fsync: %s", zmsg, strerror (errno));
- return FALSE;
- }
-#endif
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/tcp.c b/gnu/libexec/uucp/libunix/tcp.c
deleted file mode 100644
index 428aaa1..0000000
--- a/gnu/libexec/uucp/libunix/tcp.c
+++ /dev/null
@@ -1,444 +0,0 @@
-/* tcp.c
- Code to handle TCP connections.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char tcp_rcsid[] = "$Id$";
-#endif
-
-#if HAVE_TCP
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "sysdep.h"
-#include "conn.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_SYS_TYPES_TCP_H
-#include <sys/types.tcp.h>
-#endif
-#include <sys/socket.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-/* This code handles TCP connections. It assumes a Berkeley socket
- interface. */
-
-/* The normal "uucp" port number. */
-#define IUUCP_PORT (540)
-
-/* Local functions. */
-static void utcp_free P((struct sconnection *qconn));
-static boolean ftcp_open P((struct sconnection *qconn, long ibaud,
- boolean fwait));
-static boolean ftcp_close P((struct sconnection *qconn,
- pointer puuconf,
- struct uuconf_dialer *qdialer,
- boolean fsuccess));
-static boolean ftcp_dial P((struct sconnection *qconn, pointer puuconf,
- const struct uuconf_system *qsys,
- const char *zphone,
- struct uuconf_dialer *qdialer,
- enum tdialerfound *ptdialer));
-static int itcp_port_number P((const char *zport));
-
-/* The command table for a TCP connection. */
-static const struct sconncmds stcpcmds =
-{
- utcp_free,
- NULL, /* pflock */
- NULL, /* pfunlock */
- ftcp_open,
- ftcp_close,
- ftcp_dial,
- fsysdep_conn_read,
- fsysdep_conn_write,
- fsysdep_conn_io,
- NULL, /* pfbreak */
- NULL, /* pfset */
- NULL, /* pfcarrier */
- fsysdep_conn_chat,
- NULL /* pibaud */
-};
-
-/* Initialize a TCP connection. */
-
-boolean
-fsysdep_tcp_init (qconn)
- struct sconnection *qconn;
-{
- struct ssysdep_conn *q;
-
- q = (struct ssysdep_conn *) xmalloc (sizeof (struct ssysdep_conn));
- q->o = -1;
- q->ord = -1;
- q->owr = -1;
- q->zdevice = NULL;
- q->iflags = -1;
- q->iwr_flags = -1;
- q->fterminal = FALSE;
- q->ftli = FALSE;
- q->ibaud = 0;
-
- qconn->psysdep = (pointer) q;
- qconn->qcmds = &stcpcmds;
- return TRUE;
-}
-
-/* Free a TCP connection. */
-
-static void
-utcp_free (qconn)
- struct sconnection *qconn;
-{
- xfree (qconn->psysdep);
-}
-
-/* Open a TCP connection. If the fwait argument is TRUE, we are
- running as a server. Otherwise we are just trying to reach another
- system. */
-
-static boolean
-ftcp_open (qconn, ibaud, fwait)
- struct sconnection *qconn;
- long ibaud;
- boolean fwait;
-{
- struct ssysdep_conn *qsysdep;
- struct sockaddr_in s;
- const char *zport;
- uid_t ieuid;
- boolean fswap;
-
- ulog_device ("TCP");
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
-
- qsysdep->o = socket (AF_INET, SOCK_STREAM, 0);
- if (qsysdep->o < 0)
- {
- ulog (LOG_ERROR, "socket: %s", strerror (errno));
- return FALSE;
- }
-
- if (fcntl (qsysdep->o, F_SETFD,
- fcntl (qsysdep->o, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- (void) close (qsysdep->o);
- qsysdep->o = -1;
- return FALSE;
- }
-
- qsysdep->iflags = fcntl (qsysdep->o, F_GETFL, 0);
- if (qsysdep->iflags < 0)
- {
- ulog (LOG_ERROR, "fcntl: %s", strerror (errno));
- (void) close (qsysdep->o);
- qsysdep->o = -1;
- return FALSE;
- }
-
- /* We save our process ID in the qconn structure. This is checked
- in ftcp_close. */
- qsysdep->ipid = getpid ();
-
- /* If we aren't waiting for a connection, we're done. */
- if (! fwait)
- return TRUE;
-
- /* Run as a server and wait for a new connection. The code in
- uucico.c has already detached us from our controlling terminal.
- From this point on if the server gets an error we exit; we only
- return if we have received a connection. It would be more robust
- to respawn the server if it fails; someday. */
- bzero ((pointer) &s, sizeof s);
- s.sin_family = AF_INET;
- zport = qconn->qport->uuconf_u.uuconf_stcp.uuconf_zport;
- s.sin_port = itcp_port_number (zport);
- s.sin_addr.s_addr = htonl (INADDR_ANY);
-
- /* Swap to our real user ID when doing the bind call. This will
- permit the server to use privileged TCP ports when invoked by
- root. We only swap if our effective user ID is not root, so that
- the program can also be made suid root in order to get privileged
- ports when invoked by anybody. */
- fswap = geteuid () != 0;
- if (fswap)
- {
- if (! fsuser_perms (&ieuid))
- {
- (void) close (qsysdep->o);
- qsysdep->o = -1;
- return FALSE;
- }
- }
-
- if (bind (qsysdep->o, (struct sockaddr *) &s, sizeof s) < 0)
- {
- if (fswap)
- (void) fsuucp_perms ((long) ieuid);
- ulog (LOG_FATAL, "bind: %s", strerror (errno));
- }
-
- /* Now swap back to the uucp user ID. */
- if (fswap)
- {
- if (! fsuucp_perms ((long) ieuid))
- ulog (LOG_FATAL, "Could not swap back to UUCP user permissions");
- }
-
- if (listen (qsysdep->o, 5) < 0)
- ulog (LOG_FATAL, "listen: %s", strerror (errno));
-
- while (! FGOT_SIGNAL ())
- {
- size_t clen;
- int onew;
- pid_t ipid;
-
- DEBUG_MESSAGE0 (DEBUG_PORT,
- "ftcp_open: Waiting for connections");
-
- clen = sizeof s;
- onew = accept (qsysdep->o, (struct sockaddr *) &s, &clen);
- if (onew < 0)
- ulog (LOG_FATAL, "accept: %s", strerror (errno));
-
- DEBUG_MESSAGE0 (DEBUG_PORT,
- "ftcp_open: Got connection; forking");
-
- ipid = ixsfork ();
- if (ipid < 0)
- ulog (LOG_FATAL, "fork: %s", strerror (errno));
- if (ipid == 0)
- {
- (void) close (qsysdep->o);
- qsysdep->o = onew;
-
- /* Now we fork and let our parent die, so that we become
- a child of init. This lets the main server code wait
- for its child and then continue without accumulating
- zombie children. */
- ipid = ixsfork ();
- if (ipid < 0)
- {
- ulog (LOG_ERROR, "fork: %s", strerror (errno));
- _exit (EXIT_FAILURE);
- }
-
- if (ipid != 0)
- _exit (EXIT_SUCCESS);
-
- ulog_id (getpid ());
-
- return TRUE;
- }
-
- (void) close (onew);
-
- /* Now wait for the child. */
- (void) ixswait ((unsigned long) ipid, (const char *) NULL);
- }
-
- /* We got a signal. */
- usysdep_exit (FALSE);
-
- /* Avoid compiler warnings. */
- return FALSE;
-}
-
-/* Close the port. */
-
-/*ARGSUSED*/
-static boolean
-ftcp_close (qconn, puuconf, qdialer, fsuccess)
- struct sconnection *qconn;
- pointer puuconf;
- struct uuconf_dialer *qdialer;
- boolean fsuccess;
-{
- struct ssysdep_conn *qsysdep;
- boolean fret;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- fret = TRUE;
- if (qsysdep->o >= 0 && close (qsysdep->o) < 0)
- {
- ulog (LOG_ERROR, "close: %s", strerror (errno));
- fret = FALSE;
- }
- qsysdep->o = -1;
-
- /* If the current pid is not the one we used to open the port, then
- we must have forked up above and we are now the child. In this
- case, we are being called from within the fendless loop in
- uucico.c. We return FALSE to force the loop to end and the child
- to exit. This should be handled in a cleaner fashion. */
- if (qsysdep->ipid != getpid ())
- fret = FALSE;
-
- return fret;
-}
-
-/* Dial out on a TCP port, so to speak: connect to a remote computer. */
-
-/*ARGSUSED*/
-static boolean
-ftcp_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialer)
- struct sconnection *qconn;
- pointer puuconf;
- const struct uuconf_system *qsys;
- const char *zphone;
- struct uuconf_dialer *qdialer;
- enum tdialerfound *ptdialer;
-{
- struct ssysdep_conn *qsysdep;
- const char *zhost;
- struct hostent *q;
- struct sockaddr_in s;
- const char *zport;
- char **pzdialer;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
-
- *ptdialer = DIALERFOUND_FALSE;
-
- zhost = zphone;
- if (zhost == NULL)
- {
- if (qsys == NULL)
- {
- ulog (LOG_ERROR, "No address for TCP connection");
- return FALSE;
- }
- zhost = qsys->uuconf_zname;
- }
-
- errno = 0;
- q = gethostbyname ((char *) zhost);
- if (q != NULL)
- {
- s.sin_family = q->h_addrtype;
- memcpy (&s.sin_addr.s_addr, q->h_addr, (size_t) q->h_length);
- }
- else
- {
- if (errno != 0)
- {
- ulog (LOG_ERROR, "gethostbyname (%s): %s", zhost, strerror (errno));
- return FALSE;
- }
-
- s.sin_family = AF_INET;
- s.sin_addr.s_addr = inet_addr ((char *) zhost);
- if ((long) s.sin_addr.s_addr == (long) -1)
- {
- ulog (LOG_ERROR, "%s: unknown host name", zhost);
- return FALSE;
- }
- }
-
- zport = qconn->qport->uuconf_u.uuconf_stcp.uuconf_zport;
- s.sin_port = itcp_port_number (zport);
-
- if (connect (qsysdep->o, (struct sockaddr *) &s, sizeof s) < 0)
- {
- ulog (LOG_ERROR, "connect: %s", strerror (errno));
- return FALSE;
- }
-
- /* Handle the dialer sequence, if any. */
- pzdialer = qconn->qport->uuconf_u.uuconf_stcp.uuconf_pzdialer;
- if (pzdialer != NULL && *pzdialer != NULL)
- {
- if (! fconn_dial_sequence (qconn, puuconf, pzdialer, qsys, zphone,
- qdialer, ptdialer))
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Get the port number given a name. The argument will almost always
- be "uucp" so we cache that value. The return value is always in
- network byte order. This returns -1 on error. */
-
-static int
-itcp_port_number (zname)
- const char *zname;
-{
- boolean fuucp;
- static int iuucp;
- int i;
- char *zend;
- struct servent *q;
-
- fuucp = strcmp (zname, "uucp") == 0;
- if (fuucp && iuucp != 0)
- return iuucp;
-
- /* Try it as a number first. */
- i = strtol ((char *) zname, &zend, 10);
- if (i != 0 && *zend == '\0')
- return htons (i);
-
- q = getservbyname ((char *) zname, (char *) "tcp");
- if (q == NULL)
- {
- /* We know that the "uucp" service should be 540, even if isn't
- in /etc/services. */
- if (fuucp)
- {
- iuucp = htons (IUUCP_PORT);
- return iuucp;
- }
- ulog (LOG_ERROR, "getservbyname (%s): %s", zname, strerror (errno));
- return -1;
- }
-
- if (fuucp)
- iuucp = q->s_port;
-
- return q->s_port;
-}
-
-#endif /* HAVE_TCP */
diff --git a/gnu/libexec/uucp/libunix/time.c b/gnu/libexec/uucp/libunix/time.c
deleted file mode 100644
index d046243..0000000
--- a/gnu/libexec/uucp/libunix/time.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* time.c
- Get the current time. */
-
-#include "uucp.h"
-
-#if HAVE_TIME_H
-#include <time.h>
-#endif
-
-#include "system.h"
-
-#ifndef time
-extern time_t time ();
-#endif
-
-/* Get the time in seconds since the epoch, with optional
- microseconds. We use ixsysdep_process_time to get the microseconds
- if it will work (it won't if it uses times, since that returns a
- time based only on the process). */
-
-long
-ixsysdep_time (pimicros)
- long *pimicros;
-{
-#if HAVE_GETTIMEOFDAY || HAVE_FTIME
- return ixsysdep_process_time (pimicros);
-#else
- if (pimicros != NULL)
- *pimicros = 0;
- return (long) time ((time_t *) NULL);
-#endif
-}
diff --git a/gnu/libexec/uucp/libunix/tli.c b/gnu/libexec/uucp/libunix/tli.c
deleted file mode 100644
index 43e02e7..0000000
--- a/gnu/libexec/uucp/libunix/tli.c
+++ /dev/null
@@ -1,628 +0,0 @@
-/* tli.c
- Code to handle TLI connections.
-
- Copyright (C) 1992, 1993, 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char tli_rcsid[] = "$Id$";
-#endif
-
-#if HAVE_TLI
-
-#include "sysdep.h"
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-#if HAVE_TIUSER_H
-#include <tiuser.h>
-#else
-#if HAVE_XTI_H
-#include <xti.h>
-#else
-#if HAVE_SYS_TLI_H
-#include <sys/tli.h>
-#endif
-#endif
-#endif
-
-#if HAVE_STROPTS_H
-#include <stropts.h>
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-/* The arguments to t_alloca have two different names. I want the
- SVID ones, not the XPG3 ones. */
-#ifndef T_BIND
-#define T_BIND T_BIND_STR
-#endif
-#ifndef T_CALL
-#define T_CALL T_CALL_STR
-#endif
-
-/* Hopefully these externs will not cause any trouble. This is how
- they are shown in the SVID. */
-extern int t_errno;
-extern char *t_errlist[];
-extern int t_nerr;
-
-#ifndef HAVE_TIUSER_H
-#ifndef t_alloc
-extern pointer t_alloc ();
-#endif
-#endif
-
-/* This code handles TLI connections. It's Unix specific. It's
- largely based on code from Unix Network Programming, by W. Richard
- Stevens. */
-
-/* Local functions. */
-static const char *ztlierror P((void));
-static void utli_free P((struct sconnection *qconn));
-static boolean ftli_push P((struct sconnection *qconn));
-static boolean ftli_open P((struct sconnection *qconn, long ibaud,
- boolean fwait));
-static boolean ftli_close P((struct sconnection *qconn,
- pointer puuconf,
- struct uuconf_dialer *qdialer,
- boolean fsuccess));
-static boolean ftli_dial P((struct sconnection *qconn, pointer puuconf,
- const struct uuconf_system *qsys,
- const char *zphone,
- struct uuconf_dialer *qdialer,
- enum tdialerfound *ptdialer));
-
-/* The command table for a TLI connection. */
-static const struct sconncmds stlicmds =
-{
- utli_free,
- NULL, /* pflock */
- NULL, /* pfunlock */
- ftli_open,
- ftli_close,
- ftli_dial,
- fsysdep_conn_read,
- fsysdep_conn_write,
- fsysdep_conn_io,
- NULL, /* pfbreak */
- NULL, /* pfset */
- NULL, /* pfcarrier */
- fsysdep_conn_chat,
- NULL /* pibaud */
-};
-
-/* Get a TLI error string. */
-
-static const char *
-ztlierror ()
-{
- if (t_errno == TSYSERR)
- return strerror (errno);
- if (t_errno < 0 || t_errno >= t_nerr)
- return "Unknown TLI error";
- return t_errlist[t_errno];
-}
-
-/* Initialize a TLI connection. This may be called with qconn->qport
- NULL, when opening standard input as a TLI connection. */
-
-boolean
-fsysdep_tli_init (qconn)
- struct sconnection *qconn;
-{
- struct ssysdep_conn *q;
-
- q = (struct ssysdep_conn *) xmalloc (sizeof (struct ssysdep_conn));
- q->o = -1;
- q->ord = -1;
- q->owr = -1;
- q->zdevice = NULL;
- q->iflags = -1;
- q->iwr_flags = -1;
- q->fterminal = FALSE;
- q->ftli = TRUE;
- q->ibaud = 0;
-
- qconn->psysdep = (pointer) q;
- qconn->qcmds = &stlicmds;
- return TRUE;
-}
-
-/* Free a TLI connection. */
-
-static void
-utli_free (qconn)
- struct sconnection *qconn;
-{
- xfree (qconn->psysdep);
-}
-
-/* Push all desired modules onto a TLI stream. If the user requests a
- STREAMS connection without giving a list of modules, we just push
- tirdwr. If the I_PUSH ioctl is not defined on this system, we just
- ignore any list of modules. */
-
-static boolean
-ftli_push (qconn)
- struct sconnection *qconn;
-{
-#ifdef I_PUSH
-
- struct ssysdep_conn *qsysdep;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
-
- if (qconn->qport->uuconf_u.uuconf_stli.uuconf_pzpush != NULL)
- {
- char **pz;
-
- for (pz = qconn->qport->uuconf_u.uuconf_stli.uuconf_pzpush;
- *pz != NULL;
- pz++)
- {
- if (ioctl (qsysdep->o, I_PUSH, *pz) < 0)
- {
- ulog (LOG_ERROR, "ioctl (I_PUSH, %s): %s", *pz,
- strerror (errno));
- return FALSE;
- }
- }
- }
- else if (qconn->qport->uuconf_u.uuconf_stli.uuconf_fstream)
- {
- if (ioctl (qsysdep->o, I_PUSH, "tirdwr") < 0)
- {
- ulog (LOG_ERROR, "ioctl (I_PUSH, tirdwr): %s",
- strerror (errno));
- return FALSE;
- }
- }
-
- /* If we have just put the connection into stream mode, we must turn
- off the TLI flag to avoid using TLI calls on it. */
- if (qconn->qport->uuconf_u.uuconf_stli.uuconf_fstream)
- qsysdep->ftli = FALSE;
-
-#endif /* defined (I_PUSH) */
-
- return TRUE;
-}
-
-/* Open a TLI connection. If the fwait argument is TRUE, we are
- running as a server. Otherwise we are just trying to reach another
- system. */
-
-static boolean
-ftli_open (qconn, ibaud, fwait)
- struct sconnection *qconn;
- long ibaud;
- boolean fwait;
-{
- struct ssysdep_conn *qsysdep;
- const char *zdevice;
- char *zfreedev;
- const char *zservaddr;
- char *zfreeaddr;
- uid_t ieuid;
- boolean fswap;
- struct t_bind *qtbind;
- struct t_call *qtcall;
-
- /* Unlike most other device types, we don't bother to call
- ulog_device here, because fconn_open calls it with the name of
- the port anyhow. */
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
-
- zdevice = qconn->qport->uuconf_u.uuconf_stli.uuconf_zdevice;
- if (zdevice == NULL)
- zdevice = qconn->qport->uuconf_zname;
-
- zfreedev = NULL;
- if (*zdevice != '/')
- {
- zfreedev = zbufalc (sizeof "/dev/" + strlen (zdevice));
- sprintf (zfreedev, "/dev/%s", zdevice);
- zdevice = zfreedev;
- }
-
- /* If we are acting as a server, swap to our real user ID before
- calling t_open. This will permit the server to use privileged
- TCP ports when invoked by root. We only swap if our effective
- user ID is not root, so that the program can also be made suid
- root in order to get privileged ports when invoked by anybody. */
- fswap = fwait && geteuid () != 0;
- if (fswap)
- {
- if (! fsuser_perms (&ieuid))
- {
- ubuffree (zfreedev);
- return FALSE;
- }
- }
-
- qsysdep->o = t_open (zdevice, O_RDWR, (struct t_info *) NULL);
- if (qsysdep->o < 0)
- {
- if (fswap)
- (void) fsuucp_perms ((long) ieuid);
- ulog (LOG_ERROR, "t_open (%s): %s", zdevice, ztlierror ());
- ubuffree (zfreedev);
- return FALSE;
- }
-
- if (fcntl (qsysdep->o, F_SETFD,
- fcntl (qsysdep->o, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- if (fswap)
- (void) fsuucp_perms ((long) ieuid);
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- ubuffree (zfreedev);
- (void) t_close (qsysdep->o);
- qsysdep->o = -1;
- return FALSE;
- }
-
- qsysdep->iflags = fcntl (qsysdep->o, F_GETFL, 0);
- if (qsysdep->iflags < 0)
- {
- if (fswap)
- (void) fsuucp_perms ((long) ieuid);
- ulog (LOG_ERROR, "fcntl: %s", strerror (errno));
- ubuffree (zfreedev);
- (void) t_close (qsysdep->o);
- qsysdep->o = -1;
- return FALSE;
- }
-
- /* We save our process ID in the qconn structure. This is checked
- in ftli_close. */
- qsysdep->ipid = getpid ();
-
- /* If we aren't waiting for a connection, we can bind to any local
- address, and then we're finished. */
- if (! fwait)
- {
- /* fswap is known to be FALSE here. */
- ubuffree (zfreedev);
- if (t_bind (qsysdep->o, (struct t_bind *) NULL,
- (struct t_bind *) NULL) < 0)
- {
- ulog (LOG_ERROR, "t_bind: %s", ztlierror ());
- (void) t_close (qsysdep->o);
- qsysdep->o = -1;
- return FALSE;
- }
- return TRUE;
- }
-
- /* Run as a server and wait for a new connection. The code in
- uucico.c has already detached us from our controlling terminal.
- From this point on if the server gets an error we exit; we only
- return if we have received a connection. It would be more robust
- to respawn the server if it fails; someday. */
- qtbind = (struct t_bind *) t_alloc (qsysdep->o, T_BIND, T_ALL);
- if (qtbind == NULL)
- {
- if (fswap)
- (void) fsuucp_perms ((long) ieuid);
- ulog (LOG_FATAL, "t_alloc (T_BIND): %s", ztlierror ());
- }
-
- zservaddr = qconn->qport->uuconf_u.uuconf_stli.uuconf_zservaddr;
- if (zservaddr == NULL)
- {
- if (fswap)
- (void) fsuucp_perms ((long) ieuid);
- ulog (LOG_FATAL, "Can't run as TLI server; no server address");
- }
-
- zfreeaddr = zbufcpy (zservaddr);
- qtbind->addr.len = cescape (zfreeaddr);
- if (qtbind->addr.len > qtbind->addr.maxlen)
- {
- if (fswap)
- (void) fsuucp_perms ((long) ieuid);
- ulog (LOG_FATAL, "%s: TLI server address too long (max %d)",
- zservaddr, qtbind->addr.maxlen);
- }
- memcpy (qtbind->addr.buf, zfreeaddr, qtbind->addr.len);
- ubuffree (zfreeaddr);
-
- qtbind->qlen = 5;
-
- if (t_bind (qsysdep->o, qtbind, (struct t_bind *) NULL) < 0)
- {
- if (fswap)
- (void) fsuucp_perms ((long) ieuid);
- ulog (LOG_FATAL, "t_bind (%s): %s", zservaddr, ztlierror ());
- }
-
- if (fswap)
- {
- if (! fsuucp_perms ((long) ieuid))
- ulog (LOG_FATAL, "Could not swap back to UUCP user permissions");
- }
-
- (void) t_free ((pointer) qtbind, T_BIND);
-
- qtcall = (struct t_call *) t_alloc (qsysdep->o, T_CALL, T_ALL);
- if (qtcall == NULL)
- ulog (LOG_FATAL, "t_alloc (T_CALL): %s", ztlierror ());
-
- while (! FGOT_SIGNAL ())
- {
- int onew;
- pid_t ipid;
-
- DEBUG_MESSAGE0 (DEBUG_PORT,
- "ftli_open: Waiting for connections");
-
- if (t_listen (qsysdep->o, qtcall) < 0)
- ulog (LOG_FATAL, "t_listen: %s", ztlierror ());
-
- onew = t_open (zdevice, O_RDWR, (struct t_info *) NULL);
- if (onew < 0)
- ulog (LOG_FATAL, "t_open (%s): %s", zdevice, ztlierror ());
-
- if (fcntl (onew, F_SETFD,
- fcntl (onew, F_GETFD, 0) | FD_CLOEXEC) < 0)
- ulog (LOG_FATAL, "fcntl (FD_CLOEXEC): %s", strerror (errno));
-
- if (t_bind (onew, (struct t_bind *) NULL, (struct t_bind *) NULL) < 0)
- ulog (LOG_FATAL, "t_bind: %s", ztlierror ());
-
- if (t_accept (qsysdep->o, onew, qtcall) < 0)
- {
- /* We may have received a disconnect. */
- if (t_errno != TLOOK)
- ulog (LOG_FATAL, "t_accept: %s", ztlierror ());
- if (t_rcvdis (qsysdep->o, (struct t_discon *) NULL) < 0)
- ulog (LOG_FATAL, "t_rcvdis: %s", ztlierror ());
- (void) t_close (onew);
- continue;
- }
-
- DEBUG_MESSAGE0 (DEBUG_PORT,
- "ftli_open: Got connection; forking");
-
- ipid = ixsfork ();
- if (ipid < 0)
- ulog (LOG_FATAL, "fork: %s", strerror (errno));
- if (ipid == 0)
- {
- ulog_close ();
-
- (void) t_close (qsysdep->o);
- qsysdep->o = onew;
-
- /* Push any desired modules. */
- if (! ftli_push (qconn))
- _exit (EXIT_FAILURE);
-
- /* Now we fork and let our parent die, so that we become
- a child of init. This lets the main server code wait
- for its child and then continue without accumulating
- zombie children. */
- ipid = ixsfork ();
- if (ipid < 0)
- {
- ulog (LOG_ERROR, "fork: %s", strerror (errno));
- _exit (EXIT_FAILURE);
- }
-
- if (ipid != 0)
- _exit (EXIT_SUCCESS);
-
- ulog_id (getpid ());
-
- return TRUE;
- }
-
- (void) t_close (onew);
-
- /* Now wait for the child. */
- (void) ixswait ((unsigned long) ipid, (const char *) NULL);
- }
-
- /* We got a signal. */
- usysdep_exit (FALSE);
-
- /* Avoid compiler warnings. */
- return FALSE;
-}
-
-/* Close the port. */
-
-/*ARGSUSED*/
-static boolean
-ftli_close (qconn, puuconf, qdialer, fsuccess)
- struct sconnection *qconn;
- pointer puuconf;
- struct uuconf_dialer *qdialer;
- boolean fsuccess;
-{
- struct ssysdep_conn *qsysdep;
- boolean fret;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
-
- fret = TRUE;
- if (qsysdep->o >= 0)
- {
- if (qsysdep->ftli)
- {
- if (t_close (qsysdep->o) < 0)
- {
- ulog (LOG_ERROR, "t_close: %s", ztlierror ());
- fret = FALSE;
- }
- }
- else
- {
- if (close (qsysdep->o) < 0)
- {
- ulog (LOG_ERROR, "close: %s", strerror (errno));
- fret = FALSE;
- }
- }
-
- qsysdep->o = -1;
- }
-
- /* If the current pid is not the one we used to open the port, then
- we must have forked up above and we are now the child. In this
- case, we are being called from within the fendless loop in
- uucico.c. We return FALSE to force the loop to end and the child
- to exit. This should be handled in a cleaner fashion. */
- if (qsysdep->ipid != getpid ())
- fret = FALSE;
-
- return fret;
-}
-
-/* Dial out on a TLI port, so to speak: connect to a remote computer. */
-
-/*ARGSUSED*/
-static boolean
-ftli_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialerfound)
- struct sconnection *qconn;
- pointer puuconf;
- const struct uuconf_system *qsys;
- const char *zphone;
- struct uuconf_dialer *qdialer;
- enum tdialerfound *ptdialerfound;
-{
- struct ssysdep_conn *qsysdep;
- char **pzdialer;
- const char *zaddr;
- struct t_call *qtcall;
- char *zescape;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
-
- *ptdialerfound = DIALERFOUND_FALSE;
-
- pzdialer = qconn->qport->uuconf_u.uuconf_stli.uuconf_pzdialer;
- if (*pzdialer == NULL)
- pzdialer = NULL;
-
- /* If the first dialer is "TLI" or "TLIS", we use the first token
- (pzdialer[1]) as the address to connect to. */
- zaddr = zphone;
- if (pzdialer != NULL
- && (strcmp (pzdialer[0], "TLI") == 0
- || strcmp (pzdialer[0], "TLIS") == 0))
- {
- if (pzdialer[1] == NULL)
- ++pzdialer;
- else
- {
- if (strcmp (pzdialer[1], "\\D") != 0
- && strcmp (pzdialer[1], "\\T") != 0)
- zaddr = pzdialer[1];
- pzdialer += 2;
- }
- }
-
- if (zaddr == NULL)
- {
- ulog (LOG_ERROR, "No address for TLI connection");
- return FALSE;
- }
-
- qtcall = (struct t_call *) t_alloc (qsysdep->o, T_CALL, T_ADDR);
- if (qtcall == NULL)
- {
- ulog (LOG_ERROR, "t_alloc (T_CALL): %s", ztlierror ());
- return FALSE;
- }
-
- zescape = zbufcpy (zaddr);
- qtcall->addr.len = cescape (zescape);
- if (qtcall->addr.len > qtcall->addr.maxlen)
- {
- ulog (LOG_ERROR, "%s: TLI address too long (max %d)", zaddr,
- qtcall->addr.maxlen);
- ubuffree (zescape);
- return FALSE;
- }
- memcpy (qtcall->addr.buf, zescape, qtcall->addr.len);
- ubuffree (zescape);
-
- if (t_connect (qsysdep->o, qtcall, (struct t_call *) NULL) < 0)
- {
- if (t_errno != TLOOK)
- ulog (LOG_ERROR, "t_connect: %s", ztlierror ());
- else
- {
- if (t_rcvdis (qsysdep->o, (struct t_discon *) NULL) < 0)
- ulog (LOG_ERROR, "t_rcvdis: %s", ztlierror ());
- else
- ulog (LOG_ERROR, "Connection refused");
- }
- return FALSE;
- }
-
- /* We've connected to the remote. Push any desired modules. */
- if (! ftli_push (qconn))
- return FALSE;
-
- /* Handle the rest of the dialer sequence. */
- if (pzdialer != NULL && *pzdialer != NULL)
- {
- if (! fconn_dial_sequence (qconn, puuconf, pzdialer, qsys, zphone,
- qdialer, ptdialerfound))
- return FALSE;
- }
-
- return TRUE;
-}
-
-#endif /* HAVE_TLI */
diff --git a/gnu/libexec/uucp/libunix/tmpfil.c b/gnu/libexec/uucp/libunix/tmpfil.c
deleted file mode 100644
index f2f5ba8..0000000
--- a/gnu/libexec/uucp/libunix/tmpfil.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* tmpfil.c
- Get a temporary file name.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "sysdep.h"
-
-#define ZDIGS \
- "0123456789abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"
-#define CDIGS (sizeof ZDIGS - 1)
-
-/*ARGSUSED*/
-char *
-zstemp_file (qsys)
- const struct uuconf_system *qsys;
-{
- static int icount;
- const char *const zdigs = ZDIGS;
- char ab[14];
- pid_t ime;
- int iset;
-
- ab[0] = 'T';
- ab[1] = 'M';
- ab[2] = '.';
-
- ime = getpid ();
- iset = 3;
- while (ime > 0 && iset < 10)
- {
- ab[iset] = zdigs[ime % CDIGS];
- ime /= CDIGS;
- ++iset;
- }
-
- ab[iset] = '.';
- ++iset;
-
- ab[iset] = zdigs[icount / CDIGS];
- ++iset;
- ab[iset] = zdigs[icount % CDIGS];
- ++iset;
-
- ab[iset] = '\0';
-
- ++icount;
- if (icount >= CDIGS * CDIGS)
- icount = 0;
-
-#if SPOOLDIR_V2 || SPOOLDIR_BSD42
- return zbufcpy (ab);
-#endif
-#if SPOOLDIR_BSD43 || SPOOLDIR_ULTRIX || SPOOLDIR_TAYLOR
- return zsysdep_in_dir (".Temp", ab);
-#endif
-#if SPOOLDIR_HDB || SPOOLDIR_SVR4
- return zsysdep_in_dir (qsys->uuconf_zname, ab);
-#endif
-}
diff --git a/gnu/libexec/uucp/libunix/trunc.c b/gnu/libexec/uucp/libunix/trunc.c
deleted file mode 100644
index c93e82e..0000000
--- a/gnu/libexec/uucp/libunix/trunc.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/* trunc.c
- Truncate a file to zero length. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-/* External functions. */
-#ifndef lseek
-extern off_t lseek ();
-#endif
-
-/* Truncate a file to zero length. If this fails, it closes and
- removes the file. We support a number of different means of
- truncation, which is probably a waste of time since this function
- is currently only called when the 'f' protocol resends a file. */
-
-#if HAVE_FTRUNCATE
-#undef HAVE_LTRUNC
-#define HAVE_LTRUNC 0
-#endif
-
-#if ! HAVE_FTRUNCATE && ! HAVE_LTRUNC
-#ifdef F_CHSIZE
-#define HAVE_F_CHSIZE 1
-#else /* ! defined (F_CHSIZE) */
-#ifdef F_FREESP
-#define HAVE_F_FREESP 1
-#endif /* defined (F_FREESP) */
-#endif /* ! defined (F_CHSIZE) */
-#endif /* ! HAVE_FTRUNCATE && ! HAVE_LTRUNC */
-
-openfile_t
-esysdep_truncate (e, zname)
- openfile_t e;
- const char *zname;
-{
- int o;
-
-#if HAVE_FTRUNCATE || HAVE_LTRUNC || HAVE_F_CHSIZE || HAVE_F_FREESP
- int itrunc;
-
- if (! ffilerewind (e))
- {
- ulog (LOG_ERROR, "rewind: %s", strerror (errno));
- (void) ffileclose (e);
- (void) remove (zname);
- return EFILECLOSED;
- }
-
-#if USE_STDIO
- o = fileno (e);
-#else
- o = e;
-#endif
-
-#if HAVE_FTRUNCATE
- itrunc = ftruncate (o, 0);
-#endif
-#if HAVE_LTRUNC
- itrunc = ltrunc (o, (long) 0, SEEK_SET);
-#endif
-#if HAVE_F_CHSIZE
- itrunc = fcntl (o, F_CHSIZE, (off_t) 0);
-#endif
-#if HAVE_F_FREESP
- /* This selection is based on an implementation of ftruncate by
- kucharsk@Solbourne.com (William Kucharski). */
- {
- struct flock fl;
-
- fl.l_whence = 0;
- fl.l_len = 0;
- fl.l_start = 0;
- fl.l_type = F_WRLCK;
-
- itrunc = fcntl (o, F_FREESP, &fl);
- }
-#endif
-
- if (itrunc != 0)
- {
-#if HAVE_FTRUNCATE
- ulog (LOG_ERROR, "ftruncate: %s", strerror (errno));
-#endif
-#ifdef HAVE_LTRUNC
- ulog (LOG_ERROR, "ltrunc: %s", strerror (errno));
-#endif
-#ifdef HAVE_F_CHSIZE
- ulog (LOG_ERROR, "fcntl (F_CHSIZE): %s", strerror (errno));
-#endif
-#ifdef HAVE_F_FREESP
- ulog (LOG_ERROR, "fcntl (F_FREESP): %s", strerror (errno));
-#endif
-
- (void) ffileclose (e);
- (void) remove (zname);
- return EFILECLOSED;
- }
-
- return e;
-#else /* ! (HAVE_FTRUNCATE || HAVE_LTRUNC || HAVE_F_CHSIZE || HAVE_F_FREESP) */
- (void) ffileclose (e);
- (void) remove (zname);
-
- o = creat ((char *) zname, IPRIVATE_FILE_MODE);
-
- if (o == -1)
- {
- ulog (LOG_ERROR, "creat (%s): %s", zname, strerror (errno));
- return EFILECLOSED;
- }
-
- if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- (void) close (o);
- return EFILECLOSED;
- }
-
-#if USE_STDIO
- e = fdopen (o, (char *) BINWRITE);
-
- if (e == NULL)
- {
- ulog (LOG_ERROR, "fdopen (%s): %s", zname, strerror (errno));
- (void) close (o);
- (void) remove (zname);
- return NULL;
- }
-#else /* ! USE_STDIO */
- e = o;
-#endif /* ! USE_STDIO */
-
- return e;
-#endif /* ! (HAVE_FTRUNCATE || HAVE_LTRUNC || HAVE_F_CHSIZE || HAVE_F_FREESP) */
-}
diff --git a/gnu/libexec/uucp/libunix/uacces.c b/gnu/libexec/uucp/libunix/uacces.c
deleted file mode 100644
index 8f37a8e..0000000
--- a/gnu/libexec/uucp/libunix/uacces.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* uacces.c
- Check access to a file by user name.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-
-#include <pwd.h>
-#include <errno.h>
-
-#if HAVE_GETGRENT
-#include <grp.h>
-#if GETGRENT_DECLARATION_OK
-#ifndef getgrent
-extern struct group *getgrent ();
-#endif
-#endif
-#endif /* HAVE_GETGRENT */
-
-#if GETPWNAM_DECLARATION_OK
-#ifndef getpwnam
-extern struct passwd *getpwnam ();
-#endif
-#endif
-
-/* Do access(2) on a stat structure, except that the user name is
- provided. If the user name in zuser is NULL, require the file to
- be accessible to the world. Return TRUE if access is permitted,
- FALSE otherwise. This does not log an error message. */
-
-boolean
-fsuser_access (q, imode, zuser)
- const struct stat *q;
- int imode;
- const char *zuser;
-{
- static char *zuser_hold;
- static uid_t iuid_hold;
- static gid_t igid_hold;
- static int cgroups_hold;
- static gid_t *paigroups_hold;
- int ir, iw, ix, iand;
-
- if (imode == F_OK)
- return TRUE;
-
- if (zuser != NULL)
- {
- /* We keep static variables around for the last user we did, to
- avoid looking up a user multiple times. */
- if (zuser_hold == NULL || strcmp (zuser_hold, zuser) != 0)
- {
- struct passwd *qpwd;
-
- if (zuser_hold != NULL)
- {
- ubuffree (zuser_hold);
- zuser_hold = NULL;
- cgroups_hold = 0;
- xfree ((pointer) paigroups_hold);
- paigroups_hold = NULL;
- }
-
- qpwd = getpwnam ((char *) zuser);
- if (qpwd == NULL)
- {
- /* Check this as a remote request. */
- zuser = NULL;
- }
- else
- {
-#if HAVE_GETGRENT
- struct group *qg;
-#endif
-
- zuser_hold = zbufcpy (zuser);
-
- iuid_hold = qpwd->pw_uid;
- igid_hold = qpwd->pw_gid;
-
-#if HAVE_GETGRENT
- /* Get the list of groups for this user. This is
- definitely more appropriate for BSD than for System
- V. It may just be a waste of time, and perhaps it
- should be configurable. */
- setgrent ();
- while ((qg = getgrent ()) != NULL)
- {
- const char **pz;
-
- if (qg->gr_gid == igid_hold)
- continue;
- for (pz = (const char **) qg->gr_mem; *pz != NULL; pz++)
- {
- if ((*pz)[0] == *zuser
- && strcmp (*pz, zuser) == 0)
- {
- paigroups_hold = ((gid_t *)
- (xrealloc
- ((pointer) paigroups_hold,
- ((cgroups_hold + 1)
- * sizeof (gid_t)))));
- paigroups_hold[cgroups_hold] = qg->gr_gid;
- ++cgroups_hold;
- break;
- }
- }
- }
- endgrent ();
-#endif
- }
- }
- }
-
-
- /* Now do the actual access check. */
-
- if (zuser != NULL)
- {
- /* The superuser can do anything. */
- if (iuid_hold == 0)
- return TRUE;
-
- /* If this is the uid we're running under, there's no point to
- checking access further, because when we actually try the
- operation the system will do the checking for us. */
- if (iuid_hold == geteuid ())
- return TRUE;
- }
-
- ir = S_IROTH;
- iw = S_IWOTH;
- ix = S_IXOTH;
-
- if (zuser != NULL)
- {
- if (iuid_hold == q->st_uid)
- {
- ir = S_IRUSR;
- iw = S_IWUSR;
- ix = S_IXUSR;
- }
- else
- {
- boolean fgroup;
-
- fgroup = FALSE;
- if (igid_hold == q->st_gid)
- fgroup = TRUE;
- else
- {
- int i;
-
- for (i = 0; i < cgroups_hold; i++)
- {
- if (paigroups_hold[i] == q->st_gid)
- {
- fgroup = TRUE;
- break;
- }
- }
- }
-
- if (fgroup)
- {
- ir = S_IRGRP;
- iw = S_IWGRP;
- ix = S_IXGRP;
- }
- }
- }
-
- iand = 0;
- if ((imode & R_OK) != 0)
- iand |= ir;
- if ((imode & W_OK) != 0)
- iand |= iw;
- if ((imode & X_OK) != 0)
- iand |= ix;
-
- return (q->st_mode & iand) == iand;
-}
diff --git a/gnu/libexec/uucp/libunix/ufopen.c b/gnu/libexec/uucp/libunix/ufopen.c
deleted file mode 100644
index d79d9a0..0000000
--- a/gnu/libexec/uucp/libunix/ufopen.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* ufopen.c
- Open a file with the permissions of the invoking user.
-
- Copyright (C) 1992, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-/* Open a file with the permissions of the invoking user. Ignore the
- fbinary argument since Unix has no distinction between text and
- binary files. */
-
-/*ARGSUSED*/
-openfile_t
-esysdep_user_fopen (zfile, frd, fbinary)
- const char *zfile;
- boolean frd;
- boolean fbinary;
-{
- uid_t ieuid;
- openfile_t e;
- const char *zerr;
- int o = 0;
-
- if (! fsuser_perms (&ieuid))
- return EFILECLOSED;
-
- zerr = NULL;
-
-#if USE_STDIO
- e = fopen (zfile, frd ? "r" : "w");
- if (e == NULL)
- zerr = "fopen";
- else
- o = fileno (e);
-#else
- if (frd)
- {
- e = open ((char *) zfile, O_RDONLY | O_NOCTTY, 0);
- zerr = "open";
- }
- else
- {
- e = creat ((char *) zfile, IPUBLIC_FILE_MODE);
- zerr = "creat";
- }
- if (e >= 0)
- {
- o = e;
- zerr = NULL;
- }
-#endif
-
- if (! fsuucp_perms ((long) ieuid))
- {
- if (ffileisopen (e))
- (void) ffileclose (e);
- return EFILECLOSED;
- }
-
- if (zerr != NULL)
- {
- ulog (LOG_ERROR, "%s (%s): %s", zerr, zfile, strerror (errno));
-#if ! HAVE_SETREUID
- /* Are these error messages helpful or confusing? */
-#if HAVE_SAVED_SETUID
- if (errno == EACCES && getuid () == 0)
- ulog (LOG_ERROR,
- "The superuser may only transfer files that are readable by %s",
- OWNER);
-#else
- if (errno == EACCES)
- ulog (LOG_ERROR,
- "You may only transfer files that are readable by %s", OWNER);
-#endif
-#endif /* ! HAVE_SETREUID */
- return EFILECLOSED;
- }
-
- if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- (void) ffileclose (e);
- return EFILECLOSED;
- }
-
- return e;
-}
diff --git a/gnu/libexec/uucp/libunix/uid.c b/gnu/libexec/uucp/libunix/uid.c
deleted file mode 100644
index 66b8fc7..0000000
--- a/gnu/libexec/uucp/libunix/uid.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/* uid.c
- Switch back and forth between UUCP and user permissions.
-
- Copyright (C) 1992, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-
-#include <errno.h>
-
-/* NetBSD apparently does not support setuid as required by POSIX when
- using saved setuid, so use seteuid instead. */
-
-#if HAVE_SETEUID
-#define setuid seteuid
-#endif
-
-/* Switch to permissions of the invoking user. */
-
-boolean
-fsuser_perms (pieuid)
- uid_t *pieuid;
-{
- uid_t ieuid, iuid;
-
- ieuid = geteuid ();
- iuid = getuid ();
- if (pieuid != NULL)
- *pieuid = ieuid;
-
-#if HAVE_SETREUID
- /* Swap the effective user id and the real user id. We can then
- swap them back again when we want to return to the uucp user's
- permissions. */
- if (setreuid (ieuid, iuid) < 0)
- {
- ulog (LOG_ERROR, "setreuid (%ld, %ld): %s",
- (long) ieuid, (long) iuid, strerror (errno));
- return FALSE;
- }
-#else /* ! HAVE_SETREUID */
-#if HAVE_SAVED_SETUID
- /* Set the effective user id to the real user id. Since the
- effective user id is saved (it's the saved setuid) we will able
- to set back to it later. If the real user id is root we will not
- be able to switch back and forth, so don't even try. */
- if (iuid != 0)
- {
- if (setuid (iuid) < 0)
- {
- ulog (LOG_ERROR, "setuid (%ld): %s", (long) iuid, strerror (errno));
- return FALSE;
- }
- }
-#else /* ! HAVE_SAVED_SETUID */
- /* There's no way to switch between real permissions and effective
- permissions. Just try to open the file with the uucp
- permissions. */
-#endif /* ! HAVE_SAVED_SETUID */
-#endif /* ! HAVE_SETREUID */
-
- return TRUE;
-}
-
-/* Restore the uucp permissions. */
-
-/*ARGSUSED*/
-boolean
-fsuucp_perms (ieuid)
- long ieuid;
-{
-#if HAVE_SETREUID
- /* Swap effective and real user id's back to what they were. */
- if (! fsuser_perms ((uid_t *) NULL))
- return FALSE;
-#else /* ! HAVE_SETREUID */
-#if HAVE_SAVED_SETUID
- /* Set ourselves back to our original effective user id. */
- if (setuid ((uid_t) ieuid) < 0)
- {
- ulog (LOG_ERROR, "setuid (%ld): %s", (long) ieuid, strerror (errno));
- /* Is this error message helpful or confusing? */
- if (errno == EPERM)
- ulog (LOG_ERROR,
- "Probably HAVE_SAVED_SETUID in policy.h should be set to 0");
- return FALSE;
- }
-#else /* ! HAVE_SAVED_SETUID */
- /* We didn't switch, no need to switch back. */
-#endif /* ! HAVE_SAVED_SETUID */
-#endif /* ! HAVE_SETREUID */
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libunix/ultspl.c b/gnu/libexec/uucp/libunix/ultspl.c
deleted file mode 100644
index 34921d2..0000000
--- a/gnu/libexec/uucp/libunix/ultspl.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* ultspl.c
- See whether there is an Ultrix spool directory for a system. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-boolean
-fsultrix_has_spool (zsystem)
- const char *zsystem;
-{
- char *z;
- boolean fret;
-
- z = zsysdep_in_dir ("sys", zsystem);
- fret = fsysdep_directory (z);
- ubuffree (z);
- return fret;
-}
diff --git a/gnu/libexec/uucp/libunix/unknwn.c b/gnu/libexec/uucp/libunix/unknwn.c
deleted file mode 100644
index 76f5345..0000000
--- a/gnu/libexec/uucp/libunix/unknwn.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* unknwn.c
- Check remote.unknown shell script. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-/* Run the remote.unknown shell script. If it succeeds, we return
- FALSE because that means that the system is not permitted to log
- in. If the execution fails, we return TRUE. */
-
-boolean
-fsysdep_unknown_caller (zscript, zsystem)
- const char *zscript;
- const char *zsystem;
-{
- const char *azargs[3];
- int aidescs[3];
- pid_t ipid;
-
- azargs[0] = zscript;
- azargs[1] = zsystem;
- azargs[2] = NULL;
-
- aidescs[0] = SPAWN_NULL;
- aidescs[1] = SPAWN_NULL;
- aidescs[2] = SPAWN_NULL;
-
- ipid = ixsspawn (azargs, aidescs, TRUE, TRUE, (const char *) NULL, FALSE,
- TRUE, (const char *) NULL, (const char *) NULL,
- (const char *) NULL);
- if (ipid < 0)
- {
- ulog (LOG_ERROR, "ixsspawn: %s", strerror (errno));
- return FALSE;
- }
-
- return ixswait ((unsigned long) ipid, (const char *) NULL) != 0;
-}
diff --git a/gnu/libexec/uucp/libunix/uuto.c b/gnu/libexec/uucp/libunix/uuto.c
deleted file mode 100644
index debba9d..0000000
--- a/gnu/libexec/uucp/libunix/uuto.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* uuto.c
- Translate a destination for uuto. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-/* Translate a uuto destination for Unix. */
-
-char *
-zsysdep_uuto (zdest, zlocalname)
- const char *zdest;
- const char *zlocalname;
-{
- const char *zexclam;
- char *zto;
-
- zexclam = strrchr (zdest, '!');
- if (zexclam == NULL)
- return NULL;
- zto = (char *) zbufalc (zexclam - zdest
- + sizeof "!~/receive///"
- + strlen (zexclam)
- + strlen (zlocalname));
- memcpy (zto, zdest, (size_t) (zexclam - zdest));
- sprintf (zto + (zexclam - zdest), "!~/receive/%s/%s/",
- zexclam + 1, zlocalname);
- return zto;
-}
diff --git a/gnu/libexec/uucp/libunix/walk.c b/gnu/libexec/uucp/libunix/walk.c
deleted file mode 100644
index 85b94da..0000000
--- a/gnu/libexec/uucp/libunix/walk.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* walk.c
- Walk a directory tree. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#if HAVE_FTW_H
-#include <ftw.h>
-#endif
-
-static int iswalk_dir P((const char *zname, struct stat *qstat, int iflag));
-
-/* Walk a directory tree. */
-
-static size_t cSlen;
-static void (*puSfn) P((const char *zfull, const char *zrelative,
- pointer pinfo));
-static pointer pSinfo;
-
-boolean
-usysdep_walk_tree (zdir, pufn, pinfo)
- const char *zdir;
- void (*pufn) P((const char *zfull, const char *zrelative,
- pointer pinfo));
- pointer pinfo;
-{
- cSlen = strlen (zdir) + 1;
- puSfn = pufn;
- pSinfo = pinfo;
- return ftw ((char *) zdir, iswalk_dir, 5) == 0;
-}
-
-/* Pass a file found in the directory tree to the system independent
- function. */
-
-/*ARGSUSED*/
-static int
-iswalk_dir (zname, qstat, iflag)
- const char *zname;
- struct stat *qstat;
- int iflag;
-{
- char *zcopy;
-
- if (iflag != FTW_F)
- return 0;
-
- zcopy = zbufcpy (zname + cSlen);
-
- (*puSfn) (zname, zcopy, pSinfo);
-
- ubuffree (zcopy);
-
- return 0;
-}
diff --git a/gnu/libexec/uucp/libunix/wldcrd.c b/gnu/libexec/uucp/libunix/wldcrd.c
deleted file mode 100644
index 1aa17fa..0000000
--- a/gnu/libexec/uucp/libunix/wldcrd.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/* wldcrd.c
- Expand wildcards.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <ctype.h>
-#include <errno.h>
-
-#if HAVE_GLOB && ! HAVE_GLOB_H
-#undef HAVE_GLOB
-#define HAVE_GLOB 0
-#endif
-
-#if HAVE_GLOB
-#include <glob.h>
-#endif
-
-/* Local variables to hold the wildcard in progress. */
-
-#if HAVE_GLOB
-static glob_t sSglob;
-static int iSglob;
-#else
-static char *zSwildcard_alloc;
-static char *zSwildcard;
-#endif
-
-/* Start getting a wildcarded file spec. Use the glob function if it
- is available, and otherwise use the shell. */
-
-boolean
-fsysdep_wildcard_start (zfile)
- const char *zfile;
-{
-#if HAVE_GLOB
-
-#if DEBUG > 0
- if (*zfile != '/')
- ulog (LOG_FATAL, "fsysdep_wildcard: %s: Can't happen", zfile);
-#endif
-
- if (glob (zfile, 0, (int (*) ()) NULL, &sSglob) != 0)
- sSglob.gl_pathc = 0;
- iSglob = 0;
- return TRUE;
-
-#else /* ! HAVE_GLOB */
-
- char *zcmd, *zto;
- const char *zfrom;
- size_t c;
- const char *azargs[4];
- FILE *e;
- pid_t ipid;
-
-#if DEBUG > 0
- if (*zfile != '/')
- ulog (LOG_FATAL, "fsysdep_wildcard: %s: Can't happen", zfile);
-#endif
-
- zSwildcard_alloc = NULL;
- zSwildcard = NULL;
-
- zcmd = zbufalc (sizeof ECHO_PROGRAM + sizeof " " + 2 * strlen (zfile));
- memcpy (zcmd, ECHO_PROGRAM, sizeof ECHO_PROGRAM - 1);
- zto = zcmd + sizeof ECHO_PROGRAM - 1;
- *zto++ = ' ';
- zfrom = zfile;
- while (*zfrom != '\0')
- {
- /* To avoid shell trickery, we quote all characters except
- letters, digits, and wildcard specifiers. We don't quote '/'
- to avoid an Ultrix sh bug. */
- if (! isalnum (*zfrom)
- && *zfrom != '*'
- && *zfrom != '?'
- && *zfrom != '['
- && *zfrom != ']'
- && *zfrom != '/')
- *zto++ = '\\';
- *zto++ = *zfrom++;
- }
- *zto = '\0';
-
- azargs[0] = "/bin/sh";
- azargs[1] = "-c";
- azargs[2] = zcmd;
- azargs[3] = NULL;
-
- e = espopen (azargs, TRUE, &ipid);
-
- ubuffree (zcmd);
-
- if (e == NULL)
- {
- ulog (LOG_ERROR, "espopen: %s", strerror (errno));
- return FALSE;
- }
-
- zSwildcard_alloc = NULL;
- c = 0;
- if (getline (&zSwildcard_alloc, &c, e) <= 0)
- {
- xfree ((pointer) zSwildcard_alloc);
- zSwildcard_alloc = NULL;
- }
-
- if (ixswait ((unsigned long) ipid, ECHO_PROGRAM) != 0)
- {
- xfree ((pointer) zSwildcard_alloc);
- return FALSE;
- }
-
- if (zSwildcard_alloc == NULL)
- return FALSE;
-
- DEBUG_MESSAGE1 (DEBUG_EXECUTE,
- "fsysdep_wildcard_start: got \"%s\"",
- zSwildcard_alloc);
-
- zSwildcard = zSwildcard_alloc;
-
- return TRUE;
-
-#endif /* ! HAVE_GLOB */
-}
-
-/* Get the next wildcard spec. */
-
-/*ARGSUSED*/
-char *
-zsysdep_wildcard (zfile)
- const char *zfile;
-{
-#if HAVE_GLOB
-
- char *zret;
-
- if (iSglob >= sSglob.gl_pathc)
- return NULL;
- zret = zbufcpy (sSglob.gl_pathv[iSglob]);
- ++iSglob;
- return zret;
-
-#else /* ! HAVE_GLOB */
-
- char *zret;
-
- if (zSwildcard_alloc == NULL || zSwildcard == NULL)
- return NULL;
-
- zret = zSwildcard;
-
- while (*zSwildcard != '\0' && ! isspace (BUCHAR (*zSwildcard)))
- ++zSwildcard;
-
- if (*zSwildcard != '\0')
- {
- *zSwildcard = '\0';
- ++zSwildcard;
- while (*zSwildcard != '\0' && isspace (BUCHAR (*zSwildcard)))
- ++zSwildcard;
- }
-
- if (*zSwildcard == '\0')
- zSwildcard = NULL;
-
- return zbufcpy (zret);
-
-#endif /* ! HAVE_GLOB */
-}
-
-/* Finish up getting wildcard specs. */
-
-boolean
-fsysdep_wildcard_end ()
-{
-#if HAVE_GLOB
- globfree (&sSglob);
- return TRUE;
-#else /* ! HAVE_GLOB */
- xfree ((pointer) zSwildcard_alloc);
- zSwildcard_alloc = NULL;
- zSwildcard = NULL;
- return TRUE;
-#endif /* ! HAVE_GLOB */
-}
diff --git a/gnu/libexec/uucp/libunix/work.c b/gnu/libexec/uucp/libunix/work.c
deleted file mode 100644
index 8734a93..0000000
--- a/gnu/libexec/uucp/libunix/work.c
+++ /dev/null
@@ -1,791 +0,0 @@
-/* work.c
- Routines to read command files.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char work_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "sysdep.h"
-
-#include <ctype.h>
-#include <errno.h>
-
-#if HAVE_OPENDIR
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#else /* ! HAVE_DIRENT_H */
-#include <sys/dir.h>
-#define dirent direct
-#endif /* ! HAVE_DIRENT_H */
-#endif /* HAVE_OPENDIR */
-
-/* Local functions. */
-
-static char *zswork_directory P((const char *zsystem));
-static boolean fswork_file P((const char *zsystem, const char *zfile,
- char *pbgrade));
-static int iswork_cmp P((constpointer pkey, constpointer pdatum));
-
-/* These functions can support multiple actions going on at once.
- This allows the UUCP package to send and receive multiple files at
- the same time. */
-
-/* To avoid wasting a lot of time scanning the spool directory, which
- might cause the remote system to time out, we limit each scan to
- pick up at most a certain number of files. */
-#define COMMANDS_PER_SCAN (200)
-
-/* The ssfilename structure holds the name of a work file, as well as
- its grade. */
-
-struct ssfilename
-{
- char *zfile;
- char bgrade;
- /* Some compiler may need this, and it won't normally hurt. */
- char bdummy;
-};
-
-/* The ssfile structure holds a command file name and all the lines
- read in from that command file. The union within the ssline
- structure initially holds a line from the file and then holds a
- pointer back to the ssfile structure; a pointer to this union is
- used as a sequence pointer. The ztemp entry of the ssline
- structure holds the name of a temporary file to delete, if any. */
-
-#define CFILELINES (10)
-
-struct ssline
-{
- char *zline;
- struct ssfile *qfile;
- char *ztemp;
-};
-
-struct ssfile
-{
- char *zfile;
- char bgrade;
- /* bdummy is needed for some buggy compilers. */
- char bdummy;
- int clines;
- int cdid;
- struct ssline aslines[CFILELINES];
-};
-
-/* Static variables for the work scan. */
-
-static struct ssfilename *asSwork_files;
-static size_t cSwork_files;
-static size_t iSwork_file;
-static struct ssfile *qSwork_file;
-
-/* Given a system name, return a directory to search for work. */
-
-static char *
-zswork_directory (zsystem)
- const char *zsystem;
-{
-#if SPOOLDIR_V2
- return zbufcpy (".");
-#endif /* SPOOLDIR_V2 */
-#if SPOOLDIR_BSD42 || SPOOLDIR_BSD43
- return zbufcpy ("C.");
-#endif /* SPOOLDIR_BSD42 || SPOOLDIR_BSD43 */
-#if SPOOLDIR_HDB || SPOOLDIR_SVR4
- return zbufcpy (zsystem);
-#endif /* SPOOLDIR_HDB || SPOOLDIR_SVR4 */
-#if SPOOLDIR_ULTRIX
- return zsappend3 ("sys",
- (fsultrix_has_spool (zsystem)
- ? zsystem
- : "DEFAULT"),
- "C.");
-#endif /* SPOOLDIR_ULTRIX */
-#if SPOOLDIR_TAYLOR
- return zsysdep_in_dir (zsystem, "C.");
-#endif /* SPOOLDIR_TAYLOR */
-}
-
-/* See whether a file name from the directory returned by
- zswork_directory is really a command for a particular system.
- Return the command grade. */
-
-/*ARGSUSED*/
-static boolean
-fswork_file (zsystem, zfile, pbgrade)
- const char *zsystem;
- const char *zfile;
- char *pbgrade;
-{
-#if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43 || SPOOLDIR_ULTRIX
- int cfilesys, csys;
-
- /* The file name should be C.ssssssgqqqq, where g is exactly one
- letter and qqqq is exactly four numbers. The system name may be
- truncated to six or seven characters. The system name of the
- file must match the system name we're looking for, since there
- could be work files for several systems in one directory. */
- if (zfile[0] != 'C' || zfile[1] != '.')
- return FALSE;
- csys = strlen (zsystem);
- cfilesys = strlen (zfile) - 7;
- if (csys != cfilesys
- && (csys < 6 || (cfilesys != 6 && cfilesys != 7)))
- return FALSE;
- *pbgrade = zfile[cfilesys + 2];
- return strncmp (zfile + 2, zsystem, cfilesys) == 0;
-#endif /* V2 || BSD42 || BSD43 || ULTRIX */
-#if SPOOLDIR_HDB || SPOOLDIR_SVR4
- int clen;
-
- /* The HDB file name should be C.ssssssgqqqq where g is exactly one
- letter and qqqq is exactly four numbers or letters. We don't
- check the system name, because it is guaranteed by the directory
- we are looking in and some versions of uucp set it to the local
- system rather than the remote one. I'm not sure of the exact
- format of the SVR4 file name, but it does not include the grade
- at all. */
- if (zfile[0] != 'C' || zfile[1] != '.')
- return FALSE;
- clen = strlen (zfile);
- if (clen < 7)
- return FALSE;
-#if ! SPOOLDIR_SVR4
- *pbgrade = zfile[clen - 5];
-#endif
- return TRUE;
-#endif /* SPOOLDIR_HDB || SPOOLDIR_SVR4 */
-#if SPOOLDIR_TAYLOR
- /* We don't keep the system name in the file name, since that
- forces truncation. Our file names are always C.gqqqq. */
- *pbgrade = zfile[2];
- return (zfile[0] == 'C'
- && zfile[1] == '.'
- && zfile[2] != '\0');
-#endif /* SPOOLDIR_TAYLOR */
-}
-
-/* A comparison function to look through the list of file names. */
-
-static int
-iswork_cmp (pkey, pdatum)
- constpointer pkey;
- constpointer pdatum;
-{
- const struct ssfilename *qkey = (const struct ssfilename *) pkey;
- const struct ssfilename *qdatum = (const struct ssfilename *) pdatum;
-
- return strcmp (qkey->zfile, qdatum->zfile);
-}
-
-/* See whether there is any work to do for a particular system. */
-
-boolean
-fsysdep_has_work (qsys)
- const struct uuconf_system *qsys;
-{
- char *zdir;
- DIR *qdir;
- struct dirent *qentry;
-#if SPOOLDIR_SVR4
- DIR *qgdir;
- struct dirent *qgentry;
-#endif
-
- zdir = zswork_directory (qsys->uuconf_zname);
- if (zdir == NULL)
- return FALSE;
- qdir = opendir ((char *) zdir);
- if (qdir == NULL)
- {
- ubuffree (zdir);
- return FALSE;
- }
-
-#if SPOOLDIR_SVR4
- qgdir = qdir;
- while ((qgentry = readdir (qgdir)) != NULL)
- {
- char *zsub;
-
- if (qgentry->d_name[0] == '.'
- || qgentry->d_name[1] != '\0')
- continue;
- zsub = zsysdep_in_dir (zdir, qgentry->d_name);
- qdir = opendir (zsub);
- ubuffree (zsub);
- if (qdir == NULL)
- continue;
-#endif
-
- while ((qentry = readdir (qdir)) != NULL)
- {
- char bgrade;
-
- if (fswork_file (qsys->uuconf_zname, qentry->d_name, &bgrade))
- {
- closedir (qdir);
-#if SPOOLDIR_SVR4
- closedir (qgdir);
-#endif
- ubuffree (zdir);
- return TRUE;
- }
- }
-
-#if SPOOLDIR_SVR4
- closedir (qdir);
- }
- qdir = qgdir;
-#endif
-
- closedir (qdir);
- ubuffree (zdir);
- return FALSE;
-}
-
-/* Initialize the work scan. We have to read all the files in the
- work directory, so that we can sort them by work grade. The bgrade
- argument is the minimum grade to consider. We don't want to return
- files that we have already considered; usysdep_get_work_free will
- clear the data out when we are done with the system. This returns
- FALSE on error. */
-
-#define CWORKFILES (10)
-
-boolean
-fsysdep_get_work_init (qsys, bgrade)
- const struct uuconf_system *qsys;
- int bgrade;
-{
- char *zdir;
- DIR *qdir;
- struct dirent *qentry;
- size_t chad;
- size_t callocated;
-#if SPOOLDIR_SVR4
- DIR *qgdir;
- struct dirent *qgentry;
-#endif
-
- zdir = zswork_directory (qsys->uuconf_zname);
- if (zdir == NULL)
- return FALSE;
-
- qdir = opendir (zdir);
- if (qdir == NULL)
- {
- boolean fret;
-
- if (errno == ENOENT)
- fret = TRUE;
- else
- {
- ulog (LOG_ERROR, "opendir (%s): %s", zdir, strerror (errno));
- fret = FALSE;
- }
- ubuffree (zdir);
- return fret;
- }
-
- chad = cSwork_files;
- callocated = cSwork_files;
-
- /* Sort the files we already know about so that we can check the new
- ones with bsearch. It would be faster to use a hash table, and
- the code should be probably be changed. The sort done at the end
- of this function does not suffice because it only includes the
- files added last time, and does not sort the entire array. Some
- (bad) qsort implementations are very slow when given a sorted
- array, which causes particularly bad effects here. */
- if (chad > 0)
- qsort ((pointer) asSwork_files, chad, sizeof (struct ssfilename),
- iswork_cmp);
-
-#if SPOOLDIR_SVR4
- qgdir = qdir;
- while ((qgentry = readdir (qgdir)) != NULL)
- {
- char *zsub;
-
- if (qgentry->d_name[0] == '.'
- || qgentry->d_name[1] != '\0'
- || UUCONF_GRADE_CMP (bgrade, qgentry->d_name[0]) < 0)
- continue;
- zsub = zsysdep_in_dir (zdir, qgentry->d_name);
- qdir = opendir (zsub);
- if (qdir == NULL)
- {
- if (errno != ENOTDIR && errno != ENOENT)
- {
- ulog (LOG_ERROR, "opendir (%s): %s", zsub,
- strerror (errno));
- ubuffree (zsub);
- return FALSE;
- }
- ubuffree (zsub);
- continue;
- }
- ubuffree (zsub);
-#endif
-
- while ((qentry = readdir (qdir)) != NULL)
- {
- char bfilegrade;
- char *zname;
- struct ssfilename slook;
-
-#if ! SPOOLDIR_SVR4
- zname = zbufcpy (qentry->d_name);
-#else
- zname = zsysdep_in_dir (qgentry->d_name, qentry->d_name);
- bfilegrade = qgentry->d_name[0];
-#endif
-
- slook.zfile = zname;
- if (! fswork_file (qsys->uuconf_zname, qentry->d_name,
- &bfilegrade)
- || UUCONF_GRADE_CMP (bgrade, bfilegrade) < 0
- || (asSwork_files != NULL
- && bsearch ((pointer) &slook,
- (pointer) asSwork_files,
- chad, sizeof (struct ssfilename),
- iswork_cmp) != NULL))
- ubuffree (zname);
- else
- {
- DEBUG_MESSAGE1 (DEBUG_SPOOLDIR,
- "fsysdep_get_work_init: Found %s",
- zname);
-
- if (cSwork_files >= callocated)
- {
- callocated += CWORKFILES;
- asSwork_files =
- ((struct ssfilename *)
- xrealloc ((pointer) asSwork_files,
- (callocated * sizeof (struct ssfilename))));
- }
-
- asSwork_files[cSwork_files].zfile = zname;
- asSwork_files[cSwork_files].bgrade = bfilegrade;
- ++cSwork_files;
- if (cSwork_files - chad > COMMANDS_PER_SCAN)
- break;
- }
- }
-
-#if SPOOLDIR_SVR4
- closedir (qdir);
- if (cSwork_files - chad > COMMANDS_PER_SCAN)
- break;
- }
- qdir = qgdir;
-#endif
-
- closedir (qdir);
- ubuffree (zdir);
-
- /* Sorting the files alphabetically will get the grades in the
- right order, since all the file prefixes are the same. */
- if (cSwork_files > iSwork_file)
- qsort ((pointer) (asSwork_files + iSwork_file),
- cSwork_files - iSwork_file,
- sizeof (struct ssfilename), iswork_cmp);
-
- return TRUE;
-}
-
-/* Get the next work entry for a system. This must parse the next
- line in the next work file. The type of command is set into
- qcmd->bcmd If there are no more commands, qcmd->bcmd is set to 'H'.
- Each field in the structure is set to point to a spot in an
- malloced string. The grade argument is never used; it has been
- used by fsysdep_get_work_init. */
-
-/*ARGSUSED*/
-boolean
-fsysdep_get_work (qsys, bgrade, qcmd)
- const struct uuconf_system *qsys;
- int bgrade;
- struct scmd *qcmd;
-{
- char *zdir;
-
- if (qSwork_file != NULL && qSwork_file->cdid >= qSwork_file->clines)
- qSwork_file = NULL;
-
- if (asSwork_files == NULL)
- {
- qcmd->bcmd = 'H';
- return TRUE;
- }
-
- zdir = NULL;
-
- /* This loop continues until a line is returned. */
- while (TRUE)
- {
- /* This loop continues until a file is opened and read in. */
- while (qSwork_file == NULL)
- {
- FILE *e;
- struct ssfile *qfile;
- int iline, callocated;
- char *zline;
- size_t cline;
- char *zname;
- char bfilegrade;
-
- /* Read all the lines of a command file into memory. */
- do
- {
- if (iSwork_file >= cSwork_files)
- {
- qcmd->bcmd = 'H';
- ubuffree (zdir);
- return TRUE;
- }
-
- if (zdir == NULL)
- {
- zdir = zswork_directory (qsys->uuconf_zname);
- if (zdir == NULL)
- return FALSE;
- }
-
- zname = zsysdep_in_dir (zdir, asSwork_files[iSwork_file].zfile);
- bfilegrade = asSwork_files[iSwork_file].bgrade;
-
- ++iSwork_file;
-
- e = fopen (zname, "r");
- if (e == NULL)
- {
- ulog (LOG_ERROR, "fopen (%s): %s", zname,
- strerror (errno));
- ubuffree (zname);
- }
- }
- while (e == NULL);
-
- qfile = (struct ssfile *) xmalloc (sizeof (struct ssfile));
- callocated = CFILELINES;
- iline = 0;
-
- zline = NULL;
- cline = 0;
- while (getline (&zline, &cline, e) > 0)
- {
- if (iline >= callocated)
- {
- /* The sizeof (struct ssfile) includes CFILELINES
- entries already, so using callocated * sizeof
- (struct ssline) will give us callocated *
- CFILELINES entries. */
- qfile =
- ((struct ssfile *)
- xrealloc ((pointer) qfile,
- (sizeof (struct ssfile) +
- (callocated * sizeof (struct ssline)))));
- callocated += CFILELINES;
- }
- qfile->aslines[iline].zline = zbufcpy (zline);
- qfile->aslines[iline].qfile = NULL;
- qfile->aslines[iline].ztemp = NULL;
- iline++;
- }
-
- xfree ((pointer) zline);
-
- if (fclose (e) != 0)
- ulog (LOG_ERROR, "fclose: %s", strerror (errno));
-
- if (iline == 0)
- {
- /* There were no lines in the file; this is a poll file,
- for which we return a 'P' command. */
- qfile->aslines[0].zline = zbufcpy ("P");
- qfile->aslines[0].qfile = NULL;
- qfile->aslines[0].ztemp = NULL;
- iline = 1;
- }
-
- qfile->zfile = zname;
- qfile->bgrade = bfilegrade;
- qfile->clines = iline;
- qfile->cdid = 0;
- qSwork_file = qfile;
- }
-
- /* This loop continues until all the lines from the current file
- are used up, or a line is returned. */
- while (TRUE)
- {
- int iline;
-
- if (qSwork_file->cdid >= qSwork_file->clines)
- {
- /* We don't want to free qSwork_file here, since it must
- remain until all the lines have been completed. It
- is freed in fsysdep_did_work. */
- qSwork_file = NULL;
- /* Go back to the main loop which finds another file. */
- break;
- }
-
- iline = qSwork_file->cdid;
- ++qSwork_file->cdid;
-
- /* Now parse the line into a command. */
- if (! fparse_cmd (qSwork_file->aslines[iline].zline, qcmd))
- {
- ulog (LOG_ERROR, "Bad line in command file %s",
- qSwork_file->zfile);
- ubuffree (qSwork_file->aslines[iline].zline);
- qSwork_file->aslines[iline].zline = NULL;
- continue;
- }
- qcmd->bgrade = qSwork_file->bgrade;
-
- qSwork_file->aslines[iline].qfile = qSwork_file;
- qcmd->pseq = (pointer) (&qSwork_file->aslines[iline]);
-
- if (qcmd->bcmd == 'S' || qcmd->bcmd == 'E')
- {
- char *zreal;
-
- zreal = zsysdep_spool_file_name (qsys, qcmd->ztemp,
- qcmd->pseq);
- if (zreal == NULL)
- {
- ubuffree (qSwork_file->aslines[iline].zline);
- qSwork_file->aslines[iline].zline = NULL;
- ubuffree (zdir);
- return FALSE;
- }
- qSwork_file->aslines[iline].ztemp = zreal;
- }
-
- ubuffree (zdir);
- return TRUE;
- }
- }
-}
-
-/* When a command has been complete, fsysdep_did_work is called. The
- sequence entry was set above to be the address of an aslines
- structure whose pfile entry points to the ssfile corresponding to
- this file. We can then check whether all the lines have been
- completed (they will have been if the pfile entry is NULL) and
- remove the file if they have been. This means that we only remove
- a command file if we manage to complete every transfer it specifies
- in a single UUCP session. I don't know if this is how regular UUCP
- works. */
-
-boolean
-fsysdep_did_work (pseq)
- pointer pseq;
-{
- struct ssfile *qfile;
- struct ssline *qline;
- int i;
-
- qline = (struct ssline *) pseq;
-
- ubuffree (qline->zline);
- qline->zline = NULL;
-
- qfile = qline->qfile;
- qline->qfile = NULL;
-
- /* Remove the temporary file, if there is one. It really doesn't
- matter if this fails, and not checking the return value lets us
- attempt to remove D.0 or whatever an unused temporary file is
- called without complaining. */
- if (qline->ztemp != NULL)
- {
- (void) remove (qline->ztemp);
- ubuffree (qline->ztemp);
- qline->ztemp = NULL;
- }
-
- /* If not all the lines have been returned from fsysdep_get_work,
- we can't remove the file yet. */
- if (qfile->cdid < qfile->clines)
- return TRUE;
-
- /* See whether all the commands have been completed. */
- for (i = 0; i < qfile->clines; i++)
- if (qfile->aslines[i].qfile != NULL)
- return TRUE;
-
- /* All commands have finished. */
- if (remove (qfile->zfile) != 0)
- {
- ulog (LOG_ERROR, "remove (%s): %s", qfile->zfile,
- strerror (errno));
- return FALSE;
- }
-
- ubuffree (qfile->zfile);
- xfree ((pointer) qfile);
-
- if (qfile == qSwork_file)
- qSwork_file = NULL;
-
- return TRUE;
-}
-
-/* Free up the results of a work scan, when we're done with this
- system. */
-
-/*ARGSUSED*/
-void
-usysdep_get_work_free (qsys)
- const struct uuconf_system *qsys;
-{
- if (asSwork_files != NULL)
- {
- size_t i;
-
- for (i = 0; i < cSwork_files; i++)
- ubuffree ((pointer) asSwork_files[i].zfile);
- xfree ((pointer) asSwork_files);
- asSwork_files = NULL;
- cSwork_files = 0;
- iSwork_file = 0;
- }
- if (qSwork_file != NULL)
- {
- int i;
-
- ubuffree (qSwork_file->zfile);
- for (i = 0; i < qSwork_file->cdid; i++)
- {
- ubuffree (qSwork_file->aslines[i].zline);
- ubuffree (qSwork_file->aslines[i].ztemp);
- }
- for (i = qSwork_file->cdid; i < qSwork_file->clines; i++)
- ubuffree (qSwork_file->aslines[i].zline);
- xfree ((pointer) qSwork_file);
- qSwork_file = NULL;
- }
-}
-
-/* Save the temporary file used by a send command, and return an
- informative message to mail to the requestor. This is called when
- a file transfer failed, to make sure that the potentially valuable
- file is not completely lost. */
-
-const char *
-zsysdep_save_temp_file (pseq)
- pointer pseq;
-{
- struct ssline *qline = (struct ssline *) pseq;
- char *zto, *zslash;
- size_t cwant;
- static char *zbuf;
- static int cbuf;
-
- if (! fsysdep_file_exists (qline->ztemp))
- return NULL;
-
- zslash = strrchr (qline->ztemp, '/');
- if (zslash == NULL)
- zslash = qline->ztemp;
- else
- ++zslash;
-
- zto = zbufalc (sizeof PRESERVEDIR + sizeof "/" + strlen (zslash));
- sprintf (zto, "%s/%s", PRESERVEDIR, zslash);
-
- if (! fsysdep_move_file (qline->ztemp, zto, TRUE, FALSE, FALSE,
- (const char *) NULL))
- {
- /* Leave the file where it was, not that is much help. */
- ubuffree (zto);
- return "Could not move file to preservation directory";
- }
-
- cwant = sizeof "File saved as\n\t/" + strlen (zSspooldir) + strlen (zto);
- if (cwant > cbuf)
- {
- ubuffree (zbuf);
- zbuf = zbufalc (cwant);
- cbuf = cwant;
- }
-
- sprintf (zbuf, "File saved as\n\t%s/%s", zSspooldir, zto);
- ubuffree (zto);
- return zbuf;
-}
-
-/* Get the jobid of a work file. This is needed by uustat. */
-
-char *
-zsysdep_jobid (qsys, pseq)
- const struct uuconf_system *qsys;
- pointer pseq;
-{
- return zsfile_to_jobid (qsys, ((struct ssline *) pseq)->qfile->zfile,
- bsgrade (pseq));
-}
-
-/* Get the grade of a work file. The pseq argument can be NULL when
- this is called from zsysdep_spool_file_name, and simply means that
- this is a remote file; returning -1 will cause zsfind_file to do
- the right thing. */
-
-int
-bsgrade (pseq)
- pointer pseq;
-{
- const char *zfile;
- char bgrade;
-
- if (pseq == NULL)
- return -1;
-
- zfile = ((struct ssline *) pseq)->qfile->zfile;
-
-#if SPOOLDIR_TAYLOR
- bgrade = *(strrchr (zfile, '/') + 3);
-#else
-#if ! SPOOLDIR_SVR4
- bgrade = zfile[strlen (zfile) - CSEQLEN - 1];
-#else
- bgrade = *(strchr (zfile, '/') + 1);
-#endif
-#endif
-
- return bgrade;
-}
diff --git a/gnu/libexec/uucp/libunix/xqtfil.c b/gnu/libexec/uucp/libunix/xqtfil.c
deleted file mode 100644
index 5dfb6bb..0000000
--- a/gnu/libexec/uucp/libunix/xqtfil.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/* xqtfil.c
- Routines to read execute files.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char xqtfil_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "sysdep.h"
-#include "system.h"
-
-#include <errno.h>
-
-#if HAVE_OPENDIR
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#else /* ! HAVE_DIRENT_H */
-#include <sys/dir.h>
-#define dirent direct
-#endif /* ! HAVE_DIRENT_H */
-#endif /* HAVE_OPENDIR */
-
-/* Under the V2 or BSD42 spool directory scheme, all execute files are
- in the main spool directory. Under the BSD43 scheme, they are all
- in the directory X.. Under the HDB or SVR4 scheme, they are in
- directories named after systems. Under the ULTRIX scheme, they are
- in X. subdirectories of subdirectories of sys. Under the TAYLOR
- scheme, they are all in the subdirectory X. of a directory named
- after the system.
-
- This means that for HDB, ULTRIX, SVR4 or TAYLOR, we have to search
- directories of directories. */
-
-#if SPOOLDIR_V2 || SPOOLDIR_BSD42
-#define ZDIR "."
-#define SUBDIRS 0
-#endif
-#if SPOOLDIR_HDB || SPOOLDIR_SVR4 || SPOOLDIR_TAYLOR
-#define ZDIR "."
-#define SUBDIRS 1
-#endif
-#if SPOOLDIR_ULTRIX
-#define ZDIR "sys"
-#define SUBDIRS 1
-#endif
-#if SPOOLDIR_BSD43
-#define ZDIR "X."
-#define SUBDIRS 0
-#endif
-
-/* Static variables for the execute file scan. */
-
-static DIR *qSxqt_topdir;
-#if ! SUBDIRS
-static const char *zSdir;
-#else /* SUBDIRS */
-static boolean fSone_dir;
-static char *zSdir;
-static DIR *qSxqt_dir;
-static char *zSsystem;
-#endif /* SUBDIRS */
-
-/* Initialize the scan for execute files. The function
- usysdep_get_xqt_free will clear the data out when we are done with
- the system. This returns FALSE on error. */
-
-/*ARGSUSED*/
-boolean
-fsysdep_get_xqt_init (zsystem)
- const char *zsystem;
-{
- usysdep_get_xqt_free ((const char *) NULL);
-
-#if SUBDIRS
- if (zsystem != NULL)
- {
-#if SPOOLDIR_HDB || SPOOLDIR_SVR4
- zSdir = zbufcpy (zsystem);
-#endif
-#if SPOOLDIR_ULTRIX
- zSdir = zsappend3 ("sys", zsystem, "X.");
-#endif
-#if SPOOLDIR_TAYLOR
- zSdir = zsysdep_in_dir (zsystem, "X.");
-#endif
-
- qSxqt_dir = opendir ((char *) zSdir);
- if (qSxqt_dir != NULL)
- {
- qSxqt_topdir = qSxqt_dir;
- fSone_dir = TRUE;
- zSsystem = zbufcpy (zsystem);
- return TRUE;
- }
- }
-
- fSone_dir = FALSE;
-#endif
-
- qSxqt_topdir = opendir ((char *) ZDIR);
- if (qSxqt_topdir == NULL)
- {
- if (errno == ENOENT)
- return TRUE;
- ulog (LOG_ERROR, "opendir (%s): %s", ZDIR, strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Return the name of the next execute file to read and process. If
- this returns NULL, *pferr must be checked. If will be TRUE on
- error, FALSE if there are no more files. On a successful return
- *pzsystem will be set to the system for which the execute file was
- created. */
-
-/*ARGSUSED*/
-char *
-zsysdep_get_xqt (zsystem, pzsystem, pferr)
- const char *zsystem;
- char **pzsystem;
- boolean *pferr;
-{
- *pferr = FALSE;
-
- if (qSxqt_topdir == NULL)
- return NULL;
-
- /* This loop continues until we find a file. */
- while (TRUE)
- {
- DIR *qdir;
- struct dirent *q;
-
-#if ! SUBDIRS
- zSdir = ZDIR;
- qdir = qSxqt_topdir;
-#else /* SUBDIRS */
- /* This loop continues until we find a subdirectory to read. */
- while (qSxqt_dir == NULL)
- {
- struct dirent *qtop;
-
- qtop = readdir (qSxqt_topdir);
- if (qtop == NULL)
- {
- (void) closedir (qSxqt_topdir);
- qSxqt_topdir = NULL;
- return NULL;
- }
-
- /* No system name may start with a dot This allows us to
- quickly skip impossible directories. */
- if (qtop->d_name[0] == '.')
- continue;
-
- DEBUG_MESSAGE1 (DEBUG_SPOOLDIR,
- "zsysdep_get_xqt: Found %s in top directory",
- qtop->d_name);
-
- ubuffree (zSdir);
-
-#if SPOOLDIR_HDB || SPOOLDIR_SVR4
- zSdir = zbufcpy (qtop->d_name);
-#endif
-#if SPOOLDIR_ULTRIX
- zSdir = zsappend3 ("sys", qtop->d_name, "X.");
-#endif
-#if SPOOLDIR_TAYLOR
- zSdir = zsysdep_in_dir (qtop->d_name, "X.");
-#endif
-
- ubuffree (zSsystem);
- zSsystem = zbufcpy (qtop->d_name);
-
- qSxqt_dir = opendir (zSdir);
-
- if (qSxqt_dir == NULL
- && errno != ENOTDIR
- && errno != ENOENT)
- ulog (LOG_ERROR, "opendir (%s): %s", zSdir, strerror (errno));
- }
-
- qdir = qSxqt_dir;
-#endif /* SUBDIRS */
-
- q = readdir (qdir);
-
-#if DEBUG > 1
- if (q != NULL)
- DEBUG_MESSAGE2 (DEBUG_SPOOLDIR,
- "zsysdep_get_xqt: Found %s in subdirectory %s",
- q->d_name, zSdir);
-#endif
-
- /* If we've found an execute file, return it. We have to get
- the system name, which is easy for HDB or TAYLOR. For other
- spool directory schemes, we have to pull it out of the X.
- file name; this would be insecure, except that zsfind_file
- clobbers the file name to include the real system name. */
- if (q != NULL
- && q->d_name[0] == 'X'
- && q->d_name[1] == '.')
- {
- char *zret;
-
-#if SPOOLDIR_HDB || SPOOLDIR_SVR4 || SPOOLDIR_TAYLOR
- *pzsystem = zbufcpy (zSsystem);
-#else
- {
- size_t clen;
-
- clen = strlen (q->d_name) - 7;
- *pzsystem = zbufalc (clen + 1);
- memcpy (*pzsystem, q->d_name + 2, clen);
- (*pzsystem)[clen] = '\0';
- }
-#endif
-
- zret = zsysdep_in_dir (zSdir, q->d_name);
-#if DEBUG > 1
- DEBUG_MESSAGE2 (DEBUG_SPOOLDIR,
- "zsysdep_get_xqt: Returning %s (system %s)",
- zret, *pzsystem);
-#endif
- return zret;
- }
-
- /* If we've reached the end of the directory, then if we are
- using subdirectories loop around to read the next one,
- otherwise we are finished. */
- if (q == NULL)
- {
- (void) closedir (qdir);
-
-#if SUBDIRS
- qSxqt_dir = NULL;
- if (! fSone_dir)
- continue;
-#endif
-
- qSxqt_topdir = NULL;
- return NULL;
- }
- }
-}
-
-/* Free up the results of an execute file scan, when we're done with
- this system. */
-
-/*ARGSUSED*/
-void
-usysdep_get_xqt_free (zsystem)
- const char *zsystem;
-{
- if (qSxqt_topdir != NULL)
- {
- (void) closedir (qSxqt_topdir);
- qSxqt_topdir = NULL;
- }
-#if SUBDIRS
- if (qSxqt_dir != NULL)
- {
- (void) closedir (qSxqt_dir);
- qSxqt_dir = NULL;
- }
- ubuffree (zSdir);
- zSdir = NULL;
- ubuffree (zSsystem);
- zSsystem = NULL;
- fSone_dir = FALSE;
-#endif
-}
diff --git a/gnu/libexec/uucp/libunix/xqtsub.c b/gnu/libexec/uucp/libunix/xqtsub.c
deleted file mode 100644
index 4003b86..0000000
--- a/gnu/libexec/uucp/libunix/xqtsub.c
+++ /dev/null
@@ -1,711 +0,0 @@
-/* xqtsub.c
- System dependent functions used only by uuxqt.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char xqtsub_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "sysdep.h"
-
-#include <ctype.h>
-#include <errno.h>
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-#if HAVE_OPENDIR
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#else /* ! HAVE_DIRENT_H */
-#include <sys/dir.h>
-#define dirent direct
-#endif /* ! HAVE_DIRENT_H */
-#endif /* HAVE_OPENDIR */
-
-/* Get a value for EX_TEMPFAIL. */
-
-#if HAVE_SYSEXITS_H
-#include <sysexits.h>
-#endif
-
-#ifndef EX_TEMPFAIL
-#define EX_TEMPFAIL 75
-#endif
-
-/* Get the full pathname of the command to execute, given the list of
- permitted commands and the allowed path. */
-
-char *
-zsysdep_find_command (zcmd, pzcmds, pzpath, pferr)
- const char *zcmd;
- char **pzcmds;
- char **pzpath;
- boolean *pferr;
-{
- char **pz;
- struct stat s;
-
- *pferr = FALSE;
-
- for (pz = pzcmds; *pz != NULL; pz++)
- {
- char *zslash;
-
- if (strcmp (*pz, "ALL") == 0)
- break;
-
- zslash = strrchr (*pz, '/');
- if (zslash != NULL)
- ++zslash;
- else
- zslash = *pz;
- if (strcmp (zslash, zcmd) == 0
- || strcmp (*pz, zcmd) == 0)
- {
- /* If we already have an absolute path, we can get out
- immediately. */
- if (**pz == '/')
- {
- /* Quick error check. */
- if (stat (*pz, &s) != 0)
- {
- ulog (LOG_ERROR, "%s: %s", *pz, strerror (errno));
- *pferr = TRUE;
- return NULL;
- }
- return zbufcpy (*pz);
- }
- break;
- }
- }
-
- /* If we didn't find this command, get out. */
- if (*pz == NULL)
- return NULL;
-
- /* We didn't find an absolute pathname, so we must look through
- the path. */
- for (pz = pzpath; *pz != NULL; pz++)
- {
- char *zname;
-
- zname = zsysdep_in_dir (*pz, zcmd);
- if (stat (zname, &s) == 0)
- return zname;
- }
-
- return NULL;
-}
-
-/* Expand a local filename for uuxqt. This is special because uuxqt
- only wants to expand filenames that start with ~ (it does not want
- to prepend the current directory to other names) and if the ~ is
- double, it is turned into a single ~. This returns NULL to
- indicate that no change was required; it has no way to return
- error. */
-
-char *
-zsysdep_xqt_local_file (qsys, zfile)
- const struct uuconf_system *qsys;
- const char *zfile;
-{
- if (*zfile != '~')
- return NULL;
- if (zfile[1] == '~')
- {
- size_t clen;
- char *zret;
-
- clen = strlen (zfile);
- zret = zbufalc (clen);
- memcpy (zret, zfile + 1, clen);
- return zret;
- }
- return zsysdep_local_file (zfile, qsys->uuconf_zpubdir,
- (boolean *) NULL);
-}
-
-#if ! ALLOW_FILENAME_ARGUMENTS
-
-/* Check to see whether an argument specifies a file name; if it does,
- make sure that the file may legally be sent and/or received. For
- Unix, we do not permit any occurrence of "/../" in the name, nor
- may it start with "../". Otherwise, if it starts with "/" we check
- against the list of permitted files. */
-
-boolean
-fsysdep_xqt_check_file (qsys, zfile)
- const struct uuconf_system *qsys;
- const char *zfile;
-{
- size_t clen;
-
- /* Disallow exact "..", prefix "../", suffix "/..", internal "/../",
- and restricted absolute paths. */
- clen = strlen (zfile);
- if ((clen == sizeof ".." - 1
- && strcmp (zfile, "..") == 0)
- || strncmp (zfile, "../", sizeof "../" - 1) == 0
- || (clen >= sizeof "/.." - 1
- && strcmp (zfile + clen - (sizeof "/.." - 1), "/..") == 0)
- || strstr (zfile, "/../") != NULL
- || (*zfile == '/'
- && (! fin_directory_list (zfile, qsys->uuconf_pzremote_send,
- qsys->uuconf_zpubdir, TRUE, FALSE,
- (const char *) NULL)
- || ! fin_directory_list (zfile, qsys->uuconf_pzremote_receive,
- qsys->uuconf_zpubdir, TRUE, FALSE,
- (const char *) NULL))))
- {
- ulog (LOG_ERROR, "Not permitted to refer to file \"%s\"", zfile);
- return FALSE;
- }
-
- return TRUE;
-}
-
-#endif /* ! ALLOW_FILENAME_ARGUMENTS */
-
-/* Invoke the command specified by an execute file. */
-
-/*ARGSUSED*/
-boolean
-fsysdep_execute (qsys, zuser, pazargs, zfullcmd, zinput, zoutput,
- fshell, iseq, pzerror, pftemp)
- const struct uuconf_system *qsys;
- const char *zuser;
- const char **pazargs;
- const char *zfullcmd;
- const char *zinput;
- const char *zoutput;
- boolean fshell;
- int iseq;
- char **pzerror;
- boolean *pftemp;
-{
- int aidescs[3];
- boolean ferr;
- pid_t ipid;
- int ierr;
- char abxqtdir[sizeof XQTDIR + 4];
- const char *zxqtdir;
- int istat;
- char *zpath;
-#if ALLOW_SH_EXECUTION
- const char *azshargs[4];
-#endif
-
- *pzerror = NULL;
- *pftemp = FALSE;
-
- aidescs[0] = SPAWN_NULL;
- aidescs[1] = SPAWN_NULL;
- aidescs[2] = SPAWN_NULL;
-
- ferr = FALSE;
-
- if (zinput != NULL)
- {
- aidescs[0] = open ((char *) zinput, O_RDONLY | O_NOCTTY, 0);
- if (aidescs[0] < 0)
- {
- ulog (LOG_ERROR, "open (%s): %s", zinput, strerror (errno));
- ferr = TRUE;
- }
- else if (fcntl (aidescs[0], F_SETFD,
- fcntl (aidescs[0], F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- ferr = TRUE;
- }
- }
-
- if (! ferr && zoutput != NULL)
- {
- aidescs[1] = creat ((char *) zoutput, IPRIVATE_FILE_MODE);
- if (aidescs[1] < 0)
- {
- ulog (LOG_ERROR, "creat (%s): %s", zoutput, strerror (errno));
- *pftemp = TRUE;
- ferr = TRUE;
- }
- else if (fcntl (aidescs[1], F_SETFD,
- fcntl (aidescs[1], F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- ferr = TRUE;
- }
- }
-
- if (! ferr)
- {
- *pzerror = zstemp_file (qsys);
- aidescs[2] = creat (*pzerror, IPRIVATE_FILE_MODE);
- if (aidescs[2] < 0)
- {
- if (errno == ENOENT)
- {
- if (! fsysdep_make_dirs (*pzerror, FALSE))
- {
- *pftemp = TRUE;
- ferr = TRUE;
- }
- else
- aidescs[2] = creat (*pzerror, IPRIVATE_FILE_MODE);
- }
- if (! ferr && aidescs[2] < 0)
- {
- ulog (LOG_ERROR, "creat (%s): %s", *pzerror, strerror (errno));
- *pftemp = TRUE;
- ferr = TRUE;
- }
- }
- if (! ferr
- && fcntl (aidescs[2], F_SETFD,
- fcntl (aidescs[2], F_GETFD, 0) | FD_CLOEXEC) < 0)
- {
- ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
- ferr = TRUE;
- }
- }
-
- if (iseq == 0)
- zxqtdir = XQTDIR;
- else
- {
- sprintf (abxqtdir, "%s%04d", XQTDIR, iseq);
- zxqtdir = abxqtdir;
- }
-
- if (ferr)
- {
- if (aidescs[0] != SPAWN_NULL)
- (void) close (aidescs[0]);
- if (aidescs[1] != SPAWN_NULL)
- (void) close (aidescs[1]);
- if (aidescs[2] != SPAWN_NULL)
- (void) close (aidescs[2]);
- ubuffree (*pzerror);
- return FALSE;
- }
-
-#if ALLOW_SH_EXECUTION
- if (fshell)
- {
- azshargs[0] = "/bin/sh";
- azshargs[1] = "-c";
- azshargs[2] = zfullcmd;
- azshargs[3] = NULL;
- pazargs = azshargs;
- }
-#else
- fshell = FALSE;
-#endif
-
- if (qsys->uuconf_pzpath == NULL)
- zpath = NULL;
- else
- {
- size_t c;
- char **pz;
-
- c = 0;
- for (pz = qsys->uuconf_pzpath; *pz != NULL; pz++)
- c += strlen (*pz) + 1;
- zpath = zbufalc (c);
- *zpath = '\0';
- for (pz = qsys->uuconf_pzpath; *pz != NULL; pz++)
- {
- strcat (zpath, *pz);
- if (pz[1] != NULL)
- strcat (zpath, ":");
- }
- }
-
- /* Pass zchdir as zxqtdir, fnosigs as TRUE, fshell as TRUE if we
- aren't already using the shell. */
- ipid = ixsspawn (pazargs, aidescs, TRUE, FALSE, zxqtdir, TRUE,
- ! fshell, zpath, qsys->uuconf_zname, zuser);
-
- ierr = errno;
-
- ubuffree (zpath);
-
- if (aidescs[0] != SPAWN_NULL)
- (void) close (aidescs[0]);
- if (aidescs[1] != SPAWN_NULL)
- (void) close (aidescs[1]);
- if (aidescs[2] != SPAWN_NULL)
- (void) close (aidescs[2]);
-
- if (ipid < 0)
- {
- ulog (LOG_ERROR, "ixsspawn: %s", strerror (ierr));
- *pftemp = TRUE;
- return FALSE;
- }
-
- istat = ixswait ((unsigned long) ipid, "Execution");
-
- if (istat == EX_TEMPFAIL)
- *pftemp = TRUE;
-
- return istat == 0;
-}
-
-/* Lock a uuxqt process. */
-
-int
-ixsysdep_lock_uuxqt (zcmd, cmaxuuxqts)
- const char *zcmd;
- int cmaxuuxqts;
-{
- char ab[sizeof "LCK.XQT.9999"];
- int i;
-
- if (cmaxuuxqts <= 0 || cmaxuuxqts >= 10000)
- cmaxuuxqts = 9999;
- for (i = 0; i < cmaxuuxqts; i++)
- {
- sprintf (ab, "LCK.XQT.%d", i);
- if (fsdo_lock (ab, TRUE, (boolean *) NULL))
- break;
- }
- if (i >= cmaxuuxqts)
- return -1;
-
- if (zcmd != NULL)
- {
- char abcmd[sizeof "LXQ.123456789"];
-
- sprintf (abcmd, "LXQ.%.9s", zcmd);
- abcmd[strcspn (abcmd, " \t/")] = '\0';
- if (! fsdo_lock (abcmd, TRUE, (boolean *) NULL))
- {
- (void) fsdo_unlock (ab, TRUE);
- return -1;
- }
- }
-
- return i;
-}
-
-/* Unlock a uuxqt process. */
-
-boolean
-fsysdep_unlock_uuxqt (iseq, zcmd, cmaxuuxqts)
- int iseq;
- const char *zcmd;
- int cmaxuuxqts;
-{
- char ab[sizeof "LCK.XQT.9999"];
- boolean fret;
-
- fret = TRUE;
-
- sprintf (ab, "LCK.XQT.%d", iseq);
- if (! fsdo_unlock (ab, TRUE))
- fret = FALSE;
-
- if (zcmd != NULL)
- {
- char abcmd[sizeof "LXQ.123456789"];
-
- sprintf (abcmd, "LXQ.%.9s", zcmd);
- abcmd[strcspn (abcmd, " \t/")] = '\0';
- if (! fsdo_unlock (abcmd, TRUE))
- fret = FALSE;
- }
-
- return fret;
-}
-
-/* See whether a particular uuxqt command is locked (this depends on
- the implementation of fsdo_lock). */
-
-boolean
-fsysdep_uuxqt_locked (zcmd)
- const char *zcmd;
-{
- char ab[sizeof "LXQ.123456789"];
- struct stat s;
-
- sprintf (ab, "LXQ.%.9s", zcmd);
- return stat (ab, &s) == 0;
-}
-
-/* Lock a particular execute file. */
-
-boolean
-fsysdep_lock_uuxqt_file (zfile)
- const char *zfile;
-{
- char *zcopy, *z;
- boolean fret;
-
- zcopy = zbufcpy (zfile);
-
- z = strrchr (zcopy, '/');
- if (z == NULL)
- *zcopy = 'L';
- else
- *(z + 1) = 'L';
-
- fret = fsdo_lock (zcopy, TRUE, (boolean *) NULL);
- ubuffree (zcopy);
- return fret;
-}
-
-/* Unlock a particular execute file. */
-
-boolean
-fsysdep_unlock_uuxqt_file (zfile)
- const char *zfile;
-{
- char *zcopy, *z;
- boolean fret;
-
- zcopy = zbufcpy (zfile);
-
- z = strrchr (zcopy, '/');
- if (z == NULL)
- *zcopy = 'L';
- else
- *(z + 1) = 'L';
-
- fret = fsdo_unlock (zcopy, TRUE);
- ubuffree (zcopy);
- return fret;
-}
-
-/* Lock the execute directory. Since we use a different directory
- depending on which LCK.XQT.dddd file we got, there is actually no
- need to create a lock file. We do make sure that the directory
- exists, though. */
-
-boolean
-fsysdep_lock_uuxqt_dir (iseq)
- int iseq;
-{
- const char *zxqtdir;
- char abxqtdir[sizeof XQTDIR + 4];
-
- if (iseq == 0)
- zxqtdir = XQTDIR;
- else
- {
- sprintf (abxqtdir, "%s%04d", XQTDIR, iseq);
- zxqtdir = abxqtdir;
- }
-
- if (mkdir (zxqtdir, S_IRWXU) < 0
- && errno != EEXIST
- && errno != EISDIR)
- {
- ulog (LOG_ERROR, "mkdir (%s): %s", zxqtdir, strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Unlock the execute directory and clear it out. The lock is
- actually the LCK.XQT.dddd file, so we don't unlock it, but we do
- remove all the files. */
-
-boolean
-fsysdep_unlock_uuxqt_dir (iseq)
- int iseq;
-{
- const char *zxqtdir;
- char abxqtdir[sizeof XQTDIR + 4];
- DIR *qdir;
-
- if (iseq == 0)
- zxqtdir = XQTDIR;
- else
- {
- sprintf (abxqtdir, "%s%04d", XQTDIR, iseq);
- zxqtdir = abxqtdir;
- }
-
- qdir = opendir ((char *) zxqtdir);
- if (qdir != NULL)
- {
- struct dirent *qentry;
-
- while ((qentry = readdir (qdir)) != NULL)
- {
- char *z;
-
- if (strcmp (qentry->d_name, ".") == 0
- || strcmp (qentry->d_name, "..") == 0)
- continue;
- z = zsysdep_in_dir (zxqtdir, qentry->d_name);
- if (remove (z) < 0)
- {
- int ierr;
-
- ierr = errno;
- if (! fsysdep_directory (z))
- ulog (LOG_ERROR, "remove (%s): %s", z,
- strerror (ierr));
- else
- (void) fsysdep_rmdir (z);
- }
- ubuffree (z);
- }
-
- closedir (qdir);
- }
-
- return TRUE;
-}
-
-/* Move files into the execution directory. */
-
-boolean
-fsysdep_move_uuxqt_files (cfiles, pzfrom, pzto, fto, iseq, pzinput)
- int cfiles;
- const char *const *pzfrom;
- const char *const *pzto;
- boolean fto;
- int iseq;
- char **pzinput;
-{
- char *zinput;
- const char *zxqtdir;
- char abxqtdir[sizeof XQTDIR + 4];
- int i;
-
- if (pzinput == NULL)
- zinput = NULL;
- else
- zinput = *pzinput;
-
- if (iseq == 0)
- zxqtdir = XQTDIR;
- else
- {
- sprintf (abxqtdir, "%s%04d", XQTDIR, iseq);
- zxqtdir = abxqtdir;
- }
-
- for (i = 0; i < cfiles; i++)
- {
- const char *zfrom, *zto;
- char *zfree;
-
- if (pzto[i] == NULL)
- continue;
-
- zfree = zsysdep_in_dir (zxqtdir, pzto[i]);
-
- zfrom = pzfrom[i];
- zto = zfree;
-
- if (zinput != NULL && strcmp (zinput, zfrom) == 0)
- {
- *pzinput = zbufcpy (zto);
- zinput = NULL;
- }
-
- if (! fto)
- {
- const char *ztemp;
-
- ztemp = zfrom;
- zfrom = zto;
- zto = ztemp;
- (void) chmod (zfrom, IPRIVATE_FILE_MODE);
- }
-
- if (rename (zfrom, zto) < 0)
- {
-#if HAVE_RENAME
- /* On some systems the system call rename seems to fail for
- arbitrary reasons. To get around this, we always try to
- copy the file by hand if the rename failed. */
- errno = EXDEV;
-#endif
-
- if (errno != EXDEV)
- {
- ulog (LOG_ERROR, "rename (%s, %s): %s", zfrom, zto,
- strerror (errno));
- ubuffree (zfree);
- break;
- }
-
- if (! fcopy_file (zfrom, zto, FALSE, FALSE, FALSE))
- {
- ubuffree (zfree);
- break;
- }
- if (remove (zfrom) < 0)
- ulog (LOG_ERROR, "remove (%s): %s", zfrom,
- strerror (errno));
- }
-
- if (fto)
- (void) chmod (zto, IPUBLIC_FILE_MODE);
-
- ubuffree (zfree);
- }
-
- if (i < cfiles)
- {
- if (fto)
- (void) fsysdep_move_uuxqt_files (i, pzfrom, pzto, FALSE, iseq,
- (char **) NULL);
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libuuconf/COPYING.LIB b/gnu/libexec/uucp/libuuconf/COPYING.LIB
deleted file mode 100644
index eb685a5..0000000
--- a/gnu/libexec/uucp/libuuconf/COPYING.LIB
+++ /dev/null
@@ -1,481 +0,0 @@
- GNU LIBRARY GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the library GPL. It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it. You can use it for
-your libraries, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
-permission to copy, distribute and/or modify the library.
-
- Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library. If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software. To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
- Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs. This
-license, the GNU Library General Public License, applies to certain
-designated libraries. This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
- The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it. Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program. However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
- Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries. We
-concluded that weaker conditions might promote sharing better.
-
- However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves. This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them. (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.) The hope is that this
-will lead to faster development of free libraries.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, while the latter only
-works together with the library.
-
- Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-
- GNU LIBRARY GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License"). Each licensee is
-addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also compile or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- c) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- d) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/gnu/libexec/uucp/libuuconf/MANIFEST b/gnu/libexec/uucp/libuuconf/MANIFEST
deleted file mode 100644
index d4ca25e..0000000
--- a/gnu/libexec/uucp/libuuconf/MANIFEST
+++ /dev/null
@@ -1,94 +0,0 @@
-README
-COPYING.LIB
-MANIFEST
-Makefile.in
-alloc.h
-syshdr.unx
-uucnfi.h
-addblk.c
-addstr.c
-allblk.c
-alloc.c
-base.c
-bool.c
-callin.c
-calout.c
-chatc.c
-cmdarg.c
-cmdfil.c
-cmdlin.c
-debfil.c
-deblev.c
-diacod.c
-dial.c
-diasub.c
-dnams.c
-errno.c
-errstr.c
-filnam.c
-freblk.c
-fredia.c
-free.c
-freprt.c
-fresys.c
-grdcmp.c
-hdial.c
-hdnams.c
-hinit.c
-hlocnm.c
-hport.c
-hrmunk.c
-hsinfo.c
-hsnams.c
-hsys.c
-hunk.c
-iniglb.c
-init.c
-int.c
-lckdir.c
-lineno.c
-llocnm.c
-local.c
-locnm.c
-logfil.c
-maxuxq.c
-mrgblk.c
-paramc.c
-port.c
-pubdir.c
-prtsub.c
-rdlocs.c
-rdperm.c
-reliab.c
-remunk.c
-runuxq.c
-sinfo.c
-snams.c
-split.c
-spool.c
-stafil.c
-strip.c
-syssub.c
-tcalou.c
-tdial.c
-tdialc.c
-tdnams.c
-tgcmp.c
-thread.c
-time.c
-tinit.c
-tlocnm.c
-tport.c
-tportc.c
-tsinfo.c
-tsnams.c
-tsys.c
-tval.c
-ugtlin.c
-unk.c
-val.c
-vinit.c
-vport.c
-vsinfo.c
-vsnams.c
-vsys.c
diff --git a/gnu/libexec/uucp/libuuconf/Makefile b/gnu/libexec/uucp/libuuconf/Makefile
deleted file mode 100644
index 4fcfcde..0000000
--- a/gnu/libexec/uucp/libuuconf/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-# This is the Makefile for the Taylor UUCP uuconf library
-# $Id$
-
-LIB= uuconf
-SRCS = addblk.c addstr.c allblk.c alloc.c base.c bool.c callin.c \
- calout.c chatc.c cmdarg.c cmdfil.c cmdlin.c debfil.c deblev.c \
- diacod.c dial.c diasub.c dnams.c errno.c errstr.c filnam.c \
- freblk.c fredia.c free.c freprt.c fresys.c grdcmp.c hdial.c \
- hdnams.c hinit.c hlocnm.c hport.c hrmunk.c hsinfo.c hsnams.c \
- hsys.c hunk.c iniglb.c init.c int.c lckdir.c lineno.c llocnm.c \
- local.c locnm.c logfil.c maxuxq.c mrgblk.c paramc.c port.c \
- prtsub.c pubdir.c rdlocs.c rdperm.c reliab.c remunk.c runuxq.c \
- sinfo.c snams.c split.c spool.c stafil.c strip.c syssub.c \
- tcalou.c tdial.c tdialc.c tdnams.c tgcmp.c thread.c time.c \
- tinit.c tlocnm.c tport.c tportc.c tsinfo.c tsnams.c tsys.c \
- tval.c ugtlin.c unk.c val.c vinit.c vport.c vsinfo.c vsnams.c \
- vsys.c
-CFLAGS+= -I$(.CURDIR)/../common_sources \
- -DNEWCONFIGLIB=\"$(newconfigdir)\"\
- -DOLDCONFIGLIB=\"$(oldconfigdir)\"
-
-NOMAN= noman
-NOPROFILE= noprofile
-
-install:
-
-.include <bsd.lib.mk>
diff --git a/gnu/libexec/uucp/libuuconf/README b/gnu/libexec/uucp/libuuconf/README
deleted file mode 100644
index cc022ad..0000000
--- a/gnu/libexec/uucp/libuuconf/README
+++ /dev/null
@@ -1,113 +0,0 @@
-This is the README file for the beta release of the uuconf library.
-
-It was written by Ian Lance Taylor. I can be reached at ian@airs.com,
-or, equivalently, uunet!cygint!airs!ian, or c/o Cygnus Support,
-48 Grove Street, Somerville, MA, 02144, USA.
-
-This package is covered by the Gnu Library General Public License.
-See the file COPYING.LIB for details. If you would like to do
-something with this package that you feel is reasonable but you feel
-is prohibited by the license, contact me to see if we can work it out.
-
-WHAT IT IS
-
-This is a beta release of the uuconf library. The uuconf library
-provides a set of functions which can be used to read UUCP
-configuration files. V2, HDB, and Taylor UUCP configuration files are
-supported.
-
-Also included are two programs, uuchk and uuconv. uuchk will read
-configuration files and display the information it finds in a verbose
-format. This can be helpful to ensure that your configuration files
-are set up as you expect. uuconv can be used to convert configuration
-files from one type to another. This is particularly helpful for
-people installing Taylor UUCP on a existing system who want to take
-advantage of the additional functionality provided by the Taylor UUCP
-configuration files.
-
-This is strictly a beta release. The library provides all the
-information needed for uuchk and uuconv, but does not yet provide
-everything needed for uucp or cu. I am releasing it now to get
-feedback and to provide the uuconv program to people using Taylor
-UUCP.
-
-This may well be the only time this library is release independently.
-This library will be provided with Taylor UUCP, and future releases of
-the library will probably only occur as part of the complete Taylor
-UUCP package.
-
-HOW TO USE IT
-
-Configure and optionally install the package as described in INSTALL.
-
-The functions provided by the library are described in uuconf.h. At
-the moment there is no additional documentation.
-
-Programs which use the library should include uuconf.h, and should not
-include any of the other header files. The functions listed in
-uuconf.h all begin with the string "uuconf_". The internal library
-functions all begin with the string "_uuconf_". The internal library
-functions should not be called by a program which uses the library, as
-they may change in future releases. The uuchk program is an example
-of program which uses the library; uuconv is not, as it relies upon
-internal data structures.
-
-The uuchk program takes a single optional option, -I, which may be
-used to specify an alternate Taylor UUCP main configuration file. The
-default configuration file is $(newconfigdir)/config ($(newconfigdir)
-is defined in Makefile). For example:
- uuchk
- uuchk -I /usr/tmp/tstuu/Config1
-
-The uuconv program requires two options: -i to specify the input type
-and -o to specify the output type. Both options take a string
-argument, which must be one of "v2", "hdb", or "taylor". uuconv also
-takes an optional -I option, which is the same as the -I option to
-uuchk. The conversion is not intended to be perfect, and the results
-should be manually inspected. In particular, the dialcode file is not
-converted (as the format is the same for all three configuration file
-types, it may simply be copied to the appropriate new name). uuconv
-will create new files in the current working directory. For example:
- uuconv -i hdb -o taylor
- uuconv -i taylor -I /usr/tmp/tstuu/Config1 -o v2
-
-NOTES
-
-The initial underscore on the internal library functions is required
-by the GNU standards. As ANSI C reserves external identifiers with an
-initial underscore for the implementation, it is possible, though
-unlikely, that this will cause problems on other implementations; no
-workaround is currently provided for such problems.
-
-The library functions rely upon the following functions:
-
- fclose fopen free fseek
- ftell getc isalpha isdigit
- islower isspace isupper malloc
- realloc rewind strchr strcmp
- strcspn strlen strncmp strspn
- tolower toupper
-
-and the following header files:
-
- ctype.h errno.h stdio.h
-
-If the following functions cannot be found by the configure script,
-replacements will be used (the replacement for strerror is Unix
-dependent):
-
- getline memcpy strcasecmp strdup
- strerror strncasecmp strtol
-
-If the following header files are found, they will be included:
-
- libc.h limits.h memory.h stddef.h
- stdlib.h string.h strings.h sys/types.h
-
-The following functions are required on Unix only:
-
- fcntl fileno
-
-The following headers are used, if found, on Unix only:
-
- fcntl.h sys/file.h
diff --git a/gnu/libexec/uucp/libuuconf/addblk.c b/gnu/libexec/uucp/libuuconf/addblk.c
deleted file mode 100644
index 06c33e8..0000000
--- a/gnu/libexec/uucp/libuuconf/addblk.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* addblk.c
- Add an malloc block to a memory block.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_addblk_rcsid[] = "$Id$";
-#endif
-
-#include "alloc.h"
-
-/* Add a memory buffer allocated by malloc to a memory block. This is
- used by the uuconf_cmd functions so that they don't have to
- constantly copy data into memory. Returns 0 on success, non 0 on
- failure. */
-
-int
-uuconf_add_block (pblock, padd)
- pointer pblock;
- pointer padd;
-{
- struct sblock *q = (struct sblock *) pblock;
- struct sadded *qnew;
-
- qnew = (struct sadded *) uuconf_malloc (pblock, sizeof (struct sadded));
- if (qnew == NULL)
- return 1;
-
- qnew->qnext = q->qadded;
- qnew->padded = padd;
- q->qadded = qnew;
-
- return 0;
-}
diff --git a/gnu/libexec/uucp/libuuconf/addstr.c b/gnu/libexec/uucp/libuuconf/addstr.c
deleted file mode 100644
index 9a6fbc3..0000000
--- a/gnu/libexec/uucp/libuuconf/addstr.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* addstr.c
- Add a string to a list of strings.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_addstr_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* When setting system information, we need to be able to distinguish
- between a value that is not set and a value that has been set to
- NULL. We do this by initializing the value to point to the
- variable _uuconf_unset, and then correcting it in the function
- _uuconf_isystem_basic_default. This variable is declared in this
- file because some linkers will apparently not pull in an object
- file which merely declarates a variable. This functions happens to
- be pulled in by almost everything. */
-
-char *_uuconf_unset;
-
-/* Add a string to a list of strings. The list is maintained as an
- array of elements ending in NULL. The total number of available
- slots is always a multiple of CSLOTS, so by counting the current
- number of elements we can tell whether a new slot is needed. If
- the fcopy argument is TRUE, the new string is duplicated into
- memory. If the fcheck argument is TRUE, this does not add a string
- that is already in the list. The pblock argument may be used to do
- the allocations within a memory block. This returns a standard
- uuconf error code. */
-
-#define CSLOTS (8)
-
-int
-_uuconf_iadd_string (qglobal, zadd, fcopy, fcheck, ppzstrings, pblock)
- struct sglobal *qglobal;
- char *zadd;
- boolean fcopy;
- boolean fcheck;
- char ***ppzstrings;
- pointer pblock;
-{
- char **pz;
- size_t c;
-
- if (fcheck && *ppzstrings != NULL)
- {
- for (pz = *ppzstrings; *pz != NULL; pz++)
- if (strcmp (zadd, *pz) == 0)
- return UUCONF_SUCCESS;
- }
-
- if (fcopy)
- {
- size_t clen;
- char *znew;
-
- clen = strlen (zadd) + 1;
- znew = (char *) uuconf_malloc (pblock, clen);
- if (znew == NULL)
- {
- if (qglobal != NULL)
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- memcpy ((pointer) znew, (pointer) zadd, clen);
- zadd = znew;
- }
-
- pz = *ppzstrings;
- if (pz == NULL || pz == (char **) &_uuconf_unset)
- {
- pz = (char **) uuconf_malloc (pblock, CSLOTS * sizeof (char *));
- if (pz == NULL)
- {
- if (qglobal != NULL)
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- *ppzstrings = pz;
- }
- else
- {
- c = 0;
- while (*pz != NULL)
- {
- ++pz;
- ++c;
- }
-
- if ((c + 1) % CSLOTS == 0)
- {
- char **pznew;
-
- pznew = (char **) uuconf_malloc (pblock,
- ((c + 1 + CSLOTS)
- * sizeof (char *)));
- if (pznew == NULL)
- {
- if (qglobal != NULL)
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- memcpy ((pointer) pznew, (pointer) *ppzstrings,
- c * sizeof (char *));
- uuconf_free (pblock, *ppzstrings);
- *ppzstrings = pznew;
- pz = pznew + c;
- }
- }
-
- pz[0] = zadd;
- pz[1] = NULL;
-
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/allblk.c b/gnu/libexec/uucp/libuuconf/allblk.c
deleted file mode 100644
index d099477..0000000
--- a/gnu/libexec/uucp/libuuconf/allblk.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* allblk.c
- Allocate a memory block.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_allblk_rcsid[] = "$Id$";
-#endif
-
-#include "alloc.h"
-
-/* Allocate a new memory block. If this fails, uuconf_errno will be
- set, and the calling routine may return UUCONF_MALLOC_FAILED |
- UUCONF_ERROR_ERRNO. */
-
-pointer
-uuconf_malloc_block ()
-{
- struct sblock *qret;
-
- qret = (struct sblock *) malloc (sizeof (struct sblock));
- if (qret == NULL)
- return NULL;
- qret->qnext = NULL;
- qret->ifree = 0;
- qret->plast = NULL;
- qret->qadded = NULL;
- return (pointer) qret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/alloc.c b/gnu/libexec/uucp/libuuconf/alloc.c
deleted file mode 100644
index fa9cd65..0000000
--- a/gnu/libexec/uucp/libuuconf/alloc.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* alloc.c
- Allocate within a memory block.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_alloc_rcsid[] = "$Id$";
-#endif
-
-#include "alloc.h"
-
-/* Allocate some memory out of a memory block. If the memory block is
- NULL, this just calls malloc; this is convenient for a number of
- routines. If this fails, uuconf_errno will be set, and the calling
- routine may return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO. */
-
-pointer
-uuconf_malloc (pblock, c)
- pointer pblock;
- size_t c;
-{
- struct sblock *q = (struct sblock *) pblock;
- pointer pret;
-
- if (c == 0)
- return NULL;
-
- if (q == NULL)
- return malloc (c);
-
- /* Make sure that c is aligned to a double boundary. */
- c = ((c + sizeof (double) - 1) / sizeof (double)) * sizeof (double);
-
- while (q->ifree + c > CALLOC_SIZE)
- {
- if (q->qnext != NULL)
- q = q->qnext;
- else
- {
- if (c > CALLOC_SIZE)
- q->qnext = (struct sblock *) malloc (sizeof (struct sblock)
- + c - CALLOC_SIZE);
- else
- q->qnext = (struct sblock *) malloc (sizeof (struct sblock));
- if (q->qnext == NULL)
- return NULL;
- q = q->qnext;
- q->qnext = NULL;
- q->ifree = 0;
- q->qadded = NULL;
- break;
- }
- }
-
- pret = q->u.ab + q->ifree;
- q->ifree += c;
- q->plast = pret;
-
- return pret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/alloc.h b/gnu/libexec/uucp/libuuconf/alloc.h
deleted file mode 100644
index d35e0fb..0000000
--- a/gnu/libexec/uucp/libuuconf/alloc.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* alloc.h
- Header file for uuconf memory allocation routines.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-/* This header file is private to the uuconf memory allocation
- routines, and should not be included by any other files. */
-
-/* We want to be able to keep track of allocated memory blocks, so
- that we can free them up later. This will let us free up all the
- memory allocated to hold information for a system, for example. We
- do this by allocating large chunks and doling them out. Calling
- uuconf_malloc_block will return a pointer to a magic cookie which
- can then be passed to uuconf_malloc and uuconf_free. Passing the
- pointer to uuconf_free_block will free all memory allocated for
- that block. */
-
-/* We allocate this much space in each block. On most systems, this
- will make the actual structure 1024 bytes, which may be convenient
- for some types of memory allocators. */
-#define CALLOC_SIZE (1008)
-
-/* This is the actual structure of a block. */
-struct sblock
-{
- /* Next block in linked list. */
- struct sblock *qnext;
- /* Index of next free spot. */
- size_t ifree;
- /* Last value returned by uuconf_malloc for this block. */
- pointer plast;
- /* List of additional memory blocks. */
- struct sadded *qadded;
- /* Buffer of data. We put it in a union with a double to make sure
- it is adequately aligned. */
- union
- {
- char ab[CALLOC_SIZE];
- double l;
- } u;
-};
-
-/* There is a linked list of additional memory blocks inserted by
- uuconf_add_block. */
-struct sadded
-{
- /* The next in the list. */
- struct sadded *qnext;
- /* The added block. */
- pointer padded;
-};
diff --git a/gnu/libexec/uucp/libuuconf/base.c b/gnu/libexec/uucp/libuuconf/base.c
deleted file mode 100644
index a5848a6..0000000
--- a/gnu/libexec/uucp/libuuconf/base.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* base.c
- Subroutine to turn a cmdtab_offset table into a uuconf_cmdtab table.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_base_rcsid[] = "$Id$";
-#endif
-
-/* This turns a cmdtab_offset table into a uuconf_cmdtab table. Each
- offset is adjusted by a base value. */
-
-void
-_uuconf_ucmdtab_base (qoff, celes, pbase, qset)
- register const struct cmdtab_offset *qoff;
- size_t celes;
- char *pbase;
- register struct uuconf_cmdtab *qset;
-{
- register size_t i;
-
- for (i = 0; i < celes; i++, qoff++, qset++)
- {
- qset->uuconf_zcmd = qoff->zcmd;
- qset->uuconf_itype = qoff->itype;
- if (qoff->ioff == (size_t) -1)
- qset->uuconf_pvar = NULL;
- else
- qset->uuconf_pvar = pbase + qoff->ioff;
- qset->uuconf_pifn = qoff->pifn;
- }
-}
diff --git a/gnu/libexec/uucp/libuuconf/bool.c b/gnu/libexec/uucp/libuuconf/bool.c
deleted file mode 100644
index a3e1702..0000000
--- a/gnu/libexec/uucp/libuuconf/bool.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* bool.c
- Parse a boolean string into a variable.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_bool_rcsid[] = "$Id$";
-#endif
-
-/* Parse a boolean string into a variable. This is called by
- uuconf_cmd_args, as well as other functions. The parsing is done
- in a single place to make it easy to change. This should return an
- error code, including both UUCONF_CMDTABRET_KEEP and
- UUCONF_CMDTABRET_EXIT if appropriate. */
-
-/*ARGSIGNORED*/
-int
-_uuconf_iboolean (qglobal, zval, pi)
- struct sglobal *qglobal;
- const char *zval;
- boolean *pi;
-{
- switch (*zval)
- {
- case 'y':
- case 'Y':
- case 't':
- case 'T':
- *pi = TRUE;
- break;
- case 'n':
- case 'N':
- case 'f':
- case 'F':
- *pi = FALSE;
- break;
- default:
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
- }
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
diff --git a/gnu/libexec/uucp/libuuconf/callin.c b/gnu/libexec/uucp/libuuconf/callin.c
deleted file mode 100644
index c7bda6a..0000000
--- a/gnu/libexec/uucp/libuuconf/callin.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/* callin.c
- Check a login name and password against the UUCP password file.
-
- Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_callin_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-static int ipcheck P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-
-struct sinfo
-{
- int (*pcmpfn) P((int, pointer, const char *));
- pointer pinfo;
- boolean ffound;
- boolean fmatched;
-};
-
-/* Check a login name and password against the UUCP password file.
- This looks at the Taylor UUCP password file, but will work even if
- uuconf_taylor_init was not called. It accepts either spaces or
- colons as field delimiters. */
-
-int
-uuconf_callin (pglobal, pcmpfn, pinfo)
- pointer pglobal;
- int (*pcmpfn) P((int, pointer, const char *));
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
- char **pz;
- struct uuconf_cmdtab as[1];
- struct sinfo s;
- char *zline;
- size_t cline;
-
- /* If we have no password file names, fill in the default name. */
- if (qglobal->qprocess->pzpwdfiles == NULL)
- {
- char ab[sizeof NEWCONFIGLIB + sizeof PASSWDFILE - 1];
-
- memcpy ((pointer) ab, (pointer) NEWCONFIGLIB,
- sizeof NEWCONFIGLIB - 1);
- memcpy ((pointer) (ab + sizeof NEWCONFIGLIB - 1), (pointer) PASSWDFILE,
- sizeof PASSWDFILE);
- iret = _uuconf_iadd_string (qglobal, ab, TRUE, FALSE,
- &qglobal->qprocess->pzpwdfiles,
- qglobal->pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- as[0].uuconf_zcmd = NULL;
-
- s.pcmpfn = pcmpfn;
- s.pinfo = pinfo;
- s.ffound = FALSE;
- s.fmatched = FALSE;
-
- zline = NULL;
- cline = 0;
-
- iret = UUCONF_SUCCESS;
-
- for (pz = qglobal->qprocess->pzpwdfiles; *pz != NULL; pz++)
- {
- FILE *e;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- qglobal->ilineno = 0;
-
- iret = UUCONF_SUCCESS;
-
- while (getline (&zline, &cline, e) > 0)
- {
- char *z0, *z1;
-
- ++qglobal->ilineno;
-
- /* We have a few hacks to make Unix style passwd files work.
- 1) We turn the first two colon characters into spaces.
- 2) If the colon characters are adjacent, we assume there
- is no password, and we skip the entry.
- 3) If the password between colon characters contains a
- space, we assume that it has been disabled, and we
- skip the entry. */
- z0 = strchr (zline, ':');
- if (z0 != NULL)
- {
- *z0 = ' ';
- z1 = strchr (z0, ':');
- if (z1 != NULL)
- {
- if (z1 - z0 == 1)
- continue;
- *z1 = '\0';
- if (strchr (z0 + 1, ' ') != NULL)
- continue;
- }
- }
- iret = uuconf_cmd_line (pglobal, zline, as, (pointer) &s,
- ipcheck, 0, (pointer) NULL);
- if ((iret & UUCONF_CMDTABRET_EXIT) != 0)
- {
- iret &=~ UUCONF_CMDTABRET_EXIT;
- if (iret != UUCONF_SUCCESS)
- iret |= UUCONF_ERROR_LINENO;
- break;
- }
-
- iret = UUCONF_SUCCESS;
- }
-
- (void) fclose (e);
-
- if (iret != UUCONF_SUCCESS || s.ffound)
- break;
- }
-
- if (zline != NULL)
- free ((pointer) zline);
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = *pz;
- iret |= UUCONF_ERROR_FILENAME;
- }
- else if (! s.ffound || ! s.fmatched)
- iret = UUCONF_NOT_FOUND;
-
- return iret;
-}
-
-/* This is called on each line of the file. It checks to see if the
- login name from the file is the one we are looking for. If it is,
- it sets ffound, and then sets fmatched according to whether the
- password matches or not. */
-
-static int
-ipcheck (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sinfo *q = (struct sinfo *) pinfo;
-
- if (argc != 2)
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- if (! (*q->pcmpfn) (0, q->pinfo, argv[0]))
- return UUCONF_CMDTABRET_CONTINUE;
-
- q->ffound = TRUE;
- q->fmatched = (*q->pcmpfn) (1, q->pinfo, argv[1]) != 0;
-
- return UUCONF_CMDTABRET_EXIT;
-}
diff --git a/gnu/libexec/uucp/libuuconf/calout.c b/gnu/libexec/uucp/libuuconf/calout.c
deleted file mode 100644
index 80567c1..0000000
--- a/gnu/libexec/uucp/libuuconf/calout.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* calout.c
- Find callout login name and password for a system.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_calout_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Find callout login name and password for a system. */
-
-/*ARGSUSED*/
-int
-uuconf_callout (pglobal, qsys, pzlog, pzpass)
- pointer pglobal;
- const struct uuconf_system *qsys;
- char **pzlog;
- char **pzpass;
-{
-#if HAVE_TAYLOR_CONFIG
-
- return uuconf_taylor_callout (pglobal, qsys, pzlog, pzpass);
-
-#else /* ! HAVE_TAYLOR_CONFIG */
-
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pzlog = NULL;
- *pzpass = NULL;
-
- if (qsys->uuconf_zcall_login == NULL
- && qsys->uuconf_zcall_password == NULL)
- return UUCONF_NOT_FOUND;
-
- if ((qsys->uuconf_zcall_login != NULL
- && strcmp (qsys->uuconf_zcall_login, "*") == 0)
- || (qsys->uuconf_zcall_password != NULL
- && strcmp (qsys->uuconf_zcall_password, "*") == 0))
- return UUCONF_NOT_FOUND;
-
- if (qsys->uuconf_zcall_login != NULL)
- {
- *pzlog = strdup (qsys->uuconf_zcall_login);
- if (*pzlog == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- }
-
- if (qsys->uuconf_zcall_password != NULL)
- {
- *pzpass = strdup (qsys->uuconf_zcall_password);
- if (*pzpass == NULL)
- {
- qglobal->ierrno = errno;
- if (*pzlog != NULL)
- {
- free ((pointer) *pzlog);
- *pzlog = NULL;
- }
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- }
-
- return UUCONF_SUCCESS;
-
-#endif /* ! HAVE_TAYLOR_CONFIG */
-}
diff --git a/gnu/libexec/uucp/libuuconf/chatc.c b/gnu/libexec/uucp/libuuconf/chatc.c
deleted file mode 100644
index bb1c484..0000000
--- a/gnu/libexec/uucp/libuuconf/chatc.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/* chatc.c
- Subroutines to handle chat script commands.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_chatc_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-static int icchat P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int icchat_fail P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int icunknown P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-
-/* The chat script commands. */
-
-static const struct cmdtab_offset asChat_cmds[] =
-{
- { "chat", UUCONF_CMDTABTYPE_FN,
- offsetof (struct uuconf_chat, uuconf_pzchat), icchat },
- { "chat-program", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_chat, uuconf_pzprogram), NULL },
- { "chat-timeout", UUCONF_CMDTABTYPE_INT,
- offsetof (struct uuconf_chat, uuconf_ctimeout), NULL },
- { "chat-fail", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct uuconf_chat, uuconf_pzfail), icchat_fail },
- { "chat-seven-bit", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_chat, uuconf_fstrip), NULL },
- { NULL, 0, 0, NULL }
-};
-
-#define CCHAT_CMDS (sizeof asChat_cmds / sizeof asChat_cmds[0])
-
-/* Handle a chat script command. The chat script commands are entered
- as UUCONF_CMDTABTYPE_PREFIX, and the commands are routed to this
- function. We copy the command table onto the stack and repoint it
- at qchat in order to make the function reentrant. The return value
- can include UUCONF_CMDTABRET_KEEP, but should not include
- UUCONF_CMDTABRET_EXIT. */
-
-int
-_uuconf_ichat_cmd (qglobal, argc, argv, qchat, pblock)
- struct sglobal *qglobal;
- int argc;
- char **argv;
- struct uuconf_chat *qchat;
- pointer pblock;
-{
- char *zchat;
- struct uuconf_cmdtab as[CCHAT_CMDS];
- int iret;
-
- /* This is only invoked when argv[0] will contain the string "chat";
- the specific chat script command comes after that point. */
- for (zchat = argv[0]; *zchat != '\0'; zchat++)
- if ((*zchat == 'c' || *zchat == 'C')
- && strncasecmp (zchat, "chat", sizeof "chat" - 1) == 0)
- break;
- if (*zchat == '\0')
- return UUCONF_SYNTAX_ERROR;
- argv[0] = zchat;
-
- _uuconf_ucmdtab_base (asChat_cmds, CCHAT_CMDS, (char *) qchat, as);
-
- iret = uuconf_cmd_args ((pointer) qglobal, argc, argv, as, pblock,
- icunknown, 0, pblock);
- return iret &~ UUCONF_CMDTABRET_EXIT;
-}
-
-/* Handle the "chat" command. This breaks up substrings in expect
- strings, and sticks the arguments into a NULL terminated array. */
-
-static int
-icchat (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char ***ppz = (char ***) pvar;
- pointer pblock = pinfo;
- int i;
-
- *ppz = NULL;
-
- for (i = 1; i < argc; i += 2)
- {
- char *z, *zdash;
- int iret;
-
- /* Break the expect string into substrings. */
- z = argv[i];
- zdash = strchr (z, '-');
- while (zdash != NULL)
- {
- *zdash = '\0';
- iret = _uuconf_iadd_string (qglobal, z, TRUE, FALSE, ppz,
- pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
- *zdash = '-';
- z = zdash;
- zdash = strchr (z + 1, '-');
- }
-
- iret = _uuconf_iadd_string (qglobal, z, FALSE, FALSE, ppz, pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
-
- /* Add the send string without breaking it up. If it starts
- with a dash we must replace it with an escape sequence, to
- prevent it from being interpreted as a subsend. */
-
- if (i + 1 < argc)
- {
- if (argv[i + 1][0] != '-')
- iret = _uuconf_iadd_string (qglobal, argv[i + 1], FALSE,
- FALSE, ppz, pblock);
- else
- {
- size_t clen;
-
- clen = strlen (argv[i + 1]);
- z = uuconf_malloc (pblock, clen + 2);
- if (z == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- z[0] = '\\';
- memcpy ((pointer) (z + 1), (pointer) argv[i + 1], clen + 1);
- iret = _uuconf_iadd_string (qglobal, z, FALSE, FALSE, ppz,
- pblock);
- }
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- }
-
- return UUCONF_CMDTABRET_KEEP;
-}
-
-/* Add a new chat failure string. */
-
-/*ARGSUSED*/
-static int
-icchat_fail (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char ***ppz = (char ***) pvar;
- pointer pblock = pinfo;
-
- return _uuconf_iadd_string (qglobal, argv[1], TRUE, FALSE, ppz, pblock);
-}
-
-/* Return a syntax error for an unknown command. */
-
-/*ARGSUSED*/
-static int
-icunknown (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- return UUCONF_SYNTAX_ERROR;
-}
diff --git a/gnu/libexec/uucp/libuuconf/cmdarg.c b/gnu/libexec/uucp/libuuconf/cmdarg.c
deleted file mode 100644
index 2175d98..0000000
--- a/gnu/libexec/uucp/libuuconf/cmdarg.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/* cmdarg.c
- Look up a command with arguments in a command table.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_cmdarg_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-
-#undef strcmp
-#if HAVE_STRCASECMP
-#undef strcasecmp
-#endif
-extern int strcmp (), strcasecmp ();
-
-/* Look up a command with arguments in a table and execute it. */
-
-int
-uuconf_cmd_args (pglobal, cargs, pzargs, qtab, pinfo, pfiunknown, iflags,
- pblock)
- pointer pglobal;
- int cargs;
- char **pzargs;
- const struct uuconf_cmdtab *qtab;
- pointer pinfo;
- int (*pfiunknown) P((pointer, int, char **, pointer, pointer));
- int iflags;
- pointer pblock;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int bfirstu, bfirstl;
- int (*pficmp) P((const char *, const char *));
- register const struct uuconf_cmdtab *q;
- int itype;
- int callowed;
-
- bfirstu = bfirstl = pzargs[0][0];
- if ((iflags & UUCONF_CMDTABFLAG_CASE) != 0)
- pficmp = strcmp;
- else
- {
- if (islower (bfirstu))
- bfirstu = toupper (bfirstu);
- if (isupper (bfirstl))
- bfirstl = tolower (bfirstl);
- pficmp = strcasecmp;
- }
-
- itype = 0;
-
- for (q = qtab; q->uuconf_zcmd != NULL; q++)
- {
- int bfirst;
-
- bfirst = q->uuconf_zcmd[0];
- if (bfirst != bfirstu && bfirst != bfirstl)
- continue;
-
- itype = UUCONF_TTYPE_CMDTABTYPE (q->uuconf_itype);
- if (itype != UUCONF_CMDTABTYPE_PREFIX)
- {
- if ((*pficmp) (q->uuconf_zcmd, pzargs[0]) == 0)
- break;
- }
- else
- {
- size_t clen;
-
- clen = strlen (q->uuconf_zcmd);
- if ((iflags & UUCONF_CMDTABFLAG_CASE) != 0)
- {
- if (strncmp (q->uuconf_zcmd, pzargs[0], clen) == 0)
- break;
- }
- else
- {
- if (strncasecmp (q->uuconf_zcmd, pzargs[0], clen) == 0)
- break;
- }
- }
- }
-
- if (q->uuconf_zcmd == NULL)
- {
- if (pfiunknown == NULL)
- return UUCONF_CMDTABRET_CONTINUE;
- return (*pfiunknown) (pglobal, cargs, pzargs, (pointer) NULL, pinfo);
- }
-
- callowed = UUCONF_CARGS_CMDTABTYPE (q->uuconf_itype);
- if (callowed != 0 && callowed != cargs)
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- switch (itype)
- {
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_STRING):
- if (cargs == 1)
- *(char **) q->uuconf_pvar = (char *) "";
- else if (cargs == 2)
- *(char **) q->uuconf_pvar = pzargs[1];
- else
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- return UUCONF_CMDTABRET_KEEP;
-
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_INT):
- return _uuconf_iint (qglobal, pzargs[1], q->uuconf_pvar, TRUE);
-
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_LONG):
- return _uuconf_iint (qglobal, pzargs[1], q->uuconf_pvar, FALSE);
-
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_BOOLEAN):
- return _uuconf_iboolean (qglobal, pzargs[1], (int *) q->uuconf_pvar);
-
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_FULLSTRING):
- if (cargs == 1)
- {
- char ***ppz = (char ***) q->uuconf_pvar;
- int iret;
-
- *ppz = NULL;
- iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
- ppz, pblock);
- if (iret != UUCONF_SUCCESS)
- return iret | UUCONF_CMDTABRET_EXIT;
-
- return UUCONF_CMDTABRET_CONTINUE;
- }
- else
- {
- char ***ppz = (char ***) q->uuconf_pvar;
- int i;
-
- *ppz = NULL;
- for (i = 1; i < cargs; i++)
- {
- int iret;
-
- iret = _uuconf_iadd_string (qglobal, pzargs[i], FALSE, FALSE,
- ppz, pblock);
- if (iret != UUCONF_SUCCESS)
- {
- *ppz = NULL;
- return iret | UUCONF_CMDTABRET_EXIT;
- }
- }
-
- return UUCONF_CMDTABRET_KEEP;
- }
-
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_FN):
- case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_PREFIX):
- return (*q->uuconf_pifn) (pglobal, cargs, pzargs, q->uuconf_pvar,
- pinfo);
-
- default:
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
- }
-
- /*NOTREACHED*/
-}
diff --git a/gnu/libexec/uucp/libuuconf/cmdfil.c b/gnu/libexec/uucp/libuuconf/cmdfil.c
deleted file mode 100644
index d463cf1..0000000
--- a/gnu/libexec/uucp/libuuconf/cmdfil.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* cmdfil.c
- Read and parse commands from a file.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_cmdfil_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Read and parse commands from a file, updating uuconf_lineno as
- appropriate. */
-
-int
-uuconf_cmd_file (pglobal, e, qtab, pinfo, pfiunknown, iflags, pblock)
- pointer pglobal;
- FILE *e;
- const struct uuconf_cmdtab *qtab;
- pointer pinfo;
- int (*pfiunknown) P((pointer, int, char **, pointer, pointer));
- int iflags;
- pointer pblock;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- boolean fcont;
- char *zline;
- size_t cline;
- int iret;
-
- fcont = (iflags & UUCONF_CMDTABFLAG_BACKSLASH) != 0;
-
- zline = NULL;
- cline = 0;
-
- iret = UUCONF_SUCCESS;
-
- qglobal->ilineno = 0;
-
- while ((fcont
- ? _uuconf_getline (qglobal, &zline, &cline, e)
- : getline (&zline, &cline, e)) > 0)
- {
- ++qglobal->ilineno;
-
- iret = uuconf_cmd_line (pglobal, zline, qtab, pinfo, pfiunknown,
- iflags, pblock);
-
- if ((iret & UUCONF_CMDTABRET_KEEP) != 0)
- {
- iret &=~ UUCONF_CMDTABRET_KEEP;
-
- if (pblock != NULL)
- {
- if (uuconf_add_block (pblock, zline) != 0)
- {
- qglobal->ierrno = errno;
- iret = (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_ERROR_LINENO);
- break;
- }
- }
-
- zline = NULL;
- cline = 0;
- }
-
- if ((iret & UUCONF_CMDTABRET_EXIT) != 0)
- {
- iret &=~ UUCONF_CMDTABRET_EXIT;
- if (iret != UUCONF_SUCCESS)
- iret |= UUCONF_ERROR_LINENO;
- break;
- }
-
- iret = UUCONF_SUCCESS;
- }
-
- if (zline != NULL)
- free ((pointer) zline);
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/cmdlin.c b/gnu/libexec/uucp/libuuconf/cmdlin.c
deleted file mode 100644
index fcc9535..0000000
--- a/gnu/libexec/uucp/libuuconf/cmdlin.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/* cmdlin.c
- Parse a command line.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_cmdlin_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-/* Parse a command line into fields and process it via a command
- table. The command table functions may keep the memory allocated
- for the line, but they may not keep the memory allocated for the
- argv list. This function strips # comments. */
-
-#define CSTACK (16)
-
-int
-uuconf_cmd_line (pglobal, zline, qtab, pinfo, pfiunknown, iflags, pblock)
- pointer pglobal;
- char *zline;
- const struct uuconf_cmdtab *qtab;
- pointer pinfo;
- int (*pfiunknown) P((pointer, int, char **, pointer, pointer));
- int iflags;
- pointer pblock;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char *z;
- int cargs;
- char *azargs[CSTACK];
- char **pzargs;
- int iret;
-
- if ((iflags & UUCONF_CMDTABFLAG_NOCOMMENTS) == 0)
- {
- /* Any # not preceeded by a backslash starts a comment. */
- z = zline;
- while ((z = strchr (z, '#')) != NULL)
- {
- if (z == zline || *(z - 1) != '\\')
- {
- *z = '\0';
- break;
- }
- /* Remove the backslash. */
- while ((*(z - 1) = *z) != '\0')
- ++z;
- }
- }
-
- /* Parse the first CSTACK arguments by hand to avoid malloc. */
-
- z = zline;
- cargs = 0;
- pzargs = azargs;
- while (TRUE)
- {
- while (*z != '\0' && isspace (BUCHAR (*z)))
- ++z;
-
- if (*z == '\0')
- break;
-
- if (cargs >= CSTACK)
- {
- char **pzsplit;
- size_t csplit;
- int cmore;
-
- pzsplit = NULL;
- csplit = 0;
- cmore = _uuconf_istrsplit (z, '\0', &pzsplit, &csplit);
- if (cmore < 0)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- pzargs = (char **) malloc ((cmore + CSTACK) * sizeof (char *));
- if (pzargs == NULL)
- {
- qglobal->ierrno = errno;
- free ((pointer) pzsplit);
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- memcpy ((pointer) pzargs, (pointer) azargs,
- CSTACK * sizeof (char *));
- memcpy ((pointer) (pzargs + CSTACK), (pointer) pzsplit,
- cmore * sizeof (char *));
- cargs = cmore + CSTACK;
-
- free ((pointer) pzsplit);
-
- break;
- }
-
- azargs[cargs] = z;
- ++cargs;
-
- while (*z != '\0' && ! isspace (BUCHAR (*z)))
- z++;
-
- if (*z == '\0')
- break;
-
- *z++ = '\0';
- }
-
- if (cargs <= 0)
- return UUCONF_CMDTABRET_CONTINUE;
-
- iret = uuconf_cmd_args (pglobal, cargs, pzargs, qtab, pinfo, pfiunknown,
- iflags, pblock);
-
- if (pzargs != azargs)
- free ((pointer) pzargs);
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/debfil.c b/gnu/libexec/uucp/libuuconf/debfil.c
deleted file mode 100644
index baf5b06..0000000
--- a/gnu/libexec/uucp/libuuconf/debfil.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* debfil.c
- Get the name of the UUCP debugging file.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_debfil_rcsid[] = "$Id$";
-#endif
-
-/* Get the name of the UUCP debugging file. */
-
-int
-uuconf_debugfile (pglobal, pzdebug)
- pointer pglobal;
- const char **pzdebug;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pzdebug = qglobal->qprocess->zdebugfile;
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/deblev.c b/gnu/libexec/uucp/libuuconf/deblev.c
deleted file mode 100644
index 65812f0..0000000
--- a/gnu/libexec/uucp/libuuconf/deblev.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* deblev.c
- Get the UUCP debugging level.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_deblev_rcsid[] = "$Id$";
-#endif
-
-/* Get the UUCP debugging level. */
-
-int
-uuconf_debuglevel (pglobal, pzdebug)
- pointer pglobal;
- const char **pzdebug;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pzdebug = qglobal->qprocess->zdebug;
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/diacod.c b/gnu/libexec/uucp/libuuconf/diacod.c
deleted file mode 100644
index a557e57..0000000
--- a/gnu/libexec/uucp/libuuconf/diacod.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* diacod.c
- Translate a dialcode.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_diacod_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-static int idcode P((pointer pglobal, int argc, char **argv,
- pointer pinfo, pointer pvar));
-
-/* Get the name of the UUCP log file. */
-
-int
-uuconf_dialcode (pglobal, zdial, pznum)
- pointer pglobal;
- const char *zdial;
- char **pznum;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_cmdtab as[2];
- char **pz;
- int iret;
-
- as[0].uuconf_zcmd = zdial;
- as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 0;
- as[0].uuconf_pvar = (pointer) pznum;
- as[0].uuconf_pifn = idcode;
-
- as[1].uuconf_zcmd = NULL;
-
- *pznum = NULL;
-
- iret = UUCONF_SUCCESS;
-
- for (pz = qglobal->qprocess->pzdialcodefiles; *pz != NULL; pz++)
- {
- FILE *e;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- iret = uuconf_cmd_file (pglobal, e, as, (pointer) NULL,
- (uuconf_cmdtabfn) NULL, 0, (pointer) NULL);
- (void) fclose (e);
-
- if (iret != UUCONF_SUCCESS || *pznum != NULL)
- break;
- }
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = *pz;
- iret |= UUCONF_ERROR_FILENAME;
- }
- else if (*pznum == NULL)
- iret = UUCONF_NOT_FOUND;
-
- return iret;
-}
-
-/* This is called if the dialcode is found. It copies the number into
- the heap and gets out of reading the file. */
-
-/*ARGSUSED*/
-static int
-idcode (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char **pznum = (char **) pvar;
-
- if (argc == 1)
- {
- *pznum = malloc (1);
- if (*pznum != NULL)
- **pznum = '\0';
- }
- else if (argc == 2)
- *pznum = strdup (argv[1]);
- else
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- if (*pznum == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- return UUCONF_CMDTABRET_EXIT;
-}
diff --git a/gnu/libexec/uucp/libuuconf/dial.c b/gnu/libexec/uucp/libuuconf/dial.c
deleted file mode 100644
index 0d71c5e..0000000
--- a/gnu/libexec/uucp/libuuconf/dial.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* dial.c
- Find a dialer.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_dial_rcsid[] = "$Id$";
-#endif
-
-/* Find a dialer by name. */
-
-int
-uuconf_dialer_info (pglobal, zdialer, qdialer)
- pointer pglobal;
- const char *zdialer;
- struct uuconf_dialer *qdialer;
-{
-#if HAVE_HDB_CONFIG
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-#endif
- int iret;
-
-#if HAVE_TAYLOR_CONFIG
- iret = uuconf_taylor_dialer_info (pglobal, zdialer, qdialer);
- if (iret != UUCONF_NOT_FOUND)
- return iret;
-#endif
-
-#if HAVE_HDB_CONFIG
- if (qglobal->qprocess->fhdb)
- {
- iret = uuconf_hdb_dialer_info (pglobal, zdialer, qdialer);
- if (iret != UUCONF_NOT_FOUND)
- return iret;
- }
-#endif
-
- return UUCONF_NOT_FOUND;
-}
diff --git a/gnu/libexec/uucp/libuuconf/diasub.c b/gnu/libexec/uucp/libuuconf/diasub.c
deleted file mode 100644
index 6988ca6..0000000
--- a/gnu/libexec/uucp/libuuconf/diasub.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* diasub.c
- Dialer information subroutines.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_diasub_rcsid[] = "$Id$";
-#endif
-
-/* Clear the information in a dialer. */
-
-#define INIT_CHAT(q) \
- ((q)->uuconf_pzchat = NULL, \
- (q)->uuconf_pzprogram = NULL, \
- (q)->uuconf_ctimeout = 60, \
- (q)->uuconf_pzfail = NULL, \
- (q)->uuconf_fstrip = TRUE)
-
-void
-_uuconf_uclear_dialer (qdialer)
- struct uuconf_dialer *qdialer;
-{
- qdialer->uuconf_zname = NULL;
- INIT_CHAT (&qdialer->uuconf_schat);
- qdialer->uuconf_zdialtone = (char *) ",";
- qdialer->uuconf_zpause = (char *) ",";
- qdialer->uuconf_fcarrier = TRUE;
- qdialer->uuconf_ccarrier_wait = 60;
- qdialer->uuconf_fdtr_toggle = FALSE;
- qdialer->uuconf_fdtr_toggle_wait = FALSE;
- INIT_CHAT (&qdialer->uuconf_scomplete);
- INIT_CHAT (&qdialer->uuconf_sabort);
- qdialer->uuconf_qproto_params = NULL;
- /* Note that we do not set RELIABLE_SPECIFIED; this just sets
- defaults, so that ``seven-bit true'' does not imply ``reliable
- false''. */
- qdialer->uuconf_ireliable = (UUCONF_RELIABLE_RELIABLE
- | UUCONF_RELIABLE_EIGHT
- | UUCONF_RELIABLE_FULLDUPLEX);
- qdialer->uuconf_palloc = NULL;
-}
diff --git a/gnu/libexec/uucp/libuuconf/dnams.c b/gnu/libexec/uucp/libuuconf/dnams.c
deleted file mode 100644
index d291501..0000000
--- a/gnu/libexec/uucp/libuuconf/dnams.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* dnams.c
- Get all known dialer names.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_dnams_rcsid[] = "$Id$";
-#endif
-
-/* Get all known dialer names. */
-
-int
-uuconf_dialer_names (pglobal, ppzdialers)
- pointer pglobal;
- char ***ppzdialers;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char **pztaylor;
- char **pzhdb;
- int iret;
-
- *ppzdialers = NULL;
- pztaylor = NULL;
- pzhdb = NULL;
-
-#if HAVE_TAYLOR_CONFIG
- iret = uuconf_taylor_dialer_names (pglobal, &pztaylor);
- if (iret != UUCONF_SUCCESS)
- return iret;
-#endif
-
-#if HAVE_HDB_CONFIG
- if (qglobal->qprocess->fhdb)
- {
- iret = uuconf_hdb_dialer_names (pglobal, &pzhdb);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-#endif
-
- if (pzhdb == NULL)
- *ppzdialers = pztaylor;
- else if (pztaylor == NULL)
- *ppzdialers = pzhdb;
- else
- {
- char **pz;
-
- iret = UUCONF_SUCCESS;
-
- for (pz = pztaylor; *pz != NULL; pz++)
- {
- iret = _uuconf_iadd_string (qglobal, *pz, FALSE, TRUE,
- ppzdialers, (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- break;
- }
-
- if (iret == UUCONF_SUCCESS)
- {
- for (pz = pzhdb; *pz != NULL; pz++)
- {
- iret = _uuconf_iadd_string (qglobal, *pz, FALSE, TRUE,
- ppzdialers, (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- break;
- }
- }
-
- if (pztaylor != NULL)
- free ((pointer) pztaylor);
- if (pzhdb != NULL)
- free ((pointer) pzhdb);
- }
-
- if (iret == UUCONF_SUCCESS && *ppzdialers == NULL)
- iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
- ppzdialers, (pointer) NULL);
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/errno.c b/gnu/libexec/uucp/libuuconf/errno.c
deleted file mode 100644
index e9b7761..0000000
--- a/gnu/libexec/uucp/libuuconf/errno.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* errno.c
- Return the saved errno value.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_errno_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Return the saved errno value. */
-
-int
-uuconf_error_errno (pglobal)
- pointer pglobal;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- if (qglobal == NULL)
- return errno;
- else
- return qglobal->ierrno;
-}
diff --git a/gnu/libexec/uucp/libuuconf/errstr.c b/gnu/libexec/uucp/libuuconf/errstr.c
deleted file mode 100644
index 7782787..0000000
--- a/gnu/libexec/uucp/libuuconf/errstr.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/* errstr.c
- Return a string for a uuconf error.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_errstr_rcsid[] = "$Id$";
-#endif
-
-static char *zeprint_num P((char *zbuf, size_t cbuf, int ival));
-
-/* Return an error string for a uuconf error. This does not return a
- uuconf error code, but instead returns the total buffer length. */
-
-int
-uuconf_error_string (pglobal, ierr, zbuf, cbuf)
- pointer pglobal;
- int ierr;
- char *zbuf;
- size_t cbuf;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- const char *zfile;
- size_t cfile;
- const char *zlineno;
- char ablineno[100];
- size_t clineno;
- const char *zmsg;
- char abmsg[100];
- size_t cmsg;
- const char *zerrno;
- size_t cerrno;
- size_t cret;
- size_t ccopy;
-
- /* The format of the message is
-
- filename:lineno: message: errno
-
- If there is no filename, the trailing colon is not output. If
- there is no linenumber, the trailing colon is not output. If
- there is no filename, the linenumber is not output, and neither
- is the space before message. If there is no errno, the
- preceeding colon and space are not output. */
-
- /* Get the filename to put in the error message, if any. */
- if ((ierr & UUCONF_ERROR_FILENAME) == 0
- || qglobal == NULL
- || qglobal->zfilename == NULL)
- {
- zfile = "";
- cfile = 0;
- }
- else
- {
- zfile = qglobal->zfilename;
- cfile = strlen (zfile) + 1;
- }
-
- /* Get the line number to put in the error message, if any. */
- if (cfile == 0
- || (ierr & UUCONF_ERROR_LINENO) == 0
- || qglobal == NULL
- || qglobal->ilineno <= 0)
- {
- zlineno = "";
- clineno = 0;
- }
- else
- {
- zlineno = zeprint_num (ablineno, sizeof ablineno, qglobal->ilineno);
- clineno = strlen (zlineno) + 1;
- }
-
- /* Get the main message. */
- switch (UUCONF_ERROR_VALUE (ierr))
- {
- case UUCONF_SUCCESS:
- zmsg = "no error";
- break;
- case UUCONF_NOT_FOUND:
- zmsg = "not found";
- break;
- case UUCONF_FOPEN_FAILED:
- zmsg = "fopen";
- break;
- case UUCONF_FSEEK_FAILED:
- zmsg = "fseek";
- break;
- case UUCONF_MALLOC_FAILED:
- zmsg = "malloc";
- break;
- case UUCONF_SYNTAX_ERROR:
- zmsg = "syntax error";
- break;
- default:
- zmsg = zeprint_num (abmsg, sizeof abmsg, UUCONF_ERROR_VALUE (ierr));
- zmsg -= sizeof "error " - 1;
- memcpy ((pointer) zmsg, (pointer) "error ", sizeof "error " - 1);
- break;
- }
-
- cmsg = strlen (zmsg);
- if (cfile > 0)
- ++cmsg;
-
- /* Get the errno string. Note that strerror is not necessarily
- reentrant. */
- if ((ierr & UUCONF_ERROR_ERRNO) == 0
- || qglobal == NULL)
- {
- zerrno = "";
- cerrno = 0;
- }
- else
- {
- zerrno = strerror (qglobal->ierrno);
- cerrno = strlen (zerrno) + 2;
- }
-
- cret = cfile + clineno + cmsg + cerrno + 1;
-
- if (cbuf == 0)
- return cret;
-
- /* Leave room for the null byte. */
- --cbuf;
-
- if (cfile > 0)
- {
- ccopy = cfile - 1;
- if (ccopy > cbuf)
- ccopy = cbuf;
- memcpy ((pointer) zbuf, (pointer) zfile, ccopy);
- zbuf += ccopy;
- cbuf -= ccopy;
- if (cbuf > 0)
- {
- *zbuf++ = ':';
- --cbuf;
- }
- }
-
- if (clineno > 0)
- {
- ccopy = clineno - 1;
- if (ccopy > cbuf)
- ccopy = cbuf;
- memcpy ((pointer) zbuf, (pointer) zlineno, ccopy);
- zbuf += ccopy;
- cbuf -= ccopy;
- if (cbuf > 0)
- {
- *zbuf++ = ':';
- --cbuf;
- }
- }
-
- if (cbuf > 0 && cfile > 0)
- {
- *zbuf++ = ' ';
- --cbuf;
- --cmsg;
- }
- ccopy = cmsg;
- if (ccopy > cbuf)
- ccopy = cbuf;
- memcpy ((pointer) zbuf, (pointer) zmsg, ccopy);
- zbuf += ccopy;
- cbuf -= ccopy;
-
- if (cerrno > 0)
- {
- if (cbuf > 0)
- {
- *zbuf++ = ':';
- --cbuf;
- }
- if (cbuf > 0)
- {
- *zbuf++ = ' ';
- --cbuf;
- }
- ccopy = cerrno - 2;
- if (ccopy > cbuf)
- ccopy = cbuf;
- memcpy ((pointer) zbuf, (pointer) zerrno, ccopy);
- zbuf += ccopy;
- cbuf -= ccopy;
- }
-
- *zbuf = '\0';
-
- return cret;
-}
-
-/* Turn a number into a string. This should really call sprintf, but
- since nothing else in the uuconf library calls any print routine,
- it's more interesting to not call it here either. */
-
-static char *
-zeprint_num (ab, c, i)
- char *ab;
- size_t c;
- register int i;
-{
- register char *z;
-
- z = ab + c;
- *--z = '\0';
- do
- {
- *--z = i % 10 + '0';
- i /= 10;
- }
- while (i != 0);
-
- return z;
-}
diff --git a/gnu/libexec/uucp/libuuconf/filnam.c b/gnu/libexec/uucp/libuuconf/filnam.c
deleted file mode 100644
index 6057093..0000000
--- a/gnu/libexec/uucp/libuuconf/filnam.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* filnam.c
- Return the saved file name.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_filnam_rcsid[] = "$Id$";
-#endif
-
-/* Return the saved file name. */
-
-UUCONF_CONST char *
-uuconf_error_filename (pglobal)
- pointer pglobal;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- if (qglobal == NULL)
- return "";
- else
- return qglobal->zfilename;
-}
diff --git a/gnu/libexec/uucp/libuuconf/freblk.c b/gnu/libexec/uucp/libuuconf/freblk.c
deleted file mode 100644
index 6d5281c..0000000
--- a/gnu/libexec/uucp/libuuconf/freblk.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* freblk.c
- Free up an entire memory block.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_freblk_rcsid[] = "$Id$";
-#endif
-
-#include "alloc.h"
-
-/* Free up an entire memory block. */
-
-#if UUCONF_ANSI_C
-void
-#endif
-uuconf_free_block (pblock)
- pointer pblock;
-{
- struct sblock *q = (struct sblock *) pblock;
- struct sblock *qloop;
-
- /* We have to free the added blocks first because the list may link
- into blocks that are earlier on the list. */
- for (qloop = q; qloop != NULL; qloop = qloop->qnext)
- {
- struct sadded *qadd;
-
- for (qadd = qloop->qadded; qadd != NULL; qadd = qadd->qnext)
- free (qadd->padded);
- }
-
- while (q != NULL)
- {
- struct sblock *qnext;
-
- qnext = q->qnext;
- free ((pointer) q);
- q = qnext;
- }
-}
diff --git a/gnu/libexec/uucp/libuuconf/fredia.c b/gnu/libexec/uucp/libuuconf/fredia.c
deleted file mode 100644
index 5281acf..0000000
--- a/gnu/libexec/uucp/libuuconf/fredia.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* fredia.c
- Free dialer information.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_fredia_rcsid[] = "$Id$";
-#endif
-
-/* Free the memory allocated for a dialer. */
-
-#undef uuconf_dialer_free
-
-/*ARGSUSED*/
-int
-uuconf_dialer_free (pglobal, qdialer)
- pointer pglobal;
- struct uuconf_dialer *qdialer;
-{
- uuconf_free_block (qdialer->uuconf_palloc);
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/free.c b/gnu/libexec/uucp/libuuconf/free.c
deleted file mode 100644
index 4bad8bd..0000000
--- a/gnu/libexec/uucp/libuuconf/free.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* free.c
- Free a buffer from within a memory block.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_free_rcsid[] = "$Id$";
-#endif
-
-#include "alloc.h"
-
-/* Free memory allocated by uuconf_malloc. If the memory block is
- NULL, this just calls free; this is convenient for a number of
- routines. Otherwise, this will only do something if this was the
- last buffer allocated for one of the memory blocks in the list; in
- other cases, the memory is lost until the entire memory block is
- freed. */
-
-#if UUCONF_ANSI_C
-void
-#endif
-uuconf_free (pblock, pbuf)
- pointer pblock;
- pointer pbuf;
-{
- struct sblock *q = (struct sblock *) pblock;
-
- if (pbuf == NULL)
- return;
-
- if (q == NULL)
- {
- free (pbuf);
- return;
- }
-
- for (; q != NULL; q = q->qnext)
- {
- if (q->plast == pbuf)
- {
- q->ifree = (char *) pbuf - q->u.ab;
- /* We could reset q->plast here, but it doesn't matter. */
- return;
- }
- }
-}
diff --git a/gnu/libexec/uucp/libuuconf/freprt.c b/gnu/libexec/uucp/libuuconf/freprt.c
deleted file mode 100644
index e0529c0..0000000
--- a/gnu/libexec/uucp/libuuconf/freprt.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* freprt.c
- Free port information.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_freprt_rcsid[] = "$Id$";
-#endif
-
-/* Free the memory allocated for a port. */
-
-#undef uuconf_port_free
-
-/*ARGSUSED*/
-int
-uuconf_port_free (pglobal, qport)
- pointer pglobal;
- struct uuconf_port *qport;
-{
- uuconf_free_block (qport->uuconf_palloc);
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/fresys.c b/gnu/libexec/uucp/libuuconf/fresys.c
deleted file mode 100644
index 95d4fd3..0000000
--- a/gnu/libexec/uucp/libuuconf/fresys.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* fresys.c
- Free system information.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_fresys_rcsid[] = "$Id$";
-#endif
-
-/* Free the memory allocated for a system. */
-
-#undef uuconf_system_free
-
-/*ARGSUSED*/
-int
-uuconf_system_free (pglobal, qsys)
- pointer pglobal;
- struct uuconf_system *qsys;
-{
- uuconf_free_block (qsys->uuconf_palloc);
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/grdcmp.c b/gnu/libexec/uucp/libuuconf/grdcmp.c
deleted file mode 100644
index 8f0f35b..0000000
--- a/gnu/libexec/uucp/libuuconf/grdcmp.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* grdcmp.c
- Compare two grades.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_grdcmp_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-
-/* Compare two grades, returning < 0 if b1 should be executed before
- b2, == 0 if they are the same, or > 0 if b1 should be executed
- after b2. This can not fail, and does not return a standard uuconf
- error code.
-
- This implementation assumes that the upper case letters are in
- sequence, and that the lower case letters are in sequence. */
-
-int
-uuconf_grade_cmp (barg1, barg2)
- int barg1;
- int barg2;
-{
- int b1, b2;
-
- /* Make sure the arguments are unsigned. */
- b1 = (int) BUCHAR (barg1);
- b2 = (int) BUCHAR (barg2);
-
- if (isdigit (b1))
- {
- if (isdigit (b2))
- return b1 - b2;
- else
- return -1;
- }
- else if (isupper (b1))
- {
- if (isdigit (b2))
- return 1;
- else if (isupper (b2))
- return b1 - b2;
- else
- return -1;
- }
- else
- {
- if (! islower (b2))
- return 1;
- else
- return b1 - b2;
- }
-}
diff --git a/gnu/libexec/uucp/libuuconf/hdial.c b/gnu/libexec/uucp/libuuconf/hdial.c
deleted file mode 100644
index 4d46105..0000000
--- a/gnu/libexec/uucp/libuuconf/hdial.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/* hdial.c
- Find a dialer in the HDB configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_hdial_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-/* Find a dialer in the HDB configuration files by name. */
-
-int
-uuconf_hdb_dialer_info (pglobal, zname, qdialer)
- pointer pglobal;
- const char *zname;
- struct uuconf_dialer *qdialer;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char **pz;
- char *zline;
- size_t cline;
- char **pzsplit;
- size_t csplit;
- int iret;
-
- zline = NULL;
- cline = 0;
- pzsplit = NULL;
- csplit = 0;
-
- iret = UUCONF_NOT_FOUND;
-
- for (pz = qglobal->qprocess->pzhdb_dialers; *pz != NULL; pz++)
- {
- FILE *e;
- int cchars;
-
- qglobal->ilineno = 0;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0)
- {
- int ctoks;
- pointer pblock;
-
- ++qglobal->ilineno;
-
- --cchars;
- if (zline[cchars] == '\n')
- zline[cchars] = '\0';
- if (isspace (BUCHAR (zline[0])) || zline[0] == '#')
- continue;
-
- ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit);
- if (ctoks < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- if (ctoks < 1)
- continue;
-
- if (strcmp (zname, pzsplit[0]) != 0)
- continue;
-
- /* We found the dialer. */
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- if (uuconf_add_block (pblock, zline) != 0)
- {
- qglobal->ierrno = errno;
- uuconf_free_block (pblock);
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- zline = NULL;
-
- _uuconf_uclear_dialer (qdialer);
- qdialer->uuconf_zname = pzsplit[0];
- qdialer->uuconf_palloc = pblock;
-
- if (ctoks > 1)
- {
- /* The second field is characters to send instead of "="
- and "-" in phone numbers. */
- if (strcmp (pzsplit[1], "\"\"") == 0)
- {
- char *zsubs;
- char bnext;
-
- zsubs = pzsplit[1];
- bnext = *zsubs;
- while (bnext != '\0')
- {
- if (bnext == '=')
- qdialer->uuconf_zdialtone = zsubs + 1;
- else if (bnext == '-')
- qdialer->uuconf_zpause = zsubs + 1;
- if (zsubs[1] == '\0')
- break;
- zsubs += 2;
- bnext = *zsubs;
- *zsubs = '\0';
- }
- }
-
- /* Any remaining fields form a chat script. */
- if (ctoks > 2)
- {
- pzsplit[1] = (char *) "chat";
- iret = _uuconf_ichat_cmd (qglobal, ctoks - 1,
- pzsplit + 1,
- &qdialer->uuconf_schat,
- pblock);
- iret &=~ UUCONF_CMDTABRET_KEEP;
- if (iret != UUCONF_SUCCESS)
- {
- uuconf_free_block (pblock);
- break;
- }
- }
- }
-
- iret = UUCONF_SUCCESS;
- break;
- }
-
- (void) fclose (e);
-
- if (iret != UUCONF_NOT_FOUND)
- break;
- }
-
- if (zline != NULL)
- free ((pointer) zline);
- if (pzsplit != NULL)
- free ((pointer) pzsplit);
-
- if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND)
- {
- qglobal->zfilename = *pz;
- iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- }
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/hdnams.c b/gnu/libexec/uucp/libuuconf/hdnams.c
deleted file mode 100644
index a6285d0..0000000
--- a/gnu/libexec/uucp/libuuconf/hdnams.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/* hdnams.c
- Get all known dialer names from the HDB configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_hdnams_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-/* Get all the dialer names from the HDB Dialers file. */
-
-int
-uuconf_hdb_dialer_names (pglobal, ppzdialers)
- pointer pglobal;
- char ***ppzdialers;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
- char *zline;
- size_t cline;
- char **pz;
-
- *ppzdialers = NULL;
-
- iret = UUCONF_SUCCESS;
-
- zline = NULL;
- cline = 0;
-
- for (pz = qglobal->qprocess->pzhdb_dialers; *pz != NULL; pz++)
- {
- FILE *e;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- qglobal->ilineno = 0;
-
- while (_uuconf_getline (qglobal, &zline, &cline, e) > 0)
- {
- ++qglobal->ilineno;
-
- /* Lines beginning with whitespace are treated as comments.
- No dialer name can contain a '#', which is another
- comment character, so eliminating the first '#' does no
- harm and catches comments. */
- zline[strcspn (zline, " \t#\n")] = '\0';
- if (*zline == '\0')
- continue;
-
- iret = _uuconf_iadd_string (qglobal, zline, TRUE, TRUE,
- ppzdialers, (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- {
- iret |= UUCONF_ERROR_LINENO;
- break;
- }
- }
-
- (void) fclose (e);
- }
-
- if (zline != NULL)
- free ((pointer) zline);
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = *pz;
- return iret | UUCONF_ERROR_FILENAME;
- }
-
- if (*ppzdialers == NULL)
- iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
- ppzdialers, (pointer) NULL);
-
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/hinit.c b/gnu/libexec/uucp/libuuconf/hinit.c
deleted file mode 100644
index dfd7392..0000000
--- a/gnu/libexec/uucp/libuuconf/hinit.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/* hinit.c
- Initialize for reading HDB configuration files.
-
- Copyright (C) 1992, 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_hinit_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-/* Avoid replicating OLDCONFIGLIB several times if not necessary. */
-static const char abHoldconfiglib[] = OLDCONFIGLIB;
-
-/* Initialize the routines which read HDB configuration files. */
-
-int
-uuconf_hdb_init (ppglobal, zprogram)
- pointer *ppglobal;
- const char *zprogram;
-{
- struct sglobal **pqglobal = (struct sglobal **) ppglobal;
- int iret;
- struct sglobal *qglobal;
- pointer pblock;
- char abdialcodes[sizeof OLDCONFIGLIB + sizeof HDB_DIALCODES - 1];
- char *zsys;
- FILE *e;
-
- if (*pqglobal == NULL)
- {
- iret = _uuconf_iinit_global (pqglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- qglobal = *pqglobal;
- pblock = qglobal->pblock;
-
- if (zprogram == NULL
- || strcmp (zprogram, "uucp") == 0)
- zprogram = "uucico";
-
- /* Add the Dialcodes file to the global list. */
- memcpy ((pointer) abdialcodes, (pointer) abHoldconfiglib,
- sizeof OLDCONFIGLIB - 1);
- memcpy ((pointer) (abdialcodes + sizeof OLDCONFIGLIB - 1),
- (pointer) HDB_DIALCODES, sizeof HDB_DIALCODES);
- iret = _uuconf_iadd_string (qglobal, abdialcodes, TRUE, FALSE,
- &qglobal->qprocess->pzdialcodefiles,
- pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
-
- /* Read the Sysfiles file. We allocate the name on the heap rather
- than the stack so that we can return it in
- qerr->uuconf_zfilename. */
-
- zsys = uuconf_malloc (pblock,
- sizeof OLDCONFIGLIB + sizeof HDB_SYSFILES - 1);
- if (zsys == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- memcpy ((pointer) zsys, (pointer) abHoldconfiglib, sizeof OLDCONFIGLIB - 1);
- memcpy ((pointer) (zsys + sizeof OLDCONFIGLIB - 1), (pointer) HDB_SYSFILES,
- sizeof HDB_SYSFILES);
-
- iret = UUCONF_SUCCESS;
-
- e = fopen (zsys, "r");
- if (e == NULL)
- uuconf_free (pblock, zsys);
- else
- {
- char *zline;
- size_t cline;
- char **pzargs;
- size_t cargs;
- char **pzcolon;
- size_t ccolon;
- int cchars;
-
- zline = NULL;
- cline = 0;
- pzargs = NULL;
- cargs = 0;
- pzcolon = NULL;
- ccolon = 0;
-
- qglobal->ilineno = 0;
-
- while (iret == UUCONF_SUCCESS
- && (cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0)
- {
- int ctypes, cnames;
- int i;
-
- ++qglobal->ilineno;
-
- --cchars;
- if (zline[cchars] == '\n')
- zline[cchars] = '\0';
- if (zline[0] == '#')
- continue;
-
- ctypes = _uuconf_istrsplit (zline, '\0', &pzargs, &cargs);
- if (ctypes < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- if (ctypes == 0)
- continue;
-
- if (strncmp (pzargs[0], "service=", sizeof "service=" - 1) != 0)
- {
- iret = UUCONF_SYNTAX_ERROR;
- break;
- }
- pzargs[0] += sizeof "service=" - 1;
-
- cnames = _uuconf_istrsplit (pzargs[0], ':', &pzcolon, &ccolon);
- if (cnames < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- for (i = 0; i < cnames; i++)
- if (strcmp (zprogram, pzcolon[i]) == 0)
- break;
-
- if (i >= cnames)
- continue;
-
- for (i = 1; i < ctypes && iret == UUCONF_SUCCESS; i++)
- {
- char ***ppz;
- int cfiles, ifile;
-
- if (strncmp (pzargs[i], "systems=", sizeof "systems=" - 1)
- == 0)
- {
- ppz = &qglobal->qprocess->pzhdb_systems;
- pzargs[i] += sizeof "systems=" - 1;
- }
- else if (strncmp (pzargs[i], "devices=", sizeof "devices=" - 1)
- == 0)
- {
- ppz = &qglobal->qprocess->pzhdb_devices;
- pzargs[i] += sizeof "devices=" - 1;
- }
- else if (strncmp (pzargs[i], "dialers=", sizeof "dialers=" - 1)
- == 0)
- {
- ppz = &qglobal->qprocess->pzhdb_dialers;
- pzargs[i] += sizeof "dialers=" - 1;
- }
- else
- {
- iret = UUCONF_SYNTAX_ERROR;
- break;
- }
-
- cfiles = _uuconf_istrsplit (pzargs[i], ':', &pzcolon, &ccolon);
- if (cfiles < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- for (ifile = 0;
- ifile < cfiles && iret == UUCONF_SUCCESS;
- ifile++)
- {
- /* Looking for a leading '/' is Unix dependent, and
- should probably be changed. */
- if (pzcolon[ifile][0] == '/')
- iret = _uuconf_iadd_string (qglobal, pzcolon[ifile], TRUE,
- FALSE, ppz, pblock);
- else
- {
- char *zdir;
- size_t clen;
-
- clen = strlen (pzcolon[ifile]);
- zdir = (char *) uuconf_malloc (pblock,
- (sizeof OLDCONFIGLIB
- + sizeof HDB_SEPARATOR
- + clen
- - 1));
- if (zdir == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- memcpy ((pointer) zdir, (pointer) abHoldconfiglib,
- sizeof OLDCONFIGLIB - 1);
- memcpy ((pointer) (zdir + sizeof OLDCONFIGLIB - 1),
- HDB_SEPARATOR, sizeof HDB_SEPARATOR - 1);
- memcpy ((pointer) (zdir
- + sizeof OLDCONFIGLIB - 1
- + sizeof HDB_SEPARATOR - 1),
- (pointer) pzcolon[ifile], clen + 1);
- iret = _uuconf_iadd_string (qglobal, zdir, FALSE, FALSE,
- ppz, pblock);
- }
- }
- }
- }
-
- (void) fclose (e);
- if (zline != NULL)
- free ((pointer) zline);
- if (pzargs != NULL)
- free ((pointer) pzargs);
- if (pzcolon != NULL)
- free ((pointer) pzcolon);
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = zsys;
- return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- }
- }
-
- if (qglobal->qprocess->pzhdb_systems == NULL)
- {
- char ab[sizeof OLDCONFIGLIB + sizeof HDB_SYSTEMS - 1];
-
- memcpy ((pointer) ab, (pointer) abHoldconfiglib,
- sizeof OLDCONFIGLIB - 1);
- memcpy ((pointer) (ab + sizeof OLDCONFIGLIB - 1),
- (pointer) HDB_SYSTEMS, sizeof HDB_SYSTEMS);
- iret = _uuconf_iadd_string (qglobal, ab, TRUE, FALSE,
- &qglobal->qprocess->pzhdb_systems,
- pblock);
- }
- if (qglobal->qprocess->pzhdb_devices == NULL && iret == UUCONF_SUCCESS)
- {
- char ab[sizeof OLDCONFIGLIB + sizeof HDB_DEVICES - 1];
-
- memcpy ((pointer) ab, (pointer) abHoldconfiglib,
- sizeof OLDCONFIGLIB - 1);
- memcpy ((pointer) (ab + sizeof OLDCONFIGLIB - 1),
- (pointer) HDB_DEVICES, sizeof HDB_DEVICES);
- iret = _uuconf_iadd_string (qglobal, ab, TRUE, FALSE,
- &qglobal->qprocess->pzhdb_devices,
- pblock);
- }
- if (qglobal->qprocess->pzhdb_dialers == NULL && iret == UUCONF_SUCCESS)
- {
- char ab[sizeof OLDCONFIGLIB + sizeof HDB_DIALERS - 1];
-
- memcpy ((pointer) ab, (pointer) abHoldconfiglib,
- sizeof OLDCONFIGLIB - 1);
- memcpy ((pointer) (ab + sizeof OLDCONFIGLIB - 1),
- (pointer) HDB_DIALERS, sizeof HDB_DIALERS);
- iret = _uuconf_iadd_string (qglobal, ab, TRUE, FALSE,
- &qglobal->qprocess->pzhdb_dialers,
- pblock);
- }
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/hlocnm.c b/gnu/libexec/uucp/libuuconf/hlocnm.c
deleted file mode 100644
index 2cdd60a..0000000
--- a/gnu/libexec/uucp/libuuconf/hlocnm.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* hlocnm.c
- Get the local name to use from the HDB configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_hlocnm_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Get the local name to use, based on the login name, from the HDB
- configuration files. */
-
-int
-uuconf_hdb_login_localname (pglobal, zlogin, pzname)
- pointer pglobal;
- const char *zlogin;
- char **pzname;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct shpermissions *qperm;
-
- if (! qglobal->qprocess->fhdb_read_permissions)
- {
- int iret;
-
- iret = _uuconf_ihread_permissions (qglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- for (qperm = qglobal->qprocess->qhdb_permissions;
- qperm != NULL;
- qperm = qperm->qnext)
- {
- if (qperm->zmyname != NULL
- && qperm->zmyname != (char *) &_uuconf_unset
- && qperm->pzlogname != NULL
- && qperm->pzlogname != (char **) &_uuconf_unset)
- {
- char **pz;
-
- for (pz = qperm->pzlogname; *pz != NULL; pz++)
- {
- if (strcmp (*pz, zlogin) == 0)
- {
- *pzname = strdup (qperm->zmyname);
- if (*pzname == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- return UUCONF_SUCCESS;
- }
- }
- }
- }
-
- *pzname = NULL;
- return UUCONF_NOT_FOUND;
-}
diff --git a/gnu/libexec/uucp/libuuconf/hport.c b/gnu/libexec/uucp/libuuconf/hport.c
deleted file mode 100644
index d4e5e99..0000000
--- a/gnu/libexec/uucp/libuuconf/hport.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/* hport.c
- Find a port in the HDB configuration files.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_hport_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-/* Find a port in the HDB configuration files by name, baud rate, and
- special purpose function. */
-
-int
-uuconf_hdb_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport)
- pointer pglobal;
- const char *zname;
- long ibaud;
- long ihighbaud;
- int (*pifn) P((struct uuconf_port *, pointer));
- pointer pinfo;
- struct uuconf_port *qport;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char *zline;
- size_t cline;
- char **pzsplit;
- size_t csplit;
- int iret;
- char **pz;
-
- zline = NULL;
- cline = 0;
- pzsplit = NULL;
- csplit = 0;
-
- iret = UUCONF_NOT_FOUND;
-
- for (pz = qglobal->qprocess->pzhdb_devices; *pz != NULL; pz++)
- {
- FILE *e;
- int cchars;
-
- qglobal->ilineno = 0;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- iret = UUCONF_NOT_FOUND;
-
- while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0)
- {
- int ctoks;
- char *z, *zprotos, *zport;
- long ilow, ihigh;
- pointer pblock;
- char ***ppzdialer;
-
- ++qglobal->ilineno;
-
- iret = UUCONF_NOT_FOUND;
-
- --cchars;
- if (zline[cchars] == '\n')
- zline[cchars] = '\0';
- if (isspace (BUCHAR (zline[0])) || zline[0] == '#')
- continue;
-
- ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit);
- if (ctoks < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- /* An entry in Devices is
-
- type device dial-device baud dialer-token pairs
-
- The type (normally "ACU") is treated as the name. */
-
- /* If there aren't enough entries, ignore the line; this
- should probably do something more useful. */
- if (ctoks < 4)
- continue;
-
- /* There may be a comma separated list of protocols after
- the name. */
- zprotos = strchr (pzsplit[0], ',');
- if (zprotos != NULL)
- {
- *zprotos = '\0';
- ++zprotos;
- }
-
- zport = pzsplit[0];
-
- /* Get any modem class, and pick up the baud rate while
- we're at it. The modem class will be appended to the
- name, so we need to get it before we see if we've found
- the port with the right name. */
- z = pzsplit[3];
- if (strcasecmp (z, "Any") == 0
- || strcmp (z, "-") == 0)
- {
- ilow = 0L;
- ihigh = 0L;
- }
- else
- {
- char *zend;
-
- while (*z != '\0' && ! isdigit (BUCHAR (*z)))
- ++z;
-
- ilow = strtol (z, &zend, 10);
- if (*zend == '-')
- ihigh = strtol (zend + 1, (char **) NULL, 10);
- else
- ihigh = ilow;
-
- if (z != pzsplit[3])
- {
- size_t cclass, cport;
-
- cclass = z - pzsplit[3];
- cport = strlen (pzsplit[0]);
- zport = malloc (cport + cclass + 1);
- if (zport == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- memcpy ((pointer) zport, (pointer) pzsplit[0], cport);
- memcpy ((pointer) (zport + cport), (pointer) pzsplit[3],
- cclass);
- zport[cport + cclass] = '\0';
- }
- }
-
- /* Make sure the name and baud rate match any argument. */
- if ((zname != NULL
- && strcmp (zport, zname) != 0)
- || (ibaud != 0
- && ilow != 0
- && (ilow > ibaud || ihigh < ibaud)))
- {
- if (zport != pzsplit[0])
- free ((pointer) zport);
- continue;
- }
-
- /* Some systems permit ,M after the device name. This means
- to open the port with O_NDELAY and then change it. We
- just ignore this flag, although perhaps we should record
- it somewhere. */
- pzsplit[1][strcspn (pzsplit[1], ",")] = '\0';
-
- /* Now we must construct the port information, so that we
- can pass it to pifn. The port type is determined by its
- name, unfortunately. The name "Direct" is used for a
- direct port, "TCP" for a TCP port, and anything else for
- a modem port. */
- pblock = NULL;
- _uuconf_uclear_port (qport);
- qport->uuconf_zname = zport;
- qport->uuconf_zprotocols = zprotos;
- if (strcmp (pzsplit[0], "Direct") == 0)
- {
- qport->uuconf_ttype = UUCONF_PORTTYPE_DIRECT;
- qport->uuconf_u.uuconf_sdirect.uuconf_zdevice = pzsplit[1];
- qport->uuconf_u.uuconf_sdirect.uuconf_ibaud = ilow;
- qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier = FALSE;
- qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow = TRUE;
- ppzdialer = NULL;
- }
- else if (strcmp (pzsplit[0], "TCP") == 0)
- {
- /* For a TCP port, the device name is taken as the TCP
- port to use. */
- qport->uuconf_ttype = UUCONF_PORTTYPE_TCP;
- qport->uuconf_ireliable
- = (UUCONF_RELIABLE_ENDTOEND | UUCONF_RELIABLE_RELIABLE
- | UUCONF_RELIABLE_EIGHT | UUCONF_RELIABLE_FULLDUPLEX
- | UUCONF_RELIABLE_SPECIFIED);
- qport->uuconf_u.uuconf_stcp.uuconf_zport = pzsplit[1];
- ppzdialer = &qport->uuconf_u.uuconf_stcp.uuconf_pzdialer;
- }
- else if (ctoks >= 5
- && (strcmp (pzsplit[4], "TLI") == 0
- || strcmp (pzsplit[4], "TLIS") == 0))
- {
- qport->uuconf_ttype = UUCONF_PORTTYPE_TLI;
- qport->uuconf_u.uuconf_stli.uuconf_zdevice = pzsplit[1];
- qport->uuconf_u.uuconf_stli.uuconf_fstream
- = strcmp (pzsplit[4], "TLIS") == 0;
- qport->uuconf_u.uuconf_stli.uuconf_pzpush = NULL;
- qport->uuconf_u.uuconf_stli.uuconf_zservaddr = NULL;
- qport->uuconf_ireliable
- = (UUCONF_RELIABLE_ENDTOEND | UUCONF_RELIABLE_RELIABLE
- | UUCONF_RELIABLE_EIGHT | UUCONF_RELIABLE_FULLDUPLEX
- | UUCONF_RELIABLE_SPECIFIED);
- ppzdialer = &qport->uuconf_u.uuconf_stli.uuconf_pzdialer;
- }
- else
- {
- qport->uuconf_ttype = UUCONF_PORTTYPE_MODEM;
- qport->uuconf_u.uuconf_smodem.uuconf_zdevice = pzsplit[1];
- if (strcmp (pzsplit[2], "-") != 0)
- qport->uuconf_u.uuconf_smodem.uuconf_zdial_device =
- pzsplit[2];
- else
- qport->uuconf_u.uuconf_smodem.uuconf_zdial_device = NULL;
- if (ilow == ihigh)
- {
- qport->uuconf_u.uuconf_smodem.uuconf_ibaud = ilow;
- qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = 0L;
- qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = 0L;
- }
- else
- {
- qport->uuconf_u.uuconf_smodem.uuconf_ibaud = 0L;
- qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = ilow;
- qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = ihigh;
- }
- qport->uuconf_u.uuconf_smodem.uuconf_fcarrier = TRUE;
- qport->uuconf_u.uuconf_smodem.uuconf_fhardflow = TRUE;
- qport->uuconf_u.uuconf_smodem.uuconf_qdialer = NULL;
- ppzdialer = &qport->uuconf_u.uuconf_smodem.uuconf_pzdialer;
- }
-
- if (ppzdialer != NULL)
- {
- if (ctoks < 5)
- *ppzdialer = NULL;
- else
- {
- size_t c;
- char **pzd;
-
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- c = (ctoks - 4) * sizeof (char *);
- pzd = (char **) uuconf_malloc (pblock, c + sizeof (char *));
- if (pzd == NULL)
- {
- qglobal->ierrno = errno;
- uuconf_free_block (pblock);
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- memcpy ((pointer) pzd, (pointer) (pzsplit + 4), c);
- pzd[ctoks - 4] = NULL;
-
- *ppzdialer = pzd;
- }
- }
-
- if (pifn != NULL)
- {
- iret = (*pifn) (qport, pinfo);
- if (iret != UUCONF_SUCCESS)
- {
- if (zport != pzsplit[0])
- free ((pointer) zport);
- if (pblock != NULL)
- uuconf_free_block (pblock);
- if (iret != UUCONF_NOT_FOUND)
- break;
- continue;
- }
- }
-
- /* This is the port we want. */
- if (pblock == NULL)
- {
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- }
-
- if (uuconf_add_block (pblock, zline) != 0
- || (zport != pzsplit[0]
- && uuconf_add_block (pblock, zport) != 0))
- {
- qglobal->ierrno = errno;
- uuconf_free_block (pblock);
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- zline = NULL;
-
- qport->uuconf_palloc = pblock;
-
- iret = UUCONF_SUCCESS;
-
- break;
- }
-
- (void) fclose (e);
-
- if (iret != UUCONF_NOT_FOUND)
- break;
- }
-
- if (zline != NULL)
- free ((pointer) zline);
- if (pzsplit != NULL)
- free ((pointer) pzsplit);
-
- if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND)
- {
- qglobal->zfilename = *pz;
- iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- }
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/hrmunk.c b/gnu/libexec/uucp/libuuconf/hrmunk.c
deleted file mode 100644
index ecfdefc..0000000
--- a/gnu/libexec/uucp/libuuconf/hrmunk.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* remunk.c
- Get the name of the HDB remote.unknown shell script.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_hrmunk_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Get the name of the HDB remote.unknown shell script. */
-
-int
-uuconf_hdb_remote_unknown (pglobal, pzname)
- pointer pglobal;
- char **pzname;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- size_t csize;
-
- csize = sizeof OLDCONFIGLIB + sizeof HDB_REMOTE_UNKNOWN - 1;
- *pzname = malloc (csize);
- if (*pzname == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- memcpy (*pzname, OLDCONFIGLIB, sizeof OLDCONFIGLIB - 1);
- memcpy (*pzname + sizeof OLDCONFIGLIB - 1, HDB_REMOTE_UNKNOWN,
- sizeof HDB_REMOTE_UNKNOWN);
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/hsinfo.c b/gnu/libexec/uucp/libuuconf/hsinfo.c
deleted file mode 100644
index 74d9919..0000000
--- a/gnu/libexec/uucp/libuuconf/hsinfo.c
+++ /dev/null
@@ -1,637 +0,0 @@
-/* hsinfo.c
- Get information about a system from the HDB configuration files.
-
- Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_hsinfo_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-static int ihadd_machine_perm P((struct sglobal *qglobal,
- struct uuconf_system *qsys,
- struct shpermissions *qperm));
-static int ihadd_logname_perm P((struct sglobal *qglobal,
- struct uuconf_system *qsys,
- struct shpermissions *qperm));
-
-/* Get the information for a particular system from the HDB
- configuration files. This does not make sure that all the default
- values are set. */
-
-int
-_uuconf_ihdb_system_internal (qglobal, zsystem, qsys)
- struct sglobal *qglobal;
- const char *zsystem;
- struct uuconf_system *qsys;
-{
- int iret;
- struct shpermissions *qperm;
- char *zline;
- size_t cline;
- char **pzsplit;
- size_t csplit;
- char **pzcomma;
- size_t ccomma;
- pointer pblock;
- char **pz;
- boolean ffound_machine, ffound_login;
- struct shpermissions *qother_machine;
- struct uuconf_system *qalt;
-
- if (! qglobal->qprocess->fhdb_read_permissions)
- {
- iret = _uuconf_ihread_permissions (qglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- /* First look through the Permissions information to see if this is
- an alias for some system. I assume that an alias applies to the
- first name in the corresponding MACHINE entry. */
-
- for (qperm = qglobal->qprocess->qhdb_permissions;
- qperm != NULL;
- qperm = qperm->qnext)
- {
- if (qperm->pzalias == NULL
- || qperm->pzmachine == NULL
- || qperm->pzalias == (char **) &_uuconf_unset
- || qperm->pzmachine == (char **) &_uuconf_unset)
- continue;
-
- for (pz = qperm->pzalias; *pz != NULL; pz++)
- {
- if (strcmp (*pz, zsystem) == 0)
- {
- zsystem = qperm->pzmachine[0];
- break;
- }
- }
- if (*pz != NULL)
- break;
- }
-
- zline = NULL;
- cline = 0;
- pzsplit = NULL;
- csplit = 0;
- pzcomma = NULL;
- ccomma = 0;
-
- pblock = NULL;
-
- iret = UUCONF_SUCCESS;
-
- for (pz = qglobal->qprocess->pzhdb_systems; *pz != NULL; pz++)
- {
- FILE *e;
- int cchars;
-
- qglobal->ilineno = 0;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0)
- {
- int ctoks, ctimes, i;
- struct uuconf_system *qset;
- char *z, *zretry;
- int cretry;
-
- ++qglobal->ilineno;
-
- --cchars;
- if (zline[cchars] == '\n')
- zline[cchars] = '\0';
- if (isspace (BUCHAR (zline[0])) || zline[0] == '#')
- continue;
-
- ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit);
- if (ctoks < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- /* If this isn't the system we're looking for, keep reading
- the file. */
- if (ctoks < 1
- || strcmp (zsystem, pzsplit[0]) != 0)
- continue;
-
- /* If this is the first time we've found the system, we want
- to set *qsys directly. Otherwise, we allocate a new
- alternate. */
- if (pblock == NULL)
- {
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- _uuconf_uclear_system (qsys);
- qsys->uuconf_palloc = pblock;
- qset = qsys;
- }
- else
- {
- struct uuconf_system **pq;
-
- qset = ((struct uuconf_system *)
- uuconf_malloc (pblock, sizeof (struct uuconf_system)));
- if (qset == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- _uuconf_uclear_system (qset);
- for (pq = &qsys->uuconf_qalternate;
- *pq != NULL;
- pq = &(*pq)->uuconf_qalternate)
- ;
- *pq = qset;
- }
-
- /* Add this line to the memory block we are building for the
- system. */
- if (uuconf_add_block (pblock, zline) != 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- zline = NULL;
- cline = 0;
-
- /* The format of a line in Systems is
- system time device speed phone chat
- For example,
- airs Any ACU 9600 5551212 ogin: foo pass: bar
- */
-
- /* Get the system name. */
-
- qset->uuconf_zname = pzsplit[0];
- qset->uuconf_fcall = TRUE;
- qset->uuconf_fcalled = FALSE;
-
- if (ctoks < 2)
- continue;
-
- /* A time string is "time/grade,time/grade;retry". A
- missing grade is taken as BGRADE_LOW. */
- zretry = strchr (pzsplit[1], ';');
- if (zretry == NULL)
- cretry = 0;
- else
- {
- *zretry = '\0';
- cretry = (int) strtol (zretry + 1, (char **) NULL, 10);
- }
-
- ctimes = _uuconf_istrsplit (pzsplit[1], ',', &pzcomma, &ccomma);
- if (ctimes < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- for (i = 0; i < ctimes; i++)
- {
- char *zslash;
- char bgrade;
-
- z = pzcomma[i];
- zslash = strchr (z, '/');
- if (zslash == NULL)
- bgrade = UUCONF_GRADE_LOW;
- else
- {
- *zslash = '\0';
- bgrade = zslash[1];
- if (! UUCONF_GRADE_LEGAL (bgrade))
- bgrade = UUCONF_GRADE_LOW;
- }
-
- iret = _uuconf_itime_parse (qglobal, z, (long) bgrade,
- cretry, _uuconf_itime_grade_cmp,
- &qset->uuconf_qtimegrade,
- pblock);
-
- /* We treat a syntax error in the time field as
- equivalent to ``never'', on the assumption that that
- is what HDB does. */
- if (iret == UUCONF_SYNTAX_ERROR)
- iret = UUCONF_SUCCESS;
-
- if (iret != UUCONF_SUCCESS)
- break;
-
- /* Treat any time/grade setting as both a timegrade and
- a call-timegrade. */
- if (bgrade != UUCONF_GRADE_LOW)
- qset->uuconf_qcalltimegrade = qset->uuconf_qtimegrade;
- }
-
- if (iret != UUCONF_SUCCESS)
- break;
-
- if (ctoks < 3)
- continue;
-
- /* Pick up the device name. It can be followed by a comma
- and a list of protocols. */
- qset->uuconf_zport = pzsplit[2];
- z = strchr (pzsplit[2], ',');
- if (z != NULL)
- {
- qset->uuconf_zprotocols = z + 1;
- *z = '\0';
- }
-
- if (ctoks < 4)
- continue;
-
- /* The speed entry can be a numeric speed, or a range of
- speeds, or "Any", or "-". If it starts with a letter,
- the initial nonnumeric prefix is a modem class, which
- gets appended to the port name. */
- z = pzsplit[3];
- if (strcasecmp (z, "Any") != 0
- && strcmp (z, "-") != 0)
- {
- char *zend;
-
- while (*z != '\0' && ! isdigit (BUCHAR (*z)))
- ++z;
-
- qset->uuconf_ibaud = strtol (z, &zend, 10);
- if (*zend == '-')
- qset->uuconf_ihighbaud = strtol (zend + 1, (char **) NULL,
- 10);
-
- if (z != pzsplit[3])
- {
- size_t cport, cclass;
-
- cport = strlen (pzsplit[2]);
- cclass = z - pzsplit[3];
- qset->uuconf_zport = uuconf_malloc (pblock,
- cport + cclass + 1);
- if (qset->uuconf_zport == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- memcpy ((pointer) qset->uuconf_zport, (pointer) pzsplit[2],
- cport);
- memcpy ((pointer) (qset->uuconf_zport + cport),
- (pointer) pzsplit[3], cclass);
- qset->uuconf_zport[cport + cclass] = '\0';
- }
- }
-
- if (ctoks < 5)
- continue;
-
- /* Get the phone number. */
- qset->uuconf_zphone = pzsplit[4];
-
- if (ctoks < 6)
- continue;
-
- /* Get the chat script. We just hand this off to the chat
- script processor, so that it will parse subsend and
- subexpect strings correctly. */
- pzsplit[4] = (char *) "chat";
- iret = _uuconf_ichat_cmd (qglobal, ctoks - 4, pzsplit + 4,
- &qset->uuconf_schat, pblock);
- iret &=~ UUCONF_CMDTABRET_KEEP;
- if (iret != UUCONF_SUCCESS)
- break;
- }
-
- (void) fclose (e);
-
- if (iret != UUCONF_SUCCESS)
- break;
- }
-
- if (zline != NULL)
- free ((pointer) zline);
- if (pzsplit != NULL)
- free ((pointer) pzsplit);
- if (pzcomma != NULL)
- free ((pointer) pzcomma);
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = *pz;
- return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- }
-
- if (pblock == NULL)
- return UUCONF_NOT_FOUND;
-
- /* Now we have to put in the Permissions information. The relevant
- Permissions entries are those with this system in the MACHINE
- list and (if this system does not have a VALIDATE entry) those
- with a LOGNAME list but no MACHINE list. If no entry is found
- with this system in the MACHINE list, then we must look for an
- entry with "OTHER" in the MACHINE list. */
- ffound_machine = FALSE;
- ffound_login = FALSE;
- qother_machine = NULL;
- for (qperm = qglobal->qprocess->qhdb_permissions;
- qperm != NULL;
- qperm = qperm->qnext)
- {
- boolean fmachine;
-
- /* MACHINE=OTHER is recognized specially. It appears that OTHER
- need only be recognized by itself, not when combined with
- other machine names. */
- if (qother_machine == NULL
- && qperm->pzmachine != NULL
- && qperm->pzmachine != (char **) &_uuconf_unset
- && qperm->pzmachine[0][0] == 'O'
- && strcmp (qperm->pzmachine[0], "OTHER") == 0)
- qother_machine = qperm;
-
- /* If this system is named in a MACHINE entry, we must add the
- appropriate information to every alternate that could be used
- for calling out. */
- fmachine = FALSE;
- if (! ffound_machine
- && qperm->pzmachine != NULL
- && qperm->pzmachine != (char **) &_uuconf_unset)
- {
- for (pz = qperm->pzmachine; *pz != NULL; pz++)
- {
- if ((*pz)[0] == zsystem[0]
- && strcmp (*pz, zsystem) == 0)
- {
- for (qalt = qsys;
- qalt != NULL;
- qalt = qalt->uuconf_qalternate)
- {
- if (qalt->uuconf_fcall)
- {
- iret = ihadd_machine_perm (qglobal, qalt, qperm);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- }
-
- fmachine = TRUE;
- ffound_machine = TRUE;
-
- break;
- }
- }
- }
-
- /* A LOGNAME line applies to this machine if it is listed in the
- corresponding VALIDATE entry, or if it is not listed in any
- VALIDATE entry. On this pass through the Permissions entry
- we pick up the information if the system appears in a
- VALIDATE entry; if it does not, we make another pass to put
- in all the LOGNAME lines. */
- if (qperm->pzlogname != NULL
- && qperm->pzlogname != (char **) &_uuconf_unset
- && qperm->pzvalidate != NULL
- && qperm->pzvalidate != (char **) &_uuconf_unset)
- {
- for (pz = qperm->pzvalidate; *pz != NULL; ++pz)
- if ((*pz)[0] == zsystem[0]
- && strcmp (*pz, zsystem) == 0)
- break;
- if (*pz != NULL)
- {
- for (pz = qperm->pzlogname; *pz != NULL; ++pz)
- {
- /* If this LOGNAME line is also a matching MACHINE
- line, we can add the LOGNAME permissions to the
- first alternate. Otherwise, we must create a new
- alternate. We cannot put a LOGNAME line in the
- first alternate if MACHINE does not match,
- because certain permissions (e.g. READ) may be
- specified by both types of lines, and we must use
- LOGNAME entries only when accepting calls and
- MACHINE entries only when placing calls. */
- if (fmachine
- && (qsys->uuconf_zcalled_login == NULL
- || (qsys->uuconf_zcalled_login
- == (char *) &_uuconf_unset)))
- {
- qsys->uuconf_zcalled_login = *pz;
- iret = ihadd_logname_perm (qglobal, qsys, qperm);
- }
- else
- {
- struct uuconf_system *qnew;
- struct uuconf_system **pq;
-
- qnew = ((struct uuconf_system *)
- uuconf_malloc (pblock,
- sizeof (struct uuconf_system)));
- if (qnew == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- *qnew = *qsys;
- qnew->uuconf_qalternate = NULL;
- for (pq = &qsys->uuconf_qalternate;
- *pq != NULL;
- pq = &(*pq)->uuconf_qalternate)
- ;
- *pq = qnew;
-
- qnew->uuconf_zcalled_login = *pz;
- qnew->uuconf_fcall = FALSE;
- iret = ihadd_logname_perm (qglobal, qnew, qperm);
- }
-
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- ffound_login = TRUE;
- }
- }
- }
-
- /* If we didn't find an entry for the machine, we must use the
- MACHINE=OTHER entry, if any. */
- if (! ffound_machine && qother_machine != NULL)
- {
- for (qalt = qsys; qalt != NULL; qalt = qalt->uuconf_qalternate)
- {
- if (qalt->uuconf_fcall)
- {
- iret = ihadd_machine_perm (qglobal, qalt, qother_machine);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- }
- }
-
- /* If this system was not listed in any VALIDATE entry, then we must
- add a called-login for each LOGNAME entry in Permissions. */
- if (! ffound_login)
- {
- for (qperm = qglobal->qprocess->qhdb_permissions;
- qperm != NULL;
- qperm = qperm->qnext)
- {
- if (qperm->pzlogname == NULL
- || qperm->pzlogname == (char **) &_uuconf_unset)
- continue;
-
- for (pz = qperm->pzlogname; *pz != NULL; pz++)
- {
- struct uuconf_system *qnew;
- struct uuconf_system **pq;
-
- qnew = ((struct uuconf_system *)
- uuconf_malloc (pblock,
- sizeof (struct uuconf_system)));
- if (qnew == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- *qnew = *qsys;
- qnew->uuconf_qalternate = NULL;
- for (pq = &qsys->uuconf_qalternate;
- *pq != NULL;
- pq = &(*pq)->uuconf_qalternate)
- ;
- *pq = qnew;
-
- /* We recognize LOGNAME=OTHER specially, although this
- appears to be an SCO innovation. */
- if (strcmp (*pz, "OTHER") == 0)
- qnew->uuconf_zcalled_login = (char *) "ANY";
- else
- qnew->uuconf_zcalled_login = *pz;
- qnew->uuconf_fcall = FALSE;
- iret = ihadd_logname_perm (qglobal, qnew, qperm);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- }
- }
-
- /* HDB permits local requests to receive to any directory, which is
- not the default put in by _uuconf_isystem_basic_default. We set
- it here instead. */
- for (qalt = qsys; qalt != NULL; qalt = qalt->uuconf_qalternate)
- {
- iret = _uuconf_iadd_string (qglobal, (char *) ZROOTDIR,
- FALSE, FALSE,
- &qalt->uuconf_pzlocal_receive,
- pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- /* HDB does not have a maximum number of retries if a retry time is
- given in the time field. */
- if (qsys->uuconf_qtimegrade != NULL
- && qsys->uuconf_qtimegrade != (struct uuconf_timespan *) &_uuconf_unset
- && qsys->uuconf_qtimegrade->uuconf_cretry > 0)
- qsys->uuconf_cmax_retries = 0;
-
- return UUCONF_SUCCESS;
-}
-
-/* Add the settings of a MACHINE line in Permissions to a system. */
-
-/*ARGSIGNORED*/
-static int
-ihadd_machine_perm (qglobal, qsys, qperm)
- struct sglobal *qglobal;
- struct uuconf_system *qsys;
- struct shpermissions *qperm;
-{
- if (qperm->frequest >= 0)
- qsys->uuconf_fsend_request = qperm->frequest;
- else
- qsys->uuconf_fsend_request = FALSE;
- qsys->uuconf_pzremote_send = qperm->pzread;
- qsys->uuconf_pzremote_receive = qperm->pzwrite;
- qsys->uuconf_pzcmds = qperm->pzcommands;
- qsys->uuconf_zlocalname = qperm->zmyname;
- qsys->uuconf_zpubdir = qperm->zpubdir;
- qsys->uuconf_pzalias = qperm->pzalias;
-
- return UUCONF_SUCCESS;
-}
-
-/* Add the settings of a LOGNAME line in Permissions to a system. */
-
-/*ARGSIGNORED*/
-static int
-ihadd_logname_perm (qglobal, qsys, qperm)
- struct sglobal *qglobal;
- struct uuconf_system *qsys;
- struct shpermissions *qperm;
-{
- qsys->uuconf_fcalled = TRUE;
- if (qperm->frequest >= 0)
- qsys->uuconf_fsend_request = qperm->frequest;
- else
- qsys->uuconf_fsend_request = FALSE;
- qsys->uuconf_fcalled_transfer = qperm->fsendfiles;
- qsys->uuconf_pzremote_send = qperm->pzread;
- qsys->uuconf_pzremote_receive = qperm->pzwrite;
- qsys->uuconf_fcallback = qperm->fcallback;
- qsys->uuconf_zlocalname = qperm->zmyname;
- qsys->uuconf_zpubdir = qperm->zpubdir;
-
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/hsnams.c b/gnu/libexec/uucp/libuuconf/hsnams.c
deleted file mode 100644
index a459877..0000000
--- a/gnu/libexec/uucp/libuuconf/hsnams.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* hsnams.c
- Get all known system names from the HDB configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_hsnams_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-/* Get all the system names from the HDB Systems file. We have to
- read the Permissions file in order to support aliases. */
-
-int
-uuconf_hdb_system_names (pglobal, ppzsystems, falias)
- pointer pglobal;
- char ***ppzsystems;
- int falias;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
- char *zline;
- size_t cline;
- char **pz;
-
- *ppzsystems = NULL;
-
- iret = UUCONF_SUCCESS;
-
- zline = NULL;
- cline = 0;
-
- for (pz = qglobal->qprocess->pzhdb_systems; *pz != NULL; pz++)
- {
- FILE *e;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- qglobal->ilineno = 0;
-
- while (_uuconf_getline (qglobal, &zline, &cline, e) > 0)
- {
- ++qglobal->ilineno;
-
- /* Lines beginning with whitespace are treated as comments.
- No system name can contain a '#', which is another
- comment character, so eliminating the first '#' does no
- harm and catches comments. */
- zline[strcspn (zline, " \t#\n")] = '\0';
- if (*zline == '\0')
- continue;
-
- iret = _uuconf_iadd_string (qglobal, zline, TRUE, TRUE,
- ppzsystems, (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- {
- iret |= UUCONF_ERROR_LINENO;
- break;
- }
- }
-
- (void) fclose (e);
- }
-
- if (zline != NULL)
- free ((pointer) zline);
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = *pz;
- return iret | UUCONF_ERROR_FILENAME;
- }
-
- /* If we are supposed to return aliases, we must read the
- Permissions file. */
- if (falias)
- {
- struct shpermissions *q;
-
- if (! qglobal->qprocess->fhdb_read_permissions)
- {
- iret = _uuconf_ihread_permissions (qglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- for (q = qglobal->qprocess->qhdb_permissions;
- q != NULL;
- q = q->qnext)
- {
- pz = q->pzalias;
- if (pz == NULL || pz == (char **) &_uuconf_unset)
- continue;
-
- for (; *pz != NULL; pz++)
- {
- iret = _uuconf_iadd_string (qglobal, *pz, TRUE, TRUE,
- ppzsystems, (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- }
- }
-
- if (*ppzsystems == NULL)
- iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
- ppzsystems, (pointer) NULL);
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/hsys.c b/gnu/libexec/uucp/libuuconf/hsys.c
deleted file mode 100644
index 2f9940c..0000000
--- a/gnu/libexec/uucp/libuuconf/hsys.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* hsys.c
- User function to get a system from the HDB configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_hsys_rcsid[] = "$Id$";
-#endif
-
-/* Get system information from the HDB configuration files. This is a
- wrapper for the internal function which makes sure that every field
- gets a default value. */
-
-int
-uuconf_hdb_system_info (pglobal, zsystem, qsys)
- pointer pglobal;
- const char *zsystem;
- struct uuconf_system *qsys;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
-
- iret = _uuconf_ihdb_system_internal (qglobal, zsystem, qsys);
- if (iret != UUCONF_SUCCESS)
- return iret;
- return _uuconf_isystem_basic_default (qglobal, qsys);
-}
diff --git a/gnu/libexec/uucp/libuuconf/hunk.c b/gnu/libexec/uucp/libuuconf/hunk.c
deleted file mode 100644
index 6d37583..0000000
--- a/gnu/libexec/uucp/libuuconf/hunk.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* hunk.c
- Get information about an unknown system from the HDB Permissions file.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_hunk_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Get information about an unknown system from the HDB Permissions
- file. This doesn't run the remote.unknown shell script, because
- that's too system dependent. */
-
-int
-uuconf_hdb_system_unknown (pglobal, qsys)
- pointer pglobal;
- struct uuconf_system *qsys;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
- boolean ffirst;
- struct shpermissions *qperm;
- struct uuconf_system *qalt;
-
- if (! qglobal->qprocess->fhdb_read_permissions)
- {
- iret = _uuconf_ihread_permissions (qglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- _uuconf_uclear_system (qsys);
- qsys->uuconf_palloc = uuconf_malloc_block ();
- if (qsys->uuconf_palloc == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- ffirst = TRUE;
-
- for (qperm = qglobal->qprocess->qhdb_permissions;
- qperm != NULL;
- qperm = qperm->qnext)
- {
- char **pz;
-
- if (qperm->pzlogname == NULL
- || qperm->pzlogname == (char **) &_uuconf_unset)
- continue;
-
- for (pz = qperm->pzlogname; *pz != NULL; pz++)
- {
- if (ffirst)
- {
- qalt = qsys;
- ffirst = FALSE;
- }
- else
- {
- struct uuconf_system **pq;
-
- qalt = ((struct uuconf_system *)
- uuconf_malloc (qsys->uuconf_palloc,
- sizeof (struct uuconf_system)));
- if (qalt == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- _uuconf_uclear_system (qalt);
- for (pq = &qsys->uuconf_qalternate;
- *pq != NULL;
- pq = &(*pq)->uuconf_qalternate)
- ;
- *pq = qalt;
- }
-
- /* We recognize LOGNAME=OTHER specially, although this
- appears to be an SCO innovation. */
- if (strcmp (*pz, "OTHER") == 0)
- qalt->uuconf_zcalled_login = (char *) "ANY";
- else
- qalt->uuconf_zcalled_login = *pz;
- qalt->uuconf_fcall = FALSE;
- qsys->uuconf_fcalled = TRUE;
- if (qperm->frequest >= 0)
- qsys->uuconf_fsend_request = qperm->frequest;
- else
- qsys->uuconf_fsend_request = FALSE;
- qsys->uuconf_fcalled_transfer = qperm->fsendfiles;
- qsys->uuconf_pzremote_send = qperm->pzread;
- qsys->uuconf_pzremote_receive = qperm->pzwrite;
- qsys->uuconf_fcallback = qperm->fcallback;
- qsys->uuconf_zlocalname = qperm->zmyname;
- qsys->uuconf_zpubdir = qperm->zpubdir;
- }
- }
-
- if (ffirst)
- return UUCONF_NOT_FOUND;
-
- /* HDB permits local requests to receive to any directory, which is
- not the default put in by _uuconf_isystem_basic_default. We set
- it here instead. */
- for (qalt = qsys; qalt != NULL; qalt = qalt->uuconf_qalternate)
- {
- iret = _uuconf_iadd_string (qglobal, (char *) ZROOTDIR,
- FALSE, FALSE,
- &qalt->uuconf_pzlocal_receive,
- qsys->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- return _uuconf_isystem_basic_default (qglobal, qsys);
-}
diff --git a/gnu/libexec/uucp/libuuconf/iniglb.c b/gnu/libexec/uucp/libuuconf/iniglb.c
deleted file mode 100644
index 5424193..0000000
--- a/gnu/libexec/uucp/libuuconf/iniglb.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/* iniglb.c
- Initialize the global information structure.
-
- Copyright (C) 1992, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_iniglb_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Initialize the global information structure. */
-
-int
-_uuconf_iinit_global (pqglobal)
- struct sglobal **pqglobal;
-{
- pointer pblock;
- register struct sprocess *qprocess;
- char *azargs[3];
- int iret;
-
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- return UUCONF_MALLOC_FAILED;
-
- *pqglobal = (struct sglobal *) uuconf_malloc (pblock,
- sizeof (struct sglobal));
- if (*pqglobal == NULL)
- {
- uuconf_free_block (pblock);
- return UUCONF_MALLOC_FAILED;
- }
-
- (*pqglobal)->qprocess = ((struct sprocess *)
- uuconf_malloc (pblock,
- sizeof (struct sprocess)));
- if ((*pqglobal)->qprocess == NULL)
- {
- uuconf_free_block (pblock);
- *pqglobal = NULL;
- return UUCONF_MALLOC_FAILED;
- }
-
- (*pqglobal)->pblock = pblock;
- (*pqglobal)->ierrno = 0;
- (*pqglobal)->ilineno = 0;
- (*pqglobal)->zfilename = NULL;
-
- qprocess = (*pqglobal)->qprocess;
-
- qprocess->zlocalname = NULL;
- qprocess->zspooldir = SPOOLDIR;
- qprocess->zpubdir = PUBDIR;
-#ifdef LOCKDIR
- qprocess->zlockdir = LOCKDIR;
-#else
- qprocess->zlockdir = SPOOLDIR;
-#endif
- qprocess->zlogfile = LOGFILE;
- qprocess->zstatsfile = STATFILE;
- qprocess->zdebugfile = DEBUGFILE;
- qprocess->zdebug = "";
- qprocess->fstrip_login = TRUE;
- qprocess->fstrip_proto = TRUE;
- qprocess->cmaxuuxqts = 0;
- qprocess->zrunuuxqt = NULL;
- qprocess->fv2 = TRUE;
- qprocess->fhdb = TRUE;
- qprocess->pzdialcodefiles = NULL;
- qprocess->pztimetables = NULL;
- qprocess->zconfigfile = NULL;
- qprocess->pzsysfiles = NULL;
- qprocess->pzportfiles = NULL;
- qprocess->pzdialfiles = NULL;
- qprocess->pzpwdfiles = NULL;
- qprocess->pzcallfiles = NULL;
- qprocess->qunknown = NULL;
- qprocess->fread_syslocs = FALSE;
- qprocess->qsyslocs = NULL;
- qprocess->qvalidate = NULL;
- qprocess->fuses_myname = FALSE;
- qprocess->zv2systems = NULL;
- qprocess->zv2devices = NULL;
- qprocess->zv2userfile = NULL;
- qprocess->zv2cmds = NULL;
- qprocess->pzhdb_systems = NULL;
- qprocess->pzhdb_devices = NULL;
- qprocess->pzhdb_dialers = NULL;
- qprocess->fhdb_read_permissions = FALSE;
- qprocess->qhdb_permissions = NULL;
-
- azargs[0] = NULL;
- azargs[1] = (char *) "Evening";
- azargs[2] = (char *) "Wk1705-0755,Sa,Su";
- iret = _uuconf_itimetable ((pointer) *pqglobal, 3, azargs,
- (pointer) NULL, (pointer) NULL);
- if (UUCONF_ERROR_VALUE (iret) == UUCONF_SUCCESS)
- {
- azargs[1] = (char *) "Night";
- azargs[2] = (char *) "Wk2305-0755,Sa,Su2305-1655";
- iret = _uuconf_itimetable ((pointer) *pqglobal, 3, azargs,
- (pointer) NULL, (pointer) NULL);
- }
- if (UUCONF_ERROR_VALUE (iret) == UUCONF_SUCCESS)
- {
- azargs[1] = (char *) "NonPeak";
- azargs[2] = (char *) "Wk1805-0655,Sa,Su";
- iret = _uuconf_itimetable ((pointer) *pqglobal, 3, azargs,
- (pointer) NULL, (pointer) NULL);
- }
- if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS)
- {
- uuconf_free_block (pblock);
- *pqglobal = NULL;
-
- /* Strip off any special bits, since there's no global
- structure. */
- return UUCONF_ERROR_VALUE (iret);
- }
-
- return UUCONF_SUCCESS;
-}
-
-/* Add a timetable. This is also called by the Taylor UUCP
- initialization code, as well as by the Taylor UUCP sys file code
- (although the latter is obsolete). There's no point in putting
- this in a separate file, since everything must call
- _uuconf_init_global. There is a race condition here if this is
- called by two different threads on a sys file command, but the sys
- file command is obsolete anyhow. */
-
-/*ARGSUSED*/
-int
-_uuconf_itimetable (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
-
- iret = _uuconf_iadd_string (qglobal, argv[1], FALSE, FALSE,
- &qglobal->qprocess->pztimetables,
- qglobal->pblock);
- if (iret != UUCONF_SUCCESS)
- return iret | UUCONF_CMDTABRET_EXIT;
-
- iret = _uuconf_iadd_string (qglobal, argv[2], FALSE, FALSE,
- &qglobal->qprocess->pztimetables,
- qglobal->pblock);
- if (iret != UUCONF_SUCCESS)
- return iret | UUCONF_CMDTABRET_EXIT;
-
- return UUCONF_CMDTABRET_KEEP;
-}
diff --git a/gnu/libexec/uucp/libuuconf/init.c b/gnu/libexec/uucp/libuuconf/init.c
deleted file mode 100644
index fd939d8..0000000
--- a/gnu/libexec/uucp/libuuconf/init.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* init.c
- Initialize for reading UUCP configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_init_rcsid[] = "$Id$";
-#endif
-
-/* Initialize the UUCP configuration file reading routines. This is
- just a generic routine which calls the type specific routines. */
-
-/*ARGSUSED*/
-int
-uuconf_init (ppglobal, zprogram, zname)
- pointer *ppglobal;
- const char *zprogram;
- const char *zname;
-{
- struct sglobal **pqglob = (struct sglobal **) ppglobal;
- int iret;
-
- iret = UUCONF_NOT_FOUND;
-
- *pqglob = NULL;
-
-#if HAVE_TAYLOR_CONFIG
- iret = uuconf_taylor_init (ppglobal, zprogram, zname);
- if (iret != UUCONF_SUCCESS)
- return iret;
-#endif
-
-#if HAVE_V2_CONFIG
- if (*pqglob == NULL || (*pqglob)->qprocess->fv2)
- {
- iret = uuconf_v2_init (ppglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-#endif
-
-#if HAVE_HDB_CONFIG
- if (*pqglob == NULL || (*pqglob)->qprocess->fhdb)
- {
- iret = uuconf_hdb_init (ppglobal, zprogram);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-#endif
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/int.c b/gnu/libexec/uucp/libuuconf/int.c
deleted file mode 100644
index 0fc3983..0000000
--- a/gnu/libexec/uucp/libuuconf/int.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* int.c
- Parse a string into an int or a long.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_int_rcsid[] = "$Id$";
-#endif
-
-/* Parse a string into a variable. This is called by uuconf_cmd_args,
- as well as other functions. The parsing is done in a single place
- to make it easy to change. This should return an error code,
- including both UUCONF_CMDTABRET_KEEP and UUCONF_CMDTABRET_EXIT if
- appropriate. */
-
-/*ARGSIGNORED*/
-int
-_uuconf_iint (qglobal, zval, p, fint)
- struct sglobal *qglobal;
- const char *zval;
- pointer p;
- boolean fint;
-{
- long i;
- char *zend;
-
- i = strtol ((char *) zval, &zend, 10);
- if (*zend != '\0')
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- if (fint)
- *(int *) p = (int) i;
- else
- *(long *) p = i;
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
diff --git a/gnu/libexec/uucp/libuuconf/lckdir.c b/gnu/libexec/uucp/libuuconf/lckdir.c
deleted file mode 100644
index 050c7a6..0000000
--- a/gnu/libexec/uucp/libuuconf/lckdir.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* lckdir.c
- Get the name of the UUCP lock directory.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_lckdir_rcsid[] = "$Id$";
-#endif
-
-/* Get the name of the UUCP lock directory. */
-
-int
-uuconf_lockdir (pglobal, pzlock)
- pointer pglobal;
- const char **pzlock;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pzlock = qglobal->qprocess->zlockdir;
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/lineno.c b/gnu/libexec/uucp/libuuconf/lineno.c
deleted file mode 100644
index 0b5d721..0000000
--- a/gnu/libexec/uucp/libuuconf/lineno.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* lineno.c
- Return the saved line number.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_lineno_rcsid[] = "$Id$";
-#endif
-
-/* Return the saved line number. */
-
-int
-uuconf_error_lineno (pglobal)
- pointer pglobal;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- if (qglobal == NULL)
- return 0;
- else
- return qglobal->ilineno;
-}
diff --git a/gnu/libexec/uucp/libuuconf/llocnm.c b/gnu/libexec/uucp/libuuconf/llocnm.c
deleted file mode 100644
index 01eab4a..0000000
--- a/gnu/libexec/uucp/libuuconf/llocnm.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* llocnm.c
- Get the local name to use, given a login name.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_llocnm_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Get the local name to use, given a login name. */
-
-int
-uuconf_login_localname (pglobal, zlogin, pzname)
- pointer pglobal;
- const char *zlogin;
- char **pzname;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
-
-#if HAVE_TAYLOR_CONFIG
- iret = uuconf_taylor_login_localname (pglobal, zlogin, pzname);
- if (iret != UUCONF_NOT_FOUND)
- return iret;
-#endif
-
-#if HAVE_HDB_CONFIG
- if (qglobal->qprocess->fhdb)
- {
- iret = uuconf_hdb_login_localname (pglobal, zlogin, pzname);
- if (iret != UUCONF_NOT_FOUND)
- return iret;
- }
-#endif
-
- if (qglobal->qprocess->zlocalname != NULL)
- {
- *pzname = strdup ((char *) qglobal->qprocess->zlocalname);
- if (*pzname == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- return UUCONF_SUCCESS;
- }
-
- *pzname = NULL;
- return UUCONF_NOT_FOUND;
-}
diff --git a/gnu/libexec/uucp/libuuconf/local.c b/gnu/libexec/uucp/libuuconf/local.c
deleted file mode 100644
index db12322..0000000
--- a/gnu/libexec/uucp/libuuconf/local.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* local.c
- Get default information for the local system.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_local_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Get default information about the local system. */
-
-int
-uuconf_system_local (pglobal, qsys)
- pointer pglobal;
- struct uuconf_system *qsys;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
-
- _uuconf_uclear_system (qsys);
- qsys->uuconf_palloc = uuconf_malloc_block ();
- if (qsys->uuconf_palloc == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- qsys->uuconf_zname = (char *) qglobal->qprocess->zlocalname;
-
- /* By default, we permit the local system to forward to and from any
- system. */
- iret = _uuconf_iadd_string (qglobal, (char *) "ANY", FALSE, FALSE,
- &qsys->uuconf_pzforward_from,
- qsys->uuconf_palloc);
- if (iret == UUCONF_SUCCESS)
- iret = _uuconf_iadd_string (qglobal, (char *) "ANY", FALSE, FALSE,
- &qsys->uuconf_pzforward_to,
- qsys->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- {
- uuconf_free_block (qsys->uuconf_palloc);
- return iret;
- }
-
- return _uuconf_isystem_basic_default (qglobal, qsys);
-}
diff --git a/gnu/libexec/uucp/libuuconf/locnm.c b/gnu/libexec/uucp/libuuconf/locnm.c
deleted file mode 100644
index be4bb00..0000000
--- a/gnu/libexec/uucp/libuuconf/locnm.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* locnm.c
- Get the local node name.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_locnm_rcsid[] = "$Id$";
-#endif
-
-/* Get the local node name. */
-
-int
-uuconf_localname (pglobal, pzname)
- pointer pglobal;
- const char **pzname;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pzname = qglobal->qprocess->zlocalname;
- if (*pzname != NULL)
- return UUCONF_SUCCESS;
- else
- return UUCONF_NOT_FOUND;
-}
diff --git a/gnu/libexec/uucp/libuuconf/logfil.c b/gnu/libexec/uucp/libuuconf/logfil.c
deleted file mode 100644
index 8fc7eae..0000000
--- a/gnu/libexec/uucp/libuuconf/logfil.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* logfil.c
- Get the name of the UUCP log file.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_logfil_rcsid[] = "$Id$";
-#endif
-
-/* Get the name of the UUCP log file. */
-
-int
-uuconf_logfile (pglobal, pzlog)
- pointer pglobal;
- const char **pzlog;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pzlog = qglobal->qprocess->zlogfile;
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/maxuxq.c b/gnu/libexec/uucp/libuuconf/maxuxq.c
deleted file mode 100644
index 2285dd1..0000000
--- a/gnu/libexec/uucp/libuuconf/maxuxq.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* maxuxq.c
- Get the maximum number of simultaneous uuxqt executions.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_maxuxq_rcsid[] = "$Id$";
-#endif
-
-/* Get the maximum number of simultaneous uuxqt executions. When
- using TAYLOR_CONFIG, this is from the ``max-uuxqts'' command in
- config. Otherwise, when using HDB_CONFIG, we read the file
- Maxuuxqts. */
-
-int
-uuconf_maxuuxqts (pglobal, pcmax)
- pointer pglobal;
- int *pcmax;
-{
-#if HAVE_TAYLOR_CONFIG
- {
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pcmax = qglobal->qprocess->cmaxuuxqts;
- return UUCONF_SUCCESS;
- }
-#else /* ! HAVE_TAYLOR_CONFIG */
-#if HAVE_HDB_CONFIG
- {
- char ab[sizeof OLDCONFIGLIB + sizeof HDB_MAXUUXQTS - 1];
- FILE *e;
-
- *pcmax = 0;
-
- memcpy ((pointer) ab, (constpointer) OLDCONFIGLIB,
- sizeof OLDCONFIGLIB - 1);
- memcpy ((pointer) (ab + sizeof OLDCONFIGLIB - 1),
- (constpointer) HDB_MAXUUXQTS, sizeof HDB_MAXUUXQTS);
- e = fopen (ab, "r");
- if (e != NULL)
- {
- char *z;
- size_t c;
-
- z = NULL;
- c = 0;
- if (getline (&z, &c, e) > 0)
- {
- *pcmax = (int) strtol (z, (char **) NULL, 10);
- if (*pcmax < 0)
- *pcmax = 0;
- free ((pointer) z);
- }
- (void) fclose (e);
- }
-
- return UUCONF_SUCCESS;
- }
-#else /* ! HAVE_HDB_CONFIG */
- *pcmax = 0;
- return UUCONF_SUCCESS;
-#endif /* ! HAVE_HDB_CONFIG */
-#endif /* ! HAVE_TAYLOR_CONFIG */
-}
diff --git a/gnu/libexec/uucp/libuuconf/mrgblk.c b/gnu/libexec/uucp/libuuconf/mrgblk.c
deleted file mode 100644
index d3b89bd..0000000
--- a/gnu/libexec/uucp/libuuconf/mrgblk.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* mrgblk.c
- Merge two memory blocks together.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_mrgblk_rcsid[] = "$Id$";
-#endif
-
-#include "alloc.h"
-
-/* Merge one memory block into another one, returning the combined
- memory block. */
-
-pointer
-_uuconf_pmalloc_block_merge (p1, p2)
- pointer p1;
- pointer p2;
-{
- struct sblock *q1 = (struct sblock *) p1;
- struct sblock *q2 = (struct sblock *) p2;
- struct sblock **pq;
-
- for (pq = &q1; *pq != NULL; pq = &(*pq)->qnext)
- ;
- *pq = q2;
- return (pointer) q1;
-}
diff --git a/gnu/libexec/uucp/libuuconf/paramc.c b/gnu/libexec/uucp/libuuconf/paramc.c
deleted file mode 100644
index c88cf94..0000000
--- a/gnu/libexec/uucp/libuuconf/paramc.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/* paramc.c
- Handle protocol-parameter commands.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_paramc_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Handle protocol-parameter commands by inserting them into an array
- of structures. The return value may include UUCONF_CMDTABRET_KEEP
- and UUCONF_CMDTABRET_EXIT, if appropriate. */
-
-int
-_uuconf_iadd_proto_param (qglobal, argc, argv, pqparam, pblock)
- struct sglobal *qglobal;
- int argc;
- char **argv;
- struct uuconf_proto_param **pqparam;
- pointer pblock;
-{
- struct uuconf_proto_param *q;
- size_t c;
- struct uuconf_proto_param_entry *qentry;
-
- if (argc < 2)
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- /* The first argument is the protocol character. */
- if (argv[0][1] != '\0')
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- if (*pqparam == NULL)
- {
- *pqparam = ((struct uuconf_proto_param *)
- uuconf_malloc (pblock,
- 2 * sizeof (struct uuconf_proto_param)));
- if (*pqparam == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- (*pqparam)[1].uuconf_bproto = '\0';
- q = *pqparam;
- q->uuconf_bproto = argv[0][0];
- q->uuconf_qentries = NULL;
- }
- else
- {
- c = 0;
- for (q = *pqparam; q->uuconf_bproto != '\0'; q++)
- {
- if (q->uuconf_bproto == argv[0][0])
- break;
- ++c;
- }
-
- if (q->uuconf_bproto == '\0')
- {
- struct uuconf_proto_param *qnew;
-
- qnew = ((struct uuconf_proto_param *)
- uuconf_malloc (pblock,
- ((c + 2)
- * sizeof (struct uuconf_proto_param))));
- if (qnew == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- memcpy ((pointer) qnew, (pointer) *pqparam,
- c * sizeof (struct uuconf_proto_param));
- qnew[c + 1].uuconf_bproto = '\0';
-
- uuconf_free (pblock, *pqparam);
- *pqparam = qnew;
-
- q = qnew + c;
- q->uuconf_bproto = argv[0][0];
- q->uuconf_qentries = NULL;
- }
- }
-
- if (q->uuconf_qentries == NULL)
- {
- qentry = ((struct uuconf_proto_param_entry *)
- uuconf_malloc (pblock,
- 2 * sizeof (struct uuconf_proto_param_entry)));
- if (qentry == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- qentry[1].uuconf_cargs = 0;
- q->uuconf_qentries = qentry;
- }
- else
- {
- struct uuconf_proto_param_entry *qnewent;
-
- c = 0;
- for (qentry = q->uuconf_qentries; qentry->uuconf_cargs != 0; qentry++)
- ++c;
-
- qnewent = ((struct uuconf_proto_param_entry *)
- uuconf_malloc (pblock,
- ((c + 2) *
- sizeof (struct uuconf_proto_param_entry))));
- if (qnewent == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- memcpy ((pointer) qnewent, (pointer) q->uuconf_qentries,
- c * sizeof (struct uuconf_proto_param_entry));
- qnewent[c + 1].uuconf_cargs = 0;
-
- uuconf_free (pblock, q->uuconf_qentries);
- q->uuconf_qentries = qnewent;
-
- qentry = qnewent + c;
- }
-
- qentry->uuconf_cargs = argc - 1;
- qentry->uuconf_pzargs = (char **) uuconf_malloc (pblock,
- ((argc - 1)
- * sizeof (char *)));
- if (qentry->uuconf_pzargs == NULL)
- {
- qglobal->ierrno = errno;
- qentry->uuconf_cargs = 0;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- memcpy ((pointer) qentry->uuconf_pzargs, (pointer) (argv + 1),
- (argc - 1) * sizeof (char *));
-
- return UUCONF_CMDTABRET_KEEP;
-}
diff --git a/gnu/libexec/uucp/libuuconf/port.c b/gnu/libexec/uucp/libuuconf/port.c
deleted file mode 100644
index 8a5b6c2..0000000
--- a/gnu/libexec/uucp/libuuconf/port.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* port.c
- Find a port.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_port_rcsid[] = "$Id$";
-#endif
-
-/* Find a port by name, baud rate, and special purpose function. */
-
-int
-uuconf_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport)
- pointer pglobal;
- const char *zname;
- long ibaud;
- long ihighbaud;
- int (*pifn) P((struct uuconf_port *, pointer));
- pointer pinfo;
- struct uuconf_port *qport;
-{
-#if HAVE_V2_CONFIG || HAVE_HDB_CONFIG
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-#endif
- int iret;
-
-#if HAVE_TAYLOR_CONFIG
- iret = uuconf_taylor_find_port (pglobal, zname, ibaud, ihighbaud, pifn,
- pinfo, qport);
- if (iret != UUCONF_NOT_FOUND)
- return iret;
-#endif
-
-#if HAVE_V2_CONFIG
- if (qglobal->qprocess->fv2)
- {
- iret = uuconf_v2_find_port (pglobal, zname, ibaud, ihighbaud, pifn,
- pinfo, qport);
- if (iret != UUCONF_NOT_FOUND)
- return iret;
- }
-#endif
-
-#if HAVE_HDB_CONFIG
- if (qglobal->qprocess->fhdb)
- {
- iret = uuconf_hdb_find_port (pglobal, zname, ibaud, ihighbaud, pifn,
- pinfo, qport);
- if (iret != UUCONF_NOT_FOUND)
- return iret;
- }
-#endif
-
- return UUCONF_NOT_FOUND;
-}
diff --git a/gnu/libexec/uucp/libuuconf/prtsub.c b/gnu/libexec/uucp/libuuconf/prtsub.c
deleted file mode 100644
index c7f0b2c..0000000
--- a/gnu/libexec/uucp/libuuconf/prtsub.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* prtsub.c
- Port information subroutines.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_prtsub_rcsid[] = "$Id$";
-#endif
-
-/* Clear the information in a port. This can only clear the type
- independent information; the port type specific information is
- cleared when the type of the port is set. */
-
-void
-_uuconf_uclear_port (qport)
- struct uuconf_port *qport;
-{
- qport->uuconf_zname = NULL;
- qport->uuconf_ttype = UUCONF_PORTTYPE_UNKNOWN;
- qport->uuconf_zprotocols = NULL;
- qport->uuconf_qproto_params = NULL;
-
- /* Note that we do not set RELIABLE_SPECIFIED; this just sets
- defaults, so that ``seven-bit true'' does not imply ``reliable
- false''. */
- qport->uuconf_ireliable = (UUCONF_RELIABLE_RELIABLE
- | UUCONF_RELIABLE_EIGHT
- | UUCONF_RELIABLE_FULLDUPLEX);
-
- qport->uuconf_zlockname = NULL;
- qport->uuconf_palloc = NULL;
-}
diff --git a/gnu/libexec/uucp/libuuconf/pubdir.c b/gnu/libexec/uucp/libuuconf/pubdir.c
deleted file mode 100644
index 48ebca1..0000000
--- a/gnu/libexec/uucp/libuuconf/pubdir.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* pubdir.c
- Get the name of the UUCP public directory.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_pubdir_rcsid[] = "$Id$";
-#endif
-
-/* Get the name of the UUCP public directory. */
-
-int
-uuconf_pubdir (pglobal, pzpub)
- pointer pglobal;
- const char **pzpub;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pzpub = qglobal->qprocess->zpubdir;
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/rdlocs.c b/gnu/libexec/uucp/libuuconf/rdlocs.c
deleted file mode 100644
index 52d0ae9..0000000
--- a/gnu/libexec/uucp/libuuconf/rdlocs.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/* rdlocs.c
- Get the locations of systems in the Taylor UUCP configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_rdlocs_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-static int itsystem P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int itcalled_login P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int itmyname P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-
-/* This code scans through the Taylor UUCP system files in order to
- locate each system and to gather the login restrictions (since this
- information is held in additional arguments to the "called-login"
- command, it can appear anywhere in the systems files). It also
- records whether any "myname" appears, as an optimization for
- uuconf_taylor_localname.
-
- This table is used to dispatch the appropriate commands. Most
- commands are simply ignored. Note that this is a uuconf_cmdtab,
- not a cmdtab_offset. */
-
-static const struct uuconf_cmdtab asTcmds[] =
-{
- { "system", UUCONF_CMDTABTYPE_FN | 2, NULL, itsystem },
- { "alias", UUCONF_CMDTABTYPE_FN | 2, (pointer) asTcmds, itsystem },
- { "called-login", UUCONF_CMDTABTYPE_FN | 0, NULL, itcalled_login },
- { "myname", UUCONF_CMDTABTYPE_FN | 2, NULL, itmyname },
- { NULL, 0, NULL, NULL }
-};
-
-/* This structure is used to pass information into the command table
- functions. */
-
-struct sinfo
-{
- /* The sys file name. */
- const char *zname;
- /* The open sys file. */
- FILE *e;
- /* The list of locations we are building. */
- struct stsysloc *qlocs;
- /* The list of validation restrictions we are building. */
- struct svalidate *qvals;
-};
-
-/* Look through the sys files to find the location and names of all
- the systems. Since we're scanning the sys files, we also record
- the validation information specified by the additional arguments to
- the called-login command. We don't use uuconf_cmd_file to avoid
- the overhead of breaking the line up into arguments if not
- necessary. */
-
-int
-_uuconf_iread_locations (qglobal)
- struct sglobal *qglobal;
-{
- char *zline;
- size_t cline;
- struct sinfo si;
- int iret;
- char **pz;
-
- if (qglobal->qprocess->fread_syslocs)
- return UUCONF_SUCCESS;
-
- zline = NULL;
- cline = 0;
-
- si.qlocs = NULL;
- si.qvals = NULL;
-
- iret = UUCONF_SUCCESS;
-
- for (pz = qglobal->qprocess->pzsysfiles; *pz != NULL; pz++)
- {
- FILE *e;
- int cchars;
-
- qglobal->ilineno = 0;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
-#ifdef CLOSE_ON_EXEC
- CLOSE_ON_EXEC (e);
-#endif
-
- si.zname = *pz;
- si.e = e;
-
- while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0)
- {
- char *zcmd;
-
- ++qglobal->ilineno;
-
- zcmd = zline + strspn (zline, " \t");
- if (strncasecmp (zcmd, "system", sizeof "system" - 1) == 0
- || strncasecmp (zcmd, "alias", sizeof "alias" - 1) == 0
- || strncasecmp (zcmd, "called-login",
- sizeof "called-login" - 1) == 0
- || strncasecmp (zcmd, "myname", sizeof "myname" - 1) == 0)
- {
- iret = uuconf_cmd_line ((pointer) qglobal, zline, asTcmds,
- (pointer) &si, (uuconf_cmdtabfn) NULL,
- 0, qglobal->pblock);
- if ((iret & UUCONF_CMDTABRET_KEEP) != 0)
- {
- iret &=~ UUCONF_CMDTABRET_KEEP;
- zline = NULL;
- cline = 0;
- }
- if (iret != UUCONF_SUCCESS)
- {
- iret &=~ UUCONF_CMDTABRET_EXIT;
- break;
- }
- }
- }
-
- if (iret != UUCONF_SUCCESS)
- break;
- }
-
- if (zline != NULL)
- free ((pointer) zline);
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = *pz;
- iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- if (UUCONF_ERROR_VALUE (iret) != UUCONF_MALLOC_FAILED)
- qglobal->qprocess->fread_syslocs = TRUE;
- }
- else
- {
- qglobal->qprocess->qsyslocs = si.qlocs;
- qglobal->qprocess->qvalidate = si.qvals;
- qglobal->qprocess->fread_syslocs = TRUE;
- }
-
- return iret;
-}
-
-/* Handle a "system" or "alias" command by recording the file and
- location. If pvar is not NULL, this is an "alias" command. */
-
-/*ARGSUSED*/
-static int
-itsystem (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
- struct stsysloc *q;
- size_t csize;
-
- q = (struct stsysloc *) uuconf_malloc (qglobal->pblock,
- sizeof (struct stsysloc));
- if (q == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- csize = strlen (argv[1]) + 1;
- q->zname = uuconf_malloc (qglobal->pblock, csize);
- if (q->zname == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- q->qnext = qinfo->qlocs;
- memcpy ((pointer) q->zname, (pointer) argv[1], csize);
- q->falias = pvar != NULL;
- q->zfile = qinfo->zname;
- q->e = qinfo->e;
- q->iloc = ftell (qinfo->e);
- q->ilineno = qglobal->ilineno;
-
- qinfo->qlocs = q;
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Handle the "called-login" command. This just records any extra
- arguments, so that uuconf_validate can check them later if
- necessary. */
-
-/*ARGSUSED*/
-static int
-itcalled_login (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
- register struct svalidate *qval;
- int i;
-
- if (argc <= 2)
- return UUCONF_CMDTABRET_CONTINUE;
-
- for (qval = qinfo->qvals; qval != NULL; qval = qval->qnext)
- if (strcmp (argv[1], qval->zlogname) == 0)
- break;
-
- if (qval == NULL)
- {
- qval = (struct svalidate *) uuconf_malloc (qglobal->pblock,
- sizeof (struct svalidate));
- if (qval == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- qval->qnext = qinfo->qvals;
- qval->zlogname = argv[1];
- qval->pzmachines = NULL;
-
- qinfo->qvals = qval;
- }
-
- for (i = 2; i < argc; i++)
- {
- int iret;
-
- iret = _uuconf_iadd_string (qglobal, argv[i], FALSE, TRUE,
- &qval->pzmachines, qglobal->pblock);
- if (iret != UUCONF_SUCCESS)
- return iret | UUCONF_CMDTABRET_EXIT;
- }
-
- return UUCONF_CMDTABRET_KEEP;
-}
-
-/* Handle the "myname" command by simply recording that it appears.
- This information is used by uuconf_taylor_localname. */
-
-/*ARGSUSED*/
-static int
-itmyname (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- qglobal->qprocess->fuses_myname = TRUE;
- return UUCONF_CMDTABRET_CONTINUE;
-}
diff --git a/gnu/libexec/uucp/libuuconf/rdperm.c b/gnu/libexec/uucp/libuuconf/rdperm.c
deleted file mode 100644
index 9860a80..0000000
--- a/gnu/libexec/uucp/libuuconf/rdperm.c
+++ /dev/null
@@ -1,452 +0,0 @@
-/* rdperm.c
- Read the HDB Permissions file.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_rdperm_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-static int ihcolon P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int ihsendfiles P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int ihunknownperm P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int ihadd_norw P((struct sglobal *qglobal, char ***ppz, char **pzno));
-
-/* These routines reads in the HDB Permissions file. We store the
- entries in a linked list of shpermissions structures, so we only
- have to actually read the file once. */
-
-/* This command table and static structure are used to parse a line
- from Permissions. The entries are parsed as follows:
-
- Multiple strings separated by colons: LOGNAME, MACHINE, READ,
- WRITE, NOREAD, NOWRITE, COMMANDS, VALIDATE, ALIAS.
-
- Boolean values: REQUEST, CALLBACK.
-
- Simple strings: MYNAME, PUBDIR.
-
- "Yes" or "call": SENDFILES.
-
- The NOREAD and NOWRITE entries are merged into the READ and WRITE
- entries, rather than being permanently stored. They are handled
- specially in the uuconf_cmdtab table. */
-
-static const struct cmdtab_offset asHperm_cmds[] =
-{
- { "NOREAD", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, ihcolon },
- { "NOWRITE", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, ihcolon },
- { "LOGNAME", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct shpermissions, pzlogname), ihcolon },
- { "MACHINE", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct shpermissions, pzmachine), ihcolon },
- { "REQUEST", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct shpermissions, frequest), NULL },
- { "SENDFILES", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct shpermissions, fsendfiles), ihsendfiles },
- { "READ", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct shpermissions, pzread), ihcolon },
- { "WRITE", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct shpermissions, pzwrite), ihcolon },
- { "CALLBACK", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct shpermissions, fcallback), NULL },
- { "COMMANDS", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct shpermissions, pzcommands), ihcolon },
- { "VALIDATE", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct shpermissions, pzvalidate), ihcolon },
- { "MYNAME", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct shpermissions, zmyname), NULL },
- { "PUBDIR", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct shpermissions, zpubdir), NULL },
- { "ALIAS", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct shpermissions, pzalias), ihcolon },
- { NULL, 0, 0, NULL }
-};
-
-#define CHPERM_CMDS (sizeof asHperm_cmds / sizeof asHperm_cmds[0])
-
-/* Actually read the Permissions file into a linked list of
- structures. */
-
-int
-_uuconf_ihread_permissions (qglobal)
- struct sglobal *qglobal;
-{
- char *zperm;
- FILE *e;
- int iret;
- struct uuconf_cmdtab as[CHPERM_CMDS];
- char **pznoread, **pznowrite;
- struct shpermissions shperm;
- char *zline;
- size_t cline;
- char **pzsplit;
- size_t csplit;
- int cchars;
- struct shpermissions *qlist, **pq;
-
- if (qglobal->qprocess->fhdb_read_permissions)
- return UUCONF_SUCCESS;
-
- zperm = (char *) uuconf_malloc (qglobal->pblock,
- (sizeof OLDCONFIGLIB
- + sizeof HDB_PERMISSIONS - 1));
- if (zperm == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- memcpy ((pointer) zperm, (pointer) OLDCONFIGLIB,
- sizeof OLDCONFIGLIB - 1);
- memcpy ((pointer) (zperm + sizeof OLDCONFIGLIB - 1),
- (pointer) HDB_PERMISSIONS, sizeof HDB_PERMISSIONS);
-
- e = fopen (zperm, "r");
- if (e == NULL)
- {
- uuconf_free (qglobal->pblock, zperm);
- qglobal->qprocess->fhdb_read_permissions = TRUE;
- return UUCONF_SUCCESS;
- }
-
- _uuconf_ucmdtab_base (asHperm_cmds, CHPERM_CMDS, (char *) &shperm, as);
- as[0].uuconf_pvar = (pointer) &pznoread;
- as[1].uuconf_pvar = (pointer) &pznowrite;
-
- zline = NULL;
- cline = 0;
- pzsplit = NULL;
- csplit = 0;
-
- qlist = NULL;
- pq = &qlist;
-
- qglobal->ilineno = 0;
-
- iret = UUCONF_SUCCESS;
-
- while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0)
- {
- int centries;
- struct shpermissions *qnew;
- int i;
-
- ++qglobal->ilineno;
-
- --cchars;
- if (zline[cchars] == '\n')
- zline[cchars] = '\0';
- if (zline[0] == '#')
- continue;
-
- centries = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit);
- if (centries < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- if (centries == 0)
- continue;
-
- shperm.pzlogname = (char **) &_uuconf_unset;
- shperm.pzmachine = (char **) &_uuconf_unset;
- shperm.frequest = -1;
- shperm.fsendfiles = -1;
- shperm.pzread = (char **) &_uuconf_unset;
- shperm.pzwrite = (char **) &_uuconf_unset;
- shperm.fcallback = -1;
- shperm.pzcommands = (char **) &_uuconf_unset;
- shperm.pzvalidate = (char **) &_uuconf_unset;
- shperm.zmyname = (char *) &_uuconf_unset;
- shperm.zpubdir = (char *) &_uuconf_unset;
- shperm.pzalias = (char **) &_uuconf_unset;
- pznoread = (char **) &_uuconf_unset;
- pznowrite = (char **) &_uuconf_unset;
-
- for (i = 0; i < centries; i++)
- {
- char *zeq;
- char *azargs[2];
-
- zeq = strchr (pzsplit[i], '=');
- if (zeq == NULL)
- {
- iret = UUCONF_SYNTAX_ERROR;
- qglobal->qprocess->fhdb_read_permissions = TRUE;
- break;
- }
- *zeq = '\0';
-
- azargs[0] = pzsplit[i];
- azargs[1] = zeq + 1;
-
- iret = uuconf_cmd_args (qglobal, 2, azargs, as, (pointer) NULL,
- ihunknownperm, 0, qglobal->pblock);
- if ((iret & UUCONF_CMDTABRET_KEEP) != 0)
- {
- iret &=~ UUCONF_CMDTABRET_KEEP;
-
- if (uuconf_add_block (qglobal->pblock, zline) != 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- zline = NULL;
- cline = 0;
- }
- if ((iret & UUCONF_CMDTABRET_EXIT) != 0)
- {
- iret &=~ UUCONF_CMDTABRET_EXIT;
- break;
- }
- }
-
- if (iret != UUCONF_SUCCESS)
- break;
-
- if (shperm.pzmachine == (char **) &_uuconf_unset
- && shperm.pzlogname == (char **) &_uuconf_unset)
- {
- iret = UUCONF_SYNTAX_ERROR;
- qglobal->qprocess->fhdb_read_permissions = TRUE;
- break;
- }
-
- /* Attach any NOREAD or NOWRITE entries to the corresponding
- READ or WRITE entries in the format expected for the
- pzlocal_receive, etc., fields in uuconf_system. */
- if (pznoread != NULL)
- {
- iret = ihadd_norw (qglobal, &shperm.pzread, pznoread);
- if (iret != UUCONF_SUCCESS)
- break;
- uuconf_free (qglobal->pblock, pznoread);
- }
-
- if (pznowrite != NULL)
- {
- iret = ihadd_norw (qglobal, &shperm.pzwrite, pznowrite);
- if (iret != UUCONF_SUCCESS)
- break;
- uuconf_free (qglobal->pblock, pznowrite);
- }
-
- qnew = ((struct shpermissions *)
- uuconf_malloc (qglobal->pblock,
- sizeof (struct shpermissions)));
- if (qnew == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- *qnew = shperm;
- *pq = qnew;
- pq = &qnew->qnext;
- *pq = NULL;
- }
-
- (void) fclose (e);
-
- if (zline != NULL)
- free ((pointer) zline);
- if (pzsplit != NULL)
- free ((pointer) pzsplit);
-
- if (iret == UUCONF_SUCCESS)
- {
- qglobal->qprocess->qhdb_permissions = qlist;
- qglobal->qprocess->fhdb_read_permissions = TRUE;
- }
- else
- {
- qglobal->zfilename = zperm;
- iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- }
-
- return iret;
-}
-
-/* Split the argument into colon separated strings, and assign a NULL
- terminated array of strings to pvar. */
-
-/*ARGSUSED*/
-static int
-ihcolon (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char ***ppz = (char ***) pvar;
- char **pzsplit;
- size_t csplit;
- int centries;
- int i;
- int iret;
-
- *ppz = NULL;
-
- pzsplit = NULL;
- csplit = 0;
-
- centries = _uuconf_istrsplit (argv[1], ':', &pzsplit, &csplit);
- if (centries < 0)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- if (centries == 0)
- {
- if (pzsplit != NULL)
- free ((pointer) pzsplit);
- return UUCONF_CMDTABRET_CONTINUE;
- }
-
- iret = UUCONF_SUCCESS;
-
- for (i = 0; i < centries; i++)
- {
- iret = _uuconf_iadd_string (qglobal, pzsplit[i], FALSE, FALSE,
- ppz, qglobal->pblock);
- if (iret != UUCONF_SUCCESS)
- {
- iret |= UUCONF_CMDTABRET_EXIT;
- break;
- }
- }
-
- free ((pointer) pzsplit);
-
- return UUCONF_CMDTABRET_KEEP;
-}
-
-/* Handle the SENDFILES parameter, which can take "yes" or "call" or
- "no" as an argument. The string "call" is equivalent to "no". */
-
-/*ARGSUSED*/
-static int
-ihsendfiles (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- int *pi = (int *) pvar;
-
- switch (argv[1][0])
- {
- case 'C':
- case 'c':
- case 'N':
- case 'n':
- *pi = FALSE;
- break;
- case 'Y':
- case 'y':
- *pi = TRUE;
- break;
- default:
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
- }
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* If there is an unknown Permissions entry, return a syntax error.
- This should probably be more clever. */
-
-/*ARGSUSED*/
-static int
-ihunknownperm (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-}
-
-/* Add a NOREAD or NOWRITE entry to a READ or WRITE entry. */
-
-static int
-ihadd_norw (qglobal, ppz, pzno)
- struct sglobal *qglobal;
- char ***ppz;
- char **pzno;
-{
- register char **pz;
-
- if (pzno == (char **) &_uuconf_unset)
- return UUCONF_SUCCESS;
-
- for (pz = pzno; *pz != NULL; pz++)
- {
- size_t csize;
- char *znew;
- int iret;
-
- /* Ignore an attempt to say NOREAD or NOWRITE with an empty
- string, since it will be interpreted as an attempt to deny
- everything. */
- if (**pz != '\0')
- {
- csize = strlen (*pz) + 1;
- znew = (char *) uuconf_malloc (qglobal->pblock, csize + 1);
- if (znew == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- znew[0] = '!';
- memcpy ((pointer) (znew + 1), (pointer) *pz, csize);
- iret = _uuconf_iadd_string (qglobal, znew, FALSE, FALSE, ppz,
- qglobal->pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- }
-
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/reliab.c b/gnu/libexec/uucp/libuuconf/reliab.c
deleted file mode 100644
index ac4c6d8..0000000
--- a/gnu/libexec/uucp/libuuconf/reliab.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* reliab.c
- Subroutines to handle reliability commands for ports and dialers.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_reliab_rcsid[] = "$Id$";
-#endif
-
-/* Handle the "seven-bit" command for a port or a dialer. The pvar
- argument points to an integer which should be set to hold
- reliability information. */
-
-/*ARGSUSED*/
-int
-_uuconf_iseven_bit (pglobal,argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int *pi = (int *) pvar;
- int fval;
- int iret;
-
- iret = _uuconf_iboolean (qglobal, argv[1], &fval);
- if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS)
- return iret;
-
- *pi |= UUCONF_RELIABLE_SPECIFIED;
- if (fval)
- *pi &=~ UUCONF_RELIABLE_EIGHT;
- else
- *pi |= UUCONF_RELIABLE_EIGHT;
-
- return iret;
-}
-
-/* Handle the "reliable" command for a port or a dialer. The pvar
- argument points to an integer which should be set to hold
- reliability information. */
-
-/*ARGSUSED*/
-int
-_uuconf_ireliable (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int *pi = (int *) pvar;
- int fval;
- int iret;
-
- iret = _uuconf_iboolean (qglobal, argv[1], &fval);
- if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS)
- return iret;
-
- *pi |= UUCONF_RELIABLE_SPECIFIED;
- if (fval)
- *pi |= UUCONF_RELIABLE_RELIABLE;
- else
- *pi &=~ UUCONF_RELIABLE_RELIABLE;
-
- return iret;
-}
-
-/* Handle the "half-duplex" command for a port or a dialer. The pvar
- argument points to an integer which should be set to hold
- reliability information. */
-
-/*ARGSUSED*/
-int
-_uuconf_ihalf_duplex (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int *pi = (int *) pvar;
- int fval;
- int iret;
-
- iret = _uuconf_iboolean (qglobal, argv[1], &fval);
- if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS)
- return iret;
-
- *pi |= UUCONF_RELIABLE_SPECIFIED;
- if (fval)
- *pi &=~ UUCONF_RELIABLE_FULLDUPLEX;
- else
- *pi |= UUCONF_RELIABLE_FULLDUPLEX;
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/remunk.c b/gnu/libexec/uucp/libuuconf/remunk.c
deleted file mode 100644
index 28b8410..0000000
--- a/gnu/libexec/uucp/libuuconf/remunk.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* remunk.c
- Get the name of the remote.unknown shell script.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_remunk_rcsid[] = "$Id$";
-#endif
-
-/* Get the name of the remote.unknown shell script. */
-
-/*ARGSUSED*/
-int
-uuconf_remote_unknown (pglobal, pzname)
- pointer pglobal;
- char **pzname;
-{
-#if ! HAVE_HDB_CONFIG
- return UUCONF_NOT_FOUND;
-#else
-#if HAVE_TAYLOR_CONFIG
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- /* If ``unknown'' commands were used in the config file, then ignore
- any remote.unknown script. */
- if (qglobal->qprocess->qunknown != NULL)
- return UUCONF_NOT_FOUND;
-#endif /* HAVE_TAYLOR_CONFIG */
-
- return uuconf_hdb_remote_unknown (pglobal, pzname);
-#endif /* HAVE_HDB_CONFIG */
-}
diff --git a/gnu/libexec/uucp/libuuconf/runuxq.c b/gnu/libexec/uucp/libuuconf/runuxq.c
deleted file mode 100644
index b7991ea..0000000
--- a/gnu/libexec/uucp/libuuconf/runuxq.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* maxuxq.c
- Return how often to spawn a uuxqt process.
-
- Copyright (C) 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_runuxq_rcsid[] = "$Id$";
-#endif
-
-/* Return how often to spawn a uuxqt process. This is either a
- positive number representing the number of execution files to be
- received between spawns, or a special code. When using
- TAYLOR_CONFIG, this is from the ``run-uuxqt'' command in config
- (the default is UUCONF_RUNUUXQT_ONCE, for compatibility).
- Otherwise, we return UUCONF_RUNUUXQT_PERCALL for HDB_CONFIG and 10
- for V2_CONFIG, to emulate traditional HDB and V2 emulations. */
-
-int
-uuconf_runuuxqt (pglobal, pirunuuxqt)
- pointer pglobal;
- int *pirunuuxqt;
-{
-#if HAVE_TAYLOR_CONFIG
- {
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- const char *zrun;
-
- zrun = qglobal->qprocess->zrunuuxqt;
- if (zrun == NULL
- || strcasecmp (zrun, "once") == 0)
- *pirunuuxqt = UUCONF_RUNUUXQT_ONCE;
- else if (strcasecmp (zrun, "never") == 0)
- *pirunuuxqt = UUCONF_RUNUUXQT_NEVER;
- else if (strcasecmp (zrun, "percall") == 0)
- *pirunuuxqt = UUCONF_RUNUUXQT_PERCALL;
- else
- {
- char *zend;
-
- *pirunuuxqt = strtol ((char *) qglobal->qprocess->zrunuuxqt,
- &zend, 10);
- if (*zend != '\0' || *pirunuuxqt <= 0)
- *pirunuuxqt = UUCONF_RUNUUXQT_ONCE;
- }
- }
-#else /* ! HAVE_TAYLOR_CONFIG */
-#if HAVE_HDB_CONFIG
- *pirunuuxqt = UUCONF_RUNUUXQT_PERCALL;
-#else /* ! HAVE_HDB_CONFIG */
- *pirunuuxqt = 10;
-#endif /* ! HAVE_HDB_CONFIG */
-#endif /* ! HAVE_TAYLOR_CONFIG */
-
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/sinfo.c b/gnu/libexec/uucp/libuuconf/sinfo.c
deleted file mode 100644
index dab8b90..0000000
--- a/gnu/libexec/uucp/libuuconf/sinfo.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* sinfo.c
- Get information about a system.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_sinfo_rcsid[] = "$Id$";
-#endif
-
-/* Get information about a particular system. We combine the
- definitions for this system from each type of configuration file,
- by passing what we have so far into each one. */
-
-int
-uuconf_system_info (pglobal, zsystem, qsys)
- pointer pglobal;
- const char *zsystem;
- struct uuconf_system *qsys;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
- boolean fgot;
-
- fgot = FALSE;
-
-#if HAVE_TAYLOR_CONFIG
- iret = _uuconf_itaylor_system_internal (qglobal, zsystem, qsys);
- if (iret == UUCONF_SUCCESS)
- fgot = TRUE;
- else if (iret != UUCONF_NOT_FOUND)
- return iret;
-#endif
-
-#if HAVE_V2_CONFIG
- if (qglobal->qprocess->fv2)
- {
- struct uuconf_system *q;
- struct uuconf_system sv2;
-
- if (fgot)
- q = &sv2;
- else
- q = qsys;
- iret = _uuconf_iv2_system_internal (qglobal, zsystem, q);
- if (iret == UUCONF_SUCCESS)
- {
- if (fgot)
- {
- iret = _uuconf_isystem_default (qglobal, qsys, &sv2, TRUE);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- fgot = TRUE;
- }
- else if (iret != UUCONF_NOT_FOUND)
- return iret;
- }
-#endif
-
-#if HAVE_HDB_CONFIG
- if (qglobal->qprocess->fhdb)
- {
- struct uuconf_system *q;
- struct uuconf_system shdb;
-
- if (fgot)
- q = &shdb;
- else
- q = qsys;
- iret = _uuconf_ihdb_system_internal (qglobal, zsystem, q);
- if (iret == UUCONF_SUCCESS)
- {
- if (fgot)
- {
- iret = _uuconf_isystem_default (qglobal, qsys, &shdb, TRUE);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- fgot = TRUE;
- }
- else if (iret != UUCONF_NOT_FOUND)
- return iret;
- }
-#endif
-
- if (! fgot)
- return UUCONF_NOT_FOUND;
-
- return _uuconf_isystem_basic_default (qglobal, qsys);
-}
diff --git a/gnu/libexec/uucp/libuuconf/snams.c b/gnu/libexec/uucp/libuuconf/snams.c
deleted file mode 100644
index 4c521de..0000000
--- a/gnu/libexec/uucp/libuuconf/snams.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* snams.c
- Get all known system names.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_snams_rcsid[] = "$Id$";
-#endif
-
-/* Get all known system names. */
-
-int
-uuconf_system_names (pglobal, ppzsystems, falias)
- pointer pglobal;
- char ***ppzsystems;
- int falias;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char **pztaylor;
- char **pzv2;
- char **pzhdb;
- int iret;
-
- *ppzsystems = NULL;
- pztaylor = NULL;
- pzv2 = NULL;
- pzhdb = NULL;
-
-#if HAVE_TAYLOR_CONFIG
- iret = uuconf_taylor_system_names (pglobal, &pztaylor, falias);
- if (iret != UUCONF_SUCCESS)
- return iret;
-#endif
-
-#if HAVE_V2_CONFIG
- if (qglobal->qprocess->fv2)
- {
- iret = uuconf_v2_system_names (pglobal, &pzv2, falias);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-#endif
-
-#if HAVE_HDB_CONFIG
- if (qglobal->qprocess->fhdb)
- {
- iret = uuconf_hdb_system_names (pglobal, &pzhdb, falias);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-#endif
-
- if (pzv2 == NULL && pzhdb == NULL)
- *ppzsystems = pztaylor;
- else if (pztaylor == NULL && pzhdb == NULL)
- *ppzsystems = pzv2;
- else if (pztaylor == NULL && pzv2 == NULL)
- *ppzsystems = pzhdb;
- else
- {
- char **pz;
-
- iret = UUCONF_SUCCESS;
-
- if (pztaylor != NULL)
- {
- for (pz = pztaylor; *pz != NULL; pz++)
- {
- iret = _uuconf_iadd_string (qglobal, *pz, FALSE, TRUE,
- ppzsystems, (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- break;
- }
- }
-
- if (pzv2 != NULL && iret == UUCONF_SUCCESS)
- {
- for (pz = pzv2; *pz != NULL; pz++)
- {
- iret = _uuconf_iadd_string (qglobal, *pz, FALSE, TRUE,
- ppzsystems, (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- break;
- }
- }
-
- if (pzhdb != NULL && iret == UUCONF_SUCCESS)
- {
- for (pz = pzhdb; *pz != NULL; pz++)
- {
- iret = _uuconf_iadd_string (qglobal, *pz, FALSE, TRUE,
- ppzsystems, (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- break;
- }
- }
-
- if (pztaylor != NULL)
- free ((pointer) pztaylor);
- if (pzv2 != NULL)
- free ((pointer) pzv2);
- if (pzhdb != NULL)
- free ((pointer) pzhdb);
- }
-
- if (iret == UUCONF_SUCCESS && *ppzsystems == NULL)
- iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
- ppzsystems, (pointer) NULL);
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/split.c b/gnu/libexec/uucp/libuuconf/split.c
deleted file mode 100644
index abc5ea5..0000000
--- a/gnu/libexec/uucp/libuuconf/split.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* split.c
- Split a string into tokens.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_split_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-
-/* Split a string into tokens. The bsep argument is the separator to
- use. If it is the null byte, white space is used as the separator,
- and leading white space is discarded. Otherwise, each occurrence
- of the separator character delimits a field (and thus some fields
- may be empty). The array and size arguments may be used to reuse
- the same memory. This function is not tied to uuconf; the only way
- it can fail is if malloc or realloc fails. */
-
-int
-_uuconf_istrsplit (zline, bsep, ppzsplit, pcsplit)
- register char *zline;
- int bsep;
- char ***ppzsplit;
- size_t *pcsplit;
-{
- size_t i;
-
- i = 0;
-
- while (TRUE)
- {
- if (bsep == '\0')
- {
- while (isspace (BUCHAR (*zline)))
- ++zline;
- if (*zline == '\0')
- break;
- }
-
- if (i >= *pcsplit)
- {
- char **pznew;
- size_t cnew;
-
- if (*pcsplit == 0)
- {
- cnew = 8;
- pznew = (char **) malloc (cnew * sizeof (char *));
- }
- else
- {
- cnew = *pcsplit * 2;
- pznew = (char **) realloc ((pointer) *ppzsplit,
- cnew * sizeof (char *));
- }
- if (pznew == NULL)
- return -1;
- *ppzsplit = pznew;
- *pcsplit = cnew;
- }
-
- (*ppzsplit)[i] = zline;
- ++i;
-
- if (bsep == '\0')
- {
- while (*zline != '\0' && ! isspace (BUCHAR (*zline)))
- ++zline;
- }
- else
- {
- while (*zline != '\0' && *zline != bsep)
- ++zline;
- }
-
- if (*zline == '\0')
- break;
-
- *zline++ = '\0';
- }
-
- return i;
-}
diff --git a/gnu/libexec/uucp/libuuconf/spool.c b/gnu/libexec/uucp/libuuconf/spool.c
deleted file mode 100644
index c081a78..0000000
--- a/gnu/libexec/uucp/libuuconf/spool.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* spool.c
- Get the name of the UUCP spool directory.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_spool_rcsid[] = "$Id$";
-#endif
-
-/* Get the name of the UUCP spool directory. */
-
-int
-uuconf_spooldir (pglobal, pzspool)
- pointer pglobal;
- const char **pzspool;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pzspool = qglobal->qprocess->zspooldir;
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/stafil.c b/gnu/libexec/uucp/libuuconf/stafil.c
deleted file mode 100644
index 5b9fa7e..0000000
--- a/gnu/libexec/uucp/libuuconf/stafil.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* stafil.c
- Get the name of the UUCP statistics file.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_stafil_rcsid[] = "$Id$";
-#endif
-
-/* Get the name of the UUCP statistics file. */
-
-int
-uuconf_statsfile (pglobal, pzstats)
- pointer pglobal;
- const char **pzstats;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pzstats = qglobal->qprocess->zstatsfile;
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/strip.c b/gnu/libexec/uucp/libuuconf/strip.c
deleted file mode 100644
index 73fbd93..0000000
--- a/gnu/libexec/uucp/libuuconf/strip.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* maxuxq.c
- Get information about what things should be stripped.
-
- Copyright (C) 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_strip_rcsid[] = "$Id$";
-#endif
-
-/* Get information about what types of global information should be
- stripped. There are currently only two, which we return as a
- couple of bits. We store them as two separate variables, so we
- don't need to have a special function to set the values correctly. */
-
-int
-uuconf_strip (pglobal, pistrip)
- pointer pglobal;
- int *pistrip;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- *pistrip = 0;
- if (qglobal->qprocess->fstrip_login)
- *pistrip |= UUCONF_STRIP_LOGIN;
- if (qglobal->qprocess->fstrip_proto)
- *pistrip |= UUCONF_STRIP_PROTO;
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/syshdr.h b/gnu/libexec/uucp/libuuconf/syshdr.h
deleted file mode 100644
index 12d4aa4..0000000
--- a/gnu/libexec/uucp/libuuconf/syshdr.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/* syshdr.unx -*- C -*-
- Unix system header for the uuconf library.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-/* The root directory (used when setting local-send and local-receive
- values). */
-#define ZROOTDIR "/"
-
-/* The current directory (used by uuconv as a prefix for the newly
- created file names). */
-#define ZCURDIR "."
-
-/* The names of the Taylor UUCP configuration files. These are
- appended to NEWCONFIGLIB which is defined in Makefile. */
-#define CONFIGFILE "/config"
-#define SYSFILE "/sys"
-#define PORTFILE "/port"
-#define DIALFILE "/dial"
-#define CALLFILE "/call"
-#define PASSWDFILE "/passwd"
-#define DIALCODEFILE "/dialcode"
-
-/* The names of the various V2 configuration files. These are
- appended to OLDCONFIGLIB which is defined in Makefile. */
-#define V2_SYSTEMS "/L.sys"
-#define V2_DEVICES "/L-devices"
-#define V2_USERFILE "/USERFILE"
-#define V2_CMDS "/L.cmds"
-#define V2_DIALCODES "/L-dialcodes"
-
-/* The names of the HDB configuration files. These are appended to
- OLDCONFIGLIB which is defined in Makefile. */
-#define HDB_SYSFILES "/Sysfiles"
-#define HDB_SYSTEMS "/Systems"
-#define HDB_PERMISSIONS "/Permissions"
-#define HDB_DEVICES "/Devices"
-#define HDB_DIALERS "/Dialers"
-#define HDB_DIALCODES "/Dialcodes"
-#define HDB_MAXUUXQTS "/Maxuuxqts"
-#define HDB_REMOTE_UNKNOWN "/remote.unknown"
-
-/* A string which is inserted between the value of OLDCONFIGLIB
- (defined in the Makefile) and any names specified in the HDB
- Sysfiles file. */
-#define HDB_SEPARATOR "/"
-
-/* A macro to check whether fopen failed because the file did not
- exist. */
-#define FNO_SUCH_FILE() (errno == ENOENT)
-
-#if ! HAVE_STRERROR
-
-/* We need a definition for strerror; normally the function in the
- unix directory is used, but we want to be independent of that
- library. This macro evaluates its argument multiple times. */
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-#define strerror(ierr) \
- ((ierr) >= 0 && (ierr) < sys_nerr ? sys_errlist[ierr] : "unknown error")
-
-#endif /* ! HAVE_STRERROR */
-
-/* This macro is used to make a filename found in a configuration file
- into an absolute path. The zdir argument is the directory to put it
- in. The zset argument is set to the new string. The fallocated
- argument is set to TRUE if the new string was allocated. */
-#define MAKE_ABSOLUTE(zset, fallocated, zfile, zdir, pblock) \
- do \
- { \
- if (*(zfile) == '/') \
- { \
- (zset) = (zfile); \
- (fallocated) = FALSE; \
- } \
- else \
- { \
- size_t abs_cdir, abs_cfile; \
- char *abs_zret; \
-\
- abs_cdir = strlen (zdir); \
- abs_cfile = strlen (zfile); \
- abs_zret = (char *) uuconf_malloc ((pblock), \
- abs_cdir + abs_cfile + 2); \
- (zset) = abs_zret; \
- (fallocated) = TRUE; \
- if (abs_zret != NULL) \
- { \
- memcpy ((pointer) abs_zret, (pointer) (zdir), abs_cdir); \
- abs_zret[abs_cdir] = '/'; \
- memcpy ((pointer) (abs_zret + abs_cdir + 1), \
- (pointer) (zfile), abs_cfile + 1); \
- } \
- } \
- } \
- while (0)
-
-/* We want to be able to mark the Taylor UUCP system files as close on
- exec. */
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-
-#define CLOSE_ON_EXEC(e) \
- do \
- { \
- int cle_i = fileno (e); \
- \
- fcntl (cle_i, F_SETFD, fcntl (cle_i, F_GETFD, 0) | FD_CLOEXEC); \
- } \
- while (0)
diff --git a/gnu/libexec/uucp/libuuconf/syssub.c b/gnu/libexec/uucp/libuuconf/syssub.c
deleted file mode 100644
index 9f875c9..0000000
--- a/gnu/libexec/uucp/libuuconf/syssub.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/* syssub.c
- System information subroutines.
-
- Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_syssub_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* This macro operates on every string (char *) field in struct
- uuconf_system. */
-#define SYSTEM_STRINGS(OP) \
- do \
- { \
- OP (uuconf_zname); \
- OP (uuconf_zalternate); \
- OP (uuconf_zdebug); \
- OP (uuconf_zmax_remote_debug); \
- OP (uuconf_zphone); \
- OP (uuconf_zcall_login); \
- OP (uuconf_zcall_password); \
- OP (uuconf_zcalled_login); \
- OP (uuconf_zprotocols); \
- OP (uuconf_zpubdir); \
- OP (uuconf_zlocalname); \
- } \
- while (0)
-
-/* This macro operates on every string array (char **) field in struct
- uuconf_system. */
-#define SYSTEM_STRING_ARRAYS(OP) \
- do \
- { \
- OP (uuconf_pzalias); \
- OP (uuconf_pzlocal_send); \
- OP (uuconf_pzremote_send); \
- OP (uuconf_pzlocal_receive); \
- OP (uuconf_pzremote_receive); \
- OP (uuconf_pzpath); \
- OP (uuconf_pzcmds); \
- OP (uuconf_pzforward_from); \
- OP (uuconf_pzforward_to); \
- OP (uuconf_schat.uuconf_pzchat); \
- OP (uuconf_schat.uuconf_pzprogram); \
- OP (uuconf_schat.uuconf_pzfail); \
- OP (uuconf_scalled_chat.uuconf_pzchat); \
- OP (uuconf_scalled_chat.uuconf_pzprogram); \
- OP (uuconf_scalled_chat.uuconf_pzfail); \
- } \
- while (0)
-
-/* This macro operations on every timespan pointer (struct
- uuconf_timespan *) in struct uuconf_system. */
-#define SYSTEM_TIMESPANS(OP) \
- do \
- { \
- OP (uuconf_qtimegrade); \
- OP (uuconf_qcalltimegrade); \
- OP (uuconf_qcalledtimegrade); \
- OP (uuconf_qcall_local_size); \
- OP (uuconf_qcall_remote_size); \
- OP (uuconf_qcalled_local_size); \
- OP (uuconf_qcalled_remote_size); \
- } \
- while (0)
-
-/* This macro operates on every boolean value (of type int, although
- some type int are not boolean) field in uuconf_system. */
-#define SYSTEM_BOOLEANS(OP) \
- do \
- { \
- OP (uuconf_fcall); \
- OP (uuconf_fcalled); \
- OP (uuconf_fcallback); \
- OP (uuconf_fsequence); \
- OP (uuconf_fsend_request); \
- OP (uuconf_frec_request); \
- OP (uuconf_fcall_transfer); \
- OP (uuconf_fcalled_transfer); \
- OP (uuconf_schat.uuconf_fstrip); \
- OP (uuconf_scalled_chat.uuconf_fstrip); \
- } \
- while (0)
-
-/* This macro operates on every generic integer (type int or long) in
- uuconf_system. */
-#define SYSTEM_INTEGERS(OP) \
- do \
- { \
- OP (uuconf_cmax_retries); \
- OP (uuconf_csuccess_wait); \
- OP (uuconf_ibaud); \
- OP (uuconf_ihighbaud); \
- OP (uuconf_cfree_space); \
- OP (uuconf_schat.uuconf_ctimeout); \
- OP (uuconf_scalled_chat.uuconf_ctimeout); \
- } \
- while (0)
-
-/* There is no macro for uuconf_qalternate, uuconf_zport,
- uuconf_qport, uuconf_qproto_params, or uuconf_palloc. */
-
-/* Clear the contents of a struct uuconf_system. */
-
-void
-_uuconf_uclear_system (q)
- struct uuconf_system *q;
-{
-#define CLEAR(x) q->x = (char *) &_uuconf_unset
- SYSTEM_STRINGS (CLEAR);
-#undef CLEAR
-#define CLEAR(x) q->x = (char **) &_uuconf_unset
- SYSTEM_STRING_ARRAYS (CLEAR);
-#undef CLEAR
-#define CLEAR(x) q->x = (struct uuconf_timespan *) &_uuconf_unset
- SYSTEM_TIMESPANS (CLEAR);
-#undef CLEAR
-#define CLEAR(x) q->x = -1
- SYSTEM_BOOLEANS (CLEAR);
- SYSTEM_INTEGERS (CLEAR);
-#undef CLEAR
- q->uuconf_qalternate = NULL;
- q->uuconf_zport = (char *) &_uuconf_unset;
- q->uuconf_qport = (struct uuconf_port *) &_uuconf_unset;
- q->uuconf_qproto_params = (struct uuconf_proto_param *) &_uuconf_unset;
- q->uuconf_palloc = NULL;
-}
-
-/* Default the contents of one struct uuconf_system to the contents of
- another. This default alternate by alternate. Any additional
- alternates in q default to the last alternate of qdefault. If the
- faddalternates arguments is TRUE, additional alternates or qdefault
- are added to q; these alternates are copies of the first alternate
- of q, and defaults are set from the additional alternates of
- qdefault. */
-
-int
-_uuconf_isystem_default (qglobal, qset, qdefault, faddalternates)
- struct sglobal *qglobal;
- struct uuconf_system *qset;
- struct uuconf_system *qdefault;
- boolean faddalternates;
-{
- struct uuconf_system *qalt;
-
- if (qset->uuconf_palloc != qdefault->uuconf_palloc)
- qset->uuconf_palloc =
- _uuconf_pmalloc_block_merge (qset->uuconf_palloc,
- qdefault->uuconf_palloc);
-
- /* If we are adding alternates from the default, make sure we have
- at least as many alternates in qset as we do in qdefault. Each
- new alternate we create gets initialized to the first alternate
- of the system. */
- if (faddalternates)
- {
- struct uuconf_system **pq, *qdef;
-
- for (qdef = qdefault, pq = &qset;
- qdef != NULL;
- qdef = qdef->uuconf_qalternate, pq = &(*pq)->uuconf_qalternate)
- {
- if (*pq == NULL)
- {
- *pq = ((struct uuconf_system *)
- uuconf_malloc (qset->uuconf_palloc,
- sizeof (struct uuconf_system)));
- if (*pq == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- **pq = *qset;
- (*pq)->uuconf_qalternate = NULL;
- }
- }
- }
-
- for (qalt = qset; qalt != NULL; qalt = qalt->uuconf_qalternate)
- {
-#define DEFAULT(x) \
- if (qalt->x == (char *) &_uuconf_unset) qalt->x = qdefault->x
- SYSTEM_STRINGS (DEFAULT);
-#undef DEFAULT
-#define DEFAULT(x) \
- if (qalt->x == (char **) &_uuconf_unset) qalt->x = qdefault->x
- SYSTEM_STRING_ARRAYS (DEFAULT);
-#undef DEFAULT
-#define DEFAULT(x) \
- if (qalt->x == (struct uuconf_timespan *) &_uuconf_unset) \
- qalt->x = qdefault->x
- SYSTEM_TIMESPANS (DEFAULT);
-#undef DEFAULT
-#define DEFAULT(x) if (qalt->x < 0) qalt->x = qdefault->x
- SYSTEM_BOOLEANS (DEFAULT);
- SYSTEM_INTEGERS (DEFAULT);
-#undef DEFAULT
-
- /* We only copy over zport if both zport and qport are NULL,
- because otherwise a default zport would override a specific
- qport. */
- if (qalt->uuconf_zport == (char *) &_uuconf_unset
- && qalt->uuconf_qport == (struct uuconf_port *) &_uuconf_unset)
- qalt->uuconf_zport = qdefault->uuconf_zport;
- if (qalt->uuconf_qport == (struct uuconf_port *) &_uuconf_unset)
- qalt->uuconf_qport = qdefault->uuconf_qport;
-
- if (qalt->uuconf_qproto_params
- == (struct uuconf_proto_param *) &_uuconf_unset)
- qalt->uuconf_qproto_params = qdefault->uuconf_qproto_params;
- else if (qdefault->uuconf_qproto_params != NULL)
- {
- int cnew, ca;
- struct uuconf_proto_param *qd, *qa;
-
- /* Merge in the default protocol parameters, so that a
- system with 'g' protocol parameters won't lose the
- default 'i' protocol parameters. */
- ca = 0;
- cnew = 0;
- for (qd = qdefault->uuconf_qproto_params;
- qd->uuconf_bproto != '\0';
- qd++)
- {
- int c;
-
- c = 0;
- for (qa = qalt->uuconf_qproto_params;
- (qa->uuconf_bproto != '\0'
- && qa->uuconf_bproto != qd->uuconf_bproto);
- qa++)
- ++c;
- if (qa->uuconf_bproto == '\0')
- {
- ++cnew;
- ca = c;
- }
- }
-
- if (cnew > 0)
- {
- struct uuconf_proto_param *qnew;
-
- qnew = ((struct uuconf_proto_param *)
- uuconf_malloc (qset->uuconf_palloc,
- ((ca + cnew + 1)
- * sizeof (struct uuconf_proto_param))));
- if (qnew == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- memcpy ((pointer) qnew, (pointer) qalt->uuconf_qproto_params,
- ca * sizeof (struct uuconf_proto_param));
- cnew = 0;
- for (qd = qdefault->uuconf_qproto_params;
- qd->uuconf_bproto != '\0';
- qd++)
- {
- for (qa = qalt->uuconf_qproto_params;
- (qa->uuconf_bproto != '\0'
- && qa->uuconf_bproto != qd->uuconf_bproto);
- qa++)
- ;
- if (qa->uuconf_bproto == '\0')
- {
- qnew[ca + cnew] = *qd;
- ++cnew;
- }
- }
- qnew[ca + cnew].uuconf_bproto = '\0';
- uuconf_free (qset->uuconf_palloc, qalt->uuconf_qproto_params);
- qalt->uuconf_qproto_params = qnew;
- }
- }
-
- if (qdefault->uuconf_qalternate != NULL)
- qdefault = qdefault->uuconf_qalternate;
- }
-
- return UUCONF_SUCCESS;
-}
-
-/* Put in the basic defaults. This ensures that the fields are valid
- on every uuconf_system structure. */
-
-int
-_uuconf_isystem_basic_default (qglobal, q)
- struct sglobal *qglobal;
- register struct uuconf_system *q;
-{
- int iret;
-
- iret = UUCONF_SUCCESS;
-
- for (; q != NULL && iret == UUCONF_SUCCESS; q = q->uuconf_qalternate)
- {
- /* The default of 26 allowable retries is traditional. */
- if (q->uuconf_cmax_retries < 0)
- q->uuconf_cmax_retries = 26;
- if (q->uuconf_schat.uuconf_pzchat == (char **) &_uuconf_unset)
- {
- q->uuconf_schat.uuconf_pzchat = NULL;
- iret = _uuconf_iadd_string (qglobal, (char *) "\"\"", FALSE,
- FALSE,
- &q->uuconf_schat.uuconf_pzchat,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = _uuconf_iadd_string (qglobal, (char *) "\\r\\c", FALSE,
- FALSE,
- &q->uuconf_schat.uuconf_pzchat,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = _uuconf_iadd_string (qglobal, (char *) "ogin:", FALSE,
- FALSE,
- &q->uuconf_schat.uuconf_pzchat,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = _uuconf_iadd_string (qglobal, (char *) "-BREAK", FALSE,
- FALSE,
- &q->uuconf_schat.uuconf_pzchat,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = _uuconf_iadd_string (qglobal, (char *) "-ogin:", FALSE,
- FALSE,
- &q->uuconf_schat.uuconf_pzchat,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = _uuconf_iadd_string (qglobal, (char *) "-BREAK", FALSE,
- FALSE,
- &q->uuconf_schat.uuconf_pzchat,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = _uuconf_iadd_string (qglobal, (char *) "-ogin:", FALSE,
- FALSE,
- &q->uuconf_schat.uuconf_pzchat,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = _uuconf_iadd_string (qglobal, (char *) "\\L", FALSE,
- FALSE,
- &q->uuconf_schat.uuconf_pzchat,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = _uuconf_iadd_string (qglobal, (char *) "word:", FALSE,
- FALSE,
- &q->uuconf_schat.uuconf_pzchat,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = _uuconf_iadd_string (qglobal, (char *) "\\P", FALSE,
- FALSE,
- &q->uuconf_schat.uuconf_pzchat,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- if (q->uuconf_schat.uuconf_ctimeout < 0)
- q->uuconf_schat.uuconf_ctimeout = 10;
- if (q->uuconf_schat.uuconf_fstrip < 0)
- q->uuconf_schat.uuconf_fstrip = TRUE;
- if (q->uuconf_scalled_chat.uuconf_ctimeout < 0)
- q->uuconf_scalled_chat.uuconf_ctimeout = 60;
- if (q->uuconf_scalled_chat.uuconf_fstrip < 0)
- q->uuconf_scalled_chat.uuconf_fstrip = TRUE;
- if (q->uuconf_fsend_request < 0)
- q->uuconf_fsend_request = TRUE;
- if (q->uuconf_frec_request < 0)
- q->uuconf_frec_request = TRUE;
- if (q->uuconf_fcall_transfer < 0)
- q->uuconf_fcall_transfer = TRUE;
- if (q->uuconf_fcalled_transfer < 0)
- q->uuconf_fcalled_transfer = TRUE;
- if (q->uuconf_pzlocal_send == (char **) &_uuconf_unset)
- {
- q->uuconf_pzlocal_send = NULL;
- iret = _uuconf_iadd_string (qglobal, (char *) ZROOTDIR, FALSE,
- FALSE, &q->uuconf_pzlocal_send,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- if (q->uuconf_pzremote_send == (char **) &_uuconf_unset)
- {
- q->uuconf_pzremote_send = NULL;
- iret = _uuconf_iadd_string (qglobal, (char *) "~", FALSE, FALSE,
- &q->uuconf_pzremote_send,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- if (q->uuconf_pzlocal_receive == (char **) &_uuconf_unset)
- {
- q->uuconf_pzlocal_receive = NULL;
- iret = _uuconf_iadd_string (qglobal, (char *) "~", FALSE, FALSE,
- &q->uuconf_pzlocal_receive,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- if (q->uuconf_pzremote_receive == (char **) &_uuconf_unset)
- {
- q->uuconf_pzremote_receive = NULL;
- iret = _uuconf_iadd_string (qglobal, (char *) "~", FALSE, FALSE,
- &q->uuconf_pzremote_receive,
- q->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- if (q->uuconf_pzpath == (char **) &_uuconf_unset)
- {
- char *zdup;
- char **pz;
- size_t csplit;
- int c;
-
- zdup = (char *) uuconf_malloc (q->uuconf_palloc, sizeof CMDPATH);
- if (zdup == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- memcpy ((pointer) zdup, (pointer) CMDPATH, sizeof CMDPATH);
- pz = NULL;
- csplit = 0;
- if ((c = _uuconf_istrsplit (zdup, '\0', &pz, &csplit)) < 0)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- q->uuconf_pzpath = (char **) uuconf_malloc (q->uuconf_palloc,
- ((c + 1)
- * sizeof (char *)));
- if (q->uuconf_pzpath == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- memcpy ((pointer) q->uuconf_pzpath, (pointer) pz,
- c * sizeof (char *));
- q->uuconf_pzpath[c] = NULL;
- free ((pointer) pz);
- }
-
- if (q->uuconf_pzcmds == (char **) &_uuconf_unset)
- {
- q->uuconf_pzcmds = ((char **)
- uuconf_malloc (q->uuconf_palloc,
- 3 * sizeof (const char *)));
- if (q->uuconf_pzcmds == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- q->uuconf_pzcmds[0] = (char *) "rnews";
- q->uuconf_pzcmds[1] = (char *) "rmail";
- q->uuconf_pzcmds[2] = NULL;
- }
-
- if (q->uuconf_cfree_space < 0)
- q->uuconf_cfree_space = DEFAULT_FREE_SPACE;
-
- if (q->uuconf_zpubdir == (const char *) &_uuconf_unset)
- q->uuconf_zpubdir = qglobal->qprocess->zpubdir;
-
-#define SET(x) if (q->x == (char *) &_uuconf_unset) q->x = NULL
- SYSTEM_STRINGS(SET);
-#undef SET
-#define SET(x) if (q->x == (char **) &_uuconf_unset) q->x = NULL
- SYSTEM_STRING_ARRAYS(SET);
-#undef SET
-#define SET(x) \
- if (q->x == (struct uuconf_timespan *) &_uuconf_unset) q->x = NULL
- SYSTEM_TIMESPANS (SET);
-#undef SET
-#define SET(x) if (q->x < 0) q->x = 0
- SYSTEM_BOOLEANS (SET);
- SYSTEM_INTEGERS (SET);
-#undef SET
-
- if (q->uuconf_zport == (char *) &_uuconf_unset)
- q->uuconf_zport = NULL;
- if (q->uuconf_qport == (struct uuconf_port *) &_uuconf_unset)
- q->uuconf_qport = NULL;
- if (q->uuconf_qproto_params
- == (struct uuconf_proto_param *) &_uuconf_unset)
- q->uuconf_qproto_params = NULL;
- }
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/tcalou.c b/gnu/libexec/uucp/libuuconf/tcalou.c
deleted file mode 100644
index 2caaeb7..0000000
--- a/gnu/libexec/uucp/libuuconf/tcalou.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/* tcalou.c
- Find callout login name and password from Taylor UUCP configuration files.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tcalou_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-static int icsys P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-
-/* Find the callout login name and password for a system from the
- Taylor UUCP configuration files. */
-
-int
-uuconf_taylor_callout (pglobal, qsys, pzlog, pzpass)
- pointer pglobal;
- const struct uuconf_system *qsys;
- char **pzlog;
- char **pzpass;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- boolean flookup;
- struct uuconf_cmdtab as[2];
- char **pz;
- int iret;
- pointer pinfo;
-
- *pzlog = NULL;
- *pzpass = NULL;
-
- flookup = FALSE;
-
- if (qsys->uuconf_zcall_login != NULL)
- {
- if (strcmp (qsys->uuconf_zcall_login, "*") == 0)
- flookup = TRUE;
- else
- {
- *pzlog = strdup (qsys->uuconf_zcall_login);
- if (*pzlog == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- }
- }
-
- if (qsys->uuconf_zcall_password != NULL)
- {
- if (strcmp (qsys->uuconf_zcall_password, "*") == 0)
- flookup = TRUE;
- else
- {
- *pzpass = strdup (qsys->uuconf_zcall_password);
- if (*pzpass == NULL)
- {
- qglobal->ierrno = errno;
- if (*pzlog != NULL)
- {
- free ((pointer) *pzlog);
- *pzlog = NULL;
- }
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- }
- }
-
- if (! flookup)
- {
- if (*pzlog == NULL && *pzpass == NULL)
- return UUCONF_NOT_FOUND;
- return UUCONF_SUCCESS;
- }
-
- as[0].uuconf_zcmd = qsys->uuconf_zname;
- as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 0;
- if (*pzlog == NULL)
- as[0].uuconf_pvar = (pointer) pzlog;
- else
- as[0].uuconf_pvar = NULL;
- as[0].uuconf_pifn = icsys;
-
- as[1].uuconf_zcmd = NULL;
-
- if (*pzpass == NULL)
- pinfo = (pointer) pzpass;
- else
- pinfo = NULL;
-
- iret = UUCONF_SUCCESS;
-
- for (pz = qglobal->qprocess->pzcallfiles; *pz != NULL; pz++)
- {
- FILE *e;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- iret = uuconf_cmd_file (pglobal, e, as, pinfo,
- (uuconf_cmdtabfn) NULL, 0,
- qsys->uuconf_palloc);
- (void) fclose (e);
-
- if (iret != UUCONF_SUCCESS)
- break;
- if (*pzlog != NULL)
- break;
- }
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = *pz;
- return iret | UUCONF_ERROR_FILENAME;
- }
-
- if (*pzlog == NULL && *pzpass == NULL)
- return UUCONF_NOT_FOUND;
-
- return UUCONF_SUCCESS;
-}
-
-/* Copy the login name and password onto the heap and set the
- pointers. The pzlog argument is passed in pvar, and the pzpass
- argument is passed in pinfo. */
-
-static int
-icsys (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char **pzlog = (char **) pvar;
- char **pzpass = (char **) pinfo;
-
- if (argc < 2 || argc > 3)
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- if (pzlog != NULL)
- {
- *pzlog = strdup (argv[1]);
- if (*pzlog == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- }
-
- if (pzpass != NULL)
- {
- if (argc < 3)
- *pzpass = strdup ("");
- else
- *pzpass = strdup (argv[2]);
- if (*pzpass == NULL)
- {
- qglobal->ierrno = errno;
- if (pzlog != NULL)
- {
- free ((pointer) *pzlog);
- *pzlog = NULL;
- }
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- }
-
- return UUCONF_CMDTABRET_EXIT;
-}
diff --git a/gnu/libexec/uucp/libuuconf/tdial.c b/gnu/libexec/uucp/libuuconf/tdial.c
deleted file mode 100644
index e7ffc0c..0000000
--- a/gnu/libexec/uucp/libuuconf/tdial.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/* tdial.c
- Find a dialer in the Taylor UUCP configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tdial_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-static int iddialer P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int idunknown P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-
-/* Find a dialer in the Taylor UUCP configuration files by name. */
-
-int
-uuconf_taylor_dialer_info (pglobal, zname, qdialer)
- pointer pglobal;
- const char *zname;
- struct uuconf_dialer *qdialer;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- FILE *e;
- pointer pblock;
- int iret;
- char **pz;
-
- e = NULL;
- pblock = NULL;
- iret = UUCONF_NOT_FOUND;
-
- for (pz = qglobal->qprocess->pzdialfiles; *pz != NULL; pz++)
- {
- struct uuconf_cmdtab as[2];
- char *zdialer;
- struct uuconf_dialer sdefault;
- int ilineno;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- qglobal->ilineno = 0;
-
- /* Gather the default information from the top of the file. We
- do this by handling the "dialer" command ourselves and
- passing every other command to _uuconf_idialer_cmd via
- idunknown. The value of zdialer will be an malloc block. */
- as[0].uuconf_zcmd = "dialer";
- as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 2;
- as[0].uuconf_pvar = (pointer) &zdialer;
- as[0].uuconf_pifn = iddialer;
-
- as[1].uuconf_zcmd = NULL;
-
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- _uuconf_uclear_dialer (&sdefault);
- sdefault.uuconf_palloc = pblock;
- zdialer = NULL;
- iret = uuconf_cmd_file (pglobal, e, as, (pointer) &sdefault,
- idunknown, UUCONF_CMDTABFLAG_BACKSLASH,
- pblock);
-
- /* Now skip until we find a dialer with a matching name. */
- while (iret == UUCONF_SUCCESS
- && zdialer != NULL
- && strcmp (zname, zdialer) != 0)
- {
- free ((pointer) zdialer);
- zdialer = NULL;
- ilineno = qglobal->ilineno;
- iret = uuconf_cmd_file (pglobal, e, as, (pointer) NULL,
- (uuconf_cmdtabfn) NULL,
- UUCONF_CMDTABFLAG_BACKSLASH,
- pblock);
- qglobal->ilineno += ilineno;
- }
-
- if (iret != UUCONF_SUCCESS)
- {
- if (zdialer != NULL)
- free ((pointer) zdialer);
- break;
- }
-
- if (zdialer != NULL)
- {
- size_t csize;
-
- /* We've found the dialer we're looking for. Read the rest
- of the commands for it. */
- as[0].uuconf_pvar = NULL;
-
- *qdialer = sdefault;
- csize = strlen (zdialer) + 1;
- qdialer->uuconf_zname = uuconf_malloc (pblock, csize);
- if (qdialer->uuconf_zname == NULL)
- {
- qglobal->ierrno = errno;
- free ((pointer) zdialer);
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- memcpy ((pointer) qdialer->uuconf_zname, (pointer) zdialer,
- csize);
- free ((pointer) zdialer);
-
- ilineno = qglobal->ilineno;
- iret = uuconf_cmd_file (pglobal, e, as, qdialer, idunknown,
- UUCONF_CMDTABFLAG_BACKSLASH, pblock);
- qglobal->ilineno += ilineno;
- break;
- }
-
- (void) fclose (e);
- e = NULL;
- uuconf_free_block (pblock);
- pblock = NULL;
-
- iret = UUCONF_NOT_FOUND;
- }
-
- if (e != NULL)
- (void) fclose (e);
- if (iret != UUCONF_SUCCESS && pblock != NULL)
- uuconf_free_block (pblock);
-
- if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND)
- {
- qglobal->zfilename = *pz;
- iret |= UUCONF_ERROR_FILENAME;
- }
-
- return iret;
-}
-
-/* Handle a "dialer" command. This copies the string onto the heap
- and returns the pointer in *pvar, unless pvar is NULL. It returns
- UUCONF_CMDTABRET_EXIT to force _uuconf_icmd_file_internal to stop
- reading and return to the code above, which will then check the
- dialer name just read to see if it matches. */
-
-/*ARGSUSED*/
-static int
-iddialer (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char **pz = (char **) pvar;
-
- if (pz != NULL)
- {
- size_t csize;
-
- csize = strlen (argv[1]) + 1;
- *pz = malloc (csize);
- if (*pz == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- memcpy ((pointer) *pz, (pointer) argv[1], csize);
- }
- return UUCONF_CMDTABRET_EXIT;
-}
-
-/* Handle an unknown command by passing it on to _uuconf_idialer_cmd,
- which will parse it into the dialer structure. */
-
-/*ARGSUSED*/
-static int
-idunknown (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo;
-
- return _uuconf_idialer_cmd (qglobal, argc, argv, qdialer);
-}
diff --git a/gnu/libexec/uucp/libuuconf/tdialc.c b/gnu/libexec/uucp/libuuconf/tdialc.c
deleted file mode 100644
index 26d7823..0000000
--- a/gnu/libexec/uucp/libuuconf/tdialc.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/* tdialc.c
- Handle a Taylor UUCP dialer command.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tdialc_rcsid[] = "$Id$";
-#endif
-
-static int idchat P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int iddtr_toggle P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int idcomplete P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int idproto_param P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int idcunknown P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-
-/* The command table for dialer commands. The "dialer" command is
- handled specially. */
-static const struct cmdtab_offset asDialer_cmds[] =
-{
- { "chat", UUCONF_CMDTABTYPE_PREFIX | 0,
- offsetof (struct uuconf_dialer, uuconf_schat), idchat },
- { "dialtone", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_dialer, uuconf_zdialtone), NULL },
- { "pause", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_dialer, uuconf_zpause), NULL },
- { "carrier", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_dialer, uuconf_fcarrier), NULL },
- { "carrier-wait", UUCONF_CMDTABTYPE_INT,
- offsetof (struct uuconf_dialer, uuconf_ccarrier_wait), NULL },
- { "dtr-toggle", UUCONF_CMDTABTYPE_FN | 0, (size_t) -1, iddtr_toggle },
- { "complete", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct uuconf_dialer, uuconf_scomplete), idcomplete },
- { "complete-chat", UUCONF_CMDTABTYPE_PREFIX,
- offsetof (struct uuconf_dialer, uuconf_scomplete), idchat },
- { "abort", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct uuconf_dialer, uuconf_sabort), idcomplete },
- { "abort-chat", UUCONF_CMDTABTYPE_PREFIX,
- offsetof (struct uuconf_dialer, uuconf_sabort), idchat },
- { "protocol-parameter", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct uuconf_dialer, uuconf_qproto_params), idproto_param },
- { "seven-bit", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct uuconf_dialer, uuconf_ireliable), _uuconf_iseven_bit },
- { "reliable", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct uuconf_dialer, uuconf_ireliable), _uuconf_ireliable },
- { "half-duplex", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct uuconf_dialer, uuconf_ireliable),
- _uuconf_ihalf_duplex },
- { NULL, 0, 0, NULL }
-};
-
-#define CDIALER_CMDS (sizeof asDialer_cmds / sizeof asDialer_cmds[0])
-
-/* Handle a command passed to a dialer from a Taylor UUCP
- configuration file. This can be called when reading the dialer
- file, the port file, or the sys file. The return value may have
- UUCONF_CMDTABRET_KEEP set, but not UUCONF_CMDTABRET_EXIT. It
- assigns values to the elements of qdialer. The first time this is
- called, qdialer->uuconf_palloc should be set. This will not set
- qdialer->uuconf_zname. */
-
-int
-_uuconf_idialer_cmd (qglobal, argc, argv, qdialer)
- struct sglobal *qglobal;
- int argc;
- char **argv;
- struct uuconf_dialer *qdialer;
-{
- struct uuconf_cmdtab as[CDIALER_CMDS];
- int iret;
-
- _uuconf_ucmdtab_base (asDialer_cmds, CDIALER_CMDS, (char *) qdialer, as);
-
- iret = uuconf_cmd_args ((pointer) qglobal, argc, argv, as,
- (pointer) qdialer, idcunknown, 0,
- qdialer->uuconf_palloc);
-
- return iret &~ UUCONF_CMDTABRET_EXIT;
-}
-
-/* Reroute a chat script command. */
-
-static int
-idchat (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_chat *qchat = (struct uuconf_chat *) pvar;
- struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo;
-
- return _uuconf_ichat_cmd (qglobal, argc, argv, qchat,
- qdialer->uuconf_palloc);
-}
-
-/* Handle the "dtr-toggle" command, which may take two arguments. */
-
-/*ARGSUSED*/
-static int
-iddtr_toggle (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo;
- int iret;
-
- if (argc < 2 || argc > 3)
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- iret = _uuconf_iboolean (qglobal, argv[1], &qdialer->uuconf_fdtr_toggle);
- if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS)
- return iret;
-
- if (argc < 3)
- return iret;
-
- iret |= _uuconf_iboolean (qglobal, argv[2],
- &qdialer->uuconf_fdtr_toggle_wait);
-
- return iret;
-}
-
-/* Handle the "complete" and "abort" commands. These just turn a
- string into a trivial chat script. */
-
-/*ARGSUSED*/
-static int
-idcomplete (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_chat *qchat = (struct uuconf_chat *) pvar;
- struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo;
- char *azargs[3];
-
- azargs[0] = (char *) "complete-chat";
- azargs[1] = (char *) "\"\"";
- azargs[2] = (char *) argv[1];
-
- return _uuconf_ichat_cmd (qglobal, 3, azargs, qchat,
- qdialer->uuconf_palloc);
-}
-
-/* Handle the "protocol-parameter" command. */
-
-static int
-idproto_param (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_proto_param **pqparam = (struct uuconf_proto_param **) pvar;
- struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo;
-
- return _uuconf_iadd_proto_param (qglobal, argc - 1, argv + 1, pqparam,
- qdialer->uuconf_palloc);
-}
-
-/* Give an error for an unknown dialer command. */
-
-/*ARGSUSED*/
-static int
-idcunknown (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-}
diff --git a/gnu/libexec/uucp/libuuconf/tdnams.c b/gnu/libexec/uucp/libuuconf/tdnams.c
deleted file mode 100644
index 21e0d45..0000000
--- a/gnu/libexec/uucp/libuuconf/tdnams.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* tdnams.c
- Get all known dialer names from the Taylor UUCP configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tdnams_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-static int indialer P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-
-/* Get the names of all the dialers from the Taylor UUCP configuration
- files. */
-
-int
-uuconf_taylor_dialer_names (pglobal, ppzdialers)
- pointer pglobal;
- char ***ppzdialers;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_cmdtab as[2];
- char **pz;
- int iret;
-
- *ppzdialers = NULL;
-
- as[0].uuconf_zcmd = "dialer";
- as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 2;
- as[0].uuconf_pvar = (pointer) ppzdialers;
- as[0].uuconf_pifn = indialer;
-
- as[1].uuconf_zcmd = NULL;
-
- iret = UUCONF_SUCCESS;
-
- for (pz = qglobal->qprocess->pzdialfiles; *pz != NULL; pz++)
- {
- FILE *e;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- iret = uuconf_cmd_file (pglobal, e, as, (pointer) NULL,
- (uuconf_cmdtabfn) NULL,
- UUCONF_CMDTABFLAG_BACKSLASH,
- (pointer) NULL);
-
- (void) fclose (e);
-
- if (iret != UUCONF_SUCCESS)
- break;
- }
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = *pz;
- return iret | UUCONF_ERROR_FILENAME;
- }
-
- if (*ppzdialers == NULL)
- iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
- ppzdialers, (pointer) NULL);
-
- return UUCONF_SUCCESS;
-}
-
-/* Add a dialer name to the list. */
-
-/*ARGSUSED*/
-static int
-indialer (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char ***ppzdialers = (char ***) pvar;
- int iret;
-
- iret = _uuconf_iadd_string (qglobal, argv[1], TRUE, TRUE, ppzdialers,
- (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- iret |= UUCONF_CMDTABRET_EXIT;
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/tgcmp.c b/gnu/libexec/uucp/libuuconf/tgcmp.c
deleted file mode 100644
index 23ae36b..0000000
--- a/gnu/libexec/uucp/libuuconf/tgcmp.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* tgcmp.c
- A comparison function for grades for _uuconf_time_parse.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tgcmp_rcsid[] = "$Id$";
-#endif
-
-/* A comparison function to pass to _uuconf_itime_parse. This
- compares grades. We can't just pass uuconf_grade_cmp, since
- _uuconf_itime_parse wants a function takes longs as arguments. */
-
-int
-_uuconf_itime_grade_cmp (i1, i2)
- long i1;
- long i2;
-{
- return UUCONF_GRADE_CMP ((int) i1, (int) i2);
-}
diff --git a/gnu/libexec/uucp/libuuconf/thread.c b/gnu/libexec/uucp/libuuconf/thread.c
deleted file mode 100644
index 65d750c..0000000
--- a/gnu/libexec/uucp/libuuconf/thread.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* thread.c
- Initialize for a new thread.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_thread_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Initialize for a new thread, by allocating a new sglobal structure
- which points to the same sprocess structure. */
-
-int
-uuconf_init_thread (ppglobal)
- pointer *ppglobal;
-{
- struct sglobal **pqglob = (struct sglobal **) ppglobal;
- pointer pblock;
- struct sglobal *qnew;
-
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- {
- (*pqglob)->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- qnew = (struct sglobal *) uuconf_malloc (pblock,
- sizeof (struct sglobal));
- if (qnew == NULL)
- {
- (*pqglob)->ierrno = errno;
- uuconf_free_block (pblock);
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- qnew->pblock = pblock;
- qnew->ierrno = 0;
- qnew->ilineno = 0;
- qnew->zfilename = NULL;
- qnew->qprocess = (*pqglob)->qprocess;
-
- *pqglob = qnew;
-
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/time.c b/gnu/libexec/uucp/libuuconf/time.c
deleted file mode 100644
index 172013b..0000000
--- a/gnu/libexec/uucp/libuuconf/time.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/* time.c
- Parse a time string into a uuconf_timespan structure.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_time_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-static int itadd_span P((struct sglobal *qglobal, int istart, int iend,
- long ival, int cretry,
- int (*picmp) P((long, long)),
- struct uuconf_timespan **pqspan,
- pointer pblock));
-static int itnew P((struct sglobal *qglobal, struct uuconf_timespan **pqset,
- struct uuconf_timespan *qnext, int istart, int iend,
- long ival, int cretry, pointer pblock));
-
-/* An array of weekday abbreviations. The code below assumes that
- each one starts with a lower case letter. */
-
-static const struct
-{
- const char *zname;
- int imin;
- int imax;
-} asTdays[] =
-{
- { "any", 0, 6 },
- { "wk", 1, 5 },
- { "su", 0, 0 },
- { "mo", 1, 1 },
- { "tu", 2, 2 },
- { "we", 3, 3 },
- { "th", 4, 4 },
- { "fr", 5, 5 },
- { "sa", 6, 6 },
- { "never", -1, -2 },
- { "none", -1, -2 },
- { NULL, 0, 0 }
-};
-
-/* Parse a time string and add it to a span list. This function is
- given the value, the retry time, and the comparison function to
- use. */
-
-int
-_uuconf_itime_parse (qglobal, ztime, ival, cretry, picmp, pqspan, pblock)
- struct sglobal *qglobal;
- char *ztime;
- long ival;
- int cretry;
- int (*picmp) P((long, long));
- struct uuconf_timespan **pqspan;
- pointer pblock;
-{
- struct uuconf_timespan *qlist;
- char bfirst;
- const char *z;
-
- qlist = *pqspan;
- if (qlist == (struct uuconf_timespan *) &_uuconf_unset)
- qlist = NULL;
-
- /* Expand the string using a timetable. Keep rechecking the string
- until it does not match. */
- while (TRUE)
- {
- char **pz;
- char *zfound;
-
- bfirst = *ztime;
- if (isupper (BUCHAR (bfirst)))
- bfirst = tolower (BUCHAR (bfirst));
-
- zfound = NULL;
- pz = qglobal->qprocess->pztimetables;
-
- /* We want the last timetable to have been defined with this
- name, so we always look through the entire table. */
- while (*pz != NULL)
- {
- if ((bfirst == (*pz)[0]
- || (isupper (BUCHAR ((*pz)[0]))
- && (int) bfirst == (int) tolower (BUCHAR ((*pz)[0]))))
- && strcasecmp (ztime, *pz) == 0)
- zfound = pz[1];
- pz += 2;
- }
- if (zfound == NULL)
- break;
- ztime = zfound;
- }
-
- /* Look through the time string. */
- z = ztime;
- while (*z != '\0')
- {
- int iday;
- boolean afday[7];
- int istart, iend;
-
- if (*z == ',' || *z == '|')
- ++z;
- if (*z == '\0' || *z == ';')
- break;
-
- for (iday = 0; iday < 7; iday++)
- afday[iday] = FALSE;
-
- /* Get the days. */
- do
- {
- bfirst = *z;
- if (isupper (BUCHAR (bfirst)))
- bfirst = tolower (BUCHAR (bfirst));
- for (iday = 0; asTdays[iday].zname != NULL; iday++)
- {
- size_t clen;
-
- if (bfirst != asTdays[iday].zname[0])
- continue;
-
- clen = strlen (asTdays[iday].zname);
- if (strncasecmp (z, asTdays[iday].zname, clen) == 0)
- {
- int iset;
-
- for (iset = asTdays[iday].imin;
- iset <= asTdays[iday].imax;
- iset++)
- afday[iset] = TRUE;
- z += clen;
- break;
- }
- }
- if (asTdays[iday].zname == NULL)
- return UUCONF_SYNTAX_ERROR;
- }
- while (isalpha (BUCHAR (*z)));
-
- /* Get the hours. */
- if (! isdigit (BUCHAR (*z)))
- {
- istart = 0;
- iend = 24 * 60;
- }
- else
- {
- char *zendnum;
-
- istart = (int) strtol ((char *) z, &zendnum, 10);
- if (*zendnum != '-' || ! isdigit (BUCHAR (zendnum[1])))
- return UUCONF_SYNTAX_ERROR;
- z = zendnum + 1;
- iend = (int) strtol ((char *) z, &zendnum, 10);
- z = zendnum;
-
- istart = (istart / 100) * 60 + istart % 100;
- iend = (iend / 100) * 60 + iend % 100;
- }
-
- /* Add the times we've found onto the list. */
- for (iday = 0; iday < 7; iday++)
- {
- if (afday[iday])
- {
- int iminute, iret;
-
- iminute = iday * 24 * 60;
- if (istart < iend)
- iret = itadd_span (qglobal, iminute + istart,
- iminute + iend, ival, cretry, picmp,
- &qlist, pblock);
- else
- {
- /* Wrap around midnight. */
- iret = itadd_span (qglobal, iminute, iminute + iend,
- ival, cretry, picmp, &qlist, pblock);
- if (iret == UUCONF_SUCCESS)
- iret = itadd_span (qglobal, iminute + istart,
- iminute + 24 * 60, ival, cretry,
- picmp, &qlist, pblock);
- }
-
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- }
- }
-
- *pqspan = qlist;
-
- return UUCONF_SUCCESS;
-}
-
-/* Add a time span to an existing list of time spans. We keep the
- list sorted by time to make this operation easier. This modifies
- the existing list, and returns the modified version. It takes a
- comparison function which should return < 0 if the first argument
- should take precedence over the second argument and == 0 if they
- are the same (for grades this is igradecmp; for sizes it is minus
- (the binary operator)). */
-
-static int
-itadd_span (qglobal, istart, iend, ival, cretry, picmp, pqspan, pblock)
- struct sglobal *qglobal;
- int istart;
- int iend;
- long ival;
- int cretry;
- int (*picmp) P((long, long));
- struct uuconf_timespan **pqspan;
- pointer pblock;
-{
- struct uuconf_timespan **pq;
- int iret;
-
- /* istart < iend */
- for (pq = pqspan; *pq != NULL; pq = &(*pq)->uuconf_qnext)
- {
- int icmp;
-
- /* Invariant: PREV (*pq) == NULL || PREV (*pq)->iend <= istart */
- /* istart < iend && (*pq)->istart < (*pq)->iend */
-
- if (iend <= (*pq)->uuconf_istart)
- {
- /* istart < iend <= (*pq)->istart < (*pq)->iend */
- /* No overlap, and we're at the right spot. See if we can
- combine these spans. */
- if (iend == (*pq)->uuconf_istart
- && cretry == (*pq)->uuconf_cretry
- && (*picmp) (ival, (*pq)->uuconf_ival) == 0)
- {
- (*pq)->uuconf_istart = istart;
- return UUCONF_SUCCESS;
- }
- /* We couldn't combine them. */
- break;
- }
-
- if ((*pq)->uuconf_iend <= istart)
- {
- /* (*pq)->istart < (*pq)->iend <= istart < iend */
- /* No overlap. Try attaching this span. */
- if ((*pq)->uuconf_iend == istart
- && (*pq)->uuconf_cretry == cretry
- && ((*pq)->uuconf_qnext == NULL
- || iend <= (*pq)->uuconf_qnext->uuconf_istart)
- && (*picmp) (ival, (*pq)->uuconf_ival) == 0)
- {
- (*pq)->uuconf_iend = iend;
- return UUCONF_SUCCESS;
- }
- /* Couldn't attach; keep looking for the right spot. We
- might be able to combine part of the new span onto an
- existing span, but it's probably not worth it. */
- continue;
- }
-
- /* istart < iend
- && (*pq)->istart < (*pq)->iend
- && istart < (*pq)->iend
- && (*pq)->istart < iend */
- /* Overlap. */
-
- icmp = (*picmp) (ival, (*pq)->uuconf_ival);
-
- if (icmp == 0)
- {
- /* Just expand the old span to include the new span. */
- if (istart < (*pq)->uuconf_istart)
- (*pq)->uuconf_istart = istart;
- if ((*pq)->uuconf_iend >= iend)
- return UUCONF_SUCCESS;
- if ((*pq)->uuconf_qnext == NULL
- || iend <= (*pq)->uuconf_qnext->uuconf_istart)
- {
- (*pq)->uuconf_iend = iend;
- return UUCONF_SUCCESS;
- }
- /* The span we are adding overlaps the next span as well.
- Expand the old span up to the next old span, and keep
- trying to add the new span. */
- (*pq)->uuconf_iend = (*pq)->uuconf_qnext->uuconf_istart;
- istart = (*pq)->uuconf_iend;
- }
- else if (icmp < 0)
- {
- /* Replace the old span with the new span. */
- if ((*pq)->uuconf_istart < istart)
- {
- /* Save the initial portion of the old span. */
- iret = itnew (qglobal, pq, *pq, (*pq)->uuconf_istart, istart,
- (*pq)->uuconf_ival, (*pq)->uuconf_cretry,
- pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
- pq = &(*pq)->uuconf_qnext;
- }
- if (iend < (*pq)->uuconf_iend)
- {
- /* Save the final portion of the old span. */
- iret = itnew (qglobal, &(*pq)->uuconf_qnext,
- (*pq)->uuconf_qnext, iend, (*pq)->uuconf_iend,
- (*pq)->uuconf_ival, (*pq)->uuconf_cretry,
- pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- (*pq)->uuconf_ival = ival;
- (*pq)->uuconf_istart = istart;
- (*pq)->uuconf_cretry = cretry;
- if ((*pq)->uuconf_qnext == NULL
- || iend <= (*pq)->uuconf_qnext->uuconf_istart)
- {
- (*pq)->uuconf_iend = iend;
- return UUCONF_SUCCESS;
- }
- /* Move this span up to the next one, and keep trying to add
- the new span. */
- (*pq)->uuconf_iend = (*pq)->uuconf_qnext->uuconf_istart;
- istart = (*pq)->uuconf_iend;
- }
- else
- {
- /* Leave the old span untouched. */
- if (istart < (*pq)->uuconf_istart)
- {
- /* Put in the initial portion of the new span. */
- iret = itnew (qglobal, pq, *pq, istart, (*pq)->uuconf_istart,
- ival, cretry, pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
- pq = &(*pq)->uuconf_qnext;
- }
- if (iend <= (*pq)->uuconf_iend)
- return UUCONF_SUCCESS;
- /* Keep trying to add the new span. */
- istart = (*pq)->uuconf_iend;
- }
- }
-
- /* This is the spot for the new span, and there's no overlap. */
-
- return itnew (qglobal, pq, *pq, istart, iend, ival, cretry, pblock);
-}
-
-/* A utility function to create a new uuconf_timespan structure. */
-
-static int
-itnew (qglobal, pqset, qnext, istart, iend, ival, cretry, pblock)
- struct sglobal *qglobal;
- struct uuconf_timespan **pqset;
- struct uuconf_timespan *qnext;
- int istart;
- int iend;
- long ival;
- int cretry;
- pointer pblock;
-{
- register struct uuconf_timespan *qnew;
-
- qnew = ((struct uuconf_timespan *)
- uuconf_malloc (pblock, sizeof (struct uuconf_timespan)));
- if (qnew == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- qnew->uuconf_qnext = qnext;
- qnew->uuconf_istart = istart;
- qnew->uuconf_iend = iend;
- qnew->uuconf_ival = ival;
- qnew->uuconf_cretry = cretry;
-
- *pqset = qnew;
-
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/tinit.c b/gnu/libexec/uucp/libuuconf/tinit.c
deleted file mode 100644
index 2e501dd..0000000
--- a/gnu/libexec/uucp/libuuconf/tinit.c
+++ /dev/null
@@ -1,465 +0,0 @@
-/* tinit.c
- Initialize for reading Taylor UUCP configuration files.
-
- Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tinit_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Local functions. */
-
-static int itset_default P((struct sglobal *qglobal, char ***ppzvar,
- const char *zfile));
-static int itdebug P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int itaddfile P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int itunknown P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int itprogram P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-
-static const struct cmdtab_offset asCmds[] =
-{
- { "nodename", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct sprocess, zlocalname), NULL },
- { "hostname", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct sprocess, zlocalname), NULL },
- { "uuname", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct sprocess, zlocalname), NULL },
- { "spool", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct sprocess, zspooldir), NULL },
- { "pubdir", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct sprocess, zpubdir), NULL },
- { "lockdir", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct sprocess, zlockdir), NULL },
- { "logfile", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct sprocess, zlogfile), NULL },
- { "statfile", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct sprocess, zstatsfile), NULL },
- { "debugfile", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct sprocess, zdebugfile), NULL },
- { "debug", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct sprocess, zdebug), itdebug },
- { "strip-login", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct sprocess, fstrip_login), NULL },
- { "strip-proto", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct sprocess, fstrip_proto), NULL },
- { "max-uuxqts", UUCONF_CMDTABTYPE_INT,
- offsetof (struct sprocess, cmaxuuxqts), NULL },
- { "run-uuxqt", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct sprocess, zrunuuxqt), NULL },
- { "sysfile", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct sprocess, pzsysfiles), itaddfile },
- { "portfile", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct sprocess, pzportfiles), itaddfile },
- { "dialfile", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct sprocess, pzdialfiles), itaddfile },
- { "dialcodefile", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct sprocess, pzdialcodefiles), itaddfile },
- { "callfile", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct sprocess, pzcallfiles), itaddfile },
- { "passwdfile", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct sprocess, pzpwdfiles), itaddfile },
- { "unknown", UUCONF_CMDTABTYPE_FN, offsetof (struct sprocess, qunknown),
- itunknown },
- { "v2-files", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct sprocess, fv2), NULL },
- { "hdb-files", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct sprocess, fhdb), NULL },
- { "bnu-files", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct sprocess, fhdb), NULL },
- { "timetable", UUCONF_CMDTABTYPE_FN | 3,
- offsetof (struct sprocess, pztimetables), _uuconf_itimetable },
- { NULL, 0, 0, NULL }
-};
-
-#define CCMDS (sizeof asCmds / sizeof asCmds[0])
-
-/* This structure is used to pass information into the command table
- functions. */
-
-struct sinfo
-{
- /* The program name. */
- const char *zname;
- /* A pointer to the command table being used, passed to isystem so
- it can call uuconf_cmd_args. */
- struct uuconf_cmdtab *qcmds;
-};
-
-/* Initialize the routines which read the Taylor UUCP configuration
- files. */
-
-int
-uuconf_taylor_init (ppglobal, zprogram, zname)
- pointer *ppglobal;
- const char *zprogram;
- const char *zname;
-{
- struct sglobal **pqglobal = (struct sglobal **) ppglobal;
- int iret;
- char *zcopy;
- struct sglobal *qglobal;
- boolean fdefault;
- FILE *e;
- struct sinfo si;
-
- if (*pqglobal == NULL)
- {
- iret = _uuconf_iinit_global (pqglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- qglobal = *pqglobal;
-
- if (zname != NULL)
- {
- size_t csize;
-
- csize = strlen (zname) + 1;
- zcopy = uuconf_malloc (qglobal->pblock, csize);
- if (zcopy == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- memcpy ((pointer) zcopy, (pointer) zname, csize);
- fdefault = FALSE;
- }
- else
- {
- zcopy = uuconf_malloc (qglobal->pblock,
- sizeof NEWCONFIGLIB + sizeof CONFIGFILE - 1);
- if (zcopy == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- memcpy ((pointer) zcopy, (pointer) NEWCONFIGLIB,
- sizeof NEWCONFIGLIB - 1);
- memcpy ((pointer) (zcopy + sizeof NEWCONFIGLIB - 1),
- (pointer) CONFIGFILE, sizeof CONFIGFILE);
- fdefault = TRUE;
- }
-
- qglobal->qprocess->zconfigfile = zcopy;
-
- e = fopen (zcopy, "r");
- if (e == NULL)
- {
- if (! fdefault)
- {
- qglobal->ierrno = errno;
- qglobal->zfilename = zcopy;
- return (UUCONF_FOPEN_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_ERROR_FILENAME);
- }
-
- /* There is no config file, so just use the default values. */
- }
- else
- {
- struct uuconf_cmdtab as[CCMDS];
-
- _uuconf_ucmdtab_base (asCmds, CCMDS, (char *) qglobal->qprocess,
- as);
-
- if (zprogram == NULL)
- zprogram = "uucp";
-
- si.zname = zprogram;
- si.qcmds = as;
- iret = uuconf_cmd_file (qglobal, e, as, (pointer) &si, itprogram,
- UUCONF_CMDTABFLAG_BACKSLASH,
- qglobal->pblock);
-
- (void) fclose (e);
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = zcopy;
- return iret | UUCONF_ERROR_FILENAME;
- }
- }
-
- /* Get the defaults for the file names. */
-
- iret = itset_default (qglobal, &qglobal->qprocess->pzsysfiles, SYSFILE);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = itset_default (qglobal, &qglobal->qprocess->pzportfiles, PORTFILE);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = itset_default (qglobal, &qglobal->qprocess->pzdialfiles, DIALFILE);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = itset_default (qglobal, &qglobal->qprocess->pzdialcodefiles,
- DIALCODEFILE);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = itset_default (qglobal, &qglobal->qprocess->pzpwdfiles, PASSWDFILE);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = itset_default (qglobal, &qglobal->qprocess->pzcallfiles, CALLFILE);
- if (iret != UUCONF_SUCCESS)
- return iret;
-
- return UUCONF_SUCCESS;
-}
-
-/* Local interface to the _uuconf_idebug_cmd function, which handles
- the "debug" command. */
-
-static int
-itdebug (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char **pzdebug = (char **) pvar;
-
- return _uuconf_idebug_cmd (qglobal, pzdebug, argc, argv,
- qglobal->pblock);
-}
-
-/* Add new filenames to a list of files. */
-
-/*ARGSUSED*/
-static int
-itaddfile (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char ***ppz = (char ***) pvar;
- int i;
- int iret;
-
- if (argc == 1)
- {
- iret = _uuconf_iadd_string (qglobal, NULL, FALSE, FALSE, ppz,
- qglobal->pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- else
- {
- for (i = 1; i < argc; i++)
- {
- char *z;
- boolean fallocated;
-
- MAKE_ABSOLUTE (z, fallocated, argv[i], NEWCONFIGLIB,
- qglobal->pblock);
- if (z == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- iret = _uuconf_iadd_string (qglobal, z, ! fallocated, FALSE, ppz,
- qglobal->pblock);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
- }
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Handle an "unknown" command. We accumulate this into a linked
- list, and only parse them later in uuconf_unknown_system_info. */
-
-/*ARGSUSED*/
-static int
-itunknown (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sunknown **pq = (struct sunknown **) pvar;
- struct sunknown *q;
-
- q = (struct sunknown *) uuconf_malloc (qglobal->pblock,
- sizeof (struct sunknown));
- if (q == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- q->qnext = NULL;
- q->ilineno = qglobal->ilineno;
- q->cargs = argc - 1;
- q->pzargs = (char **) uuconf_malloc (qglobal->pblock,
- (argc - 1) * sizeof (char *));
- if (q->pzargs == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- memcpy ((pointer) q->pzargs, (pointer) (argv + 1),
- (argc - 1) * sizeof (char *));
-
- while (*pq != NULL)
- pq = &(*pq)->qnext;
-
- *pq = q;
-
- return UUCONF_CMDTABRET_KEEP;
-}
-
-/* If we encounter an unknown command, see if it is the program with
- which we were invoked. If it was, pass the remaining arguments
- back through the table. */
-
-/*ARGSUSED*/
-static int
-itprogram (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
-
- if (argc <= 1
- || strcasecmp (qinfo->zname, argv[0]) != 0)
- return UUCONF_CMDTABRET_CONTINUE;
-
- return uuconf_cmd_args (pglobal, argc - 1, argv + 1, qinfo->qcmds,
- (pointer) NULL, (uuconf_cmdtabfn) NULL, 0,
- qglobal->pblock);
-}
-
-/* If a filename was not set by the configuration file, add in the
- default value. */
-
-static int
-itset_default (qglobal, ppzvar, zfile)
- struct sglobal *qglobal;
- char ***ppzvar;
- const char *zfile;
-{
- size_t clen;
- char *zadd;
-
- if (*ppzvar != NULL)
- return UUCONF_SUCCESS;
-
- clen = strlen (zfile);
- zadd = (char *) uuconf_malloc (qglobal->pblock,
- sizeof NEWCONFIGLIB + clen);
- if (zadd == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- memcpy ((pointer) zadd, (pointer) NEWCONFIGLIB, sizeof NEWCONFIGLIB - 1);
- memcpy ((pointer) (zadd + sizeof NEWCONFIGLIB - 1), (pointer) zfile,
- clen + 1);
-
- return _uuconf_iadd_string (qglobal, zadd, FALSE, FALSE, ppzvar,
- qglobal->pblock);
-}
-
-/* Handle the "debug" command which is documented to take multiple
- arguments. This is also called by the ``debug'' command in a sys
- file. It returns a CMDTABRET code. This should probably be in its
- own file, but the only other place it is called is from tsinfo.c,
- and any user of tsinfo.c it sure to link in this file as well. */
-
-int
-_uuconf_idebug_cmd (qglobal, pzdebug, argc, argv, pblock)
- struct sglobal *qglobal;
- char **pzdebug;
- int argc;
- char **argv;
- pointer pblock;
-{
- if (argc == 1)
- {
- *pzdebug = NULL;
- return UUCONF_CMDTABRET_CONTINUE;
- }
- else if (argc == 2)
- {
- *pzdebug = argv[1];
- return UUCONF_CMDTABRET_KEEP;
- }
- else
- {
- size_t cdebug;
- int i;
- char *zdebug;
-
- cdebug = 0;
- for (i = 1; i < argc; i++)
- cdebug += strlen (argv[i]) + 1;
- zdebug = (char *) uuconf_malloc (pblock, cdebug);
- if (zdebug == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- cdebug = 0;
- for (i = 1; i < argc; i++)
- {
- size_t clen;
-
- clen = strlen (argv[i]);
- memcpy (zdebug + cdebug, argv[i], clen);
- zdebug[cdebug + clen] = ' ';
- cdebug += clen + 1;
- }
- zdebug[cdebug - 1] = '\0';
- *pzdebug = zdebug;
- return UUCONF_CMDTABRET_CONTINUE;
- }
-}
diff --git a/gnu/libexec/uucp/libuuconf/tlocnm.c b/gnu/libexec/uucp/libuuconf/tlocnm.c
deleted file mode 100644
index 93f53b8..0000000
--- a/gnu/libexec/uucp/libuuconf/tlocnm.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* tlocnm.c
- Get the local name to use from the Taylor UUCP configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tlocnm_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Get the local name to use, based on the login name, from the Taylor
- UUCP configuration files. This could probably be done in a
- slightly more intelligent fashion, but no matter what it has to
- read the systems files. */
-
-int
-uuconf_taylor_login_localname (pglobal, zlogin, pzname)
- pointer pglobal;
- const char *zlogin;
- char **pzname;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char **pznames, **pz;
- int iret;
-
- if (! qglobal->qprocess->fread_syslocs)
- {
- iret = _uuconf_iread_locations (qglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- /* As a simple optimization, if there is no "myname" command we can
- simply return immediately. */
- if (! qglobal->qprocess->fuses_myname)
- {
- *pzname = NULL;
- return UUCONF_NOT_FOUND;
- }
-
- iret = uuconf_taylor_system_names (pglobal, &pznames, 0);
- if (iret != UUCONF_SUCCESS)
- return iret;
-
- *pzname = NULL;
- iret = UUCONF_NOT_FOUND;
-
- for (pz = pznames; *pz != NULL; pz++)
- {
- struct uuconf_system ssys;
- struct uuconf_system *qsys;
-
- iret = uuconf_system_info (pglobal, *pz, &ssys);
- if (iret != UUCONF_SUCCESS)
- break;
-
- for (qsys = &ssys; qsys != NULL; qsys = qsys->uuconf_qalternate)
- {
- if (qsys->uuconf_zlocalname != NULL
- && qsys->uuconf_fcalled
- && qsys->uuconf_zcalled_login != NULL
- && strcmp (qsys->uuconf_zcalled_login, zlogin) == 0)
- {
- *pzname = strdup (qsys->uuconf_zlocalname);
- if (*pzname != NULL)
- iret = UUCONF_SUCCESS;
- else
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- break;
- }
- }
-
- (void) uuconf_system_free (pglobal, &ssys);
-
- if (qsys != NULL)
- break;
-
- iret = UUCONF_NOT_FOUND;
- }
-
- for (pz = pznames; *pz != NULL; pz++)
- free ((pointer) *pz);
- free ((pointer) pznames);
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/tport.c b/gnu/libexec/uucp/libuuconf/tport.c
deleted file mode 100644
index cc350f2..0000000
--- a/gnu/libexec/uucp/libuuconf/tport.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/* tport.c
- Find a port in the Taylor UUCP configuration files.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tport_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-static int ipport P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int ipunknown P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-
-/* Find a port in the Taylor UUCP configuration files by name, baud
- rate, and special purpose function. */
-
-int
-uuconf_taylor_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo,
- qport)
- pointer pglobal;
- const char *zname;
- long ibaud;
- long ihighbaud;
- int (*pifn) P((struct uuconf_port *, pointer));
- pointer pinfo;
- struct uuconf_port *qport;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- FILE *e;
- pointer pblock;
- char *zfree;
- int iret;
- char **pz;
-
- if (ihighbaud == 0L)
- ihighbaud = ibaud;
-
- e = NULL;
- pblock = NULL;
- zfree = NULL;
- iret = UUCONF_NOT_FOUND;
-
- for (pz = qglobal->qprocess->pzportfiles; *pz != NULL; pz++)
- {
- struct uuconf_cmdtab as[2];
- char *zport;
- struct uuconf_port sdefault;
- int ilineno;
-
- e = fopen (*pz, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- continue;
- qglobal->ierrno = errno;
- iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- qglobal->ilineno = 0;
-
- /* Gather the default information from the top of the file. We
- do this by handling the "port" command ourselves and passing
- every other command to _uuconf_iport_cmd via ipunknown. The
- value of zport will be an malloc block. */
- as[0].uuconf_zcmd = "port";
- as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 2;
- as[0].uuconf_pvar = (pointer) &zport;
- as[0].uuconf_pifn = ipport;
-
- as[1].uuconf_zcmd = NULL;
-
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- _uuconf_uclear_port (&sdefault);
- sdefault.uuconf_palloc = pblock;
- zport = NULL;
- iret = uuconf_cmd_file (pglobal, e, as, (pointer) &sdefault,
- ipunknown, UUCONF_CMDTABFLAG_BACKSLASH,
- pblock);
- if (iret != UUCONF_SUCCESS)
- {
- zfree = zport;
- break;
- }
-
- /* Now skip until we find a port with a matching name. If the
- zname argument is NULL, we will have to read every port. */
- iret = UUCONF_NOT_FOUND;
- while (zport != NULL)
- {
- uuconf_cmdtabfn piunknown;
- boolean fmatch;
-
- if (zname == NULL || strcmp (zname, zport) == 0)
- {
- piunknown = ipunknown;
- *qport = sdefault;
- qport->uuconf_zname = zport;
- zfree = zport;
- fmatch = TRUE;
- }
- else
- {
- piunknown = NULL;
- free ((pointer) zport);
- fmatch = FALSE;
- }
-
- zport = NULL;
- ilineno = qglobal->ilineno;
- iret = uuconf_cmd_file (pglobal, e, as, (pointer) qport,
- piunknown, UUCONF_CMDTABFLAG_BACKSLASH,
- pblock);
- qglobal->ilineno += ilineno;
- if (iret != UUCONF_SUCCESS)
- break;
- iret = UUCONF_NOT_FOUND;
-
- /* We may have just gathered information about a port. See
- if it matches the name, the baud rate and the special
- function. */
- if (fmatch)
- {
- if (ibaud != 0)
- {
- if (qport->uuconf_ttype == UUCONF_PORTTYPE_MODEM)
- {
- long imbaud, imhigh, imlow;
-
- imbaud = qport->uuconf_u.uuconf_smodem.uuconf_ibaud;
- imhigh = qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud;
- imlow = qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud;
-
- if (imbaud == 0 && imlow == 0)
- ;
- else if (ibaud <= imbaud && imbaud <= ihighbaud)
- ;
- else if (imlow != 0
- && imlow <= ihighbaud
- && imhigh >= ibaud)
- ;
- else
- fmatch = FALSE;
- }
- else if (qport->uuconf_ttype == UUCONF_PORTTYPE_DIRECT)
- {
- long idbaud;
-
- idbaud = qport->uuconf_u.uuconf_sdirect.uuconf_ibaud;
- if (idbaud != 0 && idbaud != ibaud)
- fmatch = FALSE;
- }
- }
- }
-
- if (fmatch)
- {
- if (pifn != NULL)
- {
- iret = (*pifn) (qport, pinfo);
- if (iret == UUCONF_NOT_FOUND)
- fmatch = FALSE;
- else if (iret != UUCONF_SUCCESS)
- break;
- }
- }
-
- if (fmatch)
- {
- if (uuconf_add_block (pblock, zfree) == 0)
- {
- zfree = NULL;
- iret = UUCONF_SUCCESS;
- }
- else
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- break;
- }
-
- if (zfree != NULL)
- {
- free ((pointer) zfree);
- zfree = NULL;
- }
- }
-
- (void) fclose (e);
- e = NULL;
-
- if (iret != UUCONF_NOT_FOUND)
- break;
-
- uuconf_free_block (pblock);
- pblock = NULL;
- }
-
- if (e != NULL)
- (void) fclose (e);
- if (zfree != NULL)
- free ((pointer) zfree);
- if (iret != UUCONF_SUCCESS && pblock != NULL)
- uuconf_free_block (pblock);
-
- if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND)
- {
- qglobal->zfilename = *pz;
- iret |= UUCONF_ERROR_FILENAME;
- }
-
- return iret;
-}
-
-/* Handle a "port" command. This copies the string onto the heap and
- returns the pointer in *pvar. It returns UUCONF_CMDTABRET_EXIT to
- force uuconf_cmd_file to stop reading and return to the code above,
- which will then check the port just read to see if it matches. */
-
-/*ARGSUSED*/
-static int
-ipport (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- char **pz = (char **) pvar;
- size_t csize;
-
- csize = strlen (argv[1]) + 1;
- *pz = malloc (csize);
- if (*pz == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- memcpy ((pointer) *pz, (pointer) argv[1], csize);
- return UUCONF_CMDTABRET_EXIT;
-}
-
-/* Handle an unknown command by passing it on to _uuconf_iport_cmd,
- which will parse it into the port structure. */
-
-/*ARGSUSED*/
-static int
-ipunknown (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_port *qport = (struct uuconf_port *) pinfo;
- int iret;
-
- iret = _uuconf_iport_cmd (qglobal, argc, argv, qport);
- if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS)
- iret |= UUCONF_CMDTABRET_EXIT;
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/tportc.c b/gnu/libexec/uucp/libuuconf/tportc.c
deleted file mode 100644
index a2b845a..0000000
--- a/gnu/libexec/uucp/libuuconf/tportc.c
+++ /dev/null
@@ -1,505 +0,0 @@
-/* tportc.c
- Handle a Taylor UUCP port command.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tportc_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-static int ipproto_param P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int ipbaud_range P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int ipdialer P((pointer pglobal, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int ipcunknown P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-
-/* The string names of the port types. This array corresponds to the
- uuconf_porttype enumeration. */
-
-static const char * const azPtype_names[] =
-{
- NULL,
- "stdin",
- "modem",
- "direct",
- "tcp",
- "tli",
- "pipe"
-};
-
-#define CPORT_TYPES (sizeof azPtype_names / sizeof azPtype_names[0])
-
-/* The command table for generic port commands. The "port" and "type"
- commands are handled specially. */
-static const struct cmdtab_offset asPort_cmds[] =
-{
- { "protocol", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_port, uuconf_zprotocols), NULL },
- { "protocol-parameter", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct uuconf_port, uuconf_qproto_params), ipproto_param },
- { "seven-bit", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct uuconf_port, uuconf_ireliable), _uuconf_iseven_bit },
- { "reliable", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct uuconf_port, uuconf_ireliable), _uuconf_ireliable },
- { "half-duplex", UUCONF_CMDTABTYPE_FN | 2,
- offsetof (struct uuconf_port, uuconf_ireliable),
- _uuconf_ihalf_duplex },
- { "lockname", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_port, uuconf_zlockname), NULL },
- { NULL, 0, 0, NULL }
-};
-
-#define CPORT_CMDS (sizeof asPort_cmds / sizeof asPort_cmds[0])
-
-/* The stdin port command table. */
-static const struct cmdtab_offset asPstdin_cmds[] =
-{
- { NULL, 0, 0, NULL }
-};
-
-#define CSTDIN_CMDS (sizeof asPstdin_cmds / sizeof asPstdin_cmds[0])
-
-/* The modem port command table. */
-static const struct cmdtab_offset asPmodem_cmds[] =
-{
- { "device", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_zdevice),
- NULL },
- { "baud", UUCONF_CMDTABTYPE_LONG,
- offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_ibaud),
- NULL },
- { "speed", UUCONF_CMDTABTYPE_LONG,
- offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_ibaud),
- NULL },
- { "baud-range", UUCONF_CMDTABTYPE_FN | 3,
- offsetof (struct uuconf_port, uuconf_u.uuconf_smodem), ipbaud_range },
- { "speed-range", UUCONF_CMDTABTYPE_FN | 3,
- offsetof (struct uuconf_port, uuconf_u.uuconf_smodem), ipbaud_range },
- { "carrier", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_fcarrier),
- NULL },
- { "hardflow", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_fhardflow),
- NULL },
- { "dial-device", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_port,
- uuconf_u.uuconf_smodem.uuconf_zdial_device),
- NULL },
- { "dialer", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct uuconf_port, uuconf_u.uuconf_smodem), ipdialer },
- { "dialer-sequence", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_pzdialer),
- NULL },
- { NULL, 0, 0, NULL }
-};
-
-#define CMODEM_CMDS (sizeof asPmodem_cmds / sizeof asPmodem_cmds[0])
-
-/* The direct port command table. */
-static const struct cmdtab_offset asPdirect_cmds[] =
-{
- { "device", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_zdevice),
- NULL },
- { "baud", UUCONF_CMDTABTYPE_LONG,
- offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_ibaud),
- NULL },
- { "speed", UUCONF_CMDTABTYPE_LONG,
- offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_ibaud),
- NULL },
- { "carrier", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_fcarrier),
- NULL },
- { "hardflow", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_fhardflow),
- NULL },
- { NULL, 0, 0, NULL }
-};
-
-#define CDIRECT_CMDS (sizeof asPdirect_cmds / sizeof asPdirect_cmds[0])
-
-/* The TCP port command table. */
-static const struct cmdtab_offset asPtcp_cmds[] =
-{
- { "service", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_port, uuconf_u.uuconf_stcp.uuconf_zport),
- NULL },
- { "dialer-sequence", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_port, uuconf_u.uuconf_stcp.uuconf_pzdialer),
- NULL },
- { NULL, 0, 0, NULL }
-};
-
-#define CTCP_CMDS (sizeof asPtcp_cmds / sizeof asPtcp_cmds[0])
-
-/* The TLI port command table. */
-static const struct cmdtab_offset asPtli_cmds[] =
-{
- { "device", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_port, uuconf_u.uuconf_stli.uuconf_zdevice),
- NULL },
- { "stream", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_port, uuconf_u.uuconf_stli.uuconf_fstream),
- NULL },
- { "push", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_port, uuconf_u.uuconf_stli.uuconf_pzpush),
- NULL },
- { "dialer-sequence", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_port, uuconf_u.uuconf_stli.uuconf_pzdialer),
- NULL },
- { "server-address", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_port, uuconf_u.uuconf_stli.uuconf_zservaddr),
- NULL },
- { NULL, 0, 0, NULL }
-};
-
-#define CTLI_CMDS (sizeof asPtli_cmds / sizeof asPtli_cmds[0])
-
-/* The pipe port command table. */
-static const struct cmdtab_offset asPpipe_cmds[] =
-{
- { "command", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_port, uuconf_u.uuconf_spipe.uuconf_pzcmd),
- NULL },
- { NULL, 0, 0, NULL}
-};
-
-#define CPIPE_CMDS (sizeof asPpipe_cmds / sizeof asPpipe_cmds[0])
-
-#undef max
-#define max(i1, i2) ((i1) > (i2) ? (i1) : (i2))
-#define CCMDS \
- max (max (max (CPORT_CMDS, CSTDIN_CMDS), CMODEM_CMDS), \
- max (max (CDIRECT_CMDS, CTCP_CMDS), max (CTLI_CMDS, CPIPE_CMDS)))
-
-/* Handle a command passed to a port from a Taylor UUCP configuration
- file. This can be called when reading either the port file or the
- sys file. The return value may have UUCONF_CMDTABRET_KEEP set, but
- not UUCONF_CMDTABRET_EXIT. It assigns values to the elements of
- qport. The first time this is called, qport->uuconf_zname and
- qport->uuconf_palloc should be set and qport->uuconf_ttype should
- be UUCONF_PORTTYPE_UNKNOWN. */
-
-int
-_uuconf_iport_cmd (qglobal, argc, argv, qport)
- struct sglobal *qglobal;
- int argc;
- char **argv;
- struct uuconf_port *qport;
-{
- boolean fgottype;
- const struct cmdtab_offset *qcmds;
- size_t ccmds;
- struct uuconf_cmdtab as[CCMDS];
- int i;
- int iret;
-
- fgottype = strcasecmp (argv[0], "type") == 0;
-
- if (fgottype || qport->uuconf_ttype == UUCONF_PORTTYPE_UNKNOWN)
- {
- enum uuconf_porttype ttype;
-
- /* We either just got a "type" command, or this is an
- uninitialized port. If the first command to a port is not
- "type", it is assumed to be a modem port. This
- implementation will actually permit "type" at any point, but
- will effectively discard any type specific information that
- appears before the "type" command. This supports defaults,
- in that the default may be of a specific type while future
- ports in the same file may be of other types. */
- if (! fgottype)
- ttype = UUCONF_PORTTYPE_MODEM;
- else
- {
- if (argc != 2)
- return UUCONF_SYNTAX_ERROR;
-
- for (i = 0; i < CPORT_TYPES; i++)
- if (azPtype_names[i] != NULL
- && strcasecmp (argv[1], azPtype_names[i]) == 0)
- break;
-
- if (i >= CPORT_TYPES)
- return UUCONF_SYNTAX_ERROR;
-
- ttype = (enum uuconf_porttype) i;
- }
-
- qport->uuconf_ttype = ttype;
-
- switch (ttype)
- {
- default:
- case UUCONF_PORTTYPE_STDIN:
- break;
- case UUCONF_PORTTYPE_MODEM:
- qport->uuconf_u.uuconf_smodem.uuconf_zdevice = NULL;
- qport->uuconf_u.uuconf_smodem.uuconf_zdial_device = NULL;
- qport->uuconf_u.uuconf_smodem.uuconf_ibaud = 0L;
- qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = 0L;
- qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = 0L;
- qport->uuconf_u.uuconf_smodem.uuconf_fcarrier = TRUE;
- qport->uuconf_u.uuconf_smodem.uuconf_fhardflow = TRUE;
- qport->uuconf_u.uuconf_smodem.uuconf_pzdialer = NULL;
- qport->uuconf_u.uuconf_smodem.uuconf_qdialer = NULL;
- break;
- case UUCONF_PORTTYPE_DIRECT:
- qport->uuconf_u.uuconf_sdirect.uuconf_zdevice = NULL;
- qport->uuconf_u.uuconf_sdirect.uuconf_ibaud = -1;
- qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier = FALSE;
- qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow = TRUE;
- break;
- case UUCONF_PORTTYPE_TCP:
- qport->uuconf_u.uuconf_stcp.uuconf_zport = (char *) "uucp";
- qport->uuconf_u.uuconf_stcp.uuconf_pzdialer = NULL;
- qport->uuconf_ireliable = (UUCONF_RELIABLE_SPECIFIED
- | UUCONF_RELIABLE_ENDTOEND
- | UUCONF_RELIABLE_RELIABLE
- | UUCONF_RELIABLE_EIGHT
- | UUCONF_RELIABLE_FULLDUPLEX);
- break;
- case UUCONF_PORTTYPE_TLI:
- qport->uuconf_u.uuconf_stli.uuconf_zdevice = NULL;
- qport->uuconf_u.uuconf_stli.uuconf_fstream = FALSE;
- qport->uuconf_u.uuconf_stli.uuconf_pzpush = NULL;
- qport->uuconf_u.uuconf_stli.uuconf_pzdialer = NULL;
- qport->uuconf_u.uuconf_stli.uuconf_zservaddr = NULL;
- qport->uuconf_ireliable = (UUCONF_RELIABLE_SPECIFIED
- | UUCONF_RELIABLE_ENDTOEND
- | UUCONF_RELIABLE_RELIABLE
- | UUCONF_RELIABLE_EIGHT
- | UUCONF_RELIABLE_FULLDUPLEX);
- break;
- case UUCONF_PORTTYPE_PIPE:
- qport->uuconf_u.uuconf_spipe.uuconf_pzcmd = NULL;
- break;
- }
-
- if (fgottype)
- return UUCONF_CMDTABRET_CONTINUE;
- }
-
- /* See if this command is one of the generic ones. */
- qcmds = asPort_cmds;
- ccmds = CPORT_CMDS;
-
- for (i = 0; i < CPORT_CMDS - 1; i++)
- if (strcasecmp (argv[0], asPort_cmds[i].zcmd) == 0)
- break;
-
- if (i >= CPORT_CMDS - 1)
- {
- /* It's not a generic command, so we must check the type
- specific commands. */
- switch (qport->uuconf_ttype)
- {
- case UUCONF_PORTTYPE_STDIN:
- qcmds = asPstdin_cmds;
- ccmds = CSTDIN_CMDS;
- break;
- case UUCONF_PORTTYPE_MODEM:
- qcmds = asPmodem_cmds;
- ccmds = CMODEM_CMDS;
- break;
- case UUCONF_PORTTYPE_DIRECT:
- qcmds = asPdirect_cmds;
- ccmds = CDIRECT_CMDS;
- break;
- case UUCONF_PORTTYPE_TCP:
- qcmds = asPtcp_cmds;
- ccmds = CTCP_CMDS;
- break;
- case UUCONF_PORTTYPE_TLI:
- qcmds = asPtli_cmds;
- ccmds = CTLI_CMDS;
- break;
- case UUCONF_PORTTYPE_PIPE:
- qcmds = asPpipe_cmds;
- ccmds = CPIPE_CMDS;
- break;
- default:
- return UUCONF_SYNTAX_ERROR;
- }
- }
-
- /* Copy the command table onto the stack and modify it to point to
- qport. */
- _uuconf_ucmdtab_base (qcmds, ccmds, (char *) qport, as);
-
- iret = uuconf_cmd_args ((pointer) qglobal, argc, argv, as,
- (pointer) qport, ipcunknown, 0,
- qport->uuconf_palloc);
-
- return iret &~ UUCONF_CMDTABRET_EXIT;
-}
-
-/* Handle the "protocol-parameter" command. */
-
-static int
-ipproto_param (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_proto_param **pqparam = (struct uuconf_proto_param **) pvar;
- struct uuconf_port *qport = (struct uuconf_port *) pinfo;
-
- return _uuconf_iadd_proto_param (qglobal, argc - 1, argv + 1, pqparam,
- qport->uuconf_palloc);
-}
-
-/* Handle the "baud-range" command. */
-
-/*ARGSUSED*/
-static int
-ipbaud_range (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_modem_port *qmodem = (struct uuconf_modem_port *) pvar;
- int iret;
-
- iret = _uuconf_iint (qglobal, argv[1],
- (pointer) &qmodem->uuconf_ilowbaud, FALSE);
- if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS)
- return iret;
-
- iret |= _uuconf_iint (qglobal, argv[2],
- (pointer) &qmodem->uuconf_ihighbaud, FALSE);
-
- return iret;
-}
-
-/* Handle the "dialer" command. If there is one argument, this names
- a dialer. Otherwise, the remaining arguments form a command
- describing the dialer. */
-
-static int
-ipdialer (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_modem_port *qmodem = (struct uuconf_modem_port *) pvar;
- struct uuconf_port *qport = (struct uuconf_port *) pinfo;
- int iret;
-
- if (argc < 2)
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- if (argc > 2)
- {
- if (qmodem->uuconf_qdialer == NULL)
- {
- struct uuconf_dialer *qnew;
- size_t clen;
-
- qnew = ((struct uuconf_dialer *)
- uuconf_malloc (qport->uuconf_palloc,
- sizeof (struct uuconf_dialer)));
- if (qnew == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- _uuconf_uclear_dialer (qnew);
-
- if (qport->uuconf_zname == NULL)
- qnew->uuconf_zname = (char *) "default port file dialer";
- else
- {
- clen = strlen (qport->uuconf_zname);
- qnew->uuconf_zname =
- (char *) uuconf_malloc (qport->uuconf_palloc,
- clen + sizeof " dialer");
- if (qnew->uuconf_zname == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- memcpy ((pointer) qnew->uuconf_zname,
- (pointer) qport->uuconf_zname, clen);
- memcpy ((pointer) (qnew->uuconf_zname + clen),
- (pointer) " dialer", sizeof " dialer");
- }
-
- qnew->uuconf_palloc = qport->uuconf_palloc;
-
- qmodem->uuconf_qdialer = qnew;
- }
-
- iret = _uuconf_idialer_cmd (qglobal, argc - 1, argv + 1,
- qmodem->uuconf_qdialer);
- if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS)
- iret |= UUCONF_CMDTABRET_EXIT;
- return iret;
- }
- else
- {
- qmodem->uuconf_pzdialer = NULL;
- iret = _uuconf_iadd_string (qglobal, argv[1], TRUE, FALSE,
- &qmodem->uuconf_pzdialer,
- qport->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- iret |= UUCONF_CMDTABRET_EXIT;
- return iret;
- }
-}
-
-/* Give an error for an unknown port command. */
-
-/*ARGSUSED*/
-static int
-ipcunknown (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-}
diff --git a/gnu/libexec/uucp/libuuconf/tsinfo.c b/gnu/libexec/uucp/libuuconf/tsinfo.c
deleted file mode 100644
index 2fe073c..0000000
--- a/gnu/libexec/uucp/libuuconf/tsinfo.c
+++ /dev/null
@@ -1,954 +0,0 @@
-/* tsinfo.c
- Get information about a system from the Taylor UUCP configuration files.
-
- Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tsinfo_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-static void uiset_call P((struct uuconf_system *qsys));
-static int iisizecmp P((long i1, long i2));
-
-/* Local functions needed to parse the system information file. */
-
-#define CMDTABFN(z) \
- static int z P((pointer, int, char **, pointer, pointer))
-
-CMDTABFN (iisystem);
-CMDTABFN (iialias);
-CMDTABFN (iialternate);
-CMDTABFN (iidefault_alternates);
-CMDTABFN (iitime);
-CMDTABFN (iitimegrade);
-CMDTABFN (iisize);
-CMDTABFN (iibaud_range);
-CMDTABFN (iiport);
-CMDTABFN (iichat);
-CMDTABFN (iidebug);
-CMDTABFN (iicalled_login);
-CMDTABFN (iiproto_param);
-CMDTABFN (iirequest);
-CMDTABFN (iitransfer);
-CMDTABFN (iiforward);
-CMDTABFN (iiunknown);
-
-#undef CMDTABFN
-
-/* We have to pass a fair amount of information in and out of the
- various system commands. Using global variables would make the
- code non-reentrant, so we instead pass a pointer to single
- structure as the pinfo argument to the system commands. */
-
-struct sinfo
-{
- /* The system information we're building up. */
- struct uuconf_system *qsys;
- /* Whether any alternates have been used. */
- boolean falternates;
- /* A list of the previous alternates. */
- struct uuconf_system salternate;
- /* Whether to use extra alternates from the file wide defaults. */
- int fdefault_alternates;
-};
-
-/* The command table for system commands. */
-static const struct cmdtab_offset asIcmds[] =
-{
- { "system", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, iisystem },
- { "alias", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, iialias },
- { "alternate", UUCONF_CMDTABTYPE_FN | 0, (size_t) -1, iialternate },
- { "default-alternates", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1,
- iidefault_alternates },
- { "time", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct uuconf_system, uuconf_qtimegrade), iitime },
- { "timegrade", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct uuconf_system, uuconf_qtimegrade), iitimegrade },
- { "max-retries", UUCONF_CMDTABTYPE_INT,
- offsetof (struct uuconf_system, uuconf_cmax_retries), NULL },
- { "success-wait", UUCONF_CMDTABTYPE_INT,
- offsetof (struct uuconf_system, uuconf_csuccess_wait), NULL },
- { "call-timegrade", UUCONF_CMDTABTYPE_FN | 3,
- offsetof (struct uuconf_system, uuconf_qcalltimegrade), iitimegrade },
- { "called-timegrade", UUCONF_CMDTABTYPE_FN | 3,
- offsetof (struct uuconf_system, uuconf_qcalledtimegrade), iitimegrade },
- { "call-local-size", UUCONF_CMDTABTYPE_FN | 3,
- offsetof (struct uuconf_system, uuconf_qcall_local_size), iisize },
- { "call-remote-size", UUCONF_CMDTABTYPE_FN | 3,
- offsetof (struct uuconf_system, uuconf_qcall_remote_size), iisize },
- { "called-local-size", UUCONF_CMDTABTYPE_FN | 3,
- offsetof (struct uuconf_system, uuconf_qcalled_local_size), iisize },
- { "called-remote-size", UUCONF_CMDTABTYPE_FN | 3,
- offsetof (struct uuconf_system, uuconf_qcalled_remote_size), iisize },
- { "timetable", UUCONF_CMDTABTYPE_FN | 3, (size_t) -1, _uuconf_itimetable },
- { "baud", UUCONF_CMDTABTYPE_LONG,
- offsetof (struct uuconf_system, uuconf_ibaud), NULL },
- { "speed", UUCONF_CMDTABTYPE_LONG,
- offsetof (struct uuconf_system, uuconf_ibaud), NULL },
- { "baud-range", UUCONF_CMDTABTYPE_FN | 3, 0, iibaud_range },
- { "speed-range", UUCONF_CMDTABTYPE_FN | 3, 0, iibaud_range },
- { "port", UUCONF_CMDTABTYPE_FN | 0, (size_t) -1, iiport },
- { "phone", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_system, uuconf_zphone), NULL },
- { "address", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_system, uuconf_zphone), NULL },
- { "chat", UUCONF_CMDTABTYPE_PREFIX | 0,
- offsetof (struct uuconf_system, uuconf_schat), iichat },
- { "call-login", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_system, uuconf_zcall_login), NULL },
- { "call-password", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_system, uuconf_zcall_password), NULL },
- { "called-login", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct uuconf_system, uuconf_zcalled_login), iicalled_login },
- { "callback", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_system, uuconf_fcallback), NULL },
- { "sequence", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_system, uuconf_fsequence), NULL },
- { "protocol", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_system, uuconf_zprotocols), NULL },
- { "protocol-parameter", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct uuconf_system, uuconf_qproto_params), iiproto_param },
- { "called-chat", UUCONF_CMDTABTYPE_PREFIX | 0,
- offsetof (struct uuconf_system, uuconf_scalled_chat), iichat },
- { "debug", UUCONF_CMDTABTYPE_FN | 0,
- offsetof (struct uuconf_system, uuconf_zdebug), iidebug },
- { "max-remote-debug", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_system, uuconf_zmax_remote_debug), NULL },
- { "send-request", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_system, uuconf_fsend_request), NULL },
- { "receive-request", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_system, uuconf_frec_request), NULL },
- { "request", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, iirequest },
- { "call-transfer", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_system, uuconf_fcall_transfer), NULL },
- { "called-transfer", UUCONF_CMDTABTYPE_BOOLEAN,
- offsetof (struct uuconf_system, uuconf_fcalled_transfer), NULL },
- { "transfer", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, iitransfer },
- { "local-send", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_system, uuconf_pzlocal_send), NULL },
- { "remote-send", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_system, uuconf_pzremote_send), NULL },
- { "local-receive", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_system, uuconf_pzlocal_receive), NULL },
- { "remote-receive", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_system, uuconf_pzremote_receive), NULL },
- { "command-path", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_system, uuconf_pzpath), NULL },
- { "commands", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_system, uuconf_pzcmds), NULL },
- { "free-space", UUCONF_CMDTABTYPE_LONG,
- offsetof (struct uuconf_system, uuconf_cfree_space), NULL },
- { "forward-from", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_system, uuconf_pzforward_from), NULL },
- { "forward-to", UUCONF_CMDTABTYPE_FULLSTRING,
- offsetof (struct uuconf_system, uuconf_pzforward_to), NULL },
- { "forward", UUCONF_CMDTABTYPE_FN | 0, (size_t) -1, iiforward },
- { "pubdir", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_system, uuconf_zpubdir), NULL },
- { "myname", UUCONF_CMDTABTYPE_STRING,
- offsetof (struct uuconf_system, uuconf_zlocalname), NULL },
- { NULL, 0, 0, NULL }
-};
-
-#define CSYSTEM_CMDS (sizeof asIcmds / sizeof asIcmds[0])
-
-/* Get information about the system zsystem from the Taylor UUCP
- configuration files. Sets *qsys. This does not ensure that all
- default information is set. */
-
-int
-_uuconf_itaylor_system_internal (qglobal, zsystem, qsys)
- struct sglobal *qglobal;
- const char *zsystem;
- struct uuconf_system *qsys;
-{
- int iret;
- struct stsysloc *qloc;
- struct uuconf_cmdtab as[CSYSTEM_CMDS];
- struct sinfo si;
- struct uuconf_system sdefaults;
-
- if (! qglobal->qprocess->fread_syslocs)
- {
- iret = _uuconf_iread_locations (qglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- /* Find the system in the list of locations. */
- for (qloc = qglobal->qprocess->qsyslocs; qloc != NULL; qloc = qloc->qnext)
- if (qloc->zname[0] == zsystem[0]
- && strcmp (qloc->zname, zsystem) == 0)
- break;
- if (qloc == NULL)
- return UUCONF_NOT_FOUND;
-
- /* If this is an alias, then the real system is the next non-alias
- in the list. */
- while (qloc->falias)
- {
- qloc = qloc->qnext;
- if (qloc == NULL)
- return UUCONF_NOT_FOUND;
- }
-
- _uuconf_ucmdtab_base (asIcmds, CSYSTEM_CMDS, (char *) qsys, as);
-
- rewind (qloc->e);
-
- /* Read the file wide defaults from the start of the file. */
- _uuconf_uclear_system (qsys);
-
- si.qsys = qsys;
- si.falternates = FALSE;
- si.fdefault_alternates = TRUE;
- qsys->uuconf_palloc = uuconf_malloc_block ();
- if (qsys->uuconf_palloc == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- iret = uuconf_cmd_file ((pointer) qglobal, qloc->e, as, (pointer) &si,
- iiunknown, UUCONF_CMDTABFLAG_BACKSLASH,
- qsys->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = qloc->zfile;
- return iret | UUCONF_ERROR_FILENAME;
- }
-
- if (! si.falternates)
- uiset_call (qsys);
- else
- {
- /* Attach the final alternate. */
- iret = iialternate ((pointer) qglobal, 0, (char **) NULL,
- (pointer) NULL, (pointer) &si);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- /* Save off the defaults. */
- sdefaults = *qsys;
-
- /* Advance to the information for the system we want. */
- if (fseek (qloc->e, qloc->iloc, SEEK_SET) != 0)
- {
- qglobal->ierrno = errno;
- qglobal->zfilename = qloc->zfile;
- return (UUCONF_FSEEK_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_ERROR_FILENAME);
- }
-
- /* Read in the system we want. */
- _uuconf_uclear_system (qsys);
- qsys->uuconf_zname = (char *) qloc->zname;
- qsys->uuconf_palloc = sdefaults.uuconf_palloc;
-
- si.falternates = FALSE;
-
- iret = uuconf_cmd_file (qglobal, qloc->e, as, (pointer) &si, iiunknown,
- UUCONF_CMDTABFLAG_BACKSLASH, qsys->uuconf_palloc);
- qglobal->ilineno += qloc->ilineno;
-
- if (iret == UUCONF_SUCCESS)
- {
- if (! si.falternates)
- uiset_call (qsys);
- else
- iret = iialternate ((pointer) qglobal, 0, (char **) NULL,
- (pointer) NULL, (pointer) &si);
- }
-
- /* Merge in the defaults. */
- if (iret == UUCONF_SUCCESS)
- iret = _uuconf_isystem_default (qglobal, qsys, &sdefaults,
- si.fdefault_alternates);
-
- /* The first alternate is always available for calling in. It is
- always available for calling out if it has some way to choose a
- port (this would normally be set by uiset_call anyhow, but it
- won't be if all the port information comes from the defaults). */
- if (iret == UUCONF_SUCCESS)
- {
- qsys->uuconf_fcalled = TRUE;
- if (qsys->uuconf_zport != (char *) &_uuconf_unset
- || qsys->uuconf_qport != (struct uuconf_port *) &_uuconf_unset
- || qsys->uuconf_ibaud >= 0
- || qsys->uuconf_zphone != (char *) &_uuconf_unset)
- qsys->uuconf_fcall = TRUE;
- }
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = qloc->zfile;
- iret |= UUCONF_ERROR_FILENAME;
- }
-
- return iret;
-}
-
-/* Set the fcall and fcalled field for the system. This marks a
- particular alternate for use when calling out or calling in. This
- is where we implement the semantics described in the documentation:
- a change to a relevant field implies that the alternate is used.
- If all the relevant fields are unchanged, the alternate is not
- used. */
-
-static void
-uiset_call (qsys)
- struct uuconf_system *qsys;
-{
- qsys->uuconf_fcall =
- (qsys->uuconf_qtimegrade != (struct uuconf_timespan *) &_uuconf_unset
- || qsys->uuconf_zport != (char *) &_uuconf_unset
- || qsys->uuconf_qport != (struct uuconf_port *) &_uuconf_unset
- || qsys->uuconf_ibaud >= 0
- || qsys->uuconf_zphone != (char *) &_uuconf_unset
- || qsys->uuconf_schat.uuconf_pzchat != (char **) &_uuconf_unset
- || qsys->uuconf_schat.uuconf_pzprogram != (char **) &_uuconf_unset);
-
- qsys->uuconf_fcalled =
- qsys->uuconf_zcalled_login != (char *) &_uuconf_unset;
-}
-
-/* Handle the "system" command. Because we skip directly to the
- system we want to read, a "system" command means we've reached the
- end of it. */
-
-static int
-iisystem (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- return UUCONF_CMDTABRET_EXIT;
-}
-
-/* Handle the "alias" command. */
-
-/*ARGSUSED*/
-static int
-iialias (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
- int iret;
-
- iret = _uuconf_iadd_string (qglobal, argv[1], TRUE, FALSE,
- &qinfo->qsys->uuconf_pzalias,
- qinfo->qsys->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- iret |= UUCONF_CMDTABRET_EXIT;
- return iret;
-}
-
-/* Handle the "alternate" command. The information just read is in
- sIhold. If this is the first "alternate" command for this system,
- we save off the current information in sIalternate. Otherwise we
- default this information to sIalternate, and then add it to the end
- of the list of alternates in sIalternate. */
-
-static int
-iialternate (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
-
- uiset_call (qinfo->qsys);
-
- if (! qinfo->falternates)
- {
- qinfo->salternate = *qinfo->qsys;
- qinfo->falternates = TRUE;
- }
- else
- {
- int iret;
- struct uuconf_system *qnew, **pq;
-
- iret = _uuconf_isystem_default (qglobal, qinfo->qsys,
- &qinfo->salternate, FALSE);
- if (iret != UUCONF_SUCCESS)
- return iret | UUCONF_CMDTABRET_EXIT;
- qnew = ((struct uuconf_system *)
- uuconf_malloc (qinfo->qsys->uuconf_palloc,
- sizeof (struct uuconf_system)));
- if (qnew == NULL)
- {
- qglobal->ierrno = errno;;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
- *qnew = *qinfo->qsys;
- for (pq = &qinfo->salternate.uuconf_qalternate;
- *pq != NULL;
- pq = &(*pq)->uuconf_qalternate)
- ;
- *pq = qnew;
- }
-
- /* If this is the last alternate command, move the information back
- to qinfo->qsys. */
- if (argc == 0)
- *qinfo->qsys = qinfo->salternate;
- else
- {
- _uuconf_uclear_system (qinfo->qsys);
- qinfo->qsys->uuconf_zname = qinfo->salternate.uuconf_zname;
- qinfo->qsys->uuconf_palloc = qinfo->salternate.uuconf_palloc;
- if (argc > 1)
- {
- qinfo->qsys->uuconf_zalternate = argv[1];
- return UUCONF_CMDTABRET_KEEP;
- }
- }
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Handle the "default-alternates" command. This just takes a boolean
- argument which is used to set the fdefault_alternates field of the
- sinfo structure. */
-
-/*ARGSUSED*/
-static int
-iidefault_alternates (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
-
- return _uuconf_iboolean (qglobal, argv[1], &qinfo->fdefault_alternates);
-}
-
-/* Handle the "time" command. We do this by turning it into a
- "timegrade" command with a grade of BGRADE_LOW. The first argument
- is a time string, and the optional second argument is the retry
- time. */
-
-/*ARGSUSED*/
-static int
-iitime (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- char *aznew[4];
- char ab[2];
-
- if (argc != 2 && argc != 3)
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- aznew[0] = argv[0];
- ab[0] = UUCONF_GRADE_LOW;
- ab[1] = '\0';
- aznew[1] = ab;
- aznew[2] = argv[1];
- if (argc > 2)
- aznew[3] = argv[2];
-
- return iitimegrade (pglobal, argc + 1, aznew, pvar, pinfo);
-}
-
-/* Handle the "timegrade" command by calling _uuconf_itime_parse with
- appropriate ival (the work grade) and cretry (the retry time)
- arguments. */
-
-static int
-iitimegrade (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_timespan **pqspan = (struct uuconf_timespan **) pvar;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
- int cretry;
- int iret;
-
- if (argc < 3 || argc > 4)
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- if (argv[1][1] != '\0' || ! UUCONF_GRADE_LEGAL (argv[1][0]))
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-
- if (argc == 3)
- cretry = 0;
- else
- {
- iret = _uuconf_iint (qglobal, argv[3], (pointer) &cretry, TRUE);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- iret = _uuconf_itime_parse (qglobal, argv[2], (long) argv[1][0],
- cretry, _uuconf_itime_grade_cmp, pqspan,
- qinfo->qsys->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- iret |= UUCONF_CMDTABRET_EXIT;
- return iret;
-}
-
-/* Handle the "baud-range" command, also known as "speed-range". */
-
-static int
-iibaud_range (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_system *qsys = (struct uuconf_system *) pvar;
- int iret;
-
- iret = _uuconf_iint (qglobal, argv[1], (pointer) &qsys->uuconf_ibaud,
- FALSE);
- if (iret != UUCONF_SUCCESS)
- return iret;
- return _uuconf_iint (qglobal, argv[2], (pointer) &qsys->uuconf_ihighbaud,
- FALSE);
-}
-
-/* Handle one of the size commands ("call-local-size", etc.). The
- first argument is a number of bytes, and the second argument is a
- time string. The pvar argument points to the string array to which
- we add this new string. */
-
-/*ARGSUSED*/
-static int
-iisize (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_timespan **pqspan = (struct uuconf_timespan **) pvar;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
- long ival;
- int iret;
-
- iret = _uuconf_iint (qglobal, argv[1], (pointer) &ival, FALSE);
- if (iret != UUCONF_SUCCESS)
- return iret;
-
- iret = _uuconf_itime_parse (qglobal, argv[2], ival, 0, iisizecmp,
- pqspan, qinfo->qsys->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- iret |= UUCONF_CMDTABRET_EXIT;
- return iret;
-}
-
-/* A comparison function for sizes to pass to _uuconf_itime_parse. */
-
-static int
-iisizecmp (i1, i2)
- long i1;
- long i2;
-{
- /* We can't just return i1 - i2 because that would be a long. */
- if (i1 < i2)
- return -1;
- else if (i1 == i2)
- return 0;
- else
- return 1;
-}
-
-/* Handle the "port" command. If there is one argument, this names a
- port. Otherwise, the remaining arguments form a command describing
- the port. */
-
-/*ARGSUSED*/
-static int
-iiport (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
-
- if (argc < 2)
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
- else if (argc == 2)
- {
- qinfo->qsys->uuconf_zport = argv[1];
- return UUCONF_CMDTABRET_KEEP;
- }
- else
- {
- int iret;
-
- if (qinfo->qsys->uuconf_qport
- == (struct uuconf_port *) &_uuconf_unset)
- {
- struct uuconf_port *qnew;
-
- qnew = ((struct uuconf_port *)
- uuconf_malloc (qinfo->qsys->uuconf_palloc,
- sizeof (struct uuconf_port)));
- if (qnew == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- _uuconf_uclear_port (qnew);
-
- if (qinfo->qsys->uuconf_zname == NULL)
- qnew->uuconf_zname = (char *) "default system file port";
- else
- {
- char *zname;
- size_t clen;
-
- clen = strlen (qinfo->qsys->uuconf_zname);
- zname = (char *) uuconf_malloc (qinfo->qsys->uuconf_palloc,
- clen + sizeof "system port");
- if (zname == NULL)
- {
- qglobal->ierrno = errno;
- return (UUCONF_MALLOC_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_CMDTABRET_EXIT);
- }
-
- memcpy ((pointer) zname, (pointer) "system ",
- sizeof "system " - 1);
- memcpy ((pointer) (zname + sizeof "system " - 1),
- (pointer) qinfo->qsys->uuconf_zname,
- clen);
- memcpy ((pointer) (zname + sizeof "system " - 1 + clen),
- (pointer) " port", sizeof " port");
-
- qnew->uuconf_zname = zname;
- }
-
- qnew->uuconf_palloc = qinfo->qsys->uuconf_palloc;
-
- qinfo->qsys->uuconf_qport = qnew;
- }
-
- iret = _uuconf_iport_cmd (qglobal, argc - 1, argv + 1,
- qinfo->qsys->uuconf_qport);
- if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS)
- iret |= UUCONF_CMDTABRET_EXIT;
- return iret;
- }
-}
-
-/* Handle the "chat" and "called-chat" set of commands. These just
- hand off to the generic chat script function. */
-
-static int
-iichat (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
- struct uuconf_chat *qchat = (struct uuconf_chat *) pvar;
- int iret;
-
- iret = _uuconf_ichat_cmd (qglobal, argc, argv, qchat,
- qinfo->qsys->uuconf_palloc);
- if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS)
- iret |= UUCONF_CMDTABRET_EXIT;
- return iret;
-}
-
-/* Local interface to the _uuconf_idebug_cmd function, which handles
- the "debug" command. */
-
-static int
-iidebug (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
- char **pzdebug = (char **) pvar;
-
- return _uuconf_idebug_cmd (qglobal, pzdebug, argc, argv,
- qinfo->qsys->uuconf_palloc);
-}
-
-/* Handle the "called-login" command. This only needs to be in a
- function because there can be additional arguments listing the
- remote systems which are permitted to use this login name. The
- additional arguments are not actually handled here; they are
- handled by uuconf_taylor_system_names, which already has to go
- through all the system files. */
-
-/*ARGSUSED*/
-static int
-iicalled_login (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- char **pz = (char **) pvar;
-
- if (argc < 2)
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
- *pz = argv[1];
- return UUCONF_CMDTABRET_KEEP;
-}
-
-/* Handle the "protocol-parameter" command. This just hands off to
- the generic protocol parameter handler. */
-
-static int
-iiproto_param (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_proto_param **pqparam = (struct uuconf_proto_param **) pvar;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
-
- if (*pqparam == (struct uuconf_proto_param *) &_uuconf_unset)
- *pqparam = NULL;
- return _uuconf_iadd_proto_param (qglobal, argc - 1, argv + 1, pqparam,
- qinfo->qsys->uuconf_palloc);
-}
-
-/* Handle the "request" command. This is equivalent to specifying
- both "call-request" and "called-request". */
-
-/*ARGSUSED*/
-static int
-iirequest (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
- int iret;
-
- iret = _uuconf_iboolean (qglobal, argv[1],
- &qinfo->qsys->uuconf_fsend_request);
- if (UUCONF_ERROR_VALUE (iret) == UUCONF_SUCCESS)
- qinfo->qsys->uuconf_frec_request = qinfo->qsys->uuconf_fsend_request;
-
- return iret;
-}
-
-/* Handle the "transfer" command. This is equivalent to specifying
- both "call-transfer" and "called-transfer". */
-
-/*ARGSUSED*/
-static int
-iitransfer (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
- int iret;
-
- iret = _uuconf_iboolean (qglobal, argv[1],
- &qinfo->qsys->uuconf_fcall_transfer);
- if (UUCONF_ERROR_VALUE (iret) == UUCONF_SUCCESS)
- qinfo->qsys->uuconf_fcalled_transfer = qinfo->qsys->uuconf_fcall_transfer;
-
- return iret;
-}
-
-/* Handle the "forward" command. This is equivalent to specifying
- both "forward-from" and "forward-to". */
-
-/*ARGSUSED*/
-static int
-iiforward (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct sinfo *qinfo = (struct sinfo *) pinfo;
- struct uuconf_system *qsys;
- int i;
- int iret;
-
- qsys = qinfo->qsys;
- qsys->uuconf_pzforward_from = NULL;
- qsys->uuconf_pzforward_to = NULL;
- for (i = 1; i < argc; i++)
- {
- iret = _uuconf_iadd_string (qglobal, argv[i], FALSE, FALSE,
- &qsys->uuconf_pzforward_to,
- qsys->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret | UUCONF_CMDTABRET_KEEP | UUCONF_CMDTABRET_EXIT;
- iret = _uuconf_iadd_string (qglobal, argv[i], FALSE, FALSE,
- &qsys->uuconf_pzforward_from,
- qsys->uuconf_palloc);
- if (iret != UUCONF_SUCCESS)
- return iret | UUCONF_CMDTABRET_KEEP | UUCONF_CMDTABRET_EXIT;
- }
-
- return UUCONF_CMDTABRET_KEEP;
-}
-
-/* Handle an unknown command. This should probably be done more
- intelligently. */
-
-/*ARGSUSED*/
-static int
-iiunknown (pglobal, argc, argv, pvar, pinfo)
- pointer pglobal;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
-}
-
-/* Return information for an unknown system. It would be better to
- put this in a different file, but it would require breaking several
- functions out of this file. Perhaps I will do it sometime. */
-
-int
-uuconf_taylor_system_unknown (pglobal, qsys)
- pointer pglobal;
- struct uuconf_system *qsys;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct uuconf_cmdtab as[CSYSTEM_CMDS];
- struct sinfo si;
- struct sunknown *q;
- int iret;
-
- if (qglobal->qprocess->qunknown == NULL)
- return UUCONF_NOT_FOUND;
-
- _uuconf_ucmdtab_base (asIcmds, CSYSTEM_CMDS, (char *) qsys, as);
-
- _uuconf_uclear_system (qsys);
-
- si.qsys = qsys;
- si.falternates = FALSE;
- si.fdefault_alternates = TRUE;
- qsys->uuconf_palloc = uuconf_malloc_block ();
- if (qsys->uuconf_palloc == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- for (q = qglobal->qprocess->qunknown; q != NULL; q = q->qnext)
- {
- iret = uuconf_cmd_args (pglobal, q->cargs, q->pzargs, as,
- (pointer) &si, iiunknown,
- UUCONF_CMDTABFLAG_BACKSLASH,
- qsys->uuconf_palloc);
- iret &=~ UUCONF_CMDTABRET_KEEP;
- if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS)
- {
- qglobal->zfilename = qglobal->qprocess->zconfigfile;
- qglobal->ilineno = q->ilineno;
- return ((iret &~ UUCONF_CMDTABRET_EXIT)
- | UUCONF_ERROR_FILENAME
- | UUCONF_ERROR_LINENO);
- }
- if ((iret & UUCONF_CMDTABRET_EXIT) != 0)
- break;
- }
-
- if (! si.falternates)
- uiset_call (qsys);
- else
- {
- iret = iialternate (pglobal, 0, (char **) NULL, (pointer) NULL,
- (pointer) &si);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- /* The first alternate is always available for calling in. */
- qsys->uuconf_fcalled = TRUE;
-
- return _uuconf_isystem_basic_default (qglobal, qsys);
-}
diff --git a/gnu/libexec/uucp/libuuconf/tsnams.c b/gnu/libexec/uucp/libuuconf/tsnams.c
deleted file mode 100644
index 16fb2fd..0000000
--- a/gnu/libexec/uucp/libuuconf/tsnams.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* tsnams.c
- Get all known system names from the Taylor UUCP configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tsnams_rcsid[] = "$Id$";
-#endif
-
-/* Get all the system names from the Taylor UUCP configuration files.
- These were actually already recorded by uuconf_taylor_init, so this
- function is pretty simple. */
-
-int
-uuconf_taylor_system_names (pglobal, ppzsystems, falias)
- pointer pglobal;
- char ***ppzsystems;
- int falias;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
- register struct stsysloc *q;
- char **pz;
- int c, i;
-
- if (! qglobal->qprocess->fread_syslocs)
- {
- iret = _uuconf_iread_locations (qglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- *ppzsystems = NULL;
- c = 0;
-
- for (q = qglobal->qprocess->qsyslocs; q != NULL; q = q->qnext)
- {
- if (! falias && q->falias)
- continue;
-
- iret = _uuconf_iadd_string (qglobal, (char *) q->zname, TRUE, FALSE,
- ppzsystems, (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- return iret;
- ++c;
- }
-
- /* The order of the qSyslocs list is reversed from the list in the
- configuration files. Reverse the returned list in order to make
- uuname output more intuitive. */
- pz = *ppzsystems;
- for (i = c / 2 - 1; i >= 0; i--)
- {
- char *zhold;
-
- zhold = pz[i];
- pz[i] = pz[c - i - 1];
- pz[c - i - 1] = zhold;
- }
-
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/tsys.c b/gnu/libexec/uucp/libuuconf/tsys.c
deleted file mode 100644
index 04c80ac..0000000
--- a/gnu/libexec/uucp/libuuconf/tsys.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* tsys.c
- User function to get a system from the Taylor UUCP configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tsys_rcsid[] = "$Id$";
-#endif
-
-/* Get system information from the Taylor UUCP configuration files.
- This is a wrapper for the internal function which makes sure that
- every field gets a default value. */
-
-int
-uuconf_taylor_system_info (pglobal, zsystem, qsys)
- pointer pglobal;
- const char *zsystem;
- struct uuconf_system *qsys;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
-
- iret = _uuconf_itaylor_system_internal (qglobal, zsystem, qsys);
- if (iret != UUCONF_SUCCESS)
- return iret;
- return _uuconf_isystem_basic_default (qglobal, qsys);
-}
diff --git a/gnu/libexec/uucp/libuuconf/tval.c b/gnu/libexec/uucp/libuuconf/tval.c
deleted file mode 100644
index 0b743d7..0000000
--- a/gnu/libexec/uucp/libuuconf/tval.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* tval.c
- Validate a login name for a system using Taylor UUCP files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_tval_rcsid[] = "$Id$";
-#endif
-
-/* Validate a login name for a system using Taylor UUCP configuration
- files. This assumes that the zcalled_login field is either NULL or
- "ANY". If makes sure that the login name does not appear in some
- other "called-login" command listing systems not including this
- one. */
-
-int
-uuconf_taylor_validate (pglobal, qsys, zlogin)
- pointer pglobal;
- const struct uuconf_system *qsys;
- const char *zlogin;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- struct svalidate *q;
-
- if (! qglobal->qprocess->fread_syslocs)
- {
- int iret;
-
- iret = _uuconf_iread_locations (qglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- for (q = qglobal->qprocess->qvalidate; q != NULL; q = q->qnext)
- {
- if (strcmp (q->zlogname, zlogin) == 0)
- {
- char **pz;
-
- for (pz = q->pzmachines; *pz != NULL; pz++)
- if (strcmp (*pz, qsys->uuconf_zname) == 0)
- return UUCONF_SUCCESS;
-
- return UUCONF_NOT_FOUND;
- }
- }
-
- return UUCONF_SUCCESS;
-}
diff --git a/gnu/libexec/uucp/libuuconf/ugtlin.c b/gnu/libexec/uucp/libuuconf/ugtlin.c
deleted file mode 100644
index 5085029..0000000
--- a/gnu/libexec/uucp/libuuconf/ugtlin.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ugtlin.c
- Read a line with backslash continuations.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_ugtlin_rcsid[] = "$Id$";
-#endif
-
-/* Read a line from a file with backslash continuations. This updates
- the qglobal->ilineno count for each additional line it reads. */
-
-int
-_uuconf_getline (qglobal, pzline, pcline, e)
- struct sglobal *qglobal;
- char **pzline;
- size_t *pcline;
- FILE *e;
-{
- int ctot;
- char *zline;
- size_t cline;
-
- ctot = -1;
-
- zline = NULL;
- cline = 0;
-
- while (TRUE)
- {
- int cchars;
-
- if (ctot < 0)
- cchars = getline (pzline, pcline, e);
- else
- cchars = getline (&zline, &cline, e);
- if (cchars < 0)
- {
- if (zline != NULL)
- free ((pointer) zline);
- if (ctot >= 0)
- return ctot;
- else
- return cchars;
- }
-
- if (ctot < 0)
- ctot = cchars;
- else
- {
- if (*pcline <= ctot + cchars)
- {
- char *znew;
-
- if (*pcline > 0)
- znew = (char *) realloc ((pointer) *pzline,
- (size_t) (ctot + cchars + 1));
- else
- znew = (char *) malloc ((size_t) (ctot + cchars + 1));
- if (znew == NULL)
- {
- free ((pointer) zline);
- return -1;
- }
- *pzline = znew;
- *pcline = ctot + cchars + 1;
- }
-
- memcpy ((pointer) ((*pzline) + ctot), (pointer) zline,
- (size_t) (cchars + 1));
- ctot += cchars;
- }
-
- if (ctot < 2
- || (*pzline)[ctot - 1] != '\n'
- || (*pzline)[ctot - 2] != '\\')
- {
- if (zline != NULL)
- free ((pointer) zline);
- return ctot;
- }
-
- ++qglobal->ilineno;
-
- ctot -= 2;
- (*pzline)[ctot] = '\0';
- }
-}
diff --git a/gnu/libexec/uucp/libuuconf/unk.c b/gnu/libexec/uucp/libuuconf/unk.c
deleted file mode 100644
index 3a9e294..0000000
--- a/gnu/libexec/uucp/libuuconf/unk.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* unk.c
- Get information about an unknown system.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_unk_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Get information about an unknown system. If we are using
- HAVE_TAYLOR_CONFIG, we just use it. Otherwise if we are using
- HAVE_HDB_CONFIG, we use it. Otherwise we return a default system.
- This isn't right for HAVE_V2_CONFIG, because it is possible to
- specify default directories to read and write in USERFILE.
- However, I'm not going to bother to write that code unless somebody
- actually wants it. */
-
-/*ARGSUSED*/
-int
-uuconf_system_unknown (pglobal, qsys)
- pointer pglobal;
- struct uuconf_system *qsys;
-{
-#if HAVE_TAYLOR_CONFIG
- return uuconf_taylor_system_unknown (pglobal, qsys);
-#else /* ! HAVE_TAYLOR_CONFIG */
-#if HAVE_HDB_CONFIG
- return uuconf_hdb_system_unknown (pglobal, qsys);
-#else /* ! HAVE_HDB_CONFIG */
-#if HAVE_V2_CONFIG
- struct sglobal *qglobal = (struct sglobal *) pglobal;
-
- _uuconf_uclear_system (qsys);
- qsys->uuconf_palloc = uuconf_malloc_block ();
- if (qsys->uuconf_palloc == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- return _uuconf_isystem_basic_default (qglobal, qsys);
-#else /* ! HAVE_V2_CONFIG */
- return UUCONF_NOT_FOUND;
-#endif /* ! HAVE_V2_CONFIG */
-#endif /* ! HAVE_HDB_CONFIG */
-#endif /* ! HAVE_TAYLOR_CONFIG */
-}
diff --git a/gnu/libexec/uucp/libuuconf/uucnfi.h b/gnu/libexec/uucp/libuuconf/uucnfi.h
deleted file mode 100644
index 1f42391..0000000
--- a/gnu/libexec/uucp/libuuconf/uucnfi.h
+++ /dev/null
@@ -1,380 +0,0 @@
-/* uucnfi.h
- Internal header file for the uuconf package.
-
- Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-/* This is the internal header file for the uuconf package. It should
- not be included by anything other than the uuconf code itself. */
-
-/* Get all the general definitions. */
-#include "uucp.h"
-
-/* Get the uuconf header file itself. */
-#include "uuconf.h"
-
-/* We need the system dependent header file. */
-#include "syshdr.h"
-
-/* This is the generic information structure. This holds all the
- per-thread global information needed by the uuconf code. The
- per-process global information is held in an sprocess structure,
- which this structure points to. This permits the code to not have
- any global variables at all. */
-
-struct sglobal
-{
- /* A pointer to the per-process global information. */
- struct sprocess *qprocess;
- /* A memory block in which all the memory for these fields is
- allocated. */
- pointer pblock;
- /* The value of errno after an error. */
- int ierrno;
- /* The filename for which an error occurred. */
- const char *zfilename;
- /* The line number at which an error occurred. */
- int ilineno;
-};
-
-/* This is the per-process information structure. This essentially
- holds all the global variables used by uuconf. */
-
-struct sprocess
-{
- /* The name of the local machine. This will be NULL if it is not
- specified in a configuration file. */
- const char *zlocalname;
- /* The spool directory. */
- const char *zspooldir;
- /* The default public directory. */
- const char *zpubdir;
- /* The lock directory. */
- const char *zlockdir;
- /* The log file. */
- const char *zlogfile;
- /* The statistics file. */
- const char *zstatsfile;
- /* The debugging file. */
- const char *zdebugfile;
- /* The default debugging level. */
- const char *zdebug;
- /* Whether login information should be stripped. */
- boolean fstrip_login;
- /* Whether protocol information should be stripped. */
- boolean fstrip_proto;
- /* The maximum number of simultaneously executing uuxqts. */
- int cmaxuuxqts;
- /* How often to spawn a uuxqt process. */
- const char *zrunuuxqt;
- /* Whether we are reading the V2 configuration files. */
- boolean fv2;
- /* Whether we are reading the HDB configuration files. */
- boolean fhdb;
- /* The names of the dialcode files. */
- char **pzdialcodefiles;
- /* Timetables. These are in pairs. The first element is the name,
- the second is the time string. */
- char **pztimetables;
-
- /* Taylor UUCP config file name. */
- char *zconfigfile;
- /* Taylor UUCP sys file names. */
- char **pzsysfiles;
- /* Taylor UUCP port file names. */
- char **pzportfiles;
- /* Taylor UUCP dial file names. */
- char **pzdialfiles;
- /* Taylor UUCP passwd file names. */
- char **pzpwdfiles;
- /* Taylor UUCP call file names. */
- char **pzcallfiles;
- /* List of "unknown" commands from config file. */
- struct sunknown *qunknown;
- /* Whether the Taylor UUCP system information locations have been
- read. */
- boolean fread_syslocs;
- /* Taylor UUCP system information locations. */
- struct stsysloc *qsyslocs;
- /* Taylor UUCP validation restrictions. */
- struct svalidate *qvalidate;
- /* Whether the "myname" command is used in a Taylor UUCP file. */
- boolean fuses_myname;
-
- /* V2 system file name (L.sys). */
- char *zv2systems;
- /* V2 device file name (L-devices). */
- char *zv2devices;
- /* V2 user permissions file name (USERFILE). */
- char *zv2userfile;
- /* V2 user permitted commands file (L.cmds). */
- char *zv2cmds;
-
- /* HDB system file names (Systems). */
- char **pzhdb_systems;
- /* HDB device file names (Devices). */
- char **pzhdb_devices;
- /* HDB dialer file names (Dialers). */
- char **pzhdb_dialers;
- /* Whether the HDB Permissions file has been read. */
- boolean fhdb_read_permissions;
- /* The HDB Permissions file entries. */
- struct shpermissions *qhdb_permissions;
-};
-
-/* This structure is used to hold the "unknown" commands from the
- Taylor UUCP config file before they have been parsed. */
-
-struct sunknown
-{
- /* Next element in linked list. */
- struct sunknown *qnext;
- /* Line number in config file. */
- int ilineno;
- /* Number of arguments. */
- int cargs;
- /* Arguments. */
- char **pzargs;
-};
-
-/* This structure is used to hold the locations of systems within the
- Taylor UUCP sys files. */
-
-struct stsysloc
-{
- /* Next element in linked list. */
- struct stsysloc *qnext;
- /* System name. */
- const char *zname;
- /* Whether system is an alias or a real system. If this is an
- alias, the real system is the next entry in the linked list which
- is not an alias. */
- boolean falias;
- /* File name (one of the sys files). */
- const char *zfile;
- /* Open file. */
- FILE *e;
- /* Location within file (from ftell). */
- long iloc;
- /* Line number within file. */
- int ilineno;
-};
-
-/* This structure is used to hold validation restrictions. This is a
- list of machines which are permitted to use a particular login
- name. If a machine logs in, and there is no called login entry for
- it, the login name and machine name must be passed to
- uuconf_validate to confirm that either there is no entry for this
- login name or that the machine name appears on the entry. */
-
-struct svalidate
-{
- /* Next element in linked list. */
- struct svalidate *qnext;
- /* Login name. */
- const char *zlogname;
- /* NULL terminated list of machine names. */
- char **pzmachines;
-};
-
-/* This structure is used to hold a linked list of HDB Permissions
- file entries. */
-
-struct shpermissions
-{
- /* Next entry in linked list. */
- struct shpermissions *qnext;
- /* NULL terminated array of LOGNAME values. */
- char **pzlogname;
- /* NULL terminated array of MACHINE values. */
- char **pzmachine;
- /* Boolean REQUEST value. */
- int frequest;
- /* Boolean SENDFILES value ("call" is taken as "no"). */
- int fsendfiles;
- /* NULL terminated array of READ values. */
- char **pzread;
- /* NULL terminated array of WRITE values. */
- char **pzwrite;
- /* Boolean CALLBACK value. */
- int fcallback;
- /* NULL terminated array of COMMANDS values. */
- char **pzcommands;
- /* NULL terminated array of VALIDATE values. */
- char **pzvalidate;
- /* String MYNAME value. */
- char *zmyname;
- /* String PUBDIR value. */
- const char *zpubdir;
- /* NULL terminated array of ALIAS values. */
- char **pzalias;
-};
-
-/* This structure is used to build reentrant uuconf_cmdtab tables.
- The ioff field is either (size_t) -1 or an offsetof macro. The
- table is then copied into a uuconf_cmdtab, except that offsets of
- (size_t) -1 are converted to pvar elements of NULL, and other
- offsets are converted to an offset off some base address. */
-
-struct cmdtab_offset
-{
- const char *zcmd;
- int itype;
- size_t ioff;
- uuconf_cmdtabfn pifn;
-};
-
-/* A value in a uuconf_system structure which holds the address of
- this special variable is known to be uninitialized. */
-extern char *_uuconf_unset;
-
-/* Internal function to read a system from the Taylor UUCP
- configuration files. This does not apply the basic defaults. */
-extern int _uuconf_itaylor_system_internal P((struct sglobal *qglobal,
- const char *zsystem,
- struct uuconf_system *qsys));
-
-/* Read the system locations and validation information from the
- Taylor UUCP configuration files. This sets the qsyslocs,
- qvalidate, and fread_syslocs elements of the global structure. */
-extern int _uuconf_iread_locations P((struct sglobal *qglobal));
-
-/* Process a command for a port from a Taylor UUCP file. */
-extern int _uuconf_iport_cmd P((struct sglobal *qglobal, int argc,
- char **argv, struct uuconf_port *qport));
-
-/* Process a command for a dialer from a Taylor UUCP file. */
-extern int _uuconf_idialer_cmd P((struct sglobal *qglobal, int argc,
- char **argv,
- struct uuconf_dialer *qdialer));
-
-/* Process a command for a chat script from a Taylor UUCP file; this
- is also called for HDB or V2 files, with a made up command. */
-extern int _uuconf_ichat_cmd P((struct sglobal *qglobal, int argc,
- char **argv, struct uuconf_chat *qchat,
- pointer pblock));
-
-/* Process a protocol-parameter command from a Taylor UUCP file. */
-extern int _uuconf_iadd_proto_param P((struct sglobal *qglobal,
- int argc, char **argv,
- struct uuconf_proto_param **pq,
- pointer pblock));
-
-/* Handle a "seven-bit", "reliable", or "half-duplex" command from a
- Taylor UUCP port or dialer file. The pvar field should point to
- the ireliable element of the structure. */
-extern int _uuconf_iseven_bit P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-extern int _uuconf_ireliable P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-extern int _uuconf_ihalf_duplex P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-
-/* Internal function to read a system from the V2 configuration files.
- This does not apply the basic defaults. */
-extern int _uuconf_iv2_system_internal P((struct sglobal *qglobal,
- const char *zsystem,
- struct uuconf_system *qsys));
-
-/* Internal function to read a system from the HDB configuration
- files. This does not apply the basic defaults. */
-extern int _uuconf_ihdb_system_internal P((struct sglobal *qglobal,
- const char *zsystem,
- struct uuconf_system *qsys));
-
-/* Read the HDB Permissions file. */
-extern int _uuconf_ihread_permissions P((struct sglobal *qglobal));
-
-/* Initialize the global information structure. */
-extern int _uuconf_iinit_global P((struct sglobal **pqglobal));
-
-/* Clear system information. */
-extern void _uuconf_uclear_system P((struct uuconf_system *qsys));
-
-/* Default unset aspects of one system to the contents of another. */
-extern int _uuconf_isystem_default P((struct sglobal *qglobal,
- struct uuconf_system *q,
- struct uuconf_system *qdefault,
- boolean faddalternates));
-
-/* Put in the basic system defaults. */
-extern int _uuconf_isystem_basic_default P((struct sglobal *qglobal,
- struct uuconf_system *qsys));
-
-/* Clear port information. */
-extern void _uuconf_uclear_port P((struct uuconf_port *qport));
-
-/* Clear dialer information. */
-extern void _uuconf_uclear_dialer P((struct uuconf_dialer *qdialer));
-
-/* Add a timetable. */
-extern int _uuconf_itimetable P((pointer pglobal, int argc, char **argv,
- pointer pvar, pointer pinfo));
-
-/* Parse a time string. */
-extern int _uuconf_itime_parse P((struct sglobal *qglobal, char *ztime,
- long ival, int cretry,
- int (*picmp) P((long, long)),
- struct uuconf_timespan **pqspan,
- pointer pblock));
-
-/* A grade comparison function to pass to _uuconf_itime_parse. */
-extern int _uuconf_itime_grade_cmp P((long, long));
-
-/* Parse a debugging string. */
-
-extern int _uuconf_idebug_cmd P((struct sglobal *qglobal,
- char **pzdebug, int argc,
- char **argv, pointer pblock));
-
-/* Add a string to a NULL terminated list of strings. */
-extern int _uuconf_iadd_string P((struct sglobal *qglobal,
- char *zadd, boolean fcopy,
- boolean fdupcheck, char ***ppzstrings,
- pointer pblock));
-
-/* Parse a string into a boolean value. */
-extern int _uuconf_iboolean P((struct sglobal *qglobal, const char *zval,
- int *pi));
-
-/* Parse a string into an integer value. The argument p is either an
- int * or a long *, according to the argument fint. */
-extern int _uuconf_iint P((struct sglobal *qglobal, const char *zval,
- pointer p, boolean fint));
-
-/* Turn a cmdtab_offset table into a uuconf_cmdtab table. */
-extern void _uuconf_ucmdtab_base P((const struct cmdtab_offset *qoff,
- size_t celes, char *pbase,
- struct uuconf_cmdtab *qset));
-
-/* Merge two memory blocks into one. This cannot fail. */
-extern pointer _uuconf_pmalloc_block_merge P((pointer, pointer));
-
-/* A wrapper for getline that continues lines if they end in a
- backslash. It needs qglobal so that it can increment ilineno
- correctly. */
-extern int _uuconf_getline P((struct sglobal *qglobal,
- char **, size_t *, FILE *));
-
-/* Split a string into tokens. */
-extern int _uuconf_istrsplit P((char *zline, int bsep,
- char ***ppzsplit, size_t *csplit));
diff --git a/gnu/libexec/uucp/libuuconf/val.c b/gnu/libexec/uucp/libuuconf/val.c
deleted file mode 100644
index de5b76d..0000000
--- a/gnu/libexec/uucp/libuuconf/val.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* val.c
- Validate a login name for a system.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_val_rcsid[] = "$Id$";
-#endif
-
-/* Validate a login name for a system. */
-
-/*ARGSUSED*/
-int
-uuconf_validate (pglobal, qsys, zlogin)
- pointer pglobal;
- const struct uuconf_system *qsys;
- const char *zlogin;
-{
-#if HAVE_TAYLOR_CONFIG
- return uuconf_taylor_validate (pglobal, qsys, zlogin);
-#else
- return UUCONF_SUCCESS;
-#endif
-}
diff --git a/gnu/libexec/uucp/libuuconf/vinit.c b/gnu/libexec/uucp/libuuconf/vinit.c
deleted file mode 100644
index d671b21..0000000
--- a/gnu/libexec/uucp/libuuconf/vinit.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* vinit.c
- Initialize for reading V2 configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_vinit_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-static int ivinlib P((struct sglobal *qglobal, const char *z, size_t csize,
- char **pz));
-
-/* Return an allocated buffer holding a file name in OLDCONFIGLIB.
- The c argument is the size of z including the trailing null byte,
- since this is convenient for both the caller and this function. */
-
-static int
-ivinlib (qglobal, z, c, pz)
- struct sglobal *qglobal;
- const char *z;
- size_t c;
- char **pz;
-{
- char *zalc;
-
- zalc = uuconf_malloc (qglobal->pblock, sizeof OLDCONFIGLIB - 1 + c);
- if (zalc == NULL)
- {
- qglobal->ierrno = errno;
- return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- memcpy ((pointer) zalc, (pointer) OLDCONFIGLIB,
- sizeof OLDCONFIGLIB - 1);
- memcpy ((pointer) (zalc + sizeof OLDCONFIGLIB - 1), (pointer) z, c);
-
- *pz = zalc;
-
- return UUCONF_SUCCESS;
-}
-
-/* Initialize the routines which read V2 configuration files. The
- only thing we do here is allocate the file names. */
-
-int
-uuconf_v2_init (ppglobal)
- pointer *ppglobal;
-{
- struct sglobal **pqglobal = (struct sglobal **) ppglobal;
- int iret;
- struct sglobal *qglobal;
- char *zdialcodes;
-
- if (*pqglobal == NULL)
- {
- iret = _uuconf_iinit_global (pqglobal);
- if (iret != UUCONF_SUCCESS)
- return iret;
- }
-
- qglobal = *pqglobal;
-
- iret = ivinlib (qglobal, V2_SYSTEMS, sizeof V2_SYSTEMS,
- &qglobal->qprocess->zv2systems);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = ivinlib (qglobal, V2_DEVICES, sizeof V2_DEVICES,
- &qglobal->qprocess->zv2devices);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = ivinlib (qglobal, V2_USERFILE, sizeof V2_USERFILE,
- &qglobal->qprocess->zv2userfile);
- if (iret != UUCONF_SUCCESS)
- return iret;
- iret = ivinlib (qglobal, V2_CMDS, sizeof V2_CMDS,
- &qglobal->qprocess->zv2cmds);
- if (iret != UUCONF_SUCCESS)
- return iret;
-
- iret = ivinlib (qglobal, V2_DIALCODES, sizeof V2_DIALCODES,
- &zdialcodes);
- if (iret != UUCONF_SUCCESS)
- return iret;
-
- return _uuconf_iadd_string (qglobal, zdialcodes, FALSE, FALSE,
- &qglobal->qprocess->pzdialcodefiles,
- qglobal->pblock);
-}
diff --git a/gnu/libexec/uucp/libuuconf/vport.c b/gnu/libexec/uucp/libuuconf/vport.c
deleted file mode 100644
index c2d9791..0000000
--- a/gnu/libexec/uucp/libuuconf/vport.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/* vport.c
- Find a port in the V2 configuration files.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_vport_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-/* Find a port in the V2 configuration files by name, baud rate, and
- special purpose function. */
-
-int
-uuconf_v2_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport)
- pointer pglobal;
- const char *zname;
- long ibaud;
- long ihighbaud;
- int (*pifn) P((struct uuconf_port *, pointer));
- pointer pinfo;
- struct uuconf_port *qport;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- FILE *e;
- char *zline;
- size_t cline;
- char **pzsplit;
- size_t csplit;
- int iret;
- int cchars;
-
- e = fopen (qglobal->qprocess->zv2devices, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- return UUCONF_NOT_FOUND;
- qglobal->ierrno = errno;
- qglobal->zfilename = qglobal->qprocess->zv2devices;
- return (UUCONF_FOPEN_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_ERROR_FILENAME);
- }
-
- zline = NULL;
- cline = 0;
- pzsplit = NULL;
- csplit = 0;
-
- iret = UUCONF_NOT_FOUND;
-
- qglobal->ilineno = 0;
-
- while ((cchars = getline (&zline, &cline, e)) > 0)
- {
- int ctoks;
- char *zend;
- long ilow, ihigh;
- pointer pblock;
-
- ++qglobal->ilineno;
-
- iret = UUCONF_NOT_FOUND;
-
- --cchars;
- if (zline[cchars] == '\n')
- zline[cchars] = '\0';
- zline[strcspn (zline, "#")] = '\0';
-
- ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit);
- if (ctoks < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- /* An entry in L-devices is
-
- type device dial-device baud dialer
-
- The type (normally "ACU") is treated as the name. */
-
- /* If there aren't enough entries, ignore the line; this
- should probably do something more useful. */
- if (ctoks < 4)
- continue;
-
- /* Make sure the name matches any argument. */
- if (zname != NULL
- && strcmp (pzsplit[0], zname) != 0)
- continue;
-
- /* Get the baud rate. */
- ilow = strtol (pzsplit[3], &zend, 10);
- if (*zend == '-')
- ihigh = strtol (zend + 1, (char **) NULL, 10);
- else
- ihigh = ilow;
-
- /* Make sure the baud rate matches any argument. */
- if (ibaud != 0
- && ilow != 0
- && (ilow > ibaud || ihigh < ibaud))
- continue;
-
- /* Now we must construct the port information, so that we can
- pass it to pifn. The port type is determined by it's name,
- unfortunately. The name "DIR" is used for a direct port, and
- anything else for a modem port. */
- pblock = NULL;
- _uuconf_uclear_port (qport);
- qport->uuconf_zname = pzsplit[0];
- if (strcmp (pzsplit[0], "DIR") == 0)
- {
- qport->uuconf_ttype = UUCONF_PORTTYPE_DIRECT;
- qport->uuconf_u.uuconf_sdirect.uuconf_zdevice = pzsplit[1];
- qport->uuconf_u.uuconf_sdirect.uuconf_ibaud = ilow;
- qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier = FALSE;
- qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow = TRUE;
- }
- else
- {
- qport->uuconf_ttype = UUCONF_PORTTYPE_MODEM;
- qport->uuconf_u.uuconf_smodem.uuconf_zdevice = pzsplit[1];
- if (strcmp (pzsplit[2], "-") != 0)
- qport->uuconf_u.uuconf_smodem.uuconf_zdial_device = pzsplit[2];
- else
- qport->uuconf_u.uuconf_smodem.uuconf_zdial_device = NULL;
- if (ilow == ihigh)
- {
- qport->uuconf_u.uuconf_smodem.uuconf_ibaud = ilow;
- qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = 0L;
- qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = 0L;
- }
- else
- {
- qport->uuconf_u.uuconf_smodem.uuconf_ibaud = 0L;
- qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = ilow;
- qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = ihigh;
- }
- qport->uuconf_u.uuconf_smodem.uuconf_fcarrier = TRUE;
- qport->uuconf_u.uuconf_smodem.uuconf_fhardflow = TRUE;
- if (ctoks < 5)
- qport->uuconf_u.uuconf_smodem.uuconf_pzdialer = NULL;
- else
- {
- size_t c;
- char **pzd;
-
- /* We support dialer/token pairs, although normal V2
- doesn't. */
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- c = (ctoks - 4) * sizeof (char *);
- pzd = (char **) uuconf_malloc (pblock, c + sizeof (char *));
- if (pzd == NULL)
- {
- qglobal->ierrno = errno;
- uuconf_free_block (pblock);
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- memcpy ((pointer) pzd, (pointer) (pzsplit + 4), c);
- pzd[ctoks - 4] = NULL;
-
- qport->uuconf_u.uuconf_smodem.uuconf_pzdialer = pzd;
- }
- qport->uuconf_u.uuconf_smodem.uuconf_qdialer = NULL;
- }
-
- if (pifn != NULL)
- {
- iret = (*pifn) (qport, pinfo);
- if (iret != UUCONF_SUCCESS)
- {
- if (pblock != NULL)
- uuconf_free_block (pblock);
- if (iret != UUCONF_NOT_FOUND)
- break;
- continue;
- }
- }
-
- /* This is the port we want. */
- if (pblock == NULL)
- {
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- }
-
- if (uuconf_add_block (pblock, zline) != 0)
- {
- qglobal->ierrno = errno;
- uuconf_free_block (pblock);
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- zline = NULL;
-
- qport->uuconf_palloc = pblock;
-
- break;
- }
-
- (void) fclose (e);
-
- if (zline != NULL)
- free ((pointer) zline);
- if (pzsplit != NULL)
- free ((pointer) pzsplit);
-
- if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND)
- {
- qglobal->zfilename = qglobal->qprocess->zv2devices;
- iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- }
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/vsinfo.c b/gnu/libexec/uucp/libuuconf/vsinfo.c
deleted file mode 100644
index 85bdcad..0000000
--- a/gnu/libexec/uucp/libuuconf/vsinfo.c
+++ /dev/null
@@ -1,610 +0,0 @@
-/* vsinfo.c
- Get information about a system from the V2 configuration files.
-
- Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_vsinfo_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-/* Get the information for a particular system from the V2
- configuration files. This does not make sure that all the default
- values are set. */
-
-int
-_uuconf_iv2_system_internal (qglobal, zsystem, qsys)
- struct sglobal *qglobal;
- const char *zsystem;
- struct uuconf_system *qsys;
-{
- char *zline;
- size_t cline;
- char **pzsplit;
- size_t csplit;
- char **pzcomma;
- size_t ccomma;
- FILE *e;
- int cchars;
- pointer pblock;
- int iret;
-
- e = fopen (qglobal->qprocess->zv2systems, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- return UUCONF_NOT_FOUND;
- qglobal->ierrno = errno;
- qglobal->zfilename = qglobal->qprocess->zv2systems;
- return (UUCONF_FOPEN_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_ERROR_FILENAME);
- }
-
- zline = NULL;
- cline = 0;
- pzsplit = NULL;
- csplit = 0;
- pzcomma = NULL;
- ccomma = 0;
-
- pblock = NULL;
- iret = UUCONF_SUCCESS;
-
- qglobal->ilineno = 0;
-
- while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0)
- {
- int ctoks, ctimes, i;
- struct uuconf_system *qset;
- char *z, *zretry;
- int cretry;
-
- ++qglobal->ilineno;
-
- --cchars;
- if (zline[cchars] == '\n')
- zline[cchars] = '\0';
- zline[strcspn (zline, "#")] = '\0';
-
- ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit);
- if (ctoks < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- /* If this isn't the system we're looking for, keep reading
- the file. */
- if (ctoks < 1
- || strcmp (zsystem, pzsplit[0]) != 0)
- continue;
-
- /* If this is the first time we've found the system, we want
- to set *qsys directly. Otherwise, we allocate a new
- alternate. */
- if (pblock == NULL)
- {
- pblock = uuconf_malloc_block ();
- if (pblock == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- _uuconf_uclear_system (qsys);
- qsys->uuconf_palloc = pblock;
- qset = qsys;
- }
- else
- {
- struct uuconf_system **pq;
-
- qset = ((struct uuconf_system *)
- uuconf_malloc (pblock, sizeof (struct uuconf_system)));
- if (qset == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- _uuconf_uclear_system (qset);
- for (pq = &qsys->uuconf_qalternate;
- *pq != NULL;
- pq = &(*pq)->uuconf_qalternate)
- ;
- *pq = qset;
- }
-
- /* Add this line to the memory block we are building for the
- system. */
- if (uuconf_add_block (pblock, zline) != 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- zline = NULL;
- cline = 0;
-
- /* The format of a line in Systems is
- system time device speed phone chat
- For example,
- airs Any ACU 9600 5551212 ogin: foo pass: bar
- */
-
- /* Get the system name. */
-
- qset->uuconf_zname = pzsplit[0];
- qset->uuconf_fcall = TRUE;
- qset->uuconf_fcalled = TRUE;
-
- if (ctoks < 2)
- continue;
-
- /* A time string is "time/grade,time/grade;retry". A missing
- grade is taken as BGRADE_LOW. On some versions the retry
- time is actually separated by a comma, which won't work right
- here. */
- zretry = strchr (pzsplit[1], ';');
- if (zretry == NULL)
- cretry = 55;
- else
- {
- *zretry = '\0';
- cretry = (int) strtol (zretry + 1, (char **) NULL, 10);
- }
-
- ctimes = _uuconf_istrsplit (pzsplit[1], ',', &pzcomma, &ccomma);
- if (ctimes < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- for (i = 0; i < ctimes; i++)
- {
- char *zslash;
- char bgrade;
-
- z = pzcomma[i];
- zslash = strchr (z, '/');
- if (zslash == NULL)
- bgrade = UUCONF_GRADE_LOW;
- else
- {
- *zslash = '\0';
- bgrade = zslash[1];
- if (! UUCONF_GRADE_LEGAL (bgrade))
- bgrade = UUCONF_GRADE_LOW;
- }
-
- iret = _uuconf_itime_parse (qglobal, z, (long) bgrade, cretry,
- _uuconf_itime_grade_cmp,
- &qset->uuconf_qtimegrade,
- pblock);
-
- /* We treat a syntax error in the time field as equivalent
- to ``never'', on the assumption that that is what V2
- does. */
- if (iret == UUCONF_SYNTAX_ERROR)
- iret = UUCONF_SUCCESS;
-
- if (iret != UUCONF_SUCCESS)
- break;
-
- /* Treat any time/grade setting as both a timegrade and a
- call-timegrade. */
- if (bgrade != UUCONF_GRADE_LOW)
- qset->uuconf_qcalltimegrade = qset->uuconf_qtimegrade;
- }
-
- if (iret != UUCONF_SUCCESS)
- break;
-
- if (ctoks < 3)
- continue;
-
- /* Pick up the device name. It can be followed by a comma and a
- list of protocols (this is not actually supported by most V2
- systems, but it should be compatible). */
- qset->uuconf_zport = pzsplit[2];
- z = strchr (pzsplit[2], ',');
- if (z != NULL)
- {
- qset->uuconf_zprotocols = z + 1;
- *z = '\0';
- }
-
- /* If the port is "TCP", we set up a system specific port. The
- baud rate becomes the service number and the phone number
- becomes the address (still stored in qsys->zphone). */
- if (strcmp (qset->uuconf_zport, "TCP") == 0)
- {
- qset->uuconf_zport = NULL;
- qset->uuconf_qport = ((struct uuconf_port *)
- uuconf_malloc (pblock,
- sizeof (struct uuconf_port)));
- if (qset->uuconf_qport == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- _uuconf_uclear_port (qset->uuconf_qport);
- qset->uuconf_qport->uuconf_zname = (char *) "TCP";
- qset->uuconf_qport->uuconf_ttype = UUCONF_PORTTYPE_TCP;
- qset->uuconf_qport->uuconf_ireliable
- = (UUCONF_RELIABLE_ENDTOEND | UUCONF_RELIABLE_RELIABLE
- | UUCONF_RELIABLE_EIGHT | UUCONF_RELIABLE_FULLDUPLEX
- | UUCONF_RELIABLE_SPECIFIED);
- if (ctoks < 4)
- qset->uuconf_qport->uuconf_u.uuconf_stcp.uuconf_zport
- = (char *) "uucp";
- else
- qset->uuconf_qport->uuconf_u.uuconf_stcp.uuconf_zport
- = pzsplit[3];
- qset->uuconf_qport->uuconf_u.uuconf_stcp.uuconf_pzdialer = NULL;
- }
-
- if (ctoks < 4)
- continue;
-
- qset->uuconf_ibaud = strtol (pzsplit[3], (char **) NULL, 10);
-
- if (ctoks < 5)
- continue;
-
- /* Get the phone number. */
- qset->uuconf_zphone = pzsplit[4];
-
- if (ctoks < 6)
- continue;
-
- /* Get the chat script. We just hand this off to the chat
- script processor, so that it will parse subsend and
- subexpect strings correctly. */
- pzsplit[4] = (char *) "chat";
- iret = _uuconf_ichat_cmd (qglobal, ctoks - 4, pzsplit + 4,
- &qset->uuconf_schat, pblock);
- iret &=~ UUCONF_CMDTABRET_KEEP;
- if (iret != UUCONF_SUCCESS)
- break;
- }
-
- (void) fclose (e);
-
- if (pzcomma != NULL)
- free ((pointer) pzcomma);
-
- if (iret != UUCONF_SUCCESS)
- {
- if (zline != NULL)
- free ((pointer) zline);
- if (pzsplit != NULL)
- free ((pointer) pzsplit);
- qglobal->zfilename = qglobal->qprocess->zv2systems;
- return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- }
-
- if (pblock == NULL)
- {
- if (zline != NULL)
- free ((pointer) zline);
- if (pzsplit != NULL)
- free ((pointer) pzsplit);
- return UUCONF_NOT_FOUND;
- }
-
- /* Now read USERFILE and L.cmds to get permissions. We can't fully
- handle USERFILE since that specifies permissions based on local
- users which we do not support. */
- {
- e = fopen (qglobal->qprocess->zv2userfile, "r");
- if (e != NULL)
- {
- char **pzlocal, **pzremote;
- boolean fdefault_callback;
- char *zdefault_login;
- struct uuconf_system *q;
-
- pzlocal = NULL;
- pzremote = NULL;
- fdefault_callback = FALSE;
- zdefault_login = NULL;
-
- qglobal->ilineno = 0;
-
- while ((cchars = getline (&zline, &cline, e)) > 0)
- {
- int ctoks;
- char *zcomma;
- boolean fcallback;
- char **pzlist, **pznew;
-
- ++qglobal->ilineno;
-
- --cchars;
- if (zline[cchars] == '\n')
- zline[cchars] = '\0';
- zline[strcspn (zline, "#")] = '\0';
-
- ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit);
- if (ctoks < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
-
- if (ctoks == 0)
- continue;
-
- /* The first field is username,machinename */
- zcomma = strchr (pzsplit[0], ',');
- if (zcomma == NULL)
- continue;
-
- *zcomma++ = '\0';
-
- /* The rest of the line is the list of directories, except
- that if the first directory is "c" we must call the
- system back. */
- fcallback = FALSE;
- pzlist = pzsplit + 1;
- --ctoks;
- if (ctoks > 0
- && pzsplit[1][0] == 'c'
- && pzsplit[1][1] == '\0')
- {
- fcallback = TRUE;
- pzlist = pzsplit + 2;
- --ctoks;
- }
-
- /* Now pzsplit[0] is the user name, zcomma is the system
- name, fcallback indicates whether a call back is
- required, ctoks is the number of directories and pzlist
- points to the directories. If the system name matches,
- then the user name is the name that the system must use
- to log in, and the list of directories is what may be
- transferred in by either local or remote request.
- Otherwise, if no system name matches, then the first
- line with no user name gives the list of directories
- that may be transferred by local request, and the first
- line with no system name gives the list of directories
- that may be transferred by remote request. */
- if ((pzsplit[0][0] != '\0' || pzlocal != NULL)
- && (zcomma[0] != '\0' || pzremote != NULL)
- && strcmp (zcomma, zsystem) != 0)
- continue;
-
- /* NULL terminate the list of directories. */
- pznew = (char **) uuconf_malloc (pblock,
- (ctoks + 1) * sizeof (char *));
- if (pznew == NULL)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- memcpy ((pointer) pznew, (pointer) pzlist,
- ctoks * sizeof (char *));
- pznew[ctoks] = NULL;
-
- if (uuconf_add_block (pblock, zline) != 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- break;
- }
- zline = NULL;
- cline = 0;
-
- if (pzsplit[0][0] == '\0')
- {
- pzlocal = pznew;
- fdefault_callback = fcallback;
- }
- else if (zcomma[0] == '\0')
- {
- pzremote = pznew;
- zdefault_login = pzsplit[0];
- }
- else
- {
- /* Both the login name and the machine name were
- listed; require the machine to be logged in under
- this name. This is not fully backward compatible,
- and perhaps should be changed. On the other hand,
- it is more useful. */
- for (q = qsys; q != NULL; q = q->uuconf_qalternate)
- {
- q->uuconf_zcalled_login = pzsplit[0];
- q->uuconf_fcallback = fcallback;
- q->uuconf_pzlocal_send = pznew;
- q->uuconf_pzlocal_receive = pznew;
- q->uuconf_pzremote_send = pznew;
- q->uuconf_pzremote_receive = pznew;
- }
-
- break;
- }
- }
-
- (void) fclose (e);
-
- if (iret != UUCONF_SUCCESS)
- {
- if (zline != NULL)
- free ((pointer) zline);
- if (pzsplit != NULL)
- free ((pointer) pzsplit);
- qglobal->zfilename = qglobal->qprocess->zv2userfile;
- return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- }
-
- if (qsys->uuconf_pzlocal_send == (char **) &_uuconf_unset
- && pzlocal != NULL)
- {
- for (q = qsys; q != NULL; q = q->uuconf_qalternate)
- {
- q->uuconf_fcallback = fdefault_callback;
- q->uuconf_pzlocal_send = pzlocal;
- q->uuconf_pzlocal_receive = pzlocal;
- }
- }
-
- if (qsys->uuconf_pzremote_send == (char **) &_uuconf_unset
- && pzremote != NULL)
- {
- for (q = qsys; q != NULL; q = q->uuconf_qalternate)
- {
- q->uuconf_zcalled_login = zdefault_login;
- q->uuconf_pzremote_send = pzremote;
- q->uuconf_pzremote_receive = pzremote;
- }
- }
- }
- }
-
- /* Now we must read L.cmds to determine which commands may be
- executed. */
- {
- e = fopen (qglobal->qprocess->zv2cmds, "r");
- if (e != NULL)
- {
- qglobal->ilineno = 0;
-
- if (getline (&zline, &cline, e) > 0)
- {
- ++qglobal->ilineno;
-
- zline[strcspn (zline, "#\n")] = '\0';
-
- while (*zline == '\0')
- {
- if (getline (&zline, &cline, e) <= 0)
- {
- if (zline != NULL)
- {
- free ((pointer) zline);
- zline = NULL;
- }
- }
- else
- {
- ++qglobal->ilineno;
- zline[strcspn (zline, "#\n")] = '\0';
- }
- }
-
- if (zline != NULL
- && strncmp (zline, "PATH=", sizeof "PATH=" - 1) == 0)
- {
- int ctoks;
- char **pznew;
-
- zline += sizeof "PATH=" - 1;
- ctoks = _uuconf_istrsplit (zline, ':', &pzsplit, &csplit);
- if (ctoks < 0)
- {
- qglobal->ierrno = errno;
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
-
- pznew = NULL;
- if (iret == UUCONF_SUCCESS)
- {
- pznew = ((char **)
- uuconf_malloc (pblock,
- (ctoks + 1) * sizeof (char *)));
- if (pznew == NULL)
- iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
- }
- if (iret == UUCONF_SUCCESS)
- {
- memcpy ((pointer) pznew, (pointer) pzsplit,
- ctoks * sizeof (char *));
- pznew[ctoks] = NULL;
- qsys->uuconf_pzpath = pznew;
- zline = NULL;
- cline = 0;
- }
-
- if (getline (&zline, &cline, e) < 0)
- {
- if (zline != NULL)
- {
- free ((pointer) zline);
- zline = NULL;
- }
- }
- else
- ++qglobal->ilineno;
- }
- }
-
- if (iret == UUCONF_SUCCESS && zline != NULL)
- {
- while (TRUE)
- {
- zline[strcspn (zline, "#,\n")] = '\0';
- if (*zline != '\0')
- {
- iret = _uuconf_iadd_string (qglobal, zline, TRUE, FALSE,
- &qsys->uuconf_pzcmds,
- pblock);
- if (iret != UUCONF_SUCCESS)
- break;
- }
- if (getline (&zline, &cline, e) < 0)
- break;
- ++qglobal->ilineno;
- }
- }
-
- (void) fclose (e);
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = qglobal->qprocess->zv2cmds;
- iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- }
- }
- }
-
- if (zline != NULL)
- free ((pointer) zline);
- if (pzsplit != NULL)
- free ((pointer) pzsplit);
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/vsnams.c b/gnu/libexec/uucp/libuuconf/vsnams.c
deleted file mode 100644
index 0f165ee..0000000
--- a/gnu/libexec/uucp/libuuconf/vsnams.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* vsnams.c
- Get all known system names from the V2 configuration files.
-
- Copyright (C) 1992, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_vsnams_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-/* Get all the system names from the V2 L.sys file. This code does
- not support aliases, although some V2 versions do have an L-aliases
- file. */
-
-/*ARGSUSED*/
-int
-uuconf_v2_system_names (pglobal, ppzsystems, falias)
- pointer pglobal;
- char ***ppzsystems;
- int falias;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- FILE *e;
- int iret;
- char *zline;
- size_t cline;
-
- *ppzsystems = NULL;
-
- e = fopen (qglobal->qprocess->zv2systems, "r");
- if (e == NULL)
- {
- if (FNO_SUCH_FILE ())
- return _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
- ppzsystems, (pointer) NULL);
- qglobal->ierrno = errno;
- qglobal->zfilename = qglobal->qprocess->zv2systems;
- return (UUCONF_FOPEN_FAILED
- | UUCONF_ERROR_ERRNO
- | UUCONF_ERROR_FILENAME);
- }
-
- qglobal->ilineno = 0;
- iret = UUCONF_SUCCESS;
-
- zline = NULL;
- cline = 0;
- while (_uuconf_getline (qglobal, &zline, &cline, e) > 0)
- {
- char *zname;
-
- ++qglobal->ilineno;
-
- /* Skip leading whitespace to get to the system name. Then cut
- the system name off at the first whitespace, comment, or
- newline. */
- zname = zline + strspn (zline, " \t");
- zname[strcspn (zname, " \t#\n")] = '\0';
- if (*zname == '\0')
- continue;
-
- iret = _uuconf_iadd_string (qglobal, zname, TRUE, TRUE, ppzsystems,
- (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- break;
- }
-
- (void) fclose (e);
- if (zline != NULL)
- free ((pointer) zline);
-
- if (iret != UUCONF_SUCCESS)
- {
- qglobal->zfilename = qglobal->qprocess->zv2systems;
- return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
- }
-
- if (*ppzsystems == NULL)
- iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
- ppzsystems, (pointer) NULL);
-
- return iret;
-}
diff --git a/gnu/libexec/uucp/libuuconf/vsys.c b/gnu/libexec/uucp/libuuconf/vsys.c
deleted file mode 100644
index 8c893dc..0000000
--- a/gnu/libexec/uucp/libuuconf/vsys.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* vsys.c
- User function to get a system from the V2 configuration files.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP uuconf library.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char _uuconf_vsys_rcsid[] = "$Id$";
-#endif
-
-/* Get system information from the V2 configuration files. This is a
- wrapper for the internal function which makes sure that every field
- gets a default value. */
-
-int
-uuconf_v2_system_info (pglobal, zsystem, qsys)
- pointer pglobal;
- const char *zsystem;
- struct uuconf_system *qsys;
-{
- struct sglobal *qglobal = (struct sglobal *) pglobal;
- int iret;
-
- iret = _uuconf_iv2_system_internal (qglobal, zsystem, qsys);
- if (iret != UUCONF_SUCCESS)
- return iret;
- return _uuconf_isystem_basic_default (qglobal, qsys);
-}
diff --git a/gnu/libexec/uucp/libuucp/MANIFEST b/gnu/libexec/uucp/libuucp/MANIFEST
deleted file mode 100644
index 909eb67..0000000
--- a/gnu/libexec/uucp/libuucp/MANIFEST
+++ /dev/null
@@ -1,63 +0,0 @@
-COPYING
-ChangeLog
-MANIFEST
-Makefile.in
-NEWS
-README
-TODO
-chat.c
-config.h.in
-configure
-configure.in
-conn.c
-conn.h
-copy.c
-cu.1
-cu.c
-cu.h
-getopt.h
-install-sh
-log.c
-policy.h
-prot.c
-prot.h
-prote.c
-protf.c
-protg.c
-proti.c
-protj.c
-prott.c
-proty.c
-protz.c
-rec.c
-send.c
-sysh.unx
-system.h
-time.c
-trans.c
-trans.h
-tstuu.c
-util.c
-uuchk.c
-uucico.8
-uucico.c
-uuconf.h
-uuconv.c
-uucp.1
-uucp.c
-uucp.h
-uucp.texi
-uudefs.h
-uudir.c
-uulog.c
-uuname.c
-uupick.c
-uusched.in
-uustat.1
-uustat.c
-uuto.in
-uux.1
-uux.c
-uuxqt.8
-uuxqt.c
-xcmd.c
diff --git a/gnu/libexec/uucp/libuucp/Makefile b/gnu/libexec/uucp/libuucp/Makefile
deleted file mode 100644
index 88ca27a..0000000
--- a/gnu/libexec/uucp/libuucp/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# This is the Makefile for the libuucp subdirectory of Taylor UUCP
-# $Id$
-
-LIB= uucp
-SRCS = buffer.c crc.c debug.c escape.c getopt.c getop1.c parse.c spool.c \
- status.c xfree.c xmall.c xreall.c \
- getlin.c
-CFLAGS+= -I$(.CURDIR)/../common_sources
-
-NOMAN= noman
-NOPROFILE= noprofile
-
-install:
-
-.include <bsd.lib.mk>
diff --git a/gnu/libexec/uucp/libuucp/bsrch.c b/gnu/libexec/uucp/libuucp/bsrch.c
deleted file mode 100644
index 58b8710..0000000
--- a/gnu/libexec/uucp/libuucp/bsrch.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place -
-Suite 330, Boston, MA 02111-1307, USA.
-
-This file was modified slightly by Ian Lance Taylor, May 1992, for
-Taylor UUCP. */
-
-#include "uucp.h"
-
-/* Perform a binary search for KEY in BASE which has NMEMB elements
- of SIZE bytes each. The comparisons are done by (*COMPAR)(). */
-pointer
-bsearch (key, base, nmemb, size, compar)
- register constpointer key;
- register constpointer base;
- size_t nmemb;
- register size_t size;
- register int (*compar) P((constpointer, constpointer));
-{
- register size_t l, u, idx;
- register constpointer p;
- register int comparison;
-
- l = 0;
- u = nmemb;
- while (l < u)
- {
- idx = (l + u) / 2;
- p = (constpointer) (((const char *) base) + (idx * size));
- comparison = (*compar)(key, p);
- if (comparison < 0)
- u = idx;
- else if (comparison > 0)
- l = idx + 1;
- else
- return (pointer) p;
- }
-
- return NULL;
-}
diff --git a/gnu/libexec/uucp/libuucp/buffer.c b/gnu/libexec/uucp/libuucp/buffer.c
deleted file mode 100644
index e33b282..0000000
--- a/gnu/libexec/uucp/libuucp/buffer.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* buffer.c
- Manipulate buffers used to hold strings.
-
- Copyright (C) 1992, 1993 Ian Lance Taylor
-
- This file is part of Taylor UUCP.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-
-/* We keep a linked list of buffers. The union is a hack because the
- default definition of offsetof, in uucp.h, takes the address of the
- field, and some C compilers will not let you take the address of an
- array. */
-
-struct sbuf
-{
- struct sbuf *qnext;
- size_t c;
- union
- {
- char ab[4];
- char bdummy;
- }
- u;
-};
-
-static struct sbuf *qBlist;
-
-/* Get a buffer of a given size. The buffer is returned with the
- ubuffree function. */
-
-char *
-zbufalc (c)
- size_t c;
-{
- register struct sbuf *q;
-
- if (qBlist == NULL)
- {
- q = (struct sbuf *) xmalloc (sizeof (struct sbuf) + c - 4);
- q->c = c;
- }
- else
- {
- q = qBlist;
- qBlist = q->qnext;
- if (q->c < c)
- {
- q = (struct sbuf *) xrealloc ((pointer) q,
- sizeof (struct sbuf) + c - 4);
- q->c = c;
- }
- }
- return q->u.ab;
-}
-
-/* Get a buffer holding a given string. */
-
-char *
-zbufcpy (z)
- const char *z;
-{
- size_t csize;
- char *zret;
-
- if (z == NULL)
- return NULL;
- csize = strlen (z) + 1;
- zret = zbufalc (csize);
- memcpy (zret, z, csize);
- return zret;
-}
-
-/* Free up a buffer back onto the linked list. */
-
-void
-ubuffree (z)
- char *z;
-{
- struct sbuf *q;
- /* The type of ioff should be size_t, but making it int avoids a bug
- in some versions of the HP/UX compiler, and will always work. */
- int ioff;
-
- if (z == NULL)
- return;
- ioff = offsetof (struct sbuf, u);
- q = (struct sbuf *) (pointer) (z - ioff);
-
-#ifdef DEBUG_BUFFER
- {
- struct sbuf *qlook;
-
- for (qlook = qBlist; qlook != NULL; qlook = qlook->qnext)
- {
- if (qlook == q)
- {
- ulog (LOG_ERROR, "ubuffree: Attempt to free buffer twice");
- abort ();
- }
- }
- }
-#endif
-
- q->qnext = qBlist;
- qBlist = q;
-}
diff --git a/gnu/libexec/uucp/libuucp/bzero.c b/gnu/libexec/uucp/libuucp/bzero.c
deleted file mode 100644
index 098e551..0000000
--- a/gnu/libexec/uucp/libuucp/bzero.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/* bzero.c
- Zero out a buffer. */
-
-#include "uucp.h"
-
-void
-bzero (parg, c)
- pointer parg;
- int c;
-{
- char *p = (char *) parg;
-
- while (c-- != 0)
- *p++ = 0;
-}
diff --git a/gnu/libexec/uucp/libuucp/crc.c b/gnu/libexec/uucp/libuucp/crc.c
deleted file mode 100644
index fc9687b..0000000
--- a/gnu/libexec/uucp/libuucp/crc.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 1986 Gary S. Brown. You may use this program, or
- * code or tables extracted from it, as desired without restriction.
- */
-
-/* Modified slightly by Ian Lance Taylor, ian@airs.com, for use with
- Taylor UUCP. */
-
-#include "uucp.h"
-#include "prot.h"
-
-/* First, the polynomial itself and its table of feedback terms. The */
-/* polynomial is */
-/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
-/* Note that we take it "backwards" and put the highest-order term in */
-/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */
-/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */
-/* the MSB being 1. */
-
-/* Note that the usual hardware shift register implementation, which */
-/* is what we're using (we're merely optimizing it by doing eight-bit */
-/* chunks at a time) shifts bits into the lowest-order term. In our */
-/* implementation, that means shifting towards the right. Why do we */
-/* do it this way? Because the calculated CRC must be transmitted in */
-/* order from highest-order term to lowest-order term. UARTs transmit */
-/* characters in order from LSB to MSB. By storing the CRC this way, */
-/* we hand it to the UART in the order low-byte to high-byte; the UART */
-/* sends each low-bit to hight-bit; and the result is transmission bit */
-/* by bit from highest- to lowest-order term without requiring any bit */
-/* shuffling on our part. Reception works similarly. */
-
-/* The feedback terms table consists of 256, 32-bit entries. Notes: */
-/* */
-/* The table can be generated at runtime if desired; code to do so */
-/* is shown later. It might not be obvious, but the feedback */
-/* terms simply represent the results of eight shift/xor opera- */
-/* tions for all combinations of data and CRC register values. */
-/* [this code is no longer present--ian] */
-/* */
-/* The values must be right-shifted by eight bits by the "updcrc" */
-/* logic; the shift must be unsigned (bring in zeroes). On some */
-/* hardware you could probably optimize the shift in assembler by */
-/* using byte-swap instructions. */
-
-static const unsigned long aicrc32tab[] = { /* CRC polynomial 0xedb88320 */
-0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L,
-0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L,
-0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L,
-0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L,
-0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
-0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L,
-0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL,
-0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL,
-0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L,
-0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
-0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L,
-0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L,
-0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL,
-0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L,
-0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
-0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL,
-0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L,
-0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L,
-0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L,
-0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
-0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL,
-0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L,
-0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL,
-0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL,
-0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
-0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L,
-0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L,
-0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L,
-0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL,
-0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
-0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL,
-0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL
-};
-
-/*
- * IUPDC32 macro derived from article Copyright (C) 1986 Stephen Satchell.
- * NOTE: First argument must be in range 0 to 255.
- * Second argument is referenced twice.
- *
- * Programmers may incorporate any or all code into their programs,
- * giving proper credit within the source. Publication of the
- * source routines is permitted so long as proper credit is given
- * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
- * Omen Technology.
- */
-
-#define IUPDC32(b, ick) \
- (aicrc32tab[((int) (ick) ^ (b)) & 0xff] ^ (((ick) >> 8) & 0x00ffffffL))
-
-unsigned long
-icrc (z, c, ick)
- const char *z;
- size_t c;
- unsigned long ick;
-{
- while (c > 4)
- {
- ick = IUPDC32 (*z++, ick);
- ick = IUPDC32 (*z++, ick);
- ick = IUPDC32 (*z++, ick);
- ick = IUPDC32 (*z++, ick);
- c -= 4;
- }
- while (c-- != 0)
- ick = IUPDC32 (*z++, ick);
- return ick;
-}
diff --git a/gnu/libexec/uucp/libuucp/debug.c b/gnu/libexec/uucp/libuucp/debug.c
deleted file mode 100644
index 6ae3063..0000000
--- a/gnu/libexec/uucp/libuucp/debug.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/* debug.c
- UUCP debugging functions.
-
- Copyright (C) 1991, 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#include <ctype.h>
-
-#include "uudefs.h"
-
-#if DEBUG > 1
-
-/* The debugging level. */
-int iDebug;
-
-/* Parse a debugging string. This may be a simple number, which sets
- the given number of bits in iDebug, or it may be a series of single
- letters. */
-
-static const char * const azDebug_names[] = DEBUG_NAMES;
-
-int
-idebug_parse (z)
- const char *z;
-{
- char *zend;
- int i, iret;
- char *zcopy, *ztok;
-
- if (strncasecmp (z, DEBUG_NONE, sizeof DEBUG_NONE - 1) == 0)
- return 0;
-
- i = (int) strtol ((char *) z, &zend, 0);
- if (*zend == '\0')
- {
- if (i > 15)
- i = 15;
- else if (i < 0)
- i = 0;
- return (1 << i) - 1;
- }
-
- zcopy = zbufcpy (z);
-
- iret = 0;
-
- for (ztok = strtok (zcopy, ", \t");
- ztok != NULL;
- ztok = strtok ((char *) NULL, ", \t"))
- {
- if (strcasecmp (ztok, "all") == 0)
- {
- iret = DEBUG_MAX;
- break;
- }
- for (i = 0; azDebug_names[i] != NULL; i++)
- {
- if (strncasecmp (ztok, azDebug_names[i],
- strlen (azDebug_names[i])) == 0)
- {
- iret |= 1 << i;
- break;
- }
- }
- if (azDebug_names[i] == NULL)
- ulog (LOG_ERROR, "Unrecognized debugging option \"%s\"",
- ztok);
- }
-
- ubuffree (zcopy);
-
- return iret;
-}
-
-#endif /* DEBUG > 1 */
-
-/* A debugging routine used when displaying buffers. */
-
-size_t
-cdebug_char (z, ichar)
- char *z;
- int ichar;
-{
- char b;
-
- if (isprint (BUCHAR (ichar))
- && ichar != '\"'
- && ichar != '\\')
- {
- *z++ = (char) ichar;
- *z = '\0';
- return 1;
- }
-
- *z++ = '\\';
-
- switch (ichar)
- {
- case '\n':
- b = 'n';
- break;
- case '\r':
- b = 'r';
- break;
- case '\"':
- b = '\"';
- break;
- case '\\':
- b = '\\';
- break;
- default:
- sprintf (z, "%03o", (unsigned int) BUCHAR (ichar));
- return strlen (z) + 1;
- }
-
- *z++ = b;
- *z = '\0';
- return 2;
-}
-
-#if DEBUG > 1
-
-/* Display a buffer when debugging. */
-
-void
-udebug_buffer (zhdr, zbuf, clen)
- const char *zhdr;
- const char *zbuf;
- size_t clen;
-{
- char *z, *zalc;
- int i;
-
- zalc = zbufalc (clen * 4 + 1);
-
- z = zalc;
- for (i = 0; i < clen && i < 80; i++)
- z += cdebug_char (z, zbuf[i]);
- if (i < clen)
- {
- *z++ = '.';
- *z++ = '.';
- *z++ = '.';
- }
- *z = '\0';
-
- ulog (LOG_DEBUG, "%s %lu \"%s\"", zhdr, (unsigned long) clen, zalc);
-
- ubuffree (zalc);
-}
-
-#endif
diff --git a/gnu/libexec/uucp/libuucp/escape.c b/gnu/libexec/uucp/libuucp/escape.c
deleted file mode 100644
index 646b787..0000000
--- a/gnu/libexec/uucp/libuucp/escape.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* escape.c
- Translate escape sequences. */
-
-#include "uucp.h"
-
-#include <ctype.h>
-
-#include "uudefs.h"
-
-size_t
-cescape (z)
- char *z;
-{
- char *zto, *zfrom;
-
- zto = z;
- zfrom = z;
- while (*zfrom != '\0')
- {
- if (*zfrom != '\\')
- {
- *zto++ = *zfrom++;
- continue;
- }
- ++zfrom;
- switch (*zfrom)
- {
- case '-':
- *zto++ = '-';
- break;
- case 'b':
- *zto++ = '\b';
- break;
- case 'n':
- *zto++ = '\n';
- break;
- case 'N':
- *zto++ = '\0';
- break;
- case 'r':
- *zto++ = '\r';
- break;
- case 's':
- *zto++ = ' ';
- break;
- case 't':
- *zto++ = '\t';
- break;
- case '\0':
- --zfrom;
- /* Fall through. */
- case '\\':
- *zto++ = '\\';
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- {
- int i;
-
- i = *zfrom - '0';
- if (zfrom[1] >= '0' && zfrom[1] <= '7')
- i = 8 * i + *++zfrom - '0';
- if (zfrom[1] >= '0' && zfrom[1] <= '7')
- i = 8 * i + *++zfrom - '0';
- *zto++ = (char) i;
- }
- break;
- case 'x':
- {
- int i;
-
- i = 0;
- while (isxdigit (BUCHAR (zfrom[1])))
- {
- if (isdigit (BUCHAR (zfrom[1])))
- i = 16 * i + *++zfrom - '0';
- else if (isupper (BUCHAR (zfrom[1])))
- i = 16 * i + *++zfrom - 'A' + 10;
- else
- i = 16 * i + *++zfrom - 'a' + 10;
- }
- *zto++ = (char) i;
- }
- break;
- default:
- ulog (LOG_ERROR, "Unrecognized escape sequence \\%c",
- *zfrom);
- *zto++ = *zfrom;
- break;
- }
-
- ++zfrom;
- }
-
- *zto = '\0';
-
- return (size_t) (zto - z);
-}
diff --git a/gnu/libexec/uucp/libuucp/getlin.c b/gnu/libexec/uucp/libuucp/getlin.c
deleted file mode 100644
index 822bc1c..0000000
--- a/gnu/libexec/uucp/libuucp/getlin.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* getlin.c
- Replacement for getline.
-
- Copyright (C) 1992 Ian Lance Taylor
-
- This file is part of Taylor UUCP.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License
- as published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-/* Read a line from a file, returning the number of characters read.
- This should really return ssize_t. Returns -1 on error. */
-
-#define CGETLINE_DEFAULT (63)
-
-int
-getline (pzline, pcline, e)
- char **pzline;
- size_t *pcline;
- FILE *e;
-{
- char *zput, *zend;
- int bchar;
-
- if (*pzline == NULL)
- {
- *pzline = (char *) malloc (CGETLINE_DEFAULT);
- if (*pzline == NULL)
- return -1;
- *pcline = CGETLINE_DEFAULT;
- }
-
- zput = *pzline;
- zend = *pzline + *pcline - 1;
-
- while ((bchar = getc (e)) != EOF)
- {
- if (zput >= zend)
- {
- size_t cnew;
- char *znew;
-
- cnew = *pcline * 2 + 1;
- znew = (char *) realloc ((pointer) *pzline, cnew);
- if (znew == NULL)
- return -1;
- zput = znew + *pcline - 1;
- zend = znew + cnew - 1;
- *pzline = znew;
- *pcline = cnew;
- }
-
- *zput++ = bchar;
-
- if (bchar == '\n')
- break;
- }
-
- if (zput == *pzline)
- return -1;
-
- *zput = '\0';
- return zput - *pzline;
-}
diff --git a/gnu/libexec/uucp/libuucp/getop1.c b/gnu/libexec/uucp/libuucp/getop1.c
deleted file mode 100644
index c7c7383..0000000
--- a/gnu/libexec/uucp/libuucp/getop1.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/* Getopt for GNU.
- Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- This file was modified slightly by Ian Lance Taylor, June 1992, for
- Taylor UUCP. */
-
-#include "uucp.h"
-
-#include "getopt.h"
-
-int
-getopt_long (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
-}
-
-/* Like getopt_long, but '-' as well as '--' can indicate a long option.
- If an option that starts with '-' (not '--') doesn't match a long option,
- but does match a short option, it is parsed as a short option
- instead. */
-
-int
-getopt_long_only (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
-}
-
-#ifdef TEST
-
-#include <stdio.h>
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
- int option_index = 0;
- static struct option long_options[] =
- {
- {"add", 1, 0, 0},
- {"append", 0, 0, 0},
- {"delete", 1, 0, 0},
- {"verbose", 0, 0, 0},
- {"create", 0, 0, 0},
- {"file", 1, 0, 0},
- {0, 0, 0, 0}
- };
-
- c = getopt_long (argc, argv, "abc:d:0123456789",
- long_options, &option_index);
- if (c == EOF)
- break;
-
- switch (c)
- {
- case 0:
- printf ("option %s", long_options[option_index].name);
- if (optarg)
- printf (" with arg %s", optarg);
- printf ("\n");
- break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case 'd':
- printf ("option d with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/libexec/uucp/libuucp/getopt.c b/gnu/libexec/uucp/libuucp/getopt.c
deleted file mode 100644
index eed7d8e..0000000
--- a/gnu/libexec/uucp/libuucp/getopt.c
+++ /dev/null
@@ -1,621 +0,0 @@
-/* Getopt for GNU.
- NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
- before changing it!
-
- Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- This file was modified slightly by Ian Lance Taylor, June 1992, for
- Taylor UUCP. */
-
-#include "uucp.h"
-#include "uudefs.h"
-
-/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
- long-named option. Because this is not POSIX.2 compliant, it is
- being phased out. */
-#undef GETOPT_COMPAT
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- to intersperse the options with the other arguments.
-
- As `getopt' works, it permutes the elements of ARGV so that,
- when it is done, all the options precede everything else. Thus
- all application programs are extended to handle flexible argument order.
-
- Setting the environment variable POSIXLY_CORRECT disables permutation.
- Then the behavior is completely standard.
-
- GNU application programs can use a third alternative mode in which
- they can distinguish the relative order of options and other arguments. */
-
-#include "getopt.h"
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-char *optarg = 0;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-int optind = 0;
-
-/* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
-static char *nextchar;
-
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
- If the caller did not specify anything,
- the default is REQUIRE_ORDER if the environment variable
- POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
- REQUIRE_ORDER means don't recognize them as options;
- stop option processing when the first non-option is seen.
- This is what Unix does.
- This mode of operation is selected by either setting the environment
- variable POSIXLY_CORRECT, or using `+' as the first character
- of the list of option characters.
-
- PERMUTE is the default. We permute the contents of ARGV as we scan,
- so that eventually all the non-options are at the end. This allows options
- to be given in any order, even with programs that were not written to
- expect this.
-
- RETURN_IN_ORDER is an option available to programs that were written
- to expect options and other ARGV-elements in any order and that care about
- the ordering of the two. We describe each non-option ARGV-element
- as if it were the argument of an option with character code 1.
- Using `-' as the first character of the list of option characters
- selects this mode of operation.
-
- The special argument `--' forces an end of option-scanning regardless
- of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return EOF with `optind' != ARGC. */
-
-static enum
-{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-#define my_index strchr
-#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n))
-
-/* Handle permutation of arguments. */
-
-/* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
-static int first_nonopt;
-static int last_nonopt;
-
-/* Exchange two adjacent subsequences of ARGV.
- One subsequence is elements [first_nonopt,last_nonopt)
- which contains all the non-options that have been skipped so far.
- The other is elements [last_nonopt,optind), which contains all
- the options processed since those non-options were skipped.
-
- `first_nonopt' and `last_nonopt' are relocated so that they describe
- the new indices of the non-options in ARGV after they are moved. */
-
-static void
-exchange (argv)
- char **argv;
-{
- size_t nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *);
- char **temp = (char **) malloc (nonopts_size);
-
- if (temp == NULL)
- abort ();
-
- /* Interchange the two blocks of data in ARGV. */
-
- my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size);
- my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt],
- (optind - last_nonopt) * sizeof (char *));
- my_bcopy ((char *) temp,
- (char *) &argv[first_nonopt + optind - last_nonopt],
- nonopts_size);
-
- xfree (temp);
-
- /* Update records for the slots the non-options now occupy. */
-
- first_nonopt += (optind - last_nonopt);
- last_nonopt = optind;
-}
-
-/* Scan elements of ARGV (whose length is ARGC) for option characters
- given in OPTSTRING.
-
- If an element of ARGV starts with '-', and is not exactly "-" or "--",
- then it is an option element. The characters of this element
- (aside from the initial '-') are option characters. If `getopt'
- is called repeatedly, it returns successively each of the option characters
- from each of the option elements.
-
- If `getopt' finds another option character, it returns that character,
- updating `optind' and `nextchar' so that the next call to `getopt' can
- resume the scan with the following option character or ARGV-element.
-
- If there are no more option characters, `getopt' returns `EOF'.
- Then `optind' is the index in ARGV of the first ARGV-element
- that is not an option. (The ARGV-elements have been permuted
- so that those that are not options now come last.)
-
- OPTSTRING is a string containing the legitimate option characters.
- If an option character is seen that is not listed in OPTSTRING,
- return '?' after printing an error message. If you set `opterr' to
- zero, the error message is suppressed but we still return '?'.
-
- If a char in OPTSTRING is followed by a colon, that means it wants an arg,
- so the following text in the same ARGV-element, or the text of the following
- ARGV-element, is returned in `optarg'. Two colons mean an option that
- wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `optarg', otherwise `optarg' is set to zero.
-
- If OPTSTRING starts with `-' or `+', it requests different methods of
- handling the non-option ARGV-elements.
- See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
-
- Long-named options begin with `--' instead of `-'.
- Their names may be abbreviated as long as the abbreviation is unique
- or is an exact match for some defined option. If they have an
- argument, it follows the option name in the same ARGV-element, separated
- from the option name by a `=', or else the in next ARGV-element.
- When `getopt' finds a long-named option, it returns 0 if that option's
- `flag' field is nonzero, the value of the option's `val' field
- if the `flag' field is zero.
-
- The elements of ARGV aren't really const, because we permute them.
- But we pretend they're const in the prototype to be compatible
- with other systems.
-
- LONGOPTS is a vector of `struct option' terminated by an
- element containing a name which is zero.
-
- LONGIND returns the index in LONGOPT of the long-named option found.
- It is only valid when a long-named option has been found by the most
- recent call.
-
- If LONG_ONLY is nonzero, '-' as well as '--' can introduce
- long-named options. */
-
-int
-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
- int argc;
- char *const *argv;
- const char *optstring;
- const struct option *longopts;
- int *longind;
- int long_only;
-{
- int option_index;
-
- optarg = 0;
-
- /* Initialize the internal data when the first call is made.
- Start processing options with ARGV-element 1 (since ARGV-element 0
- is the program name); the sequence of previously skipped
- non-option ARGV-elements is empty. */
-
- if (optind == 0)
- {
- first_nonopt = last_nonopt = optind = 1;
-
- nextchar = NULL;
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-')
- {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- }
- else if (optstring[0] == '+')
- {
- ordering = REQUIRE_ORDER;
- ++optstring;
- }
- else if (getenv ("POSIXLY_CORRECT") != NULL)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
- }
-
- if (nextchar == NULL || *nextchar == '\0')
- {
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Now skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < argc
- && (argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- optind++;
- last_nonopt = optind;
- }
-
- /* Special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp (argv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return EOF;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- {
- if (ordering == REQUIRE_ORDER)
- return EOF;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- Start decoding its characters. */
-
- nextchar = (argv[optind] + 1
- + (longopts != NULL && argv[optind][1] == '-'));
- }
-
- if (longopts != NULL
- && ((argv[optind][0] == '-'
- && (argv[optind][1] == '-' || long_only))
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- ))
- {
- const struct option *p;
- char *s = nextchar;
- int exact = 0;
- int ambig = 0;
- const struct option *pfound = NULL;
- int indfound = 0;
-
- while (*s && *s != '=')
- s++;
-
- /* Test all options for either exact match or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name;
- p++, option_index++)
- if (!strncmp (p->name, nextchar, (size_t) (s - nextchar)))
- {
- if (s - nextchar == strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' is ambiguous\n",
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- return '?';
- }
-
- if (pfound != NULL)
- {
- option_index = indfound;
- optind++;
- if (*s)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = s + 1;
- else
- {
- if (opterr)
- {
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- "%s: option `--%s' doesn't allow an argument\n",
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- "%s: option `%c%s' doesn't allow an argument\n",
- argv[0], argv[optind - 1][0], pfound->name);
- }
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' requires an argument\n",
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- /* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- || my_index (optstring, *nextchar) == NULL)
- {
- if (opterr)
- {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf (stderr, "%s: unrecognized option `--%s'\n",
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf (stderr, "%s: unrecognized option `%c%s'\n",
- argv[0], argv[optind][0], nextchar);
- }
- nextchar = (char *) "";
- optind++;
- return '?';
- }
- }
-
- /* Look at and handle the next option-character. */
-
- {
- char c = *nextchar++;
- char *temp = my_index (optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == '\0')
- ++optind;
-
- if (temp == NULL || c == ':')
- {
- if (opterr)
- {
- if (c < 040 || c >= 0177)
- fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
- argv[0], BUCHAR (c));
- else
- fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
- }
- return '?';
- }
- if (temp[1] == ':')
- {
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = 0;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- fprintf (stderr, "%s: option `-%c' requires an argument\n",
- argv[0], c);
- c = '?';
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
- }
- return c;
- }
-}
-
-int
-getopt (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
-{
- return _getopt_internal (argc, argv, optstring,
- (const struct option *) 0,
- (int *) 0,
- 0);
-}
-
-#ifdef TEST
-
-/* Compile with -DTEST to make an executable for use in testing
- the above definition of `getopt'. */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
-
- c = getopt (argc, argv, "abc:d:0123456789");
- if (c == EOF)
- break;
-
- switch (c)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/libexec/uucp/libuucp/memchr.c b/gnu/libexec/uucp/libuucp/memchr.c
deleted file mode 100644
index c743154..0000000
--- a/gnu/libexec/uucp/libuucp/memchr.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
- Based on strlen implemention by Torbjorn Granlund (tege@sics.se),
- with help from Dan Sahlin (dan@sics.se) and
- commentary by Jim Blandy (jimb@ai.mit.edu);
- adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
- and implemented by Roland McGrath (roland@ai.mit.edu).
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place -
-Suite 330, Boston, MA 02111-1307, USA.
-
-This file was modified slightly by Ian Lance Taylor, May 1992, for
-Taylor UUCP. It assumes 32 bit longs. I'm willing to trust that any
-system which does not have 32 bit longs will have its own
-implementation of memchr. */
-
-#include "uucp.h"
-
-/* Search no more than N bytes of S for C. */
-
-pointer
-memchr (s, c, n)
- constpointer s;
- int c;
- size_t n;
-{
- const char *char_ptr;
- const unsigned long int *longword_ptr;
- unsigned long int longword, magic_bits, charmask;
-
- c = BUCHAR (c);
-
- /* Handle the first few characters by reading one character at a time.
- Do this until CHAR_PTR is aligned on a 4-byte border. */
- for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr & 3) != 0;
- --n, ++char_ptr)
- if (BUCHAR (*char_ptr) == c)
- return (pointer) char_ptr;
-
- longword_ptr = (unsigned long int *) char_ptr;
-
- /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
- the "holes." Note that there is a hole just to the left of
- each byte, with an extra at the end:
-
- bits: 01111110 11111110 11111110 11111111
- bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
-
- The 1-bits make sure that carries propagate to the next 0-bit.
- The 0-bits provide holes for carries to fall into. */
- magic_bits = 0x7efefeff;
-
- /* Set up a longword, each of whose bytes is C. */
- charmask = c | (c << 8);
- charmask |= charmask << 16;
-
- /* Instead of the traditional loop which tests each character,
- we will test a longword at a time. The tricky part is testing
- if *any of the four* bytes in the longword in question are zero. */
- while (n >= 4)
- {
- /* We tentatively exit the loop if adding MAGIC_BITS to
- LONGWORD fails to change any of the hole bits of LONGWORD.
-
- 1) Is this safe? Will it catch all the zero bytes?
- Suppose there is a byte with all zeros. Any carry bits
- propagating from its left will fall into the hole at its
- least significant bit and stop. Since there will be no
- carry from its most significant bit, the LSB of the
- byte to the left will be unchanged, and the zero will be
- detected.
-
- 2) Is this worthwhile? Will it ignore everything except
- zero bytes? Suppose every byte of LONGWORD has a bit set
- somewhere. There will be a carry into bit 8. If bit 8
- is set, this will carry into bit 16. If bit 8 is clear,
- one of bits 9-15 must be set, so there will be a carry
- into bit 16. Similarly, there will be a carry into bit
- 24. If one of bits 24-30 is set, there will be a carry
- into bit 31, so all of the hole bits will be changed.
-
- The one misfire occurs when bits 24-30 are clear and bit
- 31 is set; in this case, the hole at bit 31 is not
- changed. If we had access to the processor carry flag,
- we could close this loophole by putting the fourth hole
- at bit 32!
-
- So it ignores everything except 128's, when they're aligned
- properly.
-
- 3) But wait! Aren't we looking for C, not zero?
- Good point. So what we do is XOR LONGWORD with a longword,
- each of whose bytes is C. This turns each byte that is C
- into a zero. */
-
- longword = *longword_ptr++ ^ charmask;
-
- /* Add MAGIC_BITS to LONGWORD. */
- if ((((longword + magic_bits)
-
- /* Set those bits that were unchanged by the addition. */
- ^ ~longword)
-
- /* Look at only the hole bits. If any of the hole bits
- are unchanged, most likely one of the bytes was a
- zero. */
- & ~magic_bits) != 0)
- {
- /* Which of the bytes was C? If none of them were, it was
- a misfire; continue the search. */
-
- const char *cp = (const char *) (longword_ptr - 1);
-
- if (BUCHAR (cp[0]) == c)
- return (pointer) cp;
- if (BUCHAR (cp[1]) == c)
- return (pointer) &cp[1];
- if (BUCHAR (cp[2]) == c)
- return (pointer) &cp[2];
- if (BUCHAR (cp[3]) == c)
- return (pointer) &cp[3];
- }
-
- n -= 4;
- }
-
- char_ptr = (const char *) longword_ptr;
-
- while (n-- > 0)
- {
- if (BUCHAR (*char_ptr) == c)
- return (pointer) char_ptr;
- else
- ++char_ptr;
- }
-
- return NULL;
-}
diff --git a/gnu/libexec/uucp/libuucp/memcmp.c b/gnu/libexec/uucp/libuucp/memcmp.c
deleted file mode 100644
index b61578a..0000000
--- a/gnu/libexec/uucp/libuucp/memcmp.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* memcmp.c
- Compare two memory buffers. */
-
-#include "uucp.h"
-
-int
-memcmp (p1arg, p2arg, c)
- constpointer p1arg;
- constpointer p2arg;
- size_t c;
-{
- const char *p1 = (const char *) p1arg;
- const char *p2 = (const char *) p2arg;
-
- while (c-- != 0)
- if (*p1++ != *p2++)
- return BUCHAR (*--p1) - BUCHAR (*--p2);
- return 0;
-}
diff --git a/gnu/libexec/uucp/libuucp/memcpy.c b/gnu/libexec/uucp/libuucp/memcpy.c
deleted file mode 100644
index 2258123..0000000
--- a/gnu/libexec/uucp/libuucp/memcpy.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/* memcpy.c
- Copy one memory buffer to another. */
-
-#include "uucp.h"
-
-pointer
-memcpy (ptoarg, pfromarg, c)
- pointer ptoarg;
- constpointer pfromarg;
- size_t c;
-{
- char *pto = (char *) ptoarg;
- const char *pfrom = (const char *) pfromarg;
-
- while (c-- != 0)
- *pto++ = *pfrom++;
- return ptoarg;
-}
diff --git a/gnu/libexec/uucp/libuucp/parse.c b/gnu/libexec/uucp/libuucp/parse.c
deleted file mode 100644
index 110c00a..0000000
--- a/gnu/libexec/uucp/libuucp/parse.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/* parse.c
- Parse a UUCP command string.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char parse_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-
-/* Parse a UUCP command string into an scmd structure. This is called
- by the 'g' protocol and the UNIX command file reading routines. It
- destroys the string it is passed, and the scmd string pointers are
- left pointing into it. For the convenience of the Unix work file
- routines, it will parse "P" into a simple 'P' command (representing
- a poll file). It returns TRUE if the string is successfully
- parsed, FALSE otherwise. */
-
-boolean
-fparse_cmd (zcmd, qcmd)
- char *zcmd;
- struct scmd *qcmd;
-{
- char *z, *zend;
-
- z = strtok (zcmd, " \t\n");
- if (z == NULL)
- return FALSE;
-
- qcmd->bcmd = *z;
- if (qcmd->bcmd != 'S'
- && qcmd->bcmd != 'R'
- && qcmd->bcmd != 'X'
- && qcmd->bcmd != 'E'
- && qcmd->bcmd != 'H'
- && qcmd->bcmd != 'P')
- return FALSE;
-
- qcmd->bgrade = '\0';
- qcmd->pseq = NULL;
- qcmd->zfrom = NULL;
- qcmd->zto = NULL;
- qcmd->zuser = NULL;
- qcmd->zoptions = NULL;
- qcmd->ztemp = NULL;
- qcmd->imode = 0666;
- qcmd->znotify = NULL;
- qcmd->cbytes = -1;
- qcmd->zcmd = NULL;
- qcmd->ipos = 0;
-
- /* Handle hangup commands specially. If it's just "H", return
- the command 'H' to indicate a hangup request. If it's "HY"
- return 'Y' and if it's "HN" return 'N'. */
- if (qcmd->bcmd == 'H')
- {
- if (z[1] != '\0')
- {
- if (z[1] == 'Y')
- qcmd->bcmd = 'Y';
- else if (z[1] == 'N')
- qcmd->bcmd = 'N';
- else
- return FALSE;
- }
-
- return TRUE;
- }
- if (qcmd->bcmd == 'P')
- return TRUE;
-
- if (z[1] != '\0')
- return FALSE;
-
- z = strtok ((char *) NULL, " \t\n");
- if (z == NULL)
- return FALSE;
- qcmd->zfrom = z;
-
- z = strtok ((char *) NULL, " \t\n");
- if (z == NULL)
- return FALSE;
- qcmd->zto = z;
-
- z = strtok ((char *) NULL, " \t\n");
- if (z == NULL)
- return FALSE;
- qcmd->zuser = z;
-
- z = strtok ((char *) NULL, " \t\n");
- if (z == NULL || *z != '-')
- return FALSE;
- qcmd->zoptions = z + 1;
-
- if (qcmd->bcmd == 'X')
- return TRUE;
-
- if (qcmd->bcmd == 'R')
- {
- z = strtok ((char *) NULL, " \t\n");
- if (z != NULL)
- {
- if (strcmp (z, "dummy") != 0)
- {
- /* This may be the maximum number of bytes the remote
- system wants to receive, if it using Taylor UUCP size
- negotiation. */
- qcmd->cbytes = strtol (z, &zend, 0);
- if (*zend != '\0')
- qcmd->cbytes = -1;
- }
- else
- {
- /* This is from an SVR4 system, and may include the
- position at which to start sending the file. The
- next fields are the mode bits, the remote owner (?),
- the remote temporary file name, and finally the
- restart position. */
- if (strtok ((char *) NULL, " \t\n") != NULL
- && strtok ((char *) NULL, " \t\n") != NULL
- && strtok ((char *) NULL, " \t\n") != NULL)
- {
- z = strtok ((char *) NULL, " \t\n");
- if (z != NULL)
- {
- qcmd->ipos = strtol (z, &zend, 0);
- if (*zend != '\0')
- qcmd->ipos = 0;
- }
- }
- }
- }
-
- return TRUE;
- }
-
- z = strtok ((char *) NULL, " \t\n");
- if (z == NULL)
- return FALSE;
- qcmd->ztemp = z;
-
- z = strtok ((char *) NULL, " \t\n");
- if (z == NULL)
- return FALSE;
- qcmd->imode = (int) strtol (z, &zend, 0);
- if (*zend != '\0')
- return FALSE;
-
- /* As a magic special case, if the mode came out as the decimal
- values 666 or 777, assume that they actually meant the octal
- values. Most systems use a leading zero, but a few do not.
- Since both 666 and 777 are greater than the largest legal mode
- value, which is 0777 == 511, this hack does not restrict any
- legal values. */
- if (qcmd->imode == 666)
- qcmd->imode = 0666;
- else if (qcmd->imode == 777)
- qcmd->imode = 0777;
-
- z = strtok ((char *) NULL, " \t\n");
- if (qcmd->bcmd == 'E' && z == NULL)
- return FALSE;
- qcmd->znotify = z;
-
- /* SVR4 UUCP will send the string "dummy" after the notify string
- but before the size. I do not know when it sends anything other
- than "dummy". Fortunately, it doesn't really hurt to not get the
- file size. */
- if (z != NULL && strcmp (z, "dummy") == 0)
- z = strtok ((char *) NULL, " \t\n");
-
- if (z != NULL)
- {
- z = strtok ((char *) NULL, " \t\n");
- if (z != NULL)
- {
- qcmd->cbytes = strtol (z, &zend, 0);
- if (*zend != '\0')
- qcmd->cbytes = -1;
- }
- else if (qcmd->bcmd == 'E')
- return FALSE;
-
- if (z != NULL)
- {
- z = strtok ((char *) NULL, "");
- if (z != NULL)
- z[strcspn (z, "\n")] = '\0';
- if (qcmd->bcmd == 'E' && z == NULL)
- return FALSE;
- qcmd->zcmd = z;
- }
- }
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libuucp/spool.c b/gnu/libexec/uucp/libuucp/spool.c
deleted file mode 100644
index 52223fb..0000000
--- a/gnu/libexec/uucp/libuucp/spool.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* spool.c
- See whether a filename is legal for the spool directory. */
-
-#include "uucp.h"
-
-#include <ctype.h>
-
-#include "uudefs.h"
-
-/* See whether a file is a spool file. Spool file names are specially
- crafted to hand around to other UUCP packages. They always begin
- with 'C', 'D' or 'X', and the second character is always a period.
- The remaining characters may be any printable characters, since
- they may include a grade set by another system. */
-
-boolean
-fspool_file (zfile)
- const char *zfile;
-{
- const char *z;
-
- if (*zfile != 'C' && *zfile != 'D' && *zfile != 'X')
- return FALSE;
- if (zfile[1] != '.')
- return FALSE;
- for (z = zfile + 2; *z != '\0'; z++)
- if (*z == '/' || ! isprint (BUCHAR (*z)) || isspace (BUCHAR (*z)))
- return FALSE;
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/libuucp/status.c b/gnu/libexec/uucp/libuucp/status.c
deleted file mode 100644
index 65e854e..0000000
--- a/gnu/libexec/uucp/libuucp/status.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* status.c
- Strings for status codes. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-
-/* Status strings. These must match enum tstatus_type. */
-
-#if USE_TRADITIONAL_STATUS
-
-const char *azStatus[] =
-{
- "SUCCESSFUL",
- "DEVICE FAILED",
- "DIAL FAILED",
- "LOGIN FAILED",
- "STARTUP FAILED",
- "CONVERSATION FAILED",
- "TALKING",
- "WRONG TIME TO CALL"
-};
-
-#else
-
-const char *azStatus[] =
-{
- "Conversation complete",
- "Port unavailable",
- "Dial failed",
- "Login failed",
- "Handshake failed",
- "Call failed",
- "Talking",
- "Wrong time to call"
-};
-
-#endif
diff --git a/gnu/libexec/uucp/libuucp/strcas.c b/gnu/libexec/uucp/libuucp/strcas.c
deleted file mode 100644
index 4bb2251..0000000
--- a/gnu/libexec/uucp/libuucp/strcas.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* strcas.c
- Compare two strings case insensitively. */
-
-#include "uucp.h"
-#include <ctype.h>
-
-int
-strcasecmp (z1, z2)
- const char *z1;
- const char *z2;
-{
- char b1, b2;
-
- while ((b1 = *z1++) != '\0')
- {
- b2 = *z2++;
- if (b2 == '\0')
- return 1;
- if (b1 != b2)
- {
- if (isupper (BUCHAR (b1)))
- b1 = tolower (BUCHAR (b1));
- if (isupper (BUCHAR (b2)))
- b2 = tolower (BUCHAR (b2));
- if (b1 != b2)
- return b1 - b2;
- }
- }
- if (*z2 == '\0')
- return 0;
- else
- return -1;
-}
diff --git a/gnu/libexec/uucp/libuucp/strchr.c b/gnu/libexec/uucp/libuucp/strchr.c
deleted file mode 100644
index ca8d8e9..0000000
--- a/gnu/libexec/uucp/libuucp/strchr.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* strchr.c
- Look for a character in a string. This works for a null byte. */
-
-#include "uucp.h"
-
-char *
-strchr (z, b)
- const char *z;
- int b;
-{
- b = (char) b;
- while (*z != b)
- if (*z++ == '\0')
- return NULL;
- return (char *) z;
-}
diff --git a/gnu/libexec/uucp/libuucp/strdup.c b/gnu/libexec/uucp/libuucp/strdup.c
deleted file mode 100644
index 231e35b..0000000
--- a/gnu/libexec/uucp/libuucp/strdup.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/* strdup.c
- Duplicate a string into memory. */
-
-#include "uucp.h"
-
-char *
-strdup (z)
- const char *z;
-{
- size_t csize;
- char *zret;
-
- csize = strlen (z) + 1;
- zret = malloc (csize);
- if (zret != NULL)
- memcpy (zret, z, csize);
- return zret;
-}
diff --git a/gnu/libexec/uucp/libuucp/strncs.c b/gnu/libexec/uucp/libuucp/strncs.c
deleted file mode 100644
index 6959d62..0000000
--- a/gnu/libexec/uucp/libuucp/strncs.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* strncs.c
- Compare two strings case insensitively up to a point. */
-
-#include "uucp.h"
-#include <ctype.h>
-
-int
-strncasecmp (z1, z2, c)
- const char *z1;
- const char *z2;
- size_t c;
-{
- char b1, b2;
-
- if (c == 0)
- return 0;
- while ((b1 = *z1++) != '\0')
- {
- b2 = *z2++;
- if (b2 == '\0')
- return 1;
- if (b1 != b2)
- {
- if (isupper (BUCHAR (b1)))
- b1 = tolower (BUCHAR (b1));
- if (isupper (BUCHAR (b2)))
- b2 = tolower (BUCHAR (b2));
- if (b1 != b2)
- return b1 - b2;
- }
- --c;
- if (c == 0)
- return 0;
- }
- if (*z2 == '\0')
- return 0;
- else
- return -1;
-}
diff --git a/gnu/libexec/uucp/libuucp/strrch.c b/gnu/libexec/uucp/libuucp/strrch.c
deleted file mode 100644
index a88e4b4..0000000
--- a/gnu/libexec/uucp/libuucp/strrch.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* strrch.c
- Look for the last occurrence of a character in a string. This is
- supposed to work for a null byte, although we never actually call
- it with one. */
-
-#include "uucp.h"
-
-char *
-strrchr (z, b)
- const char *z;
- int b;
-{
- char *zret;
-
- b = (char) b;
- zret = NULL;
- do
- {
- if (*z == b)
- zret = (char *) z;
- }
- while (*z++ != '\0');
- return zret;
-}
diff --git a/gnu/libexec/uucp/libuucp/strstr.c b/gnu/libexec/uucp/libuucp/strstr.c
deleted file mode 100644
index 2cf1097..0000000
--- a/gnu/libexec/uucp/libuucp/strstr.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place -
-Suite 330, Boston, MA 02111-1307, USA.
-
-This file was modified slightly by Ian Lance Taylor, May 1992, for
-Taylor UUCP. */
-
-#include "uucp.h"
-
-/* Return the first ocurrence of NEEDLE in HAYSTACK. */
-char *
-strstr (haystack, needle)
- const char *const haystack;
- const char *const needle;
-{
- register const char *const needle_end = strchr(needle, '\0');
- register const char *const haystack_end = strchr(haystack, '\0');
- register const size_t needle_len = needle_end - needle;
- register const size_t needle_last = needle_len - 1;
- register const char *begin;
-
- if (needle_len == 0)
- return (char *) haystack_end;
- if ((size_t) (haystack_end - haystack) < needle_len)
- return NULL;
-
- for (begin = &haystack[needle_last]; begin < haystack_end; ++begin)
- {
- register const char *n = &needle[needle_last];
- register const char *h = begin;
- do
- if (*h != *n)
- goto loop;
- while (--n >= needle && --h >= haystack);
-
- return (char *) h;
- loop:;
- }
-
- return NULL;
-}
diff --git a/gnu/libexec/uucp/libuucp/strtol.c b/gnu/libexec/uucp/libuucp/strtol.c
deleted file mode 100644
index 0c6b28c..0000000
--- a/gnu/libexec/uucp/libuucp/strtol.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place -
-Suite 330, Boston, MA 02111-1307, USA.
-
-This file was modified slightly by Ian Lance Taylor, May 1992, for
-Taylor UUCP. */
-
-#include "uucp.h"
-
-#include <ctype.h>
-#include <errno.h>
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#else
-#define ULONG_MAX 4294967295
-#define LONG_MIN (- LONG_MAX - 1)
-#define LONG_MAX 2147483647
-#endif
-
-#ifndef UNSIGNED
-#define UNSIGNED 0
-#endif
-
-/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
- If BASE is 0 the base is determined by the presence of a leading
- zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
- If BASE is < 2 or > 36, it is reset to 10.
- If ENDPTR is not NULL, a pointer to the character after the last
- one converted is stored in *ENDPTR. */
-#if UNSIGNED
-unsigned long int
-#define strtol strtoul
-#else
-long int
-#endif
-strtol (nptr, endptr, base)
- const char *nptr;
- char **endptr;
- int base;
-{
- int negative;
- register unsigned long int cutoff;
- register unsigned int cutlim;
- register unsigned long int i;
- register const char *s;
- register unsigned int c;
- const char *save;
- int overflow;
-
- if (base < 0 || base == 1 || base > 36)
- base = 10;
-
- s = nptr;
-
- /* Skip white space. */
- while (isspace(BUCHAR (*s)))
- ++s;
- if (*s == '\0')
- goto noconv;
-
- /* Check for a sign. */
- if (*s == '-')
- {
- negative = 1;
- ++s;
- }
- else if (*s == '+')
- {
- negative = 0;
- ++s;
- }
- else
- negative = 0;
-
- if (base == 16
- && s[0] == '0'
- && (s[1] == 'x' || s[1] == 'X'))
- s += 2;
-
- /* If BASE is zero, figure it out ourselves. */
- if (base == 0)
- if (*s == '0')
- {
- if (s[1] == 'x' || s[1] == 'X')
- {
- s += 2;
- base = 16;
- }
- else
- base = 8;
- }
- else
- base = 10;
-
- /* Save the pointer so we can check later if anything happened. */
- save = s;
-
- cutoff = ULONG_MAX / (unsigned long int) base;
- cutlim = ULONG_MAX % (unsigned long int) base;
-
- overflow = 0;
- i = 0;
- for (c = BUCHAR (*s); c != '\0'; c = BUCHAR (*++s))
- {
- if (isdigit(c))
- c -= '0';
- else if (islower(c))
- c = c - 'a' + 10;
- else if (isupper(c))
- c = c - 'A' + 10;
- else
- break;
- if (c >= base)
- break;
- /* Check for overflow. */
- if (i > cutoff || (i == cutoff && c > cutlim))
- overflow = 1;
- else
- {
- i *= (unsigned long int) base;
- i += c;
- }
- }
-
- /* Check if anything actually happened. */
- if (s == save)
- goto noconv;
-
- /* Store in ENDPTR the address of one character
- past the last character we converted. */
- if (endptr != NULL)
- *endptr = (char *) s;
-
-#if !UNSIGNED
- /* Check for a value that is within the range of
- `unsigned long int', but outside the range of `long int'. */
- if (i > (negative ?
- - (unsigned long int) LONG_MIN : (unsigned long int) LONG_MAX))
- overflow = 1;
-#endif
-
- if (overflow)
- {
- errno = ERANGE;
-#if UNSIGNED
- return ULONG_MAX;
-#else
- return negative ? LONG_MIN : LONG_MAX;
-#endif
- }
-
- /* Return the result of the appropriate sign. */
- return (negative ? - i : i);
-
- noconv:
- /* There was no number to convert. */
- if (endptr != NULL)
- *endptr = (char *) nptr;
- return 0L;
-}
diff --git a/gnu/libexec/uucp/libuucp/strtou.c b/gnu/libexec/uucp/libuucp/strtou.c
deleted file mode 100644
index d3c8189..0000000
--- a/gnu/libexec/uucp/libuucp/strtou.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place -
-Suite 330, Boston, MA 02111-1307, USA. */
-
-#define UNSIGNED 1
-
-#include "lib/strtol.c"
diff --git a/gnu/libexec/uucp/libuucp/xfree.c b/gnu/libexec/uucp/libuucp/xfree.c
deleted file mode 100644
index 239b015..0000000
--- a/gnu/libexec/uucp/libuucp/xfree.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/* xfree.c
- Some versions of free (like the one in SCO Unix 3.2.2) don't handle
- null pointers correctly, so we go through our own routine. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-
-void
-xfree (p)
- pointer p;
-{
- if (p != NULL)
- free (p);
-}
diff --git a/gnu/libexec/uucp/libuucp/xmall.c b/gnu/libexec/uucp/libuucp/xmall.c
deleted file mode 100644
index 4aac237..0000000
--- a/gnu/libexec/uucp/libuucp/xmall.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/* xmalloc.c
- Allocate a block of memory without fail. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-
-pointer
-xmalloc (c)
- size_t c;
-{
- pointer pret;
-
- pret = malloc (c);
- if (pret == NULL && c != 0)
- ulog (LOG_FATAL, "Out of memory");
- return pret;
-}
diff --git a/gnu/libexec/uucp/libuucp/xreall.c b/gnu/libexec/uucp/libuucp/xreall.c
deleted file mode 100644
index 36ae313..0000000
--- a/gnu/libexec/uucp/libuucp/xreall.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* xreall.c
- Realloc a block of memory without fail. Supposedly some versions of
- realloc can't handle a NULL first argument, so we check for that
- here. */
-
-#include "uucp.h"
-
-#include "uudefs.h"
-
-pointer
-xrealloc (p, c)
- pointer p;
- size_t c;
-{
- pointer pret;
-
- if (p == NULL)
- return xmalloc (c);
- pret = realloc (p, c);
- if (pret == NULL && c != 0)
- ulog (LOG_FATAL, "Out of memory");
- return pret;
-}
diff --git a/gnu/libexec/uucp/sample/Makefile b/gnu/libexec/uucp/sample/Makefile
deleted file mode 100644
index 8970172..0000000
--- a/gnu/libexec/uucp/sample/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id$
-
-FILES= call.sample config.sample dial.sample dialcode.sample passwd.sample \
- port.sample sys1.sample sys2.sample
-
-NOOBJ= noobj
-
-BINOWN= $(owner)
-BINGRP= $(group)
-
-all clean cleandir depend lint tags:
-
-install:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 440 ${FILES} \
- ${DESTDIR}/etc/uucp
-
-.include <bsd.prog.mk>
diff --git a/gnu/libexec/uucp/sample/call.sample b/gnu/libexec/uucp/sample/call.sample
deleted file mode 100644
index de4190c..0000000
--- a/gnu/libexec/uucp/sample/call.sample
+++ /dev/null
@@ -1,20 +0,0 @@
-# This is an example of call, the call out password file for Taylor
-# UUCP. To use it, you must compile the package with
-# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy
-# this file to newconfigdir as set in Makefile.in (the default is
-# /usr/local/conf/uucp), and edit it as appropriate for your system.
-
-# Everything after a '#' character is a comment. To uncomment any of
-# the sample lines below, just delete the '#'.
-
-# This file is used when the ``call-login'' or ``call-password''
-# commands are used in the sys file with a "*" argument (e.g.,
-# ``call-login *''). The system name is looked up in this file, and
-# the login name and password are used.
-
-# The point of this is that the sys file may then be publically
-# readable, while still concealing the login names and passwords used
-# to connect to the remote system.
-
-# The format is just system-name login-name password.
-uunet Uairs foobar
diff --git a/gnu/libexec/uucp/sample/config.sample b/gnu/libexec/uucp/sample/config.sample
deleted file mode 100644
index e7d683b..0000000
--- a/gnu/libexec/uucp/sample/config.sample
+++ /dev/null
@@ -1,88 +0,0 @@
-# This is an example of config, the main configuration file for Taylor
-# UUCP. To use it, you must compile the package with
-# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy
-# this file to newconfigdir as set in Makefile.in (the default is
-# /usr/local/conf/uucp), and edit it as appropriate for your system.
-
-# You need not use this file at all; all the important commands have
-# defaults which will be used if this file can not be found.
-
-# Everything after a '#' character is a comment. To uncomment any of
-# the sample lines below, just delete the '#'.
-
-# You must choose a UUCP name. If your system is going to be
-# communicating with other systems outside your organization, the name
-# must be unique in the entire world. The usual method is to pick a
-# name, and then search the UUCP maps (in the newsgroup
-# comp.mail.maps) to see whether it has already been taken. See the
-# README posting in comp.mail.maps for more information. If the name
-# of your system as returned by "uuname -n" or "hostname" is the name
-# you want to use, you do not need to set the name in this file.
-# Otherwise uncomment and edit the following line.
-# nodename uucp # The UUCP name of this system
-
-# The default spool directory is set in policy.h (the default is
-# /usr/spool/uucp). All UUCP jobs and status information are kept in
-# the spool directory. If you wish to change it, use the spool
-# command.
-# spool /usr/spool/uucp # The UUCP spool directory
-
-# The default public directory is set in policy.h (the default is
-# /usr/spool/uucppublic). Remote systems may refer to a file in this
-# directory using "~/FILE". By default, the public directory is the
-# only directory which remote systems may transfer files in and out
-# of. If you wish to change the public directory, use the pubdir
-# command.
-# pubdir /usr/spool/uucppublic # The UUCP public directory
-
-# The names of the UUCP log files are set in policy.h. The default
-# names depend on the logging option you have chosen. If
-# HAVE_TAYLOR_LOGGING is set in policy.h, the default log file name is
-# /usr/spool/uucp/Log, the default statistics file name is
-# /usr/spool/uucp/Stats, and the default debugging file name is
-# /usr/spool/uucp/Debug. These file names may be set by the following
-# commands.
-# logfile /usr/spool/uucp/Log # The UUCP log file
-# statfile /usr/spool/uucp/Stats # The UUCP statistics file
-# debugfile /usr/spool/uucp/Debug # The UUCP debugging file
-
-# uuxqt is the program which executes UUCP requests from other
-# systems. Normally one is started after each run of uucico, the
-# communications daemon. You may control the maximum number of uuxqt
-# programs run at the same time with the following command. The
-# default is to have no maximum.
-# max-uuxqts 1 # The maximum number of uuxqts
-
-# There are several files that uucico uses. By default it looks for
-# them in newconfigdir, as set in Makefile.in. You may name one or
-# more of each type of file using the following commands.
-# sysfile FILES # Default "sys"
-# portfile FILES # Default "port"
-# dialfile FILES # Default "dial"
-# dialcodefile FILES # Default "dialcode"
-# callfile FILES # Default "call"
-# passwdfile FILES # Default "passwd"
-
-# The ``timetable'' command may be used to declare timetables. These
-# may then be referred to in time strings in the other files.
-# timetable Day Wk0905-1655
-
-# The ``unknown'' command is followed by any command which may appear
-# in a sys file. These commands are taken together to describe what
-# is permitted to a system which is not listed in any sys file. If
-# the ``unknown'' command, then unknown systems are not permitted to
-# connect.
-
-# Here is an example which permits unknown systems to download files
-# from /usr/spool/anonymous, and to upload them to
-# /usr/spool/anonymous/upload.
-#
-# No commands may be executed (the list of permitted commands is empty)
-# unknown commands
-# The public directory is /usr/spool/anonymous
-# unknown pubdir /usr/spool/anonymous
-# Only files in the public directory may be sent; users may not download
-# files from the upload directory
-# unknown remote-send ~ !~/upload
-# May only upload files into /usr/spool/anonymous/upload
-# unknown remote-receive ~/upload
diff --git a/gnu/libexec/uucp/sample/dial.sample b/gnu/libexec/uucp/sample/dial.sample
deleted file mode 100644
index 7eb0087..0000000
--- a/gnu/libexec/uucp/sample/dial.sample
+++ /dev/null
@@ -1,39 +0,0 @@
-# This is an example of dial, the dialer configuration file for Taylor
-# UUCP. To use it, you must compile the package with
-# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy
-# this file to newconfigdir as set in Makefile.in (the default is
-# /usr/local/conf/uucp), and edit it as appropriate for your system.
-
-# Everything after a '#' character is a comment. To uncomment any of
-# the sample lines below, just delete the '#'.
-
-# All dialers named in the port (or sys) file must be described in the
-# dial file. It is also possible to describe a dialer directly in the
-# port (or sys) file.
-
-# This is a typical Hayes modem definition.
-dialer hayes
-
-# The chat script used to dial the phone.
-# This means:
-# 1) expect nothing (i.e., continue with step 2)
-# 2) send "ATZ", then a carriage return, then sleep for 1 to 2
-# seconds. The \c means to not send a final carriage return.
-# 3) wait until the modem echoes "OK"
-# 4) send "ATDT", then the telephone number (after translating any
-# dialcodes).
-# 5) wait until the modem echoes "CONNECT"
-# 6) Wait a little more, if your modem give CONNECT before carrier up
-chat "" ATZ\r\d\c OK ATDT\T CONNECT \p\c
-
-# If we get "BUSY" or "NO CARRIER" during the dial chat script we
-# abort the dial immediately.
-chat-fail BUSY
-chat-fail ERROR
-chat-fail NO\sDIALTONE
-chat-fail NO\sCARRIER
-
-# When the call is over, we make sure we hangup the modem.
-# You don't need this stuff, if you modem can handle DTR drop properly
-complete \d\d+++\d\dATH\r\c
-abort \d\d+++\d\dATH\r\c
diff --git a/gnu/libexec/uucp/sample/dialcode.sample b/gnu/libexec/uucp/sample/dialcode.sample
deleted file mode 100644
index 710a07b..0000000
--- a/gnu/libexec/uucp/sample/dialcode.sample
+++ /dev/null
@@ -1,19 +0,0 @@
-# This is an example of dialcode, the dialcode configuration file for
-# Taylor UUCP. To use it, you must compile the package with
-# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy
-# this file to newconfigdir as set in Makefile.in (the default is
-# /usr/local/conf/uucp), and edit it as appropriate for your system.
-
-# Everything after a '#' character is a comment. To uncomment any of
-# the sample lines below, just delete the '#'.
-
-# The dialcode file is used if \T is used in the dialer chat script
-# and the telephone number begins with alphabetic characters. The
-# alphabetic characters are looked up and translated in dialcode.
-
-# Here are a couple of sample dialcodes.
-MA 617
-CA 415
-
-# For example, if the phone number (from the sys file) is MA7389449,
-# then the string sent to the modem will be 6177389449.
diff --git a/gnu/libexec/uucp/sample/passwd.sample b/gnu/libexec/uucp/sample/passwd.sample
deleted file mode 100644
index 2b04e13..0000000
--- a/gnu/libexec/uucp/sample/passwd.sample
+++ /dev/null
@@ -1,18 +0,0 @@
-# This is an example of passwd, the call in password file for Taylor
-# UUCP. To use it, you must compile the package with
-# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy
-# this file to newconfigdir as set in Makefile.in (the default is
-# /usr/local/conf/uucp), and edit it as appropriate for your system.
-
-# Everything after a '#' character is a comment. To uncomment any of
-# the sample lines below, just delete the '#'.
-
-# This file is used when uucico is invoked with the -l or -e argument.
-# uucico will then prompt for a login name and password. The login
-# name is looked up in this file to check the password (the system
-# password file, /etc/passwd, is not checked). This permits uucico to
-# completely take over a port, allowing UUCP access to remote systems
-# but not permitting remote users to actually log in to the system.
-
-# The format is just login-name password.
-Uairs foobar
diff --git a/gnu/libexec/uucp/sample/port.sample b/gnu/libexec/uucp/sample/port.sample
deleted file mode 100644
index 8e48186..0000000
--- a/gnu/libexec/uucp/sample/port.sample
+++ /dev/null
@@ -1,41 +0,0 @@
-# This is an example of port, the port configuration file for Taylor
-# UUCP. To use it, you must compile the package with
-# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy
-# this file to newconfigdir as set in Makefile.in (the default is
-# /usr/local/conf/uucp), and edit it as appropriate for your system.
-
-# Everything after a '#' character is a comment. To uncomment any of
-# the sample lines below, just delete the '#'.
-
-# All ports named in the sys file must be described in a port file.
-# It is also possible to describe the port directly in the sys file.
-
-# Commands that appears before the first ``port'' command are defaults
-# for all ports that appear later in the file. In this case all ports
-# will default to being modems (other possible types are direct, tcp
-# and tli).
-type modem
-
-# Now we describe two ports.
-
-# This is the name of the port. This name may be used in the sys file
-# to select the port, or the sys file may just specify a baud rate in
-# which case the first matching unlocked port will be used.
-port port1
-
-# This is the device name to open to dial out.
-device /dev/ttyd0
-
-# This is the dialer to use, as described in the dialer file.
-dialer hayes
-
-# This is the baud rate to dial out at.
-speed 2400
-
-# Here is a second port. This is like the first, except that it uses
-# a different device. It also permits a range of speeds, which is
-# mainly useful if the system specifies a particular baud rate.
-port port2
-device /dev/ttyd1
-dialer hayes
-speed-range 2400 9600
diff --git a/gnu/libexec/uucp/sample/sys1.sample b/gnu/libexec/uucp/sample/sys1.sample
deleted file mode 100644
index fa9e770..0000000
--- a/gnu/libexec/uucp/sample/sys1.sample
+++ /dev/null
@@ -1,44 +0,0 @@
-# This is an example of a sys file, the file(s) which describe remote
-# systems for Taylor UUCP. To use it, you must compile the package
-# with HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default),
-# copy this file to newconfigdir as set in Makefile.in (the default is
-# /usr/local/conf/uucp), and edit it as appropriate for your system.
-
-# If you do not use the ``unknown'' command in the config file, then
-# each system that you communicate with must be listed in a sys file.
-
-# Everything after a '#' character is a comment. To uncomment any of
-# the sample lines below, just delete the '#'.
-
-# This is a sample sys file that might be used in a leaf system. A
-# leaf system is one that only contacts one other system. sys2
-# provides another example.
-
-# The name of the remote system that we call.
-system uunet
-
-# The login name and password are kept in the callout password file
-# (by default this is the file "call" in newconfigdir).
-call-login *
-call-password *
-
-# We can send anything at any time.
-time any
-
-# During the day we only accept grade 'Z' or above; at other times
-# (not mentioned here) we accept all grades. uunet queues up news
-# at grade 'd', which is lower than 'Z'.
-call-timegrade Z Wk0755-2305,Su1655-2305
-
-# The phone number to call.
-phone 7389449
-
-# uunet tends to be slow, so we increase the timeout
-chat-timeout 120
-
-# The port we use to dial out.
-port serial
-
-# Increase the timeout and the number of retries.
-protocol-parameter g timeout 20
-protocol-parameter g retries 10
diff --git a/gnu/libexec/uucp/sample/sys2.sample b/gnu/libexec/uucp/sample/sys2.sample
deleted file mode 100644
index 856529a..0000000
--- a/gnu/libexec/uucp/sample/sys2.sample
+++ /dev/null
@@ -1,51 +0,0 @@
-# This is an example of a sys file, the file(s) which describe remote
-# systems for Taylor UUCP. To use it, you must compile the package
-# with HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default),
-# copy this file to newconfigdir as set in Makefile.in (the default is
-# /usr/local/conf/uucp), and edit it as appropriate for your system.
-
-# If you do not use the ``unknown'' command in the config file, then
-# each system that you communicate with must be listed in a sys file.
-
-# Everything after a '#' character is a comment. To uncomment any of
-# the sample lines below, just delete the '#'.
-
-# This is a sample sys file that might be used by a system that
-# contacts a couple of other systems, both of which are treated the
-# same. sys1 provides another example.
-
-# Commands that appear before the first ``system'' commands are
-# defaults for all systems listed in the file.
-
-# Get the login name and password to use from the call-out file. By
-# default this is the file "call" in newconfigdir.
-call-login *
-call-password *
-
-# The systems must use a particular login
-called-login Ulocal
-
-# Permit local users to send any world readable file
-local-send /
-
-# Permit local uses to request into any world writable directory
-local-receive /
-
-# Call at any time
-time any
-
-# Use port1, then port2
-port port1
-
-alternate
-
-port port2
-
-# Now define the systems themselves. Because of all the defaults we
-# used, there is very little to specify for the systems themselves.
-
-system comton
-phone 5551212
-
-system bugs
-phone 5552424
diff --git a/gnu/libexec/uucp/tstuu.c b/gnu/libexec/uucp/tstuu.c
deleted file mode 100644
index 60aa089..0000000
--- a/gnu/libexec/uucp/tstuu.c
+++ /dev/null
@@ -1,1603 +0,0 @@
-/* tstuu.c
- Test the uucp package on a UNIX system.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char tstuu_rcsid[] = "$Id$";
-#endif
-
-#include "sysdep.h"
-#include "system.h"
-#include "getopt.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
-
-#if HAVE_SYS_TIMES_H
-#include <sys/times.h>
-#endif
-
-#if HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-#if HAVE_SELECT
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#if HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-#endif
-
-#if HAVE_POLL
-#if HAVE_STROPTS_H
-#include <stropts.h>
-#endif
-#if HAVE_POLL_H
-#include <poll.h>
-#endif
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#endif
-
-#if HAVE_TIME_H
-#if ! HAVE_SYS_TIME_H || ! HAVE_SELECT || TIME_WITH_SYS_TIME
-#include <time.h>
-#endif
-#endif
-
-#if HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#if HAVE_UNION_WAIT
-typedef union wait wait_status;
-#else
-typedef int wait_status;
-#endif
-
-#if HAVE_STREAMS_PTYS
-#include <termio.h>
-extern char *ptsname ();
-#endif
-
-/* Get definitions for both O_NONBLOCK and O_NDELAY. */
-
-#ifndef O_NDELAY
-#ifdef FNDELAY
-#define O_NDELAY FNDELAY
-#else /* ! defined (FNDELAY) */
-#define O_NDELAY 0
-#endif /* ! defined (FNDELAY) */
-#endif /* ! defined (O_NDELAY) */
-
-#ifndef O_NONBLOCK
-#ifdef FNBLOCK
-#define O_NONBLOCK FNBLOCK
-#else /* ! defined (FNBLOCK) */
-#define O_NONBLOCK 0
-#endif /* ! defined (FNBLOCK) */
-#endif /* ! defined (O_NONBLOCK) */
-
-#if O_NDELAY == 0 && O_NONBLOCK == 0
- #error No way to do nonblocking I/O
-#endif
-
-/* Get definitions for EAGAIN, EWOULDBLOCK and ENODATA. */
-#ifndef EAGAIN
-#ifndef EWOULDBLOCK
-#define EAGAIN (-1)
-#define EWOULDBLOCK (-1)
-#else /* defined (EWOULDBLOCK) */
-#define EAGAIN EWOULDBLOCK
-#endif /* defined (EWOULDBLOCK) */
-#else /* defined (EAGAIN) */
-#ifndef EWOULDBLOCK
-#define EWOULDBLOCK EAGAIN
-#endif /* ! defined (EWOULDBLOCK) */
-#endif /* defined (EAGAIN) */
-
-#ifndef ENODATA
-#define ENODATA EAGAIN
-#endif
-
-/* Make sure we have a CLK_TCK definition, even if it makes no sense.
- This is in case TIMES_TICK is defined as CLK_TCK. */
-#ifndef CLK_TCK
-#define CLK_TCK (60)
-#endif
-
-/* Don't try too hard to get a TIMES_TICK value; it doesn't matter
- that much. */
-#if TIMES_TICK == 0
-#undef TIMES_TICK
-#define TIMES_TICK CLK_TCK
-#endif
-
-#if TIMES_DECLARATION_OK
-extern long times ();
-#endif
-
-#ifndef SIGCHLD
-#define SIGCHLD SIGCLD
-#endif
-
-#if 1
-#define ZUUCICO_CMD "login uucp"
-#define UUCICO_EXECL "/bin/login", "login", "uucp"
-#else
-#define ZUUCICO_CMD "su - nuucp"
-#define UUCICO_EXECL "/bin/su", "su", "-", "nuucp"
-#endif
-
-#if ! HAVE_SELECT && ! HAVE_POLL
- #error You need select or poll
-#endif
-
-#if ! HAVE_REMOVE
-#undef remove
-#define remove unlink
-#endif
-
-/* Buffer chain to hold data read from a uucico. */
-
-#define BUFCHARS (512)
-
-struct sbuf
-{
- struct sbuf *qnext;
- int cstart;
- int cend;
- char ab[BUFCHARS];
-};
-
-/* Local functions. */
-
-static void umake_file P((const char *zfile, int cextra));
-static void uprepare_test P((boolean fmake, int itest,
- boolean fcall_uucico,
- const char *zsys));
-static void ucheck_file P((const char *zfile, const char *zerr,
- int cextra));
-static void ucheck_test P((int itest, boolean fcall_uucico));
-static RETSIGTYPE uchild P((int isig));
-static int cpshow P((char *z, int bchar));
-static void uchoose P((int *po1, int *po2));
-static long cread P((int o, struct sbuf **));
-static boolean fsend P((int o, int oslave, struct sbuf **));
-static boolean fwritable P((int o));
-static void xsystem P((const char *zcmd));
-static FILE *xfopen P((const char *zname, const char *zmode));
-
-static char *zDebug;
-static int iTest;
-static boolean fCall_uucico;
-static int iPercent;
-static pid_t iPid1, iPid2;
-static int cFrom1, cFrom2;
-static char abLogout1[sizeof "tstout /dev/ptyp0"];
-static char abLogout2[sizeof "tstout /dev/ptyp0"];
-static char *zProtocols;
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int iopt;
- const char *zcmd1, *zcmd2;
- const char *zsys;
- boolean fmake = TRUE;
- int omaster1, oslave1, omaster2, oslave2;
- char abpty1[sizeof "/dev/ptyp0"];
- char abpty2[sizeof "/dev/ptyp0"];
- struct sbuf *qbuf1, *qbuf2;
-
-#if ! HAVE_TAYLOR_CONFIG
- fprintf (stderr, "%s: only works when compiled with HAVE_TAYLOR_CONFIG\n",
- argv[0]);
- exit (1);
-#endif
-
- zcmd1 = NULL;
- zcmd2 = NULL;
- zsys = "test2";
-
- while ((iopt = getopt (argc, argv, "c:np:s:t:ux:1:2:")) != EOF)
- {
- switch (iopt)
- {
- case 'c':
- zProtocols = optarg;
- break;
- case 'n':
- fmake = FALSE;
- break;
- case 'p':
- iPercent = (int) strtol (optarg, (char **) NULL, 10);
- srand ((unsigned int) ixsysdep_time ((long *) NULL));
- break;
- case 's':
- zsys = optarg;
- break;
- case 't':
- iTest = (int) strtol (optarg, (char **) NULL, 10);
- break;
- case 'u':
- fCall_uucico = TRUE;
- break;
- case 'x':
- zDebug = optarg;
- break;
- case '1':
- zcmd1 = optarg;
- break;
- case '2':
- zcmd2 = optarg;
- break;
- default:
- fprintf (stderr,
- "Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- fprintf (stderr,
- "Usage: tstuu [-xn] [-t #] [-u] [-1 cmd] [-2 cmd]\n");
- exit (EXIT_FAILURE);
- }
- }
-
- if (fCall_uucico && zcmd2 == NULL)
- zcmd2 = ZUUCICO_CMD;
-
- uprepare_test (fmake, iTest, fCall_uucico, zsys);
-
- (void) remove ("/usr/tmp/tstuu/spool1/core");
- (void) remove ("/usr/tmp/tstuu/spool2/core");
-
- omaster1 = -1;
- oslave1 = -1;
- omaster2 = -1;
- oslave2 = -1;
-
-#if ! HAVE_STREAMS_PTYS
-
- {
- char *zptyname;
- const char *zpty;
-
- zptyname = abpty1;
-
- for (zpty = "pqrs"; *zpty != '\0'; ++zpty)
- {
- int ipty;
-
- for (ipty = 0; ipty < 16; ipty++)
- {
- int om, os;
- FILE *e;
-
- sprintf (zptyname, "/dev/pty%c%c", *zpty,
- "0123456789abcdef"[ipty]);
- om = open (zptyname, O_RDWR);
- if (om < 0)
- continue;
- zptyname[5] = 't';
- os = open (zptyname, O_RDWR);
- if (os < 0)
- {
- (void) close (om);
- continue;
- }
-
- if (omaster1 == -1)
- {
- omaster1 = om;
- oslave1 = os;
-
- e = fopen ("/usr/tmp/tstuu/pty1", "w");
- if (e == NULL)
- {
- perror ("fopen");
- exit (EXIT_FAILURE);
- }
- fprintf (e, "%s", zptyname + 5);
- if (fclose (e) != 0)
- {
- perror ("fclose");
- exit (EXIT_FAILURE);
- }
-
- zptyname = abpty2;
- }
- else
- {
- omaster2 = om;
- oslave2 = os;
-
- e = fopen ("/usr/tmp/tstuu/pty2", "w");
- if (e == NULL)
- {
- perror ("fopen");
- exit (EXIT_FAILURE);
- }
- fprintf (e, "%s", zptyname + 5);
- if (fclose (e) != 0)
- {
- perror ("fclose");
- exit (EXIT_FAILURE);
- }
- break;
- }
- }
-
- if (omaster1 != -1 && omaster2 != -1)
- break;
- }
- }
-
-#else /* HAVE_STREAMS_PTYS */
-
- {
- int ipty;
-
- for (ipty = 0; ipty < 2; ipty++)
- {
- int om, os;
- FILE *e;
- char *znam;
- struct termio stio;
-
- om = open ((char *) "/dev/ptmx", O_RDWR);
- if (om < 0)
- break;
- znam = ptsname (om);
- if (znam == NULL)
- break;
- if (unlockpt (om) != 0
- || grantpt (om) != 0)
- break;
-
- os = open (znam, O_RDWR);
- if (os < 0)
- {
- (void) close (om);
- om = -1;
- break;
- }
-
- if (ioctl (os, I_PUSH, "ptem") < 0
- || ioctl(os, I_PUSH, "ldterm") < 0)
- {
- perror ("ioctl");
- exit (EXIT_FAILURE);
- }
-
- /* Can this really be right? */
- memset (&stio, 0, sizeof (stio));
- stio.c_cflag = B9600 | CS8 | CREAD | HUPCL;
-
- if (ioctl(os, TCSETA, &stio) < 0)
- {
- perror ("TCSETA");
- exit (EXIT_FAILURE);
- }
-
- if (omaster1 == -1)
- {
- strcpy (abpty1, znam);
- omaster1 = om;
- oslave1 = os;
- e = fopen ("/usr/tmp/tstuu/pty1", "w");
- if (e == NULL)
- {
- perror ("fopen");
- exit (EXIT_FAILURE);
- }
- fprintf (e, "%s", znam + 5);
- if (fclose (e) != 0)
- {
- perror ("fclose");
- exit (EXIT_FAILURE);
- }
- }
- else
- {
- strcpy (abpty2, znam);
- omaster2 = om;
- oslave2 = os;
- e = fopen ("/usr/tmp/tstuu/pty2", "w");
- if (e == NULL)
- {
- perror ("fopen");
- exit (EXIT_FAILURE);
- }
- fprintf (e, "%s", znam + 5);
- if (fclose (e) != 0)
- {
- perror ("fclose");
- exit (EXIT_FAILURE);
- }
- }
- }
- }
-
-#endif /* HAVE_STREAMS_PTYS */
-
- if (omaster2 == -1)
- {
- fprintf (stderr, "No pseudo-terminals available\n");
- exit (EXIT_FAILURE);
- }
-
- /* Make sure we can or these into an int for the select call. Most
- systems could use 31 instead of 15, but it should never be a
- problem. */
- if (omaster1 > 15 || omaster2 > 15)
- {
- fprintf (stderr, "File descriptors are too large\n");
- exit (EXIT_FAILURE);
- }
-
- /* Prepare to log out the command if it is a login command. On
- Ultrix 4.0 uucico can only be run from login for some reason. */
-
- if (zcmd1 == NULL
- || strncmp (zcmd1, "login", sizeof "login" - 1) != 0)
- abLogout1[0] = '\0';
- else
- sprintf (abLogout1, "tstout %s", abpty1);
-
- if (zcmd2 == NULL
- || strncmp (zcmd2, "login", sizeof "login" - 1) != 0)
- abLogout2[0] = '\0';
- else
- sprintf (abLogout2, "tstout %s", abpty2);
-
- iPid1 = fork ();
- if (iPid1 < 0)
- {
- perror ("fork");
- exit (EXIT_FAILURE);
- }
- else if (iPid1 == 0)
- {
- if (close (0) < 0
- || close (1) < 0
- || close (omaster1) < 0
- || close (omaster2) < 0
- || close (oslave2) < 0)
- perror ("close");
-
- if (dup2 (oslave1, 0) < 0
- || dup2 (oslave1, 1) < 0)
- perror ("dup2");
-
- if (close (oslave1) < 0)
- perror ("close");
-
- /* This is said to improve the tests on Linux. */
- sleep (3);
-
- if (zDebug != NULL)
- fprintf (stderr, "About to exec first process\n");
-
- if (zcmd1 != NULL)
- exit (system ((char *) zcmd1));
- else
- {
- (void) execl ("uucico", "uucico", "-I", "/usr/tmp/tstuu/Config1",
- "-q", "-S", zsys, "-pstdin", (const char *) NULL);
- perror ("execl failed");
- exit (EXIT_FAILURE);
- }
- }
-
- iPid2 = fork ();
- if (iPid2 < 0)
- {
- perror ("fork");
- kill (iPid1, SIGTERM);
- exit (EXIT_FAILURE);
- }
- else if (iPid2 == 0)
- {
- if (close (0) < 0
- || close (1) < 0
- || close (omaster1) < 0
- || close (oslave1) < 0
- || close (omaster2) < 0)
- perror ("close");
-
- if (dup2 (oslave2, 0) < 0
- || dup2 (oslave2, 1) < 0)
- perror ("dup2");
-
- if (close (oslave2) < 0)
- perror ("close");
-
- /* This is said to improve the tests on Linux. */
- sleep (5);
-
- if (zDebug != NULL)
- fprintf (stderr, "About to exec second process\n");
-
- if (fCall_uucico)
- {
- (void) execl (UUCICO_EXECL, (const char *) NULL);
- perror ("execl failed");
- exit (EXIT_FAILURE);
- }
- else if (zcmd2 != NULL)
- exit (system ((char *) zcmd2));
- else
- {
- (void) execl ("uucico", "uucico", "-I", "/usr/tmp/tstuu/Config2",
- "-lq", (const char *)NULL);
- perror ("execl failed");
- exit (EXIT_FAILURE);
- }
- }
-
- signal (SIGCHLD, uchild);
-
- if (fcntl (omaster1, F_SETFL, O_NDELAY | O_NONBLOCK) < 0
- && errno == EINVAL)
- (void) fcntl (omaster1, F_SETFL, O_NONBLOCK);
- if (fcntl (omaster2, F_SETFL, O_NDELAY | O_NONBLOCK) < 0
- && errno == EINVAL)
- (void) fcntl (omaster2, F_SETFL, O_NONBLOCK);
-
- qbuf1 = NULL;
- qbuf2 = NULL;
-
- while (TRUE)
- {
- int o1, o2;
- boolean fcont;
-
- o1 = omaster1;
- o2 = omaster2;
- uchoose (&o1, &o2);
-
- if (o1 == -1 && o2 == -1)
- {
- if (zDebug != NULL)
- fprintf (stderr, "Five second pause\n");
- continue;
- }
-
- if (o1 != -1)
- cFrom1 += cread (omaster1, &qbuf1);
-
- if (o2 != -1)
- cFrom2 += cread (omaster2, &qbuf2);
-
- do
- {
- fcont = FALSE;
-
- if (qbuf1 != NULL
- && fwritable (omaster2)
- && fsend (omaster2, oslave2, &qbuf1))
- fcont = TRUE;
-
- if (qbuf2 != NULL
- && fwritable (omaster1)
- && fsend (omaster1, oslave1, &qbuf2))
- fcont = TRUE;
-
- if (! fcont
- && (qbuf1 != NULL || qbuf2 != NULL))
- {
- long cgot1, cgot2;
-
- cgot1 = cread (omaster1, &qbuf1);
- cFrom1 += cgot1;
- cgot2 = cread (omaster2, &qbuf2);
- cFrom2 += cgot2;
- fcont = TRUE;
- }
- }
- while (fcont);
- }
-
- /*NOTREACHED*/
-}
-
-/* When a child dies, kill them both. */
-
-static RETSIGTYPE
-uchild (isig)
- int isig;
-{
- struct tms sbase, s1, s2;
-
- signal (SIGCHLD, SIG_DFL);
-
- /* Give the processes a chance to die on their own. */
- sleep (2);
-
- (void) kill (iPid1, SIGTERM);
- (void) kill (iPid2, SIGTERM);
-
- (void) times (&sbase);
-
-#if HAVE_WAITPID
- (void) waitpid (iPid1, (pointer) NULL, 0);
-#else /* ! HAVE_WAITPID */
-#if HAVE_WAIT4
- (void) wait4 (iPid1, (pointer) NULL, 0, (struct rusage *) NULL);
-#else /* ! HAVE_WAIT4 */
- (void) wait ((wait_status *) NULL);
-#endif /* ! HAVE_WAIT4 */
-#endif /* ! HAVE_WAITPID */
-
- (void) times (&s1);
-
-#if HAVE_WAITPID
- (void) waitpid (iPid2, (pointer) NULL, 0);
-#else /* ! HAVE_WAITPID */
-#if HAVE_WAIT4
- (void) wait4 (iPid2, (wait_status *) NULL, 0, (struct rusage *) NULL);
-#else /* ! HAVE_WAIT4 */
- (void) wait ((wait_status *) NULL);
-#endif /* ! HAVE_WAIT4 */
-#endif /* ! HAVE_WAITPID */
-
- (void) times (&s2);
-
- fprintf (stderr,
- " First child: user: %g; system: %g\n",
- (double) (s1.tms_cutime - sbase.tms_cutime) / (double) TIMES_TICK,
- (double) (s1.tms_cstime - sbase.tms_cstime) / (double) TIMES_TICK);
- fprintf (stderr,
- "Second child: user: %g; system: %g\n",
- (double) (s2.tms_cutime - s1.tms_cutime) / (double) TIMES_TICK,
- (double) (s2.tms_cstime - s1.tms_cstime) / (double) TIMES_TICK);
-
- ucheck_test (iTest, fCall_uucico);
-
- if (abLogout1[0] != '\0')
- {
- if (zDebug != NULL)
- fprintf (stderr, "Executing %s\n", abLogout1);
- (void) system (abLogout1);
- }
- if (abLogout2[0] != '\0')
- {
- if (zDebug != NULL)
- fprintf (stderr, "Executing %s\n", abLogout2);
- (void) system (abLogout2);
- }
-
- fprintf (stderr, "Wrote %d bytes from 1 to 2\n", cFrom1);
- fprintf (stderr, "Wrote %d bytes from 2 to 1\n", cFrom2);
-
- if (access ("/usr/tmp/tstuu/spool1/core", R_OK) == 0)
- fprintf (stderr, "core file 1 exists\n");
- if (access ("/usr/tmp/tstuu/spool2/core", R_OK) == 0)
- fprintf (stderr, "core file 2 exists\n");
-
- exit (EXIT_SUCCESS);
-}
-
-/* Open a file without error. */
-
-static FILE *
-xfopen (zname, zmode)
- const char *zname;
- const char *zmode;
-{
- FILE *eret;
-
- eret = fopen (zname, zmode);
- if (eret == NULL)
- {
- perror (zname);
- exit (EXIT_FAILURE);
- }
- return eret;
-}
-
-/* Close a file without error. */
-
-static void xfclose P((FILE *e));
-
-static void
-xfclose (e)
- FILE *e;
-{
- if (fclose (e) != 0)
- {
- perror ("fclose");
- exit (EXIT_FAILURE);
- }
-}
-
-/* Create a test file. */
-
-static void
-umake_file (z, c)
- const char *z;
- int c;
-{
- int i;
- FILE *e;
-
- e = xfopen (z, "w");
-
- for (i = 0; i < 256; i++)
- {
- int i2;
-
- for (i2 = 0; i2 < 256; i2++)
- putc (i, e);
- }
-
- for (i = 0; i < c; i++)
- putc (i, e);
-
- xfclose (e);
-}
-
-/* Check a test file. */
-
-static void
-ucheck_file (z, zerr, c)
- const char *z;
- const char *zerr;
- int c;
-{
- int i;
- FILE *e;
-
- e = xfopen (z, "r");
-
- for (i = 0; i < 256; i++)
- {
- int i2;
-
- for (i2 = 0; i2 < 256; i2++)
- {
- int bread;
-
- bread = getc (e);
- if (bread == EOF)
- {
- fprintf (stderr,
- "%s: Unexpected EOF at position %d,%d\n",
- zerr, i, i2);
- xfclose (e);
- return;
- }
- if (bread != i)
- fprintf (stderr,
- "%s: At position %d,%d got %d expected %d\n",
- zerr, i, i2, bread, i);
- }
- }
-
- for (i = 0; i < c; i++)
- {
- int bread;
-
- bread = getc (e);
- if (bread == EOF)
- {
- fprintf (stderr, "%s: Unexpected EOF at extra %d\n", zerr, i);
- xfclose (e);
- return;
- }
- if (bread != i)
- fprintf (stderr, "%s: At extra %d got %d expected %d\n",
- zerr, i, bread, i);
- }
-
- if (getc (e) != EOF)
- fprintf (stderr, "%s: File is too long", zerr);
-
- xfclose (e);
-}
-
-/* Prepare all the configuration files for testing. */
-
-static void
-uprepare_test (fmake, itest, fcall_uucico, zsys)
- boolean fmake;
- int itest;
- boolean fcall_uucico;
- const char *zsys;
-{
- FILE *e;
- const char *zuucp1, *zuucp2;
- const char *zuux1, *zuux2;
- char ab[1000];
- const char *zfrom;
- const char *zto;
-
-/* We must make /usr/tmp/tstuu world writeable or we won't be able to
- receive files into it. */
- (void) umask (0);
-
-#ifndef S_IWOTH
-#define S_IWOTH 02
-#endif
-
- if (mkdir ((char *) "/usr/tmp/tstuu",
- IPUBLIC_DIRECTORY_MODE | S_IWOTH) != 0
- && errno != EEXIST)
- {
- perror ("mkdir");
- exit (EXIT_FAILURE);
- }
-
- if (mkdir ((char *) "/usr/tmp/tstuu/spool1", IPUBLIC_DIRECTORY_MODE) != 0
- && errno != EEXIST)
- {
- perror ("mkdir");
- exit (EXIT_FAILURE);
- }
-
- if (mkdir ((char *) "/usr/tmp/tstuu/spool2", IPUBLIC_DIRECTORY_MODE) != 0
- && errno != EEXIST)
- {
- perror ("mkdir");
- exit (EXIT_FAILURE);
- }
-
- if (fmake)
- {
- e = xfopen ("/usr/tmp/tstuu/Config1", "w");
-
- fprintf (e, "# First test configuration file\n");
- fprintf (e, "nodename test1\n");
- fprintf (e, "spool /usr/tmp/tstuu/spool1\n");
- fprintf (e, "lockdir /usr/tmp/tstuu/spool1\n");
- fprintf (e, "sysfile /usr/tmp/tstuu/System1\n");
- fprintf (e, "sysfile /usr/tmp/tstuu/System1.2\n");
- fprintf (e, "portfile /usr/tmp/tstuu/Port1\n");
- (void) remove ("/usr/tmp/tstuu/Log1");
-#if ! HAVE_HDB_LOGGING
- fprintf (e, "logfile /usr/tmp/tstuu/Log1\n");
-#else
- fprintf (e, "%s\n", "logfile /usr/tmp/tstuu/Log1/%s/%s");
-#endif
- fprintf (e, "statfile /usr/tmp/tstuu/Stats1\n");
- fprintf (e, "debugfile /usr/tmp/tstuu/Debug1\n");
- fprintf (e, "callfile /usr/tmp/tstuu/Call1\n");
- fprintf (e, "pubdir /usr/tmp/tstuu\n");
-#if HAVE_V2_CONFIG
- fprintf (e, "v2-files no\n");
-#endif
-#if HAVE_HDB_CONFIG
- fprintf (e, "hdb-files no\n");
-#endif
- if (zDebug != NULL)
- fprintf (e, "debug %s\n", zDebug);
-
- xfclose (e);
-
- e = xfopen ("/usr/tmp/tstuu/System1", "w");
-
- fprintf (e, "# This file is ignored, to test multiple system files\n");
- fprintf (e, "time never\n");
-
- xfclose (e);
-
- e = xfopen ("/usr/tmp/tstuu/System1.2", "w");
-
- fprintf (e, "# First test system file\n");
- fprintf (e, "time any\n");
- fprintf (e, "port stdin\n");
- fprintf (e, "# That was the defaults\n");
- fprintf (e, "system %s\n", zsys);
- if (! fcall_uucico)
- {
- FILE *eprog;
-
- eprog = xfopen ("/usr/tmp/tstuu/Chat1", "w");
-
- /* Wait for the other side to open the port and flush input. */
- fprintf (eprog, "sleep 2\n");
- fprintf (eprog,
- "echo password $1 speed $2 1>&2\n");
- fprintf (eprog, "echo test1\n");
- fprintf (eprog, "exit 0\n");
-
- xfclose (eprog);
-
- if (chmod ("/usr/tmp/tstuu/Chat1",
- S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0)
- {
- perror ("chmod (/usr/tmp/tstuu/Chat1)");
- exit (EXIT_FAILURE);
- }
-
- fprintf (e, "chat-program /usr/tmp/tstuu/Chat1 \\P \\S\n");
-
- fprintf (e, "chat word: \\P\n");
- fprintf (e, "chat-fail login;\n");
- fprintf (e, "call-login *\n");
- fprintf (e, "call-password *\n");
- }
- else
- fprintf (e, "chat \"\"\n");
- fprintf (e, "call-transfer yes\n");
- fprintf (e, "commands cat\n");
- if (! fcall_uucico && iPercent == 0)
- {
- fprintf (e, "protocol-parameter g window 7\n");
- fprintf (e, "protocol-parameter g packet-size 4096\n");
- fprintf (e, "protocol-parameter j avoid \\377\n");
- }
- if (zProtocols != NULL)
- fprintf (e, "protocol %s\n", zProtocols);
-
- xfclose (e);
-
- e = xfopen ("/usr/tmp/tstuu/Port1", "w");
-
- fprintf (e, "port stdin\n");
- fprintf (e, "type stdin\n");
-
- xfclose (e);
-
- e = xfopen ("/usr/tmp/tstuu/Call1", "w");
-
- fprintf (e, "Call out password file\n");
- fprintf (e, "%s test1 pass\\s1\n", zsys);
-
- xfclose (e);
-
- if (! fcall_uucico)
- {
- FILE *eprog;
-
- e = xfopen ("/usr/tmp/tstuu/Config2", "w");
-
- fprintf (e, "# Second test configuration file\n");
- fprintf (e, "nodename test2\n");
- fprintf (e, "spool /usr/tmp/tstuu/spool2\n");
- fprintf (e, "lockdir /usr/tmp/tstuu/spool2\n");
- fprintf (e, "sysfile /usr/tmp/tstuu/System2\n");
- (void) remove ("/usr/tmp/tstuu/Log2");
-#if ! HAVE_HDB_LOGGING
- fprintf (e, "logfile /usr/tmp/tstuu/Log2\n");
-#else
- fprintf (e, "%s\n", "logfile /usr/tmp/tstuu/Log2/%s/%s");
-#endif
- fprintf (e, "statfile /usr/tmp/tstuu/Stats2\n");
- fprintf (e, "debugfile /usr/tmp/tstuu/Debug2\n");
- fprintf (e, "passwdfile /usr/tmp/tstuu/Pass2\n");
- fprintf (e, "pubdir /usr/tmp/tstuu\n");
-#if HAVE_V2_CONFIG
- fprintf (e, "v2-files no\n");
-#endif
-#if HAVE_HDB_CONFIG
- fprintf (e, "hdb-files no\n");
-#endif
- if (zDebug != NULL)
- fprintf (e, "debug %s\n", zDebug);
-
- xfclose (e);
-
- e = xfopen ("/usr/tmp/tstuu/System2", "w");
-
- fprintf (e, "# Second test system file\n");
- fprintf (e, "system test1\n");
- fprintf (e, "called-login test1\n");
- fprintf (e, "request true\n");
- fprintf (e, "commands cat\n");
- if (zProtocols != NULL)
- fprintf (e, "protocol %s\n", zProtocols);
-
- eprog = xfopen ("/usr/tmp/tstuu/Chat2", "w");
-
- fprintf (eprog,
- "echo port $1 1>&2\n");
- fprintf (eprog, "exit 0\n");
-
- xfclose (eprog);
-
- if (chmod ("/usr/tmp/tstuu/Chat2",
- S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0)
- {
- perror ("chmod (/usr/tmp/tstuu/Chat2");
- exit (EXIT_FAILURE);
- }
-
- fprintf (e, "called-chat-program /bin/sh /usr/tmp/tstuu/Chat2 \\Y\n");
- fprintf (e, "time any\n");
-
- xfclose (e);
-
- e = xfopen ("/usr/tmp/tstuu/Pass2", "w");
-
- fprintf (e, "# Call in password file\n");
- fprintf (e, "test1 pass\\s1\n");
-
- xfclose (e);
- }
- }
-
- zuucp1 = "./uucp -I /usr/tmp/tstuu/Config1 -r";
- zuux1 = "./uux -I /usr/tmp/tstuu/Config1 -r";
-
- if (fcall_uucico)
- {
- zuucp2 = "/usr/bin/uucp -r";
- zuux2 = "/usr/bin/uux -r";
- }
- else
- {
- zuucp2 = "./uucp -I /usr/tmp/tstuu/Config2 -r";
- zuux2 = "./uux -I /usr/tmp/tstuu/Config2 -r";
- }
-
- /* Test transferring a file from the first system to the second. */
- if (itest == 0 || itest == 1)
- {
- zfrom = "/usr/tmp/tstuu/from1";
- if (fcall_uucico)
- zto = "/usr/spool/uucppublic/to1";
- else
- zto = "/usr/tmp/tstuu/to1";
-
- (void) remove (zto);
- umake_file (zfrom, 0);
-
- sprintf (ab, "%s %s %s!%s", zuucp1, zfrom, zsys, zto);
- xsystem (ab);
- }
-
- /* Test having the first system request a file from the second. */
- if (itest == 0 || itest == 2)
- {
- if (fcall_uucico)
- zfrom = "/usr/spool/uucppublic/from2";
- else
- zfrom = "/usr/tmp/tstuu/from2";
- zto = "/usr/tmp/tstuu/to2";
-
- (void) remove (zto);
- umake_file (zfrom, 3);
-
- sprintf (ab, "%s %s!%s %s", zuucp1, zsys, zfrom, zto);
- xsystem (ab);
- }
-
- /* Test having the second system send a file to the first. */
- if (itest == 0 || itest == 3)
- {
- if (fcall_uucico)
- zfrom = "/usr/spool/uucppublic/from3";
- else
- zfrom = "/usr/tmp/tstuu/from3";
- zto = "/usr/tmp/tstuu/to3";
-
- (void) remove (zto);
- umake_file (zfrom, 5);
-
- sprintf (ab, "%s -c \\~/from3 test1!~/to3", zuucp2);
- xsystem (ab);
- }
-
- /* Test having the second system request a file from the first. */
- if (itest == 0 || itest == 4)
- {
- zfrom = "/usr/tmp/tstuu/from4";
- if (fcall_uucico)
- zto = "/usr/spool/uucppublic/to4";
- else
- zto = "/usr/tmp/tstuu/to4";
-
- (void) remove (zto);
- umake_file (zfrom, 7);
-
- sprintf (ab, "%s test1!%s %s", zuucp2, zfrom, zto);
- xsystem (ab);
- }
-
- /* Test having the second system make an execution request. */
- if (itest == 0 || itest == 5)
- {
- zfrom = "/usr/tmp/tstuu/from5";
- if (fcall_uucico)
- zto = "/usr/spool/uucppublic/to5";
- else
- zto = "/usr/tmp/tstuu/to5";
-
- (void) remove (zto);
- umake_file (zfrom, 11);
-
- sprintf (ab, "%s test1!cat '<%s' '>%s'", zuux2, zfrom, zto);
- xsystem (ab);
- }
-
- /* Test having the first system request a wildcard. */
- if (itest == 0 || itest == 6)
- {
- const char *zfrom1, *zfrom2;
-
- if (fcall_uucico)
- {
- zfrom = "/usr/spool/uucppublic/to6\\*";
- zfrom1 = "/usr/spool/uucppublic/to6.1";
- zfrom2 = "/usr/spool/uucppublic/to6.2";
- }
- else
- {
- zfrom = "/usr/tmp/tstuu/spool2/to6\\*";
- zfrom1 = "/usr/tmp/tstuu/spool2/to6.1";
- zfrom2 = "/usr/tmp/tstuu/spool2/to6.2";
- }
-
- umake_file (zfrom1, 100);
- umake_file (zfrom2, 101);
- (void) remove ("/usr/tmp/tstuu/to6.1");
- (void) remove ("/usr/tmp/tstuu/to6.2");
-
- sprintf (ab, "%s %s!%s /usr/tmp/tstuu", zuucp1, zsys, zfrom);
- xsystem (ab);
- }
-
- /* Test having the second system request a wildcard. */
- if (itest == 0 || itest == 7)
- {
- const char *zto1, *zto2;
-
- if (fcall_uucico)
- {
- zto = "/usr/spool/uucppublic";
- zto1 = "/usr/spool/uucppublic/to7.1";
- zto2 = "/usr/spool/uucppublic/to7.2";
- }
- else
- {
- zto = "/usr/tmp/tstuu";
- zto1 = "/usr/tmp/tstuu/to7.1";
- zto2 = "/usr/tmp/tstuu/to7.2";
- }
-
- umake_file ("/usr/tmp/tstuu/spool1/to7.1", 150);
- umake_file ("/usr/tmp/tstuu/spool1/to7.2", 155);
- (void) remove (zto1);
- (void) remove (zto2);
-
- sprintf (ab, "%s test1!/usr/tmp/tstuu/spool1/to7.\\* %s", zuucp2,
- zto);
- xsystem (ab);
- }
-
- /* Test an E command. This runs cat, discarding the output. */
- if ((itest == 0 || itest == 8) && ! fcall_uucico)
- {
- umake_file ("/usr/tmp/tstuu/from8", 30);
- sprintf (ab, "%s - test2!cat < /usr/tmp/tstuu/from8", zuux1);
- xsystem (ab);
- }
-}
-
-/* Try to make sure the file transfers were successful. */
-
-static void
-ucheck_test (itest, fcall_uucico)
- int itest;
- boolean fcall_uucico;
-{
- if (itest == 0 || itest == 1)
- {
- if (fcall_uucico)
- ucheck_file ("/usr/spool/uucppublic/to1", "test 1", 0);
- else
- ucheck_file ("/usr/tmp/tstuu/to1", "test 1", 0);
- }
-
- if (itest == 0 || itest == 2)
- ucheck_file ("/usr/tmp/tstuu/to2", "test 2", 3);
-
- if (itest == 0 || itest == 3)
- ucheck_file ("/usr/tmp/tstuu/to3", "test 3", 5);
-
- if (itest == 0 || itest == 4)
- {
- if (fcall_uucico)
- ucheck_file ("/usr/spool/uucppublic/to4", "test 4", 7);
- else
- ucheck_file ("/usr/tmp/tstuu/to4", "test 4", 7);
- }
-
- if (itest == 0 || itest == 6)
- {
- ucheck_file ("/usr/tmp/tstuu/to6.1", "test 6.1", 100);
- ucheck_file ("/usr/tmp/tstuu/to6.2", "test 6.2", 101);
- }
-
- if (itest == 0 || itest == 7)
- {
- const char *zto1, *zto2;
-
- if (fcall_uucico)
- {
- zto1 = "/usr/spool/uucppublic/to7.1";
- zto2 = "/usr/spool/uucppublic/to7.2";
- }
- else
- {
- zto1 = "/usr/tmp/tstuu/to7.1";
- zto2 = "/usr/tmp/tstuu/to7.2";
- }
-
- ucheck_file (zto1, "test 7.1", 150);
- ucheck_file (zto2, "test 7.2", 155);
- }
-}
-
-/* A debugging routine used when displaying buffers. */
-
-static int
-cpshow (z, ichar)
- char *z;
- int ichar;
-{
- if (isprint (BUCHAR (ichar)) && ichar != '\"')
- {
- *z = (char) ichar;
- return 1;
- }
-
- *z++ = '\\';
-
- switch (ichar)
- {
- case '\n':
- *z = 'n';
- return 2;
- case '\r':
- *z = 'r';
- return 2;
- case '\"':
- *z = '\"';
- return 2;
- default:
- sprintf (z, "%03o", (unsigned int)(ichar & 0xff));
- return strlen (z) + 1;
- }
-}
-
-/* Pick one of two file descriptors which is ready for reading, or
- return in five seconds. If the argument is ready for reading,
- leave it alone; otherwise set it to -1. */
-
-static void
-uchoose (po1, po2)
- int *po1;
- int *po2;
-{
-#if HAVE_SELECT
-
- int iread;
- struct timeval stime;
-
- iread = (1 << *po1) | (1 << *po2);
- stime.tv_sec = 5;
- stime.tv_usec = 0;
-
- if (select ((*po1 > *po2 ? *po1 : *po2) + 1, (pointer) &iread,
- (pointer) NULL, (pointer) NULL, &stime) < 0)
- {
- perror ("select");
- uchild (SIGCHLD);
- }
-
- if ((iread & (1 << *po1)) == 0)
- *po1 = -1;
-
- if ((iread & (1 << *po2)) == 0)
- *po2 = -1;
-
-#else /* ! HAVE_SELECT */
-
-#if HAVE_POLL
-
- struct pollfd as[2];
-
- as[0].fd = *po1;
- as[0].events = POLLIN;
- as[1].fd = *po2;
- as[1].events = POLLIN;
-
- if (poll (as, 2, 5 * 1000) < 0)
- {
- perror ("poll");
- uchild (SIGCHLD);
- }
-
- if ((as[0].revents & POLLIN) == 0)
- *po1 = -1;
-
- if ((as[1].revents & POLLIN) == 0)
- *po2 = -1;
-
-#endif /* HAVE_POLL */
-#endif /* ! HAVE_SELECT */
-}
-
-/* Read some data from a file descriptor. This keeps reading until
- one of the reads gets no data. */
-
-static long
-cread (o, pqbuf)
- int o;
- struct sbuf **pqbuf;
-{
- long ctotal;
-
- while (*pqbuf != NULL && (*pqbuf)->qnext != NULL)
- pqbuf = &(*pqbuf)->qnext;
-
- ctotal = 0;
-
- while (TRUE)
- {
- int cgot;
-
- if (*pqbuf != NULL
- && (*pqbuf)->cend >= sizeof (*pqbuf)->ab)
- pqbuf = &(*pqbuf)->qnext;
-
- if (*pqbuf == NULL)
- {
- *pqbuf = (struct sbuf *) malloc (sizeof (struct sbuf));
- if (*pqbuf == NULL)
- {
- fprintf (stderr, "Out of memory\n");
- uchild (SIGCHLD);
- }
- (*pqbuf)->qnext = NULL;
- (*pqbuf)->cstart = 0;
- (*pqbuf)->cend = 0;
- }
-
- cgot = read (o, (*pqbuf)->ab + (*pqbuf)->cend,
- (sizeof (*pqbuf)->ab) - (*pqbuf)->cend);
- if (cgot < 0)
- {
- if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENODATA)
- cgot = 0;
- else
- {
- perror ("read");
- uchild (SIGCHLD);
- }
- }
-
- if (cgot == 0)
- return ctotal;
-
- ctotal += cgot;
-
- if (zDebug != NULL)
- {
- char abshow[325];
- char *zfrom;
- char *zshow;
- int i;
-
- zfrom = (*pqbuf)->ab + (*pqbuf)->cend;
- zshow = abshow;
- for (i = 0; i < cgot && i < 80; i++, zfrom++)
- zshow += cpshow (zshow, *zfrom);
- if (i < cgot)
- {
- *zshow++ = '.';
- *zshow++ = '.';
- *zshow++ = '.';
- }
- *zshow = '\0';
- fprintf (stderr, "Read from %d: %d \"%s\"\n", o, cgot, abshow);
- fflush (stderr);
- }
-
- if (iPercent > 0)
- {
- int i;
- int c;
-
- c = 0;
- for (i = 0; i < cgot; i++)
- {
- if (rand () % 1000 < iPercent)
- {
- ++(*pqbuf)->ab[(*pqbuf)->cend + i];
- ++c;
- }
- }
- if (zDebug != NULL && c > 0)
- fprintf (stderr, "Clobbered %d bytes\n", c);
- }
-
- (*pqbuf)->cend += cgot;
-
- if (ctotal > 256)
- return ctotal;
- }
-}
-
-/* Write data to a file descriptor until one of the writes gets no
- data. */
-
-static boolean
-fsend (o, oslave, pqbuf)
- int o;
- int oslave;
- struct sbuf **pqbuf;
-{
- long ctotal;
-
- ctotal = 0;
- while (*pqbuf != NULL)
- {
- int cwrite, cwrote;
-
- if ((*pqbuf)->cstart >= (*pqbuf)->cend)
- {
- struct sbuf *qfree;
-
- qfree = *pqbuf;
- *pqbuf = (*pqbuf)->qnext;
- free ((pointer) qfree);
- continue;
- }
-
-#ifdef FIONREAD
- {
- long cunread;
-
- if (ioctl (oslave, FIONREAD, &cunread) < 0)
- {
- perror ("FIONREAD");
- uchild (SIGCHLD);
- }
- if (zDebug != NULL)
- fprintf (stderr, "%ld unread\n", cunread);
- cwrite = 256 - cunread;
- if (cwrite <= 0)
- break;
- }
-#else /* ! FIONREAD */
- if (! fwritable (o))
- break;
- cwrite = 1;
-#endif /* ! FIONREAD */
-
- if (cwrite > (*pqbuf)->cend - (*pqbuf)->cstart)
- cwrite = (*pqbuf)->cend - (*pqbuf)->cstart;
-
- cwrote = write (o, (*pqbuf)->ab + (*pqbuf)->cstart, cwrite);
- if (cwrote < 0)
- {
- if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENODATA)
- cwrote = 0;
- else
- {
- perror ("write");
- uchild (SIGCHLD);
- }
- }
-
- if (cwrote == 0)
- break;
-
- ctotal += cwrote;
- (*pqbuf)->cstart += cwrote;
- }
-
- if (zDebug != NULL && ctotal > 0)
- fprintf (stderr, "Wrote %ld to %d\n", ctotal, o);
-
- return ctotal > 0;
-}
-
-/* Check whether a file descriptor can be written to. */
-
-static boolean
-fwritable (o)
- int o;
-{
-#if HAVE_SELECT
-
- int iwrite;
- struct timeval stime;
- int cfds;
-
- iwrite = 1 << o;
-
- stime.tv_sec = 0;
- stime.tv_usec = 0;
-
- cfds = select (o + 1, (pointer) NULL, (pointer) &iwrite,
- (pointer) NULL, &stime);
- if (cfds < 0)
- {
- perror ("select");
- uchild (SIGCHLD);
- }
-
- return cfds > 0;
-
-#else /* ! HAVE_SELECT */
-
-#if HAVE_POLL
-
- struct pollfd s;
- int cfds;
-
- s.fd = o;
- s.events = POLLOUT;
-
- cfds = poll (&s, 1, 0);
- if (cfds < 0)
- {
- perror ("poll");
- uchild (SIGCHLD);
- }
-
- return cfds > 0;
-
-#endif /* HAVE_POLL */
-#endif /* ! HAVE_SELECT */
-}
-
-/* A version of the system command that checks for errors. */
-
-static void
-xsystem (zcmd)
- const char *zcmd;
-{
- int istat;
-
- istat = system ((char *) zcmd);
- if (istat != 0)
- {
- fprintf (stderr, "Command failed with status %d\n", istat);
- fprintf (stderr, "%s\n", zcmd);
- exit (EXIT_FAILURE);
- }
-}
diff --git a/gnu/libexec/uucp/uuchk/Makefile b/gnu/libexec/uucp/uuchk/Makefile
deleted file mode 100644
index 9da46bc..0000000
--- a/gnu/libexec/uucp/uuchk/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# Makefile for uuchk
-# $Id: Makefile,v 1.6 1997/02/22 15:28:25 peter Exp $
-
-BINDIR= $(sbindir)
-
-PROG= uuchk
-MAN8= uuchk.8
-SRCS= uuchk.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -DVERSION=\"$(VERSION)\"
-
-.include <bsd.prog.mk>
diff --git a/gnu/libexec/uucp/uuchk/uuchk.8 b/gnu/libexec/uucp/uuchk/uuchk.8
deleted file mode 100644
index dbeb17c..0000000
--- a/gnu/libexec/uucp/uuchk/uuchk.8
+++ /dev/null
@@ -1,46 +0,0 @@
-''' $Id: uustat.1,v 1.8 1997/02/22 15:28:49 peter Exp $
-.TH uuchk 1 "Taylor UUCP 1.06"
-.SH NAME
-uuchk \- displays information from the UUCP configuration
-.SH SYNOPSIS
-.B uuchk
-[-s system] [standard UUCP options]
-.SH DESCRIPTION
-The
-.B uuchk
-The
-.B uuchk
-program reads the UUCP configuration files and displays
-a rather lengthy description of what it finds. This is useful when
-configuring UUCP to make certain that the UUCP package will do
-what you expect it to do.
-.SH OPTIONS
-The following options may be given to
-.B uuchk:
-.TP 5
-.B \-s, \-\-system
-Display the
-configuration for just the specified system, rather than for all
-systems. The
-.B uuchk
-program also supports the standard UUCP program
-options.
-.TP 5
-.B \-x type
-.TP 5
-.B \-\-debug type
-.TP 5
-.B \-I file
-.TP 5
-.B \-\-config file
-.TP 5
-.B \-v, \-\-version
-.TP 5
-.B \-\-help
-Standard UUCP options.
-.SH SEE ALSO
-uucp(1)
-.SH AUTHOR
-Ian Lance Taylor (ian@airs.com).
-This Manpage based on the Taylor UUCP 1.06 Texinfo documentation.
-
diff --git a/gnu/libexec/uucp/uuchk/uuchk.c b/gnu/libexec/uucp/uuchk/uuchk.c
deleted file mode 100644
index b6adc4e..0000000
--- a/gnu/libexec/uucp/uuchk/uuchk.c
+++ /dev/null
@@ -1,1127 +0,0 @@
-/* uuchk.c
- Display what we think the permissions of systems are.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char uuchk_rcsid[] = "$Id$";
-#endif
-
-#include "getopt.h"
-
-#include "uuconf.h"
-
-/* Local functions. */
-
-static void ukusage P((void));
-static void ukhelp P((void));
-static void ukshow P((const struct uuconf_system *qsys,
- pointer puuconf));
-static int ikshow_port P((struct uuconf_port *qport, pointer pinfo));
-static void ukshow_dialer P((struct uuconf_dialer *qdial));
-static void ukshow_chat P((const struct uuconf_chat *qchat,
- const char *zhdr));
-static void ukshow_size P((struct uuconf_timespan *q, boolean fcall,
- boolean flocal));
-static void ukshow_reliable P ((int i, const char *zhdr));
-static void ukshow_proto_params P((struct uuconf_proto_param *pas,
- int cindent));
-static void ukshow_time P((const struct uuconf_timespan *));
-static struct uuconf_timespan *qcompress_span P((struct uuconf_timespan *));
-static void ukuuconf_error P((pointer puuconf, int iret));
-
-/* Structure used to pass uuconf pointer into ikshow_port and also let
- it record whether any ports were found. */
-struct sinfo
-{
- /* The uuconf global pointer. */
- pointer puuconf;
- /* The system. */
- const struct uuconf_system *qsys;
- /* Whether any ports were seen. */
- boolean fgot;
-};
-
-/* Program name. */
-static const char *zKprogram;
-
-/* Long getopt options. */
-static const struct option asKlongopts[] =
-{
- { "system", required_argument, NULL,'s' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'x' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int iopt;
- const char *zsystem = NULL;
- const char *zconfig = NULL;
- int iret;
- pointer puuconf;
-
- zKprogram = argv[0];
-
- while ((iopt = getopt_long (argc, argv, "I:s:vx:", asKlongopts,
- (int *) NULL)) != EOF)
- {
- switch (iopt)
- {
- case 's':
- /* Examine specific system. */
- zsystem = optarg;
- break;
-
- case 'I':
- /* Set the configuration file name. */
- zconfig = optarg;
- break;
-
- case 'x':
- /* Set the debugging level. There is actually no debugging
- information for this program. */
- break;
-
- case 'v':
- /* Print version and exit. */
- printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zKprogram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 1:
- /* --help. */
- ukhelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found and flag set. */
- break;
-
- default:
- ukusage ();
- /*NOTREACHED*/
- }
- }
-
- if (optind != argc)
- {
- fprintf (stderr, "%s: too many arguments", zKprogram);
- ukusage ();
- }
-
- iret = uuconf_init (&puuconf, (const char *) NULL, zconfig);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
-
- if (zsystem != NULL)
- {
- struct uuconf_system ssys;
-
- iret = uuconf_system_info (puuconf, zsystem, &ssys);
- if (iret == UUCONF_NOT_FOUND)
- {
- fprintf (stderr, "%s: system not found\n", zsystem);
- exit (EXIT_FAILURE);
- }
- else if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
-
- ukshow (&ssys, puuconf);
- (void) uuconf_system_free (puuconf, &ssys);
- }
- else
- {
- const char *zstr;
- int iint;
- char **pzsystems;
-
- iret = uuconf_localname (puuconf, &zstr);
- if (iret == UUCONF_SUCCESS)
- printf ("Local node name %s\n", zstr);
- else if (iret != UUCONF_NOT_FOUND)
- ukuuconf_error (puuconf, iret);
-
- iret = uuconf_spooldir (puuconf, &zstr);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- printf ("Spool directory %s\n", zstr);
-
- iret = uuconf_pubdir (puuconf, &zstr);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- printf ("Public directory %s\n", zstr);
-
- iret = uuconf_lockdir (puuconf, &zstr);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- printf ("Lock directory %s\n", zstr);
-
- iret = uuconf_logfile (puuconf, &zstr);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- printf ("Log file %s\n", zstr);
-
- iret = uuconf_statsfile (puuconf, &zstr);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- printf ("Statistics file %s\n", zstr);
-
- iret = uuconf_debugfile (puuconf, &zstr);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- printf ("Debug file %s\n", zstr);
-
- iret = uuconf_debuglevel (puuconf, &zstr);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- if (zstr != NULL)
- printf ("Global debugging level %s\n", zstr);
-
- iret = uuconf_strip (puuconf, &iint);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- printf ("uucico -l will %sstrip login names and passwords\n",
- (iint & UUCONF_STRIP_LOGIN) != 0 ? "" : "not ");
- printf ("uucico will %sstrip UUCP protocol commands\n",
- (iint & UUCONF_STRIP_PROTO) != 0 ? "" : "not ");
-
- iret = uuconf_maxuuxqts (puuconf, &iint);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- if (iint != 0)
- printf ("Maximum number of uuxqt processes permitted %d\n", iint);
-
- iret = uuconf_runuuxqt (puuconf, &iint);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- if (iint > 0)
- printf ("Start uuxqt every %d jobs\n", iint);
- else
- {
- switch (iint)
- {
- case UUCONF_RUNUUXQT_NEVER:
- printf ("Never start uuxqt\n");
- break;
- case UUCONF_RUNUUXQT_ONCE:
- printf ("Start uuxqt once per uucico invocation\n");
- break;
- case UUCONF_RUNUUXQT_PERCALL:
- printf ("Start uuxqt once per call\n");
- break;
- default:
- fprintf (stderr, "Illegal value from uuconf_runuuxqt\n");
- exit (EXIT_FAILURE);
- break;
- }
- }
-
- iret = uuconf_system_names (puuconf, &pzsystems, FALSE);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
-
- if (*pzsystems == NULL)
- {
- fprintf (stderr, "%s: no systems found\n", zKprogram);
- exit (EXIT_FAILURE);
- }
-
- while (*pzsystems != NULL)
- {
- struct uuconf_system ssys;
-
- printf ("\n");
- iret = uuconf_system_info (puuconf, *pzsystems, &ssys);
- if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- else
- ukshow (&ssys, puuconf);
- (void) uuconf_system_free (puuconf, &ssys);
- ++pzsystems;
- }
- }
-
- exit (EXIT_SUCCESS);
-
- /* Avoid errors about not returning a value. */
- return 0;
-}
-
-/* Print a usage message and die. */
-
-static void ukusage ()
-{
- fprintf (stderr, "Usage: %s [-s system] [-I file]\n", zKprogram);
- fprintf (stderr, "Use %s --help for help\n", zKprogram);
- exit (EXIT_FAILURE);
-}
-
-/* Print a help message. */
-
-static void
-ukhelp ()
-{
- printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- printf ("Usage: %s [-s system] [-I file] [-v]\n", zKprogram);
- printf (" -s,--system system: Only print configuration for named system\n");
- printf (" -I,--config file: Set configuration file to use\n");
- printf (" -v,--version: Print version and exit\n");
- printf (" --help: Print help and exit\n");
-}
-
-/* Dump out the information for a system. */
-
-static void
-ukshow (qsys, puuconf)
- const struct uuconf_system *qsys;
- pointer puuconf;
-{
- char **pz;
- int i;
- int iret;
- boolean fanycall;
-
- printf ("System: %s", qsys->uuconf_zname);
- if (qsys->uuconf_pzalias != NULL)
- {
- printf (" (");
- for (pz = qsys->uuconf_pzalias; *pz != NULL; pz++)
- {
- printf ("%s", *pz);
- if (pz[1] != NULL)
- printf (" ");
- }
- printf (")");
- }
- printf ("\n");
-
- fanycall = FALSE;
- for (i = 0; qsys != NULL; qsys = qsys->uuconf_qalternate, i++)
- {
- boolean fcall, fcalled;
- struct uuconf_timespan *qtime, *qspan;
-
- if (i != 0 || qsys->uuconf_qalternate != NULL)
- {
- printf ("Alternate %d", i);
- if (qsys->uuconf_zalternate != NULL)
- printf (" (%s)", qsys->uuconf_zalternate);
- printf ("\n");
- }
-
- /* See if this alternate could be used when calling out. */
- fcall = qsys->uuconf_fcall;
- if (qsys->uuconf_qtimegrade == NULL)
- fcall = FALSE;
-
- /* See if this alternate could be used when calling in. */
- fcalled = qsys->uuconf_fcalled;
-
- if (! fcall && ! fcalled)
- {
- printf (" This alternate is never used\n");
- continue;
- }
-
- if (fcall)
- fanycall = TRUE;
-
- if (fcalled)
- {
- if (qsys->uuconf_zcalled_login != NULL
- && strcmp (qsys->uuconf_zcalled_login, "ANY") != 0)
- {
- if (i == 0 && qsys->uuconf_qalternate == NULL)
- printf (" Caller must log in as %s\n",
- qsys->uuconf_zcalled_login);
- else
- printf (" When called using login name %s\n",
- qsys->uuconf_zcalled_login);
- }
- else
- printf (" When called using any login name\n");
-
- if (qsys->uuconf_zlocalname != NULL)
- printf (" Will use %s as name of local system\n",
- qsys->uuconf_zlocalname);
- }
-
- if (fcalled && qsys->uuconf_fcallback)
- {
- printf (" If called, will call back\n");
- fcalled = FALSE;
- }
-
- if (fcall)
- {
- struct sinfo si;
-
- if (i == 0 && qsys->uuconf_qalternate == NULL)
- printf (" Call out");
- else
- printf (" This alternate applies when calling");
-
- if (qsys->uuconf_zport != NULL || qsys->uuconf_qport != NULL)
- {
- printf (" using ");
- if (qsys->uuconf_zport != NULL)
- printf ("port %s", qsys->uuconf_zport);
- else
- printf ("a specially defined port");
- if (qsys->uuconf_ibaud != 0)
- {
- printf (" at speed %ld", qsys->uuconf_ibaud);
- if (qsys->uuconf_ihighbaud != 0)
- printf (" to %ld", qsys->uuconf_ihighbaud);
- }
- printf ("\n");
- }
- else if (qsys->uuconf_ibaud != 0)
- {
- printf (" at speed %ld", qsys->uuconf_ibaud);
- if (qsys->uuconf_ihighbaud != 0)
- printf (" to %ld", qsys->uuconf_ihighbaud);
- printf ("\n");
- }
- else
- printf (" using any port\n");
-
- si.puuconf = puuconf;
- si.qsys = qsys;
- si.fgot = FALSE;
-
- if (qsys->uuconf_qport != NULL)
- {
- printf (" The port is defined as:\n");
- (void) ikshow_port (qsys->uuconf_qport, (pointer) &si);
- }
- else
- {
- struct uuconf_port sdummy;
-
- printf (" The possible ports are:\n");
- iret = uuconf_find_port (puuconf, qsys->uuconf_zport,
- qsys->uuconf_ibaud,
- qsys->uuconf_ihighbaud,
- ikshow_port, (pointer) &si,
- &sdummy);
- if (iret != UUCONF_NOT_FOUND)
- ukuuconf_error (puuconf, iret);
- if (! si.fgot)
- printf (" *** There are no matching ports\n");
- }
-
- if (qsys->uuconf_zphone != NULL)
- {
- if ((qsys->uuconf_zport != NULL
- && strcmp (qsys->uuconf_zport, "TCP") == 0)
- || (qsys->uuconf_qport != NULL
- && (qsys->uuconf_qport->uuconf_ttype
- == UUCONF_PORTTYPE_TCP
- || qsys->uuconf_qport->uuconf_ttype
- == UUCONF_PORTTYPE_TLI)))
- printf (" Remote address %s\n", qsys->uuconf_zphone);
- else
- printf (" Phone number %s\n", qsys->uuconf_zphone);
- }
-
- ukshow_chat (&qsys->uuconf_schat, " Chat");
-
- if (qsys->uuconf_zcall_login != NULL
- || qsys->uuconf_zcall_password != NULL)
- {
- char *zlogin, *zpass;
-
- iret = uuconf_callout (puuconf, qsys, &zlogin, &zpass);
- if (iret == UUCONF_NOT_FOUND)
- printf (" Can not determine login name or password\n");
- else if (UUCONF_ERROR_VALUE (iret) == UUCONF_FOPEN_FAILED)
- printf (" Can not read call out file\n");
- else if (iret != UUCONF_SUCCESS)
- ukuuconf_error (puuconf, iret);
- else
- {
- if (zlogin != NULL)
- {
- printf (" Login name %s\n", zlogin);
- free ((pointer) zlogin);
- }
- if (zpass != NULL)
- {
- printf (" Password %s\n", zpass);
- free ((pointer) zpass);
- }
- }
- }
-
- qtime = qcompress_span (qsys->uuconf_qtimegrade);
-
- for (qspan = qtime; qspan != NULL; qspan = qspan->uuconf_qnext)
- {
- printf (" ");
- ukshow_time (qspan);
- printf (" may call if ");
- if ((char) qspan->uuconf_ival == UUCONF_GRADE_LOW)
- printf ("any work");
- else
- printf ("work grade %c or higher", (char) qspan->uuconf_ival);
- if (qspan->uuconf_cretry != 0)
- printf (" (retry %d)", qspan->uuconf_cretry);
- printf ("\n");
- }
-
- if (qsys->uuconf_cmax_retries > 0)
- printf (" May retry the call up to %d times\n",
- qsys->uuconf_cmax_retries);
-
- if (qsys->uuconf_qcalltimegrade != NULL)
- {
- boolean fprint, fother;
-
- qtime = qcompress_span (qsys->uuconf_qcalltimegrade);
- fprint = FALSE;
- fother = FALSE;
- if (qtime->uuconf_istart != 0)
- fother = TRUE;
- for (qspan = qtime; qspan != NULL; qspan = qspan->uuconf_qnext)
- {
- if ((char) qspan->uuconf_ival == UUCONF_GRADE_LOW)
- {
- fother = TRUE;
- continue;
- }
- fprint = TRUE;
- printf (" ");
- ukshow_time (qspan);
- printf (" may accept work grade %c or higher\n",
- (char) qspan->uuconf_ival);
- if (qspan->uuconf_qnext == NULL)
- {
- if (qspan->uuconf_iend != 7 * 24 * 60)
- fother = TRUE;
- }
- else
- {
- if (qspan->uuconf_iend
- != qspan->uuconf_qnext->uuconf_istart)
- fother = TRUE;
- }
- }
- if (fprint && fother)
- printf (" (At other times may accept any work)\n");
- }
- }
-
- if (fcalled)
- {
- if (qsys->uuconf_qcalledtimegrade != NULL)
- {
- boolean fprint, fother;
-
- qtime = qcompress_span (qsys->uuconf_qcalledtimegrade);
- fprint = FALSE;
- fother = FALSE;
- if (qtime->uuconf_istart != 0)
- fother = TRUE;
- for (qspan = qtime; qspan != NULL; qspan = qspan->uuconf_qnext)
- {
- if ((char) qspan->uuconf_ival == UUCONF_GRADE_LOW)
- {
- fother = TRUE;
- continue;
- }
- fprint = TRUE;
- printf (" ");
- ukshow_time (qspan);
- printf (" will send work grade %c or higher\n",
- (char) qspan->uuconf_ival);
- if (qspan->uuconf_qnext == NULL)
- {
- if (qspan->uuconf_iend != 7 * 24 * 60)
- fother = TRUE;
- }
- else
- {
- if (qspan->uuconf_iend
- != qspan->uuconf_qnext->uuconf_istart)
- fother = TRUE;
- }
- }
- if (fprint && fother)
- printf (" (At other times will send any work)\n");
- }
- }
-
- if (fcall && qsys->uuconf_csuccess_wait != 0)
- printf (" Will wait %d seconds after a successful call\n",
- qsys->uuconf_csuccess_wait);
-
- if (qsys->uuconf_fsequence)
- printf (" Sequence numbers are used\n");
-
- if (fcalled)
- ukshow_chat (&qsys->uuconf_scalled_chat, " When called, chat");
-
- if (qsys->uuconf_zdebug != NULL)
- printf (" Debugging level %s\n", qsys->uuconf_zdebug);
- if (qsys->uuconf_zmax_remote_debug != NULL)
- printf (" Max remote debugging level %s\n",
- qsys->uuconf_zmax_remote_debug);
-
- if (fcall)
- {
- ukshow_size (qsys->uuconf_qcall_local_size, TRUE, TRUE);
- ukshow_size (qsys->uuconf_qcall_remote_size, TRUE, FALSE);
- }
- if (fcalled)
- {
- ukshow_size (qsys->uuconf_qcalled_local_size, FALSE, TRUE);
- ukshow_size (qsys->uuconf_qcalled_remote_size, FALSE, FALSE);
- }
-
- if (fcall)
- printf (" May %smake local requests when calling\n",
- qsys->uuconf_fcall_transfer ? "" : "not ");
-
- if (fcalled)
- printf (" May %smake local requests when called\n",
- qsys->uuconf_fcalled_transfer ? "" : "not ");
-
- if (qsys->uuconf_fcall_transfer || qsys->uuconf_fcalled_transfer)
- {
- printf (" May send by local request:");
- for (pz = qsys->uuconf_pzlocal_send; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
- if (! qsys->uuconf_fsend_request)
- printf (" May not send files by remote request\n");
- else
- {
- printf (" May send by remote request:");
- for (pz = qsys->uuconf_pzremote_send; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
- if (qsys->uuconf_fcall_transfer || qsys->uuconf_fcalled_transfer)
- {
- printf (" May accept by local request:");
- for (pz = qsys->uuconf_pzlocal_receive; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
- if (! qsys->uuconf_frec_request)
- printf (" May not receive files by remote request\n");
- else
- {
- printf (" May receive by remote request:");
- for (pz = qsys->uuconf_pzremote_receive; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
-
- printf (" May execute");
- for (pz = qsys->uuconf_pzcmds; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
-
- printf (" Execution path");
- for (pz = qsys->uuconf_pzpath; *pz != NULL; pz++)
- printf (" %s" , *pz);
- printf ("\n");
-
- if (qsys->uuconf_cfree_space != 0)
- printf (" Will leave %ld bytes available\n", qsys->uuconf_cfree_space);
-
- if (qsys->uuconf_zpubdir != NULL)
- printf (" Public directory is %s\n", qsys->uuconf_zpubdir);
-
- if (qsys->uuconf_pzforward_from != NULL)
- {
- printf (" May forward from");
- for (pz = qsys->uuconf_pzforward_from; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
-
- if (qsys->uuconf_pzforward_to != NULL)
- {
- printf (" May forward to");
- for (pz = qsys->uuconf_pzforward_to; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
-
- if (qsys->uuconf_zprotocols != NULL)
- printf (" Will use protocols %s\n", qsys->uuconf_zprotocols);
- else
- printf (" Will use any known protocol\n");
-
- if (qsys->uuconf_qproto_params != NULL)
- ukshow_proto_params (qsys->uuconf_qproto_params, 1);
- }
-
- if (! fanycall)
- printf (" Calls will never be placed to this system\n");
-}
-
-/* Show information about a port. */
-
-/*ARGSUSED*/
-static int
-ikshow_port (qport, pinfo)
- struct uuconf_port *qport;
- pointer pinfo;
-{
- struct sinfo *qi = (struct sinfo *) pinfo;
- char **pz;
- struct uuconf_modem_port *qmodem;
- struct uuconf_tcp_port *qtcp;
- struct uuconf_tli_port *qtli;
- struct uuconf_pipe_port *qpipe;
-
- qi->fgot = TRUE;
-
- printf (" Port name %s\n", qport->uuconf_zname);
- switch (qport->uuconf_ttype)
- {
- case UUCONF_PORTTYPE_STDIN:
- printf (" Port type stdin\n");
- break;
- case UUCONF_PORTTYPE_DIRECT:
- printf (" Port type direct\n");
- if (qport->uuconf_u.uuconf_sdirect.uuconf_zdevice != NULL)
- printf (" Device %s\n",
- qport->uuconf_u.uuconf_sdirect.uuconf_zdevice);
- else
- printf (" Using port name as device name\n");
- printf (" Speed %ld\n", qport->uuconf_u.uuconf_sdirect.uuconf_ibaud);
- printf (" Carrier %savailable\n",
- qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier ? "" : "not ");
- printf (" Hardware flow control %savailable\n",
- qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow ? "" : "not ");
- break;
- case UUCONF_PORTTYPE_MODEM:
- qmodem = &qport->uuconf_u.uuconf_smodem;
- printf (" Port type modem\n");
- if (qmodem->uuconf_zdevice != NULL)
- printf (" Device %s\n", qmodem->uuconf_zdevice);
- else
- printf (" Using port name as device name\n");
- if (qmodem->uuconf_zdial_device != NULL)
- printf (" Dial device %s\n", qmodem->uuconf_zdial_device);
- printf (" Speed %ld\n", qmodem->uuconf_ibaud);
- if (qmodem->uuconf_ilowbaud != qmodem->uuconf_ihighbaud)
- printf (" Speed range %ld to %ld\n", qmodem->uuconf_ilowbaud,
- qmodem->uuconf_ihighbaud);
- printf (" Carrier %savailable\n",
- qmodem->uuconf_fcarrier ? "" : "not ");
- printf (" Hardware flow control %savailable\n",
- qmodem->uuconf_fhardflow ? "" : "not ");
- if (qmodem->uuconf_qdialer != NULL)
- {
- printf (" Specially defined dialer\n");
- ukshow_dialer (qmodem->uuconf_qdialer);
- }
- else if (qmodem->uuconf_pzdialer != NULL
- && qmodem->uuconf_pzdialer[0] != NULL)
- {
- struct uuconf_dialer sdial;
- int iret;
-
- /* This might be a single dialer name, or it might be a
- sequence of dialer/token pairs. */
-
- if (qmodem->uuconf_pzdialer[1] == NULL
- || qmodem->uuconf_pzdialer[2] == NULL)
- {
- iret = uuconf_dialer_info (qi->puuconf,
- qmodem->uuconf_pzdialer[0],
- &sdial);
- if (iret == UUCONF_NOT_FOUND)
- printf (" *** No dialer %s\n", qmodem->uuconf_pzdialer[0]);
- else if (iret != UUCONF_SUCCESS)
- ukuuconf_error (qi->puuconf, iret);
- else
- {
- printf (" Dialer %s\n", qmodem->uuconf_pzdialer[0]);
- ukshow_dialer (&sdial);
- if (qmodem->uuconf_pzdialer[1] != NULL)
- printf (" Token %s\n", qmodem->uuconf_pzdialer[1]);
- }
- }
- else
- {
- pz = qmodem->uuconf_pzdialer;
- while (*pz != NULL)
- {
- iret = uuconf_dialer_info (qi->puuconf, *pz, &sdial);
- if (iret == UUCONF_NOT_FOUND)
- printf (" *** No dialer %s\n", *pz);
- else if (iret != UUCONF_SUCCESS)
- ukuuconf_error (qi->puuconf, iret);
- else
- {
- printf (" Dialer %s\n", *pz);
- ukshow_dialer (&sdial);
- }
-
- ++pz;
- if (*pz != NULL)
- {
- printf (" Token %s\n", *pz);
- ++pz;
- }
- }
- }
- }
- else
- printf (" *** No dialer information\n");
- break;
- case UUCONF_PORTTYPE_TCP:
- qtcp = &qport->uuconf_u.uuconf_stcp;
- printf (" Port type tcp\n");
- printf (" TCP service %s\n", qtcp->uuconf_zport);
- if (qtcp->uuconf_pzdialer != NULL
- && qtcp->uuconf_pzdialer[0] != NULL)
- {
- printf (" Dialer sequence");
- for (pz = qtcp->uuconf_pzdialer; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
- break;
- case UUCONF_PORTTYPE_TLI:
- qtli = &qport->uuconf_u.uuconf_stli;
- printf (" Port type TLI%s\n",
- qtli->uuconf_fstream ? "S" : "");
- if (qtli->uuconf_zdevice != NULL)
- printf (" Device %s\n", qtli->uuconf_zdevice);
- else
- printf (" Using port name as device name\n");
- if (qtli->uuconf_pzpush != NULL)
- {
- printf (" Push");
- for (pz = qtli->uuconf_pzpush; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
- if (qtli->uuconf_pzdialer != NULL
- && qtli->uuconf_pzdialer[0] != NULL)
- {
- printf (" Dialer sequence");
- for (pz = qtli->uuconf_pzdialer; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
- if (qtli->uuconf_zservaddr != NULL)
- printf (" Server address %s\n", qtli->uuconf_zservaddr);
- break;
- case UUCONF_PORTTYPE_PIPE:
- qpipe = &qport->uuconf_u.uuconf_spipe;
- printf (" Port type pipe\n");
- if (qpipe->uuconf_pzcmd != NULL)
- {
- printf (" Command");
- for (pz = qpipe->uuconf_pzcmd; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
- break;
- default:
- fprintf (stderr, " CAN'T HAPPEN\n");
- break;
- }
-
- if (qport->uuconf_zprotocols != NULL)
- printf (" Will use protocols %s\n", qport->uuconf_zprotocols);
-
- if (qport->uuconf_zlockname != NULL)
- printf (" Will use lockname %s\n", qport->uuconf_zlockname);
-
- if ((qport->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0)
- ukshow_reliable (qport->uuconf_ireliable, " ");
-
- if (qport->uuconf_qproto_params != NULL)
- ukshow_proto_params (qport->uuconf_qproto_params, 3);
-
- /* Return NOT_FOUND to force find_port to continue searching. */
- return UUCONF_NOT_FOUND;
-}
-
-/* Show information about a dialer. */
-
-static void
-ukshow_dialer (q)
- struct uuconf_dialer *q;
-{
- ukshow_chat (&q->uuconf_schat, " Chat");
- printf (" Wait for dialtone %s\n", q->uuconf_zdialtone);
- printf (" Pause while dialing %s\n", q->uuconf_zpause);
- printf (" Carrier %savailable\n", q->uuconf_fcarrier ? "" : "not ");
- if (q->uuconf_fcarrier)
- printf (" Wait %d seconds for carrier\n", q->uuconf_ccarrier_wait);
- if (q->uuconf_fdtr_toggle)
- {
- printf (" Toggle DTR");
- if (q->uuconf_fdtr_toggle_wait)
- printf (" and wait");
- printf ("\n");
- }
- ukshow_chat (&q->uuconf_scomplete, " When complete chat");
- ukshow_chat (&q->uuconf_sabort, " When aborting chat");
- if ((q->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0)
- ukshow_reliable (q->uuconf_ireliable, " ");
- if (q->uuconf_qproto_params != NULL)
- ukshow_proto_params (q->uuconf_qproto_params, 4);
-}
-
-/* Show a chat script. */
-
-static void
-ukshow_chat (qchat, zhdr)
- const struct uuconf_chat *qchat;
- const char *zhdr;
-{
- char **pz;
-
- if (qchat->uuconf_pzprogram != NULL)
- {
- printf ("%s program", zhdr);
- for (pz = qchat->uuconf_pzprogram; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
-
- if (qchat->uuconf_pzchat != NULL)
- {
-
- printf ("%s script", zhdr);
- for (pz = qchat->uuconf_pzchat; *pz != NULL; pz++)
- {
- if ((*pz)[0] != '-' || pz == qchat->uuconf_pzchat)
- printf (" ");
- printf ("%s", *pz);
- }
- printf ("\n");
- printf ("%s script timeout %d\n", zhdr, qchat->uuconf_ctimeout);
- if (qchat->uuconf_pzfail != NULL)
- {
- printf ("%s failure strings", zhdr);
- for (pz = qchat->uuconf_pzfail; *pz != NULL; pz++)
- printf (" %s", *pz);
- printf ("\n");
- }
- if (qchat->uuconf_fstrip)
- printf ("%s script incoming bytes stripped to seven bits\n", zhdr);
- }
-}
-
-/* Show a size/time restriction. */
-
-static void
-ukshow_size (qspan, fcall, flocal)
- struct uuconf_timespan *qspan;
- boolean fcall;
- boolean flocal;
-{
- struct uuconf_timespan *q;
- boolean fother;
-
- qspan = qcompress_span (qspan);
- if (qspan == NULL)
- return;
-
- printf (" If call%s the following applies to a %s request:\n",
- fcall ? "ing" : "ed", flocal ? "local" : "remote");
-
- fother = FALSE;
- if (qspan->uuconf_istart >= 60)
- fother = TRUE;
-
- for (q = qspan; q != NULL; q = q->uuconf_qnext)
- {
- printf (" ");
- ukshow_time (q);
- printf (" may transfer files %ld bytes or smaller\n", q->uuconf_ival);
- if (q->uuconf_qnext == NULL)
- {
- if (q->uuconf_iend <= 6 * 24 * 60 + 23 * 60)
- fother = TRUE;
- }
- else
- {
- if (q->uuconf_iend + 60 <= q->uuconf_qnext->uuconf_istart)
- fother = TRUE;
- }
- }
-
- if (fother)
- printf (" (At other times may send files of any size)\n");
-}
-
-/* Show reliability information. */
-
-static void
-ukshow_reliable (i, zhdr)
- int i;
- const char *zhdr;
-{
- printf ("%sCharacteristics:", zhdr);
- if ((i & UUCONF_RELIABLE_EIGHT) != 0)
- printf (" eight-bit-clean");
- else
- printf (" not-eight-bit-clean");
- if ((i & UUCONF_RELIABLE_RELIABLE) != 0)
- printf (" reliable");
- if ((i & UUCONF_RELIABLE_ENDTOEND) != 0)
- printf (" end-to-end");
- if ((i & UUCONF_RELIABLE_FULLDUPLEX) != 0)
- printf (" fullduplex");
- else
- printf (" halfduplex");
- printf ("\n");
-}
-
-/* Show protocol parameters. */
-
-static void
-ukshow_proto_params (pas, cindent)
- struct uuconf_proto_param *pas;
- int cindent;
-{
- struct uuconf_proto_param *q;
-
- for (q = pas; q->uuconf_bproto != '\0'; q++)
- {
- int i;
- struct uuconf_proto_param_entry *qe;
-
- for (i = 0; i < cindent; i++)
- printf (" ");
- printf ("For protocol %c will use the following parameters\n",
- q->uuconf_bproto);
- for (qe = q->uuconf_qentries; qe->uuconf_cargs > 0; qe++)
- {
- int ia;
-
- for (i = 0; i < cindent; i++)
- printf (" ");
- for (ia = 0; ia < qe->uuconf_cargs; ia++)
- printf (" %s", qe->uuconf_pzargs[ia]);
- printf ("\n");
- }
- }
-}
-
-/* Display a time span. */
-
-static void
-ukshow_time (q)
- const struct uuconf_timespan *q;
-{
- int idaystart, idayend;
- int ihourstart, ihourend;
- int iminutestart, iminuteend;
- const char * const zdays = "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat\0Sun";
-
- if (q->uuconf_istart == 0 && q->uuconf_iend == 7 * 24 * 60)
- {
- printf ("At any time");
- return;
- }
-
- idaystart = q->uuconf_istart / (24 * 60);
- ihourstart = (q->uuconf_istart % (24 * 60)) / 60;
- iminutestart = q->uuconf_istart % 60;
- idayend = q->uuconf_iend / (24 * 60);
- ihourend = (q->uuconf_iend % (24 * 60)) / 60;
- iminuteend = q->uuconf_iend % 60;
-
- if (idaystart == idayend)
- printf ("%s from %02d:%02d to %02d:%02d", zdays + idaystart * 4,
- ihourstart, iminutestart, ihourend, iminuteend);
- else
- printf ("From %s %02d:%02d to %s %02d:%02d",
- zdays + idaystart * 4, ihourstart, iminutestart,
- zdays + idayend * 4, ihourend, iminuteend);
-}
-
-/* Compress a time span by merging any two adjacent spans with
- identical values. This isn't necessary for uucico, but it looks
- nicer when printed out. */
-
-static struct uuconf_timespan *
-qcompress_span (qlist)
- struct uuconf_timespan *qlist;
-{
- struct uuconf_timespan **pq;
-
- pq = &qlist;
- while (*pq != NULL)
- {
- if ((*pq)->uuconf_qnext != NULL
- && (*pq)->uuconf_iend == (*pq)->uuconf_qnext->uuconf_istart
- && (*pq)->uuconf_ival == (*pq)->uuconf_qnext->uuconf_ival)
- {
- struct uuconf_timespan *qnext;
-
- qnext = (*pq)->uuconf_qnext;
- (*pq)->uuconf_qnext = qnext->uuconf_qnext;
- (*pq)->uuconf_iend = qnext->uuconf_iend;
- }
- else
- pq = &(*pq)->uuconf_qnext;
- }
-
- return qlist;
-}
-
-/* Display a uuconf error and exit. */
-
-static void
-ukuuconf_error (puuconf, iret)
- pointer puuconf;
- int iret;
-{
- char ab[512];
-
- (void) uuconf_error_string (puuconf, iret, ab, sizeof ab);
- if ((iret & UUCONF_ERROR_FILENAME) == 0)
- fprintf (stderr, "%s: %s\n", zKprogram, ab);
- else
- fprintf (stderr, "%s:%s\n", zKprogram, ab);
- exit (EXIT_FAILURE);
-}
diff --git a/gnu/libexec/uucp/uucico/Makefile b/gnu/libexec/uucp/uucico/Makefile
deleted file mode 100644
index 06a47e7..0000000
--- a/gnu/libexec/uucp/uucico/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-# Makefile for uucico
-# $Id$
-
-BINDIR= $(libxdir)
-BINOWN= $(owner)
-BINGRP= dialer
-BINMODE= 6555
-
-PROG= uucico
-SRCS= uucico.c trans.c send.c rec.c xcmd.c prot.c protg.c protf.c \
- prott.c prote.c proti.c protj.c proty.c protz.c time.c log.c \
- chat.c conn.c util.c copy.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -DVERSION=\"$(VERSION)\" -DOWNER=\"$(owner)\"
-
-MAN8= uucico.8
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../common_sources
diff --git a/gnu/libexec/uucp/uucico/prote.c b/gnu/libexec/uucp/uucico/prote.c
deleted file mode 100644
index a954a24..0000000
--- a/gnu/libexec/uucp/uucico/prote.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/* prote.c
- The 'e' protocol.
-
- Copyright (C) 1991, 1992, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char prote_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "trans.h"
-#include "system.h"
-#include "prot.h"
-
-/* This implementation is based on my implementation of the 't'
- protocol, which is fairly similar. The main difference between the
- protocols seems to be that 't' breaks the file into packets and
- transmits the size of the packet with each packet, whereas 'e'
- sends the size of the entire file and then sends all the data in a
- single enormous packet.
-
- The 'e' protocol does no error checking whatsoever and thus
- requires an end-to-end verified eight bit communication line, such
- as is provided by TCP. Using it with a modem is inadvisable, since
- errors can occur between the modem and the computer. */
-
-/* The buffer size we use. */
-#define CEBUFSIZE (CRECBUFLEN / 2)
-
-/* The size of the initial file size message. */
-#define CEFRAMELEN (20)
-
-/* A pointer to the buffer we will use. */
-static char *zEbuf;
-
-/* True if we are receiving a file. */
-static boolean fEfile;
-
-/* The number of bytes we have left to send or receive. */
-static long cEbytes;
-
-/* The timeout we use. */
-static int cEtimeout = 120;
-
-struct uuconf_cmdtab asEproto_params[] =
-{
- { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cEtimeout, NULL },
- { NULL, 0, NULL, NULL }
-};
-
-/* Local function. */
-
-static boolean feprocess_data P((struct sdaemon *qdaemon, boolean *pfexit,
- size_t *pcneed));
-
-/* Start the protocol. */
-
-boolean
-festart (qdaemon, pzlog)
- struct sdaemon *qdaemon;
- char **pzlog;
-{
- *pzlog = NULL;
- if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE,
- STRIPSETTING_EIGHTBITS, XONXOFF_OFF))
- return FALSE;
- zEbuf = (char *) xmalloc (CEBUFSIZE);
- fEfile = FALSE;
- usysdep_sleep (2);
- return TRUE;
-}
-
-/* Stop the protocol. */
-
-/*ARGSUSED*/
-boolean
-feshutdown (qdaemon)
- struct sdaemon *qdaemon;
-{
- xfree ((pointer) zEbuf);
- zEbuf = NULL;
- cEtimeout = 120;
- return TRUE;
-}
-
-/* Send a command string. We send everything up to and including the
- null byte. */
-
-/*ARGSUSED*/
-boolean
-fesendcmd (qdaemon, z, ilocal, iremote)
- struct sdaemon *qdaemon;
- const char *z;
- int ilocal;
- int iremote;
-{
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fesendcmd: Sending command \"%s\"", z);
-
- return fsend_data (qdaemon->qconn, z, strlen (z) + 1, TRUE);
-}
-
-/* Get space to be filled with data. We provide a buffer which has
- 20 bytes at the start available to hold the length. */
-
-/*ARGSUSED*/
-char *
-zegetspace (qdaemon, pclen)
- struct sdaemon *qdaemon;
- size_t *pclen;
-{
- *pclen = CEBUFSIZE;
- return zEbuf;
-}
-
-/* Send out some data. We are allowed to modify the 20 bytes
- preceding the buffer. This allows us to send the entire block with
- header bytes in a single call. */
-
-/*ARGSIGNORED*/
-boolean
-fesenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos)
- struct sdaemon *qdaemon;
- char *zdata;
- size_t cdata;
- int ilocal;
- int iremote;
- long ipos;
-{
-#if DEBUG > 0
- /* Keep track of the number of bytes we send out to make sure it all
- adds up. */
- cEbytes -= cdata;
- if (cEbytes < 0)
- {
- ulog (LOG_ERROR, "Protocol 'e' internal error");
- return FALSE;
- }
-#endif
-
- /* We pass FALSE to fsend_data since we don't expect the other side
- to be sending us anything just now. */
- return fsend_data (qdaemon->qconn, zdata, cdata, FALSE);
-}
-
-/* Process data and return the amount we need in *pfneed. */
-
-static boolean
-feprocess_data (qdaemon, pfexit, pcneed)
- struct sdaemon *qdaemon;
- boolean *pfexit;
- size_t *pcneed;
-{
- int cinbuf, cfirst, clen;
-
- *pfexit = FALSE;
-
- cinbuf = iPrecend - iPrecstart;
- if (cinbuf < 0)
- cinbuf += CRECBUFLEN;
-
- if (! fEfile)
- {
- /* We are not receiving a file. Commands continue up to a null
- byte. */
- while (cinbuf > 0)
- {
- char *pnull;
-
- cfirst = CRECBUFLEN - iPrecstart;
- if (cfirst > cinbuf)
- cfirst = cinbuf;
-
- pnull = memchr (abPrecbuf + iPrecstart, '\0', (size_t) cfirst);
- if (pnull != NULL)
- cfirst = pnull - (abPrecbuf + iPrecstart) + 1;
-
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "feprocess_data: Got %d command bytes",
- cfirst);
-
- if (! fgot_data (qdaemon, abPrecbuf + iPrecstart,
- (size_t) cfirst, (const char *) NULL, (size_t) 0,
- -1, -1, (long) -1, TRUE, pfexit))
- return FALSE;
-
- iPrecstart = (iPrecstart + cfirst) % CRECBUFLEN;
-
- if (*pfexit)
- return TRUE;
-
- cinbuf = iPrecend - iPrecstart;
- if (cinbuf < 0)
- cinbuf += CRECBUFLEN;
- }
-
- if (pcneed != NULL)
- *pcneed = 1;
-
- return TRUE;
- }
-
- /* Here we are receiving a file. We want cEbytes in total. If we
- don't have cEbytes yet, we have to get it first. */
-
- if (cEbytes == -1)
- {
- char ab[CEFRAMELEN + 1];
-
- if (cinbuf < CEFRAMELEN)
- {
- if (pcneed != NULL)
- *pcneed = CEFRAMELEN - cinbuf;
- return TRUE;
- }
-
- cfirst = CRECBUFLEN - iPrecstart;
- if (cfirst >= CEFRAMELEN)
- memcpy (ab, abPrecbuf + iPrecstart, (size_t) CEFRAMELEN);
- else
- {
- memcpy (ab, abPrecbuf + iPrecstart, (size_t) cfirst);
- memcpy (ab + cfirst, abPrecbuf, (size_t) CEFRAMELEN - cfirst);
- }
-
- ab[CEFRAMELEN] = '\0';
- cEbytes = strtol (ab, (char **) NULL, 10);
-
- iPrecstart = (iPrecstart + CEFRAMELEN) % CRECBUFLEN;
-
- cinbuf = iPrecend - iPrecstart;
- if (cinbuf < 0)
- cinbuf += CRECBUFLEN;
-
- if (cEbytes == 0)
- {
- if (! fgot_data (qdaemon, abPrecbuf, (size_t) 0,
- (const char *) NULL, (size_t) 0,
- -1, -1, (long) -1, TRUE, pfexit))
- return FALSE;
- if (*pfexit)
- return TRUE;
- }
- }
-
- /* Here we can read real data for the file. */
-
- while (cinbuf > 0)
- {
- clen = cinbuf;
- if ((long) clen > cEbytes)
- clen = (int) cEbytes;
-
- cfirst = CRECBUFLEN - iPrecstart;
- if (cfirst > clen)
- cfirst = clen;
-
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "feprocess_data: Got %d data bytes",
- clen);
-
- if (! fgot_data (qdaemon, abPrecbuf + iPrecstart,
- (size_t) cfirst, abPrecbuf, (size_t) (clen - cfirst),
- -1, -1, (long) -1, TRUE, pfexit))
- return FALSE;
-
- iPrecstart = (iPrecstart + clen) % CRECBUFLEN;
- cEbytes -= clen;
-
- if (cEbytes == 0)
- {
- if (! fgot_data (qdaemon, abPrecbuf, (size_t) 0,
- (const char *) NULL, (size_t) 0,
- -1, -1, (long) -1, TRUE, pfexit))
- return FALSE;
- if (*pfexit)
- return TRUE;
- }
-
- cinbuf -= clen;
- }
-
- if (pcneed != NULL)
- {
- if (cEbytes > CRECBUFLEN / 2)
- *pcneed = CRECBUFLEN / 2;
- else
- *pcneed = (int) cEbytes;
- }
-
- return TRUE;
-}
-
-/* Wait for data to come in and process it until we've reached the end
- of a command or a file. */
-
-boolean
-fewait (qdaemon)
- struct sdaemon *qdaemon;
-{
- while (TRUE)
- {
- boolean fexit;
- size_t cneed, crec;
-
- if (! feprocess_data (qdaemon, &fexit, &cneed))
- return FALSE;
- if (fexit)
- return TRUE;
-
- if (! freceive_data (qdaemon->qconn, cneed, &crec, cEtimeout, TRUE))
- return FALSE;
-
- if (crec == 0)
- {
- ulog (LOG_ERROR, "Timed out waiting for data");
- return FALSE;
- }
- }
-}
-
-/* File level routine, to handle transferring the amount of data and
- to set fEfile correctly. */
-
-boolean
-fefile (qdaemon, qtrans, fstart, fsend, cbytes, pfhandled)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
- boolean fstart;
- boolean fsend;
- long cbytes;
- boolean *pfhandled;
-{
- *pfhandled = FALSE;
-
- if (fstart)
- {
- if (fsend)
- {
- char ab[CEFRAMELEN];
-
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "Protocol 'e' starting to send %ld bytes",
- cbytes);
-
- bzero (ab, (size_t) CEFRAMELEN);
- sprintf (ab, "%ld", cbytes);
- if (! fsend_data (qdaemon->qconn, ab, (size_t) CEFRAMELEN, TRUE))
- return FALSE;
- cEbytes = cbytes;
- }
- else
- {
- cEbytes = -1;
- fEfile = TRUE;
- }
- }
- else
- {
- if (! fsend)
- fEfile = FALSE;
-#if DEBUG > 0
- if (cEbytes != 0)
- {
- ulog (LOG_ERROR,
- "Protocol 'e' internal error: %ld bytes left over",
- cEbytes);
- return FALSE;
- }
-#endif
- }
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/uucico/protf.c b/gnu/libexec/uucp/uucico/protf.c
deleted file mode 100644
index 464d13c..0000000
--- a/gnu/libexec/uucp/uucico/protf.c
+++ /dev/null
@@ -1,848 +0,0 @@
-/* protf.c
- The 'f' protocol.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char protf_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "trans.h"
-#include "system.h"
-#include "prot.h"
-
-/* This implementation is based on code by Piet Beertema, CWI,
- Amsterdam, Sep 1984.
-
- This code implements the 'f' protocol, which requires a
- flow-controlled error-free seven-bit data path. It does check for
- errors, but only at the end of each file transmission, so a noisy
- line without error correcting modems will be unusable.
-
- The conversion to seven bit data is done as follows, where b
- represents the character to convert:
-
- 0 <= b <= 037: 0172, b + 0100 (0100 to 0137)
- 040 <= b <= 0171: b ( 040 to 0171)
- 0172 <= b <= 0177: 0173, b - 0100 ( 072 to 077)
- 0200 <= b <= 0237: 0174, b - 0100 (0100 to 0137)
- 0240 <= b <= 0371: 0175, b - 0200 ( 040 to 0171)
- 0372 <= b <= 0377: 0176, b - 0300 ( 072 to 077)
-
- This causes all output bytes to be in the range 040 to 0176; these
- are the printable ASCII characters. */
-
-/* This structure is used to hold information when dealing with the
- end of file acknowledgement. */
-
-struct sfinfo
-{
- /* The functions from the generic code. */
- boolean (*psendfn) P((struct stransfer *qtrans, struct sdaemon *qdaemon));
- boolean (*precfn) P((struct stransfer *qtrans, struct sdaemon *qdaemon,
- const char *zdata, size_t cdata));
- /* The info pointer from the generic code. */
- pointer pinfo;
- /* The character to send after receiving the checksum. */
- char bsend;
-};
-
-/* Internal functions. */
-static boolean ffprocess_data P((struct sdaemon *qdaemon,
- boolean *pfexit, size_t *pcneed));
-static boolean ffawait_ack P((struct stransfer *qtrans,
- struct sdaemon *qdaemon,
- const char *zdata, size_t cdata));
-static boolean ffawait_cksum P((struct stransfer *qtrans,
- struct sdaemon *qdaemon,
- const char *zdata, size_t cdata));
-static boolean ffsend_ack P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-
-/* The size of the buffer we allocate to store outgoing data in. */
-#define CFBUFSIZE (256)
-
-/* The timeout to wait for data to arrive before giving up. */
-static int cFtimeout = 120;
-
-/* The maximum number of retries. */
-static int cFmaxretries = 2;
-
-/* The buffer we allocate for outgoing data. */
-static char *zFbuf;
-
-/* TRUE if we are receiving a file rather than a command. */
-static boolean fFfile;
-
-/* The checksum so far. */
-static unsigned int iFcheck;
-
-/* The last special byte (0172 to 0176) or 0 if none. */
-static char bFspecial;
-
-/* The number of times we have retried this file. */
-static int cFretries;
-
-/* Whether this file has been acknowledged. */
-static boolean fFacked;
-
-struct uuconf_cmdtab asFproto_params[] =
-{
- { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cFtimeout, NULL },
- { "retries", UUCONF_CMDTABTYPE_INT, (pointer) &cFmaxretries, NULL },
- { NULL, 0, NULL, NULL }
-};
-
-/* Statistics. */
-
-/* The number of data bytes sent in files. */
-static long cFsent_data;
-
-/* The number of actual bytes sent in files. */
-static long cFsent_bytes;
-
-/* The number of data bytes received in files. */
-static long cFrec_data;
-
-/* The number of actual bytes received in files. */
-static long cFrec_bytes;
-
-/* The number of file retries when sending. */
-static long cFsend_retries;
-
-/* The number of file retries when receiving. */
-static long cFrec_retries;
-
-/* Start the protocol. */
-
-boolean
-ffstart (qdaemon, pzlog)
- struct sdaemon *qdaemon;
- char **pzlog;
-{
- *pzlog = NULL;
-
- cFsent_data = 0;
- cFsent_bytes = 0;
- cFrec_data = 0;
- cFrec_bytes = 0;
- cFsend_retries = 0;
- cFrec_retries = 0;
-
- /* Use XON/XOFF handshaking. */
- if (! fconn_set (qdaemon->qconn, PARITYSETTING_DEFAULT,
- STRIPSETTING_SEVENBITS, XONXOFF_ON))
- return FALSE;
-
- /* We sleep to allow the other side to reset the terminal; this is
- what Mr. Beertema's code does. */
- usysdep_sleep (2);
-
- return TRUE;
-}
-
-/* Shutdown the protocol. */
-
-/*ARGSIGNORED*/
-boolean
-ffshutdown (qdaemon)
- struct sdaemon *qdaemon;
-{
- xfree ((pointer) zFbuf);
- zFbuf = NULL;
- ulog (LOG_NORMAL,
- "Protocol 'f': sent %ld bytes for %ld, received %ld bytes for %ld",
- cFsent_bytes, cFsent_data, cFrec_bytes, cFrec_data);
- if (cFsend_retries != 0 || cFrec_retries != 0)
- ulog (LOG_NORMAL, "Protocol 'f' file retries: %ld sending, %ld receiving",
- cFsend_retries, cFrec_retries);
- cFtimeout = 120;
- cFmaxretries = 2;
- return TRUE;
-}
-
-/* Send a command string. We just send the string followed by a carriage
- return. */
-
-/*ARGSUSED*/
-boolean
-ffsendcmd (qdaemon, z, ilocal, iremote)
- struct sdaemon *qdaemon;
- const char *z;
- int ilocal;
- int iremote;
-{
- size_t clen;
- char *zalc;
- boolean fret;
-
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "ffsendcmd: Sending command \"%s\"", z);
-
- clen = strlen (z);
- zalc = zbufalc (clen + 2);
- memcpy (zalc, z, clen);
- zalc[clen] = '\r';
- zalc[clen + 1] = '\0';
- fret = fsend_data (qdaemon->qconn, zalc, clen + 1, TRUE);
- ubuffree (zalc);
- return fret;
-}
-
-/* Get space to be filled with data. We allocate the space from the
- heap. */
-
-/*ARGSIGNORED*/
-char *
-zfgetspace (qdaemon, pclen)
- struct sdaemon *qdaemon;
- size_t *pclen;
-{
- *pclen = CFBUFSIZE;
- if (zFbuf == NULL)
- zFbuf = (char *) xmalloc (CFBUFSIZE);
- return zFbuf;
-}
-
-/* Send out a data packet. We have to encode the data into seven bits
- and accumulate a checksum. */
-
-/*ARGSIGNORED*/
-boolean
-ffsenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos)
- struct sdaemon *qdaemon;
- char *zdata;
- size_t cdata;
- int ilocal;
- int iremote;
- long ipos;
-{
- char ab[CFBUFSIZE * 2];
- char *ze;
- register unsigned int itmpchk;
-
- cFsent_data += cdata;
-
- ze = ab;
- itmpchk = iFcheck;
- while (cdata-- > 0)
- {
- register int b;
-
- /* Rotate the checksum left. */
- if ((itmpchk & 0x8000) == 0)
- itmpchk <<= 1;
- else
- {
- itmpchk <<= 1;
- ++itmpchk;
- }
-
- /* Add the next byte into the checksum. */
- b = *zdata++ & 0xff;
- itmpchk += b;
-
- /* Encode the byte. */
- if (b <= 0177)
- {
- if (b <= 037)
- {
- *ze++ = '\172';
- *ze++ = (char) (b + 0100);
- }
- else if (b <= 0171)
- *ze++ = (char) b;
- else
- {
- *ze++ = '\173';
- *ze++ = (char) (b - 0100);
- }
- }
- else
- {
- if (b <= 0237)
- {
- *ze++ = '\174';
- *ze++ = (char) (b - 0100);
- }
- else if (b <= 0371)
- {
- *ze++ = '\175';
- *ze++ = (char) (b - 0200);
- }
- else
- {
- *ze++ = '\176';
- *ze++ = (char) (b - 0300);
- }
- }
- }
-
- iFcheck = itmpchk;
-
- cFsent_bytes += ze - ab;
-
- /* Passing FALSE tells fsend_data not to bother looking for incoming
- information, since we really don't expect any. */
- return fsend_data (qdaemon->qconn, ab, (size_t) (ze - ab), FALSE);
-}
-
-/* Process data and return the amount of data we are looking for in
- *pcneed. The 'f' protocol doesn't really reveal this, but when
- transferring file we know that we need at least seven characters
- for the checksum. */
-
-static boolean
-ffprocess_data (qdaemon, pfexit, pcneed)
- struct sdaemon *qdaemon;
- boolean *pfexit;
- size_t *pcneed;
-{
- int i;
- register unsigned int itmpchk;
-
- *pfexit = FALSE;
- if (pcneed != NULL)
- *pcneed = 1;
-
- if (! fFfile)
- {
- /* A command continues until a '\r' character, which we turn
- into '\0' before calling fgot_data. */
- while (iPrecstart != iPrecend)
- {
- for (i = iPrecstart; i < CRECBUFLEN && i != iPrecend; i++)
- {
- /* Some systems seem to send characters with parity, so
- strip the parity bit. */
- abPrecbuf[i] &= 0x7f;
-
- if (abPrecbuf[i] == '\r')
- {
- int istart;
-
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "ffprocess_data: Got %d command bytes",
- i - iPrecstart + 1);
-
- abPrecbuf[i] = '\0';
- istart = iPrecstart;
- iPrecstart = (i + 1) % CRECBUFLEN;
- if (pcneed != NULL)
- *pcneed = 0;
- return fgot_data (qdaemon, abPrecbuf + istart,
- (size_t) (i - istart + 1),
- (const char *) NULL, (size_t) 0,
- -1, -1, (long) -1, TRUE, pfexit);
- }
- }
-
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "ffprocess_data: Got %d command bytes",
- i - iPrecstart);
-
- if (! fgot_data (qdaemon, abPrecbuf + iPrecstart,
- (size_t) (i - iPrecstart),
- (const char *) NULL, (size_t) 0,
- -1, -1, (long) -1, TRUE, pfexit))
- return FALSE;
-
- iPrecstart = i % CRECBUFLEN;
- }
-
- return TRUE;
- }
-
- /* Here the data is destined for a file, and we must decode it. */
-
- itmpchk = iFcheck;
-
- while (iPrecstart != iPrecend)
- {
- char *zstart, *zto, *zfrom;
- int c;
-
- zto = zfrom = zstart = abPrecbuf + iPrecstart;
-
- c = iPrecend - iPrecstart;
- if (c < 0)
- c = CRECBUFLEN - iPrecstart;
-
- while (c-- != 0)
- {
- int b;
-
- /* Some systems seem to send characters with parity, so
- strip the parity bit. */
- b = *zfrom++ & 0x7f;
- if (b < 040 || b > 0176)
- {
- ulog (LOG_ERROR, "Illegal byte %d", b);
- continue;
- }
-
- /* Characters >= 0172 are always special characters. The
- only legal pair of consecutive special characters
- are 0176 0176 which immediately precede the four
- digit checksum. */
- if (b >= 0172)
- {
- if (bFspecial != 0)
- {
- if (bFspecial != 0176 || b != 0176)
- {
- ulog (LOG_ERROR, "Illegal bytes %d %d",
- bFspecial, b);
- bFspecial = 0;
- continue;
- }
-
- /* Pass any initial data. */
- if (zto != zstart)
- {
- /* Don't count the checksum in the received bytes. */
- cFrec_bytes += zfrom - zstart - 2;
- cFrec_data += zto - zstart;
- if (! fgot_data (qdaemon, zstart,
- (size_t) (zto - zstart),
- (const char *) NULL, (size_t) 0,
- -1, -1, (long) -1, TRUE, pfexit))
- return FALSE;
- }
-
- /* The next characters we want to read are the
- checksum, so skip the second 0176. */
- iPrecstart = (iPrecstart + zfrom - zstart) % CRECBUFLEN;
-
- iFcheck = itmpchk;
-
- /* Tell fgot_data that we've read the entire file by
- passing 0 length data. This will wind up calling
- fffile to verify the checksum. We set *pcneed to
- 0 because we don't want to read any more data
- from the port, since we may have already read the
- checksum. */
- if (pcneed != NULL)
- *pcneed = 0;
- return fgot_data (qdaemon, (const char *) NULL,
- (size_t) 0, (const char *) NULL,
- (size_t) 0, -1, -1, (long) -1,
- TRUE, pfexit);
- }
-
- /* Here we have encountered a special character that
- does not follow another special character. */
- bFspecial = (char) b;
- }
- else
- {
- int bnext;
-
- /* Here we have encountered a nonspecial character. */
-
- switch (bFspecial)
- {
- default:
- bnext = b;
- break;
- case 0172:
- bnext = b - 0100;
- break;
- case 0173:
- case 0174:
- bnext = b + 0100;
- break;
- case 0175:
- bnext = b + 0200;
- break;
- case 0176:
- bnext = b + 0300;
- break;
- }
-
- *zto++ = (char) bnext;
- bFspecial = 0;
-
- /* Rotate the checksum left. */
- if ((itmpchk & 0x8000) == 0)
- itmpchk <<= 1;
- else
- {
- itmpchk <<= 1;
- ++itmpchk;
- }
-
- /* Add the next byte into the checksum. */
- itmpchk += bnext;
- }
- }
-
- if (zto != zstart)
- {
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "ffprocess_data: Got %d bytes",
- zto - zstart);
-
- cFrec_data += zto - zstart;
- if (! fgot_data (qdaemon, zstart, (size_t) (zto - zstart),
- (const char *) NULL, (size_t) 0,
- -1, -1, (long) -1, TRUE, pfexit))
- return FALSE;
- }
-
- cFrec_bytes += zfrom - zstart;
-
- iPrecstart = (iPrecstart + zfrom - zstart) % CRECBUFLEN;
- }
-
- iFcheck = itmpchk;
-
- if (pcneed != NULL)
- {
- /* At this point we may have seen the first 0176 in the checksum
- but not the second. The checksum is at least seven
- characters long (0176 0176 a b c d \r). This won't help
- much, but reading seven characters is a lot better than
- reading two, which is what I saw in a 2400 baud log file. */
- if (bFspecial == 0176)
- *pcneed = 6;
- else
- *pcneed = 7;
- }
-
- return TRUE;
-}
-
-/* Wait for data to come in and process it until we've finished a
- command or a file. */
-
-boolean
-ffwait (qdaemon)
- struct sdaemon *qdaemon;
-{
- while (TRUE)
- {
- boolean fexit;
- size_t cneed, crec;
-
- if (! ffprocess_data (qdaemon, &fexit, &cneed))
- return FALSE;
- if (fexit)
- return TRUE;
-
- if (cneed > 0)
- {
- /* We really want to do something like get all available
- characters, then sleep for half a second and get all
- available characters again, and keep this up until we
- don't get anything after sleeping. */
- if (! freceive_data (qdaemon->qconn, cneed, &crec, cFtimeout, TRUE))
- return FALSE;
- if (crec == 0)
- {
- ulog (LOG_ERROR, "Timed out waiting for data");
- return FALSE;
- }
- }
- }
-}
-
-/* File level operations. Reset the checksums when starting to send
- or receive a file, and output the checksum when we've finished
- sending a file. */
-
-/*ARGSUSED*/
-boolean
-fffile (qdaemon, qtrans, fstart, fsend, cbytes, pfhandled)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
- boolean fstart;
- boolean fsend;
- long cbytes;
- boolean *pfhandled;
-{
- DEBUG_MESSAGE3 (DEBUG_PROTO, "fffile: fstart %s; fsend %s; fFacked %s",
- fstart ? "true" : "false", fsend ? "true" : "false",
- fFacked ? "true" : "false");
-
- *pfhandled = FALSE;
-
- if (fstart)
- {
- iFcheck = 0xffff;
- cFretries = 0;
- fFacked = FALSE;
- if (! fsend)
- {
- bFspecial = 0;
- fFfile = TRUE;
- }
- return TRUE;
- }
- else
- {
- struct sfinfo *qinfo;
-
- /* We need to handle the checksum and the acknowledgement. If
- we get a successful ACK, we set fFacked to TRUE and call the
- send or receive function by hand. This will wind up calling
- here again, so if fFacked is TRUE we just return out and let
- the send or receive function do whatever it does. This is a
- bit of a hack. */
- if (fFacked)
- {
- fFacked = FALSE;
- return TRUE;
- }
-
- if (fsend)
- {
- char ab[sizeof "\176\176ABCD\r"];
-
- /* Send the final checksum. */
- sprintf (ab, "\176\176%04x\r", iFcheck & 0xffff);
- if (! fsend_data (qdaemon->qconn, ab, (size_t) 7, TRUE))
- return FALSE;
-
- /* Now wait for the acknowledgement. */
- fFfile = FALSE;
- qinfo = (struct sfinfo *) xmalloc (sizeof (struct sfinfo));
- qinfo->psendfn = qtrans->psendfn;
- qinfo->precfn = qtrans->precfn;
- qinfo->pinfo = qtrans->pinfo;
- qtrans->psendfn = NULL;
- qtrans->precfn = ffawait_ack;
- qtrans->pinfo = (pointer) qinfo;
- qtrans->fcmd = TRUE;
-
- *pfhandled = TRUE;
-
- return fqueue_receive (qdaemon, qtrans);
- }
- else
- {
- /* Wait for the checksum. */
- fFfile = FALSE;
- qinfo = (struct sfinfo *) xmalloc (sizeof (struct sfinfo));
- qinfo->psendfn = qtrans->psendfn;
- qinfo->precfn = qtrans->precfn;
- qinfo->pinfo = qtrans->pinfo;
- qtrans->psendfn = NULL;
- qtrans->precfn = ffawait_cksum;
- qtrans->pinfo = (pointer) qinfo;
- qtrans->fcmd = TRUE;
-
- *pfhandled = TRUE;
-
- return fqueue_receive (qdaemon, qtrans);
- }
- }
-}
-
-/* Wait for the ack after sending a file and the checksum. */
-
-static boolean
-ffawait_ack (qtrans, qdaemon, zdata, cdata)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
- const char *zdata;
- size_t cdata;
-{
- struct sfinfo *qinfo = (struct sfinfo *) qtrans->pinfo;
-
- qtrans->precfn = NULL;
-
- /* An R means to retry sending the file. */
- if (*zdata == 'R')
- {
- if (! ffileisopen (qtrans->e))
- {
- ulog (LOG_ERROR, "Request to resent non-file");
- return FALSE;
- }
-
- ++cFretries;
- if (cFretries > cFmaxretries)
- {
- ulog (LOG_ERROR, "Too many retries");
- return FALSE;
- }
-
- ulog (LOG_NORMAL, "Resending file");
- if (! ffilerewind (qtrans->e))
- {
- ulog (LOG_ERROR, "rewind: %s", strerror (errno));
- return FALSE;
- }
- qtrans->ipos = (long) 0;
-
- iFcheck = 0xffff;
- ++cFsend_retries;
-
- qtrans->psendfn = qinfo->psendfn;
- qtrans->precfn = qinfo->precfn;
- qtrans->pinfo = qinfo->pinfo;
- xfree ((pointer) qinfo);
- qtrans->fsendfile = TRUE;
-
- return fqueue_send (qdaemon, qtrans);
- }
-
- if (*zdata != 'G')
- {
- DEBUG_MESSAGE1 (DEBUG_PROTO, "fffile: Got \"%s\"", zdata);
- ulog (LOG_ERROR, "File send failed");
- return FALSE;
- }
-
- qtrans->psendfn = qinfo->psendfn;
- qtrans->precfn = qinfo->precfn;
- qtrans->pinfo = qinfo->pinfo;
- xfree ((pointer) qinfo);
-
- /* Now call the send function by hand after setting fFacked to TRUE.
- Since fFacked is true fffile will simply return out, and the send
- function can do whatever it what was going to do. */
- fFacked = TRUE;
- return (*qtrans->psendfn) (qtrans, qdaemon);
-}
-
-/* This function is called when the checksum arrives. */
-
-/*ARGSUSED*/
-static boolean
-ffawait_cksum (qtrans, qdaemon, zdata, cdata)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
- const char *zdata;
- size_t cdata;
-{
- struct sfinfo *qinfo = (struct sfinfo *) qtrans->pinfo;
- unsigned int icheck;
-
- qtrans->precfn = NULL;
-
- if (! isxdigit (zdata[0])
- || ! isxdigit (zdata[1])
- || ! isxdigit (zdata[2])
- || ! isxdigit (zdata[3])
- || zdata[4] != '\0')
- {
- ulog (LOG_ERROR, "Bad checksum format");
- xfree (qtrans->pinfo);
- return FALSE;
- }
-
- icheck = (unsigned int) strtol ((char *) zdata, (char **) NULL, 16);
-
- if (icheck != (iFcheck & 0xffff))
- {
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "Checksum failed; calculated 0x%x, got 0x%x",
- iFcheck & 0xffff, icheck);
-
- if (! ffileisopen (qtrans->e))
- {
- ulog (LOG_ERROR, "Failed to get non-file");
- return FALSE;
- }
-
- ++cFretries;
- if (cFretries > cFmaxretries)
- {
- ulog (LOG_ERROR, "Too many retries");
- qinfo->bsend = 'Q';
- }
- else
- {
- ulog (LOG_NORMAL, "File being resent");
-
- /* This bit of code relies on the receive code setting
- qtrans->s.ztemp to the full name of the temporary file
- being used. */
- qtrans->e = esysdep_truncate (qtrans->e, qtrans->s.ztemp);
- if (! ffileisopen (qtrans->e))
- return FALSE;
- qtrans->ipos = (long) 0;
-
- iFcheck = 0xffff;
- bFspecial = 0;
- fFfile = TRUE;
- ++cFrec_retries;
-
- /* Send an R to tell the other side to resend the file. */
- qinfo->bsend = 'R';
- }
- }
- else
- {
- /* Send a G to tell the other side the file was received
- correctly. */
- qinfo->bsend = 'G';
- }
-
- qtrans->psendfn = ffsend_ack;
-
- return fqueue_send (qdaemon, qtrans);
-}
-
-/* Send the acknowledgement, and then possible wait for the resent
- file. */
-
-static boolean
-ffsend_ack (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct sfinfo *qinfo = (struct sfinfo *) qtrans->pinfo;
- char ab[2];
-
- ab[0] = qinfo->bsend;
- ab[1] = '\0';
- if (! ffsendcmd (qdaemon, ab, 0, 0))
- return FALSE;
-
- qtrans->psendfn = qinfo->psendfn;
- qtrans->precfn = qinfo->precfn;
- qtrans->pinfo = qinfo->pinfo;
- xfree ((pointer) qinfo);
-
- if (ab[0] == 'Q')
- return FALSE;
- if (ab[0] == 'R')
- {
- qtrans->frecfile = TRUE;
- return fqueue_receive (qdaemon, qtrans);
- }
-
- fFacked = TRUE;
- return (*qtrans->precfn) (qtrans, qdaemon, (const char *) NULL,
- (size_t) 0);
-}
diff --git a/gnu/libexec/uucp/uucico/protg.c b/gnu/libexec/uucp/uucico/protg.c
deleted file mode 100644
index db5233d..0000000
--- a/gnu/libexec/uucp/uucico/protg.c
+++ /dev/null
@@ -1,1978 +0,0 @@
-/* protg.c
- The 'g' protocol.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char protg_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "trans.h"
-#include "system.h"
-#include "prot.h"
-
-/* Each 'g' protocol packet begins with six bytes. They are:
-
- <DLE><k><c0><c1><C><x>
-
- <DLE> is the ASCII DLE character (^P or '\020').
- if 1 <= <k> <= 8, the packet is followed by 2 ** (k + 4) bytes of data;
- if <k> == 9, these six bytes are a complete control packet;
- other value of <k> are illegal.
- <c0> is the low byte of a checksum.
- <c1> is the high byte of a checksum.
- <C> is a control byte (see below).
- <x> is <k> ^ <c0> ^ <c1> ^ <C>.
-
- The control byte <C> is divided into three bitfields:
-
- t t x x x y y y
-
- The two bit field tt is the packet type.
- The three bit field xxx is the control type for a control packet, or
- the sequence number for a data packet.
- The three bit field yyy is a value for a control packet, or the
- sequence number of the last packet received for a data packet.
-
- For all successfully recieved packets, the control byte is stored
- into iGpacket_control. */
-
-/* Names for the bytes in the frame header. */
-#define IFRAME_DLE (0)
-#define IFRAME_K (1)
-#define IFRAME_CHECKLOW (2)
-#define IFRAME_CHECKHIGH (3)
-#define IFRAME_CONTROL (4)
-#define IFRAME_XOR (5)
-
-/* Length of the frame header. */
-#define CFRAMELEN (6)
-
-/* Macros to break apart the control bytes. */
-#define CONTROL_TT(b) ((int)(((b) >> 6) & 03))
-#define CONTROL_XXX(b) ((int)(((b) >> 3) & 07))
-#define CONTROL_YYY(b) ((int)((b) & 07))
-
-/* DLE value. */
-#define DLE ('\020')
-
-/* Get the length of a packet given a pointer to the header. */
-#define CPACKLEN(z) ((size_t) (1 << ((z)[IFRAME_K] + 4)))
-
-/* <k> field value for a control message. */
-#define KCONTROL (9)
-
-/* Get the next sequence number given a sequence number. */
-#define INEXTSEQ(i) ((i + 1) & 07)
-
-/* Compute i1 - i2 modulo 8. */
-#define CSEQDIFF(i1, i2) (((i1) + 8 - (i2)) & 07)
-
-/* Packet types. These are from the tt field.
- CONTROL -- control packet
- ALTCHAN -- alternate channel; not used by UUCP
- DATA -- full data segment
- SHORTDATA -- less than full data segment (all the bytes specified by
- the packet length <k> are always transferred). Let <u> be the number
- of bytes in the data segment not to be used. If <u> <= 0x7f, the first
- byte of the data segment is <u> and the data follows. If <u> > 0x7f,
- the first byte of the data segment is 0x80 | (<u> & 0x7f), the second
- byte of the data segment is <u> >> 7, and the data follows. The
- maximum possible data segment size is 2**12, so this handles all
- possible cases. */
-#define CONTROL (0)
-#define ALTCHAN (1)
-#define DATA (2)
-#define SHORTDATA (3)
-
-/* Control types. These are from the xxx field if the type (tt field)
- is CONTROL.
-
- CLOSE -- close the connection
- RJ -- reject; packet yyy last to be received correctly
- SRJ -- selective reject; reject only packet yyy (not used by UUCP)
- RR -- receiver ready; packet yyy received correctly
- INITC -- third step of initialization; yyy holds window size
- INITB -- second step of initialization; yyy holds maximum <k> value - 1
- INITA -- first step of initialization; yyy holds window size.
-
- The yyy value for RR is the same as the yyy value for an ordinary
- data packet. */
-#define CLOSE (1)
-#define RJ (2)
-#define SRJ (3)
-#define RR (4)
-#define INITC (5)
-#define INITB (6)
-#define INITA (7)
-
-/* Maximum amount of data in a single packet. This is set by the <k>
- field in the header; the amount of data in a packet is
- 2 ** (<k> + 4). <k> ranges from 1 to 8. */
-
-#define CMAXDATAINDEX (8)
-
-#define CMAXDATA (1 << (CMAXDATAINDEX + 4))
-
-/* Maximum window size. */
-#define CMAXWINDOW (7)
-
-/* Defaults for the protocol parameters. These may all be changed by
- using the ``protocol-parameter g'' command, so there is no
- particular reason to change the values given here. */
-
-/* The desired window size. This is what we tell the other system to
- use. It must be between 1 and 7, and there's no reason to use less
- than 7. Protocol parameter ``window''. */
-#define IWINDOW (7)
-
-/* The desired packet size. Many implementations only support 64 byte
- packets. Protocol parameter ``packet-size''. */
-#define IPACKSIZE (64)
-
-/* The number of times to retry the exchange of INIT packets when
- starting the protocol. Protocol parameter ``startup-retries''. */
-#define CSTARTUP_RETRIES (8)
-
-/* The timeout to use when waiting for an INIT packet when starting up
- the protocol. Protocol parameter ``init-timeout''. */
-#define CEXCHANGE_INIT_TIMEOUT (10)
-
-/* The number of times to retry sending and waiting for a single INIT
- packet when starting the protocol. This controls a single INIT
- packet, while CSTARTUP_RETRIES controls how many times to try the
- entire INIT sequence. Protocol parameter ``init-retries''. */
-#define CEXCHANGE_INIT_RETRIES (4)
-
-/* The timeout to use when waiting for a packet. Protocol parameter
- ``timeout''. */
-#define CTIMEOUT (10)
-
-/* The number of times to retry waiting for a packet. Each time the
- timeout fails we send a copy of our last data packet or a reject
- message for the packet we expect from the other side, depending on
- whether we are waiting for an acknowledgement or a data packet.
- This is the number of times we try doing that and then waiting
- again. Protocol parameter ``retries''. */
-#define CRETRIES (6)
-
-/* If we see more than this much unrecognized data, we drop the
- connection. This must be larger than a single packet size, which
- means it must be larger than 4096 (the largest possible packet
- size). Protocol parameter ``garbage''. */
-#define CGARBAGE (10000)
-
-/* If we see more than this many protocol errors, we drop the
- connection. Protocol parameter ``errors''. */
-#define CERRORS (100)
-
-/* Default decay rate. Each time we send or receive this many packets
- succesfully, we decrement the error level by one (protocol
- parameter ``error-decay''). */
-#define CERROR_DECAY (10)
-
-/* If this value is non-zero, it will be used as the remote window
- size regardless of what the other side requested. This can be
- useful for dealing with some particularly flawed packages. This
- default value should always be 0, and protocol parameter
- ``remote-window'' should be used for the affected systems. */
-#define IREMOTE_WINDOW (0)
-
-/* If this value is non-zero, it will be used as the packet size to
- send to the remote system regardless of what it requested. It's
- difficult to imagine any circumstances where you would want to set
- this. Protocol parameter ``remote-packet-size''. */
-#define IREMOTE_PACKSIZE (0)
-
-/* Local variables. */
-
-/* Next sequence number to send. */
-static int iGsendseq;
-
-/* Last sequence number that has been acked. */
-static int iGremote_ack;
-
-/* Last sequence number to be retransmitted. */
-static int iGretransmit_seq;
-
-/* Last sequence number we have received. */
-static int iGrecseq;
-
-/* Last sequence number we have acked. */
-static int iGlocal_ack;
-
-/* Window size to request (protocol parameter ``window''). */
-static int iGrequest_winsize = IWINDOW;
-
-/* Packet size to request (protocol parameter ``packet-size''). */
-static int iGrequest_packsize = IPACKSIZE;
-
-/* Remote window size (set during handshake). */
-static int iGremote_winsize;
-
-/* Forced remote window size (protocol parameter ``remote-window''). */
-static int iGforced_remote_winsize = IREMOTE_WINDOW;
-
-/* Remote segment size (set during handshake). This is one less than
- the value in a packet header. */
-static int iGremote_segsize;
-
-/* Remote packet size (set based on iGremote_segsize). */
-static size_t iGremote_packsize;
-
-/* Forced remote packet size (protocol parameter
- ``remote-packet-size''). */
-static int iGforced_remote_packsize = IREMOTE_PACKSIZE;
-
-/* Recieved control byte. */
-static int iGpacket_control;
-
-/* Number of times to retry the initial handshake. Protocol parameter
- ``startup-retries''. */
-static int cGstartup_retries = CSTARTUP_RETRIES;
-
-/* Number of times to retry sending an initial control packet.
- Protocol parameter ``init-retries''. */
-static int cGexchange_init_retries = CEXCHANGE_INIT_RETRIES;
-
-/* Timeout (seconds) for receiving an initial control packet.
- Protocol parameter ``init-timeout''. */
-static int cGexchange_init_timeout = CEXCHANGE_INIT_TIMEOUT;
-
-/* Timeout (seconds) for receiving a data packet. Protocol parameter
- ``timeout''. */
-static int cGtimeout = CTIMEOUT;
-
-/* Maximum number of timeouts when receiving a data packet or
- acknowledgement. Protocol parameter ``retries''. */
-static int cGretries = CRETRIES;
-
-/* Amount of garbage data we are prepared to see before giving up.
- Protocol parameter ``garbage''. */
-static int cGgarbage_data = CGARBAGE;
-
-/* Maximum number of errors we are prepared to see before giving up.
- Protocol parameter ``errors''. */
-static int cGmax_errors = CERRORS;
-
-/* Each time we receive this many packets succesfully, we decrement
- the error level by one (protocol parameter ``error-decay''). */
-static int cGerror_decay = CERROR_DECAY;
-
-/* Whether to use shorter packets when possible. Protocol parameter
- ``short-packets''. */
-static boolean fGshort_packets = TRUE;
-
-/* Protocol parameter commands. */
-struct uuconf_cmdtab asGproto_params[] =
-{
- { "window", UUCONF_CMDTABTYPE_INT, (pointer) &iGrequest_winsize, NULL },
- { "packet-size", UUCONF_CMDTABTYPE_INT, (pointer) &iGrequest_packsize,
- NULL },
- { "startup-retries", UUCONF_CMDTABTYPE_INT, (pointer) &cGstartup_retries,
- NULL },
- { "init-timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cGexchange_init_timeout,
- NULL },
- { "init-retries", UUCONF_CMDTABTYPE_INT, (pointer) &cGexchange_init_retries,
- NULL },
- { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cGtimeout, NULL },
- { "retries", UUCONF_CMDTABTYPE_INT, (pointer) &cGretries, NULL },
- { "garbage", UUCONF_CMDTABTYPE_INT, (pointer) &cGgarbage_data, NULL },
- { "errors", UUCONF_CMDTABTYPE_INT, (pointer) &cGmax_errors, NULL },
- { "error-decay", UUCONF_CMDTABTYPE_INT, (pointer) &cGerror_decay, NULL },
- { "remote-window", UUCONF_CMDTABTYPE_INT,
- (pointer) &iGforced_remote_winsize, NULL },
- { "remote-packet-size", UUCONF_CMDTABTYPE_INT,
- (pointer) &iGforced_remote_packsize, NULL },
- { "short-packets", UUCONF_CMDTABTYPE_BOOLEAN, (pointer) &fGshort_packets,
- NULL },
- { NULL, 0, NULL, NULL }
-};
-
-/* Statistics. */
-
-/* Number of packets we have sent. */
-static long cGsent_packets;
-
-/* Number of packets we have resent (these are not included in
- cGsent_packets). */
-static long cGresent_packets;
-
-/* Number of packets we have delayed sending (these should not be
- counted in cGresent_packets). */
-static long cGdelayed_packets;
-
-/* Number of packets we have received. */
-static long cGrec_packets;
-
-/* Number of packets rejected because the header was bad. */
-static long cGbad_hdr;
-
-/* Number of packets rejected because the checksum was bad. */
-static long cGbad_checksum;
-
-/* Number of packets received out of order. */
-static long cGbad_order;
-
-/* Number of packets rejected by receiver (number of RJ packets
- received). */
-static long cGremote_rejects;
-
-/* Number of duplicate RR packets treated as RJ packets. Some UUCP
- packages appear to never send RJ packets, but only RR packets. If
- no RJ has been seen, fgprocess_data treats a duplicate RR as an RJ
- and increments this variable. */
-static long cGremote_duprrs;
-
-/* The error level. This is the total number of errors as adjusted by
- cGerror_decay. */
-static long cGerror_level;
-
-/* Each time we send an RJ, we can expect several out of order of
- packets, because the other side will probably have sent a full
- window by the time it sees the RJ. This variable keeps track of
- the number of out of order packets we expect to see. We don't
- count expected out of order packets against the error level. This
- is reset to 0 when an in order packet is received. */
-static int cGexpect_bad_order;
-
-#if DEBUG > 1
-/* Control packet names used for debugging. */
-static const char * const azGcontrol[] =
-{"?0?", "CLOSE", "RJ", "SRJ", "RR", "INITC", "INITB", "INITA"};
-#endif
-
-/* Local functions. */
-static boolean fgexchange_init P((struct sdaemon *qdaemon, int ictl,
- int ival, int *piset));
-static boolean fgsend_control P((struct sdaemon *qdaemon, int ictl,
- int ival));
-static char *zgadjust_ack P((int iseq));
-static boolean fgwait_for_packet P((struct sdaemon *qdaemon,
- boolean freturncontrol, int ctimeout,
- int cretries));
-static boolean fgsend_acks P((struct sdaemon *qdaemon));
-static boolean fggot_ack P((struct sdaemon *qdaemon, int iack));
-static boolean fgprocess_data P((struct sdaemon *qdaemon, boolean fdoacks,
- boolean freturncontrol,
- boolean *pfexit, size_t *pcneed,
- boolean *pffound));
-static boolean fginit_sendbuffers P((boolean fallocate));
-static boolean fgcheck_errors P((struct sdaemon *qdaemon));
-static int igchecksum P((const char *zdata, size_t clen));
-static int igchecksum2 P((const char *zfirst, size_t cfirst,
- const char *zsecond, size_t csecond));
-
-/* Start the protocol. This requires a three way handshake. Both sides
- must send and receive an INITA packet, an INITB packet, and an INITC
- packet. The INITA and INITC packets contain the window size, and the
- INITB packet contains the packet size. */
-
-boolean
-fgstart (qdaemon, pzlog)
- struct sdaemon *qdaemon;
- char **pzlog;
-{
- int iseg;
- int i;
- boolean fgota, fgotb;
-
- *pzlog = NULL;
-
- /* The 'g' protocol requires a full eight bit interface. */
- if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE,
- STRIPSETTING_EIGHTBITS, XONXOFF_OFF))
- return FALSE;
-
- iGsendseq = 1;
- iGremote_ack = 0;
- iGretransmit_seq = -1;
- iGrecseq = 0;
- iGlocal_ack = 0;
- cGsent_packets = 0;
- cGresent_packets = 0;
- cGdelayed_packets = 0;
- cGrec_packets = 0;
- cGbad_hdr = 0;
- cGbad_checksum = 0;
- cGbad_order = 0;
- cGremote_rejects = 0;
- cGremote_duprrs = 0;
- cGerror_level = 0;
- cGexpect_bad_order = 0;
-
- /* We must determine the segment size based on the packet size
- which may have been modified by a protocol parameter command.
- A segment size of 2^n is passed as n - 5. */
- i = iGrequest_packsize;
- iseg = -1;
- while (i > 0)
- {
- ++iseg;
- i >>= 1;
- }
- iseg -= 5;
- if (iseg < 0 || iseg > 7)
- {
- ulog (LOG_ERROR, "Illegal packet size %d for '%c' protocol",
- iGrequest_packsize, qdaemon->qproto->bname);
- iseg = 1;
- }
-
- if (iGrequest_winsize <= 0 || iGrequest_winsize > 7)
- {
- ulog (LOG_ERROR, "Illegal window size %d for '%c' protocol",
- iGrequest_winsize, qdaemon->qproto->bname);
- iGrequest_winsize = IWINDOW;
- }
-
- fgota = FALSE;
- fgotb = FALSE;
- for (i = 0; i < cGstartup_retries; i++)
- {
- if (fgota)
- {
- if (! fgsend_control (qdaemon, INITA, iGrequest_winsize))
- return FALSE;
- }
- else
- {
- if (! fgexchange_init (qdaemon, INITA, iGrequest_winsize,
- &iGremote_winsize))
- continue;
- }
- fgota = TRUE;
-
- if (fgotb)
- {
- if (! fgsend_control (qdaemon, INITB, iseg))
- return FALSE;
- }
- else
- {
- if (! fgexchange_init (qdaemon, INITB, iseg, &iGremote_segsize))
- continue;
- }
- fgotb = TRUE;
-
- if (! fgexchange_init (qdaemon, INITC, iGrequest_winsize,
- &iGremote_winsize))
- continue;
-
- /* We have succesfully connected. Determine the remote packet
- size. */
- iGremote_packsize = 1 << (iGremote_segsize + 5);
-
- /* If the user requested us to force specific remote window and
- packet sizes, do so now. */
- if (iGforced_remote_winsize > 0
- && iGforced_remote_winsize <= CMAXWINDOW)
- iGremote_winsize = iGforced_remote_winsize;
-
- if (iGforced_remote_packsize >= 32
- && iGforced_remote_packsize <= 4096)
- {
- /* Force the value to a power of two. */
- i = iGforced_remote_packsize;
- iseg = -1;
- while (i > 0)
- {
- ++iseg;
- i >>= 1;
- }
- iGremote_packsize = 1 << iseg;
- iGremote_segsize = iseg - 5;
- }
-
- /* Set up packet buffers to use. We don't do this until we know
- the maximum packet size we are going to send. */
- if (! fginit_sendbuffers (TRUE))
- return FALSE;
-
- *pzlog =
- zbufalc (sizeof "protocol '' sending packet/window / receiving /"
- + 64);
- sprintf (*pzlog,
- "protocol '%c' sending packet/window %d/%d receiving %d/%d",
- qdaemon->qproto->bname, (int) iGremote_packsize,
- (int) iGremote_winsize, (int) iGrequest_packsize,
- (int) iGrequest_winsize);
-
- return TRUE;
- }
-
- DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fgstart: Protocol startup failed");
-
- return FALSE;
-}
-
-/* The 'G' protocol is identical to the 'g' protocol, except that
- short packets are never supported. */
-
-boolean
-fbiggstart (qdaemon, pzlog)
- struct sdaemon *qdaemon;
- char **pzlog;
-{
- fGshort_packets = FALSE;
- return fgstart (qdaemon, pzlog);
-}
-
-/* The 'v' protocol is identical to the 'g' protocol, except that the
- packet size defaults to 512 bytes. Rather than really get it
- right, we automatically switch from the usual default of 64 to 512.
- This won't work correctly if somebody does protocol-parameter v
- packet-size 64. */
-
-boolean
-fvstart (qdaemon, pzlog)
- struct sdaemon *qdaemon;
- char **pzlog;
-{
- if (iGrequest_packsize == IPACKSIZE)
- iGrequest_packsize = 1024;
- return fgstart (qdaemon, pzlog);
-}
-
-/* Exchange initialization messages with the other system.
-
- A problem:
-
- We send INITA; it gets received
- We receive INITA
- We send INITB; it gets garbled
- We receive INITB
-
- We have seen and sent INITB, so we start to send INITC. The other
- side as sent INITB but not seen it, so it times out and resends
- INITB. We will continue sending INITC and the other side will
- continue sending INITB until both sides give up and start again
- with INITA.
-
- It might seem as though if we are sending INITC and receive INITB,
- we should resend our INITB, but this could cause infinite echoing
- of INITB on a long-latency line. Rather than risk that, I have
- implemented a fast drop-back procedure. If we are sending INITB and
- receive INITC, the other side has gotten ahead of us. We immediately
- fail and begin again with INITA. For the other side, if we are
- sending INITC and see INITA, we also immediately fail back to INITA.
-
- Unfortunately, this doesn't work for the other case, in which we
- are sending INITB but the other side has not yet seen INITA. As
- far as I can see, if this happens we just have to wait until we
- time out and resend INITA. */
-
-static boolean
-fgexchange_init (qdaemon, ictl, ival, piset)
- struct sdaemon *qdaemon;
- int ictl;
- int ival;
- int *piset;
-{
- int i;
-
- /* The three-way handshake should be independent of who initializes
- it, but it seems that some versions of uucico assume that the
- caller sends first and the callee responds. This only matters if
- we are the callee and the first packet is garbled. If we send a
- packet, the other side will assume that we must have seen the
- packet they sent and will never time out and send it again.
- Therefore, if we are the callee we don't send a packet the first
- time through the loop. This can still fail, but should usually
- work, and, after all, if the initialization packets are received
- correctly there will be no problem no matter what we do. */
- for (i = 0; i < cGexchange_init_retries; i++)
- {
- long itime;
- int ctimeout;
-
- if (qdaemon->fcaller || i > 0)
- {
- if (! fgsend_control (qdaemon, ictl, ival))
- return FALSE;
- }
-
- itime = ixsysdep_time ((long *) NULL);
- ctimeout = cGexchange_init_timeout;
-
- do
- {
- long inewtime;
-
- /* We pass 0 as the retry count to fgwait_for_packet because
- we want to handle retries here and because if it retried
- it would send a packet, which would be bad. */
- if (! fgwait_for_packet (qdaemon, TRUE, ctimeout, 0))
- break;
-
- if (CONTROL_TT (iGpacket_control) == CONTROL)
- {
- if (CONTROL_XXX (iGpacket_control) == ictl)
- {
- *piset = CONTROL_YYY (iGpacket_control);
-
- /* If we didn't already send our initialization
- packet, send it now. */
- if (! qdaemon->fcaller && i == 0)
- {
- if (! fgsend_control (qdaemon, ictl, ival))
- return FALSE;
- }
-
- return TRUE;
- }
-
- /* If the other side is farther along than we are,
- we have lost a packet. Fail immediately back to
- INITA (but don't fail if we are already doing INITA,
- since that would count against cStart_retries more
- than it should). */
- if (CONTROL_XXX (iGpacket_control) < ictl && ictl != INITA)
- return FALSE;
-
- /* If we are sending INITC and we receive an INITA, the other
- side has failed back (we know this because we have
- seen an INITB from them). Fail back ourselves to
- start the whole handshake over again. */
- if (CONTROL_XXX (iGpacket_control) == INITA && ictl == INITC)
- return FALSE;
-
- /* As a special hack, if we are sending INITC and we
- receive INITB, we update the segment size from the
- packet. This permits a second INITB to override the
- first one. It would be nice to do this in a cleaner
- way. */
- if (CONTROL_XXX (iGpacket_control) == INITB && ictl == INITC)
- iGremote_segsize = CONTROL_YYY (iGpacket_control);
- }
-
- inewtime = ixsysdep_time ((long *) NULL);
- ctimeout -= inewtime - itime;
- }
- while (ctimeout > 0);
- }
-
- return FALSE;
-}
-
-/* Shut down the protocol. */
-
-boolean
-fgshutdown (qdaemon)
- struct sdaemon *qdaemon;
-{
- (void) fgsend_control (qdaemon, CLOSE, 0);
- (void) fgsend_control (qdaemon, CLOSE, 0);
- (void) fginit_sendbuffers (FALSE);
-
- /* The count of sent packets may not be accurate, because some of
- them may have not been sent yet if the connection failed in the
- middle (the ones that counted for cGdelayed_packets). I don't
- think it's worth being precise. */
- ulog (LOG_NORMAL,
- "Protocol '%c' packets: sent %ld, resent %ld, received %ld",
- qdaemon->qproto->bname, cGsent_packets,
- cGresent_packets - cGdelayed_packets, cGrec_packets);
- if (cGbad_hdr != 0
- || cGbad_checksum != 0
- || cGbad_order != 0
- || cGremote_rejects != 0
- || cGremote_duprrs != 0)
- ulog (LOG_NORMAL,
- "Errors: header %ld, checksum %ld, order %ld, remote rejects %ld",
- cGbad_hdr, cGbad_checksum, cGbad_order,
- cGremote_duprrs + cGremote_rejects);
-
- /* Reset all the parameters to their default values, so that the
- protocol parameters used for this connection do not affect the
- next one. */
- iGrequest_winsize = IWINDOW;
- iGrequest_packsize = IPACKSIZE;
- cGstartup_retries = CSTARTUP_RETRIES;
- cGexchange_init_timeout = CEXCHANGE_INIT_TIMEOUT;
- cGexchange_init_retries = CEXCHANGE_INIT_RETRIES;
- cGtimeout = CTIMEOUT;
- cGretries = CRETRIES;
- cGgarbage_data = CGARBAGE;
- cGmax_errors = CERRORS;
- cGerror_decay = CERROR_DECAY;
- iGforced_remote_winsize = IREMOTE_WINDOW;
- iGforced_remote_packsize = IREMOTE_PACKSIZE;
- fGshort_packets = TRUE;
-
- return TRUE;
-}
-
-/* Send a command string. We send packets containing the string until
- the entire string has been sent. Each packet is full. */
-
-/*ARGSUSED*/
-boolean
-fgsendcmd (qdaemon, z, ilocal, iremote)
- struct sdaemon *qdaemon;
- const char *z;
- int ilocal;
- int iremote;
-{
- size_t clen;
- boolean fagain;
-
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fgsendcmd: Sending command \"%s\"", z);
-
- clen = strlen (z);
-
- do
- {
- char *zpacket;
- size_t cdummy;
-
- zpacket = zggetspace (qdaemon, &cdummy);
-
- if (clen < iGremote_packsize)
- {
- size_t csize;
-
- /* If the remote packet size is larger than 64 (the default,
- which may indicate an older UUCP package), try to fit
- this command into a smaller packet. We still always send
- a complete packet, though. */
- if (iGremote_packsize <= 64 || ! fGshort_packets)
- csize = iGremote_packsize;
- else
- {
- csize = 32;
- while (csize <= clen)
- csize <<= 1;
- }
-
- memcpy (zpacket, z, clen);
- if (csize > clen)
- bzero (zpacket + clen, csize - clen);
- fagain = FALSE;
-
- if (! fgsenddata (qdaemon, zpacket, csize, 0, 0, (long) 0))
- return FALSE;
- }
- else
- {
- memcpy (zpacket, z, iGremote_packsize);
- z += iGremote_packsize;
- clen -= iGremote_packsize;
- fagain = TRUE;
-
- if (! fgsenddata (qdaemon, zpacket, iGremote_packsize,
- 0, 0, (long) 0))
- return FALSE;
- }
- }
- while (fagain);
-
- return TRUE;
-}
-
-/* We keep an array of buffers to retransmit as necessary. Rather
- than waste static space on large buffer sizes, we allocate the
- buffers once we know how large the other system expects them to be.
- The sequence numbers used in the 'g' protocol are only three bits
- long, so we allocate eight buffers and maintain a correspondence
- between buffer index and sequence number. This always wastes some
- buffer space, but it's easy to implement.
-
- We leave room at the front of the buffer for the frame header and
- two additional bytes. The two extra bytes are used for short
- packets, which essentially use a longer header and shorter data.
- We do this to avoid moving the data. We zero out any unused bytes
- before the frame, so we can locate the real header given a buffer
- by finding the first non-zero byte (which will be one of the first
- three bytes in the buffer). */
-
-#define CSENDBUFFERS (CMAXWINDOW + 1)
-
-static char *azGsendbuffers[CSENDBUFFERS];
-
-static boolean
-fginit_sendbuffers (fallocate)
- boolean fallocate;
-{
- int i;
-
- /* Free up any remaining old buffers. */
- for (i = 0; i < CSENDBUFFERS; i++)
- {
- xfree ((pointer) azGsendbuffers[i]);
- if (fallocate)
- {
- azGsendbuffers[i] = (char *) malloc (CFRAMELEN + 2
- + iGremote_packsize);
- if (azGsendbuffers[i] == NULL)
- return FALSE;
-
- /* This bzero might not seem necessary, since before we send
- out each packet we zero out any non-data bytes. However,
- if we receive an SRJ at the start of the conversation, we
- will send out the packet before it has been set to
- anything, thus sending the contents of our heap. We
- avoid this by using bzero. */
- bzero (azGsendbuffers[i], CFRAMELEN + 2 + iGremote_packsize);
- }
- else
- azGsendbuffers[i] = NULL;
- }
- return TRUE;
-}
-
-/* Allocate a packet to send out. The return value of this function
- must be filled in and passed to fgsenddata, or discarded. This
- will ensure that the buffers and iGsendseq stay in synch. Set
- *pclen to the amount of data to place in the buffer. */
-
-/*ARGSUSED*/
-char *
-zggetspace (qdaemon, pclen)
- struct sdaemon *qdaemon;
- size_t *pclen;
-{
- *pclen = iGremote_packsize;
- return azGsendbuffers[iGsendseq] + CFRAMELEN + 2;
-}
-
-/* Send out a data packet. This computes the checksum, sets up the
- header, and sends the packet out. The argument zdata should point
- to the return value of zggetspace. */
-
-/*ARGSIGNORED*/
-boolean
-fgsenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos)
- struct sdaemon *qdaemon;
- char *zdata;
- size_t cdata;
- int ilocal;
- int iremote;
- long ipos;
-{
- char *z;
- int itt, iseg;
- size_t csize;
- int iclr1, iclr2;
- unsigned short icheck;
-
- /* Set the initial length bytes. See the description at the definition
- of SHORTDATA, above. */
- itt = DATA;
- csize = iGremote_packsize;
- iseg = iGremote_segsize + 1;
-
-#if DEBUG > 0
- if (cdata > csize)
- ulog (LOG_FATAL, "fgsend_packet: Packet size too large");
-#endif
-
- iclr1 = -1;
- iclr2 = -2;
- if (cdata < csize)
- {
- /* If the remote packet size is larger than 64, the default, we
- can assume they can handle a smaller packet as well, which
- will be more efficient to send. */
- if (iGremote_packsize > 64 && fGshort_packets)
- {
- /* The packet size is 1 << (iseg + 4). */
- iseg = 1;
- csize = 32;
- while (csize < cdata)
- {
- csize <<= 1;
- ++iseg;
- }
- }
-
- if (csize != cdata)
- {
- size_t cshort;
-
- /* We have to add bytes which indicate how short the packet
- is. We do this by pushing the header backward, which we
- can do because we allocated two extra bytes for this
- purpose. */
- iclr2 = 0;
- itt = SHORTDATA;
- cshort = csize - cdata;
- if (cshort <= 127)
- {
- --zdata;
- zdata[0] = (char) cshort;
- zdata[-1] = '\0';
- if (cshort > 1)
- bzero (zdata + cdata + 1, cshort - 1);
- }
- else
- {
- zdata -= 2;
- zdata[0] = (char) (0x80 | (cshort & 0x7f));
- zdata[1] = (char) (cshort >> 7);
- bzero (zdata + cdata + 2, cshort - 2);
- iclr1 = 0;
- }
- }
- }
-
- z = zdata - CFRAMELEN;
-
- /* Zero out the preceding bytes, in case the last time this buffer
- was used those bytes were used. We need to zero out the initial
- bytes so that we can find the true start of the packet in
- zgadjust_ack. */
- z[iclr1] = '\0';
- z[iclr2] = '\0';
-
- z[IFRAME_DLE] = DLE;
- z[IFRAME_K] = (char) iseg;
-
- icheck = (unsigned short) igchecksum (zdata, csize);
-
- /* We're just about ready to go. Wait until there is room in the
- receiver's window for us to send the packet. We do this now so
- that we send the correct value for the last packet received.
- Note that if iGsendseq == iGremote_ack, this means that the
- sequence numbers are actually 8 apart, since the packet could not
- have been acknowledged before it was sent; this can happen when
- the window size is 7. */
- while (iGsendseq == iGremote_ack
- || CSEQDIFF (iGsendseq, iGremote_ack) > iGremote_winsize)
- {
- if (! fgwait_for_packet (qdaemon, TRUE, cGtimeout, cGretries))
- return FALSE;
- }
-
- /* Ack all packets up to the next one, since the UUCP protocol
- requires that all packets be acked in order. */
- while (CSEQDIFF (iGrecseq, iGlocal_ack) > 1)
- {
- iGlocal_ack = INEXTSEQ (iGlocal_ack);
- if (! fgsend_control (qdaemon, RR, iGlocal_ack))
- return FALSE;
- }
- iGlocal_ack = iGrecseq;
-
- z[IFRAME_CONTROL] = (char) ((itt << 6) | (iGsendseq << 3) | iGrecseq);
-
- iGsendseq = INEXTSEQ (iGsendseq);
-
- icheck = ((unsigned short)
- ((0xaaaa - (icheck ^ (z[IFRAME_CONTROL] & 0xff))) & 0xffff));
- z[IFRAME_CHECKLOW] = (char) (icheck & 0xff);
- z[IFRAME_CHECKHIGH] = (char) (icheck >> 8);
-
- z[IFRAME_XOR] = (char) (z[IFRAME_K] ^ z[IFRAME_CHECKLOW]
- ^ z[IFRAME_CHECKHIGH] ^ z[IFRAME_CONTROL]);
-
- /* If we're waiting for acks of retransmitted packets, then don't
- send this packet yet. The other side may not be ready for it
- yet. Instead, code in fggot_ack will send the outstanding
- packets when an ack is received. */
- ++cGsent_packets;
-
- if (iGretransmit_seq != -1)
- {
- ++cGdelayed_packets;
- return TRUE;
- }
-
- DEBUG_MESSAGE2 (DEBUG_PROTO,
- "fgsenddata: Sending packet %d (%d bytes)",
- CONTROL_XXX (z[IFRAME_CONTROL]), cdata);
-
- return fsend_data (qdaemon->qconn, z, CFRAMELEN + csize, TRUE);
-}
-
-/* Recompute the control byte and checksum of a packet so that it
- includes the correct packet acknowledgement. This is called when a
- packet is retransmitted to make sure the retransmission does not
- confuse the other side. It returns a pointer to the start of the
- packet, skipping the bytes that may be unused at the start of
- azGsendbuffers[iseq]. */
-
-static char *
-zgadjust_ack (iseq)
- int iseq;
-{
- register char *z;
- unsigned short icheck;
-
- z = azGsendbuffers[iseq];
- if (*z == '\0')
- ++z;
- if (*z == '\0')
- ++z;
-
- /* If the received packet number is the same, there is nothing
- to do. */
- if (CONTROL_YYY (z[IFRAME_CONTROL]) == iGrecseq)
- return z;
-
- /* Get the old checksum. */
- icheck = (unsigned short) (((z[IFRAME_CHECKHIGH] & 0xff) << 8)
- | (z[IFRAME_CHECKLOW] & 0xff));
- icheck = ((unsigned short)
- (((0xaaaa - icheck) ^ (z[IFRAME_CONTROL] & 0xff)) & 0xffff));
-
- /* Update the control byte. */
- z[IFRAME_CONTROL] = (char) ((z[IFRAME_CONTROL] &~ 07) | iGrecseq);
-
- /* Create the new checksum. */
- icheck = ((unsigned short)
- ((0xaaaa - (icheck ^ (z[IFRAME_CONTROL] & 0xff))) & 0xffff));
- z[IFRAME_CHECKLOW] = (char) (icheck & 0xff);
- z[IFRAME_CHECKHIGH] = (char) (icheck >> 8);
-
- /* Update the XOR byte. */
- z[IFRAME_XOR] = (char) (z[IFRAME_K] ^ z[IFRAME_CHECKLOW]
- ^ z[IFRAME_CHECKHIGH] ^ z[IFRAME_CONTROL]);
-
- return z;
-}
-
-/* Send a control packet. These are fairly simple to construct. It
- seems reasonable to me that we should be able to send a control
- packet at any time, even if the receive window is closed. In
- particular, we don't want to delay when sending a CLOSE control
- message. If I'm wrong, it can be changed easily enough. */
-
-static boolean
-fgsend_control (qdaemon, ixxx, iyyy)
- struct sdaemon *qdaemon;
- int ixxx;
- int iyyy;
-{
- char ab[CFRAMELEN];
- int ictl;
- unsigned short icheck;
-
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_PROTO) ||
- (FDEBUGGING (DEBUG_ABNORMAL) && ixxx != RR))
- ulog (LOG_DEBUG, "fgsend_control: Sending control %s %d",
- azGcontrol[ixxx], iyyy);
-#endif
-
- ab[IFRAME_DLE] = DLE;
- ab[IFRAME_K] = KCONTROL;
-
- ictl = (CONTROL << 6) | (ixxx << 3) | iyyy;
- icheck = (unsigned short) (0xaaaa - ictl);
- ab[IFRAME_CHECKLOW] = (char) (icheck & 0xff);
- ab[IFRAME_CHECKHIGH] = (char) (icheck >> 8);
-
- ab[IFRAME_CONTROL] = (char) ictl;
-
- ab[IFRAME_XOR] = (char) (ab[IFRAME_K] ^ ab[IFRAME_CHECKLOW]
- ^ ab[IFRAME_CHECKHIGH] ^ ab[IFRAME_CONTROL]);
-
- return fsend_data (qdaemon->qconn, ab, (size_t) CFRAMELEN, TRUE);
-}
-
-/* Wait for data to come in. This continues processing until a
- complete file or command has been received. */
-
-boolean
-fgwait (qdaemon)
- struct sdaemon *qdaemon;
-{
- return fgwait_for_packet (qdaemon, FALSE, cGtimeout, cGretries);
-}
-
-/* Get a packet. This is called when we have nothing to send, but
- want to wait for a packet to come in. If freturncontrol is TRUE,
- this will return after getting any control packet. Otherwise, it
- will continue to receive packets until a complete file or a
- complete command has been received. The timeout and the number of
- retries are specified as arguments. The function returns FALSE if
- an error occurs or if cretries timeouts of ctimeout seconds were
- exceeded. */
-
-static boolean
-fgwait_for_packet (qdaemon, freturncontrol, ctimeout, cretries)
- struct sdaemon *qdaemon;
- boolean freturncontrol;
- int ctimeout;
- int cretries;
-{
- int ctimeouts;
- int cgarbage;
- int cshort;
-
- ctimeouts = 0;
- cgarbage = 0;
- cshort = 0;
-
- while (TRUE)
- {
- boolean fexit;
- size_t cneed;
- boolean ffound;
- size_t crec;
-
- if (! fgprocess_data (qdaemon, TRUE, freturncontrol, &fexit,
- &cneed, &ffound))
- return FALSE;
-
- if (fexit)
- return TRUE;
-
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "fgwait_for_packet: Need %lu bytes",
- (unsigned long) cneed);
-
- if (ffound)
- {
- ctimeouts = 0;
- cgarbage = 0;
- }
- else
- {
- if (cgarbage > cGgarbage_data)
- {
- ulog (LOG_ERROR, "Too much unrecognized data");
- return FALSE;
- }
- }
-
- if (! freceive_data (qdaemon->qconn, cneed, &crec, ctimeout, TRUE))
- return FALSE;
-
- cgarbage += crec;
-
- if (crec != 0)
- {
- /* If we don't get enough data twice in a row, we may have
- dropped some data and still be looking for the end of a
- large packet. Incrementing iPrecstart will force
- fgprocess_data to skip that packet and look through the
- rest of the data. In some situations, this will be a
- mistake. */
- if (crec >= cneed)
- cshort = 0;
- else
- {
- ++cshort;
- if (cshort > 1)
- {
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN;
- cshort = 0;
- }
- }
- }
- else
- {
- /* The read timed out. If we have an unacknowledged packet,
- send it again. Otherwise, send an RJ with the last
- packet we received correctly. */
- ++ctimeouts;
- if (ctimeouts > cretries)
- {
- if (cretries > 0)
- ulog (LOG_ERROR, "Timed out waiting for packet");
- return FALSE;
- }
-
- if (INEXTSEQ (iGremote_ack) != iGsendseq)
- {
- int inext;
- char *zsend;
-
- inext = INEXTSEQ (iGremote_ack);
-
- DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fgwait_for_packet: Resending packet %d",
- inext);
-
- ++cGresent_packets;
- zsend = zgadjust_ack (inext);
- if (! fsend_data (qdaemon->qconn, zsend,
- CFRAMELEN + CPACKLEN (zsend), TRUE))
- return FALSE;
- iGretransmit_seq = inext;
- }
- else
- {
- /* Send all pending acks first, to avoid confusing
- the other side. */
- if (iGlocal_ack != iGrecseq)
- {
- if (! fgsend_acks (qdaemon))
- return FALSE;
- }
- if (! fgsend_control (qdaemon, RJ, iGrecseq))
- return FALSE;
- }
- }
- }
-}
-
-/* Send acks for all packets we haven't acked yet. */
-
-static boolean
-fgsend_acks (qdaemon)
- struct sdaemon *qdaemon;
-{
- while (iGlocal_ack != iGrecseq)
- {
- iGlocal_ack = INEXTSEQ (iGlocal_ack);
- if (! fgsend_control (qdaemon, RR, iGlocal_ack))
- return FALSE;
- }
- return TRUE;
-}
-
-/* Handle an ack of a packet. According to Hanrahan's paper, this
- acknowledges all previous packets. If this is an ack for a
- retransmitted packet, continue by resending up to two more packets
- following the retransmitted one. This should recover quickly from
- a line glitch, while avoiding the problem of continual
- retransmission. */
-
-static boolean
-fggot_ack (qdaemon, iack)
- struct sdaemon *qdaemon;
- int iack;
-{
- int inext;
- char *zsend;
-
- /* We only decrement the error level if we are not retransmitting
- packets. We want to catch a sudden downgrade in line quality as
- fast as possible. */
- if (cGerror_level > 0
- && iGretransmit_seq == -1
- && cGsent_packets % cGerror_decay == 0)
- --cGerror_level;
- cGexpect_bad_order = 0;
-
- /* Each time packet 0 is acknowledged, we call uwindow_acked since a
- new window has been acked. */
- if (iack < iGremote_ack)
- uwindow_acked (qdaemon, FALSE);
-
- iGremote_ack = iack;
-
- if (iGretransmit_seq == -1)
- return TRUE;
-
- inext = INEXTSEQ (iGretransmit_seq);
- if (inext == iGsendseq)
- iGretransmit_seq = -1;
- else
- {
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "fggot_ack: Sending packet %d", inext);
-
- ++cGresent_packets;
- zsend = zgadjust_ack (inext);
- if (! fsend_data (qdaemon->qconn, zsend, CFRAMELEN + CPACKLEN (zsend),
- TRUE))
- return FALSE;
- inext = INEXTSEQ (inext);
- if (inext == iGsendseq)
- iGretransmit_seq = -1;
- else
- {
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "fggot_ack: Sending packet %d", inext);
-
- ++cGresent_packets;
- zsend = zgadjust_ack (inext);
- if (! fsend_data (qdaemon->qconn, zsend,
- CFRAMELEN + CPACKLEN (zsend), TRUE))
- return FALSE;
- iGretransmit_seq = inext;
- }
- }
-
- return TRUE;
-}
-
-/* See if we've received more than the permitted number of errors. If
- we receive a bad packet, we can expect a window full (less one) of
- out of order packets to follow, so we discount cGbad_order
- accordingly. */
-
-static boolean
-fgcheck_errors (qdaemon)
- struct sdaemon *qdaemon;
-{
- if (cGerror_level > cGmax_errors && cGmax_errors >= 0)
- {
- ulog (LOG_ERROR, "Too many '%c' protocol errors",
- qdaemon->qproto->bname);
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Process the receive buffer into a data packet, if possible. All
- control packets are handled here. When a data packet is received,
- fgprocess_data calls fgot_data with the data; if that sets its
- pfexit argument to TRUE fgprocess_data will set *pfexit to TRUE and
- return TRUE. Also, if the freturncontrol argument is TRUE
- fgprocess_data will set *pfexit to TRUE and return TRUE. Otherwise
- fgprocess_data will continue trying to process data. If some error
- occurs, fgprocess_data will return FALSE. If there is not enough
- data to form a complete packet, then *pfexit will be set to FALSE,
- *pcneed will be set to the number of bytes needed to form a
- complete packet (unless pcneed is NULL) and fgprocess_data will
- return TRUE. If this function found a data packet, and pffound is
- not NULL, it will set *pffound to TRUE; this can be used to tell
- valid data from an endless stream of garbage and control packets.
- If fdoacks is TRUE, received packets will be acknowledged;
- otherwise they must be acknowledged later. */
-
-static boolean
-fgprocess_data (qdaemon, fdoacks, freturncontrol, pfexit, pcneed, pffound)
- struct sdaemon *qdaemon;
- boolean fdoacks;
- boolean freturncontrol;
- boolean *pfexit;
- size_t *pcneed;
- boolean *pffound;
-{
- *pfexit = FALSE;
- if (pffound != NULL)
- *pffound = FALSE;
-
- while (iPrecstart != iPrecend)
- {
- char ab[CFRAMELEN];
- int i, iget, cwant;
- unsigned short ihdrcheck, idatcheck;
- const char *zfirst, *zsecond;
- int cfirst, csecond;
- boolean fduprr;
-
- /* Look for the DLE which must start a packet. */
- if (abPrecbuf[iPrecstart] != DLE)
- {
- char *zdle;
-
- cfirst = iPrecend - iPrecstart;
- if (cfirst < 0)
- cfirst = CRECBUFLEN - iPrecstart;
-
- zdle = memchr (abPrecbuf + iPrecstart, DLE, (size_t) cfirst);
-
- if (zdle == NULL)
- {
- iPrecstart = (iPrecstart + cfirst) % CRECBUFLEN;
- continue;
- }
-
- /* We don't need % CRECBUFLEN here because zdle - (abPrecbuf
- + iPrecstart) < cfirst <= CRECBUFLEN - iPrecstart. */
- iPrecstart += zdle - (abPrecbuf + iPrecstart);
- }
-
- /* Get the first six bytes into ab. */
- for (i = 0, iget = iPrecstart;
- i < CFRAMELEN && iget != iPrecend;
- i++, iget = (iget + 1) % CRECBUFLEN)
- ab[i] = abPrecbuf[iget];
-
- /* If there aren't six bytes, there is no packet. */
- if (i < CFRAMELEN)
- {
- if (pcneed != NULL)
- *pcneed = CFRAMELEN - i;
- return TRUE;
- }
-
- /* Make sure these six bytes start a packet. The check on
- IFRAME_DLE is basically a debugging check, since the above
- code should have ensured that it will never fail. If this is
- not the start of a packet, bump iPrecstart and loop around to
- look for another DLE. */
- if (ab[IFRAME_DLE] != DLE
- || ab[IFRAME_K] < 1
- || ab[IFRAME_K] > 9
- || ab[IFRAME_XOR] != (ab[IFRAME_K] ^ ab[IFRAME_CHECKLOW]
- ^ ab[IFRAME_CHECKHIGH] ^ ab[IFRAME_CONTROL])
- || CONTROL_TT (ab[IFRAME_CONTROL]) == ALTCHAN)
- {
- ++cGbad_hdr;
- ++cGerror_level;
-
- DEBUG_MESSAGE4 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fgprocess_data: Bad header: K %d TT %d XOR byte %d calc %d",
- ab[IFRAME_K] & 0xff,
- CONTROL_TT (ab[IFRAME_CONTROL]),
- ab[IFRAME_XOR] & 0xff,
- (ab[IFRAME_K]
- ^ ab[IFRAME_CHECKLOW]
- ^ ab[IFRAME_CHECKHIGH]
- ^ ab[IFRAME_CONTROL]) & 0xff);
-
- if (! fgcheck_errors (qdaemon))
- return FALSE;
-
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN;
- continue;
- }
-
- /* The zfirst and cfirst pair point to the first set of data for
- this packet; the zsecond and csecond point to the second set,
- in case the packet wraps around the end of the buffer. */
- zfirst = abPrecbuf + iPrecstart + CFRAMELEN;
- cfirst = 0;
- zsecond = NULL;
- csecond = 0;
-
- if (ab[IFRAME_K] == KCONTROL)
- {
- /* This is a control packet. It should not have any data. */
- if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL)
- {
- ++cGbad_hdr;
- ++cGerror_level;
-
- DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fgprocess_data: Bad header: control packet with data");
-
- if (! fgcheck_errors (qdaemon))
- return FALSE;
-
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN;
- continue;
- }
-
- idatcheck = (unsigned short) (0xaaaa - ab[IFRAME_CONTROL]);
- cwant = 0;
- }
- else
- {
- int cinbuf;
- unsigned short icheck;
-
- /* This is a data packet. It should not be type CONTROL. */
- if (CONTROL_TT (ab[IFRAME_CONTROL]) == CONTROL)
- {
- ++cGbad_hdr;
- ++cGerror_level;
-
- DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fgprocess_data: Bad header: data packet is type CONTROL");
-
- if (! fgcheck_errors (qdaemon))
- return FALSE;
-
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN;
- continue;
- }
-
- cinbuf = iPrecend - iPrecstart;
- if (cinbuf < 0)
- cinbuf += CRECBUFLEN;
- cinbuf -= CFRAMELEN;
-
- /* Make sure we have enough data. If we don't, wait for
- more. */
-
- cwant = (int) CPACKLEN (ab);
- if (cinbuf < cwant)
- {
- if (pcneed != NULL)
- *pcneed = cwant - cinbuf;
- return TRUE;
- }
-
- /* Set up the data pointers and compute the checksum. */
- if (iPrecend >= iPrecstart)
- cfirst = cwant;
- else
- {
- cfirst = CRECBUFLEN - (iPrecstart + CFRAMELEN);
- if (cfirst >= cwant)
- cfirst = cwant;
- else if (cfirst > 0)
- {
- zsecond = abPrecbuf;
- csecond = cwant - cfirst;
- }
- else
- {
- /* Here cfirst is non-positive, so subtracting from
- abPrecbuf will actually skip the appropriate number
- of bytes at the start of abPrecbuf. */
- zfirst = abPrecbuf - cfirst;
- cfirst = cwant;
- }
- }
-
- if (csecond == 0)
- icheck = (unsigned short) igchecksum (zfirst, (size_t) cfirst);
- else
- icheck = (unsigned short) igchecksum2 (zfirst, (size_t) cfirst,
- zsecond,
- (size_t) csecond);
-
- idatcheck = ((unsigned short)
- (((0xaaaa - (icheck ^ (ab[IFRAME_CONTROL] & 0xff)))
- & 0xffff)));
- }
-
- ihdrcheck = (unsigned short) (((ab[IFRAME_CHECKHIGH] & 0xff) << 8)
- | (ab[IFRAME_CHECKLOW] & 0xff));
-
- if (ihdrcheck != idatcheck)
- {
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fgprocess_data: Bad checksum: header 0x%x, data 0x%x",
- ihdrcheck, idatcheck);
-
- ++cGbad_checksum;
- ++cGerror_level;
-
- if (! fgcheck_errors (qdaemon))
- return FALSE;
-
- /* If the checksum failed for a data packet, then if it was
- the one we were expecting send an RJ, otherwise ignore
- it. Previously if this code got the wrong packet number
- it would send an RR, but that may confuse some Telebit
- modems and it doesn't help in any case since the receiver
- will probably just ignore the RR as a duplicate (that's
- basically what this code does). If we totally missed the
- packet we will time out and send an RJ in the function
- fgwait_for_packet above. */
- if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL)
- {
- /* Make sure we've acked everything up to this point. */
- if (iGrecseq != iGlocal_ack)
- {
- if (! fgsend_acks (qdaemon))
- return FALSE;
- }
-
- /* If this is the packet we wanted, tell the sender that
- it failed. */
- if (CONTROL_XXX (ab[IFRAME_CONTROL]) == INEXTSEQ (iGrecseq))
- {
- if (! fgsend_control (qdaemon, RJ, iGrecseq))
- return FALSE;
- cGexpect_bad_order += iGrequest_winsize - 1;
- }
- }
-
- /* We can't skip the packet data after this, because if we
- have lost incoming bytes the next DLE will be somewhere
- in what we thought was the packet data. */
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN;
- continue;
- }
-
- /* We have a packet; remove the processed bytes from the receive
- buffer. */
- iPrecstart = (iPrecstart + cwant + CFRAMELEN) % CRECBUFLEN;
-
- /* Store the control byte for the handshake routines. */
- iGpacket_control = ab[IFRAME_CONTROL] & 0xff;
-
- /* Annoyingly, some UUCP packages appear to send an RR packet
- rather than an RJ packet when they want a packet to be
- resent. If we get a duplicate RR and we've never seen an RJ,
- we treat the RR as an RJ. */
- fduprr = FALSE;
- if (cGremote_rejects == 0
- && CONTROL_TT (ab[IFRAME_CONTROL]) == CONTROL
- && CONTROL_XXX (ab[IFRAME_CONTROL]) == RR
- && iGremote_ack == CONTROL_YYY (ab[IFRAME_CONTROL])
- && INEXTSEQ (iGremote_ack) != iGsendseq
- && iGretransmit_seq == -1)
- {
- DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fgprocess_data: Treating duplicate RR as RJ");
- fduprr = TRUE;
- }
-
- /* Update the received sequence number from the yyy field of a
- data packet (if it is the one we are expecting) or an RR
- control packet. If we've been delaying sending packets until
- we received an ack, this may send out some packets. */
- if ((CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL
- && CONTROL_XXX (ab[IFRAME_CONTROL]) == INEXTSEQ (iGrecseq))
- || (CONTROL_XXX (ab[IFRAME_CONTROL]) == RR && ! fduprr))
- {
- if (! fggot_ack (qdaemon, CONTROL_YYY (ab[IFRAME_CONTROL])))
- return FALSE;
- }
-
- /* If this isn't a control message, make sure we have received
- the expected packet sequence number, acknowledge the packet
- if it's the right one, and process the data. */
- if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL)
- {
- if (CONTROL_XXX (ab[IFRAME_CONTROL]) != INEXTSEQ (iGrecseq))
- {
- /* We got the wrong packet number. */
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fgprocess_data: Got packet %d; expected %d",
- CONTROL_XXX (ab[IFRAME_CONTROL]),
- INEXTSEQ (iGrecseq));
-
- if (cGexpect_bad_order > 0)
- --cGexpect_bad_order;
- else
- {
- ++cGbad_order;
- ++cGerror_level;
- if (! fgcheck_errors (qdaemon))
- return FALSE;
- }
-
- /* This code used to send an RR to encourage the other
- side to get back in synch, but that may confuse some
- Telebit modems and does little good in any case,
- since the other side will probably just ignore it
- anyhow (that's what this code does). */
- continue;
- }
-
- /* We got the packet we expected. */
- ++cGrec_packets;
- if (cGerror_level > 0
- && cGrec_packets % cGerror_decay == 0)
- --cGerror_level;
- cGexpect_bad_order = 0;
-
- iGrecseq = INEXTSEQ (iGrecseq);
-
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "fgprocess_data: Got packet %d", iGrecseq);
-
- /* Tell the caller that we found something. */
- if (pffound != NULL)
- *pffound = TRUE;
-
- /* If we are supposed to do acknowledgements here, send back
- an RR packet. */
- if (fdoacks)
- {
- if (! fgsend_acks (qdaemon))
- return FALSE;
- }
-
- /* If this is a short data packet, adjust the data pointers
- and lengths. */
- if (CONTROL_TT (ab[IFRAME_CONTROL]) == SHORTDATA)
- {
- int cshort, cmove;
-
- if ((zfirst[0] & 0x80) == 0)
- {
- cshort = zfirst[0] & 0xff;
- cmove = 1;
- }
- else
- {
- int cbyte2;
-
- if (cfirst > 1)
- cbyte2 = zfirst[1] & 0xff;
- else
- cbyte2 = zsecond[0] & 0xff;
- cshort = (zfirst[0] & 0x7f) + (cbyte2 << 7);
- cmove = 2;
- }
-
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "fgprocess_data: Packet short by %d",
- cshort);
-
- /* Adjust the start of the buffer for the bytes used
- by the count. */
- if (cfirst > cmove)
- {
- zfirst += cmove;
- cfirst -= cmove;
- }
- else
- {
- zfirst = zsecond + (cmove - cfirst);
- cfirst = csecond - (cmove - cfirst);
- csecond = 0;
- }
-
- /* Adjust the length of the buffer for the bytes we are
- not supposed to consider. */
- cshort -= cmove;
- if (csecond >= cshort)
- csecond -= cshort;
- else
- {
- cfirst -= cshort - csecond;
- csecond = 0;
- }
-
-#if DEBUG > 0
- /* This should not happen, but just in case. */
- if (cfirst < 0)
- cfirst = 0;
-#endif
- }
-
- if (! fgot_data (qdaemon, zfirst, (size_t) cfirst,
- zsecond, (size_t) csecond,
- -1, -1, (long) -1,
- INEXTSEQ (iGremote_ack) == iGsendseq,
- pfexit))
- return FALSE;
-
- /* If fgot_data told us that we were finished, get out. */
- if (*pfexit)
- return TRUE;
-
- /* If we've been asked to return control packets, get out
- now. */
- if (freturncontrol)
- {
- *pfexit = TRUE;
- return TRUE;
- }
-
- continue;
- }
-
- /* Handle control messages here. */
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_PROTO)
- || (FDEBUGGING (DEBUG_ABNORMAL)
- && CONTROL_XXX (ab[IFRAME_CONTROL]) != RR))
- ulog (LOG_DEBUG, "fgprocess_data: Got control %s %d",
- azGcontrol[CONTROL_XXX (ab[IFRAME_CONTROL])],
- CONTROL_YYY (ab[IFRAME_CONTROL]));
-#endif
-
- switch (CONTROL_XXX (ab[IFRAME_CONTROL]))
- {
- case CLOSE:
- /* The other side has closed the connection. */
- if (fLog_sighup)
- {
- ulog (LOG_ERROR, "Received unexpected CLOSE packet");
- (void) fgsend_control (qdaemon, CLOSE, 0);
- }
- return FALSE;
- case RR:
- /* Acknowledge receipt of a packet. This was already handled
- above, unless we are treating it as RJ. */
- if (! fduprr)
- break;
- /* Fall through. */
- case RJ:
- /* The other side dropped a packet. Begin retransmission with
- the packet following the one acknowledged. We don't
- retransmit the packets immediately, but instead wait
- for the first one to be acked. This prevents us from
- sending an entire window several times if we get several
- RJ packets. */
- iGremote_ack = CONTROL_YYY (ab[IFRAME_CONTROL]);
- iGretransmit_seq = INEXTSEQ (iGremote_ack);
- if (iGretransmit_seq == iGsendseq)
- iGretransmit_seq = -1;
- else
- {
- char *zpack;
-
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fgprocess_data: Remote reject: next %d resending %d",
- iGsendseq, iGretransmit_seq);
-
- ++cGresent_packets;
- if (fduprr)
- ++cGremote_duprrs;
- else
- ++cGremote_rejects;
- ++cGerror_level;
- if (! fgcheck_errors (qdaemon))
- return FALSE;
- zpack = zgadjust_ack (iGretransmit_seq);
- if (! fsend_data (qdaemon->qconn, zpack,
- CFRAMELEN + CPACKLEN (zpack),
- TRUE))
- return FALSE;
- }
- break;
- case SRJ:
- /* Selectively reject a particular packet. This is not used
- by UUCP, but it's easy to support. */
- DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fgprocess_data: Selective reject of %d",
- CONTROL_YYY (ab[IFRAME_CONTROL]));
- {
- char *zpack;
-
- ++cGresent_packets;
- ++cGremote_rejects;
- ++cGerror_level;
- zpack = zgadjust_ack (CONTROL_YYY (ab[IFRAME_CONTROL]));
- if (! fsend_data (qdaemon->qconn, zpack,
- CFRAMELEN + CPACKLEN (zpack),
- TRUE))
- return FALSE;
- }
- break;
- case INITC:
- case INITB:
- case INITA:
- /* Ignore attempts to reinitialize. */
- break;
- }
-
- /* If we've been asked to return control packets, get out. */
- if (freturncontrol)
- {
- *pfexit = TRUE;
- return TRUE;
- }
-
- /* Loop around to look for the next packet, if any. */
- }
-
- /* There is no data left in the receive buffer. */
- if (pcneed != NULL)
- *pcneed = CFRAMELEN;
- return TRUE;
-}
-
-/* Compute the 'g' protocol checksum. This is unfortunately rather
- awkward. This is the most time consuming code in the entire
- program. It's also not a great checksum, since it can be fooled
- by some single bit errors. */
-
-/* Sorry about this knavery, but it speeds up the VAX code
- significantly. It would be better to rewrite the whole routine in
- assembler. */
-#ifdef __GNUC__
-#ifdef __vax__
-#define VAX_ASM 1
-#endif
-#endif
-
-#if VAX_ASM
-#define ROTATE(i) \
- asm ("cvtwl %1,%0\n\trotl $1,%0,%0" : "=g" (i) : "g" (i))
-#else
-#define ROTATE(i) i += i + ((i & 0x8000) >> 15)
-#endif
-
-#define ITERATION \
- /* Rotate ichk1 left. */ \
- ROTATE (ichk1); \
- \
- /* The guts of the checksum. */ \
- b = BUCHAR (*z++); \
- if (b != 0) \
- { \
- ichk1 &= 0xffff; \
- ichk1 += b; \
- ichk2 += ichk1 ^ c; \
- if ((ichk1 >> 16) != 0) \
- ichk1 ^= ichk2; \
- } \
- else \
- { \
- ichk2 += ichk1 ^ c; \
- ichk1 ^= ichk2; \
- } \
- \
- --c
-
-static int
-igchecksum (z, c)
- register const char *z;
- register size_t c;
-{
- register unsigned long ichk1, ichk2;
-
- ichk1 = 0xffff;
- ichk2 = 0;
-
- do
- {
- register unsigned int b;
-
- ITERATION;
- ITERATION;
- ITERATION;
- ITERATION;
- }
- while (c > 0);
-
- return ichk1 & 0xffff;
-}
-
-/* We use a separate function compute the checksum if the block is
- split around the end of the receive buffer since it occurs much
- less frequently and the checksum is already high up in the
- profiles. These functions are almost identical, and this one
- actually only has a few more instructions in the inner loop. */
-
-static int
-igchecksum2 (zfirst, cfirst, zsecond, csecond)
- const char *zfirst;
- size_t cfirst;
- const char *zsecond;
- size_t csecond;
-{
- register unsigned long ichk1, ichk2;
- register const char *z;
- register size_t c;
-
- z = zfirst;
- c = cfirst + csecond;
-
- ichk1 = 0xffff;
- ichk2 = 0;
-
- do
- {
- register unsigned int b;
-
- ITERATION;
-
- /* If the first buffer has been finished, switch to the second. */
- --cfirst;
- if (cfirst == 0)
- z = zsecond;
- }
- while (c > 0);
-
- return ichk1 & 0xffff;
-}
diff --git a/gnu/libexec/uucp/uucico/proti.c b/gnu/libexec/uucp/uucico/proti.c
deleted file mode 100644
index 5f3c49d..0000000
--- a/gnu/libexec/uucp/uucico/proti.c
+++ /dev/null
@@ -1,1699 +0,0 @@
-/* proti.c
- The 'i' protocol.
-
- Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char proti_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "trans.h"
-#include "system.h"
-#include "prot.h"
-
-/* The 'i' protocol is a simple sliding window protocol, created by
- me. It is in many ways similar to the 'g' protocol. Several ideas
- are also taken from the paper ``A High-Throughput Message Transport
- System'' by P. Lauder. I don't know where the paper was published,
- but the author's e-mail address is piers@cs.su.oz.au. However, I
- haven't adopted his main idea, which is to dispense with windows
- entirely. This is because some links still do require flow control
- and, more importantly, because I want to have a limit to the amount
- of data I must be able to resend upon request. To reduce the costs
- of window acknowledgements, I use a large window and only require
- an ack at the halfway point.
-
- Each packet starts with a header containing the following
- information:
-
- Intro byte 8 bits byte 1
- Packet number 5 bits byte 2
- Local channel 3 bits
- Packet ack 5 bits byte 3
- Remote channel 3 bits
- Packet type 3 bits bytes 4-5
- Direction 1 bit
- Data length 12 bits
- Header check 8 bits byte 6
-
- If the data length is not 0, this is followed by the data and a 32
- bit CRC checksum.
-
- The following packet types are defined:
-
- SYNC Initialize the connection
- DATA Data packet
- ACK Simple acknowledgement with no data
- NAK Negative acknowledgement; requests resend of single packet
- SPOS Set file position
- CLOSE Close the connection
- */
-
-/* The offsets of the bytes in the packet header. */
-
-#define IHDR_INTRO (0)
-#define IHDR_LOCAL (1)
-#define IHDR_REMOTE (2)
-#define IHDR_CONTENTS1 (3)
-#define IHDR_CONTENTS2 (4)
-#define IHDR_CHECK (5)
-
-/* Macros to set and extract values of IHDR_LOCAL and IHDR_REMOTE. */
-#define IHDRWIN_SET(iseq, ichan) (((iseq) << 3) | (ichan))
-#define IHDRWIN_GETSEQ(ival) (((ival) >> 3) & 0x1f)
-#define IHDRWIN_GETCHAN(ival) ((ival) & 0x07)
-
-/* Macros to set and extract values of IHDR_CONTENTS fields. */
-#define IHDRCON_SET1(ttype, fcaller, cbytes) \
- (((ttype) << 5) | ((fcaller) ? (1 << 4) : 0) | (((cbytes) >> 8) & 0x0f))
-#define IHDRCON_SET2(ttype, fcaller, cbytes) ((cbytes) & 0xff)
-#define THDRCON_GETTYPE(i1, i2) (((i1) >> 5) & 0x07)
-#define FHDRCON_GETCALLER(i1, i2) (((i1) & (1 << 4)) != 0)
-#define CHDRCON_GETBYTES(i1, i2) ((((i1) & 0x0f) << 8) | ((i2) & 0xff))
-
-/* Macros for the IHDR_CHECK field. */
-#define IHDRCHECK_VAL(zhdr) \
- ((zhdr[IHDR_LOCAL] \
- ^ zhdr[IHDR_REMOTE] \
- ^ zhdr[IHDR_CONTENTS1] \
- ^ zhdr[IHDR_CONTENTS2]) \
- & 0xff)
-
-/* Length of the packet header. */
-#define CHDRLEN (6)
-
-/* Amount of space to skip between start of packet and actual data.
- This is used to make the actual data longword aligned, to encourage
- good performance when copying data into the buffer. */
-#define CHDRSKIPLEN (CHDRLEN + (sizeof (long) - CHDRLEN % sizeof (long)))
-
-/* Amount of space to skip between memory buffer and header. */
-#define CHDROFFSET (CHDRSKIPLEN - CHDRLEN)
-
-/* Length of the trailing checksum. */
-#define CCKSUMLEN (4)
-
-/* Macros to set and get the checksum. These multiply evaluate their
- arguments. */
-#define ICKSUM_GET(z) \
- ((((((((unsigned long) ((z)[0] & 0xff)) << 8) \
- | (unsigned long) ((z)[1] & 0xff)) << 8) \
- | (unsigned long) ((z)[2] & 0xff)) << 8) \
- | (unsigned long) ((z)[3] & 0xff))
-#define UCKSUM_SET(z, i) \
- (void) ((z)[0] = (((i) >> 24) & 0xff), \
- (z)[1] = (((i) >> 16) & 0xff), \
- (z)[2] = (((i) >> 8) & 0xff), \
- (z)[3] = ((i) & 0xff))
-
-/* The header introduction character. */
-#define IINTRO ('\007')
-
-/* The packet types. */
-
-#define DATA (0)
-#define SYNC (1)
-#define ACK (2)
-#define NAK (3)
-#define SPOS (4)
-#define CLOSE (5)
-
-/* Largest possible packet size. */
-#define IMAXPACKSIZE ((1 << 12) - 1)
-
-/* Largest possible sequence number (plus 1). */
-#define IMAXSEQ 32
-
-/* Get the next sequence number given a sequence number. */
-#define INEXTSEQ(i) (((i) + 1) & (IMAXSEQ - 1))
-
-/* Get the previous sequence number given a sequence number. */
-#define IPREVSEQ(i) (((i) + IMAXSEQ - 1) & (IMAXSEQ - 1))
-
-/* Compute i1 - i2 in sequence space (i.e., the number of packets from
- i2 to i1). */
-#define CSEQDIFF(i1, i2) (((i1) + IMAXSEQ - (i2)) & (IMAXSEQ - 1))
-
-/* Largest possible channel number (plus 1). */
-#define IMAXICHAN (8)
-
-/* Default packet size to request (protocol parameter
- ``packet-size''). */
-#define IREQUEST_PACKSIZE (1024)
-
-/* Default window size to request (protocol parameter ``window''). */
-#define IREQUEST_WINSIZE (16)
-
-/* Default timeout to use when sending the SYNC packet (protocol
- parameter ``sync-timeout''). */
-#define CSYNC_TIMEOUT (10)
-
-/* Default number of times to retry sending the SYNC packet (protocol
- parameter ``sync-retries''). */
-#define CSYNC_RETRIES (6)
-
-/* Default timeout to use when waiting for a packet (protocol
- parameter ``timeout''). */
-#define CTIMEOUT (10)
-
-/* Default number of times to retry sending a packet before giving up
- (protocol parameter ``retries''). */
-#define CRETRIES (6)
-
-/* Default maximum level of errors to accept before giving up
- (protocol parameter ``errors''). */
-#define CERRORS (100)
-
-/* Default decay rate. Each time we receive this many packets
- succesfully, we decrement the error level by one (protocol
- parameter ``error-decay''). */
-#define CERROR_DECAY (10)
-
-/* The default list of characters to avoid: XON and XOFF. This string
- is processed as an escape sequence. This is 'j' protocol parameter
- ``avoid''; it is defined in this file because the 'i' and 'j'
- protocols share protocol parameters. */
-#define ZAVOID "\\021\\023"
-
-/* Local variables. */
-
-/* Packet size to request (protocol parameter ``packet-size''). */
-static int iIrequest_packsize = IREQUEST_PACKSIZE;
-
-/* Window size to request (protocol parameter ``window''). */
-static int iIrequest_winsize = IREQUEST_WINSIZE;
-
-/* Remote packet size (set from SYNC packet or from
- iIforced_remote_packsize). */
-static int iIremote_packsize;
-
-/* Size which buffers were allocated for. */
-static int iIalc_packsize;
-
-/* Forced remote packet size, used if non-zero (protocol parameter
- ``remote-packet-size''). There is no forced remote window size
- because the ACK strategy requires that both sides agree on the
- window size. */
-static int iIforced_remote_packsize = 0;
-
-/* Remote window size (set from SYNC packet). */
-static int iIremote_winsize;
-
-/* Timeout to use when sending the SYNC packet (protocol
- parameter ``sync-timeout''). */
-int cIsync_timeout = CSYNC_TIMEOUT;
-
-/* Number of times to retry sending the SYNC packet (protocol
- parameter ``sync-retries''). */
-static int cIsync_retries = CSYNC_RETRIES;
-
-/* Timeout to use when waiting for a packet (protocol parameter
- ``timeout''). */
-static int cItimeout = CTIMEOUT;
-
-/* Timeout to use when waiting for an acknowledgement to open up space
- in the window. This is computed based on the window size and the
- connection speed. */
-static int cIwindow_timeout = CTIMEOUT;
-
-/* Number of times to retry sending a packet before giving up
- (protocol parameter ``retries''). */
-static int cIretries = CRETRIES;
-
-/* Maximum level of errors to accept before giving up (protocol
- parameter ``errors''). */
-static int cIerrors = CERRORS;
-
-/* Each time we receive this many packets succesfully, we decrement
- the error level by one (protocol parameter ``error-decay''). */
-static int cIerror_decay = CERROR_DECAY;
-
-/* The number of packets we should wait to receive before sending an
- ACK; this is set by default to half the window size we have
- requested (protocol parameter ``ack-frequency''). */
-static int cIack_frequency = 0;
-
-/* The set of characters to avoid (protocol parameter ``avoid'').
- This is actually part of the 'j' protocol; it is defined in this
- file because the 'i' and 'j' protocols use the same protocol
- parameters. */
-const char *zJavoid_parameter = ZAVOID;
-
-/* Routine to use when sending data. This is a hook for the 'j'
- protocol. */
-static boolean (*pfIsend) P((struct sconnection *qconn, const char *zsend,
- size_t csend, boolean fdoread));
-
-/* Routine to use to use when reading data. This is a hook for the
- 'j' protocol. */
-static boolean (*pfIreceive) P((struct sconnection *qconn, size_t cneed,
- size_t *pcrec, int ctimeout,
- boolean freport));
-
-/* Next sequence number to send. */
-static int iIsendseq;
-
-/* Last sequence number received. */
-static int iIrecseq;
-
-/* Last sequence number we have acknowledged. */
-static int iIlocal_ack;
-
-/* Last sequence number remote system has acknowledged. */
-static int iIremote_ack;
-
-/* File position we are sending from. */
-static long iIsendpos;
-
-/* File position we are receiving to. */
-static long iIrecpos;
-
-/* TRUE if closing the connection. */
-static boolean fIclosing;
-
-/* Array of sent packets indexed by packet number. */
-static char *azIsendbuffers[IMAXSEQ];
-
-/* Array of received packets that we aren't ready to process yet,
- indexed by packet number. */
-static char *azIrecbuffers[IMAXSEQ];
-
-/* For each packet sequence number, record whether we sent a NAK for
- the packet. */
-static boolean afInaked[IMAXSEQ];
-
-/* Number of SYNC packets received (used only to detect whether one
- was received). */
-static int cIsyncs;
-
-/* Number of packets sent. */
-static long cIsent_packets;
-
-/* Number of packets received. */
-static long cIreceived_packets;
-
-/* Number of packets resent. */
-static long cIresent_packets;
-
-/* Number of bad packet headers received. */
-static long cIbad_hdr;
-
-/* Number of out of order packets received. */
-static long cIbad_order;
-
-/* Number of bad checksums received. */
-static long cIbad_cksum;
-
-/* Number of packets rejected by remote system. */
-static long cIremote_rejects;
-
-/* Protocol parameter commands. */
-
-struct uuconf_cmdtab asIproto_params[] =
-{
- { "packet-size", UUCONF_CMDTABTYPE_INT, (pointer) &iIrequest_packsize,
- NULL },
- { "window", UUCONF_CMDTABTYPE_INT, (pointer) &iIrequest_winsize, NULL },
- { "remote-packet-size", UUCONF_CMDTABTYPE_INT,
- (pointer) &iIforced_remote_packsize, NULL },
- { "sync-timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cIsync_timeout,
- NULL },
- { "sync-retries", UUCONF_CMDTABTYPE_INT, (pointer) &cIsync_retries,
- NULL },
- { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cItimeout, NULL },
- { "retries", UUCONF_CMDTABTYPE_INT, (pointer) &cIretries, NULL },
- { "errors", UUCONF_CMDTABTYPE_INT, (pointer) &cIerrors, NULL },
- { "error-decay", UUCONF_CMDTABTYPE_INT, (pointer) &cIerror_decay, NULL },
- { "ack-frequency", UUCONF_CMDTABTYPE_INT, (pointer) &cIack_frequency, NULL },
- /* The ``avoid'' protocol parameter is part of the 'j' protocol, but
- it is convenient for the 'i' and 'j' protocols to share the same
- protocol parameter table. */
- { "avoid", UUCONF_CMDTABTYPE_STRING, (pointer) &zJavoid_parameter, NULL },
- { NULL, 0, NULL, NULL }
-};
-
-/* Local functions. */
-
-static boolean finak P((struct sdaemon *qdaemon, int iseq));
-static boolean firesend P((struct sdaemon *qdaemon));
-static boolean fiwindow_wait P((struct sdaemon *qdaemon));
-static boolean fiwait_for_packet P((struct sdaemon *qdaemon,
- int ctimeout, int cretries,
- boolean fone, boolean *ftimedout));
-static boolean ficheck_errors P((struct sdaemon *qdaemon));
-static boolean fiprocess_data P((struct sdaemon *qdaemon,
- boolean *pfexit, boolean *pffound,
- size_t *pcneed));
-static boolean fiprocess_packet P((struct sdaemon *qdaemon,
- const char *zhdr,
- const char *zfirst, int cfirst,
- const char *zsecond, int csecond,
- boolean *pfexit));
-
-/* The 'i' protocol start routine. The work is done in a routine
- which is also called by the 'j' protocol start routine. */
-
-boolean
-fistart (qdaemon, pzlog)
- struct sdaemon *qdaemon;
- char **pzlog;
-{
- return fijstart (qdaemon, pzlog, IMAXPACKSIZE, fsend_data, freceive_data);
-}
-
-/* Start the protocol. This routine is called by both the 'i' and 'j'
- protocol start routines. We keep transmitting a SYNC packet
- containing the window and packet size we would like to receive
- until we receive a SYNC packet from the remote system. The first
- two bytes of the data contents of a SYNC packet are the maximum
- packet size we want to receive (high byte, low byte), and the next
- byte is the maximum window size we want to use. */
-
-boolean
-fijstart (qdaemon, pzlog, imaxpacksize, pfsend, pfreceive)
- struct sdaemon *qdaemon;
- char **pzlog;
- int imaxpacksize;
- boolean (*pfsend) P((struct sconnection *qconn, const char *zsend,
- size_t csend, boolean fdoread));
- boolean (*pfreceive) P((struct sconnection *qconn, size_t cneed,
- size_t *pcrec, int ctimeout, boolean freport));
-{
- char ab[CHDRLEN + 4 + CCKSUMLEN];
- unsigned long icksum;
- int ctries;
- int csyncs;
- long ibaud;
-
- *pzlog = NULL;
-
- pfIsend = pfsend;
- pfIreceive = pfreceive;
-
- if (iIforced_remote_packsize <= 0
- || iIforced_remote_packsize > imaxpacksize)
- iIforced_remote_packsize = 0;
- else
- iIremote_packsize = iIforced_remote_packsize;
- iIalc_packsize = 0;
-
- iIsendseq = 1;
- iIrecseq = 0;
- iIlocal_ack = 0;
- iIremote_ack = 0;
- iIsendpos = 0;
- iIrecpos = 0;
- fIclosing = FALSE;
-
- cIsent_packets = 0;
- cIreceived_packets = 0;
- cIresent_packets = 0;
- cIbad_hdr = 0;
- cIbad_order = 0;
- cIbad_cksum = 0;
- cIremote_rejects = 0;
-
- if (iIrequest_packsize < 0 || iIrequest_packsize > imaxpacksize)
- {
- ulog (LOG_ERROR, "Illegal protocol '%c' packet size; using %d",
- qdaemon->qproto->bname, imaxpacksize);
- iIrequest_packsize = imaxpacksize;
- }
-
- /* The maximum permissible window size is 16. Otherwise the
- protocol can get confused because a duplicated packet may arrive
- out of order. If the window size is large in such a case, the
- duplicate packet may be treated as a packet in the upcoming
- window, causing the protocol to assume that all intermediate
- packets have been lost, leading to immense confusion. */
- if (iIrequest_winsize < 0 || iIrequest_winsize > IMAXSEQ / 2)
- {
- ulog (LOG_ERROR, "Illegal protocol '%c' window size; using %d",
- qdaemon->qproto->bname, IREQUEST_WINSIZE);
- iIrequest_winsize = IREQUEST_WINSIZE;
- }
-
- /* The default for the ACK frequency is half the window size. */
- if (cIack_frequency <= 0 || cIack_frequency >= iIrequest_winsize)
- cIack_frequency = iIrequest_winsize / 2;
-
- ab[IHDR_INTRO] = IINTRO;
- ab[IHDR_LOCAL] = ab[IHDR_REMOTE] = IHDRWIN_SET (0, 0);
- ab[IHDR_CONTENTS1] = IHDRCON_SET1 (SYNC, qdaemon->fcaller, 4);
- ab[IHDR_CONTENTS2] = IHDRCON_SET2 (SYNC, qdaemon->fcaller, 4);
- ab[IHDR_CHECK] = IHDRCHECK_VAL (ab);
- ab[CHDRLEN + 0] = (iIrequest_packsize >> 8) & 0xff;
- ab[CHDRLEN + 1] = iIrequest_packsize & 0xff;
- ab[CHDRLEN + 2] = iIrequest_winsize;
- ab[CHDRLEN + 3] = qdaemon->cchans;
- icksum = icrc (ab + CHDRLEN, 4, ICRCINIT);
- UCKSUM_SET (ab + CHDRLEN + 4, icksum);
-
- /* The static cIsyncs is incremented each time a SYNC packet is
- received. */
- csyncs = cIsyncs;
- ctries = 0;
-
- while (TRUE)
- {
- boolean ftimedout;
-
- DEBUG_MESSAGE3 (DEBUG_PROTO,
- "fistart: Sending SYNC packsize %d winsize %d channels %d",
- iIrequest_packsize, iIrequest_winsize, qdaemon->cchans);
-
- if (! (*pfIsend) (qdaemon->qconn, ab, CHDRLEN + 4 + CCKSUMLEN,
- TRUE))
- return FALSE;
-
- if (fiwait_for_packet (qdaemon, cIsync_timeout, 0, FALSE,
- &ftimedout))
- {
- if (csyncs != cIsyncs)
- break;
- }
- else
- {
- if (! ftimedout)
- return FALSE;
-
- ++ctries;
- if (ctries > cIsync_retries)
- {
- ulog (LOG_ERROR, "Protocol startup failed");
- return FALSE;
- }
- }
- }
-
- /* Calculate the window timeout. */
- ibaud = iconn_baud (qdaemon->qconn);
- if (ibaud == 0)
- cIwindow_timeout = cItimeout;
- else
- {
- /* We expect to receive an ACK about halfway through each
- window. In principle, an entire window might be sitting in a
- modem buffer while we are waiting for an ACK. Therefore, the
- minimum time we should wait for an ACK is
- (1/2 window size) * (seconds / byte) + (roundtrip time) ==
- (1/2 window size) * (1 / (baud / 10)) + (roundtrip time) ==
- (1/2 window size) * (10 / baud) + (roundtrip time) ==
- (5 * (window size)) / baud + (roundtrip time)
-
- The window size is iIremote_packsize * iIremote_winsize. For
- typical settings of packsize == 1024, winsize == 16, baud ==
- 9600, this equation works out to
- (5 * 1024 * 16) / 9600 == 8 seconds
- We then take cItimeout as the round trip time, which gives us
- some flexibility. We get more flexibility because it is
- quite likely that by the time we have finished sending out
- the last packet in a window, the first one has already been
- received by the remote system. */
- cIwindow_timeout = ((5 * iIremote_packsize * iIremote_winsize) / ibaud
- + cItimeout);
- }
-
- /* If we are the callee, bump both timeouts by one, to make it less
- likely that both systems will timeout simultaneously. */
- if (! qdaemon->fcaller)
- {
- ++cItimeout;
- ++cIwindow_timeout;
- }
-
- /* We got a SYNC packet; set up packet buffers to use. */
- if (iIremote_packsize > imaxpacksize)
- iIremote_packsize = imaxpacksize;
- do
- {
- int iseq;
-
- for (iseq = 0; iseq < IMAXSEQ; iseq++)
- {
- azIrecbuffers[iseq] = NULL;
- afInaked[iseq] = FALSE;
- azIsendbuffers[iseq] = (char *) malloc (iIremote_packsize
- + CHDRSKIPLEN
- + CCKSUMLEN);
- if (azIsendbuffers[iseq] == NULL)
- {
- int ifree;
-
- for (ifree = 0; ifree < iseq; ifree++)
- free ((pointer) azIsendbuffers[ifree]);
- break;
- }
- }
-
- if (iseq >= IMAXSEQ)
- {
- *pzlog =
- zbufalc (sizeof "protocol '' sending packet/window / receiving /"
- + 64);
- sprintf (*pzlog,
- "protocol '%c' sending packet/window %d/%d receiving %d/%d",
- qdaemon->qproto->bname, (int) iIremote_packsize,
- (int) iIremote_winsize, (int) iIrequest_packsize,
- (int) iIrequest_winsize);
-
- iIalc_packsize = iIremote_packsize;
-
- return TRUE;
- }
-
- iIremote_packsize >>= 1;
- }
- while (iIremote_packsize > 200);
-
- ulog (LOG_ERROR,
- "'%c' protocol startup failed; insufficient memory for packets",
- qdaemon->qproto->bname);
-
- return FALSE;
-}
-
-/* Shut down the protocol. We can be fairly informal about this,
- since we know that the upper level protocol has already exchanged
- hangup messages. If we didn't know that, we would have to make
- sure that all packets before the CLOSE had been received. */
-
-boolean
-fishutdown (qdaemon)
- struct sdaemon *qdaemon;
-{
- char *z;
- size_t clen;
-
- fIclosing = TRUE;
-
- z = zigetspace (qdaemon, &clen) - CHDRLEN;
-
- z[IHDR_INTRO] = IINTRO;
- z[IHDR_LOCAL] = IHDRWIN_SET (iIsendseq, 0);
- z[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0);
- iIlocal_ack = iIrecseq;
- z[IHDR_CONTENTS1] = IHDRCON_SET1 (CLOSE, qdaemon->fcaller, 0);
- z[IHDR_CONTENTS2] = IHDRCON_SET2 (CLOSE, qdaemon->fcaller, 0);
- z[IHDR_CHECK] = IHDRCHECK_VAL (z);
-
- DEBUG_MESSAGE0 (DEBUG_PROTO, "fishutdown: Sending CLOSE");
-
- if (! (*pfIsend) (qdaemon->qconn, z, CHDRLEN, FALSE))
- return FALSE;
-
- ulog (LOG_NORMAL,
- "Protocol '%c' packets: sent %ld, resent %ld, received %ld",
- qdaemon->qproto->bname, cIsent_packets, cIresent_packets,
- cIreceived_packets);
- if (cIbad_hdr != 0
- || cIbad_cksum != 0
- || cIbad_order != 0
- || cIremote_rejects != 0)
- ulog (LOG_NORMAL,
- "Errors: header %ld, checksum %ld, order %ld, remote rejects %ld",
- cIbad_hdr, cIbad_cksum, cIbad_order, cIremote_rejects);
-
- /* Reset the protocol parameters to their default values. */
- iIrequest_packsize = IREQUEST_PACKSIZE;
- iIrequest_winsize = IREQUEST_WINSIZE;
- iIforced_remote_packsize = 0;
- cIsync_timeout = CSYNC_TIMEOUT;
- cIsync_retries = CSYNC_RETRIES;
- cItimeout = CTIMEOUT;
- cIwindow_timeout = CTIMEOUT;
- cIretries = CRETRIES;
- cIerrors = CERRORS;
- cIerror_decay = CERROR_DECAY;
- cIack_frequency = 0;
- zJavoid_parameter = ZAVOID;
-
- return TRUE;
-}
-
-/* Send a command string. These are just sent as normal packets,
- ending in a packet containing a null byte. */
-
-boolean
-fisendcmd (qdaemon, z, ilocal, iremote)
- struct sdaemon *qdaemon;
- const char *z;
- int ilocal;
- int iremote;
-{
- size_t clen;
-
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fisendcmd: Sending command \"%s\"", z);
-
- clen = strlen (z);
-
- while (TRUE)
- {
- char *zpacket;
- size_t csize;
-
- zpacket = zigetspace (qdaemon, &csize);
-
- if (clen < csize)
- {
- memcpy (zpacket, z, clen + 1);
- return fisenddata (qdaemon, zpacket, clen + 1, ilocal, iremote,
- (long) -1);
- }
-
- memcpy (zpacket, z, csize);
- z += csize;
- clen -= csize;
-
- if (! fisenddata (qdaemon, zpacket, csize, ilocal, iremote, (long) -1))
- return FALSE;
- }
- /*NOTREACHED*/
-}
-
-/* Send a NAK. */
-
-static boolean
-finak (qdaemon, iseq)
- struct sdaemon *qdaemon;
- int iseq;
-{
- char abnak[CHDRLEN];
-
- abnak[IHDR_INTRO] = IINTRO;
- abnak[IHDR_LOCAL] = IHDRWIN_SET (iseq, 0);
- abnak[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0);
- iIlocal_ack = iIrecseq;
- abnak[IHDR_CONTENTS1] = IHDRCON_SET1 (NAK, qdaemon->fcaller, 0);
- abnak[IHDR_CONTENTS2] = IHDRCON_SET2 (NAK, qdaemon->fcaller, 0);
- abnak[IHDR_CHECK] = IHDRCHECK_VAL (abnak);
-
- afInaked[iseq] = TRUE;
-
- DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "finak: Sending NAK %d", iseq);
-
- return (*pfIsend) (qdaemon->qconn, abnak, CHDRLEN, TRUE);
-}
-
-/* Resend the latest packet the remote has not acknowledged. */
-
-static boolean
-firesend (qdaemon)
- struct sdaemon *qdaemon;
-{
- int iseq;
- char *zhdr;
- size_t clen;
-
- iseq = INEXTSEQ (iIremote_ack);
- if (iseq == iIsendseq)
- {
- /* Everything has been ACKed and there is nothing to resend. */
- return TRUE;
- }
-
- DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "firesend: Resending packet %d", iseq);
-
- /* Update the received sequence number. */
- zhdr = azIsendbuffers[iseq] + CHDROFFSET;
- if (IHDRWIN_GETSEQ (zhdr[IHDR_REMOTE]) != iIrecseq)
- {
- int iremote;
-
- iremote = IHDRWIN_GETCHAN (zhdr[IHDR_REMOTE]);
- zhdr[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, iremote);
- zhdr[IHDR_CHECK] = IHDRCHECK_VAL (zhdr);
- iIlocal_ack = iIrecseq;
- }
-
- ++cIresent_packets;
-
- clen = CHDRCON_GETBYTES (zhdr[IHDR_CONTENTS1],
- zhdr[IHDR_CONTENTS2]);
-
- return (*pfIsend) (qdaemon->qconn, zhdr,
- CHDRLEN + clen + (clen > 0 ? CCKSUMLEN : 0),
- TRUE);
-}
-
-/* Wait until there is an opening in the receive window of the remote
- system. */
-
-static boolean
-fiwindow_wait (qdaemon)
- struct sdaemon *qdaemon;
-{
- /* iIsendseq is the sequence number we are sending, and iIremote_ack
- is the last sequence number acknowledged by the remote. */
- while (CSEQDIFF (iIsendseq, iIremote_ack) > iIremote_winsize)
- {
- /* If a NAK is lost, it is possible for the other side to be
- sending a stream of packets while we are waiting for an ACK.
- This should be caught in fiprocess_data; if it is about to
- send an ACK, but it has an unacknowledged packet to send, it
- sends the entire packet. Hopefully that will trigger an ACK
- or a NAK and get us going again. */
- DEBUG_MESSAGE0 (DEBUG_PROTO, "fiwindow_wait: Waiting for ACK");
- if (! fiwait_for_packet (qdaemon, cIwindow_timeout, cIretries,
- TRUE, (boolean *) NULL))
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Get buffer space to use for packet data. We return a pointer to
- the space to be used for the actual data, leaving room for the
- header. */
-
-/*ARGSUSED*/
-char *
-zigetspace (qdaemon, pclen)
- struct sdaemon *qdaemon;
- size_t *pclen;
-{
- *pclen = iIremote_packsize;
- return azIsendbuffers[iIsendseq] + CHDRSKIPLEN;
-}
-
-/* Send a data packet. The zdata argument will always point to value
- returned by zigetspace, so we know that we have room before it for
- the header information. */
-
-boolean
-fisenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos)
- struct sdaemon *qdaemon;
- char *zdata;
- size_t cdata;
- int ilocal;
- int iremote;
- long ipos;
-{
- char *zhdr;
- unsigned long icksum;
- boolean fret;
-
-#if DEBUG > 0
- if (ilocal < 0 || ilocal >= IMAXICHAN
- || iremote < 0 || iremote >= IMAXICHAN)
- ulog (LOG_FATAL, "fisenddata: ilocal %d iremote %d", ilocal, iremote);
-#endif
-
- /* If we are changing the file position, we must send an SPOS
- packet. */
- if (ipos != iIsendpos && ipos != (long) -1)
- {
- int inext;
- char *zspos;
-
- /* We need to get a buffer to hold the SPOS packet, and it needs
- to be next sequence number. However, the data we have been
- given is currently in the next sequence number buffer. So we
- shuffle the buffers around. */
- inext = INEXTSEQ (iIsendseq);
- zspos = azIsendbuffers[inext];
- azIsendbuffers[inext] = zdata - CHDRSKIPLEN;
- azIsendbuffers[iIsendseq] = zspos;
- zspos += CHDROFFSET;
-
- zspos[IHDR_INTRO] = IINTRO;
- zspos[IHDR_LOCAL] = IHDRWIN_SET (iIsendseq, 0);
- zspos[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0);
- iIlocal_ack = iIrecseq;
- zspos[IHDR_CONTENTS1] = IHDRCON_SET1 (SPOS, qdaemon->fcaller,
- CCKSUMLEN);
- zspos[IHDR_CONTENTS2] = IHDRCON_SET2 (SPOS, qdaemon->fcaller,
- CCKSUMLEN);
- zspos[IHDR_CHECK] = IHDRCHECK_VAL (zspos);
- UCKSUM_SET (zspos + CHDRLEN, (unsigned long) ipos);
- icksum = icrc (zspos + CHDRLEN, CCKSUMLEN, ICRCINIT);
- UCKSUM_SET (zspos + CHDRLEN + CCKSUMLEN, icksum);
-
- /* Wait for an opening in the window. */
- if (iIremote_winsize > 0
- && CSEQDIFF (iIsendseq, iIremote_ack) > iIremote_winsize)
- {
- if (! fiwindow_wait (qdaemon))
- return FALSE;
- }
-
- DEBUG_MESSAGE1 (DEBUG_PROTO, "fisenddata: Sending SPOS %ld",
- ipos);
-
- if (! (*pfIsend) (qdaemon->qconn, zspos,
- CHDRLEN + CCKSUMLEN + CCKSUMLEN, TRUE))
- return FALSE;
-
- iIsendseq = INEXTSEQ (iIsendseq);
- iIsendpos = ipos;
- }
-
- zhdr = zdata - CHDRLEN;
- zhdr[IHDR_INTRO] = IINTRO;
- zhdr[IHDR_LOCAL] = IHDRWIN_SET (iIsendseq, ilocal);
- zhdr[IHDR_CONTENTS1] = IHDRCON_SET1 (DATA, qdaemon->fcaller, cdata);
- zhdr[IHDR_CONTENTS2] = IHDRCON_SET2 (DATA, qdaemon->fcaller, cdata);
-
- /* Compute and set the checksum. */
- if (cdata > 0)
- {
- icksum = icrc (zdata, cdata, ICRCINIT);
- UCKSUM_SET (zdata + cdata, icksum);
- }
-
- /* Wait until there is an opening in the window (we hope to not have
- to wait here at all, actually; ideally the window should be large
- enough to avoid a wait). */
- if (iIremote_winsize > 0
- && CSEQDIFF (iIsendseq, iIremote_ack) > iIremote_winsize)
- {
- if (! fiwindow_wait (qdaemon))
- return FALSE;
- }
-
- /* We only fill in IHDR_REMOTE now, since only now do know the
- correct value of iIrecseq. */
- zhdr[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, iremote);
- iIlocal_ack = iIrecseq;
- zhdr[IHDR_CHECK] = IHDRCHECK_VAL (zhdr);
-
- DEBUG_MESSAGE4 (DEBUG_PROTO,
- "fisenddata: Sending packet %d size %d local %d remote %d",
- iIsendseq, (int) cdata, ilocal, iremote);
-
- iIsendseq = INEXTSEQ (iIsendseq);
- ++cIsent_packets;
-
- fret = (*pfIsend) (qdaemon->qconn, zhdr,
- cdata + CHDRLEN + (cdata > 0 ? CCKSUMLEN : 0),
- TRUE);
-
- iIsendpos += cdata;
-
- if (fret && iPrecstart != iPrecend)
- {
- boolean fexit;
-
- fret = fiprocess_data (qdaemon, &fexit, (boolean *) NULL,
- (size_t *) NULL);
- }
-
- return fret;
-}
-
-/* Wait for data to come in. */
-
-boolean
-fiwait (qdaemon)
- struct sdaemon *qdaemon;
-{
- return fiwait_for_packet (qdaemon, cItimeout, cIretries,
- FALSE, (boolean *) NULL);
-}
-
-/* Wait for a packet. Either there is no data to send, or the remote
- window is full. */
-
-static boolean
-fiwait_for_packet (qdaemon, ctimeout, cretries, fone, pftimedout)
- struct sdaemon *qdaemon;
- int ctimeout;
- int cretries;
- boolean fone;
- boolean *pftimedout;
-{
- int cshort;
- int ctimeouts;
-
- if (pftimedout != NULL)
- *pftimedout = FALSE;
-
- cshort = 0;
- ctimeouts = 0;
-
- while (TRUE)
- {
- boolean fexit, ffound;
- size_t cneed;
- size_t crec;
-
- if (! fiprocess_data (qdaemon, &fexit, &ffound, &cneed))
- return FALSE;
-
- if (fexit || (fone && ffound))
- return TRUE;
-
- if (cneed == 0)
- continue;
-
- DEBUG_MESSAGE1 (DEBUG_PROTO, "fiwait_for_packet: Need %d bytes",
- (int) cneed);
-
- if (! (*pfIreceive) (qdaemon->qconn, cneed, &crec, ctimeout, TRUE))
- return FALSE;
-
- if (crec != 0)
- {
- /* If we didn't get enough data twice in a row, we may have
- dropped some data and be waiting for the end of a large
- packet. Incrementing iPrecstart will force
- fiprocess_data to skip the current packet and try to find
- the next one. */
- if (crec >= cneed)
- cshort = 0;
- else
- {
- ++cshort;
- if (cshort > 1)
- {
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN;
- cshort = 0;
- }
- }
- }
- else
- {
- int i;
-
- /* We timed out on the read. */
- ++ctimeouts;
- if (ctimeouts > cretries)
- {
- if (cretries > 0)
- ulog (LOG_ERROR, "Timed out waiting for packet");
- if (pftimedout != NULL)
- *pftimedout = TRUE;
- return FALSE;
- }
-
- /* Clear out the list of packets we have sent NAKs for. We
- should have seen some sort of response by now. */
- for (i = 0; i < IMAXSEQ; i++)
- afInaked[i] = FALSE;
-
- /* Send a NAK for the packet we want, and, if we have an
- unacknowledged packet, send it again. */
- if (! finak (qdaemon, INEXTSEQ (iIrecseq))
- || ! firesend (qdaemon))
- return FALSE;
- }
- }
- /*NOTREACHED*/
-}
-
-/* Make sure we haven't overflowed the permissible error level. */
-
-static boolean
-ficheck_errors (qdaemon)
- struct sdaemon *qdaemon;
-{
- if (cIerrors < 0)
- return TRUE;
-
- if (((cIbad_order + cIbad_hdr + cIbad_cksum + cIremote_rejects)
- - (cIreceived_packets / cIerror_decay))
- > cIerrors)
- {
- /* Try shrinking the packet size. */
- if (iIrequest_packsize > 400)
- {
- char absync[CHDRLEN + 3 + CCKSUMLEN];
- unsigned long icksum;
-
- /* Don't bother sending the number of channels in this
- packet. */
- iIrequest_packsize /= 2;
- absync[IHDR_INTRO] = IINTRO;
- absync[IHDR_LOCAL] = IHDRWIN_SET (0, 0);
- absync[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0);
- iIlocal_ack = iIrecseq;
- absync[IHDR_CONTENTS1] = IHDRCON_SET1 (SYNC, qdaemon->fcaller, 3);
- absync[IHDR_CONTENTS2] = IHDRCON_SET2 (SYNC, qdaemon->fcaller, 3);
- absync[IHDR_CHECK] = IHDRCHECK_VAL (absync);
- absync[CHDRLEN + 0] = (iIrequest_packsize >> 8) & 0xff;
- absync[CHDRLEN + 1] = iIrequest_packsize & 0xff;
- absync[CHDRLEN + 2] = iIrequest_winsize;
- icksum = icrc (absync + CHDRLEN, 3, ICRCINIT);
- UCKSUM_SET (absync + CHDRLEN + 3, icksum);
-
- cIerrors *= 2;
-
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "ficheck_errors: Sending SYNC packsize %d winsize %d",
- iIrequest_packsize, iIrequest_winsize);
-
- return (*pfIsend) (qdaemon->qconn, absync,
- CHDRLEN + 3 + CCKSUMLEN, TRUE);
- }
-
- ulog (LOG_ERROR, "Too many '%c' protocol errors",
- qdaemon->qproto->bname);
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Process data waiting in the receive buffer, passing to the
- fgot_data function. */
-
-static boolean
-fiprocess_data (qdaemon, pfexit, pffound, pcneed)
- struct sdaemon *qdaemon;
- boolean *pfexit;
- boolean *pffound;
- size_t *pcneed;
-{
- boolean fbadhdr;
-
- if (pfexit != NULL)
- *pfexit = FALSE;
- if (pffound != NULL)
- *pffound = FALSE;
-
- fbadhdr = FALSE;
-
- while (iPrecstart != iPrecend)
- {
- char ab[CHDRLEN];
- int cfirst, csecond;
- char *zfirst, *zsecond;
- int i;
- int iget;
- int ttype;
- int iseq;
- int csize;
- int iack;
-
- /* If we're closing the connection, ignore any data remaining in
- the input buffer. */
- if (fIclosing)
- {
- if (pfexit != NULL)
- *pfexit = TRUE;
- if (pcneed != NULL)
- *pcneed = 0;
- return TRUE;
- }
-
- /* Look for the IINTRO character. */
- if (abPrecbuf[iPrecstart] != IINTRO)
- {
- char *zintro;
- int cintro;
-
- cintro = iPrecend - iPrecstart;
- if (cintro < 0)
- cintro = CRECBUFLEN - iPrecstart;
-
- zintro = memchr (abPrecbuf + iPrecstart, IINTRO, (size_t) cintro);
-
- if (zintro == NULL)
- {
- iPrecstart = (iPrecstart + cintro) % CRECBUFLEN;
- continue;
- }
-
- /* We don't need % CRECBUFLEN here because zintro - (abPrecbuf
- + iPrecstart) < cintro <= CRECBUFLEN - iPrecstart. */
- iPrecstart += zintro - (abPrecbuf + iPrecstart);
- }
-
- /* Get the header into ab. */
- for (i = 0, iget = iPrecstart;
- i < CHDRLEN && iget != iPrecend;
- i++, iget = (iget + 1) % CRECBUFLEN)
- ab[i] = abPrecbuf[iget];
-
- if (i < CHDRLEN)
- {
- if (pcneed != NULL)
- *pcneed = CHDRLEN - i;
- return TRUE;
- }
-
- if ((ab[IHDR_CHECK] & 0xff) != IHDRCHECK_VAL (ab)
- || (FHDRCON_GETCALLER (ab[IHDR_CONTENTS1], ab[IHDR_CONTENTS2])
- ? qdaemon->fcaller : ! qdaemon->fcaller))
- {
- /* We only report a single bad header message per call, to
- avoid generating many errors if we get many INTRO bytes
- in a row. */
- if (! fbadhdr)
- {
- DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fiprocess_data: Bad header");
-
- ++cIbad_hdr;
- if (! ficheck_errors (qdaemon))
- return FALSE;
-
- fbadhdr = TRUE;
- }
-
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN;
- continue;
- }
-
- zfirst = zsecond = NULL;
- cfirst = csecond = 0;
-
- ttype = THDRCON_GETTYPE (ab[IHDR_CONTENTS1], ab[IHDR_CONTENTS2]);
- if (ttype == DATA || ttype == SPOS || ttype == CLOSE)
- iseq = IHDRWIN_GETSEQ (ab[IHDR_LOCAL]);
- else
- iseq = -1;
- csize = CHDRCON_GETBYTES (ab[IHDR_CONTENTS1], ab[IHDR_CONTENTS2]);
-
- if (iseq != -1)
- {
- /* Make sure this packet is in our receive window. The last
- packet we have acked is iIlocal_ack. */
- if (iIrequest_winsize > 0
- && CSEQDIFF (iseq, iIlocal_ack) > iIrequest_winsize)
- {
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fiprocess_data: Out of order packet %d (ack %d)",
- iseq, iIlocal_ack);
-
- ++cIbad_order;
- if (! ficheck_errors (qdaemon))
- return FALSE;
-
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN;
-
- continue;
- }
- }
-
- if (csize > 0)
- {
- int cinbuf;
- char abcksum[CCKSUMLEN];
- unsigned long ickdata;
-
- cinbuf = iPrecend - iPrecstart;
- if (cinbuf < 0)
- cinbuf += CRECBUFLEN;
- if (cinbuf < CHDRLEN + csize + CCKSUMLEN)
- {
- if (pcneed != NULL)
- *pcneed = CHDRLEN + csize + CCKSUMLEN - cinbuf;
- return TRUE;
- }
-
- if (iPrecend > iPrecstart)
- {
- cfirst = csize;
- zfirst = abPrecbuf + iPrecstart + CHDRLEN;
- }
- else
- {
- cfirst = CRECBUFLEN - (iPrecstart + CHDRLEN);
- if (cfirst <= 0)
- {
- /* Here cfirst is non-positive, so subtracting from
- abPrecbuf will actually skip the appropriate number
- of bytes at the start of abPrecbuf. */
- zfirst = abPrecbuf - cfirst;
- cfirst = csize;
- }
- else
- {
- if (cfirst >= csize)
- cfirst = csize;
- else
- {
- zsecond = abPrecbuf;
- csecond = csize - cfirst;
- }
- zfirst = abPrecbuf + iPrecstart + CHDRLEN;
- }
- }
-
- /* Get the checksum into abcksum. */
- for (i = 0, iget = (iPrecstart + CHDRLEN + csize) % CRECBUFLEN;
- i < CCKSUMLEN;
- i++, iget = (iget + 1) % CRECBUFLEN)
- abcksum[i] = abPrecbuf[iget];
-
- ickdata = icrc (zfirst, (size_t) cfirst, ICRCINIT);
- if (csecond > 0)
- ickdata = icrc (zsecond, (size_t) csecond, ickdata);
-
- if (ICKSUM_GET (abcksum) != ickdata)
- {
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fiprocess_data: Bad checksum; data %lu, frame %lu",
- ickdata, ICKSUM_GET (abcksum));
-
- ++cIbad_cksum;
- if (! ficheck_errors (qdaemon))
- return FALSE;
-
- /* If this sequence number is in our receive window,
- send a NAK. iIrecseq is the last sequence number we
- have succesfully received. */
- if (iseq != -1
- && iseq != iIrecseq
- && (iIrequest_winsize <= 0
- || CSEQDIFF (iseq, iIrecseq) <= iIrequest_winsize)
- && azIrecbuffers[iseq] == NULL)
- {
- if (! finak (qdaemon, iseq))
- return FALSE;
- }
-
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN;
- continue;
- }
- }
-
- /* Here we know that this is a valid packet, so we can adjust
- iPrecstart accordingly. */
- if (csize == 0)
- iPrecstart = (iPrecstart + CHDRLEN) % CRECBUFLEN;
- else
- {
- iPrecstart = ((iPrecstart + CHDRLEN + csize + CCKSUMLEN)
- % CRECBUFLEN);
- ++cIreceived_packets;
- }
-
- /* Get the ack from the packet, if appropriate. iIsendseq is
- the next sequence number we are going to send, and
- iIremote_ack is the last sequence number acknowledged by the
- remote system. */
- iack = IHDRWIN_GETSEQ (ab[IHDR_REMOTE]);
- if (iIremote_winsize > 0
- && iack != iIsendseq
- && CSEQDIFF (iack, iIremote_ack) <= iIremote_winsize
- && CSEQDIFF (iIsendseq, iack) <= iIremote_winsize)
- {
- /* Call uwindow_acked each time packet 0 is acked. */
- if (iack < iIremote_ack)
- uwindow_acked (qdaemon, FALSE);
- iIremote_ack = iack;
- }
-
- if (iseq != -1)
- {
- /* If we already sent a NAK for this packet, and we have not
- seen the previous packet, then forget that we sent a NAK
- for this and any preceding packets. This is to handle
- the following sequence:
- receive packet 0
- packets 1 and 2 lost
- receive packet 3
- send NAK 1
- send NAK 2
- packet 1 lost
- receive packet 2
- At this point we want to send NAK 1. */
- if (afInaked[iseq]
- && azIrecbuffers[IPREVSEQ (iseq)] == NULL)
- {
- for (i = INEXTSEQ (iIrecseq);
- i != iseq;
- i = INEXTSEQ (i))
- afInaked[i] = FALSE;
- afInaked[iseq] = FALSE;
- }
-
- /* If we haven't handled all previous packets, we must save
- off this packet and deal with it later. */
- if (iseq != INEXTSEQ (iIrecseq))
- {
- if (iseq == iIrecseq
- || (iIrequest_winsize > 0
- && CSEQDIFF (iseq, iIrecseq) > iIrequest_winsize))
- {
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fiprocess_data: Ignoring out of order packet %d (recseq %d)",
- iseq, iIrecseq);
- continue;
- }
- else
- {
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fiprocess_data: Saving unexpected packet %d (recseq %d)",
- iseq, iIrecseq);
-
- if (azIrecbuffers[iseq] == NULL)
- {
- azIrecbuffers[iseq] = zbufalc ((size_t) (CHDRLEN
- + csize));
- memcpy (azIrecbuffers[iseq], ab, CHDRLEN);
- if (csize > 0)
- {
- memcpy (azIrecbuffers[iseq] + CHDRLEN, zfirst,
- (size_t) cfirst);
- if (csecond > 0)
- memcpy (azIrecbuffers[iseq] + CHDRLEN + cfirst,
- zsecond, (size_t) csecond);
- }
- }
- }
-
- /* Send NAK's for each packet between the last one we
- received and this one, avoiding any packets for which
- we've already sent NAK's or which we've already
- received. */
- for (i = INEXTSEQ (iIrecseq);
- i != iseq;
- i = INEXTSEQ (i))
- {
- if (! afInaked[i]
- && azIrecbuffers[i] == NULL)
- {
- if (! finak (qdaemon, i))
- return FALSE;
- }
- }
-
- continue;
- }
-
- iIrecseq = iseq;
- }
-
- if (pffound != NULL)
- *pffound = TRUE;
-
- if (! fiprocess_packet (qdaemon, ab, zfirst, cfirst, zsecond, csecond,
- pfexit))
- return FALSE;
-
- if (iseq != -1)
- {
- int inext;
-
- /* If we've already received the next packet(s), process
- them. */
- inext = INEXTSEQ (iIrecseq);
- while (azIrecbuffers[inext] != NULL)
- {
- char *z;
- int c;
-
- z = azIrecbuffers[inext];
- c = CHDRCON_GETBYTES (z[IHDR_CONTENTS1], z[IHDR_CONTENTS2]);
- iIrecseq = inext;
- if (! fiprocess_packet (qdaemon, z, z + CHDRLEN, c,
- (char *) NULL, 0, pfexit))
- return FALSE;
- ubuffree (azIrecbuffers[inext]);
- azIrecbuffers[inext] = NULL;
- inext = INEXTSEQ (inext);
- }
- }
-
- /* If we have received half of our window size or more since the
- last ACK, send one now. Sending an ACK for half the window
- at a time should significantly cut the acknowledgement
- traffic when only one side is sending. We should normally
- not have to send an ACK if we have data to send, since each
- packet sent will ACK the most recently received packet.
- However, it can happen if we receive a burst of short
- packets, such as a set of command acknowledgements. */
- if (iIrequest_winsize > 0
- && CSEQDIFF (iIrecseq, iIlocal_ack) >= cIack_frequency)
- {
- char aback[CHDRLEN];
-
- aback[IHDR_INTRO] = IINTRO;
- aback[IHDR_LOCAL] = IHDRWIN_SET (0, 0);
- aback[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0);
- iIlocal_ack = iIrecseq;
- aback[IHDR_CONTENTS1] = IHDRCON_SET1 (ACK, qdaemon->fcaller, 0);
- aback[IHDR_CONTENTS2] = IHDRCON_SET2 (ACK, qdaemon->fcaller, 0);
- aback[IHDR_CHECK] = IHDRCHECK_VAL (aback);
-
- DEBUG_MESSAGE1 (DEBUG_PROTO, "fiprocess_data: Sending ACK %d",
- iIrecseq);
-
- if (! (*pfIsend) (qdaemon->qconn, aback, CHDRLEN, TRUE))
- return FALSE;
- }
- }
-
- if (pcneed != NULL)
- *pcneed = CHDRLEN;
-
- return TRUE;
-}
-
-/* Process a single packet. */
-
-static boolean
-fiprocess_packet (qdaemon, zhdr, zfirst, cfirst, zsecond, csecond, pfexit)
- struct sdaemon *qdaemon;
- const char *zhdr;
- const char *zfirst;
- int cfirst;
- const char *zsecond;
- int csecond;
- boolean *pfexit;
-{
- int ttype;
-
- ttype = THDRCON_GETTYPE (zhdr[IHDR_CONTENTS1], zhdr[IHDR_CONTENTS2]);
- switch (ttype)
- {
- case DATA:
- {
- int iseq;
- boolean fret;
-
- iseq = IHDRWIN_GETSEQ (zhdr[IHDR_LOCAL]);
- DEBUG_MESSAGE4 (DEBUG_PROTO,
- "fiprocess_packet: Got DATA packet %d size %d local %d remote %d",
- iseq, cfirst + csecond,
- IHDRWIN_GETCHAN (zhdr[IHDR_REMOTE]),
- IHDRWIN_GETCHAN (zhdr[IHDR_LOCAL]));
- fret = fgot_data (qdaemon, zfirst, (size_t) cfirst,
- zsecond, (size_t) csecond,
- IHDRWIN_GETCHAN (zhdr[IHDR_REMOTE]),
- IHDRWIN_GETCHAN (zhdr[IHDR_LOCAL]),
- iIrecpos,
- INEXTSEQ (iIremote_ack) == iIsendseq,
- pfexit);
- iIrecpos += cfirst + csecond;
- return fret;
- }
-
- case SYNC:
- {
- int ipack, iwin, cchans;
-
- /* We accept a SYNC packet to adjust the packet and window
- sizes at any time. */
- if (cfirst + csecond < 3)
- {
- ulog (LOG_ERROR, "Bad SYNC packet");
- return FALSE;
- }
- ipack = (zfirst[0] & 0xff) << 8;
- if (cfirst > 1)
- ipack |= zfirst[1] & 0xff;
- else
- ipack |= zsecond[0];
- if (cfirst > 2)
- iwin = zfirst[2];
- else
- iwin = zsecond[2 - cfirst];
-
- /* The fourth byte in a SYNC packet is the number of channels
- to use. This is optional. Switching the number of
- channels in the middle of a conversation may cause
- problems. */
- if (cfirst + csecond <= 3)
- cchans = 0;
- else
- {
- if (cfirst > 3)
- cchans = zfirst[3];
- else
- cchans = zsecond[3 - cfirst];
- if (cchans > 0 && cchans < 8)
- qdaemon->cchans = cchans;
- }
-
- DEBUG_MESSAGE3 (DEBUG_PROTO,
- "fiprocess_packet: Got SYNC packsize %d winsize %d channels %d",
- ipack, iwin, cchans);
-
- if (iIforced_remote_packsize == 0
- && (iIalc_packsize == 0
- || ipack <= iIalc_packsize))
- iIremote_packsize = ipack;
- iIremote_winsize = iwin;
-
- /* We increment a static variable to tell the initialization
- code that a SYNC was received, and we set *pfexit to TRUE
- to get out to the initialization code (this will do no harm
- if we are called from elsewhere). */
- ++cIsyncs;
- *pfexit = TRUE;
- return TRUE;
- }
-
- case ACK:
- /* There is nothing to do here, since the ack was already
- handled in fiprocess_data. */
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "fiprocess_packet: Got ACK %d",
- IHDRWIN_GETSEQ (zhdr[IHDR_REMOTE]));
- return TRUE;
-
- case NAK:
- /* We must resend the requested packet. */
- {
- int iseq;
- char *zsend;
- size_t clen;
-
- ++cIremote_rejects;
- if (! ficheck_errors (qdaemon))
- return FALSE;
-
- iseq = IHDRWIN_GETSEQ (zhdr[IHDR_LOCAL]);
-
- /* If the remote side times out while waiting for a packet, it
- will send a NAK for the next packet it wants to see. If we
- have not sent that packet yet, and we have no
- unacknowledged data, it implies that the remote side has a
- window full of data to send, which implies that our ACK has
- been lost. Therefore, we send an ACK. */
- if (iseq == iIsendseq &&
- INEXTSEQ (iIremote_ack) == iIsendseq)
- {
- char aback[CHDRLEN];
-
- aback[IHDR_INTRO] = IINTRO;
- aback[IHDR_LOCAL] = IHDRWIN_SET (0, 0);
- aback[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0);
- iIlocal_ack = iIrecseq;
- aback[IHDR_CONTENTS1] = IHDRCON_SET1 (ACK, qdaemon->fcaller, 0);
- aback[IHDR_CONTENTS2] = IHDRCON_SET2 (ACK, qdaemon->fcaller, 0);
- aback[IHDR_CHECK] = IHDRCHECK_VAL (aback);
-
- DEBUG_MESSAGE1 (DEBUG_PROTO, "fiprocess_packet: Sending ACK %d",
- iIrecseq);
-
- return (*pfIsend) (qdaemon->qconn, aback, CHDRLEN, TRUE);
- }
- else
- {
- if (iseq == iIsendseq
- || (iIremote_winsize > 0
- && (CSEQDIFF (iseq, iIremote_ack) > iIremote_winsize
- || CSEQDIFF (iIsendseq, iseq) > iIremote_winsize)))
- {
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fiprocess_packet: Ignoring out of order NAK %d (sendseq %d)",
- iseq, iIsendseq);
- return TRUE;
- }
-
- DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fiprocess_packet: Got NAK %d; resending packet",
- iseq);
-
- /* Update the received sequence number. */
- zsend = azIsendbuffers[iseq] + CHDROFFSET;
- if (IHDRWIN_GETSEQ (zsend[IHDR_REMOTE]) != iIrecseq)
- {
- int iremote;
-
- iremote = IHDRWIN_GETCHAN (zsend[IHDR_REMOTE]);
- zsend[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, iremote);
- zsend[IHDR_CHECK] = IHDRCHECK_VAL (zsend);
- iIlocal_ack = iIrecseq;
- }
-
- ++cIresent_packets;
-
- clen = CHDRCON_GETBYTES (zsend[IHDR_CONTENTS1],
- zsend[IHDR_CONTENTS2]);
-
- return (*pfIsend) (qdaemon->qconn, zsend,
- CHDRLEN + clen + (clen > 0 ? CCKSUMLEN : 0),
- TRUE);
- }
- }
-
- case SPOS:
- /* Set the file position. */
- {
- char abpos[CCKSUMLEN];
- const char *zpos;
-
- if (cfirst >= CCKSUMLEN)
- zpos = zfirst;
- else
- {
- memcpy (abpos, zfirst, (size_t) cfirst);
- memcpy (abpos + cfirst, zsecond, (size_t) (CCKSUMLEN - cfirst));
- zpos = abpos;
- }
- iIrecpos = (long) ICKSUM_GET (zpos);
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "fiprocess_packet: Got SPOS %ld", iIrecpos);
- return TRUE;
- }
-
- case CLOSE:
- {
- boolean fexpected;
-
- fexpected = ! fLog_sighup || fIclosing;
- if (! fexpected)
- ulog (LOG_ERROR, "Received unexpected CLOSE packet");
- else
- DEBUG_MESSAGE0 (DEBUG_PROTO, "fiprocess_packet: Got CLOSE packet");
-
- fIclosing = TRUE;
- *pfexit = TRUE;
- return fexpected;
- }
-
- default:
- /* Just ignore unrecognized packet types, for future protocol
- enhancements. */
- DEBUG_MESSAGE1 (DEBUG_PROTO, "fiprocess_packet: Got packet type %d",
- ttype);
- return TRUE;
- }
- /*NOTREACHED*/
-}
diff --git a/gnu/libexec/uucp/uucico/protj.c b/gnu/libexec/uucp/uucico/protj.c
deleted file mode 100644
index 962f378..0000000
--- a/gnu/libexec/uucp/uucico/protj.c
+++ /dev/null
@@ -1,672 +0,0 @@
-/* protj.c
- The 'j' protocol.
-
- Copyright (C) 1992, 1994 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char protj_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "trans.h"
-#include "system.h"
-#include "prot.h"
-
-/* The 'j' protocol.
-
- The 'j' protocol is a wrapper around the 'i' protocol, which avoids
- the use of certain characters, such as XON and XOFF.
-
- Each 'j' protocol packet begins with a '^' character, followed by a
- two byte encoded size giving the total number of bytes in the
- packet. The first byte is HIGH, the second byte is LOW, and the
- number of bytes is (HIGH - 32) * 64 + (LOW - 32), where 32 <= HIGH
- < 127 and 32 <= LOW < 96 (i.e., HIGH and LOW are printable ASCII
- characters). This is followed by a '=' character. The next two
- bytes are the number of data bytes in the packet, using the same
- encoding. This is followed by a '@' character, and then that
- number of data bytes. The remaining bytes in the packet are
- indices of bytes which must be transformed, followed by a trailing
- '~' character. The indices are encoded in the following overly
- complex format.
-
- Each byte index is two bytes long. The first byte in the index is
- INDEX-HIGH and the second is INDEX-LOW. If 32 <= INDEX-HIGH < 126,
- the byte index refers to the byte at position (INDEX-HIGH - 32) *
- 32 + INDEX-LOW % 32 in the actual data, where 32 <= INDEX-LOW <
- 127. If 32 <= INDEX-LOW < 64, then 128 must be added to the
- indexed byte. If 64 <= INDEX-LOW < 96, then the indexed byte must
- be exclusive or'red with 32. If 96 <= INDEX-LOW < 127, both
- operations must be performed. If INDEX-HIGH == 126, then the byte
- index refers to the byte at position (INDEX-LOW - 32) * 32 + 31,
- where 32 <= INDEX-LOW < 126. 128 must be added to the byte, and it
- must be exclusive or'red with 32. This unfortunately requires a
- special test (when encoding INDEX-LOW must be checked for 127; when
- decoding INDEX-HIGH must be checked for 126). It does, however,
- permit the byte indices field to consist exclusively of printable
- ASCII characters.
-
- The maximum value for a byte index is (125 - 32) * 32 + 31 == 3007,
- so the is the maximum number of data bytes permitted. Since it is
- convenient to have each 'j' protocol packet correspond to each 'i'
- protocol packet, we restrict the 'i' protocol accordingly.
-
- Note that this encoding method assumes that we can send all
- printable ASCII characters. */
-
-/* The first byte of each packet. I just picked these values
- randomly, trying to get characters that were perhaps slightly less
- likely to appear in normal text. */
-#define FIRST '\136'
-
-/* The fourth byte of each packet. */
-#define FOURTH '\075'
-
-/* The seventh byte of each packet. */
-#define SEVENTH '\100'
-
-/* The trailing byte of each packet. */
-#define TRAILER '\176'
-
-/* The length of the header. */
-#define CHDRLEN (7)
-
-/* Get a number of bytes encoded in a two byte length at the start of
- a packet. */
-#define CGETLENGTH(b1, b2) (((b1) - 32) * 64 + ((b2) - 32))
-
-/* Set the high and low bytes of a two byte length at the start of a
- packet. */
-#define ISETLENGTH_FIRST(i) ((i) / 64 + 32)
-#define ISETLENGTH_SECOND(i) ((i) % 64 + 32)
-
-/* The maximum packet size we support, as determined by the byte
- indices. */
-#define IMAXPACKSIZE ((125 - 32) * 32 + 31)
-
-/* Amount to offset the bytes in the byte index by. */
-#define INDEX_OFFSET (32)
-
-/* Maximum value of INDEX-LOW, before offsetting. */
-#define INDEX_MAX_LOW (32)
-
-/* Maximum value of INDEX-HIGH, before offsetting. */
-#define INDEX_MAX_HIGH (94)
-
-/* The set of characters to avoid. */
-static char *zJavoid;
-
-/* The number of characters to avoid. */
-static size_t cJavoid;
-
-/* A buffer used when sending data. */
-static char *zJbuf;
-
-/* The end of the undecoded data in abPrecbuf. */
-static int iJrecend;
-
-/* Local functions. */
-static boolean fjsend_data P((struct sconnection *qconn, const char *zsend,
- size_t csend, boolean fdoread));
-static boolean fjreceive_data P((struct sconnection *qconn, size_t cneed,
- size_t *pcrec, int ctimeout,
- boolean freport));
-static boolean fjprocess_data P((size_t *pcneed));
-
-/* Start the protocol. We first send over the list of characters to
- avoid as an escape sequence, starting with FIRST and ending with
- TRAILER. There is no error checking done on this string. */
-
-boolean
-fjstart (qdaemon, pzlog)
- struct sdaemon *qdaemon;
- char **pzlog;
-{
- size_t clen;
- char *zsend;
- int b;
- size_t cbuf, cgot;
- char *zbuf;
- int i;
-
- /* Send the characters we want to avoid to the other side. */
- clen = strlen (zJavoid_parameter);
- zsend = zbufalc (clen + 3);
- zsend[0] = FIRST;
- memcpy (zsend + 1, zJavoid_parameter, clen);
- zsend[clen + 1] = TRAILER;
- zsend[clen + 2] = '\0';
- if (! fsend_data (qdaemon->qconn, zsend, clen + 2, TRUE))
- {
- ubuffree (zsend);
- return FALSE;
- }
- ubuffree (zsend);
-
- /* Read the characters the other side wants to avoid. */
- while ((b = breceive_char (qdaemon->qconn, cIsync_timeout, TRUE))
- != FIRST)
- {
- if (b < 0)
- {
- if (b == -1)
- ulog (LOG_ERROR, "Timed out in 'j' protocol startup");
- return FALSE;
- }
- }
-
- cbuf = 20;
- zbuf = zbufalc (cbuf);
- cgot = 0;
- while ((b = breceive_char (qdaemon->qconn, cIsync_timeout, TRUE))
- != TRAILER)
- {
- if (b < 0)
- {
- ubuffree (zbuf);
- if (b == -1)
- ulog (LOG_ERROR, "Timed out in 'j' protocol startup");
- return FALSE;
- }
- if (cgot + 1 >= cbuf)
- {
- char *znew;
-
- cbuf += 20;
- znew = zbufalc (cbuf);
- memcpy (znew, zbuf, cgot);
- ubuffree (zbuf);
- zbuf = znew;
- }
- zbuf[cgot] = b;
- ++cgot;
- }
- zbuf[cgot] = '\0';
-
- /* Merge the local and remote avoid bytes into one list, translated
- into bytes. */
- cgot = cescape (zbuf);
-
- clen = strlen (zJavoid_parameter);
- zJavoid = zbufalc (clen + cgot + 1);
- memcpy (zJavoid, zJavoid_parameter, clen + 1);
- cJavoid = cescape (zJavoid);
-
- for (i = 0; i < cgot; i++)
- {
- if (memchr (zJavoid, zbuf[i], cJavoid) == NULL)
- {
- zJavoid[cJavoid] = zbuf[i];
- ++cJavoid;
- }
- }
-
- ubuffree (zbuf);
-
- /* We can't avoid ASCII printable characters, since the encoding
- method assumes that they can always be sent. If it ever turns
- out to be important, a different encoding method could be used,
- perhaps keyed by a different FIRST character. */
- if (cJavoid == 0)
- {
- ulog (LOG_ERROR, "No characters to avoid in 'j' protocol");
- return FALSE;
- }
- for (i = 0; i < cJavoid; i++)
- {
- if (zJavoid[i] >= 32 && zJavoid[i] <= 126)
- {
- ulog (LOG_ERROR, "'j' protocol can't avoid character '\\%03o'",
- zJavoid[i]);
- return FALSE;
- }
- }
-
- /* If we are avoiding XON and XOFF, use XON/XOFF handshaking. */
- if (memchr (zJavoid, '\021', cJavoid) != NULL
- && memchr (zJavoid, '\023', cJavoid) != NULL)
- {
- if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE,
- STRIPSETTING_EIGHTBITS, XONXOFF_ON))
- return FALSE;
- }
-
- /* Let the port settle. */
- usysdep_sleep (2);
-
- /* Allocate a buffer we use when sending data. We will probably
- never actually need one this big; if this code is ported to a
- computer with small amounts of memory, this should be changed to
- increase the buffer size as needed. */
- zJbuf = zbufalc (CHDRLEN + IMAXPACKSIZE * 3 + 1);
- zJbuf[0] = FIRST;
- zJbuf[3] = FOURTH;
- zJbuf[6] = SEVENTH;
-
- /* iJrecend is the end of the undecoded data, and iPrecend is the
- end of the decoded data. At this point there is no decoded data,
- and we must initialize the variables accordingly. */
- iJrecend = iPrecend;
- iPrecend = iPrecstart;
-
- /* Now do the 'i' protocol startup. */
- return fijstart (qdaemon, pzlog, IMAXPACKSIZE, fjsend_data,
- fjreceive_data);
-}
-
-/* Shut down the protocol. */
-
-boolean
-fjshutdown (qdaemon)
- struct sdaemon *qdaemon;
-{
- boolean fret;
-
- fret = fishutdown (qdaemon);
- ubuffree (zJavoid);
- ubuffree (zJbuf);
- return fret;
-}
-
-/* Encode a packet of data and send it. This copies the data, which
- is a waste of time, but calling fsend_data three times (for the
- header, the body, and the trailer) would waste even more time. */
-
-static boolean
-fjsend_data (qconn, zsend, csend, fdoread)
- struct sconnection *qconn;
- const char *zsend;
- size_t csend;
- boolean fdoread;
-{
- char *zput, *zindex;
- const char *zfrom, *zend;
- char bfirst, bsecond;
- int iprecendhold;
- boolean fret;
-
- zput = zJbuf + CHDRLEN;
- zindex = zput + csend;
- zfrom = zsend;
- zend = zsend + csend;
-
- /* Optimize for the common case of avoiding two characters. */
- bfirst = zJavoid[0];
- if (cJavoid <= 1)
- bsecond = bfirst;
- else
- bsecond = zJavoid[1];
- while (zfrom < zend)
- {
- char b;
- boolean f128, f32;
- int i, ihigh, ilow;
-
- b = *zfrom++;
- if (b != bfirst && b != bsecond)
- {
- int ca;
- char *za;
-
- if (cJavoid <= 2)
- {
- *zput++ = b;
- continue;
- }
-
- ca = cJavoid - 2;
- za = zJavoid + 2;
- while (ca-- != 0)
- if (*za++ == b)
- break;
-
- if (ca < 0)
- {
- *zput++ = b;
- continue;
- }
- }
-
- if ((b & 0x80) == 0)
- f128 = FALSE;
- else
- {
- b &=~ 0x80;
- f128 = TRUE;
- }
- if (b >= 32 && b != 127)
- f32 = FALSE;
- else
- {
- b ^= 0x20;
- f32 = TRUE;
- }
-
- /* We must now put the byte index into the buffer. The byte
- index is encoded similarly to the length of the actual data,
- but the byte index also encodes the operations that must be
- performed on the byte. The first byte in the index is the
- most significant bits. If we only had to subtract 128 from
- the byte, we use the second byte directly. If we had to xor
- the byte with 32, we add 32 to the second byte index. If we
- had to perform both operations, we add 64 to the second byte
- index. However, if we had to perform both operations, and
- the second byte index was 31, then after adding 64 and
- offsetting by 32 we would come up with 127, which we are not
- permitted to use. Therefore, in this special case we set the
- first byte of the index to 126 and put the original first
- byte into the second byte position instead. This is why we
- could not permit the high byte of the length of the actual
- data to be 126. We can get away with the switch because both
- the value of the second byte index (31) and the operations to
- perform (both) are known. */
- i = zput - (zJbuf + CHDRLEN);
- ihigh = i / INDEX_MAX_LOW;
- ilow = i % INDEX_MAX_LOW;
-
- if (f128 && ! f32)
- ;
- else if (f32 && ! f128)
- ilow += INDEX_MAX_LOW;
- else
- {
- /* Both operations had to be performed. */
- if (ilow != INDEX_MAX_LOW - 1)
- ilow += 2 * INDEX_MAX_LOW;
- else
- {
- ilow = ihigh;
- ihigh = INDEX_MAX_HIGH;
- }
- }
-
- *zindex++ = ihigh + INDEX_OFFSET;
- *zindex++ = ilow + INDEX_OFFSET;
- *zput++ = b;
- }
-
- *zindex++ = TRAILER;
-
- /* Set the lengths into the buffer. zJbuf[0,3,6] were set when
- zJbuf was allocated, and are never changed thereafter. */
- zJbuf[1] = ISETLENGTH_FIRST (zindex - zJbuf);
- zJbuf[2] = ISETLENGTH_SECOND (zindex - zJbuf);
- zJbuf[4] = ISETLENGTH_FIRST (csend);
- zJbuf[5] = ISETLENGTH_SECOND (csend);
-
- /* Send the data over the line. We must preserve iPrecend as
- discussed in fjreceive_data. */
- iprecendhold = iPrecend;
- iPrecend = iJrecend;
- fret = fsend_data (qconn, zJbuf, (size_t) (zindex - zJbuf), fdoread);
- iJrecend = iPrecend;
- iPrecend = iprecendhold;
-
- /* Process any bytes that may have been placed in abPrecbuf. */
- if (fret && iPrecend != iJrecend)
- {
- if (! fjprocess_data ((size_t *) NULL))
- return FALSE;
- }
-
- return fret;
-}
-
-/* Receive and decode data. This is called by fiwait_for_packet. We
- need to be able to return decoded data between iPrecstart and
- iPrecend, while not losing any undecoded partial packets we may
- have read. We use iJrecend as a pointer to the end of the
- undecoded data, and set iPrecend for the decoded data. iPrecend
- points to the start of the undecoded data. */
-
-static boolean
-fjreceive_data (qconn, cineed, pcrec, ctimeout, freport)
- struct sconnection *qconn;
- size_t cineed;
- size_t *pcrec;
- int ctimeout;
- boolean freport;
-{
- int iprecendstart;
- size_t cjneed;
- size_t crec;
- int cnew;
-
- iprecendstart = iPrecend;
-
- /* Figure out how many bytes we need to decode the next packet. */
- if (! fjprocess_data (&cjneed))
- return FALSE;
-
- /* As we long as we read some data but don't have enough to decode a
- packet, we try to read some more. We decrease the timeout each
- time so that we will not wait forever if the connection starts
- dribbling data. */
- do
- {
- int iprecendhold;
- size_t cneed;
-
- if (cjneed > cineed)
- cneed = cjneed;
- else
- cneed = cineed;
-
- /* We are setting iPrecend to the end of the decoded data for
- the 'i' protocol. When we do the actual read, we have to set
- it to the end of the undecoded data so that any undecoded
- data we have received is not overwritten. */
- iprecendhold = iPrecend;
- iPrecend = iJrecend;
- if (! freceive_data (qconn, cneed, &crec, ctimeout, freport))
- return FALSE;
- iJrecend = iPrecend;
- iPrecend = iprecendhold;
-
- /* Process any data we have received. This will set iPrecend to
- the end of the new decoded data. */
- if (! fjprocess_data (&cjneed))
- return FALSE;
-
- cnew = iPrecend - iprecendstart;
- if (cnew < 0)
- cnew += CRECBUFLEN;
-
- if (cnew > cineed)
- cineed = 0;
- else
- cineed -= cnew;
-
- --ctimeout;
- }
- while (cnew == 0 && crec > 0 && ctimeout > 0);
-
- DEBUG_MESSAGE1 (DEBUG_PROTO, "fjreceive_data: Got %d decoded bytes",
- cnew);
-
- *pcrec = cnew;
- return TRUE;
-}
-
-/* Decode the data in the buffer, optionally returning the number of
- bytes needed to complete the next packet. */
-
-static boolean
-fjprocess_data (pcneed)
- size_t *pcneed;
-{
- int istart;
-
- istart = iPrecend;
- while (istart != iJrecend)
- {
- int i, iget;
- char ab[CHDRLEN];
- int cpacket, cdata, chave;
- int iindex, iendindex;
-
- /* Find the next occurrence of FIRST. If we have to skip some
- garbage bytes to get to it, zero them out (so they don't
- confuse the 'i' protocol) and advance iPrecend. This will
- save us from looking at them again. */
- if (abPrecbuf[istart] != FIRST)
- {
- int cintro;
- char *zintro;
- size_t cskipped;
-
- cintro = iJrecend - istart;
- if (cintro < 0)
- cintro = CRECBUFLEN - istart;
-
- zintro = memchr (abPrecbuf + istart, FIRST, (size_t) cintro);
- if (zintro == NULL)
- {
- bzero (abPrecbuf + istart, (size_t) cintro);
- istart = (istart + cintro) % CRECBUFLEN;
- iPrecend = istart;
- continue;
- }
-
- cskipped = zintro - (abPrecbuf + istart);
- bzero (abPrecbuf + istart, cskipped);
- istart += cskipped;
- iPrecend = istart;
- }
-
- for (i = 0, iget = istart;
- i < CHDRLEN && iget != iJrecend;
- ++i, iget = (iget + 1) % CRECBUFLEN)
- ab[i] = abPrecbuf[iget];
-
- if (i < CHDRLEN)
- {
- if (pcneed != NULL)
- *pcneed = CHDRLEN - i;
- return TRUE;
- }
-
- cpacket = CGETLENGTH (ab[1], ab[2]);
- cdata = CGETLENGTH (ab[4], ab[5]);
-
- /* Make sure the header has the right magic characters, that the
- data is not larger than the packet, and that we have an even
- number of byte index characters. */
- if (ab[3] != FOURTH
- || ab[6] != SEVENTH
- || cdata > cpacket - CHDRLEN - 1
- || (cpacket - cdata - CHDRLEN - 1) % 2 == 1)
- {
- istart = (istart + 1) % CRECBUFLEN;
- continue;
- }
-
- chave = iJrecend - istart;
- if (chave < 0)
- chave += CRECBUFLEN;
-
- if (chave < cpacket)
- {
- if (pcneed != NULL)
- *pcneed = cpacket - chave;
- return TRUE;
- }
-
- /* Figure out where the byte indices start and end. */
- iindex = (istart + CHDRLEN + cdata) % CRECBUFLEN;
- iendindex = (istart + cpacket - 1) % CRECBUFLEN;
-
- /* Make sure the magic trailer character is there. */
- if (abPrecbuf[iendindex] != TRAILER)
- {
- istart = (istart + 1) % CRECBUFLEN;
- continue;
- }
-
- /* We have a packet to decode. The decoding process is simpler
- than the encoding process, since all we have to do is examine
- the byte indices. We zero out the byte indices as we go, so
- that they will not confuse the 'i' protocol. */
- while (iindex != iendindex)
- {
- int ihigh, ilow;
- boolean f32, f128;
- int iset;
-
- ihigh = abPrecbuf[iindex] - INDEX_OFFSET;
- abPrecbuf[iindex] = 0;
- iindex = (iindex + 1) % CRECBUFLEN;
- ilow = abPrecbuf[iindex] - INDEX_OFFSET;
- abPrecbuf[iindex] = 0;
- iindex = (iindex + 1) % CRECBUFLEN;
-
- /* Now we must undo the encoding, by adding 128 and xoring
- with 32 as appropriate. Which to do is encoded in the
- low byte, except that if the high byte is the special
- value 126, then the low byte is actually the high byte
- and both operations are performed. */
- f128 = TRUE;
- f32 = TRUE;
- if (ihigh == INDEX_MAX_HIGH)
- iset = ilow * INDEX_MAX_LOW + INDEX_MAX_LOW - 1;
- else
- {
- iset = ihigh * INDEX_MAX_LOW + ilow % INDEX_MAX_LOW;
- if (ilow < INDEX_MAX_LOW)
- f32 = FALSE;
- else if (ilow < 2 * INDEX_MAX_LOW)
- f128 = FALSE;
- }
-
- /* Now iset is the index from the start of the data to the
- byte to modify; adjust it to an index in abPrecbuf. */
- iset = (istart + CHDRLEN + iset) % CRECBUFLEN;
-
- if (f128)
- abPrecbuf[iset] |= 0x80;
- if (f32)
- abPrecbuf[iset] ^= 0x20;
- }
-
- /* Zero out the header and trailer to avoid confusing the 'i'
- protocol, and update iPrecend to the end of decoded data. */
- for (i = 0, iget = istart;
- i < CHDRLEN && iget != iJrecend;
- ++i, iget = (iget + 1) % CRECBUFLEN)
- abPrecbuf[iget] = 0;
- abPrecbuf[iendindex] = 0;
- iPrecend = (iendindex + 1) % CRECBUFLEN;
- istart = iPrecend;
- }
-
- if (pcneed != NULL)
- *pcneed = CHDRLEN + 1;
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/uucico/prott.c b/gnu/libexec/uucp/uucico/prott.c
deleted file mode 100644
index 703fd52..0000000
--- a/gnu/libexec/uucp/uucico/prott.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/* prott.c
- The 't' protocol.
-
- Copyright (C) 1991, 1992 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char prott_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "trans.h"
-#include "system.h"
-#include "prot.h"
-
-/* This implementation is based on code written by Rick Adams.
-
- This code implements the 't' protocol, which does no error checking
- whatsoever and thus requires an end-to-end verified eight bit
- communication line, such as is provided by TCP. Using it with a
- modem is unadvisable, since errors can occur between the modem and
- the computer. */
-
-/* The buffer size we use. */
-#define CTBUFSIZE (1024)
-
-/* The offset in the buffer to the data. */
-#define CTFRAMELEN (4)
-
-/* Commands are sent in multiples of this size. */
-#define CTPACKSIZE (512)
-
-/* A pointer to the buffer we will use. */
-static char *zTbuf;
-
-/* True if we are receiving a file. */
-static boolean fTfile;
-
-/* The timeout we use. */
-static int cTtimeout = 120;
-
-struct uuconf_cmdtab asTproto_params[] =
-{
- { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cTtimeout, NULL },
- { NULL, 0, NULL, NULL }
-};
-
-/* Local function. */
-
-static boolean ftprocess_data P((struct sdaemon *qdaemon, boolean *pfexit,
- size_t *pcneed));
-
-/* Start the protocol. */
-
-boolean
-ftstart (qdaemon, pzlog)
- struct sdaemon *qdaemon;
- char **pzlog;
-{
- *pzlog = NULL;
- if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE,
- STRIPSETTING_EIGHTBITS, XONXOFF_OFF))
- return FALSE;
- zTbuf = (char *) xmalloc (CTBUFSIZE + CTFRAMELEN);
- /* The first two bytes of the buffer are always zero. */
- zTbuf[0] = 0;
- zTbuf[1] = 0;
- fTfile = FALSE;
- usysdep_sleep (2);
- return TRUE;
-}
-
-/* Stop the protocol. */
-
-/*ARGSUSED*/
-boolean
-ftshutdown (qdaemon)
- struct sdaemon *qdaemon;
-{
- xfree ((pointer) zTbuf);
- zTbuf = NULL;
- cTtimeout = 120;
- return TRUE;
-}
-
-/* Send a command string. We send everything up to and including the
- null byte. The number of bytes we send must be a multiple of
- TPACKSIZE. */
-
-/*ARGSUSED*/
-boolean
-ftsendcmd (qdaemon, z, ilocal, iremote)
- struct sdaemon *qdaemon;
- const char *z;
- int ilocal;
- int iremote;
-{
- size_t clen, csend;
- char *zalc;
- boolean fret;
-
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "ftsendcmd: Sending command \"%s\"", z);
-
- clen = strlen (z);
-
- /* We need to send the smallest multiple of CTPACKSIZE which is
- greater than clen (not equal to clen, since we need room for the
- null byte). */
- csend = ((clen / CTPACKSIZE) + 1) * CTPACKSIZE;
-
- zalc = zbufalc (csend);
- memcpy (zalc, z, clen);
- if (csend > clen)
- bzero (zalc + clen, csend - clen);
-
- fret = fsend_data (qdaemon->qconn, zalc, csend, TRUE);
- ubuffree (zalc);
- return fret;
-}
-
-/* Get space to be filled with data. We provide a buffer which has
- four bytes at the start available to hold the length. */
-
-/*ARGSIGNORED*/
-char *
-ztgetspace (qdaemon, pclen)
- struct sdaemon *qdaemon;
- size_t *pclen;
-{
- *pclen = CTBUFSIZE;
- return zTbuf + CTFRAMELEN;
-}
-
-/* Send out some data. We are allowed to modify the four bytes
- preceding the buffer. This allows us to send the entire block with
- header bytes in a single call. */
-
-/*ARGSIGNORED*/
-boolean
-ftsenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos)
- struct sdaemon *qdaemon;
- char *zdata;
- size_t cdata;
- int ilocal;
- int iremote;
- long ipos;
-{
- /* Here we do htonl by hand, since it doesn't exist everywhere. We
- know that the amount of data cannot be greater than CTBUFSIZE, so
- the first two bytes of this value will always be 0. They were
- set to 0 in ftstart so we don't touch them here. This is useful
- because we cannot portably right shift by 24 or 16, since we
- might be dealing with sixteen bit integers. */
- zdata[-2] = (char) ((cdata >> 8) & 0xff);
- zdata[-1] = (char) (cdata & 0xff);
-
- /* We pass FALSE to fsend_data since we don't expect the other side
- to be sending us anything just now. */
- return fsend_data (qdaemon->qconn, zdata - CTFRAMELEN, cdata + CTFRAMELEN,
- FALSE);
-}
-
-/* Process data and return the amount we need in *pfneed. */
-
-static boolean
-ftprocess_data (qdaemon, pfexit, pcneed)
- struct sdaemon *qdaemon;
- boolean *pfexit;
- size_t *pcneed;
-{
- int cinbuf, cfirst, clen;
-
- *pfexit = FALSE;
-
- cinbuf = iPrecend - iPrecstart;
- if (cinbuf < 0)
- cinbuf += CRECBUFLEN;
-
- if (! fTfile)
- {
- /* We are not receiving a file. Commands are read in chunks of
- CTPACKSIZE. */
- while (cinbuf >= CTPACKSIZE)
- {
- cfirst = CRECBUFLEN - iPrecstart;
- if (cfirst > CTPACKSIZE)
- cfirst = CTPACKSIZE;
-
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "ftprocess_data: Got %d command bytes",
- cfirst);
-
- if (! fgot_data (qdaemon, abPrecbuf + iPrecstart,
- (size_t) cfirst, abPrecbuf,
- (size_t) CTPACKSIZE - cfirst,
- -1, -1, (long) -1, TRUE, pfexit))
- return FALSE;
-
- iPrecstart = (iPrecstart + CTPACKSIZE) % CRECBUFLEN;
-
- if (*pfexit)
- return TRUE;
-
- cinbuf -= CTPACKSIZE;
- }
-
- if (pcneed != NULL)
- *pcneed = CTPACKSIZE - cinbuf;
-
- return TRUE;
- }
-
- /* Here we are receiving a file. The data comes in blocks. The
- first four bytes contain the length, followed by that amount of
- data. */
-
- while (cinbuf >= CTFRAMELEN)
- {
- /* The length is stored in network byte order, MSB first. */
-
- clen = (((((((abPrecbuf[iPrecstart] & 0xff) << 8)
- + (abPrecbuf[(iPrecstart + 1) % CRECBUFLEN] & 0xff)) << 8)
- + (abPrecbuf[(iPrecstart + 2) % CRECBUFLEN] & 0xff)) << 8)
- + (abPrecbuf[(iPrecstart + 3) % CRECBUFLEN] & 0xff));
-
- if (cinbuf < clen + CTFRAMELEN)
- {
- if (pcneed != NULL)
- *pcneed = clen + CTFRAMELEN - cinbuf;
- return TRUE;
- }
-
- iPrecstart = (iPrecstart + CTFRAMELEN) % CRECBUFLEN;
-
- cfirst = CRECBUFLEN - iPrecstart;
- if (cfirst > clen)
- cfirst = clen;
-
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "ftprocess_data: Got %d data bytes",
- clen);
-
- if (! fgot_data (qdaemon, abPrecbuf + iPrecstart,
- (size_t) cfirst, abPrecbuf, (size_t) (clen - cfirst),
- -1, -1, (long) -1, TRUE, pfexit))
- return FALSE;
-
- iPrecstart = (iPrecstart + clen) % CRECBUFLEN;
-
- if (*pfexit)
- return TRUE;
-
- cinbuf -= clen + CTFRAMELEN;
- }
-
- if (pcneed != NULL)
- *pcneed = CTFRAMELEN - cinbuf;
-
- return TRUE;
-}
-
-/* Wait for data to come in and process it until we've reached the end
- of a command or a file. */
-
-boolean
-ftwait (qdaemon)
- struct sdaemon *qdaemon;
-{
- while (TRUE)
- {
- boolean fexit;
- size_t cneed, crec;
-
- if (! ftprocess_data (qdaemon, &fexit, &cneed))
- return FALSE;
- if (fexit)
- return TRUE;
-
- if (! freceive_data (qdaemon->qconn, cneed, &crec, cTtimeout, TRUE))
- return FALSE;
-
- if (crec == 0)
- {
- ulog (LOG_ERROR, "Timed out waiting for data");
- return FALSE;
- }
- }
-}
-
-/* File level routine, to set fTfile correctly. */
-
-/*ARGSUSED*/
-boolean
-ftfile (qdaemon, qtrans, fstart, fsend, cbytes, pfhandled)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
- boolean fstart;
- boolean fsend;
- long cbytes;
- boolean *pfhandled;
-{
- *pfhandled = FALSE;
-
- if (! fsend)
- fTfile = fstart;
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/uucico/proty.c b/gnu/libexec/uucp/uucico/proty.c
deleted file mode 100644
index b825a7e..0000000
--- a/gnu/libexec/uucp/uucico/proty.c
+++ /dev/null
@@ -1,660 +0,0 @@
-/* proty.c
- The 'y' protocol.
-
- Copyright (C) 1994, 1995 Jorge Cwik and Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char proty_id[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "trans.h"
-#include "system.h"
-#include "prot.h"
-
-/* The 'y' protocol, and this implementation, was written and designed
- by Jorge Cwik <jorge@satlink.net>. Some of the routines, and the
- coding style in general, were taken verbatim or adapted from other
- Taylor UUCP modules. Mark Delany made the initial testings and
- helped in portability issues.
-
- This protocol does not perform any kind of error correction or flow
- control. It does do error checking. It does not require an end to
- end reliable link. It is recommended for error-free (also called
- semi-reliable) connections as provided by error correcting modems.
- It needs an eight bit clean channel and some kind of flow control
- at the lower layers, typically RTS/CTS hardware flow control.
-
- The flow of the file transmission is completely unidirectional.
- There are no ACKs or NAKs outside file boundaries. This makes it
- very suitable for half duplex modulations (like PEP) and
- connections with very long delays, like multihop satellite links. */
-
-/* This protocol uses 16 bit little-endian ints in the packet header. */
-#define FROMLITTLE(p) (((p)[0] & 0xff) + (((p)[1] & 0xff) << 8))
-#define TOLITTLE(p, i) ((p)[0] = (i) & 0xff, (p)[1] = ((i) >> 8) & 0xff)
-
-/* The buffer and packet size we use. */
-#define CYBUFSIZE (1024)
-#define IYPACKSIZE (1024)
-
-/* The offset in the buffer to the data. */
-#define CYFRAMELEN (6)
-
-/* Offsets in a packet header. */
-#define YFRAME_SEQ_OFF (0)
-#define YFRAME_LEN_OFF (2)
-#define YFRAME_CTL_OFF (2)
-#define YFRAME_CHK_OFF (4)
-
-/* Offsets in a packet header viewed as an array of shorts. */
-#define YFRAME_SEQ (0)
-#define YFRAME_LEN (1)
-#define YFRAME_CTL (1)
-#define YFRAME_CHK (2)
-
-/* The default timeout. */
-#define CYTIMEOUT (60)
-
-/* Control packet types. */
-#define YPKT_ACK (0xFFFE)
-#define YPKT_ERR (0xFFFD)
-#define YPKT_BAD (0xFFFC)
-
-/* The protocol version number. */
-#define Y_VERSION (1)
-
-/* When the protocol starts up, it transmit the following information:
- 1 byte version
- 1 byte packet size
- 2 byte flags (none currently defined)
- Future revision may expand the structure as long as these members
- keep their current offset. */
-#define Y_INIT_HDR_LEN (4)
-#define Y_INIT_HDR_VERSION_OFF (0)
-#define Y_INIT_HDR_PKTSIZE_OFF (1)
-#define Y_INIT_HDR_FLAGS_OFF (2)
-
-/* The initialization length of the lowest accepted version. */
-#define MIN_Y_SYNC (4)
-
-/* Not strictly needed, but I would not want to accept a 32k sync pkt. */
-#define MAX_Y_SYNC IYPACKSIZE
-
-/* Local and remote packet sizes (we actually use the same value for
- both). */
-static size_t iYlocal_packsize = IYPACKSIZE;
-static size_t iYremote_packsize = IYPACKSIZE;
-
-/* Local and remote packet sequence numbers. */
-static unsigned short iYlocal_pktnum;
-static unsigned short iYremote_pktnum;
-
-/* The timeout. */
-static int cYtimeout = CYTIMEOUT;
-
-/* Transmitter buffer. */
-static char *zYbuf;
-
-/* Protocol parameters. */
-
-struct uuconf_cmdtab asYproto_params[] =
-{
- { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cYtimeout, NULL },
- { "packet-size", UUCONF_CMDTABTYPE_INT, (pointer) &iYlocal_packsize, NULL },
- { NULL, 0, NULL, NULL }
-};
-
-/* Local functions. */
-
-static boolean fywait_for_packet P((struct sdaemon *qdaemon,
- boolean *pfexit));
-static unsigned short iychecksum P((const char *z, size_t c));
-static unsigned short iychecksum2 P((const char *zfirst, size_t cfirst,
- const char *zsecond, size_t csecond));
-static boolean fywait_for_header P((struct sdaemon *qdaemon,
- unsigned short header[3], int timeout));
-static boolean fysend_pkt P((struct sdaemon *qdaemon,
- const void *zdata, size_t cdata));
-static boolean fysend_control P((struct sdaemon *qdaemon,
- int itype));
-static boolean fyread_data P((struct sdaemon *qdaemon, size_t clen,
- int timeout));
-
-/* Exchange sync packets at protocol startup. */
-
-static boolean
-fyxchg_syncs (qdaemon)
- struct sdaemon *qdaemon;
-{
- char inithdr[Y_INIT_HDR_LEN];
- unsigned short header[3];
- unsigned short ichk;
- size_t clen, cfirst;
- int rpktsize;
-
- /* Send our configuration. We could use only one array (for local
- and remote). But this is safer in case the code changes and
- depend on separate ones. */
-
- inithdr[Y_INIT_HDR_VERSION_OFF] = Y_VERSION;
- inithdr[Y_INIT_HDR_PKTSIZE_OFF] = iYlocal_packsize >> 8;
- TOLITTLE (inithdr + Y_INIT_HDR_FLAGS_OFF, 0);
-
- if (! fysend_pkt (qdaemon, inithdr, Y_INIT_HDR_LEN))
- return FALSE;
-
- if (! fywait_for_header (qdaemon, header, cYtimeout))
- return FALSE;
-
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "fyxchg_syncs: Got sync header");
- clen = header[YFRAME_LEN];
-
- if (clen < MIN_Y_SYNC || clen > MAX_Y_SYNC)
- {
- ulog (LOG_ERROR, "Bad 'y' protocol sync packet length");
- return FALSE;
- }
-
- /* It may be better to integrate this code with fywait_for_packet. */
- if (! fyread_data (qdaemon, clen, cYtimeout))
- return FALSE;
-
- cfirst = CRECBUFLEN - iPrecstart;
- ichk = iychecksum2 (abPrecbuf + iPrecstart, cfirst,
- abPrecbuf, clen - cfirst);
-
- rpktsize = BUCHAR (abPrecbuf[(iPrecstart + 1) % CRECBUFLEN]);
-
- /* Future versions of the protocol may need to check and react
- according to the version number. */
-
- if (rpktsize == 0 || header[YFRAME_CHK] != ichk)
- {
- ulog (LOG_ERROR, "Bad 'y' protocol sync packet");
- return FALSE;
- }
-
- iYremote_packsize = rpktsize << 8;
-
- /* Some may want to do this different and in effect the protocol
- support this. But I like the idea that the packet size would be
- the same in both directions. This allows the caller to select
- both packet sizes without changing the configuration at the
- server. */
- if (iYremote_packsize > iYlocal_packsize)
- iYremote_packsize = iYlocal_packsize;
-
- iPrecstart = (iPrecstart + clen) % CRECBUFLEN;
- return TRUE;
-}
-
-/* Start the protocol. */
-
-boolean
-fystart (qdaemon, pzlog)
- struct sdaemon *qdaemon;
- char **pzlog;
-{
- *pzlog = NULL;
-
- /* This should force, or at least enable if available, RTS/CTS
- hardware flow control !! */
-
- /* The 'y' protocol requires an eight bit clean link */
- if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE,
- STRIPSETTING_EIGHTBITS, XONXOFF_OFF))
- return FALSE;
-
- iYlocal_pktnum = iYremote_pktnum = 0;
-
- /* Only multiple of 256 sizes are allowed */
- iYlocal_packsize &= ~0xff;
- if (iYlocal_packsize < 256 || iYlocal_packsize > (16*1024))
- iYlocal_packsize = IYPACKSIZE;
-
- /* Exhange SYNC packets */
- if (! fyxchg_syncs (qdaemon))
- {
- /* Restore defaults */
- cYtimeout = CYTIMEOUT;
- iYlocal_packsize = IYPACKSIZE;
- return FALSE;
- }
-
- zYbuf = (char *) xmalloc (CYBUFSIZE + CYFRAMELEN);
- return TRUE;
-}
-
-/* Shutdown the protocol. */
-
-boolean
-fyshutdown (qdaemon)
- struct sdaemon *qdaemon;
-{
- xfree ((pointer) zYbuf);
- zYbuf = NULL;
- cYtimeout = CYTIMEOUT;
- iYlocal_packsize = IYPACKSIZE;
- return TRUE;
-}
-
-/* Send a command string. We send packets containing the string until
- the entire string has been sent, including the zero terminator. */
-
-/*ARGSUSED*/
-boolean
-fysendcmd (qdaemon, z, ilocal, iremote)
- struct sdaemon *qdaemon;
- const char *z;
- int ilocal;
- int iremote;
-{
- size_t clen;
-
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fysendcmd: Sending command \"%s\"", z);
-
- clen = strlen (z) + 1;
-
- while (clen > 0)
- {
- size_t csize;
-
- csize = clen;
- if (csize > iYremote_packsize)
- csize = iYremote_packsize;
-
- if (! fysend_pkt (qdaemon, z, csize))
- return FALSE;
-
- z += csize;
- clen -= csize;
- }
-
- return TRUE;
-}
-
-/* Get space to be filled with data. We always use zYbuf, which was
- allocated from the heap. */
-
-char *
-zygetspace (qdaemon, pclen)
- struct sdaemon *qdaemon;
- size_t *pclen;
-{
- *pclen = iYremote_packsize;
- return zYbuf + CYFRAMELEN;
-}
-
-/* Send out a data packet. */
-
-boolean
-fysenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos)
- struct sdaemon *qdaemon;
- char *zdata;
- size_t cdata;
- int ilocal;
- int iremote;
- long ipos;
-{
-#if DEBUG > 0
- if (cdata > iYremote_packsize)
- ulog (LOG_FATAL, "fysend_packet: Packet size too large");
-#endif
-
- TOLITTLE (zYbuf + YFRAME_SEQ_OFF, iYlocal_pktnum);
- ++iYlocal_pktnum;
- TOLITTLE (zYbuf + YFRAME_LEN_OFF, cdata);
- TOLITTLE (zYbuf + YFRAME_CHK_OFF, iychecksum (zdata, cdata));
-
- /* We pass FALSE to fsend_data since we don't expect the other side
- to be sending us anything just now. */
- return fsend_data (qdaemon->qconn, zYbuf, cdata + CYFRAMELEN, FALSE);
-}
-
-/* Wait for data to come in and process it until we've finished a
- command or a file. */
-
-boolean
-fywait (qdaemon)
- struct sdaemon *qdaemon;
-{
- boolean fexit = FALSE;
-
- while (! fexit)
- {
- if (! fywait_for_packet (qdaemon, &fexit))
- return FALSE;
- }
- return TRUE;
-}
-
-/* File level routines
- We could handle this inside the other public routines,
- but this is cleaner and better for future expansions */
-
-boolean
-fyfile (qdaemon, qtrans, fstart, fsend, cbytes, pfhandled)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
- boolean fstart;
- boolean fsend;
- long cbytes;
- boolean *pfhandled;
-{
- unsigned short header[3];
-
- *pfhandled = FALSE;
-
- if (! fstart)
- {
- if (fsend)
- {
- /* It is critical that the timeout here would be long
- enough. We have just sent a full file without any kind
- of flow control at the protocol level. The traffic may
- be buffered in many places of the link, and the remote
- may take a while until cathing up. */
- if (! fywait_for_header (qdaemon, header, cYtimeout * 2))
- return FALSE;
-
- if (header[YFRAME_CTL] != (unsigned short) YPKT_ACK)
- {
- DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fyfile: Error from remote: 0x%04X", header[1]);
- ulog (LOG_ERROR, "Received 'y' protocol error from remote");
- return FALSE;
- }
- }
- else
- {
- /* This is technically not requireed. But I've put this in
- the protocol to allow easier expansions. */
- return fysend_control (qdaemon, YPKT_ACK);
- }
- }
-
- return TRUE;
-}
-
-/* Send a control packet, not used during the normal file
- transmission. */
-
-static boolean
-fysend_control (qdaemon, itype)
- struct sdaemon *qdaemon;
- int itype;
-{
- char header[CYFRAMELEN];
-
- TOLITTLE (header + YFRAME_SEQ_OFF, iYlocal_pktnum);
- iYlocal_pktnum++;
- TOLITTLE (header + YFRAME_CTL_OFF, itype);
- TOLITTLE (header + YFRAME_CHK_OFF, 0);
-
- return fsend_data (qdaemon->qconn, header, CYFRAMELEN, FALSE);
-}
-
-/* Private function to send a packet. This one doesn't need the data
- to be in the buffer provided by zygetspace. I've found it worth
- for avoiding memory copies. Somebody may want to do it otherwise */
-
-static boolean
-fysend_pkt (qdaemon, zdata, cdata)
- struct sdaemon *qdaemon;
- const void *zdata;
- size_t cdata;
-{
- char header[CYFRAMELEN];
-
- TOLITTLE (header + YFRAME_SEQ_OFF, iYlocal_pktnum);
- iYlocal_pktnum++;
- TOLITTLE (header + YFRAME_LEN_OFF, cdata);
- TOLITTLE (header + YFRAME_CHK_OFF, iychecksum (zdata, cdata));
-
- if (! fsend_data (qdaemon->qconn, header, CYFRAMELEN, FALSE))
- return FALSE;
- return fsend_data (qdaemon->qconn, zdata, cdata, FALSE);
-}
-
-/* Wait until enough data arrived from the comm line. This protocol
- doesn't need to perform any kind of action while waiting. */
-
-static boolean
-fyread_data (qdaemon, clen, timeout)
- struct sdaemon *qdaemon;
- size_t clen;
- int timeout;
-{
- int cinbuf;
- size_t crec;
-
- cinbuf = iPrecend - iPrecstart;
- if (cinbuf < 0)
- cinbuf += CRECBUFLEN;
-
- if (cinbuf < clen)
- {
- if (! freceive_data (qdaemon->qconn, clen - cinbuf, &crec,
- timeout, TRUE))
- return FALSE;
- cinbuf += crec;
- if (cinbuf < clen)
- {
- if (! freceive_data (qdaemon->qconn, clen - cinbuf, &crec,
- timeout, TRUE))
- return FALSE;
- }
- cinbuf += crec;
- if (cinbuf < clen)
- {
- ulog (LOG_ERROR, "Timed out waiting for data");
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-/* Receive a remote packet header, check for correct sequence number. */
-
-static boolean
-fywait_for_header (qdaemon, header, timeout)
- struct sdaemon *qdaemon;
- unsigned short header[3];
- int timeout;
-{
- if (! fyread_data (qdaemon, CYFRAMELEN, timeout))
- return FALSE;
-
- /* Somebody may want to optimize this in a portable way. I'm not
- sure it's worth, but the output by gcc for the portable construct
- is so bad (even with optimization), that I couldn't resist. */
-
- if (iPrecstart <= (CRECBUFLEN - CYFRAMELEN))
- {
- header[0] = FROMLITTLE (abPrecbuf + iPrecstart);
- header[1] = FROMLITTLE (abPrecbuf + iPrecstart + 2);
- header[2] = FROMLITTLE (abPrecbuf + iPrecstart + 4);
- }
- else
- {
- register int i, j;
-
- for (i = j = 0; j < CYFRAMELEN; i++, j += 2)
- {
- header[i] =
- (((abPrecbuf[(iPrecstart + j + 1) % CRECBUFLEN] & 0xff) << 8)
- + (abPrecbuf[(iPrecstart + j) % CRECBUFLEN] & 0xff));
- }
- }
-
- iPrecstart = (iPrecstart + CYFRAMELEN) % CRECBUFLEN;
-
- DEBUG_MESSAGE3 (DEBUG_UUCP_PROTO,
- "fywait_for_header: Got header: 0x%04X, 0x%04X, 0x%04X",
- header[0], header[1], header[2]);
-
- if (header[YFRAME_SEQ] != iYremote_pktnum++)
- {
- ulog (LOG_ERROR, "Incorrect 'y' packet sequence");
- fysend_control (qdaemon, YPKT_BAD);
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Receive a remote data packet */
-
-static boolean
-fywait_for_packet (qdaemon, pfexit)
- struct sdaemon *qdaemon;
- boolean *pfexit;
-{
- unsigned short header[3], ichk;
- size_t clen, cfirst;
-
- if (! fywait_for_header (qdaemon, header, cYtimeout))
- return FALSE;
-
- clen = header[YFRAME_LEN];
- if (clen == 0 && pfexit != NULL)
- {
- /* I Suppose the pointers could be NULL ??? */
- return fgot_data (qdaemon, abPrecbuf, 0, abPrecbuf, 0,
- -1, -1, (long) -1, TRUE, pfexit);
- }
-
- if (clen & 0x8000)
- {
- DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fywait_for_packet: Error from remote: 0x%04X",
- header[YFRAME_CTL]);
- ulog (LOG_ERROR, "Remote error packet");
- return FALSE;
- }
-
- /* This is really not neccessary. But if this check is removed,
- take in mind that the packet may be up to 32k long. */
- if (clen > iYlocal_packsize)
- {
- ulog (LOG_ERROR, "Packet too large");
- return FALSE;
- }
-
- if (! fyread_data (qdaemon, clen, cYtimeout))
- return FALSE;
-
- cfirst = CRECBUFLEN - iPrecstart;
- if (cfirst > clen)
- cfirst = clen;
-
- if (cfirst == clen)
- ichk = iychecksum (abPrecbuf + iPrecstart, clen);
- else
- ichk = iychecksum2 (abPrecbuf + iPrecstart, cfirst,
- abPrecbuf, clen - cfirst);
- if (header[YFRAME_CHK] != ichk)
- {
- DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
- "fywait_for_packet: Bad checksum 0x%x != 0x%x",
- header[YFRAME_CHK], ichk);
- fysend_control (qdaemon, YPKT_ERR);
- ulog (LOG_ERROR, "Checksum error");
- return FALSE;
- }
-
- if (pfexit != NULL
- && ! fgot_data (qdaemon, abPrecbuf + iPrecstart, cfirst,
- abPrecbuf, clen - cfirst,
- -1, -1, (long) -1, TRUE, pfexit))
- return FALSE;
-
- iPrecstart = (iPrecstart + clen) % CRECBUFLEN;
-
- return TRUE;
-}
-
-/* Compute 16 bit checksum */
-
-#ifdef __GNUC__
-#ifdef __i386__
-#define I386_ASM
-#endif
-#endif
-
-#ifdef I386_ASM
-#define ROTATE(i) \
- asm ("rolw $1,%0" : "=g" (i) : "g" (i))
-#else
-#define ROTATE(i) i += i + ((i & 0x8000) >> 15)
-#endif
-
-static unsigned short
-iychecksum (z, c)
- register const char *z;
- register size_t c;
-{
- register unsigned short ichk;
-
- ichk = 0xffff;
-
- while (c-- > 0)
- {
- ROTATE (ichk);
- ichk += BUCHAR (*z++);
- }
-
- return ichk;
-}
-
-static unsigned short
-iychecksum2 (zfirst, cfirst, zsecond, csecond)
- const char *zfirst;
- size_t cfirst;
- const char *zsecond;
- size_t csecond;
-{
- register unsigned short ichk;
- register const char *z;
- register size_t c;
-
- z = zfirst;
- c = cfirst + csecond;
-
- ichk = 0xffff;
-
- while (c-- > 0)
- {
- ROTATE (ichk);
- ichk += BUCHAR (*z++);
-
- /* If the first buffer has been finished, switch to the second. */
- if (--cfirst == 0)
- z = zsecond;
- }
-
- return ichk;
-}
diff --git a/gnu/libexec/uucp/uucico/protz.c b/gnu/libexec/uucp/uucico/protz.c
deleted file mode 100644
index 3d05842..0000000
--- a/gnu/libexec/uucp/uucico/protz.c
+++ /dev/null
@@ -1,2626 +0,0 @@
-/* protz.c Version 1.5, 92Apr24 */
-/* Modified by Ian Lance Taylor for Taylor UUCP 1.04 92Aug4. */
-
-/*
- * Doug Evans, dje@sspiff.UUCP or dje@ersys.edmonton.ab.ca
- *
- * This file provides the Zmodem protocol (by Chuck Forsberg) for
- * Ian Taylor's UUCP package.
- *
- * It was originally developed to establish a uucp link between myself and my
- * employer: Ivation Datasystems, Inc. of Ottawa.
- *
- * My thanks to Ivation for letting me release this to the public. Given that
- * Zmodem is in the public domain, no additional copyrights have been added.
- *
- *****************************************************************************
- *
- * It's been difficult fitting Zmodem into the UUCP world. I have been guided
- * mostly by trying to plug it into Taylor UUCP. Where "the Zmodem way of doing
- * things" conflicted with "the UUCP way of doing things", I have err'd on the
- * side of UUCP. At the end of it all, I have achieved something that will plug
- * into Taylor UUCP very easily, but some might argue that I have corrupted Z
- * too much. At any rate, compatibility with sz/rz was sacrificed to achieve a
- * clean UUCP protocol. Given that, I took the opportunity to start from
- * scratch when defining protocol constants (EG: ZBIN).
- *
- * 1) I wasn't quite sure how to enhance Zmodem to handle send+receive in one
- * session, so I added a 'g' protocol like initialization sequence. This
- * also gets this stuff out of the way, in case we ever try to support
- * full-duplex.
- *
- * Caller Callee
- * ------ ------
- * ZINIT --> <-- ZINIT
- * ZDATA (ZCRCF) --> <-- ZDATA (ZCRCF)
- * ZACK --> <-- ZACK
- * ZINITEND --> <-- ZINITEND
- *
- * ZINIT is a combination of ZRINIT and ZSINIT and is intended to exchange
- * simple protocol information (flags) and the protocol version number.
- * ZDATA is intended to include window size information as well as the
- * "Myattn" string (although at the moment it doesn't contain anything).
- * ZDATA may contain at most 1k bytes of data and is sent out as one ZCRCF
- * packet. Two ack's (ZACK + ZINITEND) are needed to ensure both sides have
- * received ZDATA.
- *
- * 2) I've hardcoded several protocol parameters, like 32 bit CRC's for data.
- * Others are not supported (we don't need them).
- *
- * 3) ZHEX headers use 32 bit CRC's.
- *
- * 4) Zmodem sends the ZFILE message "in one chunk". If there are errors, the
- * entire string is resent. I have continued this practice. All UUCP
- * commands are sent "in one chunk". This can be changed down the road if
- * necessary.
- *
- * 5) The ZEOF message has been replaced with a new ZCRCx value: ZCRCF. ZCRCF
- * is identical to ZCRCW except that it indicates the end of the message.
- * The protocol here is *not* a file transfer protocol. It is an end to end
- * transport protocol (that preserves message boundaries).
- *
- * 6) Zmodem handles restarting a file transfer, but as best as I can tell UUCP
- * does not. At least Taylor UUCP doesn't. And if UUCP does start handling
- * file restart, can it be plugged into the existing Zmodem way with zero
- * changes? Beats me. Therefore I have removed this part of the code. One
- * can always put it back in if and when UUCP handles it. Ditto for other
- * pieces of removed code: there's no point in overly complicating this code
- * when supporting all the bells and whistles requires enhancements to UUCP
- * itself.
- *
- * *** It is easier to put code back in in an upward compatible manner ***
- * *** than it is to correct for misunderstood code or poorly merged ***
- * *** (Zmodem vs UUCP) code. ***
- *
- * 7) For the character in the initial "protocol selection" sequence, I have
- * chosen 'a'. I'm told 'z' is already in use for something that isn't
- * Zmodem. It's entirely reasonable to believe that if Zmodem ever becomes a
- * standard UUCP protocol, this won't be it (so I'll leave z/Z for them).
- * Publicly, this is the 'a' protocol. Internally, it is refered to as 'z'.
- * A little confusing, I know. Maybe in time I'll refer to it internally as
- * 'a', or maybe in time this will be *the* 'z' protocol.
- *
- * 8) Since we are writing a transport protocol, which isn't supposed to know
- * anything about what is being transfered or where it is coming from, the
- * header data value has changed meaning. It no longer means "file position"
- * but instead means "window position". It is a running counter of the bytes
- * transfered. Each "message" begins on a 1k boundary so the count isn't a
- * precise byte count. The counter wraps every 4 gigabytes, although this
- * wrapping isn't supported yet.
- *
- * FIXME: At present the max data transfered per session is 4 gigabytes.
- *
- ****************************************************************************
- *
- * A typical message sequence is (master sending file to slave):
- *
- * Master Slave
- * ------ -----
- * ZDATA (S, ZCRCF) -->
- * <-- ZACK
- * <-- ZDATA (SY, ZCRCF)
- * ZACK -->
- * ZDATA -->
- * ... <-- ZACK/ZRPOS
- * ZDATA (ZCRCF) -->
- * <-- ZACK
- * <-- ZDATA (CY, ZCRCF)
- * ZACK -->
- *
- * A typical message sequence is (master receiving file from slave):
- *
- * Master Slave
- * ------ -----
- * ZDATA (R, ZCRCF) -->
- * <-- ZACK
- * <-- ZDATA (RY, ZCRCF)
- * ZACK -->
- * <-- ZDATA
- * ZACK/ZRPOS ... -->
- * <-- ZDATA (ZCRCF)
- * ZACK -->
- * ZDATA (CY, ZCRCF) -->
- * <-- ZACK
- *
- *****************************************************************************
- *
- * Notes:
- * 1) For future bidirectional concerns, keep packet types "unidirectional".
- * Sender always uses: ZDATA, ZNAK
- * Receiver always uses: ZRPOS, ZACK
- * There is no intersection.
- *
- * I'm not sure if this is necessary or even useful, but it seems to be.
- *
- * 2) I use to store the byte count / 32 in the data header. This left 5 bits
- * unused for future concerns. I removed this because of the following
- * situation when sending a file:
- *
- * ZDATA (ZCRCG, xx bytes) - received ok
- * ZDATA (ZCRCF, 0 bytes) - corrupted
- *
- * At this point the receiver would like to send back a ZRPOS with a value
- * of the size of the file. However, it can't because the value is divided
- * by 32, and it would have to round up to the next multiple of 32. This
- * seemed a little ugly, so I went with using the entire header to store
- * the byte count.
- *
- *****************************************************************************
- *
- * Source version:
- *
- * 1.1,2,3
- * Protocol version 0
- * Early attempts, completely rewritten later.
- *
- * 1.4 Protocol version 1
- * Beta test sent to Ian for analysis 92Apr18.
- *
- * 1.5 Protocol version 1
- * Released 92Apr24.
- *
- *****************************************************************************
- *
- * Protocol version:
- *
- * A version number is exchanged in the ZINIT message, so it is possible to
- * correct or enhance the protocol, without breaking existing versions.
- * The purpose of this section is to document these versions as they come out.
- * Remember, this is the protocol version, not the source version.
- *
- * 0 Initial version.
- * Zmodem controlled file transfer. This was more of a "plug Z
- * into UUCP as is" port.
- *
- * 1 Complete rewrite.
- * Made Z more of a transport protocol. UUCP now controls transfer and Z
- * is on the same footing as the other UUCP protocols.
- * Theoretically, there will be little pain when UUCP goes bidirectional.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char protz_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "trans.h"
-#include "system.h"
-#include "prot.h"
-
-#define ZPROTOCOL_VERSION 1
-
-/*
- * Control message characters ...
- */
-
-#define ZPAD '*' /* Padding character begins frames */
-#define ZDLE 030 /* Ctrl-X Zmodem escape - `ala BISYNC DLE */
-#define ZBIN 'A' /* Binary frame indicator */
-#define ZHEX 'B' /* HEX frame indicator */
-
-/*
- * Frame types (see array "frametypes" in zm.c) ...
- *
- * Note that the numbers here have been reorganized, as we don't support
- * all of them (nor do we need to).
- *
- * WARNING: The init sequence assumes ZINIT < ZDATA < ZACK < ZINITEND.
- */
-
-#define ZINIT 0 /* Init (contains protocol version, flags) */
-#define ZDATA 1 /* Data packet(s) follow */
-#define ZRPOS 2 /* Resume data trans at this position */
-#define ZACK 3 /* ACK to above */
-#define ZNAK 4 /* Last packet was garbled */
-#define Zreserved 5 /* reserved (for future concerns) */
-#define ZINITEND 6 /* end of init sequence */
-#define ZFIN 7 /* Finish session */
-
-/*
- * ZDLE sequences ...
- *
- * Note addition of ZCRCF: "end of message".
- */
-
-#define ZCRCE 'h' /* CRC next, frame ends, header packet follows */
-#define ZCRCG 'i' /* CRC next, frame continues nonstop */
-#define ZCRCQ 'j' /* CRC next, frame continues, ZACK expected */
-#define ZCRCW 'k' /* CRC next, ZACK expected, end of frame */
-#define ZCRCF 'l' /* CRC next, ZACK expected, end of message */
-
-#define ZRUB0 'm' /* Translate to rubout 0177 */
-#define ZRUB1 'n' /* Translate to rubout 0377 */
-
-
-/*
- * zdlread return values (internal) ...
- * Other values are ZM_ERROR, ZM_TIMEOUT, ZM_RCDO.
- */
-
-#define GOTOR 0400
-#define GOTCRCE (ZCRCE | GOTOR) /* ZDLE-ZCRCE received */
-#define GOTCRCG (ZCRCG | GOTOR) /* ZDLE-ZCRCG received */
-#define GOTCRCQ (ZCRCQ | GOTOR) /* ZDLE-ZCRCQ received */
-#define GOTCRCW (ZCRCW | GOTOR) /* ZDLE-ZCRCW received */
-#define GOTCRCF (ZCRCF | GOTOR) /* ZDLE-ZCRCF received */
-
-/*
- * Byte positions within header array ...
- */
-
-#define ZF0 3 /* First flags byte */
-#define ZF1 2
-#define ZF2 1
-#define ZF3 0
-
-#define ZP0 0 /* Low order 8 bits of position */
-#define ZP1 1
-#define ZP2 2
-#define ZP3 3 /* High order 8 bits of position */
-
-/*
- * Bit Masks for ZRQINIT flags byte ZF0 ...
- */
-
-#define TX_ESCCTL 1 /* Tx will escape control chars */
-
-/*
- * Possible errors when running ZMODEM ...
- */
-
-#define ZM_ERROR (-1) /* crc error, etc. */
-#define ZM_TIMEOUT (-2)
-#define ZM_RCDO (-3) /* Carrier Lost */
-
-/*
- * ASCII characters ...
- */
-
-#define LF 012
-#define CR 015
-#define XON 021
-#define XOFF 023
-
-#define XON_WAIT 10 /* seconds */
-
-/*
- * Packet sizes ...
- *
- * FIXME: CPACKETSIZE is hardcoded in a lot of places.
- * It's not clear to me whether changing it's value would be a
- * "good thing" or not. But of course that doesn't excuse the hardcoding.
- */
-
-#define CPACKETSIZE 1024 /* max packet size (data only) */
-#define CFRAMELEN 12 /* header size */
-#define CSUFFIXLEN 10 /* suffix at end of data packets */
-#define CEXCHANGE_INIT_RETRIES 4
-
-/* The header CRC value. */
-
-#if ANSI_C
-#define IHDRCRC 0xDEBB20E3UL
-#else
-#define IHDRCRC ((unsigned long) 0xDEBB20E3L)
-#endif
-
-/* packet buffer size */
-#define CPACKBUFSIZE (CFRAMELEN + 2 * CPACKETSIZE + CSUFFIXLEN + 42 /*slop*/)
-
-/*
- * Data types ...
- */
-
-typedef unsigned char achdrval_t[4];
-typedef unsigned long hdrval_t;
-typedef unsigned long winpos_t;
-
-/*
- * Configurable parms ...
- *
- * FIXME: <cZrx_buf_len> isn't used yet. It may not be needed.
- */
-
-#define CTIMEOUT 10
-#define CRETRIES 10
-#define CSTARTUP_RETRIES 4
-#define CGARBAGE 2400
-#define CSEND_WINDOW 16384
-#define FESCAPE_CONTROL FALSE
-
-static int cZtimeout = CTIMEOUT; /* (seconds) */
-static int cZretries = CRETRIES;
-static int cZstartup_retries = CSTARTUP_RETRIES;
-static int cZmax_garbage = CGARBAGE; /* max garbage before header */
-static int cZtx_window = CSEND_WINDOW; /* our transmission window */
-static int cZrx_buf_len = 0; /* our reception buffer size */
-static boolean fZesc_ctl = FESCAPE_CONTROL; /* escape control chars */
-
-struct uuconf_cmdtab asZproto_params[] =
-{
- {"timeout", UUCONF_CMDTABTYPE_INT, (pointer) & cZtimeout, NULL},
- {"retries", UUCONF_CMDTABTYPE_INT, (pointer) & cZretries, NULL},
- {"startup-retries", UUCONF_CMDTABTYPE_INT,
- (pointer) & cZstartup_retries, NULL},
- {"garbage", UUCONF_CMDTABTYPE_INT, (pointer) & cZmax_garbage, NULL},
- {"send-window", UUCONF_CMDTABTYPE_INT, (pointer) & cZtx_window, NULL},
- {"escape-control", UUCONF_CMDTABTYPE_BOOLEAN, (pointer) & fZesc_ctl,
- NULL},
- {NULL, 0, NULL, NULL}
-};
-
-/*
- * Variables for statistic gathering ...
- *
- * We use <wpZtxpos, wpZrxbytes> to record the number of "packets"
- * sent/received. Packets is in double quotes because some of them aren't full.
- */
-
-static unsigned long cZheaders_sent;
-static unsigned long cZheaders_received;
-static unsigned long cZbytes_resent;
-static unsigned long cZtimeouts;
-static unsigned long cZerrors;
-
-/*
- * Data buffers ...
- */
-
-static char *zZtx_buf; /* transmit buffer */
-
-static char *zZtx_packet_buf; /* raw outgoing packet data */
-static char *zZrx_packet_buf; /* raw incoming packet data */
-
-/*
- * Transmitter state variables ...
- */
-
-static unsigned cZblklen; /* data length in sent/received packets */
-static unsigned cZtxwspac; /* spacing between ZCRCQ requests */
-/*static unsigned cZblklen_override;*//* override value for <cZblklen> */
-static unsigned cZtxwcnt; /* counter used to space ack requests */
-static unsigned cZrxwcnt; /* counter used to watch receiver's buf size */
-static winpos_t wpZtxstart; /* <wpZtxpos> when message started */
-static winpos_t wpZtxpos; /* transmitter position */
-static winpos_t wpZlastsync; /* last offset to which we got a ZRPOS */
-static winpos_t wpZlrxpos; /* receiver's last reported offset */
-static winpos_t wpZrxpos; /* receiver file position */
-
-static int iZlast_tx_data_packet; /* type of last ZDATA packet (ZCRCx) */
-static int iZjunk_count; /* amount of garbage characters received */
-static int iZtleft; /* for dynamic packet resizing */
-
-static int iZbeenhereb4; /* times we've been ZRPOS'd to same place */
-
-/*
- * Receiver state variables ...
- */
-
-static winpos_t wpZrxbytes; /* receiver byte count */
-static int iZlast_rx_data_packet; /* last successfully received ZCRCx packet */
-
-/*
- * Misc. globals ...
- */
-
-static char xon = XON;
-
-#ifdef DJE_TESTING
-int uucptest = -1;
-int uucptest2;
-int uucptestseed;
-#endif
-
-/*
- * Kludge!!!
- * See fzfinish_tx(). Basically the next two globals are used to record the
- * fact that we got a ZDATA, but aren't quite ready to process it.
- */
-
-static int iZpkt_rcvd_kludge; /* -1 if not valid */
-static hdrval_t hvZpkt_hdrval_kludge;
-
-/*
- * Packet types ...
- */
-
-static const char *azZframe_types[] = {
- "Carrier Lost", /* -3 */
- "Timeout", /* -2 */
- "Error", /* -1 */
-#define FTOFFSET 3
- "ZINIT",
- "ZDATA",
- "ZRPOS",
- "ZACK",
- "ZNAK",
- "Zreserved",
- "ZINITEND",
- "ZFIN",
- "UNKNOWN!!!"
-};
-#define FTNUMBER (sizeof(azZframe_types) / sizeof(char *))
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-#define ZZHEADER_NAME(itype) \
- azZframe_types[min((itype) + FTOFFSET, FTNUMBER - 1)]
-
-/*
- * Local functions ...
- */
-
-static boolean fzsend_data P((struct sdaemon *qdaemon, char *zdata,
- size_t cdata, boolean fendofmessage));
-static boolean fzprocess P((struct sdaemon *qdaemon));
-static boolean fzstart_proto P((struct sdaemon *qdaemon));
-static int izexchange_init P((struct sdaemon *qdaemon, int send_type,
- achdrval_t send_val, achdrval_t recv_val));
-static boolean fzshutdown_proto P((struct sdaemon *qdaemon));
-static boolean fzstart_tx P((void));
-static boolean fzfinish_tx P((struct sdaemon *qdaemon, long *plredo));
-static boolean fzstart_rx P((void));
-static boolean fzfinish_rx P((struct sdaemon *qdaemon));
-static boolean fzsend_hdr P((struct sdaemon *qdaemon, int ipkttype,
- int ihdrtype, hdrval_t hdrval,
- boolean fcheckreceive));
-static boolean fzsend_data_packet P((struct sdaemon *qdaemon, char *zdata,
- size_t cdata, int frameend,
- boolean fcheckreceive));
-static int czbuild_header P((char *zresult, int ipkttype, int ihdrtype,
- hdrval_t hdrval));
-static int czbuild_data_packet P((char *zresult, const char *zdata,
- size_t cdata, int frameend));
-/*
- * The rest of the functions do not follow Ian's naming style. I have left
- * the names the same as the original zm source. Over time, they may change.
- */
-static int izrecv_hdr P((struct sdaemon *qdaemon, achdrval_t hdr));
-static int zrbhdr32 P((struct sdaemon *qdaemon, achdrval_t hdr));
-static int zrhhdr P((struct sdaemon *qdaemon, achdrval_t hdr));
-static int zrdat32 P((struct sdaemon *qdaemon, char *buf, int length,
- int *iprxcount));
-static int getinsync P((struct sdaemon *qdaemon, boolean flag));
-static char *zputhex P((char *p, int ch));
-static char *zputchar P((char *p, int ch));
-static int zgethex P((struct sdaemon *qdaemon));
-static int zdlread P((struct sdaemon *qdaemon));
-static int noxrd7 P((struct sdaemon *qdaemon));
-static int realreadchar P((struct sdaemon *qdaemon, int timeout));
-static boolean fzreceive_ready P((void));
-static void stohdr P((hdrval_t pos, achdrval_t hdr));
-static hdrval_t rclhdr P((achdrval_t hdr));
-static hdrval_t hvzencode_data_hdr P((winpos_t cbytes));
-static void zdecode_data_hdr P((hdrval_t hdrval, winpos_t *pcbytes));
-static winpos_t lzupdate_rxpos P((achdrval_t rx_hdr, winpos_t rxpos,
- winpos_t lrxpos, winpos_t txpos));
-
-/*
- * This macro replaces readchar() because it achieves a noticable speed up. The
- * readchar() function has been renamed realreadchar(). Thanks to Ian for
- * running this stuff through a profiler to find this out. Ian suggests further
- * speed ups may be obtained by doing a similar thing in zrdat32().
- */
-
-/* Assign the next character to b. */
-#define READCHAR(qdaemon, b, i) \
- (iPrecstart != iPrecend \
- ? ((b) = BUCHAR (abPrecbuf[iPrecstart]), \
- iPrecstart = (iPrecstart + 1) % CRECBUFLEN) \
- : ((b) = realreadchar ((qdaemon), (i))))
-
-/************************************************************************/
-
-
-/*
- * Start the protocol ...
- */
-
-boolean
-fzstart(qdaemon, pzlog)
-struct sdaemon *qdaemon;
-char **pzlog;
-{
- *pzlog = zbufalc (sizeof "protocol 'a' starting: , , , , , " + 100);
- sprintf (*pzlog, "protocol 'a' starting: %d, %d, %d, %d, %d, %d",
- cZtimeout, cZretries, cZstartup_retries,
- cZmax_garbage, cZtx_window, fZesc_ctl);
-
- if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE,
- STRIPSETTING_EIGHTBITS, XONXOFF_OFF))
- return FALSE;
-
- /*
- * For now, we place tight restrictions on the size of the transmit
- * window. This might be relaxed in the future. If it is relaxed,
- * some of these tests will stay, some will go. That is why it is
- * coded like it is.
- */
-
- if (cZtx_window % 1024 != 0 ||
- cZtx_window < 4096 || cZtx_window > 65536 ||
- 65536 % cZtx_window != 0
- ) {
- ulog (LOG_ERROR,
- "fzstart: cZtx_window not one of 4096, 8192, 16384, 32768, 65536");
- return FALSE;
- }
-
- zZtx_buf = (char *) xmalloc (CPACKETSIZE);
- zZtx_packet_buf = (char *) xmalloc (CPACKBUFSIZE);
- zZrx_packet_buf = (char *) xmalloc (CPACKBUFSIZE);
-
- iZlast_tx_data_packet = -1;
- iZlast_rx_data_packet = -1;
-
- wpZtxpos = wpZlrxpos = wpZrxpos = wpZrxbytes = 0;
- cZtxwspac = cZtx_window / 4;
-
- cZheaders_sent = cZheaders_received = cZbytes_resent = 0;
- cZtimeouts = cZerrors = 0;
-
- iZpkt_rcvd_kludge = -1;
-
-#if 0
- /*
- * We ensure <cZtx_window> is at least 4k, so the following is
- * unnecessary. It can be put back in later if needed.
- */
- if (cZblklen_override > cZtxwspac
- || (!cZblklen_override && cZtxwspac < 1024))
- cZblklen_override = cZtxwspac;
-#endif
-
-#ifdef DJE_TESTING
- {
- extern int uucptest,uucptest2,uucptestseed;
- FILE *f;
-
- if (uucptest == -1) {
- f = fopen ("/usr/local/src/bin/uucp/uucptest", "r");
- if (f != NULL) {
- fscanf (f, "%d %d %d",
- &uucptestseed, &uucptest, &uucptest2);
- fclose (f);
- }
- srand (uucptestseed);
- }
- }
-#endif
-
- /*
- * Fire up the protocol (exchange init messages) ...
- */
-
- if (!fzstart_proto (qdaemon))
- return FALSE;
-
- return TRUE;
-}
-
-/*
- * Stop the protocol ...
- */
-
-boolean
-fzshutdown(qdaemon)
-struct sdaemon *qdaemon;
-{
- (void) fzshutdown_proto (qdaemon);
-
- xfree ((pointer) zZtx_buf);
- xfree ((pointer) zZtx_packet_buf);
- xfree ((pointer) zZrx_packet_buf);
- zZtx_buf = NULL;
- zZtx_packet_buf = NULL;
- zZrx_packet_buf = NULL;
-
- /*
- * Print some informative statistics ...
- *
- * I use the word "messages" here instead of "headers" because the
- * latter is jargonese.
- */
-
- ulog (LOG_NORMAL,
- "Protocol 'a' messages: sent %lu, received %lu",
- cZheaders_sent, cZheaders_received);
- ulog (LOG_NORMAL,
- "Protocol 'a' packets: sent %lu, received %lu",
- wpZtxpos / 1024, wpZrxbytes / 1024);
- if (cZbytes_resent != 0 || cZtimeouts != 0 || cZerrors != 0)
- ulog (LOG_NORMAL,
- "Protocol 'a' errors: bytes resent %lu, timeouts %lu, errors %lu",
- cZbytes_resent, cZtimeouts, cZerrors);
-
- /*
- * Reset all the parameters to their default values, so that the
- * protocol parameters used for this connection do not affect the
- * next one.
- */
-
- cZtimeout = CTIMEOUT;
- cZretries = CRETRIES;
- cZstartup_retries = CSTARTUP_RETRIES;
- cZmax_garbage = CGARBAGE;
- cZtx_window = CSEND_WINDOW;
- fZesc_ctl = FESCAPE_CONTROL;
-
- cZheaders_sent = cZheaders_received = cZbytes_resent = 0;
- cZtimeouts = cZerrors = 0;
-
- return TRUE;
-}
-
-/*
- * Send a command string ...
- * We send everything up to and including the null byte.
- *
- * We assume the command will fit in the outgoing data buffer.
- * FIXME: A valid assumption?
- */
-
-/*ARGSUSED*/
-boolean
-fzsendcmd(qdaemon, z, ilocal, iremote)
-struct sdaemon *qdaemon;
-const char *z;
-int ilocal;
-int iremote;
-{
- size_t n,clen;
- long lredo;
- char *zbuf;
-
- clen = strlen (z) + 1;
-
- DEBUG_MESSAGE1 (DEBUG_PROTO, "fzsendcmd: sending command %s", z);
-
- if (!fzstart_tx ()) /* must be called before zzgetspace() */
- return FALSE;
-
- if ((zbuf = zzgetspace (qdaemon, &n)) == NULL)
- return FALSE;
-
-#if DEBUG > 0
- if (clen > n)
- ulog (LOG_FATAL, "fzsendcmd: clen > n");
-#endif
-
- strcpy (zbuf, z);
-
- /*
- * Send it out ...
- */
-
- do {
- if (!fzsend_data (qdaemon, zbuf, clen, TRUE))
- return FALSE;
- if (!fzfinish_tx (qdaemon, &lredo))
- return FALSE;
- } while (lredo >= 0);
-
- return fzprocess (qdaemon);
-}
-
-/*
- * Allocate a packet to send out ...
- *
- * Note that 'z' has dynamic packet resizing and that <cZblklen> will range
- * from 32 to 1024, in multiples of 2.
- */
-
-/*ARGSUSED*/
-char *
-zzgetspace(qdaemon, pclen)
-struct sdaemon *qdaemon;
-size_t *pclen;
-{
- *pclen = cZblklen;
- return zZtx_buf;
-}
-
-/*
- * Send a block of data ...
- *
- * If (cdata == 0) then the end of the file has been reached.
- */
-
-/*ARGSUSED*/
-boolean
-fzsenddata(qdaemon, zdata, cdata, ilocal, iremote, ipos)
-struct sdaemon *qdaemon;
-char *zdata;
-size_t cdata;
-int ilocal;
-int iremote;
-long ipos;
-{
- DEBUG_MESSAGE1 (DEBUG_PROTO, "fzsenddata: %d bytes", cdata);
-
- if (! fzsend_data (qdaemon, zdata, cdata, cdata == 0))
- return FALSE;
- return fzprocess (qdaemon);
-}
-
-/*
- * Send a block of data (command or file) ...
- */
-
-/* This should buffer the data internally. Until it does, it needs to
- be able to reset the file position when it is called. This is
- really ugly. */
-extern struct stransfer *qTsend;
-
-static boolean
-fzsend_data(qdaemon, zdata, cdata, fendofmessage)
-struct sdaemon *qdaemon;
-char *zdata;
-size_t cdata;
-boolean fendofmessage;
-{
- size_t n;
-
- if (iZlast_tx_data_packet == -1 || iZlast_tx_data_packet == ZCRCW) {
- cZtxwcnt = cZrxwcnt = 0;
- iZjunk_count = 0;
- if (!fzsend_hdr (qdaemon, ZBIN, ZDATA,
- hvzencode_data_hdr (wpZtxpos), TRUE))
- return FALSE;
- }
-
- n = cdata;
-
- if (fendofmessage)
- iZlast_tx_data_packet = ZCRCF;
- else if (iZjunk_count > 3)
- iZlast_tx_data_packet = ZCRCW;
- else if (wpZtxpos == wpZlastsync)
- iZlast_tx_data_packet = ZCRCW;
- else if (cZrx_buf_len && (cZrxwcnt += n) >= cZrx_buf_len)
- iZlast_tx_data_packet = ZCRCW;
- else if ((cZtxwcnt += n) >= cZtxwspac) {
- iZlast_tx_data_packet = ZCRCQ;
- cZtxwcnt = 0;
- } else
- iZlast_tx_data_packet = ZCRCG;
-
- if (++iZtleft > 3) {
- iZtleft = 0;
- if (cZblklen < 1024)
- cZblklen *= 2;
-#if 0 /* <cZblklen_override> is currently unnecessary */
- if (cZblklen_override && cZblklen > cZblklen_override)
- cZblklen = cZblklen_override;
-#endif
- if (cZblklen > 1024)
- cZblklen = 1024;
- if (cZrx_buf_len && cZblklen > cZrx_buf_len)
- cZblklen = cZrx_buf_len;
- }
-
-#if DEBUG > 1
- if (FDEBUGGING(DEBUG_PROTO)) {
- const char *type;
-
- switch (iZlast_tx_data_packet) {
- case ZCRCW: type = "ZCRCW"; break;
- case ZCRCG: type = "ZCRCG"; break;
- case ZCRCQ: type = "ZCRCQ"; break;
- case ZCRCE: type = "ZCRCE"; break;
- case ZCRCF: type = "ZCRCF"; break;
- default : type = "UNKNOWN!!!"; break;
- }
- DEBUG_MESSAGE3 (DEBUG_PROTO,
- "fzsend_data: %s, pos 0x%lx, %d bytes",
- type, wpZtxpos, n);
- }
-#endif
-
- if (!fzsend_data_packet (qdaemon, zdata, n, iZlast_tx_data_packet,
- TRUE))
- return FALSE;
-
- wpZtxpos += n;
-
- if (iZlast_tx_data_packet == ZCRCW) {
- /*
- * FIXME: Ideally this would be done in fzprocess. However, it
- * is only called if there is data pending which there
- * may not be yet. I could have patched fploop() a bit but
- * for now, I've done it like this.
- */
- switch (getinsync (qdaemon, FALSE)) {
- case ZACK:
- break;
- case ZRPOS:
- if (qTsend == NULL
- || ! ffileisopen (qTsend->e)) {
- ulog (LOG_ERROR, "Can't reset non-file");
- return FALSE;
- }
- iZlast_tx_data_packet = -1; /* trigger ZDATA */
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "fzsend_data: Seeking to %ld",
- (long) (wpZrxpos - wpZtxstart));
- if (!ffileseek (qTsend->e, wpZrxpos - wpZtxstart)) {
- ulog (LOG_ERROR, "seek: %s", strerror (errno));
- return FALSE;
- }
- break;
- default:
- return FALSE;
- }
- return TRUE;
- }
-
- /*
- * If we've reached the maximum transmit window size, let the
- * receiver catch up ...
- *
- * I use (cZtx_window - 2048) to play it safe.
- */
-
- while (wpZtxpos - wpZlrxpos >= cZtx_window - 2048) {
- if (iZlast_tx_data_packet != ZCRCQ) {
- if (!fzsend_data_packet (qdaemon, zdata, (size_t) 0,
- iZlast_tx_data_packet = ZCRCQ,
- TRUE))
- return FALSE;
- }
- /*
- * FIXME: I'd rather not call ffileseek() in this file. When we
- * start buffering the outgoing data, the following
- * ffileseek() will disappear.
- */
- switch (getinsync (qdaemon, TRUE)) {
- case ZACK:
- break;
- case ZRPOS:
- if (qTsend == NULL
- || ! ffileisopen (qTsend->e)) {
- ulog (LOG_ERROR, "Can't reset non-file");
- return FALSE;
- }
- iZlast_tx_data_packet = -1; /* trigger ZDATA */
- DEBUG_MESSAGE1 (DEBUG_PROTO,
- "fzsend_data: Seeking to %ld",
- (long) (wpZrxpos - wpZtxstart));
- if (!ffileseek (qTsend->e, wpZrxpos - wpZtxstart)) {
- ulog (LOG_ERROR, "seek: %s", strerror (errno));
- return FALSE;
- }
- break;
- default:
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-/*
- * Process existing data ...
- */
-
-static boolean
-fzprocess(qdaemon)
-struct sdaemon *qdaemon;
-{
- int c,ch;
-
- while (fzreceive_ready ()) {
- READCHAR (qdaemon, ch, 1);
- switch (ch) {
- case ZPAD:
- /* see if we're detecting ZRPOS packets quickly */
- DEBUG_MESSAGE0 (DEBUG_PROTO,
- "fzprocess: possible ZRPOS packet");
- /* We just ate the ZPAD char that getinsync
- expects, so put it back. */
- iPrecstart = ((iPrecstart + CRECBUFLEN - 1)
- % CRECBUFLEN);
- c = getinsync (qdaemon, TRUE);
- if (c == ZACK)
- break;
- /* FIXME: sz does a TCFLSH here */
-#if 0 /* FIXME: Not sure if this is needed, or where to put it. */
- /* ZCRCE - dinna wanna starta ping-pong game */
- if (!fzsend_data_packet (qdaemon, zZtx_packet_buf,
- 0, ZCRCE, TRUE))
- return FALSE;
-#endif
- if (c == ZRPOS) {
- if (qTsend == NULL
- || ! ffileisopen (qTsend->e)) {
- ulog (LOG_ERROR,
- "Attempt to back up non-file");
- return FALSE;
- }
- if (! ffileseek (qTsend->e,
- wpZrxpos - wpZtxstart)) {
- ulog (LOG_ERROR,
- "seek: %s", strerror (errno));
- return FALSE;
- }
- iZlast_tx_data_packet = -1; /* trigger ZDATA */
- break; /* not returning is intentional */
- }
- return FALSE;
- case XOFF:
- case XOFF | 0200:
- READCHAR (qdaemon, ch, XON_WAIT);
- break;
- case CR:
- break;
- default:
- iZjunk_count++;
- break;
- }
- }
-
- return TRUE;
-}
-
-/*
- * Wait for data to come in.
- *
- * This continues processing until a complete file or command has been
- * received.
- */
-
-boolean
-fzwait(qdaemon)
-struct sdaemon *qdaemon;
-{
- int c,cerr,rxcount;
- boolean fexit;
- achdrval_t rx_hdr;
-
- if (!fzstart_rx ())
- return FALSE;
-
- cerr = cZretries;
-
- goto nxthdr;
-
- for (;;) {
- if (!fzsend_hdr (qdaemon, ZHEX, ZRPOS,
- hvzencode_data_hdr (wpZrxbytes), FALSE))
- return FALSE;
-nxthdr:
- c = izrecv_hdr (qdaemon, rx_hdr);
-
- switch (c) {
- case ZM_TIMEOUT:
- case ZNAK:
- if (--cerr < 0) {
- ulog (LOG_ERROR, "fzwait: retries exhausted");
- return FALSE;
- }
- continue;
- case ZM_ERROR:
- if (--cerr < 0) {
- ulog (LOG_ERROR, "fzwait: retries exhausted");
- return FALSE;
- }
- /*fport_break ();*/
- continue;
- case ZM_RCDO:
- case ZFIN:
- return FALSE;
- case ZRPOS:
- case ZACK:
- goto nxthdr; /* ignore, partner is out of sync */
- case ZDATA: {
- winpos_t rx_bytes;
-
- zdecode_data_hdr (rclhdr (rx_hdr), &rx_bytes);
- DEBUG_MESSAGE2 (DEBUG_PROTO,
- "fzwait: bytes(us,them) 0x%lx,0x%lx",
- wpZrxbytes, rx_bytes);
- if (rx_bytes != wpZrxbytes) {
- if (--cerr < 0) {
- ulog (LOG_ERROR,
- "fzwait: retries exhausted");
- return FALSE;
- }
- (void) zrdat32 (qdaemon, zZrx_packet_buf,
- 1024, &rxcount);
- /*fport_break ();*/
- /*
- * FIXME: Seems to me we should ignore this one
- * and go for a timeout, the theory being
- * that the appropriate ZRPOS has already
- * been sent. We're obviously out of sync.
- * /dje 92Mar10
- */
- continue; /* goto nxthdr? */
- }
-moredata:
- /*
- * Do not call fgot_data() with (rxcount == 0) if it's
- * not ZCRCF. fgot_data() will erroneously think this
- * is the end of the message.
- */
- c = zrdat32 (qdaemon, zZrx_packet_buf, 1024,
- &rxcount);
-#if DEBUG > 1
- if (FDEBUGGING(DEBUG_PROTO)) {
- const char *msg;
-
- if (c < 0) {
- msg = ZZHEADER_NAME(c);
- } else {
- switch (c) {
- case GOTCRCW: msg = "ZCRCW"; break;
- case GOTCRCG: msg = "ZCRCG"; break;
- case GOTCRCQ: msg = "ZCRCQ"; break;
- case GOTCRCE: msg = "ZCRCE"; break;
- case GOTCRCF: msg = "ZCRCF"; break;
- default : msg = NULL; break;
- }
- }
- if (msg != NULL)
- DEBUG_MESSAGE2 (DEBUG_PROTO,
- "fzwait: zrdat32: %s, %d bytes",
- msg, rxcount);
- else
- DEBUG_MESSAGE2 (DEBUG_PROTO,
- "fzwait: zrdat32: %d, %d bytes",
- c, rxcount);
- }
-#endif
- switch (c) {
- case ZM_ERROR: /* CRC error */
- cZerrors++;
- if (--cerr < 0) {
- ulog (LOG_ERROR,
- "fzwait: retries exhausted");
- return FALSE;
- }
- /*fport_break ();*/
- continue;
- case ZM_TIMEOUT:
- cZtimeouts++;
- if (--cerr < 0) {
- ulog (LOG_ERROR,
- "fzwait: retries exhausted");
- return FALSE;
- }
- continue;
- case ZM_RCDO:
- return FALSE;
- case GOTCRCW:
- iZlast_rx_data_packet = ZCRCW;
- cerr = cZretries;
- if (rxcount != 0
- && !fgot_data (qdaemon, zZrx_packet_buf,
- (size_t) rxcount,
- (const char *) NULL,
- (size_t) 0,
- -1, -1, (long) -1,
- TRUE, &fexit))
- return FALSE;
- wpZrxbytes += rxcount;
- if (!fzsend_hdr (qdaemon, ZHEX, ZACK,
- hvzencode_data_hdr (wpZrxbytes),
- FALSE))
- return FALSE;
- if (! fsend_data (qdaemon->qconn, &xon,
- (size_t) 1, FALSE))
- return FALSE;
- goto nxthdr;
- case GOTCRCQ:
- iZlast_rx_data_packet = ZCRCQ;
- cerr = cZretries;
- if (rxcount != 0
- && !fgot_data (qdaemon, zZrx_packet_buf,
- (size_t) rxcount,
- (const char *) NULL,
- (size_t) 0,
- -1, -1, (long) -1,
- TRUE, &fexit))
- return FALSE;
- wpZrxbytes += rxcount;
- if (!fzsend_hdr (qdaemon, ZHEX, ZACK,
- hvzencode_data_hdr (wpZrxbytes),
- FALSE))
- return FALSE;
- goto moredata;
- case GOTCRCG:
- iZlast_rx_data_packet = ZCRCG;
- cerr = cZretries;
- if (rxcount != 0
- && !fgot_data (qdaemon, zZrx_packet_buf,
- (size_t) rxcount,
- (const char *) NULL,
- (size_t) 0,
- -1, -1, (long) -1,
- TRUE, &fexit))
- return FALSE;
- wpZrxbytes += rxcount;
- goto moredata;
- case GOTCRCE:
- iZlast_rx_data_packet = ZCRCE;
- cerr = cZretries;
- if (rxcount != 0
- && !fgot_data (qdaemon, zZrx_packet_buf,
- (size_t) rxcount,
- (const char *) NULL,
- (size_t) 0,
- -1, -1, (long) -1,
- TRUE, &fexit))
- return FALSE;
- wpZrxbytes += rxcount;
- goto nxthdr;
- case GOTCRCF:
- iZlast_rx_data_packet = ZCRCF;
- /*
- * fzfinish_rx() must be called before
- * fgot_data() because fgot_data() will send
- * out a UUCP-command but the sender won't be
- * ready for it until it receives our final
- * ZACK.
- */
- cerr = cZretries;
- wpZrxbytes += rxcount;
- if (!fzfinish_rx (qdaemon))
- return FALSE;
- if (!fgot_data (qdaemon, zZrx_packet_buf,
- (size_t) rxcount,
- (const char *) NULL,
- (size_t) 0, -1, -1,
- (long) -1, TRUE, &fexit))
- return FALSE;
- /*
- * FIXME: Examine <fexit>?
- * Or maybe ensure it's TRUE?
- */
- return TRUE;
- }
- return FALSE;
- }
- default:
- ulog (LOG_FATAL, "fzwait: received header %s",
- ZZHEADER_NAME(c));
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-/*
- * File level routine. Called when initiating/terminating file transfers.
- *
- * When starting to send a file: (TRUE, TRUE, cbytes)
- * When starting to receive a file: (TRUE, FALSE, -1)
- * When send EOF, check resend: (FALSE, TRUE, -1)
- * When receive EOF, check re-receive: (FALSE, FALSE, -1)
- */
-
-boolean
-fzfile(qdaemon, qtrans, fstart, fsend, cbytes, pfhandled)
-struct sdaemon *qdaemon;
-struct stransfer *qtrans;
-boolean fstart;
-boolean fsend;
-long cbytes;
-boolean *pfhandled;
-{
- long iredo;
-
- *pfhandled = FALSE;
-
- DEBUG_MESSAGE2 (DEBUG_PROTO, "fzfile: fstart=%d, fsend=%d", fstart,
- fsend);
-
- if (fsend) {
- if (fstart)
- return fzstart_tx ();
- if (! fzfinish_tx (qdaemon, &iredo))
- return FALSE;
- if (iredo >= 0) {
- if (! ffileisopen (qtrans->e)) {
- ulog (LOG_ERROR,
- "Attempt to back up non-file");
- return FALSE;
- }
- if (! ffileseek (qtrans->e, iredo)) {
- ulog (LOG_ERROR,
- "seek: %s", strerror (errno));
- return FALSE;
- }
- *pfhandled = TRUE;
- qtrans->fsendfile = TRUE;
- return fqueue_send (qdaemon, qtrans);
- }
- }
-
- return TRUE;
-}
-
-/****************************************************************************/
-
-
-#if 0 /* not used, we only use 32 bit crc's */
-/*
- * crctab calculated by Mark G. Mendel, Network Systems Corporation
- */
-
-static unsigned short crctab[256] = {
- 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
- 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
- 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
- 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
- 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
- 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
- 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
- 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
- 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
- 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
- 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
- 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
- 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
- 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
- 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
- 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
- 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
- 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
- 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
- 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
- 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
- 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
- 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
- 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
- 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
- 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
- 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
- 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
- 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
- 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
- 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
- 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
-};
-#endif /* crctab */
-
-/*
- * Copyright (C) 1986 Gary S. Brown. You may use this program, or
- * code or tables extracted from it, as desired without restriction.
- */
-
-/* First, the polynomial itself and its table of feedback terms. The */
-/* polynomial is */
-/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
-/* Note that we take it "backwards" and put the highest-order term in */
-/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */
-/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */
-/* the MSB being 1. */
-
-/* Note that the usual hardware shift register implementation, which */
-/* is what we're using (we're merely optimizing it by doing eight-bit */
-/* chunks at a time) shifts bits into the lowest-order term. In our */
-/* implementation, that means shifting towards the right. Why do we */
-/* do it this way? Because the calculated CRC must be transmitted in */
-/* order from highest-order term to lowest-order term. UARTs transmit */
-/* characters in order from LSB to MSB. By storing the CRC this way, */
-/* we hand it to the UART in the order low-byte to high-byte; the UART */
-/* sends each low-bit to hight-bit; and the result is transmission bit */
-/* by bit from highest- to lowest-order term without requiring any bit */
-/* shuffling on our part. Reception works similarly. */
-
-/* The feedback terms table consists of 256, 32-bit entries. Notes: */
-/* */
-/* The table can be generated at runtime if desired; code to do so */
-/* is shown later. It might not be obvious, but the feedback */
-/* terms simply represent the results of eight shift/xor opera- */
-/* tions for all combinations of data and CRC register values. */
-/* */
-/* The values must be right-shifted by eight bits by the "updcrc" */
-/* logic; the shift must be unsigned (bring in zeroes). On some */
-/* hardware you could probably optimize the shift in assembler by */
-/* using byte-swap instructions. */
-
-static unsigned long crc_32_tab[] = { /* CRC polynomial 0xedb88320 */
- 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL,
- 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L,
- 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L,
- 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L,
- 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
- 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L,
- 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL,
- 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L,
- 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L,
- 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
- 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L,
- 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L,
- 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L,
- 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL,
- 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
- 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL,
- 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL,
- 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L,
- 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L,
- 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
- 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL,
- 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L,
- 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL,
- 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L,
- 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
- 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL,
- 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L,
- 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L,
- 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L,
- 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
- 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L,
- 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL,
- 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL,
- 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L,
- 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
- 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L,
- 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL,
- 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L,
- 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL,
- 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
- 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L,
- 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL,
- 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L,
- 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L,
- 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
- 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL,
- 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L,
- 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL,
- 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL,
- 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
- 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L,
- 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L,
- 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL,
- 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L,
- 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
- 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L,
- 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L,
- 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL,
- 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L,
- 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
- 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L,
- 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL,
- 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L,
- 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL
-};
-
-/*
- * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell.
- * NOTE: First argument must be in range 0 to 255.
- * Second argument is referenced twice.
- *
- * Programmers may incorporate any or all code into their programs,
- * giving proper credit within the source. Publication of the
- * source routines is permitted so long as proper credit is given
- * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
- * Omen Technology.
- */
-
-#define updcrc(cp, crc) (crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ cp)
-
-#define UPDC32(b, crc) \
- (crc_32_tab[((unsigned)(crc) ^ (unsigned)(b)) & 0xff] \
- ^ (((crc) >> 8) & 0x00ffffffL))
-
-/****************************************************************************/
-
-/*
- * This section contains the guts of the Zmodem protocol. The intention
- * is to leave as much of it alone as possible at the start. Overtime it
- * will be cleaned up (EG: I'd like to clean up the naming of the globals).
- * Also, Zmodem has a different coding style. Over time this will be converted
- * to the Taylor UUCP coding style.
- */
-
-/*
- * Start the protocol (exchange init packets) ...
- *
- * UUCP can transfer files in both directions in one session. Therefore the
- * init sequence is a little different.
- *
- * 1) ZINIT packets are exchanged
- * - contains protocol version and protocol flags
- * 2) ZDATA packets are exchanged
- * - is intended to contain various numeric and string information
- * 3) ZACK packets are exchanged
- * 4) ZINITEND packets are exchanged
- */
-
-static boolean
-fzstart_proto(qdaemon)
-struct sdaemon *qdaemon;
-{
- int i;
- achdrval_t tx_hdr,rx_hdr;
-
- for (i = 0; i < cZstartup_retries; i++) {
- stohdr (0L, tx_hdr);
- tx_hdr[ZF0] = ZPROTOCOL_VERSION;
- if (fZesc_ctl)
- tx_hdr[ZF1] |= TX_ESCCTL;
- switch (izexchange_init (qdaemon, ZINIT, tx_hdr, rx_hdr)) {
- case -1: return FALSE;
- case 0: continue;
- case 1: break;
- }
-#if 0 /* can't work, but kept for documentation */
- if (rx_hdr[ZF0] == 0) {
- ulog (LOG_ERROR, "Old protocol version, init failed");
- return FALSE;
- }
-#endif
- fZesc_ctl = fZesc_ctl || (rx_hdr[ZF1] & TX_ESCCTL) != 0;
-
- stohdr (0L, tx_hdr);
- switch (izexchange_init (qdaemon, ZDATA, tx_hdr, rx_hdr)) {
- case -1: return FALSE;
- case 0: continue;
- case 1: break;
- }
-
- stohdr (0L, tx_hdr);
- switch (izexchange_init (qdaemon, ZACK, tx_hdr, rx_hdr)) {
- case -1: return FALSE;
- case 0: continue;
- case 1: break;
- }
-
- stohdr (0L, tx_hdr);
- switch (izexchange_init (qdaemon, ZINITEND, tx_hdr, rx_hdr)) {
- case -1: return FALSE;
- case 0: continue;
- case 1: break;
- }
-
- DEBUG_MESSAGE0 (DEBUG_PROTO,
- "fzstart_proto: Protocol started");
- return TRUE;
-
- /* FIXME: see protg.c regarding sequencing here. */
- }
-
- ulog (LOG_ERROR, "Protocol init failed");
- return FALSE;
-}
-
-/*
- * Exchange init messages. This is based on 'g'.
- * See the comments concerning fgexchange_init() in protg.c.
- *
- * We return 1 for success, 0 for restart, -1 for comm failure (terminate).
- */
-
-static int
-izexchange_init(qdaemon, send_type, send_val, recv_val)
-struct sdaemon *qdaemon;
-int send_type;
-achdrval_t send_val;
-achdrval_t recv_val;
-{
- int i,recv_type,count;
-
- for (i = 0; i < CEXCHANGE_INIT_RETRIES; i++) {
- if (!fzsend_hdr (qdaemon, send_type == ZDATA ? ZBIN : ZHEX,
- send_type, rclhdr (send_val), FALSE))
- return -1;
-
- /*
- * The ZDATA packet is intended to contain the <Attn> string
- * (eventually, if it's ever usable) and allow for anything
- * else that will need to be thrown in.
- */
-
- if (send_type == ZDATA) {
- count = czbuild_data_packet (zZtx_packet_buf, "",
- (size_t) 1, ZCRCF);
- if (!fsend_data (qdaemon->qconn, zZtx_packet_buf,
- (size_t) count, FALSE))
- return -1;
- }
-
- recv_type = izrecv_hdr (qdaemon, recv_val);
-
- switch (recv_type) {
- case ZM_TIMEOUT:
- case ZM_ERROR:
- continue;
- case ZM_RCDO:
- case ZFIN:
- return -1;
- case ZINIT:
- case ZACK:
- case ZINITEND:
- break;
- case ZDATA:
- if (zrdat32 (qdaemon, zZrx_packet_buf, 1024, &count)
- == GOTCRCF)
- break;
- continue;
- default:
- continue;
- }
-
- if (recv_type == send_type)
- return 1;
-
- /*
- * If the other side is farther along than we are, we have lost
- * a packet. Fall immediately back to ZINIT (but don't fail
- * if we are already doing ZINIT, since that would count
- * against cStart_retries more than it should).
- *
- * FIXME: The ">" test is "<" in protg.c. Check who's right.
- */
-
- if (recv_type > send_type && send_type != ZINIT)
- return 0;
-
- /*
- * If we are sending ZINITEND and we receive an ZINIT, the
- * other side has falled back (we know this because we have
- * seen a ZINIT from them). Fall back ourselves to start
- * the whole handshake over again.
- */
-
- if (recv_type == ZINIT && send_type == ZINITEND)
- return 0;
- }
-
- return 0;
-}
-
-/*
- * Shut down the protocol ...
- */
-
-static boolean
-fzshutdown_proto(qdaemon)
-struct sdaemon *qdaemon;
-{
- (void) fzsend_hdr (qdaemon, ZHEX, ZFIN, 0L, FALSE);
- return TRUE;
-}
-
-/*
- * Reset the transmitter side for sending a new message ...
- */
-
-static boolean
-fzstart_tx()
-{
- iZlast_tx_data_packet = -1;
-
- /*
- * <wpZlastsync> is set to -1L to suppress ZCRCW request otherwise
- * triggered by (wpZlastsync == wpZtxpos).
- */
-
- cZblklen = 1024;
- wpZlastsync = -1L;
- iZbeenhereb4 = 0;
- iZtleft = 0;
- iZjunk_count = 0;
-
- wpZtxpos = (wpZtxpos + 1024L) & ~1023L; /* next packet boundary */
- wpZlrxpos = wpZrxpos = wpZtxpos;
-
- wpZtxstart = wpZtxpos; /* so we can compute the "file offset" */
-
- return TRUE;
-}
-
-/*
- * Finish the sending of a message ...
- *
- * Basically, we wait for some indication that the receiver received our last
- * message. If the receiver tells us to restart from some point, we set
- * *plredo to that point.
- *
- * FIXME: This function is a major kludge at the moment. It is taken from
- * getinsync(). It is necessary because I don't yet buffer outgoing data.
- * It will go away when we do (buffer outgoing data).
- */
-
-static boolean
-fzfinish_tx(qdaemon, plredo)
-struct sdaemon *qdaemon;
-long *plredo;
-{
- int c,cerr,ctimeouts;
- achdrval_t rx_hdr;
- winpos_t rx_bytes;
-
- *plredo = -1;
- cerr = cZretries;
- ctimeouts = 0;
-
- DEBUG_MESSAGE4 (DEBUG_PROTO,
- "fzfinish_tx: txpos=0x%lx, rxpos=0x%lx, lrxpos=0x%lx, rxbytes=0x%lx",
- wpZtxpos, wpZrxpos, wpZlrxpos, wpZrxbytes);
-
- for (;;) {
- c = izrecv_hdr (qdaemon, rx_hdr);
-
- switch (c) {
- case ZRPOS:
- wpZrxpos = lzupdate_rxpos (rx_hdr, wpZrxpos,
- wpZlrxpos, wpZtxpos);
- /*
- * If the receiver sends a ZRPOS for the 1k block after
- * the one we're currently at, we lost the final ZACK.
- * We cheat and ignore this ZRPOS. Remember: the theory
- * is that this entire function will go away when we
- * begin buffering the outgoing data. Of course, one
- * can reword the protocol definition and say this
- * isn't cheating at all.
- */
- if (((wpZtxpos + 1024) & ~1023) == wpZrxpos)
- return TRUE;
- cZbytes_resent += wpZtxpos - wpZrxpos;
- wpZlrxpos = wpZtxpos = wpZrxpos;
- if (wpZlastsync == wpZrxpos) {
- if (++iZbeenhereb4 > 4)
- if (cZblklen > 32)
- cZblklen /= 2;
- /* FIXME: shouldn't we reset iZbeenhereb4? */
- }
- wpZlastsync = wpZrxpos;
- iZlast_tx_data_packet = ZCRCW; /* force a timeout */
- *plredo = wpZrxpos - wpZtxstart;
- return TRUE;
- case ZACK:
- wpZrxpos = lzupdate_rxpos (rx_hdr, wpZrxpos,
- wpZlrxpos, wpZtxpos);
- wpZlrxpos = wpZrxpos;
- if (wpZtxpos == wpZrxpos) /* the ACK we want? */
- return TRUE;
- break;
- case ZDATA:
- /*
- * We cheat here and take advantage of UUCP's current
- * half duplex nature. If we get a ZDATA starting on
- * the next 1k boundary, we lost the ZACK. We cheat and
- * tuck it away so that izrecv_hdr() can later detect
- * it. Remember: see above.
- */
- zdecode_data_hdr (rclhdr (rx_hdr), &rx_bytes);
- if (((wpZrxbytes + 1024L) & ~1023L) == rx_bytes) {
- iZpkt_rcvd_kludge = ZDATA;
- hvZpkt_hdrval_kludge = rclhdr (rx_hdr);
- return TRUE;
- }
- break; /* ignore, out of sync (old) */
- case ZNAK:
- /*
- * We cheat here and take advantage of UUCP's current
- * half duplex nature. If we get a ZNAK starting on
- * the next 1k boundary, we lost the ZACK. We cheat and
- * throw the ZNAK away. Remember: see above.
- *
- * On the other hand, if (rx_bytes == wpZrxbytes) then
- * the other side is also in fzfinish_tx(). He must
- * have lost our ZACK, so we send him another.
- */
- zdecode_data_hdr (rclhdr (rx_hdr), &rx_bytes);
- if (((wpZrxbytes + 1024L) & ~1023L) == rx_bytes)
- return TRUE;
- if (rx_bytes == wpZrxbytes) {
- if (!fzsend_hdr (qdaemon, ZHEX, ZACK,
- hvzencode_data_hdr (wpZrxbytes),
- TRUE))
- return FALSE;
- }
- break; /* ignore, out of sync (old) */
- case ZFIN:
- case ZM_RCDO:
- return FALSE;
- case ZM_TIMEOUT:
- if (--cerr < 0) {
- ulog (LOG_ERROR,
- "fzfinish_tx: retries exhausted");
- return FALSE;
- }
- /*
- * Normally the sender doesn't send NAK's for timeouts.
- * We have to here because of the following scenario:
- *
- * - We send ZDATA/ZCRCF
- * - They send ZACK (corrupted)
- * - They send ZDATA/ZCRCF (corrupted)
- *
- * At this point, both sides are in fzfinish_tx().
- * We only send ZNAK every second timeout to increase
- * our timeout delay vs. our partner. This tries to
- * avoid ZRPOS and ZNAK "passing in transit".
- */
- if (++ctimeouts % 2 == 0)
- if (!fzsend_hdr (qdaemon, ZHEX, ZNAK,
- hvzencode_data_hdr (wpZtxpos),
- TRUE))
- return FALSE;
- break;
- case ZM_ERROR:
- default:
- if (--cerr < 0) {
- ulog (LOG_ERROR,
- "fzfinish_tx: retries exhausted");
- return FALSE;
- }
- if (!fzsend_hdr (qdaemon, ZHEX, ZNAK,
- hvzencode_data_hdr (wpZtxpos),
- TRUE))
- return FALSE;
- break;
- }
- }
-}
-
-/*
- * Initialize the receiver ...
- */
-
-static boolean
-fzstart_rx()
-{
- wpZrxbytes = (wpZrxbytes + 1024L) & ~1023L; /* next packet boundary */
-
- return TRUE;
-}
-
-/*
- * Terminate the receiver ...
- *
- * Acknowledge the last packet received.
- */
-
-static boolean
-fzfinish_rx(qdaemon)
-struct sdaemon *qdaemon;
-{
- DEBUG_MESSAGE0 (DEBUG_PROTO, "fzfinish_rx: message/file received");
-
- return fzsend_hdr (qdaemon, ZHEX, ZACK,
- hvzencode_data_hdr (wpZrxbytes), FALSE);
-}
-
-/*
- * Send a Zmodem header to our partner ...
- */
-
-static boolean
-fzsend_hdr(qdaemon, ipkttype, ihdrtype, hdrval, fcheckreceive)
-struct sdaemon *qdaemon;
-int ipkttype;
-int ihdrtype;
-hdrval_t hdrval;
-boolean fcheckreceive;
-{
- int cpacketlen;
-
- DEBUG_MESSAGE2 (DEBUG_PROTO, "fzsend_hdr: %s, data = 0x%lx",
- ZZHEADER_NAME(ihdrtype), hdrval);
-
- cpacketlen = czbuild_header (zZtx_packet_buf, ipkttype,
- ihdrtype, hdrval);
-
-#ifdef DJE_TESTING
-#if 0
- if (ihdrtype == ZACK && rand () % 100 < uucptest2) {
- cZheaders_sent++;
- return TRUE;
- }
-#else
- if (ihdrtype == ZACK || ihdrtype == ZDATA) {
- boolean fresult;
- int old;
- extern int uucptest,uucptest2;
-
- old = uucptest;
- uucptest = uucptest2;
- cZheaders_sent++;
- fresult = fsend_data (qdaemon->qconn, zZtx_packet_buf,
- (size_t) cpacketlen, fcheckreceive);
- uucptest = old;
- return fresult;
- }
-#endif
-#endif
- cZheaders_sent++;
- return fsend_data (qdaemon->qconn, zZtx_packet_buf,
- (size_t) cpacketlen, fcheckreceive);
-}
-
-/*
- * Send a data packet to our partner ...
- * <frameend> is one of ZCRCx.
- */
-
-static boolean
-fzsend_data_packet(qdaemon, zdata, cdata, frameend, fcheckreceive)
-struct sdaemon *qdaemon;
-char *zdata;
-size_t cdata;
-int frameend;
-boolean fcheckreceive;
-{
- int cpacketlen;
-
- cpacketlen = czbuild_data_packet (zZtx_packet_buf, zdata, cdata,
- frameend);
-
- return fsend_data (qdaemon->qconn, zZtx_packet_buf,
- (size_t) cpacketlen, fcheckreceive);
-}
-
-/*
- * Build Zmodem headers ...
- *
- * Note that we use 32 bit CRC's for ZHEX headers.
- *
- * This function is a combination of zm fns: zsbhdr(), zsbh32(), and zshhdr().
- */
-
-static int
-czbuild_header(zresult, ipkttype, ihdrtype, hdrval)
-char *zresult;
-int ipkttype;
-int ihdrtype;
-hdrval_t hdrval;
-{
- char *p;
- int i;
- unsigned long crc;
- achdrval_t achdrval;
-
- p = zresult;
-
- switch (ipkttype) {
- case ZBIN:
- *p++ = ZPAD;
- *p++ = ZDLE;
- *p++ = ZBIN;
- p = zputchar (p, ihdrtype);
- crc = ICRCINIT;
- crc = UPDC32 (ihdrtype, crc);
- stohdr (hdrval, achdrval);
- for (i = 0; i < 4; i++) {
- p = zputchar (p, achdrval[i]);
- crc = UPDC32 (achdrval[i], crc);
- }
- crc = ~crc;
- for (i = 0; i < 4; i++) {
- p = zputchar (p, (char) crc);
- crc >>= 8;
- }
- break;
- case ZHEX: /* build hex header */
- *p++ = ZPAD;
- *p++ = ZPAD;
- *p++ = ZDLE;
- *p++ = ZHEX;
- p = zputhex (p, ihdrtype);
- crc = ICRCINIT;
- crc = UPDC32 (ihdrtype, crc);
- stohdr (hdrval, achdrval);
- for (i = 0; i < 4; i++) {
- p = zputhex (p, achdrval[i]);
- crc = UPDC32 (achdrval[i], crc);
- }
- crc = ~crc;
- for (i = 0; i < 4; i++) {
- p = zputhex (p, (char) crc);
- crc >>= 8;
- }
- *p++ = CR;
- /*
- * Uncork the remote in case a fake XOFF has stopped data flow.
- */
- if (ihdrtype != ZFIN && ihdrtype != ZACK) /* FIXME: why? */
- *p++ = XON;
- break;
- default:
- ulog (LOG_FATAL, "czbuild_header: ipkttype == %d", ipkttype);
- break;
- }
-
- return p - zresult;
-}
-
-/*
- * Build Zmodem data packets ...
- *
- * This function is zsdata() and zsda32() from the zm source.
- */
-
-static int
-czbuild_data_packet(zresult, zdata, cdata, frameend)
-char *zresult;
-const char *zdata;
-size_t cdata;
-int frameend;
-{
- char *p;
- unsigned long crc;
-
- p = zresult;
-
- crc = ICRCINIT;
- for ( ; cdata-- != 0; zdata++) {
- char c;
-
- c = *zdata;
- if (c & 0140)
- *p++ = c;
- else
- p = zputchar (p, c);
- crc = UPDC32 ((unsigned char) c, crc);
- }
- *p++ = ZDLE;
- *p++ = frameend;
- crc = UPDC32 (frameend, crc);
- crc = ~crc;
- for (cdata = 0; cdata < 4; cdata++) {
- p = zputchar (p, (char) crc);
- crc >>= 8;
- }
- if (frameend == ZCRCW || frameend == ZCRCE || frameend == ZCRCF) {
- *p++ = CR;
- *p++ = XON;
- }
-
- return p - zresult;
-}
-
-/*
- * Read in a header ...
- *
- * This is function zgethdr() from the Zmodem source.
- */
-
-static int
-izrecv_hdr(qdaemon, hdr)
-struct sdaemon *qdaemon;
-achdrval_t hdr;
-{
- int c,cerr;
-
- /*
- * Kludge alert! If another part of the program received a packet but
- * wasn't ready to handle it, it is tucked away for us to handle now.
- */
-
- if (iZpkt_rcvd_kludge != -1) {
- c = iZpkt_rcvd_kludge;
- iZpkt_rcvd_kludge = -1;
- stohdr (hvZpkt_hdrval_kludge, hdr);
- DEBUG_MESSAGE2 (DEBUG_PROTO,
- "izrecv_hdr: queued %s, data = 0x%lx",
- ZZHEADER_NAME(c), rclhdr (hdr));
- cZheaders_received++;
- return c;
- }
-
- cerr = cZmax_garbage; /* Max bytes before start of frame */
-
-again:
- switch (c = noxrd7 (qdaemon)) {
- case ZM_TIMEOUT:
- case ZM_ERROR:
- case ZM_RCDO:
- goto fifi;
- case ZPAD: /* This is what we want */
- break;
- case CR: /* padding at end of previous header */
- default:
- if (--cerr < 0) {
- c = ZM_ERROR;
- goto fifi;
- }
- goto again;
- }
-
-splat:
- switch (c = noxrd7 (qdaemon)) {
- case ZPAD:
- if (--cerr < 0) {
- c = ZM_ERROR;
- goto fifi;
- }
- goto splat;
- case ZM_TIMEOUT:
- case ZM_RCDO:
- goto fifi;
- case ZDLE: /* This is what we want */
- break;
- default:
- if (--cerr < 0) {
- c = ZM_ERROR;
- goto fifi;
- }
- goto again;
- }
-
- switch (c = noxrd7 (qdaemon)) {
- case ZM_TIMEOUT:
- case ZM_RCDO:
- goto fifi;
- case ZBIN:
- c = zrbhdr32 (qdaemon, hdr);
- break;
- case ZHEX:
- c = zrhhdr (qdaemon, hdr);
- break;
- default:
- if (--cerr < 0) {
- c = ZM_ERROR;
- goto fifi;
- }
- goto again;
- }
-
-fifi:
- switch (c) {
- case ZM_TIMEOUT:
- cZtimeouts++;
- break;
- case ZM_ERROR:
- cZerrors++;
- break;
- case ZM_RCDO:
- break;
- default:
- cZheaders_received++;
- break;
- }
- DEBUG_MESSAGE2 (DEBUG_PROTO, "izrecv_hdr: %s, data = 0x%lx",
- ZZHEADER_NAME(c), rclhdr (hdr));
-
- return c;
-}
-
-/*
- * Receive a binary style header (type and position) with 32 bit FCS ...
- */
-
-static int
-zrbhdr32(qdaemon, hdr)
-struct sdaemon *qdaemon;
-achdrval_t hdr;
-{
- int c,i,type;
- unsigned long crc;
-
- if ((c = zdlread (qdaemon)) & ~0377)
- return c;
- type = c;
- crc = ICRCINIT;
- crc = UPDC32 (c, crc);
-
- for (i = 0; i < 4; i++) {
- if ((c = zdlread (qdaemon)) & ~0377)
- return c;
- crc = UPDC32 (c, crc);
- hdr[i] = (char) c;
- }
- for (i = 0; i < 4; i++) {
- if ((c = zdlread (qdaemon)) & ~0377)
- return c;
- crc = UPDC32 (c, crc);
- }
- if (crc != IHDRCRC)
- return ZM_ERROR;
-
- return type;
-}
-
-/*
- * Receive a hex style header (type and position) ...
- */
-
-static int
-zrhhdr(qdaemon, hdr)
-struct sdaemon *qdaemon;
-achdrval_t hdr;
-{
- int c,i,type;
- unsigned long crc;
-
- if ((c = zgethex (qdaemon)) < 0)
- return c;
- type = c;
- crc = ICRCINIT;
- crc = UPDC32 (c, crc);
-
- for (i = 0; i < 4; i++) {
- if ((c = zgethex (qdaemon)) < 0)
- return c;
- crc = UPDC32 (c, crc);
- hdr[i] = (char) c;
- }
- for (i = 0; i < 4; i++) {
- if ((c = zgethex (qdaemon)) < 0)
- return c;
- crc = UPDC32 (c, crc);
- }
- if (crc != IHDRCRC)
- return ZM_ERROR;
-
- return type;
-}
-
-/*
- * Receive a data packet ...
- */
-
-static int
-zrdat32(qdaemon, buf, length, iprxcount)
-struct sdaemon *qdaemon;
-char *buf;
-int length;
-int *iprxcount;
-{
- int c,d;
- unsigned long crc;
- char *end;
-
- crc = ICRCINIT;
- *iprxcount = 0;
- end = buf + length;
- while (buf <= end) {
- if ((c = zdlread (qdaemon)) & ~0377) {
-crcfoo:
- switch (c) {
- case GOTCRCE:
- case GOTCRCG:
- case GOTCRCQ:
- case GOTCRCW:
- case GOTCRCF:
- d = c;
- c &= 0377;
- crc = UPDC32 (c, crc);
- if ((c = zdlread (qdaemon)) & ~0377)
- goto crcfoo;
- crc = UPDC32 (c, crc);
- if ((c = zdlread (qdaemon)) & ~0377)
- goto crcfoo;
- crc = UPDC32 (c, crc);
- if ((c = zdlread (qdaemon)) & ~0377)
- goto crcfoo;
- crc = UPDC32 (c, crc);
- if ((c = zdlread (qdaemon)) & ~0377)
- goto crcfoo;
- crc = UPDC32 (c, crc);
- if (crc != IHDRCRC)
- return ZM_ERROR;
- *iprxcount = length - (end - buf);
- return d;
- case ZM_TIMEOUT:
- case ZM_RCDO:
- return c;
- default:
- return ZM_ERROR;
- }
- }
- *buf++ = (char) c;
- crc = UPDC32 (c, crc);
- }
-
- return ZM_ERROR; /* bad packet, too long */
-}
-
-/*
- * Respond to receiver's complaint, get back in sync with receiver ...
- */
-
-static int
-getinsync(qdaemon, flag)
-struct sdaemon *qdaemon;
-boolean flag;
-{
- int c,cerr;
- achdrval_t rx_hdr;
-
- cerr = cZretries;
-
- for (;;) {
- c = izrecv_hdr (qdaemon, rx_hdr);
-
- switch (c) {
- case ZRPOS:
- wpZrxpos = lzupdate_rxpos (rx_hdr, wpZrxpos,
- wpZlrxpos, wpZtxpos);
- cZbytes_resent += wpZtxpos - wpZrxpos;
- wpZlrxpos = wpZtxpos = wpZrxpos;
- if (wpZlastsync == wpZrxpos) {
- if (++iZbeenhereb4 > 4)
- if (cZblklen > 32)
- cZblklen /= 2;
- /* FIXME: shouldn't we reset iZbeenhereb4? */
- }
- wpZlastsync = wpZrxpos;
- return ZRPOS;
- case ZACK:
- wpZrxpos = lzupdate_rxpos (rx_hdr, wpZrxpos,
- wpZlrxpos, wpZtxpos);
- wpZlrxpos = wpZrxpos;
- if (flag || wpZtxpos == wpZrxpos)
- return ZACK;
- break;
- case ZNAK: {
- winpos_t rx_bytes;
- /*
- * Our partner is in fzfinish_tx() and is waiting
- * for ZACK ...
- */
- zdecode_data_hdr (rclhdr (rx_hdr), &rx_bytes);
- if (rx_bytes == wpZrxbytes) {
- if (!fzsend_hdr (qdaemon, ZHEX, ZACK,
- hvzencode_data_hdr (wpZrxbytes),
- TRUE))
- return FALSE;
- }
- break;
- }
- case ZFIN:
- case ZM_RCDO:
- return c;
- case ZM_TIMEOUT:
- if (--cerr < 0) {
- ulog (LOG_ERROR,
- "getinsync: retries exhausted");
- return ZM_ERROR;
- }
- break; /* sender doesn't send ZNAK for timeout */
- case ZM_ERROR:
- default:
- if (--cerr < 0) {
- ulog (LOG_ERROR,
- "getinsync: retries exhausted");
- return ZM_ERROR;
- }
- if (!fzsend_hdr (qdaemon, ZHEX, ZNAK,
- hvzencode_data_hdr (wpZtxpos),
- TRUE))
- return ZM_ERROR;
- break;
- }
- }
-}
-
-/*
- * Send a byte as two hex digits ...
- */
-
-static char *
-zputhex(p, ch)
-char *p;
-int ch;
-{
- static char digits[] = "0123456789abcdef";
-
- *p++ = digits[(ch & 0xF0) >> 4];
- *p++ = digits[ch & 0xF];
- return p;
-}
-
-/*
- * Send character c with ZMODEM escape sequence encoding ...
- *
- * Escape XON, XOFF.
- * FIXME: Escape CR following @ (Telenet net escape) ... disabled for now
- * Will need to put back references to <lastsent>.
- */
-
-static char *
-zputchar(p, ch)
-char *p;
-int ch;
-{
- char c = ch;
-
- /* Quick check for non control characters */
-
- if (c & 0140) {
- *p++ = c;
- } else {
- switch (c & 0377) {
- case ZDLE:
- *p++ = ZDLE;
- *p++ = c ^ 0100;
- break;
- case CR:
-#if 0
- if (!fZesc_ctl && (lastsent & 0177) != '@')
- goto sendit;
-#endif
- /* fall through */
- case 020: /* ^P */
- case XON:
- case XOFF:
- *p++ = ZDLE;
- c ^= 0100;
-/*sendit:*/
- *p++ = c;
- break;
- default:
- if (fZesc_ctl && !(c & 0140)) {
- *p++ = ZDLE;
- c ^= 0100;
- }
- *p++ = c;
- break;
- }
- }
-
- return p;
-}
-
-/*
- * Decode two lower case hex digits into an 8 bit byte value ...
- */
-
-static int
-zgethex(qdaemon)
-struct sdaemon *qdaemon;
-{
- int c,n;
-
- if ((c = noxrd7 (qdaemon)) < 0)
- return c;
- n = c - '0';
- if (n > 9)
- n -= ('a' - ':');
- if (n & ~0xF)
- return ZM_ERROR;
- if ((c = noxrd7 (qdaemon)) < 0)
- return c;
- c -= '0';
- if (c > 9)
- c -= ('a' - ':');
- if (c & ~0xF)
- return ZM_ERROR;
- c += (n << 4);
-
- return c;
-}
-
-/*
- * Read a byte, checking for ZMODEM escape encoding ...
- */
-
-static int
-zdlread(qdaemon)
-struct sdaemon *qdaemon;
-{
- int c;
-
-again:
- READCHAR (qdaemon, c, cZtimeout);
- if (c < 0)
- return c;
- if (c & 0140) /* quick check for non control characters */
- return c;
- switch (c) {
- case ZDLE:
- break;
- case XON:
- goto again;
- case XOFF:
- READCHAR (qdaemon, c, XON_WAIT);
- goto again;
- default:
- if (fZesc_ctl && !(c & 0140))
- goto again;
- return c;
- }
-
-again2:
- READCHAR (qdaemon, c, cZtimeout);
- if (c < 0)
- return c;
- switch (c) {
- case ZCRCE:
- case ZCRCG:
- case ZCRCQ:
- case ZCRCW:
- case ZCRCF:
- return c | GOTOR;
- case ZRUB0: /* FIXME: This is never generated. */
- return 0177;
- case ZRUB1: /* FIXME: This is never generated. */
- return 0377;
- case XON:
- goto again2;
- case XOFF:
- READCHAR (qdaemon, c, XON_WAIT);
- goto again2;
- default:
- if (fZesc_ctl && !(c & 0140))
- goto again2; /* FIXME: why again2? */
- if ((c & 0140) == 0100)
- return c ^ 0100;
- break;
- }
-
- return ZM_ERROR;
-}
-
-/*
- * Read a character from the modem line with timeout ...
- * Eat parity bit, XON and XOFF characters.
- */
-
-static int
-noxrd7(qdaemon)
-struct sdaemon *qdaemon;
-{
- int c;
-
- for (;;) {
- READCHAR (qdaemon, c, cZtimeout);
- if (c < 0)
- return c;
- switch (c &= 0177) {
- case XON:
- continue;
- case XOFF:
- READCHAR (qdaemon, c, XON_WAIT);
- continue;
- case CR:
- case ZDLE:
- return c;
- default:
- if (fZesc_ctl && !(c & 0140))
- continue;
- return c;
- }
- }
-}
-
-/*
- * Read a character from the receive buffer, or from the line if empty ...
- *
- * <timeout> is in seconds (maybe make it tenths of seconds like in Zmodem?)
- */
-
-static int
-realreadchar(qdaemon, timeout)
-struct sdaemon *qdaemon;
-int timeout;
-{
- int c;
-
- if ((c = breceive_char (qdaemon->qconn, timeout, TRUE)) >= 0)
- return c;
-
- switch (c) {
- case -1:
- return ZM_TIMEOUT;
- case -2:
- return ZM_RCDO;
- }
-
- ulog (LOG_FATAL, "realreadchar: breceive_char() returned %d", c);
- return ZM_ERROR;
-}
-
-
-/*
- * Check if the receive channel has any characters in it.
- *
- * At present we can only test the receive buffer. No mechanism is available
- * to go to the hardware. This should not be a problem though, as long as all
- * appropriate calls to fsend_data() set <fdoread> to TRUE.
- */
-
-static boolean
-fzreceive_ready()
-{
- return iPrecstart != iPrecend;
-}
-
-/*
- * Store integer value in an achdrval_t ...
- */
-
-static void
-stohdr(val, hdr)
-hdrval_t val;
-achdrval_t hdr;
-{
- hdr[ZP0] = (char) val;
- hdr[ZP1] = (char) (val >> 8);
- hdr[ZP2] = (char) (val >> 16);
- hdr[ZP3] = (char) (val >> 24);
-}
-
-/*
- * Recover an integer from a header ...
- */
-
-static hdrval_t
-rclhdr(hdr)
-achdrval_t hdr;
-{
- hdrval_t v;
-
- v = hdr[ZP3] & 0377;
- v = (v << 8) | (hdr[ZP2] & 0377);
- v = (v << 8) | (hdr[ZP1] & 0377);
- v = (v << 8) | (hdr[ZP0] & 0377);
-
- return v;
-}
-
-/*
- * Encode a <hdrval_t> from the byte count ...
- *
- * We use to store the byte count / 32 and a message sequence number which
- * made this function very useful. Don't remove it.
- * FIXME: Well, maybe remove it later.
- */
-
-static hdrval_t
-hvzencode_data_hdr(cbytes)
-winpos_t cbytes;
-{
- return (hdrval_t) cbytes;
-}
-
-/*
- * Decode a <hdrval_t> into a byte count ...
- *
- * We use to store the byte count / 32 and a message sequence number which
- * made this function very useful. Don't remove it.
- * FIXME: Well, maybe remove it later.
- */
-
-static void
-zdecode_data_hdr(hdrval, pcbytes)
-hdrval_t hdrval;
-winpos_t *pcbytes;
-{
- *pcbytes = hdrval;
-}
-
-/*
- * Update <wpZrxpos> from the received data header value ...
- *
- * FIXME: Here is where we'd handle wrapping around at 4 gigabytes.
- */
-
-static winpos_t
-lzupdate_rxpos(rx_hdr, rxpos, lrxpos, txpos)
-achdrval_t rx_hdr;
-winpos_t rxpos,lrxpos,txpos;
-{
- winpos_t rx_pktpos;
-
- zdecode_data_hdr (rclhdr (rx_hdr), &rx_pktpos);
-
- DEBUG_MESSAGE4 (DEBUG_PROTO,
- "lzupdate_rxpos: rx_pktpos=0x%lx, rxpos=0x%lx, lrxpos=0x%lx, txpos=0x%lx",
- rx_pktpos, rxpos, lrxpos, txpos);
-
- /*
- * Check if <rx_pktpos> valid. It could be old.
- */
-
- if (rx_pktpos < wpZlrxpos
- || rx_pktpos > ((wpZtxpos + 1024L) & ~1023L))
- return rxpos;
-
- return rx_pktpos;
-}
diff --git a/gnu/libexec/uucp/uucico/rec.c b/gnu/libexec/uucp/uucico/rec.c
deleted file mode 100644
index 04fad83..0000000
--- a/gnu/libexec/uucp/uucico/rec.c
+++ /dev/null
@@ -1,1309 +0,0 @@
-/* rec.c
- Routines to receive a file.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char rec_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "prot.h"
-#include "trans.h"
-
-/* If the other side does not tell us the size of a file it wants to
- send us, we assume it is this long. This is only used for free
- space checking. */
-#define CASSUMED_FILE_SIZE (10240)
-
-/* We keep this information in the pinfo field of the stransfer
- structure. */
-struct srecinfo
-{
- /* Local user to send mail to (may be NULL). */
- char *zmail;
- /* Full file name. */
- char *zfile;
- /* Temporary file name. */
- char *ztemp;
- /* TRUE if this is a spool directory file. */
- boolean fspool;
- /* TRUE if this was a local request. */
- boolean flocal;
- /* TRUE if the file has been completely received. */
- boolean freceived;
- /* TRUE if remote request has been replied to. */
- boolean freplied;
- /* TRUE if we moved the file to the final destination. */
- boolean fmoved;
-};
-
-/* This structure is kept in the pinfo field if we are refusing a
- remote request. */
-struct srecfailinfo
-{
- /* Reason for refusal. */
- enum tfailure twhy;
- /* TRUE if we have sent the reason for refusal. */
- boolean fsent;
- /* TRUE if we have seen the end of the file. */
- boolean freceived;
-};
-
-/* Local functions. */
-
-static void urrec_free P((struct stransfer *qtrans));
-static boolean flocal_rec_fail P((struct stransfer *qtrans,
- struct scmd *qcmd,
- const struct uuconf_system *qsys,
- const char *zwhy));
-static boolean flocal_rec_send_request P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean flocal_rec_await_reply P((struct stransfer *qtrans,
- struct sdaemon *qdaemon,
- const char *zdata,
- size_t cdata));
-static boolean fremote_send_reply P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean fremote_send_fail P((struct sdaemon *qdaemon,
- struct scmd *qcmd,
- enum tfailure twhy,
- int iremote));
-static boolean fremote_send_fail_send P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean fremote_discard P((struct stransfer *qtrans,
- struct sdaemon *qdaemon,
- const char *zdata, size_t cdata));
-static boolean frec_file_end P((struct stransfer *qtrans,
- struct sdaemon *qdaemon,
- const char *zdata, size_t cdata));
-static boolean frec_file_send_confirm P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-
-/* Free up a receive stransfer structure. */
-
-static void
-urrec_free (qtrans)
- struct stransfer *qtrans;
-{
- struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo;
-
- if (qinfo != NULL)
- {
- ubuffree (qinfo->zmail);
- ubuffree (qinfo->zfile);
- ubuffree (qinfo->ztemp);
- xfree (qtrans->pinfo);
- }
-
- utransfree (qtrans);
-}
-
-/* Set up a request for a file from the remote system. This may be
- called before the remote system has been called.
-
- This is the order of function calls:
-
- flocal_rec_file_init --> fqueue_local
- flocal_rec_send_request (send R ...) --> fqueue_receive
- flocal_rec_await_reply (open file, call pffile) --> fqueue_receive
- receive file
- frec_file_end (close and move file, call pffile) --> fqueue_send
- frec_file_send_confirm (send CY)
- */
-
-boolean
-flocal_rec_file_init (qdaemon, qcmd)
- struct sdaemon *qdaemon;
- struct scmd *qcmd;
-{
- const struct uuconf_system *qsys;
- boolean fspool;
- char *zfile;
- struct srecinfo *qinfo;
- struct stransfer *qtrans;
-
- qsys = qdaemon->qsys;
-
- /* Make sure we are permitted to transfer files. */
- if (qdaemon->fcaller
- ? ! qsys->uuconf_fcall_transfer
- : ! qsys->uuconf_fcalled_transfer)
- {
- /* This case will have been checked by uucp or uux, but it could
- have changed. */
- if (! qsys->uuconf_fcall_transfer
- && ! qsys->uuconf_fcalled_transfer)
- return flocal_rec_fail ((struct stransfer *) NULL, qcmd, qsys,
- "not permitted to request files");
- return TRUE;
- }
-
- fspool = fspool_file (qcmd->zto);
-
- if (fspool)
- {
- pointer puuconf;
- int iuuconf;
- const char *zlocalname;
- struct uuconf_system slocalsys;
-
- /* Normal users are not allowed to request files to be received
- into the spool directory. To support uux forwarding, we use
- the special option '9'. This permits a file to be received
- into the spool directory for the local system only without
- the usual checking. This is only done for local requests, of
- course. */
- if (qcmd->zto[0] != 'D'
- || strchr (qcmd->zoptions, '9') == NULL)
- return flocal_rec_fail ((struct stransfer *) NULL, qcmd, qsys,
- "not permitted to receive");
-
- puuconf = qdaemon->puuconf;
- iuuconf = uuconf_localname (puuconf, &zlocalname);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- zlocalname = zsysdep_localname ();
- if (zlocalname == NULL)
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
-
- iuuconf = uuconf_system_info (puuconf, zlocalname, &slocalsys);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- iuuconf = uuconf_system_local (puuconf, &slocalsys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
- slocalsys.uuconf_zname = (char *) zlocalname;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
-
- zfile = zsysdep_spool_file_name (&slocalsys, qcmd->zto, qcmd->pseq);
-
- (void) uuconf_system_free (puuconf, &slocalsys);
-
- if (zfile == NULL)
- return FALSE;
- }
- else
- {
- zfile = zsysdep_add_base (qcmd->zto, qcmd->zfrom);
- if (zfile == NULL)
- return FALSE;
-
- /* Check permissions. */
- if (! fin_directory_list (zfile, qsys->uuconf_pzlocal_receive,
- qsys->uuconf_zpubdir, TRUE,
- FALSE, qcmd->zuser))
- {
- ubuffree (zfile);
- return flocal_rec_fail ((struct stransfer *) NULL, qcmd, qsys,
- "not permitted to receive");
- }
-
- /* The 'f' option means that directories should not
- be created if they do not already exist. */
- if (strchr (qcmd->zoptions, 'f') == NULL)
- {
- if (! fsysdep_make_dirs (zfile, TRUE))
- {
- ubuffree (zfile);
- return flocal_rec_fail ((struct stransfer *) NULL, qcmd,
- qsys, "cannot create directories");
- }
- }
- }
-
- qinfo = (struct srecinfo *) xmalloc (sizeof (struct srecinfo));
- if (strchr (qcmd->zoptions, 'm') == NULL)
- qinfo->zmail = NULL;
- else
- qinfo->zmail = zbufcpy (qcmd->zuser);
- qinfo->zfile = zfile;
- qinfo->ztemp = NULL;
- qinfo->fspool = fspool;
- qinfo->flocal = TRUE;
- qinfo->freceived = FALSE;
- qinfo->freplied = TRUE;
-
- qtrans = qtransalc (qcmd);
- qtrans->psendfn = flocal_rec_send_request;
- qtrans->pinfo = (pointer) qinfo;
-
- return fqueue_local (qdaemon, qtrans);
-}
-
-/* Report an error for a local receive request. */
-
-static boolean
-flocal_rec_fail (qtrans, qcmd, qsys, zwhy)
- struct stransfer *qtrans;
- struct scmd *qcmd;
- const struct uuconf_system *qsys;
- const char *zwhy;
-{
- if (zwhy != NULL)
- {
- ulog (LOG_ERROR, "%s: %s", qcmd->zfrom, zwhy);
- (void) fmail_transfer (FALSE, qcmd->zuser, (const char *) NULL, zwhy,
- qcmd->zfrom, qsys->uuconf_zname,
- qcmd->zto, (const char *) NULL,
- (const char *) NULL);
- (void) fsysdep_did_work (qcmd->pseq);
- }
- if (qtrans != NULL)
- urrec_free (qtrans);
- return TRUE;
-}
-
-/* This is called when we are ready to send the actual request to the
- other system. */
-
-static boolean
-flocal_rec_send_request (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo;
- long cbytes, cbytes2;
- size_t clen;
- char *zsend;
- boolean fret;
-
- qinfo->ztemp = zsysdep_receive_temp (qdaemon->qsys, qinfo->zfile,
- (const char *) NULL,
- (qdaemon->qproto->frestart
- && (qdaemon->ifeatures
- & FEATURE_RESTART) != 0));
- if (qinfo->ztemp == NULL)
- {
- urrec_free (qtrans);
- return FALSE;
- }
-
- qtrans->fcmd = TRUE;
- qtrans->precfn = flocal_rec_await_reply;
-
- if (! fqueue_receive (qdaemon, qtrans))
- return FALSE;
-
- /* Check the amount of free space available for both the temporary
- file and the real file. */
- cbytes = csysdep_bytes_free (qinfo->ztemp);
- cbytes2 = csysdep_bytes_free (qinfo->zfile);
- if (cbytes < cbytes2)
- cbytes = cbytes2;
- if (cbytes != -1)
- {
- cbytes -= qdaemon->qsys->uuconf_cfree_space;
- if (cbytes < 0)
- cbytes = 0;
- }
-
- if (qdaemon->clocal_size != -1
- && (cbytes == -1 || qdaemon->clocal_size < cbytes))
- cbytes = qdaemon->clocal_size;
-
- /* We send the string
- R from to user options
-
- We put a dash in front of options. If we are talking to a
- counterpart, we also send the maximum size file we are prepared
- to accept, as returned by esysdep_open_receive. */
- clen = (strlen (qtrans->s.zfrom) + strlen (qtrans->s.zto)
- + strlen (qtrans->s.zuser) + strlen (qtrans->s.zoptions) + 30);
- zsend = zbufalc (clen);
- if ((qdaemon->ifeatures & FEATURE_SIZES) == 0)
- sprintf (zsend, "R %s %s %s -%s", qtrans->s.zfrom, qtrans->s.zto,
- qtrans->s.zuser, qtrans->s.zoptions);
- else if ((qdaemon->ifeatures & FEATURE_V103) == 0)
- sprintf (zsend, "R %s %s %s -%s 0x%lx", qtrans->s.zfrom, qtrans->s.zto,
- qtrans->s.zuser, qtrans->s.zoptions, (unsigned long) cbytes);
- else
- sprintf (zsend, "R %s %s %s -%s %ld", qtrans->s.zfrom, qtrans->s.zto,
- qtrans->s.zuser, qtrans->s.zoptions, cbytes);
-
- fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, qtrans->ilocal,
- qtrans->iremote);
- ubuffree (zsend);
-
- /* There is a potential space leak here: if pfsendcmd fails, we
- might need to free qtrans. However, it is possible that by the
- time pfsendcmd returns, a response will have been received which
- led to the freeing of qtrans anyhow. One way to fix this would
- be some sort of counter in qtrans to track allocations, but since
- the space leak is small, and the conversation has failed anyhow,
- it doesn't seem worth it. */
-
- return fret;
-}
-
-/* This is called when a reply is received for the request. */
-
-/*ARGSUSED*/
-static boolean
-flocal_rec_await_reply (qtrans, qdaemon, zdata, cdata)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
- const char *zdata;
- size_t cdata;
-{
- struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo;
- const char *zlog;
- char *zend;
-
- if (zdata[0] != 'R'
- || (zdata[1] != 'Y' && zdata[1] != 'N'))
- {
- ulog (LOG_ERROR, "%s: bad response to receive request: \"%s\"",
- qtrans->s.zfrom, zdata);
- urrec_free (qtrans);
- return FALSE;
- }
-
- if (zdata[1] == 'N')
- {
- boolean fnever;
- const char *zerr;
-
- fnever = TRUE;
- if (zdata[2] == '2')
- zerr = "no such file";
- else if (zdata[2] == '6')
- {
- /* We sent over the maximum file size we were prepared to
- receive, and the remote system is telling us that the
- file is larger than that. Try again later. It would be
- better if we could know whether there will ever be enough
- room. */
- zerr = "too large to receive now";
- fnever = FALSE;
- }
- else if (zdata[2] == '9')
- {
- /* Remote has run out of channels. */
- zerr = "too many channels for remote";
- fnever = FALSE;
-
- /* Drop one channel; using exactly one channel causes
- slightly different behahaviour in a few places, so don't
- decrement to one. */
- if (qdaemon->cchans > 2)
- --qdaemon->cchans;
- }
- else
- zerr = "unknown reason";
-
- if (fnever)
- return flocal_rec_fail (qtrans, &qtrans->s, qdaemon->qsys, zerr);
-
- ulog (LOG_ERROR, "%s: %s", qtrans->s.zfrom, zerr);
-
- urrec_free (qtrans);
-
- return TRUE;
- }
-
- /* The mode should have been sent as "RY 0%o". If it wasn't, we use
- 0666. */
- qtrans->s.imode = (unsigned int) strtol ((char *) (zdata + 2),
- &zend, 8);
- if (qtrans->s.imode == 0)
- qtrans->s.imode = 0666;
-
- /* If there is an M after the mode, the remote has requested a
- hangup. */
- if (*zend == 'M' && qdaemon->fmaster)
- {
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO,
- "flocal_rec_await_reply: Remote has requested transfer of control");
- qdaemon->fhangup_requested = TRUE;
- }
-
- /* Open the file to receive into. We just ignore any restart count,
- since we have no way to tell it to the other side. SVR4 may have
- some way to do this, but I don't know what it is. */
- qtrans->e = esysdep_open_receive (qdaemon->qsys, qinfo->zfile,
- (const char *) NULL, qinfo->ztemp,
- (long *) NULL);
- if (! ffileisopen (qtrans->e))
- return flocal_rec_fail (qtrans, &qtrans->s, qdaemon->qsys,
- "cannot open file");
-
- if (qinfo->fspool)
- zlog = qtrans->s.zto;
- else
- zlog = qinfo->zfile;
- qtrans->zlog = zbufalc (sizeof "Receiving " + strlen (zlog));
- sprintf (qtrans->zlog, "Receiving %s", zlog);
-
- if (qdaemon->qproto->pffile != NULL)
- {
- boolean fhandled;
-
- if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, TRUE, FALSE,
- (long) -1, &fhandled))
- {
- (void) ffileclose (qtrans->e);
- return flocal_rec_fail (qtrans, &qtrans->s, qdaemon->qsys,
- (const char *) NULL);
- }
- if (fhandled)
- return TRUE;
- }
-
- qtrans->frecfile = TRUE;
- qtrans->psendfn = frec_file_send_confirm;
- qtrans->precfn = frec_file_end;
-
- return fqueue_receive (qdaemon, qtrans);
-}
-
-/* Make sure there is still enough disk space available to receive a
- file. */
-
-boolean
-frec_check_free (qtrans, cfree_space)
- struct stransfer *qtrans;
- long cfree_space;
-{
- struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo;
- long cfree1, cfree2;
-
- cfree1 = csysdep_bytes_free (qinfo->ztemp);
- cfree2 = csysdep_bytes_free (qinfo->zfile);
- if (cfree1 < cfree2)
- cfree1 = cfree2;
- if (cfree1 != -1 && cfree1 < cfree_space)
- {
- ulog (LOG_ERROR, "%s: too big to receive now", qinfo->zfile);
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* A remote request to send a file to the local system, meaning that
- we are going to receive a file.
-
- If we are using a protocol which does not support multiple
- channels, the remote system will not start sending us the file
- until it has received our confirmation. In that case, the order of
- functions is as follows:
-
- fremote_send_file_init (open file) --> fqueue_remote
- fremote_send_reply (send SY, call pffile) --> fqueue_receive
- receive file
- frec_file_end (close and move file, call pffile) --> fqueue_send
- frec_file_send_confirm (send CY)
-
- If the protocol supports multiple channels, then the remote system
- will start sending the file immediately after the send request.
- That means that the data may come in before remote_send_reply is
- called, so frec_file_end may be called before fremote_send_reply.
- Note that this means the pffile entry points may be called in
- reverse order for such a protocol.
-
- If the send request is rejected, via fremote_send_fail, and the
- protocol supports multiple channels, we must accept and discard
- data until a zero byte buffer is received from the other side,
- indicating that it has received our rejection.
-
- This code also handles execution requests, which are very similar
- to send requests. */
-
-boolean
-fremote_send_file_init (qdaemon, qcmd, iremote)
- struct sdaemon *qdaemon;
- struct scmd *qcmd;
- int iremote;
-{
- const struct uuconf_system *qsys;
- boolean fspool;
- char *zfile;
- openfile_t e;
- char *ztemp;
- long cbytes, cbytes2;
- long crestart;
- struct srecinfo *qinfo;
- struct stransfer *qtrans;
- const char *zlog;
-
- qsys = qdaemon->qsys;
-
- if (! qsys->uuconf_frec_request)
- {
- ulog (LOG_ERROR, "%s: not permitted to receive files from remote",
- qcmd->zfrom);
- return fremote_send_fail (qdaemon, qcmd, FAILURE_PERM, iremote);
- }
-
- fspool = fspool_file (qcmd->zto);
-
- /* We don't accept remote command files. An execution request may
- only send a simple data file. */
- if ((fspool && qcmd->zto[0] == 'C')
- || (qcmd->bcmd == 'E'
- && (! fspool || qcmd->zto[0] != 'D')))
- {
- ulog (LOG_ERROR, "%s: not permitted to receive", qcmd->zfrom);
- return fremote_send_fail (qdaemon, qcmd, FAILURE_PERM, iremote);
- }
-
- /* See if we have already received this file in a previous
- conversation. */
- if (fsysdep_already_received (qsys, qcmd->zto, qcmd->ztemp))
- return fremote_send_fail (qdaemon, qcmd, FAILURE_RECEIVED, iremote);
-
- if (fspool)
- {
- zfile = zsysdep_spool_file_name (qsys, qcmd->zto, (pointer) NULL);
- if (zfile == NULL)
- return FALSE;
- }
- else
- {
- boolean fbadname;
-
- zfile = zsysdep_local_file (qcmd->zto, qsys->uuconf_zpubdir,
- &fbadname);
- if (zfile == NULL && fbadname)
- {
- ulog (LOG_ERROR, "%s: bad local file name", qcmd->zto);
- return fremote_send_fail (qdaemon, qcmd, FAILURE_PERM, iremote);
- }
- if (zfile != NULL)
- {
- char *zadd;
-
- zadd = zsysdep_add_base (zfile, qcmd->zfrom);
- ubuffree (zfile);
- zfile = zadd;
- }
- if (zfile == NULL)
- return FALSE;
-
- /* Check permissions. */
- if (! fin_directory_list (zfile, qsys->uuconf_pzremote_receive,
- qsys->uuconf_zpubdir, TRUE,
- FALSE, (const char *) NULL))
- {
- ulog (LOG_ERROR, "%s: not permitted to receive", zfile);
- ubuffree (zfile);
- return fremote_send_fail (qdaemon, qcmd, FAILURE_PERM, iremote);
- }
-
- if (strchr (qcmd->zoptions, 'f') == NULL)
- {
- if (! fsysdep_make_dirs (zfile, TRUE))
- {
- ubuffree (zfile);
- return fremote_send_fail (qdaemon, qcmd, FAILURE_OPEN,
- iremote);
- }
- }
- }
-
- ztemp = zsysdep_receive_temp (qsys, zfile, qcmd->ztemp,
- (qdaemon->qproto->frestart
- && (qdaemon->ifeatures
- & FEATURE_RESTART) != 0));
-
- /* Adjust the number of bytes we are prepared to receive according
- to the amount of free space we are supposed to leave available
- and the maximum file size we are permitted to transfer. */
- cbytes = csysdep_bytes_free (ztemp);
- cbytes2 = csysdep_bytes_free (zfile);
- if (cbytes < cbytes2)
- cbytes = cbytes2;
-
- if (cbytes != -1)
- {
- cbytes -= qsys->uuconf_cfree_space;
- if (cbytes < 0)
- cbytes = 0;
- }
-
- if (qdaemon->cremote_size != -1
- && (cbytes == -1 || qdaemon->cremote_size < cbytes))
- cbytes = qdaemon->cremote_size;
-
- /* If the number of bytes we are prepared to receive is less than
- the file size, we must fail. If the remote did not tell us the
- file size, arbitrarily assumed that it is 10240 bytes. */
- if (cbytes != -1)
- {
- long csize;
-
- csize = qcmd->cbytes;
- if (csize == -1)
- csize = CASSUMED_FILE_SIZE;
- if (cbytes < csize)
- {
- ulog (LOG_ERROR, "%s: too big to receive", zfile);
- ubuffree (ztemp);
- ubuffree (zfile);
- return fremote_send_fail (qdaemon, qcmd, FAILURE_SIZE, iremote);
- }
- }
-
- /* Open the file to receive into. This may find an old copy of the
- file, which will be used for file restart if the other side
- supports it. */
- crestart = -1;
- e = esysdep_open_receive (qsys, zfile, qcmd->ztemp, ztemp,
- ((qdaemon->qproto->frestart
- && (qdaemon->ifeatures
- & FEATURE_RESTART) != 0)
- ? &crestart
- : (long *) NULL));
- if (! ffileisopen (e))
- {
- ubuffree (ztemp);
- ubuffree (zfile);
- return fremote_send_fail (qdaemon, qcmd, FAILURE_OPEN, iremote);
- }
-
- if (crestart > 0)
- {
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO,
- "fremote_send_file_init: Restarting receive from %ld",
- crestart);
- if (! ffileseek (e, crestart))
- {
- ulog (LOG_ERROR, "seek: %s", strerror (errno));
- (void) ffileclose (e);
- ubuffree (ztemp);
- ubuffree (zfile);
- return FALSE;
- }
- }
-
- qinfo = (struct srecinfo *) xmalloc (sizeof (struct srecinfo));
- if (strchr (qcmd->zoptions, 'n') == NULL)
- qinfo->zmail = NULL;
- else
- qinfo->zmail = zbufcpy (qcmd->znotify);
- qinfo->zfile = zfile;
- qinfo->ztemp = ztemp;
- qinfo->fspool = fspool;
- qinfo->flocal = FALSE;
- qinfo->freceived = FALSE;
- qinfo->freplied = FALSE;
-
- qtrans = qtransalc (qcmd);
- qtrans->psendfn = fremote_send_reply;
- qtrans->precfn = frec_file_end;
- qtrans->iremote = iremote;
- qtrans->pinfo = (pointer) qinfo;
- qtrans->frecfile = TRUE;
- qtrans->e = e;
- if (crestart > 0)
- qtrans->ipos = crestart;
-
- if (qcmd->bcmd == 'E')
- zlog = qcmd->zcmd;
- else
- {
- if (qinfo->fspool)
- zlog = qcmd->zto;
- else
- zlog = qinfo->zfile;
- }
- qtrans->zlog = zbufalc (sizeof "Receiving ( bytes resume at )"
- + strlen (zlog) + 50);
- sprintf (qtrans->zlog, "Receiving %s", zlog);
- if (crestart > 0 || qcmd->cbytes > 0)
- {
- strcat (qtrans->zlog, " (");
- if (qcmd->cbytes > 0)
- {
- sprintf (qtrans->zlog + strlen (qtrans->zlog), "%ld bytes",
- qcmd->cbytes);
- if (crestart > 0)
- strcat (qtrans->zlog, " ");
- }
- if (crestart > 0)
- sprintf (qtrans->zlog + strlen (qtrans->zlog), "resume at %ld",
- crestart);
- strcat (qtrans->zlog, ")");
- }
-
- return fqueue_remote (qdaemon, qtrans);
-}
-
-/* Reply to a send request, and prepare to receive the file. */
-
-static boolean
-fremote_send_reply (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo;
- boolean fret;
- char ab[50];
-
- /* If the file has been completely received, we just want to send
- the final confirmation. Otherwise, we must wait for the file
- first. */
- qtrans->psendfn = frec_file_send_confirm;
- if (qinfo->freceived)
- fret = fqueue_send (qdaemon, qtrans);
- else
- fret = fqueue_receive (qdaemon, qtrans);
- if (! fret)
- return FALSE;
-
- ab[0] = qtrans->s.bcmd;
- ab[1] = 'Y';
- if (qtrans->ipos <= 0)
- ab[2] = '\0';
- else
- sprintf (ab + 2, " 0x%lx", (unsigned long) qtrans->ipos);
-
- qinfo->freplied = TRUE;
-
- if (! (*qdaemon->qproto->pfsendcmd) (qdaemon, ab, qtrans->ilocal,
- qtrans->iremote))
- {
- (void) ffileclose (qtrans->e);
- (void) remove (qinfo->ztemp);
- /* Should probably free qtrans here, but see the comment at the
- end of flocal_rec_send_request. */
- return FALSE;
- }
-
- if (qdaemon->qproto->pffile != NULL)
- {
- boolean fhandled;
-
- if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, TRUE, FALSE,
- (long) -1, &fhandled))
- {
- (void) ffileclose (qtrans->e);
- (void) remove (qinfo->ztemp);
- urrec_free (qtrans);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-/* If we can't receive a file, queue up a response to the remote
- system. */
-
-static boolean
-fremote_send_fail (qdaemon, qcmd, twhy, iremote)
- struct sdaemon *qdaemon;
- struct scmd *qcmd;
- enum tfailure twhy;
- int iremote;
-{
- struct srecfailinfo *qinfo;
- struct stransfer *qtrans;
-
- qinfo = (struct srecfailinfo *) xmalloc (sizeof (struct srecfailinfo));
- qinfo->twhy = twhy;
- qinfo->fsent = FALSE;
-
- /* If the protocol does not support multiple channels (cchans <= 1),
- then we have essentially already received the entire file. */
- qinfo->freceived = qdaemon->cchans <= 1;
-
- qtrans = qtransalc (qcmd);
- qtrans->psendfn = fremote_send_fail_send;
- qtrans->precfn = fremote_discard;
- qtrans->iremote = iremote;
- qtrans->pinfo = (pointer) qinfo;
-
- return fqueue_remote (qdaemon, qtrans);
-}
-
-/* Send a failure string for a send command to the remote system;
- this is called when we are ready to reply to the command. */
-
-static boolean
-fremote_send_fail_send (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct srecfailinfo *qinfo = (struct srecfailinfo *) qtrans->pinfo;
- char ab[4];
- int ilocal, iremote;
-
- ab[0] = qtrans->s.bcmd;
- ab[1] = 'N';
-
- switch (qinfo->twhy)
- {
- case FAILURE_PERM:
- ab[2] = '2';
- break;
- case FAILURE_OPEN:
- ab[2] = '4';
- break;
- case FAILURE_SIZE:
- ab[2] = '6';
- break;
- case FAILURE_RECEIVED:
- /* Remember this file as though we successfully received it;
- when the other side acknowledges our rejection, we know that
- we no longer have to remember that we received this file. */
- usent_receive_ack (qdaemon, qtrans);
- ab[2] = '8';
- break;
- default:
- ab[2] = '\0';
- break;
- }
-
- ab[3] = '\0';
-
- ilocal = qtrans->ilocal;
- iremote = qtrans->iremote;
-
- /* Wait for the end of file marker if we haven't gotten it yet. */
- if (! qinfo->freceived)
- {
- qinfo->fsent = TRUE;
- if (! fqueue_receive (qdaemon, qtrans))
- return FALSE;
- }
- else
- {
- xfree (qtrans->pinfo);
- utransfree (qtrans);
- }
-
- return (*qdaemon->qproto->pfsendcmd) (qdaemon, ab, ilocal, iremote);
-}
-
-/* Discard data until we reach the end of the file. This is used for
- a protocol with multiple channels, since the remote system may
- start sending the file before the confirmation is sent. If we
- refuse the file, the remote system will get us back in synch by
- sending an empty buffer, which is what we look for here. */
-
-/*ARGSUSED*/
-static boolean
-fremote_discard (qtrans, qdaemon, zdata, cdata)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
- const char *zdata;
- size_t cdata;
-{
- struct srecfailinfo *qinfo = (struct srecfailinfo *) qtrans->pinfo;
-
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO,
- "fremote_discard: Discarding %lu bytes",
- (unsigned long) cdata);
-
- if (cdata != 0)
- return TRUE;
-
- qinfo->freceived = TRUE;
-
- /* If we have already sent the denial, we are done. */
- if (qinfo->fsent)
- {
- xfree (qtrans->pinfo);
- utransfree (qtrans);
- }
-
- return TRUE;
-}
-
-/* This is called when a file has been completely received. It sends
- a response to the remote system. */
-
-/*ARGSUSED*/
-static boolean
-frec_file_end (qtrans, qdaemon, zdata, cdata)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
- const char *zdata;
- size_t cdata;
-{
- struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo;
- char *zalc;
- const char *zerr;
- boolean fnever;
-
- DEBUG_MESSAGE3 (DEBUG_UUCP_PROTO, "frec_file_end: %s to %s (freplied %s)",
- qtrans->s.zfrom, qtrans->s.zto,
- qinfo->freplied ? "TRUE" : "FALSE");
-
- if (qdaemon->qproto->pffile != NULL)
- {
- boolean fhandled;
-
- if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, FALSE, FALSE,
- (long) -1, &fhandled))
- {
- (void) ffileclose (qtrans->e);
- (void) remove (qinfo->ztemp);
- urrec_free (qtrans);
- return FALSE;
- }
- if (fhandled)
- return TRUE;
- }
-
- qinfo->freceived = TRUE;
-
- fnever = FALSE;
-
- zalc = NULL;
-
- if (! fsysdep_sync (qtrans->e, qtrans->s.zto))
- {
- zerr = strerror (errno);
- (void) ffileclose (qtrans->e);
- (void) remove (qinfo->ztemp);
- }
- else if (! ffileclose (qtrans->e))
- {
- zerr = strerror (errno);
- ulog (LOG_ERROR, "%s: close: %s", qtrans->s.zto, zerr);
- (void) remove (qinfo->ztemp);
- }
- else if (! fsysdep_move_file (qinfo->ztemp, qinfo->zfile, qinfo->fspool,
- FALSE, ! qinfo->fspool,
- (qinfo->flocal
- ? qtrans->s.zuser
- : (const char *) NULL)))
- {
- long cspace;
-
- /* Keep the temporary file if there is 1.5 times the amount of
- required free space. This is just a random guess, to make an
- unusual situtation potentially less painful. */
- cspace = csysdep_bytes_free (qinfo->ztemp);
- if (cspace == -1)
- cspace = FREE_SPACE_DELTA;
- cspace -= (qdaemon->qsys->uuconf_cfree_space
- + qdaemon->qsys->uuconf_cfree_space / 2);
- if (cspace < 0)
- {
- (void) remove (qinfo->ztemp);
- zerr = "could not move to final location";
- }
- else
- {
- const char *az[20];
- int i;
-
- zalc = zbufalc (sizeof "could not move to final location (left as )"
- + strlen (qinfo->ztemp));
- sprintf (zalc, "could not move to final location (left as %s)",
- qinfo->ztemp);
- zerr = zalc;
-
- i = 0;
- az[i++] = "The file\n\t";
- az[i++] = qinfo->ztemp;
- az[i++] =
- "\nwas saved because the move to the final location failed.\n";
- az[i++] = "See the UUCP logs for more details.\n";
- az[i++] = "The file transfer was from\n\t";
- az[i++] = qdaemon->qsys->uuconf_zname;
- az[i++] = "!";
- az[i++] = qtrans->s.zfrom;
- az[i++] = "\nto\n\t";
- az[i++] = qtrans->s.zto;
- az[i++] = "\nand was requested by\n\t";
- az[i++] = qtrans->s.zuser;
- az[i++] = "\n";
- (void) fsysdep_mail (OWNER, "UUCP temporary file saved", i, az);
- }
- ulog (LOG_ERROR, "%s: %s", qinfo->zfile, zerr);
- fnever = TRUE;
- }
- else
- {
- if (! qinfo->fspool)
- {
- unsigned int imode;
-
- /* Unless we can change the ownership of the file, the only
- choice to make about these bits is whether to set the
- execute bit or not. */
- if ((qtrans->s.imode & 0111) != 0)
- imode = 0777;
- else
- imode = 0666;
- (void) fsysdep_change_mode (qinfo->zfile, imode);
- }
-
- zerr = NULL;
- }
-
- ustats (zerr == NULL, qtrans->s.zuser, qdaemon->qsys->uuconf_zname,
- FALSE, qtrans->cbytes, qtrans->isecs, qtrans->imicros,
- qdaemon->fcaller);
- qdaemon->creceived += qtrans->cbytes;
-
- if (zerr == NULL)
- {
- if (qinfo->zmail != NULL && *qinfo->zmail != '\0')
- (void) fmail_transfer (TRUE, qtrans->s.zuser, qinfo->zmail,
- (const char *) NULL,
- qtrans->s.zfrom, qdaemon->qsys->uuconf_zname,
- qtrans->s.zto, (const char *) NULL,
- (const char *) NULL);
-
- if (qtrans->s.pseq != NULL)
- (void) fsysdep_did_work (qtrans->s.pseq);
-
- if (! qinfo->flocal)
- {
- /* Remember that we have received this file, so that if the
- connection drops at this point we won't receive it again.
- We could check the return value here, but if we return
- FALSE we couldn't do anything but drop the connection,
- which would hardly be reasonable. Instead we trust that
- the administrator will notice and handle any error
- messages, which are very unlikely to occur if everything
- is set up correctly. */
- (void) fsysdep_remember_reception (qdaemon->qsys, qtrans->s.zto,
- qtrans->s.ztemp);
- }
- }
- else
- {
- /* If the transfer failed, we send mail if it was requested
- locally and if it can never succeed. */
- if (qinfo->flocal && fnever)
- {
- (void) fmail_transfer (FALSE, qtrans->s.zuser, qinfo->zmail,
- zerr, qtrans->s.zfrom,
- qdaemon->qsys->uuconf_zname,
- qtrans->s.zto, (const char *) NULL,
- (const char *) NULL);
- (void) fsysdep_did_work (qtrans->s.pseq);
- }
- }
-
- ubuffree (zalc);
-
- /* If this is an execution request, we must create the execution
- file itself. */
- if (qtrans->s.bcmd == 'E' && zerr == NULL)
- {
- char *zxqt, *zxqtfile, *ztemp;
- FILE *e;
- boolean fbad;
-
- /* We get an execution file name by simply replacing the leading
- D in the received file name with an X. This pretty much
- always has to work since we can always receive a file name
- starting with X, so the system dependent code must be
- prepared to see one. */
- zxqt = zbufcpy (qtrans->s.zto);
- zxqt[0] = 'X';
- zxqtfile = zsysdep_spool_file_name (qdaemon->qsys, zxqt,
- (pointer) NULL);
- ubuffree (zxqt);
-
- if (zxqtfile == NULL)
- {
- urrec_free (qtrans);
- return FALSE;
- }
-
- /* We have to write via a temporary file, because otherwise
- uuxqt might pick up the file before we have finished writing
- it. */
- e = NULL;
- ztemp = zsysdep_receive_temp (qdaemon->qsys, zxqtfile, "D.0",
- (qdaemon->qproto->frestart
- && (qdaemon->ifeatures
- & FEATURE_RESTART) != 0));
- if (ztemp != NULL)
- e = esysdep_fopen (ztemp, FALSE, FALSE, TRUE);
-
- if (e == NULL)
- {
- ubuffree (zxqtfile);
- ubuffree (ztemp);
- urrec_free (qtrans);
- return FALSE;
- }
-
- fprintf (e, "U %s %s\n", qtrans->s.zuser, qdaemon->qsys->uuconf_zname);
- fprintf (e, "F %s\n", qtrans->s.zto);
- fprintf (e, "I %s\n", qtrans->s.zto);
- if (strchr (qtrans->s.zoptions, 'N') != NULL)
- fprintf (e, "N\n");
- if (strchr (qtrans->s.zoptions, 'Z') != NULL)
- fprintf (e, "Z\n");
- if (strchr (qtrans->s.zoptions, 'R') != NULL)
- fprintf (e, "R %s\n", qtrans->s.znotify);
- if (strchr (qtrans->s.zoptions, 'e') != NULL)
- fprintf (e, "e\n");
- fprintf (e, "C %s\n", qtrans->s.zcmd);
-
- fbad = FALSE;
-
- if (! fstdiosync (e, ztemp))
- {
- (void) fclose (e);
- (void) remove (ztemp);
- fbad = TRUE;
- }
-
- if (! fbad)
- {
- if (fclose (e) == EOF)
- {
- ulog (LOG_ERROR, "fclose: %s", strerror (errno));
- (void) remove (ztemp);
- fbad = TRUE;
- }
- }
-
- if (! fbad)
- {
- if (! fsysdep_move_file (ztemp, zxqtfile, TRUE, FALSE, FALSE,
- (const char *) NULL))
- {
- (void) remove (ztemp);
- fbad = TRUE;
- }
- }
-
- ubuffree (zxqtfile);
- ubuffree (ztemp);
-
- if (fbad)
- {
- urrec_free (qtrans);
- return FALSE;
- }
- }
-
- /* See if we should spawn a uuxqt process. */
- if (zerr == NULL
- && (qtrans->s.bcmd == 'E'
- || (qinfo->fspool && qtrans->s.zto[0] == 'X')))
- {
- ++qdaemon->cxfiles_received;
- if (qdaemon->irunuuxqt > 0
- && qdaemon->cxfiles_received >= qdaemon->irunuuxqt)
- {
- if (fspawn_uuxqt (TRUE, qdaemon->qsys->uuconf_zname,
- qdaemon->zconfig))
- qdaemon->cxfiles_received = 0;
- }
- }
-
- /* Prepare to send the completion string to the remote system. If
- we have not yet replied to the remote send request, we leave the
- transfer structure on the remote queue. Otherwise we add it to
- the send queue. The psendfn field will already be set. */
- qinfo->fmoved = zerr == NULL;
- if (qinfo->freplied)
- return fqueue_send (qdaemon, qtrans);
-
- return TRUE;
-}
-
-/* Send the final confirmation string to the remote system. */
-
-static boolean
-frec_file_send_confirm (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo;
- const char *zsend;
- int ilocal, iremote;
-
- if (! qinfo->fmoved)
- zsend = "CN5";
- else if (! qdaemon->frequest_hangup)
- zsend = "CY";
- else
- {
-#if DEBUG > 0
- if (qdaemon->fmaster)
- ulog (LOG_FATAL, "frec_file_send_confirm: Can't happen");
-#endif
-
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO,
- "frec_send_file_confirm: Requesting remote to transfer control");
- zsend = "CYM";
- }
-
- /* If that was a remote command, then, when the confirmation message
- is acked, we no longer have to remember that we received that
- file. */
- if (! qinfo->flocal && qinfo->fmoved)
- usent_receive_ack (qdaemon, qtrans);
-
- ilocal = qtrans->ilocal;
- iremote = qtrans->iremote;
-
- urrec_free (qtrans);
-
- return (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, ilocal, iremote);
-}
-
-/* Discard a temporary file if it is not useful. A temporary file is
- useful if it could be used to restart a receive. This is called if
- the connection is lost. It is only called if qtrans->frecfile is
- TRUE. */
-
-boolean
-frec_discard_temp (qdaemon, qtrans)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
-{
- struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo;
-
- if ((qdaemon->ifeatures & FEATURE_RESTART) == 0
- || qtrans->s.ztemp == NULL
- || qtrans->s.ztemp[0] != 'D'
- || strcmp (qtrans->s.ztemp, "D.0") == 0)
- (void) remove (qinfo->ztemp);
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/uucico/send.c b/gnu/libexec/uucp/uucico/send.c
deleted file mode 100644
index db11d75..0000000
--- a/gnu/libexec/uucp/uucico/send.c
+++ /dev/null
@@ -1,1387 +0,0 @@
-/* send.c
- Routines to send a file.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char send_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "prot.h"
-#include "trans.h"
-
-/* We keep this information in the pinfo field of the stransfer
- structure. */
-struct ssendinfo
-{
- /* Local user to send mail to (may be NULL). */
- char *zmail;
- /* Full file name. */
- char *zfile;
- /* Number of bytes in file. */
- long cbytes;
- /* TRUE if this was a local request. */
- boolean flocal;
- /* TRUE if this is a spool directory file. */
- boolean fspool;
- /* TRUE if the file has been completely sent. */
- boolean fsent;
- /* TRUE if the file send will never succeed; used by
- flocal_send_cancelled. */
- boolean fnever;
- /* Execution file for sending an unsupported E request. */
- char *zexec;
- /* Confirmation command received in fsend_await_confirm. */
- char *zconfirm;
-};
-
-/* Local functions. */
-
-static void usfree_send P((struct stransfer *qtrans));
-static boolean flocal_send_fail P((struct scmd *qcmd,
- struct sdaemon *qdaemon,
- const char *zwhy));
-static boolean flocal_send_request P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean flocal_send_await_reply P((struct stransfer *qtrans,
- struct sdaemon *qdaemon,
- const char *zdata, size_t cdata));
-static boolean flocal_send_cancelled P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean flocal_send_open_file P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean fremote_rec_fail P((struct sdaemon *qdaemon,
- enum tfailure twhy, int iremote));
-static boolean fremote_rec_fail_send P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean fremote_rec_reply P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean fsend_file_end P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean fsend_await_confirm P((struct stransfer *qtrans,
- struct sdaemon *qdaemon,
- const char *zdata, size_t cdata));
-static boolean fsend_exec_file_init P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static void usadd_exec_line P((char **pz, size_t *pcalc, size_t *pclen,
- int bcmd, const char *z1, const char *z2));
-static boolean fsend_exec_file P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-
-/* Free up a send stransfer structure. */
-
-static void
-usfree_send (qtrans)
- struct stransfer *qtrans;
-{
- struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo;
-
- if (qinfo != NULL)
- {
- ubuffree (qinfo->zmail);
- ubuffree (qinfo->zfile);
- ubuffree (qinfo->zexec);
- ubuffree (qinfo->zconfirm);
- xfree (qtrans->pinfo);
- }
-
- utransfree (qtrans);
-}
-
-/* Set up a local request to send a file. This may be called before
- we have even tried to call the remote system.
-
- If we are using a traditional protocol, which doesn't support
- channel numbers and doesn't permit the file to be sent until an
- acknowledgement has been received, the sequence of function calls
- looks like this:
-
- flocal_send_file_init --> fqueue_local
- flocal_send_request (sends S request) --> fqueue_receive
- flocal_send_await_reply (waits for SY) --> fqueue_send
- flocal_send_open_file (opens file, calls pffile) --> fqueue_send
- send file
- fsend_file_end (calls pffile) --> fqueue_receive
- fsend_await_confirm (waits for CY)
-
- If flocal_send_await_reply gets an SN, it deletes the request. If
- the SY reply contains a file position at which to start sending,
- flocal_send_await_reply sets qinfo->ipos.
-
- This gets more complex if the protocol supports channels. In that
- case, we want to start sending the file data immediately, to avoid
- the round trip delay between flocal_send_request and
- flocal_send_await_reply. To do this, flocal_send_request calls
- fqueue_send rather than fqueue_receive. The main execution
- sequence looks like this:
-
- flocal_send_file_init --> fqueue_local
- flocal_send_request (sends S request) --> fqueue_send
- flocal_send_open_file (opens file, calls pffile) --> fqueue_send
- send file
- fsend_file_end (calls pffile) --> fqueue_receive
- sometime: flocal_send_await_reply (waits for SY)
- fsend_await_confirm (waits for CY)
-
- In this case flocal_send_await_reply must be run before
- fsend_await_confirm; it may be run anytime after
- flocal_send_request.
-
- If flocal_send_await_reply is called before the entire file has
- been sent: if it gets an SN, it sets the file position to the end
- and arranges to call flocal_send_cancelled. If it gets a file
- position request, it must adjust the file position accordingly.
-
- If flocal_send_await_reply is called after the entire file has been
- sent: if it gets an SN, it can simply delete the request. It can
- ignore any file position request.
-
- If the request is not deleted, flocal_send_await_reply must arrange
- for the next string to be passed to fsend_await_confirm.
- Presumably fsend_await_confirm will only be called after the entire
- file has been sent.
-
- Just to make things even more complex, these same routines support
- sending execution requests, since that is much like sending a file.
- For an execution request, the bcmd character will be E rather than
- S. If an execution request is being sent to a system which does
- not support them, it must be sent as two S requests instead. The
- second one will be the execution file, but no actual file is
- created; instead the zexec and znext fields in the ssendinfo
- structure are used. So if the bcmd character is E, then if the
- zexec field is NULL, the data file is being sent, otherwise the
- fake execution file is being sent. */
-
-boolean
-flocal_send_file_init (qdaemon, qcmd)
- struct sdaemon *qdaemon;
- struct scmd *qcmd;
-{
- const struct uuconf_system *qsys;
- boolean fspool;
- char *zfile;
- long cbytes;
- struct ssendinfo *qinfo;
- struct stransfer *qtrans;
-
- qsys = qdaemon->qsys;
-
- if (qdaemon->fcaller
- ? ! qsys->uuconf_fcall_transfer
- : ! qsys->uuconf_fcalled_transfer)
- {
- /* uux or uucp should have already made sure that the transfer
- is possible, but it might have changed since then. */
- if (! qsys->uuconf_fcall_transfer
- && ! qsys->uuconf_fcalled_transfer)
- return flocal_send_fail (qcmd, qdaemon,
- "not permitted to transfer files");
-
- /* We can't do the request now, but it may get done later. */
- return TRUE;
- }
-
- /* The 'C' option means that the file has been copied to the spool
- directory. */
- if (strchr (qcmd->zoptions, 'C') == NULL
- && ! fspool_file (qcmd->zfrom))
- {
- fspool = FALSE;
- if (! fin_directory_list (qcmd->zfrom,
- qsys->uuconf_pzlocal_send,
- qsys->uuconf_zpubdir, TRUE,
- TRUE, qcmd->zuser))
- return flocal_send_fail (qcmd, qdaemon, "not permitted to send");
- zfile = zbufcpy (qcmd->zfrom);
- }
- else
- {
- fspool = TRUE;
- zfile = zsysdep_spool_file_name (qsys, qcmd->ztemp, qcmd->pseq);
- if (zfile == NULL)
- return FALSE;
- }
-
- /* Make sure we meet any local size restrictions. The connection
- may not have been opened at this point, so we can't check remote
- size restrictions. */
- cbytes = csysdep_size (zfile);
- if (cbytes < 0)
- {
- ubuffree (zfile);
- if (cbytes != -1)
- return flocal_send_fail (qcmd, qdaemon, "can not get size");
- /* A cbytes value of -1 means that the file does not exist.
- This can happen legitimately if it has already been sent from
- the spool directory. */
- if (! fspool)
- return flocal_send_fail (qcmd, qdaemon, "does not exist");
- (void) fsysdep_did_work (qcmd->pseq);
- return TRUE;
- }
-
- if (qdaemon->clocal_size != -1
- && qdaemon->clocal_size < cbytes)
- {
- ubuffree (zfile);
-
- if (qdaemon->cmax_ever == -2)
- {
- long c1, c2;
-
- c1 = cmax_size_ever (qsys->uuconf_qcall_local_size);
- c2 = cmax_size_ever (qsys->uuconf_qcalled_local_size);
- if (c1 > c2)
- qdaemon->cmax_ever = c1;
- else
- qdaemon->cmax_ever = c2;
- }
-
- if (qdaemon->cmax_ever != -1
- && qdaemon->cmax_ever < qcmd->cbytes)
- return flocal_send_fail (qcmd, qdaemon, "too large to send");
-
- return TRUE;
- }
-
- /* We are now prepared to send the command to the remote system. We
- queue up a transfer request to send the command when we are
- ready. */
- qinfo = (struct ssendinfo *) xmalloc (sizeof (struct ssendinfo));
- if (strchr (qcmd->zoptions, 'm') == NULL)
- qinfo->zmail = NULL;
- else
- qinfo->zmail = zbufcpy (qcmd->zuser);
- qinfo->zfile = zfile;
- qinfo->cbytes = cbytes;
- qinfo->flocal = strchr (qcmd->zuser, '!') == NULL;
- qinfo->fspool = fspool;
- qinfo->fsent = FALSE;
- qinfo->zexec = NULL;
- qinfo->zconfirm = NULL;
-
- qtrans = qtransalc (qcmd);
- qtrans->psendfn = flocal_send_request;
- qtrans->pinfo = (pointer) qinfo;
-
- return fqueue_local (qdaemon, qtrans);
-}
-
-/* Clean up after a failing local send request. If zwhy is not NULL,
- this reports an error to the log file and to the user. */
-
-static boolean
-flocal_send_fail (qcmd, qdaemon, zwhy)
- struct scmd *qcmd;
- struct sdaemon *qdaemon;
- const char *zwhy;
-{
- if (zwhy != NULL)
- {
- const char *zfrom;
- char *zfree;
- const char *ztemp;
-
- if (qcmd->bcmd != 'E')
- {
- zfrom = qcmd->zfrom;
- zfree = NULL;
- }
- else
- {
- zfree = zbufalc (strlen (qcmd->zfrom)
- + sizeof " (execution of \"\")"
- + strlen (qcmd->zcmd));
- sprintf (zfree, "%s (execution of \"%s\")", qcmd->zfrom,
- qcmd->zcmd);
- zfrom = zfree;
- }
-
- ulog (LOG_ERROR, "%s: %s", zfrom, zwhy);
-
- /* We only save the temporary file if this is a request from the
- local system; otherwise a remote system could launch a denial
- of service attack by filling up the .Preserve directory
- (local users have much simpler methods for this type of
- denial of service attack, so there is little point to using a
- more sophisticated scheme). */
- if (strchr (qcmd->zuser, '!') == NULL)
- ztemp = zsysdep_save_temp_file (qcmd->pseq);
- else
- ztemp = NULL;
- (void) fmail_transfer (FALSE, qcmd->zuser, (const char *) NULL,
- zwhy, zfrom, (const char *) NULL,
- qcmd->zto, qdaemon->qsys->uuconf_zname, ztemp);
-
- ubuffree (zfree);
- }
-
- (void) fsysdep_did_work (qcmd->pseq);
-
- return TRUE;
-}
-
-/* This is called when we are ready to send the request to the remote
- system. We form the request and send it over. If the protocol
- does not support multiple channels, we start waiting for the
- response; otherwise we can start sending the file immediately. */
-
-static boolean
-flocal_send_request (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo;
- char *zsend;
- const char *znotify;
- char absize[20];
- boolean fret;
-
- /* Make sure the file meets any remote size restrictions. */
- if (qdaemon->cmax_receive != -1
- && qdaemon->cmax_receive < qinfo->cbytes)
- {
- fret = flocal_send_fail (&qtrans->s, qdaemon, "too large for receiver");
- usfree_send (qtrans);
- return fret;
- }
-
- /* Make sure the file still exists--it may have been removed between
- the conversation startup and now. After we have sent over the S
- command we must give an error if we can't find the file. */
- if (! fsysdep_file_exists (qinfo->zfile))
- {
- (void) fsysdep_did_work (qtrans->s.pseq);
- usfree_send (qtrans);
- return TRUE;
- }
-
- /* If we are using a protocol which can make multiple channels, then
- we can open and send the file whenever we are ready. This is
- because we will be able to distinguish the response by the
- channel it is directed to. This assumes that every protocol
- which supports multiple channels also supports sending the file
- position in mid-stream, since otherwise we would not be able to
- restart files. */
- qtrans->fcmd = TRUE;
- qtrans->psendfn = flocal_send_open_file;
- qtrans->precfn = flocal_send_await_reply;
-
- if (qdaemon->cchans > 1)
- fret = fqueue_send (qdaemon, qtrans);
- else
- fret = fqueue_receive (qdaemon, qtrans);
- if (! fret)
- return FALSE;
-
- /* Construct the notify string to send. If we are going to send a
- size or an execution command, it must be non-empty. */
- znotify = qtrans->s.znotify;
- if (znotify == NULL)
- znotify = "";
- if ((qdaemon->ifeatures & FEATURE_SIZES) != 0
- || (qtrans->s.bcmd == 'E'
- && (qdaemon->ifeatures & FEATURE_EXEC) != 0))
- {
- if (*znotify == '\0')
- znotify = "\"\"";
- }
- else
- {
- /* We don't need a notify string. Some crufty UUCP code can't
- handle a pair of double quotes. */
- if (strcmp (znotify, "\"\"") == 0)
- znotify = "";
- }
-
- /* Construct the size string to send. */
- if ((qdaemon->ifeatures & FEATURE_SIZES) == 0
- && (qtrans->s.bcmd != 'E'
- || (qdaemon->ifeatures & FEATURE_EXEC) == 0))
- absize[0] = '\0';
- else if ((qdaemon->ifeatures & FEATURE_V103) == 0)
- sprintf (absize, "0x%lx", (unsigned long) qinfo->cbytes);
- else
- sprintf (absize, "%ld", qinfo->cbytes);
-
- zsend = zbufalc (strlen (qtrans->s.zfrom) + strlen (qtrans->s.zto)
- + strlen (qtrans->s.zuser) + strlen (qtrans->s.zoptions)
- + strlen (qtrans->s.ztemp) + strlen (znotify)
- + strlen (absize)
- + (qtrans->s.zcmd != NULL ? strlen (qtrans->s.zcmd) : 0)
- + 50);
-
- /* If this an execution request and the other side supports
- execution requests, we send an E command. Otherwise we send an S
- command. The case of an execution request when we are sending
- the fake execution file is handled just like an S request at this
- point. */
- if (qtrans->s.bcmd == 'E'
- && (qdaemon->ifeatures & FEATURE_EXEC) != 0)
- {
- /* Send the string
- E zfrom zto zuser zoptions ztemp imode znotify size zcmd
- to the remote system. We put a '-' in front of the (possibly
- empty) options and a '0' in front of the mode. */
- sprintf (zsend, "E %s %s %s -%s %s 0%o %s %s %s", qtrans->s.zfrom,
- qtrans->s.zto, qtrans->s.zuser, qtrans->s.zoptions,
- qtrans->s.ztemp, qtrans->s.imode, znotify, absize,
- qtrans->s.zcmd);
- }
- else
- {
- const char *zoptions, *zdummy;
-
- /* Send the string
- S zfrom zto zuser zoptions ztemp imode znotify
- to the remote system. We put a '-' in front of the (possibly
- empty) options and a '0' in front of the mode. If size
- negotiation is supported, we also send the size; in this case
- if znotify is empty we must send it as "". If this is really
- an execution request, we have to simplify the options string
- to remove the various execution options which may confuse the
- remote system. SVR4 expects a string "dummy" between the
- notify string and the size; I don't know why. */
- if (qtrans->s.bcmd != 'E')
- zoptions = qtrans->s.zoptions;
- else if (strchr (qtrans->s.zoptions, 'C') != NULL)
- {
- /* This should set zoptions to "C", but at least one UUCP
- program gets confused by it. That means that it will
- fail in certain cases, but I suppose we might as well
- kowtow to compatibility. This shouldn't matter to any
- other program, I hope. */
- zoptions = "";
- }
- else
- zoptions = "c";
-
- if ((qdaemon->ifeatures & FEATURE_SVR4) != 0)
- zdummy = " dummy ";
- else
- zdummy = " ";
-
- sprintf (zsend, "S %s %s %s -%s %s 0%o %s%s%s", qtrans->s.zfrom,
- qtrans->s.zto, qtrans->s.zuser, zoptions,
- qtrans->s.ztemp, qtrans->s.imode, znotify, zdummy,
- absize);
- }
-
- fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, qtrans->ilocal,
- qtrans->iremote);
- ubuffree (zsend);
-
- /* If fret is FALSE, we should free qtrans here, but see the comment
- at the end of flocal_rec_send_request. */
-
- return fret;
-}
-
-/* This is called when a reply is received for the send request. As
- described at length above, if the protocol supports multiple
- channels we may be in the middle of sending the file, or we may
- even finished sending the file. */
-
-static boolean
-flocal_send_await_reply (qtrans, qdaemon, zdata, cdata)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
- const char *zdata;
- size_t cdata;
-{
- struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo;
- char bcmd;
-
- if (qtrans->s.bcmd == 'E'
- && (qdaemon->ifeatures & FEATURE_EXEC) != 0)
- bcmd = 'E';
- else
- bcmd = 'S';
- if (zdata[0] != bcmd
- || (zdata[1] != 'Y' && zdata[1] != 'N'))
- {
- ulog (LOG_ERROR, "%s: Bad response to %c request: \"%s\"",
- qtrans->s.zfrom, bcmd, zdata);
- usfree_send (qtrans);
- return FALSE;
- }
-
- if (zdata[1] == 'N')
- {
- const char *zerr;
- boolean fnever;
-
- fnever = TRUE;
- if (zdata[2] == '2')
- zerr = "permission denied by remote";
- else if (zdata[2] == '4')
- {
- zerr = "remote cannot create work files";
- fnever = FALSE;
- }
- else if (zdata[2] == '6')
- {
- zerr = "too large for remote now";
- fnever = FALSE;
- }
- else if (zdata[2] == '7')
- {
- /* The file is too large to ever send. */
- zerr = "too large for remote";
- }
- else if (zdata[2] == '8')
- {
- /* The file was already received by the remote system. This
- is not an error, it just means that the ack from the
- remote was lost in the previous conversation, and there
- is no need to resend the file. */
- zerr = NULL;
- }
- else if (zdata[2] == '9')
- {
- /* Remote has run out of channels. */
- zerr = "too many channels for remote";
- fnever = FALSE;
-
- /* Drop one channel; using exactly one channel causes
- slightly different behahaviour in a few places, so don't
- decrement to one. */
- if (qdaemon->cchans > 2)
- --qdaemon->cchans;
- }
- else
- zerr = "unknown reason";
-
- if (! fnever
- || (qtrans->s.bcmd == 'E'
- && (qdaemon->ifeatures & FEATURE_EXEC) == 0
- && qinfo->zexec == NULL))
- {
- if (qtrans->s.bcmd == 'E')
- ulog (LOG_ERROR, "%s (execution of \"%s\"): %s",
- qtrans->s.zfrom, qtrans->s.zcmd, zerr);
- else
- ulog (LOG_ERROR, "%s: %s", qtrans->s.zfrom, zerr);
- }
- else
- {
- if (! flocal_send_fail (&qtrans->s, qdaemon, zerr))
- return FALSE;
- }
-
- /* If the protocol does not support multiple channels, we can
- simply remove the transaction. Otherwise we must make sure
- the remote side knows that we have finished sending the file
- data. If we have already sent the entire file, there will be
- no confusion. */
- if (qdaemon->cchans == 1 || qinfo->fsent)
- {
- /* If we are breaking a 'E' command into two 'S' commands,
- and that was for the first 'S' command, we still have to
- send the second one. */
- if (fnever
- && qtrans->s.bcmd == 'E'
- && (qdaemon->ifeatures & FEATURE_EXEC) == 0
- && qinfo->zexec == NULL)
- return fsend_exec_file_init (qtrans, qdaemon);
-
- usfree_send (qtrans);
- return TRUE;
- }
- else
- {
- /* Seek to the end of the file so that the next read will
- send end of file. We have to be careful here, because we
- may have actually already sent end of file--we could be
- being called because of data received while the end of
- file block was sent. */
- if (! ffileseekend (qtrans->e))
- {
- ulog (LOG_ERROR, "seek to end: %s", strerror (errno));
- usfree_send (qtrans);
- return FALSE;
- }
- qtrans->psendfn = flocal_send_cancelled;
- qtrans->precfn = NULL;
-
- qinfo->fnever = fnever;
-
- return fqueue_send (qdaemon, qtrans);
- }
- }
-
- /* A number following the SY or EY is the file position to start
- sending from. If we are already sending the file, we must set
- the position accordingly. */
- if (zdata[2] != '\0')
- {
- long cskip;
-
- cskip = strtol ((char *) (zdata + 2), (char **) NULL, 0);
- if (cskip > 0 && qtrans->ipos < cskip)
- {
- if (qtrans->fsendfile && ! qinfo->fsent)
- {
- if (! ffileseek (qtrans->e, cskip))
- {
- ulog (LOG_ERROR, "seek: %s", strerror (errno));
- usfree_send (qtrans);
- return FALSE;
- }
- }
- qtrans->ipos = cskip;
- }
- }
-
- /* Now queue up to send the file or to wait for the confirmation.
- We already set psendfn at the end of flocal_send_request. If the
- protocol supports multiple channels, we have already called
- fqueue_send; calling it again would move the request in the
- queue, which would make the log file a bit confusing. */
- qtrans->fcmd = TRUE;
- qtrans->precfn = fsend_await_confirm;
- if (qinfo->fsent)
- return fqueue_receive (qdaemon, qtrans);
- else if (qdaemon->cchans <= 1)
- return fqueue_send (qdaemon, qtrans);
- else
- return TRUE;
-}
-
-/* Open the file, if any, and prepare to send it. */
-
-static boolean
-flocal_send_open_file (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo;
- const char *zuser;
-
- /* If this is not a fake execution file, open it. */
- if (qinfo->zexec == NULL)
- {
- /* If there is an ! in the user name, this is a remote request
- queued up by fremote_xcmd_init. */
- zuser = qtrans->s.zuser;
- if (strchr (zuser, '!') != NULL)
- zuser = NULL;
-
- qtrans->e = esysdep_open_send (qdaemon->qsys, qinfo->zfile,
- ! qinfo->fspool, zuser);
- if (! ffileisopen (qtrans->e))
- {
- (void) fmail_transfer (FALSE, qtrans->s.zuser,
- (const char *) NULL,
- "cannot open file",
- qtrans->s.zfrom, (const char *) NULL,
- qtrans->s.zto,
- qdaemon->qsys->uuconf_zname,
- (qinfo->flocal
- ? zsysdep_save_temp_file (qtrans->s.pseq)
- : (const char *) NULL));
- (void) fsysdep_did_work (qtrans->s.pseq);
- usfree_send (qtrans);
-
- /* Unfortunately, there is no way to cancel a file send
- after we've already put it in progress. So we have to
- return FALSE to drop the connection. */
- return FALSE;
- }
- }
-
- /* If flocal_send_await_reply has received a reply with a file
- position, it will have set qtrans->ipos to the position at which
- to start. */
- if (qtrans->ipos > 0)
- {
- if (qinfo->zexec != NULL)
- {
- if (qtrans->ipos > qtrans->cbytes)
- qtrans->ipos = qtrans->cbytes;
- }
- else
- {
- if (! ffileseek (qtrans->e, qtrans->ipos))
- {
- ulog (LOG_ERROR, "seek: %s", strerror (errno));
- usfree_send (qtrans);
- return FALSE;
- }
- }
- }
-
- /* We don't bother to log sending the execution file. */
- if (qinfo->zexec == NULL)
- {
- const char *zsend;
- char *zalc;
-
- if (qtrans->s.bcmd != 'E')
- {
- zsend = qtrans->s.zfrom;
- zalc = NULL;
- }
- else
- {
- zalc = zbufalc (strlen (qtrans->s.zcmd) + sizeof " ()"
- + strlen (qtrans->s.zfrom));
- sprintf (zalc, "%s (%s)", qtrans->s.zcmd, qtrans->s.zfrom);
- zsend = zalc;
- }
-
- qtrans->zlog = zbufalc (sizeof "Sending ( bytes resume at )"
- + strlen (zsend) + 50);
- sprintf (qtrans->zlog, "Sending %s (%ld bytes", zsend, qinfo->cbytes);
- if (qtrans->ipos > 0)
- sprintf (qtrans->zlog + strlen (qtrans->zlog), " resume at %ld",
- qtrans->ipos);
- strcat (qtrans->zlog, ")");
-
- ubuffree (zalc);
- }
-
- if (qdaemon->qproto->pffile != NULL)
- {
- boolean fhandled;
-
- if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, TRUE, TRUE,
- qinfo->cbytes - qtrans->ipos,
- &fhandled))
- {
- usfree_send (qtrans);
- return FALSE;
- }
-
- if (fhandled)
- return TRUE;
- }
-
- if (qinfo->zexec != NULL)
- qtrans->psendfn = fsend_exec_file;
- else
- {
- qtrans->fsendfile = TRUE;
- qtrans->psendfn = fsend_file_end;
- }
-
- return fqueue_send (qdaemon, qtrans);
-}
-
-/* Cancel a file send. This is only called for a protocol which
- supports multiple channels. It is needed so that both systems
- agree as to when a channel is no longer needed. */
-
-static boolean
-flocal_send_cancelled (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo;
-
- /* If we are breaking a 'E' command into two 'S' commands, and that
- was for the first 'S' command, and the first 'S' command will
- never be sent, we still have to send the second one. */
- if (qinfo->fnever
- && qtrans->s.bcmd == 'E'
- && (qdaemon->ifeatures & FEATURE_EXEC) == 0
- && qinfo->zexec == NULL)
- return fsend_exec_file_init (qtrans, qdaemon);
-
- usfree_send (qtrans);
- return TRUE;
-}
-
-/* A remote request to receive a file (meaning that we have to send a
- file). The sequence of functions calls is as follows:
-
- fremote_rec_file_init (open file) --> fqueue_remote
- fremote_rec_reply (send RY, call pffile) --> fqueue_send
- send file
- fsend_file_end (calls pffile) --> fqueue_receive
- fsend_await_confirm (waits for CY)
- */
-
-boolean
-fremote_rec_file_init (qdaemon, qcmd, iremote)
- struct sdaemon *qdaemon;
- struct scmd *qcmd;
- int iremote;
-{
- const struct uuconf_system *qsys;
- char *zfile;
- boolean fbadname;
- long cbytes;
- unsigned int imode;
- openfile_t e;
- struct ssendinfo *qinfo;
- struct stransfer *qtrans;
-
- qsys = qdaemon->qsys;
-
- if (! qsys->uuconf_fsend_request)
- {
- ulog (LOG_ERROR, "%s: not permitted to send files to remote",
- qcmd->zfrom);
- return fremote_rec_fail (qdaemon, FAILURE_PERM, iremote);
- }
-
- if (fspool_file (qcmd->zfrom))
- {
- ulog (LOG_ERROR, "%s: not permitted to send", qcmd->zfrom);
- return fremote_rec_fail (qdaemon, FAILURE_PERM, iremote);
- }
-
- zfile = zsysdep_local_file (qcmd->zfrom, qsys->uuconf_zpubdir, &fbadname);
- if (zfile == NULL && fbadname)
- {
- ulog (LOG_ERROR, "%s: bad local file name", qcmd->zfrom);
- return fremote_rec_fail (qdaemon, FAILURE_PERM, iremote);
- }
- if (zfile != NULL)
- {
- char *zbased;
-
- zbased = zsysdep_add_base (zfile, qcmd->zto);
- ubuffree (zfile);
- zfile = zbased;
- }
- if (zfile == NULL)
- return fremote_rec_fail (qdaemon, FAILURE_PERM, iremote);
-
- if (! fin_directory_list (zfile, qsys->uuconf_pzremote_send,
- qsys->uuconf_zpubdir, TRUE, TRUE,
- (const char *) NULL))
- {
- ulog (LOG_ERROR, "%s: not permitted to send", zfile);
- ubuffree (zfile);
- return fremote_rec_fail (qdaemon, FAILURE_PERM, iremote);
- }
-
- /* If the file is larger than the amount of space the other side
- reported, we can't send it. Should we adjust this check based on
- the restart position? */
- cbytes = csysdep_size (zfile);
- if (cbytes != -1
- && ((qcmd->cbytes != -1 && qcmd->cbytes < cbytes)
- || (qdaemon->cremote_size != -1
- && qdaemon->cremote_size < cbytes)
- || (qdaemon->cmax_receive != -1
- && qdaemon->cmax_receive < cbytes)))
- {
- ulog (LOG_ERROR, "%s: too large to send", zfile);
- ubuffree (zfile);
- return fremote_rec_fail (qdaemon, FAILURE_SIZE, iremote);
- }
-
- imode = ixsysdep_file_mode (zfile);
-
- e = esysdep_open_send (qsys, zfile, TRUE, (const char *) NULL);
- if (! ffileisopen (e))
- {
- ubuffree (zfile);
- return fremote_rec_fail (qdaemon, FAILURE_OPEN, iremote);
- }
-
- /* If the remote requested that the file send start from a
- particular position, arrange to do so. */
- if (qcmd->ipos > 0)
- {
- if (! ffileseek (e, qcmd->ipos))
- {
- ulog (LOG_ERROR, "seek: %s", strerror (errno));
- ubuffree (zfile);
- return FALSE;
- }
- }
-
- qinfo = (struct ssendinfo *) xmalloc (sizeof (struct ssendinfo));
- qinfo->zmail = NULL;
- qinfo->zfile = zfile;
- qinfo->cbytes = cbytes;
- qinfo->flocal = FALSE;
- qinfo->fspool = FALSE;
- qinfo->fsent = FALSE;
- qinfo->zexec = NULL;
- qinfo->zconfirm = NULL;
-
- qtrans = qtransalc (qcmd);
- qtrans->psendfn = fremote_rec_reply;
- qtrans->iremote = iremote;
- qtrans->pinfo = (pointer) qinfo;
- qtrans->e = e;
- qtrans->ipos = qcmd->ipos;
- qtrans->s.imode = imode;
-
- return fqueue_remote (qdaemon, qtrans);
-}
-
-/* Reply to a receive request from the remote system, and prepare to
- start sending the file. */
-
-static boolean
-fremote_rec_reply (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo;
- char absend[50];
-
- qtrans->fsendfile = TRUE;
- qtrans->psendfn = fsend_file_end;
- qtrans->fcmd = TRUE;
- qtrans->precfn = fsend_await_confirm;
-
- if (! fqueue_send (qdaemon, qtrans))
- return FALSE;
-
- qtrans->zlog = zbufalc (sizeof "Sending ( bytes) "
- + strlen (qtrans->s.zfrom) + 25);
- sprintf (qtrans->zlog, "Sending %s (%ld bytes)", qtrans->s.zfrom,
- qinfo->cbytes);
-
- /* We send the file size because SVR4 UUCP does. We don't look for
- it. We send a trailing M if we want to request a hangup. We
- send it both after the mode and at the end of the entire string;
- I don't know where programs look for it. */
- if (qdaemon->frequest_hangup)
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO,
- "fremote_rec_reply: Requesting remote to transfer control");
- sprintf (absend, "RY 0%o%s 0x%lx%s", qtrans->s.imode,
- qdaemon->frequest_hangup ? "M" : "",
- (unsigned long) qinfo->cbytes,
- qdaemon->frequest_hangup ? "M" : "");
- if (! (*qdaemon->qproto->pfsendcmd) (qdaemon, absend, qtrans->ilocal,
- qtrans->iremote))
- {
- (void) ffileclose (qtrans->e);
- /* Should probably free qtrans here, but see the comment at the
- end of flocal_rec_send_request. */
- return FALSE;
- }
-
- if (qdaemon->qproto->pffile != NULL)
- {
- boolean fhandled;
-
- if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, TRUE, TRUE,
- qinfo->cbytes, &fhandled))
- {
- usfree_send (qtrans);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-/* If we can't send a file as requested by the remote system, queue up
- a failure reply which will be sent when possible. */
-
-static boolean
-fremote_rec_fail (qdaemon, twhy, iremote)
- struct sdaemon *qdaemon;
- enum tfailure twhy;
- int iremote;
-{
- enum tfailure *ptinfo;
- struct stransfer *qtrans;
-
- ptinfo = (enum tfailure *) xmalloc (sizeof (enum tfailure));
- *ptinfo = twhy;
-
- qtrans = qtransalc ((struct scmd *) NULL);
- qtrans->psendfn = fremote_rec_fail_send;
- qtrans->iremote = iremote;
- qtrans->pinfo = (pointer) ptinfo;
-
- return fqueue_remote (qdaemon, qtrans);
-}
-
-/* Send a failure string for a receive command to the remote system;
- this is called when we are ready to reply to the command. */
-
-static boolean
-fremote_rec_fail_send (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- enum tfailure *ptinfo = (enum tfailure *) qtrans->pinfo;
- const char *z;
- int ilocal, iremote;
-
- switch (*ptinfo)
- {
- case FAILURE_PERM:
- case FAILURE_OPEN:
- z = "RN2";
- break;
- case FAILURE_SIZE:
- z = "RN6";
- break;
- default:
- z = "RN";
- break;
- }
-
- ilocal = qtrans->ilocal;
- iremote = qtrans->iremote;
-
- xfree (qtrans->pinfo);
- utransfree (qtrans);
-
- return (*qdaemon->qproto->pfsendcmd) (qdaemon, z, ilocal, iremote);
-}
-
-/* This is called when the main loop has finished sending a file. It
- prepares to wait for a response from the remote system. Note that
- if this is a local request and the protocol supports multiple
- channels, we may not even have received a confirmation of the send
- request. */
-
-static boolean
-fsend_file_end (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo;
-
- if (qdaemon->qproto->pffile != NULL)
- {
- boolean fhandled;
-
- if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, FALSE, TRUE,
- (long) -1, &fhandled))
- {
- usfree_send (qtrans);
- return FALSE;
- }
-
- if (fhandled)
- return TRUE;
- }
-
- qinfo->fsent = TRUE;
-
- /* If zconfirm is set, then we have already received the
- confirmation, and should call fsend_await_confirm directly. */
- if (qinfo->zconfirm != NULL)
- return fsend_await_confirm (qtrans, qdaemon, qinfo->zconfirm,
- strlen (qinfo->zconfirm) + 1);
-
- /* qtrans->precfn should have been set by a previous function. */
- return fqueue_receive (qdaemon, qtrans);
-}
-
-/* Handle the confirmation string received after sending a file. */
-
-/*ARGSUSED*/
-static boolean
-fsend_await_confirm (qtrans, qdaemon, zdata, cdata)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
- const char *zdata;
- size_t cdata;
-{
- struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo;
- boolean fnever;
- const char *zerr;
-
- /* If fsent is FALSE, it means that we have received the
- confirmation before fsend_file_end got called. To avoid
- confusion, we save away the confirmation message, and let
- fsend_file_end call us directly. If we did not do this, we would
- have to fix a thorny race condition in floop, which wants to
- refer to the qtrans structure after sending the end of the file. */
- if (! qinfo->fsent)
- {
- qinfo->zconfirm = zbufcpy (zdata);
- return TRUE;
- }
-
- if (qinfo->zexec == NULL)
- (void) ffileclose (qtrans->e);
-
- fnever = FALSE;
- if (zdata[0] != 'C'
- || (zdata[1] != 'Y' && zdata[1] != 'N'))
- {
- zerr = "bad confirmation from remote";
- ulog (LOG_ERROR, "%s: %s \"%s\"", qtrans->s.zfrom, zerr, zdata);
- }
- else if (zdata[1] == 'N')
- {
- fnever = TRUE;
- if (zdata[2] == '5')
- {
- zerr = "file could not be stored in final location";
- ulog (LOG_ERROR, "%s: %s", qtrans->s.zfrom, zerr);
- }
- else
- {
- zerr = "file send failed for unknown reason";
- ulog (LOG_ERROR, "%s: %s \"%s\"", qtrans->s.zfrom, zerr, zdata);
- }
- }
- else
- {
- zerr = NULL;
-
- /* If we receive CYM, it means that the other side wants us to
- hang up so that they can send us something. The
- fhangup_requested field is checked in the main loop. */
- if (zdata[2] == 'M' && qdaemon->fmaster)
- {
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO,
- "fsend_await_confirm: Remote has requested transfer of control");
- qdaemon->fhangup_requested = TRUE;
- }
- }
-
- ustats (zerr == NULL, qtrans->s.zuser, qdaemon->qsys->uuconf_zname,
- TRUE, qtrans->cbytes, qtrans->isecs, qtrans->imicros,
- qdaemon->fcaller);
- qdaemon->csent += qtrans->cbytes;
-
- if (zerr == NULL)
- {
- /* If this is an execution request, and the remote system
- doesn't support execution requests, we have to set up the
- fake execution file and loop around again. */
- if (qtrans->s.bcmd == 'E'
- && (qdaemon->ifeatures & FEATURE_EXEC) == 0
- && qinfo->zexec == NULL)
- return fsend_exec_file_init (qtrans, qdaemon);
-
- /* Send mail about the transfer if requested. */
- if (qinfo->zmail != NULL && *qinfo->zmail != '\0')
- (void) fmail_transfer (TRUE, qtrans->s.zuser, qinfo->zmail,
- (const char *) NULL,
- qtrans->s.zfrom, (const char *) NULL,
- qtrans->s.zto, qdaemon->qsys->uuconf_zname,
- (const char *) NULL);
-
- if (qtrans->s.pseq != NULL)
- (void) fsysdep_did_work (qtrans->s.pseq);
- }
- else
- {
- /* If the file send failed, we only try to save the file and
- send mail if it was requested locally and it will never
- succeed. We send mail to qinfo->zmail if set, otherwise to
- qtrans->s.zuser. I hope this is reasonable. */
- if (fnever && qinfo->flocal)
- {
- (void) fmail_transfer (FALSE, qtrans->s.zuser, qinfo->zmail,
- zerr, qtrans->s.zfrom, (const char *) NULL,
- qtrans->s.zto, qdaemon->qsys->uuconf_zname,
- zsysdep_save_temp_file (qtrans->s.pseq));
- (void) fsysdep_did_work (qtrans->s.pseq);
- }
- }
-
- usfree_send (qtrans);
-
- return TRUE;
-}
-
-/* Prepare to send an execution file to a system which does not
- support execution requests. We build the execution file in memory,
- and then call flocal_send_request as though we were sending a real
- file. Instead of sending a file, the code in flocal_send_open_file
- will arrange to call fsend_exec_file which will send data out of
- the buffer we have created. */
-
-static boolean
-fsend_exec_file_init (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo;
- char *zxqtfile;
- char abtname[CFILE_NAME_LEN];
- char abxname[CFILE_NAME_LEN];
- char *z;
- size_t calc, clen;
-
- z = NULL;
- calc = 0;
- clen = 0;
-
- usadd_exec_line (&z, &calc, &clen, 'U', qtrans->s.zuser,
- qdaemon->zlocalname);
- usadd_exec_line (&z, &calc, &clen, 'F', qtrans->s.zto, "");
- usadd_exec_line (&z, &calc, &clen, 'I', qtrans->s.zto, "");
- if (strchr (qtrans->s.zoptions, 'N') != NULL)
- usadd_exec_line (&z, &calc, &clen, 'N', "", "");
- if (strchr (qtrans->s.zoptions, 'Z') != NULL)
- usadd_exec_line (&z, &calc, &clen, 'Z', "", "");
- if (strchr (qtrans->s.zoptions, 'R') != NULL)
- usadd_exec_line (&z, &calc, &clen, 'R', qtrans->s.znotify, "");
- if (strchr (qtrans->s.zoptions, 'e') != NULL)
- usadd_exec_line (&z, &calc, &clen, 'e', "", "");
- usadd_exec_line (&z, &calc, &clen, 'C', qtrans->s.zcmd, "");
-
- qinfo->zexec = z;
- qinfo->cbytes = clen;
-
- zxqtfile = zsysdep_data_file_name (qdaemon->qsys, qdaemon->zlocalname,
- BDEFAULT_UUX_GRADE, TRUE, abtname,
- (char *) NULL, abxname);
- if (zxqtfile == NULL)
- {
- usfree_send (qtrans);
- return FALSE;
- }
- ubuffree (zxqtfile);
-
- ubuffree ((char *) qtrans->s.zfrom);
- qtrans->s.zfrom = zbufcpy (abtname);
- ubuffree ((char *) qtrans->s.zto);
- qtrans->s.zto = zbufcpy (abxname);
- ubuffree ((char *) qtrans->s.zoptions);
- qtrans->s.zoptions = zbufcpy ("C");
- ubuffree ((char *) qtrans->s.ztemp);
- qtrans->s.ztemp = zbufcpy (abtname);
-
- qtrans->psendfn = flocal_send_request;
- qtrans->precfn = NULL;
- qtrans->ipos = 0;
- qtrans->cbytes = 0;
- qtrans->isecs = 0;
- qtrans->imicros = 0;
- qinfo->fsent = FALSE;
- ubuffree (qinfo->zconfirm);
- qinfo->zconfirm = NULL;
-
- return fqueue_send (qdaemon, qtrans);
-}
-
-/* Add a line to the fake execution file. */
-
-static void
-usadd_exec_line (pz, pcalc, pclen, bcmd, z1, z2)
- char **pz;
- size_t *pcalc;
- size_t *pclen;
- int bcmd;
- const char *z1;
- const char *z2;
-{
- size_t c1, c2;
- char *znew;
-
- c1 = strlen (z1);
- c2 = strlen (z2);
-
- if (*pclen + c1 + c2 + 4 >= *pcalc)
- {
- *pcalc += c1 + c2 + 100;
- znew = zbufalc (*pcalc);
- if (*pclen > 0)
- {
- memcpy (znew, *pz, *pclen);
- ubuffree (*pz);
- }
- *pz = znew;
- }
-
- znew = *pz + *pclen;
- *znew++ = bcmd;
- if (*z1 != '\0')
- {
- *znew++ = ' ';
- memcpy (znew, z1, c1);
- znew += c1;
- if (*z2 != '\0')
- {
- *znew++ = ' ';
- memcpy (znew, z2, c2);
- znew += c2;
- }
- }
-
- /* In some bizarre non-Unix case we might have to worry about the
- newline here. We don't know how a newline is normally written
- out to a file, but whatever is written to a file is what we will
- normally transfer. If that is not simply \n then this fake
- execution file will not look like other execution files. */
- *znew++ = '\n';
-
- *pclen = znew - *pz;
-}
-
-/* This routine is called to send the contents of the fake execution
- file. Normally file data is sent by the floop routine in trans.c,
- but since we don't have an actual file we must do it here. This
- routine sends the complete buffer, followed by a zero length
- packet, and then calls fsend_file_end. */
-
-static boolean
-fsend_exec_file (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo;
- char *zdata;
- size_t cdata;
- size_t csend;
-
- zdata = (*qdaemon->qproto->pzgetspace) (qdaemon, &cdata);
- if (zdata == NULL)
- {
- usfree_send (qtrans);
- return FALSE;
- }
-
- csend = qinfo->cbytes - qtrans->ipos;
- if (csend > cdata)
- csend = cdata;
-
- memcpy (zdata, qinfo->zexec + qtrans->ipos, csend);
-
- if (! (*qdaemon->qproto->pfsenddata) (qdaemon, zdata, csend,
- qtrans->ilocal, qtrans->iremote,
- qtrans->ipos))
- {
- usfree_send (qtrans);
- return FALSE;
- }
-
- qtrans->cbytes += csend;
- qtrans->ipos += csend;
-
- if (csend == 0)
- return fsend_file_end (qtrans, qdaemon);
-
- /* Leave the job on the send queue. */
-
- return TRUE;
-}
diff --git a/gnu/libexec/uucp/uucico/time.c b/gnu/libexec/uucp/uucico/time.c
deleted file mode 100644
index 1f65b59..0000000
--- a/gnu/libexec/uucp/uucico/time.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* time.c
- Routines to deal with UUCP time spans.
-
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char time_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-
-#if TM_IN_SYS_TIME
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-
-/* External functions. */
-#ifndef time
-extern time_t time ();
-#endif
-#ifndef localtime
-extern struct tm *localtime ();
-#endif
-
-/* See if the current time matches a time span. If it does, return
- TRUE, set *pival to the value for the matching span, and set
- *pcretry to the retry for the matching span. Otherwise return
- FALSE. */
-
-boolean
-ftimespan_match (qspan, pival, pcretry)
- const struct uuconf_timespan *qspan;
- long *pival;
- int *pcretry;
-{
- time_t inow;
- struct tm *qtm;
- int itm;
- const struct uuconf_timespan *q;
-
- if (qspan == NULL)
- return FALSE;
-
- time (&inow);
- qtm = localtime (&inow);
-
- /* Get the number of minutes since Sunday for the time. */
- itm = qtm->tm_wday * 24 * 60 + qtm->tm_hour * 60 + qtm->tm_min;
-
- for (q = qspan; q != NULL; q = q->uuconf_qnext)
- {
- if (q->uuconf_istart <= itm && itm <= q->uuconf_iend)
- {
- if (pival != NULL)
- *pival = q->uuconf_ival;
- if (pcretry != NULL)
- *pcretry = q->uuconf_cretry;
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-/* Determine the maximum size that may ever be transferred, according
- to a timesize span. This returns -1 if there is no limit. */
-
-long
-cmax_size_ever (qtimesize)
- const struct uuconf_timespan *qtimesize;
-{
- long imax;
- const struct uuconf_timespan *q;
-
- if (qtimesize == NULL)
- return -1;
-
- /* Look through the list of spans. If there is any gap larger than
- 1 hour, we assume there are no restrictions. Otherwise we keep
- track of the largest value we see. I picked 1 hour arbitrarily,
- on the theory that a 1 hour span to transfer large files might
- actually occur, and is probably not an accident. */
- if (qtimesize->uuconf_istart >= 60)
- return -1;
-
- imax = -1;
-
- for (q = qtimesize; q != NULL; q = q->uuconf_qnext)
- {
- if (q->uuconf_qnext == NULL)
- {
- if (q->uuconf_iend <= 6 * 24 * 60 + 23 * 60)
- return -1;
- }
- else
- {
- if (q->uuconf_iend + 60 <= q->uuconf_qnext->uuconf_istart)
- return -1;
- }
-
- if (imax < q->uuconf_ival)
- imax = q->uuconf_ival;
- }
-
- return imax;
-}
diff --git a/gnu/libexec/uucp/uucico/trans.c b/gnu/libexec/uucp/uucico/trans.c
deleted file mode 100644
index b1f0e2c..0000000
--- a/gnu/libexec/uucp/uucico/trans.c
+++ /dev/null
@@ -1,1489 +0,0 @@
-/* trans.c
- Routines to handle file transfers.
-
- Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char trans_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "prot.h"
-#include "system.h"
-#include "trans.h"
-
-/* Local functions. */
-
-static void utqueue P((struct stransfer **, struct stransfer *,
- boolean fhead));
-static void utdequeue P((struct stransfer *));
-static void utchanalc P((struct sdaemon *qdaemon, struct stransfer *qtrans));
-__inline__ static struct stransfer *qtchan P((int ichan));
-__inline__ static void utchanfree P((struct stransfer *qtrans));
-static boolean fttime P((struct sdaemon *qdaemon, long *pisecs,
- long *pimicros));
-static boolean fcheck_queue P((struct sdaemon *qdaemon));
-static boolean ftadd_cmd P((struct sdaemon *qdaemon, const char *z,
- size_t cdata, int iremote, boolean flast));
-static boolean fremote_hangup_reply P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean flocal_poll_file P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-
-/* Queue of transfer structures that are ready to start which have
- been requested by the local system. These are only permitted to
- start when the local system is the master. */
-static struct stransfer *qTlocal;
-
-/* Queue of transfer structures that are ready to start which have
- been requested by the remote system. These are responses to
- commands received from the remote system, and should be started as
- soon as possible. */
-static struct stransfer *qTremote;
-
-/* Queue of transfer structures that have been started and want to
- send information. This should be static, but the 'a' protocol
- looks at it, at least for now. */
-struct stransfer *qTsend;
-
-/* Queue of transfer structures that have been started and are waiting
- to receive information. */
-static struct stransfer *qTreceive;
-
-/* Queue of free transfer structures. */
-static struct stransfer *qTavail;
-
-/* Array of transfer structures indexed by local channel number. This
- is maintained for local jobs. */
-static struct stransfer *aqTchan[IMAX_CHAN + 1];
-
-/* Number of local channel numbers currently allocated. */
-static int cTchans;
-
-/* Next channel number to allocate. */
-static int iTchan;
-
-/* Array of transfer structures indexed by remote channel number.
- This is maintained for remote jobs. */
-static struct stransfer *aqTremote[IMAX_CHAN + 1];
-
-/* The transaction we are currently receiving. This is used to avoid
- getting the time too frequently. */
-static struct stransfer *qTtiming_rec;
-
-/* The time from which to charge any received data. This is either
- the last time we charged for received data, or the last time
- something was put on the empty receive queue. */
-static long iTrecsecs;
-static long iTrecmicros;
-
-/* The minimum amount of time, in seconds, to wait between times we
- check the spool directory, if we are busy transferring data. If we
- have nothing to do, we will check the spool directory regardless of
- how long ago the last check was. This should probably be
- configurable. */
-#define CCHECKWAIT (600)
-
-/* The time we last checked the spool directory for work. This is set
- from the return value of ixsysdep_process_time, not ixsysdep_time,
- for convenience in the routines which use it. */
-static long iTchecktime;
-
-/* The size of the command we have read so far in ftadd_cmd. */
-static size_t cTcmdlen;
-
-/* The structure we use when waiting for an acknowledgement of a
- confirmed received file in fsent_receive_ack, and a list of those
- structures. */
-
-struct sreceive_ack
-{
- struct sreceive_ack *qnext;
- char *zto;
- char *ztemp;
- boolean fmarked;
-};
-
-static struct sreceive_ack *qTreceive_ack;
-
-/* Queue up a transfer structure before *pq. This puts it at the head
- or the tail of the list headed by *pq. */
-
-static void
-utqueue (pq, q, fhead)
- struct stransfer **pq;
- struct stransfer *q;
- boolean fhead;
-{
- if (*pq == NULL)
- {
- *pq = q;
- q->qprev = q->qnext = q;
- }
- else
- {
- q->qnext = *pq;
- q->qprev = (*pq)->qprev;
- q->qprev->qnext = q;
- q->qnext->qprev = q;
- if (fhead)
- *pq = q;
- }
- q->pqqueue = pq;
-}
-
-/* Dequeue a transfer structure. */
-
-static void
-utdequeue (q)
- struct stransfer *q;
-{
- if (q->pqqueue != NULL)
- {
- if (*(q->pqqueue) == q)
- {
- if (q->qnext == q)
- *(q->pqqueue) = NULL;
- else
- *(q->pqqueue) = q->qnext;
- }
- q->pqqueue = NULL;
- }
- if (q->qprev != NULL)
- q->qprev->qnext = q->qnext;
- if (q->qnext != NULL)
- q->qnext->qprev = q->qprev;
- q->qprev = NULL;
- q->qnext = NULL;
-}
-
-/* Queue up a transfer structure requested by the local system. */
-
-/*ARGSIGNORED*/
-boolean
-fqueue_local (qdaemon, qtrans)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
-{
- utdequeue (qtrans);
- utqueue (&qTlocal, qtrans, FALSE);
- return TRUE;
-}
-
-/* Queue up a transfer structure requested by the remote system. The
- stransfer structure should have the iremote field set. We need to
- record it, so that any subsequent data associated with this
- channel can be routed to the right place. */
-
-boolean
-fqueue_remote (qdaemon, qtrans)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
-{
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fqueue_remote: Channel %d",
- qtrans->iremote);
- if (qtrans->iremote > 0)
- aqTremote[qtrans->iremote] = qtrans;
- utdequeue (qtrans);
- utqueue (&qTremote, qtrans, FALSE);
- return TRUE;
-}
-
-/* Queue up a transfer with something to send. */
-
-boolean
-fqueue_send (qdaemon, qtrans)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
-{
-#if DEBUG > 0
- if (qtrans->psendfn == NULL)
- ulog (LOG_FATAL, "fqueue_send: Bad call");
-#endif
- utdequeue (qtrans);
-
- /* Sort the send queue to always send commands before files, and to
- sort jobs by grade. */
- if (qTsend == NULL)
- utqueue (&qTsend, qtrans, FALSE);
- else
- {
- register struct stransfer *q;
- boolean ffirst;
-
- ffirst = TRUE;
- q = qTsend;
- do
- {
- if (! qtrans->fsendfile && q->fsendfile)
- break;
- if ((! qtrans->fsendfile || q->fsendfile)
- && UUCONF_GRADE_CMP (qtrans->s.bgrade, q->s.bgrade) < 0)
- break;
-
- ffirst = FALSE;
- q = q->qnext;
- }
- while (q != qTsend);
-
- qtrans->qnext = q;
- qtrans->qprev = q->qprev;
- q->qprev = qtrans;
- qtrans->qprev->qnext = qtrans;
- if (ffirst)
- qTsend = qtrans;
- qtrans->pqqueue = &qTsend;
- }
-
- return TRUE;
-}
-
-/* Queue up a transfer with something to receive. */
-
-boolean
-fqueue_receive (qdaemon, qtrans)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
-{
-#if DEBUG > 0
- if (qtrans->precfn == NULL)
- ulog (LOG_FATAL, "fqueue_receive: Bad call");
-#endif
-
- /* If this is the only item on the receive queue, we do not want to
- charge it for any time during which we have not been waiting for
- anything, so update the receive timestamp. */
- if (qTreceive == NULL)
- iTrecsecs = ixsysdep_process_time (&iTrecmicros);
-
- utdequeue (qtrans);
- utqueue (&qTreceive, qtrans, FALSE);
-
- return TRUE;
-}
-
-/* Get a new local channel number. */
-
-static void
-utchanalc (qdaemon, qtrans)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
-{
- do
- {
- ++iTchan;
- if (iTchan > qdaemon->cchans)
- iTchan = 1;
- }
- while (aqTchan[iTchan] != NULL);
-
- qtrans->ilocal = iTchan;
- aqTchan[iTchan] = qtrans;
- ++cTchans;
-}
-
-/* Return the transfer for a channel number. */
-
-__inline__
-static struct stransfer *
-qtchan (ic)
- int ic;
-{
- return aqTchan[ic];
-}
-
-/* Clear the channel number for a transfer. */
-
-__inline__
-static void
-utchanfree (qt)
- struct stransfer *qt;
-{
- if (qt->ilocal != 0)
- {
- aqTchan[qt->ilocal] = NULL;
- qt->ilocal = 0;
- --cTchans;
- }
-}
-
-/* Allocate a new transfer structure. */
-
-struct stransfer *
-qtransalc (qcmd)
- struct scmd *qcmd;
-{
- register struct stransfer *q;
-
- q = qTavail;
- if (q != NULL)
- utdequeue (q);
- else
- q = (struct stransfer *) xmalloc (sizeof (struct stransfer));
- q->qnext = NULL;
- q->qprev = NULL;
- q->pqqueue = NULL;
- q->psendfn = NULL;
- q->precfn = NULL;
- q->pinfo = NULL;
- q->fsendfile = FALSE;
- q->frecfile = FALSE;
- q->e = EFILECLOSED;
- q->ipos = 0;
- q->fcmd = FALSE;
- q->zcmd = NULL;
- q->ccmd = 0;
- q->ilocal = 0;
- q->iremote = 0;
- if (qcmd != NULL)
- {
- q->s = *qcmd;
- q->s.zfrom = zbufcpy (qcmd->zfrom);
- q->s.zto = zbufcpy (qcmd->zto);
- q->s.zuser = zbufcpy (qcmd->zuser);
- q->s.zoptions = zbufcpy (qcmd->zoptions);
- q->s.ztemp = zbufcpy (qcmd->ztemp);
- q->s.znotify = zbufcpy (qcmd->znotify);
- q->s.zcmd = zbufcpy (qcmd->zcmd);
- }
- else
- {
- q->s.zfrom = NULL;
- q->s.zto = NULL;
- q->s.zuser = NULL;
- q->s.zoptions = NULL;
- q->s.ztemp = NULL;
- q->s.znotify = NULL;
- q->s.zcmd = NULL;
- }
- q->zlog = NULL;
- q->isecs = 0;
- q->imicros = 0;
- q->cbytes = 0;
-
- return q;
-}
-
-/* Free a transfer structure. This does not free any pinfo
- information that may have been allocated. */
-
-void
-utransfree (q)
- struct stransfer *q;
-{
- ubuffree (q->zcmd);
- ubuffree ((char *) q->s.zfrom);
- ubuffree ((char *) q->s.zto);
- ubuffree ((char *) q->s.zuser);
- ubuffree ((char *) q->s.zoptions);
- ubuffree ((char *) q->s.ztemp);
- ubuffree ((char *) q->s.znotify);
- ubuffree ((char *) q->s.zcmd);
-
- utchanfree (q);
- if (q->iremote > 0)
- {
- aqTremote[q->iremote] = NULL;
- q->iremote = 0;
- }
-
-#if DEBUG > 0
- q->e = EFILECLOSED;
- q->zcmd = NULL;
- q->s.zfrom = NULL;
- q->s.zto = NULL;
- q->s.zuser = NULL;
- q->s.zoptions = NULL;
- q->s.ztemp = NULL;
- q->s.znotify = NULL;
- q->s.zcmd = NULL;
- q->psendfn = NULL;
- q->precfn = NULL;
-#endif
-
- /* Avoid any possible confusion in the timing code. */
- if (qTtiming_rec == q)
- qTtiming_rec = NULL;
-
- utdequeue (q);
- utqueue (&qTavail, q, FALSE);
-}
-
-/* Get the time. This is a wrapper around ixsysdep_process_time. If
- enough time has elapsed since the last time we got the time, check
- the work queue. */
-
-static boolean
-fttime (qdaemon, pisecs, pimicros)
- struct sdaemon *qdaemon;
- long *pisecs;
- long *pimicros;
-{
- *pisecs = ixsysdep_process_time (pimicros);
- if (*pisecs - iTchecktime >= CCHECKWAIT)
- {
- if (! fcheck_queue (qdaemon))
- return FALSE;
- }
- return TRUE;
-}
-
-/* Gather local commands and queue them up for later processing. Also
- recompute time based control values. */
-
-boolean
-fqueue (qdaemon, pfany)
- struct sdaemon *qdaemon;
- boolean *pfany;
-{
- const struct uuconf_system *qsys;
- long ival;
- int bgrade;
- struct uuconf_timespan *qlocal_size, *qremote_size;
-
- if (pfany != NULL)
- *pfany = FALSE;
-
- qsys = qdaemon->qsys;
-
- /* If we are not the caller, the grade will be set during the
- initial handshake, although this may be overridden by the
- calledtimegrade configuration option. */
- if (! qdaemon->fcaller)
- {
- if (! ftimespan_match (qsys->uuconf_qcalledtimegrade, &ival,
- (int *) NULL))
- bgrade = qdaemon->bgrade;
- else
- bgrade = (char) ival;
- }
- else
- {
- if (! ftimespan_match (qsys->uuconf_qtimegrade, &ival,
- (int *) NULL))
- bgrade = '\0';
- else
- bgrade = (char) ival;
- }
-
- /* Determine the maximum sizes we can send and receive. */
- if (qdaemon->fcaller)
- {
- qlocal_size = qsys->uuconf_qcall_local_size;
- qremote_size = qsys->uuconf_qcall_remote_size;
- }
- else
- {
- qlocal_size = qsys->uuconf_qcalled_local_size;
- qremote_size = qsys->uuconf_qcalled_remote_size;
- }
-
- if (! ftimespan_match (qlocal_size, &qdaemon->clocal_size, (int *) NULL))
- qdaemon->clocal_size = (long) -1;
- if (! ftimespan_match (qremote_size, &qdaemon->cremote_size, (int *) NULL))
- qdaemon->cremote_size = (long) -1;
-
- if (bgrade == '\0')
- return TRUE;
-
- if (! fsysdep_get_work_init (qsys, bgrade))
- return FALSE;
-
- while (TRUE)
- {
- struct scmd s;
-
- if (! fsysdep_get_work (qsys, bgrade, &s))
- return FALSE;
-
- if (s.bcmd == 'H')
- {
- ulog_user ((const char *) NULL);
- break;
- }
-
- if (s.bcmd == 'P')
- {
- struct stransfer *qtrans;
-
- /* A poll file. */
- ulog_user ((const char *) NULL);
- qtrans = qtransalc (&s);
- qtrans->psendfn = flocal_poll_file;
- if (! fqueue_local (qdaemon, qtrans))
- return FALSE;
- continue;
- }
-
- ulog_user (s.zuser);
-
- switch (s.bcmd)
- {
- case 'S':
- case 'E':
- if (! flocal_send_file_init (qdaemon, &s))
- return FALSE;
- break;
- case 'R':
- if (! flocal_rec_file_init (qdaemon, &s))
- return FALSE;
- break;
- case 'X':
- if (! flocal_xcmd_init (qdaemon, &s))
- return FALSE;
- break;
-#if DEBUG > 0
- default:
- ulog (LOG_FATAL, "fqueue: Can't happen");
- break;
-#endif
- }
- }
-
- if (pfany != NULL)
- *pfany = qTlocal != NULL;
-
- iTchecktime = ixsysdep_process_time ((long *) NULL);
-
- return TRUE;
-}
-
-/* Clear everything off the work queue. This is used when the call is
- complete, or if the call is never made. */
-
-void
-uclear_queue (qdaemon)
- struct sdaemon *qdaemon;
-{
- int i;
-
- usysdep_get_work_free (qdaemon->qsys);
-
- qTlocal = NULL;
- qTremote = NULL;
- qTsend = NULL;
- qTreceive = NULL;
- cTchans = 0;
- iTchan = 0;
- qTtiming_rec = NULL;
- cTcmdlen = 0;
- qTreceive_ack = NULL;
- for (i = 0; i < IMAX_CHAN + 1; i++)
- {
- aqTchan[i] = NULL;
- aqTremote[i] = NULL;
- }
-}
-
-/* Recheck the work queue during a conversation. This is only called
- if it's been more than CCHECKWAIT seconds since the last time the
- queue was checked. */
-
-static boolean
-fcheck_queue (qdaemon)
- struct sdaemon *qdaemon;
-{
- /* Only check if we are the master, or if there are multiple
- channels, or if we aren't already trying to get the other side to
- hang up. Otherwise, there's nothing we can do with any new jobs
- we might find. */
- if (qdaemon->fmaster
- || qdaemon->cchans > 1
- || ! qdaemon->frequest_hangup)
- {
- boolean fany;
-
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO,
- "fcheck_queue: Rechecking work queue");
- if (! fqueue (qdaemon, &fany))
- return FALSE;
-
- /* If we found something to do, and we're not the master, and we
- don't have multiple channels to send new jobs over, try to
- get the other side to hang up. */
- if (fany && ! qdaemon->fmaster && qdaemon->cchans <= 1)
- qdaemon->frequest_hangup = TRUE;
- }
-
- return TRUE;
-}
-
-/* The main transfer loop. The uucico daemon spends essentially all
- its time in this function. */
-
-boolean
-floop (qdaemon)
- struct sdaemon *qdaemon;
-{
- boolean fret;
-
- fret = TRUE;
-
- while (! qdaemon->fhangup)
- {
- register struct stransfer *q;
-
-#if DEBUG > 1
- /* If we're doing any debugging, close the log and debugging
- files regularly. This will let people copy them off and
- remove them while the conversation is in progresss. */
- if (iDebug != 0)
- {
- ulog_close ();
- ustats_close ();
- }
-#endif
-
- if (qdaemon->fmaster)
- {
- boolean fhangup;
-
- /* We've managed to become the master, so we no longer want
- to request a hangup. */
- qdaemon->frequest_hangup = FALSE;
-
- fhangup = FALSE;
-
- if (qdaemon->fhangup_requested
- && qTsend == NULL)
- {
- /* The remote system has requested that we transfer
- control by sending CYM after receiving a file. */
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO,
- "floop: Transferring control at remote request");
- fhangup = TRUE;
- }
- else if (qTremote == NULL
- && qTlocal == NULL
- && qTsend == NULL
- && qTreceive == NULL)
- {
- /* We don't have anything to do. Try to find some new
- jobs. If we can't, transfer control. */
- if (! fqueue (qdaemon, (boolean *) NULL))
- {
- fret = FALSE;
- break;
- }
- if (qTlocal == NULL)
- {
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO,
- "floop: No work for master");
- fhangup = TRUE;
- }
- }
-
- if (fhangup)
- {
- if (! (*qdaemon->qproto->pfsendcmd) (qdaemon, "H", 0, 0))
- {
- fret = FALSE;
- break;
- }
- qdaemon->fmaster = FALSE;
- }
- }
-
- /* If we are no long the master, clear any requested hangup. We
- may have already hung up before checking this variable in the
- block above. */
- if (! qdaemon->fmaster)
- qdaemon->fhangup_requested = FALSE;
-
- /* Immediately queue up any remote jobs. We don't need local
- channel numbers for them, since we can disambiguate based on
- the remote channel number. */
- while (qTremote != NULL)
- {
- q = qTremote;
- utdequeue (q);
- utqueue (&qTsend, q, TRUE);
- }
-
- /* If we are the master, or if we have multiple channels, try to
- queue up additional local jobs. */
- if (qdaemon->fmaster || qdaemon->cchans > 1)
- {
- while (qTlocal != NULL && cTchans < qdaemon->cchans)
- {
- /* We have room for an additional channel. */
- q = qTlocal;
- if (! fqueue_send (qdaemon, q))
- {
- fret = FALSE;
- break;
- }
- utchanalc (qdaemon, q);
- }
- if (! fret)
- break;
- }
-
- q = qTsend;
-
- if (q == NULL)
- {
- ulog_user ((const char *) NULL);
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "floop: Waiting for data");
- if (! (*qdaemon->qproto->pfwait) (qdaemon))
- {
- fret = FALSE;
- break;
- }
- }
- else
- {
- ulog_user (q->s.zuser);
-
- if (! q->fsendfile)
- {
- /* Technically, we should add the time required for this
- call to q->isecs and q->imicros. In practice, the
- amount of time required should be sufficiently small
- that it can be safely disregarded. */
- if (! (*q->psendfn) (q, qdaemon))
- {
- fret = FALSE;
- break;
- }
- }
- else
- {
- long isecs, imicros;
- boolean fcharged;
- long inextsecs = 0, inextmicros;
-
- if (! fttime (qdaemon, &isecs, &imicros))
- {
- fret = FALSE;
- break;
- }
- fcharged = FALSE;
-
- if (q->zlog != NULL)
- {
- ulog (LOG_NORMAL, "%s", q->zlog);
- ubuffree (q->zlog);
- q->zlog = NULL;
- }
-
- /* We can read the file in a tight loop until we have a
- command to send, or the file send has been cancelled,
- or we have a remote job to deal with. We can
- disregard any changes to qTlocal since we already
- have something to send anyhow. */
- while (q == qTsend
- && q->fsendfile
- && qTremote == NULL)
- {
- char *zdata;
- size_t cdata;
- long ipos;
-
- zdata = (*qdaemon->qproto->pzgetspace) (qdaemon, &cdata);
- if (zdata == NULL)
- {
- fret = FALSE;
- break;
- }
-
- if (ffileeof (q->e))
- cdata = 0;
- else
- {
- cdata = cfileread (q->e, zdata, cdata);
- if (ffileioerror (q->e, cdata))
- {
- /* There is no way to report a file reading
- error, so we just drop the connection. */
- ulog (LOG_ERROR, "read: %s", strerror (errno));
- fret = FALSE;
- break;
- }
- }
-
- ipos = q->ipos;
- q->ipos += cdata;
- q->cbytes += cdata;
-
- if (! (*qdaemon->qproto->pfsenddata) (qdaemon, zdata,
- cdata, q->ilocal,
- q->iremote, ipos))
- {
- fret = FALSE;
- break;
- }
-
- if (cdata == 0)
- {
- /* We must update the time now, because this
- call may make an entry in the statistics
- file. */
- inextsecs = ixsysdep_process_time (&inextmicros);
- DEBUG_MESSAGE4 (DEBUG_UUCP_PROTO,
- "floop: Charging %ld to %c %s %s",
- ((inextsecs - isecs) * 1000000
- + inextmicros - imicros),
- q->s.bcmd, q->s.zfrom, q->s.zto);
- q->isecs += inextsecs - isecs;
- q->imicros += inextmicros - imicros;
- fcharged = TRUE;
-
- q->fsendfile = FALSE;
-
- if (! (*q->psendfn) (q, qdaemon))
- fret = FALSE;
-
- break;
- }
- }
-
- if (! fret)
- break;
-
- if (! fcharged)
- {
- inextsecs = ixsysdep_process_time (&inextmicros);
- DEBUG_MESSAGE4 (DEBUG_UUCP_PROTO,
- "floop: Charging %ld to %c %s %s",
- ((inextsecs - isecs) * 1000000
- + inextmicros - imicros),
- q->s.bcmd, q->s.zfrom, q->s.zto);
- q->isecs += inextsecs - isecs;
- q->imicros += inextmicros - imicros;
- }
-
- if (inextsecs - iTchecktime >= CCHECKWAIT)
- {
- if (! fcheck_queue (qdaemon))
- {
- fret = FALSE;
- break;
- }
- }
- }
- }
- }
-
- ulog_user ((const char *) NULL);
-
- (void) (*qdaemon->qproto->pfshutdown) (qdaemon);
-
- if (fret)
- uwindow_acked (qdaemon, TRUE);
- else
- ufailed (qdaemon);
-
- return fret;
-}
-
-/* This is called by the protocol routines when they have received
- some data. If pfexit is not NULL, *pfexit should be set to TRUE if
- the protocol receive loop should exit back to the main floop
- routine, above. It is only important to set *pfexit to TRUE if the
- main loop called the pfwait entry point, so we need never set it to
- TRUE if we just receive data for a file. This routine never sets
- *pfexit to FALSE. */
-
-boolean
-fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos,
- fallacked, pfexit)
- struct sdaemon *qdaemon;
- const char *zfirst;
- size_t cfirst;
- const char *zsecond;
- size_t csecond;
- int ilocal;
- int iremote;
- long ipos;
- boolean fallacked;
- boolean *pfexit;
-{
- struct stransfer *q;
- int cwrote;
- boolean fret;
- long isecs, imicros;
-
- if (fallacked && qTreceive_ack != NULL)
- uwindow_acked (qdaemon, TRUE);
-
- /* Now we have to decide which transfer structure gets the data. If
- ilocal is -1, it means that the protocol does not know where to
- route the data. In that case we route it to the first transfer
- that is waiting for data, or, if none, as a new command. If
- ilocal is 0, we either select based on the remote channel number
- or we have a new command. */
- if (ilocal == -1 && qTreceive != NULL)
- q = qTreceive;
- else if (ilocal == 0 && iremote > 0 && aqTremote[iremote] != NULL)
- q = aqTremote[iremote];
- else if (ilocal <= 0)
- {
- const char *znull;
-
- ulog_user ((const char *) NULL);
-
- /* This data is part of a command. If there is no null
- character in the data, this string will be continued by the
- next packet. Otherwise this must be the last string in the
- command, and we don't care about what comes after the null
- byte. */
- znull = (const char *) memchr (zfirst, '\0', cfirst);
- if (znull != NULL)
- fret = ftadd_cmd (qdaemon, zfirst, (size_t) (znull - zfirst),
- iremote, TRUE);
- else
- {
- fret = ftadd_cmd (qdaemon, zfirst, cfirst, iremote, FALSE);
- if (fret && csecond > 0)
- {
- znull = (const char *) memchr (zsecond, '\0', csecond);
- if (znull != NULL)
- fret = ftadd_cmd (qdaemon, zsecond,
- (size_t) (znull - zsecond), iremote, TRUE);
- else
- fret = ftadd_cmd (qdaemon, zsecond, csecond, iremote, FALSE);
- }
- }
-
- if (pfexit != NULL && (qdaemon->fhangup || qTremote != NULL))
- *pfexit = TRUE;
-
- /* Time spent waiting for a new command is not charged to
- anybody. */
- if (! fttime (qdaemon, &iTrecsecs, &iTrecmicros))
- fret = FALSE;
-
- return fret;
- }
- else
- {
- /* Get the transfer structure this data is intended for. */
- q = qtchan (ilocal);
- }
-
-#if DEBUG > 0
- if (q == NULL || q->precfn == NULL)
- {
- ulog (LOG_ERROR, "Protocol error: %lu bytes remote %d local %d",
- (unsigned long) (cfirst + csecond),
- iremote, ilocal);
- return FALSE;
- }
-#endif
-
- ulog_user (q->s.zuser);
-
- fret = TRUE;
-
- if (q->zlog != NULL && ! q->fsendfile)
- {
- ulog (LOG_NORMAL, "%s", q->zlog);
- ubuffree (q->zlog);
- q->zlog = NULL;
- }
-
- if (cfirst == 0 || q->fcmd || ! q->frecfile || q != qTtiming_rec)
- {
- struct stransfer *qcharge;
-
- /* Either we are receiving some sort of command, or we are
- receiving data for a transfer other than the one we are
- currently timing. It we are currently timing a transfer,
- charge any accumulated time to it. Otherwise, if we
- currently have something to send, just forget about the
- accumulated time (when using a bidirectional protocol, it's
- very difficult to charge this time correctly). Otherwise,
- charge it to whatever transfer receives it. */
- if (! fttime (qdaemon, &isecs, &imicros))
- fret = FALSE;
- if (qTtiming_rec != NULL)
- qcharge = qTtiming_rec;
- else if (qTsend != NULL)
- qcharge = NULL;
- else
- qcharge = q;
- if (qcharge != NULL)
- {
- DEBUG_MESSAGE4 (DEBUG_UUCP_PROTO,
- "fgot_data: Charging %ld to %c %s %s",
- ((isecs - iTrecsecs) * 1000000
- + imicros - iTrecmicros),
- qcharge->s.bcmd, qcharge->s.zfrom,
- qcharge->s.zto);
- qcharge->isecs += isecs - iTrecsecs;
- qcharge->imicros += imicros - iTrecmicros;
- }
- iTrecsecs = isecs;
- iTrecmicros = imicros;
-
- /* If we received file data, start timing the new transfer. */
- if (cfirst == 0 || q->fcmd || ! q->frecfile)
- qTtiming_rec = NULL;
- else
- qTtiming_rec = q;
- }
-
- /* If we're receiving a command, then accumulate it up to the null
- byte. */
- if (q->fcmd)
- {
- const char *znull;
-
- znull = NULL;
- while (cfirst > 0)
- {
- size_t cnew;
- char *znew;
-
- znull = (const char *) memchr (zfirst, '\0', cfirst);
- if (znull != NULL)
- cnew = znull - zfirst;
- else
- cnew = cfirst;
- znew = zbufalc (q->ccmd + cnew + 1);
- if (q->ccmd > 0)
- memcpy (znew, q->zcmd, q->ccmd);
- memcpy (znew + q->ccmd, zfirst, cnew);
- znew[q->ccmd + cnew] = '\0';
- ubuffree (q->zcmd);
- q->zcmd = znew;
- q->ccmd += cnew;
-
- if (znull != NULL)
- break;
-
- zfirst = zsecond;
- cfirst = csecond;
- csecond = 0;
- }
-
- if (znull != NULL)
- {
- char *zcmd;
- size_t ccmd;
-
- zcmd = q->zcmd;
- ccmd = q->ccmd;
- q->fcmd = FALSE;
- q->zcmd = NULL;
- q->ccmd = 0;
- if (! (*q->precfn) (q, qdaemon, zcmd, ccmd + 1))
- fret = FALSE;
- ubuffree (zcmd);
- }
-
- if (pfexit != NULL
- && (qdaemon->fhangup
- || qdaemon->fmaster
- || qTsend != NULL))
- *pfexit = TRUE;
- }
- else if (! q->frecfile || cfirst == 0)
- {
- /* We're either not receiving a file or the file transfer is
- complete. */
- q->frecfile = FALSE;
- if (! (*q->precfn) (q, qdaemon, zfirst, cfirst))
- fret = FALSE;
- if (fret && csecond > 0)
- return fgot_data (qdaemon, zsecond, csecond,
- (const char *) NULL, (size_t) 0,
- ilocal, iremote, ipos + (long) cfirst,
- FALSE, pfexit);
- if (pfexit != NULL
- && (qdaemon->fhangup
- || qdaemon->fmaster
- || qTsend != NULL))
- *pfexit = TRUE;
- }
- else
- {
- if (ipos != -1 && ipos != q->ipos)
- {
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO,
- "fgot_data: Seeking to %ld", ipos);
- if (! ffileseek (q->e, ipos))
- {
- ulog (LOG_ERROR, "seek: %s", strerror (errno));
- fret = FALSE;
- }
- q->ipos = ipos;
- }
-
- if (fret)
- {
- while (cfirst > 0)
- {
- cwrote = cfilewrite (q->e, (char *) zfirst, cfirst);
- if (cwrote == cfirst)
- {
-#if FREE_SPACE_DELTA > 0
- long cfree_space;
-
- /* Check that there is still enough space on the
- disk. If there isn't, we drop the connection,
- because we have no way to abort a file transfer
- in progress. */
- cfree_space = qdaemon->qsys->uuconf_cfree_space;
- if (cfree_space > 0
- && ((q->cbytes / FREE_SPACE_DELTA)
- != (q->cbytes + cfirst) / FREE_SPACE_DELTA)
- && ! frec_check_free (q, cfree_space))
- {
- fret = FALSE;
- break;
- }
-#endif
- q->cbytes += cfirst;
- q->ipos += cfirst;
- }
- else
- {
- if (ffileioerror (q->e, cwrote))
- ulog (LOG_ERROR, "write: %s", strerror (errno));
- else
- ulog (LOG_ERROR,
- "Wrote %d to file when trying to write %lu",
- cwrote, (unsigned long) cfirst);
-
- /* Any write error is almost certainly a temporary
- condition, or else UUCP would not be functioning
- at all. If we continue to accept the file, we
- will wind up rejecting it at the end (what else
- could we do?) and the remote system will throw
- away the request. We're better off just dropping
- the connection, which is what happens when we
- return FALSE, and trying again later. */
- fret = FALSE;
- break;
- }
-
- zfirst = zsecond;
- cfirst = csecond;
- csecond = 0;
- }
- }
-
- if (pfexit != NULL && qdaemon->fhangup)
- *pfexit = TRUE;
- }
-
- return fret;
-}
-
-/* Accumulate a string into a command. If the command is complete,
- start up a new transfer. */
-
-static boolean
-ftadd_cmd (qdaemon, z, clen, iremote, flast)
- struct sdaemon *qdaemon;
- const char *z;
- size_t clen;
- int iremote;
- boolean flast;
-{
- static char *zbuf;
- static size_t cbuf;
- size_t cneed;
- struct scmd s;
-
- cneed = cTcmdlen + clen + 1;
- if (cneed > cbuf)
- {
- zbuf = (char *) xrealloc ((pointer) zbuf, cneed);
- cbuf = cneed;
- }
-
- memcpy (zbuf + cTcmdlen, z, clen);
- zbuf[cTcmdlen + clen] = '\0';
-
- if (! flast)
- {
- cTcmdlen += clen;
- return TRUE;
- }
-
- /* Don't save this string for next time. */
- cTcmdlen = 0;
-
- DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO,
- "ftadd_cmd: Got command \"%s\"", zbuf);
-
- if (! fparse_cmd (zbuf, &s)
- || s.bcmd == 'P')
- {
- ulog (LOG_ERROR, "Received garbled command \"%s\"", zbuf);
- return TRUE;
- }
-
- /* Some systems seem to sometimes send garbage at the end of the
- command. Avoid interpreting it as a size if sizes are not
- supported. */
- if ((qdaemon->ifeatures & FEATURE_SIZES) == 0)
- s.cbytes = -1;
-
- if (s.bcmd != 'H' && s.bcmd != 'Y' && s.bcmd != 'N')
- ulog_user (s.zuser);
- else
- ulog_user ((const char *) NULL);
-
- switch (s.bcmd)
- {
- case 'S':
- case 'E':
- return fremote_send_file_init (qdaemon, &s, iremote);
- case 'R':
- return fremote_rec_file_init (qdaemon, &s, iremote);
- case 'X':
- return fremote_xcmd_init (qdaemon, &s, iremote);
- case 'H':
- /* This is a remote request for a hangup. We close the log
- files so that they may be moved at this point. */
- ulog_close ();
- ustats_close ();
- {
- struct stransfer *q;
-
- q = qtransalc ((struct scmd *) NULL);
- q->psendfn = fremote_hangup_reply;
- q->iremote = iremote;
- q->s.bcmd = 'H';
- return fqueue_remote (qdaemon, q);
- }
- case 'N':
- /* This means a hangup request is being denied; we just ignore
- this and wait for further commands. */
- return TRUE;
- case 'Y':
- /* This is a remote confirmation of a hangup. We reconfirm. */
- if (qdaemon->fhangup)
- return TRUE;
-#if DEBUG > 0
- if (qdaemon->fmaster)
- ulog (LOG_ERROR, "Got hangup reply as master");
-#endif
- /* Don't check errors rigorously here, since the other side
- might jump the gun and hang up. The fLog_sighup variable
- will get set TRUE again when the port is closed. */
- fLog_sighup = FALSE;
- (void) (*qdaemon->qproto->pfsendcmd) (qdaemon, "HY", 0, iremote);
- qdaemon->fhangup = TRUE;
- return TRUE;
-#if DEBUG > 0
- default:
- ulog (LOG_FATAL, "ftadd_cmd: Can't happen");
- return FALSE;
-#endif
- }
-}
-
-/* The remote system is requesting a hang up. If we have something to
- do, send an HN. Otherwise send two HY commands (the other side is
- presumed to send an HY command between the first and second, but we
- don't bother to wait for it) and hang up. */
-
-static boolean
-fremote_hangup_reply (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- boolean fret;
-
- utransfree (qtrans);
-
- if (qTremote == NULL
- && qTlocal == NULL
- && qTsend == NULL
- && qTreceive == NULL)
- {
- if (! fqueue (qdaemon, (boolean *) NULL))
- return FALSE;
-
- if (qTlocal == NULL)
- {
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "fremote_hangup_reply: No work");
- fret = ((*qdaemon->qproto->pfsendcmd) (qdaemon, "HY", 0, 0)
- && (*qdaemon->qproto->pfsendcmd) (qdaemon, "HY", 0, 0));
- qdaemon->fhangup = TRUE;
- return fret;
- }
- }
-
- DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "fremote_hangup_reply: Found work");
- fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, "HN", 0, 0);
- qdaemon->fmaster = TRUE;
- return fret;
-}
-
-/* As described in system.h, we need to keep track of which files have
- been successfully received for which we do not know that the other
- system has received our acknowledgement. This routine is called to
- keep a list of such files. */
-
-static struct sreceive_ack *qTfree_receive_ack;
-
-void
-usent_receive_ack (qdaemon, qtrans)
- struct sdaemon *qdaemon;
- struct stransfer *qtrans;
-{
- struct sreceive_ack *q;
-
- if (qTfree_receive_ack == NULL)
- q = (struct sreceive_ack *) xmalloc (sizeof (struct sreceive_ack));
- else
- {
- q = qTfree_receive_ack;
- qTfree_receive_ack = q->qnext;
- }
-
- q->qnext = qTreceive_ack;
- q->zto = zbufcpy (qtrans->s.zto);
- q->ztemp = zbufcpy (qtrans->s.ztemp);
- q->fmarked = FALSE;
-
- qTreceive_ack = q;
-}
-
-/* This routine is called by the protocol code when either all
- outstanding data has been acknowledged or one complete window has
- passed. It may be called directly by the protocol, or it may be
- called via fgot_data. If one complete window has passed, then all
- unmarked receives are marked, and we know that all marked ones have
- been acked. */
-
-void
-uwindow_acked (qdaemon, fallacked)
- struct sdaemon *qdaemon;
- boolean fallacked;
-{
- register struct sreceive_ack **pq;
-
- pq = &qTreceive_ack;
- while (*pq != NULL)
- {
- if (fallacked || (*pq)->fmarked)
- {
- struct sreceive_ack *q;
-
- q = *pq;
- (void) fsysdep_forget_reception (qdaemon->qsys, q->zto,
- q->ztemp);
- ubuffree (q->zto);
- ubuffree (q->ztemp);
- *pq = q->qnext;
- q->qnext = qTfree_receive_ack;
- qTfree_receive_ack = q;
- }
- else
- {
- (*pq)->fmarked = TRUE;
- pq = &(*pq)->qnext;
- }
- }
-}
-
-/* This routine is called when an error occurred and we are crashing
- out of the connection. It is used to report statistics on failed
- transfers to the statistics file, and it also discards useless
- temporary files for file receptions. Note that the number of bytes
- we report as having been sent has little or nothing to do with the
- number of bytes the remote site actually received. */
-
-void
-ufailed (qdaemon)
- struct sdaemon *qdaemon;
-{
- register struct stransfer *q;
-
- if (qTsend != NULL)
- {
- q = qTsend;
- do
- {
- if ((q->fsendfile || q->frecfile)
- && q->cbytes > 0)
- {
- ustats (FALSE, q->s.zuser, qdaemon->qsys->uuconf_zname,
- q->fsendfile, q->cbytes, q->isecs, q->imicros,
- qdaemon->fcaller);
- if (q->fsendfile)
- qdaemon->csent += q->cbytes;
- else
- qdaemon->creceived += q->cbytes;
- }
- if (q->frecfile)
- (void) frec_discard_temp (qdaemon, q);
- q = q->qnext;
- }
- while (q != qTsend);
- }
-
- if (qTreceive != NULL)
- {
- q = qTreceive;
- do
- {
- if ((q->fsendfile || q->frecfile)
- && q->cbytes > 0)
- {
- ustats (FALSE, q->s.zuser, qdaemon->qsys->uuconf_zname,
- q->fsendfile, q->cbytes, q->isecs, q->imicros,
- qdaemon->fcaller);
- if (q->fsendfile)
- qdaemon->csent += q->cbytes;
- else
- qdaemon->creceived += q->cbytes;
- }
- if (q->frecfile)
- (void) frec_discard_temp (qdaemon, q);
- q = q->qnext;
- }
- while (q != qTreceive);
- }
-}
-
-/* When a local poll file is found, it is entered on the queue like
- any other job. When it is pulled off the queue, this function is
- called. It just calls fsysdep_did_work, which will remove the poll
- file. This ensures that poll files are only removed if the system
- is actually called. */
-
-/*ARGSUSED*/
-static boolean
-flocal_poll_file (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- boolean fret;
-
- fret = fsysdep_did_work (qtrans->s.pseq);
- utransfree (qtrans);
- return fret;
-}
diff --git a/gnu/libexec/uucp/uucico/uucico.8 b/gnu/libexec/uucp/uucico/uucico.8
deleted file mode 100644
index b1762a9f..0000000
--- a/gnu/libexec/uucp/uucico/uucico.8
+++ /dev/null
@@ -1,291 +0,0 @@
-''' $Id$
-.TH uucico 8 "Taylor UUCP 1.06"
-.SH NAME
-uucico \- UUCP file transfer daemon
-.SH SYNOPSIS
-.B uucico
-[ options ]
-.SH DESCRIPTION
-The
-.I uucico
-daemon processes file transfer requests queued by
-.I uucp
-(1) and
-.I uux
-(1). It is started when
-.I uucp
-or
-.I uux
-is run (unless they are given the
-.B \-r
-option). It is also typically started periodically using
-entries in the
-.I crontab
-table(s).
-
-When invoked with
-.B \-r1,
-.B \-\-master,
-.B \-s,
-.B \-\-system,
-or
-.B \-S,
-the daemon will place a call to a remote system, running in master
-mode. Otherwise the daemon will start in slave mode, accepting a call
-from a remote system. Typically a special login name will be set up
-for UUCP which automatically invokes
-.I uucico
-when a call is made.
-
-When
-.I uucico
-terminates, it invokes the
-.I uuxqt
-(8) daemon, unless the
-.B \-q
-or
-.B \-\-nouuxqt
-option is given;
-.I uuxqt
-(8) executes any work orders created by
-.I uux
-(1) on a remote system, and any work orders created locally which have
-received remote files for which they were waiting.
-
-If a call fails,
-.I uucico
-will normally refuse to retry the
-call until a certain (configurable) amount of time
-has passed. This may be overriden by the
-.B -f,
-.B --force,
-or
-.B -S
-option.
-
-The
-.B \-l,
-.B \-\-prompt,
-.B \-e,
-or
-.B \-\-loop
-options may be used to force
-.I uucico
-to produce its own prompts of "login: " and "Password:". When another
-daemon calls in, it will see these prompts and log in as usual. The
-login name and password will normally be checked against a separate
-list kept specially for
-.I uucico
-rather than the
-.I /etc/passwd
-file; it is possible on some systems to direct
-.I uucico
-to use the
-.I /etc/passwd
-file. The
-.B \-l
-or
-.B \--prompt
-option will prompt once and then exit; in this mode the UUCP
-administrator or the superuser may use the
-.B \-u
-or
-.B \--login
-option to force a login name, in which case
-.I uucico
-will not prompt for one.
-The
-.B \-e
-or
-.B \--loop
-option will prompt again after the first session is over; in this mode
-.I uucico
-will permanently control a port.
-
-If
-.I uucico
-receives a SIGQUIT, SIGTERM or SIGPIPE signal, it will cleanly abort
-any current conversation with a remote system and exit. If it
-receives a SIGHUP signal it will abort any current conversation, but
-will continue to place calls to (if invoked with
-.B \-r1
-or
-.B \-\-master)
-and accept calls from (if invoked with
-.B \-e
-or
-.B \-\-loop)
-other systems. If it receives a
-SIGINT signal it will finish the current conversation, but will not
-place or accept any more calls.
-.SH OPTIONS
-The following options may be given to
-.I uucico.
-.TP 5
-.B \-r1, \-\-master
-Start in master mode (call out to a system); implied by
-.B \-s,
-.B \-\-system,
-or
-.B \-S.
-If no system is specified, call any system for which work is waiting
-to be done.
-.TP 5
-.B \-r0, \-\-slave
-Start in slave mode. This is the default.
-.TP 5
-.B \-s system, \-\-system system
-Call the named system.
-.TP 5
-.B \-S system
-Call the named system, ignoring any required wait. This is equivalent
-to
-.B \-s system \-f.
-.TP 5
-.B \-f, \-\-force
-Ignore any required wait for any systems to be called.
-.TP 5
-.B \-l, \-\-prompt
-Prompt for login name and password using "login: " and "Password:".
-This allows
-.I uucico
-to be easily run from
-.I inetd
-(8). The login name and password are checked against the UUCP
-password file, which probably has no connection to the file
-.I /etc/passwd.
-The
-.B \-\-login
-option may be used to force a login name, in which cause
-.I uucico
-will only prompt for a password.
-.TP 5
-.B \-p port, \-\-port port
-Specify a port to call out on or to listen to.
-.TP 5
-.B \-e, \-\-loop
-Enter endless loop of login/password prompts and slave mode daemon
-execution. The program will not stop by itself; you must use
-.I kill
-(1) to shut it down.
-.TP 5
-.B \-w, \-\-wait
-After calling out (to a particular system when
-.B \-s,
-.B \-\-system,
-or
-.B \-S
-is specifed, or to all systems which have work when just
-.B \-r1
-or
-.B \-\-master
-is specifed), begin an endless loop as with
-.B \-\-loop.
-.TP 5
-.B \-q, \-\-nouuxqt
-Do not start the
-.I uuxqt
-(8) daemon when finished.
-.TP 5
-.B \-c, \-\-quiet
-If no calls are permitted at this time, then don't make the call, but
-also do not put an error message in the log file and do not update the
-system status (as reported by
-.I uustat
-(1)). This can be convenient for automated polling scripts, which may
-want to simply attempt to call every system rather than worry about
-which particular systems may be called at the moment. This option
-also suppresses the log message indicating that there is no work to be
-done.
-.TP 5
-.B \-C, \-\-ifwork
-Only call the system named by
-.B \-s,
-.B \-\-system
-or
-.B \-S
-if there is work for that system.
-.TP 5
-.B \-D, \-\-nodetach
-Do not detach from the controlling terminal. Normally
-.I uucico
-detaches from the terminal before each call out to another system and
-before invoking
-.I uuxqt.
-This option prevents this.
-.TP 5
-.B \-u name, \-\-login name
-Set the login name to use instead of that of the invoking user. This
-option may only be used by the UUCP administrator or the superuser.
-If used with
-.B \-\-prompt,
-this will cause
-.I uucico
-to prompt only for the password, not the login name.
-.TP 5
-.B \-z, \-\-try-next
-If a call fails after the remote system is reached, try the next
-alternate rather than simply exiting.
-.TP 5
-.B \-i type, \-\-stdin type
-Set the type of port to use when using standard input. The only
-support port type is TLI, and this is only available on machines which
-support the TLI networking interface. Specifying
-.B \-iTLI
-causes
-.I uucico
-to use TLI calls to perform I/O.
-.TP 5
-.B \-x type, \-X type, \-\-debug type
-Turn on particular debugging types. The following types are
-recognized: abnormal, chat, handshake, uucp-proto, proto, port,
-config, spooldir, execute, incoming, outgoing.
-
-Multiple types may be given, separated by commas, and the
-.B \-\-debug
-option may appear multiple times. A number may also be given, which
-will turn on that many types from the foregoing list; for example,
-.B \-\-debug 2
-is equivalent to
-.B \-\-debug abnormal,chat.
-
-The debugging output is sent to the debugging file, usually one of
-/var/spool/uucp/Debug, /usr/spool/uucp/DEBUG, or
-/usr/spool/uucp/.Admin/audit.local.
-.TP 5
-.B \-I file, \-\-config file
-Set configuration file to use. This option may not be available,
-depending upon how
-.I uucico
-was compiled.
-.TP 5
-.B \-v, \-\-version
-Report version information and exit.
-.TP 5
-.B \-\-help
-Print a help message and exit.
-.SH FILES
-The file names may be changed at compilation time or by the
-configuration file, so these are only approximations.
-
-.br
-/etc/uucp/config - Configuration file.
-.br
-/etc/uucp/passwd - Default UUCP password file.
-.br
-/var/spool/uucp -
-UUCP spool directory.
-.br
-/var/spool/uucp/Log -
-UUCP log file.
-.br
-/var/spool/uucppublic -
-Default UUCP public directory.
-.br
-/var/spool/uucp/Debug -
-Debugging file.
-.SH SEE ALSO
-kill(1), uucp(1), uux(1), uustat(1), uuxqt(8)
-.SH AUTHOR
-Ian Lance Taylor
-<ian@airs.com>
diff --git a/gnu/libexec/uucp/uucico/uucico.c b/gnu/libexec/uucp/uucico/uucico.c
deleted file mode 100644
index 6a68752..0000000
--- a/gnu/libexec/uucp/uucico/uucico.c
+++ /dev/null
@@ -1,3074 +0,0 @@
-/* uucico.c
- This is the main UUCP communication program.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char uucico_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#else
-#define LONG_MAX 2147483647L
-#endif
-
-#include "getopt.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "conn.h"
-#include "prot.h"
-#include "trans.h"
-#include "system.h"
-
-#if HAVE_ENCRYPTED_PASSWORDS
-#ifndef crypt
-extern char *crypt ();
-#endif
-#endif
-
-/* Coherent already had a different meaning for the -c option. What a
- pain. */
-#ifdef __COHERENT__
-#define COHERENT_C_OPTION 1
-#else
-#define COHERENT_C_OPTION 0
-#endif
-
-/* Define the known protocols. */
-
-#define TCP_PROTO \
- (UUCONF_RELIABLE_ENDTOEND \
- | UUCONF_RELIABLE_RELIABLE \
- | UUCONF_RELIABLE_EIGHT)
-
-static const struct sprotocol asProtocols[] =
-{
- { 't', TCP_PROTO, 1, TRUE,
- asTproto_params, ftstart, ftshutdown, ftsendcmd, ztgetspace,
- ftsenddata, ftwait, ftfile },
- { 'e', TCP_PROTO, 1, TRUE,
- asEproto_params, festart, feshutdown, fesendcmd, zegetspace,
- fesenddata, fewait, fefile },
- { 'i', UUCONF_RELIABLE_EIGHT, 7, TRUE,
- asIproto_params, fistart, fishutdown, fisendcmd, zigetspace,
- fisenddata, fiwait, NULL },
- { 'a', UUCONF_RELIABLE_EIGHT, 1, TRUE,
- asZproto_params, fzstart, fzshutdown, fzsendcmd, zzgetspace,
- fzsenddata, fzwait, fzfile },
- { 'g', UUCONF_RELIABLE_EIGHT, 1, TRUE,
- asGproto_params, fgstart, fgshutdown, fgsendcmd, zggetspace,
- fgsenddata, fgwait, NULL },
- { 'G', UUCONF_RELIABLE_EIGHT, 1, TRUE,
- asGproto_params, fbiggstart, fgshutdown, fgsendcmd, zggetspace,
- fgsenddata, fgwait, NULL },
- { 'j', UUCONF_RELIABLE_EIGHT, 7, TRUE,
- asIproto_params, fjstart, fjshutdown, fisendcmd, zigetspace,
- fisenddata, fiwait, NULL },
- { 'f', UUCONF_RELIABLE_RELIABLE, 1, FALSE,
- asFproto_params, ffstart, ffshutdown, ffsendcmd, zfgetspace,
- ffsenddata, ffwait, fffile },
- { 'v', UUCONF_RELIABLE_EIGHT, 1, TRUE,
- asGproto_params, fvstart, fgshutdown, fgsendcmd, zggetspace,
- fgsenddata, fgwait, NULL },
- { 'y', UUCONF_RELIABLE_RELIABLE | UUCONF_RELIABLE_EIGHT, 1, TRUE,
- asYproto_params, fystart, fyshutdown, fysendcmd, zygetspace,
- fysenddata, fywait, fyfile }
-};
-
-#define CPROTOCOLS (sizeof asProtocols / sizeof asProtocols[0])
-
-/* Locked system. */
-static boolean fLocked_system;
-static struct uuconf_system sLocked_system;
-
-/* Daemon structure holding information about the remote system (must
- be global so the error handler can see it. */
-static struct sdaemon sDaemon;
-
-/* Open connection. */
-static struct sconnection *qConn;
-
-/* uuconf global pointer; need to close the connection after a fatal
- error. */
-static pointer pUuconf;
-
-/* This structure is passed to iuport_lock via uuconf_find_port. */
-struct spass
-{
- boolean fmatched;
- boolean flocked;
- struct sconnection *qconn;
-};
-
-/* Local functions. */
-
-static void uusage P((void));
-static void uhelp P((void));
-static void uabort P((void));
-static boolean fcall P((pointer puuconf, const char *zconfig, boolean fuuxqt,
- const struct uuconf_system *qsys,
- struct uuconf_port *qport, boolean fifwork,
- boolean fforce, boolean fdetach,
- boolean fquiet, boolean ftrynext));
-static boolean fconn_call P((struct sdaemon *qdaemon,
- struct uuconf_port *qport,
- struct sstatus *qstat, int cretry,
- boolean *pfcalled));
-static boolean fdo_call P((struct sdaemon *qdaemon,
- struct sstatus *qstat,
- const struct uuconf_dialer *qdialer,
- boolean *pfcalled, enum tstatus_type *pterr));
-static int iuport_lock P((struct uuconf_port *qport, pointer pinfo));
-static boolean flogin_prompt P((pointer puuconf, const char *zconfig,
- boolean fuuxqt, struct sconnection *qconn,
- const char *zlogin, const char **pzsystem));
-static int icallin_cmp P((int iwhich, pointer pinfo, const char *zfile));
-static boolean faccept_call P((pointer puuconf, const char *zconfig,
- boolean fuuxqt, const char *zlogin,
- struct sconnection *qconn,
- const char **pzsystem));
-static void uaccept_call_cleanup P((pointer puuconf,
- struct uuconf_system *qfreesys,
- struct uuconf_port *qport,
- struct uuconf_port *qfreeport,
- char *zloc));
-static void uapply_proto_params P((pointer puuconf, int bproto,
- struct uuconf_cmdtab *qcmds,
- struct uuconf_proto_param *pas));
-static boolean fsend_uucp_cmd P((struct sconnection *qconn,
- const char *z));
-static char *zget_uucp_cmd P((struct sconnection *qconn,
- boolean frequired, boolean fstrip));
-static char *zget_typed_line P((struct sconnection *qconn,
- boolean fstrip));
-
-/* Long getopt options. */
-static const struct option asLongopts[] =
-{
- { "quiet", no_argument, NULL, 2 },
- { "ifwork", no_argument, NULL, 'C' },
- { "nodetach", no_argument, NULL, 'D' },
- { "loop", no_argument, NULL, 'e' },
- { "force", no_argument, NULL, 'f'},
- { "stdin", required_argument, NULL, 'i' },
- { "prompt", no_argument, NULL, 'l' },
- { "port", required_argument, NULL, 'p' },
- { "nouuxqt", no_argument, NULL, 'q' },
- { "master", no_argument, NULL, 3 },
- { "slave", no_argument, NULL, 4 },
- { "system", required_argument, NULL, 's' },
- { "login", required_argument, NULL, 'u' },
- { "wait", no_argument, NULL, 'w' },
- { "try-next", no_argument, NULL, 'z' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'x' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- /* -c: Whether to be quiet. */
- boolean fquiet = FALSE;
- /* -C: Only call the system if there is work. */
- boolean fifwork = FALSE;
- /* -D: don't detach from controlling terminal. */
- boolean fdetach = TRUE;
- /* -e: Whether to do an endless loop of accepting calls. */
- boolean fendless = FALSE;
- /* -f: Whether to force a call despite status of previous call. */
- boolean fforce = FALSE;
- /* -i type: type of port to use for stdin. */
- enum uuconf_porttype tstdintype = UUCONF_PORTTYPE_STDIN;
- /* -I file: configuration file name. */
- const char *zconfig = NULL;
- /* -l: Whether to give a single login prompt. */
- boolean flogin = FALSE;
- /* -P port: port to use; in master mode, call out on this port. In
- slave mode, accept logins on this port. If port not specified,
- then in master mode figure it out for each system, and in slave
- mode use stdin and stdout. */
- const char *zport = NULL;
- /* -q: Whether to start uuxqt when done. */
- boolean fuuxqt = TRUE;
- /* -r1: Whether we are the master. */
- boolean fmaster = FALSE;
- /* -s,-S system: system to call. */
- const char *zsystem = NULL;
- /* -u: Login name to use. */
- const char *zlogin = NULL;
- /* -w: Whether to wait for a call after doing one. */
- boolean fwait = FALSE;
- /* -z: Try next alternate if call fails. */
- boolean ftrynext = FALSE;
- const char *zopts;
- int iopt;
- struct uuconf_port *qport;
- struct uuconf_port sport;
- boolean fret = TRUE;
- pointer puuconf;
- int iuuconf;
-#if DEBUG > 1
- int iholddebug;
-#endif
-
- zProgram = argv[0];
-
- /* When uucico is invoked by login, the first character of the
- program will be a dash. We don't want that. */
- if (*zProgram == '-')
- ++zProgram;
-
-#if COHERENT_C_OPTION
- zopts = "c:CDefi:I:lp:qr:s:S:u:x:X:vwz";
-#else
- zopts = "cCDefi:I:lp:qr:s:S:u:x:X:vwz";
-#endif
-
- while ((iopt = getopt_long (argc, argv, zopts,
- asLongopts, (int *) NULL)) != EOF)
- {
-#if COHERENT_C_OPTION
- if (iopt == 'c')
- {
- iopt = 's';
- fifwork = TRUE;
- }
-#endif
- switch (iopt)
- {
- case 2:
- case 'c':
- /* Don't warn if a call is attempted at a bad time, and
- don't print the "No work" message. */
- fquiet = TRUE;
- break;
-
- case 'C':
- fifwork = TRUE;
- break;
-
- case 'D':
- /* Don't detach from controlling terminal. */
- fdetach = FALSE;
- break;
-
- case 'e':
- /* Do an endless loop of accepting calls. */
- fendless = TRUE;
- break;
-
- case 'f':
- /* Force a call even if it hasn't been long enough since the last
- failed call. */
- fforce = TRUE;
- break;
-
- case 'i':
- /* Type of port to use for standard input. Only TLI is
- supported here, and only if HAVE_TLI is true. This
- permits the Network Listener to tell uucico to use TLI
- I/O calls. */
- if (strcasecmp (optarg, "tli") != 0)
- fprintf (stderr, "%s: unsupported port type \"%s\"\n",
- zProgram, optarg);
- else
- {
-#if HAVE_TLI
- tstdintype = UUCONF_PORTTYPE_TLI;
-#else
- fprintf (stderr, "%s: not compiled with TLI support\n",
- zProgram);
-#endif
- }
- break;
-
- case 'l':
- /* Prompt for login name and password. */
- flogin = TRUE;
- break;
-
- case 'p':
- /* Port to use */
- zport = optarg;
- break;
-
- case 'q':
- /* Don't start uuxqt. */
- fuuxqt = FALSE;
- break;
-
- case 'r':
- /* Set mode: -r1 for master, -r0 for slave (default) */
- if (strcmp (optarg, "1") == 0)
- fmaster = TRUE;
- else if (strcmp (optarg, "0") == 0)
- fmaster = FALSE;
- else
- uusage ();
- break;
-
- case 's':
- /* Set system name */
- zsystem = optarg;
- fmaster = TRUE;
- break;
-
- case 'S':
- /* Set system name and force call like -f */
- zsystem = optarg;
- fforce = TRUE;
- fmaster = TRUE;
- break;
-
- case 'u':
- /* Some versions of uucpd invoke uucico with a -u argument
- specifying the login name. If invoked by a privileged
- user, we use it instead of the result of
- zsysdep_login_name. */
- if (fsysdep_privileged ())
- zlogin = optarg;
- else
- fprintf (stderr,
- "%s: ignoring command line login name: not a privileged user\n",
- zProgram);
- break;
-
- case 'w':
- /* Call out and then wait for a call in */
- fwait = TRUE;
- break;
-
- case 'z':
- /* Try next alternate if call fails. */
- ftrynext = TRUE;
- break;
-
- case 'I':
- /* Set configuration file name (default is in sysdep.h). */
- if (fsysdep_other_config (optarg))
- zconfig = optarg;
- break;
-
- case 'x':
- case 'X':
-#if DEBUG > 1
- /* Set debugging level. */
- iDebug |= idebug_parse (optarg);
-#endif
- break;
-
- case 'v':
- /* Print version and exit. */
- printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zProgram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 4:
- /* --slave. */
- fmaster = FALSE;
- break;
-
- case 3:
- /* --master. */
- fmaster = TRUE;
- break;
-
- case 1:
- /* --help. */
- uhelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found, and flag value set. */
- break;
-
- default:
- uusage ();
- /*NOTREACHED*/
- }
- }
-
- if (optind != argc)
- uusage ();
-
- if (fwait && zport == NULL)
- {
- fprintf (stderr, "%s: -w requires -p", zProgram);
- uusage ();
- }
-
- iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- pUuconf = puuconf;
-
-#if DEBUG > 1
- {
- const char *zdebug;
-
- iuuconf = uuconf_debuglevel (puuconf, &zdebug);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (zdebug != NULL)
- iDebug |= idebug_parse (zdebug);
- }
-#endif
-
- /* If a port was named, get its information. */
- if (zport == NULL)
- qport = NULL;
- else
- {
- iuuconf = uuconf_find_port (puuconf, zport, (long) 0, (long) 0,
- (int (*) P((struct uuconf_port *,
- pointer))) NULL,
- (pointer) NULL, &sport);
- if (iuuconf == UUCONF_NOT_FOUND)
- ulog (LOG_FATAL, "%s: port not found", zport);
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- qport = &sport;
- }
-
-#ifdef SIGINT
- usysdep_signal (SIGINT);
-#endif
-#ifdef SIGHUP
- usysdep_signal (SIGHUP);
-#endif
-#ifdef SIGQUIT
- usysdep_signal (SIGQUIT);
-#endif
-#ifdef SIGTERM
- usysdep_signal (SIGTERM);
-#endif
-#ifdef SIGPIPE
- usysdep_signal (SIGPIPE);
-#endif
-
- usysdep_initialize (puuconf, INIT_SUID);
-
- ulog_to_file (puuconf, TRUE);
- ulog_fatal_fn (uabort);
-
- if (fmaster)
- {
- if (zsystem != NULL)
- {
- /* A system was named. Call it. */
- iuuconf = uuconf_system_info (puuconf, zsystem,
- &sLocked_system);
- if (iuuconf == UUCONF_NOT_FOUND)
- ulog (LOG_FATAL, "%s: System not found", zsystem);
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- /* Detach from the controlling terminal for the call. This
- probably makes sense only on Unix. We want the modem
- line to become the controlling terminal. */
- if (fdetach &&
- (qport == NULL
- || qport->uuconf_ttype != UUCONF_PORTTYPE_STDIN))
- usysdep_detach ();
-
- ulog_system (sLocked_system.uuconf_zname);
-
-#if DEBUG > 1
- iholddebug = iDebug;
- if (sLocked_system.uuconf_zdebug != NULL)
- iDebug |= idebug_parse (sLocked_system.uuconf_zdebug);
-#endif
-
- if (! fsysdep_lock_system (&sLocked_system))
- {
- ulog (LOG_ERROR, "System already locked");
- fret = FALSE;
- }
- else
- {
- fLocked_system = TRUE;
- fret = fcall (puuconf, zconfig, fuuxqt, &sLocked_system, qport,
- fifwork, fforce, fdetach, fquiet, ftrynext);
- if (fLocked_system)
- {
- (void) fsysdep_unlock_system (&sLocked_system);
- fLocked_system = FALSE;
- }
- }
-#if DEBUG > 1
- iDebug = iholddebug;
-#endif
- ulog_system ((const char *) NULL);
- (void) uuconf_system_free (puuconf, &sLocked_system);
- }
- else
- {
- char **pznames, **pz;
- int c, i;
- boolean fdidone;
-
- /* Call all systems which have work to do. */
- fret = TRUE;
- fdidone = FALSE;
-
- iuuconf = uuconf_system_names (puuconf, &pznames, 0);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- /* Randomize the order in which we call the systems. */
- c = 0;
- for (pz = pznames; *pz != NULL; pz++)
- c++;
-
- srand ((unsigned int) ixsysdep_time ((long *) NULL));
- for (i = c - 1; i > 0; i--)
- {
- int iuse;
- char *zhold;
-
- iuse = rand () % (i + 1);
- zhold = pznames[i];
- pznames[i] = pznames[iuse];
- pznames[iuse] = zhold;
- }
-
- for (pz = pznames; *pz != NULL && ! FGOT_SIGNAL (); pz++)
- {
- iuuconf = uuconf_system_info (puuconf, *pz,
- &sLocked_system);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- xfree ((pointer) *pz);
- continue;
- }
-
- if (fsysdep_has_work (&sLocked_system))
- {
- fdidone = TRUE;
-
- /* Detach from the controlling terminal. On Unix
- this means that we will wind up forking a new
- process for each system we call. */
- if (fdetach
- && (qport == NULL
- || qport->uuconf_ttype != UUCONF_PORTTYPE_STDIN))
- usysdep_detach ();
-
- ulog_system (sLocked_system.uuconf_zname);
-
-#if DEBUG > 1
- iholddebug = iDebug;
- if (sLocked_system.uuconf_zdebug != NULL)
- iDebug |= idebug_parse (sLocked_system.uuconf_zdebug);
-#endif
-
- if (! fsysdep_lock_system (&sLocked_system))
- {
- ulog (LOG_ERROR, "System already locked");
- fret = FALSE;
- }
- else
- {
- fLocked_system = TRUE;
- if (! fcall (puuconf, zconfig, fuuxqt, &sLocked_system,
- qport, TRUE, fforce, fdetach, fquiet,
- ftrynext))
- fret = FALSE;
-
- /* Now ignore any SIGHUP that we got. */
- afSignal[INDEXSIG_SIGHUP] = FALSE;
-
- if (fLocked_system)
- {
- (void) fsysdep_unlock_system (&sLocked_system);
- fLocked_system = FALSE;
- }
- }
-#if DEBUG > 1
- iDebug = iholddebug;
-#endif
- ulog_system ((const char *) NULL);
- }
-
- (void) uuconf_system_free (puuconf, &sLocked_system);
- xfree ((pointer) *pz);
- }
-
- xfree ((pointer) pznames);
-
- if (! fdidone && ! fquiet)
- ulog (LOG_NORMAL, "No work");
- }
-
- /* If requested, wait for calls after dialing out. */
- if (fwait)
- {
- fendless = TRUE;
- fmaster = FALSE;
- }
- }
-
- if (! fmaster)
- {
- struct sconnection sconn;
- boolean flocked;
-
- /* If a port was specified by name, we go into endless loop
- mode. In this mode, we wait for calls and prompt them with
- "login:" and "Password:", so that they think we are a regular
- UNIX system. If we aren't in endless loop mode, we have been
- called by some other system. If flogin is TRUE, we prompt
- with "login:" and "Password:" a single time. */
-
- fret = TRUE;
- zsystem = NULL;
-
- if (! fconn_init (qport, &sconn, tstdintype))
- fret = FALSE;
-
- if (qport != NULL)
- {
- /* We are not using standard input. Detach from the
- controlling terminal, so that the port we are about to
- use becomes our controlling terminal. */
- if (fdetach
- && qport->uuconf_ttype != UUCONF_PORTTYPE_STDIN)
- usysdep_detach ();
- }
-
- if (fconn_lock (&sconn, TRUE))
- flocked = TRUE;
- else
- {
- flocked = FALSE;
- ulog (LOG_ERROR, "%s: Port already locked",
- qport->uuconf_zname);
- fret = FALSE;
- }
-
- if (fret)
- {
- if (! fconn_open (&sconn, (long) 0, (long) 0, TRUE))
- fret = FALSE;
- qConn = &sconn;
- }
-
- if (fret)
- {
- if (fendless)
- {
- while (! FGOT_SIGNAL ()
- && flogin_prompt (puuconf, zconfig, fuuxqt, &sconn,
- (const char *) NULL,
- (const char **) NULL))
- {
- /* Close and reopen the port in between calls. */
- if (! fconn_close (&sconn, puuconf,
- (struct uuconf_dialer *) NULL,
- TRUE)
- || ! fconn_open (&sconn, (long) 0, (long) 0, TRUE))
- break;
- }
- fret = FALSE;
- }
- else
- {
- if (flogin)
- fret = flogin_prompt (puuconf, zconfig, fuuxqt, &sconn,
- zlogin, &zsystem);
- else
- {
-#if DEBUG > 1
- iholddebug = iDebug;
-#endif
- if (zlogin == NULL)
- zlogin = zsysdep_login_name ();
- fret = faccept_call (puuconf, zconfig, fuuxqt, zlogin,
- &sconn, &zsystem);
-#if DEBUG > 1
- iDebug = iholddebug;
-#endif
- }
- }
- }
-
- if (qConn != NULL)
- {
- if (! fconn_close (&sconn, puuconf, (struct uuconf_dialer *) NULL,
- fret))
- fret = FALSE;
- qConn = NULL;
- }
-
- if (flocked)
- (void) fconn_unlock (&sconn);
-
- uconn_free (&sconn);
- }
-
- ulog_close ();
- ustats_close ();
-
- /* If we got a SIGTERM, perhaps because the system is going down,
- don't run uuxqt. We go ahead and run it for any other signal,
- since I think they indicate more temporary conditions. */
- if (afSignal[INDEXSIG_SIGTERM])
- fuuxqt = FALSE;
-
- if (fuuxqt)
- {
- int irunuuxqt;
-
- iuuconf = uuconf_runuuxqt (puuconf, &irunuuxqt);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- else if (irunuuxqt == UUCONF_RUNUUXQT_ONCE)
- {
- /* Detach from the controlling terminal before starting up uuxqt,
- so that it runs as a true daemon. */
- if (fdetach)
- usysdep_detach ();
-
- if (! fspawn_uuxqt (FALSE, zsystem, zconfig))
- fret = FALSE;
- }
- }
-
- usysdep_exit (fret);
-
- /* Avoid complaints about not returning. */
- return 0;
-}
-
-/* Print out a usage message and die. */
-
-static void
-uusage ()
-{
- fprintf (stderr, "Usage: %s [options]\n", zProgram);
- fprintf (stderr, "Use %s --help for help\n", zProgram);
- exit (EXIT_FAILURE);
-}
-
-/* Print a help message. */
-
-static void
-uhelp ()
-{
- printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- printf ("Usage: %s [options]\n", zProgram);
- printf (" -s,-S,--system system: Call system (-S implies -f)\n");
- printf (" -f,--force: Force call despite system status\n");
- printf (" -r state: 1 for master, 0 for slave (default)\n");
- printf (" --master: Act as master\n");
- printf (" --slave: Act as slave (default)\n");
- printf (" -p,--port port: Specify port\n");
- printf (" -l,--prompt: prompt for login name and password\n");
- printf (" -e,--loop: Endless loop of login prompts and daemon execution\n");
- printf (" -w,--wait: After calling out, wait for incoming calls\n");
- printf (" -q,--nouuxqt: Don't start uuxqt when done\n");
- printf (" -c,--quiet: Don't log bad time or no work warnings\n");
- printf (" -C,--ifwork: Only call named system if there is work\n");
- printf (" -D,--nodetach: Don't detach from controlling terminal\n");
- printf (" -u,--login: Set login name (privileged users only)\n");
- printf (" -i,--stdin type: Type of standard input (only TLI supported)\n");
- printf (" -z,--try-next: If a call fails, try the next alternate\n");
- printf (" -x,-X,--debug debug: Set debugging level\n");
-#if HAVE_TAYLOR_CONFIG
- printf (" -I,--config file: Set configuration file to use\n");
-#endif /* HAVE_TAYLOR_CONFIG */
- printf (" -v,--version: Print version and exit\n");
- printf (" --help: Print help and exit\n");
-}
-
-/* This function is called when a LOG_FATAL error occurs. */
-
-static void
-uabort ()
-{
- if (fLocked_system)
- ufailed (&sDaemon);
-
- ulog_user ((const char *) NULL);
-
- if (qConn != NULL)
- {
- (void) fconn_close (qConn, pUuconf, (struct uuconf_dialer *) NULL,
- FALSE);
- (void) fconn_unlock (qConn);
- uconn_free (qConn);
- }
-
- if (fLocked_system)
- {
- (void) fsysdep_unlock_system (&sLocked_system);
- fLocked_system = FALSE;
- }
-
- ulog_system ((const char *) NULL);
-
- ulog_close ();
- ustats_close ();
-
- usysdep_exit (FALSE);
-}
-
-/* The number of seconds in one day. We must cast to long for this
- to be calculated correctly on a machine with 16 bit ints. */
-#define SECS_PER_DAY ((long) 24 * (long) 60 * (long) 60)
-
-/* Call another system, trying all the possible sets of calling
- instructions. The qsys argument is the system to call. The qport
- argument is the port to use, and may be NULL. If the fifwork
- argument is TRUE, the call is only placed if there is work to be
- done. If the fforce argument is TRUE, a call is forced even if not
- enough time has passed since the last failed call. If the fquiet
- argument is FALSE (the normal case), then a warning is given if
- calls are not permitted at this time. */
-
-static boolean
-fcall (puuconf, zconfig, fuuxqt, qorigsys, qport, fifwork, fforce, fdetach,
- fquiet, ftrynext)
- pointer puuconf;
- const char *zconfig;
- boolean fuuxqt;
- const struct uuconf_system *qorigsys;
- struct uuconf_port *qport;
- boolean fifwork;
- boolean fforce;
- boolean fdetach;
- boolean fquiet;
- boolean ftrynext;
-{
- struct sstatus sstat;
- long inow;
- boolean fbadtime, fnevertime, ffoundwork;
- const struct uuconf_system *qsys;
-
- if (! fsysdep_get_status (qorigsys, &sstat, (boolean *) NULL))
- return FALSE;
- ubuffree (sstat.zstring);
-
- /* Make sure it's been long enough since the last failed call, and
- that we haven't exceeded the maximum number of retries. Even if
- we are over the limit on retries, we permit a call to be made if
- 24 hours have passed. This 24 hour limit is still controlled by
- the retry time. We ignore times in the future, presumably the
- result of some sort of error. */
- inow = ixsysdep_time ((long *) NULL);
- if (! fforce)
- {
- if (qorigsys->uuconf_cmax_retries > 0
- && sstat.cretries >= qorigsys->uuconf_cmax_retries
- && sstat.ilast <= inow
- && sstat.ilast + SECS_PER_DAY > inow)
- {
- ulog (LOG_ERROR, "Too many retries");
- return FALSE;
- }
-
- if ((sstat.ttype == STATUS_COMPLETE
- ? sstat.ilast + qorigsys->uuconf_csuccess_wait > inow
- : sstat.ilast + sstat.cwait > inow)
- && sstat.ilast <= inow)
- {
- ulog (LOG_NORMAL, "Retry time not reached");
- return FALSE;
- }
- }
-
- sDaemon.puuconf = puuconf;
- sDaemon.zconfig = zconfig;
- if (! fuuxqt)
- sDaemon.irunuuxqt = UUCONF_RUNUUXQT_NEVER;
- else
- {
- int iuuconf;
-
- iuuconf = uuconf_runuuxqt (puuconf, &sDaemon.irunuuxqt);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- }
-
- fbadtime = TRUE;
- fnevertime = TRUE;
- ffoundwork = FALSE;
-
- for (qsys = qorigsys; qsys != NULL; qsys = qsys->uuconf_qalternate)
- {
- int cretry;
- boolean fany, fret, fcalled;
-
- if (FGOT_SIGNAL ())
- return FALSE;
-
- if (! qsys->uuconf_fcall || qsys->uuconf_qtimegrade == NULL)
- continue;
-
- fnevertime = FALSE;
-
- /* Make sure this is a legal time to call. */
- if (! ftimespan_match (qsys->uuconf_qtimegrade, (long *) NULL,
- &cretry))
- continue;
-
- fbadtime = FALSE;
-
- sDaemon.qsys = qsys;
- sDaemon.zlocalname = NULL;
- sDaemon.qconn = NULL;
- sDaemon.qproto = NULL;
- sDaemon.cchans = 1;
- sDaemon.clocal_size = -1;
- sDaemon.cremote_size = -1;
- sDaemon.cmax_ever = -2;
- sDaemon.cmax_receive = -1;
- sDaemon.csent = 0;
- sDaemon.creceived = 0;
- sDaemon.cxfiles_received = 0;
- sDaemon.ifeatures = 0;
- sDaemon.frequest_hangup = FALSE;
- sDaemon.fhangup_requested = FALSE;
- sDaemon.fhangup = FALSE;
- sDaemon.fmaster = TRUE;
- sDaemon.fcaller = TRUE;
- sDaemon.ireliable = 0;
- sDaemon.bgrade = '\0';
-
- /* Queue up any work there is to do. */
- if (! fqueue (&sDaemon, &fany))
- return FALSE;
-
- /* If we are only supposed to call if there is work, and there
- isn't any work, check the next alternates. We can't give up
- at this point because there might be some other alternates
- with fewer restrictions on grade or file transfer size. */
- if (fifwork && ! fany)
- {
- uclear_queue (&sDaemon);
- continue;
- }
-
- ffoundwork = TRUE;
-
- fret = fconn_call (&sDaemon, qport, &sstat, cretry, &fcalled);
-
- uclear_queue (&sDaemon);
-
- if (fret)
- return TRUE;
- if (fcalled && ! ftrynext)
- return FALSE;
-
- /* Now we have to dump that port so that we can aquire a new
- one. On Unix this means that we will fork and get a new
- process ID, so we must unlock and relock the system. */
- if (fdetach)
- {
- (void) fsysdep_unlock_system (&sLocked_system);
- fLocked_system = FALSE;
- usysdep_detach ();
- if (! fsysdep_lock_system (&sLocked_system))
- return FALSE;
- fLocked_system = TRUE;
- }
- }
-
- /* We only get here if no call succeeded. If fbadtime is TRUE it
- was the wrong time for all the alternates. Otherwise, if
- ffoundwork is FALSE there was no work for any of the alternates.
- Otherwise, we attempted a call and fconn_call logged an error
- message. */
-
- if (fbadtime)
- {
- if (! fquiet)
- ulog (LOG_NORMAL, "Wrong time to call");
-
- /* Update the status, unless the system can never be called. If
- the system can never be called, there is little point to
- putting in a ``wrong time to call'' message. We don't change
- the number of retries, although we do set the wait until the
- next retry to 0. */
- if (! fnevertime)
- {
- sstat.ttype = STATUS_WRONG_TIME;
- sstat.ilast = inow;
- sstat.cwait = 0;
- (void) fsysdep_set_status (qorigsys, &sstat);
- }
- }
- else if (! ffoundwork)
- {
- if (! fquiet)
- ulog (LOG_NORMAL, "No work");
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* Find a port to use when calling a system, open a connection, and
- dial the system. The actual call is done in fdo_call. This
- routine is responsible for opening and closing the connection. */
-
-static boolean
-fconn_call (qdaemon, qport, qstat, cretry, pfcalled)
- struct sdaemon *qdaemon;
- struct uuconf_port *qport;
- struct sstatus *qstat;
- int cretry;
- boolean *pfcalled;
-{
- pointer puuconf;
- const struct uuconf_system *qsys;
- struct uuconf_port sport;
- struct sconnection sconn;
- enum tstatus_type terr;
- boolean fret;
-
- puuconf = qdaemon->puuconf;
- qsys = qdaemon->qsys;
-
- *pfcalled = FALSE;
-
- /* Ignore any SIGHUP signal we may have received up to this point.
- This is needed on Unix because we may have gotten one from the
- shell before we detached from the controlling terminal. */
- afSignal[INDEXSIG_SIGHUP] = FALSE;
-
- /* If no port was specified on the command line, use any port
- defined for the system. To select the system port: 1) see if
- port information was specified directly; 2) see if a port was
- named; 3) get an available port given the baud rate. We don't
- change the system status if a port is unavailable; i.e. we don't
- force the system to wait for the retry time. */
- if (qport == NULL)
- qport = qsys->uuconf_qport;
- if (qport != NULL)
- {
- if (! fconn_init (qport, &sconn, UUCONF_PORTTYPE_UNKNOWN))
- return FALSE;
- if (! fconn_lock (&sconn, FALSE))
- {
- ulog (LOG_ERROR, "%s: Port already locked",
- qport->uuconf_zname);
- return FALSE;
- }
- }
- else
- {
- struct spass s;
- int iuuconf;
-
- s.fmatched = FALSE;
- s.flocked = FALSE;
- s.qconn = &sconn;
- iuuconf = uuconf_find_port (puuconf, qsys->uuconf_zport,
- qsys->uuconf_ibaud,
- qsys->uuconf_ihighbaud,
- iuport_lock, (pointer) &s,
- &sport);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- if (s.fmatched)
- ulog (LOG_ERROR, "All matching ports in use");
- else
- ulog (LOG_ERROR, "No matching ports");
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- if (s.flocked)
- {
- (void) fconn_unlock (&sconn);
- uconn_free (&sconn);
- }
- return FALSE;
- }
- }
-
- if (! fconn_open (&sconn, qsys->uuconf_ibaud, qsys->uuconf_ihighbaud,
- FALSE))
- {
- terr = STATUS_PORT_FAILED;
- fret = FALSE;
- }
- else
- {
- struct uuconf_dialer *qdialer;
- struct uuconf_dialer sdialer;
- enum tdialerfound tdialer;
-
- if (qsys->uuconf_zalternate == NULL)
- ulog (LOG_NORMAL, "Calling system %s (port %s)", qsys->uuconf_zname,
- zLdevice == NULL ? (char *) "unknown" : zLdevice);
- else
- ulog (LOG_NORMAL, "Calling system %s (alternate %s, port %s)",
- qsys->uuconf_zname, qsys->uuconf_zalternate,
- zLdevice == NULL ? (char *) "unknown" : zLdevice);
-
- qdialer = NULL;
-
- if (! fconn_dial (&sconn, puuconf, qsys, qsys->uuconf_zphone,
- &sdialer, &tdialer))
- {
- tdialer = DIALERFOUND_FALSE;
- terr = STATUS_DIAL_FAILED;
- fret = FALSE;
- }
- else
- {
- qdaemon->qconn = &sconn;
- if (tdialer == DIALERFOUND_FALSE)
- qdialer = NULL;
- else
- qdialer = &sdialer;
- fret = fdo_call (qdaemon, qstat, qdialer, pfcalled, &terr);
- }
-
- (void) fconn_close (&sconn, puuconf, qdialer, fret);
-
- if (tdialer == DIALERFOUND_FREE)
- (void) uuconf_dialer_free (puuconf, &sdialer);
- }
-
- if (! fret)
- {
- DEBUG_MESSAGE2 (DEBUG_HANDSHAKE, "Call failed: %d (%s)",
- (int) terr, azStatus[(int) terr]);
- qstat->ttype = terr;
- qstat->cretries++;
- qstat->ilast = ixsysdep_time ((long *) NULL);
- if (cretry == 0)
- qstat->cwait = CRETRY_WAIT (qstat->cretries);
- else
- qstat->cwait = cretry * 60;
- (void) fsysdep_set_status (qsys, qstat);
- }
-
- (void) fconn_unlock (&sconn);
- uconn_free (&sconn);
-
- if (qport == NULL)
- (void) uuconf_port_free (puuconf, &sport);
-
- return fret;
-}
-
-/* Do the actual work of calling another system. The qsys argument is
- the system to call, the qconn argument is the connection to use,
- the qstat argument holds the current status of the ssystem, and the
- qdialer argument holds the dialer being used (it may be NULL). If
- we log in successfully, set *pfcalled to TRUE; this is used to
- distinguish a failed dial from a failure during the call. If an
- error occurs *pterr is set to the status type to record. */
-
-static boolean
-fdo_call (qdaemon, qstat, qdialer, pfcalled, pterr)
- struct sdaemon *qdaemon;
- struct sstatus *qstat;
- const struct uuconf_dialer *qdialer;
- boolean *pfcalled;
- enum tstatus_type *pterr;
-{
- pointer puuconf;
- const struct uuconf_system *qsys;
- struct sconnection *qconn;
- int iuuconf;
- int istrip;
- boolean fstrip;
- const char *zport;
- char *zstr;
- long istart_time;
- char *zlog;
-
- puuconf = qdaemon->puuconf;
- qsys = qdaemon->qsys;
- qconn = qdaemon->qconn;
-
- iuuconf = uuconf_strip (puuconf, &istrip);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
- fstrip = (istrip & UUCONF_STRIP_PROTO) != 0;
-
- *pterr = STATUS_LOGIN_FAILED;
-
- if (qconn->qport == NULL)
- zport = "unknown";
- else
- zport = qconn->qport->uuconf_zname;
- if (! fchat (qconn, puuconf, &qsys->uuconf_schat, qsys,
- (const struct uuconf_dialer *) NULL,
- (const char *) NULL, FALSE, zport,
- iconn_baud (qconn)))
- return FALSE;
-
- *pfcalled = TRUE;
- istart_time = ixsysdep_time ((long *) NULL);
-
- *pterr = STATUS_HANDSHAKE_FAILED;
-
- /* We should now see "Shere" from the other system. Newer systems
- send "Shere=foo" where foo is the remote name. */
- zstr = zget_uucp_cmd (qconn, TRUE, fstrip);
- if (zstr == NULL)
- return FALSE;
-
- if (strncmp (zstr, "Shere", 5) != 0)
- {
- ulog (LOG_ERROR, "Bad startup string (expected \"Shere\" got \"%s\")",
- zstr);
- ubuffree (zstr);
- return FALSE;
- }
-
- ulog (LOG_NORMAL, "Login successful");
-
- qstat->ttype = STATUS_TALKING;
- qstat->ilast = ixsysdep_time ((long *) NULL);
- qstat->cretries = 0;
- qstat->cwait = 0;
- if (! fsysdep_set_status (qsys, qstat))
- return FALSE;
-
- if (zstr[5] == '=')
- {
- const char *zheresys;
- size_t clen;
- int icmp;
-
- /* Some UUCP packages only provide seven characters in the Shere
- machine name. Others only provide fourteen. */
- zheresys = zstr + 6;
- clen = strlen (zheresys);
- if (clen == 7 || clen == 14)
- icmp = strncmp (zheresys, qsys->uuconf_zname, clen);
- else
- icmp = strcmp (zheresys, qsys->uuconf_zname);
- if (icmp != 0)
- {
- if (qsys->uuconf_pzalias != NULL)
- {
- char **pz;
-
- for (pz = qsys->uuconf_pzalias; *pz != NULL; pz++)
- {
- if (clen == 7 || clen == 14)
- icmp = strncmp (zheresys, *pz, clen);
- else
- icmp = strcmp (zheresys, *pz);
- if (icmp == 0)
- break;
- }
- }
- if (icmp != 0)
- {
- ulog (LOG_ERROR, "Called wrong system (%s)", zheresys);
- ubuffree (zstr);
- return FALSE;
- }
- }
- }
-#if DEBUG > 1
- else if (zstr[5] != '\0')
- DEBUG_MESSAGE1 (DEBUG_HANDSHAKE,
- "fdo_call: Strange Shere: %s", zstr);
-#endif
-
- ubuffree (zstr);
-
- /* We now send "S" name switches, where name is our UUCP name. If
- we are using sequence numbers with this system, we send a -Q
- argument with the sequence number. If the call-timegrade command
- was used, we send a -p argument and a -vgrade= argument with the
- grade to send us (we send both argument to make it more likely
- that one is recognized). We always send a -N (for new) switch
- indicating what new features we support. */
- {
- long ival;
- char bgrade;
- char *zsend;
- boolean fret;
-
- /* Determine the grade we should request of the other system. A
- '\0' means that no restrictions have been made. */
- if (! ftimespan_match (qsys->uuconf_qcalltimegrade, &ival,
- (int *) NULL))
- bgrade = '\0';
- else
- bgrade = (char) ival;
-
- /* Determine the name we will call ourselves. */
- if (qsys->uuconf_zlocalname != NULL)
- qdaemon->zlocalname = qsys->uuconf_zlocalname;
- else
- {
- iuuconf = uuconf_localname (puuconf, &qdaemon->zlocalname);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- qdaemon->zlocalname = zsysdep_localname ();
- if (qdaemon->zlocalname == NULL)
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
- }
-
- zsend = zbufalc (strlen (qdaemon->zlocalname) + 70);
- if (! qsys->uuconf_fsequence)
- {
- if (bgrade == '\0')
- sprintf (zsend, "S%s -R -N0%o", qdaemon->zlocalname,
- (unsigned int) (FEATURE_SIZES
- | FEATURE_EXEC
- | FEATURE_RESTART));
- else
- sprintf (zsend, "S%s -p%c -vgrade=%c -R -N0%o",
- qdaemon->zlocalname, bgrade, bgrade,
- (unsigned int) (FEATURE_SIZES
- | FEATURE_EXEC
- | FEATURE_RESTART));
- }
- else
- {
- long iseq;
-
- iseq = ixsysdep_get_sequence (qsys);
- if (iseq < 0)
- return FALSE;
- if (bgrade == '\0')
- sprintf (zsend, "S%s -Q%ld -R -N0%o", qdaemon->zlocalname, iseq,
- (unsigned int) (FEATURE_SIZES
- | FEATURE_EXEC
- | FEATURE_RESTART));
- else
- sprintf (zsend, "S%s -Q%ld -p%c -vgrade=%c -R -N0%o",
- qdaemon->zlocalname, iseq, bgrade, bgrade,
- (unsigned int) (FEATURE_SIZES
- | FEATURE_EXEC
- | FEATURE_RESTART));
- }
-
- fret = fsend_uucp_cmd (qconn, zsend);
- ubuffree (zsend);
- if (! fret)
- return FALSE;
- }
-
- /* Now we should see ROK or Rreason where reason gives a cryptic
- reason for failure. If we are talking to a counterpart, we will
- get back ROKN, possibly with a feature bitfield attached. */
- zstr = zget_uucp_cmd (qconn, TRUE, fstrip);
- if (zstr == NULL)
- return FALSE;
-
- if (zstr[0] != 'R')
- {
- ulog (LOG_ERROR, "Bad response to handshake string (%s)",
- zstr);
- ubuffree (zstr);
- return FALSE;
- }
-
- if (strncmp (zstr + 1, "OKN", sizeof "OKN" - 1) == 0)
- {
- if (zstr[sizeof "ROKN" - 1] == '\0')
- qdaemon->ifeatures |= FEATURE_SIZES | FEATURE_V103;
- else
- qdaemon->ifeatures |= (int) strtol (zstr + sizeof "ROKN" - 1,
- (char **) NULL, 0);
- }
- else if (strncmp (zstr + 1, "OK", sizeof "OK" - 1) == 0)
- {
- if (zstr[sizeof "ROK" - 1] != '\0')
- {
- char *zopt;
-
- /* SVR4 UUCP returns options following the ROK string. */
- zopt = zstr + sizeof "ROK" - 1;
- while (*zopt != '\0')
- {
- char b;
- long c;
- char *zend;
-
- b = *zopt++;
- if (isspace (b) || b != '-')
- continue;
- switch (*zopt)
- {
- case 'R':
- qdaemon->ifeatures |= (FEATURE_RESTART
- | FEATURE_SVR4
- | FEATURE_SIZES);
- break;
- case 'U':
- c = strtol (zopt, &zend, 0);
- if (c > 0 && c <= LONG_MAX / (long) 512)
- qdaemon->cmax_receive = c * (long) 512;
- zopt = zend;
- break;
- }
- while (*zopt != '\0' && ! isspace (*zopt))
- ++zopt;
- }
- }
- }
- else if (strcmp (zstr + 1, "CB") == 0)
- {
- ulog (LOG_NORMAL, "Remote system will call back");
- qstat->ttype = STATUS_COMPLETE;
- (void) fsysdep_set_status (qsys, qstat);
- ubuffree (zstr);
- return TRUE;
- }
- else
- {
- ulog (LOG_ERROR, "Handshake failed (%s)", zstr + 1);
- ubuffree (zstr);
- return FALSE;
- }
-
- ubuffree (zstr);
-
- /* The slave should now send \020Pprotos\0 where protos is a list of
- supported protocols. Each protocol is a single character. */
- zstr = zget_uucp_cmd (qconn, TRUE, fstrip);
- if (zstr == NULL)
- return FALSE;
-
- if (zstr[0] != 'P')
- {
- ulog (LOG_ERROR, "Bad protocol handshake (%s)", zstr);
- ubuffree (zstr);
- return FALSE;
- }
-
- /* Determine the reliability characteristics of the connection by
- combining information for the port and the dialer. If we have no
- information, default to a reliable eight-bit full-duplex
- connection. */
- if (qconn->qport != NULL
- && (qconn->qport->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0)
- qdaemon->ireliable = qconn->qport->uuconf_ireliable;
- if (qdialer != NULL
- && (qdialer->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0)
- {
- if (qdaemon->ireliable != 0)
- qdaemon->ireliable &= qdialer->uuconf_ireliable;
- else
- qdaemon->ireliable = qdialer->uuconf_ireliable;
- }
- if (qdaemon->ireliable == 0)
- qdaemon->ireliable = (UUCONF_RELIABLE_RELIABLE
- | UUCONF_RELIABLE_EIGHT
- | UUCONF_RELIABLE_FULLDUPLEX
- | UUCONF_RELIABLE_SPECIFIED);
-
- /* Now decide which protocol to use. The system and the port may
- have their own list of protocols. */
- {
- int i;
- char ab[5];
-
- i = CPROTOCOLS;
- if (qsys->uuconf_zprotocols != NULL
- || (qconn->qport != NULL
- && qconn->qport->uuconf_zprotocols != NULL))
- {
- const char *zproto;
-
- if (qsys->uuconf_zprotocols != NULL)
- zproto = qsys->uuconf_zprotocols;
- else
- zproto = qconn->qport->uuconf_zprotocols;
- for (; *zproto != '\0'; zproto++)
- {
- if (strchr (zstr + 1, *zproto) != NULL)
- {
- for (i = 0; i < CPROTOCOLS; i++)
- if (asProtocols[i].bname == *zproto)
- break;
- if (i < CPROTOCOLS)
- break;
- }
- }
- }
- else
- {
- /* If neither the system nor the port specified a list of
- protocols, we want only protocols that match the known
- reliability of the dialer and the port. */
- for (i = 0; i < CPROTOCOLS; i++)
- {
- int ipr;
-
- ipr = asProtocols[i].ireliable;
- if ((ipr & qdaemon->ireliable) != ipr)
- continue;
- if (strchr (zstr + 1, asProtocols[i].bname) != NULL)
- break;
- }
- }
-
- ubuffree (zstr);
-
- if (i >= CPROTOCOLS)
- {
- (void) fsend_uucp_cmd (qconn, "UN");
- ulog (LOG_ERROR, "No mutually supported protocols");
- return FALSE;
- }
-
- qdaemon->qproto = &asProtocols[i];
-
- /* If we are using a half-duplex line, act as though we have only
- a single channel; otherwise we might start a send and a receive
- at the same time. */
- if ((qdaemon->ireliable & UUCONF_RELIABLE_FULLDUPLEX) == 0)
- qdaemon->cchans = 1;
- else
- qdaemon->cchans = asProtocols[i].cchans;
-
- sprintf (ab, "U%c", qdaemon->qproto->bname);
- if (! fsend_uucp_cmd (qconn, ab))
- return FALSE;
- }
-
- /* Run any protocol parameter commands. */
- if (qdaemon->qproto->qcmds != NULL)
- {
- if (qsys->uuconf_qproto_params != NULL)
- uapply_proto_params (puuconf, qdaemon->qproto->bname,
- qdaemon->qproto->qcmds,
- qsys->uuconf_qproto_params);
- if (qconn->qport != NULL
- && qconn->qport->uuconf_qproto_params != NULL)
- uapply_proto_params (puuconf, qdaemon->qproto->bname,
- qdaemon->qproto->qcmds,
- qconn->qport->uuconf_qproto_params);
- if (qdialer != NULL
- && qdialer->uuconf_qproto_params != NULL)
- uapply_proto_params (puuconf, qdaemon->qproto->bname,
- qdaemon->qproto->qcmds,
- qdialer->uuconf_qproto_params);
- }
-
- /* Turn on the selected protocol. */
- if (! (*qdaemon->qproto->pfstart) (qdaemon, &zlog))
- return FALSE;
- if (zlog == NULL)
- {
- zlog = zbufalc (sizeof "protocol ''" + 1);
- sprintf (zlog, "protocol '%c'", qdaemon->qproto->bname);
- }
- ulog (LOG_NORMAL, "Handshake successful (%s)", zlog);
- ubuffree (zlog);
-
- *pterr = STATUS_FAILED;
-
- {
- boolean fret;
- long iend_time;
-
- fret = floop (qdaemon);
-
- /* Now send the hangup message. As the caller, we send six O's
- and expect to receive seven O's. We send the six O's twice to
- help the other side. We don't worry about errors here. */
- if (fsend_uucp_cmd (qconn, "OOOOOO")
- && fsend_uucp_cmd (qconn, "OOOOOO"))
- {
- int i, fdone;
-
- /* We look for the remote hangup string to ensure that the
- modem has sent out our hangup string. This is only
- necessary because some versions of UUCP complain if they
- don't get the hangup string. The remote site should send 7
- O's, but some versions of UUCP only send 6. We look for
- the string several times because supposedly some
- implementations send some garbage after the last packet but
- before the hangup string. */
- for (i = 0; i < 25; i++)
- {
- zstr = zget_uucp_cmd (qconn, FALSE, fstrip);
- if (zstr == NULL)
- break;
- fdone = strstr (zstr, "OOOOOO") != NULL;
- ubuffree (zstr);
- if (fdone)
- break;
- }
- }
-
- iend_time = ixsysdep_time ((long *) NULL);
-
- ulog (LOG_NORMAL, "Call complete (%ld seconds %ld bytes %ld bps)",
- iend_time - istart_time,
- qdaemon->csent + qdaemon->creceived,
- (iend_time != istart_time
- ? (qdaemon->csent + qdaemon->creceived) / (iend_time - istart_time)
- : 0));
-
- if (fret)
- {
- qstat->ttype = STATUS_COMPLETE;
- qstat->ilast = iend_time;
- (void) fsysdep_set_status (qsys, qstat);
- }
-
- if (qdaemon->irunuuxqt == UUCONF_RUNUUXQT_PERCALL
- || (qdaemon->irunuuxqt > 0 && qdaemon->cxfiles_received > 0))
- (void) fspawn_uuxqt (TRUE, qdaemon->qsys->uuconf_zname,
- qdaemon->zconfig);
-
- return fret;
- }
-}
-
-/* This routine is called via uuconf_find_port when a matching port is
- found. It tries to lock the port. If it fails, it returns
- UUCONF_NOT_FOUND to force uuconf_find_port to continue searching
- for the next matching port. */
-
-static int
-iuport_lock (qport, pinfo)
- struct uuconf_port *qport;
- pointer pinfo;
-{
- struct spass *q = (struct spass *) pinfo;
-
- q->fmatched = TRUE;
-
- if (! fconn_init (qport, q->qconn, UUCONF_PORTTYPE_UNKNOWN))
- return UUCONF_NOT_FOUND;
- else if (! fconn_lock (q->qconn, FALSE))
- {
- uconn_free (q->qconn);
- return UUCONF_NOT_FOUND;
- }
- else
- {
- q->flocked = TRUE;
- return UUCONF_SUCCESS;
- }
-}
-
-/* The information structure used for the uuconf_callin comparison
- function. */
-
-struct scallin_info
-{
- const char *zuser;
- const char *zpass;
-};
-
-/* Prompt for a login name and a password, and run as the slave. */
-
-static boolean
-flogin_prompt (puuconf, zconfig, fuuxqt, qconn, zlogin, pzsystem)
- pointer puuconf;
- const char *zconfig;
- boolean fuuxqt;
- struct sconnection *qconn;
- const char *zlogin;
- const char **pzsystem;
-{
- int iuuconf;
- int istrip;
- boolean fstrip;
- char *zuser, *zpass;
- boolean fret;
- struct scallin_info s;
-
- if (pzsystem != NULL)
- *pzsystem = NULL;
-
- DEBUG_MESSAGE0 (DEBUG_HANDSHAKE, "flogin_prompt: Waiting for login");
-
- iuuconf = uuconf_strip (puuconf, &istrip);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
- fstrip = (istrip & UUCONF_STRIP_LOGIN) != 0;
-
- zuser = NULL;
- if (zlogin == NULL)
- {
- do
- {
- ubuffree (zuser);
- if (! fconn_write (qconn, "login: ", sizeof "login: " - 1))
- return FALSE;
- zuser = zget_typed_line (qconn, fstrip);
- }
- while (zuser != NULL && *zuser == '\0');
-
- if (zuser == NULL)
- return TRUE;
-
- zlogin = zuser;
- }
-
- if (! fconn_write (qconn, "Password:", sizeof "Password:" - 1))
- {
- ubuffree (zuser);
- return FALSE;
- }
-
- zpass = zget_typed_line (qconn, fstrip);
- if (zpass == NULL)
- {
- ubuffree (zuser);
- return TRUE;
- }
-
- fret = TRUE;
-
- s.zuser = zlogin;
- s.zpass = zpass;
- iuuconf = uuconf_callin (puuconf, icallin_cmp, &s);
-
- ubuffree (zpass);
-
- if (iuuconf == UUCONF_NOT_FOUND)
- ulog (LOG_ERROR, "Bad login");
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fret = FALSE;
- }
- else
- {
-#if DEBUG > 1
- int iholddebug;
-#endif
-
- /* We ignore the return value of faccept_call because we really
- don't care whether the call succeeded or not. We are going
- to reset the port anyhow. */
-#if DEBUG > 1
- iholddebug = iDebug;
-#endif
- (void) faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem);
-#if DEBUG > 1
- iDebug = iholddebug;
-#endif
- }
-
- ubuffree (zuser);
-
- return fret;
-}
-
-/* The comparison function which we pass to uuconf_callin. This
- expands escape sequences in the login name, and either encrypts or
- expands escape sequences in the password. */
-
-static int
-icallin_cmp (iwhich, pinfo, zfile)
- int iwhich;
- pointer pinfo;
- const char *zfile;
-{
- struct scallin_info *qinfo = (struct scallin_info *) pinfo;
- char *zcopy;
- int icmp;
-
-#if HAVE_ENCRYPTED_PASSWORDS
- if (iwhich != 0)
- return strcmp (crypt (qinfo->zpass, zfile), zfile) == 0;
-#endif
-
- zcopy = zbufcpy (zfile);
- (void) cescape (zcopy);
- if (iwhich == 0)
- icmp = strcmp (qinfo->zuser, zcopy);
- else
- icmp = strcmp (qinfo->zpass, zcopy);
- ubuffree (zcopy);
- return icmp == 0;
-}
-
-/* Accept a call from a remote system. If pqsys is not NULL, *pqsys
- will be set to the system that called in if known. */
-
-static boolean
-faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem)
- pointer puuconf;
- const char *zconfig;
- boolean fuuxqt;
- const char *zlogin;
- struct sconnection *qconn;
- const char **pzsystem;
-{
- long istart_time;
- int iuuconf;
- int istrip;
- boolean fstrip;
- const char *zport;
- struct uuconf_port *qport;
- struct uuconf_port sport;
- struct uuconf_dialer *qdialer;
- struct uuconf_dialer sdialer;
- boolean ftcp_port;
- char *zsend, *zspace;
- boolean fret;
- char *zstr;
- struct uuconf_system ssys;
- const struct uuconf_system *qsys;
- const struct uuconf_system *qany;
- char *zloc;
- struct sstatus sstat;
- boolean fgotseq, fgotn;
- int i;
- char *zlog;
- char *zgrade;
-
- if (pzsystem != NULL)
- *pzsystem = NULL;
-
- ulog (LOG_NORMAL, "Incoming call (login %s port %s)", zlogin,
- zLdevice == NULL ? (char *) "unknown" : zLdevice);
-
- istart_time = ixsysdep_time ((long *) NULL);
-
- iuuconf = uuconf_strip (puuconf, &istrip);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- (struct uuconf_port *) NULL,
- &sport, (char *) NULL);
- return FALSE;
- }
- fstrip = (istrip & UUCONF_STRIP_PROTO) != 0;
-
- /* Figure out protocol parameters determined by the port. If no
- port was specified we're reading standard input, so try to get
- the port name and read information from the port file. We only
- use the port information to get protocol parameters; we don't
- want to start treating the port as though it were a modem, for
- example. */
- if (qconn->qport != NULL)
- {
- qport = qconn->qport;
- zport = qport->uuconf_zname;
- ftcp_port = FALSE;
- }
- else
- {
- zport = zsysdep_port_name (&ftcp_port);
- if (zport == NULL)
- {
- qport = NULL;
- zport = "unknown";
- }
- else
- {
- iuuconf = uuconf_find_port (puuconf, zport, (long) 0, (long) 0,
- (int (*) P((struct uuconf_port *,
- pointer pinfo))) NULL,
- (pointer) NULL,
- &sport);
- if (iuuconf == UUCONF_NOT_FOUND)
- qport = NULL;
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- (struct uuconf_port *) NULL,
- &sport, (char *) NULL);
- return FALSE;
- }
- else
- qport = &sport;
- }
- }
-
- /* If we've managed to figure out that this is a modem port, now try
- to get protocol parameters from the dialer. */
- qdialer = NULL;
- if (qport != NULL)
- {
- if (qport->uuconf_ttype == UUCONF_PORTTYPE_MODEM)
- {
- if (qport->uuconf_u.uuconf_smodem.uuconf_pzdialer != NULL)
- {
- const char *zdialer;
-
- zdialer = qport->uuconf_u.uuconf_smodem.uuconf_pzdialer[0];
- iuuconf = uuconf_dialer_info (puuconf, zdialer, &sdialer);
- if (iuuconf == UUCONF_SUCCESS)
- qdialer = &sdialer;
- }
- else
- qdialer = qport->uuconf_u.uuconf_smodem.uuconf_qdialer;
- }
- else if (qport->uuconf_ttype == UUCONF_PORTTYPE_TCP
- || (qport->uuconf_ttype == UUCONF_PORTTYPE_TLI
- && (qport->uuconf_ireliable
- & UUCONF_RELIABLE_SPECIFIED) == 0))
- ftcp_port = TRUE;
- }
-
- sDaemon.puuconf = puuconf;
- sDaemon.zconfig = zconfig;
- if (! fuuxqt)
- sDaemon.irunuuxqt = UUCONF_RUNUUXQT_NEVER;
- else
- {
- iuuconf = uuconf_runuuxqt (puuconf, &sDaemon.irunuuxqt);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- }
- sDaemon.qsys = NULL;
- sDaemon.zlocalname = NULL;
- sDaemon.qconn = qconn;
- sDaemon.qproto = NULL;
- sDaemon.cchans = 1;
- sDaemon.clocal_size = -1;
- sDaemon.cremote_size = -1;
- sDaemon.cmax_ever = -2;
- sDaemon.cmax_receive = -1;
- sDaemon.csent = 0;
- sDaemon.creceived = 0;
- sDaemon.cxfiles_received = 0;
- sDaemon.ifeatures = 0;
- sDaemon.frequest_hangup = FALSE;
- sDaemon.fhangup_requested = FALSE;
- sDaemon.fhangup = FALSE;
- sDaemon.fmaster = FALSE;
- sDaemon.fcaller = FALSE;
- sDaemon.ireliable = 0;
- sDaemon.bgrade = UUCONF_GRADE_LOW;
-
- /* Get the local name to use. If uuconf_login_localname returns a
- value, it is not always freed up, although it should be. */
- iuuconf = uuconf_login_localname (puuconf, zlogin, &zloc);
- if (iuuconf == UUCONF_SUCCESS)
- sDaemon.zlocalname = zloc;
- else if (iuuconf == UUCONF_NOT_FOUND)
- {
- sDaemon.zlocalname = zsysdep_localname ();
- if (sDaemon.zlocalname == NULL)
- {
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- qport, &sport, (char *) NULL);
- return FALSE;
- }
- }
- else
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- qport, &sport, (char *) NULL);
- return FALSE;
- }
-
- /* Tell the remote system who we are. */
- zsend = zbufalc (strlen (sDaemon.zlocalname) + sizeof "Shere=");
- sprintf (zsend, "Shere=%s", sDaemon.zlocalname);
- fret = fsend_uucp_cmd (qconn, zsend);
- ubuffree (zsend);
- if (! fret)
- {
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- qport, &sport, zloc);
- return FALSE;
- }
-
- zstr = zget_uucp_cmd (qconn, TRUE, fstrip);
- if (zstr == NULL)
- {
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- qport, &sport, zloc);
- return FALSE;
- }
-
- if (zstr[0] != 'S')
- {
- ulog (LOG_ERROR, "Bad introduction string");
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- qport, &sport, zloc);
- return FALSE;
- }
-
- zspace = strchr (zstr, ' ');
- if (zspace != NULL)
- *zspace = '\0';
-
- iuuconf = uuconf_system_info (puuconf, zstr + 1, &ssys);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- char *zscript;
-
- /* Run the remote.unknown script, if appropriate. */
- iuuconf = uuconf_remote_unknown (puuconf, &zscript);
- if (iuuconf == UUCONF_SUCCESS)
- {
- if (! fsysdep_unknown_caller (zscript, zstr + 1))
- {
- xfree ((pointer) zscript);
- (void) fsend_uucp_cmd (qconn, "RYou are unknown to me");
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- qport, &sport, zloc);
- return FALSE;
- }
- xfree ((pointer) zscript);
- }
- else if (iuuconf != UUCONF_NOT_FOUND)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- qport, &sport, zloc);
- return FALSE;
- }
-
- if (! funknown_system (puuconf, zstr + 1, &ssys))
- {
- (void) fsend_uucp_cmd (qconn, "RYou are unknown to me");
- ulog (LOG_ERROR, "Call from unknown system %s", zstr + 1);
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- qport, &sport, zloc);
- return FALSE;
- }
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
- qport, &sport, zloc);
- return FALSE;
- }
-
- qany = NULL;
- for (qsys = &ssys; qsys != NULL; qsys = qsys->uuconf_qalternate)
- {
- if (! qsys->uuconf_fcalled)
- continue;
-
- if (qsys->uuconf_zcalled_login == NULL
- || strcmp (qsys->uuconf_zcalled_login, "ANY") == 0)
- {
- if (qany == NULL)
- qany = qsys;
- }
- else if (strcmp (qsys->uuconf_zcalled_login, zlogin) == 0)
- break;
- }
-
- if (qsys == NULL && qany != NULL)
- {
- iuuconf = uuconf_validate (puuconf, qany, zlogin);
- if (iuuconf == UUCONF_SUCCESS)
- qsys = qany;
- else if (iuuconf != UUCONF_NOT_FOUND)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
- }
-
- if (qsys == NULL)
- {
- (void) fsend_uucp_cmd (qconn, "RLOGIN");
- ulog (LOG_ERROR, "System %s used wrong login name %s",
- zstr + 1, zlogin);
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
-
- sDaemon.qsys = qsys;
-
- if (pzsystem != NULL)
- *pzsystem = zbufcpy (qsys->uuconf_zname);
-
- ulog_system (qsys->uuconf_zname);
-
-#if DEBUG > 1
- if (qsys->uuconf_zdebug != NULL)
- iDebug |= idebug_parse (qsys->uuconf_zdebug);
-#endif
-
- /* See if we are supposed to call the system back. This will queue
- up an empty command. It would be better to actually call back
- directly at this point as well. */
- if (qsys->uuconf_fcallback)
- {
- (void) fsend_uucp_cmd (qconn, "RCB");
- ulog (LOG_NORMAL, "Will call back");
-
- /* Clear any existing status. */
- sstat.ttype = STATUS_COMPLETE;
- sstat.cretries = 0;
- sstat.ilast = ixsysdep_time ((long *) NULL);
- sstat.cwait = 0;
- (void) fsysdep_set_status (qsys, &sstat);
-
- ubuffree (zsysdep_spool_commands (qsys, UUCONF_GRADE_HIGH, 0,
- (const struct scmd *) NULL));
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return TRUE;
- }
-
- /* We only permit one call at a time from a remote system. Lock it. */
- if (! fsysdep_lock_system (qsys))
- {
- if (qsys->uuconf_fsequence)
- {
- /* At this point the calling system has already incremented
- its sequence number, so we increment ours. This will
- only cause a mismatch if the other system is not what it
- says it is. */
- (void) ixsysdep_get_sequence (qsys);
- }
- (void) fsend_uucp_cmd (qconn, "RLCK");
- ulog (LOG_ERROR, "System already locked");
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
- sLocked_system = *qsys;
- fLocked_system = TRUE;
-
- /* Set the system status. We don't care what the status was before.
- We also don't want to kill the conversation just because we can't
- output the .Status file, so we ignore any errors. */
- sstat.ttype = STATUS_TALKING;
- sstat.cretries = 0;
- sstat.ilast = ixsysdep_time ((long *) NULL);
- sstat.cwait = 0;
- (void) fsysdep_set_status (qsys, &sstat);
-
- /* Check the arguments of the remote system, if any. */
- fgotseq = FALSE;
- fgotn = FALSE;
- if (zspace != NULL)
- {
- char **paz;
- char **pzset;
-
- ++zspace;
-
- /* Break the introduction line up into arguments. */
- paz = (char **) xmalloc ((strlen (zspace) / 2 + 2) * sizeof (char *));
- pzset = paz;
- *pzset++ = NULL;
- while (TRUE)
- {
- while (*zspace != '\0' && isspace (BUCHAR (*zspace)))
- ++zspace;
- if (*zspace == '\0')
- break;
- *pzset++ = zspace;
- ++zspace;
- while (*zspace != '\0' && ! isspace (BUCHAR (*zspace)))
- ++zspace;
- if (*zspace == '\0')
- break;
- *zspace++ = '\0';
- }
-
- if (pzset != paz + 1)
- {
- int iopt;
-
- *pzset = NULL;
-
- /* We are going to use getopt to parse the arguments. We
- must clear optind to force getopt to reinitialize, and
- clear opterr to prevent getopt from printing an error
- message. This approach assumes we are using the GNU
- getopt, which is distributed with the program anyhow. */
- optind = 0;
- opterr = 0;
-
- while ((iopt = getopt (pzset - paz, paz,
- "N::p:Q:RU:v:x:")) != EOF)
- {
- long iseq;
- long c;
- char b;
- int iwant;
-
- switch (iopt)
- {
- case 'N':
- /* This is used to indicate support for Taylor UUCP
- extensions. An plain -N mean support for size
- negotiation. If -N is followed by a number (with
- no intervening space), the number is a bit field
- of feature flags as defined in trans.h. Note
- that the argument may start with 0x for hex or 0
- for octal. */
- fgotn = TRUE;
- if (optarg == NULL)
- sDaemon.ifeatures |= FEATURE_SIZES | FEATURE_V103;
- else
- sDaemon.ifeatures |= (int) strtol (optarg,
- (char **) NULL,
- 0);
- break;
-
- case 'p':
- /* The argument is the lowest grade of work the
- local system should send. */
- if (UUCONF_GRADE_LEGAL (optarg[0]))
- sDaemon.bgrade = optarg[0];
- break;
-
- case 'Q':
- /* The conversation sequence number. */
- iseq = strtol (optarg, (char **) NULL, 10);
- if (qsys->uuconf_fsequence
- && iseq != ixsysdep_get_sequence (qsys))
- {
- (void) fsend_uucp_cmd (qconn, "RBADSEQ");
- ulog (LOG_ERROR, "Out of sequence call rejected");
- sstat.ttype = STATUS_FAILED;
- (void) fsysdep_set_status (qsys, &sstat);
- xfree ((pointer) paz);
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport,
- zloc);
- return FALSE;
- }
- fgotseq = TRUE;
- break;
-
- case 'R':
- /* The remote system supports file restart. */
- sDaemon.ifeatures |= FEATURE_RESTART;
- break;
-
- case 'U':
- /* The maximum file size the remote system is
- prepared to received, in blocks where each block
- is 512 bytes. */
- c = strtol (optarg, (char **) NULL, 0);
- if (c > 0 && c < LONG_MAX / (long) 512)
- sDaemon.cmax_receive = c * (long) 512;
- break;
-
- case 'v':
- /* -vgrade=X can be used to set the lowest grade of
- work the local system should send. */
- if (strncmp (optarg, "grade=", sizeof "grade=" - 1) == 0)
- {
- b = optarg[sizeof "grade=" - 1];
- if (UUCONF_GRADE_LEGAL (b))
- sDaemon.bgrade = b;
- }
- break;
-
- case 'x':
- iwant = (int) strtol (optarg, (char **) NULL, 10);
-#if DEBUG > 1
- if (iwant <= 9)
- iwant = (1 << iwant) - 1;
- if (qsys->uuconf_zmax_remote_debug != NULL)
- iwant &= idebug_parse (qsys->uuconf_zmax_remote_debug);
- else
- iwant &= DEBUG_ABNORMAL | DEBUG_CHAT | DEBUG_HANDSHAKE;
- if ((iDebug | iwant) != iDebug)
- {
- iDebug |= iwant;
- ulog (LOG_NORMAL, "Setting debugging mode to 0%o",
- iDebug);
- }
-#endif
- break;
-
- default:
- break;
- }
- }
- }
-
- xfree ((pointer) paz);
- }
-
- ubuffree (zstr);
-
- if (qsys->uuconf_fsequence && ! fgotseq)
- {
- (void) fsend_uucp_cmd (qconn, "RBADSEQ");
- ulog (LOG_ERROR, "No sequence number (call rejected)");
- sstat.ttype = STATUS_FAILED;
- (void) fsysdep_set_status (qsys, &sstat);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
-
- /* We recognized the system, and the sequence number (if any) was
- OK. Send an ROK, and send a list of protocols. If we got the -N
- switch, send ROKN to confirm it; if the -N switch was followed by
- a feature bitfield, return our own feature bitfield. */
- {
- char ab[20];
- const char *zreply;
-
- if (! fgotn)
- {
- if ((sDaemon.ifeatures & FEATURE_RESTART) == 0)
- zreply = "ROK";
- else
- {
- /* We got -R without -N, so assume that this is SVR4 UUCP.
- SVR4 UUCP expects ROK -R to signal support for file
- restart. */
- sDaemon.ifeatures |= FEATURE_SVR4 | FEATURE_SIZES;
- zreply = "ROK -R";
- }
- }
- else if ((sDaemon.ifeatures & FEATURE_V103) != 0)
- zreply = "ROKN";
- else
- {
- sprintf (ab, "ROKN0%o",
- (unsigned int) (FEATURE_SIZES
- | FEATURE_EXEC
- | FEATURE_RESTART));
- zreply = ab;
- }
- if (! fsend_uucp_cmd (qconn, zreply))
- {
- sstat.ttype = STATUS_FAILED;
- (void) fsysdep_set_status (qsys, &sstat);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
- }
-
- /* Determine the reliability of the connection based on the
- reliability of the port and the dialer. If we have no
- information, default to a reliable eight-bit full-duplex
- connection. */
- if (ftcp_port)
- sDaemon.ireliable = (UUCONF_RELIABLE_SPECIFIED
- | UUCONF_RELIABLE_ENDTOEND
- | UUCONF_RELIABLE_RELIABLE
- | UUCONF_RELIABLE_EIGHT
- | UUCONF_RELIABLE_FULLDUPLEX);
- else
- {
- if (qport != NULL
- && (qport->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0)
- sDaemon.ireliable = qport->uuconf_ireliable;
- if (qdialer != NULL
- && (qdialer->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0)
- {
- if (sDaemon.ireliable != 0)
- sDaemon.ireliable &= qdialer->uuconf_ireliable;
- else
- sDaemon.ireliable = qdialer->uuconf_ireliable;
- }
- if (sDaemon.ireliable == 0)
- sDaemon.ireliable = (UUCONF_RELIABLE_RELIABLE
- | UUCONF_RELIABLE_EIGHT
- | UUCONF_RELIABLE_FULLDUPLEX
- | UUCONF_RELIABLE_SPECIFIED);
- }
-
- if (qsys->uuconf_zprotocols != NULL ||
- (qport != NULL && qport->uuconf_zprotocols != NULL))
- {
- const char *zprotos;
-
- if (qsys->uuconf_zprotocols != NULL)
- zprotos = qsys->uuconf_zprotocols;
- else
- zprotos = qport->uuconf_zprotocols;
- zsend = zbufalc (strlen (zprotos) + 2);
- sprintf (zsend, "P%s", zprotos);
- }
- else
- {
- char *zset;
-
- zsend = zbufalc (CPROTOCOLS + 2);
- zset = zsend;
- *zset++ = 'P';
-
- /* If the system did not specify a list of protocols, we want
- only protocols that match the known reliability of the dialer
- and the port. */
- for (i = 0; i < CPROTOCOLS; i++)
- {
- int ipr;
-
- ipr = asProtocols[i].ireliable;
- if ((ipr & sDaemon.ireliable) != ipr)
- continue;
- *zset++ = asProtocols[i].bname;
- }
- *zset = '\0';
- }
-
- fret = fsend_uucp_cmd (qconn, zsend);
- ubuffree (zsend);
- if (! fret)
- {
- sstat.ttype = STATUS_FAILED;
- (void) fsysdep_set_status (qsys, &sstat);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
-
- /* The master will now send back the selected protocol. */
- zstr = zget_uucp_cmd (qconn, TRUE, fstrip);
- if (zstr == NULL)
- {
- sstat.ttype = STATUS_FAILED;
- (void) fsysdep_set_status (qsys, &sstat);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
-
- if (zstr[0] != 'U')
- {
- ulog (LOG_ERROR, "Bad protocol response string");
- sstat.ttype = STATUS_FAILED;
- (void) fsysdep_set_status (qsys, &sstat);
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
-
- if (zstr[1] == 'N')
- {
- ulog (LOG_ERROR, "No supported protocol");
- sstat.ttype = STATUS_FAILED;
- (void) fsysdep_set_status (qsys, &sstat);
- ubuffree (zstr);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
-
- for (i = 0; i < CPROTOCOLS; i++)
- if (asProtocols[i].bname == zstr[1])
- break;
-
- ubuffree (zstr);
-
- if (i >= CPROTOCOLS)
- {
- ulog (LOG_ERROR, "No supported protocol");
- sstat.ttype = STATUS_FAILED;
- (void) fsysdep_set_status (qsys, &sstat);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
-
- sDaemon.qproto = &asProtocols[i];
-
- /* If we are using a half-duplex line, act as though we have only a
- single channel; otherwise we might start a send and a receive at
- the same time. */
- if ((sDaemon.ireliable & UUCONF_RELIABLE_FULLDUPLEX) == 0)
- sDaemon.cchans = 1;
- else
- sDaemon.cchans = asProtocols[i].cchans;
-
- /* Run the chat script for when a call is received. */
- if (! fchat (qconn, puuconf, &qsys->uuconf_scalled_chat, qsys,
- (const struct uuconf_dialer *) NULL, (const char *) NULL,
- FALSE, zport, iconn_baud (qconn)))
- {
- sstat.ttype = STATUS_FAILED;
- sstat.ilast = ixsysdep_time ((long *) NULL);
- (void) fsysdep_set_status (qsys, &sstat);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
-
- /* Run any protocol parameter commands. */
- if (sDaemon.qproto->qcmds != NULL)
- {
- if (qsys->uuconf_qproto_params != NULL)
- uapply_proto_params (puuconf, sDaemon.qproto->bname,
- sDaemon.qproto->qcmds,
- qsys->uuconf_qproto_params);
- if (qport != NULL
- && qport->uuconf_qproto_params != NULL)
- uapply_proto_params (puuconf, sDaemon.qproto->bname,
- sDaemon.qproto->qcmds,
- qport->uuconf_qproto_params);
- if (qdialer != NULL
- && qdialer->uuconf_qproto_params != NULL)
- uapply_proto_params (puuconf, sDaemon.qproto->bname,
- sDaemon.qproto->qcmds,
- qdialer->uuconf_qproto_params);
- }
-
- /* We don't need the dialer information any more. */
- if (qdialer == &sdialer)
- (void) uuconf_dialer_free (puuconf, &sdialer);
-
- /* Turn on the selected protocol and get any jobs queued for the
- system. */
- if (! (*sDaemon.qproto->pfstart) (&sDaemon, &zlog)
- || ! fqueue (&sDaemon, (boolean *) NULL))
- {
- uclear_queue (&sDaemon);
- sstat.ttype = STATUS_FAILED;
- sstat.ilast = ixsysdep_time ((long *) NULL);
- (void) fsysdep_set_status (qsys, &sstat);
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
- return FALSE;
- }
-
- if (zlog == NULL)
- {
- zlog = zbufalc (sizeof "protocol ''" + 1);
- sprintf (zlog, "protocol '%c'", sDaemon.qproto->bname);
- }
-
- zgrade = zbufalc (sizeof "grade " + 1);
- if (sDaemon.bgrade == UUCONF_GRADE_LOW)
- *zgrade = '\0';
- else
- sprintf (zgrade, "grade %c ", sDaemon.bgrade);
-
- /* If we are using HAVE_HDB_LOGGING, then the previous ``incoming
- call'' message went to the general log, since we didn't know the
- system name at that point. In that case, we repeat the port and
- login names. */
-#if HAVE_HDB_LOGGING
- ulog (LOG_NORMAL, "Handshake successful (login %s port %s %s%s)",
- zlogin,
- zLdevice == NULL ? "unknown" : zLdevice,
- zgrade, zlog);
-#else /* ! HAVE_HDB_LOGGING */
- ulog (LOG_NORMAL, "Handshake successful (%s%s)", zgrade, zlog);
-#endif /* ! HAVE_HDB_LOGGING */
-
- ubuffree (zlog);
- ubuffree (zgrade);
-
- {
- long iend_time;
-
- fret = floop (&sDaemon);
-
- /* Hangup. As the answerer, we send seven O's and expect to
- receive six O's. We send the seven O's twice to help the other
- side. We don't worry about errors here. */
- if (fsend_uucp_cmd (qconn, "OOOOOOO")
- && fsend_uucp_cmd (qconn, "OOOOOOO"))
- {
- int fdone;
-
- /* We look for the remote hangup string to ensure that the
- modem has sent out our hangup string. This is only
- necessary because some versions of UUCP complain if they
- don't get the hangup string. We look for the string
- several times because supposedly some implementations send
- some garbage after the last packet but before the hangup
- string. */
- for (i = 0; i < 25; i++)
- {
- zstr = zget_uucp_cmd (qconn, FALSE, fstrip);
- if (zstr == NULL)
- break;
- fdone = strstr (zstr, "OOOOOO") != NULL;
- ubuffree (zstr);
- if (fdone)
- break;
- }
- }
-
- iend_time = ixsysdep_time ((long *) NULL);
-
- ulog (LOG_NORMAL, "Call complete (%ld seconds %ld bytes %ld bps)",
- iend_time - istart_time,
- sDaemon.csent + sDaemon.creceived,
- (iend_time != istart_time
- ? (sDaemon.csent + sDaemon.creceived) / (iend_time - istart_time)
- : 0));
-
- uclear_queue (&sDaemon);
-
- if (fret)
- sstat.ttype = STATUS_COMPLETE;
- else
- sstat.ttype = STATUS_FAILED;
- sstat.ilast = iend_time;
- (void) fsysdep_set_status (qsys, &sstat);
-
- if (sDaemon.irunuuxqt == UUCONF_RUNUUXQT_PERCALL
- || (sDaemon.irunuuxqt > 0 && sDaemon.cxfiles_received > 0))
- (void) fspawn_uuxqt (TRUE, qsys->uuconf_zname, zconfig);
-
- uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
-
- return fret;
- }
-}
-
-/* Clean up after faccept_call. */
-
-static void
-uaccept_call_cleanup (puuconf, qfreesys, qport, qfreeport, zloc)
- pointer puuconf;
- struct uuconf_system *qfreesys;
- struct uuconf_port *qport;
- struct uuconf_port *qfreeport;
- char *zloc;
-{
- if (fLocked_system)
- {
- (void) fsysdep_unlock_system (&sLocked_system);
- fLocked_system = FALSE;
- }
- if (qfreesys != NULL)
- (void) uuconf_system_free (puuconf, qfreesys);
- if (qport == qfreeport)
- (void) uuconf_port_free (puuconf, qfreeport);
- xfree ((pointer) zloc);
- ulog_system ((const char *) NULL);
-}
-
-/* Apply protocol parameters, once we know the protocol. */
-
-static void
-uapply_proto_params (puuconf, bproto, qcmds, pas)
- pointer puuconf;
- int bproto;
- struct uuconf_cmdtab *qcmds;
- struct uuconf_proto_param *pas;
-{
- struct uuconf_proto_param *qp;
-
- for (qp = pas; qp->uuconf_bproto != '\0'; qp++)
- {
- if (qp->uuconf_bproto == bproto)
- {
- struct uuconf_proto_param_entry *qe;
-
- for (qe = qp->uuconf_qentries; qe->uuconf_cargs > 0; qe++)
- {
- int iuuconf;
-
- iuuconf = uuconf_cmd_args (puuconf, qe->uuconf_cargs,
- qe->uuconf_pzargs, qcmds,
- (pointer) NULL,
- (uuconf_cmdtabfn) NULL, 0,
- (pointer) NULL);
- if (UUCONF_ERROR_VALUE (iuuconf) != UUCONF_SUCCESS)
- {
- ulog (LOG_ERROR, "Error in %c protocol parameters",
- bproto);
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- }
- }
-
- break;
- }
- }
-}
-
-/* Send a string to the other system beginning with a DLE
- character and terminated with a null byte. This is only
- used when no protocol is in force. */
-
-static boolean
-fsend_uucp_cmd (qconn, z)
- struct sconnection *qconn;
- const char *z;
-{
- size_t cwrite;
- char *zalc;
- boolean fret;
-
- DEBUG_MESSAGE1 (DEBUG_HANDSHAKE, "fsend_uucp_cmd: Sending \"%s\"", z);
-
- cwrite = strlen (z) + 2;
-
- zalc = zbufalc (cwrite);
- zalc[0] = '\020';
- memcpy (zalc + 1, z, cwrite - 1);
-
- fret = fconn_write (qconn, zalc, cwrite);
- ubuffree (zalc);
- return fret;
-}
-
-/* Get a UUCP command beginning with a DLE character and ending with a
- null byte. This is only used when no protocol is in force. This
- implementation has the potential of being seriously slow. It also
- doesn't have any real error recovery. The frequired argument is
- passed as TRUE if we need the string; we don't care that much if
- we're closing down the connection anyhow. */
-
-#define CTIMEOUT (120)
-#define CSHORTTIMEOUT (10)
-#define CINCREMENT (100)
-
-static char *
-zget_uucp_cmd (qconn, frequired, fstrip)
- struct sconnection *qconn;
- boolean frequired;
- boolean fstrip;
-{
- char *zalc;
- size_t calc;
- size_t cgot;
- boolean fintro;
- long iendtime;
- int ctimeout;
-#if DEBUG > 1
- int cchars;
- int iolddebug;
-#endif
-
- iendtime = ixsysdep_time ((long *) NULL);
- if (frequired)
- iendtime += CTIMEOUT;
- else
- iendtime += CSHORTTIMEOUT;
-
-#if DEBUG > 1
- cchars = 0;
- iolddebug = iDebug;
- if (FDEBUGGING (DEBUG_HANDSHAKE))
- {
- ulog (LOG_DEBUG_START, "zget_uucp_cmd: Got \"");
- iDebug &=~ (DEBUG_INCOMING | DEBUG_PORT);
- }
-#endif
-
- zalc = NULL;
- calc = 0;
- cgot = 0;
- fintro = FALSE;
- while ((ctimeout = (int) (iendtime - ixsysdep_time ((long *) NULL))) > 0)
- {
- int b;
-
- b = breceive_char (qconn, ctimeout, frequired);
- /* Now b == -1 on timeout, -2 on error. */
- if (b < 0)
- {
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_HANDSHAKE))
- {
- ulog (LOG_DEBUG_END, "\" (%s)",
- b == -1 ? "timeout" : "error");
- iDebug = iolddebug;
- }
-#endif
- if (b == -1 && frequired)
- ulog (LOG_ERROR, "Timeout");
- ubuffree (zalc);
- return NULL;
- }
-
- /* Apparently some systems use parity on these strings, so we
- optionally strip the parity bit. */
- if (fstrip)
- b &= 0x7f;
-
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_HANDSHAKE))
- {
- char ab[5];
-
- ++cchars;
- if (cchars > 60)
- {
- ulog (LOG_DEBUG_END, "\"");
- ulog (LOG_DEBUG_START, "zget_uucp_cmd: Got \"");
- cchars = 0;
- }
- (void) cdebug_char (ab, b);
- ulog (LOG_DEBUG_CONTINUE, "%s", ab);
- }
-#endif
-
- if (! fintro)
- {
- if (b == '\020')
- fintro = TRUE;
- continue;
- }
-
- /* If we see another DLE, something has gone wrong; continue
- as though this were the first one we saw. */
- if (b == '\020')
- {
- cgot = 0;
- continue;
- }
-
- /* Some systems send a trailing \n on the Shere line. As far as
- I can tell this line can never contain a \n, so this
- modification should be safe enough. */
- if (b == '\r' || b == '\n')
- b = '\0';
-
- if (cgot >= calc)
- {
- char *znew;
-
- calc += CINCREMENT;
- znew = zbufalc (calc);
- if (cgot > 0)
- memcpy (znew, zalc, cgot);
- ubuffree (zalc);
- zalc = znew;
- }
-
- zalc[cgot] = (char) b;
- ++cgot;
-
- if (b == '\0')
- {
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_HANDSHAKE))
- {
- ulog (LOG_DEBUG_END, "\"");
- iDebug = iolddebug;
- }
-#endif
- return zalc;
- }
- }
-
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_HANDSHAKE))
- {
- ulog (LOG_DEBUG_END, "\" (timeout)");
- iDebug = iolddebug;
- }
-#endif
-
- ubuffree (zalc);
-
- if (frequired)
- ulog (LOG_ERROR, "Timeout");
- return NULL;
-}
-
-/* Read a sequence of characters up to a newline or carriage return,
- and return the line without the line terminating character.
- Remember whether the last string we returned ended in \r; if it
- did, ignore a leading \n to account for \r\n pairs. */
-
-static char *
-zget_typed_line (qconn, fstrip)
- struct sconnection *qconn;
- boolean fstrip;
-{
- static boolean flastcr;
- char *zalc;
- size_t calc;
- size_t cgot;
-
-#if DEBUG > 1
- int cchars;
- int iolddebug;
-
- cchars = 0;
- iolddebug = iDebug;
- if (FDEBUGGING (DEBUG_CHAT))
- {
- ulog (LOG_DEBUG_START, "zget_typed_line: Got \"");
- iDebug &=~ (DEBUG_INCOMING | DEBUG_PORT);
- }
-#endif
-
- zalc = NULL;
- calc = 0;
- cgot = 0;
- while (TRUE)
- {
- int b;
-
- b = breceive_char (qconn, CTIMEOUT, FALSE);
-
- /* Now b == -1 on timeout, -2 on error. */
-
- if (b == -2 || FGOT_SIGNAL ())
- {
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_CHAT))
- {
- ulog (LOG_DEBUG_END, "\" (error)");
- iDebug = iolddebug;
- }
-#endif
- ubuffree (zalc);
- flastcr = FALSE;
- return NULL;
- }
-
- if (b == -1)
- {
- flastcr = FALSE;
- continue;
- }
-
- /* Optionally strip the parity bit. */
- if (fstrip)
- b &= 0x7f;
-
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_CHAT))
- {
- char ab[5];
-
- ++cchars;
- if (cchars > 60)
- {
- ulog (LOG_DEBUG_END, "\"");
- ulog (LOG_DEBUG_START, "zget_typed_line: Got \"");
- cchars = 0;
- }
- (void) cdebug_char (ab, b);
- ulog (LOG_DEBUG_CONTINUE, "%s", ab);
- }
-#endif
-
- if (b == '\n' && cgot == 0 && flastcr)
- {
- /* Ignore \n in \r\n pair. */
- flastcr = FALSE;
- continue;
- }
-
- flastcr = FALSE;
-
- if (cgot >= calc)
- {
- char *znew;
-
- calc += CINCREMENT;
- znew = zbufalc (calc);
- if (cgot > 0)
- memcpy (znew, zalc, cgot);
- ubuffree (zalc);
- zalc = znew;
- }
-
- if (b == '\n')
- b = '\0';
- else if (b == '\r')
- {
- flastcr = TRUE;
- b = '\0';
- }
-
- zalc[cgot] = (char) b;
- ++cgot;
-
- if (b == '\0')
- {
-#if DEBUG > 1
- if (FDEBUGGING (DEBUG_CHAT))
- {
- ulog (LOG_DEBUG_END, "\"");
- iDebug = iolddebug;
- }
-#endif
- return zalc;
- }
- }
-}
-
-/* Spawn a uuxqt job. This probably belongs in some other file, but I
- don't have a good place for it. */
-
-boolean
-fspawn_uuxqt (ffork, zsys, zconfig)
- boolean ffork;
- const char *zsys;
- const char *zconfig;
-{
- char *zsysarg;
- char *zconfigarg;
- boolean fret;
-
- if (zsys == NULL)
- zsysarg = NULL;
- else
- {
- zsysarg = zbufalc (sizeof "-s" + strlen (zsys));
- sprintf (zsysarg, "-s%s", zsys);
- }
-
- if (zconfig == NULL)
- zconfigarg = NULL;
- else
- {
- zconfigarg = zbufalc (sizeof "-I" + strlen (zconfig));
- sprintf (zconfigarg, "-I%s", zconfig);
- if (zsysarg == NULL)
- {
- zsysarg = zconfigarg;
- zconfigarg = NULL;
- }
- }
-
- fret = fsysdep_run (ffork, "uuxqt", zsysarg, zconfigarg);
-
- ubuffree (zsysarg);
- ubuffree (zconfigarg);
-
- return fret;
-}
diff --git a/gnu/libexec/uucp/uucico/xcmd.c b/gnu/libexec/uucp/uucico/xcmd.c
deleted file mode 100644
index 18ad39a..0000000
--- a/gnu/libexec/uucp/uucico/xcmd.c
+++ /dev/null
@@ -1,401 +0,0 @@
-/* xcmd.c
- Routines to handle work requests.
-
- Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char xcmd_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "prot.h"
-#include "trans.h"
-
-/* Local functions. */
-
-static boolean flocal_xcmd_request P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-static boolean flocal_xcmd_await_reply P((struct stransfer *qtrans,
- struct sdaemon *qdaemon,
- const char *zdata, size_t cdata));
-static boolean fremote_xcmd_reply P((struct stransfer *qtrans,
- struct sdaemon *qdaemon));
-
-/* Handle a local work request. We just set up the request for
- transmission. */
-
-boolean
-flocal_xcmd_init (qdaemon, qcmd)
- struct sdaemon *qdaemon;
- struct scmd *qcmd;
-{
- struct stransfer *qtrans;
-
- qtrans = qtransalc (qcmd);
- qtrans->psendfn = flocal_xcmd_request;
-
- return fqueue_local (qdaemon, qtrans);
-}
-
-/* Send the execution request to the remote system. */
-
-static boolean
-flocal_xcmd_request (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- size_t clen;
- char *zsend;
- boolean fret;
-
- ulog (LOG_NORMAL, "Requesting work: %s to %s", qtrans->s.zfrom,
- qtrans->s.zto);
-
-
- qtrans->fcmd = TRUE;
- qtrans->precfn = flocal_xcmd_await_reply;
-
- if (! fqueue_receive (qdaemon, qtrans))
- return FALSE;
-
- /* We send the string
- X from to user options
- We put a dash in front of options. */
- clen = (strlen (qtrans->s.zfrom) + strlen (qtrans->s.zto)
- + strlen (qtrans->s.zuser) + strlen (qtrans->s.zoptions) + 7);
- zsend = zbufalc (clen);
- sprintf (zsend, "X %s %s %s -%s", qtrans->s.zfrom, qtrans->s.zto,
- qtrans->s.zuser, qtrans->s.zoptions);
-
- fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, qtrans->ilocal,
- qtrans->iremote);
- ubuffree (zsend);
-
- /* If fret is FALSE, we should free qtrans here, but see the comment
- at the end of flocal_rec_send_request. */
-
- return fret;
-}
-
-/* Get a reply to an execution request from the remote system. */
-
-/*ARGSUSED*/
-static boolean
-flocal_xcmd_await_reply (qtrans, qdaemon, zdata, cdata)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
- const char *zdata;
- size_t cdata;
-{
- qtrans->precfn = NULL;
-
- if (zdata[0] != 'X'
- || (zdata[1] != 'Y' && zdata[1] != 'N'))
- {
- ulog (LOG_ERROR, "Bad response to work request");
- utransfree (qtrans);
- return FALSE;
- }
-
- if (zdata[1] == 'N')
- {
- ulog (LOG_ERROR, "%s: work request denied", qtrans->s.zfrom);
- (void) fmail_transfer (FALSE, qtrans->s.zuser, (const char *) NULL,
- "work request denied",
- qtrans->s.zfrom, qdaemon->qsys->uuconf_zname,
- qtrans->s.zto, (const char *) NULL,
- (const char *) NULL);
- }
-
- (void) fsysdep_did_work (qtrans->s.pseq);
- utransfree (qtrans);
-
- return TRUE;
-}
-
-/* Handle a remote work request. This just queues up the requests for
- later processing. */
-
-boolean
-fremote_xcmd_init (qdaemon, qcmd, iremote)
- struct sdaemon *qdaemon;
- struct scmd *qcmd;
- int iremote;
-{
- const struct uuconf_system *qsys;
- const char *zexclam;
- const struct uuconf_system *qdestsys;
- struct uuconf_system sdestsys;
- char *zdestfile;
- boolean fmkdirs;
- struct stransfer *qtrans;
- char *zuser;
- char aboptions[5];
- char *zfrom;
- boolean fret;
- char *zfile;
-
- ulog (LOG_NORMAL, "Work requested: %s to %s", qcmd->zfrom,
- qcmd->zto);
-
- qsys = qdaemon->qsys;
-
- zexclam = strchr (qcmd->zto, '!');
- if (zexclam == NULL
- || zexclam == qcmd->zto
- || strncmp (qdaemon->zlocalname, qcmd->zto,
- (size_t) (zexclam - qcmd->zto)) == 0)
- {
- const char *zconst;
-
- /* The files are supposed to be copied to the local system. */
- qdestsys = NULL;
- if (zexclam == NULL)
- zconst = qcmd->zto;
- else
- zconst = zexclam + 1;
-
- zdestfile = zsysdep_local_file (zconst, qsys->uuconf_zpubdir,
- (boolean *) NULL);
- if (zdestfile == NULL)
- return FALSE;
-
- zuser = NULL;
- fmkdirs = strchr (qcmd->zoptions, 'f') != NULL;
- }
- else
- {
- size_t clen;
- char *zcopy;
- int iuuconf;
- char *zoptions;
-
- clen = zexclam - qcmd->zto;
- zcopy = zbufalc (clen + 1);
- memcpy (zcopy, qcmd->zto, clen);
- zcopy[clen] = '\0';
-
- iuuconf = uuconf_system_info (qdaemon->puuconf, zcopy, &sdestsys);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- if (! funknown_system (qdaemon->puuconf, zcopy, &sdestsys))
- {
- ulog (LOG_ERROR, "%s: System not found", zcopy);
- ubuffree (zcopy);
- qtrans = qtransalc (qcmd);
- qtrans->psendfn = fremote_xcmd_reply;
- qtrans->pinfo = (pointer) "XN";
- qtrans->iremote = iremote;
- return fqueue_remote (qdaemon, qtrans);
- }
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, qdaemon->puuconf, iuuconf);
- ubuffree (zcopy);
- return FALSE;
- }
-
- ubuffree (zcopy);
-
- qdestsys = &sdestsys;
- zdestfile = zbufcpy (zexclam + 1);
-
- zuser = zbufalc (strlen (qdestsys->uuconf_zname)
- + strlen (qcmd->zuser) + sizeof "!");
- sprintf (zuser, "%s!%s", qdestsys->uuconf_zname, qcmd->zuser);
- zoptions = aboptions;
- *zoptions++ = 'C';
- if (strchr (qcmd->zoptions, 'd') != NULL)
- *zoptions++ = 'd';
- if (strchr (qcmd->zoptions, 'm') != NULL)
- *zoptions++ = 'm';
- *zoptions = '\0';
- fmkdirs = TRUE;
- }
-
- /* At this point we prepare to confirm the remote request. We could
- actually fork here and let the child spool up the requests. */
- qtrans = qtransalc (qcmd);
- qtrans->psendfn = fremote_xcmd_reply;
- qtrans->pinfo = (pointer) "XY";
- qtrans->iremote = iremote;
- if (! fqueue_remote (qdaemon, qtrans))
- {
- ubuffree (zdestfile);
- ubuffree (zuser);
- return FALSE;
- }
-
- /* Now we have to process each source file. The source
- specification may or may use wildcards. */
- zfrom = zsysdep_local_file (qcmd->zfrom, qsys->uuconf_zpubdir,
- (boolean *) NULL);
- if (zfrom == NULL)
- {
- ubuffree (zdestfile);
- ubuffree (zuser);
- return FALSE;
- }
-
- if (! fsysdep_wildcard_start (zfrom))
- {
- ubuffree (zfrom);
- ubuffree (zdestfile);
- ubuffree (zuser);
- return FALSE;
- }
-
- fret = TRUE;
-
- while ((zfile = zsysdep_wildcard (zfrom)) != NULL)
- {
- char *zto;
- char abtname[CFILE_NAME_LEN];
-
- if (! fsysdep_file_exists (zfile))
- {
- ulog (LOG_ERROR, "%s: no such file", zfile);
- continue;
- }
-
- /* Make sure the remote system is permitted to read the
- specified file. */
- if (! fin_directory_list (zfile, qsys->uuconf_pzremote_send,
- qsys->uuconf_zpubdir, TRUE, TRUE,
- (const char *) NULL))
- {
- ulog (LOG_ERROR, "%s: not permitted to send", zfile);
- break;
- }
-
- if (qdestsys != NULL)
- {
- /* We really should get the original grade here. */
- zto = zsysdep_data_file_name (qdestsys, qdaemon->zlocalname,
- BDEFAULT_UUCP_GRADE, FALSE,
- abtname, (char *) NULL,
- (char *) NULL);
- if (zto == NULL)
- {
- fret = FALSE;
- break;
- }
- }
- else
- {
- zto = zsysdep_add_base (zdestfile, zfile);
- if (zto == NULL)
- {
- fret = FALSE;
- break;
- }
- /* We only accept a local destination if the remote system
- has the right to create files there. */
- if (! fin_directory_list (zto, qsys->uuconf_pzremote_receive,
- qsys->uuconf_zpubdir, TRUE, FALSE,
- (const char *) NULL))
- {
- ulog (LOG_ERROR, "%s: not permitted to receive", zto);
- ubuffree (zto);
- break;
- }
- }
-
- /* Copy the file either to the final destination or to the
- spool directory. */
- if (! fcopy_file (zfile, zto, qdestsys == NULL, fmkdirs, FALSE))
- {
- ubuffree (zto);
- break;
- }
-
- ubuffree (zto);
-
- /* If there is a destination system, queue it up. */
- if (qdestsys != NULL)
- {
- struct scmd ssend;
- char *zjobid;
-
- ssend.bcmd = 'S';
- ssend.bgrade = BDEFAULT_UUCP_GRADE;
- ssend.pseq = NULL;
- ssend.zfrom = zfile;
- ssend.zto = zdestfile;
- ssend.zuser = zuser;
- ssend.zoptions = aboptions;
- ssend.ztemp = abtname;
- ssend.imode = ixsysdep_file_mode (zfile);
- ssend.znotify = "";
- ssend.cbytes = -1;
- ssend.zcmd = NULL;
- ssend.ipos = 0;
-
- zjobid = zsysdep_spool_commands (qdestsys, BDEFAULT_UUCP_GRADE,
- 1, &ssend);
- if (zjobid == NULL)
- break;
- ubuffree (zjobid);
- }
-
- ubuffree (zfile);
- }
-
- if (zfile != NULL)
- ubuffree (zfile);
-
- (void) fsysdep_wildcard_end ();
-
- ubuffree (zdestfile);
- if (qdestsys != NULL)
- (void) uuconf_system_free (qdaemon->puuconf, &sdestsys);
-
- ubuffree (zfrom);
- ubuffree (zuser);
-
- return fret;
-}
-
-/* Reply to a remote work request. */
-
-static boolean
-fremote_xcmd_reply (qtrans, qdaemon)
- struct stransfer *qtrans;
- struct sdaemon *qdaemon;
-{
- boolean fret;
-
- fret = (*qdaemon->qproto->pfsendcmd) (qdaemon,
- (const char *) qtrans->pinfo,
- qtrans->ilocal,
- qtrans->iremote);
- utransfree (qtrans);
- return fret;
-}
diff --git a/gnu/libexec/uucp/uuconv/Makefile b/gnu/libexec/uucp/uuconv/Makefile
deleted file mode 100644
index 808ad86..0000000
--- a/gnu/libexec/uucp/uuconv/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# Makefile for uuconv
-# $Id: Makefile,v 1.7 1997/02/22 15:28:37 peter Exp $
-
-BINDIR= $(sbindir)
-
-PROG= uuconv
-SRCS= uuconv.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -I$(.CURDIR)/../libuuconf\
- -DVERSION=\"$(VERSION)\"
-
-.include <bsd.prog.mk>
diff --git a/gnu/libexec/uucp/uuconv/uuconv.1 b/gnu/libexec/uucp/uuconv/uuconv.1
deleted file mode 100644
index b95c9e1..0000000
--- a/gnu/libexec/uucp/uuconv/uuconv.1
+++ /dev/null
@@ -1,57 +0,0 @@
-''' $Id: uustat.1,v 1.8 1997/02/22 15:28:49 peter Exp $
-.TH uuconv 1 "Taylor UUCP 1.06"
-.SH NAME
-uuconv \- convert UUCP configuration files
-.SH SYNOPSIS
-.B uuconv
-\-i type \-o type [-p program] [standard UUCP options]
-.SH DESCRIPTION
-The
-.B uuconv
-program can be used to convert UUCP configuration
-files from one format to another. This can be useful for
-administrators converting from an older UUCP package. Taylor UUCP
-is able to read and use old configuration file formats, but some
-new features can not be selected using the old formats.
-.PP
-The type of configuration file to read is specified
-using the `-i' or `--input' options. The type of configuration file to
-write is specified using the `-o' or `--output' options.
-.PP
-The supported configuration file types are `taylor', `v2', and
-`hdb'. For a description of the `taylor' configuration files, see
-*Note Configuration Files::. The other types of configuration files
-are used by traditional UUCP packages, and are not described in this
-manual.
-.PP
-An input configuration of type `v2' or `hdb' is read from a compiled
-in directory (specified by `oldconfigdir' in `Makefile'). An input
-configuration of type `taylor' is read from a compiled in directory by
-default, but may be overridden with the standard `-I' or `--config'
-options.
-.PP
-The output configuration is written to files in the directory in
-which
-.B uuconv
-is run.
-.PP
-Some information in the input files may not be representable in the
-desired output format, in which case
-.B uuconv
-will silently discard it.
-The output of
-.B uuconv
-should be carefully checked before it is used.
-The
-.B uuchk(8)
-program may be used for this purpose.
-.PP
-The `-p' or `--program' option may be used to convert specific `cu'
-configuration information, rather than the default of only converting
-the `uucp' configuration information.
-.SH SEE ALSO
-cu(1), uucp(1)
-.SH AUTHOR
-Ian Lance Taylor (ian@airs.com).
-This Manpage based on the Taylor UUCP 1.06 Texinfo documentation.
-
diff --git a/gnu/libexec/uucp/uuconv/uuconv.c b/gnu/libexec/uucp/uuconv/uuconv.c
deleted file mode 100644
index fa2d01e..0000000
--- a/gnu/libexec/uucp/uuconv/uuconv.c
+++ /dev/null
@@ -1,2106 +0,0 @@
-/* uuconv.c
- Convert one type of UUCP configuration file to another.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucnfi.h"
-
-#if USE_RCS_ID
-const char uuconv_rcsid[] = "$Id$";
-#endif
-
-#include "getopt.h"
-
-/* Local functions. */
-
-static void uvusage P((void));
-static void uvhelp P((void));
-static void uvwrite_time P((FILE *e, struct uuconf_timespan *qtime));
-static void uvwrite_string P((FILE *e, const char *zarg, const char *zcmd));
-static void uvwrite_size P((FILE *e, struct uuconf_timespan *qsize,
- const char *zcmd));
-static void uvwrite_boolean P((FILE *e, int iarg, const char *zcmd));
-static void uvwrite_string_array P((FILE *e, char **pz, const char *zcmd));
-static void uvwrite_chat_script P((FILE *e, char **pz));
-static void uvwrite_chat P((FILE *e, const struct uuconf_chat *qchat,
- const struct uuconf_chat *qlast,
- const char *zprefix, boolean fforce));
-static void uvwrite_proto_params P((FILE *e,
- const struct uuconf_proto_param *qparam,
- const char *zprefix));
-static void uvwrite_taylor_system P((FILE *e,
- const struct uuconf_system *qsys));
-static void uvwrite_v2_system P((FILE *e,
- const struct uuconf_system *qsys));
-static void uvwrite_hdb_system P((FILE *e,
- const struct uuconf_system *qsys));
-static boolean fvperm_string_cmp P((const char *z1, const char *z2));
-static boolean fvperm_array_cmp P((const char **pz1, const char **pz2));
-static void uvadd_perm P((struct shpermissions *qadd));
-static void uvwrite_perms P((void));
-static void uvwrite_perm_array P((FILE *e, const char **pz,
- const char *zcmd, size_t *pccol));
-static void uvwrite_perm_boolean P((FILE *e, int f, const char *zcmd,
- size_t *pccol, boolean fsendfiles));
-static void uvwrite_perm_rw_array P((FILE *e, const char **pz,
- const char *zcmd, size_t *pccol));
-static void uvwrite_perm_string P((FILE *e, const char *z, const char *zcmd,
- size_t *pccol));
-static int ivwrite_taylor_port P((struct uuconf_port *qport,
- pointer pinfo));
-static int ivwrite_v2_port P((struct uuconf_port *qport, pointer pinfo));
-static int ivwrite_hdb_port P((struct uuconf_port *qport, pointer pinfo));
-static void uvwrite_taylor_port P((FILE *e, struct uuconf_port *qport,
- const char *zprefix));
-static void uvwrite_taylor_dialer P((FILE *e, struct uuconf_dialer *qdialer,
- const char *zprefix));
-static void uvwrite_hdb_dialer P((FILE *e, struct uuconf_dialer *qdialer));
-static void uvuuconf_error P((pointer puuconf, int iret));
-
-/* The program name. */
-const char *zProgram;
-
-/* A list of Permissions entries built when writing out HDB system
- information. */
-static struct shpermissions *qVperms;
-
-/* Type of configuration file. */
-enum tconfig
-{
- CONFIG_TAYLOR,
- CONFIG_V2,
- CONFIG_HDB
-};
-
-/* Long getopt options. */
-static const struct option asVlongopts[] =
-{
- { "input", required_argument, NULL, 'i' },
- { "output", required_argument, NULL, 'o' },
- { "program", required_argument, NULL, 'p' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'x' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- /* -I: The configuration file name. */
- const char *zconfig = NULL;
- /* -i: Input type. */
- const char *zinput = NULL;
- /* -o: Output type. */
- const char *zoutput = NULL;
- /* -p: Program name. */
- const char *zprogram = NULL;
- int iopt;
- enum tconfig tinput, toutput;
- int iret;
- pointer pinput;
-
- zProgram = argv[0];
-
- while ((iopt = getopt_long (argc, argv, "i:I:o:p:vx:", asVlongopts,
- (int *) NULL)) != EOF)
- {
- switch (iopt)
- {
- case 'i':
- /* Input type. */
- zinput = optarg;
- break;
-
- case 'o':
- /* Output type. */
- zoutput = optarg;
- break;
-
- case 'p':
- /* Program name. */
- zprogram = optarg;
- break;
-
- case 'I':
- /* Set the configuration file name. */
- zconfig = optarg;
- break;
-
- case 'x':
- /* Set the debugging level. */
- break;
-
- case 'v':
- /* Print version and exit. */
- fprintf
- (stderr,
- "%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zProgram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 1:
- /* --help. */
- uvhelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found, and flag value set. */
- break;
-
- default:
- uvusage ();
- break;
- }
- }
-
- if (optind != argc
- || zinput == NULL
- || zoutput == NULL)
- uvusage ();
-
- if (strcasecmp (zinput, "taylor") == 0)
- tinput = CONFIG_TAYLOR;
- else if (strcasecmp (zinput, "v2") == 0)
- tinput = CONFIG_V2;
- else if (strcasecmp (zinput, "hdb") == 0)
- tinput = CONFIG_HDB;
- else
- {
- uvusage ();
- tinput = CONFIG_TAYLOR;
- }
-
- if (strcasecmp (zoutput, "taylor") == 0)
- toutput = CONFIG_TAYLOR;
- else if (strcasecmp (zoutput, "v2") == 0)
- toutput = CONFIG_V2;
- else if (strcasecmp (zoutput, "hdb") == 0)
- toutput = CONFIG_HDB;
- else
- {
- uvusage ();
- toutput = CONFIG_TAYLOR;
- }
-
- if (tinput == toutput)
- uvusage ();
-
- iret = UUCONF_SUCCESS;
-
- /* Initialize the input. */
- pinput = NULL;
- switch (tinput)
- {
- case CONFIG_TAYLOR:
- iret = uuconf_taylor_init (&pinput, zprogram, zconfig);
- break;
- case CONFIG_V2:
- iret = uuconf_v2_init (&pinput);
- break;
- case CONFIG_HDB:
- iret = uuconf_hdb_init (&pinput, zprogram);
- break;
- }
- if (iret != UUCONF_SUCCESS)
- {
- uvuuconf_error (pinput, iret);
- exit (EXIT_FAILURE);
- }
-
- {
- char **pzsystems;
- char *zsys;
- char abtaylor[sizeof ZCURDIR + sizeof SYSFILE - 1];
- char abv2[sizeof ZCURDIR + sizeof V2_SYSTEMS - 1];
- char abhdb[sizeof ZCURDIR + sizeof HDB_SYSTEMS - 1];
- FILE *esys;
- char **pz;
-
- /* Get the list of systems. */
- switch (tinput)
- {
- case CONFIG_TAYLOR:
- iret = uuconf_taylor_system_names (pinput, &pzsystems, FALSE);
- break;
- case CONFIG_V2:
- iret = uuconf_v2_system_names (pinput, &pzsystems, FALSE);
- break;
- case CONFIG_HDB:
- iret = uuconf_hdb_system_names (pinput, &pzsystems, FALSE);
- break;
- }
- if (iret != UUCONF_SUCCESS)
- uvuuconf_error (pinput, iret);
- else
- {
- /* Open the sys file for the output type. */
- switch (toutput)
- {
- default:
- case CONFIG_TAYLOR:
- sprintf (abtaylor, "%s%s", ZCURDIR, SYSFILE);
- zsys = abtaylor;
- break;
- case CONFIG_V2:
- sprintf (abv2, "%s%s", ZCURDIR, V2_SYSTEMS);
- zsys = abv2;
- break;
- case CONFIG_HDB:
- sprintf (abhdb, "%s%s", ZCURDIR, HDB_SYSTEMS);
- zsys = abhdb;
- break;
- }
- esys = fopen (zsys, "w");
- if (esys == NULL)
- {
- fprintf (stderr, "uuchk:%s: ", zsys);
- perror ("fopen");
- exit (EXIT_FAILURE);
- }
-
- fprintf (esys, "# %s file automatically generated by uuconv.\n",
- zsys);
-
- /* Read and write each system. We cheat and call the internal
- routines, so that we can easily detect default information and
- not write it out. This isn't necessary, but it makes the output
- smaller and simpler. */
- for (pz = pzsystems; *pz != NULL; pz++)
- {
- struct uuconf_system ssys;
-
- switch (tinput)
- {
- case CONFIG_TAYLOR:
- iret = _uuconf_itaylor_system_internal (pinput, *pz, &ssys);
- break;
- case CONFIG_V2:
- iret = _uuconf_iv2_system_internal (pinput, *pz, &ssys);
- break;
- case CONFIG_HDB:
- iret = _uuconf_ihdb_system_internal (pinput, *pz, &ssys);
- break;
- }
- if (iret != UUCONF_SUCCESS)
- uvuuconf_error (pinput, iret);
- else
- {
- switch (toutput)
- {
- case CONFIG_TAYLOR:
- uvwrite_taylor_system (esys, &ssys);
- break;
- case CONFIG_V2:
- uvwrite_v2_system (esys, &ssys);
- break;
- case CONFIG_HDB:
- uvwrite_hdb_system (esys, &ssys);
- break;
- }
- if (toutput != CONFIG_HDB)
- (void) uuconf_system_free (pinput, &ssys);
- }
- }
-
- if (toutput == CONFIG_HDB)
- uvwrite_perms ();
-
- if (ferror (esys)
- || fclose (esys) == EOF)
- {
- fprintf (stderr, "uuchk:%s: error during output\n", zsys);
- exit (EXIT_FAILURE);
- }
- }
- }
-
- {
- /* Open the port file for the output type. */
- char *zport;
- char abtaylor[sizeof ZCURDIR + sizeof PORTFILE - 1];
- char abv2[sizeof ZCURDIR + sizeof V2_DEVICES - 1];
- char abhdb[sizeof ZCURDIR + sizeof HDB_DEVICES - 1];
- FILE *eport;
- int (*piportfn) P((struct uuconf_port *, pointer));
- struct uuconf_port sport;
-
- switch (toutput)
- {
- default:
- case CONFIG_TAYLOR:
- sprintf (abtaylor, "%s%s", ZCURDIR, PORTFILE);
- zport = abtaylor;
- piportfn = ivwrite_taylor_port;
- break;
- case CONFIG_V2:
- sprintf (abv2, "%s%s", ZCURDIR, V2_DEVICES);
- zport = abv2;
- piportfn = ivwrite_v2_port;
- break;
- case CONFIG_HDB:
- sprintf (abhdb, "%s%s", ZCURDIR, HDB_DEVICES);
- zport = abhdb;
- piportfn = ivwrite_hdb_port;
- break;
- }
- eport = fopen (zport, "w");
- if (eport == NULL)
- {
- fprintf (stderr, "uuchk:%s: ", zport);
- perror ("fopen");
- exit (EXIT_FAILURE);
- }
-
- fprintf (eport, "# %s file automatically generated by uuconv.\n", zport);
-
- switch (tinput)
- {
- case CONFIG_TAYLOR:
- iret = uuconf_taylor_find_port (pinput, (const char *) NULL, 0L,
- 0L, piportfn, (pointer) eport,
- &sport);
- break;
- case CONFIG_V2:
- iret = uuconf_v2_find_port (pinput, (const char *) NULL, 0L, 0L,
- piportfn, (pointer) eport, &sport);
- break;
- case CONFIG_HDB:
- iret = uuconf_hdb_find_port (pinput, (const char *) NULL, 0L, 0L,
- piportfn, (pointer) eport, &sport);
- break;
- }
-
- if (iret != UUCONF_NOT_FOUND)
- uvuuconf_error (pinput, iret);
-
- if (ferror (eport)
- || fclose (eport) == EOF)
- {
- fprintf (stderr, "uuchk:%s: error during output\n", zport);
- exit (EXIT_FAILURE);
- }
- }
-
- /* V2 configuration files don't support dialers. */
- if (tinput != CONFIG_V2 && toutput != CONFIG_V2)
- {
- char **pzdialers;
- char *zdialer;
- char abtaylor[sizeof ZCURDIR + sizeof DIALFILE - 1];
- char abhdb[sizeof ZCURDIR + sizeof HDB_DIALERS - 1];
- FILE *edialer;
- char **pz;
-
- /* Get the list of dialers. */
- switch (tinput)
- {
- default:
- case CONFIG_TAYLOR:
- iret = uuconf_taylor_dialer_names (pinput, &pzdialers);
- break;
- case CONFIG_HDB:
- iret = uuconf_hdb_dialer_names (pinput, &pzdialers);
- break;
- }
- if (iret != UUCONF_SUCCESS)
- uvuuconf_error (pinput, iret);
- else
- {
- /* Open the sys file for the output type. */
- switch (toutput)
- {
- default:
- case CONFIG_TAYLOR:
- sprintf (abtaylor, "%s%s", ZCURDIR, DIALFILE);
- zdialer = abtaylor;
- break;
- case CONFIG_HDB:
- sprintf (abhdb, "%s%s", ZCURDIR, HDB_DIALERS);
- zdialer = abhdb;
- break;
- }
- edialer = fopen (zdialer, "w");
- if (edialer == NULL)
- {
- fprintf (stderr, "uuchk:%s: ", zdialer);
- perror ("fopen");
- exit (EXIT_FAILURE);
- }
-
- fprintf (edialer, "# %s file automatically generated by uuconv.\n",
- zdialer);
-
- /* Read and write each dialer. */
- for (pz = pzdialers; *pz != NULL; pz++)
- {
- struct uuconf_dialer sdialer;
-
- switch (tinput)
- {
- default:
- case CONFIG_TAYLOR:
- iret = uuconf_taylor_dialer_info (pinput, *pz, &sdialer);
- break;
- case CONFIG_HDB:
- iret = uuconf_hdb_dialer_info (pinput, *pz, &sdialer);
- break;
- }
- if (iret != UUCONF_SUCCESS)
- uvuuconf_error (pinput, iret);
- else
- {
- switch (toutput)
- {
- default:
- case CONFIG_TAYLOR:
- fprintf (edialer, "# Start of dialer %s\n",
- sdialer.uuconf_zname);
- fprintf (edialer, "dialer %s\n", sdialer.uuconf_zname);
- uvwrite_taylor_dialer (edialer, &sdialer, "");
- break;
- case CONFIG_HDB:
- uvwrite_hdb_dialer (edialer, &sdialer);
- break;
- }
- (void) uuconf_dialer_free (pinput, &sdialer);
- }
- }
-
- if (ferror (edialer)
- || fclose (edialer) == EOF)
- {
- fprintf (stderr, "uuchk:%s: error during output\n", zdialer);
- exit (EXIT_FAILURE);
- }
- }
- }
-
- exit (EXIT_SUCCESS);
-
- /* Avoid complaints about not returning. */
- return 0;
-}
-
-/* Print out a usage message and die. */
-
-static void
-uvusage ()
-{
- fprintf (stderr, "Usage: %s -i input-type -o output-type [-p program]\n",
- zProgram);
- fprintf (stderr, "Use %s --help for help\n", zProgram);
- exit (EXIT_FAILURE);
-}
-
-/* Print a help message. */
-
-static void
-uvhelp ()
-{
- fprintf (stderr,
- "Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- fprintf (stderr, "Converts UUCP configuration files from one format to another.\n");
- fprintf (stderr,
- "Usage: %s -i input -o output [-p program] [-I file]\n", zProgram);
- fprintf (stderr,
- " -i,--input input: Set input type (one of taylor, v2, hdb)\n");
- fprintf (stderr,
- " -o,--output output: Set output type (one of taylor, v2, hdb)\n");
- fprintf (stderr,
- " -p,--program program: Program to convert (e.g., uucp or cu)\n");
- fprintf (stderr,
- " -I,--config file: Set Taylor UUCP configuration file to use\n");
- fprintf (stderr,
- " -v,--version: Print version and exit\n");
- fprintf (stderr,
- " --help: Print help and exit\n");
-}
-
-/* Write out a timespan. */
-
-static void
-uvwrite_time (e, qtime)
- FILE *e;
- struct uuconf_timespan *qtime;
-{
- if (qtime == NULL)
- {
- fprintf (e, "Never");
- return;
- }
-
- if (qtime->uuconf_istart == 0 && qtime->uuconf_iend == 7 * 24 * 60)
- {
- fprintf (e, "Any");
- return;
- }
-
- for (; qtime != NULL; qtime = qtime->uuconf_qnext)
- {
- int idaystart, idayend;
- int ihourstart, ihourend;
- int iminutestart, iminuteend;
- const char * const zdays = "Su\0Mo\0Tu\0We\0Th\0Fr\0Sa";
-
- idaystart = qtime->uuconf_istart / (24 * 60);
- ihourstart = (qtime->uuconf_istart % (24 * 60)) / 60;
- iminutestart = qtime->uuconf_istart % 60;
- if (qtime->uuconf_iend >= 7 * 24 * 60)
- qtime->uuconf_iend = 7 * 24 * 60 - 1;
- idayend = qtime->uuconf_iend / (24 * 60);
- ihourend = (qtime->uuconf_iend % (24 * 60)) / 60;
- iminuteend = qtime->uuconf_iend % 60;
- if (ihourend == 0 && iminuteend == 0)
- --idayend;
-
- if (idaystart == idayend)
- fprintf (e, "%s%02d%02d-%02d%02d", zdays + idaystart * 3,
- ihourstart, iminutestart, ihourend, iminuteend);
- else
- {
- int i;
-
- fprintf (e, "%s%02d%02d-0000", zdays + idaystart * 3,
- ihourstart, iminutestart);
- for (i = idaystart + 1; i < idayend; i++)
- fprintf (e, ",%s", zdays + i * 3);
- if (ihourend != 0 || iminuteend != 0)
- fprintf (e, ",%s0000-%02d%02d", zdays + idayend * 3, ihourend,
- iminuteend);
- }
-
- if (qtime->uuconf_qnext != NULL)
- fprintf (e, ",");
- }
-}
-
-/* Some subroutines used when writing out Taylor UUCP configuration
- files. */
-
-/* Write a command with a string argument. */
-
-static void
-uvwrite_string (e, zarg, zcmd)
- FILE *e;
- const char *zarg;
- const char *zcmd;
-{
- if (zarg != (const char *) &_uuconf_unset)
- fprintf (e, "%s %s\n", zcmd, zarg == NULL ? (const char *) "" : zarg);
-}
-
-/* Write out a size restriction command. */
-
-static void
-uvwrite_size (e, qtime, zcmd)
- FILE *e;
- struct uuconf_timespan *qtime;
- const char *zcmd;
-{
- if (qtime != (struct uuconf_timespan *) &_uuconf_unset)
- {
- for (; qtime != NULL; qtime = qtime->uuconf_qnext)
- {
- fprintf (e, "%s %ld", zcmd, qtime->uuconf_ival);
- uvwrite_time (e, qtime);
- fprintf (e, "\n");
- }
- }
-}
-
-/* Write out a boolean argument with a string command. If the value
- is less than zero, than it was uninitialized and we don't write
- anything. */
-
-static void
-uvwrite_boolean (e, fval, zcmd)
- FILE *e;
- int fval;
- const char *zcmd;
-{
- if (fval >= 0)
- fprintf (e, "%s %s\n", zcmd, fval > 0 ? "true" : "false");
-}
-
-/* Write out a string array as a single command. */
-
-static void
-uvwrite_string_array (e, pz, zcmd)
- FILE *e;
- char **pz;
- const char *zcmd;
-{
- if (pz != (char **) &_uuconf_unset)
- {
- fprintf (e, "%s", zcmd);
- if (pz != NULL)
- for (; *pz != NULL; pz++)
- fprintf (e, " %s", *pz);
- fprintf (e, "\n");
- }
-}
-
-/* Write out a chat script. Don't separate subsend/subexpect strings
- by spaces. */
-
-static void
-uvwrite_chat_script (e, pzarg)
- FILE *e;
- char **pzarg;
-{
- char **pz;
-
- if (pzarg == NULL || pzarg == (char **) &_uuconf_unset)
- return;
-
- for (pz = pzarg; *pz != NULL; pz++)
- {
- if ((*pz)[0] != '-' && pz != pzarg)
- fprintf (e, " ");
- fprintf (e, *pz);
- }
-}
-
-/* Write out chat information. If the qlast argument is not NULL,
- then only values that are different from qlast should be written.
- The fforce argument is used to get around a peculiar problem: if
- the ``chat'' command is used with no arguments for a system, then
- uuconf_pzchat will be NULL (not &_uuconf_unset) and the default
- chat script will not be used. We must distinguish this case from
- the ``chat'' command not appearing at all for a port or dialer, in
- which case the value will again be NULL. In the former case we
- must output a ``chat'' command, in the latter case we would prefer
- not to. */
-
-static void
-uvwrite_chat (e, q, qlast, zprefix, fforce)
- FILE *e;
- const struct uuconf_chat *q;
- const struct uuconf_chat *qlast;
- const char *zprefix;
- boolean fforce;
-{
- char **pz;
- char ab[100];
-
- if (q->uuconf_pzchat != (char **) &_uuconf_unset
- && (qlast == NULL
- ? (fforce || q->uuconf_pzchat != NULL)
- : qlast->uuconf_pzchat != q->uuconf_pzchat))
- {
- fprintf (e, "%schat ", zprefix);
- uvwrite_chat_script (e, q->uuconf_pzchat);
- fprintf (e, "\n");
- }
-
- if (q->uuconf_pzprogram != (char **) &_uuconf_unset
- && (qlast == NULL
- ? q->uuconf_pzprogram != NULL
- : qlast->uuconf_pzprogram != q->uuconf_pzprogram))
- {
- sprintf (ab, "%schat-program", zprefix);
- uvwrite_string_array (e, q->uuconf_pzprogram, ab);
- }
-
- if (q->uuconf_ctimeout >= 0
- && (qlast == NULL
- || qlast->uuconf_ctimeout != q->uuconf_ctimeout))
- fprintf (e, "%schat-timeout %d\n", zprefix, q->uuconf_ctimeout);
-
- if (q->uuconf_pzfail != NULL
- && q->uuconf_pzfail != (char **) &_uuconf_unset
- && (qlast == NULL
- || qlast->uuconf_pzfail != q->uuconf_pzfail))
- for (pz = q->uuconf_pzfail; *pz != NULL; pz++)
- fprintf (e, "%schat-fail %s\n", zprefix, *pz);
-
- if (qlast == NULL || qlast->uuconf_fstrip != q->uuconf_fstrip)
- {
- sprintf (ab, "%schat-strip", zprefix);
- uvwrite_boolean (e, q->uuconf_fstrip, ab);
- }
-}
-
-/* Write out protocol parameters to a Taylor UUCP file. */
-
-static void
-uvwrite_proto_params (e, qparams, zprefix)
- FILE *e;
- const struct uuconf_proto_param *qparams;
- const char *zprefix;
-{
- const struct uuconf_proto_param *qp;
-
- if (qparams == NULL
- || qparams == (struct uuconf_proto_param *) &_uuconf_unset)
- return;
-
- for (qp = qparams; qp->uuconf_bproto != '\0'; qp++)
- {
- const struct uuconf_proto_param_entry *qe;
-
- for (qe = qp->uuconf_qentries; qe->uuconf_cargs > 0; qe++)
- {
- int i;
-
- fprintf (e, "%sprotocol-parameter %c", zprefix, qp->uuconf_bproto);
- for (i = 0; i < qe->uuconf_cargs; i++)
- fprintf (e, " %s", qe->uuconf_pzargs[i]);
- fprintf (e, "\n");
- }
- }
-}
-
-/* Write out Taylor UUCP system information. */
-
-static void
-uvwrite_taylor_system (e, q)
- FILE *e;
- const struct uuconf_system *q;
-{
- char **pz;
- const struct uuconf_system *qlast;
-
- fprintf (e, "# Start of system %s\n", q->uuconf_zname);
-
- fprintf (e, "system %s\n", q->uuconf_zname);
- if (q->uuconf_pzalias != NULL
- && q->uuconf_pzalias != (char **) &_uuconf_unset)
- for (pz = q->uuconf_pzalias; *pz != NULL; pz++)
- uvwrite_string (e, *pz, "alias");
-
- for (qlast = NULL; q != NULL; qlast = q, q = q->uuconf_qalternate)
- {
- struct uuconf_timespan *qtime;
-
- if (qlast != NULL)
- {
- fprintf (e, "alternate");
- if (q->uuconf_zalternate != (char *) &_uuconf_unset
- && q->uuconf_zalternate != NULL)
- fprintf (e, " %s", q->uuconf_zalternate);
- fprintf (e, "\n");
- }
-
-#define CHANGED(x) (qlast == NULL || qlast->x != q->x)
-
- if (CHANGED (uuconf_qtimegrade)
- && (q->uuconf_qtimegrade
- != (struct uuconf_timespan *) &_uuconf_unset))
- {
- if (q->uuconf_qtimegrade == NULL)
- fprintf (e, "time never\n");
- else
- {
- for (qtime = q->uuconf_qtimegrade;
- qtime != NULL;
- qtime = qtime->uuconf_qnext)
- {
- if ((char) qtime->uuconf_ival == UUCONF_GRADE_LOW)
- fprintf (e, "time ");
- else
- fprintf (e, "timegrade %c ", (char) qtime->uuconf_ival);
- uvwrite_time (e, qtime);
- if (qtime->uuconf_cretry != 0)
- fprintf (e, " %d", qtime->uuconf_cretry);
- fprintf (e, "\n");
- }
- }
- }
-
- if (CHANGED (uuconf_qcalltimegrade)
- && (q->uuconf_qcalltimegrade
- != (struct uuconf_timespan *) &_uuconf_unset))
- {
- for (qtime = q->uuconf_qcalltimegrade;
- qtime != NULL;
- qtime = qtime->uuconf_qnext)
- {
- fprintf (e, "call-timegrade %c ", (char) qtime->uuconf_ival);
- uvwrite_time (e, qtime);
- fprintf (e, "\n");
- }
- }
-
- if (CHANGED (uuconf_qcalledtimegrade)
- && (q->uuconf_qcalledtimegrade
- != (struct uuconf_timespan *) &_uuconf_unset))
- {
- for (qtime = q->uuconf_qcalledtimegrade;
- qtime != NULL;
- qtime = qtime->uuconf_qnext)
- {
- fprintf (e, "called-timegrade %c ", (char) qtime->uuconf_ival);
- uvwrite_time (e, qtime);
- fprintf (e, "\n");
- }
- }
-
- if (CHANGED (uuconf_qcall_local_size))
- uvwrite_size (e, q->uuconf_qcall_local_size, "call-local-size");
-
- if (CHANGED (uuconf_qcall_remote_size))
- uvwrite_size (e, q->uuconf_qcall_remote_size, "call-remote-size");
-
- if (CHANGED (uuconf_qcalled_local_size))
- uvwrite_size (e, q->uuconf_qcalled_local_size, "called-local-size");
-
- if (CHANGED (uuconf_qcalled_remote_size))
- uvwrite_size (e, q->uuconf_qcalled_remote_size, "called-remote-size");
-
- if (CHANGED (uuconf_ibaud) || CHANGED (uuconf_ihighbaud))
- {
- if (q->uuconf_ibaud >= 0)
- {
- if (q->uuconf_ihighbaud > 0)
- fprintf (e, "baud-range %ld %ld\n", q->uuconf_ibaud,
- q->uuconf_ihighbaud);
- else
- fprintf (e, "baud %ld\n", q->uuconf_ibaud);
- }
- }
-
- if (CHANGED (uuconf_zport) || CHANGED (uuconf_qport))
- {
- if (q->uuconf_zport != NULL
- && q->uuconf_zport != (char *) &_uuconf_unset)
- uvwrite_string (e, q->uuconf_zport, "port");
- else if (q->uuconf_qport != NULL
- && (q->uuconf_qport
- != (struct uuconf_port *) &_uuconf_unset))
- uvwrite_taylor_port (e, q->uuconf_qport, "port ");
- }
-
- if (CHANGED (uuconf_zphone))
- {
- const char *zcmd;
-
- if (q->uuconf_qport != NULL
- && q->uuconf_qport != (struct uuconf_port *) &_uuconf_unset
- && (q->uuconf_qport->uuconf_ttype == UUCONF_PORTTYPE_TCP
- || q->uuconf_qport->uuconf_ttype == UUCONF_PORTTYPE_TLI))
- zcmd = "address";
- else
- zcmd = "phone";
- uvwrite_string (e, q->uuconf_zphone, zcmd);
- }
-
- uvwrite_chat (e, &q->uuconf_schat,
- (qlast == NULL
- ? (struct uuconf_chat *) NULL
- : &qlast->uuconf_schat),
- "", TRUE);
-
- if (CHANGED (uuconf_zcall_login))
- uvwrite_string (e, q->uuconf_zcall_login, "call-login");
-
- if (CHANGED (uuconf_zcall_password))
- uvwrite_string (e, q->uuconf_zcall_password, "call-password");
-
- if (CHANGED (uuconf_zcalled_login))
- uvwrite_string (e, q->uuconf_zcalled_login, "called-login");
-
- if (CHANGED (uuconf_fcallback))
- uvwrite_boolean (e, q->uuconf_fcallback, "callback");
-
- if (CHANGED (uuconf_fsequence))
- uvwrite_boolean (e, q->uuconf_fsequence, "sequence");
-
- if (CHANGED (uuconf_zprotocols))
- uvwrite_string (e, q->uuconf_zprotocols, "protocol");
-
- if (CHANGED (uuconf_qproto_params))
- uvwrite_proto_params (e, q->uuconf_qproto_params, "");
-
- uvwrite_chat (e, &q->uuconf_scalled_chat,
- (qlast == NULL
- ? (struct uuconf_chat *) NULL
- : &qlast->uuconf_scalled_chat),
- "called-", FALSE);
-
- if (CHANGED (uuconf_zdebug))
- uvwrite_string (e, q->uuconf_zdebug, "debug");
-
- if (CHANGED (uuconf_zmax_remote_debug))
- uvwrite_string (e, q->uuconf_zmax_remote_debug, "max-remote-debug");
-
- if ((CHANGED (uuconf_fsend_request)
- || CHANGED (uuconf_frec_request))
- && (q->uuconf_fsend_request >= 0
- || q->uuconf_frec_request >= 0))
- {
- if (q->uuconf_fsend_request >= 0
- && (q->uuconf_fsend_request > 0
- ? q->uuconf_frec_request > 0
- : q->uuconf_frec_request == 0))
- uvwrite_boolean (e, q->uuconf_fsend_request, "request");
- else
- {
- uvwrite_boolean (e, q->uuconf_fsend_request, "send-request");
- uvwrite_boolean (e, q->uuconf_frec_request,
- "receive-request");
- }
- }
-
- if ((CHANGED (uuconf_fcall_transfer)
- || CHANGED (uuconf_fcalled_transfer))
- && (q->uuconf_fcall_transfer >= 0
- || q->uuconf_fcalled_transfer >= 0))
- {
- if (q->uuconf_fcall_transfer >= 0
- && (q->uuconf_fcall_transfer > 0
- ? q->uuconf_fcalled_transfer > 0
- : q->uuconf_fcalled_transfer == 0))
- uvwrite_boolean (e, q->uuconf_fcall_transfer, "transfer");
- else
- {
- uvwrite_boolean (e, q->uuconf_fcall_transfer, "call-transfer");
- uvwrite_boolean (e, q->uuconf_fcalled_transfer,
- "called-transfer");
- }
- }
-
- if (CHANGED (uuconf_pzlocal_send))
- uvwrite_string_array (e, q->uuconf_pzlocal_send, "local-send");
-
- if (CHANGED (uuconf_pzremote_send))
- uvwrite_string_array (e, q->uuconf_pzremote_send, "remote-send");
-
- if (CHANGED (uuconf_pzlocal_receive))
- uvwrite_string_array (e, q->uuconf_pzlocal_receive, "local-receive");
-
- if (CHANGED (uuconf_pzremote_receive))
- uvwrite_string_array (e, q->uuconf_pzremote_receive,
- "remote-receive");
-
- if (CHANGED (uuconf_pzpath))
- uvwrite_string_array (e, q->uuconf_pzpath, "command-path");
-
- if (CHANGED (uuconf_pzcmds))
- uvwrite_string_array (e, q->uuconf_pzcmds, "commands");
-
- if (CHANGED (uuconf_cfree_space)
- && q->uuconf_cfree_space >= 0)
- fprintf (e, "free-space %ld\n", q->uuconf_cfree_space);
-
- if (CHANGED (uuconf_pzforward_from))
- uvwrite_string_array (e, q->uuconf_pzforward_from, "forward-from");
-
- if (CHANGED (uuconf_pzforward_to))
- uvwrite_string_array (e, q->uuconf_pzforward_to, "forward-to");
-
- if (CHANGED (uuconf_zpubdir))
- uvwrite_string (e, q->uuconf_zpubdir, "pubdir");
-
- if (CHANGED (uuconf_zlocalname))
- uvwrite_string (e, q->uuconf_zlocalname, "myname");
- }
-}
-
-/* Write out V2 system information. */
-
-static void
-uvwrite_v2_system (e, q)
- FILE *e;
- const struct uuconf_system *q;
-{
- for (; q != NULL; q = q->uuconf_qalternate)
- {
- fprintf (e, "%s", q->uuconf_zname);
-
- if (q->uuconf_qtimegrade != (struct uuconf_timespan *) &_uuconf_unset)
- {
- fprintf (e, " ");
- uvwrite_time (e, q->uuconf_qtimegrade);
-
- if (q->uuconf_zport != (char *) &_uuconf_unset
- || q->uuconf_qport != (struct uuconf_port *) &_uuconf_unset)
- {
- struct uuconf_port *qp;
- boolean ftcp;
-
- qp = q->uuconf_qport;
- ftcp = (qp != (struct uuconf_port *) &_uuconf_unset
- && qp != NULL
- && qp->uuconf_ttype == UUCONF_PORTTYPE_TCP);
- if (ftcp
- || (q->uuconf_zport != NULL
- && q->uuconf_zport != (char *) &_uuconf_unset))
- {
- if (ftcp)
- fprintf (e, " TCP");
- else
- fprintf (e, " %s", q->uuconf_zport);
-
- if (ftcp || q->uuconf_ibaud >= 0)
- {
- fprintf (e, " ");
- if (ftcp)
- {
- const char *zport;
-
- zport = qp->uuconf_u.uuconf_stcp.uuconf_zport;
- if (zport == NULL)
- zport = "uucp";
- fprintf (e, "%s", zport);
- }
- else
- fprintf (e, "%ld", q->uuconf_ibaud);
-
- if (q->uuconf_zphone != (char *) &_uuconf_unset
- && q->uuconf_zphone != NULL)
- {
- char **pzc;
-
- fprintf (e, " %s", q->uuconf_zphone);
- pzc = q->uuconf_schat.uuconf_pzchat;
- if (pzc != (char **) &_uuconf_unset
- && pzc != NULL)
- {
- fprintf (e, " ");
- uvwrite_chat_script (e, pzc);
- }
- }
- }
- }
- }
- }
-
- fprintf (e, "\n");
-
- /* Here we should gather information to write out to USERFILE
- and L.cmds, and perhaps some day we will. It's much more
- likely to happen if somebody else does it, though. */
- }
-}
-
-/* Write out HDB system information. */
-
-static void
-uvwrite_hdb_system (e, qsys)
- FILE *e;
- const struct uuconf_system *qsys;
-{
- const struct uuconf_system *q;
- struct shpermissions sperm;
- char *azmachine[2];
- char *azlogname[2];
-
- for (q = qsys; q != NULL; q = q->uuconf_qalternate)
- {
- if (q->uuconf_fcall)
- {
- fprintf (e, "%s", q->uuconf_zname);
-
- if (q->uuconf_qtimegrade
- != (struct uuconf_timespan *) &_uuconf_unset)
- {
- const char *zport;
-
- fprintf (e, " ");
- uvwrite_time (e, q->uuconf_qtimegrade);
-
- zport = q->uuconf_zport;
- if (q->uuconf_qport != NULL
- && q->uuconf_qport != (struct uuconf_port *) &_uuconf_unset
- && q->uuconf_qport->uuconf_ttype == UUCONF_PORTTYPE_TCP)
- zport = "TCP";
- if (zport != NULL && zport != (char *) &_uuconf_unset)
- {
- fprintf (e, " %s", zport);
- if (q->uuconf_zprotocols != (char *) &_uuconf_unset
- && q->uuconf_zprotocols != NULL)
- fprintf (e, ",%s", q->uuconf_zprotocols);
-
- if (q->uuconf_ibaud >= 0
- || q->uuconf_zphone != (char *) &_uuconf_unset)
- {
- fprintf (e, " ");
- if (q->uuconf_ibaud < 0)
- fprintf (e, "Any");
- else
- {
- fprintf (e, "%ld", q->uuconf_ibaud);
- if (q->uuconf_ihighbaud >= 0)
- fprintf (e, "-%ld", q->uuconf_ihighbaud);
- }
-
- if (q->uuconf_zphone != (char *) &_uuconf_unset
- && q->uuconf_zphone != NULL)
- {
- char **pzc;
-
- fprintf (e, " %s", q->uuconf_zphone);
- pzc = q->uuconf_schat.uuconf_pzchat;
- if (pzc != (char **) &_uuconf_unset
- && pzc != NULL)
- {
- fprintf (e, " ");
- uvwrite_chat_script (e, pzc);
- }
- }
- }
- }
- }
-
- fprintf (e, "\n");
- }
- }
-
- /* Build a Permissions entry for this system. There will be only
- one MACHINE entry for a given system. */
-
- for (q = qsys; q != NULL; q = q->uuconf_qalternate)
- if (q->uuconf_fcall)
- break;
-
- if (q != NULL)
- {
- sperm.qnext = NULL;
- sperm.pzlogname = NULL;
- sperm.pzmachine = NULL;
- sperm.frequest = -1;
- sperm.fsendfiles = -1;
- sperm.pzread = NULL;
- sperm.pzwrite = NULL;
- sperm.fcallback = -1;
- sperm.pzcommands = NULL;
- sperm.pzvalidate = NULL;
- sperm.zmyname = NULL;
- sperm.zpubdir = NULL;
- sperm.pzalias = NULL;
-
- azmachine[0] = q->uuconf_zname;
- azmachine[1] = NULL;
- sperm.pzmachine = azmachine;
- if (q->uuconf_fsend_request >= 0)
- sperm.frequest = q->uuconf_fsend_request;
- if (q->uuconf_pzremote_send != (char **) &_uuconf_unset
- && q->uuconf_pzremote_send != NULL)
- sperm.pzread = q->uuconf_pzremote_send;
- if (q->uuconf_pzremote_receive != (char **) &_uuconf_unset
- && q->uuconf_pzremote_receive != NULL)
- sperm.pzwrite = q->uuconf_pzremote_receive;
- if (q->uuconf_pzcmds != (char **) &_uuconf_unset
- && q->uuconf_pzcmds != NULL)
- sperm.pzcommands = q->uuconf_pzcmds;
- if (q->uuconf_zlocalname != (char *) &_uuconf_unset
- && q->uuconf_zlocalname != NULL)
- sperm.zmyname = q->uuconf_zlocalname;
- if (q->uuconf_zpubdir != (char *) &_uuconf_unset
- && q->uuconf_zpubdir != NULL)
- sperm.zpubdir = q->uuconf_zpubdir;
- if (q->uuconf_pzalias != (char **) &_uuconf_unset
- && q->uuconf_pzalias != NULL)
- sperm.pzalias = q->uuconf_pzalias;
-
- if (q->uuconf_fcalled
- && q->uuconf_zcalled_login != (char *) &_uuconf_unset
- && q->uuconf_zcalled_login != NULL)
- {
- azlogname[0] = q->uuconf_zcalled_login;
- azlogname[1] = NULL;
- sperm.pzlogname = azlogname;
- if (q->uuconf_fcalled_transfer >= 0)
- sperm.fsendfiles = q->uuconf_fcalled_transfer;
- if (q->uuconf_fcallback >= 0)
- sperm.fcallback = q->uuconf_fcallback;
- sperm.pzvalidate = azmachine;
- }
-
- uvadd_perm (&sperm);
- }
-
- /* Now add a Permissions entry for each alternative that is not used
- for calling out. */
- for (q = qsys; q != NULL; q = q->uuconf_qalternate)
- {
- if (! q->uuconf_fcalled || q->uuconf_fcall)
- continue;
-
- sperm.qnext = NULL;
- sperm.pzlogname = NULL;
- sperm.pzmachine = NULL;
- sperm.frequest = -1;
- sperm.fsendfiles = -1;
- sperm.pzread = NULL;
- sperm.pzwrite = NULL;
- sperm.fcallback = -1;
- sperm.pzcommands = NULL;
- sperm.pzvalidate = NULL;
- sperm.zmyname = NULL;
- sperm.zpubdir = NULL;
- sperm.pzalias = NULL;
-
- if (q->uuconf_zcalled_login != (char *) &_uuconf_unset
- && q->uuconf_zcalled_login != NULL)
- azlogname[0] = q->uuconf_zcalled_login;
- else
- azlogname[0] = (char *) "OTHER";
- azlogname[1] = NULL;
- sperm.pzlogname = azlogname;
-
- if (q->uuconf_fsend_request >= 0)
- sperm.frequest = q->uuconf_fsend_request;
- if (q->uuconf_fcalled_transfer >= 0)
- sperm.fsendfiles = q->uuconf_fcalled_transfer;
- if (q->uuconf_pzremote_send != (char **) &_uuconf_unset
- && q->uuconf_pzremote_send != NULL)
- sperm.pzread = q->uuconf_pzremote_send;
- if (q->uuconf_pzremote_receive != (char **) &_uuconf_unset
- && q->uuconf_pzremote_receive != NULL)
- sperm.pzwrite = q->uuconf_pzremote_receive;
- if (q->uuconf_fcallback >= 0)
- sperm.fcallback = q->uuconf_fcallback;
- if (q->uuconf_zlocalname != (char *) &_uuconf_unset
- && q->uuconf_zlocalname != NULL)
- sperm.zmyname = q->uuconf_zlocalname;
- if (q->uuconf_zpubdir != (char *) &_uuconf_unset
- && q->uuconf_zpubdir != NULL)
- sperm.zpubdir = q->uuconf_zpubdir;
-
- uvadd_perm (&sperm);
- }
-}
-
-/* Compare two strings from a Permissions entry, returning TRUE if
- they are the same. */
-
-static boolean
-fvperm_string_cmp (z1, z2)
- const char *z1;
- const char *z2;
-{
- if (z1 == NULL)
- return z2 == NULL;
-
- if (z2 == NULL)
- return FALSE;
-
- return strcmp (z1, z2) == 0;
-}
-
-/* Compare two arrays of strings from a Permissions entry, returning
- TRUE if they are the same. */
-
-static boolean
-fvperm_array_cmp (pz1, pz2)
- const char **pz1;
- const char **pz2;
-{
- if (pz1 == NULL)
- return pz2 == NULL;
-
- if (pz2 == NULL)
- return FALSE;
-
- for (; *pz1 != NULL && *pz2 != NULL; pz1++, pz2++)
- if (strcmp (*pz1, *pz2) != 0)
- break;
-
- return *pz1 == NULL && *pz2 == NULL;
-}
-
-/* Add a Permissions entry to a global list, combining entries where
- possible. */
-
-static void
-uvadd_perm (qadd)
- struct shpermissions *qadd;
-{
- struct shpermissions *qlook;
- struct shpermissions *qnew;
- int iret;
-
- /* If there's no information, don't bother to add this entry. */
- if (qadd->pzlogname == NULL
- && qadd->frequest < 0
- && qadd->fsendfiles < 0
- && qadd->pzread == NULL
- && qadd->pzwrite == NULL
- && qadd->fcallback < 0
- && qadd->pzcommands == NULL
- && qadd->pzvalidate == NULL
- && qadd->zmyname == NULL
- && qadd->zpubdir == NULL
- && qadd->pzalias == NULL)
- return;
-
- for (qlook = qVperms; qlook != NULL; qlook = qlook->qnext)
- {
- /* See if we can merge qadd into qlook. */
- if (qadd->pzlogname == NULL
- ? qlook->pzlogname != NULL
- : qlook->pzlogname == NULL)
- continue;
- if (qadd->pzmachine == NULL
- ? qlook->pzmachine != NULL
- : qlook->pzmachine == NULL)
- continue;
- if (qadd->frequest != qlook->frequest
- || qadd->fsendfiles != qlook->fsendfiles
- || qadd->fcallback != qlook->fcallback)
- continue;
- if (! fvperm_string_cmp (qadd->zmyname, qlook->zmyname)
- || ! fvperm_string_cmp (qadd->zpubdir, qlook->zpubdir))
- continue;
- if (! fvperm_array_cmp ((const char **) qadd->pzread,
- (const char **) qlook->pzread)
- || ! fvperm_array_cmp ((const char **) qadd->pzwrite,
- (const char **) qlook->pzwrite)
- || ! fvperm_array_cmp ((const char **) qadd->pzcommands,
- (const char **) qlook->pzcommands))
- continue;
-
- /* Merge qadd into qlook. */
- if (qadd->pzmachine != NULL)
- {
- iret = _uuconf_iadd_string ((struct sglobal *) NULL,
- qadd->pzmachine[0], FALSE,
- TRUE, &qlook->pzmachine,
- (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- uvuuconf_error ((pointer) NULL, iret);
- }
- if (qadd->pzlogname != NULL)
- {
- iret = _uuconf_iadd_string ((struct sglobal *) NULL,
- qadd->pzlogname[0], FALSE,
- TRUE, &qlook->pzlogname,
- (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- uvuuconf_error ((pointer) NULL, iret);
- }
- if (qadd->pzalias != NULL)
- {
- char **pz;
-
- for (pz = qadd->pzalias; *pz != NULL; pz++)
- {
- iret = _uuconf_iadd_string ((struct sglobal *) NULL,
- *pz, FALSE, TRUE,
- &qlook->pzalias, (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- uvuuconf_error ((pointer) NULL, iret);
- }
- }
-
- return;
- }
-
- /* We must add qadd as a new entry on the list, which means we must
- copy it into the heap. */
-
- qnew = (struct shpermissions *) malloc (sizeof (struct shpermissions));
- if (qnew == NULL)
- uvuuconf_error ((pointer) NULL, UUCONF_MALLOC_FAILED);
- *qnew = *qadd;
- if (qadd->pzmachine != NULL)
- {
- qnew->pzmachine = NULL;
- iret = _uuconf_iadd_string ((struct sglobal *) NULL,
- qadd->pzmachine[0], FALSE,
- FALSE, &qnew->pzmachine,
- (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- uvuuconf_error ((pointer) NULL, iret);
- }
- if (qadd->pzlogname != NULL)
- {
- qnew->pzlogname = NULL;
- iret = _uuconf_iadd_string ((struct sglobal *) NULL,
- qadd->pzlogname[0], FALSE,
- FALSE, &qnew->pzlogname,
- (pointer) NULL);
- if (iret != UUCONF_SUCCESS)
- uvuuconf_error ((pointer) NULL, iret);
- }
- if (qadd->pzvalidate != NULL)
- qnew->pzvalidate = qnew->pzmachine;
-
- qnew->qnext = qVperms;
- qVperms = qnew;
-}
-
-/* Write out the Permissions entries. */
-
-static void
-uvwrite_perms ()
-{
- char ab[sizeof ZCURDIR + sizeof HDB_PERMISSIONS - 1];
- FILE *e;
- struct shpermissions *q;
-
- sprintf (ab, "%s%s", ZCURDIR, HDB_PERMISSIONS);
- e = fopen (ab, "w");
- if (e == NULL)
- {
- fprintf (stderr, "uuchk:%s: ", ab);
- perror ("fopen");
- exit (EXIT_FAILURE);
- }
-
- fprintf (e, "# Permissions file automatically generated by uuconv.\n");
-
- for (q = qVperms; q != NULL; q = q->qnext)
- {
- size_t ccol;
-
- ccol = 0;
- uvwrite_perm_array (e, (const char **) q->pzlogname, "LOGNAME", &ccol);
- uvwrite_perm_array (e, (const char **) q->pzmachine, "MACHINE", &ccol);
- uvwrite_perm_boolean (e, q->frequest, "REQUEST", &ccol, FALSE);
- uvwrite_perm_boolean (e, q->fsendfiles, "SENDFILES", &ccol, TRUE);
- uvwrite_perm_rw_array (e, (const char **) q->pzread, "READ", &ccol);
- uvwrite_perm_rw_array (e, (const char **) q->pzwrite, "WRITE", &ccol);
- uvwrite_perm_boolean (e, q->fcallback, "CALLBACK", &ccol, FALSE);
- uvwrite_perm_array (e, (const char **) q->pzcommands, "COMMANDS",
- &ccol);
- uvwrite_perm_array (e, (const char **) q->pzvalidate, "VALIDATE",
- &ccol);
- uvwrite_perm_string (e, q->zmyname, "MYNAME", &ccol);
- uvwrite_perm_string (e, q->zpubdir, "PUBDIR", &ccol);
- uvwrite_perm_array (e, (const char **) q->pzalias, "ALIAS", &ccol);
-
- fprintf (e, "\n");
- }
-
- if (ferror (e)
- || fclose (e) == EOF)
- {
- fprintf (stderr, "uuchk:%s: error during output\n", HDB_PERMISSIONS);
- exit (EXIT_FAILURE);
- }
-}
-
-/* Write an array out to the Permissions file. */
-
-static void
-uvwrite_perm_array (e, pzarg, zcmd, pccol)
- FILE *e;
- const char **pzarg;
- const char *zcmd;
- size_t *pccol;
-{
- size_t c;
- const char **pz;
-
- if (pzarg == NULL)
- return;
-
- c = strlen (zcmd) + 1;
-
- for (pz = pzarg; *pz != NULL; pz++)
- c += strlen (*pz) + 1;
-
- if (*pccol > 20 && c + *pccol > 75)
- {
- fprintf (e, " \\\n");
- *pccol = c - 1;
- }
- else
- {
- if (*pccol != 0)
- fprintf (e, " ");
- *pccol += c;
- }
-
- fprintf (e, "%s=", zcmd);
- for (pz = pzarg; *pz != NULL; pz++)
- {
- if (pz != pzarg)
- fprintf (e, ":");
- fprintf (e, "%s", *pz);
- }
-}
-
-/* Write a boolean value out to the Permissions file. This may be
- either a yes/no boolean or a yes/call boolean (the latter is for
- SENDFILES). */
-
-static void
-uvwrite_perm_boolean (e, f, zcmd, pccol, fsendfiles)
- FILE *e;
- int f;
- const char *zcmd;
- size_t *pccol;
- boolean fsendfiles;
-{
- const char *az[2];
-
- if (f < 0)
- return;
-
- if (f)
- az[0] = "yes";
- else
- az[0] = fsendfiles ? "call" : "no";
- az[1] = NULL;
-
- uvwrite_perm_array (e, az, zcmd, pccol);
-}
-
-/* Write a set of READ or WRITE entries to the Permissions file. We
- have to separate out all entries that start with '!'. */
-
-static void
-uvwrite_perm_rw_array (e, pzarg, zcmd, pccol)
- FILE *e;
- const char **pzarg;
- const char *zcmd;
- size_t *pccol;
-{
- size_t c;
- const char **pz, **pzcopy, **pzset;
-
- if (pzarg == NULL)
- return;
-
- c = 0;
- for (pz = pzarg; *pz != NULL; pz++)
- c++;
-
- pzcopy = (const char **) malloc ((c + 1) * sizeof (char *));
- if (pzcopy == NULL)
- uvuuconf_error ((pointer) NULL, UUCONF_MALLOC_FAILED);
-
- pzset = pzcopy;
- for (pz = pzarg; *pz != NULL; pz++)
- if ((*pz)[0] != '!')
- *pzset++ = *pz;
- *pzset = NULL;
-
- if (pzset != pzcopy)
- uvwrite_perm_array (e, (const char **) pzcopy, zcmd, pccol);
-
- pzset = pzcopy;
- for (pz = pzarg; *pz != NULL; pz++)
- if ((*pz)[0] == '!')
- *pzset++ = *pz;
- *pzset = NULL;
-
- if (pzset != pzcopy)
- {
- char ab[20];
-
- sprintf (ab, "NO%s", zcmd);
- uvwrite_perm_array (e, (const char **) pzcopy, ab, pccol);
- }
-}
-
-/* Write a string out to the Permissions file. */
-
-static void
-uvwrite_perm_string (e, z, zcmd, pccol)
- FILE *e;
- const char *z;
- const char *zcmd;
- size_t *pccol;
-{
- const char *az[2];
-
- if (z == NULL)
- return;
-
- az[0] = z;
- az[1] = NULL;
-
- uvwrite_perm_array (e, az, zcmd, pccol);
-}
-
-/* Write out a Taylor UUCP port. This is called via uuconf_find_port;
- the pinfo argument is the port file. */
-
-static int
-ivwrite_taylor_port (qport, pinfo)
- struct uuconf_port *qport;
- pointer pinfo;
-{
- FILE *e = (FILE *) pinfo;
-
- fprintf (e, "port %s\n", qport->uuconf_zname);
-
- uvwrite_taylor_port (e, qport, "");
-
- /* Return UUCONF_NOT_FOUND to force uuconf_find_port to keep looking
- for ports. */
- return UUCONF_NOT_FOUND;
-}
-
-/* Write a port out to a Taylor UUCP configuration file. This doesn't
- output the name, since it is called to output a specially defined
- port in the sys file. */
-
-static void
-uvwrite_taylor_port (e, qport, zprefix)
- FILE *e;
- struct uuconf_port *qport;
- const char *zprefix;
-{
- const char *ztype;
- char ab[100];
-
- switch (qport->uuconf_ttype)
- {
- default:
- case UUCONF_PORTTYPE_UNKNOWN:
- fprintf (stderr, "uuconv: Bad port type\n");
- exit (EXIT_FAILURE);
- break;
- case UUCONF_PORTTYPE_STDIN:
- ztype = "stdin";
- break;
- case UUCONF_PORTTYPE_MODEM:
- ztype = "modem";
- break;
- case UUCONF_PORTTYPE_DIRECT:
- ztype = "direct";
- break;
- case UUCONF_PORTTYPE_TCP:
- ztype = "tcp";
- break;
- case UUCONF_PORTTYPE_TLI:
- ztype = "tli";
- break;
- case UUCONF_PORTTYPE_PIPE:
- ztype = "pipe";
- break;
- }
-
- fprintf (e, "%stype %s\n", zprefix, ztype);
-
- if (qport->uuconf_zprotocols != NULL)
- fprintf (e, "%sprotocol %s\n", zprefix, qport->uuconf_zprotocols);
-
- if (qport->uuconf_qproto_params != NULL)
- uvwrite_proto_params (e, qport->uuconf_qproto_params, zprefix);
-
- if ((qport->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0)
- {
- sprintf (ab, "%sseven-bit", zprefix);
- uvwrite_boolean (e,
- ((qport->uuconf_ireliable & UUCONF_RELIABLE_EIGHT)
- == 0),
- ab);
- sprintf (ab, "%sreliable", zprefix);
- uvwrite_boolean (e,
- ((qport->uuconf_ireliable & UUCONF_RELIABLE_RELIABLE)
- != 0),
- ab);
- sprintf (ab, "%shalf-duplex", zprefix);
- uvwrite_boolean (e,
- ((qport->uuconf_ireliable & UUCONF_RELIABLE_FULLDUPLEX)
- == 0),
- ab);
- }
-
- if (qport->uuconf_zlockname != NULL)
- fprintf (e, "%slockname %s\n", zprefix, qport->uuconf_zlockname);
-
- switch (qport->uuconf_ttype)
- {
- default:
- break;
- case UUCONF_PORTTYPE_MODEM:
- {
- struct uuconf_modem_port *qm;
-
- qm = &qport->uuconf_u.uuconf_smodem;
- if (qm->uuconf_zdevice != NULL)
- fprintf (e, "%sdevice %s\n", zprefix, qm->uuconf_zdevice);
- if (qm->uuconf_zdial_device != NULL)
- fprintf (e, "%sdial-device %s\n", zprefix, qm->uuconf_zdial_device);
- if (qm->uuconf_ibaud != 0)
- fprintf (e, "%sbaud %ld\n", zprefix, qm->uuconf_ibaud);
- if (qm->uuconf_ilowbaud != 0)
- fprintf (e, "%sbaud-range %ld %ld\n", zprefix, qm->uuconf_ilowbaud,
- qm->uuconf_ihighbaud);
- if (! qm->uuconf_fcarrier)
- fprintf (e, "%scarrier false\n", zprefix);
- if (! qm->uuconf_fhardflow)
- fprintf (e, "%shardflow false\n", zprefix);
- if (qm->uuconf_pzdialer != NULL)
- {
- if (qm->uuconf_pzdialer[1] == NULL)
- fprintf (e, "%sdialer %s\n", zprefix, qm->uuconf_pzdialer[0]);
- else
- {
- sprintf (ab, "%sdialer-sequence", zprefix);
- uvwrite_string_array (e, qm->uuconf_pzdialer, ab);
- }
- }
- if (qm->uuconf_qdialer != NULL)
- {
- sprintf (ab, "%sdialer ", zprefix);
- uvwrite_taylor_dialer (e, qm->uuconf_qdialer, ab);
- }
- }
- break;
- case UUCONF_PORTTYPE_DIRECT:
- {
- struct uuconf_direct_port *qd;
-
- qd = &qport->uuconf_u.uuconf_sdirect;
- if (qd->uuconf_zdevice != NULL)
- fprintf (e, "%sdevice %s\n", zprefix, qd->uuconf_zdevice);
- if (qd->uuconf_ibaud != 0)
- fprintf (e, "%sbaud %ld\n", zprefix, qd->uuconf_ibaud);
- if (qd->uuconf_fcarrier)
- fprintf (e, "%scarrier true\n", zprefix);
- if (! qd->uuconf_fhardflow)
- fprintf (e, "%shardflow false\n", zprefix);
- }
- break;
- case UUCONF_PORTTYPE_TCP:
- if (qport->uuconf_u.uuconf_stcp.uuconf_zport != NULL)
- fprintf (e, "%sservice %s\n", zprefix,
- qport->uuconf_u.uuconf_stcp.uuconf_zport);
- if (qport->uuconf_u.uuconf_stcp.uuconf_pzdialer != NULL)
- {
- sprintf (ab, "%sdialer-sequence", zprefix);
- uvwrite_string_array (e,
- qport->uuconf_u.uuconf_stcp.uuconf_pzdialer,
- ab);
- }
- break;
- case UUCONF_PORTTYPE_TLI:
- {
- struct uuconf_tli_port *qt;
-
- qt = &qport->uuconf_u.uuconf_stli;
- if (qt->uuconf_zdevice != NULL)
- fprintf (e, "%sdevice %s\n", zprefix, qt->uuconf_zdevice);
- sprintf (ab, "%sstream", zprefix);
- uvwrite_boolean (e, qt->uuconf_fstream, ab);
- if (qt->uuconf_pzpush != NULL)
- {
- sprintf (ab, "%spush", zprefix);
- uvwrite_string_array (e, qt->uuconf_pzpush, ab);
- }
- if (qt->uuconf_pzdialer != NULL)
- {
- sprintf (ab, "%sdialer-sequence", zprefix);
- uvwrite_string_array (e, qt->uuconf_pzdialer, ab);
- }
- if (qt->uuconf_zservaddr != NULL)
- fprintf (e, "%sserver-address %s\n", zprefix,
- qt->uuconf_zservaddr);
- }
- break;
- case UUCONF_PORTTYPE_PIPE:
- {
- struct uuconf_pipe_port *qp;
-
- qp = &qport->uuconf_u.uuconf_spipe;
- if (qp->uuconf_pzcmd != NULL)
- {
- sprintf (ab, "%scommad", zprefix);
- uvwrite_string_array (e, qp->uuconf_pzcmd, ab);
- }
- }
- break;
- }
-}
-
-/* Write out a port to the V2 L-devices file. This is called via
- uuconf_find_port. */
-
-static int
-ivwrite_v2_port (qport, pinfo)
- struct uuconf_port *qport;
- pointer pinfo;
-{
- FILE *e = (FILE *) pinfo;
-
- if (qport->uuconf_ttype == UUCONF_PORTTYPE_DIRECT)
- {
- fprintf (e, "DIR %s - %ld direct",
- qport->uuconf_u.uuconf_sdirect.uuconf_zdevice,
- qport->uuconf_u.uuconf_sdirect.uuconf_ibaud);
- }
- else if (qport->uuconf_ttype == UUCONF_PORTTYPE_MODEM)
- {
- fprintf (e, "%s %s ", qport->uuconf_zname,
- qport->uuconf_u.uuconf_smodem.uuconf_zdevice);
- if (qport->uuconf_u.uuconf_smodem.uuconf_zdial_device != NULL)
- fprintf (e, "%s", qport->uuconf_u.uuconf_smodem.uuconf_zdial_device);
- else
- fprintf (e, "-");
- fprintf (e, " ");
- if (qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud != 0L)
- fprintf (e, "%ld-%ld",
- qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud,
- qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud);
- else if (qport->uuconf_u.uuconf_smodem.uuconf_ibaud != 0L)
- fprintf (e, "%ld", qport->uuconf_u.uuconf_smodem.uuconf_ibaud);
- else
- fprintf (e, "Any");
- if (qport->uuconf_u.uuconf_smodem.uuconf_pzdialer != NULL)
- fprintf (e, " %s",
- qport->uuconf_u.uuconf_smodem.uuconf_pzdialer[0]);
- }
- else
- {
- fprintf (e, "# Ignoring port %s with unsupported type",
- qport->uuconf_zname);
- }
-
- fprintf (e, "\n");
-
- /* Return UUCONF_NOT_FOUND to force uuconf_find_port to keep looking
- for a port. */
- return UUCONF_NOT_FOUND;
-}
-
-/* Write out a port to the HDB Devices file. This is called via
- uuconf_find_port. */
-
-static int
-ivwrite_hdb_port (qport, pinfo)
- struct uuconf_port *qport;
- pointer pinfo;
-{
- FILE *e = (FILE *) pinfo;
-
- if (qport->uuconf_ttype == UUCONF_PORTTYPE_DIRECT)
- {
- fprintf (e, "Direct");
- if (qport->uuconf_zprotocols != NULL)
- fprintf (e, ",%s", qport->uuconf_zprotocols);
- fprintf (e, " ");
- if (qport->uuconf_u.uuconf_sdirect.uuconf_zdevice != NULL)
- fprintf (e, "%s", qport->uuconf_u.uuconf_sdirect.uuconf_zdevice);
- else
- fprintf (e, "%s", qport->uuconf_zname);
- fprintf (e, " - %ld", qport->uuconf_u.uuconf_sdirect.uuconf_ibaud);
- }
- else if (qport->uuconf_ttype == UUCONF_PORTTYPE_MODEM)
- {
- fprintf (e, "%s", qport->uuconf_zname);
- if (qport->uuconf_zprotocols != NULL)
- fprintf (e, ",%s", qport->uuconf_zprotocols);
- fprintf (e, " ");
- if (qport->uuconf_u.uuconf_smodem.uuconf_zdevice != NULL)
- fprintf (e, "%s", qport->uuconf_u.uuconf_smodem.uuconf_zdevice);
- else
- fprintf (e, "%s", qport->uuconf_zname);
- fprintf (e, " ");
- if (qport->uuconf_u.uuconf_smodem.uuconf_zdial_device != NULL)
- fprintf (e, "%s", qport->uuconf_u.uuconf_smodem.uuconf_zdial_device);
- else
- fprintf (e, "-");
- fprintf (e, " ");
- if (qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud != 0L)
- fprintf (e, "%ld-%ld",
- qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud,
- qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud);
- else if (qport->uuconf_u.uuconf_smodem.uuconf_ibaud != 0L)
- fprintf (e, "%ld", qport->uuconf_u.uuconf_smodem.uuconf_ibaud);
- else
- fprintf (e, "Any");
- if (qport->uuconf_u.uuconf_smodem.uuconf_pzdialer != NULL)
- {
- char **pz;
-
- for (pz = qport->uuconf_u.uuconf_smodem.uuconf_pzdialer;
- *pz != NULL;
- pz++)
- fprintf (e, " %s", *pz);
- }
- }
- else if (qport->uuconf_ttype == UUCONF_PORTTYPE_TCP)
- {
- char **pz;
-
- fprintf (e, "TCP");
- if (qport->uuconf_zprotocols != NULL)
- fprintf (e, ",%s", qport->uuconf_zprotocols);
- fprintf (e, " ");
- if (qport->uuconf_u.uuconf_stcp.uuconf_zport == NULL)
- fprintf (e, "uucp");
- else
- fprintf (e, "%s", qport->uuconf_u.uuconf_stcp.uuconf_zport);
- fprintf (e, " - -");
- pz = qport->uuconf_u.uuconf_stcp.uuconf_pzdialer;
- if (pz != NULL)
- for (; *pz != NULL; pz++)
- fprintf (e, " %s", *pz);
- }
- else if (qport->uuconf_ttype == UUCONF_PORTTYPE_TLI)
- {
- char **pz;
-
- fprintf (e, "%s", qport->uuconf_zname);
- if (qport->uuconf_zprotocols != NULL)
- fprintf (e, ",%s", qport->uuconf_zprotocols);
- fprintf (e, " ");
- if (qport->uuconf_u.uuconf_stli.uuconf_zdevice != NULL)
- fprintf (e, "%s", qport->uuconf_u.uuconf_smodem.uuconf_zdevice);
- else
- fprintf (e, "-");
- fprintf (e, " - -");
- pz = qport->uuconf_u.uuconf_stli.uuconf_pzdialer;
- if (pz == NULL
- || *pz == NULL
- || (strcmp (*pz, "TLI") != 0
- && strcmp (*pz, "TLIS") != 0))
- fprintf (e, " TLI%s \\D",
- qport->uuconf_u.uuconf_stli.uuconf_fstream ? "S" : "");
- if (pz != NULL)
- for (; *pz != NULL; pz++)
- fprintf (e, " %s", *pz);
- }
- else
- {
- fprintf (e, "# Ignoring port %s with unsupported type",
- qport->uuconf_zname);
- }
-
- fprintf (e, "\n");
-
- /* Return UUCONF_NOT_FOUND to force uuconf_find_port to keep looking
- for a port. */
- return UUCONF_NOT_FOUND;
-}
-
-/* Write a dialer out to a Taylor UUCP configuration file. This
- doesn't output the name, since it is called to output a specially
- defined dialer in the sys or port file. */
-
-static void
-uvwrite_taylor_dialer (e, qdialer, zprefix)
- FILE *e;
- struct uuconf_dialer *qdialer;
- const char *zprefix;
-{
- char ab[100];
-
- /* Reset default values, so we don't output them unnecessarily. */
- if (qdialer->uuconf_schat.uuconf_ctimeout == 60)
- qdialer->uuconf_schat.uuconf_ctimeout = -1;
- if (qdialer->uuconf_schat.uuconf_fstrip)
- qdialer->uuconf_schat.uuconf_fstrip = -1;
- if (qdialer->uuconf_scomplete.uuconf_ctimeout == 60)
- qdialer->uuconf_scomplete.uuconf_ctimeout = -1;
- if (qdialer->uuconf_scomplete.uuconf_fstrip)
- qdialer->uuconf_scomplete.uuconf_fstrip = -1;
- if (qdialer->uuconf_sabort.uuconf_ctimeout == 60)
- qdialer->uuconf_sabort.uuconf_ctimeout = -1;
- if (qdialer->uuconf_sabort.uuconf_fstrip)
- qdialer->uuconf_sabort.uuconf_fstrip = -1;
-
- uvwrite_chat (e, &qdialer->uuconf_schat, (struct uuconf_chat *) NULL,
- zprefix, FALSE);
- if (qdialer->uuconf_zdialtone != NULL
- && strcmp (qdialer->uuconf_zdialtone, ",") != 0)
- fprintf (e, "%sdialtone %s\n", zprefix, qdialer->uuconf_zdialtone);
- if (qdialer->uuconf_zpause != NULL
- && strcmp (qdialer->uuconf_zpause, ",") != 0)
- fprintf (e, "%spause %s\n", zprefix, qdialer->uuconf_zpause);
- if (! qdialer->uuconf_fcarrier)
- fprintf (e, "%scarrier false\n", zprefix);
- if (qdialer->uuconf_ccarrier_wait != 60)
- fprintf (e, "%scarrier-wait %d\n", zprefix,
- qdialer->uuconf_ccarrier_wait);
- if (qdialer->uuconf_fdtr_toggle)
- fprintf (e, "%sdtr-toggle %s %s\n", zprefix,
- qdialer->uuconf_fdtr_toggle ? "true" : "false",
- qdialer->uuconf_fdtr_toggle_wait ? "true" : "false");
- sprintf (ab, "%scomplete-", zprefix);
- uvwrite_chat (e, &qdialer->uuconf_scomplete, (struct uuconf_chat *) NULL,
- ab, FALSE);
- sprintf (ab, "%sabort-", zprefix);
- uvwrite_chat (e, &qdialer->uuconf_sabort, (struct uuconf_chat *) NULL,
- ab, FALSE);
- if (qdialer->uuconf_qproto_params != NULL)
- uvwrite_proto_params (e, qdialer->uuconf_qproto_params, zprefix);
- if ((qdialer->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0)
- {
- sprintf (ab, "%sseven-bit", zprefix);
- uvwrite_boolean (e,
- ((qdialer->uuconf_ireliable & UUCONF_RELIABLE_EIGHT)
- == 0),
- ab);
- sprintf (ab, "%sreliable", zprefix);
- uvwrite_boolean (e,
- ((qdialer->uuconf_ireliable & UUCONF_RELIABLE_RELIABLE)
- != 0),
- ab);
- sprintf (ab, "%shalf-duplex", zprefix);
- uvwrite_boolean (e,
- ((qdialer->uuconf_ireliable
- & UUCONF_RELIABLE_FULLDUPLEX) == 0),
- ab);
- }
-}
-
-/* Write a dialer out to an HDB configuration file. */
-
-static void
-uvwrite_hdb_dialer (e, qdialer)
- FILE *e;
- struct uuconf_dialer *qdialer;
-{
- fprintf (e, "%s ", qdialer->uuconf_zname);
-
- if (qdialer->uuconf_zdialtone != NULL)
- fprintf (e, "=%c", qdialer->uuconf_zdialtone[0]);
- if (qdialer->uuconf_zpause != NULL)
- fprintf (e, "-%c", qdialer->uuconf_zpause[0]);
-
- if (qdialer->uuconf_schat.uuconf_pzchat != NULL)
- {
- if (qdialer->uuconf_zdialtone == NULL
- && qdialer->uuconf_zpause == NULL)
- fprintf (e, "\"\"");
- fprintf (e, " ");
- uvwrite_chat_script (e, qdialer->uuconf_schat.uuconf_pzchat);
- }
-
- fprintf (e, "\n");
-}
-
-/* Display a uuconf error and exit. */
-
-static void
-uvuuconf_error (puuconf, iret)
- pointer puuconf;
- int iret;
-{
- char ab[512];
-
- (void) uuconf_error_string (puuconf, iret, ab, sizeof ab);
- if ((iret & UUCONF_ERROR_FILENAME) == 0)
- fprintf (stderr, "uuconv: %s\n", ab);
- else
- fprintf (stderr, "uuconv:%s\n", ab);
- if (UUCONF_ERROR_VALUE (iret) != UUCONF_FOPEN_FAILED)
- exit (EXIT_FAILURE);
-}
diff --git a/gnu/libexec/uucp/uucp/Makefile b/gnu/libexec/uucp/uucp/Makefile
deleted file mode 100644
index afd32d7..0000000
--- a/gnu/libexec/uucp/uucp/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Makefile for uucp
-# $Id$
-
-BINDIR= $(bindir)
-BINOWN= $(owner)
-BINMODE= 4555
-
-PROG= uucp
-SRCS= uucp.c util.c log.c copy.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -DVERSION=\"$(VERSION)\"
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../common_sources
diff --git a/gnu/libexec/uucp/uucp/uucp.1 b/gnu/libexec/uucp/uucp/uucp.1
deleted file mode 100644
index 8cb465d..0000000
--- a/gnu/libexec/uucp/uucp/uucp.1
+++ /dev/null
@@ -1,212 +0,0 @@
-''' $Id$
-.TH uucp 1 "Taylor UUCP 1.06"
-.SH NAME
-uucp \- Unix to Unix copy
-.SH SYNOPSIS
-.B uucp
-[ options ] source-file destination-file
-.PP
-.B uucp
-[ options ] source-file... destination-directory
-.SH DESCRIPTION
-The
-.I uucp
-command copies files between systems. Each
-.I file
-argument is either a pathname on the local machine or is of the form
-.IP
-system!path
-.LP
-which is interpreted as being on a remote system.
-In the first form, the contents of the first file are copied to the
-second. In the second form, each source file is copied into the
-destination directory.
-
-A file be transferred to or from
-.I system2
-via
-.I system1
-by using
-.IP
-system1!system2!path.
-.LP
-
-Any pathname that does not begin with / or ~ will be appended to the
-current directory (unless the
-.B \-W
-or
-.B \--noexpand
-option is used); this resulting path will not necessarily exist on a
-remote system. A pathname beginning with a simple ~ starts at the
-UUCP public directory; a pathname beginning with ~name starts at the
-home directory of the named user. The ~ is interpreted on the
-appropriate system. Note that some shells will interpret a simple ~
-to the local home directory before
-.I uucp
-sees it; to avoid this the ~ must be quoted.
-
-Shell metacharacters ? * [ ] are interpreted on the appropriate
-system, assuming they are quoted to prevent the shell from
-interpreting them first.
-
-The copy does not take place immediately, but is queued up for the
-.I uucico
-(8) daemon; the daemon is started immediately unless the
-.B \-r
-or
-.B \-\-nouucico
-switch is given. In any case, the next time the remote system is called the
-file(s) will be copied.
-.SH OPTIONS
-The following options may be given to
-.I uucp.
-.TP 5
-.B \-c, \-\-nocopy
-Do not copy local source files to the spool directory. If they are
-removed before being processed by the
-.I uucico
-(8) daemon, the copy will fail. The files must be readable by the
-.I uucico
-(8) daemon, and by the invoking user.
-.TP 5
-.B \-C, \-\-copy
-Copy local source files to the spool directory. This is the default.
-.TP 5
-.B \-d, \-\-directories
-Create all necessary directories when doing the copy. This is the
-default.
-.TP 5
-.B \-f, \-\-nodirectories
-If any necessary directories do not exist for the destination path,
-abort the copy.
-.TP 5
-.B \-R, \-\-recursive
-If any of the source file names are directories, copy their contents
-recursively to the destination (which must itself be a directory).
-.TP 5
-.B \-g grade, \-\-grade grade
-Set the grade of the file transfer command. Jobs of a higher grade
-are executed first. Grades run 0 ... 9 A ... Z a ... z from high to
-low.
-.TP 5
-.B \-m, \-\-mail
-Report completion or failure of the file transfer by
-.I mail
-(1).
-.TP 5
-.B \-n user, \-\-notify user
-Report completion or failure of the file transfer by
-.I mail
-(1) to the named
-user on the remote system.
-.TP 5
-.B \-r, \-\-nouucico
-Do not start
-.I uucico
-(8) daemon immediately; merely queue up the file transfer for later
-execution.
-.TP 5
-.B \-j, \-\-jobid
-Print jobid on standard output. The job may be
-later cancelled by passing the jobid to the
-.B \-k
-switch of
-.I uustat
-(1).
-It is possible for some complex operations to produce more than one
-jobid, in which case each will be printed on a separate line. For
-example
-.br
-.in +0.5i
-.nf
-uucp sys1!~user1/file1 sys2!~user2/file2 ~user3
-.fi
-.in -0.5i
-will generate two separate jobs, one for the system
-.I sys1
-and one for the system
-.I sys2.
-.TP 5
-.B \-W, \-\-noexpand
-Do not prepend remote relative path names with the current directory.
-.TP 5
-.B \-t, \-\-uuto
-This option is used by the
-.I uuto
-shell script. It causes
-.I uucp
-to interpret the final argument as
-.I system!user.
-The file(s) are sent to
-.I ~/receive/USER/LOCAL
-on the remote system, where
-.I USER
-is from the final argument and
-.I LOCAL
-is the local UUCP
-system name. Also,
-.I uucp
-will act as though
-.I \-\-notify user
-were specified.
-.TP 5
-.B \-x type, \-\-debug type
-Turn on particular debugging types. The following types are
-recognized: abnormal, chat, handshake, uucp-proto, proto, port,
-config, spooldir, execute, incoming, outgoing. Only abnormal, config,
-spooldir and execute are meaningful for
-.I uucp.
-
-Multiple types may be given, separated by commas, and the
-.B \-\-debug
-option may appear multiple times. A number may also be given, which
-will turn on that many types from the foregoing list; for example,
-.B \-\-debug 2
-is equivalent to
-.B \-\-debug abnormal,chat.
-.TP 5
-.B \-I file, \-\-config file
-Set configuration file to use. This option may not be available,
-depending upon how
-.I uucp
-was compiled.
-.TP 5
-.B \-v, \-\-version
-Report version information and exit.
-.TP 5
-.B \-\-help
-Print a help message and exit.
-.SH FILES
-The file names may be changed at compilation time or by the
-configuration file, so these are only approximations.
-
-.br
-/etc/uucp/config - Configuration file.
-.br
-/var/spool/uucp -
-UUCP spool directory.
-.br
-/var/spool/uucp/Log -
-UUCP log file.
-.br
-/var/spool/uucppublic -
-Default UUCP public directory.
-.SH SEE ALSO
-mail(1), uux(1), uustat(1), uucico(8)
-.SH BUGS
-Some of the options are dependent on the capabilities of the
-.I uucico
-(8) daemon on the remote system.
-
-The
-.I \-n
-and
-.I \-m
-switches do not work when transferring a file from one remote system
-to another.
-
-File modes are not preserved, except for the execute bit. The
-resulting file is owned by the uucp user.
-.SH AUTHOR
-Ian Lance Taylor
-<ian@airs.com>
diff --git a/gnu/libexec/uucp/uucp/uucp.c b/gnu/libexec/uucp/uucp/uucp.c
deleted file mode 100644
index 3ebb3d4..0000000
--- a/gnu/libexec/uucp/uucp/uucp.c
+++ /dev/null
@@ -1,1268 +0,0 @@
-/* uucp.c
- Prepare to copy a file to or from a remote system.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char uucp_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-#include "getopt.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-
-/* Local functions. */
-
-static void ucusage P((void));
-static void uchelp P((void));
-static void ucdirfile P((const char *zdir, const char *zfile,
- pointer pinfo));
-static void uccopy P((const char *zfile, const char *zdest));
-static void ucadd_cmd P((const struct uuconf_system *qsys,
- const struct scmd *qcmd, const char *zlog));
-static void ucspool_cmds P((boolean fjobid));
-static const char *zcone_system P((boolean *pfany));
-static void ucrecord_file P((const char *zfile));
-static void ucabort P((void));
-
-/* Long getopt options. */
-static const struct option asClongopts[] =
-{
- { "copy", no_argument, NULL, 'C' },
- { "nocopy", no_argument, NULL, 'c' },
- { "directories", no_argument, NULL, 'd' },
- { "nodirectories", no_argument, NULL, 'f' },
- { "grade", required_argument, NULL, 'g' },
- { "jobid", no_argument, NULL, 'j' },
- { "mail", no_argument, NULL, 'm' },
- { "notify", required_argument, NULL, 'n' },
- { "nouucico", no_argument, NULL, 'r' },
- { "recursive", no_argument, NULL, 'R' },
- { "status", required_argument, NULL, 's' },
- { "uuto", no_argument, NULL, 't' },
- { "user", required_argument, NULL, 'u' },
- { "noexpand", no_argument, NULL, 'w' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'x' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-/* Local variables. There are a bunch of these, mostly set by the
- options and the last (the destination) argument. These have file
- scope so that they may be easily passed into uccopy; they could for
- the most part also be wrapped up in a structure and passed in. */
-
-/* The uuconf global pointer. */
-static pointer pCuuconf;
-
-/* TRUE if source files should be copied to the spool directory. */
-static boolean fCcopy = TRUE;
-
-/* Grade to use. */
-static char bCgrade = BDEFAULT_UUCP_GRADE;
-
-/* Whether to send mail to the requesting user when the copy is
- complete. */
-static boolean fCmail = FALSE;
-
-/* User to notify on remote system. */
-static const char *zCnotify = "";
-
-/* TRUE if remote files should be prefixed with the current working
- directory. */
-static boolean fCexpand = TRUE;
-
-/* TRUE if necessary directories should be created on the destination
- system. */
-static boolean fCmkdirs = TRUE;
-
-/* Local name. */
-static const char *zClocalname;
-
-/* User name. */
-static const char *zCuser = NULL;
-
-/* TRUE if this is a remote request. */
-static boolean fCremote = FALSE;
-
-/* TRUE if the destination is this system. */
-static boolean fClocaldest;
-
-/* Destination system. */
-static struct uuconf_system sCdestsys;
-
-/* Systems to forward to, if not NULL. */
-static char *zCforward;
-
-/* Options to use when sending a file. */
-static char abCsend_options[20];
-
-/* Options to use when receiving a file. */
-static char abCrec_options[20];
-
-/* TRUE if the current file being copied from is in the cwd. */
-static boolean fCneeds_cwd;
-
-/* The main program. */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- /* -I: configuration file name. */
- const char *zconfig = NULL;
- /* -j: output job id. */
- boolean fjobid = FALSE;
- /* -r: don't start uucico when finished. */
- boolean fuucico = TRUE;
- /* -R: copy directories recursively. */
- boolean frecursive = FALSE;
- /* -s: report status to named file. */
- const char *zstatus_file = NULL;
- /* -t: emulate uuto. */
- boolean fuuto = FALSE;
- int iopt;
- pointer puuconf;
- int iuuconf;
- int i;
- boolean fgetcwd;
- struct uuconf_system slocalsys;
- char *zexclam;
- char *zdestfile;
- const char *zdestsys;
- char *zoptions;
- boolean fexit;
-
- zProgram = argv[0];
-
- while ((iopt = getopt_long (argc, argv, "cCdfg:I:jmn:prRs:tu:Wvx:",
- asClongopts, (int *) NULL)) != EOF)
- {
- switch (iopt)
- {
- case 'c':
- /* Do not copy local files to spool directory. */
- fCcopy = FALSE;
- break;
-
- case 'p':
- case 'C':
- /* Copy local files to spool directory. */
- fCcopy = TRUE;
- break;
-
- case 'd':
- /* Create directories if necessary. */
- fCmkdirs = TRUE;
- break;
-
- case 'f':
- /* Do not create directories if they don't exist. */
- fCmkdirs = FALSE;
- break;
-
- case 'g':
- /* Set job grade. */
- bCgrade = optarg[0];
- break;
-
- case 'I':
- /* Name configuration file. */
- if (fsysdep_other_config (optarg))
- zconfig = optarg;
- break;
-
- case 'j':
- /* Output job id. */
- fjobid = TRUE;
- break;
-
- case 'm':
- /* Mail to requesting user. */
- fCmail = TRUE;
- break;
-
- case 'n':
- /* Notify remote user. */
- zCnotify = optarg;
- break;
-
- case 'r':
- /* Don't start uucico when finished. */
- fuucico = FALSE;
- break;
-
- case 'R':
- /* Copy directories recursively. */
- frecursive = TRUE;
- break;
-
- case 's':
- /* Report status to named file. */
- zstatus_file = optarg;
- break;
-
- case 't':
- /* Emulate uuto. */
- fuuto = TRUE;
- break;
-
- case 'u':
- /* Set user name. */
- zCuser = optarg;
- break;
-
- case 'W':
- /* Expand only local file names. */
- fCexpand = FALSE;
- break;
-
- case 'x':
-#if DEBUG > 1
- /* Set debugging level. */
- iDebug |= idebug_parse (optarg);
-#endif
- break;
-
- case 'v':
- /* Print version and exit. */
- printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zProgram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 1:
- /* --help. */
- uchelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found and flag set. */
- break;
-
- default:
- ucusage ();
- /*NOTREACHED*/
- }
- }
-
- if (! UUCONF_GRADE_LEGAL (bCgrade)
- || ((bCgrade < '0' || bCgrade > '9')
- && (bCgrade < 'a' || bCgrade > 'z')
- && (bCgrade < 'A' || bCgrade > 'Z')))
- {
- ulog (LOG_ERROR, "Ignoring illegal grade");
- bCgrade = BDEFAULT_UUCP_GRADE;
- }
-
- /* The user name must contain a '!', which is treated as a remote
- name, to avoid spoofing of other users (there is no advantage to
- spoofing remote users, except to send them random bits of mail,
- which you can do anyhow). */
- if (zCuser != NULL)
- {
- if (strchr (zCuser, '!') != NULL)
- fCremote = TRUE;
- else
- {
- ulog (LOG_ERROR, "Ignoring local user name");
- zCuser = NULL;
- }
- }
-
- if (argc - optind < 2)
- ucusage ();
-
- iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- pCuuconf = puuconf;
-
-#if DEBUG > 1
- {
- const char *zdebug;
-
- iuuconf = uuconf_debuglevel (puuconf, &zdebug);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (zdebug != NULL)
- iDebug |= idebug_parse (zdebug);
- }
-#endif
-
- /* See if we are going to need to know the current directory. We
- just check each argument to see whether it's an absolute
- pathname. We actually aren't going to need the cwd if fCexpand
- is FALSE and the file is remote, but so what. */
- fgetcwd = FALSE;
- for (i = optind; i < argc; i++)
- {
- zexclam = strrchr (argv[i], '!');
- if (zexclam == NULL)
- zexclam = argv[i];
- else
- ++zexclam;
- if (fsysdep_needs_cwd (zexclam))
- {
- fgetcwd = TRUE;
- break;
- }
- }
-
-#ifdef SIGINT
- usysdep_signal (SIGINT);
-#endif
-#ifdef SIGHUP
- usysdep_signal (SIGHUP);
-#endif
-#ifdef SIGQUIT
- usysdep_signal (SIGQUIT);
-#endif
-#ifdef SIGTERM
- usysdep_signal (SIGTERM);
-#endif
-#ifdef SIGPIPE
- usysdep_signal (SIGPIPE);
-#endif
-
- usysdep_initialize (puuconf, INIT_SUID | (fgetcwd ? INIT_GETCWD : 0));
-
- ulog_fatal_fn (ucabort);
-
- if (zCuser == NULL)
- zCuser = zsysdep_login_name ();
-
- iuuconf = uuconf_localname (puuconf, &zClocalname);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- zClocalname = zsysdep_localname ();
- if (zClocalname == NULL)
- exit (EXIT_FAILURE);
- }
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- /* Get the local system information. */
- iuuconf = uuconf_system_info (puuconf, zClocalname, &slocalsys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- iuuconf = uuconf_system_local (puuconf, &slocalsys);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- slocalsys.uuconf_zname = (char *) zClocalname;
- }
-
- /* If we are emulating uuto, translate the destination argument, and
- notify the destination user. This had better not turn into
- something that requires the current directory, or we may have
- passed INIT_GETCWD incorrectly. */
- if (fuuto)
- {
- if (*zCnotify == '\0')
- {
- zexclam = strrchr (argv[argc - 1], '!');
- if (zexclam == NULL)
- ucusage ();
- zCnotify = zexclam + 1;
- }
- argv[argc - 1] = zsysdep_uuto (argv[argc - 1], zClocalname);
- if (argv[argc - 1] == NULL)
- ucusage ();
- }
-
- /* Set up the file transfer options. */
- zoptions = abCsend_options;
- if (fCcopy)
- *zoptions++ = 'C';
- else
- *zoptions++ = 'c';
- if (fCmkdirs)
- *zoptions++ = 'd';
- else
- *zoptions++ = 'f';
- if (fCmail)
- *zoptions++ = 'm';
- if (*zCnotify != '\0')
- *zoptions++ = 'n';
- *zoptions = '\0';
-
- zoptions = abCrec_options;
- if (fCmkdirs)
- *zoptions++ = 'd';
- else
- *zoptions++ = 'f';
- if (fCmail)
- *zoptions++ = 'm';
- *zoptions = '\0';
-
- argv[argc - 1] = zremove_local_sys (&slocalsys, argv[argc - 1]);
-
- zexclam = strchr (argv[argc - 1], '!');
- if (zexclam == NULL)
- {
- zdestsys = zClocalname;
- zdestfile = argv[argc - 1];
- fClocaldest = TRUE;
- }
- else
- {
- size_t clen;
- char *zcopy;
-
- clen = zexclam - argv[argc - 1];
- zcopy = zbufalc (clen + 1);
- memcpy (zcopy, argv[argc - 1], clen);
- zcopy[clen] = '\0';
- zdestsys = zcopy;
-
- zdestfile = zexclam + 1;
-
- fClocaldest = FALSE;
- }
-
- iuuconf = uuconf_system_info (puuconf, zdestsys, &sCdestsys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (fClocaldest)
- {
- iuuconf = uuconf_system_local (puuconf, &sCdestsys);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- sCdestsys.uuconf_zname = (char *) zClocalname;
- }
- else
- {
- if (! funknown_system (puuconf, zdestsys, &sCdestsys))
- ulog (LOG_FATAL, "%s: System not found", zdestsys);
- }
- }
-
- /* Here zdestfile is the destination file name following the
- destination system name (if any); it may contain other systems to
- forward the files through. Isolate the file from the list of
- systems. */
- zexclam = strrchr (zdestfile, '!');
- if (zexclam == NULL)
- zCforward = NULL;
- else
- {
- size_t clen;
-
-#if DEBUG > 0
- if (fClocaldest)
- ulog (LOG_FATAL, "Can't happen");
-#endif
- clen = zexclam - zdestfile;
- zCforward = zbufalc (clen + 1);
- memcpy (zCforward, zdestfile, clen);
- zCforward[clen] = '\0';
- zdestfile = zexclam + 1;
- }
-
- /* Turn the destination into an absolute path, unless it is on a
- remote system and -W was used. */
- if (fClocaldest)
- zdestfile = zsysdep_local_file_cwd (zdestfile, sCdestsys.uuconf_zpubdir,
- (boolean *) NULL);
- else if (fCexpand)
- zdestfile = zsysdep_add_cwd (zdestfile);
- if (zdestfile == NULL)
- {
- ulog_close ();
- usysdep_exit (FALSE);
- }
-
- /* Process each source argument. */
- for (i = optind; i < argc - 1 && ! FGOT_SIGNAL (); i++)
- {
- boolean flocal;
- char *zfrom;
-
- fCneeds_cwd = FALSE;
-
- argv[i] = zremove_local_sys (&slocalsys, argv[i]);
-
- if (strchr (argv[i], '!') != NULL)
- {
- flocal = FALSE;
- zfrom = zbufcpy (argv[i]);
- }
- else
- {
- /* This is a local file. Make sure we get it out of the
- original directory. We don't support local wildcards,
- leaving that to the shell. */
- flocal = TRUE;
- if (fsysdep_needs_cwd (argv[i]))
- fCneeds_cwd = TRUE;
- zfrom = zsysdep_local_file_cwd (argv[i],
- sCdestsys.uuconf_zpubdir,
- (boolean *) NULL);
- if (zfrom == NULL)
- ucabort ();
- }
-
- if (! flocal || ! fsysdep_directory (zfrom))
- uccopy (zfrom, zdestfile);
- else
- {
- char *zbase, *zindir;
-
- if (! frecursive)
- ulog (LOG_FATAL, "%s: directory without -R", zfrom);
-
- zbase = zsysdep_base_name (zfrom);
- if (zbase == NULL)
- ucabort ();
- zindir = zsysdep_in_dir (zdestfile, zbase);
- ubuffree (zbase);
- if (zindir == NULL)
- ucabort ();
- usysdep_walk_tree (zfrom, ucdirfile, zindir);
- ubuffree (zindir);
- }
-
- ubuffree (zfrom);
- }
-
- /* See if we got an interrupt, presumably from the user. */
- if (FGOT_SIGNAL ())
- ucabort ();
-
- /* Now push out the actual commands, making log entries for them. */
- ulog_to_file (puuconf, TRUE);
- ulog_user (zCuser);
-
- ucspool_cmds (fjobid);
-
- ulog_close ();
-
- if (! fuucico)
- fexit = TRUE;
- else
- {
- const char *zsys;
- boolean fany;
-
- zsys = zcone_system (&fany);
-
- if (zsys == NULL && ! fany)
- fexit = TRUE;
- else
- {
- const char *zarg;
- char *zconfigarg;
-
- if (zsys == NULL)
- zarg = "-r1";
- else
- {
- char *z;
-
- z = zbufalc (sizeof "-Cs" + strlen (zsys));
- sprintf (z, "-Cs%s", zsys);
- zarg = z;
- }
-
- if (zconfig == NULL)
- zconfigarg = NULL;
- else
- {
- zconfigarg = zbufalc (sizeof "-I" + strlen (zconfig));
- sprintf (zconfigarg, "-I%s", zconfig);
- }
-
- fexit = fsysdep_run (FALSE, "uucico", zarg, zconfigarg);
- }
- }
-
- usysdep_exit (fexit);
-
- /* Avoid error about not returning. */
- return 0;
-}
-
-/* Print usage message and die. */
-
-static void
-ucusage ()
-{
- fprintf (stderr,
- "Usage: %s [options] file1 [file2 ...] dest\n", zProgram);
- fprintf (stderr, "Use %s --help for help\n", zProgram);
- exit (EXIT_FAILURE);
-}
-
-/* Print help message. */
-
-static void
-uchelp ()
-{
- printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- printf ("Usage: %s [options] file1 [file2 ...] dest\n", zProgram);
- printf (" -c,--nocopy: Do not copy local files to spool directory\n");
- printf (" -C,-p,--copy: Copy local files to spool directory (default)\n");
- printf (" -d,--directories: Create necessary directories (default)\n");
- printf (" -f,--nodirectories: Do not create directories (fail if they do not exist)\n");
- printf (" -g,--grade grade: Set job grade (must be alphabetic)\n");
- printf (" -m,--mail: Report status of copy by mail\n");
- printf (" -n,--notify user: Report status of copy by mail to remote user\n");
- printf (" -R,--recursive: Copy directories recursively\n");
- printf (" -r,--nouucico: Do not start uucico daemon\n");
- printf (" -s,--status file: Report completion status to file\n");
- printf (" -j,--jobid: Report job id\n");
- printf (" -W,--noexpand: Do not add current directory to remote filenames\n");
- printf (" -t,--uuto: Emulate uuto\n");
- printf (" -u,--usage name: Set user name\n");
- printf (" -x,--debug debug: Set debugging level\n");
-#if HAVE_TAYLOR_CONFIG
- printf (" -I,--config file: Set configuration file to use\n");
-#endif /* HAVE_TAYLOR_CONFIG */
- printf (" -v,--version: Print version and exit\n");
- printf (" --help: Print help and exit\n");
-}
-
-/* This is called for each file in a directory heirarchy. */
-
-static void
-ucdirfile (zfull, zrelative, pinfo)
- const char *zfull;
- const char *zrelative;
- pointer pinfo;
-{
- const char *zdestfile = (const char *) pinfo;
- char *zto;
-
- zto = zsysdep_in_dir (zdestfile, zrelative);
- if (zto == NULL)
- ucabort ();
-
- uccopy (zfull, zto);
-
- ubuffree (zto);
-}
-
-/* Handle the copying of one regular file. The zdest argument is the
- destination file; if we are recursively copying a directory, it
- will be extended by any subdirectory names. Note that zdest is an
- absolute path. */
-
-static void
-uccopy (zfile, zdest)
- const char *zfile;
- const char *zdest;
-{
- struct scmd s;
- char *zexclam;
- char *zto;
-
- zexclam = strchr (zfile, '!');
-
- if (zexclam == NULL)
- {
- openfile_t efrom;
-
- /* Copy from a local file. Make sure the user has access to
- this file, since we are running setuid. */
- if (! fsysdep_access (zfile))
- ucabort ();
-
- /* If this copy is being requested by a remote system, we may
- transfer the file if it needs the current working directory
- (meaning, I hope, that it is in the execution directory) or
- it is on the permitted transfer list. Note that unlike most
- of the other checks, this one is not double-checked by
- uucico. */
- if (fCremote
- && ! fCneeds_cwd
- && ! fin_directory_list (zfile, sCdestsys.uuconf_pzremote_send,
- sCdestsys.uuconf_zpubdir, TRUE,
- TRUE, (const char *) NULL))
- ulog (LOG_FATAL, "Not permitted to send %s", zfile);
-
- if (fClocaldest)
- {
- boolean fok;
-
- /* Copy one local file to another. */
-
- /* Check that we have permission to receive into the desired
- directory. */
- if (fCremote)
- fok = fin_directory_list (zdest,
- sCdestsys.uuconf_pzremote_receive,
- sCdestsys.uuconf_zpubdir, TRUE,
- FALSE, (const char *) NULL);
- else
- fok = fin_directory_list (zdest,
- sCdestsys.uuconf_pzlocal_receive,
- sCdestsys.uuconf_zpubdir, TRUE,
- FALSE, zCuser);
- if (! fok)
- ulog (LOG_FATAL, "Not permitted to receive to %s", zdest);
-
- zto = zsysdep_add_base (zdest, zfile);
- if (zto == NULL)
- ucabort ();
-
- efrom = esysdep_user_fopen (zfile, TRUE, TRUE);
- if (! ffileisopen (efrom))
- ucabort ();
- if (! fcopy_open_file (efrom, zto, FALSE, fCmkdirs, TRUE))
- ucabort ();
- (void) ffileclose (efrom);
- ubuffree (zto);
- }
- else
- {
- const char *zloc;
- char abtname[CFILE_NAME_LEN];
- unsigned int imode;
- char *ztemp;
-
- /* Copy a local file to a remote file. We may have to
- copy the local file to the spool directory. */
- imode = ixsysdep_file_mode (zfile);
- if (imode == 0)
- ucabort ();
-
- zloc = sCdestsys.uuconf_zlocalname;
- if (zloc == NULL)
- zloc = zClocalname;
-
- ztemp = zsysdep_data_file_name (&sCdestsys, zloc, bCgrade,
- FALSE, abtname, (char *) NULL,
- (char *) NULL);
- if (ztemp == NULL)
- ucabort ();
-
- if (! fCcopy)
- {
- /* If we are copying the file, we don't actually use the
- temporary file; we still want to get a name for the
- other system to use as a key for file restart. */
- ubuffree (ztemp);
-
- /* Make sure the daemon will be permitted to send
- this file. */
- if (! fsysdep_daemon_access (zfile))
- ucabort ();
- if (! fin_directory_list (zfile, sCdestsys.uuconf_pzlocal_send,
- sCdestsys.uuconf_zpubdir, TRUE, TRUE,
- (fCremote
- ? (const char *) NULL
- : zCuser)))
- ulog (LOG_FATAL,
- "Daemon not permitted to send %s (suggest --copy)",
- zfile);
- }
- else
- {
- efrom = esysdep_user_fopen (zfile, TRUE, TRUE);
- if (! ffileisopen (efrom))
- ucabort ();
- ucrecord_file (ztemp);
- if (! fcopy_open_file (efrom, ztemp, FALSE, TRUE, TRUE))
- ucabort ();
- (void) ffileclose (efrom);
- }
-
- if (zCforward == NULL)
- {
- /* We're not forwarding. Just send the file. */
- s.bcmd = 'S';
- s.bgrade = bCgrade;
- s.pseq = NULL;
- s.zfrom = zbufcpy (zfile);
- s.zto = zbufcpy (zdest);
- s.zuser = zCuser;
- s.zoptions = abCsend_options;
- s.ztemp = zbufcpy (abtname);
- s.imode = imode;
- s.znotify = zCnotify;
- s.cbytes = -1;
- s.zcmd = NULL;
- s.ipos = 0;
-
- ucadd_cmd (&sCdestsys, &s, (const char *) NULL);
- }
- else
- {
- char *zbase;
- char *zxqt;
- char abxtname[CFILE_NAME_LEN];
- char abdname[CFILE_NAME_LEN];
- char abxname[CFILE_NAME_LEN];
- FILE *e;
- char *zlog;
-
- /* We want to forward this file through sCdestsys to
- some other system(s). We set up a remote execution
- of uucp on sCdestsys to forward the file along. */
- zbase = zsysdep_base_name (zfile);
- if (zbase == NULL)
- ucabort ();
-
- zxqt = zsysdep_data_file_name (&sCdestsys, zloc, bCgrade,
- TRUE, abxtname, abdname,
- abxname);
- if (zxqt == NULL)
- ucabort ();
- e = esysdep_fopen (zxqt, FALSE, FALSE, TRUE);
- if (e == NULL)
- ucabort ();
- ucrecord_file (zxqt);
-
- fprintf (e, "U %s %s\n", zCuser, zloc);
- fprintf (e, "F %s %s\n", abdname, zbase);
- fprintf (e, "C uucp -C");
- if (fCmkdirs)
- fprintf (e, " -d");
- else
- fprintf (e, " -f");
- fprintf (e, " -g %c", bCgrade);
- if (fCmail)
- fprintf (e, " -m");
- if (*zCnotify != '\0')
- fprintf (e, " -n %s", zCnotify);
- if (! fCexpand)
- fprintf (e, " -W");
- fprintf (e, " %s %s!%s\n", zbase, zCforward, zdest);
-
- ubuffree (zbase);
-
- if (! fstdiosync (e, zxqt))
- ulog (LOG_FATAL, "fsync failed");
- if (fclose (e) != 0)
- ulog (LOG_FATAL, "fclose: %s", strerror (errno));
-
- /* Send the execution file. */
- s.bcmd = 'S';
- s.bgrade = bCgrade;
- s.pseq = NULL;
- s.zfrom = zbufcpy (abxtname);
- s.zto = zbufcpy (abxname);
- s.zuser = zCuser;
- s.zoptions = "C";
- s.ztemp = s.zfrom;
- s.imode = 0666;
- s.znotify = NULL;
- s.cbytes = -1;
- s.zcmd = NULL;
- s.ipos = 0;
-
- zlog = zbufalc (sizeof "Queuing uucp !" + strlen (zfile)
- + strlen (zCforward) + strlen (zdest));
- sprintf (zlog, "Queuing uucp %s %s!%s", zfile, zCforward,
- zdest);
-
- ucadd_cmd (&sCdestsys, &s, zlog);
-
- /* Send the data file. */
- s.bcmd = 'S';
- s.bgrade = bCgrade;
- s.pseq = NULL;
- s.zfrom = zbufcpy (zfile);
- s.zto = zbufcpy (abdname);
- s.zuser = zCuser;
- s.zoptions = fCcopy ? "C" : "c";
- s.ztemp = zbufcpy (abtname);
- s.imode = 0666;
- s.znotify = NULL;
- s.cbytes = -1;
- s.zcmd = NULL;
- s.ipos = 0;
-
- ucadd_cmd (&sCdestsys, &s, "");
- }
- }
- }
- else
- {
- char *zfrom;
- char *zforward;
- size_t clen;
- char *zcopy;
- struct uuconf_system *qfromsys;
- int iuuconf;
- const char *zloc;
-
- /* Copy from a remote file. Get the file name after any systems
- we may need to forward the file from. */
- zfrom = strrchr (zfile, '!');
- if (zfrom == zexclam)
- zforward = NULL;
- else
- {
- clen = zfrom - zexclam - 1;
- zforward = zbufalc (clen + 1);
- memcpy (zforward, zexclam + 1, clen);
- zforward[clen] = '\0';
- }
-
- ++zfrom;
- if (fCexpand)
- {
- /* Add the current directory to the filename if it's not
- already there. */
- zfrom = zsysdep_add_cwd (zfrom);
- if (zfrom == NULL)
- ucabort ();
- }
-
- /* Read the system information. */
- clen = zexclam - zfile;
- zcopy = zbufalc (clen + 1);
- memcpy (zcopy, zfile, clen);
- zcopy[clen] = '\0';
-
- qfromsys = ((struct uuconf_system *)
- xmalloc (sizeof (struct uuconf_system)));
-
- iuuconf = uuconf_system_info (pCuuconf, zcopy, qfromsys);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- if (! funknown_system (pCuuconf, zcopy, qfromsys))
- ulog (LOG_FATAL, "%s: System not found", zcopy);
- }
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, pCuuconf, iuuconf);
- ubuffree (zcopy);
-
- zloc = qfromsys->uuconf_zlocalname;
- if (zloc == NULL)
- zloc = zClocalname;
-
- if (zforward == NULL && fClocaldest)
- {
- boolean fok;
-
- /* The file is to come directly from qfromsys to the local
- system. */
-
- /* Check that we have permission to receive into the desired
- directory. If we don't have permission, uucico will
- fail. */
- if (fCremote)
- fok = fin_directory_list (zdest,
- qfromsys->uuconf_pzremote_receive,
- qfromsys->uuconf_zpubdir, TRUE,
- FALSE, (const char *) NULL);
- else
- fok = fin_directory_list (zdest,
- qfromsys->uuconf_pzlocal_receive,
- qfromsys->uuconf_zpubdir, TRUE,
- FALSE, zCuser);
- if (! fok)
- ulog (LOG_FATAL, "Not permitted to receive to %s", zdest);
-
- /* If the remote filespec is wildcarded, we must generate an
- 'X' request. We currently check for Unix shell
- wildcards. Note that it should do no harm to mistake a
- non-wildcard for a wildcard. */
- if (zfrom[strcspn (zfrom, "*?[")] != '\0')
- {
- s.bcmd = 'X';
- zto = zbufalc (strlen (zloc) + strlen (zdest) + sizeof "!");
- sprintf (zto, "%s!%s", zloc, zdest);
- }
- else
- {
- s.bcmd = 'R';
- zto = zbufcpy (zdest);
- }
-
- s.bgrade = bCgrade;
- s.pseq = NULL;
- s.zfrom = zfrom;
- s.zto = zto;
- s.zuser = zCuser;
- s.zoptions = abCrec_options;
- s.ztemp = "";
- s.imode = 0;
- s.znotify = "";
- s.cbytes = -1;
- s.zcmd = NULL;
- s.ipos = 0;
-
- ucadd_cmd (qfromsys, &s, (const char *) NULL);
- }
- else
- {
- char *zxqt;
- char abtname[CFILE_NAME_LEN];
- char abxname[CFILE_NAME_LEN];
- FILE *e;
- char *zcmd;
- char *zlog;
-
- /* The file either comes from some other system through
- qfromsys or is intended for some other system. Send an
- execution request to qfromsys to handle everything. */
- zxqt = zsysdep_data_file_name (qfromsys, zloc, bCgrade, TRUE,
- abtname, (char *) NULL,
- abxname);
- if (zxqt == NULL)
- ucabort ();
- e = esysdep_fopen (zxqt, FALSE, FALSE, TRUE);
- if (e == NULL)
- ucabort ();
- ucrecord_file (zxqt);
-
- fprintf (e, "U %s %s\n", zCuser, zloc);
- fprintf (e, "C uucp -C");
- if (fCmkdirs)
- fprintf (e, " -d");
- else
- fprintf (e, " -f");
- fprintf (e, " -g %c", bCgrade);
- if (fCmail)
- fprintf (e, " -m");
- if (*zCnotify != '\0')
- fprintf (e, " -n %s", zCnotify);
- if (! fCexpand)
- fprintf (e, " -W");
-
- clen = (strlen (zfrom) + strlen (zloc)
- + strlen (sCdestsys.uuconf_zname) + strlen (zdest));
- if (zforward != NULL)
- clen += strlen (zforward);
- if (zCforward != NULL)
- clen += strlen (zCforward);
- zcmd = zbufalc (sizeof "! !!!" + clen);
- *zcmd = '\0';
- if (zforward != NULL)
- sprintf (zcmd + strlen (zcmd), "%s!", zforward);
- sprintf (zcmd + strlen (zcmd), "%s %s!", zfrom, zloc);
- if (! fClocaldest)
- sprintf (zcmd + strlen (zcmd), "%s!", sCdestsys.uuconf_zname);
- if (zCforward != NULL)
- sprintf (zcmd + strlen (zcmd), "%s!", zCforward);
- sprintf (zcmd + strlen (zcmd), "%s", zdest);
-
- fprintf (e, " %s\n", zcmd);
-
- if (! fstdiosync (e, zxqt))
- ulog (LOG_FATAL, "fsync failed");
- if (fclose (e) != 0)
- ulog (LOG_FATAL, "fclose: %s", strerror (errno));
-
- /* Send the execution file. */
- s.bcmd = 'S';
- s.bgrade = bCgrade;
- s.pseq = NULL;
- s.zfrom = zbufcpy (abtname);
- s.zto = zbufcpy (abxname);
- s.zuser = zCuser;
- s.zoptions = "C";
- s.ztemp = s.zfrom;
- s.imode = 0666;
- s.znotify = NULL;
- s.cbytes = -1;
- s.zcmd = NULL;
- s.ipos = 0;
-
- zlog = zbufalc (sizeof "Queueing uucp " + strlen (zcmd));
- sprintf (zlog, "Queueing uucp %s", zcmd);
-
- ucadd_cmd (qfromsys, &s, zlog);
-
- ubuffree (zcmd);
- ubuffree (zforward);
- }
- }
-}
-
-/* We keep a list of jobs for each system. */
-
-struct sjob
-{
- struct sjob *qnext;
- const struct uuconf_system *qsys;
- int ccmds;
- struct scmd *pascmds;
- const char **pazlogs;
-};
-
-static struct sjob *qCjobs;
-
-static void
-ucadd_cmd (qsys, qcmd, zlog)
- const struct uuconf_system *qsys;
- const struct scmd *qcmd;
- const char *zlog;
-{
- struct sjob *qjob;
-
- if (! qsys->uuconf_fcall_transfer
- && ! qsys->uuconf_fcalled_transfer)
- ulog (LOG_FATAL, "Not permitted to transfer files to or from %s",
- qsys->uuconf_zname);
-
- for (qjob = qCjobs; qjob != NULL; qjob = qjob->qnext)
- if (strcmp (qjob->qsys->uuconf_zname, qsys->uuconf_zname) == 0)
- break;
-
- if (qjob == NULL)
- {
- qjob = (struct sjob *) xmalloc (sizeof (struct sjob));
- qjob->qnext = qCjobs;
- qjob->qsys = qsys;
- qjob->ccmds = 0;
- qjob->pascmds = NULL;
- qjob->pazlogs = NULL;
- qCjobs = qjob;
- }
-
- qjob->pascmds = ((struct scmd *)
- xrealloc ((pointer) qjob->pascmds,
- (qjob->ccmds + 1) * sizeof (struct scmd)));
- qjob->pascmds[qjob->ccmds] = *qcmd;
- qjob->pazlogs = ((const char **)
- xrealloc ((pointer) qjob->pazlogs,
- (qjob->ccmds + 1) * sizeof (const char *)));
- qjob->pazlogs[qjob->ccmds] = zlog;
- ++qjob->ccmds;
-}
-
-static void
-ucspool_cmds (fjobid)
- boolean fjobid;
-{
- struct sjob *qjob;
- char *zjobid;
-
- for (qjob = qCjobs; qjob != NULL; qjob = qjob->qnext)
- {
- ulog_system (qjob->qsys->uuconf_zname);
- zjobid = zsysdep_spool_commands (qjob->qsys, bCgrade, qjob->ccmds,
- qjob->pascmds);
- if (zjobid != NULL)
- {
- int i;
- struct scmd *qcmd;
- const char **pz;
-
- for (i = 0, qcmd = qjob->pascmds, pz = qjob->pazlogs;
- i < qjob->ccmds;
- i++, qcmd++, pz++)
- {
- if (*pz != NULL)
- {
- if (**pz != '\0')
- ulog (LOG_NORMAL, "%s", *pz);
- }
- else if (qcmd->bcmd == 'S')
- ulog (LOG_NORMAL, "Queuing send of %s to %s",
- qcmd->zfrom, qcmd->zto);
- else if (qcmd->bcmd == 'R')
- ulog (LOG_NORMAL, "Queuing request of %s to %s",
- qcmd->zfrom, qcmd->zto);
- else
- {
- const char *zto;
-
- zto = strrchr (qcmd->zto, '!');
- if (zto != NULL)
- ++zto;
- else
- zto = qcmd->zto;
- ulog (LOG_NORMAL, "Queuing request of %s to %s",
- qcmd->zfrom, zto);
- }
- }
-
- if (fjobid)
- printf ("%s\n", zjobid);
-
- ubuffree (zjobid);
- }
- }
-}
-
-/* Return the system name for which we have created commands, or NULL
- if we've created commands for more than one system. Set *pfany to
- FALSE if we didn't create work for any system. */
-
-static const char *
-zcone_system (pfany)
- boolean *pfany;
-{
- if (qCjobs == NULL)
- {
- *pfany = FALSE;
- return NULL;
- }
-
- *pfany = TRUE;
-
- if (qCjobs->qnext == NULL)
- return qCjobs->qsys->uuconf_zname;
- else
- return NULL;
-}
-
-/* Keep track of all files we have created so that we can delete them
- if we get a signal. The argument will be on the heap. */
-
-static int cCfiles;
-static const char **pCaz;
-
-static void
-ucrecord_file (zfile)
- const char *zfile;
-{
- pCaz = (const char **) xrealloc ((pointer) pCaz,
- (cCfiles + 1) * sizeof (const char *));
- pCaz[cCfiles] = zfile;
- ++cCfiles;
-}
-
-/* Delete all the files we have recorded and exit. */
-
-static void
-ucabort ()
-{
- int i;
-
- for (i = 0; i < cCfiles; i++)
- (void) remove (pCaz[i]);
- ulog_close ();
- usysdep_exit (FALSE);
-}
diff --git a/gnu/libexec/uucp/uulog/Makefile b/gnu/libexec/uucp/uulog/Makefile
deleted file mode 100644
index f9fd5a5..0000000
--- a/gnu/libexec/uucp/uulog/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# Makefile for uulog
-# $Id: Makefile,v 1.3 1997/02/22 15:28:41 peter Exp $
-
-BINDIR= $(bindir)
-
-PROG= uulog
-SRCS= uulog.c log.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -DVERSION=\"$(VERSION)\"
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../common_sources
diff --git a/gnu/libexec/uucp/uulog/uulog.1 b/gnu/libexec/uucp/uulog/uulog.1
deleted file mode 100644
index ef4d7c7..0000000
--- a/gnu/libexec/uucp/uulog/uulog.1
+++ /dev/null
@@ -1,84 +0,0 @@
-''' $Id: uustat.1,v 1.8 1997/02/22 15:28:49 peter Exp $
-.TH uulog 1 "Taylor UUCP 1.06"
-.SH NAME
-uulog \- display UUCP log entries
-.SH SYNOPSIS
-.B uulog
-[-#] [-n lines] [-sf system] [-u user] [-DSF] [--lines lines]
-[--system system] [--user user] [--debuglog] [--statslog]
-[--follow] [--follow=system] [standard UUCP options]
-.SH DESCRIPTION
-The
-.B uulog
-program can be used to display entries in the UUCP log
-file. It can select the entries for a particular system or a
-particular user. You can use it to see what has happened to your
-queued jobs in the past.
-.SH OPTIONS
-The following options may be given to
-.B uuname.
-.TP 5
-.B \-#, \-n lines, \-\-lines lines
-Here `#' is a number; e.g., `-10'. The specified number of lines
-is displayed from the end of the log file. The default is to
-display the entire log file, unless the `-f', `-F', or `--follow'
-options are used, in which case the default is to display 10 lines.
-.TP 5
-.B \-s system, \-\-system system
-Display only log entries pertaining to the specified system.
-.TP 5
-.B \-u user, \-\-user user
-Display only log entries pertaining to the specified user.
-.TP 5
-.B \-D, \-\-debuglog
-Display the debugging log file.
-.TP 5
-.B \-S, \-\-statslog
-Display the statistics log file.
-.B \-F, \-\-follow
-Keep displaying the log file forever, printing new lines as they
-are appended to the log file.
-.TP 5
-.B \-f system, \-\-follow=system
-Keep displaying the log file forever, displaying only log entries
-pertaining to the specified system.
-.TP 5
-.B \-X type
-.TP 5
-.B \-\-debug type
-.TP 5
-.B \-I file
-.TP 5
-.B \-\-config file
-.TP 5
-.B \-v, \-\-version
-.TP 5
-.B \-\-help
-Standard UUCP options.
-Note that
-.B uulog
-specifies the debugging type using `-X' rather than the usual `-x'.
-.PP
-The operation of
-.B uulog
-depends to some degree upon the type of log
-files generated by the UUCP programs. This is a compile time option.
-If the UUCP programs have been compiled to use HDB style log files,
-.B uulog
-changes in the following ways:
-.PP
-The new options `-x' and `--uuxqtlog' may be used to list the
-.B uuxqt
-log file.
-.PP
-It is no longer possible to omit all arguments: one of `-s',
-`--system', `-f', `--follow=system', `-D', `--debuglog', `-S',
-`--statslog', `-x', or `--uuxqtlog' must be used.
-.PP
-The option `--system ANY' may be used to list log file entries
-which do not pertain to any particular system.
-.SH SEE ALSO
-uucp(1)
-.SH AUTHOR
-Ian Lance Taylor (ian@airs.com).
-This Manpage based on the Taylor UUCP 1.06 Texinfo documentation.
diff --git a/gnu/libexec/uucp/uulog/uulog.c b/gnu/libexec/uucp/uulog/uulog.c
deleted file mode 100644
index 3174172..0000000
--- a/gnu/libexec/uucp/uulog/uulog.c
+++ /dev/null
@@ -1,492 +0,0 @@
-/* uulog.c
- Display the UUCP log file.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char uulog_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-#include "getopt.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-
-/* This is a pretty bad implementation of uulog, which I don't think
- is a very useful program anyhow. It only takes a single -s and/or
- -u switch. When using HAVE_HDB_LOGGING it requires a system. */
-
-/* Local functions. */
-
-static void ulusage P((void));
-static void ulhelp P((void));
-
-/* Long getopt options. */
-static const struct option asLlongopts[] =
-{
- { "debuglog", no_argument, NULL, 'D' },
- { "follow", optional_argument, NULL, 2 },
- { "lines", required_argument, NULL, 'n' },
- { "system", required_argument, NULL, 's' },
- { "statslog", no_argument, NULL, 'S' },
- { "user", required_argument, NULL, 'u' },
- { "uuxqtlog", no_argument, NULL, 'x' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'X' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- /* -D: display Debug file */
- boolean fdebug = FALSE;
- /* -f: keep displaying lines forever. */
- boolean fforever = FALSE;
- /* -n lines: number of lines to display. */
- int cshow = 0;
- /* -s: system name. */
- const char *zsystem = NULL;
- /* -S: display Stats file */
- boolean fstats = FALSE;
- /* -u: user name. */
- const char *zuser = NULL;
- /* -I: configuration file name. */
- const char *zconfig = NULL;
- /* -x: display uuxqt log file. */
- boolean fuuxqt = FALSE;
- int i;
- int iopt;
- pointer puuconf;
- int iuuconf;
- const char *zlogfile;
- const char *zstatsfile;
- const char *zdebugfile;
- const char *zfile;
- FILE *e;
- char **pzshow = NULL;
- int ishow = 0;
- size_t csystem = 0;
- size_t cuser = 0;
- char *zline;
- size_t cline;
-
- zProgram = argv[0];
-
- /* Look for a straight number argument, and convert it to -n before
- passing the arguments to getopt. */
- for (i = 0; i < argc; i++)
- {
- if (argv[i][0] == '-' && isdigit (argv[i][1]))
- {
- size_t clen;
- char *znew;
-
- clen = strlen (argv[i]);
- znew = zbufalc (clen + 2);
- znew[0] = '-';
- znew[1] = 'n';
- memcpy (znew + 2, argv[i] + 1, clen);
- argv[i] = znew;
- }
- }
-
- while ((iopt = getopt_long (argc, argv, "Df:FI:n:s:Su:vxX:", asLlongopts,
- (int *) NULL)) != EOF)
- {
- switch (iopt)
- {
- case 'D':
- /* Show debugging file. */
- fdebug = TRUE;
- break;
-
- case 'f':
- /* Keep displaying lines forever for a particular system. */
- fforever = TRUE;
- zsystem = optarg;
- if (cshow == 0)
- cshow = 10;
- break;
-
- case 'F':
- /* Keep displaying lines forever. */
- fforever = TRUE;
- if (cshow == 0)
- cshow = 10;
- break;
-
- case 'I':
- /* Configuration file name. */
- if (fsysdep_other_config (optarg))
- zconfig = optarg;
- break;
-
- case 'n':
- /* Number of lines to display. */
- cshow = (int) strtol (optarg, (char **) NULL, 10);
- break;
-
- case 's':
- /* System name. */
- zsystem = optarg;
- break;
-
- case 'S':
- /* Show statistics file. */
- fstats = TRUE;
- break;
-
- case 'u':
- /* User name. */
- zuser = optarg;
- break;
-
- case 'x':
- /* Display uuxqt log file. */
- fuuxqt = TRUE;
- break;
-
- case 'X':
-#if DEBUG > 1
- /* Set debugging level. */
- iDebug |= idebug_parse (optarg);
-#endif
- break;
-
- case 'v':
- /* Print version and exit. */
- printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zProgram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 2:
- /* --follow. */
- fforever = TRUE;
- if (cshow == 0)
- cshow = 10;
- if (optarg != NULL)
- zsystem = optarg;
- break;
-
- case 1:
- /* --help. */
- ulhelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found and flag set. */
- break;
-
- default:
- ulusage ();
- /*NOTREACHED*/
- }
- }
-
- if (optind != argc || (fstats && fdebug))
- ulusage ();
-
- iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
-#if DEBUG > 1
- {
- const char *zdebug;
-
- iuuconf = uuconf_debuglevel (puuconf, &zdebug);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (zdebug != NULL)
- iDebug |= idebug_parse (zdebug);
- }
-#endif
-
- iuuconf = uuconf_logfile (puuconf, &zlogfile);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- iuuconf = uuconf_statsfile (puuconf, &zstatsfile);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- iuuconf = uuconf_debugfile (puuconf, &zdebugfile);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- usysdep_initialize (puuconf, INIT_NOCHDIR);
-
- if (zsystem != NULL)
- {
-#if HAVE_HDB_LOGGING
- if (strcmp (zsystem, "ANY") != 0)
-#endif
- {
- struct uuconf_system ssys;
-
- /* Canonicalize the system name. If we can't find the
- system information, just use whatever we were given so
- that people can check on systems that logged in
- anonymously. */
- iuuconf = uuconf_system_info (puuconf, zsystem, &ssys);
- if (iuuconf == UUCONF_SUCCESS)
- {
- zsystem = zbufcpy (ssys.uuconf_zname);
- (void) uuconf_system_free (puuconf, &ssys);
- }
- }
- }
-
- if (fstats)
- zfile = zstatsfile;
- else if (fdebug)
- zfile = zdebugfile;
- else
- {
-#if ! HAVE_HDB_LOGGING
- zfile = zlogfile;
-#else
- const char *zprogram;
- char *zalc;
-
- /* We need a system to find a HDB log file. */
- if (zsystem == NULL)
- ulog (LOG_FATAL,
- "system name (-s argument) required for HDB format log files");
-
- if (fuuxqt)
- zprogram = "uuxqt";
- else
- zprogram = "uucico";
-
- zalc = zbufalc (strlen (zlogfile)
- + strlen (zprogram)
- + strlen (zsystem)
- + 1);
- sprintf (zalc, zlogfile, zprogram, zsystem);
- zfile = zalc;
-
- if (! fsysdep_file_exists (zfile))
- ulog (LOG_FATAL, "no log file available for system %s", zsystem);
-
- if (strcmp (zsystem, "ANY") == 0)
- zsystem = NULL;
-#endif
- }
-
- e = fopen (zfile, "r");
- if (e == NULL)
- {
- ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno));
- usysdep_exit (FALSE);
- }
-
- if (cshow > 0)
- {
- pzshow = (char **) xmalloc (cshow * sizeof (char *));
- for (ishow = 0; ishow < cshow; ishow++)
- pzshow[ishow] = NULL;
- ishow = 0;
- }
-
- /* Read the log file and output the appropriate lines. */
- if (zsystem != NULL)
- csystem = strlen (zsystem);
-
- if (zuser != NULL)
- cuser = strlen (zuser);
-
- zline = NULL;
- cline = 0;
-
- while (TRUE)
- {
- while (getline (&zline, &cline, e) > 0)
- {
- char *zluser, *zlsys, *znext;
- size_t cluser, clsys;
-
- /* Skip any leading whitespace (not that there should be
- any). */
- znext = zline + strspn (zline, " \t");
-
- if (! fstats)
- {
-#if ! HAVE_TAYLOR_LOGGING
- /* The user name is the first field on the line. */
- zluser = znext;
- cluser = strcspn (znext, " \t");
-#endif
-
- /* Skip the first field. */
- znext += strcspn (znext, " \t");
- znext += strspn (znext, " \t");
-
- /* The system is the second field on the line. */
- zlsys = znext;
- clsys = strcspn (znext, " \t");
-
- /* Skip the second field. */
- znext += clsys;
- znext += strspn (znext, " \t");
-
-#if HAVE_TAYLOR_LOGGING
- /* The user is the third field on the line. */
- zluser = znext;
- cluser = strcspn (znext, " \t");
-#endif
- }
- else
- {
-#if ! HAVE_HDB_LOGGING
- /* The user name is the first field on the line, and the
- system name is the second. */
- zluser = znext;
- cluser = strcspn (znext, " \t");
- znext += cluser;
- znext += strspn (znext, " \t");
- zlsys = znext;
- clsys = strcspn (znext, " \t");
-#else
- /* The first field is system!user. */
- zlsys = znext;
- clsys = strcspn (znext, "!");
- znext += clsys + 1;
- zluser = znext;
- cluser = strcspn (znext, " \t");
-#endif
- }
-
- /* See if we should print this line. */
- if (zsystem != NULL
- && (csystem != clsys
- || strncmp (zsystem, zlsys, clsys) != 0))
- continue;
-
- if (zuser != NULL
- && (cuser != cluser
- || strncmp (zuser, zluser, cluser) != 0))
- continue;
-
- /* Output the line, or save it if we are outputting only a
- particular number of lines. */
- if (cshow <= 0)
- printf ("%s", zline);
- else
- {
- ubuffree ((pointer) pzshow[ishow]);
- pzshow[ishow] = zbufcpy (zline);
- ishow = (ishow + 1) % cshow;
- }
- }
-
- /* Output the number of lines requested by the -n option. */
- if (cshow > 0)
- {
- for (i = 0; i < cshow; i++)
- {
- if (pzshow[ishow] != NULL)
- printf ("%s", pzshow[ishow]);
- ishow = (ishow + 1) % cshow;
- }
- }
-
- /* If -f was not specified, or an error occurred while reading
- the file, get out. */
- if (! fforever || ferror (e))
- break;
-
- clearerr (e);
- cshow = 0;
-
- /* Sleep 1 second before going around the loop again. */
- usysdep_sleep (1);
- }
-
- (void) fclose (e);
-
- ulog_close ();
-
- usysdep_exit (TRUE);
-
- /* Avoid errors about not returning a value. */
- return 0;
-}
-
-/* Print a usage message and die. */
-
-static void
-ulusage ()
-{
- fprintf (stderr,
- "Usage: %s [-n #] [-sf system] [-u user] [-xDSF] [-I file] [-X debug]\n",
- zProgram);
- fprintf (stderr, "Use %s --help for help\n", zProgram);
- exit (EXIT_FAILURE);
-}
-
-/* Print a help message. */
-
-static void
-ulhelp ()
-{
- printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
-#if HAVE_HDB_LOGGING
- printf ("Usage: %s [-n #] [-sf system] [-u user] [-xDS] [-I file] [-X debug]\n",
- zProgram);
-#else
- printf ("Usage: %s [-n #] [-sf system] [-u user] [-DSF] [-I file] [-X debug]\n",
- zProgram);
-#endif
- printf (" -n,--lines: show given number of lines from end of log\n");
- printf (" -s,--system: print entries for named system\n");
- printf (" -f system,--follow=system: follow entries for named system\n");
- printf (" -u,--user user: print entries for named user\n");
-#if HAVE_HDB_LOGGING
- printf (" -x,--uuxqt: print uuxqt log rather than uucico log\n");
-#else
- printf (" -F,--follow: follow entries for any system\n");
-#endif
- printf (" -S,--statslog: show statistics file\n");
- printf (" -D,--debuglog: show debugging file\n");
- printf (" -X,--debug debug: Set debugging level\n");
-#if HAVE_TAYLOR_CONFIG
- printf (" -I,--config file: Set configuration file to use\n");
-#endif /* HAVE_TAYLOR_CONFIG */
- printf (" -v,--version: Print version and exit\n");
- printf (" --help: Print help and exit\n");
-}
diff --git a/gnu/libexec/uucp/uuname/Makefile b/gnu/libexec/uucp/uuname/Makefile
deleted file mode 100644
index ea701b6..0000000
--- a/gnu/libexec/uucp/uuname/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# Makefile for uuname
-# $Id: Makefile,v 1.3 1997/02/22 15:28:43 peter Exp $
-
-BINDIR= $(bindir)
-BINOWN= $(owner)
-BINMODE= 4555
-
-PROG= uuname
-SRCS= uuname.c log.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -DVERSION=\"$(VERSION)\"
-
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../common_sources
diff --git a/gnu/libexec/uucp/uuname/uuname.1 b/gnu/libexec/uucp/uuname/uuname.1
deleted file mode 100644
index 3ae8e12..0000000
--- a/gnu/libexec/uucp/uuname/uuname.1
+++ /dev/null
@@ -1,45 +0,0 @@
-''' $Id: uustat.1,v 1.8 1997/02/22 15:28:49 peter Exp $
-.TH uuname 1 "Taylor UUCP 1.06"
-.SH NAME
-uuname \- list known remote UUCP sites
-.SH SYNOPSIS
-.B uuname
-[-a] [-l] [standard UUCP options]
-.SH DESCRIPTION
-The
-.B uuname
-program by default lists all the remote systems your
-system knows about. You can also use it to get the name of your
-local system. It is mostly useful for shell scripts.
-.SH OPTIONS
-The following options may be given to
-.B uuname.
-.TP 5
-.B \-a, \-\-aliases
-List all aliases for remote systems, as well as their canonical
-names. Aliases may be specified in the
-.I sys
-file.
-.TP 5
-.B \-l, \-\-local
-Print the UUCP name of the local system, rather than listing the
-names of all the remote systems.
-.TP 5
-.B \-x type
-.TP 5
-.B \-\-debug type
-.TP 5
-.B \-I file
-.TP 5
-.B \-\-config file
-.TP 5
-.B \-v, \-\-version
-.TP 5
-.B \-\-help
-Standard UUCP options.
-.SH SEE ALSO
-uucp(1)
-.SH AUTHOR
-Ian Lance Taylor (ian@airs.com).
-This Manpage based on the Taylor UUCP 1.06 Texinfo documentation.
-
diff --git a/gnu/libexec/uucp/uuname/uuname.c b/gnu/libexec/uucp/uuname/uuname.c
deleted file mode 100644
index 42fdc61..0000000
--- a/gnu/libexec/uucp/uuname/uuname.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/* uuname.c
- List the names of known remote UUCP sites.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char uuname_rcsid[] = "$Id$";
-#endif
-
-#include "getopt.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-
-/* Local functions. */
-
-static void unusage P((void));
-static void unhelp P((void));
-
-/* Long getopt options. */
-static const struct option asNlongopts[] =
-{
- { "aliases", no_argument, NULL, 'a' },
- { "local", no_argument, NULL, 'l' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'x' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- /* -a: display aliases. */
- boolean falias = FALSE;
- /* -l: if true, output local node name. */
- boolean flocal = FALSE;
- /* -I: configuration file name. */
- const char *zconfig = NULL;
- int iopt;
- pointer puuconf;
- int iuuconf;
-
- zProgram = argv[0];
-
- while ((iopt = getopt_long (argc, argv, "alI:vx:", asNlongopts,
- (int *) NULL)) != EOF)
- {
- switch (iopt)
- {
- case 'a':
- /* Display aliases. */
- falias = TRUE;
- break;
-
- case 'l':
- /* Output local node name. */
- flocal = TRUE;
- break;
-
- case 'I':
- /* Configuration file name. */
- if (fsysdep_other_config (optarg))
- zconfig = optarg;
- break;
-
- case 'x':
-#if DEBUG > 1
- /* Set debugging level. */
- iDebug |= idebug_parse (optarg);
-#endif
- break;
-
- case 'v':
- /* Print version and exit. */
- printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zProgram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 1:
- /* --help. */
- unhelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found and flag set. */
- break;
-
- default:
- unusage ();
- /*NOTREACHED*/
- }
- }
-
- if (optind != argc)
- unusage ();
-
- iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
-#if DEBUG > 1
- {
- const char *zdebug;
-
- iuuconf = uuconf_debuglevel (puuconf, &zdebug);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (zdebug != NULL)
- iDebug |= idebug_parse (zdebug);
- }
-#endif
-
- usysdep_initialize (puuconf, INIT_SUID | INIT_NOCHDIR);
-
- if (flocal)
- {
- const char *zlocalname;
-
- iuuconf = uuconf_localname (puuconf, &zlocalname);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- zlocalname = zsysdep_localname ();
- if (zlocalname == NULL)
- usysdep_exit (FALSE);
- }
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- printf ("%s\n", zlocalname);
- }
- else
- {
- char **pznames, **pz;
-
- iuuconf = uuconf_system_names (puuconf, &pznames, falias);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- for (pz = pznames; *pz != NULL; pz++)
- printf ("%s\n", *pz);
- }
-
- usysdep_exit (TRUE);
-
- /* Avoid warnings about not returning a value. */
- return 0;
-}
-
-/* Print a usage message and die. */
-
-static void
-unusage ()
-{
- fprintf (stderr,
- "Usage: %s [-a] [-l] [-I file]\n", zProgram);
- fprintf (stderr, "Use %s --help for help\n", zProgram);
- exit (EXIT_FAILURE);
-}
-
-/* Print a help message. */
-
-static void unhelp ()
-{
- printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- printf ("Usage: %s [-a] [-l] [-I file]\n", zProgram);
- printf (" -a,--aliases: display aliases\n");
- printf (" -l,--local: print local name\n");
-#if HAVE_TAYLOR_CONFIG
- printf (" -I,--config file: Set configuration file to use\n");
-#endif /* HAVE_TAYLOR_CONFIG */
- printf (" -v,--version: Print version and exit\n");
- printf (" --help: Print help and exit\n");
-}
diff --git a/gnu/libexec/uucp/uupick/Makefile b/gnu/libexec/uucp/uupick/Makefile
deleted file mode 100644
index 717dc8a..0000000
--- a/gnu/libexec/uucp/uupick/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# Makefile for uupick
-# $Id: Makefile,v 1.3 1997/02/22 15:28:45 peter Exp $
-
-BINDIR= $(bindir)
-
-PROG= uupick
-SRCS= uupick.c log.c copy.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -DVERSION=\"$(VERSION)\"
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../common_sources
diff --git a/gnu/libexec/uucp/uupick/uupick.1 b/gnu/libexec/uucp/uupick/uupick.1
deleted file mode 100644
index 0933cbc..0000000
--- a/gnu/libexec/uucp/uupick/uupick.1
+++ /dev/null
@@ -1,72 +0,0 @@
-''' $Id: uustat.1,v 1.8 1997/02/22 15:28:49 peter Exp $
-.TH uupick 1 "Taylor UUCP 1.06"
-.SH NAME
-uupick \- retrieve files transferred by uuto
-.SH SYNOPSIS
-.B uupick
-[\-s] [standard UUCP options]
-.SH DESCRIPTION
-The
-.B uupick
-program is used to conveniently retrieve files
-transferred by the
-.B uuto(1)
-program.
-For each file transferred by
-.B uuto(1),
-.B uupick
-will display the
-source system, the file name, and whether the name refers to a regular
-file or a directory. It will then wait for the user to specify an
-action to take. One of the following commands must be entered:
-.TP 5
-.I q
-Quit out of
-.B uupick.
-.TP 5
-.I RETURN
-Skip the file.
-.TP 5
-.I m [directory]
-Move the file or directory to the specified directory. If no
-directory is specified, the file is moved to the current directory.
-.TP 5
-.I a [directory]
-Move all files from this system to the specified directory. If no
-directory is specified, the files are moved to the current
-directory.
-.TP 5
-.I p
-List the file on standard output.
-.TP 5
-.I d
-Delete the file.
-.TP 5
-.I ! [command]
-Execute `command' as a shell escape.
-.SH OPTIONS
-The following options may be given to
-.B uupick.
-.TP 5
-.B \-s, \-\-system system
-This option may be used to restrict
-.B uupick
-to only present files transferred from a particular system.
-.TP 5
-.B \-x type
-.TP 5
-.B \-\-debug type
-.TP 5
-.B \-I file
-.TP 5
-.B \-\-config file
-.TP 5
-.B \-v, \-\-version
-.TP 5
-.B \-\-help
-Standard UUCP options.
-.SH SEE ALSO
-uucp(1), uuto(1)
-.SH AUTHOR
-Ian Lance Taylor (ian@airs.com).
-This Manpage based on the Taylor UUCP 1.06 Texinfo documentation.
diff --git a/gnu/libexec/uucp/uupick/uupick.c b/gnu/libexec/uucp/uupick/uupick.c
deleted file mode 100644
index f34943e..0000000
--- a/gnu/libexec/uucp/uupick/uupick.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/* uupick.c
- Get files stored in the public directory by uucp -t.
-
- Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char uupick_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-
-#include "getopt.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-
-/* Local functions. */
-
-static void upmovedir P((const char *zfull, const char *zrelative,
- pointer pinfo));
-static void upmove P((const char *zfrom, const char *zto));
-
-/* Long getopt options. */
-static const struct option asPlongopts[] =
-{
- { "system", required_argument, NULL, 's' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'x' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-/* Local functions. */
-
-static void upusage P((void));
-static void uphelp P((void));
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- /* -s: system name. */
- const char *zsystem = NULL;
- /* -I: configuration file name. */
- const char *zconfig = NULL;
- int iopt;
- pointer puuconf;
- int iuuconf;
- const char *zpubdir;
- char *zfile, *zfrom, *zfull;
- char *zallsys;
- char ab[1000];
- boolean fquit;
-
- zProgram = "uupick";
-
- while ((iopt = getopt_long (argc, argv, "I:s:vx:", asPlongopts,
- (int *) NULL)) != EOF)
- {
- switch (iopt)
- {
- case 's':
- /* System name to get files from. */
- zsystem = optarg;
- break;
-
- case 'I':
- /* Name configuration file. */
- if (fsysdep_other_config (optarg))
- zconfig = optarg;
- break;
-
- case 'x':
-#if DEBUG > 1
- /* Set debugging level. */
- iDebug |= idebug_parse (optarg);
-#endif
- break;
-
- case 'v':
- /* Print version and exit. */
- fprintf
- (stderr,
- "%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zProgram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 1:
- /* --help. */
- uphelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found and flag set. */
- break;
-
- default:
- upusage ();
- /*NOTREACHED*/
- }
- }
-
- if (argc != optind)
- upusage ();
-
- iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- usysdep_initialize (puuconf, INIT_GETCWD | INIT_NOCHDIR);
-
- zpubdir = NULL;
- if (zsystem != NULL)
- {
- struct uuconf_system ssys;
-
- /* Get the public directory for the system. If we can't find
- the system information, just use the standard public
- directory, since uupick is not setuid. */
- iuuconf = uuconf_system_info (puuconf, zsystem, &ssys);
- if (iuuconf == UUCONF_SUCCESS)
- {
- zpubdir = zbufcpy (ssys.uuconf_zpubdir);
- (void) uuconf_system_free (puuconf, &ssys);
- }
- }
- if (zpubdir == NULL)
- {
- iuuconf = uuconf_pubdir (puuconf, &zpubdir);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- }
-
- if (! fsysdep_uupick_init (zsystem, zpubdir))
- usysdep_exit (FALSE);
-
- zallsys = NULL;
- fquit = FALSE;
-
- while (! fquit
- && ((zfile = zsysdep_uupick (zsystem, zpubdir, &zfrom, &zfull))
- != NULL))
- {
- boolean fdir;
- char *zto, *zlocal;
- FILE *e;
- boolean fcontinue;
-
- fdir = fsysdep_directory (zfull);
-
- do
- {
- boolean fbadname;
-
- fcontinue = FALSE;
-
- if (zallsys == NULL
- || strcmp (zallsys, zfrom) != 0)
- {
- if (zallsys != NULL)
- {
- ubuffree (zallsys);
- zallsys = NULL;
- }
-
- printf ("from %s: %s %s ?\n", zfrom, fdir ? "dir" : "file",
- zfile);
-
- if (fgets (ab, sizeof ab, stdin) == NULL)
- break;
- }
-
- if (ab[0] == 'q')
- {
- fquit = TRUE;
- break;
- }
-
- switch (ab[0])
- {
- case '\n':
- break;
-
- case 'd':
- if (fdir)
- (void) fsysdep_rmdir (zfull);
- else
- {
- if (remove (zfull) != 0)
- ulog (LOG_ERROR, "remove (%s): %s", zfull,
- strerror(errno));
- }
- break;
-
- case 'm':
- case 'a':
- zto = ab + 1 + strspn (ab + 1, " \t");
- zto[strcspn (zto, " \t\n")] = '\0';
- zlocal = zsysdep_uupick_local_file (zto, &fbadname);
- if (zlocal == NULL)
- {
- if (! fbadname)
- usysdep_exit (FALSE);
- ulog (LOG_ERROR, "%s: bad local file name", zto);
- fcontinue = TRUE;
- break;
- }
- zto = zsysdep_in_dir (zlocal, zfile);
- ubuffree (zlocal);
- if (zto == NULL)
- usysdep_exit (FALSE);
- if (! fdir)
- upmove (zfull, zto);
- else
- {
- usysdep_walk_tree (zfull, upmovedir, (pointer) zto);
- (void) fsysdep_rmdir (zfull);
- }
- ubuffree (zto);
-
- if (ab[0] == 'a')
- {
- zallsys = zbufcpy (zfrom);
- ab[0] = 'm';
- }
-
- break;
-
- case 'p':
- if (fdir)
- ulog (LOG_ERROR, "Can't print directory");
- else
- {
- e = fopen (zfull, "r");
- if (e == NULL)
- ulog (LOG_ERROR, "fopen (%s): %s", zfull,
- strerror (errno));
- else
- {
- while (fgets (ab, sizeof ab, e) != NULL)
- (void) fputs (ab, stdout);
- (void) fclose (e);
- }
- }
- fcontinue = TRUE;
- break;
-
- case '!':
- (void) system (ab + 1);
- fcontinue = TRUE;
- break;
-
- default:
- printf ("uupick commands:\n");
- printf ("q: quit\n");
- printf ("<return>: skip file\n");
- printf ("m [dir]: move file to directory\n");
- printf ("a [dir]: move all files from this system to directory\n");
- printf ("p: list file to stdout\n");
- printf ("d: delete file\n");
- printf ("! command: shell escape\n");
- fcontinue = TRUE;
- break;
- }
- }
- while (fcontinue);
-
- ubuffree (zfull);
- ubuffree (zfrom);
- ubuffree (zfile);
- }
-
- (void) fsysdep_uupick_free (zsystem, zpubdir);
-
- usysdep_exit (TRUE);
-
- /* Avoid error about not returning. */
- return 0;
-}
-
-/* Print usage message and die. */
-
-static void
-upusage ()
-{
- fprintf (stderr,
- "Usage: %s [-s system] [-I config] [-x debug]\n", zProgram);
- fprintf (stderr, "Use %s --help for help\n", zProgram);
- exit (EXIT_FAILURE);
-}
-
-/* Print help message. */
-
-static void
-uphelp ()
-{
- fprintf (stderr,
- "Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- fprintf (stderr,
- " -s,--system system: Only consider files from named system\n");
- fprintf (stderr,
- " -x,--debug debug: Set debugging level\n");
-#if HAVE_TAYLOR_CONFIG
- fprintf (stderr,
- " -I,--config file: Set configuration file to use\n");
-#endif /* HAVE_TAYLOR_CONFIG */
- fprintf (stderr,
- " -v,--version: Print version and exit\n");
- fprintf (stderr,
- " --help: Print help and exit\n");
-}
-
-/* This routine is called by usysdep_walk_tree when moving the
- contents of an entire directory. */
-
-static void
-upmovedir (zfull, zrelative, pinfo)
- const char *zfull;
- const char *zrelative;
- pointer pinfo;
-{
- const char *ztodir = (const char *) pinfo;
- char *zto;
-
- zto = zsysdep_in_dir (ztodir, zrelative);
- if (zto == NULL)
- usysdep_exit (FALSE);
- upmove (zfull, zto);
- ubuffree (zto);
-}
-
-/* Move a file. */
-
-static void
-upmove (zfrom, zto)
- const char *zfrom;
- const char *zto;
-{
- (void) fsysdep_move_file (zfrom, zto, TRUE, TRUE, FALSE,
- (const char *) NULL);
-}
diff --git a/gnu/libexec/uucp/uusched/Makefile b/gnu/libexec/uucp/uusched/Makefile
deleted file mode 100644
index 317710f..0000000
--- a/gnu/libexec/uucp/uusched/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# Makefile for uusched
-# $Id: Makefile,v 1.10 1997/02/22 15:28:46 peter Exp $
-
-BINDIR= $(bindir)
-CLEANFILES+= $(ONESHPROG)
-ONESHPROG= uusched
-MAN8= uusched.8
-
-all: $(ONESHPROG)
-
-$(ONESHPROG): $(ONESHPROG).in Makefile
- sed -e "s|@SBINDIR@|$(libxdir)|g" \
- $(.ALLSRC:N*Makefile) > $(.TARGET)
-
-beforeinstall:
- ${INSTALL} -c -o $(BINOWN) -g $(BINGRP) -m $(BINMODE) \
- $(ONESHPROG) $(DESTDIR)$(BINDIR)/$(ONESHPROG)
-
-.include <bsd.prog.mk>
diff --git a/gnu/libexec/uucp/uusched/uusched.8 b/gnu/libexec/uucp/uusched/uusched.8
deleted file mode 100644
index c1c1508..0000000
--- a/gnu/libexec/uucp/uusched/uusched.8
+++ /dev/null
@@ -1,24 +0,0 @@
-''' $Id: uustat.1,v 1.8 1997/02/22 15:28:49 peter Exp $
-.TH uusched 8 "Taylor UUCP 1.06"
-.SH NAME
-uusched \- UUCP file transfer daemon
-.SH SYNOPSIS
-.B uusched
-[uucico options]
-.SH DESCRIPTION
-The
-.B uusched
-program is actually just a shell script which invokes
-the
-.B uucico(8)
-daemon. It is provided for backward compatibility. It
-causes
-uucico(8) to call all systems for which there is work. Any
-option which may be given to uucico(8) may also be given to
-.B uusched
-.SH SEE ALSO
-uucico(8), uucp(1)
-.SH AUTHOR
-Ian Lance Taylor (ian@airs.com).
-This Manpage based on the Taylor UUCP 1.06 Texinfo documentation.
-
diff --git a/gnu/libexec/uucp/uusched/uusched.in b/gnu/libexec/uucp/uusched/uusched.in
deleted file mode 100644
index 5acb86a..0000000
--- a/gnu/libexec/uucp/uusched/uusched.in
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-# uusched
-# Call all systems which have work in a random order
-#
-# Copyright (C) 1992, 1993 Ian Lance Taylor
-#
-# Please feel free do whatever you like with this exciting shell
-# script.
-#
-# This is pretty trivial, since all the functionality was moved into
-# uucico itself.
-#
-exec @SBINDIR@/uucico -r1 $*
diff --git a/gnu/libexec/uucp/uustat/Makefile b/gnu/libexec/uucp/uustat/Makefile
deleted file mode 100644
index 30f4a83..0000000
--- a/gnu/libexec/uucp/uustat/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# Makefile for uustat
-# $Id$
-
-BINDIR= $(bindir)
-BINOWN= $(owner)
-BINGRP= dialer
-BINMODE= 6555
-
-PROG= uustat
-SRCS= uustat.c util.c log.c copy.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -DOWNER=\"$(owner)\"\
- -DVERSION=\"$(VERSION)\"
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../common_sources
diff --git a/gnu/libexec/uucp/uustat/uustat.1 b/gnu/libexec/uucp/uustat/uustat.1
deleted file mode 100644
index 8cb7381..0000000
--- a/gnu/libexec/uucp/uustat/uustat.1
+++ /dev/null
@@ -1,551 +0,0 @@
-''' $Id$
-.TH uustat 1 "Taylor UUCP 1.06"
-.SH NAME
-uustat \- UUCP status inquiry and control
-.SH SYNOPSIS
-.B uustat \-a
-.PP
-.B uustat \-\-all
-.PP
-.B uustat
-[
-.B \-eKRiMNQ ] [
-.B \-sS
-system ] [
-.B \-uU
-user ] [
-.B \-cC
-command ] [
-.B \-oy
-hours ] [
-.B \-B
-lines ] [
-.B \-\-executions
-] [
-.B \-\-kill-all
-] [
-.B \-\-rejuvenate-all
-] [
-.B \-\-prompt
-] [
-.B \-\-mail
-] [
-.B \-\-notify
-] [
-.B \-\-no-list
-] [
-.B \-\-system
-system ] [
-.B \-\-not-system
-system ] [
-.B \-\-user
-user ] [
-.B \-\-not-user
-user ] [
-.B \-\-command
-command ] [
-.B \-\-not-command
-command ] [
-.B \-\-older-than
-hours ] [
-.B \-\-younger-than
-hours ] [
-.B \-\-mail-lines
-lines ]
-.PP
-.B uustat
-[
-.B \-kr
-jobid ] [
-.B \-\-kill
-jobid ] [
-.B \-\-rejuvenate
-jobid ]
-.PP
-.B uustat \-q [
-.B \-sS
-system ] [
-.B \-oy
-hours ] [
-.B \-\-system
-system ] [
-.B \-\-not-system
-system ] [
-.B \-\-older-than
-hours ] [
-.B \-\-younger-than
-hours ]
-.PP
-.B uustat \-\-list [
-.B \-sS
-system ] [
-.B \-oy
-hours ] [
-.B \-\-system
-system ] [
-.B \-\-not-system
-system ] [
-.B \-\-older-than
-hours ] [
-.B \-\-younger-than
-hours ]
-.PP
-.B uustat \-m
-.PP
-.B uustat \-\-status
-.PP
-.B uustat \-p
-.PP
-.B uustat \-\-ps
-.SH DESCRIPTION
-The
-.I uustat
-command can display various types of status information about the UUCP
-system. It can also be used to cancel or rejuvenate requests made by
-.I uucp
-(1) or
-.I uux
-(1).
-
-By default
-.I uustat
-displays all jobs queued up for the invoking user, as if given the
-.B \-\-user
-option with the appropriate argument.
-
-If any of the
-.B \-a,
-.B \-\-all,
-.B \-e,
-.B \-\-executions,
-.B \-s,
-.B \-\-system,
-.B \-S,
-.B \-\-not-system,
-.B \-u,
-.B \-\-user,
-.B \-U,
-.B \-\-not-user,
-.B \-c,
-.B \-\-command,
-.B \-C,
-.B \-\-not-command,
-.B \-o,
-.B \-\-older-than,
-.B \-y,
-.B \-\-younger-than
-options are given, then all jobs which match the combined
-specifications are displayed.
-
-The
-.B \-K
-or
-.B \-\-kill-all
-option may be used to kill off a selected group of jobs, such as all
-jobs more than 7 days old.
-.SH OPTIONS
-The following options may be given to
-.I uustat.
-.TP 5
-.B \-a, \-\-all
-List all queued file transfer requests.
-.TP 5
-.B \-e, \-\-executions
-List queued execution requests rather than queued file transfer
-requests. Queued execution requests are processed by
-.I uuxqt
-(8) rather than
-.I uucico
-(8). Queued execution requests may be waiting for some file to be
-transferred from a remote system. They are created by an invocation
-of
-.I uux
-(1).
-.TP 5
-.B \-s system, \-\-system system
-List all jobs queued up for the named system. These options may be
-specified multiple times, in which case all jobs for all the systems
-will be listed. If used with
-.B \-\-list
-only the systems named will be listed.
-.TP 5
-.B \-S system, \-\-not-system system
-List all jobs queued for systems other than the one named. These
-options may be specified multiple times, in which case no jobs from
-any of the specified systems will be listed. If used with
-.B \-\-list
-only the systems not named will be listed. These options may not be
-used with
-.B \-s
-or
-.B \-\-system.
-.TP 5
-.B \-u user, \-\-user user
-List all jobs queued up for the named user. These options may be
-specified multiple times, in which case all jobs for all the users
-will be listed.
-.TP 5
-.B \-U user, \-\-not-user user
-List all jobs queued up for users other than the one named. These
-options may be specified multiple times, in which case no jobs from
-any of the specified users will be listed. These options may not be
-used with
-.B \-u
-or
-.B \-\-user.
-.TP 5
-.B \-c command, \-\-command command
-List all jobs requesting the execution of the named command. If
-.B command
-is
-.I ALL
-this will list all jobs requesting the execution of some command (as
-opposed to simply requesting a file transfer). These options may be
-specified multiple times, in which case all jobs requesting any of the
-commands will be listed.
-.TP 5
-.B \-C command, \-\-not-command command
-List all jobs requesting execution of some command other than the
-named command, or, if
-.B command
-is
-.I ALL,
-list all jobs that simply request a file transfer (as opposed to
-requesting the execution of some command). These options may be
-specified multiple times, in which case no job requesting one of the
-specified commands will be listed. These options may not be used with
-.B \-c
-or
-.B \-\-command.
-.TP 5
-.B \-o hours, \-\-older-than hours
-List all queued jobs older than the given number of hours. If used
-with
-.B \-\-list
-only systems whose oldest job is older than the given number of hours
-will be listed.
-.TP 5
-.B \-y hours, \-\-younger-than hours
-List all queued jobs younger than the given number of hours. If used
-with
-.B \-\-list
-only systems whose oldest job is younger than the given number of
-hours will be listed.
-.TP 5
-.B \-k jobid, \-\-kill jobid
-Kill the named job. The job id is shown by the default output format,
-as well as by the
-.B \-j
-or
-.B \-\-jobid
-option to
-.I uucp
-(1) or
-.I uux
-(1). A job may only be killed by the user who created the job, or by
-the UUCP administrator or the superuser. The
-.B \-k
-or
-.B \-\-kill
-options may be used multiple times on the command line to kill several
-jobs.
-.TP 5
-.B \-r jobid, \-\-rejuvenate jobid
-Rejuvenate the named job. This will mark it as having been invoked at
-the current time, affecting the output of the
-.B \-o,
-.B \-\-older-than,
-.B \-y,
-or
-.B \-\-younger-than
-options and preserving it from any automated cleanup daemon. The job
-id is shown by the default output format, as well as by the
-.B \-j
-or
-.B \-\-jobid
-options to
-.I uucp
-(1) or
-.I uux
-(1). A job may only be rejuvenated by the user who created the job,
-or by the UUCP administrator or the superuser. The
-.B \-r
-or
-.B \-\-rejuvenate
-options may be used multiple times on the command line to rejuvenate
-several jobs.
-.TP 5
-.B \-q, \-\-list
-Display the status of commands, executions and conversations for all
-remote systems for which commands or executions are queued. The
-.B \-s,
-.B \-\-system,
-.B \-S,
-.B \-\-not-system,
-.B \-o,
-.B \-\-older-than,
-.B \-y,
-and
-.B \-\-younger-than
-options may be used to restrict the systems which are listed. Systems
-for which no commands or executions are queued will never be listed.
-.TP 5
-.B \-m, \-\-status
-Display the status of conversations for all remote systems.
-.TP 5
-.B \-p, \-\-ps
-Display the status of all processes holding UUCP locks on systems or
-ports.
-.TP 5
-.B \-i, \-\-prompt
-For each listed job, prompt whether to kill the job or not. If the
-first character of the input line is
-.I y
-or
-.I Y
-the job will be killed.
-.TP 5
-.B \-K, \-\-kill-all
-Automatically kill each listed job. This can be useful for automatic
-cleanup scripts, in conjunction with the
-.B \-\-mail
-and
-.B \-\-notify
-options.
-.TP 5
-.B \-R, \-\-rejuvenate-all
-Automatically rejuvenate each listed job. This may not be used with
-.B \-\-kill-all.
-.TP 5
-.B \-M, \-\-mail
-For each listed job, send mail to the UUCP administrator. If the job
-is killed (due to
-.B \-\-kill-all
-or
-.B \-\-prompt
-with an affirmative response) the mail will indicate that. A comment
-specified by the
-.B \-\-comment
-option may be included. If the job is an execution, the initial
-portion of its standard input will be included in the mail message;
-the number of lines to include may be set with the
-.B \-\-mail-lines
-option (the default is 100). If the standard input contains null
-characters, it is assumed to be a binary file and is not included.
-.TP 5
-.B \-N, \-\-notify
-For each listed job, send mail to the user who requested the job. The
-mail is identical to that sent by the
-.B \-M
-or
-.B \-\-mail
-options.
-.TP 5
-.B \-W comment, \-\-comment comment
-Specify a comment to be included in mail sent with the
-.B \-M,
-.B \-\-mail,
-.B \-N,
-or
-.B \-\-notify
-options.
-.TP 5
-.B \-B lines, \-\-mail-lines lines
-When the
-.B \-M,
-.B \-\-mail,
-.B \-N,
-or
-.B \-\-notify
-options are used to send mail about an execution with standard input,
-this option controls the number of lines of standard input to include
-in the message. The default is 100.
-.TP 5
-.B \-Q, \-\-no-list
-Do not actually list the job, but only take any actions indicated by
-the
-.B \-i,
-.B \-\-prompt,
-.B \-K,
-.B \-\-kill-all,
-.B \-M,
-.B \-\-mail,
-.B \-N
-or
-.B \-\-notify
-options.
-.TP 5
-.B \-x type, \-\-debug type
-Turn on particular debugging types. The following types are
-recognized: abnormal, chat, handshake, uucp-proto, proto, port,
-config, spooldir, execute, incoming, outgoing. Only abnormal, config,
-spooldir and execute are meaningful for
-.I uustat.
-
-Multiple types may be given, separated by commas, and the
-.B \-\-debug
-option may appear multiple times. A number may also be given, which
-will turn on that many types from the foregoing list; for example,
-.B \-\-debug 2
-is equivalent to
-.B \-\-debug abnormal,chat.
-.TP 5
-.B \-I file, \-\-config file
-Set configuration file to use. This option may not be available,
-depending upon how
-.I uustat
-was compiled.
-.TP 5
-.B \-v, \-\-version
-Report version information and exit.
-.TP 5
-.B \-\-help
-Print a help message and exit.
-.SH EXAMPLES
-.br
-.nf
-uustat --all
-.fi
-Display status of all jobs. A sample output line is as follows:
-.br
-.in +0.5i
-.nf
-bugsA027h bugs ian 04-01 13:50 Executing rmail ian@airs.com (sending 1283 bytes)
-.fi
-.in -0.5i
-The format is
-.br
-.in +0.5i
-.nf
-jobid system user queue-date command (size)
-.fi
-.in -0.5i
-The jobid may be passed to the
-.B \-\-kill
-or
-.B \-\-rejuvenate
-options.
-The size indicates how much data is to be transferred to the remote
-system, and is absent for a file receive request.
-The
-.B \-\-system,
-.B \-\-not-system,
-.B \-\-user,
-.B \-\-not-user,
-.B \-\-command,
-.B \-\-not-command,
-.B \-\-older-than,
-and
-.B \-\-younger-than
-options may be used to control which jobs are listed.
-
-.br
-.nf
-uustat --executions
-.fi
-Display status of queued up execution requests. A sample output line
-is as follows:
-.br
-.in +0.5i
-.nf
-bugs bugs!ian 05-20 12:51 rmail ian
-.fi
-.in -0.5i
-The format is
-.br
-.in +0.5i
-.nf
-system requestor queue-date command
-.fi
-.in -0.5i
-The
-.B \-\-system,
-.B \-\-not-system,
-.B \-\-user,
-.B \-\-not-user,
-.B \-\-command,
-.B \-\-not-command,
-.B \-\-older-than,
-and
-.B \-\-younger-than
-options may be used to control which requests are listed.
-
-.br
-.nf
-uustat --list
-.fi
-Display status for all systems with queued up commands. A sample
-output line is as follows:
-.br
-.in +0.5i
-.nf
-bugs 4C (1 hour) 0X (0 secs) 04-01 14:45 Dial failed
-.fi
-.in -0.5i
-This indicates the system, the number of queued commands, the age of
-the oldest queued command, the number of queued local executions, the
-age of the oldest queued execution, the date of the last conversation,
-and the status of that conversation.
-
-.br
-.nf
-uustat --status
-.fi
-Display conversation status for all remote systems. A sample output
-line is as follows:
-.br
-.in +0.5i
-.nf
-bugs 04-01 15:51 Conversation complete
-.fi
-.in -0.5i
-This indicates the system, the date of the last conversation, and the
-status of that conversation. If the last conversation failed,
-.I uustat
-will indicate how many attempts have been made to call the system. If
-the retry period is currently preventing calls to that system,
-.I uustat
-also displays the time when the next call will be permitted.
-
-.br
-.nf
-uustat --ps
-.fi
-Display the status of all processes holding UUCP locks. The output
-format is system dependent, as
-.I uustat
-simply invokes
-.I ps
-(1) on each process holding a lock.
-
-.br
-.in +0.5i
-.nf
-uustat --command rmail --older-than 168 --kill-all --no-list --mail --notify --comment "Queued for over 1 week"
-.fi
-.in -0.5i
-This will kill all
-.I rmail
-commands that have been queued up waiting for delivery for over 1 week
-(168 hours). For each such command, mail will be sent both to the
-UUCP administrator and to the user who requested the rmail execution.
-The mail message sent will include the string given by the
-.B \-\-comment
-option. The
-.B \-\-no-list
-option prevents any of the jobs from being listed on the terminal, so
-any output from the program will be error messages.
-.SH FILES
-The file names may be changed at compilation time or by the
-configuration file, so these are only approximations.
-
-.br
-/etc/uucp/config - Configuration file.
-.br
-/var/spool/uucp -
-UUCP spool directory.
-.SH SEE ALSO
-ps(1), rmail(8), uucp(1), uux(1), uucico(8), uuxqt(8)
-.SH AUTHOR
-Ian Lance Taylor
-(ian@airs.com)
diff --git a/gnu/libexec/uucp/uustat/uustat.c b/gnu/libexec/uucp/uustat/uustat.c
deleted file mode 100644
index b4a29f7..0000000
--- a/gnu/libexec/uucp/uustat/uustat.c
+++ /dev/null
@@ -1,2441 +0,0 @@
-/* uustat.c
- UUCP status program
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char uustat_rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-
-#if TM_IN_SYS_TIME
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-
-#include "getopt.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-
-/* The uustat program permits various listings and manipulations of
- files in the spool directory. This implementation supports the
- following switches:
-
- -a list all jobs
- -Blines number of lines of standard input to mail
- -ccommand list only executions of specified command
- -Ccommand list only jobs other than executions of specified command
- -e list execute jobs rather than command requests
- -i ask user whether to kill each listed job
- -Ifile set configuration file name
- -kjobid kill job with specified ID
- -K kill each listed job
- -m report status for all remote machines
- -M mail uucp about each job killed with -K
- -N mail requestor about each job killed with -K
- -ohour report jobs older than specified number of hours
- -p do "ps -flp" on all processes holding lock files (Unix specific)
- -q list number of jobs for all systems
- -Q don't list jobs, just do -K processing
- -rjobid rejuvenate job with specified ID
- -ssystem report on all jobs for specified system
- -Ssystem report on all jobs other than for specified system
- -uuser report on all jobs for specified user
- -Uuser report on all jobs other than for specified user
- -Wcomment comment to include in mail messages
- -xdebug set debugging level
- -yhour report jobs younger than specified number of hours */
-
-/* What to do with a job that matches the selection criteria; these
- values may be or'red together. */
-#define JOB_SHOW (01)
-#define JOB_INQUIRE (02)
-#define JOB_KILL (04)
-#define JOB_REJUVENATE (010)
-#define JOB_MAIL (020)
-#define JOB_NOTIFY (040)
-
-/* This structure is used to accumulate all the lines in a single
- command file, so that they can all be displayed at once and so that
- executions can be displayed reasonably. */
-
-struct scmdlist
-{
- struct scmdlist *qnext;
- struct scmd s;
- long itime;
-};
-
-/* Local functions. */
-
-static void ususage P((void));
-static void ushelp P((void));
-static boolean fsxqt_file_read P((pointer puuconf, FILE *));
-static void usxqt_file_free P((void));
-static int isxqt_cmd P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int isxqt_file P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int isxqt_user P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static boolean fsworkfiles P((pointer puuconf, int icmd, int csystems,
- char **pazsystems, boolean fnotsystems,
- int cusers, char **pazusers,
- boolean fnotusers, long iold, long iyoung,
- int ccommands, char **pazcommands,
- boolean fnotcommands, const char *zcomment,
- int cstdin));
-static boolean fsworkfiles_system P((pointer puuconf,int icmd,
- const struct uuconf_system *qsys,
- int cusers, char **pazusers,
- boolean fnotusers, long iold,
- long iyoung, int ccommands,
- char **pazcommands,
- boolean fnotcommands,
- const char *zcomment, int cstdin));
-static boolean fsworkfile_show P((pointer puuconf, int icmd,
- const struct uuconf_system *qsys,
- const struct scmd *qcmd,
- long itime, int ccommands,
- char **pazcommands, boolean fnotcommands,
- const char *zcomment, int cstdin));
-static void usworkfile_header P((const struct uuconf_system *qsys,
- const struct scmd *qcmd,
- const char *zjobid,
- long itime, boolean ffirst));
-static boolean fsexecutions P((pointer puuconf, int icmd, int csystems,
- char **pazsystems, boolean fnotsystems,
- int cusers, char **pazusers,
- boolean fnotusers, long iold, long iyoung,
- int ccommands, char **pazcommands,
- boolean fnotcommands, const char *zcomment,
- int cstdin));
-static boolean fsnotify P((pointer puuconf, int icmd, const char *zcomment,
- int cstdin, boolean fkilled, const char *zcmd,
- struct scmdlist *qcmd, const char *zid,
- long itime, const char *zuser,
- const struct uuconf_system *qsys,
- const char *zstdin, pointer pstdinseq,
- const char *zrequestor));
-static boolean fsquery P((pointer puuconf, int csystems,
- char **pazsystems, boolean fnotsystems,
- long iold, long iyoung));
-static int csunits_show P((long idiff));
-static boolean fsmachines P((void));
-
-/* Long getopt options. */
-static const struct option asSlongopts[] =
-{
- { "all", no_argument, NULL, 'a' },
- { "mail-lines", required_argument, NULL, 'B' },
- { "command", required_argument, NULL, 'c' },
- { "not-command", required_argument, NULL, 'C' },
- { "executions", no_argument, NULL, 'e' },
- { "prompt", no_argument, NULL, 'i' },
- { "kill", required_argument, NULL, 'k' },
- { "kill-all", no_argument, NULL, 'K' },
- { "status", no_argument, NULL, 'm' },
- { "mail", no_argument, NULL, 'M' },
- { "notify", no_argument, NULL, 'N' },
- { "older-than", required_argument, NULL, 'o' },
- { "ps", no_argument, NULL, 'p' },
- { "list", no_argument, NULL, 'q' },
- { "no-list", no_argument, NULL, 'Q' },
- { "rejuvenate", required_argument, NULL, 'r' },
- { "rejuvenate-all", no_argument, NULL, 'R' },
- { "system", required_argument, NULL, 's' },
- { "not-system", required_argument, NULL, 'S' },
- { "user", required_argument, NULL, 'u' },
- { "not-user", required_argument, NULL, 'U' },
- { "comment", required_argument, NULL, 'W' },
- { "younger-than", required_argument, NULL, 'y' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'x' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- /* -a: list all jobs. */
- boolean fall = FALSE;
- /* -B lines: number of lines of standard input to mail. */
- int cstdin = 100;
- /* -c,-C command: list only specified command. */
- int ccommands = 0;
- char **pazcommands = NULL;
- boolean fnotcommands = FALSE;
- /* -e: list execute jobs. */
- boolean fexecute = FALSE;
- /* -k jobid: kill specified job. */
- int ckills = 0;
- char **pazkills = NULL;
- /* -m: report machine status. */
- boolean fmachine = FALSE;
- /* -o hour: report jobs older than given number of hours. */
- int ioldhours = -1;
- /* -p: report status of jobs holding lock files. */
- boolean fps = FALSE;
- /* -q: list number of jobs for each system. */
- boolean fquery = FALSE;
- /* -r jobid: rejuvenate specified job. */
- int crejuvs = 0;
- char **pazrejuvs = NULL;
- /* -s,-S system: list all jobs for specified system. */
- int csystems = 0;
- char **pazsystems = NULL;
- boolean fnotsystems = FALSE;
- /* -u,-U user: list all jobs for specified user. */
- int cusers = 0;
- char **pazusers = NULL;
- boolean fnotusers = FALSE;
- /* -W comment: comment to include in mail messages. */
- const char *zcomment = NULL;
- /* -y hour: report jobs younger than given number of hours. */
- int iyounghours = -1;
- /* -I file: set configuration file. */
- const char *zconfig = NULL;
- /* -Q, -i, -K, -M, -N: what to do with each job. */
- int icmd = JOB_SHOW;
- int ccmds;
- int iopt;
- pointer puuconf;
- int iuuconf;
- long iold;
- long iyoung;
- const char *azoneuser[1];
- boolean fret;
-
- zProgram = argv[0];
-
- while ((iopt = getopt_long (argc, argv,
- "aB:c:C:eiI:k:KmMNo:pqQr:Rs:S:u:U:vW:x:y:",
- asSlongopts, (int *) NULL)) != EOF)
- {
- switch (iopt)
- {
- case 'a':
- /* List all jobs. */
- fall = TRUE;
- break;
-
- case 'B':
- /* Number of lines of standard input to mail. */
- cstdin = (int) strtol (optarg, (char **) NULL, 10);
- break;
-
- case 'C':
- /* List jobs for other than specified command. */
- fnotcommands = TRUE;
- /* Fall through. */
- case 'c':
- /* List specified command. */
- ++ccommands;
- pazcommands = (char **) xrealloc ((pointer) pazcommands,
- ccommands * sizeof (char *));
- pazcommands[ccommands - 1] = optarg;
- break;
-
- case 'e':
- /* List execute jobs. */
- fexecute = TRUE;
- break;
-
- case 'i':
- /* Prompt the user whether to kill each job. */
- icmd |= JOB_INQUIRE;
- break;
-
- case 'I':
- /* Set configuration file name. */
- if (fsysdep_other_config (optarg))
- zconfig = optarg;
- break;
-
- case 'k':
- /* Kill specified job. */
- ++ckills;
- pazkills = (char **) xrealloc ((pointer) pazkills,
- ckills * sizeof (char *));
- pazkills[ckills - 1] = optarg;
- break;
-
- case 'K':
- /* Kill each listed job. */
- icmd |= JOB_KILL;
- break;
-
- case 'm':
- /* Report machine status. */
- fmachine = TRUE;
- break;
-
- case 'M':
- /* Mail to uucp action taken on each job. */
- icmd |= JOB_MAIL;
- break;
-
- case 'N':
- /* Mail to requestor action taken on each job. */
- icmd |= JOB_NOTIFY;
- break;
-
- case 'o':
- /* Report old jobs. */
- ioldhours = (int) strtol (optarg, (char **) NULL, 10);
- break;
-
- case 'p':
- /* Get status of processes holding locks. */
- fps = TRUE;
- break;
-
- case 'q':
- /* List number of jobs for each system. */
- fquery = TRUE;
- break;
-
- case 'Q':
- /* Don't list jobs, just do -K processing. */
- icmd &=~ JOB_SHOW;
- break;
-
- case 'r':
- /* Rejuvenate specified job. */
- ++crejuvs;
- pazrejuvs = (char **) xrealloc ((pointer) pazrejuvs,
- crejuvs * sizeof (char *));
- pazrejuvs[crejuvs - 1] = optarg;
- break;
-
- case 'R':
- /* Rejuvenate each listed job. */
- icmd |= JOB_REJUVENATE;
- break;
-
- case 'S':
- /* List jobs for other than specified system. */
- fnotsystems = TRUE;
- /* Fall through. */
- case 's':
- /* List jobs for specified system. */
- ++csystems;
- pazsystems = (char **) xrealloc ((pointer) pazsystems,
- csystems * sizeof (char *));
- pazsystems[csystems - 1] = optarg;
- break;
-
- case 'U':
- /* List jobs for other than specified user. */
- fnotusers = TRUE;
- /* Fall through. */
- case 'u':
- /* List jobs for specified user. */
- ++cusers;
- pazusers = (char **) xrealloc ((pointer) pazusers,
- cusers * sizeof (char *));
- pazusers[cusers - 1] = optarg;
- break;
-
- case 'W':
- /* Comment to include in mail messages. */
- zcomment = optarg;
- break;
-
- case 'x':
-#if DEBUG > 1
- /* Set debugging level. */
- iDebug |= idebug_parse (optarg);
-#endif
- break;
-
- case 'y':
- /* List jobs younger than given number of hours. */
- iyounghours = (int) strtol (optarg, (char **) NULL, 10);
- break;
-
- case 'v':
- /* Print version and exit. */
- printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zProgram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 1:
- /* --help. */
- ushelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found and flag set. */
- break;
-
- default:
- ususage ();
- /*NOTREACHED*/
- }
- }
-
- if (optind != argc)
- ususage ();
-
- /* To avoid confusion, most options are only permitted by
- themselves. This restriction might be removed later, but it is
- imposed by most implementations. We do permit any combination of
- -c, -s, -u, -o and -y, and any combination of -k and -r. */
- ccmds = 0;
- if (fall)
- ++ccmds;
- if (ckills > 0 || crejuvs > 0)
- ++ccmds;
- if (fmachine)
- ++ccmds;
- if (fps)
- ++ccmds;
- if (fexecute || fquery || csystems > 0 || cusers > 0 || ioldhours != -1
- || iyounghours != -1 || ccommands > 0)
- ++ccmds;
- if (fexecute && fquery)
- ++ccmds;
-
- if (ccmds > 1)
- {
- fprintf (stderr, "%s: too many options\n", zProgram);
- ususage ();
- }
-
- if ((icmd & JOB_KILL) != 0
- && (icmd & JOB_REJUVENATE) != 0)
- {
- fprintf (stderr, "%s: can not both rejuvenate and kill jobs\n",
- zProgram);
- ususage ();
- }
-
- iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
-#if DEBUG > 1
- {
- const char *zdebug;
-
- iuuconf = uuconf_debuglevel (puuconf, &zdebug);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (zdebug != NULL)
- iDebug |= idebug_parse (zdebug);
- }
-#endif
-
- usysdep_initialize (puuconf, INIT_SUID);
-
- /* If no commands were specified, we list all commands for the given
- user. */
- if (ccmds == 0)
- {
- cusers = 1;
- azoneuser[0] = zsysdep_login_name ();
- pazusers = (char **) azoneuser;
- }
-
- /* Canonicalize the system names. */
- if (csystems > 0)
- {
- int i;
-
- for (i = 0; i < csystems; i++)
- {
- struct uuconf_system ssys;
-
- iuuconf = uuconf_system_info (puuconf, pazsystems[i], &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf == UUCONF_NOT_FOUND)
- ulog (LOG_FATAL, "%s: System not found", pazsystems[i]);
- else
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- }
- if (strcmp (pazsystems[i], ssys.uuconf_zname) != 0)
- pazsystems[i] = zbufcpy (ssys.uuconf_zname);
- (void) uuconf_system_free (puuconf, &ssys);
- }
- }
-
- if (ioldhours == -1)
- iold = (long) -1;
- else
- {
- iold = (ixsysdep_time ((long *) NULL)
- - (long) ioldhours * (long) 60 * (long) 60);
- if (iold < 0L)
- iold = 0L;
- }
- if (iyounghours == -1)
- iyoung = (long) -1;
- else
- {
- iyoung = (ixsysdep_time ((long *) NULL)
- - (long) iyounghours * (long) 60 * (long) 60);
- if (iyoung < 0L)
- iyoung = 0L;
- }
-
- if (! fexecute
- && ! fquery
- && (fall
- || csystems > 0
- || cusers > 0
- || ioldhours != -1
- || iyounghours != -1
- || ccommands > 0))
- fret = fsworkfiles (puuconf, icmd, csystems, pazsystems, fnotsystems,
- cusers, pazusers, fnotusers, iold, iyoung,
- ccommands, pazcommands, fnotcommands, zcomment,
- cstdin);
- else if (fexecute)
- fret = fsexecutions (puuconf, icmd, csystems, pazsystems, fnotsystems,
- cusers, pazusers, fnotusers, iold, iyoung,
- ccommands, pazcommands, fnotcommands, zcomment,
- cstdin);
- else if (icmd != JOB_SHOW)
- {
- ulog (LOG_ERROR,
- "-i, -K, -M, -N, -Q, -R not supported with -k, -m, -p, -q, -r");
- ususage ();
- fret = FALSE;
- }
- else if (fquery)
- {
- if (cusers > 0 || ccommands > 0)
- {
- ulog (LOG_ERROR, "-u, -c not supported with -q");
- ususage ();
- fret = FALSE;
- }
- else
- fret = fsquery (puuconf, csystems, pazsystems, fnotsystems,
- iold, iyoung);
- }
- else if (fmachine)
- fret = fsmachines ();
- else if (ckills > 0 || crejuvs > 0)
- {
- int i;
-
- fret = TRUE;
- for (i = 0; i < ckills; i++)
- if (! fsysdep_kill_job (puuconf, pazkills[i]))
- fret = FALSE;
-
- for (i = 0; i < crejuvs; i++)
- if (! fsysdep_rejuvenate_job (puuconf, pazrejuvs[i]))
- fret = FALSE;
- }
- else if (fps)
- fret = fsysdep_lock_status ();
- else
- {
-#if DEBUG > 0
- ulog (LOG_FATAL, "Can't happen");
-#endif
- fret = FALSE;
- }
-
- ulog_close ();
-
- usysdep_exit (fret);
-
- /* Avoid errors about not returning a value. */
- return 0;
-}
-
-/* Print a usage message and die. */
-
-static void
-ususage ()
-{
- fprintf (stderr, "Usage: %s [options]\n", zProgram);
- fprintf (stderr, "Use %s --help for help\n", zProgram);
- exit (EXIT_FAILURE);
-}
-
-/* Print a help message. */
-
-static void
-ushelp ()
-{
- printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- printf ("Usage: %s [options]\n", zProgram);
- printf (" -a,--all: list all UUCP jobs\n");
- printf (" -B,--mail-lines num: number of lines to return in -M or -N mail message\n");
- printf (" -c,--command command: list requests for named command\n");
- printf (" -C,--not-command command: list requests for other than named command\n");
- printf (" -e,--executions: list queued executions rather than job requests\n");
- printf (" -i,--prompt: prompt for whether to kill each listed job\n");
- printf (" -k,--kill job: kill specified UUCP job\n");
- printf (" -K,--kill-all: kill each listed job\n");
- printf (" -m,--status: report status for all remote machines\n");
- printf (" -M,--mail: mail report on each listed job to UUCP administrator\n");
- printf (" -N,--notify: mail report on each listed job to requestor\n");
- printf (" -o,--older-than hours: list all jobs older than given number of hours\n");
- printf (" -p,--ps: show status of all processes holding UUCP locks\n");
- printf (" -q,--list: list number of jobs for each system\n");
- printf (" -Q,--no-list: don't list jobs, just take actions (-i, -K, -M, -N)\n");
- printf (" -r,--rejuvenate job: rejuvenate specified UUCP job\n");
- printf (" -R,--rejuvenate-all: rejuvenate each listed job\n");
- printf (" -s,--system system: list all jobs for specified system\n");
- printf (" -S,--not-system system: list all jobs for other than specified system\n");
- printf (" -u,--user user: list all jobs for specified user\n");
- printf (" -U,--not-user user: list all jobs for other than specified user\n");
- printf (" -W,--comment comment: comment to include in mail messages\n");
- printf (" -y,--younger-than hours: list all jobs younger than given number of hours\n");
- printf (" -x,--debug debug: Set debugging level\n");
-#if HAVE_TAYLOR_CONFIG
- printf (" -I,--config file: Set configuration file to use\n");
-#endif /* HAVE_TAYLOR_CONFIG */
- printf (" -v,--version: Print version and exit\n");
- printf (" --help: Print help and exit\n");
-}
-
-/* We need to be able to read information from an execution file. */
-
-/* The user name extracted from an execution file. */
-static char *zSxqt_user;
-
-/* The system name from an execution file. */
-static char *zSxqt_system;
-
-/* Address of requesting user (who to send mail to). */
-static const char *zSxqt_requestor;
-
-/* The command (no arguments) from an execution file. */
-static char *zSxqt_prog;
-
-/* The full command line from an execution file. */
-static char *zSxqt_cmd;
-
-/* Number of files associated with an execution file. */
-static int cSxqt_files;
-
-/* Names of files associated with execution file. */
-static char **pazSxqt_files;
-
-/* Standard input file name. */
-static const char *zSxqt_stdin;
-
-/* A command table used to dispatch an execution file. */
-static const struct uuconf_cmdtab asSxqt_cmds[] =
-{
- { "C", UUCONF_CMDTABTYPE_FN | 0, NULL, isxqt_cmd },
- { "I", UUCONF_CMDTABTYPE_STRING, (pointer) &zSxqt_stdin, NULL },
- { "F", UUCONF_CMDTABTYPE_FN | 0, NULL, isxqt_file },
- { "R", UUCONF_CMDTABTYPE_STRING, (pointer) &zSxqt_requestor, NULL },
- { "U", UUCONF_CMDTABTYPE_FN | 3, NULL, isxqt_user },
- { NULL, 0, NULL, NULL }
-};
-
-/* Read an execution file, setting the above variables. */
-
-static boolean
-fsxqt_file_read (puuconf, e)
- pointer puuconf;
- FILE *e;
-{
- int iuuconf;
- boolean fret;
-
- zSxqt_user = NULL;
- zSxqt_system = NULL;
- zSxqt_stdin = NULL;
- zSxqt_requestor = NULL;
- zSxqt_prog = NULL;
- zSxqt_cmd = NULL;
- cSxqt_files = 0;
- pazSxqt_files = NULL;
-
- iuuconf = uuconf_cmd_file (puuconf, e, asSxqt_cmds, (pointer) NULL,
- (uuconf_cmdtabfn) NULL,
- UUCONF_CMDTABFLAG_CASE, (pointer) NULL);
- if (iuuconf == UUCONF_SUCCESS)
- fret = TRUE;
- else
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fret = FALSE;
- }
-
- if (zSxqt_user == NULL)
- zSxqt_user = zbufcpy ("*unknown*");
- if (zSxqt_system == NULL)
- zSxqt_system = zbufcpy ("*unknown*");
- if (zSxqt_prog == NULL)
- {
- zSxqt_prog = zbufcpy ("*none*");
- zSxqt_cmd = zbufcpy ("*none*");
- }
-
- return fret;
-}
-
-/* Free up the information read from an execution file. */
-
-static void
-usxqt_file_free ()
-{
- int i;
-
- ubuffree (zSxqt_user);
- zSxqt_user = NULL;
- ubuffree (zSxqt_system);
- zSxqt_system = NULL;
- ubuffree (zSxqt_prog);
- zSxqt_prog = NULL;
- ubuffree (zSxqt_cmd);
- zSxqt_cmd = NULL;
- for (i = 0; i < cSxqt_files; i++)
- ubuffree (pazSxqt_files[i]);
- cSxqt_files = 0;
- xfree ((pointer) pazSxqt_files);
- pazSxqt_files = NULL;
- zSxqt_stdin = NULL;
- zSxqt_requestor = NULL;
-}
-
-/* Get the command from an execution file. */
-
-/*ARGSUSED*/
-static int
-isxqt_cmd (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- size_t clen;
- int i;
-
- if (argc <= 1)
- return UUCONF_CMDTABRET_CONTINUE;
-
- zSxqt_prog = zbufcpy (argv[1]);
-
- clen = 0;
- for (i = 1; i < argc; i++)
- clen += strlen (argv[i]) + 1;
-
- zSxqt_cmd = zbufalc (clen);
- zSxqt_cmd[0] = '\0';
- for (i = 1; i < argc - 1; i++)
- {
- strcat (zSxqt_cmd, argv[i]);
- strcat (zSxqt_cmd, " ");
- }
- strcat (zSxqt_cmd, argv[i]);
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Get the associated files from an execution file. */
-
-/*ARGSUSED*/
-static int
-isxqt_file (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- if (argc != 2 && argc != 3)
- return UUCONF_CMDTABRET_CONTINUE;
-
- /* If this file is not in the spool directory, just ignore it. */
- if (! fspool_file (argv[1]))
- return UUCONF_CMDTABRET_CONTINUE;
-
- ++cSxqt_files;
- pazSxqt_files = (char **) xrealloc ((pointer) pazSxqt_files,
- cSxqt_files * sizeof (char *));
-
- pazSxqt_files[cSxqt_files - 1] = zbufcpy (argv[1]);
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Get the requesting user and system from an execution file. */
-
-/*ARGSUSED*/
-static int
-isxqt_user (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- zSxqt_user = zbufcpy (argv[1]);
- zSxqt_system = zbufcpy (argv[2]);
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Handle various possible requests to look at work files. */
-
-static boolean
-fsworkfiles (puuconf, icmd, csystems, pazsystems, fnotsystems, cusers,
- pazusers, fnotusers, iold, iyoung, ccommands, pazcommands,
- fnotcommands, zcomment, cstdin)
- pointer puuconf;
- int icmd;
- int csystems;
- char **pazsystems;
- boolean fnotsystems;
- int cusers;
- char **pazusers;
- boolean fnotusers;
- long iold;
- long iyoung;
- int ccommands;
- char **pazcommands;
- boolean fnotcommands;
- const char *zcomment;
- int cstdin;
-{
- boolean fret;
- int i;
- int iuuconf;
- struct uuconf_system ssys;
-
- fret = TRUE;
-
- if (csystems > 0 && ! fnotsystems)
- {
- for (i = 0; i < csystems; i++)
- {
- iuuconf = uuconf_system_info (puuconf, pazsystems[i], &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf == UUCONF_NOT_FOUND)
- ulog (LOG_ERROR, "%s: System not found", pazsystems[i]);
- else
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fret = FALSE;
- continue;
- }
-
- if (! fsworkfiles_system (puuconf, icmd, &ssys, cusers, pazusers,
- fnotusers, iold, iyoung, ccommands,
- pazcommands, fnotcommands, zcomment,
- cstdin))
- fret = FALSE;
-
- (void) uuconf_system_free (puuconf, &ssys);
- }
- }
- else
- {
- char **pznames, **pz;
-
- iuuconf = uuconf_system_names (puuconf, &pznames, 0);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
-
- for (pz = pznames; *pz != NULL; pz++)
- {
- if (csystems > 0)
- {
- for (i = 0; i < csystems; i++)
- if (strcmp (*pz, pazsystems[i]) == 0)
- break;
- if (i < csystems)
- continue;
- }
-
- iuuconf = uuconf_system_info (puuconf, *pz, &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fret = FALSE;
- continue;
- }
-
- if (! fsworkfiles_system (puuconf, icmd, &ssys, cusers, pazusers,
- fnotusers, iold, iyoung, ccommands,
- pazcommands, fnotcommands, zcomment,
- cstdin))
- fret = FALSE;
-
- (void) uuconf_system_free (puuconf, &ssys);
- xfree ((pointer) *pz);
- }
- xfree ((pointer) pznames);
- }
-
- return fret;
-}
-
-/* Look at the work files for a particular system. */
-
-static boolean
-fsworkfiles_system (puuconf, icmd, qsys, cusers, pazusers, fnotusers, iold,
- iyoung, ccommands, pazcommands, fnotcommands, zcomment,
- cstdin)
- pointer puuconf;
- int icmd;
- const struct uuconf_system *qsys;
- int cusers;
- char **pazusers;
- boolean fnotusers;
- long iold;
- long iyoung;
- int ccommands;
- char **pazcommands;
- boolean fnotcommands;
- const char *zcomment;
- int cstdin;
-{
- boolean fret;
-
- if (! fsysdep_get_work_init (qsys, UUCONF_GRADE_LOW))
- return FALSE;
-
- while (TRUE)
- {
- struct scmd s;
- long itime;
-
- if (! fsysdep_get_work (qsys, UUCONF_GRADE_LOW, &s))
- {
- usysdep_get_work_free (qsys);
- return FALSE;
- }
- if (s.bcmd == 'H')
- break;
-
- if (cusers > 0)
- {
- boolean fmatch;
- int i;
-
- fmatch = fnotusers;
- for (i = 0; i < cusers; i++)
- {
- if (s.zuser != NULL
- && strcmp (pazusers[i], s.zuser) == 0)
- {
- fmatch = ! fmatch;
- break;
- }
- }
- if (! fmatch)
- continue;
- }
-
- itime = ixsysdep_work_time (qsys, s.pseq);
-
- if (iold != (long) -1 && itime > iold)
- continue;
-
- if (iyoung != (long) -1 && itime < iyoung)
- continue;
-
- if (! fsworkfile_show (puuconf, icmd, qsys, &s, itime, ccommands,
- pazcommands, fnotcommands, zcomment, cstdin))
- {
- usysdep_get_work_free (qsys);
- return FALSE;
- }
- }
-
- fret = fsworkfile_show (puuconf, icmd, qsys, (const struct scmd *) NULL,
- 0L, ccommands, pazcommands, fnotcommands, zcomment,
- cstdin);
-
- usysdep_get_work_free (qsys);
-
- return fret;
-}
-
-/* Show a single workfile. This is actually called once for each line
- in the workfile, so we accumulate the lines and show them all at
- once. This lets us show an execution in a useful fashion. */
-
-static boolean
-fsworkfile_show (puuconf, icmd, qsys, qcmd, itime, ccommands, pazcommands,
- fnotcommands, zcomment, cstdin)
- pointer puuconf;
- int icmd;
- const struct uuconf_system *qsys;
- const struct scmd *qcmd;
- long itime;
- int ccommands;
- char **pazcommands;
- boolean fnotcommands;
- const char *zcomment;
- int cstdin;
-{
- static struct scmdlist *qlist;
- static char *zlistid;
- char *zid;
-
- if (qcmd == NULL)
- zid = NULL;
- else
- {
- zid = zsysdep_jobid (qsys, qcmd->pseq);
- if (zid == NULL)
- return FALSE;
- }
-
- /* If this is the same jobid as the list, put it on the end. */
-
- if (qcmd != NULL
- && qlist != NULL
- && strcmp (zlistid, zid) == 0)
- {
- struct scmdlist *qnew, **pq;
-
- ubuffree (zid);
- qnew = (struct scmdlist *) xmalloc (sizeof (struct scmdlist));
- qnew->qnext = NULL;
- qnew->s = *qcmd;
- qnew->itime = itime;
- for (pq = &qlist; *pq != NULL; pq = &(*pq)->qnext)
- ;
- *pq = qnew;
- return TRUE;
- }
-
- /* Here we have found a different job ID, so we print the scmd
- structures that we have accumulated. We look for the special
- case of an execution (an E command, or one of the destination
- files begins with X.). We could be more clever about other
- situations as well. */
- if (qlist != NULL)
- {
- boolean fmatch;
- const char *zprog, *zcmd, *zrequestor, *zstdin;
- char *zfree;
- struct scmdlist *qxqt;
- FILE *exqt = NULL;
- struct scmdlist *qfree;
-
- fmatch = FALSE;
- zprog = zcmd = zrequestor = zstdin = NULL;
- zfree = NULL;
-
- for (qxqt = qlist; qxqt != NULL; qxqt = qxqt->qnext)
- {
- if (qxqt->s.bcmd == 'E')
- break;
- if (qxqt->s.bcmd == 'S'
- && qxqt->s.zto[0] == 'X'
- && qxqt->s.zto[1] == '.'
- && fspool_file (qxqt->s.zfrom))
- {
- char *zxqt;
-
- /* Open the file now, so that, if it does not exist, we
- can still report sensibly (the qxqt == NULL case) on
- any other files that may exist. */
-
- zxqt = zsysdep_spool_file_name (qsys, qxqt->s.zfrom,
- qxqt->s.pseq);
- if (zxqt == NULL)
- return FALSE;
-
- exqt = fopen (zxqt, "r");
-
- ubuffree (zxqt);
-
- if (exqt != NULL)
- break;
- }
- }
-
- if (qxqt == NULL)
- {
- if (ccommands == 0
- || (fnotcommands
- && strcmp (pazcommands[0], "ALL") == 0))
- {
- /* Show all the lines in a regular work file. */
- fmatch = TRUE;
-
- if ((icmd & JOB_SHOW) != 0)
- {
- struct scmdlist *qshow;
-
- for (qshow = qlist; qshow != NULL; qshow = qshow->qnext)
- {
- char *zfile;
- long cbytes;
-
- usworkfile_header (qsys, &qshow->s, zlistid,
- qshow->itime, qshow == qlist);
-
- switch (qshow->s.bcmd)
- {
- case 'S':
- if (strchr (qshow->s.zoptions, 'C') != NULL
- || fspool_file (qshow->s.zfrom))
- zfile = zsysdep_spool_file_name (qsys,
- qshow->s.ztemp,
- qshow->s.pseq);
- else
- zfile = zbufcpy (qshow->s.zfrom);
- if (zfile == NULL)
- cbytes = -1;
- else
- cbytes = csysdep_size (zfile);
- if (cbytes >= 0)
- printf ("Sending %s (%ld bytes) to %s",
- qshow->s.zfrom, cbytes, qshow->s.zto);
- ubuffree (zfile);
- break;
- case 'R':
- printf ("Requesting %s to %s", qshow->s.zfrom,
- qshow->s.zto);
- break;
- case 'X':
- printf ("Requesting %s to %s", qshow->s.zfrom,
- qshow->s.zto);
- break;
- case 'P':
- printf ("(poll file)");
- break;
-#if DEBUG > 0
- default:
- printf ("Bad line %d", qshow->s.bcmd);
- break;
-#endif
- }
-
- printf ("\n");
- }
- }
- }
- }
- else
- {
- long csize;
- struct scmdlist *qsize;
-
- /* Show the command for an execution file. */
- if (qxqt->s.bcmd == 'E')
- {
- zfree = zbufcpy (qxqt->s.zcmd);
- zfree[strcspn (zfree, " \t")] = '\0';
- zprog = zfree;
- zcmd = qxqt->s.zcmd;
- if (strchr (qxqt->s.zoptions, 'R') != NULL)
- zrequestor = qxqt->s.znotify;
- }
- else
- {
- if (! fsxqt_file_read (puuconf, exqt))
- {
- (void) fclose (exqt);
- return FALSE;
- }
-
- (void) fclose (exqt);
-
- zprog = zSxqt_prog;
- zcmd = zSxqt_cmd;
- zrequestor = zSxqt_requestor;
- }
-
- csize = 0L;
- for (qsize = qlist; qsize != NULL; qsize = qsize->qnext)
- {
- if (qsize->s.bcmd == 'S' || qsize->s.bcmd == 'E')
- {
- char *zfile;
-
- if (strchr (qsize->s.zoptions, 'C') != NULL
- || fspool_file (qsize->s.zfrom))
- zfile = zsysdep_spool_file_name (qsys, qsize->s.ztemp,
- qsize->s.pseq);
- else
- zfile = zbufcpy (qsize->s.zfrom);
- if (zfile != NULL)
- {
- long cbytes;
-
- cbytes = csysdep_size (zfile);
- if (cbytes > 0)
- csize += cbytes;
- ubuffree (zfile);
- }
- }
- }
-
- if (ccommands == 0)
- fmatch = TRUE;
- else
- {
- int i;
-
- fmatch = fnotcommands;
- for (i = 0; i < ccommands; i++)
- {
- if (strcmp (pazcommands[i], "ALL") == 0
- || strcmp (pazcommands[i], zprog) == 0)
- {
- fmatch = ! fmatch;
- break;
- }
- }
- }
-
- /* To get the name of the standard input file on this system
- we have to look through the list of file transfers to
- find the right one on the remote system. */
- if (fmatch)
- {
- struct scmdlist *qstdin;
-
- if (qxqt->s.bcmd == 'E')
- qstdin = qxqt;
- else if (zSxqt_stdin != NULL)
- {
- for (qstdin = qlist;
- qstdin != NULL;
- qstdin = qstdin->qnext)
- if (qstdin->s.bcmd == 'S'
- && strcmp (qstdin->s.zto, zSxqt_stdin) == 0)
- break;
- }
- else
- qstdin = NULL;
-
- if (qstdin != NULL)
- {
- if (strchr (qstdin->s.zoptions, 'C') != NULL
- || fspool_file (qstdin->s.zfrom))
- zstdin = qstdin->s.ztemp;
- else
- zstdin = qstdin->s.zfrom;
- }
- }
-
- if (fmatch && (icmd & JOB_SHOW) != 0)
- {
- usworkfile_header (qsys, &qxqt->s, zlistid, qxqt->itime,
- TRUE);
- printf ("Executing %s (sending %ld bytes)\n", zcmd, csize);
- }
- }
-
- if (fmatch)
- {
- boolean fkill_or_rejuv;
-
- fkill_or_rejuv = FALSE;
- if ((icmd & JOB_INQUIRE) != 0)
- {
- int b;
-
- /* Ask stdin whether this job should be killed. */
- fprintf (stderr, "%s: %s %s? ",
- zProgram,
- (icmd & JOB_REJUVENATE) != 0 ? "Rejuvenate" : "Kill",
- zlistid);
- (void) fflush (stderr);
- b = getchar ();
- fkill_or_rejuv = b == 'y' || b == 'Y';
- while (b != EOF && b != '\n')
- b = getchar ();
- }
- else if ((icmd & JOB_KILL) != 0
- || (icmd & JOB_REJUVENATE) != 0)
- fkill_or_rejuv = TRUE;
-
- if (fkill_or_rejuv
- && (qlist->s.zuser == NULL
- || strcmp (zsysdep_login_name (), qlist->s.zuser) != 0)
- && ! fsysdep_privileged ())
- ulog (LOG_ERROR, "%s: Not submitted by you", zlistid);
- else
- {
- if ((icmd & (JOB_MAIL | JOB_NOTIFY)) != 0)
- {
- if (! fsnotify (puuconf, icmd, zcomment, cstdin,
- (fkill_or_rejuv &&
- (icmd & JOB_REJUVENATE) == 0),
- zcmd, qlist, zlistid, qlist->itime,
- qlist->s.zuser, qsys, zstdin,
- qlist->s.pseq, zrequestor))
- return FALSE;
- }
-
- if (fkill_or_rejuv)
- {
- if ((icmd & JOB_REJUVENATE) == 0)
- {
- if (! fsysdep_kill_job (puuconf, zlistid))
- return FALSE;
- }
- else
- {
- if (! fsysdep_rejuvenate_job (puuconf, zlistid))
- return FALSE;
- }
- }
- }
- }
-
- if (qxqt != NULL)
- {
- if (qxqt->s.bcmd == 'E')
- ubuffree (zfree);
- else
- usxqt_file_free ();
- }
-
- /* Free up the list of entries. */
- qfree = qlist;
- while (qfree != NULL)
- {
- struct scmdlist *qnext;
-
- qnext = qfree->qnext;
- xfree ((pointer) qfree);
- qfree = qnext;
- }
-
- ubuffree (zlistid);
-
- qlist = NULL;
- zlistid = NULL;
- }
-
- /* Start a new list with the entry we just got. */
- if (qcmd != NULL)
- {
- qlist = (struct scmdlist *) xmalloc (sizeof (struct scmdlist));
- qlist->qnext = NULL;
- qlist->s = *qcmd;
- qlist->itime = itime;
- zlistid = zid;
- }
-
- return TRUE;
-}
-
-/* Show the header of the line describing a workfile. */
-
-static void
-usworkfile_header (qsys, qcmd, zjobid, itime, ffirst)
- const struct uuconf_system *qsys;
- const struct scmd *qcmd;
- const char *zjobid;
- long itime;
- boolean ffirst;
-{
- const char *zshowid;
- struct tm stime;
-
- if (ffirst)
- zshowid = zjobid;
- else
- zshowid = "-";
-
- printf ("%s %s %s ", zshowid, qsys->uuconf_zname,
- qcmd->zuser != NULL ? qcmd->zuser : OWNER);
-
- usysdep_localtime (itime, &stime);
- printf ("%02d-%02d %02d:%02d ",
- stime.tm_mon + 1, stime.tm_mday, stime.tm_hour, stime.tm_min);
-}
-
-/* List queued executions that have not been processed by uuxqt for
- one reason or another. */
-
-static boolean
-fsexecutions (puuconf, icmd, csystems, pazsystems, fnotsystems, cusers,
- pazusers, fnotusers, iold, iyoung, ccommands, pazcommands,
- fnotcommands, zcomment, cstdin)
- pointer puuconf;
- int icmd;
- int csystems;
- char **pazsystems;
- boolean fnotsystems;
- int cusers;
- char **pazusers;
- boolean fnotusers;
- long iold;
- long iyoung;
- int ccommands;
- char **pazcommands;
- boolean fnotcommands;
- const char *zcomment;
- int cstdin;
-{
- const char *zlocalname;
- int iuuconf;
- char *zfile;
- char *zsystem;
- boolean ferr;
-
- iuuconf = uuconf_localname (puuconf, &zlocalname);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- zlocalname = zsysdep_localname ();
- if (zlocalname == NULL)
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
-
- if (! fsysdep_get_xqt_init ((const char *) NULL))
- return FALSE;
-
- while ((zfile = zsysdep_get_xqt ((const char *) NULL, &zsystem, &ferr))
- != NULL)
- {
- boolean fmatch;
- int i;
- long itime;
- FILE *e;
-
- if (csystems > 0)
- {
- fmatch = fnotsystems;
- for (i = 0; i < csystems; i++)
- {
- if (strcmp (pazsystems[i], zsystem) == 0)
- {
- fmatch = ! fmatch;
- break;
- }
- }
- if (! fmatch)
- {
- ubuffree (zfile);
- ubuffree (zsystem);
- continue;
- }
- }
-
- itime = ixsysdep_file_time (zfile);
-
- if ((iold != (long) -1 && itime > iold)
- || (iyoung != (long) -1 && itime < iyoung))
- {
- ubuffree (zfile);
- ubuffree (zsystem);
- continue;
- }
-
- /* We need to read the execution file before we can check the
- user name. */
- e = fopen (zfile, "r");
- if (e == NULL)
- {
- /* Probably uucico just deleted the file. */
- continue;
- }
- if (! fsxqt_file_read (puuconf, e))
- {
- (void) fclose (e);
- ubuffree (zfile);
- ubuffree (zsystem);
- continue;
- }
- (void) fclose (e);
-
- if (cusers == 0)
- fmatch = TRUE;
- else
- {
- fmatch = fnotusers;
- for (i = 0; i < cusers; i++)
- {
- if (strcmp (zSxqt_user, pazusers[i]) == 0
- || (zSxqt_requestor != NULL
- && strcmp (zSxqt_requestor, pazusers[i]) == 0))
- {
- fmatch = ! fmatch;
- break;
- }
- }
- }
-
- if (fmatch && ccommands > 0)
- {
- fmatch = fnotcommands;
- for (i = 0; i < ccommands; i++)
- {
- if (strcmp (pazcommands[i], "ALL") == 0
- || strcmp (pazcommands[i], zSxqt_prog) == 0)
- {
- fmatch = ! fmatch;
- break;
- }
- }
- }
-
- if (fmatch)
- {
- boolean fbad, fkill_or_rejuv;
- struct uuconf_system ssys;
-
- fbad = FALSE;
-
- if ((icmd & JOB_SHOW) != 0)
- {
- struct tm stime;
-
- printf ("%s %s!", zsystem, zSxqt_system);
- if (zSxqt_requestor != NULL)
- printf ("%s", zSxqt_requestor);
- else
- printf ("%s", zSxqt_user);
-
- usysdep_localtime (itime, &stime);
- printf (" %02d-%02d %02d:%02d ",
- stime.tm_mon + 1, stime.tm_mday, stime.tm_hour,
- stime.tm_min);
-
- printf ("%s\n", zSxqt_cmd);
- }
-
- fkill_or_rejuv = FALSE;
- if ((icmd & JOB_INQUIRE) != 0)
- {
- int b;
-
- /* Ask stdin whether this job should be killed. */
- fprintf (stderr, "%s: %s %s? ",
- zProgram,
- (icmd & JOB_REJUVENATE) != 0 ? "Rejuvenate" : "Kill",
- zSxqt_cmd);
- (void) fflush (stderr);
- b = getchar ();
- fkill_or_rejuv = b == 'y' || b == 'Y';
- while (b != EOF && b != '\n')
- b = getchar ();
- }
- else if ((icmd & JOB_KILL) != 0
- || (icmd & JOB_REJUVENATE) != 0)
- fkill_or_rejuv = TRUE;
-
- if (fkill_or_rejuv)
- {
- if ((strcmp (zSxqt_user, zsysdep_login_name ()) != 0
- || strcmp (zsystem, zlocalname) != 0)
- && ! fsysdep_privileged ())
- {
- ulog (LOG_ERROR, "Job not submitted by you\n");
- fbad = TRUE;
- }
- }
-
- if (! fbad)
- {
- iuuconf = uuconf_system_info (puuconf, zsystem, &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fbad = TRUE;
- }
- else if (strcmp (zsystem, zlocalname) == 0)
- {
- iuuconf = uuconf_system_local (puuconf, &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fbad = TRUE;
- }
- ssys.uuconf_zname = (char *) zlocalname;
- }
- else if (! funknown_system (puuconf, zsystem, &ssys))
- {
- ulog (LOG_ERROR, "Job for unknown system %s",
- zsystem);
- fbad = TRUE;
- }
- }
- }
-
- if (! fbad && (icmd & (JOB_MAIL | JOB_NOTIFY)) != 0)
- {
- if (! fsnotify (puuconf, icmd, zcomment, cstdin,
- fkill_or_rejuv && (icmd & JOB_REJUVENATE) == 0,
- zSxqt_cmd, (struct scmdlist *) NULL,
- (const char *) NULL, itime, zSxqt_user, &ssys,
- zSxqt_stdin, (pointer) NULL, zSxqt_requestor))
- {
- ferr = TRUE;
- usxqt_file_free ();
- ubuffree (zfile);
- ubuffree (zsystem);
- break;
- }
- }
-
- if (! fbad && fkill_or_rejuv)
- {
- for (i = 0; i < cSxqt_files; i++)
- {
- char *z;
-
- z = zsysdep_spool_file_name (&ssys, pazSxqt_files[i],
- (pointer) NULL);
- if (z != NULL)
- {
- if ((icmd & JOB_REJUVENATE) != 0)
- (void) fsysdep_touch_file (z);
- else
- (void) remove (z);
- ubuffree (z);
- }
- }
- if ((icmd & JOB_REJUVENATE) != 0)
- (void) fsysdep_touch_file (zfile);
- else
- {
- if (remove (zfile) != 0)
- ulog (LOG_ERROR, "remove (%s): %s", zfile,
- strerror (errno));
- }
- }
-
- if (! fbad)
- (void) uuconf_system_free (puuconf, &ssys);
- }
-
- usxqt_file_free ();
- ubuffree (zfile);
- ubuffree (zsystem);
- }
-
- usysdep_get_xqt_free ((const char *) NULL);
-
- return ferr;
-}
-
-/* When a job is killed, send mail to the appropriate people. */
-
-static boolean
-fsnotify (puuconf, icmd, zcomment, cstdin, fkilled, zcmd, qcmd, zid, itime,
- zuser, qsys, zstdin, pstdinseq, zrequestor)
- pointer puuconf;
- int icmd;
- const char *zcomment;
- int cstdin;
- boolean fkilled;
- const char *zcmd;
- struct scmdlist *qcmd;
- const char *zid;
- long itime;
- const char *zuser;
- const struct uuconf_system *qsys;
- const char *zstdin;
- pointer pstdinseq;
- const char *zrequestor;
-{
- const char **pz;
- int cgot;
- int i, istdin;
- struct tm stime;
- char ab[sizeof "1991-12-31 12:00:00"];
- const char *zsubject;
- boolean fret;
-
- pz = (const char **) xmalloc (20 * sizeof (const char *));
- cgot = 20;
-
- i = 0;
- if (zid == NULL)
- pz[i++] = "A UUCP execution request";
- else
- {
- pz[i++] = "UUCP job\n\t";
- pz[i++] = zid;
- pz[i++] = "\nfor system\n\t";
- pz[i++] = qsys->uuconf_zname;
- }
- pz[i++] = "\nrequested by\n\t";
- pz[i++] = zuser != NULL ? zuser : OWNER;
- if (zid == NULL)
- {
- pz[i++] = "\non system\n\t";
- pz[i++] = qsys->uuconf_zname;
- }
- pz[i++] = "\n";
-
- if (fkilled)
- pz[i++] = "has been killed.\n";
-
- if (zcomment != NULL)
- {
- pz[i++] = zcomment;
- pz[i++] = "\n";
- }
-
- pz[i++] = "The job was queued at ";
- usysdep_localtime (itime, &stime);
- sprintf (ab, "%04d-%02d-%02d %02d:%02d:%02d",
- stime.tm_year + 1900, stime.tm_mon + 1, stime.tm_mday,
- stime.tm_hour, stime.tm_min, stime.tm_sec);
- pz[i++] = ab;
- pz[i++] = ".\nIt ";
-
- if (fkilled)
- pz[i++] = "was\n";
- else
- pz[i++] = "is\n";
-
- if (zcmd != NULL)
- {
- pz[i++] = "\t";
- pz[i++] = zcmd;
- }
- else
- {
- struct scmdlist *qshow;
-
- for (qshow = qcmd; qshow != NULL; qshow = qshow->qnext)
- {
- if (i + 10 > cgot)
- {
- cgot += 20;
- pz = (const char **) xrealloc ((pointer) pz,
- cgot * sizeof (const char *));
- }
-
- switch (qshow->s.bcmd)
- {
- case 'S':
- pz[i++] = "\tsend ";
- break;
- default:
- case 'R':
- case 'X':
- pz[i++] = "\trequest ";
- break;
- case 'P':
- pz[i++] = "\tpoll ";
- break;
-#if DEBUG > 0
- case 'E':
- ulog (LOG_FATAL, "fsnotify: Can't happen");
- break;
-#endif
- }
- if (qshow->s.zfrom != NULL && qshow->s.zto != NULL)
- {
- pz[i++] = qshow->s.zfrom;
- pz[i++] = " to ";
- pz[i++] = qshow->s.zto;
- }
- }
- }
-
- istdin = i;
- if (cstdin > 0 && zstdin != NULL)
- {
- boolean fspool;
- char *zfile;
- FILE *e;
-
- fspool = fspool_file (zstdin);
- if (fspool)
- zfile = zsysdep_spool_file_name (qsys, zstdin, pstdinseq);
- else
- zfile = zsysdep_local_file (zstdin, qsys->uuconf_zpubdir,
- (boolean *) NULL);
-
- if (zfile != NULL
- && (fspool
- || fin_directory_list (zfile, qsys->uuconf_pzremote_send,
- qsys->uuconf_zpubdir, TRUE, TRUE,
- (const char *) NULL)))
- {
- e = fopen (zfile, "r");
- if (e != NULL)
- {
- int clines, clen;
- char *zline;
- size_t cline;
-
- pz[i++] = "\n";
- istdin = i;
-
- clines = 0;
-
- zline = NULL;
- cline = 0;
- while ((clen = getline (&zline, &cline, e)) > 0)
- {
- if (memchr (zline, '\0', (size_t) clen) != NULL)
- {
- int ifree;
-
- /* A null character means this is probably a
- binary file. */
- for (ifree = istdin; ifree < i; ifree++)
- ubuffree ((char *) pz[ifree]);
- i = istdin - 1;
- break;
- }
- ++clines;
- if (clines > cstdin)
- break;
- if (i >= cgot)
- {
- cgot += 20;
- pz = (const char **) xrealloc ((pointer) pz,
- (cgot
- * sizeof (char *)));
- }
- if (strncmp (zline, "From ", sizeof "From " - 1) != 0)
- pz[i++] = zbufcpy (zline);
- else
- {
- char *zalc;
-
- /* Escape "From " at the start of a line. This
- should really be the responsibility of the
- mail transfer agent. On some systems,
- though, the mail transfer agent does not do
- it, but user mail programs expect it. We
- help them out here, since it doesn't matter
- much--we're already truncating the message
- anyhow. */
- zalc = zbufalc (strlen (zline) + 2);
- zalc[0] = '>';
- strcpy (zalc + 1, zline);
- pz[i++] = zalc;
- }
- }
- xfree ((pointer) zline);
- (void) fclose (e);
- }
- }
-
- ubuffree (zfile);
- }
-
- if (fkilled)
- zsubject = "UUCP job killed";
- else
- zsubject = "UUCP notification";
-
- fret = TRUE;
-
- if ((icmd & JOB_MAIL) != 0)
- {
- if (! fsysdep_mail (OWNER, zsubject, i, pz))
- fret = FALSE;
- }
-
- if ((icmd & JOB_NOTIFY) != 0
- && (zrequestor != NULL || zuser != NULL))
- {
- const char *zmail;
- char *zfree;
-
- if (zrequestor != NULL)
- zmail = zrequestor;
- else
- zmail = zuser;
-
- zfree = NULL;
-
- if (zid == NULL)
- {
- int iuuconf;
- const char *zloc;
-
- /* This is an execution request, which may be from another
- system. If it is, we must prepend that system name to
- the user name extracted from the X. file. */
- iuuconf = uuconf_localname (puuconf, &zloc);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- zloc = zsysdep_localname ();
- if (zloc == NULL)
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- if (strcmp (qsys->uuconf_zname, zloc) != 0
-#if HAVE_INTERNET_MAIL
- && strchr (zmail, '@') == NULL
-#endif
- )
- {
- zfree = zbufalc (strlen (qsys->uuconf_zname)
- + strlen (zmail)
- + sizeof "!");
- sprintf (zfree, "%s!%s", qsys->uuconf_zname, zmail);
- zmail = zfree;
- }
- }
-
- if (! fsysdep_mail (zmail, zsubject, i, pz))
- fret = FALSE;
-
- ubuffree (zfree);
- }
-
- while (istdin < i)
- {
- ubuffree ((char *) pz[istdin]);
- istdin++;
- }
-
- xfree ((pointer) pz);
-
- return fret;
-}
-
-/* Handle the -q option. For each remote system this lists the number
- of jobs queued, the number of executions queued, and the current
- call status. We get the executions all at once, because they are
- not accessed by system. They could be, but it is possible to have
- executions pending for an unknown system, so special handling would
- still be required. */
-
-struct sxqtlist
-{
- struct sxqtlist *qnext;
- char *zsystem;
- int cxqts;
- long ifirst;
-};
-
-/* These local functions need the definition of sxqtlist for the
- prototype. */
-
-static boolean fsquery_system P((const struct uuconf_system *qsys,
- struct sxqtlist **pq,
- long inow, const char *zlocalname,
- int csystems, char **pazsystems,
- boolean fnotsystems, long iold, long iyoung));
-static boolean fsquery_show P((const struct uuconf_system *qsys, int cwork,
- long ifirstwork, struct sxqtlist *qxqt,
- long inow, const char *zlocalname,
- int csystems, char **pazsystems,
- boolean fnotsystems, long iold, long iyoung));
-
-static boolean
-fsquery (puuconf, csystems, pazsystems, fnotsystems, iold, iyoung)
- pointer puuconf;
- int csystems;
- char **pazsystems;
- boolean fnotsystems;
- long iold;
- long iyoung;
-{
- int iuuconf;
- const char *zlocalname;
- struct sxqtlist *qlist;
- char *zfile, *zsystem;
- boolean ferr;
- long inow;
- char **pznames, **pz;
- boolean fret;
-
- iuuconf = uuconf_localname (puuconf, &zlocalname);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- zlocalname = zsysdep_localname ();
- if (zlocalname == NULL)
- return FALSE;
- }
- else if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
-
- /* Get a count of all the execution files. */
- if (! fsysdep_get_xqt_init ((const char *) NULL))
- return FALSE;
-
- qlist = NULL;
- while ((zfile = zsysdep_get_xqt ((const char *) NULL, &zsystem, &ferr))
- != NULL)
- {
- struct sxqtlist *qlook;
-
- for (qlook = qlist; qlook != NULL; qlook = qlook->qnext)
- if (strcmp (zsystem, qlook->zsystem) == 0)
- break;
-
- if (qlook != NULL)
- {
- long itime;
-
- ubuffree (zsystem);
- ++qlook->cxqts;
- itime = ixsysdep_file_time (zfile);
- if (itime < qlook->ifirst)
- qlook->ifirst = itime;
- }
- else
- {
- struct sxqtlist *qnew;
-
- qnew = (struct sxqtlist *) xmalloc (sizeof (struct sxqtlist));
- qnew->qnext = qlist;
- qnew->zsystem = zsystem;
- qnew->cxqts = 1;
- qnew->ifirst = ixsysdep_file_time (zfile);
- qlist = qnew;
- }
-
- ubuffree (zfile);
- }
-
- usysdep_get_xqt_free ((const char *) NULL);
-
- if (ferr)
- return FALSE;
-
- inow = ixsysdep_time ((long *) NULL);
-
- /* Show the information for each system. */
- iuuconf = uuconf_system_names (puuconf, &pznames, 0);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- return FALSE;
- }
-
- fret = TRUE;
-
- for (pz = pznames; *pz != NULL; pz++)
- {
- struct uuconf_system ssys;
-
- iuuconf = uuconf_system_info (puuconf, *pz, &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fret = FALSE;
- continue;
- }
-
- if (! fsquery_system (&ssys, &qlist, inow, zlocalname, csystems,
- pazsystems, fnotsystems, iold, iyoung))
- fret = FALSE;
-
- (void) uuconf_system_free (puuconf, &ssys);
- xfree ((pointer) *pz);
- }
-
- /* Check for the local system in the list of execution files. */
- if (qlist != NULL)
- {
- struct sxqtlist **pq;
-
- for (pq = &qlist; *pq != NULL; pq = &(*pq)->qnext)
- {
- if (strcmp ((*pq)->zsystem, zlocalname) == 0)
- {
- struct uuconf_system ssys;
- struct sxqtlist *qfree;
-
- iuuconf = uuconf_system_info (puuconf, zlocalname, &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fret = FALSE;
- break;
- }
-
- iuuconf = uuconf_system_local (puuconf, &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- fret = FALSE;
- break;
- }
- ssys.uuconf_zname = (char *) zlocalname;
- }
-
- if (! fsquery_show (&ssys, 0, 0L, *pq, inow, zlocalname,
- csystems, pazsystems, fnotsystems,
- iold, iyoung))
- fret = FALSE;
- (void) uuconf_system_free (puuconf, &ssys);
- qfree = *pq;
- *pq = qfree->qnext;
- ubuffree (qfree->zsystem);
- xfree ((pointer) qfree);
- break;
- }
- }
- }
-
- /* Print out information for any unknown systems for which we have
- execution files. */
- while (qlist != NULL)
- {
- struct uuconf_system ssys;
- struct sxqtlist *qnext;
-
- if (! funknown_system (puuconf, qlist->zsystem, &ssys))
- {
- ulog (LOG_ERROR, "Executions queued up for unknown systems");
- fret = FALSE;
- break;
- }
-
- if (! fsquery_show (&ssys, 0, 0L, qlist, inow, zlocalname,
- csystems, pazsystems, fnotsystems, iold, iyoung))
- fret = FALSE;
- (void) uuconf_system_free (puuconf, &ssys);
- qnext = qlist->qnext;
- ubuffree (qlist->zsystem);
- xfree ((pointer) qlist);
- qlist = qnext;
- }
-
- return fret;
-}
-
-/* Query a single known system. */
-
-static boolean
-fsquery_system (qsys, pq, inow, zlocalname, csystems, pazsystems,
- fnotsystems, iold, iyoung)
- const struct uuconf_system *qsys;
- struct sxqtlist **pq;
- long inow;
- const char *zlocalname;
- int csystems;
- char **pazsystems;
- boolean fnotsystems;
- long iold;
- long iyoung;
-{
- int cwork;
- long ifirstwork;
- char *zid;
- boolean fret;
-
- if (! fsysdep_get_work_init (qsys, UUCONF_GRADE_LOW))
- return FALSE;
-
- cwork = 0;
- ifirstwork = 0L;
- zid = NULL;
- while (TRUE)
- {
- struct scmd s;
- long itime;
- char *zthisid;
-
- if (! fsysdep_get_work (qsys, UUCONF_GRADE_LOW, &s))
- return FALSE;
- if (s.bcmd == 'H')
- break;
-
- zthisid = zsysdep_jobid (qsys, s.pseq);
- if (zid != NULL && strcmp (zid, zthisid) == 0)
- ubuffree (zthisid);
- else
- {
- ++cwork;
- ubuffree (zid);
- zid = zthisid;
- }
-
- itime = ixsysdep_work_time (qsys, s.pseq);
- if (ifirstwork == 0L || ifirstwork > itime)
- ifirstwork = itime;
- }
-
- usysdep_get_work_free (qsys);
- ubuffree (zid);
-
- /* Find the execution information, if any. */
- while (*pq != NULL)
- {
- if (strcmp ((*pq)->zsystem, qsys->uuconf_zname) == 0)
- break;
- pq = &(*pq)->qnext;
- }
-
- /* If there are no commands and no executions, don't print any
- information for this system. */
- if (cwork == 0 && *pq == NULL)
- return TRUE;
-
- fret = fsquery_show (qsys, cwork, ifirstwork, *pq, inow,
- zlocalname, csystems, pazsystems, fnotsystems,
- iold, iyoung);
-
- if (*pq != NULL)
- {
- struct sxqtlist *qfree;
-
- qfree = *pq;
- *pq = qfree->qnext;
- ubuffree (qfree->zsystem);
- xfree ((pointer) qfree);
- }
-
- return fret;
-}
-
-/* Print out the query information for a single system. We handle the
- local system specially. */
-
-static boolean
-fsquery_show (qsys, cwork, ifirstwork, qxqt, inow, zlocalname,
- csystems, pazsystems, fnotsystems, iold, iyoung)
- const struct uuconf_system *qsys;
- int cwork;
- long ifirstwork;
- struct sxqtlist *qxqt;
- long inow;
- const char *zlocalname;
- int csystems;
- char **pazsystems;
- boolean fnotsystems;
- long iold;
- long iyoung;
-{
- boolean flocal;
- struct sstatus sstat;
- boolean fnostatus;
- struct tm stime;
- int cpad;
-
- /* Make sure this is one of the systems we are printing. */
- if (csystems > 0)
- {
- boolean fmatch;
- int i;
-
- fmatch = fnotsystems;
- for (i = 0; i < csystems; i++)
- {
- if (strcmp (pazsystems[i], qsys->uuconf_zname) == 0)
- {
- fmatch = ! fmatch;
- break;
- }
- }
- if (! fmatch)
- return TRUE;
- }
-
- /* Make sure the commands are within the time bounds. */
- if ((iold != (long) -1
- && (cwork == 0 || ifirstwork > iold)
- && (qxqt == NULL || qxqt->ifirst > iold))
- || (iyoung != (long) -1
- && (cwork == 0 || ifirstwork < iyoung)
- && (qxqt == NULL || qxqt->ifirst < iyoung)))
- return TRUE;
-
- flocal = strcmp (qsys->uuconf_zname, zlocalname) == 0;
-
- if (! flocal)
- {
- if (! fsysdep_get_status (qsys, &sstat, &fnostatus))
- return FALSE;
- }
-
- printf ("%-10s %3dC (", qsys->uuconf_zname, cwork);
-
- if (cwork == 0)
- {
- printf ("0 secs");
- cpad = 3;
- }
- else
- cpad = csunits_show (inow - ifirstwork);
-
- printf (") ");
- while (cpad-- != 0)
- printf (" ");
-
- if (qxqt == NULL)
- printf (" 0X (0 secs) ");
- else
- {
- printf ("%3dX (", qxqt->cxqts);
- cpad = csunits_show (inow - qxqt->ifirst);
- printf (")");
- while (cpad-- != 0)
- printf (" ");
- }
-
- if (flocal || fnostatus)
- {
- printf ("\n");
- if (! flocal)
- ubuffree (sstat.zstring);
- return TRUE;
- }
-
- usysdep_localtime (sstat.ilast, &stime);
-
- printf (" %02d-%02d %02d:%02d ",
- stime.tm_mon + 1,stime.tm_mday, stime.tm_hour, stime.tm_min);
-
- if (sstat.zstring == NULL)
- printf ("%s\n", azStatus[(int) sstat.ttype]);
- else
- {
- printf ("%s\n", sstat.zstring);
- ubuffree (sstat.zstring);
- }
-
- return TRUE;
-}
-
-/* Print a time difference in the largest applicable units. */
-
-static int
-csunits_show (idiff)
- long idiff;
-{
- const char *zunit;
- long iunits;
- int cpad;
-
- if (idiff > (long) 24 * (long) 60 * (long) 60)
- {
- iunits = idiff / ((long) 24 * (long) 60 * (long) 60);
- zunit = "day";
- cpad = 4;
- }
- else if (idiff > (long) 60 * 60)
- {
- iunits = idiff / (long) (60 * 60);
- zunit = "hour";
- cpad = 3;
- }
- else if (idiff > (long) 60)
- {
- iunits = idiff / (long) 60;
- zunit = "min";
- cpad = 4;
- }
- else
- {
- iunits = idiff;
- zunit = "sec";
- cpad = 4;
- }
-
- printf ("%ld %s%s", iunits, zunit, iunits == 1 ? "" : "s");
-
- if (iunits != 1)
- --cpad;
- if (iunits > 99)
- --cpad;
- if (iunits > 9)
- --cpad;
- return cpad;
-}
-
-/* Give a list of all status entries for all machines that we have
- status entries for. We need to get a list of status entries in a
- system dependent fashion, since we may have status for unknown
- systems. */
-
-static boolean
-fsmachines ()
-{
- pointer phold;
- char *zsystem;
- boolean ferr;
- struct sstatus sstat;
-
- if (! fsysdep_all_status_init (&phold))
- return FALSE;
-
- while ((zsystem = zsysdep_all_status (phold, &ferr, &sstat)) != NULL)
- {
- struct tm stime;
-
- usysdep_localtime (sstat.ilast, &stime);
- printf ("%-14s %02d-%02d %02d:%02d ", zsystem,
- stime.tm_mon + 1, stime.tm_mday, stime.tm_hour,
- stime.tm_min);
- if (sstat.zstring == NULL)
- printf ("%s", azStatus[(int) sstat.ttype]);
- else
- {
- printf ("%s", sstat.zstring);
- ubuffree (sstat.zstring);
- }
- ubuffree (zsystem);
- if (sstat.ttype != STATUS_TALKING
- && sstat.cwait > 0)
- {
- printf (" (%d %s", sstat.cretries,
- sstat.cretries == 1 ? "try" : "tries");
- if (sstat.ilast + sstat.cwait > ixsysdep_time ((long *) NULL))
- {
- usysdep_localtime (sstat.ilast + sstat.cwait, &stime);
- printf (", next after %02d-%02d %02d:%02d",
- stime.tm_mon + 1, stime.tm_mday, stime.tm_hour,
- stime.tm_min);
- }
- printf (")");
- }
- printf ("\n");
- }
-
- usysdep_all_status_free (phold);
-
- return ! ferr;
-}
diff --git a/gnu/libexec/uucp/uuto/Makefile b/gnu/libexec/uucp/uuto/Makefile
deleted file mode 100644
index d7a8e69..0000000
--- a/gnu/libexec/uucp/uuto/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# Makefile for uuto
-# $Id: Makefile,v 1.8 1997/02/22 15:28:52 peter Exp $
-
-BINDIR= $(bindir)
-CLEANFILES+= $(ONESHPROG)
-ONESHPROG= uuto
-MAN1= uuto.1
-
-all: $(ONESHPROG)
-
-$(ONESHPROG): $(ONESHPROG).in Makefile
- sed -e "s|@BINDIR@|$(bindir)|g" \
- $(.ALLSRC:N*Makefile) > $(.TARGET)
-
-beforeinstall:
- ${INSTALL} -c -o $(BINOWN) -g $(BINGRP) -m $(BINMODE) \
- $(ONESHPROG) $(DESTDIR)$(BINDIR)/$(ONESHPROG)
-
-.include <bsd.prog.mk>
diff --git a/gnu/libexec/uucp/uuto/uuto.1 b/gnu/libexec/uucp/uuto/uuto.1
deleted file mode 100644
index b215b99..0000000
--- a/gnu/libexec/uucp/uuto/uuto.1
+++ /dev/null
@@ -1,41 +0,0 @@
-''' $Id: uustat.1,v 1.8 1997/02/22 15:28:49 peter Exp $
-''' based on the uucp texinfo documentation
-.TH uuto 1 "Taylor UUCP 1.06"
-.SH NAME
-uuto \- send files to a user on a remote system.
-.SH SYNOPSIS
-.B uuto
-[uucp options] files... system!user
-.SH DESCRIPTION
-The
-.B uuto
-program may be used to conveniently send files to a
-particular user on a remote system. It will arrange for mail to be sent
-to the remote user when the files arrive on the remote system, and he or
-she may easily retrieve the files using the
-.B uupick
-program. Note that
-.B uuto
-does not provide any
-security--any user on the remote system can examine the files.
-.PP
-The last argument specifies the system and user name to which to send
-the files. The other arguments are the files or directories to be sent.
-.PP
-The
-.B uuto
-program is actually just a trivial shell script which
-invokes the
-.B uucp
-program with the appropriate arguments. Any option
-which may be given to
-.B uucp
-may also be given to
-.B uuto.
-.SH SEE ALSO
-uucp(1)
-.SH AUTHOR
-Ian Lance Taylor (ian@airs.com).
-This Manpage based on the Taylor UUCP 1.06 Texinfo documentation.
-
-
diff --git a/gnu/libexec/uucp/uuto/uuto.in b/gnu/libexec/uucp/uuto/uuto.in
deleted file mode 100644
index 26a0dc7..0000000
--- a/gnu/libexec/uucp/uuto/uuto.in
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-# uuto
-# Send files to a user on another system.
-#
-# Copyright (C) 1992, 1993 Ian Lance Taylor
-#
-# Please feel free do whatever you like with this exciting shell
-# script.
-#
-# This is pretty trivial, since all the functionality was moved into
-# uucp itself. The -t means to interpret the final argument as
-# system!user, the -R means to copy directories recursively, and the
-# -c means to not copy the files to the spool directory (may be
-# overriden by -C or -p).
-#
-exec @BINDIR@/uucp -t -R -c $*
diff --git a/gnu/libexec/uucp/uux/Makefile b/gnu/libexec/uucp/uux/Makefile
deleted file mode 100644
index 2814b6b..0000000
--- a/gnu/libexec/uucp/uux/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Makefile for uux
-# $Id$
-
-BINDIR= $(bindir)
-BINOWN= $(owner)
-BINMODE= 4555
-
-PROG= uux
-SRCS= uux.c util.c log.c copy.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -DVERSION=\"$(VERSION)\"
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../common_sources
diff --git a/gnu/libexec/uucp/uux/uux.1 b/gnu/libexec/uucp/uux/uux.1
deleted file mode 100644
index ddcbcf5..0000000
--- a/gnu/libexec/uucp/uux/uux.1
+++ /dev/null
@@ -1,255 +0,0 @@
-''' $Id$
-.TH uux 1 "Taylor UUCP 1.06"
-.SH NAME
-uux \- Remote command execution over UUCP
-.SH SYNOPSIS
-.B uux
-[ options ] command
-.SH DESCRIPTION
-The
-.I uux
-command is used to execute a command on a remote system, or to execute
-a command on the local system using files from remote systems.
-The command
-is not executed immediately; the request is queued until the
-.I uucico
-(8) daemon calls the system and executes it. The daemon is
-started automatically unless one of the
-.B \-r
-or
-.B \-\-nouucico
-options is given.
-
-The actual command execution is done by the
-.I uuxqt
-(8) daemon.
-
-File arguments can be gathered from remote systems to the execution
-system, as can standard input. Standard output may be directed to a
-file on a remote system.
-
-The command name may be preceded by a system name followed by an
-exclamation point if it is to be executed on a remote system. An
-empty system name is taken as the local system.
-
-Each argument that contains an exclamation point is treated as naming
-a file. The system which the file is on is before the exclamation
-point, and the pathname on that system follows it. An empty system
-name is taken as the local system; this must be used to transfer a
-file to a command being executed on a remote system. If the path is
-not absolute, it will be appended to the current working directory on
-the local system; the result may not be meaningful on the remote
-system. A pathname may begin with ~/, in which case it is relative to
-the UUCP public directory (usually /var/spool/uucppublic) on the
-appropriate system. A pathname may begin with ~name/, in which case
-it is relative to the home directory of the named user on the
-appropriate system.
-
-Standard input and output may be redirected as usual; the pathnames
-used may contain exclamation points to indicate that they are on
-remote systems. Note that the redirection characters must be quoted
-so that they are passed to
-.I uux
-rather than interpreted by the shell. Append redirection (>>) does
-not work.
-
-All specified files are gathered together into a single directory
-before execution of the command begins. This means that each file
-must have a distinct base name. For example,
-.br
-.in +0.5i
-.nf
-uux 'sys1!diff sys2!~user1/foo sys3!~user2/foo >!foo.diff'
-.fi
-.in -0.5i
-will fail because both files will be copied to sys1 and stored under
-the name foo.
-
-Arguments may be quoted by parentheses to avoid interpretation of
-exclamation points. This is useful when executing the
-.I uucp
-command on a remote system.
-
-A request to execute an empty command (e.g.,
-.I uux sys!)
-will create a poll file for the specified system.
-.SH OPTIONS
-The following options may be given to
-.I uux.
-.TP 5
-.B \-, \-p, \-\-stdin
-Read standard input and use it as the standard input for the command
-to be executed.
-.TP 5
-.B \-c, \-\-nocopy
-Do not copy local files to the spool directory. This is the default.
-If they are
-removed before being processed by the
-.I uucico
-(8) daemon, the copy will fail. The files must be readable by the
-.I uucico
-(8) daemon,
-as well as the by the invoker of
-.I uux.
-.TP 5
-.B \-C, \-\-copy
-Copy local files to the spool directory.
-.TP 5
-.B \-l, \-\-link
-Link local files into the spool directory. If a file can not be
-linked because it is on a different device, it will be copied unless
-one of the
-.B \-c
-or
-.B \-\-nocopy
-options also appears (in other words, use of
-.B \-\-link
-switches the default from
-.B \-\-nocopy
-to
-.B \-\-copy).
-If the files are changed before being processed by the
-.I uucico
-(8) daemon, the changed versions will be used. The files must be
-readable by the
-.I uucico
-(8) daemon, as well as by the invoker of
-.I uux.
-.TP 5
-.B \-g grade, \-\-grade grade
-Set the grade of the file transfer command. Jobs of a higher grade
-are executed first. Grades run 0 ... 9 A ... Z a ... z from high to
-low.
-.TP 5
-.B \-n, \-\-notification=no
-Do not send mail about the status of the job, even if it fails.
-.TP 5
-.B \-z, \-\-notification=error
-Send mail about the status of the job if an error occurs. For many
-.I uuxqt
-daemons, including the Taylor UUCP
-.I uuxqt,
-this is the default action; for those,
-.B \-\-notification=error
-will have no effect. However, some
-.I uuxqt
-daemons will send mail if the job succeeds unless the
-.B \-\-notification=error
-option is used, and some other
-.I uuxqt
-daemons will not send mail if the job fails unless the
-.B \-\-notification=error
-option is used.
-.TP 5
-.B \-r, \-\-nouucico
-Do not start the
-.I uucico
-(8) daemon immediately; merely queue up the execution request for later
-processing.
-.TP 5
-.B \-j, \-\-jobid
-Print jobids on standard output. A jobid will be generated for each
-file copy operation required to perform the operation. These file
-copies may be cancelled by passing the jobid to the
-.B \-\-kill
-switch of
-.I uustat
-(1), which will make the execution impossible to complete.
-.TP 5
-.B \-a address, \-\-requestor address
-Report job status to the specified e-mail address.
-.TP 5
-.B \-x type, \-\-debug type
-Turn on particular debugging types. The following types are
-recognized: abnormal, chat, handshake, uucp-proto, proto, port,
-config, spooldir, execute, incoming, outgoing. Only abnormal, config,
-spooldir and execute are meaningful for
-.I uux.
-
-Multiple types may be given, separated by commas, and the
-.B \-\-debug
-option may appear multiple times. A number may also be given, which
-will turn on that many types from the foregoing list; for example,
-.B \-\-debug 2
-is equivalent to
-.B \-\-debug abnormal,chat.
-.TP 5
-.B \-I file, \-\-config file
-Set configuration file to use. This option may not be available,
-depending upon how
-.I uux
-was compiled.
-.TP 5
-.B \-v, \-\-version
-Report version information and exit.
-.TP 5
-.B \-\-help
-Print a help message and exit.
-.SH EXAMPLES
-.br
-.nf
-uux -z - sys1!rmail user1
-.fi
-Execute the command ``rmail user1'' on the system sys1, giving it as
-standard input whatever is given to
-.I uux
-as standard input. If a failure occurs, send a message using
-.I mail
-(1).
-
-.br
-.nf
-uux 'diff -c sys1!~user1/file1 sys2!~user2/file2 >!file.diff'
-.fi
-Fetch the two named files from system sys1 and system sys2 and execute
-.I diff
-putting the result in file.diff in the current directory. The current
-directory must be writable by the
-.I uuxqt
-(8) daemon for this to work.
-
-.br
-.nf
-uux 'sys1!uucp ~user1/file1 (sys2!~user2/file2)'
-.fi
-Execute
-.I uucp
-on the system sys1 copying file1 (on system sys1) to sys2. This
-illustrates the use of parentheses for quoting.
-.SH RESTRICTIONS
-The remote system may not permit you to execute certain commands.
-Many remote systems only permit the execution of
-.I rmail
-and
-.I rnews.
-
-Some of the options are dependent on the capabilities of the
-.I uuxqt
-(8) daemon on the remote system.
-.SH FILES
-The file names may be changed at compilation time or by the
-configuration file, so these are only approximations.
-
-.br
-/etc/uucp/config - Configuration file.
-.br
-/var/spool/uucp -
-UUCP spool directory.
-.br
-/var/spool/uucp/Log -
-UUCP log file.
-.br
-/var/spool/uucppublic -
-Default UUCP public directory.
-.SH SEE ALSO
-mail(1), uustat(1), uucp(1), uucico(8), uuxqt(8)
-.SH BUGS
-Files can not be referenced across multiple systems.
-
-Too many jobids are output by
-.B \-\-jobid,
-and there is no good way to cancel a local execution requiring remote
-files.
-.SH AUTHOR
-Ian Lance Taylor
-(ian@airs.com)
diff --git a/gnu/libexec/uucp/uux/uux.c b/gnu/libexec/uucp/uux/uux.c
deleted file mode 100644
index cb7cdac..0000000
--- a/gnu/libexec/uucp/uux/uux.c
+++ /dev/null
@@ -1,1626 +0,0 @@
-/* uux.c
- Prepare to execute a command on a remote system.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char uux_rcsid[] = "$Id$";
-#endif
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-#include "sysdep.h"
-#include "getopt.h"
-
-#include <ctype.h>
-#include <errno.h>
-
-/* These character lists should, perhaps, be in sysdep.h. */
-
-/* This is the list of shell metacharacters that we check for. If one
- of these is present, we request uuxqt to execute the command with
- /bin/sh. Otherwise we let it execute using execve. */
-
-#define ZSHELLCHARS "\"'`*?[;&()|<>\\$"
-
-/* This is the list of word separators. We break filename arguments
- at these characters. */
-#define ZSHELLSEPS ";&*|<> \t"
-
-/* This is the list of word separators without the redirection
- operators. */
-#define ZSHELLNONREDIRSEPS ";&*| \t"
-
-/* Whether this execution is occurring on the local system. */
-static boolean fXxqtlocal;
-
-/* The execution system. */
-static struct uuconf_system sXxqtsys;
-
-/* The name of local system from the point of view of the execution
- system. */
-static const char *zXxqtloc;
-
-/* The job grade to use. */
-static char bXgrade = BDEFAULT_UUX_GRADE;
-
-/* The temporary file name of the execute file. */
-static char abXxqt_tname[CFILE_NAME_LEN];
-
-/* The name of the execute file on the remote system. */
-static char abXxqt_xname[CFILE_NAME_LEN];
-
-/* The execute file we are creating. */
-static FILE *eXxqt_file;
-
-/* A list of commands to be spooled. */
-static struct scmd *pasXcmds;
-static int cXcmds;
-
-/* A file to close if we're forced to exit. */
-static FILE *eXclose;
-
-/* A list of file names which will match the file names which appear
- in the uucico logs. */
-static char *zXnames;
-
-/* Local functions. */
-static void uxusage P((void));
-static void uxhelp P((void));
-static void uxadd_xqt_line P((int bchar, const char *z1, const char *z2));
-static void uxadd_send_file P((const char *zfrom, const char *zto,
- const char *zoptions, const char *ztemp,
- const char *zforward));
-static void uxcopy_stdin P((FILE *e));
-static void uxrecord_file P((const char *zfile));
-static void uxabort P((void));
-static void uxadd_name P((const char *));
-
-/* Long getopt options. */
-static const struct option asXlongopts[] =
-{
- { "requestor", required_argument, NULL, 'a' },
- { "return-stdin", no_argument, NULL, 'b' },
- { "nocopy", no_argument, NULL, 'c' },
- { "copy", no_argument, NULL, 'C' },
- { "grade", required_argument, NULL, 'g' },
- { "jobid", no_argument, NULL, 'j' },
- { "link", no_argument, NULL, 'l' },
- { "notification", required_argument, NULL, 2 },
- { "stdin", no_argument, NULL, 'p' },
- { "nouucico", no_argument, NULL, 'r' },
- { "status", required_argument, NULL, 's' },
- { "noexpand", no_argument, NULL, 'W' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'x' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-/* The main routine. */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- /* -a: requestor address for status reports. */
- const char *zrequestor = NULL;
- /* -b: if true, return standard input on error. */
- boolean fretstdin = FALSE;
- /* -c,-C: if true, copy to spool directory. */
- boolean fcopy = FALSE;
- /* -c: set if -c appears explicitly; if it and -l appear, then if the
- link fails we don't copy the file. */
- boolean fdontcopy = FALSE;
- /* -I: configuration file name. */
- const char *zconfig = NULL;
- /* -j: output job id. */
- boolean fjobid = FALSE;
- /* -l: link file to spool directory. */
- boolean flink = FALSE;
- /* -n: do not notify upon command completion. */
- boolean fno_ack = FALSE;
- /* -p: read standard input for command standard input. */
- boolean fread_stdin = FALSE;
- /* -r: do not start uucico when finished. */
- boolean fuucico = TRUE;
- /* -s: report status to named file. */
- const char *zstatus_file = NULL;
- /* -W: only expand local file names. */
- boolean fexpand = TRUE;
- /* -z: report status only on error. */
- boolean ferror_ack = FALSE;
- int iopt;
- pointer puuconf;
- int iuuconf;
- const char *zlocalname;
- int i;
- size_t clen;
- char *zargs;
- char *zarg;
- char *zcmd;
- const char *zsys;
- char *zexclam;
- boolean fgetcwd;
- const char *zuser;
- char *zforward;
- char **pzargs;
- int calloc_args;
- int cargs;
- const char *zinput_from;
- const char *zinput_to;
- const char *zinput_temp;
- boolean finputcopied;
- char *zcall_system;
- boolean fcall_any;
- struct uuconf_system slocalsys;
- boolean fneedshell;
- char *zfullcmd;
- boolean fpoll;
- char aboptions[10];
- boolean fexit;
-
- zProgram = argv[0];
-
- /* We need to be able to read a single - as an option, which getopt
- won't do. We handle this by using getopt to scan the argument
- list multiple times, replacing any single "-" with "-p". */
- opterr = 0;
- while (1)
- {
- while (getopt_long (argc, argv, "+a:bcCg:I:jlnprs:Wvx:z",
- asXlongopts, (int *) NULL) != EOF)
- ;
- if (optind >= argc || strcmp (argv[optind], "-") != 0)
- break;
- argv[optind] = zbufcpy ("-p");
- optind = 0;
- }
- opterr = 1;
- optind = 0;
-
- /* The leading + in the getopt string means to stop processing
- options as soon as a non-option argument is seen. */
- while ((iopt = getopt_long (argc, argv, "+a:bcCg:I:jlnprs:Wvx:z",
- asXlongopts, (int *) NULL)) != EOF)
- {
- switch (iopt)
- {
- case 'a':
- /* Set requestor name: mail address to which status reports
- should be sent. */
- zrequestor = optarg;
- break;
-
- case 'b':
- /* Return standard input on error. */
- fretstdin = TRUE;
- break;
-
- case 'c':
- /* Do not copy local files to spool directory. */
- fcopy = FALSE;
- fdontcopy = TRUE;
- break;
-
- case 'C':
- /* Copy local files to spool directory. */
- fcopy = TRUE;
- break;
-
- case 'I':
- /* Configuration file name. */
- if (fsysdep_other_config (optarg))
- zconfig = optarg;
- break;
-
- case 'j':
- /* Output jobid. */
- fjobid = TRUE;
- break;
-
- case 'g':
- /* Set job grade. */
- bXgrade = optarg[0];
- break;
-
- case 'l':
- /* Link file to spool directory. */
- flink = TRUE;
- break;
-
- case 'n':
- /* Do not notify upon command completion. */
- fno_ack = TRUE;
- break;
-
- case 'p':
- /* Read standard input for command standard input. */
- fread_stdin = TRUE;
- break;
-
- case 'r':
- /* Do not start uucico when finished. */
- fuucico = FALSE;
- break;
-
- case 's':
- /* Report status to named file. */
- zstatus_file = optarg;
- break;
-
- case 'W':
- /* Only expand local file names. */
- fexpand = FALSE;
- break;
-
- case 'x':
-#if DEBUG > 1
- /* Set debugging level. */
- iDebug |= idebug_parse (optarg);
-#endif
- break;
-
- case 'z':
- /* Report status only on error. */
- ferror_ack = TRUE;
- break;
-
- case 2:
- /* --notify={true,false,error}. */
- if (*optarg == 't'
- || *optarg == 'T'
- || *optarg == 'y'
- || *optarg == 'Y'
- || *optarg == 'e'
- || *optarg == 'E')
- {
- ferror_ack = TRUE;
- fno_ack = FALSE;
- }
- else if (*optarg == 'f'
- || *optarg == 'F'
- || *optarg == 'n'
- || *optarg == 'N')
- {
- ferror_ack = FALSE;
- fno_ack = TRUE;
- }
- break;
-
- case 'v':
- /* Print version and exit. */
- printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zProgram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 1:
- /* --help. */
- uxhelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found and flag set. */
- break;
-
- default:
- uxusage ();
- break;
- }
- }
-
- if (! UUCONF_GRADE_LEGAL (bXgrade)
- || ((bXgrade < '0' || bXgrade > '9')
- && (bXgrade < 'a' || bXgrade > 'z')
- && (bXgrade < 'A' || bXgrade > 'Z')))
- {
- ulog (LOG_ERROR, "Ignoring illegal grade");
- bXgrade = BDEFAULT_UUX_GRADE;
- }
-
- if (optind == argc)
- uxusage ();
-
- iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
-#if DEBUG > 1
- {
- const char *zdebug;
-
- iuuconf = uuconf_debuglevel (puuconf, &zdebug);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (zdebug != NULL)
- iDebug |= idebug_parse (zdebug);
- }
-#endif
-
- /* The command and files arguments could be quoted in any number of
- ways, so we split them apart ourselves. We do this before
- calling usysdep_initialize because we want to set fgetcwd
- correctly. */
- clen = 1;
- for (i = optind; i < argc; i++)
- clen += strlen (argv[i]) + 1;
-
- zargs = zbufalc (clen);
- *zargs = '\0';
- for (i = optind; i < argc; i++)
- {
- strcat (zargs, argv[i]);
- strcat (zargs, " ");
- }
-
- /* The first argument is the command to execute. */
- clen = strcspn (zargs, ZSHELLSEPS);
- zcmd = zbufalc (clen + 1);
- strncpy (zcmd, zargs, clen);
- zcmd[clen] = '\0';
- zargs += clen;
-
- /* Split the arguments out into an array. We break the arguments
- into alternating sequences of characters not in ZSHELLSEPS
- and characters in ZSHELLSEPS. We remove whitespace. We
- separate the redirection characters '>' and '<' into their
- own arguments to make them easier to process below. */
- calloc_args = 10;
- pzargs = (char **) xmalloc (calloc_args * sizeof (char *));
- cargs = 0;
-
- for (zarg = strtok (zargs, " \t");
- zarg != NULL;
- zarg = strtok ((char *) NULL, " \t"))
- {
- while (*zarg != '\0')
- {
- if (cargs + 1 >= calloc_args)
- {
- calloc_args += 10;
- pzargs = (char **) xrealloc ((pointer) pzargs,
- calloc_args * sizeof (char *));
- }
-
- if (*zarg == '(')
- clen = strlen (zarg);
- else
- clen = strcspn (zarg, ZSHELLSEPS);
- if (clen > 0)
- {
- pzargs[cargs] = zbufalc (clen + 1);
- memcpy (pzargs[cargs], zarg, clen);
- pzargs[cargs][clen] = '\0';
- ++cargs;
- zarg += clen;
- }
-
- /* We deliberately separate '>' and '<' out. */
- if (*zarg != '\0')
- {
- clen = strspn (zarg, ZSHELLNONREDIRSEPS);
- if (clen == 0)
- clen = 1;
- pzargs[cargs] = zbufalc (clen + 1);
- memcpy (pzargs[cargs], zarg, clen);
- pzargs[cargs][clen] = '\0';
- ++cargs;
- zarg += clen;
- }
- }
- }
-
- /* Now look through the arguments to see if we are going to need the
- current working directory. We don't try to make a precise
- determination, just a conservative one. The basic idea is that
- we don't want to get the cwd for 'foo!rmail - user' (note that we
- don't examine the command itself). */
- fgetcwd = FALSE;
- for (i = 0; i < cargs; i++)
- {
- if (pzargs[i][0] == '(')
- continue;
- zexclam = strrchr (pzargs[i], '!');
- if (zexclam != NULL && fsysdep_needs_cwd (zexclam + 1))
- {
- fgetcwd = TRUE;
- break;
- }
- if ((pzargs[i][0] == '<' || pzargs[i][0] == '>')
- && i + 1 < cargs
- && strchr (pzargs[i + 1], '!') == NULL
- && fsysdep_needs_cwd (pzargs[i + 1]))
- {
- fgetcwd = TRUE;
- break;
- }
- }
-
-#ifdef SIGINT
- usysdep_signal (SIGINT);
-#endif
-#ifdef SIGHUP
- usysdep_signal (SIGHUP);
-#endif
-#ifdef SIGQUIT
- usysdep_signal (SIGQUIT);
-#endif
-#ifdef SIGTERM
- usysdep_signal (SIGTERM);
-#endif
-#ifdef SIGPIPE
- usysdep_signal (SIGPIPE);
-#endif
-
- usysdep_initialize (puuconf, INIT_SUID | (fgetcwd ? INIT_GETCWD : 0));
-
- ulog_fatal_fn (uxabort);
-
- zuser = zsysdep_login_name ();
-
- /* Get the local system name. */
- iuuconf = uuconf_localname (puuconf, &zlocalname);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- zlocalname = zsysdep_localname ();
- if (zlocalname == NULL)
- exit (EXIT_FAILURE);
- }
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- /* Get the local system information. */
- iuuconf = uuconf_system_info (puuconf, zlocalname, &slocalsys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- iuuconf = uuconf_system_local (puuconf, &slocalsys);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- slocalsys.uuconf_zname = (char *) zlocalname;
- }
-
- /* Figure out which system the command is to be executed on. */
- zcmd = zremove_local_sys (&slocalsys, zcmd);
- zexclam = strchr (zcmd, '!');
- if (zexclam == NULL)
- {
- zsys = zlocalname;
- fXxqtlocal = TRUE;
- zforward = NULL;
- }
- else
- {
- *zexclam = '\0';
- zsys = zcmd;
- zcmd = zexclam + 1;
- fXxqtlocal = FALSE;
-
- /* See if we must forward this command through other systems
- (e.g. uux a!b!cmd). */
- zexclam = strrchr (zcmd, '!');
- if (zexclam == NULL)
- zforward = NULL;
- else
- {
- clen = zexclam - zcmd;
- zforward = zbufalc (clen);
- memcpy (zforward, zcmd, clen);
- zforward[clen] = '\0';
- zcmd = zexclam + 1;
- }
- }
-
- if (fXxqtlocal)
- sXxqtsys = slocalsys;
- else
- {
- iuuconf = uuconf_system_info (puuconf, zsys, &sXxqtsys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (! funknown_system (puuconf, zsys, &sXxqtsys))
- ulog (LOG_FATAL, "%s: System not found", zsys);
- }
- }
-
- /* Get the local name the remote system know us as. */
- zXxqtloc = sXxqtsys.uuconf_zlocalname;
- if (zXxqtloc == NULL)
- zXxqtloc = zlocalname;
-
- /* Look through the arguments. Any argument containing an
- exclamation point character is interpreted as a file name, and is
- sent to the appropriate system. */
- zinput_from = NULL;
- zinput_to = NULL;
- zinput_temp = NULL;
- finputcopied = FALSE;
- zcall_system = NULL;
- fcall_any = FALSE;
-
- for (i = 0; i < cargs; i++)
- {
- const char *zsystem;
- char *zfile;
- char *zforw;
- boolean finput, foutput;
- boolean flocal, fonxqt;
-
- /* Check for a parenthesized argument; remove the parentheses
- and otherwise ignore it (this is how an exclamation point is
- quoted). */
- if (pzargs[i][0] == '(')
- {
- clen = strlen (pzargs[i]);
- if (pzargs[i][clen - 1] != ')')
- ulog (LOG_ERROR, "Mismatched parentheses");
- else
- pzargs[i][clen - 1] = '\0';
- ++pzargs[i];
- continue;
- }
-
- /* Check whether we are doing a redirection. */
- finput = FALSE;
- foutput = FALSE;
- if (i + 1 < cargs)
- {
- if (pzargs[i][0] == '<')
- finput = TRUE;
- else if (pzargs[i][0] == '>')
- foutput = TRUE;
- if (finput || foutput)
- {
- pzargs[i] = NULL;
- i++;
- }
- }
-
- zexclam = strchr (pzargs[i], '!');
-
- /* If there is no exclamation point and no redirection, this
- argument is left untouched. */
- if (zexclam == NULL && ! finput && ! foutput)
- continue;
-
- if (zexclam != NULL)
- {
- pzargs[i] = zremove_local_sys (&slocalsys, pzargs[i]);
- zexclam = strchr (pzargs[i], '!');
- }
-
- /* Get the system name and file name for this file. */
- if (zexclam == NULL)
- {
- zsystem = zlocalname;
- zfile = pzargs[i];
- flocal = TRUE;
- zforw = NULL;
- }
- else
- {
- *zexclam = '\0';
- zsystem = pzargs[i];
- zfile = zexclam + 1;
- flocal = FALSE;
- zexclam = strrchr (zfile, '!');
- if (zexclam == NULL)
- zforw = NULL;
- else
- {
- *zexclam = '\0';
- zforw = zfile;
- zfile = zexclam + 1;
- }
- }
-
- /* Check if the file is already on the execution system. */
- if (flocal)
- fonxqt = fXxqtlocal;
- else if (fXxqtlocal)
- fonxqt = FALSE;
- else if (zforward == NULL ? zforw != NULL : zforw == NULL)
- fonxqt = FALSE;
- else if (zforward != NULL
- && zforw != NULL
- && strcmp (zforward, zforw) != 0)
- fonxqt = FALSE;
- else if (strcmp (zsystem, sXxqtsys.uuconf_zname) == 0)
- fonxqt = TRUE;
- else if (sXxqtsys.uuconf_pzalias == NULL)
- fonxqt = FALSE;
- else
- {
- char **pzal;
-
- fonxqt = FALSE;
- for (pzal = sXxqtsys.uuconf_pzalias; *pzal != NULL; pzal++)
- {
- if (strcmp (zsystem, *pzal) == 0)
- {
- fonxqt = TRUE;
- break;
- }
- }
- }
-
- /* Turn the file into an absolute path. */
- if (flocal)
- zfile = zsysdep_local_file_cwd (zfile, sXxqtsys.uuconf_zpubdir,
- (boolean *) NULL);
- else if (fexpand)
- zfile = zsysdep_add_cwd (zfile);
- if (zfile == NULL)
- uxabort ();
-
- /* Check for output redirection. */
- if (foutput)
- {
- if (flocal)
- {
- if (! fin_directory_list (zfile,
- sXxqtsys.uuconf_pzremote_receive,
- sXxqtsys.uuconf_zpubdir, TRUE,
- FALSE, (const char *) NULL))
- ulog (LOG_FATAL, "Not permitted to create %s", zfile);
- }
-
- /* There are various cases of output redirection.
-
- uux cmd >out: The command is executed on the local
- system, and the output file is placed on the local
- system (fonxqt is TRUE).
-
- uux cmd >a!out: The command is executed on the local
- system, and the output file is sent to a.
-
- uux a!cmd >out: The command is executed on a, and the
- output file is returned to the local system (flocal
- is TRUE).
-
- uux a!cmd >a!out: The command is executed on a, and the
- output file is left on a (fonxqt is TRUE).
-
- uux a!cmd >b!out: The command is executed on a, and the
- output file is sent to b; traditionally, I believe
- that b is relative to a, rather than to the local
- system. However, this essentially contradicts the
- previous two cases, in which the output file is
- relative to the local system.
-
- Now, the cases that we don't handle.
-
- uux cmd >a!b!out: The command is executed on the local
- system, and the output file is sent to b via a. This
- requires the local uuxqt to support forwarding of the
- output file.
-
- uux a!b!cmd >out: The command is executed on b, which is
- reached via a. Probably the output file is intended
- for the local system, in which case the uuxqt on b
- must support forwarding of the output file.
-
- uux a!b!cmd >c!out: Is c relative to b or to the local
- system? If it's relative to b this is easy to
- handle. Otherwise, we must arrange for the file to
- be sent back to the local system and for the local
- system to send it on to c.
-
- There are many variations of the last case. It's not at
- all clear to me how they should be handled. */
- if (zforward != NULL || zforw != NULL)
- ulog (LOG_FATAL, "May not forward standard output");
-
- if (fonxqt)
- uxadd_xqt_line ('O', zfile, (const char *) NULL);
- else if (flocal)
- uxadd_xqt_line ('O', zfile, zXxqtloc);
- else
- uxadd_xqt_line ('O', zfile, zsystem);
- pzargs[i] = NULL;
- continue;
- }
-
- if (finput)
- {
- if (fread_stdin)
- ulog (LOG_FATAL, "Standard input specified twice");
- pzargs[i] = NULL;
- }
-
- if (flocal)
- {
- char *zuse;
- char *zdata;
- char abtname[CFILE_NAME_LEN];
- char abdname[CFILE_NAME_LEN];
-
- /* It's a local file. If requested by -C, copy the file to
- the spool directory. If requested by -l, link the file
- to the spool directory; if the link fails, we copy the
- file, unless -c was explictly used. If the execution is
- occurring on the local system, we force the copy as well,
- because otherwise we would have to have some way to tell
- uuxqt not to move the file. If the file is being shipped
- to another system, we must set up a transfer request.
- First make sure the user has legitimate access, since we
- are running setuid. */
- if (! fsysdep_access (zfile))
- uxabort ();
-
- zdata = zsysdep_data_file_name (&sXxqtsys, zXxqtloc, bXgrade, FALSE,
- abtname, abdname, (char *) NULL);
- if (zdata == NULL)
- uxabort ();
-
- if (fcopy || flink || fXxqtlocal)
- {
- boolean fdid;
-
- uxrecord_file (zdata);
-
- fdid = FALSE;
- if (flink)
- {
- boolean fworked;
-
- if (! fsysdep_link (zfile, zdata, &fworked))
- uxabort ();
-
- if (fworked)
- fdid = TRUE;
- else if (fdontcopy)
- ulog (LOG_FATAL, "%s: Can't link to spool directory",
- zfile);
- }
-
- if (! fdid)
- {
- openfile_t efile;
-
- efile = esysdep_user_fopen (zfile, TRUE, TRUE);
- if (! ffileisopen (efile))
- uxabort ();
- if (! fcopy_open_file (efile, zdata, FALSE, TRUE, TRUE))
- uxabort ();
- (void) ffileclose (efile);
- }
-
- zuse = abtname;
- }
- else
- {
- /* We don't actually use the spool file name, but we
- need a name to use as the destination. */
- ubuffree (zdata);
- /* Make sure the daemon can access the file. */
- if (! fsysdep_daemon_access (zfile))
- uxabort ();
- if (! fin_directory_list (zfile, sXxqtsys.uuconf_pzlocal_send,
- sXxqtsys.uuconf_zpubdir, TRUE,
- TRUE, zuser))
- ulog (LOG_FATAL, "Not permitted to send from %s",
- zfile);
-
- zuse = zfile;
- }
-
- if (fXxqtlocal)
- {
- if (finput)
- uxadd_xqt_line ('I', zuse, (char *) NULL);
- else
- pzargs[i] = zuse;
- }
- else
- {
- finputcopied = fcopy || flink;
-
- if (finput)
- {
- zinput_from = zuse;
- zinput_to = zbufcpy (abdname);
- zinput_temp = zbufcpy (abtname);
- }
- else
- {
- char *zbase;
-
- uxadd_send_file (zuse, abdname,
- finputcopied ? "C" : "c",
- abtname, zforward);
- zbase = zsysdep_base_name (zfile);
- if (zbase == NULL)
- uxabort ();
- uxadd_xqt_line ('F', abdname, zbase);
- pzargs[i] = zbase;
- }
- }
- }
- else if (fonxqt)
- {
- /* The file is already on the system where the command is to
- be executed. */
- if (finput)
- uxadd_xqt_line ('I', zfile, (const char *) NULL);
- else
- pzargs[i] = zfile;
- }
- else
- {
- struct uuconf_system sfromsys;
- char abtname[CFILE_NAME_LEN];
- struct scmd s;
- char *zjobid;
-
- /* We need to request a remote file. */
- iuuconf = uuconf_system_info (puuconf, zsystem, &sfromsys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (! funknown_system (puuconf, zsystem, &sfromsys))
- ulog (LOG_FATAL, "%s: System not found", zsystem);
- }
-
- if (fonxqt)
- {
- /* The file is already on the system where the command is to
- be executed. */
- if (finput)
- uxadd_xqt_line ('I', zfile, (const char *) NULL);
- else
- pzargs[i] = zfile;
- }
- else
- {
- char *zdata;
-
- if (! sfromsys.uuconf_fcall_transfer
- && ! sfromsys.uuconf_fcalled_transfer)
- ulog (LOG_FATAL,
- "Not permitted to transfer files to or from %s",
- sfromsys.uuconf_zname);
-
- if (zforw != NULL)
- {
- /* This is ``uux cmd a!b!file''. To make this work,
- we would have to be able to set up a request to a
- to fetch file from b and send it to us. But it
- turns out that that will not work, because when a
- sends us the file we will put it in a's spool
- directory, not the local system spool directory.
- So we won't have any way to find it. This is not
- a conceptual problem, and it could doubtless be
- solved. Please feel free to solve it and send me
- the solution. */
- ulog (LOG_FATAL, "File forwarding not supported");
- }
-
- /* We must request the file from the remote system to
- this one. */
- zdata = zsysdep_data_file_name (&slocalsys, zXxqtloc, bXgrade,
- FALSE, abtname, (char *) NULL,
- (char *) NULL);
- if (zdata == NULL)
- uxabort ();
- ubuffree (zdata);
-
- /* Request the file. The special option '9' is a signal
- to uucico that it's OK to receive a file into the
- spool directory; normally such requests are rejected.
- This privilege is easy to abuse. */
- s.bcmd = 'R';
- s.bgrade = bXgrade;
- s.pseq = NULL;
- s.zfrom = zfile;
- s.zto = zbufcpy (abtname);
- s.zuser = zuser;
- s.zoptions = "9";
- s.ztemp = "";
- s.imode = 0600;
- s.znotify = "";
- s.cbytes = -1;
- s.zcmd = NULL;
- s.ipos = 0;
-
- zjobid = zsysdep_spool_commands (&sfromsys, bXgrade, 1, &s);
- if (zjobid == NULL)
- uxabort ();
-
- if (fjobid)
- printf ("%s\n", zjobid);
-
- ubuffree (zjobid);
-
- if (fcall_any)
- {
- ubuffree (zcall_system);
- zcall_system = NULL;
- }
- else
- {
- fcall_any = TRUE;
- zcall_system = zbufcpy (sfromsys.uuconf_zname);
- }
-
- if (fXxqtlocal)
- {
- /* Tell the command execution to wait until the file
- has been received, and tell it the real file
- name. */
- if (finput)
- {
- uxadd_xqt_line ('F', abtname, (char *) NULL);
- uxadd_xqt_line ('I', abtname, (char *) NULL);
- }
- else
- {
- char *zbase;
-
- zbase = zsysdep_base_name (zfile);
- if (zbase == NULL)
- uxabort ();
- uxadd_xqt_line ('F', abtname, zbase);
- pzargs[i] = zbase;
- }
- }
- else
- {
- char abxtname[CFILE_NAME_LEN];
- char *zbase;
- char *zxqt;
- FILE *e;
-
- /* Now we must arrange to forward the file on to the
- execution system. We need to get a name to give
- the file on the execution system (abxtname). */
- zdata = zsysdep_data_file_name (&sXxqtsys, zXxqtloc,
- bXgrade, TRUE, abxtname,
- (char *) NULL,
- (char *) NULL);
- if (zdata == NULL)
- uxabort ();
- ubuffree (zdata);
-
- zbase = zsysdep_base_name (zfile);
- if (zbase == NULL)
- uxabort ();
-
- zxqt = zsysdep_xqt_file_name ();
- if (zxqt == NULL)
- uxabort ();
- e = esysdep_fopen (zxqt, FALSE, FALSE, TRUE);
- if (e == NULL)
- uxabort ();
- uxrecord_file (zxqt);
-
- fprintf (e, "U %s %s\n", zsysdep_login_name (),
- zlocalname);
- fprintf (e, "F %s %s\n", abtname, zbase);
- fprintf (e, "C uucp -C -W -d -g %c %s %s!", bXgrade,
- zbase, sXxqtsys.uuconf_zname);
- if (zforward != NULL)
- fprintf (e, "%s!", zforward);
- fprintf (e, "%s\n", abxtname);
-
- if (! fstdiosync (e, zxqt))
- ulog (LOG_FATAL, "fsync failed");
- if (fclose (e) != 0)
- ulog (LOG_FATAL, "fclose: %s", strerror (errno));
-
- if (finput)
- {
- uxadd_xqt_line ('F', abxtname, (char *) NULL);
- uxadd_xqt_line ('I', abxtname, (char *) NULL);
- ubuffree (zbase);
- }
- else
- {
- uxadd_xqt_line ('F', abxtname, zbase);
- pzargs[i] = zbase;
- }
- }
- }
-
- (void) uuconf_system_free (puuconf, &sfromsys);
- }
- }
-
- /* If standard input is to be read from the stdin of uux, we read it
- here into a temporary file and send it to the execute system. */
- if (fread_stdin)
- {
- char *zdata;
- char abtname[CFILE_NAME_LEN];
- char abdname[CFILE_NAME_LEN];
- FILE *e;
-
- zdata = zsysdep_data_file_name (&sXxqtsys, zXxqtloc, bXgrade, FALSE,
- abtname, abdname, (char *) NULL);
- if (zdata == NULL)
- uxabort ();
-
- e = esysdep_fopen (zdata, FALSE, FALSE, TRUE);
- if (e == NULL)
- uxabort ();
-
- eXclose = e;
- uxrecord_file (zdata);
-
- uxcopy_stdin (e);
-
- if (! fstdiosync (e, zdata))
- ulog (LOG_FATAL, "fsync failed");
- eXclose = NULL;
- if (fclose (e) != 0)
- ulog (LOG_FATAL, "fclose: %s", strerror (errno));
-
- if (fXxqtlocal)
- uxadd_xqt_line ('I', abtname, (const char *) NULL);
- else
- {
- zinput_from = zbufcpy (abtname);
- zinput_to = zbufcpy (abdname);
- zinput_temp = zinput_from;
- finputcopied = TRUE;
- }
- }
-
- /* If we are returning standard input, or we're putting the status
- in a file, we can't use an E command. */
- if (fretstdin)
- uxadd_xqt_line ('B', (const char *) NULL, (const char *) NULL);
-
- if (zstatus_file != NULL)
- uxadd_xqt_line ('M', zstatus_file, (const char *) NULL);
-
- /* Get the complete command line, and decide whether the command
- needs to be executed by the shell. */
- fneedshell = FALSE;
-
- if (zcmd[strcspn (zcmd, ZSHELLCHARS)] != '\0')
- fneedshell = TRUE;
-
- clen = strlen (zcmd) + 1;
- for (i = 0; i < cargs; i++)
- {
- if (pzargs[i] != NULL)
- {
- clen += strlen (pzargs[i]) + 1;
- if (pzargs[i][strcspn (pzargs[i], ZSHELLCHARS)] != '\0')
- fneedshell = TRUE;
- }
- }
-
- zfullcmd = zbufalc (clen);
-
- strcpy (zfullcmd, zcmd);
- for (i = 0; i < cargs; i++)
- {
- if (pzargs[i] != NULL)
- {
- strcat (zfullcmd, " ");
- strcat (zfullcmd, pzargs[i]);
- }
- }
-
- fpoll = FALSE;
-
- /* If we haven't written anything to the execution file yet, and we
- have a standard input file, and we're not forwarding, then every
- other option can be handled in an E command. */
- if (eXxqt_file == NULL && zinput_from != NULL && zforward == NULL)
- {
- struct scmd s;
- char *zoptions;
-
- /* Set up an E command. */
- s.bcmd = 'E';
- s.bgrade = bXgrade;
- s.pseq = NULL;
- s.zuser = zuser;
- s.zfrom = zinput_from;
- s.zto = zinput_to;
- s.zoptions = aboptions;
- zoptions = aboptions;
- *zoptions++ = finputcopied ? 'C' : 'c';
- if (fno_ack)
- *zoptions++ = 'N';
- if (ferror_ack)
- *zoptions++ = 'Z';
- if (zrequestor != NULL)
- *zoptions++ = 'R';
- if (fneedshell)
- *zoptions++ = 'e';
- *zoptions = '\0';
- s.ztemp = zinput_temp;
- s.imode = 0666;
- if (zrequestor == NULL)
- zrequestor = "\"\"";
- s.znotify = zrequestor;
- s.cbytes = -1;
- s.zcmd = zfullcmd;
- s.ipos = 0;
-
- ++cXcmds;
- pasXcmds = (struct scmd *) xrealloc ((pointer) pasXcmds,
- cXcmds * sizeof (struct scmd));
- pasXcmds[cXcmds - 1] = s;
-
- uxadd_name (zinput_from);
- }
- else if (*zfullcmd == '\0'
- && eXxqt_file == NULL
- && zinput_from == NULL
- && cXcmds == 0)
- {
- /* As a special case, if we are asked to execute an empty
- command, we create a poll file instead. */
- fpoll = TRUE;
- }
- else
- {
- /* Finish up the execute file. */
- uxadd_xqt_line ('U', zuser, zXxqtloc);
- if (zinput_from != NULL)
- {
- uxadd_xqt_line ('F', zinput_to, (char *) NULL);
- uxadd_xqt_line ('I', zinput_to, (char *) NULL);
- uxadd_send_file (zinput_from, zinput_to,
- finputcopied ? "C" : "c",
- zinput_temp, zforward);
- }
- if (fno_ack)
- uxadd_xqt_line ('N', (const char *) NULL, (const char *) NULL);
- if (ferror_ack)
- uxadd_xqt_line ('Z', (const char *) NULL, (const char *) NULL);
- if (zrequestor != NULL)
- uxadd_xqt_line ('R', zrequestor, (const char *) NULL);
- if (fneedshell)
- uxadd_xqt_line ('e', (const char *) NULL, (const char *) NULL);
- uxadd_xqt_line ('C', zfullcmd, (const char *) NULL);
- if (! fstdiosync (eXxqt_file, "execution file"))
- ulog (LOG_FATAL, "fsync failed");
- if (fclose (eXxqt_file) != 0)
- ulog (LOG_FATAL, "fclose: %s", strerror (errno));
- eXxqt_file = NULL;
-
- /* If the execution is to occur on another system, we must now
- arrange to copy the execute file to this system. */
- if (! fXxqtlocal)
- uxadd_send_file (abXxqt_tname, abXxqt_xname, "C", abXxqt_tname,
- zforward);
- }
-
- /* If we got a signal, get out before spooling anything. */
- if (FGOT_SIGNAL ())
- uxabort ();
-
- /* From here on in, it's too late. We don't call uxabort. */
- if (cXcmds > 0 || fpoll)
- {
- char *zjobid;
-
- if (! fpoll
- && ! sXxqtsys.uuconf_fcall_transfer
- && ! sXxqtsys.uuconf_fcalled_transfer)
- ulog (LOG_FATAL, "Not permitted to transfer files to or from %s",
- sXxqtsys.uuconf_zname);
-
- zjobid = zsysdep_spool_commands (&sXxqtsys, bXgrade, cXcmds, pasXcmds);
- if (zjobid == NULL)
- {
- ulog_close ();
- usysdep_exit (FALSE);
- }
-
- if (fjobid)
- printf ("%s\n", zjobid);
-
- ubuffree (zjobid);
-
- if (fcall_any)
- {
- ubuffree (zcall_system);
- zcall_system = NULL;
- }
- else
- {
- fcall_any = TRUE;
- zcall_system = zbufcpy (sXxqtsys.uuconf_zname);
- }
- }
-
- if (! fpoll)
- {
- /* If all that worked, make a log file entry. All log file
- reports up to this point went to stderr. */
- ulog_to_file (puuconf, TRUE);
- ulog_system (sXxqtsys.uuconf_zname);
- ulog_user (zuser);
-
- if (zXnames == NULL)
- ulog (LOG_NORMAL, "Queuing %s", zfullcmd);
- else
- ulog (LOG_NORMAL, "Queuing %s (%s)", zfullcmd, zXnames);
-
- ulog_close ();
- }
-
- if (! fuucico
- || (zcall_system == NULL && ! fcall_any))
- {
- if (! fXxqtlocal || ! fuucico)
- fexit = TRUE;
- else
- {
- char *zconfigarg;
-
- if (zconfig == NULL)
- zconfigarg = NULL;
- else
- {
- zconfigarg = zbufalc (sizeof "-I" + strlen (zconfig));
- sprintf (zconfigarg, "-I%s", zconfig);
- }
-
- fexit = fsysdep_run (FALSE, "uuxqt", zconfigarg,
- (const char *) NULL);
- }
- }
- else
- {
- const char *zcicoarg;
- char *zconfigarg;
-
- if (zcall_system == NULL)
- zcicoarg = "-r1";
- else
- {
- char *z;
-
- z = zbufalc (sizeof "-Cs" + strlen (zcall_system));
- sprintf (z, "-Cs%s", zcall_system);
- zcicoarg = z;
- }
-
- if (zconfig == NULL)
- zconfigarg = NULL;
- else
- {
- zconfigarg = zbufalc (sizeof "-I" + strlen (zconfig));
- sprintf (zconfigarg, "-I%s", zconfig);
- }
-
- fexit = fsysdep_run (FALSE, "uucico", zcicoarg, zconfigarg);
- }
-
- usysdep_exit (fexit);
-
- /* Avoid error about not returning a value. */
- return 0;
-}
-
-/* Report command usage. */
-
-static void
-uxhelp ()
-{
- printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- printf ("Usage: %s [options] [-] command\n", zProgram);
- printf (" -,-p,--stdin: Read standard input for standard input of command\n");
- printf (" -c,--nocopy: Do not copy local files to spool directory (default)\n");
- printf (" -C,--copy: Copy local files to spool directory\n");
- printf (" -l,--link: link local files to spool directory\n");
- printf (" -g,--grade grade: Set job grade (must be alphabetic)\n");
- printf (" -n,--notification=no: Do not report completion status\n");
- printf (" -z,--notification=error: Report completion status only on error\n");
- printf (" -r,--nouucico: Do not start uucico daemon\n");
- printf (" -a,--requestor address: Address to mail status report to\n");
- printf (" -b,--return-stdin: Return standard input with status report\n");
- printf (" -s,--status file: Report completion status to file\n");
- printf (" -j,--jobid: Report job id\n");
- printf (" -x,--debug debug: Set debugging level\n");
-#if HAVE_TAYLOR_CONFIG
- printf (" -I,--config file: Set configuration file to use\n");
-#endif /* HAVE_TAYLOR_CONFIG */
- printf (" -v,--version: Print version and exit\n");
- printf (" --help: Print help and exit\n");
-}
-
-static void
-uxusage ()
-{
- fprintf (stderr,
- "Usage: %s [options] [-] command\n", zProgram);
- fprintf (stderr, "Use %s --help for help\n", zProgram);
- exit (EXIT_FAILURE);
-}
-
-/* Add a line to the execute file. */
-
-static void
-uxadd_xqt_line (bchar, z1, z2)
- int bchar;
- const char *z1;
- const char *z2;
-{
- if (eXxqt_file == NULL)
- {
- const char *zxqt_name;
-
- if (fXxqtlocal)
- zxqt_name = zsysdep_xqt_file_name ();
- else
- zxqt_name = zsysdep_data_file_name (&sXxqtsys, zXxqtloc, bXgrade, TRUE,
- abXxqt_tname, (char *) NULL,
- abXxqt_xname);
- if (zxqt_name == NULL)
- uxabort ();
-
- uxrecord_file (zxqt_name);
-
- eXxqt_file = esysdep_fopen (zxqt_name, FALSE, FALSE, TRUE);
- if (eXxqt_file == NULL)
- uxabort ();
- }
-
- if (z1 == NULL)
- fprintf (eXxqt_file, "%c\n", bchar);
- else if (z2 == NULL)
- fprintf (eXxqt_file, "%c %s\n", bchar, z1);
- else
- fprintf (eXxqt_file, "%c %s %s\n", bchar, z1, z2);
-}
-
-/* Add a file to be sent to the execute system. */
-
-static void
-uxadd_send_file (zfrom, zto, zoptions, ztemp, zforward)
- const char *zfrom;
- const char *zto;
- const char *zoptions;
- const char *ztemp;
- const char *zforward;
-{
- struct scmd s;
-
- if (zforward != NULL)
- {
- char *zbase;
- char *zxqt;
- char abtname[CFILE_NAME_LEN];
- char abdname[CFILE_NAME_LEN];
- char abxname[CFILE_NAME_LEN];
- FILE *e;
-
- /* We want to forward this file through the first execution
- system to other systems. We set up a remote execution of
- uucp to forward the file. */
- zbase = zsysdep_base_name (zfrom);
- if (zbase == NULL)
- uxabort ();
-
- zxqt = zsysdep_data_file_name (&sXxqtsys, zXxqtloc, bXgrade, TRUE,
- abtname, abdname, abxname);
- if (zxqt == NULL)
- uxabort ();
- e = esysdep_fopen (zxqt, FALSE, FALSE, TRUE);
- if (e == NULL)
- uxabort ();
- uxrecord_file (zxqt);
-
- fprintf (e, "U %s %s\n", zsysdep_login_name (), zXxqtloc);
- fprintf (e, "F %s %s\n", abdname, zbase);
- fprintf (e, "C uucp -C -W -d -g %c %s %s!%s\n",
- bXgrade, zbase, zforward, zto);
-
- ubuffree (zbase);
-
- if (! fstdiosync (e, zxqt))
- ulog (LOG_FATAL, "fsync failed");
- if (fclose (e) != 0)
- ulog (LOG_FATAL, "fclose: %s", strerror (errno));
-
- /* Send the execution file. */
- s.bcmd = 'S';
- s.bgrade = bXgrade;
- s.pseq = NULL;
- s.zfrom = zbufcpy (abtname);
- s.zto = zbufcpy (abxname);
- s.zuser = zsysdep_login_name ();
- s.zoptions = "C";
- s.ztemp = s.zfrom;
- s.imode = 0666;
- s.znotify = NULL;
- s.cbytes = -1;
- s.zcmd = NULL;
- s.ipos = 0;
-
- ++cXcmds;
- pasXcmds = (struct scmd *) xrealloc ((pointer) pasXcmds,
- cXcmds * sizeof (struct scmd));
- pasXcmds[cXcmds - 1] = s;
-
- uxadd_name (abtname);
-
- /* Send the data file to abdname where the execution file will
- expect it. */
- zto = abdname;
- }
-
- s.bcmd = 'S';
- s.bgrade = bXgrade;
- s.pseq = NULL;
- s.zfrom = zbufcpy (zfrom);
- s.zto = zbufcpy (zto);
- s.zuser = zsysdep_login_name ();
- s.zoptions = zbufcpy (zoptions);
- s.ztemp = zbufcpy (ztemp);
- s.imode = 0666;
- s.znotify = "";
- s.cbytes = -1;
- s.zcmd = NULL;
- s.ipos = 0;
-
- ++cXcmds;
- pasXcmds = (struct scmd *) xrealloc ((pointer) pasXcmds,
- cXcmds * sizeof (struct scmd));
- pasXcmds[cXcmds - 1] = s;
-
- uxadd_name (zfrom);
-}
-
-/* Copy stdin to a file. This is a separate function because it may
- call setjmp. */
-
-static void
-uxcopy_stdin (e)
- FILE *e;
-{
- CATCH_PROTECT size_t cread;
- char ab[1024];
-
- do
- {
- size_t cwrite;
-
- /* I want to use fread here, but there is a bug in some versions
- of SVR4 which causes fread to return less than a complete
- buffer even if EOF has not been reached. This is not online
- time, so speed is not critical, but it's still quite annoying
- to have to use an inefficient algorithm. */
- cread = 0;
- if (fsysdep_catch ())
- {
- usysdep_start_catch ();
-
- while (cread < sizeof (ab))
- {
- int b;
-
- if (FGOT_SIGNAL ())
- uxabort ();
-
- /* There's an unimportant race here. If the user hits
- ^C between the FGOT_SIGNAL we just did and the time
- we enter getchar, we won't know about the signal
- (unless we're doing a longjmp, but we normally
- aren't). It's not a big problem, because the user
- can just hit ^C again. */
- b = getchar ();
- if (b == EOF)
- break;
- ab[cread] = b;
- ++cread;
- }
- }
-
- usysdep_end_catch ();
-
- if (FGOT_SIGNAL ())
- uxabort ();
-
- if (cread > 0)
- {
- cwrite = fwrite (ab, sizeof (char), cread, e);
- if (cwrite != cread)
- ulog (LOG_FATAL, "fwrite: Wrote %d when attempted %d",
- (int) cwrite, (int) cread);
- }
- }
- while (cread == sizeof ab);
-}
-
-/* Keep track of all files we have created so that we can delete them
- if we get a signal. The argument will be on the heap. */
-
-static int cXfiles;
-static const char **pXaz;
-
-static void
-uxrecord_file (zfile)
- const char *zfile;
-{
- pXaz = (const char **) xrealloc ((pointer) pXaz,
- (cXfiles + 1) * sizeof (const char *));
- pXaz[cXfiles] = zfile;
- ++cXfiles;
-}
-
-/* Delete all the files we have recorded and exit. */
-
-static void
-uxabort ()
-{
- int i;
-
- if (eXxqt_file != NULL)
- (void) fclose (eXxqt_file);
- if (eXclose != NULL)
- (void) fclose (eXclose);
- for (i = 0; i < cXfiles; i++)
- (void) remove (pXaz[i]);
- ulog_close ();
- usysdep_exit (FALSE);
-}
-
-/* Add a name to the list of file names we are going to log. We log
- all the file names which will appear in the uucico log file. This
- permits people to associate the file send in the uucico log with
- the uux entry which created the file. Normally only one file name
- will appear. */
-
-static void
-uxadd_name (z)
- const char *z;
-{
- if (zXnames == NULL)
- zXnames = zbufcpy (z);
- else
- {
- size_t cold, cadd;
- char *znew;
-
- cold = strlen (zXnames);
- cadd = strlen (z);
- znew = zbufalc (cold + 2 + cadd);
- memcpy (znew, zXnames, cold);
- znew[cold] = ' ';
- memcpy (znew + cold + 1, z, cadd + 1);
- ubuffree (zXnames);
- zXnames = znew;
- }
-}
diff --git a/gnu/libexec/uucp/uuxqt/Makefile b/gnu/libexec/uucp/uuxqt/Makefile
deleted file mode 100644
index f117449..0000000
--- a/gnu/libexec/uucp/uuxqt/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# Makefile for uuxqt
-# $Id$
-
-BINDIR= $(libxdir)
-BINOWN= $(owner)
-BINGRP= $(group)
-BINMODE= 4550
-
-PROG= uuxqt
-SRCS= uuxqt.c util.c log.c copy.c
-LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
-CFLAGS+= -I$(.CURDIR)/../common_sources\
- -DVERSION=\"$(VERSION)\" -DOWNER=\"$(owner)\"
-
-MAN8= uuxqt.8
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../common_sources
diff --git a/gnu/libexec/uucp/uuxqt/uuxqt.8 b/gnu/libexec/uucp/uuxqt/uuxqt.8
deleted file mode 100644
index c6996b6..0000000
--- a/gnu/libexec/uucp/uuxqt/uuxqt.8
+++ /dev/null
@@ -1,103 +0,0 @@
-''' $Id$
-.TH uuxqt 8 "Taylor UUCP 1.06"
-.SH NAME
-uuxqt \- UUCP execution daemon
-.SH SYNOPSIS
-.B uuxqt
-[ options ]
-.SH DESCRIPTION
-The
-.I uuxqt
-daemon executes commands requested by
-.I uux
-(1) from either the local system or from remote systems.
-It is started automatically by the
-.I uucico
-(8) daemon (unless
-.I uucico
-(8) is given the
-.B \-q
-or
-.B \-\-nouuxqt
-option).
-
-There is normally no need to run this command, since it will be
-invoked by
-.I uucico
-(8). However, it can be used to provide greater control over the
-processing of the work queue.
-
-Multiple invocations of
-.I uuxqt
-may be run at once, as controlled by the
-.I max-uuxqts
-configuration command.
-.SH OPTIONS
-The following options may be given to
-.I uuxqt.
-.TP 5
-.B \-c command, \-\-command command
-Only execute requests for the specified command. For example:
-.br
-.in +0.5i
-.nf
-uuxqt --command rmail
-.fi
-.in -0.5i
-.TP 5
-.B \-s system, \-\-system system
-Only execute requests originating from the specified system.
-.TP 5
-.B \-x type, \-\-debug type
-Turn on particular debugging types. The following types are
-recognized: abnormal, chat, handshake, uucp-proto, proto, port,
-config, spooldir, execute, incoming, outgoing. Only abnormal, config,
-spooldir and execute are meaningful for
-.I uuxqt.
-
-Multiple types may be given, separated by commas, and the
-.B \-\-debug
-option may appear multiple times. A number may also be given, which
-will turn on that many types from the foregoing list; for example,
-.B \-\-debug 2
-is equivalent to
-.B \-\-debug abnormal,chat.
-
-The debugging output is sent to the debugging file, usually one of
-/var/spool/uucp/Debug, /usr/spool/uucp/DEBUG, or
-/usr/spool/uucp/.Admin/audit.local.
-.TP 5
-.B \-I file, \-\-config
-Set configuration file to use. This option may not be available,
-depending upon how
-.I uuxqt
-was compiled.
-.TP 5
-.B \-v, \-\-version
-Report version information and exit.
-.TP 5
-.B \-\-help
-Print a help message and exit.
-.SH FILES
-The file names may be changed at compilation time or by the
-configuration file, so these are only approximations.
-
-.br
-/etc/uucp/config - Configuration file.
-.br
-/var/spool/uucp -
-UUCP spool directory.
-.br
-/var/spool/uucp/Log -
-UUCP log file.
-.br
-/var/spool/uucppublic -
-Default UUCP public directory.
-.br
-/var/spool/uucp/Debug -
-Debugging file.
-.SH SEE ALSO
-uucp(1), uux(1), uucico(8)
-.SH AUTHOR
-Ian Lance Taylor
-(ian@airs.com)
diff --git a/gnu/libexec/uucp/uuxqt/uuxqt.c b/gnu/libexec/uucp/uuxqt/uuxqt.c
deleted file mode 100644
index 6e21473..0000000
--- a/gnu/libexec/uucp/uuxqt/uuxqt.c
+++ /dev/null
@@ -1,1766 +0,0 @@
-/* uuxqt.c
- Run uux commands.
-
- Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
-
- This file is part of the Taylor UUCP package.
-
- 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 of the
- License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
- */
-
-#include "uucp.h"
-
-#if USE_RCS_ID
-const char uuxqt_rcsid[] = "$Id$";
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-
-#include "getopt.h"
-
-#include "uudefs.h"
-#include "uuconf.h"
-#include "system.h"
-
-/* Static variables used to unlock things if we get a fatal error. */
-static int iQlock_seq = -1;
-static const char *zQunlock_cmd;
-static const char *zQunlock_file;
-static boolean fQunlock_directory;
-int cQmaxuuxqts;
-
-/* Static variables to free in uqcleanup. */
-static char *zQoutput;
-static char *zQmail;
-
-/* Local functions. */
-static void uqusage P((void));
-static void uqhelp P((void));
-static void uqabort P((void));
-static void uqdo_xqt_file P((pointer puuconf, const char *zfile,
- const char *zbase,
- const struct uuconf_system *qsys,
- const char *zlocalname,
- const char *zcmd, boolean *pfprocessed));
-static void uqcleanup P((const char *zfile, int iflags));
-static int isave_files P((const struct uuconf_system *, const char *zmail,
- const char *zfile, int iclean));
-static boolean fqforward P((const char *zfile, char **pzallowed,
- const char *zlog, const char *zmail));
-
-/* Long getopt options. */
-static const struct option asQlongopts[] =
-{
- { "command", required_argument, 0, 'c' },
- { "system", required_argument, 0, 's' },
- { "config", required_argument, NULL, 'I' },
- { "debug", required_argument, NULL, 'x' },
- { "version", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 1 },
- { NULL, 0, NULL, 0 }
-};
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- /* The type of command to execute (NULL for any type). */
- const char *zcmd = NULL;
- /* The configuration file name. */
- const char *zconfig = NULL;
- /* The system to execute commands for. */
- const char *zdosys = NULL;
- int iopt;
- pointer puuconf;
- int iuuconf;
- const char *zlocalname;
- boolean fany;
- char *z, *zgetsys;
- boolean ferr;
- boolean fsys;
- struct uuconf_system ssys;
-
- zProgram = argv[0];
-
- while ((iopt = getopt_long (argc, argv, "c:I:s:vx:", asQlongopts,
- (int *) NULL)) != EOF)
- {
- switch (iopt)
- {
- case 'c':
- /* Set the type of command to execute. */
- zcmd = optarg;
- break;
-
- case 'I':
- /* Set the configuration file name. */
- if (fsysdep_other_config (optarg))
- zconfig = optarg;
- break;
-
- case 's':
- zdosys = optarg;
- break;
-
- case 'x':
-#if DEBUG > 1
- /* Set the debugging level. */
- iDebug |= idebug_parse (optarg);
-#endif
- break;
-
- case 'v':
- /* Print version and exit. */
- printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- zProgram, VERSION);
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 1:
- /* --help. */
- uqhelp ();
- exit (EXIT_SUCCESS);
- /*NOTREACHED*/
-
- case 0:
- /* Long option found and flag set. */
- break;
-
- default:
- uqusage ();
- break;
- }
- }
-
- if (optind != argc)
- uqusage ();
-
- iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
-#if DEBUG > 1
- {
- const char *zdebug;
-
- iuuconf = uuconf_debuglevel (puuconf, &zdebug);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- if (zdebug != NULL)
- iDebug |= idebug_parse (zdebug);
- }
-#endif
-
- iuuconf = uuconf_maxuuxqts (puuconf, &cQmaxuuxqts);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
-#ifdef SIGINT
- usysdep_signal (SIGINT);
-#endif
-#ifdef SIGHUP
- usysdep_signal (SIGHUP);
-#endif
-#ifdef SIGQUIT
- usysdep_signal (SIGQUIT);
-#endif
-#ifdef SIGTERM
- usysdep_signal (SIGTERM);
-#endif
-#ifdef SIGPIPE
- usysdep_signal (SIGPIPE);
-#endif
-
- usysdep_initialize (puuconf, INIT_SUID);
-
- ulog_to_file (puuconf, TRUE);
- ulog_fatal_fn (uqabort);
-
- iuuconf = uuconf_localname (puuconf, &zlocalname);
- if (iuuconf == UUCONF_NOT_FOUND)
- {
- zlocalname = zsysdep_localname ();
- if (zlocalname == NULL)
- exit (EXIT_FAILURE);
- }
- else if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- fsys = FALSE;
-
- /* If we were given a system name, canonicalize it. */
- if (zdosys != NULL)
- {
- iuuconf = uuconf_system_info (puuconf, zdosys, &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
-
- if (strcmp (zdosys, zlocalname) == 0)
- {
- iuuconf = uuconf_system_local (puuconf, &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
- ssys.uuconf_zname = (char *) zlocalname;
- }
- else
- {
- if (! funknown_system (puuconf, zdosys, &ssys))
- ulog (LOG_FATAL, "%s: system not found", zdosys);
- }
- }
-
- zdosys = zbufcpy (ssys.uuconf_zname);
- fsys = TRUE;
- }
-
- /* Limit the number of uuxqt processes, and make sure we're the only
- uuxqt daemon running for this command. */
- iQlock_seq = ixsysdep_lock_uuxqt (zcmd, cQmaxuuxqts);
- if (iQlock_seq < 0)
- {
- ulog_close ();
- usysdep_exit (TRUE);
- }
- zQunlock_cmd = zcmd;
-
- /* Keep scanning the execute files until we don't process any of
- them. */
- do
- {
- fany = FALSE;
-
- /* Look for each execute file, and run it. */
-
- if (! fsysdep_get_xqt_init (zdosys))
- {
- ulog_close ();
- usysdep_exit (FALSE);
- }
-
- while ((z = zsysdep_get_xqt (zdosys, &zgetsys, &ferr)) != NULL)
- {
- const char *zloc;
- boolean fprocessed;
- char *zbase;
-
- /* Get the system information for the system returned by
- zsysdep_get_xqt. */
- if (! fsys || strcmp (ssys.uuconf_zname, zgetsys) != 0)
- {
- if (fsys)
- (void) uuconf_system_free (puuconf, &ssys);
-
- iuuconf = uuconf_system_info (puuconf, zgetsys,
- &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- ubuffree (z);
- ubuffree (zgetsys);
- continue;
- }
- else if (strcmp (zgetsys, zlocalname) == 0)
- {
- iuuconf = uuconf_system_local (puuconf, &ssys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- ubuffree (z);
- ubuffree (zgetsys);
- continue;
- }
- ssys.uuconf_zname = (char *) zlocalname;
- }
- else
- {
- if (! funknown_system (puuconf, zgetsys, &ssys))
- {
- ulog (LOG_ERROR,
- "%s: Execute file for unknown system %s",
- z, zgetsys);
- (void) remove (z);
- ubuffree (z);
- ubuffree (zgetsys);
- continue;
- }
- }
- }
-
- fsys = TRUE;
- }
-
- /* If we've received a signal, get out of the loop. */
- if (FGOT_SIGNAL ())
- {
- ubuffree (z);
- ubuffree (zgetsys);
- break;
- }
-
- /* Make sure we are supposed to be executing jobs for this
- system. */
- if (zdosys != NULL && strcmp (zdosys, ssys.uuconf_zname) != 0)
- {
- ubuffree (z);
- ubuffree (zgetsys);
- continue;
- }
-
- zloc = ssys.uuconf_zlocalname;
- if (zloc == NULL)
- zloc = zlocalname;
-
- ulog_system (ssys.uuconf_zname);
- zbase = zsysdep_base_name (z);
- uqdo_xqt_file (puuconf, z, zbase, &ssys, zloc, zcmd, &fprocessed);
- ubuffree (zbase);
- ulog_system ((const char *) NULL);
- ulog_user ((const char *) NULL);
-
- if (fprocessed)
- fany = TRUE;
- ubuffree (z);
- ubuffree (zgetsys);
- }
-
- usysdep_get_xqt_free (zdosys);
- }
- while (fany && ! FGOT_SIGNAL ());
-
- (void) fsysdep_unlock_uuxqt (iQlock_seq, zcmd, cQmaxuuxqts);
- iQlock_seq = -1;
-
- ulog_close ();
-
- if (FGOT_SIGNAL ())
- ferr = TRUE;
-
- usysdep_exit (! ferr);
-
- /* Avoid errors about not returning a value. */
- return 0;
-}
-
-static void
-uqhelp ()
-{
- printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
- VERSION);
- printf ("Usage: %s [-c,--command cmd] [-s,--system system]\n", zProgram);
- printf (" -c,--command cmd: Set type of command to execute\n");
- printf (" -s,--system system: Execute commands only for named system\n");
- printf (" -x,--debug debug: Set debugging level\n");
-#if HAVE_TAYLOR_CONFIG
- printf (" -I,--config file: Set configuration file to use\n");
-#endif /* HAVE_TAYLOR_CONFIG */
- printf (" -v,--version: Print version and exit\n");
- printf (" --help: Print help and exit\n");
-}
-
-static void
-uqusage ()
-{
- fprintf (stderr,
- "Usage: %s [-c,--command cmd] [-s,--system system]\n", zProgram);
- fprintf (stderr, "Use %s --help for help\n", zProgram);
- exit (EXIT_FAILURE);
-}
-
-/* This is the abort function called when we get a fatal error. */
-
-static void
-uqabort ()
-{
-#if ! HAVE_HDB_LOGGING
- /* When using HDB logging, it's a pain to have no system name. */
- ulog_system ((const char *) NULL);
-#endif
-
- ulog_user ((const char *) NULL);
-
- if (fQunlock_directory)
- (void) fsysdep_unlock_uuxqt_dir (iQlock_seq);
-
- if (zQunlock_file != NULL)
- (void) fsysdep_unlock_uuxqt_file (zQunlock_file);
-
- if (iQlock_seq >= 0)
- (void) fsysdep_unlock_uuxqt (iQlock_seq, zQunlock_cmd, cQmaxuuxqts);
-
- ulog_close ();
-
- usysdep_exit (FALSE);
-}
-
-/* An execute file is a series of lines. The first character of each
- line is a command. The following commands are defined:
-
- C command-line
- I standard-input
- O standard-output [ system ]
- F required-file filename-to-use
- R requestor-address
- U user system
- Z (acknowledge if command failed; default)
- N (no acknowledgement on failure)
- n (acknowledge if command succeeded)
- B (return command input on error)
- e (process with sh)
- E (process with exec)
- M status-file
- # comment
-
- Unrecognized commands are ignored. We actually do not recognize
- the Z command, since it requests default behaviour. We always send
- mail on failure, unless the N command appears. We never send mail
- on success, unless the n command appears.
-
- This code does not currently support the B or M commands. */
-
-/* Command arguments. */
-static char **azQargs;
-/* Command as a complete string. */
-static char *zQcmd;
-/* Standard input file name. */
-static char *zQinput;
-/* Standard output file name. */
-static char *zQoutfile;
-/* Standard output system. */
-static char *zQoutsys;
-/* Number of required files. */
-static int cQfiles;
-/* Names of required files. */
-static char **azQfiles;
-/* Names required files should be renamed to (NULL if original is OK). */
-static char **azQfiles_to;
-/* Requestor address (this is where mail should be sent). */
-static char *zQrequestor;
-/* User name. */
-static const char *zQuser;
-/* System name. */
-static const char *zQsystem;
-/* This is set by the N flag, meaning that no acknowledgement should
- be mailed on failure. */
-static boolean fQno_ack;
-/* This is set by the n flag, meaning that acknowledgement should be
- mailed if the command succeeded. */
-static boolean fQsuccess_ack;
-/* This is set by the B flag, meaning that command input should be
- mailed to the requestor if an error occurred. */
-static boolean fQsend_input;
-/* This is set by the E flag, meaning that exec should be used to
- execute the command. */
-static boolean fQuse_exec;
-/* The status should be copied to this file on the requesting host. */
-static const char *zQstatus_file;
-#if ALLOW_SH_EXECUTION
-/* This is set by the e flag, meaning that sh should be used to
- execute the command. */
-static boolean fQuse_sh;
-#endif /* ALLOW_SH_EXECUTION */
-
-static int iqcmd P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int iqout P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int iqfile P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int iqrequestor P((pointer puuconf, int argc, char **argv,
- pointer pvar, pointer pinfo));
-static int iquser P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-static int iqset P((pointer puuconf, int argc, char **argv, pointer pvar,
- pointer pinfo));
-
-/* We are lax about the number of arguments the functions accept,
- because there is a lot of variation in what other (buggy) UUCP
- packages generate. Unused arguments are ignored. */
-
-static const struct uuconf_cmdtab asQcmds[] =
-{
- { "C", UUCONF_CMDTABTYPE_FN | 0, NULL, iqcmd },
- { "I", UUCONF_CMDTABTYPE_STRING, (pointer) &zQinput, NULL },
- { "O", UUCONF_CMDTABTYPE_FN | 0, NULL, iqout },
- { "F", UUCONF_CMDTABTYPE_FN | 0, NULL, iqfile },
- { "R", UUCONF_CMDTABTYPE_FN | 0, NULL, iqrequestor },
- { "U", UUCONF_CMDTABTYPE_FN | 0, NULL, iquser },
- { "N", UUCONF_CMDTABTYPE_FN | 0, (pointer) &fQno_ack, iqset },
- { "n", UUCONF_CMDTABTYPE_FN | 0, (pointer) &fQsuccess_ack, iqset },
- { "B", UUCONF_CMDTABTYPE_FN | 0, (pointer) &fQsend_input, iqset },
-#if ALLOW_SH_EXECUTION
- { "e", UUCONF_CMDTABTYPE_FN | 0, (pointer) &fQuse_sh, iqset },
-#endif
- { "E", UUCONF_CMDTABTYPE_FN | 0, (pointer) &fQuse_exec, iqset },
- { "M", UUCONF_CMDTABTYPE_STRING, (pointer) &zQstatus_file, NULL },
- { NULL, 0, NULL, NULL }
-};
-
-/* Handle the C command: store off the arguments. */
-
-/*ARGSUSED*/
-static int
-iqcmd (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- int i;
- size_t clen;
-
- if (argc <= 1)
- return UUCONF_CMDTABRET_CONTINUE;
-
- azQargs = (char **) xmalloc (argc * sizeof (char *));
- clen = 0;
- for (i = 1; i < argc; i++)
- {
- azQargs[i - 1] = zbufcpy (argv[i]);
- clen += strlen (argv[i]) + 1;
- }
- azQargs[i - 1] = NULL;
-
- zQcmd = (char *) xmalloc (clen);
- zQcmd[0] = '\0';
- for (i = 1; i < argc - 1; i++)
- {
- strcat (zQcmd, argv[i]);
- strcat (zQcmd, " ");
- }
- strcat (zQcmd, argv[i]);
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Handle the O command, which may have one or two arguments. */
-
-/*ARGSUSED*/
-static int
-iqout (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- if (argc > 1)
- zQoutfile = zbufcpy (argv[1]);
- if (argc > 2)
- zQoutsys = zbufcpy (argv[2]);
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Handle the F command, which may have one or two arguments. */
-
-/*ARGSUSED*/
-static int
-iqfile (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- if (argc < 2)
- return UUCONF_CMDTABRET_CONTINUE;
-
- /* If this file is not in the spool directory, just ignore it. */
- if (! fspool_file (argv[1]))
- return UUCONF_CMDTABRET_CONTINUE;
-
- ++cQfiles;
- azQfiles = (char **) xrealloc ((pointer) azQfiles,
- cQfiles * sizeof (char *));
- azQfiles_to = (char **) xrealloc ((pointer) azQfiles_to,
- cQfiles * sizeof (char *));
-
- azQfiles[cQfiles - 1] = zbufcpy (argv[1]);
- if (argc > 2)
- azQfiles_to[cQfiles - 1] = zbufcpy (argv[2]);
- else
- azQfiles_to[cQfiles - 1] = NULL;
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Handle the R command, which may have one or two arguments. */
-
-/*ARGSUSED*/
-static int
-iqrequestor (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- /* We normally have a single argument, which is the ``requestor''
- address, to which we should send any success or error messages.
- Apparently the DOS program UUPC sends two arguments, which are
- the username and the host. */
- if (argc == 2)
- zQrequestor = zbufcpy (argv[1]);
- else if (argc > 2)
- {
- zQrequestor = zbufalc (strlen (argv[1]) + strlen (argv[2])
- + sizeof "!");
- sprintf (zQrequestor, "%s!%s", argv[2], argv[1]);
- }
-
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* Handle the U command, which takes two arguments. */
-
-/*ARGSUSED*/
-static int
-iquser (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- if (argc > 1)
- zQuser = argv[1];
- if (argc > 2)
- zQsystem = argv[2];
- return UUCONF_CMDTABRET_KEEP;
-}
-
-/* Handle various commands which just set boolean variables. */
-
-/*ARGSUSED*/
-static int
-iqset (puuconf, argc, argv, pvar, pinfo)
- pointer puuconf;
- int argc;
- char **argv;
- pointer pvar;
- pointer pinfo;
-{
- boolean *pf = (boolean *) pvar;
-
- *pf = TRUE;
- return UUCONF_CMDTABRET_CONTINUE;
-}
-
-/* The execution processing does a lot of things that have to be
- cleaned up. Rather than try to add the appropriate statements
- to each return point, we keep a set of flags indicating what
- has to be cleaned up. The actual clean up is done by the
- function uqcleanup. */
-#define REMOVE_FILE (01)
-#define REMOVE_NEEDED (02)
-#define FREE_QINPUT (04)
-#define REMOVE_QINPUT (010)
-#define FREE_OUTPUT (020)
-#define FREE_MAIL (040)
-
-/* Process an execute file. The zfile argument is the name of the
- execute file. The zbase argument is the base name of zfile. The
- qsys argument describes the system it came from. The zcmd argument
- is the name of the command we are executing (from the -c option) or
- NULL if any command is OK. This sets *pfprocessed to TRUE if the
- file is ready to be executed. */
-
-static void
-uqdo_xqt_file (puuconf, zfile, zbase, qsys, zlocalname, zcmd, pfprocessed)
- pointer puuconf;
- const char *zfile;
- const char *zbase;
- const struct uuconf_system *qsys;
- const char *zlocalname;
- const char *zcmd;
- boolean *pfprocessed;
-{
- char *zabsolute;
- boolean ferr;
- FILE *e;
- int iuuconf;
- int i;
- int iclean;
- const char *zmail;
- char *zoutput;
- char *zinput;
- boolean fbadname;
- char abtemp[CFILE_NAME_LEN];
- char abdata[CFILE_NAME_LEN];
- char *zerror;
- struct uuconf_system soutsys;
- const struct uuconf_system *qoutsys;
- boolean fshell;
- size_t clen;
- char *zfullcmd;
- boolean ftemp;
-
- *pfprocessed = FALSE;
-
- e = fopen (zfile, "r");
- if (e == NULL)
- return;
-
- azQargs = NULL;
- zQcmd = NULL;
- zQinput = NULL;
- zQoutfile = NULL;
- zQoutsys = NULL;
- cQfiles = 0;
- azQfiles = NULL;
- azQfiles_to = NULL;
- zQrequestor = NULL;
- zQuser = NULL;
- zQsystem = NULL;
- fQno_ack = FALSE;
- fQsuccess_ack = FALSE;
- fQsend_input = FALSE;
- fQuse_exec = FALSE;
- zQstatus_file = NULL;
-#if ALLOW_SH_EXECUTION
- fQuse_sh = FALSE;
-#endif
-
- iuuconf = uuconf_cmd_file (puuconf, e, asQcmds, (pointer) zbase,
- (uuconf_cmdtabfn) NULL,
- (UUCONF_CMDTABFLAG_CASE
- | UUCONF_CMDTABFLAG_NOCOMMENTS),
- (pointer) NULL);
- (void) fclose (e);
-
- if (iuuconf != UUCONF_SUCCESS)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
-
- /* If we got a non-transient error, we notify the administrator.
- We can't bounce it back to the original requestor, because we
- don't know how to read the file to figure out who it is (it
- would probably be possible to read the file and work it out,
- but it doesn't seem worth it for such an unlikely error). */
- if (UUCONF_ERROR_VALUE (iuuconf) == UUCONF_SYNTAX_ERROR
- || UUCONF_ERROR_VALUE (iuuconf) == UUCONF_UNKNOWN_COMMAND)
- {
- const char *az[20];
- char *znew;
-
- i = 0;
- az[i++] = "The execution file\n\t";
- az[i++] = zfile;
- az[i++] = "\nfor system\n\t";
- az[i++] = qsys->uuconf_zname;
- az[i++] = "\nwas corrupt. ";
- znew = zsysdep_save_corrupt_file (zfile);
- if (znew == NULL)
- {
- az[i++] = "The file could not be preserved.\n";
- (void) remove (zfile);
- }
- else
- {
- az[i++] = "It has been moved to\n\t";
- az[i++] = znew;
- az[i++] = "\n";
- }
- (void) fsysdep_mail (OWNER, "Corrupt execution file", i, az);
- ubuffree (znew);
- }
-
- return;
- }
-
- iclean = 0;
-
- if (azQargs == NULL)
- {
- ulog (LOG_ERROR, "%s: No command given", zbase);
- uqcleanup (zfile, iclean | REMOVE_FILE);
- return;
- }
-
- if (zcmd != NULL)
- {
- if (strcmp (zcmd, azQargs[0]) != 0)
- {
- uqcleanup (zfile, iclean);
- return;
- }
- }
- else
- {
- /* If there is a lock file for this particular command already,
- it means that some other uuxqt is supposed to handle it. */
- if (fsysdep_uuxqt_locked (azQargs[0]))
- {
- uqcleanup (zfile, iclean);
- return;
- }
- }
-
- /* Lock this particular file. */
- if (! fsysdep_lock_uuxqt_file (zfile))
- {
- uqcleanup (zfile, iclean);
- return;
- }
-
- zQunlock_file = zfile;
-
- /* Now that we have the file locked, make sure it still exists.
- Otherwise another uuxqt could have just finished processing it
- and removed the lock file. */
- if (! fsysdep_file_exists (zfile))
- {
- uqcleanup (zfile, iclean);
- return;
- }
-
- if (zQuser != NULL)
- ulog_user (zQuser);
- else if (zQrequestor != NULL)
- ulog_user (zQrequestor);
- else
- ulog_user ("unknown");
-
- /* zQsystem, if it is set, comes from the execution file, which
- means that we do not trust it. We only retain it if
- qsys->uuconf_zname is a prefix of it, since that can happen with
- a job from an anonymous system on certain spool directory types,
- and is unlikely to cause any trouble anyhow. */
- if (zQsystem == NULL
- || strncmp (zQsystem, qsys->uuconf_zname,
- strlen (qsys->uuconf_zname)) != 0)
- zQsystem = qsys->uuconf_zname;
-
- /* Make sure that all the required files exist, and get their
- full names in the spool directory. */
- for (i = 0; i < cQfiles; i++)
- {
- char *zreal;
-
- zreal = zsysdep_spool_file_name (qsys, azQfiles[i], (pointer) NULL);
- if (zreal == NULL)
- {
- uqcleanup (zfile, iclean);
- return;
- }
- if (! fsysdep_file_exists (zreal))
- {
- uqcleanup (zfile, iclean);
- return;
- }
- ubuffree (azQfiles[i]);
- azQfiles[i] = zbufcpy (zreal);
- ubuffree (zreal);
- }
-
- /* Lock the execution directory. */
- if (! fsysdep_lock_uuxqt_dir (iQlock_seq))
- {
- ulog (LOG_ERROR, "Could not lock execute directory");
- uqcleanup (zfile, iclean);
- return;
- }
- fQunlock_directory = TRUE;
-
- iclean |= REMOVE_FILE | REMOVE_NEEDED;
- *pfprocessed = TRUE;
-
- /* Get the address to mail results to. Prepend the system from
- which the execute file originated, since mail addresses are
- relative to it. */
- zmail = NULL;
- if (zQrequestor != NULL)
- zmail = zQrequestor;
- else if (zQuser != NULL)
- zmail = zQuser;
- if (zmail != NULL
-#if HAVE_INTERNET_MAIL
- && strchr (zmail, '@') == NULL
-#endif
- && strcmp (zQsystem, zlocalname) != 0)
- {
- char *zset;
-
- zset = zbufalc (strlen (zQsystem) + strlen (zmail) + 2);
- sprintf (zset, "%s!%s", zQsystem, zmail);
- zmail = zset;
- zQmail = zset;
- iclean |= FREE_MAIL;
- }
-
- /* The command "uucp" is handled specially. We make sure that the
- appropriate forwarding is permitted, and we add a -u argument to
- specify the user. */
- if (strcmp (azQargs[0], "uucp") == 0)
- {
- char *zfrom, *zto;
- boolean fmany;
- char **azargs;
- const char *zuser;
-
- zfrom = NULL;
- zto = NULL;
- fmany = FALSE;
-
- /* Skip all the options, and get the from and to specs. We
- don't permit multiple arguments. */
- for (i = 1; azQargs[i] != NULL; i++)
- {
- if (azQargs[i][0] == '-')
- {
- char *zopts;
-
- for (zopts = azQargs[i] + 1; *zopts != '\0'; zopts++)
- {
- /* The -g, -n, and -s options take an argument. */
- if (*zopts == 'g' || *zopts == 'n' || *zopts == 's')
- {
- if (zopts[1] == '\0')
- ++i;
- break;
- }
- /* The -I, -u and -x options are not permitted. */
- if (*zopts == 'I' || *zopts == 'u' || *zopts == 'x')
- {
- *zopts = 'r';
- if (zopts[1] != '\0')
- zopts[1] = '\0';
- else
- {
- ++i;
- azQargs[i] = zbufcpy ("-r");
- }
- break;
- }
- }
- }
- else if (zfrom == NULL)
- zfrom = azQargs[i];
- else if (zto == NULL)
- zto = azQargs[i];
- else
- {
- fmany = TRUE;
- break;
- }
- }
-
- /* Add the -u argument. This is required to let uucp do the
- correct permissions checking on the file transfer. */
- for (i = 0; azQargs[i] != NULL; i++)
- ;
- azargs = (char **) xmalloc ((i + 2) * sizeof (char *));
- azargs[0] = azQargs[0];
- zuser = zQuser;
- if (zuser == NULL)
- zuser = "uucp";
- azargs[1] = zbufalc (strlen (zQsystem) + strlen (zuser)
- + sizeof "-u!");
- sprintf (azargs[1], "-u%s!%s", zQsystem, zuser);
- memcpy (azargs + 2, azQargs + 1, i * sizeof (char *));
- xfree ((pointer) azQargs);
- azQargs = azargs;
-
- /* Find the uucp binary. */
- zabsolute = zsysdep_find_command ("uucp", qsys->uuconf_pzcmds,
- qsys->uuconf_pzpath, &ferr);
- if (zabsolute == NULL && ! ferr)
- {
- const char *azcmds[2];
-
- /* If "uucp" is not a permitted command, then the forwarding
- entries must be set. */
- if (! fqforward (zfrom, qsys->uuconf_pzforward_from, "from", zmail)
- || ! fqforward (zto, qsys->uuconf_pzforward_to, "to", zmail))
- {
- uqcleanup (zfile, iclean);
- return;
- }
-
- /* If "uucp" is not a permitted command, then only uucp
- requests with a single source are permitted, since that
- is all that will be generated by uucp or uux. */
- if (fmany)
- {
- ulog (LOG_ERROR, "Bad uucp request %s", zQcmd);
-
- if (zmail != NULL && ! fQno_ack)
- {
- const char *az[20];
-
- i = 0;
- az[i++] = "Your execution request failed because it was an";
- az[i++] = " unsupported uucp request.\n";
- az[i++] = "Execution requested was:\n\t";
- az[i++] = zQcmd;
- az[i++] = "\n";
-
- (void) fsysdep_mail (zmail, "Execution failed", i, az);
- }
-
- uqcleanup (zfile, iclean);
- return;
- }
-
- azcmds[0] = "uucp";
- azcmds[1] = NULL;
- zabsolute = zsysdep_find_command ("uucp", (char **) azcmds,
- qsys->uuconf_pzpath, &ferr);
- }
- if (zabsolute == NULL)
- {
- if (! ferr)
- ulog (LOG_ERROR, "Can't find uucp executable");
-
- uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED));
- *pfprocessed = FALSE;
- return;
- }
- }
- else
- {
- /* Get the pathname to execute. */
- zabsolute = zsysdep_find_command (azQargs[0], qsys->uuconf_pzcmds,
- qsys->uuconf_pzpath,
- &ferr);
- if (zabsolute == NULL)
- {
- if (ferr)
- {
- /* If we get an error, try again later. */
- uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED));
- *pfprocessed = FALSE;
- return;
- }
-
- /* Not permitted. Send mail to requestor. */
- ulog (LOG_ERROR, "Not permitted to execute %s",
- azQargs[0]);
-
- if (zmail != NULL && ! fQno_ack)
- {
- const char *az[20];
-
- i = 0;
- az[i++] = "Your execution request failed because you are not";
- az[i++] = " permitted to execute\n\t";
- az[i++] = azQargs[0];
- az[i++] = "\non this system.\n";
- az[i++] = "Execution requested was:\n\t";
- az[i++] = zQcmd;
- az[i++] = "\n";
-
- (void) fsysdep_mail (zmail, "Execution failed", i, az);
- }
-
- iclean = isave_files (qsys, zmail, zfile, iclean);
-
- uqcleanup (zfile, iclean);
- return;
- }
- }
-
- ubuffree (azQargs[0]);
- azQargs[0] = zabsolute;
-
- for (i = 1; azQargs[i] != NULL; i++)
- {
- char *zlocal;
-
- zlocal = zsysdep_xqt_local_file (qsys, azQargs[i]);
- if (zlocal != NULL)
- {
- ubuffree (azQargs[i]);
- azQargs[i] = zlocal;
- }
- }
-
-#if ! ALLOW_FILENAME_ARGUMENTS
-
- /* Check all the arguments to make sure they don't try to specify
- files they are not permitted to access. */
- for (i = 1; azQargs[i] != NULL; i++)
- {
- if (! fsysdep_xqt_check_file (qsys, azQargs[i]))
- {
- if (zmail != NULL && ! fQno_ack)
- {
- const char *az[20];
- const char *zfailed;
-
- zfailed = azQargs[i];
- i = 0;
- az[i++] = "Your execution request failed because you are not";
- az[i++] = " permitted to refer to file\n\t";
- az[i++] = zfailed;
- az[i++] = "\non this system.\n";
- az[i++] = "Execution requested was:\n\t";
- az[i++] = zQcmd;
- az[i++] = "\n";
-
- (void) fsysdep_mail (zmail, "Execution failed", i, az);
- }
-
- iclean = isave_files (qsys, zmail, zfile, iclean);
-
- uqcleanup (zfile, iclean);
- return;
- }
- }
-
-#endif /* ! ALLOW_FILENAME_ARGUMENTS */
-
- ulog (LOG_NORMAL, "Executing %s (%s)", zbase, zQcmd);
-
- if (zQinput != NULL)
- {
- boolean fspool;
- char *zreal;
-
- fspool = fspool_file (zQinput);
- if (! fspool)
- zreal = zsysdep_local_file (zQinput, qsys->uuconf_zpubdir, &fbadname);
- else
- {
- zreal = zsysdep_spool_file_name (qsys, zQinput, (pointer) NULL);
- fbadname = FALSE;
- }
- if (zreal == NULL && ! fbadname)
- {
- /* If we get an error, try again later. */
- uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED));
- *pfprocessed = FALSE;
- return;
- }
-
- if (zreal != NULL)
- {
- zQinput = zreal;
- iclean |= FREE_QINPUT;
- if (fspool)
- iclean |= REMOVE_QINPUT;
- }
-
- if (zreal == NULL
- || (! fspool
- && ! fin_directory_list (zQinput, qsys->uuconf_pzremote_send,
- qsys->uuconf_zpubdir, TRUE, TRUE,
- (const char *) NULL)))
- {
- ulog (LOG_ERROR, "Not permitted to read %s", zQinput);
-
- if (zmail != NULL && ! fQno_ack)
- {
- const char *az[20];
-
- i = 0;
- az[i++] = "Your execution request failed because you are";
- az[i++] = " not permitted to read\n\t";
- az[i++] = zQinput;
- az[i++] = "\non this system.\n";
- az[i++] = "Execution requested was:\n\t";
- az[i++] = zQcmd;
- az[i++] = "\n";
-
- (void) fsysdep_mail (zmail, "Execution failed", i, az);
- }
-
- uqcleanup (zfile, iclean);
- return;
- }
- }
-
- zoutput = NULL;
- if (zQoutfile == NULL)
- qoutsys = NULL;
- else if (zQoutsys != NULL
- && strcmp (zQoutsys, zlocalname) != 0)
- {
- char *zdata;
-
- /* The output file is destined for some other system, so we must
- use a temporary file to catch standard output. */
- if (strcmp (zQoutsys, qsys->uuconf_zname) == 0)
- qoutsys = qsys;
- else
- {
- iuuconf = uuconf_system_info (puuconf, zQoutsys, &soutsys);
- if (iuuconf != UUCONF_SUCCESS)
- {
- if (iuuconf != UUCONF_NOT_FOUND)
- {
- ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
- uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED));
- *pfprocessed = FALSE;
- return;
- }
-
- if (! funknown_system (puuconf, zQoutsys, &soutsys))
- {
- ulog (LOG_ERROR,
- "Can't send standard output to unknown system %s",
- zQoutsys);
- /* We don't send mail to unknown systems, either.
- Maybe we should. */
- uqcleanup (zfile, iclean);
- return;
- }
- }
-
- qoutsys = &soutsys;
- }
-
- zdata = zsysdep_data_file_name (qoutsys, zlocalname,
- BDEFAULT_UUX_GRADE, FALSE, abtemp,
- abdata, (char *) NULL);
- if (zdata == NULL)
- {
- /* If we get an error, try again later. */
- uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED));
- *pfprocessed = FALSE;
- return;
- }
- zoutput = zdata;
- zQoutput = zoutput;
- iclean |= FREE_OUTPUT;
- }
- else
- {
- boolean fok;
-
- qoutsys = NULL;
-
- /* If we permitted the standard output to be redirected into
- the spool directory, people could set up phony commands. */
- if (fspool_file (zQoutfile))
- fok = FALSE;
- else
- {
- zoutput = zsysdep_local_file (zQoutfile, qsys->uuconf_zpubdir,
- &fbadname);
- if (zoutput == NULL)
- {
- if (! fbadname)
- {
- /* If we get an error, try again later. */
- uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED));
- *pfprocessed = FALSE;
- return;
- }
- fok = FALSE;
- }
- else
- {
- ubuffree (zQoutfile);
- zQoutfile = zoutput;
-
- /* Make sure it's OK to receive this file. */
- fok = fin_directory_list (zQoutfile,
- qsys->uuconf_pzremote_receive,
- qsys->uuconf_zpubdir, TRUE, FALSE,
- (const char *) NULL);
- }
- }
-
- if (! fok)
- {
- ulog (LOG_ERROR, "Not permitted to write to %s", zQoutfile);
-
- if (zmail != NULL && ! fQno_ack)
- {
- const char *az[20];
-
- i = 0;
- az[i++] = "Your execution request failed because you are";
- az[i++] = " not permitted to write to\n\t";
- az[i++] = zQoutfile;
- az[i++] = "\non this system.\n";
- az[i++] = "Execution requested was:\n\t";
- az[i++] = zQcmd;
- az[i++] = "\n";
-
- (void) fsysdep_mail (zmail, "Execution failed", i, az);
- }
-
- uqcleanup (zfile, iclean);
- return;
- }
- }
-
- /* Move the required files to the execution directory if necessary. */
- zinput = zQinput;
- if (! fsysdep_move_uuxqt_files (cQfiles, (const char **) azQfiles,
- (const char **) azQfiles_to,
- TRUE, iQlock_seq, &zinput))
- {
- /* If we get an error, try again later. */
- uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED));
- *pfprocessed = FALSE;
- return;
- }
- if (zQinput != NULL && strcmp (zQinput, zinput) != 0)
- {
- if ((iclean & FREE_QINPUT) != 0)
- ubuffree (zQinput);
- zQinput = zinput;
- iclean |= FREE_QINPUT;
- }
-
-#if ALLOW_SH_EXECUTION
- fshell = fQuse_sh;
-#else
- fshell = FALSE;
-#endif
-
- /* Get a shell command which uses the full path of the command to
- execute. */
- clen = 0;
- for (i = 0; azQargs[i] != NULL; i++)
- clen += strlen (azQargs[i]) + 1;
- zfullcmd = zbufalc (clen);
- strcpy (zfullcmd, azQargs[0]);
- for (i = 1; azQargs[i] != NULL; i++)
- {
- strcat (zfullcmd, " ");
- strcat (zfullcmd, azQargs[i]);
- }
-
- if (! fsysdep_execute (qsys,
- zQuser == NULL ? (const char *) "uucp" : zQuser,
- (const char **) azQargs, zfullcmd, zQinput,
- zoutput, fshell, iQlock_seq, &zerror, &ftemp))
- {
- ubuffree (zfullcmd);
-
- (void) fsysdep_move_uuxqt_files (cQfiles, (const char **) azQfiles,
- (const char **) azQfiles_to,
- FALSE, iQlock_seq,
- (char **) NULL);
-
- if (ftemp)
- {
- ulog (LOG_NORMAL, "Will retry later (%s)", zbase);
- if (zoutput != NULL)
- (void) remove (zoutput);
- if (zerror != NULL)
- {
- (void) remove (zerror);
- ubuffree (zerror);
- }
- uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED));
- *pfprocessed = FALSE;
- return;
- }
-
- ulog (LOG_NORMAL, "Execution failed (%s)", zbase);
-
- if (zmail != NULL && ! fQno_ack)
- {
- const char **pz;
- int cgot;
- FILE *eerr;
- int istart;
-
- cgot = 20;
- pz = (const char **) xmalloc (cgot * sizeof (const char *));
- i = 0;
- pz[i++] = "Execution request failed:\n\t";
- pz[i++] = zQcmd;
- pz[i++] = "\n";
-
- if (zerror == NULL)
- eerr = NULL;
- else
- eerr = fopen (zerror, "r");
- if (eerr == NULL)
- {
- pz[i++] = "There was no output on standard error\n";
- istart = i;
- }
- else
- {
- char *zline;
- size_t cline;
-
- pz[i++] = "Standard error output was:\n";
- istart = i;
-
- zline = NULL;
- cline = 0;
- while (getline (&zline, &cline, eerr) > 0)
- {
- if (i >= cgot)
- {
- cgot += 20;
- pz = ((const char **)
- xrealloc ((pointer) pz,
- cgot * sizeof (const char *)));
- }
- pz[i++] = zbufcpy (zline);
- }
-
- (void) fclose (eerr);
- xfree ((pointer) zline);
- }
-
- (void) fsysdep_mail (zmail, "Execution failed", i, pz);
-
- for (; istart < i; istart++)
- ubuffree ((char *) pz[istart]);
- xfree ((pointer) pz);
- }
-
- if (qoutsys != NULL)
- (void) remove (zoutput);
-
- iclean = isave_files (qsys, zmail, zfile, iclean);
- }
- else
- {
- ubuffree (zfullcmd);
-
- if (zmail != NULL && fQsuccess_ack)
- {
- const char *az[20];
-
- i = 0;
- az[i++] = "\nExecution request succeeded:\n\t";
- az[i++] = zQcmd;
- az[i++] = "\n";
-
- (void) fsysdep_mail (zmail, "Execution succeded", i, az);
- }
-
- /* Now we may have to uucp the output to some other machine. */
-
- if (qoutsys != NULL)
- {
- struct scmd s;
-
- /* Fill in the command structure. */
-
- s.bcmd = 'S';
- s.bgrade = BDEFAULT_UUX_GRADE;
- s.pseq = NULL;
- s.zfrom = abtemp;
- s.zto = zQoutfile;
- if (zQuser != NULL)
- s.zuser = zQuser;
- else
- s.zuser = "uucp";
- if (zmail != NULL && fQsuccess_ack)
- s.zoptions = "Cn";
- else
- s.zoptions = "C";
- s.ztemp = abtemp;
- s.imode = 0666;
- if (zmail != NULL && fQsuccess_ack)
- s.znotify = zmail;
- else
- s.znotify = "";
- s.cbytes = -1;
- s.zcmd = NULL;
- s.ipos = 0;
-
- ubuffree (zsysdep_spool_commands (qoutsys, BDEFAULT_UUX_GRADE,
- 1, &s));
- }
- }
-
- if (zerror != NULL)
- {
- (void) remove (zerror);
- ubuffree (zerror);
- }
-
- uqcleanup (zfile, iclean);
-}
-
-/* If we have enough disk space, save the data files so that the UUCP
- administrator can examine them. Send a mail message listing the
- saved files. */
-
-static int
-isave_files (qsys, zmail, zfile, iclean)
- const struct uuconf_system *qsys;
- const char *zmail;
- const char *zfile;
- int iclean;
-{
- long cspace;
- char *zsavecmd;
- char **pzsave;
- int c;
- int ifile;
- char *zsaveinput;
- const char **pz;
- int i;
-
- /* Save the files if there is 1.5 times the amount of required free
- space. */
- cspace = csysdep_bytes_free (zfile);
- if (cspace == -1)
- cspace = FREE_SPACE_DELTA;
- cspace -= qsys->uuconf_cfree_space + qsys->uuconf_cfree_space / 2;
- if (cspace < 0)
- return iclean;
-
- zsavecmd = zsysdep_save_failed_file (zfile);
- if (zsavecmd == NULL)
- return iclean;
-
- c = 1;
-
- pzsave = (char **) xmalloc (cQfiles * sizeof (char *));
- for (ifile = 0; ifile < cQfiles; ifile++)
- {
- if (azQfiles[ifile] != NULL)
- {
- ++c;
- pzsave[ifile] = zsysdep_save_failed_file (azQfiles[ifile]);
- if (pzsave[ifile] == NULL)
- {
- ubuffree (zsavecmd);
- for (i = 0; i < ifile; i++)
- if (azQfiles[i] != NULL)
- ubuffree (pzsave[i]);
- xfree ((pointer) pzsave);
- return iclean;
- }
- }
- }
-
- zsaveinput = NULL;
- if ((iclean & REMOVE_QINPUT) != 0
- && fsysdep_file_exists (zQinput))
- {
- zsaveinput = zsysdep_save_failed_file (zQinput);
- if (zsaveinput == NULL)
- {
- ubuffree (zsavecmd);
- for (i = 0; i < cQfiles; i++)
- if (azQfiles[i] != NULL)
- ubuffree (pzsave[i]);
- xfree ((pointer) pzsave);
- return iclean;
- }
- }
-
- pz = (const char **) xmalloc ((20 + 2 * cQfiles) * sizeof (char *));
- i = 0;
-
- pz[i++] = "A UUCP execution request failed:\n\t";
- pz[i++] = zQcmd;
- if (zmail != NULL)
- {
- pz[i++] = "\nThe request was made by\n\t";
- pz[i++] = zmail;
- }
- else
- {
- pz[i++] = "\nThe request came from system\n\t";
- pz[i++] = qsys->uuconf_zname;
- }
- if (c == 1 && zsaveinput == NULL)
- pz[i++] = "\nThe following file has been saved:\n\t";
- else
- pz[i++] = "\nThe following files have been saved:\n\t";
- pz[i++] = zsavecmd;
- for (ifile = 0; ifile < cQfiles; ifile++)
- {
- if (azQfiles[ifile] != NULL)
- {
- pz[i++] = "\n\t";
- pz[i++] = pzsave[ifile];
- }
- }
- if (zsaveinput != NULL)
- {
- pz[i++] = "\n\t";
- pz[i++] = zsaveinput;
- }
- pz[i++] = "\n";
-
- (void) fsysdep_mail (OWNER,
- "UUCP execution files saved after failure",
- i, pz);
-
- xfree ((pointer) pz);
-
- ubuffree (zsavecmd);
- for (ifile = 0; ifile < cQfiles; ifile++)
- if (azQfiles[ifile] != NULL)
- ubuffree (pzsave[ifile]);
- xfree ((pointer) pzsave);
- ubuffree (zsaveinput);
-
- return iclean &~ (REMOVE_FILE | REMOVE_NEEDED);
-}
-
-/* Clean up the results of uqdo_xqt_file. */
-
-static void
-uqcleanup (zfile, iflags)
- const char *zfile;
- int iflags;
-{
- int i;
-
- DEBUG_MESSAGE2 (DEBUG_SPOOLDIR,
- "uqcleanup: %s, %d", zfile, iflags);
-
- if (zQunlock_file != NULL)
- {
- (void) fsysdep_unlock_uuxqt_file (zQunlock_file);
- zQunlock_file = NULL;
- }
-
- if ((iflags & REMOVE_FILE) != 0)
- (void) remove (zfile);
-
- if ((iflags & REMOVE_NEEDED) != 0)
- {
- for (i = 0; i < cQfiles; i++)
- {
- if (azQfiles[i] != NULL)
- (void) remove (azQfiles[i]);
- }
- if ((iflags & REMOVE_QINPUT) != 0)
- (void) remove (zQinput);
- }
-
- if ((iflags & FREE_QINPUT) != 0)
- ubuffree (zQinput);
-
- if ((iflags & FREE_OUTPUT) != 0)
- ubuffree (zQoutput);
- if ((iflags & FREE_MAIL) != 0)
- ubuffree (zQmail);
-
- if (fQunlock_directory)
- {
- (void) fsysdep_unlock_uuxqt_dir (iQlock_seq);
- fQunlock_directory = FALSE;
- }
-
- for (i = 0; i < cQfiles; i++)
- {
- ubuffree (azQfiles[i]);
- ubuffree (azQfiles_to[i]);
- }
-
- ubuffree (zQoutfile);
- ubuffree (zQoutsys);
- ubuffree (zQrequestor);
-
- if (azQargs != NULL)
- {
- for (i = 0; azQargs[i] != NULL; i++)
- ubuffree (azQargs[i]);
- xfree ((pointer) azQargs);
- azQargs = NULL;
- }
-
- xfree ((pointer) zQcmd);
- zQcmd = NULL;
-
- xfree ((pointer) azQfiles);
- azQfiles = NULL;
-
- xfree ((pointer) azQfiles_to);
- azQfiles_to = NULL;
-}
-
-/* Check whether forwarding is permitted. */
-
-static boolean
-fqforward (zfile, pzallowed, zlog, zmail)
- const char *zfile;
- char **pzallowed;
- const char *zlog;
- const char *zmail;
-{
- const char *zexclam;
-
- zexclam = strchr (zfile, '!');
- if (zexclam != NULL)
- {
- size_t clen;
- char *zsys;
- boolean fret;
-
- clen = zexclam - zfile;
- zsys = zbufalc (clen + 1);
- memcpy (zsys, zfile, clen);
- zsys[clen] = '\0';
-
- fret = FALSE;
- if (pzallowed != NULL)
- {
- char **pz;
-
- for (pz = pzallowed; *pz != NULL; pz++)
- {
- if (strcmp (*pz, "ANY") == 0
- || strcmp (*pz, zsys) == 0)
- {
- fret = TRUE;
- break;
- }
- }
- }
-
- if (! fret)
- {
- ulog (LOG_ERROR, "Not permitted to forward %s %s (%s)",
- zlog, zsys, zQcmd);
-
- if (zmail != NULL && ! fQno_ack)
- {
- int i;
- const char *az[20];
-
- i = 0;
- az[i++] = "Your execution request failed because you are";
- az[i++] = " not permitted to forward files\n";
- az[i++] = zlog;
- az[i++] = " the system\n\t";
- az[i++] = zsys;
- az[i++] = "\n";
- az[i++] = "Execution requested was:\n\t";
- az[i++] = zQcmd;
- az[i++] = "\n";
-
- (void) fsysdep_mail (zmail, "Execution failed", i, az);
- }
- }
-
- ubuffree (zsys);
-
- return fret;
- }
-
- return TRUE;
-}
diff --git a/gnu/usr.bin/Makefile b/gnu/usr.bin/Makefile
deleted file mode 100644
index f3128df..0000000
--- a/gnu/usr.bin/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id: Makefile,v 1.35 1997/02/22 15:43:16 peter Exp $
-
-SUBDIR= as awk bc bison cc cpio cvs dc dialog diff diff3 gdb genclass gperf \
- grep groff gzip ld man patch ptx rcs sdiff send-pr \
- sort tar texinfo
-
-.if !defined(NOPERL) && exists(${.CURDIR}/perl)
-SUBDIR+=perl
-.endif
-
-.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/Makefile.inc b/gnu/usr.bin/Makefile.inc
deleted file mode 100644
index 5371a22..0000000
--- a/gnu/usr.bin/Makefile.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-# $Id$
-
-BINDIR?= /usr/bin
diff --git a/gnu/usr.bin/as/CONTRIBUTORS b/gnu/usr.bin/as/CONTRIBUTORS
deleted file mode 100644
index cfcc7bc..0000000
--- a/gnu/usr.bin/as/CONTRIBUTORS
+++ /dev/null
@@ -1,11 +0,0 @@
-(This file under construction).
-
-If you've contributed to gas and your name isn't listed here, it is
-not meant as a slight. I just don't know about it. Email me,
-rich@cygnus.com and I'll correct the situation.
-
-Dean Elsnor wrote the original gas for vax.
-
-Jay Fenalson maintained gas for a while.
-
-K. Richard Pixley currently maintains gas.
diff --git a/gnu/usr.bin/as/COPYING b/gnu/usr.bin/as/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/as/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/as/ChangeLog b/gnu/usr.bin/as/ChangeLog
deleted file mode 100644
index db77234..0000000
--- a/gnu/usr.bin/as/ChangeLog
+++ /dev/null
@@ -1,429 +0,0 @@
-Sun Mar 1 17:02:06 1992 K. Richard Pixley (rich@cygnus.com)
-
- * README: updated to 1.92.3, included mail announcement.
-
-Sat Feb 29 00:53:16 1992 K. Richard Pixley (rich@cygnus.com)
-
- * tc-sparc.c (md_apply_fix): relocation overflow checks.
-
- * atof-generic.c (atof_generic): recognize 99e999 as infinity for
- older, broken, compilers.
-
- * version.c: bump to 1.92.3, drop "Cygnus".
-
- * input-scrub.c (as_where): use myname (which comes from argv[0])
- as part of all error messages.
-
- * mess-dose renaming:
- flonum-copy.c -> flo-copy.c
- flonum-const.c -> flo-const.c
- config/a.out.gnu.h -> config/aout.h
- config/coff.gnu.h -> config/coff.h
-
- * Makefile.in, obj-aout.h, obj-coff.h: reflect file renaming.
-
- * output-file.c (output_file_create): add "b" to the fopen to
- humor mess-dos.
-
- * configure.in: tahoe needs atof-tahoe.
-
- * config/tc-tahoe.[hc], config/atof-tahoe.c, opcode/tahoe.h: new
- files. This is kinda blind cause I don't have anything to run
- through it or compare against.
-
- * read.c (read_a_source_file), expr.c (operand): fix a very old
- bug in label reading exposed by m88k. Also, m88k can't have a
- pseudo "set".
-
- * config/m88k.[hc]: freshen copyrights, version 2 gpl, update to
- current gas.
-
- * config/m88k-opcode.h moved to opcode/m88k.h
-
- * read.c: NO_DOT_PSEUDOS from hacks unfinished work.
-
- * opcode/m68k.h: Sun's JFcc aliases appear to be variable length.
- Make them so.
-
- * opcode/a29k.h: remove rcsid.
-
- * config/te-sun3.h: remove semicolon typo.
-
- * config/obj-vms.c: another patch from eric youngdale.
-
- * write.c: white space only.
-
- * config/tc-i960.c: change from intel for header flags.
-
- * config/te-sequent.h, config/obj-aout.h: first cut at building
- sequent headers.
-
- * config/tc-ns32k.c: patches from Jyrki Kuoppala <jkp@cs.hut.fi>.
-
- * struct-symbol.h: removed redundant decl of N_TYPE_seg.
-
- * config/tc-sparc.c (sparc_ip), opcode/sparc.h: changes from chris
- torek to correct a problem with "neg". some white space.
-
- * confic/tc-m68k.c: a fix pulled from hack's unfinished work and
- my mail archives. Try again to get pcrel working. Fix stupid
- botch on cpu_type comparison.
-
- * config/tc-sparc.c: .empty pseudo-op from
- gordoni@cs.adelaide.edu.au.
-
- * opcode/sparc.h: some new aliases from chris torek.
-
- * opcode/i386.h: some new aliases and opcodes. also patches from
- Steve Bleazard <steve@robobar.co.uk>.
-
- * config/te-hpux.h: new file.
-
- * configure.in: when targetting hpux, use te-hpux.h.
-
- * config/obj-aout.c (obj-pre-write-hook), config/obj-bout.[ch]
- (obj-pre-write-hook), config/obj-coff.[ch] (obj-pre-write-hook),
- config/obj-generic.h, config/obj-vms.h, write.c
- (write_object_file): move magic number fiddling out of write.c
- and into obj-pre-write-hook.
-
- * config/tc-i860.c: gcc -Wall cleanup.
-
-Fri Feb 28 00:30:36 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * configure.in: if target is sun3, use te-sun3.h.
-
- * config/tc-m68k.h, config/te-sun3.h: moved #define of
- default_magic_number_for_object_file from former to latter.
-
- * config/te-sun3.h: removed sun_asm_syntax and te_sun3, they
- aren't used.
-
- * all: white space changes.
- " -> " becomes "->"
- "foo [" becomes "foo["
- "a . b" becomes "a.b"
- "\(if\|for\|while\|switch\)(" become "\\1("
- "\\([^\n]\\)[ \t]*\\([=!+-*/<>]\\)=[ \t]*" become "\\1 \\2= "
-
- * read.c, write.c, config/tc-i386.c: white space and comments
- only.
-
- * config/obj-vms.c: convert PUT_LONG and PUT_SHORT to squirt byte
- swapped numbers.
-
- * as.c, flonum-const.c, hex-value.c, input-file.c, version.c,
- config/obj-aout.h, config/obj-vms.c: VMS -> HO_VMS.
-
- * config/ho-vms.h: added HO_VMS.
-
-Thu Feb 27 18:25:11 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * config/ChangeLog: removed. entries merged into this file.
-
- * config/ho-vms.h: new file. Move the VMS stuff out of ho-vax.h
- into ho-vms.h.
-
- * configure.in: use ho-i386v4 for i386-sysvr4.
-
- * config/ho-i386v4: new file.
-
-Tue Feb 25 19:54:04 1992 (Eric Youngdale at youngdale@v6550c.nrl.navy.mil)
-
- * config/obj-vms.c (VMS_write_object_file): Add work-around
- for g++ compiler bug involving external vtables.
-
-Mon Feb 24 22:19:10 1992 (Eric Youngdale at youngdale@v6550c.nrl.navy.mil)
-
- * README-vms: Describe how to get a VMS obj file to a vms machine
- via NFS.
-
- * configure.in: For i386-sysv*, use gas_host=i386.
-
- * Makefile.in: Remove continuation line markers when the next line
- is blank.
-
- * read.c (line_comment_chars): Make external.
-
- * input-file.c: Remove redundant include of <assert.h>.
-
- * config/ho-vax.h [VMS]: Include <ctype.h> and <perror.h>.
-
- * config/obj-vms.h: Remove said includes. Add RELOC_32 to
- reloc_type to prevent compilation error.
-
- * config/obj-vms.c: Change bcopy to memcpy throughout.
- (VMS_local_stab_Parse): Fix typo.
- (VMS_local_stab_Parse, VMS_RSYM_Parse, Define_Local_Symbols,
- Define_Routine, VMS_write_object_file): Allow 'f' for functions
- as well as 'F'.
-
-Mon Feb 24 03:48:04 1992 K. Richard Pixley (rich@cygnus.com)
-
- * README: updated to reflect current testing status.
-
- * README.rich, NOTES, NOTES.config: updated slightly, marked as
- "under construction".
-
- * CONTRIBUTORS: new file.
-
- * README-vms: options to configure are now -options=, not
- +options=.
-
- * version.c: bumped version to 1.92.2.
-
-Mon Feb 24 03:27:00 1992 Eric Youngdale (youngdale at v6550c.nrl.navy.mil)
-
- * config.sub: Added vms as a target system. (So people do not
- have to try to figure out that "vax-dec-vms" would work).
-
- * configure.in: Added vms as a target os, and object file format.
- (Useless on a vms system, but this is for people who want to
- cross assemble).
-
- * config-gas.com: New file. Script for VMS systems to set up the
- configuration to build gas for VMS, and create config.status.
-
- * make-gas.com: Redone to work with the bfd-gas scheme.
-
- * as.c: Add const modifier to version_string.
-
- * atof-vax.c: Remove redundant include of flonum.h. (This is also
- included via as.h).
-
- * expr.c: Add "const" modifier to hex_value.
-
- * read.c: Add "const" modifier to line_comment_chars, and
- line_separator_chars. Make use of the -1 switch for backward
- compatibility with gcc 1.nn.
- (s_ignore): remove redundant declaration of is_end_of_line.
-
- * symbols.c: Finish conversion to S_* macros in the VMS only
- parts of the program. Add "const" modifier to
- md_[long,short]_jump_size. Remove declaration of const_flag
- (which will be declared in obj-vms.h).
-
- * write.c: Add "const" modifier to md_[long,short]_jump_size.
- Fix arguments to VMS_write_object_file.
-
- * obj-vms.h: New file (sort of). Mostly canibalized from other
- files, using:
-
- - objrecdef.h: Removed structure definition that we do not use,
- and removed dollar signs from identifiers, since Unix System 5
- does not like them.
-
- - obj-aout.h: Took S_*, some H_* macros, and a number of
- symbol definitions.
-
- - a.out.hp.h: Took nlist structure. We do not really use this
- per se, but it is easiest to let gas think that we do. When we
- write the object file, we just pick out the parts that we need.
-
- - stab.h: Just included it, since on non VMS and non a.out systems
- we have no guarantee of having it. (Define N_* symbols).
-
- *obj-vms.c: Renamed from vms.c. Did the following:
-
- - Reworked to use the S_* macros.
-
- - Add "const" modifier to version_string.
-
- - Added global[ref,def,value] support
-
- - (VMS_Store_PIC_Symbol_Reference):fix a bug with static constants.
-
- - Remove a few redunant includes - all are now included through as.h.
-
- - (obj_crawl_symbol_chain): Clean up (a lot), and remove non-VMS
- code. Add definition for obj_read_begin_hook.
-
- - Borrow the stab[s,d,n] routines from obj-aout.c.
-
- - Borrow the seg_N_TYPE and N_TYPE_seg arrays from aout.c
-
- - Use <fab.h>,<rab.h> and <xab.h> instead of <vms/fabdef.h>
- <vms/rabdef.h> and <vms/xabdef.h>, for more consistent results.
- (Some peoples <vms/*.h> files are different than others).
-
- - Merged vms-dbg.c into obj-vms.c. Modified to use
- the S_* macros. Added code to remove the psect hack from
- variable names before writing them to the debugger records.
-
-
-
- The following patches make cross assembly possible.
-
- * as.c, read.c, symbols.c, write.c: Change "ifdef VMS" to
- "ifdef OBJ_VMS".
-
- * vms.c:
-
- - Wrap the #include of some VMS system dependent headers
- with "ifdef VMS".
-
- - (get_VMS_time_on_unix): Add new routine. Generates current
- time in VMS format to be written into object file.
-
- - (Write_VMS_MHD_Records): Use get_VMS_time_on_unix if we are not
- running on a VMS system.
-
- - (Flush_VMS_Object_Record_Buffer): Add code to write correct
- record format when running on a non-VMS system.
-
- - (Create_VMS_Object_File): Use different mode if running under
- unix.
-
- - (VMS_TBT_Source_File): If we are not running on a VMS system,
- write a source file record for the debugger that looks reasonable.
-
-Mon Feb 24 02:06:00 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in: remove $(srcdir)/../include from INCLUDES. It
- isn't needed.
-
- * README: updated with current state.
-
- * read.c (stringer): read arbitrary expressions between the commas
- and treat them as ".byte" values. At least some i860 assembler
- does this so now we do too. Also white space throughout.
-
- * expr.c, expr.h, frags.c, symbols.c, write.c: white space only.
-
-Mon Feb 24 01:45:40 1992 K. Richard Pixley (rich@cygnus.com)
-
- * config/te-sequent.h, config/tc-ns32k.h, config/tc-ns32k.c:
- SEQUENT_COMPATIBILITY -> TE_SEQUENT.
-
- * config/obj-aout.c: if OLD_GAS and i386, then screw up the magic
- number.
-
- * config/obj-bout.c: do not include aout/stab_gnu.h if NO_LISTING.
-
- * config/obj-bout.h: added enum reloc_type.
-
- * config/tc-i386.c: on OLD_GAS, .align is power of two, rather
- than bytes.
-
- * config/tc-i386.h: on OLD_GAS, the filler byte should be zero
- rather than NOOP.
-
- * config/tc-i860.c: relocs are 12bytes on this target. Also white
- space.
-
- * config/tc-m68kmote.c: removed. Not ready yet.
-
- * config/a.out.gnu.h, config/tc-a29k.c, config/tc-m68k.c,
- config/tc-ns32k.c: white space only.
-
- * config/tc-a29k.h, config/tc-i860.h, config/tc-i960.h,
- config/tc-m68k.h, config/tc-ns32k.h, config/tc-sparc.h,
- config/tc-vax.h: NO_LISTING
-
- * config/tc-m68k.h, config/tc-i860.h, config/tc-vax.h:
- REVERSE_SORT_RELOCS if OLD_GAS.
-
- * config/mt-m68k: removed. not needed.
-
-Fri Feb 21 06:22:15 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * config/obj-aout.c: do not include stab.gnu.h if NO_LISTING.
-
- * config/tc-i860.c, config/a.out.gnu.h: move i860 relocs to a proper place.
-
- * config/a.out.h: removed.
-
-Fri Feb 21 06:21:07 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * Makefile.in: put header files before C source for TAGS; remove
- references to non-existent syscalls.h.
-
- * read.c, write.c subsegs.c: back out the .bss changes.
-
-Fri Feb 21 02:17:22 1992 Minh Tran-Le (TRANLE@INTELLICORP.COM)
-
- * config/tc-i386.c: config/tc-i386.c: added handling of the
- following opcodes: i/o opcodes - inb, inw, outb and outw.
- string manipulation with att syntax - scmp, slod, smov, ssca,
- ssto.
-
-Fri Feb 21 01:53:50 1992 Minh Tran-Le (TRANLE@INTELLICORP.COM)
-
- * config/obj-coff.c: (for aix386) Moved the symbols .text, .data
- and .bss to just after .file .
-
- In obj_crawl_symbol_chain() where it tries to put the external
- symbols apart, with the condition:
- (!S_IS_DEFINED(symbolP) &&
- !S_IS_DEBUG(symbolP) &&
- !SF_GET_STATICS(symbolP))
- it was moving too many symbols out. So I switch it back to the
- condition:
- (S_GET_STORAGE_CLASS(symbolP) == C_EXT && !SF_GET_FUNCTION(symbolP))
-
- In obj_emit_relocations() added the conditional on KEEP_RELOC_INFO
- so that we don't use the F_RELFLG which make the linker complain
- that somebody has stripped the relocation info.
-
- Also, the AIX ld program require that the relocation table
- is sorted by r_vaddr like the standard ATT assembler does.
-
- [he also changed the sizeof(struct ...)'s into the coff
- style FOOSZ macros. I'm not sure this is right, but I can't
- remember why. xoxorich.]
-
-Fri Feb 21 01:08:48 1992 Minh Tran-Le (TRANLE@INTELLICORP.COM)
-
- * symbols.c (local_label_name): symbols now start with ^A.
-
- * read.c, subsegs.c, write.c obj-coff.c: added handling of
- `.bss` pseudo op for unitialized data. The new gcc (1.37.9x)
- generate these sections. .align: will use NOP_OPCODE or 0
- for padding. This is just for being nice to the
- disassembler.
-
- * expr.c (operand): changed to generate local label "\001L0"
- starting with a ^A so that it is recognized as a local label.
-
- * as.c (perform_an_assembly_pass): zero bss_fix_root, too.
-
-Fri Feb 21 01:08:48 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in, configure.in, doc: use the doc. Build it, install
- it, clean it, etc.
-
-Tue Feb 18 02:21:25 1992 K. Richard Pixley (rich at cygnus.com)
-
- * read.c: white space and comments only.
-
- * configure.in: use the new atof-ns32.c for ns32k.
-
- * write.c: comment change only.
-
-Tue Feb 18 02:11:10 1992 K. Richard Pixley (rich at cygnus.com)
-
- * config/tc-m88k.[hc]: pulled in from hack's unfinished work. These
- aren't yet integrated.
-
- * config/tc-i860.[hc]: blew off the dust. Something must still be
- done about conflicting relocation types.
-
- * config/tc-ns32k.c: Replaced previous tc_aout_fix_to_chars stub
- with the real thing.
-
- * config/tc-i960.c, tc-sparc.c: white space and comments only.
-
- * config/tc-a29k.h: delete duplicate macro definition.
-
- * new file config/atof-ns32k.c copied from hack's last unreleased
- gas.
-
-Mon Feb 17 07:51:06 1992 K. Richard Pixley (rich at cygnus.com)
-
- * config/tc-ns32k.c: actually make tc_aout_fix_to_chars work
- rather than abort.
-
- * nearly everything. flush ChangeLog, package as gas-1.92.1.
- ChangeLog's prior to this are sketchy at best. I have logs.
- They just aren't ChangeLogs.
-
diff --git a/gnu/usr.bin/as/Makefile b/gnu/usr.bin/as/Makefile
deleted file mode 100644
index d86c025..0000000
--- a/gnu/usr.bin/as/Makefile
+++ /dev/null
@@ -1,71 +0,0 @@
-# from: @(#)Makefile 6.1 (Berkeley) 3/3/91
-# $Id$
-
-.include "config/Makefile.$(MACHINE)"
-
-.if !defined (gas_hosttype)
-gas_hosttype=$(MACHINE)
-.endif
-.if !defined (gas_target)
-gas_target=$(MACHINE)
-.endif
-.if !defined (gas_objformat)
-gas_objformat=aout
-.endif
-
-ADDINCLUDE=-I${.OBJDIR}
-
-PROG= as
-SRCS+= app.c as.c atof-generic.c bignum-copy.c \
- cond.c expr.c flo-const.c flo-copy.c flonum-mult.c \
- frags.c hash.c hex-value.c input-file.c input-scrub.c \
- listing.c messages.c obstack.c output-file.c read.c subsegs.c \
- symbols.c version.c write.c xmalloc.c xrealloc.c \
- obj-$(gas_objformat).c
-CFLAGS+= -I$(.CURDIR) ${ADDINCLUDE} -I$(.CURDIR)/config \
- -DOLD_GAS -DSIGTY=void -Derror=as_fatal \
- -DSUB_SEGMENT_ALIGN=4 -DFREEBSD_AOUT
-
-CONF_HEADERS= targ-cpu.h obj-format.h host.h targ-env.h
-
-.PATH: $(.CURDIR)/config
-
-SUBDIR+= doc
-
-beforedepend ${PROG}: ${CONF_HEADERS}
-
-targ-cpu.h: Makefile config/Makefile.$(MACHINE) $(.CURDIR)/config/tc-$(gas_target).h
- @cmp -s $(.CURDIR)/config/tc-$(gas_target).h targ-cpu.h || \
- ( ${ECHO} "updating ${.TARGET}..." ; /bin/rm -f targ-cpu.h ; \
- cp $(.CURDIR)/config/tc-$(gas_target).h targ-cpu.h )
-
-obj-format.h: Makefile config/Makefile.$(MACHINE) $(.CURDIR)/config/obj-$(gas_objformat).h
- @cmp -s $(.CURDIR)/config/obj-$(gas_objformat).h obj-format.h || \
- ( ${ECHO} "updating ${.TARGET}..." ; /bin/rm -f obj-format.h ; \
- cp $(.CURDIR)/config/obj-$(gas_objformat).h obj-format.h )
-
-.if exists ($(.CURDIR)/config/ho-$(gas_hosttype).h)
-config_hostfile= $(.CURDIR)/config/ho-$(gas_hosttype).h
-.else
-config_hostfile= $(.CURDIR)/config/ho-generic.h
-.endif
-
-host.h: Makefile config/Makefile.$(MACHINE) $(config_hostfile)
- @cmp -s $(config_hostfile) host.h || \
- ( ${ECHO} "updating ${.TARGET}..." ; /bin/rm -f host.h ; \
- cp $(config_hostfile) host.h )
-
-.if exists ($(.CURDIR)/config/te-$(MACHINE).h)
-config_targenvfile= $(.CURDIR)/config/te-$(MACHINE).h
-.else
-config_targenvfile= $(.CURDIR)/config/te-generic.h
-.endif
-
-targ-env.h: Makefile config/Makefile.$(MACHINE) $(config_targenvfile)
- @cmp -s $(config_targenvfile) targ-env.h || \
- ( ${ECHO} "updating ${.TARGET}..." ; /bin/rm -f targ-env.h ; \
- cp $(config_targenvfile) targ-env.h )
-
-CLEANFILES+= ${CONF_HEADERS}
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/as/Makefile.in b/gnu/usr.bin/as/Makefile.in
deleted file mode 100644
index b91bb33..0000000
--- a/gnu/usr.bin/as/Makefile.in
+++ /dev/null
@@ -1,411 +0,0 @@
-# $Id$
-
-# Makefile for GNU Assembler
-# Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
-#This file is part of GNU GAS.
-
-#GNU GAS 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.
-
-#GNU GAS 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 GNU GAS; see the file COPYING. If not, write to
-#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-# The targets for external use include:
-# all, doc, proto, install, uninstall, includes, TAGS,
-# clean, cleanconfig, realclean, stage1, stage2, stage3, stage4.
-
-# Variables that exist for you to override.
-# See below for how to change them for certain systems.
-
-srcdir = .
-
-prefix = /usr/local
-
-bindir = $(prefix)/bin
-datadir = $(prefix)/lib
-libdir = $(prefix)/lib
-mandir = $(datadir)/man
-man1dir = $(mandir)/man1
-man2dir = $(mandir)/man2
-man3dir = $(mandir)/man3
-man4dir = $(mandir)/man4
-man5dir = $(mandir)/man5
-man6dir = $(mandir)/man6
-man7dir = $(mandir)/man7
-man8dir = $(mandir)/man8
-man9dir = $(mandir)/man9
-infodir = $(datadir)/info
-includedir = $(prefix)/include
-docdir = $(datadir)/doc
-
-SHELL = /bin/sh
-
-INSTALL = install -c
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_DATA = $(INSTALL)
-
-AR = ar
-AR_FLAGS = qv
-BISON = bison
-MAKEINFO = makeinfo
-RANLIB = ranlib
-MINUS_G = -g
-
-# Lists of files for various purposes.
-
-REAL_SOURCES = \
- $(srcdir)/app.c \
- $(srcdir)/as.c \
- $(srcdir)/atof-generic.c \
- $(srcdir)/bignum-copy.c \
- $(srcdir)/cond.c \
- $(srcdir)/expr.c \
- $(srcdir)/flo-const.c \
- $(srcdir)/flo-copy.c \
- $(srcdir)/flonum-mult.c \
- $(srcdir)/frags.c \
- $(srcdir)/hash.c \
- $(srcdir)/hex-value.c \
- $(srcdir)/input-file.c \
- $(srcdir)/input-scrub.c \
- $(srcdir)/messages.c \
- $(srcdir)/obstack.c \
- $(srcdir)/output-file.c \
- $(srcdir)/read.c \
- $(srcdir)/strerror.c \
- $(srcdir)/strstr.c \
- $(srcdir)/subsegs.c \
- $(srcdir)/symbols.c \
- $(srcdir)/version.c \
- $(srcdir)/write.c \
- $(srcdir)/listing.c \
- $(srcdir)/xmalloc.c \
- $(srcdir)/xrealloc.c
-
-# in an expedient order
-LINKED_SOURCES = \
- targ-cpu.c \
- obj-format.c \
- atof-targ.c
-
-SOURCES = $(LINKED_SOURCES) $(REAL_SOURCES)
-
-REAL_HEADERS = \
- $(srcdir)/as.h \
- $(srcdir)/bignum.h \
- $(srcdir)/expr.h \
- $(srcdir)/flonum.h \
- $(srcdir)/frags.h \
- $(srcdir)/hash.h \
- $(srcdir)/input-file.h \
- $(srcdir)/listing.h \
- $(srcdir)/tc.h \
- $(srcdir)/obj.h \
- $(srcdir)/obstack.h \
- $(srcdir)/read.h \
- $(srcdir)/struc-symbol.h \
- $(srcdir)/subsegs.h \
- $(srcdir)/symbols.h \
- $(srcdir)/write.h
-
-LINKED_HEADERS = \
- a.out.gnu.h \
- a.out.h \
- host.h \
- targ-env.h \
- targ-cpu.h \
- obj-format.h \
- atof-targ.h
-
-HEADERS = $(LINKED_HEADERS) $(REAL_HEADERS)
-
-OBJS = \
- targ-cpu.o \
- obj-format.o \
- atof-targ.o \
- app.o \
- as.o \
- atof-generic.o \
- bignum-copy.o \
- cond.o \
- expr.o \
- flo-const.o \
- flo-copy.o \
- flonum-mult.o \
- frags.o \
- hash.o \
- hex-value.o \
- input-file.o \
- input-scrub.o \
- messages.o \
- obstack.o \
- output-file.o \
- read.o \
- strerror.o \
- strstr.o \
- subsegs.o \
- symbols.o \
- version.o \
- write.o \
- listing.o \
- xmalloc.o \
- xrealloc.o
-
-#### host, target, and site specific Makefile frags come in here.
-
-all: as.new
- (cd doc ; $(MAKE) all)
-
-info:
- (cd doc ; $(MAKE) info)
-
-install-info:
- (cd doc ; $(MAKE) install-info)
-
-clean-info:
- (cd doc ; $(MAKE) clean-info)
-
-# Now figure out from those variables how to compile and link.
-
-# This is the variable actually used when we compile.
-ALL_CFLAGS = $(MINUS_G) $(INTERNAL_CFLAGS) $(CFLAGS) $(HDEFINES) $(TDEFINES) -DPIC -DOLD_GAS
-
-# How to link with both our special library facilities
-# and the system's installed libraries.
-
-LIBS = $(HLIBS)
-
-# Specify the directories to be searched for header files.
-# Both . and srcdir are used, in that order,
-# so that tm.h and config.h will be found in the compilation
-# subdirectory rather than in the source directory.
-INCLUDES = -I. -I$(srcdir) -I$(srcdir)/config # -I$(srcdir)/../include
-SUBDIR_INCLUDES = -I.. -I$(srcdir) -I$(srcdir)/config
-
-# Always use -I$(srcdir)/config when compiling.
-.c.o:
- $(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $<
-
-# This tells GNU make version 3 not to export all the variables
-# defined in this file into the environment.
-.NOEXPORT:
-
-# Files to be copied away after each stage in building.
-STAGESTUFF = *.o as.new
-
-as.new: $(OBJS) $(LIBDEPS)
- -mv -f as.new as.old
- $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o as.new $(OBJS) $(LIBS)
-
-config.status:
- @echo You must configure gas. Look at the INSTALL file for details.
- @false
-
-# Compiling object files from source files.
-
-app.o : app.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-as.o : as.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-atof-generic.o : atof-generic.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-bignum-copy.o : bignum-copy.c as.h host.h \
- targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-cond.o : cond.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-
-debug.o : debug.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- subsegs.h
-expr.o : expr.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-
-flo-const.o : flo-const.c flonum.h bignum.h
-flo-copy.o : flo-copy.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-flonum-mult.o : flonum-mult.c flonum.h bignum.h
-frags.o : frags.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- subsegs.h
-hash.o : hash.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-hex-value.o : hex-value.c
-input-file.o : input-file.c as.h host.h \
- targ-env.h obj-format.h targ-cpu.h \
- struc-symbol.h write.h flonum.h bignum.h expr.h \
- frags.h hash.h read.h symbols.h tc.h obj.h input-file.h
-input-scrub.o : input-scrub.c /usr/include/errno.h /usr/include/sys/errno.h \
- as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- input-file.h
-listing.o : listing.c as.h host.h targ-env.h flonum.h bignum.h \
- listing.h obj-format.h targ-cpu.h struc-symbol.h write.h expr.h \
- frags.h hash.h read.h symbols.h tc.h obj.h input-file.h
-messages.o : messages.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-obstack.o : obstack.c
-output-file.o : output-file.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- output-file.h
-read.o : read.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-
-strstr.o : strstr.c
-subsegs.o : subsegs.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- subsegs.h
-symbols.o : symbols.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- subsegs.h
-version.o : version.c
-write.o : write.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- subsegs.h output-file.h
-xmalloc.o : xmalloc.c
-xrealloc.o : xrealloc.c
-atof-targ.o : atof-targ.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h \
- symbols.h tc.h obj.h
-obj-format.o : obj-format.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h \
- symbols.h tc.h obj.h
-targ-cpu.o : targ-cpu.c targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h \
- symbols.h tc.h obj.h $(TARG_CPU_DEPENDENTS)
-
-# Remake the info files.
-
-doc: $(srcdir)/as.info
-
-$(srcdir)/as.info: $(srcdir)/doc/as.texinfo
- (cd doc; make as.info; mv -f as.info $srcdir)
-
-clean:
- (cd doc ; $(MAKE) clean)
- -rm -f $(STAGESTUFF) core
-
-# Like clean but also delete the links made to configure gas.
-distclean: clean
- -rm -f config.status Makefile host.h targ-env.h targ-cpu.h \
- targ-cpu.c obj-format.h obj-format.c atof-targ.c \
- gas.aux gas.cps gas.fns gas.info gas.kys gas.pgs \
- gas.tps gas.vrs TAGS gas.info* gas.?? gas.??s gas.log \
- gas.toc gas.*aux *.dvi
-
-# Entry points `install', `includes' and `uninstall'.
-
-# Copy the files into directories where they will be run.
-install:
- if [ "$(host_alias)" = "$(target_alias)" ] ; then \
- $(INSTALL_PROGRAM) as.new $(bindir)/as ; \
- else \
- $(INSTALL_PROGRAM) as.new $(bindir)/as-$(target_alias) ; \
- fi
-
-# Create the installation directory.
-install-dir:
- -mkdir $(libdir)
- -mkdir $(libdir)/gcc
- -mkdir $(libdir)/gcc/$(target)
- -mkdir $(libdir)/gcc/$(target)/$(version)
-
-# Cancel installation by deleting the installed files.
-uninstall:
- -rm -rf $(libsubdir)
- -rm -rf $(bindir)/as
- -rm -rf $(mandir)/gas.$(manext)
-
-
-# These exist for maintenance purposes.
-
-tags TAGS: force
- etags $(REAL_HEADERS) $(REAL_SOURCES) $(srcdir)/config/*.[hc] $(srcdir)/README $(srcdir)/Makefile.in
-
-bootstrap: as.new force
- $(MAKE) stage1
- $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new
- $(MAKE) stage2
- $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new
- $(MAKE) comparison against=stage2
-
-bootstrap2: force
- $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new
- $(MAKE) stage2
- $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new
- $(MAKE) comparison against=stage2
-
-bootstrap3: force
- $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new
- $(MAKE) comparison against=stage2
-
-# Copy the object files from a particular stage into a subdirectory.
-stage1: force
- -mkdir stage1
- -mv -f $(STAGESTUFF) stage1
- if [ -f stage1/as.new -a ! -f stage1/as ] ; then (cd stage1 ; ln -s as.new as) ; fi
-
-stage2: force
- -mkdir stage2
- -mv -f $(STAGESTUFF) stage2
- if [ -f stage2/as.new -a ! -f stage2/as ] ; then (cd stage2 ; ln -s as.new as) ; fi
-
-stage3: force
- -mkdir stage3
- -mv -f $(STAGESTUFF) stage3
- if [ -f stage3/as.new -a ! -f stage3/as ] ; then (cd stage3 ; ln -s as.new as) ; fi
-
-against=stage2
-
-comparison: force
- for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done
-
-de-stage1: force
- - (cd stage1 ; rm -f as ; mv -f * ..)
- - rmdir stage1
-
-de-stage2: force
- - (cd stage2 ; rm -f as ; mv -f * ..)
- - rmdir stage2
-
-de-stage3: force
- - (cd stage3 ; rm -f as ; mv -f * ..)
- - rmdir stage3
-
-#In GNU Make, ignore whether `stage*' exists.
-.PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap
-
-force:
-
-Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
- $(SHELL) ./config.status
-
diff --git a/gnu/usr.bin/as/NOTES b/gnu/usr.bin/as/NOTES
deleted file mode 100644
index 9f18fac..0000000
--- a/gnu/usr.bin/as/NOTES
+++ /dev/null
@@ -1,16 +0,0 @@
-to do:
-
-remove DONTDEF
-remove the ifdef's from fx_callj tests?
-what are callj tests?
-space tighten sparc alignment.
-fix number_to_chars, & family to have no side effects.
-md_ => tp_
-multiple segments.
-share b.out with a.out.
-
-regress:
-
-+-inf
-
-stack:
diff --git a/gnu/usr.bin/as/NOTES.config b/gnu/usr.bin/as/NOTES.config
deleted file mode 100644
index a511519..0000000
--- a/gnu/usr.bin/as/NOTES.config
+++ /dev/null
@@ -1,52 +0,0 @@
-(This file under construction).
-
-
- The GAS Configuration Plan
-
-Theory:
-
-The goal of the new configuration scheme is to bury all object format,
-target processor, and host machine dependancies in object, target, and
-host specific files. That is, to move as many #ifdef's as possible
-out of the gas common code.
-
-Here's how it works. There is a .h and a .c file for each object file
-format, a .h and a .c file for each target processor, and a .h for
-each host. configure creates {sym}links in the current directory to
-the appropriate files in the config directory.
-
-Implementation:
-
-host.h is a {sym}link to .../config/ho-yourhost.h. It is intended to
-be used to hide host compiler, system header file, and system library
-differences between host machines. If your host needs actual c source
-files, then either: these are generally useful functions, in which
-case you should probably build a local library outside of the gas
-source tree, or someone, perhaps me, is confused about what is needed
-by different hosts.
-
-obj-format.h is a {sym}link to .../config/obj-something.h. It is
-intended to hide object file format differences from the bulk of gas,
-and from most of the cpu backend.
-
-All gas .c files include as.h.
-
-as.h #define's "gas", includes host.h, defines a number of gas
-specific structures and types, and then includes tp.h, obj.h, and
-target-environment.h.
-
-te-something.h defines a target environment specific preprocessor
-flag, eg, TE_SUN, and then includes obj-format.h.
-
-obj-format.h defines an object format specific preprocessor flag, eg,
-OBJ_AOUT, OBJ_BOUT, OBJ_COFF, includes "target-processor.h", and then
-defines the object specific macros, functions, types, and structures.
-
-target-processor.h
-
-target-processor.
-
-Porting:
-
-There appear to be four major types of ports; new hosts, new target
-processors, new object file formats, and new target environments.
diff --git a/gnu/usr.bin/as/README b/gnu/usr.bin/as/README
deleted file mode 100644
index 73b7605..0000000
--- a/gnu/usr.bin/as/README
+++ /dev/null
@@ -1,212 +0,0 @@
-This is a pre-alpha version of the GNU assembler, version 1.92.3.
-
-(this is a copy of the mail announcement. Real README follows below.)
-
-This session I merged the m88k support. It configures, builds, and
-assembles things, including some gcc2 output. I have no way of
-knowing if the output is right.
-
-I've merged the tahoe support. It configures and builds. I couldn't
-build the cygnus version of gcc2 for this machine, so I have no idea
-whether gas is assembling anything at all for it.
-
-I've walked through my bug and patch archives. Gas now makes a
-tolerable guess at a.out headers for hpux and sequent, although I have
-no way to know if these are right yet.
-
-Ming tran-le's changes for 386aix will probably drop out soon. He
-needs multiple segments and I don't plan to get that in before the
-real release.
-
-Eric youngdale's help with vms has been invaluable. According to him,
-this gas is doing vms. I didn't quite get a cross to vms working and
-don't plan to spend any more time on it.
-
-The gas manual is included in the distribution, configuration, and
-Makefiles. It should build, be printable, and readable through info.
-
-I have not yet verified that this gas has all of the unreleased
-changes that hack made after the last gas release. At this point I
-plan to ignore these until those bugs are re-reported in an alpha or
-full release I don't think it's worth my time.
-
-I have not yet verified any hosts other than sun4, although I have
-three-staged sun3 native.
-
-I have not updated the configuration doc.
-
-I do not plan to bring in any new backends for the upcoming release
-unless someone hands them to me on a platter as eric did for vms. I
-merged the m88k and tahoe ports because they were simple for me at
-this point, but would have been difficult for someone else. I may yet
-do this for the ncube support as well.
-
-I've looked at the osf stuff and discarded it for this release. I'm
-not sure I like what they've done for macho object format and without
-macho headers, I can't even build their version.
-
-I've looked at the utah stuff and discarded it for this release.
-They, too, have made some sweeping changes to support their object
-format that I'm not sure were necessary. In any case, merging this
-would be too much work for me right now.
-
-I've looked at the tron port. It's remarkably clean and it's a.out
-format. I don't plan to merge this for the full release for two
-reasons. First, it's so clean, they will be able to add their stuff
-on top and build a seperate distribution without much trouble.
-Second, I'm get responses from them, and hope that they will be able
-to do the merge.
-
-
-To do before alpha:
-
-* merge patches and address bugs as they arrive.
-
-* kill a remaining bug. The following input:
-
- .text
-a .word 3
-b .word 4
-c .half b-a
-
-kills most risc ports. I believe that this represents a failing of
-the internal representation of relocs (aka fixS's). The fix is
-relatively straightforward and I intend to make it.
-
-* add autoconf style configuration for hosts (not targets).
-
-* test via three-staging (preferably with gcc2) on all a.out based
- machines to which I have access.
-
-* update/clean out README's and build a brief porting guide.
-
-There is still a copyright issue on the coff back end, so it may need
-to be pulled for the full release. If this gets resolved, I hope to
-see coff run personally on at least one native machine before full
-release.
-
-
-Real README:
-
-This is a pre-alpha version of the GNU assembler, version 1.92.3.
-
-A number of things have changed and the wonderful world of gas looks
-very different. There's still a lot of irrelevant garbage lying
-around that will be cleaned up soon. The gas manual now builds and
-installs, but internal documentation is still scarce, as are logs of
-the changes made since the last gas release. My apologies, and I'll
-try to get something useful
-
-At this point I believe gas to be ansi only code for most target
-cpu's. That is, there should be relatively few, if any host system
-dependencies. Most of my recent effort has been spent testing and
-dusting off ports for which Cygnus hasn't had recent need.
-
-Hosting has recently been tested on only:
-
- sun4
- sun3
-
-I believe that gas can currently be targetted for:
-
- sun4
- sun3
-
-and "ports" for other cpu's and object file formats from the following
-set are probably trivial at this point:
-
- a.out
-
- a29k
- i386
- i860
- i960
- m68k
- m88k
- ns32k
- tahoe
- sparc
- vax
-
-I have tested most of these in "generic" a.out configurations so I
-feel pretty confident in them. If anything else works, it's an
-accident.
-
-Some ports now generate object files that are somewhat differently
-shaped, but should be more correct. Specifically:
-
-* Most a.out ports now sort the relocation table in numerically
- ascending order. In previous versions of gas, the relocation table
- was sorted in descending order. To get the previous functionality,
- compile with -DREVERSE_SORT_RELOCS.
-
-* ns32k: The last gas I have from hack simply looks broken for ns32k.
- I think this one works, but don't have an assembler that I trust
- against which to compare.
-
-* i386: now uses ".align x" to mean x bytes rather than 2^x bytes. It
- also pads with the noop instruction rather than zeroes.
-
-In all cases, compiling with -DOLD_GAS will produce an assembler that
-should produce object files that are bitwise identical to the previous
-version of gas.
-
-
-
- NEW FEATURES!
-
-
-This isn't a complete catalog. I've forgotten what all has been done.
-
-* support for i960, a29k, m88k, and tahoe.
-
-* support for 68030 and 68040, including the ability to limit the
- instructions that gas will accept. ie, you can assemble for EXACTLY
- 68000 and no more.
-
-* object file formats have been broken out into separate backends.
-
-* a new "backend" has been created to represent the target
- environment. That is, gas now mimics various other assemblers
- rather than creating it's own requirements. A side effect of this
- is that this version of gas may not behave the same way as previous
- versions.
-
-* ansi. gas is now strictly ansi code so host ports should be
- trivial.
-
-
-
- REPORTING BUGS IN GAS
-
-
-Bugs in THIS RELEASE of gas should be reported directly to
-rich@cygnus.com. NOT to bug-gnu-utils@prep.ai.mit.edu.
-
-If you report a bug in GAS, please remember to include:
-
-A description of exactly what went wrong.
-
-How GAS was configured,
-
-The Operating System GAS was running under.
-
-The options given to GAS.
-
-The actual input file that caused the problem.
-
-It is silly to report a bug in GAS without including an input file for
-GAS. Don't ask us to generate the file just because you made it from
-files you think we have access to.
-
-1. You might be mistaken.
-2. It might take us a lot of time to install things to regenerate that file.
-3. We might get a different file from the one you got, and might not see any
-bug.
-
-To save us these delays and uncertainties, always send the input file
-for the program that failed.
-
-If the input file is very large, and you are on the internet, you may
-want to make it avaliable for anonymous FTP instead of mailing it. If you
-do, include instructions for FTP'ing it in your bug report.
diff --git a/gnu/usr.bin/as/README-vms b/gnu/usr.bin/as/README-vms
deleted file mode 100644
index 796c603..0000000
--- a/gnu/usr.bin/as/README-vms
+++ /dev/null
@@ -1,248 +0,0 @@
- This document explains a couple of things that are specific to VMS.
-There are currently two "chapters", the first deals with cross-assembly
-issues, and the second deals with the VMS debugger and GNU-CC.
-
-
-***********************************************************************
-****************** Notes for Cross Assembly with VMS ******************
-***********************************************************************
-
- If you wish to build gas on a non-VMS system to cross-assemble,
-you should use:
-
-configure ${hosttype} -target=vms
-
-and then follow the usual procedure. The object files generated on
-Unix will be correct from a binary point of view, but the real trick is
-getting them to the VMS machine. The format of the object file is
-a variable-length record, but each record contains binary data. gas
-writes the records in the same format that VMS would expect,
-namely a two-byte count followed by that number of bytes.
-
- If you try to copy the file to a VMS system using ftp, the ftp
-protocol will screw up the file by looking for nulls (record terminator for
-unix) and it will insert it's own record terminators at that point. This
-will obviously corrupt the file.
-
- If you try to transfer the file with ftp in binary mode, the
-file itself will not be corrupt, but VMS will think that the file contains
-fixed-length records of 512 bytes. You can use the public-domain FILE
-utility to change this with a command like:
-
-$FILE foo.o/type=variable
-
-If you do not have this utility available, the following program can be
-used to perform this task:
-
- #include <fab.h>
-
- #define RME$C_SETRFM 1
-
- struct FAB * fab;
-
- main(int argc, char * argv[]){
- int i, status;
- fab = (struct FAB*) malloc(sizeof(struct FAB));
- *fab = cc$rms_fab; /* initialize FAB*/
- fab->fab$b_fac = FAB$M_PUT;
- fab->fab$l_fop |= FAB$M_ESC;
- fab->fab$l_ctx = RME$C_SETRFM;
- fab->fab$w_ifi = 0;
- for(i=1;i<argc;i++){
- printf("Setting %s to variable length records.\n",argv[i]);
- fab->fab$l_fna = argv[i];
- fab->fab$b_fns = strlen(argv[i]);
- status = sys$open(fab,0,0);
- if((status & 7) != 1) lib$signal(status);
- fab->fab$b_rfm = FAB$C_VAR;
- status = sys$modify(fab,0,0);
- if((status & 7) != 1) lib$signal(status);
- status = sys$close(fab,0,0);
- if((status & 7) != 1) lib$signal(status);
- };
- }
-
- If you have NFS running on the VMS system, what you need to do
-depends upon which NFS software you are running on the VMS system. There
-are a number of different TCP/IP packages for VMS available, and only very
-limited testing has been performed. In the tests that has been done so
-far, the contents of the file will always be correct when transferring the
-file via NFS, but the record attributes may or may not be correct.
-
- One proprietary TCP/IP/NFS package for VMS is known to
-automatically fix the record attributes of the object file if you NFS mount
-a unix disk from the VMS system, and if the file has a ".obj" extension on
-the unix system. Other TCP/IP packages might do this for you as well, but
-they have not been checked.
-
-No matter what method you use to get the file to the VMS system, it is
-always a good idea to check to make sure that it is the correct type by
-doing a "$dir/full" on the object file. The desired record attributes will
-be "None". Undesirable record attributes will be "Stream-LF" or anything
-else.
-
-Once you get the files on the VMS system, you can check their integrity
-with the "$anal/obj" command. (Naturally at some point you should rename
-the .o files to .obj). As far as the debugger is concerned, the records
-will be correct, but the debugger will not be able to find the source files,
-since it only has the file name, and not the full directory specification.
-You must give the debugger some help by telling it which directories to
-search for the individual files - once you have done this you should be
-able to proceed normally.
-
- It is a good idea to use names for your files which will be valid
-under VMS, since otherwise you will have no way of getting the debugger to
-find the source file when deugging.
-
-The reason for this is that the object file normally contins specific
-information that the debugger can use to positively identify a file, and if
-you are assembling on a unix system this information simply does not exist
-in a meaningful way. You must help the debugger by using the "SET FILE="
-command to tell the debugger where to look for source files. The debugger
-records will be correct, except that the debugger will not be initially
-able to find the source files. You can use the "SET FILE" command to tell
-the debugger where to look for the source files.
-
-I have only tested this with a SVr4 i486 machine, and everything seems to
-work OK, with the limited testing that I have done. Other machines may
-or may not work. You should read the chapters on cross-compilers in the gcc
-manual before fooling with this. Since gas does not need to do any floating
-point arithmetic, the floating point constants that are generated here should
-be correct - the only concern is with constant folding in the main compiler.
-The range and precision of floats and doubles are similar on the 486 (with
-a builtin 80387) and the VAX, although there is a factor of 2 to 4
-difference in the range. The double, as implemented on the 486, is quite
-similar to the G_FLOAT on the VAX.
-
-***********************************************************************
-****************** Notes for using GNU CC with the VMS debugger********
-***********************************************************************
-
-
- 1) You should be aware that GNU-C, as with any other decent compiler,
-will do things when optimization is turned on that you may not expect.
-Sometimes intermediate results are not written to variables, if they are only
-used in one place, and sometimes variables that are not used at all will not be
-written to the symbol table. Also, parameters to inline functions are often
-inaccessible. You can see the assembly code equivalent by using KP7 in the
-debugger, and from this you can tell if in fact a variable should have the
-value that you expect. You can find out if a variable lives withing a register
-by doing a 'show symbol/addr'.
-
- 2) Overly complex data types, such as:
-
-int (*(*(*(*(*(* sarr6)[1])[1])[2])[3])[4])[5];
-
-will not be debugged properly, since the debugging record overflows an internal
-debugger buffer. gcc-as will convert these to *void as far as the debugger
-symbol table is concerned, which will avoid any problems, and the assembler
-will give you a message informing you that this has happened.
-
- 3) You must, of course, compile and link with /debug. If you link
-without debug, you still get traceback table in the executable, but there is no
-symbol table for variables.
-
- 4) Included in the patches to VMS.C are fixes to two bugs that are
-unrelated to the changes that I have made. One of these made it impossible to
-debug small programs sometimes, and the other caused the debugger to become
-confused about which routine it was in, and give this incorrect info in
-tracebacks.
-
- 5) If you are using the GNU-C++ compiler, you should modify the
-compiler driver file GNU_CC:[000000]GCC.COM (or GXX.COM). If you have a
-seperate GXX.COM, then you need to change one line in GXX.COM to:
-$ if f$locate("D",p2) .ne. P2_Length then Debug = " ""-G0"""
- Notice zero---> ^
-If you are using a GCC.COM that does both C and C++, add the following lines to
-GCC.COM:
-
-$!
-$! Use old style debugging records for VMS
-$!
-$ if (Debug.nes."" ).and. Plus then Debug = " ""-G0"""
-
-after the variables Plus and Debug are set. The reason for this, is that C++
-compiler by default generates debugging records that are more complex,
-with many new syntactical elements that allow for the new features of the
-language. The -G0 switch tells the C++ compiler to use the old style debugging
-records. Until the debugger understands C++ there is not any point to try and
-use the expanded syntax.
-
- 6) When you have nested scopes, i.e.:
-main(){
- int i;
- {int i;
- {int i;
-};};}
-and you say "EXAM i" the debugger needs to figure out which variable you
-actually want to reference. I have arranged things to define a block to the
-debugger when you use brackets to enter a new scope, so in the example above,
-the variables would be described as:
-TEST\main\i
-TEST\main\$0\i
-TEST\main\$0\$0\i
-At each level, the block name is a number with a dollar sign prefix, the
-numbers start with 0 and count upward. When you say EXAM i, the debugger looks
-at the current PC, and decides which block it is currently in. It works from
-the innermost level outward until it finds a block that has the variable "i"
-defined. You can always specify the scope explicitly.
-
- 7) With C++, there can be a lot of inline functions, and it would be
-rather restrictive to force the user to debug the program by converting all of
-the inline functions to normal functions. What I have done is to essentially
-"add" (with the debugger) source lines from the include files that contain the
-inline functions. Thus when you step into an inline function it appears as if
-you have called the function, and you can examine variables and so forth.
-There are several *very* important differences, however. First of all, since
-there is no function call involved, you cannot step over the inline function
-call - you always step into it. Secondly, since the same source lines are used
-in many locations, there is a seperate copy of the source for *each* usage.
-Without this, breakpoints do not work, since we must have a 1-to-1 mapping
-between source lines and PC.
- Since you cannot step over inline function calls, it can be a real pain
-if you are not really interested in what is going on for that function call.
-What I have done is to use the "-D" switch for the assembler to toggle the
-following behavior. With the "-D" switch, all inline functions are included in
-the object file, and you can debug everything. Without the "-D" switch
-(default case with VMS implementation), inline functions are included *only* if
-they did not come from system header files (i.e. from GNU_CC_INCLUDE: or
-GNU_GXX_INCLUDE:). Thus, without the switch the user only debugs his/her own
-inline functions, and not the system ones. (This is especially useful if you do
-a lot of stream I/O in C++). This probably will not provide enough granularity
-for many users, but for now this is still somewhat experimental, and I would
-like to reflect upon it and get some feedback before I go any further.
-Possible solutions include an interactive prompting, a logical name, or a new
-command line option in gcc.c (which is then passed through somehow to the guts
-of the assembler).
- The inline functions from header files appear after the source code
-for the source file. This has the advantage that the source file itself is
-numbered with the same line numbers that you get with an editor. In addition,
-the entire header file is not included, since the assembler makes a list of
-the min and max source lines that are used, and only includes those lines from
-the first to the last actually used. (It is easy to change it to include the
-whole file).
-
- 8) When you are debugging C++ objects, the object "this" is refered to
-as "$this". Actually, the compiler writes it as ".this", but the period is
-not good for the debugger, so I have a routine to convert it to a $. (It
-actually converts all periods to $, but only for variables, since this was
-intended to allow us to access "this".
-
- 9) If you use the asm("...") keyword for global symbols, you will not
-be able to see that symbol with the debugger. The reason is that there are two
-records for the symbol stored in the data structures of the assembler. One
-contains the info such as psect number and offset, and the other one contains
-the information having to do with the data type of the variable. In order to
-debug as symbol, you need to be able to coorelate these records, and the only
-way to do this is by name. The record with the storage attributes will take
-the name used in the asm directive, and the record that specifies the data type
-has the actual variable name, and thus when you use the asm directive to change
-a variable name, the symbol becomes invisible.
-
- 10) Older versions of the compiler ( GNU-C 1.37.92 and earlier) place
-global constants in the text psect. This is unfortunate, since to the linker
-this appears to be an entry point. I sent a patch to the compiler to RMS,
-which will generate a .const section for these variables, and patched the
-assembler to put these variables into a psect just like that for normal
-variables, except that they are marked NOWRT. static constants are still
-placed in the text psect, since there is no need for any external access.
diff --git a/gnu/usr.bin/as/README.coff b/gnu/usr.bin/as/README.coff
deleted file mode 100644
index 46c61cd..0000000
--- a/gnu/usr.bin/as/README.coff
+++ /dev/null
@@ -1,79 +0,0 @@
-The coff patches intend to do the following :
-
- . Generate coff files very compatible with vanilla linker.
- . Understands coff debug directives.
-
-Here are the guidelines of the work I have done :
-
- . Encapsulate format dependent code in macros where it is possible.
- . Where not possible differenciate with #ifdef
- . try not to change the calling conventions of the existing functions.
- I made one exception : symbol_new. I would be pleased to hear about
- a better solution. (symbols.c)
- . Extend the use of N_TYPE_seg seg_N_TYPE tables so that segments can
- be manipulated without using their format dependent name. (subsegs.c)
- . Write a function to parse the .def debug directives
- . Write two small peaces of code to handle the .ln directive.
- . In write.c try to move all the cross compilation specifics (md_..) to
- format dependent files.
- . Encapsulate the data structures using generic types, macros calls.
- . Added too much code to resolve the complexity of the symbol table
- generated. Most of the code deals with debug stuff.
- . Create another makefile, shorter, cleaner.
- . Create a config.gas shell script to mimic the gcc,gdb... configuration
- mechanism. This reduce the complexity of the makefile.
- . Isolate the format dependent code in two files
- coff.c coff.h
- aout.c aout.h
- elf.c elf.h [ Not yet ;-]
- . added a little stack management routine for coff in file stack.c
- . isolate os specific flags in m- files
-
-If further development is planed on it is should solve the following problems :
-
- . Encapsulate DESC & OTHER tests in a macro call. I'm not aware
- of their exact semantics.
- . Clean up the seg_N_TYPE N_TYPE_seg naming scheme
- . Try to remove as much reference to segment dependent names as possible
- . Find a cleaner solution for symbol_new.
- . Report the modifications on vax, ns32k, sparc machine dependent files.
- To acheive this goal, search for \<N_, sy_, symbol_new and symbolS.
- . Allow an arbitrary number of segments (spare sections .ctor .dtor .bletch)
- . Find a way to extend the debug information without breaking sdb
- compatibility. Mainly intended for G++.
- . should it do something to generate shared libraries objects ?
-
-I have tested this code on the following processor/os. gcc-1.37.1 was
- used for all the tests.
-
-386 SCO unix ODT
- gcc-1.37.1, gas, emacs-18.55
-
-386 Esix rev C
- gas-1.37/write.s
-
-386 Ix 2.02
- gas, all the X11R4 mit clients
-
-386 CTIX 3.2
- xsol (X11R4 solitary game), gas
-
-68030 unisoft 1.3
- the kernel (V.3.2) + tcp/ip extensions
- bash-1.05, bison-1.11, compress-4.0, cproto, shar-3.49, diff-1.14,
- dist-18.55, flex-2.3, gas-1.37, gcc-1.37.1, gdb-3.6, grep-1.5,
- kermit, make-3.58, makedep, patch, printf, makeinfo, g++-1.37.1,
- tar-1.08, texi2roff, uuencode, uutraf-1.2, libg++-1.37.2, groff-0.5
-
-68020 sunos 3.5 (no, not coff, just to be sure that I didn't
- introduce errors)
- gcc-1.37.1, gas, emacs-18.55, gdb-3.6, bison-1.11, diff-1.14,
- make-3.58, tar-1.08
-
-68030 sunos 4.0.3 (idem)
- gas
-
-I would be glad to hear about new experiences
-
- Loic (loic@adesign.uucp or loic@afp.uucp)
-
diff --git a/gnu/usr.bin/as/README.pic b/gnu/usr.bin/as/README.pic
deleted file mode 100644
index adde6fe..0000000
--- a/gnu/usr.bin/as/README.pic
+++ /dev/null
@@ -1,25 +0,0 @@
-A few short notes on PIC support.
-
-. References to the symbol "_GLOBAL_OFFSET_TABLE_" are special. These always
- PC relative to the start of the current instruction. Also, they occur
- in "complex" expressions in function prologs, eg.
-
- move _GLOBAL_OFFSET_TABLE_ + (. - L1 ), %some_register
-
- The expression parser can't handle these generically, so the expression
- above is recognised as a special case.
-
-. Some archs have special PIC assembler syntax to reference static and global
- data. This is handled in targ-cpu.c.
-
-. Correct relocation_info must be output (eg. fields r_jmptable and r_baserel).
-
-. Internal labels must be output in the symbol table if they are referred to
- by PIC instructions. The linker must allocate a GOT slot for them.
-
-. The former meaning of the -k switch ("WORKING_DOT" stuff), has been nuked
- in favour of enabling PIC code recognition.
-
-
--pk
-
diff --git a/gnu/usr.bin/as/README.rich b/gnu/usr.bin/as/README.rich
deleted file mode 100644
index 5a2ecc4..0000000
--- a/gnu/usr.bin/as/README.rich
+++ /dev/null
@@ -1,144 +0,0 @@
-(This file is under construction.)
-
-
- The Code Pedigree of This Directory
-
-
-This directory contains a big merge of several development lines of
-gas as well as a few bug fixes and some configuration that I've added
-in order to retain my own sanity.
-
-A little history.
-
-The only common baseline of all versions was gas-1.31.
-
-From 1.31, Intel branched off and added:
-
- support for the Intel 80960 (i960) processor.
- support for b.out object files.
- some bug fixes.
- sloppy mac MPW support
- Intel gnu/960 makefiles and version numbering.
-
-Many of the bug fixes found their way into the main development line
-prior to 1.36. ALL intel changes were ifdef'd I80960. This was good
-as it isolated the changes, but bad in that it connected the b.out
-support to the i960 support, and bad in that the bug fixes were only
-active in the i960+b.out executables of gas, (although most of these
-were nicely marked with comments indicating that they were probably
-general bug fixes.)
-
-To pick up the main FSF development line again, along the way to 1.36,
-several new processors were added, many bugs fixed, and the world was
-a somewhat better place in general.
-
-From gas-1.36, Loic at Axis Design (france!) encapsulated object
-format specific actions, added coff versions of those encapsulations,
-and a config.gas style configuration and Makefile. This was a big
-change and a lot of work.
-
-Then along came the FIRST FSF release of gas-1.37. I say this because
-there have been at least two releases of gas-1.37. Only two of them
-do we care about for this story, so let's call them gas-1.37.1 and
-gas-1.37.2.
-
-Here starts the confusion. Firstly, gas-1.37.1 did not compile.
-
-In the meantime, John Gilmore at Cygnus Support had been hacking
-gas-1.37.1. He got it to compile. He added support for the AMD 29000
-processor. AND he started encapsulating some of the a.out specific
-pieces of code mostly into functions. AND he rebuilt the relocation
-info to be generic. AND he restructured somewhat so that for a single
-host, cross assemblers could be built for all targets in the same
-directory. Useful work but a considerable nuisance because the a29k
-changes were not partitioned from the encapsulation changes, the
-encapsulation changes were incomplete, and the encapsulation required
-functions where alternate structuring might have used macros. Let's
-call this version gas-1.37.1+a29k.
-
-By the time gas-1.37.2 was "released", (remember that it TOO was
-labelled by FSF as gas-1.37), it compiled, but it also added i860
-support and ansi style const declarations.
-
-At this point, Loic rolled his changes into gas-1.37.2.
-
-What I've done.
-
-I collected all the stray versions of gas that sounded relevant to my
-goals of cross assembly and alternate object file formats and the FSF
-releases from which the stray versions had branched.
-
-I rolled the Intel i960 changes from 1.31 into versions that I call
-1.34+i960, 1.36+i960, and then 1.37.1+i960.
-
-Then I merged 1.37.1+i960 with 1.37.1+a29k to produce what I call
-1.37.1+i960+a29k or 1.37.3.
-
-From 1.37.3, I pulled in Loic's stuff. This wasn't easy as Loic's
-stuff hit all the same points as John's encapsulations. Loic's goal
-was to split the a.out from coff dependancies for native assembly on
-coff, while John's was to split for multiple cross assembly from a
-single host.
-
-Loic's config arranged files much like emacs into m-*, etc. I've
-rearranged these somewhat.
-
-Theory:
-
-The goal of the new configuration scheme is to bury all object format,
-target processor, and host machine dependancies in object, target, and
-host specific files. That is, to move all #ifdef's out of the gas
-common code.
-
-Here's how it works. There is a .h and a .c file for each object file
-format, a .h and a .c file for each target processor, and a .h for
-each host. config.gas creates {sym}links in the current directory to
-the appropriate files in the config directory. config.gas also serves
-as a list of triplets {host, target, object-format} that have been
-tested at one time or another. I also recommend that config.gas be
-used to document triplet specific notes as to purpose of the triplet,
-etc.
-
-Implementation:
-
-host.h is a {sym}link to .../config/xm-yourhost.h. It is intended to
-be used to hide host compiler, system header file, and system library
-differences between host machines. If your host needs actual c source
-files, then either: these are generally useful functions, in which
-case you should probably build a local library outside of the gas
-source tree, or someone, perhaps me, is confused about what is needed
-by different hosts.
-
-obj-format.h is a {sym}link to .../config/obj-something.h. It is intended
-
-All gas .c files include as.h.
-
-as.h #define's "gas", includes host.h, defines a number of gas
-specific structures and types, and then includes tp.h, obj.h, and
-target-environment.h.
-
-target-environment.h defines a target environment specific
-preprocessor flag, eg, TE_SUN, and then includes obj-format.h.
-
-obj-format.h defines an object format specific preprocessor flag, eg,
-OBJ_AOUT, OBJ_BOUT, OBJ_COFF, includes "target-processor.h", and then
-defines the object specific macros, functions, types, and structures.
-
-target-processor.h
-
-target-processor.
-
-Porting:
-
-There appear to be four major types of ports; new hosts, new target
-processors, new object file formats, and new target environments.
-
-
------
-
-reloc now stored internally as generic. (symbols too?) (segment types
-vs. names?)
-
-I don't mean to overlook anyone here. There have also been several
-other development lines here that I looked at and elected to bypass.
-Specifically, xxx's stabs in coff stuff was particularly tempting.
diff --git a/gnu/usr.bin/as/VERSION b/gnu/usr.bin/as/VERSION
deleted file mode 100644
index a3f79bb..0000000
--- a/gnu/usr.bin/as/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-1.92.3
diff --git a/gnu/usr.bin/as/app.c b/gnu/usr.bin/as/app.c
deleted file mode 100644
index 04a5e6c..0000000
--- a/gnu/usr.bin/as/app.c
+++ /dev/null
@@ -1,746 +0,0 @@
-/* This is the Assembler Pre-Processor
- Copyright (C) 1987, 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Modified by Allen Wirfs-Brock, Instantiations Inc 2/90 */
-/* App, the assembler pre-processor. This pre-processor strips out excess
- spaces, turns single-quoted characters into a decimal constant, and turns
- # <number> <filename> <garbage> into a .line <number>\n.file <filename>
- pair. This needs better error-handling. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include <stdio.h>
-#include "as.h" /* For BAD_CASE() only */
-
-#if (__STDC__ != 1)
-#ifndef const
-#define const /* empty */
-#endif
-#endif
-
-static char lex[256];
-static const char symbol_chars[] =
-"$._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-
-#define LEX_IS_SYMBOL_COMPONENT 1
-#define LEX_IS_WHITESPACE 2
-#define LEX_IS_LINE_SEPARATOR 3
-#define LEX_IS_COMMENT_START 4
-#define LEX_IS_LINE_COMMENT_START 5
-#define LEX_IS_TWOCHAR_COMMENT_1ST 6
-#define LEX_IS_TWOCHAR_COMMENT_2ND 7
-#define LEX_IS_STRINGQUOTE 8
-#define LEX_IS_COLON 9
-#define LEX_IS_NEWLINE 10
-#define LEX_IS_ONECHAR_QUOTE 11
-#define IS_SYMBOL_COMPONENT(c) (lex[c] == LEX_IS_SYMBOL_COMPONENT)
-#define IS_WHITESPACE(c) (lex[c] == LEX_IS_WHITESPACE)
-#define IS_LINE_SEPARATOR(c) (lex[c] == LEX_IS_LINE_SEPARATOR)
-#define IS_COMMENT(c) (lex[c] == LEX_IS_COMMENT_START)
-#define IS_LINE_COMMENT(c) (lex[c] == LEX_IS_LINE_COMMENT_START)
-#define IS_NEWLINE(c) (lex[c] == LEX_IS_NEWLINE)
-
-static int process_escape PARAMS ((int));
-
-/* FIXME-soon: The entire lexer/parser thingy should be
- built statically at compile time rather than dynamically
- each and every time the assembler is run. xoxorich. */
-
-void
-do_scrub_begin ()
-{
- const char *p;
-
- lex[' '] = LEX_IS_WHITESPACE;
- lex['\t'] = LEX_IS_WHITESPACE;
- lex['\n'] = LEX_IS_NEWLINE;
- lex[';'] = LEX_IS_LINE_SEPARATOR;
- lex['"'] = LEX_IS_STRINGQUOTE;
-#ifndef TC_HPPA
- lex['\''] = LEX_IS_ONECHAR_QUOTE;
-#endif
- lex[':'] = LEX_IS_COLON;
-
-
-
-#ifdef SINGLE_QUOTE_STRINGS
- lex['\''] = LEX_IS_STRINGQUOTE;
-#endif
-
- /* Note that these override the previous defaults, e.g. if ';' is a
- comment char, then it isn't a line separator. */
- for (p = symbol_chars; *p; ++p)
- {
- lex[(unsigned char) *p] = LEX_IS_SYMBOL_COMPONENT;
- } /* declare symbol characters */
-
- for (p = comment_chars; *p; p++)
- {
- lex[(unsigned char) *p] = LEX_IS_COMMENT_START;
- } /* declare comment chars */
-
- for (p = line_comment_chars; *p; p++)
- {
- lex[(unsigned char) *p] = LEX_IS_LINE_COMMENT_START;
- } /* declare line comment chars */
-
- for (p = line_separator_chars; *p; p++)
- {
- lex[(unsigned char) *p] = LEX_IS_LINE_SEPARATOR;
- } /* declare line separators */
-
- /* Only allow slash-star comments if slash is not in use */
- if (lex['/'] == 0)
- {
- lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST;
- }
- /* FIXME-soon. This is a bad hack but otherwise, we can't do
- c-style comments when '/' is a line comment char. xoxorich. */
- if (lex['*'] == 0)
- {
- lex['*'] = LEX_IS_TWOCHAR_COMMENT_2ND;
- }
-} /* do_scrub_begin() */
-
-FILE *scrub_file;
-
-int
-scrub_from_file ()
-{
- return getc (scrub_file);
-}
-
-void
-scrub_to_file (ch)
- int ch;
-{
- ungetc (ch, scrub_file);
-} /* scrub_to_file() */
-
-char *scrub_string;
-char *scrub_last_string;
-
-int
-scrub_from_string ()
-{
- return scrub_string == scrub_last_string ? EOF : *scrub_string++;
-} /* scrub_from_string() */
-
-void
-scrub_to_string (ch)
- int ch;
-{
- *--scrub_string = ch;
-} /* scrub_to_string() */
-
-/* Saved state of the scrubber */
-static int state;
-static int old_state;
-static char *out_string;
-static char out_buf[20];
-static int add_newlines = 0;
-
-/* Data structure for saving the state of app across #include's. Note that
- app is called asynchronously to the parsing of the .include's, so our
- state at the time .include is interpreted is completely unrelated.
- That's why we have to save it all. */
-
-struct app_save
- {
- int state;
- int old_state;
- char *out_string;
- char out_buf[sizeof (out_buf)];
- int add_newlines;
- char *scrub_string;
- char *scrub_last_string;
- FILE *scrub_file;
- };
-
-char *
-app_push ()
-{
- register struct app_save *saved;
-
- saved = (struct app_save *) xmalloc (sizeof (*saved));
- saved->state = state;
- saved->old_state = old_state;
- saved->out_string = out_string;
- memcpy (saved->out_buf, out_buf, sizeof (out_buf));
- saved->add_newlines = add_newlines;
- saved->scrub_string = scrub_string;
- saved->scrub_last_string = scrub_last_string;
- saved->scrub_file = scrub_file;
-
- /* do_scrub_begin() is not useful, just wastes time. */
- return (char *) saved;
-}
-
-void
-app_pop (arg)
- char *arg;
-{
- register struct app_save *saved = (struct app_save *) arg;
-
- /* There is no do_scrub_end (). */
- state = saved->state;
- old_state = saved->old_state;
- out_string = saved->out_string;
- memcpy (out_buf, saved->out_buf, sizeof (out_buf));
- add_newlines = saved->add_newlines;
- scrub_string = saved->scrub_string;
- scrub_last_string = saved->scrub_last_string;
- scrub_file = saved->scrub_file;
-
- free (arg);
-} /* app_pop() */
-
-/* @@ This assumes that \n &c are the same on host and target. This is not
- necessarily true. */
-static int
-process_escape (ch)
- int ch;
-{
- switch (ch)
- {
- case 'b':
- return '\b';
- case 'f':
- return '\f';
- case 'n':
- return '\n';
- case 'r':
- return '\r';
- case 't':
- return '\t';
- case '\'':
- return '\'';
- case '"':
- return '\"';
- default:
- return ch;
- }
-}
-int
-do_scrub_next_char (get, unget)
- int (*get) ();
- void (*unget) ();
-{
- /*State 0: beginning of normal line
- 1: After first whitespace on line (flush more white)
- 2: After first non-white (opcode) on line (keep 1white)
- 3: after second white on line (into operands) (flush white)
- 4: after putting out a .line, put out digits
- 5: parsing a string, then go to old-state
- 6: putting out \ escape in a "d string.
- 7: After putting out a .appfile, put out string.
- 8: After putting out a .appfile string, flush until newline.
- 9: After seeing symbol char in state 3 (keep 1white after symchar)
- 10: After seeing whitespace in state 9 (keep white before symchar)
- 11: After seeing a symbol character in state 0 (eg a label definition)
- -1: output string in out_string and go to the state in old_state
- -2: flush text until a '*' '/' is seen, then go to state old_state
- */
-
- /* I added states 9 and 10 because the MIPS ECOFF assembler uses
- constructs like ``.loc 1 20''. This was turning into ``.loc
- 120''. States 9 and 10 ensure that a space is never dropped in
- between characters which could appear in a identifier. Ian
- Taylor, ian@cygnus.com.
-
- I added state 11 so that something like "Lfoo add %r25,%r26,%r27" works
- correctly on the PA (and any other target where colons are optional).
- Jeff Law, law@cs.utah.edu. */
-
- register int ch, ch2 = 0;
- int not_cpp_line = 0;
-
- switch (state)
- {
- case -1:
- ch = *out_string++;
- if (*out_string == 0)
- {
- state = old_state;
- old_state = 3;
- }
- return ch;
-
- case -2:
- for (;;)
- {
- do
- {
- ch = (*get) ();
- }
- while (ch != EOF && ch != '\n' && ch != '*');
- if (ch == '\n' || ch == EOF)
- return ch;
-
- /* At this point, ch must be a '*' */
- while ((ch = (*get) ()) == '*')
- {
- ;
- }
- if (ch == EOF || ch == '/')
- break;
- (*unget) (ch);
- }
- state = old_state;
- return ' ';
-
- case 4:
- ch = (*get) ();
- if (ch == EOF || (ch >= '0' && ch <= '9'))
- return ch;
- else
- {
- while (ch != EOF && IS_WHITESPACE (ch))
- ch = (*get) ();
- if (ch == '"')
- {
- (*unget) (ch);
- out_string = "\n\t.appfile ";
- old_state = 7;
- state = -1;
- return *out_string++;
- }
- else
- {
- while (ch != EOF && ch != '\n')
- ch = (*get) ();
- state = 0;
- return ch;
- }
- }
-
- case 5:
- ch = (*get) ();
- if (lex[ch] == LEX_IS_STRINGQUOTE)
- {
- state = old_state;
- return ch;
- }
-#ifndef NO_STRING_ESCAPES
- else if (ch == '\\')
- {
- state = 6;
- return ch;
- }
-#endif
- else if (ch == EOF)
- {
- as_warn ("End of file in string: inserted '\"'");
- state = old_state;
- (*unget) ('\n');
- return '"';
- }
- else
- {
- return ch;
- }
-
- case 6:
- state = 5;
- ch = (*get) ();
- switch (ch)
- {
- /* Handle strings broken across lines, by turning '\n' into
- '\\' and 'n'. */
- case '\n':
- (*unget) ('n');
- add_newlines++;
- return '\\';
-
- case '"':
- case '\\':
- case 'b':
- case 'f':
- case 'n':
- case 'r':
- case 't':
-#ifdef BACKSLASH_V
- case 'v':
-#endif /* BACKSLASH_V */
- case 'x':
- case 'X':
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- break;
-#if defined(IGNORE_NONSTANDARD_ESCAPES) | defined(ONLY_STANDARD_ESCAPES)
- default:
- as_warn ("Unknown escape '\\%c' in string: Ignored", ch);
- break;
-#else /* ONLY_STANDARD_ESCAPES */
- default:
- /* Accept \x as x for any x */
- break;
-#endif /* ONLY_STANDARD_ESCAPES */
-
- case EOF:
- as_warn ("End of file in string: '\"' inserted");
- return '"';
- }
- return ch;
-
- case 7:
- ch = (*get) ();
- state = 5;
- old_state = 8;
- return ch;
-
- case 8:
- do
- ch = (*get) ();
- while (ch != '\n');
- state = 0;
- return ch;
- }
-
- /* OK, we are somewhere in states 0 through 4 or 9 through 11 */
-
- /* flushchar: */
- ch = (*get) ();
-recycle:
- if (ch == EOF)
- {
- if (state != 0)
- as_warn ("End of file not at end of a line: Newline inserted.");
- return ch;
- }
-
- switch (lex[ch])
- {
- case LEX_IS_WHITESPACE:
- do
- /* Preserve a single whitespace character at the beginning of
- a line. */
- if (state == 0)
- {
- state = 1;
- return ch;
- }
- else
- ch = (*get) ();
- while (ch != EOF && IS_WHITESPACE (ch));
- if (ch == EOF)
- return ch;
-
- if (IS_COMMENT (ch)
- || (state == 0 && IS_LINE_COMMENT (ch))
- || ch == '/'
- || IS_LINE_SEPARATOR (ch))
- {
- /* cpp never outputs a leading space before the #, so try to
- avoid being confused. */
- not_cpp_line = 1;
- goto recycle;
- }
-#ifdef MRI
- (*unget) (ch); /* Put back */
- return ' '; /* Always return one space at start of line */
-#endif
-
- /* If we're in state 2 or 11, we've seen a non-white character
- followed by whitespace. If the next character is ':', this
- is whitespace after a label name which we *must* ignore. */
- if ((state == 2 || state == 11) && lex[ch] == LEX_IS_COLON)
- {
- state = 1;
- return ch;
- }
-
- switch (state)
- {
- case 0:
- state++;
- goto recycle; /* Punted leading sp */
- case 1:
- /* We can arrive here if we leave a leading whitespace character
- at the beginning of a line. */
- goto recycle;
- case 2:
- state = 3;
- (*unget) (ch);
- return ' '; /* Sp after opco */
- case 3:
- goto recycle; /* Sp in operands */
- case 9:
- case 10:
- state = 10; /* Sp after symbol char */
- goto recycle;
- case 11:
- state = 1;
- (*unget) (ch);
- return ' '; /* Sp after label definition. */
- default:
- BAD_CASE (state);
- }
- break;
-
- case LEX_IS_TWOCHAR_COMMENT_1ST:
- ch2 = (*get) ();
- if (ch2 != EOF && lex[ch2] == LEX_IS_TWOCHAR_COMMENT_2ND)
- {
- for (;;)
- {
- do
- {
- ch2 = (*get) ();
- if (ch2 != EOF && IS_NEWLINE (ch2))
- add_newlines++;
- }
- while (ch2 != EOF &&
- (lex[ch2] != LEX_IS_TWOCHAR_COMMENT_2ND));
-
- while (ch2 != EOF &&
- (lex[ch2] == LEX_IS_TWOCHAR_COMMENT_2ND))
- {
- ch2 = (*get) ();
- }
-
- if (ch2 == EOF
- || lex[ch2] == LEX_IS_TWOCHAR_COMMENT_1ST)
- break;
- (*unget) (ch);
- }
- if (ch2 == EOF)
- as_warn ("End of file in multiline comment");
-
- ch = ' ';
- goto recycle;
- }
- else
- {
- if (ch2 != EOF)
- (*unget) (ch2);
- if (state == 9 || state == 10)
- state = 3;
- return ch;
- }
- break;
-
- case LEX_IS_STRINGQUOTE:
- if (state == 9 || state == 10)
- old_state = 3;
- else
- old_state = state;
- state = 5;
- return ch;
-#ifndef MRI
-#ifndef IEEE_STYLE
- case LEX_IS_ONECHAR_QUOTE:
- ch = (*get) ();
- if (ch == EOF)
- {
- as_warn ("End-of-file after a one-character quote; \\000 inserted");
- ch = 0;
- }
- if (ch == '\\')
- {
- ch = (*get) ();
- ch = process_escape (ch);
- }
- sprintf (out_buf, "%d", (int) (unsigned char) ch);
-
-
- /* None of these 'x constants for us. We want 'x'. */
- if ((ch = (*get) ()) != '\'')
- {
-#ifdef REQUIRE_CHAR_CLOSE_QUOTE
- as_warn ("Missing close quote: (assumed)");
-#else
- (*unget) (ch);
-#endif
- }
- if (strlen (out_buf) == 1)
- {
- return out_buf[0];
- }
- if (state == 9 || state == 10)
- old_state = 3;
- else
- old_state = state;
- state = -1;
- out_string = out_buf;
- return *out_string++;
-#endif
-#endif
- case LEX_IS_COLON:
- if (state == 9 || state == 10)
- state = 3;
- else if (state != 3)
- state = 1;
- return ch;
-
- case LEX_IS_NEWLINE:
- /* Roll out a bunch of newlines from inside comments, etc. */
- if (add_newlines)
- {
- --add_newlines;
- (*unget) (ch);
- }
- /* fall thru into... */
-
- case LEX_IS_LINE_SEPARATOR:
- state = 0;
- return ch;
-
- case LEX_IS_LINE_COMMENT_START:
- if (state == 0) /* Only comment at start of line. */
- {
- /* FIXME-someday: The two character comment stuff was badly
- thought out. On i386, we want '/' as line comment start
- AND we want C style comments. hence this hack. The
- whole lexical process should be reworked. xoxorich. */
- if (ch == '/')
- {
- ch2 = (*get) ();
- if (ch2 == '*')
- {
- state = -2;
- return (do_scrub_next_char (get, unget));
- }
- else
- {
- (*unget) (ch2);
- }
- } /* bad hack */
-
- if (ch != '#')
- not_cpp_line = 1;
-
- do
- ch = (*get) ();
- while (ch != EOF && IS_WHITESPACE (ch));
- if (ch == EOF)
- {
- as_warn ("EOF in comment: Newline inserted");
- return '\n';
- }
- if (ch < '0' || ch > '9' || not_cpp_line)
- {
- /* Non-numerics: Eat whole comment line */
- while (ch != EOF && !IS_NEWLINE (ch))
- ch = (*get) ();
- if (ch == EOF)
- as_warn ("EOF in Comment: Newline inserted");
- state = 0;
- return '\n';
- }
- /* Numerics begin comment. Perhaps CPP `# 123 "filename"' */
- (*unget) (ch);
- old_state = 4;
- state = -1;
- out_string = "\t.appline ";
- return *out_string++;
- }
-
- /* We have a line comment character which is not at the start of
- a line. If this is also a normal comment character, fall
- through. Otherwise treat it as a default character. */
- if (strchr (comment_chars, ch) == NULL)
- goto de_fault;
- /* Fall through. */
- case LEX_IS_COMMENT_START:
- do
- ch = (*get) ();
- while (ch != EOF && !IS_NEWLINE (ch));
- if (ch == EOF)
- as_warn ("EOF in comment: Newline inserted");
- state = 0;
- return '\n';
-
- case LEX_IS_SYMBOL_COMPONENT:
- if (state == 10)
- {
- /* This is a symbol character following another symbol
- character, with whitespace in between. We skipped the
- whitespace earlier, so output it now. */
- (*unget) (ch);
- state = 3;
- return ' ';
- }
- if (state == 3)
- state = 9;
- /* Fall through. */
- default:
- de_fault:
- /* Some relatively `normal' character. */
- if (state == 0)
- {
- state = 11; /* Now seeing label definition */
- return ch;
- }
- else if (state == 1)
- {
- state = 2; /* Ditto */
- return ch;
- }
- else if (state == 9)
- {
- if (lex[ch] != LEX_IS_SYMBOL_COMPONENT)
- state = 3;
- return ch;
- }
- else if (state == 10)
- {
- state = 3;
- return ch;
- }
- else
- {
- return ch; /* Opcode or operands already */
- }
- }
- return -1;
-}
-
-#ifdef TEST
-
-const char comment_chars[] = "|";
-const char line_comment_chars[] = "#";
-
-main ()
-{
- int ch;
-
- app_begin ();
- while ((ch = do_scrub_next_char (stdin)) != EOF)
- putc (ch, stdout);
-}
-
-as_warn (str)
- char *str;
-{
- fputs (str, stderr);
- putc ('\n', stderr);
-}
-
-#endif
-
-/* end of app.c */
diff --git a/gnu/usr.bin/as/as.1 b/gnu/usr.bin/as/as.1
deleted file mode 100644
index e1cb4cb..0000000
--- a/gnu/usr.bin/as/as.1
+++ /dev/null
@@ -1,283 +0,0 @@
-.\" Copyright (c) 1991, 1992 Free Software Foundation
-.\" See section COPYING for conditions for redistribution
-.\" $Id$
-.TH as 1 "21 January 1992" "cygnus support" "GNU Development Tools"
-
-.SH NAME
-as \- the portable GNU assembler.
-
-.SH SYNOPSIS
-.na
-.B as
-.RB "[\|" \-a "\||\|" \-al "\||\|" -as\c
-\&\|]
-.RB "[\|" \-D "\|]"
-.RB "[\|" \-f "\|]"
-.RB "[\|" \-I
-.I path\c
-\&\|]
-.RB "[\|" \-k "\|]"
-.RB "[\|" \-K "\|]"
-.RB "[\|" \-L "\|]"
-.RB "[\|" \-o
-.I objfile\c
-\&\|]
-.RB "[\|" \-R "\|]"
-.RB "[\|" \-v "\|]"
-.RB "[\|" \-w "\|]"
-.RB "[\|" \-\^\- "\ |\ " \c
-.I files\c
-\&\|.\|.\|.\|]
-
-.I i960-only options:
-.br
-.RB "[\|" \-ACA "\||\|" \-ACA_A "\||\|" \-ACB\c
-.RB "\||\|" \-ACC "\||\|" \-AKA "\||\|" \-AKB\c
-.RB "\||\|" \-AKC "\||\|" \-AMC "\|]"
-.RB "[\|" \-b "\|]"
-.RB "[\|" \-norelax "\|]"
-
-.I m680x0-only options:
-.br
-.RB "[\|" \-l "\|]"
-.RB "[\|" \-mc68000 "\||\|" \-mc68010 "\||\|" \-mc68020 "\|]"
-.ad b
-
-.SH DESCRIPTION
-GNU \c
-.B as\c
-\& is really a family of assemblers.
-If you use (or have used) the GNU assembler on one architecture, you
-should find a fairly similar environment when you use it on another
-architecture. Each version has much in common with the others,
-including object file formats, most assembler directives (often called
-\c
-.I pseudo-ops)\c
-\& and assembler syntax.
-
-For information on the syntax and pseudo-ops used by GNU \c
-.B as\c
-\&, see `\|\c
-.B as\c
-\|' entry in \c
-.B info \c
-(or the manual \c
-.I
-.I
-Using as: The GNU Assembler\c
-\&).
-
-\c
-.B as\c
-\& is primarily intended to assemble the output of the GNU C
-compiler \c
-.B gcc\c
-\& for use by the linker \c
-.B ld\c
-\&. Nevertheless,
-we've tried to make \c
-.B as\c
-\& assemble correctly everything that the native
-assembler would.
-This doesn't mean \c
-.B as\c
-\& always uses the same syntax as another
-assembler for the same architecture; for example, we know of several
-incompatible versions of 680x0 assembly language syntax.
-
-Each time you run \c
-.B as\c
-\& it assembles exactly one source
-program. The source program is made up of one or more files.
-(The standard input is also a file.)
-
-If \c
-.B as\c
-\& is given no file names it attempts to read one input file
-from the \c
-.B as\c
-\& standard input, which is normally your terminal. You
-may have to type \c
-.B ctl-D\c
-\& to tell \c
-.B as\c
-\& there is no more program
-to assemble. Use `\|\c
-.B \-\^\-\c
-\|' if you need to explicitly name the standard input file
-in your command line.
-
-.B as\c
-\& may write warnings and error messages to the standard error
-file (usually your terminal). This should not happen when \c
-.B as\c
-\& is
-run automatically by a compiler. Warnings report an assumption made so
-that \c
-.B as\c
-\& could keep assembling a flawed program; errors report a
-grave problem that stops the assembly.
-
-.SH OPTIONS
-.TP
-.BR \-a \||\| \-al \||\| \-as
-Turn on assembly listings; `\|\c
-.B \-al\c
-\&\|', listing only, `\|\c
-.B \-as\c
-\&\|', symbols
-only, `\|\c
-.B \-a\c
-\&\|', everything.
-.TP
-.B \-D
-This option is accepted only for script compatibility with calls to
-other assemblers; it has no effect on \c
-.B as\c
-\&.
-.TP
-.B \-f
-``fast''--skip preprocessing (assume source is compiler output).
-.TP
-.BI "\-I\ " path
-Add
-.I path
-to the search list for
-.B .include
-directives.
-.TP
-.B \-k
-Handle position independent code, generated by gcc -fpic.
-.TP
-.B \-K
-Handle position independent code, generated by gcc -fPIC.
-This is normally the same as -k.
-.TP
-.B \-L
-Keep (in symbol table) local symbols, starting with `\|\c
-.B L\c
-\|'
-.TP
-.BI "\-o\ " objfile
-Name the object-file output from \c
-.B as
-.TP
-.B \-R
-Fold data section into text section
-.TP
-.B \-v
-Announce \c
-.B as\c
-\& version
-.TP
-.B \-W
-Suppress warning messages
-.TP
-.IR "\-\^\-" "\ |\ " "files\|.\|.\|."
-Source files to assemble, or standard input (\c
-.BR "\-\^\-" ")"
-.TP
-.BI \-A var
-.I
-(When configured for Intel 960.)
-Specify which variant of the 960 architecture is the target.
-.TP
-.B \-b
-.I
-(When configured for Intel 960.)
-Add code to collect statistics about branches taken.
-.TP
-.B \-norelax
-.I
-(When configured for Intel 960.)
-Do not alter compare-and-branch instructions for long displacements;
-error if necessary.
-.TP
-.B \-l
-.I
-(When configured for Motorola 68000).
-.br
-Shorten references to undefined symbols, to one word instead of two.
-.TP
-.BR "\-mc68000" "\||\|" "\-mc68010" "\||\|" "\-mc68020"
-.I
-(When configured for Motorola 68000).
-.br
-Specify what processor in the 68000 family is the target (default 68020)
-
-.PP
-Options may be in any order, and may be
-before, after, or between file names. The order of file names is
-significant.
-
-`\|\c
-.B \-\^\-\c
-\|' (two hyphens) by itself names the standard input file
-explicitly, as one of the files for \c
-.B as\c
-\& to assemble.
-
-Except for `\|\c
-.B \-\^\-\c
-\|' any command line argument that begins with a
-hyphen (`\|\c
-.B \-\c
-\|') is an option. Each option changes the behavior of
-\c
-.B as\c
-\&. No option changes the way another option works. An
-option is a `\|\c
-.B \-\c
-\|' followed by one or more letters; the case of
-the letter is important. All options are optional.
-
-The `\|\c
-.B \-o\c
-\|' option expects exactly one file name to follow. The file
-name may either immediately follow the option's letter (compatible
-with older assemblers) or it may be the next command argument (GNU
-standard).
-
-These two command lines are equivalent:
-.br
-.B
-as\ \ \-o\ \ my\-object\-file.o\ \ mumble.s
-.br
-.B
-as\ \ \-omy\-object\-file.o\ \ mumble.s
-
-.SH "SEE ALSO"
-.RB "`\|" as "\|'"
-entry in
-.B
-info\c
-\&;
-.I
-Using as: The GNU Assembler\c
-\&;
-.BR gcc "(" 1 "),"
-.BR ld "(" 1 ")."
-
-.SH HISTORY
-A
-.I as
-command appeared in
-Version 1 AT&T UNIX.
-
-.SH COPYING
-Copyright (c) 1991, 1992 Free Software Foundation, Inc.
-.PP
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-.PP
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-.PP
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
diff --git a/gnu/usr.bin/as/as.1aout b/gnu/usr.bin/as/as.1aout
deleted file mode 100644
index e1cb4cb..0000000
--- a/gnu/usr.bin/as/as.1aout
+++ /dev/null
@@ -1,283 +0,0 @@
-.\" Copyright (c) 1991, 1992 Free Software Foundation
-.\" See section COPYING for conditions for redistribution
-.\" $Id$
-.TH as 1 "21 January 1992" "cygnus support" "GNU Development Tools"
-
-.SH NAME
-as \- the portable GNU assembler.
-
-.SH SYNOPSIS
-.na
-.B as
-.RB "[\|" \-a "\||\|" \-al "\||\|" -as\c
-\&\|]
-.RB "[\|" \-D "\|]"
-.RB "[\|" \-f "\|]"
-.RB "[\|" \-I
-.I path\c
-\&\|]
-.RB "[\|" \-k "\|]"
-.RB "[\|" \-K "\|]"
-.RB "[\|" \-L "\|]"
-.RB "[\|" \-o
-.I objfile\c
-\&\|]
-.RB "[\|" \-R "\|]"
-.RB "[\|" \-v "\|]"
-.RB "[\|" \-w "\|]"
-.RB "[\|" \-\^\- "\ |\ " \c
-.I files\c
-\&\|.\|.\|.\|]
-
-.I i960-only options:
-.br
-.RB "[\|" \-ACA "\||\|" \-ACA_A "\||\|" \-ACB\c
-.RB "\||\|" \-ACC "\||\|" \-AKA "\||\|" \-AKB\c
-.RB "\||\|" \-AKC "\||\|" \-AMC "\|]"
-.RB "[\|" \-b "\|]"
-.RB "[\|" \-norelax "\|]"
-
-.I m680x0-only options:
-.br
-.RB "[\|" \-l "\|]"
-.RB "[\|" \-mc68000 "\||\|" \-mc68010 "\||\|" \-mc68020 "\|]"
-.ad b
-
-.SH DESCRIPTION
-GNU \c
-.B as\c
-\& is really a family of assemblers.
-If you use (or have used) the GNU assembler on one architecture, you
-should find a fairly similar environment when you use it on another
-architecture. Each version has much in common with the others,
-including object file formats, most assembler directives (often called
-\c
-.I pseudo-ops)\c
-\& and assembler syntax.
-
-For information on the syntax and pseudo-ops used by GNU \c
-.B as\c
-\&, see `\|\c
-.B as\c
-\|' entry in \c
-.B info \c
-(or the manual \c
-.I
-.I
-Using as: The GNU Assembler\c
-\&).
-
-\c
-.B as\c
-\& is primarily intended to assemble the output of the GNU C
-compiler \c
-.B gcc\c
-\& for use by the linker \c
-.B ld\c
-\&. Nevertheless,
-we've tried to make \c
-.B as\c
-\& assemble correctly everything that the native
-assembler would.
-This doesn't mean \c
-.B as\c
-\& always uses the same syntax as another
-assembler for the same architecture; for example, we know of several
-incompatible versions of 680x0 assembly language syntax.
-
-Each time you run \c
-.B as\c
-\& it assembles exactly one source
-program. The source program is made up of one or more files.
-(The standard input is also a file.)
-
-If \c
-.B as\c
-\& is given no file names it attempts to read one input file
-from the \c
-.B as\c
-\& standard input, which is normally your terminal. You
-may have to type \c
-.B ctl-D\c
-\& to tell \c
-.B as\c
-\& there is no more program
-to assemble. Use `\|\c
-.B \-\^\-\c
-\|' if you need to explicitly name the standard input file
-in your command line.
-
-.B as\c
-\& may write warnings and error messages to the standard error
-file (usually your terminal). This should not happen when \c
-.B as\c
-\& is
-run automatically by a compiler. Warnings report an assumption made so
-that \c
-.B as\c
-\& could keep assembling a flawed program; errors report a
-grave problem that stops the assembly.
-
-.SH OPTIONS
-.TP
-.BR \-a \||\| \-al \||\| \-as
-Turn on assembly listings; `\|\c
-.B \-al\c
-\&\|', listing only, `\|\c
-.B \-as\c
-\&\|', symbols
-only, `\|\c
-.B \-a\c
-\&\|', everything.
-.TP
-.B \-D
-This option is accepted only for script compatibility with calls to
-other assemblers; it has no effect on \c
-.B as\c
-\&.
-.TP
-.B \-f
-``fast''--skip preprocessing (assume source is compiler output).
-.TP
-.BI "\-I\ " path
-Add
-.I path
-to the search list for
-.B .include
-directives.
-.TP
-.B \-k
-Handle position independent code, generated by gcc -fpic.
-.TP
-.B \-K
-Handle position independent code, generated by gcc -fPIC.
-This is normally the same as -k.
-.TP
-.B \-L
-Keep (in symbol table) local symbols, starting with `\|\c
-.B L\c
-\|'
-.TP
-.BI "\-o\ " objfile
-Name the object-file output from \c
-.B as
-.TP
-.B \-R
-Fold data section into text section
-.TP
-.B \-v
-Announce \c
-.B as\c
-\& version
-.TP
-.B \-W
-Suppress warning messages
-.TP
-.IR "\-\^\-" "\ |\ " "files\|.\|.\|."
-Source files to assemble, or standard input (\c
-.BR "\-\^\-" ")"
-.TP
-.BI \-A var
-.I
-(When configured for Intel 960.)
-Specify which variant of the 960 architecture is the target.
-.TP
-.B \-b
-.I
-(When configured for Intel 960.)
-Add code to collect statistics about branches taken.
-.TP
-.B \-norelax
-.I
-(When configured for Intel 960.)
-Do not alter compare-and-branch instructions for long displacements;
-error if necessary.
-.TP
-.B \-l
-.I
-(When configured for Motorola 68000).
-.br
-Shorten references to undefined symbols, to one word instead of two.
-.TP
-.BR "\-mc68000" "\||\|" "\-mc68010" "\||\|" "\-mc68020"
-.I
-(When configured for Motorola 68000).
-.br
-Specify what processor in the 68000 family is the target (default 68020)
-
-.PP
-Options may be in any order, and may be
-before, after, or between file names. The order of file names is
-significant.
-
-`\|\c
-.B \-\^\-\c
-\|' (two hyphens) by itself names the standard input file
-explicitly, as one of the files for \c
-.B as\c
-\& to assemble.
-
-Except for `\|\c
-.B \-\^\-\c
-\|' any command line argument that begins with a
-hyphen (`\|\c
-.B \-\c
-\|') is an option. Each option changes the behavior of
-\c
-.B as\c
-\&. No option changes the way another option works. An
-option is a `\|\c
-.B \-\c
-\|' followed by one or more letters; the case of
-the letter is important. All options are optional.
-
-The `\|\c
-.B \-o\c
-\|' option expects exactly one file name to follow. The file
-name may either immediately follow the option's letter (compatible
-with older assemblers) or it may be the next command argument (GNU
-standard).
-
-These two command lines are equivalent:
-.br
-.B
-as\ \ \-o\ \ my\-object\-file.o\ \ mumble.s
-.br
-.B
-as\ \ \-omy\-object\-file.o\ \ mumble.s
-
-.SH "SEE ALSO"
-.RB "`\|" as "\|'"
-entry in
-.B
-info\c
-\&;
-.I
-Using as: The GNU Assembler\c
-\&;
-.BR gcc "(" 1 "),"
-.BR ld "(" 1 ")."
-
-.SH HISTORY
-A
-.I as
-command appeared in
-Version 1 AT&T UNIX.
-
-.SH COPYING
-Copyright (c) 1991, 1992 Free Software Foundation, Inc.
-.PP
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-.PP
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-.PP
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
diff --git a/gnu/usr.bin/as/as.c b/gnu/usr.bin/as/as.c
deleted file mode 100644
index 3464693..0000000
--- a/gnu/usr.bin/as/as.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/* as.c - GAS main program.
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Main program for AS; a 32-bit assembler of GNU.
- * Understands command arguments.
- * Has a few routines that don't fit in other modules because they
- * are shared.
- *
- *
- * bugs
- *
- * : initialisers
- * Since no-one else says they will support them in future: I
- * don't support them now.
- *
- */
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef _POSIX_SOURCE
-#include <sys/types.h> /* For pid_t in signal.h */
-#endif
-#include <signal.h>
-
-#define COMMON
-
-#include "as.h"
-#include "subsegs.h"
-#if __STDC__ == 1
-
-/* This prototype for got_sig() is ansi. If you want
- anything else, then your compiler is lying to you when
- it says that it is __STDC__. If you want to change it,
- #ifdef protect it from those of us with real ansi
- compilers. */
-
-#define SIGTY void
-
-static void got_sig(int sig);
-static char *stralloc(char *str);
-static void perform_an_assembly_pass(int argc, char **argv);
-
-#else /* __STDC__ */
-
-#ifndef SIGTY
-#define SIGTY int
-#endif
-
-static SIGTY got_sig();
-static char *stralloc(); /* Make a (safe) copy of a string. */
-static void perform_an_assembly_pass();
-
-#endif /* not __STDC__ */
-
-#ifdef DONTDEF
-static char * gdb_symbol_file_name;
-long gdb_begin();
-#endif
-
-int listing; /* true if a listing is wanted */
-
-char *myname; /* argv[0] */
-extern const char version_string[];
-
-int main(argc,argv)
-int argc;
-char **argv;
-{
- int work_argc; /* variable copy of argc */
- char **work_argv; /* variable copy of argv */
- char *arg; /* an arg to program */
- char a; /* an arg flag (after -) */
- static const int sig[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM, 0};
-
- for (a=0;sig[a] != 0;a++)
- if (signal(sig[a], SIG_IGN) != SIG_IGN)
- signal(sig[a], got_sig);
-
- myname=argv[0];
- memset(flagseen, '\0', sizeof(flagseen)); /* aint seen nothing yet */
-#ifndef OBJ_DEFAULT_OUTPUT_FILE_NAME
-#define OBJ_DEFAULT_OUTPUT_FILE_NAME "a.out"
-#endif /* OBJ_DEFAULT_OUTPUT_FILE_NAME */
- out_file_name = OBJ_DEFAULT_OUTPUT_FILE_NAME;
-
- symbol_begin(); /* symbols.c */
- subsegs_begin(); /* subsegs.c */
- read_begin(); /* read.c */
- md_begin(); /* MACHINE.c */
- input_scrub_begin(); /* input_scrub.c */
-#ifdef DONTDEF
- gdb_symbol_file_name = 0;
-#endif
- /*
- * Parse arguments, but we are only interested in flags.
- * When we find a flag, we process it then make it's argv[] NULL.
- * This helps any future argv[] scanners avoid what we processed.
- * Since it is easy to do here we interpret the special arg "-"
- * to mean "use stdin" and we set that argv[] pointing to "".
- * After we have munged argv[], the only things left are source file
- * name(s) and ""(s) denoting stdin. These file names are used
- * (perhaps more than once) later.
- */
- /* FIXME-SOMEDAY this should use getopt. */
- work_argc = argc-1; /* don't count argv[0] */
- work_argv = argv+1; /* skip argv[0] */
- for (;work_argc--;work_argv++) {
- arg = * work_argv; /* work_argv points to this argument */
-
- if (*arg != '-') /* Filename. We need it later. */
- continue; /* Keep scanning args looking for flags. */
- if (arg[1] == '-' && arg[2] == 0) {
- /* "--" as an argument means read STDIN */
- /* on this scan, we don't want to think about filenames */
- * work_argv = ""; /* Code that means 'use stdin'. */
- continue;
- }
- /* This better be a switch. */
- arg ++; /*->letter. */
-
- while ((a = * arg) != '\0') {/* scan all the 1-char flags */
- arg ++; /* arg->after letter. */
- a &= 0x7F; /* ascii only please */
- /* if (flagseen[a])
- as_tsktsk("%s: Flag option - %c has already been seen.", myname, a); */
- flagseen[a] = 1;
- switch (a) {
-
- case 'a':
- {
- int loop =1;
-
- while (loop) {
- switch (*arg)
- {
- case 'l':
- listing |= LISTING_LISTING;
- arg++;
- break;
- case 's':
- listing |= LISTING_SYMBOLS;
- arg++;
- break;
- case 'h':
- listing |= LISTING_HLL;
- arg++;
- break;
-
- case 'n':
- listing |= LISTING_NOFORM;
- arg++;
- break;
- case 'd':
- listing |= LISTING_NODEBUG;
- arg++;
- break;
- default:
- if (!listing)
- listing= LISTING_DEFAULT;
- loop = 0;
- break;
- }
- }
- }
-
- break;
-
-
- case 'f':
- break; /* -f means fast - no need for "app" preprocessor. */
-
- case 'D':
- /* DEBUG is implemented: it debugs different */
- /* things to other people's assemblers. */
- break;
-
-#ifdef DONTDEF
- case 'G': /* GNU AS switch: include gdbsyms. */
- if (*arg) /* Rest of argument is file-name. */
- gdb_symbol_file_name = stralloc (arg);
- else if (work_argc) { /* Next argument is file-name. */
- work_argc --;
- * work_argv = NULL; /* Not a source file-name. */
- gdb_symbol_file_name = * ++ work_argv;
- } else
- as_warn("%s: I expected a filename after -G", myname);
- arg = ""; /* Finished with this arg. */
- break;
-#endif
-
- case 'I': { /* Include file directory */
-
- char *temp = NULL;
- if (*arg)
- temp = stralloc (arg);
- else if (work_argc) {
- * work_argv = NULL;
- work_argc--;
- temp = * ++ work_argv;
- } else
- as_warn("%s: I expected a filename after -I", myname);
- add_include_dir (temp);
- arg = ""; /* Finished with this arg. */
- break;
- }
-
- case 'L': /* -L means keep L* symbols */
- break;
-
- case 'o':
- if (*arg) /* Rest of argument is object file-name. */
- out_file_name = stralloc (arg);
- else if (work_argc) { /* Want next arg for a file-name. */
- * work_argv = NULL; /* This is not a file-name. */
- work_argc--;
- out_file_name = * ++ work_argv;
- } else
- as_warn("%s: I expected a filename after -o. \"%s\" assumed.", myname, out_file_name);
- arg = ""; /* Finished with this arg. */
- break;
-
- case 'R':
- /* -R means put data into text segment */
- break;
-
- case 'v':
-#ifdef OBJ_VMS
- {
- extern char *compiler_version_string;
- compiler_version_string = arg;
- }
-#else /* not OBJ_VMS */
- fprintf(stderr,version_string);
- if (*arg && strcmp(arg,"ersion"))
- as_warn("Unknown -v option ignored");
-#endif /* not OBJ_VMS */
- while (*arg) arg++; /* Skip the rest */
- break;
-
- case 'W':
- /* -W means don't warn about things */
- case 'X':
- /* -X means treat warnings as errors */
- case 'Z':
- /* -Z means attempt to generate object file even after errors. */
- break;
-
- default:
- --arg;
- if (md_parse_option(&arg,&work_argc,&work_argv) == 0)
- as_warn("%s: I don't understand '%c' flag.", myname, a);
- if (arg && *arg)
- arg++;
- break;
- }
- }
- /*
- * We have just processed a "-..." arg, which was not a
- * file-name. Smash it so the
- * things that look for filenames won't ever see it.
- *
- * Whatever work_argv points to, it has already been used
- * as part of a flag, so DON'T re-use it as a filename.
- */
- *work_argv = NULL; /* NULL means 'not a file-name' */
- }
-#ifdef PIC
- if (flagseen['K'] || flagseen['k'])
- picmode = 1;
-#endif
-#ifdef DONTDEF
- if (gdb_begin(gdb_symbol_file_name) == 0)
- flagseen['G'] = 0; /* Don't do any gdbsym stuff. */
-#endif
- /* Here with flags set up in flagseen[]. */
-
- perform_an_assembly_pass(argc,argv); /* Assemble it. */
-#ifdef TC_I960
- brtab_emit();
-#endif
- if (seen_at_least_1_file()
- && !((had_warnings() && flagseen['Z'])
- || had_errors() > 0)) {
- write_object_file(); /* relax() addresses then emit object file */
- } /* we also check in write_object_file() just before emit. */
-
- input_scrub_end();
- md_end(); /* MACHINE.c */
-
-#ifndef NO_LISTING
- listing_print("");
-#endif
-
-#ifndef HO_VMS
- return((had_warnings() && flagseen['Z'])
- || had_errors() > 0); /* WIN */
-#else /* HO_VMS */
- return(!((had_warnings() && flagseen['Z'])
- || had_errors() > 0)); /* WIN */
-#endif /* HO_VMS */
-
-} /* main() */
-
-
-/* perform_an_assembly_pass()
- *
- * Here to attempt 1 pass over each input file.
- * We scan argv[*] looking for filenames or exactly "" which is
- * shorthand for stdin. Any argv that is NULL is not a file-name.
- * We set need_pass_2 TRUE if, after this, we still have unresolved
- * expressions of the form (unknown value)+-(unknown value).
- *
- * Note the un*x semantics: there is only 1 logical input file, but it
- * may be a catenation of many 'physical' input files.
- */
-static void perform_an_assembly_pass(argc, argv)
-int argc;
-char **argv;
-{
- int saw_a_file = 0;
- need_pass_2 = 0;
-
-#ifdef MANY_SEGMENTS
- unsigned int i;
-
- for (i= SEG_E0; i < SEG_UNKNOWN; i++)
- {
- segment_info[i].fix_root = 0;
- }
- /* Create the three fixed ones */
- subseg_new (SEG_E0, 0);
- subseg_new (SEG_E1, 0);
- subseg_new (SEG_E2, 0);
- strcpy(segment_info[SEG_E0].scnhdr.s_name,".text");
- strcpy(segment_info[SEG_E1].scnhdr.s_name,".data");
- strcpy(segment_info[SEG_E2].scnhdr.s_name,".bss");
-
- subseg_new (SEG_E0, 0);
-#else /* not MANY_SEGMENTS */
- text_fix_root = NULL;
- data_fix_root = NULL;
- bss_fix_root = NULL;
-
- subseg_new (SEG_TEXT, 0);
-#endif /* not MANY_SEGMENTS */
-
- argv++; /* skip argv[0] */
- argc--; /* skip argv[0] */
- while (argc--) {
- if (*argv) { /* Is it a file-name argument? */
- saw_a_file++;
- /* argv->"" if stdin desired, else->filename */
- read_a_source_file(*argv);
- }
- argv++; /* completed that argv */
- }
- if (!saw_a_file)
- read_a_source_file("");
-} /* perform_an_assembly_pass() */
-
-/*
- * stralloc()
- *
- * Allocate memory for a new copy of a string. Copy the string.
- * Return the address of the new string. Die if there is any error.
- */
-
-static char *
- stralloc (str)
-char * str;
-{
- register char * retval;
- register long len;
-
- len = strlen (str) + 1;
- retval = xmalloc (len);
- (void) strcpy(retval, str);
- return(retval);
-}
-
-#ifdef comment
-static void lose() {
- as_fatal("%s: 2nd pass not implemented - get your code from random(3)", myname);
- return;
-} /* lose() */
-#endif /* comment */
-
-static SIGTY
- got_sig(sig)
-int sig;
-{
- static here_before = 0;
-
- as_bad("Interrupted by signal %d", sig);
- if (here_before++)
- exit(1);
- return((SIGTY) 0);
-}
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of as.c */
diff --git a/gnu/usr.bin/as/as.h b/gnu/usr.bin/as/as.h
deleted file mode 100644
index 28b6974..0000000
--- a/gnu/usr.bin/as/as.h
+++ /dev/null
@@ -1,426 +0,0 @@
-/* as.h - global header file
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * $Id$
- */
-
-#define GAS 1
-/* #include <ansidecl.h> */
-#include "host.h"
-#include "flonum.h"
-
-#if __STDC__ != 1
-#define volatile /**/
-#ifndef const
-#define const /**/
-#endif /* const */
-#endif /* __STDC__ */
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#define register
-#endif /* __GNUC__ */
-
-#ifndef __LINE__
-#define __LINE__ "unknown"
-#endif /* __LINE__ */
-
-#ifndef __FILE__
-#define __FILE__ "unknown"
-#endif /* __FILE__ */
-
-#ifndef PARAMS
-#if __STDC__ != 1
-#define PARAMS(x) ()
-#else
-#define PARAMS(x) x
-#endif
-#endif /*PARAMS */
-
-/*
- * I think this stuff is largely out of date. xoxorich.
- *
- * CAPITALISED names are #defined.
- * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
- * "lowercaseT" is a typedef of "lowercase" objects.
- * "lowercaseP" is type "pointer to object of type 'lowercase'".
- * "lowercaseS" is typedef struct ... lowercaseS.
- *
- * #define DEBUG to enable all the "know" assertion tests.
- * #define SUSPECT when debugging.
- * #define COMMON as "extern" for all modules except one, where you #define
- * COMMON as "".
- * If TEST is #defined, then we are testing a module: #define COMMON as "".
- */
-
-/* These #defines are for parameters of entire assembler. */
-
-/* #define SUSPECT JF remove for speed testing */
-/* These #includes are for type definitions etc. */
-
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free xfree
-
-#define xfree free
-
-#define BAD_CASE(value) \
-{ \
- as_fatal("Case value %d unexpected at line %d of file \"%s\"\n", \
- value, __LINE__, __FILE__); \
- }
-
-
-/* These are assembler-wide concepts */
-
-
-#ifndef COMMON
-#ifdef TEST
-#define COMMON /* declare our COMMONs storage here. */
-#else
-#define COMMON extern /* our commons live elswhere */
-#endif
-#endif
-/* COMMON now defined */
-#define DEBUG /* temporary */
-
-#ifdef DEBUG
-#undef NDEBUG
-#ifndef know
-#define know(p) assert(p) /* Verify our assumptions! */
-#endif /* not yet defined */
-#else
-#define know(p) /* know() checks are no-op.ed */
-#endif
-
-/* input_scrub.c */
-
-/*
- * Supplies sanitised buffers to read.c.
- * Also understands printing line-number part of error messages.
- */
-
-
-/* subsegs.c Sub-segments. Also, segment(=expression type)s.*/
-
-/*
- * This table describes the use of segments as EXPRESSION types.
- *
- * X_seg X_add_symbol X_subtract_symbol X_add_number
- * SEG_ABSENT no (legal) expression
- * SEG_PASS1 no (defined) "
- * SEG_BIG * > 32 bits const.
- * SEG_ABSOLUTE 0
- * SEG_DATA * 0
- * SEG_TEXT * 0
- * SEG_BSS * 0
- * SEG_UNKNOWN * 0
- * SEG_DIFFERENCE 0 * 0
- * SEG_REGISTER *
- *
- * The blank fields MUST be 0, and are nugatory.
- * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
- *
- * SEG_BIG: X_add_number is < 0 if the result is in
- * generic_floating_point_number. The value is -'c' where c is the
- * character that introduced the constant. e.g. "0f6.9" will have -'f'
- * as a X_add_number value.
- * X_add_number > 0 is a count of how many littlenums it took to
- * represent a bignum.
- * SEG_DIFFERENCE:
- * If segments of both symbols are known, they are the same segment.
- * X_add_symbol != X_sub_symbol (then we just cancel them, => SEG_ABSOLUTE).
- */
-
-
-#ifdef MANY_SEGMENTS
-#define N_SEGMENTS 10
-#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
-#define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
-#define SEG_DATA SEG_E1
-#define SEG_TEXT SEG_E0
-#define SEG_BSS SEG_E2
-#else
-#define N_SEGMENTS 3
-#define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
-#define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
-#endif
-
-typedef enum _segT {
- SEG_ABSOLUTE = 0,
- SEG_LIST,
- SEG_UNKNOWN,
- SEG_ABSENT, /* Mythical Segment (absent): NO expression seen. */
- SEG_PASS1, /* Mythical Segment: Need another pass. */
- SEG_GOOF, /* Only happens if AS has a logic error. */
- /* Invented so we don't crash printing */
- /* error message involving weird segment. */
- SEG_BIG, /* Bigger than 32 bits constant. */
- SEG_DIFFERENCE, /* Mythical Segment: absolute difference. */
- SEG_DEBUG, /* Debug segment */
- SEG_NTV, /* Transfert vector preload segment */
- SEG_PTV, /* Transfert vector postload segment */
- SEG_REGISTER, /* Mythical: a register-valued expression */
-} segT;
-
-#define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
-
-typedef int subsegT;
-
-COMMON subsegT now_subseg;
-/* What subseg we are accreting now? */
-
-
-COMMON segT now_seg;
-/* Segment our instructions emit to. */
-/* Only OK values are SEG_TEXT or SEG_DATA. */
-
-
-extern char *const seg_name[];
-extern int section_alignment[];
-
-
-/* relax() */
-
-typedef enum _relax_state {
- rs_fill, /* Variable chars to be repeated fr_offset times. Fr_symbol
- unused. Used with fr_offset == 0 for a constant length
- frag. */
-
- rs_align, /* Align: Fr_offset: power of 2. 1 variable char: fill
- character. */
-
- rs_org, /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
- character. */
-
- rs_machine_dependent,
-
-#ifndef WORKING_DOT_WORD
- rs_broken_word, /* JF: gunpoint */
-#endif
-} relax_stateT;
-
-/* typedef unsigned char relax_substateT; */
-/* JF this is more likely to leave the end of a struct frag on an align
- boundry. Be very careful with this. */
-typedef unsigned long relax_substateT;
-
-typedef unsigned long relax_addressT;/* Enough bits for address. */
-/* Still an integer type. */
-
-
-/* frags.c */
-
-/*
- * A code fragment (frag) is some known number of chars, followed by some
- * unknown number of chars. Typically the unknown number of chars is an
- * instruction address whose size is yet unknown. We always know the greatest
- * possible size the unknown number of chars may become, and reserve that
- * much room at the end of the frag.
- * Once created, frags do not change address during assembly.
- * We chain the frags in (a) forward-linked list(s). The object-file address
- * of the 1st char of a frag is generally not known until after relax().
- * Many things at assembly time describe an address by {object-file-address
- * of a particular frag}+offset.
-
- BUG: it may be smarter to have a single pointer off to various different
- notes for different frag kinds. See how code pans
- */
-struct frag /* a code fragment */
-{
- unsigned long fr_address; /* Object file address. */
- struct frag *fr_next; /* Chain forward; ascending address order. */
- /* Rooted in frch_root. */
-
- long fr_fix; /* (Fixed) number of chars we know we have. */
- /* May be 0. */
- long fr_var; /* (Variable) number of chars after above. */
- /* May be 0. */
- struct symbol *fr_symbol; /* For variable-length tail. */
- long fr_offset; /* For variable-length tail. */
- char *fr_opcode; /*->opcode low addr byte,for relax()ation*/
- relax_stateT fr_type; /* What state is my tail in? */
- relax_substateT fr_subtype;
- /* These are needed only on the NS32K machines */
- char fr_pcrel_adjust;
- char fr_bsr;
-#ifndef NO_LISTING
- struct list_info_struct *line;
-#endif
- char fr_literal[1]; /* Chars begin here. */
- /* One day we will compile fr_literal[0]. */
-};
-#define SIZEOF_STRUCT_FRAG \
-((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
-/* We want to say fr_literal[0] above. */
-
-typedef struct frag fragS;
-
-COMMON fragS *frag_now; /* -> current frag we are building. */
-/* This frag is incomplete. */
-/* It is, however, included in frchain_now. */
-/* Frag_now->fr_fix is bogus. Use: */
-/* Virtual frag_now->fr_fix == obstack_next_free(&frags)-frag_now->fr_literal.*/
-
-COMMON fragS zero_address_frag; /* For foreign-segment symbol fixups. */
-COMMON fragS bss_address_frag; /* For local common (N_BSS segment) fixups. */
-
-/* main program "as.c" (command arguments etc) */
-
-COMMON char
- flagseen[128]; /* ['x'] TRUE if "-x" seen. */
-
-COMMON char *
- out_file_name; /* name of emitted object file */
-
-COMMON int need_pass_2; /* TRUE if we need a second pass. */
-
-COMMON int picmode; /* TRUE if "-k" or "-K" seen. */
-
-typedef struct {
- char * poc_name; /* assembler mnemonic, lower case, no '.' */
- void (*poc_handler)(); /* Do the work */
- int poc_val; /* Value to pass to handler */
-} pseudo_typeS;
-
-#if (__STDC__ == 1) & !defined(NO_STDARG)
-
-int had_errors(void);
-int had_warnings(void);
-void as_bad(const char *Format, ...);
-void as_fatal(const char *Format, ...);
-void as_tsktsk(const char *Format, ...);
-void as_warn(const char *Format, ...);
-
-#else
-
-int had_errors();
-int had_warnings();
-void as_bad();
-void as_fatal();
-void as_tsktsk();
-void as_warn();
-
-#endif /* __STDC__ & !NO_STDARG */
-
-#if __STDC__ == 1
-
-char *app_push(void);
-char *atof_ieee(char *str, int what_kind, LITTLENUM_TYPE *words);
-char *input_scrub_include_file(char *filename, char *position);
-char *input_scrub_new_file(char *filename);
-char *input_scrub_next_buffer(char **bufp);
-char *strstr(const char *s, const char *wanted);
-char *xmalloc(int size);
-char *xrealloc(char *ptr, long n);
-int do_scrub_next_char(int (*get)(), void (*unget)());
-int gen_to_words(LITTLENUM_TYPE *words, int precision, long exponent_bits);
-int had_err(void);
-int had_errors(void);
-int had_warnings(void);
-int ignore_input(void);
-int scrub_from_file(void);
-int scrub_from_file(void);
-int scrub_from_string(void);
-int seen_at_least_1_file(void);
-void app_pop(char *arg);
-void as_howmuch(FILE *stream);
-void as_perror(const char *gripe, const char *filename);
-void as_where(char **, unsigned int *);
-void bump_line_counters(void);
-void do_scrub_begin(void);
-void input_scrub_begin(void);
-void input_scrub_close(void);
-void input_scrub_end(void);
-void int_to_gen(long x);
-void new_logical_line(char *fname, int line_number);
-void scrub_to_file(int ch);
-void scrub_to_string(int ch);
-void subseg_change(segT seg, int subseg);
-void subseg_new(segT seg, subsegT subseg);
-void subsegs_begin(void);
-
-#else /* not __STDC__ */
-
-char *app_push();
-char *atof_ieee();
-char *input_scrub_include_file();
-char *input_scrub_new_file();
-char *input_scrub_next_buffer();
-char *strstr();
-char *xmalloc();
-char *xrealloc();
-int do_scrub_next_char();
-int gen_to_words();
-int had_err();
-int had_errors();
-int had_warnings();
-int ignore_input();
-int scrub_from_file();
-int scrub_from_file();
-int scrub_from_string();
-int seen_at_least_1_file();
-void app_pop();
-void as_howmuch();
-void as_perror();
-void as_where();
-void bump_line_counters();
-void do_scrub_begin();
-void input_scrub_begin();
-void input_scrub_close();
-void input_scrub_end();
-void int_to_gen();
-void new_logical_line();
-void scrub_to_file();
-void scrub_to_string();
-void subseg_change();
-void subseg_new();
-void subsegs_begin();
-
-#endif /* not __STDC__ */
-
-/* this one starts the chain of target dependant headers */
-#include "targ-env.h"
-
-/* these define types needed by the interfaces */
-#include "struc-symbol.h"
-#include "write.h"
-#include "expr.h"
-#include "frags.h"
-#include "hash.h"
-#include "read.h"
-#include "symbols.h"
-
-#include "tc.h"
-#include "obj.h"
-
-#include "listing.h"
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of as.h */
diff --git a/gnu/usr.bin/as/atof-generic.c b/gnu/usr.bin/as/atof-generic.c
deleted file mode 100644
index b0a8ff1..0000000
--- a/gnu/usr.bin/as/atof-generic.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/* atof_generic.c - turn a string of digits into a Flonum
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <string.h>
-
-#include "as.h"
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-#ifdef sparc
-#include <alloca.h>
-#endif
-#endif
-
-/* #define FALSE (0) */
-/* #define TRUE (1) */
-
-/***********************************************************************\
- * *
- * Given a string of decimal digits , with optional decimal *
- * mark and optional decimal exponent (place value) of the *
- * lowest_order decimal digit: produce a floating point *
- * number. The number is 'generic' floating point: our *
- * caller will encode it for a specific machine architecture. *
- * *
- * Assumptions *
- * uses base (radix) 2 *
- * this machine uses 2's complement binary integers *
- * target flonums use " " " " *
- * target flonums exponents fit in a long *
- * *
- \***********************************************************************/
-
-/*
-
- Syntax:
-
- <flonum> ::= <optional-sign> <decimal-number> <optional-exponent>
- <optional-sign> ::= '+' | '-' | {empty}
- <decimal-number> ::= <integer>
- | <integer> <radix-character>
- | <integer> <radix-character> <integer>
- | <radix-character> <integer>
-
- <optional-exponent> ::= {empty}
- | <exponent-character> <optional-sign> <integer>
-
- <integer> ::= <digit> | <digit> <integer>
- <digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
- <exponent-character> ::= {one character from "string_of_decimal_exponent_marks"}
- <radix-character> ::= {one character from "string_of_decimal_marks"}
-
- */
-
-int /* 0 if OK */
- atof_generic (
- address_of_string_pointer, /* return pointer to just
- AFTER number we read. */
- string_of_decimal_marks, /* At most one per number. */
- string_of_decimal_exponent_marks,
- address_of_generic_floating_point_number)
-char **address_of_string_pointer;
-const char *string_of_decimal_marks;
-const char *string_of_decimal_exponent_marks;
-FLONUM_TYPE *address_of_generic_floating_point_number;
-{
- int return_value; /* 0 means OK. */
- char * first_digit;
- /* char *last_digit; JF unused */
- int number_of_digits_before_decimal;
- int number_of_digits_after_decimal;
- long decimal_exponent;
- int number_of_digits_available;
- char digits_sign_char;
-
- /*
- * Scan the input string, abstracting (1)digits (2)decimal mark (3) exponent.
- * It would be simpler to modify the string, but we don't; just to be nice
- * to caller.
- * We need to know how many digits we have, so we can allocate space for
- * the digits' value.
- */
-
- char *p;
- char c;
- int seen_significant_digit;
-
- first_digit = *address_of_string_pointer;
- c = *first_digit;
-
- if (c == '-' || c == '+') {
- digits_sign_char = c;
- first_digit++;
- } else
- digits_sign_char = '+';
-
- if ((first_digit[0] == 'n' || first_digit[0] == 'N')
- && (first_digit[1] == 'a' || first_digit[1] == 'A')
- && (first_digit[2] == 'n' || first_digit[2] == 'N')) {
- address_of_generic_floating_point_number->sign = 0;
- address_of_generic_floating_point_number->exponent = 0;
- address_of_generic_floating_point_number->leader =
- address_of_generic_floating_point_number->low;
- *address_of_string_pointer = first_digit + 3;
- return(0);
- }
-
- /* 99e999 is a "special" token to some older, broken compilers. */
- if ((first_digit[0] == 'i' || first_digit[0] == 'I')
- && (first_digit[1] == 'n' || first_digit[1] == 'N')
- && (first_digit[2] == 'f' || first_digit[2] == 'F')) {
- address_of_generic_floating_point_number->sign =
- digits_sign_char == '+' ? 'P' : 'N';
- address_of_generic_floating_point_number->exponent = 0;
- address_of_generic_floating_point_number->leader =
- address_of_generic_floating_point_number->low;
-
- if ((first_digit[3] == 'i' || first_digit[3] == 'I')
- && (first_digit[4] == 'n' || first_digit[4] == 'N')
- && (first_digit[5] == 'i' || first_digit[5] == 'I')
- && (first_digit[6] == 't' || first_digit[6] == 'T')
- && (first_digit[7] == 'y' || first_digit[7] == 'Y')) {
- *address_of_string_pointer = first_digit + 8;
- } else {
- *address_of_string_pointer = first_digit + 3;
- }
- return(0);
- }
-
- if (strncmp(first_digit, "99e999", 6) == 0) {
- address_of_generic_floating_point_number->sign =
- digits_sign_char == '+' ? 'P' : 'N';
- address_of_generic_floating_point_number->exponent = 0;
- address_of_generic_floating_point_number->leader =
- address_of_generic_floating_point_number->low;
- *address_of_string_pointer = first_digit + 6;
- return(0);
- }
-
- number_of_digits_before_decimal = 0;
- number_of_digits_after_decimal = 0;
- decimal_exponent = 0;
- seen_significant_digit = 0;
- for (p = first_digit; (((c = * p) != '\0')
- && (!c || ! strchr(string_of_decimal_marks, c))
- && (!c || !strchr(string_of_decimal_exponent_marks, c)));
- p++) {
- if (isdigit(c)) {
- if (seen_significant_digit || c > '0') {
- ++number_of_digits_before_decimal;
- seen_significant_digit = 1;
- } else {
- first_digit++;
- }
- } else {
- break; /* p -> char after pre-decimal digits. */
- }
- } /* For each digit before decimal mark. */
-
-#ifndef OLD_FLOAT_READS
- /* Ignore trailing 0's after the decimal point. The original code here
- * (ifdef'd out) does not do this, and numbers like
- * 4.29496729600000000000e+09 (2**31)
- * come out inexact for some reason related to length of the digit
- * string.
- */
- if (c && strchr(string_of_decimal_marks, c)) {
- int zeros = 0; /* Length of current string of zeros */
-
- for (p++; (c = *p) && isdigit(c); p++) {
- if (c == '0') {
- zeros++;
- } else {
- number_of_digits_after_decimal += 1 + zeros;
- zeros = 0;
- }
- }
- }
-#else
- if (c && strchr(string_of_decimal_marks, c)) {
- for (p++; (((c = *p) != '\0')
- && (!c || !strchr(string_of_decimal_exponent_marks, c)));
- p++) {
- if (isdigit(c)) {
- number_of_digits_after_decimal++; /* This may be retracted below. */
- if (/* seen_significant_digit || */ c > '0') {
- seen_significant_digit = TRUE;
- }
- } else {
- if (!seen_significant_digit) {
- number_of_digits_after_decimal = 0;
- }
- break;
- }
- } /* For each digit after decimal mark. */
- }
-
- while (number_of_digits_after_decimal && first_digit[number_of_digits_before_decimal
- + number_of_digits_after_decimal] == '0')
- --number_of_digits_after_decimal;
- /* last_digit = p; JF unused */
-#endif
-
- if (c && strchr(string_of_decimal_exponent_marks, c) ) {
- char digits_exponent_sign_char;
-
- c = *++p;
- if (c && strchr ("+-",c)) {
- digits_exponent_sign_char = c;
- c = *++p;
- } else {
- digits_exponent_sign_char = '+';
- }
-
- for ( ; (c); c = *++p) {
- if (isdigit(c)) {
- decimal_exponent = decimal_exponent * 10 + c - '0';
- /*
- * BUG! If we overflow here, we lose!
- */
- } else {
- break;
- }
- }
-
- if (digits_exponent_sign_char == '-') {
- decimal_exponent = -decimal_exponent;
- }
- }
-
- *address_of_string_pointer = p;
-
-
-
- number_of_digits_available =
- number_of_digits_before_decimal + number_of_digits_after_decimal;
- return_value = 0;
- if (number_of_digits_available == 0) {
- address_of_generic_floating_point_number->exponent = 0; /* Not strictly necessary */
- address_of_generic_floating_point_number->leader
- = -1 + address_of_generic_floating_point_number->low;
- address_of_generic_floating_point_number->sign = digits_sign_char;
- /* We have just concocted (+/-)0.0E0 */
-
- } else {
- int count; /* Number of useful digits left to scan. */
-
- LITTLENUM_TYPE *digits_binary_low;
- int precision;
- int maximum_useful_digits;
- int number_of_digits_to_use;
- int more_than_enough_bits_for_digits;
- int more_than_enough_littlenums_for_digits;
- int size_of_digits_in_littlenums;
- int size_of_digits_in_chars;
- FLONUM_TYPE power_of_10_flonum;
- FLONUM_TYPE digits_flonum;
-
- precision = (address_of_generic_floating_point_number->high
- - address_of_generic_floating_point_number->low
- + 1); /* Number of destination littlenums. */
-
- /* Includes guard bits (two littlenums worth) */
- maximum_useful_digits = (((double) (precision - 2))
- * ((double) (LITTLENUM_NUMBER_OF_BITS))
- / (LOG_TO_BASE_2_OF_10))
- + 2; /* 2 :: guard digits. */
-
- if (number_of_digits_available > maximum_useful_digits) {
- number_of_digits_to_use = maximum_useful_digits;
- } else {
- number_of_digits_to_use = number_of_digits_available;
- }
-
- decimal_exponent += number_of_digits_before_decimal - number_of_digits_to_use;
-
- more_than_enough_bits_for_digits
- = ((((double)number_of_digits_to_use) * LOG_TO_BASE_2_OF_10) + 1);
-
- more_than_enough_littlenums_for_digits
- = (more_than_enough_bits_for_digits
- / LITTLENUM_NUMBER_OF_BITS)
- + 2;
-
- /*
- * Compute (digits) part. In "12.34E56" this is the "1234" part.
- * Arithmetic is exact here. If no digits are supplied then
- * this part is a 0 valued binary integer.
- * Allocate room to build up the binary number as littlenums.
- * We want this memory to disappear when we leave this function.
- * Assume no alignment problems => (room for n objects) ==
- * n * (room for 1 object).
- */
-
- size_of_digits_in_littlenums = more_than_enough_littlenums_for_digits;
- size_of_digits_in_chars = size_of_digits_in_littlenums
- * sizeof(LITTLENUM_TYPE);
-
- digits_binary_low = (LITTLENUM_TYPE *)
- alloca(size_of_digits_in_chars);
-
- memset((char *)digits_binary_low, '\0', size_of_digits_in_chars);
-
- /* Digits_binary_low[] is allocated and zeroed. */
-
- /*
- * Parse the decimal digits as if * digits_low was in the units position.
- * Emit a binary number into digits_binary_low[].
- *
- * Use a large-precision version of:
- * (((1st-digit) * 10 + 2nd-digit) * 10 + 3rd-digit ...) * 10 + last-digit
- */
-
- for (p = first_digit, count = number_of_digits_to_use; count; p++, --count) {
- c = *p;
- if (isdigit(c)) {
- /*
- * Multiply by 10. Assume can never overflow.
- * Add this digit to digits_binary_low[].
- */
-
- long carry;
- LITTLENUM_TYPE *littlenum_pointer;
- LITTLENUM_TYPE *littlenum_limit;
-
- littlenum_limit = digits_binary_low
- + more_than_enough_littlenums_for_digits
- - 1;
-
- carry = c - '0'; /* char -> binary */
-
- for (littlenum_pointer = digits_binary_low;
- littlenum_pointer <= littlenum_limit;
- littlenum_pointer++) {
- long work;
-
- work = carry + 10 * (long) (*littlenum_pointer);
- *littlenum_pointer = work & LITTLENUM_MASK;
- carry = work >> LITTLENUM_NUMBER_OF_BITS;
- }
-
- if (carry != 0) {
- /*
- * We have a GROSS internal error.
- * This should never happen.
- */
- as_fatal("failed sanity check."); /* RMS prefers abort() to any message. */
- }
- } else {
- ++ count; /* '.' doesn't alter digits used count. */
- } /* if valid digit */
- } /* for each digit */
-
-
- /*
- * Digits_binary_low[] properly encodes the value of the digits.
- * Forget about any high-order littlenums that are 0.
- */
- while (digits_binary_low[size_of_digits_in_littlenums - 1] == 0
- && size_of_digits_in_littlenums >= 2)
- size_of_digits_in_littlenums--;
-
- digits_flonum.low = digits_binary_low;
- digits_flonum.high = digits_binary_low + size_of_digits_in_littlenums - 1;
- digits_flonum.leader = digits_flonum.high;
- digits_flonum.exponent = 0;
- /*
- * The value of digits_flonum.sign should not be important.
- * We have already decided the output's sign.
- * We trust that the sign won't influence the other parts of the number!
- * So we give it a value for these reasons:
- * (1) courtesy to humans reading/debugging
- * these numbers so they don't get excited about strange values
- * (2) in future there may be more meaning attached to sign,
- * and what was
- * harmless noise may become disruptive, ill-conditioned (or worse)
- * input.
- */
- digits_flonum.sign = '+';
-
- {
- /*
- * Compute the mantssa (& exponent) of the power of 10.
- * If sucessful, then multiply the power of 10 by the digits
- * giving return_binary_mantissa and return_binary_exponent.
- */
-
- LITTLENUM_TYPE *power_binary_low;
- int decimal_exponent_is_negative;
- /* This refers to the "-56" in "12.34E-56". */
- /* FALSE: decimal_exponent is positive (or 0) */
- /* TRUE: decimal_exponent is negative */
- FLONUM_TYPE temporary_flonum;
- LITTLENUM_TYPE *temporary_binary_low;
- int size_of_power_in_littlenums;
- int size_of_power_in_chars;
-
- size_of_power_in_littlenums = precision;
- /* Precision has a built-in fudge factor so we get a few guard bits. */
-
- decimal_exponent_is_negative = decimal_exponent < 0;
- if (decimal_exponent_is_negative) {
- decimal_exponent = -decimal_exponent;
- }
-
- /* From now on: the decimal exponent is > 0. Its sign is seperate. */
-
- size_of_power_in_chars = size_of_power_in_littlenums
- * sizeof(LITTLENUM_TYPE) + 2;
-
- power_binary_low = (LITTLENUM_TYPE *) alloca(size_of_power_in_chars);
- temporary_binary_low = (LITTLENUM_TYPE *) alloca(size_of_power_in_chars);
- memset((char *)power_binary_low, '\0', size_of_power_in_chars);
- * power_binary_low = 1;
- power_of_10_flonum.exponent = 0;
- power_of_10_flonum.low = power_binary_low;
- power_of_10_flonum.leader = power_binary_low;
- power_of_10_flonum.high = power_binary_low + size_of_power_in_littlenums - 1;
- power_of_10_flonum.sign = '+';
- temporary_flonum.low = temporary_binary_low;
- temporary_flonum.high = temporary_binary_low + size_of_power_in_littlenums - 1;
- /*
- * (power) == 1.
- * Space for temporary_flonum allocated.
- */
-
- /*
- * ...
- *
- * WHILE more bits
- * DO find next bit (with place value)
- * multiply into power mantissa
- * OD
- */
- {
- int place_number_limit;
- /* Any 10^(2^n) whose "n" exceeds this */
- /* value will fall off the end of */
- /* flonum_XXXX_powers_of_ten[]. */
- int place_number;
- const FLONUM_TYPE *multiplicand; /* -> 10^(2^n) */
-
- place_number_limit = table_size_of_flonum_powers_of_ten;
-
- multiplicand = (decimal_exponent_is_negative
- ? flonum_negative_powers_of_ten
- : flonum_positive_powers_of_ten);
-
- for (place_number = 1; /* Place value of this bit of exponent. */
- decimal_exponent; /* Quit when no more 1 bits in exponent. */
- decimal_exponent >>= 1, place_number++) {
- if (decimal_exponent & 1) {
- if (place_number > place_number_limit) {
- /*
- * The decimal exponent has a magnitude so great that
- * our tables can't help us fragment it. Although this
- * routine is in error because it can't imagine a
- * number that big, signal an error as if it is the
- * user's fault for presenting such a big number.
- */
- return_value = ERROR_EXPONENT_OVERFLOW;
- /*
- * quit out of loop gracefully
- */
- decimal_exponent = 0;
- } else {
-#ifdef TRACE
- printf("before multiply, place_number = %d., power_of_10_flonum:\n",
- place_number);
-
- flonum_print(&power_of_10_flonum);
- (void)putchar('\n');
-#endif
- flonum_multip(multiplicand + place_number,
- &power_of_10_flonum, &temporary_flonum);
- flonum_copy(&temporary_flonum, &power_of_10_flonum);
- } /* If this bit of decimal_exponent was computable.*/
- } /* If this bit of decimal_exponent was set. */
- } /* For each bit of binary representation of exponent */
-#ifdef TRACE
- printf(" after computing power_of_10_flonum: ");
- flonum_print(&power_of_10_flonum );
- (void) putchar('\n');
-#endif
- }
-
- }
-
- /*
- * power_of_10_flonum is power of ten in binary (mantissa) , (exponent).
- * It may be the number 1, in which case we don't NEED to multiply.
- *
- * Multiply (decimal digits) by power_of_10_flonum.
- */
-
- flonum_multip(&power_of_10_flonum, &digits_flonum, address_of_generic_floating_point_number);
- /* Assert sign of the number we made is '+'. */
- address_of_generic_floating_point_number->sign = digits_sign_char;
-
- } /* If we had any significant digits. */
- return(return_value);
-} /* atof_generic () */
-
-/* end of atof_generic.c */
diff --git a/gnu/usr.bin/as/bignum-copy.c b/gnu/usr.bin/as/bignum-copy.c
deleted file mode 100644
index b212096..0000000
--- a/gnu/usr.bin/as/bignum-copy.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* bignum_copy.c - copy a bignum
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "as.h"
-
-/*
- * bignum_copy ()
- *
- * Copy a bignum from in to out.
- * If the output is shorter than the input, copy lower-order littlenums.
- * Return 0 or the number of significant littlenums dropped.
- * Assumes littlenum arrays are densely packed: no unused chars between
- * the littlenums. Uses memcpy() to move littlenums, and wants to
- * know length (in chars) of the input bignum.
- */
-
-/* void */
-int
- bignum_copy(in, in_length, out, out_length)
-register LITTLENUM_TYPE *in;
-register int in_length; /* in sizeof(littlenum)s */
-register LITTLENUM_TYPE *out;
-register int out_length; /* in sizeof(littlenum)s */
-{
- int significant_littlenums_dropped;
-
- if (out_length < in_length) {
- LITTLENUM_TYPE *p; /* -> most significant (non-zero) input
- littlenum. */
-
- memcpy((void *) out, (void *) in,
- out_length << LITTLENUM_SHIFT);
- for (p = in + in_length - 1; p >= in; --p) {
- if (* p) break;
- }
- significant_littlenums_dropped = p - in - in_length + 1;
-
- if (significant_littlenums_dropped < 0) {
- significant_littlenums_dropped = 0;
- }
- } else {
- memcpy((char *) out, (char *) in,
- in_length << LITTLENUM_SHIFT);
-
- if (out_length > in_length) {
- memset((char *) (out + out_length),
- '\0', (out_length - in_length) << LITTLENUM_SHIFT);
- }
-
- significant_littlenums_dropped = 0;
- }
-
- return(significant_littlenums_dropped);
-} /* bignum_copy() */
-
-/* end of bignum-copy.c */
diff --git a/gnu/usr.bin/as/bignum.h b/gnu/usr.bin/as/bignum.h
deleted file mode 100644
index 71b85f8..0000000
--- a/gnu/usr.bin/as/bignum.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* bignum.h-arbitrary precision integers
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * $Id$
- */
-
-/***********************************************************************\
- * *
- * Arbitrary-precision integer arithmetic. *
- * For speed, we work in groups of bits, even though this *
- * complicates algorithms. *
- * Each group of bits is called a 'littlenum'. *
- * A bunch of littlenums representing a (possibly large) *
- * integer is called a 'bignum'. *
- * Bignums are >= 0. *
- * *
- \***********************************************************************/
-
-#define LITTLENUM_NUMBER_OF_BITS (16)
-#define LITTLENUM_RADIX (1 << LITTLENUM_NUMBER_OF_BITS)
-#define LITTLENUM_MASK (0xFFFF)
-#define LITTLENUM_SHIFT (1)
-#define CHARS_PER_LITTLENUM (1 << LITTLENUM_SHIFT)
-#ifndef BITS_PER_CHAR
-#define BITS_PER_CHAR (8)
-#endif
-
-typedef unsigned short LITTLENUM_TYPE;
-
-/* JF truncated this to get around a problem with GCC */
-#define LOG_TO_BASE_2_OF_10 (3.3219280948873623478703194294893901758651)
-/* WARNING: I haven't checked that the trailing digits are correct! */
-
- /* lengths are in sizeof(littlenum)s */
-#if __STDC__ == 1
-
-int bignum_copy(LITTLENUM_TYPE *in, int in_length,
- LITTLENUM_TYPE *out, int out_length);
-
-#else
-
-int bignum_copy();
-
-#endif /* __STDC__ */
-
-
-/* end of bignum.h */
diff --git a/gnu/usr.bin/as/bit_fix.h b/gnu/usr.bin/as/bit_fix.h
deleted file mode 100644
index 3d075d7..0000000
--- a/gnu/usr.bin/as/bit_fix.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* write.h
-
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-/* The bit_fix was implemented to support machines that need variables
- to be inserted in bitfields other than 1, 2 and 4 bytes.
- Furthermore it gives us a possibillity to mask in bits in the symbol
- when it's fixed in the objectcode and check the symbols limits.
-
- The or-mask is used to set the huffman bits in displacements for the
- ns32k port.
- The acbi, addqi, movqi, cmpqi instruction requires an assembler that
- can handle bitfields. Ie handle an expression, evaluate it and insert
- the result in an some bitfield. ( ex: 5 bits in a short field of a opcode)
- */
-
-#ifndef __bit_fix_h__
-#define __bit_fix_h__
-
-struct bit_fix {
- int fx_bit_size; /* Length of bitfield */
- int fx_bit_offset; /* Bit offset to bitfield */
- long fx_bit_base; /* Where do we apply the bitfix.
- If this is zero, default is assumed. */
- long fx_bit_base_adj; /* Adjustment of base */
- long fx_bit_max; /* Signextended max for bitfield */
- long fx_bit_min; /* Signextended min for bitfield */
- long fx_bit_add; /* Or mask, used for huffman prefix */
-};
-typedef struct bit_fix bit_fixS;
-
-#endif /* __bit_fix_h__ */
-
- /* end of bit_fix.h */
diff --git a/gnu/usr.bin/as/cond.c b/gnu/usr.bin/as/cond.c
deleted file mode 100644
index 6fd46b6..0000000
--- a/gnu/usr.bin/as/cond.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/* cond.c - conditional assembly pseudo-ops, and .include
- Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "as.h"
-
-#include "obstack.h"
-
-/* This is allocated to grow and shrink as .ifdef/.endif pairs are scanned. */
-struct obstack cond_obstack;
-
-struct file_line
-{
- char *file;
- unsigned int line;
-}; /* file_line */
-
-/* This is what we push and pop. */
-struct conditional_frame
- {
- struct file_line if_file_line; /* the source file & line number of the "if" */
- struct file_line else_file_line; /* the source file & line of the "else" */
- struct conditional_frame *previous_cframe;
- int else_seen; /* have we seen an else yet? */
- int ignoring; /* if we are currently ignoring input. */
- int dead_tree; /* if a conditional at a higher level is ignoring input. */
- }; /* conditional_frame */
-
-static void initialize_cframe PARAMS ((struct conditional_frame *cframe));
-
-static struct conditional_frame *current_cframe = NULL;
-
-void
-s_ifdef (arg)
- int arg;
-{
- register char *name; /* points to name of symbol */
- register struct symbol *symbolP; /* Points to symbol */
- struct conditional_frame cframe;
-
- SKIP_WHITESPACE (); /* Leading whitespace is part of operand. */
- name = input_line_pointer;
-
- if (!is_name_beginner (*name))
- {
- as_bad ("invalid identifier for \".ifdef\"");
- obstack_1grow (&cond_obstack, 0);
- }
- else
- {
- get_symbol_end ();
- ++input_line_pointer;
- symbolP = symbol_find (name);
-
- initialize_cframe (&cframe);
- cframe.ignoring = cframe.dead_tree || !((symbolP != 0) ^ arg);
- current_cframe = (struct conditional_frame *) obstack_copy (&cond_obstack, &cframe, sizeof (cframe));
- } /* if a valid identifyer name */
-
- return;
-} /* s_ifdef() */
-
-void
-s_if (arg)
- int arg;
-{
- expressionS operand;
- struct conditional_frame cframe;
-
- SKIP_WHITESPACE (); /* Leading whitespace is part of operand. */
- expression (&operand);
-
-#ifdef notyet
- if (operand.X_op != O_constant)
- as_bad ("non-constant expression in \".if\" statement");
-#else
- if (operand.X_add_symbol != NULL || operand.X_subtract_symbol != NULL) {
- as_bad("non-constant expression in \".if\" statement");
- } /* bad condition */
-#endif
-
- /* If the above error is signaled, this will dispatch
- using an undefined result. No big deal. */
- initialize_cframe (&cframe);
- cframe.ignoring = cframe.dead_tree || !((operand.X_add_number != 0) ^ arg);
- current_cframe = (struct conditional_frame *) obstack_copy (&cond_obstack, &cframe, sizeof (cframe));
- return;
-} /* s_if() */
-
-void
-s_endif (arg)
- int arg;
-{
- struct conditional_frame *hold;
-
- if (current_cframe == NULL)
- {
- as_bad ("\".endif\" without \".if\"");
- }
- else
- {
- hold = current_cframe;
- current_cframe = current_cframe->previous_cframe;
- obstack_free (&cond_obstack, hold);
- } /* if one pop too many */
-
- return;
-} /* s_endif() */
-
-void
-s_else (arg)
- int arg;
-{
- if (current_cframe == NULL)
- {
- as_bad (".else without matching .if - ignored");
-
- }
- else if (current_cframe->else_seen)
- {
- as_bad ("duplicate \"else\" - ignored");
- as_bad_where (current_cframe->else_file_line.file,
- current_cframe->else_file_line.line,
- "here is the previous \"else\"");
- as_bad_where (current_cframe->if_file_line.file,
- current_cframe->if_file_line.line,
- "here is the previous \"if\"");
- }
- else
- {
- as_where (&current_cframe->else_file_line.file,
- &current_cframe->else_file_line.line);
-
- if (!current_cframe->dead_tree)
- {
- current_cframe->ignoring = !current_cframe->ignoring;
- } /* if not a dead tree */
-
- current_cframe->else_seen = 1;
- } /* if error else do it */
-
- return;
-} /* s_else() */
-
-void
-s_ifeqs (arg)
- int arg;
-{
- as_bad ("ifeqs not implemented.");
-
- return;
-} /* s_ifeqs() */
-
-void
-s_end (arg)
- int arg;
-{
- return;
-} /* s_end() */
-
-int
-ignore_input ()
-{
- /* We cannot ignore certain pseudo ops. */
- if (input_line_pointer[-1] == '.'
- && ((input_line_pointer[0] == 'i'
- && (!strncmp (input_line_pointer, "if", 2)
- || !strncmp (input_line_pointer, "ifdef", 5)
- || !strncmp (input_line_pointer, "ifndef", 6)))
- || (input_line_pointer[0] == 'e'
- && (!strncmp (input_line_pointer, "else", 4)
- || !strncmp (input_line_pointer, "endif", 5)))))
- {
- return 0;
- }
-
- return ((current_cframe != NULL) && (current_cframe->ignoring));
-} /* ignore_input() */
-
-static void
-initialize_cframe (cframe)
- struct conditional_frame *cframe;
-{
- memset (cframe, 0, sizeof (*cframe));
- as_where (&cframe->if_file_line.file,
- &cframe->if_file_line.line);
- cframe->previous_cframe = current_cframe;
- cframe->dead_tree = current_cframe != NULL && current_cframe->ignoring;
-
- return;
-} /* initialize_cframe() */
-
-/*
- * Local Variables:
- * fill-column: 131
- * comment-column: 0
- * End:
- */
-
-/* end of cond.c */
diff --git a/gnu/usr.bin/as/config-gas.com b/gnu/usr.bin/as/config-gas.com
deleted file mode 100644
index 48e2e49..0000000
--- a/gnu/usr.bin/as/config-gas.com
+++ /dev/null
@@ -1,76 +0,0 @@
-$!
-$! This file sets things up to build gas on a VMS system to generate object
-$! files for a VMS system. We do not use the configure script, since we
-$! do not have /bin/sh to execute it.
-$!
-$! If you are running this file, then obviously the host is vax-dec-vms.
-$!
-$gas_host="vms"
-$!
-$cpu_type="vax"
-$emulation="generic"
-$obj_format="vms"
-$atof="vax"
-$!
-$! host specific information
-$call link host.h [.config]ho-'gas_host'.h
-$!
-$! Target specific information
-$call link targ-cpu.c [.config]tc-'cpu_type'.c
-$call link targ-cpu.h [.config]tc-'cpu_type'.h
-$call link targ-env.h [.config]te-'emulation'.h
-$!
-$! Code to handle the object file format.
-$call link obj-format.h [.config]obj-'obj_format'.h
-$call link obj-format.c [.config]obj-'obj_format'.c
-$!
-$! Code to handle floating point.
-$call link atof-targ.c [.config]atof-'atof'.c
-$!
-$!
-$! Create the file version.opt, which helps identify the executalbe.
-$!
-$search version.c version_string,"="/match=and/output=t.tmp
-$open ifile$ t.tmp
-$read ifile$ line
-$close ifile$
-$delete/nolog t.tmp;
-$ijk=f$locate("""",line)+1
-$line=f$extract(ijk,f$length(line)-ijk,line)
-$ijk=f$locate("""",line)
-$line=f$extract(0,ijk,line)
-$ijk=f$locate("\n",line)
-$line=f$extract(0,ijk,line)
-$!
-$i=0
-$loop:
-$elm=f$element(i," ",line)
-$if elm.eqs."" then goto no_ident
-$if (elm.les."9").and.(elm.ges."0") then goto write_ident
-$i=i+1
-$goto loop
-$!
-$no_ident:
-$elm="?.??"
-$!
-$!
-$write_ident:
-$open ifile$ version.opt/write
-$write ifile$ "ident="+""""+elm+""""
-$close ifile$
-$!
-$ !
-$ if f$search("config.status") .nes. "" then delete config.status.*
-$ open/write file config.status
-$ write file "Links are now set up for use with a vax running VMS."
-$ close file
-$ type config.status
-$exit
-$!
-$!
-$link:
-$subroutine
-$if f$search(p1).nes."" then delete/nolog 'p1';
-$copy 'p2' 'p1'
-$write sys$output "Linked ''p2' to ''p1'."
-$endsubroutine
diff --git a/gnu/usr.bin/as/config/Makefile.hp300 b/gnu/usr.bin/as/config/Makefile.hp300
deleted file mode 100644
index 4b89820..0000000
--- a/gnu/usr.bin/as/config/Makefile.hp300
+++ /dev/null
@@ -1,7 +0,0 @@
-# from: @(#)Makefile.hp300 6.1 (Berkeley) 3/3/91
-# $Id$
-
-CFLAGS+= -Dm68851
-SRCS+= tc-m68k.c atof-ieee.c
-
-gas_target= m68k
diff --git a/gnu/usr.bin/as/config/Makefile.i386 b/gnu/usr.bin/as/config/Makefile.i386
deleted file mode 100644
index dab2459..0000000
--- a/gnu/usr.bin/as/config/Makefile.i386
+++ /dev/null
@@ -1,5 +0,0 @@
-# from: @(#)Makefile.i386 6.1 (Berkeley) 3/3/91
-# $Id$
-
-CFLAGS+= -DNON_BROKEN_WORDS -DPIC
-SRCS+= tc-i386.c atof-ieee.c
diff --git a/gnu/usr.bin/as/config/Makefile.pc532 b/gnu/usr.bin/as/config/Makefile.pc532
deleted file mode 100644
index 5eb588d..0000000
--- a/gnu/usr.bin/as/config/Makefile.pc532
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Id$
-
-SRCS+= tc-ns32k.c atof-ns32k.c
-
-CFLAGS+= -DNS32532 -DNS32381
-
-gas_target= ns32k
diff --git a/gnu/usr.bin/as/config/Makefile.sparc b/gnu/usr.bin/as/config/Makefile.sparc
deleted file mode 100644
index 25608f1..0000000
--- a/gnu/usr.bin/as/config/Makefile.sparc
+++ /dev/null
@@ -1,5 +0,0 @@
-# from: @(#)Makefile.i386 6.1 (Berkeley) 3/3/91
-# $Id$
-
-CFLAGS+= -DNON_BROKEN_WORDS -DPIC
-SRCS+= tc-sparc.c atof-ieee.c
diff --git a/gnu/usr.bin/as/config/Makefile.vax b/gnu/usr.bin/as/config/Makefile.vax
deleted file mode 100644
index eb2bca8..0000000
--- a/gnu/usr.bin/as/config/Makefile.vax
+++ /dev/null
@@ -1,4 +0,0 @@
-# from: @(#)Makefile.vax 6.1 (Berkeley) 3/3/91
-# $Id$
-
-SRCS+= tc-vax.c atof-vax.c
diff --git a/gnu/usr.bin/as/config/aout.h b/gnu/usr.bin/as/config/aout.h
deleted file mode 100644
index 9856cb0..0000000
--- a/gnu/usr.bin/as/config/aout.h
+++ /dev/null
@@ -1,440 +0,0 @@
-/* This file is aout.h
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef __A_OUT_GNU_H__
-#define __A_OUT_GNU_H__
-
-enum reloc_type {
-
-#ifdef TC_M88K
- RELOC_LO16, /* lo16(sym) */
- RELOC_HI16, /* hi16(sym) */
- RELOC_PC16, /* bb0, bb1, bcnd */
- RELOC_PC26, /* br, bsr */
- RELOC_32, /* jump tables, etc */
- RELOC_IW16, /* global access through linker regs 28 */
- NO_RELOC,
-#else /* not TC_M88K */
-#ifdef TC_I860
-
-/* NOTE: three bits max, see struct reloc_info_i860.r_type */
- NO_RELOC = 0, BRADDR, LOW0, LOW1, LOW2, LOW3, LOW4, SPLIT0, SPLIT1, SPLIT2, RELOC_32,
-
-#else /* not TC_I860 */
-
- RELOC_8, RELOC_16, RELOC_32, /* simple relocations */
- RELOC_DISP8, RELOC_DISP16, RELOC_DISP32, /* pc-rel displacement */
- RELOC_WDISP30, RELOC_WDISP22,
- RELOC_HI22, RELOC_22,
- RELOC_13, RELOC_LO10,
- RELOC_SFA_BASE, RELOC_SFA_OFF13,
- RELOC_BASE10, RELOC_BASE13, RELOC_BASE22, /* P.I.C. (base-relative) */
- RELOC_PC10, RELOC_PC22, /* for some sort of pc-rel P.I.C. (?) */
- RELOC_JMP_TBL, /* P.I.C. jump table */
- RELOC_SEGOFF16, /* reputedly for shared libraries somehow */
- RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE,
-#ifndef TC_SPARC
- RELOC_11,
- RELOC_WDISP2_14,
- RELOC_WDISP19,
- RELOC_HHI22,
- RELOC_HLO10,
-
- /* 29K relocation types */
- RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH,
-
- RELOC_WDISP14, RELOC_WDISP21,
-#endif /* not TC_SPARC */
- NO_RELOC,
-
-#ifdef TC_I386
- /* Used internally by gas */
- RELOC_GOT,
- RELOC_GOTOFF,
-#endif
-
-#endif /* not TC_I860 */
-#endif /* not TC_M88K */
-};
-
-
-#ifdef TC_I860
- /* NOTE: two bits max, see reloc_info_i860.r_type */
-enum highlow_type {
- NO_SPEC = 0, PAIR, HIGH, HIGHADJ,
-};
-#endif /* TC_I860 */
-
-
-#define __GNU_EXEC_MACROS__
-
-#ifndef __STRUCT_EXEC_OVERRIDE__
-
-/* This is the layout on disk of a Unix V7, Berkeley, SunOS, Vax Ultrix
- "struct exec". Don't assume that on this machine, the "struct exec"
- will lay out the same sizes or alignments. */
-
-struct exec_bytes {
- unsigned char a_info[4];
- unsigned char a_text[4];
- unsigned char a_data[4];
- unsigned char a_bss[4];
- unsigned char a_syms[4];
- unsigned char a_entry[4];
- unsigned char a_trsize[4];
- unsigned char a_drsize[4];
-};
-
-/* How big the "struct exec" is on disk */
-#define EXEC_BYTES_SIZE (8 * 4)
-
-/* This is the layout in memory of a "struct exec" while we process it. */
-
-struct exec
-{
- unsigned long a_info; /* Use macros N_MAGIC, etc for access */
- unsigned a_text; /* length of text, in bytes */
- unsigned a_data; /* length of data, in bytes */
- unsigned a_bss; /* length of uninitialized data area for file, in bytes */
- unsigned a_syms; /* length of symbol table data in file, in bytes */
- unsigned a_entry; /* start address */
- unsigned a_trsize; /* length of relocation info for text, in bytes */
- unsigned a_drsize; /* length of relocation info for data, in bytes */
-};
-
-#endif /* __STRUCT_EXEC_OVERRIDE__ */
-
-/* these go in the N_MACHTYPE field */
-/* These symbols could be defined by code from Suns...punt 'em */
-#undef M_UNKNOWN
-#undef M_68010
-#undef M_68020
-#undef M_SPARC
-enum machine_type {
- M_UNKNOWN = 0,
- M_68010 = 1,
- M_68020 = 2,
- M_SPARC = 3,
- /* skip a bunch so we don't run into any of sun's numbers */
- M_386 = 100,
- M_29K = 101,
- M_RS6000 = 102, /* IBM RS/6000 */
- /* HP/BSD formats */
- M_HP200 = 200, /* hp200 (68010) BSD binary */
- M_HP300 = 300, /* hp300 (68020+68881) BSD binary */
- M_HPUX23 = 0x020C, /* hp200/300 HPUX binary */
-};
-
-#define N_MAGIC(exec) ((exec).a_info & 0xffff)
-#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
-#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
-#define N_SET_INFO(exec, magic, type, flags) \
- ((exec).a_info = ((magic) & 0xffff) \
- | (((int)(type) & 0xff) << 16) \
- | (((flags) & 0xff) << 24))
-#define N_SET_MAGIC(exec, magic) \
- ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
-
-#define N_SET_MACHTYPE(exec, machtype) \
- ((exec).a_info = \
- ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
-
-#define N_SET_FLAGS(exec, flags) \
- ((exec).a_info = \
- ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
-
-/* Code indicating object file or impure executable. */
-#define OMAGIC 0407
-/* Code indicating pure executable. */
-#define NMAGIC 0410
-/* Code indicating demand-paged executable. */
-#define ZMAGIC 0413
-
-/* Virtual Address of text segment from the a.out file. For OMAGIC,
- (almost always "unlinked .o's" these days), should be zero.
- For linked files, should reflect reality if we know it. */
-
-#ifndef N_TXTADDR
-#define N_TXTADDR(x) (N_MAGIC(x) == OMAGIC? 0 : TEXT_START_ADDR)
-#endif
-
-#ifndef N_BADMAG
-#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
- && N_MAGIC(x) != NMAGIC \
- && N_MAGIC(x) != ZMAGIC)
-#endif
-
-/* By default, segment size is constant. But on some machines, it can
- be a function of the a.out header (e.g. machine type). */
-#ifndef N_SEGSIZE
-#define N_SEGSIZE(x) SEGMENT_SIZE
-#endif
-
- /* This complexity is for encapsulated COFF support */
-#ifndef _N_HDROFF
-#define _N_HDROFF(x) (N_SEGSIZE(x) - sizeof (struct exec))
-#endif
-
-#ifndef N_TXTOFF
-#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? \
- _N_HDROFF((x)) + sizeof (struct exec) : \
- sizeof (struct exec))
-#endif
-
-
-#ifndef N_DATOFF
-#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
-#endif
-
-#ifndef N_TRELOFF
-#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
-#endif
-
-#ifndef N_DRELOFF
-#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
-#endif
-
-#ifndef N_SYMOFF
-#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
-#endif
-
-#ifndef N_STROFF
-#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
-#endif
-
-/* Address of text segment in memory after it is loaded. */
-#ifndef N_TXTADDR
-#define N_TXTADDR(x) 0
-#endif
-
-#ifndef N_DATADDR
-#define N_DATADDR(x) \
- (N_MAGIC(x) == OMAGIC? (N_TXTADDR(x)+(x).a_text) \
- : (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1))))
-#endif
-
-/* Address of bss segment in memory after it is loaded. */
-#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
-
-struct nlist {
- union {
- char *n_name;
- struct nlist *n_next;
- long n_strx;
- } n_un;
- unsigned char n_type;
- char n_other;
- short n_desc;
- unsigned long n_value;
-};
-
-#define N_UNDF 0
-#define N_ABS 2
-#define N_TEXT 4
-#define N_DATA 6
-#define N_BSS 8
-#define N_COMM 0x12 /* common (visible in shared lib commons) */
-#define N_FN 0x1F /* File name of a .o file */
-
-/* Note: N_EXT can only usefully be OR-ed with N_UNDF, N_ABS, N_TEXT,
- N_DATA, or N_BSS. When the low-order bit of other types is set,
- (e.g. N_WARNING versus N_FN), they are two different types. */
-#define N_EXT 1
-#define N_TYPE 036
-#define N_STAB 0340
-
-/* The following type indicates the definition of a symbol as being
- an indirect reference to another symbol. The other symbol
- appears as an undefined reference, immediately following this symbol.
-
- Indirection is asymmetrical. The other symbol's value will be used
- to satisfy requests for the indirect symbol, but not vice versa.
- If the other symbol does not have a definition, libraries will
- be searched to find a definition. */
-
-#define N_INDR 0xa
-
-/* The following type indicates the size of the symbol it refers to */
-#define N_SIZE 0xc
-
-/* The following symbols refer to set elements.
- All the N_SET[ATDB] symbols with the same name form one set.
- Space is allocated for the set in the text section, and each set
- element's value is stored into one word of the space.
- The first word of the space is the length of the set (number of elements).
-
- The address of the set is made into an N_SETV symbol
- whose name is the same as the name of the set.
- This symbol acts like a N_DATA global symbol
- in that it can satisfy undefined external references. */
-
-/* These appear as input to LD, in a .o file. */
-#define N_SETA 0x14 /* Absolute set element symbol */
-#define N_SETT 0x16 /* Text set element symbol */
-#define N_SETD 0x18 /* Data set element symbol */
-#define N_SETB 0x1A /* Bss set element symbol */
-
-/* This is output from LD. */
-#define N_SETV 0x1C /* Pointer to set vector in data area. */
-
-/* Warning symbol. The text gives a warning message, the next symbol
- in the table will be undefined. When the symbol is referenced, the
- message is printed. */
-
-#define N_WARNING 0x1e
-
-/* This structure describes a single relocation to be performed.
- The text-relocation section of the file is a vector of these structures,
- all of which apply to the text section.
- Likewise, the data-relocation section applies to the data section. */
-
-/* The following enum and struct were borrowed from SunOS's
- /usr/include/sun4/a.out.h and extended to handle
- other machines. It is currently used on SPARC and AMD 29000.
-
- reloc_ext_bytes is how it looks on disk. reloc_info_extended is
- how we might process it on a native host. */
-
-struct reloc_ext_bytes {
- unsigned char r_address[4];
- unsigned char r_index[3];
- unsigned char r_bits[1];
- unsigned char r_addend[4];
-};
-
-struct reloc_info_i860
-{
- unsigned long r_address;
- /*
- * Using bit fields here is a bad idea because the order is not portable. :-(
- */
- unsigned int r_symbolnum: 24;
- unsigned int r_pcrel : 1;
- unsigned int r_extern : 1;
- /* combining the two field simplifies the argument passing in "new_fix()" */
- /* and is compatible with the existing Sparc #ifdef's */
- /* r_type: highlow_type - bits 5,4; reloc_type - bits 3-0 */
- unsigned int r_type : 6;
- long r_addend;
-};
-
-
-#define RELOC_EXT_BITS_EXTERN_BIG 0x80
-#define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
-
-#define RELOC_EXT_BITS_TYPE_BIG 0x1F
-#define RELOC_EXT_BITS_TYPE_SH_BIG 0
-#define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
-#define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
-
-#define RELOC_EXT_SIZE 12 /* Bytes per relocation entry */
-
-struct reloc_info_extended
-{
- unsigned long r_address;
- unsigned int r_index:24;
-# define r_symbolnum r_index
- unsigned r_extern:1;
- unsigned :2;
- /* RS/6000 compiler does not support enum bitfield
- enum reloc_type r_type:5; */
- enum reloc_type r_type;
- long int r_addend;
-};
-
-/* The standard, old-fashioned, Berkeley compatible relocation struct */
-
-struct reloc_std_bytes {
- unsigned char r_address[4];
- unsigned char r_index[3];
- unsigned char r_bits[1];
-};
-
-#define RELOC_STD_BITS_PCREL_BIG 0x80
-#define RELOC_STD_BITS_PCREL_LITTLE 0x01
-
-#define RELOC_STD_BITS_LENGTH_BIG 0x60
-#define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
-#define RELOC_STD_BITS_LENGTH_LITTLE 0x06
-#define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
-
-#define RELOC_STD_BITS_EXTERN_BIG 0x10
-#define RELOC_STD_BITS_EXTERN_LITTLE 0x08
-
-#define RELOC_STD_BITS_BASEREL_BIG 0x08
-#define RELOC_STD_BITS_BASEREL_LITTLE 0x08
-
-#define RELOC_STD_BITS_JMPTABLE_BIG 0x04
-#define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
-
-#define RELOC_STD_BITS_RELATIVE_BIG 0x02
-#define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
-
-#define RELOC_STD_SIZE 8 /* Bytes per relocation entry */
-
-#ifndef CUSTOM_RELOC_FORMAT
-struct relocation_info {
- /* Address (within segment) to be relocated. */
- int r_address;
- /* The meaning of r_symbolnum depends on r_extern. */
-#if defined(TC_NS32K) && !defined(TE_SEQUENT)
- unsigned int r_symbolnum:22;
- unsigned int r_copy:1;
- unsigned int r_relative:1;
-#else
- unsigned int r_symbolnum:24;
-#endif
- /* Nonzero means value is a pc-relative offset
- and it should be relocated for changes in its own address
- as well as for changes in the symbol or section specified. */
- unsigned int r_pcrel:1;
- /* Length (as exponent of 2) of the field to be relocated.
- Thus, a value of 2 indicates 1<<2 bytes. */
- unsigned int r_length:2;
- /* 1 => relocate with value of symbol.
- r_symbolnum is the index of the symbol
- in file's the symbol table.
- 0 => relocate with the address of a segment.
- r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
- (the N_EXT bit may be set also, but signifies nothing). */
- unsigned int r_extern:1;
-#ifdef TC_NS32K
-#ifdef TE_SEQUENT
- unsigned int r_bsr:1;
-#else
- unsigned int r_jmptable:1;
-#endif
- unsigned int r_disp:2;
- unsigned int r_baserel:1;
-#else
- /* The next three bits are for SunOS shared libraries, and seem to
- be undocumented. */
- unsigned int r_baserel:1; /* Linkage table relative */
- unsigned int r_jmptable:1; /* pc-relative to jump table */
- unsigned int r_relative:1; /* "relative relocation" */
- /* unused */
- unsigned int r_pad:1; /* Padding -- set to zero */
-#endif
-};
-#endif /* CUSTOM_RELOC_FORMAT */
-
-#endif /* __A_OUT_GNU_H__ */
-
-/* end of aout.h */
diff --git a/gnu/usr.bin/as/config/atof-ieee.c b/gnu/usr.bin/as/config/atof-ieee.c
deleted file mode 100644
index da9d730..0000000
--- a/gnu/usr.bin/as/config/atof-ieee.c
+++ /dev/null
@@ -1,525 +0,0 @@
-/* atof_ieee.c - turn a Flonum into an IEEE floating point number
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id: atof-ieee.c,v 1.7 1997/02/22 15:44:21 peter Exp $";
-#endif
-
-#include "as.h"
-
-extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */
-
-#ifndef NULL
-#define NULL (0)
-#endif
-
-extern char EXP_CHARS[];
-/* Precision in LittleNums. */
-#define MAX_PRECISION (6)
-#define F_PRECISION (2)
-#define D_PRECISION (4)
-#define X_PRECISION (6)
-#define P_PRECISION (6)
-
-/* Length in LittleNums of guard bits. */
-#define GUARD (2)
-
-static unsigned long mask[] = {
- 0x00000000,
- 0x00000001,
- 0x00000003,
- 0x00000007,
- 0x0000000f,
- 0x0000001f,
- 0x0000003f,
- 0x0000007f,
- 0x000000ff,
- 0x000001ff,
- 0x000003ff,
- 0x000007ff,
- 0x00000fff,
- 0x00001fff,
- 0x00003fff,
- 0x00007fff,
- 0x0000ffff,
- 0x0001ffff,
- 0x0003ffff,
- 0x0007ffff,
- 0x000fffff,
- 0x001fffff,
- 0x003fffff,
- 0x007fffff,
- 0x00ffffff,
- 0x01ffffff,
- 0x03ffffff,
- 0x07ffffff,
- 0x0fffffff,
- 0x1fffffff,
- 0x3fffffff,
- 0x7fffffff,
- 0xffffffff,
-};
-
-
-static int bits_left_in_littlenum;
-static int littlenums_left;
-static LITTLENUM_TYPE *littlenum_pointer;
-
-static int
- next_bits (number_of_bits)
-int number_of_bits;
-{
- int return_value;
-
- if (!littlenums_left)
- return(0);
- if (number_of_bits >= bits_left_in_littlenum) {
- return_value = mask[bits_left_in_littlenum] & *littlenum_pointer;
- number_of_bits -= bits_left_in_littlenum;
- return_value <<= number_of_bits;
-
- if (--littlenums_left) {
- bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
- --littlenum_pointer;
- return_value |= (*littlenum_pointer >> bits_left_in_littlenum) & mask[number_of_bits];
- }
- } else {
- bits_left_in_littlenum -= number_of_bits;
- return_value = mask[number_of_bits] & (*littlenum_pointer >> bits_left_in_littlenum);
- }
- return(return_value);
-}
-
-/* Num had better be less than LITTLENUM_NUMBER_OF_BITS */
-static void
- unget_bits(num)
-int num;
-{
- if (!littlenums_left) {
- ++littlenum_pointer;
- ++littlenums_left;
- bits_left_in_littlenum = num;
- } else if (bits_left_in_littlenum + num > LITTLENUM_NUMBER_OF_BITS) {
- bits_left_in_littlenum = num - (LITTLENUM_NUMBER_OF_BITS - bits_left_in_littlenum);
- ++littlenum_pointer;
- ++littlenums_left;
- } else
- bits_left_in_littlenum += num;
-}
-
-static void
- make_invalid_floating_point_number(words)
-LITTLENUM_TYPE *words;
-{
- as_bad("cannot create floating-point number");
- /* Zero the leftmost bit */
- words[0] = (LITTLENUM_TYPE) ((unsigned) -1) >> 1;
- words[1] = (LITTLENUM_TYPE) -1;
- words[2] = (LITTLENUM_TYPE) -1;
- words[3] = (LITTLENUM_TYPE) -1;
- words[4] = (LITTLENUM_TYPE) -1;
- words[5] = (LITTLENUM_TYPE) -1;
-}
-
-/***********************************************************************\
- * Warning: this returns 16-bit LITTLENUMs. It is up to the caller *
- * to figure out any alignment problems and to conspire for the *
- * bytes/word to be emitted in the right order. Bigendians beware! *
- * *
- \***********************************************************************/
-
-/* Note that atof-ieee always has X and P precisions enabled. it is up
- to md_atof to filter them out if the target machine does not support
- them. */
-
-char * /* Return pointer past text consumed. */
- atof_ieee(str, what_kind, words)
-char *str; /* Text to convert to binary. */
-char what_kind; /* 'd', 'f', 'g', 'h' */
-LITTLENUM_TYPE *words; /* Build the binary here. */
-{
- static LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
- /* Extra bits for zeroed low-order bits. */
- /* The 1st MAX_PRECISION are zeroed, */
- /* the last contain flonum bits. */
- char *return_value;
- int precision; /* Number of 16-bit words in the format. */
- long exponent_bits;
- FLONUM_TYPE save_gen_flonum;
-
- /* We have to save the generic_floating_point_number because it
- contains storage allocation about the array of LITTLENUMs
- where the value is actually stored. We will allocate our
- own array of littlenums below, but have to restore the global
- one on exit. */
- save_gen_flonum = generic_floating_point_number;
-
- return_value = str;
- generic_floating_point_number.low = bits + MAX_PRECISION;
- generic_floating_point_number.high = NULL;
- generic_floating_point_number.leader = NULL;
- generic_floating_point_number.exponent = 0;
- generic_floating_point_number.sign = '\0';
-
- /* Use more LittleNums than seems */
- /* necessary: the highest flonum may have */
- /* 15 leading 0 bits, so could be useless. */
-
- memset(bits, '\0', sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
-
- switch (what_kind) {
- case 'f':
- case 'F':
- case 's':
- case 'S':
- precision = F_PRECISION;
- exponent_bits = 8;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- precision = D_PRECISION;
- exponent_bits = 11;
- break;
-
- case 'x':
- case 'X':
- case 'e':
- case 'E':
- precision = X_PRECISION;
- exponent_bits = 15;
- break;
-
- case 'p':
- case 'P':
-
- precision = P_PRECISION;
- exponent_bits = -1;
- break;
-
- default:
- make_invalid_floating_point_number(words);
- return(NULL);
- }
-
- generic_floating_point_number.high = generic_floating_point_number.low + precision - 1 + GUARD;
-
- if (atof_generic(&return_value, ".", EXP_CHARS, &generic_floating_point_number)) {
- /* as_bad("Error converting floating point number (Exponent overflow?)"); */
- make_invalid_floating_point_number(words);
- return(NULL);
- }
- gen_to_words(words, precision, exponent_bits);
-
- /* Restore the generic_floating_point_number's storage alloc
- (and everything else). */
- generic_floating_point_number = save_gen_flonum;
-
- return(return_value);
-}
-
-/* Turn generic_floating_point_number into a real float/double/extended */
-int gen_to_words(words, precision, exponent_bits)
-LITTLENUM_TYPE *words;
-int precision;
-long exponent_bits;
-{
- int return_value = 0;
-
- long exponent_1;
- long exponent_2;
- long exponent_3;
- long exponent_4;
- int exponent_skippage;
- LITTLENUM_TYPE word1;
- LITTLENUM_TYPE *lp;
-
- if (generic_floating_point_number.low > generic_floating_point_number.leader) {
- /* 0.0e0 seen. */
- if (generic_floating_point_number.sign == '+')
- words[0] = 0x0000;
- else
- words[0] = 0x8000;
- memset(&words[1], '\0', sizeof(LITTLENUM_TYPE) * (precision - 1));
- return(return_value);
- }
-
- /* NaN: Do the right thing */
- if (generic_floating_point_number.sign == 0) {
- if (precision == F_PRECISION) {
- words[0] = 0x7fff;
- words[1] = 0xffff;
- } else {
- words[0] = 0x7fff;
- words[1] = 0xffff;
- words[2] = 0xffff;
- words[3] = 0xffff;
- }
- return return_value;
- } else if (generic_floating_point_number.sign == 'P') {
- /* +INF: Do the right thing */
- if (precision == F_PRECISION) {
- words[0] = 0x7f80;
- words[1] = 0;
- } else {
- words[0] = 0x7ff0;
- words[1] = 0;
- words[2] = 0;
- words[3] = 0;
- }
- return(return_value);
- } else if (generic_floating_point_number.sign == 'N') {
- /* Negative INF */
- if (precision == F_PRECISION) {
- words[0] = 0xff80;
- words[1] = 0x0;
- } else {
- words[0] = 0xfff0;
- words[1] = 0x0;
- words[2] = 0x0;
- words[3] = 0x0;
- }
- return(return_value);
- }
- /*
- * The floating point formats we support have:
- * Bit 15 is sign bit.
- * Bits 14:n are excess-whatever exponent.
- * Bits n-1:0 (if any) are most significant bits of fraction.
- * Bits 15:0 of the next word(s) are the next most significant bits.
- *
- * So we need: number of bits of exponent, number of bits of
- * mantissa.
- */
- bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
- littlenum_pointer = generic_floating_point_number.leader;
- littlenums_left = 1 + generic_floating_point_number.leader - generic_floating_point_number.low;
- /* Seek (and forget) 1st significant bit */
- for (exponent_skippage = 0; !next_bits(1); ++exponent_skippage) ;;
- exponent_1 = generic_floating_point_number.exponent + generic_floating_point_number.leader
- + 1 - generic_floating_point_number.low;
- /* Radix LITTLENUM_RADIX, point just higher than generic_floating_point_number.leader. */
- exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
- /* Radix 2. */
- exponent_3 = exponent_2 - exponent_skippage;
- /* Forget leading zeros, forget 1st bit. */
- exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
- /* Offset exponent. */
-
- lp = words;
-
- /* Word 1. Sign, exponent and perhaps high bits. */
- word1 = (generic_floating_point_number.sign == '+') ? 0 : (1 << (LITTLENUM_NUMBER_OF_BITS - 1));
-
- /* Assume 2's complement integers. */
- if (exponent_4 < 1 && exponent_4 >= -62) {
- int prec_bits;
- int num_bits;
-
- unget_bits(1);
- num_bits = -exponent_4;
- prec_bits = LITTLENUM_NUMBER_OF_BITS * precision - (exponent_bits + 1 + num_bits);
- if (precision == X_PRECISION && exponent_bits == 15)
- prec_bits -= LITTLENUM_NUMBER_OF_BITS + 1;
-
- if (num_bits >= LITTLENUM_NUMBER_OF_BITS - exponent_bits) {
- /* Bigger than one littlenum */
- num_bits -= (LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits;
- *lp++ = word1;
- if (num_bits + exponent_bits + 1 >= precision * LITTLENUM_NUMBER_OF_BITS) {
- /* Exponent overflow */
- make_invalid_floating_point_number(words);
- return(return_value);
- }
- if (precision == X_PRECISION && exponent_bits == 15) {
- *lp++ = 0;
- *lp++ = 0;
- num_bits -= LITTLENUM_NUMBER_OF_BITS - 1;
- }
- while (num_bits >= LITTLENUM_NUMBER_OF_BITS) {
- num_bits -= LITTLENUM_NUMBER_OF_BITS;
- *lp++ = 0;
- }
- if (num_bits)
- *lp++ = next_bits(LITTLENUM_NUMBER_OF_BITS - (num_bits));
- } else {
- if (precision == X_PRECISION && exponent_bits == 15) {
- *lp++ = word1;
- *lp++ = 0;
- if (num_bits == LITTLENUM_NUMBER_OF_BITS) {
- *lp++ = 0;
- *lp++ = next_bits(LITTLENUM_NUMBER_OF_BITS - 1);
- } else if (num_bits == LITTLENUM_NUMBER_OF_BITS - 1)
- *lp++ = 0;
- else
- *lp++ = next_bits(LITTLENUM_NUMBER_OF_BITS - 1 - num_bits);
- num_bits = 0;
- } else {
- word1 |= next_bits((LITTLENUM_NUMBER_OF_BITS - 1) - (exponent_bits + num_bits));
- *lp++ = word1;
- }
- }
- while (lp < words + precision)
- *lp++ = next_bits(LITTLENUM_NUMBER_OF_BITS);
-
- /* Round the mantissa up, but don't change the number */
- if (next_bits(1)) {
- --lp;
- if (prec_bits > LITTLENUM_NUMBER_OF_BITS) {
- int n = 0;
- int tmp_bits;
-
- n = 0;
- tmp_bits = prec_bits;
- while (tmp_bits > LITTLENUM_NUMBER_OF_BITS) {
- if (lp[n] != (LITTLENUM_TYPE) - 1)
- break;
- --n;
- tmp_bits -= LITTLENUM_NUMBER_OF_BITS;
- }
- if (tmp_bits > LITTLENUM_NUMBER_OF_BITS || (lp[n] & mask[tmp_bits]) != mask[tmp_bits]) {
- unsigned long carry;
-
- for (carry = 1; carry && (lp >= words); lp --) {
- carry = *lp + carry;
- *lp = carry;
- carry >>= LITTLENUM_NUMBER_OF_BITS;
- }
- }
- } else if ((*lp & mask[prec_bits]) != mask[prec_bits])
- lp++;
- }
-
- return return_value;
- } else if (exponent_4 & ~ mask[exponent_bits]) {
- /*
- * Exponent overflow. Lose immediately.
- */
-
- /*
- * We leave return_value alone: admit we read the
- * number, but return a floating exception
- * because we can't encode the number.
- */
- make_invalid_floating_point_number (words);
- return return_value;
- } else {
- word1 |= (exponent_4 << ((LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits))
- | next_bits ((LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits);
- }
-
- *lp++ = word1;
-
- /* X_PRECISION is special: it has 16 bits of zero in the middle,
- followed by a 1 bit. */
- if (exponent_bits == 15 && precision == X_PRECISION) {
- *lp++ = 0;
- *lp++ = 1 << (LITTLENUM_NUMBER_OF_BITS) | next_bits(LITTLENUM_NUMBER_OF_BITS - 1);
- }
-
- /* The rest of the words are just mantissa bits. */
- while (lp < words + precision)
- *lp++ = next_bits(LITTLENUM_NUMBER_OF_BITS);
-
- if (next_bits(1)) {
- unsigned long carry;
- /*
- * Since the NEXT bit is a 1, round UP the mantissa.
- * The cunning design of these hidden-1 floats permits
- * us to let the mantissa overflow into the exponent, and
- * it 'does the right thing'. However, we lose if the
- * highest-order bit of the lowest-order word flips.
- * Is that clear?
- */
-
- /* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
- Please allow at least 1 more bit in carry than is in a LITTLENUM.
- We need that extra bit to hold a carry during a LITTLENUM carry
- propagation. Another extra bit (kept 0) will assure us that we
- don't get a sticky sign bit after shifting right, and that
- permits us to propagate the carry without any masking of bits.
- #endif */
- for (carry = 1, lp--; carry && (lp >= words); lp--) {
- carry = *lp + carry;
- *lp = carry;
- carry >>= LITTLENUM_NUMBER_OF_BITS;
- }
- if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1))) {
- /* We leave return_value alone: admit we read the
- * number, but return a floating exception
- * because we can't encode the number.
- */
- *words &= ~(1 << (LITTLENUM_NUMBER_OF_BITS - 1));
- /* make_invalid_floating_point_number (words); */
- /* return return_value; */
- }
- }
- return (return_value);
-}
-
-/* This routine is a real kludge. Someone really should do it better, but
- I'm too lazy, and I don't understand this stuff all too well anyway
- (JF)
- */
-void
- int_to_gen(x)
-long x;
-{
- char buf[20];
- char *bufp;
-
- sprintf(buf,"%ld",x);
- bufp = &buf[0];
- if (atof_generic(&bufp, ".", EXP_CHARS, &generic_floating_point_number))
- as_bad("Error converting number to floating point (Exponent overflow?)");
-}
-
-#ifdef TEST
-char *
- print_gen(gen)
-FLONUM_TYPE *gen;
-{
- FLONUM_TYPE f;
- LITTLENUM_TYPE arr[10];
- double dv;
- float fv;
- static char sbuf[40];
-
- if (gen) {
- f = generic_floating_point_number;
- generic_floating_point_number = *gen;
- }
- gen_to_words(&arr[0], 4, 11);
- memcpy(&dv, &arr[0], sizeof(double));
- sprintf(sbuf, "%x %x %x %x %.14G ", arr[0], arr[1], arr[2], arr[3], dv);
- gen_to_words(&arr[0], 2, 8);
- memcpy(&fv, &arr[0], sizeof(float));
- sprintf(sbuf + strlen(sbuf), "%x %x %.12g\n", arr[0], arr[1], fv);
-
- if (gen) {
- generic_floating_point_number = f;
- }
-
- return(sbuf);
-}
-#endif
-
-/* end of atof-ieee.c */
diff --git a/gnu/usr.bin/as/config/atof-ns32k.c b/gnu/usr.bin/as/config/atof-ns32k.c
deleted file mode 100644
index 06b748e..0000000
--- a/gnu/usr.bin/as/config/atof-ns32k.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/* atof_ns32k.c - turn a Flonum into a ns32k floating point number
- Copyright (C) 1987 Free Software Foundation, Inc.
-
-This file is part of GAS, the GNU Assembler.
-
-GAS is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GAS 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 GAS; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* this is atof-m68k.c hacked for ns32k */
-
-#include "as.h"
-
-extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */
-
-extern char EXP_CHARS[];
- /* Precision in LittleNums. */
-#define MAX_PRECISION (4)
-#define F_PRECISION (2)
-#define D_PRECISION (4)
-
- /* Length in LittleNums of guard bits. */
-#define GUARD (2)
-
-int /* Number of chars in flonum type 'letter'. */
-atof_sizeof (letter)
- char letter;
-{
- int return_value;
-
- /*
- * Permitting uppercase letters is probably a bad idea.
- * Please use only lower-cased letters in case the upper-cased
- * ones become unsupported!
- */
- switch (letter)
- {
- case 'f':
- return_value = F_PRECISION;
- break;
-
- case 'd':
- return_value = D_PRECISION;
- break;
-
- default:
- return_value = 0;
- break;
- }
- return (return_value);
-}
-
-static unsigned long int mask[] = {
- 0x00000000,
- 0x00000001,
- 0x00000003,
- 0x00000007,
- 0x0000000f,
- 0x0000001f,
- 0x0000003f,
- 0x0000007f,
- 0x000000ff,
- 0x000001ff,
- 0x000003ff,
- 0x000007ff,
- 0x00000fff,
- 0x00001fff,
- 0x00003fff,
- 0x00007fff,
- 0x0000ffff,
- 0x0001ffff,
- 0x0003ffff,
- 0x0007ffff,
- 0x000fffff,
- 0x001fffff,
- 0x003fffff,
- 0x007fffff,
- 0x00ffffff,
- 0x01ffffff,
- 0x03ffffff,
- 0x07ffffff,
- 0x0fffffff,
- 0x1fffffff,
- 0x3fffffff,
- 0x7fffffff,
- 0xffffffff
- };
-
-static int bits_left_in_littlenum;
-static int littlenums_left;
-static LITTLENUM_TYPE * littlenum_pointer;
-
-static int
-next_bits (number_of_bits)
- int number_of_bits;
-{
- int return_value;
-
- if (!littlenums_left)
- return 0;
- if (number_of_bits >= bits_left_in_littlenum)
- {
- return_value = mask[bits_left_in_littlenum] & *littlenum_pointer;
- number_of_bits -= bits_left_in_littlenum;
- return_value <<= number_of_bits;
- if (littlenums_left) {
- bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
- littlenum_pointer --;
- --littlenums_left;
- return_value |= (*littlenum_pointer>>bits_left_in_littlenum) & mask[number_of_bits];
- }
- }
- else
- {
- bits_left_in_littlenum -= number_of_bits;
- return_value = mask[number_of_bits] & (*littlenum_pointer>>bits_left_in_littlenum);
- }
- return (return_value);
-}
-
-static void
-make_invalid_floating_point_number (words)
- LITTLENUM_TYPE * words;
-{
- /* Zero the leftmost bit */
- words[0]= (LITTLENUM_TYPE) ((unsigned)-1)>>1;
- words[1]= (LITTLENUM_TYPE) -1;
- words[2]= (LITTLENUM_TYPE) -1;
- words[3]= (LITTLENUM_TYPE) -1;
-}
-
-/***********************************************************************\
-* *
-* Warning: this returns 16-bit LITTLENUMs, because that is *
-* what the VAX thinks in. It is up to the caller to figure *
-* out any alignment problems and to conspire for the bytes/word *
-* to be emitted in the right order. Bigendians beware! *
-* *
-\***********************************************************************/
-
-char * /* Return pointer past text consumed. */
-atof_ns32k (str, what_kind, words)
- char * str; /* Text to convert to binary. */
- char what_kind; /* 'd', 'f', 'g', 'h' */
- LITTLENUM_TYPE * words; /* Build the binary here. */
-{
- FLONUM_TYPE f;
- LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
- /* Extra bits for zeroed low-order bits. */
- /* The 1st MAX_PRECISION are zeroed, */
- /* the last contain flonum bits. */
- char * return_value;
- int precision; /* Number of 16-bit words in the format. */
- long int exponent_bits;
-
- long int exponent_1;
- long int exponent_2;
- long int exponent_3;
- long int exponent_4;
- int exponent_skippage;
- LITTLENUM_TYPE word1;
- LITTLENUM_TYPE * lp;
-
- return_value = str;
- f.low = bits + MAX_PRECISION;
- f.high = NULL;
- f.leader = NULL;
- f.exponent = NULL;
- f.sign = '\0';
-
- /* Use more LittleNums than seems */
- /* necessary: the highest flonum may have */
- /* 15 leading 0 bits, so could be useless. */
-
- bzero (bits, sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
-
- switch (what_kind) {
- case 'f':
- precision = F_PRECISION;
- exponent_bits = 8;
- break;
-
- case 'd':
- precision = D_PRECISION;
- exponent_bits = 11;
- break;
-
- default:
- make_invalid_floating_point_number (words);
- return NULL;
- }
-
- f.high = f.low + precision - 1 + GUARD;
-
- if (atof_generic (& return_value, ".", EXP_CHARS, & f)) {
- as_warn("Error converting floating point number (Exponent overflow?)");
- make_invalid_floating_point_number (words);
- return NULL;
- }
-
- if (f.low > f.leader) {
- /* 0.0e0 seen. */
- bzero (words, sizeof(LITTLENUM_TYPE) * precision);
- return return_value;
- }
-
- if (f.sign != '+' && f.sign != '-') {
- make_invalid_floating_point_number(words);
- return NULL;
- }
-
-
- /*
- * All vaxen floating_point formats (so far) have:
- * Bit 15 is sign bit.
- * Bits 14:n are excess-whatever exponent.
- * Bits n-1:0 (if any) are most significant bits of fraction.
- * Bits 15:0 of the next word are the next most significant bits.
- * And so on for each other word.
- *
- * So we need: number of bits of exponent, number of bits of
- * mantissa.
- */
- bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
- littlenum_pointer = f.leader;
- littlenums_left = 1 + f.leader-f.low;
- /* Seek (and forget) 1st significant bit */
- for (exponent_skippage = 0;! next_bits(1); exponent_skippage ++)
- ;
- exponent_1 = f.exponent + f.leader + 1 - f.low;
- /* Radix LITTLENUM_RADIX, point just higher than f.leader. */
- exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
- /* Radix 2. */
- exponent_3 = exponent_2 - exponent_skippage;
- /* Forget leading zeros, forget 1st bit. */
- exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
- /* Offset exponent. */
-
- if (exponent_4 & ~ mask[exponent_bits]) {
- /*
- * Exponent overflow. Lose immediately.
- */
-
- /*
- * We leave return_value alone: admit we read the
- * number, but return a floating exception
- * because we can't encode the number.
- */
-
- as_warn("Exponent overflow in floating-point number");
- make_invalid_floating_point_number (words);
- return return_value;
- }
- lp = words;
-
- /* Word 1. Sign, exponent and perhaps high bits. */
- /* Assume 2's complement integers. */
- word1 = ((exponent_4 & mask[exponent_bits]) << (15 - exponent_bits)) |
- ((f.sign == '+') ? 0 : 0x8000) | next_bits (15 - exponent_bits);
- * lp ++ = word1;
-
- /* The rest of the words are just mantissa bits. */
- for (; lp < words + precision; lp++)
- * lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
-
- if (next_bits (1)) {
- unsigned long int carry;
- /*
- * Since the NEXT bit is a 1, round UP the mantissa.
- * The cunning design of these hidden-1 floats permits
- * us to let the mantissa overflow into the exponent, and
- * it 'does the right thing'. However, we lose if the
- * highest-order bit of the lowest-order word flips.
- * Is that clear?
- */
-
-
-/* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
- Please allow at least 1 more bit in carry than is in a LITTLENUM.
- We need that extra bit to hold a carry during a LITTLENUM carry
- propagation. Another extra bit (kept 0) will assure us that we
- don't get a sticky sign bit after shifting right, and that
- permits us to propagate the carry without any masking of bits.
-#endif */
- for (carry = 1, lp --; carry && (lp >= words); lp --) {
- carry = * lp + carry;
- * lp = carry;
- carry >>= LITTLENUM_NUMBER_OF_BITS;
- }
- if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) ) {
- /* We leave return_value alone: admit we read the
- * number, but return a floating exception
- * because we can't encode the number.
- */
- make_invalid_floating_point_number (words);
- return return_value;
- }
- }
- return (return_value);
-}
-
-/* This is really identical to atof_ns32k except for some details */
-
-gen_to_words(words,precision,exponent_bits)
-LITTLENUM_TYPE *words;
-long int exponent_bits;
-{
- int return_value=0;
-
- long int exponent_1;
- long int exponent_2;
- long int exponent_3;
- long int exponent_4;
- int exponent_skippage;
- LITTLENUM_TYPE word1;
- LITTLENUM_TYPE * lp;
-
- if (generic_floating_point_number.low > generic_floating_point_number.leader) {
- /* 0.0e0 seen. */
- bzero (words, sizeof(LITTLENUM_TYPE) * precision);
- return return_value;
- }
-
- /*
- * All vaxen floating_point formats (so far) have:
- * Bit 15 is sign bit.
- * Bits 14:n are excess-whatever exponent.
- * Bits n-1:0 (if any) are most significant bits of fraction.
- * Bits 15:0 of the next word are the next most significant bits.
- * And so on for each other word.
- *
- * So we need: number of bits of exponent, number of bits of
- * mantissa.
- */
- bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
- littlenum_pointer = generic_floating_point_number.leader;
- littlenums_left = 1+generic_floating_point_number.leader - generic_floating_point_number.low;
- /* Seek (and forget) 1st significant bit */
- for (exponent_skippage = 0;! next_bits(1); exponent_skippage ++)
- ;
- exponent_1 = generic_floating_point_number.exponent + generic_floating_point_number.leader + 1 -
- generic_floating_point_number.low;
- /* Radix LITTLENUM_RADIX, point just higher than generic_floating_point_number.leader. */
- exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
- /* Radix 2. */
- exponent_3 = exponent_2 - exponent_skippage;
- /* Forget leading zeros, forget 1st bit. */
- exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
- /* Offset exponent. */
-
- if (exponent_4 & ~ mask[exponent_bits]) {
- /*
- * Exponent overflow. Lose immediately.
- */
-
- /*
- * We leave return_value alone: admit we read the
- * number, but return a floating exception
- * because we can't encode the number.
- */
-
- make_invalid_floating_point_number (words);
- return return_value;
- }
- lp = words;
-
- /* Word 1. Sign, exponent and perhaps high bits. */
- /* Assume 2's complement integers. */
- word1 = ((exponent_4 & mask[exponent_bits]) << (15 - exponent_bits)) |
- ((generic_floating_point_number.sign == '+') ? 0 : 0x8000) | next_bits (15 - exponent_bits);
- * lp ++ = word1;
-
- /* The rest of the words are just mantissa bits. */
- for (; lp < words + precision; lp++)
- * lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
-
- if (next_bits (1)) {
- unsigned long int carry;
- /*
- * Since the NEXT bit is a 1, round UP the mantissa.
- * The cunning design of these hidden-1 floats permits
- * us to let the mantissa overflow into the exponent, and
- * it 'does the right thing'. However, we lose if the
- * highest-order bit of the lowest-order word flips.
- * Is that clear?
- */
-
-
-/* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
- Please allow at least 1 more bit in carry than is in a LITTLENUM.
- We need that extra bit to hold a carry during a LITTLENUM carry
- propagation. Another extra bit (kept 0) will assure us that we
- don't get a sticky sign bit after shifting right, and that
- permits us to propagate the carry without any masking of bits.
-#endif */
- for (carry = 1, lp --; carry && (lp >= words); lp --) {
- carry = * lp + carry;
- * lp = carry;
- carry >>= LITTLENUM_NUMBER_OF_BITS;
- }
- if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) ) {
- /* We leave return_value alone: admit we read the
- * number, but return a floating exception
- * because we can't encode the number.
- */
- make_invalid_floating_point_number (words);
- return return_value;
- }
- }
- return (return_value);
-}
-
-/* This routine is a real kludge. Someone really should do it better, but
- I'm too lazy, and I don't understand this stuff all too well anyway
- (JF)
- */
-void int_to_gen(x)
-long x;
-{
- char buf[20];
- char *bufp;
-
- sprintf(buf,"%ld",x);
- bufp= &buf[0];
- if (atof_generic(&bufp,".", EXP_CHARS, &generic_floating_point_number))
- as_warn("Error converting number to floating point (Exponent overflow?)");
-}
diff --git a/gnu/usr.bin/as/config/atof-tahoe.c b/gnu/usr.bin/as/config/atof-tahoe.c
deleted file mode 100644
index 64d00ea..0000000
--- a/gnu/usr.bin/as/config/atof-tahoe.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/* atof_tahoe.c - turn a string into a Tahoe floating point number
- Copyright (C) 1987 Free Software Foundation, Inc.
- */
-
-/* This is really a simplified version of atof_vax.c. I glommed it wholesale
- and then shaved it down. I don't even know how it works. (Don't you find
- my honesty refreshing? bowen@cs.Buffalo.EDU (Devon E Bowen)
-
- I don't allow uppercase letters in the precision descrpitors. Ie 'f' and
- 'd' are allowed but 'F' and 'D' aren't */
-
-#include "as.h"
-
-/* Precision in LittleNums. */
-#define MAX_PRECISION (4)
-#define D_PRECISION (4)
-#define F_PRECISION (2)
-
-/* Precision in chars. */
-#define D_PRECISION_CHARS (8)
-#define F_PRECISION_CHARS (4)
-
- /* Length in LittleNums of guard bits. */
-#define GUARD (2)
-
-static const long int mask [] = {
- 0x00000000,
- 0x00000001,
- 0x00000003,
- 0x00000007,
- 0x0000000f,
- 0x0000001f,
- 0x0000003f,
- 0x0000007f,
- 0x000000ff,
- 0x000001ff,
- 0x000003ff,
- 0x000007ff,
- 0x00000fff,
- 0x00001fff,
- 0x00003fff,
- 0x00007fff,
- 0x0000ffff,
- 0x0001ffff,
- 0x0003ffff,
- 0x0007ffff,
- 0x000fffff,
- 0x001fffff,
- 0x003fffff,
- 0x007fffff,
- 0x00ffffff,
- 0x01ffffff,
- 0x03ffffff,
- 0x07ffffff,
- 0x0fffffff,
- 0x1fffffff,
- 0x3fffffff,
- 0x7fffffff,
- 0xffffffff
- };
-
-
-/* Shared between flonum_gen2tahoe and next_bits */
-static int bits_left_in_littlenum;
-static LITTLENUM_TYPE * littlenum_pointer;
-static LITTLENUM_TYPE * littlenum_end;
-
-#if __STDC__ == 1
-
-int flonum_gen2tahoe(int format_letter, FLONUM_TYPE *f, LITTLENUM_TYPE *words);
-
-#else /* not __STDC__ */
-
-int flonum_gen2tahoe();
-
-#endif /* not __STDC__ */
-
-
-static int
-next_bits (number_of_bits)
- int number_of_bits;
-{
- int return_value;
-
- if(littlenum_pointer<littlenum_end)
- return 0;
- if (number_of_bits >= bits_left_in_littlenum)
- {
- return_value = mask [bits_left_in_littlenum] & * littlenum_pointer;
- number_of_bits -= bits_left_in_littlenum;
- return_value <<= number_of_bits;
- bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
- littlenum_pointer --;
- if(littlenum_pointer>=littlenum_end)
- return_value |= ((*littlenum_pointer) >> (bits_left_in_littlenum)) &
- mask [number_of_bits];
- }
- else
- {
- bits_left_in_littlenum -= number_of_bits;
- return_value = mask [number_of_bits] &
- ((*littlenum_pointer) >> bits_left_in_littlenum);
- }
- return (return_value);
-}
-
-static void
-make_invalid_floating_point_number (words)
- LITTLENUM_TYPE * words;
-{
- *words = 0x8000; /* Floating Reserved Operand Code */
-}
-
-static int /* 0 means letter is OK. */
-what_kind_of_float (letter, precisionP, exponent_bitsP)
- char letter; /* In: lowercase please. What kind of float? */
- int * precisionP; /* Number of 16-bit words in the float. */
- long int * exponent_bitsP; /* Number of exponent bits. */
-{
- int retval; /* 0: OK. */
-
- retval = 0;
- switch (letter)
- {
- case 'f':
- * precisionP = F_PRECISION;
- * exponent_bitsP = 8;
- break;
-
- case 'd':
- * precisionP = D_PRECISION;
- * exponent_bitsP = 8;
- break;
-
- default:
- retval = 69;
- break;
- }
- return (retval);
-}
-
-/***********************************************************************\
-* *
-* Warning: this returns 16-bit LITTLENUMs, because that is *
-* what the VAX thinks in. It is up to the caller to figure *
-* out any alignment problems and to conspire for the bytes/word *
-* to be emitted in the right order. Bigendians beware! *
-* *
-\***********************************************************************/
-
-char * /* Return pointer past text consumed. */
-atof_tahoe (str, what_kind, words)
- char * str; /* Text to convert to binary. */
- char what_kind; /* 'd', 'f', 'g', 'h' */
- LITTLENUM_TYPE * words; /* Build the binary here. */
-{
- FLONUM_TYPE f;
- LITTLENUM_TYPE bits [MAX_PRECISION + MAX_PRECISION + GUARD];
- /* Extra bits for zeroed low-order bits. */
- /* The 1st MAX_PRECISION are zeroed, */
- /* the last contain flonum bits. */
- char * return_value;
- int precision; /* Number of 16-bit words in the format. */
- long int exponent_bits;
-
- return_value = str;
- f . low = bits + MAX_PRECISION;
- f . high = NULL;
- f . leader = NULL;
- f . exponent = NULL;
- f . sign = '\0';
-
- if (what_kind_of_float (what_kind, & precision, & exponent_bits))
- {
- return_value = NULL; /* We lost. */
- make_invalid_floating_point_number (words);
- }
- if (return_value)
- {
- memset(bits, '\0', sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
-
- /* Use more LittleNums than seems */
- /* necessary: the highest flonum may have */
- /* 15 leading 0 bits, so could be useless. */
- f . high = f . low + precision - 1 + GUARD;
-
- if (atof_generic (& return_value, ".", "eE", & f))
- {
- make_invalid_floating_point_number (words);
- return_value = NULL; /* we lost */
- }
- else
- {
- if (flonum_gen2tahoe (what_kind, & f, words))
- {
- return_value = NULL;
- }
- }
- }
- return (return_value);
-}
-
-/*
- * In: a flonum, a Tahoe floating point format.
- * Out: a Tahoe floating-point bit pattern.
- */
-
-int /* 0: OK. */
-flonum_gen2tahoe (format_letter, f, words)
- char format_letter; /* One of 'd' 'f'. */
- FLONUM_TYPE * f;
- LITTLENUM_TYPE * words; /* Deliver answer here. */
-{
- LITTLENUM_TYPE * lp;
- int precision;
- long int exponent_bits;
- int return_value; /* 0 == OK. */
-
- return_value = what_kind_of_float(format_letter,&precision,&exponent_bits);
- if (return_value != 0)
- {
- make_invalid_floating_point_number (words);
- }
- else
- {
- if (f -> low > f -> leader)
- {
- /* 0.0e0 seen. */
- memset(words, '\0', sizeof(LITTLENUM_TYPE) * precision);
- }
- else
- {
- long int exponent_1;
- long int exponent_2;
- long int exponent_3;
- long int exponent_4;
- int exponent_skippage;
- LITTLENUM_TYPE word1;
-
- /* JF: Deal with new Nan, +Inf and -Inf codes */
- if(f->sign!='-' && f->sign!='+') {
- make_invalid_floating_point_number(words);
- return return_value;
- }
- /*
- * All tahoe floating_point formats have:
- * Bit 15 is sign bit.
- * Bits 14:n are excess-whatever exponent.
- * Bits n-1:0 (if any) are most significant bits of fraction.
- * Bits 15:0 of the next word are the next most significant bits.
- * And so on for each other word.
- *
- * So we need: number of bits of exponent, number of bits of
- * mantissa.
- */
-
- bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
- littlenum_pointer = f -> leader;
- littlenum_end = f->low;
- /* Seek (and forget) 1st significant bit */
- for (exponent_skippage = 0;
- ! next_bits(1);
- exponent_skippage ++)
- {
- }
- exponent_1 = f -> exponent + f -> leader + 1 - f -> low;
- /* Radix LITTLENUM_RADIX, point just higher than f -> leader. */
- exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
- /* Radix 2. */
- exponent_3 = exponent_2 - exponent_skippage;
- /* Forget leading zeros, forget 1st bit. */
- exponent_4 = exponent_3 + (1 << (exponent_bits - 1));
- /* Offset exponent. */
-
- if (exponent_4 & ~ mask [exponent_bits])
- {
- /*
- * Exponent overflow. Lose immediately.
- */
-
- make_invalid_floating_point_number (words);
-
- /*
- * We leave return_value alone: admit we read the
- * number, but return a floating exception
- * because we can't encode the number.
- */
- }
- else
- {
- lp = words;
-
- /* Word 1. Sign, exponent and perhaps high bits. */
- /* Assume 2's complement integers. */
- word1 = ((exponent_4 & mask [exponent_bits]) << (15 - exponent_bits))
- | ((f -> sign == '+') ? 0 : 0x8000)
- | next_bits (15 - exponent_bits);
- * lp ++ = word1;
-
- /* The rest of the words are just mantissa bits. */
- for (; lp < words + precision; lp++)
- {
- * lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
- }
-
- if (next_bits (1))
- {
- /*
- * Since the NEXT bit is a 1, round UP the mantissa.
- * The cunning design of these hidden-1 floats permits
- * us to let the mantissa overflow into the exponent, and
- * it 'does the right thing'. However, we lose if the
- * highest-order bit of the lowest-order word flips.
- * Is that clear?
- */
-
- unsigned long int carry;
-
- /*
- #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
- Please allow at least 1 more bit in carry than is in a LITTLENUM.
- We need that extra bit to hold a carry during a LITTLENUM carry
- propagation. Another extra bit (kept 0) will assure us that we
- don't get a sticky sign bit after shifting right, and that
- permits us to propagate the carry without any masking of bits.
- #endif
- */
- for (carry = 1, lp --;
- carry && (lp >= words);
- lp --)
- {
- carry = * lp + carry;
- * lp = carry;
- carry >>= LITTLENUM_NUMBER_OF_BITS;
- }
-
- if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) )
- {
- make_invalid_floating_point_number (words);
- /*
- * We leave return_value alone: admit we read the
- * number, but return a floating exception
- * because we can't encode the number.
- */
- }
- } /* if (we needed to round up) */
- } /* if (exponent overflow) */
- } /* if (0.0e0) */
- } /* if (float_type was OK) */
- return (return_value);
-}
-
-/*
- * md_atof()
- *
- * In: input_line_pointer -> the 1st character of a floating-point
- * number.
- * 1 letter denoting the type of statement that wants a
- * binary floating point number returned.
- * Address of where to build floating point literal.
- * Assumed to be 'big enough'.
- * Address of where to return size of literal (in chars).
- *
- * Out: Input_line_pointer -> of next char after floating number.
- * Error message, or "".
- * Floating point literal.
- * Number of chars we used for the literal.
- */
-
-char *
-md_atof (what_statement_type, literalP, sizeP)
- char what_statement_type;
- char * literalP;
- int * sizeP;
-{
- LITTLENUM_TYPE words [MAX_PRECISION];
- register char kind_of_float;
- register int number_of_chars;
- register LITTLENUM_TYPE * littlenum_pointer;
-
- switch (what_statement_type)
- {
- case 'f': /* .ffloat */
- case 'd': /* .dfloat */
- kind_of_float = what_statement_type;
- break;
-
- default:
- kind_of_float = 0;
- break;
- };
-
- if (kind_of_float)
- {
- register LITTLENUM_TYPE * limit;
-
- input_line_pointer = atof_tahoe (input_line_pointer,
- kind_of_float,
- words);
- /*
- * The atof_tahoe() builds up 16-bit numbers.
- * Since the assembler may not be running on
- * a different-endian machine, be very careful about
- * converting words to chars.
- */
- number_of_chars = (kind_of_float == 'f' ? F_PRECISION_CHARS :
- (kind_of_float == 'd' ? D_PRECISION_CHARS : 0));
- know(number_of_chars<=MAX_PRECISION*sizeof(LITTLENUM_TYPE));
- limit = words + (number_of_chars / sizeof(LITTLENUM_TYPE));
- for (littlenum_pointer = words;
- littlenum_pointer < limit;
- littlenum_pointer ++)
- {
- md_number_to_chars(literalP,*littlenum_pointer,
- sizeof(LITTLENUM_TYPE));
- literalP += sizeof(LITTLENUM_TYPE);
- };
- }
- else
- {
- number_of_chars = 0;
- };
-
- * sizeP = number_of_chars;
- return (kind_of_float ? "" : "Bad call to md_atof()");
-} /* md_atof() */
-
-/* atof_tahoe.c */
diff --git a/gnu/usr.bin/as/config/atof-vax.c b/gnu/usr.bin/as/config/atof-vax.c
deleted file mode 100644
index 56ad35a..0000000
--- a/gnu/usr.bin/as/config/atof-vax.c
+++ /dev/null
@@ -1,497 +0,0 @@
-/* atof_vax.c - turn a Flonum into a VAX floating point number
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* JF added these two for md_atof() */
-#include "as.h"
-
-/* Precision in LittleNums. */
-#define MAX_PRECISION (8)
-#define H_PRECISION (8)
-#define G_PRECISION (4)
-#define D_PRECISION (4)
-#define F_PRECISION (2)
-
-/* Length in LittleNums of guard bits. */
-#define GUARD (2)
-
-#if __STDC__ == 1
-
-int flonum_gen2vax(int format_letter, FLONUM_TYPE *f, LITTLENUM_TYPE *words);
-
-#else /* not __STDC__ */
-
-int flonum_gen2vax();
-
-#endif /* not __STDC__ */
-
-int /* Number of chars in flonum type 'letter'. */
- atof_vax_sizeof (letter)
-char letter;
-{
- int return_value;
-
- /*
- * Permitting uppercase letters is probably a bad idea.
- * Please use only lower-cased letters in case the upper-cased
- * ones become unsupported!
- */
- switch (letter)
- {
- case 'f':
- case 'F':
- return_value = 4;
- break;
-
- case 'd':
- case 'D':
- case 'g':
- case 'G':
- return_value = 8;
- break;
-
- case 'h':
- case 'H':
- return_value = 16;
- break;
-
- default:
- return_value = 0;
- break;
- }
- return (return_value);
-} /* atof_vax_sizeof */
-
-static const long mask[] = {
- 0x00000000,
- 0x00000001,
- 0x00000003,
- 0x00000007,
- 0x0000000f,
- 0x0000001f,
- 0x0000003f,
- 0x0000007f,
- 0x000000ff,
- 0x000001ff,
- 0x000003ff,
- 0x000007ff,
- 0x00000fff,
- 0x00001fff,
- 0x00003fff,
- 0x00007fff,
- 0x0000ffff,
- 0x0001ffff,
- 0x0003ffff,
- 0x0007ffff,
- 0x000fffff,
- 0x001fffff,
- 0x003fffff,
- 0x007fffff,
- 0x00ffffff,
- 0x01ffffff,
- 0x03ffffff,
- 0x07ffffff,
- 0x0fffffff,
- 0x1fffffff,
- 0x3fffffff,
- 0x7fffffff,
- 0xffffffff
- };
-
-
-/* Shared between flonum_gen2vax and next_bits */
-static int bits_left_in_littlenum;
-static LITTLENUM_TYPE * littlenum_pointer;
-static LITTLENUM_TYPE * littlenum_end;
-
-static int
- next_bits (number_of_bits)
-int number_of_bits;
-{
- int return_value;
-
- if (littlenum_pointer<littlenum_end)
- return 0;
- if (number_of_bits >= bits_left_in_littlenum)
- {
- return_value = mask[bits_left_in_littlenum] & * littlenum_pointer;
- number_of_bits -= bits_left_in_littlenum;
- return_value <<= number_of_bits;
- bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
- littlenum_pointer --;
- if (littlenum_pointer >= littlenum_end)
- return_value |= ( (* littlenum_pointer) >> (bits_left_in_littlenum) ) & mask[number_of_bits];
- }
- else
- {
- bits_left_in_littlenum -= number_of_bits;
- return_value = mask[number_of_bits] & ( (* littlenum_pointer) >> bits_left_in_littlenum);
- }
- return (return_value);
-}
-
-static void
- make_invalid_floating_point_number (words)
-LITTLENUM_TYPE * words;
-{
- * words = 0x8000; /* Floating Reserved Operand Code */
-}
-
-static int /* 0 means letter is OK. */
- what_kind_of_float (letter, precisionP, exponent_bitsP)
-char letter; /* In: lowercase please. What kind of float? */
-int * precisionP; /* Number of 16-bit words in the float. */
-long * exponent_bitsP; /* Number of exponent bits. */
-{
- int retval; /* 0: OK. */
-
- retval = 0;
- switch (letter)
- {
- case 'f':
- * precisionP = F_PRECISION;
- * exponent_bitsP = 8;
- break;
-
- case 'd':
- * precisionP = D_PRECISION;
- * exponent_bitsP = 8;
- break;
-
- case 'g':
- * precisionP = G_PRECISION;
- * exponent_bitsP = 11;
- break;
-
- case 'h':
- * precisionP = H_PRECISION;
- * exponent_bitsP = 15;
- break;
-
- default:
- retval = 69;
- break;
- }
- return (retval);
-}
-
-/***********************************************************************\
- * *
- * Warning: this returns 16-bit LITTLENUMs, because that is *
- * what the VAX thinks in. It is up to the caller to figure *
- * out any alignment problems and to conspire for the bytes/word *
- * to be emitted in the right order. Bigendians beware! *
- * *
- \***********************************************************************/
-
-char * /* Return pointer past text consumed. */
- atof_vax(str, what_kind, words)
-char *str; /* Text to convert to binary. */
-char what_kind; /* 'd', 'f', 'g', 'h' */
-LITTLENUM_TYPE *words; /* Build the binary here. */
-{
- FLONUM_TYPE f;
- LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
- /* Extra bits for zeroed low-order bits. */
- /* The 1st MAX_PRECISION are zeroed, */
- /* the last contain flonum bits. */
- char *return_value;
- int precision; /* Number of 16-bit words in the format. */
- long exponent_bits;
-
- return_value = str;
- f.low = bits + MAX_PRECISION;
- f.high = NULL;
- f.leader = NULL;
- f.exponent = NULL;
- f.sign = '\0';
-
- if (what_kind_of_float (what_kind, & precision, & exponent_bits)) {
- return_value = NULL; /* We lost. */
- make_invalid_floating_point_number (words);
- }
-
- if (return_value) {
- memset(bits, '\0', sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
-
- /* Use more LittleNums than seems */
- /* necessary: the highest flonum may have */
- /* 15 leading 0 bits, so could be useless. */
- f.high = f.low + precision - 1 + GUARD;
-
- if (atof_generic (& return_value, ".", "eE", & f)) {
- make_invalid_floating_point_number (words);
- return_value = NULL; /* we lost */
- } else {
- if (flonum_gen2vax(what_kind, & f, words)) {
- return_value = NULL;
- }
- }
- }
- return(return_value);
-} /* atof_vax() */
-
-/*
- * In: a flonum, a vax floating point format.
- * Out: a vax floating-point bit pattern.
- */
-
-int /* 0: OK. */
- flonum_gen2vax (format_letter, f, words)
-char format_letter; /* One of 'd' 'f' 'g' 'h'. */
-FLONUM_TYPE *f;
-LITTLENUM_TYPE *words; /* Deliver answer here. */
-{
- LITTLENUM_TYPE *lp;
- int precision;
- long exponent_bits;
- int return_value; /* 0 == OK. */
-
- return_value = what_kind_of_float(format_letter, &precision, &exponent_bits);
-
- if (return_value != 0) {
- make_invalid_floating_point_number (words);
- } else {
- if (f->low > f->leader) {
- /* 0.0e0 seen. */
-memset(words, '\0', sizeof(LITTLENUM_TYPE) * precision);
- } else {
- long exponent_1;
- long exponent_2;
- long exponent_3;
- long exponent_4;
- int exponent_skippage;
- LITTLENUM_TYPE word1;
-
- /* JF: Deal with new Nan, +Inf and -Inf codes */
- if (f->sign != '-' && f->sign != '+') {
- make_invalid_floating_point_number(words);
- return return_value;
- }
- /*
- * All vaxen floating_point formats (so far) have:
- * Bit 15 is sign bit.
- * Bits 14:n are excess-whatever exponent.
- * Bits n-1:0 (if any) are most significant bits of fraction.
- * Bits 15:0 of the next word are the next most significant bits.
- * And so on for each other word.
- *
- * All this to be compatible with a KF11?? (Which is still faster
- * than lots of vaxen I can think of, but it also has higher
- * maintenance costs ... sigh).
- *
- * So we need: number of bits of exponent, number of bits of
- * mantissa.
- */
-
-#ifdef NEVER /******* This zeroing seems redundant - Dean 3may86 **********/
- /*
- * No matter how few bits we got back from the atof()
- * routine, add enough zero littlenums so the rest of the
- * code won't run out of "significant" bits in the mantissa.
- */
- {
- LITTLENUM_TYPE *ltp;
- for (ltp = f->leader + 1;
- ltp <= f->low + precision;
- ltp++) {
- *ltp = 0;
- }
- }
-#endif
-
- bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
- littlenum_pointer = f->leader;
- littlenum_end = f->low;
- /* Seek (and forget) 1st significant bit */
- for (exponent_skippage = 0;
- ! next_bits(1);
- exponent_skippage ++) ;;
-
- exponent_1 = f->exponent + f->leader + 1 - f->low;
- /* Radix LITTLENUM_RADIX, point just higher than f->leader. */
- exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
- /* Radix 2. */
- exponent_3 = exponent_2 - exponent_skippage;
- /* Forget leading zeros, forget 1st bit. */
- exponent_4 = exponent_3 + (1 << (exponent_bits - 1));
- /* Offset exponent. */
-
- if (exponent_4 & ~mask[exponent_bits]) {
- /*
- * Exponent overflow. Lose immediately.
- */
-
- make_invalid_floating_point_number (words);
-
- /*
- * We leave return_value alone: admit we read the
- * number, but return a floating exception
- * because we can't encode the number.
- */
- } else {
- lp = words;
-
- /* Word 1. Sign, exponent and perhaps high bits. */
- /* Assume 2's complement integers. */
- word1 = (((exponent_4 &mask[exponent_bits]) << (15 - exponent_bits))
- | ((f->sign == '+') ? 0 : 0x8000)
- | next_bits(15 - exponent_bits));
- *lp++ = word1;
-
- /* The rest of the words are just mantissa bits. */
- for (; lp < words + precision; lp++) {
- *lp = next_bits(LITTLENUM_NUMBER_OF_BITS);
- }
-
- if (next_bits (1)) {
- /*
- * Since the NEXT bit is a 1, round UP the mantissa.
- * The cunning design of these hidden-1 floats permits
- * us to let the mantissa overflow into the exponent, and
- * it 'does the right thing'. However, we lose if the
- * highest-order bit of the lowest-order word flips.
- * Is that clear?
- */
-
- unsigned long carry;
-
- /*
- #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
- Please allow at least 1 more bit in carry than is in a LITTLENUM.
- We need that extra bit to hold a carry during a LITTLENUM carry
- propagation. Another extra bit (kept 0) will assure us that we
- don't get a sticky sign bit after shifting right, and that
- permits us to propagate the carry without any masking of bits.
- #endif
- */
- for (carry = 1, lp--;
- carry && (lp >= words);
- lp--) {
- carry = *lp + carry;
- *lp = carry;
- carry >>= LITTLENUM_NUMBER_OF_BITS;
- }
-
- if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1))) {
- make_invalid_floating_point_number(words);
- /*
- * We leave return_value alone: admit we read the
- * number, but return a floating exception
- * because we can't encode the number.
- */
- }
- } /* if (we needed to round up) */
- } /* if (exponent overflow) */
- } /* if (0.0e0) */
- } /* if (float_type was OK) */
- return(return_value);
-} /* flonum_gen2vax() */
-
-
-/* JF this used to be in vax.c but this looks like a better place for it */
-
-/*
- * md_atof()
- *
- * In: input_line_pointer->the 1st character of a floating-point
- * number.
- * 1 letter denoting the type of statement that wants a
- * binary floating point number returned.
- * Address of where to build floating point literal.
- * Assumed to be 'big enough'.
- * Address of where to return size of literal (in chars).
- *
- * Out: Input_line_pointer->of next char after floating number.
- * Error message, or "".
- * Floating point literal.
- * Number of chars we used for the literal.
- */
-
-#define MAXIMUM_NUMBER_OF_LITTLENUMS (8) /* For .hfloats. */
-
-char *
- md_atof (what_statement_type, literalP, sizeP)
-char what_statement_type;
-char * literalP;
-int * sizeP;
-{
- LITTLENUM_TYPE words[MAXIMUM_NUMBER_OF_LITTLENUMS];
- register char kind_of_float;
- register int number_of_chars;
- register LITTLENUM_TYPE * littlenum_pointer;
-
- switch (what_statement_type)
- {
- case 'F': /* .float */
- case 'f': /* .ffloat */
- kind_of_float = 'f';
- break;
-
- case 'D': /* .double */
- case 'd': /* .dfloat */
- kind_of_float = 'd';
- break;
-
- case 'g': /* .gfloat */
- kind_of_float = 'g';
- break;
-
- case 'h': /* .hfloat */
- kind_of_float = 'h';
- break;
-
- default:
- kind_of_float = 0;
- break;
- };
-
- if (kind_of_float)
- {
- register LITTLENUM_TYPE * limit;
-
- input_line_pointer = atof_vax (input_line_pointer,
- kind_of_float,
- words);
- /*
- * The atof_vax() builds up 16-bit numbers.
- * Since the assembler may not be running on
- * a little-endian machine, be very careful about
- * converting words to chars.
- */
- number_of_chars = atof_vax_sizeof (kind_of_float);
- know( number_of_chars <= MAXIMUM_NUMBER_OF_LITTLENUMS * sizeof(LITTLENUM_TYPE) );
- limit = words + (number_of_chars / sizeof(LITTLENUM_TYPE));
- for (littlenum_pointer = words;
- littlenum_pointer < limit;
- littlenum_pointer ++)
- {
- md_number_to_chars (literalP, * littlenum_pointer, sizeof(LITTLENUM_TYPE));
- literalP += sizeof(LITTLENUM_TYPE);
- };
- }
- else
- {
- number_of_chars = 0;
- };
-
- * sizeP = number_of_chars;
- return (kind_of_float ? "" : "Bad call to md_atof()");
-} /* md_atof() */
-
-/* end of atof-vax.c */
diff --git a/gnu/usr.bin/as/config/coff.h b/gnu/usr.bin/as/config/coff.h
deleted file mode 100644
index a54f35b..0000000
--- a/gnu/usr.bin/as/config/coff.h
+++ /dev/null
@@ -1,783 +0,0 @@
-/* coff.h
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * At this point I'm sure this file is right for i960 and I'm pretty sure it's
- * right for a29k, although it hasn't been tested rigorously. Please feel free
- * to add your own machine's description here. Without that info, it isn't
- * possible to build cross development tools from elsewhere nor is it easy to
- * continue to support your machines format.
- *
- * The TC_foo ifdef's are mine. They are what gas uses. The other ifdef's
- * remain for documentation from other scavenged files. xoxorich.
- */
-
-/********************** FILE HEADER **********************/
-
-struct filehdr {
- unsigned short f_magic; /* magic number */
- unsigned short f_nscns; /* number of sections */
- long f_timdat; /* time & date stamp */
- long f_symptr; /* file pointer to symtab */
- long f_nsyms; /* number of symtab entries */
- unsigned short f_opthdr; /* sizeof(optional hdr) */
- unsigned short f_flags; /* flags */
-};
-
-/* Bits for f_flags:
- * F_RELFLG relocation info stripped from file
- * F_EXEC file is executable (no unresolved externel references)
- * F_LNNO line nunbers stripped from file
- * F_LSYMS local symbols stripped from file
- * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
- */
-#define F_RELFLG (0x0001)
-#define F_EXEC (0x0002)
-#define F_LNNO (0x0004)
-#define F_LSYMS (0x0008)
-
-#ifdef TC_I960
-#define F_AR32WR (0x0010) /* File has 32 bits per word, least
- significant byte first. */
-#else /* TC_I960 */
-#define F_AR32WR (0x0100)
-#endif /* TC_I960 */
-
-#define F_MINMAL (0x0010) /* ??? */
-#define F_UPDATE (0x0020) /* ??? */
-#define F_SWABD (0x0040) /* ??? */
-#define F_AR16WR (0x0080) /* File has the byte ordering used by
- the PDP*-11/70 processor. */
-#define F_AR32W (0x0200) /* File has 32 bits per word, most
- significant byte first. */
-
-/*
- * Intel 80960 (I960) processor flags.
- * F_I960TYPE == mask for processor type field.
- */
-
-#define F_I960TYPE (0xf000)
-#define F_I960CORE (0x1000)
-#define F_I960KB (0x2000)
-#define F_I960SB (0x2000)
-#define F_I960MC (0x3000)
-#define F_I960XA (0x4000)
-#define F_I960CA (0x5000)
-#define F_I960KA (0x6000)
-#define F_I960SA (0x6000)
-
-/*
- * i80960 Magic Numbers
- */
-
-#define I960ROMAGIC (0x160) /* read-only text segments */
-#define I960RWMAGIC (0x161) /* read-write text segments */
-
-#define I960BADMAG(x) (((x).f_magic != I960ROMAGIC) && ((x).f_magic != I960RWMAGIC))
-
-#define SIPFBOMAGIC (0x17a) /* Am29000 (Byte 0 is MSB - Big Endian) */
-#define SIPRBOMAGIC (0x17b) /* Am29000 (Byte 0 is LSB - Little Endian) */
-
-#define A29KBADMAG(x) (((x).f_magic != SIPFBOMAGIC) && ((x).f_magic != SIPRBOMAGIC))
-
-#ifdef TE_I386AIX
-# define I386MAGIC (0x175) /* Danbury AIX C compiler */
-# define I386SVMAGIC (0x14c) /* System V C Compiler */
-# define I386BADMAG(x) (((x).f_magic != I386MAGIC) && \
- ((x).f_magic != I386SVMAGIC))
-#else /* not TE_I386AIX */
-# define I386MAGIC 0x14c
-# define I386BADMAG(x) (((x).f_magic != I386MAGIC))
-#endif /* not TE_I386AIX */
-
-
-#define FILHDR struct filehdr
-#define FILHSZ sizeof(FILHDR)
-
-
-/********************** AOUT "OPTIONAL HEADER" **********************/
-
-typedef struct {
- unsigned long phys_addr;
- unsigned long bitarray;
-} TAGBITS;
-
-/* These appear to be used only by exec(2). I don't know who cares
- about them in a cross development environment. In any case, this
- is my collection after researching the issue for a few hours.
- Apparently, most have these have remained essentially unchanged
- since v7 days, although a few new ones have been added. xoxorich. */
-
-#define BAD0MAGIC (0401) /* (?) "lpd (UNIX/RT)" */
-#define BAD1MAGIC (0405) /* (?) overlay */
-#define OMAGIC (0407) /* old impure format. data immediately
- follows text. both sections are rw. */
-#define NMAGIC (0410) /* split i&d, read-only text */
-#define A_MAGIC3 (0411) /* (?) "separated I&D" */
-#define ZMAGIC (0413) /* like NMAGIC, but demand loaded */
-#define PAGEMAGIC2 (0414) /* (?) like ZMAGIC, but address zero
- explicitly unmapped. */
-#define REGMAGIC (0414) /* (?) a PAGEMAGIC2 alias? */
-#define PAGEMAGIC3 (0415) /* (?) like ZMAGIC, but address zero mapped. */
-#define A_MAGIC5 (0437) /* (?) "system overlay, separated I&D" */
-/* intended for non-unix cross development */
-#define SASMAGIC (010000) /* Single Address Space */
-#define MASMAGIC (020000) /* (?) "Multiple (separate I & D) Address Spaces" */
-
-typedef struct aouthdr {
- short magic; /* type of file */
- short vstamp; /* version stamp */
- unsigned long tsize; /* text size in bytes, padded to FW bdry*/
- unsigned long dsize; /* initialized data " " */
- unsigned long bsize; /* uninitialized data " " */
-#if U3B
- unsigned long dum1;
- unsigned long dum2; /* pad to entry point */
-#endif
- unsigned long entry; /* entry pt. */
- unsigned long text_start; /* base of text used for this file */
- unsigned long data_start; /* base of data used for this file */
- /* CAREFUL: some formats omit the tagentries member. */
- unsigned long tagentries; /* number of tag entries to
- follow (always zero for i960) */
-} AOUTHDR;
-
-/* return a pointer to the tag bits array */
-
-#define TAGPTR(aout) ((TAGBITS *) (&(aout.tagentries)+1))
-
-/* compute size of a header */
-
-/*#define AOUTSZ(aout) (sizeof(AOUTHDR)+(aout.tagentries*sizeof(TAGBITS)))*/
-#define AOUTSZ (sizeof(AOUTHDR))
-
-
-/********************** STORAGE CLASSES **********************/
-
-#define C_EFCN -1 /* physical end of function */
-#define C_NULL 0
-#define C_AUTO 1 /* automatic variable */
-#define C_EXT 2 /* external symbol */
-#define C_STAT 3 /* static */
-#define C_REG 4 /* register variable */
-#define C_EXTDEF 5 /* external definition */
-#define C_LABEL 6 /* label */
-#define C_ULABEL 7 /* undefined label */
-#define C_MOS 8 /* member of structure */
-#define C_ARG 9 /* function argument */
-#define C_STRTAG 10 /* structure tag */
-#define C_MOU 11 /* member of union */
-#define C_UNTAG 12 /* union tag */
-#define C_TPDEF 13 /* type definition */
-#define C_USTATIC 14 /* undefined static */
-#define C_ENTAG 15 /* enumeration tag */
-#define C_MOE 16 /* member of enumeration */
-#define C_REGPARM 17 /* register parameter */
-#define C_FIELD 18 /* bit field */
-
-#ifdef TC_I960
-#define C_AUTOARG 19 /* auto argument */
-#define C_LASTENT 20 /* dummy entry (end of block) */
-#endif /* TC_I960 */
-
-#ifdef TC_A29K
-#define C_GLBLREG 19 /* global register */
-#define C_EXTREG 20 /* external global register */
-#define C_DEFREG 21 /* ext. def. of global register */
-#define C_STARTOF 22 /* as29 $SIZEOF and $STARTOF symbols */
-#endif /* TC_A29K */
-
-#define C_BLOCK 100 /* ".bb" or ".eb" */
-#define C_FCN 101 /* ".bf" or ".ef" */
-#define C_EOS 102 /* end of structure */
-#define C_FILE 103 /* file name */
-#define C_LINE 104 /* line # reformatted as symbol table entry */
-#define C_ALIAS 105 /* duplicate tag */
-#define C_HIDDEN 106 /* ext symbol in dmert public lib. like static,
- used to avoid name conflicts. */
-
-#ifdef TC_I960
-/* New storage classes for 80960 */
-#define C_SCALL 107 /* Procedure reachable via system call */
-/* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */
-#define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */
-#define C_LEAFEXT 108
-#define C_OPTVAR 109 /* Optimized variable */
-#define C_DEFINE 110 /* Preprocessor #define */
-#define C_PRAGMA 111 /* Advice to compiler or linker */
-#define C_SEGMENT 112 /* 80960 segment name */
-#define C_LEAFSTAT 113 /* Static leaf */
-#endif /* TC_I960 */
-
-#ifdef TC_A29K
-#define C_SHADOW 107 /* shadow symbol */
-#endif /* TC_A29K */
-
-/********************** SECTION HEADER **********************/
-
-struct scnhdr {
- char s_name[8]; /* section name */
- long s_paddr; /* physical address, aliased s_nlib */
- long s_vaddr; /* virtual address */
- long s_size; /* section size */
- long s_scnptr; /* file ptr to raw data for section */
- long s_relptr; /* file ptr to relocation */
- long s_lnnoptr; /* file ptr to line numbers */
- unsigned short s_nreloc; /* number of relocation entries */
- unsigned short s_nlnno; /* number of line number entries */
- long s_flags; /* flags */
-
-#ifdef TC_I960
- unsigned long s_align; /* section alignment */
-#endif /* TC_I960 */
-};
-
-#define SCNHDR struct scnhdr
-#define SCNHSZ sizeof(SCNHDR)
-
-/*
- * names of "special" sections
- */
-#define _TEXT ".text" /* executable code section */
-#define _DATA ".data" /* initialized data */
-#define _BSS ".bss" /* un-initialized data */
-#define _DEBUG ".debug" /* special section used by dbx */
-#define _COMMENT ".comment" /* version info */
-#define _LIB ".lib" /* shared lib info section */
-#define _TV ".tv"
-
-/*
- * s_flags "type"
- */
-
-/*
- * In instances where it is necessary for a linker to
- * produce an output file which contains text or data not
- * based at virtual address 0, e.g. for a ROM, then the
- * linker should accept address base information as command
- * input and use PAD sections to skip over unused addresses.
- * (at least for a29k. Maybe others.)
- */
-
-#define STYP_REG (0x0000) /* "regular" section: allocated, relocated, loaded */
-#define STYP_DSECT (0x0001) /* "dummy" section: not allocated, relocated, not loaded */
-#define STYP_NOLOAD (0x0002) /* "noload" section: allocated, relocated, not loaded */
-#define STYP_GROUP (0x0004) /* "grouped" section: formed of input sections */
-#define STYP_PAD (0x0008) /* "padding" section: not allocated, not relocated, loaded */
-#define STYP_COPY (0x0010) /* "copy" section: for decision function used by field update; not allocated, not relocated,
- loaded; reloc & lineno entries processed normally */
-#define STYP_TEXT (0x0020) /* section contains text only */
-#define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
- will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
- update all process invocations. */
-#define STYP_DATA (0x0040) /* section contains data only */
-#define STYP_BSS (0x0080) /* section contains bss only */
-#define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */
-#define STYP_INFO (0x0200) /* comment section : not allocated not relocated, not loaded */
-#define STYP_OVER (0x0400) /* overlay section : relocated not allocated or loaded */
-#define STYP_LIB (0x0800) /* for .lib section : same as INFO */
-#define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */
-#define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a
- word of contiguous bytes beginning on a word boundary. */
-
-#ifdef TC_A29K
-/* NOTE: The use of STYP_BSSREG for relocation is not yet defined. */
-#define STYP_BSSREG 0x1200 /* Global register area (like STYP_INFO) */
-#define STYP_ENVIR 0x2200 /* Environment (like STYP_INFO) */
-#define STYP_ABS 0x4000 /* Absolute (allocated, not reloc, loaded) */
-#define STYP_LIT 0x8020 /* Literal data (like STYP_TEXT) */
-#endif /* TC_A29K */
-
-/********************** LINE NUMBERS **********************/
-
-/* 1 line number entry for every "breakpointable" source line in a section.
- * Line numbers are grouped on a per function basis; first entry in a function
- * grouping will have l_lnno = 0 and in place of physical address will be the
- * symbol table index of the function name.
- */
-struct lineno {
- union {
- long l_symndx; /* symbol index of function name, iff l_lnno == 0*/
- long l_paddr; /* (physical) address of line number */
- } l_addr;
- unsigned short l_lnno; /* line number */
-#ifdef TC_I960
- /* not used on a29k */
- char padding[2]; /* force alignment */
-#endif /* TC_I960 */
-};
-
-#define LINENO struct lineno
-#define LINESZ sizeof(LINENO)
-
-
-/********************** SYMBOLS **********************/
-
-#define SYMNMLEN 8 /* # characters in a symbol name */
-#define FILNMLEN 14 /* # characters in a file name */
-#define DIMNUM 4 /* # array dimensions in auxiliary entry */
-
-struct syment {
- union {
- char _n_name[SYMNMLEN]; /* old COFF version */
- struct {
- long _n_zeroes; /* new == 0 */
- long _n_offset; /* offset into string table */
- } _n_n;
- char *_n_nptr[2]; /* allows for overlaying */
- } _n;
- long n_value; /* value of symbol */
- short n_scnum; /* section number */
-
-#ifdef TC_I960
- /* This isn't yet used on the i960. In some formats this
- is two bytes of padding. In others, it is missing entirely. */
- unsigned short n_flags; /* copy of flags from filhdr */
-#endif /* TC_I960 */
-
-#ifdef TC_A29K
- unsigned short n_type; /* type and derived type */
-#else /* TC_A29K */
- /* at least i960 uses long */
- unsigned long n_type; /* type and derived type */
-#endif /* TC_A29K */
-
- char n_sclass; /* storage class */
- char n_numaux; /* number of aux. entries */
-
-#ifndef TC_A29K
- char pad2[2]; /* force alignment */
-#endif /* TC_A29K */
-};
-
-#define SYMENT struct syment
-#define SYMESZ sizeof(SYMENT) /* This had better also be sizeof(AUXENT) */
-
-#define n_name _n._n_name
-#define n_ptr _n._n_nptr[1]
-#define n_zeroes _n._n_n._n_zeroes
-#define n_offset _n._n_n._n_offset
-
- /*
- * Relocatable symbols have number of the section in which they are defined,
- * or one of the following:
- */
-
-#define N_SCNUM ((short) 1-65535) /* section num where symbol defined */
-#define N_UNDEF ((short)0) /* undefined symbol */
-#define N_ABS ((short)-1) /* value of symbol is absolute */
-#define N_DEBUG ((short)-2) /* debugging symbol -- symbol value is meaningless */
-#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */
-#define P_TV ((short)-4) /* indicates symbol needs transfer vector (postload) */
-
-/*
- * Type of a symbol, in low 4 bits of the word
- */
-#define T_NULL 0 /* type not assigned */
-#define T_VOID 1 /* function argument (only used by compiler) (but now real void). */
-#define T_CHAR 2 /* character */
-#define T_SHORT 3 /* short integer */
-#define T_INT 4 /* integer */
-#define T_LONG 5 /* long integer */
-#define T_FLOAT 6 /* floating point */
-#define T_DOUBLE 7 /* double word */
-#define T_STRUCT 8 /* structure */
-#define T_UNION 9 /* union */
-#define T_ENUM 10 /* enumeration */
-#define T_MOE 11 /* member of enumeration */
-#define T_UCHAR 12 /* unsigned character */
-#define T_USHORT 13 /* unsigned short */
-#define T_UINT 14 /* unsigned integer */
-#define T_ULONG 15 /* unsigned long */
-
-#ifdef TC_I960
-#define T_LNGDBL 16 /* long double */
-#endif /* TC_I960 */
-
-/*
- * derived types, in n_type
- */
-#define DT_NON (0) /* no derived type */
-#define DT_PTR (1) /* pointer */
-#define DT_FCN (2) /* function */
-#define DT_ARY (3) /* array */
-
-#ifndef TC_I960
-
-#define N_BTMASK (0x0f)
-#define N_TMASK (0x30)
-#define N_BTSHFT (4)
-#define N_TSHIFT (2)
-
-#else /* TC_I960 */
-
-#define N_BTMASK (0x1f)
-#define N_TMASK (0x60)
-#define N_BTSHFT (5)
-#define N_TSHIFT (2)
-
-#endif /* TC_I960 */
-
-#define BTYPE(x) ((x) & N_BTMASK)
-
-#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
-#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
-#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
-
-#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
-
-union auxent {
- struct {
- long x_tagndx; /* str, un, or enum tag indx */
- union {
- struct {
- unsigned short x_lnno; /* declaration line number */
- unsigned short x_size; /* str/union/array size */
- } x_lnsz;
- long x_fsize; /* size of function */
- } x_misc;
- union {
- struct { /* if ISFCN, tag, or .bb */
- long x_lnnoptr; /* ptr to fcn line # */
- long x_endndx; /* entry ndx past block end */
- } x_fcn;
- struct { /* if ISARY, up to 4 dimen. */
- unsigned short x_dimen[DIMNUM];
- } x_ary;
- } x_fcnary;
- unsigned short x_tvndx; /* tv index */
- } x_sym;
-
- /* This was just a struct x_file with x_fname only in a29k. xoxorich. */
- union {
- char x_fname[FILNMLEN];
- struct {
- long x_zeroes;
- long x_offset;
- } x_n;
- } x_file;
-
- struct {
- long x_scnlen; /* section length */
- unsigned short x_nreloc; /* # relocation entries */
- unsigned short x_nlinno; /* # line numbers */
- } x_scn;
-
- struct {
- long x_tvfill; /* tv fill value */
- unsigned short x_tvlen; /* length of .tv */
-
- /* This field was typo'd x_tvrna on a29k. xoxorich. */
- unsigned short x_tvran[2]; /* tv range */
- } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
-
-#ifdef TC_I960
- /******************************************
- * I960-specific *2nd* aux. entry formats
- ******************************************/
- struct {
- /* This is a very old typo that keeps getting propogated. */
-#define x_stdindx x_stindx
- long x_stindx; /* sys. table entry */
- } x_sc; /* system call entry */
-
- struct {
- unsigned long x_balntry; /* BAL entry point */
- } x_bal; /* BAL-callable function */
-
- struct {
- unsigned long x_timestamp; /* time stamp */
- char x_idstring[20]; /* producer identity string */
- } x_ident; /* Producer ident info */
-
- char a[sizeof(struct syment)]; /* force auxent/syment sizes to match */
-#endif /* TC_I960 */
-};
-
-#define AUXENT union auxent
-#define AUXESZ sizeof(AUXENT) /* This had better also be sizeof(SYMENT) */
-
-#if VAX || I960
-# define _ETEXT "_etext"
-#else
-# define _ETEXT "etext"
-#endif
-
-/********************** RELOCATION DIRECTIVES **********************/
-
-struct reloc {
- long r_vaddr; /* Virtual address of reference */
- long r_symndx; /* Index into symbol table */
- unsigned short r_type; /* Relocation type */
-#ifdef TC_I960
- /* not used for a29k */
- char pad[2]; /* Unused */
-#endif /* TC_I960 */
-};
-
-#define RELOC struct reloc
-#define RELSZ sizeof(RELOC)
-
-#define R_ABS (0x00) /* reference is absolute */
-
-#ifdef TC_I960
-#define R_RELLONG (0x11) /* Direct 32-bit relocation */
-#define R_IPRSHORT (0x18)
-#define R_IPRMED (0x19) /* 24-bit ip-relative relocation */
-#define R_IPRLONG (0x1a)
-#define R_OPTCALL (0x1b) /* 32-bit optimizable call (leafproc/sysproc) */
-#define R_OPTCALLX (0x1c) /* 64-bit optimizable call (leafproc/sysproc) */
-#define R_GETSEG (0x1d)
-#define R_GETPA (0x1e)
-#define R_TAGWORD (0x1f)
-#endif /* TC_I960 */
-
-#ifdef TC_A29K
-/*
- * NOTE: All the "I" forms refer to Am29000 instruction
- * formats. The linker is expected to know how the numeric
- * information is split and/or aligned within the
- * instruction word(s). R_BYTE works for instructions, too.
- *
- * If the parameter to a CONSTH instruction is a relocatable
- * type, two relocation records are written. The first has
- * an r_type of R_IHIHALF (33 octal) and a normal r_vaddr
- * and r_symndx. The second relocation record has an r_type
- * of R_IHCONST (34 octal), a normal r_vaddr (which is
- * redundant), and an r_symndx containing the 32-bit
- * constant offset to the relocation instead of the actual
- * symbol table index. This second record is always
- * written, even if the constant offset is zero. The
- * constant fields of the instruction are set to zero.
- */
-
-#define R_IREL (0x18) /* instruction relative (jmp/call) */
-#define R_IABS (0x19) /* instruction absolute (jmp/call) */
-#define R_ILOHALF (0x1a) /* instruction low half (const) */
-#define R_IHIHALF (0x1b) /* instruction high half (consth) part 1 */
-#define R_IHCONST (0x1c) /* instruction high half (consth) part 2
- constant offset of R_IHIHALF relocation */
-#define R_BYTE (0x1d) /* relocatable byte value */
-#define R_HWORD (0x1e) /* relocatable halfword value */
-#define R_WORD (0x1f) /* relocatable word value */
-#define R_IGLBLRC (0x20) /* instruction global register RC */
-#define R_IGLBLRA (0x21) /* instruction global register RA */
-#define R_IGLBLRB (0x22) /* instruction global register RB */
-#endif /* TC_A29K */
-
-
-#define DEFAULT_DATA_SECTION_ALIGNMENT 4
-#define DEFAULT_BSS_SECTION_ALIGNMENT 4
-#define DEFAULT_TEXT_SECTION_ALIGNMENT 16
-/* For new sections we haven't heard of before */
-#define DEFAULT_SECTION_ALIGNMENT 4
-
-#if defined(TC_I386)
-/*
- * X86 generic
- * 8-bit offset reference in 8-bits
- * 8-bit offset reference in 16-bits
- * 12-bit segment reference
- * auxiliary relocation entry
- */
-#define R_OFF8 07
-#define R_OFF16 010
-#define R_SEG12 011
-#define R_AUX 013
-
-/*
- * B16 and X86 generics
- * 16-bit direct reference
- * 16-bit "relative" reference
- * 16-bit "indirect" (TV) reference
- */
-#define R_DIR16 01
-#define R_REL16 02
-#define R_IND16 03
-
-/*
- * 3B generic
- * 24-bit direct reference
- * 24-bit "relative" reference
- * 16-bit optimized "indirect" TV reference
- * 24-bit "indirect" TV reference
- * 32-bit "indirect" TV reference
- */
-#define R_DIR24 04
-#define R_REL24 05
-#define R_OPT16 014
-#define R_IND24 015
-#define R_IND32 016
-
-/*
- * XL generics
- * 10-bit direct reference
- * 10-bit "relative" reference
- * 32-bit "relative" reference
- */
-#define R_DIR10 025
-#define R_REL10 026
-#define R_REL32 027
-
-/*
- * 3B and M32 generics
- * 32-bit direct reference
- */
-#define R_DIR32 06
-
-/*
- * M32 generic
- * 32-bit direct reference with bytes swapped
- */
-#define R_DIR32S 012
-
-#endif /* TC_I386 */
-
-#if defined(TE_I386AIX)
-
-#define UINFOSIZ 64 /* size of user info buffer */
-typedef char uinfo_t[UINFOSIZ];
-
-struct env387 {
- unsigned short control;
- unsigned short r0;
- unsigned short status;
- unsigned short r1;
- unsigned short tag;
- unsigned short r2;
- unsigned long eip;
- unsigned short code_seg;
- unsigned short opcode;
- unsigned long operand;
- unsigned short operand_seg;
- unsigned short r3;
- unsigned char regs[8][10];
-};
-
-#define CD_NAMELEN 16 /* length of most names in this header */
-#define CORHDRSIZ 2048 /* size to which header is padded out */
-#define MAX_CORE_SEGS 32 /* maximum segments in a core dump */
-#define NUM_FREGS 1 /* # of saved FP regs */
-
-/*
- * These are defined such that 286 and 386 kernels can produce
- * compatible dumps.
- */
-#define CD_AX 0
-#define CD_BX 1
-#define CD_CX 2
-#define CD_DX 3
-#define CD_SI 4
-#define CD_DI 5
-#define CD_BP 6
-#define CD_SP 7
-#define CD_FL 8
-#define CD_IP 9
-#define CD_CS 10
-#define CD_DS 11
-#define CD_ES 12
-#define CD_FS 13
-#define CD_GS 14
-#define CD_SS 15
-#define NUM_REGS 16
-
-#ifndef SPATHLEN
-# define SPATHLEN 16 /* sys/param.h */
-#endif
-#ifndef NSIG
-# define NSIG 63 /* sys/signal.h */
-# define SIGSETSZ ((NSIG+31)/32)
-typedef struct ksigmask {
- unsigned long sigs[SIGSETSZ];
-} ksigmask_t;
-#endif
-
-struct corehdr {
- char cd_magic[4]; /* COR_MAGIC = "core" */
-
- /* general information about the dump itself */
- struct dumpseg { /* table of contents for dump */
- long cs_type; /* seg. type; see below */
- long cs_len; /* length (in bytes) of segment */
- long cs_offset; /* offset (in dump) of segment */
- long cs_address; /* address segment had in mem */
- } cd_segs[MAX_CORE_SEGS];
-
- /* general information about the process */
- char cd_comm[CD_NAMELEN]; /* command being run */
- char cd_mach[CD_NAMELEN]; /* type of machine it ran on */
- char cd_site[CD_NAMELEN]; /* name of site it ran on */
- long cd_ldtype; /* type of load module running */
- char cd_intsize; /* sizeof(int) */
- char cd_dptrsize; /* sizeof(char *) */
- char cd_tptrsize; /* sizeof(int (*)()) */
- char cd_unused;
-
- /* user-mode program state */
- long cd_regs[NUM_REGS]; /* user-mode general registers */
- struct env387 cd_fpregs; /* user-mode floating-point state */
-
- /* kernel-mode program state */
- int (*cd_sig[NSIG])(); /* disposition of signals */
- ksigmask_t cd_sigmask; /* signals to be blocked */
- ksigmask_t cd_sigpend; /* signals currently pending */
- long cd_cursig; /* signal that caused the dump */
-
- long cd_pid; /* process ID of the corpse */
- long cd_ppid; /* parent process ID of corpse */
- short cd_uid; /* process effective user ID */
- short cd_ruid; /* process real user ID */
- short cd_gid; /* process effective group ID */
- short cd_rgid; /* process real group ID */
-
- uinfo_t cd_uinfo; /* buffer of user information */
- char cd_locname[32]; /* name of /local */
- char cd_uvers[CD_NAMELEN]; /* user version string */
- unsigned short cd_spath[SPATHLEN]; /* sitepath */
-};
-
-#ifndef NOCHECKS
-/* this will generate an error if sizeof(struct corehdr) > CORHDRSIZ */
-struct { char xxcdxx[CORHDRSIZ+1-sizeof(struct corehdr)]; };
-#endif /* ! NOCHECKS */
-
-/*
- * segment types (in cs_type)
- * each segment in the address space appears here, whether or not it
- * is actually dumped. Read/only segments will not actually be dumped.
- * A segment that is not in the dump will have a cs_offset of zero.
- */
-#define COR_TYPE_CODE 'x' /* process code - NOT IN DUMP */
-#define COR_TYPE_DATA 'd' /* process data segment */
-#define COR_TYPE_STACK 's' /* process stack segment */
-#define COR_TYPE_LIBCODE 'X' /* shared lib code - NOT IN DUMP*/
-#define COR_TYPE_LIBDATA 'D' /* shared lib data */
-#define COR_TYPE_READ 'r' /* other read/only - NOT IN DUMP*/
-#define COR_TYPE_WRITE 'w' /* other writeable */
-#define COR_TYPE_MSC '?' /* other, mapped in segment */
-
-#endif /* TE_I386AIX */
-
-/*
- * Local Variables:
- * comment-column: 0
- * End:
- */
-
-/* end of coff.h */
diff --git a/gnu/usr.bin/as/config/cplus-dem.c b/gnu/usr.bin/as/config/cplus-dem.c
deleted file mode 100644
index 79d3279..0000000
--- a/gnu/usr.bin/as/config/cplus-dem.c
+++ /dev/null
@@ -1,927 +0,0 @@
-/* Demangler for GNU C++
- Copyright (C) 1989, 1992 Free Software Foundation, Inc.
- written by James Clark (jjc@jclark.uucp)
-
- 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. */
-
-/* This is for g++ 1.36.1 (November 6 version). It will probably
- require changes for any other version. */
-
-/* This file exports one function
-
- char *cplus_demangle (const char *name)
-
- If `name' is a mangled function name produced by g++, then
- a pointer to a malloced string giving a C++ representation
- of the name will be returned; otherwise NULL will be returned.
- It is the caller's responsibility to free the string which
- is returned.
-
- For example,
-
- cplus_demangle ("_foo__1Ai")
-
- returns
-
- "A::foo(int)"
-
- This file imports xmalloc and xrealloc, which are like malloc and
- realloc except that they generate a fatal error if there is no
- available memory. */
-
-/* #define nounderscore 1 /* define this is names don't start with _ */
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#if !defined(sequent) && !defined(NeXT)
-#include <memory.h>
-#else
-#define memcpy(s1, s2, n) strncpy(s1, s2, n)
-#define memcmp(s1, s2, n) strncmp(s1, s2, n)
-#define strchr(s, c) index(s, c)
-#endif
-
-#if __STDC__ != 1
-#define const
-#endif
-
-#if __STDC__ == 1
-extern char *cplus_demangle (const char *type);
-#else
-extern char *cplus_demangle ();
-#endif
-
-#if __STDC__ == 1
-extern char *xmalloc (int);
-extern char *xrealloc (char *, int);
-#else
-extern char *xmalloc ();
-extern char *xrealloc ();
-#endif
-
-static char **typevec = 0;
-static int ntypes = 0;
-static int typevec_size = 0;
-
-static struct {
- const char *in;
- const char *out;
-} optable[] = {
- "new", " new",
- "delete", " delete",
- "ne", "!=",
- "eq", "==",
- "ge", ">=",
- "gt", ">",
- "le", "<=",
- "lt", "<",
- "plus", "+",
- "minus", "-",
- "mult", "*",
- "negate", "-",
- "trunc_mod", "%",
- "trunc_div", "/",
- "truth_andif", "&&",
- "truth_orif", "||",
- "postincrement", "++",
- "postdecrement", "--",
- "bit_ior", "|",
- "bit_xor", "^",
- "bit_and", "&",
- "bit_not", "~",
- "call", "()",
- "cond", "?:",
- "alshift", "<<",
- "arshift", ">>",
- "component", "->",
- "nop", "", /* for operator= */
-};
-
-/* Beware: these aren't '\0' terminated. */
-
-typedef struct {
- char *b; /* pointer to start of string */
- char *p; /* pointer after last character */
- char *e; /* pointer after end of allocated space */
-} string;
-
-#if __STDC__ == 1
-static void string_need (string *s, int n);
-static void string_delete (string *s);
-static void string_init (string *s);
-static void string_clear (string *s);
-static int string_empty (string *s);
-static void string_append (string *p, const char *s);
-static void string_appends (string *p, string *s);
-static void string_appendn (string *p, const char *s, int n);
-static void string_prepend (string *p, const char *s);
-#if 0
-static void string_prepends (string *p, string *s);
-#endif
-static void string_prependn (string *p, const char *s, int n);
-static int get_count (const char **type, int *count);
-static int do_args (const char **type, string *decl);
-static int do_type (const char **type, string *result);
-static int do_arg (const char **type, string *result);
-static int do_args (const char **type, string *decl);
-static void munge_function_name (string *name);
-#else
-static void string_need ();
-static void string_delete ();
-static void string_init ();
-static void string_clear ();
-static int string_empty ();
-static void string_append ();
-static void string_appends ();
-static void string_appendn ();
-static void string_prepend ();
-static void string_prepends ();
-static void string_prependn ();
-static int get_count ();
-static int do_args ();
-static int do_type ();
-static int do_arg ();
-static int do_args ();
-static void munge_function_name ();
-#endif
-
-char *
- cplus_demangle (type)
-const char *type;
-{
- string decl;
- int n;
- int success = 0;
- int constructor = 0;
- int const_flag = 0;
- int i;
- const char *p;
-
- if (type == NULL || *type == '\0')
- return NULL;
-#ifndef nounderscore
- if (*type++ != '_')
- return NULL;
-#endif
- p = type;
- while (*p != '\0' && !(*p == '_' && p[1] == '_'))
- p++;
- if (*p == '\0')
- {
- /* destructor */
- if (type[0] == '_' && type[1] == '$' && type[2] == '_')
- {
- int n = (strlen (type) - 3)*2 + 3 + 2 + 1;
- char *tem = (char *) xmalloc (n);
- strcpy (tem, type + 3);
- strcat (tem, "::~");
- strcat (tem, type + 3);
- strcat (tem, "()");
- return tem;
- }
- /* static data member */
- if (*type != '_' && (p = strchr (type, '$')) != '\0')
- {
- int n = strlen (type) + 2;
- char *tem = (char *) xmalloc (n);
- memcpy (tem, type, p - type);
- strcpy (tem + (p - type), "::");
- strcpy (tem + (p - type) + 2, p + 1);
- return tem;
- }
- return NULL;
- }
-
- string_init (&decl);
-
- if (p == type)
- {
- if (!isdigit (p[2]))
- {
- string_delete (&decl);
- return NULL;
- }
- constructor = 1;
- }
- else
- {
- string_appendn (&decl, type, p - type);
- munge_function_name (&decl);
- }
- p += 2;
-
- switch (*p)
- {
- case 'C':
- /* a const member function */
- if (!isdigit (p[1]))
- {
- string_delete (&decl);
- return NULL;
- }
- p += 1;
- const_flag = 1;
- /* fall through */
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- n = 0;
- do
- {
- n *= 10;
- n += *p - '0';
- p += 1;
- }
- while (isdigit (*p));
- if (strlen (p) < n)
- {
- string_delete (&decl);
- return NULL;
- }
- if (constructor)
- {
- string_appendn (&decl, p, n);
- string_append (&decl, "::");
- string_appendn (&decl, p, n);
- }
- else
- {
- string_prepend (&decl, "::");
- string_prependn (&decl, p, n);
- }
- p += n;
- success = do_args (&p, &decl);
- if (const_flag)
- string_append (&decl, " const");
- break;
- case 'F':
- p += 1;
- success = do_args (&p, &decl);
- break;
- }
-
- for (i = 0; i < ntypes; i++)
- if (typevec[i] != NULL)
- free (typevec[i]);
- ntypes = 0;
- if (typevec != NULL)
- {
- free ((char *)typevec);
- typevec = NULL;
- typevec_size = 0;
- }
-
- if (success)
- {
- string_appendn (&decl, "", 1);
- return decl.b;
- }
- else
- {
- string_delete (&decl);
- return NULL;
- }
-}
-
-static int
- get_count (type, count)
-const char **type;
-int *count;
-{
- if (!isdigit (**type))
- return 0;
- *count = **type - '0';
- *type += 1;
- /* see flush_repeats in cplus-method.c */
- if (isdigit (**type))
- {
- const char *p = *type;
- int n = *count;
- do
- {
- n *= 10;
- n += *p - '0';
- p += 1;
- }
- while (isdigit (*p));
- if (*p == '_')
- {
- *type = p + 1;
- *count = n;
- }
- }
- return 1;
-}
-
-/* result will be initialised here; it will be freed on failure */
-
-static int
- do_type (type, result)
-const char **type;
-string *result;
-{
- int n;
- int done;
- int non_empty;
- int success;
- string decl;
- const char *remembered_type;
-
- string_init (&decl);
- string_init (result);
-
- done = 0;
- success = 1;
- while (success && !done)
- {
- int member;
- switch (**type)
- {
- case 'P':
- *type += 1;
- string_prepend (&decl, "*");
- break;
-
- case 'R':
- *type += 1;
- string_prepend (&decl, "&");
- break;
-
- case 'T':
- *type += 1;
- if (!get_count (type, &n) || n >= ntypes)
- success = 0;
- else
- {
- remembered_type = typevec[n];
- type = &remembered_type;
- }
- break;
-
- case 'F':
- *type += 1;
- if (!string_empty (&decl) && decl.b[0] == '*')
- {
- string_prepend (&decl, "(");
- string_append (&decl, ")");
- }
- if (!do_args (type, &decl) || **type != '_')
- success = 0;
- else
- *type += 1;
- break;
-
- case 'M':
- case 'O':
- {
- int constp = 0;
- int volatilep = 0;
-
- member = **type == 'M';
- *type += 1;
- if (!isdigit (**type))
- {
- success = 0;
- break;
- }
- n = 0;
- do
- {
- n *= 10;
- n += **type - '0';
- *type += 1;
- }
- while (isdigit (**type));
- if (strlen (*type) < n)
- {
- success = 0;
- break;
- }
- string_append (&decl, ")");
- string_prepend (&decl, "::");
- string_prependn (&decl, *type, n);
- string_prepend (&decl, "(");
- *type += n;
- if (member)
- {
- if (**type == 'C')
- {
- *type += 1;
- constp = 1;
- }
- if (**type == 'V')
- {
- *type += 1;
- volatilep = 1;
- }
- if (*(*type)++ != 'F')
- {
- success = 0;
- break;
- }
- }
- if ((member && !do_args (type, &decl)) || **type != '_')
- {
- success = 0;
- break;
- }
- *type += 1;
- if (constp)
- {
- if (non_empty)
- string_append (&decl, " ");
- else
- non_empty = 1;
- string_append (&decl, "const");
- }
- if (volatilep)
- {
- if (non_empty)
- string_append (&decl, " ");
- else
- non_empty = 1;
- string_append (&decl, "volatilep");
- }
- break;
- }
-
- case 'C':
- if ((*type)[1] == 'P')
- {
- *type += 1;
- if (!string_empty (&decl))
- string_prepend (&decl, " ");
- string_prepend (&decl, "const");
- break;
- }
-
- /* fall through */
- default:
- done = 1;
- break;
- }
- }
-
- done = 0;
- non_empty = 0;
- while (success && !done)
- {
- switch (**type)
- {
- case 'C':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- else
- non_empty = 1;
- string_append (result, "const");
- break;
- case 'U':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- else
- non_empty = 1;
- string_append (result, "unsigned");
- break;
- case 'V':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- else
- non_empty = 1;
- string_append (result, "volatile");
- break;
- default:
- done = 1;
- break;
- }
- }
-
- if (success)
- switch (**type)
- {
- case '\0':
- case '_':
- break;
- case 'v':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- string_append (result, "void");
- break;
- case 'l':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- string_append (result, "long");
- break;
- case 'i':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- string_append (result, "int");
- break;
- case 's':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- string_append (result, "short");
- break;
- case 'c':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- string_append (result, "char");
- break;
- case 'r':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- string_append (result, "long double");
- break;
- case 'd':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- string_append (result, "double");
- break;
- case 'f':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- string_append (result, "float");
- break;
- case 'G':
- *type += 1;
- if (!isdigit (**type))
- {
- success = 0;
- break;
- }
- /* fall through */
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- n = 0;
- do
- {
- n *= 10;
- n += **type - '0';
- *type += 1;
- }
- while (isdigit (**type));
- if (strlen (*type) < n)
- {
- success = 0;
- break;
- }
- if (non_empty)
- string_append (result, " ");
- string_appendn (result, *type, n);
- *type += n;
- break;
- default:
- success = 0;
- break;
- }
-
- if (success)
- {
- if (!string_empty (&decl))
- {
- string_append (result, " ");
- string_appends (result, &decl);
- }
- string_delete (&decl);
- return 1;
- }
- else
- {
- string_delete (&decl);
- string_delete (result);
- return 0;
- }
-}
-
-/* `result' will be initialised in do_type; it will be freed on failure */
-
-static int
- do_arg (type, result)
-const char **type;
-string *result;
-{
- char *tem;
- int len;
- const char *start;
- const char *end;
-
- start = *type;
- if (!do_type (type, result))
- return 0;
- end = *type;
- if (ntypes >= typevec_size)
- {
- if (typevec_size == 0)
- {
- typevec_size = 3;
- typevec = (char **) xmalloc (sizeof (char*)*typevec_size);
- }
- else
- {
- typevec_size *= 2;
- typevec = (char **) xrealloc ((char *)typevec, sizeof (char*)*typevec_size);
- }
- }
- len = end - start;
- tem = (char *) xmalloc (len + 1);
- memcpy (tem, start, len);
- tem[len] = '\0';
- typevec[ntypes++] = tem;
- return 1;
-}
-
-/* `decl' must be already initialised, usually non-empty;
- it won't be freed on failure */
-
-static int
- do_args (type, decl)
-const char **type;
-string *decl;
-{
- string arg;
- int need_comma = 0;
-
- string_append (decl, "(");
-
- while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v')
- {
- if (**type == 'N')
- {
- int r;
- int t;
- *type += 1;
- if (!get_count (type, &r) || !get_count (type, &t) || t >= ntypes)
- return 0;
- while (--r >= 0)
- {
- const char *tem = typevec[t];
- if (need_comma)
- string_append (decl, ", ");
- if (!do_arg (&tem, &arg))
- return 0;
- string_appends (decl, &arg);
- string_delete (&arg);
- need_comma = 1;
- }
- }
- else
- {
- if (need_comma)
- string_append (decl, ", ");
- if (!do_arg (type, &arg))
- return 0;
- string_appends (decl, &arg);
- string_delete (&arg);
- need_comma = 1;
- }
- }
-
- if (**type == 'v')
- *type += 1;
- else if (**type == 'e')
- {
- *type += 1;
- if (need_comma)
- string_append (decl, ",");
- string_append (decl, "...");
- }
-
- string_append (decl, ")");
- return 1;
-}
-
-static void
- munge_function_name (name)
-string *name;
-{
- if (!string_empty (name) && name->p - name->b >= 3
- && name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == '$')
- {
- int i;
- /* see if it's an assignment expression */
- if (name->p - name->b >= 10 /* op$assign_ */
- && memcmp (name->b + 3, "assign_", 7) == 0)
- {
- for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++)
- {
- int len = name->p - name->b - 10;
- if (strlen (optable[i].in) == len
- && memcmp (optable[i].in, name->b + 10, len) == 0)
- {
- string_clear (name);
- string_append (name, "operator");
- string_append (name, optable[i].out);
- string_append (name, "=");
- return;
- }
- }
- }
- else
- {
- for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++)
- {
- int len = name->p - name->b - 3;
- if (strlen (optable[i].in) == len
- && memcmp (optable[i].in, name->b + 3, len) == 0)
- {
- string_clear (name);
- string_append (name, "operator");
- string_append (name, optable[i].out);
- return;
- }
- }
- }
- return;
- }
- else if (!string_empty (name) && name->p - name->b >= 5
- && memcmp (name->b, "type$", 5) == 0)
- {
- /* type conversion operator */
- string type;
- const char *tem = name->b + 5;
- if (do_type (&tem, &type))
- {
- string_clear (name);
- string_append (name, "operator ");
- string_appends (name, &type);
- string_delete (&type);
- return;
- }
- }
-}
-
-/* a mini string-handling package */
-
-static void
- string_need (s, n)
-string *s;
-int n;
-{
- if (s->b == NULL)
- {
- if (n < 32)
- n = 32;
- s->p = s->b = (char *) xmalloc (n);
- s->e = s->b + n;
- }
- else if (s->e - s->p < n)
- {
- int tem = s->p - s->b;
- n += tem;
- n *= 2;
- s->b = (char *) xrealloc (s->b, n);
- s->p = s->b + tem;
- s->e = s->b + n;
- }
-}
-
-static void
- string_delete (s)
-string *s;
-{
- if (s->b != NULL)
- {
- free (s->b);
- s->b = s->e = s->p = NULL;
- }
-}
-
-static void
- string_init (s)
-string *s;
-{
- s->b = s->p = s->e = NULL;
-}
-
-static void
- string_clear (s)
-string *s;
-{
- s->p = s->b;
-}
-
-static int
- string_empty (s)
-string *s;
-{
- return s->b == s->p;
-}
-
-static void
- string_append (p, s)
-string *p;
-const char *s;
-{
- int n;
- if (s == NULL || *s == '\0')
- return;
- n = strlen (s);
- string_need (p, n);
- memcpy (p->p, s, n);
- p->p += n;
-}
-
-static void
- string_appends (p, s)
-string *p, *s;
-{
- int n;
- if (s->b == s->p)
- return;
- n = s->p - s->b;
- string_need (p, n);
- memcpy (p->p, s->b, n);
- p->p += n;
-}
-
-static void
- string_appendn (p, s, n)
-string *p;
-const char *s;
-int n;
-{
- if (n == 0)
- return;
- string_need (p, n);
- memcpy (p->p, s, n);
- p->p += n;
-}
-
-static void
- string_prepend (p, s)
-string *p;
-const char *s;
-{
- if (s == NULL || *s == '\0')
- return;
- string_prependn (p, s, strlen (s));
-}
-
-#if 0
-static void
- string_prepends (p, s)
-string *p, *s;
-{
- if (s->b == s->p)
- return;
- string_prependn (p, s->b, s->p - s->b);
-}
-#endif
-
-static void
- string_prependn (p, s, n)
-string *p;
-const char *s;
-int n;
-{
- char *q;
-
- if (n == 0)
- return;
- string_need (p, n);
- for (q = p->p - 1; q >= p->b; q--)
- q[n] = q[0];
- memcpy (p->b, s, n);
- p->p += n;
-}
-
-/* end of cplus-dem.c */
diff --git a/gnu/usr.bin/as/config/ho-ansi.h b/gnu/usr.bin/as/config/ho-ansi.h
deleted file mode 100644
index bd2d909..0000000
--- a/gnu/usr.bin/as/config/ho-ansi.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* ho-ansi.h Host-specific header file for generic ansi environments.
- Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define M_ANSI 1
-
-#include <stdlib.h>
-#include <string.h>
-#include <memory.h>
-
-#define sys_nerr _sys_nerr
-#define sys_errlist _sys_errlist
-
-/* end of ho-ansi.h */
diff --git a/gnu/usr.bin/as/config/ho-decstation.h b/gnu/usr.bin/as/config/ho-decstation.h
deleted file mode 100644
index 69a4699..0000000
--- a/gnu/usr.bin/as/config/ho-decstation.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* ho-pmax.h Host-specific header file for decstation 3100.
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include <string.h>
-
-extern char *malloc();
-extern int free();
-
-#if !defined(__GNUC__)
-#define know(x)
-#endif /* not gcc */
-
-/* end of ho-decstation.h */
diff --git a/gnu/usr.bin/as/config/ho-generic.h b/gnu/usr.bin/as/config/ho-generic.h
deleted file mode 100644
index 7c7129f..0000000
--- a/gnu/usr.bin/as/config/ho-generic.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ho-generic.h Generic host-specific header file.
- Copyright 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* It is my intent that this become a file capable of config'ing and
- compiling for nearly any host as aid for testing and porting.
- xoxorich. */
-
-#define M_GENERIC 1
-
-#define HAVE_STRERROR
-
-extern int free();
-
-/* end of ho-generic.h */
diff --git a/gnu/usr.bin/as/config/ho-hpux.h b/gnu/usr.bin/as/config/ho-hpux.h
deleted file mode 100644
index ebea9e2..0000000
--- a/gnu/usr.bin/as/config/ho-hpux.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ho-hpux.h -- Header to compile the assembler under HP-UX
- Copyright (C) 1988, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "ho-sysv.h"
-
-/* This header file contains the #defines specific
- to HPUX changes sent me by cph@zurich.ai.mit.edu */
-#ifndef hpux
-#define hpux
-#endif
-
-#ifdef setbuffer
-#undef setbuffer
-#endif /* setbuffer */
-
-#define setbuffer(stream, buf, size)
-
-/* end of ho-hpux.h */
diff --git a/gnu/usr.bin/as/config/ho-i386.h b/gnu/usr.bin/as/config/ho-i386.h
deleted file mode 100644
index 7e18c00..0000000
--- a/gnu/usr.bin/as/config/ho-i386.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ho-i386.h i386 specific header file.
- Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-#define HO_I386 1
-
-#define NO_STDARG
-
-#include "ho-sysv.h"
-
-/* end of ho-i386.h */
diff --git a/gnu/usr.bin/as/config/ho-i386aix.h b/gnu/usr.bin/as/config/ho-i386aix.h
deleted file mode 100644
index d439f74..0000000
--- a/gnu/usr.bin/as/config/ho-i386aix.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* ho-386aix.h AIX PS/2 i386 specific header file.
- Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define HO_I386 1
-
-#include "ho-sysv.h"
-
-/* end of ho-i386aix.h */
diff --git a/gnu/usr.bin/as/config/ho-rs6000.h b/gnu/usr.bin/as/config/ho-rs6000.h
deleted file mode 100644
index ed49484..0000000
--- a/gnu/usr.bin/as/config/ho-rs6000.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* ho-rs6000.h Rs6000 host-specific header file.
- Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define M_RS6000 1
-
-/* end of ho-rs6000.h */
diff --git a/gnu/usr.bin/as/config/ho-sun3.h b/gnu/usr.bin/as/config/ho-sun3.h
deleted file mode 100644
index 0d68e6f..0000000
--- a/gnu/usr.bin/as/config/ho-sun3.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <ho-sunos.h>
-
-/* end of ho-sun3.h */
diff --git a/gnu/usr.bin/as/config/ho-sun386.h b/gnu/usr.bin/as/config/ho-sun386.h
deleted file mode 100644
index 6c74df4..0000000
--- a/gnu/usr.bin/as/config/ho-sun386.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <ho-sunos.h>
-
-extern int sprintf();
-
-/* end of ho-sun386.h */
diff --git a/gnu/usr.bin/as/config/ho-sun4.h b/gnu/usr.bin/as/config/ho-sun4.h
deleted file mode 100644
index cf619e8..0000000
--- a/gnu/usr.bin/as/config/ho-sun4.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <ho-sunos.h>
-
-/* end of ho-sun4.h */
diff --git a/gnu/usr.bin/as/config/ho-sunos.h b/gnu/usr.bin/as/config/ho-sunos.h
deleted file mode 100644
index 9c6cc01..0000000
--- a/gnu/usr.bin/as/config/ho-sunos.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* This file is ho-sunos.h
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if __STDC__ != 1
-#define NO_STDARG
-#endif /* not __STDC__ */
-
-#if !defined(__GNUC__) && (__STDC__ != 1)
-#include <memory.h>
-#else
-extern int memset();
-#endif
-
-/* #include <sys/stdtypes.h> before <stddef.h> when compiling by GCC. */
-#include <sys/stdtypes.h>
-#include <stddef.h>
-#include <ctype.h>
-#include <string.h>
-
-/* externs for system libraries. */
-
-/*extern int abort();*/
-/*extern int exit();*/
-extern char *malloc();
-extern char *realloc();
-extern char *strchr();
-extern char *strrchr();
-extern int _filbuf();
-extern int _flsbuf();
-extern int fclose();
-extern int fgetc();
-extern int fprintf();
-extern int fread();
-extern int free();
-extern int perror();
-extern int printf();
-extern int rewind();
-extern int setvbuf();
-extern int sscanf();
-extern int strcmp();
-extern int strlen();
-extern int strncmp();
-extern int time();
-extern int ungetc();
-extern int vfprintf();
-extern int vprintf();
-extern int vsprintf();
-extern long atol();
-
-#ifndef tolower
-extern int tolower();
-#endif /* tolower */
-
-#ifndef toupper
-extern int toupper();
-#endif /* toupper */
-
-/*
- * Local Variables:
- * fill-column: 80
- * comment-column: 0
- * End:
- */
-
-/* end of ho-sunos.h */
diff --git a/gnu/usr.bin/as/config/ho-sysv.h b/gnu/usr.bin/as/config/ho-sysv.h
deleted file mode 100644
index 5407e5d..0000000
--- a/gnu/usr.bin/as/config/ho-sysv.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ho-sysv.h System V specific header file.
- Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define HO_USG
-
-#define setbuffer(stream, buf, size) setvbuf((stream), (buf), _IOLBF, (size))
-
-extern int free();
-extern char *malloc();
-
-/* end of ho-sysv.h */
diff --git a/gnu/usr.bin/as/config/ho-vax.h b/gnu/usr.bin/as/config/ho-vax.h
deleted file mode 100644
index ea77e81..0000000
--- a/gnu/usr.bin/as/config/ho-vax.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ho-vax.h Intended for vax ultrix
- Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if __STDC__ != 1
-#define NO_STDARG
-#endif /* not ansi */
-
-extern char *malloc();
-extern int free();
-
-/* end of ho-vax.h */
diff --git a/gnu/usr.bin/as/config/ho-vms.h b/gnu/usr.bin/as/config/ho-vms.h
deleted file mode 100644
index 63f448e..0000000
--- a/gnu/usr.bin/as/config/ho-vms.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ho-vax.h Intended for vax vms
- Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define HO_VAX 1
-
-#include "ho-vax.h"
-
-/* We get better performance if we use the macros rather than the functions.*/
-#include <ctype.h>
-
-/* We need this to make sure that sys_nerr has the right Psect hack. */
-#include <perror.h>
-
-/* end of ho-vms.h */
diff --git a/gnu/usr.bin/as/config/mh-i386 b/gnu/usr.bin/as/config/mh-i386
deleted file mode 100644
index 3375d42..0000000
--- a/gnu/usr.bin/as/config/mh-i386
+++ /dev/null
@@ -1 +0,0 @@
-ALLOCA=alloca.o
diff --git a/gnu/usr.bin/as/config/mh-i386aix b/gnu/usr.bin/as/config/mh-i386aix
deleted file mode 100644
index a1e5d77..0000000
--- a/gnu/usr.bin/as/config/mh-i386aix
+++ /dev/null
@@ -1,5 +0,0 @@
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV
-RANLIB = /bin/true
-CC = gcc
-MINUS_G = -O
diff --git a/gnu/usr.bin/as/config/mh-i386v4 b/gnu/usr.bin/as/config/mh-i386v4
deleted file mode 100644
index 5bfcd28..0000000
--- a/gnu/usr.bin/as/config/mh-i386v4
+++ /dev/null
@@ -1 +0,0 @@
-HLIBS=-lucb
diff --git a/gnu/usr.bin/as/config/mt-ebmon29k b/gnu/usr.bin/as/config/mt-ebmon29k
deleted file mode 100644
index 528e6fc..0000000
--- a/gnu/usr.bin/as/config/mt-ebmon29k
+++ /dev/null
@@ -1,6 +0,0 @@
-TARG_CPU_DEPENDENTS=
-LOCAL_LOADLIBES=../bfd$(subdir)/libbfd.a
-TDEFINES=-DBFD_HEADERS -DMANY_SEGMENTS -DBFD
-
-
-
diff --git a/gnu/usr.bin/as/config/mt-h8300 b/gnu/usr.bin/as/config/mt-h8300
deleted file mode 100644
index d968db2..0000000
--- a/gnu/usr.bin/as/config/mt-h8300
+++ /dev/null
@@ -1,5 +0,0 @@
-TARG_CPU_DEPENDENTS=$(srcdir)/../include/opcode/h8300.h
-LOCAL_LOADLIBES=$(srcdir)/../bfd/$(srcdir)/libbfd.a
-TDEFINES=-DBFD_HEADERS -DMANY_SEGMENTS -DBFD
-
-CC=gcc
diff --git a/gnu/usr.bin/as/config/mt-h8300hds b/gnu/usr.bin/as/config/mt-h8300hds
deleted file mode 100644
index 1e6eb3c..0000000
--- a/gnu/usr.bin/as/config/mt-h8300hds
+++ /dev/null
@@ -1,4 +0,0 @@
-TARG_CPU_DEPENDENTS=$(srcdir)/../include/h8300-opcode.h
-LOCAL_LOADLIBES=$(srcdir)/../bfd/$(srcdir)/libbfd.a
-TDEFINES=-DBFD -DMANY_SEGMENTS
-
diff --git a/gnu/usr.bin/as/config/mt-i386aix b/gnu/usr.bin/as/config/mt-i386aix
deleted file mode 100644
index 225fc36..0000000
--- a/gnu/usr.bin/as/config/mt-i386aix
+++ /dev/null
@@ -1,3 +0,0 @@
-# TDEFINES = -DBFD_HEADERS
-CC = gcc
-MINUS_G = -O
diff --git a/gnu/usr.bin/as/config/mt-mips b/gnu/usr.bin/as/config/mt-mips
deleted file mode 100644
index f40f51d..0000000
--- a/gnu/usr.bin/as/config/mt-mips
+++ /dev/null
@@ -1 +0,0 @@
-ALL=fake-as
diff --git a/gnu/usr.bin/as/config/mt-rs6000 b/gnu/usr.bin/as/config/mt-rs6000
deleted file mode 100644
index f40f51d..0000000
--- a/gnu/usr.bin/as/config/mt-rs6000
+++ /dev/null
@@ -1 +0,0 @@
-ALL=fake-as
diff --git a/gnu/usr.bin/as/config/obj-aout.c b/gnu/usr.bin/as/config/obj-aout.c
deleted file mode 100644
index 8aaa7d7..0000000
--- a/gnu/usr.bin/as/config/obj-aout.c
+++ /dev/null
@@ -1,654 +0,0 @@
-/* a.out object file format
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write
- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "as.h"
-#include "obstack.h"
-
-
-#include <stab.h>
-
-/* in: segT out: N_TYPE bits */
-const short seg_N_TYPE[] = {
- N_ABS,
- N_TEXT,
- N_DATA,
- N_BSS,
- N_UNDF, /* unknown */
- N_UNDF, /* absent */
- N_UNDF, /* pass1 */
- N_UNDF, /* error */
- N_UNDF, /* bignum/flonum */
- N_UNDF, /* difference */
- N_UNDF, /* debug */
- N_UNDF, /* ntv */
- N_UNDF, /* ptv */
- N_REGISTER, /* register */
-};
-
-const segT N_TYPE_seg[N_TYPE+2] = { /* N_TYPE == 0x1E = 32-2 */
- SEG_UNKNOWN, SEG_GOOF, /* N_UNDF == 0 */
- SEG_ABSOLUTE, SEG_GOOF, /* N_ABS == 2 */
- SEG_TEXT, SEG_GOOF, /* N_TEXT == 4 */
- SEG_DATA, SEG_GOOF, /* N_DATA == 6 */
- SEG_BSS, SEG_GOOF, /* N_BSS == 8 */
- SEG_GOOF, SEG_GOOF, /* N_INDR == 0xa */
- SEG_GOOF, SEG_GOOF, /* 0xc */
- SEG_GOOF, SEG_GOOF, /* 0xe */
- SEG_GOOF, SEG_GOOF, /* 0x10 */
- SEG_REGISTER, SEG_GOOF, /* 0x12 (dummy N_REGISTER) */
- SEG_GOOF, SEG_GOOF, /* N_SETA == 0x14 */
- SEG_GOOF, SEG_GOOF, /* N_SETT == 0x16 */
- SEG_GOOF, SEG_GOOF, /* N_SETD == 0x18 */
- SEG_GOOF, SEG_GOOF, /* N_SETB == 0x1a */
- SEG_GOOF, SEG_GOOF, /* N_SETV == 0x1c */
- SEG_GOOF, SEG_GOOF, /* N_WARNING == 0x1e */
-};
-
-#if __STDC__ == 1
-static void obj_aout_stab(int what);
-static void obj_aout_line(void);
-static void obj_aout_desc(void);
-#else /* not __STDC__ */
-static void obj_aout_desc();
-static void obj_aout_stab();
-static void obj_aout_line();
-#endif /* not __STDC__ */
-
-const pseudo_typeS obj_pseudo_table[] = {
-#ifndef IGNORE_DEBUG
- /* stabs debug info */
- { "line", obj_aout_line, 0 }, /* source code line number */
- { "ln", obj_aout_line, 0 }, /* coff line number that we use anyway */
- { "desc", obj_aout_desc, 0 }, /* desc */
- { "stabd", obj_aout_stab, 'd' }, /* stabs */
- { "stabn", obj_aout_stab, 'n' }, /* stabs */
- { "stabs", obj_aout_stab, 's' }, /* stabs */
-#else /* IGNORE_DEBUG */
- { "line", obj_aout_line, 0 }, /* source code line number */
- { "ln", obj_aout_line, 0 }, /* coff line number that we use anyway */
- { "desc", obj_aout_desc, 0 }, /* desc */
- { "stabd", obj_aout_stab, 'd' }, /* stabs */
- { "stabn", obj_aout_stab, 'n' }, /* stabs */
- { "stabs", obj_aout_stab, 's' }, /* stabs */
-#endif /* IGNORE_DEBUG */
-
- /* coff debug pseudos (ignored) */
- { "def", s_ignore, 0 },
- { "dim", s_ignore, 0 },
- { "endef", s_ignore, 0 },
- { "ident", s_ignore, 0 },
- { "line", s_ignore, 0 },
- { "ln", s_ignore, 0 },
- { "scl", s_ignore, 0 },
- { "size", s_size, 0 },
- { "tag", s_ignore, 0 },
- { "type", s_type, 0 },
- { "val", s_ignore, 0 },
- { "version", s_ignore, 0 },
- { "weak", s_weak, 0 },
-
- /* stabs-in-coff (?) debug pseudos (ignored) */
- { "optim", s_ignore, 0 }, /* For sun386i cc (?) */
-
- /* other stuff */
- { "ABORT", s_abort, 0 },
-
- { NULL} /* end sentinel */
-}; /* obj_pseudo_table */
-
-
-/* Relocation. */
-
-/*
- * emit_relocations()
- *
- * Crawl along a fixS chain. Emit the segment's relocations.
- */
-void obj_emit_relocations(where, fixP, segment_address_in_file)
-char **where;
-fixS *fixP; /* Fixup chain for this segment. */
-relax_addressT segment_address_in_file;
-{
- for (; fixP; fixP = fixP->fx_next) {
- if (fixP->fx_addsy != NULL) {
- tc_aout_fix_to_chars(*where, fixP, segment_address_in_file);
- *where += md_reloc_size;
- } /* if there is an add symbol */
- } /* for each fix */
-
- return;
-} /* obj_emit_relocations() */
-
-/* Aout file generation & utilities */
-void obj_header_append(where, headers)
-char **where;
-object_headers *headers;
-{
- tc_headers_hook(headers);
-
-#if defined(FREEBSD_AOUT) || defined(NETBSD_AOUT)
- /* `a_info' (magic, mid, flags) is in network byte-order */
- (*where)[0] = ((char *)&headers->header.a_info)[0];
- (*where)[1] = ((char *)&headers->header.a_info)[1];
- (*where)[2] = ((char *)&headers->header.a_info)[2];
- (*where)[3] = ((char *)&headers->header.a_info)[3];
-#else
- md_number_to_chars(*where, headers->header.a_info,
- sizeof(headers->header.a_info));
-#endif
- *where += sizeof(headers->header.a_info);
-
-#ifdef TE_HPUX
- md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare1 */
- md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare2 */
-#endif /* TE_HPUX */
-
- md_number_to_chars(*where, headers->header.a_text, 4); *where += 4;
- md_number_to_chars(*where, headers->header.a_data, 4); *where += 4;
- md_number_to_chars(*where, headers->header.a_bss, 4); *where += 4;
-
-#ifndef TE_HPUX
- md_number_to_chars(*where, headers->header.a_syms, 4); *where += 4;
- md_number_to_chars(*where, headers->header.a_entry, 4); *where += 4;
-#endif /* not TE_HPUX */
-
- md_number_to_chars(*where, headers->header.a_trsize, 4); *where += 4;
- md_number_to_chars(*where, headers->header.a_drsize, 4); *where += 4;
-
-#ifdef TE_SEQUENT
- memset(*where, '\0', 3 * 2 * 4); *where += 3 * 2 * 4; /* global descriptor table? */
- md_number_to_chars(*where, 0, 4); *where += 4; /* shdata - length of initialized shared data */
- md_number_to_chars(*where, 0, 4); *where += 4; /* shbss - length of uninitialized shared data */
- md_number_to_chars(*where, 0, 4); *where += 4; /* shdrsize - length of shared data relocation */
-
- memset(*where, '\0', 11 * 4); *where += 11 * 4; /* boostrap for standalone */
- memset(*where, '\0', 3 * 4); *where += 3 * 4; /* reserved */
- md_number_to_chars(*where, 0, 4); *where += 4; /* version */
-#endif /* TE_SEQUENT */
-
-#ifdef TE_HPUX
- md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare3 - HP = pascal interface size */
- md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare4 - HP = symbol table size */
- md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare5 - HP = debug name table size */
-
- md_number_to_chars(*where, headers->header.a_entry, 4); *where += 4;
-
- md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare6 - HP = source line table size */
- md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare7 - HP = value table size */
-
- md_number_to_chars(*where, headers->header.a_syms, 4); *where += 4;
-
- md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare8 */
-#endif /* TE_HPUX */
-
- return;
-} /* obj_append_header() */
-
-void obj_symbol_to_chars(where, symbolP)
-char **where;
-symbolS *symbolP;
-{
- md_number_to_chars((char *)&(S_GET_OFFSET(symbolP)), S_GET_OFFSET(symbolP), sizeof(S_GET_OFFSET(symbolP)));
- md_number_to_chars((char *)&(S_GET_DESC(symbolP)), S_GET_DESC(symbolP), sizeof(S_GET_DESC(symbolP)));
- md_number_to_chars((char *)&(S_GET_VALUE(symbolP)), S_GET_VALUE(symbolP), sizeof(S_GET_VALUE(symbolP)));
-
- append(where, (char *)&symbolP->sy_symbol, sizeof(obj_symbol_type));
-} /* obj_symbol_to_chars() */
-
-void obj_emit_symbols(where, symbol_rootP)
-char **where;
-symbolS *symbol_rootP;
-{
- symbolS * symbolP;
-
- /*
- * Emit all symbols left in the symbol chain.
- */
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- /* Used to save the offset of the name. It is used to point
- to the string in memory but must be a file offset. */
- register char *temp;
-
- temp = S_GET_NAME(symbolP);
- S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
-
- /* Any symbol still undefined and is not a dbg symbol is made N_EXT. */
- if (!S_IS_DEBUG(symbolP) && !S_IS_DEFINED(symbolP))
- S_SET_EXTERNAL(symbolP);
-
- /*
- * Put aux info in lower four bits of `n_other' field
- * Do this only now, because things like S_IS_DEFINED()
- * depend on S_GET_OTHER() for some unspecified reason.
- */
- S_SET_OTHER(symbolP,
- (symbolP->sy_bind << 4) | (symbolP->sy_aux & 0xf));
-
- if (S_GET_TYPE(symbolP) == N_SIZE) {
- expressionS *exp = (expressionS*)symbolP->sy_sizexp;
- long size = 0;
-
- if (exp == NULL) {
- as_bad("Internal error: no size expression");
- return;
- }
-
- switch (exp->X_seg) {
- case SEG_ABSOLUTE:
- size = exp->X_add_number;
- break;
- case SEG_DIFFERENCE:
- size = S_GET_VALUE(exp->X_add_symbol) -
- S_GET_VALUE(exp->X_subtract_symbol) +
- exp->X_add_number;
- break;
- default:
- as_bad("Unsupported .size expression");
- break;
- }
- S_SET_VALUE(symbolP, size);
- }
-
- obj_symbol_to_chars(where, symbolP);
- S_SET_NAME(symbolP,temp);
- }
-} /* emit_symbols() */
-
-#if comment
-/* uneeded if symbol is born zeroed. */
-void obj_symbol_new_hook(symbolP)
-symbolS *symbolP;
-{
- S_SET_OTHER(symbolP, 0);
- S_SET_DESC(symbolP, 0);
- return;
-} /* obj_symbol_new_hook() */
-#endif /* comment */
-
-static void obj_aout_line() {
- /* Assume delimiter is part of expression. */
- /* BSD4.2 as fails with delightful bug, so we */
- /* are not being incompatible here. */
- new_logical_line((char *)NULL, (int)(get_absolute_expression()));
- demand_empty_rest_of_line();
-} /* obj_aout_line() */
-
-/*
- * stab()
- *
- * Handle .stabX directives, which used to be open-coded.
- * So much creeping featurism overloaded the semantics that we decided
- * to put all .stabX thinking in one place. Here.
- *
- * We try to make any .stabX directive legal. Other people's AS will often
- * do assembly-time consistency checks: eg assigning meaning to n_type bits
- * and "protecting" you from setting them to certain values. (They also zero
- * certain bits before emitting symbols. Tut tut.)
- *
- * If an expression is not absolute we either gripe or use the relocation
- * information. Other people's assemblers silently forget information they
- * don't need and invent information they need that you didn't supply.
- *
- * .stabX directives always make a symbol table entry. It may be junk if
- * the rest of your .stabX directive is malformed.
- */
-static void obj_aout_stab(what)
-int what;
-{
-#ifndef NO_LISTING
- extern int listing;
-#endif /* NO_LISTING */
-
- register symbolS *symbolP = 0;
- register char *string;
- int saved_type = 0;
- int length;
- int goof; /* TRUE if we have aborted. */
- long longint;
-
- /*
- * Enter with input_line_pointer pointing past .stabX and any following
- * whitespace.
- */
- goof = 0; /* JF who forgot this?? */
- if (what == 's') {
- string = demand_copy_C_string(& length);
- SKIP_WHITESPACE();
- if (* input_line_pointer == ',')
- input_line_pointer ++;
- else {
- as_bad("I need a comma after symbol's name");
- goof = 1;
- }
- } else
- string = "";
-
- /*
- * Input_line_pointer->after ','. String->symbol name.
- */
- if (! goof) {
- symbolP = symbol_new(string,
- SEG_UNKNOWN,
- 0,
- (struct frag *)0);
- switch (what) {
- case 'd':
- S_SET_NAME(symbolP, NULL); /* .stabd feature. */
- S_SET_VALUE(symbolP, obstack_next_free(&frags) - frag_now->fr_literal);
- symbolP->sy_frag = frag_now;
- break;
-
- case 'n':
- symbolP->sy_frag = &zero_address_frag;
- break;
-
- case 's':
- symbolP->sy_frag = & zero_address_frag;
- break;
-
- default:
- BAD_CASE(what);
- break;
- }
-
- if (get_absolute_expression_and_terminator(&longint) == ',')
- symbolP->sy_symbol.n_type = saved_type = longint;
- else {
- as_bad("I want a comma after the n_type expression");
- goof = 1;
- input_line_pointer --; /* Backup over a non-',' char. */
- }
- }
-
- if (!goof) {
- if (get_absolute_expression_and_terminator(&longint) == ',')
- S_SET_OTHER(symbolP, longint);
- else {
- as_bad("I want a comma after the n_other expression");
- goof = 1;
- input_line_pointer--; /* Backup over a non-',' char. */
- }
- }
-
- if (!goof) {
- S_SET_DESC(symbolP, get_absolute_expression());
- if (what == 's' || what == 'n') {
- if (*input_line_pointer != ',') {
- as_bad("I want a comma after the n_desc expression");
- goof = 1;
- } else {
- input_line_pointer++;
- }
- }
- }
-
- if ((!goof) && (what == 's' || what == 'n')) {
- pseudo_set(symbolP);
- symbolP->sy_symbol.n_type = saved_type;
- }
-#ifndef NO_LISTING
- if (listing && !goof)
- {
- if (symbolP->sy_symbol.n_type == N_SLINE)
- {
-
- listing_source_line(symbolP->sy_symbol.n_desc);
- }
- else if (symbolP->sy_symbol.n_type == N_SO
- || symbolP->sy_symbol.n_type == N_SOL)
- {
- listing_source_file(string);
- }
- }
-#endif
-
- if (goof)
- ignore_rest_of_line();
- else
- demand_empty_rest_of_line ();
-} /* obj_aout_stab() */
-
-static void obj_aout_desc() {
- register char *name;
- register char c;
- register char *p;
- register symbolS *symbolP;
- register int temp;
-
- /*
- * Frob invented at RMS' request. Set the n_desc of a symbol.
- */
- name = input_line_pointer;
- c = get_symbol_end();
- p = input_line_pointer;
- * p = c;
- SKIP_WHITESPACE();
- if (*input_line_pointer != ',') {
- *p = 0;
- as_bad("Expected comma after name \"%s\"", name);
- *p = c;
- ignore_rest_of_line();
- } else {
- input_line_pointer ++;
- temp = get_absolute_expression();
- *p = 0;
- symbolP = symbol_find_or_make(name);
- *p = c;
- S_SET_DESC(symbolP,temp);
- }
- demand_empty_rest_of_line();
-} /* obj_aout_desc() */
-
-void obj_read_begin_hook() {
- return;
-} /* obj_read_begin_hook() */
-
-void obj_crawl_symbol_chain(headers)
-object_headers *headers;
-{
- symbolS *symbolP;
- symbolS **symbolPP;
- int symbol_number = 0;
-
- /* JF deal with forward references first... */
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- if (symbolP->sy_forward && symbolP->sy_forward != symbolP) {
- S_SET_SEGMENT(symbolP,
- S_GET_SEGMENT(symbolP->sy_forward));
- S_SET_VALUE(symbolP, S_GET_VALUE(symbolP)
- + S_GET_VALUE(symbolP->sy_forward)
- + symbolP->sy_forward->sy_frag->fr_address);
-
- symbolP->sy_aux |= symbolP->sy_forward->sy_aux;
- symbolP->sy_sizexp = symbolP->sy_forward->sy_sizexp;
- if (S_IS_EXTERNAL(symbolP->sy_forward))
- S_SET_EXTERNAL(symbolP);
- } /* if it has a forward reference */
- symbolP->sy_forward=0;
- } /* walk the symbol chain */
-
- tc_crawl_symbol_chain(headers);
-
- symbolPP = &symbol_rootP; /*->last symbol chain link. */
- while ((symbolP = *symbolPP) != NULL) {
- if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_DATA)) {
- S_SET_SEGMENT(symbolP, SEG_TEXT);
- } /* if pushing data into text */
-
- S_SET_VALUE(symbolP, S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address);
-
- /* OK, here is how we decide which symbols go out into the
- brave new symtab. Symbols that do are:
-
- * symbols with no name (stabd's?)
- * symbols with debug info in their N_TYPE
- * symbols marked "forceout" (to force out local `L'
- symbols in PIC code)
-
- Symbols that don't are:
- * symbols that are registers
- * symbols with \1 as their 3rd character (numeric labels)
- * "local labels" as defined by S_LOCAL_NAME(name)
- if the -L switch was passed to gas.
-
- All other symbols are output. We complain if a deleted
- symbol was marked external. */
-
-
- if (!S_IS_REGISTER(symbolP)
- && (!S_GET_NAME(symbolP)
- || S_IS_DEBUG(symbolP)
-#ifdef TC_I960
- /* FIXME-SOON this ifdef seems highly dubious to me. xoxorich. */
- || !S_IS_DEFINED(symbolP)
- || S_IS_EXTERNAL(symbolP)
-#endif /* TC_I960 */
- || (S_GET_NAME(symbolP)[0] != '\001' &&
- (flagseen['L'] || ! S_LOCAL_NAME(symbolP))
-#ifdef PIC
- || (picmode && symbolP->sy_forceout)
-#endif
- )
- )
-#ifdef PIC
- && (!picmode ||
- symbolP != GOT_symbol || got_referenced != 0
- )
-#endif
- ) {
- symbolP->sy_number = symbol_number++;
-
- /* The + 1 after strlen account for the \0 at the
- end of each string */
- if (!S_IS_STABD(symbolP)) {
- /* Ordinary case. */
- symbolP->sy_name_offset = string_byte_count;
- string_byte_count += strlen(S_GET_NAME(symbolP)) + 1;
- }
- else /* .Stabd case. */
- symbolP->sy_name_offset = 0;
-
- /*
- * If symbol has a known size, output an extra symbol
- * of type N_SIZE and with the same name.
- * We cannot evaluate the size expression just yet, as
- * some its terms may not have had their final values
- * set. We defer this until `obj_emit_symbols()'
- */
- if (picmode &&
- S_GET_TYPE(symbolP) != N_SIZE &&
-#ifndef GRACE_PERIOD_EXPIRED
- /*Can be enabled when no more old ld's around*/
- (symbolP->sy_aux == AUX_OBJECT) &&
-#endif
- symbolP->sy_sizexp) {
-
- symbolS *addme;
-
- /* Put a new symbol on the chain */
-#ifdef NSIZE_PREFIX /*XXX*/
- char buf[BUFSIZ];
-
- buf[0] = NSIZE_PREFIX;
- strncpy(buf+1, S_GET_NAME(symbolP), BUFSIZ-2);
- addme = symbol_make(buf);
-#else
- addme = symbol_make(S_GET_NAME(symbolP));
-#endif
- /* Set type and transfer size expression */
- addme->sy_symbol.n_type = N_SIZE;
- addme->sy_sizexp = symbolP->sy_sizexp;
- symbolP->sy_sizexp = NULL;
-
- /* Set external if symbolP is */
- if (S_IS_EXTERN(symbolP))
- S_SET_EXTERNAL(addme);
-
- }
- symbolPP = &(symbol_next(symbolP));
- } else {
- if ((S_IS_EXTERNAL(symbolP) || !S_IS_DEFINED(symbolP))
-#ifdef PIC
- && (!picmode ||
- symbolP != GOT_symbol || got_referenced != 0
- )
-#endif
- ) {
- as_bad("Local symbol %s never defined.", decode_local_label_name(S_GET_NAME(symbolP)));
- } /* oops. */
-
- /* Unhook it from the chain */
- *symbolPP = symbol_next(symbolP);
- } /* if this symbol should be in the output */
- } /* for each symbol */
-
- H_SET_SYMBOL_TABLE_SIZE(headers, symbol_number);
-
- return;
-} /* obj_crawl_symbol_chain() */
-
-/*
- * Find strings by crawling along symbol table chain.
- */
-
-void obj_emit_strings(where)
-char **where;
-{
- symbolS *symbolP;
-
-#ifdef CROSS_COMPILE
- /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
- md_number_to_chars(*where, string_byte_count, sizeof(string_byte_count));
- *where += sizeof(string_byte_count);
-#else /* CROSS_COMPILE */
- append (where, (char *)&string_byte_count, (unsigned long)sizeof(string_byte_count));
-#endif /* CROSS_COMPILE */
-
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- if (S_GET_NAME(symbolP))
- append(&next_object_file_charP, S_GET_NAME(symbolP),
- (unsigned long)(strlen (S_GET_NAME(symbolP)) + 1));
- } /* walk symbol chain */
-
- return;
-} /* obj_emit_strings() */
-
-void obj_pre_write_hook(headers)
-object_headers *headers;
-{
- H_SET_INFO(headers,
- DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE,
- AOUT_MACHTYPE,
- AOUT_FLAGS,
- AOUT_VERSION);
-
- H_SET_ENTRY_POINT(headers, 0);
-
- tc_aout_pre_write_hook(headers);
- return;
-} /* obj_pre_write_hook() */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-aout.c */
diff --git a/gnu/usr.bin/as/config/obj-aout.h b/gnu/usr.bin/as/config/obj-aout.h
deleted file mode 100644
index 05ad5b3..0000000
--- a/gnu/usr.bin/as/config/obj-aout.h
+++ /dev/null
@@ -1,305 +0,0 @@
-/* obj-aout.h, a.out object file format for gas, the assembler.
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write
- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- $Id$
- */
-
-
-/* Tag to validate a.out object file format processing */
-#define OBJ_AOUT 1
-
-#include "targ-cpu.h"
-
-#include "aout.h" /* Needed to define struct nlist. Sigh. */
-
-#ifndef AOUT_MACHTYPE
-#define AOUT_MACHTYPE 0
-#endif
-
-#ifndef AOUT_VERSION
-#define AOUT_VERSION 0
-#endif
-
-#ifndef AOUT_FLAGS
-#define AOUT_FLAGS 0
-#endif
-
-extern const short seg_N_TYPE[];
-extern const segT N_TYPE_seg[];
-#define N_REGISTER 0x12 /* Fake register type */
-
-#ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE
-#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC)
-#endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */
-
-/* First character of operand in `.type' directives */
-#define TYPE_OPERAND_FMT '@'
-
-/* SYMBOL TABLE */
-/* Symbol table entry data type */
-
-typedef struct nlist obj_symbol_type; /* Symbol table entry */
-
-/* Symbol table macros and constants */
-
-/*
- * Macros to extract information from a symbol table entry.
- * This syntaxic indirection allows independence regarding a.out or coff.
- * The argument (s) of all these macros is a pointer to a symbol table entry.
- */
-
-/* True if the symbol is external */
-#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT)
-
-/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
-#define S_IS_DEFINED(s) ((S_GET_TYPE(s) != N_UNDF) || (S_GET_OTHER(s) != 0) || (S_GET_DESC(s) != 0))
-
-#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER)
-
-/* True if a debug special symbol entry */
-#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB)
-/* True if a symbol is local symbol name */
-/* A symbol name whose name begin with ^A is a gas internal pseudo symbol
- nameless symbols come from .stab directives. */
-#define S_IS_LOCAL(s) (S_GET_NAME(s) && \
- !S_IS_DEBUG(s) && \
- (S_GET_NAME(s)[0] == '\001' || \
- (S_LOCAL_NAME(s) && !flagseen['L'])))
-/* True if a symbol is not defined in this file */
-#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
-/* True if the symbol has been generated because of a .stabd directive */
-#define S_IS_STABD(s) (S_GET_NAME(s) == (char *)0)
-
-/* Accessors */
-/* The value of the symbol */
-#define S_GET_VALUE(s) (((s)->sy_symbol.n_value))
-/* The name of the symbol */
-#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
-/* The pointer to the string table */
-#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx)
-/* The type of the symbol */
-#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE)
-/* The numeric value of the segment */
-#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)])
-/* The n_other expression value */
-#define S_GET_OTHER(s) ((s)->sy_symbol.n_other)
-/* The n_desc expression value */
-#define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
-
-/* Modifiers */
-/* Set the value of the symbol */
-#define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v))
-/* Assume that a symbol cannot be simultaneously in more than on segment */
-/* set segment */
-#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
-/* The symbol is external */
-#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT)
-/* The symbol is not external */
-#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT)
-/* Set the name of the symbol */
-#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
-/* Set the offset in the string table */
-#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
-/* Set the n_other expression value */
-#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
-/* Set the n_desc expression value */
-#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v))
-
-/* File header macro and type definition */
-
-#define H_GET_FILE_SIZE(h) (H_GET_HEADER_SIZE(h) \
- + H_GET_TEXT_SIZE(h) \
- + H_GET_DATA_SIZE(h) \
- + H_GET_SYMBOL_TABLE_SIZE(h) \
- + H_GET_TEXT_RELOCATION_SIZE(h) \
- + H_GET_DATA_RELOCATION_SIZE(h) \
- + H_GET_STRING_SIZE(h))
-
-#ifndef H_GET_HEADER_SIZE
-#define H_GET_HEADER_SIZE(h) (sizeof(struct exec))
-#endif /* not H_GET_HEADER_SIZE */
-
-#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
-#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
-#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
-#define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize)
-#define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize)
-#define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms)
-#define H_GET_ENTRY_POINT(h) ((h)->header.a_entry)
-#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
-#define H_GET_LINENO_SIZE(h) (0)
-
-#if defined(FREEBSD_AOUT) || defined(NETBSD_AOUT)
-
-#if defined(FREEBSD_AOUT)
-/* duplicate part of <sys/imgact_aout.h> */
-#define H_GET_FLAGS(h) \
- ( (((h)->header.a_info)&0xffff) \
- ? ((h)->header.a_info >> 26) & 0x3f ) \
- : 0 \
- )
-#define H_GET_MACHTYPE(h) \
- ( (((h)->header.a_info)&0xffff) \
- ? ((h)->header.a_info >>16 ) & 0x3ff) \
- : 0 \
- )
-
-#define H_GET_MAGIC_NUMBER(h) \
- ( (((h)->header.a_info)&0xffff) \
- ? ((h)->header.a_info & 0xffff) \
- : (ntohl(((h)->header.a_info))&0xffff) \
- )
-
-#define H_SET_INFO(h,mag,mid,f,v) \
- ( (h)->header.a_info = \
- htonl( (((f)&0x3f)<<26) | (((mid)&0x03ff)<<16) | (((mag)&0xffff)) ) )
-
-#endif /* FREEBSD_AOUT */
-
-#if defined(NETBSD_AOUT)
-/* SH*T, duplicate part of <a.out.h> */
-#define H_GET_FLAGS(h) \
- ( (((h)->header.a_info)&0xffff0000) \
- ? ((ntohl(((h)->header.a_info))>>26)&0x3f) \
- : 0 \
- )
-
-#define H_GET_MACHTYPE(h) \
- ( (((h)->header.a_info)&0xffff0000) \
- ? ((ntohl(((h)->header.a_info))>>16)&0x3ff) \
- : 0 \
- )
-
-#define H_GET_MAGIC_NUMBER(h) \
- ( (((h)->header.a_info)&0xffff0000) \
- ? (ntohl(((h)->header.a_info))&0xffff) \
- : ((h)->header.a_info & 0xffff) \
- )
-
-#define H_SET_INFO(h,mag,mid,f,v) \
- ( (h)->header.a_info = \
- htonl( (((f)&0x3f)<<26) | (((mid)&0x03ff)<<16) | (((mag)&0xffff)) ) )
-
-#endif /* NETBSD_AOUT */
-
-#define EX_DYNAMIC 0x20
-#define EX_PIC 0x10
-#undef AOUT_FLAGS
-#define AOUT_FLAGS (picmode ? EX_PIC : 0)
-
-#define H_GET_DYNAMIC(h) (H_GET_FLAGS(h) & EX_DYNAMIC)
-
-#define H_GET_VERSION(h) (0)
-
-#define H_SET_DYNAMIC(h,v) \
- H_SET_INFO(h, H_GET_MAGIC_NUMBER(h), H_GET_MACHTYPE(h), \
- (v)?(H_GET_FLAGS(h)|0x20):(H_GET_FLAGS(h)&(~0x20)), 0)
-
-#define H_SET_VERSION(h,v)
-
-#define H_SET_MACHTYPE(h,v) \
- H_SET_INFO(h, H_GET_MAGIC_NUMBER(h), (v), H_GET_FLAGS(h), 0)
-
-#define H_SET_MAGIC_NUMBER(h,v) \
- H_SET_INFO(h, (v), H_GET_MACHTYPE(h), H_GET_FLAGS(h), 0)
-
-#else /* !(FREEBSD_AOUT || NETBSD_AOUT) */
-
-#define H_GET_DYNAMIC(h) ((h)->header.a_info >> 31)
-#define H_GET_VERSION(h) (((h)->header.a_info >> 24) & 0x7f)
-#define H_GET_MACHTYPE(h) (((h)->header.a_info >> 16) & 0xff)
-#define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info & 0xffff)
-
-#define H_SET_DYNAMIC(h,v) ((h)->header.a_info = \
- (((v) << 31) \
- | (H_GET_VERSION(h) << 24) \
- | (H_GET_MACHTYPE(h) << 16) \
- | (H_GET_MAGIC_NUMBER(h))))
-
-#define H_SET_VERSION(h,v) ((h)->header.a_info = \
- ((H_GET_DYNAMIC(h) << 31) \
- | ((v) << 24) \
- | (H_GET_MACHTYPE(h) << 16) \
- | (H_GET_MAGIC_NUMBER(h))))
-
-#define H_SET_MACHTYPE(h,v) ((h)->header.a_info = \
- ((H_GET_DYNAMIC(h) << 31) \
- | (H_GET_VERSION(h) << 24) \
- | ((v) << 16) \
- | (H_GET_MAGIC_NUMBER(h))))
-
-#define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_info = \
- ((H_GET_DYNAMIC(h) << 31) \
- | (H_GET_VERSION(h) << 24) \
- | (H_GET_MACHTYPE(h) << 16) \
- | ((v))))
-#define H_SET_INFO(h,mag,mid,f,v) ((h)->header.a_info = \
- ((((f)==0x20) << 31) \
- | ((v) << 24) \
- | ((mid) << 16) \
- | ((mag))) )
-#endif /* FREEBSD_AOUT || NETBSD_AOUT */
-
-#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align(SEG_TEXT, (v)))
-#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align(SEG_DATA, (v)))
-#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align(SEG_BSS, (v)))
-
-#define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\
- H_SET_DATA_RELOCATION_SIZE((h),(d)))
-
-#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
-#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
-#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \
- sizeof(struct nlist))
-
-#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v))
-#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
-
-/*
- * Current means for getting the name of a segment.
- * This will change for infinite-segments support (e.g. COFF).
- */
-#define segment_name(seg) (seg_name[(int)(seg)])
-extern char *const seg_name[];
-
-typedef struct {
- struct exec header; /* a.out header */
- long string_table_size; /* names + '\0' + sizeof(int) */
-} object_headers;
-
-/* line numbering stuff. */
-#define OBJ_EMIT_LINENO(a, b, c) {;}
-
-#define obj_symbol_new_hook(s) {;}
-
-#if __STDC__ == 1
-struct fix;
-void tc_aout_fix_to_chars(char *where, struct fix *fixP, relax_addressT segment_address);
-#else /* not __STDC__ */
-void tc_aout_fix_to_chars();
-#endif /* not __STDC__ */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-aout.h */
diff --git a/gnu/usr.bin/as/config/obj-bfd-sunos.c b/gnu/usr.bin/as/config/obj-bfd-sunos.c
deleted file mode 100644
index 6db63de5..0000000
--- a/gnu/usr.bin/as/config/obj-bfd-sunos.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* obj-bfd-sunos.c
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
-#include "as.h"
-
-static
-
- const short seg_N_TYPE[] = {
- N_ABS,
- N_TEXT,
- N_DATA,
- N_BSS,
- N_UNDF, /* unknown */
- N_UNDF, /* absent */
- N_UNDF, /* pass1 */
- N_UNDF, /* error */
- N_UNDF, /* bignum/flonum */
- N_UNDF, /* difference */
- N_REGISTER, /* register */
- };
-
-const segT N_TYPE_seg[N_TYPE+2] = { /* N_TYPE == 0x1E = 32-2 */
- SEG_UNKNOWN, /* N_UNDF == 0 */
- SEG_GOOF,
- SEG_ABSOLUTE, /* N_ABS == 2 */
- SEG_GOOF,
- SEG_TEXT, /* N_TEXT == 4 */
- SEG_GOOF,
- SEG_DATA, /* N_DATA == 6 */
- SEG_GOOF,
- SEG_BSS, /* N_BSS == 8 */
- SEG_GOOF,
- SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
- SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
- SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
- SEG_REGISTER, /* dummy N_REGISTER for regs = 30 */
- SEG_GOOF,
-};
-
-
-void obj_symbol_new_hook(symbolP)
-symbolS *symbolP;
-{
- return;
-} /* obj_symbol_new_hook() */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-bfd-sunos.c */
diff --git a/gnu/usr.bin/as/config/obj-bfd-sunos.h b/gnu/usr.bin/as/config/obj-bfd-sunos.h
deleted file mode 100644
index 122594e..0000000
--- a/gnu/usr.bin/as/config/obj-bfd-sunos.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * This file is obj-bfd-sunos.h.
- */
-
-/* define an obj specific macro off which target cpu back ends may key. */
-#define OBJ_BFD
-#define OBJ_BFD_SUNOS
-
-#include "bfd.h"
-
-/* include whatever target cpu is appropriate. */
-#include "targ-cpu.h"
-
-/*
- * SYMBOLS
- */
-
-/*
- * If your object format needs to reorder symbols, define this. When
- * defined, symbols are kept on a doubly linked list and functions are
- * made available for push, insert, append, and delete. If not defined,
- * symbols are kept on a singly linked list, only the append and clear
- * facilities are available, and they are macros.
- */
-
-/* #define SYMBOLS_NEED_PACKPOINTERS */
-
-typedef asymbol obj_symbol_type;
-typedef void *object_headers;
-
-#define S_SET_NAME(s, v) ((s)->sy_symbol.name = (v))
-#define S_GET_NAME(s) ((s)->sy_symbol.name)
-#define S_SET_SEGMENT(s,v) ((s)->sy_symbol.udata = (v))
-#define S_GET_SEGMENT(s) ((s)->sy_symbol.udata)
-#define S_SET_EXTERNAL(s) ((s)->sy_symbol.flags |= BSF_GLOBAL)
-#define S_SET_VALUE(s,v) ((s)->sy_symbol.value = (v))
-#define S_GET_VALUE(s) ((s)->sy_symbol.value)
-#define S_IS_DEFINED(s) (!((s)->sy_symbol.flags & BSF_UNDEFINED))
-
-#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (0) /* your magic number */
-#define OBJ_EMIT_LINENO(a,b,c) /* must be *something*. This no-op's it out. */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-bfd-sunos.h */
diff --git a/gnu/usr.bin/as/config/obj-bout.c b/gnu/usr.bin/as/config/obj-bout.c
deleted file mode 100644
index 734f3a3..0000000
--- a/gnu/usr.bin/as/config/obj-bout.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/* b.out object file format
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write
- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "as.h"
-#include "obstack.h"
-
-#ifndef NO_LISTING
-#include "aout/stab_gnu.h"
-#endif /* NO_LISTING */
-
-const short /* in: segT out: N_TYPE bits */
- seg_N_TYPE[] = {
- N_ABS,
- N_TEXT,
- N_DATA,
- N_BSS,
- N_UNDF, /* unknown */
- N_UNDF, /* absent */
- N_UNDF, /* pass1 */
- N_UNDF, /* error */
- N_UNDF, /* bignum/flonum */
- N_UNDF, /* difference */
- N_REGISTER, /* register */
- };
-
-const segT N_TYPE_seg[N_TYPE+2] = { /* N_TYPE == 0x1E = 32-2 */
- SEG_UNKNOWN, /* N_UNDF == 0 */
- SEG_GOOF,
- SEG_ABSOLUTE, /* N_ABS == 2 */
- SEG_GOOF,
- SEG_TEXT, /* N_TEXT == 4 */
- SEG_GOOF,
- SEG_DATA, /* N_DATA == 6 */
- SEG_GOOF,
- SEG_BSS, /* N_BSS == 8 */
- SEG_GOOF,
- SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
- SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
- SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
- SEG_REGISTER, /* dummy N_REGISTER for regs = 30 */
- SEG_GOOF,
-};
-
-#if __STDC__ == 1
-static void obj_bout_stab(int what);
-static void obj_bout_line(void);
-static void obj_bout_desc(void);
-#else /* not __STDC__ */
-static void obj_bout_desc();
-static void obj_bout_stab();
-static void obj_bout_line();
-#endif /* not __STDC__ */
-
-const pseudo_typeS obj_pseudo_table[] = {
- /* stabs (aka a.out aka b.out directives for debug symbols) */
- { "desc", obj_bout_desc, 0 }, /* def */
- { "line", obj_bout_line, 0 }, /* source code line number */
- { "stabd", obj_bout_stab, 'd' }, /* stabs */
- { "stabn", obj_bout_stab, 'n' }, /* stabs */
- { "stabs", obj_bout_stab, 's' }, /* stabs */
-
- /* coff debugging directives. Currently ignored silently */
- { "def", s_ignore, 0 },
- { "dim", s_ignore, 0 },
- { "endef", s_ignore, 0 },
- { "ln", s_ignore, 0 },
- { "scl", s_ignore, 0 },
- { "size", s_ignore, 0 },
- { "tag", s_ignore, 0 },
- { "type", s_ignore, 0 },
- { "val", s_ignore, 0 },
-
- /* other stuff we don't handle */
- { "ABORT", s_ignore, 0 },
- { "ident", s_ignore, 0 },
-
- { NULL} /* end sentinel */
-}; /* obj_pseudo_table */
-
-/* Relocation. */
-
-/*
- * emit_relocations()
- *
- * Crawl along a fixS chain. Emit the segment's relocations.
- */
-void obj_emit_relocations(where, fixP, segment_address_in_file)
-char **where;
-fixS *fixP; /* Fixup chain for this segment. */
-relax_addressT segment_address_in_file;
-{
- for (; fixP; fixP = fixP->fx_next) {
- if (fixP->fx_addsy != NULL) {
- tc_bout_fix_to_chars(*where, fixP, segment_address_in_file);
- *where += sizeof(struct relocation_info);
- } /* if there's a symbol */
- } /* for each fixup */
-
-} /* emit_relocations() */
-
-/* Aout file generation & utilities */
-
-/* Convert a lvalue to machine dependent data */
-void obj_header_append(where, headers)
-char **where;
-object_headers *headers;
-{
- /* Always leave in host byte order */
-
- headers->header.a_talign = section_alignment[SEG_TEXT];
-
- if (headers->header.a_talign < 2){
- headers->header.a_talign = 2;
- } /* force to at least 2 */
-
- headers->header.a_dalign = section_alignment[SEG_DATA];
- headers->header.a_balign = section_alignment[SEG_BSS];
-
- headers->header.a_tload = 0;
- headers->header.a_dload = md_section_align(SEG_DATA, H_GET_TEXT_SIZE(headers));
-
- append(where, (char *) &headers->header, sizeof(headers->header));
-} /* a_header_append() */
-
-void obj_symbol_to_chars(where, symbolP)
-char **where;
-symbolS *symbolP;
-{
- /* leave in host byte order */
- append(where, (char *)&symbolP->sy_symbol, sizeof(obj_symbol_type));
-} /* obj_symbol_to_chars() */
-
-void obj_emit_symbols(where, symbol_rootP)
-char **where;
-symbolS *symbol_rootP;
-{
- symbolS * symbolP;
-
- /*
- * Emit all symbols left in the symbol chain.
- */
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- /* Used to save the offset of the name. It is used to point
- to the string in memory but must be a file offset. */
- char *temp;
-
- temp = S_GET_NAME(symbolP);
- S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
-
- /* Any symbol still undefined and is not a dbg symbol is made N_EXT. */
- if (!S_IS_DEBUG(symbolP) && !S_IS_DEFINED(symbolP)) S_SET_EXTERNAL(symbolP);
-
- obj_symbol_to_chars(where, symbolP);
- S_SET_NAME(symbolP,temp);
- }
-} /* emit_symbols() */
-
-void obj_symbol_new_hook(symbolP)
-symbolS *symbolP;
-{
- S_SET_OTHER(symbolP, 0);
- S_SET_DESC(symbolP, 0);
- return;
-} /* obj_symbol_new_hook() */
-
-static void obj_bout_line() {
- /* Assume delimiter is part of expression. */
- /* BSD4.2 as fails with delightful bug, so we */
- /* are not being incompatible here. */
- new_logical_line ((char *)NULL, (int)(get_absolute_expression ()));
- demand_empty_rest_of_line();
-} /* obj_bout_line() */
-
-/*
- * stab()
- *
- * Handle .stabX directives, which used to be open-coded.
- * So much creeping featurism overloaded the semantics that we decided
- * to put all .stabX thinking in one place. Here.
- *
- * We try to make any .stabX directive legal. Other people's AS will often
- * do assembly-time consistency checks: eg assigning meaning to n_type bits
- * and "protecting" you from setting them to certain values. (They also zero
- * certain bits before emitting symbols. Tut tut.)
- *
- * If an expression is not absolute we either gripe or use the relocation
- * information. Other people's assemblers silently forget information they
- * don't need and invent information they need that you didn't supply.
- *
- * .stabX directives always make a symbol table entry. It may be junk if
- * the rest of your .stabX directive is malformed.
- */
-static void obj_bout_stab(what)
-int what;
-{
- register symbolS * symbolP = 0;
- register char * string;
- int saved_type = 0;
- int length;
- int goof; /* TRUE if we have aborted. */
- long longint;
-
- /*
- * Enter with input_line_pointer pointing past .stabX and any following
- * whitespace.
- */
- goof = 0; /* JF who forgot this?? */
- if (what == 's') {
- string = demand_copy_C_string(& length);
- SKIP_WHITESPACE();
- if (*input_line_pointer == ',')
- input_line_pointer ++;
- else {
- as_bad("I need a comma after symbol's name");
- goof = 1;
- }
- } else
- string = "";
-
- /*
- * Input_line_pointer->after ','. String->symbol name.
- */
- if (!goof) {
- symbolP = symbol_new(string,
- SEG_UNKNOWN,
- 0,
- (struct frag *)0);
- switch (what) {
- case 'd':
- S_SET_NAME(symbolP,NULL); /* .stabd feature. */
- S_SET_VALUE(symbolP,obstack_next_free(&frags) -
- frag_now->fr_literal);
- symbolP->sy_frag = frag_now;
- break;
-
- case 'n':
- symbolP->sy_frag = &zero_address_frag;
- break;
-
- case 's':
- symbolP->sy_frag = & zero_address_frag;
- break;
-
- default:
- BAD_CASE(what);
- break;
- }
- if (get_absolute_expression_and_terminator(& longint) == ',')
- symbolP->sy_symbol.n_type = saved_type = longint;
- else {
- as_bad("I want a comma after the n_type expression");
- goof = 1;
- input_line_pointer--; /* Backup over a non-',' char. */
- }
- }
- if (! goof) {
- if (get_absolute_expression_and_terminator (& longint) == ',')
- S_SET_OTHER(symbolP,longint);
- else {
- as_bad("I want a comma after the n_other expression");
- goof = 1;
- input_line_pointer--; /* Backup over a non-',' char. */
- }
- }
- if (! goof) {
- S_SET_DESC(symbolP, get_absolute_expression ());
- if (what == 's' || what == 'n') {
- if (* input_line_pointer != ',') {
- as_bad("I want a comma after the n_desc expression");
- goof = 1;
- } else {
- input_line_pointer ++;
- }
- }
- }
- if ((!goof) && (what == 's' || what == 'n')) {
- pseudo_set(symbolP);
- symbolP->sy_symbol.n_type = saved_type;
- }
-#ifndef NO_LISTING
- {
- extern int listing;
-
- if (listing && !goof) {
- if (symbolP->sy_symbol.n_type == N_SLINE) {
-
- listing_source_line(symbolP->sy_symbol.n_desc);
- } else if (symbolP->sy_symbol.n_type == N_SO
- || symbolP->sy_symbol.n_type == N_SOL) {
- listing_source_file(string);
- }
- }
- }
-
-#endif
-
- if (goof)
- ignore_rest_of_line ();
- else
- demand_empty_rest_of_line ();
-} /* obj_bout_stab() */
-
-static void obj_bout_desc() {
- register char *name;
- register char c;
- register char *p;
- register symbolS * symbolP;
- register int temp;
-
- /*
- * Frob invented at RMS' request. Set the n_desc of a symbol.
- */
- name = input_line_pointer;
- c = get_symbol_end();
- p = input_line_pointer;
- * p = c;
- SKIP_WHITESPACE();
- if (*input_line_pointer != ',') {
- *p = 0;
- as_bad("Expected comma after name \"%s\"", name);
- *p = c;
- ignore_rest_of_line();
- } else {
- input_line_pointer ++;
- temp = get_absolute_expression ();
- *p = 0;
- symbolP = symbol_find_or_make(name);
- *p = c;
- S_SET_DESC(symbolP,temp);
- }
- demand_empty_rest_of_line();
-} /* obj_bout_desc() */
-
-void obj_read_begin_hook() {
- return;
-} /* obj_read_begin_hook() */
-
-void obj_crawl_symbol_chain(headers)
-object_headers *headers;
-{
- symbolS **symbolPP;
- symbolS *symbolP;
- int symbol_number = 0;
-
- /* JF deal with forward references first... */
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- if (symbolP->sy_forward) {
- S_SET_VALUE(symbolP, S_GET_VALUE(symbolP)
- + S_GET_VALUE(symbolP->sy_forward)
- + symbolP->sy_forward->sy_frag->fr_address);
-
- symbolP->sy_forward=0;
- } /* if it has a forward reference */
- } /* walk the symbol chain */
-
- tc_crawl_symbol_chain(headers);
-
- symbolPP = & symbol_rootP; /*->last symbol chain link. */
- while ((symbolP = *symbolPP) != NULL) {
- if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_DATA)) {
- S_SET_SEGMENT(symbolP, SEG_TEXT);
- } /* if pusing data into text */
-
- S_SET_VALUE(symbolP, S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address);
-
- /* OK, here is how we decide which symbols go out into the
- brave new symtab. Symbols that do are:
-
- * symbols with no name (stabd's?)
- * symbols with debug info in their N_TYPE
-
- Symbols that don't are:
- * symbols that are registers
- * symbols with \1 as their 3rd character (numeric labels)
- * "local labels" as defined by S_LOCAL_NAME(name)
- if the -L switch was passed to gas.
-
- All other symbols are output. We complain if a deleted
- symbol was marked external. */
-
-
- if (1
- && !S_IS_REGISTER(symbolP)
- && (!S_GET_NAME(symbolP)
- || S_IS_DEBUG(symbolP)
-#ifdef TC_I960
- /* FIXME-SOON this ifdef seems highly dubious to me. xoxorich. */
- || !S_IS_DEFINED(symbolP)
- || S_IS_EXTERNAL(symbolP)
-#endif /* TC_I960 */
- || (S_GET_NAME(symbolP)[0] != '\001' && (flagseen['L'] || ! S_LOCAL_NAME(symbolP))))) {
- symbolP->sy_number = symbol_number++;
-
- /* The + 1 after strlen account for the \0 at the
- end of each string */
- if (!S_IS_STABD(symbolP)) {
- /* Ordinary case. */
- symbolP->sy_name_offset = string_byte_count;
- string_byte_count += strlen(S_GET_NAME(symbolP)) + 1;
- }
- else /* .Stabd case. */
- symbolP->sy_name_offset = 0;
- symbolPP = &(symbol_next(symbolP));
- } else {
- if (S_IS_EXTERNAL(symbolP) || !S_IS_DEFINED(symbolP)) {
- as_bad("Local symbol %s never defined", S_GET_NAME(symbolP));
- } /* oops. */
-
- /* Unhook it from the chain */
- *symbolPP = symbol_next(symbolP);
- } /* if this symbol should be in the output */
- } /* for each symbol */
-
- H_SET_SYMBOL_TABLE_SIZE(headers, symbol_number);
-
- return;
-} /* obj_crawl_symbol_chain() */
-
-/*
- * Find strings by crawling along symbol table chain.
- */
-
-void obj_emit_strings(where)
-char **where;
-{
- symbolS *symbolP;
-
-#ifdef CROSS_COMPILE
- /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
- md_number_to_chars(*where, string_byte_count, sizeof(string_byte_count));
- *where += sizeof(string_byte_count);
-#else /* CROSS_COMPILE */
- append(where, (char *) &string_byte_count, (unsigned long) sizeof(string_byte_count));
-#endif /* CROSS_COMPILE */
-
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- if (S_GET_NAME(symbolP))
- append(where, S_GET_NAME(symbolP), (unsigned long)(strlen (S_GET_NAME(symbolP)) + 1));
- } /* walk symbol chain */
-
- return;
-} /* obj_emit_strings() */
-
-void obj_pre_write_hook(headers)
-object_headers *headers;
-{
- H_SET_MAGIC_NUMBER(headers, BMAGIC);
- H_SET_ENTRY_POINT(headers, 0);
-
- return;
-} /* obj_pre_write_hook() */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-bout.c */
diff --git a/gnu/usr.bin/as/config/obj-bout.h b/gnu/usr.bin/as/config/obj-bout.h
deleted file mode 100644
index 6de818a..0000000
--- a/gnu/usr.bin/as/config/obj-bout.h
+++ /dev/null
@@ -1,313 +0,0 @@
-/* b.out object file format
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write
- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA
- 02139, USA. */
-
-/*
- * This file is a modified version of 'a.out.h'. It is to be used in all GNU
- * tools modified to support the i80960 b.out format (or tools that operate on
- * object files created by such tools).
- *
- * All i80960 development is done in a CROSS-DEVELOPMENT environment. I.e.,
- * object code is generated on, and executed under the direction of a symbolic
- * debugger running on, a host system. We do not want to be subject to the
- * vagaries of which host it is or whether it supports COFF or a.out format, or
- * anything else. We DO want to:
- *
- * o always generate the same format object files, regardless of host.
- *
- * o have an 'a.out' header that we can modify for our own purposes
- * (the 80960 is typically an embedded processor and may require
- * enhanced linker support that the normal a.out.h header can't
- * accommodate).
- *
- * As for byte-ordering, the following rules apply:
- *
- * o Text and data that is actually downloaded to the target is always
- * in i80960 (little-endian) order.
- *
- * o All other numbers (in the header, symbols, relocation directives)
- * are in host byte-order: object files CANNOT be lifted from a
- * little-end host and used on a big-endian (or vice versa) without
- * modification.
- *
- * o The downloader ('comm960') takes care to generate a pseudo-header
- * with correct (i80960) byte-ordering before shipping text and data
- * off to the NINDY monitor in the target systems. Symbols and
- * relocation info are never sent to the target.
- */
-
-
-#define OBJ_BOUT 1
-
-#include "targ-cpu.h"
-
-/* bout uses host byte order for headers */
-#ifdef CROSS_COMPILE
-#undef CROSS_COMPILE
-#endif /* CROSS_COMPILE */
-
-/* We want \v. */
-#define BACKSLASH_V 1
-
-#define OBJ_DEFAULT_OUTPUT_FILE_NAME "b.out"
-
-extern const short seg_N_TYPE[];
-extern const segT N_TYPE_seg[];
-
-#define BMAGIC 0415
-/* We don't accept the following (see N_BADMAG macro).
- * They're just here so GNU code will compile.
- */
-#define OMAGIC 0407 /* old impure format */
-#define NMAGIC 0410 /* read-only text */
-#define ZMAGIC 0413 /* demand load format */
-
-/* FILE HEADER
- * All 'lengths' are given as a number of bytes.
- * All 'alignments' are for relinkable files only; an alignment of
- * 'n' indicates the corresponding segment must begin at an
- * address that is a multiple of (2**n).
- */
-struct exec {
- /* Standard stuff */
- unsigned long a_magic; /* Identifies this as a b.out file */
- unsigned long a_text; /* Length of text */
- unsigned long a_data; /* Length of data */
- unsigned long a_bss; /* Length of runtime uninitialized data area */
- unsigned long a_syms; /* Length of symbol table */
- unsigned long a_entry; /* Runtime start address */
- unsigned long a_trsize; /* Length of text relocation info */
- unsigned long a_drsize; /* Length of data relocation info */
-
- /* Added for i960 */
- unsigned long a_tload; /* Text runtime load address */
- unsigned long a_dload; /* Data runtime load address */
- unsigned char a_talign; /* Alignment of text segment */
- unsigned char a_dalign; /* Alignment of data segment */
- unsigned char a_balign; /* Alignment of bss segment */
- unsigned char unused; /* (Just to make struct size a multiple of 4) */
-};
-
-#define N_BADMAG(x) (((x).a_magic) != BMAGIC)
-#define N_TXTOFF(x) ( sizeof(struct exec) )
-#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
-#define N_TROFF(x) ( N_DATOFF(x) + (x).a_data )
-#define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize )
-#define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize )
-#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
-
-/* A single entry in the symbol table
- */
-struct nlist {
- union {
- char *n_name;
- struct nlist *n_next;
- long n_strx; /* Index into string table */
- } n_un;
- unsigned char n_type; /* See below */
- char n_other; /* Used in i80960 support -- see below */
- short n_desc;
- unsigned long n_value;
-};
-
-typedef struct nlist obj_symbol_type;
-
-/* Legal values of n_type
- */
-#define N_UNDF 0 /* Undefined symbol */
-#define N_ABS 2 /* Absolute symbol */
-#define N_TEXT 4 /* Text symbol */
-#define N_DATA 6 /* Data symbol */
-#define N_BSS 8 /* BSS symbol */
-#define N_FN 31 /* Filename symbol */
-
-#define N_EXT 1 /* External symbol (OR'd in with one of above) */
-#define N_TYPE 036 /* Mask for all the type bits */
-#define N_STAB 0340 /* Mask for all bits used for SDB entries */
-
-#ifndef CUSTOM_RELOC_FORMAT
-struct relocation_info {
- int r_address; /* File address of item to be relocated */
- unsigned
- r_index:24,/* Index of symbol on which relocation is based*/
- r_pcrel:1, /* 1 => relocate PC-relative; else absolute
- * On i960, pc-relative implies 24-bit
- * address, absolute implies 32-bit.
- */
- r_length:2, /* Number of bytes to relocate:
- * 0 => 1 byte
- * 1 => 2 bytes
- * 2 => 4 bytes -- only value used for i960
- */
- r_extern:1,
- r_bsr:1, /* Something for the GNU NS32K assembler */
- r_disp:1, /* Something for the GNU NS32K assembler */
- r_callj:1, /* 1 if relocation target is an i960 'callj' */
- nuthin:1; /* Unused */
-};
-#endif /* CUSTOM_RELOC_FORMAT */
-
-/*
- * Macros to extract information from a symbol table entry.
- * This syntaxic indirection allows independence regarding a.out or coff.
- * The argument (s) of all these macros is a pointer to a symbol table entry.
- */
-
-/* Predicates */
-/* True if the symbol is external */
-#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT)
-
-/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
-#define S_IS_DEFINED(s) ((S_GET_TYPE(s) != N_UNDF) || (S_GET_DESC(s) != 0))
-#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER)
-
-/* True if a debug special symbol entry */
-#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB)
-/* True if a symbol is local symbol name */
-/* A symbol name whose name begin with ^A is a gas internal pseudo symbol
- nameless symbols come from .stab directives. */
-#define S_IS_LOCAL(s) (S_GET_NAME(s) && \
- !S_IS_DEBUG(s) && \
- (S_GET_NAME(s)[0] == '\001' || \
- (S_LOCAL_NAME(s) && !flagseen['L'])))
-/* True if a symbol is not defined in this file */
-#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
-/* True if the symbol has been generated because of a .stabd directive */
-#define S_IS_STABD(s) (S_GET_NAME(s) == NULL)
-
-/* Accessors */
-/* The value of the symbol */
-#define S_GET_VALUE(s) ((unsigned long) ((s)->sy_symbol.n_value))
-/* The name of the symbol */
-#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
-/* The pointer to the string table */
-#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx)
-/* The type of the symbol */
-#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE)
-/* The numeric value of the segment */
-#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)])
-/* The n_other expression value */
-#define S_GET_OTHER(s) ((s)->sy_symbol.n_other)
-/* The n_desc expression value */
-#define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
-
-/* Modifiers */
-/* Set the value of the symbol */
-#define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v))
-/* Assume that a symbol cannot be simultaneously in more than on segment */
-/* set segment */
-#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
-/* The symbol is external */
-#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT)
-/* The symbol is not external */
-#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT)
-/* Set the name of the symbol */
-#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
-/* Set the offset in the string table */
-#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
-/* Set the n_other expression value */
-#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
-/* Set the n_desc expression value */
-#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v))
-
-/* File header macro and type definition */
-
-#define H_GET_FILE_SIZE(h) (sizeof(struct exec) + \
- H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
- H_GET_SYMBOL_TABLE_SIZE(h) + \
- H_GET_TEXT_RELOCATION_SIZE(h) + \
- H_GET_DATA_RELOCATION_SIZE(h) + \
- (h)->string_table_size)
-
-#define H_GET_HEADER_SIZE(h) (sizeof(struct exec))
-#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
-#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
-#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
-#define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize)
-#define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize)
-#define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms)
-#define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info)
-#define H_GET_ENTRY_POINT(h) ((h)->header.a_entry)
-#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
-#define H_GET_LINENO_SIZE(h) (0)
-
-#ifdef EXEC_MACHINE_TYPE
-#define H_GET_MACHINE_TYPE(h) ((h)->header.a_machtype)
-#endif /* EXEC_MACHINE_TYPE */
-#ifdef EXEC_VERSION
-#define H_GET_VERSION(h) ((h)->header.a_version)
-#endif /* EXEC_VERSION */
-
-#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = (v))
-#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = (v))
-#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = (v))
-
-#define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\
- H_SET_DATA_RELOCATION_SIZE((h),(d)))
-
-#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
-#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
-#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \
- sizeof(struct nlist))
-
-#define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_magic = (v))
-
-#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v))
-#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
-#ifdef EXEC_MACHINE_TYPE
-#define H_SET_MACHINE_TYPE(h,v) ((h)->header.a_machtype = (v))
-#endif /* EXEC_MACHINE_TYPE */
-#ifdef EXEC_VERSION
-#define H_SET_VERSION(h,v) ((h)->header.a_version = (v))
-#endif /* EXEC_VERSION */
-
-/*
- * Current means for getting the name of a segment.
- * This will change for infinite-segments support (e.g. COFF).
- */
-#define segment_name(seg) ( seg_name[(int)(seg)] )
-extern char *const seg_name[];
-
-typedef struct {
- struct exec header; /* a.out header */
- long string_table_size; /* names + '\0' + sizeof(int) */
-} object_headers;
-
-/* unused hooks. */
-#define OBJ_EMIT_LINENO(a, b, c) {;}
-
-#if __STDC__
-struct fix;
-void tc_aout_fix_to_chars(char *where, struct fix *fixP, relax_addressT segment_address);
-#else /* not __STDC__ */
-void tc_aout_fix_to_chars();
-#endif /* not __STDC__ */
-
-enum reloc_type {
- NO_RELOC, RELOC_32,
-};
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-bout.h */
diff --git a/gnu/usr.bin/as/config/obj-coff.c b/gnu/usr.bin/as/config/obj-coff.c
deleted file mode 100644
index b57c6cd..0000000
--- a/gnu/usr.bin/as/config/obj-coff.c
+++ /dev/null
@@ -1,1978 +0,0 @@
-/* coff object file format
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "as.h"
-
-#include "obstack.h"
-
-lineno* lineno_rootP;
-
-const short seg_N_TYPE[] = { /* in: segT out: N_TYPE bits */
- C_ABS_SECTION,
- C_TEXT_SECTION,
- C_DATA_SECTION,
- C_BSS_SECTION,
- C_UNDEF_SECTION, /* SEG_UNKNOWN */
- C_UNDEF_SECTION, /* SEG_ABSENT */
- C_UNDEF_SECTION, /* SEG_PASS1 */
- C_UNDEF_SECTION, /* SEG_GOOF */
- C_UNDEF_SECTION, /* SEG_BIG */
- C_UNDEF_SECTION, /* SEG_DIFFERENCE */
- C_DEBUG_SECTION, /* SEG_DEBUG */
- C_NTV_SECTION, /* SEG_NTV */
- C_PTV_SECTION, /* SEG_PTV */
- C_REGISTER_SECTION, /* SEG_REGISTER */
-};
-
-
-/* Add 4 to the real value to get the index and compensate the negatives */
-
-const segT N_TYPE_seg[32] =
-{
- SEG_PTV, /* C_PTV_SECTION == -4 */
- SEG_NTV, /* C_NTV_SECTION == -3 */
- SEG_DEBUG, /* C_DEBUG_SECTION == -2 */
- SEG_ABSOLUTE, /* C_ABS_SECTION == -1 */
- SEG_UNKNOWN, /* C_UNDEF_SECTION == 0 */
- SEG_TEXT, /* C_TEXT_SECTION == 1 */
- SEG_DATA, /* C_DATA_SECTION == 2 */
- SEG_BSS, /* C_BSS_SECTION == 3 */
- SEG_REGISTER, /* C_REGISTER_SECTION == 4 */
- SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,
- SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,
- SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF
- };
-
-#if __STDC__ == 1
-
-char *s_get_name(symbolS *s);
-static symbolS *tag_find_or_make(char *name);
-static symbolS* tag_find(char *name);
-#ifdef BFD_HEADERS
-static void obj_coff_section_header_append(char **where, struct internal_scnhdr *header);
-#else
-static void obj_coff_section_header_append(char **where, SCNHDR *header);
-#endif
-static void obj_coff_def(int what);
-static void obj_coff_dim(void);
-static void obj_coff_endef(void);
-static void obj_coff_line(void);
-static void obj_coff_ln(void);
-static void obj_coff_scl(void);
-static void obj_coff_size(void);
-static void obj_coff_stab(int what);
-static void obj_coff_tag(void);
-static void obj_coff_type(void);
-static void obj_coff_val(void);
-static void tag_init(void);
-static void tag_insert(char *name, symbolS *symbolP);
-
-#else /* not __STDC__ */
-
-char *s_get_name();
-static symbolS *tag_find();
-static symbolS *tag_find_or_make();
-static void obj_coff_section_header_append();
-static void obj_coff_def();
-static void obj_coff_dim();
-static void obj_coff_endef();
-static void obj_coff_line();
-static void obj_coff_ln();
-static void obj_coff_scl();
-static void obj_coff_size();
-static void obj_coff_stab();
-static void obj_coff_tag();
-static void obj_coff_type();
-static void obj_coff_val();
-static void tag_init();
-static void tag_insert();
-
-#endif /* not __STDC__ */
-
-static struct hash_control *tag_hash;
-static symbolS *def_symbol_in_progress = NULL;
-
-const pseudo_typeS obj_pseudo_table[] = {
-#ifndef IGNORE_DEBUG
- { "def", obj_coff_def, 0 },
- { "dim", obj_coff_dim, 0 },
- { "endef", obj_coff_endef, 0 },
- { "line", obj_coff_line, 0 },
- { "ln", obj_coff_ln, 0 },
- { "scl", obj_coff_scl, 0 },
- { "size", obj_coff_size, 0 },
- { "tag", obj_coff_tag, 0 },
- { "type", obj_coff_type, 0 },
- { "val", obj_coff_val, 0 },
-#else
- { "def", s_ignore, 0 },
- { "dim", s_ignore, 0 },
- { "endef", s_ignore, 0 },
- { "line", s_ignore, 0 },
- { "ln", s_ignore, 0 },
- { "scl", s_ignore, 0 },
- { "size", s_ignore, 0 },
- { "tag", s_ignore, 0 },
- { "type", s_ignore, 0 },
- { "val", s_ignore, 0 },
-#endif /* ignore debug */
-
- { "ident", s_ignore, 0 }, /* we don't yet handle this. */
-
-
- /* stabs aka a.out aka b.out directives for debug symbols.
- Currently ignored silently. Except for .line at which
- we guess from context. */
- { "desc", s_ignore, 0 }, /* def */
- /* { "line", s_ignore, 0 }, */ /* source code line number */
- { "stabd", obj_coff_stab, 'd' }, /* stabs */
- { "stabn", obj_coff_stab, 'n' }, /* stabs */
- { "stabs", obj_coff_stab, 's' }, /* stabs */
-
- /* stabs-in-coff (?) debug pseudos (ignored) */
- { "optim", s_ignore, 0 }, /* For sun386i cc (?) */
- /* other stuff */
- { "ABORT", s_abort, 0 },
-
- { NULL} /* end sentinel */
-}; /* obj_pseudo_table */
-
-
-/* obj dependant output values */
-#ifdef BFD_HEADERS
-static struct internal_scnhdr bss_section_header;
-struct internal_scnhdr data_section_header;
-struct internal_scnhdr text_section_header;
-#else
-static SCNHDR bss_section_header;
-SCNHDR data_section_header;
-SCNHDR text_section_header;
-#endif
-/* Relocation. */
-
-static int reloc_compare(p1, p2)
-#ifdef BFD_HEADERS
-struct internal_reloc *p1, *p2;
-#else
-RELOC *p1, *p2;
-#endif
-{
- return (int)(p1->r_vaddr - p2->r_vaddr);
-}
-
-/*
- * emit_relocations()
- *
- * Crawl along a fixS chain. Emit the segment's relocations.
- */
-
-void obj_emit_relocations(where, fixP, segment_address_in_file)
-char **where;
-fixS *fixP; /* Fixup chain for this segment. */
-relax_addressT segment_address_in_file;
-{
-#ifdef BFD_HEADERS
- struct internal_reloc *ri_table;
-#else
- RELOC *ri_table;
-#endif
- symbolS *symbolP;
- int i, count;
- fixS *p;
-
- for (count = 0, p = fixP; p ; p = p->fx_next)
- if (p->fx_addsy) count++;
- if (!count)
- return;
-
-#ifdef BFD_HEADERS
- ri_table = (struct internal_reloc *) calloc(sizeof(*ri_table),count);
-#else
- ri_table = (RELOC *) calloc(sizeof(*ri_table),count);
-#endif
- if (!ri_table)
- as_fatal ("obj_emit_relocations: Could not malloc relocation table");
-
-#ifdef TC_I960
- callj_table = (char *)malloc (sizeof(char)*count);
- if (!callj_table)
- as_fatal ("obj_emit_relocations: Could not malloc callj table");
-#endif
-
- for (i = 0; fixP; fixP = fixP->fx_next) {
- if (symbolP = fixP->fx_addsy) {
-#if defined(TC_M68K)
- ri_table[i].r_type = (fixP->fx_pcrel ?
- (fixP->fx_size == 1 ? R_PCRBYTE :
- fixP->fx_size == 2 ? R_PCRWORD :
- R_PCRLONG):
- (fixP->fx_size == 1 ? R_RELBYTE :
- fixP->fx_size == 2 ? R_RELWORD :
- R_RELLONG));
-#elif defined(TC_I386)
- /* FIXME-SOON R_OFF8 & R_DIR16 are a vague guess, completly
- untested. */
- ri_table[i].r_type = (fixP->fx_pcrel ?
- (fixP->fx_size == 1 ? R_PCRBYTE :
- fixP->fx_size == 2 ? R_PCRWORD :
- R_PCRLONG):
- (fixP->fx_size == 1 ? R_OFF8 :
- fixP->fx_size == 2 ? R_DIR16 :
- R_DIR32));
-#elif defined(TC_I960)
- ri_table[i].r_type = (fixP->fx_pcrel
- ? R_IPRMED
- : R_RELLONG);
- callj_table[i] = fixP->fx_callj ? 1 : 0;
-#elif defined(TC_A29K)
- ri_table[i].r_type = tc_coff_fix2rtype(fixP);
-
-#else
-#error you lose
-#endif /* TC_M68K || TC_I386 */
- ri_table[i].r_vaddr = (fixP->fx_frag->fr_address
- + fixP->fx_where);
- /* If symbol associated to relocation entry is a bss symbol
- or undefined symbol just remember the index of the symbol.
- Otherwise store the index of the symbol describing the
- section the symbol belong to. This heuristic speeds up ld.
- */
- /* Local symbols can generate relocation information. In case
- of structure return for instance. But they have no symbol
- number because they won't be emitted in the final object.
- In the case where they are in the BSS section, this leads
- to an incorrect r_symndx.
- Under bsd the loader do not care if the symbol reference
- is incorrect. But the SYS V ld complains about this. To
- avoid this we associate the symbol to the associated
- section, *even* if it is the BSS section. */
- /* If someone can tell me why the other symbols of the bss
- section are not associated with the .bss section entry,
- I'd be gratefull. I guess that it has to do with the special
- nature of the .bss section. Or maybe this is because the
- bss symbols are declared in the common section and can
- be resized later. Can it break code some where ? */
- ri_table[i].r_symndx = (S_GET_SEGMENT(symbolP) == SEG_TEXT
- ? dot_text_symbol->sy_number
- : (S_GET_SEGMENT(symbolP) == SEG_DATA
- ? dot_data_symbol->sy_number
- : ((SF_GET_LOCAL(symbolP)
- ? dot_bss_symbol->sy_number
- : symbolP->sy_number)))); /* bss or undefined */
-
- /* md_ri_to_chars((char *) &ri, ri); */ /* Last step : write md f */
-
- i++;
- } /* if there's a symbol */
- } /* for each fixP */
-
- /*
- * AIX ld prefer to have the reloc table with r_vaddr sorted.
- * But sorting it should not hurt any other ld.
- */
- qsort (ri_table, count, sizeof(*ri_table), reloc_compare);
-
- for (i = 0; i < count; i++)
- {
-#ifdef BFD_HEADERS
- *where += bfd_coff_swap_reloc_out(stdoutput, &ri_table[i], *where);
-# ifdef TC_A29K
- /* The 29k has a special kludge for the high 16 bit reloc.
- Two relocations are emmited, R_IHIHALF, and R_IHCONST.
- The second one doesn't contain a symbol, but uses the
- value for offset */
- if (ri_table[i].r_type == R_IHIHALF)
- {
- /* now emit the second bit */
- ri_table[i].r_type = R_IHCONST;
- ri_table[i].r_symndx = fixP->fx_addnumber;
- *where += bfd_coff_swap_reloc_out(stdoutput, &ri_table[i],
- *where);
- }
-# endif /* TC_A29K */
-
-#else /* not BFD_HEADERS */
- append(where, (char *) &ri_table[i], RELSZ);
-#endif /* not BFD_HEADERS */
-
-#ifdef TC_I960
- if (callj_table[i])
- {
- ri_table[i].r_type = R_OPTCALL;
-# ifdef BFD_HEADERS
- *where += bfd_coff_swap_reloc_out(stdoutput, &ri_table[i],
- *where);
-# else
- append(where, (char *) &ri_table[i], (unsigned long)RELSZ);
-# endif /* BFD_HEADERS */
- } /* if it's a callj, do it again for the opcode */
-#endif /* TC_I960 */
- }
-
- free (ri_table);
-#ifdef TC_I960
- free (callj_table);
-#endif
-
- return;
-} /* obj_emit_relocations() */
-
-/* Coff file generation & utilities */
-
-#ifdef BFD_HEADERS
-void obj_header_append(where, headers)
-char **where;
-object_headers *headers;
-{
- tc_headers_hook(headers);
- *where += bfd_coff_swap_filehdr_out(stdoutput, &(headers->filehdr), *where);
-#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
- *where += bfd_coff_swap_aouthdr_out(stdoutput, &(headers->aouthdr), *where);
-#endif
- obj_coff_section_header_append(where, &text_section_header);
- obj_coff_section_header_append(where, &data_section_header);
- obj_coff_section_header_append(where, &bss_section_header);
-
-}
-
-#else
-
-void obj_header_append(where, headers)
-char **where;
-object_headers *headers;
-{
- tc_headers_hook(headers);
-
-#ifdef CROSS_COMPILE
- /* Eventually swap bytes for cross compilation for file header */
- md_number_to_chars(*where, headers->filehdr.f_magic, sizeof(headers->filehdr.f_magic));
- *where += sizeof(headers->filehdr.f_magic);
- md_number_to_chars(*where, headers->filehdr.f_nscns, sizeof(headers->filehdr.f_nscns));
- *where += sizeof(headers->filehdr.f_nscns);
- md_number_to_chars(*where, headers->filehdr.f_timdat, sizeof(headers->filehdr.f_timdat));
- *where += sizeof(headers->filehdr.f_timdat);
- md_number_to_chars(*where, headers->filehdr.f_symptr, sizeof(headers->filehdr.f_symptr));
- *where += sizeof(headers->filehdr.f_symptr);
- md_number_to_chars(*where, headers->filehdr.f_nsyms, sizeof(headers->filehdr.f_nsyms));
- *where += sizeof(headers->filehdr.f_nsyms);
- md_number_to_chars(*where, headers->filehdr.f_opthdr, sizeof(headers->filehdr.f_opthdr));
- *where += sizeof(headers->filehdr.f_opthdr);
- md_number_to_chars(*where, headers->filehdr.f_flags, sizeof(headers->filehdr.f_flags));
- *where += sizeof(headers->filehdr.f_flags);
-
-#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
- /* Eventually swap bytes for cross compilation for a.out header */
- md_number_to_chars(*where, headers->aouthdr.magic, sizeof(headers->aouthdr.magic));
- *where += sizeof(headers->aouthdr.magic);
- md_number_to_chars(*where, headers->aouthdr.vstamp, sizeof(headers->aouthdr.vstamp));
- *where += sizeof(headers->aouthdr.vstamp);
- md_number_to_chars(*where, headers->aouthdr.tsize, sizeof(headers->aouthdr.tsize));
- *where += sizeof(headers->aouthdr.tsize);
- md_number_to_chars(*where, headers->aouthdr.dsize, sizeof(headers->aouthdr.dsize));
- *where += sizeof(headers->aouthdr.dsize);
- md_number_to_chars(*where, headers->aouthdr.bsize, sizeof(headers->aouthdr.bsize));
- *where += sizeof(headers->aouthdr.bsize);
- md_number_to_chars(*where, headers->aouthdr.entry, sizeof(headers->aouthdr.entry));
- *where += sizeof(headers->aouthdr.entry);
- md_number_to_chars(*where, headers->aouthdr.text_start, sizeof(headers->aouthdr.text_start));
- *where += sizeof(headers->aouthdr.text_start);
- md_number_to_chars(*where, headers->aouthdr.data_start, sizeof(headers->aouthdr.data_start));
- *where += sizeof(headers->aouthdr.data_start);
- md_number_to_chars(*where, headers->aouthdr.tagentries, sizeof(headers->aouthdr.tagentries));
- *where += sizeof(headers->aouthdr.tagentries);
-#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
-
-#else /* CROSS_COMPILE */
-
- append(where, (char *) &headers->filehdr, sizeof(headers->filehdr));
-#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
- append(where, (char *) &headers->aouthdr, sizeof(headers->aouthdr));
-#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
-
-#endif /* CROSS_COMPILE */
-
- /* Output the section headers */
- obj_coff_section_header_append(where, &text_section_header);
- obj_coff_section_header_append(where, &data_section_header);
- obj_coff_section_header_append(where, &bss_section_header);
-
- return;
-} /* obj_header_append() */
-#endif
-void obj_symbol_to_chars(where, symbolP)
-char **where;
-symbolS *symbolP;
-{
-#ifdef BFD_HEADERS
- unsigned int numaux = symbolP->sy_symbol.ost_entry.n_numaux;
- unsigned int i;
-
- if (S_GET_SEGMENT(symbolP) == SEG_REGISTER) {
- S_SET_SEGMENT(symbolP, SEG_ABSOLUTE);
- }
- *where += bfd_coff_swap_sym_out(stdoutput, &symbolP->sy_symbol.ost_entry,
- *where);
-
- for (i = 0; i < numaux; i++)
- {
- *where += bfd_coff_swap_aux_out(stdoutput,
- &symbolP->sy_symbol.ost_auxent[i],
- S_GET_DATA_TYPE(symbolP),
- S_GET_STORAGE_CLASS(symbolP),
- *where);
- }
-
-#else /* BFD_HEADERS */
- SYMENT *syment = &symbolP->sy_symbol.ost_entry;
- int i;
- char numaux = syment->n_numaux;
- unsigned short type = S_GET_DATA_TYPE(symbolP);
-
-#ifdef CROSS_COMPILE
- md_number_to_chars(*where, syment->n_value, sizeof(syment->n_value));
- *where += sizeof(syment->n_value);
- md_number_to_chars(*where, syment->n_scnum, sizeof(syment->n_scnum));
- *where += sizeof(syment->n_scnum);
- md_number_to_chars(*where, 0, sizeof(short)); /* pad n_flags */
- *where += sizeof(short);
- md_number_to_chars(*where, syment->n_type, sizeof(syment->n_type));
- *where += sizeof(syment->n_type);
- md_number_to_chars(*where, syment->n_sclass, sizeof(syment->n_sclass));
- *where += sizeof(syment->n_sclass);
- md_number_to_chars(*where, syment->n_numaux, sizeof(syment->n_numaux));
- *where += sizeof(syment->n_numaux);
-#else /* CROSS_COMPILE */
- append(where, (char *) syment, sizeof(*syment));
-#endif /* CROSS_COMPILE */
-
- /* Should do the following : if (.file entry) MD(..)... else if (static entry) MD(..) */
- if (numaux > OBJ_COFF_MAX_AUXENTRIES) {
- as_bad("Internal error? too many auxents for symbol");
- } /* too many auxents */
-
- for (i = 0; i < numaux; ++i) {
-#ifdef CROSS_COMPILE
-#if 0 /* This code has never been tested */
- /* The most common case, x_sym entry. */
- if ((SF_GET(symbolP) & (SF_FILE | SF_STATICS)) == 0) {
- md_number_to_chars(*where, auxP->x_sym.x_tagndx, sizeof(auxP->x_sym.x_tagndx));
- *where += sizeof(auxP->x_sym.x_tagndx);
- if (ISFCN(type)) {
- md_number_to_chars(*where, auxP->x_sym.x_misc.x_fsize, sizeof(auxP->x_sym.x_misc.x_fsize));
- *where += sizeof(auxP->x_sym.x_misc.x_fsize);
- } else {
- md_number_to_chars(*where, auxP->x_sym.x_misc.x_lnno, sizeof(auxP->x_sym.x_misc.x_lnno));
- *where += sizeof(auxP->x_sym.x_misc.x_lnno);
- md_number_to_chars(*where, auxP->x_sym.x_misc.x_size, sizeof(auxP->x_sym.x_misc.x_size));
- *where += sizeof(auxP->x_sym.x_misc.x_size);
- }
- if (ISARY(type)) {
- register int index;
- for (index = 0; index < DIMNUM; index++)
- md_number_to_chars(*where, auxP->x_sym.x_fcnary.x_ary.x_dimen[index], sizeof(auxP->x_sym.x_fcnary.x_ary.x_dimen[index]));
- *where += sizeof(auxP->x_sym.x_fcnary.x_ary.x_dimen[index]);
- } else {
- md_number_to_chars(*where, auxP->x_sym.x_fcnary.x_fcn.x_lnnoptr, sizeof(auxP->x_sym.x_fcnary.x_fcn.x_lnnoptr));
- *where += sizeof(auxP->x_sym.x_fcnary.x_fcn.x_lnnoptr);
- md_number_to_chars(*where, auxP->x_sym.x_fcnary.x_fcn.x_endndx, sizeof(auxP->x_sym.x_fcnary.x_fcn.x_endndx));
- *where += sizeof(auxP->x_sym.x_fcnary.x_fcn.x_endndx);
- }
- md_number_to_chars(*where, auxP->x_sym.x_tvndx, sizeof(auxP->x_sym.x_tvndx));
- *where += sizeof(auxP->x_sym.x_tvndx);
- } else if (SF_GET_FILE(symbolP)) { /* .file */
- ;
- } else if (SF_GET_STATICS(symbolP)) { /* .text, .data, .bss symbols */
- md_number_to_chars(*where, auxP->x_scn.x_scnlen, sizeof(auxP->x_scn.x_scnlen));
- *where += sizeof(auxP->x_scn.x_scnlen);
- md_number_to_chars(*where, auxP->x_scn.x_nreloc, sizeof(auxP->x_scn.x_nreloc));
- *where += sizeof(auxP->x_scn.x_nreloc);
- md_number_to_chars(*where, auxP->x_scn.x_nlinno, sizeof(auxP->x_scn.x_nlinno));
- *where += sizeof(auxP->x_scn.x_nlinno);
- }
-#endif /* 0 */
-#else /* CROSS_COMPILE */
- append(where, (char *) &symbolP->sy_symbol.ost_auxent[i], sizeof(symbolP->sy_symbol.ost_auxent[i]));
-#endif /* CROSS_COMPILE */
-
- }; /* for each aux in use */
-#endif /* BFD_HEADERS */
- return;
-} /* obj_symbol_to_chars() */
-
-#ifdef BFD_HEADERS
-static void obj_coff_section_header_append(where, header)
-char **where;
-struct internal_scnhdr *header;
-{
- *where += bfd_coff_swap_scnhdr_out(stdoutput, header, *where);
-}
-#else
-static void obj_coff_section_header_append(where, header)
-char **where;
-SCNHDR *header;
-{
-#ifdef CROSS_COMPILE
- memcpy(*where, header->s_name, sizeof(header->s_name));
- *where += sizeof(header->s_name);
-
- md_number_to_chars(*where, header->s_paddr, sizeof(header->s_paddr));
- *where += sizeof(header->s_paddr);
-
- md_number_to_chars(*where, header->s_vaddr, sizeof(header->s_vaddr));
- *where += sizeof(header->s_vaddr);
-
- md_number_to_chars(*where, header->s_size, sizeof(header->s_size));
- *where += sizeof(header->s_size);
-
- md_number_to_chars(*where, header->s_scnptr, sizeof(header->s_scnptr));
- *where += sizeof(header->s_scnptr);
-
- md_number_to_chars(*where, header->s_relptr, sizeof(header->s_relptr));
- *where += sizeof(header->s_relptr);
-
- md_number_to_chars(*where, header->s_lnnoptr, sizeof(header->s_lnnoptr));
- *where += sizeof(header->s_lnnoptr);
-
- md_number_to_chars(*where, header->s_nreloc, sizeof(header->s_nreloc));
- *where += sizeof(header->s_nreloc);
-
- md_number_to_chars(*where, header->s_nlnno, sizeof(header->s_nlnno));
- *where += sizeof(header->s_nlnno);
-
- md_number_to_chars(*where, header->s_flags, sizeof(header->s_flags));
- *where += sizeof(header->s_flags);
-
-#ifdef TC_I960
- md_number_to_chars(*where, header->s_align, sizeof(header->s_align));
- *where += sizeof(header->s_align);
-#endif /* TC_I960 */
-
-#else /* CROSS_COMPILE */
-
- append(where, (char *) header, sizeof(*header));
-
-#endif /* CROSS_COMPILE */
-
- return;
-} /* obj_coff_section_header_append() */
-
-#endif
-void obj_emit_symbols(where, symbol_rootP)
-char **where;
-symbolS *symbol_rootP;
-{
- symbolS *symbolP;
- /*
- * Emit all symbols left in the symbol chain.
- */
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- /* Used to save the offset of the name. It is used to point
- to the string in memory but must be a file offset. */
- register char * temp;
-
- tc_coff_symbol_emit_hook(symbolP);
-
- temp = S_GET_NAME(symbolP);
- if (SF_GET_STRING(symbolP)) {
- S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
- S_SET_ZEROES(symbolP, 0);
- } else {
- memset(symbolP->sy_symbol.ost_entry.n_name, '\0', SYMNMLEN);
- strncpy(symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN);
- }
- obj_symbol_to_chars(where, symbolP);
- S_SET_NAME(symbolP,temp);
- }
-} /* obj_emit_symbols() */
-
-/* Merge a debug symbol containing debug information into a normal symbol. */
-
-void c_symbol_merge(debug, normal)
-symbolS *debug;
-symbolS *normal;
-{
- S_SET_DATA_TYPE(normal, S_GET_DATA_TYPE(debug));
- S_SET_STORAGE_CLASS(normal, S_GET_STORAGE_CLASS(debug));
-
- if (S_GET_NUMBER_AUXILIARY(debug) > S_GET_NUMBER_AUXILIARY(normal)) {
- S_SET_NUMBER_AUXILIARY(normal, S_GET_NUMBER_AUXILIARY(debug));
- } /* take the most we have */
-
- if (S_GET_NUMBER_AUXILIARY(debug) > 0) {
- memcpy((char*)&normal->sy_symbol.ost_auxent[0], (char*)&debug->sy_symbol.ost_auxent[0], S_GET_NUMBER_AUXILIARY(debug) * AUXESZ);
- } /* Move all the auxiliary information */
-
- /* Move the debug flags. */
- SF_SET_DEBUG_FIELD(normal, SF_GET_DEBUG_FIELD(debug));
-} /* c_symbol_merge() */
-
-static symbolS *previous_file_symbol = NULL;
-
-void c_dot_file_symbol(filename)
-char *filename;
-{
- symbolS* symbolP;
-
- symbolP = symbol_new(".file",
- SEG_DEBUG,
- 0,
- &zero_address_frag);
-
- S_SET_STORAGE_CLASS(symbolP, C_FILE);
- S_SET_NUMBER_AUXILIARY(symbolP, 1);
- SA_SET_FILE_FNAME(symbolP, filename);
- SF_SET_DEBUG(symbolP);
- S_SET_VALUE(symbolP, (long) previous_file_symbol);
-
- previous_file_symbol = symbolP;
-
- /* Make sure that the symbol is first on the symbol chain */
- if (symbol_rootP != symbolP) {
- if (symbolP == symbol_lastP) {
- symbol_lastP = symbol_lastP->sy_previous;
- } /* if it was the last thing on the list */
-
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
- symbol_insert(symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP);
- symbol_rootP = symbolP;
- } /* if not first on the list */
-
-} /* c_dot_file_symbol() */
-/*
- * Build a 'section static' symbol.
- */
-
-char *c_section_symbol(name, value, length, nreloc, nlnno)
-char *name;
-long value;
-long length;
-unsigned short nreloc;
-unsigned short nlnno;
-{
- symbolS *symbolP;
-
- symbolP = symbol_new(name,
- (name[1] == 't'
- ? SEG_TEXT
- : (name[1] == 'd'
- ? SEG_DATA
- : SEG_BSS)),
- value,
- &zero_address_frag);
-
- S_SET_STORAGE_CLASS(symbolP, C_STAT);
- S_SET_NUMBER_AUXILIARY(symbolP, 1);
-
- SA_SET_SCN_SCNLEN(symbolP, length);
- SA_SET_SCN_NRELOC(symbolP, nreloc);
- SA_SET_SCN_NLINNO(symbolP, nlnno);
-
- SF_SET_STATICS(symbolP);
-
- return (char*)symbolP;
-} /* c_section_symbol() */
-
-void c_section_header(header,
- name,
- core_address,
- size,
- data_ptr,
- reloc_ptr,
- lineno_ptr,
- reloc_number,
- lineno_number,
- alignment)
-#ifdef BFD_HEADERS
-struct internal_scnhdr *header;
-#else
-SCNHDR *header;
-#endif
-char *name;
-long core_address;
-long size;
-long data_ptr;
-long reloc_ptr;
-long lineno_ptr;
-long reloc_number;
-long lineno_number;
-long alignment;
-{
- strncpy(header->s_name, name, 8);
- header->s_paddr = header->s_vaddr = core_address;
- header->s_scnptr = ((header->s_size = size) != 0) ? data_ptr : 0;
- header->s_relptr = reloc_ptr;
- header->s_lnnoptr = lineno_ptr;
- header->s_nreloc = reloc_number;
- header->s_nlnno = lineno_number;
-
-#ifdef OBJ_COFF_SECTION_HEADER_HAS_ALIGNMENT
-#ifdef OBJ_COFF_BROKEN_ALIGNMENT
- header->s_align = ((name[1] == 'b' || (size > 0)) ? 16 : 0);
-#else
- header->s_align = ((alignment == 0)
- ? 0
- : (1 << alignment));
-#endif /* OBJ_COFF_BROKEN_ALIGNMENT */
-#endif /* OBJ_COFF_SECTION_HEADER_HAS_ALIGNMENT */
-
- header->s_flags = STYP_REG | (name[1] == 't'
- ? STYP_TEXT
- : (name[1] == 'd'
- ? STYP_DATA
- : (name[1] == 'b'
- ? STYP_BSS
- : STYP_INFO)));
- return;
-} /* c_section_header() */
-
-/* Line number handling */
-
-int function_lineoff = -1; /* Offset in line#s where the last function
- started (the odd entry for line #0) */
-int text_lineno_number = 0;
-int our_lineno_number = 0; /* we use this to build pointers from .bf's
- into the linetable. It should match
- exactly the values that are later
- assigned in text_lineno_number by
- write.c. */
-lineno* lineno_lastP = (lineno*)0;
-
-int
- c_line_new(paddr, line_number, frag)
-long paddr;
-unsigned short line_number;
-fragS* frag;
-{
- lineno* new_line = (lineno*)xmalloc(sizeof(lineno));
-
- new_line->line.l_addr.l_paddr = paddr;
- new_line->line.l_lnno = line_number;
- new_line->frag = (char*)frag;
- new_line->next = (lineno*)0;
-
- if (lineno_rootP == (lineno*)0)
- lineno_rootP = new_line;
- else
- lineno_lastP->next = new_line;
- lineno_lastP = new_line;
- return LINESZ * our_lineno_number++;
-}
-
-void obj_emit_lineno(where, line, file_start)
-char **where;
-lineno *line;
-char *file_start;
-{
-#ifdef BFD_HEADERS
- struct bfd_internal_lineno *line_entry;
-#else
- LINENO *line_entry;
-#endif
- for (; line; line = line->next) {
- line_entry = &line->line;
-
- /* FIXME-SOMEDAY Resolving the sy_number of function linno's used to be done in
- write_object_file() but their symbols need a fileptr to the lnno, so
- I moved this resolution check here. xoxorich. */
-
- if (line_entry->l_lnno == 0) {
- /* There is a good chance that the symbol pointed to
- is not the one that will be emitted and that the
- sy_number is not accurate. */
- /* char *name; */
- symbolS *symbolP;
-
- symbolP = (symbolS *) line_entry->l_addr.l_symndx;
-
- line_entry->l_addr.l_symndx = symbolP->sy_number;
- symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr = *where - file_start;
-
- } /* if this is a function linno */
-#ifdef BFD_HEADERS
- *where += bfd_coff_swap_lineno_out(stdoutput, line_entry, *where);
-#else
- /* No matter which member of the union we process, they are
- both long. */
-#ifdef CROSS_COMPILE
- md_number_to_chars(*where, line_entry->l_addr.l_paddr, sizeof(line_entry->l_addr.l_paddr));
- *where += sizeof(line_entry->l_addr.l_paddr);
-
- md_number_to_chars(*where, line_entry->l_lnno, sizeof(line_entry->l_lnno));
- *where += sizeof(line_entry->l_lnno);
-
-#ifdef TC_I960
- **where = '0';
- ++*where;
- **where = '0';
- ++*where;
-#endif /* TC_I960 */
-
-#else /* CROSS_COMPILE */
- append(where, (char *) line_entry, LINESZ);
-#endif /* CROSS_COMPILE */
-#endif /* BFD_HEADERS */
- } /* for each line number */
-
- return ;
-} /* obj_emit_lineno() */
-
-void obj_symbol_new_hook(symbolP)
-symbolS *symbolP;
-{
- char underscore = 0; /* Symbol has leading _ */
-
- /* Effective symbol */
- /* Store the pointer in the offset. */
- S_SET_ZEROES(symbolP, 0L);
- S_SET_DATA_TYPE(symbolP, T_NULL);
- S_SET_STORAGE_CLASS(symbolP, 0);
- S_SET_NUMBER_AUXILIARY(symbolP, 0);
- /* Additional information */
- symbolP->sy_symbol.ost_flags = 0;
- /* Auxiliary entries */
- memset((char*) &symbolP->sy_symbol.ost_auxent[0], '\0', AUXESZ);
-
-#ifdef STRIP_UNDERSCORE
- /* Remove leading underscore at the beginning of the symbol.
- * This is to be compatible with the standard librairies.
- */
- if (*S_GET_NAME(symbolP) == '_') {
- underscore = 1;
- S_SET_NAME(symbolP, S_GET_NAME(symbolP) + 1);
- } /* strip underscore */
-#endif /* STRIP_UNDERSCORE */
-
- if (S_IS_STRING(symbolP))
- SF_SET_STRING(symbolP);
- if (!underscore && S_IS_LOCAL(symbolP))
- SF_SET_LOCAL(symbolP);
-
- return;
-} /* obj_symbol_new_hook() */
-
-/* stack stuff */
-stack* stack_init(chunk_size, element_size)
-unsigned long chunk_size;
-unsigned long element_size;
-{
- stack* st;
-
- if ((st = (stack*)malloc(sizeof(stack))) == (stack*)0)
- return (stack*)0;
- if ((st->data = malloc(chunk_size)) == (char*)0) {
- free(st);
- return (stack*)0;
- }
- st->pointer = 0;
- st->size = chunk_size;
- st->chunk_size = chunk_size;
- st->element_size = element_size;
- return st;
-} /* stack_init() */
-
-void stack_delete(st)
-stack* st;
-{
- free(st->data);
- free(st);
-}
-
-char *stack_push(st, element)
-stack *st;
-char *element;
-{
- if (st->pointer + st->element_size >= st->size) {
- st->size += st->chunk_size;
- if ((st->data = xrealloc(st->data, st->size)) == (char*)0)
- return (char*)0;
- }
- memcpy(st->data + st->pointer, element, st->element_size);
- st->pointer += st->element_size;
- return st->data + st->pointer;
-} /* stack_push() */
-
-char* stack_pop(st)
-stack* st;
-{
- if ((st->pointer -= st->element_size) < 0) {
- st->pointer = 0;
- return (char*)0;
- }
- return st->data + st->pointer;
-}
-
-char* stack_top(st)
-stack* st;
-{
- return st->data + st->pointer - st->element_size;
-}
-
-
-/*
- * Handle .ln directives.
- */
-
-static void obj_coff_ln() {
- if (def_symbol_in_progress != NULL) {
- as_warn(".ln pseudo-op inside .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
- } /* wrong context */
-
- c_line_new(obstack_next_free(&frags) - frag_now->fr_literal,
- get_absolute_expression(),
- frag_now);
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_line() */
-
-/*
- * def()
- *
- * Handle .def directives.
- *
- * One might ask : why can't we symbol_new if the symbol does not
- * already exist and fill it with debug information. Because of
- * the C_EFCN special symbol. It would clobber the value of the
- * function symbol before we have a chance to notice that it is
- * a C_EFCN. And a second reason is that the code is more clear this
- * way. (at least I think it is :-).
- *
- */
-
-#define SKIP_SEMI_COLON() while (*input_line_pointer++ != ';')
-#define SKIP_WHITESPACES() while (*input_line_pointer == ' ' || \
- *input_line_pointer == '\t') \
- input_line_pointer++;
-
-static void obj_coff_def(what)
-int what;
-{
- char name_end; /* Char after the end of name */
- char *symbol_name; /* Name of the debug symbol */
- char *symbol_name_copy; /* Temporary copy of the name */
- unsigned int symbol_name_length;
- /*$char* directiveP;$ */ /* Name of the pseudo opcode */
- /*$char directive[MAX_DIRECTIVE];$ */ /* Backup of the directive */
- /*$char end = 0;$ */ /* If 1, stop parsing */
-
- if (def_symbol_in_progress != NULL) {
- as_warn(".def pseudo-op used inside of .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- SKIP_WHITESPACES();
-
- def_symbol_in_progress = (symbolS *) obstack_alloc(&notes, sizeof(*def_symbol_in_progress));
- memset(def_symbol_in_progress, '\0', sizeof(*def_symbol_in_progress));
-
- symbol_name = input_line_pointer;
- name_end = get_symbol_end();
- symbol_name_length = strlen(symbol_name);
- symbol_name_copy = xmalloc(symbol_name_length + 1);
- strcpy(symbol_name_copy, symbol_name);
-
- /* Initialize the new symbol */
-#ifdef STRIP_UNDERSCORE
- S_SET_NAME(def_symbol_in_progress, (*symbol_name_copy == '_'
- ? symbol_name_copy + 1
- : symbol_name_copy));
-#else /* STRIP_UNDERSCORE */
- S_SET_NAME(def_symbol_in_progress, symbol_name_copy);
-#endif /* STRIP_UNDERSCORE */
- /* free(symbol_name_copy); */
- def_symbol_in_progress->sy_name_offset = ~0;
- def_symbol_in_progress->sy_number = ~0;
- def_symbol_in_progress->sy_frag = &zero_address_frag;
-
- if (S_IS_STRING(def_symbol_in_progress)) {
- SF_SET_STRING(def_symbol_in_progress);
- } /* "long" name */
-
- *input_line_pointer = name_end;
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_def() */
-
-unsigned int dim_index;
-static void obj_coff_endef() {
- symbolS *symbolP;
- /* DIM BUG FIX sac@cygnus.com */
- dim_index =0;
- if (def_symbol_in_progress == NULL) {
- as_warn(".endef pseudo-op used outside of .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- /* Set the section number according to storage class. */
- switch (S_GET_STORAGE_CLASS(def_symbol_in_progress)) {
- case C_STRTAG:
- case C_ENTAG:
- case C_UNTAG:
- SF_SET_TAG(def_symbol_in_progress);
- /* intentional fallthrough */
- case C_FILE:
- case C_TPDEF:
- SF_SET_DEBUG(def_symbol_in_progress);
- S_SET_SEGMENT(def_symbol_in_progress, SEG_DEBUG);
- break;
-
- case C_EFCN:
- SF_SET_LOCAL(def_symbol_in_progress); /* Do not emit this symbol. */
- /* intentional fallthrough */
- case C_BLOCK:
- SF_SET_PROCESS(def_symbol_in_progress); /* Will need processing before writing */
- /* intentional fallthrough */
- case C_FCN:
- S_SET_SEGMENT(def_symbol_in_progress, SEG_TEXT);
-
- if (def_symbol_in_progress->sy_symbol.ost_entry.n_name[1] == 'b') { /* .bf */
- if (function_lineoff < 0) {
- fprintf(stderr, "`.bf' symbol without preceding function\n");
- } /* missing function symbol */
- SA_GET_SYM_LNNOPTR(def_symbol_in_progress) = function_lineoff;
- SF_SET_PROCESS(def_symbol_in_progress); /* Will need relocating */
- function_lineoff = -1;
- }
- break;
-
-#ifdef C_AUTOARG
- case C_AUTOARG:
-#endif /* C_AUTOARG */
- case C_AUTO:
- case C_REG:
- case C_MOS:
- case C_MOE:
- case C_MOU:
- case C_ARG:
- case C_REGPARM:
- case C_FIELD:
- case C_EOS:
- SF_SET_DEBUG(def_symbol_in_progress);
- S_SET_SEGMENT(def_symbol_in_progress, SEG_ABSOLUTE);
- break;
-
- case C_EXT:
- case C_STAT:
- case C_LABEL:
- /* Valid but set somewhere else (s_comm, s_lcomm, colon) */
- break;
-
- case C_USTATIC:
- case C_EXTDEF:
- case C_ULABEL:
- as_warn("unexpected storage class %d", S_GET_STORAGE_CLASS(def_symbol_in_progress));
- break;
- } /* switch on storage class */
-
- /* Now that we have built a debug symbol, try to
- find if we should merge with an existing symbol
- or not. If a symbol is C_EFCN or SEG_ABSOLUTE or
- untagged SEG_DEBUG it never merges. */
-
- /* Two cases for functions. Either debug followed
- by definition or definition followed by debug.
- For definition first, we will merge the debug
- symbol into the definition. For debug first, the
- lineno entry MUST point to the definition
- function or else it will point off into space
- when obj_crawl_symbol_chain() merges the debug
- symbol into the real symbol. Therefor, let's
- presume the debug symbol is a real function
- reference. */
-
- /* FIXME-SOON If for some reason the definition
- label/symbol is never seen, this will probably
- leave an undefined symbol at link time. */
-
- if (S_GET_STORAGE_CLASS(def_symbol_in_progress) == C_EFCN
- || (S_GET_SEGMENT(def_symbol_in_progress) == SEG_DEBUG
- && !SF_GET_TAG(def_symbol_in_progress))
- || S_GET_SEGMENT(def_symbol_in_progress) == SEG_ABSOLUTE
- || (symbolP = symbol_find_base(S_GET_NAME(def_symbol_in_progress), DO_NOT_STRIP)) == NULL) {
-
- symbol_append(def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP);
-
- } else {
- /* This symbol already exists, merge the
- newly created symbol into the old one.
- This is not mandatory. The linker can
- handle duplicate symbols correctly. But I
- guess that it save a *lot* of space if
- the assembly file defines a lot of
- symbols. [loic] */
-
- /* The debug entry (def_symbol_in_progress)
- is merged into the previous definition. */
-
- c_symbol_merge(def_symbol_in_progress, symbolP);
- /* FIXME-SOON Should *def_symbol_in_progress be free'd? xoxorich. */
- def_symbol_in_progress = symbolP;
-
- if (SF_GET_FUNCTION(def_symbol_in_progress)
- || SF_GET_TAG(def_symbol_in_progress)) {
- /* For functions, and tags, the symbol *must* be where the debug symbol
- appears. Move the existing symbol to the current place. */
- /* If it already is at the end of the symbol list, do nothing */
- if (def_symbol_in_progress != symbol_lastP) {
- symbol_remove(def_symbol_in_progress, &symbol_rootP, &symbol_lastP);
- symbol_append(def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP);
- } /* if not already in place */
- } /* if function */
- } /* normal or mergable */
-
- if (SF_GET_TAG(def_symbol_in_progress)
- && symbol_find_base(S_GET_NAME(def_symbol_in_progress), DO_NOT_STRIP) == NULL) {
- tag_insert(S_GET_NAME(def_symbol_in_progress), def_symbol_in_progress);
- } /* If symbol is a {structure,union} tag, associate symbol to its name. */
-
- if (SF_GET_FUNCTION(def_symbol_in_progress)) {
- know(sizeof(def_symbol_in_progress) <= sizeof(long));
- function_lineoff = c_line_new((long) def_symbol_in_progress, 0, &zero_address_frag);
- SF_SET_PROCESS(def_symbol_in_progress);
-
- if (symbolP == NULL) {
- /* That is, if this is the first
- time we've seen the function... */
- symbol_table_insert(def_symbol_in_progress);
- } /* definition follows debug */
- } /* Create the line number entry pointing to the function being defined */
-
- def_symbol_in_progress = NULL;
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_endef() */
-
-static void obj_coff_dim()
-{
- register int dim_index;
-
- if (def_symbol_in_progress == NULL) {
- as_warn(".dim pseudo-op used outside of .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
-
- for (dim_index = 0; dim_index < DIMNUM; dim_index++) {
- SKIP_WHITESPACES();
- SA_SET_SYM_DIMEN(def_symbol_in_progress, dim_index, get_absolute_expression());
-
- switch (*input_line_pointer) {
-
- case ',':
- input_line_pointer++;
- break;
-
- default:
- as_warn("badly formed .dim directive ignored");
- /* intentional fallthrough */
- case '\n':
- case ';':
- dim_index = DIMNUM;
- break;
- } /* switch on following character */
- } /* for each dimension */
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_dim() */
-
-static void obj_coff_line() {
- if (def_symbol_in_progress == NULL) {
- obj_coff_ln();
- return;
- } /* if it looks like a stabs style line */
-
- S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
- SA_SET_SYM_LNNO(def_symbol_in_progress, get_absolute_expression());
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_line() */
-
-static void obj_coff_size() {
- if (def_symbol_in_progress == NULL) {
- as_warn(".size pseudo-op used outside of .def/.endef ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
- SA_SET_SYM_SIZE(def_symbol_in_progress, get_absolute_expression());
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_size() */
-
-static void obj_coff_scl() {
- if (def_symbol_in_progress == NULL) {
- as_warn(".scl pseudo-op used outside of .def/.endef ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_STORAGE_CLASS(def_symbol_in_progress, get_absolute_expression());
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_scl() */
-
-static void obj_coff_tag() {
- char *symbol_name;
- char name_end;
-
- if (def_symbol_in_progress == NULL) {
- as_warn(".tag pseudo-op used outside of .def/.endef ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
- symbol_name = input_line_pointer;
- name_end = get_symbol_end();
-
- /* Assume that the symbol referred to by .tag is always defined. */
- /* This was a bad assumption. I've added find_or_make. xoxorich. */
- SA_SET_SYM_TAGNDX(def_symbol_in_progress, (long) tag_find_or_make(symbol_name));
- if (SA_GET_SYM_TAGNDX(def_symbol_in_progress) == 0L) {
- as_warn("tag not found for .tag %s", symbol_name);
- } /* not defined */
-
- SF_SET_TAGGED(def_symbol_in_progress);
- *input_line_pointer = name_end;
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_tag() */
-
-static void obj_coff_type() {
- if (def_symbol_in_progress == NULL) {
- as_warn(".type pseudo-op used outside of .def/.endef ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_DATA_TYPE(def_symbol_in_progress, get_absolute_expression());
-
- if (ISFCN(S_GET_DATA_TYPE(def_symbol_in_progress)) &&
- S_GET_STORAGE_CLASS(def_symbol_in_progress) != C_TPDEF) {
- SF_SET_FUNCTION(def_symbol_in_progress);
- } /* is a function */
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_type() */
-
-static void obj_coff_val() {
- if (def_symbol_in_progress == NULL) {
- as_warn(".val pseudo-op used outside of .def/.endef ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- if (is_name_beginner(*input_line_pointer)) {
- char *symbol_name = input_line_pointer;
- char name_end = get_symbol_end();
-
- if (!strcmp(symbol_name, ".")) {
- def_symbol_in_progress->sy_frag = frag_now;
- S_SET_VALUE(def_symbol_in_progress, obstack_next_free(&frags) - frag_now->fr_literal);
- /* If the .val is != from the .def (e.g. statics) */
- } else if (strcmp(S_GET_NAME(def_symbol_in_progress), symbol_name)) {
- def_symbol_in_progress->sy_forward = symbol_find_or_make(symbol_name);
-
- /* If the segment is undefined when the forward
- reference is solved, then copy the segment id
- from the forward symbol. */
- SF_SET_GET_SEGMENT(def_symbol_in_progress);
- }
- /* Otherwise, it is the name of a non debug symbol and its value will be calculated later. */
- *input_line_pointer = name_end;
- } else {
- S_SET_VALUE(def_symbol_in_progress, get_absolute_expression());
- } /* if symbol based */
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_val() */
-
-/*
- * Maintain a list of the tagnames of the structres.
- */
-
-static void tag_init() {
- tag_hash = hash_new();
- return ;
-} /* tag_init() */
-
-static void tag_insert(name, symbolP)
-char *name;
-symbolS *symbolP;
-{
- register char * error_string;
-
- if (*(error_string = hash_jam(tag_hash, name, (char *)symbolP))) {
- as_fatal("Inserting \"%s\" into structure table failed: %s",
- name, error_string);
- }
- return ;
-} /* tag_insert() */
-
-static symbolS *tag_find_or_make(name)
-char *name;
-{
- symbolS *symbolP;
-
- if ((symbolP = tag_find(name)) == NULL) {
- symbolP = symbol_new(name,
- SEG_UNKNOWN,
- 0,
- &zero_address_frag);
-
- tag_insert(S_GET_NAME(symbolP), symbolP);
- symbol_table_insert(symbolP);
- } /* not found */
-
- return(symbolP);
-} /* tag_find_or_make() */
-
-static symbolS *tag_find(name)
-char *name;
-{
-#ifdef STRIP_UNDERSCORE
- if (*name == '_') name++;
-#endif /* STRIP_UNDERSCORE */
- return((symbolS*)hash_find(tag_hash, name));
-} /* tag_find() */
-
-void obj_read_begin_hook() {
- /* These had better be the same. Usually 18 bytes. */
-#ifndef BFD_HEADERS
- know(sizeof(SYMENT) == sizeof(AUXENT));
- know(SYMESZ == AUXESZ);
-#endif
- tag_init();
-
- return;
-} /* obj_read_begin_hook() */
-
-void obj_crawl_symbol_chain(headers)
-object_headers *headers;
-{
- int symbol_number = 0;
- lineno *lineP;
- symbolS *last_functionP = NULL;
- symbolS *last_tagP;
- symbolS *symbolP;
- symbolS *symbol_externP = NULL;
- symbolS *symbol_extern_lastP = NULL;
-
- /* Initialize the stack used to keep track of the matching .bb .be */
- stack* block_stack = stack_init(512, sizeof(symbolS*));
-
- /* JF deal with forward references first... */
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
-
- if (symbolP->sy_forward) {
- S_SET_VALUE(symbolP, (S_GET_VALUE(symbolP)
- + S_GET_VALUE(symbolP->sy_forward)
- + symbolP->sy_forward->sy_frag->fr_address));
-
- if (
-#ifndef TE_I386AIX
- SF_GET_GET_SEGMENT(symbolP)
-#else
- SF_GET_GET_SEGMENT(symbolP)
- && S_GET_SEGMENT(symbolP) == SEG_UNKNOWN
-#endif /* TE_I386AIX */
- ) {
- S_SET_SEGMENT(symbolP, S_GET_SEGMENT(symbolP->sy_forward));
- } /* forward segment also */
-
- symbolP->sy_forward=0;
- } /* if it has a forward reference */
- } /* walk the symbol chain */
-
- tc_crawl_symbol_chain(headers);
-
- /* The symbol list should be ordered according to the following sequence
- * order :
- * . .file symbol
- * . debug entries for functions
- * . fake symbols for .text .data and .bss
- * . defined symbols
- * . undefined symbols
- * But this is not mandatory. The only important point is to put the
- * undefined symbols at the end of the list.
- */
-
- if (symbol_rootP == NULL
- || S_GET_STORAGE_CLASS(symbol_rootP) != C_FILE) {
- know(!previous_file_symbol);
- c_dot_file_symbol("fake");
- } /* Is there a .file symbol ? If not insert one at the beginning. */
-
- /*
- * Build up static symbols for .text, .data and .bss
- */
- dot_text_symbol = (symbolS*)
- c_section_symbol(".text",
- 0,
- H_GET_TEXT_SIZE(headers),
- 0/*text_relocation_number */,
- 0/*text_lineno_number */);
-#ifdef TE_I386AIX
- symbol_remove(dot_text_symbol, &symbol_rootP, &symbol_lastP);
- symbol_append(dot_text_symbol, previous_file_symbol,
- &symbol_rootP, &symbol_lastP);
-#endif /* TE_I386AIX */
-
- dot_data_symbol = (symbolS*)
- c_section_symbol(".data",
- H_GET_TEXT_SIZE(headers),
- H_GET_DATA_SIZE(headers),
- 0/*data_relocation_number */,
- 0); /* There are no data lineno entries */
-#ifdef TE_I386AIX
- symbol_remove(dot_data_symbol, &symbol_rootP, &symbol_lastP);
- symbol_append(dot_data_symbol, dot_text_symbol,
- &symbol_rootP, &symbol_lastP);
-#endif /* TE_I386AIX */
-
- dot_bss_symbol = (symbolS*)
- c_section_symbol(".bss",
- H_GET_TEXT_SIZE(headers) + H_GET_DATA_SIZE(headers),
- H_GET_BSS_SIZE(headers),
- 0, /* No relocation for a bss section. */
- 0); /* There are no bss lineno entries */
-#ifdef TE_I386AIX
- symbol_remove(dot_bss_symbol, &symbol_rootP, &symbol_lastP);
- symbol_append(dot_bss_symbol, dot_data_symbol,
- &symbol_rootP, &symbol_lastP);
-#endif /* TE_I386AIX */
-
-#if defined(DEBUG)
- verify_symbol_chain(symbol_rootP, symbol_lastP);
-#endif /* DEBUG */
-
- /* Three traversals of symbol chains here. The
- first traversal yanks externals into a temporary
- chain, removing the externals from the global
- chain, numbers symbols, and does some other guck.
- The second traversal is on the temporary chain of
- externals and just appends them to the global
- chain again, numbering them as we go. The third
- traversal patches pointers to symbols (using sym
- indexes). The last traversal was once done as
- part of the first pass, but that fails when a
- reference preceeds a definition as the definition
- has no number at the time we process the
- reference. */
-
- /* Note that symbolP will be NULL at the end of a loop
- if an external was at the beginning of the list (it
- gets moved off the list). Hence the weird check in
- the loop control.
- */
- for (symbolP = symbol_rootP;
- symbolP;
- symbolP = symbolP ? symbol_next(symbolP) : symbol_rootP) {
- if (!SF_GET_DEBUG(symbolP)) {
- /* Debug symbols do not need all this rubbish */
- symbolS* real_symbolP;
-
- /* L* and C_EFCN symbols never merge. */
- if (!SF_GET_LOCAL(symbolP)
- && (real_symbolP = symbol_find_base(S_GET_NAME(symbolP), DO_NOT_STRIP))
- && real_symbolP != symbolP) {
- /* FIXME-SOON: where do dups come from? Maybe tag references before definitions? xoxorich. */
- /* Move the debug data from the debug symbol to the
- real symbol. Do NOT do the oposite (i.e. move from
- real symbol to debug symbol and remove real symbol from the
- list.) Because some pointers refer to the real symbol
- whereas no pointers refer to the debug symbol. */
- c_symbol_merge(symbolP, real_symbolP);
- /* Replace the current symbol by the real one */
- /* The symbols will never be the last or the first
- because : 1st symbol is .file and 3 last symbols are
- .text, .data, .bss */
- symbol_remove(real_symbolP, &symbol_rootP, &symbol_lastP);
- symbol_insert(real_symbolP, symbolP, &symbol_rootP, &symbol_lastP);
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
- symbolP = real_symbolP;
- } /* if not local but dup'd */
-
- if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_DATA)) {
- S_SET_SEGMENT(symbolP, SEG_TEXT);
- } /* push data into text */
-
- S_SET_VALUE(symbolP, S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address);
-
- if (!S_IS_DEFINED(symbolP) && !SF_GET_LOCAL(symbolP)) {
- S_SET_EXTERNAL(symbolP);
- } else if (S_GET_STORAGE_CLASS(symbolP) == C_NULL) {
- if (S_GET_SEGMENT(symbolP) == SEG_TEXT){
- S_SET_STORAGE_CLASS(symbolP, C_LABEL);
- } else {
- S_SET_STORAGE_CLASS(symbolP, C_STAT);
- }
- } /* no storage class yet */
-
- /* Mainly to speed up if not -g */
- if (SF_GET_PROCESS(symbolP)) {
- /* Handle the nested blocks auxiliary info. */
- if (S_GET_STORAGE_CLASS(symbolP) == C_BLOCK) {
- if (!strcmp(S_GET_NAME(symbolP), ".bb"))
- stack_push(block_stack, (char *) &symbolP);
- else { /* .eb */
- register symbolS* begin_symbolP;
- begin_symbolP = *(symbolS**)stack_pop(block_stack);
- if (begin_symbolP == (symbolS*)0)
- as_warn("mismatched .eb");
- else
- SA_SET_SYM_ENDNDX(begin_symbolP, symbol_number+2);
- }
- }
- /* If we are able to identify the type of a function, and we
- are out of a function (last_functionP == 0) then, the
- function symbol will be associated with an auxiliary
- entry. */
- if (last_functionP == (symbolS*)0 &&
- SF_GET_FUNCTION(symbolP)) {
- last_functionP = symbolP;
-
- if (S_GET_NUMBER_AUXILIARY(symbolP) < 1) {
- S_SET_NUMBER_AUXILIARY(symbolP, 1);
- } /* make it at least 1 */
-
- /* Clobber possible stale .dim information. */
- memset(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen,
- '\0', sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen));
- }
- /* The C_FCN doesn't need any additional information.
- I don't even know if this is needed for sdb. But the
- standard assembler generates it, so...
- */
- if (S_GET_STORAGE_CLASS(symbolP) == C_EFCN) {
- if (last_functionP == (symbolS*)0)
- as_fatal("C_EFCN symbol out of scope");
- SA_SET_SYM_FSIZE(last_functionP,
- (long)(S_GET_VALUE(symbolP) -
- S_GET_VALUE(last_functionP)));
- SA_SET_SYM_ENDNDX(last_functionP, symbol_number);
- last_functionP = (symbolS*)0;
- }
- }
- } else if (SF_GET_TAG(symbolP)) {
- /* First descriptor of a structure must point to
- the first slot after the structure description. */
- last_tagP = symbolP;
-
- } else if (S_GET_STORAGE_CLASS(symbolP) == C_EOS) {
- /* +2 take in account the current symbol */
- SA_SET_SYM_ENDNDX(last_tagP, symbol_number + 2);
- } else if (S_GET_STORAGE_CLASS(symbolP) == C_FILE) {
- if (S_GET_VALUE(symbolP)) {
- S_SET_VALUE((symbolS *) S_GET_VALUE(symbolP), symbol_number);
- S_SET_VALUE(symbolP, 0);
- } /* no one points at the first .file symbol */
- } /* if debug or tag or eos or file */
-
- /* We must put the external symbols apart. The loader
- does not bomb if we do not. But the references in
- the endndx field for a .bb symbol are not corrected
- if an external symbol is removed between .bb and .be.
- I.e in the following case :
- [20] .bb endndx = 22
- [21] foo external
- [22] .be
- ld will move the symbol 21 to the end of the list but
- endndx will still be 22 instead of 21. */
-
-
- if (SF_GET_LOCAL(symbolP)) {
- /* remove C_EFCN and LOCAL (L...) symbols */
- /* next pointer remains valid */
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
-
- } else if (
-#ifdef TE_I386AIX
- S_GET_STORAGE_CLASS(symbolP) == C_EXT && !SF_GET_FUNCTION(symbolP)
-#else /* not TE_I386AIX */
- !S_IS_DEFINED(symbolP) && !S_IS_DEBUG(symbolP) && !SF_GET_STATICS(symbolP)
-#endif /* not TE_I386AIX */
- ) {
- /* if external, Remove from the list */
- symbolS *hold = symbol_previous(symbolP);
-
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
- symbol_clear_list_pointers(symbolP);
- symbol_append(symbolP, symbol_extern_lastP, &symbol_externP, &symbol_extern_lastP);
- symbolP = hold;
- } else {
- if (SF_GET_STRING(symbolP)) {
- symbolP->sy_name_offset = string_byte_count;
- string_byte_count += strlen(S_GET_NAME(symbolP)) + 1;
- } else {
- symbolP->sy_name_offset = 0;
- } /* fix "long" names */
-
- symbolP->sy_number = symbol_number;
- symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP);
- } /* if local symbol */
- } /* traverse the symbol list */
-
- for (symbolP = symbol_externP; symbol_externP;) {
- symbolS *tmp = symbol_externP;
-
- /* append */
- symbol_remove(tmp, &symbol_externP, &symbol_extern_lastP);
- symbol_append(tmp, symbol_lastP, &symbol_rootP, &symbol_lastP);
-
- /* and process */
- if (SF_GET_STRING(tmp)) {
- tmp->sy_name_offset = string_byte_count;
- string_byte_count += strlen(S_GET_NAME(tmp)) + 1;
- } else {
- tmp->sy_name_offset = 0;
- } /* fix "long" names */
-
- tmp->sy_number = symbol_number;
- symbol_number += 1 + S_GET_NUMBER_AUXILIARY(tmp);
- } /* append the entire extern chain */
-
- /* When a tag reference preceeds the tag definition,
- the definition will not have a number at the time
- we process the reference during the first
- traversal. Thus, a second traversal. */
-
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- if (SF_GET_TAGGED(symbolP)) {
- SA_SET_SYM_TAGNDX(symbolP, ((symbolS*) SA_GET_SYM_TAGNDX(symbolP))->sy_number);
- } /* If the symbol has a tagndx entry, resolve it */
- } /* second traversal */
-
- know(symbol_externP == NULL);
- know(symbol_extern_lastP == NULL);
-
- /* FIXME-SOMEDAY I'm counting line no's here so we know what to put in the section
- headers, and I'm resolving the addresses since I'm not sure how to
- do it later. I am NOT resolving the linno's representing functions.
- Their symbols need a fileptr pointing to this linno when emitted.
- Thus, I resolve them on emit. xoxorich. */
-
- for (lineP = lineno_rootP; lineP; lineP = lineP->next) {
- if (lineP->line.l_lnno > 0) {
- lineP->line.l_addr.l_paddr += ((fragS*)lineP->frag)->fr_address;
- } else {
- ;
- }
- text_lineno_number++;
- } /* for each line number */
-
- H_SET_SYMBOL_TABLE_SIZE(headers, symbol_number);
-
- return;
-} /* obj_crawl_symbol_chain() */
-
-/*
- * Find strings by crawling along symbol table chain.
- */
-
-void obj_emit_strings(where)
-char **where;
-{
- symbolS *symbolP;
-
-#ifdef CROSS_COMPILE
- /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
- md_number_to_chars(*where, string_byte_count, sizeof(string_byte_count));
- *where += sizeof(string_byte_count);
-#else /* CROSS_COMPILE */
- append(where, (char *) &string_byte_count, (unsigned long) sizeof(string_byte_count));
-#endif /* CROSS_COMPILE */
-
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- if (SF_GET_STRING(symbolP)) {
- append(where, S_GET_NAME(symbolP), (unsigned long)(strlen(S_GET_NAME(symbolP)) + 1));
- } /* if it has a string */
- } /* walk the symbol chain */
-
- return;
-} /* obj_emit_strings() */
-
-void obj_pre_write_hook(headers)
-object_headers *headers;
-{
- register int text_relocation_number = 0;
- register int data_relocation_number = 0;
- register fixS *fixP;
-
- H_SET_MAGIC_NUMBER(headers, FILE_HEADER_MAGIC);
- H_SET_ENTRY_POINT(headers, 0);
-
- /* FIXME-SOMEDAY this should be done at
- fixup_segment time but I'm going to wait until I
- do multiple segments. xoxorich. */
- /* Count the number of relocation entries for text and data */
- for (fixP = text_fix_root; fixP; fixP = fixP->fx_next) {
- if (fixP->fx_addsy) {
- ++text_relocation_number;
-#ifdef TC_I960
- /* two relocs per callj under coff. */
- if (fixP->fx_callj) {
- ++text_relocation_number;
- } /* if callj and not already fixed. */
-#endif /* TC_I960 */
-#ifdef TC_A29K
- /* Count 2 for a constH */
- if (fixP->fx_r_type == RELOC_CONSTH) {
- ++text_relocation_number;
- }
-#endif
-
- } /* if not yet fixed */
- } /* for each fix */
-
- SA_SET_SCN_NRELOC(dot_text_symbol, text_relocation_number);
- /* Assign the number of line number entries for the text section */
- SA_SET_SCN_NLINNO(dot_text_symbol, text_lineno_number);
- /* Assign the size of the section */
- SA_SET_SCN_SCNLEN(dot_text_symbol, H_GET_TEXT_SIZE(headers));
-
- for (fixP = data_fix_root; fixP; fixP = fixP->fx_next) {
- if (fixP->fx_addsy) {
- ++data_relocation_number;
- } /* if still relocatable */
-#ifdef TC_A29K
- /* Count 2 for a constH */
- if (fixP->fx_r_type == RELOC_CONSTH) {
- ++data_relocation_number;
- }
-#endif
-
- } /* for each fix */
-
-
- SA_SET_SCN_NRELOC(dot_data_symbol, data_relocation_number);
- /* Assign the size of the section */
- SA_SET_SCN_SCNLEN(dot_data_symbol, H_GET_DATA_SIZE(headers));
-
- /* Assign the size of the section */
- SA_SET_SCN_SCNLEN(dot_bss_symbol, H_GET_BSS_SIZE(headers));
-
- /* pre write hook can add relocs (for 960 and 29k coff) so */
- headers->relocation_size = text_relocation_number * RELSZ +
- data_relocation_number *RELSZ;
-
-
-
- /* Fill in extra coff fields */
-
- /* Initialize general line number information. */
- H_SET_LINENO_SIZE(headers, text_lineno_number * LINESZ);
-
- /* filehdr */
- H_SET_FILE_MAGIC_NUMBER(headers, FILE_HEADER_MAGIC);
- H_SET_NUMBER_OF_SECTIONS(headers, 3); /* text+data+bss */
-#ifndef OBJ_COFF_OMIT_TIMESTAMP
- H_SET_TIME_STAMP(headers, (long)time((long*)0));
-#else /* OBJ_COFF_OMIT_TIMESTAMP */
- H_SET_TIME_STAMP(headers, 0);
-#endif /* OBJ_COFF_OMIT_TIMESTAMP */
- H_SET_SYMBOL_TABLE_POINTER(headers, H_GET_SYMBOL_TABLE_FILE_OFFSET(headers));
-#if 0
- printf("FILHSZ %x\n", FILHSZ);
- printf("OBJ_COFF_AOUTHDRSZ %x\n", OBJ_COFF_AOUTHDRSZ);
- printf("section headers %x\n", H_GET_NUMBER_OF_SECTIONS(headers) * SCNHSZ);
- printf("get text size %x\n", H_GET_TEXT_SIZE(headers));
- printf("get data size %x\n", H_GET_DATA_SIZE(headers));
- printf("get relocation size %x\n", H_GET_RELOCATION_SIZE(headers));
- printf("get lineno size %x\n", H_GET_LINENO_SIZE(headers));
-#endif
- /* symbol table size allready set */
- H_SET_SIZEOF_OPTIONAL_HEADER(headers, OBJ_COFF_AOUTHDRSZ);
-
- /* do not added the F_RELFLG for the standard COFF.
- * The AIX linker complain on file with relocation info striped flag.
- */
-#ifdef KEEP_RELOC_INFO
- H_SET_FLAGS(headers, (text_lineno_number == 0 ? F_LNNO : 0)
- | BYTE_ORDERING);
-#else
- H_SET_FLAGS(headers, (text_lineno_number == 0 ? F_LNNO : 0)
- | ((text_relocation_number + data_relocation_number) ? 0 : F_RELFLG)
- | BYTE_ORDERING);
-#endif
- /* aouthdr */
- /* magic number allready set */
- H_SET_VERSION_STAMP(headers, 0);
- /* Text, data, bss size; entry point; text_start and data_start are already set */
-
- /* Build section headers */
-
- c_section_header(&text_section_header,
- ".text",
- 0,
- H_GET_TEXT_SIZE(headers),
- H_GET_TEXT_FILE_OFFSET(headers),
- (SA_GET_SCN_NRELOC(dot_text_symbol)
- ? H_GET_RELOCATION_FILE_OFFSET(headers)
- : 0),
- (text_lineno_number
- ? H_GET_LINENO_FILE_OFFSET(headers)
- : 0),
- SA_GET_SCN_NRELOC(dot_text_symbol),
- text_lineno_number,
- section_alignment[(int) SEG_TEXT]);
-
- c_section_header(&data_section_header,
- ".data",
- H_GET_TEXT_SIZE(headers),
- H_GET_DATA_SIZE(headers),
- (H_GET_DATA_SIZE(headers)
- ? H_GET_DATA_FILE_OFFSET(headers)
- : 0),
- (SA_GET_SCN_NRELOC(dot_data_symbol)
- ? (H_GET_RELOCATION_FILE_OFFSET(headers)
- + text_section_header.s_nreloc * RELSZ)
- : 0),
- 0, /* No line number information */
- SA_GET_SCN_NRELOC(dot_data_symbol),
- 0, /* No line number information */
- section_alignment[(int) SEG_DATA]);
-
- c_section_header(&bss_section_header,
- ".bss",
- H_GET_TEXT_SIZE(headers) + H_GET_DATA_SIZE(headers),
- H_GET_BSS_SIZE(headers),
- 0, /* No file offset */
- 0, /* No relocation information */
- 0, /* No line number information */
- 0, /* No relocation information */
- 0, /* No line number information */
- section_alignment[(int) SEG_BSS]);
-
- return;
-} /* obj_pre_write_hook() */
-
-/* This is a copy from aout. All I do is neglect to actually build the symbol. */
-
-static void obj_coff_stab(what)
-int what;
-{
- char *string;
- expressionS e;
- int goof = 0; /* TRUE if we have aborted. */
- int length;
- int saved_type = 0;
- long longint;
- symbolS *symbolP = 0;
-
- if (what == 's') {
- string = demand_copy_C_string(&length);
- SKIP_WHITESPACE();
-
- if (*input_line_pointer == ',') {
- input_line_pointer++;
- } else {
- as_bad("I need a comma after symbol's name");
- goof = 1;
- } /* better be a comma */
- } /* skip the string */
-
- /*
- * Input_line_pointer->after ','. String->symbol name.
- */
- if (!goof) {
- if (get_absolute_expression_and_terminator(&longint) != ',') {
- as_bad("I want a comma after the n_type expression");
- goof = 1;
- input_line_pointer--; /* Backup over a non-',' char. */
- } /* on error */
- } /* no error */
-
- if (!goof) {
- if (get_absolute_expression_and_terminator(&longint) != ',') {
- as_bad("I want a comma after the n_other expression");
- goof = 1;
- input_line_pointer--; /* Backup over a non-',' char. */
- } /* on error */
- } /* no error */
-
- if (!goof) {
- get_absolute_expression();
-
- if (what == 's' || what == 'n') {
- if (*input_line_pointer != ',') {
- as_bad("I want a comma after the n_desc expression");
- goof = 1;
- } else {
- input_line_pointer++;
- } /* on goof */
- } /* not stabd */
- } /* no error */
-
- expression(&e);
-
- if (goof) {
- ignore_rest_of_line();
- } else {
- demand_empty_rest_of_line();
- } /* on error */
-} /* obj_coff_stab() */
-
-#ifdef DEBUG
-/* for debugging */
-char *s_get_name(s)
-symbolS *s;
-{
- return((s == NULL) ? "(NULL)" : S_GET_NAME(s));
-} /* s_get_name() */
-
-void symbol_dump() {
- symbolS *symbolP;
-
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- printf("%3ld: 0x%lx \"%s\" type = %ld, class = %d, segment = %d\n",
- symbolP->sy_number,
- (unsigned long) symbolP,
- S_GET_NAME(symbolP),
- (long) S_GET_DATA_TYPE(symbolP),
- S_GET_STORAGE_CLASS(symbolP),
- (int) S_GET_SEGMENT(symbolP));
- } /* traverse symbols */
-
- return;
-} /* symbol_dump() */
-#endif /* DEBUG */
-
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-coff.c */
diff --git a/gnu/usr.bin/as/config/obj-coff.h b/gnu/usr.bin/as/config/obj-coff.h
deleted file mode 100644
index 3f1f7ea..0000000
--- a/gnu/usr.bin/as/config/obj-coff.h
+++ /dev/null
@@ -1,598 +0,0 @@
-/* coff object file format
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define OBJ_COFF 1
-
-#include "targ-cpu.h"
-
-
-
-#ifdef BFD_HEADERS
-#ifdef TC_A29K
-#include "bfd.h"
-#include "coff/a29k.h"
-
-/* This internal_lineno crap is to stop namespace pollution from the bfd internal
- coff headerfile. */
-
-#define internal_lineno bfd_internal_lineno
-#include "coff/internal.h"
-#undef internal_lineno
-/*
- #undef RELOC
- #undef SYMENT
- #undef AUXENT
- #undef LINENO
- #undef FILHDR
- #undef SCNHDR
- #define RELOC struct internal_reloc
- #define SYMENT struct internal_syment
- #define AUXENT union internal_auxent
- #define SCNHDR struct internal_scnhdr
- #define LINENO struct bfd_internal_lineno
- #define AOUTHDR struct internal_aouthdr
- #define FILHDR struct internal_filehdr
- #define AOUTHDRSZ sizeof(struct external_aouthdr)
- */
-/*#define x_endndx x_endndx.l
- #define x_tagndx x_tagndx.l*/
-#define TARGET_FORMAT "coff-a29k-big"
-extern bfd *stdoutput;
-
-#else /* not TC_A29K */
-# ifdef TC_I386
-# include "bfd.h"
-# include "coff/i386.h"
-# define internal_lineno bfd_internal_lineno
-# include "coff/internal.h"
-# undef internal_lineno
-# define TARGET_FORMAT "coff-i386"
-extern bfd *stdoutput;
-
-#else /* not TC_I386 */
-#error help me
-#endif /* not TC_I386 */
-
-#endif /* not TC_A29K */
-
-#else /* not BFD_HEADERS */
-
-#ifdef USE_NATIVE_HEADERS
-#include <filehdr.h>
-#include <aouthdr.h>
-#include <scnhdr.h>
-#include <storclass.h>
-#include <linenum.h>
-#include <syms.h>
-#include <reloc.h>
-#include <sys/types.h>
-#else /* not USE_NATIVE_HEADERS */
-#include "coff.h"
-#endif /* not USE_NATIVE_HEADERS */
-
-#endif /* not BFD_HEADERS */
-
-/* Define some processor dependent values according to the processor we are on. */
-#ifdef TC_M68K
-
-#define BYTE_ORDERING F_AR32W /* See filehdr.h for more info. */
-#ifndef FILE_HEADER_MAGIC
-#define FILE_HEADER_MAGIC MC68MAGIC /* ... */
-#endif /* FILE_HEADER_MAGIC */
-
-#elif defined(TC_I386)
-
-#define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */
-#ifndef FILE_HEADER_MAGIC
-#define FILE_HEADER_MAGIC I386MAGIC /* ... */
-#endif /* FILE_HEADER_MAGIC */
-
-#elif defined(TC_I960)
-
-#define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */
-#ifndef FILE_HEADER_MAGIC
-#define FILE_HEADER_MAGIC I960ROMAGIC /* ... */
-#endif /* FILE_HEADER_MAGIC */
-
-#elif defined(TC_A29K)
-
-#define BYTE_ORDERING F_AR32W /* big endian. */
-#ifndef FILE_HEADER_MAGIC
-#define FILE_HEADER_MAGIC SIPFBOMAGIC
-#endif /* FILE_HEADER_MAGIC */
-
-#else
-you lose
-#endif
-
-#ifndef OBJ_COFF_MAX_AUXENTRIES
-#define OBJ_COFF_MAX_AUXENTRIES 1
-#endif /* OBJ_COFF_MAX_AUXENTRIES */
-
- extern const short seg_N_TYPE[];
-extern const segT N_TYPE_seg[];
-
-#ifndef BFD_HEADERS
-
-/* Add these definitions to have a consistent convention for all the
- types used in COFF format. */
-#define AOUTHDR struct aouthdr
-#define AOUTHDRSZ sizeof(AOUTHDR)
-#endif
-
-/* SYMBOL TABLE */
-
-/* targets may also set this */
-#ifndef SYMBOLS_NEED_BACKPOINTERS
-#define SYMBOLS_NEED_BACKPOINTERS 1
-#endif /* SYMBOLS_NEED_BACKPOINTERS */
-
-/* Symbol table entry data type */
-
-typedef struct {
-#ifdef BFD_HEADERS
- struct internal_syment ost_entry; /* Basic symbol */
- union internal_auxent ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */
-#else
- SYMENT ost_entry; /* Basic symbol */
- AUXENT ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */
-#endif
- unsigned int ost_flags; /* obj_coff internal use only flags */
-} obj_symbol_type;
-
-#define DO_NOT_STRIP 0
-#define DO_STRIP 1
-
-/* Symbol table macros and constants */
-
-/* Possible and usefull section number in symbol table
- * The values of TEXT, DATA and BSS may not be portable.
- */
-
-#define C_TEXT_SECTION ((short)1)
-#define C_DATA_SECTION ((short)2)
-#define C_BSS_SECTION ((short)3)
-#define C_ABS_SECTION N_ABS
-#define C_UNDEF_SECTION N_UNDEF
-#define C_DEBUG_SECTION N_DEBUG
-#define C_NTV_SECTION N_TV
-#define C_PTV_SECTION P_TV
-#define C_REGISTER_SECTION 4
-
-/*
- * Macros to extract information from a symbol table entry.
- * This syntaxic indirection allows independence regarding a.out or coff.
- * The argument (s) of all these macros is a pointer to a symbol table entry.
- */
-
-/* Predicates */
-/* True if the symbol is external */
-#define S_IS_EXTERNAL(s) ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION)
-/* True if symbol has been defined, ie :
- section > 0 (DATA, TEXT or BSS)
- section == 0 and value > 0 (external bss symbol) */
-#define S_IS_DEFINED(s) ((s)->sy_symbol.ost_entry.n_scnum > C_UNDEF_SECTION || \
- ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION && \
- (s)->sy_symbol.ost_entry.n_value > 0))
-/* True if a debug special symbol entry */
-#define S_IS_DEBUG(s) ((s)->sy_symbol.ost_entry.n_scnum == C_DEBUG_SECTION)
-/* True if a symbol is local symbol name */
-/* A symbol name whose name begin with ^A is a gas internal pseudo symbol */
-#define S_IS_LOCAL(s) (S_GET_NAME(s)[0] == '\001' || \
- (s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION || \
- (S_LOCAL_NAME(s) && !flagseen['L']))
-/* True if a symbol is not defined in this file */
-#define S_IS_EXTERN(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value == 0)
-/*
- * True if a symbol can be multiply defined (bss symbols have this def
- * though it is bad practice)
- */
-#define S_IS_COMMON(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value != 0)
-/* True if a symbol name is in the string table, i.e. its length is > 8. */
-#define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
-
-/* Accessors */
-/* The name of the symbol */
-#define S_GET_NAME(s) ((char*)(s)->sy_symbol.ost_entry.n_offset)
-/* The pointer to the string table */
-#define S_GET_OFFSET(s) ((s)->sy_symbol.ost_entry.n_offset)
-/* The zeroes if symbol name is longer than 8 chars */
-#define S_GET_ZEROES(s) ((s)->sy_symbol.ost_entry.n_zeroes)
-/* The value of the symbol */
-#define S_GET_VALUE(s) ((unsigned) ((s)->sy_symbol.ost_entry.n_value))
-/* The numeric value of the segment */
-#define S_GET_SEGMENT(s) (N_TYPE_seg[(s)->sy_symbol.ost_entry.n_scnum+4])
-/* The data type */
-#define S_GET_DATA_TYPE(s) ((s)->sy_symbol.ost_entry.n_type)
-/* The storage class */
-#define S_GET_STORAGE_CLASS(s) ((s)->sy_symbol.ost_entry.n_sclass)
-/* The number of auxiliary entries */
-#define S_GET_NUMBER_AUXILIARY(s) ((s)->sy_symbol.ost_entry.n_numaux)
-
-/* Modifiers */
-/* Set the name of the symbol */
-#define S_SET_NAME(s,v) ((s)->sy_symbol.ost_entry.n_offset = (unsigned long)(v))
-/* Set the offset of the symbol */
-#define S_SET_OFFSET(s,v) ((s)->sy_symbol.ost_entry.n_offset = (v))
-/* The zeroes if symbol name is longer than 8 chars */
-#define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v))
-/* Set the value of the symbol */
-#define S_SET_VALUE(s,v) ((s)->sy_symbol.ost_entry.n_value = (v))
-/* The numeric value of the segment */
-#define S_SET_SEGMENT(s,v) ((s)->sy_symbol.ost_entry.n_scnum = SEGMENT_TO_SYMBOL_TYPE(v))
-/* The data type */
-#define S_SET_DATA_TYPE(s,v) ((s)->sy_symbol.ost_entry.n_type = (v))
-/* The storage class */
-#define S_SET_STORAGE_CLASS(s,v) ((s)->sy_symbol.ost_entry.n_sclass = (v))
-/* The number of auxiliary entries */
-#define S_SET_NUMBER_AUXILIARY(s,v) ((s)->sy_symbol.ost_entry.n_numaux = (v))
-
-/* Additional modifiers */
-/* The symbol is external (does not mean undefined) */
-#define S_SET_EXTERNAL(s) { S_SET_STORAGE_CLASS(s, C_EXT) ; SF_CLEAR_LOCAL(s); }
-
-/* Auxiliary entry macros. SA_ stands for symbol auxiliary */
-/* Omit the tv related fields */
-/* Accessors */
-#ifdef BFD_HEADERS
-#define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l)
-#else
-#define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx)
-#endif
-#define SA_GET_SYM_LNNO(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno)
-#define SA_GET_SYM_SIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size)
-#define SA_GET_SYM_FSIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize)
-#define SA_GET_SYM_LNNOPTR(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr)
-#ifdef BFD_HEADERS
-#define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l)
-#else
-#define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx)
-#endif
-#define SA_GET_SYM_DIMEN(s,i) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)])
-#define SA_GET_FILE_FNAME(s) ((s)->sy_symbol.ost_auxent[0].x_file.x_fname)
-#define SA_GET_SCN_SCNLEN(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen)
-#define SA_GET_SCN_NRELOC(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc)
-#define SA_GET_SCN_NLINNO(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno)
-
-/* Modifiers */
-#ifdef BFD_HEADERS
-#define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l=(v))
-#else
-#define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx=(v))
-#endif
-#define SA_SET_SYM_LNNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno=(v))
-#define SA_SET_SYM_SIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size=(v))
-#define SA_SET_SYM_FSIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize=(v))
-#define SA_SET_SYM_LNNOPTR(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr=(v))
-#ifdef BFD_HEADERS
-#define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l=(v))
-#else
-#define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx=(v))
-#endif
-#define SA_SET_SYM_DIMEN(s,i,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v))
-#define SA_SET_FILE_FNAME(s,v) strncpy((s)->sy_symbol.ost_auxent[0].x_file.x_fname,(v),FILNMLEN)
-#define SA_SET_SCN_SCNLEN(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen=(v))
-#define SA_SET_SCN_NRELOC(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc=(v))
-#define SA_SET_SCN_NLINNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno=(v))
-
-/*
- * Internal use only definitions. SF_ stands for symbol flags.
- *
- * These values can be assigned to sy_symbol.ost_flags field of a symbolS.
- *
- * You'll break i960 if you shift the SYSPROC bits anywhere else. for
- * more on the balname/callname hack, see tc-i960.h. b.out is done
- * differently.
- */
-
-#define SF_I960_MASK (0x000001ff) /* Bits 0-8 are used by the i960 port. */
-#define SF_SYSPROC (0x0000003f) /* bits 0-5 are used to store the sysproc number */
-#define SF_IS_SYSPROC (0x00000040) /* bit 6 marks symbols that are sysprocs */
-#define SF_BALNAME (0x00000080) /* bit 7 marks BALNAME symbols */
-#define SF_CALLNAME (0x00000100) /* bit 8 marks CALLNAME symbols */
-
-#define SF_NORMAL_MASK (0x0000ffff) /* bits 12-15 are general purpose. */
-
-#define SF_STATICS (0x00001000) /* Mark the .text & all symbols */
-#define SF_DEFINED (0x00002000) /* Symbol is defined in this file */
-#define SF_STRING (0x00004000) /* Symbol name length > 8 */
-#define SF_LOCAL (0x00008000) /* Symbol must not be emitted */
-
-#define SF_DEBUG_MASK (0xffff0000) /* bits 16-31 are debug info */
-
-#define SF_FUNCTION (0x00010000) /* The symbol is a function */
-#define SF_PROCESS (0x00020000) /* Process symbol before write */
-#define SF_TAGGED (0x00040000) /* Is associated with a tag */
-#define SF_TAG (0x00080000) /* Is a tag */
-#define SF_DEBUG (0x00100000) /* Is in debug or abs section */
-#define SF_GET_SEGMENT (0x00200000) /* Get the section of the forward symbol. */
-/* All other bits are unused. */
-
-/* Accessors */
-#define SF_GET(s) ((s)->sy_symbol.ost_flags)
-#define SF_GET_NORMAL_FIELD(s) ((s)->sy_symbol.ost_flags & SF_NORMAL_MASK)
-#define SF_GET_DEBUG_FIELD(s) ((s)->sy_symbol.ost_flags & SF_DEBUG_MASK)
-#define SF_GET_FILE(s) ((s)->sy_symbol.ost_flags & SF_FILE)
-#define SF_GET_STATICS(s) ((s)->sy_symbol.ost_flags & SF_STATICS)
-#define SF_GET_DEFINED(s) ((s)->sy_symbol.ost_flags & SF_DEFINED)
-#define SF_GET_STRING(s) ((s)->sy_symbol.ost_flags & SF_STRING)
-#define SF_GET_LOCAL(s) ((s)->sy_symbol.ost_flags & SF_LOCAL)
-#define SF_GET_FUNCTION(s) ((s)->sy_symbol.ost_flags & SF_FUNCTION)
-#define SF_GET_PROCESS(s) ((s)->sy_symbol.ost_flags & SF_PROCESS)
-#define SF_GET_DEBUG(s) ((s)->sy_symbol.ost_flags & SF_DEBUG)
-#define SF_GET_TAGGED(s) ((s)->sy_symbol.ost_flags & SF_TAGGED)
-#define SF_GET_TAG(s) ((s)->sy_symbol.ost_flags & SF_TAG)
-#define SF_GET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags & SF_GET_SEGMENT)
-#define SF_GET_I960(s) ((s)->sy_symbol.ost_flags & SF_I960_MASK) /* used by i960 */
-#define SF_GET_BALNAME(s) ((s)->sy_symbol.ost_flags & SF_BALNAME) /* used by i960 */
-#define SF_GET_CALLNAME(s) ((s)->sy_symbol.ost_flags & SF_CALLNAME) /* used by i960 */
-#define SF_GET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_IS_SYSPROC) /* used by i960 */
-#define SF_GET_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_SYSPROC) /* used by i960 */
-
-/* Modifiers */
-#define SF_SET(s,v) ((s)->sy_symbol.ost_flags = (v))
-#define SF_SET_NORMAL_FIELD(s,v)((s)->sy_symbol.ost_flags |= ((v) & SF_NORMAL_MASK))
-#define SF_SET_DEBUG_FIELD(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_DEBUG_MASK))
-#define SF_SET_FILE(s) ((s)->sy_symbol.ost_flags |= SF_FILE)
-#define SF_SET_STATICS(s) ((s)->sy_symbol.ost_flags |= SF_STATICS)
-#define SF_SET_DEFINED(s) ((s)->sy_symbol.ost_flags |= SF_DEFINED)
-#define SF_SET_STRING(s) ((s)->sy_symbol.ost_flags |= SF_STRING)
-#define SF_SET_LOCAL(s) ((s)->sy_symbol.ost_flags |= SF_LOCAL)
-#define SF_CLEAR_LOCAL(s) ((s)->sy_symbol.ost_flags &= ~SF_LOCAL)
-#define SF_SET_FUNCTION(s) ((s)->sy_symbol.ost_flags |= SF_FUNCTION)
-#define SF_SET_PROCESS(s) ((s)->sy_symbol.ost_flags |= SF_PROCESS)
-#define SF_SET_DEBUG(s) ((s)->sy_symbol.ost_flags |= SF_DEBUG)
-#define SF_SET_TAGGED(s) ((s)->sy_symbol.ost_flags |= SF_TAGGED)
-#define SF_SET_TAG(s) ((s)->sy_symbol.ost_flags |= SF_TAG)
-#define SF_SET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags |= SF_GET_SEGMENT)
-#define SF_SET_I960(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_I960_MASK)) /* used by i960 */
-#define SF_SET_BALNAME(s) ((s)->sy_symbol.ost_flags |= SF_BALNAME) /* used by i960 */
-#define SF_SET_CALLNAME(s) ((s)->sy_symbol.ost_flags |= SF_CALLNAME) /* used by i960 */
-#define SF_SET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags |= SF_IS_SYSPROC) /* used by i960 */
-#define SF_SET_SYSPROC(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_SYSPROC)) /* used by i960 */
-
-/* File header macro and type definition */
-
-/*
- * File position calculators. Beware to use them when all the
- * appropriate fields are set in the header.
- */
-
-#ifdef OBJ_COFF_OMIT_OPTIONAL_HEADER
-#define OBJ_COFF_AOUTHDRSZ (0)
-#else
-#define OBJ_COFF_AOUTHDRSZ (AOUTHDRSZ)
-#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
-
-#define H_GET_FILE_SIZE(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
- H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
- H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h) + \
- H_GET_SYMBOL_TABLE_SIZE(h) + \
- (h)->string_table_size)
-#define H_GET_TEXT_FILE_OFFSET(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)
-#define H_GET_DATA_FILE_OFFSET(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
- H_GET_TEXT_SIZE(h))
-#define H_GET_BSS_FILE_OFFSET(h) 0
-#define H_GET_RELOCATION_FILE_OFFSET(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
- H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h))
-#define H_GET_LINENO_FILE_OFFSET(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
- H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
- H_GET_RELOCATION_SIZE(h))
-#define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
- H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
- H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h))
-
-/* Accessors */
-/* aouthdr */
-#define H_GET_MAGIC_NUMBER(h) ((h)->aouthdr.magic)
-#define H_GET_VERSION_STAMP(h) ((h)->aouthdr.vstamp)
-#define H_GET_TEXT_SIZE(h) ((h)->aouthdr.tsize)
-#define H_GET_DATA_SIZE(h) ((h)->aouthdr.dsize)
-#define H_GET_BSS_SIZE(h) ((h)->aouthdr.bsize)
-#define H_GET_ENTRY_POINT(h) ((h)->aouthdr.entry)
-#define H_GET_TEXT_START(h) ((h)->aouthdr.text_start)
-#define H_GET_DATA_START(h) ((h)->aouthdr.data_start)
-/* filehdr */
-#define H_GET_FILE_MAGIC_NUMBER(h) ((h)->filehdr.f_magic)
-#define H_GET_NUMBER_OF_SECTIONS(h) ((h)->filehdr.f_nscns)
-#define H_GET_TIME_STAMP(h) ((h)->filehdr.f_timdat)
-#define H_GET_SYMBOL_TABLE_POINTER(h) ((h)->filehdr.f_symptr)
-#define H_GET_SYMBOL_COUNT(h) ((h)->filehdr.f_nsyms)
-#define H_GET_SYMBOL_TABLE_SIZE(h) (H_GET_SYMBOL_COUNT(h) * SYMESZ)
-#define H_GET_SIZEOF_OPTIONAL_HEADER(h) ((h)->filehdr.f_opthdr)
-#define H_GET_FLAGS(h) ((h)->filehdr.f_flags)
-/* Extra fields to achieve bsd a.out compatibility and for convenience */
-#define H_GET_RELOCATION_SIZE(h) ((h)->relocation_size)
-#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
-#define H_GET_LINENO_SIZE(h) ((h)->lineno_size)
-
-#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
-#define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \
- + sizeof(AOUTHDR)\
- + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
-#else /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
-#define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \
- + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
-#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
-
-#define H_GET_TEXT_RELOCATION_SIZE(h) (text_section_header.s_nreloc * RELSZ)
-#define H_GET_DATA_RELOCATION_SIZE(h) (data_section_header.s_nreloc * RELSZ)
-
-/* Modifiers */
-/* aouthdr */
-#define H_SET_MAGIC_NUMBER(h,v) ((h)->aouthdr.magic = (v))
-#define H_SET_VERSION_STAMP(h,v) ((h)->aouthdr.vstamp = (v))
-#define H_SET_TEXT_SIZE(h,v) ((h)->aouthdr.tsize = (v))
-#define H_SET_DATA_SIZE(h,v) ((h)->aouthdr.dsize = (v))
-#define H_SET_BSS_SIZE(h,v) ((h)->aouthdr.bsize = (v))
-#define H_SET_ENTRY_POINT(h,v) ((h)->aouthdr.entry = (v))
-#define H_SET_TEXT_START(h,v) ((h)->aouthdr.text_start = (v))
-#define H_SET_DATA_START(h,v) ((h)->aouthdr.data_start = (v))
-/* filehdr */
-#define H_SET_FILE_MAGIC_NUMBER(h,v) ((h)->filehdr.f_magic = (v))
-#define H_SET_NUMBER_OF_SECTIONS(h,v) ((h)->filehdr.f_nscns = (v))
-#define H_SET_TIME_STAMP(h,v) ((h)->filehdr.f_timdat = (v))
-#define H_SET_SYMBOL_TABLE_POINTER(h,v) ((h)->filehdr.f_symptr = (v))
-#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->filehdr.f_nsyms = (v))
-#define H_SET_SIZEOF_OPTIONAL_HEADER(h,v) ((h)->filehdr.f_opthdr = (v))
-#define H_SET_FLAGS(h,v) ((h)->filehdr.f_flags = (v))
-/* Extra fields to achieve bsd a.out compatibility and for convinience */
-#define H_SET_RELOCATION_SIZE(h,t,d) ((h)->relocation_size = (t)+(d))
-#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
-#define H_SET_LINENO_SIZE(h,v) ((h)->lineno_size = (v))
-
-/* Segment flipping */
-#define segment_name(v) (seg_name[(int) (v)])
-
-typedef struct {
-#ifdef BFD_HEADERS
- struct internal_aouthdr aouthdr; /* a.out header */
- struct internal_filehdr filehdr; /* File header, not machine dep. */
-#else
- AOUTHDR aouthdr; /* a.out header */
- FILHDR filehdr; /* File header, not machine dep. */
-#endif
- long string_table_size; /* names + '\0' + sizeof(int) */
- long relocation_size; /* Cumulated size of relocation
- information for all sections in
- bytes. */
- long lineno_size; /* Size of the line number information
- table in bytes */
-} object_headers;
-
-/* -------------- Line number handling ------- */
-extern int text_lineno_number;
-
-/* line numbering stuff. */
-
-typedef struct internal_lineno {
-#ifdef BFD_HEADERS
- struct bfd_internal_lineno line;
-#else
- LINENO line; /* The lineno structure itself */
-#endif
- char* frag; /* Frag to which the line number is related */
- struct internal_lineno* next; /* Forward chain pointer */
-} lineno;
-
-extern lineno *lineno_lastP;
-extern lineno *lineno_rootP;
-#define OBJ_EMIT_LINENO(a, b, c) obj_emit_lineno((a),(b),(c))
-
-#if __STDC__ == 1
-void obj_emit_lineno(char **where, lineno *line, char *file_start);
-#else /* not __STDC__ */
-void obj_emit_lineno();
-#endif /* not __STDC__ */
-
-/* stack stuff */
-typedef struct {
- unsigned long chunk_size;
- unsigned long element_size;
- unsigned long size;
- char* data;
- unsigned long pointer;
-} stack;
-
-#if __STDC__ == 1
-
-char *stack_pop(stack *st);
-char *stack_push(stack *st, char *element);
-char *stack_top(stack *st);
-stack *stack_init(unsigned long chunk_size, unsigned long element_size);
-void c_dot_file_symbol(char *filename);
-void obj_extra_stuff(object_headers *headers);
-void stack_delete(stack *st);
-
-#ifndef tc_headers_hook
-void tc_headers_hook(object_headers *headers);
-#endif /* tc_headers_hook */
-
-#ifndef tc_coff_symbol_emit_hook
-void tc_coff_symbol_emit_hook(); /* really tc_coff_symbol_emit_hook(symbolS *symbolP) */
-#endif /* tc_coff_symbol_emit_hook */
-
-void c_section_header(
-#ifdef BFD_HEADERS
- struct internal_scnhdr *header,
-#else
- SCNHDR *header,
-#endif
-
- char *name,
- long core_address,
- long size,
- long data_ptr,
- long reloc_ptr,
- long lineno_ptr,
- long reloc_number,
- long lineno_number,
- long alignment);
-
-#else /* not __STDC__ */
-
-char *stack_pop();
-char *stack_push();
-char *stack_top();
-stack *stack_init();
-void c_dot_file_symbol();
-void c_section_header();
-void obj_extra_stuff();
-void stack_delete();
-void tc_headers_hook();
-void tc_coff_symbol_emit_hook();
-
-#endif /* not __STDC__ */
-
-
-/* sanity check */
-
-#ifdef TC_I960
-#ifndef C_LEAFSTAT
-hey! Where is the C_LEAFSTAT definition? i960-coff support is depending on it.
-#endif /* no C_LEAFSTAT */
-#endif /* TC_I960 */
-#ifdef BFD_HEADERS
- extern struct internal_scnhdr data_section_header;
-extern struct internal_scnhdr text_section_header;
-#else
-extern SCNHDR data_section_header;
-extern SCNHDR text_section_header;
-#endif
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-coff.h */
diff --git a/gnu/usr.bin/as/config/obj-coffbfd.c b/gnu/usr.bin/as/config/obj-coffbfd.c
deleted file mode 100644
index 352893a..0000000
--- a/gnu/usr.bin/as/config/obj-coffbfd.c
+++ /dev/null
@@ -1,2182 +0,0 @@
-/* coff object file format with bfd
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
-
- How does this releate to the rest of GAS ?
-
- Well, all the other files in gas are more or less a black box. It
- takes care of opening files, parsing command lines, stripping blanks
- etc etc. This module gets a chance to register what it wants to do by
- saying that it is interested in various pseduo ops. The other big
- change is write_object_file. This runs through all the data
- structures that gas builds, and outputs the file in the format of our
- choice.
-
- Hacked for BFDness by steve chamberlain
-
- This object module now supports the Hitachi H8/300 and the AMD 29k
-
- sac@cygnus.com
- */
-
-#include "as.h"
-#include "obstack.h"
-#include "subsegs.h"
-#include "frags.h"
-#include "../bfd/libbfd.h"
-
-
-/* This vector is used to turn an internal segment into a section #
- suitable for insertion into a coff symbol table
- */
-
-const short seg_N_TYPE[] = { /* in: segT out: N_TYPE bits */
- C_ABS_SECTION,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- C_UNDEF_SECTION, /* SEG_UNKNOWN */
- C_UNDEF_SECTION, /* SEG_ABSENT */
- C_UNDEF_SECTION, /* SEG_PASS1 */
- C_UNDEF_SECTION, /* SEG_GOOF */
- C_UNDEF_SECTION, /* SEG_BIG */
- C_UNDEF_SECTION, /* SEG_DIFFERENCE */
- C_DEBUG_SECTION, /* SEG_DEBUG */
- C_NTV_SECTION, /* SEG_NTV */
- C_PTV_SECTION, /* SEG_PTV */
- C_REGISTER_SECTION, /* SEG_REGISTER */
-};
-
-
-int function_lineoff = -1; /* Offset in line#s where the last function
- started (the odd entry for line #0) */
-
-int our_lineno_number = 0; /* we use this to build pointers from .bf's
- into the linetable. It should match
- exactly the values that are later
- assigned in text_lineno_number by
- write.c. */
-
-int text_lineno_number = 0;
-
-/* Add 4 to the real value to get the index and compensate the
- negatives. This vector is used by S_GET_SEGMENT to turn a coff
- section number into a segment number
- */
-static symbolS *previous_file_symbol = NULL;
-void c_symbol_merge();
-static int line_base;
-
-symbolS *c_section_symbol();
-bfd *abfd;
-void EXFUN(bfd_as_write_hook,(struct internal_filehdr *,
- bfd *abfd));
-
-static void EXFUN(fixup_segment,(fixS * fixP,
- segT this_segment_type));
-
-static void EXFUN(fill_section,(bfd *abfd ,
- struct internal_filehdr *f, unsigned
- long *));
-
-
-char *EXFUN(s_get_name,(symbolS *s));
-static symbolS *EXFUN(tag_find_or_make,(char *name));
-static symbolS* EXFUN(tag_find,(char *name));
-
-
-static int
- EXFUN(c_line_new,(
- symbolS *symbol,
- long paddr,
- unsigned short line_number,
- fragS* frag));
-
-
-static void EXFUN(w_symbols,
- (bfd *abfd ,
- char *where ,
- symbolS *symbol_rootP));
-
-
-
-static void EXFUN( obj_coff_def,(int what));
-static void EXFUN( obj_coff_lcomm,(void));
-static void EXFUN( obj_coff_dim,(void));
-static void EXFUN( obj_coff_text,(void));
-static void EXFUN( obj_coff_data,(void));
-static void EXFUN( obj_coff_endef,(void));
-static void EXFUN( obj_coff_line,(void));
-static void EXFUN( obj_coff_ln,(void));
-static void EXFUN( obj_coff_scl,(void));
-static void EXFUN( obj_coff_size,(void));
-static void EXFUN( obj_coff_tag,(void));
-static void EXFUN( obj_coff_type,(void));
-static void EXFUN( obj_coff_val,(void));
-static void EXFUN( obj_coff_section,(void));
-static void EXFUN( tag_init,(void));
-static void EXFUN( tag_insert,(char *name, symbolS *symbolP));
-
-
-static struct hash_control *tag_hash;
-static symbolS *def_symbol_in_progress = NULL;
-
-const pseudo_typeS obj_pseudo_table[] = {
- { "def", obj_coff_def, 0 },
- { "dim", obj_coff_dim, 0 },
- { "endef", obj_coff_endef, 0 },
- { "line", obj_coff_line, 0 },
- { "ln", obj_coff_ln, 0 },
- { "scl", obj_coff_scl, 0 },
- { "size", obj_coff_size, 0 },
- { "tag", obj_coff_tag, 0 },
- { "type", obj_coff_type, 0 },
- { "val", obj_coff_val, 0 },
- { "section", obj_coff_section, 0 },
- { "text", obj_coff_text, 0 },
- { "data", obj_coff_data, 0 },
- /* we don't yet handle this. */
- { "ident", s_ignore, 0 },
- { "ABORT", s_abort, 0 },
- { "lcomm", obj_coff_lcomm, 0},
- { NULL} /* end sentinel */
-}; /* obj_pseudo_table */
-
-
-
-/* Section stuff
-
- We allow more than just the standard 3 sections, infact, we allow
- 10 sections, (though the usual three have to be there).
-
- This structure performs the mappings for us:
-
- */
-
-/* OBS stuff
- static struct internal_scnhdr bss_section_header;
- struct internal_scnhdr data_section_header;
- struct internal_scnhdr text_section_header;
-
- const segT N_TYPE_seg[32] =
- {
-
- };
-
- */
-
-#define N_SEG 32
-typedef struct
-{
- segT seg_t;
- int i;
-} seg_info_type;
-
-seg_info_type seg_info_off_by_4[N_SEG] =
-{
- {SEG_PTV, },
- {SEG_NTV, },
- {SEG_DEBUG, },
- {SEG_ABSOLUTE, },
- {SEG_UNKNOWN, },
- {SEG_E0},
- {SEG_E1},
- {SEG_E2},
- {SEG_E3},
- {SEG_E4},
- {SEG_E5},
- {SEG_E6},
- {SEG_E7},
- {SEG_E8},
- {SEG_E9},
- {15},
- {16},
- {17},
- {18},
- {19},
- {20},
- {0},
- {0},
- {0},
- {SEG_REGISTER},0,0,0,0};
-
-#define SEG_INFO_FROM_SECTION_NUMBER(x) (seg_info_off_by_4[(x)+4])
-#define SEG_INFO_FROM_SEG_NUMBER(x) (seg_info_off_by_4[(x)])
-
-
-relax_addressT
- DEFUN(relax_align,(address, alignment),
- register relax_addressT address AND
- register long alignment )
-{
- relax_addressT mask;
- relax_addressT new_address;
-
- mask = ~ ( (~0) << alignment );
- new_address = (address + mask) & (~ mask);
- return (new_address - address);
-} /* relax_align() */
-
-
-segT
- DEFUN(s_get_segment,(x) ,
- symbolS* x)
-{
- return SEG_INFO_FROM_SECTION_NUMBER(x->sy_symbol.ost_entry.n_scnum).seg_t;
-}
-
-
-
-/* calculate the size of the frag chain and fill in the section header
- to contain all of it, also fill in the addr of the sections */
-static unsigned int DEFUN(size_section,(abfd, idx),
- bfd *abfd AND
- unsigned int idx)
-{
-
- unsigned int size = 0;
- fragS *frag = segment_info[idx].frchainP->frch_root;
- while (frag) {
- if (frag->fr_address != size) {
- printf("Out of step\n");
- size = frag->fr_address;
- }
- size += frag->fr_fix;
- switch (frag->fr_type) {
- case rs_fill:
- case rs_org:
- size += frag->fr_offset * frag->fr_var;
- break;
- case rs_align:
- size += relax_align(size, frag->fr_offset);
- }
- frag = frag->fr_next;
- }
- segment_info[idx].scnhdr.s_size = size;
- return size;
-}
-
-
-static unsigned int DEFUN(count_entries_in_chain,(idx),
- unsigned int idx)
-{
- unsigned int nrelocs;
- fixS *fixup_ptr;
-
- /* Count the relocations */
- fixup_ptr = segment_info[idx].fix_root;
- nrelocs = 0;
- while (fixup_ptr != (fixS *)NULL)
- {
- if (TC_COUNT_RELOC(fixup_ptr))
- {
-
-#ifdef TC_A29K
-
- if (fixup_ptr->fx_r_type == RELOC_CONSTH)
- nrelocs+=2;
- else
- nrelocs++;
-#else
- nrelocs++;
-#endif
- }
-
- fixup_ptr = fixup_ptr->fx_next;
- }
- return nrelocs;
-}
-
-/* output all the relocations for a section */
-void DEFUN(do_relocs_for,(abfd, file_cursor),
- bfd *abfd AND
- unsigned long *file_cursor)
-{
- unsigned int nrelocs;
- unsigned int idx;
-
- for (idx = SEG_E0; idx < SEG_E9; idx++)
- {
- if (segment_info[idx].scnhdr.s_name[0])
- {
-
- struct external_reloc *ext_ptr;
- struct external_reloc *external_reloc_vec;
- unsigned int external_reloc_size;
- unsigned int count = 0;
- unsigned int base = segment_info[idx].scnhdr.s_paddr;
- fixS * fix_ptr = segment_info[idx].fix_root;
- nrelocs = count_entries_in_chain(idx);
- external_reloc_size = nrelocs * RELSZ;
- external_reloc_vec =
- (struct external_reloc*)malloc(external_reloc_size);
-
-
-
- ext_ptr = external_reloc_vec;
-
- /* Fill in the internal coff style reloc struct from the
- internal fix list */
- while (fix_ptr)
- {
- symbolS *symbol_ptr;
- struct internal_reloc intr;
-
- /* Only output some of the relocations */
- if (TC_COUNT_RELOC(fix_ptr))
- {
-#ifdef TC_RELOC_MANGLE
- TC_RELOC_MANGLE(fix_ptr, &intr, base);
-
-#else
- symbolS *dot;
- symbol_ptr = fix_ptr->fx_addsy;
-
- intr.r_type = TC_COFF_FIX2RTYPE(fix_ptr);
- intr.r_vaddr =
- base + fix_ptr->fx_frag->fr_address + fix_ptr->fx_where ;
-
- intr.r_offset = fix_ptr->fx_offset;
-
- intr.r_offset = 0;
-
- /* Turn the segment of the symbol into an offset
- */
- if (symbol_ptr)
- {
- dot = segment_info[S_GET_SEGMENT(symbol_ptr)].dot;
- if (dot)
- {
- intr.r_symndx = dot->sy_number;
- }
- else
- {
- intr.r_symndx = symbol_ptr->sy_number;
- }
-
- }
- else
- {
- intr.r_symndx = -1;
-
-
- }
-#endif
-
- (void)bfd_coff_swap_reloc_out(abfd, &intr, ext_ptr);
- ext_ptr++;
-
-#if defined(TC_A29K)
- /* The 29k has a special kludge for the high 16 bit reloc.
- Two relocations are emmited, R_IHIHALF, and
- R_IHCONST. The second one doesn't contain a symbol,
- but uses the value for offset */
-
- if (intr.r_type == R_IHIHALF)
- {
- /* now emit the second bit */
- intr.r_type = R_IHCONST;
- intr.r_symndx = fix_ptr->fx_addnumber;
- (void)bfd_coff_swap_reloc_out(abfd,&intr,ext_ptr);
- ext_ptr++;
- }
-#endif
- }
-
- fix_ptr = fix_ptr->fx_next;
- }
-
- /* Write out the reloc table */
- segment_info[idx].scnhdr.s_relptr = *file_cursor;
- segment_info[idx].scnhdr.s_nreloc = nrelocs;
- bfd_write((PTR)external_reloc_vec, 1, external_reloc_size, abfd);
- *file_cursor += external_reloc_size;
- free( external_reloc_vec);
- }
- }
-}
-
-
-/* run through a frag chain and write out the data to go with it, fill
- in the scnhdrs with the info on the file postions
- */
-static void DEFUN(fill_section,(abfd, filehdr, file_cursor),
- bfd *abfd AND
- struct internal_filehdr *filehdr AND
- unsigned long *file_cursor)
-{
-
- unsigned int i;
- unsigned int paddr = 0;
-
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
- unsigned int offset = 0;
-
- struct internal_scnhdr *s = &( segment_info[i].scnhdr);
-
- if (s->s_name[0])
- {
- fragS *frag = segment_info[i].frchainP->frch_root;
- char *buffer = malloc(s->s_size);
- s->s_scnptr = *file_cursor;
- s->s_paddr = paddr;
- s->s_vaddr = paddr;
-
- s->s_flags = STYP_REG;
- if (strcmp(s->s_name,".text") == 0)
- s->s_flags |= STYP_TEXT;
- else if (strcmp(s->s_name,".data") == 0)
- s->s_flags |= STYP_DATA;
- else if (strcmp(s->s_name,".bss") == 0)
- s->s_flags |= STYP_BSS | STYP_NOLOAD;
-
- while (frag) {
- unsigned int fill_size;
- switch (frag->fr_type) {
-
- case rs_fill:
- case rs_align:
- case rs_org:
- if (frag->fr_fix)
- {
- memcpy(buffer + frag->fr_address,
- frag->fr_literal,
- frag->fr_fix);
- offset += frag->fr_fix;
- }
-
- fill_size = frag->fr_var;
- if (fill_size)
- {
- unsigned int count ;
- unsigned int off = frag->fr_fix;
- for (count = frag->fr_offset; count; count--)
- {
- memcpy(buffer + frag->fr_address + off,
- frag->fr_literal + frag->fr_fix,
- fill_size);
- off += fill_size;
- offset += fill_size;
-
- }
-
- }
- break;
- default:
- abort();
- }
- frag = frag->fr_next;
- }
-
-
- bfd_write(buffer, s->s_size,1,abfd);
- free(buffer);
-
- *file_cursor += s->s_size;
- paddr += s->s_size;
- }
- }
-
-}
-
-
-
-/* Coff file generation & utilities */
-
-
-static void
- DEFUN(coff_header_append,(abfd, filehdr, aouthdr),
- bfd *abfd AND
- struct internal_filehdr *filehdr AND
- struct internal_aouthdr *aouthdr)
-{
- unsigned int i;
- char buffer[1000];
- char buffero[1000];
-
- bfd_seek(abfd, 0, 0);
-#if 0
- filehdr.f_opthdr = bfd_coff_swap_aouthdr_out(abfd, aouthdr,
- buffero);
-#else
- filehdr->f_opthdr = 0;
-#endif
- i = bfd_coff_swap_filehdr_out(abfd, filehdr, buffer);
-
- bfd_write(buffer, i ,1, abfd);
- bfd_write(buffero, filehdr->f_opthdr, 1, abfd);
-
- for (i = SEG_E0; i < SEG_E9; i++)
- {
- if (segment_info[i].scnhdr.s_name[0])
- {
- unsigned int size =
- bfd_coff_swap_scnhdr_out(abfd,
- &(segment_info[i].scnhdr),
- buffer);
- bfd_write(buffer, size, 1, abfd);
- }
- }
-}
-
-
-char *
- DEFUN(symbol_to_chars,(abfd, where, symbolP),
- bfd*abfd AND
- char *where AND
- symbolS *symbolP)
-{
- unsigned int numaux = symbolP->sy_symbol.ost_entry.n_numaux;
- unsigned int i;
-
- /* Turn any symbols with register attributes into abs symbols */
- if (S_GET_SEGMENT(symbolP) == SEG_REGISTER)
- {
- S_SET_SEGMENT(symbolP, SEG_ABSOLUTE);
- }
- /* At the same time, relocate all symbols to their output value */
-
- S_SET_VALUE(symbolP,
- segment_info[S_GET_SEGMENT(symbolP)].scnhdr.s_paddr
- + S_GET_VALUE(symbolP));
-
- where += bfd_coff_swap_sym_out(abfd, &symbolP->sy_symbol.ost_entry,
- where);
-
- for (i = 0; i < numaux; i++)
- {
- where += bfd_coff_swap_aux_out(abfd,
- &symbolP->sy_symbol.ost_auxent[i],
- S_GET_DATA_TYPE(symbolP),
- S_GET_STORAGE_CLASS(symbolP),
- where);
- }
- return where;
-
-}
-
-
-
-
-void obj_symbol_new_hook(symbolP)
-symbolS *symbolP;
-{
- char underscore = 0; /* Symbol has leading _ */
-
- /* Effective symbol */
- /* Store the pointer in the offset. */
- S_SET_ZEROES(symbolP, 0L);
- S_SET_DATA_TYPE(symbolP, T_NULL);
- S_SET_STORAGE_CLASS(symbolP, 0);
- S_SET_NUMBER_AUXILIARY(symbolP, 0);
- /* Additional information */
- symbolP->sy_symbol.ost_flags = 0;
- /* Auxiliary entries */
- memset((char*) &symbolP->sy_symbol.ost_auxent[0], '\0', AUXESZ);
-
-#ifdef STRIP_UNDERSCORE
- /* Remove leading underscore at the beginning of the symbol.
- * This is to be compatible with the standard librairies.
- */
- if (*S_GET_NAME(symbolP) == '_') {
- underscore = 1;
- S_SET_NAME(symbolP, S_GET_NAME(symbolP) + 1);
- } /* strip underscore */
-#endif /* STRIP_UNDERSCORE */
-
- if (S_IS_STRING(symbolP))
- SF_SET_STRING(symbolP);
- if (!underscore && S_IS_LOCAL(symbolP))
- SF_SET_LOCAL(symbolP);
-
- return;
-} /* obj_symbol_new_hook() */
-
-/* stack stuff */
-stack* stack_init(chunk_size, element_size)
-unsigned long chunk_size;
-unsigned long element_size;
-{
- stack* st;
-
- if ((st = (stack*)malloc(sizeof(stack))) == (stack*)0)
- return (stack*)0;
- if ((st->data = malloc(chunk_size)) == (char*)0) {
- free(st);
- return (stack*)0;
- }
- st->pointer = 0;
- st->size = chunk_size;
- st->chunk_size = chunk_size;
- st->element_size = element_size;
- return st;
-} /* stack_init() */
-
-void stack_delete(st)
-stack* st;
-{
- free(st->data);
- free(st);
-}
-
-char *stack_push(st, element)
-stack *st;
-char *element;
-{
- if (st->pointer + st->element_size >= st->size) {
- st->size += st->chunk_size;
- if ((st->data = xrealloc(st->data, st->size)) == (char*)0)
- return (char*)0;
- }
- memcpy(st->data + st->pointer, element, st->element_size);
- st->pointer += st->element_size;
- return st->data + st->pointer;
-} /* stack_push() */
-
-char* stack_pop(st)
-stack* st;
-{
- if ((st->pointer -= st->element_size) < 0) {
- st->pointer = 0;
- return (char*)0;
- }
-
- return st->data + st->pointer;
-}
-
-char* stack_top(st)
-stack* st;
-{
- return st->data + st->pointer - st->element_size;
-}
-
-
-/*
- * Handle .ln directives.
- */
-
-static void obj_coff_ln()
-{
- int l;
-
- if (def_symbol_in_progress != NULL) {
- as_warn(".ln pseudo-op inside .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
- } /* wrong context */
-
- c_line_new(0,
- obstack_next_free(&frags) - frag_now->fr_literal,
- l = get_absolute_expression(),
- frag_now);
-#ifndef NO_LISTING
- {
- extern int listing;
-
- if (listing)
- {
- listing_source_line(l + line_base - 1);
- }
-
- }
-#endif
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_line() */
-
-/*
- * def()
- *
- * Handle .def directives.
- *
- * One might ask : why can't we symbol_new if the symbol does not
- * already exist and fill it with debug information. Because of
- * the C_EFCN special symbol. It would clobber the value of the
- * function symbol before we have a chance to notice that it is
- * a C_EFCN. And a second reason is that the code is more clear this
- * way. (at least I think it is :-).
- *
- */
-
-#define SKIP_SEMI_COLON() while (*input_line_pointer++ != ';')
-#define SKIP_WHITESPACES() while (*input_line_pointer == ' ' || \
- *input_line_pointer == '\t') \
- input_line_pointer++;
-
-static void
- DEFUN(obj_coff_def,(what),
- int what)
-{
- char name_end; /* Char after the end of name */
- char *symbol_name; /* Name of the debug symbol */
- char *symbol_name_copy; /* Temporary copy of the name */
- unsigned int symbol_name_length;
- /*$char* directiveP;$ */ /* Name of the pseudo opcode */
- /*$char directive[MAX_DIRECTIVE];$ */ /* Backup of the directive */
- /*$char end = 0;$ */ /* If 1, stop parsing */
-
- if (def_symbol_in_progress != NULL) {
- as_warn(".def pseudo-op used inside of .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- SKIP_WHITESPACES();
-
- def_symbol_in_progress = (symbolS *) obstack_alloc(&notes, sizeof(*def_symbol_in_progress));
- memset(def_symbol_in_progress, '\0', sizeof(*def_symbol_in_progress));
-
- symbol_name = input_line_pointer;
- name_end = get_symbol_end();
- symbol_name_length = strlen(symbol_name);
- symbol_name_copy = xmalloc(symbol_name_length + 1);
- strcpy(symbol_name_copy, symbol_name);
-
- /* Initialize the new symbol */
-#ifdef STRIP_UNDERSCORE
- S_SET_NAME(def_symbol_in_progress, (*symbol_name_copy == '_'
- ? symbol_name_copy + 1
- : symbol_name_copy));
-#else /* STRIP_UNDERSCORE */
- S_SET_NAME(def_symbol_in_progress, symbol_name_copy);
-#endif /* STRIP_UNDERSCORE */
- /* free(symbol_name_copy); */
- def_symbol_in_progress->sy_name_offset = ~0;
- def_symbol_in_progress->sy_number = ~0;
- def_symbol_in_progress->sy_frag = &zero_address_frag;
-
- if (S_IS_STRING(def_symbol_in_progress)) {
- SF_SET_STRING(def_symbol_in_progress);
- } /* "long" name */
-
- *input_line_pointer = name_end;
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_def() */
-
-unsigned int dim_index;
-static void
- DEFUN_VOID(obj_coff_endef)
-{
- symbolS *symbolP = 0;
- /* DIM BUG FIX sac@cygnus.com */
- dim_index =0;
- if (def_symbol_in_progress == NULL) {
- as_warn(".endef pseudo-op used outside of .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- /* Set the section number according to storage class. */
- switch (S_GET_STORAGE_CLASS(def_symbol_in_progress)) {
- case C_STRTAG:
- case C_ENTAG:
- case C_UNTAG:
- SF_SET_TAG(def_symbol_in_progress);
- /* intentional fallthrough */
- case C_FILE:
- case C_TPDEF:
- SF_SET_DEBUG(def_symbol_in_progress);
- S_SET_SEGMENT(def_symbol_in_progress, SEG_DEBUG);
- break;
-
- case C_EFCN:
- SF_SET_LOCAL(def_symbol_in_progress); /* Do not emit this symbol. */
- /* intentional fallthrough */
- case C_BLOCK:
- SF_SET_PROCESS(def_symbol_in_progress); /* Will need processing before writing */
- /* intentional fallthrough */
- case C_FCN:
- S_SET_SEGMENT(def_symbol_in_progress, SEG_E0);
-
- if (def_symbol_in_progress->sy_symbol.ost_entry.n_name[1] == 'b') { /* .bf */
- if (function_lineoff < 0) {
- fprintf(stderr, "`.bf' symbol without preceding function\n");
- } /* missing function symbol */
- SA_GET_SYM_LNNOPTR(def_symbol_in_progress) = function_lineoff;
- SF_SET_PROCESS(def_symbol_in_progress); /* Will need relocating */
- function_lineoff = -1;
- }
- break;
-
-#ifdef C_AUTOARG
- case C_AUTOARG:
-#endif /* C_AUTOARG */
- case C_AUTO:
- case C_REG:
- case C_MOS:
- case C_MOE:
- case C_MOU:
- case C_ARG:
- case C_REGPARM:
- case C_FIELD:
- case C_EOS:
- SF_SET_DEBUG(def_symbol_in_progress);
- S_SET_SEGMENT(def_symbol_in_progress, SEG_ABSOLUTE);
- break;
-
- case C_EXT:
- case C_STAT:
- case C_LABEL:
- /* Valid but set somewhere else (s_comm, s_lcomm, colon) */
- break;
-
- case C_USTATIC:
- case C_EXTDEF:
- case C_ULABEL:
- as_warn("unexpected storage class %d", S_GET_STORAGE_CLASS(def_symbol_in_progress));
- break;
- } /* switch on storage class */
-
- /* Now that we have built a debug symbol, try to
- find if we should merge with an existing symbol
- or not. If a symbol is C_EFCN or SEG_ABSOLUTE or
- untagged SEG_DEBUG it never merges. */
-
- /* Two cases for functions. Either debug followed
- by definition or definition followed by debug.
- For definition first, we will merge the debug
- symbol into the definition. For debug first, the
- lineno entry MUST point to the definition
- function or else it will point off into space
- when crawl_symbols() merges the debug
- symbol into the real symbol. Therefor, let's
- presume the debug symbol is a real function
- reference. */
-
- /* FIXME-SOON If for some reason the definition
- label/symbol is never seen, this will probably
- leave an undefined symbol at link time. */
-
- if (S_GET_STORAGE_CLASS(def_symbol_in_progress) == C_EFCN
- || (S_GET_SEGMENT(def_symbol_in_progress) == SEG_DEBUG
- && !SF_GET_TAG(def_symbol_in_progress))
- || S_GET_SEGMENT(def_symbol_in_progress) == SEG_ABSOLUTE
- || (symbolP = symbol_find_base(S_GET_NAME(def_symbol_in_progress), DO_NOT_STRIP)) == NULL) {
-
- symbol_append(def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP);
-
- } else {
- /* This symbol already exists, merge the
- newly created symbol into the old one.
- This is not mandatory. The linker can
- handle duplicate symbols correctly. But I
- guess that it save a *lot* of space if
- the assembly file defines a lot of
- symbols. [loic] */
-
- /* The debug entry (def_symbol_in_progress)
- is merged into the previous definition. */
-
- c_symbol_merge(def_symbol_in_progress, symbolP);
- /* FIXME-SOON Should *def_symbol_in_progress be free'd? xoxorich. */
- def_symbol_in_progress = symbolP;
-
- if (SF_GET_FUNCTION(def_symbol_in_progress)
- || SF_GET_TAG(def_symbol_in_progress)) {
- /* For functions, and tags, the symbol *must* be where the debug symbol
- appears. Move the existing symbol to the current place. */
- /* If it already is at the end of the symbol list, do nothing */
- if (def_symbol_in_progress != symbol_lastP) {
- symbol_remove(def_symbol_in_progress, &symbol_rootP, &symbol_lastP);
- symbol_append(def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP);
- } /* if not already in place */
- } /* if function */
- } /* normal or mergable */
-
- if (SF_GET_TAG(def_symbol_in_progress)
- && symbol_find_base(S_GET_NAME(def_symbol_in_progress), DO_NOT_STRIP) == NULL) {
- tag_insert(S_GET_NAME(def_symbol_in_progress), def_symbol_in_progress);
- } /* If symbol is a {structure,union} tag, associate symbol to its name. */
-
- if (SF_GET_FUNCTION(def_symbol_in_progress)) {
- know(sizeof(def_symbol_in_progress) <= sizeof(long));
- function_lineoff
- = c_line_new(def_symbol_in_progress,0, 0, &zero_address_frag);
-
-
-
- SF_SET_PROCESS(def_symbol_in_progress);
-
- if (symbolP == NULL) {
- /* That is, if this is the first
- time we've seen the function... */
- symbol_table_insert(def_symbol_in_progress);
- } /* definition follows debug */
- } /* Create the line number entry pointing to the function being defined */
-
- def_symbol_in_progress = NULL;
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_endef() */
-
-static void
- DEFUN_VOID(obj_coff_dim)
-{
- register int dim_index;
-
- if (def_symbol_in_progress == NULL)
- {
- as_warn(".dim pseudo-op used outside of .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
-
- for (dim_index = 0; dim_index < DIMNUM; dim_index++)
- {
- SKIP_WHITESPACES();
- SA_SET_SYM_DIMEN(def_symbol_in_progress, dim_index, get_absolute_expression());
-
- switch (*input_line_pointer)
- {
-
- case ',':
- input_line_pointer++;
- break;
-
- default:
- as_warn("badly formed .dim directive ignored");
- /* intentional fallthrough */
- case '\n':
- case ';':
- dim_index = DIMNUM;
- break;
- } /* switch on following character */
- } /* for each dimension */
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_dim() */
-
-static void obj_coff_line()
-{
- int this_base;
-
- if (def_symbol_in_progress == NULL) {
- obj_coff_ln();
- return;
- } /* if it looks like a stabs style line */
-
- this_base = get_absolute_expression();
- if (this_base > line_base)
- {
- line_base = this_base;
- }
-
-
-#ifndef NO_LISTING
- {
- extern int listing;
- if (listing && 0) {
- listing_source_line(line_base);
- }
- }
-#endif
- S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
- SA_SET_SYM_LNNO(def_symbol_in_progress, line_base);
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_line() */
-
-static void obj_coff_size() {
- if (def_symbol_in_progress == NULL) {
- as_warn(".size pseudo-op used outside of .def/.endef ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
- SA_SET_SYM_SIZE(def_symbol_in_progress, get_absolute_expression());
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_size() */
-
-static void obj_coff_scl() {
- if (def_symbol_in_progress == NULL) {
- as_warn(".scl pseudo-op used outside of .def/.endef ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_STORAGE_CLASS(def_symbol_in_progress, get_absolute_expression());
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_scl() */
-
-static void obj_coff_tag() {
- char *symbol_name;
- char name_end;
-
- if (def_symbol_in_progress == NULL) {
- as_warn(".tag pseudo-op used outside of .def/.endef ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
- symbol_name = input_line_pointer;
- name_end = get_symbol_end();
-
- /* Assume that the symbol referred to by .tag is always defined. */
- /* This was a bad assumption. I've added find_or_make. xoxorich. */
- SA_SET_SYM_TAGNDX(def_symbol_in_progress, (long) tag_find_or_make(symbol_name));
- if (SA_GET_SYM_TAGNDX(def_symbol_in_progress) == 0L) {
- as_warn("tag not found for .tag %s", symbol_name);
- } /* not defined */
-
- SF_SET_TAGGED(def_symbol_in_progress);
- *input_line_pointer = name_end;
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_tag() */
-
-static void obj_coff_type() {
- if (def_symbol_in_progress == NULL) {
- as_warn(".type pseudo-op used outside of .def/.endef ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_DATA_TYPE(def_symbol_in_progress, get_absolute_expression());
-
- if (ISFCN(S_GET_DATA_TYPE(def_symbol_in_progress)) &&
- S_GET_STORAGE_CLASS(def_symbol_in_progress) != C_TPDEF) {
- SF_SET_FUNCTION(def_symbol_in_progress);
- } /* is a function */
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_type() */
-
-static void obj_coff_val() {
- if (def_symbol_in_progress == NULL) {
- as_warn(".val pseudo-op used outside of .def/.endef ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- if (is_name_beginner(*input_line_pointer)) {
- char *symbol_name = input_line_pointer;
- char name_end = get_symbol_end();
-
- if (!strcmp(symbol_name, ".")) {
- def_symbol_in_progress->sy_frag = frag_now;
- S_SET_VALUE(def_symbol_in_progress, obstack_next_free(&frags) - frag_now->fr_literal);
- /* If the .val is != from the .def (e.g. statics) */
- } else if (strcmp(S_GET_NAME(def_symbol_in_progress), symbol_name)) {
- def_symbol_in_progress->sy_forward = symbol_find_or_make(symbol_name);
-
- /* If the segment is undefined when the forward
- reference is solved, then copy the segment id
- from the forward symbol. */
- SF_SET_GET_SEGMENT(def_symbol_in_progress);
- }
- /* Otherwise, it is the name of a non debug symbol and its value will be calculated later. */
- *input_line_pointer = name_end;
- } else {
- S_SET_VALUE(def_symbol_in_progress, get_absolute_expression());
- } /* if symbol based */
-
- demand_empty_rest_of_line();
- return;
-} /* obj_coff_val() */
-
-/*
- * Maintain a list of the tagnames of the structres.
- */
-
-static void tag_init() {
- tag_hash = hash_new();
- return ;
-} /* tag_init() */
-
-static void tag_insert(name, symbolP)
-char *name;
-symbolS *symbolP;
-{
- register char * error_string;
-
- if (*(error_string = hash_jam(tag_hash, name, (char *)symbolP))) {
- as_fatal("Inserting \"%s\" into structure table failed: %s",
- name, error_string);
- }
- return ;
-} /* tag_insert() */
-
-static symbolS *tag_find_or_make(name)
-char *name;
-{
- symbolS *symbolP;
-
- if ((symbolP = tag_find(name)) == NULL) {
- symbolP = symbol_new(name,
- SEG_UNKNOWN,
- 0,
- &zero_address_frag);
-
- tag_insert(S_GET_NAME(symbolP), symbolP);
- symbol_table_insert(symbolP);
- } /* not found */
-
- return(symbolP);
-} /* tag_find_or_make() */
-
-static symbolS *tag_find(name)
-char *name;
-{
-#ifdef STRIP_UNDERSCORE
- if (*name == '_') name++;
-#endif /* STRIP_UNDERSCORE */
- return((symbolS*)hash_find(tag_hash, name));
-} /* tag_find() */
-
-void obj_read_begin_hook() {
- /* These had better be the same. Usually 18 bytes. */
-#ifndef BFD_HEADERS
- know(sizeof(SYMENT) == sizeof(AUXENT));
- know(SYMESZ == AUXESZ);
-#endif
- tag_init();
-
- return;
-} /* obj_read_begin_hook() */
-
-/* This function runs through the symbol table and puts all the
- externals onto another chain */
-
-/* The chain of externals */
-symbolS *symbol_externP = NULL;
-symbolS *symbol_extern_lastP = NULL;
-
-stack*block_stack;
-symbolS *last_functionP = NULL;
-symbolS *last_tagP;
-
-
-static unsigned int DEFUN_VOID(yank_symbols)
-{
- symbolS *symbolP;
- unsigned int symbol_number =0;
-
- for (symbolP = symbol_rootP;
- symbolP;
- symbolP = symbolP ? symbol_next(symbolP) : symbol_rootP) {
- if (!SF_GET_DEBUG(symbolP)) {
- /* Debug symbols do not need all this rubbish */
- symbolS* real_symbolP;
-
- /* L* and C_EFCN symbols never merge. */
- if (!SF_GET_LOCAL(symbolP)
- && (real_symbolP = symbol_find_base(S_GET_NAME(symbolP), DO_NOT_STRIP))
- && real_symbolP != symbolP) {
- /* FIXME-SOON: where do dups come from?
- Maybe tag references before definitions? xoxorich. */
- /* Move the debug data from the debug symbol to the
- real symbol. Do NOT do the oposite (i.e. move from
- real symbol to debug symbol and remove real symbol from the
- list.) Because some pointers refer to the real symbol
- whereas no pointers refer to the debug symbol. */
- c_symbol_merge(symbolP, real_symbolP);
- /* Replace the current symbol by the real one */
- /* The symbols will never be the last or the first
- because : 1st symbol is .file and 3 last symbols are
- .text, .data, .bss */
- symbol_remove(real_symbolP, &symbol_rootP, &symbol_lastP);
- symbol_insert(real_symbolP, symbolP, &symbol_rootP, &symbol_lastP);
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
- symbolP = real_symbolP;
- } /* if not local but dup'd */
-
- if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_E1)) {
- S_SET_SEGMENT(symbolP, SEG_E0);
- } /* push data into text */
-
- S_SET_VALUE(symbolP,
- S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address);
-
- if (!S_IS_DEFINED(symbolP) && !SF_GET_LOCAL(symbolP))
- {
- S_SET_EXTERNAL(symbolP);
- }
- else if (S_GET_STORAGE_CLASS(symbolP) == C_NULL)
- {
- if (S_GET_SEGMENT(symbolP) == SEG_E0)
- {
- S_SET_STORAGE_CLASS(symbolP, C_LABEL);
- }
- else
- {
- S_SET_STORAGE_CLASS(symbolP, C_STAT);
- }
- }
-
- /* Mainly to speed up if not -g */
- if (SF_GET_PROCESS(symbolP))
- {
- /* Handle the nested blocks auxiliary info. */
- if (S_GET_STORAGE_CLASS(symbolP) == C_BLOCK) {
- if (!strcmp(S_GET_NAME(symbolP), ".bb"))
- stack_push(block_stack, (char *) &symbolP);
- else { /* .eb */
- register symbolS* begin_symbolP;
- begin_symbolP = *(symbolS**)stack_pop(block_stack);
- if (begin_symbolP == (symbolS*)0)
- as_warn("mismatched .eb");
- else
- SA_SET_SYM_ENDNDX(begin_symbolP, symbol_number+2);
- }
- }
- /* If we are able to identify the type of a function, and we
- are out of a function (last_functionP == 0) then, the
- function symbol will be associated with an auxiliary
- entry. */
- if (last_functionP == (symbolS*)0 &&
- SF_GET_FUNCTION(symbolP)) {
- last_functionP = symbolP;
-
- if (S_GET_NUMBER_AUXILIARY(symbolP) < 1) {
- S_SET_NUMBER_AUXILIARY(symbolP, 1);
- } /* make it at least 1 */
-
- /* Clobber possible stale .dim information. */
- memset(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen,
- '\0', sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen));
- }
- /* The C_FCN doesn't need any additional information.
- I don't even know if this is needed for sdb. But the
- standard assembler generates it, so...
- */
- if (S_GET_STORAGE_CLASS(symbolP) == C_EFCN) {
- if (last_functionP == (symbolS*)0)
- as_fatal("C_EFCN symbol out of scope");
- SA_SET_SYM_FSIZE(last_functionP,
- (long)(S_GET_VALUE(symbolP) -
- S_GET_VALUE(last_functionP)));
- SA_SET_SYM_ENDNDX(last_functionP, symbol_number);
- last_functionP = (symbolS*)0;
- }
- }
- } else if (SF_GET_TAG(symbolP)) {
- /* First descriptor of a structure must point to
- the first slot after the structure description. */
- last_tagP = symbolP;
-
- } else if (S_GET_STORAGE_CLASS(symbolP) == C_EOS) {
- /* +2 take in account the current symbol */
- SA_SET_SYM_ENDNDX(last_tagP, symbol_number + 2);
- } else if (S_GET_STORAGE_CLASS(symbolP) == C_FILE) {
- if (S_GET_VALUE(symbolP)) {
- S_SET_VALUE((symbolS *) S_GET_VALUE(symbolP), symbol_number);
- S_SET_VALUE(symbolP, 0);
- } /* no one points at the first .file symbol */
- } /* if debug or tag or eos or file */
-
- /* We must put the external symbols apart. The loader
- does not bomb if we do not. But the references in
- the endndx field for a .bb symbol are not corrected
- if an external symbol is removed between .bb and .be.
- I.e in the following case :
- [20] .bb endndx = 22
- [21] foo external
- [22] .be
- ld will move the symbol 21 to the end of the list but
- endndx will still be 22 instead of 21. */
-
-
- if (SF_GET_LOCAL(symbolP)) {
- /* remove C_EFCN and LOCAL (L...) symbols */
- /* next pointer remains valid */
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
-
- }
- else if (!S_IS_DEFINED(symbolP)
- && !S_IS_DEBUG(symbolP)
- && !SF_GET_STATICS(symbolP) &&
- S_GET_STORAGE_CLASS(symbolP) == C_EXT)
- { /* C_EXT && !SF_GET_FUNCTION(symbolP)) */
- /* if external, Remove from the list */
- symbolS *hold = symbol_previous(symbolP);
-
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
- symbol_clear_list_pointers(symbolP);
- symbol_append(symbolP, symbol_extern_lastP, &symbol_externP, &symbol_extern_lastP);
- symbolP = hold;
- } else {
- if (SF_GET_STRING(symbolP)) {
- symbolP->sy_name_offset = string_byte_count;
- string_byte_count += strlen(S_GET_NAME(symbolP)) + 1;
- } else {
- symbolP->sy_name_offset = 0;
- } /* fix "long" names */
-
- symbolP->sy_number = symbol_number;
- symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP);
- } /* if local symbol */
- } /* traverse the symbol list */
- return symbol_number;
-
-}
-
-
-static unsigned int DEFUN_VOID(glue_symbols)
-{
- unsigned int symbol_number = 0;
- symbolS *symbolP;
- for (symbolP = symbol_externP; symbol_externP;) {
- symbolS *tmp = symbol_externP;
-
- /* append */
- symbol_remove(tmp, &symbol_externP, &symbol_extern_lastP);
- symbol_append(tmp, symbol_lastP, &symbol_rootP, &symbol_lastP);
-
- /* and process */
- if (SF_GET_STRING(tmp)) {
- tmp->sy_name_offset = string_byte_count;
- string_byte_count += strlen(S_GET_NAME(tmp)) + 1;
- } else {
- tmp->sy_name_offset = 0;
- } /* fix "long" names */
-
- tmp->sy_number = symbol_number;
- symbol_number += 1 + S_GET_NUMBER_AUXILIARY(tmp);
- } /* append the entire extern chain */
- return symbol_number;
-
-}
-
-static unsigned int DEFUN_VOID(tie_tags)
-{
- unsigned int symbol_number = 0;
-
- symbolS*symbolP;
- for (symbolP = symbol_rootP; symbolP; symbolP =
- symbol_next(symbolP))
- {
- symbolP->sy_number = symbol_number;
-
-
-
- if (SF_GET_TAGGED(symbolP))
- {
- SA_SET_SYM_TAGNDX
- (symbolP,
- ((symbolS*) SA_GET_SYM_TAGNDX(symbolP))->sy_number);
- }
-
- symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP);
- }
- return symbol_number;
-
-}
-
-static void
- DEFUN(crawl_symbols,(headers, abfd),
- struct internal_filehdr *headers AND
- bfd *abfd)
-{
-
- unsigned int i;
- unsigned int ptr = 0;
-
-
- symbolS *symbolP;
-
- /* Initialize the stack used to keep track of the matching .bb .be */
-
- block_stack = stack_init(512, sizeof(symbolS*));
- /* JF deal with forward references first... */
- for (symbolP = symbol_rootP;
- symbolP;
- symbolP = symbol_next(symbolP))
- {
-
- if (symbolP->sy_forward) {
- S_SET_VALUE(symbolP, (S_GET_VALUE(symbolP)
- + S_GET_VALUE(symbolP->sy_forward)
- + symbolP->sy_forward->sy_frag->fr_address));
-
- if (SF_GET_GET_SEGMENT(symbolP)) {
- S_SET_SEGMENT(symbolP, S_GET_SEGMENT(symbolP->sy_forward));
- } /* forward segment also */
-
- symbolP->sy_forward=0;
- } /* if it has a forward reference */
- } /* walk the symbol chain */
-
-
- /* The symbol list should be ordered according to the following sequence
- * order :
- * . .file symbol
- * . debug entries for functions
- * . fake symbols for the sections, including.text .data and .bss
- * . defined symbols
- * . undefined symbols
- * But this is not mandatory. The only important point is to put the
- * undefined symbols at the end of the list.
- */
-
- if (symbol_rootP == NULL
- || S_GET_STORAGE_CLASS(symbol_rootP) != C_FILE) {
- c_dot_file_symbol("fake");
- }
- /* Is there a .file symbol ? If not insert one at the beginning. */
-
- /*
- * Build up static symbols for the sections, they are filled in later
- */
-
-
- for (i = SEG_E0; i < SEG_E9; i++)
- {
- if (segment_info[i].scnhdr.s_name[0])
- {
- segment_info[i].dot =
- c_section_symbol(segment_info[i].scnhdr.s_name,
- i-SEG_E0+1);
-
- }
- }
-
-
- /* Take all the externals out and put them into another chain */
- headers->f_nsyms = yank_symbols();
- /* Take the externals and glue them onto the end.*/
- headers->f_nsyms += glue_symbols();
-
- headers->f_nsyms = tie_tags();
- know(symbol_externP == NULL);
- know(symbol_extern_lastP == NULL);
-
- return;
-}
-
-/*
- * Find strings by crawling along symbol table chain.
- */
-
-void DEFUN(w_strings,(where),
- char *where)
-{
- symbolS *symbolP;
-
- /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
- md_number_to_chars(where, string_byte_count, sizeof(string_byte_count));
- where += sizeof(string_byte_count);
- for (symbolP = symbol_rootP;
- symbolP;
- symbolP = symbol_next(symbolP))
- {
- unsigned int size;
-
- if (SF_GET_STRING(symbolP)) {
- size = strlen(S_GET_NAME(symbolP)) + 1;
-
- memcpy(where, S_GET_NAME(symbolP),size);
- where += size;
-
- }
- }
-
-}
-
-
-
-
-
-static void
- DEFUN(do_linenos_for,(abfd, file_cursor),
- bfd *abfd AND
- unsigned long *file_cursor)
-{
- unsigned int idx;
-
- for (idx = SEG_E0; idx < SEG_E9; idx++)
- {
- segment_info_type *s = segment_info + idx;
-
-
- if (s->scnhdr.s_nlnno != 0)
- {
- struct lineno_list *line_ptr ;
-
- struct external_lineno *buffer =
- (struct external_lineno *)xmalloc(s->scnhdr.s_nlnno * LINESZ);
-
- struct external_lineno *dst= buffer;
-
- /* Run through the table we've built and turn it into its external
- form, take this chance to remove duplicates */
-
- for (line_ptr = s->lineno_list_head;
- line_ptr != (struct lineno_list *)NULL;
- line_ptr = line_ptr->next)
- {
-
- if (line_ptr->line.l_lnno == 0)
- {
- /* Turn a pointer to a symbol into the symbols' index */
- line_ptr->line.l_addr.l_symndx =
- ( (symbolS *)line_ptr->line.l_addr.l_symndx)->sy_number;
- }
- else
- {
- line_ptr->line.l_addr.l_paddr += ((struct frag * )(line_ptr->frag))->fr_address;
- }
-
-
- (void) bfd_coff_swap_lineno_out(abfd, &(line_ptr->line), dst);
- dst++;
-
- }
-
- s->scnhdr.s_lnnoptr = *file_cursor;
-
- bfd_write(buffer, 1, s->scnhdr.s_nlnno* LINESZ, abfd);
- free(buffer);
-
- *file_cursor += s->scnhdr.s_nlnno * LINESZ;
- }
- }
-}
-
-
-/* Now we run through the list of frag chains in a segment and
- make all the subsegment frags appear at the end of the
- list, as if the seg 0 was extra long */
-
-static void DEFUN_VOID(remove_subsegs)
-{
- unsigned int i;
-
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
- frchainS *head = segment_info[i].frchainP;
- fragS dummy;
- fragS * prev_frag = &dummy;
-
- while (head && head->frch_seg == i)
- {
- prev_frag->fr_next = head->frch_root;
- prev_frag = head->frch_last;
- head = head->frch_next;
- }
- prev_frag->fr_next = 0;
- }
-}
-
-
-extern void DEFUN_VOID(write_object_file)
-{
- int i;
- struct frchain *frchain_ptr;
-
- struct internal_filehdr filehdr;
- struct internal_aouthdr aouthdr;
- unsigned long file_cursor;
- bfd *abfd;
- unsigned int addr = 0;
- abfd = bfd_openw(out_file_name, TARGET_FORMAT);
-
-
- if (abfd == 0) {
- as_perror ("FATAL: Can't create %s", out_file_name);
- exit(42);
- }
- bfd_set_format(abfd, bfd_object);
- bfd_set_arch_mach(abfd, BFD_ARCH, 0);
-
-
-
- string_byte_count = 4;
-
- for (frchain_ptr = frchain_root;
- frchain_ptr != (struct frchain *)NULL;
- frchain_ptr = frchain_ptr->frch_next) {
- /* Run through all the sub-segments and align them up. Also close any
- open frags. We tack a .fill onto the end of the frag chain so
- that any .align's size can be worked by looking at the next
- frag */
-
- subseg_new(frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
-#define SUB_SEGMENT_ALIGN 1
- frag_align(SUB_SEGMENT_ALIGN,0);
- frag_wane(frag_now);
- frag_now->fr_fix = 0;
- know( frag_now->fr_next == NULL );
- }
-
-
- remove_subsegs();
-
-
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
- relax_segment(segment_info[i].frchainP->frch_root, i);
- }
-
-
-
-
-
- filehdr.f_nscns = 0;
-
- /* Find out how big the sections are */
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
-
- if (segment_info[i].scnhdr.s_name[0])
- {
- filehdr.f_nscns++;
- }
- segment_info[i].scnhdr.s_paddr = addr;
- if (i == SEG_E2) {
- /* THis is a special case, we leave the size alone, which will have */
- /* been made up from all and any lcomms seen */
- }
- else {
- addr += size_section(abfd, i);
- }
- }
-
-
-
- /* Turn the gas native symbol table shape into a coff symbol table */
- crawl_symbols(&filehdr, abfd);
-#ifndef TC_H8300
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
- fixup_segment(segment_info[i].fix_root, i);
- }
-#endif
-
- file_cursor = FILHSZ + SCNHSZ * filehdr.f_nscns ;
-
- bfd_seek(abfd, file_cursor, 0);
-
-
- do_relocs_for(abfd, &file_cursor);
-
- do_linenos_for(abfd, &file_cursor);
-
-
- /* Plant the data */
-
- fill_section(abfd,&filehdr, &file_cursor);
-
- filehdr.f_magic = COFF_MAGIC;
- filehdr.f_timdat = 0;
- filehdr.f_flags = 0;
-
-
-
- {
-
- unsigned int symtable_size = filehdr.f_nsyms * SYMESZ;
- char *buffer1 = malloc(symtable_size + string_byte_count + 4);
- char *ptr = buffer1;
- filehdr.f_symptr = bfd_tell(abfd);
- w_symbols(abfd, buffer1, symbol_rootP);
- w_strings(buffer1 + symtable_size);
- bfd_write(buffer1, 1,symtable_size + string_byte_count + 4, abfd);
- free(buffer1);
-
- }
- coff_header_append(abfd, &filehdr, &aouthdr);
-
- bfd_close_all_done(abfd);
-}
-
-
-static void DEFUN(change_to_section,(name, len, exp),
- char *name AND
- unsigned int len AND
- unsigned int exp)
-{
- unsigned int i;
- /* Find out if we've already got a section of this name etc */
- for (i = SEG_E0; i < SEG_E9 && segment_info[i].scnhdr.s_name[0] ; i++)
- {
- if (strncmp(segment_info[i].scnhdr.s_name, name, len) == 0)
- {
- subseg_new(i, exp);
- return;
-
- }
- }
- /* No section, add one */
- strncpy(segment_info[i].scnhdr.s_name, name, 8);
- subseg_new(i, exp);
-}
-
-static void
- DEFUN_VOID(obj_coff_section)
-{
- /* Strip out the section name */
- char *section_name ;
- char *section_name_end;
- char c;
-
- unsigned int len;
- unsigned int exp;
-
- section_name = input_line_pointer;
- c = get_symbol_end();
- section_name_end = input_line_pointer;
-
- len = section_name_end - section_name ;
- input_line_pointer++;
- SKIP_WHITESPACE();
- if (c == ',')
- {
- exp = get_absolute_expression();
- }
- else if ( *input_line_pointer == ',')
- {
-
- input_line_pointer++;
- exp = get_absolute_expression();
- }
- else
- {
- exp = 0;
- }
-
- change_to_section(section_name, len,exp);
- *section_name_end = c;
-
-}
-
-
-static void obj_coff_text()
-{
- change_to_section(".text",5, get_absolute_expression());
-}
-
-
-static void obj_coff_data()
-{
- change_to_section(".data",5, get_absolute_expression());
-}
-
-void c_symbol_merge(debug, normal)
-symbolS *debug;
-symbolS *normal;
-{
- S_SET_DATA_TYPE(normal, S_GET_DATA_TYPE(debug));
- S_SET_STORAGE_CLASS(normal, S_GET_STORAGE_CLASS(debug));
-
- if (S_GET_NUMBER_AUXILIARY(debug) > S_GET_NUMBER_AUXILIARY(normal)) {
- S_SET_NUMBER_AUXILIARY(normal, S_GET_NUMBER_AUXILIARY(debug));
- } /* take the most we have */
-
- if (S_GET_NUMBER_AUXILIARY(debug) > 0) {
- memcpy((char*)&normal->sy_symbol.ost_auxent[0], (char*)&debug->sy_symbol.ost_auxent[0], S_GET_NUMBER_AUXILIARY(debug) * AUXESZ);
- } /* Move all the auxiliary information */
-
- /* Move the debug flags. */
- SF_SET_DEBUG_FIELD(normal, SF_GET_DEBUG_FIELD(debug));
-} /* c_symbol_merge() */
-
-static int
- DEFUN(c_line_new,(symbol, paddr, line_number, frag),
- symbolS *symbol AND
- long paddr AND
- unsigned short line_number AND
- fragS* frag)
-{
- struct lineno_list* new_line =
- (struct lineno_list *)xmalloc(sizeof(struct lineno_list));
-
- segment_info_type *s = segment_info + now_seg;
- new_line->line.l_lnno = line_number;
-
- if (line_number == 0)
- {
- new_line->line.l_addr.l_symndx = (long)symbol;
- }
- else
- {
- new_line->line.l_addr.l_paddr = paddr;
- }
-
- new_line->frag = (char*)frag;
- new_line->next = (struct lineno_list*)NULL;
-
-
- if (s->lineno_list_head == (struct lineno_list *)NULL)
- {
- s->lineno_list_head = new_line;
- }
- else
- {
- s->lineno_list_tail->next = new_line;
- }
- s->lineno_list_tail = new_line;
- return LINESZ * s->scnhdr.s_nlnno ++;
-}
-
-void c_dot_file_symbol(filename)
-char *filename;
-{
- symbolS* symbolP;
-
- symbolP = symbol_new(".file",
- SEG_DEBUG,
- 0,
- &zero_address_frag);
-
- S_SET_STORAGE_CLASS(symbolP, C_FILE);
- S_SET_NUMBER_AUXILIARY(symbolP, 1);
- SA_SET_FILE_FNAME(symbolP, filename);
-#ifndef NO_LISTING
- {
- extern int listing;
- if (listing)
- {
- listing_source_file(filename);
- }
-
- }
-
-#endif
- SF_SET_DEBUG(symbolP);
- S_SET_VALUE(symbolP, (long) previous_file_symbol);
-
- previous_file_symbol = symbolP;
-
- /* Make sure that the symbol is first on the symbol chain */
- if (symbol_rootP != symbolP) {
- if (symbolP == symbol_lastP) {
- symbol_lastP = symbol_lastP->sy_previous;
- } /* if it was the last thing on the list */
-
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
- symbol_insert(symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP);
- symbol_rootP = symbolP;
- } /* if not first on the list */
-
-} /* c_dot_file_symbol() */
-
-/*
- * Build a 'section static' symbol.
- */
-
-symbolS *c_section_symbol(name,idx)
-char *name;
-int idx;
-{
- symbolS *symbolP;
-
- symbolP = symbol_new(name,idx,
- 0,
- &zero_address_frag);
-
- S_SET_STORAGE_CLASS(symbolP, C_STAT);
- S_SET_NUMBER_AUXILIARY(symbolP, 1);
-
- SF_SET_STATICS(symbolP);
-
- return symbolP;
-} /* c_section_symbol() */
-
-static void
- DEFUN(w_symbols,(abfd, where, symbol_rootP),
- bfd *abfd AND
- char *where AND
- symbolS *symbol_rootP)
-{
- symbolS *symbolP;
- unsigned int i;
-
- /* First fill in those values we have only just worked out */
- for (i = SEG_E0; i < SEG_E9; i++)
- {
- symbolP = segment_info[i].dot;
- if (symbolP)
- {
-
- SA_SET_SCN_SCNLEN(symbolP, segment_info[i].scnhdr.s_size);
- SA_SET_SCN_NRELOC(symbolP, segment_info[i].scnhdr.s_nreloc);
- SA_SET_SCN_NLINNO(symbolP, segment_info[i].scnhdr.s_nlnno);
-
- }
- }
-
- /*
- * Emit all symbols left in the symbol chain.
- */
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- /* Used to save the offset of the name. It is used to point
- to the string in memory but must be a file offset. */
- register char * temp;
-
- tc_coff_symbol_emit_hook(symbolP);
-
- temp = S_GET_NAME(symbolP);
- if (SF_GET_STRING(symbolP)) {
- S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
- S_SET_ZEROES(symbolP, 0);
- } else {
- memset(symbolP->sy_symbol.ost_entry.n_name, '\0', SYMNMLEN);
- strncpy(symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN);
- }
- where = symbol_to_chars(abfd, where, symbolP);
- S_SET_NAME(symbolP,temp);
- }
-
-} /* w_symbols() */
-
-static void DEFUN_VOID(obj_coff_lcomm)
-{
- char *name;
- char c;
- int temp;
- char *p;
- symbolS *symbolP;
- name = input_line_pointer;
-
-
-
- c = get_symbol_end();
- p = input_line_pointer;
- *p = c;
- SKIP_WHITESPACE();
- if (*input_line_pointer != ',') {
- as_bad("Expected comma after name");
- ignore_rest_of_line();
- return;
- }
- if (*input_line_pointer == '\n') {
- as_bad("Missing size expression");
- return;
- }
- input_line_pointer++;
- if ((temp = get_absolute_expression ()) < 0) {
- as_warn("lcomm length (%d.) <0! Ignored.", temp);
- ignore_rest_of_line();
- return;
- }
- *p = 0;
- symbolP = symbol_find_or_make(name);
- S_SET_VALUE(symbolP, segment_info[SEG_E2].scnhdr.s_size);
- S_SET_SEGMENT(symbolP, SEG_E2);
- segment_info[SEG_E2].scnhdr.s_size += temp;
- S_SET_STORAGE_CLASS(symbolP, C_STAT);
- demand_empty_rest_of_line();
-}
-
-
-#if 1
-static void DEFUN(fixup_segment,(fixP, this_segment_type),
- register fixS * fixP AND
- segT this_segment_type)
-{
- register symbolS *add_symbolP;
- register symbolS *sub_symbolP;
- register long add_number;
- register int size;
- register char *place;
- register long where;
- register char pcrel;
- register fragS *fragP;
- register segT add_symbol_segment = SEG_ABSOLUTE;
-
-
- for ( ; fixP; fixP = fixP->fx_next)
- {
- fragP = fixP->fx_frag;
- know(fragP);
- where = fixP->fx_where;
- place = fragP->fr_literal + where;
- size = fixP->fx_size;
- add_symbolP = fixP->fx_addsy;
-#ifdef TC_I960
- if (fixP->fx_callj && TC_S_IS_CALLNAME(add_symbolP)) {
- /* Relocation should be done via the
- associated 'bal' entry point
- symbol. */
-
- if (!TC_S_IS_BALNAME(tc_get_bal_of_call(add_symbolP))) {
- as_bad("No 'bal' entry point for leafproc %s",
- S_GET_NAME(add_symbolP));
- continue;
- }
- fixP->fx_addsy = add_symbolP = tc_get_bal_of_call(add_symbolP);
- } /* callj relocation */
-#endif
- sub_symbolP = fixP->fx_subsy;
- add_number = fixP->fx_offset;
- pcrel = fixP->fx_pcrel;
-
- if (add_symbolP) {
- add_symbol_segment = S_GET_SEGMENT(add_symbolP);
- } /* if there is an addend */
-
- if (sub_symbolP) {
- if (!add_symbolP) {
- /* Its just -sym */
- if (S_GET_SEGMENT(sub_symbolP) != SEG_ABSOLUTE) {
- as_bad("Negative of non-absolute symbol %s", S_GET_NAME(sub_symbolP));
- } /* not absolute */
-
- add_number -= S_GET_VALUE(sub_symbolP);
-
- /* if sub_symbol is in the same segment that add_symbol
- and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE */
- } else if ((S_GET_SEGMENT(sub_symbolP) == add_symbol_segment)
- && (SEG_NORMAL(add_symbol_segment)
- || (add_symbol_segment == SEG_ABSOLUTE))) {
- /* Difference of 2 symbols from same segment. */
- /* Can't make difference of 2 undefineds: 'value' means */
- /* something different for N_UNDF. */
-#ifdef TC_I960
- /* Makes no sense to use the difference of 2 arbitrary symbols
- * as the target of a call instruction.
- */
- if (fixP->fx_callj) {
- as_bad("callj to difference of 2 symbols");
- }
-#endif /* TC_I960 */
- add_number += S_GET_VALUE(add_symbolP) -
- S_GET_VALUE(sub_symbolP);
-
- add_symbolP = NULL;
- fixP->fx_addsy = NULL;
- } else {
- /* Different segments in subtraction. */
- know(!(S_IS_EXTERNAL(sub_symbolP) && (S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)));
-
- if ((S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)) {
- add_number -= S_GET_VALUE(sub_symbolP);
- } else {
- as_bad("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.",
- segment_name(S_GET_SEGMENT(sub_symbolP)),
- S_GET_NAME(sub_symbolP), fragP->fr_address + where);
- } /* if absolute */
- }
- } /* if sub_symbolP */
-
- if (add_symbolP) {
- if (add_symbol_segment == this_segment_type && pcrel) {
- /*
- * This fixup was made when the symbol's segment was
- * SEG_UNKNOWN, but it is now in the local segment.
- * So we know how to do the address without relocation.
- */
-#ifdef TC_I960
- /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal',
- * in which cases it modifies *fixP as appropriate. In the case
- * of a 'calls', no further work is required, and *fixP has been
- * set up to make the rest of the code below a no-op.
- */
- reloc_callj(fixP);
-#endif /* TC_I960 */
-
- add_number += S_GET_VALUE(add_symbolP);
- add_number -= md_pcrel_from (fixP);
- pcrel = 0; /* Lie. Don't want further pcrel processing. */
- fixP->fx_addsy = NULL; /* No relocations please. */
- } else
- {
- switch (add_symbol_segment)
- {
- case SEG_ABSOLUTE:
-#ifdef TC_I960
- reloc_callj(fixP); /* See comment about reloc_callj() above*/
-#endif /* TC_I960 */
- add_number += S_GET_VALUE(add_symbolP);
- fixP->fx_addsy = NULL;
- add_symbolP = NULL;
- break;
- default:
-
- add_number += S_GET_VALUE(add_symbolP) +
- segment_info[S_GET_SEGMENT(add_symbolP)].scnhdr.s_paddr ;
- break;
-
- case SEG_UNKNOWN:
-#ifdef TC_I960
- if ((int)fixP->fx_bit_fixP == 13) {
- /* This is a COBR instruction. They have only a
- * 13-bit displacement and are only to be used
- * for local branches: flag as error, don't generate
- * relocation.
- */
- as_bad("can't use COBR format with external label");
- fixP->fx_addsy = NULL; /* No relocations please. */
- continue;
- } /* COBR */
-#endif /* TC_I960 */
-
-
-
- break;
-
-
- } /* switch on symbol seg */
- } /* if not in local seg */
- } /* if there was a + symbol */
-
- if (pcrel) {
- add_number -= md_pcrel_from(fixP);
- if (add_symbolP == 0) {
- fixP->fx_addsy = & abs_symbol;
- } /* if there's an add_symbol */
- } /* if pcrel */
-
- if (!fixP->fx_bit_fixP) {
- if ((size == 1
- && (add_number & ~0xFF) && (add_number & ~0xFF != (-1 & ~0xFF))) ||
- (size == 2
- && (add_number & ~0xFFFF) && (add_number & ~0xFFFF != (-1 & ~0xFFFF)))) {
- as_bad("Value of %d too large for field of %d bytes at 0x%x",
- add_number, size, fragP->fr_address + where);
- } /* generic error checking */
- } /* not a bit fix */
- /* once this fix has been applied, we don't have to output anything
- nothing more need be done -*/
- md_apply_fix(fixP, add_number);
-
- } /* For each fixS in this segment. */
-
-
-} /* fixup_segment() */
-#endif
-
-/*
- * Local Variables:
- * fill-column: 131
- * End:
- */
-
-/* end of obj-coffbfd.c */
diff --git a/gnu/usr.bin/as/config/obj-coffbfd.h b/gnu/usr.bin/as/config/obj-coffbfd.h
deleted file mode 100644
index 5ccefab..0000000
--- a/gnu/usr.bin/as/config/obj-coffbfd.h
+++ /dev/null
@@ -1,516 +0,0 @@
-/* coff object file format
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef OBJ_FORMAT_H
-#define OBJ_FORMAT_H
-
-#define OBJ_COFF 1
-
-#include "targ-cpu.h"
-
-#include "bfd.h"
-
-/*extern bfd *stdoutput;*/
-/* This internal_lineno crap is to stop namespace pollution from the
- bfd internal coff headerfile. */
-
-#define internal_lineno bfd_internal_lineno
-#include "coff/internal.h"
-#undef internal_lineno
-
-#if defined(TC_H8300)
-#include "coff/h8300.h"
-#define TARGET_FORMAT "coff-h8300"
-#elif defined(TC_A29K)
-#include "coff/a29k.h"
-#define TARGET_FORMAT "coff-a29k-big"
-#else
-help me
-#endif
-
-#if 0
- /* Define some processor dependent values according to the processor we are
- on. */
-#if defined(TC_H8300)
-#define BYTE_ORDERING 0
-#define FILE_HEADER_MAGIC H8300MAGIC
-#elif defined(TC_M68K)
-
-#define BYTE_ORDERING F_AR32W /* See filehdr.h for more info. */
-#ifndef FILE_HEADER_MAGIC
-#define FILE_HEADER_MAGIC MC68MAGIC /* ... */
-#endif /* FILE_HEADER_MAGIC */
-
-#elif defined(TC_I386)
-
-#define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */
-#ifndef FILE_HEADER_MAGIC
-#define FILE_HEADER_MAGIC I386MAGIC /* ... */
-#endif /* FILE_HEADER_MAGIC */
-
-#elif defined(TC_I960)
-
-#define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */
-#ifndef FILE_HEADER_MAGIC
-#define FILE_HEADER_MAGIC I960ROMAGIC /* ... */
-#endif /* FILE_HEADER_MAGIC */
-
-#elif defined(TC_A29K)
-
-#define BYTE_ORDERING F_AR32W /* big endian. */
-#ifndef FILE_HEADER_MAGIC
-#define FILE_HEADER_MAGIC SIPFBOMAGIC
-#endif /* FILE_HEADER_MAGIC */
-
-#else
-you lose
-#endif
-
-#endif
-
-#ifndef OBJ_COFF_MAX_AUXENTRIES
-#define OBJ_COFF_MAX_AUXENTRIES 1
-#endif /* OBJ_COFF_MAX_AUXENTRIES */
-
-
- extern const segT N_TYPE_seg[];
-
-/* Magic number of paged executable. */
-#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE 0x8300
-
-
-/* SYMBOL TABLE */
-
-/* targets may also set this */
-#ifndef SYMBOLS_NEED_BACKPOINTERS
-#define SYMBOLS_NEED_BACKPOINTERS 1
-#endif /* SYMBOLS_NEED_BACKPOINTERS */
-
-/* Symbol table entry data type */
-
-typedef struct
-{
- struct internal_syment ost_entry; /* Basic symbol */
- union internal_auxent ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */
-
- unsigned int ost_flags; /* obj_coff internal use only flags */
-} obj_symbol_type;
-
-#ifndef DO_NOT_STRIP
-#define DO_NOT_STRIP 0
-#define DO_STRIP 1
-#endif
-/* Symbol table macros and constants */
-
-/* Possible and usefull section number in symbol table
- * The values of TEXT, DATA and BSS may not be portable.
- */
-
-#define C_ABS_SECTION N_ABS
-#define C_UNDEF_SECTION N_UNDEF
-#define C_DEBUG_SECTION N_DEBUG
-#define C_NTV_SECTION N_TV
-#define C_PTV_SECTION P_TV
-#define C_REGISTER_SECTION 20
-
-/*
- * Macros to extract information from a symbol table entry.
- * This syntaxic indirection allows independence regarding a.out or coff.
- * The argument (s) of all these macros is a pointer to a symbol table entry.
- */
-
-/* Predicates */
-/* True if the symbol is external */
-#define S_IS_EXTERNAL(s) ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION)
-/* True if symbol has been defined, ie :
- section > 0 (DATA, TEXT or BSS)
- section == 0 and value > 0 (external bss symbol) */
-#define S_IS_DEFINED(s) ((s)->sy_symbol.ost_entry.n_scnum > C_UNDEF_SECTION || \
- ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION && \
- (s)->sy_symbol.ost_entry.n_value > 0))
-/* True if a debug special symbol entry */
-#define S_IS_DEBUG(s) ((s)->sy_symbol.ost_entry.n_scnum == C_DEBUG_SECTION)
-/* True if a symbol is local symbol name */
-/* A symbol name whose name begin with ^A is a gas internal pseudo symbol */
-#define S_IS_LOCAL(s) (S_GET_NAME(s)[0] == '\001' || \
- (s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION || \
- (S_LOCAL_NAME(s) && !flagseen['L']))
-/* True if a symbol is not defined in this file */
-#define S_IS_EXTERN(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value == 0)
-/*
- * True if a symbol can be multiply defined (bss symbols have this def
- * though it is bad practice)
- */
-#define S_IS_COMMON(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value != 0)
-/* True if a symbol name is in the string table, i.e. its length is > 8. */
-#define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
-
-/* Accessors */
-/* The name of the symbol */
-#define S_GET_NAME(s) ((char*)(s)->sy_symbol.ost_entry.n_offset)
-/* The pointer to the string table */
-#define S_GET_OFFSET(s) ((s)->sy_symbol.ost_entry.n_offset)
-/* The zeroes if symbol name is longer than 8 chars */
-#define S_GET_ZEROES(s) ((s)->sy_symbol.ost_entry.n_zeroes)
-/* The value of the symbol */
-#define S_GET_VALUE(s) ((unsigned) ((s)->sy_symbol.ost_entry.n_value))
-/* The numeric value of the segment */
-#define S_GET_SEGMENT(s) s_get_segment(s)
-/* The data type */
-#define S_GET_DATA_TYPE(s) ((s)->sy_symbol.ost_entry.n_type)
-/* The storage class */
-#define S_GET_STORAGE_CLASS(s) ((s)->sy_symbol.ost_entry.n_sclass)
-/* The number of auxiliary entries */
-#define S_GET_NUMBER_AUXILIARY(s) ((s)->sy_symbol.ost_entry.n_numaux)
-
-/* Modifiers */
-/* Set the name of the symbol */
-#define S_SET_NAME(s,v) ((s)->sy_symbol.ost_entry.n_offset = (unsigned long)(v))
-/* Set the offset of the symbol */
-#define S_SET_OFFSET(s,v) ((s)->sy_symbol.ost_entry.n_offset = (v))
-/* The zeroes if symbol name is longer than 8 chars */
-#define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v))
-/* Set the value of the symbol */
-#define S_SET_VALUE(s,v) ((s)->sy_symbol.ost_entry.n_value = (v))
-/* The numeric value of the segment */
-#define S_SET_SEGMENT(s,v) ((s)->sy_symbol.ost_entry.n_scnum = SEGMENT_TO_SYMBOL_TYPE(v))
-/* The data type */
-#define S_SET_DATA_TYPE(s,v) ((s)->sy_symbol.ost_entry.n_type = (v))
-/* The storage class */
-#define S_SET_STORAGE_CLASS(s,v) ((s)->sy_symbol.ost_entry.n_sclass = (v))
-/* The number of auxiliary entries */
-#define S_SET_NUMBER_AUXILIARY(s,v) ((s)->sy_symbol.ost_entry.n_numaux = (v))
-
-/* Additional modifiers */
-/* The symbol is external (does not mean undefined) */
-#define S_SET_EXTERNAL(s) { S_SET_STORAGE_CLASS(s, C_EXT) ; SF_CLEAR_LOCAL(s); }
-
-/* Auxiliary entry macros. SA_ stands for symbol auxiliary */
-/* Omit the tv related fields */
-/* Accessors */
-#ifdef BFD_HEADERS
-#define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l)
-#else
-#define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx)
-#endif
-#define SA_GET_SYM_LNNO(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno)
-#define SA_GET_SYM_SIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size)
-#define SA_GET_SYM_FSIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize)
-#define SA_GET_SYM_LNNOPTR(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr)
-#ifdef BFD_HEADERS
-#define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l)
-#else
-#define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx)
-#endif
-#define SA_GET_SYM_DIMEN(s,i) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)])
-#define SA_GET_FILE_FNAME(s) ((s)->sy_symbol.ost_auxent[0].x_file.x_fname)
-#define SA_GET_SCN_SCNLEN(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen)
-#define SA_GET_SCN_NRELOC(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc)
-#define SA_GET_SCN_NLINNO(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno)
-
-/* Modifiers */
-#ifdef BFD_HEADERS
-#define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l=(v))
-#else
-#define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx=(v))
-#endif
-#define SA_SET_SYM_LNNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno=(v))
-#define SA_SET_SYM_SIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size=(v))
-#define SA_SET_SYM_FSIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize=(v))
-#define SA_SET_SYM_LNNOPTR(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr=(v))
-#ifdef BFD_HEADERS
-#define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l=(v))
-#else
-#define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx=(v))
-#endif
-#define SA_SET_SYM_DIMEN(s,i,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v))
-#define SA_SET_FILE_FNAME(s,v) strncpy((s)->sy_symbol.ost_auxent[0].x_file.x_fname,(v),FILNMLEN)
-#define SA_SET_SCN_SCNLEN(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen=(v))
-#define SA_SET_SCN_NRELOC(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc=(v))
-#define SA_SET_SCN_NLINNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno=(v))
-
-/*
- * Internal use only definitions. SF_ stands for symbol flags.
- *
- * These values can be assigned to sy_symbol.ost_flags field of a symbolS.
- *
- * You'll break i960 if you shift the SYSPROC bits anywhere else. for
- * more on the balname/callname hack, see tc-i960.h. b.out is done
- * differently.
- */
-
-#define SF_I960_MASK (0x000001ff) /* Bits 0-8 are used by the i960 port. */
-#define SF_SYSPROC (0x0000003f) /* bits 0-5 are used to store the sysproc number */
-#define SF_IS_SYSPROC (0x00000040) /* bit 6 marks symbols that are sysprocs */
-#define SF_BALNAME (0x00000080) /* bit 7 marks BALNAME symbols */
-#define SF_CALLNAME (0x00000100) /* bit 8 marks CALLNAME symbols */
-
-#define SF_NORMAL_MASK (0x0000ffff) /* bits 12-15 are general purpose. */
-
-#define SF_STATICS (0x00001000) /* Mark the .text & all symbols */
-#define SF_DEFINED (0x00002000) /* Symbol is defined in this file */
-#define SF_STRING (0x00004000) /* Symbol name length > 8 */
-#define SF_LOCAL (0x00008000) /* Symbol must not be emitted */
-
-#define SF_DEBUG_MASK (0xffff0000) /* bits 16-31 are debug info */
-
-#define SF_FUNCTION (0x00010000) /* The symbol is a function */
-#define SF_PROCESS (0x00020000) /* Process symbol before write */
-#define SF_TAGGED (0x00040000) /* Is associated with a tag */
-#define SF_TAG (0x00080000) /* Is a tag */
-#define SF_DEBUG (0x00100000) /* Is in debug or abs section */
-#define SF_GET_SEGMENT (0x00200000) /* Get the section of the forward symbol. */
-/* All other bits are unused. */
-
-/* Accessors */
-#define SF_GET(s) ((s)->sy_symbol.ost_flags)
-#define SF_GET_NORMAL_FIELD(s) ((s)->sy_symbol.ost_flags & SF_NORMAL_MASK)
-#define SF_GET_DEBUG_FIELD(s) ((s)->sy_symbol.ost_flags & SF_DEBUG_MASK)
-#define SF_GET_FILE(s) ((s)->sy_symbol.ost_flags & SF_FILE)
-#define SF_GET_STATICS(s) ((s)->sy_symbol.ost_flags & SF_STATICS)
-#define SF_GET_DEFINED(s) ((s)->sy_symbol.ost_flags & SF_DEFINED)
-#define SF_GET_STRING(s) ((s)->sy_symbol.ost_flags & SF_STRING)
-#define SF_GET_LOCAL(s) ((s)->sy_symbol.ost_flags & SF_LOCAL)
-#define SF_GET_FUNCTION(s) ((s)->sy_symbol.ost_flags & SF_FUNCTION)
-#define SF_GET_PROCESS(s) ((s)->sy_symbol.ost_flags & SF_PROCESS)
-#define SF_GET_DEBUG(s) ((s)->sy_symbol.ost_flags & SF_DEBUG)
-#define SF_GET_TAGGED(s) ((s)->sy_symbol.ost_flags & SF_TAGGED)
-#define SF_GET_TAG(s) ((s)->sy_symbol.ost_flags & SF_TAG)
-#define SF_GET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags & SF_GET_SEGMENT)
-#define SF_GET_I960(s) ((s)->sy_symbol.ost_flags & SF_I960_MASK) /* used by i960 */
-#define SF_GET_BALNAME(s) ((s)->sy_symbol.ost_flags & SF_BALNAME) /* used by i960 */
-#define SF_GET_CALLNAME(s) ((s)->sy_symbol.ost_flags & SF_CALLNAME) /* used by i960 */
-#define SF_GET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_IS_SYSPROC) /* used by i960 */
-#define SF_GET_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_SYSPROC) /* used by i960 */
-
-/* Modifiers */
-#define SF_SET(s,v) ((s)->sy_symbol.ost_flags = (v))
-#define SF_SET_NORMAL_FIELD(s,v)((s)->sy_symbol.ost_flags |= ((v) & SF_NORMAL_MASK))
-#define SF_SET_DEBUG_FIELD(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_DEBUG_MASK))
-#define SF_SET_FILE(s) ((s)->sy_symbol.ost_flags |= SF_FILE)
-#define SF_SET_STATICS(s) ((s)->sy_symbol.ost_flags |= SF_STATICS)
-#define SF_SET_DEFINED(s) ((s)->sy_symbol.ost_flags |= SF_DEFINED)
-#define SF_SET_STRING(s) ((s)->sy_symbol.ost_flags |= SF_STRING)
-#define SF_SET_LOCAL(s) ((s)->sy_symbol.ost_flags |= SF_LOCAL)
-#define SF_CLEAR_LOCAL(s) ((s)->sy_symbol.ost_flags &= ~SF_LOCAL)
-#define SF_SET_FUNCTION(s) ((s)->sy_symbol.ost_flags |= SF_FUNCTION)
-#define SF_SET_PROCESS(s) ((s)->sy_symbol.ost_flags |= SF_PROCESS)
-#define SF_SET_DEBUG(s) ((s)->sy_symbol.ost_flags |= SF_DEBUG)
-#define SF_SET_TAGGED(s) ((s)->sy_symbol.ost_flags |= SF_TAGGED)
-#define SF_SET_TAG(s) ((s)->sy_symbol.ost_flags |= SF_TAG)
-#define SF_SET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags |= SF_GET_SEGMENT)
-#define SF_SET_I960(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_I960_MASK)) /* used by i960 */
-#define SF_SET_BALNAME(s) ((s)->sy_symbol.ost_flags |= SF_BALNAME) /* used by i960 */
-#define SF_SET_CALLNAME(s) ((s)->sy_symbol.ost_flags |= SF_CALLNAME) /* used by i960 */
-#define SF_SET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags |= SF_IS_SYSPROC) /* used by i960 */
-#define SF_SET_SYSPROC(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_SYSPROC)) /* used by i960 */
-
-/* File header macro and type definition */
-
-/*
- * File position calculators. Beware to use them when all the
- * appropriate fields are set in the header.
- */
-
-#ifdef OBJ_COFF_OMIT_OPTIONAL_HEADER
-#define OBJ_COFF_AOUTHDRSZ (0)
-#else
-#define OBJ_COFF_AOUTHDRSZ (AOUTHDRSZ)
-#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
-
-#define H_GET_FILE_SIZE(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
- H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
- H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h) + \
- H_GET_SYMBOL_TABLE_SIZE(h) + \
- (h)->string_table_size)
-#define H_GET_TEXT_FILE_OFFSET(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)
-#define H_GET_DATA_FILE_OFFSET(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
- H_GET_TEXT_SIZE(h))
-#define H_GET_BSS_FILE_OFFSET(h) 0
-#define H_GET_RELOCATION_FILE_OFFSET(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
- H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h))
-#define H_GET_LINENO_FILE_OFFSET(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
- H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
- H_GET_RELOCATION_SIZE(h))
-#define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \
- (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
- H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
- H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
- H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h))
-
-/* Accessors */
-/* aouthdr */
-#define H_GET_MAGIC_NUMBER(h) ((h)->aouthdr.magic)
-#define H_GET_VERSION_STAMP(h) ((h)->aouthdr.vstamp)
-#define H_GET_TEXT_SIZE(h) ((h)->aouthdr.tsize)
-#define H_GET_DATA_SIZE(h) ((h)->aouthdr.dsize)
-#define H_GET_BSS_SIZE(h) ((h)->aouthdr.bsize)
-#define H_GET_ENTRY_POINT(h) ((h)->aouthdr.entry)
-#define H_GET_TEXT_START(h) ((h)->aouthdr.text_start)
-#define H_GET_DATA_START(h) ((h)->aouthdr.data_start)
-/* filehdr */
-#define H_GET_FILE_MAGIC_NUMBER(h) ((h)->filehdr.f_magic)
-#define H_GET_NUMBER_OF_SECTIONS(h) ((h)->filehdr.f_nscns)
-#define H_GET_TIME_STAMP(h) ((h)->filehdr.f_timdat)
-#define H_GET_SYMBOL_TABLE_POINTER(h) ((h)->filehdr.f_symptr)
-#define H_GET_SYMBOL_COUNT(h) ((h)->filehdr.f_nsyms)
-#define H_GET_SYMBOL_TABLE_SIZE(h) (H_GET_SYMBOL_COUNT(h) * SYMESZ)
-#define H_GET_SIZEOF_OPTIONAL_HEADER(h) ((h)->filehdr.f_opthdr)
-#define H_GET_FLAGS(h) ((h)->filehdr.f_flags)
-/* Extra fields to achieve bsd a.out compatibility and for convenience */
-#define H_GET_RELOCATION_SIZE(h) ((h)->relocation_size)
-#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
-#define H_GET_LINENO_SIZE(h) ((h)->lineno_size)
-
-#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
-#define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \
- + sizeof(AOUTHDR)\
- + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
-#else /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
-#define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \
- + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
-#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
-
-#define H_GET_TEXT_RELOCATION_SIZE(h) (text_section_header.s_nreloc * RELSZ)
-#define H_GET_DATA_RELOCATION_SIZE(h) (data_section_header.s_nreloc * RELSZ)
-
-/* Modifiers */
-/* aouthdr */
-#define H_SET_MAGIC_NUMBER(h,v) ((h)->aouthdr.magic = (v))
-#define H_SET_VERSION_STAMP(h,v) ((h)->aouthdr.vstamp = (v))
-#define H_SET_TEXT_SIZE(h,v) ((h)->aouthdr.tsize = (v))
-#define H_SET_DATA_SIZE(h,v) ((h)->aouthdr.dsize = (v))
-#define H_SET_BSS_SIZE(h,v) ((h)->aouthdr.bsize = (v))
-#define H_SET_ENTRY_POINT(h,v) ((h)->aouthdr.entry = (v))
-#define H_SET_TEXT_START(h,v) ((h)->aouthdr.text_start = (v))
-#define H_SET_DATA_START(h,v) ((h)->aouthdr.data_start = (v))
-/* filehdr */
-#define H_SET_FILE_MAGIC_NUMBER(h,v) ((h)->filehdr.f_magic = (v))
-#define H_SET_NUMBER_OF_SECTIONS(h,v) ((h)->filehdr.f_nscns = (v))
-#define H_SET_TIME_STAMP(h,v) ((h)->filehdr.f_timdat = (v))
-#define H_SET_SYMBOL_TABLE_POINTER(h,v) ((h)->filehdr.f_symptr = (v))
-#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->filehdr.f_nsyms = (v))
-#define H_SET_SIZEOF_OPTIONAL_HEADER(h,v) ((h)->filehdr.f_opthdr = (v))
-#define H_SET_FLAGS(h,v) ((h)->filehdr.f_flags = (v))
-/* Extra fields to achieve bsd a.out compatibility and for convinience */
-#define H_SET_RELOCATION_SIZE(h,t,d) ((h)->relocation_size = (t)+(d))
-#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
-#define H_SET_LINENO_SIZE(h,v) ((h)->lineno_size = (v))
-
-/* Segment flipping */
-#define segment_name(v) (seg_name[(int) (v)])
-
-typedef struct {
-#ifdef BFD_HEADERS
- struct internal_aouthdr aouthdr; /* a.out header */
- struct internal_filehdr filehdr; /* File header, not machine dep. */
-#else
- AOUTHDR aouthdr; /* a.out header */
- FILHDR filehdr; /* File header, not machine dep. */
-#endif
- long string_table_size; /* names + '\0' + sizeof(int) */
- long relocation_size; /* Cumulated size of relocation
- information for all sections in
- bytes. */
- long lineno_size; /* Size of the line number information
- table in bytes */
-} object_headers;
-
-
-
-struct lineno_list
-{
-
- struct bfd_internal_lineno line;
- char* frag; /* Frag to which the line number is related */
- struct lineno_list* next; /* Forward chain pointer */
-} ;
-
-
-
-
-/* stack stuff */
-typedef struct {
- unsigned long chunk_size;
- unsigned long element_size;
- unsigned long size;
- char* data;
- unsigned long pointer;
-} stack;
-
-
-
-char *EXFUN(stack_pop,(stack *st));
-char *EXFUN(stack_push,(stack *st, char *element));
-char *EXFUN(stack_top,(stack *st));
-stack *EXFUN(stack_init,(unsigned long chunk_size, unsigned long element_size));
-void EXFUN(c_dot_file_symbol,(char *filename));
-void EXFUN(obj_extra_stuff,(object_headers *headers));
-void EXFUN(stack_delete,(stack *st));
-
-
-
-void EXFUN(c_section_header,(
-
- struct internal_scnhdr *header,
- char *name,
- long core_address,
- long size,
- long data_ptr,
- long reloc_ptr,
- long lineno_ptr,
- long reloc_number,
- long lineno_number,
- long alignment));
-
-
-/* sanity check */
-
-#ifdef TC_I960
-#ifndef C_LEAFSTAT
-hey! Where is the C_LEAFSTAT definition? i960-coff support is depending on it.
-#endif /* no C_LEAFSTAT */
-#endif /* TC_I960 */
-#ifdef BFD_HEADERS
- extern struct internal_scnhdr data_section_header;
-extern struct internal_scnhdr text_section_header;
-#else
-extern SCNHDR data_section_header;
-extern SCNHDR text_section_header;
-#endif
-#endif
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-coffbfd.h */
diff --git a/gnu/usr.bin/as/config/obj-generic.c b/gnu/usr.bin/as/config/obj-generic.c
deleted file mode 100644
index 2f69ce4..0000000
--- a/gnu/usr.bin/as/config/obj-generic.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* This file is obj-generic.c and is intended to be a template for
- object format specific source files.
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Chars that can be used to separate mant from exp in floating point nums */
-char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant */
-/* As in 0f12.456 */
-/* or 0d1.2345e12 */
-char FLT_CHARS[] = "rRsSfFdDxXpP";
-
-/* These chars start a comment anywhere in a source file (except inside
- another comment */
-const char comment_chars[] = "#";
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-generic.c */
diff --git a/gnu/usr.bin/as/config/obj-generic.h b/gnu/usr.bin/as/config/obj-generic.h
deleted file mode 100644
index 24a6ace..0000000
--- a/gnu/usr.bin/as/config/obj-generic.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* This file is obj-generic.h
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * This file is obj-generic.h and is intended to be a template for
- * object format specific header files.
- */
-
-/* define an obj specific macro off which target cpu back ends may key. */
-#define OBJ_GENERIC 1
-
-/* include whatever target cpu is appropriate. */
-#include "targ-cpu.h"
-
-/*
- * SYMBOLS
- */
-
-/*
- * If your object format needs to reorder symbols, define this. When
- * defined, symbols are kept on a doubly linked list and functions are
- * made available for push, insert, append, and delete. If not defined,
- * symbols are kept on a singly linked list, only the append and clear
- * facilities are available, and they are macros.
- */
-
-/* #define SYMBOLS_NEED_PACKPOINTERS */
-
-/* */
-typedef struct {
- void *nothing;
-} obj_symbol_type; /* should be the format's symbol structure */
-
-typedef void *object_headers;
-
-/* symbols have names */
-#define S_GET_NAME(s) ("foo") /* get the name of a symbolP */
-#define S_SET_NAME(s,v) ;
- /* symbols have segments */
-#define S_GET_SEGMENT(s) (SEG_UNKNOWN)
-#define S_SET_SEGMENT(s,v) ;
- /* symbols have a value */
-#define S_GET_VALUE(s) (0)
-#define S_SET_VALUE(s,v) ;
- /* symbols may be external */
-#define S_IS_EXTERNAL(s) (0)
-#define S_SET_EXTERNAL(s) ;
-
- /* symbols may or may not be defined */
-#define S_IS_DEFINED(s) (0)
-
-
-#define OBJ_EMIT_LINENO(a,b,c) /* must be *something*. This no-op's it out. */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-generic.h */
diff --git a/gnu/usr.bin/as/config/obj-ieee.c b/gnu/usr.bin/as/config/obj-ieee.c
deleted file mode 100644
index c190999..0000000
--- a/gnu/usr.bin/as/config/obj-ieee.c
+++ /dev/null
@@ -1,539 +0,0 @@
-/* obj-format for ieee-695 records.
- Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
-/*
- created by
-
- steve chamberlain steve@cygnus.com
- */
-
-/*
- this will hopefully become the port through which bfd and gas talk,
- for the moment, only ieee is known to work well.
- */
-
-#include "bfd.h"
-#include "as.h"
-#include "subsegs.h"
-#include "output-file.h"
-#include "frags.h"
-
-bfd *abfd;
-
-/* How many addresses does the .align take? */
-static relax_addressT relax_align(address, alignment)
-register relax_addressT address; /* Address now. */
-register long alignment; /* Alignment (binary). */
-{
- relax_addressT mask;
- relax_addressT new_address;
-
- mask = ~ ( (~0) << alignment );
- new_address = (address + mask) & (~ mask);
- return (new_address - address);
-} /* relax_align() */
-
-/* calculate the size of the frag chain and create a bfd section
- to contain all of it */
-static void DEFUN(size_section,(abfd, idx),
- bfd *abfd AND
- unsigned int idx)
-{
- asection *sec;
- unsigned int size = 0;
- fragS *frag = segment_info[idx].frag_root;
- while (frag) {
- if (frag->fr_address != size) {
- printf("Out of step\n");
- size = frag->fr_address;
- }
- size += frag->fr_fix;
- switch (frag->fr_type) {
- case rs_fill:
- case rs_org:
- size += frag->fr_offset * frag->fr_var;
- break;
- case rs_align:
- size += relax_align(size, frag->fr_offset);
- }
- frag = frag->fr_next;
- }
- if (size) {
- char *name = segment_info[idx].name;
- if (name == (char *)NULL) {
- name = ".data";
- }
- segment_info[idx].user_stuff = (char *)(sec = bfd_make_section(abfd, name));
- /* Make it output through itself */
- sec->output_section = sec;
- sec->flags |= SEC_HAS_CONTENTS;
- bfd_set_section_size(abfd, sec, size);
- }
-}
-
-/* run through a frag chain and write out the data to go with it */
-static void DEFUN(fill_section,(abfd, idx),
- bfd *abfd AND
- unsigned int idx)
-{
- asection *sec = segment_info[idx].user_stuff;
- if (sec) {
- fragS *frag = segment_info[idx].frag_root;
- unsigned int offset = 0;
- while (frag) {
- unsigned int fill_size;
- unsigned int count;
- switch (frag->fr_type) {
- case rs_fill:
- case rs_align:
- case rs_org:
- if (frag->fr_fix)
- {
- bfd_set_section_contents(abfd,
- sec,
- frag->fr_literal,
- frag->fr_address,
- frag->fr_fix);
- }
- offset += frag->fr_fix;
- fill_size = frag->fr_var;
- if (fill_size)
- {
- unsigned int off = frag->fr_fix;
- for (count = frag->fr_offset; count; count--)
- {
- bfd_set_section_contents(abfd, sec,
- frag->fr_literal +
- frag->fr_fix,
- frag->fr_address + off,
- fill_size);
- off += fill_size;
- }
- }
- break;
- default:
- abort();
- }
- frag = frag->fr_next;
- }
- }
-}
-
-/* Count the relocations in a chain */
-
-static unsigned int DEFUN(count_entries_in_chain,(idx),
- unsigned int idx)
-{
- unsigned int nrelocs;
- fixS *fixup_ptr;
-
- /* Count the relocations */
- fixup_ptr = segment_info[idx].fix_root;
- nrelocs = 0;
- while (fixup_ptr != (fixS *)NULL)
- {
- fixup_ptr = fixup_ptr->fx_next;
- nrelocs ++ ;
- }
- return nrelocs;
-}
-
-/* output all the relocations for a section */
-void DEFUN(do_relocs_for,(idx),
- unsigned int idx)
-{
- unsigned int nrelocs;
- arelent **reloc_ptr_vector;
- arelent *reloc_vector;
- asymbol **ptrs;
- asection *section = (asection *)(segment_info[idx].user_stuff);
- unsigned int i;
- fixS *from;
- if (section) {
- nrelocs = count_entries_in_chain(idx);
-
- reloc_ptr_vector = (arelent**)malloc((nrelocs+1) * sizeof(arelent *));
- reloc_vector = (arelent*)malloc(nrelocs * sizeof(arelent));
- ptrs = (asymbol **)malloc(nrelocs * sizeof(asymbol *));
- from = segment_info[idx].fix_root;
- for (i = 0; i < nrelocs; i++)
- {
- arelent *to = reloc_vector + i;
- asymbol *s ;
- reloc_ptr_vector[i] = to;
- to->howto = (reloc_howto_type *)(from->fx_r_type);
-
- /* We can't represent complicated things in a reloc yet */
- /* if (from->fx_addsy == 0 ||
- from->fx_subsy != 0) abort();
- */
- s = &( from->fx_addsy->sy_symbol.sy);
- to->address = ((char *)( from->fx_frag->fr_address +
- from->fx_where))
- - ((char *)(&(from->fx_frag->fr_literal)));
- to->addend = from->fx_offset ;
- /* If we know the symbol which we want to relocate to, turn this
- reloaction into a section relative.
-
- If this relocation is pcrelative, and we know the
- destination, we still want to keep the relocation - since
- the linker might relax some of the bytes, but it stops
- being pc relative and turns into an absolute relocation.
-
- */
- if (s) {
- if ((s->flags & BSF_UNDEFINED) == 0) {
- to->section = s->section;
- to->addend += s->value ;
- to->sym_ptr_ptr = 0;
- if (to->howto->pcrel_offset) {
- /* This is a pcrel relocation, the addend should be adjusted */
- to->addend -= to->address +1;
- }
- }
- else {
- to->section = 0;
- *ptrs = &(from->fx_addsy->sy_symbol.sy);
- to->sym_ptr_ptr = ptrs;
-
- if (to->howto->pcrel_offset) {
- /* This is a pcrel relocation, the addend should be adjusted */
- to->addend -= to->address -1;
- }
- }
-
- }
- else {
- to->section = 0;
- }
-
- ptrs++;
- from = from->fx_next;
- }
-
- /* attatch to the section */
- section->orelocation = reloc_ptr_vector;
- section->reloc_count = nrelocs;
- section->flags |= SEC_LOAD;
- }
-}
-
-/* do the symbols.. */
-static void DEFUN(do_symbols, (abfd),
- bfd *abfd)
-{
- extern symbolS *symbol_rootP;
- symbolS *ptr;
- asymbol **symbol_ptr_vec;
- asymbol *symbol_vec;
- unsigned int count = 0;
- unsigned int index;
-
-
- for (ptr = symbol_rootP;
- ptr != (symbolS *)NULL;
- ptr = ptr->sy_next)
- {
- if (SEG_NORMAL(ptr->sy_symbol.seg))
- {
- ptr->sy_symbol.sy.section =
- (asection *)(segment_info[ptr->sy_symbol.seg].user_stuff);
- ptr->sy_symbol.sy.value += ptr->sy_frag->fr_address;
- if (ptr->sy_symbol.sy.flags == 0) {
- ptr->sy_symbol.sy.flags = BSF_LOCAL ;
- }
- }
- else {
- switch (ptr->sy_symbol.seg) {
- case SEG_ABSOLUTE:
- ptr->sy_symbol.sy.flags |= BSF_ABSOLUTE;
- ptr->sy_symbol.sy.section = 0;
- break;
- case SEG_UNKNOWN:
- ptr->sy_symbol.sy.flags = BSF_UNDEFINED ;
- ptr->sy_symbol.sy.section = 0;
- break;
- default:
- abort();
- }
- }
- count++;
- }
- symbol_ptr_vec = (asymbol **)malloc((count+1) * sizeof(asymbol *));
-
- index = 0;
- for (ptr = symbol_rootP;
- ptr != (symbolS *)NULL;
- ptr = ptr->sy_next)
- {
- symbol_ptr_vec[index] = &(ptr->sy_symbol.sy);
- index++;
- }
- symbol_ptr_vec[index] =0;
- abfd->outsymbols = symbol_ptr_vec;
- abfd->symcount = count;
-}
-
-/* The generic as->bfd converter. Other backends may have special case
- code */
-
-void DEFUN_VOID(bfd_as_write_hook)
-{
- int i;
-
- for (i = SEG_E0; i < SEG_UNKNOWN; i++) {
- size_section(abfd, i);
- }
-
-
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- fill_section(abfd,i);
-
- do_symbols(abfd);
-
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- do_relocs_for(i);
-
-}
-
-
-
-S_GET_VALUE(x)
-symbolS *x;
-{
- return x->sy_symbol.sy.value;
-}
-
-S_SET_SEGMENT(x,y)
-symbolS *x ;
-int y;
-{
- x->sy_symbol.seg = y;
-}
-
-S_IS_DEFINED(x)
-symbolS *x;
-{
- if (SEG_NORMAL(x->sy_symbol.seg))
- {
- return 1;
- }
- switch (x->sy_symbol.seg)
- {
- case SEG_UNKNOWN:
- return 0;
- default:
- abort();
- }
-}
-
-S_IS_EXTERNAL(x) { abort(); }
-S_GET_DESC(x) { abort() ; }
-
-S_GET_SEGMENT(x)
-symbolS *x;
-{ return x->sy_symbol.seg; }
-
-S_SET_EXTERNAL(x)
-symbolS *x;
-{
- x->sy_symbol.sy.flags |= BSF_GLOBAL | BSF_EXPORT;
-}
-
-S_SET_NAME(x,y)
-symbolS*x;
-char *y; {
- x->sy_symbol.sy.name = y; }
-
-S_SET_VALUE(s,v)
-symbolS *s;
-long v;
-{
- s->sy_symbol.sy.value = v;
-}
-
-S_GET_OTHER(x) { abort() ;}
-S_IS_DEBUG(x) { abort(); }
-
-char *segment_name() { abort(); }
-
-void obj_read_begin_hook() { }
-
-static void obj_ieee_section(ignore)
-int ignore;
-{
- extern char *input_line_pointer;
- extern char is_end_of_line[];
- char *p= input_line_pointer;
- char *s = p;
- int i;
- /* Look up the name, if it doesn't exist, make it */
- while (*p &&* p != ' ' && *p != ',' && !is_end_of_line[*p]) {
- p++;
- }
- for (i = SEG_E0; i < SEG_UNKNOWN; i++) {
- if (segment_info[i].hadone){
- if (strncmp(segment_info[i].name, s, p-s) == 0) {
- goto ok;
-
- }
- }
- else break;
- }
- if (i == SEG_UNKNOWN) {
- as_bad("too many sections");
- return;
- }
-
- segment_info[i].hadone = 1;
- segment_info[i].name = malloc(p-s + 1);
- memcpy(segment_info[i].name, s, p-s);
- segment_info[i].name[p-s] = 0;
- ok:
- subseg_new(i,0);
- while (!is_end_of_line[*p])
- p++;
- input_line_pointer = p;
-
-}
-
-
-void cons();
-void s_ignore();
-
-
-/*
- * stringer()
- *
- * We read 0 or more ',' seperated, double-quoted strings.
- *
- * Caller should have checked need_pass_2 is FALSE because we don't check it.
- */
-
-void stringer();
-void s_globl();
-const pseudo_typeS obj_pseudo_table[] =
-{
- {"section", obj_ieee_section, 0},
- {"data.b", cons, 1},
- {"data.w", cons, 2},
- {"data.l", cons, 4},
- {"export", s_globl, 0},
- {"option", s_ignore, 0},
- {"end", s_ignore, 0},
- {"import", s_ignore, 0},
- {"sdata", stringer, 0},
- 0,
-
-};
-
-
-
-void obj_symbol_new_hook(symbolP)
-symbolS *symbolP;
-{
- symbolP->sy_symbol.sy.the_bfd = abfd;
-}
-
-
-
-
-
-#if 1
-extern void DEFUN_VOID(write_object_file)
-{
- int i;
- struct frchain *frchain_ptr;
- struct frag *frag_ptr;
-
- abfd = bfd_openw(out_file_name, "ieee");
-
- if (abfd == 0) {
- as_perror ("FATAL: Can't create %s", out_file_name);
- exit(42);
- }
- bfd_set_format(abfd, bfd_object);
- bfd_set_arch_mach(abfd, bfd_arch_h8300, 0);
- subseg_new(1,0);
- subseg_new(2,0);
- subseg_new(3,0);
- for (frchain_ptr = frchain_root;
- frchain_ptr != (struct frchain *)NULL;
- frchain_ptr = frchain_ptr->frch_next) {
- /* Run through all the sub-segments and align them up. Also close any
- open frags. We tack a .fill onto the end of the frag chain so
- that any .align's size can be worked by looking at the next
- frag */
-
- subseg_new(frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
-#define SUB_SEGMENT_ALIGN 2
- frag_align(SUB_SEGMENT_ALIGN,0);
- frag_wane(frag_now);
- frag_now->fr_fix = 0;
- know( frag_now->fr_next == NULL );
- }
-
- /* Now build one big frag chain for each segment, linked through
- fr_next. */
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
-
- fragS ** prev_frag_ptr_ptr ;
- struct frchain *next_frchain_ptr;
-
- /* struct frag **head_ptr = segment_info[i].frag_root;*/
-
- segment_info[i].frag_root = segment_info[i].frchainP->frch_root;
-#if 0
- /* Im not sure what this is for */
- for (frchain_ptr = segment_info[i].frchainP->frch_root;
- frchain_ptr != (struct frchain *)NULL;
- frchain_ptr = frchain_ptr->frch_next)
- {
- *head_ptr = frchain_ptr;
- head_ptr = &frchain_ptr->next;
- }
-
-
-#endif
- }
-
- for (i = SEG_E0; i < SEG_UNKNOWN; i++) {
- relax_segment(segment_info[i].frag_root, i);
- }
-
- /* Now the addresses of the frags are correct within the segment */
-
- bfd_as_write_hook();
- bfd_close(abfd);
-}
-
-#endif
-
-H_SET_TEXT_SIZE(a,b) { abort(); }
-H_GET_TEXT_SIZE() { abort(); }
-H_SET_BSS_SIZE() { abort(); }
-H_SET_STRING_SIZE() { abort(); }
-H_SET_RELOCATION_SIZE() { abort(); }
-H_SET_MAGIC_NUMBER() { abort(); }
-H_GET_FILE_SIZE() { abort(); }
-H_GET_TEXT_RELOCATION_SIZE() { abort(); }
-
-/* end of obj-ieee.c */
diff --git a/gnu/usr.bin/as/config/obj-ieee.h b/gnu/usr.bin/as/config/obj-ieee.h
deleted file mode 100644
index b2864bc..0000000
--- a/gnu/usr.bin/as/config/obj-ieee.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* This file is obj-ieee.h
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define BFD 1
-
-#include <bfd.h>
-
-typedef struct
-{
-asymbol sy;
-int seg;
-} obj_symbol_type;
-
-#define S_GET_NAME(s) (((s)->sy_symbol.sy.name))
-
-typedef struct {
-int x;
-}
-object_headers;
-
-#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE 1
-
-
-int lineno_rootP;
-
-
-#define IEEE_STYLE
-
-/* end of obj-ieee.h */
diff --git a/gnu/usr.bin/as/config/obj-vms.c b/gnu/usr.bin/as/config/obj-vms.c
deleted file mode 100644
index 2a51ba9..0000000
--- a/gnu/usr.bin/as/config/obj-vms.c
+++ /dev/null
@@ -1,5484 +0,0 @@
-/* vms.c -- Write out a VAX/VMS object file
- Copyright (C) 1987, 1988, 1992 Free Software Foundation, Inc.
-
-This file is part of GAS, the GNU Assembler.
-
-GAS 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.
-
-GAS 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 GAS; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Written by David L. Kashtan */
-/* Modified by Eric Youngdale to write VMS debug records for program
- variables */
-#include "as.h"
-#include "subsegs.h"
-#include "obstack.h"
-
-/* What we do if there is a goof. */
-#define error as_fatal
-
-#ifdef HO_VMS /* These are of no use if we are cross assembling. */
-#include <fab.h> /* Define File Access Block */
-#include <nam.h> /* Define NAM Block */
-#include <xab.h> /* Define XAB - all different types*/
-#endif
-/*
- * Version string of the compiler that produced the code we are
- * assembling. (And this assembler, if we do not have compiler info.)
- */
-extern const char version_string[];
-char *compiler_version_string;
-
-/* Flag that determines how we map names. This takes several values, and
- * is set with the -h switch. A value of zero implies names should be
- * upper case, and the presence of the -h switch inhibits the case hack.
- * No -h switch at all sets vms_name_mapping to 0, and allows case hacking.
- * A value of 2 (set with -h2) implies names should be
- * all lower case, with no case hack. A value of 3 (set with -h3) implies
- * that case should be preserved. */
-
-/* If the -+ switch is given, then the hash is appended to any name that is
- * longer than 31 characters, irregardless of the setting of the -h switch.
- */
-
-char vms_name_mapping = 0;
-
-
-extern char *strchr ();
-extern char *myname;
-static symbolS *Entry_Point_Symbol = 0; /* Pointer to "_main" */
-
-/*
- * We augment the "gas" symbol structure with this
- */
-struct VMS_Symbol
-{
- struct VMS_Symbol *Next;
- struct symbol *Symbol;
- int Size;
- int Psect_Index;
- int Psect_Offset;
-};
-struct VMS_Symbol *VMS_Symbols = 0;
-
-/* We need this to keep track of the various input files, so that we can
- * give the debugger the correct source line.
- */
-
-struct input_file
-{
- struct input_file *next;
- struct input_file *same_file_fpnt;
- int file_number;
- int max_line;
- int min_line;
- int offset;
- char flag;
- char *name;
- symbolS *spnt;
-};
-
-static struct input_file *file_root = (struct input_file *) NULL;
-
-
-static struct input_file *find_file (symbolS *);
-
-/*
- * This enum is used to keep track of the various types of variables that
- * may be present.
- */
-
-enum advanced_type
-{
- BASIC, POINTER, ARRAY, ENUM, STRUCT, UNION, FUNCTION, VOID, UNKNOWN
-};
-
-/*
- * This structure contains the information from the stabs directives, and the
- * information is filled in by VMS_typedef_parse. Everything that is needed
- * to generate the debugging record for a given symbol is present here.
- * This could be done more efficiently, using nested struct/unions, but for now
- * I am happy that it works.
- */
-struct VMS_DBG_Symbol
-{
- struct VMS_DBG_Symbol *next;
- enum advanced_type advanced; /* description of what this is */
- int dbx_type; /* this record is for this type */
- int type2; /* For advanced types this is the type referred to.
- i.e. the type a pointer points to, or the type
- of object that makes up an array */
- int VMS_type; /* Use this type when generating a variable def */
- int index_min; /* used for arrays - this will be present for all */
- int index_max; /* entries, but will be meaningless for non-arrays */
- int data_size; /* size in bytes of the data type. For an array, this
- is the size of one element in the array */
- int struc_numb; /* Number of the structure/union/enum - used for ref */
-};
-
-struct VMS_DBG_Symbol *VMS_Symbol_type_list =
-{(struct VMS_DBG_Symbol *) NULL};
-
-/*
- * We need this structure to keep track of forward references to
- * struct/union/enum that have not been defined yet. When they are ultimately
- * defined, then we can go back and generate the TIR commands to make a back
- * reference.
- */
-
-struct forward_ref
-{
- struct forward_ref *next;
- int dbx_type;
- int struc_numb;
- char resolved;
-};
-
-struct forward_ref *f_ref_root =
-{(struct forward_ref *) NULL};
-
-/*
- * This routine is used to compare the names of certain types to various
- * fixed types that are known by the debugger.
- */
-#define type_check(x) !strcmp( symbol_name , x )
-
-/*
- * This variable is used to keep track of the name of the symbol we are
- * working on while we are parsing the stabs directives.
- */
-static char *symbol_name;
-
-/* We use this counter to assign numbers to all of the structures, unions
- * and enums that we define. When we actually declare a variable to the
- * debugger, we can simply do it by number, rather than describing the
- * whole thing each time.
- */
-
-static structure_count = 0;
-
-/* This variable is used to keep track of the current structure number
- * for a given variable. If this is < 0, that means that the structure
- * has not yet been defined to the debugger. This is still cool, since
- * the VMS object language has ways of fixing things up after the fact,
- * so we just make a note of this, and generate fixups at the end.
- */
-static int struct_number;
-
-
-/*
- * Variable descriptors are used tell the debugger the data types of certain
- * more complicated variables (basically anything involving a structure,
- * union, enum, array or pointer). Some non-pointer variables of the
- * basic types that the debugger knows about do not require a variable
- * descriptor.
- *
- * Since it is impossible to have a variable descriptor longer than 128
- * bytes by virtue of the way that the VMS object language is set up,
- * it makes not sense to make the arrays any longer than this, or worrying
- * about dynamic sizing of the array.
- *
- * These are the arrays and counters that we use to build a variable
- * descriptor.
- */
-
-#define MAX_DEBUG_RECORD 128
-static char Local[MAX_DEBUG_RECORD]; /* buffer for variable descriptor */
-static char Asuffix[MAX_DEBUG_RECORD]; /* buffer for array descriptor */
-static int Lpnt; /* index into Local */
-static int Apoint; /* index into Asuffix */
-static char overflow; /* flag to indicate we have written too much*/
-static int total_len; /* used to calculate the total length of variable
- descriptor plus array descriptor - used for len byte*/
-
-/* Flag if we have told user about finding global constants in the text
- section. */
-static gave_compiler_message = 0;
-
-/* A pointer to the current routine that we are working on. */
-
-static symbolS *Current_Routine;
-
-/* The psect number for $code a.k.a. the text section. */
-
-static int Text_Psect;
-
-
-/*
- * Global data (Object records limited to 512 bytes by VAX-11 "C" runtime)
- */
-static int VMS_Object_File_FD; /* File Descriptor for object file */
-static char Object_Record_Buffer[512]; /* Buffer for object file records */
-static int Object_Record_Offset;/* Offset to end of data */
-static int Current_Object_Record_Type; /* Type of record in above */
-
-/*
- * Macros for placing data into the object record buffer
- */
-
-#define PUT_LONG(val) \
-{ md_number_to_chars(Object_Record_Buffer + \
- Object_Record_Offset, val, 4); \
- Object_Record_Offset += 4; }
-
-#define PUT_SHORT(val) \
-{ md_number_to_chars(Object_Record_Buffer + \
- Object_Record_Offset, val, 2); \
- Object_Record_Offset += 2; }
-
-#define PUT_CHAR(val) Object_Record_Buffer[Object_Record_Offset++] = val
-
-#define PUT_COUNTED_STRING(cp) {\
- register char *p = cp; \
- PUT_CHAR(strlen(p)); \
- while (*p) PUT_CHAR(*p++);}
-
-/*
- * Macro for determining if a Name has psect attributes attached
- * to it.
- */
-#define PSECT_ATTRIBUTES_STRING "$$PsectAttributes_"
-#define PSECT_ATTRIBUTES_STRING_LENGTH 18
-
-#define HAS_PSECT_ATTRIBUTES(Name) \
- (strncmp((Name[0] == '_' ? Name + 1 : Name), \
- PSECT_ATTRIBUTES_STRING, \
- PSECT_ATTRIBUTES_STRING_LENGTH) == 0)
-
-
- /* in: segT out: N_TYPE bits */
-const short seg_N_TYPE[] =
-{
- N_ABS,
- N_TEXT,
- N_DATA,
- N_BSS,
- N_UNDF, /* unknown */
- N_UNDF, /* absent */
- N_UNDF, /* pass1 */
- N_UNDF, /* error */
- N_UNDF, /* bignum/flonum */
- N_UNDF, /* difference */
- N_UNDF, /* debug */
- N_UNDF, /* ntv */
- N_UNDF, /* ptv */
- N_REGISTER, /* register */
-};
-
-const segT N_TYPE_seg[N_TYPE + 2] =
-{ /* N_TYPE == 0x1E = 32-2 */
- SEG_UNKNOWN, /* N_UNDF == 0 */
- SEG_GOOF,
- SEG_ABSOLUTE, /* N_ABS == 2 */
- SEG_GOOF,
- SEG_TEXT, /* N_TEXT == 4 */
- SEG_GOOF,
- SEG_DATA, /* N_DATA == 6 */
- SEG_GOOF,
- SEG_BSS, /* N_BSS == 8 */
- SEG_GOOF,
- SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
- SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
- SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
- SEG_REGISTER, /* dummy N_REGISTER for regs = 30 */
- SEG_GOOF,
-};
-
-
-/* The following code defines the special types of pseudo-ops that we
- * use with VMS.
- */
-
-char const_flag = 0;
-
-void
-s_const ()
-{
- register int temp;
-
- temp = get_absolute_expression ();
- subseg_new (SEG_DATA, (subsegT) temp);
- const_flag = 1;
- demand_empty_rest_of_line ();
-}
-
-/*
- * stab()
- *
- * Handle .stabX directives, which used to be open-coded.
- * So much creeping featurism overloaded the semantics that we decided
- * to put all .stabX thinking in one place. Here.
- *
- * We try to make any .stabX directive legal. Other people's AS will often
- * do assembly-time consistency checks: eg assigning meaning to n_type bits
- * and "protecting" you from setting them to certain values. (They also zero
- * certain bits before emitting symbols. Tut tut.)
- *
- * If an expression is not absolute we either gripe or use the relocation
- * information. Other people's assemblers silently forget information they
- * don't need and invent information they need that you didn't supply.
- *
- * .stabX directives always make a symbol table entry. It may be junk if
- * the rest of your .stabX directive is malformed.
- */
-static void
-obj_aout_stab (what)
- int what;
-{
- register symbolS *symbolP = 0;
- register char *string;
- int saved_type = 0;
- int length;
- int goof; /* TRUE if we have aborted. */
- long longint;
-
-/*
- * Enter with input_line_pointer pointing past .stabX and any following
- * whitespace.
- */
- goof = 0; /* JF who forgot this?? */
- if (what == 's')
- {
- string = demand_copy_C_string (&length);
- SKIP_WHITESPACE ();
- if (*input_line_pointer == ',')
- input_line_pointer++;
- else
- {
- as_bad ("I need a comma after symbol's name");
- goof = 1;
- }
- }
- else
- string = "";
-
-/*
- * Input_line_pointer->after ','. String->symbol name.
- */
- if (!goof)
- {
- symbolP = symbol_new (string,
- SEG_UNKNOWN,
- 0,
- (struct frag *) 0);
- switch (what)
- {
- case 'd':
- S_SET_NAME (symbolP, NULL); /* .stabd feature. */
- S_SET_VALUE (symbolP, obstack_next_free (&frags) - frag_now->fr_literal);
- symbolP->sy_frag = frag_now;
- break;
-
- case 'n':
- symbolP->sy_frag = &zero_address_frag;
- break;
-
- case 's':
- symbolP->sy_frag = &zero_address_frag;
- break;
-
- default:
- BAD_CASE (what);
- break;
- }
-
- if (get_absolute_expression_and_terminator (&longint) == ',')
- symbolP->sy_symbol.n_type = saved_type = longint;
- else
- {
- as_bad ("I want a comma after the n_type expression");
- goof = 1;
- input_line_pointer--; /* Backup over a non-',' char. */
- }
- }
-
- if (!goof)
- {
- if (get_absolute_expression_and_terminator (&longint) == ',')
- S_SET_OTHER (symbolP, longint);
- else
- {
- as_bad ("I want a comma after the n_other expression");
- goof = 1;
- input_line_pointer--; /* Backup over a non-',' char. */
- }
- }
-
- if (!goof)
- {
- S_SET_DESC (symbolP, get_absolute_expression ());
- if (what == 's' || what == 'n')
- {
- if (*input_line_pointer != ',')
- {
- as_bad ("I want a comma after the n_desc expression");
- goof = 1;
- }
- else
- {
- input_line_pointer++;
- }
- }
- }
-
- if ((!goof) && (what == 's' || what == 'n'))
- {
- pseudo_set (symbolP);
- symbolP->sy_symbol.n_type = saved_type;
- }
-
- if (goof)
- ignore_rest_of_line ();
- else
- demand_empty_rest_of_line ();
-} /* obj_aout_stab() */
-
-const pseudo_typeS obj_pseudo_table[] =
-{
- {"stabd", obj_aout_stab, 'd'},/* stabs */
- {"stabn", obj_aout_stab, 'n'},/* stabs */
- {"stabs", obj_aout_stab, 's'},/* stabs */
- {"const", s_const, 0},
- {0, 0, 0},
-
-}; /* obj_pseudo_table */
-
-void
-obj_read_begin_hook ()
-{
- return;
-} /* obj_read_begin_hook() */
-
-void
-obj_crawl_symbol_chain (headers)
- object_headers *headers;
-{
- symbolS *symbolP;
- symbolS **symbolPP;
- int symbol_number = 0;
-
- /* JF deal with forward references first... */
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
- {
- if (symbolP->sy_forward)
- {
- S_SET_VALUE (symbolP, S_GET_VALUE (symbolP)
- + S_GET_VALUE (symbolP->sy_forward)
- + symbolP->sy_forward->sy_frag->fr_address);
- symbolP->sy_forward = 0;
- } /* if it has a forward reference */
- } /* walk the symbol chain */
-
- { /* crawl symbol table */
- register int symbol_number = 0;
-
- {
- symbolPP = &symbol_rootP; /* -> last symbol chain link. */
- while ((symbolP = *symbolPP) != NULL)
- {
- S_GET_VALUE (symbolP) += symbolP->sy_frag->fr_address;
-
- /* OK, here is how we decide which symbols go out into the
- brave new symtab. Symbols that do are:
-
- * symbols with no name (stabd's?)
- * symbols with debug info in their N_TYPE
-
- Symbols that don't are:
- * symbols that are registers
- * symbols with \1 as their 3rd character (numeric labels)
- * "local labels" as defined by S_LOCAL_NAME(name)
- if the -L switch was passed to gas.
-
- All other symbols are output. We complain if a deleted
- symbol was marked external. */
-
-
- if (!S_IS_REGISTER (symbolP))
- {
- symbolP->sy_name_offset = 0;
- symbolPP = &(symbol_next (symbolP));
- }
- else
- {
- if (S_IS_EXTERNAL (symbolP) || !S_IS_DEFINED (symbolP))
- {
- as_bad ("Local symbol %s never defined", S_GET_NAME (symbolP));
- } /* oops. */
-
- } /* if this symbol should be in the output */
- } /* for each symbol */
- }
- H_SET_STRING_SIZE (headers, string_byte_count);
- H_SET_SYMBOL_TABLE_SIZE (headers, symbol_number);
- } /* crawl symbol table */
-
-} /* obj_crawl_symbol_chain() */
-
-
- /****** VMS OBJECT FILE HACKING ROUTINES *******/
-
-
-/*
- * Create the VMS object file
- */
-static
-Create_VMS_Object_File ()
-{
-#if defined(eunice) || !defined(HO_VMS)
- VMS_Object_File_FD = creat (out_file_name, 0777, "var");
-#else /* eunice */
- VMS_Object_File_FD = creat (out_file_name, 0, "rfm=var",
- "mbc=16", "deq=64", "fop=tef", "shr=nil");
-#endif /* eunice */
- /*
- * Deal with errors
- */
- if (VMS_Object_File_FD < 0)
- {
- char Error_Line[256];
-
- sprintf (Error_Line, "Couldn't create VMS object file \"%s\"",
- out_file_name);
- error (Error_Line);
- }
- /*
- * Initialize object file hacking variables
- */
- Object_Record_Offset = 0;
- Current_Object_Record_Type = -1;
-}
-
-
-/*
- * Flush the object record buffer to the object file
- */
-static
-Flush_VMS_Object_Record_Buffer ()
-{
- int i;
- short int zero;
- /*
- * If the buffer is empty, we are done
- */
- if (Object_Record_Offset == 0)
- return;
- /*
- * Write the data to the file
- */
-#ifndef HO_VMS /* For cross-assembly purposes. */
- i = write (VMS_Object_File_FD, &Object_Record_Offset, 2);
-#endif /* not HO_VMS */
- i = write (VMS_Object_File_FD,
- Object_Record_Buffer,
- Object_Record_Offset);
- if (i != Object_Record_Offset)
- error ("I/O error writing VMS object file");
-#ifndef HO_VMS /* When cross-assembling, we need to pad the record to an even
- number of bytes. */
- /* pad it if needed */
- zero = 0;
- if (Object_Record_Offset & 1 != 0)
- write (VMS_Object_File_FD, &zero, 1);
-#endif /* not HO_VMS */
- /*
- * The buffer is now empty
- */
- Object_Record_Offset = 0;
-}
-
-
-/*
- * Declare a particular type of object file record
- */
-static
-Set_VMS_Object_File_Record (Type)
- int Type;
-{
- /*
- * If the type matches, we are done
- */
- if (Type == Current_Object_Record_Type)
- return;
- /*
- * Otherwise: flush the buffer
- */
- Flush_VMS_Object_Record_Buffer ();
- /*
- * Set the new type
- */
- Current_Object_Record_Type = Type;
-}
-
-
-
-/*
- * Close the VMS Object file
- */
-static
-Close_VMS_Object_File ()
-{
- short int m_one = -1;
-#ifndef HO_VMS /* For cross-assembly purposes. */
-/* Write a 0xffff into the file, which means "End of File" */
- write (VMS_Object_File_FD, &m_one, 2);
-#endif /* not HO_VMS */
- close (VMS_Object_File_FD);
-}
-
-
-/*
- * Store immediate data in current Psect
- */
-static
-VMS_Store_Immediate_Data (Pointer, Size, Record_Type)
- register char *Pointer;
- int Size;
- int Record_Type;
-{
- register int i;
-
- /*
- * We are writing a "Record_Type" record
- */
- Set_VMS_Object_File_Record (Record_Type);
- /*
- * We can only store 128 bytes at a time
- */
- while (Size > 0)
- {
- /*
- * Store a maximum of 128 bytes
- */
- i = (Size > 128) ? 128 : Size;
- Size -= i;
- /*
- * If we cannot accommodate this record, flush the
- * buffer.
- */
- if ((Object_Record_Offset + i + 1) >=
- sizeof (Object_Record_Buffer))
- Flush_VMS_Object_Record_Buffer ();
- /*
- * If the buffer is empty we must insert record type
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (Record_Type);
- /*
- * Store the count
- */
- PUT_CHAR (-i & 0xff);
- /*
- * Store the data
- */
- while (--i >= 0)
- PUT_CHAR (*Pointer++);
- /*
- * Flush the buffer if it is more than 75% full
- */
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
- }
-}
-
-/*
- * Make a data reference
- */
-static
-VMS_Set_Data (Psect_Index, Offset, Record_Type, Force)
- int Psect_Index;
- int Offset;
- int Record_Type;
- int Force;
-{
- /*
- * We are writing a "Record_Type" record
- */
- Set_VMS_Object_File_Record (Record_Type);
- /*
- * If the buffer is empty we must insert the record type
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (Record_Type);
- /*
- * Stack the Psect base + Longword Offset
- */
- if (Force == 1)
- {
- if (Psect_Index > 127)
- {
- PUT_CHAR (TIR_S_C_STA_WPL);
- PUT_SHORT (Psect_Index);
- PUT_LONG (Offset);
- }
- else
- {
- PUT_CHAR (TIR_S_C_STA_PL);
- PUT_CHAR (Psect_Index);
- PUT_LONG (Offset);
- }
- }
- else
- {
- if (Offset > 32767)
- {
- PUT_CHAR (TIR_S_C_STA_WPL);
- PUT_SHORT (Psect_Index);
- PUT_LONG (Offset);
- }
- else if (Offset > 127)
- {
- PUT_CHAR (TIR_S_C_STA_WPW);
- PUT_SHORT (Psect_Index);
- PUT_SHORT (Offset);
- }
- else
- {
- PUT_CHAR (TIR_S_C_STA_WPB);
- PUT_SHORT (Psect_Index);
- PUT_CHAR (Offset);
- };
- };
- /*
- * Set relocation base
- */
- PUT_CHAR (TIR_S_C_STO_PIDR);
- /*
- * Flush the buffer if it is more than 75% full
- */
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
-}
-
-/*
- * Make a debugger reference to a struct, union or enum.
- */
-static
-VMS_Store_Struct (int Struct_Index)
-{
- /*
- * We are writing a "OBJ_S_C_DBG" record
- */
- Set_VMS_Object_File_Record (OBJ_S_C_DBG);
- /*
- * If the buffer is empty we must insert the record type
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (OBJ_S_C_DBG);
- PUT_CHAR (TIR_S_C_STA_UW);
- PUT_SHORT (Struct_Index);
- PUT_CHAR (TIR_S_C_CTL_STKDL);
- PUT_CHAR (TIR_S_C_STO_L);
- /*
- * Flush the buffer if it is more than 75% full
- */
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
-}
-
-/*
- * Make a debugger reference to partially define a struct, union or enum.
- */
-static
-VMS_Def_Struct (int Struct_Index)
-{
- /*
- * We are writing a "OBJ_S_C_DBG" record
- */
- Set_VMS_Object_File_Record (OBJ_S_C_DBG);
- /*
- * If the buffer is empty we must insert the record type
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (OBJ_S_C_DBG);
- PUT_CHAR (TIR_S_C_STA_UW);
- PUT_SHORT (Struct_Index);
- PUT_CHAR (TIR_S_C_CTL_DFLOC);
- /*
- * Flush the buffer if it is more than 75% full
- */
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
-}
-
-static
-VMS_Set_Struct (int Struct_Index)
-{ /* see previous functions for comments */
- Set_VMS_Object_File_Record (OBJ_S_C_DBG);
- if (Object_Record_Offset == 0)
- PUT_CHAR (OBJ_S_C_DBG);
- PUT_CHAR (TIR_S_C_STA_UW);
- PUT_SHORT (Struct_Index);
- PUT_CHAR (TIR_S_C_CTL_STLOC);
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
-}
-
-/*
- * Write the Traceback Module Begin record
- */
-static
-VMS_TBT_Module_Begin ()
-{
- register char *cp, *cp1;
- int Size;
- char Module_Name[256];
- char Local[256];
-
- /*
- * Get module name (the FILENAME part of the object file)
- */
- cp = out_file_name;
- cp1 = Module_Name;
- while (*cp)
- {
- if ((*cp == ']') || (*cp == '>') ||
- (*cp == ':') || (*cp == '/'))
- {
- cp1 = Module_Name;
- cp++;
- continue;
- }
- *cp1++ = islower (*cp) ? toupper (*cp++) : *cp++;
- }
- *cp1 = 0;
- /*
- * Limit it to 31 characters
- */
- while (--cp1 >= Module_Name)
- if (*cp1 == '.')
- *cp1 = 0;
- if (strlen (Module_Name) > 31)
- {
- if (flagseen['+'])
- printf ("%s: Module name truncated: %s\n", myname, Module_Name);
- Module_Name[31] = 0;
- }
- /*
- * Arrange to store the data locally (leave room for size byte)
- */
- cp = Local + 1;
- /*
- * Begin module
- */
- *cp++ = DST_S_C_MODBEG;
- /*
- * Unused
- */
- *cp++ = 0;
- /*
- * Language type == "C"
- */
- *(long *) cp = DST_S_C_C;
- cp += sizeof (long);
- /*
- * Store the module name
- */
- *cp++ = strlen (Module_Name);
- cp1 = Module_Name;
- while (*cp1)
- *cp++ = *cp1++;
- /*
- * Now we can store the record size
- */
- Size = (cp - Local);
- Local[0] = Size - 1;
- /*
- * Put it into the object record
- */
- VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_TBT);
-}
-
-
-/*
- * Write the Traceback Module End record
-*/
-static
-VMS_TBT_Module_End ()
-{
- char Local[2];
-
- /*
- * End module
- */
- Local[0] = 1;
- Local[1] = DST_S_C_MODEND;
- /*
- * Put it into the object record
- */
- VMS_Store_Immediate_Data (Local, 2, OBJ_S_C_TBT);
-}
-
-
-/*
- * Write the Traceback Routine Begin record
- */
-static
-VMS_TBT_Routine_Begin (symbolP, Psect)
- struct symbol *symbolP;
- int Psect;
-{
- register char *cp, *cp1;
- char *Name;
- int Offset;
- int Size;
- char Local[512];
-
- /*
- * Strip the leading "_" from the name
- */
- Name = S_GET_NAME (symbolP);
- if (*Name == '_')
- Name++;
- /*
- * Get the text psect offset
- */
- Offset = S_GET_VALUE (symbolP);
- /*
- * Calculate the record size
- */
- Size = 1 + 1 + 4 + 1 + strlen (Name);
- /*
- * Record Size
- */
- Local[0] = Size;
- /*
- * Begin Routine
- */
- Local[1] = DST_S_C_RTNBEG;
- /*
- * Uses CallS/CallG
- */
- Local[2] = 0;
- /*
- * Store the data so far
- */
- VMS_Store_Immediate_Data (Local, 3, OBJ_S_C_TBT);
- /*
- * Make sure we are still generating a OBJ_S_C_TBT record
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (OBJ_S_C_TBT);
- /*
- * Now get the symbol address
- */
- PUT_CHAR (TIR_S_C_STA_WPL);
- PUT_SHORT (Psect);
- PUT_LONG (Offset);
- /*
- * Store the data reference
- */
- PUT_CHAR (TIR_S_C_STO_PIDR);
- /*
- * Store the counted string as data
- */
- cp = Local;
- cp1 = Name;
- Size = strlen (cp1) + 1;
- *cp++ = Size - 1;
- while (*cp1)
- *cp++ = *cp1++;
- VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_TBT);
-}
-
-
-/*
- * Write the Traceback Routine End record
- * We *must* search the symbol table to find the next routine, since
- * the assember has a way of reassembling the symbol table OUT OF ORDER
- * Thus the next routine in the symbol list is not necessarily the
- * next one in memory. For debugging to work correctly we must know the
- * size of the routine.
- */
-static
-VMS_TBT_Routine_End (Max_Size, sp)
- int Max_Size;
- symbolS *sp;
-{
- symbolS *symbolP;
- int Size = 0x7fffffff;
- char Local[16];
-
-
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
- {
- if (!S_IS_DEBUG (symbolP) && S_GET_TYPE (symbolP) == N_TEXT)
- {
- if (*S_GET_NAME (symbolP) == 'L')
- continue;
- if ((S_GET_VALUE (symbolP) > S_GET_VALUE (sp)) &&
- (S_GET_VALUE (symbolP) < Size))
- Size = S_GET_VALUE (symbolP);
- /* check if gcc_compiled. has size of zero */
- if ((S_GET_VALUE (symbolP) == S_GET_VALUE (sp)) &&
- sp != symbolP &&
- (!strcmp (S_GET_NAME (sp), "gcc_compiled.") ||
- !strcmp (S_GET_NAME (sp), "gcc2_compiled.")))
- Size = S_GET_VALUE (symbolP);
-
- };
- };
- if (Size == 0x7fffffff)
- Size = Max_Size;
- Size -= S_GET_VALUE (sp); /* and get the size of the routine */
- /*
- * Record Size
- */
- Local[0] = 6;
- /*
- * End of Routine
- */
- Local[1] = DST_S_C_RTNEND;
- /*
- * Unused
- */
- Local[2] = 0;
- /*
- * Size of routine
- */
- *((long *) (Local + 3)) = Size;
- /*
- * Store the record
- */
- VMS_Store_Immediate_Data (Local, 7, OBJ_S_C_TBT);
-}
-
-/*
- * Write the Traceback Block End record
- */
-static
-VMS_TBT_Block_Begin (symbolP, Psect, Name)
- struct symbol *symbolP;
- int Psect;
- char *Name;
-{
- register char *cp, *cp1;
- int Offset;
- int Size;
- char Local[512];
- /*
- * Begin block
- */
- Size = 1 + 1 + 4 + 1 + strlen (Name);
- /*
- * Record Size
- */
- Local[0] = Size;
- /*
- * Begin Block - We simulate with a phony routine
- */
- Local[1] = DST_S_C_BLKBEG;
- /*
- * Uses CallS/CallG
- */
- Local[2] = 0;
- /*
- * Store the data so far
- */
- VMS_Store_Immediate_Data (Local, 3, OBJ_S_C_DBG);
- /*
- * Make sure we are still generating a OBJ_S_C_DBG record
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (OBJ_S_C_DBG);
- /*
- * Now get the symbol address
- */
- PUT_CHAR (TIR_S_C_STA_WPL);
- PUT_SHORT (Psect);
- /*
- * Get the text psect offset
- */
- Offset = S_GET_VALUE (symbolP);
- PUT_LONG (Offset);
- /*
- * Store the data reference
- */
- PUT_CHAR (TIR_S_C_STO_PIDR);
- /*
- * Store the counted string as data
- */
- cp = Local;
- cp1 = Name;
- Size = strlen (cp1) + 1;
- *cp++ = Size - 1;
- while (*cp1)
- *cp++ = *cp1++;
- VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_DBG);
-}
-
-
-/*
- * Write the Traceback Block End record
- */
-static
-VMS_TBT_Block_End (int Size)
-{
- char Local[16];
-
- /*
- * End block - simulate with a phony end routine
- */
- Local[0] = 6;
- Local[1] = DST_S_C_BLKEND;
- *((long *) (Local + 3)) = Size;
- /*
- * Unused
- */
- Local[2] = 0;
- VMS_Store_Immediate_Data (Local, 7, OBJ_S_C_DBG);
-}
-
-
-
-/*
- * Write a Line number / PC correlation record
- */
-static
-VMS_TBT_Line_PC_Correlation (Line_Number, Offset, Psect, Do_Delta)
- int Line_Number;
- int Offset;
- int Psect;
- int Do_Delta;
-{
- register char *cp;
- char Local[64];
-
- /*
-* If not delta, set our PC/Line number correlation
-*/
- if (Do_Delta == 0)
- {
- /*
- * Size
- */
- Local[0] = 1 + 1 + 2 + 1 + 4;
- /*
- * Line Number/PC correlation
- */
- Local[1] = DST_S_C_LINE_NUM;
- /*
- * Set Line number
- */
- Local[2] = DST_S_C_SET_LINE_NUM;
- *((unsigned short *) (Local + 3)) = Line_Number - 1;
- /*
- * Set PC
- */
- Local[5] = DST_S_C_SET_ABS_PC;
- VMS_Store_Immediate_Data (Local, 6, OBJ_S_C_TBT);
- /*
- * Make sure we are still generating a OBJ_S_C_TBT record
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (OBJ_S_C_TBT);
- if (Psect < 255)
- {
- PUT_CHAR (TIR_S_C_STA_PL);
- PUT_CHAR (Psect);
- }
- else
- {
- PUT_CHAR (TIR_S_C_STA_WPL);
- PUT_SHORT (Psect);
- }
- PUT_LONG (Offset);
- PUT_CHAR (TIR_S_C_STO_PIDR);
- /*
- * Do a PC offset of 0 to register the line number
- */
- Local[0] = 2;
- Local[1] = DST_S_C_LINE_NUM;
- Local[2] = 0; /* Increment PC by 0 and register line # */
- VMS_Store_Immediate_Data (Local, 3, OBJ_S_C_TBT);
- }
- else
- {
- /*
- * If Delta is negative, terminate the line numbers
- */
- if (Do_Delta < 0)
- {
- Local[0] = 1 + 1 + 4;
- Local[1] = DST_S_C_LINE_NUM;
- Local[2] = DST_S_C_TERM_L;
- *((long *) (Local + 3)) = Offset;
- VMS_Store_Immediate_Data (Local, 7, OBJ_S_C_TBT);
- /*
- * Done
- */
- return;
- }
- /*
- * Do a PC/Line delta
- */
- cp = Local + 1;
- *cp++ = DST_S_C_LINE_NUM;
- if (Line_Number > 1)
- {
- /*
- * We need to increment the line number
- */
- if (Line_Number - 1 <= 255)
- {
- *cp++ = DST_S_C_INCR_LINUM;
- *cp++ = Line_Number - 1;
- }
- else
- {
- *cp++ = DST_S_C_INCR_LINUM_W;
- *(short *) cp = Line_Number - 1;
- cp += sizeof (short);
- }
- }
- /*
- * Increment the PC
- */
- if (Offset <= 128)
- {
- *cp++ = -Offset;
- }
- else
- {
- if (Offset < 0x10000)
- {
- *cp++ = DST_S_C_DELTA_PC_W;
- *(short *) cp = Offset;
- cp += sizeof (short);
- }
- else
- {
- *cp++ = DST_S_C_DELTA_PC_L;
- *(long *) cp = Offset;
- cp += sizeof (long);
- }
- }
- Local[0] = cp - (Local + 1);
- VMS_Store_Immediate_Data (Local, cp - Local, OBJ_S_C_TBT);
- }
-}
-
-
-/*
- * Describe a source file to the debugger
- */
-static
-VMS_TBT_Source_File (Filename, ID_Number)
- char *Filename;
- int ID_Number;
-{
- register char *cp, *cp1;
- int Status, i;
- char Local[512];
-#ifndef HO_VMS /* Used for cross-assembly */
- i = strlen (Filename);
-#else /* HO_VMS */
- static struct FAB Fab;
- static struct NAM Nam;
- static struct XABDAT Date_Xab;
- static struct XABFHC File_Header_Xab;
- char Es_String[255], Rs_String[255];
-
- /*
- * Setup the Fab
- */
- Fab.fab$b_bid = FAB$C_BID;
- Fab.fab$b_bln = sizeof (Fab);
- Fab.fab$l_nam = (&Nam);
- Fab.fab$l_xab = (char *) &Date_Xab;
- /*
- * Setup the Nam block so we can find out the FULL name
- * of the source file.
- */
- Nam.nam$b_bid = NAM$C_BID;
- Nam.nam$b_bln = sizeof (Nam);
- Nam.nam$l_rsa = Rs_String;
- Nam.nam$b_rss = sizeof (Rs_String);
- Nam.nam$l_esa = Es_String;
- Nam.nam$b_ess = sizeof (Es_String);
- /*
- * Setup the Date and File Header Xabs
- */
- Date_Xab.xab$b_cod = XAB$C_DAT;
- Date_Xab.xab$b_bln = sizeof (Date_Xab);
- Date_Xab.xab$l_nxt = (char *) &File_Header_Xab;
- File_Header_Xab.xab$b_cod = XAB$C_FHC;
- File_Header_Xab.xab$b_bln = sizeof (File_Header_Xab);
- /*
- * Get the file information
- */
- Fab.fab$l_fna = Filename;
- Fab.fab$b_fns = strlen (Filename);
- Status = sys$open (&Fab);
- if (!(Status & 1))
- {
- printf ("gas: Couldn't find source file \"%s\", Error = %%X%x\n",
- Filename, Status);
- return (0);
- }
- sys$close (&Fab);
- /*
- * Calculate the size of the resultant string
- */
- i = Nam.nam$b_rsl;
-#endif /* HO_VMS */
- /*
- * Size of record
- */
- Local[0] = 1 + 1 + 1 + 1 + 1 + 2 + 8 + 4 + 2 + 1 + 1 + i + 1;
- /*
- * Source declaration
- */
- Local[1] = DST_S_C_SOURCE;
- /*
- * Make formfeeds count as source records
- */
- Local[2] = DST_S_C_SRC_FORMFEED;
- /*
- * Declare source file
- */
- Local[3] = DST_S_C_SRC_DECLFILE;
- Local[4] = 1 + 2 + 8 + 4 + 2 + 1 + 1 + i + 1;
- cp = Local + 5;
- /*
- * Flags
- */
- *cp++ = 0;
- /*
- * File ID
- */
- *(short *) cp = ID_Number;
- cp += sizeof (short);
-#ifndef HO_VMS
- /*
- * Creation Date. Unknown, so we fill with zeroes.
- */
- *(long *) cp = 0;
- cp += sizeof (long);
- *(long *) cp = 0;
- cp += sizeof (long);
- /*
- * End of file block
- */
- *(long *) cp = 0;
- cp += sizeof (long);
- /*
- * First free byte
- */
- *(short *) cp = 0;
- cp += sizeof (short);
- /*
- * Record format
- */
- *cp++ = 0;
- /*
- * Filename
- */
- *cp++ = i;
- cp1 = Filename;
-#else /* Use this code when assembling for VMS on a VMS system */
- /*
- * Creation Date
- */
- *(long *) cp = ((long *) &Date_Xab.xab$q_cdt)[0];
- cp += sizeof (long);
- *(long *) cp = ((long *) &Date_Xab.xab$q_cdt)[1];
- cp += sizeof (long);
- /*
- * End of file block
- */
- *(long *) cp = File_Header_Xab.xab$l_ebk;
- cp += sizeof (long);
- /*
- * First free byte
- */
- *(short *) cp = File_Header_Xab.xab$w_ffb;
- cp += sizeof (short);
- /*
- * Record format
- */
- *cp++ = File_Header_Xab.xab$b_rfo;
- /*
- * Filename
- */
- *cp++ = i;
- cp1 = Rs_String;
-#endif /* HO_VMS */
- while (--i >= 0)
- *cp++ = *cp1++;
- /*
- * Library module name (none)
- */
- *cp++ = 0;
- /*
- * Done
- */
- VMS_Store_Immediate_Data (Local, cp - Local, OBJ_S_C_TBT);
- return 1;
-}
-
-
-/*
- * Give the number of source lines to the debugger
- */
-static
-VMS_TBT_Source_Lines (ID_Number, Starting_Line_Number, Number_Of_Lines)
- int ID_Number;
- int Starting_Line_Number;
- int Number_Of_Lines;
-{
- char *cp, *cp1;
- char Local[16];
-
- /*
- * Size of record
- */
- Local[0] = 1 + 1 + 2 + 1 + 4 + 1 + 2;
- /*
- * Source declaration
- */
- Local[1] = DST_S_C_SOURCE;
- /*
- * Set Source File
- */
- cp = Local + 2;
- *cp++ = DST_S_C_SRC_SETFILE;
- /*
- * File ID Number
- */
- *(short *) cp = ID_Number;
- cp += sizeof (short);
- /*
- * Set record number
- */
- *cp++ = DST_S_C_SRC_SETREC_L;
- *(long *) cp = Starting_Line_Number;
- cp += sizeof (long);
- /*
- * Define lines
- */
- *cp++ = DST_S_C_SRC_DEFLINES_W;
- *(short *) cp = Number_Of_Lines;
- cp += sizeof (short);
- /*
- * Done
- */
- VMS_Store_Immediate_Data (Local, cp - Local, OBJ_S_C_TBT);
-}
-
-
-
-
-/* This routine locates a file in the list of files. If an entry does not
- * exist, one is created. For include files, a new entry is always created
- * such that inline functions can be properly debugged. */
-static struct input_file *
-find_file (sp)
- symbolS *sp;
-{
- struct input_file *same_file;
- struct input_file *fpnt;
- same_file = (struct input_file *) NULL;
- for (fpnt = file_root; fpnt; fpnt = fpnt->next)
- {
- if (fpnt == (struct input_file *) NULL)
- break;
- if (fpnt->spnt == sp)
- return fpnt;
- };
- for (fpnt = file_root; fpnt; fpnt = fpnt->next)
- {
- if (fpnt == (struct input_file *) NULL)
- break;
- if (strcmp (S_GET_NAME (sp), fpnt->name) == 0)
- {
- if (fpnt->flag == 1)
- return fpnt;
- same_file = fpnt;
- break;
- };
- };
- fpnt = (struct input_file *) malloc (sizeof (struct input_file));
- if (file_root == (struct input_file *) NULL)
- file_root = fpnt;
- else
- {
- struct input_file *fpnt1;
- for (fpnt1 = file_root; fpnt1->next; fpnt1 = fpnt1->next) ;
- fpnt1->next = fpnt;
- };
- fpnt->next = (struct input_file *) NULL;
- fpnt->name = S_GET_NAME (sp);
- fpnt->min_line = 0x7fffffff;
- fpnt->max_line = 0;
- fpnt->offset = 0;
- fpnt->flag = 0;
- fpnt->file_number = 0;
- fpnt->spnt = sp;
- fpnt->same_file_fpnt = same_file;
- return fpnt;
-}
-
-/*
- * The following functions and definitions are used to generate object records
- * that will describe program variables to the VMS debugger.
- *
- * This file contains many of the routines needed to output debugging info into
- * the object file that the VMS debugger needs to understand symbols. These
- * routines are called very late in the assembly process, and thus we can be
- * fairly lax about changing things, since the GSD and the TIR sections have
- * already been output.
- */
-
-
-/* This routine converts a number string into an integer, and stops when it
- * sees an invalid character the return value is the address of the character
- * just past the last character read. No error is generated.
- */
-static char *
-cvt_integer (str, rtn)
- char *str;
- int *rtn;
-{
- int ival, neg;
- neg = *str == '-' ? ++str, -1 : 1;
- ival = 0; /* first get the number of the type for dbx */
- while ((*str <= '9') && (*str >= '0'))
- ival = 10 * ival + *str++ - '0';
- *rtn = neg * ival;
- return str;
-}
-
-/* this routine fixes the names that are generated by C++, ".this" is a good
- * example. The period does not work for the debugger, since it looks like
- * the syntax for a structure element, and thus it gets mightily confused
- *
- * We also use this to strip the PsectAttribute hack from the name before we
- * write a debugger record */
-
-static char *
-fix_name (pnt)
- char *pnt;
-{
- char *pnt1;
- /*
- * Kill any leading "_"
- */
- if (*pnt == '_')
- pnt++;
- /*
- * Is there a Psect Attribute to skip??
- */
- if (HAS_PSECT_ATTRIBUTES (pnt))
- {
- /*
- * Yes: Skip it
- */
- pnt += PSECT_ATTRIBUTES_STRING_LENGTH;
- while (*pnt)
- {
- if ((pnt[0] == '$') && (pnt[1] == '$'))
- {
- pnt += 2;
- break;
- }
- pnt++;
- }
- }
-/* Here we fix the .this -> $this conversion */
- for (pnt1 = pnt; *pnt1 != 0; pnt1++)
- {
- if (*pnt1 == '.')
- *pnt1 = '$';
- };
- return pnt;
-}
-
-/* When defining a structure, this routine is called to find the name of
- * the actual structure. It is assumed that str points to the equal sign
- * in the definition, and it moves backward until it finds the start of the
- * name. If it finds a 0, then it knows that this structure def is in the
- * outermost level, and thus symbol_name points to the symbol name.
- */
-static char *
-get_struct_name (str)
- char *str;
-{
- char *pnt;
- pnt = str;
- while ((*pnt != ':') && (*pnt != '\0'))
- pnt--;
- if (*pnt == '\0')
- return symbol_name;
- *pnt-- = '\0';
- while ((*pnt != ';') && (*pnt != '='))
- pnt--;
- if (*pnt == ';')
- return pnt + 1;
- while ((*pnt < '0') || (*pnt > '9'))
- pnt++;
- while ((*pnt >= '0') && (*pnt <= '9'))
- pnt++;
- return pnt;
-}
-
-/* search symbol list for type number dbx_type. Return a pointer to struct */
-static struct VMS_DBG_Symbol *
-find_symbol (dbx_type)
- int dbx_type;
-{
- struct VMS_DBG_Symbol *spnt;
- spnt = VMS_Symbol_type_list;
- while (spnt != (struct VMS_DBG_Symbol *) NULL)
- {
- if (spnt->dbx_type == dbx_type)
- break;
- spnt = spnt->next;
- };
- if (spnt == (struct VMS_DBG_Symbol *) NULL)
- return 0; /*Dunno what this is*/
- return spnt;
-}
-
-
-/* this routine puts info into either Local or Asuffix, depending on the sign
- * of size. The reason is that it is easier to build the variable descriptor
- * backwards, while the array descriptor is best built forwards. In the end
- * they get put together, if there is not a struct/union/enum along the way
- */
-static
-push (value, size)
- int value, size;
-{
- char *pnt;
- int i;
- int size1;
- long int val;
- val = value;
- pnt = (char *) &val;
- size1 = size;
- if (size < 0)
- {
- size1 = -size;
- pnt += size1 - 1;
- };
- if (size < 0)
- for (i = 0; i < size1; i++)
- {
- Local[Lpnt--] = *pnt--;
- if (Lpnt < 0)
- {
- overflow = 1;
- Lpnt = 1;
- };
- }
- else
- for (i = 0; i < size1; i++)
- {
- Asuffix[Apoint++] = *pnt++;
- if (Apoint >= MAX_DEBUG_RECORD)
- {
- overflow = 1;
- Apoint = MAX_DEBUG_RECORD - 1;
- };
- }
-}
-
-/* this routine generates the array descriptor for a given array */
-static
-array_suffix (spnt2)
- struct VMS_DBG_Symbol *spnt2;
-{
- struct VMS_DBG_Symbol *spnt;
- struct VMS_DBG_Symbol *spnt1;
- int rank;
- int total_size;
- int i;
- rank = 0;
- spnt = spnt2;
- while (spnt->advanced != ARRAY)
- {
- spnt = find_symbol (spnt->type2);
- if (spnt == (struct VMS_DBG_Symbol *) NULL)
- return;
- };
- spnt1 = spnt;
- spnt1 = spnt;
- total_size = 1;
- while (spnt1->advanced == ARRAY)
- {
- rank++;
- total_size *= (spnt1->index_max - spnt1->index_min + 1);
- spnt1 = find_symbol (spnt1->type2);
- };
- total_size = total_size * spnt1->data_size;
- push (spnt1->data_size, 2);
- if (spnt1->VMS_type == 0xa3)
- push (0, 1);
- else
- push (spnt1->VMS_type, 1);
- push (4, 1);
- for (i = 0; i < 6; i++)
- push (0, 1);
- push (0xc0, 1);
- push (rank, 1);
- push (total_size, 4);
- push (0, 4);
- spnt1 = spnt;
- while (spnt1->advanced == ARRAY)
- {
- push (spnt1->index_max - spnt1->index_min + 1, 4);
- spnt1 = find_symbol (spnt1->type2);
- };
- spnt1 = spnt;
- while (spnt1->advanced == ARRAY)
- {
- push (spnt1->index_min, 4);
- push (spnt1->index_max, 4);
- spnt1 = find_symbol (spnt1->type2);
- };
-}
-
-/* this routine generates the start of a variable descriptor based upon
- * a struct/union/enum that has yet to be defined. We define this spot as
- * a new location, and save four bytes for the address. When the struct is
- * finally defined, then we can go back and plug in the correct address
-*/
-static
-new_forward_ref (dbx_type)
- int dbx_type;
-{
- struct forward_ref *fpnt;
- fpnt = (struct forward_ref *) malloc (sizeof (struct forward_ref));
- fpnt->next = f_ref_root;
- f_ref_root = fpnt;
- fpnt->dbx_type = dbx_type;
- fpnt->struc_numb = ++structure_count;
- fpnt->resolved = 'N';
- push (3, -1);
- total_len = 5;
- push (total_len, -2);
- struct_number = -fpnt->struc_numb;
-}
-
-/* this routine generates the variable descriptor used to describe non-basic
- * variables. It calls itself recursively until it gets to the bottom of it
- * all, and then builds the descriptor backwards. It is easiest to do it this
- *way since we must periodically write length bytes, and it is easiest if we know
- *the value when it is time to write it.
- */
-static int
-gen1 (spnt, array_suffix_len)
- struct VMS_DBG_Symbol *spnt;
- int array_suffix_len;
-{
- struct VMS_DBG_Symbol *spnt1;
- int i;
- switch (spnt->advanced)
- {
- case VOID:
- push (DBG_S_C_VOID, -1);
- total_len += 1;
- push (total_len, -2);
- return 0;
- case BASIC:
- case FUNCTION:
- if (array_suffix_len == 0)
- {
- push (spnt->VMS_type, -1);
- push (DBG_S_C_BASIC, -1);
- total_len = 2;
- push (total_len, -2);
- return 1;
- };
- push (0, -4);
- push (0xfa02, -2);
- total_len = -2;
- return 1;
- case STRUCT:
- case UNION:
- case ENUM:
- struct_number = spnt->struc_numb;
- if (struct_number < 0)
- {
- new_forward_ref (spnt->dbx_type);
- return 1;
- }
- push (DBG_S_C_STRUCT, -1);
- total_len = 5;
- push (total_len, -2);
- return 1;
- case POINTER:
- spnt1 = find_symbol (spnt->type2);
- i = 1;
- if (spnt1 == (struct VMS_DBG_Symbol *) NULL)
- new_forward_ref (spnt->type2);
- else
- i = gen1 (spnt1, 0);
- if (i)
- { /* (*void) is a special case, do not put pointer suffix*/
- push (DBG_S_C_POINTER, -1);
- total_len += 3;
- push (total_len, -2);
- };
- return 1;
- case ARRAY:
- spnt1 = spnt;
- while (spnt1->advanced == ARRAY)
- {
- spnt1 = find_symbol (spnt1->type2);
- if (spnt1 == (struct VMS_DBG_Symbol *) NULL)
- {
- printf ("gcc-as warning(debugger output):");
- printf ("Forward reference error, dbx type %d\n",
- spnt->type2);
- return;
- }
- };
-/* It is too late to generate forward references, so the user gets a message.
- * This should only happen on a compiler error */
- i = gen1 (spnt1, 1);
- i = Apoint;
- array_suffix (spnt);
- array_suffix_len = Apoint - i;
- switch (spnt1->advanced)
- {
- case BASIC:
- case FUNCTION:
- break;
- default:
- push (0, -2);
- total_len += 2;
- push (total_len, -2);
- push (0xfa, -1);
- push (0x0101, -2);
- push (DBG_S_C_COMPLEX_ARRAY, -1);
- };
- total_len += array_suffix_len + 8;
- push (total_len, -2);
- };
-}
-
-/* This generates a suffix for a variable. If it is not a defined type yet,
- * then dbx_type contains the type we are expecting so we can generate a
- * forward reference. This calls gen1 to build most of the descriptor, and
- * then it puts the icing on at the end. It then dumps whatever is needed
- * to get a complete descriptor (i.e. struct reference, array suffix ).
- */
-static
-generate_suffix (spnt, dbx_type)
- struct VMS_DBG_Symbol *spnt;
- int dbx_type;
-{
- int ilen;
- int i;
- char pvoid[6] =
- {5, 0xaf, 0, 1, 0, 5};
- struct VMS_DBG_Symbol *spnt1;
- Apoint = 0;
- Lpnt = MAX_DEBUG_RECORD - 1;
- total_len = 0;
- struct_number = 0;
- overflow = 0;
- if (spnt == (struct VMS_DBG_Symbol *) NULL)
- new_forward_ref (dbx_type);
- else
- {
- if (spnt->VMS_type != 0xa3)
- return 0; /* no suffix needed */
- gen1 (spnt, 0);
- };
- push (0x00af, -2);
- total_len += 4;
- push (total_len, -1);
-/* if the variable descriptor overflows the record, output a descriptor for
- * a pointer to void.
- */
- if ((total_len >= MAX_DEBUG_RECORD) || overflow)
- {
- printf (" Variable descriptor %d too complicated. Defined as *void ", spnt->dbx_type);
- VMS_Store_Immediate_Data (pvoid, 6, OBJ_S_C_DBG);
- return;
- };
- i = 0;
- while (Lpnt < MAX_DEBUG_RECORD - 1)
- Local[i++] = Local[++Lpnt];
- Lpnt = i;
-/* we use this for a reference to a structure that has already been defined */
- if (struct_number > 0)
- {
- VMS_Store_Immediate_Data (Local, Lpnt, OBJ_S_C_DBG);
- Lpnt = 0;
- VMS_Store_Struct (struct_number);
- };
-/* we use this for a forward reference to a structure that has yet to be
-*defined. We store four bytes of zero to make room for the actual address once
-* it is known
-*/
- if (struct_number < 0)
- {
- struct_number = -struct_number;
- VMS_Store_Immediate_Data (Local, Lpnt, OBJ_S_C_DBG);
- Lpnt = 0;
- VMS_Def_Struct (struct_number);
- for (i = 0; i < 4; i++)
- Local[Lpnt++] = 0;
- VMS_Store_Immediate_Data (Local, Lpnt, OBJ_S_C_DBG);
- Lpnt = 0;
- };
- i = 0;
- while (i < Apoint)
- Local[Lpnt++] = Asuffix[i++];
- if (Lpnt != 0)
- VMS_Store_Immediate_Data (Local, Lpnt, OBJ_S_C_DBG);
- Lpnt = 0;
-}
-
-/* This routine generates a symbol definition for a C sybmol for the debugger.
- * It takes a psect and offset for global symbols - if psect < 0, then this is
- * a local variable and the offset is relative to FP. In this case it can
- * be either a variable (Offset < 0) or a parameter (Offset > 0).
- */
-static
-VMS_DBG_record (spnt, Psect, Offset, Name)
- struct VMS_DBG_Symbol *spnt;
- int Psect;
- int Offset;
- char *Name;
-{
- char *pnt;
- char *Name_pnt;
- int j;
- int maxlen;
- int i = 0;
- Name_pnt = fix_name (Name); /* if there are bad characters in name, convert them */
- if (Psect < 0)
- { /* this is a local variable, referenced to SP */
- maxlen = 7 + strlen (Name_pnt);
- Local[i++] = maxlen;
- Local[i++] = spnt->VMS_type;
- if (Offset > 0)
- Local[i++] = DBG_S_C_FUNCTION_PARAMETER;
- else
- Local[i++] = DBG_S_C_LOCAL_SYM;
- pnt = (char *) &Offset;
- for (j = 0; j < 4; j++)
- Local[i++] = *pnt++; /* copy the offset */
- }
- else
- {
- maxlen = 7 + strlen (Name_pnt); /* symbols fixed in memory */
- Local[i++] = 7 + strlen (Name_pnt);
- Local[i++] = spnt->VMS_type;
- Local[i++] = 1;
- VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
- i = 0;
- VMS_Set_Data (Psect, Offset, OBJ_S_C_DBG, 0);
- }
- Local[i++] = strlen (Name_pnt);
- while (*Name_pnt != '\0')
- Local[i++] = *Name_pnt++;
- VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
- if (spnt->VMS_type == DBG_S_C_ADVANCED_TYPE)
- generate_suffix (spnt, 0);
-}
-
-
-/* This routine parses the stabs entries in order to make the definition
- * for the debugger of local symbols and function parameters
- */
-static int
-VMS_local_stab_Parse (sp)
- symbolS *sp;
-{
- char *pnt;
- char *pnt1;
- char *str;
- struct VMS_DBG_Symbol *spnt;
- struct VMS_Symbol *vsp;
- int dbx_type;
- int VMS_type;
- dbx_type = 0;
- str = S_GET_NAME (sp);
- pnt = (char *) strchr (str, ':');
- if (pnt == (char *) NULL)
- return; /* no colon present */
- pnt1 = pnt++; /* save this for later, and skip colon */
- if (*pnt == 'c')
- return 0; /* ignore static constants */
-/* there is one little catch that we must be aware of. Sometimes function
- * parameters are optimized into registers, and the compiler, in its infiite
- * wisdom outputs stabs records for *both*. In general we want to use the
- * register if it is present, so we must search the rest of the symbols for
- * this function to see if this parameter is assigned to a register.
- */
- {
- char *str1;
- char *pnt2;
- symbolS *sp1;
- if (*pnt == 'p')
- {
- for (sp1 = symbol_next (sp); sp1; sp1 = symbol_next (sp1))
- {
- if (!S_IS_DEBUG (sp1))
- continue;
- if (S_GET_RAW_TYPE (sp1) == N_FUN)
- {
- char * pnt3=(char*) strchr (S_GET_NAME (sp1), ':') + 1;
- if (*pnt3 == 'F' || *pnt3 == 'f') break;
- };
- if (S_GET_RAW_TYPE (sp1) != N_RSYM)
- continue;
- str1 = S_GET_NAME (sp1); /* and get the name */
- pnt2 = str;
- while (*pnt2 != ':')
- {
- if (*pnt2 != *str1)
- break;
- pnt2++;
- str1++;
- };
- if ((*str1 != ':') || (*pnt2 != ':'))
- continue;
- return; /* they are the same! lets skip this one */
- }; /* for */
-/* first find the dbx symbol type from list, and then find VMS type */
- pnt++; /* skip p in case no register */
- }; /* if */
- }; /* p block */
- pnt = cvt_integer (pnt, &dbx_type);
- spnt = find_symbol (dbx_type);
- if (spnt == (struct VMS_DBG_Symbol *) NULL)
- return 0; /*Dunno what this is*/
- *pnt1 = '\0';
- VMS_DBG_record (spnt, -1, S_GET_VALUE (sp), str);
- *pnt1 = ':'; /* and restore the string */
- return 1;
-}
-
-/* This routine parses a stabs entry to find the information required to define
- * a variable. It is used for global and static variables.
- * Basically we need to know the address of the symbol. With older versions
- * of the compiler, const symbols are
- * treated differently, in that if they are global they are written into the
- * text psect. The global symbol entry for such a const is actually written
- * as a program entry point (Yuk!!), so if we cannot find a symbol in the list
- * of psects, we must search the entry points as well. static consts are even
- * harder, since they are never assigned a memory address. The compiler passes
- * a stab to tell us the value, but I am not sure what to do with it.
- */
-
-static
-VMS_stab_parse (sp, expected_type, type1, type2, Text_Psect)
- symbolS *sp;
- char expected_type;
- int type1, type2, Text_Psect;
-{
- char *pnt;
- char *pnt1;
- char *str;
- symbolS *sp1;
- struct VMS_DBG_Symbol *spnt;
- struct VMS_Symbol *vsp;
- int dbx_type;
- int VMS_type;
- dbx_type = 0;
- str = S_GET_NAME (sp);
- pnt = (char *) strchr (str, ':');
- if (pnt == (char *) NULL)
- return; /* no colon present */
- pnt1 = pnt; /* save this for later*/
- pnt++;
- if (*pnt == expected_type)
- {
- pnt = cvt_integer (pnt + 1, &dbx_type);
- spnt = find_symbol (dbx_type);
- if (spnt == (struct VMS_DBG_Symbol *) NULL)
- return 0; /*Dunno what this is*/
-/* now we need to search the symbol table to find the psect and offset for
- * this variable.
- */
- *pnt1 = '\0';
- vsp = VMS_Symbols;
- while (vsp != (struct VMS_Symbol *) NULL)
- {
- pnt = S_GET_NAME (vsp->Symbol);
- if (pnt != (char *) NULL)
- if (*pnt++ == '_')
-/* make sure name is the same, and make sure correct symbol type */
- if ((strlen (pnt) == strlen (str)) && (strcmp (pnt, str) == 0)
- && ((S_GET_RAW_TYPE (vsp->Symbol) == type1) ||
- (S_GET_RAW_TYPE (vsp->Symbol) == type2)))
- break;
- vsp = vsp->Next;
- };
- if (vsp != (struct VMS_Symbol *) NULL)
- {
- VMS_DBG_record (spnt, vsp->Psect_Index, vsp->Psect_Offset, str);
- *pnt1 = ':'; /* and restore the string */
- return 1;
- };
-/* the symbol was not in the symbol list, but it may be an "entry point"
- if it was a constant */
- for (sp1 = symbol_rootP; sp1; sp1 = symbol_next (sp1))
- {
- /*
- * Dispatch on STAB type
- */
- if (S_IS_DEBUG (sp1) || (S_GET_TYPE (sp1) != N_TEXT))
- continue;
- pnt = S_GET_NAME (sp1);
- if (*pnt == '_')
- pnt++;
- if (strcmp (pnt, str) == 0)
- {
- if (!gave_compiler_message && expected_type == 'G')
- {
- printf ("***Warning - the assembly code generated by the compiler has placed\n");
- printf ("global constant(s) in the text psect. These will not be available to\n");
- printf ("other modules, since this is not the correct way to handle this. You\n");
- printf ("have two options: 1) get a patched compiler that does not put global\n");
- printf ("constants in the text psect, or 2) remove the 'const' keyword from\n");
- printf ("definitions of global variables in your source module(s). Don't say\n");
- printf ("I didn't warn you!");
- gave_compiler_message = 1;
- };
- VMS_DBG_record (spnt,
- Text_Psect,
- S_GET_VALUE (sp1),
- str);
- *pnt1 = ':';
- *S_GET_NAME (sp1) = 'L';
- /* fool assembler to not output this
- * as a routine in the TBT */
- return 1;
- };
- };
- };
- *pnt1 = ':'; /* and restore the string */
- return 0;
-}
-
-static
-VMS_GSYM_Parse (sp, Text_Psect)
- symbolS *sp;
- int Text_Psect;
-{ /* Global variables */
- VMS_stab_parse (sp, 'G', (N_UNDF | N_EXT), (N_DATA | N_EXT), Text_Psect);
-}
-
-
-static
-VMS_LCSYM_Parse (sp, Text_Psect)
- symbolS *sp;
- int Text_Psect;
-{ /* Static symbols - uninitialized */
- VMS_stab_parse (sp, 'S', N_BSS, -1, Text_Psect);
-}
-
-static
-VMS_STSYM_Parse (sp, Text_Psect)
- symbolS *sp;
- int Text_Psect;
-{ /* Static symbols - initialized */
- VMS_stab_parse (sp, 'S', N_DATA, -1, Text_Psect);
-}
-
-
-/* for register symbols, we must figure out what range of addresses within the
- * psect are valid. We will use the brackets in the stab directives to give us
- * guidance as to the PC range that this variable is in scope. I am still not
- * completely comfortable with this but as I learn more, I seem to get a better
- * handle on what is going on.
- * Caveat Emptor.
- */
-static
-VMS_RSYM_Parse (sp, Current_Routine, Text_Psect)
- symbolS *sp, *Current_Routine;
- int Text_Psect;
-{
- char *pnt;
- char *pnt1;
- char *str;
- int dbx_type;
- struct VMS_DBG_Symbol *spnt;
- int j;
- int maxlen;
- int i = 0;
- int bcnt = 0;
- int Min_Offset = -1; /* min PC of validity */
- int Max_Offset = 0; /* max PC of validity */
- symbolS *symbolP;
- for (symbolP = sp; symbolP; symbolP = symbol_next (symbolP))
- {
- /*
- * Dispatch on STAB type
- */
- switch (S_GET_RAW_TYPE (symbolP))
- {
- case N_LBRAC:
- if (bcnt++ == 0)
- Min_Offset = S_GET_VALUE (symbolP);
- break;
- case N_RBRAC:
- if (--bcnt == 0)
- Max_Offset =
- S_GET_VALUE (symbolP) - 1;
- break;
- }
- if ((Min_Offset != -1) && (bcnt == 0))
- break;
- if (S_GET_RAW_TYPE (symbolP) == N_FUN)
- {
- pnt=(char*) strchr (S_GET_NAME (symbolP), ':') + 1;
- if (*pnt == 'F' || *pnt == 'f') break;
- };
- }
-/* check to see that the addresses were defined. If not, then there were no
- * brackets in the function, and we must try to search for the next function
- * Since functions can be in any order, we should search all of the symbol list
- * to find the correct ending address. */
- if (Min_Offset == -1)
- {
- int Max_Source_Offset;
- int This_Offset;
- Min_Offset = S_GET_VALUE (sp);
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
- {
- /*
- * Dispatch on STAB type
- */
- This_Offset = S_GET_VALUE (symbolP);
- switch (S_GET_RAW_TYPE (symbolP))
- {
- case N_TEXT | N_EXT:
- if ((This_Offset > Min_Offset) && (This_Offset < Max_Offset))
- Max_Offset = This_Offset;
- break;
- case N_SLINE:
- if (This_Offset > Max_Source_Offset)
- Max_Source_Offset = This_Offset;
- }
- }
-/* if this is the last routine, then we use the PC of the last source line
- * as a marker of the max PC for which this reg is valid */
- if (Max_Offset == 0x7fffffff)
- Max_Offset = Max_Source_Offset;
- };
- dbx_type = 0;
- str = S_GET_NAME (sp);
- pnt = (char *) strchr (str, ':');
- if (pnt == (char *) NULL)
- return; /* no colon present */
- pnt1 = pnt; /* save this for later*/
- pnt++;
- if (*pnt != 'r')
- return 0;
- pnt = cvt_integer (pnt + 1, &dbx_type);
- spnt = find_symbol (dbx_type);
- if (spnt == (struct VMS_DBG_Symbol *) NULL)
- return 0; /*Dunno what this is yet*/
- *pnt1 = '\0';
- pnt = fix_name (S_GET_NAME (sp)); /* if there are bad characters in name, convert them */
- maxlen = 25 + strlen (pnt);
- Local[i++] = maxlen;
- Local[i++] = spnt->VMS_type;
- Local[i++] = 0xfb;
- Local[i++] = strlen (pnt) + 1;
- Local[i++] = 0x00;
- Local[i++] = 0x00;
- Local[i++] = 0x00;
- Local[i++] = strlen (pnt);
- while (*pnt != '\0')
- Local[i++] = *pnt++;
- Local[i++] = 0xfd;
- Local[i++] = 0x0f;
- Local[i++] = 0x00;
- Local[i++] = 0x03;
- Local[i++] = 0x01;
- VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
- i = 0;
- VMS_Set_Data (Text_Psect, Min_Offset, OBJ_S_C_DBG, 1);
- VMS_Set_Data (Text_Psect, Max_Offset, OBJ_S_C_DBG, 1);
- Local[i++] = 0x03;
- Local[i++] = S_GET_VALUE (sp);
- Local[i++] = 0x00;
- Local[i++] = 0x00;
- Local[i++] = 0x00;
- VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
- *pnt1 = ':';
- if (spnt->VMS_type == DBG_S_C_ADVANCED_TYPE)
- generate_suffix (spnt, 0);
-}
-
-/* this function examines a structure definition, checking all of the elements
- * to make sure that all of them are fully defined. The only thing that we
- * kick out are arrays of undefined structs, since we do not know how big
- * they are. All others we can handle with a normal forward reference.
- */
-static int
-forward_reference (pnt)
- char *pnt;
-{
- int i;
- struct VMS_DBG_Symbol *spnt;
- struct VMS_DBG_Symbol *spnt1;
- pnt = cvt_integer (pnt + 1, &i);
- if (*pnt == ';')
- return 0; /* no forward references */
- do
- {
- pnt = (char *) strchr (pnt, ':');
- pnt = cvt_integer (pnt + 1, &i);
- spnt = find_symbol (i);
- if (spnt == (struct VMS_DBG_Symbol *) NULL)
- return 0;
- while ((spnt->advanced == POINTER) || (spnt->advanced == ARRAY))
- {
- i = spnt->type2;
- spnt1 = find_symbol (spnt->type2);
- if ((spnt->advanced == ARRAY) &&
- (spnt1 == (struct VMS_DBG_Symbol *) NULL))
- return 1;
- if (spnt1 == (struct VMS_DBG_Symbol *) NULL)
- break;
- spnt = spnt1;
- };
- pnt = cvt_integer (pnt + 1, &i);
- pnt = cvt_integer (pnt + 1, &i);
- } while (*++pnt != ';');
- return 0; /* no forward refences found */
-}
-
-/* This routine parses the stabs directives to find any definitions of dbx type
- * numbers. It makes a note of all of them, creating a structure element
- * of VMS_DBG_Symbol that describes it. This also generates the info for the
- * debugger that describes the struct/union/enum, so that further references
- * to these data types will be by number
- * We have to process pointers right away, since there can be references
- * to them later in the same stabs directive. We cannot have forward
- * references to pointers, (but we can have a forward reference to a pointer to
- * a structure/enum/union) and this is why we process them immediately.
- * After we process the pointer, then we search for defs that are nested even
- * deeper.
- */
-static int
-VMS_typedef_parse (str)
- char *str;
-{
- char *pnt;
- char *pnt1;
- char *pnt2;
- int i;
- int dtype;
- struct forward_ref *fpnt;
- int i1, i2, i3;
- int convert_integer;
- struct VMS_DBG_Symbol *spnt;
- struct VMS_DBG_Symbol *spnt1;
-/* check for any nested def's */
- pnt = (char *) strchr (str + 1, '=');
- if ((pnt != (char *) NULL) && (*(str + 1) != '*'))
- if (VMS_typedef_parse (pnt) == 1)
- return 1;
-/* now find dbx_type of entry */
- pnt = str - 1;
- if (*pnt == 'c')
- { /* check for static constants */
- *str = '\0'; /* for now we ignore them */
- return 0;
- };
- while ((*pnt <= '9') && (*pnt >= '0'))
- pnt--;
- pnt++; /* and get back to the number */
- cvt_integer (pnt, &i1);
- spnt = find_symbol (i1);
-/* first we see if this has been defined already, due to a forward reference*/
- if (spnt == (struct VMS_DBG_Symbol *) NULL)
- {
- if (VMS_Symbol_type_list == (struct VMS_DBG_Symbol *) NULL)
- {
- spnt = (struct VMS_DBG_Symbol *) malloc (sizeof (struct VMS_DBG_Symbol));
- spnt->next = (struct VMS_DBG_Symbol *) NULL;
- VMS_Symbol_type_list = spnt;
- }
- else
- {
- spnt = (struct VMS_DBG_Symbol *) malloc (sizeof (struct VMS_DBG_Symbol));
- spnt->next = VMS_Symbol_type_list;
- VMS_Symbol_type_list = spnt;
- };
- spnt->dbx_type = i1; /* and save the type */
- };
-/* for structs and unions, do a partial parse, otherwise we sometimes get
- * circular definitions that are impossible to resolve. We read enough info
- * so that any reference to this type has enough info to be resolved
- */
- pnt = str + 1; /* point to character past equal sign */
- if ((*pnt == 'u') || (*pnt == 's'))
- {
- };
- if ((*pnt <= '9') && (*pnt >= '0'))
- {
- if (type_check ("void"))
- { /* this is the void symbol */
- *str = '\0';
- spnt->advanced = VOID;
- return 0;
- };
- if (type_check ("unknown type"))
- { /* this is the void symbol */
- *str = '\0';
- spnt->advanced = UNKNOWN;
- return 0;
- };
- printf ("gcc-as warning(debugger output):");
- printf (" %d is an unknown untyped variable.\n", spnt->dbx_type);
- return 1; /* do not know what this is */
- };
-/* now define this module*/
- pnt = str + 1; /* point to character past equal sign */
- switch (*pnt)
- {
- case 'r':
- spnt->advanced = BASIC;
- if (type_check ("int"))
- {
- spnt->VMS_type = DBG_S_C_SLINT;
- spnt->data_size = 4;
- }
- else if (type_check ("long int"))
- {
- spnt->VMS_type = DBG_S_C_SLINT;
- spnt->data_size = 4;
- }
- else if (type_check ("unsigned int"))
- {
- spnt->VMS_type = DBG_S_C_ULINT;
- spnt->data_size = 4;
- }
- else if (type_check ("long unsigned int"))
- {
- spnt->VMS_type = DBG_S_C_ULINT;
- spnt->data_size = 4;
- }
- else if (type_check ("short int"))
- {
- spnt->VMS_type = DBG_S_C_SSINT;
- spnt->data_size = 2;
- }
- else if (type_check ("short unsigned int"))
- {
- spnt->VMS_type = DBG_S_C_USINT;
- spnt->data_size = 2;
- }
- else if (type_check ("char"))
- {
- spnt->VMS_type = DBG_S_C_SCHAR;
- spnt->data_size = 1;
- }
- else if (type_check ("signed char"))
- {
- spnt->VMS_type = DBG_S_C_SCHAR;
- spnt->data_size = 1;
- }
- else if (type_check ("unsigned char"))
- {
- spnt->VMS_type = DBG_S_C_UCHAR;
- spnt->data_size = 1;
- }
- else if (type_check ("float"))
- {
- spnt->VMS_type = DBG_S_C_REAL4;
- spnt->data_size = 4;
- }
- else if (type_check ("double"))
- {
- spnt->VMS_type = DBG_S_C_REAL8;
- spnt->data_size = 8;
- }
- pnt1 = (char *) strchr (str, ';') + 1;
- break;
- case 's':
- case 'u':
- if (*pnt == 's')
- spnt->advanced = STRUCT;
- else
- spnt->advanced = UNION;
- spnt->VMS_type = DBG_S_C_ADVANCED_TYPE;
- pnt1 = cvt_integer (pnt + 1, &spnt->data_size);
- if (forward_reference (pnt))
- {
- spnt->struc_numb = -1;
- return 1;
- }
- spnt->struc_numb = ++structure_count;
- pnt1--;
- pnt = get_struct_name (str);
- VMS_Def_Struct (spnt->struc_numb);
- fpnt = f_ref_root;
- while (fpnt != (struct forward_ref *) NULL)
- {
- if (fpnt->dbx_type == spnt->dbx_type)
- {
- fpnt->resolved = 'Y';
- VMS_Set_Struct (fpnt->struc_numb);
- VMS_Store_Struct (spnt->struc_numb);
- };
- fpnt = fpnt->next;
- };
- VMS_Set_Struct (spnt->struc_numb);
- i = 0;
- Local[i++] = 11 + strlen (pnt);
- Local[i++] = DBG_S_C_STRUCT_START;
- Local[i++] = 0x80;
- for (i1 = 0; i1 < 4; i1++)
- Local[i++] = 0x00;
- Local[i++] = strlen (pnt);
- pnt2 = pnt;
- while (*pnt2 != '\0')
- Local[i++] = *pnt2++;
- i2 = spnt->data_size * 8; /* number of bits */
- pnt2 = (char *) &i2;
- for (i1 = 0; i1 < 4; i1++)
- Local[i++] = *pnt2++;
- VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
- i = 0;
- if (pnt != symbol_name)
- {
- pnt += strlen (pnt);
- *pnt = ':';
- }; /* replace colon for later */
- while (*++pnt1 != ';')
- {
- pnt = (char *) strchr (pnt1, ':');
- *pnt = '\0';
- pnt2 = pnt1;
- pnt1 = cvt_integer (pnt + 1, &dtype);
- pnt1 = cvt_integer (pnt1 + 1, &i2);
- pnt1 = cvt_integer (pnt1 + 1, &i3);
- if ((dtype == 1) && (i3 != 32))
- { /* bitfield */
- Apoint = 0;
- push (19 + strlen (pnt2), 1);
- push (0xfa22, 2);
- push (1 + strlen (pnt2), 4);
- push (strlen (pnt2), 1);
- while (*pnt2 != '\0')
- push (*pnt2++, 1);
- push (i3, 2); /* size of bitfield */
- push (0x0d22, 2);
- push (0x00, 4);
- push (i2, 4); /* start position */
- VMS_Store_Immediate_Data (Asuffix, Apoint, OBJ_S_C_DBG);
- Apoint = 0;
- }
- else
- {
- Local[i++] = 7 + strlen (pnt2);
- spnt1 = find_symbol (dtype);
- /* check if this is a forward reference */
- if (spnt1 != (struct VMS_DBG_Symbol *) NULL)
- Local[i++] = spnt1->VMS_type;
- else
- Local[i++] = DBG_S_C_ADVANCED_TYPE;
- Local[i++] = DBG_S_C_STRUCT_ITEM;
- pnt = (char *) &i2;
- for (i1 = 0; i1 < 4; i1++)
- Local[i++] = *pnt++;
- Local[i++] = strlen (pnt2);
- while (*pnt2 != '\0')
- Local[i++] = *pnt2++;
- VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
- i = 0;
- if (spnt1 == (struct VMS_DBG_Symbol *) NULL)
- generate_suffix (spnt1, dtype);
- else if (spnt1->VMS_type == DBG_S_C_ADVANCED_TYPE)
- generate_suffix (spnt1, 0);
- };
- };
- pnt1++;
- Local[i++] = 0x01; /* length byte */
- Local[i++] = DBG_S_C_STRUCT_END;
- VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
- i = 0;
- break;
- case 'e':
- spnt->advanced = ENUM;
- spnt->VMS_type = DBG_S_C_ADVANCED_TYPE;
- spnt->struc_numb = ++structure_count;
- spnt->data_size = 4;
- VMS_Def_Struct (spnt->struc_numb);
- fpnt = f_ref_root;
- while (fpnt != (struct forward_ref *) NULL)
- {
- if (fpnt->dbx_type == spnt->dbx_type)
- {
- fpnt->resolved = 'Y';
- VMS_Set_Struct (fpnt->struc_numb);
- VMS_Store_Struct (spnt->struc_numb);
- };
- fpnt = fpnt->next;
- };
- VMS_Set_Struct (spnt->struc_numb);
- i = 0;
- Local[i++] = 3 + strlen (symbol_name);
- Local[i++] = DBG_S_C_ENUM_START;
- Local[i++] = 0x20;
- Local[i++] = strlen (symbol_name);
- pnt2 = symbol_name;
- while (*pnt2 != '\0')
- Local[i++] = *pnt2++;
- VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
- i = 0;
- while (*++pnt != ';')
- {
- pnt1 = (char *) strchr (pnt, ':');
- *pnt1++ = '\0';
- pnt1 = cvt_integer (pnt1, &i1);
- Local[i++] = 7 + strlen (pnt);
- Local[i++] = DBG_S_C_ENUM_ITEM;
- Local[i++] = 0x00;
- pnt2 = (char *) &i1;
- for (i2 = 0; i2 < 4; i2++)
- Local[i++] = *pnt2++;
- Local[i++] = strlen (pnt);
- pnt2 = pnt;
- while (*pnt != '\0')
- Local[i++] = *pnt++;
- VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
- i = 0;
- pnt = pnt1; /* Skip final semicolon */
- };
- Local[i++] = 0x01; /* len byte */
- Local[i++] = DBG_S_C_ENUM_END;
- VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
- i = 0;
- pnt1 = pnt + 1;
- break;
- case 'a':
- spnt->advanced = ARRAY;
- spnt->VMS_type = DBG_S_C_ADVANCED_TYPE;
- pnt = (char *) strchr (pnt, ';');
- if (pnt == (char *) NULL)
- return 1;
- pnt1 = cvt_integer (pnt + 1, &spnt->index_min);
- pnt1 = cvt_integer (pnt1 + 1, &spnt->index_max);
- pnt1 = cvt_integer (pnt1 + 1, &spnt->type2);
- break;
- case 'f':
- spnt->advanced = FUNCTION;
- spnt->VMS_type = DBG_S_C_FUNCTION_ADDR;
- /* this masquerades as a basic type*/
- spnt->data_size = 4;
- pnt1 = cvt_integer (pnt + 1, &spnt->type2);
- break;
- case '*':
- spnt->advanced = POINTER;
- spnt->VMS_type = DBG_S_C_ADVANCED_TYPE;
- spnt->data_size = 4;
- pnt1 = cvt_integer (pnt + 1, &spnt->type2);
- pnt = (char *) strchr (str + 1, '=');
- if ((pnt != (char *) NULL))
- if (VMS_typedef_parse (pnt) == 1)
- return 1;
- break;
- default:
- spnt->advanced = UNKNOWN;
- spnt->VMS_type = 0;
- printf ("gcc-as warning(debugger output):");
- printf (" %d is an unknown type of variable.\n", spnt->dbx_type);
- return 1; /* unable to decipher */
- };
-/* this removes the evidence of the definition so that the outer levels of
-parsing do not have to worry about it */
- pnt = str;
- while (*pnt1 != '\0')
- *pnt++ = *pnt1++;
- *pnt = '\0';
- return 0;
-}
-
-
-/*
- * This is the root routine that parses the stabs entries for definitions.
- * it calls VMS_typedef_parse, which can in turn call itself.
- * We need to be careful, since sometimes there are forward references to
- * other symbol types, and these cannot be resolved until we have completed
- * the parse.
- */
-static int
-VMS_LSYM_Parse ()
-{
- char *pnt;
- char *pnt1;
- char *pnt2;
- char *str;
- char fixit[10];
- int incomplete, i, pass, incom1;
- struct VMS_DBG_Symbol *spnt;
- struct VMS_Symbol *vsp;
- struct forward_ref *fpnt;
- symbolS *sp;
- pass = 0;
- incomplete = 0;
- do
- {
- incom1 = incomplete;
- incomplete = 0;
- for (sp = symbol_rootP; sp; sp = symbol_next (sp))
- {
- /*
- * Deal with STAB symbols
- */
- if (S_IS_DEBUG (sp))
- {
- /*
- * Dispatch on STAB type
- */
- switch (S_GET_RAW_TYPE (sp))
- {
- case N_GSYM:
- case N_LCSYM:
- case N_STSYM:
- case N_PSYM:
- case N_RSYM:
- case N_LSYM:
- case N_FUN: /*sometimes these contain typedefs*/
- str = S_GET_NAME (sp);
- symbol_name = str;
- pnt = (char *) strchr (str, ':');
- if (pnt == (char *) NULL)
- break;
- *pnt = '\0';
- pnt1 = pnt + 1;
- pnt2 = (char *) strchr (pnt1, '=');
- if (pnt2 == (char *) NULL)
- {
- *pnt = ':'; /* replace colon */
- break;
- }; /* no symbol here */
- incomplete += VMS_typedef_parse (pnt2);
- *pnt = ':'; /* put back colon so variable def code finds dbx_type*/
- break;
- } /*switch*/
- } /* if */
- } /*for*/
- pass++;
- } while ((incomplete != 0) && (incomplete != incom1));
- /* repeat until all refs resolved if possible */
-/* if (pass > 1) printf(" Required %d passes\n",pass);*/
- if (incomplete != 0)
- {
- printf ("gcc-as warning(debugger output):");
- printf ("Unable to resolve %d circular references.\n", incomplete);
- };
- fpnt = f_ref_root;
- symbol_name = "\0";
- while (fpnt != (struct forward_ref *) NULL)
- {
- if (fpnt->resolved != 'Y')
- {
- if (find_symbol (fpnt->dbx_type) !=
- (struct VMS_DBG_Symbol *) NULL)
- {
- printf ("gcc-as warning(debugger output):");
- printf ("Forward reference error, dbx type %d\n",
- fpnt->dbx_type);
- break;
- };
- fixit[0] = 0;
- sprintf (&fixit[1], "%d=s4;", fpnt->dbx_type);
- pnt2 = (char *) strchr (&fixit[1], '=');
- VMS_typedef_parse (pnt2);
- };
- fpnt = fpnt->next;
- };
-}
-
-static
-Define_Local_Symbols (s1, s2)
- symbolS *s1, *s2;
-{
- symbolS *symbolP1;
- for (symbolP1 = symbol_next (s1); symbolP1 != s2; symbolP1 = symbol_next (symbolP1))
- {
- if (symbolP1 == (symbolS *) NULL)
- return;
- if (S_GET_RAW_TYPE (symbolP1) == N_FUN)
- {
- char * pnt=(char*) strchr (S_GET_NAME (symbolP1), ':') + 1;
- if (*pnt == 'F' || *pnt == 'f') break;
- };
- /*
- * Deal with STAB symbols
- */
- if (S_IS_DEBUG (symbolP1))
- {
- /*
- * Dispatch on STAB type
- */
- switch (S_GET_RAW_TYPE (symbolP1))
- {
- case N_LSYM:
- case N_PSYM:
- VMS_local_stab_Parse (symbolP1);
- break;
- case N_RSYM:
- VMS_RSYM_Parse (symbolP1, Current_Routine, Text_Psect);
- break;
- } /*switch*/
- } /* if */
- } /* for */
-}
-
-
-/* This function crawls the symbol chain searching for local symbols that need
- * to be described to the debugger. When we enter a new scope with a "{", it
- * creates a new "block", which helps the debugger keep track of which scope
- * we are currently in.
- */
-
-static symbolS *
-Define_Routine (symbolP, Level)
- symbolS *symbolP;
- int Level;
-{
- symbolS *sstart;
- symbolS *symbolP1;
- char str[10];
- int rcount = 0;
- int Offset;
- sstart = symbolP;
- for (symbolP1 = symbol_next (symbolP); symbolP1; symbolP1 = symbol_next (symbolP1))
- {
- if (S_GET_RAW_TYPE (symbolP1) == N_FUN)
- {
- char * pnt=(char*) strchr (S_GET_NAME (symbolP1), ':') + 1;
- if (*pnt == 'F' || *pnt == 'f') break;
- };
- /*
- * Deal with STAB symbols
- */
- if (S_IS_DEBUG (symbolP1))
- {
- /*
- * Dispatch on STAB type
- */
- switch (S_GET_RAW_TYPE (symbolP1))
- {
- case N_LBRAC:
- if (Level != 0)
- {
- sprintf (str, "$%d", rcount++);
- VMS_TBT_Block_Begin (symbolP1, Text_Psect, str);
- };
- Offset = S_GET_VALUE (symbolP1);
- Define_Local_Symbols (sstart, symbolP1);
- symbolP1 =
- Define_Routine (symbolP1, Level + 1);
- if (Level != 0)
- VMS_TBT_Block_End (S_GET_VALUE (symbolP1) -
- Offset);
- sstart = symbolP1;
- break;
- case N_RBRAC:
- return symbolP1;
- } /*switch*/
- } /* if */
- } /* for */
- /* we end up here if there were no brackets in this function. Define
-everything */
- Define_Local_Symbols (sstart, (symbolS *) 0);
- return symbolP1;
-}
-
-
-static
-VMS_DBG_Define_Routine (symbolP, Curr_Routine, Txt_Psect)
- symbolS *symbolP;
- symbolS *Curr_Routine;
- int Txt_Psect;
-{
- Current_Routine = Curr_Routine;
- Text_Psect = Txt_Psect;
- Define_Routine (symbolP, 0);
-}
-
-
-
-
-#ifndef HO_VMS
-#include <sys/types.h>
-#include <time.h>
-
-/* Manufacure a VMS like time on a unix based system. */
-get_VMS_time_on_unix (char *Now)
-{
- char *pnt;
- time_t timeb;
- time (&timeb);
- pnt = ctime (&timeb);
- pnt[3] = 0;
- pnt[7] = 0;
- pnt[10] = 0;
- pnt[16] = 0;
- pnt[24] = 0;
- sprintf (Now, "%2s-%3s-%s %s", pnt + 8, pnt + 4, pnt + 20, pnt + 11);
-}
-
-#endif /* not HO_VMS */
-/*
- * Write the MHD (Module Header) records
- */
-static
-Write_VMS_MHD_Records ()
-{
- register char *cp, *cp1;
- register int i;
- struct
- {
- int Size;
- char *Ptr;
- } Descriptor;
- char Module_Name[256];
- char Now[18];
-
- /*
- * We are writing a module header record
- */
- Set_VMS_Object_File_Record (OBJ_S_C_HDR);
- /*
- * ***************************
- * *MAIN MODULE HEADER RECORD*
- * ***************************
- *
- * Store record type and header type
- */
- PUT_CHAR (OBJ_S_C_HDR);
- PUT_CHAR (MHD_S_C_MHD);
- /*
- * Structure level is 0
- */
- PUT_CHAR (OBJ_S_C_STRLVL);
- /*
- * Maximum record size is size of the object record buffer
- */
- PUT_SHORT (sizeof (Object_Record_Buffer));
- /*
- * Get module name (the FILENAME part of the object file)
- */
- cp = out_file_name;
- cp1 = Module_Name;
- while (*cp)
- {
- if ((*cp == ']') || (*cp == '>') ||
- (*cp == ':') || (*cp == '/'))
- {
- cp1 = Module_Name;
- cp++;
- continue;
- }
- *cp1++ = islower (*cp) ? toupper (*cp++) : *cp++;
- }
- *cp1 = 0;
- /*
- * Limit it to 31 characters and store in the object record
- */
- while (--cp1 >= Module_Name)
- if (*cp1 == '.')
- *cp1 = 0;
- if (strlen (Module_Name) > 31)
- {
- if (flagseen['+'])
- printf ("%s: Module name truncated: %s\n", myname, Module_Name);
- Module_Name[31] = 0;
- }
- PUT_COUNTED_STRING (Module_Name);
- /*
- * Module Version is "V1.0"
- */
- PUT_COUNTED_STRING ("V1.0");
- /*
- * Creation time is "now" (17 chars of time string)
- */
-#ifndef HO_VMS
- get_VMS_time_on_unix (&Now[0]);
-#else /* HO_VMS */
- Descriptor.Size = 17;
- Descriptor.Ptr = Now;
- sys$asctim (0, &Descriptor, 0, 0);
-#endif /* HO_VMS */
- for (i = 0; i < 17; i++)
- PUT_CHAR (Now[i]);
- /*
- * Patch time is "never" (17 zeros)
- */
- for (i = 0; i < 17; i++)
- PUT_CHAR (0);
- /*
- * Flush the record
- */
- Flush_VMS_Object_Record_Buffer ();
- /*
- * *************************
- * *LANGUAGE PROCESSOR NAME*
- * *************************
- *
- * Store record type and header type
- */
- PUT_CHAR (OBJ_S_C_HDR);
- PUT_CHAR (MHD_S_C_LNM);
- /*
- * Store language processor name and version
- * (not a counted string!)
- */
- cp = compiler_version_string;
- if (cp == 0)
- {
- cp = "GNU AS V";
- while (*cp)
- PUT_CHAR (*cp++);
- cp = strchr (&version_string, '.');
- while (*cp != ' ')
- cp--;
- cp++;
- };
- while (*cp >= 32)
- PUT_CHAR (*cp++);
- /*
- * Flush the record
- */
- Flush_VMS_Object_Record_Buffer ();
-}
-
-
-/*
- * Write the EOM (End Of Module) record
- */
-static
-Write_VMS_EOM_Record (Psect, Offset)
- int Psect;
- int Offset;
-{
- /*
- * We are writing an end-of-module record
- */
- Set_VMS_Object_File_Record (OBJ_S_C_EOM);
- /*
- * Store record Type
- */
- PUT_CHAR (OBJ_S_C_EOM);
- /*
- * Store the error severity (0)
- */
- PUT_CHAR (0);
- /*
- * Store the entry point, if it exists
- */
- if (Psect >= 0)
- {
- /*
- * Store the entry point Psect
- */
- PUT_CHAR (Psect);
- /*
- * Store the entry point Psect offset
- */
- PUT_LONG (Offset);
- }
- /*
- * Flush the record
- */
- Flush_VMS_Object_Record_Buffer ();
-}
-
-
-/* this hash routine borrowed from GNU-EMACS, and strengthened slightly ERY*/
-
-static int
-hash_string (ptr)
- unsigned char *ptr;
-{
- register unsigned char *p = ptr;
- register unsigned char *end = p + strlen (ptr);
- register unsigned char c;
- register int hash = 0;
-
- while (p != end)
- {
- c = *p++;
- hash = ((hash << 3) + (hash << 15) + (hash >> 28) + c);
- }
- return hash;
-}
-
-/*
- * Generate a Case-Hacked VMS symbol name (limited to 31 chars)
- */
-static
-VMS_Case_Hack_Symbol (In, Out)
- register char *In;
- register char *Out;
-{
- long int init = 0;
- long int result;
- char *pnt;
- char *new_name;
- char *old_name;
- register int i;
- int destructor = 0; /*hack to allow for case sens in a destructor*/
- int truncate = 0;
- int Case_Hack_Bits = 0;
- int Saw_Dollar = 0;
- static char Hex_Table[16] =
- {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
-
- /*
- * Kill any leading "_"
- */
- if ((In[0] == '_') && ((In[1] > '9') || (In[1] < '0')))
- In++;
-
- new_name = Out; /* save this for later*/
-
-#if barfoo /* Dead code */
- if ((In[0] == '_') && (In[1] == '$') && (In[2] == '_'))
- destructor = 1;
-#endif
-
- /* We may need to truncate the symbol, save the hash for later*/
- if (strlen (In) > 23)
- result = hash_string (In);
- /*
- * Is there a Psect Attribute to skip??
- */
- if (HAS_PSECT_ATTRIBUTES (In))
- {
- /*
- * Yes: Skip it
- */
- In += PSECT_ATTRIBUTES_STRING_LENGTH;
- while (*In)
- {
- if ((In[0] == '$') && (In[1] == '$'))
- {
- In += 2;
- break;
- }
- In++;
- }
- }
-
- old_name = In;
-/* if (strlen(In) > 31 && flagseen['+'])
- printf("%s: Symbol name truncated: %s\n",myname,In);*/
- /*
- * Do the case conversion
- */
- i = 23; /* Maximum of 23 chars */
- while (*In && (--i >= 0))
- {
- Case_Hack_Bits <<= 1;
- if (*In == '$')
- Saw_Dollar = 1;
- if ((destructor == 1) && (i == 21))
- Saw_Dollar = 0;
- switch (vms_name_mapping)
- {
- case 0:
- if (isupper(*In)) {
- *Out++ = *In++;
- Case_Hack_Bits |= 1;
- } else {
- *Out++ = islower(*In) ? toupper(*In++) : *In++;
- }
- break;
- case 3: *Out++ = *In++;
- break;
- case 2:
- if (islower(*In)) {
- *Out++ = *In++;
- } else {
- *Out++ = isupper(*In) ? tolower(*In++) : *In++;
- }
- break;
- };
- }
- /*
- * If we saw a dollar sign, we don't do case hacking
- */
- if (flagseen['h'] || Saw_Dollar)
- Case_Hack_Bits = 0;
-
- /*
- * If we have more than 23 characters and everything is lowercase
- * we can insert the full 31 characters
- */
- if (*In)
- {
- /*
- * We have more than 23 characters
- * If we must add the case hack, then we have truncated the str
- */
- pnt = Out;
- truncate = 1;
- if (Case_Hack_Bits == 0)
- {
- /*
- * And so far they are all lower case:
- * Check up to 8 more characters
- * and ensure that they are lowercase
- */
- for (i = 0; (In[i] != 0) && (i < 8); i++)
- if (isupper(In[i]) && !Saw_Dollar && !flagseen['h'])
- break;
-
- if (In[i] == 0)
- truncate = 0;
-
- if ((i == 8) || (In[i] == 0))
- {
- /*
- * They are: Copy up to 31 characters
- * to the output string
- */
- i = 8;
- while ((--i >= 0) && (*In))
- switch (vms_name_mapping){
- case 0: *Out++ = islower(*In) ?
- toupper (*In++) :
- *In++;
- break;
- case 3: *Out++ = *In++;
- break;
- case 2: *Out++ = isupper(*In) ?
- tolower(*In++) :
- *In++;
- break;
- };
- }
- }
- }
- /*
- * If there were any uppercase characters in the name we
- * take on the case hacking string
- */
-
- /* Old behavior for regular GNU-C compiler */
- if (!flagseen['+'])
- truncate = 0;
- if ((Case_Hack_Bits != 0) || (truncate == 1))
- {
- if (truncate == 0)
- {
- *Out++ = '_';
- for (i = 0; i < 6; i++)
- {
- *Out++ = Hex_Table[Case_Hack_Bits & 0xf];
- Case_Hack_Bits >>= 4;
- }
- *Out++ = 'X';
- }
- else
- {
- Out = pnt; /*Cut back to 23 characters maximum */
- *Out++ = '_';
- for (i = 0; i < 7; i++)
- {
- init = result & 0x01f;
- if (init < 10)
- *Out++ = '0' + init;
- else
- *Out++ = 'A' + init - 10;
- result = result >> 5;
- }
- }
- } /*Case Hack */
- /*
- * Done
- */
- *Out = 0;
- if (truncate == 1 && flagseen['+'] && flagseen['H'])
- printf ("%s: Symbol %s replaced by %s\n", myname, old_name, new_name);
-}
-
-
-/*
- * Scan a symbol name for a psect attribute specification
- */
-#define GLOBALSYMBOL_BIT 0x10000
-#define GLOBALVALUE_BIT 0x20000
-
-
-static
-VMS_Modify_Psect_Attributes (Name, Attribute_Pointer)
- char *Name;
- int *Attribute_Pointer;
-{
- register int i;
- register char *cp;
- int Negate;
- static struct
- {
- char *Name;
- int Value;
- } Attributes[] =
- {
- {"PIC", GPS_S_M_PIC},
- {"LIB", GPS_S_M_LIB},
- {"OVR", GPS_S_M_OVR},
- {"REL", GPS_S_M_REL},
- {"GBL", GPS_S_M_GBL},
- {"SHR", GPS_S_M_SHR},
- {"EXE", GPS_S_M_EXE},
- {"RD", GPS_S_M_RD},
- {"WRT", GPS_S_M_WRT},
- {"VEC", GPS_S_M_VEC},
- {"GLOBALSYMBOL", GLOBALSYMBOL_BIT},
- {"GLOBALVALUE", GLOBALVALUE_BIT},
- {0, 0}
- };
-
- /*
- * Kill leading "_"
- */
- if (*Name == '_')
- Name++;
- /*
- * Check for a PSECT attribute list
- */
- if (!HAS_PSECT_ATTRIBUTES (Name))
- return; /* If not, return */
- /*
- * Skip the attribute list indicator
- */
- Name += PSECT_ATTRIBUTES_STRING_LENGTH;
- /*
- * Process the attributes ("_" separated, "$" terminated)
- */
- while (*Name != '$')
- {
- /*
- * Assume not negating
- */
- Negate = 0;
- /*
- * Check for "NO"
- */
- if ((Name[0] == 'N') && (Name[1] == 'O'))
- {
- /*
- * We are negating (and skip the NO)
- */
- Negate = 1;
- Name += 2;
- }
- /*
- * Find the token delimiter
- */
- cp = Name;
- while (*cp && (*cp != '_') && (*cp != '$'))
- cp++;
- /*
- * Look for the token in the attribute list
- */
- for (i = 0; Attributes[i].Name; i++)
- {
- /*
- * If the strings match, set/clear the attr.
- */
- if (strncmp (Name, Attributes[i].Name, cp - Name) == 0)
- {
- /*
- * Set or clear
- */
- if (Negate)
- *Attribute_Pointer &=
- ~Attributes[i].Value;
- else
- *Attribute_Pointer |=
- Attributes[i].Value;
- /*
- * Done
- */
- break;
- }
- }
- /*
- * Now skip the attribute
- */
- Name = cp;
- if (*Name == '_')
- Name++;
- }
- /*
- * Done
- */
- return;
-}
-
-
-/*
- * Define a global symbol
- */
-static
-VMS_Global_Symbol_Spec (Name, Psect_Number, Psect_Offset, Defined)
- char *Name;
- int Psect_Number;
- int Psect_Offset;
-{
- char Local[32];
-
- /*
- * We are writing a GSD record
- */
- Set_VMS_Object_File_Record (OBJ_S_C_GSD);
- /*
- * If the buffer is empty we must insert the GSD record type
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (OBJ_S_C_GSD);
- /*
- * We are writing a Global symbol definition subrecord
- */
- if (Psect_Number <= 255)
- {
- PUT_CHAR (GSD_S_C_SYM);
- }
- else
- {
- PUT_CHAR (GSD_S_C_SYMW);
- }
- /*
- * Data type is undefined
- */
- PUT_CHAR (0);
- /*
- * Switch on Definition/Reference
- */
- if ((Defined & 1) != 0)
- {
- /*
- * Definition:
- * Flags = "RELOCATABLE" and "DEFINED" for regular symbol
- * = "DEFINED" for globalvalue (Defined & 2 == 1)
- */
- if ((Defined & 2) == 0)
- {
- PUT_SHORT (GSY_S_M_DEF | GSY_S_M_REL);
- }
- else
- {
- PUT_SHORT (GSY_S_M_DEF);
- };
- /*
- * Psect Number
- */
- if (Psect_Number <= 255)
- {
- PUT_CHAR (Psect_Number);
- }
- else
- {
- PUT_SHORT (Psect_Number);
- }
- /*
- * Offset
- */
- PUT_LONG (Psect_Offset);
- }
- else
- {
- /*
- * Reference:
- * Flags = "RELOCATABLE" for regular symbol,
- * = "" for globalvalue (Defined & 2 == 1)
- */
- if ((Defined & 2) == 0)
- {
- PUT_SHORT (GSY_S_M_REL);
- }
- else
- {
- PUT_SHORT (0);
- };
- }
- /*
- * Finally, the global symbol name
- */
- VMS_Case_Hack_Symbol (Name, Local);
- PUT_COUNTED_STRING (Local);
- /*
- * Flush the buffer if it is more than 75% full
- */
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
-}
-
-
-/*
- * Define a psect
- */
-static int
-VMS_Psect_Spec (Name, Size, Type, vsp)
- char *Name;
- int Size;
- char *Type;
- struct VMS_Symbol *vsp;
-{
- char Local[32];
- int Psect_Attributes;
-
- /*
- * Generate the appropriate PSECT flags given the PSECT type
- */
- if (strcmp (Type, "COMMON") == 0)
- {
- /*
- * Common block psects are: PIC,OVR,REL,GBL,SHR,RD,WRT
- */
- Psect_Attributes = (GPS_S_M_PIC | GPS_S_M_OVR | GPS_S_M_REL | GPS_S_M_GBL |
- GPS_S_M_SHR | GPS_S_M_RD | GPS_S_M_WRT);
- }
- else if (strcmp (Type, "CONST") == 0)
- {
- /*
- * Common block psects are: PIC,OVR,REL,GBL,SHR,RD
- */
- Psect_Attributes = (GPS_S_M_PIC | GPS_S_M_OVR | GPS_S_M_REL | GPS_S_M_GBL |
- GPS_S_M_SHR | GPS_S_M_RD);
- }
- else if (strcmp (Type, "DATA") == 0)
- {
- /*
- * The Data psects are PIC,REL,RD,WRT
- */
- Psect_Attributes =
- (GPS_S_M_PIC | GPS_S_M_REL | GPS_S_M_RD | GPS_S_M_WRT);
- }
- else if (strcmp (Type, "TEXT") == 0)
- {
- /*
- * The Text psects are PIC,REL,SHR,EXE,RD
- */
- Psect_Attributes =
- (GPS_S_M_PIC | GPS_S_M_REL | GPS_S_M_SHR |
- GPS_S_M_EXE | GPS_S_M_RD);
- }
- else
- {
- /*
- * Error: Unknown psect type
- */
- error ("Unknown VMS psect type");
- }
- /*
- * Modify the psect attributes according to any attribute string
- */
- if (HAS_PSECT_ATTRIBUTES (Name))
- VMS_Modify_Psect_Attributes (Name, &Psect_Attributes);
- /*
- * Check for globalref/def/val.
- */
- if ((Psect_Attributes & GLOBALVALUE_BIT) != 0)
- {
- /*
- * globalvalue symbols were generated before. This code
- * prevents unsightly psect buildup, and makes sure that
- * fixup references are emitted correctly.
- */
- vsp->Psect_Index = -1; /* to catch errors */
- S_GET_RAW_TYPE (vsp->Symbol) = N_UNDF; /* make refs work */
- return 1; /* decrement psect counter */
- };
-
- if ((Psect_Attributes & GLOBALSYMBOL_BIT) != 0)
- {
- switch (S_GET_RAW_TYPE (vsp->Symbol))
- {
- case N_UNDF | N_EXT:
- VMS_Global_Symbol_Spec (Name, vsp->Psect_Index,
- vsp->Psect_Offset, 0);
- vsp->Psect_Index = -1;
- S_GET_RAW_TYPE (vsp->Symbol) = N_UNDF;
- return 1; /* return and indicate no psect */
- case N_DATA | N_EXT:
- VMS_Global_Symbol_Spec (Name, vsp->Psect_Index,
- vsp->Psect_Offset, 1);
- /* In this case we still generate the psect */
- break;
- default:
- {
- char Error_Line[256];
- sprintf (Error_Line, "Globalsymbol attribute for"
- " symbol %s was unexpected.\n", Name);
- error (Error_Line);
- break;
- };
- }; /* switch */
- };
-
- Psect_Attributes &= 0xffff; /* clear out the globalref/def stuff */
- /*
- * We are writing a GSD record
- */
- Set_VMS_Object_File_Record (OBJ_S_C_GSD);
- /*
- * If the buffer is empty we must insert the GSD record type
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (OBJ_S_C_GSD);
- /*
- * We are writing a PSECT definition subrecord
- */
- PUT_CHAR (GSD_S_C_PSC);
- /*
- * Psects are always LONGWORD aligned
- */
- PUT_CHAR (2);
- /*
- * Specify the psect attributes
- */
- PUT_SHORT (Psect_Attributes);
- /*
- * Specify the allocation
- */
- PUT_LONG (Size);
- /*
- * Finally, the psect name
- */
- VMS_Case_Hack_Symbol (Name, Local);
- PUT_COUNTED_STRING (Local);
- /*
- * Flush the buffer if it is more than 75% full
- */
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
- return 0;
-}
-
-
-/*
- * Given the pointer to a symbol we calculate how big the data at the
- * symbol is. We do this by looking for the next symbol (local or
- * global) which will indicate the start of another datum.
- */
-static int
-VMS_Initialized_Data_Size (sp, End_Of_Data)
- register struct symbol *sp;
- int End_Of_Data;
-{
- register struct symbol *sp1, *Next_Symbol;
-
- /*
- * Find the next symbol
- * it delimits this datum
- */
- Next_Symbol = 0;
- for (sp1 = symbol_rootP; sp1; sp1 = symbol_next (sp1))
- {
- /*
- * The data type must match
- */
- if (S_GET_TYPE (sp1) != N_DATA)
- continue;
- /*
- * The symbol must be AFTER this symbol
- */
- if (S_GET_VALUE (sp1) <= S_GET_VALUE (sp))
- continue;
- /*
- * We ignore THIS symbol
- */
- if (sp1 == sp)
- continue;
- /*
- * If there is already a candidate selected for the
- * next symbol, see if we are a better candidate
- */
- if (Next_Symbol)
- {
- /*
- * We are a better candidate if we are "closer"
- * to the symbol
- */
- if (S_GET_VALUE (sp1) >
- S_GET_VALUE (Next_Symbol))
- continue;
- /*
- * Win: Make this the candidate
- */
- Next_Symbol = sp1;
- }
- else
- {
- /*
- * This is the 1st candidate
- */
- Next_Symbol = sp1;
- }
- }
- /*
- * Calculate its size
- */
- return (Next_Symbol ?
- (S_GET_VALUE (Next_Symbol) -
- S_GET_VALUE (sp)) :
- (End_Of_Data - S_GET_VALUE (sp)));
-}
-
-/*
- * Check symbol names for the Psect hack with a globalvalue, and then
- * generate globalvalues for those that have it.
- */
-static
-VMS_Emit_Globalvalues (text_siz, data_siz, Data_Segment)
- unsigned text_siz;
- unsigned data_siz;
- char *Data_Segment;
-{
- register symbolS *sp;
- char *stripped_name, *Name;
- int Size;
- int Psect_Attributes;
- int globalvalue;
-
- /*
- * Scan the symbol table for globalvalues, and emit def/ref when
- * required. These will be caught again later and converted to
- * N_UNDF
- */
- for (sp = symbol_rootP; sp; sp = sp->sy_next)
- {
- /*
- * See if this is something we want to look at.
- */
- if ((S_GET_RAW_TYPE (sp) != (N_DATA | N_EXT)) &&
- (S_GET_RAW_TYPE (sp) != (N_UNDF | N_EXT)))
- continue;
- /*
- * See if this has globalvalue specification.
- */
- Name = S_GET_NAME (sp);
-
- if (!HAS_PSECT_ATTRIBUTES (Name))
- continue;
-
- stripped_name = (char *) malloc (strlen (Name) + 1);
- strcpy (stripped_name, Name);
- Psect_Attributes = 0;
- VMS_Modify_Psect_Attributes (stripped_name, &Psect_Attributes);
-
- if ((Psect_Attributes & GLOBALVALUE_BIT) != 0)
- {
- switch (S_GET_RAW_TYPE (sp))
- {
- case N_UNDF | N_EXT:
- VMS_Global_Symbol_Spec (stripped_name, 0, 0, 2);
- break;
- case N_DATA | N_EXT:
- Size = VMS_Initialized_Data_Size (sp, text_siz + data_siz);
- if (Size > 4)
- error ("Invalid data type for globalvalue");
- globalvalue = 0;
-
- memcpy (&globalvalue, Data_Segment + S_GET_VALUE (sp) -
- text_siz, Size);
- /* Three times for good luck. The linker seems to get confused
- if there are fewer than three */
- VMS_Global_Symbol_Spec (stripped_name, 0, 0, 2);
- VMS_Global_Symbol_Spec (stripped_name, 0, globalvalue, 3);
- VMS_Global_Symbol_Spec (stripped_name, 0, globalvalue, 3);
- break;
- default:
- printf (" Invalid globalvalue of %s\n", stripped_name);
- break;
- }; /* switch */
- }; /* if */
- free (stripped_name); /* clean up */
- }; /* for */
-
-}
-
-
-/*
- * Define a procedure entry pt/mask
- */
-static
-VMS_Procedure_Entry_Pt (Name, Psect_Number, Psect_Offset, Entry_Mask)
- char *Name;
- int Psect_Number;
- int Psect_Offset;
- int Entry_Mask;
-{
- char Local[32];
-
- /*
- * We are writing a GSD record
- */
- Set_VMS_Object_File_Record (OBJ_S_C_GSD);
- /*
- * If the buffer is empty we must insert the GSD record type
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (OBJ_S_C_GSD);
- /*
- * We are writing a Procedure Entry Pt/Mask subrecord
- */
- if (Psect_Number <= 255)
- {
- PUT_CHAR (GSD_S_C_EPM);
- }
- else
- {
- PUT_CHAR (GSD_S_C_EPMW);
- }
- /*
- * Data type is undefined
- */
- PUT_CHAR (0);
- /*
- * Flags = "RELOCATABLE" and "DEFINED"
- */
- PUT_SHORT (GSY_S_M_DEF | GSY_S_M_REL);
- /*
- * Psect Number
- */
- if (Psect_Number <= 255)
- {
- PUT_CHAR (Psect_Number);
- }
- else
- {
- PUT_SHORT (Psect_Number);
- }
- /*
- * Offset
- */
- PUT_LONG (Psect_Offset);
- /*
- * Entry mask
- */
- PUT_SHORT (Entry_Mask);
- /*
- * Finally, the global symbol name
- */
- VMS_Case_Hack_Symbol (Name, Local);
- PUT_COUNTED_STRING (Local);
- /*
- * Flush the buffer if it is more than 75% full
- */
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
-}
-
-
-/*
- * Set the current location counter to a particular Psect and Offset
- */
-static
-VMS_Set_Psect (Psect_Index, Offset, Record_Type)
- int Psect_Index;
- int Offset;
- int Record_Type;
-{
- /*
- * We are writing a "Record_Type" record
- */
- Set_VMS_Object_File_Record (Record_Type);
- /*
- * If the buffer is empty we must insert the record type
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (Record_Type);
- /*
- * Stack the Psect base + Longword Offset
- */
- if (Psect_Index < 255)
- {
- PUT_CHAR (TIR_S_C_STA_PL);
- PUT_CHAR (Psect_Index);
- }
- else
- {
- PUT_CHAR (TIR_S_C_STA_WPL);
- PUT_SHORT (Psect_Index);
- }
- PUT_LONG (Offset);
- /*
- * Set relocation base
- */
- PUT_CHAR (TIR_S_C_CTL_SETRB);
- /*
- * Flush the buffer if it is more than 75% full
- */
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
-}
-
-
-/*
- * Store repeated immediate data in current Psect
- */
-static
-VMS_Store_Repeated_Data (Repeat_Count, Pointer, Size, Record_Type)
- int Repeat_Count;
- register char *Pointer;
- int Size;
- int Record_Type;
-{
-
- /*
- * Ignore zero bytes/words/longwords
- */
- if ((Size == sizeof (char)) && (*Pointer == 0))
- return;
- if ((Size == sizeof (short)) && (*(short *) Pointer == 0))
- return;
- if ((Size == sizeof (long)) && (*(long *) Pointer == 0))
- return;
- /*
- * If the data is too big for a TIR_S_C_STO_RIVB sub-record
- * then we do it manually
- */
- if (Size > 255)
- {
- while (--Repeat_Count >= 0)
- VMS_Store_Immediate_Data (Pointer, Size, Record_Type);
- return;
- }
- /*
- * We are writing a "Record_Type" record
- */
- Set_VMS_Object_File_Record (Record_Type);
- /*
- * If the buffer is empty we must insert record type
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (Record_Type);
- /*
- * Stack the repeat count
- */
- PUT_CHAR (TIR_S_C_STA_LW);
- PUT_LONG (Repeat_Count);
- /*
- * And now the command and its data
- */
- PUT_CHAR (TIR_S_C_STO_RIVB);
- PUT_CHAR (Size);
- while (--Size >= 0)
- PUT_CHAR (*Pointer++);
- /*
- * Flush the buffer if it is more than 75% full
- */
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
-}
-
-
-/*
- * Store a Position Independent Reference
- */
-static
-VMS_Store_PIC_Symbol_Reference (Symbol, Offset, PC_Relative,
- Psect, Psect_Offset, Record_Type)
- struct symbol *Symbol;
- int Offset;
- int PC_Relative;
- int Psect;
- int Psect_Offset;
- int Record_Type;
-{
- register struct VMS_Symbol *vsp =
- (struct VMS_Symbol *) (Symbol->sy_number);
- char Local[32];
-
- /*
- * We are writing a "Record_Type" record
- */
- Set_VMS_Object_File_Record (Record_Type);
- /*
- * If the buffer is empty we must insert record type
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (Record_Type);
- /*
- * Set to the appropriate offset in the Psect
- */
- if (PC_Relative)
- {
- /*
- * For a Code reference we need to fix the operand
- * specifier as well (so back up 1 byte)
- */
- VMS_Set_Psect (Psect, Psect_Offset - 1, Record_Type);
- }
- else
- {
- /*
- * For a Data reference we just store HERE
- */
- VMS_Set_Psect (Psect, Psect_Offset, Record_Type);
- }
- /*
- * Make sure we are still generating a "Record Type" record
- */
- if (Object_Record_Offset == 0)
- PUT_CHAR (Record_Type);
- /*
- * Dispatch on symbol type (so we can stack its value)
- */
- switch (S_GET_RAW_TYPE (Symbol))
- {
- /*
- * Global symbol
- */
-#ifdef NOT_VAX_11_C_COMPATIBLE
- case N_UNDF | N_EXT:
- case N_DATA | N_EXT:
-#endif /* NOT_VAX_11_C_COMPATIBLE */
- case N_UNDF:
- case N_TEXT | N_EXT:
- /*
- * Get the symbol name (case hacked)
- */
- VMS_Case_Hack_Symbol (S_GET_NAME (Symbol), Local);
- /*
- * Stack the global symbol value
- */
- PUT_CHAR (TIR_S_C_STA_GBL);
- PUT_COUNTED_STRING (Local);
- if (Offset)
- {
- /*
- * Stack the longword offset
- */
- PUT_CHAR (TIR_S_C_STA_LW);
- PUT_LONG (Offset);
- /*
- * Add the two, leaving the result on the stack
- */
- PUT_CHAR (TIR_S_C_OPR_ADD);
- }
- break;
- /*
- * Uninitialized local data
- */
- case N_BSS:
- /*
- * Stack the Psect (+offset)
- */
- if (vsp->Psect_Index < 255)
- {
- PUT_CHAR (TIR_S_C_STA_PL);
- PUT_CHAR (vsp->Psect_Index);
- }
- else
- {
- PUT_CHAR (TIR_S_C_STA_WPL);
- PUT_SHORT (vsp->Psect_Index);
- }
- PUT_LONG (vsp->Psect_Offset + Offset);
- break;
- /*
- * Local text
- */
- case N_TEXT:
- /*
- * Stack the Psect (+offset)
- */
- if (vsp->Psect_Index < 255)
- {
- PUT_CHAR (TIR_S_C_STA_PL);
- PUT_CHAR (vsp->Psect_Index);
- }
- else
- {
- PUT_CHAR (TIR_S_C_STA_WPL);
- PUT_SHORT (vsp->Psect_Index);
- }
- PUT_LONG (S_GET_VALUE (Symbol) + Offset);
- break;
- /*
- * Initialized local or global data
- */
- case N_DATA:
-#ifndef NOT_VAX_11_C_COMPATIBLE
- case N_UNDF | N_EXT:
- case N_DATA | N_EXT:
-#endif /* NOT_VAX_11_C_COMPATIBLE */
- /*
- * Stack the Psect (+offset)
- */
- if (vsp->Psect_Index < 255)
- {
- PUT_CHAR (TIR_S_C_STA_PL);
- PUT_CHAR (vsp->Psect_Index);
- }
- else
- {
- PUT_CHAR (TIR_S_C_STA_WPL);
- PUT_SHORT (vsp->Psect_Index);
- }
- PUT_LONG (vsp->Psect_Offset + Offset);
- break;
- }
- /*
- * Store either a code or data reference
- */
- PUT_CHAR (PC_Relative ? TIR_S_C_STO_PICR : TIR_S_C_STO_PIDR);
- /*
- * Flush the buffer if it is more than 75% full
- */
- if (Object_Record_Offset >
- (sizeof (Object_Record_Buffer) * 3 / 4))
- Flush_VMS_Object_Record_Buffer ();
-}
-
-
-/*
- * Check in the text area for an indirect pc-relative reference
- * and fix it up with addressing mode 0xff [PC indirect]
- *
- * THIS SHOULD BE REPLACED BY THE USE OF TIR_S_C_STO_PIRR IN THE
- * PIC CODE GENERATING FIXUP ROUTINE.
- */
-static
-VMS_Fix_Indirect_Reference (Text_Psect, Offset, fragP, text_frag_root)
- int Text_Psect;
- int Offset;
- register fragS *fragP;
- struct frag *text_frag_root;
-{
- /*
- * The addressing mode byte is 1 byte before the address
- */
- Offset--;
- /*
- * Is it in THIS frag??
- */
- if ((Offset < fragP->fr_address) ||
- (Offset >= (fragP->fr_address + fragP->fr_fix)))
- {
- /*
- * We need to search for the fragment containing this
- * Offset
- */
- for (fragP = text_frag_root; fragP; fragP = fragP->fr_next)
- {
- if ((Offset >= fragP->fr_address) &&
- (Offset < (fragP->fr_address + fragP->fr_fix)))
- break;
- }
- /*
- * If we couldn't find the frag, things are BAD!!
- */
- if (fragP == 0)
- error ("Couldn't find fixup fragment when checking for indirect reference");
- }
- /*
- * Check for indirect PC relative addressing mode
- */
- if (fragP->fr_literal[Offset - fragP->fr_address] == (char) 0xff)
- {
- static char Address_Mode = 0xff;
-
- /*
- * Yes: Store the indirect mode back into the image
- * to fix up the damage done by STO_PICR
- */
- VMS_Set_Psect (Text_Psect, Offset, OBJ_S_C_TIR);
- VMS_Store_Immediate_Data (&Address_Mode, 1, OBJ_S_C_TIR);
- }
-}
-
-
-
-/*
- * This is a hacked _doprnt() for VAX-11 "C". It understands that
- * it is ONLY called by as_fatal(Format, Args) with a pointer to the
- * "Args" argument. From this we can make it all work right!
- */
-#if !defined(eunice) && defined(HO_VMS)
-_doprnt (Format, a, f)
- char *Format;
- FILE *f;
- char **a;
-{
- int Nargs = ((int *) a)[-2]; /* This understands as_fatal() */
-
- switch (Nargs)
- {
- default:
- fprintf (f, "_doprnt error on \"%s\"!!", Format);
- break;
- case 1:
- fprintf (f, Format);
- break;
- case 2:
- fprintf (f, Format, a[0]);
- break;
- case 3:
- fprintf (f, Format, a[0], a[1]);
- break;
- case 4:
- fprintf (f, Format, a[0], a[1], a[2]);
- break;
- case 5:
- fprintf (f, Format, a[0], a[1], a[2], a[3]);
- break;
- case 6:
- fprintf (f, Format, a[0], a[1], a[2], a[3], a[4]);
- break;
- case 7:
- fprintf (f, Format, a[0], a[1], a[2], a[3], a[4], a[5]);
- break;
- case 8:
- fprintf (f, Format, a[0], a[1], a[2], a[3], a[4], a[5], a[6]);
- break;
- case 9:
- fprintf (f, Format, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]);
- break;
- case 10:
- fprintf (f, Format, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
- break;
- }
-}
-
-#endif /* eunice */
-
-
-/*
- * If the procedure "main()" exists we have to add the instruction
- * "jsb c$main_args" at the beginning to be compatible with VAX-11 "C".
- */
-VMS_Check_For_Main ()
-{
- register symbolS *symbolP;
-#ifdef HACK_DEC_C_STARTUP /* JF */
- register struct frchain *frchainP;
- register fragS *fragP;
- register fragS **prev_fragPP;
- register struct fix *fixP;
- register fragS *New_Frag;
- int i;
-#endif /* HACK_DEC_C_STARTUP */
-
- symbolP = (struct symbol *) symbol_find ("_main");
- if (symbolP && !S_IS_DEBUG (symbolP) &&
- S_IS_EXTERNAL (symbolP) && (S_GET_TYPE (symbolP) == N_TEXT))
- {
-#ifdef HACK_DEC_C_STARTUP
- if (!flagseen['+'])
- {
-#endif
- /*
- * Remember the entry point symbol
- */
- Entry_Point_Symbol = symbolP;
-#ifdef HACK_DEC_C_STARTUP
- }
- else
- {
- /*
- * Scan all the fragment chains for the one with "_main"
- * (Actually we know the fragment from the symbol, but we need
- * the previous fragment so we can change its pointer)
- */
- frchainP = frchain_root;
- while (frchainP)
- {
- /*
- * Scan all the fragments in this chain, remembering
- * the "previous fragment"
- */
- prev_fragPP = &frchainP->frch_root;
- fragP = frchainP->frch_root;
- while (fragP && (fragP != frchainP->frch_last))
- {
- /*
- * Is this the fragment?
- */
- if (fragP == symbolP->sy_frag)
- {
- /*
- * Yes: Modify the fragment by replacing
- * it with a new fragment.
- */
- New_Frag = (fragS *)
- xmalloc (sizeof (*New_Frag) +
- fragP->fr_fix +
- fragP->fr_var +
- 5);
- /*
- * The fragments are the same except
- * that the "fixed" area is larger
- */
- *New_Frag = *fragP;
- New_Frag->fr_fix += 6;
- /*
- * Copy the literal data opening a hole
- * 2 bytes after "_main" (i.e. just after
- * the entry mask). Into which we place
- * the JSB instruction.
- */
- New_Frag->fr_literal[0] = fragP->fr_literal[0];
- New_Frag->fr_literal[1] = fragP->fr_literal[1];
- New_Frag->fr_literal[2] = 0x16; /* Jsb */
- New_Frag->fr_literal[3] = 0xef;
- New_Frag->fr_literal[4] = 0;
- New_Frag->fr_literal[5] = 0;
- New_Frag->fr_literal[6] = 0;
- New_Frag->fr_literal[7] = 0;
- for (i = 2; i < fragP->fr_fix + fragP->fr_var; i++)
- New_Frag->fr_literal[i + 6] =
- fragP->fr_literal[i];
- /*
- * Now replace the old fragment with the
- * newly generated one.
- */
- *prev_fragPP = New_Frag;
- /*
- * Remember the entry point symbol
- */
- Entry_Point_Symbol = symbolP;
- /*
- * Scan the text area fixup structures
- * as offsets in the fragment may have
- * changed
- */
- for (fixP = text_fix_root; fixP; fixP = fixP->fx_next)
- {
- /*
- * Look for references to this
- * fragment.
- */
- if (fixP->fx_frag == fragP)
- {
- /*
- * Change the fragment
- * pointer
- */
- fixP->fx_frag = New_Frag;
- /*
- * If the offset is after
- * the entry mask we need
- * to account for the JSB
- * instruction we just
- * inserted.
- */
- if (fixP->fx_where >= 2)
- fixP->fx_where += 6;
- }
- }
- /*
- * Scan the symbols as offsets in the
- * fragment may have changed
- */
- for (symbolP = symbol_rootP;
- symbolP;
- symbolP = symbol_next (symbolP))
- {
- /*
- * Look for references to this
- * fragment.
- */
- if (symbolP->sy_frag == fragP)
- {
- /*
- * Change the fragment
- * pointer
- */
- symbolP->sy_frag = New_Frag;
- /*
- * If the offset is after
- * the entry mask we need
- * to account for the JSB
- * instruction we just
- * inserted.
- */
- if (S_GET_VALUE (symbolP) >= 2)
- S_GET_VALUE (symbolP) += 6;
- }
- }
- /*
- * Make a symbol reference to
- * "_c$main_args" so we can get
- * its address inserted into the
- * JSB instruction.
- */
- symbolP = (symbolS *) xmalloc (sizeof (*symbolP));
- S_GET_NAME (symbolP) = "_c$main_args";
- S_SET_TYPE (symbolP, N_UNDF);
- S_GET_OTHER (symbolP) = 0;
- S_GET_DESC (symbolP) = 0;
- S_GET_VALUE (symbolP) = 0;
- symbolP->sy_name_offset = 0;
- symbolP->sy_number = 0;
- symbolP->sy_frag = New_Frag;
- symbolP->sy_forward = 0;
- /* this actually inserts at the beginning of the list */
- symbol_append (symbol_rootP, symbolP, &symbol_rootP, &symbol_lastP);
-
- symbol_rootP = symbolP;
- /*
- * Generate a text fixup structure
- * to get "_c$main_args" stored into the
- * JSB instruction.
- */
- fixP = (struct fix *) xmalloc (sizeof (*fixP));
- fixP->fx_frag = New_Frag;
- fixP->fx_where = 4;
- fixP->fx_addsy = symbolP;
- fixP->fx_subsy = 0;
- fixP->fx_offset = 0;
- fixP->fx_size = sizeof (long);
- fixP->fx_pcrel = 1;
- fixP->fx_next = text_fix_root;
- text_fix_root = fixP;
- /*
- * Now make sure we exit from the loop
- */
- frchainP = 0;
- break;
- }
- /*
- * Try the next fragment
- */
- prev_fragPP = &fragP->fr_next;
- fragP = fragP->fr_next;
- }
- /*
- * Try the next fragment chain
- */
- if (frchainP)
- frchainP = frchainP->frch_next;
- }
- }
-#endif /* HACK_DEC_C_STARTUP */
- }
-}
-
-/*
- * Write a VAX/VMS object file (everything else has been done!)
- */
-VMS_write_object_file (text_siz, data_siz, text_frag_root, data_frag_root)
- unsigned text_siz;
- unsigned data_siz;
- struct frag *text_frag_root;
- struct frag *data_frag_root;
-{
- register fragS *fragP;
- register symbolS *symbolP;
- register symbolS *sp;
- register struct fix *fixP;
- register struct VMS_Symbol *vsp;
- char *Data_Segment;
- int Local_Initialized_Data_Size = 0;
- int Globalref;
- int Psect_Number = 0; /* Psect Index Number */
- int Text_Psect = -1; /* Text Psect Index */
- int Data_Psect = -2; /* Data Psect Index JF: Was -1 */
- int Bss_Psect = -3; /* Bss Psect Index JF: Was -1 */
-
- /*
- * Create the VMS object file
- */
- Create_VMS_Object_File ();
- /*
- * Write the module header records
- */
- Write_VMS_MHD_Records ();
-
- /*
- * Store the Data segment:
- *
- * Since this is REALLY hard to do any other way,
- * we actually manufacture the data segment and
- * the store the appropriate values out of it.
- * We need to generate this early, so that globalvalues
- * can be properly emitted.
- */
- if (data_siz > 0)
- {
- /*
- * Allocate the data segment
- */
- Data_Segment = (char *) xmalloc (data_siz);
- /*
- * Run through the data fragments, filling in the segment
- */
- for (fragP = data_frag_root; fragP; fragP = fragP->fr_next)
- {
- register long int count;
- register char *fill_literal;
- register long int fill_size;
- int i;
-
- i = fragP->fr_address - text_siz;
- if (fragP->fr_fix)
- memcpy (Data_Segment + i,
- fragP->fr_literal,
- fragP->fr_fix);
- i += fragP->fr_fix;
-
- fill_literal = fragP->fr_literal + fragP->fr_fix;
- fill_size = fragP->fr_var;
- for (count = fragP->fr_offset; count; count--)
- {
- if (fill_size)
- memcpy (Data_Segment + i, fill_literal, fill_size);
- i += fill_size;
- }
- }
- }
-
-
- /*
- * Generate the VMS object file records
- * 1st GSD then TIR records
- */
-
- /******* Global Symbol Dictionary *******/
- /*
- * Emit globalvalues now. We must do this before the text psect
- * is defined, or we will get linker warnings about multiply defined
- * symbols. All of the globalvalues "reference" psect 0, although
- * it really does not have anything to do with it.
- */
- VMS_Emit_Globalvalues (text_siz, data_siz, Data_Segment);
- /*
- * Define the Text Psect
- */
- Text_Psect = Psect_Number++;
- VMS_Psect_Spec ("$code", text_siz, "TEXT", 0);
- /*
- * Define the BSS Psect
- */
- if (local_bss_counter > 0)
- {
- Bss_Psect = Psect_Number++;
- VMS_Psect_Spec ("$uninitialized_data", local_bss_counter, "DATA",
- 0);
- }
-#ifndef gxx_bug_fixed
- /*
- * The g++ compiler does not write out external references to vtables
- * correctly. Check for this and holler if we see it happening.
- * If that compiler bug is ever fixed we can remove this.
- */
- for (sp = symbol_rootP; sp; sp = symbol_next (sp))
- {
- /*
- * Dispatch on symbol type
- */
- switch (S_GET_RAW_TYPE (sp)) {
- /*
- * Global Reference
- */
- case N_UNDF:
- /*
- * Make a GSD global symbol reference
- * record.
- */
- if (strncmp (S_GET_NAME (sp),"__vt.",5) == 0)
- {
- S_GET_RAW_TYPE (sp) = N_UNDF | N_EXT;
- as_warn("g++ wrote an extern reference to %s as a routine.",
- S_GET_NAME (sp));
- as_warn("I will fix it, but I hope that it was not really a routine");
- };
- break;
- default:
- break;
- }
- }
-#endif /* gxx_bug_fixed */
- /*
- * Now scan the symbols and emit the appropriate GSD records
- */
- for (sp = symbol_rootP; sp; sp = symbol_next (sp))
- {
- /*
- * Dispatch on symbol type
- */
- switch (S_GET_RAW_TYPE (sp))
- {
- /*
- * Global uninitialized data
- */
- case N_UNDF | N_EXT:
- /*
- * Make a VMS data symbol entry
- */
- vsp = (struct VMS_Symbol *)
- xmalloc (sizeof (*vsp));
- vsp->Symbol = sp;
- vsp->Size = S_GET_VALUE (sp);
- vsp->Psect_Index = Psect_Number++;
- vsp->Psect_Offset = 0;
- vsp->Next = VMS_Symbols;
- VMS_Symbols = vsp;
- sp->sy_number = (int) vsp;
- /*
- * Make the psect for this data
- */
- if (S_GET_OTHER (sp))
- Globalref = VMS_Psect_Spec (
- S_GET_NAME (sp),
- vsp->Size,
- "CONST",
- vsp);
- else
- Globalref = VMS_Psect_Spec (
- S_GET_NAME (sp),
- vsp->Size,
- "COMMON",
- vsp);
- if (Globalref)
- Psect_Number--;
-#ifdef NOT_VAX_11_C_COMPATIBLE
- /*
- * Place a global symbol at the
- * beginning of the Psect
- */
- VMS_Global_Symbol_Spec (S_GET_NAME (sp),
- vsp->Psect_Index,
- 0,
- 1);
-#endif /* NOT_VAX_11_C_COMPATIBLE */
- break;
- /*
- * Local uninitialized data
- */
- case N_BSS:
- /*
- * Make a VMS data symbol entry
- */
- vsp = (struct VMS_Symbol *)
- xmalloc (sizeof (*vsp));
- vsp->Symbol = sp;
- vsp->Size = 0;
- vsp->Psect_Index = Bss_Psect;
- vsp->Psect_Offset =
- S_GET_VALUE (sp) -
- bss_address_frag.fr_address;
- vsp->Next = VMS_Symbols;
- VMS_Symbols = vsp;
- sp->sy_number = (int) vsp;
- break;
- /*
- * Global initialized data
- */
- case N_DATA | N_EXT:
- /*
- * Make a VMS data symbol entry
- */
- vsp = (struct VMS_Symbol *)
- xmalloc (sizeof (*vsp));
- vsp->Symbol = sp;
- vsp->Size = VMS_Initialized_Data_Size (sp,
- text_siz + data_siz);
- vsp->Psect_Index = Psect_Number++;
- vsp->Psect_Offset = 0;
- vsp->Next = VMS_Symbols;
- VMS_Symbols = vsp;
- sp->sy_number = (int) vsp;
- /*
- * Make its psect
- */
- if (S_GET_OTHER (sp))
- Globalref = VMS_Psect_Spec (
- S_GET_NAME (sp),
- vsp->Size,
- "CONST",
- vsp);
- else
- Globalref = VMS_Psect_Spec (
- S_GET_NAME (sp),
- vsp->Size,
- "COMMON",
- vsp);
- if (Globalref)
- Psect_Number--;
-#ifdef NOT_VAX_11_C_COMPATIBLE
- /*
- * Place a global symbol at the
- * beginning of the Psect
- */
- VMS_Global_Symbol_Spec (S_GET_NAME (sp),
- vsp->Psect_Index,
- 0,
- 1);
-#endif /* NOT_VAX_11_C_COMPATIBLE */
- break;
- /*
- * Local initialized data
- */
- case N_DATA:
- /*
- * Make a VMS data symbol entry
- */
- vsp = (struct VMS_Symbol *)
- xmalloc (sizeof (*vsp));
- vsp->Symbol = sp;
- vsp->Size =
- VMS_Initialized_Data_Size (sp,
- text_siz + data_siz);
- vsp->Psect_Index = Data_Psect;
- vsp->Psect_Offset =
- Local_Initialized_Data_Size;
- Local_Initialized_Data_Size += vsp->Size;
- vsp->Next = VMS_Symbols;
- VMS_Symbols = vsp;
- sp->sy_number = (int) vsp;
- break;
- /*
- * Global Text definition
- */
- case N_TEXT | N_EXT:
- {
- unsigned short Entry_Mask;
-
- /*
- * Get the entry mask
- */
- fragP = sp->sy_frag;
- Entry_Mask = (fragP->fr_literal[0] & 0xff) +
- ((fragP->fr_literal[1] & 0xff)
- << 8);
- /*
- * Define the Procedure entry pt.
- */
- VMS_Procedure_Entry_Pt (S_GET_NAME (sp),
- Text_Psect,
- S_GET_VALUE (sp),
- Entry_Mask);
- break;
- }
- /*
- * Local Text definition
- */
- case N_TEXT:
- /*
- * Make a VMS data symbol entry
- */
- if (Text_Psect != -1)
- {
- vsp = (struct VMS_Symbol *)
- xmalloc (sizeof (*vsp));
- vsp->Symbol = sp;
- vsp->Size = 0;
- vsp->Psect_Index = Text_Psect;
- vsp->Psect_Offset = S_GET_VALUE (sp);
- vsp->Next = VMS_Symbols;
- VMS_Symbols = vsp;
- sp->sy_number = (int) vsp;
- }
- break;
- /*
- * Global Reference
- */
- case N_UNDF:
- /*
- * Make a GSD global symbol reference
- * record.
- */
- VMS_Global_Symbol_Spec (S_GET_NAME (sp),
- 0,
- 0,
- 0);
- break;
- /*
- * Anything else
- */
- default:
- /*
- * Ignore STAB symbols
- * Including .stabs emitted by g++
- */
- if (S_IS_DEBUG (sp) || (S_GET_TYPE (sp) == 22))
- break;
- /*
- * Error
- */
- if (S_GET_TYPE (sp) != 22)
- printf (" ERROR, unknown type (%d)\n",
- S_GET_TYPE (sp));
- break;
- }
- }
- /*
- * Define the Data Psect
- */
- if ((data_siz > 0) && (Local_Initialized_Data_Size > 0))
- {
- /*
- * Do it
- */
- Data_Psect = Psect_Number++;
- VMS_Psect_Spec ("$data",
- Local_Initialized_Data_Size,
- "DATA", 0);
- /*
- * Scan the VMS symbols and fill in the data psect
- */
- for (vsp = VMS_Symbols; vsp; vsp = vsp->Next)
- {
- /*
- * Only look for undefined psects
- */
- if (vsp->Psect_Index < 0)
- {
- /*
- * And only initialized data
- */
- if ((S_GET_TYPE (vsp->Symbol) == N_DATA) && !S_IS_EXTERNAL (vsp->Symbol))
- vsp->Psect_Index = Data_Psect;
- }
- }
- }
-
- /******* Text Information and Relocation Records *******/
- /*
- * Write the text segment data
- */
- if (text_siz > 0)
- {
- /*
- * Scan the text fragments
- */
- for (fragP = text_frag_root; fragP; fragP = fragP->fr_next)
- {
- /*
- * Stop if we get to the data fragments
- */
- if (fragP == data_frag_root)
- break;
- /*
- * Ignore fragments with no data
- */
- if ((fragP->fr_fix == 0) && (fragP->fr_var == 0))
- continue;
- /*
- * Go the the appropriate offset in the
- * Text Psect.
- */
- VMS_Set_Psect (Text_Psect, fragP->fr_address, OBJ_S_C_TIR);
- /*
- * Store the "fixed" part
- */
- if (fragP->fr_fix)
- VMS_Store_Immediate_Data (fragP->fr_literal,
- fragP->fr_fix,
- OBJ_S_C_TIR);
- /*
- * Store the "variable" part
- */
- if (fragP->fr_var && fragP->fr_offset)
- VMS_Store_Repeated_Data (fragP->fr_offset,
- fragP->fr_literal +
- fragP->fr_fix,
- fragP->fr_var,
- OBJ_S_C_TIR);
- }
- /*
- * Now we go through the text segment fixups and
- * generate TIR records to fix up addresses within
- * the Text Psect
- */
- for (fixP = text_fix_root; fixP; fixP = fixP->fx_next)
- {
- /*
- * We DO handle the case of "Symbol - Symbol" as
- * long as it is in the same segment.
- */
- if (fixP->fx_subsy && fixP->fx_addsy)
- {
- int i;
-
- /*
- * They need to be in the same segment
- */
- if (S_GET_RAW_TYPE (fixP->fx_subsy) !=
- S_GET_RAW_TYPE (fixP->fx_addsy))
- error ("Fixup data addsy and subsy didn't have the same type");
- /*
- * And they need to be in one that we
- * can check the psect on
- */
- if ((S_GET_TYPE (fixP->fx_addsy) != N_DATA) &&
- (S_GET_TYPE (fixP->fx_addsy) != N_TEXT))
- error ("Fixup data addsy and subsy didn't have an appropriate type");
- /*
- * This had better not be PC relative!
- */
- if (fixP->fx_pcrel)
- error ("Fixup data was erroneously \"pcrel\"");
- /*
- * Subtract their values to get the
- * difference.
- */
- i = S_GET_VALUE (fixP->fx_addsy) -
- S_GET_VALUE (fixP->fx_subsy);
- /*
- * Now generate the fixup object records
- * Set the psect and store the data
- */
- VMS_Set_Psect (Text_Psect,
- fixP->fx_where +
- fixP->fx_frag->fr_address,
- OBJ_S_C_TIR);
- VMS_Store_Immediate_Data (&i,
- fixP->fx_size,
- OBJ_S_C_TIR);
- /*
- * Done
- */
- continue;
- }
- /*
- * Size will HAVE to be "long"
- */
- if (fixP->fx_size != sizeof (long))
- error ("Fixup datum was not a longword");
- /*
- * Symbol must be "added" (if it is ever
- * subtracted we can
- * fix this assumption)
- */
- if (fixP->fx_addsy == 0)
- error ("Fixup datum was not \"fixP->fx_addsy\"");
- /*
- * Store the symbol value in a PIC fashion
- */
- VMS_Store_PIC_Symbol_Reference (fixP->fx_addsy,
- fixP->fx_offset,
- fixP->fx_pcrel,
- Text_Psect,
- fixP->fx_where +
- fixP->fx_frag->fr_address,
- OBJ_S_C_TIR);
- /*
- * Check for indirect address reference,
- * which has to be fixed up (as the linker
- * will screw it up with TIR_S_C_STO_PICR).
- */
- if (fixP->fx_pcrel)
- VMS_Fix_Indirect_Reference (Text_Psect,
- fixP->fx_where +
- fixP->fx_frag->fr_address,
- fixP->fx_frag,
- text_frag_root);
- }
- }
- /*
- * Store the Data segment:
- *
- * Since this is REALLY hard to do any other way,
- * we actually manufacture the data segment and
- * the store the appropriate values out of it.
- * The segment was manufactured before, now we just
- * dump it into the appropriate psects.
- */
- if (data_siz > 0)
- {
-
- /*
- * Now we can run through all the data symbols
- * and store the data
- */
- for (vsp = VMS_Symbols; vsp; vsp = vsp->Next)
- {
- /*
- * Ignore anything other than data symbols
- */
- if (S_GET_TYPE (vsp->Symbol) != N_DATA)
- continue;
- /*
- * Set the Psect + Offset
- */
- VMS_Set_Psect (vsp->Psect_Index,
- vsp->Psect_Offset,
- OBJ_S_C_TIR);
- /*
- * Store the data
- */
- VMS_Store_Immediate_Data (Data_Segment +
- S_GET_VALUE (vsp->Symbol) -
- text_siz,
- vsp->Size,
- OBJ_S_C_TIR);
- }
- /*
- * Now we go through the data segment fixups and
- * generate TIR records to fix up addresses within
- * the Data Psects
- */
- for (fixP = data_fix_root; fixP; fixP = fixP->fx_next)
- {
- /*
- * Find the symbol for the containing datum
- */
- for (vsp = VMS_Symbols; vsp; vsp = vsp->Next)
- {
- /*
- * Only bother with Data symbols
- */
- sp = vsp->Symbol;
- if (S_GET_TYPE (sp) != N_DATA)
- continue;
- /*
- * Ignore symbol if After fixup
- */
- if (S_GET_VALUE (sp) >
- (fixP->fx_where +
- fixP->fx_frag->fr_address))
- continue;
- /*
- * See if the datum is here
- */
- if ((S_GET_VALUE (sp) + vsp->Size) <=
- (fixP->fx_where +
- fixP->fx_frag->fr_address))
- continue;
- /*
- * We DO handle the case of "Symbol - Symbol" as
- * long as it is in the same segment.
- */
- if (fixP->fx_subsy && fixP->fx_addsy)
- {
- int i;
-
- /*
- * They need to be in the same segment
- */
- if (S_GET_RAW_TYPE (fixP->fx_subsy) !=
- S_GET_RAW_TYPE (fixP->fx_addsy))
- error ("Fixup data addsy and subsy didn't have the same type");
- /*
- * And they need to be in one that we
- * can check the psect on
- */
- if ((S_GET_TYPE (fixP->fx_addsy) != N_DATA) &&
- (S_GET_TYPE (fixP->fx_addsy) != N_TEXT))
- error ("Fixup data addsy and subsy didn't have an appropriate type");
- /*
- * This had better not be PC relative!
- */
- if (fixP->fx_pcrel)
- error ("Fixup data was erroneously \"pcrel\"");
- /*
- * Subtract their values to get the
- * difference.
- */
- i = S_GET_VALUE (fixP->fx_addsy) -
- S_GET_VALUE (fixP->fx_subsy);
- /*
- * Now generate the fixup object records
- * Set the psect and store the data
- */
- VMS_Set_Psect (vsp->Psect_Index,
- fixP->fx_frag->fr_address +
- fixP->fx_where -
- S_GET_VALUE (vsp->Symbol) +
- vsp->Psect_Offset,
- OBJ_S_C_TIR);
- VMS_Store_Immediate_Data (&i,
- fixP->fx_size,
- OBJ_S_C_TIR);
- /*
- * Done
- */
- break;
- }
- /*
- * Size will HAVE to be "long"
- */
- if (fixP->fx_size != sizeof (long))
- error ("Fixup datum was not a longword");
- /*
- * Symbol must be "added" (if it is ever
- * subtracted we can
- * fix this assumption)
- */
- if (fixP->fx_addsy == 0)
- error ("Fixup datum was not \"fixP->fx_addsy\"");
- /*
- * Store the symbol value in a PIC fashion
- */
- VMS_Store_PIC_Symbol_Reference (
- fixP->fx_addsy,
- fixP->fx_offset,
- fixP->fx_pcrel,
- vsp->Psect_Index,
- fixP->fx_frag->fr_address +
- fixP->fx_where -
- S_GET_VALUE (vsp->Symbol) +
- vsp->Psect_Offset,
- OBJ_S_C_TIR);
- /*
- * Done
- */
- break;
- }
-
- }
- }
-
- /*
- * Write the Traceback Begin Module record
- */
- VMS_TBT_Module_Begin ();
- /*
- * Scan the symbols and write out the routines
- * (this makes the assumption that symbols are in
- * order of ascending text segment offset)
- */
- {
- struct symbol *Current_Routine = 0;
- int Current_Line_Number = 0;
- int Current_Offset = -1;
- struct input_file *Current_File;
-
-/* Output debugging info for global variables and static variables that are not
- * specific to one routine. We also need to examine all stabs directives, to
- * find the definitions to all of the advanced data types, and this is done by
- * VMS_LSYM_Parse. This needs to be done before any definitions are output to
- * the object file, since there can be forward references in the stabs
- * directives. When through with parsing, the text of the stabs directive
- * is altered, with the definitions removed, so that later passes will see
- * directives as they would be written if the type were already defined.
- *
- * We also look for files and include files, and make a list of them. We
- * examine the source file numbers to establish the actual lines that code was
- * generated from, and then generate offsets.
- */
- VMS_LSYM_Parse ();
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
- {
- /*
- * Deal with STAB symbols
- */
- if (S_IS_DEBUG (symbolP))
- {
- /*
- * Dispatch on STAB type
- */
- switch ((unsigned char) S_GET_RAW_TYPE (symbolP))
- {
- case N_SLINE:
- if (S_GET_DESC (symbolP) > Current_File->max_line)
- Current_File->max_line = S_GET_DESC (symbolP);
- if (S_GET_DESC (symbolP) < Current_File->min_line)
- Current_File->min_line = S_GET_DESC (symbolP);
- break;
- case N_SO:
- Current_File = find_file (symbolP);
- Current_File->flag = 1;
- Current_File->min_line = 1;
- break;
- case N_SOL:
- Current_File = find_file (symbolP);
- break;
- case N_GSYM:
- VMS_GSYM_Parse (symbolP, Text_Psect);
- break;
- case N_LCSYM:
- VMS_LCSYM_Parse (symbolP, Text_Psect);
- break;
- case N_FUN: /* For static constant symbols */
- case N_STSYM:
- VMS_STSYM_Parse (symbolP, Text_Psect);
- break;
- }
- }
- }
-
- /* now we take a quick sweep through the files and assign offsets
- to each one. This will essentially be the starting line number to the
- debugger for each file. Output the info for the debugger to specify the
- files, and then tell it how many lines to use */
- {
- int File_Number = 0;
- int Debugger_Offset = 0;
- int file_available;
- Current_File = file_root;
- for (Current_File = file_root; Current_File; Current_File = Current_File->next)
- {
- if (Current_File == (struct input_file *) NULL)
- break;
- if (Current_File->max_line == 0)
- continue;
- if ((strncmp (Current_File->name, "GNU_GXX_INCLUDE:", 16) == 0) &&
- !flagseen['D'])
- continue;
- if ((strncmp (Current_File->name, "GNU_CC_INCLUDE:", 15) == 0) &&
- !flagseen['D'])
- continue;
-/* show a few extra lines at the start of the region selected */
- if (Current_File->min_line > 2)
- Current_File->min_line -= 2;
- Current_File->offset = Debugger_Offset - Current_File->min_line + 1;
- Debugger_Offset += Current_File->max_line - Current_File->min_line + 1;
- if (Current_File->same_file_fpnt != (struct input_file *) NULL)
- Current_File->file_number = Current_File->same_file_fpnt->file_number;
- else
- {
- Current_File->file_number = ++File_Number;
- file_available = VMS_TBT_Source_File (Current_File->name,
- Current_File->file_number);
- if (!file_available)
- {
- Current_File->file_number = 0;
- File_Number--;
- continue;
- };
- };
- VMS_TBT_Source_Lines (Current_File->file_number,
- Current_File->min_line,
- Current_File->max_line - Current_File->min_line + 1);
- }; /* for */
- }; /* scope */
- Current_File = (struct input_file *) NULL;
-
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
- {
- /*
- * Deal with text symbols
- */
- if (!S_IS_DEBUG (symbolP) && (S_GET_TYPE (symbolP) == N_TEXT))
- {
- /*
- * Ignore symbols starting with "L",
- * as they are local symbols
- */
- if (*S_GET_NAME (symbolP) == 'L')
- continue;
- /*
- * If there is a routine start defined,
- * terminate it.
- */
- if (Current_Routine)
- {
- /*
- * End the routine
- */
- VMS_TBT_Routine_End (text_siz, Current_Routine);
- }
- /*
- * Store the routine begin traceback info
- */
- if (Text_Psect != -1)
- {
- VMS_TBT_Routine_Begin (symbolP, Text_Psect);
- Current_Routine = symbolP;
- }
-/* Output local symbols, i.e. all symbols that are associated with a specific
- * routine. We output them now so the debugger recognizes them as local to
- * this routine.
- */
- {
- symbolS *symbolP1;
- char *pnt;
- char *pnt1;
- for (symbolP1 = Current_Routine; symbolP1; symbolP1 = symbol_next (symbolP1))
- {
- if (!S_IS_DEBUG (symbolP1))
- continue;
- if (S_GET_RAW_TYPE (symbolP1) != N_FUN)
- continue;
- pnt = S_GET_NAME (symbolP);
- pnt1 = S_GET_NAME (symbolP1);
- if (*pnt++ != '_')
- continue;
- while (*pnt++ == *pnt1++)
- {
- };
- if (*pnt1 != 'F' && *pnt1 != 'f') continue;
- if ((*(--pnt) == '\0') && (*(--pnt1) == ':'))
- break;
- };
- if (symbolP1 != (symbolS *) NULL)
- VMS_DBG_Define_Routine (symbolP1, Current_Routine, Text_Psect);
- } /* local symbol block */
- /*
- * Done
- */
- continue;
- }
- /*
- * Deal with STAB symbols
- */
- if (S_IS_DEBUG (symbolP))
- {
- /*
- * Dispatch on STAB type
- */
- switch ((unsigned char) S_GET_RAW_TYPE (symbolP))
- {
- /*
- * Line number
- */
- case N_SLINE:
- /* Offset the line into the correct portion
- * of the file */
- if (Current_File->file_number == 0)
- break;
- /* Sometimes the same offset gets several source
- * lines assigned to it.
- * We should be selective about which lines
- * we allow, we should prefer lines that are
- * in the main source file when debugging
- * inline functions. */
- if ((Current_File->file_number != 1) &&
- S_GET_VALUE (symbolP) ==
- Current_Offset)
- break;
- /* calculate actual debugger source line */
- S_GET_DESC (symbolP)
- += Current_File->offset;
- /*
- * If this is the 1st N_SLINE, setup
- * PC/Line correlation. Otherwise
- * do the delta PC/Line. If the offset
- * for the line number is not +ve we need
- * to do another PC/Line correlation
- * setup
- */
- if (Current_Offset == -1)
- {
- VMS_TBT_Line_PC_Correlation (
- S_GET_DESC (symbolP),
- S_GET_VALUE (symbolP),
- Text_Psect,
- 0);
- }
- else
- {
- if ((S_GET_DESC (symbolP) -
- Current_Line_Number) <= 0)
- {
- /*
- * Line delta is not +ve, we
- * need to close the line and
- * start a new PC/Line
- * correlation.
- */
- VMS_TBT_Line_PC_Correlation (0,
- S_GET_VALUE (symbolP) -
- Current_Offset,
- 0,
- -1);
- VMS_TBT_Line_PC_Correlation (
- S_GET_DESC (symbolP),
- S_GET_VALUE (symbolP),
- Text_Psect,
- 0);
- }
- else
- {
- /*
- * Line delta is +ve, all is well
- */
- VMS_TBT_Line_PC_Correlation (
- S_GET_DESC (symbolP) -
- Current_Line_Number,
- S_GET_VALUE (symbolP) -
- Current_Offset,
- 0,
- 1);
- }
- }
- /*
- * Update the current line/PC
- */
- Current_Line_Number = S_GET_DESC (symbolP);
- Current_Offset = S_GET_VALUE (symbolP);
- /*
- * Done
- */
- break;
- /*
- * Source file
- */
- case N_SO:
- /*
- * Remember that we had a source file
- * and emit the source file debugger
- * record
- */
- Current_File =
- find_file (symbolP);
- break;
-/* We need to make sure that we are really in the actual source file when
- * we compute the maximum line number. Otherwise the debugger gets really
- * confused */
- case N_SOL:
- Current_File =
- find_file (symbolP);
- break;
- }
- }
- }
- /*
- * If there is a routine start defined,
- * terminate it (and the line numbers)
- */
- if (Current_Routine)
- {
- /*
- * Terminate the line numbers
- */
- VMS_TBT_Line_PC_Correlation (0,
- text_siz - S_GET_VALUE (Current_Routine),
- 0,
- -1);
- /*
- * Terminate the routine
- */
- VMS_TBT_Routine_End (text_siz, Current_Routine);
- }
- }
- /*
- * Write the Traceback End Module TBT record
- */
- VMS_TBT_Module_End ();
-
- /*
- * Write the End Of Module record
- */
- if (Entry_Point_Symbol == 0)
- Write_VMS_EOM_Record (-1, 0);
- else
- Write_VMS_EOM_Record (Text_Psect,
- S_GET_VALUE (Entry_Point_Symbol));
-
- /*
- * All done, close the object file
- */
- Close_VMS_Object_File ();
-}
-
-/* end of obj-vms.c */
diff --git a/gnu/usr.bin/as/config/obj-vms.h b/gnu/usr.bin/as/config/obj-vms.h
deleted file mode 100644
index f997535..0000000
--- a/gnu/usr.bin/as/config/obj-vms.h
+++ /dev/null
@@ -1,474 +0,0 @@
-/* VMS object file format
- Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
-
-This file is part of GAS, the GNU Assembler.
-
-GAS 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.
-
-GAS 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 GAS; see the file COPYING. If not, write
-to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Tag to validate a.out object file format processing */
-#define OBJ_VMS 1
-
-#include "targ-cpu.h"
-
-/* This flag is used to remember whether we are in the const or the
- data section. By and large they are identical, but we set a no-write
- bit for psects in the const section. */
-
-extern char const_flag;
-
-
-/* These are defined in obj-vms.c. */
-extern const short seg_N_TYPE[];
-extern const segT N_TYPE_seg[];
-
-enum reloc_type {
- NO_RELOC, RELOC_32
-};
-
-#define N_BADMAG(x) (0)
-#define N_TXTOFF(x) ( sizeof(struct exec) )
-#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
-#define N_TROFF(x) ( N_DATOFF(x) + (x).a_data )
-#define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize )
-#define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize )
-#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
-
-/* We use this copy of the exec header for VMS. We do not actually use it, but
- what we actually do is let gas fill in the relevant slots, and when we get
- around to writing an obj file, we just pick out what we need. */
-
-struct exec
-{
- unsigned long a_text; /* length of text, in bytes */
- unsigned long a_data; /* length of data, in bytes */
- unsigned long a_bss; /* length of uninitialized data area for file, in bytes */
- unsigned long a_trsize; /* length of relocation info for text, in bytes */
- unsigned long a_drsize; /* length of relocation info for data, in bytes */
- unsigned long a_entry; /* start address */
- unsigned long a_syms; /* length of symbol table data in file, in bytes */
-};
-
-typedef struct {
- struct exec header; /* a.out header */
- long string_table_size; /* names + '\0' + sizeof(int) */
-} object_headers;
-
-/* A single entry in the symbol table
- */
-struct nlist {
- union {
- char *n_name;
- struct nlist *n_next;
- long n_strx; /* Index into string table */
- } n_un;
- unsigned char n_type; /* See below */
- char n_other; /* Used in i80960 support -- see below */
- short n_desc;
- unsigned long n_value;
-};
-
-/* Legal values of n_type
- */
-#define N_UNDF 0 /* Undefined symbol */
-#define N_ABS 2 /* Absolute symbol */
-#define N_TEXT 4 /* Text symbol */
-#define N_DATA 6 /* Data symbol */
-#define N_BSS 8 /* BSS symbol */
-#define N_FN 31 /* Filename symbol */
-
-#define N_EXT 1 /* External symbol (OR'd in with one of above) */
-#define N_TYPE 036 /* Mask for all the type bits */
-
-#define N_STAB 0340 /* Mask for all bits used for SDB entries */
-
-#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */
-#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */
-#define N_FUN 0x24 /* procedure: name,,0,linenumber,address */
-#define N_STSYM 0x26 /* static symbol: name,,0,type,address */
-#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */
-#define N_RSYM 0x40 /* register sym: name,,0,type,register */
-#define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */
-#define N_CATCH 0x54 /* */
-#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */
-#define N_SO 0x64 /* source file name: name,,0,0,address */
-#define N_LSYM 0x80 /* local sym: name,,0,type,offset */
-#define N_SOL 0x84 /* #included file name: name,,0,0,address */
-#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */
-#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */
-#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */
-#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */
-#define N_BCOMM 0xe2 /* begin common: name,, */
-#define N_ECOMM 0xe4 /* end common: name,, */
-#define N_ECOML 0xe8 /* end common (local name): ,,address */
-#define N_LENG 0xfe /* second stab entry with length information */
-
-/* SYMBOL TABLE */
-/* Symbol table entry data type */
-
-typedef struct nlist obj_symbol_type; /* Symbol table entry */
-
-/* Symbol table macros and constants */
-
-/*
- * Macros to extract information from a symbol table entry.
- * This syntaxic indirection allows independence regarding a.out or coff.
- * The argument (s) of all these macros is a pointer to a symbol table entry.
- */
-
-/* True if the symbol is external */
-#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT)
-
-/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
-#define S_IS_DEFINED(s) (S_GET_TYPE(s) != N_UNDF)
-
-#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER)
-
-/* True if a debug special symbol entry */
-#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB)
-/* True if a symbol is local symbol name */
-/* A symbol name whose name begin with ^A is a gas internal pseudo symbol
- nameless symbols come from .stab directives. */
-#define S_IS_LOCAL(s) (S_GET_NAME(s) && \
- !S_IS_DEBUG(s) && \
- (S_GET_NAME(s)[0] == '\001' || \
- (S_LOCAL_NAME(s) && !flagseen['L'])))
-/* True if a symbol is not defined in this file */
-#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
-/* True if the symbol has been generated because of a .stabd directive */
-#define S_IS_STABD(s) (S_GET_NAME(s) == (char *)0)
-
-/* Accessors */
-/* The value of the symbol */
-#define S_GET_VALUE(s) (((s)->sy_symbol.n_value))
-/* The name of the symbol */
-#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
-/* The pointer to the string table */
-#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx)
-/* The raw type of the symbol */
-#define S_GET_RAW_TYPE(s) ((s)->sy_symbol.n_type)
-/* The type of the symbol */
-#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE)
-/* The numeric value of the segment */
-#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)])
-/* The n_other expression value */
-#define S_GET_OTHER(s) ((s)->sy_symbol.n_other)
-/* The n_desc expression value */
-#define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
-
-/* Modifiers */
-/* Set the value of the symbol */
-#define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v))
-/* Assume that a symbol cannot be simultaneously in more than on segment */
- /* set segment */
-#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
-/* The symbol is external */
-#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT)
-/* The symbol is not external */
-#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT)
-/* Set the name of the symbol */
-#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
-/* Set the offset in the string table */
-#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
-/* Set the n_other expression value */
-#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
-/* Set the n_desc expression value */
-#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v))
-
-
-/* File header macro and type definition */
-
-#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
-#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
-#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
-
-#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align(SEG_TEXT, (v)))
-#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align(SEG_DATA, (v)))
-#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align(SEG_BSS, (v)))
-
-#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
-#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \
- sizeof(struct nlist))
-
-/*
- * Current means for getting the name of a segment.
- * This will change for infinite-segments support (e.g. COFF).
- */
-#define segment_name(seg) ( seg_name[(int)(seg)] )
-extern char *const seg_name[];
-
-
-/* line numbering stuff. */
-#define OBJ_EMIT_LINENO(a, b, c) {;}
-
-#define obj_symbol_new_hook(s) {;}
-
-#ifdef __STDC__
-struct fix;
-void tc_aout_fix_to_chars(char *where, struct fix *fixP, relax_addressT segment_address);
-#else
-void tc_aout_fix_to_chars();
-#endif /* __STDC__ */
-
-/* The rest of this file contains definitions for constants used within the actual
- VMS object file. We do not use a $ in the symbols (as per usual VMS
- convention) since System V gags on it. */
-
-#define OBJ_S_C_HDR 0
-#define OBJ_S_C_HDR_MHD 0
-#define OBJ_S_C_HDR_LNM 1
-#define OBJ_S_C_HDR_SRC 2
-#define OBJ_S_C_HDR_TTL 3
-#define OBJ_S_C_HDR_CPR 4
-#define OBJ_S_C_HDR_MTC 5
-#define OBJ_S_C_HDR_GTX 6
-#define OBJ_S_C_GSD 1
-#define OBJ_S_C_GSD_PSC 0
-#define OBJ_S_C_GSD_SYM 1
-#define OBJ_S_C_GSD_EPM 2
-#define OBJ_S_C_GSD_PRO 3
-#define OBJ_S_C_GSD_SYMW 4
-#define OBJ_S_C_GSD_EPMW 5
-#define OBJ_S_C_GSD_PROW 6
-#define OBJ_S_C_GSD_IDC 7
-#define OBJ_S_C_GSD_ENV 8
-#define OBJ_S_C_GSD_LSY 9
-#define OBJ_S_C_GSD_LEPM 10
-#define OBJ_S_C_GSD_LPRO 11
-#define OBJ_S_C_GSD_SPSC 12
-#define OBJ_S_C_TIR 2
-#define OBJ_S_C_EOM 3
-#define OBJ_S_C_DBG 4
-#define OBJ_S_C_TBT 5
-#define OBJ_S_C_LNK 6
-#define OBJ_S_C_EOMW 7
-#define OBJ_S_C_MAXRECTYP 7
-#define OBJ_S_K_SUBTYP 1
-#define OBJ_S_C_SUBTYP 1
-#define OBJ_S_C_MAXRECSIZ 2048
-#define OBJ_S_C_STRLVL 0
-#define OBJ_S_C_SYMSIZ 31
-#define OBJ_S_C_STOREPLIM -1
-#define OBJ_S_C_PSCALILIM 9
-
-#define MHD_S_C_MHD 0
-#define MHD_S_C_LNM 1
-#define MHD_S_C_SRC 2
-#define MHD_S_C_TTL 3
-#define MHD_S_C_CPR 4
-#define MHD_S_C_MTC 5
-#define MHD_S_C_GTX 6
-#define MHD_S_C_MAXHDRTYP 6
-
-#define GSD_S_K_ENTRIES 1
-#define GSD_S_C_ENTRIES 1
-#define GSD_S_C_PSC 0
-#define GSD_S_C_SYM 1
-#define GSD_S_C_EPM 2
-#define GSD_S_C_PRO 3
-#define GSD_S_C_SYMW 4
-#define GSD_S_C_EPMW 5
-#define GSD_S_C_PROW 6
-#define GSD_S_C_IDC 7
-#define GSD_S_C_ENV 8
-#define GSD_S_C_LSY 9
-#define GSD_S_C_LEPM 10
-#define GSD_S_C_LPRO 11
-#define GSD_S_C_SPSC 12
-#define GSD_S_C_SYMV 13
-#define GSD_S_C_EPMV 14
-#define GSD_S_C_PROV 15
-#define GSD_S_C_MAXRECTYP 15
-
-#define GSY_S_M_WEAK 1
-#define GSY_S_M_DEF 2
-#define GSY_S_M_UNI 4
-#define GSY_S_M_REL 8
-
-#define GPS_S_M_PIC 1
-#define GPS_S_M_LIB 2
-#define GPS_S_M_OVR 4
-#define GPS_S_M_REL 8
-#define GPS_S_M_GBL 16
-#define GPS_S_M_SHR 32
-#define GPS_S_M_EXE 64
-#define GPS_S_M_RD 128
-#define GPS_S_M_WRT 256
-#define GPS_S_M_VEC 512
-#define GPS_S_K_NAME 9
-#define GPS_S_C_NAME 9
-
-#define TIR_S_C_STA_GBL 0
-#define TIR_S_C_STA_SB 1
-#define TIR_S_C_STA_SW 2
-#define TIR_S_C_STA_LW 3
-#define TIR_S_C_STA_PB 4
-#define TIR_S_C_STA_PW 5
-#define TIR_S_C_STA_PL 6
-#define TIR_S_C_STA_UB 7
-#define TIR_S_C_STA_UW 8
-#define TIR_S_C_STA_BFI 9
-#define TIR_S_C_STA_WFI 10
-#define TIR_S_C_STA_LFI 11
-#define TIR_S_C_STA_EPM 12
-#define TIR_S_C_STA_CKARG 13
-#define TIR_S_C_STA_WPB 14
-#define TIR_S_C_STA_WPW 15
-#define TIR_S_C_STA_WPL 16
-#define TIR_S_C_STA_LSY 17
-#define TIR_S_C_STA_LIT 18
-#define TIR_S_C_STA_LEPM 19
-#define TIR_S_C_MAXSTACOD 19
-#define TIR_S_C_MINSTOCOD 20
-#define TIR_S_C_STO_SB 20
-#define TIR_S_C_STO_SW 21
-#define TIR_S_C_STO_L 22
-#define TIR_S_C_STO_BD 23
-#define TIR_S_C_STO_WD 24
-#define TIR_S_C_STO_LD 25
-#define TIR_S_C_STO_LI 26
-#define TIR_S_C_STO_PIDR 27
-#define TIR_S_C_STO_PICR 28
-#define TIR_S_C_STO_RSB 29
-#define TIR_S_C_STO_RSW 30
-#define TIR_S_C_STO_RL 31
-#define TIR_S_C_STO_VPS 32
-#define TIR_S_C_STO_USB 33
-#define TIR_S_C_STO_USW 34
-#define TIR_S_C_STO_RUB 35
-#define TIR_S_C_STO_RUW 36
-#define TIR_S_C_STO_B 37
-#define TIR_S_C_STO_W 38
-#define TIR_S_C_STO_RB 39
-#define TIR_S_C_STO_RW 40
-#define TIR_S_C_STO_RIVB 41
-#define TIR_S_C_STO_PIRR 42
-#define TIR_S_C_MAXSTOCOD 42
-#define TIR_S_C_MINOPRCOD 50
-#define TIR_S_C_OPR_NOP 50
-#define TIR_S_C_OPR_ADD 51
-#define TIR_S_C_OPR_SUB 52
-#define TIR_S_C_OPR_MUL 53
-#define TIR_S_C_OPR_DIV 54
-#define TIR_S_C_OPR_AND 55
-#define TIR_S_C_OPR_IOR 56
-#define TIR_S_C_OPR_EOR 57
-#define TIR_S_C_OPR_NEG 58
-#define TIR_S_C_OPR_COM 59
-#define TIR_S_C_OPR_INSV 60
-#define TIR_S_C_OPR_ASH 61
-#define TIR_S_C_OPR_USH 62
-#define TIR_S_C_OPR_ROT 63
-#define TIR_S_C_OPR_SEL 64
-#define TIR_S_C_OPR_REDEF 65
-#define TIR_S_C_OPR_DFLIT 66
-#define TIR_S_C_MAXOPRCOD 66
-#define TIR_S_C_MINCTLCOD 80
-#define TIR_S_C_CTL_SETRB 80
-#define TIR_S_C_CTL_AUGRB 81
-#define TIR_S_C_CTL_DFLOC 82
-#define TIR_S_C_CTL_STLOC 83
-#define TIR_S_C_CTL_STKDL 84
-#define TIR_S_C_MAXCTLCOD 84
-
-/*
- * Debugger symbol definitions: These are done by hand, as no
- * machine-readable version seems
- * to be available.
- */
-#define DST_S_C_C 7 /* Language == "C" */
-#define DST_S_C_VERSION 153
-#define DST_S_C_SOURCE 155 /* Source file */
-#define DST_S_C_PROLOG 162
-#define DST_S_C_BLKBEG 176 /* Beginning of block */
-#define DST_S_C_BLKEND 177 /* End of block */
-#define DST_S_C_ENTRY 181
-#define DST_S_C_PSECT 184
-#define DST_S_C_LINE_NUM 185 /* Line Number */
-#define DST_S_C_LBLORLIT 186
-#define DST_S_C_LABEL 187
-#define DST_S_C_MODBEG 188 /* Beginning of module */
-#define DST_S_C_MODEND 189 /* End of module */
-#define DST_S_C_RTNBEG 190 /* Beginning of routine */
-#define DST_S_C_RTNEND 191 /* End of routine */
-#define DST_S_C_DELTA_PC_W 1 /* Incr PC */
-#define DST_S_C_INCR_LINUM 2 /* Incr Line # */
-#define DST_S_C_INCR_LINUM_W 3 /* Incr Line # */
-#define DST_S_C_SET_LINUM_INCR 4
-#define DST_S_C_SET_LINUM_INCR_W 5
-#define DST_S_C_RESET_LINUM_INCR 6
-#define DST_S_C_BEG_STMT_MODE 7
-#define DST_S_C_END_STMT_MODE 8
-#define DST_S_C_SET_LINE_NUM 9 /* Set Line # */
-#define DST_S_C_SET_PC 10
-#define DST_S_C_SET_PC_W 11
-#define DST_S_C_SET_PC_L 12
-#define DST_S_C_SET_STMTNUM 13
-#define DST_S_C_TERM 14 /* End of lines */
-#define DST_S_C_TERM_W 15 /* End of lines */
-#define DST_S_C_SET_ABS_PC 16 /* Set PC */
-#define DST_S_C_DELTA_PC_L 17 /* Incr PC */
-#define DST_S_C_INCR_LINUM_L 18 /* Incr Line # */
-#define DST_S_C_SET_LINUM_B 19 /* Set Line # */
-#define DST_S_C_SET_LINUM_L 20 /* Set Line # */
-#define DST_S_C_TERM_L 21 /* End of lines */
-/* these are used with DST_S_C_SOURCE */
-#define DST_S_C_SRC_FORMFEED 16 /* ^L counts */
-#define DST_S_C_SRC_DECLFILE 1 /* Declare file */
-#define DST_S_C_SRC_SETFILE 2 /* Set file */
-#define DST_S_C_SRC_SETREC_L 3 /* Set record */
-#define DST_S_C_SRC_DEFLINES_W 10 /* # of line */
-/* the following are the codes for the various data types. Anything not on
- * the list is included under 'advanced_type'
- */
-#define DBG_S_C_UCHAR 0x02
-#define DBG_S_C_USINT 0x03
-#define DBG_S_C_ULINT 0x04
-#define DBG_S_C_SCHAR 0x06
-#define DBG_S_C_SSINT 0x07
-#define DBG_S_C_SLINT 0x08
-#define DBG_S_C_REAL4 0x0a
-#define DBG_S_C_REAL8 0x0b
-#define DBG_S_C_FUNCTION_ADDR 0x17
-#define DBG_S_C_ADVANCED_TYPE 0xa3
-/* These are the codes that are used to generate the definitions of struct
- * union and enum records
- */
-#define DBG_S_C_ENUM_ITEM 0xa4
-#define DBG_S_C_ENUM_START 0xa5
-#define DBG_S_C_ENUM_END 0xa6
-#define DBG_S_C_STRUCT_START 0xab
-#define DBG_S_C_STRUCT_ITEM 0xff
-#define DBG_S_C_STRUCT_END 0xac
-/* These are the codes that are used in the suffix records to determine the
- * actual data type
- */
-#define DBG_S_C_BASIC 0x01
-#define DBG_S_C_BASIC_ARRAY 0x02
-#define DBG_S_C_STRUCT 0x03
-#define DBG_S_C_POINTER 0x04
-#define DBG_S_C_VOID 0x05
-#define DBG_S_C_COMPLEX_ARRAY 0x07
-/* These codes are used in the generation of the symbol definition records
- */
-#define DBG_S_C_FUNCTION_PARAMETER 0xc9
-#define DBG_S_C_LOCAL_SYM 0xd9
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj-vms.h */
diff --git a/gnu/usr.bin/as/config/tc-a29k.c b/gnu/usr.bin/as/config/tc-a29k.c
deleted file mode 100644
index c32c2b3..0000000
--- a/gnu/usr.bin/as/config/tc-a29k.c
+++ /dev/null
@@ -1,1113 +0,0 @@
-/* tc-a29k.c -- Assemble for the AMD 29000.
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* John Gilmore has reorganized this module somewhat, to make it easier
- to convert it to new machines' assemblers as desired. There was too
- much bloody rewriting required before. There still probably is. */
-
-#include "as.h"
-
-#include "opcode/a29k.h"
-
-/* Make it easier to clone this machine desc into another one. */
-#define machine_opcode a29k_opcode
-#define machine_opcodes a29k_opcodes
-#define machine_ip a29k_ip
-#define machine_it a29k_it
-
-const relax_typeS md_relax_table[] = { 0 };
-
-#define IMMEDIATE_BIT 0x01000000 /* Turns RB into Immediate */
-#define ABSOLUTE_BIT 0x01000000 /* Turns PC-relative to Absolute */
-#define CE_BIT 0x00800000 /* Coprocessor enable in LOAD */
-#define UI_BIT 0x00000080 /* Unsigned integer in CONVERT */
-
-/* handle of the OPCODE hash table */
-static struct hash_control *op_hash = NULL;
-
-struct machine_it {
- char *error;
- unsigned long opcode;
- struct nlist *nlistp;
- expressionS exp;
- int pcrel;
- int reloc_offset; /* Offset of reloc within insn */
- enum reloc_type reloc;
-} the_insn;
-
-#if __STDC__ == 1
-
-/* static int getExpression(char *str); */
-static void machine_ip(char *str);
-/* static void print_insn(struct machine_it *insn); */
-static void s_data1(void);
-static void s_use(void);
-
-#else /* not __STDC__ */
-
-/* static int getExpression(); */
-static void machine_ip();
-/* static void print_insn(); */
-static void s_data1();
-static void s_use();
-
-#endif /* not __STDC__ */
-
-const pseudo_typeS
- md_pseudo_table[] = {
- { "align", s_align_bytes, 4 },
- { "block", s_space, 0 },
- { "cputype", s_ignore, 0 }, /* CPU as 29000 or 29050 */
- { "reg", s_lsym, 0 }, /* Register equate, same as equ */
- { "space", s_ignore, 0 }, /* Listing control */
- { "sect", s_ignore, 0 }, /* Creation of coff sections */
- { "use", s_use, 0 },
- { "word", cons, 4 },
- { NULL, 0, 0 },
- };
-
-int md_short_jump_size = 4;
-int md_long_jump_size = 4;
-#if defined(BFD_HEADERS)
-#ifdef RELSZ
-const int md_reloc_size = RELSZ; /* Coff headers */
-#else
-const int md_reloc_size = 12; /* something else headers */
-#endif
-#else
-const int md_reloc_size = 12; /* Not bfdized*/
-#endif
-
-/* This array holds the chars that always start a comment. If the
- pre-processor is disabled, these aren't very useful */
-char comment_chars[] = ";";
-
-/* This array holds the chars that only start a comment at the beginning of
- a line. If the line seems to have the form '# 123 filename'
- .line and .file directives will appear in the pre-processed output */
-/* Note that input_file.c hand checks for '#' at the beginning of the
- first line of the input file. This is because the compiler outputs
- #NO_APP at the beginning of its output. */
-/* Also note that comments like this one will always work */
-char line_comment_chars[] = "#";
-
-/* We needed an unused char for line separation to work around the
- lack of macros, using sed and such. */
-char line_separator_chars[] = "@";
-
-/* Chars that can be used to separate mant from exp in floating point nums */
-char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant */
-/* As in 0f12.456 */
-/* or 0d1.2345e12 */
-char FLT_CHARS[] = "rRsSfFdDxXpP";
-
-/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
- changed in read.c. Ideally it shouldn't have to know about it at all,
- but nothing is ideal around here.
- */
-
-static unsigned char octal[256];
-#define isoctal(c) octal[c]
- static unsigned char toHex[256];
-
-/*
- * anull bit - causes the branch delay slot instructions to not be executed
- */
-#define ANNUL (1 << 29)
-
-static void
- s_use()
-{
-
- if (strncmp(input_line_pointer, ".text", 5) == 0) {
- input_line_pointer += 5;
- s_text();
- return;
- }
- if (strncmp(input_line_pointer, ".data", 5) == 0) {
- input_line_pointer += 5;
- s_data();
- return;
- }
- if (strncmp(input_line_pointer, ".data1", 6) == 0) {
- input_line_pointer += 6;
- s_data1();
- return;
- }
- /* Literals can't go in the text segment because you can't read
- from instruction memory on some 29k's. So, into initialized data. */
- if (strncmp(input_line_pointer, ".lit", 4) == 0) {
- input_line_pointer += 4;
- subseg_new(SEG_DATA, 200);
- demand_empty_rest_of_line();
- return;
- }
-
- as_bad("Unknown segment type");
- demand_empty_rest_of_line();
- return;
-}
-
-static void
- s_data1()
-{
- subseg_new(SEG_DATA, 1);
- demand_empty_rest_of_line();
- return;
-}
-
-/* Install symbol definition that maps REGNAME to REGNO.
- FIXME-SOON: These are not recognized in mixed case. */
-
-static void
- insert_sreg (regname, regnum)
-char *regname;
-int regnum;
-{
- /* FIXME-SOON, put something in these syms so they won't be output to the symbol
- table of the resulting object file. */
-
- /* Must be large enough to hold the names of the special registers. */
- char buf[80];
- int i;
-
- symbol_table_insert(symbol_new(regname, SEG_REGISTER, regnum, &zero_address_frag));
- for (i = 0; regname[i]; i++)
- buf[i] = islower (regname[i]) ? toupper (regname[i]) : regname[i];
- buf[i] = '\0';
-
- symbol_table_insert(symbol_new(buf, SEG_REGISTER, regnum, &zero_address_frag));
-} /* insert_sreg() */
-
-/* Install symbol definitions for assorted special registers.
- See ASM29K Ref page 2-9. */
-
-void define_some_regs() {
-#define SREG 256
-
- /* Protected special-purpose register names */
- insert_sreg ("vab", SREG+0);
- insert_sreg ("ops", SREG+1);
- insert_sreg ("cps", SREG+2);
- insert_sreg ("cfg", SREG+3);
- insert_sreg ("cha", SREG+4);
- insert_sreg ("chd", SREG+5);
- insert_sreg ("chc", SREG+6);
- insert_sreg ("rbp", SREG+7);
- insert_sreg ("tmc", SREG+8);
- insert_sreg ("tmr", SREG+9);
- insert_sreg ("pc0", SREG+10);
- insert_sreg ("pc1", SREG+11);
- insert_sreg ("pc2", SREG+12);
- insert_sreg ("mmu", SREG+13);
- insert_sreg ("lru", SREG+14);
-
- /* Unprotected special-purpose register names */
- insert_sreg ("ipc", SREG+128);
- insert_sreg ("ipa", SREG+129);
- insert_sreg ("ipb", SREG+130);
- insert_sreg ("q", SREG+131);
- insert_sreg ("alu", SREG+132);
- insert_sreg ("bp", SREG+133);
- insert_sreg ("fc", SREG+134);
- insert_sreg ("cr", SREG+135);
- insert_sreg ("fpe", SREG+160);
- insert_sreg ("inte",SREG+161);
- insert_sreg ("fps", SREG+162);
- /* "", SREG+163); Reserved */
- insert_sreg ("exop",SREG+164);
-} /* define_some_regs() */
-
-/* This function is called once, at assembler startup time. It should
- set up all the tables, etc. that the MD part of the assembler will need. */
-void
- md_begin()
-{
- register char *retval = NULL;
- int lose = 0;
- register int skipnext = 0;
- register unsigned int i;
- register char *strend, *strend2;
-
- /* Hash up all the opcodes for fast use later. */
-
- op_hash = hash_new();
- if (op_hash == NULL)
- as_fatal("Virtual memory exhausted");
-
- for (i = 0; i < num_opcodes; i++)
- {
- const char *name = machine_opcodes[i].name;
-
- if (skipnext) {
- skipnext = 0;
- continue;
- }
-
- /* Hack to avoid multiple opcode entries. We pre-locate all the
- variations (b/i field and P/A field) and handle them. */
-
- if (!strcmp (name, machine_opcodes[i+1].name)) {
- if ((machine_opcodes[i].opcode ^ machine_opcodes[i+1].opcode)
- != 0x01000000)
- goto bad_table;
- strend = machine_opcodes[i ].args+strlen(machine_opcodes[i ].args)-1;
- strend2 = machine_opcodes[i+1].args+strlen(machine_opcodes[i+1].args)-1;
- switch (*strend) {
- case 'b':
- if (*strend2 != 'i') goto bad_table;
- break;
- case 'i':
- if (*strend2 != 'b') goto bad_table;
- break;
- case 'P':
- if (*strend2 != 'A') goto bad_table;
- break;
- case 'A':
- if (*strend2 != 'P') goto bad_table;
- break;
- default:
- bad_table:
- fprintf (stderr, "internal error: can't handle opcode %s\n", name);
- lose = 1;
- }
-
- /* OK, this is an i/b or A/P pair. We skip the higher-valued one,
- and let the code for operand checking handle OR-ing in the bit. */
- if (machine_opcodes[i].opcode & 1)
- continue;
- else
- skipnext = 1;
- }
-
- retval = hash_insert (op_hash, name, &machine_opcodes[i]);
- if (retval != NULL && *retval != '\0')
- {
- fprintf (stderr, "internal error: can't hash `%s': %s\n",
- machine_opcodes[i].name, retval);
- lose = 1;
- }
- }
-
- if (lose)
- as_fatal("Broken assembler. No assembly attempted.");
-
- for (i = '0'; i < '8'; ++i)
- octal[i] = 1;
- for (i = '0'; i <= '9'; ++i)
- toHex[i] = i - '0';
- for (i = 'a'; i <= 'f'; ++i)
- toHex[i] = i + 10 - 'a';
- for (i = 'A'; i <= 'F'; ++i)
- toHex[i] = i + 10 - 'A';
-
- define_some_regs ();
-}
-
-void md_end() {
- return;
-}
-
-/* Assemble a single instruction. Its label has already been handled
- by the generic front end. We just parse opcode and operands, and
- produce the bytes of data and relocation. */
-
-void md_assemble(str)
-char *str;
-{
- char *toP;
- /* !!!! int rsd; */
-
- know(str);
- machine_ip(str);
- toP = frag_more(4);
- /* put out the opcode */
- md_number_to_chars(toP, the_insn.opcode, 4);
-
- /* put out the symbol-dependent stuff */
- if (the_insn.reloc != NO_RELOC) {
- fix_new(
- frag_now, /* which frag */
- (toP - frag_now->fr_literal + the_insn.reloc_offset), /* where */
- 4, /* size */
- the_insn.exp.X_add_symbol,
- the_insn.exp.X_subtract_symbol,
- the_insn.exp.X_add_number,
- the_insn.pcrel,
- the_insn.reloc
- );
- }
-}
-
-char *
- parse_operand (s, operandp)
-char *s;
-expressionS *operandp;
-{
- char *save = input_line_pointer;
- char *new;
- segT seg;
-
- input_line_pointer = s;
- seg = expr (0, operandp);
- new = input_line_pointer;
- input_line_pointer = save;
-
- switch (seg) {
- case SEG_ABSOLUTE:
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_UNKNOWN:
- case SEG_DIFFERENCE:
- case SEG_BIG:
- case SEG_REGISTER:
- return new;
-
- case SEG_ABSENT:
- as_bad("Missing operand");
- return new;
-
- default:
- as_bad("Don't understand operand of type %s", segment_name (seg));
- return new;
- }
-}
-
-/* Instruction parsing. Takes a string containing the opcode.
- Operands are at input_line_pointer. Output is in the_insn.
- Warnings or errors are generated. */
-
-static void
- machine_ip(str)
-char *str;
-{
- char *s;
- const char *args;
- /* !!!! char c; */
- /* !!!! unsigned long i; */
- struct machine_opcode *insn;
- char *argsStart;
- unsigned long opcode;
- /* !!!! unsigned int mask; */
- expressionS the_operand;
- expressionS *operand = &the_operand;
- unsigned int reg;
-
- /* Must handle `div0' opcode. */
- s = str;
- if (isalpha(*s))
- for (; isalnum(*s); ++s)
- if (isupper (*s))
- *s = tolower (*s);
-
- switch (*s) {
- case '\0':
- break;
-
- case ' ': /* FIXME-SOMEDAY more whitespace */
- *s++ = '\0';
- break;
-
- default:
- as_bad("Unknown opcode: `%s'", str);
- return;
- }
- if ((insn = (struct machine_opcode *) hash_find(op_hash, str)) == NULL) {
- as_bad("Unknown opcode `%s'.", str);
- return;
- }
- argsStart = s;
- opcode = insn->opcode;
- memset(&the_insn, '\0', sizeof(the_insn));
- the_insn.reloc = NO_RELOC;
-
- /*
- * Build the opcode, checking as we go to make
- * sure that the operands match.
- *
- * If an operand matches, we modify the_insn or opcode appropriately,
- * and do a "continue". If an operand fails to match, we "break".
- */
- if (insn->args[0] != '\0')
- s = parse_operand (s, operand); /* Prime the pump */
-
- for (args = insn->args; ; ++args) {
- switch (*args) {
-
- case '\0': /* end of args */
- if (*s == '\0') {
- /* We are truly done. */
- the_insn.opcode = opcode;
- return;
- }
- as_bad("Too many operands: %s", s);
- break;
-
- case ',': /* Must match a comma */
- if (*s++ == ',') {
- s = parse_operand (s, operand); /* Parse next opnd */
- continue;
- }
- break;
-
- case 'v': /* Trap numbers (immediate field) */
- if (operand->X_seg == SEG_ABSOLUTE) {
- if (operand->X_add_number < 256) {
- opcode |= (operand->X_add_number << 16);
- continue;
- } else {
- as_bad("Immediate value of %d is too large",
- operand->X_add_number);
- continue;
- }
- }
- the_insn.reloc = RELOC_8;
- the_insn.reloc_offset = 1; /* BIG-ENDIAN Byte 1 of insn */
- the_insn.exp = *operand;
- continue;
-
- case 'b': /* A general register or 8-bit immediate */
- case 'i':
- /* We treat the two cases identically since we mashed
- them together in the opcode table. */
- if (operand->X_seg == SEG_REGISTER)
- goto general_reg;
-
- opcode |= IMMEDIATE_BIT;
- if (operand->X_seg == SEG_ABSOLUTE) {
- if (operand->X_add_number < 256) {
- opcode |= operand->X_add_number;
- continue;
- } else {
- as_bad("Immediate value of %d is too large",
- operand->X_add_number);
- continue;
- }
- }
- the_insn.reloc = RELOC_8;
- the_insn.reloc_offset = 3; /* BIG-ENDIAN Byte 3 of insn */
- the_insn.exp = *operand;
- continue;
-
- case 'a': /* next operand must be a register */
- case 'c':
- general_reg:
- /* lrNNN or grNNN or %%expr or a user-def register name */
- if (operand->X_seg != SEG_REGISTER)
- break; /* Only registers */
- know (operand->X_add_symbol == 0);
- know (operand->X_subtract_symbol == 0);
- reg = operand->X_add_number;
- if (reg >= SREG)
- break; /* No special registers */
-
- /*
- * Got the register, now figure out where
- * it goes in the opcode.
- */
- switch (*args) {
- case 'a':
- opcode |= reg << 8;
- continue;
-
- case 'b':
- case 'i':
- opcode |= reg;
- continue;
-
- case 'c':
- opcode |= reg << 16;
- continue;
- }
- as_fatal("failed sanity check.");
- break;
-
- case 'x': /* 16 bit constant, zero-extended */
- case 'X': /* 16 bit constant, one-extended */
- if (operand->X_seg == SEG_ABSOLUTE) {
- opcode |= (operand->X_add_number & 0xFF) << 0 |
- ((operand->X_add_number & 0xFF00) << 8);
- continue;
- }
- the_insn.reloc = RELOC_CONST;
- the_insn.exp = *operand;
- continue;
-
- case 'h':
- if (operand->X_seg == SEG_ABSOLUTE) {
- opcode |= (operand->X_add_number & 0x00FF0000) >> 16 |
- (((unsigned long)operand->X_add_number
- /* avoid sign ext */ & 0xFF000000) >> 8);
- continue;
- }
- the_insn.reloc = RELOC_CONSTH;
- the_insn.exp = *operand;
- continue;
-
- case 'P': /* PC-relative jump address */
- case 'A': /* Absolute jump address */
- /* These two are treated together since we folded the
- opcode table entries together. */
- if (operand->X_seg == SEG_ABSOLUTE) {
- opcode |= ABSOLUTE_BIT |
- (operand->X_add_number & 0x0003FC00) << 6 |
- ((operand->X_add_number & 0x000003FC) >> 2);
- continue;
- }
- the_insn.reloc = RELOC_JUMPTARG;
- the_insn.exp = *operand;
- the_insn.pcrel = 1; /* Assume PC-relative jump */
- /* FIXME-SOON, Do we figure out whether abs later, after know sym val? */
- continue;
-
- case 'e': /* Coprocessor enable bit for LOAD/STORE insn */
- if (operand->X_seg == SEG_ABSOLUTE) {
- if (operand->X_add_number == 0)
- continue;
- if (operand->X_add_number == 1) {
- opcode |= CE_BIT;
- continue;
- }
- }
- break;
-
- case 'n': /* Control bits for LOAD/STORE instructions */
- if (operand->X_seg == SEG_ABSOLUTE &&
- operand->X_add_number < 128) {
- opcode |= (operand->X_add_number << 16);
- continue;
- }
- break;
-
- case 's': /* Special register number */
- if (operand->X_seg != SEG_REGISTER)
- break; /* Only registers */
- if (operand->X_add_number < SREG)
- break; /* Not a special register */
- opcode |= (operand->X_add_number & 0xFF) << 8;
- continue;
-
- case 'u': /* UI bit of CONVERT */
- if (operand->X_seg == SEG_ABSOLUTE) {
- if (operand->X_add_number == 0)
- continue;
- if (operand->X_add_number == 1) {
- opcode |= UI_BIT;
- continue;
- }
- }
- break;
-
- case 'r': /* RND bits of CONVERT */
- if (operand->X_seg == SEG_ABSOLUTE &&
- operand->X_add_number < 8) {
- opcode |= operand->X_add_number << 4;
- continue;
- }
- break;
-
- case 'd': /* FD bits of CONVERT */
- if (operand->X_seg == SEG_ABSOLUTE &&
- operand->X_add_number < 4) {
- opcode |= operand->X_add_number << 2;
- continue;
- }
- break;
-
-
- case 'f': /* FS bits of CONVERT */
- if (operand->X_seg == SEG_ABSOLUTE &&
- operand->X_add_number < 4) {
- opcode |= operand->X_add_number << 0;
- continue;
- }
- break;
-
- case 'C':
- if (operand->X_seg == SEG_ABSOLUTE &&
- operand->X_add_number < 4) {
- opcode |= operand->X_add_number << 16;
- continue;
- }
- break;
-
- case 'F':
- if (operand->X_seg == SEG_ABSOLUTE &&
- operand->X_add_number < 16) {
- opcode |= operand->X_add_number << 18;
- continue;
- }
- break;
-
- default:
- BAD_CASE (*args);
- }
- /* Types or values of args don't match. */
- as_bad("Invalid operands");
- return;
- }
-}
-
-/*
- This is identical to the md_atof in m68k.c. I think this is right,
- but I'm not sure.
-
- Turn a string in input_line_pointer into a floating point constant of type
- type, and store the appropriate bytes in *litP. The number of LITTLENUMS
- emitted is stored in *sizeP. An error message is returned, or NULL on OK.
- */
-
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
-char *
- md_atof(type,litP,sizeP)
-char type;
-char *litP;
-int *sizeP;
-{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- char *t;
-
- switch (type) {
-
- case 'f':
- case 'F':
- case 's':
- case 'S':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- prec = 4;
- break;
-
- case 'x':
- case 'X':
- prec = 6;
- break;
-
- case 'p':
- case 'P':
- prec = 6;
- break;
-
- default:
- *sizeP=0;
- return "Bad call to MD_ATOF()";
- }
- t=atof_ieee(input_line_pointer,type,words);
- if (t)
- input_line_pointer=t;
- *sizeP=prec * sizeof(LITTLENUM_TYPE);
- for (wordP=words;prec--;) {
- md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE));
- litP+=sizeof(LITTLENUM_TYPE);
- }
- return ""; /* Someone should teach Dean about null pointers */
-}
-
-/*
- * Write out big-endian.
- */
-void
- md_number_to_chars(buf, val, n)
-char *buf;
-long val;
-int n;
-{
-
- switch (n) {
-
- case 4:
- *buf++ = val >> 24;
- *buf++ = val >> 16;
- case 2:
- *buf++ = val >> 8;
- case 1:
- *buf = val;
- break;
-
- default:
- as_fatal("failed sanity check.");
- }
- return;
-}
-
-void md_apply_fix(fixP, val)
-fixS *fixP;
-long val;
-{
- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- fixP->fx_addnumber = val; /* Remember value for emit_reloc */
-
-
- know(fixP->fx_size == 4);
- know(fixP->fx_r_type < NO_RELOC);
-
- /*
- * This is a hack. There should be a better way to
- * handle this.
- */
- if (fixP->fx_r_type == RELOC_WDISP30 && fixP->fx_addsy) {
- val += fixP->fx_where + fixP->fx_frag->fr_address;
- }
-
- switch (fixP->fx_r_type) {
-
- case RELOC_32:
- buf[0] = val >> 24;
- buf[1] = val >> 16;
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
- case RELOC_8:
- buf[0] = val;
- break;
-
- case RELOC_WDISP30:
- val = (val >>= 2) + 1;
- buf[0] |= (val >> 24) & 0x3f;
- buf[1]= (val >> 16);
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
- case RELOC_HI22:
- buf[1] |= (val >> 26) & 0x3f;
- buf[2] = val >> 18;
- buf[3] = val >> 10;
- break;
-
- case RELOC_LO10:
- buf[2] |= (val >> 8) & 0x03;
- buf[3] = val;
- break;
-
- case RELOC_BASE13:
- buf[2] |= (val >> 8) & 0x1f;
- buf[3] = val;
- break;
-
- case RELOC_WDISP22:
- val = (val >>= 2) + 1;
- /* FALLTHROUGH */
- case RELOC_BASE22:
- buf[1] |= (val >> 16) & 0x3f;
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
-#if 0
- case RELOC_PC10:
- case RELOC_PC22:
- case RELOC_JMP_TBL:
- case RELOC_SEGOFF16:
- case RELOC_GLOB_DAT:
- case RELOC_JMP_SLOT:
- case RELOC_RELATIVE:
-#endif
- case RELOC_JUMPTARG: /* 00XX00XX pattern in a word */
- buf[1] = val >> 10; /* Holds bits 0003FFFC of address */
- buf[3] = val >> 2;
- break;
-
- case RELOC_CONST: /* 00XX00XX pattern in a word */
- buf[1] = val >> 8; /* Holds bits 0000XXXX */
- buf[3] = val;
- break;
-
- case RELOC_CONSTH: /* 00XX00XX pattern in a word */
- buf[1] = val >> 24; /* Holds bits XXXX0000 */
- buf[3] = val >> 16;
- break;
-
- case NO_RELOC:
- default:
- as_bad("bad relocation type: 0x%02x", fixP->fx_r_type);
- break;
- }
- return;
-}
-
-#ifdef OBJ_COFF
-short tc_coff_fix2rtype(fixP)
-fixS *fixP;
-{
-
- /* FIXME-NOW: relocation type handling is not yet written for
- a29k. */
-
-
- switch (fixP->fx_r_type) {
- case RELOC_32: return(R_WORD);
- case RELOC_8: return(R_BYTE);
- case RELOC_CONST: return (R_ILOHALF);
- case RELOC_CONSTH: return (R_IHIHALF);
- case RELOC_JUMPTARG: return (R_IREL);
- default: printf("need %o3\n", fixP->fx_r_type);
- abort(0);
- } /* switch on type */
-
- return(0);
-} /* tc_coff_fix2rtype() */
-#endif /* OBJ_COFF */
-
-/* should never be called for sparc */
-void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr, to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- as_fatal("a29k_create_short_jmp\n");
-}
-
-/* should never be called for 29k */
-void md_convert_frag(headers, fragP)
-object_headers *headers;
-register fragS *fragP;
-{
- as_fatal("sparc_convert_frag\n");
-}
-
-/* should never be called for 29k */
-void md_create_long_jump(ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr;
-long to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- as_fatal("sparc_create_long_jump\n");
-}
-
-/* should never be called for a29k */
-int md_estimate_size_before_relax(fragP, segtype)
-register fragS *fragP;
-segT segtype;
-{
- as_fatal("sparc_estimate_size_before_relax\n");
- return(0);
-}
-
-#if 0
-/* for debugging only */
-static void
- print_insn(insn)
-struct machine_it *insn;
-{
- char *Reloc[] = {
- "RELOC_8",
- "RELOC_16",
- "RELOC_32",
- "RELOC_DISP8",
- "RELOC_DISP16",
- "RELOC_DISP32",
- "RELOC_WDISP30",
- "RELOC_WDISP22",
- "RELOC_HI22",
- "RELOC_22",
- "RELOC_13",
- "RELOC_LO10",
- "RELOC_SFA_BASE",
- "RELOC_SFA_OFF13",
- "RELOC_BASE10",
- "RELOC_BASE13",
- "RELOC_BASE22",
- "RELOC_PC10",
- "RELOC_PC22",
- "RELOC_JMP_TBL",
- "RELOC_SEGOFF16",
- "RELOC_GLOB_DAT",
- "RELOC_JMP_SLOT",
- "RELOC_RELATIVE",
- "NO_RELOC"
- };
-
- if (insn->error) {
- fprintf(stderr, "ERROR: %s\n");
- }
- fprintf(stderr, "opcode=0x%08x\n", insn->opcode);
- fprintf(stderr, "reloc = %s\n", Reloc[insn->reloc]);
- fprintf(stderr, "exp = {\n");
- fprintf(stderr, "\t\tX_add_symbol = %s\n",
- insn->exp.X_add_symbol ?
- (S_GET_NAME(insn->exp.X_add_symbol) ?
- S_GET_NAME(insn->exp.X_add_symbol) : "???") : "0");
- fprintf(stderr, "\t\tX_sub_symbol = %s\n",
- insn->exp.X_subtract_symbol ?
- (S_GET_NAME(insn->exp.X_subtract_symbol) ?
- S_GET_NAME(insn->exp.X_subtract_symbol) : "???") : "0");
- fprintf(stderr, "\t\tX_add_number = %d\n",
- insn->exp.X_add_number);
- fprintf(stderr, "}\n");
- return;
-}
-#endif
-
-/* Translate internal representation of relocation info to target format.
-
- On sparc/29k: first 4 bytes are normal unsigned long address, next three
- bytes are index, most sig. byte first. Byte 7 is broken up with
- bit 7 as external, bits 6 & 5 unused, and the lower
- five bits as relocation type. Next 4 bytes are long addend. */
-/* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com */
-
-#ifdef OBJ_AOUT
-
-void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
-char *where;
-fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- long r_symbolnum;
-
- know(fixP->fx_r_type < NO_RELOC);
- know(fixP->fx_addsy != NULL);
-
- md_number_to_chars(where,
- fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
- 4);
-
- r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
- ? S_GET_TYPE(fixP->fx_addsy)
- : fixP->fx_addsy->sy_number);
-
- where[4] = (r_symbolnum >> 16) & 0x0ff;
- where[5] = (r_symbolnum >> 8) & 0x0ff;
- where[6] = r_symbolnum & 0x0ff;
- where[7] = (((!S_IS_DEFINED(fixP->fx_addsy)) << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F);
- /* Also easy */
- md_number_to_chars(&where[8], fixP->fx_addnumber, 4);
-
- return;
-} /* tc_aout_fix_to_chars() */
-
-#endif /* OBJ_AOUT */
-
-int
- md_parse_option(argP,cntP,vecP)
-char **argP;
-int *cntP;
-char ***vecP;
-{
- return(0);
-}
-
-
-/* Default the values of symbols known that should be "predefined". We
- don't bother to predefine them unless you actually use one, since there
- are a lot of them. */
-
-symbolS *md_undefined_symbol (name)
-char *name;
-{
- long regnum;
- char testbuf[5+ /*SLOP*/ 5];
-
- if (name[0] == 'g' || name[0] == 'G' || name[0] == 'l' || name[0] == 'L')
- {
- /* Perhaps a global or local register name */
- if (name[1] == 'r' || name[1] == 'R')
- {
- /* Parse the number, make sure it has no extra zeroes or trailing
- chars */
- regnum = atol(&name[2]);
- if (regnum > 127)
- return 0;
- sprintf(testbuf, "%ld", regnum);
- if (strcmp (testbuf, &name[2]) != 0)
- return 0; /* gr007 or lr7foo or whatever */
-
- /* We have a wiener! Define and return a new symbol for it. */
- if (name[0] == 'l' || name[0] == 'L')
- regnum += 128;
- return(symbol_new(name, SEG_REGISTER, regnum, &zero_address_frag));
- }
- }
-
- return 0;
-}
-
-/* Parse an operand that is machine-specific. */
-
-void md_operand(expressionP)
-expressionS *expressionP;
-{
-
- if (input_line_pointer[0] == '%' && input_line_pointer[1] == '%')
- {
- /* We have a numeric register expression. No biggy. */
- input_line_pointer += 2; /* Skip %% */
- (void)expression (expressionP);
- if (expressionP->X_seg != SEG_ABSOLUTE
- || expressionP->X_add_number > 255)
- as_bad("Invalid expression after %%%%\n");
- expressionP->X_seg = SEG_REGISTER;
- }
- else if (input_line_pointer[0] == '&')
- {
- /* We are taking the 'address' of a register...this one is not
- in the manual, but it *is* in traps/fpsymbol.h! What they
- seem to want is the register number, as an absolute number. */
- input_line_pointer++; /* Skip & */
- (void)expression (expressionP);
- if (expressionP->X_seg != SEG_REGISTER)
- as_bad("Invalid register in & expression");
- else
- expressionP->X_seg = SEG_ABSOLUTE;
- }
-}
-
-/* Round up a section size to the appropriate boundary. */
-long
- md_section_align (segment, size)
-segT segment;
-long size;
-{
- return size; /* Byte alignment is fine */
-}
-
-/* Exactly what point is a PC-relative offset relative TO?
- On the 29000, they're relative to the address of the instruction,
- which we have set up as the address of the fixup too. */
-long md_pcrel_from (fixP)
-fixS *fixP;
-{
- return fixP->fx_where + fixP->fx_frag->fr_address;
-}
-
-/*
- * Local Variables:
- * comment-column: 0
- * End:
- */
-
-/* end of tc-a29k.c */
diff --git a/gnu/usr.bin/as/config/tc-a29k.h b/gnu/usr.bin/as/config/tc-a29k.h
deleted file mode 100644
index a362595..0000000
--- a/gnu/usr.bin/as/config/tc-a29k.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* tc-a29k.h -- Assemble for the AMD 29000.
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define TC_A29K
-
-#define NO_LISTING
-
-#define tc_aout_pre_write_hook(x) {;} /* not used */
-#define tc_coff_symbol_emit_hook(a) {;} /* not used */
-#define tc_crawl_symbol_chain(a) {;} /* not used */
-#define tc_headers_hook(a) {;} /* not used */
-
-#define AOUT_MACHTYPE 101
-#define TC_COFF_FIX2RTYPE(fix_ptr) tc_coff_fix2rtype(fix_ptr)
-#define BFD_ARCH bfd_arch_a29k
-#define COFF_MAGIC SIPFBOMAGIC
-
-/* Should the reloc be output ?
- on the 29k, this is true only if there is a symbol attatched.
- on the h8, this is allways true, since no fixup is done
- */
-#define TC_COUNT_RELOC(x) (x->fx_addsy)
-
-/* end of tc-a29k.h */
diff --git a/gnu/usr.bin/as/config/tc-generic.c b/gnu/usr.bin/as/config/tc-generic.c
deleted file mode 100644
index e69de29..0000000
--- a/gnu/usr.bin/as/config/tc-generic.c
+++ /dev/null
diff --git a/gnu/usr.bin/as/config/tc-generic.h b/gnu/usr.bin/as/config/tc-generic.h
deleted file mode 100644
index 7a16dd0..0000000
--- a/gnu/usr.bin/as/config/tc-generic.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* This file is tc-generic.h
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * This file is tc-generic.h and is intended to be a template for target cpu
- * specific header files. It is my intent that this file compile. It is also
- * my intent that this file grow into something that can be used as both a
- * template for porting, and a stub for testing. xoxorich.
- */
-
-#define TC_GENERIC 1
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-generic.h */
diff --git a/gnu/usr.bin/as/config/tc-h8300.c b/gnu/usr.bin/as/config/tc-h8300.c
deleted file mode 100644
index 4657d1e..0000000
--- a/gnu/usr.bin/as/config/tc-h8300.c
+++ /dev/null
@@ -1,1295 +0,0 @@
-/* tc-h8300.c -- Assemble code for the Hitachi H8/300
- Copyright (C) 1991, 1992 Free Software Foundation.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
-/*
- Written By Steve Chamberlain
- sac@cygnus.com
- */
-
-#include <stdio.h>
-#include "as.h"
-#include "bfd.h"
-#include "opcode/h8300.h"
-#include <ctype.h>
-#include "listing.h"
-
-char comment_chars[] = { ';',0 };
-char line_separator_chars[] = { '$' ,0};
-
-/* This table describes all the machine specific pseudo-ops the assembler
- has to support. The fields are:
- pseudo-op name without dot
- function to call to execute this pseudo-op
- Integer arg to pass to the function
- */
-
-void cons();
-
-const pseudo_typeS md_pseudo_table[] = {
- { "int", cons, 2 },
- { 0,0,0 }
-};
-
-const int md_reloc_size ;
-
-const char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant */
-/* As in 0f12.456 */
-/* or 0d1.2345e12 */
-char FLT_CHARS[] = "rRsSfFdDxXpP";
-
-
-const relax_typeS md_relax_table[1];
-
-
-static struct hash_control *opcode_hash_control; /* Opcode mnemonics */
-
-
-/*
- This function is called once, at assembler startup time. This should
- set up all the tables, etc that the MD part of the assembler needs
- */
-#if 0
-/* encode the size and number into the number field
- xxnnnn
- 00 8 bit
- 01 16 bit
- 10 ccr
- nnnnreg number
- */
-#define WORD_REG 0x10
-#define BYTE_REG 0x00
-#define CCR_REG 0x20
-struct reg_entry
-{
- char *name;
- char number;
-};
-
-struct reg_entry reg_list[] = {
- "r0",WORD_REG +0,
- "r1",WORD_REG +1,
- "r2",WORD_REG +2,
- "r3",WORD_REG +3,
- "r4",WORD_REG +4,
- "r5",WORD_REG +5,
- "r6",WORD_REG +6,
- "r7",WORD_REG +7,
- "fp",WORD_REG +6,
- "sp",WORD_REG +7,
- "r0h",BYTE_REG + 0,
- "r0l",BYTE_REG + 1,
- "r1h",BYTE_REG + 2,
- "r1l",BYTE_REG + 3,
- "r2h",BYTE_REG + 4,
- "r2l",BYTE_REG + 5,
- "r3h",BYTE_REG + 6,
- "r3l",BYTE_REG + 7,
- "r4h",BYTE_REG + 8,
- "r4l",BYTE_REG + 9,
- "r5h",BYTE_REG + 10,
- "r5l",BYTE_REG + 11,
- "r6h",BYTE_REG + 12,
- "r6l",BYTE_REG + 13,
- "r7h",BYTE_REG + 14,
- "r7l",BYTE_REG + 15,
- "ccr",CCR_REG,
- 0,0
- }
-;
-
-
-#endif
-
-
-void md_begin ()
-{
- struct h8_opcode *opcode;
- const struct reg_entry *reg;
- char prev_buffer[100];
- int idx = 0;
-
- opcode_hash_control = hash_new();
- prev_buffer[0] = 0;
-
- for (opcode = h8_opcodes; opcode->name; opcode++)
- {
- /* Strip off any . part when inserting the opcode and only enter
- unique codes into the hash table
- */
- char *src= opcode->name;
- unsigned int len = strlen(src);
- char *dst = malloc(len+1);
- char *buffer = dst;
- opcode->size = 0;
- while (*src) {
- if (*src == '.') {
- *dst++ = 0;
- src++;
- opcode->size = *src;
- break;
- }
- *dst++ = *src++;
- }
- if (strcmp(buffer, prev_buffer))
- {
- hash_insert(opcode_hash_control, buffer, (char *)opcode);
- strcpy(prev_buffer, buffer);
- idx++;
- }
- opcode->idx = idx;
-
-
- /* Find the number of operands */
- opcode->noperands = 0;
- while (opcode->args.nib[opcode->noperands] != E)
- opcode->noperands ++;
- /* Find the length of the opcode in bytes */
- opcode->length =0;
- while (opcode->data.nib[opcode->length*2] != E)
- opcode->length++;
- }
-
-}
-
-
-struct h8_exp {
- char *e_beg;
- char *e_end;
- expressionS e_exp;
-};
-struct h8_op
-{
- unsigned int dispreg;
- op_type mode;
- unsigned reg;
- expressionS exp;
-};
-
-
-
-/*
- parse operands
- WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
- r0l,r0h,..r7l,r7h
- @WREG
- @WREG+
- @-WREG
- #const
-
- */
-
-op_type r8_sord[] = {RS8, RD8};
-op_type r16_sord[] = {RS16, RD16};
-op_type rind_sord[] = {RSIND, RDIND};
-op_type abs_sord[2] = {ABS16SRC, ABS16DST};
-op_type disp_sord[] = {DISPSRC, DISPDST};
-
-/* try and parse a reg name, returns number of chars consumed */
-int
- DEFUN(parse_reg,(src, mode, reg, dst),
- char *src AND
- op_type *mode AND
- unsigned int *reg AND
- int dst)
-{
- if (src[0] == 's' && src[1] == 'p')
- {
- *mode = r16_sord[dst];
- *reg = 7;
- return 2;
- }
- if (src[0] == 'c' && src[1] == 'c' && src[2] == 'r')
- {
- *mode = CCR;
- *reg = 0;
- return 3;
- }
- if (src[0] == 'f' && src[1] == 'p')
- {
- *mode = r16_sord[dst];
- *reg = 6;
- return 2;
- }
- if (src[0] == 'r')
- {
- if (src[1] >= '0' && src[1] <= '7')
- {
- if (src[2] == 'l')
- {
- *mode = r8_sord[dst];
- *reg = (src[1] - '0') + 8;
- return 3;
- }
- if (src[2] == 'h')
- {
- *mode = r8_sord[dst];
- *reg = (src[1] - '0') ;
- return 3;
- }
- *mode = r16_sord[dst];
- *reg = (src[1] - '0');
- return 2;
- }
- }
- return 0;
-}
-
-char *
- DEFUN(parse_exp,(s, op),
- char *s AND
- expressionS *op)
-{
- char *save = input_line_pointer;
- char *new;
- segT seg;
- input_line_pointer = s;
- seg = expr(0,op);
- new = input_line_pointer;
- input_line_pointer = save;
- if (SEG_NORMAL(seg))
- return new;
- switch (seg) {
- case SEG_ABSOLUTE:
- case SEG_UNKNOWN:
- case SEG_DIFFERENCE:
- case SEG_BIG:
- case SEG_REGISTER:
- return new;
- case SEG_ABSENT:
- as_bad("Missing operand");
- return new;
- default:
- as_bad("Don't understand operand of type %s", segment_name (seg));
- return new;
- }
-}
-
-static char *
- DEFUN(skip_colonthing,(ptr),
- char *ptr)
-{
- if (*ptr == ':') {
- ptr++;
- while (isdigit(*ptr))
- ptr++;
-
- }
- return ptr;
-}
-
-/* The many forms of operand:
-
- Rn Register direct
- @Rn Register indirect
- @(exp[:16], Rn) Register indirect with displacement
- @Rn+
- @-Rn
- @aa:8 absolute 8 bit
- @aa:16 absolute 16 bit
- @aa absolute 16 bit
-
- #xx[:size] immediate data
- @(exp:[8], pc) pc rel
- @@aa[:8] memory indirect
-
- */
-
-static void
- DEFUN(get_operand,(ptr, op, dst),
- char **ptr AND
- struct h8_op *op AND
- unsigned int dst)
-{
- char *src = *ptr;
- op_type mode;
- unsigned int num;
- unsigned int len;
- unsigned int size;
- op->mode = E;
-
- len = parse_reg(src, &op->mode, &op->reg, dst);
- if (len) {
- *ptr = src + len;
- return ;
- }
-
- if (*src == '@')
- {
- src++;
- if (*src == '@')
- {
- src++;
- src = parse_exp(src,&op->exp);
- src = skip_colonthing(src);
-
- *ptr = src;
-
- op->mode = MEMIND;
- return;
-
- }
-
-
- if (*src == '-')
- {
- src++;
- len = parse_reg(src, &mode, &num, dst);
- if (len == 0)
- {
- /* Oops, not a reg after all, must be ordinary exp */
- src--;
- /* must be a symbol */
- op->mode = abs_sord[dst];
- *ptr = skip_colonthing(parse_exp(src, &op->exp));
-
- return;
-
-
- }
-
- if (mode != r16_sord[dst])
- {
- as_bad("@- needs word register");
- }
- op->mode = RDDEC;
- op->reg = num;
- *ptr = src + len;
- return;
- }
- if (*src == '(' && ')')
- {
- /* Disp */
- src++;
- src = parse_exp(src, &op->exp);
-
- if (*src == ')')
- {
- src++;
- op->mode = abs_sord[dst];
- *ptr = src;
- return;
- }
- src = skip_colonthing(src);
-
- if (*src != ',')
- {
- as_bad("expected @(exp, reg16)");
- }
- src++;
- len = parse_reg(src, &mode, &op->reg, dst);
- if (len == 0 || mode != r16_sord[dst])
- {
- as_bad("expected @(exp, reg16)");
- }
- op->mode = disp_sord[dst];
- src += len;
- src = skip_colonthing(src);
-
- if (*src != ')' && '(')
- {
- as_bad("expected @(exp, reg16)");
-
- }
- *ptr = src +1;
-
- return;
- }
- len = parse_reg(src, &mode, &num, dst);
-
- if (len) {
- src += len;
- if (*src == '+')
- {
- src++;
- if (mode != RS16)
- {
- as_bad("@Rn+ needs src word register");
- }
- op->mode = RSINC;
- op->reg = num;
- *ptr = src;
- return;
- }
- if (mode != r16_sord[dst])
- {
- as_bad("@Rn needs word register");
- }
- op->mode =rind_sord[dst];
- op->reg = num;
- *ptr = src;
- return;
- }
- else
- {
- /* must be a symbol */
- op->mode = abs_sord[dst];
- *ptr = skip_colonthing(parse_exp(src, &op->exp));
-
- return;
- }
- }
-
-
- if (*src == '#') {
- src++;
- op->mode = IMM16;
- src = parse_exp(src, &op->exp);
- *ptr= skip_colonthing(src);
-
- return;
- }
- else {
- *ptr = parse_exp(src, &op->exp);
- op->mode = DISP8;
- }
-}
-
-
-static
- char *
- DEFUN(get_operands,(noperands,op_end, operand),
- unsigned int noperands AND
- char *op_end AND
- struct h8_op *operand)
-{
- char *ptr = op_end;
- switch (noperands)
- {
- case 0:
- operand[0].mode = 0;
- operand[1].mode = 0;
- break;
-
- case 1:
- ptr++;
- get_operand(& ptr, operand +0,0);
- operand[1].mode =0;
- break;
-
- case 2:
- ptr++;
- get_operand(& ptr, operand +0,0);
- if (*ptr == ',') ptr++;
- get_operand(& ptr, operand +1, 1);
- break;
-
- default:
- abort();
- }
-
-
- return ptr;
-}
-
-/* Passed a pointer to a list of opcodes which use different
- addressing modes, return the opcode which matches the opcodes
- provided
- */
-static
- struct h8_opcode *
- DEFUN(get_specific,(opcode, operands),
- struct h8_opcode *opcode AND
- struct h8_op *operands)
-
-{
- struct h8_opcode *this_try = opcode ;
- int found = 0;
- unsigned int noperands = opcode->noperands;
-
- unsigned int dispreg;
- unsigned int this_index = opcode->idx;
- while (this_index == opcode->idx && !found)
- {
- unsigned int i;
-
- this_try = opcode ++;
- for (i = 0; i < noperands; i++)
- {
- op_type op = (this_try->args.nib[i]) & ~(B30|B31);
- switch (op)
- {
- case Hex0:
- case Hex1:
- case Hex2:
- case Hex3:
- case Hex4:
- case Hex5:
- case Hex6:
- case Hex7:
- case Hex8:
- case Hex9:
- case HexA:
- case HexB:
- case HexC:
- case HexD:
- case HexE:
- case HexF:
- break;
- case DISPSRC:
- case DISPDST:
- operands[0].dispreg = operands[i].reg;
- case RD8:
- case RS8:
- case RDIND:
- case RSIND:
- case RD16:
- case RS16:
- case CCR:
- case RSINC:
- case RDDEC:
- if (operands[i].mode != op) goto fail;
- break;
- case KBIT:
- case IMM16:
- case IMM3:
- case IMM8:
- if (operands[i].mode != IMM16) goto fail;
- break;
- case MEMIND:
- if (operands[i].mode != MEMIND) goto fail;
- break;
- case ABS16SRC:
- case ABS8SRC:
- case ABS16OR8SRC:
- case ABS16ORREL8SRC:
-
- if (operands[i].mode != ABS16SRC) goto fail;
- break;
- case ABS16OR8DST:
- case ABS16DST:
- case ABS8DST:
- if (operands[i].mode != ABS16DST) goto fail;
- break;
- }
- }
- found =1;
- fail: ;
- }
- if (found)
- return this_try;
- else
- return 0;
-}
-
-static void
- DEFUN(check_operand,(operand, width, string),
- struct h8_op *operand AND
- unsigned int width AND
- char *string)
-{
- if (operand->exp.X_add_symbol == 0
- && operand->exp.X_subtract_symbol == 0)
- {
-
- /* No symbol involved, let's look at offset, it's dangerous if any of
- the high bits are not 0 or ff's, find out by oring or anding with
- the width and seeing if the answer is 0 or all fs*/
- if ((operand->exp.X_add_number | width) != ~0 &&
- (operand->exp.X_add_number & ~width) != 0)
- {
- as_warn("operand %s0x%x out of range.", string, operand->exp.X_add_number);
- }
- }
-
-}
-
-/* Now we know what sort of opcodes it is, lets build the bytes -
- */
-static void
- DEFUN (build_bytes,(this_try, operand),
- struct h8_opcode *this_try AND
- struct h8_op *operand)
-
-{
- unsigned int i;
-
- char *output = frag_more(this_try->length);
- char *output_ptr = output;
- op_type *nibble_ptr = this_try->data.nib;
- char part;
- op_type c;
- char high;
- int nib;
- top: ;
- while (*nibble_ptr != E)
- {
- int nibble;
- for (nibble = 0; nibble <2; nibble++)
- {
- c = *nibble_ptr & ~(B30|B31);
- switch (c)
- {
- default:
- abort();
- case KBIT:
- switch (operand[0].exp.X_add_number)
- {
- case 1:
- nib = 0;
- break;
- case 2:
- nib = 8;
- break;
- default:
- as_bad("Need #1 or #2 here");
- break;
- }
- /* stop it making a fix */
- operand[0].mode = 0;
- break;
- case 0:
- case 1:
- case 2: case 3: case 4: case 5: case 6:
- case 7: case 8: case 9: case 10: case 11:
- case 12: case 13: case 14: case 15:
- nib = c;
- break;
- case DISPREG:
- nib = operand[0].dispreg;
- break;
- case IMM8:
- operand[0].mode = IMM8;
- nib = 0;
- break;
-
- case DISPDST:
- nib = 0;
- break;
- case IMM3:
- if (operand[0].exp.X_add_symbol == 0) {
- operand[0].mode = 0; /* stop it making a fix */
- nib = (operand[0].exp.X_add_number);
- }
- else as_bad("can't have symbol for bit number");
- if (nib < 0 || nib > 7)
- {
- as_bad("Bit number out of range %d", nib);
- }
-
- break;
-
- case ABS16DST:
- nib = 0;
- break;
- case ABS8DST:
- operand[1].mode = ABS8DST;
- nib = 0;
- break;
- case ABS8SRC:
- operand[0].mode = ABS8SRC;
- nib = 0;
- break;
- case ABS16OR8DST:
- operand[1].mode = c;
-
- nib = 0;
-
- break;
-
- case ABS16ORREL8SRC:
- operand[0].mode = c;
- nib=0;
- break;
-
- case ABS16OR8SRC:
- operand[0].mode = ABS16OR8SRC;
- nib = 0;
- break;
- case DISPSRC:
- operand[0].mode = ABS16SRC;
- nib = 0;
- break;
-
- case DISP8:
- operand[0].mode = DISP8;
- nib = 0;
- break;
-
- case ABS16SRC:
- case IMM16:
- case IGNORE:
- case MEMIND:
-
- nib=0;
- break;
- case RS8:
- case RS16:
- case RSIND:
- case RSINC:
- nib = operand[0].reg;
- break;
-
- case RD8:
- case RD16:
- case RDDEC:
- case RDIND:
- nib = operand[1].reg;
- break;
-
- case E:
- abort();
- break;
- }
- if (*nibble_ptr & B31) {
- nib |=0x8;
- }
-
- if (nibble == 0) {
- *output_ptr = nib << 4;
- }
- else {
- *output_ptr |= nib;
- output_ptr++;
- }
- nibble_ptr++;
- }
-
- }
-
- /* output any fixes */
- for (i = 0; i < 2; i++)
- {
- switch (operand[i].mode) {
- case 0:
- break;
-
- case DISP8:
- check_operand(operand+i, 0x7f,"@");
-
- fix_new(frag_now,
- output - frag_now->fr_literal + 1,
- 1,
- operand[i].exp.X_add_symbol,
- operand[i].exp.X_subtract_symbol,
- operand[i].exp.X_add_number -1,
- 1,
- R_PCRBYTE);
- break;
- case IMM8:
- check_operand(operand+i, 0xff,"#");
- /* If there is nothing else going on we can safely
- reloc in place */
- if (operand[i].exp.X_add_symbol == 0)
- {
- output[1] = operand[i].exp.X_add_number;
- }
- else
- {
- fix_new(frag_now,
- output - frag_now->fr_literal + 1,
- 1,
- operand[i].exp.X_add_symbol,
- operand[i].exp.X_subtract_symbol,
- operand[i].exp.X_add_number,
- 0,
- R_RELBYTE);
- }
-
- break;
- case MEMIND:
- check_operand(operand+i, 0xff,"@@");
- fix_new(frag_now,
- output - frag_now->fr_literal + 1,
- 1,
- operand[i].exp.X_add_symbol,
- operand[i].exp.X_subtract_symbol,
- operand[i].exp.X_add_number,
- 0,
- R_RELBYTE);
- break;
- case ABS8DST:
- case ABS8SRC:
- check_operand(operand+i, 0xff,"@");
- fix_new(frag_now,
- output - frag_now->fr_literal + 1,
- 1,
- operand[i].exp.X_add_symbol,
- operand[i].exp.X_subtract_symbol,
- operand[i].exp.X_add_number,
- 0,
- R_RELBYTE);
- break;
-
- case ABS16OR8SRC:
- case ABS16OR8DST:
- check_operand(operand+i, 0xffff,"@");
-
- fix_new(frag_now,
- output - frag_now->fr_literal + 2,
- 2,
- operand[i].exp.X_add_symbol,
- operand[i].exp.X_subtract_symbol,
- operand[i].exp.X_add_number,
- 0,
- R_MOVB1);
- break;
-
- case ABS16ORREL8SRC:
- check_operand(operand+i, 0xffff,"@");
-
- fix_new(frag_now,
- output - frag_now->fr_literal + 2,
- 2,
- operand[i].exp.X_add_symbol,
- operand[i].exp.X_subtract_symbol,
- operand[i].exp.X_add_number,
- 0,
- R_JMP1);
- break;
-
-
- case ABS16SRC:
- case ABS16DST:
- case IMM16:
- case DISPSRC:
- case DISPDST:
- check_operand(operand+i, 0xffff,"@");
- if (operand[i].exp.X_add_symbol == 0)
- {
- /* This should be done with bfd */
- output[3] = operand[i].exp.X_add_number & 0xff;
- output[2] = operand[i].exp.X_add_number >> 8;
-
- }
- else
- {
-
- fix_new(frag_now,
- output - frag_now->fr_literal + 2,
- 2,
- operand[i].exp.X_add_symbol,
- operand[i].exp.X_subtract_symbol,
- operand[i].exp.X_add_number,
- 0,
- R_RELWORD);
- }
-
- break;
- case RS8:
- case RD8:
- case RS16:
- case RD16:
- case RDDEC:
- case KBIT:
- case RSINC:
- case RDIND:
- case RSIND:
- case CCR:
-
- break;
- default:
- abort();
- }
- }
-
-}
-/*
- try and give an intelligent error message for common and simple to
- detect errors
- */
-
-static void
- DEFUN(clever_message, (opcode, operand),
- struct h8_opcode *opcode AND
- struct h8_op *operand)
-{
- struct h8_opcode *scan = opcode;
-
- /* Find out if there was more than one possible opccode */
-
- if ((opcode+1)->idx != opcode->idx)
- {
- unsigned int argn;
-
- /* Only one opcode of this flavour, try and guess which operand
- didn't match */
- for (argn = 0; argn < opcode->noperands; argn++)
- {
- switch (opcode->args.nib[argn])
- {
- case RD16:
- if (operand[argn].mode != RD16)
- {
- as_bad("destination operand must be 16 bit register");
- }
- return;
- case RS8:
-
- if (operand[argn].mode != RS8)
- {
- as_bad("source operand must be 8 bit register");
- }
- return;
- case ABS16DST:
- if (operand[argn].mode != ABS16DST)
- {
- as_bad("destination operand must be 16bit absolute address");
- return;
- }
-
- case RD8:
- if (operand[argn].mode != RD8)
- {
- as_bad("destination operand must be 8 bit register");
- }
- return;
-
- case ABS16SRC:
- if (operand[argn].mode != ABS16SRC)
- {
- as_bad("source operand must be 16bit absolute address");
- return;
- }
- }
- }
- }
- as_bad("invalid operands");
-}
-
-/* This is the guts of the machine-dependent assembler. STR points to a
- machine dependent instruction. This funciton is supposed to emit
- the frags/bytes it assembles to.
- */
-
-
-
-void
- DEFUN(md_assemble,(str),
- char *str)
-{
- char *op_start;
- char *op_end;
- unsigned int i;
- struct h8_op operand[2];
- struct h8_opcode * opcode;
- struct h8_opcode * prev_opcode;
-
- char *dot = 0;
- char c;
- /* Drop leading whitespace */
- while (*str == ' ')
- str++;
-
- /* find the op code end */
- for (op_start = op_end = str;
- *op_end != 0 && *op_end != ' ';
- op_end ++)
- {
- if (*op_end == '.') {
- dot = op_end+1;
- *op_end = 0;
- op_end+=2;
- break;
- }
- }
-
- ;
-
- if (op_end == op_start)
- {
- as_bad("can't find opcode ");
- }
- c = *op_end;
-
- *op_end = 0;
-
- opcode = (struct h8_opcode *) hash_find(opcode_hash_control,
- op_start);
-
- if (opcode == NULL)
- {
- as_bad("unknown opcode");
- return;
- }
-
-
- input_line_pointer = get_operands(opcode->noperands, op_end,
- operand);
- *op_end = c;
- prev_opcode = opcode;
-
- opcode = get_specific(opcode, operand);
-
- if (opcode == 0)
- {
- /* Couldn't find an opcode which matched the operands */
- char *where =frag_more(2);
- where[0] = 0x0;
- where[1] = 0x0;
- clever_message(prev_opcode, operand);
-
- return;
- }
- if (opcode->size && dot)
- {
- if (opcode->size != *dot)
- {
- as_warn("mismatch between opcode size and operand size");
- }
- }
-
- build_bytes(opcode, operand);
-
-}
-
-void
- DEFUN(tc_crawl_symbol_chain, (headers),
- object_headers *headers)
-{
- printf("call to tc_crawl_symbol_chain \n");
-}
-
-symbolS *DEFUN(md_undefined_symbol,(name),
- char *name)
-{
- return 0;
-}
-
-void
- DEFUN(tc_headers_hook,(headers),
- object_headers *headers)
-{
- printf("call to tc_headers_hook \n");
-}
-void
- DEFUN_VOID(md_end)
-{
-}
-
-/* Various routines to kill one day */
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
-/* Turn a string in input_line_pointer into a floating point constant of type
- type, and store the appropriate bytes in *litP. The number of LITTLENUMS
- emitted is stored in *sizeP. An error message is returned, or NULL on OK.
- */
-char *
- md_atof(type,litP,sizeP)
-char type;
-char *litP;
-int *sizeP;
-{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- char *t;
- char *atof_ieee();
-
- switch (type) {
- case 'f':
- case 'F':
- case 's':
- case 'S':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- prec = 4;
- break;
-
- case 'x':
- case 'X':
- prec = 6;
- break;
-
- case 'p':
- case 'P':
- prec = 6;
- break;
-
- default:
- *sizeP=0;
- return "Bad call to MD_ATOF()";
- }
- t=atof_ieee(input_line_pointer,type,words);
- if (t)
- input_line_pointer=t;
-
- *sizeP=prec * sizeof(LITTLENUM_TYPE);
- for (wordP=words;prec--;) {
- md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE));
- litP+=sizeof(LITTLENUM_TYPE);
- }
- return ""; /* Someone should teach Dean about null pointers */
-}
-
-int
- md_parse_option(argP, cntP, vecP)
-char **argP;
-int *cntP;
-char ***vecP;
-
-{
- return 0;
-
-}
-
-int md_short_jump_size;
-
-void tc_aout_fix_to_chars () { printf("call to tc_aout_fix_to_chars \n");
- abort(); }
-void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr;
-long to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- as_fatal("failed sanity check.");
-}
-
-void
- md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol)
-char *ptr;
-long from_addr, to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- as_fatal("failed sanity check.");
-}
-
-void
- md_convert_frag(headers, fragP)
-object_headers *headers;
-fragS * fragP;
-
-{ printf("call to md_convert_frag \n"); abort(); }
-
-long
- DEFUN(md_section_align,(seg, size),
- segT seg AND
- long size)
-{
- return((size + (1 << section_alignment[(int) seg]) - 1) & (-1 << section_alignment[(int) seg]));
-
-}
-
-void
- md_apply_fix(fixP, val)
-fixS *fixP;
-long val;
-{
- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- switch (fixP->fx_size) {
- case 1:
- *buf++=val;
- break;
- case 2:
- *buf++=(val>>8);
- *buf++=val;
- break;
- case 4:
- *buf++=(val>>24);
- *buf++=(val>>16);
- *buf++=(val>>8);
- *buf++=val;
- break;
- default:
- abort();
-
- }
-}
-
-void DEFUN(md_operand, (expressionP),expressionS *expressionP)
-{ }
-
-int md_long_jump_size;
-int
- md_estimate_size_before_relax(fragP, segment_type)
-register fragS *fragP;
-register segT segment_type;
-{
- printf("call tomd_estimate_size_before_relax \n"); abort(); }
-/* Put number into target byte order */
-
-void DEFUN(md_number_to_chars,(ptr, use, nbytes),
- char *ptr AND
- long use AND
- int nbytes)
-{
- switch (nbytes) {
- case 4: *ptr++ = (use >> 24) & 0xff;
- case 3: *ptr++ = (use >> 16) & 0xff;
- case 2: *ptr++ = (use >> 8) & 0xff;
- case 1: *ptr++ = (use >> 0) & 0xff;
- break;
- default:
- abort();
- }
-}
-long md_pcrel_from(fixP)
-fixS *fixP; { abort(); }
-
-void tc_coff_symbol_emit_hook() { }
-
-
-void tc_reloc_mangle(fix_ptr, intr, base)
-fixS *fix_ptr;
-struct internal_reloc *intr;
-bfd_vma base;
-
-{
- symbolS *symbol_ptr;
-
- symbol_ptr = fix_ptr->fx_addsy;
-
- /* If this relocation is attached to a symbol then it's ok
- to output it */
- if (fix_ptr->fx_r_type == RELOC_32) {
- /* cons likes to create reloc32's whatever the size of the reloc..
- */
- switch (fix_ptr->fx_size)
- {
-
- case 2:
- intr->r_type = R_RELWORD;
- break;
- case 1:
- intr->r_type = R_RELBYTE;
- break;
- default:
- abort();
-
- }
-
- }
- else {
- intr->r_type = fix_ptr->fx_r_type;
- }
-
- intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where +base;
- intr->r_offset = fix_ptr->fx_offset;
-
- if (symbol_ptr)
- intr->r_symndx = symbol_ptr->sy_number;
- else
- intr->r_symndx = -1;
-
-
-}
-
-/* end of tc-h8300.c */
diff --git a/gnu/usr.bin/as/config/tc-h8300.h b/gnu/usr.bin/as/config/tc-h8300.h
deleted file mode 100644
index dc01f6c..0000000
--- a/gnu/usr.bin/as/config/tc-h8300.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* This file is tc-h8300.h
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
-#define TC_H8300
-
-/* This macro translates between an internal fix and an coff reloc type */
-#define TC_COFF_FIX2RTYPE(fixP) abort();
-
-#define BFD_ARCH bfd_arch_h8300
-#define COFF_MAGIC 0x8300
-#define TC_COUNT_RELOC(x) (1)
-
-
-#define TC_RELOC_MANGLE(a,b,c) tc_reloc_mangle(a,b,c)
-
-#define DO_NOT_STRIP 1
-#define DO_STRIP 0
-#define LISTING_HEADER "Hitachi H8/300 GAS "
-
-/* end of tc-h8300.h */
diff --git a/gnu/usr.bin/as/config/tc-i386.c b/gnu/usr.bin/as/config/tc-i386.c
deleted file mode 100644
index fba7800..0000000
--- a/gnu/usr.bin/as/config/tc-i386.c
+++ /dev/null
@@ -1,2345 +0,0 @@
-/* i386.c -- Assemble code for the Intel 80386
- Copyright (C) 1989, 1991, 1992 Free Software Foundation.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- Intel 80386 machine specific gas.
- Written by Eliot Dresselhaus (eliot@mgm.mit.edu).
- Bugs & suggestions are completely welcome. This is free software.
- Please help us make it better.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "as.h"
-
-#include "obstack.h"
-#include "opcode/i386.h"
-
-/* 'md_assemble ()' gathers together information and puts it into a
- i386_insn. */
-
-typedef struct {
- /* TM holds the template for the insn were currently assembling. */
- template tm;
- /* SUFFIX holds the opcode suffix (e.g. 'l' for 'movl') if given. */
- char suffix;
- /* Operands are coded with OPERANDS, TYPES, DISPS, IMMS, and REGS. */
-
- /* OPERANDS gives the number of given operands. */
- unsigned int operands;
-
- /* REG_OPERANDS, DISP_OPERANDS, MEM_OPERANDS, IMM_OPERANDS give the number of
- given register, displacement, memory operands and immediate operands. */
- unsigned int reg_operands, disp_operands, mem_operands, imm_operands;
-
- /* TYPES [i] is the type (see above #defines) which tells us how to
- search through DISPS [i] & IMMS [i] & REGS [i] for the required
- operand. */
- unsigned int types[MAX_OPERANDS];
-
- /* Displacements (if given) for each operand. */
- expressionS *disps[MAX_OPERANDS];
-
-#ifdef PIC
- /* Relocation type for operand */
- enum reloc_type disp_reloc[MAX_OPERANDS];
-#endif
-
- /* Immediate operands (if given) for each operand. */
- expressionS *imms[MAX_OPERANDS];
-
- /* Register operands (if given) for each operand. */
- reg_entry *regs[MAX_OPERANDS];
-
- /* BASE_REG, INDEX_REG, and LOG2_SCALE_FACTOR are used to encode
- the base index byte below. */
- reg_entry *base_reg;
- reg_entry *index_reg;
- unsigned int log2_scale_factor;
-
- /* SEG gives the seg_entry of this insn. It is equal to zero unless
- an explicit segment override is given. */
- const seg_entry *seg; /* segment for memory operands (if given) */
-
- /* PREFIX holds all the given prefix opcodes (usually null).
- PREFIXES is the size of PREFIX. */
- /* richfix: really unsigned? */
- unsigned char prefix[MAX_PREFIXES];
- unsigned int prefixes;
-
- /* RM and IB are the modrm byte and the base index byte where the addressing
- modes of this insn are encoded. */
-
- modrm_byte rm;
- base_index_byte bi;
-
-} i386_insn;
-
-/* This array holds the chars that always start a comment. If the
- pre-processor is disabled, these aren't very useful */
-const char comment_chars[] = "#";
-
-/* This array holds the chars that only start a comment at the beginning of
- a line. If the line seems to have the form '# 123 filename'
- .line and .file directives will appear in the pre-processed output */
-/* Note that input_file.c hand checks for '#' at the beginning of the
- first line of the input file. This is because the compiler outputs
- #NO_APP at the beginning of its output. */
-/* Also note that comments started like this one will always work if
- '/' isn't otherwise defined. */
-const char line_comment_chars[] = "#/"; /* removed '#' xoxorich. */
-
-/* Chars that can be used to separate mant from exp in floating point nums */
-const char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant */
-/* As in 0f12.456 */
-/* or 0d1.2345e12 */
-const char FLT_CHARS[] = "fFdDxX";
-
-/* tables for lexical analysis */
-static char opcode_chars[256];
-static char register_chars[256];
-static char operand_chars[256];
-static char space_chars[256];
-static char identifier_chars[256];
-static char digit_chars[256];
-
-/* lexical macros */
-#define is_opcode_char(x) (opcode_chars[(unsigned char) x])
-#define is_operand_char(x) (operand_chars[(unsigned char) x])
-#define is_register_char(x) (register_chars[(unsigned char) x])
-#define is_space_char(x) (space_chars[(unsigned char) x])
-#define is_identifier_char(x) (identifier_chars[(unsigned char) x])
-#define is_digit_char(x) (digit_chars[(unsigned char) x])
-
-/* put here all non-digit non-letter charcters that may occur in an operand */
-static char operand_special_chars[] = "%$-+(,)*._~/<>|&^!:";
-
-static char *ordinal_names[] = { "first", "second", "third" }; /* for printfs */
-
-/* md_assemble() always leaves the strings it's passed unaltered. To
- effect this we maintain a stack of saved characters that we've smashed
- with '\0's (indicating end of strings for various sub-fields of the
- assembler instruction). */
-static char save_stack[32];
-static char *save_stack_p; /* stack pointer */
-#define END_STRING_AND_SAVE(s) *save_stack_p++ = *s; *s = '\0'
-#define RESTORE_END_STRING(s) *s = *--save_stack_p
-
- /* The instruction we're assembling. */
- static i386_insn i;
-
-/* Per instruction expressionS buffers: 2 displacements & 2 immediate max. */
-static expressionS disp_expressions[2], im_expressions[2];
-
-/* pointers to ebp & esp entries in reg_hash hash table */
-static reg_entry *ebp, *esp;
-
-static int this_operand; /* current operand we are working on */
-
-/*
- Interface to relax_segment.
- There are 2 relax states for 386 jump insns: one for conditional & one
- for unconditional jumps. This is because the these two types of jumps
- add different sizes to frags when we're figuring out what sort of jump
- to choose to reach a given label. */
-
-/* types */
-#define COND_JUMP 1 /* conditional jump */
-#define UNCOND_JUMP 2 /* unconditional jump */
-/* sizes */
-#define BYTE 0
-#define WORD 1
-#define DWORD 2
-#define UNKNOWN_SIZE 3
-
-#define ENCODE_RELAX_STATE(type,size) ((type<<2) | (size))
-#define SIZE_FROM_RELAX_STATE(s) \
- ( (((s) & 0x3) == BYTE ? 1 : (((s) & 0x3) == WORD ? 2 : 4)) )
-
-const relax_typeS md_relax_table[] = {
- /*
- The fields are:
- 1) most positive reach of this state,
- 2) most negative reach of this state,
- 3) how many bytes this mode will add to the size of the current frag
- 4) which index into the table to try if we can't fit into this one.
- */
- {1, 1, 0, 0},
- {1, 1, 0, 0},
- {1, 1, 0, 0},
- {1, 1, 0, 0},
-
- /* For now we don't use word displacement jumps: they may be
- untrustworthy. */
- {127+1, -128+1, 0, ENCODE_RELAX_STATE(COND_JUMP,DWORD) },
- /* word conditionals add 3 bytes to frag:
- 2 opcode prefix; 1 displacement bytes */
- {32767+2, -32768+2, 3, ENCODE_RELAX_STATE(COND_JUMP,DWORD) },
- /* dword conditionals adds 4 bytes to frag:
- 1 opcode prefix; 3 displacement bytes */
- {0, 0, 4, 0},
- {1, 1, 0, 0},
-
- {127+1, -128+1, 0, ENCODE_RELAX_STATE(UNCOND_JUMP,DWORD) },
- /* word jmp adds 2 bytes to frag:
- 1 opcode prefix; 1 displacement bytes */
- {32767+2, -32768+2, 2, ENCODE_RELAX_STATE(UNCOND_JUMP,DWORD) },
- /* dword jmp adds 3 bytes to frag:
- 0 opcode prefix; 3 displacement bytes */
- {0, 0, 3, 0},
- {1, 1, 0, 0},
-
-};
-
-#if __STDC__ == 1
-
-static char *output_invalid(int c);
-static int fits_in_signed_byte(long num);
-static int fits_in_signed_word(long num);
-static int fits_in_unsigned_byte(long num);
-static int fits_in_unsigned_word(long num);
-static int i386_operand(char *operand_string);
-static int smallest_imm_type(long num);
-static reg_entry *parse_register(char *reg_string);
-static unsigned long mode_from_disp_size(unsigned long t);
-static unsigned long opcode_suffix_to_type(unsigned long s);
-static void s_bss(void);
-
-#else /* not __STDC__ */
-
-static char *output_invalid();
-static int fits_in_signed_byte();
-static int fits_in_signed_word();
-static int fits_in_unsigned_byte();
-static int fits_in_unsigned_word();
-static int i386_operand();
-static int smallest_imm_type();
-static reg_entry *parse_register();
-static unsigned long mode_from_disp_size();
-static unsigned long opcode_suffix_to_type();
-static void s_bss();
-
-#endif /* not __STDC__ */
-
-
-/* Ignore certain directives generated by gcc. This probably should
- not be here. */
-void dummy ()
-{
- while (*input_line_pointer && *input_line_pointer != '\n')
- input_line_pointer++;
-}
-
-const pseudo_typeS md_pseudo_table[] = {
- { "bss", s_bss, 0 },
-
-#ifndef OLD_GAS
- { "align", s_align_bytes, 0 },
-#else /* OLD_GAS */
- { "align", s_align_ptwo, 0 },
-#endif /* OLD_GAS */
-
- { "ffloat", float_cons, 'f' },
- { "dfloat", float_cons, 'd' },
- { "tfloat", float_cons, 'x' },
- { "value", cons, 2 },
- { 0, 0, 0 }
-};
-
-/* for interface with expression () */
-extern char * input_line_pointer;
-
-/* obstack for constructing various things in md_begin */
-struct obstack o;
-
-/* hash table for opcode lookup */
-static struct hash_control *op_hash = (struct hash_control *) 0;
-/* hash table for register lookup */
-static struct hash_control *reg_hash = (struct hash_control *) 0;
-/* hash table for prefix lookup */
-static struct hash_control *prefix_hash = (struct hash_control *) 0;
-
-
-void md_begin ()
-{
- char * hash_err;
-
- obstack_begin (&o,4096);
-
- /* initialize op_hash hash table */
- op_hash = hash_new(); /* xmalloc handles error */
-
- {
- register const template *optab;
- register templates *core_optab;
- char *prev_name;
-
- optab = i386_optab; /* setup for loop */
- prev_name = optab->name;
- obstack_grow (&o, optab, sizeof(template));
- core_optab = (templates *) xmalloc (sizeof (templates));
-
- for (optab++; optab < i386_optab_end; optab++) {
- if (! strcmp (optab->name, prev_name)) {
- /* same name as before --> append to current template list */
- obstack_grow (&o, optab, sizeof(template));
- } else {
- /* different name --> ship out current template list;
- add to hash table; & begin anew */
- /* Note: end must be set before start! since obstack_next_free changes
- upon opstack_finish */
- core_optab->end = (template *) obstack_next_free(&o);
- core_optab->start = (template *) obstack_finish(&o);
- hash_err = hash_insert (op_hash, prev_name, (char *) core_optab);
- if (hash_err && *hash_err) {
- hash_error:
- as_fatal("Internal Error: Can't hash %s: %s", prev_name, hash_err);
- }
- prev_name = optab->name;
- core_optab = (templates *) xmalloc (sizeof(templates));
- obstack_grow (&o, optab, sizeof(template));
- }
- }
- }
-
- /* initialize reg_hash hash table */
- reg_hash = hash_new();
- {
- register const reg_entry *regtab;
-
- for (regtab = i386_regtab; regtab < i386_regtab_end; regtab++) {
- hash_err = hash_insert (reg_hash, regtab->reg_name, regtab);
- if (hash_err && *hash_err) goto hash_error;
- }
- }
-
- esp = (reg_entry *) hash_find (reg_hash, "esp");
- ebp = (reg_entry *) hash_find (reg_hash, "ebp");
-
- /* initialize reg_hash hash table */
- prefix_hash = hash_new();
- {
- register const prefix_entry *prefixtab;
-
- for (prefixtab = i386_prefixtab;
- prefixtab < i386_prefixtab_end; prefixtab++) {
- hash_err = hash_insert (prefix_hash, prefixtab->prefix_name, prefixtab);
- if (hash_err && *hash_err) goto hash_error;
- }
- }
-
- /* fill in lexical tables: opcode_chars, operand_chars, space_chars */
- {
- register unsigned int c;
-
- memset(opcode_chars, '\0', sizeof(opcode_chars));
- memset(operand_chars, '\0', sizeof(operand_chars));
- memset(space_chars, '\0', sizeof(space_chars));
- memset(identifier_chars, '\0', sizeof(identifier_chars));
- memset(digit_chars, '\0', sizeof(digit_chars));
-
- for (c = 0; c < 256; c++) {
- if (islower(c) || isdigit(c)) {
- opcode_chars[c] = c;
- register_chars[c] = c;
- } else if (isupper(c)) {
- opcode_chars[c] = tolower(c);
- register_chars[c] = opcode_chars[c];
- } else if (c == PREFIX_SEPERATOR) {
- opcode_chars[c] = c;
- } else if (c == ')' || c == '(') {
- register_chars[c] = c;
- }
-
- if (isupper(c) || islower(c) || isdigit(c))
- operand_chars[c] = c;
- else if (c && strchr(operand_special_chars, c))
- operand_chars[c] = c;
-
- if (isdigit(c) || c == '-') digit_chars[c] = c;
-
- if (isalpha(c) || c == '_' || c == '.' || isdigit(c))
- identifier_chars[c] = c;
-
- if (c == ' ' || c == '\t') space_chars[c] = c;
- }
- }
-}
-
-void md_end() {} /* not much to do here. */
-
-
-#define DEBUG386
-#ifdef DEBUG386
-
-/* debugging routines for md_assemble */
-static void pi (), pte (), pt (), pe (), ps ();
-
-static void pi (line, x)
-char * line;
-i386_insn *x;
-{
- register template *p;
- int i;
-
- fprintf (stdout, "%s: template ", line);
- pte (&x->tm);
- fprintf (stdout, " modrm: mode %x reg %x reg/mem %x",
- x->rm.mode, x->rm.reg, x->rm.regmem);
- fprintf (stdout, " base %x index %x scale %x\n",
- x->bi.base, x->bi.index, x->bi.scale);
- for (i = 0; i < x->operands; i++) {
- fprintf (stdout, " #%d: ", i+1);
- pt (x->types[i]);
- fprintf (stdout, "\n");
- if (x->types[i] & Reg) fprintf (stdout, "%s\n", x->regs[i]->reg_name);
- if (x->types[i] & Imm) pe (x->imms[i]);
- if (x->types[i] & (Disp|Abs)) pe (x->disps[i]);
- }
-}
-
-static void pte (t)
-template *t;
-{
- int i;
- fprintf (stdout, " %d operands ", t->operands);
- fprintf (stdout, "opcode %x ",
- t->base_opcode);
- if (t->extension_opcode != None)
- fprintf (stdout, "ext %x ", t->extension_opcode);
- if (t->opcode_modifier&D)
- fprintf (stdout, "D");
- if (t->opcode_modifier&W)
- fprintf (stdout, "W");
- fprintf (stdout, "\n");
- for (i = 0; i < t->operands; i++) {
- fprintf (stdout, " #%d type ", i+1);
- pt (t->operand_types[i]);
- fprintf (stdout, "\n");
- }
-}
-
-static void pe (e)
-expressionS *e;
-{
- fprintf (stdout, " segment %s\n", segment_name (e->X_seg));
- fprintf (stdout, " add_number %d (%x)\n",
- e->X_add_number, e->X_add_number);
- if (e->X_add_symbol) {
- fprintf (stdout, " add_symbol ");
- ps (e->X_add_symbol);
- fprintf (stdout, "\n");
- }
- if (e->X_subtract_symbol) {
- fprintf (stdout, " sub_symbol ");
- ps (e->X_subtract_symbol);
- fprintf (stdout, "\n");
- }
-}
-
-static void ps (s)
-symbolS *s;
-{
- fprintf (stdout, "%s type %s%s",
- S_GET_NAME(s),
- S_IS_EXTERNAL(s) ? "EXTERNAL " : "",
- segment_name(S_GET_SEGMENT(s)));
-}
-
-struct type_name {
- unsigned int mask;
- char *tname;
-} type_names[] = {
- { Reg8, "r8" }, { Reg16, "r16" }, { Reg32, "r32" }, { Imm8, "i8" },
- { Imm8S, "i8s" },
- { Imm16, "i16" }, { Imm32, "i32" }, { Mem8, "Mem8"}, { Mem16, "Mem16"},
- { Mem32, "Mem32"}, { BaseIndex, "BaseIndex" },
- { Abs8, "Abs8" }, { Abs16, "Abs16" }, { Abs32, "Abs32" },
- { Disp8, "d8" }, { Disp16, "d16" },
- { Disp32, "d32" }, { SReg2, "SReg2" }, { SReg3, "SReg3" }, { Acc, "Acc" },
- { InOutPortReg, "InOutPortReg" }, { ShiftCount, "ShiftCount" },
- { Imm1, "i1" }, { Control, "control reg" }, {Test, "test reg"},
- { FloatReg, "FReg"}, {FloatAcc, "FAcc"},
- { JumpAbsolute, "Jump Absolute"},
- { 0, "" }
-};
-
-static void pt (t)
-unsigned int t;
-{
- register struct type_name *ty;
-
- if (t == Unknown) {
- fprintf (stdout, "Unknown");
- } else {
- for (ty = type_names; ty->mask; ty++)
- if (t & ty->mask) fprintf (stdout, "%s, ", ty->tname);
- }
- fflush (stdout);
-}
-
-#endif /* DEBUG386 */
-
-/*
- This is the guts of the machine-dependent assembler. LINE points to a
- machine dependent instruction. This funciton is supposed to emit
- the frags/bytes it assembles to.
- */
-void md_assemble (line)
-char *line;
-{
- /* Holds temlate once we've found it. */
- register template *t;
-
- /* Possible templates for current insn */
- templates *current_templates = (templates *) 0;
-
- /* Initialize globals. */
- memset(&i, '\0', sizeof(i));
- memset(disp_expressions, '\0', sizeof(disp_expressions));
- memset(im_expressions, '\0', sizeof(im_expressions));
- save_stack_p = save_stack; /* reset stack pointer */
-
- /* Fist parse an opcode & call i386_operand for the operands.
- We assume that the scrubber has arranged it so that line[0] is the valid
- start of a (possibly prefixed) opcode. */
- {
- register char *l = line; /* Fast place to put LINE. */
-
- /* 1 if operand is pending after ','. */
- unsigned int expecting_operand = 0;
- /* 1 if we found a prefix only acceptable with string insns. */
- unsigned int expecting_string_instruction = 0;
- /* Non-zero if operand parens not balenced. */
- unsigned int paren_not_balenced;
- char * token_start = l;
-
- while (! is_space_char(*l) && *l != END_OF_INSN) {
- if (! is_opcode_char(*l)) {
- as_bad("invalid character %s in opcode", output_invalid(*l));
- return;
- } else if (*l != PREFIX_SEPERATOR) {
- *l = opcode_chars[(unsigned char) *l]; /* fold case of opcodes */
- l++;
- } else { /* this opcode's got a prefix */
- register unsigned int q;
- register prefix_entry * prefix;
-
- if (l == token_start) {
- as_bad("expecting prefix; got nothing");
- return;
- }
- END_STRING_AND_SAVE (l);
- prefix = (prefix_entry *) hash_find (prefix_hash, token_start);
- if (! prefix) {
- as_bad("no such opcode prefix ('%s')", token_start);
- return;
- }
- RESTORE_END_STRING (l);
- /* check for repeated prefix */
- for (q = 0; q < i.prefixes; q++)
- if (i.prefix[q] == prefix->prefix_code) {
- as_bad("same prefix used twice; you don't really want this!");
- return;
- }
- if (i.prefixes == MAX_PREFIXES) {
- as_bad("too many opcode prefixes");
- return;
- }
- i.prefix[i.prefixes++] = prefix->prefix_code;
- if (prefix->prefix_code == REPE || prefix->prefix_code == REPNE)
- expecting_string_instruction = 1;
- /* skip past PREFIX_SEPERATOR and reset token_start */
- token_start = ++l;
- }
- }
- END_STRING_AND_SAVE (l);
- if (token_start == l) {
- as_bad("expecting opcode; got nothing");
- return;
- }
-
- /* Lookup insn in hash; try intel & att naming conventions if appropriate;
- that is: we only use the opcode suffix 'b' 'w' or 'l' if we need to. */
- current_templates = (templates *) hash_find (op_hash, token_start);
- if (! current_templates) {
- int last_index = strlen(token_start) - 1;
- char last_char = token_start[last_index];
- switch (last_char) {
- case DWORD_OPCODE_SUFFIX:
- case WORD_OPCODE_SUFFIX:
- case BYTE_OPCODE_SUFFIX:
- token_start[last_index] = '\0';
- current_templates = (templates *) hash_find (op_hash, token_start);
- token_start[last_index] = last_char;
- i.suffix = last_char;
- }
- if (!current_templates) {
- as_bad("no such 386 instruction: `%s'", token_start); return;
- }
- }
- RESTORE_END_STRING (l);
-
- /* check for rep/repne without a string instruction */
- if (expecting_string_instruction &&
- ! IS_STRING_INSTRUCTION (current_templates->
- start->base_opcode)) {
- as_bad("expecting string instruction after rep/repne");
- return;
- }
-
- /* There may be operands to parse. */
- if (*l != END_OF_INSN &&
- /* For string instructions, we ignore any operands if given. This
- kludges, for example, 'rep/movsb %ds:(%esi), %es:(%edi)' where
- the operands are always going to be the same, and are not really
- encoded in machine code. */
- ! IS_STRING_INSTRUCTION (current_templates->
- start->base_opcode)) {
- /* parse operands */
- do {
- /* skip optional white space before operand */
- while (! is_operand_char(*l) && *l != END_OF_INSN) {
- if (! is_space_char(*l)) {
- as_bad("invalid character %s before %s operand",
- output_invalid(*l),
- ordinal_names[i.operands]);
- return;
- }
- l++;
- }
- token_start = l; /* after white space */
- paren_not_balenced = 0;
- while (paren_not_balenced || *l != ',') {
- if (*l == END_OF_INSN) {
- if (paren_not_balenced) {
- as_bad("unbalenced parenthesis in %s operand.",
- ordinal_names[i.operands]);
- return;
- } else break; /* we are done */
- } else if (! is_operand_char(*l) && ! is_space_char(*l)) {
- as_bad("invalid character %s in %s operand",
- output_invalid(*l),
- ordinal_names[i.operands]);
- return;
- }
- if (*l == '(') ++paren_not_balenced;
- if (*l == ')') --paren_not_balenced;
- l++;
- }
- if (l != token_start) { /* yes, we've read in another operand */
- unsigned int operand_ok;
- this_operand = i.operands++;
- if (i.operands > MAX_OPERANDS) {
- as_bad("spurious operands; (%d operands/instruction max)",
- MAX_OPERANDS);
- return;
- }
- /* now parse operand adding info to 'i' as we go along */
- END_STRING_AND_SAVE (l);
- operand_ok = i386_operand (token_start);
- RESTORE_END_STRING (l); /* restore old contents */
- if (!operand_ok) return;
- } else {
- if (expecting_operand) {
- expecting_operand_after_comma:
- as_bad("expecting operand after ','; got nothing");
- return;
- }
- if (*l == ',') {
- as_bad("expecting operand before ','; got nothing");
- return;
- }
- }
-
- /* now *l must be either ',' or END_OF_INSN */
- if (*l == ',') {
- if (*++l == END_OF_INSN) { /* just skip it, if it's \n complain */
- goto expecting_operand_after_comma;
- }
- expecting_operand = 1;
- }
- } while (*l != END_OF_INSN); /* until we get end of insn */
- }
- }
-
- /* Now we've parsed the opcode into a set of templates, and have the
- operands at hand.
- Next, we find a template that matches the given insn,
- making sure the overlap of the given operands types is consistent
- with the template operand types. */
-
-#define MATCH(overlap,given_type) \
- (overlap && \
- (overlap & (JumpAbsolute|BaseIndex|Mem8)) \
- == (given_type & (JumpAbsolute|BaseIndex|Mem8)))
-
- /* If m0 and m1 are register matches they must be consistent
- with the expected operand types t0 and t1.
- That is, if both m0 & m1 are register matches
- i.e. ( ((m0 & (Reg)) && (m1 & (Reg)) ) ?
- then, either 1. or 2. must be true:
- 1. the expected operand type register overlap is null:
- (t0 & t1 & Reg) == 0
- AND
- the given register overlap is null:
- (m0 & m1 & Reg) == 0
- 2. the expected operand type register overlap == the given
- operand type overlap: (t0 & t1 & m0 & m1 & Reg).
- */
-#define CONSISTENT_REGISTER_MATCH(m0, m1, t0, t1) \
- ( ((m0 & (Reg)) && (m1 & (Reg))) ? \
- ( ((t0 & t1 & (Reg)) == 0 && (m0 & m1 & (Reg)) == 0) || \
- ((t0 & t1) & (m0 & m1) & (Reg)) \
- ) : 1)
- {
- register unsigned int overlap0, overlap1;
- expressionS * exp;
- unsigned int overlap2;
- unsigned int found_reverse_match;
-
- overlap0 = overlap1 = overlap2 = found_reverse_match = 0;
- for (t = current_templates->start;
- t < current_templates->end;
- t++) {
-
- /* must have right number of operands */
- if (i.operands != t->operands) continue;
- else if (!t->operands) break; /* 0 operands always matches */
-
- overlap0 = i.types[0] & t->operand_types[0];
- switch (t->operands) {
- case 1:
- if (! MATCH (overlap0,i.types[0])) continue;
- break;
- case 2: case 3:
- overlap1 = i.types[1] & t->operand_types[1];
- if (! MATCH (overlap0,i.types[0]) ||
- ! MATCH (overlap1,i.types[1]) ||
- ! CONSISTENT_REGISTER_MATCH(overlap0, overlap1,
- t->operand_types[0],
- t->operand_types[1])) {
-
- /* check if other direction is valid ... */
- if (! (t->opcode_modifier & COMES_IN_BOTH_DIRECTIONS))
- continue;
-
- /* try reversing direction of operands */
- overlap0 = i.types[0] & t->operand_types[1];
- overlap1 = i.types[1] & t->operand_types[0];
- if (! MATCH (overlap0,i.types[0]) ||
- ! MATCH (overlap1,i.types[1]) ||
- ! CONSISTENT_REGISTER_MATCH (overlap0, overlap1,
- t->operand_types[0],
- t->operand_types[1])) {
- /* does not match either direction */
- continue;
- }
- /* found a reverse match here -- slip through */
- /* found_reverse_match holds which of D or FloatD we've found */
- found_reverse_match = t->opcode_modifier & COMES_IN_BOTH_DIRECTIONS;
- } /* endif: not forward match */
- /* found either forward/reverse 2 operand match here */
- if (t->operands == 3) {
- overlap2 = i.types[2] & t->operand_types[2];
- if (! MATCH (overlap2,i.types[2]) ||
- ! CONSISTENT_REGISTER_MATCH (overlap0, overlap2,
- t->operand_types[0],
- t->operand_types[2]) ||
- ! CONSISTENT_REGISTER_MATCH (overlap1, overlap2,
- t->operand_types[1],
- t->operand_types[2]))
- continue;
- }
- /* found either forward/reverse 2 or 3 operand match here:
- slip through to break */
- }
- break; /* we've found a match; break out of loop */
- } /* for (t = ... */
- if (t == current_templates->end) { /* we found no match */
- as_bad("operands given don't match any known 386 instruction");
- return;
- }
-
- /* Copy the template we found (we may change it!). */
- memcpy(&i.tm, t, sizeof(template));
- t = &i.tm; /* alter new copy of template */
-
- /* If there's no opcode suffix we try to invent one based on register
- operands. */
- if (! i.suffix && i.reg_operands) {
- /* We take i.suffix from the LAST register operand specified. This
- assumes that the last register operands is the destination register
- operand. */
- int o;
- for (o = 0; o < MAX_OPERANDS; o++)
- if (i.types[o] & Reg) {
- i.suffix = (i.types[o] == Reg8) ? BYTE_OPCODE_SUFFIX :
- (i.types[o] == Reg16) ? WORD_OPCODE_SUFFIX :
- DWORD_OPCODE_SUFFIX;
- }
- }
-
- /* Make still unresolved immediate matches conform to size of immediate
- given in i.suffix. Note: overlap2 cannot be an immediate!
- We assume this. */
- if ((overlap0 & (Imm8|Imm8S|Imm16|Imm32))
- && overlap0 != Imm8 && overlap0 != Imm8S
- && overlap0 != Imm16 && overlap0 != Imm32) {
- if (! i.suffix) {
- as_bad("no opcode suffix given; can't determine immediate size");
- return;
- }
- overlap0 &= (i.suffix == BYTE_OPCODE_SUFFIX ? (Imm8|Imm8S) :
- (i.suffix == WORD_OPCODE_SUFFIX ? Imm16 : Imm32));
- }
- if ((overlap1 & (Imm8|Imm8S|Imm16|Imm32))
- && overlap1 != Imm8 && overlap1 != Imm8S
- && overlap1 != Imm16 && overlap1 != Imm32) {
- if (! i.suffix) {
- as_bad("no opcode suffix given; can't determine immediate size");
- return;
- }
- overlap1 &= (i.suffix == BYTE_OPCODE_SUFFIX ? (Imm8|Imm8S) :
- (i.suffix == WORD_OPCODE_SUFFIX ? Imm16 : Imm32));
- }
-
- i.types[0] = overlap0;
- i.types[1] = overlap1;
- i.types[2] = overlap2;
-
- if (overlap0 & ImplicitRegister) i.reg_operands--;
- if (overlap1 & ImplicitRegister) i.reg_operands--;
- if (overlap2 & ImplicitRegister) i.reg_operands--;
- if (overlap0 & Imm1) i.imm_operands = 0; /* kludge for shift insns */
-
- if (found_reverse_match) {
- unsigned int save;
- save = t->operand_types[0];
- t->operand_types[0] = t->operand_types[1];
- t->operand_types[1] = save;
- }
-
- /* Finalize opcode. First, we change the opcode based on the operand
- size given by i.suffix: we never have to change things for byte insns,
- or when no opcode suffix is need to size the operands. */
-
- if (! i.suffix && (t->opcode_modifier & W)) {
- as_bad("no opcode suffix given and no register operands; can't size instruction");
- return;
- }
-
- if (i.suffix && i.suffix != BYTE_OPCODE_SUFFIX) {
- /* Select between byte and word/dword operations. */
- if (t->opcode_modifier & W)
- t->base_opcode |= W;
- /* Now select between word & dword operations via the
- operand size prefix. */
- if (i.suffix == WORD_OPCODE_SUFFIX) {
- if (i.prefixes == MAX_PREFIXES) {
- as_bad("%d prefixes given and 'w' opcode suffix gives too many prefixes",
- MAX_PREFIXES);
- return;
- }
- i.prefix[i.prefixes++] = WORD_PREFIX_OPCODE;
- }
- }
-
- /* For insns with operands there are more diddles to do to the opcode. */
- if (i.operands) {
- /* If we found a reverse match we must alter the opcode direction bit
- found_reverse_match holds bit to set (different for int &
- float insns). */
-
- if (found_reverse_match) {
- t->base_opcode |= found_reverse_match;
- }
-
- /*
- The imul $imm, %reg instruction is converted into
- imul $imm, %reg, %reg. */
- if (t->opcode_modifier & imulKludge) {
- i.regs[2] = i.regs[1]; /* Pretend we saw the 3 operand case. */
- i.reg_operands = 2;
- }
-
- /* Certain instructions expect the destination to be in the i.rm.reg
- field. This is by far the exceptional case. For these instructions,
- if the source operand is a register, we must reverse the i.rm.reg
- and i.rm.regmem fields. We accomplish this by faking that the
- two register operands were given in the reverse order. */
- if ((t->opcode_modifier & ReverseRegRegmem) && i.reg_operands == 2) {
- unsigned int first_reg_operand = (i.types[0] & Reg) ? 0 : 1;
- unsigned int second_reg_operand = first_reg_operand + 1;
- reg_entry *tmp = i.regs[first_reg_operand];
- i.regs[first_reg_operand] = i.regs[second_reg_operand];
- i.regs[second_reg_operand] = tmp;
- }
-
- if (t->opcode_modifier & ShortForm) {
- /* The register or float register operand is in operand 0 or 1. */
- unsigned int o = (i.types[0] & (Reg|FloatReg)) ? 0 : 1;
- /* Register goes in low 3 bits of opcode. */
- t->base_opcode |= i.regs[o]->reg_num;
- } else if (t->opcode_modifier & ShortFormW) {
- /* Short form with 0x8 width bit. Register is always dest. operand */
- t->base_opcode |= i.regs[1]->reg_num;
- if (i.suffix == WORD_OPCODE_SUFFIX ||
- i.suffix == DWORD_OPCODE_SUFFIX)
- t->base_opcode |= 0x8;
- } else if (t->opcode_modifier & Seg2ShortForm) {
- if (t->base_opcode == POP_SEG_SHORT && i.regs[0]->reg_num == 1) {
- as_bad("you can't 'pop cs' on the 386.");
- return;
- }
- t->base_opcode |= (i.regs[0]->reg_num << 3);
- } else if (t->opcode_modifier & Seg3ShortForm) {
- /* 'push %fs' is 0x0fa0; 'pop %fs' is 0x0fa1.
- 'push %gs' is 0x0fa8; 'pop %fs' is 0x0fa9.
- So, only if i.regs[0]->reg_num == 5 (%gs) do we need
- to change the opcode. */
- if (i.regs[0]->reg_num == 5)
- t->base_opcode |= 0x08;
- } else if (t->opcode_modifier & Modrm) {
- /* The opcode is completed (modulo t->extension_opcode which must
- be put into the modrm byte.
- Now, we make the modrm & index base bytes based on all the info
- we've collected. */
-
- /* i.reg_operands MUST be the number of real register operands;
- implicit registers do not count. */
- if (i.reg_operands == 2) {
- unsigned int source, dest;
- source = (i.types[0] & (Reg|SReg2|SReg3|Control|Debug|Test)) ? 0 : 1;
- dest = source + 1;
- i.rm.mode = 3;
- /* We must be careful to make sure that all segment/control/test/
- debug registers go into the i.rm.reg field (despite the whether
- they are source or destination operands). */
- if (i.regs[dest]->reg_type & (SReg2|SReg3|Control|Debug|Test)) {
- i.rm.reg = i.regs[dest]->reg_num;
- i.rm.regmem = i.regs[source]->reg_num;
- } else {
- i.rm.reg = i.regs[source]->reg_num;
- i.rm.regmem = i.regs[dest]->reg_num;
- }
- } else { /* if it's not 2 reg operands... */
- if (i.mem_operands) {
- unsigned int fake_zero_displacement = 0;
- unsigned int o = (i.types[0] & Mem) ? 0 : ((i.types[1] & Mem) ? 1 : 2);
-
- /* Encode memory operand into modrm byte and base index byte. */
-
- if (i.base_reg == esp && ! i.index_reg) {
- /* <disp>(%esp) becomes two byte modrm with no index register. */
- i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING;
- i.rm.mode = mode_from_disp_size(i.types[o]);
- i.bi.base = ESP_REG_NUM;
- i.bi.index = NO_INDEX_REGISTER;
- i.bi.scale = 0; /* Must be zero! */
- } else if (i.base_reg == ebp && !i.index_reg) {
- if (! (i.types[o] & Disp)) {
- /* Must fake a zero byte displacement.
- There is no direct way to code '(%ebp)' directly. */
- fake_zero_displacement = 1;
- /* fake_zero_displacement code does not set this. */
- i.types[o] |= Disp8;
- }
- i.rm.mode = mode_from_disp_size(i.types[o]);
- i.rm.regmem = EBP_REG_NUM;
- } else if (! i.base_reg && (i.types[o] & BaseIndex)) {
- /* There are three cases here.
- Case 1: '<32bit disp>(,1)' -- indirect absolute.
- (Same as cases 2 & 3 with NO index register)
- Case 2: <32bit disp> (,<index>) -- no base register with disp
- Case 3: (, <index>) --- no base register;
- no disp (must add 32bit 0 disp). */
- i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING;
- i.rm.mode = 0; /* 32bit mode */
- i.bi.base = NO_BASE_REGISTER;
- i.types[o] &= ~Disp;
- i.types[o] |= Disp32; /* Must be 32bit! */
- if (i.index_reg) { /* case 2 or case 3 */
- i.bi.index = i.index_reg->reg_num;
- i.bi.scale = i.log2_scale_factor;
- if (i.disp_operands == 0)
- fake_zero_displacement = 1; /* case 3 */
- } else {
- i.bi.index = NO_INDEX_REGISTER;
- i.bi.scale = 0;
- }
- } else if (i.disp_operands && !i.base_reg && !i.index_reg) {
- /* Operand is just <32bit disp> */
- i.rm.regmem = EBP_REG_NUM;
- i.rm.mode = 0;
- i.types[o] &= ~Disp;
- i.types[o] |= Disp32;
- } else {
- /* It's not a special case; rev'em up. */
- i.rm.regmem = i.base_reg->reg_num;
- i.rm.mode = mode_from_disp_size(i.types[o]);
- if (i.index_reg) {
- i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING;
- i.bi.base = i.base_reg->reg_num;
- i.bi.index = i.index_reg->reg_num;
- i.bi.scale = i.log2_scale_factor;
- if (i.base_reg == ebp && i.disp_operands == 0) { /* pace */
- fake_zero_displacement = 1;
- i.types[o] |= Disp8;
- i.rm.mode = mode_from_disp_size(i.types[o]);
- }
- }
- }
- if (fake_zero_displacement) {
- /* Fakes a zero displacement assuming that i.types[o] holds
- the correct displacement size. */
- exp = &disp_expressions[i.disp_operands++];
- i.disps[o] = exp;
- exp->X_seg = SEG_ABSOLUTE;
- exp->X_add_number = 0;
- exp->X_add_symbol = (symbolS *) 0;
- exp->X_subtract_symbol = (symbolS *) 0;
- }
-
- /* Select the correct segment for the memory operand. */
- if (i.seg) {
- unsigned int seg_index;
- const seg_entry *default_seg;
-
- if (i.rm.regmem == ESCAPE_TO_TWO_BYTE_ADDRESSING) {
- seg_index = (i.rm.mode<<3) | i.bi.base;
- default_seg = two_byte_segment_defaults[seg_index];
- } else {
- seg_index = (i.rm.mode<<3) | i.rm.regmem;
- default_seg = one_byte_segment_defaults[seg_index];
- }
- /* If the specified segment is not the default, use an
- opcode prefix to select it */
- if (i.seg != default_seg) {
- if (i.prefixes == MAX_PREFIXES) {
- as_bad("%d prefixes given and %s segment override gives too many prefixes",
- MAX_PREFIXES, i.seg->seg_name);
- return;
- }
- i.prefix[i.prefixes++] = i.seg->seg_prefix;
- }
- }
- }
-
- /* Fill in i.rm.reg or i.rm.regmem field with register operand
- (if any) based on t->extension_opcode. Again, we must be careful
- to make sure that segment/control/debug/test registers are coded
- into the i.rm.reg field. */
- if (i.reg_operands) {
- unsigned int o =
- (i.types[0] & (Reg|SReg2|SReg3|Control|Debug|Test)) ? 0 :
- (i.types[1] & (Reg|SReg2|SReg3|Control|Debug|Test)) ? 1 : 2;
- /* If there is an extension opcode to put here, the register number
- must be put into the regmem field. */
- if (t->extension_opcode != None)
- i.rm.regmem = i.regs[o]->reg_num;
- else i.rm.reg = i.regs[o]->reg_num;
-
- /* Now, if no memory operand has set i.rm.mode = 0, 1, 2
- we must set it to 3 to indicate this is a register operand
- int the regmem field */
- if (! i.mem_operands) i.rm.mode = 3;
- }
-
- /* Fill in i.rm.reg field with extension opcode (if any). */
- if (t->extension_opcode != None)
- i.rm.reg = t->extension_opcode;
- }
- }
- }
- }
-
- /* Handle conversion of 'int $3' --> special int3 insn. */
- if (t->base_opcode == INT_OPCODE && i.imms[0]->X_add_number == 3) {
- t->base_opcode = INT3_OPCODE;
- i.imm_operands = 0;
- }
-
- /* We are ready to output the insn. */
- {
- register char * p;
-
- /* Output jumps. */
- if (t->opcode_modifier & Jump) {
- int n = i.disps[0]->X_add_number;
-
- switch (i.disps[0]->X_seg) {
- case SEG_ABSOLUTE:
- if (fits_in_signed_byte(n)) {
- p = frag_more (2);
- p[0] = t->base_opcode;
- p[1] = n;
-#if 0 /* leave out 16 bit jumps - pace */
- } else if (fits_in_signed_word(n)) {
- p = frag_more (4);
- p[0] = WORD_PREFIX_OPCODE;
- p[1] = t->base_opcode;
- md_number_to_chars (&p[2], n, 2);
-#endif
- } else { /* It's an absolute dword displacement. */
- if (t->base_opcode == JUMP_PC_RELATIVE) { /* pace */
- /* unconditional jump */
- p = frag_more (5);
- p[0] = 0xe9;
- md_number_to_chars (&p[1], n, 4);
- } else {
- /* conditional jump */
- p = frag_more (6);
- p[0] = TWO_BYTE_OPCODE_ESCAPE;
- p[1] = t->base_opcode + 0x10;
- md_number_to_chars (&p[2], n, 4);
- }
- }
- break;
- default:
- /* It's a symbol; end frag & setup for relax.
- Make sure there are 6 chars left in the current frag; if not
- we'll have to start a new one. */
- /* I caught it failing with obstack_room == 6,
- so I changed to <= pace */
- if (obstack_room (&frags) <= 6) {
- frag_wane(frag_now);
- frag_new (0);
- }
- p = frag_more (1);
- p[0] = t->base_opcode;
- frag_var (rs_machine_dependent,
- 6, /* 2 opcode/prefix + 4 displacement */
- 1,
- ((unsigned char) *p == JUMP_PC_RELATIVE
- ? ENCODE_RELAX_STATE (UNCOND_JUMP, BYTE)
- : ENCODE_RELAX_STATE (COND_JUMP, BYTE)),
- i.disps[0]->X_add_symbol,
- n, p);
-/*
- * XXX - what do we do about jmp x@PLT ??
- * kludged in md_estimate_size_before_relax() below
- */
- break;
- }
- } else if (t->opcode_modifier & (JumpByte|JumpDword)) {
- int size = (t->opcode_modifier & JumpByte) ? 1 : 4;
- int n = i.disps[0]->X_add_number;
-
- if (fits_in_unsigned_byte(t->base_opcode)) {
- FRAG_APPEND_1_CHAR (t->base_opcode);
- } else {
- p = frag_more (2); /* opcode can be at most two bytes */
- /* put out high byte first: can't use md_number_to_chars! */
- *p++ = (t->base_opcode >> 8) & 0xff;
- *p = t->base_opcode & 0xff;
- }
-
- p = frag_more (size);
- switch (i.disps[0]->X_seg) {
- case SEG_ABSOLUTE:
- md_number_to_chars (p, n, size);
- if (size == 1 && ! fits_in_signed_byte(n)) {
- as_bad("loop/jecx only takes byte displacement; %d shortened to %d",
- n, *p);
- }
- break;
- default:
- fix_new (frag_now, p - frag_now->fr_literal, size,
- i.disps[0]->X_add_symbol, i.disps[0]->X_subtract_symbol,
- i.disps[0]->X_add_number, 1, i.disp_reloc[0], i.disps[0]->X_got_symbol);
- break;
- }
- } else if (t->opcode_modifier & JumpInterSegment) {
- p = frag_more (1 + 2 + 4); /* 1 opcode; 2 segment; 4 offset */
- p[0] = t->base_opcode;
- if (i.imms[1]->X_seg == SEG_ABSOLUTE)
- md_number_to_chars (p + 1, i.imms[1]->X_add_number, 4);
- else
- fix_new (frag_now, p + 1 - frag_now->fr_literal, 4,
- i.imms[1]->X_add_symbol,
- i.imms[1]->X_subtract_symbol,
- i.imms[1]->X_add_number, 0, NO_RELOC, i.imms[1]->X_got_symbol);
- if (i.imms[0]->X_seg != SEG_ABSOLUTE)
- as_bad("can't handle non absolute segment in long call/jmp");
- md_number_to_chars (p + 5, i.imms[0]->X_add_number, 2);
- } else {
- /* Output normal instructions here. */
- unsigned char *q;
-#ifdef PIC
- /*
- * Remember # of opcode bytes to put in pcrel_adjust
- * for use in _GLOBAL_OFFSET_TABLE_ expressions.
- */
- int nopbytes = 0;
-#endif
-
- /* First the prefix bytes. */
- for (q = i.prefix; q < i.prefix + i.prefixes; q++) {
- p = frag_more (1);
- nopbytes += 1;
- md_number_to_chars (p, (unsigned int) *q, 1);
- }
-
- /* Now the opcode; be careful about word order here! */
- if (fits_in_unsigned_byte(t->base_opcode)) {
- nopbytes += 1;
- FRAG_APPEND_1_CHAR (t->base_opcode);
- } else if (fits_in_unsigned_word(t->base_opcode)) {
- p = frag_more (2);
- nopbytes += 2;
- /* put out high byte first: can't use md_number_to_chars! */
- *p++ = (t->base_opcode >> 8) & 0xff;
- *p = t->base_opcode & 0xff;
- } else { /* opcode is either 3 or 4 bytes */
- if (t->base_opcode & 0xff000000) {
- p = frag_more (4);
- nopbytes += 4;
- *p++ = (t->base_opcode >> 24) & 0xff;
- } else {
- p = frag_more (3);
- nopbytes += 3;
- }
- *p++ = (t->base_opcode >> 16) & 0xff;
- *p++ = (t->base_opcode >> 8) & 0xff;
- *p = (t->base_opcode ) & 0xff;
- }
-
- /* Now the modrm byte and base index byte (if present). */
- if (t->opcode_modifier & Modrm) {
- p = frag_more (1);
- nopbytes += 1;
- /* md_number_to_chars (p, i.rm, 1); */
- md_number_to_chars (p, (i.rm.regmem<<0 | i.rm.reg<<3 | i.rm.mode<<6), 1);
- /* If i.rm.regmem == ESP (4) && i.rm.mode != Mode 3 (Register mode)
- ==> need second modrm byte. */
- if (i.rm.regmem == ESCAPE_TO_TWO_BYTE_ADDRESSING && i.rm.mode != 3) {
- p = frag_more (1);
- nopbytes += 1;
- /* md_number_to_chars (p, i.bi, 1); */
- md_number_to_chars (p,(i.bi.base<<0 | i.bi.index<<3 | i.bi.scale<<6), 1);
- }
- }
-
- if (i.disp_operands) {
- register unsigned int n;
-
- for (n = 0; n < i.operands; n++) {
- if (i.disps[n]) {
- if (i.disps[n]->X_seg == SEG_ABSOLUTE) {
- if (i.types[n] & (Disp8|Abs8)) {
- p = frag_more (1);
- md_number_to_chars (p, i.disps[n]->X_add_number, 1);
- } else if (i.types[n] & (Disp16|Abs16)) {
- p = frag_more (2);
- md_number_to_chars (p, i.disps[n]->X_add_number, 2);
- } else { /* Disp32|Abs32 */
- p = frag_more (4);
- md_number_to_chars (p, i.disps[n]->X_add_number, 4);
- }
- } else { /* not SEG_ABSOLUTE */
- /* need a 32-bit fixup (don't support 8bit non-absolute disps) */
-
- fixS *fixP;
- p = frag_more (4);
- fixP = fix_new (frag_now, p - frag_now->fr_literal, 4,
- i.disps[n]->X_add_symbol, i.disps[n]->X_subtract_symbol,
- i.disps[n]->X_add_number, 0, i.disp_reloc[n], i.disps[n]->X_got_symbol);
-#ifdef PIC
- if (i.disps[n]->X_got_symbol) {
- fixP->fx_pcrel_adjust = nopbytes;
- }
-#endif
- }
- }
- }
- } /* end displacement output */
-
- /* output immediate */
- if (i.imm_operands) {
- register unsigned int n;
-
- for (n = 0; n < i.operands; n++) {
- if (i.imms[n]) {
- if (i.imms[n]->X_seg == SEG_ABSOLUTE) {
- if (i.types[n] & (Imm8|Imm8S)) {
- p = frag_more (1);
- md_number_to_chars (p, i.imms[n]->X_add_number, 1);
- } else if (i.types[n] & Imm16) {
- p = frag_more (2);
- md_number_to_chars (p, i.imms[n]->X_add_number, 2);
- } else {
- p = frag_more (4);
- md_number_to_chars (p, i.imms[n]->X_add_number, 4);
- }
- } else { /* not SEG_ABSOLUTE */
- /* need a 32-bit fixup (don't support 8bit non-absolute ims) */
- /* try to support other sizes ... */
- fixS *fixP;
- int size;
- if (i.types[n] & (Imm8|Imm8S))
- size = 1;
- else if (i.types[n] & Imm16)
- size = 2;
- else
- size = 4;
- p = frag_more (size);
- fixP = fix_new (frag_now, p - frag_now->fr_literal, size,
- i.imms[n]->X_add_symbol, i.imms[n]->X_subtract_symbol,
- i.imms[n]->X_add_number, 0, NO_RELOC, i.imms[n]->X_got_symbol);
-#ifdef PIC
- if (i.imms[n]->X_got_symbol) {
- fixP->fx_pcrel_adjust = nopbytes;
- }
-#endif
- }
- }
- }
- } /* end immediate output */
- }
-
-#ifdef DEBUG386
- if (flagseen['D']) {
- pi (line, &i);
- }
-#endif /* DEBUG386 */
-
- }
- return;
-}
-
-/* Parse OPERAND_STRING into the i386_insn structure I. Returns non-zero
- on error. */
-
-static int i386_operand (operand_string)
-char *operand_string;
-{
- register char *op_string = operand_string;
-
- /* Address of '\0' at end of operand_string. */
- char * end_of_operand_string = operand_string + strlen(operand_string);
-
- /* Start and end of displacement string expression (if found). */
- char *displacement_string_start = NULL;
- char *displacement_string_end = NULL;
-
- /* We check for an absolute prefix (differentiating,
- for example, 'jmp pc_relative_label' from 'jmp *absolute_label'. */
- if (*op_string == ABSOLUTE_PREFIX) {
- op_string++;
- i.types[this_operand] |= JumpAbsolute;
- }
-
- /* Check if operand is a register. */
- if (*op_string == REGISTER_PREFIX) {
- register reg_entry *r;
- if (!(r = parse_register (op_string))) {
- as_bad("bad register name ('%s')", op_string);
- return 0;
- }
- /* Check for segment override, rather than segment register by
- searching for ':' after %<x>s where <x> = s, c, d, e, f, g. */
- if ((r->reg_type & (SReg2|SReg3)) && op_string[3] == ':') {
- switch (r->reg_num) {
- case 0:
- i.seg = (seg_entry *) &es; break;
- case 1:
- i.seg = (seg_entry *) &cs; break;
- case 2:
- i.seg = (seg_entry *) &ss; break;
- case 3:
- i.seg = (seg_entry *) &ds; break;
- case 4:
- i.seg = (seg_entry *) &fs; break;
- case 5:
- i.seg = (seg_entry *) &gs; break;
- }
- op_string += 4; /* skip % <x> s : */
- operand_string = op_string; /* Pretend given string starts here. */
- if (!is_digit_char(*op_string) && !is_identifier_char(*op_string)
- && *op_string != '(' && *op_string != ABSOLUTE_PREFIX) {
- as_bad("bad memory operand after segment override");
- return 0;
- }
- /* Handle case of %es:*foo. */
- if (*op_string == ABSOLUTE_PREFIX) {
- op_string++;
- i.types[this_operand] |= JumpAbsolute;
- }
- goto do_memory_reference;
- }
- i.types[this_operand] |= r->reg_type;
- i.regs[this_operand] = r;
- i.reg_operands++;
- } else if (*op_string == IMMEDIATE_PREFIX) { /* ... or an immediate */
- char *save_input_line_pointer;
- segT exp_seg = SEG_GOOF;
- expressionS *exp;
-
- if (i.imm_operands == MAX_IMMEDIATE_OPERANDS) {
- as_bad("only 1 or 2 immediate operands are allowed");
- return 0;
- }
-
- exp = &im_expressions[i.imm_operands++];
- i.imms[this_operand] = exp;
- save_input_line_pointer = input_line_pointer;
- /* must advance op_string! */
- input_line_pointer = ++op_string;
- SKIP_WHITESPACE ();
-
- exp_seg = expression(exp);
- input_line_pointer = save_input_line_pointer;
-
- switch (exp_seg) {
- case SEG_ABSENT: /* missing or bad expr becomes absolute 0 */
- as_bad("missing or invalid immediate expression '%s' taken as 0",
- operand_string);
- exp->X_seg = SEG_ABSOLUTE;
- exp->X_add_number = 0;
- exp->X_add_symbol = (symbolS *) 0;
- exp->X_subtract_symbol = (symbolS *) 0;
- i.types[this_operand] |= Imm;
- break;
- case SEG_ABSOLUTE:
- i.types[this_operand] |= smallest_imm_type(exp->X_add_number);
- break;
- case SEG_TEXT: case SEG_DATA: case SEG_BSS: case SEG_UNKNOWN:
- case SEG_DIFFERENCE:
- i.types[this_operand] |= Imm32; /* this is an address ==> 32bit */
- break;
- default:
- seg_unimplemented:
- as_bad("Unimplemented segment type %d in parse_operand", exp_seg);
- return 0;
- }
- /* shorten this type of this operand if the instruction wants
- * fewer bits than are present in the immediate. The bit field
- * code can put out 'andb $0xffffff, %al', for example. pace
- * also 'movw $foo,(%eax)'
- */
- switch (i.suffix) {
- case WORD_OPCODE_SUFFIX:
- i.types[this_operand] |= Imm16;
- break;
- case BYTE_OPCODE_SUFFIX:
- i.types[this_operand] |= Imm16 | Imm8 | Imm8S;
- break;
- }
- } else if (is_digit_char(*op_string) || is_identifier_char(*op_string)
- || *op_string == '(') {
- /* This is a memory reference of some sort. */
- register char * base_string;
- unsigned int found_base_index_form;
-
- do_memory_reference:
- if (i.mem_operands == MAX_MEMORY_OPERANDS) {
- as_bad("more than 1 memory reference in instruction");
- return 0;
- }
- i.mem_operands++;
-
- /* Determine type of memory operand from opcode_suffix;
- no opcode suffix implies general memory references. */
- switch (i.suffix) {
- case BYTE_OPCODE_SUFFIX:
- i.types[this_operand] |= Mem8;
- break;
- case WORD_OPCODE_SUFFIX:
- i.types[this_operand] |= Mem16;
- break;
- case DWORD_OPCODE_SUFFIX:
- default:
- i.types[this_operand] |= Mem32;
- }
-
- /* Check for base index form. We detect the base index form by
- looking for an ')' at the end of the operand, searching
- for the '(' matching it, and finding a REGISTER_PREFIX or ','
- after it. */
- base_string = end_of_operand_string - 1;
- found_base_index_form = 0;
- if (*base_string == ')') {
- unsigned int parens_balenced = 1;
- /* We've already checked that the number of left & right ()'s are equal,
- so this loop will not be infinite. */
- do {
- base_string--;
- if (*base_string == ')') parens_balenced++;
- if (*base_string == '(') parens_balenced--;
- } while (parens_balenced);
- base_string++; /* Skip past '('. */
- if (*base_string == REGISTER_PREFIX || *base_string == ',')
- found_base_index_form = 1;
- }
-
- /* If we can't parse a base index register expression, we've found
- a pure displacement expression. We set up displacement_string_start
- and displacement_string_end for the code below. */
- if (! found_base_index_form) {
- displacement_string_start = op_string;
- displacement_string_end = end_of_operand_string;
- } else {
- char *base_reg_name, *index_reg_name, *num_string;
- int num;
-
- i.types[this_operand] |= BaseIndex;
-
- /* If there is a displacement set-up for it to be parsed later. */
- if (base_string != op_string + 1) {
- displacement_string_start = op_string;
- displacement_string_end = base_string - 1;
- }
-
- /* Find base register (if any). */
- if (*base_string != ',') {
- base_reg_name = base_string++;
- /* skip past register name & parse it */
- while (isalpha(*base_string)) base_string++;
- if (base_string == base_reg_name+1) {
- as_bad("can't find base register name after '(%c'",
- REGISTER_PREFIX);
- return 0;
- }
- END_STRING_AND_SAVE (base_string);
- if (! (i.base_reg = parse_register (base_reg_name))) {
- as_bad("bad base register name ('%s')", base_reg_name);
- return 0;
- }
- RESTORE_END_STRING (base_string);
- }
-
- /* Now check seperator; must be ',' ==> index reg
- OR num ==> no index reg. just scale factor
- OR ')' ==> end. (scale factor = 1) */
- if (*base_string != ',' && *base_string != ')') {
- as_bad("expecting ',' or ')' after base register in `%s'",
- operand_string);
- return 0;
- }
-
- /* There may index reg here; and there may be a scale factor. */
- if (*base_string == ',' && *(base_string+1) == REGISTER_PREFIX) {
- index_reg_name = ++base_string;
- while (isalpha(*++base_string));
- END_STRING_AND_SAVE (base_string);
- if (! (i.index_reg = parse_register(index_reg_name))) {
- as_bad("bad index register name ('%s')", index_reg_name);
- return 0;
- }
- RESTORE_END_STRING (base_string);
- }
-
- /* Check for scale factor. */
- if (*base_string == ',' && isdigit(*(base_string+1))) {
- num_string = ++base_string;
- while (is_digit_char(*base_string)) base_string++;
- if (base_string == num_string) {
- as_bad("can't find a scale factor after ','");
- return 0;
- }
- END_STRING_AND_SAVE (base_string);
- /* We've got a scale factor. */
- if (! sscanf (num_string, "%d", &num)) {
- as_bad("can't parse scale factor from '%s'", num_string);
- return 0;
- }
- RESTORE_END_STRING (base_string);
- switch (num) { /* must be 1 digit scale */
- case 1: i.log2_scale_factor = 0; break;
- case 2: i.log2_scale_factor = 1; break;
- case 4: i.log2_scale_factor = 2; break;
- case 8: i.log2_scale_factor = 3; break;
- default:
- as_bad("expecting scale factor of 1, 2, 4, 8; got %d", num);
- return 0;
- }
- } else {
- if (! i.index_reg && *base_string == ',') {
- as_bad("expecting index register or scale factor after ','; got '%c'",
- *(base_string+1));
- return 0;
- }
- }
- }
-
- /* If there's an expression begining the operand, parse it,
- assuming displacement_string_start and displacement_string_end
- are meaningful. */
- if (displacement_string_start) {
- register expressionS *exp;
- segT exp_seg = SEG_GOOF;
- char *save_input_line_pointer;
- exp = &disp_expressions[i.disp_operands];
- i.disps[this_operand] = exp;
- i.disp_reloc[this_operand] = NO_RELOC;
- i.disp_operands++;
- save_input_line_pointer = input_line_pointer;
- input_line_pointer = displacement_string_start;
- END_STRING_AND_SAVE (displacement_string_end);
-#ifdef PIC
- {
- /*
- * We can have operands of the form
- * <symbol>@GOTOFF+<nnn>
- * Take the easy way out here and copy everything
- * into a temporary buffer...
- */
- register char *cp;
- if (picmode &&
- (cp = strchr(input_line_pointer,'@'))) {
- char tmpbuf[BUFSIZ];
-
- if (strncmp(cp+1, "PLT", 3) == 0) {
- i.disp_reloc[this_operand] = RELOC_JMP_TBL;
- *cp = '\0';
- strcpy(tmpbuf, input_line_pointer);
- strcat(tmpbuf, cp+1+3);
- *cp = '@';
- } else if (strncmp(cp+1, "GOTOFF", 6) == 0) {
- i.disp_reloc[this_operand] = RELOC_GOTOFF;
- *cp = '\0';
- strcpy(tmpbuf, input_line_pointer);
- strcat(tmpbuf, cp+1+6);
- *cp = '@';
- } else if (strncmp(cp+1, "GOT", 3) == 0) {
- i.disp_reloc[this_operand] = RELOC_GOT;
- *cp = '\0';
- strcpy(tmpbuf, input_line_pointer);
- strcat(tmpbuf, cp+1+3);
- *cp = '@';
- } else
- as_bad("Bad reloc specifier '%s' in expression", cp+1);
- input_line_pointer = tmpbuf;
- }
- }
-#endif
- exp_seg = expression(exp);
-#ifdef PIC
- if (i.disp_reloc[this_operand] == RELOC_GOTOFF)
- exp->X_add_symbol->sy_forceout = 1;
-#endif
- if (*input_line_pointer)
- as_bad("Ignoring junk '%s' after expression",input_line_pointer);
- RESTORE_END_STRING (displacement_string_end);
- input_line_pointer = save_input_line_pointer;
- switch (exp_seg) {
- case SEG_ABSENT:
- /* missing expr becomes absolute 0 */
- as_bad("missing or invalid displacement '%s' taken as 0",
- operand_string);
- if (i.disp_reloc[this_operand] != NO_RELOC || !found_base_index_form || !i.base_reg) {
- i.types[this_operand] |= (Disp|Abs);
- exp->X_seg = SEG_ABSOLUTE;
- exp->X_add_number = 0;
- exp->X_add_symbol = (symbolS *) 0;
- exp->X_subtract_symbol = (symbolS *) 0;
- } else {
-#ifdef DEBUGxxx
- printf("displacement removed in operand `%s'\n", operand_string);
-#endif
- i.disp_operands--;
- i.disps[this_operand] = 0;
- }
- break;
- case SEG_ABSOLUTE:
- if (i.disp_reloc[this_operand] != NO_RELOC || !found_base_index_form || !i.base_reg || exp->X_add_symbol || exp->X_subtract_symbol || exp->X_add_number != 0)
- i.types[this_operand] |= SMALLEST_DISP_TYPE (exp->X_add_number);
- else {
-#ifdef DEBUGxxx
- printf("displacement removed in operand `%s'\n", operand_string);
-#endif
- i.disp_operands--;
- i.disps[this_operand] = 0;
- }
- break;
- case SEG_TEXT: case SEG_DATA: case SEG_BSS:
- case SEG_UNKNOWN: /* must be 32 bit displacement (i.e. address) */
- if (i.disp_reloc[this_operand] != NO_RELOC || !found_base_index_form || !i.base_reg || exp->X_add_symbol || exp->X_subtract_symbol || exp->X_add_number != 0)
- i.types[this_operand] |= Disp32;
- else {
-#ifdef DEBUGxxx
- printf("displacement removed in operand `%s'\n", operand_string);
-#endif
- i.disp_operands--;
- i.disps[this_operand] = 0;
- }
- break;
- default:
- goto seg_unimplemented;
- }
- }
-
- /* Make sure the memory operand we've been dealt is valid. */
- if (i.base_reg && i.index_reg &&
- ! (i.base_reg->reg_type & i.index_reg->reg_type & Reg)) {
- as_bad("register size mismatch in (base,index,scale) expression");
- return 0;
- }
- /*
- * special case for (%dx) while doing input/output op
- */
- if ((i.base_reg &&
- (i.base_reg->reg_type == (Reg16|InOutPortReg)) &&
- (i.index_reg == 0)))
- return 1;
- if ((i.base_reg && (i.base_reg->reg_type & Reg32) == 0) ||
- (i.index_reg && (i.index_reg->reg_type & Reg32) == 0)) {
- as_bad("base/index register must be 32 bit register");
- return 0;
- }
- if (i.index_reg && i.index_reg == esp) {
- as_bad("%s may not be used as an index register", esp->reg_name);
- return 0;
- }
- } else { /* it's not a memory operand; argh! */
- as_bad("invalid char %s begining %s operand '%s'",
- output_invalid(*op_string), ordinal_names[this_operand],
- op_string);
- return 0;
- }
- return 1; /* normal return */
-}
-
-/*
- * md_estimate_size_before_relax()
- *
- * Called just before relax().
- * Any symbol that is now undefined will not become defined.
- * Return the correct fr_subtype in the frag.
- * Return the initial "guess for fr_var" to caller.
- * The guess for fr_var is ACTUALLY the growth beyond fr_fix.
- * Whatever we do to grow fr_fix or fr_var contributes to our returned value.
- * Although it may not be explicit in the frag, pretend fr_var starts with a
- * 0 value.
- */
-int
- md_estimate_size_before_relax (fragP, segment)
-register fragS * fragP;
-register segT segment;
-{
- register unsigned char * opcode;
- register int old_fr_fix;
-
- old_fr_fix = fragP->fr_fix;
- opcode = (unsigned char *) fragP->fr_opcode;
- /* We've already got fragP->fr_subtype right; all we have to do is check
- for un-relaxable symbols. */
- if (S_GET_SEGMENT(fragP->fr_symbol) != segment) {
- /* symbol is undefined in this segment */
- switch (opcode[0]) {
- case JUMP_PC_RELATIVE: /* make jmp (0xeb) a dword displacement jump */
- opcode[0] = 0xe9; /* dword disp jmp */
- fragP->fr_fix += 4;
- fix_new (fragP, old_fr_fix, 4,
- fragP->fr_symbol,
- (symbolS *) 0,
- fragP->fr_offset, 1,
-#ifdef PIC
-/* XXX - oops, the JMP_TBL relocation info should have percolated through
- * here, define a field in frag to this?
- */
- (picmode && S_GET_SEGMENT(fragP->fr_symbol) == SEG_UNKNOWN)?
- RELOC_JMP_TBL :
-#endif
- NO_RELOC, (symbolS *)0);
- break;
-
- default:
- /* This changes the byte-displacement jump 0x7N -->
- the dword-displacement jump 0x0f8N */
- opcode[1] = opcode[0] + 0x10;
- opcode[0] = TWO_BYTE_OPCODE_ESCAPE; /* two-byte escape */
- fragP->fr_fix += 1 + 4; /* we've added an opcode byte */
- fix_new (fragP, old_fr_fix + 1, 4,
- fragP->fr_symbol,
- (symbolS *) 0,
- fragP->fr_offset, 1,
-#ifdef PIC
-/*XXX*/ (picmode && S_GET_SEGMENT(fragP->fr_symbol) == SEG_UNKNOWN)?
- RELOC_JMP_TBL :
-#endif
- NO_RELOC, (symbolS *)0);
- break;
- }
- frag_wane (fragP);
- }
- return (fragP->fr_var + fragP->fr_fix - old_fr_fix);
-} /* md_estimate_size_before_relax() */
-
-/*
- * md_convert_frag();
- *
- * Called after relax() is finished.
- * In: Address of frag.
- * fr_type == rs_machine_dependent.
- * fr_subtype is what the address relaxed to.
- *
- * Out: Any fixSs and constants are set up.
- * Caller will turn frag into a ".space 0".
- */
-void
- md_convert_frag (headers, fragP)
-object_headers *headers;
-register fragS * fragP;
-{
- register unsigned char *opcode;
- unsigned char *where_to_put_displacement = NULL;
- unsigned int target_address;
- unsigned int opcode_address;
- unsigned int extension = 0;
- int displacement_from_opcode_start;
-
- opcode = (unsigned char *) fragP->fr_opcode;
-
- /* Address we want to reach in file space. */
- target_address = S_GET_VALUE(fragP->fr_symbol) + fragP->fr_offset;
-
- /* Address opcode resides at in file space. */
- opcode_address = fragP->fr_address + fragP->fr_fix;
-
- /* Displacement from opcode start to fill into instruction. */
- displacement_from_opcode_start = target_address - opcode_address;
-
- switch (fragP->fr_subtype) {
- case ENCODE_RELAX_STATE (COND_JUMP, BYTE):
- case ENCODE_RELAX_STATE (UNCOND_JUMP, BYTE):
- /* don't have to change opcode */
- extension = 1; /* 1 opcode + 1 displacement */
- where_to_put_displacement = &opcode[1];
- break;
-
- case ENCODE_RELAX_STATE (COND_JUMP, WORD):
- opcode[1] = TWO_BYTE_OPCODE_ESCAPE;
- opcode[2] = opcode[0] + 0x10;
- opcode[0] = WORD_PREFIX_OPCODE;
- extension = 4; /* 3 opcode + 2 displacement */
- where_to_put_displacement = &opcode[3];
- break;
-
- case ENCODE_RELAX_STATE (UNCOND_JUMP, WORD):
- opcode[1] = 0xe9;
- opcode[0] = WORD_PREFIX_OPCODE;
- extension = 3; /* 2 opcode + 2 displacement */
- where_to_put_displacement = &opcode[2];
- break;
-
- case ENCODE_RELAX_STATE (COND_JUMP, DWORD):
- opcode[1] = opcode[0] + 0x10;
- opcode[0] = TWO_BYTE_OPCODE_ESCAPE;
- extension = 5; /* 2 opcode + 4 displacement */
- where_to_put_displacement = &opcode[2];
- break;
-
- case ENCODE_RELAX_STATE (UNCOND_JUMP, DWORD):
- opcode[0] = 0xe9;
- extension = 4; /* 1 opcode + 4 displacement */
- where_to_put_displacement = &opcode[1];
- break;
-
- default:
- BAD_CASE(fragP->fr_subtype);
- break;
-}
- /* now put displacement after opcode */
- md_number_to_chars ((char *) where_to_put_displacement,
- displacement_from_opcode_start - extension,
- SIZE_FROM_RELAX_STATE (fragP->fr_subtype));
- fragP->fr_fix += extension;
-}
-
-
-int md_short_jump_size = 2; /* size of byte displacement jmp */
-int md_long_jump_size = 5; /* size of dword displacement jmp */
-const int md_reloc_size = 8; /* Size of relocation record */
-
-void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr, to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- long offset;
-
- offset = to_addr - (from_addr + 2);
- md_number_to_chars (ptr, (long) 0xeb, 1); /* opcode for byte-disp jump */
- md_number_to_chars (ptr + 1, offset, 1);
-}
-
-void md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr, to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- long offset;
-
- if (flagseen['m']) {
- offset = to_addr - S_GET_VALUE(to_symbol);
- md_number_to_chars (ptr, 0xe9, 1); /* opcode for long jmp */
- md_number_to_chars (ptr + 1, offset, 4);
- fix_new (frag, (ptr+1) - frag->fr_literal, 4,
- to_symbol, (symbolS *) 0, (long) 0, 0, NO_RELOC, (symbolS *)0);
- } else {
- offset = to_addr - (from_addr + 5);
- md_number_to_chars(ptr, (long) 0xe9, 1);
- md_number_to_chars(ptr + 1, offset, 4);
- }
-}
-
-int
- md_parse_option(argP,cntP,vecP)
-char **argP;
-int *cntP;
-char ***vecP;
-{
- switch (**argP) {
-#ifdef PIC
- case 'k':
- case 'K':
-#if 00
- char *tmp = xmalloc(3+1+strlen(operand_special_chars));
- strcpy(tmp, operand_special_chars);
- strcat(tmp, "@[]");
- operand_special_chars = tmp;
-#endif
- /* Allow `[', `]' in expressions and `@' in operands */
- operand_chars['@'] = '@';
- operand_chars['['] = '[';
- operand_chars[']'] = ']';
-
- /* Disallow `[' as a name beginner */
- lex_type['['] = 0;
-
- /* Predefine GOT symbol */
- GOT_symbol = symbol_find_or_make("__GLOBAL_OFFSET_TABLE_");
- break;
-#endif
-
- default:
- return 0;
- }
- return 1;
-}
-
- /* write out in little endian. */
-void /* Knows about order of bytes in address. */
- md_number_to_chars(con, value, nbytes)
-char con[]; /* Return 'nbytes' of chars here. */
-long value; /* The value of the bits. */
-int nbytes; /* Number of bytes in the output. */
-{
- register char * p = con;
-
- switch (nbytes) {
- case 1:
- p[0] = value & 0xff;
- break;
- case 2:
- p[0] = value & 0xff;
- p[1] = (value >> 8) & 0xff;
- break;
- case 4:
- p[0] = value & 0xff;
- p[1] = (value>>8) & 0xff;
- p[2] = (value>>16) & 0xff;
- p[3] = (value>>24) & 0xff;
- break;
- default:
- BAD_CASE (nbytes);
- }
-}
-
-
-/* Apply a fixup (fixS) to segment data, once it has been determined
- by our caller that we have all the info we need to fix it up.
-
- On the 386, immediates, displacements, and data pointers are all in
- the same (little-endian) format, so we don't need to care about which
- we are handling. */
-
-void
- md_apply_fix (fixP, value)
-fixS * fixP; /* The fix we're to put in */
-long value; /* The value of the bits. */
-{
- register char * p = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- switch (fixP->fx_size) {
- case 1:
- *p = value;
- break;
- case 2:
- *p++ = value;
- *p = (value>>8);
- break;
- case 4:
- *p++ = value;
- *p++ = (value>>8);
- *p++ = (value>>16);
- *p = (value>>24);
- break;
- default:
- BAD_CASE (fixP->fx_size);
- }
-}
-
-long /* Knows about the byte order in a word. */
- md_chars_to_number (con, nbytes)
-unsigned char con[]; /* Low order byte 1st. */
-int nbytes; /* Number of bytes in the input. */
-{
- long retval;
- for (retval=0, con+=nbytes-1; nbytes--; con--)
- {
- retval <<= BITS_PER_CHAR;
- retval |= *con;
- }
- return retval;
-}
-
-/* Not needed for coff since relocation structure does not
- contain bitfields. */
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
-#ifdef comment
-/* Output relocation information in the target's format. */
-void
- md_ri_to_chars(the_bytes, ri)
-char *the_bytes;
-struct reloc_info_generic *ri;
-{
- /* this is easy */
- md_number_to_chars(the_bytes, ri->r_address, 4);
- /* now the fun stuff */
- the_bytes[6] = (ri->r_symbolnum >> 16) & 0x0ff;
- the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff;
- the_bytes[4] = ri->r_symbolnum & 0x0ff;
- the_bytes[7] = (((ri->r_extern << 3) & 0x08) | ((ri->r_length << 1) & 0x06) |
- ((ri->r_pcrel << 0) & 0x01)) & 0x0F;
-}
-#endif /* comment */
-
-void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
-char *where;
-fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- /*
- * In: length of relocation (or of address) in chars: 1, 2 or 4.
- * Out: GNU LD relocation length code: 0, 1, or 2.
- */
-
- static unsigned char nbytes_r_length[] = { 42, 0, 1, 42, 2 };
- long r_symbolnum;
-
- know(fixP->fx_addsy != NULL);
-
- md_number_to_chars(where,
- fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
- 4);
-
- r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
- ? S_GET_TYPE(fixP->fx_addsy)
- : fixP->fx_addsy->sy_number);
-
-#ifdef PIC
- {
- int extra_bits = 0;
- int extrn_bit = !S_IS_DEFINED(fixP->fx_addsy);
-
- switch (fixP->fx_r_type) {
- case NO_RELOC:
- break;
- case RELOC_32:
- if (!picmode || !S_IS_EXTERNAL(fixP->fx_addsy))
- break;
- r_symbolnum = fixP->fx_addsy->sy_number;
- extrn_bit = 1;
- break;
- case RELOC_GOT:
- extra_bits = (1 << 4) & 0x10; /* r_baserel */
- r_symbolnum = fixP->fx_addsy->sy_number;
- if (!extrn_bit && !S_IS_EXTERNAL(fixP->fx_addsy))
- as_warn("GOT relocation burb: `%s' should be global",
- S_GET_NAME(fixP->fx_addsy));
- S_SET_EXTERNAL(fixP->fx_addsy);
- extrn_bit = 1;
- break;
- case RELOC_GOTOFF:
- extra_bits = (1 << 4) & 0x10; /* r_baserel */
- r_symbolnum = fixP->fx_addsy->sy_number;
- if (extrn_bit || S_IS_EXTERNAL(fixP->fx_addsy))
- as_warn("GOT relocation burb: `%s' should be static",
- S_GET_NAME(fixP->fx_addsy));
- break;
- case RELOC_JMP_TBL:
- extra_bits = (1 << 5) & 0x20; /* r_jmptable */
- break;
- case RELOC_RELATIVE:
- /* consider using this bit (together with r_baserel) for
- * GOTOFFs, so ld can check
- */
- as_fatal("relocation botch");
- extra_bits = (1 << 6) & 0x40; /* r_relative */
- break;
- }
- where[6] = (r_symbolnum >> 16) & 0x0ff;
- where[5] = (r_symbolnum >> 8) & 0x0ff;
- where[4] = r_symbolnum & 0x0ff;
- where[7] = ( ((extrn_bit << 3) & 0x08)
- | ((nbytes_r_length[fixP->fx_size] << 1) & 0x06)
- | ((fixP->fx_pcrel << 0) & 0x01)
- | (extra_bits)
- );
- }
-#else
- where[6] = (r_symbolnum >> 16) & 0x0ff;
- where[5] = (r_symbolnum >> 8) & 0x0ff;
- where[4] = r_symbolnum & 0x0ff;
- where[7] = ((((!S_IS_DEFINED(fixP->fx_addsy)) << 3) & 0x08)
- | ((nbytes_r_length[fixP->fx_size] << 1) & 0x06)
- | (((fixP->fx_pcrel << 0) & 0x01) & 0x0f));
-#endif
-
- return;
-} /* tc_aout_fix_to_chars() */
-
-#endif /* OBJ_AOUT or OBJ_BOUT */
-
-
-#define MAX_LITTLENUMS 6
-
-/* Turn the string pointed to by litP into a floating point constant of type
- type, and emit the appropriate bytes. The number of LITTLENUMS emitted
- is stored in *sizeP. An error message is returned, or NULL on OK.
- */
-char *
- md_atof(type,litP,sizeP)
-char type;
-char *litP;
-int *sizeP;
-{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- char *t;
-
- switch (type) {
- case 'f':
- case 'F':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- prec = 4;
- break;
-
- case 'x':
- case 'X':
- prec = 5;
- break;
-
- default:
- *sizeP=0;
- return "Bad call to md_atof ()";
- }
- t = atof_ieee (input_line_pointer,type,words);
- if (t)
- input_line_pointer=t;
-
- *sizeP = prec * sizeof(LITTLENUM_TYPE);
- /* this loops outputs the LITTLENUMs in REVERSE order; in accord with
- the bigendian 386 */
- for (wordP = words + prec - 1;prec--;) {
- md_number_to_chars (litP, (long) (*wordP--), sizeof(LITTLENUM_TYPE));
- litP += sizeof(LITTLENUM_TYPE);
- }
- return ""; /* Someone should teach Dean about null pointers */
-}
-
-char output_invalid_buf[8];
-
-static char * output_invalid (c)
-char c;
-{
- if (isprint(c)) sprintf (output_invalid_buf, "'%c'", c);
- else sprintf (output_invalid_buf, "(0x%x)", (unsigned) c);
- return output_invalid_buf;
-}
-
-static reg_entry *parse_register (reg_string)
-char *reg_string; /* reg_string starts *before* REGISTER_PREFIX */
-{
- register char *s = reg_string;
- register char *p;
- char reg_name_given[MAX_REG_NAME_SIZE];
-
- s++; /* skip REGISTER_PREFIX */
- for (p = reg_name_given; is_register_char (*s); p++, s++) {
- *p = register_chars[*s];
- if (p >= reg_name_given + MAX_REG_NAME_SIZE)
- return (reg_entry *) 0;
- }
- *p = '\0';
- return (reg_entry *) hash_find (reg_hash, reg_name_given);
-}
-
-
-/* We have no need to default values of symbols. */
-
-/* ARGSUSED */
-symbolS *
- md_undefined_symbol (name)
-char *name;
-{
-#ifdef PIC
- /* HACK:
- * Sun's ld expects __GLOBAL_OFFSET_TABLE_,
- * gcc generates _GLOBAL_OFFSET_TABLE_
- * should probably fix ld - new SVR4 style??
- */
- if (*name == '_' && *(name+1) == 'G' &&
- strcmp(name, "_GLOBAL_OFFSET_TABLE_") == 0)
- return symbol_find("__GLOBAL_OFFSET_TABLE_");
-#endif
- return 0;
-}
-
-/* Parse an operand that is machine-specific.
- We just return without modifying the expression if we have nothing
- to do. */
-
-/* ARGSUSED */
-void
- md_operand (expressionP)
-expressionS *expressionP;
-{
-}
-
-/* Round up a section size to the appropriate boundary. */
-long
- md_section_align (segment, size)
-segT segment;
-long size;
-{
- return size; /* Byte alignment is fine */
-}
-
-/* Exactly what point is a PC-relative offset relative TO?
- On the i386, they're relative to the address of the offset, plus
- its size. (??? Is this right? FIXME-SOON!) */
-long
- md_pcrel_from (fixP)
-fixS *fixP;
-{
-#ifdef PIC
- /*
- * _GLOBAL_OFFSET_TABLE_ refs are relative to the offset of the
- * current instruction. fx_pcrel_adjust has been setup to account
- * for the number of opcode bytes preceding the fixup location,
- * it is zero for eg. .long pseudo-ops.
- */
- if (fixP->fx_gotsy)
- return fixP->fx_where + fixP->fx_frag->fr_address - fixP->fx_pcrel_adjust;
- else
-#endif
- return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
-}
-
- /* these were macros, but I don't trust macros that eval their
- arguments more than once. Besides, gcc can static inline them.
- xoxorich. */
-
-static unsigned long mode_from_disp_size(t)
-unsigned long t;
-{
- return((t & (Disp8))
- ? 1
- : ((t & (Disp32)) ? 2 : 0));
-} /* mode_from_disp_size() */
-
-/* convert opcode suffix ('b' 'w' 'l' typically) into type specifyer */
-
-static unsigned long opcode_suffix_to_type(s)
-unsigned long s;
-{
- return(s == BYTE_OPCODE_SUFFIX
- ? Byte : (s == WORD_OPCODE_SUFFIX
- ? Word : DWord));
-} /* opcode_suffix_to_type() */
-
-static int fits_in_signed_byte(num)
-long num;
-{
- return((num >= -128) && (num <= 127));
-} /* fits_in_signed_byte() */
-
-static int fits_in_unsigned_byte(num)
-long num;
-{
- return((num & 0xff) == num);
-} /* fits_in_unsigned_byte() */
-
-static int fits_in_unsigned_word(num)
-long num;
-{
- return((num & 0xffff) == num);
-} /* fits_in_unsigned_word() */
-
-static int fits_in_signed_word(num)
-long num;
-{
- return((-32768 <= num) && (num <= 32767));
-} /* fits_in_signed_word() */
-
-static int smallest_imm_type(num)
-long num;
-{
- return((num == 1)
- ? (Imm1|Imm8|Imm8S|Imm16|Imm32)
- : (fits_in_signed_byte(num)
- ? (Imm8S|Imm8|Imm16|Imm32)
- : (fits_in_unsigned_byte(num)
- ? (Imm8|Imm16|Imm32)
- : ((fits_in_signed_word(num) || fits_in_unsigned_word(num))
- ? (Imm16|Imm32)
- : (Imm32)))));
-} /* smallest_imm_type() */
-
-static void s_bss()
-{
- register int temp;
-
- temp = get_absolute_expression ();
- subseg_new (SEG_BSS, (subsegT)temp);
- demand_empty_rest_of_line();
-}
-
-/*
- * Local Variables:
- * comment-column: 0
- * End:
- */
-
-/* end of tc-i386.c */
diff --git a/gnu/usr.bin/as/config/tc-i386.h b/gnu/usr.bin/as/config/tc-i386.h
deleted file mode 100644
index 0a31d4d..0000000
--- a/gnu/usr.bin/as/config/tc-i386.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/* tc-i386.h -- Header file for tc-i386.c
- Copyright (C) 1989, 1992 Free Software Foundation.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * $Id$
- */
-
-#ifndef TC_I386
-#define TC_I386 1
-
-#define AOUT_MACHTYPE 134
-
-#define REVERSE_SORT_RELOCS
-
-#define LOCAL_LABELS_FB
-
-#define tc_coff_symbol_emit_hook(a) ; /* not used */
-
- /* Local labels starts with .L */
- /* fixme-now: this is for testing against old gas */
-/* #define LOCAL_LABEL(name) ((name)[0] == '.' && (name)[1] == 'L') */
-#define tc_aout_pre_write_hook(x) {;} /* not used */
-#define tc_crawl_symbol_chain(a) {;} /* not used */
-#define tc_headers_hook(a) {;} /* not used */
-
-#define MAX_OPERANDS 3 /* max operands per insn */
-#define MAX_PREFIXES 4 /* max prefixes per opcode */
-#define MAX_IMMEDIATE_OPERANDS 2 /* max immediates per insn */
-#define MAX_MEMORY_OPERANDS 2 /* max memory ref per insn
- * lcall uses 2
- */
-/* we define the syntax here (modulo base,index,scale syntax) */
-#define REGISTER_PREFIX '%'
-#define IMMEDIATE_PREFIX '$'
-#define ABSOLUTE_PREFIX '*'
-#define PREFIX_SEPERATOR '/'
-
-#define TWO_BYTE_OPCODE_ESCAPE 0x0f
-
-#ifndef OLD_GAS
-#define NOP_OPCODE 0x90
-#else /* OLD_GAS */
-#define NOP_OPCODE 0x00
-#endif /* OLD_GAS */
-
-/* register numbers */
-#define EBP_REG_NUM 5
-#define ESP_REG_NUM 4
-
-/* modrm_byte.regmem for twobyte escape */
-#define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM
-/* index_base_byte.index for no index register addressing */
-#define NO_INDEX_REGISTER ESP_REG_NUM
-/* index_base_byte.base for no base register addressing */
-#define NO_BASE_REGISTER EBP_REG_NUM
-
- /* these are the att as opcode suffixes, making movl --> mov, for example */
-#define DWORD_OPCODE_SUFFIX 'l'
-#define WORD_OPCODE_SUFFIX 'w'
-#define BYTE_OPCODE_SUFFIX 'b'
-
- /* modrm.mode = REGMEM_FIELD_HAS_REG when a register is in there */
-#define REGMEM_FIELD_HAS_REG 0x3 /* always = 0x3 */
-#define REGMEM_FIELD_HAS_MEM (~REGMEM_FIELD_HAS_REG)
-
-#define END_OF_INSN '\0'
-
-/*
- When an operand is read in it is classified by its type. This type includes
- all the possible ways an operand can be used. Thus, '%eax' is both 'register
- # 0' and 'The Accumulator'. In our language this is expressed by OR'ing
- 'Reg32' (any 32 bit register) and 'Acc' (the accumulator).
- Operands are classified so that we can match given operand types with
- the opcode table in i386-opcode.h.
- */
-#define Unknown 0x0
-/* register */
-#define Reg8 0x1 /* 8 bit reg */
-#define Reg16 0x2 /* 16 bit reg */
-#define Reg32 0x4 /* 32 bit reg */
-#define Reg (Reg8|Reg16|Reg32) /* gen'l register */
-#define WordReg (Reg16|Reg32) /* for push/pop operands */
-/* immediate */
-#define Imm8 0x8 /* 8 bit immediate */
-#define Imm8S 0x10 /* 8 bit immediate sign extended */
-#define Imm16 0x20 /* 16 bit immediate */
-#define Imm32 0x40 /* 32 bit immediate */
-#define Imm1 0x80 /* 1 bit immediate */
-#define ImmUnknown Imm32 /* for unknown expressions */
-#define Imm (Imm8|Imm8S|Imm16|Imm32) /* gen'l immediate */
-/* memory */
-#define Disp8 0x200 /* 8 bit displacement (for jumps) */
-#define Disp16 0x400 /* 16 bit displacement */
-#define Disp32 0x800 /* 32 bit displacement */
-#define Disp (Disp8|Disp16|Disp32) /* General displacement */
-#define DispUnknown Disp32 /* for unknown size displacements */
-#define Mem8 0x1000
-#define Mem16 0x2000
-#define Mem32 0x4000
-#define BaseIndex 0x8000
-#define Mem (Disp|Mem8|Mem16|Mem32|BaseIndex) /* General memory */
-#define WordMem (Mem16|Mem32|Disp|BaseIndex)
-#define ByteMem (Mem8|Disp|BaseIndex)
-/* specials */
-#define InOutPortReg 0x10000 /* register to hold in/out port addr = dx */
-#define ShiftCount 0x20000 /* register to hold shift cound = cl */
-#define Control 0x40000 /* Control register */
-#define Debug 0x80000 /* Debug register */
-#define Test 0x100000 /* Test register */
-#define FloatReg 0x200000 /* Float register */
-#define FloatAcc 0x400000 /* Float stack top %st(0) */
-#define SReg2 0x800000 /* 2 bit segment register */
-#define SReg3 0x1000000 /* 3 bit segment register */
-#define Acc 0x2000000 /* Accumulator %al or %ax or %eax */
-#define ImplicitRegister (InOutPortReg|ShiftCount|Acc|FloatAcc)
-#define JumpAbsolute 0x4000000
-#define Abs8 0x08000000
-#define Abs16 0x10000000
-#define Abs32 0x20000000
-#define Abs (Abs8|Abs16|Abs32)
-
-#define Byte (Reg8|Imm8|Imm8S)
-#define Word (Reg16|Imm16)
-#define DWord (Reg32|Imm32)
-
-#define SMALLEST_DISP_TYPE(num) \
- fits_in_signed_byte(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32)
-
-typedef struct {
- /* instruction name sans width suffix ("mov" for movl insns) */
- char *name;
-
- /* how many operands */
- unsigned int operands;
-
- /* base_opcode is the fundamental opcode byte with a optional prefix(es). */
- unsigned int base_opcode;
-
- /* extension_opcode is the 3 bit extension for group <n> insns.
- If this template has no extension opcode (the usual case) use None */
- unsigned char extension_opcode;
-#define None 0xff /* If no extension_opcode is possible. */
-
- /* the bits in opcode_modifier are used to generate the final opcode from
- the base_opcode. These bits also are used to detect alternate forms of
- the same instruction */
- unsigned int opcode_modifier;
-
- /* opcode_modifier bits: */
-#define W 0x1 /* set if operands are words or dwords */
-#define D 0x2 /* D = 0 if Reg --> Regmem; D = 1 if Regmem --> Reg */
- /* direction flag for floating insns: MUST BE 0x400 */
-#define FloatD 0x400
- /* shorthand */
-#define DW (D|W)
-#define ShortForm 0x10 /* register is in low 3 bits of opcode */
-#define ShortFormW 0x20 /* ShortForm and W bit is 0x8 */
-#define Seg2ShortForm 0x40 /* encoding of load segment reg insns */
-#define Seg3ShortForm 0x80 /* fs/gs segment register insns. */
-#define Jump 0x100 /* special case for jump insns. */
-#define JumpInterSegment 0x200 /* special case for intersegment leaps/calls */
- /* 0x400 CANNOT BE USED since it's already used by FloatD above */
-#define DONT_USE 0x400
-#define NoModrm 0x800
-#define Modrm 0x1000
-#define imulKludge 0x2000
-#define JumpByte 0x4000
-#define JumpDword 0x8000
-#define ReverseRegRegmem 0x10000
-
- /* (opcode_modifier & COMES_IN_ALL_SIZES) is true if the
- instuction comes in byte, word, and dword sizes and is encoded into
- machine code in the canonical way. */
-#define COMES_IN_ALL_SIZES (W)
-
- /* (opcode_modifier & COMES_IN_BOTH_DIRECTIONS) indicates that the
- source and destination operands can be reversed by setting either
- the D (for integer insns) or the FloatD (for floating insns) bit
- in base_opcode. */
-#define COMES_IN_BOTH_DIRECTIONS (D|FloatD)
-
- /* operand_types[i] describes the type of operand i. This is made
- by OR'ing together all of the possible type masks. (e.g.
- 'operand_types[i] = Reg|Imm' specifies that operand i can be
- either a register or an immediate operand */
- unsigned int operand_types[3];
-} template;
-
-/*
- 'templates' is for grouping together 'template' structures for opcodes
- of the same name. This is only used for storing the insns in the grand
- ole hash table of insns.
- The templates themselves start at START and range up to (but not including)
- END.
- */
-typedef struct {
- template *start;
- template *end;
-} templates;
-
-/* these are for register name --> number & type hash lookup */
-typedef struct {
- char *reg_name;
- unsigned int reg_type;
- unsigned int reg_num;
-} reg_entry;
-
-typedef struct {
- char *seg_name;
- unsigned int seg_prefix;
-} seg_entry;
-
-/* these are for prefix name --> prefix code hash lookup */
-typedef struct {
- char *prefix_name;
- unsigned char prefix_code;
-} prefix_entry;
-
-/* 386 operand encoding bytes: see 386 book for details of this. */
-typedef struct {
- unsigned regmem:3; /* codes register or memory operand */
- unsigned reg:3; /* codes register operand (or extended opcode) */
- unsigned mode:2; /* how to interpret regmem & reg */
-} modrm_byte;
-
-/* 386 opcode byte to code indirect addressing. */
-typedef struct {
- unsigned base:3;
- unsigned index:3;
- unsigned scale:2;
-} base_index_byte;
-
-#endif /* TC_I386 */
-
-/* end of tc-i386.h */
diff --git a/gnu/usr.bin/as/config/tc-i860.c b/gnu/usr.bin/as/config/tc-i860.c
deleted file mode 100644
index be2690d..0000000
--- a/gnu/usr.bin/as/config/tc-i860.c
+++ /dev/null
@@ -1,1295 +0,0 @@
-/* tc-i860.c -- Assemble for the I860
- Copyright (C) 1989, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "as.h"
-
-#include "opcode/i860.h"
-
-void md_begin();
-void md_end();
-void md_number_to_chars();
-void md_assemble();
-char *md_atof();
-void md_convert_frag();
-void md_create_short_jump();
-void md_create_long_jump();
-int md_estimate_size_before_relax();
-void md_number_to_imm();
-void md_number_to_disp();
-void md_number_to_field();
-void md_ri_to_chars();
-static void i860_ip();
-
-const relax_typeS md_relax_table[] = { 0 };
-
-/* handle of the OPCODE hash table */
-static struct hash_control *op_hash = NULL;
-
-static void s_dual(), s_enddual();
-static void s_atmp();
-
-const pseudo_typeS
- md_pseudo_table[] = {
- { "dual", s_dual, 4 },
- { "enddual", s_enddual, 4 },
- { "atmp", s_atmp, 4 },
- { NULL, 0, 0 },
- };
-
-int md_short_jump_size = 4;
-int md_long_jump_size = 4;
-
-/* This array holds the chars that always start a comment. If the
- pre-processor is disabled, these aren't very useful */
-char comment_chars[] = "!/"; /* JF removed '|' from comment_chars */
-
-/* This array holds the chars that only start a comment at the beginning of
- a line. If the line seems to have the form '# 123 filename'
- .line and .file directives will appear in the pre-processed output */
-/* Note that input_file.c hand checks for '#' at the beginning of the
- first line of the input file. This is because the compiler outputs
- #NO_APP at the beginning of its output. */
-/* Also note that comments like this one will always work. */
-char line_comment_chars[] = "#/";
-
-/* Chars that can be used to separate mant from exp in floating point nums */
-char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant */
-/* As in 0f12.456 */
-/* or 0d1.2345e12 */
-char FLT_CHARS[] = "rRsSfFdDxXpP";
-
-/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
- changed in read.c. Ideally it shouldn't have to know about it at all,
- but nothing is ideal around here.
- */
-int size_reloc_info = sizeof(struct relocation_info);
-
-static unsigned char octal[256];
-#define isoctal(c) octal[c]
- static unsigned char toHex[256];
-
-struct i860_it {
- char *error;
- unsigned long opcode;
- struct nlist *nlistp;
- expressionS exp;
- int pcrel;
- enum expand_type expand;
- enum highlow_type highlow;
- enum reloc_type reloc;
-} the_insn;
-
-#if __STDC__ == 1
-
-#ifdef comment
-static void print_insn(struct i860_it *insn);
-#endif /* comment */
-
-static int getExpression(char *str);
-
-#else /* not __STDC__ */
-
-#ifdef comment
-static void print_insn();
-#endif /* comment */
-
-static int getExpression();
-
-#endif /* not __STDC__ */
-
-static char *expr_end;
-static char last_expand; /* error if expansion after branch */
-
-enum dual
-{
- DUAL_OFF = 0, DUAL_ON, DUAL_DDOT, DUAL_ONDDOT,
-};
-static enum dual dual_mode = DUAL_OFF; /* dual-instruction mode */
-
-static void
- s_dual() /* floating point instructions have dual set */
-{
- dual_mode = DUAL_ON;
-}
-
-static void
- s_enddual() /* floating point instructions have dual set */
-{
- dual_mode = DUAL_OFF;
-}
-
-static int atmp = 31; /* temporary register for pseudo's */
-
-static void
- s_atmp()
-{
- register int temp;
- if (strncmp(input_line_pointer, "sp", 2) == 0) {
- input_line_pointer += 2;
- atmp = 2;
- }
- else if (strncmp(input_line_pointer, "fp", 2) == 0) {
- input_line_pointer += 2;
- atmp = 3;
- }
- else if (strncmp(input_line_pointer, "r", 1) == 0) {
- input_line_pointer += 1;
- temp = get_absolute_expression();
- if (temp >= 0 && temp <= 31)
- atmp = temp;
- else
- as_bad("Unknown temporary pseudo register");
- }
- else {
- as_bad("Unknown temporary pseudo register");
- }
- demand_empty_rest_of_line();
- return;
-}
-
-/* This function is called once, at assembler startup time. It should
- set up all the tables, etc. that the MD part of the assembler will need. */
-void
- md_begin()
-{
- register char *retval = NULL;
- int lose = 0;
- register unsigned int i = 0;
-
- op_hash = hash_new();
- if (op_hash == NULL)
- as_fatal("Virtual memory exhausted");
-
- while (i < NUMOPCODES)
- {
- const char *name = i860_opcodes[i].name;
- retval = hash_insert(op_hash, name, &i860_opcodes[i]);
- if (retval != NULL && *retval != '\0')
- {
- fprintf (stderr, "internal error: can't hash `%s': %s\n",
- i860_opcodes[i].name, retval);
- lose = 1;
- }
- do
- {
- if (i860_opcodes[i].match & i860_opcodes[i].lose)
- {
- fprintf (stderr, "internal error: losing opcode: `%s' \"%s\"\n",
- i860_opcodes[i].name, i860_opcodes[i].args);
- lose = 1;
- }
- ++i;
- } while (i < NUMOPCODES
- && !strcmp(i860_opcodes[i].name, name));
- }
-
- if (lose)
- as_fatal("Broken assembler. No assembly attempted.");
-
- for (i = '0'; i < '8'; ++i)
- octal[i] = 1;
- for (i = '0'; i <= '9'; ++i)
- toHex[i] = i - '0';
- for (i = 'a'; i <= 'f'; ++i)
- toHex[i] = i + 10 - 'a';
- for (i = 'A'; i <= 'F'; ++i)
- toHex[i] = i + 10 - 'A';
-}
-
-void
- md_end()
-{
- return;
-}
-
-void
- md_assemble(str)
-char *str;
-{
- char *toP;
-/* int rsd; FIXME: remove this line. */
- int no_opcodes = 1;
- int i;
- struct i860_it pseudo[3];
-
- assert(str);
- i860_ip(str);
-
- /* check for expandable flag to produce pseudo-instructions */
- if (the_insn.expand != 0 && the_insn.highlow == NO_SPEC) {
- for (i = 0; i < 3; i++)
- pseudo[i] = the_insn;
-
- switch (the_insn.expand) {
-
- case E_DELAY:
- no_opcodes = 1;
- break;
-
- case E_MOV:
- if (the_insn.exp.X_add_symbol == NULL &&
- the_insn.exp.X_subtract_symbol == NULL &&
- (the_insn.exp.X_add_number < (1 << 15) &&
- the_insn.exp.X_add_number >= -(1 << 15)))
- break;
- /* or l%const,r0,ireg_dest */
- pseudo[0].opcode = (the_insn.opcode & 0x001f0000) | 0xe4000000;
- pseudo[0].highlow = PAIR;
- /* orh h%const,ireg_dest,ireg_dest */
- pseudo[1].opcode = (the_insn.opcode & 0x03ffffff) | 0xec000000 |
- ((the_insn.opcode & 0x001f0000) << 5);
- pseudo[1].highlow = HIGH;
- no_opcodes = 2;
- break;
-
- case E_ADDR:
- if (the_insn.exp.X_add_symbol == NULL &&
- the_insn.exp.X_subtract_symbol == NULL)
- break;
- /* orh ha%addr_expr,r0,r31 */
- pseudo[0].opcode = 0xec000000 | (atmp<<16);
- pseudo[0].highlow = HIGHADJ;
- pseudo[0].reloc = LOW0; /* must overwrite */
- /* l%addr_expr(r31),ireg_dest */
- pseudo[1].opcode = (the_insn.opcode & ~0x003e0000) | (atmp << 21);
- pseudo[1].highlow = PAIR;
- no_opcodes = 2;
- break;
-
- case E_U32: /* 2nd version emulates Intel as, not doc. */
- if (the_insn.exp.X_add_symbol == NULL &&
- the_insn.exp.X_subtract_symbol == NULL &&
- (the_insn.exp.X_add_number < (1 << 16) &&
- the_insn.exp.X_add_number >= 0))
- break;
- /* $(opcode)h h%const,ireg_src2,ireg_dest
- pseudo[0].opcode = (the_insn.opcode & 0xf3ffffff) | 0x0c000000; */
- /* $(opcode)h h%const,ireg_src2,r31 */
- pseudo[0].opcode = (the_insn.opcode & 0xf3e0ffff) | 0x0c000000 |
- (atmp << 16);
- pseudo[0].highlow = HIGH;
- /* $(opcode) l%const,ireg_dest,ireg_dest
- pseudo[1].opcode = (the_insn.opcode & 0xf01f0000) | 0x04000000 |
- ((the_insn.opcode & 0x001f0000) << 5); */
- /* $(opcode) l%const,r31,ireg_dest */
- pseudo[1].opcode = (the_insn.opcode & 0xf01f0000) | 0x04000000 |
- (atmp << 21);
- pseudo[1].highlow = PAIR;
- no_opcodes = 2;
- break;
-
- case E_AND: /* 2nd version emulates Intel as, not doc. */
- if (the_insn.exp.X_add_symbol == NULL &&
- the_insn.exp.X_subtract_symbol == NULL &&
- (the_insn.exp.X_add_number < (1 << 16) &&
- the_insn.exp.X_add_number >= 0))
- break;
- /* andnot h%const,ireg_src2,ireg_dest
- pseudo[0].opcode = (the_insn.opcode & 0x03ffffff) | 0xd4000000; */
- /* andnot h%const,ireg_src2,r31 */
- pseudo[0].opcode = (the_insn.opcode & 0x03e0ffff) | 0xd4000000 |
- (atmp << 16);
- pseudo[0].highlow = HIGH;
- pseudo[0].exp.X_add_number = -1 - the_insn.exp.X_add_number;
- /* andnot l%const,ireg_dest,ireg_dest
- pseudo[1].opcode = (the_insn.opcode & 0x001f0000) | 0xd4000000 |
- ((the_insn.opcode & 0x001f0000) << 5); */
- /* andnot l%const,r31,ireg_dest */
- pseudo[1].opcode = (the_insn.opcode & 0x001f0000) | 0xd4000000 |
- (atmp << 21);
- pseudo[1].highlow = PAIR;
- pseudo[1].exp.X_add_number = -1 - the_insn.exp.X_add_number;
- no_opcodes = 2;
- break;
-
- case E_S32:
- if (the_insn.exp.X_add_symbol == NULL &&
- the_insn.exp.X_subtract_symbol == NULL &&
- (the_insn.exp.X_add_number < (1 << 15) &&
- the_insn.exp.X_add_number >= -(1 << 15)))
- break;
- /* orh h%const,r0,r31 */
- pseudo[0].opcode = 0xec000000 | (atmp << 16);
- pseudo[0].highlow = HIGH;
- /* or l%const,r31,r31 */
- pseudo[1].opcode = 0xe4000000 | (atmp << 21) | (atmp << 16);
- pseudo[1].highlow = PAIR;
- /* r31,ireg_src2,ireg_dest */
- pseudo[2].opcode = (the_insn.opcode & ~0x0400ffff) | (atmp << 11);
- pseudo[2].reloc = NO_RELOC;
- no_opcodes = 3;
- break;
-
- default:
- as_fatal("failed sanity check.");
- }
-
- the_insn = pseudo[0];
- /* check for expanded opcode after branch or in dual */
- if (no_opcodes > 1 && last_expand == 1)
- as_warn("Expanded opcode after delayed branch: `%s'", str);
- if (no_opcodes > 1 && dual_mode != DUAL_OFF)
- as_warn("Expanded opcode in dual mode: `%s'", str);
- }
-
- i = 0;
- do { /* always produce at least one opcode */
- toP = frag_more(4);
- /* put out the opcode */
- md_number_to_chars(toP, the_insn.opcode, 4);
-
- /* check for expanded opcode after branch or in dual */
- last_expand = the_insn.pcrel;
-
- /* put out the symbol-dependent stuff */
- if (the_insn.reloc != NO_RELOC) {
- fix_new(frag_now, /* which frag */
- (toP - frag_now->fr_literal), /* where */
- 4, /* size */
- the_insn.exp.X_add_symbol,
- the_insn.exp.X_subtract_symbol,
- the_insn.exp.X_add_number,
- the_insn.pcrel,
- /* merge bit fields into one argument */
- (int)(((the_insn.highlow & 0x3) << 4) | (the_insn.reloc & 0xf)));
- }
- the_insn = pseudo[++i];
- } while (--no_opcodes > 0);
-
-}
-
-static void
- i860_ip(str)
-char *str;
-{
- char *s;
- const char *args;
- char c;
-/* unsigned long i; FIXME: remove this line. */
- struct i860_opcode *insn;
- char *argsStart;
- unsigned long opcode;
- unsigned int mask;
- int match = 0;
- int comma = 0;
-
-
- for (s = str; islower(*s) || *s == '.' || *s == '3'; ++s)
- ;
- switch (*s) {
-
- case '\0':
- break;
-
- case ',':
- comma = 1;
-
- /*FALLTHROUGH*/
-
- case ' ':
- *s++ = '\0';
- break;
-
- default:
- as_bad("Unknown opcode: `%s'", str);
- exit(1);
- }
-
- if (strncmp(str, "d.", 2) == 0) { /* check for d. opcode prefix */
- if (dual_mode == DUAL_ON)
- dual_mode = DUAL_ONDDOT;
- else
- dual_mode = DUAL_DDOT;
- str += 2;
- }
-
- if ((insn = (struct i860_opcode *) hash_find(op_hash, str)) == NULL) {
- if (dual_mode == DUAL_DDOT || dual_mode == DUAL_ONDDOT)
- str -= 2;
- as_bad("Unknown opcode: `%s'", str);
- return;
- }
- if (comma) {
- *--s = ',';
- }
- argsStart = s;
- for (;;) {
- opcode = insn->match;
- memset(&the_insn, '\0', sizeof(the_insn));
- the_insn.reloc = NO_RELOC;
-
- /*
- * Build the opcode, checking as we go to make
- * sure that the operands match
- */
- for (args = insn->args; ; ++args) {
- switch (*args) {
-
- case '\0': /* end of args */
- if (*s == '\0') {
- match = 1;
- }
- break;
-
- case '+':
- case '(': /* these must match exactly */
- case ')':
- case ',':
- case ' ':
- if (*s++ == *args)
- continue;
- break;
-
- case '#': /* must be at least one digit */
- if (isdigit(*s++)) {
- while (isdigit(*s)) {
- ++s;
- }
- continue;
- }
- break;
-
- case '1': /* next operand must be a register */
- case '2':
- case 'd':
- switch (*s) {
-
- case 'f': /* frame pointer */
- s++;
- if (*s++ == 'p') {
- mask = 0x3;
- break;
- }
- goto error;
-
- case 's': /* stack pointer */
- s++;
- if (*s++ == 'p') {
- mask= 0x2;
- break;
- }
- goto error;
-
- case 'r': /* any register */
- s++;
- if (!isdigit(c = *s++)) {
- goto error;
- }
- if (isdigit(*s)) {
- if ((c = 10 * (c - '0') + (*s++ - '0')) >= 32) {
- goto error;
- }
- } else {
- c -= '0';
- }
- mask= c;
- break;
-
- default: /* not this opcode */
- goto error;
- }
- /*
- * Got the register, now figure out where
- * it goes in the opcode.
- */
- switch (*args) {
-
- case '1':
- opcode |= mask << 11;
- continue;
-
- case '2':
- opcode |= mask << 21;
- continue;
-
- case 'd':
- opcode |= mask << 16;
- continue;
-
- }
- break;
-
- case 'e': /* next operand is a floating point register */
- case 'f':
- case 'g':
- if (*s++ == 'f' && isdigit(*s)) {
- mask = *s++;
- if (isdigit(*s)) {
- mask = 10 * (mask - '0') + (*s++ - '0');
- if (mask >= 32) {
- break;
- }
- } else {
- mask -= '0';
- }
- switch (*args) {
-
- case 'e':
- opcode |= mask << 11;
- continue;
-
- case 'f':
- opcode |= mask << 21;
- continue;
-
- case 'g':
- opcode |= mask << 16;
- if (dual_mode != DUAL_OFF)
- opcode |= (1 << 9); /* dual mode instruction */
- if (dual_mode == DUAL_DDOT)
- dual_mode = DUAL_OFF;
- if (dual_mode == DUAL_ONDDOT)
- dual_mode = DUAL_ON;
- if ((opcode & (1 << 10)) && (mask == ((opcode >> 11) & 0x1f)))
- as_warn("Fsr1 equals fdest with Pipelining");
- continue;
- }
- }
- break;
-
- case 'c': /* next operand must be a control register */
- if (strncmp(s, "fir", 3) == 0) {
- opcode |= 0x0 << 21;
- s += 3;
- continue;
- }
- if (strncmp(s, "psr", 3) == 0) {
- opcode |= 0x1 << 21;
- s += 3;
- continue;
- }
- if (strncmp(s, "dirbase", 7) == 0) {
- opcode |= 0x2 << 21;
- s += 7;
- continue;
- }
- if (strncmp(s, "db", 2) == 0) {
- opcode |= 0x3 << 21;
- s += 2;
- continue;
- }
- if (strncmp(s, "fsr", 3) == 0) {
- opcode |= 0x4 << 21;
- s += 3;
- continue;
- }
- if (strncmp(s, "epsr", 4) == 0) {
- opcode |= 0x5 << 21;
- s += 4;
- continue;
- }
- break;
-
- case '5': /* 5 bit immediate in src1 */
- memset(&the_insn, '\0', sizeof(the_insn));
- if ( !getExpression(s)) {
- s = expr_end;
- if (the_insn.exp.X_add_number & ~0x1f)
- as_bad("5-bit immediate too large");
- opcode |= (the_insn.exp.X_add_number & 0x1f) << 11;
- memset(&the_insn, '\0', sizeof(the_insn));
- the_insn.reloc = NO_RELOC;
- continue;
- }
- break;
-
- case 'l': /* 26 bit immediate, relative branch */
- the_insn.reloc = BRADDR;
- the_insn.pcrel = 1;
- goto immediate;
-
- case 's': /* 16 bit immediate, split relative branch */
- /* upper 5 bits of offset in dest field */
- the_insn.pcrel = 1;
- the_insn.reloc = SPLIT0;
- goto immediate;
-
- case 'S': /* 16 bit immediate, split (st), aligned */
- if (opcode & (1 << 28))
- if (opcode & 0x1)
- the_insn.reloc = SPLIT2;
- else
- the_insn.reloc = SPLIT1;
- else
- the_insn.reloc = SPLIT0;
- goto immediate;
-
- case 'I': /* 16 bit immediate, aligned */
- if (opcode & (1 << 28))
- if (opcode & 0x1)
- the_insn.reloc = LOW2;
- else
- the_insn.reloc = LOW1;
- else
- the_insn.reloc = LOW0;
- goto immediate;
-
- case 'i': /* 16 bit immediate */
- the_insn.reloc = LOW0;
-
- /*FALLTHROUGH*/
-
- immediate:
- if (*s == ' ')
- s++;
- if (strncmp(s, "ha%", 3) == 0) {
- the_insn.highlow = HIGHADJ;
- s += 3;
- } else if (strncmp(s, "h%", 2) == 0) {
- the_insn.highlow = HIGH;
- s += 2;
- } else if (strncmp(s, "l%", 2) == 0) {
- the_insn.highlow = PAIR;
- s += 2;
- }
- the_insn.expand = insn->expand;
-
- /* Note that if the getExpression() fails, we will still have
- created U entries in the symbol table for the 'symbols'
- in the input string. Try not to create U symbols for
- registers, etc. */
-
- if ( !getExpression(s)) {
- s = expr_end;
- continue;
- }
- break;
-
- default:
- as_fatal("failed sanity check.");
- }
- break;
- }
- error:
- if (match == 0)
- {
- /* Args don't match. */
- if (&insn[1] - i860_opcodes < NUMOPCODES
- && !strcmp(insn->name, insn[1].name))
- {
- ++insn;
- s = argsStart;
- continue;
- }
- else
- {
- as_bad("Illegal operands");
- return;
- }
- }
- break;
- }
-
- the_insn.opcode = opcode;
- return;
-}
-
-static int
- getExpression(str)
-char *str;
-{
- char *save_in;
- segT seg;
-
- save_in = input_line_pointer;
- input_line_pointer = str;
- switch (seg = expression(&the_insn.exp)) {
-
- case SEG_ABSOLUTE:
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_UNKNOWN:
- case SEG_DIFFERENCE:
- case SEG_BIG:
- case SEG_ABSENT:
- break;
-
- default:
- the_insn.error = "bad segment";
- expr_end = input_line_pointer;
- input_line_pointer=save_in;
- return 1;
- }
- expr_end = input_line_pointer;
- input_line_pointer = save_in;
- return 0;
-}
-
-
-/*
- This is identical to the md_atof in m68k.c. I think this is right,
- but I'm not sure.
-
- Turn a string in input_line_pointer into a floating point constant of type
- type, and store the appropriate bytes in *litP. The number of LITTLENUMS
- emitted is stored in *sizeP. An error message is returned, or NULL on OK.
- */
-
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
-char *
- md_atof(type,litP,sizeP)
-char type;
-char *litP;
-int *sizeP;
-{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- char *t;
- char *atof_ieee();
-
- switch (type) {
-
- case 'f':
- case 'F':
- case 's':
- case 'S':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- prec = 4;
- break;
-
- case 'x':
- case 'X':
- prec = 6;
- break;
-
- case 'p':
- case 'P':
- prec = 6;
- break;
-
- default:
- *sizeP=0;
- return "Bad call to MD_ATOF()";
- }
- t=atof_ieee(input_line_pointer,type,words);
- if (t)
- input_line_pointer=t;
- *sizeP=prec * sizeof(LITTLENUM_TYPE);
- for (wordP=words;prec--;) {
- md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE));
- litP+=sizeof(LITTLENUM_TYPE);
- }
- return ""; /* Someone should teach Dean about null pointers */
-}
-
-/*
- * Write out big-endian.
- */
-void
- md_number_to_chars(buf, val, n)
-char *buf;
-long val;
-int n;
-{
- switch (n) {
-
- case 4:
- *buf++ = val >> 24;
- *buf++ = val >> 16;
- case 2:
- *buf++ = val >> 8;
- case 1:
- *buf = val;
- break;
-
- default:
- as_fatal("failed sanity check.");
- }
- return;
-}
-
-void md_number_to_imm(buf, val, n, fixP)
-char *buf;
-long val;
-int n;
-fixS *fixP;
-{
- enum reloc_type reloc = fixP->fx_r_type & 0xf;
- enum highlow_type highlow = (fixP->fx_r_type >> 4) & 0x3;
-
- assert(buf);
- assert(n == 4); /* always on i860 */
-
- switch (highlow) {
-
- case HIGHADJ: /* adjusts the high-order 16-bits */
- if (val & (1 << 15))
- val += (1 << 16);
-
- /*FALLTHROUGH*/
-
- case HIGH: /* selects the high-order 16-bits */
- val >>= 16;
- break;
-
- case PAIR: /* selects the low-order 16-bits */
- val = val & 0xffff;
- break;
-
- default:
- break;
- }
-
- switch (reloc) {
-
- case BRADDR: /* br, call, bc, bc.t, bnc, bnc.t w/26-bit immediate */
- if (fixP->fx_pcrel != 1)
- as_bad("26-bit branch w/o pc relative set: 0x%08x", val);
- val >>= 2; /* align pcrel offset, see manual */
-
- if (val >= (1 << 25) || val < -(1 << 25)) /* check for overflow */
- as_bad("26-bit branch offset overflow: 0x%08x", val);
- buf[0] = (buf[0] & 0xfc) | ((val >> 24) & 0x3);
- buf[1] = val >> 16;
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
- case SPLIT2: /* 16 bit immediate, 4-byte aligned */
- if (val & 0x3)
- as_bad("16-bit immediate 4-byte alignment error: 0x%08x", val);
- val &= ~0x3; /* 4-byte align value */
- /*FALLTHROUGH*/
- case SPLIT1: /* 16 bit immediate, 2-byte aligned */
- if (val & 0x1)
- as_bad("16-bit immediate 2-byte alignment error: 0x%08x", val);
- val &= ~0x1; /* 2-byte align value */
- /*FALLTHROUGH*/
- case SPLIT0: /* st,bla,bte,btne w/16-bit immediate */
- if (fixP->fx_pcrel == 1)
- val >>= 2; /* align pcrel offset, see manual */
- /* check for bounds */
- if (highlow != PAIR && (val >= (1 << 16) || val < -(1 << 15)))
- as_bad("16-bit branch offset overflow: 0x%08x", val);
- buf[1] = (buf[1] & ~0x1f) | ((val >> 11) & 0x1f);
- buf[2] = (buf[2] & ~0x7) | ((val >> 8) & 0x7);
- buf[3] |= val; /* perserve bottom opcode bits */
- break;
-
- case LOW4: /* fld,pfld,pst,flush 16-byte aligned */
- if (val & 0xf)
- as_bad("16-bit immediate 16-byte alignment error: 0x%08x", val);
- val &= ~0xf; /* 16-byte align value */
- /*FALLTHROUGH*/
- case LOW3: /* fld,pfld,pst,flush 8-byte aligned */
- if (val & 0x7)
- as_bad("16-bit immediate 8-byte alignment error: 0x%08x", val);
- val &= ~0x7; /* 8-byte align value */
- /*FALLTHROUGH*/
- case LOW2: /* 16 bit immediate, 4-byte aligned */
- if (val & 0x3)
- as_bad("16-bit immediate 4-byte alignment error: 0x%08x", val);
- val &= ~0x3; /* 4-byte align value */
- /*FALLTHROUGH*/
- case LOW1: /* 16 bit immediate, 2-byte aligned */
- if (val & 0x1)
- as_bad("16-bit immediate 2-byte alignment error: 0x%08x", val);
- val &= ~0x1; /* 2-byte align value */
- /*FALLTHROUGH*/
- case LOW0: /* 16 bit immediate, byte aligned */
- /* check for bounds */
- if (highlow != PAIR && (val >= (1 << 16) || val < -(1 << 15)))
- as_bad("16-bit immediate overflow: 0x%08x", val);
- buf[2] = val >> 8;
- buf[3] |= val; /* perserve bottom opcode bits */
- break;
-
- case RELOC_32:
- md_number_to_chars(buf, val, 4);
- break;
-
- case NO_RELOC:
- default:
- as_bad("bad relocation type: 0x%02x", reloc);
- break;
- }
- return;
-}
-
-/* should never be called for i860 */
-void
- md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr, to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- as_fatal("i860_create_short_jmp\n");
-}
-
-/* should never be called for i860 */
-void
- md_number_to_disp(buf, val, n)
-char *buf;
-long val;
-int n;
-{
- as_fatal("md_number_to_disp\n");
-}
-
-/* should never be called for i860 */
-void
- md_number_to_field(buf,val,fix)
-char *buf;
-long val;
-void *fix;
-{
- as_fatal("i860_number_to_field\n");
-}
-
-/* the bit-field entries in the relocation_info struct plays hell
- with the byte-order problems of cross-assembly. So as a hack,
- I added this mach. dependent ri twiddler. Ugly, but it gets
- you there. -KWK */
-/* on i860: first 4 bytes are normal unsigned long address, next three
- bytes are index, most sig. byte first. Byte 7 is broken up with
- bit 7 as pcrel, bit 6 as extern, and the lower six bits as
- relocation type (highlow 5-4). Next 4 bytes are long addend. */
-/* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com */
-void
- md_ri_to_chars(ri_p, ri)
-struct relocation_info *ri_p, ri;
-{
-#if 0
- unsigned char the_bytes[sizeof(*ri_p)];
-
- /* this is easy */
- md_number_to_chars(the_bytes, ri.r_address, sizeof(ri.r_address));
- /* now the fun stuff */
- the_bytes[4] = (ri.r_index >> 16) & 0x0ff;
- the_bytes[5] = (ri.r_index >> 8) & 0x0ff;
- the_bytes[6] = ri.r_index & 0x0ff;
- the_bytes[7] = ((ri.r_extern << 7) & 0x80) | (0 & 0x60) | (ri.r_type & 0x1F);
- /* Also easy */
- md_number_to_chars(&the_bytes[8], ri.r_addend, sizeof(ri.r_addend));
- /* now put it back where you found it, Junior... */
- memcpy((char *) ri_p, the_bytes, sizeof(*ri_p));
-#endif
-}
-
-/* should never be called for i860 */
-void
- md_convert_frag(headers, fragP)
-object_headers *headers;
-register fragS *fragP;
-{
- as_fatal("i860_convert_frag\n");
-}
-
-/* should never be called for i860 */
-void
- md_create_long_jump(ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr,
- to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- as_fatal("i860_create_long_jump\n");
-}
-
-/* should never be called for i860 */
-int
- md_estimate_size_before_relax(fragP, segtype)
-register fragS *fragP;
-segT segtype;
-{
- as_fatal("i860_estimate_size_before_relax\n");
- return(0);
-}
-
-#ifdef comment
-/* for debugging only, must match enum reloc_type */
-static char *Reloc[] = {
- "NO_RELOC",
- "BRADDR",
- "LOW0",
- "LOW1",
- "LOW2",
- "LOW3",
- "LOW4",
- "SPLIT0",
- "SPLIT1",
- "SPLIT2",
- "RELOC_32",
-};
-static char *Highlow[] = {
- "NO_SPEC",
- "PAIR",
- "HIGH",
- "HIGHADJ",
-};
-
-static void
- print_insn(insn)
-struct i860_it *insn;
-{
- if (insn->error) {
- fprintf(stderr, "ERROR: %s\n", insn->error);
- }
- fprintf(stderr, "opcode=0x%08x\t", insn->opcode);
- fprintf(stderr, "expand=0x%08x\t", insn->expand);
- fprintf(stderr, "reloc = %s\t", Reloc[insn->reloc]);
- fprintf(stderr, "highlow = %s\n", Highlow[insn->highlow]);
- fprintf(stderr, "exp = {\n");
- fprintf(stderr, "\t\tX_add_symbol = %s\n",
- insn->exp.X_add_symbol ?
- (S_GET_NAME(insn->exp.X_add_symbol) ?
- S_GET_NAME(insn->exp.X_add_symbol) : "???") : "0");
- fprintf(stderr, "\t\tX_sub_symbol = %s\n",
- insn->exp.X_subtract_symbol ?
- (S_GET_NAME(insn->exp.X_subtract_symbol) ?
- S_GET_NAME(insn->exp.X_subtract_symbol) : "???") : "0");
- fprintf(stderr, "\t\tX_add_number = %d\n",
- insn->exp.X_add_number);
- fprintf(stderr, "}\n");
- return;
-}
-#endif /* comment */
-
-int
- md_parse_option(argP,cntP,vecP)
-char **argP;
-int *cntP;
-char ***vecP;
-{
- return 0;
-}
-
-#ifdef comment
-/*
- * I860 relocations are completely different, so it needs
- * this machine dependent routine to emit them.
- */
-void
- emit_machine_reloc(fixP, segment_address_in_file)
-register fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- struct reloc_info_i860 ri;
- register symbolS *symbolP;
- extern char *next_object_file_charP;
- long add_number;
-
- memset((char *) &ri, '\0', sizeof(ri));
- for (; fixP; fixP = fixP->fx_next) {
-
- if (fixP->fx_r_type & ~0x3f) {
- as_fatal("fixP->fx_r_type = %d\n", fixP->fx_r_type);
- }
- ri.r_pcrel = fixP->fx_pcrel;
- ri.r_type = fixP->fx_r_type;
-
- if ((symbolP = fixP->fx_addsy) != NULL) {
- ri.r_address = fixP->fx_frag->fr_address +
- fixP->fx_where - segment_address_in_file;
- if (!S_IS_DEFINED(symbolP)) {
- ri.r_extern = 1;
- ri.r_symbolnum = symbolP->sy_number;
- } else {
- ri.r_extern = 0;
- ri.r_symbolnum = S_GET_TYPE(symbolP);
- }
- if (symbolP && symbolP->sy_frag) {
- ri.r_addend = symbolP->sy_frag->fr_address;
- }
- ri.r_type = fixP->fx_r_type;
- if (fixP->fx_pcrel) {
- /* preserve actual offset vs. pc + 4 */
- ri.r_addend -= (ri.r_address + 4);
- } else {
- ri.r_addend = fixP->fx_addnumber;
- }
-
- md_ri_to_chars((char *) &ri, ri);
- append(&next_object_file_charP, (char *)& ri, sizeof(ri));
- }
- }
- return;
-}
-#endif /* comment */
-
-#ifdef OBJ_AOUT
-
-/* on i860: first 4 bytes are normal unsigned long address, next three
- bytes are index, most sig. byte first. Byte 7 is broken up with
- bit 7 as pcrel, bit 6 as extern, and the lower six bits as
- relocation type (highlow 5-4). Next 4 bytes are long addend.
-
- ie,
-
- struct reloc_info_i860 {
- unsigned long r_address;
- unsigned int r_symbolnum : 24;
- unsigned int r_pcrel : 1;
- unsigned int r_extern : 1;
- unsigned int r_type : 6;
- long r_addend;
- }
-
- */
-
-const int md_reloc_size = 12;
-
-void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
-char *where;
-fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- long r_index;
- long r_extern;
- long r_addend = 0;
- long r_address;
-
- know(fixP->fx_addsy);
- know(!(fixP->fx_r_type & ~0x3f));
-
- if (!S_IS_DEFINED(fixP->fx_addsy)) {
- r_extern = 1;
- r_index = fixP->fx_addsy->sy_number;
- } else {
- r_extern = 0;
- r_index = S_GET_TYPE(fixP->fx_addsy);
- }
-
- md_number_to_chars(where,
- r_address = fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
- 4);
-
- where[4] = (r_index >> 16) & 0x0ff;
- where[5] = (r_index >> 8) & 0x0ff;
- where[6] = r_index & 0x0ff;
- where[7] = (((fixP->fx_pcrel << 7) & 0x80)
- | ((r_extern << 6) & 0x40)
- | (fixP->fx_r_type & 0x3F));
-
- if (fixP->fx_addsy->sy_frag) {
- r_addend = fixP->fx_addsy->sy_frag->fr_address;
- }
-
- if (fixP->fx_pcrel) {
- /* preserve actual offset vs. pc + 4 */
- r_addend -= (r_address + 4);
- } else {
- r_addend = fixP->fx_addnumber;
- }
-
- md_number_to_chars(&where[8], r_addend, 4);
-
- return;
-} /* tc_aout_fix_to_chars() */
-
-#endif /* OBJ_AOUT */
-
-/* Parse an operand that is machine-specific.
- We just return without modifying the expression if we have nothing
- to do. */
-
-/* ARGSUSED */
-void
- md_operand (expressionP)
-expressionS *expressionP;
-{
-}
-
-/* We have no need to default values of symbols. */
-
-/* ARGSUSED */
-symbolS *
- md_undefined_symbol (name)
-char *name;
-{
- return 0;
-}
-
-/* Round up a section size to the appropriate boundary. */
-long
- md_section_align (segment, size)
-segT segment;
-long size;
-{
- return size; /* Byte alignment is fine */
-}
-
-/* Exactly what point is a PC-relative offset relative TO?
- On the i860, they're relative to the address of the offset, plus
- its size. (??? Is this right? FIXME-SOON!) */
-long
- md_pcrel_from (fixP)
-fixS *fixP;
-{
- return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
-}
-
-void
- md_apply_fix(fixP, val)
-fixS *fixP;
-long val;
-{
- char *place = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- /* fixme-soon: looks to me like i860 never has bit fixes. Let's see. xoxorich. */
- know(fixP->fx_bit_fixP == NULL);
- if (!fixP->fx_bit_fixP) {
-
- /* fixme-soon: also looks like fx_im_disp is always 0. Let's see. xoxorich. */
- know(fixP->fx_im_disp == 0);
- switch (fixP->fx_im_disp) {
- case 0:
- fixP->fx_addnumber = val;
- md_number_to_imm(place, val, fixP->fx_size, fixP);
- break;
- case 1:
- md_number_to_disp(place,
- fixP->fx_pcrel ? val + fixP->fx_pcrel_adjust : val,
- fixP->fx_size);
- break;
- case 2: /* fix requested for .long .word etc */
- md_number_to_chars(place, val, fixP->fx_size);
- break;
- default:
- as_fatal("Internal error in md_apply_fix() in file \"%s\"", __FILE__);
- } /* OVE: maybe one ought to put _imm _disp _chars in one md-func */
- } else {
- md_number_to_field(place, val, fixP->fx_bit_fixP);
- }
-
- return;
-} /* md_apply_fix() */
-
-/*
- * Local Variables:
- * fill-column: 131
- * comment-column: 0
- * End:
- */
-
-/* end of tc-i860.c */
diff --git a/gnu/usr.bin/as/config/tc-i860.h b/gnu/usr.bin/as/config/tc-i860.h
deleted file mode 100644
index adc0d8f..0000000
--- a/gnu/usr.bin/as/config/tc-i860.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * This file is tc-i860.h.
- */
-
-#define TC_I860 1
-
-#define NO_LISTING
-
-#ifdef OLD_GAS
-#define REVERSE_SORT_RELOCS
-#endif /* OLD_GAS */
-
-#define tc_headers_hook(a) {;} /* not used */
-#define tc_crawl_symbol_chain(a) {;} /* not used */
-#define tc_aout_pre_write_hook(x) {;} /* not used */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-i860.h */
diff --git a/gnu/usr.bin/as/config/tc-i960.c b/gnu/usr.bin/as/config/tc-i960.c
deleted file mode 100644
index 5a3c8ca..0000000
--- a/gnu/usr.bin/as/config/tc-i960.c
+++ /dev/null
@@ -1,2759 +0,0 @@
-/* tc-i960.c - All the i80960-specific stuff
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* See comment on md_parse_option for 80960-specific invocation options. */
-
-/******************************************************************************
- * i80690 NOTE!!!:
- * Header, symbol, and relocation info will be used on the host machine
- * only -- only executable code is actually downloaded to the i80960.
- * Therefore, leave all such information in host byte order.
- *
- * (That's a slight lie -- we DO download some header information, but
- * the downloader converts the file format and corrects the byte-ordering
- * of the relevant fields while doing so.)
- *
- ***************************************************************************** */
-
-/* There are 4 different lengths of (potentially) symbol-based displacements
- * in the 80960 instruction set, each of which could require address fix-ups
- * and (in the case of external symbols) emission of relocation directives:
- *
- * 32-bit (MEMB)
- * This is a standard length for the base assembler and requires no
- * special action.
- *
- * 13-bit (COBR)
- * This is a non-standard length, but the base assembler has a hook for
- * bit field address fixups: the fixS structure can point to a descriptor
- * of the field, in which case our md_number_to_field() routine gets called
- * to process it.
- *
- * I made the hook a little cleaner by having fix_new() (in the base
- * assembler) return a pointer to the fixS in question. And I made it a
- * little simpler by storing the field size (in this case 13) instead of
- * of a pointer to another structure: 80960 displacements are ALWAYS
- * stored in the low-order bits of a 4-byte word.
- *
- * Since the target of a COBR cannot be external, no relocation directives
- * for this size displacement have to be generated. But the base assembler
- * had to be modified to issue error messages if the symbol did turn out
- * to be external.
- *
- * 24-bit (CTRL)
- * Fixups are handled as for the 13-bit case (except that 24 is stored
- * in the fixS).
- *
- * The relocation directive generated is the same as that for the 32-bit
- * displacement, except that it's PC-relative (the 32-bit displacement
- * never is). The i80960 version of the linker needs a mod to
- * distinguish and handle the 24-bit case.
- *
- * 12-bit (MEMA)
- * MEMA formats are always promoted to MEMB (32-bit) if the displacement
- * is based on a symbol, because it could be relocated at link time.
- * The only time we use the 12-bit format is if an absolute value of
- * less than 4096 is specified, in which case we need neither a fixup nor
- * a relocation directive.
- */
-
-#include <stdio.h>
-#include <ctype.h>
-
-#include "as.h"
-
-#include "obstack.h"
-
-#include "opcode/i960.h"
-
-extern char *input_line_pointer;
-extern struct hash_control *po_hash;
-extern char *next_object_file_charP;
-
-#ifdef OBJ_COFF
-const int md_reloc_size = sizeof(struct reloc);
-#else /* OBJ_COFF */
-const int md_reloc_size = sizeof(struct relocation_info);
-#endif /* OBJ_COFF */
-
-/***************************
- * Local i80960 routines *
- ************************** */
-
-static void brcnt_emit(); /* Emit branch-prediction instrumentation code */
-static char * brlab_next(); /* Return next branch local label */
-void brtab_emit(); /* Emit br-predict instrumentation table */
-static void cobr_fmt(); /* Generate COBR instruction */
-static void ctrl_fmt(); /* Generate CTRL instruction */
-static char * emit(); /* Emit (internally) binary */
-static int get_args(); /* Break arguments out of comma-separated list */
-static void get_cdisp(); /* Handle COBR or CTRL displacement */
-static char * get_ispec(); /* Find index specification string */
-static int get_regnum(); /* Translate text to register number */
-static int i_scan(); /* Lexical scan of instruction source */
-static void mem_fmt(); /* Generate MEMA or MEMB instruction */
-static void mema_to_memb(); /* Convert MEMA instruction to MEMB format */
-static segT parse_expr(); /* Parse an expression */
-static int parse_ldconst();/* Parse and replace a 'ldconst' pseudo-op */
-static void parse_memop(); /* Parse a memory operand */
-static void parse_po(); /* Parse machine-dependent pseudo-op */
-static void parse_regop(); /* Parse a register operand */
-static void reg_fmt(); /* Generate a REG format instruction */
-void reloc_callj(); /* Relocate a 'callj' instruction */
-static void relax_cobr(); /* "De-optimize" cobr into compare/branch */
-static void s_leafproc(); /* Process '.leafproc' pseudo-op */
-static void s_sysproc(); /* Process '.sysproc' pseudo-op */
-static int shift_ok(); /* Will a 'shlo' substiture for a 'ldconst'? */
-static void syntax(); /* Give syntax error */
-static int targ_has_sfr(); /* Target chip supports spec-func register? */
-static int targ_has_iclass();/* Target chip supports instruction set? */
-/* static void unlink_sym(); */ /* Remove a symbol from the symbol list */
-
-/* See md_parse_option() for meanings of these options */
-static char norelax = 0; /* True if -norelax switch seen */
-static char instrument_branches = 0; /* True if -b switch seen */
-
-/* Characters that always start a comment.
- * If the pre-processor is disabled, these aren't very useful.
- */
-char comment_chars[] = "#";
-
-/* Characters that only start a comment at the beginning of
- * a line. If the line seems to have the form '# 123 filename'
- * .line and .file directives will appear in the pre-processed output.
- *
- * Note that input_file.c hand checks for '#' at the beginning of the
- * first line of the input file. This is because the compiler outputs
- * #NO_APP at the beginning of its output.
- */
-
-/* Also note that comments started like this one will always work. */
-
-char line_comment_chars[] = "";
-
-/* Chars that can be used to separate mant from exp in floating point nums */
-char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant,
- * as in 0f12.456 or 0d1.2345e12
- */
-char FLT_CHARS[] = "fFdDtT";
-
-
-/* Table used by base assembler to relax addresses based on varying length
- * instructions. The fields are:
- * 1) most positive reach of this state,
- * 2) most negative reach of this state,
- * 3) how many bytes this mode will add to the size of the current frag
- * 4) which index into the table to try if we can't fit into this one.
- *
- * For i80960, the only application is the (de-)optimization of cobr
- * instructions into separate compare and branch instructions when a 13-bit
- * displacement won't hack it.
- */
-const relax_typeS
- md_relax_table[] = {
- {0, 0, 0,0}, /* State 0 => no more relaxation possible */
- {4088, -4096, 0,2}, /* State 1: conditional branch (cobr) */
- {0x800000-8,-0x800000,4,0}, /* State 2: compare (reg) & branch (ctrl) */
- };
-
-
-/* These are the machine dependent pseudo-ops.
- *
- * This table describes all the machine specific pseudo-ops the assembler
- * has to support. The fields are:
- * pseudo-op name without dot
- * function to call to execute this pseudo-op
- * integer arg to pass to the function
- */
-#define S_LEAFPROC 1
-#define S_SYSPROC 2
-
-const pseudo_typeS
- md_pseudo_table[] = {
-
- { "bss", s_lcomm, 1 },
- { "extended", float_cons, 't' },
- { "leafproc", parse_po, S_LEAFPROC },
- { "sysproc", parse_po, S_SYSPROC },
-
- { "word", cons, 4 },
- { "quad", big_cons, 16 },
-
- { 0, 0, 0 }
- };
-
-/* Macros to extract info from an 'expressionS' structure 'e' */
-#define adds(e) e.X_add_symbol
-#define subs(e) e.X_subtract_symbol
-#define offs(e) e.X_add_number
-#define segs(e) e.X_seg
-
-
- /* Branch-prediction bits for CTRL/COBR format opcodes */
-#define BP_MASK 0x00000002 /* Mask for branch-prediction bit */
-#define BP_TAKEN 0x00000000 /* Value to OR in to predict branch */
-#define BP_NOT_TAKEN 0x00000002 /* Value to OR in to predict no branch */
-
-
- /* Some instruction opcodes that we need explicitly */
-#define BE 0x12000000
-#define BG 0x11000000
-#define BGE 0x13000000
-#define BL 0x14000000
-#define BLE 0x16000000
-#define BNE 0x15000000
-#define BNO 0x10000000
-#define BO 0x17000000
-#define CHKBIT 0x5a002700
-#define CMPI 0x5a002080
-#define CMPO 0x5a002000
-
-#define B 0x08000000
-#define BAL 0x0b000000
-#define CALL 0x09000000
-#define CALLS 0x66003800
-#define RET 0x0a000000
-
-
- /* These masks are used to build up a set of MEMB mode bits. */
-#define A_BIT 0x0400
-#define I_BIT 0x0800
-#define MEMB_BIT 0x1000
-#define D_BIT 0x2000
-
-
- /* Mask for the only mode bit in a MEMA instruction (if set, abase reg is used) */
-#define MEMA_ABASE 0x2000
-
- /* Info from which a MEMA or MEMB format instruction can be generated */
- typedef struct {
- long opcode; /* (First) 32 bits of instruction */
- int disp; /* 0-(none), 12- or, 32-bit displacement needed */
- char *e; /* The expression in the source instruction from
- * which the displacement should be determined
- */
- } memS;
-
-
-/* The two pieces of info we need to generate a register operand */
-struct regop {
- int mode; /* 0 =>local/global/spec reg; 1=> literal or fp reg */
- int special; /* 0 =>not a sfr; 1=> is a sfr (not valid w/mode=0) */
- int n; /* Register number or literal value */
-};
-
-
-/* Number and assembler mnemonic for all registers that can appear in operands */
-static struct {
- char *reg_name;
- int reg_num;
-} regnames[] = {
- { "pfp", 0 }, { "sp", 1 }, { "rip", 2 }, { "r3", 3 },
- { "r4", 4 }, { "r5", 5 }, { "r6", 6 }, { "r7", 7 },
- { "r8", 8 }, { "r9", 9 }, { "r10", 10 }, { "r11", 11 },
- { "r12", 12 }, { "r13", 13 }, { "r14", 14 }, { "r15", 15 },
- { "g0", 16 }, { "g1", 17 }, { "g2", 18 }, { "g3", 19 },
- { "g4", 20 }, { "g5", 21 }, { "g6", 22 }, { "g7", 23 },
- { "g8", 24 }, { "g9", 25 }, { "g10", 26 }, { "g11", 27 },
- { "g12", 28 }, { "g13", 29 }, { "g14", 30 }, { "fp", 31 },
-
- /* Numbers for special-function registers are for assembler internal
- * use only: they are scaled back to range [0-31] for binary output.
- */
-# define SF0 32
-
- { "sf0", 32 }, { "sf1", 33 }, { "sf2", 34 }, { "sf3", 35 },
- { "sf4", 36 }, { "sf5", 37 }, { "sf6", 38 }, { "sf7", 39 },
- { "sf8", 40 }, { "sf9", 41 }, { "sf10",42 }, { "sf11",43 },
- { "sf12",44 }, { "sf13",45 }, { "sf14",46 }, { "sf15",47 },
- { "sf16",48 }, { "sf17",49 }, { "sf18",50 }, { "sf19",51 },
- { "sf20",52 }, { "sf21",53 }, { "sf22",54 }, { "sf23",55 },
- { "sf24",56 }, { "sf25",57 }, { "sf26",58 }, { "sf27",59 },
- { "sf28",60 }, { "sf29",61 }, { "sf30",62 }, { "sf31",63 },
-
- /* Numbers for floating point registers are for assembler internal use
- * only: they are scaled back to [0-3] for binary output.
- */
-# define FP0 64
-
- { "fp0", 64 }, { "fp1", 65 }, { "fp2", 66 }, { "fp3", 67 },
-
- { NULL, 0 }, /* END OF LIST */
-};
-
-#define IS_RG_REG(n) ((0 <= (n)) && ((n) < SF0))
-#define IS_SF_REG(n) ((SF0 <= (n)) && ((n) < FP0))
-#define IS_FP_REG(n) ((n) >= FP0)
-
-/* Number and assembler mnemonic for all registers that can appear as 'abase'
- * (indirect addressing) registers.
- */
-static struct {
- char *areg_name;
- int areg_num;
-} aregs[] = {
- { "(pfp)", 0 }, { "(sp)", 1 }, { "(rip)", 2 }, { "(r3)", 3 },
- { "(r4)", 4 }, { "(r5)", 5 }, { "(r6)", 6 }, { "(r7)", 7 },
- { "(r8)", 8 }, { "(r9)", 9 }, { "(r10)", 10 }, { "(r11)", 11 },
- { "(r12)", 12 }, { "(r13)", 13 }, { "(r14)", 14 }, { "(r15)", 15 },
- { "(g0)", 16 }, { "(g1)", 17 }, { "(g2)", 18 }, { "(g3)", 19 },
- { "(g4)", 20 }, { "(g5)", 21 }, { "(g6)", 22 }, { "(g7)", 23 },
- { "(g8)", 24 }, { "(g9)", 25 }, { "(g10)", 26 }, { "(g11)", 27 },
- { "(g12)", 28 }, { "(g13)", 29 }, { "(g14)", 30 }, { "(fp)", 31 },
-
-# define IPREL 32
- /* for assembler internal use only: this number never appears in binary
- * output.
- */
- { "(ip)", IPREL },
-
- { NULL, 0 }, /* END OF LIST */
-};
-
-
-/* Hash tables */
-static struct hash_control *op_hash = NULL; /* Opcode mnemonics */
-static struct hash_control *reg_hash = NULL; /* Register name hash table */
-static struct hash_control *areg_hash = NULL; /* Abase register hash table */
-
-
-/* Architecture for which we are assembling */
-#define ARCH_ANY 0 /* Default: no architecture checking done */
-#define ARCH_KA 1
-#define ARCH_KB 2
-#define ARCH_MC 3
-#define ARCH_CA 4
-int architecture = ARCH_ANY; /* Architecture requested on invocation line */
-int iclasses_seen = 0; /* OR of instruction classes (I_* constants)
- * for which we've actually assembled
- * instructions.
- */
-
-
-/* BRANCH-PREDICTION INSTRUMENTATION
- *
- * The following supports generation of branch-prediction instrumentation
- * (turned on by -b switch). The instrumentation collects counts
- * of branches taken/not-taken for later input to a utility that will
- * set the branch prediction bits of the instructions in accordance with
- * the behavior observed. (Note that the KX series does not have
- * brach-prediction.)
- *
- * The instrumentation consists of:
- *
- * (1) before and after each conditional branch, a call to an external
- * routine that increments and steps over an inline counter. The
- * counter itself, initialized to 0, immediately follows the call
- * instruction. For each branch, the counter following the branch
- * is the number of times the branch was not taken, and the difference
- * between the counters is the number of times it was taken. An
- * example of an instrumented conditional branch:
- *
- * call BR_CNT_FUNC
- * .word 0
- * LBRANCH23: be label
- * call BR_CNT_FUNC
- * .word 0
- *
- * (2) a table of pointers to the instrumented branches, so that an
- * external postprocessing routine can locate all of the counters.
- * the table begins with a 2-word header: a pointer to the next in
- * a linked list of such tables (initialized to 0); and a count
- * of the number of entries in the table (exclusive of the header.
- *
- * Note that input source code is expected to already contain calls
- * an external routine that will link the branch local table into a
- * list of such tables.
- */
-
-static int br_cnt = 0; /* Number of branches instrumented so far.
- * Also used to generate unique local labels
- * for each instrumented branch
- */
-
-#define BR_LABEL_BASE "LBRANCH"
-/* Basename of local labels on instrumented
- * branches, to avoid conflict with compiler-
- * generated local labels.
- */
-
-#define BR_CNT_FUNC "__inc_branch"
-/* Name of the external routine that will
- * increment (and step over) an inline counter.
- */
-
-#define BR_TAB_NAME "__BRANCH_TABLE__"
-/* Name of the table of pointers to branches.
- * A local (i.e., non-external) symbol.
- */
-
-/*****************************************************************************
- * md_begin: One-time initialization.
- *
- * Set up hash tables.
- *
- **************************************************************************** */
-void
- md_begin()
-{
- int i; /* Loop counter */
- const struct i960_opcode *oP; /* Pointer into opcode table */
- char *retval; /* Value returned by hash functions */
-
- if (((op_hash = hash_new()) == 0)
- || ((reg_hash = hash_new()) == 0)
- || ((areg_hash = hash_new()) == 0)) {
- as_fatal("virtual memory exceeded");
- }
-
- retval = ""; /* For some reason, the base assembler uses an empty
- * string for "no error message", instead of a NULL
- * pointer.
- */
-
- for (oP=i960_opcodes; oP->name && !*retval; oP++) {
- retval = hash_insert(op_hash, oP->name, oP);
- }
-
- for (i=0; regnames[i].reg_name && !*retval; i++) {
- retval = hash_insert(reg_hash, regnames[i].reg_name,
- &regnames[i].reg_num);
- }
-
- for (i=0; aregs[i].areg_name && !*retval; i++){
- retval = hash_insert(areg_hash, aregs[i].areg_name,
- &aregs[i].areg_num);
- }
-
- if (*retval) {
- as_fatal("Hashing returned \"%s\".", retval);
- }
-} /* md_begin() */
-
-/*****************************************************************************
- * md_end: One-time final cleanup
- *
- * None necessary
- *
- **************************************************************************** */
-void
- md_end()
-{
-}
-
-/*****************************************************************************
- * md_assemble: Assemble an instruction
- *
- * Assumptions about the passed-in text:
- * - all comments, labels removed
- * - text is an instruction
- * - all white space compressed to single blanks
- * - all character constants have been replaced with decimal
- *
- **************************************************************************** */
-void
- md_assemble(textP)
-char *textP; /* Source text of instruction */
-{
- char *args[4]; /* Parsed instruction text, containing NO whitespace:
- * arg[0]->opcode mnemonic
- * arg[1-3]->operands, with char constants
- * replaced by decimal numbers
- */
- int n_ops; /* Number of instruction operands */
-
- struct i960_opcode *oP;
- /* Pointer to instruction description */
- int branch_predict;
- /* TRUE iff opcode mnemonic included branch-prediction
- * suffix (".f" or ".t")
- */
- long bp_bits; /* Setting of branch-prediction bit(s) to be OR'd
- * into instruction opcode of CTRL/COBR format
- * instructions.
- */
- int n; /* Offset of last character in opcode mnemonic */
-
- static const char bp_error_msg[] = "branch prediction invalid on this opcode";
-
-
- /* Parse instruction into opcode and operands */
- memset(args, '\0', sizeof(args));
- n_ops = i_scan(textP, args);
- if (n_ops == -1){
- return; /* Error message already issued */
- }
-
- /* Do "macro substitution" (sort of) on 'ldconst' pseudo-instruction */
- if (!strcmp(args[0],"ldconst")){
- n_ops = parse_ldconst(args);
- if (n_ops == -1){
- return;
- }
- }
-
- /* Check for branch-prediction suffix on opcode mnemonic, strip it off */
- n = strlen(args[0]) - 1;
- branch_predict = 0;
- bp_bits = 0;
- if (args[0][n-1] == '.' && (args[0][n] == 't' || args[0][n] == 'f')){
- /* We could check here to see if the target architecture
- * supports branch prediction, but why bother? The bit
- * will just be ignored by processors that don't use it.
- */
- branch_predict = 1;
- bp_bits = (args[0][n] == 't') ? BP_TAKEN : BP_NOT_TAKEN;
- args[0][n-1] = '\0'; /* Strip suffix from opcode mnemonic */
- }
-
- /* Look up opcode mnemonic in table and check number of operands.
- * Check that opcode is legal for the target architecture.
- * If all looks good, assemble instruction.
- */
- oP = (struct i960_opcode *) hash_find(op_hash, args[0]);
- if (!oP || !targ_has_iclass(oP->iclass)) {
- as_bad("invalid opcode, \"%s\".", args[0]);
-
- } else if (n_ops != oP->num_ops) {
- as_bad("improper number of operands. expecting %d, got %d", oP->num_ops, n_ops);
-
- } else {
- switch (oP->format){
- case FBRA:
- case CTRL:
- ctrl_fmt(args[1], oP->opcode | bp_bits, oP->num_ops);
- if (oP->format == FBRA){
- /* Now generate a 'bno' to same arg */
- ctrl_fmt(args[1], BNO | bp_bits, 1);
- }
- break;
- case COBR:
- case COJ:
- cobr_fmt(args, oP->opcode | bp_bits, oP);
- break;
- case REG:
- if (branch_predict){
- as_warn(bp_error_msg);
- }
- reg_fmt(args, oP);
- break;
- case MEM1:
- case MEM2:
- case MEM4:
- case MEM8:
- case MEM12:
- case MEM16:
- if (branch_predict){
- as_warn(bp_error_msg);
- }
- mem_fmt(args, oP);
- break;
- case CALLJ:
- if (branch_predict){
- as_warn(bp_error_msg);
- }
- /* Output opcode & set up "fixup" (relocation);
- * flag relocation as 'callj' type.
- */
- know(oP->num_ops == 1);
- get_cdisp(args[1], "CTRL", oP->opcode, 24, 0, 1);
- break;
- default:
- BAD_CASE(oP->format);
- break;
- }
- }
-} /* md_assemble() */
-
-/*****************************************************************************
- * md_number_to_chars: convert a number to target byte order
- *
- **************************************************************************** */
-void
- md_number_to_chars(buf, value, n)
-char *buf; /* Put output here */
-long value; /* The integer to be converted */
-int n; /* Number of bytes to output (significant bytes
- * in 'value')
- */
-{
- while (n--){
- *buf++ = value;
- value >>= 8;
- }
-
- /* XXX line number probably botched for this warning message. */
- if (value != 0 && value != -1){
- as_bad("Displacement too long for instruction field length.");
- }
-
- return;
-} /* md_number_to_chars() */
-
-/*****************************************************************************
- * md_chars_to_number: convert from target byte order to host byte order.
- *
- **************************************************************************** */
-int
- md_chars_to_number(val, n)
-unsigned char *val; /* Value in target byte order */
-int n; /* Number of bytes in the input */
-{
- int retval;
-
- for (retval=0; n--;){
- retval <<= 8;
- retval |= val[n];
- }
- return retval;
-}
-
-
-#define MAX_LITTLENUMS 6
-#define LNUM_SIZE sizeof(LITTLENUM_TYPE)
-
-/*****************************************************************************
- * md_atof: convert ascii to floating point
- *
- * Turn a string at input_line_pointer into a floating point constant of type
- * 'type', and store the appropriate bytes at *litP. The number of LITTLENUMS
- * emitted is returned at 'sizeP'. An error message is returned, or a pointer
- * to an empty message if OK.
- *
- * Note we call the i386 floating point routine, rather than complicating
- * things with more files or symbolic links.
- *
- **************************************************************************** */
-char * md_atof(type, litP, sizeP)
-int type;
-char *litP;
-int *sizeP;
-{
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- int prec;
- char *t;
- char *atof_ieee();
-
- switch (type) {
- case 'f':
- case 'F':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- prec = 4;
- break;
-
- case 't':
- case 'T':
- prec = 5;
- type = 'x'; /* That's what atof_ieee() understands */
- break;
-
- default:
- *sizeP=0;
- return "Bad call to md_atof()";
- }
-
- t = atof_ieee(input_line_pointer, type, words);
- if (t){
- input_line_pointer = t;
- }
-
- *sizeP = prec * LNUM_SIZE;
-
- /* Output the LITTLENUMs in REVERSE order in accord with i80960
- * word-order. (Dunno why atof_ieee doesn't do it in the right
- * order in the first place -- probably because it's a hack of
- * atof_m68k.)
- */
-
- for (wordP = words + prec - 1; prec--;){
- md_number_to_chars(litP, (long) (*wordP--), LNUM_SIZE);
- litP += sizeof(LITTLENUM_TYPE);
- }
-
- return ""; /* Someone should teach Dean about null pointers */
-}
-
-
-/*****************************************************************************
- * md_number_to_imm
- *
- **************************************************************************** */
-void
- md_number_to_imm(buf, val, n)
-char *buf;
-long val;
-int n;
-{
- md_number_to_chars(buf, val, n);
-}
-
-
-/*****************************************************************************
- * md_number_to_disp
- *
- **************************************************************************** */
-void
- md_number_to_disp(buf, val, n)
-char *buf;
-long val;
-int n;
-{
- md_number_to_chars(buf, val, n);
-}
-
-/*****************************************************************************
- * md_number_to_field:
- *
- * Stick a value (an address fixup) into a bit field of
- * previously-generated instruction.
- *
- **************************************************************************** */
-void
- md_number_to_field(instrP, val, bfixP)
-char *instrP; /* Pointer to instruction to be fixed */
-long val; /* Address fixup value */
-bit_fixS *bfixP; /* Description of bit field to be fixed up */
-{
- int numbits; /* Length of bit field to be fixed */
- long instr; /* 32-bit instruction to be fixed-up */
- long sign; /* 0 or -1, according to sign bit of 'val' */
-
- /* Convert instruction back to host byte order
- */
- instr = md_chars_to_number(instrP, 4);
-
- /* Surprise! -- we stored the number of bits
- * to be modified rather than a pointer to a structure.
- */
- numbits = (int)bfixP;
- if (numbits == 1){
- /* This is a no-op, stuck here by reloc_callj() */
- return;
- }
-
- know ((numbits == 13) || (numbits == 24));
-
- /* Propagate sign bit of 'val' for the given number of bits.
- * Result should be all 0 or all 1
- */
- sign = val >> ((int)numbits - 1);
- if (((val < 0) && (sign != -1))
- || ((val > 0) && (sign != 0))){
- as_bad("Fixup of %d too large for field width of %d",
- val, numbits);
- } else {
- /* Put bit field into instruction and write back in target
- * byte order.
- */
- val &= ~(-1 << (int)numbits); /* Clear unused sign bits */
- instr |= val;
- md_number_to_chars(instrP, instr, 4);
- }
-} /* md_number_to_field() */
-
-
-/*****************************************************************************
- * md_parse_option
- * Invocation line includes a switch not recognized by the base assembler.
- * See if it's a processor-specific option. For the 960, these are:
- *
- * -norelax:
- * Conditional branch instructions that require displacements
- * greater than 13 bits (or that have external targets) should
- * generate errors. The default is to replace each such
- * instruction with the corresponding compare (or chkbit) and
- * branch instructions. Note that the Intel "j" cobr directives
- * are ALWAYS "de-optimized" in this way when necessary,
- * regardless of the setting of this option.
- *
- * -b:
- * Add code to collect information about branches taken, for
- * later optimization of branch prediction bits by a separate
- * tool. COBR and CNTL format instructions have branch
- * prediction bits (in the CX architecture); if "BR" represents
- * an instruction in one of these classes, the following rep-
- * resents the code generated by the assembler:
- *
- * call <increment routine>
- * .word 0 # pre-counter
- * Label: BR
- * call <increment routine>
- * .word 0 # post-counter
- *
- * A table of all such "Labels" is also generated.
- *
- *
- * -AKA, -AKB, -AKC, -ASA, -ASB, -AMC, -ACA:
- * Select the 80960 architecture. Instructions or features not
- * supported by the selected architecture cause fatal errors.
- * The default is to generate code for any instruction or feature
- * that is supported by SOME version of the 960 (even if this
- * means mixing architectures!).
- *
- **************************************************************************** */
-int
- md_parse_option(argP, cntP, vecP)
-char **argP;
-int *cntP;
-char ***vecP;
-{
- char *p;
- struct tabentry { char *flag; int arch; };
- static struct tabentry arch_tab[] = {
- "KA", ARCH_KA,
- "KB", ARCH_KB,
- "SA", ARCH_KA, /* Synonym for KA */
- "SB", ARCH_KB, /* Synonym for KB */
- "KC", ARCH_MC, /* Synonym for MC */
- "MC", ARCH_MC,
- "CA", ARCH_CA,
- NULL, 0
- };
- struct tabentry *tp;
-
- if (!strcmp(*argP,"norelax")){
- norelax = 1;
-
- } else if (**argP == 'b'){
- instrument_branches = 1;
-
- } else if (**argP == 'A'){
- p = (*argP) + 1;
-
- for (tp = arch_tab; tp->flag != NULL; tp++){
- if (!strcmp(p,tp->flag)){
- break;
- }
- }
-
- if (tp->flag == NULL){
- as_bad("unknown architecture: %s", p);
- } else {
- architecture = tp->arch;
- }
- } else {
- /* Unknown option */
- (*argP)++;
- return 0;
- }
- **argP = '\0'; /* Done parsing this switch */
- return 1;
-}
-
-/*****************************************************************************
- * md_convert_frag:
- * Called by base assembler after address relaxation is finished: modify
- * variable fragments according to how much relaxation was done.
- *
- * If the fragment substate is still 1, a 13-bit displacement was enough
- * to reach the symbol in question. Set up an address fixup, but otherwise
- * leave the cobr instruction alone.
- *
- * If the fragment substate is 2, a 13-bit displacement was not enough.
- * Replace the cobr with a two instructions (a compare and a branch).
- *
- **************************************************************************** */
-void
- md_convert_frag(headers, fragP)
-object_headers *headers;
-fragS * fragP;
-{
- fixS *fixP; /* Structure describing needed address fix */
-
- switch (fragP->fr_subtype){
- case 1:
- /* LEAVE SINGLE COBR INSTRUCTION */
- fixP = fix_new(fragP,
- fragP->fr_opcode-fragP->fr_literal,
- 4,
- fragP->fr_symbol,
- 0,
- fragP->fr_offset,
- 1,
- 0);
-
- fixP->fx_bit_fixP = (bit_fixS *) 13; /* size of bit field */
- break;
- case 2:
- /* REPLACE COBR WITH COMPARE/BRANCH INSTRUCTIONS */
- relax_cobr(fragP);
- break;
- default:
- BAD_CASE(fragP->fr_subtype);
- break;
- }
-}
-
-/*****************************************************************************
- * md_estimate_size_before_relax: How much does it look like *fragP will grow?
- *
- * Called by base assembler just before address relaxation.
- * Return the amount by which the fragment will grow.
- *
- * Any symbol that is now undefined will not become defined; cobr's
- * based on undefined symbols will have to be replaced with a compare
- * instruction and a branch instruction, and the code fragment will grow
- * by 4 bytes.
- *
- **************************************************************************** */
-int
- md_estimate_size_before_relax(fragP, segment_type)
-register fragS *fragP;
-register segT segment_type;
-{
- /* If symbol is undefined in this segment, go to "relaxed" state
- * (compare and branch instructions instead of cobr) right now.
- */
- if (S_GET_SEGMENT(fragP->fr_symbol) != segment_type) {
- relax_cobr(fragP);
- return 4;
- }
- return 0;
-} /* md_estimate_size_before_relax() */
-
-
-/*****************************************************************************
- * md_ri_to_chars:
- * This routine exists in order to overcome machine byte-order problems
- * when dealing with bit-field entries in the relocation_info struct.
- *
- * But relocation info will be used on the host machine only (only
- * executable code is actually downloaded to the i80960). Therefore,
- * we leave it in host byte order.
- *
- **************************************************************************** */
-void md_ri_to_chars(where, ri)
-char *where;
-struct relocation_info *ri;
-{
- *((struct relocation_info *) where) = *ri; /* structure assignment */
-} /* md_ri_to_chars() */
-
-#ifndef WORKING_DOT_WORD
-
-int md_short_jump_size = 0;
-int md_long_jump_size = 0;
-
-void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr;
-long to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- as_fatal("failed sanity check.");
-}
-
-void
- md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol)
-char *ptr;
-long from_addr, to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- as_fatal("failed sanity check.");
-}
-#endif
-
-/*************************************************************
- * *
- * FOLLOWING ARE THE LOCAL ROUTINES, IN ALPHABETICAL ORDER *
- * *
- ************************************************************ */
-
-
-
-/*****************************************************************************
- * brcnt_emit: Emit code to increment inline branch counter.
- *
- * See the comments above the declaration of 'br_cnt' for details on
- * branch-prediction instrumentation.
- **************************************************************************** */
-static void
- brcnt_emit()
-{
- ctrl_fmt(BR_CNT_FUNC,CALL,1);/* Emit call to "increment" routine */
- emit(0); /* Emit inline counter to be incremented */
-}
-
-/*****************************************************************************
- * brlab_next: generate the next branch local label
- *
- * See the comments above the declaration of 'br_cnt' for details on
- * branch-prediction instrumentation.
- **************************************************************************** */
-static char *
- brlab_next()
-{
- static char buf[20];
-
- sprintf(buf, "%s%d", BR_LABEL_BASE, br_cnt++);
- return buf;
-}
-
-/*****************************************************************************
- * brtab_emit: generate the fetch-prediction branch table.
- *
- * See the comments above the declaration of 'br_cnt' for details on
- * branch-prediction instrumentation.
- *
- * The code emitted here would be functionally equivalent to the following
- * example assembler source.
- *
- * .data
- * .align 2
- * BR_TAB_NAME:
- * .word 0 # link to next table
- * .word 3 # length of table
- * .word LBRANCH0 # 1st entry in table proper
- * .word LBRANCH1
- * .word LBRANCH2
- ***************************************************************************** */
-void
- brtab_emit()
-{
- int i;
- char buf[20];
- char *p; /* Where the binary was output to */
- fixS *fixP; /*->description of deferred address fixup */
-
- if (!instrument_branches){
- return;
- }
-
- subseg_new(SEG_DATA,0); /* .data */
- frag_align(2,0); /* .align 2 */
- record_alignment(now_seg,2);
- colon(BR_TAB_NAME); /* BR_TAB_NAME: */
- emit(0); /* .word 0 #link to next table */
- emit(br_cnt); /* .word n #length of table */
-
- for (i=0; i<br_cnt; i++){
- sprintf(buf, "%s%d", BR_LABEL_BASE, i);
- p = emit(0);
- fixP = fix_new(frag_now,
- p - frag_now->fr_literal,
- 4,
- symbol_find(buf),
- 0,
- 0,
- 0,
- 0);
- fixP->fx_im_disp = 2; /* 32-bit displacement fix */
- }
-}
-
-/*****************************************************************************
- * cobr_fmt: generate a COBR-format instruction
- *
- **************************************************************************** */
-static
- void
- cobr_fmt(arg, opcode, oP)
-char *arg[]; /* arg[0]->opcode mnemonic, arg[1-3]->operands (ascii) */
-long opcode; /* Opcode, with branch-prediction bits already set
- * if necessary.
- */
-struct i960_opcode *oP;
-/*->description of instruction */
-{
- long instr; /* 32-bit instruction */
- struct regop regop; /* Description of register operand */
- int n; /* Number of operands */
- int var_frag; /* 1 if varying length code fragment should
- * be emitted; 0 if an address fix
- * should be emitted.
- */
-
- instr = opcode;
- n = oP->num_ops;
-
- if (n >= 1) {
- /* First operand (if any) of a COBR is always a register
- * operand. Parse it.
- */
- parse_regop(&regop, arg[1], oP->operand[0]);
- instr |= (regop.n << 19) | (regop.mode << 13);
- }
- if (n >= 2) {
- /* Second operand (if any) of a COBR is always a register
- * operand. Parse it.
- */
- parse_regop(&regop, arg[2], oP->operand[1]);
- instr |= (regop.n << 14) | regop.special;
- }
-
-
- if (n < 3){
- emit(instr);
-
- } else {
- if (instrument_branches){
- brcnt_emit();
- colon(brlab_next());
- }
-
- /* A third operand to a COBR is always a displacement.
- * Parse it; if it's relaxable (a cobr "j" directive, or any
- * cobr other than bbs/bbc when the "-norelax" option is not in
- * use) set up a variable code fragment; otherwise set up an
- * address fix.
- */
- var_frag = !norelax || (oP->format == COJ); /* TRUE or FALSE */
- get_cdisp(arg[3], "COBR", instr, 13, var_frag, 0);
-
- if (instrument_branches){
- brcnt_emit();
- }
- }
-} /* cobr_fmt() */
-
-
-/*****************************************************************************
- * ctrl_fmt: generate a CTRL-format instruction
- *
- **************************************************************************** */
-static
- void
- ctrl_fmt(targP, opcode, num_ops)
-char *targP; /* Pointer to text of lone operand (if any) */
-long opcode; /* Template of instruction */
-int num_ops; /* Number of operands */
-{
- int instrument; /* TRUE iff we should add instrumentation to track
- * how often the branch is taken
- */
-
-
- if (num_ops == 0){
- emit(opcode); /* Output opcode */
- } else {
-
- instrument = instrument_branches && (opcode != CALL)
- && (opcode != B) && (opcode != RET) && (opcode != BAL);
-
- if (instrument){
- brcnt_emit();
- colon(brlab_next());
- }
-
- /* The operand MUST be an ip-relative displacment. Parse it
- * and set up address fix for the instruction we just output.
- */
- get_cdisp(targP, "CTRL", opcode, 24, 0, 0);
-
- if (instrument){
- brcnt_emit();
- }
- }
-
-}
-
-
-/*****************************************************************************
- * emit: output instruction binary
- *
- * Output instruction binary, in target byte order, 4 bytes at a time.
- * Return pointer to where it was placed.
- *
- **************************************************************************** */
-static
- char *
- emit(instr)
-long instr; /* Word to be output, host byte order */
-{
- char *toP; /* Where to output it */
-
- toP = frag_more(4); /* Allocate storage */
- md_number_to_chars(toP, instr, 4); /* Convert to target byte order */
- return toP;
-}
-
-
-/*****************************************************************************
- * get_args: break individual arguments out of comma-separated list
- *
- * Input assumptions:
- * - all comments and labels have been removed
- * - all strings of whitespace have been collapsed to a single blank.
- * - all character constants ('x') have been replaced with decimal
- *
- * Output:
- * args[0] is untouched. args[1] points to first operand, etc. All args:
- * - are NULL-terminated
- * - contain no whitespace
- *
- * Return value:
- * Number of operands (0,1,2, or 3) or -1 on error.
- *
- **************************************************************************** */
-static int get_args(p, args)
-register char *p; /* Pointer to comma-separated operands; MUCKED BY US */
-char *args[]; /* Output arg: pointers to operands placed in args[1-3].
- * MUST ACCOMMODATE 4 ENTRIES (args[0-3]).
- */
-{
- register int n; /* Number of operands */
- register char *to;
- /* char buf[4]; */
- /* int len; */
-
-
- /* Skip lead white space */
- while (*p == ' '){
- p++;
- }
-
- if (*p == '\0'){
- return 0;
- }
-
- n = 1;
- args[1] = p;
-
- /* Squeze blanks out by moving non-blanks toward start of string.
- * Isolate operands, whenever comma is found.
- */
- to = p;
- while (*p != '\0'){
-
- if (*p == ' '){
- p++;
-
- } else if (*p == ','){
-
- /* Start of operand */
- if (n == 3){
- as_bad("too many operands");
- return -1;
- }
- *to++ = '\0'; /* Terminate argument */
- args[++n] = to; /* Start next argument */
- p++;
-
- } else {
- *to++ = *p++;
- }
- }
- *to = '\0';
- return n;
-}
-
-
-/*****************************************************************************
- * get_cdisp: handle displacement for a COBR or CTRL instruction.
- *
- * Parse displacement for a COBR or CTRL instruction.
- *
- * If successful, output the instruction opcode and set up for it,
- * depending on the arg 'var_frag', either:
- * o an address fixup to be done when all symbol values are known, or
- * o a varying length code fragment, with address fixup info. This
- * will be done for cobr instructions that may have to be relaxed
- * in to compare/branch instructions (8 bytes) if the final address
- * displacement is greater than 13 bits.
- *
- **************************************************************************** */
-static
- void
- get_cdisp(dispP, ifmtP, instr, numbits, var_frag, callj)
-char *dispP; /*->displacement as specified in source instruction */
-char *ifmtP; /*->"COBR" or "CTRL" (for use in error message) */
-long instr; /* Instruction needing the displacement */
-int numbits; /* # bits of displacement (13 for COBR, 24 for CTRL) */
-int var_frag; /* 1 if varying length code fragment should be emitted;
- * 0 if an address fix should be emitted.
- */
-int callj; /* 1 if callj relocation should be done; else 0 */
-{
- expressionS e; /* Parsed expression */
- fixS *fixP; /* Structure describing needed address fix */
- char *outP; /* Where instruction binary is output to */
-
- fixP = NULL;
-
- switch (parse_expr(dispP,&e)) {
-
- case SEG_GOOF:
- as_bad("expression syntax error");
- break;
-
- case SEG_TEXT:
- case SEG_UNKNOWN:
- if (var_frag) {
- outP = frag_more(8); /* Allocate worst-case storage */
- md_number_to_chars(outP, instr, 4);
- frag_variant(rs_machine_dependent, 4, 4, 1,
- adds(e), offs(e), outP, 0, 0);
- } else {
- /* Set up a new fix structure, so address can be updated
- * when all symbol values are known.
- */
- outP = emit(instr);
- fixP = fix_new(frag_now,
- outP - frag_now->fr_literal,
- 4,
- adds(e),
- 0,
- offs(e),
- 1,
- 0);
-
- fixP->fx_callj = callj;
-
- /* We want to modify a bit field when the address is
- * known. But we don't need all the garbage in the
- * bit_fix structure. So we're going to lie and store
- * the number of bits affected instead of a pointer.
- */
- fixP->fx_bit_fixP = (bit_fixS *) numbits;
- }
- break;
-
- case SEG_DATA:
- case SEG_BSS:
- as_bad("attempt to branch into different segment");
- break;
-
- default:
- as_bad("target of %s instruction must be a label", ifmtP);
- break;
- }
-}
-
-
-/*****************************************************************************
- * get_ispec: parse a memory operand for an index specification
- *
- * Here, an "index specification" is taken to be anything surrounded
- * by square brackets and NOT followed by anything else.
- *
- * If it's found, detach it from the input string, remove the surrounding
- * square brackets, and return a pointer to it. Otherwise, return NULL.
- *
- **************************************************************************** */
-static
- char *
- get_ispec(textP)
-char *textP; /*->memory operand from source instruction, no white space */
-{
- char *start; /*->start of index specification */
- char *end; /*->end of index specification */
-
- /* Find opening square bracket, if any
- */
- start = strchr(textP, '[');
-
- if (start != NULL){
-
- /* Eliminate '[', detach from rest of operand */
- *start++ = '\0';
-
- end = strchr(start, ']');
-
- if (end == NULL){
- as_bad("unmatched '['");
-
- } else {
- /* Eliminate ']' and make sure it was the last thing
- * in the string.
- */
- *end = '\0';
- if (*(end+1) != '\0'){
- as_bad("garbage after index spec ignored");
- }
- }
- }
- return start;
-}
-
-/*****************************************************************************
- * get_regnum:
- *
- * Look up a (suspected) register name in the register table and return the
- * associated register number (or -1 if not found).
- *
- **************************************************************************** */
-static
- int
- get_regnum(regname)
-char *regname; /* Suspected register name */
-{
- int *rP;
-
- rP = (int *) hash_find(reg_hash, regname);
- return (rP == NULL) ? -1 : *rP;
-}
-
-
-/*****************************************************************************
- * i_scan: perform lexical scan of ascii assembler instruction.
- *
- * Input assumptions:
- * - input string is an i80960 instruction (not a pseudo-op)
- * - all comments and labels have been removed
- * - all strings of whitespace have been collapsed to a single blank.
- *
- * Output:
- * args[0] points to opcode, other entries point to operands. All strings:
- * - are NULL-terminated
- * - contain no whitespace
- * - have character constants ('x') replaced with a decimal number
- *
- * Return value:
- * Number of operands (0,1,2, or 3) or -1 on error.
- *
- **************************************************************************** */
-static int i_scan(iP, args)
-register char *iP; /* Pointer to ascii instruction; MUCKED BY US. */
-char *args[]; /* Output arg: pointers to opcode and operands placed
- * here. MUST ACCOMMODATE 4 ENTRIES.
- */
-{
-
- /* Isolate opcode */
- if (*(iP) == ' ') {
- iP++;
- } /* Skip lead space, if any */
- args[0] = iP;
- for (; *iP != ' '; iP++) {
- if (*iP == '\0') {
- /* There are no operands */
- if (args[0] == iP) {
- /* We never moved: there was no opcode either! */
- as_bad("missing opcode");
- return -1;
- }
- return 0;
- }
- }
- *iP++ = '\0'; /* Terminate opcode */
- return(get_args(iP, args));
-} /* i_scan() */
-
-
-/*****************************************************************************
- * mem_fmt: generate a MEMA- or MEMB-format instruction
- *
- **************************************************************************** */
-static void mem_fmt(args, oP)
-char *args[]; /* args[0]->opcode mnemonic, args[1-3]->operands */
-struct i960_opcode *oP; /* Pointer to description of instruction */
-{
- int i; /* Loop counter */
- struct regop regop; /* Description of register operand */
- char opdesc; /* Operand descriptor byte */
- memS instr; /* Description of binary to be output */
- char *outP; /* Where the binary was output to */
- expressionS expr; /* Parsed expression */
- fixS *fixP; /*->description of deferred address fixup */
-
- memset(&instr, '\0', sizeof(memS));
- instr.opcode = oP->opcode;
-
- /* Process operands. */
- for (i = 1; i <= oP->num_ops; i++){
- opdesc = oP->operand[i-1];
-
- if (MEMOP(opdesc)){
- parse_memop(&instr, args[i], oP->format);
- } else {
- parse_regop(&regop, args[i], opdesc);
- instr.opcode |= regop.n << 19;
- }
- }
-
- /* Output opcode */
- outP = emit(instr.opcode);
-
- if (instr.disp == 0){
- return;
- }
-
- /* Parse and process the displacement */
- switch (parse_expr(instr.e,&expr)){
-
- case SEG_GOOF:
- as_bad("expression syntax error");
- break;
-
- case SEG_ABSOLUTE:
- if (instr.disp == 32){
- (void) emit(offs(expr)); /* Output displacement */
- } else {
- /* 12-bit displacement */
- if (offs(expr) & ~0xfff){
- /* Won't fit in 12 bits: convert already-output
- * instruction to MEMB format, output
- * displacement.
- */
- mema_to_memb(outP);
- (void) emit(offs(expr));
- } else {
- /* WILL fit in 12 bits: OR into opcode and
- * overwrite the binary we already put out
- */
- instr.opcode |= offs(expr);
- md_number_to_chars(outP, instr.opcode, 4);
- }
- }
- break;
-
- case SEG_DIFFERENCE:
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_UNKNOWN:
- if (instr.disp == 12){
- /* Displacement is dependent on a symbol, whose value
- * may change at link time. We HAVE to reserve 32 bits.
- * Convert already-output opcode to MEMB format.
- */
- mema_to_memb(outP);
- }
-
- /* Output 0 displacement and set up address fixup for when
- * this symbol's value becomes known.
- */
- outP = emit((long) 0);
- fixP = fix_new(frag_now,
- outP - frag_now->fr_literal,
- 4,
- adds(expr),
- subs(expr),
- offs(expr),
- 0,
- 0);
- fixP->fx_im_disp = 2; /* 32-bit displacement fix */
- break;
-
- default:
- BAD_CASE(segs(expr));
- break;
- }
-} /* memfmt() */
-
-
-/*****************************************************************************
- * mema_to_memb: convert a MEMA-format opcode to a MEMB-format opcode.
- *
- * There are 2 possible MEMA formats:
- * - displacement only
- * - displacement + abase
- *
- * They are distinguished by the setting of the MEMA_ABASE bit.
- *
- **************************************************************************** */
-static void mema_to_memb(opcodeP)
-char *opcodeP; /* Where to find the opcode, in target byte order */
-{
- long opcode; /* Opcode in host byte order */
- long mode; /* Mode bits for MEMB instruction */
-
- opcode = md_chars_to_number(opcodeP, 4);
- know(!(opcode & MEMB_BIT));
-
- mode = MEMB_BIT | D_BIT;
- if (opcode & MEMA_ABASE){
- mode |= A_BIT;
- }
-
- opcode &= 0xffffc000; /* Clear MEMA offset and mode bits */
- opcode |= mode; /* Set MEMB mode bits */
-
- md_number_to_chars(opcodeP, opcode, 4);
-} /* mema_to_memb() */
-
-
-/*****************************************************************************
- * parse_expr: parse an expression
- *
- * Use base assembler's expression parser to parse an expression.
- * It, unfortunately, runs off a global which we have to save/restore
- * in order to make it work for us.
- *
- * An empty expression string is treated as an absolute 0.
- *
- * Return "segment" to which the expression evaluates.
- * Return SEG_GOOF regardless of expression evaluation if entire input
- * string is not consumed in the evaluation -- tolerate no dangling junk!
- *
- **************************************************************************** */
-static
- segT
- parse_expr(textP, expP)
-char *textP; /* Text of expression to be parsed */
-expressionS *expP; /* Where to put the results of parsing */
-{
- char *save_in; /* Save global here */
- segT seg; /* Segment to which expression evaluates */
- symbolS *symP;
-
- know(textP);
-
- if (*textP == '\0') {
- /* Treat empty string as absolute 0 */
- expP->X_add_symbol = expP->X_subtract_symbol = NULL;
- expP->X_add_number = 0;
- seg = expP->X_seg = SEG_ABSOLUTE;
-
- } else {
- save_in = input_line_pointer; /* Save global */
- input_line_pointer = textP; /* Make parser work for us */
-
- seg = expression(expP);
- if (input_line_pointer - textP != strlen(textP)) {
- /* Did not consume all of the input */
- seg = SEG_GOOF;
- }
- symP = expP->X_add_symbol;
- if (symP && (hash_find(reg_hash, S_GET_NAME(symP)))) {
- /* Register name in an expression */
- seg = SEG_GOOF;
- }
-
- input_line_pointer = save_in; /* Restore global */
- }
- return seg;
-}
-
-
-/*****************************************************************************
- * parse_ldcont:
- * Parse and replace a 'ldconst' pseudo-instruction with an appropriate
- * i80960 instruction.
- *
- * Assumes the input consists of:
- * arg[0] opcode mnemonic ('ldconst')
- * arg[1] first operand (constant)
- * arg[2] name of register to be loaded
- *
- * Replaces opcode and/or operands as appropriate.
- *
- * Returns the new number of arguments, or -1 on failure.
- *
- **************************************************************************** */
-static
- int
- parse_ldconst(arg)
-char *arg[]; /* See above */
-{
- int n; /* Constant to be loaded */
- int shift; /* Shift count for "shlo" instruction */
- static char buf[5]; /* Literal for first operand */
- static char buf2[5]; /* Literal for second operand */
- expressionS e; /* Parsed expression */
-
-
- arg[3] = NULL; /* So we can tell at the end if it got used or not */
-
- switch (parse_expr(arg[1],&e)){
-
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_UNKNOWN:
- case SEG_DIFFERENCE:
- /* We're dependent on one or more symbols -- use "lda" */
- arg[0] = "lda";
- break;
-
- case SEG_ABSOLUTE:
- /* Try the following mappings:
- * ldconst 0,<reg> ->mov 0,<reg>
- * ldconst 31,<reg> ->mov 31,<reg>
- * ldconst 32,<reg> ->addo 1,31,<reg>
- * ldconst 62,<reg> ->addo 31,31,<reg>
- * ldconst 64,<reg> ->shlo 8,3,<reg>
- * ldconst -1,<reg> ->subo 1,0,<reg>
- * ldconst -31,<reg>->subo 31,0,<reg>
- *
- * anthing else becomes:
- * lda xxx,<reg>
- */
- n = offs(e);
- if ((0 <= n) && (n <= 31)){
- arg[0] = "mov";
-
- } else if ((-31 <= n) && (n <= -1)){
- arg[0] = "subo";
- arg[3] = arg[2];
- sprintf(buf, "%d", -n);
- arg[1] = buf;
- arg[2] = "0";
-
- } else if ((32 <= n) && (n <= 62)){
- arg[0] = "addo";
- arg[3] = arg[2];
- arg[1] = "31";
- sprintf(buf, "%d", n-31);
- arg[2] = buf;
-
- } else if ((shift = shift_ok(n)) != 0){
- arg[0] = "shlo";
- arg[3] = arg[2];
- sprintf(buf, "%d", shift);
- arg[1] = buf;
- sprintf(buf2, "%d", n >> shift);
- arg[2] = buf2;
-
- } else {
- arg[0] = "lda";
- }
- break;
-
- default:
- as_bad("invalid constant");
- return -1;
- break;
- }
- return (arg[3] == 0) ? 2: 3;
-}
-
-/*****************************************************************************
- * parse_memop: parse a memory operand
- *
- * This routine is based on the observation that the 4 mode bits of the
- * MEMB format, taken individually, have fairly consistent meaning:
- *
- * M3 (bit 13): 1 if displacement is present (D_BIT)
- * M2 (bit 12): 1 for MEMB instructions (MEMB_BIT)
- * M1 (bit 11): 1 if index is present (I_BIT)
- * M0 (bit 10): 1 if abase is present (A_BIT)
- *
- * So we parse the memory operand and set bits in the mode as we find
- * things. Then at the end, if we go to MEMB format, we need only set
- * the MEMB bit (M2) and our mode is built for us.
- *
- * Unfortunately, I said "fairly consistent". The exceptions:
- *
- * DBIA
- * 0100 Would seem illegal, but means "abase-only".
- *
- * 0101 Would seem to mean "abase-only" -- it means IP-relative.
- * Must be converted to 0100.
- *
- * 0110 Would seem to mean "index-only", but is reserved.
- * We turn on the D bit and provide a 0 displacement.
- *
- * The other thing to observe is that we parse from the right, peeling
- * things * off as we go: first any index spec, then any abase, then
- * the displacement.
- *
- **************************************************************************** */
-static
- void
- parse_memop(memP, argP, optype)
-memS *memP; /* Where to put the results */
-char *argP; /* Text of the operand to be parsed */
-int optype; /* MEM1, MEM2, MEM4, MEM8, MEM12, or MEM16 */
-{
- char *indexP; /* Pointer to index specification with "[]" removed */
- char *p; /* Temp char pointer */
- char iprel_flag;/* True if this is an IP-relative operand */
- int regnum; /* Register number */
- int scale; /* Scale factor: 1,2,4,8, or 16. Later converted
- * to internal format (0,1,2,3,4 respectively).
- */
- int mode; /* MEMB mode bits */
- int *intP; /* Pointer to register number */
-
- /* The following table contains the default scale factors for each
- * type of memory instruction. It is accessed using (optype-MEM1)
- * as an index -- thus it assumes the 'optype' constants are assigned
- * consecutive values, in the order they appear in this table
- */
- static int def_scale[] = {
- 1, /* MEM1 */
- 2, /* MEM2 */
- 4, /* MEM4 */
- 8, /* MEM8 */
- -1, /* MEM12 -- no valid default */
- 16 /* MEM16 */
- };
-
-
- iprel_flag = mode = 0;
-
- /* Any index present? */
- indexP = get_ispec(argP);
- if (indexP) {
- p = strchr(indexP, '*');
- if (p == NULL) {
- /* No explicit scale -- use default for this
- *instruction type.
- */
- scale = def_scale[ optype - MEM1 ];
- } else {
- *p++ = '\0'; /* Eliminate '*' */
-
- /* Now indexP->a '\0'-terminated register name,
- * and p->a scale factor.
- */
-
- if (!strcmp(p,"16")){
- scale = 16;
- } else if (strchr("1248",*p) && (p[1] == '\0')){
- scale = *p - '0';
- } else {
- scale = -1;
- }
- }
-
- regnum = get_regnum(indexP); /* Get index reg. # */
- if (!IS_RG_REG(regnum)){
- as_bad("invalid index register");
- return;
- }
-
- /* Convert scale to its binary encoding */
- switch (scale){
- case 1: scale = 0 << 7; break;
- case 2: scale = 1 << 7; break;
- case 4: scale = 2 << 7; break;
- case 8: scale = 3 << 7; break;
- case 16: scale = 4 << 7; break;
- default: as_bad("invalid scale factor"); return;
- };
-
- memP->opcode |= scale | regnum; /* Set index bits in opcode */
- mode |= I_BIT; /* Found a valid index spec */
- }
-
- /* Any abase (Register Indirect) specification present? */
- if ((p = strrchr(argP,'(')) != NULL) {
- /* "(" is there -- does it start a legal abase spec?
- * (If not it could be part of a displacement expression.)
- */
- intP = (int *) hash_find(areg_hash, p);
- if (intP != NULL){
- /* Got an abase here */
- regnum = *intP;
- *p = '\0'; /* discard register spec */
- if (regnum == IPREL){
- /* We have to specialcase ip-rel mode */
- iprel_flag = 1;
- } else {
- memP->opcode |= regnum << 14;
- mode |= A_BIT;
- }
- }
- }
-
- /* Any expression present? */
- memP->e = argP;
- if (*argP != '\0'){
- mode |= D_BIT;
- }
-
- /* Special-case ip-relative addressing */
- if (iprel_flag){
- if (mode & I_BIT){
- syntax();
- } else {
- memP->opcode |= 5 << 10; /* IP-relative mode */
- memP->disp = 32;
- }
- return;
- }
-
- /* Handle all other modes */
- switch (mode){
- case D_BIT | A_BIT:
- /* Go with MEMA instruction format for now (grow to MEMB later
- * if 12 bits is not enough for the displacement).
- * MEMA format has a single mode bit: set it to indicate
- * that abase is present.
- */
- memP->opcode |= MEMA_ABASE;
- memP->disp = 12;
- break;
-
- case D_BIT:
- /* Go with MEMA instruction format for now (grow to MEMB later
- * if 12 bits is not enough for the displacement).
- */
- memP->disp = 12;
- break;
-
- case A_BIT:
- /* For some reason, the bit string for this mode is not
- * consistent: it should be 0 (exclusive of the MEMB bit),
- * so we set it "by hand" here.
- */
- memP->opcode |= MEMB_BIT;
- break;
-
- case A_BIT | I_BIT:
- /* set MEMB bit in mode, and OR in mode bits */
- memP->opcode |= mode | MEMB_BIT;
- break;
-
- case I_BIT:
- /* Treat missing displacement as displacement of 0 */
- mode |= D_BIT;
- /***********************
- * Fall into next case *
- ********************** */
- case D_BIT | A_BIT | I_BIT:
- case D_BIT | I_BIT:
- /* set MEMB bit in mode, and OR in mode bits */
- memP->opcode |= mode | MEMB_BIT;
- memP->disp = 32;
- break;
-
- default:
- syntax();
- break;
- }
-}
-
-/*****************************************************************************
- * parse_po: parse machine-dependent pseudo-op
- *
- * This is a top-level routine for machine-dependent pseudo-ops. It slurps
- * up the rest of the input line, breaks out the individual arguments,
- * and dispatches them to the correct handler.
- **************************************************************************** */
-static
- void
- parse_po(po_num)
-int po_num; /* Pseudo-op number: currently S_LEAFPROC or S_SYSPROC */
-{
- char *args[4]; /* Pointers operands, with no embedded whitespace.
- * arg[0] unused.
- * arg[1-3]->operands
- */
- int n_ops; /* Number of operands */
- char *p; /* Pointer to beginning of unparsed argument string */
- char eol; /* Character that indicated end of line */
-
- extern char is_end_of_line[];
-
- /* Advance input pointer to end of line. */
- p = input_line_pointer;
- while (!is_end_of_line[ *input_line_pointer ]){
- input_line_pointer++;
- }
- eol = *input_line_pointer; /* Save end-of-line char */
- *input_line_pointer = '\0'; /* Terminate argument list */
-
- /* Parse out operands */
- n_ops = get_args(p, args);
- if (n_ops == -1){
- return;
- }
-
- /* Dispatch to correct handler */
- switch (po_num){
- case S_SYSPROC: s_sysproc(n_ops, args); break;
- case S_LEAFPROC: s_leafproc(n_ops, args); break;
- default: BAD_CASE(po_num); break;
- }
-
- /* Restore eol, so line numbers get updated correctly. Base assembler
- * assumes we leave input pointer pointing at char following the eol.
- */
- *input_line_pointer++ = eol;
-}
-
-/*****************************************************************************
- * parse_regop: parse a register operand.
- *
- * In case of illegal operand, issue a message and return some valid
- * information so instruction processing can continue.
- **************************************************************************** */
-static
- void
- parse_regop(regopP, optext, opdesc)
-struct regop *regopP; /* Where to put description of register operand */
-char *optext; /* Text of operand */
-char opdesc; /* Descriptor byte: what's legal for this operand */
-{
- int n; /* Register number */
- expressionS e; /* Parsed expression */
-
- /* See if operand is a register */
- n = get_regnum(optext);
- if (n >= 0){
- if (IS_RG_REG(n)){
- /* global or local register */
- if (!REG_ALIGN(opdesc,n)){
- as_bad("unaligned register");
- }
- regopP->n = n;
- regopP->mode = 0;
- regopP->special = 0;
- return;
- } else if (IS_FP_REG(n) && FP_OK(opdesc)){
- /* Floating point register, and it's allowed */
- regopP->n = n - FP0;
- regopP->mode = 1;
- regopP->special = 0;
- return;
- } else if (IS_SF_REG(n) && SFR_OK(opdesc)){
- /* Special-function register, and it's allowed */
- regopP->n = n - SF0;
- regopP->mode = 0;
- regopP->special = 1;
- if (!targ_has_sfr(regopP->n)){
- as_bad("no such sfr in this architecture");
- }
- return;
- }
- } else if (LIT_OK(opdesc)){
- /*
- * How about a literal?
- */
- regopP->mode = 1;
- regopP->special = 0;
- if (FP_OK(opdesc)){ /* floating point literal acceptable */
- /* Skip over 0f, 0d, or 0e prefix */
- if ( (optext[0] == '0')
- && (optext[1] >= 'd')
- && (optext[1] <= 'f') ){
- optext += 2;
- }
-
- if (!strcmp(optext,"0.0") || !strcmp(optext,"0") ){
- regopP->n = 0x10;
- return;
- }
- if (!strcmp(optext,"1.0") || !strcmp(optext,"1") ){
- regopP->n = 0x16;
- return;
- }
-
- } else { /* fixed point literal acceptable */
- if ((parse_expr(optext,&e) != SEG_ABSOLUTE)
- || (offs(e) < 0) || (offs(e) > 31)){
- as_bad("illegal literal");
- offs(e) = 0;
- }
- regopP->n = offs(e);
- return;
- }
- }
-
- /* Nothing worked */
- syntax();
- regopP->mode = 0; /* Register r0 is always a good one */
- regopP->n = 0;
- regopP->special = 0;
-} /* parse_regop() */
-
-/*****************************************************************************
- * reg_fmt: generate a REG-format instruction
- *
- **************************************************************************** */
-static void reg_fmt(args, oP)
-char *args[]; /* args[0]->opcode mnemonic, args[1-3]->operands */
-struct i960_opcode *oP; /* Pointer to description of instruction */
-{
- long instr; /* Binary to be output */
- struct regop regop; /* Description of register operand */
- int n_ops; /* Number of operands */
-
-
- instr = oP->opcode;
- n_ops = oP->num_ops;
-
- if (n_ops >= 1){
- parse_regop(&regop, args[1], oP->operand[0]);
-
- if ((n_ops == 1) && !(instr & M3)){
- /* 1-operand instruction in which the dst field should
- * be used (instead of src1).
- */
- regop.n <<= 19;
- if (regop.special){
- regop.mode = regop.special;
- }
- regop.mode <<= 13;
- regop.special = 0;
- } else {
- /* regop.n goes in bit 0, needs no shifting */
- regop.mode <<= 11;
- regop.special <<= 5;
- }
- instr |= regop.n | regop.mode | regop.special;
- }
-
- if (n_ops >= 2) {
- parse_regop(&regop, args[2], oP->operand[1]);
-
- if ((n_ops == 2) && !(instr & M3)){
- /* 2-operand instruction in which the dst field should
- * be used instead of src2).
- */
- regop.n <<= 19;
- if (regop.special){
- regop.mode = regop.special;
- }
- regop.mode <<= 13;
- regop.special = 0;
- } else {
- regop.n <<= 14;
- regop.mode <<= 12;
- regop.special <<= 6;
- }
- instr |= regop.n | regop.mode | regop.special;
- }
- if (n_ops == 3){
- parse_regop(&regop, args[3], oP->operand[2]);
- if (regop.special){
- regop.mode = regop.special;
- }
- instr |= (regop.n <<= 19) | (regop.mode <<= 13);
- }
- emit(instr);
-}
-
-
-/*****************************************************************************
- * relax_cobr:
- * Replace cobr instruction in a code fragment with equivalent branch and
- * compare instructions, so it can reach beyond a 13-bit displacement.
- * Set up an address fix/relocation for the new branch instruction.
- *
- **************************************************************************** */
-
-/* This "conditional jump" table maps cobr instructions into equivalent
- * compare and branch opcodes.
- */
-static
- struct {
- long compare;
- long branch;
- } coj[] = { /* COBR OPCODE: */
- CHKBIT, BNO, /* 0x30 - bbc */
- CMPO, BG, /* 0x31 - cmpobg */
- CMPO, BE, /* 0x32 - cmpobe */
- CMPO, BGE, /* 0x33 - cmpobge */
- CMPO, BL, /* 0x34 - cmpobl */
- CMPO, BNE, /* 0x35 - cmpobne */
- CMPO, BLE, /* 0x36 - cmpoble */
- CHKBIT, BO, /* 0x37 - bbs */
- CMPI, BNO, /* 0x38 - cmpibno */
- CMPI, BG, /* 0x39 - cmpibg */
- CMPI, BE, /* 0x3a - cmpibe */
- CMPI, BGE, /* 0x3b - cmpibge */
- CMPI, BL, /* 0x3c - cmpibl */
- CMPI, BNE, /* 0x3d - cmpibne */
- CMPI, BLE, /* 0x3e - cmpible */
- CMPI, BO, /* 0x3f - cmpibo */
- };
-
-static
- void
- relax_cobr(fragP)
-register fragS *fragP; /* fragP->fr_opcode is assumed to point to
- * the cobr instruction, which comes at the
- * end of the code fragment.
- */
-{
- int opcode, src1, src2, m1, s2;
- /* Bit fields from cobr instruction */
- long bp_bits; /* Branch prediction bits from cobr instruction */
- long instr; /* A single i960 instruction */
- char *iP; /*->instruction to be replaced */
- fixS *fixP; /* Relocation that can be done at assembly time */
-
- /* PICK UP & PARSE COBR INSTRUCTION */
- iP = fragP->fr_opcode;
- instr = md_chars_to_number(iP, 4);
- opcode = ((instr >> 24) & 0xff) - 0x30; /* "-0x30" for table index */
- src1 = (instr >> 19) & 0x1f;
- m1 = (instr >> 13) & 1;
- s2 = instr & 1;
- src2 = (instr >> 14) & 0x1f;
- bp_bits= instr & BP_MASK;
-
- /* GENERATE AND OUTPUT COMPARE INSTRUCTION */
- instr = coj[opcode].compare
- | src1 | (m1 << 11) | (s2 << 6) | (src2 << 14);
- md_number_to_chars(iP, instr, 4);
-
- /* OUTPUT BRANCH INSTRUCTION */
- md_number_to_chars(iP+4, coj[opcode].branch | bp_bits, 4);
-
- /* SET UP ADDRESS FIXUP/RELOCATION */
- fixP = fix_new(fragP,
- iP+4 - fragP->fr_literal,
- 4,
- fragP->fr_symbol,
- 0,
- fragP->fr_offset,
- 1,
- 0);
-
- fixP->fx_bit_fixP = (bit_fixS *) 24; /* Store size of bit field */
-
- fragP->fr_fix += 4;
- frag_wane(fragP);
-}
-
-
-/*****************************************************************************
- * reloc_callj: Relocate a 'callj' instruction
- *
- * This is a "non-(GNU)-standard" machine-dependent hook. The base
- * assembler calls it when it decides it can relocate an address at
- * assembly time instead of emitting a relocation directive.
- *
- * Check to see if the relocation involves a 'callj' instruction to a:
- * sysproc: Replace the default 'call' instruction with a 'calls'
- * leafproc: Replace the default 'call' instruction with a 'bal'.
- * other proc: Do nothing.
- *
- * See b.out.h for details on the 'n_other' field in a symbol structure.
- *
- * IMPORTANT!:
- * Assumes the caller has already figured out, in the case of a leafproc,
- * to use the 'bal' entry point, and has substituted that symbol into the
- * passed fixup structure.
- *
- **************************************************************************** */
-void reloc_callj(fixP)
-fixS *fixP; /* Relocation that can be done at assembly time */
-{
- char *where; /*->the binary for the instruction being relocated */
-
- if (!fixP->fx_callj) {
- return;
- } /* This wasn't a callj instruction in the first place */
-
- where = fixP->fx_frag->fr_literal + fixP->fx_where;
-
- if (TC_S_IS_SYSPROC(fixP->fx_addsy)) {
- /* Symbol is a .sysproc: replace 'call' with 'calls'.
- * System procedure number is (other-1).
- */
- md_number_to_chars(where, CALLS|TC_S_GET_SYSPROC(fixP->fx_addsy), 4);
-
- /* Nothing else needs to be done for this instruction.
- * Make sure 'md_number_to_field()' will perform a no-op.
- */
- fixP->fx_bit_fixP = (bit_fixS *) 1;
-
- } else if (TC_S_IS_CALLNAME(fixP->fx_addsy)) {
- /* Should not happen: see block comment above */
- as_fatal("Trying to 'bal' to %s", S_GET_NAME(fixP->fx_addsy));
-
- } else if (TC_S_IS_BALNAME(fixP->fx_addsy)) {
- /* Replace 'call' with 'bal'; both instructions have
- * the same format, so calling code should complete
- * relocation as if nothing happened here.
- */
- md_number_to_chars(where, BAL, 4);
- } else if (TC_S_IS_BADPROC(fixP->fx_addsy)) {
- as_bad("Looks like a proc, but can't tell what kind.\n");
- } /* switch on proc type */
-
- /* else Symbol is neither a sysproc nor a leafproc */
-
- return;
-} /* reloc_callj() */
-
-
-/*****************************************************************************
- * s_leafproc: process .leafproc pseudo-op
- *
- * .leafproc takes two arguments, the second one is optional:
- * arg[1]: name of 'call' entry point to leaf procedure
- * arg[2]: name of 'bal' entry point to leaf procedure
- *
- * If the two arguments are identical, or if the second one is missing,
- * the first argument is taken to be the 'bal' entry point.
- *
- * If there are 2 distinct arguments, we must make sure that the 'bal'
- * entry point immediately follows the 'call' entry point in the linked
- * list of symbols.
- *
- **************************************************************************** */
-static void s_leafproc(n_ops, args)
-int n_ops; /* Number of operands */
-char *args[]; /* args[1]->1st operand, args[2]->2nd operand */
-{
- symbolS *callP; /* Pointer to leafproc 'call' entry point symbol */
- symbolS *balP; /* Pointer to leafproc 'bal' entry point symbol */
-
- if ((n_ops != 1) && (n_ops != 2)) {
- as_bad("should have 1 or 2 operands");
- return;
- } /* Check number of arguments */
-
- /* Find or create symbol for 'call' entry point. */
- callP = symbol_find_or_make(args[1]);
-
- if (TC_S_IS_CALLNAME(callP)) {
- as_warn("Redefining leafproc %s", S_GET_NAME(callP));
- } /* is leafproc */
-
- /* If that was the only argument, use it as the 'bal' entry point.
- * Otherwise, mark it as the 'call' entry point and find or create
- * another symbol for the 'bal' entry point.
- */
- if ((n_ops == 1) || !strcmp(args[1],args[2])) {
- TC_S_FORCE_TO_BALNAME(callP);
-
- } else {
- TC_S_FORCE_TO_CALLNAME(callP);
-
- balP = symbol_find_or_make(args[2]);
- if (TC_S_IS_CALLNAME(balP)) {
- as_warn("Redefining leafproc %s", S_GET_NAME(balP));
- }
- TC_S_FORCE_TO_BALNAME(balP);
-
- tc_set_bal_of_call(callP, balP);
- } /* if only one arg, or the args are the same */
-
- return;
-} /* s_leafproc() */
-
-
-/*
- * s_sysproc: process .sysproc pseudo-op
- *
- * .sysproc takes two arguments:
- * arg[1]: name of entry point to system procedure
- * arg[2]: 'entry_num' (index) of system procedure in the range
- * [0,31] inclusive.
- *
- * For [ab].out, we store the 'entrynum' in the 'n_other' field of
- * the symbol. Since that entry is normally 0, we bias 'entrynum'
- * by adding 1 to it. It must be unbiased before it is used.
- */
-static void s_sysproc(n_ops, args)
-int n_ops; /* Number of operands */
-char *args[]; /* args[1]->1st operand, args[2]->2nd operand */
-{
- expressionS exp;
- symbolS *symP;
-
- if (n_ops != 2) {
- as_bad("should have two operands");
- return;
- } /* bad arg count */
-
- /* Parse "entry_num" argument and check it for validity. */
- if ((parse_expr(args[2],&exp) != SEG_ABSOLUTE)
- || (offs(exp) < 0)
- || (offs(exp) > 31)) {
- as_bad("'entry_num' must be absolute number in [0,31]");
- return;
- }
-
- /* Find/make symbol and stick entry number (biased by +1) into it */
- symP = symbol_find_or_make(args[1]);
-
- if (TC_S_IS_SYSPROC(symP)) {
- as_warn("Redefining entrynum for sysproc %s", S_GET_NAME(symP));
- } /* redefining */
-
- TC_S_SET_SYSPROC(symP, offs(exp)); /* encode entry number */
- TC_S_FORCE_TO_SYSPROC(symP);
-
- return;
-} /* s_sysproc() */
-
-
-/*****************************************************************************
- * shift_ok:
- * Determine if a "shlo" instruction can be used to implement a "ldconst".
- * This means that some number X < 32 can be shifted left to produce the
- * constant of interest.
- *
- * Return the shift count, or 0 if we can't do it.
- * Caller calculates X by shifting original constant right 'shift' places.
- *
- **************************************************************************** */
-static
- int
- shift_ok(n)
-int n; /* The constant of interest */
-{
- int shift; /* The shift count */
-
- if (n <= 0){
- /* Can't do it for negative numbers */
- return 0;
- }
-
- /* Shift 'n' right until a 1 is about to be lost */
- for (shift = 0; (n & 1) == 0; shift++){
- n >>= 1;
- }
-
- if (n >= 32){
- return 0;
- }
- return shift;
-}
-
-
-/*****************************************************************************
- * syntax: issue syntax error
- *
- **************************************************************************** */
-static void syntax() {
- as_bad("syntax error");
-} /* syntax() */
-
-
-/*****************************************************************************
- * targ_has_sfr:
- * Return TRUE iff the target architecture supports the specified
- * special-function register (sfr).
- *
- **************************************************************************** */
-static
- int
- targ_has_sfr(n)
-int n; /* Number (0-31) of sfr */
-{
- switch (architecture){
- case ARCH_KA:
- case ARCH_KB:
- case ARCH_MC:
- return 0;
- case ARCH_CA:
- default:
- return ((0 <= n) && (n <= 2));
- }
-}
-
-
-/*****************************************************************************
- * targ_has_iclass:
- * Return TRUE iff the target architecture supports the indicated
- * class of instructions.
- *
- **************************************************************************** */
-static
- int
- targ_has_iclass(ic)
-int ic; /* Instruction class; one of:
- * I_BASE, I_CX, I_DEC, I_KX, I_FP, I_MIL, I_CASIM
- */
-{
- iclasses_seen |= ic;
- switch (architecture){
- case ARCH_KA: return ic & (I_BASE | I_KX);
- case ARCH_KB: return ic & (I_BASE | I_KX | I_FP | I_DEC);
- case ARCH_MC: return ic & (I_BASE | I_KX | I_FP | I_DEC | I_MIL);
- case ARCH_CA: return ic & (I_BASE | I_CX | I_CASIM);
- default:
- if ((iclasses_seen & (I_KX|I_FP|I_DEC|I_MIL))
- && (iclasses_seen & I_CX)){
- as_warn("architecture of opcode conflicts with that of earlier instruction(s)");
- iclasses_seen &= ~ic;
- }
- return 1;
- }
-}
-
-
-/* Parse an operand that is machine-specific.
- We just return without modifying the expression if we have nothing
- to do. */
-
-/* ARGSUSED */
-void
- md_operand (expressionP)
-expressionS *expressionP;
-{
-}
-
-/* We have no need to default values of symbols. */
-
-/* ARGSUSED */
-symbolS *md_undefined_symbol(name)
-char *name;
-{
- return 0;
-} /* md_undefined_symbol() */
-
-/* Exactly what point is a PC-relative offset relative TO?
- On the i960, they're relative to the address of the instruction,
- which we have set up as the address of the fixup too. */
-long
- md_pcrel_from (fixP)
-fixS *fixP;
-{
- return fixP->fx_where + fixP->fx_frag->fr_address;
-}
-
-void
- md_apply_fix(fixP, val)
-fixS *fixP;
-long val;
-{
- char *place = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- if (!fixP->fx_bit_fixP) {
-
- switch (fixP->fx_im_disp) {
- case 0:
- fixP->fx_addnumber = val;
- md_number_to_imm(place, val, fixP->fx_size, fixP);
- break;
- case 1:
- md_number_to_disp(place,
- fixP->fx_pcrel ? val + fixP->fx_pcrel_adjust : val,
- fixP->fx_size);
- break;
- case 2: /* fix requested for .long .word etc */
- md_number_to_chars(place, val, fixP->fx_size);
- break;
- default:
- as_fatal("Internal error in md_apply_fix() in file \"%s\"", __FILE__);
- } /* OVE: maybe one ought to put _imm _disp _chars in one md-func */
- } else {
- md_number_to_field(place, val, fixP->fx_bit_fixP);
- }
-
- return;
-} /* md_apply_fix() */
-
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
-void tc_bout_fix_to_chars(where, fixP, segment_address_in_file)
-char *where;
-fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- static unsigned char nbytes_r_length[] = { 42, 0, 1, 42, 2 };
- struct relocation_info ri;
- symbolS *symbolP;
-
- /* JF this is for paranoia */
- memset((char *)&ri, '\0', sizeof(ri));
-
- know((symbolP = fixP->fx_addsy) != 0);
-
- /* These two 'cuz of NS32K */
- ri.r_callj = fixP->fx_callj;
-
- ri.r_length = nbytes_r_length[fixP->fx_size];
- ri.r_pcrel = fixP->fx_pcrel;
- ri.r_address = fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file;
-
- if (!S_IS_DEFINED(symbolP)) {
- ri.r_extern = 1;
- ri.r_index = symbolP->sy_number;
- } else {
- ri.r_extern = 0;
- ri.r_index = S_GET_TYPE(symbolP);
- }
-
- /* Output the relocation information in machine-dependent form. */
- md_ri_to_chars(where, &ri);
-
- return;
-} /* tc_bout_fix_to_chars() */
-
-#endif /* OBJ_AOUT or OBJ_BOUT */
-
-/* Align an address by rounding it up to the specified boundary.
- */
-long md_section_align(seg, addr)
-segT seg;
-long addr; /* Address to be rounded up */
-{
- return((addr + (1 << section_alignment[(int) seg]) - 1) & (-1 << section_alignment[(int) seg]));
-} /* md_section_align() */
-
-#ifdef OBJ_COFF
-void tc_headers_hook(headers)
-object_headers *headers;
-{
- /* FIXME: remove this line */ /* unsigned short arch_flag = 0; */
-
- if ((iclasses_seen == I_BASE) || (iclasses_seen == 0)) {
- headers->filehdr.f_flags |= F_I960CORE;
- } else if (iclasses_seen & I_CX){
- headers->filehdr.f_flags |= F_I960CA;
- } else if (iclasses_seen & I_MIL){
- headers->filehdr.f_flags |= F_I960MC;
- } else if (iclasses_seen & (I_DEC|I_FP)){
- headers->filehdr.f_flags |= F_I960KB;
- } else {
- headers->filehdr.f_flags |= F_I960KA;
- } /* set arch flag */
-
- if (flagseen['R']) {
- headers->filehdr.f_magic = I960RWMAGIC;
- headers->aouthdr.magic = OMAGIC;
- } else {
- headers->filehdr.f_magic = I960ROMAGIC;
- headers->aouthdr.magic = NMAGIC;
- } /* set magic numbers */
-
- return;
-} /* tc_headers_hook() */
-#endif /* OBJ_COFF */
-
-/*
- * Things going on here:
- *
- * For bout, We need to assure a couple of simplifying
- * assumptions about leafprocs for the linker: the leafproc
- * entry symbols will be defined in the same assembly in
- * which they're declared with the '.leafproc' directive;
- * and if a leafproc has both 'call' and 'bal' entry points
- * they are both global or both local.
- *
- * For coff, the call symbol has a second aux entry that
- * contains the bal entry point. The bal symbol becomes a
- * label.
- *
- * For coff representation, the call symbol has a second aux entry that
- * contains the bal entry point. The bal symbol becomes a label.
- *
- */
-
-void tc_crawl_symbol_chain(headers)
-object_headers *headers;
-{
- symbolS *symbolP;
-
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
-#ifdef OBJ_COFF
- if (TC_S_IS_SYSPROC(symbolP)) {
- /* second aux entry already contains the sysproc number */
- S_SET_NUMBER_AUXILIARY(symbolP, 2);
- S_SET_STORAGE_CLASS(symbolP, C_SCALL);
- S_SET_DATA_TYPE(symbolP, S_GET_DATA_TYPE(symbolP) | (DT_FCN << N_BTSHFT));
- continue;
- } /* rewrite sysproc */
-#endif /* OBJ_COFF */
-
- if (!TC_S_IS_BALNAME(symbolP) && !TC_S_IS_CALLNAME(symbolP)) {
- continue;
- } /* Not a leafproc symbol */
-
- if (!S_IS_DEFINED(symbolP)) {
- as_bad("leafproc symbol '%s' undefined", S_GET_NAME(symbolP));
- } /* undefined leaf */
-
- if (TC_S_IS_CALLNAME(symbolP)) {
- symbolS *balP = tc_get_bal_of_call(symbolP);
- if (S_IS_EXTERNAL(symbolP) != S_IS_EXTERNAL(balP)) {
- S_SET_EXTERNAL(symbolP);
- S_SET_EXTERNAL(balP);
- as_warn("Warning: making leafproc entries %s and %s both global\n",
- S_GET_NAME(symbolP), S_GET_NAME(balP));
- } /* externality mismatch */
- } /* if callname */
- } /* walk the symbol chain */
-
- return;
-} /* tc_crawl_symbol_chain() */
-
-/*
- * For aout or bout, the bal immediately follows the call.
- *
- * For coff, we cheat and store a pointer to the bal symbol
- * in the second aux entry of the call.
- */
-
-void tc_set_bal_of_call(callP, balP)
-symbolS *callP;
-symbolS *balP;
-{
- know(TC_S_IS_CALLNAME(callP));
- know(TC_S_IS_BALNAME(balP));
-
-#ifdef OBJ_COFF
-
- callP->sy_symbol.ost_auxent[1].x_bal.x_balntry = (int) balP;
- S_SET_NUMBER_AUXILIARY(callP,2);
-
-#elif defined(OBJ_AOUT) || defined(OBJ_BOUT)
-
- /* If the 'bal' entry doesn't immediately follow the 'call'
- * symbol, unlink it from the symbol list and re-insert it.
- */
- if (symbol_next(callP) != balP) {
- symbol_remove(balP, &symbol_rootP, &symbol_lastP);
- symbol_append(balP, callP, &symbol_rootP, &symbol_lastP);
- } /* if not in order */
-
-#else
- (as yet unwritten.);
-#endif /* switch on OBJ_FORMAT */
-
- return;
-} /* tc_set_bal_of_call() */
-
-char *_tc_get_bal_of_call(callP)
-symbolS *callP;
-{
- symbolS *retval;
-
- know(TC_S_IS_CALLNAME(callP));
-
-#ifdef OBJ_COFF
- retval = (symbolS *) (callP->sy_symbol.ost_auxent[1].x_bal.x_balntry);
-#elif defined(OBJ_AOUT) || defined(OBJ_BOUT)
- retval = symbol_next(callP);
-#else
- (as yet unwritten.);
-#endif /* switch on OBJ_FORMAT */
-
- know(TC_S_IS_BALNAME(retval));
- return((char *) retval);
-} /* _tc_get_bal_of_call() */
-
-void tc_coff_symbol_emit_hook(symbolP)
-symbolS *symbolP;
-{
- if (TC_S_IS_CALLNAME(symbolP)) {
-#ifdef OBJ_COFF
- symbolS *balP = tc_get_bal_of_call(symbolP);
-
- /* second aux entry contains the bal entry point */
- /* S_SET_NUMBER_AUXILIARY(symbolP, 2); */
- symbolP->sy_symbol.ost_auxent[1].x_bal.x_balntry = S_GET_VALUE(balP);
- S_SET_STORAGE_CLASS(symbolP, (!SF_GET_LOCAL(symbolP) ? C_LEAFEXT : C_LEAFSTAT));
- S_SET_DATA_TYPE(symbolP, S_GET_DATA_TYPE(symbolP) | (DT_FCN << N_BTSHFT));
- /* fix up the bal symbol */
- S_SET_STORAGE_CLASS(balP, C_LABEL);
-#endif /* OBJ_COFF */
- } /* only on calls */
-
- return;
-} /* tc_coff_symbol_emit_hook() */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-i960.c */
diff --git a/gnu/usr.bin/as/config/tc-i960.h b/gnu/usr.bin/as/config/tc-i960.h
deleted file mode 100644
index 236c9b1..0000000
--- a/gnu/usr.bin/as/config/tc-i960.h
+++ /dev/null
@@ -1,281 +0,0 @@
-/* tc-i960.h - Basic 80960 instruction formats.
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write
- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef TC_I960
-#define TC_I960 1
-
-#define NO_LISTING
-
-/*
- * The 'COJ' instructions are actually COBR instructions with the 'b' in
- * the mnemonic replaced by a 'j'; they are ALWAYS "de-optimized" if necessary:
- * if the displacement will not fit in 13 bits, the assembler will replace them
- * with the corresponding compare and branch instructions.
- *
- * All of the 'MEMn' instructions are the same format; the 'n' in the name
- * indicates the default index scale factor (the size of the datum operated on).
- *
- * The FBRA formats are not actually an instruction format. They are the
- * "convenience directives" for branching on floating-point comparisons,
- * each of which generates 2 instructions (a 'bno' and one other branch).
- *
- * The CALLJ format is not actually an instruction format. It indicates that
- * the instruction generated (a CTRL-format 'call') should have its relocation
- * specially flagged for link-time replacement with a 'bal' or 'calls' if
- * appropriate.
- */
-
-/* tailor gas */
-#define SYMBOLS_NEED_BACKPOINTERS
-#define LOCAL_LABELS_FB
-#define WANT_BITFIELDS
-
-/* tailor the coff format */
-#define OBJ_COFF_SECTION_HEADER_HAS_ALIGNMENT
-#define OBJ_COFF_MAX_AUXENTRIES (2)
-
-/* other */
-#define CTRL 0
-#define COBR 1
-#define COJ 2
-#define REG 3
-#define MEM1 4
-#define MEM2 5
-#define MEM4 6
-#define MEM8 7
-#define MEM12 8
-#define MEM16 9
-#define FBRA 10
-#define CALLJ 11
-
-/* Masks for the mode bits in REG format instructions */
-#define M1 0x0800
-#define M2 0x1000
-#define M3 0x2000
-
-/* Generate the 12-bit opcode for a REG format instruction by placing the
- * high 8 bits in instruction bits 24-31, the low 4 bits in instruction bits
- * 7-10.
- */
-
-#define REG_OPC(opc) ((opc & 0xff0) << 20) | ((opc & 0xf) << 7)
-
-/* Generate a template for a REG format instruction: place the opcode bits
- * in the appropriate fields and OR in mode bits for the operands that will not
- * be used. I.e.,
- * set m1=1, if src1 will not be used
- * set m2=1, if src2 will not be used
- * set m3=1, if dst will not be used
- *
- * Setting the "unused" mode bits to 1 speeds up instruction execution(!).
- * The information is also useful to us because some 1-operand REG instructions
- * use the src1 field, others the dst field; and some 2-operand REG instructions
- * use src1/src2, others src1/dst. The set mode bits enable us to distinguish.
- */
-#define R_0(opc) ( REG_OPC(opc) | M1 | M2 | M3 ) /* No operands */
-#define R_1(opc) ( REG_OPC(opc) | M2 | M3 ) /* 1 operand: src1 */
-#define R_1D(opc) ( REG_OPC(opc) | M1 | M2 ) /* 1 operand: dst */
-#define R_2(opc) ( REG_OPC(opc) | M3 ) /* 2 ops: src1/src2 */
-#define R_2D(opc) ( REG_OPC(opc) | M2 ) /* 2 ops: src1/dst */
-#define R_3(opc) ( REG_OPC(opc) ) /* 3 operands */
-
-/* DESCRIPTOR BYTES FOR REGISTER OPERANDS
- *
- * Interpret names as follows:
- * R: global or local register only
- * RS: global, local, or (if target allows) special-function register only
- * RL: global or local register, or integer literal
- * RSL: global, local, or (if target allows) special-function register;
- * or integer literal
- * F: global, local, or floating-point register
- * FL: global, local, or floating-point register; or literal (including
- * floating point)
- *
- * A number appended to a name indicates that registers must be aligned,
- * as follows:
- * 2: register number must be multiple of 2
- * 4: register number must be multiple of 4
- */
-
-#define SFR 0x10 /* Mask for the "sfr-OK" bit */
-#define LIT 0x08 /* Mask for the "literal-OK" bit */
-#define FP 0x04 /* Mask for "floating-point-OK" bit */
-
-/* This macro ors the bits together. Note that 'align' is a mask
- * for the low 0, 1, or 2 bits of the register number, as appropriate.
- */
-#define OP(align,lit,fp,sfr) ( align | lit | fp | sfr )
-
-#define R OP( 0, 0, 0, 0 )
-#define RS OP( 0, 0, 0, SFR )
-#define RL OP( 0, LIT, 0, 0 )
-#define RSL OP( 0, LIT, 0, SFR )
-#define F OP( 0, 0, FP, 0 )
-#define FL OP( 0, LIT, FP, 0 )
-#define R2 OP( 1, 0, 0, 0 )
-#define RL2 OP( 1, LIT, 0, 0 )
-#define F2 OP( 1, 0, FP, 0 )
-#define FL2 OP( 1, LIT, FP, 0 )
-#define R4 OP( 3, 0, 0, 0 )
-#define RL4 OP( 3, LIT, 0, 0 )
-#define F4 OP( 3, 0, FP, 0 )
-#define FL4 OP( 3, LIT, FP, 0 )
-
-#define M 0x7f /* Memory operand (MEMA & MEMB format instructions) */
-
-/* Macros to extract info from the register operand descriptor byte 'od'.
- */
-#define SFR_OK(od) (od & SFR) /* TRUE if sfr operand allowed */
-#define LIT_OK(od) (od & LIT) /* TRUE if literal operand allowed */
-#define FP_OK(od) (od & FP) /* TRUE if floating-point op allowed */
-#define REG_ALIGN(od,n) ((od & 0x3 & n) == 0)
-/* TRUE if reg #n is properly aligned */
-#define MEMOP(od) (od == M) /* TRUE if operand is a memory operand*/
-
-/* Classes of 960 intructions:
- * - each instruction falls into one class.
- * - each target architecture supports one or more classes.
- *
- * EACH CONSTANT MUST CONTAIN 1 AND ONLY 1 SET BIT!: see targ_has_iclass().
- */
-#define I_BASE 0x01 /* 80960 base instruction set */
-#define I_CX 0x02 /* 80960Cx instruction */
-#define I_DEC 0x04 /* Decimal instruction */
-#define I_FP 0x08 /* Floating point instruction */
-#define I_KX 0x10 /* 80960Kx instruction */
-#define I_MIL 0x20 /* Military instruction */
-
-/* MEANING OF 'n_other' in the symbol record.
- *
- * If non-zero, the 'n_other' fields indicates either a leaf procedure or
- * a system procedure, as follows:
- *
- * 1 <= n_other <= 32 :
- * The symbol is the entry point to a system procedure.
- * 'n_value' is the address of the entry, as for any other
- * procedure. The system procedure number (which can be used in
- * a 'calls' instruction) is (n_other-1). These entries come from
- * '.sysproc' directives.
- *
- * n_other == N_CALLNAME
- * the symbol is the 'call' entry point to a leaf procedure.
- * The *next* symbol in the symbol table must be the corresponding
- * 'bal' entry point to the procedure (see following). These
- * entries come from '.leafproc' directives in which two different
- * symbols are specified (the first one is represented here).
- *
- *
- * n_other == N_BALNAME
- * the symbol is the 'bal' entry point to a leaf procedure.
- * These entries result from '.leafproc' directives in which only
- * one symbol is specified, or in which the same symbol is
- * specified twice.
- *
- * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
- * but not every N_BALNAME entry must have an N_CALLNAME entry.
- */
-#define N_CALLNAME (-1)
-#define N_BALNAME (-2)
-
-
-/* i960 uses a custom relocation record. */
-
-/* let obj-aout.h know */
-#define CUSTOM_RELOC_FORMAT 1
-/* let a.out.gnu.h know */
-#define N_RELOCATION_INFO_DECLARED 1
-struct relocation_info {
- int r_address; /* File address of item to be relocated */
- unsigned
- r_index:24,/* Index of symbol on which relocation is based*/
- r_pcrel:1, /* 1 => relocate PC-relative; else absolute
- * On i960, pc-relative implies 24-bit
- * address, absolute implies 32-bit.
- */
- r_length:2, /* Number of bytes to relocate:
- * 0 => 1 byte
- * 1 => 2 bytes
- * 2 => 4 bytes -- only value used for i960
- */
- r_extern:1,
- r_bsr:1, /* Something for the GNU NS32K assembler */
- r_disp:1, /* Something for the GNU NS32K assembler */
- r_callj:1, /* 1 if relocation target is an i960 'callj' */
- nuthin:1; /* Unused */
-};
-
-/* hacks for tracking callj's */
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
-
-#define TC_S_IS_SYSPROC(s) ((1 <= S_GET_OTHER(s)) && (S_GET_OTHER(s) <= 32))
-#define TC_S_IS_BALNAME(s) (S_GET_OTHER(s) == N_BALNAME)
-#define TC_S_IS_CALLNAME(s) (S_GET_OTHER(s) == N_CALLNAME)
-#define TC_S_IS_BADPROC(s) ((S_GET_OTHER(s) != 0) && !TC_S_IS_CALLNAME(s) && !TC_S_IS_BALNAME(s) && !TC_S_IS_SYSPROC(s))
-
-#define TC_S_SET_SYSPROC(s, p) (S_SET_OTHER((s), (p)+1))
-#define TC_S_GET_SYSPROC(s) (S_GET_OTHER(s)-1)
-
-#define TC_S_FORCE_TO_BALNAME(s) (S_SET_OTHER((s), N_BALNAME))
-#define TC_S_FORCE_TO_CALLNAME(s) (S_SET_OTHER((s), N_CALLNAME))
-#define TC_S_FORCE_TO_SYSPROC(s) {;}
-
-#elif defined(OBJ_COFF)
-
-#define TC_S_IS_SYSPROC(s) (S_GET_STORAGE_CLASS(s) == C_SCALL)
-#define TC_S_IS_BALNAME(s) (SF_GET_BALNAME(s))
-#define TC_S_IS_CALLNAME(s) (SF_GET_CALLNAME(s))
-#define TC_S_IS_BADPROC(s) (TC_S_IS_SYSPROC(s) && TC_S_GET_SYSPROC(s) < 0 && 31 < TC_S_GET_SYSPROC(s))
-
-#define TC_S_SET_SYSPROC(s, p) ((s)->sy_symbol.ost_auxent[1].x_sc.x_stindx = (p))
-#define TC_S_GET_SYSPROC(s) ((s)->sy_symbol.ost_auxent[1].x_sc.x_stindx)
-
-#define TC_S_FORCE_TO_BALNAME(s) (SF_SET_BALNAME(s))
-#define TC_S_FORCE_TO_CALLNAME(s) (SF_SET_CALLNAME(s))
-#define TC_S_FORCE_TO_SYSPROC(s) (S_SET_STORAGE_CLASS((s), C_SCALL))
-
-#else /* switch on OBJ */
-you lose
-#endif /* witch on OBJ */
-
-#if __STDC__ == 1
-
- void brtab_emit(void);
-void reloc_callj(); /* this is really reloc_callj(fixS *fixP) but I don't want to change header inclusion order. */
-void tc_set_bal_of_call(); /* this is really tc_set_bal_of_call(symbolS *callP, symbolS *balP) */
-
-#else /* not __STDC__ */
-
-void brtab_emit();
-void reloc_callj();
-void tc_set_bal_of_call();
-
-#endif /* not __STDC__ */
-
-char *_tc_get_bal_of_call(); /* this is really symbolS *tc_get_bal_of_call(symbolS *callP). */
-#define tc_get_bal_of_call(c) ((symbolS *) _tc_get_bal_of_call(c))
-#endif
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-i960.h */
diff --git a/gnu/usr.bin/as/config/tc-m68851.h b/gnu/usr.bin/as/config/tc-m68851.h
deleted file mode 100644
index 8e69702..0000000
--- a/gnu/usr.bin/as/config/tc-m68851.h
+++ /dev/null
@@ -1,304 +0,0 @@
-/* This file is tc-m68851.h
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * pmmu.h
- */
-
-/* I suppose we have to copyright this file. Someone on the net sent it
- to us as part of the changes for the m68851 Memory Management Unit */
-
-/* Copyright (C) 1987 Free Software Foundation, Inc.
-
- This file is part of Gas, the GNU Assembler.
-
- The GNU assembler is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY. No author or distributor
- accepts responsibility to anyone for the consequences of using it
- or for whether it serves any particular purpose or works at all,
- unless he says so in writing. Refer to the GNU Assembler General
- Public License for full details.
-
- Everyone is granted permission to copy, modify and redistribute
- the GNU Assembler, but only under the conditions described in the
- GNU Assembler General Public License. A copy of this license is
- supposed to have been given to you along with the GNU Assembler
- so you can know your rights and responsibilities. It should be
- in a file named COPYING. Among other things, the copyright
- notice and this notice must be preserved on all copies. */
-
-#ifdef m68851
-
-/*
- I didn't use much imagination in choosing the
- following codes, so many of them aren't very
- mnemonic. -rab
-
- P pmmu register
- Possible values:
- 000 TC Translation Control reg
- 100 CAL Current Access Level
- 101 VAL Validate Access Level
- 110 SCC Stack Change Control
- 111 AC Access Control
-
- W wide pmmu registers
- Possible values:
- 001 DRP Dma Root Pointer
- 010 SRP Supervisor Root Pointer
- 011 CRP Cpu Root Pointer
-
- f function code register
- 0 SFC
- 1 DFC
-
- V VAL register only
-
- X BADx, BACx
- 100 BAD Breakpoint Acknowledge Data
- 101 BAC Breakpoint Acknowledge Control
-
- Y PSR
- Z PCSR
-
- | memory (modes 2-6, 7.*)
-
- */
-
-/*
- * these defines should be in m68k.c but
- * i put them here to keep all the m68851 stuff
- * together -rab
- * JF--Make sure these #s don't clash with the ones in m68k.c
- * That would be BAD.
- */
-#define TC (FPS+1) /* 48 */
-#define DRP (TC+1) /* 49 */
-#define SRP (DRP+1) /* 50 */
-#define CRP (SRP+1) /* 51 */
-#define CAL (CRP+1) /* 52 */
-#define VAL (CAL+1) /* 53 */
-#define SCC (VAL+1) /* 54 */
-#define AC (SCC+1) /* 55 */
-#define BAD (AC+1) /* 56,57,58,59, 60,61,62,63 */
-#define BAC (BAD+8) /* 64,65,66,67, 68,69,70,71 */
-#define PSR (BAC+8) /* 72 */
-#define PCSR (PSR+1) /* 73 */
-
-/* name */ /* opcode */ /* match */ /* args */
-
-{"pbac", one(0xf0c7), one(0xffbf), "Bc"},
-{"pbacw", one(0xf087), one(0xffbf), "Bc"},
-{"pbas", one(0xf0c6), one(0xffbf), "Bc"},
-{"pbasw", one(0xf086), one(0xffbf), "Bc"},
-{"pbbc", one(0xf0c1), one(0xffbf), "Bc"},
-{"pbbcw", one(0xf081), one(0xffbf), "Bc"},
-{"pbbs", one(0xf0c0), one(0xffbf), "Bc"},
-{"pbbsw", one(0xf080), one(0xffbf), "Bc"},
-{"pbcc", one(0xf0cf), one(0xffbf), "Bc"},
-{"pbccw", one(0xf08f), one(0xffbf), "Bc"},
-{"pbcs", one(0xf0ce), one(0xffbf), "Bc"},
-{"pbcsw", one(0xf08e), one(0xffbf), "Bc"},
-{"pbgc", one(0xf0cd), one(0xffbf), "Bc"},
-{"pbgcw", one(0xf08d), one(0xffbf), "Bc"},
-{"pbgs", one(0xf0cc), one(0xffbf), "Bc"},
-{"pbgsw", one(0xf08c), one(0xffbf), "Bc"},
-{"pbic", one(0xf0cb), one(0xffbf), "Bc"},
-{"pbicw", one(0xf08b), one(0xffbf), "Bc"},
-{"pbis", one(0xf0ca), one(0xffbf), "Bc"},
-{"pbisw", one(0xf08a), one(0xffbf), "Bc"},
-{"pblc", one(0xf0c3), one(0xffbf), "Bc"},
-{"pblcw", one(0xf083), one(0xffbf), "Bc"},
-{"pbls", one(0xf0c2), one(0xffbf), "Bc"},
-{"pblsw", one(0xf082), one(0xffbf), "Bc"},
-{"pbsc", one(0xf0c5), one(0xffbf), "Bc"},
-{"pbscw", one(0xf085), one(0xffbf), "Bc"},
-{"pbss", one(0xf0c4), one(0xffbf), "Bc"},
-{"pbssw", one(0xf084), one(0xffbf), "Bc"},
-{"pbwc", one(0xf0c9), one(0xffbf), "Bc"},
-{"pbwcw", one(0xf089), one(0xffbf), "Bc"},
-{"pbws", one(0xf0c8), one(0xffbf), "Bc"},
-{"pbwsw", one(0xf088), one(0xffbf), "Bc"},
-
-
-{"pdbac", two(0xf048, 0x0007), two(0xfff8, 0xffff), "DsBw"},
-{"pdbas", two(0xf048, 0x0006), two(0xfff8, 0xffff), "DsBw"},
-{"pdbbc", two(0xf048, 0x0001), two(0xfff8, 0xffff), "DsBw"},
-{"pdbbs", two(0xf048, 0x0000), two(0xfff8, 0xffff), "DsBw"},
-{"pdbcc", two(0xf048, 0x000f), two(0xfff8, 0xffff), "DsBw"},
-{"pdbcs", two(0xf048, 0x000e), two(0xfff8, 0xffff), "DsBw"},
-{"pdbgc", two(0xf048, 0x000d), two(0xfff8, 0xffff), "DsBw"},
-{"pdbgs", two(0xf048, 0x000c), two(0xfff8, 0xffff), "DsBw"},
-{"pdbic", two(0xf048, 0x000b), two(0xfff8, 0xffff), "DsBw"},
-{"pdbis", two(0xf048, 0x000a), two(0xfff8, 0xffff), "DsBw"},
-{"pdblc", two(0xf048, 0x0003), two(0xfff8, 0xffff), "DsBw"},
-{"pdbls", two(0xf048, 0x0002), two(0xfff8, 0xffff), "DsBw"},
-{"pdbsc", two(0xf048, 0x0005), two(0xfff8, 0xffff), "DsBw"},
-{"pdbss", two(0xf048, 0x0004), two(0xfff8, 0xffff), "DsBw"},
-{"pdbwc", two(0xf048, 0x0009), two(0xfff8, 0xffff), "DsBw"},
-{"pdbws", two(0xf048, 0x0008), two(0xfff8, 0xffff), "DsBw"},
-
-{"pflusha", two(0xf000, 0x2400), two(0xffff, 0xffff), "" },
-
-{"pflush", two(0xf000, 0x3010), two(0xffc0, 0xfe10), "T3T9" },
-{"pflush", two(0xf000, 0x3810), two(0xffc0, 0xfe10), "T3T9&s" },
-{"pflush", two(0xf000, 0x3008), two(0xffc0, 0xfe18), "D3T9" },
-{"pflush", two(0xf000, 0x3808), two(0xffc0, 0xfe18), "D3T9&s" },
-{"pflush", two(0xf000, 0x3000), two(0xffc0, 0xfe1e), "f3T9" },
-{"pflush", two(0xf000, 0x3800), two(0xffc0, 0xfe1e), "f3T9&s" },
-
-{"pflushs", two(0xf000, 0x3410), two(0xfff8, 0xfe10), "T3T9" },
-{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe00), "T3T9&s" },
-{"pflushs", two(0xf000, 0x3408), two(0xfff8, 0xfe18), "D3T9" },
-{"pflushs", two(0xf000, 0x3c08), two(0xfff8, 0xfe18), "D3T9&s" },
-{"pflushs", two(0xf000, 0x3400), two(0xfff8, 0xfe1e), "f3T9" },
-{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe1e), "f3T9&s"},
-
-{"pflushr", two(0xf000, 0xa000), two(0xffc0, 0xffff), "|s" },
-
-{"ploadr", two(0xf000, 0x2210), two(0xffc0, 0xfff0), "T3&s" },
-{"ploadr", two(0xf000, 0x2208), two(0xffc0, 0xfff8), "D3&s" },
-{"ploadr", two(0xf000, 0x2200), two(0xffc0, 0xfffe), "f3&s" },
-{"ploadw", two(0xf000, 0x2010), two(0xffc0, 0xfff0), "T3&s" },
-{"ploadw", two(0xf000, 0x2008), two(0xffc0, 0xfff8), "D3&s" },
-{"ploadw", two(0xf000, 0x2000), two(0xffc0, 0xfffe), "f3&s" },
-
- /* TC, CRP, DRP, SRP, CAL, VAL, SCC, AC */
-{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "*sP8" },
-{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "P8%s" },
-{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "|sW8" },
-{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "W8~s" },
-
- /* BADx, BACx */
-{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xe3e3), "*sX3" },
-{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xe3e3), "X3%s" },
-
- /* PSR, PCSR */
- /* {"pmove", two(0xf000, 0x6100), two(oxffc0, oxffff), "*sZ8" }, */
-{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xffff), "*sY8" },
-{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xffff), "Y8%s" },
-{"pmove", two(0xf000, 0x6600), two(0xffc0, 0xffff), "Z8%s" },
-
-{"prestore", one(0xf140), one(0xffc0), "&s"},
-{"prestore", one(0xf158), one(0xfff8), "+s"},
-{"psave", one(0xf100), one(0xffc0), "&s"},
-{"psave", one(0xf100), one(0xffc0), "+s"},
-
-{"psac", two(0xf040, 0x0007), two(0xffc0, 0xffff), "@s"},
-{"psas", two(0xf040, 0x0006), two(0xffc0, 0xffff), "@s"},
-{"psbc", two(0xf040, 0x0001), two(0xffc0, 0xffff), "@s"},
-{"psbs", two(0xf040, 0x0000), two(0xffc0, 0xffff), "@s"},
-{"pscc", two(0xf040, 0x000f), two(0xffc0, 0xffff), "@s"},
-{"pscs", two(0xf040, 0x000e), two(0xffc0, 0xffff), "@s"},
-{"psgc", two(0xf040, 0x000d), two(0xffc0, 0xffff), "@s"},
-{"psgs", two(0xf040, 0x000c), two(0xffc0, 0xffff), "@s"},
-{"psic", two(0xf040, 0x000b), two(0xffc0, 0xffff), "@s"},
-{"psis", two(0xf040, 0x000a), two(0xffc0, 0xffff), "@s"},
-{"pslc", two(0xf040, 0x0003), two(0xffc0, 0xffff), "@s"},
-{"psls", two(0xf040, 0x0002), two(0xffc0, 0xffff), "@s"},
-{"pssc", two(0xf040, 0x0005), two(0xffc0, 0xffff), "@s"},
-{"psss", two(0xf040, 0x0004), two(0xffc0, 0xffff), "@s"},
-{"pswc", two(0xf040, 0x0009), two(0xffc0, 0xffff), "@s"},
-{"psws", two(0xf040, 0x0008), two(0xffc0, 0xffff), "@s"},
-
-{"ptestr", two(0xf000, 0x8210), two(0xffc0, 0xe3f0), "T3&sQ8" },
-{"ptestr", two(0xf000, 0x8310), two(0xffc0, 0xe310), "T3&sQ8A9" },
-{"ptestr", two(0xf000, 0x8208), two(0xffc0, 0xe3f8), "D3&sQ8" },
-{"ptestr", two(0xf000, 0x8308), two(0xffc0, 0xe318), "D3&sQ8A9" },
-{"ptestr", two(0xf000, 0x8200), two(0xffc0, 0xe3fe), "f3&sQ8" },
-{"ptestr", two(0xf000, 0x8300), two(0xffc0, 0xe31e), "f3&sQ8A9" },
-
-{"ptestw", two(0xf000, 0x8010), two(0xffc0, 0xe3f0), "T3&sQ8" },
-{"ptestw", two(0xf000, 0x8110), two(0xffc0, 0xe310), "T3&sQ8A9" },
-{"ptestw", two(0xf000, 0x8008), two(0xffc0, 0xe3f8), "D3&sQ8" },
-{"ptestw", two(0xf000, 0x8108), two(0xffc0, 0xe318), "D3&sQ8A9" },
-{"ptestw", two(0xf000, 0x8000), two(0xffc0, 0xe3fe), "f3&sQ8" },
-{"ptestw", two(0xf000, 0x8100), two(0xffc0, 0xe31e), "f3&sQ8A9" },
-
-{"ptrapacw", two(0xf07a, 0x0007), two(0xffff, 0xffff), "#w"},
-{"ptrapacl", two(0xf07b, 0x0007), two(0xffff, 0xffff), "#l"},
-{"ptrapac", two(0xf07c, 0x0007), two(0xffff, 0xffff), ""},
-
-{"ptrapasw", two(0xf07a, 0x0006), two(0xffff, 0xffff), "#w"},
-{"ptrapasl", two(0xf07b, 0x0006), two(0xffff, 0xffff), "#l"},
-{"ptrapas", two(0xf07c, 0x0006), two(0xffff, 0xffff), ""},
-
-{"ptrapbcw", two(0xf07a, 0x0001), two(0xffff, 0xffff), "#w"},
-{"ptrapbcl", two(0xf07b, 0x0001), two(0xffff, 0xffff), "#l"},
-{"ptrapbc", two(0xf07c, 0x0001), two(0xffff, 0xffff), ""},
-
-{"ptrapbsw", two(0xf07a, 0x0000), two(0xffff, 0xffff), "#w"},
-{"ptrapbsl", two(0xf07b, 0x0000), two(0xffff, 0xffff), "#l"},
-{"ptrapbs", two(0xf07c, 0x0000), two(0xffff, 0xffff), ""},
-
-{"ptrapccw", two(0xf07a, 0x000f), two(0xffff, 0xffff), "#w"},
-{"ptrapccl", two(0xf07b, 0x000f), two(0xffff, 0xffff), "#l"},
-{"ptrapcc", two(0xf07c, 0x000f), two(0xffff, 0xffff), ""},
-
-{"ptrapcsw", two(0xf07a, 0x000e), two(0xffff, 0xffff), "#w"},
-{"ptrapcsl", two(0xf07b, 0x000e), two(0xffff, 0xffff), "#l"},
-{"ptrapcs", two(0xf07c, 0x000e), two(0xffff, 0xffff), ""},
-
-{"ptrapgcw", two(0xf07a, 0x000d), two(0xffff, 0xffff), "#w"},
-{"ptrapgcl", two(0xf07b, 0x000d), two(0xffff, 0xffff), "#l"},
-{"ptrapgc", two(0xf07c, 0x000d), two(0xffff, 0xffff), ""},
-
-{"ptrapgsw", two(0xf07a, 0x000c), two(0xffff, 0xffff), "#w"},
-{"ptrapgsl", two(0xf07b, 0x000c), two(0xffff, 0xffff), "#l"},
-{"ptrapgs", two(0xf07c, 0x000c), two(0xffff, 0xffff), ""},
-
-{"ptrapicw", two(0xf07a, 0x000b), two(0xffff, 0xffff), "#w"},
-{"ptrapicl", two(0xf07b, 0x000b), two(0xffff, 0xffff), "#l"},
-{"ptrapic", two(0xf07c, 0x000b), two(0xffff, 0xffff), ""},
-
-{"ptrapisw", two(0xf07a, 0x000a), two(0xffff, 0xffff), "#w"},
-{"ptrapisl", two(0xf07b, 0x000a), two(0xffff, 0xffff), "#l"},
-{"ptrapis", two(0xf07c, 0x000a), two(0xffff, 0xffff), ""},
-
-{"ptraplcw", two(0xf07a, 0x0003), two(0xffff, 0xffff), "#w"},
-{"ptraplcl", two(0xf07b, 0x0003), two(0xffff, 0xffff), "#l"},
-{"ptraplc", two(0xf07c, 0x0003), two(0xffff, 0xffff), ""},
-
-{"ptraplsw", two(0xf07a, 0x0002), two(0xffff, 0xffff), "#w"},
-{"ptraplsl", two(0xf07b, 0x0002), two(0xffff, 0xffff), "#l"},
-{"ptrapls", two(0xf07c, 0x0002), two(0xffff, 0xffff), ""},
-
-{"ptrapscw", two(0xf07a, 0x0005), two(0xffff, 0xffff), "#w"},
-{"ptrapscl", two(0xf07b, 0x0005), two(0xffff, 0xffff), "#l"},
-{"ptrapsc", two(0xf07c, 0x0005), two(0xffff, 0xffff), ""},
-
-{"ptrapssw", two(0xf07a, 0x0004), two(0xffff, 0xffff), "#w"},
-{"ptrapssl", two(0xf07b, 0x0004), two(0xffff, 0xffff), "#l"},
-{"ptrapss", two(0xf07c, 0x0004), two(0xffff, 0xffff), ""},
-
-{"ptrapwcw", two(0xf07a, 0x0009), two(0xffff, 0xffff), "#w"},
-{"ptrapwcl", two(0xf07b, 0x0009), two(0xffff, 0xffff), "#l"},
-{"ptrapwc", two(0xf07c, 0x0009), two(0xffff, 0xffff), ""},
-
-{"ptrapwsw", two(0xf07a, 0x0008), two(0xffff, 0xffff), "#w"},
-{"ptrapwsl", two(0xf07b, 0x0008), two(0xffff, 0xffff), "#l"},
-{"ptrapws", two(0xf07c, 0x0008), two(0xffff, 0xffff), ""},
-
-{"pvalid", two(0xf000, 0x2800), two(0xffc0, 0xffff), "Vs&s"},
-{"pvalid", two(0xf000, 0x2c00), two(0xffc0, 0xfff8), "A3&s" },
-
-#endif /* m68851 */
-
-/* end of tc-m68851.h */
diff --git a/gnu/usr.bin/as/config/tc-m68k.c b/gnu/usr.bin/as/config/tc-m68k.c
deleted file mode 100644
index dc4d3e8..0000000
--- a/gnu/usr.bin/as/config/tc-m68k.c
+++ /dev/null
@@ -1,4088 +0,0 @@
-/* tc-m68k.c All the m68020 specific stuff in one convenient, huge,
- slow to compile, easy to find file.
-
- Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include <ctype.h>
-
-#include "as.h"
-
-#include "obstack.h"
-
-/* note that this file includes real declarations and thus can only be included by one source file per executable. */
-#include "opcode/m68k.h"
-#ifdef TE_SUN
-/* This variable contains the value to write out at the beginning of
- the a.out file. The 2<<16 means that this is a 68020 file instead
- of an old-style 68000 file */
-
-long omagic = 2<<16|OMAGIC; /* Magic byte for header file */
-#else
-long omagic = OMAGIC;
-#endif
-
-/* This array holds the chars that always start a comment. If the
- pre-processor is disabled, these aren't very useful */
-const char comment_chars[] = "|";
-
-/* This array holds the chars that only start a comment at the beginning of
- a line. If the line seems to have the form '# 123 filename'
- .line and .file directives will appear in the pre-processed output */
-/* Note that input_file.c hand checks for '#' at the beginning of the
- first line of the input file. This is because the compiler outputs
- #NO_APP at the beginning of its output. */
-/* Also note that comments like this one will always work. */
-const char line_comment_chars[] = "#";
-
-/* Chars that can be used to separate mant from exp in floating point nums */
-const char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant */
-/* As in 0f12.456 */
-/* or 0d1.2345e12 */
-
-const char FLT_CHARS[] = "rRsSfFdDxXeEpP";
-
-/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
- changed in read.c. Ideally it shouldn't have to know about it at all,
- but nothing is ideal around here.
- */
-
-const int md_reloc_size = 8; /* Size of relocation record */
-
-/* Its an arbitrary name: This means I don't approve of it */
-/* See flames below */
-static struct obstack robyn;
-
-#define TAB(x,y) (((x)<<2)+(y))
-#define TABTYPE(xy) ((xy) >> 2)
-#define BYTE 0
-#define SHORT 1
-#define LONG 2
-#define SZ_UNDEF 3
-
-#define BRANCH 1
-#define FBRANCH 2
-#define PCREL 3
-#define BCC68000 4
-#define DBCC 5
-#define PCLEA 6
-
-/* Operands we can parse: (And associated modes)
-
- numb: 8 bit num
- numw: 16 bit num
- numl: 32 bit num
- dreg: data reg 0-7
- reg: address or data register
- areg: address register
- apc: address register, PC, ZPC or empty string
- num: 16 or 32 bit num
- num2: like num
- sz: w or l if omitted, l assumed
- scale: 1 2 4 or 8 if omitted, 1 assumed
-
- 7.4 IMMED #num --> NUM
- 0.? DREG dreg --> dreg
- 1.? AREG areg --> areg
- 2.? AINDR areg@ --> *(areg)
- 3.? AINC areg@+ --> *(areg++)
- 4.? ADEC areg@- --> *(--areg)
- 5.? AOFF apc@(numw) --> *(apc+numw) -- empty string and ZPC not allowed here
- 6.? AINDX apc@(num,reg:sz:scale) --> *(apc+num+reg*scale)
- 6.? AINDX apc@(reg:sz:scale) --> same, with num=0
- 6.? APODX apc@(num)@(num2,reg:sz:scale) --> *(*(apc+num)+num2+reg*scale)
- 6.? APODX apc@(num)@(reg:sz:scale) --> same, with num2=0
- 6.? AMIND apc@(num)@(num2) --> *(*(apc+num)+num2) (previous mode without an index reg)
- 6.? APRDX apc@(num,reg:sz:scale)@(num2) --> *(*(apc+num+reg*scale)+num2)
- 6.? APRDX apc@(reg:sz:scale)@(num2) --> same, with num=0
- 7.0 ABSL num:sz --> *(num)
- num --> *(num) (sz L assumed)
- *** MSCR otherreg --> Magic
- With -l option
- 5.? AOFF apc@(num) --> *(apc+num) -- empty string and ZPC not allowed here still
-
- examples:
- #foo #0x35 #12
- d2
- a4
- a3@
- a5@+
- a6@-
- a2@(12) pc@(14)
- a1@(5,d2:w:1) @(45,d6:l:4)
- pc@(a2) @(d4)
- etc...
-
-
- #name@(numw) -->turn into PC rel mode
- apc@(num8,reg:sz:scale) --> *(apc+num8+reg*scale)
-
- */
-
-enum operand_type {
- IMMED = 1,
- DREG,
- AREG,
- AINDR,
- ADEC,
- AINC,
- AOFF,
- AINDX,
- APODX,
- AMIND,
- APRDX,
- ABSL,
- MSCR,
- REGLST,
-};
-
-
-struct m68k_exp {
- char *e_beg;
- char *e_end;
- expressionS e_exp;
- short e_siz; /* 0 == default 1 == short/byte 2 == word 3 == long */
-};
-
-/* DATA and ADDR have to be contiguous, so that reg-DATA gives 0-7 == data reg,
- 8-15 == addr reg for operands that take both types */
-
-enum _register {
- DATA = 1, /* 1- 8 == data registers 0-7 */
- DATA0 = DATA,
- DATA1,
- DATA2,
- DATA3,
- DATA4,
- DATA5,
- DATA6,
- DATA7,
-
- ADDR,
- ADDR0 = ADDR,
- ADDR1,
- ADDR2,
- ADDR3,
- ADDR4,
- ADDR5,
- ADDR6,
- ADDR7,
-
- /* Note that COPNUM == processor #1 -- COPNUM+7 == #8, which stores as 000 */
- /* I think... */
-
- SP = ADDR7,
-
- FPREG, /* Eight FP registers */
- FP0 = FPREG,
- FP1,
- FP2,
- FP3,
- FP4,
- FP5,
- FP6,
- FP7,
- COPNUM = (FPREG+8), /* Co-processor #1-#8 */
- COP0 = COPNUM,
- COP1,
- COP2,
- COP3,
- COP4,
- COP5,
- COP6,
- COP7,
- PC, /* Program counter */
- ZPC, /* Hack for Program space, but 0 addressing */
- SR, /* Status Reg */
- CCR, /* Condition code Reg */
-
- /* These have to be in order for the movec instruction to work. */
- USP, /* User Stack Pointer */
- ISP, /* Interrupt stack pointer */
- SFC,
- DFC,
- CACR,
- VBR,
- CAAR,
- MSP,
- ITT0,
- ITT1,
- DTT0,
- DTT1,
- MMUSR,
- TC,
- SRP,
- URP,
- /* end of movec ordering constraints */
-
- FPI,
- FPS,
- FPC,
-
- DRP,
- CRP,
- CAL,
- VAL,
- SCC,
- AC,
- BAD,
- BAD0 = BAD,
- BAD1,
- BAD2,
- BAD3,
- BAD4,
- BAD5,
- BAD6,
- BAD7,
- BAC,
- BAC0 = BAC,
- BAC1,
- BAC2,
- BAC3,
- BAC4,
- BAC5,
- BAC6,
- BAC7,
- PSR,
- PCSR,
-
- IC, /* instruction cache token */
- DC, /* data cache token */
- NC, /* no cache token */
- BC, /* both caches token */
-
-};
-
-/* Internal form of an operand. */
-struct m68k_op {
- char *error; /* Couldn't parse it */
- enum operand_type mode; /* What mode this instruction is in. */
- enum _register reg; /* Base register */
- struct m68k_exp *con1;
- int ireg; /* Index register */
- int isiz; /* 0 == unspec 1 == byte(?) 2 == short 3 == long */
- int imul; /* Multipy ireg by this (1,2,4,or 8) */
- struct m68k_exp *con2;
-};
-
-/* internal form of a 68020 instruction */
-struct m68k_it {
- char *error;
- char *args; /* list of opcode info */
- int numargs;
-
- int numo; /* Number of shorts in opcode */
- short opcode[11];
-
- struct m68k_op operands[6];
-
- int nexp; /* number of exprs in use */
- struct m68k_exp exprs[4];
-
- int nfrag; /* Number of frags we have to produce */
- struct {
- int fragoff; /* Where in the current opcode[] the frag ends */
- symbolS *fadd;
- long foff;
- int fragty;
- } fragb[4];
-
- int nrel; /* Num of reloc strucs in use */
- struct {
- int n;
- symbolS *add,
- *sub,
- *got;
- long off;
- char wid;
- char pcrel;
- enum reloc_type rtype;
- } reloc[5]; /* Five is enough??? */
-};
-
-#define cpu_of_arch(x) ((x) & m68000up)
-#define float_of_arch(x) ((x) & mfloat)
-#define mmu_of_arch(x) ((x) & mmmu)
-
-static struct m68k_it the_ins; /* the instruction being assembled */
-
-/* Macros for adding things to the m68k_it struct */
-
-#define addword(w) the_ins.opcode[the_ins.numo++]=(w)
-
-/* Like addword, but goes BEFORE general operands */
-#define insop(w) { \
- int z; \
- for (z=the_ins.numo;z>opcode->m_codenum;--z) \
- the_ins.opcode[z]=the_ins.opcode[z-1]; \
- for (z=0;z<the_ins.nrel;z++) \
- the_ins.reloc[z].n+=2; \
- the_ins.opcode[opcode->m_codenum]=w; \
- the_ins.numo++; \
- }
-
-
-#define add_exp(beg,end) (the_ins.exprs[the_ins.nexp].e_beg=beg, \
- the_ins.exprs[the_ins.nexp].e_end=end, \
- &the_ins.exprs[the_ins.nexp++] \
- )
-
-
-/* The numo+1 kludge is so we can hit the low order byte of the prev word. Blecch*/
-#define add_fix(width, exp, pc_rel, r_type) { \
- the_ins.reloc[the_ins.nrel].n= ((width) == 'B') ? (the_ins.numo*2-1) : \
- (((width) == 'b') ? ((the_ins.numo-1)*2) : (the_ins.numo*2)); \
- the_ins.reloc[the_ins.nrel].add=adds((exp)); \
- the_ins.reloc[the_ins.nrel].sub=subs((exp)); \
- the_ins.reloc[the_ins.nrel].off=offs((exp)); \
- the_ins.reloc[the_ins.nrel].got=gots((exp)); \
- the_ins.reloc[the_ins.nrel].wid=width; \
- the_ins.reloc[the_ins.nrel].pcrel=pc_rel; \
- the_ins.reloc[the_ins.nrel++].rtype=r_type; \
- }
-
-#define add_frag(add,off,type) {\
- the_ins.fragb[the_ins.nfrag].fragoff=the_ins.numo;\
- the_ins.fragb[the_ins.nfrag].fadd=add;\
- the_ins.fragb[the_ins.nfrag].foff=off;\
- the_ins.fragb[the_ins.nfrag++].fragty=type;\
- }
-
-#define isvar(exp) ((exp) && (adds(exp) || subs(exp) || gots(exp)))
-
-#define seg(exp) ((exp)->e_exp.X_seg)
-#define adds(exp) ((exp)->e_exp.X_add_symbol)
-#define subs(exp) ((exp)->e_exp.X_subtract_symbol)
-#define offs(exp) ((exp)->e_exp.X_add_number)
-#define gots(exp) ((exp)->e_exp.X_got_symbol)
-
-
-struct m68k_incant {
- char *m_operands;
- unsigned long m_opcode;
- short m_opnum;
- short m_codenum;
- enum m68k_architecture m_arch;
- struct m68k_incant *m_next;
-};
-
-#define getone(x) ((((x)->m_opcode)>>16)&0xffff)
-#define gettwo(x) (((x)->m_opcode)&0xffff)
-
-
-#if __STDC__ == 1
-
-static char *crack_operand(char *str, struct m68k_op *opP);
-static int get_num(struct m68k_exp *exp, int ok);
-static int get_regs(int i, char *str, struct m68k_op *opP);
-static int reverse_16_bits(int in);
-static int reverse_8_bits(int in);
-static int try_index(char **s, struct m68k_op *opP);
-static void install_gen_operand(int mode, int val);
-static void install_operand(int mode, int val);
-static void s_bss(void);
-static void s_data1(void);
-static void s_data2(void);
-static void s_even(void);
-static void s_proc(void);
-
-#else /* not __STDC__ */
-
-static char *crack_operand();
-static int get_num();
-static int get_regs();
-static int reverse_16_bits();
-static int reverse_8_bits();
-static int try_index();
-static void install_gen_operand();
-static void install_operand();
-static void s_bss();
-static void s_data1();
-static void s_data2();
-static void s_even();
-static void s_proc();
-
-#endif /* not __STDC__ */
-
-static enum m68k_architecture current_architecture = 0;
-
-/* BCC68000 is for patching in an extra jmp instruction for long offsets
- on the 68000. The 68000 doesn't support long branches with branchs */
-
-/* This table desribes how you change sizes for the various types of variable
- size expressions. This version only supports two kinds. */
-
-/* Note that calls to frag_var need to specify the maximum expansion needed */
-/* This is currently 10 bytes for DBCC */
-
-/* The fields are:
- How far Forward this mode will reach:
- How far Backward this mode will reach:
- How many bytes this mode will add to the size of the frag
- Which mode to go to if the offset won't fit in this one
- */
-const relax_typeS
- md_relax_table[] = {
- { 1, 1, 0, 0 }, /* First entries aren't used */
- { 1, 1, 0, 0 }, /* For no good reason except */
- { 1, 1, 0, 0 }, /* that the VAX doesn't either */
- { 1, 1, 0, 0 },
-
- { (127), (-128), 0, TAB(BRANCH,SHORT)},
- { (32767), (-32768), 2, TAB(BRANCH,LONG) },
- { 0, 0, 4, 0 },
- { 1, 1, 0, 0 },
-
- { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE */
- { (32767), (-32768), 2, TAB(FBRANCH,LONG)},
- { 0, 0, 4, 0 },
- { 1, 1, 0, 0 },
-
- { 1, 1, 0, 0 }, /* PCREL doesn't come BYTE */
- { (32767), (-32768), 2, TAB(PCREL,LONG)},
- { 0, 0, 4, 0 },
- { 1, 1, 0, 0 },
-
- { (127), (-128), 0, TAB(BCC68000,SHORT)},
- { (32767), (-32768), 2, TAB(BCC68000,LONG) },
- { 0, 0, 6, 0 }, /* jmp long space */
- { 1, 1, 0, 0 },
-
- { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE */
- { (32767), (-32768), 2, TAB(DBCC,LONG) },
- { 0, 0, 10, 0 }, /* bra/jmp long space */
- { 1, 1, 0, 0 },
-
- { 1, 1, 0, 0 }, /* PCLEA doesn't come BYTE */
- { 32767, -32768, 2, TAB(PCLEA,LONG) },
- { 0, 0, 6, 0 },
- { 1, 1, 0, 0 },
-
- };
-
-/* These are the machine dependent pseudo-ops. These are included so
- the assembler can work on the output from the SUN C compiler, which
- generates these.
- */
-
-/* This table describes all the machine specific pseudo-ops the assembler
- has to support. The fields are:
- pseudo-op name without dot
- function to call to execute this pseudo-op
- Integer arg to pass to the function
- */
-const pseudo_typeS md_pseudo_table[] = {
- { "data1", s_data1, 0 },
- { "data2", s_data2, 0 },
- { "bss", s_bss, 0 },
- { "even", s_even, 0 },
- { "skip", s_space, 0 },
- { "proc", s_proc, 0 },
- { 0, 0, 0 }
-};
-
-
-/* #define isbyte(x) ((x) >= -128 && (x) <= 127) */
-/* #define isword(x) ((x) >= -32768 && (x) <= 32767) */
-
-#define issbyte(x) ((x) >= -128 && (x) <= 127)
-#define isubyte(x) ((x) >= 0 && (x) <= 255)
-#define issword(x) ((x) >= -32768 && (x) <= 32767)
-#define isuword(x) ((x) >= 0 && (x) <= 65535)
-
-#define isbyte(x) ((x) >= -128 && (x) <= 255)
-#define isword(x) ((x) >= -32768 && (x) <= 65535)
-#define islong(x) (1)
-
-extern char *input_line_pointer;
-
-enum {
- FAIL = 0,
- OK = 1,
-};
-
-/* JF these tables here are for speed at the expense of size */
-/* You can replace them with the #if 0 versions if you really
- need space and don't mind it running a bit slower */
-
-static char mklower_table[256];
-#define mklower(c) (mklower_table[(unsigned char)(c)])
-static char notend_table[256];
-static char alt_notend_table[256];
-#define notend(s) (!(notend_table[(unsigned char)(*s)] || (*s == ':' &&\
- alt_notend_table[(unsigned char)(s[1])])))
-
-#if 0
-#define mklower(c) (isupper(c) ? tolower(c) : c)
-#endif
-
-/* Handle the extra arg for fix_new when doing PIC */
-#ifdef PIC
-#define FIX_NO_RELOC NO_RELOC, NULL
-#else
-#define FIX_NO_RELOC NO_RELOC
-#endif /* PIC */
-
-
-/* JF modified this to handle cases where the first part of a symbol name
- looks like a register */
-
-/*
- * m68k_reg_parse() := if it looks like a register, return it's token &
- * advance the pointer.
- */
-
-enum _register m68k_reg_parse(ccp)
-register char **ccp;
-{
-#ifndef MAX_REG_NAME_LEN
-#define MAX_REG_NAME_LEN (6)
-#endif /* MAX_REG_NAME_LEN */
- register char c[MAX_REG_NAME_LEN];
- char *p, *q;
- register int n = 0,
- ret = FAIL;
-
- c[0] = mklower(ccp[0][0]);
-#ifdef REGISTER_PREFIX
- if (c[0] != REGISTER_PREFIX) {
- return(FAIL);
- } /* need prefix */
-#endif
-
- for (p = c, q = ccp[0]; p < c + MAX_REG_NAME_LEN; ++p, ++q)
- {
- if (*q == 0)
- {
- *p = 0;
- break;
- }
- else
- *p = mklower(*q);
- } /* downcase */
-
- switch (c[0]) {
- case 'a':
- if (c[1] >= '0' && c[1] <= '7') {
- n=2;
- ret=ADDR+c[1]-'0';
- }
-#ifndef NO_68851
- else if (c[1] == 'c') {
- n = 2;
- ret = AC;
- }
-#endif
- break;
-#ifndef NO_68851
- case 'b':
- if (c[1] == 'a') {
- if (c[2] == 'd') {
- if (c[3] >= '0' && c[3] <= '7') {
- n = 4;
- ret = BAD + c[3] - '0';
- }
- } /* BAD */
- if (c[2] == 'c') {
- if (c[3] >= '0' && c[3] <= '7') {
- n = 4;
- ret = BAC + c[3] - '0';
- }
- } /* BAC */
- } else if (c[1] == 'c') {
- n = 2;
- ret = BC;
- } /* BC */
- break;
-#endif
- case 'c':
-#ifndef NO_68851
- if (c[1] == 'a' && c[2] == 'l') {
- n = 3;
- ret = CAL;
- } else
-#endif
- /* This supports both CCR and CC as the ccr reg. */
- if (c[1] == 'c' && c[2] == 'r') {
- n=3;
- ret = CCR;
- } else if (c[1] == 'c') {
- n=2;
- ret = CCR;
- } else if (c[1] == 'a' && (c[2] == 'a' || c[2] == 'c') && c[3] == 'r') {
- n=4;
- ret = c[2] == 'a' ? CAAR : CACR;
- }
-#ifndef NO_68851
- else if (c[1] == 'r' && c[2] == 'p') {
- n = 3;
- ret = (CRP);
- }
-#endif
- break;
- case 'd':
- if (c[1] >= '0' && c[1] <= '7') {
- n = 2;
- ret = DATA + c[1] - '0';
- } else if (c[1] == 'f' && c[2] == 'c') {
- n = 3;
- ret = DFC;
- } else if (c[1] == 'c') {
- n = 2;
- ret = DC;
- } else if (c[1] == 't' && c[2] == 't') {
- if ('0' <= c[3] && c[3] <= '1') {
- n = 4;
- ret = DTT0 + (c[3] - '0');
- } /* DTT[01] */
- }
-#ifndef NO_68851
- else if (c[1] == 'r' && c[2] == 'p') {
- n = 3;
- ret = (DRP);
- }
-#endif
- break;
- case 'f':
- if (c[1] == 'p') {
- if (c[2] >= '0' && c[2] <= '7') {
- n=3;
- ret = FPREG+c[2]-'0';
- if (c[3] == ':')
- ccp[0][3]=',';
- } else if (c[2] == 'i') {
- n=3;
- ret = FPI;
- } else if (c[2] == 's') {
- n= (c[3] == 'r' ? 4 : 3);
- ret = FPS;
- } else if (c[2] == 'c') {
- n= (c[3] == 'r' ? 4 : 3);
- ret = FPC;
- }
- }
- break;
- case 'i':
- if (c[1] == 's' && c[2] == 'p') {
- n = 3;
- ret = ISP;
- } else if (c[1] == 'c') {
- n = 2;
- ret = IC;
- } else if (c[1] == 't' && c[2] == 't') {
- if ('0' <= c[3] && c[3] <= '1') {
- n = 4;
- ret = ITT0 + (c[3] - '0');
- } /* ITT[01] */
- }
- break;
- case 'm':
- if (c[1] == 's' && c[2] == 'p') {
- n = 3;
- ret = MSP;
- } else if (c[1] == 'm' && c[2] == 'u' && c[3] == 's' && c[4] == 'r') {
- n = 5;
- ret = MMUSR;
- }
- break;
- case 'n':
- if (c[1] == 'c') {
- n = 2;
- ret = NC;
- }
- break;
- case 'p':
- if (c[1] == 'c') {
-#ifndef NO_68851
- if (c[2] == 's' && c[3] == 'r') {
- n=4;
- ret = (PCSR);
- } else
-#endif
- {
- n=2;
- ret = PC;
- }
- }
-#ifndef NO_68851
- else if (c[1] == 's' && c[2] == 'r') {
- n = 3;
- ret = (PSR);
- }
-#endif
- break;
- case 's':
-#ifndef NO_68851
- if (c[1] == 'c' && c[2] == 'c') {
- n = 3;
- ret = (SCC);
- } else
-#endif
- if (c[1] == 'r') {
- if (c[2] == 'p') {
- n = 3;
- ret = SRP;
- } else {
- n = 2;
- ret = SR;
- } /* srp else sr */
- } else if (c[1] == 'p') {
- n = 2;
- ret = SP;
- } else if (c[1] == 'f' && c[2] == 'c') {
- n = 3;
- ret = SFC;
- }
- break;
- case 't':
- if (c[1] == 'c') {
- n = 2;
- ret = TC;
- }
- break;
- case 'u':
- if (c[1] == 's' && c[2] == 'p') {
- n=3;
- ret = USP;
- } else if (c[1] == 'r' && c[2] == 'p') {
- n = 3;
- ret = URP;
- }
- break;
- case 'v':
-#ifndef NO_68851
- if (c[1] == 'a' && c[2] == 'l') {
- n = 3;
- ret = (VAL);
- } else
-#endif
- if (c[1] == 'b' && c[2] == 'r') {
- n=3;
- ret = VBR;
- }
- break;
- case 'z':
- if (c[1] == 'p' && c[2] == 'c') {
- n=3;
- ret = ZPC;
- }
- break;
- default:
- break;
- }
- if (n) {
-#ifdef REGISTER_PREFIX
- n++;
-#endif
- if (isalnum(ccp[0][n]) || ccp[0][n] == '_')
- ret=FAIL;
- else
- ccp[0]+=n;
- } else
- ret = FAIL;
- return ret;
-}
-
-#define SKIP_WHITE() { str++; if (*str == ' ') str++;}
-
-/*
- * m68k_ip_op := '#' + <anything>
- * | <register> + range_sep + get_regs
- * ;
- *
- * range_sep := '/' | '-' ;
- *
- * SKIP_WHITE := <empty> | ' ' ;
- *
- */
-
-int
- m68k_ip_op(str,opP)
-char *str;
-register struct m68k_op *opP;
-{
- char *strend;
- long i;
- char *parse_index();
-
- if (*str == ' ') {
- str++;
- } /* Find the beginning of the string */
-
- if (!*str) {
- opP->error="Missing operand";
- return FAIL;
- } /* Out of gas */
-
- for (strend = str; *strend; strend++) ;;
-
- --strend;
-
- if (*str == '#') {
- str++;
- opP->con1=add_exp(str,strend);
- opP->mode=IMMED;
- return OK;
- } /* Guess what: A constant. Shar and enjoy */
-
- i = m68k_reg_parse(&str);
-
- /* is a register, is exactly a register, and is followed by '@' */
-
- if ((i == FAIL || *str != '\0') && *str != '@') {
- char *stmp;
-
- if (i != FAIL && (*str == '/' || *str == '-')) {
- opP->mode=REGLST;
- return(get_regs(i,str,opP));
- }
- if ((stmp=strchr(str,'@')) != '\0') {
- opP->con1=add_exp(str,stmp-1);
- if (stmp == strend) {
- opP->mode=AINDX;
- return(OK);
- }
-
- if ((current_architecture & m68020up) == 0) {
- return(FAIL);
- } /* if target is not a '20 or better */
-
- stmp++;
- if (*stmp++ != '(' || *strend-- != ')') {
- opP->error="Malformed operand";
- return(FAIL);
- }
- i=try_index(&stmp,opP);
- opP->con2=add_exp(stmp,strend);
-
- if (i == FAIL) {
- opP->mode=AMIND;
- } else {
- opP->mode=APODX;
- }
- return(OK);
- } /* if there's an '@' */
- opP->mode = ABSL;
- opP->con1 = add_exp(str,strend);
- return(OK);
- } /* not a register, not exactly a register, or no '@' */
-
- opP->reg=i;
-
- if (*str == '\0') {
- if (i >= DATA+0 && i <= DATA+7)
- opP->mode=DREG;
- else if (i >= ADDR+0 && i <= ADDR+7)
- opP->mode=AREG;
- else
- opP->mode=MSCR;
- return OK;
- }
-
- if ((i<ADDR+0 || i>ADDR+7) && i != PC && i != ZPC && i != FAIL) { /* Can't indirect off non address regs */
- opP->error="Invalid indirect register";
- return FAIL;
- }
- know(*str == '@');
-
- str++;
- switch (*str) {
- case '\0':
- opP->mode=AINDR;
- return OK;
- case '-':
- opP->mode=ADEC;
- return OK;
- case '+':
- opP->mode=AINC;
- return OK;
- case '(':
- str++;
- break;
- default:
- opP->error="Junk after indirect";
- return FAIL;
- }
- /* Some kind of indexing involved. Lets find out how bad it is */
- i=try_index(&str,opP);
- /* Didn't start with an index reg, maybe its offset or offset,reg */
- if (i == FAIL) {
- char *beg_str;
-
- beg_str=str;
- for (i=1;i;) {
- switch (*str++) {
- case '\0':
- opP->error="Missing )";
- return FAIL;
- case ',': i=0; break;
- case '(': i++; break;
- case ')': --i; break;
- }
- }
- /* if (str[-3] == ':') {
- int siz;
-
- switch (str[-2]) {
- case 'b':
- case 'B':
- siz=1;
- break;
- case 'w':
- case 'W':
- siz=2;
- break;
- case 'l':
- case 'L':
- siz=3;
- break;
- default:
- opP->error="Specified size isn't :w or :l";
- return FAIL;
- }
- opP->con1=add_exp(beg_str,str-4);
- opP->con1->e_siz=siz;
- } else */
- opP->con1=add_exp(beg_str,str-2);
- /* Should be offset,reg */
- if (str[-1] == ',') {
- i=try_index(&str,opP);
- if (i == FAIL) {
- opP->error="Malformed index reg";
- return FAIL;
- }
- }
- }
- /* We've now got offset) offset,reg) or reg) */
-
- if (*str == '\0') {
- /* Th-the-thats all folks */
- if (opP->reg == FAIL) opP->mode = AINDX; /* Other form of indirect */
- else if (opP->ireg == FAIL) opP->mode = AOFF;
- else opP->mode = AINDX;
- return(OK);
- }
- /* Next thing had better be another @ */
- if (*str != '@' || str[1] != '(') {
- opP->error = "junk after indirect";
- return(FAIL);
- }
-
- if ((current_architecture & m68020up) == 0) {
- return(FAIL);
- } /* if target is not a '20 or better */
-
- str+=2;
-
- if (opP->ireg != FAIL) {
- opP->mode = APRDX;
-
- i = try_index(&str, opP);
- if (i != FAIL) {
- opP->error = "Two index registers! not allowed!";
- return(FAIL);
- }
- } else {
- i = try_index(&str, opP);
- }
-
- if (i == FAIL) {
- char *beg_str;
-
- beg_str = str;
-
- for (i = 1; i; ) {
- switch (*str++) {
- case '\0':
- opP->error="Missing )";
- return(FAIL);
- case ',': i=0; break;
- case '(': i++; break;
- case ')': --i; break;
- }
- }
-
- opP->con2=add_exp(beg_str,str-2);
-
- if (str[-1] == ',') {
- if (opP->ireg != FAIL) {
- opP->error = "Can't have two index regs";
- return(FAIL);
- }
-
- i = try_index(&str, opP);
-
- if (i == FAIL) {
- opP->error = "malformed index reg";
- return(FAIL);
- }
-
- opP->mode = APODX;
- } else if (opP->ireg != FAIL) {
- opP->mode = APRDX;
- } else {
- opP->mode = AMIND;
- }
- } else {
- opP->mode = APODX;
- }
-
- if (*str != '\0') {
- opP->error="Junk after indirect";
- return FAIL;
- }
- return(OK);
-} /* m68k_ip_op() */
-
-/*
- *
- * try_index := data_or_address_register + ')' + SKIP_W
- * | data_or_address_register + ':' + SKIP_W + size_spec + SKIP_W + multiplier + ')' + SKIP_W
- *
- * multiplier := <empty>
- * | ':' + multiplier_number
- * ;
- *
- * multiplier_number := '1' | '2' | '4' | '8' ;
- *
- * size_spec := 'l' | 'L' | 'w' | 'W' ;
- *
- * SKIP_W := <empty> | ' ' ;
- *
- */
-
-static int try_index(s,opP)
-char **s;
-struct m68k_op *opP;
-{
- register int i;
- char *ss;
-#define SKIP_W() { ss++; if (*ss == ' ') ss++;}
-
- ss= *s;
- /* SKIP_W(); */
- i=m68k_reg_parse(&ss);
- if (!(i >= DATA+0 && i <= ADDR+7)) { /* if i is not DATA or ADDR reg */
- *s=ss;
- return FAIL;
- }
- opP->ireg=i;
- /* SKIP_W(); */
- if (*ss == ')') {
- opP->isiz=0;
- opP->imul=1;
- SKIP_W();
- *s=ss;
- return OK;
- }
- if (*ss != ':') {
- opP->error="Missing : in index register";
- *s=ss;
- return FAIL;
- }
- SKIP_W();
- switch (*ss) {
- case 'w':
- case 'W':
- opP->isiz=2;
- break;
- case 'l':
- case 'L':
- opP->isiz=3;
- break;
- default:
- opP->error="Index register size spec not :w or :l";
- *s=ss;
- return FAIL;
- }
- SKIP_W();
- if (*ss == ':') {
- SKIP_W();
- switch (*ss) {
- case '1':
- case '2':
- case '4':
- case '8':
- opP->imul= *ss-'0';
- break;
- default:
- opP->error="index multiplier not 1, 2, 4 or 8";
- *s=ss;
- return FAIL;
- }
- SKIP_W();
- } else opP->imul=1;
- if (*ss != ')') {
- opP->error="Missing )";
- *s=ss;
- return FAIL;
- }
- SKIP_W();
- *s=ss;
- return OK;
-} /* try_index() */
-
-#ifdef TEST1 /* TEST1 tests m68k_ip_op(), which parses operands */
-main()
-{
- char buf[128];
- struct m68k_op thark;
-
- for (;;) {
- if (!gets(buf))
- break;
- memset(&thark, '\0', sizeof(thark));
- if (!m68k_ip_op(buf,&thark)) printf("FAIL:");
- if (thark.error)
- printf("op1 error %s in %s\n",thark.error,buf);
- printf("mode %d, reg %d, ",thark.mode,thark.reg);
- if (thark.b_const)
- printf("Constant: '%.*s',",1+thark.e_const-thark.b_const,thark.b_const);
- printf("ireg %d, isiz %d, imul %d ",thark.ireg,thark.isiz,thark.imul);
- if (thark.b_iadd)
- printf("Iadd: '%.*s'",1+thark.e_iadd-thark.b_iadd,thark.b_iadd);
- printf("\n");
- }
- exit(0);
-}
-
-#endif
-
-
-static struct hash_control* op_hash = NULL; /* handle of the OPCODE hash table
- NULL means any use before m68k_ip_begin()
- will crash */
-
-
-/*
- * m 6 8 k _ i p ( )
- *
- * This converts a string into a 68k instruction.
- * The string must be a bare single instruction in sun format
- * with RMS-style 68020 indirects
- * (example: )
- *
- * It provides some error messages: at most one fatal error message (which
- * stops the scan) and at most one warning message for each operand.
- * The 68k instruction is returned in exploded form, since we have no
- * knowledge of how you parse (or evaluate) your expressions.
- * We do however strip off and decode addressing modes and operation
- * mnemonic.
- *
- * This function's value is a string. If it is not "" then an internal
- * logic error was found: read this code to assign meaning to the string.
- * No argument string should generate such an error string:
- * it means a bug in our code, not in the user's text.
- *
- * You MUST have called m68k_ip_begin() once and m86_ip_end() never before using
- * this function.
- */
-
-/* JF this function no longer returns a useful value. Sorry */
-void m68k_ip (instring)
-char *instring;
-{
- register char *p;
- register struct m68k_op *opP;
- register struct m68k_incant *opcode;
- register char *s;
- register int tmpreg = 0,
- baseo = 0,
- outro = 0,
- nextword;
- int siz1,
- siz2;
- char c;
- int losing;
- int opsfound;
- int reloc_type;
- char *crack_operand();
- LITTLENUM_TYPE words[6];
- LITTLENUM_TYPE *wordp;
-
- if (*instring == ' ')
- instring++; /* skip leading whitespace */
-
- /* Scan up to end of operation-code, which MUST end in end-of-string
- or exactly 1 space. */
- for (p = instring; *p != '\0'; p++)
- if (*p == ' ')
- break;
-
-
- if (p == instring) {
- the_ins.error = "No operator";
- the_ins.opcode[0] = NULL;
- /* the_ins.numo=1; */
- return;
- }
-
- /* p now points to the end of the opcode name, probably whitespace.
- make sure the name is null terminated by clobbering the whitespace,
- look it up in the hash table, then fix it back. */
- c = *p;
- *p = '\0';
- opcode = (struct m68k_incant *)hash_find (op_hash, instring);
- *p = c;
-
- if (opcode == NULL) {
- the_ins.error = "Unknown operator";
- the_ins.opcode[0] = NULL;
- /* the_ins.numo=1; */
- return;
- }
-
- /* found a legitimate opcode, start matching operands */
- while (*p == ' ') ++p;
-
- for (opP = &the_ins.operands[0]; *p; opP++) {
-
- p = crack_operand(p, opP);
-
- if (opP->error) {
- the_ins.error=opP->error;
- return;
- }
- }
-
- opsfound = opP - &the_ins.operands[0];
-
- /* This ugly hack is to support the floating pt opcodes in their standard form */
- /* Essentially, we fake a first enty of type COP#1 */
- if (opcode->m_operands[0] == 'I') {
- int n;
-
- for (n=opsfound;n>0;--n)
- the_ins.operands[n]=the_ins.operands[n-1];
-
- /* memcpy((char *)(&the_ins.operands[1]), (char *)(&the_ins.operands[0]), opsfound*sizeof(the_ins.operands[0])); */
- memset((char *)(&the_ins.operands[0]), '\0', sizeof(the_ins.operands[0]));
- the_ins.operands[0].mode=MSCR;
- the_ins.operands[0].reg=COPNUM; /* COP #1 */
- opsfound++;
- }
-
- /* We've got the operands. Find an opcode that'll accept them */
- for (losing = 0; ; ) {
- /* if we didn't get the right number of ops,
- or we have no common model with this pattern
- then reject this pattern. */
-
- if (opsfound != opcode->m_opnum
- || ((opcode->m_arch & current_architecture) == 0)) {
-
- ++losing;
-
- } else {
- for (s=opcode->m_operands, opP = &the_ins.operands[0]; *s && !losing; s += 2, opP++) {
- /* Warning: this switch is huge! */
- /* I've tried to organize the cases into this order:
- non-alpha first, then alpha by letter. lower-case goes directly
- before uppercase counterpart. */
- /* Code with multiple case ...: gets sorted by the lowest case ...
- it belongs to. I hope this makes sense. */
- switch (*s) {
-#ifdef PIC
- case ' ':
- /* this operand is just here to indicate a jump-table branch */
- if (!picmode)
- losing++;
- break;
-#endif /* PIC */
-
- case '!':
- if (opP->mode == MSCR || opP->mode == IMMED
- || opP->mode == DREG || opP->mode == AREG
- || opP->mode == AINC || opP->mode == ADEC
- || opP->mode == REGLST)
- losing++;
- break;
-
- case '#':
- if (opP->mode != IMMED)
- losing++;
- else {
- long t;
-
- t=get_num(opP->con1,80);
- if (s[1] == 'b' && !isbyte(t))
- losing++;
- else if (s[1] == 'w' && !isword(t))
- losing++;
- }
- break;
-
- case '^':
- case 'T':
- if (opP->mode != IMMED)
- losing++;
- break;
-
- case '$':
- if (opP->mode == MSCR || opP->mode == AREG ||
- opP->mode == IMMED || opP->reg == PC || opP->reg == ZPC || opP->mode == REGLST)
- losing++;
- break;
-
- case '%':
- if (opP->mode == MSCR || opP->reg == PC ||
- opP->reg == ZPC || opP->mode == REGLST)
- losing++;
- break;
-
-
- case '&':
- if (opP->mode == MSCR || opP->mode == DREG ||
- opP->mode == AREG || opP->mode == IMMED || opP->reg == PC || opP->reg == ZPC ||
- opP->mode == AINC || opP->mode == ADEC || opP->mode == REGLST)
- losing++;
- break;
-
- case '*':
- if (opP->mode == MSCR || opP->mode == REGLST)
- losing++;
- break;
-
- case '+':
- if (opP->mode != AINC)
- losing++;
- break;
-
- case '-':
- if (opP->mode != ADEC)
- losing++;
- break;
-
- case '/':
- if (opP->mode == MSCR || opP->mode == AREG ||
- opP->mode == AINC || opP->mode == ADEC || opP->mode == IMMED || opP->mode == REGLST)
- losing++;
- break;
-
- case ';':
- if (opP->mode == MSCR || opP->mode == AREG || opP->mode == REGLST)
- losing++;
- break;
-
- case '?':
- if (opP->mode == MSCR || opP->mode == AREG ||
- opP->mode == AINC || opP->mode == ADEC || opP->mode == IMMED || opP->reg == PC ||
- opP->reg == ZPC || opP->mode == REGLST)
- losing++;
- break;
-
- case '@':
- if (opP->mode == MSCR || opP->mode == AREG ||
- opP->mode == IMMED || opP->mode == REGLST)
- losing++;
- break;
-
- case '~': /* For now! (JF FOO is this right?) */
- if (opP->mode == MSCR || opP->mode == DREG ||
- opP->mode == AREG || opP->mode == IMMED || opP->reg == PC || opP->reg == ZPC || opP->mode == REGLST)
- losing++;
- break;
-
- case 'A':
- if (opP->mode != AREG)
- losing++;
- break;
- case 'a':
- if (opP->mode != AINDR) {
- ++losing;
- } /* if not address register indirect */
- break;
- case 'B': /* FOO */
- if (opP->mode != ABSL || (flagseen['S'] && instring[0] == 'j'
- && instring[1] == 'b'
- && instring[2] == 's'
- && instring[3] == 'r'))
- losing++;
- break;
-
- case 'C':
- if (opP->mode != MSCR || opP->reg != CCR)
- losing++;
- break;
-
- case 'd': /* FOO This mode is a KLUDGE!! */
- if (opP->mode != AOFF && (opP->mode != ABSL ||
- opP->con1->e_beg[0] != '(' || opP->con1->e_end[0] != ')'))
- losing++;
- break;
-
- case 'D':
- if (opP->mode != DREG)
- losing++;
- break;
-
- case 'F':
- if (opP->mode != MSCR || opP->reg<(FPREG+0) || opP->reg>(FPREG+7))
- losing++;
- break;
-
- case 'I':
- if (opP->mode != MSCR || opP->reg<COPNUM ||
- opP->reg >= COPNUM+7)
- losing++;
- break;
-
- case 'J':
- if (opP->mode != MSCR
- || opP->reg < USP
- || opP->reg > URP
- || cpu_of_arch(current_architecture) < m68010 /* before 68010 had none */
- || (cpu_of_arch(current_architecture) < m68020
- && opP->reg != SFC
- && opP->reg != DFC
- && opP->reg != USP
- && opP->reg != VBR) /* 68010's had only these */
- || (cpu_of_arch(current_architecture) < m68040
- && opP->reg != SFC
- && opP->reg != DFC
- && opP->reg != USP
- && opP->reg != VBR
- && opP->reg != CACR
- && opP->reg != CAAR
- && opP->reg != MSP
- && opP->reg != ISP) /* 680[23]0's have only these */
- || (cpu_of_arch(current_architecture) == m68040 /* 68040 has all but this */
- && opP->reg == CAAR)) {
- losing++;
- } /* doesn't cut it */
- break;
-
- case 'k':
- if (opP->mode != IMMED)
- losing++;
- break;
-
- case 'l':
- case 'L':
- if (opP->mode == DREG || opP->mode == AREG || opP->mode == FPREG) {
- if (s[1] == '8')
- losing++;
- else {
- opP->mode=REGLST;
- opP->reg=1<<(opP->reg-DATA);
- }
- } else if (opP->mode != REGLST) {
- losing++;
- } else if (s[1] == '8' && opP->reg&0x0FFffFF)
- losing++;
- else if (s[1] == '3' && opP->reg&0x7000000)
- losing++;
- break;
-
- case 'M':
- if (opP->mode != IMMED)
- losing++;
- else {
- long t;
-
- t=get_num(opP->con1,80);
- if (!issbyte(t) || isvar(opP->con1))
- losing++;
- }
- break;
-
- case 'O':
- if (opP->mode != DREG && opP->mode != IMMED)
- losing++;
- break;
-
- case 'Q':
- if (opP->mode != IMMED)
- losing++;
- else {
- long t;
-
- t=get_num(opP->con1,80);
- if (t<1 || t>8 || isvar(opP->con1))
- losing++;
- }
- break;
-
- case 'R':
- if (opP->mode != DREG && opP->mode != AREG)
- losing++;
- break;
-
- case 's':
- if (opP->mode != MSCR || !(opP->reg == FPI || opP->reg == FPS || opP->reg == FPC))
- losing++;
- break;
-
- case 'S':
- if (opP->mode != MSCR || opP->reg != SR)
- losing++;
- break;
-
- case 'U':
- if (opP->mode != MSCR || opP->reg != USP)
- losing++;
- break;
-
- /* JF these are out of order. We could put them
- in order if we were willing to put up with
- bunches of #ifdef m68851s in the code */
-#ifndef NO_68851
- /* Memory addressing mode used by pflushr */
- case '|':
- if (opP->mode == MSCR || opP->mode == DREG ||
- opP->mode == AREG || opP->mode == REGLST)
- losing++;
- break;
-
- case 'f':
- if (opP->mode != MSCR || (opP->reg != SFC && opP->reg != DFC))
- losing++;
- break;
-
- case 'P':
- if (opP->mode != MSCR || (opP->reg != TC && opP->reg != CAL &&
- opP->reg != VAL && opP->reg != SCC && opP->reg != AC))
- losing++;
- break;
-
- case 'V':
- if (opP->reg != VAL)
- losing++;
- break;
-
- case 'W':
- if (opP->mode != MSCR || (opP->reg != DRP && opP->reg != SRP &&
- opP->reg != CRP))
- losing++;
- break;
-
- case 'X':
- if (opP->mode != MSCR ||
- (!(opP->reg >= BAD && opP->reg <= BAD+7) &&
- !(opP->reg >= BAC && opP->reg <= BAC+7)))
- losing++;
- break;
-
- case 'Y':
- if (opP->reg != PSR)
- losing++;
- break;
-
- case 'Z':
- if (opP->reg != PCSR)
- losing++;
- break;
-#endif
- case 'c':
- if (opP->reg != NC
- && opP->reg != IC
- && opP->reg != DC
- && opP->reg != BC) {
- losing++;
- } /* not a cache specifier. */
- break;
-
- case '_':
- if (opP->mode != ABSL) {
- ++losing;
- } /* not absolute */
- break;
-
- default:
- as_fatal("Internal error: Operand mode %c unknown in line %s of file \"%s\"",
- *s, __LINE__, __FILE__);
- } /* switch on type of operand */
-
- if (losing) break;
- } /* for each operand */
- } /* if immediately wrong */
-
- if (!losing) {
- break;
- } /* got it. */
-
- opcode = opcode->m_next;
-
- if (!opcode) {
- the_ins.error = "instruction/operands mismatch";
- return;
- } /* Fell off the end */
-
- losing = 0;
- }
-
- /* now assemble it */
-
- the_ins.args=opcode->m_operands;
- the_ins.numargs=opcode->m_opnum;
- the_ins.numo=opcode->m_codenum;
- the_ins.opcode[0]=getone(opcode);
- the_ins.opcode[1]=gettwo(opcode);
-
- for (s = the_ins.args, opP = &the_ins.operands[0]; *s; s += 2, opP++) {
- /* This switch is a doozy.
- Watch the first step; its a big one! */
- switch (s[0]) {
-
-#ifdef PIC
- case ' ':
- /* this operand is just here to indicate a jump-table branch */
- break;
-#endif /* PIC */
-
- case '*':
- case '~':
- case '%':
- case ';':
- case '@':
- case '!':
- case '&':
- case '$':
- case '?':
- case '/':
-#ifndef NO_68851
- case '|':
-#endif
-
-#ifdef PIC
- /* Use GLOB_DAT for operand references in PIC mode */
- if (picmode)
- reloc_type = RELOC_GLOB_DAT;
- else
-#endif /* PIC */
- reloc_type = NO_RELOC;
-
- switch (opP->mode) {
- int literal;
-
- case IMMED:
- tmpreg=0x3c; /* 7.4 */
- if (*opP->con1->e_beg == ':') {
- ++opP->con1->e_beg;
- literal = 1;
- } else
- literal = 0;
- if (strchr("bwl",s[1])) nextword=get_num(opP->con1,80);
- else nextword=nextword=get_num(opP->con1,0);
- if (isvar(opP->con1)) {
-#ifdef PIC
- /* KLUDGE!!! In PIC assembly, an immediate reference to
- __GLOBAL_OFFSET_TABLE_ is turned into a pc-relative
- reference to __GLOBAL_OFFSET_TABLE_ - 6,
- for the sake of Sun compatibility. */
- if (s[1] == 'l' && picmode && gots(opP->con1)) {
- offs(opP->con1) -= 6;
- add_fix(s[1], opP->con1, 1, NO_RELOC);
- } else
-#endif /* PIC */
- add_fix(s[1],opP->con1,0,reloc_type);
- }
- switch (s[1]) {
- case 'b':
- if (!isbyte(nextword))
- opP->error="operand out of range";
- addword(nextword);
- baseo=0;
- break;
- case 'w':
- if (!isword(nextword))
- opP->error="operand out of range";
- addword(nextword);
- baseo=0;
- break;
- case 'l':
- addword(nextword>>16);
- addword(nextword);
- baseo=0;
- break;
-
- case 'f':
- baseo=2;
- outro=8;
- break;
- case 'F':
- baseo=4;
- outro=11;
- break;
- case 'x':
- baseo=6;
- outro=15;
- break;
- case 'p':
- baseo=6;
- outro= -1;
- break;
- default:
- as_fatal("Internal error: Can't decode %c%c in line %s of file \"%s\"",
- *s, s[1], __LINE__, __FILE__);
- }
- if (!baseo)
- break;
-
- if (literal) {
- if (seg(opP->con1) == SEG_BIG)
- goto bignum;
- while (baseo -= 2) {
- addword(0);
- addword(0);
- }
- addword(nextword>>16);
- addword(nextword);
- break;
- }
-
- /* We gotta put out some float */
- if (seg(opP->con1) != SEG_BIG) {
- int_to_gen(nextword);
- gen_to_words(words,baseo,(long int)outro);
- for (wordp=words;baseo--;wordp++)
- addword(*wordp);
- break;
- } /* Its BIG */
- if (offs(opP->con1)>0) {
- as_warn("Bignum assumed to be binary bit-pattern");
- bignum:
- if (offs(opP->con1)>baseo) {
- as_warn("Bignum too big for %c format; truncated",s[1]);
- offs(opP->con1)=baseo;
- }
- baseo-=offs(opP->con1);
- for (wordp=generic_bignum+offs(opP->con1)-1;offs(opP->con1)--;--wordp)
- addword(*wordp);
- while (baseo--)
- addword(0);
- break;
- }
- gen_to_words(words,baseo,(long)outro);
- for (wordp=words;baseo--;wordp++)
- addword(*wordp);
- break;
- case DREG:
- tmpreg=opP->reg-DATA; /* 0.dreg */
- break;
- case AREG:
- tmpreg=0x08+opP->reg-ADDR; /* 1.areg */
- break;
- case AINDR:
- tmpreg=0x10+opP->reg-ADDR; /* 2.areg */
- break;
- case ADEC:
- tmpreg=0x20+opP->reg-ADDR; /* 4.areg */
- break;
- case AINC:
- tmpreg=0x18+opP->reg-ADDR; /* 3.areg */
- break;
- case AOFF:
-
- nextword=get_num(opP->con1,80);
- /* Force into index mode. Hope this works */
-
- /* We do the first bit for 32-bit displacements,
- and the second bit for 16 bit ones. It is
- possible that we should make the default be
- WORD instead of LONG, but I think that'd
- break GCC, so we put up with a little
- inefficiency for the sake of working output.
- */
-
- if ( !issword(nextword)
- || ( isvar(opP->con1)
- && ((opP->con1->e_siz == 0
- && flagseen['l'] == 0)
- || opP->con1->e_siz == 3))) {
-
- if (opP->reg == PC)
- tmpreg=0x3B; /* 7.3 */
- else
- tmpreg=0x30+opP->reg-ADDR; /* 6.areg */
- if (isvar(opP->con1)) {
- if (opP->reg == PC && !subs(opP->con1)) {
- add_frag(adds(opP->con1),
- offs(opP->con1),
- TAB(PCLEA,SZ_UNDEF));
- break;
- } else {
- addword(0x0170);
- add_fix('l',opP->con1,0,reloc_type);
- }
- } else
- addword(0x0170);
- addword(nextword>>16);
- } else {
- if (opP->reg == PC)
- tmpreg=0x3A; /* 7.2 */
- else
- tmpreg=0x28+opP->reg-ADDR; /* 5.areg */
-
- if (isvar(opP->con1)) {
- if (opP->reg == PC) {
- add_fix('w',opP->con1,1,NO_RELOC);
- } else
- add_fix('w',opP->con1,0,reloc_type);
- }
- }
- addword(nextword);
- break;
-
- case APODX:
- case AMIND:
- case APRDX:
- know(current_architecture & m68020up);
- /* intentional fall-through */
- case AINDX:
- nextword=0;
- baseo=get_num(opP->con1,80);
- outro=get_num(opP->con2,80);
- /* Figure out the 'addressing mode' */
- /* Also turn on the BASE_DISABLE bit, if needed */
- if (opP->reg == PC || opP->reg == ZPC) {
- tmpreg=0x3b; /* 7.3 */
- if (opP->reg == ZPC)
- nextword|=0x80;
- } else if (opP->reg == FAIL) {
- nextword|=0x80;
- tmpreg=0x30; /* 6.garbage */
- } else tmpreg=0x30+opP->reg-ADDR; /* 6.areg */
-
- siz1= (opP->con1) ? opP->con1->e_siz : 0;
- siz2= (opP->con2) ? opP->con2->e_siz : 0;
-
- /* Index register stuff */
- if (opP->ireg >= DATA+0 && opP->ireg <= ADDR+7) {
- nextword|=(opP->ireg-DATA)<<12;
-
- if (opP->isiz == 0 || opP->isiz == 3)
- nextword|=0x800;
- switch (opP->imul) {
- case 1: break;
- case 2: nextword|=0x200; break;
- case 4: nextword|=0x400; break;
- case 8: nextword|=0x600; break;
- default: as_fatal("failed sanity check.");
- }
- /* IF its simple,
- GET US OUT OF HERE! */
-
- /* Must be INDEX, with an index
- register. Address register
- cannot be ZERO-PC, and either
- :b was forced, or we know
- it will fit */
- if (opP->mode == AINDX
- && opP->reg != FAIL
- && opP->reg != ZPC
- && (siz1 == 1
- || ( issbyte(baseo)
- && !isvar(opP->con1)))) {
- nextword +=baseo&0xff;
- addword(nextword);
- if (isvar(opP->con1))
- add_fix('B',opP->con1,0,reloc_type);
- break;
- }
- } else
- nextword|=0x40; /* No index reg */
-
- /* It aint simple */
- nextword|=0x100;
- /* If the guy specified a width, we assume that
- it is wide enough. Maybe it isn't. If so, we lose
- */
- switch (siz1) {
- case 0:
- if (isvar(opP->con1) || !issword(baseo)) {
- siz1=3;
- nextword|=0x30;
- } else if (baseo == 0)
- nextword|=0x10;
- else {
- nextword|=0x20;
- siz1=2;
- }
- break;
- case 1:
- as_warn("Byte dispacement won't work. Defaulting to :w");
- case 2:
- nextword|=0x20;
- break;
- case 3:
- nextword|=0x30;
- break;
- }
-
- /* Figure out innner displacement stuff */
- if (opP->mode != AINDX) {
- switch (siz2) {
- case 0:
- if (isvar(opP->con2) || !issword(outro)) {
- siz2=3;
- nextword|=0x3;
- } else if (outro == 0)
- nextword|=0x1;
- else {
- nextword|=0x2;
- siz2=2;
- }
- break;
- case 1:
- as_warn("Byte dispacement won't work. Defaulting to :w");
- case 2:
- nextword|=0x2;
- break;
- case 3:
- nextword|=0x3;
- break;
- }
- if (opP->mode == APODX) nextword|=0x04;
- else if (opP->mode == AMIND) nextword|=0x40;
- }
- addword(nextword);
-
- if (isvar(opP->con1)) {
- if (opP->reg == PC || opP->reg == ZPC) {
- add_fix(siz1 == 3 ? 'l' : 'w',opP->con1,1,NO_RELOC);
- opP->con1->e_exp.X_add_number+=6;
- } else
- add_fix(siz1 == 3 ? 'l' : 'w',opP->con1,0,reloc_type);
- }
- if (siz1 == 3)
- addword(baseo>>16);
- if (siz1)
- addword(baseo);
-
- if (isvar(opP->con2)) {
- if (opP->reg == PC || opP->reg == ZPC) {
- add_fix(siz2 == 3 ? 'l' : 'w',opP->con2,1,NO_RELOC);
- opP->con1->e_exp.X_add_number+=6;
- } else
- add_fix(siz2 == 3 ? 'l' : 'w',opP->con2,0,reloc_type);
- }
- if (siz2 == 3)
- addword(outro>>16);
- if (siz2)
- addword(outro);
-
- break;
-
- case ABSL:
- nextword=get_num(opP->con1,80);
- switch (opP->con1->e_siz) {
- default:
- as_warn("Unknown size for absolute reference");
- case 0:
- if (!isvar(opP->con1) && issword(offs(opP->con1))) {
- tmpreg=0x38; /* 7.0 */
- addword(nextword);
- break;
- }
- /* Don't generate pc relative code
- on 68010 and 68000 */
- if (isvar(opP->con1)
- && !subs(opP->con1)
- && seg(opP->con1) == SEG_TEXT
- && now_seg == SEG_TEXT
- && cpu_of_arch(current_architecture) >= m68020
- && !flagseen['S']
- && !strchr("~%&$?", s[0])) {
- tmpreg=0x3A; /* 7.2 */
- add_frag(adds(opP->con1),
- offs(opP->con1),
- TAB(PCREL,SZ_UNDEF));
- break;
- }
- case 3: /* Fall through into long */
- if (isvar(opP->con1))
- add_fix('l',opP->con1,0,NO_RELOC);
-
- tmpreg=0x39; /* 7.1 mode */
- addword(nextword>>16);
- addword(nextword);
- break;
-
- case 2: /* Word */
- if (isvar(opP->con1))
- add_fix('w',opP->con1,0,NO_RELOC);
-
- tmpreg=0x38; /* 7.0 mode */
- addword(nextword);
- break;
- }
- break;
- case MSCR:
- default:
- as_bad("unknown/incorrect operand");
- /* abort(); */
- }
- install_gen_operand(s[1],tmpreg);
- break;
-
- case '#':
- case '^':
- switch (s[1]) { /* JF: I hate floating point! */
- case 'j':
- tmpreg=70;
- break;
- case '8':
- tmpreg=20;
- break;
- case 'C':
- tmpreg=50;
- break;
- case '3':
- default:
- tmpreg=80;
- break;
- }
- tmpreg=get_num(opP->con1,tmpreg);
- if (isvar(opP->con1))
- add_fix(s[1],opP->con1,0,NO_RELOC);
- switch (s[1]) {
- case 'b': /* Danger: These do no check for
- certain types of overflow.
- user beware! */
- if (!isbyte(tmpreg))
- opP->error="out of range";
- insop(tmpreg);
- if (isvar(opP->con1))
- the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
- break;
- case 'w':
- if (!isword(tmpreg))
- opP->error="out of range";
- insop(tmpreg);
- if (isvar(opP->con1))
- the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
- break;
- case 'l':
- insop(tmpreg); /* Because of the way insop works, we put these two out backwards */
- insop(tmpreg>>16);
- if (isvar(opP->con1))
- the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
- break;
- case '3':
- tmpreg&=0xFF;
- case '8':
- case 'C':
- install_operand(s[1],tmpreg);
- break;
- default:
- as_fatal("Internal error: Unknown mode #%c in line %s of file \"%s\"", s[1], __LINE__, __FILE__);
- }
- break;
-
- case '+':
- case '-':
- case 'A':
- case 'a':
- install_operand(s[1], opP->reg - ADDR);
- break;
-
- case 'B':
- tmpreg = get_num(opP->con1, 80);
- switch (s[1]) {
- case 'B':
- /* Offset is relative to next word */
- opP->con1->e_exp.X_add_number -= 1;
- add_fix('B', opP->con1, 1,NO_RELOC);
- break;
- case 'W':
- add_fix('w', opP->con1, 1,NO_RELOC);
- addword(0);
- break;
- case 'L':
- long_branch:
- if (cpu_of_arch(current_architecture) < m68020) /* 68000 or 010 */
- as_warn("Can't use long branches on 68000/68010");
- the_ins.opcode[the_ins.numo-1]|=0xff;
- add_fix('l',opP->con1,1,NO_RELOC);
- addword(0);
- addword(0);
- break;
- case 'g':
-#ifdef PIC
- /* If we have the optional kludgey 2nd operand,
- make this go via the jump table. */
- if (picmode && s[2] == ' ') {
- the_ins.opcode[the_ins.numo-1] |= 0xFF;
- add_fix('l', opP->con1, 1, RELOC_JMP_TBL);
- addword(0);
- addword(0);
- break;
- }
-#endif /* PIC */
- if (subs(opP->con1)) /* We can't relax it */
- goto long_branch;
-
- /* This could either be a symbol, or an
- absolute address. No matter, the
- frag hacking will finger it out.
- Not quite: it can't switch from
- BRANCH to BCC68000 for the case
- where opnd is absolute (it needs
- to use the 68000 hack since no
- conditional abs jumps). */
- if (((cpu_of_arch(current_architecture) < m68020) || (0 == adds(opP->con1)))
- && (the_ins.opcode[0] >= 0x6200)
- && (the_ins.opcode[0] <= 0x6f00)) {
- add_frag(adds(opP->con1),offs(opP->con1),TAB(BCC68000,SZ_UNDEF));
- } else {
- add_frag(adds(opP->con1),offs(opP->con1),TAB(BRANCH,SZ_UNDEF));
- }
- break;
- case 'w':
- if (isvar(opP->con1)) {
- /* check for DBcc instruction */
- if ((the_ins.opcode[0] & 0xf0f8) == 0x50c8) {
- /* size varies if patch */
- /* needed for long form */
- add_frag(adds(opP->con1),offs(opP->con1),TAB(DBCC,SZ_UNDEF));
- break;
- }
-
- /* Don't ask! */
- opP->con1->e_exp.X_add_number+=2;
- add_fix('w',opP->con1,1,NO_RELOC);
- }
- addword(0);
- break;
- case 'C': /* Fixed size LONG coproc branches */
- the_ins.opcode[the_ins.numo-1]|=0x40;
- /* Offset the displacement to be relative to byte disp location */
- /* Coproc branches don't have a byte disp option, but they are
- compatible with the ordinary branches, which do... */
- opP->con1->e_exp.X_add_number+=4;
- add_fix('l',opP->con1,1,NO_RELOC);
- addword(0);
- addword(0);
- break;
- case 'c': /* Var size Coprocesssor branches */
- if (subs(opP->con1)) {
- add_fix('l',opP->con1,1,NO_RELOC);
- add_frag((symbolS *)0,(long)0,TAB(FBRANCH,LONG));
- } else if (adds(opP->con1)) {
- add_frag(adds(opP->con1),offs(opP->con1),TAB(FBRANCH,SZ_UNDEF));
- } else {
- /* add_frag((symbolS *)0,offs(opP->con1),TAB(FBRANCH,SHORT)); */
- the_ins.opcode[the_ins.numo-1]|=0x40;
- add_fix('l',opP->con1,1,NO_RELOC);
- addword(0);
- addword(4);
- }
- break;
- default:
- as_fatal("Internal error: operand type B%c unknown in line %s of file \"%s\"",
- s[1], __LINE__, __FILE__);
- }
- break;
-
- case 'C': /* Ignore it */
- break;
-
- case 'd': /* JF this is a kludge */
- if (opP->mode == AOFF) {
- install_operand('s',opP->reg-ADDR);
- } else {
- char *tmpP;
-
- tmpP=opP->con1->e_end-2;
- opP->con1->e_beg++;
- opP->con1->e_end-=4; /* point to the , */
- baseo=m68k_reg_parse(&tmpP);
- if (baseo<ADDR+0 || baseo>ADDR+7) {
- as_bad("Unknown address reg, using A0");
- baseo=0;
- } else baseo-=ADDR;
- install_operand('s',baseo);
- }
- tmpreg=get_num(opP->con1,80);
- if (!issword(tmpreg)) {
- as_warn("Expression out of range, using 0");
- tmpreg=0;
- }
- addword(tmpreg);
- break;
-
- case 'D':
- install_operand(s[1],opP->reg-DATA);
- break;
-
- case 'F':
- install_operand(s[1],opP->reg-FPREG);
- break;
-
- case 'I':
- tmpreg=1+opP->reg-COPNUM;
- if (tmpreg == 8)
- tmpreg=0;
- install_operand(s[1],tmpreg);
- break;
-
- case 'J': /* JF foo */
- switch (opP->reg) {
- case SFC: tmpreg=0x000; break;
- case DFC: tmpreg=0x001; break;
- case CACR: tmpreg=0x002; break;
- case TC: tmpreg=0x003; break;
- case ITT0: tmpreg=0x004; break;
- case ITT1: tmpreg=0x005; break;
- case DTT0: tmpreg=0x006; break;
- case DTT1: tmpreg=0x007; break;
-
- case USP: tmpreg=0x800; break;
- case VBR: tmpreg=0x801; break;
- case CAAR: tmpreg=0x802; break;
- case MSP: tmpreg=0x803; break;
- case ISP: tmpreg=0x804; break;
- case MMUSR: tmpreg=0x805; break;
- case URP: tmpreg=0x806; break;
- case SRP: tmpreg=0x807; break;
- default:
- as_fatal("failed sanity check.");
- }
- install_operand(s[1],tmpreg);
- break;
-
- case 'k':
- tmpreg=get_num(opP->con1,55);
- install_operand(s[1],tmpreg&0x7f);
- break;
-
- case 'l':
- tmpreg=opP->reg;
- if (s[1] == 'w') {
- if (tmpreg&0x7FF0000)
- as_bad("Floating point register in register list");
- insop(reverse_16_bits(tmpreg));
- } else {
- if (tmpreg&0x700FFFF)
- as_bad("Wrong register in floating-point reglist");
- install_operand(s[1],reverse_8_bits(tmpreg>>16));
- }
- break;
-
- case 'L':
- tmpreg=opP->reg;
- if (s[1] == 'w') {
- if (tmpreg&0x7FF0000)
- as_bad("Floating point register in register list");
- insop(tmpreg);
- } else if (s[1] == '8') {
- if (tmpreg&0x0FFFFFF)
- as_bad("incorrect register in reglist");
- install_operand(s[1],tmpreg>>24);
- } else {
- if (tmpreg&0x700FFFF)
- as_bad("wrong register in floating-point reglist");
- else
- install_operand(s[1],tmpreg>>16);
- }
- break;
-
- case 'M':
- install_operand(s[1],get_num(opP->con1,60));
- break;
-
- case 'O':
- tmpreg= (opP->mode == DREG)
- ? 0x20+opP->reg-DATA
- : (get_num(opP->con1,40)&0x1F);
- install_operand(s[1],tmpreg);
- break;
-
- case 'Q':
- tmpreg=get_num(opP->con1,10);
- if (tmpreg == 8)
- tmpreg=0;
- install_operand(s[1],tmpreg);
- break;
-
- case 'R':
- /* This depends on the fact that ADDR registers are
- eight more than their corresponding DATA regs, so
- the result will have the ADDR_REG bit set */
- install_operand(s[1],opP->reg-DATA);
- break;
-
- case 's':
- if (opP->reg == FPI) tmpreg=0x1;
- else if (opP->reg == FPS) tmpreg=0x2;
- else if (opP->reg == FPC) tmpreg=0x4;
- else as_fatal("failed sanity check.");
- install_operand(s[1],tmpreg);
- break;
-
- case 'S': /* Ignore it */
- break;
-
- case 'T':
- install_operand(s[1],get_num(opP->con1,30));
- break;
-
- case 'U': /* Ignore it */
- break;
-
- case 'c':
- switch (opP->reg) {
- case NC: tmpreg = 0; break;
- case DC: tmpreg = 1; break;
- case IC: tmpreg = 2; break;
- case BC: tmpreg = 3; break;
- default:
- as_fatal("failed sanity check");
- } /* switch on cache token */
- install_operand(s[1], tmpreg);
- break;
-#ifndef NO_68851
- /* JF: These are out of order, I fear. */
- case 'f':
- switch (opP->reg) {
- case SFC:
- tmpreg=0;
- break;
- case DFC:
- tmpreg=1;
- break;
- default:
- as_fatal("failed sanity check.");
- }
- install_operand(s[1],tmpreg);
- break;
-
- case 'P':
- switch (opP->reg) {
- case TC:
- tmpreg=0;
- break;
- case CAL:
- tmpreg=4;
- break;
- case VAL:
- tmpreg=5;
- break;
- case SCC:
- tmpreg=6;
- break;
- case AC:
- tmpreg=7;
- break;
- default:
- as_fatal("failed sanity check.");
- }
- install_operand(s[1],tmpreg);
- break;
-
- case 'V':
- if (opP->reg == VAL)
- break;
- as_fatal("failed sanity check.");
-
- case 'W':
- switch (opP->reg) {
-
- case DRP:
- tmpreg=1;
- break;
- case SRP:
- tmpreg=2;
- break;
- case CRP:
- tmpreg=3;
- break;
- default:
- as_fatal("failed sanity check.");
- }
- install_operand(s[1],tmpreg);
- break;
-
- case 'X':
- switch (opP->reg) {
- case BAD: case BAD+1: case BAD+2: case BAD+3:
- case BAD+4: case BAD+5: case BAD+6: case BAD+7:
- tmpreg = (4 << 10) | ((opP->reg - BAD) << 2);
- break;
-
- case BAC: case BAC+1: case BAC+2: case BAC+3:
- case BAC+4: case BAC+5: case BAC+6: case BAC+7:
- tmpreg = (5 << 10) | ((opP->reg - BAC) << 2);
- break;
-
- default:
- as_fatal("failed sanity check.");
- }
- install_operand(s[1], tmpreg);
- break;
- case 'Y':
- know(opP->reg == PSR);
- break;
- case 'Z':
- know(opP->reg == PCSR);
- break;
-#endif /* m68851 */
- case '_':
- tmpreg=get_num(opP->con1,80);
- install_operand(s[1], tmpreg);
- break;
- default:
- as_fatal("Internal error: Operand type %c unknown in line %s of file \"%s\"", s[0], __LINE__, __FILE__);
- }
- }
- /* By the time whe get here (FINALLY) the_ins contains the complete
- instruction, ready to be emitted... */
-} /* m68k_ip() */
-
-/*
- * get_regs := '/' + ?
- * | '-' + <register>
- * | '-' + <register> + ?
- * | <empty>
- * ;
- *
-
- * The idea here must be to scan in a set of registers but I don't
- * understand it. Looks awfully sloppy to me but I don't have any doc on
- * this format so...
-
- *
- *
- */
-
-static int get_regs(i,str,opP)
-int i;
-struct m68k_op *opP;
-char *str;
-{
- /* 26, 25, 24, 23-16, 15-8, 0-7 */
- /* Low order 24 bits encoded fpc,fps,fpi,fp7-fp0,a7-a0,d7-d0 */
- unsigned long cur_regs = 0;
- int reg1,
- reg2;
-
-#define ADD_REG(x) { if (x == FPI) cur_regs|=(1<<24);\
-else if (x == FPS) cur_regs|=(1<<25);\
-else if (x == FPC) cur_regs|=(1<<26);\
-else cur_regs|=(1<<(x-1)); }
-
- reg1=i;
- for (;;) {
- if (*str == '/') {
- ADD_REG(reg1);
- str++;
- } else if (*str == '-') {
- str++;
- reg2=m68k_reg_parse(&str);
- if (reg2<DATA || reg2 >= FPREG+8 || reg1 == FPI || reg1 == FPS || reg1 == FPC) {
- opP->error="unknown register in register list";
- return FAIL;
- }
- while (reg1 <= reg2) {
- ADD_REG(reg1);
- reg1++;
- }
- if (*str == '\0')
- break;
- } else if (*str == '\0') {
- ADD_REG(reg1);
- break;
- } else {
- opP->error="unknow character in register list";
- return FAIL;
- }
- /* DJA -- Bug Fix. Did't handle d1-d2/a1 until the following instruction was added */
- if (*str == '/')
- str ++;
- reg1=m68k_reg_parse(&str);
- if ((reg1<DATA || reg1 >= FPREG+8) && !(reg1 == FPI || reg1 == FPS || reg1 == FPC)) {
- opP->error="unknown register in register list";
- return FAIL;
- }
- }
- opP->reg=cur_regs;
- return OK;
-} /* get_regs() */
-
-static int reverse_16_bits(in)
-int in;
-{
- int out=0;
- int n;
-
- static int mask[16] = {
- 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,
- 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000
- };
- for (n=0;n<16;n++) {
- if (in&mask[n])
- out|=mask[15-n];
- }
- return out;
-} /* reverse_16_bits() */
-
-static int reverse_8_bits(in)
-int in;
-{
- int out=0;
- int n;
-
- static int mask[8] = {
- 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,
- };
-
- for (n=0;n<8;n++) {
- if (in&mask[n])
- out|=mask[7-n];
- }
- return out;
-} /* reverse_8_bits() */
-
-static void install_operand(mode,val)
-int mode;
-int val;
-{
- switch (mode) {
- case 's':
- the_ins.opcode[0]|=val & 0xFF; /* JF FF is for M kludge */
- break;
- case 'd':
- the_ins.opcode[0]|=val<<9;
- break;
- case '1':
- the_ins.opcode[1]|=val<<12;
- break;
- case '2':
- the_ins.opcode[1]|=val<<6;
- break;
- case '3':
- the_ins.opcode[1]|=val;
- break;
- case '4':
- the_ins.opcode[2]|=val<<12;
- break;
- case '5':
- the_ins.opcode[2]|=val<<6;
- break;
- case '6':
- /* DANGER! This is a hack to force cas2l and cas2w cmds
- to be three words long! */
- the_ins.numo++;
- the_ins.opcode[2]|=val;
- break;
- case '7':
- the_ins.opcode[1]|=val<<7;
- break;
- case '8':
- the_ins.opcode[1]|=val<<10;
- break;
-#ifndef NO_68851
- case '9':
- the_ins.opcode[1]|=val<<5;
- break;
-#endif
-
- case 't':
- the_ins.opcode[1]|=(val<<10)|(val<<7);
- break;
- case 'D':
- the_ins.opcode[1]|=(val<<12)|val;
- break;
- case 'g':
- the_ins.opcode[0]|=val=0xff;
- break;
- case 'i':
- the_ins.opcode[0]|=val<<9;
- break;
- case 'C':
- the_ins.opcode[1]|=val;
- break;
- case 'j':
- the_ins.opcode[1]|=val;
- the_ins.numo++; /* What a hack */
- break;
- case 'k':
- the_ins.opcode[1]|=val<<4;
- break;
- case 'b':
- case 'w':
- case 'l':
- break;
- case 'e':
- the_ins.opcode[0] |= (val << 6);
- break;
- case 'L':
- the_ins.opcode[1] = (val >> 16);
- the_ins.opcode[2] = val & 0xffff;
- break;
- case 'c':
- default:
- as_fatal("failed sanity check.");
- }
-} /* install_operand() */
-
-static void install_gen_operand(mode,val)
-int mode;
-int val;
-{
- switch (mode) {
- case 's':
- the_ins.opcode[0]|=val;
- break;
- case 'd':
- /* This is a kludge!!! */
- the_ins.opcode[0]|=(val&0x07)<<9|(val&0x38)<<3;
- break;
- case 'b':
- case 'w':
- case 'l':
- case 'f':
- case 'F':
- case 'x':
- case 'p':
- the_ins.opcode[0]|=val;
- break;
- /* more stuff goes here */
- default:
- as_fatal("failed sanity check.");
- }
-} /* install_gen_operand() */
-
-/*
- * verify that we have some number of paren pairs, do m68k_ip_op(), and
- * then deal with the bitfield hack.
- */
-
-static char *crack_operand(str,opP)
-register char *str;
-register struct m68k_op *opP;
-{
- register int parens;
- register int c;
- register char *beg_str;
-
- if (!str) {
- return str;
- }
- beg_str=str;
- for (parens=0;*str && (parens>0 || notend(str));str++) {
- if (*str == '(') parens++;
- else if (*str == ')') {
- if (!parens) { /* ERROR */
- opP->error="Extra )";
- return str;
- }
- --parens;
- }
- }
- if (!*str && parens) { /* ERROR */
- opP->error="Missing )";
- return str;
- }
- c= *str;
- *str='\0';
- if (m68k_ip_op(beg_str,opP) == FAIL) {
- *str=c;
- return str;
- }
- *str=c;
- if (c == '}')
- c= *++str; /* JF bitfield hack */
- if (c) {
- c= *++str;
- if (!c)
- as_bad("Missing operand");
- }
- return str;
-}
-
-/* See the comment up above where the #define notend(... is */
-#if 0
-notend(s)
-char *s;
-{
- if (*s == ',') return 0;
- if (*s == '{' || *s == '}')
- return 0;
- if (*s != ':') return 1;
- /* This kludge here is for the division cmd, which is a kludge */
- if (index("aAdD#",s[1])) return 0;
- return 1;
-}
-#endif
-
-/*
- * Generate a new fixup for one of the relocs in the_ins.
- */
-static void
- make_fix(m, where)
-int m;
-char *where;
-{
- int n;
-
- switch (the_ins.reloc[m].wid) {
- case 'B':
- case 'b':
- n=1;
- break;
- case '3':
- case 'w':
- n=2;
- break;
- case 'l':
- n=4;
- break;
- default:
- as_fatal("Don't know how to figure width of %c in md_assemble()",the_ins.reloc[m].wid);
- }
- fix_new(frag_now,
- where - frag_now->fr_literal + the_ins.reloc[m].n,
- n,
- the_ins.reloc[m].add,
- the_ins.reloc[m].sub,
- the_ins.reloc[m].off,
- the_ins.reloc[m].pcrel,
- the_ins.reloc[m].rtype
-#ifdef PIC
- , the_ins.reloc[m].got
-#endif /* PIC */
- );
-#ifdef PIC
- if (the_ins.reloc[m].rtype == RELOC_GLOB_DAT
- && the_ins.reloc[m].add != NULL)
- the_ins.reloc[m].add->sy_forceout = 1;
-#endif /* PIC */
-}
-
-/* This is the guts of the machine-dependent assembler. STR points to a
- machine dependent instruction. This function is supposed to emit
- the frags/bytes it assembles to.
- */
-void
- md_assemble(str)
-char *str;
-{
- char *er;
- short *fromP;
- char *toP = NULL;
- int m,n = 0;
- char *to_beg_P;
- int shorts_this_frag;
-
-
- if (current_architecture == 0) {
- current_architecture = (m68020
-#ifndef NO_68881
- | m68881
-#endif
-#ifndef NO_68851
- | m68851
-#endif
- );
- } /* default current_architecture */
-
- memset((char *)(&the_ins), '\0', sizeof(the_ins)); /* JF for paranoia sake */
- m68k_ip(str);
- er=the_ins.error;
- if (!er) {
- for (n=the_ins.numargs;n;--n)
- if (the_ins.operands[n].error) {
- er=the_ins.operands[n].error;
- break;
- }
- }
- if (er) {
- as_bad("\"%s\" -- Statement '%s' ignored",er,str);
- return;
- }
-
- if (the_ins.nfrag == 0) { /* No frag hacking involved; just put it out */
- toP=frag_more(2*the_ins.numo);
- fromP= &the_ins.opcode[0];
- for (m=the_ins.numo;m;--m) {
- md_number_to_chars(toP,(long)(*fromP),2);
- toP+=2;
- fromP++;
- }
- /* put out symbol-dependent info */
- for (m = 0; m < the_ins.nrel; m++) {
- make_fix(m, toP-the_ins.numo*2);
- }
- return;
- }
-
- /* There's some frag hacking */
- for (n=0,fromP= &the_ins.opcode[0];n<the_ins.nfrag;n++) {
- int wid;
-
- if (n == 0) wid=2*the_ins.fragb[n].fragoff;
- else wid=2*(the_ins.numo-the_ins.fragb[n-1].fragoff);
- toP=frag_more(wid);
- to_beg_P=toP;
- shorts_this_frag=0;
- for (m=wid/2;m;--m) {
- md_number_to_chars(toP,(long)(*fromP),2);
- toP+=2;
- fromP++;
- shorts_this_frag++;
- }
- for (m=0;m<the_ins.nrel;m++) {
- if ((the_ins.reloc[m].n) >= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */) {
- the_ins.reloc[m].n-= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */;
- break;
- }
- if (the_ins.reloc[m].wid == 0)
- continue;
- make_fix(m, toP-the_ins.numo*2);
- the_ins.reloc[m].wid=0;
- }
- /* know(the_ins.fragb[n].fadd); */
- (void)frag_var(rs_machine_dependent,10,0,(relax_substateT)(the_ins.fragb[n].fragty),
- the_ins.fragb[n].fadd,the_ins.fragb[n].foff,to_beg_P);
- }
- n=(the_ins.numo-the_ins.fragb[n-1].fragoff);
- shorts_this_frag=0;
- if (n) {
- toP=frag_more(n*sizeof(short));
- while (n--) {
- md_number_to_chars(toP,(long)(*fromP),2);
- toP+=2;
- fromP++;
- shorts_this_frag++;
- }
- }
- for (m=0;m<the_ins.nrel;m++) {
- if (the_ins.reloc[m].wid == 0)
- continue;
- make_fix(m, toP - /* the_ins.numo */ shorts_this_frag*2);
- }
-}
-
-/* This function is called once, at assembler startup time. This should
- set up all the tables, etc that the MD part of the assembler needs
- */
-void
- md_begin()
-{
- /*
- * md_begin -- set up hash tables with 68000 instructions.
- * similar to what the vax assembler does. ---phr
- */
- /* RMS claims the thing to do is take the m68k-opcode.h table, and make
- a copy of it at runtime, adding in the information we want but isn't
- there. I think it'd be better to have an awk script hack the table
- at compile time. Or even just xstr the table and use it as-is. But
- my lord ghod hath spoken, so we do it this way. Excuse the ugly var
- names. */
-
- register const struct m68k_opcode *ins;
- register struct m68k_incant *hack,
- *slak;
- register char *retval = 0; /* empty string, or error msg text */
- register unsigned int i;
- register char c;
-
- if ((op_hash = hash_new()) == NULL)
- as_fatal("Virtual memory exhausted");
-
- obstack_begin(&robyn,4000);
- for (ins = m68k_opcodes; ins < endop; ins++) {
- hack=slak=(struct m68k_incant *)obstack_alloc(&robyn,sizeof(struct m68k_incant));
- do {
- /* we *could* ignore insns that don't match our
- arch here but just leaving them out of the
- hash. */
- slak->m_operands=ins->args;
- slak->m_opnum=strlen(slak->m_operands)/2;
- slak->m_arch = ins->arch;
- slak->m_opcode=ins->opcode;
- /* This is kludgey */
- slak->m_codenum=((ins->match)&0xffffL) ? 2 : 1;
- if ((ins+1) != endop && !strcmp(ins->name,(ins+1)->name)) {
- slak->m_next=(struct m68k_incant *) obstack_alloc(&robyn,sizeof(struct m68k_incant));
- ins++;
- } else
- slak->m_next=0;
- slak=slak->m_next;
- } while (slak);
-
- retval = hash_insert (op_hash, ins->name,(char *)hack);
- /* Didn't his mommy tell him about null pointers? */
- if (retval && *retval)
- as_fatal("Internal Error: Can't hash %s: %s",ins->name,retval);
- }
-
- for (i = 0; i < sizeof(mklower_table) ; i++)
- mklower_table[i] = (isupper(c = (char) i)) ? tolower(c) : c;
-
- for (i = 0 ; i < sizeof(notend_table) ; i++) {
- notend_table[i] = 0;
- alt_notend_table[i] = 0;
- }
- notend_table[','] = 1;
- notend_table['{'] = 1;
- notend_table['}'] = 1;
- alt_notend_table['a'] = 1;
- alt_notend_table['A'] = 1;
- alt_notend_table['d'] = 1;
- alt_notend_table['D'] = 1;
- alt_notend_table['#'] = 1;
- alt_notend_table['f'] = 1;
- alt_notend_table['F'] = 1;
-#ifdef REGISTER_PREFIX
- alt_notend_table[REGISTER_PREFIX] = 1;
-#endif
-}
-
-#if 0
-#define notend(s) ((*s == ',' || *s == '}' || *s == '{' \
- || (*s == ':' && strchr("aAdD#", s[1]))) \
- ? 0 : 1)
-#endif
-
-/* This funciton is called once, before the assembler exits. It is
- supposed to do any final cleanup for this part of the assembler.
- */
-void
- md_end()
-{
-}
-
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
-/* Turn a string in input_line_pointer into a floating point constant of type
- type, and store the appropriate bytes in *litP. The number of LITTLENUMS
- emitted is stored in *sizeP. An error message is returned, or NULL on OK.
- */
-char *
- md_atof(type,litP,sizeP)
-char type;
-char *litP;
-int *sizeP;
-{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- char *t;
- char *atof_ieee();
-
- switch (type) {
- case 'f':
- case 'F':
- case 's':
- case 'S':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- prec = 4;
- break;
-
- case 'x':
- case 'X':
- prec = 6;
- break;
-
- case 'p':
- case 'P':
- prec = 6;
- break;
-
- default:
- *sizeP=0;
- return "Bad call to MD_ATOF()";
- }
- t=atof_ieee(input_line_pointer,type,words);
- if (t)
- input_line_pointer=t;
-
- *sizeP=prec * sizeof(LITTLENUM_TYPE);
- for (wordP=words;prec--;) {
- md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE));
- litP+=sizeof(LITTLENUM_TYPE);
- }
- return ""; /* Someone should teach Dean about null pointers */
-}
-
-/* Turn an integer of n bytes (in val) into a stream of bytes appropriate
- for use in the a.out file, and stores them in the array pointed to by buf.
- This knows about the endian-ness of the target machine and does
- THE RIGHT THING, whatever it is. Possible values for n are 1 (byte)
- 2 (short) and 4 (long) Floating numbers are put out as a series of
- LITTLENUMS (shorts, here at least)
- */
-void
- md_number_to_chars(buf, val, n)
-char *buf;
-long val;
-int n;
-{
- switch (n) {
- case 1:
- *buf++=val;
- break;
- case 2:
- *buf++=(val>>8);
- *buf++=val;
- break;
- case 4:
- *buf++=(val>>24);
- *buf++=(val>>16);
- *buf++=(val>>8);
- *buf++=val;
- break;
- default:
- as_fatal("failed sanity check.");
- }
-}
-
-void
- md_apply_fix(fixP, val)
-fixS *fixP;
-long val;
-{
- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- switch (fixP->fx_size) {
- case 1:
- *buf++ = val;
- break;
- case 2:
- *buf++ = (val >> 8);
- *buf++ = val;
- break;
- case 4:
- *buf++ = (val >> 24);
- *buf++ = (val >> 16);
- *buf++ = (val >> 8);
- *buf++ = val;
- break;
- default:
- BAD_CASE (fixP->fx_size);
- }
-}
-
-
-/* *fragP has been relaxed to its final size, and now needs to have
- the bytes inside it modified to conform to the new size There is UGLY
- MAGIC here. ..
- */
-void
- md_convert_frag(headers, fragP)
-object_headers *headers;
-register fragS *fragP;
-{
- long disp;
- long ext = 0;
-
- /* Address in object code of the displacement. */
- register int object_address = fragP->fr_fix + fragP->fr_address;
-
-#ifdef IBM_COMPILER_SUX
- /* This is wrong but it convinces the native rs6000 compiler to
- generate the code we want. */
- register char *buffer_address = fragP->fr_literal;
- buffer_address += fragP->fr_fix;
-#else /* IBM_COMPILER_SUX */
- /* Address in gas core of the place to store the displacement. */
- register char *buffer_address = fragP->fr_fix + fragP->fr_literal;
-#endif /* IBM_COMPILER_SUX */
-
- /* No longer true: know(fragP->fr_symbol); */
-
- /* The displacement of the address, from current location. */
- disp = fragP->fr_symbol ? S_GET_VALUE(fragP->fr_symbol) : 0;
- disp = (disp + fragP->fr_offset) - object_address;
-
- switch (fragP->fr_subtype) {
- case TAB(BCC68000,BYTE):
- case TAB(BRANCH,BYTE):
- know(issbyte(disp));
- if (disp == 0)
- as_bad("short branch with zero offset: use :w");
- fragP->fr_opcode[1]=disp;
- ext=0;
- break;
- case TAB(DBCC,SHORT):
- know(issword(disp));
- ext=2;
- break;
- case TAB(BCC68000,SHORT):
- case TAB(BRANCH,SHORT):
- know(issword(disp));
- fragP->fr_opcode[1]=0x00;
- ext=2;
- break;
- case TAB(BRANCH,LONG):
- if (cpu_of_arch(current_architecture) < m68020) {
- if (fragP->fr_opcode[0] == 0x61) {
- fragP->fr_opcode[0]= 0x4E;
- fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */
- subseg_change(SEG_TEXT, 0);
-
- fix_new(fragP,
- fragP->fr_fix,
- 4,
- fragP->fr_symbol,
- 0,
- fragP->fr_offset,
- 0,
- FIX_NO_RELOC);
-
- fragP->fr_fix+=4;
- ext=0;
- } else if (fragP->fr_opcode[0] == 0x60) {
- fragP->fr_opcode[0]= 0x4E;
- fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */
- subseg_change(SEG_TEXT, 0);
- fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset,0,
- FIX_NO_RELOC);
- fragP->fr_fix+=4;
- ext=0;
- } else {
- as_bad("Long branch offset not supported.");
- }
- } else {
- fragP->fr_opcode[1]=0xff;
- ext=4;
- }
- break;
- case TAB(BCC68000,LONG):
- /* only Bcc 68000 instructions can come here */
- /* change bcc into b!cc/jmp absl long */
- fragP->fr_opcode[0] ^= 0x01; /* invert bcc */
- fragP->fr_opcode[1] = 0x6; /* branch offset = 6 */
-
- /* JF: these used to be fr_opcode[2,3], but they may be in a
- different frag, in which case refering to them is a no-no.
- Only fr_opcode[0,1] are guaranteed to work. */
- *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */
- *buffer_address++ = 0xf9;
- fragP->fr_fix += 2; /* account for jmp instruction */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
- fragP->fr_offset,0,
- FIX_NO_RELOC);
- fragP->fr_fix += 4;
- ext=0;
- break;
- case TAB(DBCC,LONG):
- /* only DBcc 68000 instructions can come here */
- /* change dbcc into dbcc/jmp absl long */
- /* JF: these used to be fr_opcode[2-7], but that's wrong */
- *buffer_address++ = 0x00; /* branch offset = 4 */
- *buffer_address++ = 0x04;
- *buffer_address++ = 0x60; /* put in bra pc+6 */
- *buffer_address++ = 0x06;
- *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */
- *buffer_address++ = 0xf9;
-
- fragP->fr_fix += 6; /* account for bra/jmp instructions */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
- fragP->fr_offset,0,
- FIX_NO_RELOC);
- fragP->fr_fix += 4;
- ext=0;
- break;
- case TAB(FBRANCH,SHORT):
- know((fragP->fr_opcode[1]&0x40) == 0);
- ext=2;
- break;
- case TAB(FBRANCH,LONG):
- fragP->fr_opcode[1]|=0x40; /* Turn on LONG bit */
- ext=4;
- break;
- case TAB(PCREL,SHORT):
- ext=2;
- break;
- case TAB(PCREL,LONG):
- /* The thing to do here is force it to ABSOLUTE LONG, since
- PCREL is really trying to shorten an ABSOLUTE address anyway */
- /* JF FOO This code has not been tested */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset, 0, FIX_NO_RELOC);
- if ((fragP->fr_opcode[1] & 0x3F) != 0x3A)
- as_bad("Internal error (long PC-relative operand) for insn 0x%04lx at 0x%lx",
- fragP->fr_opcode[0],fragP->fr_address);
- fragP->fr_opcode[1]&= ~0x3F;
- fragP->fr_opcode[1]|=0x39; /* Mode 7.1 */
- fragP->fr_fix+=4;
- /* md_number_to_chars(buffer_address,
- (long)(fragP->fr_symbol->sy_value + fragP->fr_offset),
- 4); */
- ext=0;
- break;
- case TAB(PCLEA,SHORT):
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol, (symbolS *) 0, fragP->fr_offset, 1, FIX_NO_RELOC);
- fragP->fr_opcode[1] &= ~0x3F;
- fragP->fr_opcode[1] |= 0x3A;
- ext=2;
- break;
- case TAB(PCLEA,LONG):
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, (int) (fragP->fr_fix) + 2, 4, fragP->fr_symbol, (symbolS *) 0, fragP->fr_offset + 2, 1, FIX_NO_RELOC);
- *buffer_address++ = 0x01;
- *buffer_address++ = 0x70;
- fragP->fr_fix+=2;
- /* buffer_address+=2; */
- ext=4;
- break;
-
-} /* switch on subtype */
-
- if (ext) {
- md_number_to_chars(buffer_address, (long) disp, (int) ext);
- fragP->fr_fix += ext;
- /* H_SET_TEXT_SIZE(headers, H_GET_TEXT_SIZE(headers) + ext); */
- } /* if extending */
-
- return;
-} /* md_convert_frag() */
-
-/* Force truly undefined symbols to their maximum size, and generally set up
- the frag list to be relaxed
- */
-int md_estimate_size_before_relax(fragP, segment)
-register fragS *fragP;
-segT segment;
-{
- int old_fix;
- register char *buffer_address = fragP->fr_fix + fragP->fr_literal;
-
- old_fix = fragP->fr_fix;
-
- /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */
- switch (fragP->fr_subtype) {
-
- case TAB(BRANCH,SZ_UNDEF): {
- if ((fragP->fr_symbol != NULL) /* Not absolute */
- && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- fragP->fr_subtype = TAB(TABTYPE(fragP->fr_subtype), BYTE);
- break;
- } else if ((fragP->fr_symbol == 0) || (cpu_of_arch(current_architecture) < m68020)) {
- /* On 68000, or for absolute value, switch to abs long */
- /* FIXME, we should check abs val, pick short or long */
- if (fragP->fr_opcode[0] == 0x61) {
- fragP->fr_opcode[0]= 0x4E;
- fragP->fr_opcode[1]= 0xB9; /* JSR with ABSL LONG offset */
- subseg_change(SEG_TEXT, 0);
- fix_new(fragP, fragP->fr_fix, 4,
- fragP->fr_symbol, 0, fragP->fr_offset, 0, FIX_NO_RELOC);
- fragP->fr_fix+=4;
- frag_wane(fragP);
- } else if (fragP->fr_opcode[0] == 0x60) {
- fragP->fr_opcode[0]= 0x4E;
- fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */
- subseg_change(SEG_TEXT, 0);
- fix_new(fragP, fragP->fr_fix, 4,
- fragP->fr_symbol, 0, fragP->fr_offset, 0, FIX_NO_RELOC);
- fragP->fr_fix+=4;
- frag_wane(fragP);
- } else {
- as_warn("Long branch offset to extern symbol not supported.");
- }
- } else if (flagseen['l']) { /* Symbol is still undefined. Make it simple */
- fix_new(fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol,
- (symbolS *) 0, fragP->fr_offset, 1, FIX_NO_RELOC);
- fragP->fr_fix += 2;
- fragP->fr_opcode[1] = 0x00;
- frag_wane(fragP);
- } else {
- fix_new(fragP, (int) (fragP->fr_fix), 4, fragP->fr_symbol,
- (symbolS *) 0, fragP->fr_offset, 1,
-#ifdef PIC
- /* With -k, make all external branches go via the jump table. */
- (picmode? RELOC_JMP_TBL: NO_RELOC), NULL
-#else
- NO_RELOC
-#endif
- );
- fragP->fr_fix += 4;
- fragP->fr_opcode[1] = 0xff;
- frag_wane(fragP);
- break;
- }
-
- break;
- } /* case TAB(BRANCH,SZ_UNDEF) */
-
- case TAB(FBRANCH,SZ_UNDEF): {
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) {
- fragP->fr_subtype = TAB(FBRANCH,SHORT);
- fragP->fr_var += 2;
- } else {
- fragP->fr_subtype = TAB(FBRANCH,LONG);
- fragP->fr_var += 4;
- }
- break;
- } /* TAB(FBRANCH,SZ_UNDEF) */
-
- case TAB(PCREL,SZ_UNDEF): {
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) {
- fragP->fr_subtype = TAB(PCREL,SHORT);
- fragP->fr_var += 2;
- } else {
- fragP->fr_subtype = TAB(PCREL,LONG);
- fragP->fr_var += 4;
- }
- break;
- } /* TAB(PCREL,SZ_UNDEF) */
-
- case TAB(BCC68000,SZ_UNDEF): {
- if ((fragP->fr_symbol != NULL)
- && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- fragP->fr_subtype=TAB(BCC68000,BYTE);
- break;
- }
- /* only Bcc 68000 instructions can come here */
- /* change bcc into b!cc/jmp absl long */
- fragP->fr_opcode[0] ^= 0x01; /* invert bcc */
- if (flagseen['l']) {
- fragP->fr_opcode[1] = 0x04; /* branch offset = 6 */
- /* JF: these were fr_opcode[2,3] */
- buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */
- buffer_address[1] = 0xf8;
- fragP->fr_fix += 2; /* account for jmp instruction */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0,
- fragP->fr_offset, 0, FIX_NO_RELOC);
- fragP->fr_fix += 2;
- } else {
- fragP->fr_opcode[1] = 0x06; /* branch offset = 6 */
- /* JF: these were fr_opcode[2,3] */
- buffer_address[2] = 0x4e; /* put in jmp long (0x4ef9) */
- buffer_address[3] = 0xf9;
- fragP->fr_fix += 2; /* account for jmp instruction */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 0, FIX_NO_RELOC);
- fragP->fr_fix += 4;
- }
- frag_wane(fragP);
- break;
- } /* case TAB(BCC68000,SZ_UNDEF) */
-
- case TAB(DBCC,SZ_UNDEF): {
- if (fragP->fr_symbol != NULL && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- fragP->fr_subtype=TAB(DBCC,SHORT);
- fragP->fr_var+=2;
- break;
- }
- /* only DBcc 68000 instructions can come here */
- /* change dbcc into dbcc/jmp absl long */
- /* JF: these used to be fr_opcode[2-4], which is wrong. */
- buffer_address[0] = 0x00; /* branch offset = 4 */
- buffer_address[1] = 0x04;
- buffer_address[2] = 0x60; /* put in bra pc + ... */
-
- if (flagseen['l']) {
- /* JF: these were fr_opcode[5-7] */
- buffer_address[3] = 0x04; /* plus 4 */
- buffer_address[4] = 0x4e;/* Put in Jump Word */
- buffer_address[5] = 0xf8;
- fragP->fr_fix += 6; /* account for bra/jmp instruction */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0,
- fragP->fr_offset, 0, FIX_NO_RELOC);
- fragP->fr_fix += 2;
- } else {
- /* JF: these were fr_opcode[5-7] */
- buffer_address[3] = 0x06; /* Plus 6 */
- buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */
- buffer_address[5] = 0xf9;
- fragP->fr_fix += 6; /* account for bra/jmp instruction */
- subseg_change(SEG_TEXT,0);
- fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 0, FIX_NO_RELOC);
- fragP->fr_fix += 4;
- }
-
- frag_wane(fragP);
- break;
- } /* case TAB(DBCC,SZ_UNDEF) */
-
- case TAB(PCLEA,SZ_UNDEF): {
- if ((S_GET_SEGMENT(fragP->fr_symbol)) == segment || flagseen['l']) {
- fragP->fr_subtype=TAB(PCLEA,SHORT);
- fragP->fr_var+=2;
- } else {
- fragP->fr_subtype=TAB(PCLEA,LONG);
- fragP->fr_var+=6;
- }
- break;
- } /* TAB(PCLEA,SZ_UNDEF) */
-
- default:
- break;
-
- } /* switch on subtype looking for SZ_UNDEF's. */
-
- /* now that SZ_UNDEF are taken care of, check others */
- switch (fragP->fr_subtype) {
- case TAB(BCC68000,BYTE):
- case TAB(BRANCH,BYTE):
- /* We can't do a short jump to the next instruction,
- so we force word mode. */
- if (fragP->fr_symbol && S_GET_VALUE(fragP->fr_symbol) == 0 &&
- fragP->fr_symbol->sy_frag == fragP->fr_next) {
- fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),SHORT);
- fragP->fr_var+=2;
- }
- break;
- default:
- break;
-}
- return fragP->fr_var + fragP->fr_fix - old_fix;
-}
-
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
-/* the bit-field entries in the relocation_info struct plays hell
- with the byte-order problems of cross-assembly. So as a hack,
- I added this mach. dependent ri twiddler. Ugly, but it gets
- you there. -KWK */
-/* on m68k: first 4 bytes are normal unsigned long, next three bytes
- are symbolnum, most sig. byte first. Last byte is broken up with
- bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower
- nibble as nuthin. (on Sun 3 at least) */
-/* Translate the internal relocation information into target-specific
- format. */
-#ifdef comment
-void
- md_ri_to_chars(the_bytes, ri)
-char *the_bytes;
-struct reloc_info_generic *ri;
-{
- /* this is easy */
- md_number_to_chars(the_bytes, ri->r_address, 4);
- /* now the fun stuff */
- the_bytes[4] = (ri->r_symbolnum >> 16) & 0x0ff;
- the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff;
- the_bytes[6] = ri->r_symbolnum & 0x0ff;
- the_bytes[7] = (((ri->r_pcrel << 7) & 0x80) | ((ri->r_length << 5) & 0x60) |
- ((ri->r_extern << 4) & 0x10));
-}
-#endif /* comment */
-
-void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
-char *where;
-fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- /*
- * In: length of relocation (or of address) in chars: 1, 2 or 4.
- * Out: GNU LD relocation length code: 0, 1, or 2.
- */
-
- static unsigned char nbytes_r_length[] = { 42, 0, 1, 42, 2 };
- long r_symbolnum;
- int r_flags;
-
- know(fixP->fx_addsy != NULL);
-
- md_number_to_chars(where,
- fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
- 4);
-
- r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
- ? S_GET_TYPE(fixP->fx_addsy)
- : fixP->fx_addsy->sy_number);
- r_flags = (fixP->fx_pcrel? 0x80: 0)
- | ((nbytes_r_length[fixP->fx_size] & 3) << 5)
- | (!S_IS_DEFINED(fixP->fx_addsy)? 0x10: 0);
-
-#ifdef PIC
- switch (fixP->fx_r_type) {
- case NO_RELOC:
- break;
- case RELOC_32:
- if (picmode && S_IS_EXTERNAL(fixP->fx_addsy)) {
- r_symbolnum = fixP->fx_addsy->sy_number;
- r_flags |= 0x10; /* set extern bit */
- }
- break;
- case RELOC_GLOB_DAT:
- r_flags |= 8; /* set baserel bit */
- r_symbolnum = fixP->fx_addsy->sy_number;
- if (S_IS_EXTERNAL(fixP->fx_addsy))
- r_flags |= 0x10;
- break;
- case RELOC_JMP_TBL:
- r_flags |= 4; /* set jmptable bit */
- break;
- case RELOC_RELATIVE:
- /* should never happen */
- r_flags |= 2; /* set relative bit */
- break;
- }
-#endif /* PIC */
-
- where[4] = (r_symbolnum >> 16) & 0x0ff;
- where[5] = (r_symbolnum >> 8) & 0x0ff;
- where[6] = r_symbolnum & 0x0ff;
- where[7] = r_flags;
-
- return;
-} /* tc_aout_fix_to_chars() */
-
-#endif /* OBJ_AOUT or OBJ_BOUT */
-
-#ifndef WORKING_DOT_WORD
-const int md_short_jump_size = 4;
-const int md_long_jump_size = 6;
-
-void
- md_create_short_jump(ptr,from_addr,to_addr,frag,to_symbol)
-char *ptr;
-long from_addr,
- to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- long offset;
-
- offset = to_addr - (from_addr+2);
-
- md_number_to_chars(ptr ,(long)0x6000,2);
- md_number_to_chars(ptr+2,(long)offset,2);
-}
-
-void
- md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol)
-char *ptr;
-long from_addr,
- to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- long offset;
-
- if (cpu_of_arch(current_architecture) < m68020) {
- offset=to_addr-S_GET_VALUE(to_symbol);
- md_number_to_chars(ptr ,(long)0x4EF9,2);
- md_number_to_chars(ptr+2,(long)offset,4);
- fix_new(frag,(ptr+2)-frag->fr_literal,4,to_symbol,(symbolS *)0,(long)0,0,
- FIX_NO_RELOC);
- } else {
- offset=to_addr - (from_addr+2);
- md_number_to_chars(ptr ,(long)0x60ff,2);
- md_number_to_chars(ptr+2,(long)offset,4);
- }
-}
-
-#endif
-/* Different values of OK tell what its OK to return. Things that aren't OK are an error (what a shock, no?)
-
- 0: Everything is OK
- 10: Absolute 1:8 only
- 20: Absolute 0:7 only
- 30: absolute 0:15 only
- 40: Absolute 0:31 only
- 50: absolute 0:127 only
- 55: absolute -64:63 only
- 60: absolute -128:127 only
- 70: absolute 0:4095 only
- 80: No bignums
-
- */
-
-static int get_num(exp,ok)
-struct m68k_exp *exp;
-int ok;
-{
-#ifdef TEST2
- long l = 0;
-
- if (!exp->e_beg)
- return 0;
- if (*exp->e_beg == '0') {
- if (exp->e_beg[1] == 'x')
- sscanf(exp->e_beg+2,"%x",&l);
- else
- sscanf(exp->e_beg+1,"%O",&l);
- return l;
- }
- return atol(exp->e_beg);
-#else
- char *save_in;
- char c_save;
-
- if (!exp) {
- /* Can't do anything */
- return 0;
- }
- if (!exp->e_beg || !exp->e_end) {
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)= (ok == 10) ? 1 : 0;
- as_warn("Null expression defaults to %ld",offs(exp));
- return 0;
- }
-
- exp->e_siz=0;
- if (/* ok != 80 && */exp->e_end[-1] == ':' && (exp->e_end-exp->e_beg) >= 2) {
- switch (exp->e_end[0]) {
- case 's':
- case 'S':
- case 'b':
- case 'B':
- exp->e_siz=1;
- break;
- case 'w':
- case 'W':
- exp->e_siz=2;
- break;
- case 'l':
- case 'L':
- exp->e_siz=3;
- break;
- default:
- as_bad("Unknown size for expression \"%c\"",exp->e_end[0]);
- }
- exp->e_end-=2;
- }
- c_save=exp->e_end[1];
- exp->e_end[1]='\0';
- save_in=input_line_pointer;
- input_line_pointer=exp->e_beg;
- switch (expression(&(exp->e_exp))) {
- case SEG_PASS1:
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)= (ok == 10) ? 1 : 0;
- as_warn("Unknown expression: '%s' defaulting to %d",exp->e_beg,offs(exp));
- break;
-
- case SEG_ABSENT:
- /* Do the same thing the VAX asm does */
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)=0;
- if (ok == 10) {
- as_warn("expression out of range: defaulting to 1");
- offs(exp)=1;
- }
- break;
- case SEG_ABSOLUTE:
- switch (ok) {
- case 10:
- if (offs(exp)<1 || offs(exp)>8) {
- as_warn("expression out of range: defaulting to 1");
- offs(exp)=1;
- }
- break;
- case 20:
- if (offs(exp)<0 || offs(exp)>7)
- goto outrange;
- break;
- case 30:
- if (offs(exp)<0 || offs(exp)>15)
- goto outrange;
- break;
- case 40:
- if (offs(exp)<0 || offs(exp)>32)
- goto outrange;
- break;
- case 50:
- if (offs(exp)<0 || offs(exp)>127)
- goto outrange;
- break;
- case 55:
- if (offs(exp)<-64 || offs(exp)>63)
- goto outrange;
- break;
- case 60:
- if (offs(exp)<-128 || offs(exp)>127)
- goto outrange;
- break;
- case 70:
- if (offs(exp)<0 || offs(exp)>4095) {
- outrange:
- as_warn("expression out of range: defaulting to 0");
- offs(exp)=0;
- }
- break;
- default:
- break;
- }
- break;
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_UNKNOWN:
- case SEG_DIFFERENCE:
- if (ok >= 10 && ok <= 70) {
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)= (ok == 10) ? 1 : 0;
- as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp));
- }
- break;
- case SEG_BIG:
- if (ok == 80 && offs(exp)<0) { /* HACK! Turn it into a long */
- LITTLENUM_TYPE words[6];
-
- gen_to_words(words,2,8L);/* These numbers are magic! */
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)=words[1]|(words[0]<<16);
- } else if (ok != 0) {
- seg(exp)=SEG_ABSOLUTE;
- adds(exp)=0;
- subs(exp)=0;
- offs(exp)= (ok == 10) ? 1 : 0;
- as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp));
- }
- break;
- default:
- as_fatal("failed sanity check.");
- }
- if (input_line_pointer != exp->e_end+1)
- as_bad("Ignoring junk after expression");
- exp->e_end[1]=c_save;
- input_line_pointer=save_in;
- if (exp->e_siz) {
- switch (exp->e_siz) {
- case 1:
- if (!isbyte(offs(exp)))
- as_warn("expression doesn't fit in BYTE");
- break;
- case 2:
- if (!isword(offs(exp)))
- as_warn("expression doesn't fit in WORD");
- break;
- }
- }
- return offs(exp);
-#endif
-} /* get_num() */
-
-/* These are the back-ends for the various machine dependent pseudo-ops. */
-void demand_empty_rest_of_line(); /* Hate those extra verbose names */
-
-static void s_data1() {
- subseg_new(SEG_DATA,1);
- demand_empty_rest_of_line();
-} /* s_data1() */
-
-static void s_data2() {
- subseg_new(SEG_DATA,2);
- demand_empty_rest_of_line();
-} /* s_data2() */
-
-static void s_bss() {
- /* We don't support putting frags in the BSS segment, but we
- can put them into initialized data for now... */
- subseg_new(SEG_DATA,255); /* FIXME-SOON */
- demand_empty_rest_of_line();
-} /* s_bss() */
-
-static void s_even() {
- register int temp;
- register long temp_fill;
-
- temp = 1; /* JF should be 2? */
- temp_fill = get_absolute_expression ();
- if ( ! need_pass_2 ) /* Never make frag if expect extra pass. */
- frag_align (temp, (int)temp_fill);
- demand_empty_rest_of_line();
-} /* s_even() */
-
-static void s_proc() {
- demand_empty_rest_of_line();
-} /* s_proc() */
-
-/* s_space is defined in read.c .skip is simply an alias to it. */
-
-/*
- * md_parse_option
- * Invocation line includes a switch not recognized by the base assembler.
- * See if it's a processor-specific option. These are:
- *
- * -[A]m[c]68000, -[A]m[c]68008, -[A]m[c]68010, -[A]m[c]68020, -[A]m[c]68030, -[A]m[c]68040
- * -[A]m[c]68881, -[A]m[c]68882, -[A]m[c]68851
- * Select the architecture. Instructions or features not
- * supported by the selected architecture cause fatal
- * errors. More than one may be specified. The default is
- * -m68020 -m68851 -m68881. Note that -m68008 is a synonym
- * for -m68000, and -m68882 is a synonym for -m68881.
- *
- * MAYBE_FLOAT_TOO is defined below so that specifying a processor type
- * (e.g. m68020) also requests that float instructions be included. This
- * is the default setup, mostly to avoid hassling users. A better
- * rearrangement of this structure would be to add an option to DENY
- * floating point opcodes, for people who want to really know there's none
- * of that funny floaty stuff going on. FIXME-later.
- */
-#ifndef MAYBE_FLOAT_TOO
-#define MAYBE_FLOAT_TOO m68881
-#endif
-
-int md_parse_option(argP,cntP,vecP)
-char **argP;
-int *cntP;
-char ***vecP;
-{
- switch (**argP) {
- case 'l': /* -l means keep external to 2 bit offset
- rather than 16 bit one */
- break;
-
- case 'S': /* -S means that jbsr's always turn into jsr's. */
- break;
-
- case 'A':
- (*argP)++;
- /* intentional fall-through */
- case 'm':
- (*argP)++;
-
- if (**argP == 'c') {
- (*argP)++;
- } /* allow an optional "c" */
-
- if (!strcmp(*argP, "68000")
- || !strcmp(*argP, "68008")) {
- current_architecture |= m68000;
- } else if (!strcmp(*argP, "68010")) {
-#ifdef TE_SUN
- omagic= 1<<16|OMAGIC;
-#endif
- current_architecture |= m68010;
-
- } else if (!strcmp(*argP, "68020")) {
- current_architecture |= m68020 | MAYBE_FLOAT_TOO;
-
- } else if (!strcmp(*argP, "68030")) {
- current_architecture |= m68030 | MAYBE_FLOAT_TOO;
-
- } else if (!strcmp(*argP, "68040")) {
- current_architecture |= m68040 | MAYBE_FLOAT_TOO;
-
- } else if (!strcmp(*argP, "68060")) {
- current_architecture |= m68040 | MAYBE_FLOAT_TOO;
-
-#ifndef NO_68881
- } else if (!strcmp(*argP, "68881")) {
- current_architecture |= m68881;
-
- } else if (!strcmp(*argP, "68882")) {
- current_architecture |= m68882;
-
-#endif /* NO_68881 */
-#ifndef NO_68851
- } else if (!strcmp(*argP,"68851")) {
- current_architecture |= m68851;
-
-#endif /* NO_68851 */
- } else {
- as_warn("Unknown architecture, \"%s\". option ignored", *argP);
- } /* switch on architecture */
-
- while (**argP) (*argP)++;
-
- break;
-
- case 'p':
- if (!strcmp(*argP,"pic")) {
- (*argP) += 3;
- break; /* -pic, Position Independent Code */
- } else {
- return(0);
- } /* pic or not */
-
-#ifdef PIC
- case 'k':
- case 'K':
- /* Predefine GOT symbol */
- GOT_symbol = symbol_find_or_make("__GLOBAL_OFFSET_TABLE_");
- break;
-#endif /* PIC */
-
- default:
- return 0;
- }
- return 1;
-}
-
-
-#ifdef TEST2
-
-/* TEST2: Test md_assemble() */
-/* Warning, this routine probably doesn't work anymore */
-
-main()
-{
- struct m68k_it the_ins;
- char buf[120];
- char *cp;
- int n;
-
- m68k_ip_begin();
- for (;;) {
- if (!gets(buf) || !*buf)
- break;
- if (buf[0] == '|' || buf[1] == '.')
- continue;
- for (cp=buf;*cp;cp++)
- if (*cp == '\t')
- *cp=' ';
- if (is_label(buf))
- continue;
- memset(&the_ins, '\0', sizeof(the_ins));
- m68k_ip(&the_ins,buf);
- if (the_ins.error) {
- printf("Error %s in %s\n",the_ins.error,buf);
- } else {
- printf("Opcode(%d.%s): ",the_ins.numo,the_ins.args);
- for (n=0;n<the_ins.numo;n++)
- printf(" 0x%x",the_ins.opcode[n]&0xffff);
- printf(" ");
- print_the_insn(&the_ins.opcode[0],stdout);
- (void)putchar('\n');
- }
- for (n=0;n<strlen(the_ins.args)/2;n++) {
- if (the_ins.operands[n].error) {
- printf("op%d Error %s in %s\n",n,the_ins.operands[n].error,buf);
- continue;
- }
- printf("mode %d, reg %d, ",the_ins.operands[n].mode,the_ins.operands[n].reg);
- if (the_ins.operands[n].b_const)
- printf("Constant: '%.*s', ",1+the_ins.operands[n].e_const-the_ins.operands[n].b_const,the_ins.operands[n].b_const);
- printf("ireg %d, isiz %d, imul %d, ",the_ins.operands[n].ireg,the_ins.operands[n].isiz,the_ins.operands[n].imul);
- if (the_ins.operands[n].b_iadd)
- printf("Iadd: '%.*s',",1+the_ins.operands[n].e_iadd-the_ins.operands[n].b_iadd,the_ins.operands[n].b_iadd);
- (void)putchar('\n');
- }
- }
- m68k_ip_end();
- return 0;
-}
-
-is_label(str)
-char *str;
-{
- while (*str == ' ')
- str++;
- while (*str && *str != ' ')
- str++;
- if (str[-1] == ':' || str[1] == '=')
- return 1;
- return 0;
-}
-
-#endif
-
-/* Possible states for relaxation:
-
- 0 0 branch offset byte (bra, etc)
- 0 1 word
- 0 2 long
-
- 1 0 indexed offsets byte a0@(32,d4:w:1) etc
- 1 1 word
- 1 2 long
-
- 2 0 two-offset index word-word a0@(32,d4)@(45) etc
- 2 1 word-long
- 2 2 long-word
- 2 3 long-long
-
- */
-
-
-
-#ifdef DONTDEF
-abort()
-{
- printf("ABORT!\n");
- exit(12);
-}
-
-print_frags()
-{
- fragS *fragP;
- extern fragS *text_frag_root;
-
- for (fragP=text_frag_root;fragP;fragP=fragP->fr_next) {
- printf("addr %lu next 0x%x fix %ld var %ld symbol 0x%x offset %ld\n",
- fragP->fr_address,fragP->fr_next,fragP->fr_fix,fragP->fr_var,fragP->fr_symbol,fragP->fr_offset);
- printf("opcode 0x%x type %d subtype %d\n\n",fragP->fr_opcode,fragP->fr_type,fragP->fr_subtype);
- }
- fflush(stdout);
- return 0;
-}
-#endif
-
-
-/* We have no need to default values of symbols. */
-
-/* ARGSUSED */
-symbolS *
- md_undefined_symbol (name)
-char *name;
-{
- return 0;
-}
-
-/* Parse an operand that is machine-specific.
- We just return without modifying the expression if we have nothing
- to do. */
-
-/* ARGSUSED */
-void
- md_operand (expressionP)
-expressionS *expressionP;
-{
-}
-
-/* Round up a section size to the appropriate boundary. */
-long
- md_section_align (segment, size)
-segT segment;
-long size;
-{
- return size; /* Byte alignment is fine */
-}
-
-/* Exactly what point is a PC-relative offset relative TO?
- On the 68k, they're relative to the address of the offset. */
-long
- md_pcrel_from (fixP)
-fixS *fixP;
-{
- return(fixP->fx_where + fixP->fx_frag->fr_address);
-}
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-m68k.c */
diff --git a/gnu/usr.bin/as/config/tc-m68k.h b/gnu/usr.bin/as/config/tc-m68k.h
deleted file mode 100644
index 33d8d96..0000000
--- a/gnu/usr.bin/as/config/tc-m68k.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* This file is tc-m68k.h
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * This file is tp-generic.h and is intended to be a template for
- * target processor specific header files.
- */
-
-#define MID_M68K 135
-#define MID_M68K4K 136
-#include <machine/param.h>
-
-#define TC_M68K 1
-
-#ifdef OLD_GAS
-#define REVERSE_SORT_RELOCS
-#endif /* OLD_GAS */
-
-#define AOUT_MACHTYPE MID_MACHINE
-#define LOCAL_LABELS_FB
-
-#define tc_crawl_symbol_chain(a) {;} /* not used */
-#define tc_headers_hook(a) {;} /* not used */
-#define tc_aout_pre_write_hook(x) {;} /* not used */
-
-#define LISTING_WORD_SIZE 2 /* A word is 2 bytes */
-#define LISTING_LHS_WIDTH 2 /* One word on the first line */
-#define LISTING_LHS_WIDTH_SECOND 2 /* One word on the second line */
-#define LISTING_LHS_CONT_LINES 4 /* And 4 lines max */
-#define LISTING_HEADER "68K GAS "
-
-/* Copied from write.c */
-#define M68K_AIM_KLUDGE(aim, this_state,this_type) \
- if (aim == 0 && this_state == 4) { /* hard encoded from tc-m68k.c */ \
- aim=this_type->rlx_forward+1; /* Force relaxation into word mode */ \
- }
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-m68k.h */
diff --git a/gnu/usr.bin/as/config/tc-m68kmote.h b/gnu/usr.bin/as/config/tc-m68kmote.h
deleted file mode 100644
index 70afae3..0000000
--- a/gnu/usr.bin/as/config/tc-m68kmote.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* This file is tc-m68kmote.h
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * This file is tp-generic.h and is intended to be a template for
- * target processor specific header files.
- */
-
-#define TC_M68K 1
-
-#ifdef TE_SUN3
-/* This variable contains the value to write out at the beginning of
- the a.out file. The 2<<16 means that this is a 68020 file instead
- of an old-style 68000 file */
-
-#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (2<<16|OMAGIC); /* Magic byte for file header */
-#endif /* TE_SUN3 */
-
-#define AOUT_MACHTYPE 0x2
-#define REVERSE_SORT_RELOCS /* FIXME-NOW: this line can be removed. */
-#define LOCAL_LABELS_FB
-
-#define tc_crawl_symbol_chain(a) {;} /* not used */
-#define tc_headers_hook(a) {;} /* not used */
-#define tc_aout_pre_write_hook(x) {;} /* not used */
-
-#define LISTING_WORD_SIZE 2 /* A word is 2 bytes */
-#define LISTING_LHS_WIDTH 3 /* 3 word on the first line */
-#define LISTING_LHS_WIDTH_SECOND 3 /* One word on the second line */
-#define LISTING_LHS_CONT_LINES 4 /* And 4 lines max */
-#define LISTING_HEADER "68K GAS "
-
-/* Copied from write.c */
-#define M68K_AIM_KLUDGE(aim, this_state,this_type) \
- if (aim == 0 && this_state == 4) { /* hard encoded from tc-m68k.c */ \
- aim=this_type->rlx_forward+1; /* Force relaxation into word mode */ \
- }
-#define MRI
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-m68kmote.h */
diff --git a/gnu/usr.bin/as/config/tc-m88k.c b/gnu/usr.bin/as/config/tc-m88k.c
deleted file mode 100644
index 34c6ba3..0000000
--- a/gnu/usr.bin/as/config/tc-m88k.c
+++ /dev/null
@@ -1,1435 +0,0 @@
-/* m88k.c -- Assembler for the Motorola 88000
- Contributed by Devon Bowen of Buffalo University
- and Torbjorn Granlund of the Swedish Institute of Computer Science.
- Copyright (C) 1989-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "as.h"
-#include "opcode/m88k.h"
-
-struct m88k_insn
-{
- unsigned long opcode;
- expressionS exp;
- enum reloc_type reloc;
-};
-
-#if __STDC__ == 1
-
-static int calcop(struct m88k_opcode *format, char *param, struct m88k_insn *insn);
-
-#else /* not __STDC__ */
-
-static int calcop();
-
-#endif /* not __STDC__ */
-
-char *getval ();
-char *get_reg ();
-char *get_imm16 ();
-char *get_bf ();
-char *get_pcr ();
-char *get_cmp ();
-char *get_cnd ();
-char *get_cr ();
-char *get_fcr ();
-char *get_vec9 ();
-
-struct field_val_assoc
-{
- char *name;
- unsigned val;
-};
-
-struct field_val_assoc cr_regs[] =
-{
- {"PID", 0},
- {"PSR", 1},
- {"EPSR", 2},
- {"SSBR", 3},
- {"SXIP", 4},
- {"SNIP", 5},
- {"SFIP", 6},
- {"VBR", 7},
- {"DMT0", 8},
- {"DMD0", 9},
- {"DMA0", 10},
- {"DMT1", 11},
- {"DMD1", 12},
- {"DMA1", 13},
- {"DMT2", 14},
- {"DMD2", 15},
- {"DMA2", 16},
- {"SR0", 17},
- {"SR1", 18},
- {"SR2", 19},
- {"SR3", 20},
-
- {NULL, 0},
-};
-
-struct field_val_assoc fcr_regs[] =
-{
- {"FPECR", 0},
- {"FPHS1", 1},
- {"FPLS1", 2},
- {"FPHS2", 3},
- {"FPLS2", 4},
- {"FPPT", 5},
- {"FPRH", 6},
- {"FPRL", 7},
- {"FPIT", 8},
-
- {"FPSR", 62},
- {"FPCR", 63},
-
- {NULL, 0},
-};
-
-struct field_val_assoc cmpslot[] =
-{
-/* Integer Floating point */
- {"nc", 0},
- {"cp", 1},
- {"eq", 2},
- {"ne", 3},
- {"gt", 4},
- {"le", 5},
- {"lt", 6},
- {"ge", 7},
- {"hi", 8}, {"ou", 8},
- {"ls", 9}, {"ib", 9},
- {"lo", 10}, {"in", 10},
- {"hs", 11}, {"ob", 11},
-
- {NULL, 0},
-};
-
-struct field_val_assoc cndmsk[] =
-{
- {"gt0", 1},
- {"eq0", 2},
- {"ge0", 3},
- {"lt0", 12},
- {"ne0", 13},
- {"le0", 14},
-
- {NULL, 0},
-};
-
-extern char *myname;
-static struct hash_control *op_hash = NULL;
-
-/* These bits should be turned off in the first address of every segment */
-int md_seg_align = 7;
-
-/* This is the number to put at the beginning of the a.out file */
-long omagic = OMAGIC;
-
-/* These chars start a comment anywhere in a source file (except inside
- another comment */
-char comment_chars[] = ";";
-
-/* These chars only start a comment at the beginning of a line. */
-char line_comment_chars[] = "#";
-
-/* Chars that can be used to separate mant from exp in floating point nums */
-char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant */
-/* as in 0f123.456 */
-/* or 0H1.234E-12 (see exp chars above) */
-char FLT_CHARS[] = "dDfF";
-
-extern void float_cons (), cons (), s_globl (), s_line (),
- s_space (), s_set (), stringer (), s_lcomm ();
-static void s_bss ();
-
-const pseudo_typeS md_pseudo_table[] = {
- {"align", s_align_bytes, 0 },
- {"def", s_set, 0},
- {"dfloat", float_cons, 'd'},
- {"ffloat", float_cons, 'f'},
- {"global", s_globl, 0},
- {"half", cons, 2 },
- {"bss", s_bss, 0},
- {"string", stringer, 0},
- {"word", cons, 4 },
- {"zero", s_space, 0},
- {0}
-};
-
-const int md_reloc_size = 12; /* Size of relocation record */
-
-void
-md_begin ()
-{
- char *retval = NULL;
- unsigned int i = 0;
-
- /* initialize hash table */
-
- op_hash = hash_new ();
- if (op_hash == NULL)
- as_fatal ("Could not initialize hash table");
-
- /* loop until you see the end of the list */
-
- while (*m88k_opcodes[i].name)
- {
- char *name = m88k_opcodes[i].name;
-
- /* hash each mnemonic and record its position */
-
- retval = hash_insert (op_hash, name, &m88k_opcodes[i]);
-
- if (retval != NULL && *retval != '\0')
- as_fatal ("Can't hash instruction '%s':%s",
- m88k_opcodes[i].name, retval);
-
- /* skip to next unique mnemonic or end of list */
-
- for (i++; !strcmp (m88k_opcodes[i].name, name); i++)
- ;
- }
-}
-
-int
-md_parse_option (argP, cntP, vecP)
- char **argP;
- int *cntP;
- char ***vecP;
-{
- as_warn ("unknown option: -%s", *argP);
- return(0);
-}
-
-void
-md_assemble (op)
- char *op;
-{
- char *param, *thisfrag;
- struct m88k_opcode *format;
- struct m88k_insn insn;
-
- assert (op);
-
- /* skip over instruction to find parameters */
-
- for (param = op; *param != 0 && !isspace (*param); param++)
- ;
- if (*param != 0)
- *param++ = 0;
-
- /* try to find the instruction in the hash table */
-
- if ((format = (struct m88k_opcode *) hash_find (op_hash, op)) == NULL)
- {
- as_fatal ("Invalid mnemonic '%s'", op);
- return;
- }
-
- /* try parsing this instruction into insn */
-
- insn.exp.X_add_symbol = 0;
- insn.exp.X_subtract_symbol = 0;
- insn.exp.X_add_number = 0;
- insn.exp.X_seg = 0;
- insn.reloc = NO_RELOC;
-
- while (!calcop(format, param, &insn))
- {
- /* if it doesn't parse try the next instruction */
-
- if (!strcmp (format[0].name, format[1].name))
- format++;
- else
- {
- as_fatal ("Parameter syntax error");
- return;
- }
- }
-
- /* grow the current frag and plop in the opcode */
-
- thisfrag = frag_more (4);
- md_number_to_chars (thisfrag, insn.opcode, 4);
-
- /* if this instruction requires labels mark it for later */
-
- switch (insn.reloc)
- {
- case NO_RELOC:
- break;
-
- case RELOC_LO16:
- case RELOC_HI16:
- fix_new (frag_now,
- thisfrag - frag_now->fr_literal + 2,
- 2,
- insn.exp.X_add_symbol,
- insn.exp.X_subtract_symbol,
- insn.exp.X_add_number,
- 0,
- insn.reloc);
- break;
-
- case RELOC_IW16:
- fix_new (frag_now,
- thisfrag - frag_now->fr_literal,
- 4,
- insn.exp.X_add_symbol,
- insn.exp.X_subtract_symbol,
- insn.exp.X_add_number,
- 0,
- insn.reloc);
- break;
-
- case RELOC_PC16:
- fix_new (frag_now,
- thisfrag - frag_now->fr_literal + 2,
- 2,
- insn.exp.X_add_symbol,
- insn.exp.X_subtract_symbol,
- insn.exp.X_add_number,
- 1,
- insn.reloc);
- break;
-
- case RELOC_PC26:
- fix_new (frag_now,
- thisfrag - frag_now->fr_literal,
- 4,
- insn.exp.X_add_symbol,
- insn.exp.X_subtract_symbol,
- insn.exp.X_add_number,
- 1,
- insn.reloc);
- break;
-
- default:
- as_fatal ("Unknown relocation type");
- break;
- }
-}
-
-int
-calcop (format, param, insn)
- struct m88k_opcode *format;
- char *param;
- struct m88k_insn *insn;
-{
- char *fmt = format->op_spec;
- int f;
- unsigned val;
- unsigned opcode;
-
- insn->opcode = format->opcode;
- opcode = 0;
-
- for (;;)
- {
- if (param == 0)
- return 0;
- f = *fmt++;
- switch (f)
- {
- case 0:
- insn->opcode |= opcode;
- return *param == 0;
-
- default:
- if (f != *param++)
- return 0;
- break;
-
- case 'd':
- param = get_reg (param, &val);
- opcode |= val << 21;
- break;
-
- case '1':
- param = get_reg (param, &val);
- opcode |= val << 16;
- break;
-
- case '2':
- param = get_reg (param, &val);
- opcode |= val;
- break;
-
- case '3':
- param = get_reg (param, &val);
- opcode |= (val << 16) | val;
- break;
-
- case 'I':
- param = get_imm16 (param, insn);
- break;
-
- case 'b':
- param = get_bf (param, &val);
- opcode |= val;
- break;
-
- case 'p':
- param = get_pcr (param, insn, RELOC_PC16);
- break;
-
- case 'P':
- param = get_pcr (param, insn, RELOC_PC26);
- break;
-
- case 'B':
- param = get_cmp (param, &val);
- opcode |= val;
- break;
-
- case 'M':
- param = get_cnd (param, &val);
- opcode |= val;
- break;
-
- case 'c':
- param = get_cr (param, &val);
- opcode |= val << 5;
- break;
-
- case 'f':
- param = get_fcr (param, &val);
- opcode |= val << 5;
- break;
-
- case 'V':
- param = get_vec9 (param, &val);
- opcode |= val;
- break;
-
- case '?':
- /* Having this here repeats the warning somtimes.
- But can't we stand that? */
- as_warn ("Use of obsolete instruction");
- break;
- }
- }
-}
-
-char *
-match_name (param, assoc_tab, valp)
- char *param;
- struct field_val_assoc *assoc_tab;
- unsigned *valp;
-{
- int i;
- char *name;
- int name_len;
-
- for (i = 0;; i++)
- {
- name = assoc_tab[i].name;
- if (name == NULL)
- return NULL;
- name_len = strlen (name);
- if (!strncmp (param, name, name_len))
- {
- *valp = assoc_tab[i].val;
- return param + name_len;
- }
- }
-}
-
-char *
-get_reg (param, regnop)
- char *param;
- unsigned *regnop;
-{
- unsigned c;
- unsigned regno;
-
- c = *param++;
- if (c == 'r')
- {
- regno = *param++ - '0';
- if (regno < 10)
- {
- if (regno == 0)
- {
- *regnop = 0;
- return param;
- }
- c = *param - '0';
- if (c < 10)
- {
- regno = regno * 10 + c;
- if (c < 32)
- {
- *regnop = regno;
- return param + 1;
- }
- }
- else
- {
- *regnop = regno;
- return param;
- }
- }
- return NULL;
- }
- else if (c == 's' && param[0] == 'p')
- {
- *regnop = 31;
- return param + 1;
- }
-
- return 0;
-}
-
-char *
-get_imm16 (param, insn)
- char *param;
- struct m88k_insn *insn;
-{
- enum reloc_type reloc = NO_RELOC;
- unsigned int val;
- segT seg;
- char *save_ptr;
-
- if (!strncmp (param, "hi16", 4) && !isalnum (param[4]))
- {
- reloc = RELOC_HI16;
- param += 4;
- }
- else if (!strncmp (param, "lo16", 4) && !isalnum (param[4]))
- {
- reloc = RELOC_LO16;
- param += 4;
- }
- else if (!strncmp (param, "iw16", 4) && !isalnum (param[4]))
- {
- reloc = RELOC_IW16;
- param += 4;
- }
-
- save_ptr = input_line_pointer;
- input_line_pointer = param;
- seg = expression (&insn->exp);
- param = input_line_pointer;
- input_line_pointer = save_ptr;
-
- val = insn->exp.X_add_number;
-
- if (seg == SEG_ABSOLUTE)
- {
- /* Insert the value now, and reset reloc to NO_RELOC. */
- if (reloc == NO_RELOC)
- {
- /* Warn about too big expressions if not surrounded by xx16. */
- if (val > 0xffff)
- as_warn ("Expression truncated to 16 bits");
- }
-
- if (reloc == RELOC_HI16)
- val >>= 16;
-
- insn->opcode |= val & 0xffff;
- reloc = NO_RELOC;
- }
- else if (reloc == NO_RELOC)
- /* We accept a symbol even without lo16, hi16, etc, and assume
- lo16 was intended. */
- reloc = RELOC_LO16;
-
- insn->reloc = reloc;
-
- return param;
-}
-
-char *
-get_pcr (param, insn, reloc)
- char *param;
- struct m88k_insn *insn;
- enum reloc_type reloc;
-{
- char *saveptr, *saveparam;
- segT seg;
-
- saveptr = input_line_pointer;
- input_line_pointer = param;
-
- seg = expression (&insn->exp);
-
- saveparam = input_line_pointer;
- input_line_pointer = saveptr;
-
- /* Botch: We should relocate now if SEG_ABSOLUTE. */
- insn->reloc = reloc;
-
- return saveparam;
-}
-
-char *
-get_cmp (param, valp)
- char *param;
- unsigned *valp;
-{
- unsigned int val;
- char *save_ptr;
-
- save_ptr = param;
-
- param = match_name (param, cmpslot, valp);
- val = *valp;
-
- if (param == NULL)
- {
- param = save_ptr;
-
- save_ptr = input_line_pointer;
- input_line_pointer = param;
- val = get_absolute_expression ();
- param = input_line_pointer;
- input_line_pointer = save_ptr;
-
- if (val >= 32)
- {
- as_warn ("Expression truncated to 5 bits");
- val %= 32;
- }
- }
-
- *valp = val << 21;
- return param;
-}
-
-char *
-get_cnd (param, valp)
- char *param;
- unsigned *valp;
-{
- unsigned int val;
-
- if (isdigit (*param))
- {
- param = getval (param, &val);
-
- if (val >= 32)
- {
- as_warn ("Expression truncated to 5 bits");
- val %= 32;
- }
- }
- else
- {
- if (isupper (*param))
- *param = tolower (*param);
-
- if (isupper (param[1]))
- param[1] = tolower (param[1]);
-
- param = match_name (param, cndmsk, valp);
-
- if (param == NULL)
- return NULL;
-
- val = *valp;
- }
-
- *valp = val << 21;
- return param;
-}
-
-char *
-get_bf2 (param, bc)
- char *param;
- int bc;
-{
- int depth = 0;
- int c;
-
- for (;;)
- {
- c = *param;
- if (c == 0)
- return param;
- else if (c == '(')
- depth++;
- else if (c == ')')
- depth--;
- else if (c == bc && depth <= 0)
- return param;
- param++;
- }
-}
-
-char *
-get_bf_offset_expression (param, offsetp)
- char *param;
- unsigned *offsetp;
-{
- unsigned offset;
-
- if (isalpha (param[0]))
- {
- if (isupper (param[0]))
- param[0] = tolower (param[0]);
- if (isupper (param[1]))
- param[1] = tolower (param[1]);
-
- param = match_name (param, cmpslot, offsetp);
-
- return param;
- }
- else
- {
- input_line_pointer = param;
- offset = get_absolute_expression ();
- param = input_line_pointer;
- }
-
- *offsetp = offset;
- return param;
-}
-
-char *
-get_bf (param, valp)
- char *param;
- unsigned *valp;
-{
- unsigned offset = 0;
- unsigned width = 0;
- char *xp;
- char *save_ptr;
-
- xp = get_bf2 (param, '<');
-
- save_ptr = input_line_pointer;
- input_line_pointer = param;
- if (*xp == 0)
- {
- /* We did not find '<'. We have an offset (width implicitly 32). */
- param = get_bf_offset_expression (param, &offset);
- if (param == NULL)
- return NULL;
- input_line_pointer = save_ptr;
- }
- else
- {
- *xp++ = 0; /* Overwrite the '<' */
- param = get_bf2 (xp, '>');
- if (*param == 0)
- return NULL;
- *param++ = 0; /* Overwrite the '>' */
-
- width = get_absolute_expression ();
- xp = get_bf_offset_expression (xp, &offset);
- input_line_pointer = save_ptr;
-
- if (xp + 1 != param)
- return NULL;
- }
-
- *valp = ((width % 32) << 5) | (offset % 32);
-
- return param;
-}
-
-char *
-get_cr (param, regnop)
- char *param;
- unsigned *regnop;
-{
- unsigned regno;
- unsigned c;
-/* int i; FIXME remove this */
-/* int name_len; FIXME remove this */
-
- if (!strncmp (param, "cr", 2))
- {
- param += 2;
-
- regno = *param++ - '0';
- if (regno < 10)
- {
- if (regno == 0)
- {
- *regnop = 0;
- return param;
- }
- c = *param - '0';
- if (c < 10)
- {
- regno = regno * 10 + c;
- if (c < 64)
- {
- *regnop = regno;
- return param + 1;
- }
- }
- else
- {
- *regnop = regno;
- return param;
- }
- }
- return NULL;
- }
-
- param = match_name (param, cr_regs, regnop);
-
- return param;
-}
-
-char *
-get_fcr (param, regnop)
- char *param;
- unsigned *regnop;
-{
- unsigned regno;
- unsigned c;
-/* int i; FIXME remove this */
-/* int name_len; FIXME: remove this */
-
- if (!strncmp (param, "fcr", 3))
- {
- param += 3;
-
- regno = *param++ - '0';
- if (regno < 10)
- {
- if (regno == 0)
- {
- *regnop = 0;
- return param;
- }
- c = *param - '0';
- if (c < 10)
- {
- regno = regno * 10 + c;
- if (c < 64)
- {
- *regnop = regno;
- return param + 1;
- }
- }
- else
- {
- *regnop = regno;
- return param;
- }
- }
- return NULL;
- }
-
- param = match_name (param, fcr_regs, regnop);
-
- return param;
-}
-
-char *
-get_vec9 (param, valp)
- char *param;
- unsigned *valp;
-{
- unsigned val;
- char *save_ptr;
-
- save_ptr = input_line_pointer;
- input_line_pointer = param;
- val = get_absolute_expression ();
- param = input_line_pointer;
- input_line_pointer = save_ptr;
-
- if (val >= 1 << 9)
- as_warn ("Expression truncated to 9 bits");
-
- *valp = val % (1 << 9);
-
- return param;
-}
-
-#define hexval(z) \
- (isdigit (z) ? (z) - '0' : \
- islower (z) ? (z) - 'a' + 10 : \
- isupper (z) ? (z) - 'A' + 10 : -1)
-
-char *
-getval (param, valp)
- char *param;
- unsigned int *valp;
-{
- unsigned int val = 0;
- unsigned int c;
-
- c = *param++;
- if (c == '0')
- {
- c = *param++;
- if (c == 'x' || c == 'X')
- {
- c = *param++;
- c = hexval (c);
- while (c < 16)
- {
- val = val * 16 + c;
- c = *param++;
- c = hexval (c);
- }
- }
- else
- {
- c -= '0';
- while (c < 8)
- {
- val = val * 8 + c;
- c = *param++ - '0';
- }
- }
- }
- else
- {
- c -= '0';
- while (c < 10)
- {
- val = val * 10 + c;
- c = *param++ - '0';
- }
- }
-
- *valp = val;
- return param - 1;
-}
-
-void
-md_number_to_chars (buf, val, nbytes)
-char *buf;
-long val;
-int nbytes;
-{
- switch (nbytes)
- {
- case 4:
- *buf++ = val >> 24;
- *buf++ = val >> 16;
- case 2:
- *buf++ = val >> 8;
- case 1:
- *buf = val;
- break;
-
- default:
- abort ();
- }
-}
-
-#ifdef comment
-
-void
-md_number_to_imm (buf, val, nbytes, fixP, seg_type)
-unsigned char *buf;
-unsigned int val;
-int nbytes;
-fixS *fixP;
-int seg_type;
-{
- if (seg_type != N_TEXT || fixP->fx_r_type == NO_RELOC)
- {
- switch (nbytes)
- {
- case 4:
- *buf++ = val >> 24;
- *buf++ = val >> 16;
- case 2:
- *buf++ = val >> 8;
- case 1:
- *buf = val;
- break;
-
- default:
- abort ();
- }
- return;
- }
-
- switch (fixP->fx_r_type)
- {
- case RELOC_IW16:
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
- case RELOC_LO16:
- buf[0] = val >> 8;
- buf[1] = val;
- break;
-
- case RELOC_HI16:
- buf[0] = val >> 24;
- buf[1] = val >> 16;
- break;
-
- case RELOC_PC16:
- val += 4;
- buf[0] = val >> 10;
- buf[1] = val >> 2;
- break;
-
- case RELOC_PC26:
- val += 4;
- buf[0] |= (val >> 26) & 0x03;
- buf[1] = val >> 18;
- buf[2] = val >> 10;
- buf[3] = val >> 2;
- break;
-
- case RELOC_32:
- buf[0] = val >> 24;
- buf[1] = val >> 16;
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
- default:
- as_fatal ("Bad relocation type");
- break;
- }
-}
-#endif /* comment */
-
-/* Apply a fixS to the frags, now that we know the value it ought to
- hold. */
-
-void md_apply_fix(fixP, val)
-fixS *fixP;
-long val;
-{
- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- fixP->fx_addnumber = val;
-
-
- switch (fixP->fx_r_type) {
-
- case RELOC_IW16:
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
- case RELOC_LO16:
- buf[0] = val >> 8;
- buf[1] = val;
- break;
-
- case RELOC_HI16:
- buf[0] = val >> 24;
- buf[1] = val >> 16;
- break;
-
- case RELOC_PC16:
- val += 4;
- buf[0] = val >> 10;
- buf[1] = val >> 2;
- break;
-
- case RELOC_PC26:
- val += 4;
- buf[0] |= (val >> 26) & 0x03;
- buf[1] = val >> 18;
- buf[2] = val >> 10;
- buf[3] = val >> 2;
- break;
-
- case RELOC_32:
- buf[0] = val >> 24;
- buf[1] = val >> 16;
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
- case NO_RELOC:
- switch (fixP->fx_size) {
- case 4:
- *buf++ = val >> 24;
- *buf++ = val >> 16;
- case 2:
- *buf++ = val >> 8;
- case 1:
- *buf = val;
- break;
-
- default:
- abort ();
- }
-
- default:
- as_bad("bad relocation type: 0x%02x", fixP->fx_r_type);
- break;
- }
-
- return;
-} /* md_apply_fix() */
-
-void
-md_number_to_disp (buf, val, nbytes)
-char *buf;
-int val;
-int nbytes;
-{
- as_fatal ("md_number_to_disp not defined");
- md_number_to_chars (buf, val, nbytes);
-}
-
-void
-md_number_to_field (buf, val, nbytes)
-char *buf;
-int val;
-int nbytes;
-{
- as_fatal ("md_number_to_field not defined");
- md_number_to_chars (buf, val, nbytes);
-}
-
-#define MAX_LITTLENUMS 6
-
-/* Turn a string in input_line_pointer into a floating point constant of type
- type, and store the appropriate bytes in *litP. The number of LITTLENUMS
- emitted is stored in *sizeP. An error message is returned, or NULL on OK.
- */
-char *
-md_atof (type, litP, sizeP)
- char type;
- char *litP;
- int *sizeP;
-{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- char *t;
- char *atof_ieee ();
-
- switch (type)
- {
- case 'f':
- case 'F':
- case 's':
- case 'S':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- prec = 4;
- break;
-
- case 'x':
- case 'X':
- prec = 6;
- break;
-
- case 'p':
- case 'P':
- prec = 6;
- break;
-
- default:
- *sizeP=0;
- return "Bad call to MD_ATOF()";
- }
- t=atof_ieee (input_line_pointer, type, words);
- if (t)
- input_line_pointer=t;
-
- *sizeP=prec * sizeof (LITTLENUM_TYPE);
- for (wordP=words;prec--;)
- {
- md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
- litP+=sizeof (LITTLENUM_TYPE);
- }
- return ""; /* Someone should teach Dean about null pointers */
-}
-
-int md_short_jump_size = 4;
-
-void
-md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
- char *ptr;
- long from_addr, to_addr;
- fragS *frag;
- symbolS *to_symbol;
-{
- ptr[0] = 0xc0; ptr[1] = 0x00; ptr[2] = 0x00; ptr[3] = 0x00;
- fix_new (frag,
- ptr - frag->fr_literal,
- 4,
- to_symbol,
- (symbolS *) 0,
- (long int) 0,
- 0,
- RELOC_PC26); /* Botch: Shouldn't this be RELOC_PC16? */
-}
-
-int md_long_jump_size = 4;
-
-void
-md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
- char *ptr;
- long from_addr, to_addr;
- fragS *frag;
- symbolS *to_symbol;
-{
- ptr[0] = 0xc0; ptr[1] = 0x00; ptr[2] = 0x00; ptr[3] = 0x00;
- fix_new (frag,
- ptr - frag->fr_literal,
- 4,
- to_symbol,
- (symbolS *) 0,
- (long int) 0,
- 0,
- RELOC_PC26);
-}
-
-int
-md_estimate_size_before_relax (fragP, segment_type)
- fragS *fragP;
- segT segment_type;
-{
- as_fatal("Relaxation should never occur");
- return(0);
-}
-
-const relax_typeS md_relax_table[] = {0};
-
-void
-md_convert_frag (headers, fragP)
-object_headers *headers;
- fragS *fragP;
-{
- as_fatal ("Relaxation should never occur");
-}
-
-void
-md_end ()
-{
-}
-
-#ifdef comment
-
-/*
- * Risc relocations are completely different, so it needs
- * this machine dependent routine to emit them.
- */
-void
-emit_relocations (fixP, segment_address_in_file)
- fixS *fixP;
- relax_addressT segment_address_in_file;
-{
- struct reloc_info_m88k ri;
- symbolS *symbolP;
- extern char *next_object_file_charP;
-
- bzero ((char *) &ri, sizeof (ri));
- for (; fixP; fixP = fixP->fx_next) {
-
- if (fixP->fx_r_type >= NO_RELOC) {
- fprintf (stderr, "fixP->fx_r_type = %d\n", fixP->fx_r_type);
- abort ();
- }
-
- if ((symbolP = fixP->fx_addsy) != NULL) {
- ri.r_address = fixP->fx_frag->fr_address +
- fixP->fx_where - segment_address_in_file;
- if ((symbolP->sy_type & N_TYPE) == N_UNDF) {
- ri.r_extern = 1;
- ri.r_symbolnum = symbolP->sy_number;
- } else {
- ri.r_extern = 0;
- ri.r_symbolnum = symbolP->sy_type & N_TYPE;
- }
- if (symbolP && symbolP->sy_frag) {
- ri.r_addend = symbolP->sy_frag->fr_address;
- }
- ri.r_type = fixP->fx_r_type;
- if (fixP->fx_pcrel) {
-/* ri.r_addend -= fixP->fx_where; */
- ri.r_addend -= ri.r_address;
- } else {
- ri.r_addend = fixP->fx_addnumber;
- }
-
-/* md_ri_to_chars ((char *) &ri, ri); */
- append (&next_object_file_charP, (char *)& ri, sizeof (ri));
- }
- }
- return;
-}
-#endif /* comment */
-
-/* Translate internal representation of relocation info to target format.
-
- On m88k: first 4 bytes are normal unsigned long address,
- next three bytes are index, most sig. byte first.
- Byte 7 is broken up with bit 7 as external,
- bits 6, 5, & 4 unused, and the lower four bits as relocation
- type.
- Next 4 bytes are long addend. */
-
-void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
-char *where;
-fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- long r_index;
- long r_extern;
- long r_addend = 0;
- long r_address;
-
- know(fixP->fx_addsy);
-
- if (!S_IS_DEFINED(fixP->fx_addsy)) {
- r_extern = 1;
- r_index = fixP->fx_addsy->sy_number;
- } else {
- r_extern = 0;
- r_index = S_GET_TYPE(fixP->fx_addsy);
- }
-
- /* this is easy */
- md_number_to_chars(where,
- r_address = fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
- 4);
-
- /* now the fun stuff */
- where[4] = (r_index >> 16) & 0x0ff;
- where[5] = (r_index >> 8) & 0x0ff;
- where[6] = r_index & 0x0ff;
- where[7] = ((r_extern << 7) & 0x80) | (0 & 0x70) | (fixP->fx_r_type & 0xf);
-
- /* Also easy */
- if (fixP->fx_addsy->sy_frag) {
- r_addend = fixP->fx_addsy->sy_frag->fr_address;
- }
-
- if (fixP->fx_pcrel) {
- r_addend -= r_address;
- } else {
- r_addend = fixP->fx_addnumber;
- }
-
- md_number_to_chars(&where[8], r_addend, 4);
-
- return;
-} /* tc_aout_fix_to_chars() */
-
-
-static void
-s_bss()
-{
- char *name;
- char c;
- char *p;
- int temp, bss_align = 1;
- symbolS *symbolP;
- extern char is_end_of_line[256];
-
- name = input_line_pointer;
- c = get_symbol_end();
- p = input_line_pointer;
- *p = c;
- SKIP_WHITESPACE();
- if ( * input_line_pointer != ',' )
- {
- as_warn("Expected comma after name");
- ignore_rest_of_line();
- return;
- }
- input_line_pointer ++;
- if ((temp = get_absolute_expression()) < 0)
- {
- as_warn("BSS length (%d.) <0! Ignored.", temp);
- ignore_rest_of_line();
- return;
- }
- *p = 0;
- symbolP = symbol_find_or_make(name);
- *p = c;
- if (*input_line_pointer == ',')
- {
- input_line_pointer++;
- bss_align = get_absolute_expression();
- while (local_bss_counter % bss_align != 0)
- local_bss_counter++;
- }
-
- if (!S_IS_DEFINED(symbolP)
- || (S_GET_SEGMENT(symbolP) == SEG_BSS
- && S_GET_VALUE(symbolP) == local_bss_counter)) {
- S_SET_VALUE(symbolP, local_bss_counter);
- S_SET_SEGMENT(symbolP, SEG_BSS);
- symbolP->sy_frag = &bss_address_frag;
- local_bss_counter += temp;
- } else {
- as_warn( "Ignoring attempt to re-define symbol from %d. to %d.",
- S_GET_VALUE(symbolP), local_bss_counter );
- }
- while (!is_end_of_line[*input_line_pointer])
- {
- input_line_pointer++;
- }
-
- return;
-}
-
-/* We have no need to default values of symbols. */
-
-/* ARGSUSED */
-symbolS *md_undefined_symbol(name)
-char *name;
-{
- return 0;
-} /* md_undefined_symbol() */
-
-/* Parse an operand that is machine-specific.
- We just return without modifying the expression if we have nothing
- to do. */
-
-/* ARGSUSED */
-void md_operand(expressionP)
-expressionS *expressionP;
-{
-} /* md_operand() */
-
-/* Round up a section size to the appropriate boundary. */
-long md_section_align(segment, size)
-segT segment;
-long size;
-{
- return((size + 7) & ~7); /* Round all sects to multiple of 8 */
-} /* md_section_align() */
-
-/* Exactly what point is a PC-relative offset relative TO?
- On the sparc, they're relative to the address of the offset, plus
- its size. This gets us to the following instruction.
- (??? Is this right? FIXME-SOON) */
-long md_pcrel_from(fixP)
-fixS *fixP;
-{
- return(fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address);
-} /* md_pcrel_from() */
-
- /* end of tc-m88k.c */
diff --git a/gnu/usr.bin/as/config/tc-m88k.h b/gnu/usr.bin/as/config/tc-m88k.h
deleted file mode 100644
index f518085..0000000
--- a/gnu/usr.bin/as/config/tc-m88k.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* m88k.h -- Assembler for the Motorola 88000
- Contributed by Devon Bowen of Buffalo University
- and Torbjorn Granlund of the Swedish Institute of Computer Science.
- Copyright (C) 1989-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define TC_M88K 1
-
-#define NO_LISTING
-#define NO_DOT_PSEUDOS
-#define ALLOW_ATSIGN
-
-#define LOCAL_LABEL(name) (name[0] == '@' \
- && ( name[1] == 'L' || name[1] == '.' ))
-
-#define tc_crawl_symbol_chain(a) {;} /* not used */
-#define tc_headers_hook(a) {;} /* not used */
-#define tc_aout_pre_write_hook(x) {;} /* not used */
-
- /* end of tc-m88k.h */
diff --git a/gnu/usr.bin/as/config/tc-mips.c b/gnu/usr.bin/as/config/tc-mips.c
deleted file mode 100644
index e69de29..0000000
--- a/gnu/usr.bin/as/config/tc-mips.c
+++ /dev/null
diff --git a/gnu/usr.bin/as/config/tc-mips.h b/gnu/usr.bin/as/config/tc-mips.h
deleted file mode 100644
index e69de29..0000000
--- a/gnu/usr.bin/as/config/tc-mips.h
+++ /dev/null
diff --git a/gnu/usr.bin/as/config/tc-ns32k.c b/gnu/usr.bin/as/config/tc-ns32k.c
deleted file mode 100644
index e82b07b..0000000
--- a/gnu/usr.bin/as/config/tc-ns32k.c
+++ /dev/null
@@ -1,2015 +0,0 @@
-/* ns32k.c -- Assemble on the National Semiconductor 32k series
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*#define SHOW_NUM 1*/ /* uncomment for debugging */
-
-#include <stdio.h>
-#include <ctype.h>
-#ifdef USG
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-#include "opcode/ns32k.h"
-
-#include "as.h"
-
-#include "obstack.h"
-
-/* Macros */
-#define IIF_ENTRIES 13 /* number of entries in iif */
-#define PRIVATE_SIZE 256 /* size of my garbage memory */
-#define MAX_ARGS 4
-#define DEFAULT -1 /* addr_mode returns this value when plain constant or label is encountered */
-
-#define IIF(ptr,a1,c1,e1,g1,i1,k1,m1,o1,q1,s1,u1) \
- iif.iifP[ptr].type= a1; \
- iif.iifP[ptr].size= c1; \
- iif.iifP[ptr].object= e1; \
- iif.iifP[ptr].object_adjust= g1; \
- iif.iifP[ptr].pcrel= i1; \
- iif.iifP[ptr].pcrel_adjust= k1; \
- iif.iifP[ptr].im_disp= m1; \
- iif.iifP[ptr].relax_substate= o1; \
- iif.iifP[ptr].bit_fixP= q1; \
- iif.iifP[ptr].addr_mode= s1; \
- iif.iifP[ptr].bsr= u1;
-
-#ifdef TE_SEQUENT
-#define LINE_COMMENT_CHARS "|"
-#define ABSOLUTE_PREFIX '@'
-#define IMMEDIATE_PREFIX '#'
-#endif
-
-#ifndef LINE_COMMENT_CHARS
-#define LINE_COMMENT_CHARS "#"
-#endif
-
-const char comment_chars[] = "#";
-const char line_comment_chars[] = LINE_COMMENT_CHARS;
-#if !defined(ABSOLUTE_PREFIX) && !defined(IMMEDIATE_PREFIX)
-#define ABSOLUTE_PREFIX '@' /* One or the other MUST be defined */
-#endif
-
-struct addr_mode {
- char mode; /* addressing mode of operand (0-31) */
- char scaled_mode; /* mode combined with scaled mode */
- char scaled_reg; /* register used in scaled+1 (1-8) */
- char float_flag; /* set if R0..R7 was F0..F7 ie a floating-point-register */
- char am_size; /* estimated max size of general addr-mode parts*/
- char im_disp; /* if im_disp == 1 we have a displacement */
- char pcrel; /* 1 if pcrel, this is really redundant info */
- char disp_suffix[2]; /* length of displacement(s), 0=undefined */
- char *disp[2]; /* pointer(s) at displacement(s)
- or immediates(s) (ascii) */
- char index_byte; /* index byte */
-};
-typedef struct addr_mode addr_modeS;
-
-
-char *freeptr,*freeptr_static; /* points at some number of free bytes */
-struct hash_control *inst_hash_handle;
-
-struct ns32k_opcode *desc; /* pointer at description of instruction */
-addr_modeS addr_modeP;
-char EXP_CHARS[] = "eE";
-char FLT_CHARS[] = "fd"; /* we don't want to support lowercase, do we */
-
-/* UPPERCASE denotes live names
- * when an instruction is built, IIF is used as an intermidiate form to store
- * the actual parts of the instruction. A ns32k machine instruction can
- * be divided into a couple of sub PARTs. When an instruction is assembled
- * the appropriate PART get an assignment. When an IIF has been completed it's
- * converted to a FRAGment as specified in AS.H */
-
-/* internal structs */
-struct option {
- char *pattern;
- unsigned long or;
- unsigned long and;
-};
-
-typedef struct {
- int type; /* how to interpret object */
- int size; /* Estimated max size of object */
- unsigned long object; /* binary data */
- int object_adjust; /* number added to object */
- int pcrel; /* True if object is pcrel */
- int pcrel_adjust; /* length in bytes from the
- instruction start to the
- displacement */
- int im_disp; /* True if the object is a displacement */
- relax_substateT relax_substate; /* Initial relaxsubstate */
- bit_fixS *bit_fixP; /* Pointer at bit_fix struct */
- int addr_mode; /* What addrmode do we associate with this iif-entry */
- char bsr; /* Sequent hack */
-}iif_entryT; /* Internal Instruction Format */
-
-struct int_ins_form {
- int instr_size; /* Max size of instruction in bytes. */
- iif_entryT iifP[IIF_ENTRIES + 1];
-};
-struct int_ins_form iif;
-expressionS exprP;
-char *input_line_pointer;
-/* description of the PARTs in IIF
- *object[n]:
- * 0 total length in bytes of entries in iif
- * 1 opcode
- * 2 index_byte_a
- * 3 index_byte_b
- * 4 disp_a_1
- * 5 disp_a_2
- * 6 disp_b_1
- * 7 disp_b_2
- * 8 imm_a
- * 9 imm_b
- * 10 implied1
- * 11 implied2
- *
- * For every entry there is a datalength in bytes. This is stored in size[n].
- * 0, the objectlength is not explicitly given by the instruction
- * and the operand is undefined. This is a case for relaxation.
- * Reserve 4 bytes for the final object.
- *
- * 1, the entry contains one byte
- * 2, the entry contains two bytes
- * 3, the entry contains three bytes
- * 4, the entry contains four bytes
- * etc
- *
- * Furthermore, every entry has a data type identifier in type[n].
- *
- * 0, the entry is void, ignore it.
- * 1, the entry is a binary number.
- * 2, the entry is a pointer at an expression.
- * Where expression may be as simple as a single '1',
- * and as complicated as foo-bar+12,
- * foo and bar may be undefined but suffixed by :{b|w|d} to
- * control the length of the object.
- *
- * 3, the entry is a pointer at a bignum struct
- *
- *
- * The low-order-byte coresponds to low physical memory.
- * Obviously a FRAGment must be created for each valid disp in PART whose
- * datalength is undefined (to bad) .
- * The case where just the expression is undefined is less severe and is
- * handled by fix. Here the number of bytes in the objectfile is known.
- * With this representation we simplify the assembly and separates the
- * machine dependent/independent parts in a more clean way (said OE)
- */
-
-struct option opt1[]= /* restore, exit */
-{
- { "r0", 0x80, 0xff },
- { "r1", 0x40, 0xff },
- { "r2", 0x20, 0xff },
- { "r3", 0x10, 0xff },
- { "r4", 0x08, 0xff },
- { "r5", 0x04, 0xff },
- { "r6", 0x02, 0xff },
- { "r7", 0x01, 0xff },
- { 0 , 0x00, 0xff }
-};
-struct option opt2[]= /* save, enter */
-{
- { "r0", 0x01, 0xff },
- { "r1", 0x02, 0xff },
- { "r2", 0x04, 0xff },
- { "r3", 0x08, 0xff },
- { "r4", 0x10, 0xff },
- { "r5", 0x20, 0xff },
- { "r6", 0x40, 0xff },
- { "r7", 0x80, 0xff },
- { 0 , 0x00, 0xff }
-};
-struct option opt3[]= /* setcfg */
-{
- { "c", 0x8, 0xff },
- { "m", 0x4, 0xff },
- { "f", 0x2, 0xff },
- { "i", 0x1, 0xff },
- { 0 , 0x0, 0xff }
-};
-struct option opt4[]= /* cinv */
-{
- { "a", 0x4, 0xff },
- { "i", 0x2, 0xff },
- { "d", 0x1, 0xff },
- { 0 , 0x0, 0xff }
-};
-struct option opt5[]= /* string inst */
-{
- { "b", 0x2, 0xff },
- { "u", 0xc, 0xff },
- { "w", 0x4, 0xff },
- { 0 , 0x0, 0xff }
-};
-struct option opt6[]= /* plain reg ext,cvtp etc */
-{
- { "r0", 0x00, 0xff },
- { "r1", 0x01, 0xff },
- { "r2", 0x02, 0xff },
- { "r3", 0x03, 0xff },
- { "r4", 0x04, 0xff },
- { "r5", 0x05, 0xff },
- { "r6", 0x06, 0xff },
- { "r7", 0x07, 0xff },
- { 0 , 0x00, 0xff }
-};
-
-#if !defined(NS32032) && !defined(NS32532)
-#define NS32032
-#endif
-
-struct option cpureg_532[]= /* lpr spr */
-{
- { "us", 0x0, 0xff },
- { "dcr", 0x1, 0xff },
- { "bpc", 0x2, 0xff },
- { "dsr", 0x3, 0xff },
- { "car", 0x4, 0xff },
- { "fp", 0x8, 0xff },
- { "sp", 0x9, 0xff },
- { "sb", 0xa, 0xff },
- { "usp", 0xb, 0xff },
- { "cfg", 0xc, 0xff },
- { "psr", 0xd, 0xff },
- { "intbase", 0xe, 0xff },
- { "mod", 0xf, 0xff },
- { 0 , 0x00, 0xff }
-};
-struct option mmureg_532[]= /* lmr smr */
-{
- { "mcr", 0x9, 0xff },
- { "msr", 0xa, 0xff },
- { "tear", 0xb, 0xff },
- { "ptb0", 0xc, 0xff },
- { "ptb1", 0xd, 0xff },
- { "ivar0", 0xe, 0xff },
- { "ivar1", 0xf, 0xff },
- { 0 , 0x0, 0xff }
-};
-
-struct option cpureg_032[]= /* lpr spr */
-{
- { "upsr", 0x0, 0xff },
- { "fp", 0x8, 0xff },
- { "sp", 0x9, 0xff },
- { "sb", 0xa, 0xff },
- { "psr", 0xd, 0xff },
- { "intbase", 0xe, 0xff },
- { "mod", 0xf, 0xff },
- { 0 , 0x0, 0xff }
-};
-struct option mmureg_032[]= /* lmr smr */
-{
- { "bpr0", 0x0, 0xff },
- { "bpr1", 0x1, 0xff },
- { "pf0", 0x4, 0xff },
- { "pf1", 0x5, 0xff },
- { "sc", 0x8, 0xff },
- { "msr", 0xa, 0xff },
- { "bcnt", 0xb, 0xff },
- { "ptb0", 0xc, 0xff },
- { "ptb1", 0xd, 0xff },
- { "eia", 0xf, 0xff },
- { 0 , 0x0, 0xff }
-};
-
-#if defined(NS32532)
-struct option *cpureg = cpureg_532;
-struct option *mmureg = mmureg_532;
-#else
-struct option *cpureg = cpureg_032;
-struct option *mmureg = mmureg_032;
-#endif
-
-
-const pseudo_typeS md_pseudo_table[]={ /* so far empty */
- { 0, 0, 0 }
-};
-
-#define IND(x,y) (((x)<<2)+(y))
-
-/* those are index's to relax groups in md_relax_table
- ie it must be multiplied by 4 to point at a group start. Viz IND(x,y)
- Se function relax_segment in write.c for more info */
-
-#define BRANCH 1
-#define PCREL 2
-
-/* those are index's to entries in a relax group */
-
-#define BYTE 0
-#define WORD 1
-#define DOUBLE 2
-#define UNDEF 3
-/* Those limits are calculated from the displacement start in memory.
- The ns32k uses the begining of the instruction as displacement base.
- This type of displacements could be handled here by moving the limit window
- up or down. I choose to use an internal displacement base-adjust as there
- are other routines that must consider this. Also, as we have two various
- offset-adjusts in the ns32k (acb versus br/brs/jsr/bcond), two set of limits
- would have had to be used.
- Now we dont have to think about that. */
-
-
-const relax_typeS md_relax_table[] = {
- { 1, 1, 0, 0 },
- { 1, 1, 0, 0 },
- { 1, 1, 0, 0 },
- { 1, 1, 0, 0 },
-
- { (63), (-64), 1, IND(BRANCH,WORD) },
- { (8191), (-8192), 2, IND(BRANCH,DOUBLE) },
- { 0, 0, 4, 0 },
- { 1, 1, 0, 0 }
-};
-
-/* Array used to test if mode contains displacements.
- Value is true if mode contains displacement. */
-
-char disp_test[] = { 0,0,0,0,0,0,0,0,
- 1,1,1,1,1,1,1,1,
- 1,1,1,0,0,1,1,0,
- 1,1,1,1,1,1,1,1 };
-
-/* Array used to calculate max size of displacements */
-
-char disp_size[] = { 4,1,2,0,4 };
-
-#ifdef PIC
-/* In pic-mode all external pc-relative references are jmpslot
- references except references to __GLOBAL_OFFSET_TABLE_. */
-static symbolS *got_symbol;
-
-/* The size of got-offsets. */
-static int got_offset_size = 2;
-#endif
-
-
-
-#if __STDC__ == 1
-
-static segT evaluate_expr(expressionS *resultP, char *ptr);
-static void md_number_to_disp(char *buf, long val, int n);
-static void md_number_to_imm(char *buf, long val, int n);
-
-#else /* not __STDC__ */
-
-static segT evaluate_expr();
-static void md_number_to_disp();
-static void md_number_to_imm();
-
-#endif /* not __STDC__ */
-
-/* Parses a general operand into an addressingmode struct
-
- in: pointer at operand in ascii form
- pointer at addr_mode struct for result
- the level of recursion. (always 0 or 1)
-
- out: data in addr_mode struct
- */
-int addr_mode(operand,addr_modeP,recursive_level)
-char *operand;
-register addr_modeS *addr_modeP;
-int recursive_level;
-{
- register char *str;
- register int i;
- register int strl;
- register int mode;
- int j;
- mode = DEFAULT; /* default */
- addr_modeP->scaled_mode=0; /* why not */
- addr_modeP->scaled_reg=0; /* if 0, not scaled index */
- addr_modeP->float_flag=0;
- addr_modeP->am_size=0;
- addr_modeP->im_disp=0;
- addr_modeP->pcrel=0; /* not set in this function */
- addr_modeP->disp_suffix[0]=0;
- addr_modeP->disp_suffix[1]=0;
- addr_modeP->disp[0]=NULL;
- addr_modeP->disp[1]=NULL;
- str=operand;
- if (str[0] == 0) {return (0);} /* we don't want this */
- strl=strlen(str);
- switch (str[0]) {
- /* the following three case statements controls the mode-chars
- this is the place to ed if you want to change them */
-#ifdef ABSOLUTE_PREFIX
- case ABSOLUTE_PREFIX:
- if (str[strl-1] == ']') break;
- addr_modeP->mode=21; /* absolute */
- addr_modeP->disp[0]=str+1;
- return (-1);
-#endif
-#ifdef IMMEDIATE_PREFIX
- case IMMEDIATE_PREFIX:
- if (str[strl-1] == ']') break;
- addr_modeP->mode=20; /* immediate */
- addr_modeP->disp[0]=str+1;
- return (-1);
-#endif
- case '.':
- if (str[strl-1] != ']') {
- switch (str[1]) {
- case'-':case'+':
- if (str[2] != '\000') {
- addr_modeP->mode=27; /* pc-relativ */
- addr_modeP->disp[0]=str+2;
- return (-1);
- }
- default:
- as_warn("Invalid syntax in PC-relative addressing mode");
- return(0);
- }
- }
- break;
- case'e':
- if (str[strl-1] != ']') {
- if ((!strncmp(str,"ext(",4)) && strl>7) { /* external */
- addr_modeP->disp[0]=str+4;
- i=0;
- j=2;
- do { /* disp[0]'s termination point */
- j+=1;
- if (str[j] == '(') i++;
- if (str[j] == ')') i--;
- } while (j < strl && i != 0);
- if (i != 0 || !(str[j+1] == '-' || str[j+1] == '+') ) {
- as_warn("Invalid syntax in External addressing mode");
- return(0);
- }
- str[j]='\000'; /* null terminate disp[0] */
- addr_modeP->disp[1]=str+j+2;
- addr_modeP->mode=22;
- return (-1);
- }
- }
- break;
- default:;
- }
- strl=strlen(str);
- switch (strl) {
- case 2:
- switch (str[0]) {
- case'f':addr_modeP->float_flag=1;
- case'r':
- if (str[1] >= '0' && str[1] < '8') {
- addr_modeP->mode=str[1]-'0';
- return (-1);
- }
- }
- case 3:
- if (!strncmp(str,"tos",3)) {
- addr_modeP->mode=23; /* TopOfStack */
- return (-1);
- }
- default:;
- }
- if (strl>4) {
- if (str[strl - 1] == ')') {
- if (str[strl - 2] == ')') {
- if (!strncmp(&str[strl-5],"(fp",3)) {
- mode=16; /* Memory Relative */
- }
- if (!strncmp(&str[strl-5],"(sp",3)) {
- mode=17;
- }
- if (!strncmp(&str[strl-5],"(sb",3)) {
- mode=18;
- }
- if (mode != DEFAULT) { /* memory relative */
- addr_modeP->mode=mode;
- j=strl-5; /* temp for end of disp[0] */
- i=0;
- do {
- strl-=1;
- if (str[strl] == ')') i++;
- if (str[strl] == '(') i--;
- } while (strl>-1 && i != 0);
- if (i != 0) {
- as_warn("Invalid syntax in Memory Relative addressing mode");
- return(0);
- }
- addr_modeP->disp[1]=str;
- addr_modeP->disp[0]=str+strl+1;
- str[j]='\000'; /* null terminate disp[0] */
- str[strl]='\000'; /* null terminate disp[1] */
- return (-1);
- }
- }
- switch (str[strl-3]) {
- case'r':case'R':
- if (str[strl - 2] >= '0' && str[strl - 2] < '8' && str[strl - 4] == '(') {
- addr_modeP->mode=str[strl-2]-'0'+8;
- addr_modeP->disp[0]=str;
- str[strl-4]=0;
- return (-1); /* reg rel */
- }
- default:
- if (!strncmp(&str[strl-4],"(fp",3)) {
- mode=24;
- }
- if (!strncmp(&str[strl-4],"(sp",3)) {
- mode=25;
- }
- if (!strncmp(&str[strl-4],"(sb",3)) {
- mode=26;
- }
- if (!strncmp(&str[strl-4],"(pc",3)) {
- mode=27;
- }
- if (mode != DEFAULT) {
- addr_modeP->mode=mode;
- addr_modeP->disp[0]=str;
- str[strl-4]='\0';
- return (-1); /* memory space */
- }
- }
- }
- /* no trailing ')' do we have a ']' ? */
- if (str[strl - 1] == ']') {
- switch (str[strl-2]) {
- case'b':mode=28;break;
- case'w':mode=29;break;
- case'd':mode=30;break;
- case'q':mode=31;break;
- default:;
- as_warn("Invalid scaled-indexed mode, use (b,w,d,q)");
- if (str[strl - 3] != ':' || str[strl - 6] != '[' ||
- str[strl - 5] == 'r' || str[strl - 4] < '0' || str[strl - 4] > '7') {
- as_warn("Syntax in scaled-indexed mode, use [Rn:m] where n=[0..7] m={b,w,d,q}");
- }
- } /* scaled index */
- {
- if (recursive_level>0) {
- as_warn("Scaled-indexed addressing mode combined with scaled-index");
- return(0);
- }
- addr_modeP->am_size+=1; /* scaled index byte */
- j=str[strl-4]-'0'; /* store temporary */
- str[strl-6]='\000'; /* nullterminate for recursive call */
- i=addr_mode(str,addr_modeP,1);
- if (!i || addr_modeP->mode == 20) {
- as_warn("Invalid or illegal addressing mode combined with scaled-index");
- return(0);
- }
- addr_modeP->scaled_mode=addr_modeP->mode; /* store the inferior mode */
- addr_modeP->mode=mode;
- addr_modeP->scaled_reg=j+1;
- return (-1);
- }
- }
- }
- addr_modeP->mode = DEFAULT; /* default to whatever */
- addr_modeP->disp[0]=str;
- return (-1);
-}
-
-/* ptr points at string
- addr_modeP points at struct with result
- This routine calls addr_mode to determine the general addr.mode of
- the operand. When this is ready it parses the displacements for size
- specifying suffixes and determines size of immediate mode via ns32k-opcode.
- Also builds index bytes if needed.
- */
-int get_addr_mode(ptr,addr_modeP)
-char *ptr;
-addr_modeS *addr_modeP;
-{
- int tmp;
- addr_mode(ptr,addr_modeP,0);
- if (addr_modeP->mode == DEFAULT || addr_modeP->scaled_mode == -1) {
- /* resolve ambigious operands, this shouldn't
- be necessary if one uses standard NSC operand
- syntax. But the sequent compiler doesn't!!!
- This finds a proper addressinging mode if it
- is implicitly stated. See ns32k-opcode.h */
- (void)evaluate_expr(&exprP,ptr); /* this call takes time Sigh! */
- if (addr_modeP->mode == DEFAULT) {
- if (exprP.X_add_symbol || exprP.X_subtract_symbol) {
- addr_modeP->mode=desc->default_model; /* we have a label */
- } else {
- addr_modeP->mode=desc->default_modec; /* we have a constant */
- }
- } else {
- if (exprP.X_add_symbol || exprP.X_subtract_symbol) {
- addr_modeP->scaled_mode=desc->default_model;
- } else {
- addr_modeP->scaled_mode=desc->default_modec;
- }
- }
- /* must put this mess down in addr_mode to handle the scaled case better */
- }
- /* It appears as the sequent compiler wants an absolute when we have a
- label without @. Constants becomes immediates besides the addr case.
- Think it does so with local labels too, not optimum, pcrel is better.
- When I have time I will make gas check this and select pcrel when possible
- Actually that is trivial.
- */
- if (tmp=addr_modeP->scaled_reg) { /* build indexbyte */
- tmp--; /* remember regnumber comes incremented for flagpurpose */
- tmp|=addr_modeP->scaled_mode<<3;
- addr_modeP->index_byte=(char)tmp;
- addr_modeP->am_size+=1;
- }
- if (disp_test[addr_modeP->mode]) { /* there was a displacement, probe for length specifying suffix*/
- {
- register char c;
- register char suffix;
- register char suffix_sub;
- register int i;
- register char *toP;
- register char *fromP;
-
- addr_modeP->pcrel=0;
- if (disp_test[addr_modeP->mode]) { /* there is a displacement */
- if (addr_modeP->mode == 27 || addr_modeP->scaled_mode == 27) { /* do we have pcrel. mode */
- addr_modeP->pcrel=1;
- }
- addr_modeP->im_disp=1;
- for (i=0;i<2;i++) {
- suffix_sub=suffix=0;
- if (toP=addr_modeP->disp[i]) { /* suffix of expression, the largest size rules */
- fromP=toP;
- while (c = *fromP++) {
- *toP++=c;
- if (c == ':') {
- switch (*fromP) {
- case '\0':
- as_warn("Premature end of suffix--Defaulting to d");
- suffix=4;
- continue;
- case 'b':suffix_sub=1;break;
- case 'w':suffix_sub=2;break;
- case 'd':suffix_sub=4;break;
- default:
- as_warn("Bad suffix after ':' use {b|w|d} Defaulting to d");
- suffix=4;
- }
- fromP++;
- toP--; /* So we write over the ':' */
- if (suffix<suffix_sub) suffix=suffix_sub;
- }
- }
- *toP='\0'; /* terminate properly */
- addr_modeP->disp_suffix[i]=suffix;
- addr_modeP->am_size+=suffix ? suffix : 4;
- }
- }
- }
- }
- } else {
- if (addr_modeP->mode == 20) { /* look in ns32k_opcode for size */
- addr_modeP->disp_suffix[0]=addr_modeP->am_size=desc->im_size;
- addr_modeP->im_disp=0;
- }
- }
- return addr_modeP->mode;
-}
-
-
-/* read an optionlist */
-void optlist(str,optionP,default_map)
-char *str; /* the string to extract options from */
-struct option *optionP; /* how to search the string */
-unsigned long *default_map; /* default pattern and output */
-{
- register int i,j,k,strlen1,strlen2;
- register char *patternP,*strP;
- strlen1=strlen(str);
- if (strlen1<1) {
- as_fatal("Very short instr to option, ie you can't do it on a NULLstr");
- }
- for (i = 0; optionP[i].pattern != 0; i++) {
- strlen2=strlen(optionP[i].pattern);
- for (j=0;j<strlen1;j++) {
- patternP=optionP[i].pattern;
- strP = &str[j];
- for (k=0;k<strlen2;k++) {
- if (*(strP++) != *(patternP++)) break;
- }
- if (k == strlen2) { /* match */
- *default_map|=optionP[i].or;
- *default_map&=optionP[i].and;
- }
- }
- }
-}
-/* search struct for symbols
- This function is used to get the short integer form of reg names
- in the instructions lmr, smr, lpr, spr
- return true if str is found in list */
-
-int list_search(str,optionP,default_map)
-char *str; /* the string to match */
-struct option *optionP; /* list to search */
-unsigned long *default_map; /* default pattern and output */
-{
- register int i;
- for (i = 0; optionP[i].pattern != 0; i++) {
- if (!strncmp(optionP[i].pattern,str,20)) { /* use strncmp to be safe */
- *default_map|=optionP[i].or;
- *default_map&=optionP[i].and;
- return -1;
- }
- }
- as_warn("No such entry in list. (cpu/mmu register)");
- return 0;
-}
-static segT evaluate_expr(resultP,ptr)
-expressionS *resultP;
-char *ptr;
-{
- register char *tmp_line;
- register segT segment;
- tmp_line = input_line_pointer;
- input_line_pointer = ptr;
- segment = expression(&exprP);
- input_line_pointer = tmp_line;
- return(segment);
-}
-
-/* Convert operands to iif-format and adds bitfields to the opcode.
- Operands are parsed in such an order that the opcode is updated from
- its most significant bit, that is when the operand need to alter the
- opcode.
- Be carefull not to put to objects in the same iif-slot.
- */
-
-void encode_operand(argc,argv,operandsP,suffixP,im_size,opcode_bit_ptr)
-int argc;
-char **argv;
-char *operandsP;
-char *suffixP;
-char im_size;
-char opcode_bit_ptr;
-{
- register int i,j;
- int pcrel,tmp,b,loop,pcrel_adjust;
- for (loop=0;loop<argc;loop++) {
- i=operandsP[loop<<1]-'1'; /* what operand are we supposed to work on */
- if (i>3) as_fatal("Internal consistency error. check ns32k-opcode.h");
- pcrel=0;
- pcrel_adjust=0;
- tmp=0;
- switch (operandsP[(loop<<1)+1]) {
- case 'f': /* operand of sfsr turns out to be a nasty specialcase */
- opcode_bit_ptr-=5;
- case 'F': /* 32 bit float general form */
- case 'L': /* 64 bit float */
- case 'Q': /* quad-word */
- case 'B': /* byte */
- case 'W': /* word */
- case 'D': /* double-word */
- case 'A': /* double-word gen-address-form ie no regs allowed */
- get_addr_mode(argv[i],&addr_modeP);
- iif.instr_size+=addr_modeP.am_size;
- if (opcode_bit_ptr == desc->opcode_size) b = 4; else b = 6;
- for (j=b;j<(b+2);j++) {
- if (addr_modeP.disp[j-b]) {
- IIF(j,
- 2,
- addr_modeP.disp_suffix[j-b],
- (unsigned long)addr_modeP.disp[j-b],
- 0,
- addr_modeP.pcrel,
- iif.instr_size-addr_modeP.am_size, /* this aint used (now) */
- addr_modeP.im_disp,
- IND(BRANCH,BYTE),
- NULL,
- addr_modeP.scaled_reg ? addr_modeP.scaled_mode:addr_modeP.mode,
- 0);
- }
- }
- opcode_bit_ptr-=5;
- iif.iifP[1].object|=((long)addr_modeP.mode)<<opcode_bit_ptr;
- if (addr_modeP.scaled_reg) {
- j=b/2;
- IIF(j,1,1, (unsigned long)addr_modeP.index_byte,0,0,0,0,0, NULL,-1,0);
- }
- break;
- case 'b': /* multiple instruction disp */
- freeptr++; /* OVE:this is an useful hack */
- tmp = (int) sprintf(freeptr,
- "((%s-1)*%d)\000",
- argv[i], desc->im_size);
- argv[i]=freeptr;
- freeptr=(char*)tmp;
- pcrel-=1; /* make pcrel 0 inspite of what case 'p': wants */
- /* fall thru */
- case 'p': /* displacement - pc relative addressing */
- pcrel+=1;
- /* fall thru */
- case 'd': /* displacement */
- iif.instr_size+=suffixP[i] ? suffixP[i] : 4;
- IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0,
- pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,0);
- break;
- case 'H': /* sequent-hack: the linker wants a bit set when bsr */
- pcrel=1;
- iif.instr_size+=suffixP[i] ? suffixP[i] : 4;
- IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0,
- pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1, 1);
- break;
- case 'q': /* quick */
- opcode_bit_ptr-=4;
- IIF(11,2,42,(unsigned long)argv[i],0,0,0,0,0,
- bit_fix_new(4,opcode_bit_ptr,-8,7,0,1,0),-1,0);
- break;
- case 'r': /* register number (3 bits) */
- list_search(argv[i],opt6,&tmp);
- opcode_bit_ptr-=3;
- iif.iifP[1].object|=tmp<<opcode_bit_ptr;
- break;
- case 'O': /* setcfg instruction optionslist */
- optlist(argv[i],opt3,&tmp);
- opcode_bit_ptr-=4;
- iif.iifP[1].object|=tmp<<15;
- break;
- case 'C': /* cinv instruction optionslist */
- optlist(argv[i],opt4,&tmp);
- opcode_bit_ptr-=4;
- iif.iifP[1].object|=tmp<<15;/*insert the regtype in opcode */
- break;
- case 'S': /* stringinstruction optionslist */
- optlist(argv[i],opt5,&tmp);
- opcode_bit_ptr-=4;
- iif.iifP[1].object|=tmp<<15;
- break;
- case 'u':case 'U': /* registerlist */
- IIF(10,1,1,0,0,0,0,0,0,NULL,-1,0);
- switch (operandsP[(i<<1)+1]) {
- case 'u': /* restore, exit */
- optlist(argv[i],opt1,&iif.iifP[10].object);
- break;
- case 'U': /* save,enter */
- optlist(argv[i],opt2,&iif.iifP[10].object);
- break;
- }
- iif.instr_size+=1;
- break;
- case 'M': /* mmu register */
- list_search(argv[i],mmureg,&tmp);
- opcode_bit_ptr-=4;
- iif.iifP[1].object|=tmp<<opcode_bit_ptr;
- break;
- case 'P': /* cpu register */
- list_search(argv[i],cpureg,&tmp);
- opcode_bit_ptr-=4;
- iif.iifP[1].object|=tmp<<opcode_bit_ptr;
- break;
- case 'g': /* inss exts */
- iif.instr_size+=1; /* 1 byte is allocated after the opcode */
- IIF(10,2,1,
- (unsigned long)argv[i], /* i always 2 here */
- 0,0,0,0,0,
- bit_fix_new(3,5,0,7,0,0,0), /* a bit_fix is targeted to the byte */
- -1,0);
- case 'G':
- IIF(11,2,42,
- (unsigned long)argv[i], /* i always 3 here */
- 0,0,0,0,0,
- bit_fix_new(5,0,1,32,-1,0,-1),-1,0);
- break;
- case 'i':
- iif.instr_size+=1;
- b=2+i; /* put the extension byte after opcode */
- IIF(b,2,1,0,0,0,0,0,0,0,-1,0);
- default:
- as_fatal("Bad opcode-table-option, check in file ns32k-opcode.h");
- }
- }
-}
-
-/* in: instruction line
- out: internal structure of instruction
- that has been prepared for direct conversion to fragment(s) and
- fixes in a systematical fashion
- Return-value = recursive_level
- */
-/* build iif of one assembly text line */
-int parse(line,recursive_level)
-char *line;
-int recursive_level;
-{
- register char *lineptr,c,suffix_separator;
- register int i;
- int argc,arg_type;
- char sqr,sep;
- char suffix[MAX_ARGS],*argv[MAX_ARGS];/* no more than 4 operands */
- if (recursive_level <= 0) { /* called from md_assemble */
- for (lineptr=line; (*lineptr) != '\0' && (*lineptr) != ' '; lineptr++);
- c = *lineptr;
- *lineptr = '\0';
- desc = (struct ns32k_opcode*) hash_find(inst_hash_handle,line);
- if (!desc) {
- as_fatal("No such opcode");
- }
- *lineptr = c;
- } else {
- lineptr = line;
- }
- argc = 0;
- if (*desc->operands != NULL) {
- if (*lineptr++ != '\0') {
- sqr='[';
- sep=',';
- while (*lineptr != '\0') {
- if (desc->operands[argc << 1]) {
- suffix[argc] = 0;
- arg_type =
- desc->operands[(argc << 1) + 1];
- switch (arg_type) {
- case 'd':
- case 'b':
- case 'p':
- case 'H': /* the operand is supposed to be a displacement */
- /* Hackwarning: do not forget to update the 4 cases above when editing ns32k-opcode.h */
- suffix_separator = ':';
- break;
- default:
- suffix_separator = '\255'; /* if this char occurs we loose */
- }
- suffix[argc] = 0; /* 0 when no ':' is encountered */
- argv[argc] = freeptr;
- *freeptr = '\0';
- while ((c = *lineptr) != '\0' && c != sep) {
- if (c == sqr) {
- if (sqr == '[') {
- sqr = ']';
- sep = '\0';
- } else {
- sqr = '[';
- sep = ',';
- }
- }
- if (c == suffix_separator) { /* ':' - label/suffix separator */
- switch (lineptr[1]) {
- case 'b': suffix[argc] = 1; break;
- case 'w': suffix[argc] = 2; break;
- case 'd': suffix[argc] = 4; break;
- default: as_warn("Bad suffix, defaulting to d");
- suffix[argc] = 4;
- if (lineptr[1] == '\0' || lineptr[1] == sep) {
- lineptr += 1;
- continue;
- }
- }
- lineptr += 2;
- continue;
- }
- *freeptr++ = c;
- lineptr++;
- }
- *freeptr++ = '\0';
- argc += 1;
- if (*lineptr == '\0') continue;
- lineptr += 1;
- } else {
- as_fatal("Too many operands passed to instruction");
- }
- }
- }
- }
- if (argc != strlen(desc->operands) / 2) {
- if (strlen(desc->default_args) != 0) { /* we can apply default, dont goof */
- if (parse(desc->default_args,1) != 1) { /* check error in default */
- as_fatal("Wrong numbers of operands in default, check ns32k-opcodes.h");
- }
- } else {
- as_fatal("Wrong number of operands");
- }
-
- }
- for (i = 0; i < IIF_ENTRIES; i++) {
- iif.iifP[i].type = 0; /* mark all entries as void*/
- }
-
- /* build opcode iif-entry */
- iif.instr_size = desc->opcode_size / 8;
- IIF(1,1,iif.instr_size,desc->opcode_seed,0,0,0,0,0,0,-1,0);
-
- /* this call encodes operands to iif format */
- if (argc) {
- encode_operand(argc,
- argv,
- &desc->operands[0],
- &suffix[0],
- desc->im_size,
- desc->opcode_size);
- }
- return(recursive_level);
-}
-
-
-/* Convert iif to fragments.
- From this point we start to dribble with functions in other files than
- this one.(Except hash.c) So, if it's possible to make an iif for an other
- CPU, you don't need to know what frags, relax, obstacks, etc is in order
- to port this assembler. You only need to know if it's possible to reduce
- your cpu-instruction to iif-format (takes some work) and adopt the other
- md_? parts according to given instructions
- Note that iif was invented for the clean ns32k`s architecure.
- */
-void convert_iif() {
- int i;
- bit_fixS *bit_fixP;
- fragS *inst_frag;
- char *inst_offset;
- char *inst_opcode;
- char *memP;
- segT segment;
- int l;
- int k;
- int rem_size; /* count the remaining bytes of instruction */
- char type;
- char size = 0;
- int size_so_far = 0; /* used to calculate pcrel_adjust */
- int pcrel_symbols = 0;/* kludge by jkp@hut.fi to make
- movd _foo(pc),_bar(pc) work.
- It should be done with two frags
- for one insn, but I don't understand
- enough to make it work */
-
- rem_size = iif.instr_size;
- memP = frag_more(iif.instr_size); /* make sure we have enough bytes for instruction */
- inst_opcode = memP;
- inst_offset = (char *)(memP-frag_now->fr_literal);
- inst_frag = frag_now;
- for (i=0; i < IIF_ENTRIES; i++) { /* jkp kludge alert */
- if (iif.iifP[i].type && iif.iifP[i].size == 0 &&
- iif.iifP[i].pcrel) {
- evaluate_expr(&exprP, (char *)iif.iifP[i].object);
- if (exprP.X_add_symbol || exprP.X_subtract_symbol)
- pcrel_symbols++;
- }
- }
- for (i=0;i<IIF_ENTRIES;i++) {
- if (type=iif.iifP[i].type) { /* the object exist, so handle it */
-#ifdef PIC
- int reloc_mode;
- if ((i == 4 || i == 6)
- && picmode
- && (iif.iifP[i].addr_mode == 18 || iif.iifP[i].addr_mode == 26))
- reloc_mode = RELOC_GLOB_DAT;
- else
- reloc_mode = NO_RELOC;
-#else
- int reloc_mode = NO_RELOC;
-#endif
- switch (size=iif.iifP[i].size) {
- case 42: size=0; /* it's a bitfix that operates on an existing object*/
- if (iif.iifP[i].bit_fixP->fx_bit_base) { /* expand fx_bit_base to point at opcode */
- iif.iifP[i].bit_fixP->fx_bit_base = (long) inst_opcode;
- }
- case 8: /* bignum or doublefloat */
- memset(memP, '\0', 8);
- case 1:case 2:case 3:case 4:/* the final size in objectmemory is known */
- bit_fixP = iif.iifP[i].bit_fixP;
- switch (type) {
- case 1: /* the object is pure binary */
- if (bit_fixP || iif.iifP[i].pcrel) {
- fix_new_ns32k(frag_now,
- (long)(memP-frag_now->fr_literal),
- size,
- 0,
- 0,
- iif.iifP[i].object,
- iif.iifP[i].pcrel,
- (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/
- iif.iifP[i].im_disp,
- bit_fixP,
- iif.iifP[i].bsr, /* sequent hack */
- reloc_mode);
- } else { /* good, just put them bytes out */
- switch (iif.iifP[i].im_disp) {
- case 0:
- md_number_to_chars(memP,iif.iifP[i].object,size);break;
- case 1:
- md_number_to_disp(memP,iif.iifP[i].object,size);break;
- default: as_fatal("iif convert internal pcrel/binary");
- }
- }
- memP+=size;
- rem_size-=size;
- break;
- case 2: /* the object is a pointer at an expression, so unpack
- it, note that bignums may result from the expression
- */
- if ((segment = evaluate_expr(&exprP, (char*)iif.iifP[i].object)) == SEG_BIG || size == 8) {
- if ((k=exprP.X_add_number)>0) { /* we have a bignum ie a quad */
- /* this can only happens in a long suffixed instruction */
- memset(memP, '\0', size); /* size normally is 8 */
- if (k*2>size) as_warn("Bignum too big for long");
- if (k == 3) memP += 2;
- for (l=0;k>0;k--,l+=2) {
- md_number_to_chars(memP+l,generic_bignum[l>>1],sizeof(LITTLENUM_TYPE));
- }
- } else { /* flonum */
- LITTLENUM_TYPE words[4];
-
- switch (size) {
- case 4:
- gen_to_words(words,2,8);
- md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE));
- md_number_to_imm(memP+sizeof(LITTLENUM_TYPE),(long)words[1],sizeof(LITTLENUM_TYPE));
- break;
- case 8:
- gen_to_words(words,4,11);
- md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE));
- md_number_to_imm(memP+sizeof(LITTLENUM_TYPE) ,(long)words[1],sizeof(LITTLENUM_TYPE));
- md_number_to_imm(memP+2*sizeof(LITTLENUM_TYPE),(long)words[2],sizeof(LITTLENUM_TYPE));
- md_number_to_imm(memP+3*sizeof(LITTLENUM_TYPE),(long)words[3],sizeof(LITTLENUM_TYPE));
- break;
- }
- }
- memP+=size;
- rem_size-=size;
- break;
- }
- if (bit_fixP ||
- exprP.X_add_symbol ||
- exprP.X_subtract_symbol ||
- iif.iifP[i].pcrel) { /* fixit */
- /* the expression was undefined due to an undefined label */
- /* create a fix so we can fix the object later */
- exprP.X_add_number+=iif.iifP[i].object_adjust;
- fix_new_ns32k(frag_now,
- (long)(memP-frag_now->fr_literal),
- size,
- exprP.X_add_symbol,
- exprP.X_subtract_symbol,
- exprP.X_add_number,
- iif.iifP[i].pcrel,
- (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/
- iif.iifP[i].im_disp,
- bit_fixP,
- iif.iifP[i].bsr, /* sequent hack */
- reloc_mode);
-
- } else { /* good, just put them bytes out */
- switch (iif.iifP[i].im_disp) {
- case 0:
- md_number_to_imm(memP,exprP.X_add_number,size);break;
- case 1:
- md_number_to_disp(memP,exprP.X_add_number,size);break;
- default: as_fatal("iif convert internal pcrel/pointer");
- }
- }
- memP+=size;
- rem_size-=size;
- break;
- default: as_fatal("Internal logic error in iif.iifP[n].type");
- }
- break;
- case 0: /* To bad, the object may be undefined as far as its final
- nsize in object memory is concerned. The size of the object
- in objectmemory is not explicitly given.
- If the object is defined its length can be determined and
- a fix can replace the frag.
- */
- {
- int temp;
- segment = evaluate_expr(&exprP, (char*)iif.iifP[i].object);
- if (((exprP.X_add_symbol || exprP.X_subtract_symbol) &&
- !iif.iifP[i].pcrel) || pcrel_symbols >= 2 /*jkp*/) { /* OVE: hack, clamp to 4 bytes */
-#ifdef PIC
- if (reloc_mode == RELOC_GLOB_DAT && got_offset_size == 2) {
- size = 2;
- /* rewind the bytes not used */
- obstack_blank_fast(&frags, -2);
- } else
-#endif
- size=4; /* we dont wan't to frag this, use 4 so it reaches */
- fix_new_ns32k(frag_now,
- (long)(memP-frag_now->fr_literal),
- size,
- exprP.X_add_symbol,
- exprP.X_subtract_symbol,
- exprP.X_add_number,
- pcrel_symbols >= 2 ? iif.iifP[i].pcrel : 0, /*jkp*//* never iif.iifP[i].pcrel, */
- (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/
- 1, /* always iif.iifP[i].im_disp, */
- 0,0,
- reloc_mode);
- memP+=size;
- rem_size-=4;
- break; /* exit this absolute hack */
- }
-
- if (exprP.X_add_symbol || exprP.X_subtract_symbol) { /* frag it */
- if (exprP.X_subtract_symbol) { /* We cant relax this case */
- as_fatal("Can't relax difference");
- } else {
- /* at this stage we must undo some of the effect caused
- by frag_more, ie we must make sure that frag_var causes
- frag_new to creat a valid fix-size in the frag it`s closing
- */
- temp = -(rem_size-4);
- obstack_blank_fast(&frags,temp);
- /* we rewind none, some or all of the requested size we
- requested by the first frag_more for this iif chunk.
- Note: that we allocate 4 bytes to an object we NOT YET
- know the size of, thus rem_size-4.
- */
- (void) frag_variant(rs_machine_dependent,
- 4,
- 0,
- IND(BRANCH,UNDEF), /* expecting the worst */
- exprP.X_add_symbol,
- exprP.X_add_number,
- inst_opcode,
- (char)size_so_far, /*iif.iifP[i].pcrel_adjust);*/
- iif.iifP[i].bsr); /* sequent linker hack */
- rem_size -= 4;
- if (rem_size > 0) {
- memP = frag_more(rem_size);
- }
- }
- } else {/* Double work, this is done in md_number_to_disp */
- /* exprP.X_add_number; fixme-soon what was this supposed to be? xoxorich. */
- if (-64 <= exprP.X_add_number && exprP.X_add_number <= 63) {
- size = 1;
- } else {
- if (-8192 <= exprP.X_add_number && exprP.X_add_number <= 8191) {
- size = 2;
-
- /* Dave Taylor <taylor@think.com> says: Note: The reason the lower
- limit is -0x1f000000 and not -0x20000000 is that, according to
- Nat'l Semi's data sheet on the ns32532, ``the pattern 11100000
- for the most significant byte of the displacement is reserved by
- National for future enhancements''. */
- } else if (/* -0x40000000 <= exprP.X_add_number &&
- exprP.X_add_number <= 0x3fffffff */
- -0x1f000000 <= exprP.X_add_number &&
- exprP.X_add_number <= 0x1fffffff) {
- size = 4;
- } else {
- as_warn("Displacement too large for :d");
- size = 4;
- }
- }
- /* rewind the bytes not used */
- temp = -(4-size);
- md_number_to_disp(memP,exprP.X_add_number,size);
- obstack_blank_fast(&frags,temp);
- memP += size;
- rem_size -= 4; /* we allocated this amount */
- }
- }
- break;
- default:
- as_fatal("Internal logic error in iif.iifP[].type");
- }
- size_so_far += size;
- size = 0;
- }
- }
-}
-
-void md_assemble(line)
-char *line;
-{
- freeptr=freeptr_static;
- parse(line,0); /* explode line to more fix form in iif */
- convert_iif(); /* convert iif to frags, fix's etc */
-#ifdef SHOW_NUM
- printf(" \t\t\t%s\n",line);
-#endif
-}
-
-
-void md_begin() {
- /* build a hashtable of the instructions */
- register const struct ns32k_opcode *ptr;
- register char *stat;
- inst_hash_handle=hash_new();
- for (ptr=ns32k_opcodes;ptr<endop;ptr++) {
- if (*(stat=hash_insert(inst_hash_handle,ptr->name,(char*)ptr))) {
- as_fatal("Can't hash %s: %s", ptr->name,stat); /*fatal*/
- exit(0);
- }
- }
- freeptr_static=(char*)malloc(PRIVATE_SIZE); /* some private space please! */
-}
-
-
-void
- md_end() {
- free(freeptr_static);
- }
-
-/* Must be equal to MAX_PRECISON in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
-/* Turn the string pointed to by litP into a floating point constant of type
- type, and emit the appropriate bytes. The number of LITTLENUMS emitted
- is stored in *sizeP. An error message is returned, or NULL on OK.
- */
-char *
- md_atof(type,litP,sizeP)
-char type;
-char *litP;
-int *sizeP;
-{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- extern char *atof_ieee();
- char *t;
-
- switch (type) {
- case 'f':
- prec = 2;
- break;
-
- case 'd':
- prec = 4;
- break;
- default:
- *sizeP = 0;
- return "Bad call to MD_ATOF()";
- }
- t = atof_ieee(input_line_pointer, type, words);
- if (t)
- input_line_pointer=t;
-
- *sizeP = prec * sizeof(LITTLENUM_TYPE);
- for (wordP = words +prec; prec--;) {
- md_number_to_chars(litP, (long)(*--wordP), sizeof(LITTLENUM_TYPE));
- litP+=sizeof(LITTLENUM_TYPE);
- }
- return ""; /* Someone should teach Dean about null pointers */
-}
-
-/* Convert number to chars in correct order */
-
-void
- md_number_to_chars(buf, value, nbytes)
-char *buf;
-long value;
-int nbytes;
-{
- while (nbytes--) {
-#ifdef SHOW_NUM
- printf("%x ",value & 0xff);
-#endif
- *buf++ = value; /* Lint wants & MASK_CHAR. */
- value >>= BITS_PER_CHAR;
- }
-} /* md_number_to_chars() */
-
-
-/* This is a variant of md_numbers_to_chars. The reason for its' existence
- is the fact that ns32k uses Huffman coded displacements. This implies
- that the bit order is reversed in displacements and that they are prefixed
- with a size-tag.
-
- binary: msb->lsb
- 0xxxxxxx byte
- 10xxxxxx xxxxxxxx word
- 11xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx double word
-
- This must be taken care of and we do it here!
- */
-static void md_number_to_disp(buf, val, n)
-char *buf;
-long val;
-char n;
-{
- switch (n) {
- case 1:
- if (val < -64 || val > 63)
-{
-fprintf(stderr, "val = %d\n", val);
- as_warn("Byte displacement out of range. line number not valid");
-}
- val &= 0x7f;
-#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
-#endif
- *buf++ = val;
- break;
- case 2:
- if (val < -8192 || val > 8191)
- as_warn("Word displacement out of range. line number not valid");
- val&=0x3fff;
- val|=0x8000;
-#ifdef SHOW_NUM
- printf("%x ",val>>8 & 0xff);
-#endif
- *buf++=(val>>8);
-#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
-#endif
- *buf++=val;
- break;
- case 4:
-
- /* Dave Taylor <taylor@think.com> says: Note: The reason the
- lower limit is -0x1f000000 and not -0x20000000 is that,
- according to Nat'l Semi's data sheet on the ns32532, ``the
- pattern 11100000 for the most significant byte of the
- displacement is reserved by National for future
- enhancements''. */
-
- if (val < -0x1f000000 || val >= 0x20000000)
- as_warn("Double word displacement out of range");
- val|=0xc0000000;
-#ifdef SHOW_NUM
- printf("%x ",val>>24 & 0xff);
-#endif
- *buf++=(val>>24);
-#ifdef SHOW_NUM
- printf("%x ",val>>16 & 0xff);
-#endif
- *buf++=(val>>16);
-#ifdef SHOW_NUM
- printf("%x ",val>>8 & 0xff);
-#endif
- *buf++=(val>>8);
-#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
-#endif
- *buf++=val;
- break;
- default:
- as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__);
- }
-}
-
-static void md_number_to_imm(buf,val,n)
-char *buf;
-long val;
-char n;
-{
- switch (n) {
- case 1:
-#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
-#endif
- *buf++=val;
- break;
- case 2:
-#ifdef SHOW_NUM
- printf("%x ",val>>8 & 0xff);
-#endif
- *buf++=(val>>8);
-#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
-#endif
- *buf++=val;
- break;
- case 4:
-#ifdef SHOW_NUM
- printf("%x ",val>>24 & 0xff);
-#endif
- *buf++=(val>>24);
-#ifdef SHOW_NUM
- printf("%x ",val>>16 & 0xff);
-#endif
- *buf++=(val>>16);
-#ifdef SHOW_NUM
- printf("%x ",val>>8 & 0xff);
-#endif
- *buf++=(val>>8);
-#ifdef SHOW_NUM
- printf("%x ",val & 0xff);
-#endif
- *buf++=val;
- break;
- default:
- as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__);
- }
-}
-
-/* Translate internal representation of relocation info into target format.
-
- OVE: on a ns32k the twiddling continues at an even deeper level
- here we have to distinguish between displacements and immediates.
-
- The sequent has a bit for this. It also has a bit for relocobjects that
- points at the target for a bsr (BranchSubRoutine) !?!?!?!
-
- This md_ri.... is tailored for sequent.
- */
-
-#ifdef comment
-void
- md_ri_to_chars(the_bytes, ri)
-char *the_bytes;
-struct reloc_info_generic *ri;
-{
- if (ri->r_bsr) { ri->r_pcrel = 0; } /* sequent seems to want this */
- md_number_to_chars(the_bytes, ri->r_address, sizeof(ri->r_address));
- md_number_to_chars(the_bytes+4, ((long)(ri->r_symbolnum )
- | (long)(ri->r_pcrel << 24 )
- | (long)(ri->r_length << 25 )
- | (long)(ri->r_extern << 27 )
- | (long)(ri->r_bsr << 28 )
- | (long)(ri->r_disp << 29 )),
- 4);
- /* the first and second md_number_to_chars never overlaps (32bit cpu case) */
-}
-#endif /* comment */
-
-#ifdef OBJ_AOUT
-void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
-char *where;
-fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- /*
- * In: length of relocation (or of address) in chars: 1, 2 or 4.
- * Out: GNU LD relocation length code: 0, 1, or 2.
- */
-
- static unsigned char nbytes_r_length[] = { 42, 0, 1, 42, 2 };
- long r_symbolnum;
- int r_flags;
-
- know(fixP->fx_addsy != NULL);
-
- md_number_to_chars(where,
- fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
- 4);
-
- r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
- ? S_GET_TYPE(fixP->fx_addsy)
- : fixP->fx_addsy->sy_number);
- r_flags = (fixP->fx_pcrel ? 1 : 0)
- | ((nbytes_r_length[fixP->fx_size] & 3) << 1)
- | (!S_IS_DEFINED(fixP->fx_addsy) ? 8 : 0)
-#if defined(TE_SEQUENT)
- | (fixP->fx_bsr ? 0x10 : 0)
-#elif defined(PIC)
- /* Undefined pc-relative relocations are of type jmpslot */
- | ((!S_IS_DEFINED(fixP->fx_addsy)
- && fixP->fx_pcrel
- && fixP->fx_addsy != got_symbol
- && picmode) ? 0x10 : 0)
-#endif
- | (fixP->fx_im_disp & 3) << 5;
-
-#ifdef PIC
- switch (fixP->fx_r_type) {
- case NO_RELOC:
- break;
- case RELOC_32:
- if (picmode && S_IS_EXTERNAL(fixP->fx_addsy)) {
- r_symbolnum = fixP->fx_addsy->sy_number;
- r_flags |= 8; /* set extern bit */
- }
- break;
- case RELOC_GLOB_DAT:
- if (!fixP->fx_pcrel) {
- r_flags |= 0x80; /* set baserel bit */
- r_symbolnum = fixP->fx_addsy->sy_number;
- if (S_IS_EXTERNAL(fixP->fx_addsy))
- r_flags |= 8;
- }
- break;
- case RELOC_RELATIVE:
- /* should never happen */
- as_fatal("relocation botch");
- break;
- }
-#endif /* PIC */
-
- where[4] = r_symbolnum & 0x0ff;
- where[5] = (r_symbolnum >> 8) & 0x0ff;
- where[6] = (r_symbolnum >> 16) & 0x0ff;
- where[7] = r_flags;
-
- return;
-} /* tc_aout_fix_to_chars() */
-
-
-#endif /* OBJ_AOUT */
-
-/* fast bitfiddling support */
-/* mask used to zero bitfield before oring in the true field */
-
-static unsigned long l_mask[] = {
- 0xffffffff, 0xfffffffe, 0xfffffffc, 0xfffffff8,
- 0xfffffff0, 0xffffffe0, 0xffffffc0, 0xffffff80,
- 0xffffff00, 0xfffffe00, 0xfffffc00, 0xfffff800,
- 0xfffff000, 0xffffe000, 0xffffc000, 0xffff8000,
- 0xffff0000, 0xfffe0000, 0xfffc0000, 0xfff80000,
- 0xfff00000, 0xffe00000, 0xffc00000, 0xff800000,
- 0xff000000, 0xfe000000, 0xfc000000, 0xf8000000,
- 0xf0000000, 0xe0000000, 0xc0000000, 0x80000000,
-};
-static unsigned long r_mask[] = {
- 0x00000000, 0x00000001, 0x00000003, 0x00000007,
- 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
- 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
- 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
- 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
- 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
- 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
- 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
-};
-#define MASK_BITS 31
-/* Insert bitfield described by field_ptr and val at buf
- This routine is written for modification of the first 4 bytes pointed
- to by buf, to yield speed.
- The ifdef stuff is for selection between a ns32k-dependent routine
- and a general version. (My advice: use the general version!)
- */
-
-static void
- md_number_to_field(buf,val,field_ptr)
-register char *buf;
-register long val;
-register bit_fixS *field_ptr;
-{
- register unsigned long object;
- register unsigned long mask;
- /* define ENDIAN on a ns32k machine */
-#ifdef ENDIAN
- register unsigned long *mem_ptr;
-#else
- register char *mem_ptr;
-#endif
- if (field_ptr->fx_bit_min <= val && val <= field_ptr->fx_bit_max) {
-#ifdef ENDIAN
- if (field_ptr->fx_bit_base) { /* override buf */
- mem_ptr=(unsigned long*)field_ptr->fx_bit_base;
- } else {
- mem_ptr=(unsigned long*)buf;
- }
-#else
- if (field_ptr->fx_bit_base) { /* override buf */
- mem_ptr=(char*)field_ptr->fx_bit_base;
- } else {
- mem_ptr=buf;
- }
-#endif
- mem_ptr+=field_ptr->fx_bit_base_adj;
-#ifdef ENDIAN /* we have a nice ns32k machine with lowbyte at low-physical mem */
- object = *mem_ptr; /* get some bytes */
-#else /* OVE Goof! the machine is a m68k or dito */
- /* That takes more byte fiddling */
- object=0;
- object|=mem_ptr[3] & 0xff;
- object<<=8;
- object|=mem_ptr[2] & 0xff;
- object<<=8;
- object|=mem_ptr[1] & 0xff;
- object<<=8;
- object|=mem_ptr[0] & 0xff;
-#endif
- mask=0;
- mask|=(r_mask[field_ptr->fx_bit_offset]);
- mask|=(l_mask[field_ptr->fx_bit_offset+field_ptr->fx_bit_size]);
- object&=mask;
- val+=field_ptr->fx_bit_add;
- object|=((val<<field_ptr->fx_bit_offset) & (mask ^ 0xffffffff));
-#ifdef ENDIAN
- *mem_ptr=object;
-#else
- mem_ptr[0]=(char)object;
- object>>=8;
- mem_ptr[1]=(char)object;
- object>>=8;
- mem_ptr[2]=(char)object;
- object>>=8;
- mem_ptr[3]=(char)object;
-#endif
- } else {
- as_warn("Bit field out of range");
- }
-}
-
-/* Apply a fixS (fixup of an instruction or data that we didn't have
- enough info to complete immediately) to the data in a frag.
-
- On the ns32k, everything is in a different format, so we have broken
- out separate functions for each kind of thing we could be fixing.
- They all get called from here. */
-
-void
- md_apply_fix(fixP, val)
-fixS *fixP;
-long val;
-{
- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- if (fixP->fx_bit_fixP) { /* Bitfields to fix, sigh */
- md_number_to_field (buf, val, fixP->fx_bit_fixP);
- } else switch (fixP->fx_im_disp) {
-
- case 0: /* Immediate field */
- md_number_to_imm (buf, val, fixP->fx_size);
- break;
-
- case 1: /* Displacement field */
- md_number_to_disp (buf,
- fixP->fx_pcrel? val + fixP->fx_pcrel_adjust: val,
- fixP->fx_size);
- break;
-
- case 2: /* Pointer in a data object */
- md_number_to_chars (buf, val, fixP->fx_size);
- break;
- }
-}
-
-/* Convert a relaxed displacement to ditto in final output */
-
-void
- md_convert_frag(headers, fragP)
-object_headers *headers;
-register fragS *fragP;
-{
- long disp;
- long ext = 0;
-
- /* Address in gas core of the place to store the displacement. */
- register char *buffer_address = fragP->fr_fix + fragP->fr_literal;
- /* Address in object code of the displacement. */
- register int object_address = fragP->fr_fix + fragP->fr_address;
-
- know(fragP->fr_symbol);
-
- /* The displacement of the address, from current location. */
- disp = (S_GET_VALUE(fragP->fr_symbol) + fragP->fr_offset) - object_address;
- disp += fragP->fr_pcrel_adjust;
-
- switch (fragP->fr_subtype) {
- case IND(BRANCH,BYTE):
- ext = 1;
- break;
- case IND(BRANCH,WORD):
- ext = 2;
- break;
- case IND(BRANCH,DOUBLE):
- ext = 4;
- break;
- }
- if (ext) {
- md_number_to_disp(buffer_address, (long)disp, (int)ext);
- fragP->fr_fix += ext;
- }
-} /* md_convert_frag() */
-
-
-
-/* This function returns the estimated size a variable object will occupy,
- one can say that we tries to guess the size of the objects before we
- actually know it */
-
-int md_estimate_size_before_relax(fragP, segment)
-register fragS *fragP;
-segT segment;
-{
- int old_fix;
- old_fix = fragP->fr_fix;
- switch (fragP->fr_subtype) {
- case IND(BRANCH,UNDEF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- /* the symbol has been assigned a value */
- fragP->fr_subtype = IND(BRANCH,BYTE);
- } else {
- /* we don't relax symbols defined in an other segment
- the thing to do is to assume the object will occupy 4 bytes */
- fix_new_ns32k(fragP,
- (int)(fragP->fr_fix),
- 4,
- fragP->fr_symbol,
- (symbolS *)0,
- fragP->fr_offset,
- 1,
- fragP->fr_pcrel_adjust,
- 1,
- 0,
- fragP->fr_bsr, /*sequent hack */
- NO_RELOC);
- fragP->fr_fix+=4;
- /* fragP->fr_opcode[1]=0xff; */
- frag_wane(fragP);
- break;
- }
- case IND(BRANCH,BYTE):
- fragP->fr_var+=1;
- break;
- default:
- break;
- }
- return fragP->fr_var + fragP->fr_fix - old_fix;
-}
-
-int md_short_jump_size = 3;
-int md_long_jump_size = 5;
-const int md_reloc_size = 8; /* Size of relocation record */
-
-void
- md_create_short_jump(ptr,from_addr,to_addr,frag,to_symbol)
-char *ptr;
-long from_addr,
- to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- long offset;
-
- offset = to_addr - from_addr;
- md_number_to_chars(ptr, (long)0xEA ,1);
- md_number_to_disp(ptr+1,(long)offset,2);
-}
-
-void
- md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol)
-char *ptr;
-long from_addr,
- to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- long offset;
-
- offset= to_addr - from_addr;
- md_number_to_chars(ptr, (long)0xEA, 2);
- md_number_to_disp(ptr+2,(long)offset,4);
-}
-
-/* JF this is a new function to parse machine-dep options */
-int
- md_parse_option(argP,cntP,vecP)
-char **argP;
-int *cntP;
-char ***vecP;
-{
- switch (**argP) {
- case 'm':
- (*argP)++;
-
- if (!strcmp(*argP,"32032")) {
- cpureg = cpureg_032;
- mmureg = mmureg_032;
- } else if (!strcmp(*argP, "32532")) {
- cpureg = cpureg_532;
- mmureg = mmureg_532;
- } else
- as_warn("Unknown -m option ignored");
-
- while (**argP)
- (*argP)++;
- break;
-
-#ifdef PIC
- case 'K':
- got_offset_size = 4;
- /*FALLTHROUGH*/
- case 'k':
- got_symbol = symbol_find_or_make("__GLOBAL_OFFSET_TABLE_");
- break;
-#endif
-
- default:
- return 0;
- }
- return 1;
-}
-
-/*
- * bit_fix_new()
- *
- * Create a bit_fixS in obstack 'notes'.
- * This struct is used to profile the normal fix. If the bit_fixP is a
- * valid pointer (not NULL) the bit_fix data will be used to format the fix.
- */
-bit_fixS *bit_fix_new(size, offset, min, max, add, base_type, base_adj)
-char size; /* Length of bitfield */
-char offset; /* Bit offset to bitfield */
-long base_type; /* 0 or 1, if 1 it's exploded to opcode ptr */
-long base_adj;
-long min; /* Signextended min for bitfield */
-long max; /* Signextended max for bitfield */
-long add; /* Add mask, used for huffman prefix */
-{
- register bit_fixS * bit_fixP;
-
- bit_fixP = (bit_fixS *)obstack_alloc(&notes,sizeof(bit_fixS));
-
- bit_fixP->fx_bit_size = size;
- bit_fixP->fx_bit_offset = offset;
- bit_fixP->fx_bit_base = base_type;
- bit_fixP->fx_bit_base_adj = base_adj;
- bit_fixP->fx_bit_max = max;
- bit_fixP->fx_bit_min = min;
- bit_fixP->fx_bit_add = add;
-
- return(bit_fixP);
-}
-
-void
- fix_new_ns32k(frag, where, size, add_symbol, sub_symbol, offset, pcrel,
- pcrel_adjust, im_disp, bit_fixP, bsr, r_type)
-fragS *frag; /* Which frag? */
-int where; /* Where in that frag? */
-int size; /* 1, 2 or 4 usually. */
-symbolS *add_symbol; /* X_add_symbol. */
-symbolS *sub_symbol; /* X_subtract_symbol. */
-long offset; /* X_add_number. */
-int pcrel; /* TRUE if PC-relative relocation. */
-char pcrel_adjust; /* not zero if adjustment of pcrel offset is needed */
-char im_disp; /* true if the value to write is a displacement */
-bit_fixS *bit_fixP; /* pointer at struct of bit_fix's, ignored if NULL */
-char bsr; /* sequent-linker-hack: 1 when relocobject is a bsr */
-int r_type; /* Relocation type */
-
-{
-#ifdef PIC
- fixS *fixP = fix_new(frag, where, size, add_symbol, sub_symbol,
- offset, pcrel, r_type, NULL);
-#else
- fixS *fixP = fix_new(frag, where, size, add_symbol, sub_symbol,
- offset, pcrel, r_type);
-#endif /* PIC */
- fixP->fx_pcrel_adjust = pcrel_adjust;
- fixP->fx_im_disp = im_disp;
- fixP->fx_bit_fixP = bit_fixP;
- fixP->fx_bsr = bsr;
-#ifdef PIC
- if (r_type == RELOC_GLOB_DAT)
- add_symbol->sy_forceout = 1;
-#endif /* PIC */
-} /* fix_new_ns32k() */
-
-/* We have no need to default values of symbols. */
-
-symbolS *
- md_undefined_symbol (name)
-char *name;
-{
- return 0;
-}
-
-/* Parse an operand that is machine-specific.
- We just return without modifying the expression if we have nothing
- to do. */
-
-/* ARGSUSED */
-void
- md_operand (expressionP)
-expressionS *expressionP;
-{
-}
-
-/* Round up a section size to the appropriate boundary. */
-long
- md_section_align (segment, size)
-segT segment;
-long size;
-{
- return size; /* Byte alignment is fine */
-}
-
-/* Exactly what point is a PC-relative offset relative TO?
- On the National warts, they're relative to the address of the offset,
- with some funny adjustments in some circumstances during blue moons.
- (??? Is this right? FIXME-SOON) */
-long
- md_pcrel_from (fixP)
-fixS *fixP;
-{
- long res;
- res = fixP->fx_where + fixP->fx_frag->fr_address;
-#ifdef TE_SEQUENT
- if (fixP->fx_frag->fr_bsr)
- res += 0x12; /* FOO Kludge alert! */
-#endif
- return(res);
-}
-
-/*
- * Local Variables:
- * comment-column: 0
- * End:
- */
-
-/* end of tc-ns32k.c */
diff --git a/gnu/usr.bin/as/config/tc-ns32k.h b/gnu/usr.bin/as/config/tc-ns32k.h
deleted file mode 100644
index 8f97304..0000000
--- a/gnu/usr.bin/as/config/tc-ns32k.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* tc-ns32k.h -- Opcode table for National Semi 32k processor
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef TC_NS32K
-#define TC_NS32K 1
-#include "bit_fix.h"
-
-#define LOCAL_LABELS_FB
-
-#define AOUT_MACHTYPE 137
-
-#define tc_aout_pre_write_hook(x) {;} /* not used */
-#define tc_crawl_symbol_chain(a) {;} /* not used */
-#define tc_headers_hook(a) {;} /* not used */
-
-#ifndef DEF_MODEC
-#define DEF_MODEC 20
-#endif
-
-#ifndef DEF_MODEL
-#define DEF_MODEL 20
-#endif
-
-#define MAX_ARGS 4
-#define ARG_LEN 50
-
-#if __STDC__ == 1
-
-void fix_new_ns32k(fragS *frag,
- int where,
- int size,
- struct symbol *add_symbol,
- struct symbol *sub_symbol,
- long offset,
- int pcrel,
- int pcrel_adjust,
- int im_disp,
- bit_fixS *bit_fixP, /* really bit_fixS */
- int bsr,
- int r_type);
-
-#else /* not __STDC__ */
-
-void fix_new_ns32k();
-
-#endif /* not __STDC__ */
-
-#endif /* TC_NS32K */
-
-/* end of tc-ns32k.h */
diff --git a/gnu/usr.bin/as/config/tc-rs6000.c b/gnu/usr.bin/as/config/tc-rs6000.c
deleted file mode 100644
index e69de29..0000000
--- a/gnu/usr.bin/as/config/tc-rs6000.c
+++ /dev/null
diff --git a/gnu/usr.bin/as/config/tc-rs6000.h b/gnu/usr.bin/as/config/tc-rs6000.h
deleted file mode 100644
index e69de29..0000000
--- a/gnu/usr.bin/as/config/tc-rs6000.h
+++ /dev/null
diff --git a/gnu/usr.bin/as/config/tc-sparc.c b/gnu/usr.bin/as/config/tc-sparc.c
deleted file mode 100644
index 5f2d6da..0000000
--- a/gnu/usr.bin/as/config/tc-sparc.c
+++ /dev/null
@@ -1,1803 +0,0 @@
-/* tc-sparc.c -- Assemble for the SPARC
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#define cypress 1234
-
-#include <stdio.h>
-#include <ctype.h>
-
-#include "as.h"
-
-/* careful, this file includes data *declarations* */
-#include "opcode/sparc.h"
-
-#define DEBUG_SPARC 1
-void md_begin();
-void md_end();
-void md_number_to_chars();
-void md_assemble();
-char *md_atof();
-void md_convert_frag();
-void md_create_short_jump();
-void md_create_long_jump();
-int md_estimate_size_before_relax();
-void md_ri_to_chars();
-symbolS *md_undefined_symbol();
-static void sparc_ip();
-
-static enum sparc_architecture current_architecture = v6;
-static int architecture_requested = 0;
-static int warn_on_bump = 0;
-
-const relax_typeS md_relax_table[] = {
- 0 };
-
-/* handle of the OPCODE hash table */
-static struct hash_control *op_hash = NULL;
-
-static void s_seg(), s_proc(), s_data1(), s_reserve(), s_common(), s_empty();
-extern void s_globl(), s_long(), s_short(), s_space(), cons();
-extern void s_align_bytes(), s_ignore();
-
-const pseudo_typeS md_pseudo_table[] = {
- { "align", s_align_bytes, 0 }, /* Defaulting is invalid (0) */
- { "empty", s_empty, 0 },
- { "common", s_common, 0 },
- { "global", s_globl, 0 },
- { "half", cons, 2 },
- { "optim", s_ignore, 0 },
- { "proc", s_proc, 0 },
- { "reserve", s_reserve, 0 },
- { "seg", s_seg, 0 },
- { "skip", s_space, 0 },
- { "word", cons, 4 },
- { NULL, 0, 0 },
-};
-
-const int md_short_jump_size = 4;
-const int md_long_jump_size = 4;
-const int md_reloc_size = 12; /* Size of relocation record */
-
-/* This array holds the chars that always start a comment. If the
- pre-processor is disabled, these aren't very useful */
-const char comment_chars[] = "!"; /* JF removed '|' from comment_chars */
-
-/* This array holds the chars that only start a comment at the beginning of
- a line. If the line seems to have the form '# 123 filename'
- .line and .file directives will appear in the pre-processed output */
-/* Note that input_file.c hand checks for '#' at the beginning of the
- first line of the input file. This is because the compiler outputs
- #NO_APP at the beginning of its output. */
-/* Also note that comments started like this one will always
- work if '/' isn't otherwise defined. */
-const char line_comment_chars[] = "#";
-
-/* Chars that can be used to separate mant from exp in floating point nums */
-const char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant */
-/* As in 0f12.456 */
-/* or 0d1.2345e12 */
-const char FLT_CHARS[] = "rRsSfFdDxXpP";
-
-/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
- changed in read.c. Ideally it shouldn't have to know about it at all,
- but nothing is ideal around here.
- */
-
-static unsigned char octal[256];
-#define isoctal(c) octal[c]
- static unsigned char toHex[256];
-
-struct sparc_it {
- char *error;
- unsigned long opcode;
- struct nlist *nlistp;
- expressionS exp;
- int pcrel;
- enum reloc_type reloc;
-} the_insn, set_insn;
-
-#if __STDC__ == 1
-#if DEBUG_SPARC
-static void print_insn(struct sparc_it *insn);
-#endif
-static int getExpression(char *str);
-#else /* not __STDC__ */
-#if DEBUG_SPARC
-static void print_insn();
-#endif
-static int getExpression();
-#endif /* not __STDC__ */
-
-static char *Reloc[] = {
- "RELOC_8",
- "RELOC_16",
- "RELOC_32",
- "RELOC_DISP8",
- "RELOC_DISP16",
- "RELOC_DISP32",
- "RELOC_WDISP30",
- "RELOC_WDISP22",
- "RELOC_HI22",
- "RELOC_22",
- "RELOC_13",
- "RELOC_LO10",
- "RELOC_SFA_BASE",
- "RELOC_SFA_OFF13",
- "RELOC_BASE10",
- "RELOC_BASE13",
- "RELOC_BASE22",
- "RELOC_PC10",
- "RELOC_PC22",
- "RELOC_JMP_TBL",
- "RELOC_SEGOFF16",
- "RELOC_GLOB_DAT",
- "RELOC_JMP_SLOT",
- "RELOC_RELATIVE",
- "NO_RELOC"
-};
-
-static char *expr_end;
-static int special_case;
-
-/*
- * Instructions that require wierd handling because they're longer than
- * 4 bytes.
- */
-#define SPECIAL_CASE_SET 1
-#define SPECIAL_CASE_FDIV 2
-
-/*
- * sort of like s_lcomm
- *
- */
-static int max_alignment = 15;
-
-static void s_reserve() {
- char *name;
- char *p;
- char c;
- int align;
- int size;
- int temp;
- symbolS *symbolP;
-
- name = input_line_pointer;
- c = get_symbol_end();
- p = input_line_pointer;
- *p = c;
- SKIP_WHITESPACE();
-
- if (*input_line_pointer != ',') {
- as_bad("Expected comma after name");
- ignore_rest_of_line();
- return;
- }
-
- ++input_line_pointer;
-
- if ((size = get_absolute_expression()) < 0) {
- as_bad("BSS length (%d.) <0! Ignored.", size);
- ignore_rest_of_line();
- return;
- } /* bad length */
-
- *p = 0;
- symbolP = symbol_find_or_make(name);
- *p = c;
-
- if (strncmp(input_line_pointer, ",\"bss\"", 6) != 0) {
- as_bad("bad .reserve segment: `%s'", input_line_pointer);
- return;
- } /* if not bss */
-
- input_line_pointer += 6;
- SKIP_WHITESPACE();
-
- if (*input_line_pointer == ',') {
- ++input_line_pointer;
-
- SKIP_WHITESPACE();
- if (*input_line_pointer == '\n') {
- as_bad("Missing alignment");
- return;
- }
-
- align = get_absolute_expression();
- if (align > max_alignment){
- align = max_alignment;
- as_warn("Alignment too large: %d. assumed.", align);
- } else if (align < 0) {
- align = 0;
- as_warn("Alignment negative. 0 assumed.");
- }
-#ifdef MANY_SEGMENTS
-#define SEG_BSS SEG_E2
- record_alignment(SEG_E2, align);
-#else
- record_alignment(SEG_BSS, align);
-#endif
-
- /* convert to a power of 2 alignment */
- for (temp = 0; (align & 1) == 0; align >>= 1, ++temp) ;;
-
- if (align != 1) {
- as_bad("Alignment not a power of 2");
- ignore_rest_of_line();
- return;
- } /* not a power of two */
-
- align = temp;
-
- /* Align */
- align = ~((~0) << align); /* Convert to a mask */
- local_bss_counter = (local_bss_counter + align) & (~align);
- } /* if has optional alignment */
-
- if (S_GET_OTHER(symbolP) == 0
- && S_GET_DESC(symbolP) == 0
- && ((S_GET_SEGMENT(symbolP) == SEG_BSS
- && S_GET_VALUE(symbolP) == local_bss_counter)
- || !S_IS_DEFINED(symbolP))) {
- S_SET_VALUE(symbolP, local_bss_counter);
- S_SET_SEGMENT(symbolP, SEG_BSS);
- symbolP->sy_frag = &bss_address_frag;
- local_bss_counter += size;
- } else {
- as_warn("Ignoring attempt to re-define symbol from %d. to %d.",
- S_GET_VALUE(symbolP), local_bss_counter);
- } /* if not redefining */
-
- demand_empty_rest_of_line();
- return;
-} /* s_reserve() */
-
-static void s_common() {
- register char *name;
- register char c;
- register char *p;
- register int temp;
- register symbolS * symbolP;
-
- name = input_line_pointer;
- c = get_symbol_end();
- /* just after name is now '\0' */
- p = input_line_pointer;
- *p = c;
- SKIP_WHITESPACE();
- if (* input_line_pointer != ',') {
- as_bad("Expected comma after symbol-name");
- ignore_rest_of_line();
- return;
- }
- input_line_pointer ++; /* skip ',' */
- if ((temp = get_absolute_expression ()) < 0) {
- as_bad(".COMMon length (%d.) <0! Ignored.", temp);
- ignore_rest_of_line();
- return;
- }
- *p = 0;
- symbolP = symbol_find_or_make(name);
- *p = c;
- if (S_IS_DEFINED(symbolP)) {
- as_bad("Ignoring attempt to re-define symbol");
- ignore_rest_of_line();
- return;
- }
- if (S_GET_VALUE(symbolP) != 0) {
- if (S_GET_VALUE(symbolP) != temp) {
- as_warn("Length of .comm \"%s\" is already %d. Not changed to %d.",
- S_GET_NAME(symbolP), S_GET_VALUE(symbolP), temp);
- }
- } else {
- S_SET_VALUE(symbolP, temp);
- S_SET_EXTERNAL(symbolP);
- }
- know(symbolP->sy_frag == &zero_address_frag);
- if (strncmp(input_line_pointer, ",\"bss\"", 6) != 0
- && strncmp(input_line_pointer, ",\"data\"", 7) != 0) {
- p=input_line_pointer;
- while (*p && *p != '\n')
- p++;
- c= *p;
- *p='\0';
- as_bad("bad .common segment: `%s'", input_line_pointer);
- *p=c;
- return;
- }
- input_line_pointer += 6 + (input_line_pointer[2] == 'd'); /* Skip either */
- demand_empty_rest_of_line();
- return;
-} /* s_common() */
-
-static void s_seg() {
-
- if (strncmp(input_line_pointer, "\"text\"", 6) == 0) {
- input_line_pointer += 6;
- s_text();
- return;
- }
- if (strncmp(input_line_pointer, "\"data\"", 6) == 0) {
- input_line_pointer += 6;
- s_data();
- return;
- }
- if (strncmp(input_line_pointer, "\"data1\"", 7) == 0) {
- input_line_pointer += 7;
- s_data1();
- return;
- }
- if (strncmp(input_line_pointer, "\"bss\"", 5) == 0) {
- input_line_pointer += 5;
- /* We only support 2 segments -- text and data -- for now, so
- things in the "bss segment" will have to go into data for now.
- You can still allocate SEG_BSS stuff with .lcomm or .reserve. */
- subseg_new(SEG_DATA, 255); /* FIXME-SOMEDAY */
- return;
- }
- as_bad("Unknown segment type");
- demand_empty_rest_of_line();
- return;
-} /* s_seg() */
-
-static void s_data1() {
- subseg_new(SEG_DATA, 1);
- demand_empty_rest_of_line();
- return;
-} /* s_data1() */
-
-static void s_proc() {
- extern char is_end_of_line[];
-
- while (!is_end_of_line[*input_line_pointer]) {
- ++input_line_pointer;
- }
- ++input_line_pointer;
- return;
-} /* s_proc() */
-
-/*
- * GI: This is needed for compatability with Sun's assembler - which
- * otherwise generates a warning when certain "suspect" instructions
- * appear in the delay slot of a branch. And more seriously without
- * this directive in certain cases Sun's assembler will rearrange
- * code thinking it knows how to alter things when it doesn't.
- */
-static void
-s_empty()
-{
- demand_empty_rest_of_line();
- return;
-} /* s_empty() */
-
-/* This function is called once, at assembler startup time. It should
- set up all the tables, etc. that the MD part of the assembler will need. */
-void md_begin() {
- register char *retval = NULL;
- int lose = 0;
- register unsigned int i = 0;
-
- op_hash = hash_new();
- if (op_hash == NULL)
- as_fatal("Virtual memory exhausted");
-
- while (i < NUMOPCODES) {
- const char *name = sparc_opcodes[i].name;
- retval = hash_insert(op_hash, name, &sparc_opcodes[i]);
- if (retval != NULL && *retval != '\0') {
- fprintf (stderr, "internal error: can't hash `%s': %s\n",
- sparc_opcodes[i].name, retval);
- lose = 1;
- }
- do
- {
- if (sparc_opcodes[i].match & sparc_opcodes[i].lose) {
- fprintf (stderr, "internal error: losing opcode: `%s' \"%s\"\n",
- sparc_opcodes[i].name, sparc_opcodes[i].args);
- lose = 1;
- }
- ++i;
- } while (i < NUMOPCODES
- && !strcmp(sparc_opcodes[i].name, name));
- }
-
- if (lose)
- as_fatal("Broken assembler. No assembly attempted.");
-
- for (i = '0'; i < '8'; ++i)
- octal[i] = 1;
- for (i = '0'; i <= '9'; ++i)
- toHex[i] = i - '0';
- for (i = 'a'; i <= 'f'; ++i)
- toHex[i] = i + 10 - 'a';
- for (i = 'A'; i <= 'F'; ++i)
- toHex[i] = i + 10 - 'A';
-
-#if 0
- if (picmode)
- GOT_symbol = symbol_find_or_make("__GLOBAL_OFFSET_TABLE_");
-#endif
-} /* md_begin() */
-
-void md_end() {
- return;
-} /* md_end() */
-
-void md_assemble(str)
-char *str;
-{
- char *toP;
- int rsd;
-
- know(str);
- sparc_ip(str);
-
- /* See if "set" operand is absolute and small; skip sethi if so. */
- if (special_case == SPECIAL_CASE_SET && the_insn.exp.X_seg == SEG_ABSOLUTE) {
- if (the_insn.exp.X_add_number >= -(1<<12)
- && the_insn.exp.X_add_number < (1<<12)) {
- the_insn.opcode = 0x80102000 /* or %g0,imm,... */
- | (the_insn.opcode & 0x3E000000) /* dest reg */
- | (the_insn.exp.X_add_number & 0x1FFF); /* imm */
- special_case = 0; /* No longer special */
- the_insn.reloc = NO_RELOC; /* No longer relocated */
- }
- }
-
- toP = frag_more(4);
- /* put out the opcode */
- md_number_to_chars(toP, the_insn.opcode, 4);
-
- /* put out the symbol-dependent stuff */
- if (the_insn.reloc != NO_RELOC) {
- fix_new(frag_now, /* which frag */
- (toP - frag_now->fr_literal), /* where */
- 4, /* size */
- the_insn.exp.X_add_symbol,
- the_insn.exp.X_subtract_symbol,
- the_insn.exp.X_add_number,
- the_insn.pcrel,
- the_insn.reloc,
- the_insn.exp.X_got_symbol);
- }
- switch (special_case) {
-
- case SPECIAL_CASE_SET:
- special_case = 0;
- know(the_insn.reloc == RELOC_HI22 ||
- the_insn.reloc == RELOC_BASE22);
- /* See if "set" operand has no low-order bits; skip OR if so. */
- if (the_insn.exp.X_seg == SEG_ABSOLUTE
- && ((the_insn.exp.X_add_number & 0x3FF) == 0))
- return;
- toP = frag_more(4);
- rsd = (the_insn.opcode >> 25) & 0x1f;
- the_insn.opcode = 0x80102000 | (rsd << 25) | (rsd << 14);
- md_number_to_chars(toP, the_insn.opcode, 4);
- fix_new(frag_now, /* which frag */
- (toP - frag_now->fr_literal), /* where */
- 4, /* size */
- the_insn.exp.X_add_symbol,
- the_insn.exp.X_subtract_symbol,
- the_insn.exp.X_add_number,
- the_insn.pcrel,
- the_insn.reloc==RELOC_BASE22?RELOC_BASE10:RELOC_LO10,
- the_insn.exp.X_got_symbol);
- return;
-
- case SPECIAL_CASE_FDIV:
- /* According to information leaked from Sun, the "fdiv" instructions
- on early SPARC machines would produce incorrect results sometimes.
- The workaround is to add an fmovs of the destination register to
- itself just after the instruction. This was true on machines
- with Weitek 1165 float chips, such as the Sun-4/260 and /280. */
- special_case = 0;
- assert(the_insn.reloc == NO_RELOC);
- toP = frag_more(4);
- rsd = (the_insn.opcode >> 25) & 0x1f;
- the_insn.opcode = 0x81A00020 | (rsd << 25) | rsd; /* fmovs dest,dest */
- md_number_to_chars(toP, the_insn.opcode, 4);
- return;
-
- case 0:
- return;
-
- default:
- as_fatal("md_assemble: failed sanity check.");
- }
-} /* md_assemble() */
-
-static void sparc_ip(str)
-char *str;
-{
- char *error_message = "";
- char *s;
- const char *args;
- char c;
- struct sparc_opcode *insn;
- char *argsStart;
- unsigned long opcode;
- unsigned int mask = 0;
- int match = 0;
- int comma = 0;
-
- for (s = str; islower(*s) || (*s >= '0' && *s <= '3'); ++s)
- ;
- switch (*s) {
-
- case '\0':
- break;
-
- case ',':
- comma = 1;
-
- /*FALLTHROUGH */
-
- case ' ':
- *s++ = '\0';
- break;
-
- default:
- as_bad("Unknown opcode: `%s'", str);
- exit(1);
- }
- if ((insn = (struct sparc_opcode *) hash_find(op_hash, str)) == NULL) {
- as_bad("Unknown opcode: `%s'", str);
- return;
- }
- if (comma) {
- *--s = ',';
- }
- argsStart = s;
- for (;;) {
- opcode = insn->match;
- memset(&the_insn, '\0', sizeof(the_insn));
- the_insn.reloc = NO_RELOC;
-
- /*
- * Build the opcode, checking as we go to make
- * sure that the operands match
- */
- for (args = insn->args; ; ++args) {
- switch (*args) {
-
- case 'M':
- case 'm':
- if (strncmp(s, "%asr", 4) == 0) {
- s += 4;
-
- if (isdigit(*s)) {
- long num = 0;
-
- while (isdigit(*s)) {
- num = num*10 + *s-'0';
- ++s;
- }
-
- if (num < 16 || 31 < num) {
- error_message = ": asr number must be between 15 and 31";
- goto error;
- } /* out of range */
-
- opcode |= (*args == 'M' ? RS1(num) : RD(num));
- continue;
- } else {
- error_message = ": expecting %asrN";
- goto error;
- } /* if %asr followed by a number. */
-
- } /* if %asr */
- break;
-
-
- case '\0': /* end of args */
- if (*s == '\0') {
- match = 1;
- }
- break;
-
- case '+':
- if (*s == '+') {
- ++s;
- continue;
- }
- if (*s == '-') {
- continue;
- }
- break;
-
- case '[': /* these must match exactly */
- case ']':
- case ',':
- case ' ':
- if (*s++ == *args)
- continue;
- break;
-
- case '#': /* must be at least one digit */
- if (isdigit(*s++)) {
- while (isdigit(*s)) {
- ++s;
- }
- continue;
- }
- break;
-
- case 'C': /* coprocessor state register */
- if (strncmp(s, "%csr", 4) == 0) {
- s += 4;
- continue;
- }
- break;
-
- case 'b': /* next operand is a coprocessor register */
- case 'c':
- case 'D':
- if (*s++ == '%' && *s++ == 'c' && isdigit(*s)) {
- mask = *s++;
- if (isdigit(*s)) {
- mask = 10 * (mask - '0') + (*s++ - '0');
- if (mask >= 32) {
- break;
- }
- } else {
- mask -= '0';
- }
- switch (*args) {
-
- case 'b':
- opcode |= mask << 14;
- continue;
-
- case 'c':
- opcode |= mask;
- continue;
-
- case 'D':
- opcode |= mask << 25;
- continue;
- }
- }
- break;
-
- case 'r': /* next operand must be a register */
- case 's':
- case '1':
- case '2':
- case 'd':
- case 'x':
- if (*s++ == '%') {
- switch (c = *s++) {
-
- case 'f': /* frame pointer */
- if (*s++ == 'p') {
- mask = 0x1e;
- break;
- }
- goto error;
-
- case 'g': /* global register */
- if (isoctal(c = *s++)) {
- mask = c - '0';
- break;
- }
- goto error;
-
- case 'i': /* in register */
- if (isoctal(c = *s++)) {
- mask = c - '0' + 24;
- break;
- }
- goto error;
-
- case 'l': /* local register */
- if (isoctal(c = *s++)) {
- mask= (c - '0' + 16) ;
- break;
- }
- goto error;
-
- case 'o': /* out register */
- if (isoctal(c = *s++)) {
- mask= (c - '0' + 8) ;
- break;
- }
- goto error;
-
- case 's': /* stack pointer */
- if (*s++ == 'p') {
- mask= 0xe;
- break;
- }
- goto error;
-
- case 'r': /* any register */
- if (!isdigit(c = *s++)) {
- goto error;
- }
- /* FALLTHROUGH */
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- if (isdigit(*s)) {
- if ((c = 10 * (c - '0') + (*s++ - '0')) >= 32) {
- goto error;
- }
- } else {
- c -= '0';
- }
- mask= c;
- break;
-
- case 'x':
- opcode |= (mask << 25) | mask;
- continue;
-
- default:
- goto error;
- }
- /*
- * Got the register, now figure out where
- * it goes in the opcode.
- */
- switch (*args) {
-
- case '1':
- opcode |= mask << 14;
- continue;
-
- case '2':
- opcode |= mask;
- continue;
-
- case 'd':
- opcode |= mask << 25;
- continue;
-
- case 'r':
- opcode |= (mask << 25) | (mask << 14);
- continue;
- case 'x':
- opcode |= (mask << 25) | mask;
- continue;
- }
- }
- break;
-
- case 'e': /* next operand is a floating point register */
- case 'v':
- case 'V':
-
- case 'f':
- case 'B':
- case 'R':
-
- case 'g':
- case 'H':
- case 'J': {
- char format;
-
- if (*s++ == '%'
-
- && ((format = *s) == 'f')
-
- && isdigit(*++s)) {
-
-
-
- for (mask = 0; isdigit(*s); ++s) {
- mask = 10 * mask + (*s - '0');
- } /* read the number */
-
- if ((*args == 'u'
- || *args == 'v'
- || *args == 'B'
- || *args == 'H')
- && (mask & 1)) {
- break;
- } /* register must be even numbered */
-
- if ((*args == 'U'
- || *args == 'V'
- || *args == 'R'
- || *args == 'J')
- && (mask & 3)) {
- break;
- } /* register must be multiple of 4 */
-
- if (format == 'f') {
- if (mask >= 32) {
- error_message = ": There are only 32 f registers; [0-31]";
- goto error;
- } /* on error */
- } /* if not an 'f' register. */
- } /* on error */
-
- switch (*args) {
-
- case 'v':
- case 'V':
- case 'e':
- opcode |= RS1(mask);
- continue;
-
-
- case 'f':
- case 'B':
- case 'R':
- opcode |= RS2(mask);
- continue;
-
- case 'g':
- case 'H':
- case 'J':
- opcode |= RD(mask);
- continue;
- } /* pack it in. */
-
- know(0);
- break;
- } /* float arg */
-
- case 'F':
- if (strncmp(s, "%fsr", 4) == 0) {
- s += 4;
- continue;
- }
- break;
-
- case 'h': /* high 22 bits */
- /*
- * In the case of a `set' pseudo instruction
- * we have an implied `%hi' operator.
- */
- if (special_case == SPECIAL_CASE_SET)
- the_insn.reloc = RELOC_HI22;
- else
- the_insn.reloc = RELOC_22;
- goto immediate;
-
- case 'l': /* 22 bit PC relative immediate */
- the_insn.reloc = RELOC_WDISP22;
- the_insn.pcrel = 1;
- goto immediate;
-
- case 'L': /* 30 bit immediate */
- the_insn.reloc =
-#ifdef PIC
- picmode?RELOC_JMP_TBL:
-#endif
- RELOC_WDISP30;
- the_insn.pcrel = 1;
- goto immediate;
-
- case 'n': /* 22 bit immediate */
- the_insn.reloc = RELOC_22;
- goto immediate;
-
- case 'i': /* 13 bit immediate */
- the_insn.reloc = RELOC_13;
-
- /*FALLTHROUGH */
-
- immediate:
- if (*s == ' ')
- s++;
- if (*s == '%') {
- if ((c = s[1]) == 'h' && s[2] == 'i') {
- if (the_insn.reloc != RELOC_22)
- as_bad(
- "`%hi' in improper context");
- the_insn.reloc = RELOC_HI22;
- s+=3;
- } else if (c == 'l' && s[2] == 'o') {
- the_insn.reloc = RELOC_LO10;
- s+=3;
- } else
- break;
- }
- /* Note that if the getExpression() fails, we
- will still have created U entries in the
- symbol table for the 'symbols' in the input
- string. Try not to create U symbols for
- registers, etc. */
- {
- /* This stuff checks to see if the
- expression ends in +%reg If it does,
- it removes the register from the
- expression, and re-sets 's' to point
- to the right place */
-
- char *s1;
-
- for (s1 = s; *s1 && *s1 != ',' && *s1 != ']'; s1++) ;;
-
- if (s1 != s && isdigit(s1[-1])) {
- if (s1[-2] == '%' && s1[-3] == '+') {
- s1 -= 3;
- *s1 = '\0';
- (void) getExpression(s);
- *s1 = '+';
- s = s1;
- continue;
- } else if (strchr("goli0123456789", s1[-2]) && s1[-3] == '%' && s1[-4] == '+') {
- s1 -= 4;
- *s1 = '\0';
- (void) getExpression(s);
- *s1 = '+';
- s = s1;
- continue;
- }
- }
- }
- (void)getExpression(s);
-#ifdef PIC
- /*
- * Handle refs to __GLOBAL_OFFSET_TABLE_
- */
- if (the_insn.exp.X_got_symbol) {
- switch(the_insn.reloc) {
- case RELOC_22:
- case RELOC_HI22:
- the_insn.reloc = RELOC_PC22;
- the_insn.pcrel = 1;
- break;
- case RELOC_LO10:
- the_insn.reloc = RELOC_PC10;
- the_insn.pcrel = 1;
- break;
- default:
- break;
- }
- }
-
- if (picmode && the_insn.exp.X_add_symbol) {
- switch (the_insn.reloc) {
- case RELOC_LO10:
- the_insn.reloc = RELOC_BASE10;
- the_insn.exp.X_add_symbol->sy_forceout = 1;
- break;
- case RELOC_HI22:
- the_insn.reloc = RELOC_BASE22;
- the_insn.exp.X_add_symbol->sy_forceout = 1;
- break;
- case RELOC_13:
- the_insn.reloc = RELOC_BASE13;
- the_insn.exp.X_add_symbol->sy_forceout = 1;
- break;
- }
- }
-#endif
- s = expr_end;
- continue;
-
- case 'a':
- if (*s++ == 'a') {
- opcode |= ANNUL;
- continue;
- }
- break;
-
- case 'A': {
- char *push = input_line_pointer;
- expressionS e;
-
- input_line_pointer = s;
-
- if (expression(&e) == SEG_ABSOLUTE) {
- opcode |= e.X_add_number << 5;
- s = input_line_pointer;
- input_line_pointer = push;
- continue;
- } /* if absolute */
-
- break;
- } /* alternate space */
-
- case 'p':
- if (strncmp(s, "%psr", 4) == 0) {
- s += 4;
- continue;
- }
- break;
-
- case 'q': /* floating point queue */
- if (strncmp(s, "%fq", 3) == 0) {
- s += 3;
- continue;
- }
- break;
-
- case 'Q': /* coprocessor queue */
- if (strncmp(s, "%cq", 3) == 0) {
- s += 3;
- continue;
- }
- break;
-
- case 'S':
- if (strcmp(str, "set") == 0) {
- special_case = SPECIAL_CASE_SET;
- continue;
- } else if (strncmp(str, "fdiv", 4) == 0) {
- special_case = SPECIAL_CASE_FDIV;
- continue;
- }
- break;
-
- case 't':
- if (strncmp(s, "%tbr", 4) != 0)
- break;
- s += 4;
- continue;
-
- case 'w':
- if (strncmp(s, "%wim", 4) != 0)
- break;
- s += 4;
- continue;
-
- case 'y':
- if (strncmp(s, "%y", 2) != 0)
- break;
- s += 2;
- continue;
-
- default:
- as_fatal("sparc_ip: failed sanity check.");
- } /* switch on arg code */
- break;
- } /* for each arg that we expect */
- error:
- if (match == 0) {
- /* Args don't match. */
- if (((unsigned) (&insn[1] - sparc_opcodes)) < NUMOPCODES
- && !strcmp(insn->name, insn[1].name)) {
- ++insn;
- s = argsStart;
- continue;
- } else {
- as_bad("Illegal operands%s", error_message);
- return;
- }
- } else {
- if (insn->architecture > current_architecture) {
- if (!architecture_requested || warn_on_bump) {
-
- if (warn_on_bump) {
- as_warn("architecture bumped from \"%s\" to \"%s\" on \"%s\"",
- architecture_pname[current_architecture],
- architecture_pname[insn->architecture],
- str);
- } /* if warning */
-
- current_architecture = insn->architecture;
- } else {
- as_bad("architecture mismatch on \"%s\" (\"%s\"). current architecture is \"%s\"",
- str,
- architecture_pname[insn->architecture],
- architecture_pname[current_architecture]);
- return;
- } /* if bump ok else error */
- } /* if architecture higher */
- } /* if no match */
-
- break;
- } /* forever looking for a match */
-
- the_insn.opcode = opcode;
-#if DEBUG_SPARC
- if (flagseen['D'])
- print_insn(&the_insn);
-#endif
- return;
-} /* sparc_ip() */
-
-static int getExpression(str)
-char *str;
-{
- char *save_in;
- segT seg;
-
- save_in = input_line_pointer;
- input_line_pointer = str;
- switch (seg = expression(&the_insn.exp)) {
-
- case SEG_ABSOLUTE:
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_UNKNOWN:
- case SEG_DIFFERENCE:
- case SEG_BIG:
- case SEG_ABSENT:
- break;
-
- default:
- the_insn.error = "bad segment";
- expr_end = input_line_pointer;
- input_line_pointer=save_in;
- return 1;
- }
-
- expr_end = input_line_pointer;
- input_line_pointer = save_in;
- return 0;
-} /* getExpression() */
-
-
-/*
- This is identical to the md_atof in m68k.c. I think this is right,
- but I'm not sure.
-
- Turn a string in input_line_pointer into a floating point constant of type
- type, and store the appropriate bytes in *litP. The number of LITTLENUMS
- emitted is stored in *sizeP. An error message is returned, or NULL on OK.
- */
-
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
-char *md_atof(type,litP,sizeP)
-char type;
-char *litP;
-int *sizeP;
-{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- char *t;
- char *atof_ieee();
-
- switch (type) {
-
- case 'f':
- case 'F':
- case 's':
- case 'S':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- prec = 4;
- break;
-
- case 'x':
- case 'X':
- prec = 6;
- break;
-
- case 'p':
- case 'P':
- prec = 6;
- break;
-
- default:
- *sizeP=0;
- return "Bad call to MD_ATOF()";
- }
- t=atof_ieee(input_line_pointer,type,words);
- if (t)
- input_line_pointer=t;
- *sizeP=prec * sizeof(LITTLENUM_TYPE);
- for (wordP=words;prec--;) {
- md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE));
- litP+=sizeof(LITTLENUM_TYPE);
- }
- return ""; /* Someone should teach Dean about null pointers */
-} /* md_atof() */
-
-/*
- * Write out big-endian.
- */
-void md_number_to_chars(buf,val,n)
-char *buf;
-long val;
-int n;
-{
-
- switch (n) {
-
- case 4:
- *buf++ = val >> 24;
- *buf++ = val >> 16;
- case 2:
- *buf++ = val >> 8;
- case 1:
- *buf = val;
- break;
-
- default:
- as_fatal("md_number_to_chars: failed sanity check.");
- }
- return;
-} /* md_number_to_chars() */
-
-static int reloc_check(val, bits, fixP)
-long val;
-int bits;
-fixS *fixP /* For reporting errors */;
-{
- if (((val & (-1 << bits)) != 0)
- && ((val & (-1 << bits)) != (-1 << (bits - 0)))) {
-
- long addr = fixP->fx_where + fixP->fx_frag->fr_address;
- int ln;
- char *fname;
-
- if (fixP->fx_frag->line) {
- fname = fixP->fx_frag->line->file->filename;
- ln = fixP->fx_frag->line->line;
- } else {
- fname = "";
- ln = -1;
- }
-
- as_warn_where(fname, ln,
- "Relocation (%s) overflow at %#x, value truncated.",
- Reloc[fixP->fx_r_type], addr);
- } /* on overflow */
-
-} /* reloc_check() */
-
-
-/* Apply a fixS to the frags, now that we know the value it ought to
- hold. */
-
-void md_apply_fix(fixP, val)
-fixS *fixP;
-long val;
-{
- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
- long addr = fixP->fx_where + fixP->fx_frag->fr_address;
-
-#if DEBUG_SPARC
- if (flagseen['D'])
- fprintf(stderr, "md_apply_fix: \"%s\" \"%s\", val %d -- %s\n",
- ((fixP->fx_addsy != NULL)
- ? ((S_GET_NAME(fixP->fx_addsy) != NULL)
- ? S_GET_NAME(fixP->fx_addsy)
- : "???")
- : "0"),
- ((fixP->fx_subsy != NULL)
- ? ((S_GET_NAME(fixP->fx_subsy) != NULL)
- ? S_GET_NAME(fixP->fx_subsy)
- : "???")
- : "0"),
- val, Reloc[fixP->fx_r_type]);
-#endif
-
- assert(fixP->fx_size == 4);
- assert(fixP->fx_r_type < NO_RELOC);
-
- fixP->fx_addnumber = val; /* Remember value for emit_reloc */
-
- /*
- * This is a hack. There should be a better way to
- * handle this.
- */
- if (fixP->fx_r_type == RELOC_WDISP30 && fixP->fx_addsy) {
- val += fixP->fx_where + fixP->fx_frag->fr_address;
- }
-
- switch (fixP->fx_r_type) {
-
- /* Michael Bloom <mb@ttidca.tti.com> says... [This] change was
- made to match the behavior of Sun's assembler. Some broken
- loaders depend on that. At least one such loader actually
- adds the section data to what it finds in the addend. (It
- should only be using the addend like Sun's loader seems to).
- This caused incorrect relocation: (addend + adjustment)
- became ( ( 2 * addend ) + adjustment ). [and there should
- be no cases that reach here anyway. */
- case RELOC_32:
- if (fixP->fx_addsy == NULL) {
- /*
- * Ok, the remarks above do not hold if the
- * expression has been reduced to a number.
- */
- buf[0] = val >> 24;
- buf[1] = val >> 16;
- buf[2] = val >> 8;
- buf[3] = val;
- } else {
- buf[0] = 0;
- buf[1] = 0;
- buf[2] = 0;
- buf[3] = 0;
- }
- break;
-
- case RELOC_JMP_TBL:
- if (!fixP->fx_addsy) {
- val = (val >>= 2) + 1;
- reloc_check(val, 30, fixP);
-
- buf[0] |= (val >> 24) & 0x3f;
- buf[1]= (val >> 16);
- buf[2] = val >> 8;
- buf[3] = val;
- }
- break;
-
- case RELOC_WDISP30:
- val = (val >>= 2) + 1;
- reloc_check(val, 30, fixP);
-
- buf[0] |= (val >> 24) & 0x3f;
- buf[1]= (val >> 16);
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
- case RELOC_WDISP22:
- val = (val >>= 2) + 1;
- reloc_check(val, 22, fixP);
-
- buf[1] |= (val >> 16) & 0x3f;
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
- /*
- * We should only use the RELOC_HI22 type as a result of the %hi
- * operator (which is implicit in the case of the `set' pseudo op),
- * This is NOT the same as using the `sethi' instruction, which merely
- * puts the 22 bit operand into the high 22 bits of the destination
- * register.
- */
- case RELOC_22:
- if (!fixP->fx_addsy) {
- reloc_check(val, 22, fixP);
-
- buf[1] |= (val >> 16) & 0x3f;
- buf[2] = val >> 8;
- buf[3] = val;
- }
- break;
-
- case RELOC_HI22:
- case RELOC_BASE22:
- if (!fixP->fx_addsy) {
- buf[1] |= (val >> 26) & 0x3f;
- buf[2] = val >> 18;
- buf[3] = val >> 10;
- } else {
- if (picmode && fixP->fx_r_type == RELOC_HI22)
- as_warn("non-PIC access to %s",
- S_GET_NAME(fixP->fx_addsy));
- buf[2]=0;
- buf[3]=0;
- }
- break;
-
- case RELOC_13:
- case RELOC_BASE13:
- if (!fixP->fx_addsy) {
- reloc_check(val, 13, fixP);
- buf[2] |= (val >> 8) & 0x1f;
- buf[3] = val;
- } else {
- buf[3]=0;
- }
- break;
-
- case RELOC_LO10:
- case RELOC_BASE10:
- if (!fixP->fx_addsy) {
- buf[2] |= (val >> 8) & 0x03;
- buf[3] = val & 0xff;
- } else {
- if (picmode && fixP->fx_r_type == RELOC_LO10)
- as_warn("non-PIC access to %s",
- S_GET_NAME(fixP->fx_addsy));
- buf[3]=0;
- }
- break;
-
- case RELOC_PC10:
- case RELOC_PC22:
- if (fixP->fx_addsy != GOT_symbol) {
- as_fatal("GOT");
- }
- break;
-
-#if 0
- case RELOC_8: /* These don't seem to ever be needed. */
- case RELOC_16:
- case RELOC_DISP8:
- case RELOC_DISP16:
- case RELOC_DISP32:
- case RELOC_SEGOFF16:
- case RELOC_SFA_BASE:
- case RELOC_SFA_OFF13:
-
- case RELOC_GLOB_DAT: /* These are output by linker only */
- case RELOC_JMP_SLOT:
- case RELOC_RELATIVE:
-#endif
-
- case NO_RELOC:
- default:
- as_bad("bad relocation type: 0x%02x", fixP->fx_r_type);
- break;
- }
-} /* md_apply_fix() */
-
-/* should never be called for sparc */
-void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr;
-long to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- as_fatal("sparc_create_short_jmp\n");
-} /* md_create_short_jump() */
-
-/* Translate internal representation of relocation info to target format.
-
- On sparc: first 4 bytes are normal unsigned long address, next three
- bytes are index, most sig. byte first. Byte 7 is broken up with
- bit 7 as external, bits 6 & 5 unused, and the lower
- five bits as relocation type. Next 4 bytes are long addend. */
-/* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com */
-void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
-char *where;
-fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- long r_index;
- long r_extern;
- long r_addend = 0;
- long r_address;
-#ifdef PIC
- int kflag = 0;
-#endif
-
- know(fixP->fx_addsy);
-
- if (!S_IS_DEFINED(fixP->fx_addsy)) {
- r_extern = 1;
- r_index = fixP->fx_addsy->sy_number;
- } else {
- r_extern = 0;
- r_index = S_GET_TYPE(fixP->fx_addsy);
-#ifdef PIC
- if (picmode) {
- switch (fixP->fx_r_type) {
- case RELOC_BASE10:
- case RELOC_BASE13:
- case RELOC_BASE22:
- r_index = fixP->fx_addsy->sy_number;
- if (S_IS_EXTERNAL(fixP->fx_addsy))
- r_extern = 1;
- kflag = 1;
- break;
-
- case RELOC_32:
- if (!S_IS_EXTERNAL(fixP->fx_addsy))
- break;
- r_extern = 1;
- r_index = fixP->fx_addsy->sy_number;
- break;
-
- default:
- break;
- }
- }
-#endif
- }
-
- /* this is easy */
- md_number_to_chars(where,
- r_address = fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
- 4);
-
- /* now the fun stuff */
- where[4] = (r_index >> 16) & 0x0ff;
- where[5] = (r_index >> 8) & 0x0ff;
- where[6] = r_index & 0x0ff;
- where[7] = ((r_extern << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F);
-
- /* Also easy */
- if (fixP->fx_addsy->sy_frag) {
- r_addend = fixP->fx_addsy->sy_frag->fr_address;
- }
-
- if (fixP->fx_pcrel) {
-#ifdef PIC
- if (fixP->fx_gotsy) {
- r_addend = r_address;
- r_addend += fixP->fx_addnumber;
- } else
-#endif
- r_addend -= r_address;
- } else {
-#ifdef PIC
- if (kflag)
- r_addend = 0;
- else
-#endif
- r_addend = fixP->fx_addnumber;
- }
-
- md_number_to_chars(&where[8], r_addend, 4);
-
- return;
-} /* tc_aout_fix_to_chars() */
-
-/* should never be called for sparc */
-void md_convert_frag(headers, fragP)
-object_headers *headers;
-register fragS *fragP;
-{
- as_fatal("sparc_convert_frag\n");
-} /* md_convert_frag() */
-
-/* should never be called for sparc */
-void md_create_long_jump(ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr, to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- as_fatal("sparc_create_long_jump\n");
-} /* md_create_long_jump() */
-
-/* should never be called for sparc */
-int md_estimate_size_before_relax(fragP, segtype)
-fragS *fragP;
-segT segtype;
-{
- as_fatal("sparc_estimate_size_before_relax\n");
- return(1);
-} /* md_estimate_size_before_relax() */
-
-#if DEBUG_SPARC
-/* for debugging only */
-static void print_insn(insn)
-struct sparc_it *insn;
-{
-
- if (insn->error) {
- fprintf(stderr, "ERROR: %s\n", insn->error);
- }
- fprintf(stderr, "opcode=0x%08x\n", insn->opcode);
- fprintf(stderr, "reloc = %s\n", Reloc[insn->reloc]);
- fprintf(stderr, "exp = {\n");
- fprintf(stderr, "\t\tX_add_symbol = %s\n",
- ((insn->exp.X_add_symbol != NULL)
- ? ((S_GET_NAME(insn->exp.X_add_symbol) != NULL)
- ? S_GET_NAME(insn->exp.X_add_symbol)
- : "???")
- : "0"));
- fprintf(stderr, "\t\tX_sub_symbol = %s\n",
- ((insn->exp.X_subtract_symbol != NULL)
- ? (S_GET_NAME(insn->exp.X_subtract_symbol)
- ? S_GET_NAME(insn->exp.X_subtract_symbol)
- : "???")
- : "0"));
- fprintf(stderr, "\t\tX_got_symbol = %s\n",
- ((insn->exp.X_got_symbol != NULL)
- ? (S_GET_NAME(insn->exp.X_got_symbol)
- ? S_GET_NAME(insn->exp.X_got_symbol)
- : "???")
- : "0"));
- fprintf(stderr, "\t\tX_add_number = %d\n",
- insn->exp.X_add_number);
- fprintf(stderr, "}\n");
- return;
-} /* print_insn() */
-#endif
-
-/* Set the hook... */
-
-/* void emit_sparc_reloc();
- void (*md_emit_relocations)() = emit_sparc_reloc; */
-
-#ifdef comment
-
-/*
- * Sparc/AM29K relocations are completely different, so it needs
- * this machine dependent routine to emit them.
- */
-#if defined(OBJ_AOUT) || defined(OBJ_BOUT)
-void emit_sparc_reloc(fixP, segment_address_in_file)
-register fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- struct reloc_info_generic ri;
- register symbolS *symbolP;
- extern char *next_object_file_charP;
- /* long add_number; */
-
- memset((char *) &ri, '\0', sizeof(ri));
- for (; fixP; fixP = fixP->fx_next) {
-
- if (fixP->fx_r_type >= NO_RELOC) {
- as_fatal("fixP->fx_r_type = %d\n", fixP->fx_r_type);
- }
-
- if ((symbolP = fixP->fx_addsy) != NULL) {
- ri.r_address = fixP->fx_frag->fr_address +
- fixP->fx_where - segment_address_in_file;
- if ((S_GET_TYPE(symbolP)) == N_UNDF) {
- ri.r_extern = 1;
- ri.r_index = symbolP->sy_number;
- } else {
- ri.r_extern = 0;
- ri.r_index = S_GET_TYPE(symbolP);
- }
- if (symbolP && symbolP->sy_frag) {
- ri.r_addend = symbolP->sy_frag->fr_address;
- }
- ri.r_type = fixP->fx_r_type;
- if (fixP->fx_pcrel) {
- /* ri.r_addend -= fixP->fx_where; */
- ri.r_addend -= ri.r_address;
- } else {
- ri.r_addend = fixP->fx_addnumber;
- }
-
- md_ri_to_chars(next_object_file_charP, &ri);
- next_object_file_charP += md_reloc_size;
- }
- }
- return;
-} /* emit_sparc_reloc() */
-#endif /* aout or bout */
-#endif /* comment */
-
-/*
- * md_parse_option
- * Invocation line includes a switch not recognized by the base assembler.
- * See if it's a processor-specific option. These are:
- *
- * -bump
- * Warn on architecture bumps. See also -A.
- *
- * -Av6, -Av7, -Av8
- * Select the architecture. Instructions or features not
- * supported by the selected architecture cause fatal errors.
- *
- * The default is to start at v6, and bump the architecture up
- * whenever an instruction is seen at a higher level.
- *
- * If -bump is specified, a warning is printing when bumping to
- * higher levels.
- *
- * If an architecture is specified, all instructions must match
- * that architecture. Any higher level instructions are flagged
- * as errors.
- *
- * if both an architecture and -bump are specified, the
- * architecture starts at the specified level, but bumps are
- * warnings.
- *
- */
-int md_parse_option(argP, cntP, vecP)
-char **argP;
-int *cntP;
-char ***vecP;
-{
- char *p;
- const char **arch;
-
- if (!strcmp(*argP,"bump")){
- warn_on_bump = 1;
-
- } else if (**argP == 'A'){
- p = (*argP) + 1;
-
- for (arch = architecture_pname; *arch != NULL; ++arch){
- if (strcmp(p, *arch) == 0){
- break;
- } /* found a match */
- } /* walk the pname table */
-
- if (*arch == NULL){
- as_bad("unknown architecture: %s", p);
- } else {
- current_architecture = (enum sparc_architecture) (arch - architecture_pname);
- architecture_requested = 1;
- }
-#ifdef PIC
- } else if (**argP == 'k' || **argP == 'K') {
- /* Predefine GOT symbol */
- GOT_symbol = symbol_find_or_make("__GLOBAL_OFFSET_TABLE_");
-#endif
- } else {
- /* Unknown option */
- (*argP)++;
- return 0;
- }
- **argP = '\0'; /* Done parsing this switch */
- return 1;
-} /* md_parse_option() */
-
-/* We have no need to default values of symbols. */
-
-/* ARGSUSED */
-symbolS *md_undefined_symbol(name)
-char *name;
-{
- return 0;
-} /* md_undefined_symbol() */
-
-/* Parse an operand that is machine-specific.
- We just return without modifying the expression if we have nothing
- to do. */
-
-/* ARGSUSED */
-void md_operand(expressionP)
-expressionS *expressionP;
-{
-} /* md_operand() */
-
-/* Round up a section size to the appropriate boundary. */
-long md_section_align(segment, size)
-segT segment;
-long size;
-{
- return((size + 7) & ~7); /* Round all sects to multiple of 8 */
-} /* md_section_align() */
-
-/* Exactly what point is a PC-relative offset relative TO?
- On the sparc, they're relative to the address of the offset, plus
- its size. This gets us to the following instruction.
- (??? Is this right? FIXME-SOON) */
-long md_pcrel_from(fixP)
-fixS *fixP;
-{
-#ifdef PIC
- /*
- * _GLOBAL_OFFSET_TABLE_ refs are relative to the offset of the
- * current instruction. We omit fx_size from the computation (which
- * is always 4 anyway).
- */
- if (fixP->fx_gotsy)
- return fixP->fx_where + fixP->fx_frag->fr_address;
- else
-#endif
- return(fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address);
-} /* md_pcrel_from() */
-
-void tc_aout_pre_write_hook(headers)
-object_headers *headers;
-{
- H_SET_VERSION(headers, 1);
- return;
-} /* tc_aout_pre_write_hook() */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-sparc.c */
diff --git a/gnu/usr.bin/as/config/tc-sparc.h b/gnu/usr.bin/as/config/tc-sparc.h
deleted file mode 100644
index 2a82a31..0000000
--- a/gnu/usr.bin/as/config/tc-sparc.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* tc-sparc.h - Macros and type defines for the sparc.
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write
- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * $Id$
- */
-
-#define TC_SPARC 1
-
-#define LOCAL_LABELS_FB
-#define WORKING_DOT_WORD
-
-#ifdef __NetBSD__
-#define AOUT_MACHTYPE 138
-#endif
-
-#ifdef sun
-#define AOUT_MACHTYPE 3
-#define AOUT_VERSION 1
-#endif
-
-#define tc_headers_hook(a) {;} /* don't need it. */
-#define tc_crawl_symbol_chain(a) {;} /* don't need it. */
-
-void tc_aout_pre_write_hook();
-
-#define LISTING_HEADER "SPARC GAS "
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-sparc.h */
diff --git a/gnu/usr.bin/as/config/tc-tahoe.c b/gnu/usr.bin/as/config/tc-tahoe.c
deleted file mode 100644
index 4cd1a82..0000000
--- a/gnu/usr.bin/as/config/tc-tahoe.c
+++ /dev/null
@@ -1,1924 +0,0 @@
-/* tc-tahoe.c
- Not part of GAS yet. */
-
-#include "as.h"
-#include "obstack.h"
-
- /* this bit glommed from tahoe-inst.h */
-
-typedef unsigned char byte;
-typedef byte tahoe_opcodeT;
-
-/*
- * This is part of tahoe-ins-parse.c & friends.
- * We want to parse a tahoe instruction text into a tree defined here.
- */
-
-#define TIT_MAX_OPERANDS (4) /* maximum number of operands in one
- single tahoe instruction */
-
-struct top /* tahoe instruction operand */
-{
- int top_ndx; /* -1, or index register. eg 7=[R7] */
- int top_reg; /* -1, or register number. eg 7 = R7 or (R7) */
- byte top_mode; /* Addressing mode byte. This byte, defines
- which of the 11 modes opcode is. */
-
- char top_access; /* Access type wanted for this opperand
- 'b'branch ' 'no-instruction 'amrvw' */
- char top_width; /* Operand width expected, one of "bwlq?-:!" */
-
- char *top_error; /* Say if operand is inappropriate */
-
- expressionS exp_of_operand; /* The expression as parsed by expression()*/
-
- byte top_dispsize; /* Number of bytes in the displacement if we
- can figure it out */
-};
-
-/* The addressing modes for an operand. These numbers are the acutal values
- for certain modes, so be carefull if you screw with them. */
-#define TAHOE_DIRECT_REG (0x50)
-#define TAHOE_REG_DEFERRED (0x60)
-
-#define TAHOE_REG_DISP (0xE0)
-#define TAHOE_REG_DISP_DEFERRED (0xF0)
-
-#define TAHOE_IMMEDIATE (0x8F)
-#define TAHOE_IMMEDIATE_BYTE (0x88)
-#define TAHOE_IMMEDIATE_WORD (0x89)
-#define TAHOE_IMMEDIATE_LONGWORD (0x8F)
-#define TAHOE_ABSOLUTE_ADDR (0x9F)
-
-#define TAHOE_DISPLACED_RELATIVE (0xEF)
-#define TAHOE_DISP_REL_DEFERRED (0xFF)
-
-#define TAHOE_AUTO_DEC (0x7E)
-#define TAHOE_AUTO_INC (0x8E)
-#define TAHOE_AUTO_INC_DEFERRED (0x9E)
-/* INDEXED_REG is decided by the existance or lack of a [reg] */
-
-/* These are encoded into top_width when top_access=='b'
- and it's a psuedo op.*/
-#define TAHOE_WIDTH_ALWAYS_JUMP '-'
-#define TAHOE_WIDTH_CONDITIONAL_JUMP '?'
-#define TAHOE_WIDTH_BIG_REV_JUMP '!'
-#define TAHOE_WIDTH_BIG_NON_REV_JUMP ':'
-
-/* The hex code for certain tahoe commands and modes.
- This is just for readability. */
-#define TAHOE_JMP (0x71)
-#define TAHOE_PC_REL_LONG (0xEF)
-#define TAHOE_BRB (0x11)
-#define TAHOE_BRW (0x13)
-/* These, when 'ored' with, or added to, a register number,
- set up the number for the displacement mode. */
-#define TAHOE_PC_OR_BYTE (0xA0)
-#define TAHOE_PC_OR_WORD (0xC0)
-#define TAHOE_PC_OR_LONG (0xE0)
-
-struct tit /* get it out of the sewer, it stands for
- tahoe instruction tree (Geeze!) */
-{
- tahoe_opcodeT tit_opcode; /* The opcode. */
- byte tit_operands; /* How many operands are here. */
- struct top tit_operand[TIT_MAX_OPERANDS]; /* Operands */
- char *tit_error; /* "" or fatal error text */
-};
-
-/* end: tahoe-inst.h */
-
-/* tahoe.c - tahoe-specific -
- Not part of gas yet.
- */
-
-#include "opcode/tahoe.h"
-
-/* This is the number to put at the beginning of the a.out file */
-long omagic = OMAGIC;
-
-/* These chars start a comment anywhere in a source file (except inside
- another comment or a quoted string. */
-const char comment_chars[] = "#;";
-
-/* These chars only start a comment at the beginning of a line. */
-const char line_comment_chars[] = "#";
-
-/* Chars that can be used to separate mant from exp in floating point nums */
-const char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant
- as in 0f123.456
- or 0d1.234E-12 (see exp chars above)
- Note: The Tahoe port doesn't support floating point constants. This is
- consistant with 'as' If it's needed, I can always add it later. */
-const char FLT_CHARS[] = "df";
-
-/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
- changed in read.c . Ideally it shouldn't have to know about it at all,
- but nothing is ideal around here.
- (The tahoe has plenty of room, so the change currently isn't needed.)
- */
-
-static struct tit t; /* A tahoe instruction after decoding. */
-
-void float_cons ();
-/* A table of pseudo ops (sans .), the function called, and an integer op
- that the function is called with. */
-
-const pseudo_typeS md_pseudo_table[] =
-{
- {"dfloat", float_cons, 'd'},
- {"ffloat", float_cons, 'f'},
- {0}
-};
-
-/*
- * For Tahoe, relative addresses of "just the right length" are pretty easy.
- * The branch displacement is always the last operand, even in
- * synthetic instructions.
- * For Tahoe, we encode the relax_substateTs (in e.g. fr_substate) as:
- *
- * 4 3 2 1 0 bit number
- * ---/ /--+-------+-------+-------+-------+-------+
- * | what state ? | how long ? |
- * ---/ /--+-------+-------+-------+-------+-------+
- *
- * The "how long" bits are 00=byte, 01=word, 10=long.
- * This is a Un*x convention.
- * Not all lengths are legit for a given value of (what state).
- * The four states are listed below.
- * The "how long" refers merely to the displacement length.
- * The address usually has some constant bytes in it as well.
- *
-
-States for Tahoe address relaxing.
-1. TAHOE_WIDTH_ALWAYS_JUMP (-)
- Format: "b-"
- Tahoe opcodes are: (Hex)
- jr 11
- jbr 11
- Simple branch.
- Always, 1 byte opcode, then displacement/absolute.
- If word or longword, change opcode to brw or jmp.
-
-
-2. TAHOE_WIDTH_CONDITIONAL_JUMP (?)
- J<cond> where <cond> is a simple flag test.
- Format: "b?"
- Tahoe opcodes are: (Hex)
- jneq/jnequ 21
- jeql/jeqlu 31
- jgtr 41
- jleq 51
- jgeq 81
- jlss 91
- jgtru a1
- jlequ b1
- jvc c1
- jvs d1
- jlssu/jcs e1
- jgequ/jcc f1
- Always, you complement 4th bit to reverse the condition.
- Always, 1-byte opcode, then 1-byte displacement.
-
-3. TAHOE_WIDTH_BIG_REV_JUMP (!)
- Jbc/Jbs where cond tests a memory bit.
- Format: "rlvlb!"
- Tahoe opcodes are: (Hex)
- jbs 0e
- jbc 1e
- Always, you complement 4th bit to reverse the condition.
- Always, 1-byte opcde, longword, longword-address, 1-word-displacement
-
-4. TAHOE_WIDTH_BIG_NON_REV_JUMP (:)
- JaoblXX/Jbssi
- Format: "rlmlb:"
- Tahoe opcodes are: (Hex)
- aojlss 2f
- jaoblss 2f
- aojleq 3f
- jaobleq 3f
- jbssi 5f
- Always, we cannot reverse the sense of the branch; we have a word
- displacement.
-
-We need to modify the opcode is for class 1, 2 and 3 instructions.
-After relax() we may complement the 4th bit of 2 or 3 to reverse sense of
-branch.
-
-We sometimes store context in the operand literal. This way we can figure out
-after relax() what the original addressing mode was. (Was is pc_rel, or
-pc_rel_disp? That sort of thing.) */
-
-/* These displacements are relative to the START address of the
- displacement which is at the start of the displacement, not the end of
- the instruction. The hardware pc_rel is at the end of the instructions.
- That's why all the displacements have the length of the displacement added
- to them. (WF + length(word))
-
- The first letter is Byte, Word.
- 2nd letter is Forward, Backward. */
-#define BF (1+ 127)
-#define BB (1+-128)
-#define WF (2+ 32767)
-#define WB (2+-32768)
-/* Dont need LF, LB because they always reach. [They are coded as 0.] */
-
-#define C(a,b) ENCODE_RELAX(a,b)
- /* This macro has no side-effects. */
-#define ENCODE_RELAX(what,length) (((what) << 2) + (length))
-#define RELAX_STATE(what) ((what) >> 2)
-#define RELAX_LENGTH(length) ((length) && 3)
-
-#define STATE_ALWAYS_BRANCH (1)
-#define STATE_CONDITIONAL_BRANCH (2)
-#define STATE_BIG_REV_BRANCH (3)
-#define STATE_BIG_NON_REV_BRANCH (4)
-#define STATE_PC_RELATIVE (5)
-
-#define STATE_BYTE (0)
-#define STATE_WORD (1)
-#define STATE_LONG (2)
-#define STATE_UNDF (3) /* Symbol undefined in pass1 */
-
-/* This is the table used by gas to figure out relaxing modes. The fields are
- forward_branch reach, backward_branch reach, number of bytes it would take,
- where the next biggest branch is. */
-const relax_typeS
-md_relax_table[] =
-{
- {
- 1, 1, 0, 0
- }, /* error sentinel 0,0 */
- {
- 1, 1, 0, 0
- }, /* unused 0,1 */
- {
- 1, 1, 0, 0
- }, /* unused 0,2 */
- {
- 1, 1, 0, 0
- }, /* unused 0,3 */
- /* Unconditional branch cases "jrb"
- The relax part is the actual displacement */
- {
- BF, BB, 1, C (1, 1)
- }, /* brb B`foo 1,0 */
- {
- WF, WB, 2, C (1, 2)
- }, /* brw W`foo 1,1 */
- {
- 0, 0, 5, 0
- }, /* Jmp L`foo 1,2 */
- {
- 1, 1, 0, 0
- }, /* unused 1,3 */
- /* Reversible Conditional Branch. If the branch won't reach, reverse
- it, and jump over a brw or a jmp that will reach. The relax part is the
- actual address. */
- {
- BF, BB, 1, C (2, 1)
- }, /* b<cond> B`foo 2,0 */
- {
- WF + 2, WB + 2, 4, C (2, 2)
- }, /* brev over, brw W`foo, over: 2,1 */
- {
- 0, 0, 7, 0
- }, /* brev over, jmp L`foo, over: 2,2 */
- {
- 1, 1, 0, 0
- }, /* unused 2,3 */
- /* Another type of reversable branch. But this only has a word
- displacement. */
- {
- 1, 1, 0, 0
- }, /* unused 3,0 */
- {
- WF, WB, 2, C(3, 2)
- }, /* jbX W`foo 3,1 */
- {
- 0, 0, 8, 0
- }, /* jrevX over, jmp L`foo, over: 3,2 */
- {
- 1, 1, 0, 0
- }, /* unused 3,3 */
- /* These are the non reversable branches, all of which have a word
- displacement. If I can't reach, branch over a byte branch, to a
- jump that will reach. The jumped branch jumps over the reaching
- branch, to continue with the flow of the program. It's like playing
- leap frog. */
- {
- 1, 1, 0, 0
- }, /* unused 4,0 */
- {
- WF, WB, 2, C (4, 2)
- }, /* aobl_ W`foo 4,1 */
- {
- 0, 0, 10, 0
- }, /*aobl_ W`hop,br over,hop: jmp L^foo,over 4,2*/
- {
- 1, 1, 0, 0
- }, /* unused 4,3 */
- /* Normal displacement mode, no jumping or anything like that.
- The relax points to one byte before the address, thats why all
- the numbers are up by one. */
- {
- BF + 1, BB + 1, 2, C (5, 1)
- }, /* B^"foo" 5,0 */
- {
- WF + 1, WB + 1, 3, C (5, 2)
- }, /* W^"foo" 5,1 */
- {
- 0, 0, 5, 0
- }, /* L^"foo" 5,2 */
- {
- 1, 1, 0, 0
- }, /* unused 5,3 */
-};
-
-#undef C
-#undef BF
-#undef BB
-#undef WF
-#undef WB
-/* End relax stuff */
-
-static struct hash_control *op_hash = NULL; /* handle of the OPCODE hash table
- NULL means any use before md_begin() will
- crash */
-
-/* Init function. Build the hash table. */
-void
-md_begin()
-{
- struct tot *tP;
- char *errorval = "";
- int synthetic_too = 1; /* If 0, just use real opcodes. */
-
- if ((op_hash = hash_new())){
- for (tP= totstrs; *tP->name && !*errorval; tP++){
- errorval = hash_insert (op_hash, tP->name, &tP->detail);
- }
- if (synthetic_too){
- for (tP = synthetic_totstrs; *tP->name && !*errorval; tP++){
- errorval = hash_insert (op_hash, tP->name, &tP->detail);
- }
- }
- }else{
- errorval = "Virtual memory exceeded";
- }
- if (*errorval)
- as_fatal(errorval);
-}/* md_begin */
-
-void
-md_end()
-{
-}/* md_end */
-
-int
-md_parse_option (argP, cntP, vecP)
- char **argP;
- int *cntP;
- char ***vecP;
-{
- char *temp_name; /* name for -t or -d options */
- char opt;
-
- switch (**argP){
- case 'a':
- as_warn("The -a option doesn't exits. (Dispite what the man page says!");
-
- case 'J':
- as_warn("JUMPIFY (-J) not implemented, use psuedo ops instead.");
- break;
-
- case 'S':
- as_warn ("SYMBOL TABLE not implemented");
- break; /* SYMBOL TABLE not implemented */
-
- case 'T':
- as_warn ("TOKEN TRACE not implemented");
- break; /* TOKEN TRACE not implemented */
-
- case 'd':
- case 't':
- opt= **argP;
- if (**argP){ /* Rest of argument is filename. */
- temp_name = *argP;
- while (**argP)
- (*argP)++;
- }else if (*cntP){
- while (**argP)
- (*argP)++;
- --(*cntP);
- temp_name = *++(*vecP);
- **vecP = NULL; /* Remember this is not a file-name. */
- }else{
- as_warn ("I expected a filename after -%c.",opt);
- temp_name = "{absent}";
- }
-
- if(opt=='d')
- as_warn ("Displacement length %s ignored!", temp_name);
- else
- as_warn ("I don't need or use temp. file \"%s\".", temp_name);
- break;
-
- case 'V':
- as_warn ("I don't use an interpass file! -V ignored");
- break;
-
- default:
- return 0;
-
- }
- return 1;
-}
-
-/* The functions in this section take numbers in the machine format, and
- munges them into Tahoe byte order.
- They exist primarily for cross assembly purpose. */
-void /* Knows about order of bytes in address. */
-md_number_to_chars (con, value, nbytes)
- char con[]; /* Return 'nbytes' of chars here. */
- long int value; /* The value of the bits. */
- int nbytes; /* Number of bytes in the output. */
-{
- int n = nbytes;
- long int v = value;
-
- con += nbytes - 1; /* Tahoes is (Bleah!) big endian */
- while (nbytes--){
- *con-- = value; /* Lint wants & MASK_CHAR. */
- value >>= BITS_PER_CHAR;
- }
- /* XXX line number probably botched for this warning message. */
- if (value != 0 && value != -1)
- as_warn ("Displacement (%ld) long for instruction field length (%d).",v,n);
-}
-
-#ifdef comment
-void /* Knows about order of bytes in address. */
-md_number_to_imm (con, value, nbytes)
- char con[]; /* Return 'nbytes' of chars here. */
- long int value; /* The value of the bits. */
- int nbytes; /* Number of bytes in the output. */
-{
- md_number_to_chars(con, value, nbytes);
-}
-#endif /* comment */
-
-void
- md_apply_fix(fixP, val)
-fixS *fixP;
-long val;
-{
- char *place = fixP->fx_where + fixP->fx_frag->fr_literal;
- md_number_to_chars(place, val, fixP->fx_size);
- return;
-} /* md_apply_fix() */
-
-void /* Knows about order of bytes in address. */
-md_number_to_disp (con, value, nbytes)
- char con[]; /* Return 'nbytes' of chars here. */
- long int value; /* The value of the bits. */
- int nbytes; /* Number of bytes in the output. */
-{
- md_number_to_chars(con, value, nbytes);
-}
-
-void /* Knows about order of bytes in address. */
-md_number_to_field (con, value, nbytes)
- char con[]; /* Return 'nbytes' of chars here. */
- long int value; /* The value of the bits. */
- int nbytes; /* Number of bytes in the output. */
-{
- md_number_to_chars(con, value, nbytes);
-}
-
-/* Put the bits in an order that a tahoe will understand, despite the ordering
- of the native machine.
- On Tahoe: first 4 bytes are normal unsigned big endian long,
- next three bytes are symbolnum, in kind of 3 byte big endian (least sig. byte last).
- The last byte is broken up with bit 7 as pcrel,
- bits 6 & 5 as length,
- bit 4 as extern and the last nibble as 'undefined'. */
-
-#if comment
-void
-md_ri_to_chars (ri_p, ri)
- struct relocation_info *ri_p, ri;
-{
- byte the_bytes[sizeof(struct relocation_info)];
- /* The reason I can't just encode these directly into ri_p is that
- ri_p may point to ri. */
-
- /* This is easy */
- md_number_to_chars (the_bytes, ri.r_address, sizeof(ri.r_address));
-
- /* now the fun stuff */
- the_bytes[4] = (ri.r_symbolnum >> 16) & 0x0ff;
- the_bytes[5] = (ri.r_symbolnum >> 8) & 0x0ff;
- the_bytes[6] = ri.r_symbolnum & 0x0ff;
- the_bytes[7] = (((ri.r_extern << 4) & 0x10) | ((ri.r_length << 5) & 0x60) |
- ((ri.r_pcrel << 7) & 0x80)) & 0xf0;
-
- bcopy (the_bytes, (char *) ri_p, sizeof (struct relocation_info));
-}
-#endif /* comment */
-
-/* Put the bits in an order that a tahoe will understand, despite the ordering
- of the native machine.
- On Tahoe: first 4 bytes are normal unsigned big endian long,
- next three bytes are symbolnum, in kind of 3 byte big endian (least sig. byte last).
- The last byte is broken up with bit 7 as pcrel,
- bits 6 & 5 as length,
- bit 4 as extern and the last nibble as 'undefined'. */
-
-void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
-char *where;
-fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- /*
- * In: length of relocation (or of address) in chars: 1, 2 or 4.
- * Out: GNU LD relocation length code: 0, 1, or 2.
- */
-
- static unsigned char nbytes_r_length[] = { 42, 0, 1, 42, 2 };
- long r_symbolnum;
-
- know(fixP->fx_addsy != NULL);
-
- md_number_to_chars(where,
- fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
- 4);
-
- r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
- ? S_GET_TYPE(fixP->fx_addsy)
- : fixP->fx_addsy->sy_number);
-
- where[4] = (r_symbolnum >> 16) & 0x0ff;
- where[5] = (r_symbolnum >> 8) & 0x0ff;
- where[6] = r_symbolnum & 0x0ff;
- where[7] = (((fixP->fx_pcrel << 7) & 0x80)
- | ((nbytes_r_length[fixP->fx_size] << 5) & 0x60)
- | ((!S_IS_DEFINED(fixP->fx_addsy) << 4) & 0x10));
-
- return;
-} /* tc_aout_fix_to_chars() */
-
-/* Relocate byte stuff */
-
-/* This is for broken word. */
-const int md_short_jump_size = 3;
-
-void
-md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
- char *ptr;
- long from_addr, to_addr;
- fragS *frag;
- symbolS *to_symbol;
-{
- long offset;
-
- offset = to_addr - (from_addr + 1);
- *ptr++ = TAHOE_BRW;
- md_number_to_chars (ptr, offset, 2);
-}
-
-const int md_long_jump_size = 6;
-const int md_reloc_size = 8; /* Size of relocation record */
-
-void
-md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
- char *ptr;
- long from_addr, to_addr;
- fragS *frag;
- symbolS *to_symbol;
-{
- long offset;
-
- offset = to_addr - (from_addr + 4);
- *ptr++ = TAHOE_JMP;
- *ptr++ = TAHOE_PC_REL_LONG;
- md_number_to_chars (ptr, offset, 4);
-}
-
-/*
- * md_estimate_size_before_relax()
- *
- * Called just before relax().
- * Any symbol that is now undefined will not become defined, so we assumed
- * that it will be resolved by the linker.
- * Return the correct fr_subtype in the frag, for relax()
- * Return the initial "guess for fr_var" to caller. (How big I think this
- * will be.)
- * The guess for fr_var is ACTUALLY the growth beyond fr_fix.
- * Whatever we do to grow fr_fix or fr_var contributes to our returned value.
- * Although it may not be explicit in the frag, pretend fr_var starts with a
- * 0 value.
- */
-int
-md_estimate_size_before_relax (fragP, segment_type)
- register fragS *fragP;
- segT segment_type; /* N_DATA or N_TEXT. */
-{
- register char *p;
- register int old_fr_fix;
-/* int pc_rel; FIXME: remove this */
-
- old_fr_fix = fragP->fr_fix;
- switch (fragP->fr_subtype){
- case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_UNDF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment_type) {
- /* The symbol was in the same segment as the opcode, and it's
- a real pc_rel case so it's a relaxable case. */
- fragP->fr_subtype = ENCODE_RELAX(STATE_PC_RELATIVE, STATE_BYTE);
- }else{
- /* This case is still undefined, so asume it's a long word for the
- linker to fix. */
- p = fragP->fr_literal + old_fr_fix;
- *p |= TAHOE_PC_OR_LONG;
- /* We now know how big it will be, one long word. */
- fragP->fr_fix += 1 + 4;
- fix_new (fragP, old_fr_fix + 1, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 1, NO_RELOC);
- frag_wane (fragP);
- }
- break;
-
- case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment_type){
- fragP->fr_subtype = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE);
- }else{
- p = fragP->fr_literal + old_fr_fix;
- *fragP->fr_opcode ^= 0x10; /* Reverse sense of branch. */
- *p++ = 6;
- *p++ = TAHOE_JMP;
- *p++ = TAHOE_PC_REL_LONG;
- fragP->fr_fix += 1 + 1 + 1 + 4;
- fix_new (fragP, old_fr_fix + 3, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 1, NO_RELOC);
- frag_wane (fragP);
- }
- break;
-
- case ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_UNDF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment_type){
- fragP->fr_subtype =
- ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_WORD);
- }else{
- p = fragP->fr_literal + old_fr_fix;
- *fragP->fr_opcode ^= 0x10; /* Reverse sense of branch. */
- *p++ = 0;
- *p++ = 6;
- *p++ = TAHOE_JMP;
- *p++ = TAHOE_PC_REL_LONG;
- fragP->fr_fix += 2 + 2 + 4;
- fix_new (fragP, old_fr_fix + 4, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 1, NO_RELOC);
- frag_wane (fragP);
- }
- break;
-
- case ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_UNDF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment_type){
- fragP->fr_subtype = ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_WORD);
- }else{
- p = fragP->fr_literal + old_fr_fix;
- *p++ = 2;
- *p++ = 0;
- *p++ = TAHOE_BRB;
- *p++ = 6;
- *p++ = TAHOE_JMP;
- *p++ = TAHOE_PC_REL_LONG;
- fragP->fr_fix += 2 + 2 + 2 + 4;
- fix_new (fragP, old_fr_fix + 6, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 1, NO_RELOC);
- frag_wane (fragP);
- }
- break;
-
- case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_UNDF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment_type){
- fragP->fr_subtype = ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE);
- }else{
- p = fragP->fr_literal + old_fr_fix;
- *fragP->fr_opcode = TAHOE_JMP;
- *p++ = TAHOE_PC_REL_LONG;
- fragP->fr_fix += 1 + 4;
- fix_new (fragP, old_fr_fix + 1, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 1, NO_RELOC);
- frag_wane (fragP);
- }
- break;
-
- default:
- break;
- }
- return (fragP->fr_var + fragP->fr_fix - old_fr_fix);
-} /* md_estimate_size_before_relax() */
-
-/*
- * md_convert_frag();
- *
- * Called after relax() is finished.
- * In: Address of frag.
- * fr_type == rs_machine_dependent.
- * fr_subtype is what the address relaxed to.
- *
- * Out: Any fixSs and constants are set up.
- * Caller will turn frag into a ".space 0".
- */
-void
-md_convert_frag (headers, fragP)
-object_headers *headers;
- register fragS *fragP;
-{
- register char *addressP; /* -> _var to change. */
- register char *opcodeP; /* -> opcode char(s) to change. */
- register short int length_code; /* 2=long 1=word 0=byte */
- register short int extension = 0; /* Size of relaxed address.
- Added to fr_fix: incl. ALL var chars. */
- register symbolS *symbolP;
- register long int where;
- register long int address_of_var;
- /* Where, in file space, is _var of *fragP? */
- register long int target_address;
- /* Where, in file space, does addr point? */
-
- know (fragP->fr_type == rs_machine_dependent);
- length_code = RELAX_LENGTH(fragP->fr_subtype);
- know (length_code >= 0 && length_code < 3);
- where = fragP->fr_fix;
- addressP = fragP->fr_literal + where;
- opcodeP = fragP->fr_opcode;
- symbolP = fragP->fr_symbol;
- know(symbolP);
- target_address = S_GET_VALUE(symbolP) + fragP->fr_offset;
- address_of_var = fragP->fr_address + where;
- switch (fragP->fr_subtype){
- case ENCODE_RELAX(STATE_PC_RELATIVE, STATE_BYTE):
- /* *addressP holds the registers number, plus 0x10, if it's deferred
- mode. To set up the right mode, just OR the size of this displacement */
- /* Byte displacement. */
- *addressP++ |= TAHOE_PC_OR_BYTE;
- *addressP = target_address - (address_of_var + 2);
- extension = 2;
- break;
-
- case ENCODE_RELAX(STATE_PC_RELATIVE, STATE_WORD):
- /* Word displacement. */
- *addressP++ |= TAHOE_PC_OR_WORD;
- md_number_to_chars(addressP, target_address - (address_of_var + 3), 2);
- extension = 3;
- break;
-
- case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_LONG):
- /* Long word displacement. */
- *addressP++ |= TAHOE_PC_OR_LONG;
- md_number_to_chars(addressP, target_address - (address_of_var + 5), 4);
- extension = 5;
- break;
-
- case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE):
- *addressP = target_address - (address_of_var + 1);
- extension = 1;
- break;
-
- case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_WORD):
- *opcodeP ^= 0x10; /* Reverse sense of test. */
- *addressP++ = 3; /* Jump over word branch */
- *addressP++ = TAHOE_BRW;
- md_number_to_chars (addressP, target_address - (address_of_var + 4), 2);
- extension = 4;
- break;
-
- case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_LONG):
- *opcodeP ^= 0x10; /* Reverse sense of test. */
- *addressP++ = 6;
- *addressP++ = TAHOE_JMP;
- *addressP++ = TAHOE_PC_REL_LONG;
- md_number_to_chars (addressP, target_address, 4);
- extension = 7;
- break;
-
- case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE):
- *addressP = target_address - (address_of_var + 1);
- extension = 1;
- break;
-
- case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_WORD):
- *opcodeP = TAHOE_BRW;
- md_number_to_chars (addressP, target_address - (address_of_var + 2), 2);
- extension = 2;
- break;
-
- case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_LONG):
- *opcodeP = TAHOE_JMP;
- *addressP++ = TAHOE_PC_REL_LONG;
- md_number_to_chars(addressP, target_address - (address_of_var + 5), 4);
- extension = 5;
- break;
-
- case ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_WORD):
- md_number_to_chars (addressP, target_address - (address_of_var + 2), 2);
- extension = 2;
- break;
-
- case ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_LONG):
- *opcodeP ^= 0x10;
- *addressP++ = 0;
- *addressP++ = 6;
- *addressP++ = TAHOE_JMP;
- *addressP++ = TAHOE_PC_REL_LONG;
- md_number_to_chars (addressP, target_address, 4);
- extension = 8;
- break;
-
- case ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_WORD):
- md_number_to_chars (addressP, target_address - (address_of_var + 2), 2);
- extension = 2;
- break;
-
- case ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_LONG):
- *addressP++ = 0;
- *addressP++ = 2;
- *addressP++ = TAHOE_BRB;
- *addressP++ = 6;
- *addressP++ = TAHOE_JMP;
- *addressP++ = TAHOE_PC_REL_LONG;
- md_number_to_chars (addressP, target_address, 4);
- extension = 10;
- break;
-
- default:
- BAD_CASE (fragP->fr_subtype);
- break;
- }
- fragP->fr_fix += extension;
-} /* md_convert_frag */
-
-
-/* This is the stuff for md_assemble. */
-#define FP_REG 13
-#define SP_REG 14
-#define PC_REG 15
-#define BIGGESTREG PC_REG
-
-/*
- * Parse the string pointed to by START
- * If it represents a valid register, point START to the character after
- * the last valid register char, and return the register number (0-15).
- * If invalid, leave START alone, return -1.
- * The format has to be exact. I don't do things like eat leading zeros
- * or the like.
- * Note: This doesn't check for the next character in the string making
- * this invalid. Ex: R123 would return 12, it's the callers job to check
- * what start is point to apon return.
- *
- * Valid registers are R1-R15, %1-%15, FP (13), SP (14), PC (15)
- * Case doesn't matter.
- */
-int
-tahoe_reg_parse(start)
- char **start; /* A pointer to the string to parse. */
-{
- register char *regpoint = *start;
- register int regnum = -1;
-
- switch(*regpoint++){
- case '%': /* Registers can start with a %,
- R or r, and then a number. */
- case 'R':
- case 'r':
- if (isdigit(*regpoint)){
- /* Got the first digit. */
- regnum = *regpoint++ - '0';
- if ((regnum == 1) && isdigit(*regpoint)){
- /* Its a two digit number. */
- regnum = 10 + (*regpoint++ - '0');
- if (regnum > BIGGESTREG){ /* Number too big? */
- regnum = -1;
- }
- }
- }
- break;
- case 'F': /* Is it the FP */
- case 'f':
- switch(*regpoint++){
- case 'p':
- case 'P':
- regnum = FP_REG;
- }
- break;
- case 's': /* How about the SP */
- case 'S':
- switch(*regpoint++){
- case 'p':
- case 'P':
- regnum = SP_REG;
- }
- break;
- case 'p': /* OR the PC even */
- case 'P':
- switch(*regpoint++){
- case 'c':
- case 'C':
- regnum = PC_REG;
- }
- break;
- }
-
- if (regnum != -1){ /* No error, so move string pointer */
- *start = regpoint;
- }
- return regnum; /* Return results */
-} /* tahoe_reg_parse */
-
-/*
- * This chops up an operand and figures out its modes and stuff.
- * It's a little touchy about extra characters.
- * Optex to start with one extra character so it can be overwritten for
- * the backward part of the parsing.
- * You can't put a bunch of extra characters in side to
- * make the command look cute. ie: * foo ( r1 ) [ r0 ]
- * If you like doing a lot of typing, try COBOL!
- * Actually, this parser is a little weak all around. It's designed to be
- * used with compliers, so I emphisise correct decoding of valid code quickly
- * rather that catching every possable error.
- * Note: This uses the expression function, so save input_line_pointer before
- * calling.
- *
- * Sperry defines the semantics of address modes (and values)
- * by a two-letter code, explained here.
- *
- * letter 1: access type
- *
- * a address calculation - no data access, registers forbidden
- * b branch displacement
- * m read - let go of bus - write back "modify"
- * r read
- * w write
- * v bit field address: like 'a' but registers are OK
- *
- * letter 2: data type (i.e. width, alignment)
- *
- * b byte
- * w word
- * l longword
- * q quadword (Even regs < 14 allowed) (if 12, you get a warning)
- * - unconditional synthetic jbr operand
- * ? simple synthetic reversable branch operand
- * ! complex synthetic reversable branch operand
- * : complex synthetic non-reversable branch operand
- *
- * The '-?!:' letter 2's are not for external consumption. They are used
- * by GAS for psuedo ops relaxing code.
- *
- * After parsing topP has:
- *
- * top_ndx: -1, or the index register. eg 7=[R7]
- * top_reg: -1, or register number. eg 7 = R7 or (R7)
- * top_mode: The addressing mode byte. This byte, defines which of
- * the 11 modes opcode is.
- * top_access: Access type wanted for this opperand 'b'branch ' '
- * no-instruction 'amrvw'
- * top_width: Operand width expected, one of "bwlq?-:!"
- * exp_of_operand: The expression as parsed by expression()
- * top_dispsize: Number of bytes in the displacement if we can figure it
- * out and it's relavent.
- *
- * Need syntax checks built.
- */
-
-void
-tip_op (optex,topP)
- char *optex; /* The users text input, with one leading character */
- struct top *topP;/* The tahoe instruction with some fields already set:
- in: access, width
- out: ndx, reg, mode, error, dispsize */
-
-{
- int mode = 0; /* This operand's mode. */
- char segfault = *optex; /* To keep the back parsing from freaking. */
- char *point = optex+1; /* Parsing from front to back. */
- char *end; /* Parsing from back to front. */
- int reg = -1; /* major register, -1 means absent */
- int imreg = -1; /* Major register in immediate mode */
- int ndx = -1; /* index register number, -1 means absent */
- char dec_inc = ' '; /* Is the SP auto-incremented '+' or
- auto-decremented '-' or neither ' '. */
- int immediate = 0; /* 1 if '$' immediate mode */
- int call_width = 0; /* If the caller casts the displacement */
- int abs_width = 0; /* The width of the absolute displacment */
- int com_width = 0; /* Displacement width required by branch */
- int deferred = 0; /* 1 if '*' deferral is used */
- byte disp_size = 0; /* How big is this operand. 0 == don't know */
- char *op_bad = ""; /* Bad operand error */
-
- char *tp, *temp, c; /* Temporary holders */
-
- char access = topP->top_access; /* Save on a deref. */
- char width = topP->top_width;
-
- int really_none = 0; /* Empty expressions evaluate to 0
- but I need to know if it's there or not */
- expressionS *expP; /* -> expression values for this operand */
-
- /* Does this command restrict the displacement size. */
- if (access == 'b')
- com_width = (width == 'b' ? 1 :
- (width == 'w' ? 2 :
- (width == 'l' ? 4 : 0)));
-
- *optex = '\0'; /* This is kind of a back stop for all
- the searches to fail on if needed.*/
- if (*point == '*') { /* A dereference? */
- deferred = 1;
- point++;
- }
-
- /* Force words into a certain mode */
- /* Bitch, Bitch, Bitch! */
- /*
- * Using the ^ operator is ambigous. If I have an absolute label
- * called 'w' set to, say 2, and I have the expression 'w^1', do I get
- * 1, forced to be in word displacement mode, or do I get the value of
- * 'w' or'ed with 1 (3 in this case).
- * The default is 'w' as an offset, so that's what I use.
- * Stick with `, it does the same, and isn't ambig.
- */
-
- if (*point != '\0' && ((point[1] == '^') || (point[1] == '`')))
- switch(*point){
- case 'b':
- case 'B':
- case 'w':
- case 'W':
- case 'l':
- case 'L':
- if (com_width)
- as_warn("Casting a branch displacement is bad form, and is ignored.");
- else{
- c = (isupper(*point) ? tolower(*point) : *point);
- call_width = ((c == 'b') ? 1 :
- ((c == 'w') ? 2 : 4));
- }
- point += 2;
- break;
- }
-
- /* Setting immediate mode */
- if (*point == '$'){
- immediate = 1;
- point++;
- }
-
- /*
- * I've pulled off all the easy stuff off the front, move to the end and
- * yank.
- */
-
- for(end = point;*end != '\0';end++) /* Move to the end. */
- ;
-
- if(end != point) /* Null string? */
- end--;
-
- if (end > point && *end == ' ' && end[-1] != '\'')
- end--; /* Hop white space */
-
- /* Is this an index reg. */
- if ((*end == ']') && (end[-1] != '\'')){
- temp = end;
-
- /* Find opening brace. */
- for(--end;(*end != '[' && end != point);end--)
- ;
-
- /* If I found the opening brace, get the index register number. */
- if (*end == '['){
- tp = end + 1; /* tp should point to the start of a reg. */
- ndx = tahoe_reg_parse(&tp);
- if (tp != temp){ /* Reg. parse error. */
- ndx = -1;
- } else {
- end--; /* Found it, move past brace. */
- }
- if (ndx == -1){
- op_bad = "Couldn't parse the [index] in this operand.";
- end = point; /* Force all the rest of the tests to fail. */
- }
- }else{
- op_bad = "Couldn't find the opening '[' for the index of this operand.";
- end = point; /* Force all the rest of the tests to fail. */
- }
- }
-
- /* Post increment? */
- if (*end == '+'){
- dec_inc = '+';
-/* was: *end--; */
- end--;
- }
-
- /* register in parens? */
- if ((*end == ')') && (end[-1] != '\'')){
- temp = end;
-
- /* Find opening paren. */
- for(--end;(*end != '(' && end != point);end--)
- ;
-
- /* If I found the opening paren, get the register number. */
- if (*end == '('){
- tp = end + 1;
- reg = tahoe_reg_parse(&tp);
- if (tp != temp){
- /* Not a register, but could be part of the expression. */
- reg = -1;
- end = temp; /* Rest the pointer back */
- } else {
- end--; /* Found the reg. move before opening paren. */
- }
- }else{
- op_bad = "Couldn't find the opening '(' for the deref of this operand.";
- end = point; /* Force all the rest of the tests to fail. */
- }
- }
-
- /* Pre decrement? */
- if (*end == '-'){
- if (dec_inc != ' '){
- op_bad = "Operand can't be both pre-inc and post-dec.";
- end = point;
- }else{
- dec_inc = '-';
-/* was: *end--; */
- end--;
- }
- }
-
- /*
- * Everything between point and end is the 'expression', unless it's
- * a register name.
- */
-
- c = end[1];
- end[1] = '\0';
-
- tp = point;
- imreg = tahoe_reg_parse(&point); /* Get the immediate register
- if it is there.*/
- if (*point != '\0'){
- /* If there is junk after point, then the it's not immediate reg. */
- point = tp;
- imreg = -1;
- }
-
- if (imreg != -1 && reg != -1)
- op_bad = "I parsed 2 registers in this operand.";
-
- /*
- * Evaluate whats left of the expression to see if it's valid.
- * Note again: This assumes that the calling expression has saved
- * input_line_pointer. (Nag, nag, nag!)
- */
-
- if (*op_bad == '\0'){
- /* statement has no syntax goofs yet: lets sniff the expression */
- input_line_pointer = point;
- expP = &(topP->exp_of_operand);
- switch (expression (expP)){
- /* If expression == SEG_PASS1, expression() will have set
- need_pass_2 = 1. */
- case SEG_ABSENT:
- /* No expression. For BSD4.2 compatibility, missing expression is
- absolute 0 */
- expP->X_seg = SEG_ABSOLUTE;
- expP->X_add_number = 0;
- really_none = 1;
- case SEG_ABSOLUTE:
- /* for SEG_ABSOLUTE, we shouldnt need to set X_subtract_symbol,
- X_add_symbol to any particular value. */
- /* But, we will program defensively. Since this situation occurs
- rarely so it costs us little to do so. */
- expP->X_add_symbol = NULL;
- expP->X_subtract_symbol = NULL;
- /* How many bytes are needed to express this abs value? */
- abs_width =
- ((((expP->X_add_number & 0xFFFFFF80) == 0) ||
- ((expP->X_add_number & 0xFFFFFF80) == 0xFFFFFF80)) ? 1 :
- (((expP->X_add_number & 0xFFFF8000) == 0) ||
- ((expP->X_add_number & 0xFFFF8000) == 0xFFFF8000)) ? 2 : 4);
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_UNKNOWN:
- break;
-
- case SEG_DIFFERENCE:
- /*
- * Major bug. We can't handle the case of a
- * SEG_DIFFERENCE expression in a synthetic opcode
- * variable-length instruction.
- * We don't have a frag type that is smart enough to
- * relax a SEG_DIFFERENCE, and so we just force all
- * SEG_DIFFERENCEs to behave like SEG_PASS1s.
- * Clearly, if there is a demand we can invent a new or
- * modified frag type and then coding up a frag for this
- * case will be easy. SEG_DIFFERENCE was invented for the
- * .words after a CASE opcode, and was never intended for
- * instruction operands.
- */
- need_pass_2 = 1;
- case SEG_PASS1:
- op_bad = "Can't relocate expression error.";
- break;
-
- case SEG_BIG:
- /* This is an error. Tahoe doesn't allow any expressions
- bigger that a 32 bit long word. Any bigger has to be referenced
- by address. */
- op_bad = "Expression is too large for a 32 bits.";
- break;
-
- default:
- as_fatal("Complier Bug: I got segment %d in tip_op.",expP->X_seg);
- break;
- }
- if (*input_line_pointer != '\0'){
- op_bad = "Junk at end of expression.";
- }
- }
-
- end[1] = c;
-
- /* I'm done, so restore optex */
- *optex = segfault;
-
-
- /*
- * At this point in the game, we (in theory) have all the components of
- * the operand at least parsed. Now it's time to check for syntax/semantic
- * errors, and build the mode.
- * This is what I have:
- * deferred = 1 if '*'
- * call_width = 0,1,2,4
- * abs_width = 0,1,2,4
- * com_width = 0,1,2,4
- * immediate = 1 if '$'
- * ndx = -1 or reg num
- * dec_inc = '-' or '+' or ' '
- * reg = -1 or reg num
- * imreg = -1 or reg num
- * topP->exp_of_operand
- * really_none
- */
- /* Is there a displacement size? */
- disp_size = (call_width ? call_width :
- (com_width ? com_width :
- abs_width ? abs_width : 0));
-
- if (*op_bad == '\0'){
- if (imreg != -1){
- /* Rn */
- mode = TAHOE_DIRECT_REG;
- if (deferred || immediate || (dec_inc != ' ') ||
- (reg != -1) || !really_none)
- op_bad = "Syntax error in direct register mode.";
- else if (ndx != -1)
- op_bad = "You can't index a register in direct register mode.";
- else if (imreg == SP_REG && access == 'r')
- op_bad =
- "SP can't be the source operand with direct register addressing.";
- else if (access == 'a')
- op_bad = "Can't take the address of a register.";
- else if (access == 'b')
- op_bad = "Direct Register can't be used in a branch.";
- else if (width == 'q' && ((imreg % 2) || (imreg > 13)))
- op_bad = "For quad access, the register must be even and < 14.";
- else if (call_width)
- op_bad = "You can't cast a direct register.";
-
- if (*op_bad == '\0'){
- /* No errors, check for warnings */
- if (width == 'q' && imreg == 12)
- as_warn("Using reg 14 for quadwords can tromp the FP register.");
-
- reg = imreg;
- }
-
- /* We know: imm = -1 */
- }else if (dec_inc == '-'){
- /* -(SP) */
- mode = TAHOE_AUTO_DEC;
- if (deferred || immediate || !really_none)
- op_bad = "Syntax error in auto-dec mode.";
- else if (ndx != -1)
- op_bad = "You can't have an index auto dec mode.";
- else if (access == 'r')
- op_bad = "Auto dec mode cant be used for reading.";
- else if (reg != SP_REG)
- op_bad = "Auto dec only works of the SP register.";
- else if (access == 'b')
- op_bad = "Auto dec can't be used in a branch.";
- else if (width == 'q')
- op_bad = "Auto dec won't work with quadwords.";
-
- /* We know: imm = -1, dec_inc != '-' */
- }else if (dec_inc == '+'){
- if (immediate || !really_none)
- op_bad = "Syntax error in one of the auto-inc modes.";
- else if (deferred){
- /* *(SP)+ */
- mode = TAHOE_AUTO_INC_DEFERRED;
- if (reg != SP_REG)
- op_bad = "Auto inc deferred only works of the SP register.";
- else if (ndx != -1)
- op_bad = "You can't have an index auto inc deferred mode.";
- else if (access == 'b')
- op_bad = "Auto inc can't be used in a branch.";
- }else{
- /* (SP)+ */
- mode = TAHOE_AUTO_INC;
- if (access == 'm' || access == 'w')
- op_bad = "You can't write to an auto inc register.";
- else if (reg != SP_REG)
- op_bad = "Auto inc only works of the SP register.";
- else if (access == 'b')
- op_bad = "Auto inc can't be used in a branch.";
- else if (width == 'q')
- op_bad = "Auto inc won't work with quadwords.";
- else if (ndx != -1)
- op_bad = "You can't have an index in auto inc mode.";
- }
-
- /* We know: imm = -1, dec_inc == ' ' */
- }else if (reg != -1){
- if ((ndx != -1) && (reg == SP_REG))
- op_bad = "You can't index the sp register.";
- if (deferred){
- /* *<disp>(Rn) */
- mode = TAHOE_REG_DISP_DEFERRED;
- if (immediate)
- op_bad = "Syntax error in register displaced mode.";
- }else if (really_none){
- /* (Rn) */
- mode = TAHOE_REG_DEFERRED;
- /* if reg = SP then cant be indexed */
- }else{
- /* <disp>(Rn) */
- mode = TAHOE_REG_DISP;
- }
-
- /* We know: imm = -1, dec_inc == ' ', Reg = -1 */
- }else{
- if (really_none)
- op_bad = "An offest is needed for this operand.";
- if (deferred && immediate){
- /* *$<ADDR> */
- mode = TAHOE_ABSOLUTE_ADDR;
- disp_size = 4;
- }else if (immediate){
- /* $<disp> */
- mode = TAHOE_IMMEDIATE;
- if (ndx != -1)
- op_bad = "You can't index a register in immediate mode.";
- if (access == 'a')
- op_bad = "Immediate access can't be used as an address.";
- /* ponder the wisdom of a cast because it doesn't do any good. */
- }else if (deferred){
- /* *<disp> */
- mode = TAHOE_DISP_REL_DEFERRED;
- }else{
- /* <disp> */
- mode = TAHOE_DISPLACED_RELATIVE;
- }
- }
- }
-
- /*
- * At this point, all the errors we can do have be checked for.
- * We can build the 'top'. */
-
- topP->top_ndx = ndx;
- topP->top_reg = reg;
- topP->top_mode = mode;
- topP->top_error = op_bad;
- topP->top_dispsize = disp_size;
-} /* tip_op */
-
-/*
- * t i p ( )
- *
- * This converts a string into a tahoe instruction.
- * The string must be a bare single instruction in tahoe (with BSD4 frobs)
- * format.
- * It provides at most one fatal error message (which stops the scan)
- * some warning messages as it finds them.
- * The tahoe instruction is returned in exploded form.
- *
- * The exploded instruction is returned to a struct tit of your choice.
- * #include "tahoe-inst.h" to know what a struct tit is.
- *
- */
-
-static void
-tip (titP, instring)
- struct tit *titP; /* We build an exploded instruction here. */
- char *instring; /* Text of a vax instruction: we modify. */
-{
- register struct tot_wot *twP = NULL; /* How to bit-encode this opcode. */
- register char *p; /* 1/skip whitespace.2/scan vot_how */
- register char *q; /* */
- register unsigned char count; /* counts number of operands seen */
- register struct top *operandp;/* scan operands in struct tit */
- register char *alloperr = ""; /* error over all operands */
- register char c; /* Remember char, (we clobber it
- with '\0' temporarily). */
- char *save_input_line_pointer;
-
- if (*instring == ' ')
- ++instring; /* Skip leading whitespace. */
- for (p = instring; *p && *p != ' '; p++)
- ; /* MUST end in end-of-string or
- exactly 1 space. */
- /* Scanned up to end of operation-code. */
- /* Operation-code is ended with whitespace. */
- if (p == instring){
- titP->tit_error = "No operator";
- count = 0;
- titP->tit_opcode = 0;
- } else {
- c = *p;
- *p = '\0';
- /*
- * Here with instring pointing to what better be an op-name, and p
- * pointing to character just past that.
- * We trust instring points to an op-name, with no whitespace.
- */
- twP = (struct tot_wot *) hash_find(op_hash, instring);
- *p = c; /* Restore char after op-code. */
- if (twP == 0){
- titP->tit_error = "Unknown operator";
- count = 0;
- titP->tit_opcode = 0;
- }else{
- /*
- * We found a match! So lets pick up as many operands as the
- * instruction wants, and even gripe if there are too many.
- * We expect comma to seperate each operand.
- * We let instring track the text, while p tracks a part of the
- * struct tot.
- */
-
- count = 0; /* no operands seen yet */
- instring = p+(*p!='\0'); /* point past the operation code */
- /* tip_op() screws with the input_line_pointer, so save it before
- I jump in */
- save_input_line_pointer = input_line_pointer;
- for (p = twP->args, operandp = titP->tit_operand;
- !*alloperr && *p;
- operandp++, p += 2){
- /*
- * Here to parse one operand. Leave instring pointing just
- * past any one ',' that marks the end of this operand.
- */
- if (!p[1])
- as_fatal("Compiler bug: ODD number of bytes in arg structure %s.",
- twP->args);
- else if (*instring){
- for (q = instring; (*q != ',' && *q != '\0'); q++){
- if (*q == '\'' && q[1] != '\0') /* Jump quoted characters */
- q++;
- }
- c = *q;
- /*
- * Q points to ',' or '\0' that ends argument. C is that
- * character.
- */
- *q = '\0';
- operandp->top_access = p[0];
- operandp->top_width = p[1];
- tip_op(instring-1, operandp);
- *q = c; /* Restore input text. */
- if (*(operandp->top_error)){
- alloperr = operandp->top_error;
- }
- instring = q + (c ? 1 : 0); /* next operand (if any) */
- count++; /* won another argument, may have an operr */
- }else
- alloperr = "Not enough operands";
- }
- /* Restore the pointer. */
- input_line_pointer = save_input_line_pointer;
-
- if (!*alloperr){
- if (*instring == ' ')
- instring++; /* Skip whitespace. */
- if (*instring)
- alloperr = "Too many operands";
- }
- titP->tit_error = alloperr;
- }
- }
-
- titP->tit_opcode = twP->code; /* The op-code. */
- titP->tit_operands = count;
-} /* tip */
-
-/* md_assemble() emit frags for 1 instruction */
-void
-md_assemble (instruction_string)
- char *instruction_string; /* A string: assemble 1 instruction. */
-{
- char *p;
- register struct top *operandP; /* An operand. Scans all operands. */
-/* char c_save; fixme: remove this line */ /* What used to live after an expression. */
-/* struct frag *fragP; fixme: remove this line */ /* Fragment of code we just made. */
-/* register struct top *end_operandP; fixme: remove this line */ /* -> slot just after last operand
- Limit of the for (each operand). */
- register expressionS *expP; /* -> expression values for this operand */
-
- /* These refer to an instruction operand expression. */
- segT to_seg; /* Target segment of the address. */
-
- register valueT this_add_number;
- register struct symbol *this_add_symbol; /* +ve (minuend) symbol. */
-
-/* tahoe_opcodeT opcode_as_number; fixme: remove this line */ /* The opcode as a number. */
- char *opcodeP; /* Where it is in a frag. */
-/* char *opmodeP; fixme: remove this line */ /* Where opcode type is, in a frag. */
-
- int dispsize; /* From top_dispsize: tahoe_operand_width
- (in bytes) */
- int is_undefined; /* 1 if operand expression's
- segment not known yet. */
- int pc_rel; /* Is this operand pc relative? */
-
- /* Decode the operand. */
- tip(&t, instruction_string);
-
- /*
- * Check to see if this operand decode properly.
- * Notice that we haven't made any frags yet.
- * If it goofed, then this instruction will wedge in any pass,
- * and we can safely flush it, without causing interpass symbol phase
- * errors. That is, without changing label values in different passes.
- */
- if (*t.tit_error){
- as_warn("Ignoring statement due to \"%s\"", t.tit_error);
- }else{
- /* We saw no errors in any operands - try to make frag(s) */
- /* Emit op-code. */
- /* Remember where it is, in case we want to modify the op-code later. */
- opcodeP = frag_more(1);
- *opcodeP = t.tit_opcode;
- /* Now do each operand. */
- for (operandP = t.tit_operand;
- operandP < t.tit_operand + t.tit_operands;
- operandP++){ /* for each operand */
- expP = &(operandP->exp_of_operand);
- if (operandP->top_ndx >= 0){
- /* Indexed addressing byte
- Legality of indexed mode already checked: it is OK */
- FRAG_APPEND_1_CHAR(0x40 + operandP->top_ndx);
- } /* if(top_ndx>=0) */
-
- /* Here to make main operand frag(s). */
- this_add_number = expP->X_add_number;
- this_add_symbol = expP->X_add_symbol;
- to_seg = expP->X_seg;
- know (to_seg == SEG_UNKNOWN||\
- to_seg == SEG_ABSOLUTE||\
- to_seg == SEG_DATA||\
- to_seg == SEG_TEXT||\
- to_seg == SEG_BSS);
- is_undefined = (to_seg == SEG_UNKNOWN);
- /* Do we know how big this opperand is? */
- dispsize = operandP->top_dispsize;
- pc_rel = 0;
- /* Deal with the branch possabilities. (Note, this doesn't include
- jumps.)*/
- if (operandP->top_access == 'b'){
- /* Branches must be expressions. A psuedo branch can also jump to
- an absolute address. */
- if (to_seg == now_seg || is_undefined){
- /* If is_undefined, then it might BECOME now_seg by relax time. */
- if (dispsize){
- /* I know how big the branch is supposed to be (it's a normal
- branch), so I set up the frag, and let GAS do the rest. */
- p = frag_more (dispsize);
- fix_new (frag_now, p - frag_now->fr_literal, dispsize,
- this_add_symbol, 0, this_add_number, 1, NO_RELOC);
- } else {
- /* (to_seg==now_seg || to_seg == SEG_UNKNOWN) && dispsize==0 */
- /* If we don't know how big it is, then its a synthetic branch,
- so we set up a simple relax state. */
- switch (operandP->top_width){
- case TAHOE_WIDTH_CONDITIONAL_JUMP:
- /* Simple (conditional) jump. I may have to reverse the
- condition of opcodeP, and then jump to my destination.
- I set 1 byte aside for the branch off set, and could need 6
- more bytes for the pc_rel jump */
- frag_var (rs_machine_dependent, 7, 1,
- ENCODE_RELAX (STATE_CONDITIONAL_BRANCH,
- is_undefined ? STATE_UNDF : STATE_BYTE),
- this_add_symbol, this_add_number, opcodeP);
- break;
- case TAHOE_WIDTH_ALWAYS_JUMP:
- /* Simple (unconditional) jump. I may have to convert this to
- a word branch, or an absolute jump. */
- frag_var (rs_machine_dependent, 5, 1,
- ENCODE_RELAX (STATE_ALWAYS_BRANCH,
- is_undefined ? STATE_UNDF : STATE_BYTE),
- this_add_symbol, this_add_number, opcodeP);
- break;
- /* The smallest size for the next 2 cases is word. */
- case TAHOE_WIDTH_BIG_REV_JUMP:
- frag_var (rs_machine_dependent, 8, 2,
- ENCODE_RELAX (STATE_BIG_REV_BRANCH,
- is_undefined ? STATE_UNDF : STATE_WORD),
- this_add_symbol, this_add_number,
- opcodeP);
- break;
- case TAHOE_WIDTH_BIG_NON_REV_JUMP:
- frag_var (rs_machine_dependent, 10, 2,
- ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH,
- is_undefined ? STATE_UNDF : STATE_WORD),
- this_add_symbol, this_add_number,
- opcodeP);
- break;
- default:
- as_fatal("Compliler bug: Got a case (%d) I wasn't expecting.",
- operandP->top_width);
- }
- }
- }else{
- /* to_seg != now_seg && to_seg != seg_unknown (still in branch)
- In other words, I'm jumping out of my segment so extend the
- branches to jumps, and let GAS fix them. */
-
- /* These are "branches" what will always be branches around a jump
- to the correct addresss in real life.
- If to_seg is SEG_ABSOLUTE, just encode the branch in,
- else let GAS fix the address. */
-
- switch (operandP->top_width){
- /* The theory:
- For SEG_ABSOLUTE, then mode is ABSOLUTE_ADDR, jump
- to that addresss (not pc_rel).
- For other segs, address is a long word PC rel jump. */
- case TAHOE_WIDTH_CONDITIONAL_JUMP:
- /* b<cond> */
- /* To reverse the condition in a TAHOE branch,
- complement bit 4 */
- *opcodeP ^= 0x10;
- p = frag_more (7);
- *p++ = 6;
- *p++ = TAHOE_JMP;
- *p++ = (operandP->top_mode ==
- TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR :
- TAHOE_PC_REL_LONG);
- fix_new (frag_now, p - frag_now->fr_literal, 4,
- this_add_symbol, 0, this_add_number,
- (to_seg != SEG_ABSOLUTE), NO_RELOC);
- /*
- * Now (eg) BLEQ 1f
- * JMP foo
- * 1:
- */
- break;
- case TAHOE_WIDTH_ALWAYS_JUMP:
- /* br, just turn it into a jump */
- *opcodeP = TAHOE_JMP;
- p = frag_more (5);
- *p++ = (operandP->top_mode ==
- TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR :
- TAHOE_PC_REL_LONG);
- fix_new (frag_now, p - frag_now->fr_literal, 4,
- this_add_symbol, 0, this_add_number,
- (to_seg != SEG_ABSOLUTE), NO_RELOC);
- /* Now (eg) JMP foo */
- break;
- case TAHOE_WIDTH_BIG_REV_JUMP:
- p = frag_more (8);
- *opcodeP ^= 0x10;
- *p++ = 0;
- *p++ = 6;
- *p++ = TAHOE_JMP;
- *p++ = (operandP->top_mode ==
- TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR :
- TAHOE_PC_REL_LONG);
- fix_new (frag_now, p - frag_now->fr_literal, 4,
- this_add_symbol, 0, this_add_number,
- (to_seg != SEG_ABSOLUTE), NO_RELOC);
- /*
- * Now (eg) ACBx 1f
- * JMP foo
- * 1:
- */
- break;
- case TAHOE_WIDTH_BIG_NON_REV_JUMP:
- p = frag_more (10);
- *p++ = 0;
- *p++ = 2;
- *p++ = TAHOE_BRB;
- *p++ = 6;
- *p++ = TAHOE_JMP;
- *p++ = (operandP->top_mode ==
- TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR :
- TAHOE_PC_REL_LONG);
- fix_new (frag_now, p - frag_now->fr_literal, 4,
- this_add_symbol, 0, this_add_number,
- (to_seg != SEG_ABSOLUTE), NO_RELOC);
- /*
- * Now (eg) xOBxxx 1f
- * BRB 2f
- * 1: JMP @#foo
- * 2:
- */
- break;
- case 'b':
- case 'w':
- as_warn("Real branch displacements must be expressions.");
- break;
- default:
- as_fatal("Complier error: I got an unknown synthetic branch :%c",
- operandP->top_width);
- break;
- }
- }
- }else{
- /* It ain't a branch operand. */
- switch (operandP->top_mode){
- /* Auto-foo access, only works for one reg (SP)
- so the only thing needed is the mode. */
- case TAHOE_AUTO_DEC:
- case TAHOE_AUTO_INC:
- case TAHOE_AUTO_INC_DEFERRED:
- FRAG_APPEND_1_CHAR(operandP->top_mode);
- break;
-
- /* Numbered Register only access. Only thing needed is the
- mode + Register number */
- case TAHOE_DIRECT_REG:
- case TAHOE_REG_DEFERRED:
- FRAG_APPEND_1_CHAR(operandP->top_mode + operandP->top_reg);
- break;
-
- /* An absolute address. It's size is always 5 bytes.
- (mode_type + 4 byte address). */
- case TAHOE_ABSOLUTE_ADDR:
- know((this_add_symbol == NULL));
- p = frag_more(5);
- *p = TAHOE_ABSOLUTE_ADDR;
- md_number_to_chars(p+1,this_add_number,4);
- break;
-
- /* Immediate data. If the size isn't known, then it's an address
- + and offset, which is 4 bytes big. */
- case TAHOE_IMMEDIATE:
- if (this_add_symbol != NULL){
- p = frag_more (5);
- *p++ = TAHOE_IMMEDIATE_LONGWORD;
- fix_new (frag_now, p - frag_now->fr_literal,
- 4, this_add_symbol,0,this_add_number,
- 0, NO_RELOC);
- }else{
- /* It's a integer, and I know it's size. */
- if ((unsigned) this_add_number < 0x40){
- /* Will it fit in a literal? */
- FRAG_APPEND_1_CHAR((byte) this_add_number);
- }else{
- p = frag_more(dispsize+1);
- switch(dispsize){
- case 1:
- *p++ = TAHOE_IMMEDIATE_BYTE;
- *p = (byte) this_add_number;
- break;
- case 2:
- *p++ = TAHOE_IMMEDIATE_WORD;
- md_number_to_chars(p,this_add_number,2);
- break;
- case 4:
- *p++ = TAHOE_IMMEDIATE_LONGWORD;
- md_number_to_chars(p,this_add_number,4);
- break;
- }
- }
- }
- break;
-
- /* Distance from the PC. If the size isn't known, we have to relax
- into it. The difference between this and disp(sp) is that
- this offset is pc_rel, and disp(sp) isn't.
- Note the drop through code. */
-
- case TAHOE_DISPLACED_RELATIVE:
- case TAHOE_DISP_REL_DEFERRED:
- operandP->top_reg = PC_REG;
- pc_rel = 1;
-
- /* Register, plus a displacement mode. Save the register number,
- and weather its deffered or not, and relax the size if it isn't
- known. */
- case TAHOE_REG_DISP:
- case TAHOE_REG_DISP_DEFERRED:
- if (operandP->top_mode == TAHOE_DISP_REL_DEFERRED ||
- operandP->top_mode == TAHOE_REG_DISP_DEFERRED)
- operandP->top_reg += 0x10; /* deffered mode is always 0x10 higher
- than it's non-deffered sibling. */
-
- /* Is this a value out of this segment?
- The first part of this conditional is a cludge to make gas
- produce the same output as 'as' when there is a lable, in
- the current segment, displaceing a register. It's strange,
- and no one in their right mind would do it, but it's easy
- to cludge. */
- if ((dispsize == 0 && !pc_rel) ||
- (to_seg != now_seg && !is_undefined && to_seg != SEG_ABSOLUTE))
- dispsize = 4;
-
- if (dispsize == 0){
- /*
- * We have a SEG_UNKNOWN symbol, or the size isn't cast.
- * It might turn out to be in the same segment as
- * the instruction, permitting relaxation.
- */
- p = frag_var(rs_machine_dependent, 5, 2,
- ENCODE_RELAX(STATE_PC_RELATIVE,
- is_undefined ? STATE_UNDF:STATE_BYTE),
- this_add_symbol, this_add_number,0);
- *p = operandP->top_reg;
- }else{
- /* Either this is an abs, or a cast. */
- p = frag_more (dispsize + 1);
- switch(dispsize){
- case 1:
- *p = TAHOE_PC_OR_BYTE + operandP->top_reg;
- break;
- case 2:
- *p = TAHOE_PC_OR_WORD + operandP->top_reg;
- break;
- case 4:
- *p = TAHOE_PC_OR_LONG + operandP->top_reg;
- break;
- };
- fix_new (frag_now, p + 1 - frag_now->fr_literal,
- dispsize, this_add_symbol,0,this_add_number,
- pc_rel, NO_RELOC);
- }
- break;
- default:
- as_fatal("Barf, bad mode %x\n",operandP->top_mode);
- }
- }
- } /* for(operandP) */
- } /* if(!need_pass_2 && !goofed) */
-} /* tahoe_assemble() */
-
-
-/* We have no need to default values of symbols. */
-
-/* ARGSUSED */
-symbolS *md_undefined_symbol(name)
-char *name;
-{
- return 0;
-} /* md_undefined_symbol() */
-
-/* Parse an operand that is machine-specific.
- We just return without modifying the expression if we have nothing
- to do. */
-
-/* ARGSUSED */
-void md_operand(expressionP)
-expressionS *expressionP;
-{
-} /* md_operand() */
-
-/* Round up a section size to the appropriate boundary. */
-long md_section_align(segment, size)
-segT segment;
-long size;
-{
- return((size + 7) & ~7); /* Round all sects to multiple of 8 */
-} /* md_section_align() */
-
-/* Exactly what point is a PC-relative offset relative TO?
- On the sparc, they're relative to the address of the offset, plus
- its size. This gets us to the following instruction.
- (??? Is this right? FIXME-SOON) */
-long md_pcrel_from(fixP)
-fixS *fixP;
-{
- return(fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address);
-} /* md_pcrel_from() */
-
-/* end of tc-tahoe.c */
diff --git a/gnu/usr.bin/as/config/tc-tahoe.h b/gnu/usr.bin/as/config/tc-tahoe.h
deleted file mode 100644
index 4593a76..0000000
--- a/gnu/usr.bin/as/config/tc-tahoe.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* This file is tc-tahoe.h
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define TC_TAHOE 1
-
-#define NO_LISTING
-
-#define tc_headers_hook(a) {;} /* don't need it. */
-#define tc_crawl_symbol_chain(a) {;} /* don't need it. */
-#define tc_aout_pre_write_hook(a) {;}
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-tahoe.h */
diff --git a/gnu/usr.bin/as/config/tc-vax.c b/gnu/usr.bin/as/config/tc-vax.c
deleted file mode 100644
index 2b1970a..0000000
--- a/gnu/usr.bin/as/config/tc-vax.c
+++ /dev/null
@@ -1,3073 +0,0 @@
-/* tc-vax.c - vax-specific -
- Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* JF I moved almost all the vax specific stuff into this one file 'cuz RMS
- seems to think its a good idea. I hope I managed to get all the VAX-isms */
-
-
-#include "as.h"
-
-#include "read.h"
-#include "vax-inst.h"
-#include "obstack.h" /* For FRAG_APPEND_1_CHAR macro in "frags.h" */
-
-/* These chars start a comment anywhere in a source file (except inside
- another comment */
-const char comment_chars[] = "#";
-
-/* These chars only start a comment at the beginning of a line. */
-/* Note that for the VAX the are the same as comment_chars above. */
-const char line_comment_chars[] = "#";
-
-/* Chars that can be used to separate mant from exp in floating point nums */
-const char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant */
-/* as in 0f123.456 */
-/* or 0H1.234E-12 (see exp chars above) */
-const char FLT_CHARS[] = "dDfFgGhH";
-
-/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
- changed in read.c. Ideally it shouldn't have to know about it at all,
- but nothing is ideal around here.
- */
-
-static expressionS /* Hold details of an operand expression */
- exp_of_operand[VIT_MAX_OPERANDS];
-
-static struct vit
- v; /* A vax instruction after decoding. */
-
-LITTLENUM_TYPE big_operand_bits[VIT_MAX_OPERANDS][SIZE_OF_LARGE_NUMBER];
-/* Hold details of big operands. */
-FLONUM_TYPE float_operand[VIT_MAX_OPERANDS];
-/* Above is made to point into */
-/* big_operand_bits by md_begin(). */
-
-/*
- * For VAX, relative addresses of "just the right length" are easy.
- * The branch displacement is always the last operand, even in
- * synthetic instructions.
- * For VAX, we encode the relax_substateTs (in e.g. fr_substate) as:
- *
- * 4 3 2 1 0 bit number
- * ---/ /--+-------+-------+-------+-------+-------+
- * | what state ? | how long ? |
- * ---/ /--+-------+-------+-------+-------+-------+
- *
- * The "how long" bits are 00=byte, 01=word, 10=long.
- * This is a Un*x convention.
- * Not all lengths are legit for a given value of (what state).
- * The "how long" refers merely to the displacement length.
- * The address usually has some constant bytes in it as well.
- *
-
- groups for VAX address relaxing.
-
- 1. "foo" pc-relative.
- length of byte, word, long
-
- 2a. J<cond> where <cond> is a simple flag test.
- length of byte, word, long.
- VAX opcodes are: (Hex)
- bneq/bnequ 12
- beql/beqlu 13
- bgtr 14
- bleq 15
- bgeq 18
- blss 19
- bgtru 1a
- blequ 1b
- bvc 1c
- bvs 1d
- bgequ/bcc 1e
- blssu/bcs 1f
- Always, you complement 0th bit to reverse condition.
- Always, 1-byte opcode, then 1-byte displacement.
-
- 2b. J<cond> where cond tests a memory bit.
- length of byte, word, long.
- Vax opcodes are: (Hex)
- bbs e0
- bbc e1
- bbss e2
- bbcs e3
- bbsc e4
- bbcc e5
- bbssi e6
- bbcci e7
- Always, you complement 0th bit to reverse condition.
- Always, 1-byte opcde, longword-address, byte-address, 1-byte-displacement
-
- 2c. J<cond> where cond tests low-order memory bit
- length of byte,word,long.
- Vax opcodes are: (Hex)
- blbs e8
- blbc e9
- Always, you complement 0th bit to reverse condition.
- Always, 1-byte opcode, longword-address, 1-byte displacement.
-
- 3. Jbs/Jbr.
- length of byte,word,long.
- Vax opcodes are: (Hex)
- bsbb 10
- brb 11
- These are like (2) but there is no condition to reverse.
- Always, 1 byte opcode, then displacement/absolute.
-
- 4a. JacbX
- length of word, long.
- Vax opcodes are: (Hex)
- acbw 3d
- acbf 4f
- acbd 6f
- abcb 9d
- acbl f1
- acbg 4ffd
- acbh 6ffd
- Always, we cannot reverse the sense of the branch; we have a word
- displacement.
- The double-byte op-codes don't hurt: we never want to modify the
- opcode, so we don't care how many bytes are between the opcode and
- the operand.
-
- 4b. JXobXXX
- length of long, long, byte.
- Vax opcodes are: (Hex)
- aoblss f2
- aobleq f3
- sobgeq f4
- sobgtr f5
- Always, we cannot reverse the sense of the branch; we have a byte
- displacement.
-
- The only time we need to modify the opcode is for class 2 instructions.
- After relax() we may complement the lowest order bit of such instruction
- to reverse sense of branch.
-
- For class 2 instructions, we store context of "where is the opcode literal".
- We can change an opcode's lowest order bit without breaking anything else.
-
- We sometimes store context in the operand literal. This way we can figure out
- after relax() what the original addressing mode was.
- */
-
-/* These displacements are relative to */
-/* the start address of the displacement. */
-/* The first letter is Byte, Word. */
-/* 2nd letter is Forward, Backward. */
-#define BF (1+ 127)
-#define BB (1+-128)
-#define WF (2+ 32767)
-#define WB (2+-32768)
-/* Dont need LF, LB because they always */
-/* reach. [They are coded as 0.] */
-
-
-#define C(a,b) ENCODE_RELAX(a,b)
-/* This macro has no side-effects. */
-#define ENCODE_RELAX(what,length) (((what) << 2) + (length))
-
-const relax_typeS
- md_relax_table[] =
-{
- { 1, 1, 0, 0 }, /* error sentinel 0,0 */
- { 1, 1, 0, 0 }, /* unused 0,1 */
- { 1, 1, 0, 0 }, /* unused 0,2 */
- { 1, 1, 0, 0 }, /* unused 0,3 */
- { BF + 1, BB + 1, 2, C(1, 1) }, /* B^"foo" 1,0 */
- { WF + 1, WB + 1, 3, C (1, 2) }, /* W^"foo" 1,1 */
- { 0, 0, 5, 0 }, /* L^"foo" 1,2 */
- { 1, 1, 0, 0 }, /* unused 1,3 */
- { BF, BB, 1, C(2, 1) }, /* b<cond> B^"foo" 2,0 */
- { WF + 2, WB + 2, 4, C (2, 2) }, /* br.+? brw X 2,1 */
- { 0, 0, 7, 0 }, /* br.+? jmp X 2,2 */
- { 1, 1, 0, 0 }, /* unused 2,3 */
- { BF, BB, 1, C (3, 1) }, /* brb B^foo 3,0 */
- { WF, WB, 2, C (3, 2) }, /* brw W^foo 3,1 */
- { 0, 0, 5, 0 }, /* Jmp L^foo 3,2 */
- { 1, 1, 0, 0 }, /* unused 3,3 */
- { 1, 1, 0, 0 }, /* unused 4,0 */
- { WF, WB, 2, C (4, 2) }, /* acb_ ^Wfoo 4,1 */
- { 0, 0, 10, 0 }, /* acb_,br,jmp L^foo4,2 */
- { 1, 1, 0, 0 }, /* unused 4,3 */
- { BF, BB, 1, C (5, 1) }, /* Xob___,,foo 5,0 */
- { WF + 4, WB + 4, 6, C (5, 2) }, /* Xob.+2,brb.+3,brw5,1 */
- { 0, 0, 9, 0 }, /* Xob.+2,brb.+6,jmp5,2 */
-};
-
-#undef C
-#undef BF
-#undef BB
-#undef WF
-#undef WB
-
-void float_cons ();
-
-const pseudo_typeS md_pseudo_table[] = {
- {"dfloat", float_cons, 'd'},
- {"ffloat", float_cons, 'f'},
- {"gfloat", float_cons, 'g'},
- {"hfloat", float_cons, 'h'},
- {0},
-};
-
-#define STATE_PC_RELATIVE (1)
-#define STATE_CONDITIONAL_BRANCH (2)
-#define STATE_ALWAYS_BRANCH (3) /* includes BSB... */
-#define STATE_COMPLEX_BRANCH (4)
-#define STATE_COMPLEX_HOP (5)
-
-#define STATE_BYTE (0)
-#define STATE_WORD (1)
-#define STATE_LONG (2)
-#define STATE_UNDF (3) /* Symbol undefined in pass1 */
-
-
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
-#if __STDC__ == 1
-
-int flonum_gen2vax(char format_letter, FLONUM_TYPE *f, LITTLENUM_TYPE *words);
-static void vip_end(void);
-static void vip_op_defaults(char *immediate, char *indirect, char *displen);
-
-#else /* not __STDC__ */
-
-int flonum_gen2vax();
-static void vip_end();
-static void vip_op_defaults();
-
-#endif /* not __STDC__ */
-
-void
- md_begin ()
-{
- char *vip_begin ();
- char *errtxt;
- FLONUM_TYPE *fP;
- int i;
-
- if (*(errtxt = vip_begin (1, "$", "*", "`"))) {
- as_fatal("VIP_BEGIN error:%s", errtxt);
- }
-
- for (i = 0, fP = float_operand;
- fP < float_operand + VIT_MAX_OPERANDS;
- i++, fP++) {
- fP->low = &big_operand_bits[i][0];
- fP->high = &big_operand_bits[i][SIZE_OF_LARGE_NUMBER - 1];
- }
-}
-
-void
- md_end ()
-{
- vip_end ();
-}
-
-void /* Knows about order of bytes in address. */
- md_number_to_chars(con, value, nbytes)
-char con[]; /* Return 'nbytes' of chars here. */
-long value; /* The value of the bits. */
-int nbytes; /* Number of bytes in the output. */
-{
- int n;
- long v;
-
- n = nbytes;
- v = value;
- while (nbytes--) {
- *con++ = value; /* Lint wants & MASK_CHAR. */
- value >>= BITS_PER_CHAR;
- }
- /* XXX line number probably botched for this warning message. */
- if (value != 0 && value != -1)
- as_bad("Displacement (%ld) long for instruction field length (%d).", v, n);
-}
-
-/* Fix up some data or instructions after we find out the value of a symbol
- that they reference. */
-
-void /* Knows about order of bytes in address. */
- md_apply_fix(fixP, value)
-fixS *fixP; /* Fixup struct pointer */
-long value; /* The value of the bits. */
-{
- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
- int nbytes; /* Number of bytes in the output. */
-
- nbytes = fixP->fx_size;
- while (nbytes--) {
- *buf++ = value; /* Lint wants & MASK_CHAR. */
- value >>= BITS_PER_CHAR;
- }
-}
-
-long /* Knows about the byte order in a word. */
- md_chars_to_number (con, nbytes)
-unsigned char con[]; /* Low order byte 1st. */
-int nbytes; /* Number of bytes in the input. */
-{
- long retval;
- for (retval = 0, con += nbytes - 1; nbytes--; con--) {
- retval <<= BITS_PER_CHAR;
- retval |= *con;
- }
- return retval;
-}
-
-/* vax:md_assemble() emit frags for 1 instruction */
-
-void
- md_assemble (instruction_string)
-char *instruction_string; /* A string: assemble 1 instruction. */
-{
- /* We saw no errors in any operands - try to make frag(s) */
- int is_undefined; /* 1 if operand expression's */
- /* segment not known yet. */
- int length_code;
-
- char *p;
- register struct vop *operandP;/* An operand. Scans all operands. */
- char *save_input_line_pointer;
- char c_save; /* What used to live after an expression. */
- /* fixme: unused? */
-/* struct frag *fragP; */ /* Fragment of code we just made. */
- register int goofed; /* 1: instruction_string bad for all passes. */
- register struct vop *end_operandP; /* -> slot just after last operand */
- /* Limit of the for (each operand). */
- register expressionS *expP; /* -> expression values for this operand */
-
- /* These refer to an instruction operand expression. */
- segT to_seg; /* Target segment of the address. */
- register valueT this_add_number;
- register struct symbol *this_add_symbol; /* +ve (minuend) symbol. */
- register struct symbol *this_subtract_symbol; /* -ve(subtrahend) symbol. */
-
- long opcode_as_number; /* As a number. */
- char *opcode_as_chars; /* Least significant byte 1st. */
- /* As an array of characters. */
- char *opcode_low_byteP; /* Least significant byte 1st */
- /* richfix: unused? */
-/* struct details *detP; */ /* The details of an ADxxx frag. */
- int length; /* length (bytes) meant by vop_short. */
- int at; /* 0, or 1 if '@' is in addressing mode. */
- int nbytes; /* From vop_nbytes: vax_operand_width (in bytes) */
- FLONUM_TYPE *floatP;
- char *vip ();
- LITTLENUM_TYPE literal_float[8];
- /* Big enough for any floating point literal. */
-
- if (*(p = vip (&v, instruction_string))) {
- as_fatal("vax_assemble\"%s\" in=\"%s\"", p, instruction_string);
- }
- /*
- * Now we try to find as many as_warn()s as we can. If we do any as_warn()s
- * then goofed=1. Notice that we don't make any frags yet.
- * Should goofed be 1, then this instruction will wedge in any pass,
- * and we can safely flush it, without causing interpass symbol phase
- * errors. That is, without changing label values in different passes.
- */
- if (goofed = (*v.vit_error)) {
- as_warn ("Ignoring statement due to \"%s\"", v.vit_error);
- }
- /*
- * We need to use expression() and friends, which require us to diddle
- * input_line_pointer. So we save it and restore it later.
- */
- save_input_line_pointer = input_line_pointer;
- for (operandP = v.vit_operand,
- expP = exp_of_operand,
- floatP = float_operand,
- end_operandP = v.vit_operand + v.vit_operands;
-
- operandP < end_operandP;
-
- operandP++, expP++, floatP++) { /* for each operand */
- if (*(operandP->vop_error)) {
- as_warn ("Ignoring statement because \"%s\"", (operandP->vop_error));
- goofed = 1;
- } else { /* statement has no syntax goofs: lets sniff the expression */
- int can_be_short = 0; /* 1 if a bignum can be reduced to a short literal. */
-
- input_line_pointer = operandP->vop_expr_begin;
- c_save = operandP->vop_expr_end[1];
- operandP->vop_expr_end[1] = '\0';
- /* If to_seg == SEG_PASS1, expression() will have set need_pass_2 = 1. */
- switch (to_seg = expression (expP)) {
- case SEG_ABSENT:
- /* for BSD4.2 compatibility, missing expression is absolute 0 */
- to_seg = expP->X_seg = SEG_ABSOLUTE;
- expP->X_add_number = 0;
- /* for SEG_ABSOLUTE, we shouldnt need to set X_subtract_symbol, X_add_symbol to any
- particular value. But, we will program defensively. Since this situation occurs rarely
- so it costs us little to do, and stops Dean worrying about the origin of random bits in
- expressionS's. */
- expP->X_add_symbol = NULL;
- expP->X_subtract_symbol = NULL;
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_ABSOLUTE:
- case SEG_UNKNOWN:
- break;
-
- case SEG_DIFFERENCE:
- case SEG_PASS1:
- /*
- * Major bug. We can't handle the case of a
- * SEG_DIFFERENCE expression in a VIT_OPCODE_SYNTHETIC
- * variable-length instruction.
- * We don't have a frag type that is smart enough to
- * relax a SEG_DIFFERENCE, and so we just force all
- * SEG_DIFFERENCEs to behave like SEG_PASS1s.
- * Clearly, if there is a demand we can invent a new or
- * modified frag type and then coding up a frag for this
- * case will be easy. SEG_DIFFERENCE was invented for the
- * .words after a CASE opcode, and was never intended for
- * instruction operands.
- */
- need_pass_2 = 1;
- as_warn("Can't relocate expression");
- break;
-
- case SEG_BIG:
- /* Preserve the bits. */
- if (expP->X_add_number > 0) {
- bignum_copy(generic_bignum, expP->X_add_number,
- floatP->low, SIZE_OF_LARGE_NUMBER);
- } else {
- know(expP->X_add_number < 0);
- flonum_copy (&generic_floating_point_number,
- floatP);
- if (strchr("s i", operandP->vop_short)) { /* Could possibly become S^# */
- flonum_gen2vax(-expP->X_add_number, floatP, literal_float);
- switch (-expP->X_add_number) {
- case 'f':
- can_be_short =
- (literal_float[0] & 0xFC0F) == 0x4000
- && literal_float[1] == 0;
- break;
-
- case 'd':
- can_be_short =
- (literal_float[0] & 0xFC0F) == 0x4000
- && literal_float[1] == 0
- && literal_float[2] == 0
- && literal_float[3] == 0;
- break;
-
- case 'g':
- can_be_short =
- (literal_float[0] & 0xFF81) == 0x4000
- && literal_float[1] == 0
- && literal_float[2] == 0
- && literal_float[3] == 0;
- break;
-
- case 'h':
- can_be_short = ((literal_float[0] & 0xFFF8) == 0x4000
- && (literal_float[1] & 0xE000) == 0
- && literal_float[2] == 0
- && literal_float[3] == 0
- && literal_float[4] == 0
- && literal_float[5] == 0
- && literal_float[6] == 0
- && literal_float[7] == 0);
- break;
-
- default:
- BAD_CASE(-expP->X_add_number);
- break;
- } /* switch (float type) */
- } /* if (could want to become S^#...) */
- } /* bignum or flonum ? */
-
- if (operandP->vop_short == 's'
- || operandP->vop_short == 'i'
- || (operandP->vop_short == ' '
- && operandP->vop_reg == 0xF
- && (operandP->vop_mode & 0xE) == 0x8)) {
- /* Saw a '#'. */
- if (operandP->vop_short == ' ') { /* We must chose S^ or I^. */
- if (expP->X_add_number > 0) { /* Bignum: Short literal impossible. */
- operandP->vop_short = 'i';
- operandP->vop_mode = 8;
- operandP->vop_reg = 0xF; /* VAX PC. */
- } else { /* Flonum: Try to do it. */
- if (can_be_short)
- {
- operandP->vop_short = 's';
- operandP->vop_mode = 0;
- operandP->vop_ndx = -1;
- operandP->vop_reg = -1;
- /* JF hope this is the right thing */
- expP->X_seg = SEG_ABSOLUTE;
- } else {
- operandP->vop_short = 'i';
- operandP->vop_mode = 8;
- operandP->vop_reg = 0xF; /* VAX PC */
- }
- } /* bignum or flonum ? */
- } /* if #, but no S^ or I^ seen. */
- /* No more ' ' case: either 's' or 'i'. */
- if (operandP->vop_short == 's') {
- /* Wants to be a short literal. */
- if (expP->X_add_number > 0) {
- as_warn ("Bignum not permitted in short literal. Immediate mode assumed.");
- operandP->vop_short = 'i';
- operandP->vop_mode = 8;
- operandP->vop_reg = 0xF; /* VAX PC. */
- } else {
- if (!can_be_short) {
- as_warn ("Can't do flonum short literal: immediate mode used.");
- operandP->vop_short = 'i';
- operandP->vop_mode = 8;
- operandP->vop_reg = 0xF; /* VAX PC. */
- } else { /* Encode short literal now. */
- int temp = 0;
-
- switch (-expP->X_add_number) {
- case 'f':
- case 'd':
- temp = literal_float[0] >> 4;
- break;
-
- case 'g':
- temp = literal_float[0] >> 1;
- break;
-
- case 'h':
- temp = ((literal_float[0] << 3) & 070)
- | ((literal_float[1] >> 13) & 07);
- break;
-
- default:
- BAD_CASE(-expP->X_add_number);
- break;
- }
-
- floatP->low[0] = temp & 077;
- floatP->low[1] = 0;
- } /* if can be short literal float */
- } /* flonum or bignum ? */
- } else { /* I^# seen: set it up if float. */
- if (expP->X_add_number < 0) {
- memcpy(floatP->low, literal_float, sizeof(literal_float));
- }
- } /* if S^# seen. */
- } else {
- as_warn ("A bignum/flonum may not be a displacement: 0x%x used",
- expP->X_add_number = 0x80000000);
- /* Chosen so luser gets the most offset bits to patch later. */
- }
- expP->X_add_number = floatP->low[0]
- | ((LITTLENUM_MASK & (floatP->low[1])) << LITTLENUM_NUMBER_OF_BITS);
- /*
- * For the SEG_BIG case we have:
- * If vop_short == 's' then a short floating literal is in the
- * lowest 6 bits of floatP->low [0], which is
- * big_operand_bits [---] [0].
- * If vop_short == 'i' then the appropriate number of elements
- * of big_operand_bits [---] [...] are set up with the correct
- * bits.
- * Also, just in case width is byte word or long, we copy the lowest
- * 32 bits of the number to X_add_number.
- */
- break;
-
- default:
- BAD_CASE (to_seg);
- break;
- }
- if (input_line_pointer != operandP->vop_expr_end + 1) {
- as_warn ("Junk at end of expression \"%s\"", input_line_pointer);
- goofed = 1;
- }
- operandP->vop_expr_end[1] = c_save;
- }
- } /* for (each operand) */
-
- input_line_pointer = save_input_line_pointer;
-
- if (need_pass_2 || goofed) {
- return;
- }
-
-
- /* Emit op-code. */
- /* Remember where it is, in case we want to modify the op-code later. */
- opcode_low_byteP = frag_more (v.vit_opcode_nbytes);
- memcpy(opcode_low_byteP, v.vit_opcode, v.vit_opcode_nbytes);
- opcode_as_number = md_chars_to_number (opcode_as_chars = v.vit_opcode, 4);
- for (operandP = v.vit_operand,
- expP = exp_of_operand,
- floatP = float_operand,
- end_operandP = v.vit_operand + v.vit_operands;
-
- operandP < end_operandP;
-
- operandP++,
- floatP++,
- expP++) { /* for each operand */
- if (operandP->vop_ndx >= 0) {
- /* indexed addressing byte */
- /* Legality of indexed mode already checked: it is OK */
- FRAG_APPEND_1_CHAR (0x40 + operandP->vop_ndx);
- } /* if (vop_ndx >= 0) */
-
- /* Here to make main operand frag(s). */
- this_add_number = expP->X_add_number;
- this_add_symbol = expP->X_add_symbol;
- this_subtract_symbol = expP->X_subtract_symbol;
- to_seg = expP->X_seg;
- is_undefined = (to_seg == SEG_UNKNOWN);
- know(to_seg == SEG_UNKNOWN
- || to_seg == SEG_ABSOLUTE
- || to_seg == SEG_DATA
- || to_seg == SEG_TEXT
- || to_seg == SEG_BSS
- || to_seg == SEG_BIG);
- at = operandP->vop_mode & 1;
- length = (operandP->vop_short == 'b'
- ? 1 : (operandP->vop_short == 'w'
- ? 2 : (operandP->vop_short == 'l'
- ? 4 : 0)));
- nbytes = operandP->vop_nbytes;
- if (operandP->vop_access == 'b') {
- if (to_seg == now_seg || is_undefined) {
- /* If is_undefined, then it might BECOME now_seg. */
- if (nbytes) {
- p = frag_more(nbytes);
- fix_new(frag_now, p - frag_now->fr_literal, nbytes,
- this_add_symbol, 0, this_add_number, 1, NO_RELOC);
- } else { /* to_seg == now_seg || to_seg == SEG_UNKNOWN */
- /* nbytes == 0 */
- length_code = is_undefined ? STATE_UNDF : STATE_BYTE;
- if (opcode_as_number & VIT_OPCODE_SPECIAL) {
- if (operandP->vop_width == VAX_WIDTH_UNCONDITIONAL_JUMP) {
- /* br or jsb */
- frag_var(rs_machine_dependent, 5, 1,
- ENCODE_RELAX (STATE_ALWAYS_BRANCH, length_code),
- this_add_symbol, this_add_number,
- opcode_low_byteP);
- } else {
- if (operandP->vop_width == VAX_WIDTH_WORD_JUMP) {
- length_code = STATE_WORD;
- /* JF: There is no state_byte for this one! */
- frag_var(rs_machine_dependent, 10, 2,
- ENCODE_RELAX (STATE_COMPLEX_BRANCH, length_code),
- this_add_symbol, this_add_number,
- opcode_low_byteP);
- } else {
- know(operandP->vop_width == VAX_WIDTH_BYTE_JUMP);
- frag_var(rs_machine_dependent, 9, 1,
- ENCODE_RELAX (STATE_COMPLEX_HOP, length_code),
- this_add_symbol, this_add_number,
- opcode_low_byteP);
- }
- }
- } else {
- know(operandP->vop_width == VAX_WIDTH_CONDITIONAL_JUMP);
- frag_var(rs_machine_dependent, 7, 1,
- ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, length_code),
- this_add_symbol, this_add_number,
- opcode_low_byteP);
- }
- }
- } else { /* to_seg != now_seg && to_seg != SEG_UNKNOWN */
- /*
- * --- SEG FLOAT MAY APPEAR HERE ----
- */
- if (to_seg == SEG_ABSOLUTE) {
- if (nbytes) {
- know(!(opcode_as_number & VIT_OPCODE_SYNTHETIC));
- p = frag_more (nbytes);
- /* Conventional relocation. */
- fix_new(frag_now, p - frag_now->fr_literal,
- nbytes, &abs_symbol, 0, this_add_number, 1, NO_RELOC);
- } else {
- know(opcode_as_number & VIT_OPCODE_SYNTHETIC);
- if (opcode_as_number & VIT_OPCODE_SPECIAL) {
- if (operandP->vop_width == VAX_WIDTH_UNCONDITIONAL_JUMP) {
- /* br or jsb */
- *opcode_low_byteP = opcode_as_chars[0] + VAX_WIDEN_LONG;
- know(opcode_as_chars[1] == 0);
- p = frag_more (5);
- p[0] = VAX_ABSOLUTE_MODE; /* @#... */
- md_number_to_chars(p + 1, this_add_number, 4);
- /* Now (eg) JMP @#foo or JSB @#foo. */
- } else {
- if (operandP->vop_width == VAX_WIDTH_WORD_JUMP) {
- p = frag_more (10);
- p[0] = 2;
- p[1] = 0;
- p[2] = VAX_BRB;
- p[3] = 6;
- p[4] = VAX_JMP;
- p[5] = VAX_ABSOLUTE_MODE; /* @#... */
- md_number_to_chars(p + 6, this_add_number, 4);
- /*
- * Now (eg) ACBx 1f
- * BRB 2f
- * 1: JMP @#foo
- * 2:
- */
- } else {
- know(operandP->vop_width == VAX_WIDTH_BYTE_JUMP);
- p = frag_more (9);
- p[0] = 2;
- p[1] = VAX_BRB;
- p[2] = 6;
- p[3] = VAX_JMP;
- p[4] = VAX_PC_RELATIVE_MODE + 1; /* @#... */
- md_number_to_chars(p + 5, this_add_number, 4);
- /*
- * Now (eg) xOBxxx 1f
- * BRB 2f
- * 1: JMP @#foo
- * 2:
- */
- }
- }
- } else {
- /* b<cond> */
- *opcode_low_byteP ^= 1;
- /* To reverse the condition in a VAX branch, complement the lowest order
- bit. */
- p = frag_more (7);
- p[0] = 6;
- p[1] = VAX_JMP;
- p[2] = VAX_ABSOLUTE_MODE; /* @#... */
- md_number_to_chars(p + 3, this_add_number, 4);
- /*
- * Now (eg) BLEQ 1f
- * JMP @#foo
- * 1:
- */
- }
- }
- } else { /* to_seg != now_seg && to_seg != SEG_UNKNOWN && to_Seg != SEG_ABSOLUTE */
- if (nbytes > 0) {
- /* Pc-relative. Conventional relocation. */
- know(!(opcode_as_number & VIT_OPCODE_SYNTHETIC));
- p = frag_more (nbytes);
- fix_new(frag_now, p - frag_now->fr_literal,
- nbytes, &abs_symbol, 0, this_add_number, 1, NO_RELOC);
- } else {
- know(opcode_as_number & VIT_OPCODE_SYNTHETIC);
- if (opcode_as_number & VIT_OPCODE_SPECIAL) {
- if (operandP->vop_width == VAX_WIDTH_UNCONDITIONAL_JUMP) {
- /* br or jsb */
- know(opcode_as_chars[1] == 0);
- *opcode_low_byteP = opcode_as_chars[0] + VAX_WIDEN_LONG;
- p = frag_more (5);
- p[0] = VAX_PC_RELATIVE_MODE;
- fix_new(frag_now,
- p + 1 - frag_now->fr_literal, 4,
- this_add_symbol, 0,
- this_add_number, 1, NO_RELOC);
- /* Now eg JMP foo or JSB foo. */
- } else {
- if (operandP->vop_width == VAX_WIDTH_WORD_JUMP) {
- p = frag_more (10);
- p[0] = 0;
- p[1] = 2;
- p[2] = VAX_BRB;
- p[3] = 6;
- p[4] = VAX_JMP;
- p[5] = VAX_PC_RELATIVE_MODE;
- fix_new(frag_now,
- p + 6 - frag_now->fr_literal, 4,
- this_add_symbol, 0,
- this_add_number, 1, NO_RELOC);
- /*
- * Now (eg) ACBx 1f
- * BRB 2f
- * 1: JMP foo
- * 2:
- */
- } else {
- know(operandP->vop_width == VAX_WIDTH_BYTE_JUMP);
- p = frag_more (10);
- p[0] = 2;
- p[1] = VAX_BRB;
- p[2] = 6;
- p[3] = VAX_JMP;
- p[4] = VAX_PC_RELATIVE_MODE;
- fix_new(frag_now,
- p + 5 - frag_now->fr_literal,
- 4, this_add_symbol, 0,
- this_add_number, 1, NO_RELOC);
- /*
- * Now (eg) xOBxxx 1f
- * BRB 2f
- * 1: JMP foo
- * 2:
- */
- }
- }
- } else {
- know(operandP->vop_width == VAX_WIDTH_CONDITIONAL_JUMP);
- *opcode_low_byteP ^= 1; /* Reverse branch condition. */
- p = frag_more (7);
- p[0] = 6;
- p[1] = VAX_JMP;
- p[2] = VAX_PC_RELATIVE_MODE;
- fix_new(frag_now, p + 3 - frag_now->fr_literal,
- 4, this_add_symbol, 0,
- this_add_number, 1, NO_RELOC);
- }
- }
- }
- }
- } else {
- know(operandP->vop_access != 'b'); /* So it is ordinary operand. */
- know(operandP->vop_access != ' '); /* ' ' target-independent: elsewhere. */
- know(operandP->vop_access == 'a'
- || operandP->vop_access == 'm'
- || operandP->vop_access == 'r'
- || operandP->vop_access == 'v'
- || operandP->vop_access == 'w');
- if (operandP->vop_short == 's') {
- if (to_seg == SEG_ABSOLUTE) {
- if (this_add_number < 0 || this_add_number >= 64) {
- as_warn("Short literal overflow(%d.), immediate mode assumed.", this_add_number);
- operandP->vop_short = 'i';
- operandP->vop_mode = 8;
- operandP->vop_reg = 0xF;
- }
- } else {
- as_warn ("Forced short literal to immediate mode. now_seg=%s to_seg=%s",
- segment_name(now_seg), segment_name(to_seg));
- operandP->vop_short = 'i';
- operandP->vop_mode = 8;
- operandP->vop_reg = 0xF;
- }
- }
- if (operandP->vop_reg >= 0 && (operandP->vop_mode < 8
- || (operandP->vop_reg != 0xF && operandP->vop_mode < 10))) {
- /* One byte operand. */
- know(operandP->vop_mode > 3);
- FRAG_APPEND_1_CHAR (operandP->vop_mode << 4 | operandP->vop_reg);
- /* All 1-bytes except S^# happen here. */
- } else { /* {@}{q^}foo{(Rn)} or S^#foo */
- if (operandP->vop_reg == -1 && operandP->vop_short != 's') {
- /* "{@}{q^}foo" */
- if (to_seg == now_seg) {
- if (length == 0) {
- know(operandP->vop_short == ' ');
- p = frag_var(rs_machine_dependent, 10, 2,
- ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE),
- this_add_symbol, this_add_number,
- opcode_low_byteP);
- know(operandP->vop_mode == 10 + at);
- *p = at << 4;
- /* At is the only context we need to carry to */
- /* other side of relax() process. */
- /* Must be in the correct bit position of VAX */
- /* operand spec. byte. */
- } else {
- know(length);
- know(operandP->vop_short != ' ');
- p = frag_more (length + 1);
- /* JF is this array stuff really going to work? */
- p[0] = 0xF | ((at + "?\12\14?\16"[length]) << 4);
- fix_new(frag_now, p + 1 - frag_now->fr_literal,
- length, this_add_symbol, 0,
- this_add_number, 1, NO_RELOC);
- }
- } else { /* to_seg != now_seg */
- if (this_add_symbol == NULL) {
- know(to_seg == SEG_ABSOLUTE);
- /* Do @#foo: simpler relocation than foo-.(pc) anyway. */
- p = frag_more (5);
- p[0] = VAX_ABSOLUTE_MODE; /* @#... */
- md_number_to_chars(p + 1, this_add_number, 4);
- if (length && length != 4)
- {
- as_warn ("Length specification ignored. Address mode 9F used");
- }
- } else {
- /* {@}{q^}other_seg */
- know((length == 0 && operandP->vop_short == ' ')
- ||(length > 0 && operandP->vop_short != ' '));
- if (is_undefined) {
- /*
- * We have a SEG_UNKNOWN symbol. It might
- * turn out to be in the same segment as
- * the instruction, permitting relaxation.
- */
- p = frag_var(rs_machine_dependent, 5, 2,
- ENCODE_RELAX (STATE_PC_RELATIVE, STATE_UNDF),
- this_add_symbol, this_add_number,
- 0);
- p[0] = at << 4;
- } else {
- if (length == 0) {
- know(operandP->vop_short == ' ');
- length = 4; /* Longest possible. */
- }
- p = frag_more (length + 1);
- p[0] = 0xF | ((at + "?\12\14?\16"[length]) << 4);
- md_number_to_chars(p + 1, this_add_number, length);
- fix_new(frag_now,
- p + 1 - frag_now->fr_literal,
- length, this_add_symbol, 0,
- this_add_number, 1, NO_RELOC);
- }
- }
- }
- } else { /* {@}{q^}foo(Rn) or S^# or I^# or # */
- if (operandP->vop_mode < 0xA) { /* # or S^# or I^# */
- /* know( (length == 0 && operandP->vop_short == ' ')
- || (length > 0 && operandP->vop_short != ' ')); */
- if (length == 0
- && to_seg == SEG_ABSOLUTE
- && operandP->vop_mode == 8 /* No '@'. */
- && this_add_number < 64
- && this_add_number >= 0) {
- operandP->vop_short = 's';
- }
- if (operandP->vop_short == 's') {
- FRAG_APPEND_1_CHAR (this_add_number);
- } else { /* I^#... */
- know(nbytes);
- p = frag_more (nbytes + 1);
- know(operandP->vop_reg == 0xF);
- p[0] = (operandP->vop_mode << 4) | 0xF;
- if (to_seg == SEG_ABSOLUTE) {
- /*
- * If nbytes > 4, then we are scrod. We don't know if the
- * high order bytes are to be 0xFF or 0x00.
- * BSD4.2 & RMS say use 0x00. OK --- but this
- * assembler needs ANOTHER rewrite to
- * cope properly with this bug.
- */
- md_number_to_chars(p + 1, this_add_number, min (4, nbytes));
- if (nbytes > 4)
- {
- memset(p + 5, '\0', nbytes - 4);
- }
- } else {
- if (to_seg == SEG_BIG) {
- /*
- * Problem here is to get the bytes in the right order.
- * We stored our constant as LITTLENUMs, not bytes.
- */
- LITTLENUM_TYPE *lP;
-
- lP = floatP->low;
- if (nbytes & 1) {
- know(nbytes == 1);
- p[1] = *lP;
- } else {
- for (p++; nbytes; nbytes -= 2, p += 2, lP++)
- {
- md_number_to_chars(p, *lP, 2);
- }
- }
- } else {
- fix_new(frag_now, p + 1 - frag_now->fr_literal,
- nbytes, this_add_symbol, 0,
- this_add_number, 0, NO_RELOC);
- }
- }
- }
- } else { /* {@}{q^}foo(Rn) */
- know((length == 0 && operandP->vop_short == ' ')
- ||(length > 0 && operandP->vop_short != ' '));
- if (length == 0) {
- if (to_seg == SEG_ABSOLUTE) {
- register long test;
-
- test = this_add_number;
-
- if (test < 0)
- test = ~test;
-
- length = test & 0xffff8000 ? 4
- : test & 0xffffff80 ? 2
- : 1;
- } else {
- length = 4;
- }
- }
- p = frag_more (1 + length);
- know(operandP->vop_reg >= 0);
- p[0] = operandP->vop_reg
- | ((at | "?\12\14?\16"[length]) << 4);
- if (to_seg == SEG_ABSOLUTE) {
- md_number_to_chars(p + 1, this_add_number, length);
- } else {
- fix_new(frag_now, p + 1 - frag_now->fr_literal,
- length, this_add_symbol, 0,
- this_add_number, 0, NO_RELOC);
- }
- }
- }
- } /* if (single-byte-operand) */
- }
- } /* for (operandP) */
-} /* vax_assemble() */
-
-/*
- * md_estimate_size_before_relax()
- *
- * Called just before relax().
- * Any symbol that is now undefined will not become defined.
- * Return the correct fr_subtype in the frag.
- * Return the initial "guess for fr_var" to caller.
- * The guess for fr_var is ACTUALLY the growth beyond fr_fix.
- * Whatever we do to grow fr_fix or fr_var contributes to our returned value.
- * Although it may not be explicit in the frag, pretend fr_var starts with a
- * 0 value.
- */
-int
- md_estimate_size_before_relax (fragP, segment)
-register fragS *fragP;
-register segT segment;
-{
- register char *p;
- register int old_fr_fix;
-
- old_fr_fix = fragP->fr_fix;
- switch (fragP->fr_subtype) {
- case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_UNDF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment) { /* A relaxable case. */
- fragP->fr_subtype = ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE);
- } else {
- p = fragP->fr_literal + old_fr_fix;
- p[0] |= VAX_PC_RELATIVE_MODE; /* Preserve @ bit. */
- fragP->fr_fix += 1 + 4;
- fix_new(fragP, old_fr_fix + 1, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 1, NO_RELOC);
- frag_wane(fragP);
- }
- break;
-
- case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- fragP->fr_subtype = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE);
- } else {
- p = fragP->fr_literal + old_fr_fix;
- *fragP->fr_opcode ^= 1; /* Reverse sense of branch. */
- p[0] = 6;
- p[1] = VAX_JMP;
- p[2] = VAX_PC_RELATIVE_MODE; /* ...(PC) */
- fragP->fr_fix += 1 + 1 + 1 + 4;
- fix_new(fragP, old_fr_fix + 3, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 1, NO_RELOC);
- frag_wane(fragP);
- }
- break;
-
- case ENCODE_RELAX (STATE_COMPLEX_BRANCH, STATE_UNDF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- fragP->fr_subtype = ENCODE_RELAX (STATE_COMPLEX_BRANCH, STATE_WORD);
- } else {
- p = fragP->fr_literal + old_fr_fix;
- p[0] = 2;
- p[1] = 0;
- p[2] = VAX_BRB;
- p[3] = 6;
- p[4] = VAX_JMP;
- p[5] = VAX_PC_RELATIVE_MODE; /* ...(pc) */
- fragP->fr_fix += 2 + 2 + 1 + 1 + 4;
- fix_new(fragP, old_fr_fix + 6, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 1, NO_RELOC);
- frag_wane(fragP);
- }
- break;
-
- case ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_UNDF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- fragP->fr_subtype = ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_BYTE);
- } else {
- p = fragP->fr_literal + old_fr_fix;
- p[0] = 2;
- p[1] = VAX_BRB;
- p[2] = 6;
- p[3] = VAX_JMP;
- p[4] = VAX_PC_RELATIVE_MODE; /* ...(pc) */
- fragP->fr_fix += 1 + 2 + 1 + 1 + 4;
- fix_new(fragP, old_fr_fix + 5, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 1, NO_RELOC);
- frag_wane(fragP);
- }
- break;
-
- case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_UNDF):
- if (S_GET_SEGMENT(fragP->fr_symbol) == segment) {
- fragP->fr_subtype = ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE);
- } else {
- p = fragP->fr_literal + old_fr_fix;
- *fragP->fr_opcode += VAX_WIDEN_LONG;
- p[0] = VAX_PC_RELATIVE_MODE; /* ...(PC) */
- fragP->fr_fix += 1 + 4;
- fix_new(fragP, old_fr_fix + 1, 4, fragP->fr_symbol, 0,
- fragP->fr_offset, 1, NO_RELOC);
- frag_wane(fragP);
- }
- break;
-
- default:
- break;
- }
- return (fragP->fr_var + fragP->fr_fix - old_fr_fix);
-} /* md_estimate_size_before_relax() */
-
-/*
- * md_convert_frag();
- *
- * Called after relax() is finished.
- * In: Address of frag.
- * fr_type == rs_machine_dependent.
- * fr_subtype is what the address relaxed to.
- *
- * Out: Any fixSs and constants are set up.
- * Caller will turn frag into a ".space 0".
- */
-void
- md_convert_frag (headers, fragP)
-object_headers *headers;
-register fragS *fragP;
-{
- char *addressP; /* -> _var to change. */
- char *opcodeP; /* -> opcode char(s) to change. */
- short int length_code; /* 2=long 1=word 0=byte */
- short int extension = 0; /* Size of relaxed address. */
- /* Added to fr_fix: incl. ALL var chars. */
- symbolS *symbolP;
- long where;
- long address_of_var;
- /* Where, in file space, is _var of *fragP? */
- long target_address = 0;
- /* Where, in file space, does addr point? */
-
- know(fragP->fr_type == rs_machine_dependent);
- length_code = fragP->fr_subtype & 3; /* depends on ENCODE_RELAX() */
- know(length_code >= 0 && length_code < 3);
- where = fragP->fr_fix;
- addressP = fragP->fr_literal + where;
- opcodeP = fragP->fr_opcode;
- symbolP = fragP->fr_symbol;
- know(symbolP);
- target_address = S_GET_VALUE(symbolP) + fragP->fr_offset;
- address_of_var = fragP->fr_address + where;
-
- switch (fragP->fr_subtype) {
-
- case ENCODE_RELAX(STATE_PC_RELATIVE, STATE_BYTE):
- know(*addressP == 0 || *addressP == 0x10); /* '@' bit. */
- addressP[0] |= 0xAF; /* Byte displacement. */
- addressP[1] = target_address - (address_of_var + 2);
- extension = 2;
- break;
-
- case ENCODE_RELAX(STATE_PC_RELATIVE, STATE_WORD):
- know(*addressP == 0 || *addressP == 0x10); /* '@' bit. */
- addressP[0] |= 0xCF; /* Word displacement. */
- md_number_to_chars(addressP + 1, target_address - (address_of_var + 3), 2);
- extension = 3;
- break;
-
- case ENCODE_RELAX(STATE_PC_RELATIVE, STATE_LONG):
- know(*addressP == 0 || *addressP == 0x10); /* '@' bit. */
- addressP[0] |= 0xEF; /* Long word displacement. */
- md_number_to_chars(addressP + 1, target_address - (address_of_var + 5), 4);
- extension = 5;
- break;
-
- case ENCODE_RELAX(STATE_CONDITIONAL_BRANCH, STATE_BYTE):
- addressP[0] = target_address - (address_of_var + 1);
- extension = 1;
- break;
-
- case ENCODE_RELAX(STATE_CONDITIONAL_BRANCH, STATE_WORD):
- opcodeP[0] ^= 1; /* Reverse sense of test. */
- addressP[0] = 3;
- addressP[1] = VAX_BRB + VAX_WIDEN_WORD;
- md_number_to_chars(addressP + 2, target_address - (address_of_var + 4), 2);
- extension = 4;
- break;
-
- case ENCODE_RELAX(STATE_CONDITIONAL_BRANCH, STATE_LONG):
- opcodeP[0] ^= 1; /* Reverse sense of test. */
- addressP[0] = 6;
- addressP[1] = VAX_JMP;
- addressP[2] = VAX_PC_RELATIVE_MODE;
- md_number_to_chars(addressP + 3, target_address, 4);
- extension = 7;
- break;
-
- case ENCODE_RELAX(STATE_ALWAYS_BRANCH, STATE_BYTE):
- addressP[0] = target_address - (address_of_var + 1);
- extension = 1;
- break;
-
- case ENCODE_RELAX(STATE_ALWAYS_BRANCH, STATE_WORD):
- opcodeP[0] += VAX_WIDEN_WORD; /* brb -> brw, bsbb -> bsbw */
- md_number_to_chars(addressP, target_address - (address_of_var + 2), 2);
- extension = 2;
- break;
-
- case ENCODE_RELAX(STATE_ALWAYS_BRANCH, STATE_LONG):
- opcodeP[0] += VAX_WIDEN_LONG; /* brb -> jmp, bsbb -> jsb */
- addressP[0] = VAX_PC_RELATIVE_MODE;
- md_number_to_chars(addressP + 1, target_address - (address_of_var + 5), 4);
- extension = 5;
- break;
-
- case ENCODE_RELAX(STATE_COMPLEX_BRANCH, STATE_WORD):
- md_number_to_chars(addressP, target_address - (address_of_var + 2), 2);
- extension = 2;
- break;
-
- case ENCODE_RELAX(STATE_COMPLEX_BRANCH, STATE_LONG):
- addressP[0] = 2;
- addressP[1] = 0;
- addressP[2] = VAX_BRB;
- addressP[3] = 6;
- addressP[4] = VAX_JMP;
- addressP[5] = VAX_PC_RELATIVE_MODE;
- md_number_to_chars(addressP + 6, target_address, 4);
- extension = 10;
- break;
-
- case ENCODE_RELAX(STATE_COMPLEX_HOP, STATE_BYTE):
- addressP[0] = target_address - (address_of_var + 1);
- extension = 1;
- break;
-
- case ENCODE_RELAX(STATE_COMPLEX_HOP, STATE_WORD):
- addressP[0] = 2;
- addressP[1] = VAX_BRB;
- addressP[2] = 3;
- addressP[3] = VAX_BRW;
- md_number_to_chars(addressP + 4, target_address - (address_of_var + 6), 2);
- extension = 6;
- break;
-
- case ENCODE_RELAX(STATE_COMPLEX_HOP, STATE_LONG):
- addressP[0] = 2;
- addressP[1] = VAX_BRB;
- addressP[2] = 6;
- addressP[3] = VAX_JMP;
- addressP[4] = VAX_PC_RELATIVE_MODE;
- md_number_to_chars(addressP + 5, target_address, 4);
- extension = 9;
- break;
-
- default:
- BAD_CASE(fragP->fr_subtype);
- break;
- }
- fragP->fr_fix += extension;
-} /* md_convert_frag() */
-
-/* Translate internal format of relocation info into target format.
-
- On vax: first 4 bytes are normal unsigned long, next three bytes
- are symbolnum, least sig. byte first. Last byte is broken up with
- the upper nibble as nuthin, bit 3 as extern, bits 2 & 1 as length, and
- bit 0 as pcrel. */
-#ifdef comment
-void
- md_ri_to_chars (the_bytes, ri)
-char *the_bytes;
-struct reloc_info_generic ri;
-{
- /* this is easy */
- md_number_to_chars(the_bytes, ri.r_address, sizeof (ri.r_address));
- /* now the fun stuff */
- the_bytes[6] = (ri.r_symbolnum >> 16) & 0x0ff;
- the_bytes[5] = (ri.r_symbolnum >> 8) & 0x0ff;
- the_bytes[4] = ri.r_symbolnum & 0x0ff;
- the_bytes[7] = (((ri.r_extern << 3) & 0x08) | ((ri.r_length << 1) & 0x06) |
- ((ri.r_pcrel << 0) & 0x01)) & 0x0F;
-}
-#endif /* comment */
-
-void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
-char *where;
-fixS *fixP;
-relax_addressT segment_address_in_file;
-{
- /*
- * In: length of relocation (or of address) in chars: 1, 2 or 4.
- * Out: GNU LD relocation length code: 0, 1, or 2.
- */
-
- static unsigned char nbytes_r_length[] = { 42, 0, 1, 42, 2 };
- long r_symbolnum;
-
- know(fixP->fx_addsy != NULL);
-
- md_number_to_chars(where,
- fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
- 4);
-
- r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
- ? S_GET_TYPE(fixP->fx_addsy)
- : fixP->fx_addsy->sy_number);
-
- where[6] = (r_symbolnum >> 16) & 0x0ff;
- where[5] = (r_symbolnum >> 8) & 0x0ff;
- where[4] = r_symbolnum & 0x0ff;
- where[7] = ((((!S_IS_DEFINED(fixP->fx_addsy)) << 3) & 0x08)
- | ((nbytes_r_length[fixP->fx_size] << 1) & 0x06)
- | (((fixP->fx_pcrel << 0) & 0x01) & 0x0f));
-
- return;
-} /* tc_aout_fix_to_chars() */
-/*
- * BUGS, GRIPES, APOLOGIA, etc.
- *
- * The opcode table 'votstrs' needs to be sorted on opcode frequency.
- * That is, AFTER we hash it with hash_...(), we want most-used opcodes
- * to come out of the hash table faster.
- *
- * I am sorry to inflict
- * yet another VAX assembler on the world, but RMS says we must
- * do everything from scratch, to prevent pin-heads restricting
- * this software.
- */
-
-/*
- * This is a vaguely modular set of routines in C to parse VAX
- * assembly code using DEC mnemonics. It is NOT un*x specific.
- *
- * The idea here is that the assembler has taken care of all:
- * labels
- * macros
- * listing
- * pseudo-ops
- * line continuation
- * comments
- * condensing any whitespace down to exactly one space
- * and all we have to do is parse 1 line into a vax instruction
- * partially formed. We will accept a line, and deliver:
- * an error message (hopefully empty)
- * a skeleton VAX instruction (tree structure)
- * textual pointers to all the operand expressions
- * a warning message that notes a silly operand (hopefully empty)
- */
-
-/*
- * E D I T H I S T O R Y
- *
- * 17may86 Dean Elsner. Bug if line ends immediately after opcode.
- * 30apr86 Dean Elsner. New vip_op() uses arg block so change call.
- * 6jan86 Dean Elsner. Crock vip_begin() to call vip_op_defaults().
- * 2jan86 Dean Elsner. Invent synthetic opcodes.
- * Widen vax_opcodeT to 32 bits. Use a bit for VIT_OPCODE_SYNTHETIC,
- * which means this is not a real opcode, it is like a macro; it will
- * be relax()ed into 1 or more instructions.
- * Use another bit for VIT_OPCODE_SPECIAL if the op-code is not optimised
- * like a regular branch instruction. Option added to vip_begin():
- * exclude synthetic opcodes. Invent synthetic_votstrs[].
- * 31dec85 Dean Elsner. Invent vit_opcode_nbytes.
- * Also make vit_opcode into a char[]. We now have n-byte vax opcodes,
- * so caller's don't have to know the difference between a 1-byte & a
- * 2-byte op-code. Still need vax_opcodeT concept, so we know how
- * big an object must be to hold an op.code.
- * 30dec85 Dean Elsner. Widen typedef vax_opcodeT in "vax-inst.h"
- * because vax opcodes may be 16 bits. Our crufty C compiler was
- * happily initialising 8-bit vot_codes with 16-bit numbers!
- * (Wouldn't the 'phone company like to compress data so easily!)
- * 29dec85 Dean Elsner. New static table vax_operand_width_size[].
- * Invented so we know hw many bytes a "I^#42" needs in its immediate
- * operand. Revised struct vop in "vax-inst.h": explicitly include
- * byte length of each operand, and it's letter-code datum type.
- * 17nov85 Dean Elsner. Name Change.
- * Due to ar(1) truncating names, we learned the hard way that
- * "vax-inst-parse.c" -> "vax-inst-parse." dropping the "o" off
- * the archived object name. SO... we shortened the name of this
- * source file, and changed the makefile.
- */
-
-static struct hash_control *op_hash = NULL; /* handle of the OPCODE hash table */
-/* NULL means any use before vip_begin() */
-/* will crash */
-
-/*
- * In: 1 character, from "bdfghloqpw" being the data-type of an operand
- * of a vax instruction.
- *
- * Out: the length of an operand of that type, in bytes.
- * Special branch operands types "-?!" have length 0.
- */
-
-static const short int vax_operand_width_size[256] =
-{
-
-#define _ 0
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, 1, _, 8, _, 4, 8, 16, _, _, _, 4, _, _, 16, /* ..b.d.fgh...l..o */
- _, 8, _, _, _, _, _, 2, _, _, _, _, _, _, _, _, /* .q.....w........ */
- _, _, 1, _, 8, _, 4, 8, 16, _, _, _, 4, _, _, 16, /* ..b.d.fgh...l..o */
- _, 8, _, _, _, _, _, 2, _, _, _, _, _, _, _, _, /* .q.....w........ */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _};
-#undef _
-
-/*
- * This perversion encodes all the vax opcodes as a bunch of strings.
- * RMS says we should build our hash-table at run-time. Hmm.
- * Please would someone arrange these in decreasing frequency of opcode?
- * Because of the way hash_...() works, the most frequently used opcode
- * should be textually first and so on.
- *
- * Input for this table was 'vax.opcodes', awk(1)ed by 'vax.opcodes.c.awk' .
- * So change 'vax.opcodes', then re-generate this table.
- */
-
-#include "opcode/vax.h"
-
-/*
- * This is a table of optional op-codes. All of them represent
- * 'synthetic' instructions that seem popular.
- *
- * Here we make some pseudo op-codes. Every code has a bit set to say
- * it is synthetic. This lets you catch them if you want to
- * ban these opcodes. They are mnemonics for "elastic" instructions
- * that are supposed to assemble into the fewest bytes needed to do a
- * branch, or to do a conditional branch, or whatever.
- *
- * The opcode is in the usual place [low-order n*8 bits]. This means
- * that if you mask off the bucky bits, the usual rules apply about
- * how long the opcode is.
- *
- * All VAX branch displacements come at the end of the instruction.
- * For simple branches (1-byte opcode + 1-byte displacement) the last
- * operand is coded 'b?' where the "data type" '?' is a clue that we
- * may reverse the sense of the branch (complement lowest order bit)
- * and branch around a jump. This is by far the most common case.
- * That is why the VIT_OPCODE_SYNTHETIC bit is set: it says this is
- * a 0-byte op-code followed by 2 or more bytes of operand address.
- *
- * If the op-code has VIT_OPCODE_SPECIAL set, then we have a more unusual
- * case.
- *
- * For JBSB & JBR the treatment is the similar, except (1) we have a 'bw'
- * option before (2) we can directly JSB/JMP because there is no condition.
- * These operands have 'b-' as their access/data type.
- *
- * That leaves a bunch of random opcodes: JACBx, JxOBxxx. In these
- * cases, we do the same idea. JACBxxx are all marked with a 'b!'
- * JAOBxxx & JSOBxxx are marked with a 'b:'.
- *
- */
-#if (VIT_OPCODE_SYNTHETIC != 0x80000000)
-You have just broken the encoding below, which assumes the sign bit
- means 'I am an imaginary instruction'.
-#endif
-
-#if (VIT_OPCODE_SPECIAL != 0x40000000)
-You have just broken the encoding below, which assumes the 0x40 M bit means
- 'I am not to be "optimised" the way normal branches are'.
-#endif
-
- static const struct vot
- synthetic_votstrs[] =
-{
- {"jbsb", {"b-", 0xC0000010}}, /* BSD 4.2 */
- /* jsb used already */
- {"jbr", {"b-", 0xC0000011}}, /* BSD 4.2 */
- {"jr", {"b-", 0xC0000011}}, /* consistent */
- {"jneq", {"b?", 0x80000012}},
- {"jnequ", {"b?", 0x80000012}},
- {"jeql", {"b?", 0x80000013}},
- {"jeqlu", {"b?", 0x80000013}},
- {"jgtr", {"b?", 0x80000014}},
- {"jleq", {"b?", 0x80000015}},
- /* un-used opcodes here */
- {"jgeq", {"b?", 0x80000018}},
- {"jlss", {"b?", 0x80000019}},
- {"jgtru", {"b?", 0x8000001a}},
- {"jlequ", {"b?", 0x8000001b}},
- {"jvc", {"b?", 0x8000001c}},
- {"jvs", {"b?", 0x8000001d}},
- {"jgequ", {"b?", 0x8000001e}},
- {"jcc", {"b?", 0x8000001e}},
- {"jlssu", {"b?", 0x8000001f}},
- {"jcs", {"b?", 0x8000001f}},
-
- {"jacbw", {"rwrwmwb!", 0xC000003d}},
- {"jacbf", {"rfrfmfb!", 0xC000004f}},
- {"jacbd", {"rdrdmdb!", 0xC000006f}},
- {"jacbb", {"rbrbmbb!", 0xC000009d}},
- {"jacbl", {"rlrlmlb!", 0xC00000f1}},
- {"jacbg", {"rgrgmgb!", 0xC0004ffd}},
- {"jacbh", {"rhrhmhb!", 0xC0006ffd}},
-
- {"jbs", {"rlvbb?", 0x800000e0}},
- {"jbc", {"rlvbb?", 0x800000e1}},
- {"jbss", {"rlvbb?", 0x800000e2}},
- {"jbcs", {"rlvbb?", 0x800000e3}},
- {"jbsc", {"rlvbb?", 0x800000e4}},
- {"jbcc", {"rlvbb?", 0x800000e5}},
- {"jbssi", {"rlvbb?", 0x800000e6}},
- {"jbcci", {"rlvbb?", 0x800000e7}},
- {"jlbs", {"rlb?", 0x800000e8}}, /* JF changed from rlvbb? */
- {"jlbc", {"rlb?", 0x800000e9}}, /* JF changed from rlvbb? */
-
- {"jaoblss", {"rlmlb:", 0xC00000f2}},
- {"jaobleq", {"rlmlb:", 0xC00000f3}},
- {"jsobgeq", {"mlb:", 0xC00000f4}}, /* JF was rlmlb: */
- {"jsobgtr", {"mlb:", 0xC00000f5}}, /* JF was rlmlb: */
-
- /* CASEx has no branch addresses in our conception of it. */
- /* You should use ".word ..." statements after the "case ...". */
-
- {"", ""} /* empty is end sentinel */
-
-}; /* synthetic_votstrs */
-
-/*
- * v i p _ b e g i n ( )
- *
- * Call me once before you decode any lines.
- * I decode votstrs into a hash table at op_hash (which I create).
- * I return an error text: hopefully "".
- * If you want, I will include the 'synthetic' jXXX instructions in the
- * instruction table.
- * You must nominate metacharacters for eg DEC's "#", "@", "^".
- */
-
-char *
- vip_begin (synthetic_too, immediate, indirect, displen)
-int synthetic_too; /* 1 means include jXXX op-codes. */
-char *immediate, *indirect, *displen;
-{
- const struct vot *vP; /* scan votstrs */
- char *retval; /* error text */
-
- if ((op_hash = hash_new())) {
- retval = ""; /* OK so far */
- for (vP = votstrs; *vP->vot_name && !*retval; vP++) {
- retval = hash_insert(op_hash, vP->vot_name, &vP->vot_detail);
- }
- if (synthetic_too) {
- for (vP = synthetic_votstrs; *vP->vot_name && !*retval; vP++) {
- retval = hash_insert(op_hash, vP->vot_name, &vP->vot_detail);
- }
- }
- } else {
- retval = "virtual memory exceeded";
- }
-#ifndef CONST_TABLE
- vip_op_defaults(immediate, indirect, displen);
-#endif
-
- return (retval);
-}
-
-
-/*
- * v i p _ e n d ( )
- *
- * Call me once after you have decoded all lines.
- * I do any cleaning-up needed.
- *
- * We don't have to do any cleanup ourselves: all of our operand
- * symbol table is static, and free()ing it is naughty.
- */
-static void vip_end () { }
-
-/*
- * v i p ( )
- *
- * This converts a string into a vax instruction.
- * The string must be a bare single instruction in dec-vax (with BSD4 frobs)
- * format.
- * It provides some error messages: at most one fatal error message (which
- * stops the scan) and at most one warning message for each operand.
- * The vax instruction is returned in exploded form, since we have no
- * knowledge of how you parse (or evaluate) your expressions.
- * We do however strip off and decode addressing modes and operation
- * mnemonic.
- *
- * The exploded instruction is returned to a struct vit of your choice.
- * #include "vax-inst.h" to know what a struct vit is.
- *
- * This function's value is a string. If it is not "" then an internal
- * logic error was found: read this code to assign meaning to the string.
- * No argument string should generate such an error string:
- * it means a bug in our code, not in the user's text.
- *
- * You MUST have called vip_begin() once and vip_end() never before using
- * this function.
- */
-
-char * /* "" or bug string */
- vip (vitP, instring)
-struct vit *vitP; /* We build an exploded instruction here. */
-char *instring; /* Text of a vax instruction: we modify. */
-{
- register struct vot_wot *vwP; /* How to bit-encode this opcode. */
- register char *p; /* 1/skip whitespace.2/scan vot_how */
- register char *q; /* */
- register char *bug; /* "" or program logic error */
- register unsigned char count; /* counts number of operands seen */
- register struct vop *operandp;/* scan operands in struct vit */
- register char *alloperr; /* error over all operands */
- register char c; /* Remember char, (we clobber it */
- /* with '\0' temporarily). */
- register vax_opcodeT oc; /* Op-code of this instruction. */
-
- char *vip_op ();
-
- bug = "";
- if (*instring == ' ')
- ++instring; /* Skip leading whitespace. */
- for (p = instring; *p && *p != ' '; p++) ;; /* MUST end in end-of-string or exactly 1 space. */
- /* Scanned up to end of operation-code. */
- /* Operation-code is ended with whitespace. */
- if (p - instring == 0) {
- vitP->vit_error = "No operator";
- count = 0;
- memset(vitP->vit_opcode, '\0', sizeof(vitP->vit_opcode));
- } else {
- c = *p;
- *p = '\0';
- /*
- * Here with instring pointing to what better be an op-name, and p
- * pointing to character just past that.
- * We trust instring points to an op-name, with no whitespace.
- */
- vwP = (struct vot_wot *) hash_find(op_hash, instring);
- *p = c; /* Restore char after op-code. */
- if (vwP == 0) {
- vitP->vit_error = "Unknown operator";
- count = 0;
- memset(vitP->vit_opcode, '\0', sizeof(vitP->vit_opcode));
- } else {
- /*
- * We found a match! So lets pick up as many operands as the
- * instruction wants, and even gripe if there are too many.
- * We expect comma to seperate each operand.
- * We let instring track the text, while p tracks a part of the
- * struct vot.
- */
- /*
- * The lines below know about 2-byte opcodes starting FD,FE or FF.
- * They also understand synthetic opcodes. Note:
- * we return 32 bits of opcode, including bucky bits, BUT
- * an opcode length is either 8 or 16 bits for vit_opcode_nbytes.
- */
- oc = vwP->vot_code; /* The op-code. */
- vitP->vit_opcode_nbytes = (oc & 0xFF) >= 0xFD ? 2 : 1;
- md_number_to_chars(vitP->vit_opcode, oc, 4);
- count = 0; /* no operands seen yet */
- instring = p; /* point just past operation code */
- alloperr = "";
- for (p = vwP->vot_how, operandp = vitP->vit_operand;
- !*alloperr && !*bug && *p;
- operandp++, p += 2
- ) {
- /*
- * Here to parse one operand. Leave instring pointing just
- * past any one ',' that marks the end of this operand.
- */
- if (!p[1])
- bug = "p"; /* ODD(!!) number of bytes in vot_how?? */
- else if (*instring) {
- for (q = instring; (c = *q) && c != ','; q++)
- ;
- /*
- * Q points to ',' or '\0' that ends argument. C is that
- * character.
- */
- *q = 0;
- operandp->vop_width = p[1];
- operandp->vop_nbytes = vax_operand_width_size[p[1]];
- operandp->vop_access = p[0];
- bug = vip_op (instring, operandp);
- *q = c; /* Restore input text. */
- if (*(operandp->vop_error))
- alloperr = "Bad operand";
- instring = q + (c ? 1 : 0); /* next operand (if any) */
- count++; /* won another argument, may have an operr */
- } else
- alloperr = "Not enough operands";
- }
- if (!*alloperr) {
- if (*instring == ' ')
- instring++; /* Skip whitespace. */
- if (*instring)
- alloperr = "Too many operands";
- }
- vitP->vit_error = alloperr;
- }
- }
- vitP->vit_operands = count;
- return (bug);
-}
-
-#ifdef test
-
-/*
- * Test program for above.
- */
-
-struct vit myvit; /* build an exploded vax instruction here */
-char answer[100]; /* human types a line of vax assembler here */
-char *mybug; /* "" or an internal logic diagnostic */
-int mycount; /* number of operands */
-struct vop *myvop; /* scan operands from myvit */
-int mysynth; /* 1 means want synthetic opcodes. */
-char my_immediate[200];
-char my_indirect[200];
-char my_displen[200];
-
-char *vip ();
-
-main ()
-{
- char *p;
- char *vip_begin ();
-
- printf ("0 means no synthetic instructions. ");
- printf ("Value for vip_begin? ");
- gets (answer);
- sscanf (answer, "%d", &mysynth);
- printf ("Synthetic opcodes %s be included.\n", mysynth ? "will" : "will not");
- printf ("enter immediate symbols eg enter # ");
- gets (my_immediate);
- printf ("enter indirect symbols eg enter @ ");
- gets (my_indirect);
- printf ("enter displen symbols eg enter ^ ");
- gets (my_displen);
- if (*(p = vip_begin (mysynth, my_immediate, my_indirect, my_displen))) {
- error ("vip_begin=%s", p);
- }
- printf ("An empty input line will quit you from the vax instruction parser\n");
- for (;;) {
- printf ("vax instruction: ");
- fflush (stdout);
- gets (answer);
- if (!*answer) {
- break; /* out of for each input text loop */
- }
- mybug = vip (&myvit, answer);
- if (*mybug) {
- printf ("BUG:\"%s\"\n", mybug);
- }
- if (*myvit.vit_error) {
- printf ("ERR:\"%s\"\n", myvit.vit_error);
- }
- printf ("opcode=");
- for (mycount = myvit.vit_opcode_nbytes, p = myvit.vit_opcode;
- mycount;
- mycount--, p++
- ) {
- printf ("%02x ", *p & 0xFF);
- }
- printf (" operand count=%d.\n", mycount = myvit.vit_operands);
- for (myvop = myvit.vit_operand; mycount; mycount--, myvop++) {
- printf ("mode=%xx reg=%xx ndx=%xx len='%c'=%c%c%d. expr=\"",
- myvop->vop_mode, myvop->vop_reg, myvop->vop_ndx,
- myvop->vop_short, myvop->vop_access, myvop->vop_width,
- myvop->vop_nbytes);
- for (p = myvop->vop_expr_begin; p <= myvop->vop_expr_end; p++) {
- putchar (*p);
- }
- printf ("\"\n");
- if (*myvop->vop_error) {
- printf (" err:\"%s\"\n", myvop->vop_error);
- }
- if (*myvop->vop_warn) {
- printf (" wrn:\"%s\"\n", myvop->vop_warn);
- }
- }
- }
- vip_end ();
- exit ();
-}
-
-#endif /* #ifdef test */
-
-/* end of vax_ins_parse.c */
-
-/* JF this used to be a separate file also */
-/* vax_reg_parse.c - convert a VAX register name to a number */
-
-/* Copyright (C) 1987 Free Software Foundation, Inc. A part of GNU. */
-
-/*
- * v a x _ r e g _ p a r s e ( )
- *
- * Take 3 char.s, the last of which may be `\0` (non-existent)
- * and return the VAX register number that they represent.
- *
- * Return -1 if they don't form a register name. Good names return
- * a number from 0:15 inclusive.
- *
- * Case is not important in a name.
- *
- * Register names understood are:
- *
- * R0
- * R1
- * R2
- * R3
- * R4
- * R5
- * R6
- * R7
- * R8
- * R9
- * R10
- * R11
- * R12 AP
- * R13 FP
- * R14 SP
- * R15 PC
- *
- */
-
-#include <ctype.h>
-#define AP (12)
-#define FP (13)
-#define SP (14)
-#define PC (15)
-
-int /* return -1 or 0:15 */
- vax_reg_parse (c1, c2, c3) /* 3 chars of register name */
-char c1, c2, c3; /* c3 == 0 if 2-character reg name */
-{
- register int retval; /* return -1:15 */
-
- retval = -1;
-
- if (isupper (c1))
- c1 = tolower (c1);
- if (isupper (c2))
- c2 = tolower (c2);
- if (isdigit (c2) && c1 == 'r') {
- retval = c2 - '0';
- if (isdigit (c3)) {
- retval = retval * 10 + c3 - '0';
- retval = (retval > 15) ? -1 : retval;
- /* clamp the register value to 1 hex digit */
- } else if (c3)
- retval = -1; /* c3 must be '\0' or a digit */
- } else if (c3) /* There are no three letter regs */
- retval = -1;
- else if (c2 == 'p') {
- switch (c1) {
- case 's':
- retval = SP;
- break;
- case 'f':
- retval = FP;
- break;
- case 'a':
- retval = AP;
- break;
- default:
- retval = -1;
- }
- } else if (c1 == 'p' && c2 == 'c')
- retval = PC;
- else
- retval = -1;
- return (retval);
-}
-
-/*
- * v i p _ o p ( )
- *
- * Parse a vax operand in DEC assembler notation.
- * For speed, expect a string of whitespace to be reduced to a single ' '.
- * This is the case for GNU AS, and is easy for other DEC-compatible
- * assemblers.
- *
- * Knowledge about DEC VAX assembler operand notation lives here.
- * This doesn't even know what a register name is, except it believes
- * all register names are 2 or 3 characters, and lets vax_reg_parse() say
- * what number each name represents.
- * It does, however, know that PC, SP etc are special registers so it can
- * detect addressing modes that are silly for those registers.
- *
- * Where possible, it delivers 1 fatal or 1 warning message if the operand
- * is suspect. Exactly what we test for is still evolving.
- */
-
-/*
- * B u g s
- *
- * Arg block.
- *
- * There were a number of 'mismatched argument type' bugs to vip_op.
- * The most general solution is to typedef each (of many) arguments.
- * We used instead a typedef'd argument block. This is less modular
- * than using seperate return pointers for each result, but runs faster
- * on most engines, and seems to keep programmers happy. It will have
- * to be done properly if we ever want to use vip_op as a general-purpose
- * module (it was designed to be).
- *
- * G^
- *
- * Doesn't support DEC "G^" format operands. These always take 5 bytes
- * to express, and code as modes 8F or 9F. Reason: "G^" deprives you of
- * optimising to (say) a "B^" if you are lucky in the way you link.
- * When someone builds a linker smart enough to convert "G^" to "B^", "W^"
- * whenever possible, then we should implement it.
- * If there is some other use for "G^", feel free to code it in!
- *
- *
- * speed
- *
- * If I nested if ()s more, I could avoid testing (*err) which would save
- * time, space and page faults. I didn't nest all those if ()s for clarity
- * and because I think the mode testing can be re-arranged 1st to test the
- * commoner constructs 1st. Does anybody have statistics on this?
- *
- *
- *
- * error messages
- *
- * In future, we should be able to 'compose' error messages in a scratch area
- * and give the user MUCH more informative error messages. Although this takes
- * a little more code at run-time, it will make this module much more self-
- * documenting. As an example of what sucks now: most error messages have
- * hardwired into them the DEC VAX metacharacters "#^@" which are nothing like
- * the Un*x characters "$`*", that most users will expect from this AS.
- */
-
-/*
- * The input is a string, ending with '\0'.
- *
- * We also require a 'hint' of what kind of operand is expected: so
- * we can remind caller not to write into literals for instance.
- *
- * The output is a skeletal instruction.
- *
- * The algorithm has two parts.
- * 1. extract the syntactic features (parse off all the @^#-()+[] mode crud);
- * 2. express the @^#-()+[] as some parameters suited to further analysis.
- *
- * 2nd step is where we detect the googles of possible invalid combinations
- * a human (or compiler) might write. Note that if we do a half-way
- * decent assembler, we don't know how long to make (eg) displacement
- * fields when we first meet them (because they may not have defined values).
- * So we must wait until we know how many bits are needed for each address,
- * then we can know both length and opcodes of instructions.
- * For reason(s) above, we will pass to our caller a 'broken' instruction
- * of these major components, from which our caller can generate instructions:
- * - displacement length I^ S^ L^ B^ W^ unspecified
- * - mode (many)
- * - register R0-R15 or absent
- * - index register R0-R15 or absent
- * - expression text what we don't parse
- * - error text(s) why we couldn't understand the operand
- */
-
-/*
- * To decode output of this, test errtxt. If errtxt[0] == '\0', then
- * we had no errors that prevented parsing. Also, if we ever report
- * an internal bug, errtxt[0] is set non-zero. So one test tells you
- * if the other outputs are to be taken seriously.
- */
-
-
-/* vax registers we need to know */
-/* JF #define SP (14) */
-/* JF for one big happy file #define PC (15) */
-
-/*
- * Because this module is useful for both VMS and UN*X style assemblers
- * and because of the variety of UN*X assemblers we must recognise
- * the different conventions for assembler operand notation. For example
- * VMS says "#42" for immediate mode, while most UN*X say "$42".
- * We permit arbitrary sets of (single) characters to represent the
- * 3 concepts that DEC writes '#', '@', '^'.
- */
-
-/* character tests */
-#define VIP_IMMEDIATE 01 /* Character is like DEC # */
-#define VIP_INDIRECT 02 /* Char is like DEC @ */
-#define VIP_DISPLEN 04 /* Char is like DEC ^ */
-
-#define IMMEDIATEP(c) (vip_metacharacters[(c)&0xff]&VIP_IMMEDIATE)
-#define INDIRECTP(c) (vip_metacharacters[(c)&0xff]&VIP_INDIRECT)
-#define DISPLENP(c) (vip_metacharacters[(c)&0xff]&VIP_DISPLEN)
-
-/* We assume 8 bits per byte. Use vip_op_defaults() to set these up BEFORE we
- * are ever called.
- */
-
-#if defined(CONST_TABLE)
-#define _ 0,
-#define I VIP_IMMEDIATE,
-#define S VIP_INDIRECT,
-#define D VIP_DISPLEN,
-static const char
- vip_metacharacters[256] = {
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/* ^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O*/
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_ */
- _ _ _ _ I _ _ _ _ _ S _ _ _ _ _/* sp ! " # $ % & ' ( ) * + , - . / */
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*0 1 2 3 4 5 6 7 8 9 : ; < = > ?*/
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*@ A B C D E F G H I J K L M N O*/
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*P Q R S T U V W X Y Z [ \ ] ^ _*/
- D _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*` a b c d e f g h i j k l m n o*/
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*p q r s t u v w x y z { | } ~ ^?*/
-
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- };
-#undef _
-#undef I
-#undef S
-#undef D
-#else
-static char vip_metacharacters[256];
-
-/* Macro is faster under GCC; The constant table is faster yet, but only works with ASCII */
-#if 0
-static
-#ifdef __GNUC__
- inline
-#endif
- static void
- vip_op_1(bit,syms)
-int bit;
-char *syms;
-{
- unsigned char t;
-
- while (t= *syms++)
- vip_metacharacters[t]|=bit;
-}
-#else
-#define vip_op_1(bit,syms) { \
- unsigned char t; \
- char *table=vip_metacharacters; \
- while (t= *syms++) \
- table[t]|=bit; \
- }
-#endif
-
-static void vip_op_defaults(immediate, indirect, displen) /* can be called any time */
-char *immediate; /* Strings of characters for each job. */
-char *indirect;
-char *displen; /* more arguments may appear in future! */
-{
- vip_op_1 (VIP_IMMEDIATE, immediate);
- vip_op_1 (VIP_INDIRECT, indirect);
- vip_op_1 (VIP_DISPLEN, displen);
-
- return;
-}
-#endif
-
-
-/*
- * Dec defines the semantics of address modes (and values)
- * by a two-letter code, explained here.
- *
- * letter 1: access type
- *
- * a address calculation - no data access, registers forbidden
- * b branch displacement
- * m read - let go of bus - write back "modify"
- * r read
- * v bit field address: like 'a' but registers are OK
- * w write
- * space no operator (eg ".long foo") [our convention]
- *
- * letter 2: data type (i.e. width, alignment)
- *
- * b byte
- * d double precision floating point (D format)
- * f single precision floating point (F format)
- * g G format floating
- * h H format floating
- * l longword
- * o octaword
- * q quadword
- * w word
- * ? simple synthetic branch operand
- * - unconditional synthetic JSB/JSR operand
- * ! complex synthetic branch operand
- *
- * The '-?!' letter 2's are not for external consumption. They are used
- * for various assemblers. Generally, all unknown widths are assumed 0.
- * We don't limit your choice of width character.
- *
- * DEC operands are hard work to parse. For example, '@' as the first
- * character means indirect (deferred) mode but elswhere it is a shift
- * operator.
- * The long-winded explanation of how this is supposed to work is
- * cancelled. Read a DEC vax manual.
- * We try hard not to parse anything that MIGHT be part of the expression
- * buried in that syntax. For example if we see @...(Rn) we don't check
- * for '-' before the '(' because mode @-(Rn) does not exist.
- *
- * After parsing we have:
- *
- * at 1 if leading '@' (or Un*x '*')
- * len takes one value from " bilsw". eg B^ -> 'b'.
- * hash 1 if leading '#' (or Un*x '$')
- * expr_begin, expr_end the expression we did not parse
- * even though we don't interpret it, we make use
- * of its presence or absence.
- * sign -1: -(Rn) 0: absent +1: (Rn)+
- * paren 1 if () are around register
- * reg major register number 0:15 -1 means absent
- * ndx index register number 0:15 -1 means absent
- *
- * Again, I dare not explain it: just trace ALL the code!
- */
-
-char * /* (code here) bug message, "" = OK */
- /* our code bug, NOT bad assembly language */
- vip_op (optext, vopP)
-char *optext; /* user's input string e.g.: */
-/* "@B^foo@bar(AP)[FP]:" */
-struct vop *vopP; /* In: vop_access, vop_width. */
-/* Out: _ndx, _reg, _mode, _short, _warn, */
-/* _error _expr_begin, _expr_end, _nbytes. */
-/* vop_nbytes : number of bytes in a datum. */
-{
- char *p; /* track operand text forward */
- char *q; /* track operand text backward */
- int at; /* 1 if leading '@' ('*') seen */
- char len; /* one of " bilsw" */
- int hash; /* 1 if leading '#' ('$') seen */
- int sign = 0; /* -1, 0 or +1 */
- int paren = 0; /* 1 if () surround register */
- int reg = 0; /* register number, -1:absent */
- int ndx = 0; /* index register number -1:absent */
- char *bug; /* report any logic error in here, "" == OK */
- char *err; /* report illegal operand, "" == OK */
- /* " " is a FAKE error: means we won */
- /* ANY err that begins with ' ' is a fake. */
- /* " " is converted to "" before return */
- char *wrn; /* warn about weird modes pf address */
- char *oldq = NULL; /* preserve q in case we backup */
- int mode = 0; /* build up 4-bit operand mode here */
- /* note: index mode is in ndx, this is */
- /* the major mode of operand address */
- /*
- * Notice how we move wrong-arg-type bugs INSIDE this module: if we
- * get the types wrong below, we lose at compile time rather than at
- * lint or run time.
- */
- char access; /* vop_access. */
- char width; /* vop_width. */
-
- int vax_reg_parse (); /* returns 0:15 or -1 if not a register */
-
- access = vopP->vop_access;
- width = vopP->vop_width;
- bug = /* none of our code bugs (yet) */
- err = /* no user text errors */
- wrn = ""; /* no warnings even */
-
- p = optext;
-
- if (*p == ' ') /* Expect all whitespace reduced to ' '. */
- p++; /* skip over whitespace */
-
- if (at = INDIRECTP (*p)) { /* 1 if *p == '@'(or '*' for Un*x) */
- p++; /* at is determined */
- if (*p == ' ') /* Expect all whitespace reduced to ' '. */
- p++; /* skip over whitespace */
- }
-
- /*
- * This code is subtle. It tries to detect all legal (letter)'^'
- * but it doesn't waste time explicitly testing for premature '\0' because
- * this case is rejected as a mismatch against either (letter) or '^'.
- */
- {
- register char c;
-
- c = *p;
- if (isupper (c))
- c = tolower (c);
- if (DISPLENP (p[1]) && strchr ("bilws", len = c))
- p += 2; /* skip (letter) '^' */
- else /* no (letter) '^' seen */
- len = ' '; /* len is determined */
- }
-
- if (*p == ' ') /* Expect all whitespace reduced to ' '. */
- p++; /* skip over whitespace */
-
- if (hash = IMMEDIATEP (*p)) /* 1 if *p == '#' ('$' for Un*x) */
- p++; /* hash is determined */
-
- /*
- * p points to what may be the beginning of an expression.
- * We have peeled off the front all that is peelable.
- * We know at, len, hash.
- *
- * Lets point q at the end of the text and parse that (backwards).
- */
-
- for (q = p; *q; q++)
- ;
- q--; /* now q points at last char of text */
-
- if (*q == ' ' && q >= p) /* Expect all whitespace reduced to ' '. */
- q--;
- /* reverse over whitespace, but don't */
- /* run back over *p */
-
- /*
- * As a matter of policy here, we look for [Rn], although both Rn and S^#
- * forbid [Rn]. This is because it is easy, and because only a sick
- * cyborg would have [...] trailing an expression in a VAX-like assembler.
- * A meticulous parser would first check for Rn followed by '(' or '['
- * and not parse a trailing ']' if it found another. We just ban expressions
- * ending in ']'.
- */
- if (*q == ']') {
- while (q >= p && *q != '[')
- q--;
- /* either q<p or we got matching '[' */
- if (q < p)
- err = "no '[' to match ']'";
- else {
- /*
- * Confusers like "[]" will eventually lose with a bad register
- * name error. So again we don't need to check for early '\0'.
- */
- if (q[3] == ']')
- ndx = vax_reg_parse (q[1], q[2], 0);
- else if (q[4] == ']')
- ndx = vax_reg_parse (q[1], q[2], q[3]);
- else
- ndx = -1;
- /*
- * Since we saw a ']' we will demand a register name in the [].
- * If luser hasn't given us one: be rude.
- */
- if (ndx < 0)
- err = "bad register in []";
- else if (ndx == PC)
- err = "[PC] index banned";
- else
- q--; /* point q just before "[...]" */
- }
- } else
- ndx = -1; /* no ']', so no iNDeX register */
-
- /*
- * If err = "..." then we lost: run away.
- * Otherwise ndx == -1 if there was no "[...]".
- * Otherwise, ndx is index register number, and q points before "[...]".
- */
-
- if (*q == ' ' && q >= p) /* Expect all whitespace reduced to ' '. */
- q--;
- /* reverse over whitespace, but don't */
- /* run back over *p */
- if (!*err) {
- sign = 0; /* no ()+ or -() seen yet */
-
- if (q > p + 3 && *q == '+' && q[-1] == ')') {
- sign = 1; /* we saw a ")+" */
- q--; /* q points to ')' */
- }
-
- if (*q == ')' && q > p + 2) {
- paren = 1; /* assume we have "(...)" */
- while (q >= p && *q != '(')
- q--;
- /* either q<p or we got matching '(' */
- if (q < p)
- err = "no '(' to match ')'";
- else {
- /*
- * Confusers like "()" will eventually lose with a bad register
- * name error. So again we don't need to check for early '\0'.
- */
- if (q[3] == ')')
- reg = vax_reg_parse (q[1], q[2], 0);
- else if (q[4] == ')')
- reg = vax_reg_parse (q[1], q[2], q[3]);
- else
- reg = -1;
- /*
- * Since we saw a ')' we will demand a register name in the ')'.
- * This is nasty: why can't our hypothetical assembler permit
- * parenthesised expressions? BECAUSE I AM LAZY! That is why.
- * Abuse luser if we didn't spy a register name.
- */
- if (reg < 0) {
- /* JF allow parenthasized expressions. I hope this works */
- paren = 0;
- while (*q != ')')
- q++;
- /* err = "unknown register in ()"; */
- } else
- q--; /* point just before '(' of "(...)" */
- /*
- * If err == "..." then we lost. Run away.
- * Otherwise if reg >= 0 then we saw (Rn).
- */
- }
- /*
- * If err == "..." then we lost.
- * Otherwise paren == 1 and reg = register in "()".
- */
- } else
- paren = 0;
- /*
- * If err == "..." then we lost.
- * Otherwise, q points just before "(Rn)", if any.
- * If there was a "(...)" then paren == 1, and reg is the register.
- */
-
- /*
- * We should only seek '-' of "-(...)" if:
- * we saw "(...)" paren == 1
- * we have no errors so far ! *err
- * we did not see '+' of "(...)+" sign < 1
- * We don't check len. We want a specific error message later if
- * user tries "x^...-(Rn)". This is a feature not a bug.
- */
- if (!*err) {
- if (paren && sign < 1)/* !sign is adequate test */ {
- if (*q == '-') {
- sign = -1;
- q--;
- }
- }
- /*
- * We have back-tracked over most
- * of the crud at the end of an operand.
- * Unless err, we know: sign, paren. If paren, we know reg.
- * The last case is of an expression "Rn".
- * This is worth hunting for if !err, !paren.
- * We wouldn't be here if err.
- * We remember to save q, in case we didn't want "Rn" anyway.
- */
- if (!paren) {
- if (*q == ' ' && q >= p) /* Expect all whitespace reduced to ' '. */
- q--;
- /* reverse over whitespace, but don't */
- /* run back over *p */
- if (q > p && q < p + 3) /* room for Rn or Rnn exactly? */
- reg = vax_reg_parse (p[0], p[1], q < p + 2 ? 0 : p[2]);
- else
- reg = -1; /* always comes here if no register at all */
- /*
- * Here with a definitive reg value.
- */
- if (reg >= 0) {
- oldq = q;
- q = p - 1;
- }
- }
- }
- }
- /*
- * have reg. -1:absent; else 0:15
- */
-
- /*
- * We have: err, at, len, hash, ndx, sign, paren, reg.
- * Also, any remaining expression is from *p through *q inclusive.
- * Should there be no expression, q == p-1. So expression length = q-p+1.
- * This completes the first part: parsing the operand text.
- */
-
- /*
- * We now want to boil the data down, checking consistency on the way.
- * We want: len, mode, reg, ndx, err, p, q, wrn, bug.
- * We will deliver a 4-bit reg, and a 4-bit mode.
- */
-
- /*
- * Case of branch operand. Different. No L^B^W^I^S^ allowed for instance.
- *
- * in: at ?
- * len ?
- * hash ?
- * p:q ?
- * sign ?
- * paren ?
- * reg ?
- * ndx ?
- *
- * out: mode 0
- * reg -1
- * len ' '
- * p:q whatever was input
- * ndx -1
- * err " " or error message, and other outputs trashed
- */
- /* branch operands have restricted forms */
- if (!*err && access == 'b') {
- if (at || hash || sign || paren || ndx >= 0 || reg >= 0 || len != ' ')
- err = "invalid branch operand";
- else
- err = " ";
- }
-
- /* Since nobody seems to use it: comment this 'feature'(?) out for now. */
-#ifdef NEVER
- /*
- * Case of stand-alone operand. e.g. ".long foo"
- *
- * in: at ?
- * len ?
- * hash ?
- * p:q ?
- * sign ?
- * paren ?
- * reg ?
- * ndx ?
- *
- * out: mode 0
- * reg -1
- * len ' '
- * p:q whatever was input
- * ndx -1
- * err " " or error message, and other outputs trashed
- */
- if (!*err) {
- if (access == ' ') { /* addresses have restricted forms */
- if (at)
- err = "address prohibits @";
- else {
- if (hash)
- err = "address prohibits #";
- else {
- if (sign) {
- if (sign < 0)
- err = "address prohibits -()";
- else
- err = "address prohibits ()+";
- } else {
- if (paren)
- err = "address prohibits ()";
- else {
- if (ndx >= 0)
- err = "address prohibits []";
- else {
- if (reg >= 0)
- err = "address prohibits register";
- else {
- if (len != ' ')
- err = "address prohibits displacement length specifier";
- else {
- err = " "; /* succeed */
- mode = 0;
- }
- }
- }
- }
- }
- }
- }
- }
- }
-#endif /*#Ifdef NEVER*/
-
- /*
- * Case of S^#.
- *
- * in: at 0
- * len 's' definition
- * hash 1 demand
- * p:q demand not empty
- * sign 0 by paren == 0
- * paren 0 by "()" scan logic because "S^" seen
- * reg -1 or nn by mistake
- * ndx -1
- *
- * out: mode 0
- * reg -1
- * len 's'
- * exp
- * ndx -1
- */
- if (!*err && len == 's') {
- if (!hash || paren || at || ndx >= 0)
- err = "invalid operand of S^#";
- else {
- if (reg >= 0) {
- /*
- * SHIT! we saw S^#Rnn ! put the Rnn back in
- * expression. KLUDGE! Use oldq so we don't
- * need to know exact length of reg name.
- */
- q = oldq;
- reg = 0;
- }
- /*
- * We have all the expression we will ever get.
- */
- if (p > q)
- err = "S^# needs expression";
- else if (access == 'r') {
- err = " "; /* WIN! */
- mode = 0;
- } else
- err = "S^# may only read-access";
- }
- }
-
- /*
- * Case of -(Rn), which is weird case.
- *
- * in: at 0
- * len '
- * hash 0
- * p:q q<p
- * sign -1 by definition
- * paren 1 by definition
- * reg present by definition
- * ndx optional
- *
- * out: mode 7
- * reg present
- * len ' '
- * exp "" enforce empty expression
- * ndx optional warn if same as reg
- */
- if (!*err && sign < 0) {
- if (len != ' ' || hash || at || p <= q)
- err = "invalid operand of -()";
- else {
- err = " "; /* win */
- mode = 7;
- if (reg == PC)
- wrn = "-(PC) unpredictable";
- else if (reg == ndx)
- wrn = "[]index same as -()register: unpredictable";
- }
- }
-
- /*
- * We convert "(Rn)" to "@Rn" for our convenience.
- * (I hope this is convenient: has someone got a better way to parse this?)
- * A side-effect of this is that "@Rn" is a valid operand.
- */
- if (paren && !sign && !hash && !at && len == ' ' && p > q) {
- at = 1;
- paren = 0;
- }
-
- /*
- * Case of (Rn)+, which is slightly different.
- *
- * in: at
- * len ' '
- * hash 0
- * p:q q<p
- * sign +1 by definition
- * paren 1 by definition
- * reg present by definition
- * ndx optional
- *
- * out: mode 8+@
- * reg present
- * len ' '
- * exp "" enforce empty expression
- * ndx optional warn if same as reg
- */
- if (!*err && sign > 0) {
- if (len != ' ' || hash || p <= q)
- err = "invalid operand of ()+";
- else {
- err = " "; /* win */
- mode = 8 + (at ? 1 : 0);
- if (reg == PC)
- wrn = "(PC)+ unpredictable";
- else if (reg == ndx)
- wrn = "[]index same as ()+register: unpredictable";
- }
- }
-
- /*
- * Case of #, without S^.
- *
- * in: at
- * len ' ' or 'i'
- * hash 1 by definition
- * p:q
- * sign 0
- * paren 0
- * reg absent
- * ndx optional
- *
- * out: mode 8+@
- * reg PC
- * len ' ' or 'i'
- * exp
- * ndx optional
- */
- if (!*err && hash) {
- if (len != 'i' && len != ' ')
- err = "# conflicts length";
- else if (paren)
- err = "# bars register";
- else {
- if (reg >= 0) {
- /*
- * SHIT! we saw #Rnn! Put the Rnn back into the expression.
- * By using oldq, we don't need to know how long Rnn was.
- * KLUDGE!
- */
- q = oldq;
- reg = -1; /* no register any more */
- }
- err = " "; /* win */
-
- /* JF a bugfix, I think! */
- if (at && access == 'a')
- vopP->vop_nbytes=4;
-
- mode = (at ? 9 : 8);
- reg = PC;
- if ((access == 'm' || access == 'w') && !at)
- wrn = "writing or modifying # is unpredictable";
- }
- }
- /*
- * If !*err, then sign == 0
- * hash == 0
- */
-
- /*
- * Case of Rn. We seperate this one because it has a few special
- * errors the remaining modes lack.
- *
- * in: at optional
- * len ' '
- * hash 0 by program logic
- * p:q empty
- * sign 0 by program logic
- * paren 0 by definition
- * reg present by definition
- * ndx optional
- *
- * out: mode 5+@
- * reg present
- * len ' ' enforce no length
- * exp "" enforce empty expression
- * ndx optional warn if same as reg
- */
- if (!*err && !paren && reg >= 0) {
- if (len != ' ')
- err = "length not needed";
- else if (at) {
- err = " "; /* win */
- mode = 6; /* @Rn */
- } else if (ndx >= 0)
- err = "can't []index a register, because it has no address";
- else if (access == 'a')
- err = "a register has no address";
- else {
- /*
- * Idea here is to detect from length of datum
- * and from register number if we will touch PC.
- * Warn if we do.
- * vop_nbytes is number of bytes in operand.
- * Compute highest byte affected, compare to PC0.
- */
- if ((vopP->vop_nbytes + reg * 4) > 60)
- wrn = "PC part of operand unpredictable";
- err = " "; /* win */
- mode = 5; /* Rn */
- }
- }
- /*
- * If !*err, sign == 0
- * hash == 0
- * paren == 1 OR reg == -1
- */
-
- /*
- * Rest of cases fit into one bunch.
- *
- * in: at optional
- * len ' ' or 'b' or 'w' or 'l'
- * hash 0 by program logic
- * p:q expected (empty is not an error)
- * sign 0 by program logic
- * paren optional
- * reg optional
- * ndx optional
- *
- * out: mode 10 + @ + len
- * reg optional
- * len ' ' or 'b' or 'w' or 'l'
- * exp maybe empty
- * ndx optional warn if same as reg
- */
- if (!*err) {
- err = " "; /* win (always) */
- mode = 10 + (at ? 1 : 0);
- switch (len) {
- case 'l':
- mode += 2;
- case 'w':
- mode += 2;
- case ' ': /* assumed B^ until our caller changes it */
- case 'b':
- break;
- }
- }
-
- /*
- * here with completely specified mode
- * len
- * reg
- * expression p,q
- * ndx
- */
-
- if (*err == ' ')
- err = ""; /* " " is no longer an error */
-
- vopP->vop_mode = mode;
- vopP->vop_reg = reg;
- vopP->vop_short = len;
- vopP->vop_expr_begin = p;
- vopP->vop_expr_end = q;
- vopP->vop_ndx = ndx;
- vopP->vop_error = err;
- vopP->vop_warn = wrn;
- return (bug);
-
-} /* vip_op() */
-
-/*
-
- Summary of vip_op outputs.
-
- mode reg len ndx
- (Rn) => @Rn
- {@}Rn 5+@ n ' ' optional
- branch operand 0 -1 ' ' -1
- S^#foo 0 -1 's' -1
- -(Rn) 7 n ' ' optional
- {@}(Rn)+ 8+@ n ' ' optional
- {@}#foo, no S^ 8+@ PC " i" optional
- {@}{q^}{(Rn)} 10+@+q option " bwl" optional
-
- */
-
-#ifdef TEST /* #Define to use this testbed. */
-
-/*
- * Follows a test program for this function.
- * We declare arrays non-local in case some of our tiny-minded machines
- * default to small stacks. Also, helps with some debuggers.
- */
-
-#include <stdio.h>
-
-char answer[100]; /* human types into here */
-char *p; /* */
-char *myerr;
-char *mywrn;
-char *mybug;
-char myaccess;
-char mywidth;
-char mymode;
-char myreg;
-char mylen;
-char *myleft;
-char *myright;
-char myndx;
-int my_operand_length;
-char my_immediate[200];
-char my_indirect[200];
-char my_displen[200];
-
-main ()
-{
- char *vip_op (); /* make cc happy */
-
- printf ("enter immediate symbols eg enter # ");
- gets (my_immediate);
- printf ("enter indirect symbols eg enter @ ");
- gets (my_indirect);
- printf ("enter displen symbols eg enter ^ ");
- gets (my_displen);
- vip_op_defaults (my_immediate, my_indirect, my_displen);
- for (;;) {
- printf ("access,width (eg 'ab' or 'wh') [empty line to quit] : ");
- fflush (stdout);
- gets (answer);
- if (!answer[0])
- exit (0);
- myaccess = answer[0];
- mywidth = answer[1];
- switch (mywidth) {
- case 'b':
- my_operand_length = 1;
- break;
- case 'd':
- my_operand_length = 8;
- break;
- case 'f':
- my_operand_length = 4;
- break;
- case 'g':
- my_operand_length = 16;
- break;
- case 'h':
- my_operand_length = 32;
- break;
- case 'l':
- my_operand_length = 4;
- break;
- case 'o':
- my_operand_length = 16;
- break;
- case 'q':
- my_operand_length = 8;
- break;
- case 'w':
- my_operand_length = 2;
- break;
- case '!':
- case '?':
- case '-':
- my_operand_length = 0;
- break;
-
- default:
- my_operand_length = 2;
- printf ("I dn't understand access width %c\n", mywidth);
- break;
- }
- printf ("VAX assembler instruction operand: ");
- fflush (stdout);
- gets (answer);
- mybug = vip_op (answer, myaccess, mywidth, my_operand_length,
- &mymode, &myreg, &mylen, &myleft, &myright, &myndx,
- &myerr, &mywrn);
- if (*myerr) {
- printf ("error: \"%s\"\n", myerr);
- if (*mybug)
- printf (" bug: \"%s\"\n", mybug);
- } else {
- if (*mywrn)
- printf ("warning: \"%s\"\n", mywrn);
- mumble ("mode", mymode);
- mumble ("register", myreg);
- mumble ("index", myndx);
- printf ("width:'%c' ", mylen);
- printf ("expression: \"");
- while (myleft <= myright)
- putchar (*myleft++);
- printf ("\"\n");
- }
- }
-}
-
-mumble (text, value)
-char *text;
-int value;
-{
- printf ("%s:", text);
- if (value >= 0)
- printf ("%xx", value);
- else
- printf ("ABSENT");
- printf (" ");
-}
-
-#endif /* ifdef TEST */
-
-/* end: vip_op.c */
-
-const int md_short_jump_size = 3;
-const int md_long_jump_size = 6;
-const int md_reloc_size = 8; /* Size of relocation record */
-
-void
- md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr, to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- long offset;
-
- offset = to_addr - (from_addr + 1);
- *ptr++ = 0x31;
- md_number_to_chars(ptr, offset, 2);
-}
-
-void
- md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
-char *ptr;
-long from_addr, to_addr;
-fragS *frag;
-symbolS *to_symbol;
-{
- long offset;
-
- offset = to_addr - S_GET_VALUE(to_symbol);
- *ptr++ = 0x17;
- *ptr++ = 0x9F;
- md_number_to_chars(ptr, offset, 4);
- fix_new(frag, ptr - frag->fr_literal, 4, to_symbol, (symbolS *) 0, (long) 0, 0, NO_RELOC);
-}
-
-#ifdef OBJ_VMS
-extern char vms_name_mapping;
-#endif
-
-int
- md_parse_option (argP, cntP, vecP)
-char **argP;
-int *cntP;
-char ***vecP;
-{
- char *temp_name; /* name for -t or -d options */
- char opt;
-
- switch (**argP) {
- case 'J':
- /* as_warn ("I can do better than -J!"); */
- break;
-
- case 'S':
- as_warn ("SYMBOL TABLE not implemented");
- break; /* SYMBOL TABLE not implemented */
-
- case 'T':
- as_warn ("TOKEN TRACE not implemented");
- break; /* TOKEN TRACE not implemented */
-
- case 'd':
- case 't':
- opt= **argP;
- if (**argP) { /* Rest of argument is filename. */
- temp_name = *argP;
- while (**argP)
- (*argP)++;
- } else if (*cntP) {
- while (**argP)
- (*argP)++;
- --(*cntP);
- temp_name = *++(*vecP);
- **vecP = NULL; /* Remember this is not a file-name. */
- } else {
- as_warn ("I expected a filename after -%c.",opt);
- temp_name = "{absent}";
- }
-
- if (opt == 'd')
- as_warn ("Displacement length %s ignored!", temp_name);
- else
- as_warn ("I don't need or use temp. file \"%s\".", temp_name);
- break;
-
- case 'V':
- as_warn ("I don't use an interpass file! -V ignored");
- break;
-
-#ifdef OBJ_VMS
- case '+': /* For g++ */
- break;
-
- case '1': /* For backward compatibility */
- break;
-
- case 'h': /* No hashing of mixed-case names */
- vms_name_mapping = 0;
- (*argP)++;
- if (**argP) vms_name_mapping = *((*argP)++) - '0';
- (*argP)--;
- break;
-
- case 'H': /* Show new symbol after hash truncation */
- break;
-#endif
-
- default:
- return 0;
-
- }
- return 1;
-}
-
-/* We have no need to default values of symbols. */
-
-/* ARGSUSED */
-symbolS *
- md_undefined_symbol (name)
-char *name;
-{
- return 0;
-}
-
-/* Parse an operand that is machine-specific.
- We just return without modifying the expression if we have nothing
- to do. */
-
-/* ARGSUSED */
-void
- md_operand (expressionP)
-expressionS *expressionP;
-{
-}
-
-/* Round up a section size to the appropriate boundary. */
-long
- md_section_align (segment, size)
-segT segment;
-long size;
-{
- return size; /* Byte alignment is fine */
-}
-
-/* Exactly what point is a PC-relative offset relative TO?
- On the vax, they're relative to the address of the offset, plus
- its size. (??? Is this right? FIXME-SOON) */
-long
- md_pcrel_from (fixP)
-fixS *fixP;
-{
- return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
-}
-
-/* end of tc-vax.c */
diff --git a/gnu/usr.bin/as/config/tc-vax.h b/gnu/usr.bin/as/config/tc-vax.h
deleted file mode 100644
index f995a6c..0000000
--- a/gnu/usr.bin/as/config/tc-vax.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This file is tc-vax.h.
- */
-
-#define TC_VAX 1
-
-#define LOCAL_LABELS_FB
-#define NO_LISTING
-
- /* use this to compare against gas-1.38 */
-#ifdef OLD_GAS
-#define REVERSE_SORT_RELOCS
-#endif
-
-#define tc_aout_pre_write_hook(x) {;} /* not used */
-#define tc_crawl_symbol_chain(a) {;} /* not used */
-#define tc_headers_hook(a) {;} /* not used */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc-vax.h */
diff --git a/gnu/usr.bin/as/config/te-dpx2.h b/gnu/usr.bin/as/config/te-dpx2.h
deleted file mode 100644
index 5f358a2..0000000
--- a/gnu/usr.bin/as/config/te-dpx2.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Machine specific defines for the dpx2 machine */
-#define dpx2
-#define TC_M68K
-
-/* The magic number is not the usual MC68MAGIC. */
-#define FILE_HEADER_MAGIC MC68KBCSMAGIC
-
-/* end of te-dpx2.h */
diff --git a/gnu/usr.bin/as/config/te-generic.h b/gnu/usr.bin/as/config/te-generic.h
deleted file mode 100644
index c17f1ed..0000000
--- a/gnu/usr.bin/as/config/te-generic.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * This file is te-generic.h and is intended to be a template for
- * target environment specific header files.
- *
- * It is my intent that this file will evolve into a file suitable for config,
- * compile, and copying as an aid for testing and porting. xoxorich.
- */
-/*
- * $Id$
- */
-
-
-#define TE_GENERIC 1
-
-/* these define interfaces */
-#include "obj-format.h"
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of te-generic.h */
diff --git a/gnu/usr.bin/as/config/te-hpux.h b/gnu/usr.bin/as/config/te-hpux.h
deleted file mode 100644
index 5458df6..0000000
--- a/gnu/usr.bin/as/config/te-hpux.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Special version of <a.out.h> for use under hp-ux.
- Copyright (C) 1988, 1992 Free Software Foundation, Inc.
-
- This file is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This file 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 file; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define TE_HPUX
-
-#define HP9000S200_ID (0x20C)
-#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (HP9000S200_ID)
-
- /* hpux has "special" headers. */
-#define H_GET_HEADER_SIZE(h) (64)
-
-#include "obj-format.h"
-
-/* This stuff is from an old a.out.hpux.h. It isn't used anymore,
- (see obj-aout.c, obj_header_append) but I'm including it here for
- context. xoxorich. */
-
-#if comment
-
-/* The `exec' structure and overall layout must be close to HP's when
- we are running on an HP system, otherwise we will not be able to
- execute the resulting file. */
-
-/* Allow this file to be included twice. */
-#ifndef __GNU_EXEC_MACROS__
-
-struct exec
-{
- unsigned short a_machtype; /* machine type */
- unsigned short a_info; /* magic number */
- unsigned long a_spare1;
- unsigned long a_spare2;
- unsigned long a_text; /* length of text, in bytes */
- unsigned long a_data; /* length of data, in bytes */
- unsigned long a_bss; /* length of uninitialized data area for file, in bytes */
- unsigned long a_trsize; /* length of relocation info for text, in bytes */
- unsigned long a_drsize; /* length of relocation info for data, in bytes */
- unsigned long a_spare3; /* HP = pascal interface size */
- unsigned long a_spare4; /* HP = symbol table size */
- unsigned long a_spare5; /* HP = debug name table size */
- unsigned long a_entry; /* start address */
- unsigned long a_spare6; /* HP = source line table size */
- unsigned long a_spare7; /* HP = value table size */
- unsigned long a_syms; /* length of symbol table data in file, in bytes */
- unsigned long a_spare8;
-};
-
-/* Tell a.out.gnu.h not to define `struct exec'. */
-#define __STRUCT_EXEC_OVERRIDE__
-
-#include "a.out.gnu.h"
-
-#undef N_MAGIC
-#undef N_MACHTYPE
-#undef N_FLAGS
-#undef N_SET_INFO
-#undef N_SET_MAGIC
-#undef N_SET_MACHTYPE
-#undef N_SET_FLAGS
-
-#define N_MAGIC(exec) ((exec) . a_magic)
-#define N_MACHTYPE(exec) ((exec) . a_machtype)
-#define N_SET_MAGIC(exec, magic) (((exec) . a_magic) = (magic))
-#define N_SET_MACHTYPE(exec, machtype) (((exec) . a_machtype) = (machtype))
-
-#undef N_BADMAG
-#define N_BADMAG(x) ((_N_BADMAG (x)) || (_N_BADMACH (x)))
-
-#define _N_BADMACH(x) \
-(((N_MACHTYPE (x)) != HP9000S200_ID) && \
- ((N_MACHTYPE (x)) != HP98x6_ID))
-
-#define HP98x6_ID 0x20A
-#define HP9000S200_ID 0x20C
-
-#undef _N_HDROFF
-#define _N_HDROFF(x) (SEGMENT_SIZE - (sizeof (struct exec)))
-
-#define SEGMENT_SIZE 0x1000
-
-#endif /* __GNU_EXEC_MACROS__ */
-
-#endif /* comment */
-
-/* end of te-hpux.h */
diff --git a/gnu/usr.bin/as/config/te-i386aix.h b/gnu/usr.bin/as/config/te-i386aix.h
deleted file mode 100644
index dcadbc3..0000000
--- a/gnu/usr.bin/as/config/te-i386aix.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * This file is te-i386aix.h and is built from pieces of code from Minh Tran-Le
- * <TRANLE@INTELLICORP.COM> by rich@cygnus.com.
- */
-
-#define TE_I386AIX 1
-
-#include "obj-format.h"
-
-#define KEEP_RELOC_INFO
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 79
- * End:
- */
-
-/* end of te-i386aix.h */
diff --git a/gnu/usr.bin/as/config/te-ic960.h b/gnu/usr.bin/as/config/te-ic960.h
deleted file mode 100644
index 7a9dbe7..0000000
--- a/gnu/usr.bin/as/config/te-ic960.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* This file is twe-ic960.h
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * This file is te-ic960.h and is intended to define ic960 environment
- * specific differences.
- */
-
-#define TE_IC960 1
-
-/* intel uses host byte order for headers */
-#ifdef CROSS_COMPILE
-#undef CROSS_COMPILE
-#endif /* CROSS_COMPILE */
-
-#define OBJ_COFF_OMIT_OPTIONAL_HEADER
-#define LOCAL_LABEL(name) ( (name[0] == 'L') \
- || (name[0] == '.' \
- && (name[1] == 'C' || name[1] == 'I' || name[1] == '.')))
-#include "obj-format.h"
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of te-ic960.h */
diff --git a/gnu/usr.bin/as/config/te-sco386.h b/gnu/usr.bin/as/config/te-sco386.h
deleted file mode 100644
index da8de1d..0000000
--- a/gnu/usr.bin/as/config/te-sco386.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Machine specific defines for the SCO Unix V.3.2 ODT */
-#define scounix
-
-/* Return true if s (a non null string pointer), points to a local variable name. */
-#define LOCAL_LABEL(n) ((n)[0] == '.' && (n)[1] == 'L')
-
-/* end of te-sco386.h */
diff --git a/gnu/usr.bin/as/config/te-sequent.h b/gnu/usr.bin/as/config/te-sequent.h
deleted file mode 100644
index fbf9d9a..0000000
--- a/gnu/usr.bin/as/config/te-sequent.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * This file is te-sequent.h and is intended to set up emulation with
- * sequent's development tools.
- *
- */
-
-#define TE_SEQUENT 1
-
- /* sequent has a "special" header. */
-#define H_GET_HEADER_SIZE(h) (128)
-
-#ifdef TC_I386
- /* zmagic is 0x22eb */
-#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (0x12eb)
-#endif /* TC_I386 */
-
-#ifdef TC_NS32K
- /* zmagic is 0x10ea */
-#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (0x00ea)
-#endif /* TC_NS32K */
-
-/* these define interfaces */
-#include "obj-format.h"
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of te-sequent.h */
diff --git a/gnu/usr.bin/as/config/te-sun3.h b/gnu/usr.bin/as/config/te-sun3.h
deleted file mode 100644
index ec4d29a..0000000
--- a/gnu/usr.bin/as/config/te-sun3.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* te-sun3.h -- Sun-3 target environment declarations.
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* This header file contains the #defines specific
- to SUN computer SUN 3 series computers. (The only kind
- we have around here, unfortunatly.)
-
- Rumor has it that this file will work on the Sun-2 if the assembler
- is called with -m68010 This is not tested. */
-
-
-/* Could also be :
- #define S_LOCAL_NAME(s) (S_GET_NAME(s)[0] == '.' &&
- S_GET_NAME(s)[1] == 'L' ||
- S_GET_NAME(s)[1] == '.')
- */
-
-/* This variable contains the value to write out at the beginning of
- the a.out file. The 2<<16 means that this is a 68020 file instead
- of an old-style 68000 file */
-
-#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (2<<16|OMAGIC) /* Magic byte for file header */
-
-#include "obj-format.h"
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of te-sun3.h */
diff --git a/gnu/usr.bin/as/config/te-sysv32.h b/gnu/usr.bin/as/config/te-sysv32.h
deleted file mode 100644
index 99702fb..0000000
--- a/gnu/usr.bin/as/config/te-sysv32.h
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Remove leading underscore from the gcc generated symbol names */
-#define STRIP_UNDERSCORE
-
-/* end of te-sysv32.h */
diff --git a/gnu/usr.bin/as/config/vax-inst.h b/gnu/usr.bin/as/config/vax-inst.h
deleted file mode 100644
index 47c5ef0..0000000
--- a/gnu/usr.bin/as/config/vax-inst.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* vax-inst.h - GNU - Part of vax.c
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * This is part of vax-ins-parse.c & friends.
- * We want to parse a vax instruction text into a tree defined here.
- */
-
-#define VIT_MAX_OPERANDS (6) /* maximum number of operands in one */
-/* single vax instruction */
-
-struct vop /* vax instruction operand */
-{
- short int vop_ndx; /* -1, or index register. eg 7=[R7] */
- short int vop_reg; /* -1, or register number. eg @I^#=0xF */
- /* Helps distinguish "abs" from "abs(PC)". */
- short int vop_mode; /* addressing mode 4 bits. eg I^#=0x9 */
- char vop_short; /* operand displacement length as written */
- /* ' '=none, "bilsw"=B^I^L^S^W^. */
- char vop_access; /* 'b'branch ' 'no-instruction 'amrvw'norm */
- char vop_width; /* Operand width, one of "bdfghloqw" */
- char *vop_warn; /* warning message of this operand, if any */
- char *vop_error; /* say if operand is inappropriate */
- char *vop_expr_begin; /* Unparsed expression, 1st char ... */
- char *vop_expr_end; /* ... last char. */
- unsigned char vop_nbytes; /* number of bytes in datum */
-};
-
-
-typedef long vax_opcodeT; /* For initialising array of opcodes */
-/* Some synthetic opcodes > 16 bits! */
-
-#define VIT_OPCODE_SYNTHETIC 0x80000000 /* Not real hardware instruction. */
-#define VIT_OPCODE_SPECIAL 0x40000000 /* Not normal branch optimising. */
-/* Never set without ..._SYNTHETIC */
-
-#define VAX_WIDTH_UNCONDITIONAL_JUMP '-' /* These are encoded into */
-#define VAX_WIDTH_CONDITIONAL_JUMP '?' /* vop_width when vop_access == 'b' */
-#define VAX_WIDTH_WORD_JUMP '!' /* and VIT_OPCODE_SYNTHETIC set. */
-#define VAX_WIDTH_BYTE_JUMP ':' /* */
-
-#define VAX_JMP (0x17) /* Useful for branch optimising. Jump instr*/
-#define VAX_PC_RELATIVE_MODE (0xef) /* Use it after VAX_JMP */
-#define VAX_ABSOLUTE_MODE (0x9F) /* Use as @#... */
-#define VAX_BRB (0x11) /* Canonical branch. */
-#define VAX_BRW (0x31) /* Another canonical branch */
-#define VAX_WIDEN_WORD (0x20) /* Add this to byte branch to get word br. */
-#define VAX_WIDEN_LONG (0x6) /* Add this to byte branch to get long jmp.*/
-/* Needs VAX_PC_RELATIVE_MODE byte after it*/
-
-struct vit /* vax instruction tree */
-{
- /* vit_opcode is char[] for portability. */
- char vit_opcode[ sizeof (vax_opcodeT) ];
- unsigned char vit_opcode_nbytes; /* How long is _opcode? (chars) */
- unsigned char vit_operands;/* */
- struct vop vit_operand[VIT_MAX_OPERANDS]; /* operands */
- char * vit_error; /* "" or error text */
-};
-
-/* end of vax-inst.h */
diff --git a/gnu/usr.bin/as/configdos.bat b/gnu/usr.bin/as/configdos.bat
deleted file mode 100644
index 18331cd..0000000
--- a/gnu/usr.bin/as/configdos.bat
+++ /dev/null
@@ -1,14 +0,0 @@
-@echo off
-echo Configuring GAS for H8/300
-
-copy config\ho-go32.h host.h
-copy config\tc-h8300.c targ-cpu.c
-copy config\tc-h8300.h targ-cpu.h
-copy config\te-generic.h targ-env.h
-copy config\objcoff-bfd.h obj-format.h
-copy config\objcoff-bfd.c obj-format.c
-copy config\atof-ieee.c atof-targ.c
-
-copy Makefile.dos Makefile
-
-
diff --git a/gnu/usr.bin/as/configure.in b/gnu/usr.bin/as/configure.in
deleted file mode 100755
index 52f4b29..0000000
--- a/gnu/usr.bin/as/configure.in
+++ /dev/null
@@ -1,204 +0,0 @@
-# This file is configure.in
-#
-# Copyright (C) 1987-1992 Free Software Foundation, Inc.
-#
-# This file is part of GAS, the GNU Assembler.
-#
-# GAS 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.
-#
-# GAS 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 GAS; see the file COPYING. If not, write to
-# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-#
-
-# This file is a shell script that supplies the information necessary
-# to tailor a template configure script into the configure script
-# appropriate for this directory. For more information, check any
-# existing configure script.
-
-srctrigger=as.c
-srcname="gas"
-need_bfd=
-configdirs=doc
-
-# per-host:
-
-gas_host=generic
-
-case "${host_cpu}" in
-a29k | rs6000 | vax)
- case "${host_os}" in
- vms*) gas_host=vms ;;
- *) gas_host=${host_cpu} ;;
- esac
- ;;
-mips)
- case "${host_os}" in
- ultrix) gas_host=decstation ;;
- esac
- ;;
-i386)
- case "${host_os}" in
- aix*) gas_host=i386aix ;;
- sysv4*)
- gas_host=i386
- host_makefile_frag=config/ho-i386v4
- ;;
- esac
- ;;
-*)
- case "${host_os}" in
- ansi | ultrix | hpux | sysv*) gas_host=${host_os} ;;
- *)
- case "${host_vendor}" in
- sun)
- case "${host_cpu}" in
- m68k) gas_host=sun3 ;;
- i386) gas_host=sun386 ;;
- sparc) gas_host=sun4 ;;
- esac
- ;;
- esac
- ;;
- esac
- ;;
-esac
-
-# per-target:
-
-# assign cpu type
-environment=generic
-
-cpu_type=${target_cpu}
-
-# assign object format
-case ${target_os} in
-aix*)
- case "${target_cpu}" in
- i386) obj_format=coff
- target_cpu=i386aix
- environment=i386aix
- ;;
- esac
- ;;
-
-bout*) obj_format=bout ;;
-nindy*) obj_format=bout ;;
-bsd* | sunos*)
- obj_format=aout
- case "${target_cpu}" in
- m68k) environment=sun3 ;;
- i386 | ns32k)
- case "${target_vendor}" in
- sequent) environment=${target_vendor} ;;
- esac
- esac
- ;;
-
-ebmon-old)
- obj_format=coff
- need_bfd="$(unsubdir)/../bfd$(subdir)/libbfd.a"
- target_cpu=ebmon29k
- ;;
-
-ebmon)
- obj_format=coffbfd
- need_bfd="$(unsubdir)/../bfd$(subdir)/libbfd.a"
- target_cpu=ebmon29k
- ;;
-
-generic) obj_format=generic ;;
-
-hms)
- obj_format=coffbfd
- need_bfd="$(unsubdir)/../bfd$(subdir)/libbfd.a"
- ;;
-
-hpux)
- obj_format=aout
- environment=hpux
- ;;
-
-sysv32)
- obj_format=coff
- environment=sysv32
- ;;
-
-vms)
- obj_format=vms
- ;;
-
-coff* | sysv*)
- obj_format=coff
-
- case ${target_vendor} in
- bull) environment=dpx2 ;;
- sco) environment=sco386 ;;
- sun) environment=sun3 ;;
- *)
- esac
- ;;
-vxworks)
- case ${target_cpu} in
- i960) obj_format=bout ;;
- *) obj_format=aout ;;
- esac
- ;;
-*)
- case ${target_vendor} in
- aout) obj_format=aout ;;
- bout) obj_format=bout ;;
- coff)
- obj_format=coff
- case ${target_cpu} in
- i960) environment=ic960 ;;
- esac
- ;;
- sequent)
- obj_format=aout
- environment=sequent
- ;;
- *) obj_format=aout ;;
- esac
- ;;
-
-esac
-
-# assign floating point type
-case ${target_cpu} in
-ns32k) atof=ns32k ;;
-tahoe) atof=tahoe ;;
-vax) atof=vax ;;
-*) atof=ieee ;;
-esac
-
-# and target makefile frag
-
-target_makefile_frag=config/mt-${target_cpu}
-
-files="config/ho-${gas_host}.h config/tc-${cpu_type}.c \
- config/tc-${cpu_type}.h config/te-${environment}.h \
- config/obj-${obj_format}.h config/obj-${obj_format}.c \
- config/atof-${atof}.c"
-
-links="host.h targ-cpu.c targ-cpu.h targ-env.h obj-format.h obj-format.c atof-targ.c"
-
-# post-target:
-
-if [ ${target_alias} != ${host_alias} ] ; then
- echo INTERNAL_CFLAGS=-DCROSS_COMPILE > Makefile.tem
- cat Makefile >> Makefile.tem
- mv Makefile.tem Makefile
-else
- true
-fi
-
-# end of gas/configure.in
diff --git a/gnu/usr.bin/as/debug.c b/gnu/usr.bin/as/debug.c
deleted file mode 100644
index dd39b96..0000000
--- a/gnu/usr.bin/as/debug.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/* This file is debug.c
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Routines for debug use only. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "as.h"
-#include "subsegs.h"
-
-dmp_frags()
-{
- frchainS *chp;
- char *p;
-
- for ( chp=frchain_root; chp; chp = chp->frch_next ){
- switch ( chp->frch_seg ){
- case SEG_DATA:
- p ="Data";
- break;
- case SEG_TEXT:
- p ="Text";
- break;
- default:
- p ="???";
- break;
- }
- printf("\nSEGMENT %s %d\n", p, chp->frch_subseg);
- dmp_frag( chp->frch_root,"\t");
- }
-}
-
-dmp_frag( fp, indent )
- struct frag *fp;
- char *indent;
-{
- for ( ; fp; fp = fp->fr_next ){
- printf("%sFRAGMENT @ 0x%x\n", indent, fp);
- switch( fp->fr_type ){
- case rs_align:
- printf("%srs_align(%d)\n",indent, fp->fr_offset);
- break;
- case rs_fill:
- printf("%srs_fill(%d)\n",indent, fp->fr_offset);
- printf("%s", indent);
- var_chars( fp, fp->fr_var + fp->fr_fix );
- printf("%s\t repeated %d times,",
- indent, fp->fr_offset);
- printf(" fixed length if # chars == 0)\n");
- break;
- case rs_org:
- printf("%srs_org(%d+sym @0x%x)\n",indent,
- fp->fr_offset, fp->fr_symbol);
- printf("%sfill with ",indent);
- var_chars( fp, 1 );
- printf("\n");
- break;
- case rs_machine_dependent:
- printf("%smachine_dep\n",indent);
- break;
- default:
- printf("%sunknown type\n",indent);
- break;
- }
- printf("%saddr=%d(0x%x)\n",indent,fp->fr_address,fp->fr_address);
- printf("%sfr_fix=%d\n",indent,fp->fr_fix);
- printf("%sfr_var=%d\n",indent,fp->fr_var);
- printf("%sfr_offset=%d\n",indent,fp->fr_offset);
- printf("%schars @ 0x%x\n",indent,fp->fr_literal);
- printf("\n");
- }
-}
-
-var_chars( fp, n )
- struct frag *fp;
- int n;
-{
- unsigned char *p;
-
- for ( p=(unsigned char*)fp->fr_literal; n; n-- , p++ ){
- printf("%02x ", *p );
- }
-}
-
-/* end of debug.c */
diff --git a/gnu/usr.bin/as/doc/Makefile b/gnu/usr.bin/as/doc/Makefile
deleted file mode 100644
index 45f2210..0000000
--- a/gnu/usr.bin/as/doc/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-INFO = as-all
-INFOSECTION= "Programming & development tools."
-INFOENTRY_as-all= "* AS: (as-all). The GNU Assembler manual."
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/as/doc/as-all.texinfo b/gnu/usr.bin/as/doc/as-all.texinfo
deleted file mode 100644
index bc4779b..0000000
--- a/gnu/usr.bin/as/doc/as-all.texinfo
+++ /dev/null
@@ -1,4995 +0,0 @@
-
-
-\input texinfo @c -*-Texinfo-*-
-@c Copyright (c) 1991 1992 Free Software Foundation, Inc.
-@c %**start of header
-@setfilename as.info
-@settitle Using as
-@setchapternewpage odd
-@c @smallbook
-@c @cropmarks
-@c %**end of header
-
-@finalout
-@syncodeindex ky cp
-
-@c
-@ifinfo
-This file documents the GNU Assembler "as".
-
-Copyright (C) 1991 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-@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
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that the
-section entitled ``GNU General Public License'' is included exactly as
-in the original, and provided that the entire resulting derived work is
-distributed under the terms of a permission notice identical to this
-one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions,
-except that the section entitled ``GNU General Public License'' may be
-included in a translation approved by the Free Software Foundation
-instead of in the original English.
-@end ifinfo
-
-@titlepage
-@title Using as
-@subtitle The GNU Assembler
-@sp 1
-@subtitle January 1992
-@sp 1
-@sp 13
-The Free Software Foundation Inc. thanks The Nice Computer
-Company of Australia for loaning Dean Elsner to write the
-first (Vax) version of @code{as} for Project GNU.
-The proprietors, management and staff of TNCCA thank FSF for
-distracting the boss while they got some work
-done.
-@sp 3
-@author Dean Elsner, Jay Fenlason & friends
-@c edited by: pesch@cygnus.com
-@page
-@tex
-\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
-\xdef\manvers{\$Revision: 1.1 $} % For use in headers, footers too
-{\parskip=0pt
-\hfill \manvers\par
-\hfill \TeX{}info \texinfoversion\par
-}
-%"boxit" macro for figures:
-%Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3)
-\gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt
- \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil
-#2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline
-\gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box
-@end tex
-
-Edited by Roland Pesch for Cygnus Support.
-
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1991 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that the
-section entitled ``GNU General Public License'' is included exactly as
-in the original, and provided that the entire resulting derived work is
-distributed under the terms of a permission notice identical to this
-one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions,
-except that the section entitled ``GNU General Public License'' may be
-included in a translation approved by the Free Software Foundation
-instead of in the original English.
-@end titlepage
-@page
-@node Top, Overview, (dir), (dir)
-@ifinfo
-This file is a user guide to the GNU assembler @code{as}.
-@end ifinfo
-@menu
-* Overview:: Overview
-* Invoking:: Command-Line Options
-* Syntax:: Syntax
-* Sections:: Sections and Relocation
-* Symbols:: Symbols
-* Expressions:: Expressions
-* Pseudo Ops:: Assembler Directives
-* Machine Dependent:: Machine Dependent Features
-* Copying:: GNU GENERAL PUBLIC LICENSE
-* Index:: Index
-@end menu
-
-@node Overview, Invoking, Top, Top
-@chapter Overview
-@iftex
-This manual is a user guide to the GNU assembler @code{as}.
-@end iftex
-
-@cindex invocation summary
-@cindex option summary
-@cindex summary of options
-Here is a brief summary of how to invoke @code{as}. For details,
-@pxref{Invoking,,Comand-Line Options}.
-
-@c We don't use deffn and friends for the following because they seem
-@c to be limited to one line for the header.
-@smallexample
- as [ -a | -al | -as ] [ -D ] [ -f ]
- [ -I @var{path} ] [ -k ] [ -L ]
- [ -o @var{objfile} ] [ -R ] [ -v ] [ -w ]
-@c am29k has no machine-dependent assembler options
-@c h8/300 has no machine-dependent assembler options
-@c see md_parse_option in i960.c
- [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ]
- [ -b ] [ -norelax ]
- [ -l ] [ -mc68000 | -mc68010 | -mc68020 ]
- [ -- | @var{files} @dots{} ]
-@end smallexample
-
-@table @code
-@item -a | -al | -as
-Turn on assembly listings; @samp{-al}, listing only, @samp{-as}, symbols
-only, @samp{-a}, everything.
-
-@item -D
-This option is accepted only for script compatibility with calls to
-other assemblers; it has no effect on @code{as}.
-
-@item -f
-``fast''---skip preprocessing (assume source is compiler output)
-
-@item -I @var{path}
-Add @var{path} to the search list for @code{.include} directives
-
-@item -k
-Issue warnings when difference tables altered for long displacements.
-
-@item -L
-Keep (in symbol table) local symbols, starting with @samp{L}
-
-@item -o @var{objfile}
-Name the object-file output from @code{as}
-
-@item -R
-Fold data section into text section
-
-@item -v
-Announce @code{as} version
-
-@item -W
-Suppress warning messages
-
-@item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
-(When configured for Intel 960).
-Specify which variant of the 960 architecture is the target.
-
-@item -b
-(When configured for Intel 960).
-Add code to collect statistics about branches taken.
-
-@item -norelax
-(When configured for Intel 960).
-Do not alter compare-and-branch instructions for long displacements;
-error if necessary.
-
-@item -l
-(When configured for Motorola 68000).
-Shorten references to undefined symbols, to one word instead of two
-
-@item -mc68000 | -mc68010 | -mc68020
-(When configured for Motorola 68000).
-Specify what processor in the 68000 family is the target (default 68020)
-
-@item -- | @var{files} @dots{}
-Standard input, or source files to assemble
-@end table
-
-@menu
-* Manual:: Structure of this Manual
-* GNU Assembler:: as, the GNU Assembler
-* Object Formats:: Object File Formats
-* Command Line:: Command Line
-* Input Files:: Input Files
-* Object:: Output (Object) File
-* Errors:: Error and Warning Messages
-@end menu
-
-@node Manual, GNU Assembler, Overview, Overview
-@section Structure of this Manual
-
-@cindex manual, structure and purpose
-This manual is intended to describe what you need to know to use
-@sc{gnu} @code{as}. We cover the syntax expected in source files, including
-notation for symbols, constants, and expressions; the directives that
-@code{as} understands; and of course how to invoke @code{as}.
-
-This manual also describes some of the machine-dependent features of
-various flavors of the assembler.
-@refill
-
-@cindex machine instructions (not covered)
-On the other hand, this manual is @emph{not} intended as an introduction
-to programming in assembly language---let alone programming in general!
-In a similar vein, we make no attempt to introduce the machine
-architecture; we do @emph{not} describe the instruction set, standard
-mnemonics, registers or addressing modes that are standard to a
-particular architecture.
-You may want to consult the manufacturer's
-machine architecture manual for this information.
-
-
-@c I think this is premature---pesch@cygnus.com, 17jan1991
-@ignore
-Throughout this manual, we assume that you are running @dfn{GNU},
-the portable operating system from the @dfn{Free Software
-Foundation, Inc.}. This restricts our attention to certain kinds of
-computer (in particular, the kinds of computers that GNU can run on);
-once this assumption is granted examples and definitions need less
-qualification.
-
-@code{as} is part of a team of programs that turn a high-level
-human-readable series of instructions into a low-level
-computer-readable series of instructions. Different versions of
-@code{as} are used for different kinds of computer.
-@end ignore
-
-@c There used to be a section "Terminology" here, which defined
-@c "contents", "byte", "word", and "long". Defining "word" to any
-@c particular size is confusing when the .word directive may generate 16
-@c bits on one machine and 32 bits on another; in general, for the user
-@c version of this manual, none of these terms seem essential to define.
-@c They were used very little even in the former draft of the manual;
-@c this draft makes an effort to avoid them (except in names of
-@c directives).
-
-@node GNU Assembler, Object Formats, Manual, Overview
-@section as, the GNU Assembler
-
-GNU @code{as} is really a family of assemblers.
-If you use (or have used) the GNU assembler on one architecture, you
-should find a fairly similar environment when you use it on another
-architecture. Each version has much in common with the others,
-including object file formats, most assembler directives (often called
-@dfn{pseudo-ops)} and assembler syntax.@refill
-
-@cindex purpose of @sc{gnu} @code{as}
-@code{as} is primarily intended to assemble the output of the GNU C
-compiler @code{gcc} for use by the linker @code{ld}. Nevertheless,
-we've tried to make @code{as} assemble correctly everything that the native
-assembler would.
-Any exceptions are documented explicitly (@pxref{Machine Dependent}).
-This doesn't mean @code{as} always uses the same syntax as another
-assembler for the same architecture; for example, we know of several
-incompatible versions of 680x0 assembly language syntax.
-
-Unlike older assemblers, @code{as} is designed to assemble a source
-program in one pass of the source file. This has a subtle impact on the
-@kbd{.org} directive (@pxref{Org,,@code{.org}}).
-
-@node Object Formats, Command Line, GNU Assembler, Overview
-@section Object File Formats
-
-@cindex object file format
-The GNU assembler can be configured to produce several alternative
-object file formats. For the most part, this does not affect how you
-write assembly language programs; but directives for debugging symbols
-are typically different in different file formats. @xref{Symbol
-Attributes,,Symbol Attributes}.
-
-@node Command Line, Input Files, Object Formats, Overview
-@section Command Line
-
-@cindex command line conventions
-After the program name @code{as}, the command line may contain
-options and file names. Options may appear in any order, and may be
-before, after, or between file names. The order of file names is
-significant.
-
-@cindex standard input, as input file
-@kindex --
-@file{--} (two hyphens) by itself names the standard input file
-explicitly, as one of the files for @code{as} to assemble.
-
-@cindex options, command line
-Except for @samp{--} any command line argument that begins with a
-hyphen (@samp{-}) is an option. Each option changes the behavior of
-@code{as}. No option changes the way another option works. An
-option is a @samp{-} followed by one or more letters; the case of
-the letter is important. All options are optional.
-
-Some options expect exactly one file name to follow them. The file
-name may either immediately follow the option's letter (compatible
-with older assemblers) or it may be the next command argument (GNU
-standard). These two command lines are equivalent:
-
-@smallexample
-as -o my-object-file.o mumble.s
-as -omy-object-file.o mumble.s
-@end smallexample
-
-@node Input Files, Object, Command Line, Overview
-@section Input Files
-
-@cindex input
-@cindex source program
-@cindex files, input
-We use the phrase @dfn{source program}, abbreviated @dfn{source}, to
-describe the program input to one run of @code{as}. The program may
-be in one or more files; how the source is partitioned into files
-doesn't change the meaning of the source.
-
-@c I added "con" prefix to "catenation" just to prove I can overcome my
-@c APL training... pesch@cygnus.com
-The source program is a concatenation of the text in all the files, in the
-order specified.
-
-Each time you run @code{as} it assembles exactly one source
-program. The source program is made up of one or more files.
-(The standard input is also a file.)
-
-You give @code{as} a command line that has zero or more input file
-names. The input files are read (from left file name to right). A
-command line argument (in any position) that has no special meaning
-is taken to be an input file name.
-
-If you give @code{as} no file names it attempts to read one input file
-from the @code{as} standard input, which is normally your terminal. You
-may have to type @key{ctl-D} to tell @code{as} there is no more program
-to assemble.
-
-Use @samp{--} if you need to explicitly name the standard input file
-in your command line.
-
-If the source is empty, @code{as} will produce a small, empty object
-file.
-
-@subheading Filenames and Line-numbers
-
-@cindex input file linenumbers
-@cindex line numbers, in input files
-There are two ways of locating a line in the input file (or files) and
-either may be used in reporting error messages. One way refers to a line
-number in a physical file; the other refers to a line number in a
-``logical'' file. @xref{Errors, ,Error and Warning Messages}.
-
-@dfn{Physical files} are those files named in the command line given
-to @code{as}.
-
-@dfn{Logical files} are simply names declared explicitly by assembler
-directives; they bear no relation to physical files. Logical file names
-help error messages reflect the original source file, when @code{as}
-source is itself synthesized from other files.
-@xref{App-File,,@code{.app-file}}.
-
-@node Object, Errors, Input Files, Overview
-@section Output (Object) File
-
-@cindex object file
-@cindex output file
-@kindex a.out
-@kindex .o
-Every time you run @code{as} it produces an output file, which is
-your assembly language program translated into numbers. This file
-is the object file, named @code{a.out} unless you tell @code{as} to
-give it another name by using the @code{-o} option. Conventionally,
-object file names end with @file{.o}. The default name of
-@file{a.out} is used for historical reasons: older assemblers were
-capable of assembling self-contained programs directly into a
-runnable program.
-@c This may still work, but hasn't been tested.
-
-@cindex linker
-@kindex ld
-The object file is meant for input to the linker @code{ld}. It contains
-assembled program code, information to help @code{ld} integrate
-the assembled program into a runnable file, and (optionally) symbolic
-information for the debugger.
-
-@c link above to some info file(s) like the description of a.out.
-@c don't forget to describe GNU info as well as Unix lossage.
-
-@node Errors, , Object, Overview
-@section Error and Warning Messages
-
-@cindex error messsages
-@cindex warning messages
-@cindex messages from @code{as}
-@code{as} may write warnings and error messages to the standard error
-file (usually your terminal). This should not happen when a compiler
-runs @code{as} automatically. Warnings report an assumption made so
-that @code{as} could keep assembling a flawed program; errors report a
-grave problem that stops the assembly.
-
-@cindex format of warning messages
-Warning messages have the format
-
-@smallexample
-file_name:@b{NNN}:Warning Message Text
-@end smallexample
-
-@noindent
-@cindex line numbers, in warnings/errors
-(where @b{NNN} is a line number). If a logical file name has
-been given (@pxref{App-File,,@code{.app-file}}) it is used for the filename, otherwise the
-name of the current input file is used. If a logical line number was
-given
-(@pxref{Ln,,@code{.ln}})
-then it is used to calculate the number printed,
-otherwise the actual line in the current source file is printed. The
-message text is intended to be self explanatory (in the grand Unix
-tradition). @refill
-
-@cindex format of error messages
-Error messages have the format
-@smallexample
-file_name:@b{NNN}:FATAL:Error Message Text
-@end smallexample
-The file name and line number are derived as for warning
-messages. The actual message text may be rather less explanatory
-because many of them aren't supposed to happen.
-
-@node Invoking, Syntax, Overview, Top
-@chapter Command-Line Options
-
-@cindex options, all versions of @code{as}
-This chapter describes command-line options available in @emph{all}
-versions of the GNU assembler; @pxref{Machine Dependent}, for options specific
-to particular machine architectures.
-
-@section Enable Listings: @code{-a}, @code{-al}, @code{-as}
-
-@kindex -a
-@kindex -al
-@kindex -as
-@cindex listings, enabling
-@cindex assembly listings, enabling
-These options enable listing output from the assembler. @samp{-a} by
-itself requests all listing output; @samp{-al} requests only the
-output-program listing, and @samp{-as} requests only a symbol table
-listing.
-
-Once you have specified one of these options, you can further control
-listing output and its appearance using the directives @code{.list},
-@code{.nolist}, @code{.psize}, @code{.eject}, @code{.title}, and
-@code{.sbttl}.
-
-If you do not request listing output with one of the @samp{-a} options, the
-listing-control directives have no effect.
-
-@section @code{-D}
-
-@kindex -D
-This option has no effect whatsoever, but it is accepted to make it more
-likely that scripts written for other assemblers will also work with
-@code{as}.
-
-@section Work Faster: @code{-f}
-
-@kindex -f
-@cindex trusted compiler
-@cindex faster processing (@code{-f})
-@samp{-f} should only be used when assembling programs written by a
-(trusted) compiler. @samp{-f} stops the assembler from pre-processing
-the input file(s) before assembling them. @xref{Pre-processing,
-,Pre-processing}.
-
-@quotation
-@emph{Warning:} if the files actually need to be pre-processed (if they
-contain comments, for example), @code{as} will not work correctly if
-@samp{-f} is used.
-@end quotation
-
-@section @code{.include} search path: @code{-I} @var{path}
-
-@kindex -I @var{path}
-@cindex paths for @code{.include}
-@cindex search path for @code{.include}
-@cindex @code{include} directive search path
-Use this option to add a @var{path} to the list of directories
-@code{as} will search for files specified in @code{.include}
-directives (@pxref{Include,,@code{.include}}). You may use @code{-I} as
-many times as necessary to include a variety of paths. The current
-working directory is always searched first; after that, @code{as}
-searches any @samp{-I} directories in the same order as they were
-specified (left to right) on the command line.
-
-@section Difference Tables: @code{-k}
-
-@kindex -k
-
-@cindex difference tables, warning
-@cindex warning for altered difference tables
-@code{as} sometimes alters the code emitted for directives of the form
-@samp{.word @var{sym1}-@var{sym2}}; @pxref{Word,,@code{.word}}.
-You can use the @samp{-k} option if you want a warning issued when this
-is done.
-
-@section Include Local Labels: @code{-L}
-
-@kindex -L
-@cindex local labels, retaining in output
-Labels beginning with @samp{L} (upper case only) are called @dfn{local
-labels}. @xref{Symbol Names}. Normally you don't see such labels when
-debugging, because they are intended for the use of programs (like
-compilers) that compose assembler programs, not for your notice.
-Normally both @code{as} and @code{ld} discard such labels, so you don't
-normally debug with them.
-
-This option tells @code{as} to retain those @samp{L@dots{}} symbols
-in the object file. Usually if you do this you also tell the linker
-@code{ld} to preserve symbols whose names begin with @samp{L}.
-
-@section Name the Object File: @code{-o}
-
-@kindex -o
-@cindex naming object file
-@cindex object file name
-There is always one object file output when you run @code{as}. By
-default it has the name @file{a.out}. You use this option (which
-takes exactly one filename) to give the object file a different name.
-
-Whatever the object file is called, @code{as} will overwrite any
-existing file of the same name.
-
-@section Join Data and Text Sections: @code{-R}
-
-@kindex -R
-@cindex data and text sections, joining
-@cindex text and data sections, joining
-@cindex joining text and data sections
-@cindex merging text and data sections
-@code{-R} tells @code{as} to write the object file as if all
-data-section data lives in the text section. This is only done at
-the very last moment: your binary data are the same, but data
-section parts are relocated differently. The data section part of
-your object file is zero bytes long because all it bytes are
-appended to the text section. (@xref{Sections,,Sections and Relocation}.)
-
-When you specify @code{-R} it would be possible to generate shorter
-address displacements (because we don't have to cross between text and
-data section). We refrain from doing this simply for compatibility with
-older versions of @code{as}. In future, @code{-R} may work this way.
-
-When @code{as} is configured for COFF output,
-this option is only useful if you use sections named @samp{.text} and
-@samp{.data}.
-
-@section Announce Version: @code{-v}
-
-@kindex -v
-@kindex -version
-@cindex @code{as} version
-@cindex version of @code{as}
-You can find out what version of as is running by including the
-option @samp{-v} (which you can also spell as @samp{-version}) on the
-command line.
-
-@section Suppress Warnings: @code{-W}
-
-@kindex -W
-@cindex suppressing warnings
-@cindex warnings, suppressing
-@code{as} should never give a warning or error message when
-assembling compiler output. But programs written by people often
-cause @code{as} to give a warning that a particular assumption was
-made. All such warnings are directed to the standard error file.
-If you use this option, no warnings are issued. This option only
-affects the warning messages: it does not change any particular of how
-@code{as} assembles your file. Errors, which stop the assembly, are
-still reported.
-
-@node Syntax, Sections, Invoking, Top
-@chapter Syntax
-
-@cindex machine-independent syntax
-@cindex syntax, machine-independent
-This chapter describes the machine-independent syntax allowed in a
-source file. @code{as} syntax is similar to what many other assemblers
-use; it is inspired in BSD 4.2
-assembler, except that @code{as} does not assemble Vax bit-fields.
-
-@menu
-* Pre-processing:: Pre-processing
-* Whitespace:: Whitespace
-* Comments:: Comments
-* Symbol Intro:: Symbols
-* Statements:: Statements
-* Constants:: Constants
-@end menu
-
-@node Pre-processing, Whitespace, Syntax, Syntax
-@section Pre-Processing
-
-@cindex preprocessing
-The pre-processor:
-@itemize @bullet
-@cindex whitespace, removed by preprocessor
-@item
-adjusts and removes extra whitespace. It leaves one space or tab before
-the keywords on a line, and turns any other whitespace on the line into
-a single space.
-
-@cindex comments, removed by preprocessor
-@item
-removes all comments, replacing them with a single space, or an
-appropriate number of newlines.
-
-@cindex constants, converted by preprocessor
-@item
-converts character constants into the appropriate numeric values.
-@end itemize
-
-Excess whitespace, comments, and character constants
-cannot be used in the portions of the input text that are not
-pre-processed.
-
-@cindex turning preprocessing on and off
-@cindex preprocessing, turning on and off
-@kindex #NO_APP
-@kindex #APP
-If the first line of an input file is @code{#NO_APP} or the @samp{-f}
-option is given, the input file will not be pre-processed. Within such
-an input file, parts of the file can be pre-processed by putting a line
-that says @code{#APP} before the text that should be pre-processed, and
-putting a line that says @code{#NO_APP} after them. This feature is
-mainly intend to support @code{asm} statements in compilers whose output
-normally does not need to be pre-processed.
-
-@node Whitespace, Comments, Pre-processing, Syntax
-@section Whitespace
-
-@cindex whitespace
-@dfn{Whitespace} is one or more blanks or tabs, in any order.
-Whitespace is used to separate symbols, and to make programs neater for
-people to read. Unless within character constants
-(@pxref{Characters,,Character Constants}), any whitespace means the same
-as exactly one space.
-
-@node Comments, Symbol Intro, Whitespace, Syntax
-@section Comments
-
-@cindex comments
-There are two ways of rendering comments to @code{as}. In both
-cases the comment is equivalent to one space.
-
-Anything from @samp{/*} through the next @samp{*/} is a comment.
-This means you may not nest these comments.
-
-@smallexample
-/*
- The only way to include a newline ('\n') in a comment
- is to use this sort of comment.
-*/
-
-/* This sort of comment does not nest. */
-@end smallexample
-
-@cindex line comment character
-Anything from the @dfn{line comment} character to the next newline
-is considered a comment and is ignored. The line comment character is
-@samp{#} on the Vax;
-@samp{#} on the i960;
-@samp{|} on the 680x0;
-@samp{;} for the AMD 29K family;
-@samp{;} for the machine specific family;
-@pxref{Machine Dependent}. @refill
-@c FIXME: fill in SPARC line comment char
-
-On some machines there are two different line comment characters. One
-will only begin a comment if it is the first non-whitespace character on
-a line, while the other will always begin a comment.
-
-@kindex #
-@cindex lines starting with @code{#}
-@cindex logical line numbers
-To be compatible with past assemblers, a special interpretation is
-given to lines that begin with @samp{#}. Following the @samp{#} an
-absolute expression (@pxref{Expressions}) is expected: this will be
-the logical line number of the @b{next} line. Then a string
-(@xref{Strings}.) is allowed: if present it is a new logical file
-name. The rest of the line, if any, should be whitespace.
-
-If the first non-whitespace characters on the line are not numeric,
-the line is ignored. (Just like a comment.)
-@smallexample
- # This is an ordinary comment.
-# 42-6 "new_file_name" # New logical file name
- # This is logical line # 36.
-@end smallexample
-This feature is deprecated, and may disappear from future versions
-of @code{as}.
-
-@node Symbol Intro, Statements, Comments, Syntax
-@section Symbols
-
-@cindex symbols
-@cindex characters used in symbols
-A @dfn{symbol} is one or more characters chosen from the set of all
-letters (both upper and lower case), digits and
-the two characters @samp{_.}
-On most machines, you can also use @code{$} in symbol names; exceptions
-are noted in @ref{Machine Dependent}.
-No symbol may begin with a digit. Case is significant.
-There is no length limit: all characters are significant. Symbols are
-delimited by characters not in that set, or by the beginning of a file
-(since the source program must end with a newline, the end of a file is
-not a possible symbol delimiter). @xref{Symbols}.
-@cindex length of symbols
-
-@node Statements, Constants, Symbol Intro, Syntax
-@section Statements
-
-@cindex statements, structure of
-@cindex line separator character
-@cindex statement separator character
-A @dfn{statement} ends at a newline character (@samp{\n}) or line
-separator character. (The line separator is usually @samp{;}, unless
-this conflicts with the comment character; @pxref{Machine Dependent}.) The
-newline or separator character is considered part of the preceding
-statement. Newlines and separators within character constants are an
-exception: they don't end statements.
-
-@cindex newline, required at file end
-@cindex EOF, newline must precede
-It is an error to end any statement with end-of-file: the last
-character of any input file should be a newline.@refill
-
-@cindex continuing statements
-@cindex multi-line statements
-@cindex statement on multiple lines
-You may write a statement on more than one line if you put a
-backslash (@kbd{\}) immediately in front of any newlines within the
-statement. When @code{as} reads a backslashed newline both
-characters are ignored. You can even put backslashed newlines in
-the middle of symbol names without changing the meaning of your
-source program.
-
-An empty statement is allowed, and may include whitespace. It is ignored.
-
-@cindex instructions and directives
-@cindex directives and instructions
-@c "key symbol" is not used elsewhere in the document; seems pedantic to
-@c @defn{} it in that case, as was done previously... pesch@cygnus.com,
-@c 13feb91.
-A statement begins with zero or more labels, optionally followed by a
-key symbol which determines what kind of statement it is. The key
-symbol determines the syntax of the rest of the statement. If the
-symbol begins with a dot @samp{.} then the statement is an assembler
-directive: typically valid for any computer. If the symbol begins with
-a letter the statement is an assembly language @dfn{instruction}: it
-will assemble into a machine language instruction.
-Different versions of @code{as} for different computers will
-recognize different instructions. In fact, the same symbol may
-represent a different instruction in a different computer's assembly
-language.@refill
-
-@cindex @code{:} (label)
-@cindex label (@code{:})
-A label is a symbol immediately followed by a colon (@code{:}).
-Whitespace before a label or after a colon is permitted, but you may not
-have whitespace between a label's symbol and its colon. @xref{Labels}.
-
-@smallexample
-label: .directive followed by something
-another_label: # This is an empty statement.
- instruction operand_1, operand_2, @dots{}
-@end smallexample
-
-@node Constants, , Statements, Syntax
-@section Constants
-
-@cindex constants
-A constant is a number, written so that its value is known by
-inspection, without knowing any context. Like this:
-@smallexample
-.byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value.
-.ascii "Ring the bell\7" # A string constant.
-.octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
-.float 0f-314159265358979323846264338327\
-95028841971.693993751E-40 # - pi, a flonum.
-@end smallexample
-
-@menu
-* Characters:: Character Constants
-* Numbers:: Number Constants
-@end menu
-
-@node Characters, Numbers, Constants, Constants
-@subsection Character Constants
-
-@cindex character constants
-@cindex constants, character
-There are two kinds of character constants. A @dfn{character} stands
-for one character in one byte and its value may be used in
-numeric expressions. String constants (properly called string
-@emph{literals}) are potentially many bytes and their values may not be
-used in arithmetic expressions.
-
-@menu
-* Strings:: Strings
-* Chars:: Characters
-@end menu
-
-@node Strings, Chars, Characters, Characters
-@subsubsection Strings
-
-@cindex string constants
-@cindex constants, string
-A @dfn{string} is written between double-quotes. It may contain
-double-quotes or null characters. The way to get special characters
-into a string is to @dfn{escape} these characters: precede them with
-a backslash @samp{\} character. For example @samp{\\} represents
-one backslash: the first @code{\} is an escape which tells
-@code{as} to interpret the second character literally as a backslash
-(which prevents @code{as} from recognizing the second @code{\} as an
-escape character). The complete list of escapes follows.
-
-@cindex escape codes, character
-@cindex character escape codes
-@table @kbd
-@c @item \a
-@c Mnemonic for ACKnowledge; for ASCII this is octal code 007.
-@c
-@item \b
-@cindex @code{\b} (backspace character)
-@cindex backspace (@code{\b})
-Mnemonic for backspace; for ASCII this is octal code 010.
-
-@c @item \e
-@c Mnemonic for EOText; for ASCII this is octal code 004.
-@c
-@item \f
-@cindex @code{\f} (formfeed character)
-@cindex formfeed (@code{\f})
-Mnemonic for FormFeed; for ASCII this is octal code 014.
-
-@item \n
-@cindex @code{\n} (newline character)
-@cindex newline (@code{\n})
-Mnemonic for newline; for ASCII this is octal code 012.
-
-@c @item \p
-@c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}.
-@c
-@item \r
-@cindex @code{\r} (carriage return character)
-@cindex carriage return (@code{\r})
-Mnemonic for carriage-Return; for ASCII this is octal code 015.
-
-@c @item \s
-@c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with
-@c other assemblers.
-@c
-@item \t
-@cindex @code{\t} (tab)
-@cindex tab (@code{\t})
-Mnemonic for horizontal Tab; for ASCII this is octal code 011.
-
-@c @item \v
-@c Mnemonic for Vertical tab; for ASCII this is octal code 013.
-@c @item \x @var{digit} @var{digit} @var{digit}
-@c A hexadecimal character code. The numeric code is 3 hexadecimal digits.
-@c
-@item \ @var{digit} @var{digit} @var{digit}
-@cindex @code{\@var{ddd}} (octal character code)
-@cindex octal character code (@code{\@var{ddd}})
-An octal character code. The numeric code is 3 octal digits.
-For compatibility with other Unix systems, 8 and 9 are accepted as digits:
-for example, @code{\008} has the value 010, and @code{\009} the value 011.
-
-@item \\
-@cindex @code{\\} (@samp{\} character)
-@cindex backslash (@code{\\})
-Represents one @samp{\} character.
-
-@c @item \'
-@c Represents one @samp{'} (accent acute) character.
-@c This is needed in single character literals
-@c (@xref{Characters,,Character Constants}.) to represent
-@c a @samp{'}.
-@c
-@item \"
-@cindex @code{\"} (doublequote character)
-@cindex doublequote (@code{\"})
-Represents one @samp{"} character. Needed in strings to represent
-this character, because an unescaped @samp{"} would end the string.
-
-@item \ @var{anything-else}
-Any other character when escaped by @kbd{\} will give a warning, but
-assemble as if the @samp{\} was not present. The idea is that if
-you used an escape sequence you clearly didn't want the literal
-interpretation of the following character. However @code{as} has no
-other interpretation, so @code{as} knows it is giving you the wrong
-code and warns you of the fact.
-@end table
-
-Which characters are escapable, and what those escapes represent,
-varies widely among assemblers. The current set is what we think
-the BSD 4.2 assembler recognizes, and is a subset of what most C
-compilers recognize. If you are in doubt, don't use an escape
-sequence.
-
-@node Chars, , Strings, Characters
-@subsubsection Characters
-
-@cindex single character constant
-@cindex character, single
-@cindex constant, single character
-A single character may be written as a single quote immediately
-followed by that character. The same escapes apply to characters as
-to strings. So if you want to write the character backslash, you
-must write @kbd{'\\} where the first @code{\} escapes the second
-@code{\}. As you can see, the quote is an acute accent, not a
-grave accent. A newline
-immediately following an acute accent is taken as a literal character
-and does not count as the end of a statement. The value of a character
-constant in a numeric expression is the machine's byte-wide code for
-that character. @code{as} assumes your character code is ASCII:
-@kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill
-
-@node Numbers, , Characters, Constants
-@subsection Number Constants
-
-@cindex constants, number
-@cindex number constants
-@code{as} distinguishes three kinds of numbers according to how they
-are stored in the target machine. @emph{Integers} are numbers that
-would fit into an @code{int} in the C language. @emph{Bignums} are
-integers, but they are stored in more than 32 bits. @emph{Flonums}
-are floating point numbers, described below.
-
-@menu
-* Integers:: Integers
-* Bignums:: Bignums
-* Flonums:: Flonums
-@end menu
-
-@node Integers, Bignums, Numbers, Numbers
-@subsubsection Integers
-@cindex integers
-@cindex constants, integer
-
-@cindex binary integers
-@cindex integers, binary
-A binary integer is @samp{0b} or @samp{0B} followed by zero or more of
-the binary digits @samp{01}.
-
-@cindex octal integers
-@cindex integers, octal
-An octal integer is @samp{0} followed by zero or more of the octal
-digits (@samp{01234567}).
-
-@cindex decimal integers
-@cindex integers, decimal
-A decimal integer starts with a non-zero digit followed by zero or
-more digits (@samp{0123456789}).
-
-@cindex hexadecimal integers
-@cindex integers, hexadecimal
-A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
-more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
-
-Integers have the usual values. To denote a negative integer, use
-the prefix operator @samp{-} discussed under expressions
-(@pxref{Prefix Ops,,Prefix Operators}).
-
-@node Bignums, Flonums, Integers, Numbers
-@subsubsection Bignums
-
-@cindex bignums
-@cindex constants, bignum
-A @dfn{bignum} has the same syntax and semantics as an integer
-except that the number (or its negative) takes more than 32 bits to
-represent in binary. The distinction is made because in some places
-integers are permitted while bignums are not.
-
-@node Flonums, , Bignums, Numbers
-@subsubsection Flonums
-@cindex flonums
-@cindex floating point numbers
-@cindex constants, floating point
-
-@cindex precision, floating point
-A @dfn{flonum} represents a floating point number. The translation is
-indirect: a decimal floating point number from the text is converted by
-@code{as} to a generic binary floating point number of more than
-sufficient precision. This generic floating point number is converted
-to a particular computer's floating point format (or formats) by a
-portion of @code{as} specialized to that computer.
-
-A flonum is written by writing (in order)
-@itemize @bullet
-@item
-The digit @samp{0}.
-@item
-A letter, to tell @code{as} the rest of the number is a flonum.
-@kbd{e} is recommended. Case is not important.
-@ignore
-@c FIXME: verify if flonum syntax really this vague for most cases
- (Any otherwise illegal letter
-will work here, but that might be changed. Vax BSD 4.2 assembler seems
-to allow any of @samp{defghDEFGH}.)
-@end ignore
-On the AMD 29K and H8/300 architectures, the letter must be:
-One of the letters @samp{DFPRSX} (in upper or lower case).
-On the Intel 960 architecture, the letter must be:
-One of the letters @samp{DFT} (in upper or lower case).
-@item
-An optional sign: either @samp{+} or @samp{-}.
-@item
-An optional @dfn{integer part}: zero or more decimal digits.
-@item
-An optional @dfn{fractional part}: @samp{.} followed by zero
-or more decimal digits.
-@item
-An optional exponent, consisting of:
-@itemize @bullet
-@item
-An @samp{E} or @samp{e}.
-@c I can't find a config where "EXP_CHARS" is other than 'eE', but in
-@c principle this can perfectly well be different on different targets.
-@item
-Optional sign: either @samp{+} or @samp{-}.
-@item
-One or more decimal digits.
-@end itemize
-@end itemize
-
-At least one of the integer part or the fractional part must be
-present. The floating point number has the usual base-10 value.
-
-@code{as} does all processing using integers. Flonums are computed
-independently of any floating point hardware in the computer running
-@code{as}.
-
-
-@node Sections, Symbols, Syntax, Top
-@chapter Sections and Relocation
-@cindex sections
-@cindex relocation
-
-@menu
-* Secs Background:: Background
-* ld Sections:: ld Sections
-* as Sections:: as Internal Sections
-* Sub-Sections:: Sub-Sections
-* bss:: bss Section
-@end menu
-
-@node Secs Background, ld Sections, Sections, Sections
-@section Background
-
-Roughly, a section is a range of addresses, with no gaps; all data
-``in'' those addresses is treated the same for some particular purpose.
-For example there may be a ``read only'' section.
-
-@cindex linker, and assembler
-@cindex assembler, and linker
-The linker @code{ld} reads many object files (partial programs) and
-combines their contents to form a runnable program. When @code{as}
-emits an object file, the partial program is assumed to start at address
-0. @code{ld} will assign the final addresses the partial program
-occupies, so that different partial programs don't overlap. This is
-actually an over-simplification, but it will suffice to explain how
-@code{as} uses sections.
-
-@code{ld} moves blocks of bytes of your program to their run-time
-addresses. These blocks slide to their run-time addresses as rigid
-units; their length does not change and neither does the order of bytes
-within them. Such a rigid unit is called a @emph{section}. Assigning
-run-time addresses to sections is called @dfn{relocation}. It includes
-the task of adjusting mentions of object-file addresses so they refer to
-the proper run-time addresses.
-For the H8/300, @code{as} pads sections if needed to ensure they end
-on a word (sixteen bit) boundary.
-
-@cindex standard @code{as} sections
-An object file written by @code{as} has at least three sections, any
-of which may be empty. These are named @dfn{text}, @dfn{data} and
-@dfn{bss} sections.
-
-When it generates COFF output,
-@code{as} can also generate whatever other named sections you specify
-using the @samp{.section} directive (@pxref{Section,,@code{.section}}).
-If you don't use any directives that place output in the @samp{.text}
-or @samp{.data} sections, these sections will still exist, but will be empty.
-
-Within the object file, the text section starts at address @code{0}, the
-data section follows, and the bss section follows the data section.
-
-To let @code{ld} know which data will change when the sections are
-relocated, and how to change that data, @code{as} also writes to the
-object file details of the relocation needed. To perform relocation
-@code{ld} must know, each time an address in the object
-file is mentioned:
-@itemize @bullet
-@item
-Where in the object file is the beginning of this reference to
-an address?
-@item
-How long (in bytes) is this reference?
-@item
-Which section does the address refer to? What is the numeric value of
-@display
-(@var{address}) @minus{} (@var{start-address of section})?
-@end display
-@item
-Is the reference to an address ``Program-Counter relative''?
-@end itemize
-
-@cindex addresses, format of
-@cindex section-relative addressing
-In fact, every address @code{as} ever uses is expressed as
-@display
-(@var{section}) + (@var{offset into section})
-@end display
-@noindent
-Further, every expression @code{as} computes is of this section-relative
-nature. @dfn{Absolute expression} means an expression with section
-``absolute'' (@pxref{ld Sections}). A @dfn{pass1 expression} means
-an expression with section ``pass1'' (@pxref{as Sections,,as
-Internal Sections}). In this manual we use the notation @{@var{secname}
-@var{N}@} to mean ``offset @var{N} into section @var{secname}''.
-
-Apart from text, data and bss sections you need to know about the
-@dfn{absolute} section. When @code{ld} mixes partial programs,
-addresses in the absolute section remain unchanged. For example, address
-@code{@{absolute 0@}} is ``relocated'' to run-time address 0 by @code{ld}.
-Although two partial programs' data sections will not overlap addresses
-after linking, @emph{by definition} their absolute sections will overlap.
-Address @code{@{absolute@ 239@}} in one partial program will always be the same
-address when the program is running as address @code{@{absolute@ 239@}} in any
-other partial program.
-
-The idea of sections is extended to the @dfn{undefined} section. Any
-address whose section is unknown at assembly time is by definition
-rendered @{undefined @var{U}@}---where @var{U} will be filled in later.
-Since numbers are always defined, the only way to generate an undefined
-address is to mention an undefined symbol. A reference to a named
-common block would be such a symbol: its value is unknown at assembly
-time so it has section @emph{undefined}.
-
-By analogy the word @emph{section} is used to describe groups of sections in
-the linked program. @code{ld} puts all partial programs' text
-sections in contiguous addresses in the linked program. It is
-customary to refer to the @emph{text section} of a program, meaning all
-the addresses of all partial program's text sections. Likewise for
-data and bss sections.
-
-Some sections are manipulated by @code{ld}; others are invented for
-use of @code{as} and have no meaning except during assembly.
-
-@node ld Sections, as Sections, Secs Background, Sections
-@section ld Sections
-@code{ld} deals with just four kinds of sections, summarized below.
-
-@table @strong
-
-@cindex named sections
-@cindex sections, named
-@item named sections
-@cindex text section
-@cindex data section
-@item text section
-@itemx data section
-These sections hold your program. @code{as} and @code{ld} treat them as
-separate but equal sections. Anything you can say of one section is
-true another.
-When the program is running, however, it is
-customary for the text section to be unalterable. The
-text section is often shared among processes: it will contain
-instructions, constants and the like. The data section of a running
-program is usually alterable: for example, C variables would be stored
-in the data section.
-
-@cindex bss section
-@item bss section
-This section contains zeroed bytes when your program begins running. It
-is used to hold unitialized variables or common storage. The length of
-each partial program's bss section is important, but because it starts
-out containing zeroed bytes there is no need to store explicit zero
-bytes in the object file. The bss section was invented to eliminate
-those explicit zeros from object files.
-
-@cindex absolute section
-@item absolute section
-Address 0 of this section is always ``relocated'' to runtime address 0.
-This is useful if you want to refer to an address that @code{ld} must
-not change when relocating. In this sense we speak of absolute
-addresses being ``unrelocatable'': they don't change during relocation.
-
-@cindex undefined section
-@item undefined section
-This ``section'' is a catch-all for address references to objects not in
-the preceding sections.
-@c FIXME: ref to some other doc on obj-file formats could go here.
-@end table
-
-@cindex relocation example
-An idealized example of three relocatable sections follows.
-The example uses the traditional section names @samp{.text} and @samp{.data}.
-Memory addresses are on the horizontal axis.
-
-@c TEXI2ROFF-KILL
-@ifinfo
-@c END TEXI2ROFF-KILL
-@smallexample
- +-----+----+--+
-partial program # 1: |ttttt|dddd|00|
- +-----+----+--+
-
- text data bss
- seg. seg. seg.
-
- +---+---+---+
-partial program # 2: |TTT|DDD|000|
- +---+---+---+
-
- +--+---+-----+--+----+---+-----+~~
-linked program: | |TTT|ttttt| |dddd|DDD|00000|
- +--+---+-----+--+----+---+-----+~~
-
- addresses: 0 @dots{}
-@end smallexample
-@c TEXI2ROFF-KILL
-@end ifinfo
-@c FIXME make sure no page breaks inside figure!!
-@tex
-
-\line{\it Partial program \#1: \hfil}
-\line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
-\line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil}
-
-\line{\it Partial program \#2: \hfil}
-\line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil}
-\line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil}
-
-\line{\it linked program: \hfil}
-\line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil}
-\line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt
-ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt
-DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil}
-
-\line{\it addresses: \hfil}
-\line{0\dots\hfil}
-
-@end tex
-@c END TEXI2ROFF-KILL
-
-@node as Sections, Sub-Sections, ld Sections, Sections
-@section as Internal Sections
-
-@cindex internal @code{as} sections
-@cindex sections in messages, internal
-These sections are meant only for the internal use of @code{as}. They
-have no meaning at run-time. You don't really need to know about these
-sections for most purposes; but they can be mentioned in @code{as}
-warning messages, so it might be helpful to have an idea of their
-meanings to @code{as}. These sections are used to permit the
-value of every expression in your assembly language program to be a
-section-relative address.
-
-@table @b
-@item absent
-@cindex absent (internal section)
-An expression was expected and none was found.
-
-@item ASSEMBLER-INTERNAL-LOGIC-ERROR!
-@cindex assembler internal logic error
-An internal assembler logic error has been found. This means there is a
-bug in the assembler.
-
-@item bignum/flonum
-@cindex bignum/flonum (internal section)
-If a number can't be written as a C @code{int} constant (a bignum or a
-flonum, but not an integer), it is recorded as belonging to this
-``section''. @code{as} has to remember that a flonum or a bignum
-does not fit into 32 bits, and cannot be an argument (@pxref{Arguments})
-in an expression: this is done by making a flonum or bignum be in a
-separate internal section. This is purely for internal @code{as}
-convenience; bignum/flonum section behaves similarly to absolute
-section.
-
-@item pass1 section
-@cindex pass1 (internal section)
-The expression was impossible to evaluate in the first pass. The
-assembler will attempt a second pass (second reading of the source) to
-evaluate the expression. Your expression mentioned an undefined symbol
-in a way that defies the one-pass (section + offset in section) assembly
-process. No compiler need emit such an expression.
-
-@quotation
-@emph{Warning:} the second pass is currently not implemented. @code{as}
-will abort with an error message if one is required.
-@end quotation
-
-@item difference section
-@cindex difference (internal section)
-As an assist to the C compiler, expressions of the forms
-@display
- (@var{undefined symbol}) @minus{} (@var{expression})
- @var{something} @minus{} (@var{undefined symbol})
- (@var{undefined symbol}) @minus{} (@var{undefined symbol})
-@end display
-
-are permitted, and belong to the difference section. @code{as}
-re-evaluates such expressions after the source file has been read and
-the symbol table built. If by that time there are no undefined symbols
-in the expression then the expression assumes a new section. The
-intention is to permit statements like
-@samp{.word label - base_of_table}
-to be assembled in one pass where both @code{label} and
-@code{base_of_table} are undefined. This is useful for compiling C and
-Algol switch statements, Pascal case statements, FORTRAN computed goto
-statements and the like.
-@c FIXME item debug
-@c FIXME item transfer[t] vector preload
-@c FIXME item transfer[t] vector postload
-@c FIXME item register
-@end table
-
-@node Sub-Sections, bss, as Sections, Sections
-@section Sub-Sections
-
-@cindex numbered subsections
-@cindex grouping data
-Assembled bytes
-conventionally
-fall into two sections: text and data.
-You may have separate groups of
-data in named sections
-that you want to end up near to each other in the object
-file, even though they are not contiguous in the assembler source.
-@code{as} allows you to use @dfn{subsections} for this purpose.
-Within each section, there can be numbered subsections with
-values from 0 to 8192. Objects assembled into the same subsection will
-be grouped with other objects in the same subsection when they are all
-put into the object file. For example, a compiler might want to store
-constants in the text section, but might not want to have them
-interspersed with the program being assembled. In this case, the
-compiler could issue a @samp{.text 0} before each section of code being
-output, and a @samp{.text 1} before each group of constants being output.
-
-Subsections are optional. If you don't use subsections, everything
-will be stored in subsection number zero.
-
-Each subsection is zero-padded up to a multiple of four bytes.
-(Subsections may be padded a different amount on different flavors
-of @code{as}.)
-
-Subsections appear in your object file in numeric order, lowest numbered
-to highest. (All this to be compatible with other people's assemblers.)
-The object file contains no representation of subsections; @code{ld} and
-other programs that manipulate object files will see no trace of them.
-They just see all your text subsections as a text section, and all your
-data subsections as a data section.
-
-To specify which subsection you want subsequent statements assembled
-into, use a numeric argument to specify it, in a @samp{.text
-@var{expression}} or a @samp{.data @var{expression}} statement.
-When generating COFF output, you
-can also use an extra subsection
-argument with arbitrary named sections: @samp{.section @var{name},
-@var{expression}}.
-@var{Expression} should be an absolute expression.
-(@xref{Expressions}.) If you just say @samp{.text} then @samp{.text 0}
-is assumed. Likewise @samp{.data} means @samp{.data 0}. Assembly
-begins in @code{text 0}. For instance:
-@smallexample
-.text 0 # The default subsection is text 0 anyway.
-.ascii "This lives in the first text subsection. *"
-.text 1
-.ascii "But this lives in the second text subsection."
-.data 0
-.ascii "This lives in the data section,"
-.ascii "in the first data subsection."
-.text 0
-.ascii "This lives in the first text section,"
-.ascii "immediately following the asterisk (*)."
-@end smallexample
-
-Each section has a @dfn{location counter} incremented by one for every
-byte assembled into that section. Because subsections are merely a
-convenience restricted to @code{as} there is no concept of a subsection
-location counter. There is no way to directly manipulate a location
-counter---but the @code{.align} directive will change it, and any label
-definition will capture its current value. The location counter of the
-section that statements are being assembled into is said to be the
-@dfn{active} location counter.
-
-@node bss, , Sub-Sections, Sections
-@section bss Section
-
-@cindex bss section
-@cindex common variable storage
-The bss section is used for local common variable storage.
-You may allocate address space in the bss section, but you may
-not dictate data to load into it before your program executes. When
-your program starts running, all the contents of the bss
-section are zeroed bytes.
-
-Addresses in the bss section are allocated with special directives; you
-may not assemble anything directly into the bss section. Hence there
-are no bss subsections. @xref{Comm,,@code{.comm}},
-@pxref{Lcomm,,@code{.lcomm}}.
-
-@node Symbols, Expressions, Sections, Top
-@chapter Symbols
-
-@cindex symbols
-Symbols are a central concept: the programmer uses symbols to name
-things, the linker uses symbols to link, and the debugger uses symbols
-to debug.
-
-@quotation
-@cindex debuggers, and symbol order
-@emph{Warning:} @code{as} does not place symbols in the object file in
-the same order they were declared. This may break some debuggers.
-@end quotation
-
-@menu
-* Labels:: Labels
-* Setting Symbols:: Giving Symbols Other Values
-* Symbol Names:: Symbol Names
-* Dot:: The Special Dot Symbol
-* Symbol Attributes:: Symbol Attributes
-@end menu
-
-@node Labels, Setting Symbols, Symbols, Symbols
-@section Labels
-
-@cindex labels
-A @dfn{label} is written as a symbol immediately followed by a colon
-@samp{:}. The symbol then represents the current value of the
-active location counter, and is, for example, a suitable instruction
-operand. You are warned if you use the same symbol to represent two
-different locations: the first definition overrides any other
-definitions.
-
-@node Setting Symbols, Symbol Names, Labels, Symbols
-@section Giving Symbols Other Values
-
-@cindex assigning values to symbols
-@cindex symbol values, assigning
-A symbol can be given an arbitrary value by writing a symbol, followed
-by an equals sign @samp{=}, followed by an expression
-(@pxref{Expressions}). This is equivalent to using the @code{.set}
-directive. @xref{Set,,@code{.set}}.
-
-@node Symbol Names, Dot, Setting Symbols, Symbols
-@section Symbol Names
-
-@cindex symbol names
-@cindex names, symbol
-Symbol names begin with a letter or with one of
-@samp{_.}
-(On most machines, you can also use @code{$} in symbol names; exceptions
-are noted in @ref{Machine Dependent}.)
-That character may be followed by any string of digits, letters,
-dollar signs (unless otherwise noted in @ref{Machine Dependent}),
-and underscores.
-Case of letters is significant:
-@code{foo} is a different symbol name than @code{Foo}.
-
-For the AMD 29K family, @samp{?} is also allowed in the
-body of a symbol name, though not at its beginning.
-
-Each symbol has exactly one name. Each name in an assembly language
-program refers to exactly one symbol. You may use that symbol name any
-number of times in a program.
-
-@subheading Local Symbol Names
-
-@cindex local symbol names
-@cindex symbol names, local
-@cindex temporary symbol names
-@cindex symbol names, temporary
-Local symbols help compilers and programmers use names temporarily.
-There are ten local symbol names, which are re-used throughout the
-program. You may refer to them using the names @samp{0} @samp{1}
-@dots{} @samp{9}. To define a local symbol, write a label of the form
-@samp{@b{N}:} (where @b{N} represents any digit). To refer to the most
-recent previous definition of that symbol write @samp{@b{N}b}, using the
-same digit as when you defined the label. To refer to the next
-definition of a local label, write @samp{@b{N}f}---where @b{N} gives you
-a choice of 10 forward references. The @samp{b} stands for
-``backwards'' and the @samp{f} stands for ``forwards''.
-
-Local symbols are not emitted by the current GNU C compiler.
-
-There is no restriction on how you can use these labels, but
-remember that at any point in the assembly you can refer to at most
-10 prior local labels and to at most 10 forward local labels.
-
-Local symbol names are only a notation device. They are immediately
-transformed into more conventional symbol names before the assembler
-uses them. The symbol names stored in the symbol table, appearing in
-error messages and optionally emitted to the object file have these
-parts:
-
-@table @code
-@item L
-All local labels begin with @samp{L}. Normally both @code{as} and
-@code{ld} forget symbols that start with @samp{L}. These labels are
-used for symbols you are never intended to see. If you give the
-@samp{-L} option then @code{as} will retain these symbols in the
-object file. If you also instruct @code{ld} to retain these symbols,
-you may use them in debugging.
-
-@item @var{digit}
-If the label is written @samp{0:} then the digit is @samp{0}.
-If the label is written @samp{1:} then the digit is @samp{1}.
-And so on up through @samp{9:}.
-
-@item @kbd{C-A}
-This unusual character is included so you don't accidentally invent
-a symbol of the same name. The character has ASCII value
-@samp{\001}.
-
-@item @emph{ordinal number}
-This is a serial number to keep the labels distinct. The first
-@samp{0:} gets the number @samp{1}; The 15th @samp{0:} gets the
-number @samp{15}; @emph{etc.}. Likewise for the other labels @samp{1:}
-through @samp{9:}.
-@end table
-
-For instance, the first @code{1:} is named @code{L1@kbd{C-A}1}, the 44th
-@code{3:} is named @code{L3@kbd{C-A}44}.
-
-@node Dot, Symbol Attributes, Symbol Names, Symbols
-@section The Special Dot Symbol
-
-@cindex dot (symbol)
-@cindex @code{.} (symbol)
-@cindex current address
-@cindex location counter
-The special symbol @samp{.} refers to the current address that
-@code{as} is assembling into. Thus, the expression @samp{melvin:
-.long .} will cause @code{melvin} to contain its own address.
-Assigning a value to @code{.} is treated the same as a @code{.org}
-directive. Thus, the expression @samp{.=.+4} is the same as saying
-@samp{.block 4}.
-
-@node Symbol Attributes, , Dot, Symbols
-@section Symbol Attributes
-
-@cindex symbol attributes
-@cindex attributes, symbol
-Every symbol has, as well as its name, the attributes ``Value'' and
-``Type''. Depending on output format, symbols can also have auxiliary
-attributes.
-
-If you use a symbol without defining it, @code{as} assumes zero for
-all these attributes, and probably won't warn you. This makes the
-symbol an externally defined symbol, which is generally what you
-would want.
-
-@menu
-* Symbol Value:: Value
-* Symbol Type:: Type
-* a.out Symbols:: Symbol Attributes: @code{a.out}
-* COFF Symbols:: Symbol Attributes for COFF
-@end menu
-
-@node Symbol Value, Symbol Type, Symbol Attributes, Symbol Attributes
-@subsection Value
-
-@cindex value of a symbol
-@cindex symbol value
-The value of a symbol is (usually) 32 bits. For a symbol which labels a
-location in the text, data, bss or absolute sections the value is the
-number of addresses from the start of that section to the label.
-Naturally for text, data and bss sections the value of a symbol changes
-as @code{ld} changes section base addresses during linking. Absolute
-symbols' values do not change during linking: that is why they are
-called absolute.
-
-The value of an undefined symbol is treated in a special way. If it is
-0 then the symbol is not defined in this assembler source program, and
-@code{ld} will try to determine its value from other programs it is
-linked with. You make this kind of symbol simply by mentioning a symbol
-name without defining it. A non-zero value represents a @code{.comm}
-common declaration. The value is how much common storage to reserve, in
-bytes (addresses). The symbol refers to the first address of the
-allocated storage.
-
-@node Symbol Type, a.out Symbols, Symbol Value, Symbol Attributes
-@subsection Type
-
-@cindex type of a symbol
-@cindex symbol type
-The type attribute of a symbol contains relocation (section)
-information, any flag settings indicating that a symbol is external, and
-(optionally), other information for linkers and debuggers. The exact
-format depends on the object-code output format in use.
-
-@node a.out Symbols, COFF Symbols, Symbol Type, Symbol Attributes
-@subsection Symbol Attributes: @code{a.out}
-
-@cindex @code{a.out} symbol attributes
-@cindex symbol attributes, @code{a.out}
-
-@menu
-* Symbol Desc:: Descriptor
-* Symbol Other:: Other
-@end menu
-
-@node Symbol Desc, Symbol Other, a.out Symbols, a.out Symbols
-@subsubsection Descriptor
-
-@cindex descriptor, of @code{a.out} symbol
-This is an arbitrary 16-bit value. You may establish a symbol's
-descriptor value by using a @code{.desc} statement
-(@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to
-@code{as}.
-
-@node Symbol Other, , Symbol Desc, a.out Symbols
-@subsubsection Other
-
-@cindex other attribute, of @code{a.out} symbol
-This is an arbitrary 8-bit value. It means nothing to @code{as}.
-
-@node COFF Symbols, , a.out Symbols, Symbol Attributes
-@subsection Symbol Attributes for COFF
-
-@cindex COFF symbol attributes
-@cindex symbol attributes, COFF
-
-The COFF format supports a multitude of auxiliary symbol attributes;
-like the primary symbol attributes, they are set between @code{.def} and
-@code{.endef} directives.
-
-@subsubsection Primary Attributes
-
-@cindex primary attributes, COFF symbols
-The symbol name is set with @code{.def}; the value and type,
-respectively, with @code{.val} and @code{.type}.
-
-@subsubsection Auxiliary Attributes
-
-@cindex auxiliary attributes, COFF symbols
-The @code{as} directives @code{.dim}, @code{.line}, @code{.scl},
-@code{.size}, and @code{.tag} can generate auxiliary symbol table
-information for COFF.
-
-@node Expressions, Pseudo Ops, Symbols, Top
-@chapter Expressions
-
-@cindex expressions
-@cindex addresses
-@cindex numeric values
-An @dfn{expression} specifies an address or numeric value.
-Whitespace may precede and/or follow an expression.
-
-@menu
-* Empty Exprs:: Empty Expressions
-* Integer Exprs:: Integer Expressions
-@end menu
-
-@node Empty Exprs, Integer Exprs, Expressions, Expressions
-@section Empty Expressions
-
-@cindex empty expressions
-@cindex expressions, empty
-An empty expression has no value: it is just whitespace or null.
-Wherever an absolute expression is required, you may omit the
-expression and @code{as} will assume a value of (absolute) 0. This
-is compatible with other assemblers.
-
-@node Integer Exprs, , Empty Exprs, Expressions
-@section Integer Expressions
-
-@cindex integer expressions
-@cindex expressions, integer
-An @dfn{integer expression} is one or more @emph{arguments} delimited
-by @emph{operators}.
-
-@menu
-* Arguments:: Arguments
-* Operators:: Operators
-* Prefix Ops:: Prefix Operators
-* Infix Ops:: Infix Operators
-@end menu
-
-@node Arguments, Operators, Integer Exprs, Integer Exprs
-@subsection Arguments
-
-@cindex expression arguments
-@cindex arguments in expressions
-@cindex operands in expressions
-@cindex arithmetic operands
-@dfn{Arguments} are symbols, numbers or subexpressions. In other
-contexts arguments are sometimes called ``arithmetic operands''. In
-this manual, to avoid confusing them with the ``instruction operands'' of
-the machine language, we use the term ``argument'' to refer to parts of
-expressions only, reserving the word ``operand'' to refer only to machine
-instruction operands.
-
-Symbols are evaluated to yield @{@var{section} @var{NNN}@} where
-@var{section} is one of text, data, bss, absolute,
-or undefined. @var{NNN} is a signed, 2's complement 32 bit
-integer.
-
-Numbers are usually integers.
-
-A number can be a flonum or bignum. In this case, you are warned
-that only the low order 32 bits are used, and @code{as} pretends
-these 32 bits are an integer. You may write integer-manipulating
-instructions that act on exotic constants, compatible with other
-assemblers.
-
-@cindex subexpressions
-Subexpressions are a left parenthesis @samp{(} followed by an integer
-expression, followed by a right parenthesis @samp{)}; or a prefix
-operator followed by an argument.
-
-@node Operators, Prefix Ops, Arguments, Integer Exprs
-@subsection Operators
-
-@cindex operators, in expressions
-@cindex arithmetic functions
-@cindex functions, in expressions
-@dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix
-operators are followed by an argument. Infix operators appear
-between their arguments. Operators may be preceded and/or followed by
-whitespace.
-
-@node Prefix Ops, Infix Ops, Operators, Integer Exprs
-@subsection Prefix Operator
-
-@cindex prefix operators
-@code{as} has the following @dfn{prefix operators}. They each take
-one argument, which must be absolute.
-
-@c the tex/end tex stuff surrounding this small table is meant to make
-@c it align, on the printed page, with the similar table in the next
-@c section (which is inside an enumerate).
-@tex
-\global\advance\leftskip by \itemindent
-@end tex
-
-@table @code
-@item -
-@dfn{Negation}. Two's complement negation.
-@item ~
-@dfn{Complementation}. Bitwise not.
-@end table
-
-@tex
-\global\advance\leftskip by -\itemindent
-@end tex
-
-@node Infix Ops, , Prefix Ops, Integer Exprs
-@subsection Infix Operators
-
-@cindex infix operators
-@cindex operators, permitted arguments
-@dfn{Infix operators} take two arguments, one on either side. Operators
-have precedence, but operations with equal precedence are performed left
-to right. Apart from @code{+} or @code{-}, both arguments must be
-absolute, and the result is absolute.
-
-@enumerate
-@cindex operator precedence
-@cindex precedence of operators
-
-@item
-Highest Precedence
-
-@table @code
-@item *
-@dfn{Multiplication}.
-
-@item /
-@dfn{Division}. Truncation is the same as the C operator @samp{/}
-
-@item %
-@dfn{Remainder}.
-
-@item <
-@itemx <<
-@dfn{Shift Left}. Same as the C operator @samp{<<}
-
-@item >
-@itemx >>
-@dfn{Shift Right}. Same as the C operator @samp{>>}
-@end table
-
-@item
-Intermediate precedence
-
-@table @code
-@item |
-
-@dfn{Bitwise Inclusive Or}.
-
-@item &
-@dfn{Bitwise And}.
-
-@item ^
-@dfn{Bitwise Exclusive Or}.
-
-@item !
-@dfn{Bitwise Or Not}.
-@end table
-
-@item
-Lowest Precedence
-
-@table @code
-@item +
-@cindex addition, permitted arguments
-@cindex plus, permitted arguments
-@cindex arguments for addition
-@dfn{Addition}. If either argument is absolute, the result
-has the section of the other argument.
-If either argument is pass1 or undefined, the result is pass1.
-Otherwise @code{+} is illegal.
-
-@item -
-@cindex subtraction, permitted arguments
-@cindex minus, permitted arguments
-@cindex arguments for subtraction
-@dfn{Subtraction}. If the right argument is absolute, the
-result has the section of the left argument.
-If either argument is pass1 the result is pass1.
-If either argument is undefined the result is difference section.
-If both arguments are in the same section, the result is absolute---provided
-that section is one of text, data or bss.
-Otherwise subtraction is illegal.
-@end table
-@end enumerate
-
-The sense of the rule for addition is that it's only meaningful to add
-the @emph{offsets} in an address; you can only have a defined section in
-one of the two arguments.
-
-Similarly, you can't subtract quantities from two different sections.
-
-@node Pseudo Ops, Machine Dependent, Expressions, Top
-@chapter Assembler Directives
-
-@cindex directives, machine independent
-@cindex pseudo-ops, machine independent
-@cindex machine independent directives
-All assembler directives have names that begin with a period (@samp{.}).
-The rest of the name is letters, usually in lower case.
-
-This chapter discusses directives present regardless of the target
-machine configuration for the GNU assembler.
-
-@menu
-* Abort:: @code{.abort}
-* coff-ABORT:: @code{.ABORT}
-* Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
-* App-File:: @code{.app-file @var{string}}
-* Ascii:: @code{.ascii "@var{string}"}@dots{}
-* Asciz:: @code{.asciz "@var{string}"}@dots{}
-* Byte:: @code{.byte @var{expressions}}
-* Comm:: @code{.comm @var{symbol} , @var{length} }
-* Data:: @code{.data @var{subsection}}
-* Def:: @code{.def @var{name}}
-* Desc:: @code{.desc @var{symbol}, @var{abs-expression}}
-* Dim:: @code{.dim}
-* Double:: @code{.double @var{flonums}}
-* Eject:: @code{.eject}
-* Else:: @code{.else}
-* Endef:: @code{.endef}
-* Endif:: @code{.endif}
-* Equ:: @code{.equ @var{symbol}, @var{expression}}
-* Extern:: @code{.extern}
-* File:: @code{.file @var{string}}
-* Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
-* Float:: @code{.float @var{flonums}}
-* Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
-* hword:: @code{.hword @var{expressions}}
-* Ident:: @code{.ident}
-* If:: @code{.if @var{absolute expression}}
-* Include:: @code{.include "@var{file}"}
-* Int:: @code{.int @var{expressions}}
-* Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
-* Lflags:: @code{.lflags}
-* Line:: @code{.line @var{line-number}}
-* Ln:: @code{.ln @var{line-number}}
-* List:: @code{.list}
-* Long:: @code{.long @var{expressions}}
-* Lsym:: @code{.lsym @var{symbol}, @var{expression}}
-* Nolist:: @code{.nolist}
-* Octa:: @code{.octa @var{bignums}}
-* Org:: @code{.org @var{new-lc} , @var{fill}}
-* Psize:: @code{.psize @var{lines}, @var{columns}}
-* Quad:: @code{.quad @var{bignums}}
-* Sbttl:: @code{.sbttl "@var{subheading}"}
-* Scl:: @code{.scl @var{class}}
-* Section:: @code{.section @var{name}, @var{subsection}}
-* Set:: @code{.set @var{symbol}, @var{expression}}
-* Short:: @code{.short @var{expressions}}
-* Single:: @code{.single @var{flonums}}
-* Size:: @code{.size}
-* Space:: @code{.space @var{size} , @var{fill}}
-* Stab:: @code{.stabd, .stabn, .stabs}
-* Tag:: @code{.tag @var{structname}}
-* Text:: @code{.text @var{subsection}}
-* Title:: @code{.title "@var{heading}"}
-* Type:: @code{.type @var{int}}
-* Val:: @code{.val @var{addr}}
-* Word:: @code{.word @var{expressions}}
-* Deprecated:: Deprecated Directives
-@end menu
-
-@node Abort, coff-ABORT, Pseudo Ops, Pseudo Ops
-@section @code{.abort}
-
-@cindex @code{abort} directive
-@cindex stopping the assembly
-This directive stops the assembly immediately. It is for
-compatibility with other assemblers. The original idea was that the
-assembly language source would be piped into the assembler. If the sender
-of the source quit, it could use this directive tells @code{as} to
-quit also. One day @code{.abort} will not be supported.
-
-@node coff-ABORT, Align, Abort, Pseudo Ops
-@section @code{.ABORT}
-
-@cindex @code{ABORT} directive
-When producing COFF output, @code{as} accepts this directive as a
-synonym for @samp{.abort}.
-
-
-When producing @code{b.out} output, @code{as} accepts this directive,
-but ignores it.
-
-@node Align, App-File, coff-ABORT, Pseudo Ops
-@section @code{.align @var{abs-expr} , @var{abs-expr}}
-
-@cindex padding the location counter
-@cindex advancing location counter
-@cindex location counter, advancing
-@cindex @code{align} directive
-Pad the location counter (in the current subsection) to a particular
-storage boundary. The first expression (which must be absolute) is the
-number of low-order zero bits the location counter will have after
-advancement. For example @samp{.align 3} will advance the location
-counter until it a multiple of 8. If the location counter is already a
-multiple of 8, no change is needed.
-
-The second expression (also absolute) gives the value to be stored in
-the padding bytes. It (and the comma) may be omitted. If it is
-omitted, the padding bytes are zero.
-
-@node App-File, Ascii, Align, Pseudo Ops
-@section @code{.app-file @var{string}}
-
-@cindex logical file name
-@cindex file name, logical
-@cindex @code{app-file} directive
-@code{.app-file}
-tells @code{as} that we are about to start a new
-logical file. @var{string} is the new file name. In general, the
-filename is recognized whether or not it is surrounded by quotes @samp{"};
-but if you wish to specify an empty file name is permitted,
-you must give the quotes--@code{""}. This statement may go away in
-future: it is only recognized to be compatible with old @code{as}
-programs.@refill
-
-@node Ascii, Asciz, App-File, Pseudo Ops
-@section @code{.ascii "@var{string}"}@dots{}
-
-@cindex @code{ascii} directive
-@cindex string literals
-@code{.ascii} expects zero or more string literals (@pxref{Strings})
-separated by commas. It assembles each string (with no automatic
-trailing zero byte) into consecutive addresses.
-
-@node Asciz, Byte, Ascii, Pseudo Ops
-@section @code{.asciz "@var{string}"}@dots{}
-
-@cindex @code{asciz} directive
-@cindex zero-terminated strings
-@cindex null-terminated strings
-@code{.asciz} is just like @code{.ascii}, but each string is followed by
-a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''.
-
-@node Byte, Comm, Asciz, Pseudo Ops
-@section @code{.byte @var{expressions}}
-
-@cindex @code{byte} directive
-@cindex integers, one byte
-@code{.byte} expects zero or more expressions, separated by commas.
-Each expression is assembled into the next byte.
-
-@node Comm, Data, Byte, Pseudo Ops
-@section @code{.comm @var{symbol} , @var{length} }
-
-@cindex @code{comm} directive
-@cindex symbol, common
-@code{.comm} declares a named common area in the bss section. Normally
-@code{ld} reserves memory addresses for it during linking, so no partial
-program defines the location of the symbol. Use @code{.comm} to tell
-@code{ld} that it must be at least @var{length} bytes long. @code{ld}
-will allocate space for each @code{.comm} symbol that is at least as
-long as the longest @code{.comm} request in any of the partial programs
-linked. @var{length} is an absolute expression.
-
-@node Data, Def, Comm, Pseudo Ops
-@section @code{.data @var{subsection}}
-
-@cindex @code{data} directive
-@code{.data} tells @code{as} to assemble the following statements onto the
-end of the data subsection numbered @var{subsection} (which is an
-absolute expression). If @var{subsection} is omitted, it defaults
-to zero.
-
-@node Def, Desc, Data, Pseudo Ops
-@section @code{.def @var{name}}
-
-@cindex @code{def} directive
-@cindex COFF symbols, debugging
-@cindex debugging COFF symbols
-Begin defining debugging information for a symbol @var{name}; the
-definition extends until the @code{.endef} directive is encountered.
-
-This directive is only observed when @code{as} is configured for COFF
-format output; when producing @code{b.out}, @samp{.def} is recognized,
-but ignored.
-
-@node Desc, Dim, Def, Pseudo Ops
-@section @code{.desc @var{symbol}, @var{abs-expression}}
-
-@cindex @code{desc} directive
-@cindex COFF symbol descriptor
-@cindex symbol descriptor, COFF
-This directive sets the descriptor of the symbol (@pxref{Symbol Attributes})
-to the low 16 bits of an absolute expression.
-
-The @samp{.desc} directive is not available when @code{as} is
-configured for COFF output; it is only for @code{a.out} or @code{b.out}
-object format. For the sake of compatibility, @code{as} will accept
-it, but produce no output, when configured for COFF.
-
-@node Dim, Double, Desc, Pseudo Ops
-@section @code{.dim}
-
-@cindex @code{dim} directive
-@cindex COFF auxiliary symbol information
-@cindex auxiliary symbol information, COFF
-This directive is generated by compilers to include auxiliary debugging
-information in the symbol table. It is only permitted inside
-@code{.def}/@code{.endef} pairs.
-
-@samp{.dim} is only meaningful when generating COFF format output; when
-@code{as} is generating @code{b.out}, it accepts this directive but
-ignores it.
-
-@node Double, Eject, Dim, Pseudo Ops
-@section @code{.double @var{flonums}}
-
-@cindex @code{double} directive
-@cindex floating point numbers (double)
-@code{.double} expects zero or more flonums, separated by commas. It
-assembles floating point numbers.
-The exact kind of floating point numbers emitted depends on how
-@code{as} is configured. @xref{Machine Dependent}.
-
-@node Eject, Else, Double, Pseudo Ops
-@section @code{.eject}
-
-@cindex @code{eject} directive
-@cindex new page, in listings
-@cindex page, in listings
-@cindex listing control: new page
-Force a page break at this point, when generating assembly listings.
-
-@node Else, Endef, Eject, Pseudo Ops
-@section @code{.else}
-
-@cindex @code{else} directive
-@code{.else} is part of the @code{as} support for conditional
-assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section
-of code to be assembled if the condition for the preceding @code{.if}
-was false.
-
-
-@node Endef, Endif, Else, Pseudo Ops
-@section @code{.endef}
-
-@cindex @code{endef} directive
-This directive flags the end of a symbol definition begun with
-@code{.def}.
-
-@samp{.endef} is only meaningful when generating COFF format output; if
-@code{as} is configured to generate @code{b.out}, it accepts this
-directive but ignores it.
-
-@node Endif, Equ, Endef, Pseudo Ops
-@section @code{.endif}
-
-@cindex @code{endif} directive
-@code{.endif} is part of the @code{as} support for conditional assembly;
-it marks the end of a block of code that is only assembled
-conditionally. @xref{If,,@code{.if}}.
-
-@node Equ, Extern, Endif, Pseudo Ops
-@section @code{.equ @var{symbol}, @var{expression}}
-
-@cindex @code{equ} directive
-@cindex assigning values to symbols
-@cindex symbols, assigning values to
-This directive sets the value of @var{symbol} to @var{expression}.
-It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}.
-
-@node Extern, File, Equ, Pseudo Ops
-@section @code{.extern}
-
-@cindex @code{extern} directive
-@code{.extern} is accepted in the source program---for compatibility
-with other assemblers---but it is ignored. @code{as} treats
-all undefined symbols as external.
-
-@node File, Fill, Extern, Pseudo Ops
-@section @code{.file @var{string}}
-
-@cindex @code{file} directive
-@cindex logical file name
-@cindex file name, logical
-@code{.file} (which may also be spelled @samp{.app-file}) tells
-@code{as} that we are about to start a new logical file.
-@var{string} is the new file name. In general, the filename is
-recognized whether or not it is surrounded by quotes @samp{"}; but if
-you wish to specify an empty file name, you must give the
-quotes--@code{""}. This statement may go away in future: it is only
-recognized to be compatible with old @code{as} programs.
-In some configurations of @code{as}, @code{.file} has already been
-removed to avoid conflicts with other assemblers. @xref{Machine Dependent}.
-
-@node Fill, Float, File, Pseudo Ops
-@section @code{.fill @var{repeat} , @var{size} , @var{value}}
-
-@cindex @code{fill} directive
-@cindex writing patterns in memory
-@cindex patterns, writing in memory
-@var{result}, @var{size} and @var{value} are absolute expressions.
-This emits @var{repeat} copies of @var{size} bytes. @var{Repeat}
-may be zero or more. @var{Size} may be zero or more, but if it is
-more than 8, then it is deemed to have the value 8, compatible with
-other people's assemblers. The contents of each @var{repeat} bytes
-is taken from an 8-byte number. The highest order 4 bytes are
-zero. The lowest order 4 bytes are @var{value} rendered in the
-byte-order of an integer on the computer @code{as} is assembling for.
-Each @var{size} bytes in a repetition is taken from the lowest order
-@var{size} bytes of this number. Again, this bizarre behavior is
-compatible with other people's assemblers.
-
-@var{size} and @var{value} are optional.
-If the second comma and @var{value} are absent, @var{value} is
-assumed zero. If the first comma and following tokens are absent,
-@var{size} is assumed to be 1.
-
-@node Float, Global, Fill, Pseudo Ops
-@section @code{.float @var{flonums}}
-
-@cindex floating point numbers (single)
-@cindex @code{float} directive
-This directive assembles zero or more flonums, separated by commas. It
-has the same effect as @code{.single}.
-The exact kind of floating point numbers emitted depends on how
-@code{as} is configured.
-@xref{Machine Dependent}.
-
-@node Global, hword, Float, Pseudo Ops
-@section @code{.global @var{symbol}}, @code{.globl @var{symbol}}
-
-@cindex @code{global} directive
-@cindex symbol, making visible to linker
-@code{.global} makes the symbol visible to @code{ld}. If you define
-@var{symbol} in your partial program, its value is made available to
-other partial programs that are linked with it. Otherwise,
-@var{symbol} will take its attributes from a symbol of the same name
-from another partial program it is linked with.
-
-Both spellings (@samp{.globl} and @samp{.global}) are accepted, for
-compatibility with other assemblers.
-
-@node hword, Ident, Global, Pseudo Ops
-@section @code{.hword @var{expressions}}
-
-@cindex @code{hword} directive
-@cindex integers, 16-bit
-@cindex numbers, 16-bit
-@cindex sixteen bit integers
-This expects zero or more @var{expressions}, and emits
-a 16 bit number for each.
-
-This directive is a synonym for @samp{.short}; depending on the target
-architecture, it may also be a synonym for @samp{.word}.
-
-@node Ident, If, hword, Pseudo Ops
-@section @code{.ident}
-
-@cindex @code{ident} directive
-This directive is used by some assemblers to place tags in object files.
-@code{as} simply accepts the directive for source-file
-compatibility with such assemblers, but does not actually emit anything
-for it.
-
-@node If, Include, Ident, Pseudo Ops
-@section @code{.if @var{absolute expression}}
-
-@cindex conditional assembly
-@cindex @code{if} directive
-@code{.if} marks the beginning of a section of code which is only
-considered part of the source program being assembled if the argument
-(which must be an @var{absolute expression}) is non-zero. The end of
-the conditional section of code must be marked by @code{.endif}
-(@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
-alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}.
-
-The following variants of @code{.if} are also supported:
-@table @code
-@item .ifdef @var{symbol}
-@cindex @code{ifdef} directive
-Assembles the following section of code if the specified @var{symbol}
-has been defined.
-
-
-@item .ifndef @var{symbol}
-@itemx ifnotdef @var{symbol}
-@cindex @code{ifndef} directive
-@cindex @code{ifnotdef} directive
-Assembles the following section of code if the specified @var{symbol}
-has not been defined. Both spelling variants are equivalent.
-
-@end table
-
-@node Include, Int, If, Pseudo Ops
-@section @code{.include "@var{file}"}
-
-@cindex @code{include} directive
-@cindex supporting files, including
-@cindex files, including
-This directive provides a way to include supporting files at specified
-points in your source program. The code from @var{file} is assembled as
-if it followed the point of the @code{.include}; when the end of the
-included file is reached, assembly of the original file continues. You
-can control the search paths used with the @samp{-I} command-line option
-(@pxref{Invoking,,Command-Line Options}). Quotation marks are required
-around @var{file}.
-
-@node Int, Lcomm, Include, Pseudo Ops
-@section @code{.int @var{expressions}}
-
-@cindex @code{int} directive
-@cindex integers, 32-bit
-Expect zero or more @var{expressions}, of any section, separated by
-commas. For each expression, emit a
-32-bit
-number that will, at run
-time, be the value of that expression. The byte order of the
-expression depends on what kind of computer will run the program.
-
-@node Lcomm, Lflags, Int, Pseudo Ops
-@section @code{.lcomm @var{symbol} , @var{length}}
-
-@cindex @code{lcomm} directive
-@cindex local common symbols
-@cindex symbols, local common
-Reserve @var{length} (an absolute expression) bytes for a local common
-denoted by @var{symbol}. The section and value of @var{symbol} are
-those of the new local common. The addresses are allocated in the bss
-section, so at run-time the bytes will start off zeroed. @var{Symbol}
-is not declared global (@pxref{Global,,@code{.global}}), so is normally
-not visible to @code{ld}.
-
-@node Lflags, Line, Lcomm, Pseudo Ops
-@section @code{.lflags}
-
-@cindex @code{lflags} directive (ignored)
-@code{as} accepts this directive, for compatibility with other
-assemblers, but ignores it.
-
-@node Line, Ln, Lflags, Pseudo Ops
-@section @code{.line @var{line-number}}
-
-@cindex @code{line} directive
-@cindex logical line number
-Tell @code{as} to change the logical line number. @var{line-number} must be
-an absolute expression. The next line will have that logical line
-number. So any other statements on the current line (after a statement
-separator
-character)
-will be reported as on logical line number
-@var{line-number} @minus{} 1.
-One day this directive will be unsupported: it is used only
-for compatibility with existing assembler programs. @refill
-
-@emph{Warning:} In the AMD29K configuration of as, this command is
-only available with the name @code{.ln}, rather than as either
-@code{.line} or @code{.ln}.
-
-Even though this is a directive associated with the @code{a.out} or
-@code{b.out} object-code formats, @code{as} will still recognize it
-when producing COFF output, and will treat @samp{.line} as though it
-were the COFF @samp{.ln} @emph{if} it is found outside a
-@code{.def}/@code{.endef} pair.
-
-Inside a @code{.def}, @samp{.line} is, instead, one of the directives
-used by compilers to generate auxiliary symbol information for
-debugging.
-
-@node Ln, List, Line, Pseudo Ops
-@section @code{.ln @var{line-number}}
-
-@cindex @code{ln} directive
-@samp{.ln} is a synonym for @samp{.line}.
-
-@node List, Long, Ln, Pseudo Ops
-@section @code{.list}
-
-@cindex @code{list} directive
-@cindex listing control, turning on
-Control (in conjunction with the @code{.nolist} directive) whether or
-not assembly listings are generated. These two directives maintain an
-internal counter (which is zero initially). @code{.list} increments the
-counter, and @code{.nolist} decrements it. Assembly listings are
-generated whenever the counter is greater than zero.
-
-By default, listings are disabled. When you enable them (with the
-@samp{-a} command line option; @pxref{Invoking,,Command-Line Options}),
-the initial value of the listing counter is one.
-
-@node Long, Lsym, List, Pseudo Ops
-@section @code{.long @var{expressions}}
-
-@cindex @code{long} directive
-@code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}.
-
-@node Lsym, Nolist, Long, Pseudo Ops
-@section @code{.lsym @var{symbol}, @var{expression}}
-
-@cindex @code{lsym} directive
-@cindex symbol, not referenced in assembly
-@code{.lsym} creates a new symbol named @var{symbol}, but does not put it in
-the hash table, ensuring it cannot be referenced by name during the
-rest of the assembly. This sets the attributes of the symbol to be
-the same as the expression value:
-@smallexample
-@var{other} = @var{descriptor} = 0
-@var{type} = @r{(section of @var{expression})}
-@var{value} = @var{expression}
-@end smallexample
-@noindent
-The new symbol is not flagged as external.
-
-@node Nolist, Octa, Lsym, Pseudo Ops
-@section @code{.nolist}
-
-@cindex @code{nolist} directive
-@cindex listing control, turning off
-Control (in conjunction with the @code{.list} directive) whether or
-not assembly listings are generated. These two directives maintain an
-internal counter (which is zero initially). @code{.list} increments the
-counter, and @code{.nolist} decrements it. Assembly listings are
-generated whenever the counter is greater than zero.
-
-@node Octa, Org, Nolist, Pseudo Ops
-@section @code{.octa @var{bignums}}
-
-@c FIXME: double size emitted for "octa" on i960, others? Or warn?
-@cindex @code{octa} directive
-@cindex integer, 16-byte
-@cindex sixteen byte integer
-This directive expects zero or more bignums, separated by commas. For each
-bignum, it emits a 16-byte integer.
-
-The term ``octa'' comes from contexts in which a ``word'' is two bytes;
-hence @emph{octa}-word for 16 bytes.
-
-@node Org, Psize, Octa, Pseudo Ops
-@section @code{.org @var{new-lc} , @var{fill}}
-
-@cindex @code{org} directive
-@cindex location counter, advancing
-@cindex advancing location counter
-@cindex current address, advancing
-@code{.org} will advance the location counter of the current section to
-@var{new-lc}. @var{new-lc} is either an absolute expression or an
-expression with the same section as the current subsection. That is,
-you can't use @code{.org} to cross sections: if @var{new-lc} has the
-wrong section, the @code{.org} directive is ignored. To be compatible
-with former assemblers, if the section of @var{new-lc} is absolute,
-@code{as} will issue a warning, then pretend the section of @var{new-lc}
-is the same as the current subsection.
-
-@code{.org} may only increase the location counter, or leave it
-unchanged; you cannot use @code{.org} to move the location counter
-backwards.
-
-@c double negative used below "not undefined" because this is a specific
-@c reference to "undefined" (as SEG_UNKNOWN is called in this manual)
-@c section. pesch@cygnus.com 18feb91
-Because @code{as} tries to assemble programs in one pass @var{new-lc}
-may not be undefined. If you really detest this restriction we eagerly await
-a chance to share your improved assembler.
-
-Beware that the origin is relative to the start of the section, not
-to the start of the subsection. This is compatible with other
-people's assemblers.
-
-When the location counter (of the current subsection) is advanced, the
-intervening bytes are filled with @var{fill} which should be an
-absolute expression. If the comma and @var{fill} are omitted,
-@var{fill} defaults to zero.
-
-@node Psize, Quad, Org, Pseudo Ops
-@section @code{.psize @var{lines} , @var{columns}}
-
-@cindex @code{psize} directive
-@cindex listing control: paper size
-@cindex paper size, for listings
-Use this directive to declare the number of lines---and, optionally, the
-number of columns---to use for each page, when generating listings.
-
-If you don't use @code{.psize}, listings will use a default line-count
-of 60. You may omit the comma and @var{columns} specification; the
-default width is 200 columns.
-
-@code{as} will generate formfeeds whenever the specified number of
-lines is exceeded (or whenever you explicitly request one, using
-@code{.eject}).
-
-If you specify @var{lines} as @code{0}, no formfeeds are generated save
-those explicitly specified with @code{.eject}.
-
-@node Quad, Sbttl, Psize, Pseudo Ops
-@section @code{.quad @var{bignums}}
-
-@cindex @code{quad} directive
-@code{.quad} expects zero or more bignums, separated by commas. For
-each bignum, it emits
-an 8-byte integer. If the bignum won't fit in 8
-bytes, it prints a warning message; and just takes the lowest order 8
-bytes of the bignum.@refill
-@cindex eight-byte integer
-@cindex integer, 8-byte
-
-The term ``quad'' comes from contexts in which a ``word'' is two bytes;
-hence @emph{quad}-word for 8 bytes.
-
-@node Sbttl, Scl, Quad, Pseudo Ops
-@section @code{.sbttl "@var{subheading}"}
-
-@cindex @code{sbttl} directive
-@cindex subtitles for listings
-@cindex listing control: subtitle
-Use @var{subheading} as the title (third line, immediately after the
-title line) when generating assembly listings.
-
-This directive affects subsequent pages, as well as the current page if
-it appears within ten lines of the top of a page.
-
-@node Scl, Section, Sbttl, Pseudo Ops
-@section @code{.scl @var{class}}
-
-@cindex @code{scl} directive
-@cindex symbol storage class (COFF)
-@cindex COFF symbol storage class
-Set the storage-class value for a symbol. This directive may only be
-used inside a @code{.def}/@code{.endef} pair. Storage class may flag
-whether a symbol is static or external, or it may record further
-symbolic debugging information.
-
-The @samp{.scl} directive is primarily associated with COFF output; when
-configured to generate @code{b.out} output format, @code{as} will
-accept this directive but ignore it.
-
-@node Section, Set, Scl, Pseudo Ops
-@section @code{.section @var{name}, @var{subsection}}
-
-@cindex @code{section} directive
-@cindex named section (COFF)
-@cindex COFF named section
-Assemble the following code into end of subsection numbered
-@var{subsection} in the COFF named section @var{name}. If you omit
-@var{subsection}, @code{as} uses subsection number zero.
-@samp{.section .text} is equivalent to the @code{.text} directive;
-@samp{.section .data} is equivalent to the @code{.data} directive.
-
-@node Set, Short, Section, Pseudo Ops
-@section @code{.set @var{symbol}, @var{expression}}
-
-@cindex @code{set} directive
-@cindex symbol value, setting
-This directive sets the value of @var{symbol} to @var{expression}. This
-will change @var{symbol}'s value and type to conform to
-@var{expression}. If @var{symbol} was flagged as external, it remains
-flagged. (@xref{Symbol Attributes}.)
-
-You may @code{.set} a symbol many times in the same assembly.
-If the expression's section is unknowable during pass 1, a second
-pass over the source program will be forced. The second pass is
-currently not implemented. @code{as} will abort with an error
-message if one is required.
-
-If you @code{.set} a global symbol, the value stored in the object
-file is the last value stored into it.
-
-@node Short, Single, Set, Pseudo Ops
-@section @code{.short @var{expressions}}
-
-@cindex @code{short} directive
-@code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}.
-@node Single, Size, Short, Pseudo Ops
-@section @code{.single @var{flonums}}
-
-@cindex @code{single} directive
-@cindex floating point numbers (single)
-This directive assembles zero or more flonums, separated by commas. It
-has the same effect as @code{.float}.
-The exact kind of floating point numbers emitted depends on how
-@code{as} is configured. @xref{Machine Dependent}.
-
-@node Size, Space, Single, Pseudo Ops
-@section @code{.size}
-
-@cindex @code{size} directive
-This directive is generated by compilers to include auxiliary debugging
-information in the symbol table. It is only permitted inside
-@code{.def}/@code{.endef} pairs.
-
-@samp{.size} is only meaningful when generating COFF format output; when
-@code{as} is generating @code{b.out}, it accepts this directive but
-ignores it.
-
-@node Space, Stab, Size, Pseudo Ops
-@section @code{.space @var{size} , @var{fill}}
-
-@cindex @code{space} directive
-@cindex filling memory
-This directive emits @var{size} bytes, each of value @var{fill}. Both
-@var{size} and @var{fill} are absolute expressions. If the comma
-and @var{fill} are omitted, @var{fill} is assumed to be zero.
-
-@section @code{.space}
-
-@cindex @code{space} directive
-On the AMD 29K, this directive is ignored; it is accepted for
-compatibility with other AMD 29K assemblers.
-
-@quotation
-@emph{Warning:} In other versions of the GNU assembler, the directive
-@code{.space} has the effect of @code{.block} @xref{Machine Dependent}.
-@end quotation
-
-@node Stab, Tag, Space, Pseudo Ops
-@section @code{.stabd, .stabn, .stabs}
-
-@cindex symbolic debuggers, information for
-@cindex @code{stab@var{x}} directives
-There are three directives that begin @samp{.stab}.
-All emit symbols (@pxref{Symbols}), for use by symbolic debuggers.
-The symbols are not entered in the @code{as} hash table: they
-cannot be referenced elsewhere in the source file.
-Up to five fields are required:
-@table @var
-@item string
-This is the symbol's name. It may contain any character except @samp{\000},
-so is more general than ordinary symbol names. Some debuggers used to
-code arbitrarily complex structures into symbol names using this field.
-@item type
-An absolute expression. The symbol's type is set to the low 8
-bits of this expression.
-Any bit pattern is permitted, but @code{ld} and debuggers will choke on
-silly bit patterns.
-@item other
-An absolute expression.
-The symbol's ``other'' attribute is set to the low 8 bits of this expression.
-@item desc
-An absolute expression.
-The symbol's descriptor is set to the low 16 bits of this expression.
-@item value
-An absolute expression which becomes the symbol's value.
-@end table
-
-If a warning is detected while reading a @code{.stabd}, @code{.stabn},
-or @code{.stabs} statement, the symbol has probably already been created
-and you will get a half-formed symbol in your object file. This is
-compatible with earlier assemblers!
-
-@table @code
-@cindex @code{stabd} directive
-@item .stabd @var{type} , @var{other} , @var{desc}
-
-The ``name'' of the symbol generated is not even an empty string.
-It is a null pointer, for compatibility. Older assemblers used a
-null pointer so they didn't waste space in object files with empty
-strings.
-
-The symbol's value is set to the location counter,
-relocatably. When your program is linked, the value of this symbol
-will be where the location counter was when the @code{.stabd} was
-assembled.
-
-@item .stabn @var{type} , @var{other} , @var{desc} , @var{value}
-@cindex @code{stabn} directive
-The name of the symbol is set to the empty string @code{""}.
-
-@item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value}
-@cindex @code{stabs} directive
-All five fields are specified.
-@end table
-
-@node Tag, Text, Stab, Pseudo Ops
-@section @code{.tag @var{structname}}
-
-@cindex COFF structure debugging
-@cindex structure debugging, COFF
-@cindex @code{tag} directive
-This directive is generated by compilers to include auxiliary debugging
-information in the symbol table. It is only permitted inside
-@code{.def}/@code{.endef} pairs. Tags are used to link structure
-definitions in the symbol table with instances of those structures.
-
-@samp{.tag} is only used when generating COFF format output; when
-@code{as} is generating @code{b.out}, it accepts this directive but
-ignores it.
-
-@node Text, Title, Tag, Pseudo Ops
-@section @code{.text @var{subsection}}
-
-@cindex @code{text} directive
-Tells @code{as} to assemble the following statements onto the end of
-the text subsection numbered @var{subsection}, which is an absolute
-expression. If @var{subsection} is omitted, subsection number zero
-is used.
-
-@node Title, Type, Text, Pseudo Ops
-@section @code{.title "@var{heading}"}
-
-@cindex @code{title} directive
-@cindex listing control: title line
-Use @var{heading} as the title (second line, immediately after the
-source file name and pagenumber) when generating assembly listings.
-
-This directive affects subsequent pages, as well as the current page if
-it appears within ten lines of the top of a page.
-
-@node Type, Val, Title, Pseudo Ops
-@section @code{.type @var{int}}
-
-@cindex COFF symbol type
-@cindex symbol type, COFF
-@cindex @code{type} directive
-This directive, permitted only within @code{.def}/@code{.endef} pairs,
-records the integer @var{int} as the type attribute of a symbol table entry.
-
-@samp{.type} is associated only with COFF format output; when
-@code{as} is configured for @code{b.out} output, it accepts this
-directive but ignores it.
-
-@node Val, Word, Type, Pseudo Ops
-@section @code{.val @var{addr}}
-
-@cindex @code{val} directive
-@cindex COFF value attribute
-@cindex value attribute, COFF
-This directive, permitted only within @code{.def}/@code{.endef} pairs,
-records the address @var{addr} as the value attribute of a symbol table
-entry.
-
-@samp{.val} is used only for COFF output; when @code{as} is
-configured for @code{b.out}, it accepts this directive but ignores it.
-
-@node Word, Deprecated, Val, Pseudo Ops
-@section @code{.word @var{expressions}}
-
-@cindex @code{word} directive
-This directive expects zero or more @var{expressions}, of any section,
-separated by commas.
-
-The size of the number emitted, and its byte order,
-depends on what kind of computer will run the program.
-
-@c on amd29k, i960, sparc the "special treatment to support compilers" doesn't
-@c happen---32-bit addressability, period; no long/short jumps.
-@cindex difference tables altered
-@cindex altered difference tables
-@quotation
-@emph{Warning: Special Treatment to support Compilers}
-@end quotation
-
-Machines with a 32-bit address space, but that do less than 32-bit
-addressing, require the following special treatment. If the machine of
-interest to you does 32-bit addressing (or doesn't require it;
-@pxref{Machine Dependent}), you can ignore this issue.
-
-In order to assemble compiler output into something that will work,
-@code{as} will occasionlly do strange things to @samp{.word} directives.
-Directives of the form @samp{.word sym1-sym2} are often emitted by
-compilers as part of jump tables. Therefore, when @code{as} assembles a
-directive of the form @samp{.word sym1-sym2}, and the difference between
-@code{sym1} and @code{sym2} does not fit in 16 bits, @code{as} will
-create a @dfn{secondary jump table}, immediately before the next label.
-This secondary jump table will be preceded by a short-jump to the
-first byte after the secondary table. This short-jump prevents the flow
-of control from accidentally falling into the new table. Inside the
-table will be a long-jump to @code{sym2}. The original @samp{.word}
-will contain @code{sym1} minus the address of the long-jump to
-@code{sym2}.
-
-If there were several occurrences of @samp{.word sym1-sym2} before the
-secondary jump table, all of them will be adjusted. If there was a
-@samp{.word sym3-sym4}, that also did not fit in sixteen bits, a
-long-jump to @code{sym4} will be included in the secondary jump table,
-and the @code{.word} directives will be adjusted to contain @code{sym3}
-minus the address of the long-jump to @code{sym4}; and so on, for as many
-entries in the original jump table as necessary.
-
-
-@node Deprecated, , Word, Pseudo Ops
-@section Deprecated Directives
-
-@cindex deprecated directives
-@cindex obsolescent directives
-One day these directives won't work.
-They are included for compatibility with older assemblers.
-@table @t
-@item .abort
-@item .app-file
-@item .line
-@end table
-
-@node Machine Dependent, Copying, Pseudo Ops, Top
-@chapter Machine Dependent Features
-
-@cindex machine dependencies
-The machine instruction sets are (almost by definition) different on
-each machine where @code{as} runs. Floating point representations
-vary as well, and @code{as} often supports a few additional
-directives or command-line options for compatibility with other
-assemblers on a particular platform. Finally, some versions of
-@code{as} support special pseudo-instructions for branch
-optimization.
-
-This chapter discusses most of these differences, though it does not
-include details on any machine's instruction set. For details on that
-subject, see the hardware manufacturer's manual.
-
-@menu
-* Vax-Dependent:: VAX Dependent Features
-* AMD29K-Dependent:: AMD 29K Dependent Features
-* H8/300-Dependent:: AMD 29K Dependent Features
-* i960-Dependent:: Intel 80960 Dependent Features
-* M68K-Dependent:: M680x0 Dependent Features
-* Sparc-Dependent:: SPARC Dependent Features
-* i386-Dependent:: 80386 Dependent Features
-@end menu
-
-@node Vax-Dependent, AMD29K-Dependent, Machine Dependent, Machine Dependent
-@section VAX Dependent Features
-
-@cindex VAX support
-@menu
-* Vax-Opts:: VAX Command-Line Options
-* VAX-float:: VAX Floating Point
-* VAX-directives:: Vax Machine Directives
-* VAX-opcodes:: VAX Opcodes
-* VAX-branch:: VAX Branch Improvement
-* VAX-operands:: VAX Operands
-* VAX-no:: Not Supported on VAX
-@end menu
-
-@node Vax-Opts, VAX-float, Vax-Dependent, Vax-Dependent
-@subsection VAX Command-Line Options
-
-@cindex command-line options ignored, VAX
-@cindex VAX command-line options ignored
-The Vax version of @code{as} accepts any of the following options,
-gives a warning message that the option was ignored and proceeds.
-These options are for compatibility with scripts designed for other
-people's assemblers.
-
-@table @asis
-@item @kbd{-D} (Debug)
-@itemx @kbd{-S} (Symbol Table)
-@itemx @kbd{-T} (Token Trace)
-@cindex @code{-D}, ignored on VAX
-@cindex @code{-S}, ignored on VAX
-@cindex @code{-T}, ignored on VAX
-These are obsolete options used to debug old assemblers.
-
-@item @kbd{-d} (Displacement size for JUMPs)
-@cindex @code{-d}, VAX option
-This option expects a number following the @kbd{-d}. Like options
-that expect filenames, the number may immediately follow the
-@kbd{-d} (old standard) or constitute the whole of the command line
-argument that follows @kbd{-d} (GNU standard).
-
-@item @kbd{-V} (Virtualize Interpass Temporary File)
-@cindex @code{-V}, redundant on VAX
-Some other assemblers use a temporary file. This option
-commanded them to keep the information in active memory rather
-than in a disk file. @code{as} always does this, so this
-option is redundant.
-
-@item @kbd{-J} (JUMPify Longer Branches)
-@cindex @code{-J}, ignored on VAX
-Many 32-bit computers permit a variety of branch instructions
-to do the same job. Some of these instructions are short (and
-fast) but have a limited range; others are long (and slow) but
-can branch anywhere in virtual memory. Often there are 3
-flavors of branch: short, medium and long. Some other
-assemblers would emit short and medium branches, unless told by
-this option to emit short and long branches.
-
-@item @kbd{-t} (Temporary File Directory)
-@cindex @code{-t}, ignored on VAX
-Some other assemblers may use a temporary file, and this option
-takes a filename being the directory to site the temporary
-file. @code{as} does not use a temporary disk file, so this
-option makes no difference. @kbd{-t} needs exactly one
-filename.
-@end table
-
-@cindex VMS (VAX) options
-@cindex options for VAX/VMS
-@cindex VAX/VMS options
-@cindex @code{-h} option, VAX/VMS
-@cindex @code{-+} option, VAX/VMS
-@cindex Vax-11 C compatibility
-@cindex symbols with lowercase, VAX/VMS
-@c FIXME! look into "I think" below, correct if needed, delete.
-The Vax version of the assembler accepts two options when
-compiled for VMS. They are @kbd{-h}, and @kbd{-+}. The
-@kbd{-h} option prevents @code{as} from modifying the
-symbol-table entries for symbols that contain lowercase
-characters (I think). The @kbd{-+} option causes @code{as} to
-print warning messages if the FILENAME part of the object file,
-or any symbol name is larger than 31 characters. The @kbd{-+}
-option also insertes some code following the @samp{_main}
-symbol so that the object file will be compatible with Vax-11
-"C".
-
-@node VAX-float, VAX-directives, Vax-Opts, Vax-Dependent
-@subsection VAX Floating Point
-
-@cindex VAX floating point
-@cindex floating point, VAX
-Conversion of flonums to floating point is correct, and
-compatible with previous assemblers. Rounding is
-towards zero if the remainder is exactly half the least significant bit.
-
-@code{D}, @code{F}, @code{G} and @code{H} floating point formats
-are understood.
-
-Immediate floating literals (@emph{e.g.} @samp{S`$6.9})
-are rendered correctly. Again, rounding is towards zero in the
-boundary case.
-
-@cindex @code{float} directive, VAX
-@cindex @code{double} directive, VAX
-The @code{.float} directive produces @code{f} format numbers.
-The @code{.double} directive produces @code{d} format numbers.
-
-@node VAX-directives, VAX-opcodes, VAX-float, Vax-Dependent
-@subsection Vax Machine Directives
-
-@cindex machine directives, VAX
-@cindex VAX machine directives
-The Vax version of the assembler supports four directives for
-generating Vax floating point constants. They are described in the
-table below.
-
-@cindex wide floating point directives, VAX
-@table @code
-@item .dfloat
-@cindex @code{dfloat} directive, VAX
-This expects zero or more flonums, separated by commas, and
-assembles Vax @code{d} format 64-bit floating point constants.
-
-@item .ffloat
-@cindex @code{ffloat} directive, VAX
-This expects zero or more flonums, separated by commas, and
-assembles Vax @code{f} format 32-bit floating point constants.
-
-@item .gfloat
-@cindex @code{gfloat} directive, VAX
-This expects zero or more flonums, separated by commas, and
-assembles Vax @code{g} format 64-bit floating point constants.
-
-@item .hfloat
-@cindex @code{hfloat} directive, VAX
-This expects zero or more flonums, separated by commas, and
-assembles Vax @code{h} format 128-bit floating point constants.
-
-@end table
-
-@node VAX-opcodes, VAX-branch, VAX-directives, Vax-Dependent
-@subsection VAX Opcodes
-
-@cindex VAX opcode mnemonics
-@cindex opcode mnemonics, VAX
-@cindex mnemonics for opcodes, VAX
-All DEC mnemonics are supported. Beware that @code{case@dots{}}
-instructions have exactly 3 operands. The dispatch table that
-follows the @code{case@dots{}} instruction should be made with
-@code{.word} statements. This is compatible with all unix
-assemblers we know of.
-
-@node VAX-branch, VAX-operands, VAX-opcodes, Vax-Dependent
-@subsection VAX Branch Improvement
-
-@cindex VAX branch improvement
-@cindex branch improvement, VAX
-@cindex pseudo-ops for branch, VAX
-Certain pseudo opcodes are permitted. They are for branch
-instructions. They expand to the shortest branch instruction that
-will reach the target. Generally these mnemonics are made by
-substituting @samp{j} for @samp{b} at the start of a DEC mnemonic.
-This feature is included both for compatibility and to help
-compilers. If you don't need this feature, don't use these
-opcodes. Here are the mnemonics, and the code they can expand into.
-
-@table @code
-@item jbsb
-@samp{Jsb} is already an instruction mnemonic, so we chose @samp{jbsb}.
-@table @asis
-@item (byte displacement)
-@kbd{bsbb @dots{}}
-@item (word displacement)
-@kbd{bsbw @dots{}}
-@item (long displacement)
-@kbd{jsb @dots{}}
-@end table
-@item jbr
-@itemx jr
-Unconditional branch.
-@table @asis
-@item (byte displacement)
-@kbd{brb @dots{}}
-@item (word displacement)
-@kbd{brw @dots{}}
-@item (long displacement)
-@kbd{jmp @dots{}}
-@end table
-@item j@var{COND}
-@var{COND} may be any one of the conditional branches
-@code{neq nequ eql eqlu gtr geq lss gtru lequ vc vs gequ cc lssu cs}.
-@var{COND} may also be one of the bit tests
-@code{bs bc bss bcs bsc bcc bssi bcci lbs lbc}.
-@var{NOTCOND} is the opposite condition to @var{COND}.
-@table @asis
-@item (byte displacement)
-@kbd{b@var{COND} @dots{}}
-@item (word displacement)
-@kbd{b@var{NOTCOND} foo ; brw @dots{} ; foo:}
-@item (long displacement)
-@kbd{b@var{NOTCOND} foo ; jmp @dots{} ; foo:}
-@end table
-@item jacb@var{X}
-@var{X} may be one of @code{b d f g h l w}.
-@table @asis
-@item (word displacement)
-@kbd{@var{OPCODE} @dots{}}
-@item (long displacement)
-@example
-@var{OPCODE} @dots{}, foo ;
-brb bar ;
-foo: jmp @dots{} ;
-bar:
-@end example
-@end table
-@item jaob@var{YYY}
-@var{YYY} may be one of @code{lss leq}.
-@item jsob@var{ZZZ}
-@var{ZZZ} may be one of @code{geq gtr}.
-@table @asis
-@item (byte displacement)
-@kbd{@var{OPCODE} @dots{}}
-@item (word displacement)
-@example
-@var{OPCODE} @dots{}, foo ;
-brb bar ;
-foo: brw @var{destination} ;
-bar:
-@end example
-@item (long displacement)
-@example
-@var{OPCODE} @dots{}, foo ;
-brb bar ;
-foo: jmp @var{destination} ;
-bar:
-@end example
-@end table
-@item aobleq
-@itemx aoblss
-@itemx sobgeq
-@itemx sobgtr
-@table @asis
-@item (byte displacement)
-@kbd{@var{OPCODE} @dots{}}
-@item (word displacement)
-@example
-@var{OPCODE} @dots{}, foo ;
-brb bar ;
-foo: brw @var{destination} ;
-bar:
-@end example
-@item (long displacement)
-@example
-@var{OPCODE} @dots{}, foo ;
-brb bar ;
-foo: jmp @var{destination} ;
-bar:
-@end example
-@end table
-@end table
-
-@node VAX-operands, VAX-no, VAX-branch, Vax-Dependent
-@subsection VAX Operands
-
-@cindex VAX operand notation
-@cindex operand notation, VAX
-@cindex immediate character, VAX
-@cindex VAX immediate character
-The immediate character is @samp{$} for Unix compatibility, not
-@samp{#} as DEC writes it.
-
-@cindex indirect character, VAX
-@cindex VAX indirect character
-The indirect character is @samp{*} for Unix compatibility, not
-@samp{@@} as DEC writes it.
-
-@cindex displacement sizing character, VAX
-@cindex VAX displacement sizing character
-The displacement sizing character is @samp{`} (an accent grave) for
-Unix compatibility, not @samp{^} as DEC writes it. The letter
-preceding @samp{`} may have either case. @samp{G} is not
-understood, but all other letters (@code{b i l s w}) are understood.
-
-@cindex register names, VAX
-@cindex VAX register names
-Register names understood are @code{r0 r1 r2 @dots{} r15 ap fp sp
-pc}. Any case of letters will do.
-
-For instance
-@smallexample
-tstb *w`$4(r5)
-@end smallexample
-
-Any expression is permitted in an operand. Operands are comma
-separated.
-
-@c There is some bug to do with recognizing expressions
-@c in operands, but I forget what it is. It is
-@c a syntax clash because () is used as an address mode
-@c and to encapsulate sub-expressions.
-
-@node VAX-no, , VAX-operands, Vax-Dependent
-@subsection Not Supported on VAX
-
-@cindex VAX bitfields not supported
-@cindex bitfields, not supported on VAX
-Vax bit fields can not be assembled with @code{as}. Someone
-can add the required code if they really need it.
-
-@node AMD29K-Dependent, H8/300-Dependent, Vax-Dependent, Machine Dependent
-@section AMD 29K Dependent Features
-
-@cindex AMD 29K support
-@cindex 29K support
-@menu
-* AMD29K Options:: Options
-* AMD29K Syntax:: Syntax
-* AMD29K Floating Point:: Floating Point
-* AMD29K Directives:: AMD 29K Machine Directives
-* AMD29K Opcodes:: Opcodes
-@end menu
-
-@node AMD29K Options, AMD29K Syntax, AMD29K-Dependent, AMD29K-Dependent
-@subsection Options
-@cindex AMD 29K options (none)
-@cindex options for AMD29K (none)
-@code{as} has no additional command-line options for the AMD
-29K family.
-
-@node AMD29K Syntax, AMD29K Floating Point, AMD29K Options, AMD29K-Dependent
-@subsection Syntax
-@menu
-* AMD29K-Chars:: Special Characters
-* AMD29K-Regs:: Register Names
-@end menu
-
-@node AMD29K-Chars, AMD29K-Regs, AMD29K Syntax, AMD29K Syntax
-@subsubsection Special Characters
-
-@cindex line comment character, AMD 29K
-@cindex AMD 29K line comment character
-@samp{;} is the line comment character.
-
-@cindex line separator, AMD 29K
-@cindex AMD 29K line separator
-@cindex statement separator, AMD 29K
-@cindex AMD 29K statement separator
-@samp{@@} can be used instead of a newline to separate statements.
-
-@cindex identifiers, AMD 29K
-@cindex AMD 29K identifiers
-The character @samp{?} is permitted in identifiers (but may not begin
-an identifier).
-
-@node AMD29K-Regs, , AMD29K-Chars, AMD29K Syntax
-@subsubsection Register Names
-
-@cindex AMD 29K register names
-@cindex register names, AMD 29K
-General-purpose registers are represented by predefined symbols of the
-form @samp{GR@var{nnn}} (for global registers) or @samp{LR@var{nnn}}
-(for local registers), where @var{nnn} represents a number between
-@code{0} and @code{127}, written with no leading zeros. The leading
-letters may be in either upper or lower case; for example, @samp{gr13}
-and @samp{LR7} are both valid register names.
-
-You may also refer to general-purpose registers by specifying the
-register number as the result of an expression (prefixed with @samp{%%}
-to flag the expression as a register number):
-@smallexample
-%%@var{expression}
-@end smallexample
-@noindent
----where @var{expression} must be an absolute expression evaluating to a
-number between @code{0} and @code{255}. The range [0, 127] refers to
-global registers, and the range [128, 255] to local registers.
-
-@cindex special purpose registers, AMD 29K
-@cindex AMD 29K special purpose registers
-@cindex protected registers, AMD 29K
-@cindex AMD 29K protected registers
-In addition, @code{as} understands the following protected
-special-purpose register names for the AMD 29K family:
-
-@smallexample
- vab chd pc0
- ops chc pc1
- cps rbp pc2
- cfg tmc mmu
- cha tmr lru
-@end smallexample
-
-These unprotected special-purpose register names are also recognized:
-@smallexample
- ipc alu fpe
- ipa bp inte
- ipb fc fps
- q cr exop
-@end smallexample
-
-@node AMD29K Floating Point, AMD29K Directives, AMD29K Syntax, AMD29K-Dependent
-@subsection Floating Point
-
-@cindex floating point, AMD 29K (@sc{ieee})
-@cindex AMD 29K floating point (@sc{ieee})
-The AMD 29K family uses @sc{ieee} floating-point numbers.
-
-@node AMD29K Directives, AMD29K Opcodes, AMD29K Floating Point, AMD29K-Dependent
-@subsection AMD 29K Machine Directives
-
-@cindex machine directives, AMD 29K
-@cindex AMD 29K machine directives
-@table @code
-@item .block @var{size} , @var{fill}
-@cindex @code{block} directive, AMD 29K
-This directive emits @var{size} bytes, each of value @var{fill}. Both
-@var{size} and @var{fill} are absolute expressions. If the comma
-and @var{fill} are omitted, @var{fill} is assumed to be zero.
-
-In other versions of the GNU assembler, this directive is called
-@samp{.space}.
-@end table
-
-@table @code
-@item .cputype
-@cindex @code{cputype} directive, AMD 29K
-This directive is ignored; it is accepted for compatibility with other
-AMD 29K assemblers.
-
-@item .file
-@cindex @code{file} directive, AMD 29K
-This directive is ignored; it is accepted for compatibility with other
-AMD 29K assemblers.
-
-@quotation
-@emph{Warning:} in other versions of the GNU assembler, @code{.file} is
-used for the directive called @code{.app-file} in the AMD 29K support.
-@end quotation
-
-@item .line
-@cindex @code{line} directive, AMD 29K
-This directive is ignored; it is accepted for compatibility with other
-AMD 29K assemblers.
-
-@item .reg @var{symbol}, @var{expression}
-@cindex @code{reg} directive, AMD 29K
-@code{.reg} has the same effect as @code{.lsym}; @pxref{Lsym,,@code{.lsym}}.
-
-@item .sect
-@cindex @code{sect} directive, AMD 29K
-This directive is ignored; it is accepted for compatibility with other
-AMD 29K assemblers.
-
-@item .use @var{section name}
-@cindex @code{use} directive, AMD 29K
-Establishes the section and subsection for the following code;
-@var{section name} may be one of @code{.text}, @code{.data},
-@code{.data1}, or @code{.lit}. With one of the first three @var{section
-name} options, @samp{.use} is equivalent to the machine directive
-@var{section name}; the remaining case, @samp{.use .lit}, is the same as
-@samp{.data 200}.
-@end table
-
-@node AMD29K Opcodes, , AMD29K Directives, AMD29K-Dependent
-@subsection Opcodes
-
-@cindex AMD 29K opcodes
-@cindex opcodes for AMD 29K
-@code{as} implements all the standard AMD 29K opcodes. No
-additional pseudo-instructions are needed on this family.
-
-For information on the 29K machine instruction set, see @cite{Am29000
-User's Manual}, Advanced Micro Devices, Inc.
-
-@node H8/300-Dependent, i960-Dependent, AMD29K-Dependent, Machine Dependent
-@section H8/300 Dependent Features
-
-@cindex H8/300 support
-@menu
-* H8/300 Options:: Options
-* H8/300 Syntax:: Syntax
-* H8/300 Floating Point:: Floating Point
-* H8/300 Directives:: H8/300 Machine Directives
-* H8/300 Opcodes:: Opcodes
-@end menu
-
-@node H8/300 Options, H8/300 Syntax, H8/300-Dependent, H8/300-Dependent
-@subsection Options
-
-@cindex H8/300 options (none)
-@cindex options, H8/300 (none)
-@code{as} has no additional command-line options for the Hitachi
-H8/300 family.
-
-@node H8/300 Syntax, H8/300 Floating Point, H8/300 Options, H8/300-Dependent
-@subsection Syntax
-@menu
-* H8/300-Chars:: Special Characters
-* H8/300-Regs:: Register Names
-* H8/300-Addressing:: Addressing Modes
-@end menu
-
-@node H8/300-Chars, H8/300-Regs, H8/300 Syntax, H8/300 Syntax
-@subsubsection Special Characters
-
-@cindex line comment character, H8/300
-@cindex H8/300 line comment character
-@samp{;} is the line comment character.
-
-@cindex line separator, H8/300
-@cindex statement separator, H8/300
-@cindex H8/300 line separator
-@samp{$} can be used instead of a newline to separate statements.
-Therefore @emph{you may not use @samp{$} in symbol names} on the H8/300.
-
-@node H8/300-Regs, H8/300-Addressing, H8/300-Chars, H8/300 Syntax
-@subsubsection Register Names
-
-@cindex H8/300 registers
-@cindex registers, H8/300
-You can use predefined symbols of the form @samp{r@var{n}h} and
-@samp{r@var{n}l} to refer to the H8/300 registers as sixteen 8-bit
-general-purpose registers. @var{n} is a digit from @samp{0} to
-@samp{7}); for instance, both @samp{r0h} and @samp{r7l} are valid
-register names.
-
-You can also use the eight predefined symbols @samp{r@var{n}} to refer
-to the H8/300 registers as 16-bit registers (you must use this form for
-addressing).
-
-The two control registers are called @code{pc} (program counter; a
-16-bit register) and @code{ccr} (condition code register; an 8-bit
-register). @code{r7} is used as the stack pointer, and can also be
-called @code{sp}.
-
-@node H8/300-Addressing, , H8/300-Regs, H8/300 Syntax
-@subsubsection Addressing Modes
-
-@cindex addressing modes, H8/300
-@cindex H8/300 addressing modes
-as understands the following addressing modes for the H8/300:
-@table @code
-@item r@var{n}
-Register direct
-
-@item @@r@var{n}
-Register indirect
-
-@item @@(@var{d}, r@var{n})
-@itemx @@(@var{d}:16, r@var{n})
-Register indirect: 16-bit displacement @var{d} from register @var{n}.
-(You may specify the @samp{:16} for clarity if you wish, but it is not
-required and has no effect.)
-
-@item @@r@var{n}+
-Register indirect with post-increment
-
-@item @@-r@var{n}
-Register indirect with pre-decrement
-
-@item @code{@@}@var{aa}
-@itemx @code{@@}@var{aa}:8
-@itemx @code{@@}@var{aa}:16
-Absolute address @code{aa}. You may specify the @samp{:8} or @samp{:16}
-for clarity, if you wish; but @code{as} neither requires this nor
-uses it---the address size required is taken from context.
-
-@item #@var{xx}
-@itemx #@var{xx}:8
-@itemx #@var{xx}:16
-Immediate data @var{xx}. You may specify the @samp{:8} or @samp{:16}
-for clarity, if you wish; but @code{as} neither requires this nor
-uses it---the data size required is taken from context.
-
-@item @code{@@}@code{@@}@var{aa}
-@itemx @code{@@}@code{@@}@var{aa}:8
-Memory indirect. You may specify the @samp{:8} for clarity, if you
-wish; but @code{as} neither requires this nor uses it.
-@end table
-
-@node H8/300 Floating Point, H8/300 Directives, H8/300 Syntax, H8/300-Dependent
-@subsection Floating Point
-
-@cindex floating point, H8/300 (@sc{ieee})
-@cindex H8/300 floating point (@sc{ieee})
-The H8/300 family uses @sc{ieee} floating-point numbers.
-
-@node H8/300 Directives, H8/300 Opcodes, H8/300 Floating Point, H8/300-Dependent
-@subsection H8/300 Machine Directives
-
-@cindex H8/300 machine directives (none)
-@cindex machine directives, H8/300 (none)
-@cindex @code{word} directive, H8/300
-@cindex @code{int} directive, H8/300
-@code{as} has no machine-dependent directives for the H8/300.
-However, on this platform the @samp{.int} and @samp{.word} directives
-generate 16-bit numbers.
-
-@node H8/300 Opcodes, , H8/300 Directives, H8/300-Dependent
-@subsection Opcodes
-
-@cindex H8/300 opcode summary
-@cindex opcode summary, H8/300
-@cindex mnemonics, H8/300
-@cindex instruction summary, H8/300
-For detailed information on the H8/300 machine instruction set, see
-@cite{H8/300 Series Programming Manual} (Hitachi ADE--602--025).
-
-@code{as} implements all the standard H8/300 opcodes. No additional
-pseudo-instructions are needed on this family.
-
-The following table summarizes the opcodes and their arguments:
-@c kluge due to lack of group outside example
-@page
-@smallexample
-@group
- Rs @r{source register}
- Rd @r{destination register}
- imm @r{immediate data}
- x:3 @r{a bit (as a number between 0 and 7)}
- d:8 @r{eight bit displacement from @code{pc}}
- d:16 @r{sixteen bit displacement from @code{Rs}}
-
-add.b Rs,Rd biand #x:3,Rd
-add.b #imm:8,Rd biand #x:3,@@Rd
-add.w Rs,Rd biand #x:3,@@aa:8
-adds #1,Rd bild #x:3,Rd
-adds #2,Rd bild #x:3,@@Rd
-addx #imm:8,Rd bild #x:3,@@aa:8
-addx Rs,Rd bior #x:3,Rd
-and #imm:8,Rd bior #x:3,@@Rd
-and Rs,Rd bior #x:3,@@aa:8
-andc #imm:8,ccr bist #x:3,Rd
-band #x:3,Rd bist #x:3,@@Rd
-band #x:3,@@Rd bist #x:3,@@aa:8
-bra d:8 bixor #x:3,Rd
-bt d:8 bixor #x:3,@@Rd
-brn d:8 bixor #x:3,@@aa:8
-bf d:8 bld #x:3,Rd
-bhi d:8 bld #x:3,@@Rd
-bls d:8 bld #x:3,@@aa:8
-bcc d:8 bnot #x:3,Rd
-bhs d:8 bnot #x:3,@@Rd
-bcs d:8 bnot #x:3,@@aa:8
-blo d:8 bnot Rs,Rd
-bne d:8 bnot Rs,@@Rd
-beq d:8 bnot Rs,@@aa:8
-bvc d:8 bor #x:3,Rd
-bvs d:8 bor #x:3,@@Rd
-bpl d:8 bor #x:3,@@aa:8
-bmi d:8 bset #x:3,@@Rd
-bge d:8 bset #x:3,@@aa:8
-blt d:8 bset Rs,Rd
-bgt d:8 bset Rs,@@Rd
-ble d:8 bset Rs,@@aa:8
-bclr #x:3,Rd bsr d:8
-bclr #x:3,@@Rd bst #x:3,Rd
-bclr #x:3,@@aa:8 bst #x:3,@@Rd
-bclr Rs,Rd bst #x:3,@@aa:8
-bclr Rs,@@Rd btst #x:3,Rd
-@end group
-@group
-btst #x:3,@@Rd mov.w @@(d:16, Rs),Rd
-btst #x:3,@@aa:8 mov.w @@Rs+,Rd
-btst Rs,Rd mov.w @@aa:16,Rd
-btst Rs,@@Rd mov.w Rs,@@Rd
-btst Rs,@@aa:8 mov.w Rs,@@(d:16, Rd)
-bxor #x:3,Rd mov.w Rs,@@-Rd
-bxor #x:3,@@Rd mov.w Rs,@@aa:16
-bxor #x:3,@@aa:8 movfpe @@aa:16,Rd
-cmp.b #imm:8,Rd movtpe Rs,@@aa:16
-cmp.b Rs,Rd mulxu Rs,Rd
-cmp.w Rs,Rd neg Rs
-daa Rs nop
-das Rs not Rs
-dec Rs or #imm:8,Rd
-divxu Rs,Rd or Rs,Rd
-eepmov orc #imm:8,ccr
-inc Rs pop Rs
-jmp @@Rs push Rs
-jmp @@aa:16 rotl Rs
-jmp @@@@aa rotr Rs
-jsr @@Rs rotxl Rs
-jsr @@aa:16 rotxr Rs
-jsr @@@@aa:8 rte
-ldc #imm:8,ccr rts
-ldc Rs,ccr shal Rs
-mov.b Rs,Rd shar Rs
-mov.b #imm:8,Rd shll Rs
-mov.b @@Rs,Rd shlr Rs
-mov.b @@(d:16, Rs),Rd sleep
-mov.b @@Rs+,Rd stc ccr,Rd
-mov.b @@aa:16,Rd sub.b Rs,Rd
-mov.b @@aa:8,Rd sub.w Rs,Rd
-mov.b Rs,@@Rd subs #1,Rd
-mov.b Rs,@@(d:16, Rd) subs #2,Rd
-mov.b Rs,@@-Rd subx #imm:8,Rd
-mov.b Rs,@@aa:16 subx Rs,Rd
-mov.b Rs,@@aa:8 xor #imm:8,Rd
-mov.w Rs,Rd xor Rs,Rd
-mov.w #imm:16,Rd xorc #imm:8,ccr
-mov.w @@Rs,Rd
-@end group
-@end smallexample
-
-@cindex size suffixes, H8/300
-@cindex H8/300 size suffixes
-Four H8/300 instructions (@code{add}, @code{cmp}, @code{mov},
-@code{sub}) are defined with variants using the suffixes @samp{.b} and
-@samp{.w} to specify the size of a memory operand. @code{as}
-supports these suffixes, but does not require them; since one of the
-operands is always a register, @code{as} can deduce the correct size.
-
-For example, since @code{r0} refers to a 16-bit register,
-@example
-mov r0,@@foo
-@exdent is equivalent to
-mov.w r0,@@foo
-@end example
-
-If you use the size suffixes, @code{as} will issue a warning if
-there's a mismatch between the suffix and the register size.
-
-@node i960-Dependent, M68K-Dependent, H8/300-Dependent, Machine Dependent
-@section Intel 80960 Dependent Features
-
-@cindex i960 support
-@menu
-* Options-i960:: i960 Command-line Options
-* Floating Point-i960:: Floating Point
-* Directives-i960:: i960 Machine Directives
-* Opcodes for i960:: i960 Opcodes
-@end menu
-
-@c FIXME! Add Syntax sec with discussion of bitfields here, at least so
-@c long as they're not turned on for other machines than 960.
-@node Options-i960, Floating Point-i960, i960-Dependent, i960-Dependent
-
-@subsection i960 Command-line Options
-
-@cindex i960 options
-@cindex options, i960
-@table @code
-
-@item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
-@cindex i960 architecture options
-@cindex architecture options, i960
-@cindex @code{-A} options, i960
-Select the 80960 architecture. Instructions or features not supported
-by the selected architecture cause fatal errors.
-
-@samp{-ACA} is equivalent to @samp{-ACA_A}; @samp{-AKC} is equivalent to
-@samp{-AMC}. Synonyms are provided for compatibility with other tools.
-
-If none of these options is specified, @code{as} will generate code for any
-instruction or feature that is supported by @emph{some} version of the
-960 (even if this means mixing architectures!). In principle,
-@code{as} will attempt to deduce the minimal sufficient processor
-type if none is specified; depending on the object code format, the
-processor type may be recorded in the object file. If it is critical
-that the @code{as} output match a specific architecture, specify that
-architecture explicitly.
-
-@item -b
-@cindex @code{-b} option, i960
-@cindex branch recording, i960
-@cindex i960 branch recording
-Add code to collect information about conditional branches taken, for
-later optimization using branch prediction bits. (The conditional branch
-instructions have branch prediction bits in the CA, CB, and CC
-architectures.) If @var{BR} represents a conditional branch instruction,
-the following represents the code generated by the assembler when
-@samp{-b} is specified:
-
-@smallexample
- call @var{increment routine}
- .word 0 # pre-counter
-Label: @var{BR}
- call @var{increment routine}
- .word 0 # post-counter
-@end smallexample
-
-The counter following a branch records the number of times that branch
-was @emph{not} taken; the differenc between the two counters is the
-number of times the branch @emph{was} taken.
-
-@cindex @code{gbr960}, i960 postprocessor
-@cindex branch statistics table, i960
-A table of every such @code{Label} is also generated, so that the
-external postprocessor @code{gbr960} (supplied by Intel) can locate all
-the counters. This table is always labelled @samp{__BRANCH_TABLE__};
-this is a local symbol to permit collecting statistics for many separate
-object files. The table is word aligned, and begins with a two-word
-header. The first word, initialized to 0, is used in maintaining linked
-lists of branch tables. The second word is a count of the number of
-entries in the table, which follow immediately: each is a word, pointing
-to one of the labels illustrated above.
-
-@c TEXI2ROFF-KILL
-@ifinfo
-@c END TEXI2ROFF-KILL
-@example
- +------------+------------+------------+ ... +------------+
- | | | | | |
- | *NEXT | COUNT: N | *BRLAB 1 | | *BRLAB N |
- | | | | | |
- +------------+------------+------------+ ... +------------+
-
- __BRANCH_TABLE__ layout
-@end example
-@c TEXI2ROFF-KILL
-@end ifinfo
-@tex
-\vskip 1pc
-\line{\leftskip=0pt\hskip\tableindent
-\boxit{2cm}{\tt *NEXT}\boxit{2cm}{\tt COUNT: \it N}\boxit{2cm}{\tt
-*BRLAB 1}\ibox{1cm}{\quad\dots}\boxit{2cm}{\tt *BRLAB \it N}\hfil}
-\centerline{\it {\tt \_\_BRANCH\_TABLE\_\_} layout}
-@end tex
-@c END TEXI2ROFF-KILL
-
-The first word of the header is used to locate multiple branch tables,
-since each object file may contain one. Normally the links are
-maintained with a call to an initialization routine, placed at the
-beginning of each function in the file. The GNU C compiler will
-generate these calls automatically when you give it a @samp{-b} option.
-For further details, see the documentation of @samp{gbr960}.
-
-@item -norelax
-@cindex @code{-norelax} option, i960
-Normally, Compare-and-Branch instructions with targets that require
-displacements greater than 13 bits (or that have external targets) are
-replaced with the corresponding compare (or @samp{chkbit}) and branch
-instructions. You can use the @samp{-norelax} option to specify that
-@code{as} should generate errors instead, if the target displacement
-is larger than 13 bits.
-
-This option does not affect the Compare-and-Jump instructions; the code
-emitted for them is @emph{always} adjusted when necessary (depending on
-displacement size), regardless of whether you use @samp{-norelax}.
-@end table
-
-@node Floating Point-i960, Directives-i960, Options-i960, i960-Dependent
-@subsection Floating Point
-
-@cindex floating point, i960 (@sc{ieee})
-@cindex i960 floating point (@sc{ieee})
-@code{as} generates @sc{ieee} floating-point numbers for the directives
-@samp{.float}, @samp{.double}, @samp{.extended}, and @samp{.single}.
-
-@node Directives-i960, Opcodes for i960, Floating Point-i960, i960-Dependent
-@subsection i960 Machine Directives
-
-@cindex machine directives, i960
-@cindex i960 machine directives
-
-@table @code
-@cindex @code{bss} directive, i960
-@item .bss @var{symbol}, @var{length}, @var{align}
-Reserve @var{length} bytes in the bss section for a local @var{symbol},
-aligned to the power of two specified by @var{align}. @var{length} and
-@var{align} must be positive absolute expressions. This directive
-differs from @samp{.lcomm} only in that it permits you to specify
-an alignment. @xref{Lcomm,,@code{.lcomm}}.
-@end table
-
-@table @code
-@item .extended @var{flonums}
-@cindex @code{extended} directive, i960
-@code{.extended} expects zero or more flonums, separated by commas; for
-each flonum, @samp{.extended} emits an @sc{ieee} extended-format (80-bit)
-floating-point number.
-
-@item .leafproc @var{call-lab}, @var{bal-lab}
-@cindex @code{leafproc} directive, i960
-You can use the @samp{.leafproc} directive in conjunction with the
-optimized @code{callj} instruction to enable faster calls of leaf
-procedures. If a procedure is known to call no other procedures, you
-may define an entry point that skips procedure prolog code (and that does
-not depend on system-supplied saved context), and declare it as the
-@var{bal-lab} using @samp{.leafproc}. If the procedure also has an
-entry point that goes through the normal prolog, you can specify that
-entry point as @var{call-lab}.
-
-A @samp{.leafproc} declaration is meant for use in conjunction with the
-optimized call instruction @samp{callj}; the directive records the data
-needed later to choose between converting the @samp{callj} into a
-@code{bal} or a @code{call}.
-
-@var{call-lab} is optional; if only one argument is present, or if the
-two arguments are identical, the single argument is assumed to be the
-@code{bal} entry point.
-
-@item .sysproc @var{name}, @var{index}
-@cindex @code{sysproc} directive, i960
-The @samp{.sysproc} directive defines a name for a system procedure.
-After you define it using @samp{.sysproc}, you can use @var{name} to
-refer to the system procedure identified by @var{index} when calling
-procedures with the optimized call instruction @samp{callj}.
-
-Both arguments are required; @var{index} must be between 0 and 31
-(inclusive).
-@end table
-
-@node Opcodes for i960, , Directives-i960, i960-Dependent
-@subsection i960 Opcodes
-
-@cindex opcodes, i960
-@cindex i960 opcodes
-All Intel 960 machine instructions are supported;
-@pxref{Options-i960,,i960 Command-line Options} for a discussion of
-selecting the instruction subset for a particular 960
-architecture.@refill
-
-Some opcodes are processed beyond simply emitting a single corresponding
-instruction: @samp{callj}, and Compare-and-Branch or Compare-and-Jump
-instructions with target displacements larger than 13 bits.
-
-@menu
-* callj-i960:: @code{callj}
-* Compare-and-branch-i960:: Compare-and-Branch
-@end menu
-
-@node callj-i960, Compare-and-branch-i960, Opcodes for i960, Opcodes for i960
-@subsubsection @code{callj}
-
-@cindex @code{callj}, i960 pseudo-opcode
-@cindex i960 @code{callj} pseudo-opcode
-You can write @code{callj} to have the assembler or the linker determine
-the most appropriate form of subroutine call: @samp{call},
-@samp{bal}, or @samp{calls}. If the assembly source contains
-enough information---a @samp{.leafproc} or @samp{.sysproc} directive
-defining the operand---then @code{as} will translate the
-@code{callj}; if not, it will simply emit the @code{callj}, leaving it
-for the linker to resolve.
-
-@node Compare-and-branch-i960, , callj-i960, Opcodes for i960
-@subsubsection Compare-and-Branch
-
-@cindex i960 compare and branch instructions
-@cindex compare and branch instructions, i960
-The 960 architectures provide combined Compare-and-Branch instructions
-that permit you to store the branch target in the lower 13 bits of the
-instruction word itself. However, if you specify a branch target far
-enough away that its address won't fit in 13 bits, the assembler can
-either issue an error, or convert your Compare-and-Branch instruction
-into separate instructions to do the compare and the branch.
-
-@cindex compare and jump expansions, i960
-@cindex i960 compare and jump expansions
-Whether @code{as} gives an error or expands the instruction depends
-on two choices you can make: whether you use the @samp{-norelax} option,
-and whether you use a ``Compare and Branch'' instruction or a ``Compare
-and Jump'' instruction. The ``Jump'' instructions are @emph{always}
-expanded if necessary; the ``Branch'' instructions are expanded when
-necessary @emph{unless} you specify @code{-norelax}---in which case
-@code{as} gives an error instead.
-
-These are the Compare-and-Branch instructions, their ``Jump'' variants,
-and the instruction pairs they may expand into:
-
-@c TEXI2ROFF-KILL
-@ifinfo
-@c END TEXI2ROFF-KILL
-@example
- Compare and
- Branch Jump Expanded to
- ------ ------ ------------
- bbc chkbit; bno
- bbs chkbit; bo
- cmpibe cmpije cmpi; be
- cmpibg cmpijg cmpi; bg
- cmpibge cmpijge cmpi; bge
- cmpibl cmpijl cmpi; bl
- cmpible cmpijle cmpi; ble
- cmpibno cmpijno cmpi; bno
- cmpibne cmpijne cmpi; bne
- cmpibo cmpijo cmpi; bo
- cmpobe cmpoje cmpo; be
- cmpobg cmpojg cmpo; bg
- cmpobge cmpojge cmpo; bge
- cmpobl cmpojl cmpo; bl
- cmpoble cmpojle cmpo; ble
- cmpobne cmpojne cmpo; bne
-@end example
-@c TEXI2ROFF-KILL
-@end ifinfo
-@tex
-\hskip\tableindent
-\halign{\hfil {\tt #}\quad&\hfil {\tt #}\qquad&{\tt #}\hfil\cr
-\omit{\hfil\it Compare and\hfil}\span\omit&\cr
-{\it Branch}&{\it Jump}&{\it Expanded to}\cr
- bbc& & chkbit; bno\cr
- bbs& & chkbit; bo\cr
- cmpibe& cmpije& cmpi; be\cr
- cmpibg& cmpijg& cmpi; bg\cr
- cmpibge& cmpijge& cmpi; bge\cr
- cmpibl& cmpijl& cmpi; bl\cr
- cmpible& cmpijle& cmpi; ble\cr
- cmpibno& cmpijno& cmpi; bno\cr
- cmpibne& cmpijne& cmpi; bne\cr
- cmpibo& cmpijo& cmpi; bo\cr
- cmpobe& cmpoje& cmpo; be\cr
- cmpobg& cmpojg& cmpo; bg\cr
- cmpobge& cmpojge& cmpo; bge\cr
- cmpobl& cmpojl& cmpo; bl\cr
- cmpoble& cmpojle& cmpo; ble\cr
- cmpobne& cmpojne& cmpo; bne\cr}
-@end tex
-@c END TEXI2ROFF-KILL
-
-@c FIXME! node conds are only sufficient for m68k alone, all, and vintage
-@node M68K-Dependent, Sparc-Dependent, i960-Dependent, Machine Dependent
-@section M680x0 Dependent Features
-
-@cindex M680x0 support
-@menu
-* M68K-Opts:: M680x0 Options
-* M68K-Syntax:: Syntax
-* M68K-Float:: Floating Point
-* M68K-Directives:: 680x0 Machine Directives
-* M68K-opcodes:: Opcodes
-@end menu
-
-@node M68K-Opts, M68K-Syntax, M68K-Dependent, M68K-Dependent
-@subsection M680x0 Options
-
-@cindex options, M680x0
-@cindex M680x0 options
-The Motorola 680x0 version of @code{as} has two machine dependent options.
-One shortens undefined references from 32 to 16 bits, while the
-other is used to tell @code{as} what kind of machine it is
-assembling for.
-
-@cindex @code{-l} option, M680x0
-You can use the @kbd{-l} option to shorten the size of references to
-undefined symbols. If the @kbd{-l} option is not given, references to
-undefined symbols will be a full long (32 bits) wide. (Since @code{as}
-cannot know where these symbols will end up, @code{as} can only allocate
-space for the linker to fill in later. Since @code{as} doesn't know how
-far away these symbols will be, it allocates as much space as it can.)
-If this option is given, the references will only be one word wide (16
-bits). This may be useful if you want the object file to be as small as
-possible, and you know that the relevant symbols will be less than 17
-bits away.
-
-@cindex @code{-m68000} and related options, M680x0
-@cindex architecture options, M680x0
-@cindex M680x0 architecture options
-The 680x0 version of @code{as} is most frequently used to assemble
-programs for the Motorola MC68020 microprocessor. Occasionally it is
-used to assemble programs for the mostly similar, but slightly different
-MC68000 or MC68010 microprocessors. You can give @code{as} the options
-@samp{-m68000}, @samp{-mc68000}, @samp{-m68010}, @samp{-mc68010},
-@samp{-m68020}, and @samp{-mc68020} to tell it what processor is the
-target.
-
-@node M68K-Syntax, M68K-Float, M68K-Opts, M68K-Dependent
-@subsection Syntax
-
-@cindex M680x0 syntax
-@cindex syntax, M680x0
-@cindex M680x0 size modifiers
-@cindex size modifiers, M680x0
-The 680x0 version of @code{as} uses syntax similar to the Sun assembler.
-Size modifiers are appended directly to the end of the opcode without an
-intervening period. For example, write @samp{movl} rather than
-@samp{move.l}.
-
-
-In the following table @dfn{apc} stands for any of the address
-registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the
-Program Counter (@samp{pc}), or the zero-address relative to the
-program counter (@samp{zpc}).
-
-@cindex M680x0 addressing modes
-@cindex addressing modes, M680x0
-The following addressing modes are understood:
-@table @dfn
-@item Immediate
-@samp{#@var{digits}}
-
-@item Data Register
-@samp{d0} through @samp{d7}
-
-@item Address Register
-@samp{a0} through @samp{a7}
-
-@item Address Register Indirect
-@samp{a0@@} through @samp{a7@@}
-
-@item Address Register Postincrement
-@samp{a0@@+} through @samp{a7@@+}
-
-@item Address Register Predecrement
-@samp{a0@@-} through @samp{a7@@-}
-
-@item Indirect Plus Offset
-@samp{@var{apc}@@(@var{digits})}
-
-@item Index
-@samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})}
-
-or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})}
-
-@item Postindex
-@samp{@var{apc}@@(@var{digits})@@(@var{digits},@var{register}:@var{size}:@var{scale})}
-
-or @samp{@var{apc}@@(@var{digits})@@(@var{register}:@var{size}:@var{scale})}
-
-@item Preindex
-@samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})@@(@var{digits})}
-
-or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})@@(@var{digits})}
-
-@item Memory Indirect
-@samp{@var{apc}@@(@var{digits})@@(@var{digits})}
-
-@item Absolute
-@samp{@var{symbol}}, or @samp{@var{digits}}
-@ignore
-@c pesch@cygnus.com: gnu, rich concur the following needs careful
-@c research before documenting.
- , or either of the above followed
-by @samp{:b}, @samp{:w}, or @samp{:l}.
-@end ignore
-@end table
-
-@node M68K-Float, M68K-Directives, M68K-Syntax, M68K-Dependent
-@subsection Floating Point
-
-@cindex floating point, M680x0
-@cindex M680x0 floating point
-@c FIXME is this "not too well tested" crud STILL true?
-The floating point code is not too well tested, and may have
-subtle bugs in it.
-
-Packed decimal (P) format floating literals are not supported.
-Feel free to add the code!
-
-The floating point formats generated by directives are these.
-
-@table @code
-@item .float
-@cindex @code{float} directive, M680x0
-@code{Single} precision floating point constants.
-
-@item .double
-@cindex @code{double} directive, M680x0
-@code{Double} precision floating point constants.
-@end table
-
-There is no directive to produce regions of memory holding
-extended precision numbers, however they can be used as
-immediate operands to floating-point instructions. Adding a
-directive to create extended precision numbers would not be
-hard, but it has not yet seemed necessary.
-
-@node M68K-Directives, M68K-opcodes, M68K-Float, M68K-Dependent
-@subsection 680x0 Machine Directives
-
-@cindex M680x0 directives
-@cindex directives, M680x0
-In order to be compatible with the Sun assembler the 680x0 assembler
-understands the following directives.
-
-@table @code
-@item .data1
-@cindex @code{data1} directive, M680x0
-This directive is identical to a @code{.data 1} directive.
-
-@item .data2
-@cindex @code{data2} directive, M680x0
-This directive is identical to a @code{.data 2} directive.
-
-@item .even
-@cindex @code{even} directive, M680x0
-This directive is identical to a @code{.align 1} directive.
-@c Is this true? does it work???
-
-@item .skip
-@cindex @code{skip} directive, M680x0
-This directive is identical to a @code{.space} directive.
-@end table
-
-@node M68K-opcodes, , M68K-Directives, M68K-Dependent
-@subsection Opcodes
-
-@cindex M680x0 opcodes
-@cindex opcodes, M680x0
-@cindex instruction set, M680x0
-@c pesch@cygnus.com: I don't see any point in the following
-@c paragraph. Bugs are bugs; how does saying this
-@c help anyone?
-@ignore
-Danger: Several bugs have been found in the opcode table (and
-fixed). More bugs may exist. Be careful when using obscure
-instructions.
-@end ignore
-
-@menu
-* M68K-Branch:: Branch Improvement
-* M68K-Chars:: Special Characters
-@end menu
-
-@node M68K-Branch, M68K-Chars, M68K-opcodes, M68K-opcodes
-@subsubsection Branch Improvement
-
-@cindex pseudo-opcodes, M680x0
-@cindex M680x0 pseudo-opcodes
-@cindex branch improvement, M680x0
-@cindex M680x0 branch improvement
-Certain pseudo opcodes are permitted for branch instructions.
-They expand to the shortest branch instruction that will reach the
-target. Generally these mnemonics are made by substituting @samp{j} for
-@samp{b} at the start of a Motorola mnemonic.
-
-The following table summarizes the pseudo-operations. A @code{*} flags
-cases that are more fully described after the table:
-
-@smallexample
- Displacement
- +---------------------------------------------------------
- | 68020 68000/10
-Pseudo-Op |BYTE WORD LONG LONG non-PC relative
- +---------------------------------------------------------
- jbsr |bsrs bsr bsrl jsr jsr
- jra |bras bra bral jmp jmp
-* jXX |bXXs bXX bXXl bNXs;jmpl bNXs;jmp
-* dbXX |dbXX dbXX dbXX; bra; jmpl
-* fjXX |fbXXw fbXXw fbXXl fbNXw;jmp
-
-XX: condition
-NX: negative of condition XX
-
-@end smallexample
-@center @code{*}---see full description below
-
-@table @code
-@item jbsr
-@itemx jra
-These are the simplest jump pseudo-operations; they always map to one
-particular machine instruction, depending on the displacement to the
-branch target.
-
-@item j@var{XX}
-Here, @samp{j@var{XX}} stands for an entire family of pseudo-operations,
-where @var{XX} is a conditional branch or condition-code test. The full
-list of pseudo-ops in this family is:
-@smallexample
- jhi jls jcc jcs jne jeq jvc
- jvs jpl jmi jge jlt jgt jle
-@end smallexample
-
-For the cases of non-PC relative displacements and long displacements on
-the 68000 or 68010, @code{as} will issue a longer code fragment in terms of
-@var{NX}, the opposite condition to @var{XX}:
-@smallexample
- j@var{XX} foo
-@end smallexample
-gives
-@smallexample
- b@var{NX}s oof
- jmp foo
- oof:
-@end smallexample
-
-@item db@var{XX}
-The full family of pseudo-operations covered here is
-@smallexample
- dbhi dbls dbcc dbcs dbne dbeq dbvc
- dbvs dbpl dbmi dbge dblt dbgt dble
- dbf dbra dbt
-@end smallexample
-
-Other than for word and byte displacements, when the source reads
-@samp{db@var{XX} foo}, @code{as} will emit
-@smallexample
- db@var{XX} oo1
- bra oo2
- oo1:jmpl foo
- oo2:
-@end smallexample
-
-@item fj@var{XX}
-This family includes
-@smallexample
- fjne fjeq fjge fjlt fjgt fjle fjf
- fjt fjgl fjgle fjnge fjngl fjngle fjngt
- fjnle fjnlt fjoge fjogl fjogt fjole fjolt
- fjor fjseq fjsf fjsne fjst fjueq fjuge
- fjugt fjule fjult fjun
-@end smallexample
-
-For branch targets that are not PC relative, @code{as} emits
-@smallexample
- fb@var{NX} oof
- jmp foo
- oof:
-@end smallexample
-when it encounters @samp{fj@var{XX} foo}.
-
-@end table
-
-@node M68K-Chars, , M68K-Branch, M68K-opcodes
-@subsubsection Special Characters
-
-@cindex special characters, M680x0
-@cindex M680x0 immediate character
-@cindex immediate character, M680x0
-@cindex M680x0 line comment character
-@cindex line comment character, M680x0
-@cindex comments, M680x0
-The immediate character is @samp{#} for Sun compatibility. The
-line-comment character is @samp{|}. If a @samp{#} appears at the
-beginning of a line, it is treated as a comment unless it looks like
-@samp{# line file}, in which case it is treated normally.
-
-@node Sparc-Dependent, i386-Dependent, M68K-Dependent, Machine Dependent
-@section SPARC Dependent Features
-
-@cindex SPARC support
-@menu
-* Sparc-Opts:: Options
-* Sparc-Float:: Floating Point
-* Sparc-Directives:: Sparc Machine Directives
-@end menu
-
-@node Sparc-Opts, Sparc-Float, Sparc-Dependent, Sparc-Dependent
-@subsection Options
-
-@cindex options for SPARC (none)
-@cindex SPARC options (none)
-The Sparc has no machine dependent options.
-
-@ignore
-@c FIXME: (sparc) Fill in "syntax" section!
-@c subsection syntax
-I don't know anything about Sparc syntax. Someone who does
-will have to write this section.
-@end ignore
-
-@node Sparc-Float, Sparc-Directives, Sparc-Opts, Sparc-Dependent
-@subsection Floating Point
-
-@cindex floating point, SPARC (@sc{ieee})
-@cindex SPARC floating point (@sc{ieee})
-The Sparc uses @sc{ieee} floating-point numbers.
-
-@node Sparc-Directives, , Sparc-Float, Sparc-Dependent
-@subsection Sparc Machine Directives
-
-@cindex SPARC machine directives
-@cindex machine directives, SPARC
-The Sparc version of @code{as} supports the following additional
-machine directives:
-
-@table @code
-@item .common
-@cindex @code{common} directive, SPARC
-This must be followed by a symbol name, a positive number, and
-@code{"bss"}. This behaves somewhat like @code{.comm}, but the
-syntax is different.
-
-@item .half
-@cindex @code{half} directive, SPARC
-This is functionally identical to @code{.short}.
-
-@item .proc
-@cindex @code{proc} directive, SPARC
-This directive is ignored. Any text following it on the same
-line is also ignored.
-
-@item .reserve
-@cindex @code{reserve} directive, SPARC
-This must be followed by a symbol name, a positive number, and
-@code{"bss"}. This behaves somewhat like @code{.lcomm}, but the
-syntax is different.
-
-@item .seg
-@cindex @code{seg} directive, SPARC
-This must be followed by @code{"text"}, @code{"data"}, or
-@code{"data1"}. It behaves like @code{.text}, @code{.data}, or
-@code{.data 1}.
-
-@item .skip
-@cindex @code{skip} directive, SPARC
-This is functionally identical to the @code{.space} directive.
-
-@item .word
-@cindex @code{word} directive, SPARC
-On the Sparc, the .word directive produces 32 bit values,
-instead of the 16 bit values it produces on many other machines.
-@end table
-
-@c FIXME! Conditionalize for all combinations in this section
-@node i386-Dependent, , Sparc-Dependent, Machine Dependent
-@section 80386 Dependent Features
-
-@cindex i386 support
-@cindex i80306 support
-@menu
-* i386-Options:: Options
-* i386-Syntax:: AT&T Syntax versus Intel Syntax
-* i386-Opcodes:: Opcode Naming
-* i386-Regs:: Register Naming
-* i386-prefixes:: Opcode Prefixes
-* i386-Memory:: Memory References
-* i386-jumps:: Handling of Jump Instructions
-* i386-Float:: Floating Point
-* i386-Notes:: Notes
-@end menu
-
-@node i386-Options, i386-Syntax, i386-Dependent, i386-Dependent
-@subsection Options
-
-@cindex options for i386 (none)
-@cindex i386 options (none)
-The 80386 has no machine dependent options.
-
-@node i386-Syntax, i386-Opcodes, i386-Options, i386-Dependent
-@subsection AT&T Syntax versus Intel Syntax
-
-@cindex i386 syntax compatibility
-@cindex syntax compatibility, i386
-In order to maintain compatibility with the output of @code{gcc},
-@code{as} supports AT&T System V/386 assembler syntax. This is quite
-different from Intel syntax. We mention these differences because
-almost all 80386 documents used only Intel syntax. Notable differences
-between the two syntaxes are:
-
-@itemize @bullet
-@item
-@cindex immediate operands, i386
-@cindex i386 immediate operands
-@cindex register operands, i386
-@cindex i386 register operands
-@cindex jump/call operands, i386
-@cindex i386 jump/call operands
-@cindex operand delimiters, i386
-AT&T immediate operands are preceded by @samp{$}; Intel immediate
-operands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}).
-AT&T register operands are preceded by @samp{%}; Intel register operands
-are undelimited. AT&T absolute (as opposed to PC relative) jump/call
-operands are prefixed by @samp{*}; they are undelimited in Intel syntax.
-
-@item
-@cindex i386 source, destination operands
-@cindex source, destination operands; i386
-AT&T and Intel syntax use the opposite order for source and destination
-operands. Intel @samp{add eax, 4} is @samp{addl $4, %eax}. The
-@samp{source, dest} convention is maintained for compatibility with
-previous Unix assemblers.
-
-@item
-@cindex opcode suffixes, i386
-@cindex sizes operands, i386
-@cindex i386 size suffixes
-In AT&T syntax the size of memory operands is determined from the last
-character of the opcode name. Opcode suffixes of @samp{b}, @samp{w},
-and @samp{l} specify byte (8-bit), word (16-bit), and long (32-bit)
-memory references. Intel syntax accomplishes this by prefixes memory
-operands (@emph{not} the opcodes themselves) with @samp{byte ptr},
-@samp{word ptr}, and @samp{dword ptr}. Thus, Intel @samp{mov al, byte
-ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&T syntax.
-
-@item
-@cindex return instructions, i386
-@cindex i386 jump, call, return
-Immediate form long jumps and calls are
-@samp{lcall/ljmp $@var{section}, $@var{offset}} in AT&T syntax; the
-Intel syntax is
-@samp{call/jmp far @var{section}:@var{offset}}. Also, the far return
-instruction
-is @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is
-@samp{ret far @var{stack-adjust}}.
-
-@item
-@cindex sections, i386
-@cindex i386 sections
-The AT&T assembler does not provide support for multiple section
-programs. Unix style systems expect all programs to be single sections.
-@end itemize
-
-@node i386-Opcodes, i386-Regs, i386-Syntax, i386-Dependent
-@subsection Opcode Naming
-
-@cindex i386 opcode naming
-@cindex opcode naming, i386
-Opcode names are suffixed with one character modifiers which specify the
-size of operands. The letters @samp{b}, @samp{w}, and @samp{l} specify
-byte, word, and long operands. If no suffix is specified by an
-instruction and it contains no memory operands then @code{as} tries to
-fill in the missing suffix based on the destination register operand
-(the last one by convention). Thus, @samp{mov %ax, %bx} is equivalent
-to @samp{movw %ax, %bx}; also, @samp{mov $1, %bx} is equivalent to
-@samp{movw $1, %bx}. Note that this is incompatible with the AT&T Unix
-assembler which assumes that a missing opcode suffix implies long
-operand size. (This incompatibility does not affect compiler output
-since compilers always explicitly specify the opcode suffix.)
-
-Almost all opcodes have the same names in AT&T and Intel format. There
-are a few exceptions. The sign extend and zero extend instructions need
-two sizes to specify them. They need a size to sign/zero extend
-@emph{from} and a size to zero extend @emph{to}. This is accomplished
-by using two opcode suffixes in AT&T syntax. Base names for sign extend
-and zero extend are @samp{movs@dots{}} and @samp{movz@dots{}} in AT&T
-syntax (@samp{movsx} and @samp{movzx} in Intel syntax). The opcode
-suffixes are tacked on to this base name, the @emph{from} suffix before
-the @emph{to} suffix. Thus, @samp{movsbl %al, %edx} is AT&T syntax for
-``move sign extend @emph{from} %al @emph{to} %edx.'' Possible suffixes,
-thus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word),
-and @samp{wl} (from word to long).
-
-@cindex conversion instructions, i386
-@cindex i386 conversion instructions
-The Intel-syntax conversion instructions
-
-@itemize @bullet
-@item
-@samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax},
-
-@item
-@samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax},
-
-@item
-@samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax},
-
-@item
-@samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax},
-@end itemize
-
-@noindent
-are called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, and @samp{cltd} in
-AT&T naming. @code{as} accepts either naming for these instructions.
-
-@cindex jump instructions, i386
-@cindex call instructions, i386
-Far call/jump instructions are @samp{lcall} and @samp{ljmp} in
-AT&T syntax, but are @samp{call far} and @samp{jump far} in Intel
-convention.
-
-@node i386-Regs, i386-prefixes, i386-Opcodes, i386-Dependent
-@subsection Register Naming
-
-@cindex i386 registers
-@cindex registers, i386
-Register operands are always prefixes with @samp{%}. The 80386 registers
-consist of
-
-@itemize @bullet
-@item
-the 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx},
-@samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (the
-frame pointer), and @samp{%esp} (the stack pointer).
-
-@item
-the 8 16-bit low-ends of these: @samp{%ax}, @samp{%bx}, @samp{%cx},
-@samp{%dx}, @samp{%di}, @samp{%si}, @samp{%bp}, and @samp{%sp}.
-
-@item
-the 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh},
-@samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (These
-are the high-bytes and low-bytes of @samp{%ax}, @samp{%bx},
-@samp{%cx}, and @samp{%dx})
-
-@item
-the 6 section registers @samp{%cs} (code section), @samp{%ds}
-(data section), @samp{%ss} (stack section), @samp{%es}, @samp{%fs},
-and @samp{%gs}.
-
-@item
-the 3 processor control registers @samp{%cr0}, @samp{%cr2}, and
-@samp{%cr3}.
-
-@item
-the 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2},
-@samp{%db3}, @samp{%db6}, and @samp{%db7}.
-
-@item
-the 2 test registers @samp{%tr6} and @samp{%tr7}.
-
-@item
-the 8 floating point register stack @samp{%st} or equivalently
-@samp{%st(0)}, @samp{%st(1)}, @samp{%st(2)}, @samp{%st(3)},
-@samp{%st(4)}, @samp{%st(5)}, @samp{%st(6)}, and @samp{%st(7)}.
-@end itemize
-
-@node i386-prefixes, i386-Memory, i386-Regs, i386-Dependent
-@subsection Opcode Prefixes
-
-@cindex i386 opcode prefixes
-@cindex opcode prefixes, i386
-@cindex prefixes, i386
-Opcode prefixes are used to modify the following opcode. They are used
-to repeat string instructions, to provide section overrides, to perform
-bus lock operations, and to give operand and address size (16-bit
-operands are specified in an instruction by prefixing what would
-normally be 32-bit operands with a ``operand size'' opcode prefix).
-Opcode prefixes are usually given as single-line instructions with no
-operands, and must directly precede the instruction they act upon. For
-example, the @samp{scas} (scan string) instruction is repeated with:
-@smallexample
- repne
- scas
-@end smallexample
-
-Here is a list of opcode prefixes:
-
-@itemize @bullet
-@item
-@cindex section override prefixes, i386
-Section override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es},
-@samp{fs}, @samp{gs}. These are automatically added by specifying
-using the @var{section}:@var{memory-operand} form for memory references.
-
-@item
-@cindex size prefixes, i386
-Operand/Address size prefixes @samp{data16} and @samp{addr16}
-change 32-bit operands/addresses into 16-bit operands/addresses. Note
-that 16-bit addressing modes (i.e. 8086 and 80286 addressing modes)
-are not supported (yet).
-
-@item
-@cindex bus lock prefixes, i386
-@cindex inhibiting interrupts, i386
-The bus lock prefix @samp{lock} inhibits interrupts during
-execution of the instruction it precedes. (This is only valid with
-certain instructions; see a 80386 manual for details).
-
-@item
-@cindex coprocessor wait, i386
-The wait for coprocessor prefix @samp{wait} waits for the
-coprocessor to complete the current instruction. This should never be
-needed for the 80386/80387 combination.
-
-@item
-@cindex repeat prefixes, i386
-The @samp{rep}, @samp{repe}, and @samp{repne} prefixes are added
-to string instructions to make them repeat @samp{%ecx} times.
-@end itemize
-
-@node i386-Memory, i386-jumps, i386-prefixes, i386-Dependent
-@subsection Memory References
-
-@cindex i386 memory references
-@cindex memory references, i386
-An Intel syntax indirect memory reference of the form
-
-@smallexample
-@var{section}:[@var{base} + @var{index}*@var{scale} + @var{disp}]
-@end smallexample
-
-@noindent
-is translated into the AT&T syntax
-
-@smallexample
-@var{section}:@var{disp}(@var{base}, @var{index}, @var{scale})
-@end smallexample
-
-@noindent
-where @var{base} and @var{index} are the optional 32-bit base and
-index registers, @var{disp} is the optional displacement, and
-@var{scale}, taking the values 1, 2, 4, and 8, multiplies @var{index}
-to calculate the address of the operand. If no @var{scale} is
-specified, @var{scale} is taken to be 1. @var{section} specifies the
-optional section register for the memory operand, and may override the
-default section register (see a 80386 manual for section register
-defaults). Note that section overrides in AT&T syntax @emph{must} have
-be preceded by a @samp{%}. If you specify a section override which
-coincides with the default section register, @code{as} will @emph{not}
-output any section register override prefixes to assemble the given
-instruction. Thus, section overrides can be specified to emphasize which
-section register is used for a given memory operand.
-
-Here are some examples of Intel and AT&T style memory references:
-
-@table @asis
-@item AT&T: @samp{-4(%ebp)}, Intel: @samp{[ebp - 4]}
-@var{base} is @samp{%ebp}; @var{disp} is @samp{-4}. @var{section} is
-missing, and the default section is used (@samp{%ss} for addressing with
-@samp{%ebp} as the base register). @var{index}, @var{scale} are both missing.
-
-@item AT&T: @samp{foo(,%eax,4)}, Intel: @samp{[foo + eax*4]}
-@var{index} is @samp{%eax} (scaled by a @var{scale} 4); @var{disp} is
-@samp{foo}. All other fields are missing. The section register here
-defaults to @samp{%ds}.
-
-@item AT&T: @samp{foo(,1)}; Intel @samp{[foo]}
-This uses the value pointed to by @samp{foo} as a memory operand.
-Note that @var{base} and @var{index} are both missing, but there is only
-@emph{one} @samp{,}. This is a syntactic exception.
-
-@item AT&T: @samp{%gs:foo}; Intel @samp{gs:foo}
-This selects the contents of the variable @samp{foo} with section
-register @var{section} being @samp{%gs}.
-@end table
-
-Absolute (as opposed to PC relative) call and jump operands must be
-prefixed with @samp{*}. If no @samp{*} is specified, @code{as} will
-always choose PC relative addressing for jump/call labels.
-
-Any instruction that has a memory operand @emph{must} specify its size (byte,
-word, or long) with an opcode suffix (@samp{b}, @samp{w}, or @samp{l},
-respectively).
-
-@node i386-jumps, i386-Float, i386-Memory, i386-Dependent
-@subsection Handling of Jump Instructions
-
-@cindex jump optimization, i386
-@cindex i386 jump optimization
-Jump instructions are always optimized to use the smallest possible
-displacements. This is accomplished by using byte (8-bit) displacement
-jumps whenever the target is sufficiently close. If a byte displacement
-is insufficient a long (32-bit) displacement is used. We do not support
-word (16-bit) displacement jumps (i.e. prefixing the jump instruction
-with the @samp{addr16} opcode prefix), since the 80386 insists upon masking
-@samp{%eip} to 16 bits after the word displacement is added.
-
-Note that the @samp{jcxz}, @samp{jecxz}, @samp{loop}, @samp{loopz},
-@samp{loope}, @samp{loopnz} and @samp{loopne} instructions only come in
-byte displacements, so that it is possible that use of these
-instructions (@code{gcc} does not use them) will cause the assembler to
-print an error message (and generate incorrect code). The AT&T 80386
-assembler tries to get around this problem by expanding @samp{jcxz foo} to
-@smallexample
- jcxz cx_zero
- jmp cx_nonzero
-cx_zero: jmp foo
-cx_nonzero:
-@end smallexample
-
-@node i386-Float, i386-Notes, i386-jumps, i386-Dependent
-@subsection Floating Point
-
-@cindex i386 floating point
-@cindex floating point, i386
-All 80387 floating point types except packed BCD are supported.
-(BCD support may be added without much difficulty). These data
-types are 16-, 32-, and 64- bit integers, and single (32-bit),
-double (64-bit), and extended (80-bit) precision floating point.
-Each supported type has an opcode suffix and a constructor
-associated with it. Opcode suffixes specify operand's data
-types. Constructors build these data types into memory.
-
-@itemize @bullet
-@item
-@cindex @code{float} directive, i386
-@cindex @code{single} directive, i386
-@cindex @code{double} directive, i386
-@cindex @code{tfloat} directive, i386
-Floating point constructors are @samp{.float} or @samp{.single},
-@samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats.
-These correspond to opcode suffixes @samp{s}, @samp{l}, and @samp{t}.
-@samp{t} stands for temporary real, and that the 80387 only supports
-this format via the @samp{fldt} (load temporary real to stack top) and
-@samp{fstpt} (store temporary real and pop stack) instructions.
-
-@item
-@cindex @code{word} directive, i386
-@cindex @code{long} directive, i386
-@cindex @code{int} directive, i386
-@cindex @code{quad} directive, i386
-Integer constructors are @samp{.word}, @samp{.long} or @samp{.int}, and
-@samp{.quad} for the 16-, 32-, and 64-bit integer formats. The corresponding
-opcode suffixes are @samp{s} (single), @samp{l} (long), and @samp{q}
-(quad). As with the temporary real format the 64-bit @samp{q} format is
-only present in the @samp{fildq} (load quad integer to stack top) and
-@samp{fistpq} (store quad integer and pop stack) instructions.
-@end itemize
-
-Register to register operations do not require opcode suffixes,
-so that @samp{fst %st, %st(1)} is equivalent to @samp{fstl %st, %st(1)}.
-
-@cindex i386 @code{fwait} instruction
-@cindex @code{fwait instruction}, i386
-Since the 80387 automatically synchronizes with the 80386 @samp{fwait}
-instructions are almost never needed (this is not the case for the
-80286/80287 and 8086/8087 combinations). Therefore, @code{as} suppresses
-the @samp{fwait} instruction whenever it is implicitly selected by one
-of the @samp{fn@dots{}} instructions. For example, @samp{fsave} and
-@samp{fnsave} are treated identically. In general, all the @samp{fn@dots{}}
-instructions are made equivalent to @samp{f@dots{}} instructions. If
-@samp{fwait} is desired it must be explicitly coded.
-
-@node i386-Notes, , i386-Float, i386-Dependent
-@subsection Notes
-
-@cindex i386 @code{mul}, @code{imul} instructions
-@cindex @code{mul} instruction, i386
-@cindex @code{imul} instruction, i386
-There is some trickery concerning the @samp{mul} and @samp{imul}
-instructions that deserves mention. The 16-, 32-, and 64-bit expanding
-multiplies (base opcode @samp{0xf6}; extension 4 for @samp{mul} and 5
-for @samp{imul}) can be output only in the one operand form. Thus,
-@samp{imul %ebx, %eax} does @emph{not} select the expanding multiply;
-the expanding multiply would clobber the @samp{%edx} register, and this
-would confuse @code{gcc} output. Use @samp{imul %ebx} to get the
-64-bit product in @samp{%edx:%eax}.
-
-We have added a two operand form of @samp{imul} when the first operand
-is an immediate mode expression and the second operand is a register.
-This is just a shorthand, so that, multiplying @samp{%eax} by 69, for
-example, can be done with @samp{imul $69, %eax} rather than @samp{imul
-$69, %eax, %eax}.
-
-
-@node Copying, Index, Machine Dependent, Top
-@unnumbered GNU GENERAL PUBLIC LICENSE
-
-@cindex license
-@cindex GPL
-@cindex copying @code{as}
-@center Version 2, June 1991
-
-@display
-Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
-675 Mass Ave, Cambridge, MA 02139, USA
-
-Everyone is permitted to copy and distribute verbatim copies
-of this license document, but changing it is not allowed.
-@end display
-
-@unnumberedsec Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software---to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
-@iftex
-@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-@end iftex
-@ifinfo
-@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-@end ifinfo
-
-@enumerate
-@item
-This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The ``Program'', below,
-refers to any such program or work, and a ``work based on the Program''
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term ``modification''.) Each licensee is addressed as ``you''.
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-@item
-You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-@item
-You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-@enumerate a
-@item
-You must cause the modified files to carry prominent notices
-stating that you changed the files and the date of any change.
-
-@item
-You must cause any work that you distribute or publish, that in
-whole or in part contains or is derived from the Program or any
-part thereof, to be licensed as a whole at no charge to all third
-parties under the terms of this License.
-
-@item
-If the modified program normally reads commands interactively
-when run, you must cause it, when started running for such
-interactive use in the most ordinary way, to print or display an
-announcement including an appropriate copyright notice and a
-notice that there is no warranty (or else, saying that you provide
-a warranty) and that users may redistribute the program under
-these conditions, and telling the user how to view a copy of this
-License. (Exception: if the Program itself is interactive but
-does not normally print such an announcement, your work based on
-the Program is not required to print an announcement.)
-@end enumerate
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-@item
-You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-@enumerate a
-@item
-Accompany it with the complete corresponding machine-readable
-source code, which must be distributed under the terms of Sections
-1 and 2 above on a medium customarily used for software interchange; or,
-
-@item
-Accompany it with a written offer, valid for at least three
-years, to give any third party, for a charge no more than your
-cost of physically performing source distribution, a complete
-machine-readable copy of the corresponding source code, to be
-distributed under the terms of Sections 1 and 2 above on a medium
-customarily used for software interchange; or,
-
-@item
-Accompany it with the information you received as to the offer
-to distribute corresponding source code. (This alternative is
-allowed only for noncommercial distribution and only if you
-received the program in object code or executable form with such
-an offer, in accord with Subsection b above.)
-@end enumerate
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-@item
-You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-@item
-You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-@item
-Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-@item
-If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-@item
-If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-@item
-The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and ``any
-later version'', you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-@item
-If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-@iftex
-@heading NO WARRANTY
-@end iftex
-@ifinfo
-@center NO WARRANTY
-@end ifinfo
-
-@item
-BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-@item
-IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-@end enumerate
-
-@iftex
-@heading END OF TERMS AND CONDITIONS
-@end iftex
-@ifinfo
-@center END OF TERMS AND CONDITIONS
-@end ifinfo
-
-@page
-@unnumberedsec Applying These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the ``copyright'' line and a pointer to where the full notice is found.
-
-@smallexample
-@var{one line to give the program's name and an idea of what it does.}
-Copyright (C) 19@var{yy} @var{name of author}
-
-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
-of the License, 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.
-@end smallexample
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-@smallexample
-Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
-Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
-type `show w'. This is free software, and you are welcome
-to redistribute it under certain conditions; type `show c'
-for details.
-@end smallexample
-
-The hypothetical commands @samp{show w} and @samp{show c} should show
-the appropriate parts of the General Public License. Of course, the
-commands you use may be called something other than @samp{show w} and
-@samp{show c}; they could even be mouse-clicks or menu items---whatever
-suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a ``copyright disclaimer'' for the program, if
-necessary. Here is a sample; alter the names:
-
-@smallexample
-Yoyodyne, Inc., hereby disclaims all copyright interest in
-the program `Gnomovision' (which makes passes at compilers)
-written by James Hacker.
-
-@var{signature of Ty Coon}, 1 April 1989
-Ty Coon, President of Vice
-@end smallexample
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
-
-@node Index, , Copying, Top
-@unnumbered Index
-
-@printindex cp
-
-@summarycontents
-@contents
-@bye
diff --git a/gnu/usr.bin/as/expr.c b/gnu/usr.bin/as/expr.c
deleted file mode 100644
index 7c168ff..0000000
--- a/gnu/usr.bin/as/expr.c
+++ /dev/null
@@ -1,1000 +0,0 @@
-/* expr.c -operands, expressions-
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * This is really a branch office of as-read.c. I split it out to clearly
- * distinguish the world of expressions from the world of statements.
- * (It also gives smaller files to re-compile.)
- * Here, "operand"s are of expressions, not instructions.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <string.h>
-
-#include "as.h"
-
-#include "obstack.h"
-
-#if __STDC__ == 1
-static void clean_up_expression(expressionS *expressionP);
-#else /* __STDC__ */
-static void clean_up_expression(); /* Internal. */
-#endif /* not __STDC__ */
-extern const char EXP_CHARS[]; /* JF hide MD floating pt stuff all the same place */
-extern const char FLT_CHARS[];
-
-#ifdef LOCAL_LABELS_DOLLAR
-extern int local_label_defined[];
-#endif
-
-/*
- * Build any floating-point literal here.
- * Also build any bignum literal here.
- */
-
-/* LITTLENUM_TYPE generic_buffer[6]; */ /* JF this is a hack */
-/* Seems atof_machine can backscan through generic_bignum and hit whatever
- happens to be loaded before it in memory. And its way too complicated
- for me to fix right. Thus a hack. JF: Just make generic_bignum bigger,
- and never write into the early words, thus they'll always be zero.
- I hate Dean's floating-point code. Bleh.
- */
-LITTLENUM_TYPE generic_bignum[SIZE_OF_LARGE_NUMBER+6];
-FLONUM_TYPE generic_floating_point_number =
-{
- &generic_bignum[6], /* low (JF: Was 0) */
- &generic_bignum[SIZE_OF_LARGE_NUMBER+6 - 1], /* high JF: (added +6) */
- 0, /* leader */
- 0, /* exponent */
- 0 /* sign */
- };
-/* If nonzero, we've been asked to assemble nan, +inf or -inf */
-int generic_floating_point_magic;
-
-/*
- * Summary of operand().
- *
- * in: Input_line_pointer points to 1st char of operand, which may
- * be a space.
- *
- * out: A expressionS. X_seg determines how to understand the rest of the
- * expressionS.
- * The operand may have been empty: in this case X_seg == SEG_ABSENT.
- * Input_line_pointer->(next non-blank) char after operand.
- *
- */
-
-static segT
- operand (expressionP)
-register expressionS * expressionP;
-{
- register char c;
- register char *name; /* points to name of symbol */
- register symbolS * symbolP; /* Points to symbol */
-
- extern const char hex_value[]; /* In hex_value.c */
-
-#ifdef PIC
-/* XXX */ expressionP->X_got_symbol = 0;
-#endif
- SKIP_WHITESPACE(); /* Leading whitespace is part of operand. */
- c = * input_line_pointer ++; /* Input_line_pointer->past char in c. */
- if (isdigit(c) || (c == 'H' && input_line_pointer[0] == '\''))
- {
- register valueT number; /* offset or (absolute) value */
- register short int digit; /* value of next digit in current radix */
- /* invented for humans only, hope */
- /* optimising compiler flushes it! */
- register short int radix; /* 2, 8, 10 or 16 */
- /* 0 means we saw start of a floating- */
- /* point constant. */
- register short int maxdig = 0;/* Highest permitted digit value. */
- register int too_many_digits = 0; /* If we see >= this number of */
- /* digits, assume it is a bignum. */
- register char * digit_2; /*->2nd digit of number. */
- int small; /* TRUE if fits in 32 bits. */
-
-
- if (c == 'H' || c == '0') { /* non-decimal radix */
- if ((c = *input_line_pointer ++) == 'x' || c == 'X' || c == '\'') {
- c = *input_line_pointer ++; /* read past "0x" or "0X" or H' */
- maxdig = radix = 16;
- too_many_digits = 9;
- } else {
- /* If it says '0f' and the line ends or it DOESN'T look like
- a floating point #, its a local label ref. DTRT */
- /* likewise for the b's. xoxorich. */
- if ((c == 'f' || c == 'b' || c == 'B')
- && (!*input_line_pointer ||
- (!strchr("+-.0123456789iInN",*input_line_pointer) &&
- !strchr(EXP_CHARS,*input_line_pointer)))) {
- maxdig = radix = 10;
- too_many_digits = 11;
- c = '0';
- input_line_pointer -= 2;
-
- } else if (c == 'b' || c == 'B') {
- c = *input_line_pointer++;
- maxdig = radix = 2;
- too_many_digits = 33;
-
- } else if (c && strchr(FLT_CHARS,c)) {
- radix = 0; /* Start of floating-point constant. */
- /* input_line_pointer->1st char of number. */
- expressionP->X_add_number = -(isupper(c) ? tolower(c) : c);
-
- } else { /* By elimination, assume octal radix. */
- radix = maxdig = 8;
- too_many_digits = 11;
- }
- } /* c == char after "0" or "0x" or "0X" or "0e" etc. */
- } else {
- maxdig = radix = 10;
- too_many_digits = 11;
- } /* if operand starts with a zero */
-
- if (radix) { /* Fixed-point integer constant. */
- /* May be bignum, or may fit in 32 bits. */
- /*
- * Most numbers fit into 32 bits, and we want this case to be fast.
- * So we pretend it will fit into 32 bits. If, after making up a 32
- * bit number, we realise that we have scanned more digits than
- * comfortably fit into 32 bits, we re-scan the digits coding
- * them into a bignum. For decimal and octal numbers we are conservative: some
- * numbers may be assumed bignums when in fact they do fit into 32 bits.
- * Numbers of any radix can have excess leading zeros: we strive
- * to recognise this and cast them back into 32 bits.
- * We must check that the bignum really is more than 32
- * bits, and change it back to a 32-bit number if it fits.
- * The number we are looking for is expected to be positive, but
- * if it fits into 32 bits as an unsigned number, we let it be a 32-bit
- * number. The cavalier approach is for speed in ordinary cases.
- */
- digit_2 = input_line_pointer;
- for (number=0; (digit=hex_value[c])<maxdig; c = * input_line_pointer ++)
- {
- number = number * radix + digit;
- }
- /* C contains character after number. */
- /* Input_line_pointer->char after C. */
- small = input_line_pointer - digit_2 < too_many_digits;
- if (!small)
- {
- /*
- * We saw a lot of digits. Manufacture a bignum the hard way.
- */
- LITTLENUM_TYPE *leader; /*->high order littlenum of the bignum. */
- LITTLENUM_TYPE *pointer; /*->littlenum we are frobbing now. */
- long carry;
-
- leader = generic_bignum;
- generic_bignum[0] = 0;
- generic_bignum[1] = 0;
- /* We could just use digit_2, but lets be mnemonic. */
- input_line_pointer = --digit_2; /*->1st digit. */
- c = *input_line_pointer++;
- for (; (carry = hex_value[c]) < maxdig; c = *input_line_pointer++)
- {
- for (pointer = generic_bignum;
- pointer <= leader;
- pointer++)
- {
- long work;
-
- work = carry + radix * *pointer;
- *pointer = work & LITTLENUM_MASK;
- carry = work >> LITTLENUM_NUMBER_OF_BITS;
- }
- if (carry)
- {
- if (leader < generic_bignum + SIZE_OF_LARGE_NUMBER - 1)
- { /* Room to grow a longer bignum. */
- *++leader = carry;
- }
- }
- }
- /* Again, C is char after number, */
- /* input_line_pointer->after C. */
- know(sizeof (int) * 8 == 32);
- know(LITTLENUM_NUMBER_OF_BITS == 16);
- /* Hence the constant "2" in the next line. */
- if (leader < generic_bignum + 2)
- { /* Will fit into 32 bits. */
- number =
- ((generic_bignum[1] & LITTLENUM_MASK) << LITTLENUM_NUMBER_OF_BITS)
- | (generic_bignum[0] & LITTLENUM_MASK);
- small = 1;
- }
- else
- {
- number = leader - generic_bignum + 1; /* Number of littlenums in the bignum. */
- }
- }
- if (small)
- {
- /*
- * Here with number, in correct radix. c is the next char.
- * Note that unlike Un*x, we allow "011f" "0x9f" to
- * both mean the same as the (conventional) "9f". This is simply easier
- * than checking for strict canonical form. Syntax sux!
- */
- if (number<10)
- {
- if (0
-#ifdef LOCAL_LABELS_FB
- || c == 'b'
-#endif
-#ifdef LOCAL_LABELS_DOLLAR
- || (c == '$' && local_label_defined[number])
-#endif
- )
- {
- /*
- * Backward ref to local label.
- * Because it is backward, expect it to be DEFINED.
- */
- /*
- * Construct a local label.
- */
- name = local_label_name ((int)number, 0);
- if (((symbolP = symbol_find(name)) != NULL) /* seen before */
- && (S_IS_DEFINED(symbolP))) /* symbol is defined: OK */
- { /* Expected path: symbol defined. */
- /* Local labels are never absolute. Don't waste time checking absoluteness. */
- know(SEG_NORMAL(S_GET_SEGMENT(symbolP)));
-
- expressionP->X_add_symbol = symbolP;
- expressionP->X_add_number = 0;
- expressionP->X_seg = S_GET_SEGMENT(symbolP);
- }
- else
- { /* Either not seen or not defined. */
- as_bad("Backw. ref to unknown label \"%d:\", 0 assumed.",
- number);
- expressionP->X_add_number = 0;
- expressionP->X_seg = SEG_ABSOLUTE;
- }
- }
- else
- {
- if (0
-#ifdef LOCAL_LABELS_FB
- || c == 'f'
-#endif
-#ifdef LOCAL_LABELS_DOLLAR
- || (c == '$' && !local_label_defined[number])
-#endif
- )
- {
- /*
- * Forward reference. Expect symbol to be undefined or
- * unknown. Undefined: seen it before. Unknown: never seen
- * it in this pass.
- * Construct a local label name, then an undefined symbol.
- * Don't create a XSEG frag for it: caller may do that.
- * Just return it as never seen before.
- */
- name = local_label_name((int)number, 1);
- symbolP = symbol_find_or_make(name);
- /* We have no need to check symbol properties. */
-#ifndef MANY_SEGMENTS
- /* Since "know" puts its arg into a "string", we
- can't have newlines in the argument. */
- know(S_GET_SEGMENT(symbolP) == SEG_UNKNOWN || S_GET_SEGMENT(symbolP) == SEG_TEXT || S_GET_SEGMENT(symbolP) == SEG_DATA);
-#endif
- expressionP->X_add_symbol = symbolP;
- expressionP->X_seg = SEG_UNKNOWN;
- expressionP->X_subtract_symbol = NULL;
- expressionP->X_add_number = 0;
- }
- else
- { /* Really a number, not a local label. */
- expressionP->X_add_number = number;
- expressionP->X_seg = SEG_ABSOLUTE;
- input_line_pointer--; /* Restore following character. */
- } /* if (c == 'f') */
- } /* if (c == 'b') */
- }
- else
- { /* Really a number. */
- expressionP->X_add_number = number;
- expressionP->X_seg = SEG_ABSOLUTE;
- input_line_pointer--; /* Restore following character. */
- } /* if (number<10) */
- }
- else
- {
- expressionP->X_add_number = number;
- expressionP->X_seg = SEG_BIG;
- input_line_pointer --; /*->char following number. */
- } /* if (small) */
- } /* (If integer constant) */
- else
- { /* input_line_pointer->*/
- /* floating-point constant. */
- int error_code;
-
- error_code = atof_generic
- (& input_line_pointer, ".", EXP_CHARS,
- & generic_floating_point_number);
-
- if (error_code)
- {
- if (error_code == ERROR_EXPONENT_OVERFLOW)
- {
- as_bad("Bad floating-point constant: exponent overflow, probably assembling junk");
- }
- else
- {
- as_bad("Bad floating-point constant: unknown error code=%d.", error_code);
- }
- }
- expressionP->X_seg = SEG_BIG;
- /* input_line_pointer->just after constant, */
- /* which may point to whitespace. */
- know(expressionP->X_add_number < 0); /* < 0 means "floating point". */
- } /* if (not floating-point constant) */
- }
- else if (c == '.' && !is_part_of_name(*input_line_pointer)) {
- extern struct obstack frags;
-
- /*
- JF: '.' is pseudo symbol with value of current location in current
- segment...
- */
- symbolP = symbol_new("\001L0",
- now_seg,
- (valueT)(obstack_next_free(&frags)-frag_now->fr_literal),
- frag_now);
-
- expressionP->X_add_number=0;
- expressionP->X_add_symbol=symbolP;
- expressionP->X_seg = now_seg;
-
- } else if (is_name_beginner(c)) { /* here if did not begin with a digit */
-
- /*
- * Identifier begins here.
- * This is kludged for speed, so code is repeated.
- */
- name = input_line_pointer - 1;
- c = get_symbol_end();
- symbolP = symbol_find_or_make(name);
- /*
- * If we have an absolute symbol or a reg, then we know its value now.
- */
- expressionP->X_seg = S_GET_SEGMENT(symbolP);
- switch (expressionP->X_seg)
- {
- case SEG_ABSOLUTE:
- case SEG_REGISTER:
- expressionP->X_add_number = S_GET_VALUE(symbolP);
- break;
-
- default:
- expressionP->X_add_number = 0;
-#ifdef PIC
- if (symbolP == GOT_symbol) {
- expressionP->X_got_symbol = symbolP;
- got_referenced = 1;
- } else
-#endif
- expressionP->X_add_symbol = symbolP;
- }
- *input_line_pointer = c;
- expressionP->X_subtract_symbol = NULL;
- } else if (c == '(' || c == '[') {/* didn't begin with digit & not a name */
- (void)expression(expressionP);
- /* Expression() will pass trailing whitespace */
- if (c == '(' && *input_line_pointer++ != ')' ||
- c == '[' && *input_line_pointer++ != ']') {
- as_bad("Missing ')' assumed");
- input_line_pointer--;
- }
- /* here with input_line_pointer->char after "(...)" */
- } else if (c == '~' || c == '-' || c == '+') {
- /* unary operator: hope for SEG_ABSOLUTE */
- switch (operand (expressionP)) {
- case SEG_ABSOLUTE:
- /* input_line_pointer->char after operand */
- if (c == '-') {
- expressionP->X_add_number = - expressionP->X_add_number;
- /*
- * Notice: '-' may overflow: no warning is given. This is compatible
- * with other people's assemblers. Sigh.
- */
- } else if (c == '~') {
- expressionP->X_add_number = ~ expressionP->X_add_number;
- } else if (c != '+') {
- know(0);
- } /* switch on unary operator */
- break;
-
- default: /* unary on non-absolute is unsuported */
- if (!SEG_NORMAL(operand(expressionP)))
- {
- as_bad("Unary operator %c ignored because bad operand follows", c);
- break;
- }
- /* Fall through for normal segments ****/
- case SEG_PASS1:
- case SEG_UNKNOWN:
- if (c == '-') { /* JF I hope this hack works */
- expressionP->X_subtract_symbol=expressionP->X_add_symbol;
- expressionP->X_add_symbol=0;
- expressionP->X_seg=SEG_DIFFERENCE;
- break;
- }
- /* Expression undisturbed from operand(). */
- }
- }
- else if (c == '\'')
- {
- /*
- * Warning: to conform to other people's assemblers NO ESCAPEMENT is permitted
- * for a single quote. The next character, parity errors and all, is taken
- * as the value of the operand. VERY KINKY.
- */
- expressionP->X_add_number = * input_line_pointer ++;
- expressionP->X_seg = SEG_ABSOLUTE;
- }
- else
- {
- /* can't imagine any other kind of operand */
- expressionP->X_seg = SEG_ABSENT;
- input_line_pointer --;
- md_operand (expressionP);
- }
- /*
- * It is more 'efficient' to clean up the expressions when they are created.
- * Doing it here saves lines of code.
- */
- clean_up_expression(expressionP);
- SKIP_WHITESPACE(); /*->1st char after operand. */
- know(*input_line_pointer != ' ');
- return(expressionP->X_seg);
-} /* operand() */
-
-/* Internal. Simplify a struct expression for use by expr() */
-
-/*
- * In: address of a expressionS.
- * The X_seg field of the expressionS may only take certain values.
- * Now, we permit SEG_PASS1 to make code smaller & faster.
- * Elsewise we waste time special-case testing. Sigh. Ditto SEG_ABSENT.
- * Out: expressionS may have been modified:
- * 'foo-foo' symbol references cancelled to 0,
- * which changes X_seg from SEG_DIFFERENCE to SEG_ABSOLUTE;
- * Unused fields zeroed to help expr().
- */
-
-static void
- clean_up_expression (expressionP)
-register expressionS *expressionP;
-{
- switch (expressionP->X_seg) {
- case SEG_ABSENT:
- case SEG_PASS1:
- expressionP->X_add_symbol = NULL;
- expressionP->X_subtract_symbol = NULL;
- expressionP->X_add_number = 0;
- break;
-
- case SEG_BIG:
- case SEG_ABSOLUTE:
- expressionP->X_subtract_symbol = NULL;
- expressionP->X_add_symbol = NULL;
- break;
-
- case SEG_UNKNOWN:
- expressionP->X_subtract_symbol = NULL;
- break;
-
- case SEG_DIFFERENCE:
- /*
- * It does not hurt to 'cancel' NULL == NULL
- * when comparing symbols for 'eq'ness.
- * It is faster to re-cancel them to NULL
- * than to check for this special case.
- */
- if (expressionP->X_subtract_symbol == expressionP->X_add_symbol
- || (expressionP->X_subtract_symbol
- && expressionP->X_add_symbol
- && expressionP->X_subtract_symbol->sy_frag == expressionP->X_add_symbol->sy_frag
- && S_GET_VALUE(expressionP->X_subtract_symbol) == S_GET_VALUE(expressionP->X_add_symbol))) {
- expressionP->X_subtract_symbol = NULL;
- expressionP->X_add_symbol = NULL;
- expressionP->X_seg = SEG_ABSOLUTE;
- }
- break;
-
- case SEG_REGISTER:
- expressionP->X_add_symbol = NULL;
- expressionP->X_subtract_symbol = NULL;
- break;
-
- default:
- if (SEG_NORMAL(expressionP->X_seg)) {
- expressionP->X_subtract_symbol = NULL;
- }
- else {
- BAD_CASE (expressionP->X_seg);
- }
- break;
- }
-} /* clean_up_expression() */
-
-/*
- * expr_part ()
- *
- * Internal. Made a function because this code is used in 2 places.
- * Generate error or correct X_?????_symbol of expressionS.
- */
-
-/*
- * symbol_1 += symbol_2 ... well ... sort of.
- */
-
-static segT
- expr_part (symbol_1_PP, symbol_2_P)
-symbolS ** symbol_1_PP;
-symbolS * symbol_2_P;
-{
- segT return_value;
-#ifndef MANY_SEGMENTS
- know((* symbol_1_PP) == NULL || (S_GET_SEGMENT(*symbol_1_PP) == SEG_TEXT) || (S_GET_SEGMENT(*symbol_1_PP) == SEG_DATA) || (S_GET_SEGMENT(*symbol_1_PP) == SEG_BSS) || (!S_IS_DEFINED(* symbol_1_PP)));
- know(symbol_2_P == NULL || (S_GET_SEGMENT(symbol_2_P) == SEG_TEXT) || (S_GET_SEGMENT(symbol_2_P) == SEG_DATA) || (S_GET_SEGMENT(symbol_2_P) == SEG_BSS) || (!S_IS_DEFINED(symbol_2_P)));
-#endif
- if (* symbol_1_PP)
- {
- if (!S_IS_DEFINED(* symbol_1_PP))
- {
- if (symbol_2_P)
- {
- return_value = SEG_PASS1;
- * symbol_1_PP = NULL;
- }
- else
- {
- know(!S_IS_DEFINED(* symbol_1_PP));
- return_value = SEG_UNKNOWN;
- }
- }
- else
- {
- if (symbol_2_P)
- {
- if (!S_IS_DEFINED(symbol_2_P))
- {
- * symbol_1_PP = NULL;
- return_value = SEG_PASS1;
- }
- else
- {
- /* {seg1} - {seg2} */
- as_bad("Expression too complex, 2 symbols forgotten: \"%s\" \"%s\"",
- S_GET_NAME(* symbol_1_PP), S_GET_NAME(symbol_2_P));
- * symbol_1_PP = NULL;
- return_value = SEG_ABSOLUTE;
- }
- }
- else
- {
- return_value = S_GET_SEGMENT(* symbol_1_PP);
- }
- }
- }
- else
- { /* (* symbol_1_PP) == NULL */
- if (symbol_2_P)
- {
- * symbol_1_PP = symbol_2_P;
- return_value = S_GET_SEGMENT(symbol_2_P);
- }
- else
- {
- * symbol_1_PP = NULL;
- return_value = SEG_ABSOLUTE;
- }
- }
-#ifndef MANY_SEGMENTS
- know(return_value == SEG_ABSOLUTE || return_value == SEG_TEXT || return_value == SEG_DATA || return_value == SEG_BSS || return_value == SEG_UNKNOWN || return_value == SEG_PASS1);
-#endif
- know((*symbol_1_PP) == NULL || (S_GET_SEGMENT(*symbol_1_PP) == return_value));
- return (return_value);
-} /* expr_part() */
-
-void ps (s)
-symbolS *s;
-{
- fprintf (stdout, "%s type %s%s",
- S_GET_NAME(s),
- S_IS_EXTERNAL(s) ? "EXTERNAL " : "",
- segment_name(S_GET_SEGMENT(s)));
-}
-void pe (e)
-expressionS *e;
-{
- fprintf (stdout, " segment %s\n", segment_name (e->X_seg));
- fprintf (stdout, " add_number %d (%x)\n",
- e->X_add_number, e->X_add_number);
- if (e->X_add_symbol) {
- fprintf (stdout, " add_symbol ");
- ps (e->X_add_symbol);
- fprintf (stdout, "\n");
- }
- if (e->X_subtract_symbol) {
- fprintf (stdout, " sub_symbol ");
- ps (e->X_subtract_symbol);
- fprintf (stdout, "\n");
- }
-}
-
-/* Expression parser. */
-
-/*
- * We allow an empty expression, and just assume (absolute,0) silently.
- * Unary operators and parenthetical expressions are treated as operands.
- * As usual, Q == quantity == operand, O == operator, X == expression mnemonics.
- *
- * We used to do a aho/ullman shift-reduce parser, but the logic got so
- * warped that I flushed it and wrote a recursive-descent parser instead.
- * Now things are stable, would anybody like to write a fast parser?
- * Most expressions are either register (which does not even reach here)
- * or 1 symbol. Then "symbol+constant" and "symbol-symbol" are common.
- * So I guess it doesn't really matter how inefficient more complex expressions
- * are parsed.
- *
- * After expr(RANK,resultP) input_line_pointer->operator of rank <= RANK.
- * Also, we have consumed any leading or trailing spaces (operand does that)
- * and done all intervening operators.
- */
-
-typedef enum
-{
- O_illegal, /* (0) what we get for illegal op */
-
- O_multiply, /* (1) * */
- O_divide, /* (2) / */
- O_modulus, /* (3) % */
- O_left_shift, /* (4) < */
- O_right_shift, /* (5) > */
- O_bit_inclusive_or, /* (6) | */
- O_bit_or_not, /* (7) ! */
- O_bit_exclusive_or, /* (8) ^ */
- O_bit_and, /* (9) & */
- O_add, /* (10) + */
- O_subtract /* (11) - */
- }
-operatorT;
-
-#define __ O_illegal
-
-static const operatorT op_encoding[256] = { /* maps ASCII->operators */
-
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
-
- __, O_bit_or_not, __, __, __, O_modulus, O_bit_and, __,
- __, __, O_multiply, O_add, __, O_subtract, __, O_divide,
- __, __, __, __, __, __, __, __,
- __, __, __, __, O_left_shift, __, O_right_shift, __,
- __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, O_bit_exclusive_or, __,
- __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __,
- __, __, __, __, O_bit_inclusive_or, __, __, __,
-
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __
- };
-
-
-/*
- * Rank Examples
- * 0 operand, (expression)
- * 1 + -
- * 2 & ^ ! |
- * 3 * / % << >>
- */
-static const operator_rankT
- op_rank[] = { 0, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1 };
-
-/* Return resultP->X_seg. */
-segT expr(rank, resultP)
- register operator_rankT rank; /* Larger # is higher rank. */
- register expressionS *resultP; /* Deliver result here. */
-{
- expressionS right;
- register operatorT op_left;
- register char c_left; /* 1st operator character. */
- register operatorT op_right;
- register char c_right;
-
- know(rank >= 0);
- (void) operand(resultP);
- know(*input_line_pointer != ' '); /* Operand() gobbles spaces. */
- c_left = *input_line_pointer; /* Potential operator character. */
- op_left = op_encoding[c_left];
-
- while (op_left != O_illegal && op_rank[(int) op_left] > rank) {
- input_line_pointer++; /*->after 1st character of operator. */
-
- /* Operators "<<" and ">>" have 2 characters. */
- if (*input_line_pointer == c_left && (c_left == '<' || c_left == '>')) {
- input_line_pointer ++;
- } /*->after operator. */
- if (SEG_ABSENT == expr (op_rank[(int) op_left], &right)) {
- as_warn("Missing operand value assumed absolute 0.");
- resultP->X_add_number = 0;
- resultP->X_subtract_symbol = NULL;
- resultP->X_add_symbol = NULL;
- resultP->X_seg = SEG_ABSOLUTE;
- }
-
- know(*input_line_pointer != ' ');
- c_right = *input_line_pointer;
- op_right = op_encoding[c_right];
-
- if (*input_line_pointer == c_right && (c_right == '<' || c_right == '>')) {
- input_line_pointer ++;
- } /*->after operator. */
-
- know((int) op_right == 0 || op_rank[(int) op_right] <= op_rank[(int) op_left]);
- /* input_line_pointer->after right-hand quantity. */
- /* left-hand quantity in resultP */
- /* right-hand quantity in right. */
- /* operator in op_left. */
- if (resultP->X_seg == SEG_PASS1 || right.X_seg == SEG_PASS1) {
- resultP->X_seg = SEG_PASS1;
- } else {
- if (resultP->X_seg == SEG_BIG) {
- as_warn("Left operand of %c is a %s. Integer 0 assumed.",
- c_left, resultP->X_add_number > 0 ? "bignum" : "float");
- resultP->X_seg = SEG_ABSOLUTE;
- resultP->X_add_symbol = 0;
- resultP->X_subtract_symbol = 0;
- resultP->X_add_number = 0;
- }
- if (right.X_seg == SEG_BIG) {
- as_warn("Right operand of %c is a %s. Integer 0 assumed.",
- c_left, right.X_add_number > 0 ? "bignum" : "float");
- right.X_seg = SEG_ABSOLUTE;
- right.X_add_symbol = 0;
- right.X_subtract_symbol = 0;
- right.X_add_number = 0;
- }
- if (op_left == O_subtract) {
- /*
- * Convert - into + by exchanging symbols and negating number.
- * I know -infinity can't be negated in 2's complement:
- * but then it can't be subtracted either. This trick
- * does not cause any further inaccuracy.
- */
-
- register symbolS * symbolP;
-
- right.X_add_number = - right.X_add_number;
- symbolP = right.X_add_symbol;
- right.X_add_symbol = right.X_subtract_symbol;
- right.X_subtract_symbol = symbolP;
- if (symbolP) {
- right.X_seg = SEG_DIFFERENCE;
- }
- op_left = O_add;
- }
-
- if (op_left == O_add) {
- segT seg1;
- segT seg2;
-#ifndef MANY_SEGMENTS
- know(resultP->X_seg == SEG_DATA
- || resultP->X_seg == SEG_TEXT
- || resultP->X_seg == SEG_BSS
- || resultP->X_seg == SEG_UNKNOWN
- || resultP->X_seg == SEG_DIFFERENCE
- || resultP->X_seg == SEG_ABSOLUTE
- || resultP->X_seg == SEG_PASS1);
- know(right.X_seg == SEG_DATA
- || right.X_seg == SEG_TEXT
- || right.X_seg == SEG_BSS
- || right.X_seg == SEG_UNKNOWN
- || right.X_seg == SEG_DIFFERENCE
- || right.X_seg == SEG_ABSOLUTE
- || right.X_seg == SEG_PASS1);
-#endif
- clean_up_expression(& right);
- clean_up_expression(resultP);
-
-#ifdef PIC
-/* XXX - kludge here to accomodate "_GLOBAL_OFFSET_TABLE + (x - y)"
- * expressions: this only works for this special case, the
- * _GLOBAL_OFFSET_TABLE thing *must* be the left operand, the whole
- * expression is given the segment of right expression (always a DIFFERENCE,
- * which should get resolved by fixup_segment())
- */
- if (resultP->X_got_symbol) {
- resultP->X_add_symbol = right.X_add_symbol;
- resultP->X_subtract_symbol = right.X_subtract_symbol;
- seg1 = S_GET_SEGMENT(right.X_add_symbol);
- seg2 = S_GET_SEGMENT(right.X_subtract_symbol);
- resultP->X_seg = right.X_seg;
- } else {
-#endif
- seg1 = expr_part(&resultP->X_add_symbol, right.X_add_symbol);
- seg2 = expr_part(&resultP->X_subtract_symbol, right.X_subtract_symbol);
-#ifdef PIC
- }
-#endif
- if (seg1 == SEG_PASS1 || seg2 == SEG_PASS1) {
- need_pass_2 = 1;
- resultP->X_seg = SEG_PASS1;
- } else if (seg2 == SEG_ABSOLUTE)
- resultP->X_seg = seg1;
- else if (seg1 != SEG_UNKNOWN
- && seg1 != SEG_ABSOLUTE
- && seg2 != SEG_UNKNOWN
- && seg1 != seg2) {
- know(seg2 != SEG_ABSOLUTE);
- know(resultP->X_subtract_symbol);
-#ifndef MANY_SEGMENTS
- know(seg1 == SEG_TEXT || seg1 == SEG_DATA || seg1 == SEG_BSS);
- know(seg2 == SEG_TEXT || seg2 == SEG_DATA || seg2 == SEG_BSS);
-#endif
- know(resultP->X_add_symbol);
- know(resultP->X_subtract_symbol);
- as_bad("Expression too complex: forgetting %s - %s",
- S_GET_NAME(resultP->X_add_symbol),
- S_GET_NAME(resultP->X_subtract_symbol));
- resultP->X_seg = SEG_ABSOLUTE;
- /* Clean_up_expression() will do the rest. */
- } else
- resultP->X_seg = SEG_DIFFERENCE;
-
- resultP->X_add_number += right.X_add_number;
- clean_up_expression(resultP);
- } else { /* Not +. */
- if (resultP->X_seg == SEG_UNKNOWN || right.X_seg == SEG_UNKNOWN) {
- resultP->X_seg = SEG_PASS1;
- need_pass_2 = 1;
- } else {
- resultP->X_subtract_symbol = NULL;
- resultP->X_add_symbol = NULL;
-
- /* Will be SEG_ABSOLUTE. */
- if (resultP->X_seg != SEG_ABSOLUTE || right.X_seg != SEG_ABSOLUTE) {
- as_bad("Relocation error. Absolute 0 assumed.");
- resultP->X_seg = SEG_ABSOLUTE;
- resultP->X_add_number = 0;
- } else {
- switch (op_left) {
- case O_bit_inclusive_or:
- resultP->X_add_number |= right.X_add_number;
- break;
-
- case O_modulus:
- if (right.X_add_number) {
- resultP->X_add_number %= right.X_add_number;
- } else {
- as_warn("Division by 0. 0 assumed.");
- resultP->X_add_number = 0;
- }
- break;
-
- case O_bit_and:
- resultP->X_add_number &= right.X_add_number;
- break;
-
- case O_multiply:
- resultP->X_add_number *= right.X_add_number;
- break;
-
- case O_divide:
- if (right.X_add_number) {
- resultP->X_add_number /= right.X_add_number;
- } else {
- as_warn("Division by 0. 0 assumed.");
- resultP->X_add_number = 0;
- }
- break;
-
- case O_left_shift:
- resultP->X_add_number <<= right.X_add_number;
- break;
-
- case O_right_shift:
- resultP->X_add_number >>= right.X_add_number;
- break;
-
- case O_bit_exclusive_or:
- resultP->X_add_number ^= right.X_add_number;
- break;
-
- case O_bit_or_not:
- resultP->X_add_number |= ~ right.X_add_number;
- break;
-
- default:
- BAD_CASE(op_left);
- break;
- } /* switch (operator) */
- }
- } /* If we have to force need_pass_2. */
- } /* If operator was +. */
- } /* If we didn't set need_pass_2. */
- op_left = op_right;
- } /* While next operator is >= this rank. */
-
- return(resultP->X_seg);
-} /* expr() */
-
-/*
- * get_symbol_end()
- *
- * This lives here because it belongs equally in expr.c & read.c.
- * Expr.c is just a branch office read.c anyway, and putting it
- * here lessens the crowd at read.c.
- *
- * Assume input_line_pointer is at start of symbol name.
- * Advance input_line_pointer past symbol name.
- * Turn that character into a '\0', returning its former value.
- * This allows a string compare (RMS wants symbol names to be strings)
- * of the symbol name.
- * There will always be a char following symbol name, because all good
- * lines end in end-of-line.
- */
-char
- get_symbol_end()
-{
- register char c;
-
- while (is_part_of_name(c = *input_line_pointer++)) ;;
- *--input_line_pointer = 0;
- return (c);
-}
-
-
-unsigned int get_single_number()
-{
- expressionS exp;
- operand(&exp);
- return exp.X_add_number;
-
-}
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of expr.c */
diff --git a/gnu/usr.bin/as/expr.h b/gnu/usr.bin/as/expr.h
deleted file mode 100644
index 7fd97a2..0000000
--- a/gnu/usr.bin/as/expr.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* expr.h -> header file for expr.c
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-/*
- * Abbreviations (mnemonics).
- *
- * O operator
- * Q quantity, operand
- * X eXpression
- */
-
-/*
- * By popular demand, we define a struct to represent an expression.
- * This will no doubt mutate as expressions become baroque.
- *
- * Currently, we support expressions like "foo-bar+42".
- * In other words we permit a (possibly undefined) minuend, a
- * (possibly undefined) subtrahend and an (absolute) augend.
- * RMS says this is so we can have 1-pass assembly for any compiler
- * emmissions, and a 'case' statement might emit 'undefined1 - undefined2'.
- *
- * To simplify table-driven dispatch, we also have a "segment" for the
- * entire expression. That way we don't require complex reasoning about
- * whether particular components are defined; and we can change component
- * semantics without re-working all the dispatch tables in the assembler.
- * In other words the "type" of an expression is its segment.
- */
-
-typedef struct {
- symbolS *X_add_symbol; /* foo */
- symbolS *X_subtract_symbol; /* bar */
- symbolS *X_got_symbol; /* got */
- long X_add_number; /* 42. Must be signed. */
- segT X_seg; /* What segment (expr type)? */
-}
-expressionS;
-
-/* result should be type (expressionS *). */
-#define expression(result) expr(0,result)
-
-/* If an expression is SEG_BIG, look here */
-/* for its value. These common data may */
-/* be clobbered whenever expr() is called. */
-extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */
-/* Enough to hold most precise flonum. */
-extern LITTLENUM_TYPE generic_bignum[]; /* Bignums returned here. */
-#define SIZE_OF_LARGE_NUMBER (20) /* Number of littlenums in above. */
-
-typedef char operator_rankT;
-
-#if __STDC__ == 1
-
-char get_symbol_end(void);
-segT expr(int rank, expressionS *resultP);
-unsigned int get_single_number(void);
-
-#else /* not __STDC__ */
-
-char get_symbol_end();
-segT expr();
-unsigned int get_single_number();
-
-#endif /* not __STDC__ */
-
-/* end of expr.h */
diff --git a/gnu/usr.bin/as/flo-const.c b/gnu/usr.bin/as/flo-const.c
deleted file mode 100644
index d401854..0000000
--- a/gnu/usr.bin/as/flo-const.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* flonum_const.c - Useful Flonum constants
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "flonum.h"
-/* JF: I added the last entry to this table, and I'm not
- sure if its right or not. Could go either way. I wish
- I really understood this stuff. */
-
-
-const int table_size_of_flonum_powers_of_ten = 11;
-
-static const LITTLENUM_TYPE zero[] = { 1 };
-
-/***********************************************************************\
- * *
- * Warning: the low order bits may be WRONG here. *
- * I took this from a suspect bc(1) script. *
- * "minus_X"[] is supposed to be 10^(2^-X) expressed in base 2^16. *
- * The radix point is just AFTER the highest element of the [] *
- * *
- * Because bc rounds DOWN for printing (I think), the lowest *
- * significance littlenums should probably have 1 added to them. *
- * *
- \***********************************************************************/
-
-/* JF: If this equals 6553/(2^16)+39321/(2^32)+... it approaches .1 */
-static const LITTLENUM_TYPE minus_1[] = {
- 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321,
- 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 6553 };
-static const LITTLENUM_TYPE plus_1[] = { 10 };
-
-/* JF: If this equals 655/(2^16) + 23592/(2^32) + ... it approaches .01 */
-static const LITTLENUM_TYPE minus_2[] = {
- 10485, 36700, 62914, 23592, 49807, 10485, 36700, 62914, 23592, 49807,
- 10485, 36700, 62914, 23592, 49807, 10485, 36700, 62914, 23592, 655 };
-static const LITTLENUM_TYPE plus_2[] = { 100 };
-
-/* This approaches .0001 */
-static const LITTLENUM_TYPE minus_3[] = {
- 52533, 20027, 37329, 65116, 64067, 60397, 14784, 18979, 33659, 19503,
- 2726, 9542, 629, 2202, 40475, 10590, 4299, 47815, 36280, 6 };
-static const LITTLENUM_TYPE plus_3[] = { 10000 };
-
-/* JF: this approaches 1e-8 */
-static const LITTLENUM_TYPE minus_4[] = {
- 22516, 49501, 54293, 19424, 60699, 6716, 24348, 22618, 23904, 21327,
- 3919, 44703, 19149, 28803, 48959, 6259, 50273, 62237, 42 };
-/* This equals 1525 * 2^16 + 57600 */
-static const LITTLENUM_TYPE plus_4[] = { 57600, 1525 };
-
-/* This approaches 1e-16 */
-static const LITTLENUM_TYPE minus_5[] = {
- 22199, 45957, 17005, 26266, 10526, 16260, 55017, 35680, 40443, 19789,
- 17356, 30195, 55905, 28426, 63010, 44197, 1844 };
-static const LITTLENUM_TYPE plus_5[] = { 28609, 34546, 35 };
-
-static const LITTLENUM_TYPE minus_6[] = {
- 30926, 26518, 13110, 43018, 54982, 48258, 24658, 15209, 63366, 11929,
- 20069, 43857, 60487, 51 };
-static const LITTLENUM_TYPE plus_6[] = { 61313, 34220, 16731, 11629, 1262 };
-
-static const LITTLENUM_TYPE minus_7[] = {
- 29819, 14733, 21490, 40602, 31315, 65186, 2695 };
-static const LITTLENUM_TYPE plus_7[] = {
- 7937, 49002, 60772, 28216, 38893, 55975, 63988, 59711, 20227, 24 };
-
-static const LITTLENUM_TYPE minus_8[] = {
- 45849, 19069, 18068, 36324, 37948, 48745, 10873, 64360, 15961, 20566,
- 24178, 15922, 59427, 110 };
-static const LITTLENUM_TYPE plus_8[] = {
- 15873, 11925, 39177, 991, 14589, 19735, 25347, 65086, 53853, 938,
- 37209, 47086, 33626, 23253, 32586, 42547, 9731, 59679, 590 };
-
-static const LITTLENUM_TYPE minus_9[] = {
- 63601, 55221, 43562, 33661, 29067, 28203, 65417, 64352, 22462, 41110,
- 12570, 28635, 23199, 50572, 28471, 27074, 46375, 64028, 13106, 63700,
- 32698, 17493, 32420, 34382, 22750, 20681, 12300 };
-static const LITTLENUM_TYPE plus_9[] = {
- 63564, 61556, 29377, 54467, 18621, 28141, 36415, 61241, 47119, 30026,
- 19740, 46002, 13541, 61413, 30480, 38664, 32205, 50593, 51112, 48904,
- 48263, 43814, 286, 30826, 52813, 62575, 61390, 24540, 21495, 5 };
-
-static const LITTLENUM_TYPE minus_10[] = {
- 50313, 34681, 1464, 25889, 19575, 41125, 17635, 4598, 49708, 13427,
- 17287, 56115, 53783, 38255, 32415, 17778, 31596, 7557, 20951, 18477,
- 40353, 1178, 44405, 11837, 11571, 50963, 15649, 11698, 40675, 2308, };
-static const LITTLENUM_TYPE plus_10[] = {
- 18520, 53764, 54535, 61910, 61962, 59843, 46270, 58053, 12473, 63785,
- 2449, 43230, 50044, 47595, 10403, 35766, 32607, 1124, 24966, 35044,
- 25524, 23631, 18826, 14518, 58448, 14562, 49618, 5588, 25396, 28 };
-
-static const LITTLENUM_TYPE minus_11[] = {
- 6223, 59909, 62437, 59960, 14652, 45336, 48800, 7647, 51962, 37982,
- 60436, 58176, 26767, 8440, 9831, 48556, 20994, 14148, 6757, 17221,
- 60624, 46129, 53210, 44085, 54016, 24259, 11232, 21229, 21313, 81, };
-static const LITTLENUM_TYPE plus_11[] = {
- 36159, 2055, 33615, 61362, 23581, 62454, 9748, 15275, 39284, 58636,
- 16269, 42793, 47240, 45774, 50861, 48400, 9413, 40281, 4030, 9572,
- 7984, 33038, 59522, 19450, 40593, 24486, 54320, 6661, 55766, 805, };
-
-/* Shut up complaints about differing pointer types. They only differ
- in the const attribute, but there isn't any easy way to do this
- */
-#define X (LITTLENUM_TYPE *)
-
-const FLONUM_TYPE flonum_negative_powers_of_ten[] = {
- {X zero, X zero, X zero, 0, '+'},
- {X minus_1, X minus_1 +19, X minus_1 + 19, -20, '+'},
- {X minus_2, X minus_2 +19, X minus_2 + 19, -20, '+'},
- {X minus_3, X minus_3 +19, X minus_3 + 19, -20, '+'},
- {X minus_4, X minus_4 +18, X minus_4 + 18, -20, '+'},
- {X minus_5, X minus_5 +16, X minus_5 + 16, -20, '+'},
- {X minus_6, X minus_6 +13, X minus_6 + 13, -20, '+'},
- {X minus_7, X minus_7 + 6, X minus_7 + 6, -20, '+'},
- {X minus_8, X minus_8 +13, X minus_8 + 13, -40, '+'},
- {X minus_9, X minus_9 +26, X minus_9 + 26, -80, '+'},
- {X minus_10, X minus_10+29, X minus_10 + 29,-136, '+'},
- {X minus_11, X minus_11+29, X minus_11 + 29,-242, '+'},
-};
-
-const FLONUM_TYPE flonum_positive_powers_of_ten[] = {
- {X zero, X zero, X zero, 0, '+'},
- {X plus_1, X plus_1 + 0, X plus_1 + 0, 0, '+'},
- {X plus_2, X plus_2 + 0, X plus_2 + 0, 0, '+'},
- {X plus_3, X plus_3 + 0, X plus_3 + 0, 0, '+'},
- {X plus_4, X plus_4 + 1, X plus_4 + 1, 0, '+'},
- {X plus_5, X plus_5 + 2, X plus_5 + 2, 1, '+'},
- {X plus_6, X plus_6 + 4, X plus_6 + 4, 2, '+'},
- {X plus_7, X plus_7 + 9, X plus_7 + 9, 4, '+'},
- {X plus_8, X plus_8 + 18, X plus_8 + 18, 8, '+'},
- {X plus_9, X plus_9 + 29, X plus_9 + 29, 24, '+'},
- {X plus_10, X plus_10 + 29, X plus_10 + 29, 77, '+'},
- {X plus_11, X plus_11 + 29, X plus_11 + 29, 183, '+'},
-};
-
-#ifdef HO_VMS
-dummy1()
-{
-}
-#endif
-/* end of flonum_const.c */
diff --git a/gnu/usr.bin/as/flo-copy.c b/gnu/usr.bin/as/flo-copy.c
deleted file mode 100644
index 54927ec..0000000
--- a/gnu/usr.bin/as/flo-copy.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* flonum_copy.c - copy a flonum
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "as.h"
-
-void
- flonum_copy(in, out)
-FLONUM_TYPE *in;
-FLONUM_TYPE *out;
-{
- int in_length; /* 0 origin */
- int out_length; /* 0 origin */
-
- out->sign = in->sign;
- in_length = in->leader - in->low;
-
- if (in_length < 0) {
- out->leader = out->low - 1; /* 0.0 case */
- } else {
- out_length = out->high - out->low;
- /*
- * Assume no GAPS in packing of littlenums.
- * I.e. sizeof(array) == sizeof(element) * number_of_elements.
- */
- if (in_length <= out_length) {
- {
- /*
- * For defensive programming, zero any high-order littlenums we don't need.
- * This is destroying evidence and wasting time, so why bother???
- */
- if (in_length < out_length) {
-memset((char *)(out->low + in_length + 1), '\0', out_length - in_length);
- }
- }
- memcpy((void *)(out->low), (void *)(in->low), (int)((in_length + 1) * sizeof(LITTLENUM_TYPE)));
- out->exponent = in->exponent;
- out->leader = in->leader - in->low + out->low;
- } else {
- int shorten; /* 1-origin. Number of littlenums we drop. */
-
- shorten = in_length - out_length;
- /* Assume out_length >= 0 ! */
- memcpy((void *)( out->low), (void *)(in->low + shorten), (int)((out_length + 1) * sizeof(LITTLENUM_TYPE)));
- out->leader = out->high;
- out->exponent = in->exponent + shorten;
- }
- } /* if any significant bits */
-} /* flonum_copy() */
-
-/* end of flonum_copy.c */
diff --git a/gnu/usr.bin/as/flonum-mult.c b/gnu/usr.bin/as/flonum-mult.c
deleted file mode 100644
index fa377f5..0000000
--- a/gnu/usr.bin/as/flonum-mult.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/* flonum_mult.c - multiply two flonums
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of Gas, the GNU Assembler.
-
- The GNU assembler is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY. No author or distributor
- accepts responsibility to anyone for the consequences of using it
- or for whether it serves any particular purpose or works at all,
- unless he says so in writing. Refer to the GNU Assembler General
- Public License for full details.
-
- Everyone is granted permission to copy, modify and redistribute
- the GNU Assembler, but only under the conditions described in the
- GNU Assembler General Public License. A copy of this license is
- supposed to have been given to you along with the GNU Assembler
- so you can know your rights and responsibilities. It should be
- in a file named COPYING. Among other things, the copyright
- notice and this notice must be preserved on all copies. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "flonum.h"
-
-/* plan for a . b => p(roduct)
-
-
- +-------+-------+-/ /-+-------+-------+
- | a | a | ... | a | a |
- | A | A-1 | | 1 | 0 |
- +-------+-------+-/ /-+-------+-------+
-
-
- +-------+-------+-/ /-+-------+-------+
- | b | b | ... | b | b |
- | B | B-1 | | 1 | 0 |
- +-------+-------+-/ /-+-------+-------+
-
-
- +-------+-------+-/ /-+-------+-/ /-+-------+-------+
- | p | p | ... | p | ... | p | p |
- | A+B+1| A+B | | N | | 1 | 0 |
- +-------+-------+-/ /-+-------+-/ /-+-------+-------+
-
- /^\
- (carry) a .b ... | ... a .b a .b
- A B | 0 1 0 0
- |
- ... | ... a .b
- | 1 0
- |
- | ...
- |
- |
- |
- | ___
- | \
- +----- P = > a .b
- N /__ i j
-
- N = 0 ... A+B
-
- for all i,j where i+j=N
- [i,j integers > 0]
-
- a[], b[], p[] may not intersect.
- Zero length factors signify 0 significant bits: treat as 0.0.
- 0.0 factors do the right thing.
- Zero length product OK.
-
- I chose the ForTran accent "foo[bar]" instead of the C accent "*garply"
- because I felt the ForTran way was more intuitive. The C way would
- probably yield better code on most C compilers. Dean Elsner.
- (C style also gives deeper insight [to me] ... oh well ...)
- */
-
-void flonum_multip (a, b, product)
-const FLONUM_TYPE *a;
-const FLONUM_TYPE *b;
-FLONUM_TYPE *product;
-{
- int size_of_a; /* 0 origin */
- int size_of_b; /* 0 origin */
- int size_of_product; /* 0 origin */
- int size_of_sum; /* 0 origin */
- int extra_product_positions;/* 1 origin */
- unsigned long work;
- unsigned long carry;
- long exponent;
- LITTLENUM_TYPE * q;
- long significant; /* TRUE when we emit a non-0 littlenum */
- /* ForTran accent follows. */
- int P; /* Scan product low-order -> high. */
- int N; /* As in sum above. */
- int A; /* Which [] of a? */
- int B; /* Which [] of b? */
-
- if ((a->sign != '-' && a->sign != '+') || (b->sign != '-' && b->sign != '+')) {
- /* ...
- Got to fail somehow. Any suggestions? */
- product->sign=0;
- return;
- }
- product->sign = (a->sign == b->sign) ? '+' : '-';
- size_of_a = a->leader - a->low;
- size_of_b = b->leader - b->low;
- exponent = a->exponent + b->exponent;
- size_of_product = product->high - product->low;
- size_of_sum = size_of_a + size_of_b;
- extra_product_positions = size_of_product - size_of_sum;
- if (extra_product_positions < 0)
- {
- P = extra_product_positions; /* P < 0 */
- exponent -= extra_product_positions; /* Increases exponent. */
- }
- else
- {
- P = 0;
- }
- carry = 0;
- significant = 0;
- for (N = 0;
- N <= size_of_sum;
- N++)
- {
- work = carry;
- carry = 0;
- for (A = 0;
- A <= N;
- A ++)
- {
- B = N - A;
- if (A <= size_of_a && B <= size_of_b && B >= 0)
- {
-#ifdef TRACE
- printf("a:low[%d.]=%04x b:low[%d.]=%04x work_before=%08x\n", A, a->low[A], B, b->low[B], work);
-#endif
- work += a->low[A] * b->low[B];
- carry += work >> LITTLENUM_NUMBER_OF_BITS;
- work &= LITTLENUM_MASK;
-#ifdef TRACE
- printf("work=%08x carry=%04x\n", work, carry);
-#endif
- }
- }
- significant |= work;
- if (significant || P<0)
- {
- if (P >= 0)
- {
- product->low[P] = work;
-#ifdef TRACE
- printf("P=%d. work[p]:=%04x\n", P, work);
-#endif
- }
- P ++;
- }
- else
- {
- extra_product_positions ++;
- exponent ++;
- }
- }
- /*
- * [P]->position # size_of_sum + 1.
- * This is where 'carry' should go.
- */
-#ifdef TRACE
- printf("final carry =%04x\n", carry);
-#endif
- if (carry)
- {
- if (extra_product_positions > 0)
- {
- product->low[P] = carry;
- }
- else
- {
- /* No room at high order for carry littlenum. */
- /* Shift right 1 to make room for most significant littlenum. */
- exponent ++;
- P --;
- for (q = product->low + P;
- q >= product->low;
- q --)
- {
- work = * q;
- * q = carry;
- carry = work;
- }
- }
- }
- else
- {
- P --;
- }
- product->leader = product->low + P;
- product->exponent = exponent;
-}
-
-/* end of flonum_mult.c */
diff --git a/gnu/usr.bin/as/flonum.h b/gnu/usr.bin/as/flonum.h
deleted file mode 100644
index 95ea373..0000000
--- a/gnu/usr.bin/as/flonum.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* flonum.h - Floating point package
-
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-/***********************************************************************\
- * *
- * Arbitrary-precision floating point arithmetic. *
- * *
- * *
- * Notation: a floating point number is expressed as *
- * MANTISSA * (2 ** EXPONENT). *
- * *
- * If this offends more traditional mathematicians, then *
- * please tell me your nomenclature for flonums! *
- * *
- \***********************************************************************/
-#if (__STDC__ != 1) && !defined(const)
-#define const /* empty */
-#endif
-
-#include "bignum.h"
-
-/***********************************************************************\
- * *
- * Variable precision floating point numbers. *
- * *
- * Exponent is the place value of the low littlenum. E.g.: *
- * If 0: low points to the units littlenum. *
- * If 1: low points to the LITTLENUM_RADIX littlenum. *
- * If -1: low points to the 1/LITTLENUM_RADIX littlenum. *
- * *
- \***********************************************************************/
-
-/* JF: A sign value of 0 means we have been asked to assemble NaN
- A sign value of 'P' means we've been asked to assemble +Inf
- A sign value of 'N' means we've been asked to assemble -Inf
- */
-struct FLONUM_STRUCT
-{
- LITTLENUM_TYPE *low; /* low order littlenum of a bignum */
- LITTLENUM_TYPE *high; /* high order littlenum of a bignum */
- LITTLENUM_TYPE *leader; /* -> 1st non-zero littlenum */
- /* If flonum is 0.0, leader == low-1 */
- long exponent; /* base LITTLENUM_RADIX */
- char sign; /* '+' or '-' */
-};
-
-typedef struct FLONUM_STRUCT FLONUM_TYPE;
-
-
-/***********************************************************************\
- * *
- * Since we can (& do) meet with exponents like 10^5000, it *
- * is silly to make a table of ~ 10,000 entries, one for each *
- * power of 10. We keep a table where item [n] is a struct *
- * FLONUM_FLOATING_POINT representing 10^(2^n). We then *
- * multiply appropriate entries from this table to get any *
- * particular power of 10. For the example of 10^5000, a table *
- * of just 25 entries suffices: 10^(2^-12)...10^(2^+12). *
- * *
- \***********************************************************************/
-
-
-extern const FLONUM_TYPE flonum_positive_powers_of_ten[];
-extern const FLONUM_TYPE flonum_negative_powers_of_ten[];
-extern const int table_size_of_flonum_powers_of_ten;
-/* Flonum_XXX_powers_of_ten[] table has */
-/* legal indices from 0 to */
-/* + this number inclusive. */
-
-
-
-/***********************************************************************\
- * *
- * Declare worker functions. *
- * *
- \***********************************************************************/
-
-#if __STDC__ == 1
-
-int atof_generic(char **address_of_string_pointer,
- const char *string_of_decimal_marks,
- const char *string_of_decimal_exponent_marks,
- FLONUM_TYPE *address_of_generic_floating_point_number);
-
-void flonum_copy(FLONUM_TYPE *in, FLONUM_TYPE *out);
-void flonum_multip(const FLONUM_TYPE *a, const FLONUM_TYPE *b, FLONUM_TYPE *product);
-
-#else /* not __STDC__ */
-
-int atof_generic();
-void flonum_copy();
-void flonum_multip();
-
-#endif /* not __STDC__ */
-
-/***********************************************************************\
- * *
- * Declare error codes. *
- * *
- \***********************************************************************/
-
-#define ERROR_EXPONENT_OVERFLOW (2)
-
-/* end of flonum.h */
diff --git a/gnu/usr.bin/as/frags.c b/gnu/usr.bin/as/frags.c
deleted file mode 100644
index b203abb..0000000
--- a/gnu/usr.bin/as/frags.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/* frags.c - manage frags -
-
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "as.h"
-#include "subsegs.h"
-#include "obstack.h"
-
-struct obstack frags; /* All, and only, frags live here. */
-
-fragS zero_address_frag = {
- 0, /* fr_address */
- NULL, /* fr_next */
- 0, /* fr_fix */
- 0, /* fr_var */
- 0, /* fr_symbol */
- 0, /* fr_offset */
- NULL, /* fr_opcode */
- rs_fill, /* fr_type */
- 0, /* fr_subtype */
- 0, /* fr_pcrel_adjust */
- 0, /* fr_bsr */
- 0 /* fr_literal[0] */
- };
-
-fragS bss_address_frag = {
- 0, /* fr_address. Gets filled in to make up
- sy_value-s. */
- NULL, /* fr_next */
- 0, /* fr_fix */
- 0, /* fr_var */
- 0, /* fr_symbol */
- 0, /* fr_offset */
- NULL, /* fr_opcode */
- rs_fill, /* fr_type */
- 0, /* fr_subtype */
- 0, /* fr_pcrel_adjust */
- 0, /* fr_bsr */
- 0 /* fr_literal[0] */
- };
-
-/*
- * frag_grow()
- *
- * Internal.
- * Try to augment current frag by nchars chars.
- * If there is no room, close of the current frag with a ".fill 0"
- * and begin a new frag. Unless the new frag has nchars chars available
- * do not return. Do not set up any fields of *now_frag.
- */
-static void frag_grow(nchars)
-unsigned int nchars;
-{
- if (obstack_room (&frags) < nchars) {
- unsigned int n,oldn;
- long oldc;
-
- frag_wane(frag_now);
- frag_new(0);
- oldn=(unsigned)-1;
- oldc=frags.chunk_size;
- frags.chunk_size=2*nchars;
- while ((n=obstack_room(&frags))<nchars && n<oldn) {
- frag_wane(frag_now);
- frag_new(0);
- oldn=n;
- }
- frags.chunk_size=oldc;
- }
- if (obstack_room (&frags) < nchars)
- as_fatal("Can't extend frag %d. chars", nchars);
-} /* frag_grow() */
-
-/*
- * frag_new()
- *
- * Call this to close off a completed frag, and start up a new (empty)
- * frag, in the same subsegment as the old frag.
- * [frchain_now remains the same but frag_now is updated.]
- * Because this calculates the correct value of fr_fix by
- * looking at the obstack 'frags', it needs to know how many
- * characters at the end of the old frag belong to (the maximal)
- * fr_var: the rest must belong to fr_fix.
- * It doesn't actually set up the old frag's fr_var: you may have
- * set fr_var == 1, but allocated 10 chars to the end of the frag:
- * in this case you pass old_frags_var_max_size == 10.
- *
- * Make a new frag, initialising some components. Link new frag at end
- * of frchain_now.
- */
-void frag_new(old_frags_var_max_size)
-int old_frags_var_max_size; /* Number of chars (already allocated on
- obstack frags) */
-/* in variable_length part of frag. */
-{
- register fragS * former_last_fragP;
- /* char *throw_away_pointer; JF unused */
- register frchainS * frchP;
- long tmp; /* JF */
-
- frag_now->fr_fix = (char *) (obstack_next_free (&frags)) -
- (frag_now->fr_literal) - old_frags_var_max_size;
- /* Fix up old frag's fr_fix. */
-
- obstack_finish (&frags);
- /* This will align the obstack so the */
- /* next struct we allocate on it will */
- /* begin at a correct boundary. */
- frchP = frchain_now;
- know (frchP);
- former_last_fragP = frchP->frch_last;
- know (former_last_fragP);
- know (former_last_fragP == frag_now);
- obstack_blank (&frags, SIZEOF_STRUCT_FRAG);
- /* We expect this will begin at a correct */
- /* boundary for a struct. */
- tmp=obstack_alignment_mask(&frags);
- obstack_alignment_mask(&frags)=0; /* Turn off alignment */
- /* If we ever hit a machine
- where strings must be
- aligned, we Lose Big */
- frag_now=(fragS *)obstack_finish(&frags);
- obstack_alignment_mask(&frags)=tmp; /* Restore alignment */
-
- /* Just in case we don't get zero'd bytes */
- memset(frag_now, '\0', SIZEOF_STRUCT_FRAG);
-
- /* obstack_unaligned_done (&frags, &frag_now); */
- /* know (frags.obstack_c_next_free == frag_now->fr_literal); */
- /* Generally, frag_now->points to an */
- /* address rounded up to next alignment. */
- /* However, characters will add to obstack */
- /* frags IMMEDIATELY after the struct frag, */
- /* even if they are not starting at an */
- /* alignment address. */
- former_last_fragP->fr_next = frag_now;
- frchP->frch_last = frag_now;
-
-#ifndef NO_LISTING
- {
- extern struct list_info_struct *listing_tail;
- frag_now->line = listing_tail;
- }
-#endif
-
- frag_now->fr_next = NULL;
-} /* frag_new() */
-
-/*
- * frag_more()
- *
- * Start a new frag unless we have n more chars of room in the current frag.
- * Close off the old frag with a .fill 0.
- *
- * Return the address of the 1st char to write into. Advance
- * frag_now_growth past the new chars.
- */
-
-char *frag_more (nchars)
-int nchars;
-{
- register char *retval;
-
- frag_grow (nchars);
- retval = obstack_next_free (&frags);
- obstack_blank_fast (&frags, nchars);
- return (retval);
-} /* frag_more() */
-
-/*
- * frag_var()
- *
- * Start a new frag unless we have max_chars more chars of room in the current frag.
- * Close off the old frag with a .fill 0.
- *
- * Set up a machine_dependent relaxable frag, then start a new frag.
- * Return the address of the 1st char of the var part of the old frag
- * to write into.
- */
-
-char *frag_var(type, max_chars, var, subtype, symbol, offset, opcode)
-relax_stateT type;
-int max_chars;
-int var;
-relax_substateT subtype;
-symbolS *symbol;
-long offset;
-char *opcode;
-{
- register char *retval;
-
- frag_grow (max_chars);
- retval = obstack_next_free (&frags);
- obstack_blank_fast (&frags, max_chars);
- frag_now->fr_var = var;
- frag_now->fr_type = type;
- frag_now->fr_subtype = subtype;
- frag_now->fr_symbol = symbol;
- frag_now->fr_offset = offset;
- frag_now->fr_opcode = opcode;
- /* default these to zero. */
- frag_now->fr_pcrel_adjust = 0;
- frag_now->fr_bsr = 0;
- frag_new (max_chars);
- return (retval);
-} /* frag_var() */
-
-/*
- * frag_variant()
- *
- * OVE: This variant of frag_var assumes that space for the tail has been
- * allocated by caller.
- * No call to frag_grow is done.
- * Two new arguments have been added.
- */
-
-char *frag_variant(type, max_chars, var, subtype, symbol, offset, opcode, pcrel_adjust,bsr)
-relax_stateT type;
-int max_chars;
-int var;
-relax_substateT subtype;
-symbolS *symbol;
-long offset;
-char *opcode;
-int pcrel_adjust;
-char bsr;
-{
- register char *retval;
-
- /* frag_grow (max_chars); */
- retval = obstack_next_free (&frags);
- /* obstack_blank_fast (&frags, max_chars); */ /* OVE: so far the only diff */
- frag_now->fr_var = var;
- frag_now->fr_type = type;
- frag_now->fr_subtype = subtype;
- frag_now->fr_symbol = symbol;
- frag_now->fr_offset = offset;
- frag_now->fr_opcode = opcode;
- frag_now->fr_pcrel_adjust = pcrel_adjust;
- frag_now->fr_bsr = bsr;
- frag_new(max_chars);
- return(retval);
-} /* frag_variant() */
-
-/*
- * frag_wane()
- *
- * Reduce the variable end of a frag to a harmless state.
- */
-void frag_wane(fragP)
-register fragS * fragP;
-{
- fragP->fr_type = rs_fill;
- fragP->fr_offset = 0;
- fragP->fr_var = 0;
-}
-
-/*
- * frag_align()
- *
- * Make a frag for ".align foo,bar". Call is "frag_align (foo,bar);".
- * Foo & bar are absolute integers.
- *
- * Call to close off the current frag with a ".align", then start a new
- * (so far empty) frag, in the same subsegment as the last frag.
- */
-
-void frag_align(alignment, fill_character)
-int alignment;
-int fill_character;
-{
- *(frag_var (rs_align, 1, 1, (relax_substateT)0, (symbolS *)0,
- (long)alignment, (char *)0)) = fill_character;
-} /* frag_align() */
-
-/* end of frags.c */
diff --git a/gnu/usr.bin/as/frags.h b/gnu/usr.bin/as/frags.h
deleted file mode 100644
index 722de54..0000000
--- a/gnu/usr.bin/as/frags.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* frags.h - Header file for the frag concept.
-
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-extern struct obstack frags;
-/* Frags ONLY live in this obstack. */
-/* We use obstack_next_free() macro */
-/* so please don't put any other objects */
-/* on this stack! */
-
-/*
- * A macro to speed up appending exactly 1 char
- * to current frag.
- */
-/* JF changed < 1 to <= 1 to avoid a race conditon */
-#define FRAG_APPEND_1_CHAR(datum) \
-{ \
- if (obstack_room( &frags ) <= 1) {\
- frag_wane (frag_now); \
- frag_new (0); \
- } \
- obstack_1grow( &frags, datum ); \
- }
-
-
-#if __STDC__ == 1
-
-char *frag_more(int nchars);
-void frag_align(int alignment, int fill_character);
-void frag_new(int old_frags_var_max_size);
-void frag_wane(fragS *fragP);
-
-char *frag_variant(relax_stateT type,
- int max_chars,
- int var,
- relax_substateT subtype,
- symbolS *symbol,
- long offset,
- char *opcode,
- int pcrel_adjust,
- int bsr);
-
-char *frag_var(relax_stateT type,
- int max_chars,
- int var,
- relax_substateT subtype,
- symbolS *symbol,
- long offset,
- char *opcode);
-
-#else /* not __STDC__ */
-
-char *frag_more();
-char *frag_var();
-char *frag_variant();
-void frag_align();
-void frag_new();
-void frag_wane();
-
-#endif /* not __STDC__ */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of frags.h */
diff --git a/gnu/usr.bin/as/gas-format.el b/gnu/usr.bin/as/gas-format.el
deleted file mode 100644
index 32c6426..0000000
--- a/gnu/usr.bin/as/gas-format.el
+++ /dev/null
@@ -1,79 +0,0 @@
-;; -*- lisp-interaction -*-
-;; -*- emacs-lisp -*-
-;;
-;;
-;; originally from...
-;; Rich's personal .emacs file. feel free to copy.
-;;
-;; this file sets emacs up for the type of C source code formatting used within
-;; gas. I don't use gnu indent. If you do, and find a setup that approximates
-;; these settings, please send it to me.
-;;
-;; Last Mod Thu Feb 13 00:59:16 PST 1992, by rich@sendai
-;;
-
-;;
-;;
-;; This section sets constants used by c-mode for formating
-;;
-;;
-
-
-;; If `c-auto-newline' is non-`nil', newlines are inserted both
-;;before and after braces that you insert, and after colons and semicolons.
-;;Correct C indentation is done on all the lines that are made this way.
-
-(setq c-auto-newline nil)
-
-
-;; If `c-tab-always-indent' is non-`nil', the TAB command
-;;in C mode does indentation only if point is at the left margin or within
-;;the line's indentation. If there is non-whitespace to the left of point,
-;;then TAB just inserts a tab character in the buffer. Normally,
-;;this variable is `nil', and TAB always reindents the current line.
-
-(setq c-tab-always-indent nil)
-
-;; C does not have anything analogous to particular function names for which
-;;special forms of indentation are desirable. However, it has a different
-;;need for customization facilities: many different styles of C indentation
-;;are in common use.
-;;
-;; There are six variables you can set to control the style that Emacs C
-;;mode will use.
-;;
-;;`c-indent-level'
-;; Indentation of C statements within surrounding block. The surrounding
-;; block's indentation is the indentation of the line on which the
-;; open-brace appears.
-
-(setq c-indent-level 8)
-
-;;`c-continued-statement-offset'
-;; Extra indentation given to a substatement, such as the then-clause of
-;; an if or body of a while.
-
-(setq c-continued-statement-offset 4)
-
-;;`c-brace-offset'
-;; Extra indentation for line if it starts with an open brace.
-
-(setq c-brace-offset 0)
-
-;;`c-brace-imaginary-offset'
-;; An open brace following other text is treated as if it were this far
-;; to the right of the start of its line.
-
-(setq c-brace-imaginary-offset 0)
-
-;;`c-argdecl-indent'
-;; Indentation level of declarations of C function arguments.
-
-(setq c-argdecl-indent 0)
-
-;;`c-label-offset'
-;; Extra indentation for line that is a label, or case or default.
-
-(setq c-label-offset -8)
-
-;; end of gas-format.el
diff --git a/gnu/usr.bin/as/hash.c b/gnu/usr.bin/as/hash.c
deleted file mode 100644
index 40752c9..0000000
--- a/gnu/usr.bin/as/hash.c
+++ /dev/null
@@ -1,992 +0,0 @@
-/* hash.c - hash table lookup strings -
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * BUGS, GRIPES, APOLOGIA etc.
- *
- * A typical user doesn't need ALL this: I intend to make a library out
- * of it one day - Dean Elsner.
- * Also, I want to change the definition of a symbol to (address,length)
- * so I can put arbitrary binary in the names stored. [see hsh.c for that]
- *
- * This slime is common coupled inside the module. Com-coupling (and other
- * vandalism) was done to speed running time. The interfaces at the
- * module's edges are adequately clean.
- *
- * There is no way to (a) run a test script through this heap and (b)
- * compare results with previous scripts, to see if we have broken any
- * code. Use GNU (f)utilities to do this. A few commands assist test.
- * The testing is awkward: it tries to be both batch & interactive.
- * For now, interactive rules!
- */
-
-/*
- * The idea is to implement a symbol table. A test jig is here.
- * Symbols are arbitrary strings; they can't contain '\0'.
- * [See hsh.c for a more general symbol flavour.]
- * Each symbol is associated with a char*, which can point to anything
- * you want, allowing an arbitrary property list for each symbol.
- *
- * The basic operations are:
- *
- * new creates symbol table, returns handle
- * find (symbol) returns char*
- * insert (symbol,char*) error if symbol already in table
- * delete (symbol) returns char* if symbol was in table
- * apply so you can delete all symbols before die()
- * die destroy symbol table (free up memory)
- *
- * Supplementary functions include:
- *
- * say how big? what % full?
- * replace (symbol,newval) report previous value
- * jam (symbol,value) assert symbol:=value
- *
- * You, the caller, have control over errors: this just reports them.
- *
- * This package requires malloc(), free().
- * Malloc(size) returns NULL or address of char[size].
- * Free(address) frees same.
- */
-
-/*
- * The code and its structures are re-enterent.
- * Before you do anything else, you must call hash_new() which will
- * return the address of a hash-table-control-block (or NULL if there
- * is not enough memory). You then use this address as a handle of the
- * symbol table by passing it to all the other hash_...() functions.
- * The only approved way to recover the memory used by the symbol table
- * is to call hash_die() with the handle of the symbol table.
- *
- * Before you call hash_die() you normally delete anything pointed to
- * by individual symbols. After hash_die() you can't use that symbol
- * table again.
- *
- * The char* you associate with a symbol may not be NULL (0) because
- * NULL is returned whenever a symbol is not in the table. Any other
- * value is OK, except DELETED, #defined below.
- *
- * When you supply a symbol string for insertion, YOU MUST PRESERVE THE
- * STRING until that symbol is deleted from the table. The reason is that
- * only the address you supply, NOT the symbol string itself, is stored
- * in the symbol table.
- *
- * You may delete and add symbols arbitrarily.
- * Any or all symbols may have the same 'value' (char *). In fact, these
- * routines don't do anything with your symbol values.
- *
- * You have no right to know where the symbol:char* mapping is stored,
- * because it moves around in memory; also because we may change how it
- * works and we don't want to break your code do we? However the handle
- * (address of struct hash_control) is never changed in
- * the life of the symbol table.
- *
- * What you CAN find out about a symbol table is:
- * how many slots are in the hash table?
- * how many slots are filled with symbols?
- * (total hashes,collisions) for (reads,writes) (*)
- * All of the above values vary in time.
- * (*) some of these numbers will not be meaningful if we change the
- * internals.
- */
-
-/*
- * I N T E R N A L
- *
- * Hash table is an array of hash_entries; each entry is a pointer to a
- * a string and a user-supplied value 1 char* wide.
- *
- * The array always has 2 ** n elements, n>0, n integer.
- * There is also a 'wall' entry after the array, which is always empty
- * and acts as a sentinel to stop running off the end of the array.
- * When the array gets too full, we create a new array twice as large
- * and re-hash the symbols into the new array, then forget the old array.
- * (Of course, we copy the values into the new array before we junk the
- * old array!)
- *
- */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include <stdio.h>
-
-#ifndef FALSE
-#define FALSE (0)
-#define TRUE (!FALSE)
-#endif /* no FALSE yet */
-
-#include <ctype.h>
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
-#include "as.h"
-
-#define error as_fatal
-
-#define DELETED ((char *)1) /* guarenteed invalid address */
-#define START_POWER (11) /* power of two: size of new hash table *//* JF was 6 */
-/* JF These next two aren't used any more. */
-/* #define START_SIZE (64) / * 2 ** START_POWER */
-/* #define START_FULL (32) / * number of entries before table expands */
-#define islive(ptr) (ptr->hash_string && ptr->hash_string != DELETED)
-/* above TRUE if a symbol is in entry @ ptr */
-
-#define STAT_SIZE (0) /* number of slots in hash table */
-/* the wall does not count here */
-/* we expect this is always a power of 2 */
-#define STAT_ACCESS (1) /* number of hash_ask()s */
-#define STAT__READ (0) /* reading */
-#define STAT__WRITE (1) /* writing */
-#define STAT_COLLIDE (3) /* number of collisions (total) */
-/* this may exceed STAT_ACCESS if we have */
-/* lots of collisions/access */
-#define STAT_USED (5) /* slots used right now */
-#define STATLENGTH (6) /* size of statistics block */
-#if STATLENGTH != HASH_STATLENGTH
-Panic! Please make #include "stat.h" agree with previous definitions!
-#endif
-
- /* #define SUSPECT to do runtime checks */
- /* #define TEST to be a test jig for hash...() */
-
-#ifdef TEST /* TEST: use smaller hash table */
-#undef START_POWER
-#define START_POWER (3)
-#undef START_SIZE
-#define START_SIZE (8)
-#undef START_FULL
-#define START_FULL (4)
-#endif
-
-/*------------------ plan ---------------------------------- i = internal
-
- struct hash_control * c;
- struct hash_entry * e; i
- int b[z]; buffer for statistics
- z size of b
- char * s; symbol string (address) [ key ]
- char * v; value string (address) [datum]
- boolean f; TRUE if we found s in hash table i
- char * t; error string; "" means OK
- int a; access type [0...n) i
-
- c=hash_new () create new hash_control
-
- hash_die (c) destroy hash_control (and hash table)
- table should be empty.
- doesn't check if table is empty.
- c has no meaning after this.
-
- hash_say (c,b,z) report statistics of hash_control.
- also report number of available statistics.
-
- v=hash_delete (c,s) delete symbol, return old value if any.
- ask() NULL means no old value.
- f
-
- v=hash_replace (c,s,v) replace old value of s with v.
- ask() NULL means no old value: no table change.
- f
-
- t=hash_insert (c,s,v) insert (s,v) in c.
- ask() return error string.
- f it is an error to insert if s is already
- in table.
- if any error, c is unchanged.
-
- t=hash_jam (c,s,v) assert that new value of s will be v. i
- ask() it may decide to GROW the table. i
- f i
- grow() i
- t=hash_grow (c) grow the hash table. i
- jam() will invoke JAM. i
-
- ?=hash_apply (c,y) apply y() to every symbol in c.
- y evtries visited in 'unspecified' order.
-
- v=hash_find (c,s) return value of s, or NULL if s not in c.
- ask()
- f
-
- f,e=hash_ask() (c,s,a) return slot where s SHOULD live. i
- code() maintain collision stats in c. i
-
- .=hash_code (c,s) compute hash-code for s, i
- from parameters of c. i
-
- */
-
-static char hash_found; /* returned by hash_ask() to stop extra */
-/* testing. hash_ask() wants to return both */
-/* a slot and a status. This is the status. */
-/* TRUE: found symbol */
-/* FALSE: absent: empty or deleted slot */
-/* Also returned by hash_jam(). */
-/* TRUE: we replaced a value */
-/* FALSE: we inserted a value */
-
-static struct hash_entry * hash_ask();
-static int hash_code ();
-static char * hash_grow();
-
-/*
- * h a s h _ n e w ( )
- *
- */
-struct hash_control *
- hash_new() /* create a new hash table */
-/* return NULL if failed */
-/* return handle (address of struct hash) */
-{
- register struct hash_control * retval;
- register struct hash_entry * room; /* points to hash table */
- register struct hash_entry * wall;
- register struct hash_entry * entry;
- register int * ip; /* scan stats block of struct hash_control */
- register int * nd; /* limit of stats block */
-
- if (( room = (struct hash_entry *) malloc( sizeof(struct
- hash_entry)*((1<<START_POWER) + 1) ) ) != NULL)
- /* +1 for the wall entry */
- {
- if (( retval = (struct hash_control *) malloc(sizeof(struct
- hash_control)) ) != NULL)
- {
- nd = retval->hash_stat + STATLENGTH;
- for (ip=retval->hash_stat; ip<nd; ip++)
- {
- *ip = 0;
- }
-
- retval->hash_stat[STAT_SIZE] = 1<<START_POWER;
- retval->hash_mask = (1<<START_POWER) - 1;
- retval->hash_sizelog = START_POWER;
- /* works for 1's compl ok */
- retval->hash_where = room;
- retval->hash_wall =
- wall = room + (1<<START_POWER);
- retval->hash_full = (1<<START_POWER)/2;
- for (entry=room; entry <= wall; entry++)
- {
- entry->hash_string = NULL;
- }
- }
- }
- else
- {
- retval = NULL; /* no room for table: fake a failure */
- }
- return(retval); /* return NULL or set-up structs */
-}
-
-/*
- * h a s h _ d i e ( )
- *
- * Table should be empty, but this is not checked.
- * To empty the table, try hash_apply()ing a symbol deleter.
- * Return to free memory both the hash table and it's control
- * block.
- * 'handle' has no meaning after this function.
- * No errors are recoverable.
- */
-void
- hash_die(handle)
-struct hash_control * handle;
-{
- free((char *)handle->hash_where);
- free((char *)handle);
-}
-
-/*
- * h a s h _ s a y ( )
- *
- * Return the size of the statistics table, and as many statistics as
- * we can until either (a) we have run out of statistics or (b) caller
- * has run out of buffer.
- * NOTE: hash_say treats all statistics alike.
- * These numbers may change with time, due to insertions, deletions
- * and expansions of the table.
- * The first "statistic" returned is the length of hash_stat[].
- * Then contents of hash_stat[] are read out (in ascending order)
- * until your buffer or hash_stat[] is exausted.
- */
-void
- hash_say(handle,buffer,bufsiz)
-register struct hash_control * handle;
-register int buffer[/*bufsiz*/];
-register int bufsiz;
-{
- register int * nd; /* limit of statistics block */
- register int * ip; /* scan statistics */
-
- ip = handle->hash_stat;
- nd = ip + min(bufsiz-1,STATLENGTH);
- if (bufsiz>0) /* trust nothing! bufsiz <= 0 is dangerous */
- {
- *buffer++ = STATLENGTH;
- for (; ip<nd; ip++,buffer++)
- {
- *buffer = *ip;
- }
- }
-}
-
-/*
- * h a s h _ d e l e t e ( )
- *
- * Try to delete a symbol from the table.
- * If it was there, return its value (and adjust STAT_USED).
- * Otherwise, return NULL.
- * Anyway, the symbol is not present after this function.
- *
- */
-char * /* NULL if string not in table, else */
- /* returns value of deleted symbol */
- hash_delete(handle,string)
-register struct hash_control * handle;
-register char * string;
-{
- register char * retval; /* NULL if string not in table */
- register struct hash_entry * entry; /* NULL or entry of this symbol */
-
- entry = hash_ask(handle,string,STAT__WRITE);
- if (hash_found)
- {
- retval = entry->hash_value;
- entry->hash_string = DELETED; /* mark as deleted */
- handle->hash_stat[STAT_USED] -= 1; /* slots-in-use count */
-#ifdef SUSPECT
- if (handle->hash_stat[STAT_USED]<0)
- {
- error("hash_delete");
- }
-#endif /* def SUSPECT */
- }
- else
- {
- retval = NULL;
- }
- return(retval);
-}
-
-/*
- * h a s h _ r e p l a c e ( )
- *
- * Try to replace the old value of a symbol with a new value.
- * Normally return the old value.
- * Return NULL and don't change the table if the symbol is not already
- * in the table.
- */
-char *
- hash_replace(handle,string,value)
-register struct hash_control * handle;
-register char * string;
-register char * value;
-{
- register struct hash_entry * entry;
- register char * retval;
-
- entry = hash_ask(handle,string,STAT__WRITE);
- if (hash_found)
- {
- retval = entry->hash_value;
- entry->hash_value = value;
- }
- else
- {
- retval = NULL;
- }
- ;
- return (retval);
-}
-
-/*
- * h a s h _ i n s e r t ( )
- *
- * Insert a (symbol-string, value) into the hash table.
- * Return an error string, "" means OK.
- * It is an 'error' to insert an existing symbol.
- */
-
-char * /* return error string */
- hash_insert(handle,string,value)
-register struct hash_control * handle;
-register char * string;
-register char * value;
-{
- register struct hash_entry * entry;
- register char * retval;
-
- retval = "";
- if (handle->hash_stat[STAT_USED] > handle->hash_full)
- {
- retval = hash_grow(handle);
- }
- if ( ! * retval)
- {
- entry = hash_ask(handle,string,STAT__WRITE);
- if (hash_found)
- {
- retval = "exists";
- }
- else
- {
- entry->hash_value = value;
- entry->hash_string = string;
- handle->hash_stat[STAT_USED] += 1;
- }
- }
- return(retval);
-}
-
-/*
- * h a s h _ j a m ( )
- *
- * Regardless of what was in the symbol table before, after hash_jam()
- * the named symbol has the given value. The symbol is either inserted or
- * (its value is) relpaced.
- * An error message string is returned, "" means OK.
- *
- * WARNING: this may decide to grow the hashed symbol table.
- * To do this, we call hash_grow(), WHICH WILL recursively CALL US.
- *
- * We report status internally: hash_found is TRUE if we replaced, but
- * false if we inserted.
- */
-char *
- hash_jam(handle,string,value)
-register struct hash_control * handle;
-register char * string;
-register char * value;
-{
- register char * retval;
- register struct hash_entry * entry;
-
- retval = "";
- if (handle->hash_stat[STAT_USED] > handle->hash_full)
- {
- retval = hash_grow(handle);
- }
- if (! * retval)
- {
- entry = hash_ask(handle,string,STAT__WRITE);
- if ( ! hash_found)
- {
- entry->hash_string = string;
- handle->hash_stat[STAT_USED] += 1;
- }
- entry->hash_value = value;
- }
- return(retval);
-}
-
-/*
- * h a s h _ g r o w ( )
- *
- * Grow a new (bigger) hash table from the old one.
- * We choose to double the hash table's size.
- * Return a human-scrutible error string: "" if OK.
- * Warning! This uses hash_jam(), which had better not recurse
- * back here! Hash_jam() conditionally calls us, but we ALWAYS
- * call hash_jam()!
- * Internal.
- */
-static char *
- hash_grow(handle) /* make a hash table grow */
-struct hash_control * handle;
-{
- register struct hash_entry * newwall;
- register struct hash_entry * newwhere;
- struct hash_entry * newtrack;
- register struct hash_entry * oldtrack;
- register struct hash_entry * oldwhere;
- register struct hash_entry * oldwall;
- register int temp;
- int newsize;
- char * string;
- char * retval;
-#ifdef SUSPECT
- int oldused;
-#endif
-
- /*
- * capture info about old hash table
- */
- oldwhere = handle->hash_where;
- oldwall = handle->hash_wall;
-#ifdef SUSPECT
- oldused = handle->hash_stat[STAT_USED];
-#endif
- /*
- * attempt to get enough room for a hash table twice as big
- */
- temp = handle->hash_stat[STAT_SIZE];
- if (( newwhere = (struct hash_entry *)
- xmalloc((long)((temp+temp+1)*sizeof(struct hash_entry)))) != NULL)
- /* +1 for wall slot */
- {
- retval = ""; /* assume success until proven otherwise */
- /*
- * have enough room: now we do all the work.
- * double the size of everything in handle,
- * note: hash_mask frob works for 1's & for 2's complement machines
- */
- handle->hash_mask = handle->hash_mask + handle->hash_mask + 1;
- handle->hash_stat[STAT_SIZE] <<= 1;
- newsize = handle->hash_stat[STAT_SIZE];
- handle->hash_where = newwhere;
- handle->hash_full <<= 1;
- handle->hash_sizelog += 1;
- handle->hash_stat[STAT_USED] = 0;
- handle->hash_wall =
- newwall = newwhere + newsize;
- /*
- * set all those pesky new slots to vacant.
- */
- for (newtrack=newwhere; newtrack <= newwall; newtrack++)
- {
- newtrack->hash_string = NULL;
- }
- /*
- * we will do a scan of the old table, the hard way, using the
- * new control block to re-insert the data into new hash table.
- */
- handle->hash_stat[STAT_USED] = 0; /* inserts will bump it up to correct */
- for (oldtrack=oldwhere; oldtrack < oldwall; oldtrack++)
- {
- if (((string = oldtrack->hash_string) != NULL) && string != DELETED)
- {
- if ( * (retval = hash_jam(handle,string,oldtrack->hash_value) ) )
- {
- break;
- }
- }
- }
-#ifdef SUSPECT
- if ( !*retval && handle->hash_stat[STAT_USED] != oldused)
- {
- retval = "hash_used";
- }
-#endif
- if (!*retval)
- {
- /*
- * we have a completely faked up control block.
- * return the old hash table.
- */
- free((char *)oldwhere);
- /*
- * Here with success. retval is already "".
- */
- }
- }
- else
- {
- retval = "no room";
- }
- return(retval);
-}
-
-/*
- * h a s h _ a p p l y ( )
- *
- * Use this to scan each entry in symbol table.
- * For each symbol, this calls (applys) a nominated function supplying the
- * symbol's value (and the symbol's name).
- * The idea is you use this to destroy whatever is associted with
- * any values in the table BEFORE you destroy the table with hash_die.
- * Of course, you can use it for other jobs; whenever you need to
- * visit all extant symbols in the table.
- *
- * We choose to have a call-you-back idea for two reasons:
- * asthetic: it is a neater idea to use apply than an explicit loop
- * sensible: if we ever had to grow the symbol table (due to insertions)
- * then we would lose our place in the table when we re-hashed
- * symbols into the new table in a different order.
- *
- * The order symbols are visited depends entirely on the hashing function.
- * Whenever you insert a (symbol, value) you risk expanding the table. If
- * you do expand the table, then the hashing function WILL change, so you
- * MIGHT get a different order of symbols visited. In other words, if you
- * want the same order of visiting symbols as the last time you used
- * hash_apply() then you better not have done any hash_insert()s or
- * hash_jam()s since the last time you used hash_apply().
- *
- * In future we may use the value returned by your nominated function.
- * One idea is to abort the scan if, after applying the function to a
- * certain node, the function returns a certain code.
- * To be safe, please make your functions of type char *. If you always
- * return NULL, then the scan will complete, visiting every symbol in
- * the table exactly once. ALL OTHER RETURNED VALUES have no meaning yet!
- * Caveat Actor!
- *
- * The function you supply should be of the form:
- * char * myfunct(string,value)
- * char * string; |* the symbol's name *|
- * char * value; |* the symbol's value *|
- * {
- * |* ... *|
- * return(NULL);
- * }
- *
- * The returned value of hash_apply() is (char*)NULL. In future it may return
- * other values. NULL means "completed scan OK". Other values have no meaning
- * yet. (The function has no graceful failures.)
- */
-char *
- hash_apply(handle,function)
-struct hash_control * handle;
-char* (*function)();
-{
- register struct hash_entry * entry;
- register struct hash_entry * wall;
-
- wall = handle->hash_wall;
- for (entry = handle->hash_where; entry < wall; entry++)
- {
- if (islive(entry)) /* silly code: tests entry->string twice! */
- {
- (*function)(entry->hash_string,entry->hash_value);
- }
- }
- return (NULL);
-}
-
-/*
- * h a s h _ f i n d ( )
- *
- * Given symbol string, find value (if any).
- * Return found value or NULL.
- */
-char *
- hash_find(handle,string) /* return char* or NULL */
-struct hash_control * handle;
-char * string;
-{
- register struct hash_entry * entry;
- register char * retval;
-
- entry = hash_ask(handle,string,STAT__READ);
- if (hash_found)
- {
- retval = entry->hash_value;
- }
- else
- {
- retval = NULL;
- }
- return(retval);
-}
-
-/*
- * h a s h _ a s k ( )
- *
- * Searches for given symbol string.
- * Return the slot where it OUGHT to live. It may be there.
- * Return hash_found: TRUE only if symbol is in that slot.
- * Access argument is to help keep statistics in control block.
- * Internal.
- */
-static struct hash_entry * /* string slot, may be empty or deleted */
- hash_ask(handle,string,access)
-struct hash_control * handle;
-char * string;
-int access; /* access type */
-{
- register char *string1; /* JF avoid strcmp calls */
- register char * s;
- register int c;
- register struct hash_entry * slot;
- register int collision; /* count collisions */
-
- slot = handle->hash_where + hash_code(handle,string); /* start looking here */
- handle->hash_stat[STAT_ACCESS+access] += 1;
- collision = 0;
- hash_found = FALSE;
- while (((s = slot->hash_string) != NULL) && s != DELETED)
- {
- for (string1=string;;) {
- if ((c= *s++) == 0) {
- if (!*string1)
- hash_found = TRUE;
- break;
- }
- if (*string1++ != c)
- break;
- }
- if (hash_found)
- break;
- collision++;
- slot++;
- }
- /*
- * slot: return:
- * in use: we found string slot
- * at empty:
- * at wall: we fell off: wrap round ????
- * in table: dig here slot
- * at DELETED: dig here slot
- */
- if (slot == handle->hash_wall)
- {
- slot = handle->hash_where; /* now look again */
- while (((s = slot->hash_string) != NULL) && s != DELETED)
- {
- for (string1=string;*s;string1++,s++) {
- if (*string1 != *s)
- break;
- }
- if (*s == *string1) {
- hash_found = TRUE;
- break;
- }
- collision++;
- slot++;
- }
- /*
- * slot: return:
- * in use: we found it slot
- * empty: wall: ERROR IMPOSSIBLE !!!!
- * in table: dig here slot
- * DELETED:dig here slot
- */
- }
- /* fprintf(stderr,"hash_ask(%s)->%d(%d)\n",string,hash_code(handle,string),collision); */
- handle->hash_stat[STAT_COLLIDE+access] += collision;
- return(slot); /* also return hash_found */
-}
-
-/*
- * h a s h _ c o d e
- *
- * Does hashing of symbol string to hash number.
- * Internal.
- */
-static int
- hash_code(handle,string)
-struct hash_control * handle;
-register char * string;
-{
- register long h; /* hash code built here */
- register long c; /* each character lands here */
- register int n; /* Amount to shift h by */
-
- n = (handle->hash_sizelog - 3);
- h = 0;
- while ((c = *string++) != 0)
- {
- h += c;
- h = (h<<3) + (h>>n) + c;
- }
- return (h & handle->hash_mask);
-}
-
-/*
- * Here is a test program to exercise above.
- */
-#ifdef TEST
-
-#define TABLES (6) /* number of hash tables to maintain */
-/* (at once) in any testing */
-#define STATBUFSIZE (12) /* we can have 12 statistics */
-
-int statbuf[STATBUFSIZE]; /* display statistics here */
-char answer[100]; /* human farts here */
-char * hashtable[TABLES]; /* we test many hash tables at once */
-char * h; /* points to curent hash_control */
-char ** pp;
-char * p;
-char * name;
-char * value;
-int size;
-int used;
-char command;
-int number; /* number 0:TABLES-1 of current hashed */
-/* symbol table */
-
-main()
-{
- char (*applicatee());
- char * hash_find();
- char * destroy();
- char * what();
- struct hash_control * hash_new();
- char * hash_replace();
- int * ip;
-
- number = 0;
- h = 0;
- printf("type h <RETURN> for help\n");
- for (;;)
- {
- printf("hash_test command: ");
- fgets(answer, 100, stdin);
- command = answer[0];
- if (isupper(command)) command = tolower(command); /* ecch! */
- switch (command)
- {
- case '#':
- printf("old hash table #=%d.\n",number);
- whattable();
- break;
- case '?':
- for (pp=hashtable; pp<hashtable+TABLES; pp++)
- {
- printf("address of hash table #%d control block is %xx\n"
- ,pp-hashtable,*pp);
- }
- break;
- case 'a':
- hash_apply(h,applicatee);
- break;
- case 'd':
- hash_apply(h,destroy);
- hash_die(h);
- break;
- case 'f':
- p = hash_find(h,name=what("symbol"));
- printf("value of \"%s\" is \"%s\"\n",name,p?p:"NOT-PRESENT");
- break;
- case 'h':
- printf("# show old, select new default hash table number\n");
- printf("? display all hashtable control block addresses\n");
- printf("a apply a simple display-er to each symbol in table\n");
- printf("d die: destroy hashtable\n");
- printf("f find value of nominated symbol\n");
- printf("h this help\n");
- printf("i insert value into symbol\n");
- printf("j jam value into symbol\n");
- printf("n new hashtable\n");
- printf("r replace a value with another\n");
- printf("s say what %% of table is used\n");
- printf("q exit this program\n");
- printf("x delete a symbol from table, report its value\n");
- break;
- case 'i':
- p = hash_insert(h,name=what("symbol"),value=what("value"));
- if (*p)
- {
- printf("symbol=\"%s\" value=\"%s\" error=%s\n",name,value,p);
- }
- break;
- case 'j':
- p = hash_jam(h,name=what("symbol"),value=what("value"));
- if (*p)
- {
- printf("symbol=\"%s\" value=\"%s\" error=%s\n",name,value,p);
- }
- break;
- case 'n':
- h = hashtable[number] = (char *) hash_new();
- break;
- case 'q':
- exit();
- case 'r':
- p = hash_replace(h,name=what("symbol"),value=what("value"));
- printf("old value was \"%s\"\n",p?p:"{}");
- break;
- case 's':
- hash_say(h,statbuf,STATBUFSIZE);
- for (ip=statbuf; ip<statbuf+STATBUFSIZE; ip++)
- {
- printf("%d ",*ip);
- }
- printf("\n");
- break;
- case 'x':
- p = hash_delete(h,name=what("symbol"));
- printf("old value was \"%s\"\n",p?p:"{}");
- break;
- default:
- printf("I can't understand command \"%c\"\n",command);
- break;
- }
- }
-}
-
-char *
- what(description)
-char * description;
-{
- char * retval;
- char * malloc();
-
- printf(" %s : ",description);
- fgets(answer, 100, stdin);
- /* will one day clean up answer here */
- retval = malloc(strlen(answer)+1);
- if (!retval)
- {
- error("room");
- }
- (void)strcpy(retval,answer);
- return(retval);
-}
-
-char *
- destroy(string,value)
-char * string;
-char * value;
-{
- free(string);
- free(value);
- return(NULL);
-}
-
-
-char *
- applicatee(string,value)
-char * string;
-char * value;
-{
- printf("%.20s-%.20s\n",string,value);
- return(NULL);
-}
-
-whattable() /* determine number: what hash table to use */
-/* also determine h: points to hash_control */
-{
-
- for (;;)
- {
- printf(" what hash table (%d:%d) ? ",0,TABLES-1);
- fgets(answer, 100, stdin);
- sscanf(answer,"%d",&number);
- if (number >= 0 && number<TABLES)
- {
- h = hashtable[number];
- if (!h)
- {
- printf("warning: current hash-table-#%d. has no hash-control\n",number);
- }
- return;
- }
- else
- {
- printf("invalid hash table number: %d\n",number);
- }
- }
-}
-
-
-
-#endif /* #ifdef TEST */
-
-/* end of hash.c */
diff --git a/gnu/usr.bin/as/hash.h b/gnu/usr.bin/as/hash.h
deleted file mode 100644
index 6325559..0000000
--- a/gnu/usr.bin/as/hash.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* hash.h - for hash.c
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-#ifndef hashH
-#define hashH
-
-struct hash_entry
-{
- char *hash_string; /* points to where the symbol string is */
- /* NULL means slot is not used */
- /* DELETED means slot was deleted */
- char *hash_value; /* user's datum, associated with symbol */
-};
-
-
-#define HASH_STATLENGTH (6)
-struct hash_control
-{
- struct hash_entry *hash_where; /* address of hash table */
- int hash_sizelog; /* Log of ( hash_mask + 1 ) */
- int hash_mask; /* masks a hash into index into table */
- int hash_full; /* when hash_stat[STAT_USED] exceeds this, */
- /* grow table */
- struct hash_entry * hash_wall; /* point just after last (usable) entry */
- /* here we have some statistics */
- int hash_stat[HASH_STATLENGTH]; /* lies & statistics */
- /* we need STAT_USED & STAT_SIZE */
-};
-
- /* fixme: prototype. */
-
-/* returns */
-struct hash_control *hash_new(); /* [control block] */
-void hash_die();
-void hash_say();
-char *hash_delete(); /* previous value */
-char *hash_relpace(); /* previous value */
-char *hash_insert(); /* error string */
-char *hash_apply(); /* 0 means OK */
-char *hash_find(); /* value */
-char *hash_jam(); /* error text (internal) */
-
-#endif /* #ifdef hashH */
-
-/* end of hash.h */
diff --git a/gnu/usr.bin/as/hex-value.c b/gnu/usr.bin/as/hex-value.c
deleted file mode 100644
index 342f5ee..0000000
--- a/gnu/usr.bin/as/hex-value.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* hex_value.c - char=>radix-value -
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Export: Hex_value[]. Converts digits to their radix-values.
- * As distributed assumes 8 bits per char (256 entries) and ASCII.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#define __ (42) /* blatently illegal digit value */
-/* exceeds any normal radix */
-
-#if (__STDC__ != 1) && !defined(const)
-#define const /* empty */
-#endif
-const char
- hex_value[256] = { /* for fast ASCII -> binary */
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, __, __, __, __, __, __,
- __, 10, 11, 12, 13, 14, 15, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, 10, 11, 12, 13, 14, 15, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
- __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __
- };
-
-#ifdef HO_VMS
-dummy2()
-{
-}
-#endif
-
-/* end of hex_value.c */
diff --git a/gnu/usr.bin/as/input-file.c b/gnu/usr.bin/as/input-file.c
deleted file mode 100644
index ab834fd..0000000
--- a/gnu/usr.bin/as/input-file.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/* input_file.c - Deal with Input Files -
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Confines all details of reading source bytes to this module.
- * All O/S specific crocks should live here.
- * What we lose in "efficiency" we gain in modularity.
- * Note we don't need to #include the "as.h" file. No common coupling!
- */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#ifdef USG
-#define setbuffer(stream, buf, size) setvbuf((stream), (buf), _IOFBF, (size))
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#include "as.h"
-#include "input-file.h"
-
-/* This variable is non-zero if the file currently being read should be
- preprocessed by app. It is zero if the file can be read straight in.
- */
-int preprocess = 0;
-
-/*
- * This code opens a file, then delivers BUFFER_SIZE character
- * chunks of the file on demand.
- * BUFFER_SIZE is supposed to be a number chosen for speed.
- * The caller only asks once what BUFFER_SIZE is, and asks before
- * the nature of the input files (if any) is known.
- */
-
-#define BUFFER_SIZE (32 * 1024)
-
-/*
- * We use static data: the data area is not sharable.
- */
-
-FILE *f_in;
-/* static JF remove static so app.c can use file_name */
-char * file_name;
-
-/* Struct for saving the state of this module for file includes. */
-struct saved_file {
- FILE *f_in;
- char *file_name;
- int preprocess;
- char *app_save;
-};
-
-/* These hooks accomodate most operating systems. */
-
-void input_file_begin() {
- f_in = (FILE *)0;
-}
-
-void input_file_end () { }
-
-/* Return BUFFER_SIZE. */
-int input_file_buffer_size() {
- return (BUFFER_SIZE);
-}
-
-int input_file_is_open() {
- return f_in != (FILE *)0;
-}
-
-/* Push the state of our input, returning a pointer to saved info that
- can be restored with input_file_pop (). */
-char *input_file_push () {
- register struct saved_file *saved;
-
- saved = (struct saved_file *)xmalloc (sizeof *saved);
-
- saved->f_in = f_in;
- saved->file_name = file_name;
- saved->preprocess = preprocess;
- if (preprocess)
- saved->app_save = app_push ();
-
- input_file_begin (); /* Initialize for new file */
-
- return (char *)saved;
-}
-
-void
- input_file_pop (arg)
-char *arg;
-{
- register struct saved_file *saved = (struct saved_file *)arg;
-
- input_file_end (); /* Close out old file */
-
- f_in = saved->f_in;
- file_name = saved->file_name;
- preprocess = saved->preprocess;
- if (preprocess)
- app_pop (saved->app_save);
-
- free(arg);
-}
-
-#ifdef DONTDEF /* JF save old version in case we need it */
-void
- input_file_open (filename, preprocess, debugging)
-char * filename; /* "" means use stdin. Must not be 0. */
-int preprocess; /* TRUE if needs app. */
-int debugging; /* TRUE if we are debugging assembler. */
-{
- assert( filename != 0 ); /* Filename may not be NULL. */
- if (filename[0])
- { /* We have a file name. Suck it and see. */
- file_handle = open (filename, O_RDONLY, 0);
- file_name = filename;
- }
- else
- { /* use stdin for the input file. */
- file_handle = fileno (stdin);
- file_name = "{standard input}"; /* For error messages. */
- }
- if (file_handle < 0)
- as_perror ("Can't open %s for reading", file_name);
- if ( preprocess )
- {
- /*
- * This code was written in haste for a frobbed BSD 4.2.
- * I have a flight to catch: will someone please do proper
- * error checks? - Dean.
- */
- int pid;
- char temporary_file_name[12];
- int fd;
- union wait status;
-
- (void)strcpy (temporary_file_name, "#appXXXXXX");
- (void)mktemp (temporary_file_name);
- pid = vfork ();
- if (pid == -1)
- {
- as_perror ("Vfork failed", file_name);
- _exit (144);
- }
- if (pid == 0)
- {
- (void)dup2 (file_handle, fileno(stdin));
- fd = open (temporary_file_name, O_WRONLY + O_TRUNC + O_CREAT, 0666);
- if (fd == -1)
- {
- (void)write(2,"Can't open temporary\n",21);
- _exit (99);
- }
- (void)dup2 (fd, fileno(stdout));
- /* JF for testing #define PREPROCESSOR "/lib/app" */
-#define PREPROCESSOR "./app"
- execl (PREPROCESSOR, PREPROCESSOR, 0);
- execl ("app","app",0);
- (void)write(2,"Exec of app failed. Get help.\n",31);
- (void)unlink(temporary_file_name);
- _exit (11);
- }
- (void)wait (& status);
- if (status.w_status & 0xFF00) /* JF was 0xF000, was wrong */
- {
- file_handle = -1;
- as_bad( "Can't preprocess file \"%s\", status = %xx", file_name, status.w_status );
- }
- else
- {
- file_handle = open (temporary_file_name, O_RDONLY, 0);
- if ( ! debugging && unlink(temporary_file_name))
- as_perror ("Can't delete temp file %s", temporary_file_name);
- }
- if (file_handle == -1)
- as_perror ("Can't retrieve temp file %s", temporary_file_name);
- }
-}
-#else
-
-void
- input_file_open (filename,pre)
-char * filename; /* "" means use stdin. Must not be 0. */
-int pre;
-{
- int c;
- char buf[80];
-
- preprocess = pre;
-
- assert( filename != 0 ); /* Filename may not be NULL. */
- if (filename[0]) { /* We have a file name. Suck it and see. */
- f_in=fopen(filename,"r");
- file_name=filename;
- } else { /* use stdin for the input file. */
- f_in = stdin;
- file_name = "{standard input}"; /* For error messages. */
- }
- if (f_in == (FILE *)0) {
- as_perror ("Can't open %s for reading", file_name);
- return;
- }
-
-#ifndef HO_VMS
- /* Ask stdio to buffer our input at BUFFER_SIZE, with a dynamically
- allocated buffer. */
- setvbuf(f_in, (char *)NULL, _IOFBF, BUFFER_SIZE);
-#endif /* HO_VMS */
-
- c = getc(f_in);
- if (c == '#') { /* Begins with comment, may not want to preprocess */
- c = getc(f_in);
- if (c == 'N') {
- fgets(buf,80,f_in);
- if (!strcmp(buf,"O_APP\n"))
- preprocess=0;
- if (!strchr(buf,'\n'))
- ungetc('#',f_in); /* It was longer */
- else
- ungetc('\n',f_in);
- } else if (c == '\n')
- ungetc('\n',f_in);
- else
- ungetc('#',f_in);
- } else
- ungetc(c,f_in);
-
-#ifdef DONTDEF
- if ( preprocess ) {
- char temporary_file_name[17];
- FILE *f_out;
-
- (void)strcpy (temporary_file_name, "/tmp/#appXXXXXX");
- (void)mktemp (temporary_file_name);
- f_out=fopen(temporary_file_name,"w+");
- if (f_out == (FILE *)0)
- as_perror("Can't open temp file %s",temporary_file_name);
-
- /* JF this will have to be moved on any system that
- does not support removal of open files. */
- (void)unlink(temporary_file_name);/* JF do it NOW */
- do_scrub(f_in,f_out);
- (void)fclose(f_in); /* All done with it */
- (void)rewind(f_out);
- f_in=f_out;
- }
-#endif
-}
-#endif
-
-/* Close input file. */
-void input_file_close() {
- if (f_in != NULL) {
- fclose (f_in);
- } /* don't close a null file pointer */
- f_in = 0;
-} /* input_file_close() */
-
-char *
- input_file_give_next_buffer (where)
-char * where; /* Where to place 1st character of new buffer. */
-{
- char * return_value; /* -> Last char of what we read, + 1. */
- register int size;
-
- if (f_in == (FILE *)0)
- return 0;
- /*
- * fflush (stdin); could be done here if you want to synchronise
- * stdin and stdout, for the case where our input file is stdin.
- * Since the assembler shouldn't do any output to stdout, we
- * don't bother to synch output and input.
- */
- if (preprocess) {
- char *p;
- int n;
- int ch;
- extern FILE *scrub_file;
-
- scrub_file=f_in;
- for (p = where, n = BUFFER_SIZE; n; --n) {
-
- ch = do_scrub_next_char(scrub_from_file, scrub_to_file);
- if (ch == EOF)
- break;
- *p++=ch;
- }
- size=BUFFER_SIZE-n;
- } else
- size= fread(where,sizeof(char),BUFFER_SIZE,f_in);
- if (size < 0)
- {
- as_perror ("Can't read from %s", file_name);
- size = 0;
- }
- if (size)
- return_value = where + size;
- else
- {
- if (fclose (f_in))
- as_perror ("Can't close %s", file_name);
- f_in = (FILE *)0;
- return_value = 0;
- }
- return (return_value);
-}
-
-/* end of input-file.c */
diff --git a/gnu/usr.bin/as/input-file.h b/gnu/usr.bin/as/input-file.h
deleted file mode 100644
index ce6fcde..0000000
--- a/gnu/usr.bin/as/input-file.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* input_file.h header for input-file.c
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*"input_file.c":Operating-system dependant functions to read source files.*/
-
-/*
- * $Id$
- */
-
-
-/*
- * No matter what the operating system, this module must provide the
- * following services to its callers.
- *
- * input_file_begin() Call once before anything else.
- *
- * input_file_end() Call once after everything else.
- *
- * input_file_buffer_size() Call anytime. Returns largest possible
- * delivery from
- * input_file_give_next_buffer().
- *
- * input_file_open(name) Call once for each input file.
- *
- * input_file_give_next_buffer(where) Call once to get each new buffer.
- * Return 0: no more chars left in file,
- * the file has already been closed.
- * Otherwise: return a pointer to just
- * after the last character we read
- * into the buffer.
- * If we can only read 0 characters, then
- * end-of-file is faked.
- *
- * input_file_push() Push state, which can be restored
- * later. Does implicit input_file_begin.
- * Returns char * to saved state.
- *
- * input_file_pop (arg) Pops previously saved state.
- *
- * input_file_close () Closes opened file.
- *
- * All errors are reported (using as_perror) so caller doesn't have to think
- * about I/O errors. No I/O errors are fatal: an end-of-file may be faked.
- */
-
-#if __STDC__ == 1
-
-char *input_file_give_next_buffer(char *where);
-char *input_file_push(void);
-int input_file_buffer_size(void);
-int input_file_is_open(void);
-void input_file_begin(void);
-void input_file_close(void);
-void input_file_end(void);
-void input_file_open(char *filename, int pre);
-void input_file_pop(char *arg);
-
-#else /* not __STDC__ */
-
-char *input_file_give_next_buffer();
-char *input_file_push();
-int input_file_buffer_size();
-int input_file_is_open();
-void input_file_begin();
-void input_file_close();
-void input_file_end();
-void input_file_open();
-void input_file_pop();
-
-#endif /* not __STDC__ */
-
-/* end of input_file.h */
diff --git a/gnu/usr.bin/as/input-scrub.c b/gnu/usr.bin/as/input-scrub.c
deleted file mode 100644
index 1d7cb23..0000000
--- a/gnu/usr.bin/as/input-scrub.c
+++ /dev/null
@@ -1,420 +0,0 @@
-/* input_scrub.c - Break up input buffers into whole numbers of lines.
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include <errno.h> /* Need this to make errno declaration right */
-#include "as.h"
-#include "input-file.h"
-
-/*
- * O/S independent module to supply buffers of sanitised source code
- * to rest of assembler. We get sanitized input data of arbitrary length.
- * We break these buffers on line boundaries, recombine pieces that
- * were broken across buffers, and return a buffer of full lines to
- * the caller.
- * The last partial line begins the next buffer we build and return to caller.
- * The buffer returned to caller is preceeded by BEFORE_STRING and followed
- * by AFTER_STRING, as sentinels. The last character before AFTER_STRING
- * is a newline.
- * Also looks after line numbers, for e.g. error messages.
- */
-
-/*
- * We don't care how filthy our buffers are, but our callers assume
- * that the following sanitation has already been done.
- *
- * No comments, reduce a comment to a space.
- * Reduce a tab to a space unless it is 1st char of line.
- * All multiple tabs and spaces collapsed into 1 char. Tab only
- * legal if 1st char of line.
- * # line file statements converted to .line x;.file y; statements.
- * Escaped newlines at end of line: remove them but add as many newlines
- * to end of statement as you removed in the middle, to synch line numbers.
- */
-
-#define BEFORE_STRING ("\n")
-#define AFTER_STRING ("\0") /* memcpy of 0 chars might choke. */
-#define BEFORE_SIZE (1)
-#define AFTER_SIZE (1)
-
-static char *buffer_start; /*->1st char of full buffer area. */
-static char *partial_where; /*->after last full line in buffer. */
-static int partial_size; /* >=0. Number of chars in partial line in buffer. */
-static char save_source[AFTER_SIZE];
-/* Because we need AFTER_STRING just after last */
-/* full line, it clobbers 1st part of partial */
-/* line. So we preserve 1st part of partial */
-/* line here. */
-static unsigned int buffer_length; /* What is the largest size buffer that */
-/* input_file_give_next_buffer() could */
-/* return to us? */
-
-/* Saved information about the file that .include'd this one. When we hit EOF,
- we automatically pop to that file. */
-
-static char *next_saved_file;
-
-/* We can have more than one source file open at once, though the info for all
- but the latest one are saved off in a struct input_save. These files remain
- open, so we are limited by the number of open files allowed by the
- underlying OS. We may also sequentially read more than one source file in an
- assembly. */
-
-/* We must track the physical file and line number for error messages. We also
- track a "logical" file and line number corresponding to (C?) compiler
- source line numbers. Whenever we open a file we must fill in
- physical_input_file. So if it is NULL we have not opened any files yet. */
-
-static char *physical_input_file;
-static char *logical_input_file;
-
-typedef unsigned int line_numberT; /* 1-origin line number in a source file. */
-/* A line ends in '\n' or eof. */
-
-static line_numberT physical_input_line;
-static int logical_input_line;
-
-/* Struct used to save the state of the input handler during include files */
-struct input_save
- {
- char *buffer_start;
- char *partial_where;
- int partial_size;
- char save_source[AFTER_SIZE];
- unsigned int buffer_length;
- char *physical_input_file;
- char *logical_input_file;
- line_numberT physical_input_line;
- int logical_input_line;
- char *next_saved_file; /* Chain of input_saves */
- char *input_file_save; /* Saved state of input routines */
- char *saved_position; /* Caller's saved position in buf */
- };
-
-static char *input_scrub_push PARAMS ((char *saved_position));
-static char *input_scrub_pop PARAMS ((char *arg));
-static void as_1_char PARAMS ((unsigned int c, FILE * stream));
-
-/* Push the state of input reading and scrubbing so that we can #include.
- The return value is a 'void *' (fudged for old compilers) to a save
- area, which can be restored by passing it to input_scrub_pop(). */
-static char *
-input_scrub_push (saved_position)
- char *saved_position;
-{
- register struct input_save *saved;
-
- saved = (struct input_save *) xmalloc (sizeof *saved);
-
- saved->saved_position = saved_position;
- saved->buffer_start = buffer_start;
- saved->partial_where = partial_where;
- saved->partial_size = partial_size;
- saved->buffer_length = buffer_length;
- saved->physical_input_file = physical_input_file;
- saved->logical_input_file = logical_input_file;
- saved->physical_input_line = physical_input_line;
- saved->logical_input_line = logical_input_line;
- memcpy (saved->save_source, save_source, sizeof (save_source));
- saved->next_saved_file = next_saved_file;
- saved->input_file_save = input_file_push ();
-
- input_file_begin (); /* Reinitialize! */
- logical_input_line = -1;
- logical_input_file = (char *) NULL;
- buffer_length = input_file_buffer_size ();
-
- buffer_start = xmalloc ((BEFORE_SIZE + buffer_length + buffer_length + AFTER_SIZE));
- memcpy (buffer_start, BEFORE_STRING, (int) BEFORE_SIZE);
-
- return ((char *) saved);
-} /* input_scrub_push() */
-
-static char *
-input_scrub_pop (arg)
- char *arg;
-{
- register struct input_save *saved;
- char *saved_position;
-
- input_scrub_end (); /* Finish off old buffer */
-
- saved = (struct input_save *) arg;
-
- input_file_pop (saved->input_file_save);
- saved_position = saved->saved_position;
- buffer_start = saved->buffer_start;
- buffer_length = saved->buffer_length;
- physical_input_file = saved->physical_input_file;
- logical_input_file = saved->logical_input_file;
- physical_input_line = saved->physical_input_line;
- logical_input_line = saved->logical_input_line;
- partial_where = saved->partial_where;
- partial_size = saved->partial_size;
- next_saved_file = saved->next_saved_file;
- memcpy (save_source, saved->save_source, sizeof (save_source));
-
- free (arg);
- return saved_position;
-}
-
-
-void
-input_scrub_begin ()
-{
- know (strlen (BEFORE_STRING) == BEFORE_SIZE);
- know (strlen (AFTER_STRING) == AFTER_SIZE || (AFTER_STRING[0] == '\0' && AFTER_SIZE == 1));
-
- input_file_begin ();
-
- buffer_length = input_file_buffer_size ();
-
- buffer_start = xmalloc ((BEFORE_SIZE + buffer_length + buffer_length + AFTER_SIZE));
- memcpy (buffer_start, BEFORE_STRING, (int) BEFORE_SIZE);
-
- /* Line number things. */
- logical_input_line = -1;
- logical_input_file = (char *) NULL;
- physical_input_file = NULL; /* No file read yet. */
- next_saved_file = NULL; /* At EOF, don't pop to any other file */
- do_scrub_begin ();
-}
-
-void
-input_scrub_end ()
-{
- if (buffer_start)
- {
- free (buffer_start);
- buffer_start = 0;
- input_file_end ();
- }
-}
-
-/* Start reading input from a new file. */
-
-char * /* Return start of caller's part of buffer. */
-input_scrub_new_file (filename)
- char *filename;
-{
- input_file_open (filename, !flagseen['f']);
- physical_input_file = filename[0] ? filename : "{standard input}";
- physical_input_line = 0;
-
- partial_size = 0;
- return (buffer_start + BEFORE_SIZE);
-}
-
-
-/* Include a file from the current file. Save our state, cause it to
- be restored on EOF, and begin handling a new file. Same result as
- input_scrub_new_file. */
-
-char *
-input_scrub_include_file (filename, position)
- char *filename;
- char *position;
-{
- next_saved_file = input_scrub_push (position);
- return input_scrub_new_file (filename);
-}
-
-void
-input_scrub_close ()
-{
- input_file_close ();
-}
-
-char *
-input_scrub_next_buffer (bufp)
- char **bufp;
-{
- register char *limit; /*->just after last char of buffer. */
-
- *bufp = buffer_start + BEFORE_SIZE;
-
- if (partial_size)
- {
- memcpy (buffer_start + BEFORE_SIZE, partial_where,
- (unsigned int) partial_size);
- memcpy (buffer_start + BEFORE_SIZE, save_source, AFTER_SIZE);
- }
- limit = input_file_give_next_buffer (buffer_start + BEFORE_SIZE + partial_size);
- if (limit)
- {
- register char *p; /* Find last newline. */
-
- for (p = limit; *--p != '\n';);;
- ++p;
- if (p <= buffer_start + BEFORE_SIZE)
- {
- as_fatal ("Source line too long. Please change file %s then rebuild assembler.", __FILE__);
- }
- partial_where = p;
- partial_size = limit - p;
- memcpy (save_source, partial_where, (int) AFTER_SIZE);
- memcpy (partial_where, AFTER_STRING, (int) AFTER_SIZE);
- }
- else
- {
- partial_where = 0;
- if (partial_size > 0)
- {
- as_warn ("Partial line at end of file ignored");
- }
- /* If we should pop to another file at EOF, do it. */
- if (next_saved_file)
- {
- *bufp = input_scrub_pop (next_saved_file); /* Pop state */
- /* partial_where is now correct to return, since we popped it. */
- }
- }
- return (partial_where);
-} /* input_scrub_next_buffer() */
-
-/*
- * The remaining part of this file deals with line numbers, error
- * messages and so on.
- */
-
-
-int
-seen_at_least_1_file () /* TRUE if we opened any file. */
-{
- return (physical_input_file != NULL);
-}
-
-void
-bump_line_counters ()
-{
- ++physical_input_line;
- if (logical_input_line >= 0)
- ++logical_input_line;
-}
-
-/*
- * new_logical_line()
- *
- * Tells us what the new logical line number and file are.
- * If the line_number is -1, we don't change the current logical line
- * number. If it is -2, we decrement the logical line number (this is
- * to support the .appfile pseudo-op inserted into the stream by
- * do_scrub_next_char).
- * If the fname is NULL, we don't change the current logical file name.
- */
-void
-new_logical_line (fname, line_number)
- char *fname; /* DON'T destroy it! We point to it! */
- int line_number;
-{
- if (fname)
- {
- logical_input_file = fname;
- } /* if we have a file name */
-
- if (line_number >= 0)
- logical_input_line = line_number;
- else if (line_number == -2 && logical_input_line > 0)
- --logical_input_line;
-} /* new_logical_line() */
-
-/*
- * a s _ w h e r e ()
- *
- * Return the current file name and line number.
- * namep should be char * const *, but there are compilers which screw
- * up declarations like that, and it's easier to avoid it.
- */
-void
-as_where (namep, linep)
- char **namep;
- unsigned int *linep;
-{
- if (logical_input_file != NULL
- && (linep == NULL || logical_input_line >= 0))
- {
- *namep = logical_input_file;
- if (linep != NULL)
- *linep = logical_input_line;
- }
- else if (physical_input_file != NULL)
- {
- *namep = physical_input_file;
- if (linep != NULL)
- *linep = physical_input_line;
- }
- else
- {
- *namep = (char *) "*unknown*";
- if (linep != NULL)
- *linep = 0;
- }
-} /* as_where() */
-
-
-
-
-/*
- * a s _ h o w m u c h ()
- *
- * Output to given stream how much of line we have scanned so far.
- * Assumes we have scanned up to and including input_line_pointer.
- * No free '\n' at end of line.
- */
-void
-as_howmuch (stream)
- FILE *stream; /* Opened for write please. */
-{
- register char *p; /* Scan input line. */
- /* register char c; JF unused */
-
- for (p = input_line_pointer - 1; *p != '\n'; --p)
- {
- }
- ++p; /* p->1st char of line. */
- for (; p <= input_line_pointer; p++)
- {
- /* Assume ASCII. EBCDIC & other micro-computer char sets ignored. */
- /* c = *p & 0xFF; JF unused */
- as_1_char ((unsigned char) *p, stream);
- }
-}
-
-static void
-as_1_char (c, stream)
- unsigned int c;
- FILE *stream;
-{
- if (c > 127)
- {
- (void) putc ('%', stream);
- c -= 128;
- }
- if (c < 32)
- {
- (void) putc ('^', stream);
- c += '@';
- }
- (void) putc (c, stream);
-}
-
-/* end of input_scrub.c */
diff --git a/gnu/usr.bin/as/link.cmd b/gnu/usr.bin/as/link.cmd
deleted file mode 100644
index a035ca8..0000000
--- a/gnu/usr.bin/as/link.cmd
+++ /dev/null
@@ -1,10 +0,0 @@
-ALIGN=1024
-RESNUM 0x0000, 0x8000
-; Putting in .lit1 gives errors.
-ORDER .data=0x80002000, .data1, .lit, .bss
-; Let's put this on the command line so it goes first, which is what
-; GDB expects.
-; LOAD /s2/amd/29k/lib/crt0.o
-LOAD /s2/amd/29k/lib/libqcb0h.lib
-LOAD /s2/amd/29k/lib/libscb0h.lib
-LOAD /s2/amd/29k/lib/libacb0h.lib
diff --git a/gnu/usr.bin/as/listing.c b/gnu/usr.bin/as/listing.c
deleted file mode 100644
index 8cfba4b..0000000
--- a/gnu/usr.bin/as/listing.c
+++ /dev/null
@@ -1,1079 +0,0 @@
-/* listing.c - mainting assembly listings
- Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of GAS, the GNU Assembler.
-
-GAS 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.
-
-GAS 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 GAS; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- Contributed by Steve Chamberlain
- sac@cygnus.com
-
-
- A listing page looks like:
-
- LISTING_HEADER sourcefilename pagenumber
- TITLE LINE
- SUBTITLE LINE
- linenumber address data source
- linenumber address data source
- linenumber address data source
- linenumber address data source
-
- If not overridden, the listing commands are:
-
- .title "stuff"
- Put "stuff" onto the title line
- .sbttl "stuff"
- Put stuff onto the subtitle line
-
- If these commands come within 10 lines of the top of the page, they
- will affect the page they are on, as well as any subsequent page
-
- .eject
- Thow a page
- .list
- Increment the enable listing counter
- .nolist
- Decrement the enable listing counter
-
- .psize Y[,X]
- Set the paper size to X wide and Y high. Setting a psize Y of
- zero will suppress form feeds except where demanded by .eject
-
- If the counter goes below zero, listing is suppressed.
-
-
- Listings are a maintained by read calling various listing_<foo>
- functions. What happens most is that the macro NO_LISTING is not
- defined (from the Makefile), then the macro LISTING_NEWLINE expands
- into a call to listing_newline. The call is done from read.c, every
- time it sees a newline, and -l is on the command line.
-
- The function listing_newline remembers the frag associated with the
- newline, and creates a new frag - note that this is wasteful, but not
- a big deal, since listing slows things down a lot anyway. The
- function also rememebers when the filename changes.
-
- When all the input has finished, and gas has had a chance to settle
- down, the listing is output. This is done by running down the list of
- frag/source file records, and opening the files as needed and printing
- out the bytes and chars associated with them.
-
- The only things which the architecture can change about the listing
- are defined in these macros:
-
- LISTING_HEADER The name of the architecture
- LISTING_WORD_SIZE The make of the number of bytes in a word, this determines
- the clumping of the output data. eg a value of
- 2 makes words look like 1234 5678, whilst 1
- would make the same value look like 12 34 56
- 78
- LISTING_LHS_WIDTH Number of words of above size for the lhs
-
- LISTING_LHS_WIDTH_SECOND Number of words for the data on the lhs
- for the second line
-
- LISTING_LHS_CONT_LINES Max number of lines to use up for a continutation
- LISTING_RHS_WIDTH Number of chars from the input file to print
- on a line
-*/
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-
-#include "as.h"
-#include <obstack.h>
-#include "input-file.h"
-#include "subsegs.h"
-
-#ifndef NO_LISTING
-#ifndef LISTING_HEADER
-#define LISTING_HEADER "GAS LISTING"
-#endif
-#ifndef LISTING_WORD_SIZE
-#define LISTING_WORD_SIZE 4
-#endif
-#ifndef LISTING_LHS_WIDTH
-#define LISTING_LHS_WIDTH 1
-#endif
-#ifndef LISTING_LHS_WIDTH_SECOND
-#define LISTING_LHS_WIDTH_SECOND 1
-#endif
-#ifndef LISTING_RHS_WIDTH
-#define LISTING_RHS_WIDTH 100
-#endif
-#ifndef LISTING_LHS_CONT_LINES
-#define LISTING_LHS_CONT_LINES 4
-#endif
-
-
-
-
-static struct list_info_struct *head;
-struct list_info_struct *listing_tail;
-extern int listing;
-extern fragS *frag_now;
-
-
-static int paper_width = 200;
-static int paper_height = 60;
-
-
-/* this static array is used to keep the text of data to be printed
- before the start of the line.
- It is stored so we can give a bit more info on the next line. To much, and large
- initialized arrays will use up lots of paper.
- */
-
-static char data_buffer[100];
-static unsigned int data_buffer_size;
-
-
-/* Prototypes. */
-static void listing_message PARAMS ((const char *name, const char *message));
-static file_info_type *file_info PARAMS ((const char *file_name));
-static void new_frag PARAMS ((void));
-static char *buffer_line PARAMS ((file_info_type *file,
- char *line, unsigned int size));
-static void listing_page PARAMS ((list_info_type *list));
-static unsigned int calc_hex PARAMS ((list_info_type *list));
-static void print_lines PARAMS ((list_info_type *list,
- char *string,
- unsigned int address));
-static void list_symbol_table PARAMS ((void));
-static void print_source PARAMS ((file_info_type *current_file,
- list_info_type *list,
- char *buffer,
- unsigned int width));
-static int debugging_pseudo PARAMS ((char *line));
-static void listing_listing PARAMS ((char *name));
-
-
-static void
-listing_message (name, message)
- const char *name;
- const char *message;
-{
- unsigned int l = strlen (name) + strlen (message) + 1;
- char *n = (char *) xmalloc (l);
- strcpy (n, name);
- strcat (n, message);
- if (listing_tail != (list_info_type *) NULL)
- {
- listing_tail->message = n;
- }
-}
-
-void
-listing_warning (message)
- const char *message;
-{
- listing_message ("Warning:", message);
-}
-
-void
-listing_error (message)
- const char *message;
-{
- listing_message ("Error:", message);
-}
-
-
-
-
-static file_info_type *file_info_head;
-
-static file_info_type *
-file_info (file_name)
- const char *file_name;
-{
- /* Find an entry with this file name */
- file_info_type *p = file_info_head;
-
- while (p != (file_info_type *) NULL)
- {
- if (strcmp (p->filename, file_name) == 0)
- return p;
- p = p->next;
- }
-
- /* Make new entry */
-
- p = (file_info_type *) xmalloc (sizeof (file_info_type));
- p->next = file_info_head;
- file_info_head = p;
- p->filename = xmalloc ((unsigned long) strlen (file_name) + 1);
- strcpy (p->filename, file_name);
- p->linenum = 0;
- p->end_pending = 0;
-
- /* Do we really prefer binary mode for this?? */
-#define FOPEN_RB "r"
- p->file = fopen (p->filename, FOPEN_RB);
- if (p->file)
- fgetc (p->file);
-
- return p;
-}
-
-
-static void
-new_frag ()
-{
-
- frag_wane (frag_now);
- frag_new (0);
-
-}
-
-void
-listing_newline (ps)
- char *ps;
-{
- char *file;
- unsigned int line;
- static unsigned int last_line = 0xffff;
- static char *last_file = NULL;
- list_info_type *new;
-
- as_where (&file, &line);
- if (line != last_line || last_file && file && strcmp(file, last_file))
- {
- last_line = line;
- last_file = file;
- new_frag ();
-
- new = (list_info_type *) xmalloc (sizeof (list_info_type));
- new->frag = frag_now;
- new->line = line;
- new->file = file_info (file);
-
- if (listing_tail)
- {
- listing_tail->next = new;
- }
- else
- {
- head = new;
- }
- listing_tail = new;
- new->next = (list_info_type *) NULL;
- new->message = (char *) NULL;
- new->edict = EDICT_NONE;
- new->hll_file = (file_info_type *) NULL;
- new->hll_line = 0;
- new_frag ();
- }
-}
-
-/* Attach all current frags to the previous line instead of the
- current line. This is called by the MIPS backend when it discovers
- that it needs to add some NOP instructions; the added NOP
- instructions should go with the instruction that has the delay, not
- with the new instruction. */
-
-void
-listing_prev_line ()
-{
- list_info_type *l;
- fragS *f;
-
- if (head == (list_info_type *) NULL
- || head == listing_tail)
- return;
-
- new_frag ();
-
- for (l = head; l->next != listing_tail; l = l->next)
- ;
-
- for (f = frchain_now->frch_root; f != (fragS *) NULL; f = f->fr_next)
- if (f->line == listing_tail)
- f->line = l;
-
- listing_tail->frag = frag_now;
- new_frag ();
-}
-
-/*
- This function returns the next source line from the file supplied,
- truncated to size. It appends a fake line to the end of each input
- file to make
-*/
-
-static char *
-buffer_line (file, line, size)
- file_info_type * file;
- char *line;
- unsigned int size;
-{
- unsigned int count = 0;
- int c;
-
- char *p = line;
-
- /* If we couldn't open the file, return an empty line */
- if (file->file == (FILE *) NULL)
- {
- return "";
- }
-
- if (file->linenum == 0)
- rewind (file->file);
-
- if (file->end_pending == 10)
- {
- *p++ = '\n';
- fseek (file->file, 0, 0);
- file->linenum = 0;
- file->end_pending = 0;
- }
- c = fgetc (file->file);
-
-
- size -= 1; /* leave room for null */
-
- while (c != EOF && c != '\n')
- {
- if (count < size)
- *p++ = c;
- count++;
-
- c = fgetc (file->file);
-
- }
- if (c == EOF)
- {
- file->end_pending++;
- *p++ = '.';
- *p++ = '.';
- *p++ = '.';
- }
- file->linenum++;
- *p++ = 0;
- return line;
-}
-
-
-static const char *fn;
-
-static unsigned int eject; /* Eject pending */
-static unsigned int page; /* Current page number */
-static char *title; /* current title */
-static char *subtitle; /* current subtitle */
-static unsigned int on_page; /* number of lines printed on current page */
-
-
-static void
-listing_page (list)
- list_info_type *list;
-{
- /* Grope around, see if we can see a title or subtitle edict coming up
- soon (we look down 10 lines of the page and see if it's there)*/
- if ((eject || (on_page >= paper_height)) && paper_height != 0)
- {
- unsigned int c = 10;
- int had_title = 0;
- int had_subtitle = 0;
-
- page++;
-
- while (c != 0 && list)
- {
- if (list->edict == EDICT_SBTTL && !had_subtitle)
- {
- had_subtitle = 1;
- subtitle = list->edict_arg;
- }
- if (list->edict == EDICT_TITLE && !had_title)
- {
- had_title = 1;
- title = list->edict_arg;
- }
- list = list->next;
- c--;
- }
-
-
- if (page > 1)
- {
- printf ("\f");
- }
-
- printf ("%s %s \t\t\tpage %d\n", LISTING_HEADER, fn, page);
- printf ("%s\n", title);
- printf ("%s\n", subtitle);
- on_page = 3;
- eject = 0;
- }
-}
-
-
-static unsigned int
-calc_hex (list)
- list_info_type * list;
-{
- list_info_type *first = list;
- unsigned int address = (unsigned int) ~0;
-
- fragS *frag;
- fragS *frag_ptr;
-
- unsigned int byte_in_frag;
-
-
- /* Find first frag which says it belongs to this line */
- frag = list->frag;
- while (frag && frag->line != list)
- frag = frag->fr_next;
-
- frag_ptr = frag;
-
- data_buffer_size = 0;
-
- /* Dump all the frags which belong to this line */
- while (frag_ptr != (fragS *) NULL && frag_ptr->line == first)
- {
- /* Print as many bytes from the fixed part as is sensible */
- byte_in_frag = 0;
- while (byte_in_frag < frag_ptr->fr_fix && data_buffer_size < sizeof (data_buffer) - 10)
- {
- if (address == ~0)
- {
- address = frag_ptr->fr_address;
- }
-
- sprintf (data_buffer + data_buffer_size,
- "%02X",
- (frag_ptr->fr_literal[byte_in_frag]) & 0xff);
- data_buffer_size += 2;
- byte_in_frag++;
- }
- {
- unsigned int var_rep_max = byte_in_frag;
- unsigned int var_rep_idx = byte_in_frag;
-
- /* Print as many bytes from the variable part as is sensible */
- while (byte_in_frag < frag_ptr->fr_var * frag_ptr->fr_offset
- && data_buffer_size < sizeof (data_buffer) - 10)
- {
- if (address == ~0)
- {
- address = frag_ptr->fr_address;
- }
- sprintf (data_buffer + data_buffer_size,
- "%02X",
- (frag_ptr->fr_literal[var_rep_idx]) & 0xff);
-#if 0
- data_buffer[data_buffer_size++] = '*';
- data_buffer[data_buffer_size++] = '*';
-#endif
- data_buffer_size += 2;
-
- var_rep_idx++;
- byte_in_frag++;
-
- if (var_rep_idx >= frag_ptr->fr_var)
- var_rep_idx = var_rep_max;
- }
- }
-
- frag_ptr = frag_ptr->fr_next;
- }
- data_buffer[data_buffer_size++] = 0;
- return address;
-}
-
-
-
-
-
-
-static void
-print_lines (list, string, address)
- list_info_type *list;
- char *string;
- unsigned int address;
-{
- unsigned int idx;
- unsigned int nchars;
- unsigned int lines;
- unsigned int byte_in_word = 0;
- char *src = data_buffer;
-
- /* Print the stuff on the first line */
- listing_page (list);
- nchars = (LISTING_WORD_SIZE * 2 + 1) * LISTING_LHS_WIDTH;
- /* Print the hex for the first line */
- if (address == ~0)
- {
- printf ("% 4d ", list->line);
- for (idx = 0; idx < nchars; idx++)
- printf (" ");
-
- printf ("\t%s\n", string ? string : "");
- on_page++;
- listing_page (0);
-
- }
- else
- {
- if (had_errors ())
- {
- printf ("% 4d ???? ", list->line);
- }
- else
- {
- printf ("% 4d %04x ", list->line, address);
- }
-
- /* And the data to go along with it */
- idx = 0;
-
- while (*src && idx < nchars)
- {
- printf ("%c%c", src[0], src[1]);
- src += 2;
- byte_in_word++;
- if (byte_in_word == LISTING_WORD_SIZE)
- {
- printf (" ");
- idx++;
- byte_in_word = 0;
- }
- idx += 2;
- }
-
- for (; idx < nchars; idx++)
- printf (" ");
-
- printf ("\t%s\n", string ? string : "");
- on_page++;
- listing_page (list);
- if (list->message)
- {
- printf ("**** %s\n", list->message);
- listing_page (list);
- on_page++;
- }
-
- for (lines = 0;
- lines < LISTING_LHS_CONT_LINES
- && *src;
- lines++)
- {
- nchars = ((LISTING_WORD_SIZE * 2) + 1) * LISTING_LHS_WIDTH_SECOND - 1;
- idx = 0;
- /* Print any more lines of data, but more compactly */
- printf ("% 4d ", list->line);
-
- while (*src && idx < nchars)
- {
- printf ("%c%c", src[0], src[1]);
- src += 2;
- idx += 2;
- byte_in_word++;
- if (byte_in_word == LISTING_WORD_SIZE)
- {
- printf (" ");
- idx++;
- byte_in_word = 0;
- }
- }
-
- printf ("\n");
- on_page++;
- listing_page (list);
-
- }
-
-
- }
-}
-
-
-static void
-list_symbol_table ()
-{
- extern symbolS *symbol_rootP;
- int got_some = 0;
-
- symbolS *ptr;
- eject = 1;
- listing_page (0);
-
- for (ptr = symbol_rootP; ptr != (symbolS *) NULL; ptr = symbol_next (ptr))
- {
- if (ptr->sy_frag->line)
- {
- if (S_GET_NAME (ptr))
- {
- char buf[30];
- valueT val = S_GET_VALUE (ptr);
-
- /* @@ Note that this is dependent on the compilation options,
- not solely on the target characteristics. */
- if (sizeof (val) == 4 && sizeof (int) == 4)
- sprintf (buf, "%08lx", (unsigned long) val);
-#if defined (BFD64)
- else if (sizeof (val) > 4)
- {
- char buf1[30];
- sprintf_vma (buf1, val);
- strcpy (buf, "00000000");
- strcpy (buf + 8 - strlen (buf1), buf1);
- }
-#endif
- else
- abort ();
-
- if (!got_some)
- {
- printf ("DEFINED SYMBOLS\n");
- on_page++;
- got_some = 1;
- }
-
- printf ("%20s:%-5d %s:%s %s\n",
- ptr->sy_frag->line->file->filename,
- ptr->sy_frag->line->line,
- segment_name (S_GET_SEGMENT (ptr)),
- buf, S_GET_NAME (ptr));
-
- on_page++;
- listing_page (0);
- }
- }
-
- }
- if (!got_some)
- {
- printf ("NO DEFINED SYMBOLS\n");
- on_page++;
- }
- printf ("\n");
- on_page++;
- listing_page (0);
-
- got_some = 0;
-
- for (ptr = symbol_rootP; ptr != (symbolS *) NULL; ptr = symbol_next (ptr))
- {
- if (S_GET_NAME (ptr) && strlen (S_GET_NAME (ptr)) != 0)
- {
- if (ptr->sy_frag->line == 0
-#ifdef notyet
- && S_GET_SEGMENT (ptr) != reg_section)
-#else
- && !S_IS_REGISTER(ptr))
-#endif
- {
- if (!got_some)
- {
- got_some = 1;
- printf ("UNDEFINED SYMBOLS\n");
- on_page++;
- listing_page (0);
- }
- printf ("%s\n", S_GET_NAME (ptr));
- on_page++;
- listing_page (0);
- }
- }
- }
- if (!got_some)
- {
- printf ("NO UNDEFINED SYMBOLS\n");
- on_page++;
- listing_page (0);
- }
-}
-
-static void
-print_source (current_file, list, buffer, width)
- file_info_type *current_file;
- list_info_type *list;
- char *buffer;
- unsigned int width;
-{
- if (current_file->file)
- {
- while (current_file->linenum < list->hll_line)
- {
- char *p = buffer_line (current_file, buffer, width);
- printf ("%4d:%-13s **** %s\n", current_file->linenum, current_file->filename, p);
- on_page++;
- listing_page (list);
- }
- }
-}
-
-/* Sometimes the user doesn't want to be bothered by the debugging
- records inserted by the compiler, see if the line is suspicious */
-
-static int
-debugging_pseudo (line)
- char *line;
-{
- while (isspace (*line))
- line++;
-
- if (*line != '.')
- return 0;
-
- line++;
-
- if (strncmp (line, "def", 3) == 0)
- return 1;
- if (strncmp (line, "val", 3) == 0)
- return 1;
- if (strncmp (line, "scl", 3) == 0)
- return 1;
- if (strncmp (line, "line", 4) == 0)
- return 1;
- if (strncmp (line, "endef", 5) == 0)
- return 1;
- if (strncmp (line, "ln", 2) == 0)
- return 1;
- if (strncmp (line, "type", 4) == 0)
- return 1;
- if (strncmp (line, "size", 4) == 0)
- return 1;
- if (strncmp (line, "dim", 3) == 0)
- return 1;
- if (strncmp (line, "tag", 3) == 0)
- return 1;
-
- if (strncmp (line, "stabs", 5) == 0)
- return 1;
- if (strncmp (line, "stabn", 5) == 0)
- return 1;
-
- return 0;
-
-}
-
-static void
-listing_listing (name)
- char *name;
-{
- list_info_type *list = head;
- file_info_type *current_hll_file = (file_info_type *) NULL;
- char *message;
- char *buffer;
- char *p;
- int show_listing = 1;
- unsigned int width;
-
- buffer = xmalloc (LISTING_RHS_WIDTH);
- eject = 1;
- list = head;
-
- while (list != (list_info_type *) NULL && 0)
- {
- if (list->next)
- list->frag = list->next->frag;
- list = list->next;
-
- }
-
- list = head->next;
-
-
- while (list)
- {
- width = LISTING_RHS_WIDTH > paper_width ? paper_width :
- LISTING_RHS_WIDTH;
-
- switch (list->edict)
- {
- case EDICT_LIST:
- show_listing++;
- break;
- case EDICT_NOLIST:
- show_listing--;
- break;
- case EDICT_EJECT:
- break;
- case EDICT_NONE:
- break;
- case EDICT_TITLE:
- title = list->edict_arg;
- break;
- case EDICT_SBTTL:
- subtitle = list->edict_arg;
- break;
- default:
- abort ();
- }
-
- if (show_listing > 0)
- {
- /* Scan down the list and print all the stuff which can be done
- with this line (or lines). */
- message = 0;
-
- if (list->hll_file)
- {
- current_hll_file = list->hll_file;
- }
-
- if (current_hll_file && list->hll_line && listing & LISTING_HLL)
- {
- print_source (current_hll_file, list, buffer, width);
- }
-
- while (list->file->file &&
- list->file->linenum < list->line && !list->file->end_pending) {
- p = buffer_line (list->file, buffer, width);
-
- if (!((listing & LISTING_NODEBUG) && debugging_pseudo (p)))
- {
- print_lines (list, p, calc_hex (list));
- }
- }
-
- if (list->edict == EDICT_EJECT)
- {
- eject = 1;
- }
- }
- else
- {
-
- while (list->file->file &&
- list->file->linenum < list->line && !list->file->end_pending)
- p = buffer_line (list->file, buffer, width);
- }
-
- list = list->next;
- }
- free (buffer);
-}
-
-void
-listing_print (name)
- char *name;
-{
- title = "";
- subtitle = "";
-
- if (listing & LISTING_NOFORM)
- {
- paper_height = 0;
- }
-
- if (listing & LISTING_LISTING)
- {
- listing_listing (name);
-
- }
- if (listing & LISTING_SYMBOLS)
- {
- list_symbol_table ();
- }
-}
-
-
-void
-listing_file (name)
- const char *name;
-{
- fn = name;
-}
-
-void
-listing_eject (ignore)
- int ignore;
-{
- listing_tail->edict = EDICT_EJECT;
-}
-
-void
-listing_flags (ignore)
- int ignore;
-{
- while ((*input_line_pointer++) && (*input_line_pointer != '\n'))
- input_line_pointer++;
-
-}
-
-void
-listing_list (on)
- int on;
-{
- listing_tail->edict = on ? EDICT_LIST : EDICT_NOLIST;
-}
-
-
-void
-listing_psize (ignore)
- int ignore;
-{
- paper_height = get_absolute_expression ();
-
- if (paper_height < 0 || paper_height > 1000)
- {
- paper_height = 0;
- as_warn ("strange paper height, set to no form");
- }
- if (*input_line_pointer == ',')
- {
- input_line_pointer++;
- paper_width = get_absolute_expression ();
- }
-}
-
-
-void
-listing_title (depth)
- int depth;
-{
- char *start;
- char *ttl;
- unsigned int length;
-
- SKIP_WHITESPACE ();
- if (*input_line_pointer == '\"')
- {
- input_line_pointer++;
- start = input_line_pointer;
-
- while (*input_line_pointer)
- {
- if (*input_line_pointer == '\"')
- {
- length = input_line_pointer - start;
- ttl = xmalloc (length + 1);
- memcpy (ttl, start, length);
- ttl[length] = 0;
- listing_tail->edict = depth ? EDICT_SBTTL : EDICT_TITLE;
- listing_tail->edict_arg = ttl;
- input_line_pointer++;
- demand_empty_rest_of_line ();
- return;
- }
- else if (*input_line_pointer == '\n')
- {
- as_bad ("New line in title");
- demand_empty_rest_of_line ();
- return;
- }
- else
- {
- input_line_pointer++;
- }
- }
- }
- else
- {
- as_bad ("expecting title in quotes");
- }
-}
-
-
-
-void
-listing_source_line (line)
- unsigned int line;
-{
- new_frag ();
- listing_tail->hll_line = line;
- new_frag ();
-
-}
-
-void
-listing_source_file (file)
- const char *file;
-{
- if (listing_tail)
- listing_tail->hll_file = file_info (file);
-}
-
-
-
-#else
-
-
-/* Dummy functions for when compiled without listing enabled */
-
-void
-listing_flags (ignore)
- int ignore;
-{
- s_ignore (0);
-}
-
-void
-listing_list (on)
- int on;
-{
- s_ignore (0);
-}
-
-void
-listing_eject (ignore)
- int ignore;
-{
- s_ignore (0);
-}
-
-void
-listing_psize (ignore)
- int ignore;
-{
- s_ignore (0);
-}
-
-void
-listing_title (depth)
- int depth;
-{
- s_ignore (0);
-}
-
-void
-listing_file (name)
- const char *name;
-{
-
-}
-
-void
-listing_newline (name)
- char *name;
-{
-
-}
-
-void
-listing_source_line (n)
- unsigned int n;
-{
-
-}
-void
-listing_source_file (n)
- const char *n;
-{
-
-}
-
-#endif
diff --git a/gnu/usr.bin/as/listing.h b/gnu/usr.bin/as/listing.h
deleted file mode 100644
index 1e14440..0000000
--- a/gnu/usr.bin/as/listing.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* This file is listing.h
- Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * $Id$
- */
-
-#ifndef __listing_h__
-#define __listing_h__
-
-#define LISTING_LISTING 1
-#define LISTING_SYMBOLS 2
-#define LISTING_NOFORM 4
-#define LISTING_HLL 8
-#define LISTING_NODEBUG 16
-
-#define LISTING_DEFAULT (LISTING_LISTING | LISTING_HLL | LISTING_SYMBOLS)
-
-#ifndef NO_LISTING
-#define LISTING_NEWLINE() { if (listing) listing_newline(input_line_pointer); }
-#else
-#define LISTING_NEWLINE() {;}
-#endif
-
-
-/* This structure remembers which .s were used */
-typedef struct file_info_struct
-{
- char *filename;
- int linenum;
- FILE *file;
- struct file_info_struct *next;
- int end_pending;
-
-}
-
-file_info_type;
-
-
-/* this structure rememebrs which line from which file goes into which
- frag */
-typedef struct list_info_struct
-{
- /* Frag which this line of source is nearest to */
- fragS *frag;
- /* The actual line in the source file */
- unsigned int line;
- /* Pointer to the file info struct for the file which this line
- belongs to */
- file_info_type *file;
-
- /* Next in list */
- struct list_info_struct *next;
-
-
- /* Pointer to the file info struct for the high level language
- source line that belongs here */
- file_info_type *hll_file;
-
- /* High level language source line */
- int hll_line;
-
-
- /* Pointer to any error message associated with this line */
- char *message;
-
- enum
- {
- EDICT_NONE,
- EDICT_SBTTL,
- EDICT_TITLE,
- EDICT_NOLIST,
- EDICT_LIST,
- EDICT_EJECT
- } edict;
- char *edict_arg;
-
-}
-
-list_info_type;
-
-void listing_eject PARAMS ((int));
-void listing_error PARAMS ((const char *message));
-void listing_file PARAMS ((const char *name));
-void listing_flags PARAMS ((int));
-void listing_list PARAMS ((int on));
-void listing_newline PARAMS ((char *ps));
-void listing_prev_line PARAMS ((void));
-void listing_print PARAMS ((char *name));
-void listing_psize PARAMS ((int));
-void listing_source_file PARAMS ((const char *));
-void listing_source_line PARAMS ((unsigned int));
-void listing_title PARAMS ((int depth));
-void listing_warning PARAMS ((const char *message));
-void listing_width PARAMS ((unsigned int x));
-
-#endif /* __listing_h__ */
-
-/* end of listing.h */
diff --git a/gnu/usr.bin/as/make-gas.com b/gnu/usr.bin/as/make-gas.com
deleted file mode 100644
index cb3064d..0000000
--- a/gnu/usr.bin/as/make-gas.com
+++ /dev/null
@@ -1,86 +0,0 @@
-$! Set the def dir to proper place for use in batch. Works for interactive to.
-$flnm = f$enviroment("PROCEDURE") ! get current procedure name
-$set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
-$!
-$! Command file to build a GNU assembler on VMS
-$!
-$! If you are using a version of GCC that supports global constants
-$! you should remove the define="const=" from the gcc lines.
-$!
-$! Caution: Versions 1.38.1 and earlier had a bug in the handling of
-$! some static constants. If you are using such a version of the
-$! assembler, and you wish to compile without the "const=" hack,
-$! you should first build this version *with* the "const="
-$! definition, and then use that assembler to rebuild it without the
-$! "const=" definition. Failure to do this will result in an assembler
-$! that will mung floating point constants.
-$!
-$! Note: The version of gas shipped on the GCC VMS tapes has been patched
-$! to fix the above mentioned bug.
-$!
-$ write sys$output "If this assembler is going to be used with GCC 1.n, you"
-$ write sys$Output "need to modify the driver to supply the -1 switch to gas."
-$ write sys$output "This is required because of a small change in how global"
-$ write sys$Output "constant variables are handled. Failure to include this"
-$ write sys$output "will result in linker warning messages about mismatched
-$ write sys$output "psect attributes."
-$!
-$ C_DEFS :="""VMS"""
-$! C_DEFS :="""VMS""","""const="""
-$ C_INCLUDES :=/include=([],[.config],[-.include])
-$ C_FLAGS := /debug 'c_includes'
-$!
-$!
-$ if "''p1'" .eqs. "LINK" then goto Link
-$!
-$! This helps gcc 1.nn find the aout/* files.
-$!
-$ aout_dev = f$parse(flnm,,,"DEVICE")
-$ tmp = aout_dev - ":"
-$if f$trnlnm(tmp).nes."" then aout_dev = f$trnlnm(tmp)
-$ aout_dir = aout_dev+f$parse(flnm,,,"DIRECTORY")' -
- - "GAS]" + "INCLUDE.AOUT.]" - "]["
-$assign 'aout_dir' aout/tran=conc
-$ opcode_dir = aout_dev+f$parse(flnm,,,"DIRECTORY")' -
- - "GAS]" + "INCLUDE.OPCODE.]" - "]["
-$assign 'opcode_dir' opcode/tran=conc
-$!
-$ gcc 'c_flags'/define=('C_DEFS') as.c
-$ gcc 'c_flags'/define=("error=as_fatal",'C_DEFS') xrealloc.c
-$ gcc 'c_flags'/define=("error=as_fatal",'C_DEFS') xmalloc.c
-$ gcc 'c_flags'/define=("error=as_fatal",'C_DEFS') hash.c
-$ gcc 'c_flags'/define=('C_DEFS') obstack.c
-$ gcc 'c_flags'/define=('C_DEFS') hex-value.c
-$ gcc 'c_flags'/define=('C_DEFS') messages.c
-$ gcc 'c_flags'/define=('C_DEFS') atof-generic.c
-$ gcc 'c_flags'/define=('C_DEFS') expr.c
-$ gcc 'c_flags'/define=('C_DEFS') cond.c
-$ gcc 'c_flags'/define=('C_DEFS') app.c
-$ gcc 'c_flags'/define=('C_DEFS') frags.c
-$ gcc 'c_flags'/define=('C_DEFS') input-file.c
-$ gcc 'c_flags'/define=('C_DEFS') input-scrub.c
-$ gcc 'c_flags'/define=('C_DEFS') output-file.c
-$ gcc 'c_flags'/define=('C_DEFS') read.c
-$ gcc 'c_flags'/define=('C_DEFS') subsegs.c
-$ gcc 'c_flags'/define=('C_DEFS') symbols.c
-$ gcc 'c_flags'/define=('C_DEFS') write.c
-$ gcc 'c_flags'/define=('C_DEFS') version.c
-$ gcc 'c_flags'/define=('C_DEFS') flonum-const.c
-$ gcc 'c_flags'/define=('C_DEFS') flonum-copy.c
-$ gcc 'c_flags'/define=('C_DEFS') flonum-mult.c
-$ gcc 'c_flags'/define=('C_DEFS') strstr.c
-$ gcc 'c_flags'/define=('C_DEFS') bignum-copy.c
-$ gcc 'c_flags'/define=('C_DEFS') listing.c
-$ gcc 'c_flags'/define=('C_DEFS') atof-targ.c
-$ gcc 'c_flags'/define=("error=as_fatal",'C_DEFS') targ-cpu.c
-$ gcc 'c_flags'/define=("error=as_fatal",'C_DEFS') obj-format.c
-$ Link:
-$ link/nomap/exec=gcc-as version.opt/opt+sys$input:/opt
-!
-! Linker options file for GNU assembler
-!
-as,xrealloc,xmalloc,hash,hex-value,atof-generic,messages,expr,app,cond,-
-frags,input-file,input-scrub,output-file,read,subsegs,symbols,write,-
-version,flonum-const,flonum-copy,flonum-mult,strstr,bignum-copy,listing,-
-obstack,targ-cpu,atof-targ,obj-format,-
-gnu_cc:[000000]gcclib/lib,sys$share:vaxcrtl/lib
diff --git a/gnu/usr.bin/as/makefile.dos b/gnu/usr.bin/as/makefile.dos
deleted file mode 100644
index c146e19..0000000
--- a/gnu/usr.bin/as/makefile.dos
+++ /dev/null
@@ -1,593 +0,0 @@
-# Makefile for GNU Assembler
-# Copyright (C) 1987, 1988, 1990, 1991 Free Software Foundation, Inc.
-
-#This file is part of GNU GAS.
-
-#GNU GAS is free software; you can redistribute it and/or modify
-#it under the terms of the GNU General Public License as published by
-#the Free Software Foundation; either version 1, or (at your option)
-#any later version.
-
-#GNU GAS 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 GNU GAS; see the file COPYING. If not, write to
-#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-# $Id$
-
-# The targets for external use include:
-# all, doc, proto, install, uninstall, includes, TAGS,
-# clean, cleanconfig, realclean, stage1, stage2, stage3, stage4.
-
-# Variables that exist for you to override.
-# See below for how to change them for certain systems.
-
-LIBDEPS=
-CROSS=
-HDEFINES=
-CPPFLAGS=
-
-ALLOCA =
-CFLAGS = -g -D__MSDOS__ -D__GO32__ -I../include
-INTERNAL_CFLAGS = $(CROSS)
-OLDCC = cc
-BISON = bison
-BISONFLAGS = -v
-AR = ar
-OLDAR_FLAGS = qc
-AR_FLAGS = rc
-SHELL = /bin/sh
-# on sysV, define this as cp.
-INSTALL = install -c
-# These permit overriding just for certain files.
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_FILE = $(INSTALL)
-
-# Define this as & to perform parallel make on a Sequent.
-# Note that this has some bugs, and it seems currently necessary
-# to compile all the gen* files first by hand to avoid erroneous results.
-P =
-
-# How to invoke ranlib.
-RANLIB = ranlib
-# Test to use to see whether ranlib exists on the system.
-RANLIB_TEST = [ -f /usr/bin/ranlib -o -f /bin/ranlib ]
-
-# CFLAGS for use with OLDCC, for compiling gnulib.
-# NOTE: -O does not work on some Unix systems!
-CCLIBFLAGS = -O
-
-# Version of ar to use when compiling gnulib.
-OLDAR = ar
-
-version=`$(unsubdir)/../gcc$(subdir)/gcc -dumpversion`
-
-# Directory where sources are, from where we are.
-srcdir = .
-# Common prefix for installation directories.
-# NOTE: This directory must exist when you start installation.
-ddestdir = /usr/local
-# Directory in which to put the executable for the command `gcc'
-bindir = $(ddestdir)/bin
-# Directory in which to put the directories used by the compiler.
-libdir = $(ddestdir)/lib
-# Directory in which the compiler finds executables, libraries, etc.
-libsubdir = $(libdir)/gcc/$(target_alias)/$(version)
-# Number to put in man-page filename.
-manext = 1
-# Directory in which to put man pages.
-mandir = $(destdir)/H-independent/man/man$(manext)
-
-# Additional system libraries to link with.
-CLIB=
-
-# Specify the rule for actually making gnulib.
-GNULIB = gnulib.portable
-
-# Specify the rule for actually making gnulib2.
-GNULIB2 = gnulib2.portable
-
-# List of extra C and assembler files to add to gnulib.
-# Assembler files should have names ending in `.asm'.
-LIBFUNCS_EXTRA =
-
-# Program to convert libraries.
-LIBCONVERT =
-
-# Control whether header files are installed.
-INSTALL_HEADERS=install-headers
-
-# Change this to empty to prevent installing limits.h
-LIMITS_H = limits.h
-
-# Directory to link to, when using the target `maketest'.
-DIR = ../gcc
-
-# For better debugging under COFF, define SEPARATE_AUX_OUTPUT in config.h
-# and define the following variable as `aux-output2.c' in make-...
-AUX_OUTPUT2 =
-
-# Flags to use when cross-building GCC.
-# Prefix to apply to names of object files when using them
-# to run on the machine we are compiling on.
-HOST_PREFIX=
-# Prefix to apply to names of object files when compiling them
-# to run on the machine we are compiling on.
-# The default for this variable is chosen to keep these rules
-# out of the way of the other rules for compiling the same source files.
-HOST_PREFIX_1=loser-
-HOST_CC=$(CC)
-HOST_CFLAGS=$(ALL_CFLAGS)
-HOST_LDFLAGS=$(LDFLAGS)
-HOST_CPPFLAGS=$(CPPFLAGS)
-
-# Choose the real default target.
-ALL=as.new
-
-# End of variables for you to override.
-
-# Lists of files for various purposes.
-
-REAL_SOURCES = \
- app.c \
- as.c \
- atof-generic.c \
- bignum-copy.c \
- cond.c \
- expr.c \
- fn-const.c \
- fn-copy.c \
- flonum-mult.c \
- frags.c \
- hash.c \
- hex-value.c \
- input-file.c \
- input-scrub.c \
- messages.c \
- output-file.c \
- read.c \
- strstr.c \
- subsegs.c \
- symbols.c \
- version.c \
- write.c \
- xmalloc.c \
- xrealloc.c
-
-# in an expedient order
-LINKED_SOURCES = \
- targ-cpu.c \
- obj-format.c \
- atof-targ.c
-
-SOURCES = $(LINKED_SOURCES) $(REAL_SOURCES)
-
-REAL_HEADERS = \
- as.h \
- bignum.h \
- expr.h \
- flonum.h \
- frags.h \
- hash.h \
- input-file.h \
- tc.h \
- obj.h \
- read.h \
- struc-symbol.h \
- subsegs.h \
- symbols.h \
- syscalls.h \
- write.h
-
-LINKED_HEADERS = \
- a.out.gnu.h \
- a.out.h \
- host.h \
- targ-env.h \
- targ-cpu.h \
- obj-format.h \
- atof-targ.h
-
-HEADERS = $(LINKED_HEADERS) $(REAL_HEADERS)
-
-OBJS = \
- targ-cpu.o \
- obj-format.o \
- atof-targ.o \
- app.o \
- as.o \
- atof-generic.o \
- bignum-copy.o \
- cond.o \
- expr.o \
- fn-const.o \
- fn-copy.o \
- flonum-mult.o \
- frags.o \
- hash.o \
- hex-value.o \
- input-file.o \
- input-scrub.o \
- messages.o \
- output-file.o \
- read.o \
- strstr.o \
- subsegs.o \
- symbols.o \
- version.o \
- write.o \
- xmalloc.o \
- xrealloc.o
-
-#### host, target, and site specific Makefile frags come in here.
-TARG_CPU_DEPENDENTS=../include/h8300-opcode.h
-LOCAL_LOADLIBES=../bfd/libbfd.a
-TDEFINES=-DBFD -DBFD_HEADERS -DMANY_SEGMENTS
-
-
-# Definition of `all' is here so that new rules inserted by sed
-# do not specify the default target.
-# The real definition is under `all.internal'.
-
-all: $(ALL)
-all-info:
-install-info:
-
-fake-as: force
- - rm -f ./as.new
- cp /bin/as ./fake-as
-
-# Now figure out from those variables how to compile and link.
-
-# This is the variable actually used when we compile.
-ALL_CFLAGS = $(INTERNAL_CFLAGS) $(CFLAGS) $(HDEFINES) $(TDEFINES)
-
-# Even if ALLOCA is set, don't use it if compiling with GCC.
-USE_ALLOCA= `if [ x"${CC}" = x"${OLDCC}" ] ; then echo ${ALLOCA}; else true; fi`
-USE_HOST_ALLOCA= `if [ x"${CC}" = x"${OLDCC}" ] ; then echo ${HOST_PREFIX}${ALLOCA}; else true; fi`
-
-# Likewise, for use in the tools that must run on this machine
-# even if we are cross-building GCC.
-# We don't use USE_ALLOCA because backquote expansion doesn't work in deps.
-HOST_LIBDEPS= $(HOST_PREFIX)$(OBSTACK) $(HOST_PREFIX)$(ALLOCA) $(HOST_PREFIX)$(MALLOC)
-
-# How to link with both our special library facilities
-# and the system's installed libraries.
-
-LIBS = $(LOCAL_LOADLIBES) $(CLIB) $(unsubdir)/../libiberty$(subdir)/libiberty.a
-
-# Likewise, for use in the tools that must run on this machine
-# even if we are cross-building GCC.
-HOST_LIBS = $(HOST_PREFIX)$(OBSTACK) $(USE_HOST_ALLOCA) $(HOST_PREFIX)$(MALLOC) $(CLIB)
-
-# Specify the directories to be searched for header files.
-# Both . and srcdir are used, in that order,
-# so that tm.h and config.h will be found in the compilation
-# subdirectory rather than in the source directory.
-INCLUDES = -I. -I$(srcdir) -Iconfig
-SUBDIR_INCLUDES = -I.. -I../$(srcdir) -I../config
-
-# Always use -Iconfig when compiling.
-.c.o:
- $(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $<
-
-# This tells GNU make version 3 not to export all the variables
-# defined in this file into the environment.
-.NOEXPORT:
-
-# Files to be copied away after each stage in building.
-STAGE_GCC=gcc
-STAGESTUFF = *.o as.new
-
-# The files that "belong" in CONFIG_H are deliberately omitted
-# because having them there would not be useful in actual practice.
-# All they would do is cause complete recompilation every time
-# one of the machine description files is edited.
-# That may or may not be what one wants to do.
-# If it is, rm *.o is an easy way to do it.
-# CONFIG_H = config.h tm.h
-CONFIG_H =
-
-as.new: $(OBJS) $(LIBDEPS)
- -mv -f as.new as.old
- >as.rf $(ALL_CFLAGS) $(LDFLAGS) -o as.new $(OBJS) $(LIBS) $(LOADLIBES)
- $(CC) @as.rf
-
-objdump:
-
-all.internal: native
-# This is what is made with the host's compiler if making a cross assembler.
-native: config.status as
-
-config.status:
- @echo You must configure gas. Look at the INSTALL file for details.
- @false
-
-compilations: ${OBJS}
-
-# Compiling object files from source files.
-
-app.o : app.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-as.o : as.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-atof-generic.o : atof-generic.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-bignum-copy.o : bignum-copy.c as.h host.h \
- targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-cond.o : cond.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
-
-debug.o : debug.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- subsegs.h
-expr.o : expr.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
-
-fn-const.o : fn-const.c flonum.h bignum.h
-fn-copy.o : fn-copy.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-flonum-mult.o : flonum-mult.c flonum.h bignum.h
-frags.o : frags.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- subsegs.h
-hash.o : hash.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-hex-value.o : hex-value.c
-input-file.o : input-file.c as.h host.h \
- targ-env.h obj-format.h targ-cpu.h \
- struc-symbol.h write.h flonum.h bignum.h expr.h \
- frags.h hash.h read.h symbols.h tc.h obj.h input-file.h
-input-scrub.o : input-scrub.c \
- as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- input-file.h
-messages.o : messages.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h
-obstack.o : obstack.c
-output-file.o : output-file.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- output-file.h
-read.o : read.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
-
-strstr.o : strstr.c
-subsegs.o : subsegs.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- subsegs.h
-symbols.o : symbols.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- subsegs.h
-version.o : version.c
-write.o : write.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \
- subsegs.h output-file.h
-xmalloc.o : xmalloc.c
-xrealloc.o : xrealloc.c
-atof-targ.o : atof-targ.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h \
- symbols.h tc.h obj.h
-obj-format.o : obj-format.c as.h host.h targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h \
- symbols.h tc.h obj.h
-targ-cpu.o : targ-cpu.c targ-env.h obj-format.h \
- targ-cpu.h struc-symbol.h \
- write.h flonum.h bignum.h expr.h frags.h hash.h read.h \
- symbols.h tc.h obj.h $(TARG_CPU_DEPENDENTS)
-
-
-# Compile the libraries to be used by gen*.
-# If we are not cross-building, gen* use the same .o's that cc1 will use,
-# and HOST_PREFIX_1 is `foobar', just to ensure these rules don't conflict
-# with the rules for rtl.o, alloca.o, etc.
-$(HOST_PREFIX_1)alloca.o: alloca.c
- rm -f $(HOST_PREFIX)alloca.c
- cp alloca.c $(HOST_PREFIX)alloca.c
- $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)alloca.c
-
-$(HOST_PREFIX_1)obstack.o: obstack.c
- rm -f $(HOST_PREFIX)obstack.c
- cp obstack.c $(HOST_PREFIX)obstack.c
- $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)obstack.c
-
-$(HOST_PREFIX_1)malloc.o: malloc.c
- rm -f $(HOST_PREFIX)malloc.c
- cp malloc.c $(HOST_PREFIX)malloc.c
- $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)malloc.c
-
-# Remake the info files.
-
-doc: as.info
-
-as.info: doc/as.texinfo
- (cd doc; make as.info; mv as.info $srcdir)
-
-
-# Deletion of files made during compilation.
-# There are three levels of this: `clean', `cleanconfig' and `realclean'.
-# `clean' deletes what you want to delete ordinarily to save space.
-# This is most, but not all, of the files made by compilation.
-# `cleanconfig' also deletes everything depending
-# on the choice of config files.
-# `realclean' also deletes everything that could be regenerated automatically.
-
-clean:
- -rm -f $(STAGESTUFF)
-# Delete the temporary source copies for cross compilation.
- -rm -f $(HOST_PREFIX_1)alloca.c $(HOST_PREFIX_1)malloc.c
- -rm -f $(HOST_PREFIX_1)obstack.c
-# Delete the stamp files except stamp-gnulib2.
- -rm -f core
-
-# Like clean but also delete the links made to configure gas.
-cleanconfig: clean
- -rm -f config.status Makefile host.h targ-env.h
- -rm -f targ-cpu.h targ-cpu.c
- -rm -f obj-format.h obj-format.c
- -rm -f atof-targ.c
-
-# Get rid of every file that's generated from some other file (except INSTALL).
-realclean: cleanconfig
- -rm -f gas.aux gas.cps gas.fns gas.info gas.kys gas.pgs gas.tps gas.vrs
- -rm -f TAGS
- -rm -f gas.info* gas.?? gas.??s gas.log gas.toc gas.*aux
- -rm -f *.dvi
-
-# Entry points `install', `includes' and `uninstall'.
-
-# Copy the files into directories where they will be run.
-install: $(ALL)
- $(INSTALL_PROGRAM) $(ALL) $(libsubdir)/as
-# cp $(ALL) $(bindir)/as.new
-# mv -f $(bindir)/as.new $(bindir)/as
-
-# Create the installation directory.
-install-dir:
- -mkdir $(libdir)
- -mkdir $(libdir)/gcc
- -mkdir $(libdir)/gcc/$(target)
- -mkdir $(libdir)/gcc/$(target)/$(version)
-
-# Install the compiler executables built during cross compilation.
-install-cross: native install-dir
- -if [ -f cc1 ] ; then $(INSTALL_PROGRAM) cc1 $(libsubdir)/cc1; else true; fi
- -if [ -f cc1plus ] ; then $(INSTALL_PROGRAM) cc1plus $(libsubdir)/cc1plus; else true; fi
- $(INSTALL_PROGRAM) cpp $(libsubdir)/cpp
- ./gcc -dumpspecs > $(libsubdir)/specs
- $(INSTALL_PROGRAM) gcc $(bindir)/gcc
-
-# Install the man pages.
-install-man: install-dir gcc.1 protoize.1 unprotoize.1
- $(INSTALL_FILE) gcc.1 $(mandir)/gcc.$(manext)
- chmod a-x $(mandir)/gcc.$(manext)
- $(INSTALL_FILE) protoize.1 $(mandir)/protoize.$(manext)
- chmod a-x $(mandir)/protoize.$(manext)
- $(INSTALL_FILE) unprotoize.1 $(mandir)/unprotoize.$(manext)
- chmod a-x $(mandir)/unprotoize.$(manext)
-
-# Cancel installation by deleting the installed files.
-uninstall:
- -rm -rf $(libsubdir)
- -rm -rf $(bindir)/as
- -rm -rf $(mandir)/gas.$(manext)
-
-
-# These exist for maintenance purposes.
-
-tags TAGS: force
- etags $(REAL_SOURCES) $(REAL_HEADERS) README Makefile config/*.[hc]
-
-bootstrap: $(ALL) force
- $(MAKE) stage1
- $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL)
- $(MAKE) stage2
- $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL)
- $(MAKE) comparison against=stage2
-
-bootstrap2: force
- $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL)
- $(MAKE) stage2
- $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL)
- $(MAKE) comparison against=stage2
-
-bootstrap3: force
- $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL)
- $(MAKE) comparison against=stage2
-
-# Copy the object files from a particular stage into a subdirectory.
-stage1: force
- -mkdir stage1
- -mv $(STAGESTUFF) stage1
- if [ -f stage1/as.new -a ! -f stage1/as ] ; then (cd stage1 ; ln -s as.new as) ; fi
-
-stage2: force
- -mkdir stage2
- -mv $(STAGESTUFF) stage2
- if [ -f stage2/as.new -a ! -f stage2/as ] ; then (cd stage2 ; ln -s as.new as) ; fi
-
-stage3: force
- -mkdir stage3
- -mv $(STAGESTUFF) stage3
- if [ -f stage3/as.new -a ! -f stage3/as ] ; then (cd stage3 ; ln -s as.new as) ; fi
-
-against=stage2
-
-comparison: force
- for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done
-
-de-stage1: force
- - (cd stage1 ; rm as ; mv -f * ..)
- - rmdir stage1
-
-de-stage2: force
- - (cd stage2 ; rm as ; mv -f * ..)
- - rmdir stage2
-
-de-stage3: force
- - (cd stage3 ; rm as ; mv -f * ..)
- - rmdir stage3
-
-# Copy just the executable files from a particular stage into a subdirectory,
-# and delete the object files. Use this if you're just verifying a version
-# that is pretty sure to work, and you are short of disk space.
-risky-stage1: force
- -mkdir stage1
- -mv cc1 cpp cccp gcc stage1
- -rm -f stage1/gnulib
- -cp gnulib stage1 && $(RANLIB) stage1/gnulib
- -make clean
-
-risky-stage2: force
- -mkdir stage2
- -mv cc1 cpp cccp gcc stage2
- -rm -f stage2/gnulib
- -cp gnulib stage2 && $(RANLIB) stage2/gnulib
- -make clean
-
-risky-stage3: force
- -mkdir stage3
- -mv cc1 cpp cccp gcc stage3
- -rm -f stage3/gnulib
- -cp gnulib stage3 && $(RANLIB) stage3/gnulib
- -make clean
-
-risky-stage4: force
- -mkdir stage4
- -mv cc1 cpp cccp gcc stage4
- -rm -f stage4/gnulib
- -cp gnulib stage4 && $(RANLIB) stage4/gnulib
- -make clean
-
-#In GNU Make, ignore whether `stage*' exists.
-.PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap
-.PHONY: risky-stage1 risky-stage2 risky-stage3 risky-stage4
-
-force:
-
-Makefile: Makefile.in $(host_makefile_frag) $(target_makefile_frag)
- $(SHELL) ./config.status
-
diff --git a/gnu/usr.bin/as/messages.c b/gnu/usr.bin/as/messages.c
deleted file mode 100644
index ed5c8af..0000000
--- a/gnu/usr.bin/as/messages.c
+++ /dev/null
@@ -1,595 +0,0 @@
-/* messages.c - error reporter -
- Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-
-#include "as.h"
-
-#ifndef __STDC__
-#ifndef NO_STDARG
-#define NO_STDARG
-#endif
-#endif
-
-#ifndef NO_STDARG
-#include <stdarg.h>
-#else
-#ifndef NO_VARARGS
-#include <varargs.h>
-#endif /* NO_VARARGS */
-#endif /* NO_STDARG */
-
-extern char *strerror ();
-
-static void as_show_where PARAMS ((void));
-static void as_warn_internal PARAMS ((char *, unsigned int, char *));
-static void as_bad_internal PARAMS ((char *, unsigned int, char *));
-
-/*
- * Despite the rest of the comments in this file, (FIXME-SOON),
- * here is the current scheme for error messages etc:
- *
- * as_fatal() is used when gas is quite confused and
- * continuing the assembly is pointless. In this case we
- * exit immediately with error status.
- *
- * as_bad() is used to mark errors that result in what we
- * presume to be a useless object file. Say, we ignored
- * something that might have been vital. If we see any of
- * these, assembly will continue to the end of the source,
- * no object file will be produced, and we will terminate
- * with error status. The new option, -Z, tells us to
- * produce an object file anyway but we still exit with
- * error status. The assumption here is that you don't want
- * this object file but we could be wrong.
- *
- * as_warn() is used when we have an error from which we
- * have a plausible error recovery. eg, masking the top
- * bits of a constant that is longer than will fit in the
- * destination. In this case we will continue to assemble
- * the source, although we may have made a bad assumption,
- * and we will produce an object file and return normal exit
- * status (ie, no error). The new option -X tells us to
- * treat all as_warn() errors as as_bad() errors. That is,
- * no object file will be produced and we will exit with
- * error status. The idea here is that we don't kill an
- * entire make because of an error that we knew how to
- * correct. On the other hand, sometimes you might want to
- * stop the make at these points.
- *
- * as_tsktsk() is used when we see a minor error for which
- * our error recovery action is almost certainly correct.
- * In this case, we print a message and then assembly
- * continues as though no error occurred.
- */
-
-static void
-identify (file)
- char *file;
-{
- static int identified;
- if (identified)
- return;
- identified++;
-
- if (!file)
- {
- unsigned int x;
- as_where (&file, &x);
- }
-
- fprintf (stderr, "%s: Assembler messages:\n", file);
-}
-
-static int warning_count; /* Count of number of warnings issued */
-
-int
-had_warnings ()
-{
- return (warning_count);
-} /* had_err() */
-
-/* Nonzero if we've hit a 'bad error', and should not write an obj file,
- and exit with a nonzero error code */
-
-static int error_count;
-
-int
-had_errors ()
-{
- return (error_count);
-} /* had_errors() */
-
-
-/* Print the current location to stderr. */
-
-static void
-as_show_where ()
-{
- char *file;
- unsigned int line;
-
- as_where (&file, &line);
- identify (file);
- fprintf (stderr, "%s:%u: ", file, line);
-}
-
-/*
- * a s _ p e r r o r
- *
- * Like perror(3), but with more info.
- */
-
-void
-as_perror (gripe, filename)
- const char *gripe; /* Unpunctuated error theme. */
- const char *filename;
-{
- const char *errtxt;
-
- as_show_where ();
- fprintf (stderr, gripe, filename);
-#ifdef BFD_ASSEMBLER
- errtxt = bfd_errmsg (bfd_get_error ());
-#else
- errtxt = strerror (errno);
-#endif
- fprintf (stderr, ": %s\n", errtxt);
- errno = 0;
-#ifdef BFD_ASSEMBLER
- bfd_set_error (bfd_error_no_error);
-#endif
-}
-
-/*
- * a s _ t s k t s k ()
- *
- * Send to stderr a string as a warning, and locate warning
- * in input file(s).
- * Please only use this for when we have some recovery action.
- * Please explain in string (which may have '\n's) what recovery was done.
- */
-
-#ifndef NO_STDARG
-void
-as_tsktsk (const char *format,...)
-{
- va_list args;
-
- as_show_where ();
- va_start (args, format);
- vfprintf (stderr, format, args);
- va_end (args);
- (void) putc ('\n', stderr);
-} /* as_tsktsk() */
-
-#else
-#ifndef NO_VARARGS
-void
-as_tsktsk (format, va_alist)
- char *format;
- va_dcl
-{
- va_list args;
-
- as_show_where ();
- va_start (args);
- vfprintf (stderr, format, args);
- va_end (args);
- (void) putc ('\n', stderr);
-} /* as_tsktsk() */
-
-#else
-/*VARARGS1 */
-as_tsktsk (format, args)
- char *format;
-{
- as_show_where ();
- _doprnt (format, &args, stderr);
- (void) putc ('\n', stderr);
-} /* as_tsktsk */
-
-#endif /* not NO_VARARGS */
-#endif /* not NO_STDARG */
-
-/* The common portion of as_warn and as_warn_where. */
-
-static void
-as_warn_internal (file, line, buffer)
- char *file;
- unsigned int line;
- char *buffer;
-{
- ++warning_count;
-
- if (file == NULL)
- as_where (&file, &line);
-
- identify (file);
- fprintf (stderr, "%s:%u: Warning: ", file, line);
- fputs (buffer, stderr);
- (void) putc ('\n', stderr);
-#ifndef NO_LISTING
- listing_warning (buffer);
-#endif
-}
-
-/*
- * a s _ w a r n ()
- *
- * Send to stderr a string as a warning, and locate warning
- * in input file(s).
- * Please only use this for when we have some recovery action.
- * Please explain in string (which may have '\n's) what recovery was done.
- */
-
-#if 1
-#define flag_no_warnings (flagseen['W'])
-#endif
-
-#ifndef NO_STDARG
-void
-as_warn (const char *format,...)
-{
- va_list args;
- char buffer[200];
-
- if (!flag_no_warnings)
- {
- va_start (args, format);
- vsprintf (buffer, format, args);
- va_end (args);
- as_warn_internal ((char *) NULL, 0, buffer);
- }
-} /* as_warn() */
-
-#else
-#ifndef NO_VARARGS
-void
-as_warn (format, va_alist)
- char *format;
- va_dcl
-{
- va_list args;
- char buffer[200];
-
- if (!flag_no_warnings)
- {
- va_start (args);
- vsprintf (buffer, format, args);
- va_end (args);
- as_warn_internal ((char *) NULL, 0, buffer);
- }
-} /* as_warn() */
-
-#else
-/*VARARGS1 */
-as_warn (format, args)
- char *format;
-{
- if (!flag_no_warnings)
- {
- ++warning_count;
- as_show_where ();
- fprintf (stderr, "Warning: ");
- _doprnt (format, &args, stderr);
- (void) putc ('\n', stderr);
- }
-} /* as_warn() */
-
-#endif /* not NO_VARARGS */
-#endif /* not NO_STDARG */
-
-/* as_warn_where, like as_bad but the file name and line number are
- passed in. Unfortunately, we have to repeat the function in order
- to handle the varargs correctly and portably. */
-
-#ifndef NO_STDARG
-void
-as_warn_where (char *file, unsigned int line, const char *format,...)
-{
- va_list args;
- char buffer[200];
-
- if (!flag_no_warnings)
- {
- va_start (args, format);
- vsprintf (buffer, format, args);
- va_end (args);
- as_warn_internal (file, line, buffer);
- }
-} /* as_warn() */
-
-#else
-#ifndef NO_VARARGS
-void
-as_warn_where (file, line, format, va_alist)
- char *file;
- unsigned int line;
- char *format;
- va_dcl
-{
- va_list args;
- char buffer[200];
-
- if (!flag_no_warnings)
- {
- va_start (args);
- vsprintf (buffer, format, args);
- va_end (args);
- as_warn_internal (file, line, buffer);
- }
-} /* as_warn() */
-
-#else
-/*VARARGS1 */
-as_warn_where (file, line, format, args)
- char *file;
- unsigned int line;
- char *format;
-{
- if (!flag_no_warnings)
- {
- ++warning_count;
- identify (file);
- fprintf (stderr, "%s:%u: Warning: ", file, line);
- _doprnt (format, &args, stderr);
- (void) putc ('\n', stderr);
- }
-} /* as_warn() */
-
-#endif /* not NO_VARARGS */
-#endif /* not NO_STDARG */
-
-/* The common portion of as_bad and as_bad_where. */
-
-static void
-as_bad_internal (file, line, buffer)
- char *file;
- unsigned int line;
- char *buffer;
-{
- ++error_count;
-
- if (file == NULL)
- as_where (&file, &line);
-
- identify (file);
- fprintf (stderr, "%s:%u: Error: ", file, line);
- fputs (buffer, stderr);
- (void) putc ('\n', stderr);
-#ifndef NO_LISTING
- listing_error (buffer);
-#endif
-}
-
-/*
- * a s _ b a d ()
- *
- * Send to stderr a string as a warning, and locate warning in input file(s).
- * Please us when there is no recovery, but we want to continue processing
- * but not produce an object file.
- * Please explain in string (which may have '\n's) what recovery was done.
- */
-
-#ifndef NO_STDARG
-void
-as_bad (const char *format,...)
-{
- va_list args;
- char buffer[200];
-
- va_start (args, format);
- vsprintf (buffer, format, args);
- va_end (args);
-
- as_bad_internal ((char *) NULL, 0, buffer);
-}
-
-#else
-#ifndef NO_VARARGS
-void
-as_bad (format, va_alist)
- char *format;
- va_dcl
-{
- va_list args;
- char buffer[200];
-
- va_start (args);
- vsprintf (buffer, format, args);
- va_end (args);
-
- as_bad_internal ((char *) NULL, 0, buffer);
-}
-
-#else
-/*VARARGS1 */
-as_bad (format, args)
- char *format;
-{
- ++error_count;
-
- as_show_where ();
- fprintf (stderr, "Error: ");
- _doprnt (format, &args, stderr);
- (void) putc ('\n', stderr);
-} /* as_bad() */
-
-#endif /* not NO_VARARGS */
-#endif /* not NO_STDARG */
-
-/* as_bad_where, like as_bad but the file name and line number are
- passed in. Unfortunately, we have to repeat the function in order
- to handle the varargs correctly and portably. */
-
-#ifndef NO_STDARG
-void
-as_bad_where (char *file, unsigned int line, const char *format,...)
-{
- va_list args;
- char buffer[200];
-
- va_start (args, format);
- vsprintf (buffer, format, args);
- va_end (args);
-
- as_bad_internal (file, line, buffer);
-}
-
-#else
-#ifndef NO_VARARGS
-void
-as_bad_where (file, line, format, va_alist)
- char *file;
- unsigned int line;
- char *format;
- va_dcl
-{
- va_list args;
- char buffer[200];
-
- va_start (args);
- vsprintf (buffer, format, args);
- va_end (args);
-
- as_bad_internal (file, line, buffer);
-}
-
-#else
-/*VARARGS1 */
-as_bad_where (file, line, format, args)
- char *file;
- unsigned int line;
- char *format;
-{
- ++error_count;
-
- identify (file);
- fprintf (stderr, "%s:%u: Error: ", file, line);
- _doprnt (format, &args, stderr);
- (void) putc ('\n', stderr);
-} /* as_bad() */
-
-#endif /* not NO_VARARGS */
-#endif /* not NO_STDARG */
-
-/*
- * a s _ f a t a l ()
- *
- * Send to stderr a string as a fatal message, and print location of error in
- * input file(s).
- * Please only use this for when we DON'T have some recovery action.
- * It exit()s with a warning status.
- */
-
-#ifndef NO_STDARG
-void
-as_fatal (const char *format,...)
-{
- va_list args;
-
- as_show_where ();
- va_start (args, format);
- fprintf (stderr, "Fatal error:");
- vfprintf (stderr, format, args);
- (void) putc ('\n', stderr);
- va_end (args);
- exit (33);
-} /* as_fatal() */
-
-#else
-#ifndef NO_VARARGS
-void
-as_fatal (format, va_alist)
- char *format;
- va_dcl
-{
- va_list args;
-
- as_show_where ();
- va_start (args);
- fprintf (stderr, "Fatal error:");
- vfprintf (stderr, format, args);
- (void) putc ('\n', stderr);
- va_end (args);
- exit (33);
-} /* as_fatal() */
-
-#else
-/*VARARGS1 */
-as_fatal (format, args)
- char *format;
-{
- as_show_where ();
- fprintf (stderr, "Fatal error:");
- _doprnt (format, &args, stderr);
- (void) putc ('\n', stderr);
- exit (33); /* What is a good exit status? */
-} /* as_fatal() */
-
-#endif /* not NO_VARARGS */
-#endif /* not NO_STDARG */
-
-void
-fprint_value (file, val)
- FILE *file;
- valueT val;
-{
- if (sizeof (val) <= sizeof (long))
- {
- fprintf (file, "%ld", val);
- return;
- }
-#ifdef BFD_ASSEMBLER
- if (sizeof (val) <= sizeof (bfd_vma))
- {
- fprintf_vma (file, val);
- return;
- }
-#endif
- abort ();
-}
-
-void
-sprint_value (buf, val)
- char *buf;
- valueT val;
-{
- if (sizeof (val) <= sizeof (long))
- {
- sprintf (buf, "%ld", val);
- return;
- }
-#ifdef BFD_ASSEMBLER
- if (sizeof (val) <= sizeof (bfd_vma))
- {
- sprintf_vma (buf, val);
- return;
- }
-#endif
- abort ();
-}
-
-/* end of messages.c */
diff --git a/gnu/usr.bin/as/obj.h b/gnu/usr.bin/as/obj.h
deleted file mode 100644
index 1c41c05..0000000
--- a/gnu/usr.bin/as/obj.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* obj.h - defines the object dependent hooks for all object
- format backends.
-
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-#if __STDC__ == 1
-
-char *obj_default_output_file_name(void);
-void obj_crawl_symbol_chain(object_headers *headers);
-void obj_emit_relocations(char **where, fixS *fixP, relax_addressT segment_address_in_file);
-void obj_emit_strings(char **where);
-void obj_emit_symbols(char **where, symbolS *symbol_rootP);
-void obj_header_append(char **where, object_headers *headers);
-void obj_read_begin_hook(void);
-
-#ifndef obj_symbol_new_hook
-void obj_symbol_new_hook(symbolS *symbolP);
-#endif /* obj_symbol_new_hook */
-
-void obj_symbol_to_chars(char **where, symbolS *symbolP);
-
-#ifndef obj_pre_write_hook
-void obj_pre_write_hook(object_headers *headers);
-#endif /* obj_pre_write_hook */
-
-#else /* not __STDC__ */
-
-char *obj_default_output_file_name();
-void obj_crawl_symbol_chain();
-void obj_emit_relocations();
-void obj_emit_strings();
-void obj_emit_symbols();
-void obj_header_append();
-void obj_read_begin_hook();
-
-#ifndef obj_symbol_new_hook
-void obj_symbol_new_hook();
-#endif /* obj_symbol_new_hook */
-
-void obj_symbol_to_chars();
-
-#ifndef obj_pre_write_hook
-void obj_pre_write_hook();
-#endif /* obj_pre_write_hook */
-
-#endif /* not __STDC__ */
-
-extern const pseudo_typeS obj_pseudo_table[];
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of obj.h */
diff --git a/gnu/usr.bin/as/obstack.c b/gnu/usr.bin/as/obstack.c
deleted file mode 100644
index af76481..0000000
--- a/gnu/usr.bin/as/obstack.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/* obstack.c - subroutines used implicitly by object stack macros
- Copyright (C) 1988 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "obstack.h"
-
-#ifdef __STDC__
-#define POINTER void *
-#else
-#define POINTER char *
-#endif
-
-/* Determine default alignment. */
-struct fooalign {char x; double d;};
-#define DEFAULT_ALIGNMENT ((char *)&((struct fooalign *) 0)->d - (char *)0)
-/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
- But in fact it might be less smart and round addresses to as much as
- DEFAULT_ROUNDING. So we prepare for it to do that. */
-union fooround {long x; double d;};
-#define DEFAULT_ROUNDING (sizeof (union fooround))
-
-/* When we copy a long block of data, this is the unit to do it with.
- On some machines, copying successive ints does not work;
- in such a case, redefine COPYING_UNIT to `long' (if that works)
- or `char' as a last resort. */
-#ifndef COPYING_UNIT
-#define COPYING_UNIT int
-#endif
-
-/* The non-GNU-C macros copy the obstack into this global variable
- to avoid multiple evaluation. */
-
-struct obstack *_obstack;
-
-/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
- Objects start on multiples of ALIGNMENT (0 means use default).
- CHUNKFUN is the function to use to allocate chunks,
- and FREEFUN the function to free them. */
-
-void
-_obstack_begin (h, size, alignment, chunkfun, freefun)
- struct obstack *h;
- int size;
- int alignment;
- POINTER (*chunkfun) ();
- void (*freefun) ();
-{
- register struct _obstack_chunk* chunk; /* points to new chunk */
-
- if (alignment == 0)
- alignment = DEFAULT_ALIGNMENT;
- if (size == 0)
- /* Default size is what GNU malloc can fit in a 4096-byte block. */
- {
- /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
- Use the values for range checking, because if range checking is off,
- the extra bytes won't be missed terribly, but if range checking is on
- and we used a larger request, a whole extra 4096 bytes would be
- allocated.
-
- These number are irrelevant to the new GNU malloc. I suspect it is
- less sensitive to the size of the request. */
- int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
- + 4 + DEFAULT_ROUNDING - 1)
- & ~(DEFAULT_ROUNDING - 1));
- size = 4096 - extra;
- }
-
- h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
- h->freefun = freefun;
- h->chunk_size = size;
- h->alignment_mask = alignment - 1;
-
- chunk = h->chunk = (*h->chunkfun) (h->chunk_size);
- h->next_free = h->object_base = chunk->contents;
- h->chunk_limit = chunk->limit
- = (char *) chunk + h->chunk_size;
- chunk->prev = 0;
- /* The initial chunk now contains no empty object. */
- h->maybe_empty_object = 0;
-}
-
-/* Allocate a new current chunk for the obstack *H
- on the assumption that LENGTH bytes need to be added
- to the current object, or a new object of length LENGTH allocated.
- Copies any partial object from the end of the old chunk
- to the beginning of the new one. */
-
-void
-_obstack_newchunk (h, length)
- struct obstack *h;
- int length;
-{
- register struct _obstack_chunk* old_chunk = h->chunk;
- register struct _obstack_chunk* new_chunk;
- register long new_size;
- register int obj_size = h->next_free - h->object_base;
- register int i;
- int already;
-
- /* Compute size for new chunk. */
- new_size = (obj_size + length) + (obj_size >> 3) + 100;
- if (new_size < h->chunk_size)
- new_size = h->chunk_size;
-
- /* Allocate and initialize the new chunk. */
- new_chunk = h->chunk = (*h->chunkfun) (new_size);
- new_chunk->prev = old_chunk;
- new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
-
- /* Move the existing object to the new chunk.
- Word at a time is fast and is safe if the object
- is sufficiently aligned. */
- if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
- {
- for (i = obj_size / sizeof (COPYING_UNIT) - 1;
- i >= 0; i--)
- ((COPYING_UNIT *)new_chunk->contents)[i]
- = ((COPYING_UNIT *)h->object_base)[i];
- /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT,
- but that can cross a page boundary on a machine
- which does not do strict alignment for COPYING_UNITS. */
- already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
- }
- else
- already = 0;
- /* Copy remaining bytes one by one. */
- for (i = already; i < obj_size; i++)
- new_chunk->contents[i] = h->object_base[i];
-
- /* If the object just copied was the only data in OLD_CHUNK,
- free that chunk and remove it from the chain.
- But not if that chunk might contain an empty object. */
- if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
- {
- new_chunk->prev = old_chunk->prev;
- (*h->freefun) (old_chunk);
- }
-
- h->object_base = new_chunk->contents;
- h->next_free = h->object_base + obj_size;
- /* The new chunk certainly contains no empty object yet. */
- h->maybe_empty_object = 0;
-}
-
-/* Return nonzero if object OBJ has been allocated from obstack H.
- This is here for debugging.
- If you use it in a program, you are probably losing. */
-
-int
-_obstack_allocated_p (h, obj)
- struct obstack *h;
- POINTER obj;
-{
- register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */
- register struct _obstack_chunk* plp; /* point to previous chunk if any */
-
- lp = (h)->chunk;
- /* We use >= rather than > since the object cannot be exactly at
- the beginning of the chunk but might be an empty object exactly
- at the end of an adjacent chunk. */
- while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj))
- {
- plp = lp->prev;
- lp = plp;
- }
- return lp != 0;
-}
-
-/* Free objects in obstack H, including OBJ and everything allocate
- more recently than OBJ. If OBJ is zero, free everything in H. */
-
-#undef obstack_free
-
-/* This function has two names with identical definitions.
- This is the first one, called from non-ANSI code. */
-
-void
-_obstack_free (h, obj)
- struct obstack *h;
- POINTER obj;
-{
- register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */
- register struct _obstack_chunk* plp; /* point to previous chunk if any */
-
- lp = h->chunk;
- /* We use >= because there cannot be an object at the beginning of a chunk.
- But there can be an empty object at that address
- at the end of another chunk. */
- while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj))
- {
- plp = lp->prev;
- (*h->freefun) (lp);
- lp = plp;
- /* If we switch chunks, we can't tell whether the new current
- chunk contains an empty object, so assume that it may. */
- h->maybe_empty_object = 1;
- }
- if (lp)
- {
- h->object_base = h->next_free = (char *)(obj);
- h->chunk_limit = lp->limit;
- h->chunk = lp;
- }
- else if (obj != 0)
- /* obj is not in any of the chunks! */
- abort ();
-}
-
-/* This function is used from ANSI code. */
-
-void
-obstack_free (h, obj)
- struct obstack *h;
- POINTER obj;
-{
- register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */
- register struct _obstack_chunk* plp; /* point to previous chunk if any */
-
- lp = h->chunk;
- /* We use >= because there cannot be an object at the beginning of a chunk.
- But there can be an empty object at that address
- at the end of another chunk. */
- while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj))
- {
- plp = lp->prev;
- (*h->freefun) (lp);
- lp = plp;
- /* If we switch chunks, we can't tell whether the new current
- chunk contains an empty object, so assume that it may. */
- h->maybe_empty_object = 1;
- }
- if (lp)
- {
- h->object_base = h->next_free = (char *)(obj);
- h->chunk_limit = lp->limit;
- h->chunk = lp;
- }
- else if (obj != 0)
- /* obj is not in any of the chunks! */
- abort ();
-}
-
-#if 0
-/* These are now turned off because the applications do not use it
- and it uses bcopy via obstack_grow, which causes trouble on sysV. */
-
-/* Now define the functional versions of the obstack macros.
- Define them to simply use the corresponding macros to do the job. */
-
-#ifdef __STDC__
-/* These function definitions do not work with non-ANSI preprocessors;
- they won't pass through the macro names in parentheses. */
-
-/* The function names appear in parentheses in order to prevent
- the macro-definitions of the names from being expanded there. */
-
-POINTER (obstack_base) (obstack)
- struct obstack *obstack;
-{
- return obstack_base (obstack);
-}
-
-POINTER (obstack_next_free) (obstack)
- struct obstack *obstack;
-{
- return obstack_next_free (obstack);
-}
-
-int (obstack_object_size) (obstack)
- struct obstack *obstack;
-{
- return obstack_object_size (obstack);
-}
-
-int (obstack_room) (obstack)
- struct obstack *obstack;
-{
- return obstack_room (obstack);
-}
-
-void (obstack_grow) (obstack, pointer, length)
- struct obstack *obstack;
- POINTER pointer;
- int length;
-{
- obstack_grow (obstack, pointer, length);
-}
-
-void (obstack_grow0) (obstack, pointer, length)
- struct obstack *obstack;
- POINTER pointer;
- int length;
-{
- obstack_grow0 (obstack, pointer, length);
-}
-
-void (obstack_1grow) (obstack, character)
- struct obstack *obstack;
- int character;
-{
- obstack_1grow (obstack, character);
-}
-
-void (obstack_blank) (obstack, length)
- struct obstack *obstack;
- int length;
-{
- obstack_blank (obstack, length);
-}
-
-void (obstack_1grow_fast) (obstack, character)
- struct obstack *obstack;
- int character;
-{
- obstack_1grow_fast (obstack, character);
-}
-
-void (obstack_blank_fast) (obstack, length)
- struct obstack *obstack;
- int length;
-{
- obstack_blank_fast (obstack, length);
-}
-
-POINTER (obstack_finish) (obstack)
- struct obstack *obstack;
-{
- return obstack_finish (obstack);
-}
-
-POINTER (obstack_alloc) (obstack, length)
- struct obstack *obstack;
- int length;
-{
- return obstack_alloc (obstack, length);
-}
-
-POINTER (obstack_copy) (obstack, pointer, length)
- struct obstack *obstack;
- POINTER pointer;
- int length;
-{
- return obstack_copy (obstack, pointer, length);
-}
-
-POINTER (obstack_copy0) (obstack, pointer, length)
- struct obstack *obstack;
- POINTER pointer;
- int length;
-{
- return obstack_copy0 (obstack, pointer, length);
-}
-
-#endif /* __STDC__ */
-
-#endif /* 0 */
diff --git a/gnu/usr.bin/as/obstack.h b/gnu/usr.bin/as/obstack.h
deleted file mode 100644
index 0b3179b..0000000
--- a/gnu/usr.bin/as/obstack.h
+++ /dev/null
@@ -1,448 +0,0 @@
-/* obstack.h - object stack macros
- Copyright (C) 1988 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-/* Summary:
-
-All the apparent functions defined here are macros. The idea
-is that you would use these pre-tested macros to solve a
-very specific set of problems, and they would run fast.
-Caution: no side-effects in arguments please!! They may be
-evaluated MANY times!!
-
-These macros operate a stack of objects. Each object starts life
-small, and may grow to maturity. (Consider building a word syllable
-by syllable.) An object can move while it is growing. Once it has
-been "finished" it never changes address again. So the "top of the
-stack" is typically an immature growing object, while the rest of the
-stack is of mature, fixed size and fixed address objects.
-
-These routines grab large chunks of memory, using a function you
-supply, called `obstack_chunk_alloc'. On occasion, they free chunks,
-by calling `obstack_chunk_free'. You must define them and declare
-them before using any obstack macros.
-
-Each independent stack is represented by a `struct obstack'.
-Each of the obstack macros expects a pointer to such a structure
-as the first argument.
-
-One motivation for this package is the problem of growing char strings
-in symbol tables. Unless you are "fascist pig with a read-only mind"
-[Gosper's immortal quote from HAKMEM item 154, out of context] you
-would not like to put any arbitrary upper limit on the length of your
-symbols.
-
-In practice this often means you will build many short symbols and a
-few long symbols. At the time you are reading a symbol you don't know
-how long it is. One traditional method is to read a symbol into a
-buffer, realloc()ating the buffer every time you try to read a symbol
-that is longer than the buffer. This is beaut, but you still will
-want to copy the symbol from the buffer to a more permanent
-symbol-table entry say about half the time.
-
-With obstacks, you can work differently. Use one obstack for all symbol
-names. As you read a symbol, grow the name in the obstack gradually.
-When the name is complete, finalize it. Then, if the symbol exists already,
-free the newly read name.
-
-The way we do this is to take a large chunk, allocating memory from
-low addresses. When you want to build a symbol in the chunk you just
-add chars above the current "high water mark" in the chunk. When you
-have finished adding chars, because you got to the end of the symbol,
-you know how long the chars are, and you can create a new object.
-Mostly the chars will not burst over the highest address of the chunk,
-because you would typically expect a chunk to be (say) 100 times as
-long as an average object.
-
-In case that isn't clear, when we have enough chars to make up
-the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
-so we just point to it where it lies. No moving of chars is
-needed and this is the second win: potentially long strings need
-never be explicitly shuffled. Once an object is formed, it does not
-change its address during its lifetime.
-
-When the chars burst over a chunk boundary, we allocate a larger
-chunk, and then copy the partly formed object from the end of the old
-chunk to the beginning of the new larger chunk. We then carry on
-accreting characters to the end of the object as we normally would.
-
-A special macro is provided to add a single char at a time to a
-growing object. This allows the use of register variables, which
-break the ordinary 'growth' macro.
-
-Summary:
- We allocate large chunks.
- We carve out one object at a time from the current chunk.
- Once carved, an object never moves.
- We are free to append data of any size to the currently
- growing object.
- Exactly one object is growing in an obstack at any one time.
- You can run one obstack per control block.
- You may have as many control blocks as you dare.
- Because of the way we do it, you can `unwind' a obstack
- back to a previous state. (You may remove objects much
- as you would with a stack.)
-*/
-
-
-/* Don't do the contents of this file more than once. */
-
-#ifndef __OBSTACKS__
-#define __OBSTACKS__
-
-/* We use subtraction of (char *)0 instead of casting to int
- because on word-addressable machines a simple cast to int
- may ignore the byte-within-word field of the pointer. */
-
-#ifndef __PTR_TO_INT
-#define __PTR_TO_INT(P) ((P) - (char *)0)
-#endif
-
-#ifndef __INT_TO_PTR
-#define __INT_TO_PTR(P) ((P) + (char *)0)
-#endif
-
-struct _obstack_chunk /* Lives at front of each chunk. */
-{
- char *limit; /* 1 past end of this chunk */
- struct _obstack_chunk *prev; /* address of prior chunk or NULL */
- char contents[4]; /* objects begin here */
-};
-
-struct obstack /* control current object in current chunk */
-{
- long chunk_size; /* preferred size to allocate chunks in */
- struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */
- char *object_base; /* address of object we are building */
- char *next_free; /* where to add next char to current object */
- char *chunk_limit; /* address of char after current chunk */
- int temp; /* Temporary for some macros. */
- int alignment_mask; /* Mask of alignment for each object. */
- struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */
- void (*freefun) (); /* User's function to free a chunk. */
- /* Nonzero means there is a possibility the current chunk contains
- a zero-length object. This prevents freeing the chunk
- if we allocate a bigger chunk to replace it. */
- char maybe_empty_object;
-};
-
-/* Declare the external functions we use; they are in obstack.c. */
-
-#ifdef __STDC__
- extern void _obstack_newchunk (struct obstack *, int);
- extern void _obstack_free (struct obstack *, void *);
- extern void _obstack_begin (struct obstack *, int, int,
- void *(*) (), void (*) ());
-#else
- extern void _obstack_newchunk ();
- extern void _obstack_free ();
- extern void _obstack_begin ();
-#endif
-
-#ifdef __STDC__
-
-/* Do the function-declarations after the structs
- but before defining the macros. */
-
-void obstack_init (struct obstack *obstack);
-
-void * obstack_alloc (struct obstack *obstack, int size);
-
-void * obstack_copy (struct obstack *obstack, void *address, int size);
-void * obstack_copy0 (struct obstack *obstack, void *address, int size);
-
-void obstack_free (struct obstack *obstack, void *block);
-
-void obstack_blank (struct obstack *obstack, int size);
-
-void obstack_grow (struct obstack *obstack, void *data, int size);
-void obstack_grow0 (struct obstack *obstack, void *data, int size);
-
-void obstack_1grow (struct obstack *obstack, int data_char);
-void obstack_ptr_grow (struct obstack *obstack, void *data);
-void obstack_int_grow (struct obstack *obstack, int data);
-
-void * obstack_finish (struct obstack *obstack);
-
-int obstack_object_size (struct obstack *obstack);
-
-int obstack_room (struct obstack *obstack);
-void obstack_1grow_fast (struct obstack *obstack, int data_char);
-void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
-void obstack_int_grow_fast (struct obstack *obstack, int data);
-void obstack_blank_fast (struct obstack *obstack, int size);
-
-void * obstack_base (struct obstack *obstack);
-void * obstack_next_free (struct obstack *obstack);
-int obstack_alignment_mask (struct obstack *obstack);
-int obstack_chunk_size (struct obstack *obstack);
-
-#endif /* __STDC__ */
-
-/* Non-ANSI C cannot really support alternative functions for these macros,
- so we do not declare them. */
-
-/* Pointer to beginning of object being allocated or to be allocated next.
- Note that this might not be the final address of the object
- because a new chunk might be needed to hold the final size. */
-
-#define obstack_base(h) ((h)->object_base)
-
-/* Size for allocating ordinary chunks. */
-
-#define obstack_chunk_size(h) ((h)->chunk_size)
-
-/* Pointer to next byte not yet allocated in current chunk. */
-
-#define obstack_next_free(h) ((h)->next_free)
-
-/* Mask specifying low bits that should be clear in address of an object. */
-
-#define obstack_alignment_mask(h) ((h)->alignment_mask)
-
-#define obstack_init(h) \
- _obstack_begin ((h), 0, 0, \
- (void *(*) ()) obstack_chunk_alloc, (void (*) ())obstack_chunk_free)
-
-#define obstack_begin(h, size) \
- _obstack_begin ((h), (size), 0, \
- (void *(*) ()) obstack_chunk_alloc, (void (*) ())obstack_chunk_free)
-
-#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
-
-#define obstack_blank_fast(h,n) ((h)->next_free += (n))
-
-#if defined (__GNUC__) && defined (__STDC__)
-#if __GNUC__ < 2
-#define __extension__
-#endif
-
-/* For GNU C, if not -traditional,
- we can define these macros to compute all args only once
- without using a global variable.
- Also, we can avoid using the `temp' slot, to make faster code. */
-
-#define obstack_object_size(OBSTACK) \
- __extension__ \
- ({ struct obstack *__o = (OBSTACK); \
- (unsigned) (__o->next_free - __o->object_base); })
-
-#define obstack_room(OBSTACK) \
- __extension__ \
- ({ struct obstack *__o = (OBSTACK); \
- (unsigned) (__o->chunk_limit - __o->next_free); })
-
-/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
- so that we can avoid having void expressions
- in the arms of the conditional expression.
- Casting the third operand to void was tried before,
- but some compilers won't accept it. */
-#define obstack_grow(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- ((__o->next_free + __len > __o->chunk_limit) \
- ? (_obstack_newchunk (__o, __len), 0) : 0); \
- memcpy (__o->next_free, where, __len); \
- __o->next_free += __len; \
- (void) 0; })
-
-#define obstack_grow0(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- ((__o->next_free + __len + 1 > __o->chunk_limit) \
- ? (_obstack_newchunk (__o, __len + 1), 0) : 0), \
- memcpy (__o->next_free, where, __len), \
- __o->next_free += __len, \
- *(__o->next_free)++ = 0; \
- (void) 0; })
-
-#define obstack_1grow(OBSTACK,datum) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- ((__o->next_free + 1 > __o->chunk_limit) \
- ? (_obstack_newchunk (__o, 1), 0) : 0), \
- *(__o->next_free)++ = (datum); \
- (void) 0; })
-
-/* These assume that the obstack alignment is good enough for pointers or ints,
- and that the data added so far to the current object
- shares that much alignment. */
-
-#define obstack_ptr_grow(OBSTACK,datum) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- ((__o->next_free + sizeof (void *) > __o->chunk_limit) \
- ? (_obstack_newchunk (__o, sizeof (void *)), 0) : 0), \
- *(*(void ***)&__o->next_free)++ = ((void *)datum); \
- (void) 0; })
-
-#define obstack_int_grow(OBSTACK,datum) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- ((__o->next_free + sizeof (int) > __o->chunk_limit) \
- ? (_obstack_newchunk (__o, sizeof (int)), 0) : 0), \
- *(*(int **)&__o->next_free)++ = ((int)datum); \
- (void) 0; })
-
-#define obstack_ptr_grow_fast(h,aptr) (*(*(void ***)&(h)->next_free)++ = (void *)aptr)
-#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint)
-
-#define obstack_blank(OBSTACK,length) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- ((__o->chunk_limit - __o->next_free < __len) \
- ? (_obstack_newchunk (__o, __len), 0) : 0); \
- __o->next_free += __len; \
- (void) 0; })
-
-#define obstack_alloc(OBSTACK,length) \
-__extension__ \
-({ struct obstack *__h = (OBSTACK); \
- obstack_blank (__h, (length)); \
- obstack_finish (__h); })
-
-#define obstack_copy(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__h = (OBSTACK); \
- obstack_grow (__h, (where), (length)); \
- obstack_finish (__h); })
-
-#define obstack_copy0(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__h = (OBSTACK); \
- obstack_grow0 (__h, (where), (length)); \
- obstack_finish (__h); })
-
-/* The local variable is named __o1 to avoid a name conflict
- when obstack_blank is called. */
-#define obstack_finish(OBSTACK) \
-__extension__ \
-({ struct obstack *__o1 = (OBSTACK); \
- void *value = (void *) __o1->object_base; \
- if (__o1->next_free == value) \
- __o1->maybe_empty_object = 1; \
- __o1->next_free \
- = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
- & ~ (__o1->alignment_mask)); \
- ((__o1->next_free - (char *)__o1->chunk \
- > __o1->chunk_limit - (char *)__o1->chunk) \
- ? (__o1->next_free = __o1->chunk_limit) : 0); \
- __o1->object_base = __o1->next_free; \
- value; })
-
-#define obstack_free(OBSTACK, OBJ) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- void *__obj = (OBJ); \
- if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
- __o->next_free = __o->object_base = __obj; \
- else (obstack_free) (__o, __obj); })
-
-#else /* not __GNUC__ or not __STDC__ */
-
-#define obstack_object_size(h) \
- (unsigned) ((h)->next_free - (h)->object_base)
-
-#define obstack_room(h) \
- (unsigned) ((h)->chunk_limit - (h)->next_free)
-
-#define obstack_grow(h,where,length) \
-( (h)->temp = (length), \
- (((h)->next_free + (h)->temp > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
- memcpy ((h)->next_free, where, (h)->temp), \
- (h)->next_free += (h)->temp)
-
-#define obstack_grow0(h,where,length) \
-( (h)->temp = (length), \
- (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
- memcpy ((h)->next_free, where, (h)->temp), \
- (h)->next_free += (h)->temp, \
- *((h)->next_free)++ = 0)
-
-#define obstack_1grow(h,datum) \
-( (((h)->next_free + 1 > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), 1), 0) : 0), \
- *((h)->next_free)++ = (datum))
-
-#define obstack_ptr_grow(h,datum) \
-( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
- *(*(char ***)&(h)->next_free)++ = ((char *)datum))
-
-#define obstack_int_grow(h,datum) \
-( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
- *(*(int **)&(h)->next_free)++ = ((int)datum))
-
-#define obstack_ptr_grow_fast(h,aptr) (*(*(char ***)&(h)->next_free)++ = (char *)aptr)
-#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint)
-#define obstack_blank(h,length) \
-( (h)->temp = (length), \
- (((h)->chunk_limit - (h)->next_free < (h)->temp) \
- ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
- (h)->next_free += (h)->temp)
-
-#define obstack_alloc(h,length) \
- (obstack_blank ((h), (length)), obstack_finish ((h)))
-
-#define obstack_copy(h,where,length) \
- (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
-
-#define obstack_copy0(h,where,length) \
- (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
-
-#define obstack_finish(h) \
-( ((h)->next_free == (h)->object_base \
- ? (((h)->maybe_empty_object = 1), 0) \
- : 0), \
- (h)->temp = __PTR_TO_INT ((h)->object_base), \
- (h)->next_free \
- = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
- & ~ ((h)->alignment_mask)), \
- (((h)->next_free - (char *)(h)->chunk \
- > (h)->chunk_limit - (char *)(h)->chunk) \
- ? ((h)->next_free = (h)->chunk_limit) : 0), \
- (h)->object_base = (h)->next_free, \
- __INT_TO_PTR ((h)->temp))
-
-#ifdef __STDC__
-#define obstack_free(h,obj) \
-( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \
- (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
- ? (int) ((h)->next_free = (h)->object_base \
- = (h)->temp + (char *) (h)->chunk) \
- : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
-#else
-#define obstack_free(h,obj) \
-( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \
- (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
- ? (int) ((h)->next_free = (h)->object_base \
- = (h)->temp + (char *) (h)->chunk) \
- : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
-#endif
-
-#endif /* not __GNUC__ or not __STDC__ */
-
-#endif /* not __OBSTACKS__ */
diff --git a/gnu/usr.bin/as/opcode/ChangeLog b/gnu/usr.bin/as/opcode/ChangeLog
deleted file mode 100644
index dcb0498..0000000
--- a/gnu/usr.bin/as/opcode/ChangeLog
+++ /dev/null
@@ -1,56 +0,0 @@
-Mon Feb 24 02:02:04 1992 K. Richard Pixley (rich@cygnus.com)
-
- * ns32k.h: SEQUENT_COMPATIBILITY -> TE_SEQUENT.
-
- * i860.h: added "fst.q".
-
-Fri Feb 21 01:29:51 1992 K. Richard Pixley (rich@cygnus.com)
-
- * i386.h: added inb, inw, outb, outw opcodes, added att syntax for
- scmp, slod, smov, ssca, ssto. Curtesy Minh Tran-Le
- <TRANLE@INTELLICORP.COM>.
-
-Thu Jan 30 07:31:44 1992 Steve Chamberlain (sac at rtl.cygnus.com)
-
- * h8300.h: turned op_type enum into #define list
-
-Thu Jan 30 01:07:24 1992 John Gilmore (gnu at cygnus.com)
-
- * sparc.h: Remove "cypress" architecture. Remove "fitox" and
- similar instructions -- they've been renamed to "fitoq", etc.
- REALLY fix tsubcctv. Fix "fcmpeq" and "fcmpq" which had wrong
- number of arguments.
- * h8300.h: Remove extra ; which produces compiler warning.
-
-Tue Jan 28 22:59:22 1992 Stu Grossman (grossman at cygnus.com)
-
- * sparc.h: fix opcode for tsubcctv.
-
-Tue Jan 7 17:19:39 1992 K. Richard Pixley (rich at cygnus.com)
-
- * sparc.h: fba and cba are now aliases for fb and cb respectively.
-
-Fri Dec 27 10:55:50 1991 Per Bothner (bothner at cygnus.com)
-
- * sparc.h (nop): Made the 'lose' field be even tighter,
- so only a standard 'nop' is disassembled as a nop.
-
-Sun Dec 22 12:18:18 1991 Michael Tiemann (tiemann at cygnus.com)
-
- * sparc.h (nop): Add RD_GO to `lose' so that only %g0 in dest is
- disassembled as a nop.
-
-Tue Dec 10 00:22:20 1991 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * sparc.h: fix a typo.
-
-Sat Nov 30 20:40:51 1991 Steve Chamberlain (sac at rtl.cygnus.com)
-
- * a29k.h, arm.h, h8300.h, i386.h, i860.h, i960.h , m68k.h,
- m88k.h, mips.h , np1.h, ns32k.h, pn.h, pyr.h, sparc.h, tahoe.h,
- vax.h, ChangeLog: renamed from ../<foo>-opcode.h
-
-
-
-
-
diff --git a/gnu/usr.bin/as/opcode/a29k.h b/gnu/usr.bin/as/opcode/a29k.h
deleted file mode 100644
index 8c36167..0000000
--- a/gnu/usr.bin/as/opcode/a29k.h
+++ /dev/null
@@ -1,327 +0,0 @@
-/* Table of opcodes for the AMD 29000
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
-
-This file is part of GDB and GAS.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-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; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-struct a29k_opcode {
- /* Name of the instruction. */
- char *name;
-
- /* Opcode word */
- unsigned long opcode;
-
- /* A string of characters which describe the operands.
- Valid characters are:
- , Itself. The character appears in the assembly code.
- a RA. The register number is in bits 8-15 of the instruction.
- b RB. The register number is in bits 0-7 of the instruction.
- c RC. The register number is in bits 16-23 of the instruction.
- i An immediate operand is in bits 0-7 of the instruction.
- x Bits 0-7 and 16-23 of the instruction are bits 0-7 and 8-15
- (respectively) of the immediate operand.
- h Same as x but the instruction contains bits 16-31 of the
- immediate operand.
- X Same as x but bits 16-31 of the signed immediate operand
- are set to 1 (thus the operand is always negative).
- P,A Bits 0-7 and 16-23 of the instruction are bits 2-9 and 10-17
- (respectively) of the immediate operand.
- P=PC-relative, sign-extended to 32 bits.
- A=Absolute, zero-extended to 32 bits.
- e CE bit (bit 23) for a load/store instruction.
- n Control field (bits 16-22) for a load/store instruction.
- v Immediate operand in bits 16-23 of the instruction.
- (used for trap numbers).
- s SA. Special-purpose register number in bits 8-15
- of the instruction.
- u UI--bit 7 of the instruction.
- r RND--bits 4-6 of the instruction.
- d FD--bits 2-3 of the instruction.
- f FS--bits 0-1 of the instruction.
-
- Extensions for 29050:
-
- d FMT--bits 2-3 of the instruction (not really new).
- f ACN--bits 0-1 of the instruction (not really new).
- F FUNC--Special function in bits 18-21 of the instruction.
- C ACN--bits 16-17 specifying the accumlator register. */
- char *args;
-};
-
-#ifndef CONST
-#define CONST
-#endif /* CONST */
-
-static CONST struct a29k_opcode a29k_opcodes[] =
-{
-
-{ "add", 0x14000000, "c,a,b" },
-{ "add", 0x15000000, "c,a,i" },
-{ "addc", 0x1c000000, "c,a,b" },
-{ "addc", 0x1d000000, "c,a,i" },
-{ "addcs", 0x18000000, "c,a,b" },
-{ "addcs", 0x19000000, "c,a,i" },
-{ "addcu", 0x1a000000, "c,a,b" },
-{ "addcu", 0x1b000000, "c,a,i" },
-{ "adds", 0x10000000, "c,a,b" },
-{ "adds", 0x11000000, "c,a,i" },
-{ "addu", 0x12000000, "c,a,b" },
-{ "addu", 0x13000000, "c,a,i" },
-{ "and", 0x90000000, "c,a,b" },
-{ "and", 0x91000000, "c,a,i" },
-{ "andn", 0x9c000000, "c,a,b" },
-{ "andn", 0x9d000000, "c,a,i" },
-{ "aseq", 0x70000000, "v,a,b" },
-{ "aseq", 0x71000000, "v,a,i" },
-{ "asge", 0x5c000000, "v,a,b" },
-{ "asge", 0x5d000000, "v,a,i" },
-{ "asgeu", 0x5e000000, "v,a,b" },
-{ "asgeu", 0x5f000000, "v,a,i" },
-{ "asgt", 0x58000000, "v,a,b" },
-{ "asgt", 0x59000000, "v,a,i" },
-{ "asgtu", 0x5a000000, "v,a,b" },
-{ "asgtu", 0x5b000000, "v,a,i" },
-{ "asle", 0x54000000, "v,a,b" },
-{ "asle", 0x55000000, "v,a,i" },
-{ "asleu", 0x56000000, "v,a,b" },
-{ "asleu", 0x57000000, "v,a,i" },
-{ "aslt", 0x50000000, "v,a,b" },
-{ "aslt", 0x51000000, "v,a,i" },
-{ "asltu", 0x52000000, "v,a,b" },
-{ "asltu", 0x53000000, "v,a,i" },
-{ "asneq", 0x72000000, "v,a,b" },
-{ "asneq", 0x73000000, "v,a,i" },
-{ "call", 0xa8000000, "a,P" },
-{ "call", 0xa9000000, "a,A" },
-{ "calli", 0xc8000000, "a,b" },
-{ "class", 0xe6000000, "c,a,f" },
-{ "clz", 0x08000000, "c,b" },
-{ "clz", 0x09000000, "c,i" },
-{ "const", 0x03000000, "a,x" },
-{ "consth", 0x02000000, "a,h" },
-{ "consthz", 0x05000000, "a,h" },
-{ "constn", 0x01000000, "a,X" },
-{ "convert", 0xe4000000, "c,a,u,r,d,f" },
-{ "cpbyte", 0x2e000000, "c,a,b" },
-{ "cpbyte", 0x2f000000, "c,a,i" },
-{ "cpeq", 0x60000000, "c,a,b" },
-{ "cpeq", 0x61000000, "c,a,i" },
-{ "cpge", 0x4c000000, "c,a,b" },
-{ "cpge", 0x4d000000, "c,a,i" },
-{ "cpgeu", 0x4e000000, "c,a,b" },
-{ "cpgeu", 0x4f000000, "c,a,i" },
-{ "cpgt", 0x48000000, "c,a,b" },
-{ "cpgt", 0x49000000, "c,a,i" },
-{ "cpgtu", 0x4a000000, "c,a,b" },
-{ "cpgtu", 0x4b000000, "c,a,i" },
-{ "cple", 0x44000000, "c,a,b" },
-{ "cple", 0x45000000, "c,a,i" },
-{ "cpleu", 0x46000000, "c,a,b" },
-{ "cpleu", 0x47000000, "c,a,i" },
-{ "cplt", 0x40000000, "c,a,b" },
-{ "cplt", 0x41000000, "c,a,i" },
-{ "cpltu", 0x42000000, "c,a,b" },
-{ "cpltu", 0x43000000, "c,a,i" },
-{ "cpneq", 0x62000000, "c,a,b" },
-{ "cpneq", 0x63000000, "c,a,i" },
-{ "dadd", 0xf1000000, "c,a,b" },
-{ "ddiv", 0xf7000000, "c,a,b" },
-{ "deq", 0xeb000000, "c,a,b" },
-{ "dge", 0xef000000, "c,a,b" },
-{ "dgt", 0xed000000, "c,a,b" },
-{ "div", 0x6a000000, "c,a,b" },
-{ "div", 0x6b000000, "c,a,i" },
-{ "div0", 0x68000000, "c,b" },
-{ "div0", 0x69000000, "c,i" },
-{ "divide", 0xe1000000, "c,a,b" },
-{ "dividu", 0xe3000000, "c,a,b" },
-{ "divl", 0x6c000000, "c,a,b" },
-{ "divl", 0x6d000000, "c,a,i" },
-{ "divrem", 0x6e000000, "c,a,b" },
-{ "divrem", 0x6f000000, "c,a,i" },
-{ "dmac", 0xd9000000, "F,C,a,b" },
-{ "dmsm", 0xdb000000, "c,a,b" },
-{ "dmul", 0xf5000000, "c,a,b" },
-{ "dsub", 0xf3000000, "c,a,b" },
-{ "emulate", 0xd7000000, "v,a,b" },
-{ "exbyte", 0x0a000000, "c,a,b" },
-{ "exbyte", 0x0b000000, "c,a,i" },
-{ "exhw", 0x7c000000, "c,a,b" },
-{ "exhw", 0x7d000000, "c,a,i" },
-{ "exhws", 0x7e000000, "c,a" },
-{ "extract", 0x7a000000, "c,a,b" },
-{ "extract", 0x7b000000, "c,a,i" },
-{ "fadd", 0xf0000000, "c,a,b" },
-{ "fdiv", 0xf6000000, "c,a,b" },
-{ "fdmul", 0xf9000000, "c,a,b" },
-{ "feq", 0xea000000, "c,a,b" },
-{ "fge", 0xee000000, "c,a,b" },
-{ "fgt", 0xec000000, "c,a,b" },
-{ "fmac", 0xd8000000, "F,C,a,b" },
-{ "fmsm", 0xda000000, "c,a,b" },
-{ "fmul", 0xf4000000, "c,a,b" },
-{ "fsub", 0xf2000000, "c,a,b" },
-{ "halt", 0x89000000, "" },
-{ "inbyte", 0x0c000000, "c,a,b" },
-{ "inbyte", 0x0d000000, "c,a,i" },
-{ "inhw", 0x78000000, "c,a,b" },
-{ "inhw", 0x79000000, "c,a,i" },
-{ "inv", 0x9f000000, "" },
-{ "iret", 0x88000000, "" },
-{ "iretinv", 0x8c000000, "" },
-{ "jmp", 0xa0000000, "P" },
-{ "jmp", 0xa1000000, "A" },
-{ "jmpf", 0xa4000000, "a,P" },
-{ "jmpf", 0xa5000000, "a,A" },
-{ "jmpfdec", 0xb4000000, "a,P" },
-{ "jmpfdec", 0xb5000000, "a,A" },
-{ "jmpfi", 0xc4000000, "a,b" },
-{ "jmpi", 0xc0000000, "b" },
-{ "jmpt", 0xac000000, "a,P" },
-{ "jmpt", 0xad000000, "a,A" },
-{ "jmpti", 0xcc000000, "a,b" },
-{ "load", 0x16000000, "e,n,a,b" },
-{ "load", 0x17000000, "e,n,a,i" },
-{ "loadl", 0x06000000, "e,n,a,b" },
-{ "loadl", 0x07000000, "e,n,a,i" },
-{ "loadm", 0x36000000, "e,n,a,b" },
-{ "loadm", 0x37000000, "e,n,a,i" },
-{ "loadset", 0x26000000, "e,n,a,b" },
-{ "loadset", 0x27000000, "e,n,a,i" },
-{ "mfacc", 0xe9000100, "c,d,f" },
-{ "mfsr", 0xc6000000, "c,s" },
-{ "mftlb", 0xb6000000, "c,a" },
-{ "mtacc", 0xe8010000, "a,d,f" },
-{ "mtsr", 0xce000000, "s,b" },
-{ "mtsrim", 0x04000000, "s,x" },
-{ "mttlb", 0xbe000000, "a,b" },
-{ "mul", 0x64000000, "c,a,b" },
-{ "mul", 0x65000000, "c,a,i" },
-{ "mull", 0x66000000, "c,a,b" },
-{ "mull", 0x67000000, "c,a,i" },
-{ "multiplu", 0xe2000000, "c,a,b" },
-{ "multiply", 0xe0000000, "c,a,b" },
-{ "multm", 0xde000000, "c,a,b" },
-{ "multmu", 0xdf000000, "c,a,b" },
-{ "mulu", 0x74000000, "c,a,b" },
-{ "mulu", 0x75000000, "c,a,i" },
-{ "nand", 0x9a000000, "c,a,b" },
-{ "nand", 0x9b000000, "c,a,i" },
-{ "nop", 0x70400101, "" },
-{ "nor", 0x98000000, "c,a,b" },
-{ "nor", 0x99000000, "c,a,i" },
-{ "or", 0x92000000, "c,a,b" },
-{ "or", 0x93000000, "c,a,i" },
-{ "orn", 0xaa000000, "c,a,b" },
-{ "orn", 0xab000000, "c,a,i" },
-
-/* The description of "setip" in Chapter 8 ("instruction set") of the user's
- manual claims that these are absolute register numbers. But section
- 7.2.1 explains that they are not. The latter is correct, so print
- these normally ("lr0", "lr5", etc.). */
-{ "setip", 0x9e000000, "c,a,b" },
-
-{ "sll", 0x80000000, "c,a,b" },
-{ "sll", 0x81000000, "c,a,i" },
-{ "sqrt", 0xe5000000, "c,a,f" },
-{ "sra", 0x86000000, "c,a,b" },
-{ "sra", 0x87000000, "c,a,i" },
-{ "srl", 0x82000000, "c,a,b" },
-{ "srl", 0x83000000, "c,a,i" },
-{ "store", 0x1e000000, "e,n,a,b" },
-{ "store", 0x1f000000, "e,n,a,i" },
-{ "storel", 0x0e000000, "e,n,a,b" },
-{ "storel", 0x0f000000, "e,n,a,i" },
-{ "storem", 0x3e000000, "e,n,a,b" },
-{ "storem", 0x3f000000, "e,n,a,i" },
-{ "sub", 0x24000000, "c,a,b" },
-{ "sub", 0x25000000, "c,a,i" },
-{ "subc", 0x2c000000, "c,a,b" },
-{ "subc", 0x2d000000, "c,a,i" },
-{ "subcs", 0x28000000, "c,a,b" },
-{ "subcs", 0x29000000, "c,a,i" },
-{ "subcu", 0x2a000000, "c,a,b" },
-{ "subcu", 0x2b000000, "c,a,i" },
-{ "subr", 0x34000000, "c,a,b" },
-{ "subr", 0x35000000, "c,a,i" },
-{ "subrc", 0x3c000000, "c,a,b" },
-{ "subrc", 0x3d000000, "c,a,i" },
-{ "subrcs", 0x38000000, "c,a,b" },
-{ "subrcs", 0x39000000, "c,a,i" },
-{ "subrcu", 0x3a000000, "c,a,b" },
-{ "subrcu", 0x3b000000, "c,a,i" },
-{ "subrs", 0x30000000, "c,a,b" },
-{ "subrs", 0x31000000, "c,a,i" },
-{ "subru", 0x32000000, "c,a,b" },
-{ "subru", 0x33000000, "c,a,i" },
-{ "subs", 0x20000000, "c,a,b" },
-{ "subs", 0x21000000, "c,a,i" },
-{ "subu", 0x22000000, "c,a,b" },
-{ "subu", 0x23000000, "c,a,i" },
-{ "xnor", 0x96000000, "c,a,b" },
-{ "xnor", 0x97000000, "c,a,i" },
-{ "xor", 0x94000000, "c,a,b" },
-{ "xor", 0x95000000, "c,a,i" },
-
-{ "", 0x0, "" } /* Dummy entry, not included in NUM_OPCODES. This
- lets code examine entry i+1 without checking
- if we've run off the end of the table. */
-};
-
-CONST unsigned int num_opcodes = (((sizeof a29k_opcodes) / (sizeof a29k_opcodes[0])) - 1);
-
-/*
- * $Log: a29k.h,v $
- * Revision 1.1 1993/10/02 21:00:40 pk
- * GNU gas 1.92.3 based assembler supporting PIC code (for i386 and sparc).
- *
- * Revision 1.2 1992/02/29 17:10:43 rich
- * various smallish fixes from mail archives
- *
- * Revision 1.1.1.1 1992/02/24 02:34:30 rich
- * devo fork
- *
- * Revision 1.1 1991/12/01 02:22:19 sac
- * Initial revision
- *
- * Revision 1.5 1991/11/07 16:59:19 sac
- * Fixed encoding of mtacc instruction.
- *
- * Revision 1.4 1991/08/06 07:20:27 rich
- * Fixing CONST declarations.
- *
- * Revision 1.3 1991/08/05 22:31:05 rich
- * *** empty log message ***
- *
- * Revision 1.2 1991/07/15 23:34:04 steve
- * *** empty log message ***
- *
- * Revision 1.1 1991/05/19 00:19:33 rich
- * Initial revision
- *
- * Revision 1.1.1.1 1991/04/04 18:15:23 rich
- * new gas main line
- *
- * Revision 1.1 1991/04/04 18:15:23 rich
- * Initial revision
- *
- * Revision 1.2 1991/03/30 17:13:19 rich
- * num_opcodes now unsigned. Also, added rcsid and log.
- *
- *
- */
-
-/* end of a29k-opcode.h */
diff --git a/gnu/usr.bin/as/opcode/h8300.h b/gnu/usr.bin/as/opcode/h8300.h
deleted file mode 100644
index 59dea0d..0000000
--- a/gnu/usr.bin/as/opcode/h8300.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/* Opcode table for the H8-300
- Copyright (C) 1991,1992 Free Software Foundation.
- Written by Steve Chamberlain, sac@cygnus.com.
-
-This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler.
-
-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 of the License, 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. */
-
-typedef int op_type;
-
-#define Hex0 0
-#define Hex1 1
-#define Hex2 2
-#define Hex3 3
-#define Hex4 4
-#define Hex5 5
-#define Hex6 6
-#define Hex7 7
-#define Hex8 8
-#define Hex9 9
-#define HexA 10
-#define HexB 11
-#define HexC 12
-#define HexD 13
-#define HexE 14
-#define HexF 15
-#define START 0x20
-#define KBIT 0x21 /* K is #1, or #2, yielding 0x0 or 0x8 */
-#define IMM3 0x22 /* bit number */
-#define RD8 0x23 /* 8 bit reg as 2nd op */
-#define RD16 0x24 /* 16 bit reg as 2nd op */
-#define RS8 0x25 /* 8 bit reg as 1st op */
-#define RS16 0x26 /* 16 bit reg 1st op */
-#define IMM8 0x27 /* constant which fits into 8 bits */
-#define IMM16 0x28 /* constant which fits into 16 bits */
-#define CCR 0x29 /* CCR reg */
-#define ABS8SRC 0x2a /* abs 8 address mode */
-#define ABS8DST 0x2b /* abs 8 address mode */
-#define DISP8 0x2c /* pc rel displacement */
-#define ABS16SRC 0x2d /* abs 16 address mode */
-#define ABS16OR8SRC 0x2e /* abs 16 address mode, but could be abs 8 */
-#define ABS16DST 0x2f /* abs 16 address mode */
-#define ABS16OR8DST 0x30 /* abs 16 address mode */
-#define DISPSRC 0x31 /* @(r:16) address mode src */
-#define DISPDST 0x32 /* @(r:16) address mode dst*/
-#define DISPREG 0x33 /* register from DISP address mode */
-#define RDDEC 0x34 /* @-rn mode */
-#define RSINC 0x35 /* @rn+ mode */
-#define RDIND 0x36 /* @R mode dst */
-#define RSIND 0x37 /* @R mode src */
-#define MEMIND 0x38 /* @@abs8 mode */
-#define ABS16ORREL8SRC 0x39 /* abs 16bit or pcrel */
-#define IGNORE 0x3a
-#define B30 0x40 /* bit 3 must be low */
-#define B31 0x80 /* bit 3 must be high */
-#define E 0x81 /* End of list */
-
-
-
-struct code
-{
- op_type nib[9];
-} ;
-
-struct arg
-{
- op_type nib[3];
-} ;
-
-struct h8_opcode
-{
- char *name;
- struct arg args;
- struct code data;
- char length;
- char noperands;
- char idx;
- char size;
-
-};
-
-
-
-
-
-#ifdef DEFINE_TABLE
-
-#define BITOP(imm, name, op00, op01,op10,op11, op20,op21)\
-{ name, {imm,RD8,E}, {op00, op01, imm, RD8,E}},\
-{ name, {imm,RDIND,E}, {op10, op11, RDIND, 0, op00,op01, imm, 0,E}},\
-{ name, {imm,ABS8DST,E},{op20, op21, ABS8DST, IGNORE, op00,op01, imm, 0,E}}
-
-#define EBITOP(imm, name, op00, op01,op10,op11, op20,op21)\
- BITOP(imm, name, op00+1, op01, op10,op11, op20,op21),\
- BITOP(RS8, name, op00, op01, op10,op11, op20,op21)
-
-#define WTWOP(name, op1, op2) \
-{ name, {RS16, RD16, E}, { op1, op2, RS16, RD16, E}}
-
-#define BRANCH(name, op) \
-{ name,{DISP8,E}, { Hex4, op, DISP8,IGNORE,E }}
-
-#define SOP(name) \
-{ name
-#define EOP }
-
-
-#define TWOOP(name, op1, op2,op3) \
-{ name, {IMM8, RD8,E}, { op1, RD8, IMM8,IGNORE,E}},\
-{ name, {RS8, RD8, E}, { op2, op3, RS8, RD8 ,E}}
-
-#define UNOP(name, op1, op2) \
-{ name, {RS8, E}, { op1, op2, 0, RS8, E}}
-
-#define UNOP3(name, op1, op2, op3) \
-{ name , {RS8, E}, {op1, op2, op3, RS8, E}}
-
-struct h8_opcode h8_opcodes[]
-=
-{
- TWOOP("add.b", Hex8, Hex0,Hex8),
- WTWOP("add.w", Hex0, Hex9),
- SOP("adds"), {KBIT,RD16|B30, E}, {Hex0, HexB, KBIT, RD16|B30, E} EOP,
- TWOOP("addx", Hex9,Hex0,HexE),
- TWOOP("and", HexE,Hex1,Hex6),
- SOP("andc"), {IMM8, CCR, E}, { Hex0, Hex6, IMM8,IGNORE, E} EOP,
- BITOP(IMM3|B30, "band", Hex7, Hex6, Hex7, HexC, Hex7, HexE),
- BRANCH("bra", Hex0),
- BRANCH("bt", Hex0),
- BRANCH("brn", Hex1),
- BRANCH("bf", Hex1),
- BRANCH("bhi", Hex2),
- BRANCH("bls", Hex3),
- BRANCH("bcc", Hex4),
- BRANCH("bhs", Hex4),
- BRANCH("bcs", Hex5),
- BRANCH("blo", Hex5),
- BRANCH("bne", Hex6),
- BRANCH("beq", Hex7),
- BRANCH("bvc", Hex8),
- BRANCH("bvs", Hex9),
- BRANCH("bpl", HexA),
- BRANCH("bmi", HexB),
- BRANCH("bge", HexC),
- BRANCH("blt", HexD),
- BRANCH("bgt", HexE),
- BRANCH("ble", HexF),
- EBITOP(IMM3|B30,"bclr", Hex6, Hex2, Hex7, HexD, Hex7, HexF),
- BITOP(IMM3|B31,"biand", Hex7, Hex6, Hex7, HexC, Hex7, HexE),
- BITOP(IMM3|B31, "bild", Hex7, Hex7,Hex7, HexC, Hex7, HexE),
- BITOP(IMM3|B31, "bior", Hex7, Hex4,Hex7, HexC, Hex7, HexE),
- BITOP(IMM3|B31, "bist", Hex6, Hex7,Hex7, HexD, Hex7, HexE),
- BITOP(IMM3|B31, "bixor", Hex7, Hex5,Hex7, HexC, Hex7, HexE),
- BITOP(IMM3|B30, "bld", Hex7, Hex7,Hex7, HexC, Hex7, HexE),
- EBITOP(IMM3|B30,"bnot", Hex6, Hex1, Hex7, HexD, Hex7, HexF),
- BITOP(IMM3|B30,"bor", Hex7, Hex4,Hex7, HexC, Hex7, HexE),
- EBITOP(IMM3|B30,"bset", Hex6, Hex0,Hex7, HexD, Hex7, HexF),
- SOP("bsr"),{DISP8, E},{ Hex5, Hex5, DISP8,IGNORE, E}, EOP,
- BITOP(IMM3|B30, "bst", Hex6, Hex7,Hex7, HexD, Hex7, HexF),
- EBITOP(IMM3|B30, "btst", Hex6, Hex3,Hex7, HexC, Hex7, HexE),
- BITOP(IMM3|B30, "bxor", Hex7,Hex5,Hex7, HexC, Hex7, HexE),
- TWOOP( "cmp.b",HexA, Hex1, HexC),
- WTWOP( "cmp.w",Hex1,HexD),
- UNOP( "daa",Hex0, HexF),
- UNOP( "das",Hex1, HexF),
- UNOP( "dec",Hex1, HexA),
- SOP("divxu"),{RS8, RD16|B30, E}, { Hex5, Hex1, RS8, RD16|B30, E} EOP,
- SOP("eepmov"),{ E}, {Hex7, HexB, Hex5, HexC, Hex5, Hex9, Hex8, HexF,E} EOP,
- UNOP( "inc", Hex0, HexA),
- SOP("jmp"),{RSIND|B30, E}, {Hex5, Hex9, RSIND|B30, Hex0, E} EOP,
- SOP("jmp"),{ABS16ORREL8SRC, E}, {Hex5, HexA, Hex0, Hex0, ABS16ORREL8SRC, IGNORE,IGNORE,IGNORE,E} EOP,
- SOP("jmp"),{MEMIND, E}, {Hex5, HexB, MEMIND,IGNORE, E} EOP,
- SOP("jsr"),{RSIND|B30, E}, {Hex5, HexD, RSIND|B30, Hex0, E} EOP,
- SOP("jsr"),{ABS16ORREL8SRC, E}, {Hex5, HexE, Hex0, Hex0,
- ABS16ORREL8SRC,IGNORE,IGNORE,IGNORE, E} EOP,
- SOP("jsr"),{MEMIND, E}, {Hex5, HexF, MEMIND, IGNORE,E} EOP,
- SOP("ldc"),{IMM8, CCR, E}, { Hex0, Hex7, IMM8,IGNORE, E} EOP,
- SOP("ldc"),{RS8, CCR, E}, { Hex0, Hex3, Hex0, RS8, E} EOP,
- SOP("mov.b"),{RS8, RD8, E}, { Hex0, HexC, RS8, RD8, E} EOP,
- SOP("mov.b"),{IMM8, RD8, E}, { HexF, RD8, IMM8,IGNORE, E} EOP,
- SOP("mov.b"),{RSIND|B30,RD8, E}, { Hex6, Hex8, RSIND|B30, RD8, E} EOP,
- SOP("mov.b"),{DISPSRC,RD8, E}, { Hex6, HexE, DISPREG|B30, RD8,
- DISPSRC, IGNORE, IGNORE, IGNORE, E} EOP,
- SOP("mov.b"),{RSINC|B30, RD8, E}, { Hex6, HexC, RSINC|B30, RD8, E} EOP,
- SOP("mov.b"),{ABS16OR8SRC, RD8, E}, { Hex6, HexA, Hex0, RD8,ABS16OR8SRC,
- IGNORE,IGNORE,IGNORE,E} EOP,
- SOP("mov.b"),{ABS8SRC, RD8, E}, { Hex2, RD8, ABS8SRC,IGNORE, E} EOP,
- SOP("mov.b"),{RS8, RDIND|B30, E}, { Hex6, Hex8, RDIND|B31, RS8, E} EOP,
- SOP("mov.b"),{RS8, DISPDST, E}, { Hex6, HexE, DISPREG|B31,
- RS8,DISPDST, IGNORE, IGNORE, IGNORE, E} EOP,
- SOP("mov.b"),{RS8, RDDEC|B31, E}, { Hex6, HexC, RDDEC|B31, RS8, E} EOP,
- SOP( "mov.b"),{RS8, ABS16OR8DST, E}, { Hex6, HexA, Hex8, RS8,
- ABS16OR8DST,IGNORE,IGNORE,IGNORE, E} EOP,
- SOP( "mov.b"),{RS8, ABS8DST, E}, { Hex3, RS8, ABS8DST,IGNORE, E} EOP,
- SOP( "mov.w"),{RS16|B30, RD16|B30, E},{ Hex0, HexD, RS16|B30,
- RD16|B30, E} EOP,
- SOP("mov.w"),{IMM16, RD16|B30, E}, { Hex7, Hex9, Hex0, RD16|B30,
- IMM16,IGNORE,IGNORE,IGNORE, E} EOP,
- SOP("mov.w"),{RSIND|B30,RD16|B30, E},{ Hex6, Hex9, RSIND|B30,
- RD16|B30, E} EOP,
- SOP("mov.w"),{DISPSRC,RD16|B30, E}, { Hex6, HexF, DISPREG|B30,
- RD16|B30, DISPSRC, IGNORE, IGNORE, IGNORE,E} EOP,
- SOP("mov.w"),{RSINC|B30, RD16|B30, E}, { Hex6, HexD, RSINC|B30,
- RD16|B30, E}EOP,
- SOP("mov.w"), {ABS16SRC, RD16|B30, E}, { Hex6, HexB, Hex0,
- RD16|B30,ABS16SRC,IGNORE,IGNORE,IGNORE, E} EOP,
-SOP("mov.w"), {RS16|B30, RDIND|B30, E},{ Hex6, Hex9, RDIND|B31,
- RS16|B30, E} EOP,
-SOP("mov.w"), {RS16|B30, DISPDST, E}, { Hex6, HexF, DISPREG|B31,
- RS16|B30,DISPDST, IGNORE,IGNORE,IGNORE,E} EOP,
-SOP("mov.w"), {RS16|B30, RDDEC|B30, E},{ Hex6, HexD, RDDEC|B31,
- RS16|B30, E} EOP,
-SOP("mov.w"), {RS16|B30, ABS16DST, E}, { Hex6, HexB, Hex8, RS16|B30,
- ABS16DST, IGNORE, IGNORE, IGNORE, E} EOP,
-SOP("movfpe"), {ABS16SRC, RD8, E}, { Hex6, HexA, Hex4, RD8,
- ABS16SRC,IGNORE,IGNORE,IGNORE, E} EOP,
-SOP("movtpe"), {RS8, ABS16DST, E}, { Hex6, HexA, HexC, RS8,
- ABS16DST,IGNORE,IGNORE,IGNORE,
- E} EOP,
-SOP("mulxu"), {RS8, RD16|B30, E}, { Hex5, Hex0, RS8, RD16|B30, E} EOP,
-SOP( "neg"), {RS8, E}, { Hex1, Hex7, Hex8, RS8, E} EOP,
-SOP( "nop"), {E}, { Hex0, Hex0, Hex0, Hex0,E} EOP,
-SOP( "not"), {RS8,E}, { Hex1, Hex7, Hex0, RS8,E} EOP,
-TWOOP("or", HexC, Hex1, Hex4),
-SOP( "orc"), {IMM8, CCR,E}, { Hex0, Hex4, IMM8,IGNORE,E} EOP,
-SOP( "pop"), {RS16|B30,E}, { Hex6, HexD, Hex7, RS16|B30,E} EOP,
-SOP( "push"), {RS16|B30,E}, { Hex6, HexD, HexF, RS16|B30,E} EOP,
- UNOP3( "rotl",Hex1, Hex2,Hex8),
- UNOP3( "rotr",Hex1, Hex3, Hex8),
- UNOP3( "rotxl",Hex1, Hex2, Hex0),
- UNOP3( "rotxr",Hex1, Hex3, Hex0),
-SOP("rte"), {E}, { Hex5, Hex6, Hex7, Hex0,E} EOP,
-SOP("rts"), {E}, { Hex5, Hex4, Hex7, Hex0,E} EOP,
- UNOP3( "shal", Hex1, Hex0, Hex8),
- UNOP3( "shar", Hex1, Hex1, Hex8),
- UNOP3( "shll", Hex1, Hex0, Hex0),
- UNOP3( "shlr", Hex1, Hex1, Hex0),
-SOP("sleep"), {E}, { Hex0, Hex1, Hex8, Hex0,E} EOP,
-SOP("stc"), {CCR, RD8,E}, { Hex0, Hex2, Hex0, RD8,E} EOP,
-SOP("sub.b"), {RS8,RD8,E}, { Hex1, Hex8, RS8, RD8,E} EOP,
-SOP("sub.w"), {RS16|B30, RD16|B30,E}, {Hex1, Hex9, RS16|B30,RD16|B30,E} EOP,
-SOP("subs"), {KBIT,RD16|B30,E}, { Hex1, HexB, KBIT, RD16|B30,E} EOP,
- TWOOP("subx",HexB, Hex1, HexE),
- TWOOP("xor", HexD, Hex1, Hex5),
-SOP("xorc"), {IMM8, CCR,E}, { Hex0, Hex5, IMM8,IGNORE,E} EOP,
- 0
-};
-#else
-extern struct h8_opcode h8_opcodes[] ;
-#endif
-
-
-
-
diff --git a/gnu/usr.bin/as/opcode/i386.h b/gnu/usr.bin/as/opcode/i386.h
deleted file mode 100644
index 6a9e9c9..0000000
--- a/gnu/usr.bin/as/opcode/i386.h
+++ /dev/null
@@ -1,880 +0,0 @@
-/* i386-opcode.h -- Intel 80386 opcode table
- Copyright (C) 1989, 1991, Free Software Foundation.
-
-This file is part of GAS, the GNU Assembler.
-
-GAS is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GAS 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 GAS; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* $Id: i386.h,v 1.7 1997/02/22 15:44:29 peter Exp $ */
-
-static const template i386_optab[] = {
-
-#define _ None
-/* move instructions */
-{ "mov", 2, 0xa0, _, DW|NoModrm, Disp32, Acc, 0 },
-{ "mov", 2, 0x88, _, DW|Modrm, Reg, Reg|Mem, 0 },
-{ "mov", 2, 0xb0, _, ShortFormW, Imm, Reg, 0 },
-{ "mov", 2, 0xc6, _, W|Modrm, Imm, Reg|Mem, 0 },
-{ "mov", 2, 0x8c, _, D|Modrm, SReg3|SReg2, WordReg|WordMem, 0 },
-/* move to/from control debug registers */
-{ "mov", 2, 0x0f20, _, D|Modrm, Control, Reg32, 0},
-{ "mov", 2, 0x0f21, _, D|Modrm, Debug, Reg32, 0},
-{ "mov", 2, 0x0f24, _, D|Modrm, Test, Reg32, 0},
-
-/* move with sign extend */
-/* "movsbl" & "movsbw" must not be unified into "movsb" to avoid
- conflict with the "movs" string move instruction. Thus,
- {"movsb", 2, 0x0fbe, _, ReverseRegRegmem|Modrm, Reg8|Mem, Reg16|Reg32, 0},
- is not kosher; we must seperate the two instructions. */
-{"movsbl", 2, 0x0fbe, _, ReverseRegRegmem|Modrm, Reg8|Mem, Reg32, 0},
-{"movsbw", 2, 0x660fbe, _, ReverseRegRegmem|Modrm, Reg8|Mem, Reg16, 0},
-{"movswl", 2, 0x0fbf, _, ReverseRegRegmem|Modrm, Reg16|Mem, Reg32, 0},
-
-/* move with zero extend */
-{"movzb", 2, 0x0fb6, _, ReverseRegRegmem|Modrm, Reg8|Mem, Reg16|Reg32, 0},
-{"movzwl", 2, 0x0fb7, _, ReverseRegRegmem|Modrm, Reg16|Mem, Reg32, 0},
-
-/* push instructions */
-{"push", 1, 0x50, _, ShortForm, WordReg,0,0 },
-{"push", 1, 0xff, 0x6, Modrm, WordReg|WordMem, 0, 0 },
-{"push", 1, 0x6a, _, NoModrm, Imm8S, 0, 0},
-{"push", 1, 0x68, _, NoModrm, Imm16|Imm32, 0, 0},
-{"push", 1, 0x06, _, Seg2ShortForm, SReg2,0,0 },
-{"push", 1, 0x0fa0, _, Seg3ShortForm, SReg3,0,0 },
-/* push all */
-{"pusha", 0, 0x60, _, NoModrm, 0, 0, 0 },
-
-/* pop instructions */
-{"pop", 1, 0x58, _, ShortForm, WordReg,0,0 },
-{"pop", 1, 0x8f, 0x0, Modrm, WordReg|WordMem, 0, 0 },
-#define POP_SEG_SHORT 0x7
-{"pop", 1, 0x07, _, Seg2ShortForm, SReg2,0,0 },
-{"pop", 1, 0x0fa1, _, Seg3ShortForm, SReg3,0,0 },
-/* pop all */
-{"popa", 0, 0x61, _, NoModrm, 0, 0, 0 },
-
-/* xchg exchange instructions
- xchg commutes: we allow both operand orders */
-{"xchg", 2, 0x90, _, ShortForm, WordReg, Acc, 0 },
-{"xchg", 2, 0x90, _, ShortForm, Acc, WordReg, 0 },
-{"xchg", 2, 0x86, _, W|Modrm, Reg, Reg|Mem, 0 },
-{"xchg", 2, 0x86, _, W|Modrm, Reg|Mem, Reg, 0 },
-
-/* in/out from ports */
-{"in", 2, 0xe4, _, W|NoModrm, Imm8, Acc, 0 },
-{"in", 2, 0xec, _, W|NoModrm, InOutPortReg, Acc, 0 },
-{"out", 2, 0xe6, _, W|NoModrm, Acc, Imm8, 0 },
-{"out", 2, 0xee, _, W|NoModrm, Acc, InOutPortReg, 0 },
-
-#if 0
-{"inb", 1, 0xe4, _, NoModrm, Imm8, 0, 0 },
-{"inb", 1, 0xec, _, NoModrm, WordMem, 0, 0 },
-{"inw", 1, 0x66e5, _, NoModrm, Imm8, 0, 0 },
-{"inw", 1, 0x66ed, _, NoModrm, WordMem, 0, 0 },
-{"outb", 1, 0xe6, _, NoModrm, Imm8, 0, 0 },
-{"outb", 1, 0xee, _, NoModrm, WordMem, 0, 0 },
-{"outw", 1, 0x66e7, _, NoModrm, Imm8, 0, 0 },
-{"outw", 1, 0x66ef, _, NoModrm, WordMem, 0, 0 },
-#endif
-
-/* load effective address */
-{"lea", 2, 0x8d, _, Modrm, WordMem, WordReg, 0 },
-
-/* load segment registers from memory */
-{"lds", 2, 0xc5, _, Modrm, Mem, Reg32, 0},
-{"les", 2, 0xc4, _, Modrm, Mem, Reg32, 0},
-{"lfs", 2, 0x0fb4, _, Modrm, Mem, Reg32, 0},
-{"lgs", 2, 0x0fb5, _, Modrm, Mem, Reg32, 0},
-{"lss", 2, 0x0fb2, _, Modrm, Mem, Reg32, 0},
-
-/* flags register instructions */
-{"clc", 0, 0xf8, _, NoModrm, 0, 0, 0},
-{"cld", 0, 0xfc, _, NoModrm, 0, 0, 0},
-{"cli", 0, 0xfa, _, NoModrm, 0, 0, 0},
-{"clts", 0, 0x0f06, _, NoModrm, 0, 0, 0},
-{"cmc", 0, 0xf5, _, NoModrm, 0, 0, 0},
-{"lahf", 0, 0x9f, _, NoModrm, 0, 0, 0},
-{"sahf", 0, 0x9e, _, NoModrm, 0, 0, 0},
-{"pushf", 0, 0x9c, _, NoModrm, 0, 0, 0},
-{"popf", 0, 0x9d, _, NoModrm, 0, 0, 0},
-{"stc", 0, 0xf9, _, NoModrm, 0, 0, 0},
-{"std", 0, 0xfd, _, NoModrm, 0, 0, 0},
-{"sti", 0, 0xfb, _, NoModrm, 0, 0, 0},
-
-{"add", 2, 0x0, _, DW|Modrm, Reg, Reg|Mem, 0},
-{"add", 2, 0x83, 0, Modrm, Imm8S, WordReg|WordMem, 0},
-{"add", 2, 0x4, _, W|NoModrm, Imm, Acc, 0},
-{"add", 2, 0x80, 0, W|Modrm, Imm, Reg|Mem, 0},
-
-{"inc", 1, 0x40, _, ShortForm, WordReg, 0, 0},
-{"inc", 1, 0xfe, 0, W|Modrm, Reg|Mem, 0, 0},
-
-{"sub", 2, 0x28, _, DW|Modrm, Reg, Reg|Mem, 0},
-{"sub", 2, 0x83, 5, Modrm, Imm8S, WordReg|WordMem, 0},
-{"sub", 2, 0x2c, _, W|NoModrm, Imm, Acc, 0},
-{"sub", 2, 0x80, 5, W|Modrm, Imm, Reg|Mem, 0},
-
-{"dec", 1, 0x48, _, ShortForm, WordReg, 0, 0},
-{"dec", 1, 0xfe, 1, W|Modrm, Reg|Mem, 0, 0},
-
-{"sbb", 2, 0x18, _, DW|Modrm, Reg, Reg|Mem, 0},
-{"sbb", 2, 0x83, 3, Modrm, Imm8S, WordReg|WordMem, 0},
-{"sbb", 2, 0x1c, _, W|NoModrm, Imm, Acc, 0},
-{"sbb", 2, 0x80, 3, W|Modrm, Imm, Reg|Mem, 0},
-
-{"cmp", 2, 0x38, _, DW|Modrm, Reg, Reg|Mem, 0},
-{"cmp", 2, 0x83, 7, Modrm, Imm8S, WordReg|WordMem, 0},
-{"cmp", 2, 0x3c, _, W|NoModrm, Imm, Acc, 0},
-{"cmp", 2, 0x80, 7, W|Modrm, Imm, Reg|Mem, 0},
-
-{"test", 2, 0x84, _, W|Modrm, Reg|Mem, Reg, 0},
-{"test", 2, 0x84, _, W|Modrm, Reg, Reg|Mem, 0},
-{"test", 2, 0xa8, _, W|NoModrm, Imm, Acc, 0},
-{"test", 2, 0xf6, 0, W|Modrm, Imm, Reg|Mem, 0},
-
-{"and", 2, 0x20, _, DW|Modrm, Reg, Reg|Mem, 0},
-{"and", 2, 0x83, 4, Modrm, Imm8S, WordReg|WordMem, 0},
-{"and", 2, 0x24, _, W|NoModrm, Imm, Acc, 0},
-{"and", 2, 0x80, 4, W|Modrm, Imm, Reg|Mem, 0},
-
-{"or", 2, 0x08, _, DW|Modrm, Reg, Reg|Mem, 0},
-{"or", 2, 0x83, 1, Modrm, Imm8S, WordReg|WordMem, 0},
-{"or", 2, 0x0c, _, W|NoModrm, Imm, Acc, 0},
-{"or", 2, 0x80, 1, W|Modrm, Imm, Reg|Mem, 0},
-
-{"xor", 2, 0x30, _, DW|Modrm, Reg, Reg|Mem, 0},
-{"xor", 2, 0x83, 6, Modrm, Imm8S, WordReg|WordMem, 0},
-{"xor", 2, 0x34, _, W|NoModrm, Imm, Acc, 0},
-{"xor", 2, 0x80, 6, W|Modrm, Imm, Reg|Mem, 0},
-
-{"adc", 2, 0x10, _, DW|Modrm, Reg, Reg|Mem, 0},
-{"adc", 2, 0x83, 2, Modrm, Imm8S, WordReg|WordMem, 0},
-{"adc", 2, 0x14, _, W|NoModrm, Imm, Acc, 0},
-{"adc", 2, 0x80, 2, W|Modrm, Imm, Reg|Mem, 0},
-
-{"neg", 1, 0xf6, 3, W|Modrm, Reg|Mem, 0, 0},
-{"not", 1, 0xf6, 2, W|Modrm, Reg|Mem, 0, 0},
-
-{"aaa", 0, 0x37, _, NoModrm, 0, 0, 0},
-{"aas", 0, 0x3f, _, NoModrm, 0, 0, 0},
-{"daa", 0, 0x27, _, NoModrm, 0, 0, 0},
-{"das", 0, 0x2f, _, NoModrm, 0, 0, 0},
-{"aad", 0, 0xd50a, _, NoModrm, 0, 0, 0},
-{"aam", 0, 0xd40a, _, NoModrm, 0, 0, 0},
-
-/* conversion insns */
-/* conversion: intel naming */
-{"cbw", 0, 0x6698, _, NoModrm, 0, 0, 0},
-{"cwd", 0, 0x6699, _, NoModrm, 0, 0, 0},
-{"cwde", 0, 0x98, _, NoModrm, 0, 0, 0},
-{"cdq", 0, 0x99, _, NoModrm, 0, 0, 0},
-/* att naming */
-{"cbtw", 0, 0x6698, _, NoModrm, 0, 0, 0},
-{"cwtl", 0, 0x98, _, NoModrm, 0, 0, 0},
-{"cwtd", 0, 0x6699, _, NoModrm, 0, 0, 0},
-{"cltd", 0, 0x99, _, NoModrm, 0, 0, 0},
-
-/* Warning! the mul/imul (opcode 0xf6) must only have 1 operand! They are
- expanding 64-bit multiplies, and *cannot* be selected to accomplish
- 'imul %ebx, %eax' (opcode 0x0faf must be used in this case)
- These multiplies can only be selected with single opearnd forms. */
-{"mul", 1, 0xf6, 4, W|Modrm, Reg|Mem, 0, 0},
-{"imul", 1, 0xf6, 5, W|Modrm, Reg|Mem, 0, 0},
-
-
-
-
-/* imulKludge here is needed to reverse the i.rm.reg & i.rm.regmem fields.
- These instructions are exceptions: 'imul $2, %eax, %ecx' would put
- '%eax' in the reg field and '%ecx' in the regmem field if we did not
- switch them. */
-{"imul", 2, 0x0faf, _, Modrm|ReverseRegRegmem, WordReg|Mem, WordReg, 0},
-{"imul", 3, 0x6b, _, Modrm|ReverseRegRegmem, Imm8S, WordReg|Mem, WordReg},
-{"imul", 3, 0x69, _, Modrm|ReverseRegRegmem, Imm16|Imm32, WordReg|Mem, WordReg},
-/*
- imul with 2 operands mimicks imul with 3 by puting register both
- in i.rm.reg & i.rm.regmem fields
-*/
-{"imul", 2, 0x6b, _, Modrm|imulKludge, Imm8S, WordReg, 0},
-{"imul", 2, 0x69, _, Modrm|imulKludge, Imm16|Imm32, WordReg, 0},
-{"div", 1, 0xf6, 6, W|Modrm, Reg|Mem, 0, 0},
-{"div", 2, 0xf6, 6, W|Modrm, Reg|Mem, Acc, 0},
-{"idiv", 1, 0xf6, 7, W|Modrm, Reg|Mem, 0, 0},
-{"idiv", 2, 0xf6, 7, W|Modrm, Reg|Mem, Acc, 0},
-
-{"rol", 2, 0xd0, 0, W|Modrm, Imm1, Reg|Mem, 0},
-{"rol", 2, 0xc0, 0, W|Modrm, Imm8, Reg|Mem, 0},
-{"rol", 2, 0xd2, 0, W|Modrm, ShiftCount, Reg|Mem, 0},
-{"rol", 1, 0xd0, 0, W|Modrm, Reg|Mem, 0, 0},
-
-{"ror", 2, 0xd0, 1, W|Modrm, Imm1, Reg|Mem, 0},
-{"ror", 2, 0xc0, 1, W|Modrm, Imm8, Reg|Mem, 0},
-{"ror", 2, 0xd2, 1, W|Modrm, ShiftCount, Reg|Mem, 0},
-{"ror", 1, 0xd0, 1, W|Modrm, Reg|Mem, 0, 0},
-
-{"rcl", 2, 0xd0, 2, W|Modrm, Imm1, Reg|Mem, 0},
-{"rcl", 2, 0xc0, 2, W|Modrm, Imm8, Reg|Mem, 0},
-{"rcl", 2, 0xd2, 2, W|Modrm, ShiftCount, Reg|Mem, 0},
-{"rcl", 1, 0xd0, 2, W|Modrm, Reg|Mem, 0, 0},
-
-{"rcr", 2, 0xd0, 3, W|Modrm, Imm1, Reg|Mem, 0},
-{"rcr", 2, 0xc0, 3, W|Modrm, Imm8, Reg|Mem, 0},
-{"rcr", 2, 0xd2, 3, W|Modrm, ShiftCount, Reg|Mem, 0},
-{"rcr", 1, 0xd0, 3, W|Modrm, Reg|Mem, 0, 0},
-
-{"sal", 2, 0xd0, 4, W|Modrm, Imm1, Reg|Mem, 0},
-{"sal", 2, 0xc0, 4, W|Modrm, Imm8, Reg|Mem, 0},
-{"sal", 2, 0xd2, 4, W|Modrm, ShiftCount, Reg|Mem, 0},
-{"sal", 1, 0xd0, 4, W|Modrm, Reg|Mem, 0, 0},
-{"shl", 2, 0xd0, 4, W|Modrm, Imm1, Reg|Mem, 0},
-{"shl", 2, 0xc0, 4, W|Modrm, Imm8, Reg|Mem, 0},
-{"shl", 2, 0xd2, 4, W|Modrm, ShiftCount, Reg|Mem, 0},
-{"shl", 1, 0xd0, 4, W|Modrm, Reg|Mem, 0, 0},
-
-{"shld", 3, 0x0fa4, _, Modrm, Imm8, WordReg, WordReg|Mem},
-{"shld", 3, 0x0fa5, _, Modrm, ShiftCount, WordReg, WordReg|Mem},
-
-{"shr", 2, 0xd0, 5, W|Modrm, Imm1, Reg|Mem, 0},
-{"shr", 2, 0xc0, 5, W|Modrm, Imm8, Reg|Mem, 0},
-{"shr", 2, 0xd2, 5, W|Modrm, ShiftCount, Reg|Mem, 0},
-{"shr", 1, 0xd0, 5, W|Modrm, Reg|Mem, 0, 0},
-
-{"shrd", 3, 0x0fac, _, Modrm, Imm8, WordReg, WordReg|Mem},
-{"shrd", 3, 0x0fad, _, Modrm, ShiftCount, WordReg, WordReg|Mem},
-
-{"sar", 2, 0xd0, 7, W|Modrm, Imm1, Reg|Mem, 0},
-{"sar", 2, 0xc0, 7, W|Modrm, Imm8, Reg|Mem, 0},
-{"sar", 2, 0xd2, 7, W|Modrm, ShiftCount, Reg|Mem, 0},
-{"sar", 1, 0xd0, 7, W|Modrm, Reg|Mem, 0, 0},
-
-/* control transfer instructions */
-#define CALL_PC_RELATIVE 0xe8
-{"call", 1, 0xe8, _, JumpDword, Disp32, 0, 0},
-{"call", 1, 0xff, 2, Modrm, Reg|Mem|JumpAbsolute, 0, 0},
-#define CALL_FAR_IMMEDIATE 0x9a
-{"lcall", 2, 0x9a, _, JumpInterSegment, Imm16, Abs32, 0},
-{"lcall", 1, 0xff, 3, Modrm, Mem, 0, 0},
-
-#define JUMP_PC_RELATIVE 0xeb
-{"jmp", 1, 0xeb, _, Jump, Disp, 0, 0},
-{"jmp", 1, 0xff, 4, Modrm, Reg32|Mem|JumpAbsolute, 0, 0},
-#define JUMP_FAR_IMMEDIATE 0xea
-{"ljmp", 2, 0xea, _, JumpInterSegment, Imm16, Imm32, 0},
-{"ljmp", 1, 0xff, 5, Modrm, Mem, 0, 0},
-
-{"ret", 0, 0xc3, _, NoModrm, 0, 0, 0},
-{"ret", 1, 0xc2, _, NoModrm, Imm16, 0, 0},
-{"lret", 0, 0xcb, _, NoModrm, 0, 0, 0},
-{"lret", 1, 0xca, _, NoModrm, Imm16, 0, 0},
-{"enter", 2, 0xc8, _, NoModrm, Imm16, Imm8, 0},
-{"leave", 0, 0xc9, _, NoModrm, 0, 0, 0},
-
-/* conditional jumps */
-{"jo", 1, 0x70, _, Jump, Disp, 0, 0},
-
-{"jno", 1, 0x71, _, Jump, Disp, 0, 0},
-
-{"jb", 1, 0x72, _, Jump, Disp, 0, 0},
-{"jc", 1, 0x72, _, Jump, Disp, 0, 0},
-{"jnae", 1, 0x72, _, Jump, Disp, 0, 0},
-
-{"jnb", 1, 0x73, _, Jump, Disp, 0, 0},
-{"jnc", 1, 0x73, _, Jump, Disp, 0, 0},
-{"jae", 1, 0x73, _, Jump, Disp, 0, 0},
-
-{"je", 1, 0x74, _, Jump, Disp, 0, 0},
-{"jz", 1, 0x74, _, Jump, Disp, 0, 0},
-
-{"jne", 1, 0x75, _, Jump, Disp, 0, 0},
-{"jnz", 1, 0x75, _, Jump, Disp, 0, 0},
-
-{"jbe", 1, 0x76, _, Jump, Disp, 0, 0},
-{"jna", 1, 0x76, _, Jump, Disp, 0, 0},
-
-{"jnbe", 1, 0x77, _, Jump, Disp, 0, 0},
-{"ja", 1, 0x77, _, Jump, Disp, 0, 0},
-
-{"js", 1, 0x78, _, Jump, Disp, 0, 0},
-
-{"jns", 1, 0x79, _, Jump, Disp, 0, 0},
-
-{"jp", 1, 0x7a, _, Jump, Disp, 0, 0},
-{"jpe", 1, 0x7a, _, Jump, Disp, 0, 0},
-
-{"jnp", 1, 0x7b, _, Jump, Disp, 0, 0},
-{"jpo", 1, 0x7b, _, Jump, Disp, 0, 0},
-
-{"jl", 1, 0x7c, _, Jump, Disp, 0, 0},
-{"jnge", 1, 0x7c, _, Jump, Disp, 0, 0},
-
-{"jnl", 1, 0x7d, _, Jump, Disp, 0, 0},
-{"jge", 1, 0x7d, _, Jump, Disp, 0, 0},
-
-{"jle", 1, 0x7e, _, Jump, Disp, 0, 0},
-{"jng", 1, 0x7e, _, Jump, Disp, 0, 0},
-
-{"jnle", 1, 0x7f, _, Jump, Disp, 0, 0},
-{"jg", 1, 0x7f, _, Jump, Disp, 0, 0},
-
-/* these turn into pseudo operations when disp is larger than 8 bits */
-#define IS_JUMP_ON_CX_ZERO(o) \
- (o == 0x67e3)
-#define IS_JUMP_ON_ECX_ZERO(o) \
- (o == 0xe3)
-
-{"jcxz", 1, 0x67e3, _, JumpByte, Disp, 0, 0},
-{"jecxz", 1, 0xe3, _, JumpByte, Disp, 0, 0},
-
-#define IS_LOOP_ECX_TIMES(o) \
- (o == 0xe2 || o == 0xe1 || o == 0xe0)
-
-{"loop", 1, 0xe2, _, JumpByte, Disp, 0, 0},
-
-{"loopz", 1, 0xe1, _, JumpByte, Disp, 0, 0},
-{"loope", 1, 0xe1, _, JumpByte, Disp, 0, 0},
-
-{"loopnz", 1, 0xe0, _, JumpByte, Disp, 0, 0},
-{"loopne", 1, 0xe0, _, JumpByte, Disp, 0, 0},
-
-/* set byte on flag instructions */
-{"seto", 1, 0x0f90, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setno", 1, 0x0f91, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setc", 1, 0x0f92, 0, Modrm, Reg8|Mem, 0, 0},
-{"setb", 1, 0x0f92, 0, Modrm, Reg8|Mem, 0, 0},
-{"setnae", 1, 0x0f92, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setnc", 1, 0x0f93, 0, Modrm, Reg8|Mem, 0, 0},
-{"setnb", 1, 0x0f93, 0, Modrm, Reg8|Mem, 0, 0},
-{"setae", 1, 0x0f93, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"sete", 1, 0x0f94, 0, Modrm, Reg8|Mem, 0, 0},
-{"setz", 1, 0x0f94, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setne", 1, 0x0f95, 0, Modrm, Reg8|Mem, 0, 0},
-{"setnz", 1, 0x0f95, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setbe", 1, 0x0f96, 0, Modrm, Reg8|Mem, 0, 0},
-{"setna", 1, 0x0f96, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setnbe", 1, 0x0f97, 0, Modrm, Reg8|Mem, 0, 0},
-{"seta", 1, 0x0f97, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"sets", 1, 0x0f98, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setns", 1, 0x0f99, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setp", 1, 0x0f9a, 0, Modrm, Reg8|Mem, 0, 0},
-{"setpe", 1, 0x0f9a, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setnp", 1, 0x0f9b, 0, Modrm, Reg8|Mem, 0, 0},
-{"setpo", 1, 0x0f9b, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setl", 1, 0x0f9c, 0, Modrm, Reg8|Mem, 0, 0},
-{"setnge", 1, 0x0f9c, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setnl", 1, 0x0f9d, 0, Modrm, Reg8|Mem, 0, 0},
-{"setge", 1, 0x0f9d, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setle", 1, 0x0f9e, 0, Modrm, Reg8|Mem, 0, 0},
-{"setng", 1, 0x0f9e, 0, Modrm, Reg8|Mem, 0, 0},
-
-{"setnle", 1, 0x0f9f, 0, Modrm, Reg8|Mem, 0, 0},
-{"setg", 1, 0x0f9f, 0, Modrm, Reg8|Mem, 0, 0},
-
-#define IS_STRING_INSTRUCTION(o) \
- ((o) == 0xa6 || (o) == 0x6c || (o) == 0x6e || (o) == 0x6e || \
- (o) == 0xac || (o) == 0xa4 || (o) == 0xae || (o) == 0xaa || \
- (o) == 0xd7)
-
-/* string manipulation */
-{"cmps", 0, 0xa6, _, W|NoModrm, 0, 0, 0},
-{"scmp", 0, 0xa6, _, W|NoModrm, 0, 0, 0},
-{"ins", 0, 0x6c, _, W|NoModrm, 0, 0, 0},
-{"outs", 0, 0x6e, _, W|NoModrm, 0, 0, 0},
-{"lods", 0, 0xac, _, W|NoModrm, 0, 0, 0},
-{"slod", 0, 0xac, _, W|NoModrm, 0, 0, 0},
-{"movs", 0, 0xa4, _, W|NoModrm, 0, 0, 0},
-{"smov", 0, 0xa4, _, W|NoModrm, 0, 0, 0},
-{"scas", 0, 0xae, _, W|NoModrm, 0, 0, 0},
-{"ssca", 0, 0xae, _, W|NoModrm, 0, 0, 0},
-{"stos", 0, 0xaa, _, W|NoModrm, 0, 0, 0},
-{"ssto", 0, 0xaa, _, W|NoModrm, 0, 0, 0},
-{"xlat", 0, 0xd7, _, NoModrm, 0, 0, 0},
-
-/* bit manipulation */
-{"bsf", 2, 0x0fbc, _, Modrm|ReverseRegRegmem, Reg|Mem, Reg, 0},
-{"bsr", 2, 0x0fbd, _, Modrm|ReverseRegRegmem, Reg|Mem, Reg, 0},
-{"bt", 2, 0x0fa3, _, Modrm, Reg, Reg|Mem, 0},
-{"bt", 2, 0x0fba, 4, Modrm, Imm8, Reg|Mem, 0},
-{"btc", 2, 0x0fbb, _, Modrm, Reg, Reg|Mem, 0},
-{"btc", 2, 0x0fba, 7, Modrm, Imm8, Reg|Mem, 0},
-{"btr", 2, 0x0fb3, _, Modrm, Reg, Reg|Mem, 0},
-{"btr", 2, 0x0fba, 6, Modrm, Imm8, Reg|Mem, 0},
-{"bts", 2, 0x0fab, _, Modrm, Reg, Reg|Mem, 0},
-{"bts", 2, 0x0fba, 5, Modrm, Imm8, Reg|Mem, 0},
-
-/* interrupts & op. sys insns */
-/* See i386.c for conversion of 'int $3' into the special int 3 insn. */
-#define INT_OPCODE 0xcd
-#define INT3_OPCODE 0xcc
-{"int", 1, 0xcd, _, NoModrm, Imm8, 0, 0},
-{"int3", 0, 0xcc, _, NoModrm, 0, 0, 0},
-{"into", 0, 0xce, _, NoModrm, 0, 0, 0},
-{"iret", 0, 0xcf, _, NoModrm, 0, 0, 0},
-
-{"boundl", 2, 0x62, _, Modrm, Reg32, Mem, 0},
-{"boundw", 2, 0x6662, _, Modrm, Reg16, Mem, 0},
-
-{"hlt", 0, 0xf4, _, NoModrm, 0, 0, 0},
-{"wait", 0, 0x9b, _, NoModrm, 0, 0, 0},
-/* nop is actually 'xchgl %eax, %eax' */
-{"nop", 0, 0x90, _, NoModrm, 0, 0, 0},
-
-/* protection control */
-{"arpl", 2, 0x63, _, Modrm, Reg16, Reg16|Mem, 0},
-{"lar", 2, 0x0f02, _, Modrm|ReverseRegRegmem, WordReg|Mem, WordReg, 0},
-{"lgdt", 1, 0x0f01, 2, Modrm, Mem, 0, 0},
-{"lidt", 1, 0x0f01, 3, Modrm, Mem, 0, 0},
-{"lldt", 1, 0x0f00, 2, Modrm, WordReg|Mem, 0, 0},
-{"lmsw", 1, 0x0f01, 6, Modrm, WordReg|Mem, 0, 0},
-{"lsl", 2, 0x0f03, _, Modrm|ReverseRegRegmem, WordReg|Mem, WordReg, 0},
-{"ltr", 1, 0x0f00, 3, Modrm, WordReg|Mem, 0, 0},
-
-{"sgdt", 1, 0x0f01, 0, Modrm, Mem, 0, 0},
-{"sidt", 1, 0x0f01, 1, Modrm, Mem, 0, 0},
-{"sldt", 1, 0x0f00, 0, Modrm, WordReg|Mem, 0, 0},
-{"smsw", 1, 0x0f01, 4, Modrm, WordReg|Mem, 0, 0},
-{"str", 1, 0x0f00, 1, Modrm, Reg16|Mem, 0, 0},
-
-{"verr", 1, 0x0f00, 4, Modrm, WordReg|Mem, 0, 0},
-{"verw", 1, 0x0f00, 5, Modrm, WordReg|Mem, 0, 0},
-
-/* floating point instructions */
-
-/* load */
-{"fld", 1, 0xd9c0, _, ShortForm, FloatReg, 0, 0}, /* register */
-{"flds", 1, 0xd9, 0, Modrm, Mem, 0, 0}, /* %st0 <-- mem float */
-{"fildl", 1, 0xdb, 0, Modrm, Mem, 0, 0}, /* %st0 <-- mem word */
-{"fldl", 1, 0xdd, 0, Modrm, Mem, 0, 0}, /* %st0 <-- mem double */
-{"fldl", 1, 0xd9c0, _, ShortForm, FloatReg, 0, 0}, /* register */
-{"filds", 1, 0xdf, 0, Modrm, Mem, 0, 0}, /* %st0 <-- mem dword */
-{"fildq", 1, 0xdf, 5, Modrm, Mem, 0, 0}, /* %st0 <-- mem qword */
-{"fldt", 1, 0xdb, 5, Modrm, Mem, 0, 0}, /* %st0 <-- mem efloat */
-{"fbld", 1, 0xdf, 4, Modrm, Mem, 0, 0}, /* %st0 <-- mem bcd */
-
-/* store (no pop) */
-{"fst", 1, 0xddd0, _, ShortForm, FloatReg, 0, 0}, /* register */
-{"fsts", 1, 0xd9, 2, Modrm, Mem, 0, 0}, /* %st0 --> mem float */
-{"fistl", 1, 0xdb, 2, Modrm, Mem, 0, 0}, /* %st0 --> mem dword */
-{"fstl", 1, 0xdd, 2, Modrm, Mem, 0, 0}, /* %st0 --> mem double */
-{"fstl", 1, 0xddd0, _, ShortForm, FloatReg, 0, 0}, /* register */
-{"fists", 1, 0xdf, 2, Modrm, Mem, 0, 0}, /* %st0 --> mem word */
-
-/* store (with pop) */
-{"fstp", 1, 0xddd8, _, ShortForm, FloatReg, 0, 0}, /* register */
-{"fstps", 1, 0xd9, 3, Modrm, Mem, 0, 0}, /* %st0 --> mem float */
-{"fistpl", 1, 0xdb, 3, Modrm, Mem, 0, 0}, /* %st0 --> mem word */
-{"fstpl", 1, 0xdd, 3, Modrm, Mem, 0, 0}, /* %st0 --> mem double */
-{"fstpl", 1, 0xddd8, _, ShortForm, FloatReg, 0, 0}, /* register */
-{"fistps", 1, 0xdf, 3, Modrm, Mem, 0, 0}, /* %st0 --> mem dword */
-{"fistpq", 1, 0xdf, 7, Modrm, Mem, 0, 0}, /* %st0 --> mem qword */
-{"fstpt", 1, 0xdb, 7, Modrm, Mem, 0, 0}, /* %st0 --> mem efloat */
-{"fbstp", 1, 0xdf, 6, Modrm, Mem, 0, 0}, /* %st0 --> mem bcd */
-
-/* exchange %st<n> with %st0 */
-{"fxch", 1, 0xd9c8, _, ShortForm, FloatReg, 0, 0},
-
-/* comparison (without pop) */
-{"fcom", 1, 0xd8d0, _, ShortForm, FloatReg, 0, 0},
-{"fcoms", 1, 0xd8, 2, Modrm, Mem, 0, 0}, /* compare %st0, mem float */
-{"ficoml", 1, 0xda, 2, Modrm, Mem, 0, 0}, /* compare %st0, mem word */
-{"fcoml", 1, 0xdc, 2, Modrm, Mem, 0, 0}, /* compare %st0, mem double */
-{"fcoml", 1, 0xd8d0, _, ShortForm, FloatReg, 0, 0},
-{"ficoms", 1, 0xde, 2, Modrm, Mem, 0, 0}, /* compare %st0, mem dword */
-
-/* comparison (with pop) */
-{"fcomp", 1, 0xd8d8, _, ShortForm, FloatReg, 0, 0},
-{"fcomps", 1, 0xd8, 3, Modrm, Mem, 0, 0}, /* compare %st0, mem float */
-{"ficompl", 1, 0xda, 3, Modrm, Mem, 0, 0}, /* compare %st0, mem word */
-{"fcompl", 1, 0xdc, 3, Modrm, Mem, 0, 0}, /* compare %st0, mem double */
-{"fcompl", 1, 0xd8d8, _, ShortForm, FloatReg, 0, 0},
-{"ficomps", 1, 0xde, 3, Modrm, Mem, 0, 0}, /* compare %st0, mem dword */
-{"fcompp", 0, 0xded9, _, NoModrm, 0, 0, 0}, /* compare %st0, %st1 & pop twice */
-
-/* unordered comparison (with pop) */
-{"fucom", 1, 0xdde0, _, ShortForm, FloatReg, 0, 0},
-{"fucomp", 1, 0xdde8, _, ShortForm, FloatReg, 0, 0},
-{"fucompp", 0, 0xdae9, _, NoModrm, 0, 0, 0}, /* ucompare %st0, %st1 & pop twice */
-
-{"ftst", 0, 0xd9e4, _, NoModrm, 0, 0, 0}, /* test %st0 */
-{"fxam", 0, 0xd9e5, _, NoModrm, 0, 0, 0}, /* examine %st0 */
-
-/* load constants into %st0 */
-{"fld1", 0, 0xd9e8, _, NoModrm, 0, 0, 0}, /* %st0 <-- 1.0 */
-{"fldl2t", 0, 0xd9e9, _, NoModrm, 0, 0, 0}, /* %st0 <-- log2(10) */
-{"fldl2e", 0, 0xd9ea, _, NoModrm, 0, 0, 0}, /* %st0 <-- log2(e) */
-{"fldpi", 0, 0xd9eb, _, NoModrm, 0, 0, 0}, /* %st0 <-- pi */
-{"fldlg2", 0, 0xd9ec, _, NoModrm, 0, 0, 0}, /* %st0 <-- log10(2) */
-{"fldln2", 0, 0xd9ed, _, NoModrm, 0, 0, 0}, /* %st0 <-- ln(2) */
-{"fldz", 0, 0xd9ee, _, NoModrm, 0, 0, 0}, /* %st0 <-- 0.0 */
-
-/* arithmetic */
-
-/* add */
-{"fadd", 1, 0xd8c0, _, ShortForm, FloatReg, 0, 0},
-{"fadd", 2, 0xd8c0, _, ShortForm|FloatD, FloatReg, FloatAcc, 0},
-{"fadd", 0, 0xdcc1, _, NoModrm, 0, 0, 0}, /* alias for fadd %st, %st(1) */
-{"faddp", 1, 0xdec0, _, ShortForm, FloatReg, 0, 0},
-{"faddp", 2, 0xdac0, _, ShortForm|FloatD, FloatReg, FloatAcc, 0},
-{"faddp", 0, 0xdec1, _, NoModrm, 0, 0, 0}, /* alias for faddp %st, %st(1) */
-{"fadds", 1, 0xd8, 0, Modrm, Mem, 0, 0},
-{"fiaddl", 1, 0xda, 0, Modrm, Mem, 0, 0},
-{"faddl", 1, 0xdc, 0, Modrm, Mem, 0, 0},
-{"fiadds", 1, 0xde, 0, Modrm, Mem, 0, 0},
-
-/* sub */
-/* Note: intel has decided that certain of these operations are reversed
- in assembler syntax. */
-{"fsub", 1, 0xd8e0, _, ShortForm, FloatReg, 0, 0},
-{"fsub", 2, 0xd8e0, _, ShortForm, FloatReg, FloatAcc, 0},
-#ifdef NON_BROKEN_OPCODES
-{"fsub", 2, 0xdce8, _, ShortForm, FloatAcc, FloatReg, 0},
-#else
-{"fsub", 2, 0xdce0, _, ShortForm, FloatAcc, FloatReg, 0},
-#endif
-{"fsub", 0, 0xdce1, _, NoModrm, 0, 0, 0},
-{"fsubp", 1, 0xdee0, _, ShortForm, FloatReg, 0, 0},
-{"fsubp", 2, 0xdee0, _, ShortForm, FloatReg, FloatAcc, 0},
-#ifdef NON_BROKEN_OPCODES
-{"fsubp", 2, 0xdee8, _, ShortForm, FloatAcc, FloatReg, 0},
-#else
-{"fsubp", 2, 0xdee0, _, ShortForm, FloatAcc, FloatReg, 0},
-#endif
-{"fsubp", 0, 0xdee1, _, NoModrm, 0, 0, 0},
-{"fsubs", 1, 0xd8, 4, Modrm, Mem, 0, 0},
-{"fisubl", 1, 0xda, 4, Modrm, Mem, 0, 0},
-{"fsubl", 1, 0xdc, 4, Modrm, Mem, 0, 0},
-{"fisubs", 1, 0xde, 4, Modrm, Mem, 0, 0},
-
-/* sub reverse */
-{"fsubr", 1, 0xd8e8, _, ShortForm, FloatReg, 0, 0},
-{"fsubr", 2, 0xd8e8, _, ShortForm, FloatReg, FloatAcc, 0},
-#ifdef NON_BROKEN_OPCODES
-{"fsubr", 2, 0xdce0, _, ShortForm, FloatAcc, FloatReg, 0},
-#else
-{"fsubr", 2, 0xdce8, _, ShortForm, FloatAcc, FloatReg, 0},
-#endif
-{"fsubr", 0, 0xdce9, _, NoModrm, 0, 0, 0},
-{"fsubrp", 1, 0xdee8, _, ShortForm, FloatReg, 0, 0},
-{"fsubrp", 2, 0xdee8, _, ShortForm, FloatReg, FloatAcc, 0},
-#ifdef NON_BROKEN_OPCODES
-{"fsubrp", 2, 0xdee0, _, ShortForm, FloatAcc, FloatReg, 0},
-#else
-{"fsubrp", 2, 0xdee8, _, ShortForm, FloatAcc, FloatReg, 0},
-#endif
-{"fsubrp", 0, 0xdee9, _, NoModrm, 0, 0, 0},
-{"fsubrs", 1, 0xd8, 5, Modrm, Mem, 0, 0},
-{"fisubrl", 1, 0xda, 5, Modrm, Mem, 0, 0},
-{"fsubrl", 1, 0xdc, 5, Modrm, Mem, 0, 0},
-{"fisubrs", 1, 0xde, 5, Modrm, Mem, 0, 0},
-
-/* mul */
-{"fmul", 1, 0xd8c8, _, ShortForm, FloatReg, 0, 0},
-{"fmul", 2, 0xd8c8, _, ShortForm|FloatD, FloatReg, FloatAcc, 0},
-{"fmul", 0, 0xdcc9, _, NoModrm, 0, 0, 0},
-{"fmulp", 1, 0xdec8, _, ShortForm, FloatReg, 0, 0},
-{"fmulp", 2, 0xdec8, _, ShortForm|FloatD, FloatReg, FloatAcc, 0},
-{"fmulp", 0, 0xdec9, _, NoModrm, 0, 0, 0},
-{"fmuls", 1, 0xd8, 1, Modrm, Mem, 0, 0},
-{"fimull", 1, 0xda, 1, Modrm, Mem, 0, 0},
-{"fmull", 1, 0xdc, 1, Modrm, Mem, 0, 0},
-{"fimuls", 1, 0xde, 1, Modrm, Mem, 0, 0},
-
-/* div */
-/* Note: intel has decided that certain of these operations are reversed
- in assembler syntax. */
-{"fdiv", 1, 0xd8f0, _, ShortForm, FloatReg, 0, 0},
-{"fdiv", 2, 0xd8f0, _, ShortForm, FloatReg, FloatAcc, 0},
-#ifdef NON_BROKEN_OPCODES
-{"fdiv", 2, 0xdcf8, _, ShortForm, FloatAcc, FloatReg, 0},
-#else
-{"fdiv", 2, 0xdcf0, _, ShortForm, FloatAcc, FloatReg, 0},
-#endif
-{"fdiv", 0, 0xdcf1, _, NoModrm, 0, 0, 0},
-{"fdivp", 1, 0xdef0, _, ShortForm, FloatReg, 0, 0},
-{"fdivp", 2, 0xdef0, _, ShortForm, FloatReg, FloatAcc, 0},
-#ifdef NON_BROKEN_OPCODES
-{"fdivp", 2, 0xdef8, _, ShortForm, FloatAcc, FloatReg, 0},
-#else
-{"fdivp", 2, 0xdef0, _, ShortForm, FloatAcc, FloatReg, 0},
-#endif
-{"fdivp", 0, 0xdef1, _, NoModrm, 0, 0, 0},
-{"fdivs", 1, 0xd8, 6, Modrm, Mem, 0, 0},
-{"fidivl", 1, 0xda, 6, Modrm, Mem, 0, 0},
-{"fdivl", 1, 0xdc, 6, Modrm, Mem, 0, 0},
-{"fidivs", 1, 0xde, 6, Modrm, Mem, 0, 0},
-
-/* div reverse */
-{"fdivr", 1, 0xd8f8, _, ShortForm, FloatReg, 0, 0},
-{"fdivr", 2, 0xd8f8, _, ShortForm, FloatReg, FloatAcc, 0},
-#ifdef NON_BROKEN_OPCODES
-{"fdivr", 2, 0xdcf0, _, ShortForm, FloatAcc, FloatReg, 0},
-#else
-{"fdivr", 2, 0xdcf8, _, ShortForm, FloatAcc, FloatReg, 0},
-#endif
-{"fdivr", 0, 0xdcf9, _, NoModrm, 0, 0, 0},
-{"fdivrp", 1, 0xdef8, _, ShortForm, FloatReg, 0, 0},
-{"fdivrp", 2, 0xdef8, _, ShortForm, FloatReg, FloatAcc, 0},
-#ifdef NON_BROKEN_OPCODES
-{"fdivrp", 2, 0xdef0, _, ShortForm, FloatAcc, FloatReg, 0},
-#else
-{"fdivrp", 2, 0xdef8, _, ShortForm, FloatAcc, FloatReg, 0},
-#endif
-{"fdivrp", 0, 0xdef9, _, NoModrm, 0, 0, 0},
-{"fdivrs", 1, 0xd8, 7, Modrm, Mem, 0, 0},
-{"fidivrl", 1, 0xda, 7, Modrm, Mem, 0, 0},
-{"fdivrl", 1, 0xdc, 7, Modrm, Mem, 0, 0},
-{"fidivrs", 1, 0xde, 7, Modrm, Mem, 0, 0},
-
-{"f2xm1", 0, 0xd9f0, _, NoModrm, 0, 0, 0},
-{"fyl2x", 0, 0xd9f1, _, NoModrm, 0, 0, 0},
-{"fptan", 0, 0xd9f2, _, NoModrm, 0, 0, 0},
-{"fpatan", 0, 0xd9f3, _, NoModrm, 0, 0, 0},
-{"fxtract", 0, 0xd9f4, _, NoModrm, 0, 0, 0},
-{"fprem1", 0, 0xd9f5, _, NoModrm, 0, 0, 0},
-{"fdecstp", 0, 0xd9f6, _, NoModrm, 0, 0, 0},
-{"fincstp", 0, 0xd9f7, _, NoModrm, 0, 0, 0},
-{"fprem", 0, 0xd9f8, _, NoModrm, 0, 0, 0},
-{"fyl2xp1", 0, 0xd9f9, _, NoModrm, 0, 0, 0},
-{"fsqrt", 0, 0xd9fa, _, NoModrm, 0, 0, 0},
-{"fsincos", 0, 0xd9fb, _, NoModrm, 0, 0, 0},
-{"frndint", 0, 0xd9fc, _, NoModrm, 0, 0, 0},
-{"fscale", 0, 0xd9fd, _, NoModrm, 0, 0, 0},
-{"fsin", 0, 0xd9fe, _, NoModrm, 0, 0, 0},
-{"fcos", 0, 0xd9ff, _, NoModrm, 0, 0, 0},
-
-{"fchs", 0, 0xd9e0, _, NoModrm, 0, 0, 0},
-{"fabs", 0, 0xd9e1, _, NoModrm, 0, 0, 0},
-
-/* processor control */
-{"fninit", 0, 0xdbe3, _, NoModrm, 0, 0, 0},
-{"finit", 0, 0xdbe3, _, NoModrm, 0, 0, 0},
-{"fldcw", 1, 0xd9, 5, Modrm, Mem, 0, 0},
-{"fnstcw", 1, 0xd9, 7, Modrm, Mem, 0, 0},
-{"fstcw", 1, 0xd9, 7, Modrm, Mem, 0, 0},
-{"fnstsw", 1, 0xdfe0, _, NoModrm, Acc, 0, 0},
-{"fnstsw", 1, 0xdd, 7, Modrm, Mem, 0, 0},
-{"fnstsw", 0, 0xdfe0, _, NoModrm, 0, 0, 0},
-{"fstsw", 1, 0xdfe0, _, NoModrm, Acc, 0, 0},
-{"fstsw", 1, 0xdd, 7, Modrm, Mem, 0, 0},
-{"fstsw", 0, 0xdfe0, _, NoModrm, 0, 0, 0},
-{"fnclex", 0, 0xdbe2, _, NoModrm, 0, 0, 0},
-{"fclex", 0, 0xdbe2, _, NoModrm, 0, 0, 0},
-/*
- We ignore the short format (287) versions of fstenv/fldenv & fsave/frstor
- instructions; i'm not sure how to add them or how they are different.
- My 386/387 book offers no details about this.
-*/
-{"fnstenv", 1, 0xd9, 6, Modrm, Mem, 0, 0},
-{"fstenv", 1, 0xd9, 6, Modrm, Mem, 0, 0},
-{"fldenv", 1, 0xd9, 4, Modrm, Mem, 0, 0},
-{"fnsave", 1, 0xdd, 6, Modrm, Mem, 0, 0},
-{"fsave", 1, 0xdd, 6, Modrm, Mem, 0, 0},
-{"frstor", 1, 0xdd, 4, Modrm, Mem, 0, 0},
-
-{"ffree", 1, 0xddc0, _, ShortForm, FloatReg, 0, 0},
-{"fnop", 0, 0xd9d0, _, NoModrm, 0, 0, 0},
-{"fwait", 0, 0x9b, _, NoModrm, 0, 0, 0},
-
-/*
- opcode prefixes; we allow them as seperate insns too
- (see prefix table below)
-*/
-{"aword", 0, 0x67, _, NoModrm, 0, 0, 0},
-{"addr16", 0, 0x67, _, NoModrm, 0, 0, 0},
-{"word", 0, 0x66, _, NoModrm, 0, 0, 0},
-{"data16", 0, 0x66, _, NoModrm, 0, 0, 0},
-{"lock", 0, 0xf0, _, NoModrm, 0, 0, 0},
-{"cs", 0, 0x2e, _, NoModrm, 0, 0, 0},
-{"ds", 0, 0x3e, _, NoModrm, 0, 0, 0},
-{"es", 0, 0x26, _, NoModrm, 0, 0, 0},
-{"fs", 0, 0x64, _, NoModrm, 0, 0, 0},
-{"gs", 0, 0x65, _, NoModrm, 0, 0, 0},
-{"ss", 0, 0x36, _, NoModrm, 0, 0, 0},
-{"rep", 0, 0xf3, _, NoModrm, 0, 0, 0},
-{"repe", 0, 0xf3, _, NoModrm, 0, 0, 0},
-{ "repne", 0, 0xf2, _, NoModrm, 0, 0, 0},
-{"repz", 0, 0xf3, _, NoModrm, 0, 0, 0},
-{ "repnz", 0, 0xf2, _, NoModrm, 0, 0, 0},
-
-/* 486 extensions */
-{"bswap", 1, 0x0fc8, _, ShortForm, Reg32,0,0 },
-{"xadd", 2, 0x0fc0, _, DW|Modrm, Reg, Reg|Mem, 0 },
-{"cmpxchg", 2, 0x0fb0, _, DW|Modrm, Reg, Reg|Mem, 0 },
-{"invd", 0, 0x0f08, _, NoModrm, 0, 0, 0},
-{"wbinvd", 0, 0x0f09, _, NoModrm, 0, 0, 0},
-{"invlpg", 1, 0x0f01, 7, Modrm, Mem, 0, 0},
-
-/* Pentium and late-model 486 extensions */
-{"cpuid", 0, 0x0fa2, _, NoModrm, 0, 0, 0},
-
-/* Pentium extensions */
-{"wrmsr", 0, 0x0f30, _, NoModrm, 0, 0, 0},
-{"rdtsc", 0, 0x0f31, _, NoModrm, 0, 0, 0},
-{"rdmsr", 0, 0x0f32, _, NoModrm, 0, 0, 0},
-{"cmpxchg8b", 1, 0x0fc7, 1, Modrm, Mem, 0, 0},
-
-/* Pentium Pro extensions */
-{"rdpmc", 0, 0x0f33, _, NoModrm, 0, 0, 0},
-
-{"ud2", 0, 0x0fff, _, NoModrm, 0, 0, 0}, /* official undefined instr. */
-
-{"cmovo", 2, 0x0f40, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovno", 2, 0x0f41, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovb", 2, 0x0f42, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovae", 2, 0x0f43, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmove", 2, 0x0f44, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovne", 2, 0x0f45, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovbe", 2, 0x0f46, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmova", 2, 0x0f47, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovs", 2, 0x0f48, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovns", 2, 0x0f49, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovp", 2, 0x0f4a, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovnp", 2, 0x0f4b, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovl", 2, 0x0f4c, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovge", 2, 0x0f4d, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovle", 2, 0x0f4e, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-{"cmovg", 2, 0x0f4f, _, Modrm|ReverseRegRegmem, WordReg|WordMem, WordReg, 0},
-
-{"fcmovb", 2, 0xdac0, _, ShortForm, FloatReg, FloatAcc, 0},
-{"fcmove", 2, 0xdac8, _, ShortForm, FloatReg, FloatAcc, 0},
-{"fcmovbe",2, 0xdad0, _, ShortForm, FloatReg, FloatAcc, 0},
-{"fcmovu", 2, 0xdad8, _, ShortForm, FloatReg, FloatAcc, 0},
-{"fcmovnb", 2, 0xdbc0, _, ShortForm, FloatReg, FloatAcc, 0},
-{"fcmovne", 2, 0xdbc8, _, ShortForm, FloatReg, FloatAcc, 0},
-{"fcmovnbe",2, 0xdbd0, _, ShortForm, FloatReg, FloatAcc, 0},
-{"fcmovnu", 2, 0xdbd8, _, ShortForm, FloatReg, FloatAcc, 0},
-
-{"fcomi", 2, 0xdbf0, _, ShortForm, FloatReg, FloatAcc, 0},
-{"fucomi", 2, 0xdbe8, _, ShortForm, FloatReg, FloatAcc, 0},
-{"fcomip", 2, 0xdff0, _, ShortForm, FloatReg, FloatAcc, 0},
-{"fucomip",2, 0xdfe8, _, ShortForm, FloatReg, FloatAcc, 0},
-
-
-{"", 0, 0, 0, 0, 0, 0, 0} /* sentinal */
-};
-#undef _
-
-static const template *i386_optab_end
- = i386_optab + sizeof (i386_optab)/sizeof(i386_optab[0]);
-
-/* 386 register table */
-
-static const reg_entry i386_regtab[] = {
- /* 8 bit regs */
- {"al", Reg8|Acc, 0}, {"cl", Reg8|ShiftCount, 1}, {"dl", Reg8, 2},
- {"bl", Reg8, 3},
- {"ah", Reg8, 4}, {"ch", Reg8, 5}, {"dh", Reg8, 6}, {"bh", Reg8, 7},
- /* 16 bit regs */
- {"ax", Reg16|Acc, 0}, {"cx", Reg16, 1}, {"dx", Reg16|InOutPortReg, 2}, {"bx", Reg16, 3},
- {"sp", Reg16, 4}, {"bp", Reg16, 5}, {"si", Reg16, 6}, {"di", Reg16, 7},
- /* 32 bit regs */
- {"eax", Reg32|Acc, 0}, {"ecx", Reg32, 1}, {"edx", Reg32, 2}, {"ebx", Reg32, 3},
- {"esp", Reg32, 4}, {"ebp", Reg32, 5}, {"esi", Reg32, 6}, {"edi", Reg32, 7},
- /* segment registers */
- {"es", SReg2, 0}, {"cs", SReg2, 1}, {"ss", SReg2, 2},
- {"ds", SReg2, 3}, {"fs", SReg3, 4}, {"gs", SReg3, 5},
- /* control registers */
- {"cr0", Control, 0}, {"cr2", Control, 2}, {"cr3", Control, 3},
- {"cr4", Control, 4},
- /* debug registers */
- {"db0", Debug, 0}, {"db1", Debug, 1}, {"db2", Debug, 2},
- {"db3", Debug, 3}, {"db6", Debug, 6}, {"db7", Debug, 7},
- {"dr0", Debug, 0}, {"dr1", Debug, 1}, {"dr2", Debug, 2},
- {"dr3", Debug, 3}, {"dr6", Debug, 6}, {"dr7", Debug, 7},
- /* test registers */
- {"tr3", Test, 3}, {"tr4", Test, 4}, {"tr5", Test, 5},
- {"tr6", Test, 6}, {"tr7", Test, 7},
- /* float registers */
- {"st(0)", FloatReg|FloatAcc, 0},
- {"st", FloatReg|FloatAcc, 0},
- {"st(1)", FloatReg, 1}, {"st(2)", FloatReg, 2},
- {"st(3)", FloatReg, 3}, {"st(4)", FloatReg, 4}, {"st(5)", FloatReg, 5},
- {"st(6)", FloatReg, 6}, {"st(7)", FloatReg, 7}
-};
-
-#define MAX_REG_NAME_SIZE 8 /* for parsing register names from input */
-
-static const reg_entry *i386_regtab_end
- = i386_regtab + sizeof(i386_regtab)/sizeof(i386_regtab[0]);
-
-/* segment stuff */
-static const seg_entry cs = { "cs", 0x2e };
-static const seg_entry ds = { "ds", 0x3e };
-static const seg_entry ss = { "ss", 0x36 };
-static const seg_entry es = { "es", 0x26 };
-static const seg_entry fs = { "fs", 0x64 };
-static const seg_entry gs = { "gs", 0x65 };
-static const seg_entry null = { "", 0x0 };
-
-/*
- This table is used to store the default segment register implied by all
- possible memory addressing modes.
- It is indexed by the mode & modrm entries of the modrm byte as follows:
- index = (mode<<3) | modrm;
-*/
-static const seg_entry *one_byte_segment_defaults[] = {
- /* mode 0 */
- &ds, &ds, &ds, &ds, &null, &ds, &ds, &ds,
- /* mode 1 */
- &ds, &ds, &ds, &ds, &null, &ss, &ds, &ds,
- /* mode 2 */
- &ds, &ds, &ds, &ds, &null, &ss, &ds, &ds,
- /* mode 3 --- not a memory reference; never referenced */
-};
-
-static const seg_entry *two_byte_segment_defaults[] = {
- /* mode 0 */
- &ds, &ds, &ds, &ds, &ss, &ds, &ds, &ds,
- /* mode 1 */
- &ds, &ds, &ds, &ds, &ss, &ds, &ds, &ds,
- /* mode 2 */
- &ds, &ds, &ds, &ds, &ss, &ds, &ds, &ds,
- /* mode 3 --- not a memory reference; never referenced */
-};
-
-static const prefix_entry i386_prefixtab[] = {
- { "addr16", 0x67 }, /* address size prefix ==> 16bit addressing
- * (How is this useful?) */
-#define WORD_PREFIX_OPCODE 0x66
- { "data16", 0x66 }, /* operand size prefix */
- { "lock", 0xf0 }, /* bus lock prefix */
- { "wait", 0x9b }, /* wait for coprocessor */
- { "cs", 0x2e }, { "ds", 0x3e }, /* segment overrides ... */
- { "es", 0x26 }, { "fs", 0x64 },
- { "gs", 0x65 }, { "ss", 0x36 },
-/* REPE & REPNE used to detect rep/repne with a non-string instruction */
-#define REPNE 0xf2
-#define REPE 0xf3
- { "rep", 0xf3 }, { "repe", 0xf3 }, { "repz", 0xf3 }, /* repeat string instructions */
- { "repne", 0xf2 }, { "repnz", 0xf2 }
-};
-
-static const prefix_entry *i386_prefixtab_end
- = i386_prefixtab + sizeof(i386_prefixtab)/sizeof(i386_prefixtab[0]);
-
-/* end of i386-opcode.h */
diff --git a/gnu/usr.bin/as/opcode/i860.h b/gnu/usr.bin/as/opcode/i860.h
deleted file mode 100644
index b429a22..0000000
--- a/gnu/usr.bin/as/opcode/i860.h
+++ /dev/null
@@ -1,495 +0,0 @@
-/* Table of opcodes for the i860.
- Copyright (C) 1989 Free Software Foundation, Inc.
-
-This file is part of GAS, the GNU Assembler, and GDB, the GNU disassembler.
-
-GAS/GDB is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GAS/GDB 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 GAS or GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined(__STDC__) && !defined(const)
-#define const
-#endif
-
-/*
- * Structure of an opcode table entry.
- */
-struct i860_opcode
-{
- const char *name;
- unsigned long match; /* Bits that must be set. */
- unsigned long lose; /* Bits that must not be set. */
- const char *args;
- /* Nonzero if this is a possible expand-instruction. */
- char expand;
-};
-
-enum expand_type
-{
- E_MOV = 1, E_ADDR, E_U32, E_AND, E_S32, E_DELAY
-};
-
-/*
- All i860 opcodes are 32 bits, except for the pseudoinstructions
- and the operations utilizing a 32-bit address expression, an
- unsigned 32-bit constant, or a signed 32-bit constant.
- These opcodes are expanded into a two-instruction sequence for
- any situation where the immediate operand does not fit in 32 bits.
- In the case of the add and subtract operations the expansion is
- to a three-instruction sequence (ex: orh, or, adds). In cases
- where the address is to be relocated, the instruction is
- expanded to handle the worse case, this could be optimized at
- the final link if the actual address were known.
-
- The pseudoinstructions are: mov, fmov, pmov, nop, and fnop.
- These instructions are implemented as a one or two instruction
- sequence of other operations.
-
- The match component is a mask saying which bits must match a
- particular opcode in order for an instruction to be an instance
- of that opcode.
-
- The args component is a string containing one character
- for each operand of the instruction.
-
-Kinds of operands:
- # Number used by optimizer. It is ignored.
- 1 src1 integer register.
- 2 src2 integer register.
- d dest register.
- c ctrlreg control register.
- i 16 bit immediate.
- I 16 bit immediate, aligned.
- 5 5 bit immediate.
- l lbroff 26 bit PC relative immediate.
- r sbroff 16 bit PC relative immediate.
- s split 16 bit immediate.
- S split 16 bit immediate, aligned.
- e src1 floating point register.
- f src2 floating point register.
- g dest floating point register.
-
-*/
-
-/* The order of the opcodes in this table is significant:
-
- * The assembler requires that all instances of the same mnemonic must be
- consecutive. If they aren't, the assembler will bomb at runtime.
-
- * The disassembler should not care about the order of the opcodes. */
-
-static struct i860_opcode i860_opcodes[] =
-{
-
-/* REG-Format Instructions */
-{ "ld.c", 0x30000000, 0xcc000000, "c,d", 0 }, /* ld.c csrc2,idest */
-{ "ld.b", 0x00000000, 0xfc000000, "1(2),d", 0 }, /* ld.b isrc1(isrc2),idest */
-{ "ld.b", 0x04000000, 0xf8000000, "I(2),d", E_ADDR }, /* ld.b #const(isrc2),idest */
-{ "ld.s", 0x10000000, 0xec000001, "1(2),d", 0 }, /* ld.s isrc1(isrc2),idest */
-{ "ld.s", 0x14000001, 0xe8000000, "I(2),d", E_ADDR }, /* ld.s #const(isrc2),idest */
-{ "ld.l", 0x10000001, 0xec000000, "1(2),d", 0 }, /* ld.l isrc1(isrc2),idest */
-{ "ld.l", 0x14000001, 0xe8000000, "I(2),d", E_ADDR }, /* ld.l #const(isrc2),idest */
-
-{ "st.c", 0x38000000, 0xc4000000, "1,c", 0 }, /* st.c isrc1ni,csrc2 */
-{ "st.b", 0x0c000000, 0xf0000000, "1,S(2)", E_ADDR }, /* st.b isrc1ni,#const(isrc2) */
-{ "st.s", 0x1c000000, 0xe0000000, "1,S(2)", E_ADDR }, /* st.s isrc1ni,#const(isrc2) */
-{ "st.l", 0x1c000001, 0xe0000000, "1,S(2)", E_ADDR }, /* st.l isrc1ni,#const(isrc2) */
-
-{ "ixfr", 0x08000000, 0xf4000000, "1,g", 0 }, /* ixfr isrc1ni,fdest */
-
-{ "fld.l", 0x20000002, 0xdc000001, "1(2),g", 0 }, /* fld.l isrc1(isrc2),fdest */
-{ "fld.l", 0x24000002, 0xd8000001, "i(2),g", E_ADDR }, /* fld.l #const(isrc2),fdest */
-{ "fld.l", 0x20000003, 0xdc000000, "1(2)++,g", 0 }, /* fld.l isrc1(isrc2)++,fdest */
-{ "fld.l", 0x24000003, 0xd8000000, "i(2)++,g", E_ADDR }, /* fld.l #const(isrc2)++,fdest */
-{ "fld.d", 0x20000000, 0xdc000007, "1(2),g", 0 }, /* fld.d isrc1(isrc2),fdest */
-{ "fld.d", 0x24000000, 0xd8000007, "i(2),g", E_ADDR }, /* fld.d #const(isrc2),fdest */
-{ "fld.d", 0x20000001, 0xdc000006, "1(2)++,g", 0 }, /* fld.d isrc1(isrc2)++,fdest */
-{ "fld.d", 0x24000001, 0xd8000006, "i(2)++,g", E_ADDR }, /* fld.d #const(isrc2)++,fdest */
-{ "fld.q", 0x20000004, 0xdc000003, "1(2),g", 0 }, /* fld.q isrc1(isrc2),fdest */
-{ "fld.q", 0x24000004, 0xd8000003, "i(2),g", E_ADDR }, /* fld.q #const(isrc2),fdest */
-{ "fld.q", 0x20000005, 0xdc000002, "1(2)++,g", 0 }, /* fld.q isrc1(isrc2)++,fdest */
-{ "fld.q", 0x24000005, 0xd8000002, "i(2)++,g", E_ADDR }, /* fld.q #const(isrc2)++,fdest */
-
-{ "pfld.l", 0x60000000, 0x9c000003, "1(2),g", 0 }, /* pfld.l isrc1(isrc2),fdest */
-{ "pfld.l", 0x64000000, 0x98000003, "i(2),g", E_ADDR }, /* pfld.l #const(isrc2),fdest */
-{ "pfld.l", 0x60000001, 0x9c000002, "1(2)++,g", 0 }, /* pfld.l isrc1(isrc2)++,fdest */
-{ "pfld.l", 0x64000001, 0x98000002, "i(2)++,g", E_ADDR }, /* pfld.l #const(isrc2)++,fdest */
-{ "pfld.d", 0x60000000, 0x9c000007, "1(2),g", 0 }, /* pfld.d isrc1(isrc2),fdest */
-{ "pfld.d", 0x64000000, 0x98000007, "i(2),g", E_ADDR }, /* pfld.d #const(isrc2),fdest */
-{ "pfld.d", 0x60000001, 0x9c000006, "1(2)++,g", 0 }, /* pfld.d isrc1(isrc2)++,fdest */
-{ "pfld.d", 0x64000001, 0x98000006, "i(2)++,g", E_ADDR }, /* pfld.d #const(isrc2)++,fdest */
-
-{ "fst.l", 0x28000002, 0xd4000001, "g,1(2)", 0 }, /* fst.l fdest,isrc1(isrc2) */
-{ "fst.l", 0x2c000002, 0xd0000001, "g,i(2)", E_ADDR }, /* fst.l fdest,#const(isrc2) */
-{ "fst.l", 0x28000003, 0xd4000000, "g,1(2)++", 0 }, /* fst.l fdest,isrc1(isrc2)++ */
-{ "fst.l", 0x2c000003, 0xd0000000, "g,i(2)++", E_ADDR }, /* fst.l fdest,#const(isrc2)++ */
-{ "fst.d", 0x28000000, 0xd4000007, "g,1(2)", 0 }, /* fst.d fdest,isrc1(isrc2) */
-{ "fst.d", 0x2c000000, 0xd0000007, "g,i(2)", E_ADDR }, /* fst.d fdest,#const(isrc2) */
-{ "fst.d", 0x28000001, 0xd4000006, "g,1(2)++", 0 }, /* fst.d fdest,isrc1(isrc2)++ */
-{ "fst.d", 0x2c000001, 0xd0000006, "g,i(2)++", E_ADDR }, /* fst.d fdest,#const(isrc2)++ */
-{ "fst.q", 0x28000004, 0xd4000003, "g,1(2)", 0 }, /* fst.q fdest,isrc1(isrc2) */
-{ "fst.q", 0x2c000004, 0xd0000003, "g,i(2)", E_ADDR }, /* fst.q fdest,#const(isrc2) */
-{ "fst.q", 0x28000005, 0xd4000002, "g,1(2)++", 0 }, /* fst.q fdest,isrc1(isrc2)++ */
-{ "fst.q", 0x2c000005, 0xd0000002, "g,i(2)++", E_ADDR }, /* fst.q fdest,#const(isrc2)++ */
-
-{ "pst.d", 0x3c000000, 0xc0000007, "g,i(2)", E_ADDR }, /* pst.d fdest,#const(isrc2) */
-{ "pst.d", 0x3c000001, 0xc0000006, "g,i(2)++", E_ADDR }, /* pst.d fdest,#const(isrc2)++ */
-
-{ "addu", 0x80000000, 0x7c000000, "1,2,d", 0 }, /* addu isrc1,isrc2,idest */
-{ "addu", 0x84000000, 0x78000000, "i,2,d", E_S32 }, /* addu #const,isrc2,idest */
-{ "adds", 0x90000000, 0x6c000000, "1,2,d", 0 }, /* adds isrc1,isrc2,idest */
-{ "adds", 0x94000000, 0x68000000, "i,2,d", E_S32 }, /* adds #const,isrc2,idest */
-{ "subu", 0x88000000, 0x74000000, "1,2,d", 0 }, /* subu isrc1,isrc2,idest */
-{ "subu", 0x8c000000, 0x70000000, "i,2,d", E_S32 }, /* subu #const,isrc2,idest */
-{ "subs", 0x98000000, 0x64000000, "1,2,d", 0 }, /* subs isrc1,isrc2,idest */
-{ "subs", 0x9c000000, 0x60000000, "i,2,d", E_S32 }, /* subs #const,isrc2,idest */
-
-{ "shl", 0xa0000000, 0x5c000000, "1,2,d", 0 }, /* shl isrc1,isrc2,idest */
-{ "shl", 0xa4000000, 0x58000000, "i,2,d", 0 }, /* shl #const,isrc2,idest */
-{ "shr", 0xa8000000, 0x54000000, "1,2,d", 0 }, /* shr isrc1,isrc2,idest */
-{ "shr", 0xac000000, 0x50000000, "i,2,d", 0 }, /* shr #const,isrc2,idest */
-{ "shrd", 0xb0000000, 0x4c000000, "1,2,d", 0 }, /* shrd isrc1,isrc2,idest */
-{ "shra", 0xb8000000, 0x44000000, "1,2,d", 0 }, /* shra isrc1,isrc2,idest */
-{ "shra", 0xbc000000, 0x40000000, "i,2,d", 0 }, /* shra #const,isrc2,idest */
-
-{ "mov", 0xa0000000, 0x5c00f800, "2,d", 0 }, /* shl r0,isrc2,idest */
-{ "mov", 0x94000000, 0x69e00000, "i,d", E_MOV }, /* adds #const,r0,idest */
-{ "nop", 0xa0000000, 0x5ffff800, "", 0 }, /* shl r0,r0,r0 */
-{ "fnop", 0xb0000000, 0x4ffff800, "", 0 }, /* shrd r0,r0,r0 */
-
-{ "trap", 0x44000000, 0xb8000000, "1,2,d", 0 }, /* trap isrc1ni,isrc2,idest */
-
-{ "flush", 0x34000000, 0xc81f0001, "i(2)", E_ADDR }, /* flush #const(isrc2) */
-{ "flush", 0x34000001, 0xc81f0000, "i(2)++", E_ADDR }, /* flush #const(isrc2)++ */
-
-{ "and", 0xc0000000, 0x3c000000, "1,2,d", 0 }, /* and isrc1,isrc2,idest */
-{ "and", 0xc4000000, 0x38000000, "i,2,d", E_AND }, /* and #const,isrc2,idest */
-{ "andh", 0xc8000000, 0x34000000, "1,2,d", 0 }, /* andh isrc1,isrc2,idest */
-{ "andh", 0xcc000000, 0x30000000, "i,2,d", 0 }, /* andh #const,isrc2,idest */
-{ "andnot", 0xd0000000, 0x2c000000, "1,2,d", 0 }, /* andnot isrc1,isrc2,idest */
-{ "andnot", 0xd4000000, 0x28000000, "i,2,d", E_U32 }, /* andnot #const,isrc2,idest */
-{ "andnoth", 0xd8000000, 0x24000000, "1,2,d", 0 }, /* andnoth isrc1,isrc2,idest */
-{ "andnoth", 0xdc000000, 0x20000000, "i,2,d", 0 }, /* andnoth #const,isrc2,idest */
-{ "or", 0xe0000000, 0x1c000000, "1,2,d", 0 }, /* or isrc1,isrc2,idest */
-{ "or", 0xe4000000, 0x18000000, "i,2,d", E_U32 }, /* or #const,isrc2,idest */
-{ "orh", 0xe8000000, 0x14000000, "1,2,d", 0 }, /* orh isrc1,isrc2,idest */
-{ "orh", 0xec000000, 0x10000000, "i,2,d", 0 }, /* orh #const,isrc2,idest */
-{ "xor", 0xf0000000, 0x0c000000, "1,2,d", 0 }, /* xor isrc1,isrc2,idest */
-{ "xor", 0xf4000000, 0x08000000, "i,2,d", E_U32 }, /* xor #const,isrc2,idest */
-{ "xorh", 0xf8000000, 0x04000000, "1,2,d", 0 }, /* xorh isrc1,isrc2,idest */
-{ "xorh", 0xfc000000, 0x00000000, "i,2,d", 0 }, /* xorh #const,isrc2,idest */
-
-{ "bte", 0x58000000, 0xa4000000, "1,2,s", 0 }, /* bte isrc1s,isrc2,sbroff */
-{ "bte", 0x5c000000, 0xa0000000, "5,2,s", 0 }, /* bte #const5,isrc2,sbroff */
-{ "btne", 0x50000000, 0xac000000, "1,2,s", 0 }, /* btne isrc1s,isrc2,sbroff */
-{ "btne", 0x54000000, 0xa8000000, "5,2,s", 0 }, /* btne #const5,isrc2,sbroff */
-{ "bla", 0xb4000000, 0x48000000, "1,2,s", E_DELAY }, /* bla isrc1s,isrc2,sbroff */
-{ "bri", 0x40000000, 0xbc000000, "1", E_DELAY }, /* bri isrc1ni */
-
-/* Core Escape Instruction Format */
-{ "lock", 0x4c000001, 0xb000001e, "", 0 }, /* lock set BL in dirbase */
-{ "calli", 0x4c000002, 0xb000001d, "1", E_DELAY }, /* calli isrc1ni */
-{ "intovr", 0x4c000004, 0xb000001b, "", 0 }, /* intovr trap on integer overflow */
-{ "unlock", 0x4c000007, 0xb0000018, "", 0 }, /* unlock clear BL in dirbase */
-
-/* CTRL-Format Instructions */
-{ "br", 0x68000000, 0x94000000, "l", E_DELAY }, /* br lbroff */
-{ "call", 0x6c000000, 0x90000000, "l", E_DELAY }, /* call lbroff */
-{ "bc", 0x70000000, 0x8c000000, "l", 0 }, /* bc lbroff */
-{ "bc.t", 0x74000000, 0x88000000, "l", E_DELAY }, /* bc.t lbroff */
-{ "bnc", 0x78000000, 0x84000000, "l", 0 }, /* bnc lbroff */
-{ "bnc.t", 0x7c000000, 0x80000000, "l", E_DELAY }, /* bnc.t lbroff */
-
-/* Floating Point Escape Instruction Format - pfam.p fsrc1,fsrc2,fdest */
-{ "r2p1.ss", 0x48000400, 0xb40003ff, "e,f,g", 0 },
-{ "r2p1.sd", 0x48000480, 0xb400037f, "e,f,g", 0 },
-{ "r2p1.dd", 0x48000580, 0xb400027f, "e,f,g", 0 },
-{ "r2pt.ss", 0x48000401, 0xb40003fe, "e,f,g", 0 },
-{ "r2pt.sd", 0x48000481, 0xb400037e, "e,f,g", 0 },
-{ "r2pt.dd", 0x48000581, 0xb400027e, "e,f,g", 0 },
-{ "r2ap1.ss", 0x48000402, 0xb40003fd, "e,f,g", 0 },
-{ "r2ap1.sd", 0x48000482, 0xb400037d, "e,f,g", 0 },
-{ "r2ap1.dd", 0x48000582, 0xb400027d, "e,f,g", 0 },
-{ "r2apt.ss", 0x48000403, 0xb40003fc, "e,f,g", 0 },
-{ "r2apt.sd", 0x48000483, 0xb400037c, "e,f,g", 0 },
-{ "r2apt.dd", 0x48000583, 0xb400027c, "e,f,g", 0 },
-{ "i2p1.ss", 0x48000404, 0xb40003fb, "e,f,g", 0 },
-{ "i2p1.sd", 0x48000484, 0xb400037b, "e,f,g", 0 },
-{ "i2p1.dd", 0x48000584, 0xb400027b, "e,f,g", 0 },
-{ "i2pt.ss", 0x48000405, 0xb40003fa, "e,f,g", 0 },
-{ "i2pt.sd", 0x48000485, 0xb400037a, "e,f,g", 0 },
-{ "i2pt.dd", 0x48000585, 0xb400027a, "e,f,g", 0 },
-{ "i2ap1.ss", 0x48000406, 0xb40003f9, "e,f,g", 0 },
-{ "i2ap1.sd", 0x48000486, 0xb4000379, "e,f,g", 0 },
-{ "i2ap1.dd", 0x48000586, 0xb4000279, "e,f,g", 0 },
-{ "i2apt.ss", 0x48000407, 0xb40003f8, "e,f,g", 0 },
-{ "i2apt.sd", 0x48000487, 0xb4000378, "e,f,g", 0 },
-{ "i2apt.dd", 0x48000587, 0xb4000278, "e,f,g", 0 },
-{ "rat1p2.ss", 0x48000408, 0xb40003f7, "e,f,g", 0 },
-{ "rat1p2.sd", 0x48000488, 0xb4000377, "e,f,g", 0 },
-{ "rat1p2.dd", 0x48000588, 0xb4000277, "e,f,g", 0 },
-{ "m12apm.ss", 0x48000409, 0xb40003f6, "e,f,g", 0 },
-{ "m12apm.sd", 0x48000489, 0xb4000376, "e,f,g", 0 },
-{ "m12apm.dd", 0x48000589, 0xb4000276, "e,f,g", 0 },
-{ "ra1p2.ss", 0x4800040a, 0xb40003f5, "e,f,g", 0 },
-{ "ra1p2.sd", 0x4800048a, 0xb4000375, "e,f,g", 0 },
-{ "ra1p2.dd", 0x4800058a, 0xb4000275, "e,f,g", 0 },
-{ "m12ttpa.ss", 0x4800040b, 0xb40003f4, "e,f,g", 0 },
-{ "m12ttpa.sd", 0x4800048b, 0xb4000374, "e,f,g", 0 },
-{ "m12ttpa.dd", 0x4800058b, 0xb4000274, "e,f,g", 0 },
-{ "iat1p2.ss", 0x4800040c, 0xb40003f3, "e,f,g", 0 },
-{ "iat1p2.sd", 0x4800048c, 0xb4000373, "e,f,g", 0 },
-{ "iat1p2.dd", 0x4800058c, 0xb4000273, "e,f,g", 0 },
-{ "m12tpm.ss", 0x4800040d, 0xb40003f2, "e,f,g", 0 },
-{ "m12tpm.sd", 0x4800048d, 0xb4000372, "e,f,g", 0 },
-{ "m12tpm.dd", 0x4800058d, 0xb4000272, "e,f,g", 0 },
-{ "ia1p2.ss", 0x4800040e, 0xb40003f1, "e,f,g", 0 },
-{ "ia1p2.sd", 0x4800048e, 0xb4000371, "e,f,g", 0 },
-{ "ia1p2.dd", 0x4800058e, 0xb4000271, "e,f,g", 0 },
-{ "m12tpa.ss", 0x4800040f, 0xb40003f0, "e,f,g", 0 },
-{ "m12tpa.sd", 0x4800048f, 0xb4000370, "e,f,g", 0 },
-{ "m12tpa.dd", 0x4800058f, 0xb4000270, "e,f,g", 0 },
-
-/* Floating Point Escape Instruction Format - pfsm.p fsrc1,fsrc2,fdest */
-{ "r2s1.ss", 0x48000410, 0xb40003ef, "e,f,g", 0 },
-{ "r2s1.sd", 0x48000490, 0xb400036f, "e,f,g", 0 },
-{ "r2s1.dd", 0x48000590, 0xb400026f, "e,f,g", 0 },
-{ "r2st.ss", 0x48000411, 0xb40003ee, "e,f,g", 0 },
-{ "r2st.sd", 0x48000491, 0xb400036e, "e,f,g", 0 },
-{ "r2st.dd", 0x48000591, 0xb400026e, "e,f,g", 0 },
-{ "r2as1.ss", 0x48000412, 0xb40003ed, "e,f,g", 0 },
-{ "r2as1.sd", 0x48000492, 0xb400036d, "e,f,g", 0 },
-{ "r2as1.dd", 0x48000592, 0xb400026d, "e,f,g", 0 },
-{ "r2ast.ss", 0x48000413, 0xb40003ec, "e,f,g", 0 },
-{ "r2ast.sd", 0x48000493, 0xb400036c, "e,f,g", 0 },
-{ "r2ast.dd", 0x48000593, 0xb400026c, "e,f,g", 0 },
-{ "i2s1.ss", 0x48000414, 0xb40003eb, "e,f,g", 0 },
-{ "i2s1.sd", 0x48000494, 0xb400036b, "e,f,g", 0 },
-{ "i2s1.dd", 0x48000594, 0xb400026b, "e,f,g", 0 },
-{ "i2st.ss", 0x48000415, 0xb40003ea, "e,f,g", 0 },
-{ "i2st.sd", 0x48000495, 0xb400036a, "e,f,g", 0 },
-{ "i2st.dd", 0x48000595, 0xb400026a, "e,f,g", 0 },
-{ "i2as1.ss", 0x48000416, 0xb40003e9, "e,f,g", 0 },
-{ "i2as1.sd", 0x48000496, 0xb4000369, "e,f,g", 0 },
-{ "i2as1.dd", 0x48000596, 0xb4000269, "e,f,g", 0 },
-{ "i2ast.ss", 0x48000417, 0xb40003e8, "e,f,g", 0 },
-{ "i2ast.sd", 0x48000497, 0xb4000368, "e,f,g", 0 },
-{ "i2ast.dd", 0x48000597, 0xb4000268, "e,f,g", 0 },
-{ "rat1s2.ss", 0x48000418, 0xb40003e7, "e,f,g", 0 },
-{ "rat1s2.sd", 0x48000498, 0xb4000367, "e,f,g", 0 },
-{ "rat1s2.dd", 0x48000598, 0xb4000267, "e,f,g", 0 },
-{ "m12asm.ss", 0x48000419, 0xb40003e6, "e,f,g", 0 },
-{ "m12asm.sd", 0x48000499, 0xb4000366, "e,f,g", 0 },
-{ "m12asm.dd", 0x48000599, 0xb4000266, "e,f,g", 0 },
-{ "ra1s2.ss", 0x4800041a, 0xb40003e5, "e,f,g", 0 },
-{ "ra1s2.sd", 0x4800049a, 0xb4000365, "e,f,g", 0 },
-{ "ra1s2.dd", 0x4800059a, 0xb4000265, "e,f,g", 0 },
-{ "m12ttsa.ss", 0x4800041b, 0xb40003e4, "e,f,g", 0 },
-{ "m12ttsa.sd", 0x4800049b, 0xb4000364, "e,f,g", 0 },
-{ "m12ttsa.dd", 0x4800059b, 0xb4000264, "e,f,g", 0 },
-{ "iat1s2.ss", 0x4800041c, 0xb40003e3, "e,f,g", 0 },
-{ "iat1s2.sd", 0x4800049c, 0xb4000363, "e,f,g", 0 },
-{ "iat1s2.dd", 0x4800059c, 0xb4000263, "e,f,g", 0 },
-{ "m12tsm.ss", 0x4800041d, 0xb40003e2, "e,f,g", 0 },
-{ "m12tsm.sd", 0x4800049d, 0xb4000362, "e,f,g", 0 },
-{ "m12tsm.dd", 0x4800059d, 0xb4000262, "e,f,g", 0 },
-{ "ia1s2.ss", 0x4800041e, 0xb40003e1, "e,f,g", 0 },
-{ "ia1s2.sd", 0x4800049e, 0xb4000361, "e,f,g", 0 },
-{ "ia1s2.dd", 0x4800059e, 0xb4000261, "e,f,g", 0 },
-{ "m12tsa.ss", 0x4800041f, 0xb40003e0, "e,f,g", 0 },
-{ "m12tsa.sd", 0x4800049f, 0xb4000360, "e,f,g", 0 },
-{ "m12tsa.dd", 0x4800059f, 0xb4000260, "e,f,g", 0 },
-
-/* Floating Point Escape Instruction Format - pfmam.p fsrc1,fsrc2,fdest */
-{ "mr2p1.ss", 0x48000000, 0xb40007ff, "e,f,g", 0 },
-{ "mr2p1.sd", 0x48000080, 0xb400077f, "e,f,g", 0 },
-{ "mr2p1.dd", 0x48000180, 0xb400067f, "e,f,g", 0 },
-{ "mr2pt.ss", 0x48000001, 0xb40007fe, "e,f,g", 0 },
-{ "mr2pt.sd", 0x48000081, 0xb400077e, "e,f,g", 0 },
-{ "mr2pt.dd", 0x48000181, 0xb400067e, "e,f,g", 0 },
-{ "mr2mp1.ss", 0x48000002, 0xb40007fd, "e,f,g", 0 },
-{ "mr2mp1.sd", 0x48000082, 0xb400077d, "e,f,g", 0 },
-{ "mr2mp1.dd", 0x48000182, 0xb400067d, "e,f,g", 0 },
-{ "mr2mpt.ss", 0x48000003, 0xb40007fc, "e,f,g", 0 },
-{ "mr2mpt.sd", 0x48000083, 0xb400077c, "e,f,g", 0 },
-{ "mr2mpt.dd", 0x48000183, 0xb400067c, "e,f,g", 0 },
-{ "mi2p1.ss", 0x48000004, 0xb40007fb, "e,f,g", 0 },
-{ "mi2p1.sd", 0x48000084, 0xb400077b, "e,f,g", 0 },
-{ "mi2p1.dd", 0x48000184, 0xb400067b, "e,f,g", 0 },
-{ "mi2pt.ss", 0x48000005, 0xb40007fa, "e,f,g", 0 },
-{ "mi2pt.sd", 0x48000085, 0xb400077a, "e,f,g", 0 },
-{ "mi2pt.dd", 0x48000185, 0xb400067a, "e,f,g", 0 },
-{ "mi2mp1.ss", 0x48000006, 0xb40007f9, "e,f,g", 0 },
-{ "mi2mp1.sd", 0x48000086, 0xb4000779, "e,f,g", 0 },
-{ "mi2mp1.dd", 0x48000186, 0xb4000679, "e,f,g", 0 },
-{ "mi2mpt.ss", 0x48000007, 0xb40007f8, "e,f,g", 0 },
-{ "mi2mpt.sd", 0x48000087, 0xb4000778, "e,f,g", 0 },
-{ "mi2mpt.dd", 0x48000187, 0xb4000678, "e,f,g", 0 },
-{ "mrmt1p2.ss", 0x48000008, 0xb40007f7, "e,f,g", 0 },
-{ "mrmt1p2.sd", 0x48000088, 0xb4000777, "e,f,g", 0 },
-{ "mrmt1p2.dd", 0x48000188, 0xb4000677, "e,f,g", 0 },
-{ "mm12mpm.ss", 0x48000009, 0xb40007f6, "e,f,g", 0 },
-{ "mm12mpm.sd", 0x48000089, 0xb4000776, "e,f,g", 0 },
-{ "mm12mpm.dd", 0x48000189, 0xb4000676, "e,f,g", 0 },
-{ "mrm1p2.ss", 0x4800000a, 0xb40007f5, "e,f,g", 0 },
-{ "mrm1p2.sd", 0x4800008a, 0xb4000775, "e,f,g", 0 },
-{ "mrm1p2.dd", 0x4800018a, 0xb4000675, "e,f,g", 0 },
-{ "mm12ttpm.ss",0x4800000b, 0xb40007f4, "e,f,g", 0 },
-{ "mm12ttpm.sd",0x4800008b, 0xb4000774, "e,f,g", 0 },
-{ "mm12ttpm.dd",0x4800018b, 0xb4000674, "e,f,g", 0 },
-{ "mimt1p2.ss", 0x4800000c, 0xb40007f3, "e,f,g", 0 },
-{ "mimt1p2.sd", 0x4800008c, 0xb4000773, "e,f,g", 0 },
-{ "mimt1p2.dd", 0x4800018c, 0xb4000673, "e,f,g", 0 },
-{ "mm12tpm.ss", 0x4800000d, 0xb40007f2, "e,f,g", 0 },
-{ "mm12tpm.sd", 0x4800008d, 0xb4000772, "e,f,g", 0 },
-{ "mm12tpm.dd", 0x4800018d, 0xb4000672, "e,f,g", 0 },
-{ "mim1p2.ss", 0x4800000e, 0xb40007f1, "e,f,g", 0 },
-{ "mim1p2.sd", 0x4800008e, 0xb4000771, "e,f,g", 0 },
-{ "mim1p2.dd", 0x4800018e, 0xb4000671, "e,f,g", 0 },
-
-/* Floating Point Escape Instruction Format - pfmsm.p fsrc1,fsrc2,fdest */
-{ "mr2s1.ss", 0x48000010, 0xb40007ef, "e,f,g", 0 },
-{ "mr2s1.sd", 0x48000090, 0xb400076f, "e,f,g", 0 },
-{ "mr2s1.dd", 0x48000190, 0xb400066f, "e,f,g", 0 },
-{ "mr2st.ss", 0x48000011, 0xb40007ee, "e,f,g", 0 },
-{ "mr2st.sd", 0x48000091, 0xb400076e, "e,f,g", 0 },
-{ "mr2st.dd", 0x48000191, 0xb400066e, "e,f,g", 0 },
-{ "mr2ms1.ss", 0x48000012, 0xb40007ed, "e,f,g", 0 },
-{ "mr2ms1.sd", 0x48000092, 0xb400076d, "e,f,g", 0 },
-{ "mr2ms1.dd", 0x48000192, 0xb400066d, "e,f,g", 0 },
-{ "mr2mst.ss", 0x48000013, 0xb40007ec, "e,f,g", 0 },
-{ "mr2mst.sd", 0x48000093, 0xb400076c, "e,f,g", 0 },
-{ "mr2mst.dd", 0x48000193, 0xb400066c, "e,f,g", 0 },
-{ "mi2s1.ss", 0x48000014, 0xb40007eb, "e,f,g", 0 },
-{ "mi2s1.sd", 0x48000094, 0xb400076b, "e,f,g", 0 },
-{ "mi2s1.dd", 0x48000194, 0xb400066b, "e,f,g", 0 },
-{ "mi2st.ss", 0x48000015, 0xb40007ea, "e,f,g", 0 },
-{ "mi2st.sd", 0x48000095, 0xb400076a, "e,f,g", 0 },
-{ "mi2st.dd", 0x48000195, 0xb400066a, "e,f,g", 0 },
-{ "mi2ms1.ss", 0x48000016, 0xb40007e9, "e,f,g", 0 },
-{ "mi2ms1.sd", 0x48000096, 0xb4000769, "e,f,g", 0 },
-{ "mi2ms1.dd", 0x48000196, 0xb4000669, "e,f,g", 0 },
-{ "mi2mst.ss", 0x48000017, 0xb40007e8, "e,f,g", 0 },
-{ "mi2mst.sd", 0x48000097, 0xb4000768, "e,f,g", 0 },
-{ "mi2mst.dd", 0x48000197, 0xb4000668, "e,f,g", 0 },
-{ "mrmt1s2.ss", 0x48000018, 0xb40007e7, "e,f,g", 0 },
-{ "mrmt1s2.sd", 0x48000098, 0xb4000767, "e,f,g", 0 },
-{ "mrmt1s2.dd", 0x48000198, 0xb4000667, "e,f,g", 0 },
-{ "mm12msm.ss", 0x48000019, 0xb40007e6, "e,f,g", 0 },
-{ "mm12msm.sd", 0x48000099, 0xb4000766, "e,f,g", 0 },
-{ "mm12msm.dd", 0x48000199, 0xb4000666, "e,f,g", 0 },
-{ "mrm1s2.ss", 0x4800001a, 0xb40007e5, "e,f,g", 0 },
-{ "mrm1s2.sd", 0x4800009a, 0xb4000765, "e,f,g", 0 },
-{ "mrm1s2.dd", 0x4800019a, 0xb4000665, "e,f,g", 0 },
-{ "mm12ttsm.ss",0x4800001b, 0xb40007e4, "e,f,g", 0 },
-{ "mm12ttsm.sd",0x4800009b, 0xb4000764, "e,f,g", 0 },
-{ "mm12ttsm.dd",0x4800019b, 0xb4000664, "e,f,g", 0 },
-{ "mimt1s2.ss", 0x4800001c, 0xb40007e3, "e,f,g", 0 },
-{ "mimt1s2.sd", 0x4800009c, 0xb4000763, "e,f,g", 0 },
-{ "mimt1s2.dd", 0x4800019c, 0xb4000663, "e,f,g", 0 },
-{ "mm12tsm.ss", 0x4800001d, 0xb40007e2, "e,f,g", 0 },
-{ "mm12tsm.sd", 0x4800009d, 0xb4000762, "e,f,g", 0 },
-{ "mm12tsm.dd", 0x4800019d, 0xb4000662, "e,f,g", 0 },
-{ "mim1s2.ss", 0x4800001e, 0xb40007e1, "e,f,g", 0 },
-{ "mim1s2.sd", 0x4800009e, 0xb4000761, "e,f,g", 0 },
-{ "mim1s2.dd", 0x4800019e, 0xb4000661, "e,f,g", 0 },
-
-
-{ "fmul.ss", 0x48000020, 0xb40007df, "e,f,g", 0 }, /* fmul.p fsrc1,fsrc2,fdest */
-{ "fmul.sd", 0x480000a0, 0xb400075f, "e,f,g", 0 }, /* fmul.p fsrc1,fsrc2,fdest */
-{ "fmul.dd", 0x480001a0, 0xb400065f, "e,f,g", 0 }, /* fmul.p fsrc1,fsrc2,fdest */
-{ "pfmul.ss", 0x48000420, 0xb40003df, "e,f,g", 0 }, /* pfmul.p fsrc1,fsrc2,fdest */
-{ "pfmul.sd", 0x480004a0, 0xb400035f, "e,f,g", 0 }, /* pfmul.p fsrc1,fsrc2,fdest */
-{ "pfmul.dd", 0x480005a0, 0xb400025f, "e,f,g", 0 }, /* pfmul.p fsrc1,fsrc2,fdest */
-{ "pfmul3.dd", 0x480005a4, 0xb400025b, "e,f,g", 0 }, /* pfmul3.p fsrc1,fsrc2,fdest */
-{ "fmlow.dd", 0x480001a1, 0xb400065e, "e,f,g", 0 }, /* fmlow.dd fsrc1,fsrc2,fdest */
-{ "frcp.ss", 0x48000022, 0xb40007dd, "f,g", 0 }, /* frcp.p fsrc2,fdest */
-{ "frcp.sd", 0x480000a2, 0xb400075d, "f,g", 0 }, /* frcp.p fsrc2,fdest */
-{ "frcp.dd", 0x480001a2, 0xb400065d, "f,g", 0 }, /* frcp.p fsrc2,fdest */
-{ "frsqr.ss", 0x48000023, 0xb40007dc, "f,g", 0 }, /* frsqr.p fsrc2,fdest */
-{ "frsqr.sd", 0x480000a3, 0xb400075c, "f,g", 0 }, /* frsqr.p fsrc2,fdest */
-{ "frsqr.dd", 0x480001a3, 0xb400065c, "f,g", 0 }, /* frsqr.p fsrc2,fdest */
-{ "fadd.ss", 0x48000030, 0xb40007cf, "e,f,g", 0 }, /* fadd.p fsrc1,fsrc2,fdest */
-{ "fadd.sd", 0x480000b0, 0xb400074f, "e,f,g", 0 }, /* fadd.p fsrc1,fsrc2,fdest */
-{ "fadd.dd", 0x480001b0, 0xb400064f, "e,f,g", 0 }, /* fadd.p fsrc1,fsrc2,fdest */
-{ "pfadd.ss", 0x48000430, 0xb40003cf, "e,f,g", 0 }, /* pfadd.p fsrc1,fsrc2,fdest */
-{ "pfadd.sd", 0x480004b0, 0xb400034f, "e,f,g", 0 }, /* pfadd.p fsrc1,fsrc2,fdest */
-{ "pfadd.dd", 0x480005b0, 0xb400024f, "e,f,g", 0 }, /* pfadd.p fsrc1,fsrc2,fdest */
-{ "fsub.ss", 0x48000031, 0xb40007ce, "e,f,g", 0 }, /* fsub.p fsrc1,fsrc2,fdest */
-{ "fsub.sd", 0x480000b1, 0xb400074e, "e,f,g", 0 }, /* fsub.p fsrc1,fsrc2,fdest */
-{ "fsub.dd", 0x480001b1, 0xb400064e, "e,f,g", 0 }, /* fsub.p fsrc1,fsrc2,fdest */
-{ "pfsub.ss", 0x48000431, 0xb40003ce, "e,f,g", 0 }, /* pfsub.p fsrc1,fsrc2,fdest */
-{ "pfsub.sd", 0x480004b1, 0xb400034e, "e,f,g", 0 }, /* pfsub.p fsrc1,fsrc2,fdest */
-{ "pfsub.dd", 0x480005b1, 0xb400024e, "e,f,g", 0 }, /* pfsub.p fsrc1,fsrc2,fdest */
-{ "fix.ss", 0x48000032, 0xb40007cd, "e,g", 0 }, /* fix.p fsrc1,fdest */
-{ "fix.sd", 0x480000b2, 0xb400074d, "e,g", 0 }, /* fix.p fsrc1,fdest */
-{ "fix.dd", 0x480001b2, 0xb400064d, "e,g", 0 }, /* fix.p fsrc1,fdest */
-{ "pfix.ss", 0x48000432, 0xb40003cd, "e,g", 0 }, /* pfix.p fsrc1,fdest */
-{ "pfix.sd", 0x480004b2, 0xb400034d, "e,g", 0 }, /* pfix.p fsrc1,fdest */
-{ "pfix.dd", 0x480005b2, 0xb400024d, "e,g", 0 }, /* pfix.p fsrc1,fdest */
-{ "famov.ss", 0x48000033, 0xb40007cc, "e,g", 0 }, /* famov.p fsrc1,fdest */
-{ "famov.ds", 0x48000133, 0xb40006cc, "e,g", 0 }, /* famov.p fsrc1,fdest */
-{ "famov.sd", 0x480000b3, 0xb400074c, "e,g", 0 }, /* famov.p fsrc1,fdest */
-{ "famov.dd", 0x480001b3, 0xb400064c, "e,g", 0 }, /* famov.p fsrc1,fdest */
-{ "pfamov.ss", 0x48000433, 0xb40003cc, "e,g", 0 }, /* pfamov.p fsrc1,fdest */
-{ "pfamov.ds", 0x48000533, 0xb40002cc, "e,g", 0 }, /* pfamov.p fsrc1,fdest */
-{ "pfamov.sd", 0x480004b3, 0xb400034c, "e,g", 0 }, /* pfamov.p fsrc1,fdest */
-{ "pfamov.dd", 0x480005b3, 0xb400024c, "e,g", 0 }, /* pfamov.p fsrc1,fdest */
-/* pfgt has R bit cleared; pfle has R bit set */
-{ "pfgt.ss", 0x48000434, 0xb40003cb, "e,f,g", 0 }, /* pfgt.p fsrc1,fsrc2,fdest */
-{ "pfgt.sd", 0x48000434, 0xb40003cb, "e,f,g", 0 }, /* pfgt.p fsrc1,fsrc2,fdest */
-{ "pfgt.dd", 0x48000534, 0xb40002cb, "e,f,g", 0 }, /* pfgt.p fsrc1,fsrc2,fdest */
-/* pfgt has R bit cleared; pfle has R bit set */
-{ "pfle.ss", 0x480004b4, 0xb400034b, "e,f,g", 0 }, /* pfle.p fsrc1,fsrc2,fdest */
-{ "pfle.sd", 0x480004b4, 0xb400034b, "e,f,g", 0 }, /* pfle.p fsrc1,fsrc2,fdest */
-{ "pfle.dd", 0x480005b4, 0xb400024b, "e,f,g", 0 }, /* pfle.p fsrc1,fsrc2,fdest */
-{ "ftrunc.ss", 0x4800003a, 0xb40007c5, "e,g", 0 }, /* ftrunc.p fsrc1,fdest */
-{ "ftrunc.sd", 0x480000ba, 0xb4000745, "e,g", 0 }, /* ftrunc.p fsrc1,fdest */
-{ "ftrunc.dd", 0x480001ba, 0xb4000645, "e,g", 0 }, /* ftrunc.p fsrc1,fdest */
-{ "pftrunc.ss", 0x4800043a, 0xb40003c5, "e,g", 0 }, /* pftrunc.p fsrc1,fdest */
-{ "pftrunc.sd", 0x480004ba, 0xb4000345, "e,g", 0 }, /* pftrunc.p fsrc1,fdest */
-{ "pftrunc.dd", 0x480005ba, 0xb4000245, "e,g", 0 }, /* pftrunc.p fsrc1,fdest */
-{ "fxfr", 0x48000040, 0xb40007bf, "e,d", 0 }, /* fxfr fsrc1,idest */
-{ "fiadd.ss", 0x48000049, 0xb40007b6, "e,f,g", 0 }, /* fiadd.w fsrc1,fsrc2,fdest */
-{ "fiadd.dd", 0x480001c9, 0xb4000636, "e,f,g", 0 }, /* fiadd.w fsrc1,fsrc2,fdest */
-{ "pfiadd.ss", 0x48000449, 0xb40003b6, "e,f,g", 0 }, /* pfiadd.w fsrc1,fsrc2,fdest */
-{ "pfiadd.dd", 0x480005c9, 0xb4000236, "e,f,g", 0 }, /* pfiadd.w fsrc1,fsrc2,fdest */
-{ "fisub.ss", 0x4800004d, 0xb40007b2, "e,f,g", 0 }, /* fisub.w fsrc1,fsrc2,fdest */
-{ "fisub.dd", 0x480001cd, 0xb4000632, "e,f,g", 0 }, /* fisub.w fsrc1,fsrc2,fdest */
-{ "pfisub.ss", 0x4800044d, 0xb40003b2, "e,f,g", 0 }, /* pfisub.w fsrc1,fsrc2,fdest */
-{ "pfisub.dd", 0x480005cd, 0xb4000232, "e,f,g", 0 }, /* pfisub.w fsrc1,fsrc2,fdest */
-{ "fzchkl", 0x48000057, 0xb40007a8, "e,f,g", 0 }, /* fzchkl fsrc1,fsrc2,fdest */
-{ "pfzchkl", 0x48000457, 0xb40003a8, "e,f,g", 0 }, /* pfzchkl fsrc1,fsrc2,fdest */
-{ "fzchks", 0x4800005f, 0xb40007a0, "e,f,g", 0 }, /* fzchks fsrc1,fsrc2,fdest */
-{ "pfzchks", 0x4800045f, 0xb40003a0, "e,f,g", 0 }, /* pfzchks fsrc1,fsrc2,fdest */
-{ "faddp", 0x48000050, 0xb40007af, "e,f,g", 0 }, /* faddp fsrc1,fsrc2,fdest */
-{ "pfaddp", 0x48000450, 0xb40003af, "e,f,g", 0 }, /* pfaddp fsrc1,fsrc2,fdest */
-{ "faddz", 0x48000051, 0xb40007ae, "e,f,g", 0 }, /* faddz fsrc1,fsrc2,fdest */
-{ "pfaddz", 0x48000451, 0xb40003ae, "e,f,g", 0 }, /* pfaddz fsrc1,fsrc2,fdest */
-{ "form", 0x4800005a, 0xb40007a5, "e,g", 0 }, /* form fsrc1,fdest */
-{ "pform", 0x4800045a, 0xb40003a5, "e,g", 0 }, /* pform fsrc1,fdest */
-
-/* Floating point pseudo-instructions */
-{ "fmov.ss", 0x48000049, 0xb7e007b6, "e,g", 0 }, /* fiadd.ss fsrc1,f0,fdest */
-{ "fmov.dd", 0x480001c9, 0xb7e00636, "e,g", 0 }, /* fiadd.dd fsrc1,f0,fdest */
-{ "fmov.sd", 0x480000b0, 0xb7e0074f, "e,g", 0 }, /* fadd.sd fsrc1,f0,fdest */
-{ "fmov.ds", 0x48000130, 0xb7e006cf, "e,g", 0 }, /* fadd.ds fsrc1,f0,fdest */
-{ "pfmov.ds", 0x48000530, 0xb73002cf, "e,g", 0 }, /* pfadd.ds fsrc1,f0,fdest */
-{ "pfmov.dd", 0x480005c9, 0xb7e00236, "e,g", 0 }, /* pfiadd.dd fsrc1,f0,fdest */
-
-
-};
-
-#define NUMOPCODES ((sizeof i860_opcodes)/(sizeof i860_opcodes[0]))
-
-
diff --git a/gnu/usr.bin/as/opcode/i960.h b/gnu/usr.bin/as/opcode/i960.h
deleted file mode 100644
index 7536699..0000000
--- a/gnu/usr.bin/as/opcode/i960.h
+++ /dev/null
@@ -1,434 +0,0 @@
-/* Basic 80960 instruction formats.
- *
- * The 'COJ' instructions are actually COBR instructions with the 'b' in
- * the mnemonic replaced by a 'j'; they are ALWAYS "de-optimized" if necessary:
- * if the displacement will not fit in 13 bits, the assembler will replace them
- * with the corresponding compare and branch instructions.
- *
- * All of the 'MEMn' instructions are the same format; the 'n' in the name
- * indicates the default index scale factor (the size of the datum operated on).
- *
- * The FBRA formats are not actually an instruction format. They are the
- * "convenience directives" for branching on floating-point comparisons,
- * each of which generates 2 instructions (a 'bno' and one other branch).
- *
- * The CALLJ format is not actually an instruction format. It indicates that
- * the instruction generated (a CTRL-format 'call') should have its relocation
- * specially flagged for link-time replacement with a 'bal' or 'calls' if
- * appropriate.
- */
-
-/* $Id$ */
-
-#define CTRL 0
-#define COBR 1
-#define COJ 2
-#define REG 3
-#define MEM1 4
-#define MEM2 5
-#define MEM4 6
-#define MEM8 7
-#define MEM12 8
-#define MEM16 9
-#define FBRA 10
-#define CALLJ 11
-
-/* Masks for the mode bits in REG format instructions */
-#define M1 0x0800
-#define M2 0x1000
-#define M3 0x2000
-
-/* Generate the 12-bit opcode for a REG format instruction by placing the
- * high 8 bits in instruction bits 24-31, the low 4 bits in instruction bits
- * 7-10.
- */
-
-#define REG_OPC(opc) ((opc & 0xff0) << 20) | ((opc & 0xf) << 7)
-
-/* Generate a template for a REG format instruction: place the opcode bits
- * in the appropriate fields and OR in mode bits for the operands that will not
- * be used. I.e.,
- * set m1=1, if src1 will not be used
- * set m2=1, if src2 will not be used
- * set m3=1, if dst will not be used
- *
- * Setting the "unused" mode bits to 1 speeds up instruction execution(!).
- * The information is also useful to us because some 1-operand REG instructions
- * use the src1 field, others the dst field; and some 2-operand REG instructions
- * use src1/src2, others src1/dst. The set mode bits enable us to distinguish.
- */
-#define R_0(opc) ( REG_OPC(opc) | M1 | M2 | M3 ) /* No operands */
-#define R_1(opc) ( REG_OPC(opc) | M2 | M3 ) /* 1 operand: src1 */
-#define R_1D(opc) ( REG_OPC(opc) | M1 | M2 ) /* 1 operand: dst */
-#define R_2(opc) ( REG_OPC(opc) | M3 ) /* 2 ops: src1/src2 */
-#define R_2D(opc) ( REG_OPC(opc) | M2 ) /* 2 ops: src1/dst */
-#define R_3(opc) ( REG_OPC(opc) ) /* 3 operands */
-
-/* DESCRIPTOR BYTES FOR REGISTER OPERANDS
- *
- * Interpret names as follows:
- * R: global or local register only
- * RS: global, local, or (if target allows) special-function register only
- * RL: global or local register, or integer literal
- * RSL: global, local, or (if target allows) special-function register;
- * or integer literal
- * F: global, local, or floating-point register
- * FL: global, local, or floating-point register; or literal (including
- * floating point)
- *
- * A number appended to a name indicates that registers must be aligned,
- * as follows:
- * 2: register number must be multiple of 2
- * 4: register number must be multiple of 4
- */
-
-#define SFR 0x10 /* Mask for the "sfr-OK" bit */
-#define LIT 0x08 /* Mask for the "literal-OK" bit */
-#define FP 0x04 /* Mask for "floating-point-OK" bit */
-
-/* This macro ors the bits together. Note that 'align' is a mask
- * for the low 0, 1, or 2 bits of the register number, as appropriate.
- */
-#define OP(align,lit,fp,sfr) ( align | lit | fp | sfr )
-
-#define R OP( 0, 0, 0, 0 )
-#define RS OP( 0, 0, 0, SFR )
-#define RL OP( 0, LIT, 0, 0 )
-#define RSL OP( 0, LIT, 0, SFR )
-#define F OP( 0, 0, FP, 0 )
-#define FL OP( 0, LIT, FP, 0 )
-#define R2 OP( 1, 0, 0, 0 )
-#define RL2 OP( 1, LIT, 0, 0 )
-#define F2 OP( 1, 0, FP, 0 )
-#define FL2 OP( 1, LIT, FP, 0 )
-#define R4 OP( 3, 0, 0, 0 )
-#define RL4 OP( 3, LIT, 0, 0 )
-#define F4 OP( 3, 0, FP, 0 )
-#define FL4 OP( 3, LIT, FP, 0 )
-
-#define M 0x7f /* Memory operand (MEMA & MEMB format instructions) */
-
-/* Macros to extract info from the register operand descriptor byte 'od'.
- */
-#define SFR_OK(od) (od & SFR) /* TRUE if sfr operand allowed */
-#define LIT_OK(od) (od & LIT) /* TRUE if literal operand allowed */
-#define FP_OK(od) (od & FP) /* TRUE if floating-point op allowed */
-#define REG_ALIGN(od,n) ((od & 0x3 & n) == 0)
- /* TRUE if reg #n is properly aligned */
-#define MEMOP(od) (od == M) /* TRUE if operand is a memory operand*/
-
-/* Description of a single i80960 instruction */
-struct i960_opcode {
- long opcode; /* 32 bits, constant fields filled in, rest zeroed */
- char *name; /* Assembler mnemonic */
- short iclass; /* Class: see #defines below */
- char format; /* REG, COBR, CTRL, MEMn, COJ, FBRA, or CALLJ */
- char num_ops; /* Number of operands */
- char operand[3];/* Operand descriptors; same order as assembler instr */
-};
-
-/* Classes of 960 intructions:
- * - each instruction falls into one class.
- * - each target architecture supports one or more classes.
- *
- * EACH CONSTANT MUST CONTAIN 1 AND ONLY 1 SET BIT!: see targ_has_iclass().
- */
-#define I_BASE 0x01 /* 80960 base instruction set */
-#define I_CX 0x02 /* 80960Cx instruction */
-#define I_DEC 0x04 /* Decimal instruction */
-#define I_FP 0x08 /* Floating point instruction */
-#define I_KX 0x10 /* 80960Kx instruction */
-#define I_MIL 0x20 /* Military instruction */
-#define I_CASIM 0x40 /* CA simulator instruction */
-
-/******************************************************************************
- *
- * TABLE OF i960 INSTRUCTION DESCRIPTIONS
- *
- ******************************************************************************/
-
-const struct i960_opcode i960_opcodes[] = {
-
- /* if a CTRL instruction has an operand, it's always a displacement */
-
- { 0x09000000, "callj", I_BASE, CALLJ, 1 },/*default=='call'*/
- { 0x08000000, "b", I_BASE, CTRL, 1 },
- { 0x09000000, "call", I_BASE, CTRL, 1 },
- { 0x0a000000, "ret", I_BASE, CTRL, 0 },
- { 0x0b000000, "bal", I_BASE, CTRL, 1 },
- { 0x10000000, "bno", I_BASE, CTRL, 1 },
- { 0x10000000, "bf", I_BASE, CTRL, 1 }, /* same as bno */
- { 0x10000000, "bru", I_BASE, CTRL, 1 }, /* same as bno */
- { 0x11000000, "bg", I_BASE, CTRL, 1 },
- { 0x11000000, "brg", I_BASE, CTRL, 1 }, /* same as bg */
- { 0x12000000, "be", I_BASE, CTRL, 1 },
- { 0x12000000, "bre", I_BASE, CTRL, 1 }, /* same as be */
- { 0x13000000, "bge", I_BASE, CTRL, 1 },
- { 0x13000000, "brge", I_BASE, CTRL, 1 }, /* same as bge */
- { 0x14000000, "bl", I_BASE, CTRL, 1 },
- { 0x14000000, "brl", I_BASE, CTRL, 1 }, /* same as bl */
- { 0x15000000, "bne", I_BASE, CTRL, 1 },
- { 0x15000000, "brlg", I_BASE, CTRL, 1 }, /* same as bne */
- { 0x16000000, "ble", I_BASE, CTRL, 1 },
- { 0x16000000, "brle", I_BASE, CTRL, 1 }, /* same as ble */
- { 0x17000000, "bo", I_BASE, CTRL, 1 },
- { 0x17000000, "bt", I_BASE, CTRL, 1 }, /* same as bo */
- { 0x17000000, "bro", I_BASE, CTRL, 1 }, /* same as bo */
- { 0x18000000, "faultno", I_BASE, CTRL, 0 },
- { 0x18000000, "faultf", I_BASE, CTRL, 0 }, /*same as faultno*/
- { 0x19000000, "faultg", I_BASE, CTRL, 0 },
- { 0x1a000000, "faulte", I_BASE, CTRL, 0 },
- { 0x1b000000, "faultge", I_BASE, CTRL, 0 },
- { 0x1c000000, "faultl", I_BASE, CTRL, 0 },
- { 0x1d000000, "faultne", I_BASE, CTRL, 0 },
- { 0x1e000000, "faultle", I_BASE, CTRL, 0 },
- { 0x1f000000, "faulto", I_BASE, CTRL, 0 },
- { 0x1f000000, "faultt", I_BASE, CTRL, 0 }, /* syn for faulto */
-
- { 0x01000000, "syscall", I_CASIM,CTRL, 0 },
-
- /* If a COBR (or COJ) has 3 operands, the last one is always a
- * displacement and does not appear explicitly in the table.
- */
-
- { 0x20000000, "testno", I_BASE, COBR, 1, R },
- { 0x21000000, "testg", I_BASE, COBR, 1, R },
- { 0x22000000, "teste", I_BASE, COBR, 1, R },
- { 0x23000000, "testge", I_BASE, COBR, 1, R },
- { 0x24000000, "testl", I_BASE, COBR, 1, R },
- { 0x25000000, "testne", I_BASE, COBR, 1, R },
- { 0x26000000, "testle", I_BASE, COBR, 1, R },
- { 0x27000000, "testo", I_BASE, COBR, 1, R },
- { 0x30000000, "bbc", I_BASE, COBR, 3, RL, RS },
- { 0x31000000, "cmpobg", I_BASE, COBR, 3, RL, RS },
- { 0x32000000, "cmpobe", I_BASE, COBR, 3, RL, RS },
- { 0x33000000, "cmpobge", I_BASE, COBR, 3, RL, RS },
- { 0x34000000, "cmpobl", I_BASE, COBR, 3, RL, RS },
- { 0x35000000, "cmpobne", I_BASE, COBR, 3, RL, RS },
- { 0x36000000, "cmpoble", I_BASE, COBR, 3, RL, RS },
- { 0x37000000, "bbs", I_BASE, COBR, 3, RL, RS },
- { 0x38000000, "cmpibno", I_BASE, COBR, 3, RL, RS },
- { 0x39000000, "cmpibg", I_BASE, COBR, 3, RL, RS },
- { 0x3a000000, "cmpibe", I_BASE, COBR, 3, RL, RS },
- { 0x3b000000, "cmpibge", I_BASE, COBR, 3, RL, RS },
- { 0x3c000000, "cmpibl", I_BASE, COBR, 3, RL, RS },
- { 0x3d000000, "cmpibne", I_BASE, COBR, 3, RL, RS },
- { 0x3e000000, "cmpible", I_BASE, COBR, 3, RL, RS },
- { 0x3f000000, "cmpibo", I_BASE, COBR, 3, RL, RS },
- { 0x31000000, "cmpojg", I_BASE, COJ, 3, RL, RS },
- { 0x32000000, "cmpoje", I_BASE, COJ, 3, RL, RS },
- { 0x33000000, "cmpojge", I_BASE, COJ, 3, RL, RS },
- { 0x34000000, "cmpojl", I_BASE, COJ, 3, RL, RS },
- { 0x35000000, "cmpojne", I_BASE, COJ, 3, RL, RS },
- { 0x36000000, "cmpojle", I_BASE, COJ, 3, RL, RS },
- { 0x38000000, "cmpijno", I_BASE, COJ, 3, RL, RS },
- { 0x39000000, "cmpijg", I_BASE, COJ, 3, RL, RS },
- { 0x3a000000, "cmpije", I_BASE, COJ, 3, RL, RS },
- { 0x3b000000, "cmpijge", I_BASE, COJ, 3, RL, RS },
- { 0x3c000000, "cmpijl", I_BASE, COJ, 3, RL, RS },
- { 0x3d000000, "cmpijne", I_BASE, COJ, 3, RL, RS },
- { 0x3e000000, "cmpijle", I_BASE, COJ, 3, RL, RS },
- { 0x3f000000, "cmpijo", I_BASE, COJ, 3, RL, RS },
-
- { 0x80000000, "ldob", I_BASE, MEM1, 2, M, R },
- { 0x82000000, "stob", I_BASE, MEM1, 2, R , M },
- { 0x84000000, "bx", I_BASE, MEM1, 1, M },
- { 0x85000000, "balx", I_BASE, MEM1, 2, M, R },
- { 0x86000000, "callx", I_BASE, MEM1, 1, M },
- { 0x88000000, "ldos", I_BASE, MEM2, 2, M, R },
- { 0x8a000000, "stos", I_BASE, MEM2, 2, R , M },
- { 0x8c000000, "lda", I_BASE, MEM1, 2, M, R },
- { 0x90000000, "ld", I_BASE, MEM4, 2, M, R },
- { 0x92000000, "st", I_BASE, MEM4, 2, R , M },
- { 0x98000000, "ldl", I_BASE, MEM8, 2, M, R2 },
- { 0x9a000000, "stl", I_BASE, MEM8, 2, R2 ,M },
- { 0xa0000000, "ldt", I_BASE, MEM12, 2, M, R4 },
- { 0xa2000000, "stt", I_BASE, MEM12, 2, R4 ,M },
- { 0xb0000000, "ldq", I_BASE, MEM16, 2, M, R4 },
- { 0xb2000000, "stq", I_BASE, MEM16, 2, R4 ,M },
- { 0xc0000000, "ldib", I_BASE, MEM1, 2, M, R },
- { 0xc2000000, "stib", I_BASE, MEM1, 2, R , M },
- { 0xc8000000, "ldis", I_BASE, MEM2, 2, M, R },
- { 0xca000000, "stis", I_BASE, MEM2, 2, R , M },
-
- { R_3(0x580), "notbit", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x581), "and", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x582), "andnot", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x583), "setbit", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x584), "notand", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x586), "xor", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x587), "or", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x588), "nor", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x589), "xnor", I_BASE, REG, 3, RSL,RSL,RS },
- { R_2D(0x58a), "not", I_BASE, REG, 2, RSL,RS },
- { R_3(0x58b), "ornot", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x58c), "clrbit", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x58d), "notor", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x58e), "nand", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x58f), "alterbit", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x590), "addo", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x591), "addi", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x592), "subo", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x593), "subi", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x598), "shro", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x59a), "shrdi", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x59b), "shri", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x59c), "shlo", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x59d), "rotate", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x59e), "shli", I_BASE, REG, 3, RSL,RSL,RS },
- { R_2(0x5a0), "cmpo", I_BASE, REG, 2, RSL,RSL },
- { R_2(0x5a1), "cmpi", I_BASE, REG, 2, RSL,RSL },
- { R_2(0x5a2), "concmpo", I_BASE, REG, 2, RSL,RSL },
- { R_2(0x5a3), "concmpi", I_BASE, REG, 2, RSL,RSL },
- { R_3(0x5a4), "cmpinco", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x5a5), "cmpinci", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x5a6), "cmpdeco", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x5a7), "cmpdeci", I_BASE, REG, 3, RSL,RSL,RS },
- { R_2(0x5ac), "scanbyte", I_BASE, REG, 2, RSL,RSL },
- { R_2(0x5ae), "chkbit", I_BASE, REG, 2, RSL,RSL },
- { R_3(0x5b0), "addc", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x5b2), "subc", I_BASE, REG, 3, RSL,RSL,RS },
- { R_2D(0x5cc), "mov", I_BASE, REG, 2, RSL,RS },
- { R_2D(0x5dc), "movl", I_BASE, REG, 2, RL2,R2 },
- { R_2D(0x5ec), "movt", I_BASE, REG, 2, RL4,R4 },
- { R_2D(0x5fc), "movq", I_BASE, REG, 2, RL4,R4 },
- { R_3(0x610), "atmod", I_BASE, REG, 3, RS, RSL,R },
- { R_3(0x612), "atadd", I_BASE, REG, 3, RS, RSL,RS },
- { R_2D(0x640), "spanbit", I_BASE, REG, 2, RSL,RS },
- { R_2D(0x641), "scanbit", I_BASE, REG, 2, RSL,RS },
- { R_3(0x645), "modac", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x650), "modify", I_BASE, REG, 3, RSL,RSL,R },
- { R_3(0x651), "extract", I_BASE, REG, 3, RSL,RSL,R },
- { R_3(0x654), "modtc", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x655), "modpc", I_BASE, REG, 3, RSL,RSL,R },
- { R_1(0x660), "calls", I_BASE, REG, 1, RSL },
- { R_0(0x66b), "mark", I_BASE, REG, 0, },
- { R_0(0x66c), "fmark", I_BASE, REG, 0, },
- { R_0(0x66d), "flushreg", I_BASE, REG, 0, },
- { R_0(0x66f), "syncf", I_BASE, REG, 0, },
- { R_3(0x670), "emul", I_BASE, REG, 3, RSL,RSL,R2 },
- { R_3(0x671), "ediv", I_BASE, REG, 3, RSL,RL2,RS },
- { R_2D(0x672), "cvtadr", I_CASIM,REG, 2, RL, R2 },
- { R_3(0x701), "mulo", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x708), "remo", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x70b), "divo", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x741), "muli", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x748), "remi", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x749), "modi", I_BASE, REG, 3, RSL,RSL,RS },
- { R_3(0x74b), "divi", I_BASE, REG, 3, RSL,RSL,RS },
-
- /* Floating-point instructions */
-
- { R_2D(0x674), "cvtir", I_FP, REG, 2, RL, F },
- { R_2D(0x675), "cvtilr", I_FP, REG, 2, RL, F },
- { R_3(0x676), "scalerl", I_FP, REG, 3, RL, FL2,F2 },
- { R_3(0x677), "scaler", I_FP, REG, 3, RL, FL, F },
- { R_3(0x680), "atanr", I_FP, REG, 3, FL, FL, F },
- { R_3(0x681), "logepr", I_FP, REG, 3, FL, FL, F },
- { R_3(0x682), "logr", I_FP, REG, 3, FL, FL, F },
- { R_3(0x683), "remr", I_FP, REG, 3, FL, FL, F },
- { R_2(0x684), "cmpor", I_FP, REG, 2, FL, FL },
- { R_2(0x685), "cmpr", I_FP, REG, 2, FL, FL },
- { R_2D(0x688), "sqrtr", I_FP, REG, 2, FL, F },
- { R_2D(0x689), "expr", I_FP, REG, 2, FL, F },
- { R_2D(0x68a), "logbnr", I_FP, REG, 2, FL, F },
- { R_2D(0x68b), "roundr", I_FP, REG, 2, FL, F },
- { R_2D(0x68c), "sinr", I_FP, REG, 2, FL, F },
- { R_2D(0x68d), "cosr", I_FP, REG, 2, FL, F },
- { R_2D(0x68e), "tanr", I_FP, REG, 2, FL, F },
- { R_1(0x68f), "classr", I_FP, REG, 1, FL },
- { R_3(0x690), "atanrl", I_FP, REG, 3, FL2,FL2,F2 },
- { R_3(0x691), "logeprl", I_FP, REG, 3, FL2,FL2,F2 },
- { R_3(0x692), "logrl", I_FP, REG, 3, FL2,FL2,F2 },
- { R_3(0x693), "remrl", I_FP, REG, 3, FL2,FL2,F2 },
- { R_2(0x694), "cmporl", I_FP, REG, 2, FL2,FL2 },
- { R_2(0x695), "cmprl", I_FP, REG, 2, FL2,FL2 },
- { R_2D(0x698), "sqrtrl", I_FP, REG, 2, FL2,F2 },
- { R_2D(0x699), "exprl", I_FP, REG, 2, FL2,F2 },
- { R_2D(0x69a), "logbnrl", I_FP, REG, 2, FL2,F2 },
- { R_2D(0x69b), "roundrl", I_FP, REG, 2, FL2,F2 },
- { R_2D(0x69c), "sinrl", I_FP, REG, 2, FL2,F2 },
- { R_2D(0x69d), "cosrl", I_FP, REG, 2, FL2,F2 },
- { R_2D(0x69e), "tanrl", I_FP, REG, 2, FL2,F2 },
- { R_1(0x69f), "classrl", I_FP, REG, 1, FL2 },
- { R_2D(0x6c0), "cvtri", I_FP, REG, 2, FL, R },
- { R_2D(0x6c1), "cvtril", I_FP, REG, 2, FL, R2 },
- { R_2D(0x6c2), "cvtzri", I_FP, REG, 2, FL, R },
- { R_2D(0x6c3), "cvtzril", I_FP, REG, 2, FL, R2 },
- { R_2D(0x6c9), "movr", I_FP, REG, 2, FL, F },
- { R_2D(0x6d9), "movrl", I_FP, REG, 2, FL2,F2 },
- { R_2D(0x6e1), "movre", I_FP, REG, 2, FL4,F4 },
- { R_3(0x6e2), "cpysre", I_FP, REG, 3, FL4,FL4,F4 },
- { R_3(0x6e3), "cpyrsre", I_FP, REG, 3, FL4,FL4,F4 },
- { R_3(0x78b), "divr", I_FP, REG, 3, FL, FL, F },
- { R_3(0x78c), "mulr", I_FP, REG, 3, FL, FL, F },
- { R_3(0x78d), "subr", I_FP, REG, 3, FL, FL, F },
- { R_3(0x78f), "addr", I_FP, REG, 3, FL, FL, F },
- { R_3(0x79b), "divrl", I_FP, REG, 3, FL2,FL2,F2 },
- { R_3(0x79c), "mulrl", I_FP, REG, 3, FL2,FL2,F2 },
- { R_3(0x79d), "subrl", I_FP, REG, 3, FL2,FL2,F2 },
- { R_3(0x79f), "addrl", I_FP, REG, 3, FL2,FL2,F2 },
-
- /* These are the floating point branch instructions. Each actually
- * generates 2 branch instructions: the first a CTRL instruction with
- * the indicated opcode, and the second a 'bno'.
- */
-
- { 0x12000000, "brue", I_FP, FBRA, 1 },
- { 0x11000000, "brug", I_FP, FBRA, 1 },
- { 0x13000000, "bruge", I_FP, FBRA, 1 },
- { 0x14000000, "brul", I_FP, FBRA, 1 },
- { 0x16000000, "brule", I_FP, FBRA, 1 },
- { 0x15000000, "brulg", I_FP, FBRA, 1 },
-
-
- /* Decimal instructions */
-
- { R_3(0x642), "daddc", I_DEC, REG, 3, RSL,RSL,RS },
- { R_3(0x643), "dsubc", I_DEC, REG, 3, RSL,RSL,RS },
- { R_2D(0x644), "dmovt", I_DEC, REG, 2, RSL,RS },
-
-
- /* KX extensions */
-
- { R_2(0x600), "synmov", I_KX, REG, 2, R, R },
- { R_2(0x601), "synmovl", I_KX, REG, 2, R, R },
- { R_2(0x602), "synmovq", I_KX, REG, 2, R, R },
- { R_2D(0x615), "synld", I_KX, REG, 2, R, R },
-
-
- /* MC extensions */
-
- { R_3(0x603), "cmpstr", I_MIL, REG, 3, R, R, RL },
- { R_3(0x604), "movqstr", I_MIL, REG, 3, R, R, RL },
- { R_3(0x605), "movstr", I_MIL, REG, 3, R, R, RL },
- { R_2D(0x613), "inspacc", I_MIL, REG, 2, R, R },
- { R_2D(0x614), "ldphy", I_MIL, REG, 2, R, R },
- { R_3(0x617), "fill", I_MIL, REG, 3, R, RL, RL },
- { R_2D(0x646), "condrec", I_MIL, REG, 2, R, R },
- { R_2D(0x656), "receive", I_MIL, REG, 2, R, R },
- { R_3(0x662), "send", I_MIL, REG, 3, R, RL, R },
- { R_1(0x663), "sendserv", I_MIL, REG, 1, R },
- { R_1(0x664), "resumprcs", I_MIL, REG, 1, R },
- { R_1(0x665), "schedprcs", I_MIL, REG, 1, R },
- { R_0(0x666), "saveprcs", I_MIL, REG, 0, },
- { R_1(0x668), "condwait", I_MIL, REG, 1, R },
- { R_1(0x669), "wait", I_MIL, REG, 1, R },
- { R_1(0x66a), "signal", I_MIL, REG, 1, R },
- { R_1D(0x673), "ldtime", I_MIL, REG, 1, R2 },
-
-
- /* CX extensions */
-
- { R_3(0x5d8), "eshro", I_CX, REG, 3, RSL,RSL,RS },
- { R_3(0x630), "sdma", I_CX, REG, 3, RSL,RSL,RL },
- { R_3(0x631), "udma", I_CX, REG, 0 },
- { R_3(0x659), "sysctl", I_CX, REG, 3, RSL,RSL,RL },
-
-
- /* END OF TABLE */
-
- { 0, NULL, 0, 0 }
-};
-
- /* end of i960-opcode.h */
diff --git a/gnu/usr.bin/as/opcode/m68k.h b/gnu/usr.bin/as/opcode/m68k.h
deleted file mode 100644
index bd35495..0000000
--- a/gnu/usr.bin/as/opcode/m68k.h
+++ /dev/null
@@ -1,1998 +0,0 @@
-/* Opcode table for m680[01234]0/m6888[12]/m68851.
- Copyright (C) 1989, 1991 Free Software Foundation.
-
-This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler.
-
-Both GDB and GAS are free software; you can redistribute and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* These are used as bit flags for arch below. */
-
-enum m68k_architecture {
- m68000 = 0x01,
- m68008 = m68000, /* synonym for -m68000. otherwise unused. */
- m68010 = 0x02,
- m68020 = 0x04,
- m68030 = 0x08,
- m68040 = 0x10,
- m68881 = 0x20,
- m68882 = m68881, /* synonym for -m68881. otherwise unused. */
- m68851 = 0x40,
-
- /* handy aliases */
- m68040up = m68040,
- m68030up = (m68030 | m68040up),
- m68020up = (m68020 | m68030up),
- m68010up = (m68010 | m68020up),
- m68000up = (m68000 | m68010up),
-
- mfloat = (m68881 | m68882 | m68040),
- mmmu = (m68851 | m68030 | m68040)
-}; /* enum m68k_architecture */
-
- /* note that differences in addressing modes that aren't distinguished
- in the following table are handled explicitly by gas. */
-
-struct m68k_opcode {
- char *name;
- unsigned long opcode;
- unsigned long match;
- char *args;
- enum m68k_architecture arch;
-};
-
-/* We store four bytes of opcode for all opcodes because that
- is the most any of them need. The actual length of an instruction
- is always at least 2 bytes, and is as much longer as necessary to
- hold the operands it has.
-
- The match component is a mask saying which bits must match
- particular opcode in order for an instruction to be an instance
- of that opcode.
-
- The args component is a string containing two characters
- for each operand of the instruction. The first specifies
- the kind of operand; the second, the place it is stored. */
-
-/* Kinds of operands:
- D data register only. Stored as 3 bits.
- A address register only. Stored as 3 bits.
- a address register indirect only. Stored as 3 bits.
- R either kind of register. Stored as 4 bits.
- F floating point coprocessor register only. Stored as 3 bits.
- O an offset (or width): immediate data 0-31 or data register.
- Stored as 6 bits in special format for BF... insns.
- + autoincrement only. Stored as 3 bits (number of the address register).
- - autodecrement only. Stored as 3 bits (number of the address register).
- Q quick immediate data. Stored as 3 bits.
- This matches an immediate operand only when value is in range 1 .. 8.
- M moveq immediate data. Stored as 8 bits.
- This matches an immediate operand only when value is in range -128..127
- T trap vector immediate data. Stored as 4 bits.
-
- k K-factor for fmove.p instruction. Stored as a 7-bit constant or
- a three bit register offset, depending on the field type.
-
- # immediate data. Stored in special places (b, w or l)
- which say how many bits to store.
- ^ immediate data for floating point instructions. Special places
- are offset by 2 bytes from '#'...
- B pc-relative address, converted to an offset
- that is treated as immediate data.
- d displacement and register. Stores the register as 3 bits
- and stores the displacement in the entire second word.
-
- C the CCR. No need to store it; this is just for filtering validity.
- S the SR. No need to store, just as with CCR.
- U the USP. No need to store, just as with CCR.
-
- I Coprocessor ID. Not printed if 1. The Coprocessor ID is always
- extracted from the 'd' field of word one, which means that an extended
- coprocessor opcode can be skipped using the 'i' place, if needed.
-
- s System Control register for the floating point coprocessor.
- S List of system control registers for floating point coprocessor.
-
- J Misc register for movec instruction, stored in 'j' format.
- Possible values:
- 0x000 SFC Source Function Code reg [40, 30, 20, 10]
- 0x001 DFC Data Function Code reg [40, 30, 20, 10]
- 0x002 CACR Cache Control Register [40, 30, 20]
- 0x800 USP User Stack Pointer [40, 30, 20, 10]
- 0x801 VBR Vector Base reg [40, 30, 20, 10]
- 0x802 CAAR Cache Address Register [ 30, 20]
- 0x803 MSP Master Stack Pointer [40, 30, 20]
- 0x804 ISP Interrupt Stack Pointer [40, 30, 20]
- 0x003 TC MMU Translation Control [40]
- 0x004 ITT0 Instruction Transparent
- Translation reg 0 [40]
- 0x005 ITT1 Instruction Transparent
- Translation reg 1 [40]
- 0x006 DTT0 Data Transparent
- Translation reg 0 [40]
- 0x007 DTT1 Data Transparent
- Translation reg 1 [40]
- 0x805 MMUSR MMU Status reg [40]
- 0x806 URP User Root Pointer [40]
- 0x807 SRP Supervisor Root Pointer [40]
-
- L Register list of the type d0-d7/a0-a7 etc.
- (New! Improved! Can also hold fp0-fp7, as well!)
- The assembler tries to see if the registers match the insn by
- looking at where the insn wants them stored.
-
- l Register list like L, but with all the bits reversed.
- Used for going the other way. . .
-
- c cache identifier which may be "nc" for no cache, "ic"
- for instruction cache, "dc" for data cache, or "bc"
- for both caches. Used in cinv and cpush. Always
- stored in position "d".
-
- They are all stored as 6 bits using an address mode and a register number;
- they differ in which addressing modes they match.
-
- * all (modes 0-6,7.*)
- ~ alterable memory (modes 2-6,7.0,7.1)(not 0,1,7.~)
- % alterable (modes 0-6,7.0,7.1)(not 7.~)
- ; data (modes 0,2-6,7.*)(not 1)
- @ data, but not immediate (modes 0,2-6,7.? ? ?)(not 1,7.?) This may really be ;, the 68020 book says it is
- ! control (modes 2,5,6,7.*-)(not 0,1,3,4,7.4)
- & alterable control (modes 2,5,6,7.0,7.1)(not 0,1,7.? ? ?)
- $ alterable data (modes 0,2-6,7.0,7.1)(not 1,7.~)
- ? alterable control, or data register (modes 0,2,5,6,7.0,7.1)(not 1,3,4,7.~)
- / control, or data register (modes 0,2,5,6,7.0,7.1,7.2,7.3)(not 1,3,4,7.4)
-*/
-
-/* JF: for the 68851 */
-/*
- I didn't use much imagination in choosing the
- following codes, so many of them aren't very
- mnemonic. -rab
-
- P pmmu register
- Possible values:
- 000 TC Translation Control reg
- 100 CAL Current Access Level
- 101 VAL Validate Access Level
- 110 SCC Stack Change Control
- 111 AC Access Control
-
- W wide pmmu registers
- Possible values:
- 001 DRP Dma Root Pointer
- 010 SRP Supervisor Root Pointer
- 011 CRP Cpu Root Pointer
-
- f function code register
- 0 SFC
- 1 DFC
-
- V VAL register only
-
- X BADx, BACx
- 100 BAD Breakpoint Acknowledge Data
- 101 BAC Breakpoint Acknowledge Control
-
- Y PSR
- Z PCSR
-
- | memory (modes 2-6, 7.*)
-
-*/
-
-/* Places to put an operand, for non-general operands:
- s source, low bits of first word.
- d dest, shifted 9 in first word
- 1 second word, shifted 12
- 2 second word, shifted 6
- 3 second word, shifted 0
- 4 third word, shifted 12
- 5 third word, shifted 6
- 6 third word, shifted 0
- 7 second word, shifted 7
- 8 second word, shifted 10
- D store in both place 1 and place 3; for divul and divsl.
- B first word, low byte, for branch displacements
- W second word (entire), for branch displacements
- L second and third words (entire), for branch displacements (also overloaded for move16)
- b second word, low byte
- w second word (entire) [variable word/long branch offset for dbra]
- l second and third word (entire)
- g variable branch offset for bra and similar instructions.
- The place to store depends on the magnitude of offset.
- t store in both place 7 and place 8; for floating point operations
- c branch offset for cpBcc operations.
- The place to store is word two if bit six of word one is zero,
- and words two and three if bit six of word one is one.
- i Increment by two, to skip over coprocessor extended operands. Only
- works with the 'I' format.
- k Dynamic K-factor field. Bits 6-4 of word 2, used as a register number.
- Also used for dynamic fmovem instruction.
- C floating point coprocessor constant - 7 bits. Also used for static
- K-factors...
- j Movec register #, stored in 12 low bits of second word.
-
- Places to put operand, for general operands:
- d destination, shifted 6 bits in first word
- b source, at low bit of first word, and immediate uses one byte
- w source, at low bit of first word, and immediate uses two bytes
- l source, at low bit of first word, and immediate uses four bytes
- s source, at low bit of first word.
- Used sometimes in contexts where immediate is not allowed anyway.
- f single precision float, low bit of 1st word, immediate uses 4 bytes
- F double precision float, low bit of 1st word, immediate uses 8 bytes
- x extended precision float, low bit of 1st word, immediate uses 12 bytes
- p packed float, low bit of 1st word, immediate uses 12 bytes
-*/
-
-#define one(x) ((x) << 16)
-#define two(x, y) (((x) << 16) + y)
-
-/*
- *** DANGER WILL ROBINSON ***
-
- The assembler requires that all instances of the same mnemonic must be
- consecutive. If they aren't, the assembler will bomb at runtime
- */
-struct m68k_opcode m68k_opcodes[] =
-{
-{"abcd", one(0140400), one(0170770), "DsDd", m68000up },
-{"abcd", one(0140410), one(0170770), "-s-d", m68000up },
-
- /* Add instructions */
-{"addal", one(0150700), one(0170700), "*lAd", m68000up },
-{"addaw", one(0150300), one(0170700), "*wAd", m68000up },
-{"addib", one(0003000), one(0177700), "#b$b", m68000up },
-{"addil", one(0003200), one(0177700), "#l$l", m68000up },
-{"addiw", one(0003100), one(0177700), "#w$w", m68000up },
-{"addqb", one(0050000), one(0170700), "Qd$b", m68000up },
-{"addql", one(0050200), one(0170700), "Qd%l", m68000up },
-{"addqw", one(0050100), one(0170700), "Qd%w", m68000up },
-
-{"addb", one(0050000), one(0170700), "Qd$b", m68000up }, /* addq written as add */
-{"addb", one(0003000), one(0177700), "#b$b", m68000up }, /* addi written as add */
-{"addb", one(0150000), one(0170700), ";bDd", m68000up }, /* addb <ea>, Dd */
-{"addb", one(0150400), one(0170700), "Dd~b", m68000up }, /* addb Dd, <ea> */
-
-{"addw", one(0050100), one(0170700), "Qd%w", m68000up }, /* addq written as add */
-{"addw", one(0003100), one(0177700), "#w$w", m68000up }, /* addi written as add */
-{"addw", one(0150300), one(0170700), "*wAd", m68000up }, /* adda written as add */
-{"addw", one(0150100), one(0170700), "*wDd", m68000up }, /* addw <ea>, Dd */
-{"addw", one(0150500), one(0170700), "Dd~w", m68000up }, /* addw Dd, <ea> */
-
-{"addl", one(0050200), one(0170700), "Qd%l", m68000up }, /* addq written as add */
-{"addl", one(0003200), one(0177700), "#l$l", m68000up }, /* addi written as add */
-{"addl", one(0150700), one(0170700), "*lAd", m68000up }, /* adda written as add */
-{"addl", one(0150200), one(0170700), "*lDd", m68000up }, /* addl <ea>, Dd */
-{"addl", one(0150600), one(0170700), "Dd~l", m68000up }, /* addl Dd, <ea> */
-
-{"addxb", one(0150400), one(0170770), "DsDd", m68000up },
-{"addxb", one(0150410), one(0170770), "-s-d", m68000up },
-{"addxl", one(0150600), one(0170770), "DsDd", m68000up },
-{"addxl", one(0150610), one(0170770), "-s-d", m68000up },
-{"addxw", one(0150500), one(0170770), "DsDd", m68000up },
-{"addxw", one(0150510), one(0170770), "-s-d", m68000up },
-
-{"andib", one(0001000), one(0177700), "#b$b", m68000up },
-{"andib", one(0001074), one(0177777), "#bCb", m68000up }, /* andi to ccr */
-{"andiw", one(0001100), one(0177700), "#w$w", m68000up },
-{"andiw", one(0001174), one(0177777), "#wSw", m68000up }, /* andi to sr */
-{"andil", one(0001200), one(0177700), "#l$l", m68000up },
-
-{"andb", one(0001000), one(0177700), "#b$b", m68000up }, /* andi written as or */
-{"andb", one(0001074), one(0177777), "#bCb", m68000up }, /* andi to ccr */
-{"andb", one(0140000), one(0170700), ";bDd", m68000up }, /* memory to register */
-{"andb", one(0140400), one(0170700), "Dd~b", m68000up }, /* register to memory */
-{"andw", one(0001100), one(0177700), "#w$w", m68000up }, /* andi written as or */
-{"andw", one(0001174), one(0177777), "#wSw", m68000up }, /* andi to sr */
-{"andw", one(0140100), one(0170700), ";wDd", m68000up }, /* memory to register */
-{"andw", one(0140500), one(0170700), "Dd~w", m68000up }, /* register to memory */
-{"andl", one(0001200), one(0177700), "#l$l", m68000up }, /* andi written as or */
-{"andl", one(0140200), one(0170700), ";lDd", m68000up }, /* memory to register */
-{"andl", one(0140600), one(0170700), "Dd~l", m68000up }, /* register to memory */
-
-{"aslb", one(0160400), one(0170770), "QdDs", m68000up },
-{"aslb", one(0160440), one(0170770), "DdDs", m68000up },
-{"asll", one(0160600), one(0170770), "QdDs", m68000up },
-{"asll", one(0160640), one(0170770), "DdDs", m68000up },
-{"aslw", one(0160500), one(0170770), "QdDs", m68000up },
-{"aslw", one(0160540), one(0170770), "DdDs", m68000up },
-{"aslw", one(0160700), one(0177700), "~s", m68000up }, /* Shift memory */
-{"asrb", one(0160000), one(0170770), "QdDs", m68000up },
-{"asrb", one(0160040), one(0170770), "DdDs", m68000up },
-{"asrl", one(0160200), one(0170770), "QdDs", m68000up },
-{"asrl", one(0160240), one(0170770), "DdDs", m68000up },
-{"asrw", one(0160100), one(0170770), "QdDs", m68000up },
-{"asrw", one(0160140), one(0170770), "DdDs", m68000up },
-{"asrw", one(0160300), one(0177700), "~s", m68000up }, /* Shift memory */
-
-/* Fixed-size branches with 16-bit offsets */
-
-{"bhi", one(0061000), one(0177777), "BW", m68000up },
-{"bls", one(0061400), one(0177777), "BW", m68000up },
-{"bcc", one(0062000), one(0177777), "BW", m68000up },
-{"bcs", one(0062400), one(0177777), "BW", m68000up },
-{"bne", one(0063000), one(0177777), "BW", m68000up },
-{"beq", one(0063400), one(0177777), "BW", m68000up },
-{"bvc", one(0064000), one(0177777), "BW", m68000up },
-{"bvs", one(0064400), one(0177777), "BW", m68000up },
-{"bpl", one(0065000), one(0177777), "BW", m68000up },
-{"bmi", one(0065400), one(0177777), "BW", m68000up },
-{"bge", one(0066000), one(0177777), "BW", m68000up },
-{"blt", one(0066400), one(0177777), "BW", m68000up },
-{"bgt", one(0067000), one(0177777), "BW", m68000up },
-{"ble", one(0067400), one(0177777), "BW", m68000up },
-{"bra", one(0060000), one(0177777), "BW", m68000up },
-{"bsr", one(0060400), one(0177777), "BW", m68000up },
-
-/* Fixed-size branches with short (byte) offsets */
-
-{"bhis", one(0061000), one(0177400), "BB", m68000up },
-{"blss", one(0061400), one(0177400), "BB", m68000up },
-{"bccs", one(0062000), one(0177400), "BB", m68000up },
-{"bcss", one(0062400), one(0177400), "BB", m68000up },
-{"bnes", one(0063000), one(0177400), "BB", m68000up },
-{"beqs", one(0063400), one(0177400), "BB", m68000up },
-{"bvcs", one(0064000), one(0177400), "BB", m68000up },
-{"bvss", one(0064400), one(0177400), "BB", m68000up },
-{"bpls", one(0065000), one(0177400), "BB", m68000up },
-{"bmis", one(0065400), one(0177400), "BB", m68000up },
-{"bges", one(0066000), one(0177400), "BB", m68000up },
-{"blts", one(0066400), one(0177400), "BB", m68000up },
-{"bgts", one(0067000), one(0177400), "BB", m68000up },
-{"bles", one(0067400), one(0177400), "BB", m68000up },
-{"bras", one(0060000), one(0177400), "BB", m68000up },
-{"bsrs", one(0060400), one(0177400), "BB", m68000up },
-
-/* Fixed-size branches with long (32-bit) offsets */
-
-{"bhil", one(0061377), one(0177777), "BL", m68020up },
-{"blsl", one(0061777), one(0177777), "BL", m68020up },
-{"bccl", one(0062377), one(0177777), "BL", m68020up },
-{"bcsl", one(0062777), one(0177777), "BL", m68020up },
-{"bnel", one(0063377), one(0177777), "BL", m68020up },
-{"beql", one(0063777), one(0177777), "BL", m68020up },
-{"bvcl", one(0064377), one(0177777), "BL", m68020up },
-{"bvsl", one(0064777), one(0177777), "BL", m68020up },
-{"bpll", one(0065377), one(0177777), "BL", m68020up },
-{"bmil", one(0065777), one(0177777), "BL", m68020up },
-{"bgel", one(0066377), one(0177777), "BL", m68020up },
-{"bltl", one(0066777), one(0177777), "BL", m68020up },
-{"bgtl", one(0067377), one(0177777), "BL", m68020up },
-{"blel", one(0067777), one(0177777), "BL", m68020up },
-{"bral", one(0060377), one(0177777), "BL", m68020up },
-{"bsrl", one(0060777), one(0177777), "BL", m68020up },
-
-/* We now return you to our regularly scheduled instruction set */
-
-{"bchg", one(0000500), one(0170700), "Dd$s", m68000up },
-{"bchg", one(0004100), one(0177700), "#b$s", m68000up },
-{"bclr", one(0000600), one(0170700), "Dd$s", m68000up },
-{"bclr", one(0004200), one(0177700), "#b$s", m68000up },
-
-{"bfchg", two(0165300, 0), two(0177700, 0170000), "?sO2O3", m68020up },
-{"bfclr", two(0166300, 0), two(0177700, 0170000), "?sO2O3", m68020up },
-{"bfexts", two(0165700, 0), two(0177700, 0100000), "/sO2O3D1", m68020up },
-{"bfextu", two(0164700, 0), two(0177700, 0100000), "/sO2O3D1", m68020up },
-{"bfffo", two(0166700, 0), two(0177700, 0100000), "/sO2O3D1", m68020up },
-{"bfins", two(0167700, 0), two(0177700, 0100000), "D1?sO2O3", m68020up },
-{"bfset", two(0167300, 0), two(0177700, 0170000), "?sO2O3", m68020up },
-{"bftst", two(0164300, 0), two(0177700, 0170000), "/sO2O3", m68020up },
-{"bkpt", one(0044110), one(0177770), "Qs", m68020up },
-
-{"bset", one(0000700), one(0170700), "Dd$s", m68000up },
-{"bset", one(0004300), one(0177700), "#b$s", m68000up },
-{"btst", one(0000400), one(0170700), "Dd@s", m68000up },
-{"btst", one(0004000), one(0177700), "#b@s", m68000up },
-
-
-{"callm", one(0003300), one(0177700), "#b!s", m68020 },
-
-{"cas2l", two(0007374, 0), two(0177777, 0107070), "D3D6D2D5R1R4", m68020up }, /* JF FOO really a 3 word ins */
-{"cas2w", two(0006374, 0), two(0177777, 0107070), "D3D6D2D5R1R4", m68020up }, /* JF ditto */
-{"casb", two(0005300, 0), two(0177700, 0177070), "D3D2~s", m68020up },
-{"casl", two(0007300, 0), two(0177700, 0177070), "D3D2~s", m68020up },
-{"casw", two(0006300, 0), two(0177700, 0177070), "D3D2~s", m68020up },
-
-/* {"chk", one(0040600), one(0170700), ";wDd"}, JF FOO this looks wrong */
-{"chk2b", two(0000300, 0004000), two(0177700, 07777), "!sR1", m68020up },
-{"chk2l", two(0002300, 0004000), two(0177700, 07777), "!sR1", m68020up },
-{"chk2w", two(0001300, 0004000), two(0177700, 07777), "!sR1", m68020up },
-{"chkl", one(0040400), one(0170700), ";lDd", m68000up },
-{"chkw", one(0040600), one(0170700), ";wDd", m68000up },
-
-#define SCOPE_LINE (0x1 << 3)
-#define SCOPE_PAGE (0x2 << 3)
-#define SCOPE_ALL (0x3 << 3)
-{"cinva", one(0xf400|SCOPE_ALL), one(0xff38), "ce", m68040 },
-{"cinvl", one(0xf400|SCOPE_LINE), one(0xff38), "ceas", m68040 },
-{"cinvp", one(0xf400|SCOPE_PAGE), one(0xff38), "ceas", m68040 },
-
-{"cpusha", one(0xf420|SCOPE_ALL), one(0xff38), "ce", m68040 },
-{"cpushl", one(0xf420|SCOPE_LINE), one(0xff38), "ceas", m68040 },
-{"cpushp", one(0xf420|SCOPE_PAGE), one(0xff38), "ceas", m68040 },
-
-#undef SCOPE_LINE
-#undef SCOPE_PAGE
-#undef SCOPE_ALL
-
-{"clrb", one(0041000), one(0177700), "$s", m68000up },
-{"clrl", one(0041200), one(0177700), "$s", m68000up },
-{"clrw", one(0041100), one(0177700), "$s", m68000up },
-
-{"cmp2b", two(0000300, 0), two(0177700, 07777), "!sR1", m68020up },
-{"cmp2l", two(0002300, 0), two(0177700, 07777), "!sR1", m68020up },
-{"cmp2w", two(0001300, 0), two(0177700, 07777), "!sR1", m68020up },
-{"cmpal", one(0130700), one(0170700), "*lAd", m68000up },
-{"cmpaw", one(0130300), one(0170700), "*wAd", m68000up },
-{"cmpib", one(0006000), one(0177700), "#b;b", m68000up },
-{"cmpil", one(0006200), one(0177700), "#l;l", m68000up },
-{"cmpiw", one(0006100), one(0177700), "#w;w", m68000up },
-{"cmpb", one(0006000), one(0177700), "#b;b", m68000up }, /* cmpi written as cmp */
-{"cmpb", one(0130000), one(0170700), ";bDd", m68000up },
-{"cmpw", one(0006100), one(0177700), "#w;w", m68000up },
-{"cmpw", one(0130100), one(0170700), "*wDd", m68000up },
-{"cmpw", one(0130300), one(0170700), "*wAd", m68000up }, /* cmpa written as cmp */
-{"cmpl", one(0006200), one(0177700), "#l;l", m68000up },
-{"cmpl", one(0130200), one(0170700), "*lDd", m68000up },
-{"cmpl", one(0130700), one(0170700), "*lAd", m68000up },
-{"cmpmb", one(0130410), one(0170770), "+s+d", m68000up },
-{"cmpml", one(0130610), one(0170770), "+s+d", m68000up },
-{"cmpmw", one(0130510), one(0170770), "+s+d", m68000up },
-
-{"dbcc", one(0052310), one(0177770), "DsBw", m68000up },
-{"dbcs", one(0052710), one(0177770), "DsBw", m68000up },
-{"dbeq", one(0053710), one(0177770), "DsBw", m68000up },
-{"dbf", one(0050710), one(0177770), "DsBw", m68000up },
-{"dbge", one(0056310), one(0177770), "DsBw", m68000up },
-{"dbgt", one(0057310), one(0177770), "DsBw", m68000up },
-{"dbhi", one(0051310), one(0177770), "DsBw", m68000up },
-{"dble", one(0057710), one(0177770), "DsBw", m68000up },
-{"dbls", one(0051710), one(0177770), "DsBw", m68000up },
-{"dblt", one(0056710), one(0177770), "DsBw", m68000up },
-{"dbmi", one(0055710), one(0177770), "DsBw", m68000up },
-{"dbne", one(0053310), one(0177770), "DsBw", m68000up },
-{"dbpl", one(0055310), one(0177770), "DsBw", m68000up },
-{"dbra", one(0050710), one(0177770), "DsBw", m68000up },
-{"dbt", one(0050310), one(0177770), "DsBw", m68000up },
-{"dbvc", one(0054310), one(0177770), "DsBw", m68000up },
-{"dbvs", one(0054710), one(0177770), "DsBw", m68000up },
-
-{"divsl", two(0046100, 0006000), two(0177700, 0107770), ";lD3D1", m68020up },
-{"divsl", two(0046100, 0004000), two(0177700, 0107770), ";lDD", m68020up },
-{"divsll", two(0046100, 0004000), two(0177700, 0107770), ";lD3D1", m68020up },
-{"divsw", one(0100700), one(0170700), ";wDd", m68000up },
-{"divs", one(0100700), one(0170700), ";wDd", m68000up },
-{"divul", two(0046100, 0002000), two(0177700, 0107770), ";lD3D1", m68020up },
-{"divul", two(0046100, 0000000), two(0177700, 0107770), ";lDD", m68020up },
-{"divull", two(0046100, 0000000), two(0177700, 0107770), ";lD3D1", m68020up },
-{"divuw", one(0100300), one(0170700), ";wDd", m68000up },
-{"divu", one(0100300), one(0170700), ";wDd", m68000up },
-{"eorb", one(0005000), one(0177700), "#b$s", m68000up }, /* eori written as or */
-{"eorb", one(0005074), one(0177777), "#bCs", m68000up }, /* eori to ccr */
-{"eorb", one(0130400), one(0170700), "Dd$s", m68000up }, /* register to memory */
-{"eorib", one(0005000), one(0177700), "#b$s", m68000up },
-{"eorib", one(0005074), one(0177777), "#bCs", m68000up }, /* eori to ccr */
-{"eoril", one(0005200), one(0177700), "#l$s", m68000up },
-{"eoriw", one(0005100), one(0177700), "#w$s", m68000up },
-{"eoriw", one(0005174), one(0177777), "#wSs", m68000up }, /* eori to sr */
-{"eorl", one(0005200), one(0177700), "#l$s", m68000up },
-{"eorl", one(0130600), one(0170700), "Dd$s", m68000up },
-{"eorw", one(0005100), one(0177700), "#w$s", m68000up },
-{"eorw", one(0005174), one(0177777), "#wSs", m68000up }, /* eori to sr */
-{"eorw", one(0130500), one(0170700), "Dd$s", m68000up },
-
-{"exg", one(0140500), one(0170770), "DdDs", m68000up },
-{"exg", one(0140510), one(0170770), "AdAs", m68000up },
-{"exg", one(0140610), one(0170770), "DdAs", m68000up },
-{"exg", one(0140610), one(0170770), "AsDd", m68000up },
-
-{"extw", one(0044200), one(0177770), "Ds", m68000up },
-{"extl", one(0044300), one(0177770), "Ds", m68000up },
-{"extbl", one(0044700), one(0177770), "Ds", m68020up },
-{"extb.l", one(0044700), one(0177770), "Ds", m68020up }, /* Not sure we should support this one */
-
-/* float stuff starts here */
-{"fabsb", two(0xF000, 0x5818), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fabsd", two(0xF000, 0x5418), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fabsl", two(0xF000, 0x4018), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fabsp", two(0xF000, 0x4C18), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fabss", two(0xF000, 0x4418), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fabsw", two(0xF000, 0x5018), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fabsx", two(0xF000, 0x4818), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-/* FIXME-NOW: The '040 book that I have claims that these should be
- coded exactly like fadd. In fact, the table of opmodes calls them
- fadd, fsadd, fdadd. That can't be right. If someone can give me the
- right encoding, I'll fix it. By induction, I *think* the right
- encoding is 38 & 3c, but I'm not sure.
-
- in the mean time, if you know the encoding for the opmode field, you
- can replace all of the "38),"'s and "3c),"'s below with the corrected
- values and these guys should then just work. xoxorich. 31Aug91 */
-{"fsabsb", two(0xF000, 0x5858), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fsabsd", two(0xF000, 0x5458), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fsabsl", two(0xF000, 0x4058), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fsabsp", two(0xF000, 0x4C58), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fsabss", two(0xF000, 0x4458), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fsabsw", two(0xF000, 0x5058), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fsabsx", two(0xF000, 0x0058), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fsabsx", two(0xF000, 0x4858), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-{"fsabsx", two(0xF000, 0x0058), two(0xF1C0, 0xE07F), "IiFt", m68040 },
-
-{"fdabsb", two(0xF000, 0x585c), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040},
-{"fdabsd", two(0xF000, 0x545c), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040},
-{"fdabsl", two(0xF000, 0x405c), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040},
-{"fdabsp", two(0xF000, 0x4C5c), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040},
-{"fdabss", two(0xF000, 0x445c), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040},
-{"fdabsw", two(0xF000, 0x505c), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040},
-{"fdabsx", two(0xF000, 0x005c), two(0xF1C0, 0xE07F), "IiF8F7", m68040},
-{"fdabsx", two(0xF000, 0x485c), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040},
-{"fdabsx", two(0xF000, 0x005c), two(0xF1C0, 0xE07F), "IiFt", m68040},
-
-{"facosb", two(0xF000, 0x581C), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"facosd", two(0xF000, 0x541C), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"facosl", two(0xF000, 0x401C), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"facosp", two(0xF000, 0x4C1C), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"facoss", two(0xF000, 0x441C), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"facosw", two(0xF000, 0x501C), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"facosx", two(0xF000, 0x481C), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"faddb", two(0xF000, 0x5822), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"faddd", two(0xF000, 0x5422), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"faddl", two(0xF000, 0x4022), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"faddp", two(0xF000, 0x4C22), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fadds", two(0xF000, 0x4422), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"faddw", two(0xF000, 0x5022), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"faddx", two(0xF000, 0x4822), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-/* {"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF removed */
-{"fsaddb", two(0xF000, 0x5862), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fsaddd", two(0xF000, 0x5462), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fsaddl", two(0xF000, 0x4062), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fsaddp", two(0xF000, 0x4C62), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fsadds", two(0xF000, 0x4462), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fsaddw", two(0xF000, 0x5062), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fsaddx", two(0xF000, 0x0062), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fsaddx", two(0xF000, 0x4862), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-/* {"fsaddx", two(0xF000, 0x0062), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF removed */
-{"fdaddb", two(0xF000, 0x5866), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fdaddd", two(0xF000, 0x5466), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fdaddl", two(0xF000, 0x4066), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fdaddp", two(0xF000, 0x4C66), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fdadds", two(0xF000, 0x4466), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fdaddw", two(0xF000, 0x5066), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fdaddx", two(0xF000, 0x0066), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fdaddx", two(0xF000, 0x4866), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-/* {"faddx", two(0xF000, 0x0066), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF removed */
-
-{"fasinb", two(0xF000, 0x580C), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fasind", two(0xF000, 0x540C), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fasinl", two(0xF000, 0x400C), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fasinp", two(0xF000, 0x4C0C), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fasins", two(0xF000, 0x440C), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fasinw", two(0xF000, 0x500C), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fasinx", two(0xF000, 0x480C), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fatanb", two(0xF000, 0x580A), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fatand", two(0xF000, 0x540A), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fatanl", two(0xF000, 0x400A), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fatanp", two(0xF000, 0x4C0A), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fatans", two(0xF000, 0x440A), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fatanw", two(0xF000, 0x500A), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fatanx", two(0xF000, 0x480A), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fatanhb", two(0xF000, 0x580D), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fatanhd", two(0xF000, 0x540D), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fatanhl", two(0xF000, 0x400D), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fatanhp", two(0xF000, 0x4C0D), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fatanhs", two(0xF000, 0x440D), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fatanhw", two(0xF000, 0x500D), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fatanhx", two(0xF000, 0x480D), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-/* Fixed-size Float branches */
-
-{"fbeq", one(0xF081), one(0xF1BF), "IdBW", mfloat },
-{"fbf", one(0xF080), one(0xF1BF), "IdBW", mfloat },
-{"fbge", one(0xF093), one(0xF1BF), "IdBW", mfloat },
-{"fbgl", one(0xF096), one(0xF1BF), "IdBW", mfloat },
-{"fbgle", one(0xF097), one(0xF1BF), "IdBW", mfloat },
-{"fbgt", one(0xF092), one(0xF1BF), "IdBW", mfloat },
-{"fble", one(0xF095), one(0xF1BF), "IdBW", mfloat },
-{"fblt", one(0xF094), one(0xF1BF), "IdBW", mfloat },
-{"fbne", one(0xF08E), one(0xF1BF), "IdBW", mfloat },
-{"fbnge", one(0xF09C), one(0xF1BF), "IdBW", mfloat },
-{"fbngl", one(0xF099), one(0xF1BF), "IdBW", mfloat },
-{"fbngle", one(0xF098), one(0xF1BF), "IdBW", mfloat },
-{"fbngt", one(0xF09D), one(0xF1BF), "IdBW", mfloat },
-{"fbnle", one(0xF09A), one(0xF1BF), "IdBW", mfloat },
-{"fbnlt", one(0xF09B), one(0xF1BF), "IdBW", mfloat },
-{"fboge", one(0xF083), one(0xF1BF), "IdBW", mfloat },
-{"fbogl", one(0xF086), one(0xF1BF), "IdBW", mfloat },
-{"fbogt", one(0xF082), one(0xF1BF), "IdBW", mfloat },
-{"fbole", one(0xF085), one(0xF1BF), "IdBW", mfloat },
-{"fbolt", one(0xF084), one(0xF1BF), "IdBW", mfloat },
-{"fbor", one(0xF087), one(0xF1BF), "IdBW", mfloat },
-{"fbseq", one(0xF091), one(0xF1BF), "IdBW", mfloat },
-{"fbsf", one(0xF090), one(0xF1BF), "IdBW", mfloat },
-{"fbsne", one(0xF09E), one(0xF1BF), "IdBW", mfloat },
-{"fbst", one(0xF09F), one(0xF1BF), "IdBW", mfloat },
-{"fbt", one(0xF08F), one(0xF1BF), "IdBW", mfloat },
-{"fbueq", one(0xF089), one(0xF1BF), "IdBW", mfloat },
-{"fbuge", one(0xF08B), one(0xF1BF), "IdBW", mfloat },
-{"fbugt", one(0xF08A), one(0xF1BF), "IdBW", mfloat },
-{"fbule", one(0xF08D), one(0xF1BF), "IdBW", mfloat },
-{"fbult", one(0xF08C), one(0xF1BF), "IdBW", mfloat },
-{"fbun", one(0xF088), one(0xF1BF), "IdBW", mfloat },
-
-/* Float branches -- long (32-bit) displacements */
-
-{"fbeql", one(0xF081), one(0xF1BF), "IdBC", mfloat },
-{"fbfl", one(0xF080), one(0xF1BF), "IdBC", mfloat },
-{"fbgel", one(0xF093), one(0xF1BF), "IdBC", mfloat },
-{"fbgll", one(0xF096), one(0xF1BF), "IdBC", mfloat },
-{"fbglel", one(0xF097), one(0xF1BF), "IdBC", mfloat },
-{"fbgtl", one(0xF092), one(0xF1BF), "IdBC", mfloat },
-{"fblel", one(0xF095), one(0xF1BF), "IdBC", mfloat },
-{"fbltl", one(0xF094), one(0xF1BF), "IdBC", mfloat },
-{"fbnel", one(0xF08E), one(0xF1BF), "IdBC", mfloat },
-{"fbngel", one(0xF09C), one(0xF1BF), "IdBC", mfloat },
-{"fbngll", one(0xF099), one(0xF1BF), "IdBC", mfloat },
-{"fbnglel", one(0xF098), one(0xF1BF), "IdBC", mfloat },
-{"fbngtl", one(0xF09D), one(0xF1BF), "IdBC", mfloat },
-{"fbnlel", one(0xF09A), one(0xF1BF), "IdBC", mfloat },
-{"fbnltl", one(0xF09B), one(0xF1BF), "IdBC", mfloat },
-{"fbogel", one(0xF083), one(0xF1BF), "IdBC", mfloat },
-{"fbogll", one(0xF086), one(0xF1BF), "IdBC", mfloat },
-{"fbogtl", one(0xF082), one(0xF1BF), "IdBC", mfloat },
-{"fbolel", one(0xF085), one(0xF1BF), "IdBC", mfloat },
-{"fboltl", one(0xF084), one(0xF1BF), "IdBC", mfloat },
-{"fborl", one(0xF087), one(0xF1BF), "IdBC", mfloat },
-{"fbseql", one(0xF091), one(0xF1BF), "IdBC", mfloat },
-{"fbsfl", one(0xF090), one(0xF1BF), "IdBC", mfloat },
-{"fbsnel", one(0xF09E), one(0xF1BF), "IdBC", mfloat },
-{"fbstl", one(0xF09F), one(0xF1BF), "IdBC", mfloat },
-{"fbtl", one(0xF08F), one(0xF1BF), "IdBC", mfloat },
-{"fbueql", one(0xF089), one(0xF1BF), "IdBC", mfloat },
-{"fbugel", one(0xF08B), one(0xF1BF), "IdBC", mfloat },
-{"fbugtl", one(0xF08A), one(0xF1BF), "IdBC", mfloat },
-{"fbulel", one(0xF08D), one(0xF1BF), "IdBC", mfloat },
-{"fbultl", one(0xF08C), one(0xF1BF), "IdBC", mfloat },
-{"fbunl", one(0xF088), one(0xF1BF), "IdBC", mfloat },
-
-{"fcmpb", two(0xF000, 0x5838), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fcmpd", two(0xF000, 0x5438), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fcmpl", two(0xF000, 0x4038), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fcmpp", two(0xF000, 0x4C38), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fcmps", two(0xF000, 0x4438), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fcmpw", two(0xF000, 0x5038), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fcmpx", two(0xF000, 0x4838), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-/* {"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF removed */
-
-{"fcosb", two(0xF000, 0x581D), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fcosd", two(0xF000, 0x541D), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fcosl", two(0xF000, 0x401D), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fcosp", two(0xF000, 0x4C1D), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fcoss", two(0xF000, 0x441D), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fcosw", two(0xF000, 0x501D), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fcosx", two(0xF000, 0x481D), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fcoshb", two(0xF000, 0x5819), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fcoshd", two(0xF000, 0x5419), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fcoshl", two(0xF000, 0x4019), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fcoshp", two(0xF000, 0x4C19), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fcoshs", two(0xF000, 0x4419), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fcoshw", two(0xF000, 0x5019), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fcoshx", two(0xF000, 0x4819), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fdbeq", two(0xF048, 0x0001), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbf", two(0xF048, 0x0000), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbge", two(0xF048, 0x0013), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbgl", two(0xF048, 0x0016), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbgle", two(0xF048, 0x0017), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbgt", two(0xF048, 0x0012), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdble", two(0xF048, 0x0015), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdblt", two(0xF048, 0x0014), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbne", two(0xF048, 0x000E), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbnge", two(0xF048, 0x001C), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbngl", two(0xF048, 0x0019), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbngle", two(0xF048, 0x0018), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbngt", two(0xF048, 0x001D), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbnle", two(0xF048, 0x001A), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbnlt", two(0xF048, 0x001B), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdboge", two(0xF048, 0x0003), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbogl", two(0xF048, 0x0006), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbogt", two(0xF048, 0x0002), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbole", two(0xF048, 0x0005), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbolt", two(0xF048, 0x0004), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbor", two(0xF048, 0x0007), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbseq", two(0xF048, 0x0011), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbsf", two(0xF048, 0x0010), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbsne", two(0xF048, 0x001E), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbst", two(0xF048, 0x001F), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbt", two(0xF048, 0x000F), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbueq", two(0xF048, 0x0009), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbuge", two(0xF048, 0x000B), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbugt", two(0xF048, 0x000A), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbule", two(0xF048, 0x000D), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbult", two(0xF048, 0x000C), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-{"fdbun", two(0xF048, 0x0008), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat },
-
-{"fdivb", two(0xF000, 0x5820), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fdivd", two(0xF000, 0x5420), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fdivl", two(0xF000, 0x4020), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fdivp", two(0xF000, 0x4C20), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fdivs", two(0xF000, 0x4420), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fdivw", two(0xF000, 0x5020), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fdivx", two(0xF000, 0x4820), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-/* {"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF */
-
-{"fsdivb", two(0xF000, 0x5860), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fsdivd", two(0xF000, 0x5460), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fsdivl", two(0xF000, 0x4060), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fsdivp", two(0xF000, 0x4C60), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fsdivs", two(0xF000, 0x4460), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fsdivw", two(0xF000, 0x5060), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fsdivx", two(0xF000, 0x0060), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fsdivx", two(0xF000, 0x4860), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-/* {"fsdivx", two(0xF000, 0x0060), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF */
-
-{"fddivb", two(0xF000, 0x5864), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fddivd", two(0xF000, 0x5464), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fddivl", two(0xF000, 0x4064), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fddivp", two(0xF000, 0x4C64), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fddivs", two(0xF000, 0x4464), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fddivw", two(0xF000, 0x5064), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fddivx", two(0xF000, 0x0064), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fddivx", two(0xF000, 0x4864), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-/* {"fddivx", two(0xF000, 0x0064), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF */
-
-{"fetoxb", two(0xF000, 0x5810), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fetoxd", two(0xF000, 0x5410), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fetoxl", two(0xF000, 0x4010), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fetoxp", two(0xF000, 0x4C10), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fetoxs", two(0xF000, 0x4410), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fetoxw", two(0xF000, 0x5010), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fetoxx", two(0xF000, 0x4810), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fetoxm1b", two(0xF000, 0x5808), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fetoxm1d", two(0xF000, 0x5408), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fetoxm1l", two(0xF000, 0x4008), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fetoxm1p", two(0xF000, 0x4C08), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fetoxm1s", two(0xF000, 0x4408), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fetoxm1w", two(0xF000, 0x5008), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fetoxm1x", two(0xF000, 0x4808), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fgetexpb", two(0xF000, 0x581E), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fgetexpd", two(0xF000, 0x541E), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fgetexpl", two(0xF000, 0x401E), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fgetexpp", two(0xF000, 0x4C1E), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fgetexps", two(0xF000, 0x441E), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fgetexpw", two(0xF000, 0x501E), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fgetexpx", two(0xF000, 0x481E), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fgetmanb", two(0xF000, 0x581F), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fgetmand", two(0xF000, 0x541F), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fgetmanl", two(0xF000, 0x401F), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fgetmanp", two(0xF000, 0x4C1F), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fgetmans", two(0xF000, 0x441F), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fgetmanw", two(0xF000, 0x501F), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fgetmanx", two(0xF000, 0x481F), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fintb", two(0xF000, 0x5801), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fintd", two(0xF000, 0x5401), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fintl", two(0xF000, 0x4001), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fintp", two(0xF000, 0x4C01), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fints", two(0xF000, 0x4401), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fintw", two(0xF000, 0x5001), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fintx", two(0xF000, 0x4801), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fintrzb", two(0xF000, 0x5803), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fintrzd", two(0xF000, 0x5403), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fintrzl", two(0xF000, 0x4003), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fintrzp", two(0xF000, 0x4C03), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fintrzs", two(0xF000, 0x4403), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fintrzw", two(0xF000, 0x5003), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fintrzx", two(0xF000, 0x4803), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"flog10b", two(0xF000, 0x5815), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"flog10d", two(0xF000, 0x5415), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"flog10l", two(0xF000, 0x4015), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"flog10p", two(0xF000, 0x4C15), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"flog10s", two(0xF000, 0x4415), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"flog10w", two(0xF000, 0x5015), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"flog10x", two(0xF000, 0x4815), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"flog2b", two(0xF000, 0x5816), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"flog2d", two(0xF000, 0x5416), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"flog2l", two(0xF000, 0x4016), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"flog2p", two(0xF000, 0x4C16), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"flog2s", two(0xF000, 0x4416), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"flog2w", two(0xF000, 0x5016), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"flog2x", two(0xF000, 0x4816), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"flognb", two(0xF000, 0x5814), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"flognd", two(0xF000, 0x5414), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"flognl", two(0xF000, 0x4014), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"flognp", two(0xF000, 0x4C14), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"flogns", two(0xF000, 0x4414), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"flognw", two(0xF000, 0x5014), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"flognx", two(0xF000, 0x4814), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"flognp1b", two(0xF000, 0x5806), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"flognp1d", two(0xF000, 0x5406), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"flognp1l", two(0xF000, 0x4006), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"flognp1p", two(0xF000, 0x4C06), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"flognp1s", two(0xF000, 0x4406), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"flognp1w", two(0xF000, 0x5006), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"flognp1x", two(0xF000, 0x4806), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fmodb", two(0xF000, 0x5821), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fmodd", two(0xF000, 0x5421), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fmodl", two(0xF000, 0x4021), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fmodp", two(0xF000, 0x4C21), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fmods", two(0xF000, 0x4421), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fmodw", two(0xF000, 0x5021), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fmodx", two(0xF000, 0x4821), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-/* {"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF */
-
-{"fmoveb", two(0xF000, 0x5800), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, /* fmove from <ea> to fp<n> */
-{"fmoveb", two(0xF000, 0x7800), two(0xF1C0, 0xFC7F), "IiF7@b", mfloat }, /* fmove from fp<n> to <ea> */
-{"fmoved", two(0xF000, 0x5400), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, /* fmove from <ea> to fp<n> */
-{"fmoved", two(0xF000, 0x7400), two(0xF1C0, 0xFC7F), "IiF7@F", mfloat }, /* fmove from fp<n> to <ea> */
-{"fmovel", two(0xF000, 0x4000), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, /* fmove from <ea> to fp<n> */
-{"fmovel", two(0xF000, 0x6000), two(0xF1C0, 0xFC7F), "IiF7@l", mfloat }, /* fmove from fp<n> to <ea> */
-/* Warning: The addressing modes on these are probably not right:
- esp, Areg direct is only allowed for FPI */
- /* fmove.l from/to system control registers: */
-{"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s", mfloat },
-{"fmovel", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ls8", mfloat },
-
-/* {"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s", mfloat },
-{"fmovel", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*ss8", mfloat }, */
-
-{"fmovep", two(0xF000, 0x4C00), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, /* fmove from <ea> to fp<n> */
-{"fmovep", two(0xF000, 0x6C00), two(0xF1C0, 0xFC00), "IiF7@pkC", mfloat }, /* fmove.p with k-factors: */
-{"fmovep", two(0xF000, 0x7C00), two(0xF1C0, 0xFC0F), "IiF7@pDk", mfloat }, /* fmove.p with k-factors: */
-
-{"fmoves", two(0xF000, 0x4400), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, /* fmove from <ea> to fp<n> */
-{"fmoves", two(0xF000, 0x6400), two(0xF1C0, 0xFC7F), "IiF7@f", mfloat }, /* fmove from fp<n> to <ea> */
-{"fmovew", two(0xF000, 0x5000), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, /* fmove from <ea> to fp<n> */
-{"fmovew", two(0xF000, 0x7000), two(0xF1C0, 0xFC7F), "IiF7@w", mfloat }, /* fmove from fp<n> to <ea> */
-{"fmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, /* fmove from <ea> to fp<n> */
-{"fmovex", two(0xF000, 0x4800), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, /* fmove from <ea> to fp<n> */
-{"fmovex", two(0xF000, 0x6800), two(0xF1C0, 0xFC7F), "IiF7@x", mfloat }, /* fmove from fp<n> to <ea> */
-/* JF removed {"fmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiFt", mfloat }, / * fmove from <ea> to fp<n> */
-
-{"fsmoveb", two(0xF000, 0x5840), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fsmoved", two(0xF000, 0x5440), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fsmovel", two(0xF000, 0x4040), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fsmoves", two(0xF000, 0x4440), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fsmovew", two(0xF000, 0x5040), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fsmovex", two(0xF000, 0x0040), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fsmovex", two(0xF000, 0x4840), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, /* fmove from <ea> to fp<n> */
-/* JF removed {"fsmovex", two(0xF000, 0x0040), two(0xF1C0, 0xE07F), "IiFt", m68040 }, / * fmove from <ea> to fp<n> */
-
-{"fdmoveb", two(0xF000, 0x5844), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fdmoved", two(0xF000, 0x5444), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fdmovel", two(0xF000, 0x4044), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fdmoves", two(0xF000, 0x4444), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fdmovew", two(0xF000, 0x5044), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fdmovex", two(0xF000, 0x0044), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, /* fmove from <ea> to fp<n> */
-{"fdmovex", two(0xF000, 0x4844), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, /* fmove from <ea> to fp<n> */
-/* JF removed {"fdmovex", two(0xF000, 0x0044), two(0xF1C0, 0xE07F), "IiFt", m68040 }, / * fmove from <ea> to fp<n> */
-
-{"fmovecrx", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7", mfloat }, /* fmovecr.x #ccc, FPn */
-{"fmovecr", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7", mfloat },
-
-/* Other fmovemx. */
-{"fmovemx", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s", mfloat }, /* reg to control, static and dynamic: */
-{"fmovemx", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk", mfloat }, /* from control to reg, static and dynamic: */
-
-{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s", mfloat }, /* to control, static and dynamic: */
-{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s", mfloat }, /* to control, static and dynamic: */
-
-{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3", mfloat }, /* from control, static and dynamic: */
-{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3", mfloat }, /* from control, static and dynamic: */
-
-{"fmovemx", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s", mfloat }, /* reg to autodecrement, static and dynamic */
-{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s", mfloat }, /* to autodecrement, static and dynamic */
-{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s", mfloat }, /* to autodecrement, static and dynamic */
-
-{"fmovemx", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk", mfloat }, /* from autoinc to reg, static and dynamic: */
-{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3", mfloat }, /* from autoincrement, static and dynamic: */
-{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3", mfloat }, /* from autoincrement, static and dynamic: */
-
-{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8@s", mfloat },
-{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Ii#8@s", mfloat },
-{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s", mfloat },
-
-{"fmoveml", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8", mfloat },
-{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*s#8", mfloat },
-{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8", mfloat },
-
-/* fmovemx with register lists */
-{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s", mfloat }, /* to autodec, static & dynamic */
-{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s", mfloat }, /* to control, static and dynamic */
-{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3", mfloat }, /* from autoinc, static & dynamic */
-{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3", mfloat }, /* from control, static and dynamic */
-
- /* Alternate mnemonics for GNU as and GNU CC */
-{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s", mfloat }, /* to autodecrement, static and dynamic */
-{"fmovem", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s", mfloat }, /* to autodecrement, static and dynamic */
-
-{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s", mfloat }, /* to control, static and dynamic: */
-{"fmovem", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s", mfloat }, /* to control, static and dynamic: */
-
-{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3", mfloat }, /* from autoincrement, static and dynamic: */
-{"fmovem", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk", mfloat }, /* from autoincrement, static and dynamic: */
-
-{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3", mfloat }, /* from control, static and dynamic: */
-{"fmovem", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk", mfloat }, /* from control, static and dynamic: */
-
-/* fmoveml a FP-control register */
-{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s", mfloat },
-{"fmovem", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8", mfloat },
-
-/* fmoveml a FP-control reglist */
-{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8@s", mfloat },
-{"fmovem", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8", mfloat },
-
-{"fmulb", two(0xF000, 0x5823), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fmuld", two(0xF000, 0x5423), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fmull", two(0xF000, 0x4023), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fmulp", two(0xF000, 0x4C23), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fmuls", two(0xF000, 0x4423), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fmulw", two(0xF000, 0x5023), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fmulx", two(0xF000, 0x4823), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-/* {"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF */
-
-{"fsmulb", two(0xF000, 0x5863), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fsmuld", two(0xF000, 0x5463), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fsmull", two(0xF000, 0x4063), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fsmulp", two(0xF000, 0x4C63), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fsmuls", two(0xF000, 0x4463), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fsmulw", two(0xF000, 0x5063), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fsmulx", two(0xF000, 0x0063), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fsmulx", two(0xF000, 0x4863), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-/* {"fsmulx", two(0xF000, 0x0063), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF */
-
-{"fdmulb", two(0xF000, 0x5867), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fdmuld", two(0xF000, 0x5467), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fdmull", two(0xF000, 0x4067), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fdmulp", two(0xF000, 0x4C67), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fdmuls", two(0xF000, 0x4467), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fdmulw", two(0xF000, 0x5067), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fdmulx", two(0xF000, 0x0067), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fdmulx", two(0xF000, 0x4867), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-/* {"dfmulx", two(0xF000, 0x0067), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF */
-
-{"fnegb", two(0xF000, 0x581A), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fnegd", two(0xF000, 0x541A), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fnegl", two(0xF000, 0x401A), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fnegp", two(0xF000, 0x4C1A), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fnegs", two(0xF000, 0x441A), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fnegw", two(0xF000, 0x501A), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fnegx", two(0xF000, 0x481A), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fsnegb", two(0xF000, 0x585A), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fsnegd", two(0xF000, 0x545A), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fsnegl", two(0xF000, 0x405A), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fsnegp", two(0xF000, 0x4C5A), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fsnegs", two(0xF000, 0x445A), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fsnegw", two(0xF000, 0x505A), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fsnegx", two(0xF000, 0x005A), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fsnegx", two(0xF000, 0x485A), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-{"fsnegx", two(0xF000, 0x005A), two(0xF1C0, 0xE07F), "IiFt", m68040 },
-
-{"fdnegb", two(0xF000, 0x585E), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fdnegd", two(0xF000, 0x545E), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fdnegl", two(0xF000, 0x405E), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fdnegp", two(0xF000, 0x4C5E), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fdnegs", two(0xF000, 0x445E), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fdnegw", two(0xF000, 0x505E), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fdnegx", two(0xF000, 0x005E), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fdnegx", two(0xF000, 0x485E), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-{"fdnegx", two(0xF000, 0x005E), two(0xF1C0, 0xE07F), "IiFt", m68040 },
-
-{"fnop", two(0xF280, 0x0000), two(0xFFFF, 0xFFFF), "Ii", mfloat },
-
-{"fremb", two(0xF000, 0x5825), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fremd", two(0xF000, 0x5425), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"freml", two(0xF000, 0x4025), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fremp", two(0xF000, 0x4C25), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"frems", two(0xF000, 0x4425), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fremw", two(0xF000, 0x5025), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fremx", two(0xF000, 0x4825), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-/* {"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF */
-
-{"frestore", one(0xF140), one(0xF1C0), "Id&s", mfloat },
-{"frestore", one(0xF158), one(0xF1F8), "Id+s", mfloat },
-{"fsave", one(0xF100), one(0xF1C0), "Id&s", mfloat },
-{"fsave", one(0xF120), one(0xF1F8), "Id-s", mfloat },
-
-{"fscaleb", two(0xF000, 0x5826), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fscaled", two(0xF000, 0x5426), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fscalel", two(0xF000, 0x4026), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fscalep", two(0xF000, 0x4C26), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fscales", two(0xF000, 0x4426), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fscalew", two(0xF000, 0x5026), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fscalex", two(0xF000, 0x4826), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-/* {"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF */
-
-/* $ is necessary to prevent the assembler from using PC-relative.
- If @ were used, "label: fseq label" could produce "ftrapeq",
- because "label" became "pc@label". */
-{"fseq", two(0xF040, 0x0001), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsf", two(0xF040, 0x0000), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsge", two(0xF040, 0x0013), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsgl", two(0xF040, 0x0016), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsgle", two(0xF040, 0x0017), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsgt", two(0xF040, 0x0012), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsle", two(0xF040, 0x0015), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fslt", two(0xF040, 0x0014), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsne", two(0xF040, 0x000E), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsnge", two(0xF040, 0x001C), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsngl", two(0xF040, 0x0019), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsngle", two(0xF040, 0x0018), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsngt", two(0xF040, 0x001D), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsnle", two(0xF040, 0x001A), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsnlt", two(0xF040, 0x001B), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsoge", two(0xF040, 0x0003), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsogl", two(0xF040, 0x0006), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsogt", two(0xF040, 0x0002), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsole", two(0xF040, 0x0005), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsolt", two(0xF040, 0x0004), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsor", two(0xF040, 0x0007), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsseq", two(0xF040, 0x0011), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fssf", two(0xF040, 0x0010), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fssne", two(0xF040, 0x001E), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsst", two(0xF040, 0x001F), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fst", two(0xF040, 0x000F), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsueq", two(0xF040, 0x0009), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsuge", two(0xF040, 0x000B), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsugt", two(0xF040, 0x000A), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsule", two(0xF040, 0x000D), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsult", two(0xF040, 0x000C), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-{"fsun", two(0xF040, 0x0008), two(0xF1C0, 0xFFFF), "Ii$s", mfloat },
-
-{"fsgldivb", two(0xF000, 0x5824), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fsgldivd", two(0xF000, 0x5424), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fsgldivl", two(0xF000, 0x4024), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fsgldivp", two(0xF000, 0x4C24), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fsgldivs", two(0xF000, 0x4424), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fsgldivw", two(0xF000, 0x5024), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fsgldivx", two(0xF000, 0x4824), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fsglmulb", two(0xF000, 0x5827), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fsglmuld", two(0xF000, 0x5427), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fsglmull", two(0xF000, 0x4027), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fsglmulp", two(0xF000, 0x4C27), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fsglmuls", two(0xF000, 0x4427), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fsglmulw", two(0xF000, 0x5027), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fsglmulx", two(0xF000, 0x4827), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fsinb", two(0xF000, 0x580E), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fsind", two(0xF000, 0x540E), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fsinl", two(0xF000, 0x400E), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fsinp", two(0xF000, 0x4C0E), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fsins", two(0xF000, 0x440E), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fsinw", two(0xF000, 0x500E), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fsinx", two(0xF000, 0x480E), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fsinhb", two(0xF000, 0x5802), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fsinhd", two(0xF000, 0x5402), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fsinhl", two(0xF000, 0x4002), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fsinhp", two(0xF000, 0x4C02), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fsinhs", two(0xF000, 0x4402), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fsinhw", two(0xF000, 0x5002), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fsinhx", two(0xF000, 0x4802), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fsincosb", two(0xF000, 0x5830), two(0xF1C0, 0xFC78), "Ii;bF3F7", mfloat },
-{"fsincosd", two(0xF000, 0x5430), two(0xF1C0, 0xFC78), "Ii;FF3F7", mfloat },
-{"fsincosl", two(0xF000, 0x4030), two(0xF1C0, 0xFC78), "Ii;lF3F7", mfloat },
-{"fsincosp", two(0xF000, 0x4C30), two(0xF1C0, 0xFC78), "Ii;pF3F7", mfloat },
-{"fsincoss", two(0xF000, 0x4430), two(0xF1C0, 0xFC78), "Ii;fF3F7", mfloat },
-{"fsincosw", two(0xF000, 0x5030), two(0xF1C0, 0xFC78), "Ii;wF3F7", mfloat },
-{"fsincosx", two(0xF000, 0x0030), two(0xF1C0, 0xE078), "IiF8F3F7", mfloat },
-{"fsincosx", two(0xF000, 0x4830), two(0xF1C0, 0xFC78), "Ii;xF3F7", mfloat },
-
-{"fsqrtb", two(0xF000, 0x5804), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fsqrtd", two(0xF000, 0x5404), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fsqrtl", two(0xF000, 0x4004), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fsqrtp", two(0xF000, 0x4C04), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fsqrts", two(0xF000, 0x4404), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fsqrtw", two(0xF000, 0x5004), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fsqrtx", two(0xF000, 0x4804), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fssqrtb", two(0xF000, 0x5841), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fssqrtd", two(0xF000, 0x5441), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fssqrtl", two(0xF000, 0x4041), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fssqrtp", two(0xF000, 0x4C41), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fssqrts", two(0xF000, 0x4441), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fssqrtw", two(0xF000, 0x5041), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fssqrtx", two(0xF000, 0x0041), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fssqrtx", two(0xF000, 0x4841), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-{"fssqrtx", two(0xF000, 0x0041), two(0xF1C0, 0xE07F), "IiFt", m68040 },
-
-{"fdsqrtb", two(0xF000, 0x5845), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fdsqrtd", two(0xF000, 0x5445), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fdsqrtl", two(0xF000, 0x4045), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fdsqrtp", two(0xF000, 0x4C45), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fdsqrts", two(0xF000, 0x4445), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fdsqrtw", two(0xF000, 0x5045), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fdsqrtx", two(0xF000, 0x0045), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fdsqrtx", two(0xF000, 0x4845), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-{"fdsqrtx", two(0xF000, 0x0045), two(0xF1C0, 0xE07F), "IiFt", m68040 },
-
-{"fsubb", two(0xF000, 0x5828), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"fsubd", two(0xF000, 0x5428), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"fsubl", two(0xF000, 0x4028), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"fsubp", two(0xF000, 0x4C28), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"fsubs", two(0xF000, 0x4428), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"fsubw", two(0xF000, 0x5028), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"fsubx", two(0xF000, 0x4828), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"fssubb", two(0xF000, 0x5868), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fssubd", two(0xF000, 0x5468), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fssubl", two(0xF000, 0x4068), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fssubp", two(0xF000, 0x4C68), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fssubs", two(0xF000, 0x4468), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fssubw", two(0xF000, 0x5068), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fssubx", two(0xF000, 0x0068), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fssubx", two(0xF000, 0x4868), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-{"fssubx", two(0xF000, 0x0068), two(0xF1C0, 0xE07F), "IiFt", m68040 },
-
-{"fdsubb", two(0xF000, 0x586c), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 },
-{"fdsubd", two(0xF000, 0x546c), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 },
-{"fdsubl", two(0xF000, 0x406c), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 },
-{"fdsubp", two(0xF000, 0x4C6c), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 },
-{"fdsubs", two(0xF000, 0x446c), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 },
-{"fdsubw", two(0xF000, 0x506c), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 },
-{"fdsubx", two(0xF000, 0x006c), two(0xF1C0, 0xE07F), "IiF8F7", m68040 },
-{"fdsubx", two(0xF000, 0x486c), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 },
-{"fdsubx", two(0xF000, 0x006c), two(0xF1C0, 0xE07F), "IiFt", m68040 },
-
-{"ftanb", two(0xF000, 0x580F), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"ftand", two(0xF000, 0x540F), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"ftanl", two(0xF000, 0x400F), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"ftanp", two(0xF000, 0x4C0F), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"ftans", two(0xF000, 0x440F), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"ftanw", two(0xF000, 0x500F), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"ftanx", two(0xF000, 0x480F), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"ftanhb", two(0xF000, 0x5809), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"ftanhd", two(0xF000, 0x5409), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"ftanhl", two(0xF000, 0x4009), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"ftanhp", two(0xF000, 0x4C09), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"ftanhs", two(0xF000, 0x4409), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"ftanhw", two(0xF000, 0x5009), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"ftanhx", two(0xF000, 0x4809), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"ftentoxb", two(0xF000, 0x5812), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"ftentoxd", two(0xF000, 0x5412), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"ftentoxl", two(0xF000, 0x4012), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"ftentoxp", two(0xF000, 0x4C12), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"ftentoxs", two(0xF000, 0x4412), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"ftentoxw", two(0xF000, 0x5012), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"ftentoxx", two(0xF000, 0x4812), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-{"ftrapeq", two(0xF07C, 0x0001), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapf", two(0xF07C, 0x0000), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapge", two(0xF07C, 0x0013), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapgl", two(0xF07C, 0x0016), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapgle", two(0xF07C, 0x0017), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapgt", two(0xF07C, 0x0012), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftraple", two(0xF07C, 0x0015), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftraplt", two(0xF07C, 0x0014), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapne", two(0xF07C, 0x000E), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapnge", two(0xF07C, 0x001C), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapngl", two(0xF07C, 0x0019), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapngle", two(0xF07C, 0x0018), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapngt", two(0xF07C, 0x001D), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapnle", two(0xF07C, 0x001A), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapnlt", two(0xF07C, 0x001B), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapoge", two(0xF07C, 0x0003), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapogl", two(0xF07C, 0x0006), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapogt", two(0xF07C, 0x0002), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapole", two(0xF07C, 0x0005), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapolt", two(0xF07C, 0x0004), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapor", two(0xF07C, 0x0007), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapseq", two(0xF07C, 0x0011), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapsf", two(0xF07C, 0x0010), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapsne", two(0xF07C, 0x001E), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapst", two(0xF07C, 0x001F), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapt", two(0xF07C, 0x000F), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapueq", two(0xF07C, 0x0009), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapuge", two(0xF07C, 0x000B), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapugt", two(0xF07C, 0x000A), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapule", two(0xF07C, 0x000D), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapult", two(0xF07C, 0x000C), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-{"ftrapun", two(0xF07C, 0x0008), two(0xF1FF, 0xFFFF), "Ii", mfloat },
-
-{"ftrapeqw", two(0xF07A, 0x0001), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapfw", two(0xF07A, 0x0000), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapgew", two(0xF07A, 0x0013), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapglw", two(0xF07A, 0x0016), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapglew", two(0xF07A, 0x0017), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapgtw", two(0xF07A, 0x0012), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftraplew", two(0xF07A, 0x0015), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapltw", two(0xF07A, 0x0014), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapnew", two(0xF07A, 0x000E), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapngew", two(0xF07A, 0x001C), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapnglw", two(0xF07A, 0x0019), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapnglew", two(0xF07A, 0x0018), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapngtw", two(0xF07A, 0x001D), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapnlew", two(0xF07A, 0x001A), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapnltw", two(0xF07A, 0x001B), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapogew", two(0xF07A, 0x0003), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapoglw", two(0xF07A, 0x0006), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapogtw", two(0xF07A, 0x0002), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapolew", two(0xF07A, 0x0005), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapoltw", two(0xF07A, 0x0004), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftraporw", two(0xF07A, 0x0007), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapseqw", two(0xF07A, 0x0011), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapsfw", two(0xF07A, 0x0010), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapsnew", two(0xF07A, 0x001E), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapstw", two(0xF07A, 0x001F), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftraptw", two(0xF07A, 0x000F), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapueqw", two(0xF07A, 0x0009), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapugew", two(0xF07A, 0x000B), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapugtw", two(0xF07A, 0x000A), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapulew", two(0xF07A, 0x000D), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapultw", two(0xF07A, 0x000C), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-{"ftrapunw", two(0xF07A, 0x0008), two(0xF1FF, 0xFFFF), "Ii^w", mfloat },
-
-{"ftrapeql", two(0xF07B, 0x0001), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapfl", two(0xF07B, 0x0000), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapgel", two(0xF07B, 0x0013), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapgll", two(0xF07B, 0x0016), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapglel", two(0xF07B, 0x0017), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapgtl", two(0xF07B, 0x0012), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftraplel", two(0xF07B, 0x0015), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapltl", two(0xF07B, 0x0014), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapnel", two(0xF07B, 0x000E), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapngel", two(0xF07B, 0x001C), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapngll", two(0xF07B, 0x0019), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapnglel", two(0xF07B, 0x0018), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapngtl", two(0xF07B, 0x001D), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapnlel", two(0xF07B, 0x001A), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapnltl", two(0xF07B, 0x001B), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapogel", two(0xF07B, 0x0003), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapogll", two(0xF07B, 0x0006), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapogtl", two(0xF07B, 0x0002), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapolel", two(0xF07B, 0x0005), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapoltl", two(0xF07B, 0x0004), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftraporl", two(0xF07B, 0x0007), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapseql", two(0xF07B, 0x0011), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapsfl", two(0xF07B, 0x0010), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapsnel", two(0xF07B, 0x001E), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapstl", two(0xF07B, 0x001F), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftraptl", two(0xF07B, 0x000F), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapueql", two(0xF07B, 0x0009), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapugel", two(0xF07B, 0x000B), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapugtl", two(0xF07B, 0x000A), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapulel", two(0xF07B, 0x000D), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapultl", two(0xF07B, 0x000C), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-{"ftrapunl", two(0xF07B, 0x0008), two(0xF1FF, 0xFFFF), "Ii^l", mfloat },
-
-{"ftstb", two(0xF000, 0x583A), two(0xF1C0, 0xFC7F), "Ii;b", mfloat },
-{"ftstd", two(0xF000, 0x543A), two(0xF1C0, 0xFC7F), "Ii;F", mfloat },
-{"ftstl", two(0xF000, 0x403A), two(0xF1C0, 0xFC7F), "Ii;l", mfloat },
-{"ftstp", two(0xF000, 0x4C3A), two(0xF1C0, 0xFC7F), "Ii;p", mfloat },
-{"ftsts", two(0xF000, 0x443A), two(0xF1C0, 0xFC7F), "Ii;f", mfloat },
-{"ftstw", two(0xF000, 0x503A), two(0xF1C0, 0xFC7F), "Ii;w", mfloat },
-{"ftstx", two(0xF000, 0x003A), two(0xF1C0, 0xE07F), "IiF8", mfloat },
-{"ftstx", two(0xF000, 0x483A), two(0xF1C0, 0xFC7F), "Ii;x", mfloat },
-
-{"ftwotoxb", two(0xF000, 0x5811), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat },
-{"ftwotoxd", two(0xF000, 0x5411), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat },
-{"ftwotoxl", two(0xF000, 0x4011), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat },
-{"ftwotoxp", two(0xF000, 0x4C11), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat },
-{"ftwotoxs", two(0xF000, 0x4411), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat },
-{"ftwotoxw", two(0xF000, 0x5011), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat },
-{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiF8F7", mfloat },
-{"ftwotoxx", two(0xF000, 0x4811), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat },
-{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiFt", mfloat },
-
-/* Variable-sized float branches */
-
-{"fjeq", one(0xF081), one(0xF1FF), "IdBc", mfloat },
-{"fjf", one(0xF080), one(0xF1FF), "IdBc", mfloat },
-{"fjge", one(0xF093), one(0xF1FF), "IdBc", mfloat },
-{"fjgl", one(0xF096), one(0xF1FF), "IdBc", mfloat },
-{"fjgle", one(0xF097), one(0xF1FF), "IdBc", mfloat },
-{"fjgt", one(0xF092), one(0xF1FF), "IdBc", mfloat },
-{"fjle", one(0xF095), one(0xF1FF), "IdBc", mfloat },
-{"fjlt", one(0xF094), one(0xF1FF), "IdBc", mfloat },
-{"fjne", one(0xF08E), one(0xF1FF), "IdBc", mfloat },
-{"fjnge", one(0xF09C), one(0xF1FF), "IdBc", mfloat },
-{"fjngl", one(0xF099), one(0xF1FF), "IdBc", mfloat },
-{"fjngle", one(0xF098), one(0xF1FF), "IdBc", mfloat },
-{"fjngt", one(0xF09D), one(0xF1FF), "IdBc", mfloat },
-{"fjnle", one(0xF09A), one(0xF1FF), "IdBc", mfloat },
-{"fjnlt", one(0xF09B), one(0xF1FF), "IdBc", mfloat },
-{"fjoge", one(0xF083), one(0xF1FF), "IdBc", mfloat },
-{"fjogl", one(0xF086), one(0xF1FF), "IdBc", mfloat },
-{"fjogt", one(0xF082), one(0xF1FF), "IdBc", mfloat },
-{"fjole", one(0xF085), one(0xF1FF), "IdBc", mfloat },
-{"fjolt", one(0xF084), one(0xF1FF), "IdBc", mfloat },
-{"fjor", one(0xF087), one(0xF1FF), "IdBc", mfloat },
-{"fjseq", one(0xF091), one(0xF1FF), "IdBc", mfloat },
-{"fjsf", one(0xF090), one(0xF1FF), "IdBc", mfloat },
-{"fjsne", one(0xF09E), one(0xF1FF), "IdBc", mfloat },
-{"fjst", one(0xF09F), one(0xF1FF), "IdBc", mfloat },
-{"fjt", one(0xF08F), one(0xF1FF), "IdBc", mfloat },
-{"fjueq", one(0xF089), one(0xF1FF), "IdBc", mfloat },
-{"fjuge", one(0xF08B), one(0xF1FF), "IdBc", mfloat },
-{"fjugt", one(0xF08A), one(0xF1FF), "IdBc", mfloat },
-{"fjule", one(0xF08D), one(0xF1FF), "IdBc", mfloat },
-{"fjult", one(0xF08C), one(0xF1FF), "IdBc", mfloat },
-{"fjun", one(0xF088), one(0xF1FF), "IdBc", mfloat },
-/* float stuff ends here */
-
-{"illegal", one(0045374), one(0177777), "", m68000up },
-{"jmp", one(0047300), one(0177700), "!s", m68000up },
-{"jsr", one(0047200), one(0177700), "!s", m68000up },
-{"lea", one(0040700), one(0170700), "!sAd", m68000up },
-{"linkw", one(0047120), one(0177770), "As#w", m68000up },
-{"linkl", one(0044010), one(0177770), "As#l", m68020up },
-{"link", one(0047120), one(0177770), "As#w", m68000up },
-{"link", one(0044010), one(0177770), "As#l", m68020up },
-
-{"lslb", one(0160410), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */
-{"lslb", one(0160450), one(0170770), "DdDs", m68000up }, /* lsrb Dd, Ds */
-{"lslw", one(0160510), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */
-{"lslw", one(0160550), one(0170770), "DdDs", m68000up }, /* lsrb Dd, Ds */
-{"lslw", one(0161700), one(0177700), "~s", m68000up }, /* Shift memory */
-{"lsll", one(0160610), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */
-{"lsll", one(0160650), one(0170770), "DdDs", m68000up }, /* lsrb Dd, Ds */
-
-{"lsrb", one(0160010), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */
-{"lsrb", one(0160050), one(0170770), "DdDs", m68000up }, /* lsrb Dd, Ds */
-{"lsrl", one(0160210), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */
-{"lsrl", one(0160250), one(0170770), "DdDs", m68000up }, /* lsrb #Q, Ds */
-{"lsrw", one(0160110), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */
-{"lsrw", one(0160150), one(0170770), "DdDs", m68000up }, /* lsrb #Q, Ds */
-{"lsrw", one(0161300), one(0177700), "~s", m68000up }, /* Shift memory */
-
-{"moveal", one(0020100), one(0170700), "*lAd", m68000up },
-{"moveaw", one(0030100), one(0170700), "*wAd", m68000up },
-{"moveb", one(0010000), one(0170000), ";b$d", m68000up }, /* move */
-{"movel", one(0070000), one(0170400), "MsDd", m68000up }, /* moveq written as move */
-{"movel", one(0020000), one(0170000), "*l$d", m68000up },
-{"movel", one(0020100), one(0170700), "*lAd", m68000up },
-{"movel", one(0047140), one(0177770), "AsUd", m68000up }, /* move to USP */
-{"movel", one(0047150), one(0177770), "UdAs", m68000up }, /* move from USP */
-
-{"movec", one(0047173), one(0177777), "R1Jj", m68010up },
-{"movec", one(0047173), one(0177777), "R1#j", m68010up },
-{"movec", one(0047172), one(0177777), "JjR1", m68010up },
-{"movec", one(0047172), one(0177777), "#jR1", m68010up },
-
-/* JF added these next four for the assembler */
-{"moveml", one(0044300), one(0177700), "Lw&s", m68000up }, /* movem reg to mem. */
-{"moveml", one(0044340), one(0177770), "lw-s", m68000up }, /* movem reg to autodecrement. */
-{"moveml", one(0046300), one(0177700), "!sLw", m68000up }, /* movem mem to reg. */
-{"moveml", one(0046330), one(0177770), "+sLw", m68000up }, /* movem autoinc to reg. */
-
-{"moveml", one(0044300), one(0177700), "#w&s", m68000up }, /* movem reg to mem. */
-{"moveml", one(0044340), one(0177770), "#w-s", m68000up }, /* movem reg to autodecrement. */
-{"moveml", one(0046300), one(0177700), "!s#w", m68000up }, /* movem mem to reg. */
-{"moveml", one(0046330), one(0177770), "+s#w", m68000up }, /* movem autoinc to reg. */
-
-/* JF added these next four for the assembler */
-{"movemw", one(0044200), one(0177700), "Lw&s", m68000up }, /* movem reg to mem. */
-{"movemw", one(0044240), one(0177770), "lw-s", m68000up }, /* movem reg to autodecrement. */
-{"movemw", one(0046200), one(0177700), "!sLw", m68000up }, /* movem mem to reg. */
-{"movemw", one(0046230), one(0177770), "+sLw", m68000up }, /* movem autoinc to reg. */
-
-{"movemw", one(0044200), one(0177700), "#w&s", m68000up }, /* movem reg to mem. */
-{"movemw", one(0044240), one(0177770), "#w-s", m68000up }, /* movem reg to autodecrement. */
-{"movemw", one(0046200), one(0177700), "!s#w", m68000up }, /* movem mem to reg. */
-{"movemw", one(0046230), one(0177770), "+s#w", m68000up }, /* movem autoinc to reg. */
-
-{"movepl", one(0000510), one(0170770), "dsDd", m68000up }, /* memory to register */
-{"movepl", one(0000710), one(0170770), "Ddds", m68000up }, /* register to memory */
-{"movepw", one(0000410), one(0170770), "dsDd", m68000up }, /* memory to register */
-{"movepw", one(0000610), one(0170770), "Ddds", m68000up }, /* register to memory */
-{"moveq", one(0070000), one(0170400), "MsDd", m68000up },
-{"movew", one(0030000), one(0170000), "*w$d", m68000up },
-{"movew", one(0030100), one(0170700), "*wAd", m68000up }, /* movea, written as move */
-{"movew", one(0040300), one(0177700), "Ss$s", m68000up }, /* Move from sr */
-{"movew", one(0041300), one(0177700), "Cs$s", m68010up }, /* Move from ccr */
-{"movew", one(0042300), one(0177700), ";wCd", m68000up }, /* move to ccr */
-{"movew", one(0043300), one(0177700), ";wSd", m68000up }, /* move to sr */
-
-{"movesb", two(0007000, 0), two(0177700, 07777), "~sR1", m68010up }, /* moves from memory */
-{"movesb", two(0007000, 04000), two(0177700, 07777), "R1~s", m68010up }, /* moves to memory */
-{"movesl", two(0007200, 0), two(0177700, 07777), "~sR1", m68010up }, /* moves from memory */
-{"movesl", two(0007200, 04000), two(0177700, 07777), "R1~s", m68010up }, /* moves to memory */
-{"movesw", two(0007100, 0), two(0177700, 07777), "~sR1", m68010up }, /* moves from memory */
-{"movesw", two(0007100, 04000), two(0177700, 07777), "R1~s", m68010up }, /* moves to memory */
-
-{"move16", two(0xf620, 0x8000), two(0xfff8, 0x8fff), "+s+1", m68040 },
-{"move16", one(0xf600), one(0xfff8), "+s_L", m68040 },
-{"move16", one(0xf608), one(0xfff8), "_L+s", m68040 },
-{"move16", one(0xf610), one(0xfff8), "as_L", m68040 },
-{"move16", one(0xf618), one(0xfff8), "_Las", m68040 },
-
-{"mulsl", two(0046000, 004000), two(0177700, 0107770), ";lD1", m68020up },
-{"mulsl", two(0046000, 006000), two(0177700, 0107770), ";lD3D1", m68020up },
-{"mulsw", one(0140700), one(0170700), ";wDd", m68000up },
-{"muls", one(0140700), one(0170700), ";wDd", m68000up },
-{"mulul", two(0046000, 000000), two(0177700, 0107770), ";lD1", m68020up },
-{"mulul", two(0046000, 002000), two(0177700, 0107770), ";lD3D1", m68020up },
-{"muluw", one(0140300), one(0170700), ";wDd", m68000up },
-{"mulu", one(0140300), one(0170700), ";wDd", m68000up },
-{"nbcd", one(0044000), one(0177700), "$s", m68000up },
-{"negb", one(0042000), one(0177700), "$s", m68000up },
-{"negl", one(0042200), one(0177700), "$s", m68000up },
-{"negw", one(0042100), one(0177700), "$s", m68000up },
-{"negxb", one(0040000), one(0177700), "$s", m68000up },
-{"negxl", one(0040200), one(0177700), "$s", m68000up },
-{"negxw", one(0040100), one(0177700), "$s", m68000up },
-{"nop", one(0047161), one(0177777), "", m68000up },
-{"notb", one(0043000), one(0177700), "$s", m68000up },
-{"notl", one(0043200), one(0177700), "$s", m68000up },
-{"notw", one(0043100), one(0177700), "$s", m68000up },
-
-{"orb", one(0000000), one(0177700), "#b$s", m68000up }, /* ori written as or */
-{"orb", one(0000074), one(0177777), "#bCs", m68000up }, /* ori to ccr */
-{"orb", one(0100000), one(0170700), ";bDd", m68000up }, /* memory to register */
-{"orb", one(0100400), one(0170700), "Dd~s", m68000up }, /* register to memory */
-{"orib", one(0000000), one(0177700), "#b$s", m68000up },
-{"orib", one(0000074), one(0177777), "#bCs", m68000up }, /* ori to ccr */
-{"oril", one(0000200), one(0177700), "#l$s", m68000up },
-{"oriw", one(0000100), one(0177700), "#w$s", m68000up },
-{"oriw", one(0000174), one(0177777), "#wSs", m68000up }, /* ori to sr */
-{"orl", one(0000200), one(0177700), "#l$s", m68000up },
-{"orl", one(0100200), one(0170700), ";lDd", m68000up }, /* memory to register */
-{"orl", one(0100600), one(0170700), "Dd~s", m68000up }, /* register to memory */
-{"orw", one(0000100), one(0177700), "#w$s", m68000up },
-{"orw", one(0000174), one(0177777), "#wSs", m68000up }, /* ori to sr */
-{"orw", one(0100100), one(0170700), ";wDd", m68000up }, /* memory to register */
-{"orw", one(0100500), one(0170700), "Dd~s", m68000up }, /* register to memory */
-
-{"pack", one(0100500), one(0170770), "DsDd#w", m68020up }, /* pack Ds, Dd, #w */
-{"pack", one(0100510), one(0170770), "-s-d#w", m68020up }, /* pack -(As), -(Ad), #w */
-
-#ifndef NO_68851
-{"pbac", one(0xf0c7), one(0xffbf), "Bc", m68851 },
-{"pbacw", one(0xf087), one(0xffbf), "Bc", m68851 },
-{"pbas", one(0xf0c6), one(0xffbf), "Bc", m68851 },
-{"pbasw", one(0xf086), one(0xffbf), "Bc", m68851 },
-{"pbbc", one(0xf0c1), one(0xffbf), "Bc", m68851 },
-{"pbbcw", one(0xf081), one(0xffbf), "Bc", m68851 },
-{"pbbs", one(0xf0c0), one(0xffbf), "Bc", m68851 },
-{"pbbsw", one(0xf080), one(0xffbf), "Bc", m68851 },
-{"pbcc", one(0xf0cf), one(0xffbf), "Bc", m68851 },
-{"pbccw", one(0xf08f), one(0xffbf), "Bc", m68851 },
-{"pbcs", one(0xf0ce), one(0xffbf), "Bc", m68851 },
-{"pbcsw", one(0xf08e), one(0xffbf), "Bc", m68851 },
-{"pbgc", one(0xf0cd), one(0xffbf), "Bc", m68851 },
-{"pbgcw", one(0xf08d), one(0xffbf), "Bc", m68851 },
-{"pbgs", one(0xf0cc), one(0xffbf), "Bc", m68851 },
-{"pbgsw", one(0xf08c), one(0xffbf), "Bc", m68851 },
-{"pbic", one(0xf0cb), one(0xffbf), "Bc", m68851 },
-{"pbicw", one(0xf08b), one(0xffbf), "Bc", m68851 },
-{"pbis", one(0xf0ca), one(0xffbf), "Bc", m68851 },
-{"pbisw", one(0xf08a), one(0xffbf), "Bc", m68851 },
-{"pblc", one(0xf0c3), one(0xffbf), "Bc", m68851 },
-{"pblcw", one(0xf083), one(0xffbf), "Bc", m68851 },
-{"pbls", one(0xf0c2), one(0xffbf), "Bc", m68851 },
-{"pblsw", one(0xf082), one(0xffbf), "Bc", m68851 },
-{"pbsc", one(0xf0c5), one(0xffbf), "Bc", m68851 },
-{"pbscw", one(0xf085), one(0xffbf), "Bc", m68851 },
-{"pbss", one(0xf0c4), one(0xffbf), "Bc", m68851 },
-{"pbssw", one(0xf084), one(0xffbf), "Bc", m68851 },
-{"pbwc", one(0xf0c9), one(0xffbf), "Bc", m68851 },
-{"pbwcw", one(0xf089), one(0xffbf), "Bc", m68851 },
-{"pbws", one(0xf0c8), one(0xffbf), "Bc", m68851 },
-{"pbwsw", one(0xf088), one(0xffbf), "Bc", m68851 },
-
-{"pdbac", two(0xf048, 0x0007), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbas", two(0xf048, 0x0006), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbbc", two(0xf048, 0x0001), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbbs", two(0xf048, 0x0000), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbcc", two(0xf048, 0x000f), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbcs", two(0xf048, 0x000e), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbgc", two(0xf048, 0x000d), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbgs", two(0xf048, 0x000c), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbic", two(0xf048, 0x000b), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbis", two(0xf048, 0x000a), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdblc", two(0xf048, 0x0003), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbls", two(0xf048, 0x0002), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbsc", two(0xf048, 0x0005), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbss", two(0xf048, 0x0004), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbwc", two(0xf048, 0x0009), two(0xfff8, 0xffff), "DsBw", m68851 },
-{"pdbws", two(0xf048, 0x0008), two(0xfff8, 0xffff), "DsBw", m68851 },
-#endif /* NO_68851 */
-
-{"pea", one(0044100), one(0177700), "!s", m68000up },
-
-#ifndef NO_68851
-{"pflusha", two(0xf000, 0x2400), two(0xffff, 0xffff), "", m68030 | m68851 },
-{"pflusha", one(0xf518), one(0xfff8), "", m68040 },
-
-{"pflush", two(0xf000, 0x3010), two(0xffc0, 0xfe10), "T3T9", m68030 | m68851 },
-{"pflush", two(0xf000, 0x3810), two(0xffc0, 0xfe10), "T3T9&s", m68030 | m68851 },
-{"pflush", two(0xf000, 0x3008), two(0xffc0, 0xfe18), "D3T9", m68030 | m68851 },
-{"pflush", two(0xf000, 0x3808), two(0xffc0, 0xfe18), "D3T9&s", m68030 | m68851 },
-{"pflush", two(0xf000, 0x3000), two(0xffc0, 0xfe1e), "f3T9", m68030 | m68851 },
-{"pflush", two(0xf000, 0x3800), two(0xffc0, 0xfe1e), "f3T9&s", m68030 | m68851 },
-{"pflush", one(0xf508), one(0xfff8), "as", m68040 },
-{"pflush", one(0xf508), one(0xfff8), "As", m68040 },
-{"pflushan", one(0xf510), one(0xfff8), "", m68040 },
-{"pflushn", one(0xf500), one(0xfff8), "as", m68040 },
-{"pflushn", one(0xf500), one(0xfff8), "As", m68040 },
-
-{"pflushr", two(0xf000, 0xa000), two(0xffc0, 0xffff), "|s", m68851 },
-
-{"pflushs", two(0xf000, 0x3410), two(0xfff8, 0xfe10), "T3T9", m68851 },
-{"pflushs", two(0xf000, 0x3c10), two(0xfff8, 0xfe00), "T3T9&s", m68851 },
-{"pflushs", two(0xf000, 0x3408), two(0xfff8, 0xfe18), "D3T9", m68851 },
-{"pflushs", two(0xf000, 0x3c08), two(0xfff8, 0xfe18), "D3T9&s", m68851 },
-{"pflushs", two(0xf000, 0x3400), two(0xfff8, 0xfe1e), "f3T9", m68851 },
-{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe1e), "f3T9&s", m68851 },
-
-{"ploadr", two(0xf000, 0x2210), two(0xffc0, 0xfff0), "T3&s", m68030 | m68851 },
-{"ploadr", two(0xf000, 0x2208), two(0xffc0, 0xfff8), "D3&s", m68030 | m68851 },
-{"ploadr", two(0xf000, 0x2200), two(0xffc0, 0xfffe), "f3&s", m68030 | m68851 },
-{"ploadw", two(0xf000, 0x2010), two(0xffc0, 0xfff0), "T3&s", m68030 | m68851 },
-{"ploadw", two(0xf000, 0x2008), two(0xffc0, 0xfff8), "D3&s", m68030 | m68851 },
-{"ploadw", two(0xf000, 0x2000), two(0xffc0, 0xfffe), "f3&s", m68030 | m68851 },
-
-/* TC, CRP, DRP, SRP, CAL, VAL, SCC, AC */
-{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "*sP8", m68030 | m68851 },
-{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "P8%s", m68030 | m68851 },
-{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "|sW8", m68030 | m68851 },
-{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "W8~s", m68030 | m68851 },
-
-/* BADx, BACx */
-{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xe3e3), "*sX3", m68030 | m68851 },
-{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xe3e3), "X3%s", m68030 | m68851 },
-
-/* PSR, PCSR */
-/* {"pmove", two(0xf000, 0x6100), two(oxffc0, oxffff), "*sZ8", m68030 | m68851 }, */
-{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xffff), "*sY8", m68030 | m68851 },
-{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xffff), "Y8%s", m68030 | m68851 },
-{"pmove", two(0xf000, 0x6600), two(0xffc0, 0xffff), "Z8%s", m68030 | m68851 },
-
-{"prestore", one(0xf140), one(0xffc0), "&s", m68851 },
-{"prestore", one(0xf158), one(0xfff8), "+s", m68851 },
-{"psave", one(0xf100), one(0xffc0), "&s", m68851 },
-{"psave", one(0xf100), one(0xffc0), "+s", m68851 },
-
-{"psac", two(0xf040, 0x0007), two(0xffc0, 0xffff), "@s", m68851 },
-{"psas", two(0xf040, 0x0006), two(0xffc0, 0xffff), "@s", m68851 },
-{"psbc", two(0xf040, 0x0001), two(0xffc0, 0xffff), "@s", m68851 },
-{"psbs", two(0xf040, 0x0000), two(0xffc0, 0xffff), "@s", m68851 },
-{"pscc", two(0xf040, 0x000f), two(0xffc0, 0xffff), "@s", m68851 },
-{"pscs", two(0xf040, 0x000e), two(0xffc0, 0xffff), "@s", m68851 },
-{"psgc", two(0xf040, 0x000d), two(0xffc0, 0xffff), "@s", m68851 },
-{"psgs", two(0xf040, 0x000c), two(0xffc0, 0xffff), "@s", m68851 },
-{"psic", two(0xf040, 0x000b), two(0xffc0, 0xffff), "@s", m68851 },
-{"psis", two(0xf040, 0x000a), two(0xffc0, 0xffff), "@s", m68851 },
-{"pslc", two(0xf040, 0x0003), two(0xffc0, 0xffff), "@s", m68851 },
-{"psls", two(0xf040, 0x0002), two(0xffc0, 0xffff), "@s", m68851 },
-{"pssc", two(0xf040, 0x0005), two(0xffc0, 0xffff), "@s", m68851 },
-{"psss", two(0xf040, 0x0004), two(0xffc0, 0xffff), "@s", m68851 },
-{"pswc", two(0xf040, 0x0009), two(0xffc0, 0xffff), "@s", m68851 },
-{"psws", two(0xf040, 0x0008), two(0xffc0, 0xffff), "@s", m68851 },
-
-{"ptestr", two(0xf000, 0x8210), two(0xffc0, 0xe3f0), "T3&sQ8", m68030 | m68851 },
-{"ptestr", two(0xf000, 0x8310), two(0xffc0, 0xe310), "T3&sQ8A9", m68030 | m68851 },
-{"ptestr", two(0xf000, 0x8208), two(0xffc0, 0xe3f8), "D3&sQ8", m68030 | m68851 },
-{"ptestr", two(0xf000, 0x8308), two(0xffc0, 0xe318), "D3&sQ8A9", m68030 | m68851 },
-{"ptestr", two(0xf000, 0x8200), two(0xffc0, 0xe3fe), "f3&sQ8", m68030 | m68851 },
-{"ptestr", two(0xf000, 0x8300), two(0xffc0, 0xe31e), "f3&sQ8A9", m68030 | m68851 },
-
-{"ptestr", one(0xf568), one(0xfff8), "as", m68040 },
-
-{"ptestw", two(0xf000, 0x8010), two(0xffc0, 0xe3f0), "T3&sQ8", m68030 | m68851 },
-{"ptestw", two(0xf000, 0x8110), two(0xffc0, 0xe310), "T3&sQ8A9", m68030 | m68851 },
-{"ptestw", two(0xf000, 0x8008), two(0xffc0, 0xe3f8), "D3&sQ8", m68030 | m68851 },
-{"ptestw", two(0xf000, 0x8108), two(0xffc0, 0xe318), "D3&sQ8A9", m68030 | m68851 },
-{"ptestw", two(0xf000, 0x8000), two(0xffc0, 0xe3fe), "f3&sQ8", m68030 | m68851 },
-{"ptestw", two(0xf000, 0x8100), two(0xffc0, 0xe31e), "f3&sQ8A9", m68030 | m68851 },
-
-{"ptestw", one(0xf548), one(0xfff8), "as", m68040 },
-
-{"ptrapacw", two(0xf07a, 0x0007), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapacl", two(0xf07b, 0x0007), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapac", two(0xf07c, 0x0007), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapasw", two(0xf07a, 0x0006), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapasl", two(0xf07b, 0x0006), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapas", two(0xf07c, 0x0006), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapbcw", two(0xf07a, 0x0001), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapbcl", two(0xf07b, 0x0001), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapbc", two(0xf07c, 0x0001), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapbsw", two(0xf07a, 0x0000), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapbsl", two(0xf07b, 0x0000), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapbs", two(0xf07c, 0x0000), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapccw", two(0xf07a, 0x000f), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapccl", two(0xf07b, 0x000f), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapcc", two(0xf07c, 0x000f), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapcsw", two(0xf07a, 0x000e), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapcsl", two(0xf07b, 0x000e), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapcs", two(0xf07c, 0x000e), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapgcw", two(0xf07a, 0x000d), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapgcl", two(0xf07b, 0x000d), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapgc", two(0xf07c, 0x000d), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapgsw", two(0xf07a, 0x000c), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapgsl", two(0xf07b, 0x000c), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapgs", two(0xf07c, 0x000c), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapicw", two(0xf07a, 0x000b), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapicl", two(0xf07b, 0x000b), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapic", two(0xf07c, 0x000b), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapisw", two(0xf07a, 0x000a), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapisl", two(0xf07b, 0x000a), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapis", two(0xf07c, 0x000a), two(0xffff, 0xffff), "", m68851 },
-
-{"ptraplcw", two(0xf07a, 0x0003), two(0xffff, 0xffff), "#w", m68851 },
-{"ptraplcl", two(0xf07b, 0x0003), two(0xffff, 0xffff), "#l", m68851 },
-{"ptraplc", two(0xf07c, 0x0003), two(0xffff, 0xffff), "", m68851 },
-
-{"ptraplsw", two(0xf07a, 0x0002), two(0xffff, 0xffff), "#w", m68851 },
-{"ptraplsl", two(0xf07b, 0x0002), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapls", two(0xf07c, 0x0002), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapscw", two(0xf07a, 0x0005), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapscl", two(0xf07b, 0x0005), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapsc", two(0xf07c, 0x0005), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapssw", two(0xf07a, 0x0004), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapssl", two(0xf07b, 0x0004), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapss", two(0xf07c, 0x0004), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapwcw", two(0xf07a, 0x0009), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapwcl", two(0xf07b, 0x0009), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapwc", two(0xf07c, 0x0009), two(0xffff, 0xffff), "", m68851 },
-
-{"ptrapwsw", two(0xf07a, 0x0008), two(0xffff, 0xffff), "#w", m68851 },
-{"ptrapwsl", two(0xf07b, 0x0008), two(0xffff, 0xffff), "#l", m68851 },
-{"ptrapws", two(0xf07c, 0x0008), two(0xffff, 0xffff), "", m68851 },
-
-{"pvalid", two(0xf000, 0x2800), two(0xffc0, 0xffff), "Vs&s", m68851 },
-{"pvalid", two(0xf000, 0x2c00), two(0xffc0, 0xfff8), "A3&s", m68851 },
-
-#endif /* NO_68851 */
-
-{"reset", one(0047160), one(0177777), "", m68000up },
-
-{"rolb", one(0160430), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */
-{"rolb", one(0160470), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */
-{"roll", one(0160630), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */
-{"roll", one(0160670), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */
-{"rolw", one(0160530), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */
-{"rolw", one(0160570), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */
-{"rolw", one(0163700), one(0177700), "~s", m68000up }, /* Rotate memory */
-{"rorb", one(0160030), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */
-{"rorb", one(0160070), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */
-{"rorl", one(0160230), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */
-{"rorl", one(0160270), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */
-{"rorw", one(0160130), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */
-{"rorw", one(0160170), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */
-{"rorw", one(0163300), one(0177700), "~s", m68000up }, /* Rotate memory */
-
-{"roxlb", one(0160420), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */
-{"roxlb", one(0160460), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */
-{"roxll", one(0160620), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */
-{"roxll", one(0160660), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */
-{"roxlw", one(0160520), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */
-{"roxlw", one(0160560), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */
-{"roxlw", one(0162700), one(0177700), "~s", m68000up }, /* Rotate memory */
-{"roxrb", one(0160020), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */
-{"roxrb", one(0160060), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */
-{"roxrl", one(0160220), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */
-{"roxrl", one(0160260), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */
-{"roxrw", one(0160120), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */
-{"roxrw", one(0160160), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */
-{"roxrw", one(0162300), one(0177700), "~s", m68000up }, /* Rotate memory */
-
-{"rtd", one(0047164), one(0177777), "#w", m68010up },
-{"rte", one(0047163), one(0177777), "", m68000up },
-{"rtm", one(0003300), one(0177760), "Rs", m68020 },
-{"rtr", one(0047167), one(0177777), "", m68000up },
-{"rts", one(0047165), one(0177777), "", m68000up },
-
-{"sbcd", one(0100400), one(0170770), "DsDd", m68000up },
-{"sbcd", one(0100410), one(0170770), "-s-d", m68000up },
-
-{"scc", one(0052300), one(0177700), "$s", m68000up },
-{"scs", one(0052700), one(0177700), "$s", m68000up },
-{"seq", one(0053700), one(0177700), "$s", m68000up },
-{"sf", one(0050700), one(0177700), "$s", m68000up },
-{"sge", one(0056300), one(0177700), "$s", m68000up },
-{"sfge", one(0056300), one(0177700), "$s", m68000up },
-{"sgt", one(0057300), one(0177700), "$s", m68000up },
-{"sfgt", one(0057300), one(0177700), "$s", m68000up },
-{"shi", one(0051300), one(0177700), "$s", m68000up },
-{"sle", one(0057700), one(0177700), "$s", m68000up },
-{"sfle", one(0057700), one(0177700), "$s", m68000up },
-{"sls", one(0051700), one(0177700), "$s", m68000up },
-{"slt", one(0056700), one(0177700), "$s", m68000up },
-{"sflt", one(0056700), one(0177700), "$s", m68000up },
-{"smi", one(0055700), one(0177700), "$s", m68000up },
-{"sne", one(0053300), one(0177700), "$s", m68000up },
-{"sfneq", one(0053300), one(0177700), "$s", m68000up },
-{"spl", one(0055300), one(0177700), "$s", m68000up },
-{"st", one(0050300), one(0177700), "$s", m68000up },
-{"svc", one(0054300), one(0177700), "$s", m68000up },
-{"svs", one(0054700), one(0177700), "$s", m68000up },
-
-{"stop", one(0047162), one(0177777), "#w", m68000up },
-
-{"subal", one(0110700), one(0170700), "*lAd", m68000up },
-{"subaw", one(0110300), one(0170700), "*wAd", m68000up },
-{"subb", one(0050400), one(0170700), "Qd%s", m68000up }, /* subq written as sub */
-{"subb", one(0002000), one(0177700), "#b$s", m68000up }, /* subi written as sub */
-{"subb", one(0110000), one(0170700), ";bDd", m68000up }, /* subb ? ?, Dd */
-{"subb", one(0110400), one(0170700), "Dd~s", m68000up }, /* subb Dd, ? ? */
-{"subib", one(0002000), one(0177700), "#b$s", m68000up },
-{"subil", one(0002200), one(0177700), "#l$s", m68000up },
-{"subiw", one(0002100), one(0177700), "#w$s", m68000up },
-{"subl", one(0050600), one(0170700), "Qd%s", m68000up },
-{"subl", one(0002200), one(0177700), "#l$s", m68000up },
-{"subl", one(0110700), one(0170700), "*lAd", m68000up },
-{"subl", one(0110200), one(0170700), "*lDd", m68000up },
-{"subl", one(0110600), one(0170700), "Dd~s", m68000up },
-{"subqb", one(0050400), one(0170700), "Qd%s", m68000up },
-{"subql", one(0050600), one(0170700), "Qd%s", m68000up },
-{"subqw", one(0050500), one(0170700), "Qd%s", m68000up },
-{"subw", one(0050500), one(0170700), "Qd%s", m68000up },
-{"subw", one(0002100), one(0177700), "#w$s", m68000up },
-{"subw", one(0110100), one(0170700), "*wDd", m68000up },
-{"subw", one(0110300), one(0170700), "*wAd", m68000up }, /* suba written as sub */
-{"subw", one(0110500), one(0170700), "Dd~s", m68000up },
-{"subxb", one(0110400), one(0170770), "DsDd", m68000up }, /* subxb Ds, Dd */
-{"subxb", one(0110410), one(0170770), "-s-d", m68000up }, /* subxb -(As), -(Ad) */
-{"subxl", one(0110600), one(0170770), "DsDd", m68000up },
-{"subxl", one(0110610), one(0170770), "-s-d", m68000up },
-{"subxw", one(0110500), one(0170770), "DsDd", m68000up },
-{"subxw", one(0110510), one(0170770), "-s-d", m68000up },
-
-{"swap", one(0044100), one(0177770), "Ds", m68000up },
-
-{"tas", one(0045300), one(0177700), "$s", m68000up },
-{"trap", one(0047100), one(0177760), "Ts", m68000up },
-
-{"trapcc", one(0052374), one(0177777), "", m68020up },
-{"trapcs", one(0052774), one(0177777), "", m68020up },
-{"trapeq", one(0053774), one(0177777), "", m68020up },
-{"trapf", one(0050774), one(0177777), "", m68020up },
-{"trapge", one(0056374), one(0177777), "", m68020up },
-{"trapgt", one(0057374), one(0177777), "", m68020up },
-{"traphi", one(0051374), one(0177777), "", m68020up },
-{"traple", one(0057774), one(0177777), "", m68020up },
-{"trapls", one(0051774), one(0177777), "", m68020up },
-{"traplt", one(0056774), one(0177777), "", m68020up },
-{"trapmi", one(0055774), one(0177777), "", m68020up },
-{"trapne", one(0053374), one(0177777), "", m68020up },
-{"trappl", one(0055374), one(0177777), "", m68020up },
-{"trapt", one(0050374), one(0177777), "", m68020up },
-{"trapvc", one(0054374), one(0177777), "", m68020up },
-{"trapvs", one(0054774), one(0177777), "", m68020up },
-
-{"trapcc.w", one(0052372), one(0177777), "", m68020up },
-{"trapcs.w", one(0052772), one(0177777), "", m68020up },
-{"trapeq.w", one(0053772), one(0177777), "", m68020up },
-{"trapf.w", one(0050772), one(0177777), "", m68020up },
-{"trapge.w", one(0056372), one(0177777), "", m68020up },
-{"trapgt.w", one(0057372), one(0177777), "", m68020up },
-{"traphi.w", one(0051372), one(0177777), "", m68020up },
-{"traple.w", one(0057772), one(0177777), "", m68020up },
-{"trapls.w", one(0051772), one(0177777), "", m68020up },
-{"traplt.w", one(0056772), one(0177777), "", m68020up },
-{"trapmi.w", one(0055772), one(0177777), "", m68020up },
-{"trapne.w", one(0053372), one(0177777), "", m68020up },
-{"trappl.w", one(0055372), one(0177777), "", m68020up },
-{"trapt.w", one(0050372), one(0177777), "", m68020up },
-{"trapvc.w", one(0054372), one(0177777), "", m68020up },
-{"trapvs.w", one(0054772), one(0177777), "", m68020up },
-
-{"trapcc.l", one(0052373), one(0177777), "", m68020up },
-{"trapcs.l", one(0052773), one(0177777), "", m68020up },
-{"trapeq.l", one(0053773), one(0177777), "", m68020up },
-{"trapf.l", one(0050773), one(0177777), "", m68020up },
-{"trapge.l", one(0056373), one(0177777), "", m68020up },
-{"trapgt.l", one(0057373), one(0177777), "", m68020up },
-{"traphi.l", one(0051373), one(0177777), "", m68020up },
-{"traple.l", one(0057773), one(0177777), "", m68020up },
-{"trapls.l", one(0051773), one(0177777), "", m68020up },
-{"traplt.l", one(0056773), one(0177777), "", m68020up },
-{"trapmi.l", one(0055773), one(0177777), "", m68020up },
-{"trapne.l", one(0053373), one(0177777), "", m68020up },
-{"trappl.l", one(0055373), one(0177777), "", m68020up },
-{"trapt.l", one(0050373), one(0177777), "", m68020up },
-{"trapvc.l", one(0054373), one(0177777), "", m68020up },
-{"trapvs.l", one(0054773), one(0177777), "", m68020up },
-
-{"trapv", one(0047166), one(0177777), "", m68000up },
-
-{"tstb", one(0045000), one(0177700), ";b", m68000up },
-{"tstw", one(0045100), one(0177700), "*w", m68000up },
-{"tstl", one(0045200), one(0177700), "*l", m68000up },
-
-{"unlk", one(0047130), one(0177770), "As", m68000up },
-{"unpk", one(0100600), one(0170770), "DsDd#w", m68020up },
-{"unpk", one(0100610), one(0170770), "-s-d#w", m68020up },
-
-/* Variable-sized branches */
-
-{"jbsr", one(0060400), one(0177400), "Bg", m68000up },
-{"jbsr", one(0047200), one(0177700), "!s", m68000up },
-#ifdef PIC
-{"jbsr", one(0060400), one(0177400), "Bg ", m68020up },
-#endif /* PIC */
-
-{"jra", one(0060000), one(0177400), "Bg", m68000up },
-{"jra", one(0047300), one(0177700), "!s", m68000up },
-#ifdef PIC
-{"jra", one(0060000), one(0177400), "Bg ", m68000up },
-#endif /* PIC */
-
-{"jhi", one(0061000), one(0177400), "Bg", m68000up },
-{"jls", one(0061400), one(0177400), "Bg", m68000up },
-{"jcc", one(0062000), one(0177400), "Bg", m68000up },
-{"jfnlt", one(0062000), one(0177400), "Bg", m68000up }, /* apparently a sun alias */
-{"jcs", one(0062400), one(0177400), "Bg", m68000up },
-{"jne", one(0063000), one(0177400), "Bg", m68000up },
-{"jeq", one(0063400), one(0177400), "Bg", m68000up },
-{"jfeq", one(0063400), one(0177400), "Bg", m68000up }, /* apparently a sun alias */
-{"jvc", one(0064000), one(0177400), "Bg", m68000up },
-{"jvs", one(0064400), one(0177400), "Bg", m68000up },
-{"jpl", one(0065000), one(0177400), "Bg", m68000up },
-{"jmi", one(0065400), one(0177400), "Bg", m68000up },
-{"jge", one(0066000), one(0177400), "Bg", m68000up },
-{"jlt", one(0066400), one(0177400), "Bg", m68000up },
-{"jgt", one(0067000), one(0177400), "Bg", m68000up },
-{"jle", one(0067400), one(0177400), "Bg", m68000up },
-{"jfngt", one(0067400), one(0177400), "Bg", m68000up }, /* apparently a sun alias */
-
-/* aliases */
-
-{"movql", one(0070000), one(0170400), "MsDd", m68000up },
-{"moveql", one(0070000), one(0170400), "MsDd", m68000up },
-{"moval", one(0020100), one(0170700), "*lAd", m68000up },
-{"movaw", one(0030100), one(0170700), "*wAd", m68000up },
-{"movb", one(0010000), one(0170000), ";b$d", m68000up }, /* mov */
-{"movl", one(0070000), one(0170400), "MsDd", m68000up }, /* movq written as mov */
-{"movl", one(0020000), one(0170000), "*l$d", m68000up },
-{"movl", one(0020100), one(0170700), "*lAd", m68000up },
-{"movl", one(0047140), one(0177770), "AsUd", m68000up }, /* mov to USP */
-{"movl", one(0047150), one(0177770), "UdAs", m68000up }, /* mov from USP */
-{"movc", one(0047173), one(0177777), "R1Jj", m68010up },
-{"movc", one(0047173), one(0177777), "R1#j", m68010up },
-{"movc", one(0047172), one(0177777), "JjR1", m68010up },
-{"movc", one(0047172), one(0177777), "#jR1", m68010up },
-{"movml", one(0044300), one(0177700), "#w&s", m68000up }, /* movm reg to mem. */
-{"movml", one(0044340), one(0177770), "#w-s", m68000up }, /* movm reg to autodecrement. */
-{"movml", one(0046300), one(0177700), "!s#w", m68000up }, /* movm mem to reg. */
-{"movml", one(0046330), one(0177770), "+s#w", m68000up }, /* movm autoinc to reg. */
-{"movml", one(0044300), one(0177700), "Lw&s", m68000up }, /* movm reg to mem. */
-{"movml", one(0044340), one(0177770), "lw-s", m68000up }, /* movm reg to autodecrement. */
-{"movml", one(0046300), one(0177700), "!sLw", m68000up }, /* movm mem to reg. */
-{"movml", one(0046330), one(0177770), "+sLw", m68000up }, /* movm autoinc to reg. */
-{"movmw", one(0044200), one(0177700), "#w&s", m68000up }, /* movm reg to mem. */
-{"movmw", one(0044240), one(0177770), "#w-s", m68000up }, /* movm reg to autodecrement. */
-{"movmw", one(0046200), one(0177700), "!s#w", m68000up }, /* movm mem to reg. */
-{"movmw", one(0046230), one(0177770), "+s#w", m68000up }, /* movm autoinc to reg. */
-{"movmw", one(0044200), one(0177700), "Lw&s", m68000up }, /* movm reg to mem. */
-{"movmw", one(0044240), one(0177770), "lw-s", m68000up }, /* movm reg to autodecrement. */
-{"movmw", one(0046200), one(0177700), "!sLw", m68000up }, /* movm mem to reg. */
-{"movmw", one(0046230), one(0177770), "+sLw", m68000up }, /* movm autoinc to reg. */
-{"movpl", one(0000510), one(0170770), "dsDd", m68000up }, /* memory to register */
-{"movpl", one(0000710), one(0170770), "Ddds", m68000up }, /* register to memory */
-{"movpw", one(0000410), one(0170770), "dsDd", m68000up }, /* memory to register */
-{"movpw", one(0000610), one(0170770), "Ddds", m68000up }, /* register to memory */
-{"movq", one(0070000), one(0170400), "MsDd", m68000up },
-{"movw", one(0030000), one(0170000), "*w$d", m68000up },
-{"movw", one(0030100), one(0170700), "*wAd", m68000up }, /* mova, written as mov */
-{"movw", one(0040300), one(0177700), "Ss$s", m68000up }, /* Move from sr */
-{"movw", one(0041300), one(0177700), "Cs$s", m68010up }, /* Move from ccr */
-{"movw", one(0042300), one(0177700), ";wCd", m68000up }, /* mov to ccr */
-{"movw", one(0043300), one(0177700), ";wSd", m68000up }, /* mov to sr */
-
-{"movsb", two(0007000, 0), two(0177700, 07777), "~sR1", m68010up },
-{"movsb", two(0007000, 04000), two(0177700, 07777), "R1~s", m68010up },
-{"movsl", two(0007200, 0), two(0177700, 07777), "~sR1", m68010up },
-{"movsl", two(0007200, 04000), two(0177700, 07777), "R1~s", m68010up },
-{"movsw", two(0007100, 0), two(0177700, 07777), "~sR1", m68010up },
-{"movsw", two(0007100, 04000), two(0177700, 07777), "R1~s", m68010up },
-
-};
-
-int numopcodes=sizeof(m68k_opcodes)/sizeof(m68k_opcodes[0]);
-
-struct m68k_opcode *endop = m68k_opcodes+sizeof(m68k_opcodes)/sizeof(m68k_opcodes[0]);
-
-/*
- * Local Variables:
- * fill-column: 131
- * End:
- */
-
-/* end of m68k-opcode.h */
diff --git a/gnu/usr.bin/as/opcode/m88k.h b/gnu/usr.bin/as/opcode/m88k.h
deleted file mode 100644
index 5f685b9..0000000
--- a/gnu/usr.bin/as/opcode/m88k.h
+++ /dev/null
@@ -1,282 +0,0 @@
-/* m88k-opcode.h -- Instruction information for the Motorola 88000
- Contributed by Devon Bowen of Buffalo University
- and Torbjorn Granlund of the Swedish Institute of Computer Science.
- Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
-
-This file is part of GAS, the GNU Assembler.
-
-GAS is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GAS 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 GAS; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined(__STDC__) && !defined(const)
-#define const
-#endif
-
-/*
- Character codes for op_spec field below.
- Reserved for direct matching: x , [ ]
-
- d = GRF Destination register (21:5)
- 1 = Source register 1 (16:5)
- 2 = Source register 2 (0:5)
- 3 = Both source registers (same value) (0:5 and 16:5)
- I = IMM16 (0:16)
- b = bit field spec. (0:10)
- p = 16 bit pc displ. (0:16)
- P = 26 bit pc displ. (0:26)
- B = bb0/bb1 condition (21:5)
- M = bcnd condition (21:5)
- f = fcr (5:6)
- c = cr (5:6)
- V = VEC9 (0:9)
- ? = Give warning for this insn/operand combination
- */
-
-/* instruction descriptor structure */
-
-struct m88k_opcode
-{
- unsigned int opcode;
- char *name;
- char *op_spec;
-};
-
-/* and introducing... the Motorola 88100 instruction sets... */
-
-/* These macros may seem silly, but they are in preparation
- for future versions of the 88000 family. */
-
-#define _MC88100(OPCODE,MNEM,OP_SPEC) {OPCODE,MNEM,OP_SPEC},
-#define _MC88xxx(OPCODE,MNEM,OP_SPEC) {OPCODE,MNEM,OP_SPEC},
-
-/* Equal mnemonics must be adjacent.
- More specific operand specification must go before more general.
- For example, "d,1,2" must go before "d,1,I" as a register for s2
- would otherwise be considered a variable name. */
-
-static struct m88k_opcode m88k_opcodes[] =
-{
- /* Opcode Mnemonic Opspec */
-
- _MC88xxx(0xf4007000, "add", "d,1,2")
- _MC88xxx(0x70000000, "add", "d,1,I")
- _MC88xxx(0xf4007200, "add.ci", "d,1,2")
- _MC88xxx(0xf4007300, "add.cio", "d,1,2")
- _MC88xxx(0xf4007100, "add.co", "d,1,2")
- _MC88xxx(0xf4006000, "addu", "d,1,2")
- _MC88xxx(0x60000000, "addu", "d,1,I")
- _MC88xxx(0xf4006200, "addu.ci", "d,1,2")
- _MC88xxx(0xf4006300, "addu.cio", "d,1,2")
- _MC88xxx(0xf4006100, "addu.co", "d,1,2")
- _MC88xxx(0xf4004000, "and", "d,1,2")
- _MC88xxx(0x40000000, "and", "d,1,I")
- _MC88xxx(0xf4004400, "and.c", "d,1,2")
- _MC88xxx(0x44000000, "and.u", "d,1,I")
- _MC88xxx(0xd0000000, "bb0", "B,1,p")
- _MC88xxx(0xd4000000, "bb0.n", "B,1,p")
- _MC88xxx(0xd8000000, "bb1", "B,1,p")
- _MC88xxx(0xdc000000, "bb1.n", "B,1,p")
- _MC88xxx(0xe8000000, "bcnd", "M,1,p")
- _MC88xxx(0xec000000, "bcnd.n", "M,1,p")
- _MC88xxx(0xc0000000, "br", "P")
- _MC88xxx(0xc4000000, "br.n", "P")
- _MC88xxx(0xc8000000, "bsr", "P")
- _MC88xxx(0xcc000000, "bsr.n", "P")
- _MC88xxx(0xf4008000, "clr", "d,1,2")
- _MC88xxx(0xf0008000, "clr", "d,1,b")
- _MC88xxx(0xf4007c00, "cmp", "d,1,2")
- _MC88xxx(0x7c000000, "cmp", "d,1,I")
- _MC88xxx(0xf4007800, "div", "d,1,2")
- _MC88xxx(0x78000000, "div", "d,1,I")
- _MC88xxx(0xf4007800, "divs", "d,1,2")
- _MC88xxx(0x78000000, "divs", "d,1,I")
- _MC88xxx(0xf4006800, "divu", "d,1,2")
- _MC88xxx(0x68000000, "divu", "d,1,I")
- _MC88xxx(0xf4009000, "ext", "d,1,2")
- _MC88xxx(0xf0009000, "ext", "d,1,b")
- _MC88xxx(0xf4009800, "extu", "d,1,2")
- _MC88xxx(0xf0009800, "extu", "d,1,b")
- _MC88xxx(0x84002800, "fadd.sss", "d,1,2")
- _MC88xxx(0x84002880, "fadd.ssd", "d,1,2")
- _MC88xxx(0x84002a00, "fadd.sds", "d,1,2")
- _MC88xxx(0x84002a80, "fadd.sdd", "d,1,2")
- _MC88xxx(0x84002820, "fadd.dss", "d,1,2")
- _MC88xxx(0x840028a0, "fadd.dsd", "d,1,2")
- _MC88xxx(0x84002a20, "fadd.dds", "d,1,2")
- _MC88xxx(0x84002aa0, "fadd.ddd", "d,1,2")
- _MC88xxx(0x84003a80, "fcmp.sdd", "d,1,2")
- _MC88xxx(0x84003a00, "fcmp.sds", "d,1,2")
- _MC88xxx(0x84003880, "fcmp.ssd", "d,1,2")
- _MC88xxx(0x84003800, "fcmp.sss", "d,1,2")
- _MC88xxx(0x84007000, "fdiv.sss", "d,1,2")
- _MC88xxx(0x84007080, "fdiv.ssd", "d,1,2")
- _MC88xxx(0x84007200, "fdiv.sds", "d,1,2")
- _MC88xxx(0x84007280, "fdiv.sdd", "d,1,2")
- _MC88xxx(0x84007020, "fdiv.dss", "d,1,2")
- _MC88xxx(0x840070a0, "fdiv.dsd", "d,1,2")
- _MC88xxx(0x84007220, "fdiv.dds", "d,1,2")
- _MC88xxx(0x840072a0, "fdiv.ddd", "d,1,2")
- _MC88xxx(0xf400ec00, "ff0", "d,2")
- _MC88xxx(0xf400e800, "ff1", "d,2")
- _MC88xxx(0x80004800, "fldcr", "d,f")
- _MC88xxx(0x84002020, "flt.ds", "d,2")
- _MC88xxx(0x84002000, "flt.ss", "d,2")
- _MC88xxx(0x84000000, "fmul.sss", "d,1,2")
- _MC88xxx(0x84000080, "fmul.ssd", "d,1,2")
- _MC88xxx(0x84000200, "fmul.sds", "d,1,2")
- _MC88xxx(0x84000280, "fmul.sdd", "d,1,2")
- _MC88xxx(0x84000020, "fmul.dss", "d,1,2")
- _MC88xxx(0x840000a0, "fmul.dsd", "d,1,2")
- _MC88xxx(0x84000220, "fmul.dds", "d,1,2")
- _MC88xxx(0x840002a0, "fmul.ddd", "d,1,2")
- _MC88xxx(0x80008800, "fstcr", "3,f")
- _MC88xxx(0x84003000, "fsub.sss", "d,1,2")
- _MC88xxx(0x84003080, "fsub.ssd", "d,1,2")
- _MC88xxx(0x84003200, "fsub.sds", "d,1,2")
- _MC88xxx(0x84003280, "fsub.sdd", "d,1,2")
- _MC88xxx(0x84003020, "fsub.dss", "d,1,2")
- _MC88xxx(0x840030a0, "fsub.dsd", "d,1,2")
- _MC88xxx(0x84003220, "fsub.dds", "d,1,2")
- _MC88xxx(0x840032a0, "fsub.ddd", "d,1,2")
- _MC88xxx(0x8000c800, "fxcr", "d,3,f")
- _MC88xxx(0x8400fc01, "illop1", "")
- _MC88xxx(0x8400fc02, "illop2", "")
- _MC88xxx(0x8400fc03, "illop3", "")
- _MC88xxx(0x84004880, "int.sd", "d,2")
- _MC88xxx(0x84004800, "int.ss", "d,2")
- _MC88xxx(0xf400c000, "jmp", "2")
- _MC88xxx(0xf400c400, "jmp.n", "2")
- _MC88xxx(0xf400c800, "jsr", "2")
- _MC88xxx(0xf400cc00, "jsr.n", "2")
- _MC88xxx(0xf4001400, "ld", "d,1,2")
- _MC88xxx(0xf4001600, "ld", "d,1[2]")
- _MC88xxx(0x14000000, "ld", "d,1,I")
- _MC88xxx(0xf4001e00, "ld.b", "d,1[2]")
- _MC88xxx(0xf4001c00, "ld.b", "d,1,2")
- _MC88xxx(0x1c000000, "ld.b", "d,1,I")
- _MC88xxx(0xf4001d00, "ld.b.usr", "d,1,2")
- _MC88xxx(0xf4001f00, "ld.b.usr", "d,1[2]")
- _MC88xxx(0xf4000e00, "ld.bu", "d,1[2]")
- _MC88xxx(0xf4000c00, "ld.bu", "d,1,2")
- _MC88xxx(0x0c000000, "ld.bu", "d,1,I")
- _MC88xxx(0xf4000d00, "ld.bu.usr", "d,1,2")
- _MC88xxx(0xf4000f00, "ld.bu.usr", "d,1[2]")
- _MC88xxx(0xf4001200, "ld.d", "d,1[2]")
- _MC88xxx(0xf4001000, "ld.d", "d,1,2")
- _MC88xxx(0x10000000, "ld.d", "d,1,I")
- _MC88xxx(0xf4001100, "ld.d.usr", "d,1,2")
- _MC88xxx(0xf4001300, "ld.d.usr", "d,1[2]")
- _MC88xxx(0xf4001a00, "ld.h", "d,1[2]")
- _MC88xxx(0xf4001800, "ld.h", "d,1,2")
- _MC88xxx(0x18000000, "ld.h", "d,1,I")
- _MC88xxx(0xf4001900, "ld.h.usr", "d,1,2")
- _MC88xxx(0xf4001b00, "ld.h.usr", "d,1[2]")
- _MC88xxx(0xf4000a00, "ld.hu", "d,1[2]")
- _MC88xxx(0xf4000800, "ld.hu", "d,1,2")
- _MC88xxx(0x08000000, "ld.hu", "d,1,I")
- _MC88xxx(0xf4000900, "ld.hu.usr", "d,1,2")
- _MC88xxx(0xf4000b00, "ld.hu.usr", "d,1[2]")
- _MC88xxx(0xf4001500, "ld.usr", "d,1,2")
- _MC88xxx(0xf4001700, "ld.usr", "d,1[2]")
- _MC88xxx(0xf4003600, "lda", "d,1[2]")
- _MC88xxx(0xf4006000, "lda", "?d,1,2") /* Output addu */
- _MC88xxx(0x60000000, "lda", "?d,1,I") /* Output addu */
- _MC88xxx(0xf4006000, "lda.b", "?d,1[2]") /* Output addu */
- _MC88xxx(0xf4006000, "lda.b", "?d,1,2") /* Output addu */
- _MC88xxx(0x60000000, "lda.b", "?d,1,I") /* Output addu */
- _MC88xxx(0xf4003200, "lda.d", "d,1[2]")
- _MC88xxx(0xf4006000, "lda.d", "?d,1,2") /* Output addu */
- _MC88xxx(0x60000000, "lda.d", "?d,1,I") /* Output addu */
- _MC88xxx(0xf4003a00, "lda.h", "d,1[2]")
- _MC88xxx(0xf4006000, "lda.h", "?d,1,2") /* Output addu */
- _MC88xxx(0x60000000, "lda.h", "?d,1,I") /* Output addu */
- _MC88xxx(0x80004000, "ldcr", "d,c")
- _MC88xxx(0xf400a000, "mak", "d,1,2")
- _MC88xxx(0xf000a000, "mak", "d,1,b")
- _MC88xxx(0x48000000, "mask", "d,1,I")
- _MC88xxx(0x4c000000, "mask.u", "d,1,I")
- _MC88xxx(0xf4006c00, "mul", "d,1,2")
- _MC88xxx(0x6c000000, "mul", "d,1,I")
- _MC88xxx(0xf4006c00, "mulu", "d,1,2") /* synonym for mul */
- _MC88xxx(0x6c000000, "mulu", "d,1,I") /* synonym for mul */
- _MC88xxx(0x84005080, "nint.sd", "d,2")
- _MC88xxx(0x84005000, "nint.ss", "d,2")
- _MC88xxx(0xf4005800, "or", "d,1,2")
- _MC88xxx(0x58000000, "or", "d,1,I")
- _MC88xxx(0xf4005c00, "or.c", "d,1,2")
- _MC88xxx(0x5c000000, "or.u", "d,1,I")
- _MC88xxx(0xf000a800, "rot", "d,1,b")
- _MC88xxx(0xf400a800, "rot", "d,1,2")
- _MC88xxx(0xf400fc00, "rte", "")
- _MC88xxx(0xf4008800, "set", "d,1,2")
- _MC88xxx(0xf0008800, "set", "d,1,b")
- _MC88xxx(0xf4002600, "st", "d,1[2]")
- _MC88xxx(0xf4002400, "st", "d,1,2")
- _MC88xxx(0x24000000, "st", "d,1,I")
- _MC88xxx(0xf4002e00, "st.b", "d,1[2]")
- _MC88xxx(0xf4002c00, "st.b", "d,1,2")
- _MC88xxx(0x2c000000, "st.b", "d,1,I")
- _MC88xxx(0xf4002d00, "st.b.usr", "d,1,2")
- _MC88xxx(0xf4002f00, "st.b.usr", "d,1[2]")
- _MC88xxx(0xf4002200, "st.d", "d,1[2]")
- _MC88xxx(0xf4002000, "st.d", "d,1,2")
- _MC88xxx(0x20000000, "st.d", "d,1,I")
- _MC88xxx(0xf4002100, "st.d.usr", "d,1,2")
- _MC88xxx(0xf4002300, "st.d.usr", "d,1[2]")
- _MC88xxx(0xf4002a00, "st.h", "d,1[2]")
- _MC88xxx(0xf4002800, "st.h", "d,1,2")
- _MC88xxx(0x28000000, "st.h", "d,1,I")
- _MC88xxx(0xf4002900, "st.h.usr", "d,1,2")
- _MC88xxx(0xf4002b00, "st.h.usr", "d,1[2]")
- _MC88xxx(0xf4002500, "st.usr", "d,1,2")
- _MC88xxx(0xf4002700, "st.usr", "d,1[2]")
- _MC88xxx(0x80008000, "stcr", "3,c")
- _MC88xxx(0xf4007400, "sub", "d,1,2")
- _MC88xxx(0x74000000, "sub", "d,1,I")
- _MC88xxx(0xf4007600, "sub.ci", "d,1,2")
- _MC88xxx(0xf4007700, "sub.cio", "d,1,2")
- _MC88xxx(0xf4007500, "sub.co", "d,1,2")
- _MC88xxx(0xf4006400, "subu", "d,1,2")
- _MC88xxx(0x64000000, "subu", "d,1,I")
- _MC88xxx(0xf4006600, "subu.ci", "d,1,2")
- _MC88xxx(0xf4006700, "subu.cio", "d,1,2")
- _MC88xxx(0xf4006500, "subu.co", "d,1,2")
- _MC88xxx(0xf000d000, "tb0", "B,1,V")
- _MC88xxx(0xf000d800, "tb1", "B,1,V")
- _MC88xxx(0xf400f800, "tbnd", "1,2")
- _MC88xxx(0xf8000000, "tbnd", "1,I")
- _MC88xxx(0xf000e800, "tcnd", "M,1,V")
- _MC88xxx(0x84005880, "trnc.sd", "d,2")
- _MC88xxx(0x84005800, "trnc.ss", "d,2")
- _MC88xxx(0x8000c000, "xcr", "d,1,c")
- _MC88xxx(0xf4000600, "xmem", "d,1[2]")
- _MC88xxx(0xf4000400, "xmem", "d,1,2")
- _MC88100(0x04000000, "xmem", "?d,1,I")
- _MC88xxx(0xf4000200, "xmem.bu", "d,1[2]")
- _MC88xxx(0xf4000000, "xmem.bu", "d,1,2")
- _MC88100(0x00000000, "xmem.bu", "?d,1,I")
- _MC88xxx(0xf4000300, "xmem.bu.usr", "d,1[2]")
- _MC88xxx(0xf4000100, "xmem.bu.usr", "d,1,2")
- _MC88100(0x00000100, "xmem.bu.usr", "?d,1,I")
- _MC88xxx(0xf4000700, "xmem.usr", "d,1[2]")
- _MC88xxx(0xf4000500, "xmem.usr", "d,1,2")
- _MC88100(0x04000100, "xmem.usr", "?d,1,I")
- _MC88xxx(0xf4005000, "xor", "d,1,2")
- _MC88xxx(0x50000000, "xor", "d,1,I")
- _MC88xxx(0xf4005400, "xor.c", "d,1,2")
- _MC88xxx(0x54000000, "xor.u", "d,1,I")
- _MC88xxx(0x00000000, "", 0)
-};
-
-#define NUMOPCODES ((sizeof m88k_opcodes)/(sizeof m88k_opcodes[0]))
diff --git a/gnu/usr.bin/as/opcode/mips.h b/gnu/usr.bin/as/opcode/mips.h
deleted file mode 100644
index 796ed47..0000000
--- a/gnu/usr.bin/as/opcode/mips.h
+++ /dev/null
@@ -1,363 +0,0 @@
-/* Mips opcde list for GDB, the GNU debugger.
- Copyright (C) 1989 Free Software Foundation, Inc.
- Contributed by Nobuyuki Hikichi(hikichi@sra.junet)
- Made to work for little-endian machines, and debugged
- by Per Bothner (bothner@cs.wisc.edu).
- Many fixes contributed by Frank Yellin (fy@lucid.com).
-
-This file is part of GDB.
-
-GDB is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GDB 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 GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if BITS_BIG_ENDIAN
-#define BIT_FIELDS_2(a,b) a;b;
-#define BIT_FIELDS_4(a,b,c,d) a;b;c;d;
-#define BIT_FIELDS_6(a,b,c,d,e,f) a;b;c;d;e;f;
-#else
-#define BIT_FIELDS_2(a,b) b;a;
-#define BIT_FIELDS_4(a,b,c,d) d;c;b;a;
-#define BIT_FIELDS_6(a,b,c,d,e,f) f;e;d;c;b;a;
-#endif
-
-struct op_i_fmt
-{
-BIT_FIELDS_4(
- unsigned op : 6,
- unsigned rs : 5,
- unsigned rt : 5,
- unsigned immediate : 16)
-};
-
-struct op_j_fmt
-{
-BIT_FIELDS_2(
- unsigned op : 6,
- unsigned target : 26)
-};
-
-struct op_r_fmt
-{
-BIT_FIELDS_6(
- unsigned op : 6,
- unsigned rs : 5,
- unsigned rt : 5,
- unsigned rd : 5,
- unsigned shamt : 5,
- unsigned funct : 6)
-};
-
-
-struct fop_i_fmt
-{
-BIT_FIELDS_4(
- unsigned op : 6,
- unsigned rs : 5,
- unsigned rt : 5,
- unsigned immediate : 16)
-};
-
-struct op_b_fmt
-{
-BIT_FIELDS_4(
- unsigned op : 6,
- unsigned rs : 5,
- unsigned rt : 5,
- short delta : 16)
-};
-
-struct fop_r_fmt
-{
-BIT_FIELDS_6(
- unsigned op : 6,
- unsigned fmt : 5,
- unsigned ft : 5,
- unsigned fs : 5,
- unsigned fd : 5,
- unsigned funct : 6)
-};
-
-struct mips_opcode
-{
- char *name;
- unsigned long opcode;
- unsigned long match;
- char *args;
- int bdelay; /* Nonzero if delayed branch. */
-};
-
-/* args format;
-
- "s" rs: source register specifier
- "t" rt: target register
- "i" immediate
- "a" target address
- "c" branch condition
- "d" rd: destination register specifier
- "h" shamt: shift amount
- "f" funct: function field
-
- for fpu
- "S" fs source 1 register
- "T" ft source 2 register
- "D" distination register
-*/
-
-#define one(x) (x << 26)
-#define op_func(x, y) ((x << 26) | y)
-#define op_cond(x, y) ((x << 26) | (y << 16))
-#define op_rs_func(x, y, z) ((x << 26) | (y << 21) | z)
-#define op_rs_b11(x, y, z) ((x << 26) | (y << 21) | z)
-#define op_o16(x, y) ((x << 26) | (y << 16))
-#define op_bc(x, y, z) ((x << 26) | (y << 21) | (z << 16))
-
-struct mips_opcode mips_opcodes[] =
-{
-/* These first opcodes are special cases of the ones in the comments */
- {"nop", 0, 0xffffffff, /*li*/ "", 0},
- {"li", op_bc(9,0,0), op_bc(0x3f,31,0), /*addiu*/ "t,j", 0},
- {"b", one(4), 0xffff0000, /*beq*/ "b", 1},
- {"move", op_func(0, 33), op_cond(0x3f,31)|0x7ff,/*addu*/ "d,s", 0},
-
- {"sll", op_func(0, 0), op_func(0x3f, 0x3f), "d,t,h", 0},
- {"srl", op_func(0, 2), op_func(0x3f, 0x3f), "d,t,h", 0},
- {"sra", op_func(0, 3), op_func(0x3f, 0x3f), "d,t,h", 0},
- {"sllv", op_func(0, 4), op_func(0x3f, 0x7ff), "d,t,s", 0},
- {"srlv", op_func(0, 6), op_func(0x3f, 0x7ff), "d,t,s", 0},
- {"srav", op_func(0, 7), op_func(0x3f, 0x7ff), "d,t,s", 0},
- {"jr", op_func(0, 8), op_func(0x3f, 0x1fffff), "s", 1},
- {"jalr", op_func(0, 9), op_func(0x3f, 0x1f07ff), "d,s", 1},
- {"syscall", op_func(0, 12), op_func(0x3f, 0x3f), "", 0},
- {"break", op_func(0, 13), op_func(0x3f, 0x3f), "", 0},
- {"mfhi", op_func(0, 16), op_func(0x3f, 0x03ff07ff), "d", 0},
- {"mthi", op_func(0, 17), op_func(0x3f, 0x1fffff), "s", 0},
- {"mflo", op_func(0, 18), op_func(0x3f, 0x03ff07ff), "d", 0},
- {"mtlo", op_func(0, 19), op_func(0x3f, 0x1fffff), "s", 0},
- {"mult", op_func(0, 24), op_func(0x3f, 0xffff), "s,t", 0},
- {"multu", op_func(0, 25), op_func(0x3f, 0xffff), "s,t", 0},
- {"div", op_func(0, 26), op_func(0x3f, 0xffff), "s,t", 0},
- {"divu", op_func(0, 27), op_func(0x3f, 0xffff), "s,t", 0},
- {"add", op_func(0, 32), op_func(0x3f, 0x7ff), "d,s,t", 0},
- {"addu", op_func(0, 33), op_func(0x3f, 0x7ff), "d,s,t", 0},
- {"sub", op_func(0, 34), op_func(0x3f, 0x7ff), "d,s,t", 0},
- {"subu", op_func(0, 35), op_func(0x3f, 0x7ff), "d,s,t", 0},
- {"and", op_func(0, 36), op_func(0x3f, 0x7ff), "d,s,t", 0},
- {"or", op_func(0, 37), op_func(0x3f, 0x7ff), "d,s,t", 0},
- {"xor", op_func(0, 38), op_func(0x3f, 0x7ff), "d,s,t", 0},
- {"nor", op_func(0, 39), op_func(0x3f, 0x7ff), "d,s,t", 0},
- {"slt", op_func(0, 42), op_func(0x3f, 0x7ff), "d,s,t", 0},
- {"sltu", op_func(0, 43), op_func(0x3f, 0x7ff), "d,s,t", 0},
-
- {"bltz", op_cond (1, 0), op_cond(0x3f, 0x1f), "s,b", 1},
- {"bgez", op_cond (1, 1), op_cond(0x3f, 0x1f), "s,b", 1},
- {"bltzal", op_cond (1, 16),op_cond(0x3f, 0x1f), "s,b", 1},
- {"bgezal", op_cond (1, 17),op_cond(0x3f, 0x1f), "s,b", 1},
-
-
- {"j", one(2), one(0x3f), "a", 1},
- {"jal", one(3), one(0x3f), "a", 1},
- {"beq", one(4), one(0x3f), "s,t,b", 1},
- {"bne", one(5), one(0x3f), "s,t,b", 1},
- {"blez", one(6), one(0x3f) | 0x1f0000, "s,b", 1},
- {"bgtz", one(7), one(0x3f) | 0x1f0000, "s,b", 1},
- {"addi", one(8), one(0x3f), "t,s,j", 0},
- {"addiu", one(9), one(0x3f), "t,s,j", 0},
- {"slti", one(10), one(0x3f), "t,s,j", 0},
- {"sltiu", one(11), one(0x3f), "t,s,j", 0},
- {"andi", one(12), one(0x3f), "t,s,i", 0},
- {"ori", one(13), one(0x3f), "t,s,i", 0},
- {"xori", one(14), one(0x3f), "t,s,i", 0},
- /* rs field is don't care field? */
- {"lui", one(15), one(0x3f), "t,i", 0},
-
-/* co processor 0 instruction */
- {"mfc0", op_rs_b11 (16, 0, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"cfc0", op_rs_b11 (16, 2, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"mtc0", op_rs_b11 (16, 4, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"ctc0", op_rs_b11 (16, 6, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
-
- {"bc0f", op_o16(16, 0x100), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc0f", op_o16(16, 0x180), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc0t", op_o16(16, 0x101), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc0t", op_o16(16, 0x181), op_o16(0x3f, 0x3ff), "b", 1},
-
- {"tlbr", op_rs_func(16, 0x10, 1), ~0, "", 0},
- {"tlbwi", op_rs_func(16, 0x10, 2), ~0, "", 0},
- {"tlbwr", op_rs_func(16, 0x10, 6), ~0, "", 0},
- {"tlbp", op_rs_func(16, 0x10, 8), ~0, "", 0},
- {"rfe", op_rs_func(16, 0x10, 16), ~0, "", 0},
-
- {"mfc1", op_rs_b11 (17, 0, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0},
- {"cfc1", op_rs_b11 (17, 2, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0},
- {"mtc1", op_rs_b11 (17, 4, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0},
- {"ctc1", op_rs_b11 (17, 6, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0},
-
- {"bc1f", op_o16(17, 0x100), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc1f", op_o16(17, 0x180), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc1t", op_o16(17, 0x101), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc1t", op_o16(17, 0x181), op_o16(0x3f, 0x3ff), "b", 1},
-
-/* fpu instruction */
- {"add.s", op_rs_func(17, 0x10, 0),
- op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0},
- {"add.d", op_rs_func(17, 0x11, 0),
- op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0},
- {"sub.s", op_rs_func(17, 0x10, 1),
- op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0},
- {"sub.d", op_rs_func(17, 0x11, 1),
- op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0},
- {"mul.s", op_rs_func(17, 0x10, 2),
- op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0},
- {"mul.d", op_rs_func(17, 0x11, 2),
- op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0},
- {"div.s", op_rs_func(17, 0x10, 3),
- op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0},
- {"div.d", op_rs_func(17, 0x11, 3),
- op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0},
- {"abs.s", op_rs_func(17, 0x10, 5),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"abs.d", op_rs_func(17, 0x11, 5),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"mov.s", op_rs_func(17, 0x10, 6),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"mov.d", op_rs_func(17, 0x11, 6),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"neg.s", op_rs_func(17, 0x10, 7),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"neg.d", op_rs_func(17, 0x11, 7),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"cvt.s.s", op_rs_func(17, 0x10, 32),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"cvt.s.d", op_rs_func(17, 0x11, 32),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"cvt.s.w", op_rs_func(17, 0x14, 32),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"cvt.d.s", op_rs_func(17, 0x10, 33),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"cvt.d.d", op_rs_func(17, 0x11, 33),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"cvt.d.w", op_rs_func(17, 0x14, 33),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"cvt.w.s", op_rs_func(17, 0x10, 36),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"cvt.w.d", op_rs_func(17, 0x11, 36),
- op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0},
- {"c.f.s", op_rs_func(17, 0x10, 48),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.f.d", op_rs_func(17, 0x11, 48),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.un.s", op_rs_func(17, 0x10, 49),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.un.d", op_rs_func(17, 0x11, 49),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.eq.s", op_rs_func(17, 0x10, 50),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.eq.d", op_rs_func(17, 0x11, 50),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ueq.s", op_rs_func(17, 0x10, 51),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ueq.d", op_rs_func(17, 0x11, 51),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.olt.s", op_rs_func(17, 0x10, 52),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.olt.d", op_rs_func(17, 0x11, 52),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ult.s", op_rs_func(17, 0x10, 53),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ult.d", op_rs_func(17, 0x11, 53),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ole.s", op_rs_func(17, 0x10, 54),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ole.d", op_rs_func(17, 0x11, 54),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ule.s", op_rs_func(17, 0x10, 55),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ule.d", op_rs_func(17, 0x11, 55),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.sf.s", op_rs_func(17, 0x10, 56),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.sf.d", op_rs_func(17, 0x11, 56),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ngle.s", op_rs_func(17, 0x10, 57),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ngle.d", op_rs_func(17, 0x11, 57),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.seq.s", op_rs_func(17, 0x10, 58),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.seq.d", op_rs_func(17, 0x11, 58),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ngl.s", op_rs_func(17, 0x10, 59),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ngl.d", op_rs_func(17, 0x11, 59),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.lt.s", op_rs_func(17, 0x10, 60),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.lt.d", op_rs_func(17, 0x11, 60),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.nge.s", op_rs_func(17, 0x10, 61),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.nge.d", op_rs_func(17, 0x11, 61),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.le.s", op_rs_func(17, 0x10, 62),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.le.d", op_rs_func(17, 0x11, 62),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ngt.s", op_rs_func(17, 0x10, 63),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
- {"c.ngt.d", op_rs_func(17, 0x11, 63),
- op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0},
-
-/* co processor 2 instruction */
- {"mfc2", op_rs_b11 (18, 0, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"cfc2", op_rs_b11 (18, 2, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"mtc2", op_rs_b11 (18, 4, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"ctc2", op_rs_b11 (18, 6, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"bc2f", op_o16(18, 0x100), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc2f", op_o16(18, 0x180), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc2f", op_o16(18, 0x101), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc2t", op_o16(18, 0x181), op_o16(0x3f, 0x3ff), "b", 1},
-
-/* co processor 3 instruction */
- {"mtc3", op_rs_b11 (19, 0, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"cfc3", op_rs_b11 (19, 2, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"mtc3", op_rs_b11 (19, 4, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"ctc3", op_rs_b11 (19, 6, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0},
- {"bc3f", op_o16(19, 0x100), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc3f", op_o16(19, 0x180), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc3t", op_o16(19, 0x101), op_o16(0x3f, 0x3ff), "b", 1},
- {"bc3t", op_o16(19, 0x181), op_o16(0x3f, 0x3ff), "b", 1},
-
- {"lb", one(32), one(0x3f), "t,j(s)", 0},
- {"lh", one(33), one(0x3f), "t,j(s)", 0},
- {"lwl", one(34), one(0x3f), "t,j(s)", 0},
- {"lw", one(35), one(0x3f), "t,j(s)", 0},
- {"lbu", one(36), one(0x3f), "t,j(s)", 0},
- {"lhu", one(37), one(0x3f), "t,j(s)", 0},
- {"lwr", one(38), one(0x3f), "t,j(s)", 0},
- {"sb", one(40), one(0x3f), "t,j(s)", 0},
- {"sh", one(41), one(0x3f), "t,j(s)", 0},
- {"swl", one(42), one(0x3f), "t,j(s)", 0},
- {"swr", one(46), one(0x3f), "t,j(s)", 0},
- {"sw", one(43), one(0x3f), "t,j(s)", 0},
- {"lwc0", one(48), one(0x3f), "t,j(s)", 0},
-/* for fpu */
- {"lwc1", one(49), one(0x3f), "T,j(s)", 0},
- {"lwc2", one(50), one(0x3f), "t,j(s)", 0},
- {"lwc3", one(51), one(0x3f), "t,j(s)", 0},
- {"swc0", one(56), one(0x3f), "t,j(s)", 0},
-/* for fpu */
- {"swc1", one(57), one(0x3f), "T,j(s)", 0},
- {"swc2", one(58), one(0x3f), "t,j(s)", 0},
- {"swc3", one(59), one(0x3f), "t,j(s)", 0},
-};
diff --git a/gnu/usr.bin/as/opcode/np1.h b/gnu/usr.bin/as/opcode/np1.h
deleted file mode 100644
index 6546825..0000000
--- a/gnu/usr.bin/as/opcode/np1.h
+++ /dev/null
@@ -1,422 +0,0 @@
-/* Print GOULD NPL instructions for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-GDB is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GDB 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 GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-struct gld_opcode
-{
- char *name;
- unsigned long opcode;
- unsigned long mask;
- char *args;
- int length;
-};
-
-/* We store four bytes of opcode for all opcodes because that
- is the most any of them need. The actual length of an instruction
- is always at least 2 bytes, and at most four. The length of the
- instruction is based on the opcode.
-
- The mask component is a mask saying which bits must match
- particular opcode in order for an instruction to be an instance
- of that opcode.
-
- The args component is a string containing characters
- that are used to format the arguments to the instruction. */
-
-/* Kinds of operands:
- r Register in first field
- R Register in second field
- b Base register in first field
- B Base register in second field
- v Vector register in first field
- V Vector register in first field
- A Optional address register (base register)
- X Optional index register
- I Immediate data (16bits signed)
- O Offset field (16bits signed)
- h Offset field (15bits signed)
- d Offset field (14bits signed)
- S Shift count field
-
- any other characters are printed as is...
-*/
-
-/* The assembler requires that this array be sorted as follows:
- all instances of the same mnemonic must be consecutive.
- All instances of the same mnemonic with the same number of operands
- must be consecutive.
- */
-struct gld_opcode gld_opcodes[] =
-{
-{ "lb", 0xb4080000, 0xfc080000, "r,xOA,X", 4 },
-{ "lnb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 },
-{ "lbs", 0xec080000, 0xfc080000, "r,xOA,X", 4 },
-{ "lh", 0xb4000001, 0xfc080001, "r,xOA,X", 4 },
-{ "lnh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 },
-{ "lw", 0xb4000000, 0xfc080000, "r,xOA,X", 4 },
-{ "lnw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 },
-{ "ld", 0xb4000002, 0xfc080002, "r,xOA,X", 4 },
-{ "lnd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 },
-{ "li", 0xf8000000, 0xfc7f0000, "r,I", 4 },
-{ "lpa", 0x50080000, 0xfc080000, "r,xOA,X", 4 },
-{ "la", 0x50000000, 0xfc080000, "r,xOA,X", 4 },
-{ "labr", 0x58080000, 0xfc080000, "b,xOA,X", 4 },
-{ "lbp", 0x90080000, 0xfc080000, "r,xOA,X", 4 },
-{ "lhp", 0x90000001, 0xfc080001, "r,xOA,X", 4 },
-{ "lwp", 0x90000000, 0xfc080000, "r,xOA,X", 4 },
-{ "ldp", 0x90000002, 0xfc080002, "r,xOA,X", 4 },
-{ "suabr", 0x58000000, 0xfc080000, "b,xOA,X", 4 },
-{ "lf", 0xbc000000, 0xfc080000, "r,xOA,X", 4 },
-{ "lfbr", 0xbc080000, 0xfc080000, "b,xOA,X", 4 },
-{ "lwbr", 0x5c000000, 0xfc080000, "b,xOA,X", 4 },
-{ "stb", 0xd4080000, 0xfc080000, "r,xOA,X", 4 },
-{ "sth", 0xd4000001, 0xfc080001, "r,xOA,X", 4 },
-{ "stw", 0xd4000000, 0xfc080000, "r,xOA,X", 4 },
-{ "std", 0xd4000002, 0xfc080002, "r,xOA,X", 4 },
-{ "stf", 0xdc000000, 0xfc080000, "r,xOA,X", 4 },
-{ "stfbr", 0xdc080000, 0xfc080000, "b,xOA,X", 4 },
-{ "stwbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 },
-{ "zmb", 0xd8080000, 0xfc080000, "r,xOA,X", 4 },
-{ "zmh", 0xd8000001, 0xfc080001, "r,xOA,X", 4 },
-{ "zmw", 0xd8000000, 0xfc080000, "r,xOA,X", 4 },
-{ "zmd", 0xd8000002, 0xfc080002, "r,xOA,X", 4 },
-{ "stbp", 0x94080000, 0xfc080000, "r,xOA,X", 4 },
-{ "sthp", 0x94000001, 0xfc080001, "r,xOA,X", 4 },
-{ "stwp", 0x94000000, 0xfc080000, "r,xOA,X", 4 },
-{ "stdp", 0x94000002, 0xfc080002, "r,xOA,X", 4 },
-{ "lil", 0xf80b0000, 0xfc7f0000, "r,D", 4 },
-{ "lwsl1", 0xec000000, 0xfc080000, "r,xOA,X", 4 },
-{ "lwsl2", 0xfc000000, 0xfc080000, "r,xOA,X", 4 },
-{ "lwsl3", 0xfc080000, 0xfc080000, "r,xOA,X", 4 },
-
-{ "lvb", 0xb0080000, 0xfc080000, "v,xOA,X", 4 },
-{ "lvh", 0xb0000001, 0xfc080001, "v,xOA,X", 4 },
-{ "lvw", 0xb0000000, 0xfc080000, "v,xOA,X", 4 },
-{ "lvd", 0xb0000002, 0xfc080002, "v,xOA,X", 4 },
-{ "liv", 0x3c040000, 0xfc0f0000, "v,R", 2 },
-{ "livf", 0x3c080000, 0xfc0f0000, "v,R", 2 },
-{ "stvb", 0xd0080000, 0xfc080000, "v,xOA,X", 4 },
-{ "stvh", 0xd0000001, 0xfc080001, "v,xOA,X", 4 },
-{ "stvw", 0xd0000000, 0xfc080000, "v,xOA,X", 4 },
-{ "stvd", 0xd0000002, 0xfc080002, "v,xOA,X", 4 },
-
-{ "trr", 0x2c000000, 0xfc0f0000, "r,R", 2 },
-{ "trn", 0x2c040000, 0xfc0f0000, "r,R", 2 },
-{ "trnd", 0x2c0c0000, 0xfc0f0000, "r,R", 2 },
-{ "trabs", 0x2c010000, 0xfc0f0000, "r,R", 2 },
-{ "trabsd", 0x2c090000, 0xfc0f0000, "r,R", 2 },
-{ "trc", 0x2c030000, 0xfc0f0000, "r,R", 2 },
-{ "xcr", 0x28040000, 0xfc0f0000, "r,R", 2 },
-{ "cxcr", 0x2c060000, 0xfc0f0000, "r,R", 2 },
-{ "cxcrd", 0x2c0e0000, 0xfc0f0000, "r,R", 2 },
-{ "tbrr", 0x2c020000, 0xfc0f0000, "r,B", 2 },
-{ "trbr", 0x28030000, 0xfc0f0000, "b,R", 2 },
-{ "xcbr", 0x28020000, 0xfc0f0000, "b,B", 2 },
-{ "tbrbr", 0x28010000, 0xfc0f0000, "b,B", 2 },
-
-{ "trvv", 0x28050000, 0xfc0f0000, "v,V", 2 },
-{ "trvvn", 0x2c050000, 0xfc0f0000, "v,V", 2 },
-{ "trvvnd", 0x2c0d0000, 0xfc0f0000, "v,V", 2 },
-{ "trvab", 0x2c070000, 0xfc0f0000, "v,V", 2 },
-{ "trvabd", 0x2c0f0000, 0xfc0f0000, "v,V", 2 },
-{ "cmpv", 0x14060000, 0xfc0f0000, "v,V", 2 },
-{ "expv", 0x14070000, 0xfc0f0000, "v,V", 2 },
-{ "mrvvlt", 0x10030000, 0xfc0f0000, "v,V", 2 },
-{ "mrvvle", 0x10040000, 0xfc0f0000, "v,V", 2 },
-{ "mrvvgt", 0x14030000, 0xfc0f0000, "v,V", 2 },
-{ "mrvvge", 0x14040000, 0xfc0f0000, "v,V", 2 },
-{ "mrvveq", 0x10050000, 0xfc0f0000, "v,V", 2 },
-{ "mrvvne", 0x10050000, 0xfc0f0000, "v,V", 2 },
-{ "mrvrlt", 0x100d0000, 0xfc0f0000, "v,R", 2 },
-{ "mrvrle", 0x100e0000, 0xfc0f0000, "v,R", 2 },
-{ "mrvrgt", 0x140d0000, 0xfc0f0000, "v,R", 2 },
-{ "mrvrge", 0x140e0000, 0xfc0f0000, "v,R", 2 },
-{ "mrvreq", 0x100f0000, 0xfc0f0000, "v,R", 2 },
-{ "mrvrne", 0x140f0000, 0xfc0f0000, "v,R", 2 },
-{ "trvr", 0x140b0000, 0xfc0f0000, "r,V", 2 },
-{ "trrv", 0x140c0000, 0xfc0f0000, "v,R", 2 },
-
-{ "bu", 0x40000000, 0xff880000, "xOA,X", 4 },
-{ "bns", 0x70080000, 0xff880000, "xOA,X", 4 },
-{ "bnco", 0x70880000, 0xff880000, "xOA,X", 4 },
-{ "bge", 0x71080000, 0xff880000, "xOA,X", 4 },
-{ "bne", 0x71880000, 0xff880000, "xOA,X", 4 },
-{ "bunge", 0x72080000, 0xff880000, "xOA,X", 4 },
-{ "bunle", 0x72880000, 0xff880000, "xOA,X", 4 },
-{ "bgt", 0x73080000, 0xff880000, "xOA,X", 4 },
-{ "bnany", 0x73880000, 0xff880000, "xOA,X", 4 },
-{ "bs" , 0x70000000, 0xff880000, "xOA,X", 4 },
-{ "bco", 0x70800000, 0xff880000, "xOA,X", 4 },
-{ "blt", 0x71000000, 0xff880000, "xOA,X", 4 },
-{ "beq", 0x71800000, 0xff880000, "xOA,X", 4 },
-{ "buge", 0x72000000, 0xff880000, "xOA,X", 4 },
-{ "bult", 0x72800000, 0xff880000, "xOA,X", 4 },
-{ "ble", 0x73000000, 0xff880000, "xOA,X", 4 },
-{ "bany", 0x73800000, 0xff880000, "xOA,X", 4 },
-{ "brlnk", 0x44000000, 0xfc080000, "r,xOA,X", 4 },
-{ "bib", 0x48000000, 0xfc080000, "r,xOA,X", 4 },
-{ "bih", 0x48080000, 0xfc080000, "r,xOA,X", 4 },
-{ "biw", 0x4c000000, 0xfc080000, "r,xOA,X", 4 },
-{ "bid", 0x4c080000, 0xfc080000, "r,xOA,X", 4 },
-{ "bivb", 0x60000000, 0xfc080000, "r,xOA,X", 4 },
-{ "bivh", 0x60080000, 0xfc080000, "r,xOA,X", 4 },
-{ "bivw", 0x64000000, 0xfc080000, "r,xOA,X", 4 },
-{ "bivd", 0x64080000, 0xfc080000, "r,xOA,X", 4 },
-{ "bvsb", 0x68000000, 0xfc080000, "r,xOA,X", 4 },
-{ "bvsh", 0x68080000, 0xfc080000, "r,xOA,X", 4 },
-{ "bvsw", 0x6c000000, 0xfc080000, "r,xOA,X", 4 },
-{ "bvsd", 0x6c080000, 0xfc080000, "r,xOA,X", 4 },
-
-{ "camb", 0x80080000, 0xfc080000, "r,xOA,X", 4 },
-{ "camh", 0x80000001, 0xfc080001, "r,xOA,X", 4 },
-{ "camw", 0x80000000, 0xfc080000, "r,xOA,X", 4 },
-{ "camd", 0x80000002, 0xfc080002, "r,xOA,X", 4 },
-{ "car", 0x10000000, 0xfc0f0000, "r,R", 2 },
-{ "card", 0x14000000, 0xfc0f0000, "r,R", 2 },
-{ "ci", 0xf8050000, 0xfc7f0000, "r,I", 4 },
-{ "chkbnd", 0x5c080000, 0xfc080000, "r,xOA,X", 4 },
-
-{ "cavv", 0x10010000, 0xfc0f0000, "v,V", 2 },
-{ "cavr", 0x10020000, 0xfc0f0000, "v,R", 2 },
-{ "cavvd", 0x10090000, 0xfc0f0000, "v,V", 2 },
-{ "cavrd", 0x100b0000, 0xfc0f0000, "v,R", 2 },
-
-{ "anmb", 0x84080000, 0xfc080000, "r,xOA,X", 4 },
-{ "anmh", 0x84000001, 0xfc080001, "r,xOA,X", 4 },
-{ "anmw", 0x84000000, 0xfc080000, "r,xOA,X", 4 },
-{ "anmd", 0x84000002, 0xfc080002, "r,xOA,X", 4 },
-{ "anr", 0x04000000, 0xfc0f0000, "r,R", 2 },
-{ "ani", 0xf8080000, 0xfc7f0000, "r,I", 4 },
-{ "ormb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 },
-{ "ormh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 },
-{ "ormw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 },
-{ "ormd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 },
-{ "orr", 0x08000000, 0xfc0f0000, "r,R", 2 },
-{ "oi", 0xf8090000, 0xfc7f0000, "r,I", 4 },
-{ "eomb", 0x8c080000, 0xfc080000, "r,xOA,X", 4 },
-{ "eomh", 0x8c000001, 0xfc080001, "r,xOA,X", 4 },
-{ "eomw", 0x8c000000, 0xfc080000, "r,xOA,X", 4 },
-{ "eomd", 0x8c000002, 0xfc080002, "r,xOA,X", 4 },
-{ "eor", 0x0c000000, 0xfc0f0000, "r,R", 2 },
-{ "eoi", 0xf80a0000, 0xfc7f0000, "r,I", 4 },
-
-{ "anvv", 0x04010000, 0xfc0f0000, "v,V", 2 },
-{ "anvr", 0x04020000, 0xfc0f0000, "v,R", 2 },
-{ "orvv", 0x08010000, 0xfc0f0000, "v,V", 2 },
-{ "orvr", 0x08020000, 0xfc0f0000, "v,R", 2 },
-{ "eovv", 0x0c010000, 0xfc0f0000, "v,V", 2 },
-{ "eovr", 0x0c020000, 0xfc0f0000, "v,R", 2 },
-
-{ "sacz", 0x100c0000, 0xfc0f0000, "r,R", 2 },
-{ "sla", 0x1c400000, 0xfc600000, "r,S", 2 },
-{ "sll", 0x1c600000, 0xfc600000, "r,S", 2 },
-{ "slc", 0x24400000, 0xfc600000, "r,S", 2 },
-{ "slad", 0x20400000, 0xfc600000, "r,S", 2 },
-{ "slld", 0x20600000, 0xfc600000, "r,S", 2 },
-{ "sra", 0x1c000000, 0xfc600000, "r,S", 2 },
-{ "srl", 0x1c200000, 0xfc600000, "r,S", 2 },
-{ "src", 0x24000000, 0xfc600000, "r,S", 2 },
-{ "srad", 0x20000000, 0xfc600000, "r,S", 2 },
-{ "srld", 0x20200000, 0xfc600000, "r,S", 2 },
-{ "sda", 0x3c030000, 0xfc0f0000, "r,R", 2 },
-{ "sdl", 0x3c020000, 0xfc0f0000, "r,R", 2 },
-{ "sdc", 0x3c010000, 0xfc0f0000, "r,R", 2 },
-{ "sdad", 0x3c0b0000, 0xfc0f0000, "r,R", 2 },
-{ "sdld", 0x3c0a0000, 0xfc0f0000, "r,R", 2 },
-
-{ "svda", 0x3c070000, 0xfc0f0000, "v,R", 2 },
-{ "svdl", 0x3c060000, 0xfc0f0000, "v,R", 2 },
-{ "svdc", 0x3c050000, 0xfc0f0000, "v,R", 2 },
-{ "svdad", 0x3c0e0000, 0xfc0f0000, "v,R", 2 },
-{ "svdld", 0x3c0d0000, 0xfc0f0000, "v,R", 2 },
-
-{ "sbm", 0xac080000, 0xfc080000, "f,xOA,X", 4 },
-{ "zbm", 0xac000000, 0xfc080000, "f,xOA,X", 4 },
-{ "tbm", 0xa8080000, 0xfc080000, "f,xOA,X", 4 },
-{ "incmb", 0xa0000000, 0xfc080000, "xOA,X", 4 },
-{ "incmh", 0xa0080000, 0xfc080000, "xOA,X", 4 },
-{ "incmw", 0xa4000000, 0xfc080000, "xOA,X", 4 },
-{ "incmd", 0xa4080000, 0xfc080000, "xOA,X", 4 },
-{ "sbmd", 0x7c080000, 0xfc080000, "r,xOA,X", 4 },
-{ "zbmd", 0x7c000000, 0xfc080000, "r,xOA,X", 4 },
-{ "tbmd", 0x78080000, 0xfc080000, "r,xOA,X", 4 },
-
-{ "ssm", 0x9c080000, 0xfc080000, "f,xOA,X", 4 },
-{ "zsm", 0x9c000000, 0xfc080000, "f,xOA,X", 4 },
-{ "tsm", 0x98080000, 0xfc080000, "f,xOA,X", 4 },
-
-{ "admb", 0xc8080000, 0xfc080000, "r,xOA,X", 4 },
-{ "admh", 0xc8000001, 0xfc080001, "r,xOA,X", 4 },
-{ "admw", 0xc8000000, 0xfc080000, "r,xOA,X", 4 },
-{ "admd", 0xc8000002, 0xfc080002, "r,xOA,X", 4 },
-{ "adr", 0x38000000, 0xfc0f0000, "r,R", 2 },
-{ "armb", 0xe8080000, 0xfc080000, "r,xOA,X", 4 },
-{ "armh", 0xe8000001, 0xfc080001, "r,xOA,X", 4 },
-{ "armw", 0xe8000000, 0xfc080000, "r,xOA,X", 4 },
-{ "armd", 0xe8000002, 0xfc080002, "r,xOA,X", 4 },
-{ "adi", 0xf8010000, 0xfc0f0000, "r,I", 4 },
-{ "sumb", 0xcc080000, 0xfc080000, "r,xOA,X", 4 },
-{ "sumh", 0xcc000001, 0xfc080001, "r,xOA,X", 4 },
-{ "sumw", 0xcc000000, 0xfc080000, "r,xOA,X", 4 },
-{ "sumd", 0xcc000002, 0xfc080002, "r,xOA,X", 4 },
-{ "sur", 0x3c000000, 0xfc0f0000, "r,R", 2 },
-{ "sui", 0xf8020000, 0xfc0f0000, "r,I", 4 },
-{ "mpmb", 0xc0080000, 0xfc080000, "r,xOA,X", 4 },
-{ "mpmh", 0xc0000001, 0xfc080001, "r,xOA,X", 4 },
-{ "mpmw", 0xc0000000, 0xfc080000, "r,xOA,X", 4 },
-{ "mpr", 0x38020000, 0xfc0f0000, "r,R", 2 },
-{ "mprd", 0x3c0f0000, 0xfc0f0000, "r,R", 2 },
-{ "mpi", 0xf8030000, 0xfc0f0000, "r,I", 4 },
-{ "dvmb", 0xc4080000, 0xfc080000, "r,xOA,X", 4 },
-{ "dvmh", 0xc4000001, 0xfc080001, "r,xOA,X", 4 },
-{ "dvmw", 0xc4000000, 0xfc080000, "r,xOA,X", 4 },
-{ "dvr", 0x380a0000, 0xfc0f0000, "r,R", 2 },
-{ "dvi", 0xf8040000, 0xfc0f0000, "r,I", 4 },
-{ "exs", 0x38080000, 0xfc0f0000, "r,R", 2 },
-
-{ "advv", 0x30000000, 0xfc0f0000, "v,V", 2 },
-{ "advvd", 0x30080000, 0xfc0f0000, "v,V", 2 },
-{ "adrv", 0x34000000, 0xfc0f0000, "v,R", 2 },
-{ "adrvd", 0x34080000, 0xfc0f0000, "v,R", 2 },
-{ "suvv", 0x30010000, 0xfc0f0000, "v,V", 2 },
-{ "suvvd", 0x30090000, 0xfc0f0000, "v,V", 2 },
-{ "surv", 0x34010000, 0xfc0f0000, "v,R", 2 },
-{ "survd", 0x34090000, 0xfc0f0000, "v,R", 2 },
-{ "mpvv", 0x30020000, 0xfc0f0000, "v,V", 2 },
-{ "mprv", 0x34020000, 0xfc0f0000, "v,R", 2 },
-
-{ "adfw", 0xe0080000, 0xfc080000, "r,xOA,X", 4 },
-{ "adfd", 0xe0080002, 0xfc080002, "r,xOA,X", 4 },
-{ "adrfw", 0x38010000, 0xfc0f0000, "r,R", 2 },
-{ "adrfd", 0x38090000, 0xfc0f0000, "r,R", 2 },
-{ "surfw", 0xe0000000, 0xfc080000, "r,xOA,X", 4 },
-{ "surfd", 0xe0000002, 0xfc080002, "r,xOA,X", 4 },
-{ "surfw", 0x38030000, 0xfc0f0000, "r,R", 2 },
-{ "surfd", 0x380b0000, 0xfc0f0000, "r,R", 2 },
-{ "mpfw", 0xe4080000, 0xfc080000, "r,xOA,X", 4 },
-{ "mpfd", 0xe4080002, 0xfc080002, "r,xOA,X", 4 },
-{ "mprfw", 0x38060000, 0xfc0f0000, "r,R", 2 },
-{ "mprfd", 0x380e0000, 0xfc0f0000, "r,R", 2 },
-{ "rfw", 0xe4000000, 0xfc080000, "r,xOA,X", 4 },
-{ "rfd", 0xe4000002, 0xfc080002, "r,xOA,X", 4 },
-{ "rrfw", 0x0c0e0000, 0xfc0f0000, "r", 2 },
-{ "rrfd", 0x0c0f0000, 0xfc0f0000, "r", 2 },
-
-{ "advvfw", 0x30040000, 0xfc0f0000, "v,V", 2 },
-{ "advvfd", 0x300c0000, 0xfc0f0000, "v,V", 2 },
-{ "adrvfw", 0x34040000, 0xfc0f0000, "v,R", 2 },
-{ "adrvfd", 0x340c0000, 0xfc0f0000, "v,R", 2 },
-{ "suvvfw", 0x30050000, 0xfc0f0000, "v,V", 2 },
-{ "suvvfd", 0x300d0000, 0xfc0f0000, "v,V", 2 },
-{ "survfw", 0x34050000, 0xfc0f0000, "v,R", 2 },
-{ "survfd", 0x340d0000, 0xfc0f0000, "v,R", 2 },
-{ "mpvvfw", 0x30060000, 0xfc0f0000, "v,V", 2 },
-{ "mpvvfd", 0x300e0000, 0xfc0f0000, "v,V", 2 },
-{ "mprvfw", 0x34060000, 0xfc0f0000, "v,R", 2 },
-{ "mprvfd", 0x340e0000, 0xfc0f0000, "v,R", 2 },
-{ "rvfw", 0x30070000, 0xfc0f0000, "v", 2 },
-{ "rvfd", 0x300f0000, 0xfc0f0000, "v", 2 },
-
-{ "fltw", 0x38070000, 0xfc0f0000, "r,R", 2 },
-{ "fltd", 0x380f0000, 0xfc0f0000, "r,R", 2 },
-{ "fixw", 0x38050000, 0xfc0f0000, "r,R", 2 },
-{ "fixd", 0x380d0000, 0xfc0f0000, "r,R", 2 },
-{ "cfpds", 0x3c090000, 0xfc0f0000, "r,R", 2 },
-
-{ "fltvw", 0x080d0000, 0xfc0f0000, "v,V", 2 },
-{ "fltvd", 0x080f0000, 0xfc0f0000, "v,V", 2 },
-{ "fixvw", 0x080c0000, 0xfc0f0000, "v,V", 2 },
-{ "fixvd", 0x080e0000, 0xfc0f0000, "v,V", 2 },
-{ "cfpvds", 0x0c0d0000, 0xfc0f0000, "v,V", 2 },
-
-{ "orvrn", 0x000a0000, 0xfc0f0000, "r,V", 2 },
-{ "andvrn", 0x00080000, 0xfc0f0000, "r,V", 2 },
-{ "frsteq", 0x04090000, 0xfc0f0000, "r,V", 2 },
-{ "sigma", 0x0c080000, 0xfc0f0000, "r,V", 2 },
-{ "sigmad", 0x0c0a0000, 0xfc0f0000, "r,V", 2 },
-{ "sigmf", 0x08080000, 0xfc0f0000, "r,V", 2 },
-{ "sigmfd", 0x080a0000, 0xfc0f0000, "r,V", 2 },
-{ "prodf", 0x04080000, 0xfc0f0000, "r,V", 2 },
-{ "prodfd", 0x040a0000, 0xfc0f0000, "r,V", 2 },
-{ "maxv", 0x10080000, 0xfc0f0000, "r,V", 2 },
-{ "maxvd", 0x100a0000, 0xfc0f0000, "r,V", 2 },
-{ "minv", 0x14080000, 0xfc0f0000, "r,V", 2 },
-{ "minvd", 0x140a0000, 0xfc0f0000, "r,V", 2 },
-
-{ "lpsd", 0xf0000000, 0xfc080000, "xOA,X", 4 },
-{ "ldc", 0xf0080000, 0xfc080000, "xOA,X", 4 },
-{ "spm", 0x040c0000, 0xfc0f0000, "r", 2 },
-{ "rpm", 0x040d0000, 0xfc0f0000, "r", 2 },
-{ "tritr", 0x00070000, 0xfc0f0000, "r", 2 },
-{ "trrit", 0x00060000, 0xfc0f0000, "r", 2 },
-{ "rpswt", 0x04080000, 0xfc0f0000, "r", 2 },
-{ "exr", 0xf8070000, 0xfc0f0000, "", 4 },
-{ "halt", 0x00000000, 0xfc0f0000, "", 2 },
-{ "wait", 0x00010000, 0xfc0f0000, "", 2 },
-{ "nop", 0x00020000, 0xfc0f0000, "", 2 },
-{ "eiae", 0x00030000, 0xfc0f0000, "", 2 },
-{ "efae", 0x000d0000, 0xfc0f0000, "", 2 },
-{ "diae", 0x000e0000, 0xfc0f0000, "", 2 },
-{ "dfae", 0x000f0000, 0xfc0f0000, "", 2 },
-{ "spvc", 0xf8060000, 0xfc0f0000, "r,T,N", 4 },
-{ "rdsts", 0x00090000, 0xfc0f0000, "r", 2 },
-{ "setcpu", 0x000c0000, 0xfc0f0000, "r", 2 },
-{ "cmc", 0x000b0000, 0xfc0f0000, "r", 2 },
-{ "trrcu", 0x00040000, 0xfc0f0000, "r", 2 },
-{ "attnio", 0x00050000, 0xfc0f0000, "", 2 },
-{ "fudit", 0x28080000, 0xfc0f0000, "", 2 },
-{ "break", 0x28090000, 0xfc0f0000, "", 2 },
-{ "frzss", 0x280a0000, 0xfc0f0000, "", 2 },
-{ "ripi", 0x04040000, 0xfc0f0000, "r,R", 2 },
-{ "xcp", 0x04050000, 0xfc0f0000, "r", 2 },
-{ "block", 0x04060000, 0xfc0f0000, "", 2 },
-{ "unblock", 0x04070000, 0xfc0f0000, "", 2 },
-{ "trsc", 0x08060000, 0xfc0f0000, "r,R", 2 },
-{ "tscr", 0x08070000, 0xfc0f0000, "r,R", 2 },
-{ "fq", 0x04080000, 0xfc0f0000, "r", 2 },
-{ "flupte", 0x2c080000, 0xfc0f0000, "r", 2 },
-{ "rviu", 0x040f0000, 0xfc0f0000, "", 2 },
-{ "ldel", 0x280c0000, 0xfc0f0000, "r,R", 2 },
-{ "ldu", 0x280d0000, 0xfc0f0000, "r,R", 2 },
-{ "stdecc", 0x280b0000, 0xfc0f0000, "r,R", 2 },
-{ "trpc", 0x08040000, 0xfc0f0000, "r", 2 },
-{ "tpcr", 0x08050000, 0xfc0f0000, "r", 2 },
-{ "ghalt", 0x0c050000, 0xfc0f0000, "r", 2 },
-{ "grun", 0x0c040000, 0xfc0f0000, "", 2 },
-{ "tmpr", 0x2c0a0000, 0xfc0f0000, "r,R", 2 },
-{ "trmp", 0x2c0b0000, 0xfc0f0000, "r,R", 2 },
-
-{ "trrve", 0x28060000, 0xfc0f0000, "r", 2 },
-{ "trver", 0x28070000, 0xfc0f0000, "r", 2 },
-{ "trvlr", 0x280f0000, 0xfc0f0000, "r", 2 },
-
-{ "linkfl", 0x18000000, 0xfc0f0000, "r,R", 2 },
-{ "linkbl", 0x18020000, 0xfc0f0000, "r,R", 2 },
-{ "linkfp", 0x18010000, 0xfc0f0000, "r,R", 2 },
-{ "linkbp", 0x18030000, 0xfc0f0000, "r,R", 2 },
-{ "linkpl", 0x18040000, 0xfc0f0000, "r,R", 2 },
-{ "ulinkl", 0x18080000, 0xfc0f0000, "r,R", 2 },
-{ "ulinkp", 0x18090000, 0xfc0f0000, "r,R", 2 },
-{ "ulinktl", 0x180a0000, 0xfc0f0000, "r,R", 2 },
-{ "ulinktp", 0x180b0000, 0xfc0f0000, "r,R", 2 },
-};
-
-int numopcodes = sizeof(gld_opcodes) / sizeof(gld_opcodes[0]);
-
-struct gld_opcode *endop = gld_opcodes + sizeof(gld_opcodes) /
- sizeof(gld_opcodes[0]);
diff --git a/gnu/usr.bin/as/opcode/ns32k.h b/gnu/usr.bin/as/opcode/ns32k.h
deleted file mode 100644
index e513e64..0000000
--- a/gnu/usr.bin/as/opcode/ns32k.h
+++ /dev/null
@@ -1,491 +0,0 @@
-/* ns32k-opcode.h -- Opcode table for National Semi 32k processor
- Copyright (C) 1987 Free Software Foundation, Inc.
-
-This file is part of GAS, the GNU Assembler.
-
-GAS is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GAS 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 GAS; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
-#ifdef TE_SEQUENT
-#define DEF_MODEC 20
-#define DEF_MODEL 21
-#endif
-
-#ifndef DEF_MODEC
-#define DEF_MODEC 20
-#endif
-
-#ifndef DEF_MODEL
-#define DEF_MODEL 20
-#endif
-/*
- After deciding the instruction entry (via hash.c) the instruction parser
- will try to match the operands after the instruction to the required set
- given in the entry operandfield. Every operand will result in a change in
- the opcode or the addition of data to the opcode.
- The operands in the source instruction are checked for inconsistent
- semantics.
-
- F : 32 bit float general form
- L : 64 bit float "
- B : byte "
- W : word "
- D : double-word "
- Q : quad-word "
- A : double-word gen-address-form ie no regs allowed
- d : displacement
- b : displacement - pc relative addressing acb
- p : displacement - pc relative addressing br bcond bsr cxp
- q : quick
- i : immediate (8 bits)
- This is not a standard ns32k operandtype, it is used to build
- instructions like svc arg1,arg2
- Svc is the instruction SuperVisorCall and is sometimes used to
- call OS-routines from usermode. Some args might be handy!
- r : register number (3 bits)
- O : setcfg instruction optionslist
- C : cinv instruction optionslist
- S : stringinstruction optionslist
- U : registerlist save,enter
- u : registerlist restore,exit
- M : mmu register
- P : cpu register
- g : 3:rd operand of inss or exts instruction
- G : 4:th operand of inss or exts instruction
- Those operands are encoded in the same byte.
- This byte is placed last in the instruction.
- f : operand of sfsr
- H : sequent-hack for bsr (Warning)
-
-column 1 instructions
- 2 number of bits in opcode.
- 3 number of bits in opcode explicitly
- determined by the instruction type.
- 4 opcodeseed, the number we build our opcode
- from.
- 5 operandtypes, used by operandparser.
- 6 size in bytes of immediate
-*/
-struct ns32k_opcode {
- char *name;
- unsigned char opcode_id_size; /* not used by the assembler */
- unsigned char opcode_size;
- unsigned long opcode_seed;
- char *operands;
- unsigned char im_size; /* not used by dissassembler */
- char *default_args; /* default to those args when none given */
- char default_modec; /* default to this addr-mode when ambigous
- ie when the argument of a general addr-mode
- is a plain constant */
- char default_model; /* is a plain label */
-};
-
-#ifdef comment
-/* This section was from the gdb version of this file. */
-
-#ifndef ns32k_opcodeT
-#define ns32k_opcodeT int
-#endif /* no ns32k_opcodeT */
-
-struct not_wot /* ns32k opcode table: wot to do with this */
- /* particular opcode */
-{
- int obits; /* number of opcode bits */
- int ibits; /* number of instruction bits */
- ns32k_opcodeT code; /* op-code (may be > 8 bits!) */
- char *args; /* how to compile said opcode */
-};
-
-struct not /* ns32k opcode text */
-{
- char * name; /* opcode name: lowercase string [key] */
- struct not_wot detail; /* rest of opcode table [datum] */
-};
-
-/* Instructions look like this:
-
- basic instruction--1, 2, or 3 bytes
- index byte for operand A, if operand A is indexed--1 byte
- index byte for operand B, if operand B is indexed--1 byte
- addressing extension for operand A
- addressing extension for operand B
- implied operands
-
- Operand A is the operand listed first in the following opcode table.
- Operand B is the operand listed second in the following opcode table.
- All instructions have at most 2 general operands, so this is enough.
- The implied operands are associated with operands other than A and B.
-
- Each operand has a digit and a letter.
-
- The digit gives the position in the assembly language. The letter,
- one of the following, tells us what kind of operand it is. */
-
-/* F : 32 bit float
- * L : 64 bit float
- * B : byte
- * W : word
- * D : double-word
- * Q : quad-word
- * d : displacement
- * q : quick
- * i : immediate (8 bits)
- * r : register number (3 bits)
- * p : displacement - pc relative addressing
-*/
-
-
-#endif /* comment */
-
-static const struct ns32k_opcode ns32k_opcodes[]=
-{
- { "absf", 14,24, 0x35be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "absl", 14,24, 0x34be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "absb", 14,24, 0x304e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "absw", 14,24, 0x314e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "absd", 14,24, 0x334e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "acbb", 7,16, 0x4c, "2B1q3p", 1, "", DEF_MODEC,DEF_MODEL },
- { "acbw", 7,16, 0x4d, "2W1q3p", 2, "", DEF_MODEC,DEF_MODEL },
- { "acbd", 7,16, 0x4f, "2D1q3p", 4, "", DEF_MODEC,DEF_MODEL },
- { "addf", 14,24, 0x01be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "addl", 14,24, 0x00be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "addb", 6,16, 0x00, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "addw", 6,16, 0x01, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "addd", 6,16, 0x03, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "addcb", 6,16, 0x10, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "addcw", 6,16, 0x11, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "addcd", 6,16, 0x13, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "addpb", 14,24, 0x3c4e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "addpw", 14,24, 0x3d4e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "addpd", 14,24, 0x3f4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "addqb", 7,16, 0x0c, "2B1q", 1, "", DEF_MODEC,DEF_MODEL },
- { "addqw", 7,16, 0x0d, "2W1q", 2, "", DEF_MODEC,DEF_MODEL },
- { "addqd", 7,16, 0x0f, "2D1q", 4, "", DEF_MODEC,DEF_MODEL },
- { "addr", 6,16, 0x27, "1A2D", 4, "", 21,21 },
- { "adjspb", 11,16, 0x057c, "1B", 1, "", DEF_MODEC,DEF_MODEL },
- { "adjspw", 11,16, 0x057d, "1W", 2, "", DEF_MODEC,DEF_MODEL },
- { "adjspd", 11,16, 0x057f, "1D", 4, "", DEF_MODEC,DEF_MODEL },
- { "andb", 6,16, 0x28, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "andw", 6,16, 0x29, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "andd", 6,16, 0x2b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "ashb", 14,24, 0x044e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "ashw", 14,24, 0x054e, "1B2W", 1, "", DEF_MODEC,DEF_MODEL },
- { "ashd", 14,24, 0x074e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL },
- { "beq", 8,8, 0x0a, "1p", 0, "", 21,21 },
- { "bne", 8,8, 0x1a, "1p", 0, "", 21,21 },
- { "bcs", 8,8, 0x2a, "1p", 0, "", 21,21 },
- { "bcc", 8,8, 0x3a, "1p", 0, "", 21,21 },
- { "bhi", 8,8, 0x4a, "1p", 0, "", 21,21 },
- { "bls", 8,8, 0x5a, "1p", 0, "", 21,21 },
- { "bgt", 8,8, 0x6a, "1p", 0, "", 21,21 },
- { "ble", 8,8, 0x7a, "1p", 0, "", 21,21 },
- { "bfs", 8,8, 0x8a, "1p", 0, "", 21,21 },
- { "bfc", 8,8, 0x9a, "1p", 0, "", 21,21 },
- { "blo", 8,8, 0xaa, "1p", 0, "", 21,21 },
- { "bhs", 8,8, 0xba, "1p", 0, "", 21,21 },
- { "blt", 8,8, 0xca, "1p", 0, "", 21,21 },
- { "bge", 8,8, 0xda, "1p", 0, "", 21,21 },
- { "but", 8,8, 0xea, "1p", 0, "", 21,21 },
- { "buf", 8,8, 0xfa, "1p", 0, "", 21,21 },
- { "bicb", 6,16, 0x08, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "bicw", 6,16, 0x09, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "bicd", 6,16, 0x0b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "bicpsrb", 11,16, 0x17c, "1B", 1, "", DEF_MODEC,DEF_MODEL },
- { "bicpsrw", 11,16, 0x17d, "1W", 2, "", DEF_MODEC,DEF_MODEL },
- { "bispsrb", 11,16, 0x37c, "1B", 1, "", DEF_MODEC,DEF_MODEL },
- { "bispsrw", 11,16, 0x37d, "1W", 2, "", DEF_MODEC,DEF_MODEL },
- { "bpt", 8,8, 0xf2, "", 0, "", DEF_MODEC,DEF_MODEL },
- { "br", 8,8, 0xea, "1p", 0, "", 21,21 },
-#ifdef TE_SEQUENT
- { "bsr", 8,8, 0x02, "1H", 0, "", 21,21 },
-#else
- { "bsr", 8,8, 0x02, "1p", 0, "", 21,21 },
-#endif
- { "caseb", 11,16, 0x77c, "1B", 1, "", DEF_MODEC,DEF_MODEL },
- { "casew", 11,16, 0x77d, "1W", 2, "", DEF_MODEC,DEF_MODEL },
- { "cased", 11,16, 0x77f, "1D", 4, "", DEF_MODEC,DEF_MODEL },
- { "cbitb", 14,24, 0x084e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL },
- { "cbitw", 14,24, 0x094e, "1W2D", 2, "", DEF_MODEC,DEF_MODEL },
- { "cbitd", 14,24, 0x0b4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "cbitib", 14,24, 0x0c4e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL },
- { "cbitiw", 14,24, 0x0d4e, "1W2D", 2, "", DEF_MODEC,DEF_MODEL },
- { "cbitid", 14,24, 0x0f4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "checkb", 11,24, 0x0ee, "2A3B1r", 1, "", DEF_MODEC,DEF_MODEL },
- { "checkw", 11,24, 0x1ee, "2A3W1r", 2, "", DEF_MODEC,DEF_MODEL },
- { "checkd", 11,24, 0x3ee, "2A3D1r", 4, "", DEF_MODEC,DEF_MODEL },
- { "cinv", 14,24, 0x271e, "2D1C", 4, "", DEF_MODEC,DEF_MODEL },
- { "cmpf", 14,24, 0x09be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "cmpl", 14,24, 0x08be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "cmpb", 6,16, 0x04, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "cmpw", 6,16, 0x05, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "cmpd", 6,16, 0x07, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "cmpmb", 14,24, 0x04ce, "1A2A3b", 1, "", DEF_MODEC,DEF_MODEL },
- { "cmpmw", 14,24, 0x05ce, "1A2A3b", 2, "", DEF_MODEC,DEF_MODEL },
- { "cmpmd", 14,24, 0x07ce, "1A2A3b", 4, "", DEF_MODEC,DEF_MODEL },
- { "cmpqb", 7,16, 0x1c, "2B1q", 1, "", DEF_MODEC,DEF_MODEL },
- { "cmpqw", 7,16, 0x1d, "2W1q", 2, "", DEF_MODEC,DEF_MODEL },
- { "cmpqd", 7,16, 0x1f, "2D1q", 4, "", DEF_MODEC,DEF_MODEL },
- { "cmpsb", 16,24, 0x040e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "cmpsw", 16,24, 0x050e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "cmpsd", 16,24, 0x070e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "cmpst", 16,24, 0x840e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "comb", 14,24, 0x344e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "comw", 14,24, 0x354e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "comd", 14,24, 0x374e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "cvtp", 11,24, 0x036e, "2A3D1r", 4, "", DEF_MODEC,DEF_MODEL },
- { "cxp", 8,8, 0x22, "1p", 0, "", 21,21 },
- { "cxpd", 11,16, 0x07f, "1A", 4, "", DEF_MODEC,DEF_MODEL },
- { "deib", 14,24, 0x2cce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL },
- { "deiw", 14,24, 0x2dce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL },
- { "deid", 14,24, 0x2fce, "1D2Q", 4, "", DEF_MODEC,DEF_MODEL },
- { "dia", 8,8, 0xc2, "", 1, "", DEF_MODEC,DEF_MODEL },
- { "divf", 14,24, 0x21be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "divl", 14,24, 0x20be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "divb", 14,24, 0x3cce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "divw", 14,24, 0x3dce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "divd", 14,24, 0x3fce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "enter", 8,8, 0x82, "1U2d", 0, "", DEF_MODEC,DEF_MODEL },
- { "exit", 8,8, 0x92, "1u", 0, "", DEF_MODEC,DEF_MODEL },
- { "extb", 11,24, 0x02e, "2D3B1r4d", 1, "", DEF_MODEC,DEF_MODEL },
- { "extw", 11,24, 0x12e, "2D3W1r4d", 2, "", DEF_MODEC,DEF_MODEL },
- { "extd", 11,24, 0x32e, "2D3D1r4d", 4, "", DEF_MODEC,DEF_MODEL },
- { "extsb", 14,24, 0x0cce, "1D2B3g4G", 1, "", DEF_MODEC,DEF_MODEL },
- { "extsw", 14,24, 0x0dce, "1D2W3g4G", 2, "", DEF_MODEC,DEF_MODEL },
- { "extsd", 14,24, 0x0fce, "1D2D3g4G", 4, "", DEF_MODEC,DEF_MODEL },
- { "ffsb", 14,24, 0x046e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "ffsw", 14,24, 0x056e, "1W2B", 2, "", DEF_MODEC,DEF_MODEL },
- { "ffsd", 14,24, 0x076e, "1D2B", 4, "", DEF_MODEC,DEF_MODEL },
- { "flag", 8,8, 0xd2, "", 0, "", DEF_MODEC,DEF_MODEL },
- { "floorfb", 14,24, 0x3c3e, "1F2B", 4, "", DEF_MODEC,DEF_MODEL },
- { "floorfw", 14,24, 0x3d3e, "1F2W", 4, "", DEF_MODEC,DEF_MODEL },
- { "floorfd", 14,24, 0x3f3e, "1F2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "floorlb", 14,24, 0x383e, "1L2B", 8, "", DEF_MODEC,DEF_MODEL },
- { "floorlw", 14,24, 0x393e, "1L2W", 8, "", DEF_MODEC,DEF_MODEL },
- { "floorld", 14,24, 0x3b3e, "1L2D", 8, "", DEF_MODEC,DEF_MODEL },
- { "ibitb", 14,24, 0x384e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL },
- { "ibitw", 14,24, 0x394e, "1W2D", 2, "", DEF_MODEC,DEF_MODEL },
- { "ibitd", 14,24, 0x3b4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "indexb", 11,24, 0x42e, "2B3B1r", 1, "", DEF_MODEC,DEF_MODEL },
- { "indexw", 11,24, 0x52e, "2W3W1r", 2, "", DEF_MODEC,DEF_MODEL },
- { "indexd", 11,24, 0x72e, "2D3D1r", 4, "", DEF_MODEC,DEF_MODEL },
- { "insb", 11,24, 0x0ae, "2B3B1r4d", 1, "", DEF_MODEC,DEF_MODEL },
- { "insw", 11,24, 0x1ae, "2W3W1r4d", 2, "", DEF_MODEC,DEF_MODEL },
- { "insd", 11,24, 0x3ae, "2D3D1r4d", 4, "", DEF_MODEC,DEF_MODEL },
- { "inssb", 14,24, 0x08ce, "1B2D3g4G", 1, "", DEF_MODEC,DEF_MODEL },
- { "inssw", 14,24, 0x09ce, "1W2D3g4G", 2, "", DEF_MODEC,DEF_MODEL },
- { "inssd", 14,24, 0x0bce, "1D2D3g4G", 4, "", DEF_MODEC,DEF_MODEL },
- { "jsr", 11,16, 0x67f, "1A", 4, "", 21,21 },
- { "jump", 11,16, 0x27f, "1A", 4, "", 21,21 },
- { "lfsr", 19,24, 0x00f3e,"1D", 4, "", DEF_MODEC,DEF_MODEL },
- { "lmr", 15,24, 0x0b1e, "2D1M", 4, "", DEF_MODEC,DEF_MODEL },
- { "lprb", 7,16, 0x6c, "2B1P", 1, "", DEF_MODEC,DEF_MODEL },
- { "lprw", 7,16, 0x6d, "2W1P", 2, "", DEF_MODEC,DEF_MODEL },
- { "lprd", 7,16, 0x6f, "2D1P", 4, "", DEF_MODEC,DEF_MODEL },
- { "lshb", 14,24, 0x144e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "lshw", 14,24, 0x154e, "1B2W", 1, "", DEF_MODEC,DEF_MODEL },
- { "lshd", 14,24, 0x174e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL },
- { "meib", 14,24, 0x24ce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL },
- { "meiw", 14,24, 0x25ce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL },
- { "meid", 14,24, 0x27ce, "1D2Q", 4, "", DEF_MODEC,DEF_MODEL },
- { "modb", 14,24, 0x38ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "modw", 14,24, 0x39ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "modd", 14,24, 0x3bce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "movf", 14,24, 0x05be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "movl", 14,24, 0x04be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "movb", 6,16, 0x14, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "movw", 6,16, 0x15, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "movd", 6,16, 0x17, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "movbf", 14,24, 0x043e, "1B2F", 1, "", DEF_MODEC,DEF_MODEL },
- { "movwf", 14,24, 0x053e, "1W2F", 2, "", DEF_MODEC,DEF_MODEL },
- { "movdf", 14,24, 0x073e, "1D2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "movbl", 14,24, 0x003e, "1B2L", 1, "", DEF_MODEC,DEF_MODEL },
- { "movwl", 14,24, 0x013e, "1W2L", 2, "", DEF_MODEC,DEF_MODEL },
- { "movdl", 14,24, 0x033e, "1D2L", 4, "", DEF_MODEC,DEF_MODEL },
- { "movfl", 14,24, 0x1b3e, "1F2L", 4, "", DEF_MODEC,DEF_MODEL },
- { "movlf", 14,24, 0x163e, "1L2F", 8, "", DEF_MODEC,DEF_MODEL },
- { "movmb", 14,24, 0x00ce, "1A2A3b", 1, "", DEF_MODEC,DEF_MODEL },
- { "movmw", 14,24, 0x01ce, "1A2A3b", 2, "", DEF_MODEC,DEF_MODEL },
- { "movmd", 14,24, 0x03ce, "1A2A3b", 4, "", DEF_MODEC,DEF_MODEL },
- { "movqb", 7,16, 0x5c, "2B1q", 1, "", DEF_MODEC,DEF_MODEL },
- { "movqw", 7,16, 0x5d, "2B1q", 2, "", DEF_MODEC,DEF_MODEL },
- { "movqd", 7,16, 0x5f, "2B1q", 4, "", DEF_MODEC,DEF_MODEL },
- { "movsb", 16,24, 0x000e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "movsw", 16,24, 0x010e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "movsd", 16,24, 0x030e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "movst", 16,24, 0x800e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "movsub", 14,24, 0x0cae, "1A2A", 1, "", DEF_MODEC,DEF_MODEL },
- { "movsuw", 14,24, 0x0dae, "1A2A", 2, "", DEF_MODEC,DEF_MODEL },
- { "movsud", 14,24, 0x0fae, "1A2A", 4, "", DEF_MODEC,DEF_MODEL },
- { "movusb", 14,24, 0x1cae, "1A2A", 1, "", DEF_MODEC,DEF_MODEL },
- { "movusw", 14,24, 0x1dae, "1A2A", 2, "", DEF_MODEC,DEF_MODEL },
- { "movusd", 14,24, 0x1fae, "1A2A", 4, "", DEF_MODEC,DEF_MODEL },
- { "movxbd", 14,24, 0x1cce, "1B2D", 1, "", DEF_MODEC,DEF_MODEL },
- { "movxwd", 14,24, 0x1dce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL },
- { "movxbw", 14,24, 0x10ce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL },
- { "movzbd", 14,24, 0x18ce, "1B2D", 1, "", DEF_MODEC,DEF_MODEL },
- { "movzwd", 14,24, 0x19ce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL },
- { "movzbw", 14,24, 0x14ce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL },
- { "mulf", 14,24, 0x31be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "mull", 14,24, 0x30be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "mulb", 14,24, 0x20ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "mulw", 14,24, 0x21ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "muld", 14,24, 0x23ce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "negf", 14,24, 0x15be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "negl", 14,24, 0x14be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "negb", 14,24, 0x204e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "negw", 14,24, 0x214e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "negd", 14,24, 0x234e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "nop", 8,8, 0xa2, "", 0, "", DEF_MODEC,DEF_MODEL },
- { "notb", 14,24, 0x244e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "notw", 14,24, 0x254e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "notd", 14,24, 0x274e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "orb", 6,16, 0x18, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "orw", 6,16, 0x19, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "ord", 6,16, 0x1b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "quob", 14,24, 0x30ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "quow", 14,24, 0x31ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "quod", 14,24, 0x33ce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "rdval", 19,24, 0x0031e,"1A", 4, "", DEF_MODEC,DEF_MODEL },
- { "remb", 14,24, 0x34ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "remw", 14,24, 0x35ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "remd", 14,24, 0x37ce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "restore", 8,8, 0x72, "1u", 0, "", DEF_MODEC,DEF_MODEL },
- { "ret", 8,8, 0x12, "1d", 0, "", DEF_MODEC,DEF_MODEL },
- { "reti", 8,8, 0x52, "", 0, "", DEF_MODEC,DEF_MODEL },
- { "rett", 8,8, 0x42, "1d", 0, "", DEF_MODEC,DEF_MODEL },
- { "rotb", 14,24, 0x004e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "rotw", 14,24, 0x014e, "1B2W", 1, "", DEF_MODEC,DEF_MODEL },
- { "rotd", 14,24, 0x034e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL },
- { "roundfb", 14,24, 0x243e, "1F2B", 4, "", DEF_MODEC,DEF_MODEL },
- { "roundfw", 14,24, 0x253e, "1F2W", 4, "", DEF_MODEC,DEF_MODEL },
- { "roundfd", 14,24, 0x273e, "1F2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "roundlb", 14,24, 0x203e, "1L2B", 8, "", DEF_MODEC,DEF_MODEL },
- { "roundlw", 14,24, 0x213e, "1L2W", 8, "", DEF_MODEC,DEF_MODEL },
- { "roundld", 14,24, 0x233e, "1L2D", 8, "", DEF_MODEC,DEF_MODEL },
- { "rxp", 8,8, 0x32, "1d", 0, "", DEF_MODEC,DEF_MODEL },
- { "seqb", 11,16, 0x3c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "seqw", 11,16, 0x3d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "seqd", 11,16, 0x3f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "sneb", 11,16, 0xbc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "snew", 11,16, 0xbd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "sned", 11,16, 0xbf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "scsb", 11,16, 0x13c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "scsw", 11,16, 0x13d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "scsd", 11,16, 0x13f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "sccb", 11,16, 0x1bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "sccw", 11,16, 0x1bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "sccd", 11,16, 0x1bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "shib", 11,16, 0x23c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "shiw", 11,16, 0x23d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "shid", 11,16, 0x23f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "slsb", 11,16, 0x2bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "slsw", 11,16, 0x2bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "slsd", 11,16, 0x2bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "sgtb", 11,16, 0x33c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "sgtw", 11,16, 0x33d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "sgtd", 11,16, 0x33f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "sleb", 11,16, 0x3bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "slew", 11,16, 0x3bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "sled", 11,16, 0x3bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "sfsb", 11,16, 0x43c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "sfsw", 11,16, 0x43d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "sfsd", 11,16, 0x43f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "sfcb", 11,16, 0x4bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "sfcw", 11,16, 0x4bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "sfcd", 11,16, 0x4bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "slob", 11,16, 0x53c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "slow", 11,16, 0x53d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "slod", 11,16, 0x53f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "shsb", 11,16, 0x5bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "shsw", 11,16, 0x5bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "shsd", 11,16, 0x5bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "sltb", 11,16, 0x63c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "sltw", 11,16, 0x63d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "sltd", 11,16, 0x63f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "sgeb", 11,16, 0x6bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "sgew", 11,16, 0x6bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "sged", 11,16, 0x6bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "sutb", 11,16, 0x73c, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "sutw", 11,16, 0x73d, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "sutd", 11,16, 0x73f, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "sufb", 11,16, 0x7bc, "1B", 0, "", DEF_MODEC,DEF_MODEL },
- { "sufw", 11,16, 0x7bd, "1W", 0, "", DEF_MODEC,DEF_MODEL },
- { "sufd", 11,16, 0x7bf, "1D", 0, "", DEF_MODEC,DEF_MODEL },
- { "save", 8,8, 0x62, "1U", 0, "", DEF_MODEC,DEF_MODEL },
- { "sbitb", 14,24, 0x184e, "1B2A", 1, "", DEF_MODEC,DEF_MODEL },
- { "sbitw", 14,24, 0x194e, "1W2A", 2, "", DEF_MODEC,DEF_MODEL },
- { "sbitd", 14,24, 0x1b4e, "1D2A", 4, "", DEF_MODEC,DEF_MODEL },
- { "sbitib", 14,24, 0x1c4e, "1B2A", 1, "", DEF_MODEC,DEF_MODEL },
- { "sbitiw", 14,24, 0x1d4e, "1W2A", 2, "", DEF_MODEC,DEF_MODEL },
- { "sbitid", 14,24, 0x1f4e, "1D2A", 4, "", DEF_MODEC,DEF_MODEL },
- { "setcfg", 15,24, 0x0b0e, "1O", 0, "", DEF_MODEC,DEF_MODEL },
- { "sfsr", 14,24, 0x373e, "1f", 0, "", DEF_MODEC,DEF_MODEL },
- { "skpsb", 16,24, 0x0c0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "skpsw", 16,24, 0x0d0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "skpsd", 16,24, 0x0f0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "skpst", 16,24, 0x8c0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL },
- { "smr", 15,24, 0x0f1e, "2D1M", 4, "", DEF_MODEC,DEF_MODEL },
- { "sprb", 7,16, 0x2c, "2B1P", 1, "", DEF_MODEC,DEF_MODEL },
- { "sprw", 7,16, 0x2d, "2W1P", 2, "", DEF_MODEC,DEF_MODEL },
- { "sprd", 7,16, 0x2f, "2D1P", 4, "", DEF_MODEC,DEF_MODEL },
- { "subf", 14,24, 0x11be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "subl", 14,24, 0x10be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "subb", 6,16, 0x20, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "subw", 6,16, 0x21, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "subd", 6,16, 0x23, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "subcb", 6,16, 0x30, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "subcw", 6,16, 0x31, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "subcd", 6,16, 0x33, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "subpb", 14,24, 0x2c4e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "subpw", 14,24, 0x2d4e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "subpd", 14,24, 0x2f4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
-#ifdef NS32K_SVC_IMMED_OPERANDS
- { "svc", 8,8, 0xe2, "2i1i", 1, "", DEF_MODEC,DEF_MODEL }, /* not really, but unix uses it */
-#else
- { "svc", 8,8, 0xe2, "", 0, "", DEF_MODEC,DEF_MODEL },
-#endif
- { "tbitb", 6,16, 0x34, "1B2A", 1, "", DEF_MODEC,DEF_MODEL },
- { "tbitw", 6,16, 0x35, "1W2A", 2, "", DEF_MODEC,DEF_MODEL },
- { "tbitd", 6,16, 0x37, "1D2A", 4, "", DEF_MODEC,DEF_MODEL },
- { "truncfb", 14,24, 0x2c3e, "1F2B", 4, "", DEF_MODEC,DEF_MODEL },
- { "truncfw", 14,24, 0x2d3e, "1F2W", 4, "", DEF_MODEC,DEF_MODEL },
- { "truncfd", 14,24, 0x2f3e, "1F2D", 4, "", DEF_MODEC,DEF_MODEL },
- { "trunclb", 14,24, 0x283e, "1L2B", 8, "", DEF_MODEC,DEF_MODEL },
- { "trunclw", 14,24, 0x293e, "1L2W", 8, "", DEF_MODEC,DEF_MODEL },
- { "truncld", 14,24, 0x2b3e, "1L2D", 8, "", DEF_MODEC,DEF_MODEL },
- { "wait", 8,8, 0xb2, "", 0, "", DEF_MODEC,DEF_MODEL },
- { "wrval", 19,24, 0x0071e,"1A", 0, "", DEF_MODEC,DEF_MODEL },
- { "xorb", 6,16, 0x38, "1B2B", 1, "", DEF_MODEC,DEF_MODEL },
- { "xorw", 6,16, 0x39, "1W2W", 2, "", DEF_MODEC,DEF_MODEL },
- { "xord", 6,16, 0x3b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL },
-#if defined(NS32381) /* I'm not too sure of these */
- { "dotf", 14,24, 0x0dfe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "dotl", 14,24, 0x0cfe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "logbf", 14,24, 0x15fe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "logbl", 14,24, 0x14fe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "polyf", 14,24, 0x09fe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "polyl", 14,24, 0x08fe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
- { "scalbf", 14,24, 0x11fe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL },
- { "scalbl", 14,24, 0x10fe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL },
-#endif
-};
-
-static const int numopcodes=sizeof(ns32k_opcodes)/sizeof(ns32k_opcodes[0]);
-
-static const struct ns32k_opcode *endop = ns32k_opcodes+sizeof(ns32k_opcodes)/sizeof(ns32k_opcodes[0]);
-
-#define MAX_ARGS 4
-#define ARG_LEN 50
-
diff --git a/gnu/usr.bin/as/opcode/pn.h b/gnu/usr.bin/as/opcode/pn.h
deleted file mode 100644
index fde4764..0000000
--- a/gnu/usr.bin/as/opcode/pn.h
+++ /dev/null
@@ -1,282 +0,0 @@
-/* Print GOULD PN (PowerNode) instructions for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-GDB is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GDB 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 GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-struct gld_opcode
-{
- char *name;
- unsigned long opcode;
- unsigned long mask;
- char *args;
- int length;
-};
-
-/* We store four bytes of opcode for all opcodes because that
- is the most any of them need. The actual length of an instruction
- is always at least 2 bytes, and at most four. The length of the
- instruction is based on the opcode.
-
- The mask component is a mask saying which bits must match
- particular opcode in order for an instruction to be an instance
- of that opcode.
-
- The args component is a string containing characters
- that are used to format the arguments to the instruction. */
-
-/* Kinds of operands:
- r Register in first field
- R Register in second field
- b Base register in first field
- B Base register in second field
- v Vector register in first field
- V Vector register in first field
- A Optional address register (base register)
- X Optional index register
- I Immediate data (16bits signed)
- O Offset field (16bits signed)
- h Offset field (15bits signed)
- d Offset field (14bits signed)
- S Shift count field
-
- any other characters are printed as is...
-*/
-
-/* The assembler requires that this array be sorted as follows:
- all instances of the same mnemonic must be consecutive.
- All instances of the same mnemonic with the same number of operands
- must be consecutive.
- */
-struct gld_opcode gld_opcodes[] =
-{
-{ "abm", 0xa0080000, 0xfc080000, "f,xOA,X", 4 },
-{ "abr", 0x18080000, 0xfc0c0000, "r,f", 2 },
-{ "aci", 0xfc770000, 0xfc7f8000, "r,I", 4 },
-{ "adfd", 0xe0080002, 0xfc080002, "r,xOA,X", 4 },
-{ "adfw", 0xe0080000, 0xfc080000, "r,xOA,X", 4 },
-{ "adi", 0xc8010000, 0xfc7f0000, "r,I", 4 },
-{ "admb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 },
-{ "admd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 },
-{ "admh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 },
-{ "admw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 },
-{ "adr", 0x38000000, 0xfc0f0000, "r,R", 2 },
-{ "adrfd", 0x38090000, 0xfc0f0000, "r,R", 2 },
-{ "adrfw", 0x38010000, 0xfc0f0000, "r,R", 2 },
-{ "adrm", 0x38080000, 0xfc0f0000, "r,R", 2 },
-{ "ai", 0xfc030000, 0xfc07ffff, "I", 4 },
-{ "anmb", 0x84080000, 0xfc080000, "r,xOA,X", 4 },
-{ "anmd", 0x84000002, 0xfc080002, "r,xOA,X", 4 },
-{ "anmh", 0x84000001, 0xfc080001, "r,xOA,X", 4 },
-{ "anmw", 0x84000000, 0xfc080000, "r,xOA,X", 4 },
-{ "anr", 0x04000000, 0xfc0f0000, "r,R", 2 },
-{ "armb", 0xe8080000, 0xfc080000, "r,xOA,X", 4 },
-{ "armd", 0xe8000002, 0xfc080002, "r,xOA,X", 4 },
-{ "armh", 0xe8000001, 0xfc080001, "r,xOA,X", 4 },
-{ "armw", 0xe8000000, 0xfc080000, "r,xOA,X", 4 },
-{ "bcf", 0xf0000000, 0xfc080000, "I,xOA,X", 4 },
-{ "bct", 0xec000000, 0xfc080000, "I,xOA,X", 4 },
-{ "bei", 0x00060000, 0xffff0000, "", 2 },
-{ "bft", 0xf0000000, 0xff880000, "xOA,X", 4 },
-{ "bib", 0xf4000000, 0xfc780000, "r,xOA", 4 },
-{ "bid", 0xf4600000, 0xfc780000, "r,xOA", 4 },
-{ "bih", 0xf4200000, 0xfc780000, "r,xOA", 4 },
-{ "biw", 0xf4400000, 0xfc780000, "r,xOA", 4 },
-{ "bl", 0xf8800000, 0xff880000, "xOA,X", 4 },
-{ "bsub", 0x5c080000, 0xff8f0000, "", 2 },
-{ "bsubm", 0x28080000, 0xfc080000, "", 4 },
-{ "bu", 0xec000000, 0xff880000, "xOA,X", 4 },
-{ "call", 0x28080000, 0xfc0f0000, "", 2 },
-{ "callm", 0x5c080000, 0xff880000, "", 4 },
-{ "camb", 0x90080000, 0xfc080000, "r,xOA,X", 4 },
-{ "camd", 0x90000002, 0xfc080002, "r,xOA,X", 4 },
-{ "camh", 0x90000001, 0xfc080001, "r,xOA,X", 4 },
-{ "camw", 0x90000000, 0xfc080000, "r.xOA,X", 4 },
-{ "car", 0x10000000, 0xfc0f0000, "r,R", 2 },
-{ "cd", 0xfc060000, 0xfc070000, "r,f", 4 },
-{ "cea", 0x000f0000, 0xffff0000, "", 2 },
-{ "ci", 0xc8050000, 0xfc7f0000, "r,I", 4 },
-{ "cmc", 0x040a0000, 0xfc7f0000, "r", 2 },
-{ "cmmb", 0x94080000, 0xfc080000, "r,xOA,X", 4 },
-{ "cmmd", 0x94000002, 0xfc080002, "r,xOA,X", 4 },
-{ "cmmh", 0x94000001, 0xfc080001, "r,xOA,X", 4 },
-{ "cmmw", 0x94000000, 0xfc080000, "r,xOA,X", 4 },
-{ "cmr", 0x14000000, 0xfc0f0000, "r,R", 2 },
-{ "daci", 0xfc7f0000, 0xfc7f8000, "r,I", 4 },
-{ "dae", 0x000e0000, 0xffff0000, "", 2 },
-{ "dai", 0xfc040000, 0xfc07ffff, "I", 4 },
-{ "dci", 0xfc6f0000, 0xfc7f8000, "r,I", 4 },
-{ "di", 0xfc010000, 0xfc07ffff, "I", 4 },
-{ "dvfd", 0xe4000002, 0xfc080002, "r,xOA,X", 4 },
-{ "dvfw", 0xe4000000, 0xfc080000, "r,xOA,X", 4 },
-{ "dvi", 0xc8040000, 0xfc7f0000, "r,I", 4 },
-{ "dvmb", 0xc4080000, 0xfc080000, "r,xOA,X", 4 },
-{ "dvmh", 0xc4000001, 0xfc080001, "r,xOA,X", 4 },
-{ "dvmw", 0xc4000000, 0xfc080000, "r,xOA,X", 4 },
-{ "dvr", 0x380a0000, 0xfc0f0000, "r,R", 2 },
-{ "dvrfd", 0x380c0000, 0xfc0f0000, "r,R", 4 },
-{ "dvrfw", 0x38040000, 0xfc0f0000, "r,xOA,X", 4 },
-{ "eae", 0x00080000, 0xffff0000, "", 2 },
-{ "eci", 0xfc670000, 0xfc7f8080, "r,I", 4 },
-{ "ecwcs", 0xfc4f0000, 0xfc7f8000, "", 4 },
-{ "ei", 0xfc000000, 0xfc07ffff, "I", 4 },
-{ "eomb", 0x8c080000, 0xfc080000, "r,xOA,X", 4 },
-{ "eomd", 0x8c000002, 0xfc080002, "r,xOA,X", 4 },
-{ "eomh", 0x8c000001, 0xfc080001, "r,xOA,X", 4 },
-{ "eomw", 0x8c000000, 0xfc080000, "r,xOA,X", 4 },
-{ "eor", 0x0c000000, 0xfc0f0000, "r,R", 2 },
-{ "eorm", 0x0c080000, 0xfc0f0000, "r,R", 2 },
-{ "es", 0x00040000, 0xfc7f0000, "r", 2 },
-{ "exm", 0xa8000000, 0xff880000, "xOA,X", 4 },
-{ "exr", 0xc8070000, 0xfc7f0000, "r", 2 },
-{ "exrr", 0xc8070002, 0xfc7f0002, "r", 2 },
-{ "fixd", 0x380d0000, 0xfc0f0000, "r,R", 2 },
-{ "fixw", 0x38050000, 0xfc0f0000, "r,R", 2 },
-{ "fltd", 0x380f0000, 0xfc0f0000, "r,R", 2 },
-{ "fltw", 0x38070000, 0xfc0f0000, "r,R", 2 },
-{ "grio", 0xfc3f0000, 0xfc7f8000, "r,I", 4 },
-{ "halt", 0x00000000, 0xffff0000, "", 2 },
-{ "hio", 0xfc370000, 0xfc7f8000, "r,I", 4 },
-{ "jwcs", 0xfa080000, 0xff880000, "xOA,X", 4 },
-{ "la", 0x50000000, 0xfc000000, "r,xOA,X", 4 },
-{ "labr", 0x58080000, 0xfc080000, "b,xOA,X", 4 },
-{ "lb", 0xac080000, 0xfc080000, "r,xOA,X", 4 },
-{ "lcs", 0x00030000, 0xfc7f0000, "r", 2 },
-{ "ld", 0xac000002, 0xfc080002, "r,xOA,X", 4 },
-{ "lear", 0x80000000, 0xfc080000, "r,xOA,X", 4 },
-{ "lf", 0xcc000000, 0xfc080000, "r,xOA,X", 4 },
-{ "lfbr", 0xcc080000, 0xfc080000, "b,xOA,X", 4 },
-{ "lh", 0xac000001, 0xfc080001, "r,xOA,X", 4 },
-{ "li", 0xc8000000, 0xfc7f0000, "r,I", 4 },
-{ "lmap", 0x2c070000, 0xfc7f0000, "r", 2 },
-{ "lmb", 0xb0080000, 0xfc080000, "r,xOA,X", 4 },
-{ "lmd", 0xb0000002, 0xfc080002, "r,xOA,X", 4 },
-{ "lmh", 0xb0000001, 0xfc080001, "r,xOA,X", 4 },
-{ "lmw", 0xb0000000, 0xfc080000, "r,xOA,X", 4 },
-{ "lnb", 0xb4080000, 0xfc080000, "r,xOA,X", 4 },
-{ "lnd", 0xb4000002, 0xfc080002, "r,xOA,X", 4 },
-{ "lnh", 0xb4000001, 0xfc080001, "r,xOA,X", 4 },
-{ "lnw", 0xb4000000, 0xfc080000, "r,xOA,X", 4 },
-{ "lpsd", 0xf9800000, 0xff880000, "r,xOA,X", 4 },
-{ "lpsdcm", 0xfa800000, 0xff880000, "r,xOA,X", 4 },
-{ "lw", 0xac000000, 0xfc080000, "r,xOA,X", 4 },
-{ "lwbr", 0x5c000000, 0xfc080000, "b,xOA,X", 4 },
-{ "mpfd", 0xe4080002, 0xfc080002, "r,xOA,X", 4 },
-{ "mpfw", 0xe4080000, 0xfc080000, "r,xOA,X", 4 },
-{ "mpi", 0xc8030000, 0xfc7f0000, "r,I", 4 },
-{ "mpmb", 0xc0080000, 0xfc080000, "r,xOA,X", 4 },
-{ "mpmh", 0xc0000001, 0xfc080001, "r,xOA,X", 4 },
-{ "mpmw", 0xc0000000, 0xfc080000, "r,xOA,X", 4 },
-{ "mpr", 0x38020000, 0xfc0f0000, "r,R", 2 },
-{ "mprfd", 0x380e0000, 0xfc0f0000, "r,R", 2 },
-{ "mprfw", 0x38060000, 0xfc0f0000, "r,R", 2 },
-{ "nop", 0x00020000, 0xffff0000, "", 2 },
-{ "ormb", 0x88080000, 0xfc080000, "r,xOA,X", 4 },
-{ "ormd", 0x88000002, 0xfc080002, "r,xOA,X", 4 },
-{ "ormh", 0x88000001, 0xfc080001, "r,xOA,X", 4 },
-{ "ormw", 0x88000000, 0xfc080000, "r,xOA,X", 4 },
-{ "orr", 0x08000000, 0xfc0f0000, "r,R", 2 },
-{ "orrm", 0x08080000, 0xfc0f0000, "r,R", 2 },
-{ "rdsts", 0x00090000, 0xfc7f0000, "r", 2 },
-{ "return", 0x280e0000, 0xfc7f0000, "", 2 },
-{ "ri", 0xfc020000, 0xfc07ffff, "I", 4 },
-{ "rnd", 0x00050000, 0xfc7f0000, "r", 2 },
-{ "rpswt", 0x040b0000, 0xfc7f0000, "r", 2 },
-{ "rschnl", 0xfc2f0000, 0xfc7f8000, "r,I", 4 },
-{ "rsctl", 0xfc470000, 0xfc7f8000, "r,I", 4 },
-{ "rwcs", 0x000b0000, 0xfc0f0000, "r,R", 2 },
-{ "sacz", 0x10080000, 0xfc0f0000, "r,R", 2 },
-{ "sbm", 0x98080000, 0xfc080000, "f,xOA,X", 4 },
-{ "sbr", 0x18000000, 0xfc0c0000, "r,f", 4 },
-{ "sea", 0x000d0000, 0xffff0000, "", 2 },
-{ "setcpu", 0x2c090000, 0xfc7f0000, "r", 2 },
-{ "sio", 0xfc170000, 0xfc7f8000, "r,I", 4 },
-{ "sipu", 0x000a0000, 0xffff0000, "", 2 },
-{ "sla", 0x1c400000, 0xfc600000, "r,S", 2 },
-{ "slad", 0x20400000, 0xfc600000, "r,S", 2 },
-{ "slc", 0x24400000, 0xfc600000, "r,S", 2 },
-{ "sll", 0x1c600000, 0xfc600000, "r,S", 2 },
-{ "slld", 0x20600000, 0xfc600000, "r,S", 2 },
-{ "smc", 0x04070000, 0xfc070000, "", 2 },
-{ "sra", 0x1c000000, 0xfc600000, "r,S", 2 },
-{ "srad", 0x20000000, 0xfc600000, "r,S", 2 },
-{ "src", 0x24000000, 0xfc600000, "r,S", 2 },
-{ "srl", 0x1c200000, 0xfc600000, "r,S", 2 },
-{ "srld", 0x20200000, 0xfc600000, "r,S", 2 },
-{ "stb", 0xd4080000, 0xfc080000, "r,xOA,X", 4 },
-{ "std", 0xd4000002, 0xfc080002, "r,xOA,X", 4 },
-{ "stf", 0xdc000000, 0xfc080000, "r,xOA,X", 4 },
-{ "stfbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 },
-{ "sth", 0xd4000001, 0xfc080001, "r,xOA,X", 4 },
-{ "stmb", 0xd8080000, 0xfc080000, "r,xOA,X", 4 },
-{ "stmd", 0xd8000002, 0xfc080002, "r,xOA,X", 4 },
-{ "stmh", 0xd8000001, 0xfc080001, "r,xOA,X", 4 },
-{ "stmw", 0xd8000000, 0xfc080000, "r,xOA,X", 4 },
-{ "stpio", 0xfc270000, 0xfc7f8000, "r,I", 4 },
-{ "stw", 0xd4000000, 0xfc080000, "r,xOA,X", 4 },
-{ "stwbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 },
-{ "suabr", 0x58000000, 0xfc080000, "b,xOA,X", 4 },
-{ "sufd", 0xe0000002, 0xfc080002, "r,xOA,X", 4 },
-{ "sufw", 0xe0000000, 0xfc080000, "r,xOA,X", 4 },
-{ "sui", 0xc8020000, 0xfc7f0000, "r,I", 4 },
-{ "sumb", 0xbc080000, 0xfc080000, "r,xOA,X", 4 },
-{ "sumd", 0xbc000002, 0xfc080002, "r,xOA,X", 4 },
-{ "sumh", 0xbc000001, 0xfc080001, "r,xOA,X", 4 },
-{ "sumw", 0xbc000000, 0xfc080000, "r,xOA,X", 4 },
-{ "sur", 0x3c000000, 0xfc0f0000, "r,R", 2 },
-{ "surfd", 0x380b0000, 0xfc0f0000, "r,xOA,X", 4 },
-{ "surfw", 0x38030000, 0xfc0f0000, "r,R", 2 },
-{ "surm", 0x3c080000, 0xfc0f0000, "r,R", 2 },
-{ "svc", 0xc8060000, 0xffff0000, "", 4 },
-{ "tbm", 0xa4080000, 0xfc080000, "f,xOA,X", 4 },
-{ "tbr", 0x180c0000, 0xfc0c0000, "r,f", 2 },
-{ "tbrr", 0x2c020000, 0xfc0f0000, "r,B", 2 },
-{ "tccr", 0x28040000, 0xfc7f0000, "", 2 },
-{ "td", 0xfc050000, 0xfc070000, "r,f", 4 },
-{ "tio", 0xfc1f0000, 0xfc7f8000, "r,I", 4 },
-{ "tmapr", 0x2c0a0000, 0xfc0f0000, "r,R", 2 },
-{ "tpcbr", 0x280c0000, 0xfc7f0000, "r", 2 },
-{ "trbr", 0x2c010000, 0xfc0f0000, "b,R", 2 },
-{ "trc", 0x2c030000, 0xfc0f0000, "r,R", 2 },
-{ "trcc", 0x28050000, 0xfc7f0000, "", 2 },
-{ "trcm", 0x2c0b0000, 0xfc0f0000, "r,R", 2 },
-{ "trn", 0x2c040000, 0xfc0f0000, "r,R", 2 },
-{ "trnm", 0x2c0c0000, 0xfc0f0000, "r,R", 2 },
-{ "trr", 0x2c000000, 0xfc0f0000, "r,R", 2 },
-{ "trrm", 0x2c080000, 0xfc0f0000, "r,R", 2 },
-{ "trsc", 0x2c0e0000, 0xfc0f0000, "r,R", 2 },
-{ "trsw", 0x28000000, 0xfc7f0000, "r", 2 },
-{ "tscr", 0x2c0f0000, 0xfc0f0000, "r,R", 2 },
-{ "uei", 0x00070000, 0xffff0000, "", 2 },
-{ "wait", 0x00010000, 0xffff0000, "", 2 },
-{ "wcwcs", 0xfc5f0000, 0xfc7f8000, "", 4 },
-{ "wwcs", 0x000c0000, 0xfc0f0000, "r,R", 2 },
-{ "xcbr", 0x28020000, 0xfc0f0000, "b,B", 2 },
-{ "xcr", 0x2c050000, 0xfc0f0000, "r,R", 2 },
-{ "xcrm", 0x2c0d0000, 0xfc0f0000, "r,R", 2 },
-{ "zbm", 0x9c080000, 0xfc080000, "f,xOA,X", 4 },
-{ "zbr", 0x18040000, 0xfc0c0000, "r,f", 2 },
-{ "zmb", 0xf8080000, 0xfc080000, "r,xOA,X", 4 },
-{ "zmd", 0xf8000002, 0xfc080002, "r,xOA,X", 4 },
-{ "zmh", 0xf8000001, 0xfc080001, "r,xOA,X", 4 },
-{ "zmw", 0xf8000000, 0xfc080000, "r,xOA,X", 4 },
-{ "zr", 0x0c000000, 0xfc0f0000, "r", 2 },
-};
-
-int numopcodes = sizeof(gld_opcodes) / sizeof(gld_opcodes[0]);
-
-struct gld_opcode *endop = gld_opcodes + sizeof(gld_opcodes) /
- sizeof(gld_opcodes[0]);
diff --git a/gnu/usr.bin/as/opcode/pyr.h b/gnu/usr.bin/as/opcode/pyr.h
deleted file mode 100644
index ea5d84a..0000000
--- a/gnu/usr.bin/as/opcode/pyr.h
+++ /dev/null
@@ -1,287 +0,0 @@
-/* pyramid.opcode.h -- gdb initial attempt. */
-
-/* pyramid opcode table: wot to do with this
- particular opcode */
-
-struct pyr_datum
-{
- char nargs;
- char * args; /* how to compile said opcode */
- unsigned long mask; /* Bit vector: which operand modes are valid
- for this opcode */
- unsigned char code; /* op-code (always 6(?) bits */
-};
-
-typedef struct pyr_insn_format {
- unsigned int mode :4;
- unsigned int operator :8;
- unsigned int index_scale :2;
- unsigned int index_reg :6;
- unsigned int operand_1 :6;
- unsigned int operand_2:6;
-} pyr_insn_format;
-
-
-/* We store four bytes of opcode for all opcodes.
- Pyramid is sufficiently RISCy that:
- - insns are always an integral number of words;
- - the length of any insn can be told from the first word of
- the insn. (ie, if there are zero, one, or two words of
- immediate operand/offset).
-
-
- The args component is a string containing two characters for each
- operand of the instruction. The first specifies the kind of operand;
- the second, the place it is stored. */
-
-/* Kinds of operands:
- mask assembler syntax description
- 0x0001: movw Rn,Rn register to register
- 0x0002: movw K,Rn quick immediate to register
- 0x0004: movw I,Rn long immediate to register
- 0x0008: movw (Rn),Rn register indirect to register
- movw (Rn)[x],Rn register indirect to register
- 0x0010: movw I(Rn),Rn offset register indirect to register
- movw I(Rn)[x],Rn offset register indirect, indexed, to register
-
- 0x0020: movw Rn,(Rn) register to register indirect
- 0x0040: movw K,(Rn) quick immediate to register indirect
- 0x0080: movw I,(Rn) long immediate to register indirect
- 0x0100: movw (Rn),(Rn) register indirect to-register indirect
- 0x0100: movw (Rn),(Rn) register indirect to-register indirect
- 0x0200: movw I(Rn),(Rn) register indirect+offset to register indirect
- 0x0200: movw I(Rn),(Rn) register indirect+offset to register indirect
-
- 0x0400: movw Rn,I(Rn) register to register indirect+offset
- 0x0800: movw K,I(Rn) quick immediate to register indirect+offset
- 0x1000: movw I,I(Rn) long immediate to register indirect+offset
- 0x1000: movw (Rn),I(Rn) register indirect to-register indirect+offset
- 0x1000: movw I(Rn),I(Rn) register indirect+offset to register indirect
- +offset
- 0x0000: (irregular) ???
-
-
- Each insn has a four-bit field encoding the type(s) of its operands.
-*/
-
-/* Some common combinations
- */
-
-/* the first 5,(0x1|0x2|0x4|0x8|0x10) ie (1|2|4|8|16), ie ( 32 -1)*/
-#define GEN_TO_REG (31)
-
-#define UNKNOWN ((unsigned long)-1)
-#define ANY (GEN_TO_REG | (GEN_TO_REG << 5) | (GEN_TO_REG << 15))
-
-#define CONVERT (1|8|0x10|0x20|0x200)
-
-#define K_TO_REG (2)
-#define I_TO_REG (4)
-#define NOTK_TO_REG (GEN_TO_REG & ~K_TO_REG)
-#define NOTI_TO_REG (GEN_TO_REG & ~I_TO_REG)
-
-/* The assembler requires that this array be sorted as follows:
- all instances of the same mnemonic must be consecutive.
- All instances of the same mnemonic with the same number of operands
- must be consecutive.
- */
-
-struct pyr_opcode /* pyr opcode text */
-{
- char * name; /* opcode name: lowercase string [key] */
- struct pyr_datum datum; /* rest of opcode table [datum] */
-};
-
-#define pyr_how args
-#define pyr_nargs nargs
-#define pyr_mask mask
-#define pyr_name name
-
-struct pyr_opcode pyr_opcodes[] =
-{
- {"movb", { 2, "", UNKNOWN, 0x11}, },
- {"movh", { 2, "", UNKNOWN, 0x12} },
- {"movw", { 2, "", ANY, 0x10} },
- {"movl", { 2, "", ANY, 0x13} },
- {"mnegw", { 2, "", (0x1|0x8|0x10), 0x14} },
- {"mnegf", { 2, "", 0x1, 0x15} },
- {"mnegd", { 2, "", 0x1, 0x16} },
- {"mcomw", { 2, "", (0x1|0x8|0x10), 0x17} },
- {"mabsw", { 2, "", (0x1|0x8|0x10), 0x18} },
- {"mabsf", { 2, "", 0x1, 0x19} },
- {"mabsd", { 2, "", 0x1, 0x1a} },
- {"mtstw", { 2, "", (0x1|0x8|0x10), 0x1c} },
- {"mtstf", { 2, "", 0x1, 0x1d} },
- {"mtstd", { 2, "", 0x1, 0x1e} },
- {"mova", { 2, "", 0x8|0x10, 0x1f} },
- {"movzbw", { 2, "", (0x1|0x8|0x10), 0x20} },
- {"movzhw", { 2, "", (0x1|0x8|0x10), 0x21} },
- /* 2 insns out of order here */
- {"movbl", { 2, "", 1, 0x4f} },
- {"filbl", { 2, "", 1, 0x4e} },
-
- {"cvtbw", { 2, "", CONVERT, 0x22} },
- {"cvthw", { 2, "", CONVERT, 0x23} },
- {"cvtwb", { 2, "", CONVERT, 0x24} },
- {"cvtwh", { 2, "", CONVERT, 0x25} },
- {"cvtwf", { 2, "", CONVERT, 0x26} },
- {"cvtwd", { 2, "", CONVERT, 0x27} },
- {"cvtfw", { 2, "", CONVERT, 0x28} },
- {"cvtfd", { 2, "", CONVERT, 0x29} },
- {"cvtdw", { 2, "", CONVERT, 0x2a} },
- {"cvtdf", { 2, "", CONVERT, 0x2b} },
-
- {"addw", { 2, "", GEN_TO_REG, 0x40} },
- {"addwc", { 2, "", GEN_TO_REG, 0x41} },
- {"subw", { 2, "", GEN_TO_REG, 0x42} },
- {"subwb", { 2, "", GEN_TO_REG, 0x43} },
- {"rsubw", { 2, "", GEN_TO_REG, 0x44} },
- {"mulw", { 2, "", GEN_TO_REG, 0x45} },
- {"emul", { 2, "", GEN_TO_REG, 0x47} },
- {"umulw", { 2, "", GEN_TO_REG, 0x46} },
- {"divw", { 2, "", GEN_TO_REG, 0x48} },
- {"ediv", { 2, "", GEN_TO_REG, 0x4a} },
- {"rdivw", { 2, "", GEN_TO_REG, 0x4b} },
- {"udivw", { 2, "", GEN_TO_REG, 0x49} },
- {"modw", { 2, "", GEN_TO_REG, 0x4c} },
- {"umodw", { 2, "", GEN_TO_REG, 0x4d} },
-
-
- {"addf", { 2, "", 1, 0x50} },
- {"addd", { 2, "", 1, 0x51} },
- {"subf", { 2, "", 1, 0x52} },
- {"subd", { 2, "", 1, 0x53} },
- {"mulf", { 2, "", 1, 0x56} },
- {"muld", { 2, "", 1, 0x57} },
- {"divf", { 2, "", 1, 0x58} },
- {"divd", { 2, "", 1, 0x59} },
-
-
- {"cmpb", { 2, "", UNKNOWN, 0x61} },
- {"cmph", { 2, "", UNKNOWN, 0x62} },
- {"cmpw", { 2, "", UNKNOWN, 0x60} },
- {"ucmpb", { 2, "", UNKNOWN, 0x66} },
- /* WHY no "ucmph"??? */
- {"ucmpw", { 2, "", UNKNOWN, 0x65} },
- {"xchw", { 2, "", UNKNOWN, 0x0f} },
-
-
- {"andw", { 2, "", GEN_TO_REG, 0x30} },
- {"orw", { 2, "", GEN_TO_REG, 0x31} },
- {"xorw", { 2, "", GEN_TO_REG, 0x32} },
- {"bicw", { 2, "", GEN_TO_REG, 0x33} },
- {"lshlw", { 2, "", GEN_TO_REG, 0x38} },
- {"ashlw", { 2, "", GEN_TO_REG, 0x3a} },
- {"ashll", { 2, "", GEN_TO_REG, 0x3c} },
- {"ashrw", { 2, "", GEN_TO_REG, 0x3b} },
- {"ashrl", { 2, "", GEN_TO_REG, 0x3d} },
- {"rotlw", { 2, "", GEN_TO_REG, 0x3e} },
- {"rotrw", { 2, "", GEN_TO_REG, 0x3f} },
-
- /* push and pop insns are "going away next release". */
- {"pushw", { 2, "", GEN_TO_REG, 0x0c} },
- {"popw", { 2, "", (0x1|0x8|0x10), 0x0d} },
- {"pusha", { 2, "", (0x8|0x10), 0x0e} },
-
- {"bitsw", { 2, "", UNKNOWN, 0x35} },
- {"bitcw", { 2, "", UNKNOWN, 0x36} },
- /* some kind of ibra/dbra insns??*/
- {"icmpw", { 2, "", UNKNOWN, 0x67} },
- {"dcmpw", { 2, "", (1|4|0x20|0x80|0x400|0x1000), 0x69} },/*FIXME*/
- {"acmpw", { 2, "", 1, 0x6b} },
-
- /* Call is written as a 1-op insn, but is always (dis)assembled as a 2-op
- insn with a 2nd op of tr14. The assembler will have to grok this. */
- {"call", { 2, "", GEN_TO_REG, 0x04} },
- {"call", { 1, "", GEN_TO_REG, 0x04} },
-
- {"callk", { 1, "", UNKNOWN, 0x06} },/* system call?*/
- /* Ret is usually written as a 0-op insn, but gets disassembled as a
- 1-op insn. The operand is always tr15. */
- {"ret", { 0, "", UNKNOWN, 0x09} },
- {"ret", { 1, "", UNKNOWN, 0x09} },
- {"adsf", { 2, "", (1|2|4), 0x08} },
- {"retd", { 2, "", UNKNOWN, 0x0a} },
- {"btc", { 2, "", UNKNOWN, 0x01} },
- {"bfc", { 2, "", UNKNOWN, 0x02} },
- /* Careful: halt is 0x00000000. Jump must have some other (mode?)bit set?? */
- {"jump", { 1, "", UNKNOWN, 0x00} },
- {"btp", { 2, "", UNKNOWN, 0xf00} },
- /* read control-stack pointer is another 1-or-2 operand insn. */
- {"rcsp", { 2, "", UNKNOWN, 0x01f} },
- {"rcsp", { 1, "", UNKNOWN, 0x01f} }
-};
-
-/* end: pyramid.opcode.h */
-/* One day I will have to take the time to find out what operands
- are valid for these insns, and guess at what they mean.
-
- I can't imagine what the "I???" insns (iglob, etc) do.
-
- the arithmetic-sounding insns ending in "p" sound awfully like BCD
- arithmetic insns:
- dshlp -> Decimal SHift Left Packed
- dshrp -> Decimal SHift Right Packed
- and cvtlp would be convert long to packed.
- I have no idea how the operands are interpreted; but having them be
- a long register with (address, length) of an in-memory packed BCD operand
- would not be surprising.
- They are unlikely to be a packed bcd string: 64 bits of long give
- is only 15 digits+sign, which isn't enough for COBOL.
- */
-#if 0
- {"wcsp", { 2, "", UNKNOWN, 0x00} }, /*write csp?*/
- /* The OSx Operating System Porting Guide claims SSL does things
- with tr12 (a register reserved to it) to do with static block-structure
- references. SSL=Set Static Link? It's "Going away next release". */
- {"ssl", { 2, "", UNKNOWN, 0x00} },
- {"ccmps", { 2, "", UNKNOWN, 0x00} },
- {"lcd", { 2, "", UNKNOWN, 0x00} },
- {"uemul", { 2, "", UNKNOWN, 0x00} }, /*unsigned emul*/
- {"srf", { 2, "", UNKNOWN, 0x00} }, /*Gidget time???*/
- {"mnegp", { 2, "", UNKNOWN, 0x00} }, /move-neg phys?*/
- {"ldp", { 2, "", UNKNOWN, 0x00} }, /*load phys?*/
- {"ldti", { 2, "", UNKNOWN, 0x00} },
- {"ldb", { 2, "", UNKNOWN, 0x00} },
- {"stp", { 2, "", UNKNOWN, 0x00} },
- {"stti", { 2, "", UNKNOWN, 0x00} },
- {"stb", { 2, "", UNKNOWN, 0x00} },
- {"stu", { 2, "", UNKNOWN, 0x00} },
- {"addp", { 2, "", UNKNOWN, 0x00} },
- {"subp", { 2, "", UNKNOWN, 0x00} },
- {"mulp", { 2, "", UNKNOWN, 0x00} },
- {"divp", { 2, "", UNKNOWN, 0x00} },
- {"dshlp", { 2, "", UNKNOWN, 0x00} }, /* dec shl packed? */
- {"dshrp", { 2, "", UNKNOWN, 0x00} }, /* dec shr packed? */
- {"movs", { 2, "", UNKNOWN, 0x00} }, /*move (string?)?*/
- {"cmpp", { 2, "", UNKNOWN, 0x00} }, /* cmp phys?*/
- {"cmps", { 2, "", UNKNOWN, 0x00} }, /* cmp (string?)?*/
- {"cvtlp", { 2, "", UNKNOWN, 0x00} }, /* cvt long to p??*/
- {"cvtpl", { 2, "", UNKNOWN, 0x00} }, /* cvt p to l??*/
- {"dintr", { 2, "", UNKNOWN, 0x00} }, /* ?? intr ?*/
- {"rphysw", { 2, "", UNKNOWN, 0x00} }, /* read phys word?*/
- {"wphysw", { 2, "", UNKNOWN, 0x00} }, /* write phys word?*/
- {"cmovs", { 2, "", UNKNOWN, 0x00} },
- {"rsubw", { 2, "", UNKNOWN, 0x00} },
- {"bicpsw", { 2, "", UNKNOWN, 0x00} }, /* clr bit in psw? */
- {"bispsw", { 2, "", UNKNOWN, 0x00} }, /* set bit in psw? */
- {"eio", { 2, "", UNKNOWN, 0x00} }, /* ?? ?io ? */
- {"callp", { 2, "", UNKNOWN, 0x00} }, /* call phys?*/
- {"callr", { 2, "", UNKNOWN, 0x00} },
- {"lpcxt", { 2, "", UNKNOWN, 0x00} }, /*load proc context*/
- {"rei", { 2, "", UNKNOWN, 0x00} }, /*ret from intrpt*/
- {"rport", { 2, "", UNKNOWN, 0x00} }, /*read-port?*/
- {"rtod", { 2, "", UNKNOWN, 0x00} }, /*read-time-of-day?*/
- {"ssi", { 2, "", UNKNOWN, 0x00} },
- {"vtpa", { 2, "", UNKNOWN, 0x00} }, /*virt-to-phys-addr?*/
- {"wicl", { 2, "", UNKNOWN, 0x00} }, /* write icl ? */
- {"wport", { 2, "", UNKNOWN, 0x00} }, /*write-port?*/
- {"wtod", { 2, "", UNKNOWN, 0x00} }, /*write-time-of-day?*/
- {"flic", { 2, "", UNKNOWN, 0x00} },
- {"iglob", { 2, "", UNKNOWN, 0x00} }, /* I global? */
- {"iphys", { 2, "", UNKNOWN, 0x00} }, /* I physical? */
- {"ipid", { 2, "", UNKNOWN, 0x00} }, /* I pid? */
- {"ivect", { 2, "", UNKNOWN, 0x00} }, /* I vector? */
- {"lamst", { 2, "", UNKNOWN, 0x00} },
- {"tio", { 2, "", UNKNOWN, 0x00} },
-#endif
diff --git a/gnu/usr.bin/as/opcode/sparc.h b/gnu/usr.bin/as/opcode/sparc.h
deleted file mode 100644
index d44f182..0000000
--- a/gnu/usr.bin/as/opcode/sparc.h
+++ /dev/null
@@ -1,885 +0,0 @@
-
-/* Table of opcodes for the sparc.
- Copyright 1989, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and
-the GNU Binutils.
-
-GAS/GDB 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.
-
-GAS/GDB 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 GAS or GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * $Id$
- */
-
- /* FIXME-someday: perhaps the ,a's and such should be embedded in the
- instruction's name rather than the args. This would make gas faster, pinsn
- slower, but would mess up some macros a bit. xoxorich. */
-
-#if !defined(__STDC__) && !defined(const)
-#define const
-#endif
-
-/*
- * Structure of an opcode table entry.
- */
-enum sparc_architecture {
- v6 = 0,
- v7,
- v8,
-};
-
-static const char *architecture_pname[] = {
- "v6",
- "v7",
- "v8",
- NULL,
-};
-
-struct sparc_opcode {
- const char *name;
- unsigned long match; /* Bits that must be set. */
- unsigned long lose; /* Bits that must not be set. */
- const char *args;
- /* This was called "delayed" in versions before the flags. */
- char flags;
- enum sparc_architecture architecture;
-};
-
-#define F_DELAYED 1 /* Delayed branch */
-#define F_ALIAS 2 /* Alias for a "real" instruction */
-
-/*
-
-All sparc opcodes are 32 bits, except for the `set' instruction (really a
-macro), which is 64 bits. It is handled as a special case.
-
-The match component is a mask saying which bits must match a particular
-opcode in order for an instruction to be an instance of that opcode.
-
-The args component is a string containing one character for each operand of the
-instruction.
-
-Kinds of operands:
- # Number used by optimizer. It is ignored.
- 1 rs1 register.
- 2 rs2 register.
- d rd register.
- e frs1 floating point register.
- v frs1 floating point register (double/even).
- V frs1 floating point register (quad/multiple of 4).
- f frs2 floating point register.
- B frs2 floating point register (double/even).
- R frs2 floating point register (quad/multiple of 4).
- g frsd floating point register.
- H frsd floating point register (double/even).
- J frsd floating point register (quad/multiple of 4).
- b crs1 coprocessor register
- c crs2 coprocessor register
- D crsd coprocessor register
- m alternate space register (asr) in rd
- M alternate space register (asr) in rs1
- h 22 high bits.
- i 13 bit Immediate.
- n 22 bit immediate.
- l 22 bit PC relative immediate.
- L 30 bit PC relative immediate.
- a Annul. The annul bit is set.
- A Alternate address space. Stored as 8 bits.
- C Coprocessor state register.
- F floating point state register.
- p Processor state register.
- q Floating point queue.
- r Single register that is both rs1 and rsd.
- Q Coprocessor queue.
- S Special case.
- x Single register that is both rs2 and rsd.
- t Trap base register.
- w Window invalid mask register.
- y Y register.
-
-The following chars are unused: (note: ,[] are used as punctuation)
-[oOX3450]
-
-*/
-
-/* The order of the opcodes in this table is significant:
-
- * The assembler requires that all instances of the same mnemonic must
- be consecutive. If they aren't, the assembler will bomb at runtime.
-
- * The disassembler should not care about the order of the opcodes.
-
-*/
-
-#define OP2(x) (((x)&0x7) << 22) /* op2 field of format2 insns */
-#define OP3(x) (((x)&0x3f) << 19) /* op3 field of format3 insns */
-#define OP(x) (((x)&0x3) << 30) /* op field of all insns */
-#define OPF(x) (((x)&0x1ff) << 5) /* opf field of float insns */
-#define F3F(x, y, z) (OP(x) | OP3(y) | OPF(z)) /* format3 float insns */
-#define F3I(x) (((x)&0x1) << 13) /* immediate field of format 3 insns */
-#define F2(x, y) (OP(x) | OP2(y)) /* format 2 insns */
-#define F3(x, y, z) (OP(x) | OP3(y) | F3I(z)) /* format3 insns */
-#define F1(x) (OP(x))
-#define DISP30(x) ((x)&0x3fffffff)
-#define ASI(x) (((x)&0xff) << 5) /* asi field of format3 insns */
-#define RS2(x) ((x)&0x1f) /* rs2 field */
-#define SIMM13(x) ((x)&0x1fff) /* simm13 field */
-#define RD(x) (((x)&0x1f) << 25) /* destination register field */
-#define RS1(x) (((x)&0x1f) << 14) /* rs1 field */
-#define ASI_RS2(x) (SIMM13(x))
-
-#define ANNUL (1<<29)
-#define IMMED F3I(1)
-#define RD_G0 RD(~0)
-#define RS1_G0 RS1(~0)
-#define RS2_G0 RS2(~0)
-
-#define COND(x) (((x)&0xf)<<25)
-
-#define CONDA (COND(0x8))
-#define CONDCC (COND(0xd))
-#define CONDCS (COND(0x5))
-#define CONDE (COND(0x1))
-#define CONDG (COND(0xa))
-#define CONDGE (COND(0xb))
-#define CONDGU (COND(0xc))
-#define CONDL (COND(0x3))
-#define CONDLE (COND(0x2))
-#define CONDLEU (COND(0x4))
-#define CONDN (COND(0x0))
-#define CONDNE (COND(0x9))
-#define CONDNEG (COND(0x6))
-#define CONDPOS (COND(0xe))
-#define CONDVC (COND(0xf))
-#define CONDVS (COND(0x7))
-
-#define CONDNZ CONDNE
-#define CONDZ CONDE
-#define CONDGEU CONDCC
-#define CONDLU CONDCS
-
-#define FCONDA (COND(0x8))
-#define FCONDE (COND(0x9))
-#define FCONDG (COND(0x6))
-#define FCONDGE (COND(0xb))
-#define FCONDL (COND(0x4))
-#define FCONDLE (COND(0xd))
-#define FCONDLG (COND(0x2))
-#define FCONDN (COND(0x0))
-#define FCONDNE (COND(0x1))
-#define FCONDO (COND(0xf))
-#define FCONDU (COND(0x7))
-#define FCONDUE (COND(0xa))
-#define FCONDUG (COND(0x5))
-#define FCONDUGE (COND(0xc))
-#define FCONDUL (COND(0x3))
-#define FCONDULE (COND(0xe))
-
-#define FCONDNZ FCONDNE
-#define FCONDZ FCONDE
-
-
-static const struct sparc_opcode sparc_opcodes[] = {
-
-{ "ld", F3(3, 0x00, 0), F3(~3, ~0x00, ~0), "[1+2],d", 0, v6 },
-{ "ld", F3(3, 0x00, 0), F3(~3, ~0x00, ~0)|RS2_G0, "[1],d", 0, v6 }, /* ld [rs1+%g0],d */
-{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[1+i],d", 0, v6 },
-{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[i+1],d", 0, v6 },
-{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|RS1_G0, "[i],d", 0, v6 },
-{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ld [rs1+0],d */
-{ "ld", F3(3, 0x20, 0), F3(~3, ~0x20, ~0), "[1+2],g", 0, v6 },
-{ "ld", F3(3, 0x20, 0), F3(~3, ~0x20, ~0)|RS2_G0, "[1],g", 0, v6 }, /* ld [rs1+%g0],d */
-{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1), "[1+i],g", 0, v6 },
-{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1), "[i+1],g", 0, v6 },
-{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1)|RS1_G0, "[i],g", 0, v6 },
-{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1)|SIMM13(~0), "[1],g", 0, v6 }, /* ld [rs1+0],d */
-{ "ld", F3(3, 0x21, 0), F3(~3, ~0x21, ~0), "[1+2],F", 0, v6 },
-{ "ld", F3(3, 0x21, 0), F3(~3, ~0x21, ~0)|RS2_G0, "[1],F", 0, v6 }, /* ld [rs1+%g0],d */
-{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1), "[1+i],F", 0, v6 },
-{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1), "[i+1],F", 0, v6 },
-{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|RS1_G0, "[i],F", 0, v6 },
-{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|SIMM13(~0), "[1],F", 0, v6 }, /* ld [rs1+0],d */
-{ "ld", F3(3, 0x30, 0), F3(~3, ~0x30, ~0), "[1+2],D", 0, v6 },
-{ "ld", F3(3, 0x30, 0), F3(~3, ~0x30, ~0)|RS2_G0, "[1],D", 0, v6 }, /* ld [rs1+%g0],d */
-{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[1+i],D", 0, v6 },
-{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[i+1],D", 0, v6 },
-{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|RS1_G0, "[i],D", 0, v6 },
-{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|SIMM13(~0), "[1],D", 0, v6 }, /* ld [rs1+0],d */
-{ "ld", F3(3, 0x31, 0), F3(~3, ~0x31, ~0), "[1+2],C", 0, v6 },
-{ "ld", F3(3, 0x31, 0), F3(~3, ~0x31, ~0)|RS2_G0, "[1],C", 0, v6 }, /* ld [rs1+%g0],d */
-{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1), "[1+i],C", 0, v6 },
-{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1), "[i+1],C", 0, v6 },
-{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1)|RS1_G0, "[i],C", 0, v6 },
-{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1)|SIMM13(~0), "[1],C", 0, v6 }, /* ld [rs1+0],d */
-
-
-
-{ "lda", F3(3, 0x10, 0), F3(~3, ~0x10, ~0), "[1+2]A,d", 0, v6 },
-{ "lda", F3(3, 0x10, 0), F3(~3, ~0x10, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* lda [rs1+%g0],d */
-
-{ "ldd", F3(3, 0x03, 0), F3(~3, ~0x03, ~0)|ASI(~0), "[1+2],d", 0, v6 },
-{ "ldd", F3(3, 0x03, 0), F3(~3, ~0x03, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldd [rs1+%g0],d */
-{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1), "[1+i],d", 0, v6 },
-{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1), "[i+1],d", 0, v6 },
-{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1)|RS1_G0, "[i],d", 0, v6 },
-{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldd [rs1+0],d */
-{ "ldd", F3(3, 0x23, 0), F3(~3, ~0x23, ~0)|ASI(~0), "[1+2],g", 0, v6 },
-{ "ldd", F3(3, 0x23, 0), F3(~3, ~0x23, ~0)|ASI_RS2(~0), "[1],g", 0, v6 }, /* ldd [rs1+%g0],d */
-{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1), "[1+i],g", 0, v6 },
-{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1), "[i+1],g", 0, v6 },
-{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1)|RS1_G0, "[i],g", 0, v6 },
-{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1)|SIMM13(~0), "[1],g", 0, v6 }, /* ldd [rs1+0],d */
-{ "ldd", F3(3, 0x33, 0), F3(~3, ~0x33, ~0)|ASI(~0), "[1+2],D", 0, v6 },
-{ "ldd", F3(3, 0x33, 0), F3(~3, ~0x33, ~0)|ASI_RS2(~0), "[1],D", 0, v6 }, /* ldd [rs1+%g0],d */
-{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1), "[1+i],D", 0, v6 },
-{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1), "[i+1],D", 0, v6 },
-{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1)|RS1_G0, "[i],D", 0, v6 },
-{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1)|SIMM13(~0), "[1],D", 0, v6 }, /* ldd [rs1+0],d */
-{ "ldsb", F3(3, 0x09, 0), F3(~3, ~0x09, ~0)|ASI(~0), "[1+2],d", 0, v6 },
-{ "ldsb", F3(3, 0x09, 0), F3(~3, ~0x09, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldsb [rs1+%g0],d */
-{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1), "[1+i],d", 0, v6 },
-{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1), "[i+1],d", 0, v6 },
-{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1)|RS1_G0, "[i],d", 0, v6 },
-{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldsb [rs1+0],d */
-{ "ldsh", F3(3, 0x0a, 0), F3(~3, ~0x0a, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldsh [rs1+%g0],d */
-{ "ldsh", F3(3, 0x0a, 0), F3(~3, ~0x0a, ~0)|ASI(~0), "[1+2],d", 0, v6 },
-{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1), "[1+i],d", 0, v6 },
-{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1), "[i+1],d", 0, v6 },
-{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1)|RS1_G0, "[i],d", 0, v6 },
-{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldsh [rs1+0],d */
-{ "ldstub", F3(3, 0x0d, 0), F3(~3, ~0x0d, ~0)|ASI(~0), "[1+2],d", 0, v6 },
-{ "ldstub", F3(3, 0x0d, 0), F3(~3, ~0x0d, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldstub [rs1+%g0],d */
-{ "ldstub", F3(3, 0x0d, 1), F3(~3, ~0x0d, ~1), "[1+i],d", 0, v6 },
-{ "ldstub", F3(3, 0x0d, 1), F3(~3, ~0x0d, ~1), "[i+1],d", 0, v6 },
-{ "ldstub", F3(3, 0x0d, 1), F3(~3, ~0x0d, ~1)|RS1_G0, "[i],d", 0, v6 },
-{ "ldub", F3(3, 0x01, 0), F3(~3, ~0x01, ~0)|ASI(~0), "[1+2],d", 0, v6 },
-{ "ldub", F3(3, 0x01, 0), F3(~3, ~0x01, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldub [rs1+%g0],d */
-{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1), "[1+i],d", 0, v6 },
-{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1), "[i+1],d", 0, v6 },
-{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1)|RS1_G0, "[i],d", 0, v6 },
-{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldub [rs1+0],d */
-{ "lduh", F3(3, 0x02, 0), F3(~3, ~0x02, ~0)|ASI(~0), "[1+2],d", 0, v6 },
-{ "lduh", F3(3, 0x02, 0), F3(~3, ~0x02, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* lduh [rs1+%g0],d */
-{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1), "[1+i],d", 0, v6 },
-{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1), "[i+1],d", 0, v6 },
-{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1)|RS1_G0, "[i],d", 0, v6 },
-{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* lduh [rs1+0],d */
-
-
-{ "ldda", F3(3, 0x13, 0), F3(~3, ~0x13, ~0), "[1+2]A,d", 0, v6 },
-{ "ldda", F3(3, 0x13, 0), F3(~3, ~0x13, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldda [rs1+%g0],d */
-{ "ldsba", F3(3, 0x19, 0), F3(~3, ~0x19, ~0), "[1+2]A,d", 0, v6 },
-{ "ldsba", F3(3, 0x19, 0), F3(~3, ~0x19, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldsba [rs1+%g0],d */
-{ "ldsha", F3(3, 0x1a, 0), F3(~3, ~0x1a, ~0), "[1+2]A,d", 0, v6 },
-{ "ldsha", F3(3, 0x1a, 0), F3(~3, ~0x1a, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldsha [rs1+%g0],d */
-{ "ldstuba", F3(3, 0x1d, 0), F3(~3, ~0x1d, ~0), "[1+2]A,d", 0, v6 },
-{ "ldstuba", F3(3, 0x1d, 0), F3(~3, ~0x1d, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldstuba [rs1+%g0],d */
-{ "lduba", F3(3, 0x11, 0), F3(~3, ~0x11, ~0), "[1+2]A,d", 0, v6 },
-{ "lduba", F3(3, 0x11, 0), F3(~3, ~0x11, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* lduba [rs1+%g0],d */
-{ "lduha", F3(3, 0x12, 0), F3(~3, ~0x12, ~0), "[1+2]A,d", 0, v6 },
-{ "lduha", F3(3, 0x12, 0), F3(~3, ~0x12, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* lduha [rs1+%g0],d */
-
-{ "st", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI(~0), "d,[1+2]", 0, v6 },
-{ "st", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* st d,[rs1+%g0] */
-{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[1+i]", 0, v6 },
-{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[i+1]", 0, v6 },
-{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RS1_G0, "d,[i]", 0, v6 },
-{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* st d,[rs1+0] */
-{ "st", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI(~0), "g,[1+2]", 0, v6 },
-{ "st", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI_RS2(~0), "g,[1]", 0, v6 }, /* st d[rs1+%g0] */
-{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[1+i]", 0, v6 },
-{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[i+1]", 0, v6 },
-{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|RS1_G0, "g,[i]", 0, v6 },
-{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|SIMM13(~0), "g,[1]", 0, v6 }, /* st d,[rs1+0] */
-{ "st", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI(~0), "D,[1+2]", 0, v6 },
-{ "st", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI_RS2(~0), "D,[1]", 0, v6 }, /* st d,[rs1+%g0] */
-{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[1+i]", 0, v6 },
-{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[i+1]", 0, v6 },
-{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|RS1_G0, "D,[i]", 0, v6 },
-{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|SIMM13(~0), "D,[1]", 0, v6 }, /* st d,[rs1+0] */
-{ "st", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI(~0), "C,[1+2]", 0, v6 },
-{ "st", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI_RS2(~0), "C,[1]", 0, v6 }, /* st d,[rs1+%g0] */
-{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[1+i]", 0, v6 },
-{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[i+1]", 0, v6 },
-{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|RS1_G0, "C,[i]", 0, v6 },
-{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|SIMM13(~0), "C,[1]", 0, v6 }, /* st d,[rs1+0] */
-
-{ "st", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI(~0), "F,[1+2]", 0, v6 },
-{ "st", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI_RS2(~0), "F,[1]", 0, v6 }, /* st d,[rs1+%g0] */
-{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[1+i]", 0, v6 },
-{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[i+1]", 0, v6 },
-{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0|RS1_G0, "F,[i]", 0, v6 },
-{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|SIMM13(~0), "F,[1]", 0, v6 }, /* st d,[rs1+0] */
-
-
-
-
-{ "sta", F3(3, 0x14, 0), F3(~3, ~0x14, ~0), "d,[1+2]A", 0, v6 },
-{ "sta", F3(3, 0x14, 0), F3(~3, ~0x14, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* sta d,[rs1+%g0] */
-
-
-
-
-{ "stb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|ASI(~0), "d,[1+2]", 0, v6 },
-{ "stb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* stb d,[rs1+%g0] */
-{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1), "d,[1+i]", 0, v6 },
-{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1), "d,[i+1]", 0, v6 },
-{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RS1_G0, "d,[i]", 0, v6 },
-{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* stb d,[rs1+0] */
-
-
-
-{ "stba", F3(3, 0x15, 0), F3(~3, ~0x15, ~0), "d,[1+2]A", 0, v6 },
-{ "stba", F3(3, 0x15, 0), F3(~3, ~0x15, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* stba d,[rs1+%g0] */
-
-
-
-{ "std", F3(3, 0x07, 0), F3(~3, ~0x07, ~0)|ASI(~0), "d,[1+2]", 0, v6 },
-{ "std", F3(3, 0x07, 0), F3(~3, ~0x07, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* std d,[rs1+%g0] */
-{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1), "d,[1+i]", 0, v6 },
-{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1), "d,[i+1]", 0, v6 },
-{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1)|RS1_G0, "d,[i]", 0, v6 },
-{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* std d,[rs1+0] */
-{ "std", F3(3, 0x26, 0), F3(~3, ~0x26, ~0)|ASI(~0), "q,[1+2]", 0, v6 },
-{ "std", F3(3, 0x26, 0), F3(~3, ~0x26, ~0)|ASI_RS2(~0), "q,[1]", 0, v6 }, /* std d,[rs1+%g0] */
-{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1), "q,[1+i]", 0, v6 },
-{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1), "q,[i+1]", 0, v6 },
-{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1)|RS1_G0, "q,[i]", 0, v6 },
-{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1)|SIMM13(~0), "q,[1]", 0, v6 }, /* std d,[rs1+0] */
-{ "std", F3(3, 0x27, 0), F3(~3, ~0x27, ~0)|ASI(~0), "g,[1+2]", 0, v6 },
-{ "std", F3(3, 0x27, 0), F3(~3, ~0x27, ~0)|ASI_RS2(~0), "g,[1]", 0, v6 }, /* std d,[rs1+%g0] */
-{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1), "g,[1+i]", 0, v6 },
-{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1), "g,[i+1]", 0, v6 },
-{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1)|RS1_G0, "g,[i]", 0, v6 },
-{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1)|SIMM13(~0), "g,[1]", 0, v6 }, /* std d,[rs1+0] */
-{ "std", F3(3, 0x36, 0), F3(~3, ~0x36, ~0)|ASI(~0), "Q,[1+2]", 0, v6 },
-{ "std", F3(3, 0x36, 0), F3(~3, ~0x36, ~0)|ASI_RS2(~0), "Q,[1]", 0, v6 }, /* std d,[rs1+%g0] */
-{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1), "Q,[1+i]", 0, v6 },
-{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1), "Q,[i+1]", 0, v6 },
-{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1)|RS1_G0, "Q,[i]", 0, v6 },
-{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1)|SIMM13(~0), "Q,[1]", 0, v6 }, /* std d,[rs1+0] */
-{ "std", F3(3, 0x37, 0), F3(~3, ~0x37, ~0)|ASI(~0), "D,[1+2]", 0, v6 },
-{ "std", F3(3, 0x37, 0), F3(~3, ~0x37, ~0)|ASI_RS2(~0), "D,[1]", 0, v6 }, /* std d,[rs1+%g0] */
-{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1), "D,[1+i]", 0, v6 },
-{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1), "D,[i+1]", 0, v6 },
-{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1)|RS1_G0, "D,[i]", 0, v6 },
-{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1)|SIMM13(~0), "D,[1]", 0, v6 }, /* std d,[rs1+0] */
-
-{ "stda", F3(3, 0x17, 0), F3(~3, ~0x17, ~0), "d,[1+2]A", 0, v6 },
-{ "stda", F3(3, 0x17, 0), F3(~3, ~0x17, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* stda d,[rs1+%g0] */
-
-{ "sth", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|ASI(~0), "d,[1+2]", 0, v6 },
-{ "sth", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* sth d,[rs1+%g0] */
-{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1), "d,[1+i]", 0, v6 },
-{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1), "d,[i+1]", 0, v6 },
-{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RS1_G0, "d,[i]", 0, v6 },
-{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* sth d,[+] */
-
-
-
-{ "stha", F3(3, 0x16, 0), F3(~3, ~0x16, ~0), "d,[1+2]A", 0, v6 },
-{ "stha", F3(3, 0x16, 0), F3(~3, ~0x16, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* stha ,[+%] */
-
-
-
-
-
-{ "swap", F3(3, 0x0f, 0), F3(~3, ~0x0f, ~0)|ASI(~0), "[1+2],d", 0, v7 },
-{ "swap", F3(3, 0x0f, 0), F3(~3, ~0x0f, ~0)|ASI_RS2(~0), "[1],d", 0, v7 }, /* swap [rs1+%g0],d */
-{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1), "[1+i],d", 0, v7 },
-{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1), "[i+1],d", 0, v7 },
-{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1)|RS1_G0, "[i],d", 0, v7 },
-{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1)|SIMM13(~0), "[1],d", 0, v7 }, /* swap [rs1+0],d */
-
-{ "swapa", F3(3, 0x1f, 0), F3(~3, ~0x1f, ~0), "[1+2]A,d", 0, v7 },
-{ "swapa", F3(3, 0x1f, 0), F3(~3, ~0x1f, ~0)|RS2(~0), "[1]A,d", 0, v7 }, /* swapa [rs1+%g0],d */
-
-{ "restore", F3(2, 0x3d, 0), F3(~2, ~0x3d, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "restore", F3(2, 0x3d, 0), F3(~2, ~0x3d, ~0)|RD_G0|RS1_G0|ASI_RS2(~0), "", 0, v6 }, /* restore %g0,%g0,%g0 */
-{ "restore", F3(2, 0x3d, 1), F3(~2, ~0x3d, ~1), "1,i,d", 0, v6 },
-{ "restore", F3(2, 0x3d, 1), F3(~2, ~0x3d, ~1)|RD_G0|RS1_G0|SIMM13(~0), "", 0, v6 }, /* restore %g0,0,%g0 */
-
-{ "rett", F3(2, 0x39, 0), F3(~2, ~0x39, ~0)|RD_G0|ASI(~0), "1+2", F_DELAYED, v6 }, /* rett rs1+rs2 */
-{ "rett", F3(2, 0x39, 0), F3(~2, ~0x39, ~0)|RD_G0|ASI_RS2(~0), "1", F_DELAYED, v6 }, /* rett rs1,%g0 */
-{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0, "1+i", F_DELAYED, v6 }, /* rett rs1+X */
-{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0, "i+1", F_DELAYED, v6 }, /* rett X+rs1 */
-{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0|RS1_G0,"i", F_DELAYED, v6 }, /* rett X+rs1 */
-{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0|RS1_G0, "i", F_DELAYED, v6 }, /* rett X */
-{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0|SIMM13(~0), "1", F_DELAYED, v6 }, /* rett rs1+0 */
-
-{ "save", F3(2, 0x3c, 0), F3(~2, ~0x3c, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "save", F3(2, 0x3c, 1), F3(~2, ~0x3c, ~1), "1,i,d", 0, v6 },
-
-{ "ret", F3(2, 0x38, 1)|RS1(0x1f)|SIMM13(8), F3(~2, ~0x38, ~1)|SIMM13(~8), "", F_DELAYED, v6 }, /* jmpl %i7+8,%g0 */
-{ "retl", F3(2, 0x38, 1)|RS1(0x0f)|SIMM13(8), F3(~2, ~0x38, ~1)|RS1(~0x0f)|SIMM13(~8), "", F_DELAYED, v6 }, /* jmpl %o7+8,%g0 */
-
-{ "jmpl", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|ASI(~0), "1+2,d", F_DELAYED, v6 },
-{ "jmpl", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|ASI_RS2(~0), "1,d", F_DELAYED, v6 }, /* jmpl rs1+%g0,d */
-{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|SIMM13(~0), "1,d", F_DELAYED, v6 }, /* jmpl rs1+0,d */
-{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RS1_G0, "i,d", F_DELAYED, v6 }, /* jmpl %g0+i,d */
-{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1), "1+i,d", F_DELAYED, v6 },
-{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1), "i+1,d", F_DELAYED, v6 },
-{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RS1_G0, "i,d", F_DELAYED, v6 },
-
- /* The 1<<12 is a long story. It is necessary. For more info, please contact rich@cygnus.com */
-{ "sll", F3(2, 0x25, 0), F3(~2, ~0x25, ~0)|(1<<12)|ASI(~0), "1,2,d", 0, v6 },
-{ "sll", F3(2, 0x25, 1), F3(~2, ~0x25, ~1)|(1<<12), "1,i,d", 0, v6 },
-{ "sra", F3(2, 0x27, 0), F3(~2, ~0x27, ~0)|(1<<12)|ASI(~0), "1,2,d", 0, v6 },
-{ "sra", F3(2, 0x27, 1), F3(~2, ~0x27, ~1)|(1<<12), "1,i,d", 0, v6 },
-{ "srl", F3(2, 0x26, 0), F3(~2, ~0x26, ~0)|(1<<12)|ASI(~0), "1,2,d", 0, v6 },
-{ "srl", F3(2, 0x26, 1), F3(~2, ~0x26, ~1)|(1<<12), "1,i,d", 0, v6 },
-
-
-
-{ "mulscc", F3(2, 0x24, 0), F3(~2, ~0x24, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "mulscc", F3(2, 0x24, 1), F3(~2, ~0x24, ~1), "1,i,d", 0, v6 },
-
-{ "clr", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|RD_G0|RS1_G0|ASI_RS2(~0), "d", F_ALIAS, v6 }, /* or %g0,%g0,d */
-{ "clr", F3(2, 0x02, 1), F3(~2, ~0x02, ~1)|RS1_G0|SIMM13(~0), "d", F_ALIAS, v6 }, /* or %g0,0,d */
-{ "clr", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|RD_G0|ASI(~0), "[1+2]", F_ALIAS, v6 },
-{ "clr", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|RD_G0|ASI_RS2(~0), "[1]", F_ALIAS, v6 }, /* st %g0,[rs1+%g0] */
-{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0, "[1+i]", F_ALIAS, v6 },
-{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0, "[i+1]", F_ALIAS, v6 },
-{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0|RS1_G0, "[i]", F_ALIAS, v6 },
-{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0|SIMM13(~0), "[1]", F_ALIAS, v6 }, /* st %g0,[rs1+0] */
-
-{ "clrb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|RD_G0|ASI(~0), "[1+2]", F_ALIAS, v6 },
-{ "clrb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|RD_G0|ASI_RS2(~0), "[1]", F_ALIAS, v6 }, /* stb %g0,[rs1+%g0] */
-{ "clrb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RD_G0, "[1+i]", F_ALIAS, v6 },
-{ "clrb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RD_G0, "[i+1]", F_ALIAS, v6 },
-{ "clrb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RD_G0|RS1_G0, "[i]", F_ALIAS, v6 },
-
-{ "clrh", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|RD_G0|ASI(~0), "[1+2]", F_ALIAS, v6 },
-{ "clrh", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|RD_G0|ASI_RS2(~0), "[1]", F_ALIAS, v6 }, /* sth %g0,[rs1+%g0] */
-{ "clrh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RD_G0, "[1+i]", F_ALIAS, v6 },
-{ "clrh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RD_G0, "[i+1]", F_ALIAS, v6 },
-{ "clrh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RD_G0|RS1_G0, "[i]", F_ALIAS, v6 },
-
-{ "orcc", F3(2, 0x12, 0), F3(~2, ~0x12, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "orcc", F3(2, 0x12, 1), F3(~2, ~0x12, ~1), "1,i,d", 0, v6 },
-{ "orcc", F3(2, 0x12, 1), F3(~2, ~0x12, ~1), "i,1,d", 0, v6 },
-
-{ "orncc", F3(2, 0x16, 0), F3(~2, ~0x16, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "orncc", F3(2, 0x16, 1), F3(~2, ~0x16, ~1), "1,i,d", 0, v6 },
-{ "orncc", F3(2, 0x16, 1), F3(~2, ~0x16, ~1), "i,1,d", 0, v6 },
-
-{ "orn", F3(2, 0x06, 0), F3(~2, ~0x06, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "orn", F3(2, 0x06, 1), F3(~2, ~0x06, ~1), "1,i,d", 0, v6 },
-{ "orn", F3(2, 0x06, 1), F3(~2, ~0x06, ~1), "i,1,d", 0, v6 },
-
-{ "tst", F3(2, 0x12, 0), F3(~2, ~0x12, ~0)|RD_G0|ASI_RS2(~0), "1", 0, v6 }, /* orcc rs1, %g0, %g0 */
-{ "tst", F3(2, 0x12, 0), F3(~2, ~0x12, ~0)|RD_G0|RS1_G0|ASI(~0), "2", 0, v6 }, /* orcc %g0, rs2, %g0 */
-{ "tst", F3(2, 0x12, 1), F3(~2, ~0x12, ~1)|RD_G0|SIMM13(~0), "1", 0, v6 }, /* orcc rs1, 0, %g0 */
-
-{ "wr", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|ASI(~0), "1,2,m", 0, v8 }, /* wr r,r,%asrX */
-{ "wr", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|RD_G0|ASI(~0), "1,2,y", 0, v6 }, /* wr r,r,%y */
-{ "wr", F3(2, 0x30, 1), F3(~2, ~0x30, ~1), "1,i,m", 0, v8 }, /* wr r,i,%asrX */
-{ "wr", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|RD_G0, "1,i,y", 0, v6 }, /* wr r,i,%y */
-{ "wr", F3(2, 0x31, 0), F3(~2, ~0x31, ~0)|RD_G0|ASI(~0), "1,2,p", 0, v6 }, /* wr r,r,%psr */
-{ "wr", F3(2, 0x31, 1), F3(~2, ~0x31, ~1)|RD_G0, "1,i,p", 0, v6 }, /* wr r,i,%psr */
-{ "wr", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|RD_G0|ASI(~0), "1,2,w", 0, v6 }, /* wr r,r,%wim */
-{ "wr", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|RD_G0, "1,i,w", 0, v6 }, /* wr r,i,%wim */
-{ "wr", F3(2, 0x33, 0), F3(~2, ~0x33, ~0)|RD_G0|ASI(~0), "1,2,t", 0, v6 }, /* wr r,r,%tbr */
-{ "wr", F3(2, 0x33, 1), F3(~2, ~0x33, ~1)|RD_G0, "1,i,t", 0, v6 }, /* wr r,i,%tbr */
-
-
-{ "rd", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|SIMM13(~0), "M,d", 0, v8 }, /* rd %asr1,r */
-{ "rd", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|RS1_G0|SIMM13(~0), "y,d", 0, v6 }, /* rd %y,r */
-{ "rd", F3(2, 0x2b, 0), F3(~2, ~0x2b, ~0)|RS1_G0|SIMM13(~0), "t,d", 0, v6 }, /* rd %tbr,r */
-
-{ "rd", F3(2, 0x29, 0), F3(~2, ~0x29, ~0)|RS1_G0|SIMM13(~0), "p,d", 0, v6 }, /* rd %psr,r */
-{ "rd", F3(2, 0x2a, 0), F3(~2, ~0x2a, ~0)|RS1_G0|SIMM13(~0), "w,d", 0, v6 }, /* rd %wim,r */
-
-{ "mov", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|ASI(~0), "1,2,m", F_ALIAS, v8 }, /* wr r,r,%asrX */
-{ "mov", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|RD_G0|ASI(~0), "1,2,y", F_ALIAS, v6 }, /* wr r,r,%y */
-{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1), "1,i,m", F_ALIAS, v8 }, /* wr r,i,%asrX */
-{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|RD_G0, "1,i,y", F_ALIAS, v6 }, /* wr r,i,%y */
-{ "mov", F3(2, 0x31, 0), F3(~2, ~0x31, ~0)|RD_G0|ASI(~0), "1,2,p", F_ALIAS, v6 }, /* wr r,r,%psr */
-{ "mov", F3(2, 0x31, 1), F3(~2, ~0x31, ~1)|RD_G0, "1,i,p", F_ALIAS, v6 }, /* wr r,i,%psr */
-{ "mov", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|RD_G0|ASI(~0), "1,2,w", F_ALIAS, v6 }, /* wr r,r,%wim */
-{ "mov", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|RD_G0, "1,i,w", F_ALIAS, v6 }, /* wr r,i,%wim */
-{ "mov", F3(2, 0x33, 0), F3(~2, ~0x33, ~0)|RD_G0|ASI(~0), "1,2,t", F_ALIAS, v6 }, /* wr r,r,%tbr */
-{ "mov", F3(2, 0x33, 1), F3(~2, ~0x33, ~1)|RD_G0, "1,i,t", F_ALIAS, v6 }, /* wr r,i,%tbr */
-
-{ "mov", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|SIMM13(~0), "M,d", F_ALIAS, v8 }, /* rd %asr1,r */
-{ "mov", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|RS1_G0|SIMM13(~0), "y,d", F_ALIAS, v6 }, /* rd %y,r */
-{ "mov", F3(2, 0x29, 0), F3(~2, ~0x29, ~0)|RS1_G0|SIMM13(~0), "p,d", F_ALIAS, v6 }, /* rd %psr,r */
-{ "mov", F3(2, 0x2a, 0), F3(~2, ~0x2a, ~0)|RS1_G0|SIMM13(~0), "w,d", F_ALIAS, v6 }, /* rd %wim,r */
-{ "mov", F3(2, 0x2b, 0), F3(~2, ~0x2b, ~0)|RS1_G0|SIMM13(~0), "t,d", F_ALIAS, v6 }, /* rd %tbr,r */
-
-{ "mov", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|ASI_RS2(~0), "1,y", F_ALIAS, v6 }, /* wr rs1,%g0,%y */
-{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1), "i,y", F_ALIAS, v6 },
-{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|SIMM13(~0), "1,y", F_ALIAS, v6 }, /* wr rs1,0,%y */
-{ "mov", F3(2, 0x31, 0), F3(~2, ~0x31, ~0)|ASI_RS2(~0), "1,p", F_ALIAS, v6 }, /* wr rs1,%g0,%psr */
-{ "mov", F3(2, 0x31, 1), F3(~2, ~0x31, ~1), "i,p", F_ALIAS, v6 },
-{ "mov", F3(2, 0x31, 1), F3(~2, ~0x31, ~1)|SIMM13(~0), "1,p", F_ALIAS, v6 }, /* wr rs1,0,%psr */
-{ "mov", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|ASI_RS2(~0), "1,w", F_ALIAS, v6 }, /* wr rs1,%g0,%wim */
-{ "mov", F3(2, 0x32, 1), F3(~2, ~0x32, ~1), "i,w", F_ALIAS, v6 },
-{ "mov", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|SIMM13(~0), "1,w", F_ALIAS, v6 }, /* wr rs1,0,%wim */
-{ "mov", F3(2, 0x33, 0), F3(~2, ~0x33, ~0)|ASI_RS2(~0), "1,t", F_ALIAS, v6 }, /* wr rs1,%g0,%tbr */
-{ "mov", F3(2, 0x33, 1), F3(~2, ~0x33, ~1), "i,t", F_ALIAS, v6 },
-{ "mov", F3(2, 0x33, 1), F3(~2, ~0x33, ~1)|SIMM13(~0), "1,t", F_ALIAS, v6 }, /* wr rs1,0,%tbr */
-
-{ "mov", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|RS1_G0|ASI(~0), "2,d", 0, v6 }, /* or %g0,rs2,d */
-{ "mov", F3(2, 0x02, 1), F3(~2, ~0x02, ~1)|RS1_G0, "i,d", 0, v6 }, /* or %g0,i,d */
-{ "mov", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|ASI_RS2(~0), "1,d", 0, v6 }, /* or rs1,%g0,d */
-{ "mov", F3(2, 0x02, 1), F3(~2, ~0x02, ~1)|SIMM13(~0), "1,d", 0, v6 }, /* or rs1,0,d */
-
-{ "or", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "or", F3(2, 0x02, 1), F3(~2, ~0x02, ~1), "1,i,d", 0, v6 },
-{ "or", F3(2, 0x02, 1), F3(~2, ~0x02, ~1), "i,1,d", 0, v6 },
-
-{ "bset", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|ASI(~0), "2,r", F_ALIAS, v6 }, /* or rd,rs2,rd */
-{ "bset", F3(2, 0x02, 1), F3(~2, ~0x02, ~1), "i,r", F_ALIAS, v6 }, /* or rd,i,rd */
-
-{ "andn", F3(2, 0x05, 0), F3(~2, ~0x05, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "andn", F3(2, 0x05, 1), F3(~2, ~0x05, ~1), "1,i,d", 0, v6 },
-{ "andn", F3(2, 0x05, 1), F3(~2, ~0x05, ~1), "i,1,d", 0, v6 },
-
-{ "andncc", F3(2, 0x15, 0), F3(~2, ~0x15, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "andncc", F3(2, 0x15, 1), F3(~2, ~0x15, ~1), "1,i,d", 0, v6 },
-{ "andncc", F3(2, 0x15, 1), F3(~2, ~0x15, ~1), "i,1,d", 0, v6 },
-
-{ "bclr", F3(2, 0x05, 0), F3(~2, ~0x05, ~0)|ASI(~0), "2,r", F_ALIAS, v6 }, /* andn rd,rs2,rd */
-{ "bclr", F3(2, 0x05, 1), F3(~2, ~0x05, ~1), "i,r", F_ALIAS, v6 }, /* andn rd,i,rd */
-
-{ "cmp", F3(2, 0x14, 0), F3(~2, ~0x14, ~0)|RD_G0|ASI(~0), "1,2", 0, v6 }, /* subcc rs1,rs2,%g0 */
-{ "cmp", F3(2, 0x14, 1), F3(~2, ~0x14, ~1)|RD_G0, "1,i", 0, v6 }, /* subcc rs1,i,%g0 */
-
-{ "sub", F3(2, 0x04, 0), F3(~2, ~0x04, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "sub", F3(2, 0x04, 1), F3(~2, ~0x04, ~1), "1,i,d", 0, v6 },
-
-{ "subcc", F3(2, 0x14, 0), F3(~2, ~0x14, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "subcc", F3(2, 0x14, 1), F3(~2, ~0x14, ~1), "1,i,d", 0, v6 },
-
-{ "subx", F3(2, 0x0c, 0), F3(~2, ~0x0c, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "subx", F3(2, 0x0c, 1), F3(~2, ~0x0c, ~1), "1,i,d", 0, v6 },
-
-{ "subxcc", F3(2, 0x1c, 0), F3(~2, ~0x1c, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "subxcc", F3(2, 0x1c, 1), F3(~2, ~0x1c, ~1), "1,i,d", 0, v6 },
-
-{ "and", F3(2, 0x01, 0), F3(~2, ~0x01, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "and", F3(2, 0x01, 1), F3(~2, ~0x01, ~1), "1,i,d", 0, v6 },
-{ "and", F3(2, 0x01, 1), F3(~2, ~0x01, ~1), "i,1,d", 0, v6 },
-
-{ "andcc", F3(2, 0x11, 0), F3(~2, ~0x11, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "andcc", F3(2, 0x11, 1), F3(~2, ~0x11, ~1), "1,i,d", 0, v6 },
-{ "andcc", F3(2, 0x11, 1), F3(~2, ~0x11, ~1), "i,1,d", 0, v6 },
-
-{ "dec", F3(2, 0x04, 1)|SIMM13(0x1), F3(~2, ~0x04, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* sub rd,1,rd */
-{ "dec", F3(2, 0x04, 1), F3(~2, ~0x04, ~1), "i,r", F_ALIAS, v6 }, /* sub rd,i,rd */
-{ "deccc", F3(2, 0x14, 1)|SIMM13(0x1), F3(~2, ~0x14, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* subcc rd,1,rd */
-{ "deccc", F3(2, 0x14, 1), F3(~2, ~0x14, ~1), "i,r", F_ALIAS, v6 }, /* subcc rd,i,rd */
-{ "inc", F3(2, 0x00, 1)|SIMM13(0x1), F3(~2, ~0x00, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* add rs1,1,rsd */
-{ "inc", F3(2, 0x00, 1), F3(~2, ~0x00, ~1), "i,r", F_ALIAS, v6 }, /* add rs1,i,rsd */
-{ "inccc", F3(2, 0x10, 1)|SIMM13(0x1), F3(~2, ~0x10, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* addcc rd,1,rd */
-{ "inccc", F3(2, 0x10, 1), F3(~2, ~0x10, ~1), "i,r", F_ALIAS, v6 }, /* addcc rd,i,rd */
-
-{ "btst", F3(2, 0x11, 0), F3(~2, ~0x11, ~0)|RD_G0|ASI(~0), "1,2", F_ALIAS, v6 }, /* andcc rs1,rs2,%g0 */
-{ "btst", F3(2, 0x11, 1), F3(~2, ~0x11, ~1)|RD_G0, "i,1", F_ALIAS, v6 }, /* andcc rs1,i,%g0 */
-
-{ "neg", F3(2, 0x04, 0), F3(~2, ~0x04, ~0)|RS1_G0|ASI(~0), "2,d", F_ALIAS, v6 }, /* sub %g0,rs2,rd */
-{ "neg", F3(2, 0x04, 0), F3(~2, ~0x04, ~0)|RS1_G0|ASI(~0), "x", F_ALIAS, v6 }, /* sub %g0,rd,rd */
-
-{ "add", F3(2, 0x00, 0), F3(~2, ~0x00, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "add", F3(2, 0x00, 1), F3(~2, ~0x00, ~1), "1,i,d", 0, v6 },
-{ "add", F3(2, 0x00, 1), F3(~2, ~0x00, ~1), "i,1,d", 0, v6 },
-{ "addcc", F3(2, 0x10, 0), F3(~2, ~0x10, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "addcc", F3(2, 0x10, 1), F3(~2, ~0x10, ~1), "1,i,d", 0, v6 },
-{ "addcc", F3(2, 0x10, 1), F3(~2, ~0x10, ~1), "i,1,d", 0, v6 },
-{ "addx", F3(2, 0x08, 0), F3(~2, ~0x08, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "addx", F3(2, 0x08, 1), F3(~2, ~0x08, ~1), "1,i,d", 0, v6 },
-{ "addx", F3(2, 0x08, 1), F3(~2, ~0x08, ~1), "i,1,d", 0, v6 },
-{ "addxcc", F3(2, 0x18, 0), F3(~2, ~0x18, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "addxcc", F3(2, 0x18, 1), F3(~2, ~0x18, ~1), "1,i,d", 0, v6 },
-{ "addxcc", F3(2, 0x18, 1), F3(~2, ~0x18, ~1), "i,1,d", 0, v6 },
-
-{ "smul", F3(2, 0x0b, 0), F3(~2, ~0x0b, ~0)|ASI(~0), "1,2,d", 0, v8 },
-{ "smul", F3(2, 0x0b, 1), F3(~2, ~0x0b, ~1), "1,i,d", 0, v8 },
-{ "smul", F3(2, 0x0b, 1), F3(~2, ~0x0b, ~1), "i,1,d", 0, v8 },
-{ "smulcc", F3(2, 0x1b, 0), F3(~2, ~0x1b, ~0)|ASI(~0), "1,2,d", 0, v8 },
-{ "smulcc", F3(2, 0x1b, 1), F3(~2, ~0x1b, ~1), "1,i,d", 0, v8 },
-{ "smulcc", F3(2, 0x1b, 1), F3(~2, ~0x1b, ~1), "i,1,d", 0, v8 },
-{ "umul", F3(2, 0x0a, 0), F3(~2, ~0x0a, ~0)|ASI(~0), "1,2,d", 0, v8 },
-{ "umul", F3(2, 0x0a, 1), F3(~2, ~0x0a, ~1), "1,i,d", 0, v8 },
-{ "umul", F3(2, 0x0a, 1), F3(~2, ~0x0a, ~1), "i,1,d", 0, v8 },
-{ "umulcc", F3(2, 0x1a, 0), F3(~2, ~0x1a, ~0)|ASI(~0), "1,2,d", 0, v8 },
-{ "umulcc", F3(2, 0x1a, 1), F3(~2, ~0x1a, ~1), "1,i,d", 0, v8 },
-{ "umulcc", F3(2, 0x1a, 1), F3(~2, ~0x1a, ~1), "i,1,d", 0, v8 },
-{ "sdiv", F3(2, 0x0f, 0), F3(~2, ~0x0f, ~0)|ASI(~0), "1,2,d", 0, v8 },
-{ "sdiv", F3(2, 0x0f, 1), F3(~2, ~0x0f, ~1), "1,i,d", 0, v8 },
-{ "sdiv", F3(2, 0x0f, 1), F3(~2, ~0x0f, ~1), "i,1,d", 0, v8 },
-{ "sdivcc", F3(2, 0x1f, 0), F3(~2, ~0x1f, ~0)|ASI(~0), "1,2,d", 0, v8 },
-{ "sdivcc", F3(2, 0x1f, 1), F3(~2, ~0x1f, ~1), "1,i,d", 0, v8 },
-{ "sdivcc", F3(2, 0x1f, 1), F3(~2, ~0x1f, ~1), "i,1,d", 0, v8 },
-{ "udiv", F3(2, 0x0e, 0), F3(~2, ~0x0e, ~0)|ASI(~0), "1,2,d", 0, v8 },
-{ "udiv", F3(2, 0x0e, 1), F3(~2, ~0x0e, ~1), "1,i,d", 0, v8 },
-{ "udiv", F3(2, 0x0e, 1), F3(~2, ~0x0e, ~1), "i,1,d", 0, v8 },
-{ "udivcc", F3(2, 0x1e, 0), F3(~2, ~0x1e, ~0)|ASI(~0), "1,2,d", 0, v8 },
-{ "udivcc", F3(2, 0x1e, 1), F3(~2, ~0x1e, ~1), "1,i,d", 0, v8 },
-{ "udivcc", F3(2, 0x1e, 1), F3(~2, ~0x1e, ~1), "i,1,d", 0, v8 },
-
-{ "call", F1(0x1), F1(~0x1), "L", F_DELAYED, v6 },
-{ "call", F1(0x1), F1(~0x1), "L,#", F_DELAYED, v6 },
-{ "call", F3(2, 0x38, 0)|RD(0xf), F3(~2, ~0x38, ~0)|RD(~0xf)|ASI_RS2(~0), "1", F_DELAYED, v6 }, /* jmpl rs1+%g0, %o7 */
-{ "call", F3(2, 0x38, 0)|RD(0xf), F3(~2, ~0x38, ~0)|RD(~0xf)|ASI_RS2(~0), "1,#", F_DELAYED, v6 },
-
-{ "call", F3(2, 0x38, 0)|RD(0xf), F3(~2, ~0x38, ~0)|RD(~0xf),
-"1+2", F_DELAYED, v6 }, /* jmpl rs1+rs2,%o7 */
-{ "call", F3(2, 0x38, 0)|RD(0xf), F3(~2, ~0x38, ~0)|RD(~0xf),
-"1+2,#", F_DELAYED, v6 }, /* jmpl rs1+rs2,%o7 */
-
-{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf),
-"1+i", F_DELAYED, v6 }, /* jmpl rs1+i,%o7 */
-{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf),
-"1+i,#", F_DELAYED, v6 }, /* jmpl rs1+i,%o7 */
-{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf),
-"i+1", F_DELAYED, v6 }, /* jmpl i+rs1,%o7 */
-{ "call", F3(2, 0x38, 1)|RD(0xf), F3(~2, ~0x38, ~1)|RD(~0xf),
-"i+1,#", F_DELAYED, v6 }, /* jmpl i+rs1,%o7 */
-
-/* Conditional instructions.
-
- Because this part of the table was such a mess earlier, I have
- macrofied it so that all the branches and traps are generated from
- a single-line description of each condition value. John Gilmore. */
-
-/* Define branches -- one annulled, one without, etc. */
-#define br(opcode, mask, lose, flags) \
- { opcode, (mask)|ANNUL, (lose), ",a l", (flags), v6 }, \
- { opcode, (mask) , (lose)|ANNUL, "l", (flags), v6 }
-
-
-/* Define four traps: reg+reg, reg + immediate, immediate alone, reg alone. */
-#define tr(opcode, mask, lose, flags) \
- { opcode, (mask)|IMMED, (lose)|RS1_G0, "i", (flags), v6 }, /* %g0 + imm */ \
- { opcode, (mask)|IMMED, (lose), "1+i", (flags), v6 }, /* rs1 + imm */ \
- { opcode, (mask), IMMED|(lose), "1+2", (flags), v6 }, /* rs1 + rs2 */ \
- { opcode, (mask), IMMED|(lose)|RS2_G0, "1", (flags), v6 } /* rs1 + %g0 */
-
-/* Define both branches and traps based on condition mask */
-#define cond(bop, top, mask, flags) \
- br(bop, F2(0, 2)|(mask), F2(~0, ~2)|((~mask)&COND(~0)), F_DELAYED|(flags)), \
- tr(top, F3(2, 0x3a, 0)|(mask), F3(~2, ~0x3a, 0)|((~mask)&COND(~0)), (flags))
-
-/* Define all the conditions, all the branches, all the traps. */
-
-cond ("b", "t", CONDA, 0),
-cond ("ba", "ta", CONDA, F_ALIAS), /* for nothing */
-cond ("bcc", "tcc", CONDCC, 0),
-cond ("bcs", "tcs", CONDCS, 0),
-cond ("be", "te", CONDE, 0),
-cond ("beq", "teq", CONDE, F_ALIAS), /* for be */
-cond ("bg", "tg", CONDG, 0),
-cond ("bgt", "tgt", CONDG, F_ALIAS),
-cond ("bge", "tge", CONDGE, 0),
-cond ("bgeu", "tgeu", CONDGEU, F_ALIAS), /* for cc */
-cond ("bgu", "tgu", CONDGU, 0),
-cond ("bl", "tl", CONDL, 0),
-cond ("blt", "tlt", CONDL, F_ALIAS),
-cond ("ble", "tle", CONDLE, 0),
-cond ("bleu", "tleu", CONDLEU, 0),
-cond ("blu", "tlu", CONDLU, F_ALIAS), /* for cs */
-cond ("bn", "tn", CONDN, 0),
-cond ("bne", "tne", CONDNE, 0),
-cond ("bneg", "tneg", CONDNEG, 0),
-cond ("bnz", "tnz", CONDNZ, F_ALIAS), /* for ne */
-cond ("bpos", "tpos", CONDPOS, 0),
-cond ("bvc", "tvc", CONDVC, 0),
-cond ("bvs", "tvs", CONDVS, 0),
-cond ("bz", "tz", CONDZ, F_ALIAS), /* for e */
-
-#undef cond
-#undef br
-#undef tr
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#define brfc(opcode, mask, lose, flags) \
- { opcode, (mask), ANNUL|(lose), "l", flags|F_DELAYED, v6 }, \
- { opcode, (mask)|ANNUL, (lose), ",a l", flags|F_DELAYED, v6 }
-
-
-#define condfc(fop, cop, mask, flags) \
- brfc(fop, F2(0, 6)|COND(mask), F2(~0, ~6)|COND(~(mask)), flags), \
- brfc(cop, F2(0, 7)|COND(mask), F2(~0, ~7)|COND(~(mask)), flags) \
-
-condfc("fb", "cb", 0x8, 0),
-condfc("fba", "cba", 0x8, F_ALIAS),
-condfc("fbe", "cb0", 0x9, 0),
-condfc("fbg", "cb2", 0x6, 0),
-condfc("fbge", "cb02", 0xb, 0),
-condfc("fbl", "cb1", 0x4, 0),
-condfc("fble", "cb01", 0xd, 0),
-condfc("fblg", "cb12", 0x2, 0),
-condfc("fbn", "cbn", 0x0, 0),
-condfc("fbne", "cb123", 0x1, 0),
-condfc("fbo", "cb012", 0xf, 0),
-condfc("fbu", "cb3", 0x7, 0),
-condfc("fbue", "cb03", 0xa, 0),
-condfc("fbug", "cb23", 0x5, 0),
-condfc("fbuge", "cb023", 0xc, 0),
-condfc("fbul", "cb13", 0x3, 0),
-condfc("fbule", "cb013", 0xe, 0),
-
-#undef condfc
-#undef brfc
-
-{ "jmp", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|RD_G0|ASI(~0), "1+2", F_DELAYED, v6 }, /* jmpl rs1+rs2,%g0 */
-{ "jmp", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|RD_G0|ASI_RS2(~0), "1", F_DELAYED, v6 }, /* jmpl rs1+%g0,%g0 */
-{ "jmp", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RD_G0, "1+i", F_DELAYED, v6 }, /* jmpl rs1+i,%g0 */
-{ "jmp", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RD_G0, "i+1", F_DELAYED, v6 }, /* jmpl i+rs1,%g0 */
-{ "jmp", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RD_G0|RS1_G0, "i", F_DELAYED, v6 }, /* jmpl %g0+i,%g0 */
-
-{ "nop", F2(0, 4), 0xfeffffff, "", 0, v6 }, /* sethi 0, %g0 */
-
-{ "set", F2(0x0, 0x4), F2(~0x0, ~0x4), "Sh,d", F_ALIAS, v6 },
-
-{ "sethi", F2(0x0, 0x4), F2(~0x0, ~0x4), "h,d", 0, v6 },
-
-{ "taddcc", F3(2, 0x20, 0), F3(~2, ~0x20, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "taddcc", F3(2, 0x20, 1), F3(~2, ~0x20, ~1), "1,i,d", 0, v6 },
-{ "taddcc", F3(2, 0x20, 1), F3(~2, ~0x20, ~1), "i,1,d", 0, v6 },
-{ "taddcctv", F3(2, 0x22, 0), F3(~2, ~0x22, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "taddcctv", F3(2, 0x22, 1), F3(~2, ~0x22, ~1), "1,i,d", 0, v6 },
-{ "taddcctv", F3(2, 0x22, 1), F3(~2, ~0x22, ~1), "i,1,d", 0, v6 },
-
-{ "tsubcc", F3(2, 0x21, 0), F3(~2, ~0x21, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "tsubcc", F3(2, 0x21, 1), F3(~2, ~0x21, ~1), "1,i,d", 0, v6 },
-{ "tsubcctv", F3(2, 0x23, 0), F3(~2, ~0x23, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "tsubcctv", F3(2, 0x23, 1), F3(~2, ~0x23, ~1), "1,i,d", 0, v6 },
-
-{ "unimp", F2(0x0, 0x0), 0xffc00000, "n", 0, v6 },
-
-{ "iflush", F3(2, 0x3b, 0), F3(~2, ~0x3b, ~0)|ASI(~0), "1+2", 0, v6 },
-{ "iflush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1), "1+i", 0, v6 },
-{ "iflush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1), "i+1", 0, v6 },
-{ "iflush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1)|RS1_G0, "i", 0, v6 },
-
-{ "xnor", F3(2, 0x07, 0), F3(~2, ~0x07, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "xnor", F3(2, 0x07, 1), F3(~2, ~0x07, ~1), "1,i,d", 0, v6 },
-{ "xnor", F3(2, 0x07, 1), F3(~2, ~0x07, ~1), "i,1,d", 0, v6 },
-{ "xnorcc", F3(2, 0x17, 0), F3(~2, ~0x17, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "xnorcc", F3(2, 0x17, 1), F3(~2, ~0x17, ~1), "1,i,d", 0, v6 },
-{ "xnorcc", F3(2, 0x17, 1), F3(~2, ~0x17, ~1), "i,1,d", 0, v6 },
-{ "xor", F3(2, 0x03, 0), F3(~2, ~0x03, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "xor", F3(2, 0x03, 1), F3(~2, ~0x03, ~1), "1,i,d", 0, v6 },
-{ "xor", F3(2, 0x03, 1), F3(~2, ~0x03, ~1), "i,1,d", 0, v6 },
-{ "xorcc", F3(2, 0x13, 0), F3(~2, ~0x13, ~0)|ASI(~0), "1,2,d", 0, v6 },
-{ "xorcc", F3(2, 0x13, 1), F3(~2, ~0x13, ~1), "1,i,d", 0, v6 },
-{ "xorcc", F3(2, 0x13, 1), F3(~2, ~0x13, ~1), "i,1,d", 0, v6 },
-
-{ "not", F3(2, 0x07, 0), F3(~2, ~0x07, ~0)|ASI(~0), "1,d", F_ALIAS, v6 }, /* xnor rs1,%0,rd */
-{ "not", F3(2, 0x07, 0), F3(~2, ~0x07, ~0)|ASI(~0), "r", F_ALIAS, v6 }, /* xnor rd,%0,rd */
-
-{ "btog", F3(2, 0x03, 0), F3(~2, ~0x03, ~0)|ASI(~0), "2,r", F_ALIAS, v6 }, /* xor rd,rs2,rd */
-{ "btog", F3(2, 0x03, 1), F3(~2, ~0x03, ~1), "i,r", F_ALIAS, v6 }, /* xor rd,i,rd */
-
-{ "fpop1", F3F(2, 0x34, 0), F3F(~2, ~0x34, ~1), "[1+2],d", 0, v6 },
-{ "fpop2", F3F(2, 0x35, 0), F3F(~2, ~0x35, ~1), "[1+2],d", 0, v6 },
-
-/* float-start */
-{ "fdtoi", F3F(2, 0x34, 0x0d2), F3F(~2, ~0x34, ~0x0d2)|RS1_G0, "B,g", 0, v6 },
-{ "fstoi", F3F(2, 0x34, 0x0d1), F3F(~2, ~0x34, ~0x0d1)|RS1_G0, "f,g", 0, v6 },
-
- /* all of these conversions are confused and probably wrong. */
-{ "fitod", F3F(2, 0x34, 0x0c8), F3F(~2, ~0x34, ~0x0c8)|RS1_G0, "f,H", 0, v6 },
-{ "fitos", F3F(2, 0x34, 0x0c4), F3F(~2, ~0x34, ~0x0c4)|RS1_G0, "f,g", 0, v6 },
-
-{ "fitoq", F3F(2, 0x34, 0x0cc), F3F(~2, ~0x34, ~0x0cc)|RS1_G0, "f,J", 0, v8 },
-
-
-{ "fdtoq", F3F(2, 0x34, 0x0ce), F3F(~2, ~0x34, ~0x0ce)|RS1_G0, "B,J", 0, v8 },
-{ "fdtos", F3F(2, 0x34, 0x0c6), F3F(~2, ~0x34, ~0x0c6)|RS1_G0, "B,g", 0, v6 },
-{ "fqtod", F3F(2, 0x34, 0x0cb), F3F(~2, ~0x34, ~0x0cb)|RS1_G0, "R,H", 0, v8 },
-{ "fqtos", F3F(2, 0x34, 0x0c7), F3F(~2, ~0x34, ~0x0c7)|RS1_G0, "R,g", 0, v8 },
-{ "fstod", F3F(2, 0x34, 0x0c9), F3F(~2, ~0x34, ~0x0c9)|RS1_G0, "f,H", 0, v6 },
-{ "fstoq", F3F(2, 0x34, 0x0cd), F3F(~2, ~0x34, ~0x0cd)|RS1_G0, "f,J", 0, v8 },
-
-
-
-
-
-{ "fqtoi", F3F(2, 0x34, 0x0d3), F3F(~2, ~0x34, ~0x0d3)|RS1_G0, "R,g", 0, v8 },
-
-
-{ "fdivd", F3F(2, 0x34, 0x04e), F3F(~2, ~0x34, ~0x04e), "v,B,H", 0, v6 },
-{ "fdivq", F3F(2, 0x34, 0x04f), F3F(~2, ~0x34, ~0x04f), "V,R,J", 0, v8 },
-{ "fdivs", F3F(2, 0x34, 0x04d), F3F(~2, ~0x34, ~0x04d), "e,f,g", 0, v6 },
-{ "fmuld", F3F(2, 0x34, 0x04a), F3F(~2, ~0x34, ~0x04a), "v,B,H", 0, v6 },
-{ "fmulq", F3F(2, 0x34, 0x04b), F3F(~2, ~0x34, ~0x04b), "V,R,J", 0, v8 },
-{ "fmuls", F3F(2, 0x34, 0x049), F3F(~2, ~0x34, ~0x049), "e,f,g", 0, v6 },
-
-{ "fdmulq", F3F(2, 0x34, 0x06e), F3F(~2, ~0x34, ~0x06e), "v,B,J", 0, v8 },
-{ "fsmuld", F3F(2, 0x34, 0x069), F3F(~2, ~0x34, ~0x069), "e,f,H", 0, v8 },
-
-{ "fsqrtd", F3F(2, 0x34, 0x02a), F3F(~2, ~0x34, ~0x02a)|RS1_G0, "B,H", 0, v7 },
-{ "fsqrtq", F3F(2, 0x34, 0x02b), F3F(~2, ~0x34, ~0x02b)|RS1_G0, "R,J", 0, v8 },
-{ "fsqrts", F3F(2, 0x34, 0x029), F3F(~2, ~0x34, ~0x029)|RS1_G0, "f,g", 0, v7 },
-
-{ "fabsq", F3F(2, 0x34, 0x00b), F3F(~2, ~0x34, ~0x00b)|RS1_G0, "R,J", 0, v6 },
-{ "fabss", F3F(2, 0x34, 0x009), F3F(~2, ~0x34, ~0x009)|RS1_G0, "f,g", 0, v6 },
-{ "fmovq", F3F(2, 0x34, 0x003), F3F(~2, ~0x34, ~0x003)|RS1_G0, "R,J", 0, v6 },
-{ "fmovs", F3F(2, 0x34, 0x001), F3F(~2, ~0x34, ~0x001)|RS1_G0, "f,g", 0, v6 },
-{ "fnegq", F3F(2, 0x34, 0x007), F3F(~2, ~0x34, ~0x007)|RS1_G0, "R,J", 0, v6 },
-{ "fnegs", F3F(2, 0x34, 0x005), F3F(~2, ~0x34, ~0x005)|RS1_G0, "f,g", 0, v6 },
-
-
-{ "faddd", F3F(2, 0x34, 0x042), F3F(~2, ~0x34, ~0x042), "v,B,H", 0, v6 },
-{ "faddq", F3F(2, 0x34, 0x043), F3F(~2, ~0x34, ~0x043), "V,R,J", 0, v8 },
-{ "fadds", F3F(2, 0x34, 0x041), F3F(~2, ~0x34, ~0x041), "e,f,g", 0, v6 },
-{ "fsubd", F3F(2, 0x34, 0x046), F3F(~2, ~0x34, ~0x046), "v,B,H", 0, v6 },
-{ "fsubq", F3F(2, 0x34, 0x047), F3F(~2, ~0x34, ~0x047), "V,R,J", 0, v8 },
-{ "fsubs", F3F(2, 0x34, 0x045), F3F(~2, ~0x34, ~0x045), "e,f,g", 0, v6 },
-
-#define CMPFCC(x) (((x)&0x3)<<25)
-
-{ "fcmpd", F3F(2, 0x35, 0x052), F3F(~2, ~0x35, ~0x052)|RS1_G0, "v,B", 0, v6 },
-{ "fcmped", F3F(2, 0x35, 0x056), F3F(~2, ~0x35, ~0x056)|RS1_G0, "v,B", 0, v6 },
-{ "fcmpeq", F3F(2, 0x34, 0x057), F3F(~2, ~0x34, ~0x057), "V,R", 0, v8 },
-{ "fcmpes", F3F(2, 0x35, 0x055), F3F(~2, ~0x35, ~0x055)|RS1_G0, "e,f", 0, v6 },
-{ "fcmpq", F3F(2, 0x34, 0x053), F3F(~2, ~0x34, ~0x053), "V,R", 0, v8 },
-{ "fcmps", F3F(2, 0x35, 0x051), F3F(~2, ~0x35, ~0x051)|RS1_G0, "e,f", 0, v6 },
-
-{ "cpop1", F3(2, 0x36, 0), F3(~2, ~0x36, ~1), "[1+2],d", 0, v6 },
-{ "cpop2", F3(2, 0x37, 0), F3(~2, ~0x37, ~1), "[1+2],d", 0, v6 },
-
-
-
-};
-
-#define NUMOPCODES ((sizeof sparc_opcodes)/(sizeof sparc_opcodes[0]))
-
-/*
- * Local Variables:
- * fill-column: 131
- * comment-column: 0
- * End:
- */
-
-/* end of sparc-opcode.h */
diff --git a/gnu/usr.bin/as/opcode/tahoe.h b/gnu/usr.bin/as/opcode/tahoe.h
deleted file mode 100644
index 72b0082..0000000
--- a/gnu/usr.bin/as/opcode/tahoe.h
+++ /dev/null
@@ -1,247 +0,0 @@
-/* tahoe-opcode.h - tahoe-specific
- * Not part of GAS yet
- *
- * Ported by the State University of New York at Buffalo by the Distributed
- * Computer Systems Lab, Department of Computer Science, 1991. (And by Dale
- * Wiles who was unemployed at the time.)
- */
-
-struct tot_wot /* tahoe opcode table: wot to do with this */
- /* particular opcode */
-{
- char *args; /* how to compile said opcode */
- tahoe_opcodeT code; /* The opcode. */
-};
-
-struct tot /* tahoe opcode text */
-{
- char *name; /* opcode name: lowercase string [key] */
- struct tot_wot detail; /* rest of opcode table [datum] */
-};
-
-static struct tot
-totstrs[] =
-{
-{ "halt", {"", 0x00 } },
-{ "sinf", {"", 0x05 } },
-{ "ldf", {"rl", 0x06 } },
-{ "ldd", {"rq", 0x07 } },
-{ "addb2", {"rbmb", 0x08 } },
-{ "movb", {"rbwb", 0x09 } },
-{ "addw2", {"rwmw", 0x0a } },
-{ "movw", {"rwww", 0x0b } },
-{ "addl2", {"rlml", 0x0c } },
-{ "movl", {"rlwl", 0x0d } },
-{ "bbs", {"rlvlbw", 0x0e } },
-{ "nop", {"", 0x10 } },
-{ "brb", {"bb", 0x11 } },
-{ "brw", {"bw", 0x13 } },
-{ "cosf", {"", 0x15 } },
-{ "lnf", {"rl", 0x16 } },
-{ "lnd", {"rq", 0x17 } },
-{ "addb3", {"rbrbwb", 0x18 } },
- /* cmpb is wrong in the "offical" (what a joke!) text. It's not "rbwb" */
-{ "cmpb", {"rbrb", 0x19 } },
-{ "addw3", {"rwrwww", 0x1a } },
- /* cmpw is wrong in the "offical" text. It's not "rwww" */
-{ "cmpw", {"rwrw", 0x1b } },
-{ "addl3", {"rlrlwl", 0x1c } },
- /* cmpl is wrong in the "offical" text. It's not "rlwl" */
-{ "cmpl", {"rlrl", 0x1d } },
-{ "bbc", {"rlvlbw", 0x1e } },
-{ "rei", {"", 0x20 } },
-{ "bneq", {"bb", 0x21 } },
-{ "bnequ", {"bb", 0x21 } },
-{ "cvtwl", {"rwwl", 0x23 } },
-{ "stf", {"wl", 0x26 } },
-{ "std", {"wq", 0x27 } },
-{ "subb2", {"rbmb", 0x28 } },
-{ "mcomb", {"rbwb", 0x29 } },
-{ "subw2", {"rwmw", 0x2a } },
-{ "mcomw", {"rwww", 0x2b } },
-{ "subl2", {"rlml", 0x2c } },
-{ "mcoml", {"rlwl", 0x2d } },
-{ "emul", {"rlrlrlwq", 0x2e } },
-{ "aoblss", {"rlmlbw", 0x2f } },
-{ "bpt", {"", 0x30 } },
-{ "beql", {"bb", 0x31 } },
-{ "beqlu", {"bb", 0x31 } },
-{ "cvtwb", {"rwwb", 0x33 } },
-{ "logf", {"", 0x35 } },
-{ "cmpf", {"rl", 0x36 } },
-{ "cmpd", {"rq", 0x37 } },
-{ "subb3", {"rbrbwb", 0x38 } },
-{ "bitb", {"rbrb", 0x39 } },
-{ "subw3", {"rwrwww", 0x3a } },
-{ "bitw", {"rwrw", 0x3b } },
-{ "subl3", {"rlrlwl", 0x3c } },
-{ "bitl", {"rlrl", 0x3d } },
-{ "ediv", {"rlrqwlwl", 0x3e } },
-{ "aobleq", {"rlmlbw", 0x3f } },
-{ "ret", {"", 0x40 } },
-{ "bgtr", {"bb", 0x41 } },
-{ "sqrtf", {"", 0x45 } },
-{ "cmpf2", {"rlrl", 0x46 } },
-{ "cmpd2", {"rqrq", 0x47 } },
-{ "shll", {"rbrlwl", 0x48 } },
-{ "clrb", {"wb", 0x49 } },
-{ "shlq", {"rbrqwq", 0x4a } },
-{ "clrw", {"ww", 0x4b } },
-{ "mull2", {"rlml", 0x4c } },
-{ "clrl", {"wl", 0x4d } },
-{ "shal", {"rbrlwl", 0x4e } },
-{ "bleq", {"bb", 0x51 } },
-{ "expf", {"", 0x55 } },
-{ "tstf", {"", 0x56 } },
-{ "tstd", {"", 0x57 } },
-{ "shrl", {"rbrlwl", 0x58 } },
-{ "tstb", {"rb", 0x59 } },
-{ "shrq", {"rbrqwq", 0x5a } },
-{ "tstw", {"rw", 0x5b } },
-{ "mull3", {"rlrlwl", 0x5c } },
-{ "tstl", {"rl", 0x5d } },
-{ "shar", {"rbrlwl", 0x5e } },
-{ "bbssi", {"rlmlbw", 0x5f } },
-{ "ldpctx", {"", 0x60 } },
-{ "pushd", {"", 0x67 } },
-{ "incb", {"mb", 0x69 } },
-{ "incw", {"mw", 0x6b } },
-{ "divl2", {"rlml", 0x6c } },
-{ "incl", {"ml", 0x6d } },
-{ "cvtlb", {"rlwb", 0x6f } },
-{ "svpctx", {"", 0x70 } },
-{ "jmp", {"ab", 0x71 } },
-{ "cvlf", {"rl", 0x76 } },
-{ "cvld", {"rl", 0x77 } },
-{ "decb", {"mb", 0x79 } },
-{ "decw", {"mw", 0x7b } },
-{ "divl3", {"rlrlwl", 0x7c } },
-{ "decl", {"ml", 0x7d } },
-{ "cvtlw", {"rlww", 0x7f } },
-{ "bgeq", {"bb", 0x81 } },
-{ "movs2", {"abab", 0x82 } },
-{ "cvfl", {"wl", 0x86 } },
-{ "cvdl", {"wl", 0x87 } },
-{ "orb2", {"rbmb", 0x88 } },
-{ "cvtbl", {"rbwl", 0x89 } },
-{ "orw2", {"rwmw", 0x8a } },
-{ "bispsw", {"rw", 0x8b } },
-{ "orl2", {"rlml", 0x8c } },
-{ "adwc", {"rlml", 0x8d } },
-{ "adda", {"rlml", 0x8e } },
-{ "blss", {"bb", 0x91 } },
-{ "cmps2", {"abab", 0x92 } },
-{ "ldfd", {"rl", 0x97 } },
-{ "orb3", {"rbrbwb", 0x98 } },
-{ "cvtbw", {"rbww", 0x99 } },
-{ "orw3", {"rwrwww", 0x9a } },
-{ "bicpsw", {"rw", 0x9b } },
-{ "orl3", {"rlrlwl", 0x9c } },
-{ "sbwc", {"rlml", 0x9d } },
-{ "suba", {"rlml", 0x9e } },
-{ "bgtru", {"bb", 0xa1 } },
-{ "cvdf", {"", 0xa6 } },
-{ "andb2", {"rbmb", 0xa8 } },
-{ "movzbl", {"rbwl", 0xa9 } },
-{ "andw2", {"rwmw", 0xaa } },
-{ "loadr", {"rwal", 0xab } },
-{ "andl2", {"rlml", 0xac } },
-{ "mtpr", {"rlrl", 0xad } },
-{ "ffs", {"rlwl", 0xae } },
-{ "blequ", {"bb", 0xb1 } },
-{ "negf", {"", 0xb6 } },
-{ "negd", {"", 0xb7 } },
-{ "andb3", {"rbrbwb", 0xb8 } },
-{ "movzbw", {"rbww", 0xb9 } },
-{ "andw3", {"rwrwww", 0xba } },
-{ "storer", {"rwal", 0xbb } },
-{ "andl3", {"rlrlwl", 0xbc } },
-{ "mfpr", {"rlwl", 0xbd } },
-{ "ffc", {"rlwl", 0xbe } },
-{ "calls", {"rbab", 0xbf } },
-{ "prober", {"rbabrl", 0xc0 } },
-{ "bvc", {"bb", 0xc1 } },
-{ "movs3", {"ababrw", 0xc2 } },
-{ "movzwl", {"rwwl", 0xc3 } },
-{ "addf", {"rl", 0xc6 } },
-{ "addd", {"rq", 0xc7 } },
-{ "xorb2", {"rbmb", 0xc8 } },
-{ "movob", {"rbwb", 0xc9 } },
-{ "xorw2", {"rwmw", 0xca } },
-{ "movow", {"rwww", 0xcb } },
-{ "xorl2", {"rlml", 0xcc } },
-{ "movpsl", {"wl", 0xcd } },
-{ "kcall", {"rw", 0xcf } },
-{ "probew", {"rbabrl", 0xd0 } },
-{ "bvs", {"bb", 0xd1 } },
-{ "cmps3", {"ababrw", 0xd2 } },
-{ "subf", {"rq", 0xd6 } },
-{ "subd", {"rq", 0xd7 } },
-{ "xorb3", {"rbrbwb", 0xd8 } },
-{ "pushb", {"rb", 0xd9 } },
-{ "xorw3", {"rwrwww", 0xda } },
-{ "pushw", {"rw", 0xdb } },
-{ "xorl3", {"rlrlwl", 0xdc } },
-{ "pushl", {"rl", 0xdd } },
-{ "insque", {"abab", 0xe0 } },
-{ "bcs", {"bb", 0xe1 } },
-{ "bgequ", {"bb", 0xe1 } },
-{ "mulf", {"rq", 0xe6 } },
-{ "muld", {"rq", 0xe7 } },
-{ "mnegb", {"rbwb", 0xe8 } },
-{ "movab", {"abwl", 0xe9 } },
-{ "mnegw", {"rwww", 0xea } },
-{ "movaw", {"awwl", 0xeb } },
-{ "mnegl", {"rlwl", 0xec } },
-{ "moval", {"alwl", 0xed } },
-{ "remque", {"ab", 0xf0 } },
-{ "bcc", {"bb", 0xf1 } },
-{ "blssu", {"bb", 0xf1 } },
-{ "divf", {"rq", 0xf6 } },
-{ "divd", {"rq", 0xf7 } },
- /* movblk is really "alalrw" but 'as' won't accept it,
- 'cc' and 'gcc' also produce code this way. */
-{ "movblk", {"", 0xf8 } },
-{ "pushab", {"ab", 0xf9 } },
-{ "pushaw", {"aw", 0xfb } },
-{ "casel", {"rlrlrl", 0xfc } },
-{ "pushal", {"al", 0xfd } },
-{ "callf", {"rbab", 0xfe } },
-{ "", "" } /* empty is end sentinel */
-};
-
-/* These are synthetic instructions, where the assembler will munge
- the addressings modes for you. */
-static struct tot
-synthetic_totstrs[] =
-{
-{ "jr", {"b-", 0x11 } },
-{ "jbr", {"b-", 0x11 } },
-
-{ "jneq", {"b?", 0x21 } },
-{ "jnequ", {"b?", 0x21 } },
-{ "jeql", {"b?", 0x31 } },
-{ "jeqlu", {"b?", 0x31 } },
-{ "jgtr", {"b?", 0x41 } },
-{ "jleq", {"b?", 0x51 } },
-{ "jgeq", {"b?", 0x81 } },
-{ "jlss", {"b?", 0x91 } },
-{ "jgtru", {"b?", 0xa1 } },
-{ "jlequ", {"b?", 0xb1 } },
-{ "jvc", {"b?", 0xc1 } },
-{ "jvs", {"b?", 0xd1 } },
-{ "jcs", {"b?", 0xe1 } },
-{ "jgequ", {"b?", 0xe1 } },
-{ "jcc", {"b?", 0xf1 } },
-{ "jlssu", {"b?", 0xf1 } },
-
-{ "jbs", {"rlvlb!", 0x0e } },
-{ "jbc", {"rlvlb!", 0x1e } },
-
-{ "aojlss", {"rlmlb:", 0x2f } },
-{ "jaoblss", {"rlmlb:", 0x2f } },
-{ "aojleq", {"rlmlb:", 0x3f } },
-{ "jaobleq", {"rlmlb:", 0x3f } },
-{ "jbssi", {"rlmlb:", 0x5f } },
- { "", "" } /* empty is end sentinel */
-};
diff --git a/gnu/usr.bin/as/opcode/vax.h b/gnu/usr.bin/as/opcode/vax.h
deleted file mode 100644
index d604e3f..0000000
--- a/gnu/usr.bin/as/opcode/vax.h
+++ /dev/null
@@ -1,382 +0,0 @@
-/* Vax opcde list.
- Copyright (C) 1989, Free Software Foundation, Inc.
-
-This file is part of GDB and GAS.
-
-GDB and GAS are free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef vax_opcodeT
-#define vax_opcodeT int
-#endif /* no vax_opcodeT */
-
-struct vot_wot /* vax opcode table: wot to do with this */
- /* particular opcode */
-{
- char * args; /* how to compile said opcode */
- vax_opcodeT code; /* op-code (may be > 8 bits!) */
-};
-
-struct vot /* vax opcode text */
-{
- char * name; /* opcode name: lowercase string [key] */
- struct vot_wot detail; /* rest of opcode table [datum] */
-};
-
-#define vot_how args
-#define vot_code code
-#define vot_detail detail
-#define vot_name name
-
-static const struct vot
-votstrs[] =
-{
-{ "halt", {"", 0x00 } },
-{ "nop", {"", 0x01 } },
-{ "rei", {"", 0x02 } },
-{ "bpt", {"", 0x03 } },
-{ "ret", {"", 0x04 } },
-{ "rsb", {"", 0x05 } },
-{ "ldpctx", {"", 0x06 } },
-{ "svpctx", {"", 0x07 } },
-{ "cvtps", {"rwabrwab", 0x08 } },
-{ "cvtsp", {"rwabrwab", 0x09 } },
-{ "index", {"rlrlrlrlrlwl", 0x0a } },
-{ "crc", {"abrlrwab", 0x0b } },
-{ "prober", {"rbrwab", 0x0c } },
-{ "probew", {"rbrwab", 0x0d } },
-{ "insque", {"abab", 0x0e } },
-{ "remque", {"abwl", 0x0f } },
-{ "bsbb", {"bb", 0x10 } },
-{ "brb", {"bb", 0x11 } },
-{ "bneq", {"bb", 0x12 } },
-{ "bnequ", {"bb", 0x12 } },
-{ "beql", {"bb", 0x13 } },
-{ "beqlu", {"bb", 0x13 } },
-{ "bgtr", {"bb", 0x14 } },
-{ "bleq", {"bb", 0x15 } },
-{ "jsb", {"ab", 0x16 } },
-{ "jmp", {"ab", 0x17 } },
-{ "bgeq", {"bb", 0x18 } },
-{ "blss", {"bb", 0x19 } },
-{ "bgtru", {"bb", 0x1a } },
-{ "blequ", {"bb", 0x1b } },
-{ "bvc", {"bb", 0x1c } },
-{ "bvs", {"bb", 0x1d } },
-{ "bcc", {"bb", 0x1e } },
-{ "bgequ", {"bb", 0x1e } },
-{ "blssu", {"bb", 0x1f } },
-{ "bcs", {"bb", 0x1f } },
-{ "addp4", {"rwabrwab", 0x20 } },
-{ "addp6", {"rwabrwabrwab", 0x21 } },
-{ "subp4", {"rwabrwab", 0x22 } },
-{ "subp6", {"rwabrwabrwab", 0x23 } },
-{ "cvtpt", {"rwababrwab", 0x24 } },
-{ "mulp", {"rwabrwabrwab", 0x25 } },
-{ "cvttp", {"rwababrwab", 0x26 } },
-{ "divp", {"rwabrwabrwab", 0x27 } },
-{ "movc3", {"rwabab", 0x28 } },
-{ "cmpc3", {"rwabab", 0x29 } },
-{ "scanc", {"rwababrb", 0x2a } },
-{ "spanc", {"rwababrb", 0x2b } },
-{ "movc5", {"rwabrbrwab", 0x2c } },
-{ "cmpc5", {"rwabrbrwab", 0x2d } },
-{ "movtc", {"rwabrbabrwab", 0x2e } },
-{ "movtuc", {"rwabrbabrwab", 0x2f } },
-{ "bsbw", {"bw", 0x30 } },
-{ "brw", {"bw", 0x31 } },
-{ "cvtwl", {"rwwl", 0x32 } },
-{ "cvtwb", {"rwwb", 0x33 } },
-{ "movp", {"rwabab", 0x34 } },
-{ "cmpp3", {"rwabab", 0x35 } },
-{ "cvtpl", {"rwabwl", 0x36 } },
-{ "cmpp4", {"rwabrwab", 0x37 } },
-{ "editpc", {"rwababab", 0x38 } },
-{ "matchc", {"rwabrwab", 0x39 } },
-{ "locc", {"rbrwab", 0x3a } },
-{ "skpc", {"rbrwab", 0x3b } },
-{ "movzwl", {"rwwl", 0x3c } },
-{ "acbw", {"rwrwmwbw", 0x3d } },
-{ "movaw", {"awwl", 0x3e } },
-{ "pushaw", {"aw", 0x3f } },
-{ "addf2", {"rfmf", 0x40 } },
-{ "addf3", {"rfrfwf", 0x41 } },
-{ "subf2", {"rfmf", 0x42 } },
-{ "subf3", {"rfrfwf", 0x43 } },
-{ "mulf2", {"rfmf", 0x44 } },
-{ "mulf3", {"rfrfwf", 0x45 } },
-{ "divf2", {"rfmf", 0x46 } },
-{ "divf3", {"rfrfwf", 0x47 } },
-{ "cvtfb", {"rfwb", 0x48 } },
-{ "cvtfw", {"rfww", 0x49 } },
-{ "cvtfl", {"rfwl", 0x4a } },
-{ "cvtrfl", {"rfwl", 0x4b } },
-{ "cvtbf", {"rbwf", 0x4c } },
-{ "cvtwf", {"rwwf", 0x4d } },
-{ "cvtlf", {"rlwf", 0x4e } },
-{ "acbf", {"rfrfmfbw", 0x4f } },
-{ "movf", {"rfwf", 0x50 } },
-{ "cmpf", {"rfrf", 0x51 } },
-{ "mnegf", {"rfwf", 0x52 } },
-{ "tstf", {"rf", 0x53 } },
-{ "emodf", {"rfrbrfwlwf", 0x54 } },
-{ "polyf", {"rfrwab", 0x55 } },
-{ "cvtfd", {"rfwd", 0x56 } },
- /* opcode 57 is not defined yet */
-{ "adawi", {"rwmw", 0x58 } },
- /* opcode 59 is not defined yet */
- /* opcode 5a is not defined yet */
- /* opcode 5b is not defined yet */
-{ "insqhi", {"abaq", 0x5c } },
-{ "insqti", {"abaq", 0x5d } },
-{ "remqhi", {"aqwl", 0x5e } },
-{ "remqti", {"aqwl", 0x5f } },
-{ "addd2", {"rdmd", 0x60 } },
-{ "addd3", {"rdrdwd", 0x61 } },
-{ "subd2", {"rdmd", 0x62 } },
-{ "subd3", {"rdrdwd", 0x63 } },
-{ "muld2", {"rdmd", 0x64 } },
-{ "muld3", {"rdrdwd", 0x65 } },
-{ "divd2", {"rdmd", 0x66 } },
-{ "divd3", {"rdrdwd", 0x67 } },
-{ "cvtdb", {"rdwb", 0x68 } },
-{ "cvtdw", {"rdww", 0x69 } },
-{ "cvtdl", {"rdwl", 0x6a } },
-{ "cvtrdl", {"rdwl", 0x6b } },
-{ "cvtbd", {"rbwd", 0x6c } },
-{ "cvtwd", {"rwwd", 0x6d } },
-{ "cvtld", {"rlwd", 0x6e } },
-{ "acbd", {"rdrdmdbw", 0x6f } },
-{ "movd", {"rdwd", 0x70 } },
-{ "cmpd", {"rdrd", 0x71 } },
-{ "mnegd", {"rdwd", 0x72 } },
-{ "tstd", {"rd", 0x73 } },
-{ "emodd", {"rdrbrdwlwd", 0x74 } },
-{ "polyd", {"rdrwab", 0x75 } },
-{ "cvtdf", {"rdwf", 0x76 } },
- /* opcode 77 is not defined yet */
-{ "ashl", {"rbrlwl", 0x78 } },
-{ "ashq", {"rbrqwq", 0x79 } },
-{ "emul", {"rlrlrlwq", 0x7a } },
-{ "ediv", {"rlrqwlwl", 0x7b } },
-{ "clrd", {"wd", 0x7c } },
-{ "clrg", {"wg", 0x7c } },
-{ "clrq", {"wd", 0x7c } },
-{ "movq", {"rqwq", 0x7d } },
-{ "movaq", {"aqwl", 0x7e } },
-{ "movad", {"adwl", 0x7e } },
-{ "pushaq", {"aq", 0x7f } },
-{ "pushad", {"ad", 0x7f } },
-{ "addb2", {"rbmb", 0x80 } },
-{ "addb3", {"rbrbwb", 0x81 } },
-{ "subb2", {"rbmb", 0x82 } },
-{ "subb3", {"rbrbwb", 0x83 } },
-{ "mulb2", {"rbmb", 0x84 } },
-{ "mulb3", {"rbrbwb", 0x85 } },
-{ "divb2", {"rbmb", 0x86 } },
-{ "divb3", {"rbrbwb", 0x87 } },
-{ "bisb2", {"rbmb", 0x88 } },
-{ "bisb3", {"rbrbwb", 0x89 } },
-{ "bicb2", {"rbmb", 0x8a } },
-{ "bicb3", {"rbrbwb", 0x8b } },
-{ "xorb2", {"rbmb", 0x8c } },
-{ "xorb3", {"rbrbwb", 0x8d } },
-{ "mnegb", {"rbwb", 0x8e } },
-{ "caseb", {"rbrbrb", 0x8f } },
-{ "movb", {"rbwb", 0x90 } },
-{ "cmpb", {"rbrb", 0x91 } },
-{ "mcomb", {"rbwb", 0x92 } },
-{ "bitb", {"rbrb", 0x93 } },
-{ "clrb", {"wb", 0x94 } },
-{ "tstb", {"rb", 0x95 } },
-{ "incb", {"mb", 0x96 } },
-{ "decb", {"mb", 0x97 } },
-{ "cvtbl", {"rbwl", 0x98 } },
-{ "cvtbw", {"rbww", 0x99 } },
-{ "movzbl", {"rbwl", 0x9a } },
-{ "movzbw", {"rbww", 0x9b } },
-{ "rotl", {"rbrlwl", 0x9c } },
-{ "acbb", {"rbrbmbbw", 0x9d } },
-{ "movab", {"abwl", 0x9e } },
-{ "pushab", {"ab", 0x9f } },
-{ "addw2", {"rwmw", 0xa0 } },
-{ "addw3", {"rwrwww", 0xa1 } },
-{ "subw2", {"rwmw", 0xa2 } },
-{ "subw3", {"rwrwww", 0xa3 } },
-{ "mulw2", {"rwmw", 0xa4 } },
-{ "mulw3", {"rwrwww", 0xa5 } },
-{ "divw2", {"rwmw", 0xa6 } },
-{ "divw3", {"rwrwww", 0xa7 } },
-{ "bisw2", {"rwmw", 0xa8 } },
-{ "bisw3", {"rwrwww", 0xa9 } },
-{ "bicw2", {"rwmw", 0xaa } },
-{ "bicw3", {"rwrwww", 0xab } },
-{ "xorw2", {"rwmw", 0xac } },
-{ "xorw3", {"rwrwww", 0xad } },
-{ "mnegw", {"rwww", 0xae } },
-{ "casew", {"rwrwrw", 0xaf } },
-{ "movw", {"rwww", 0xb0 } },
-{ "cmpw", {"rwrw", 0xb1 } },
-{ "mcomw", {"rwww", 0xb2 } },
-{ "bitw", {"rwrw", 0xb3 } },
-{ "clrw", {"ww", 0xb4 } },
-{ "tstw", {"rw", 0xb5 } },
-{ "incw", {"mw", 0xb6 } },
-{ "decw", {"mw", 0xb7 } },
-{ "bispsw", {"rw", 0xb8 } },
-{ "bicpsw", {"rw", 0xb9 } },
-{ "popr", {"rw", 0xba } },
-{ "pushr", {"rw", 0xbb } },
-{ "chmk", {"rw", 0xbc } },
-{ "chme", {"rw", 0xbd } },
-{ "chms", {"rw", 0xbe } },
-{ "chmu", {"rw", 0xbf } },
-{ "addl2", {"rlml", 0xc0 } },
-{ "addl3", {"rlrlwl", 0xc1 } },
-{ "subl2", {"rlml", 0xc2 } },
-{ "subl3", {"rlrlwl", 0xc3 } },
-{ "mull2", {"rlml", 0xc4 } },
-{ "mull3", {"rlrlwl", 0xc5 } },
-{ "divl2", {"rlml", 0xc6 } },
-{ "divl3", {"rlrlwl", 0xc7 } },
-{ "bisl2", {"rlml", 0xc8 } },
-{ "bisl3", {"rlrlwl", 0xc9 } },
-{ "bicl2", {"rlml", 0xca } },
-{ "bicl3", {"rlrlwl", 0xcb } },
-{ "xorl2", {"rlml", 0xcc } },
-{ "xorl3", {"rlrlwl", 0xcd } },
-{ "mnegl", {"rlwl", 0xce } },
-{ "casel", {"rlrlrl", 0xcf } },
-{ "movl", {"rlwl", 0xd0 } },
-{ "cmpl", {"rlrl", 0xd1 } },
-{ "mcoml", {"rlwl", 0xd2 } },
-{ "bitl", {"rlrl", 0xd3 } },
-{ "clrf", {"wf", 0xd4 } },
-{ "clrl", {"wl", 0xd4 } },
-{ "tstl", {"rl", 0xd5 } },
-{ "incl", {"ml", 0xd6 } },
-{ "decl", {"ml", 0xd7 } },
-{ "adwc", {"rlml", 0xd8 } },
-{ "sbwc", {"rlml", 0xd9 } },
-{ "mtpr", {"rlrl", 0xda } },
-{ "mfpr", {"rlwl", 0xdb } },
-{ "movpsl", {"wl", 0xdc } },
-{ "pushl", {"rl", 0xdd } },
-{ "moval", {"alwl", 0xde } },
-{ "movaf", {"afwl", 0xde } },
-{ "pushal", {"al", 0xdf } },
-{ "pushaf", {"af", 0xdf } },
-{ "bbs", {"rlabbb", 0xe0 } },
-{ "bbc", {"rlabbb", 0xe1 } },
-{ "bbss", {"rlabbb", 0xe2 } },
-{ "bbcs", {"rlabbb", 0xe3 } },
-{ "bbsc", {"rlabbb", 0xe4 } },
-{ "bbcc", {"rlabbb", 0xe5 } },
-{ "bbssi", {"rlabbb", 0xe6 } },
-{ "bbcci", {"rlabbb", 0xe7 } },
-{ "blbs", {"rlbb", 0xe8 } },
-{ "blbc", {"rlbb", 0xe9 } },
-{ "ffs", {"rlrbvbwl", 0xea } },
-{ "ffc", {"rlrbvbwl", 0xeb } },
-{ "cmpv", {"rlrbvbrl", 0xec } },
-{ "cmpzv", {"rlrbvbrl", 0xed } },
-{ "extv", {"rlrbvbwl", 0xee } },
-{ "extzv", {"rlrbvbwl", 0xef } },
-{ "insv", {"rlrlrbvb", 0xf0 } },
-{ "acbl", {"rlrlmlbw", 0xf1 } },
-{ "aoblss", {"rlmlbb", 0xf2 } },
-{ "aobleq", {"rlmlbb", 0xf3 } },
-{ "sobgeq", {"mlbb", 0xf4 } },
-{ "sobgtr", {"mlbb", 0xf5 } },
-{ "cvtlb", {"rlwb", 0xf6 } },
-{ "cvtlw", {"rlww", 0xf7 } },
-{ "ashp", {"rbrwabrbrwab", 0xf8 } },
-{ "cvtlp", {"rlrwab", 0xf9 } },
-{ "callg", {"abab", 0xfa } },
-{ "calls", {"rlab", 0xfb } },
-{ "xfc", {"", 0xfc } },
- /* undefined opcodes here */
-{ "cvtdh", {"rdwh", 0x32fd } },
-{ "cvtgf", {"rgwh", 0x33fd } },
-{ "addg2", {"rgmg", 0x40fd } },
-{ "addg3", {"rgrgwg", 0x41fd } },
-{ "subg2", {"rgmg", 0x42fd } },
-{ "subg3", {"rgrgwg", 0x43fd } },
-{ "mulg2", {"rgmg", 0x44fd } },
-{ "mulg3", {"rgrgwg", 0x45fd } },
-{ "divg2", {"rgmg", 0x46fd } },
-{ "divg3", {"rgrgwg", 0x47fd } },
-{ "cvtgb", {"rgwb", 0x48fd } },
-{ "cvtgw", {"rgww", 0x49fd } },
-{ "cvtgl", {"rgwl", 0x4afd } },
-{ "cvtrgl", {"rgwl", 0x4bfd } },
-{ "cvtbg", {"rbwg", 0x4cfd } },
-{ "cvtwg", {"rwwg", 0x4dfd } },
-{ "cvtlg", {"rlwg", 0x4efd } },
-{ "acbg", {"rgrgmgbw", 0x4ffd } },
-{ "movg", {"rgwg", 0x50fd } },
-{ "cmpg", {"rgrg", 0x51fd } },
-{ "mnegg", {"rgwg", 0x52fd } },
-{ "tstg", {"rg", 0x53fd } },
-{ "emodg", {"rgrwrgwlwg", 0x54fd } },
-{ "polyg", {"rgrwab", 0x55fd } },
-{ "cvtgh", {"rgwh", 0x56fd } },
- /* undefined opcodes here */
-{ "addh2", {"rhmh", 0x60fd } },
-{ "addh3", {"rhrhwh", 0x61fd } },
-{ "subh2", {"rhmh", 0x62fd } },
-{ "subh3", {"rhrhwh", 0x63fd } },
-{ "mulh2", {"rhmh", 0x64fd } },
-{ "mulh3", {"rhrhwh", 0x65fd } },
-{ "divh2", {"rhmh", 0x66fd } },
-{ "divh3", {"rhrhwh", 0x67fd } },
-{ "cvthb", {"rhwb", 0x68fd } },
-{ "cvthw", {"rhww", 0x69fd } },
-{ "cvthl", {"rhwl", 0x6afd } },
-{ "cvtrhl", {"rhwl", 0x6bfd } },
-{ "cvtbh", {"rbwh", 0x6cfd } },
-{ "cvtwh", {"rwwh", 0x6dfd } },
-{ "cvtlh", {"rlwh", 0x6efd } },
-{ "acbh", {"rhrhmhbw", 0x6ffd } },
-{ "movh", {"rhwh", 0x70fd } },
-{ "cmph", {"rhrh", 0x71fd } },
-{ "mnegh", {"rhwh", 0x72fd } },
-{ "tsth", {"rh", 0x73fd } },
-{ "emodh", {"rhrwrhwlwh", 0x74fd } },
-{ "polyh", {"rhrwab", 0x75fd } },
-{ "cvthg", {"rhwg", 0x76fd } },
- /* undefined opcodes here */
-{ "clrh", {"wh", 0x7cfd } },
-{ "clro", {"wo", 0x7cfd } },
-{ "movo", {"rowo", 0x7dfd } },
-{ "movah", {"ahwl", 0x7efd } },
-{ "movao", {"aowl", 0x7efd } },
-{ "pushah", {"ah", 0x7ffd } },
-{ "pushao", {"ao", 0x7ffd } },
- /* undefined opcodes here */
-{ "cvtfh", {"rfwh", 0x98fd } },
-{ "cvtfg", {"rfwg", 0x99fd } },
- /* undefined opcodes here */
-{ "cvthf", {"rhwf", 0xf6fd } },
-{ "cvthd", {"rhwd", 0xf7fd } },
- /* undefined opcodes here */
-{ "bugl", {"rl", 0xfdff } },
-{ "bugw", {"rw", 0xfeff } },
- /* undefined opcodes here */
-
-{ "" , "" } /* empty is end sentinel */
-
-}; /* votstrs */
-
-/* end: vax.opcode.h */
diff --git a/gnu/usr.bin/as/output-file.c b/gnu/usr.bin/as/output-file.c
deleted file mode 100644
index 87b4db9..0000000
--- a/gnu/usr.bin/as/output-file.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* output-file.c - Deal with the output file
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Confines all details of emitting object bytes to this module.
- * All O/S specific crocks should live here.
- * What we lose in "efficiency" we gain in modularity.
- * Note we don't need to #include the "as.h" file. No common coupling!
- */
-
-/* note that we do need config info. xoxorich. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include <stdio.h>
-
-#include "as.h"
-
-#include "output-file.h"
-#ifdef BFD_HEADERS
-#include "bfd.h"
-bfd *stdoutput;
-void output_file_create(name)
-char *name;
-{
- if (name[0] == '-' && name[1] == '\0') {
- as_perror("FATAL: Can't open a bfd on stdout %s ", name);
- }
- else if ( ! (stdoutput = bfd_openw( name, TARGET_FORMAT )) )
- {
- as_perror ("FATAL: Can't create %s", name);
- exit(42);
- }
- bfd_set_format(stdoutput, bfd_object);
-}
-/* output_file_create() */
-
-
-void output_file_close(filename)
-char *filename;
-{
- /* Close the bfd without getting bfd to write out anything by itself */
- if ( bfd_close_all_done( stdoutput ) == 0 )
- {
- as_perror ("FATAL: Can't close %s\n", filename);
- exit(42);
- }
- stdoutput = NULL; /* Trust nobody! */
-} /* output_file_close() */
-
-void output_file_append(where, length, filename)
-char *where;
-long length;
-char *filename;
-{
- abort(); /* Never do this */
-}
-
-#else
-
-static FILE *stdoutput;
-
-void output_file_create(name)
-char *name;
-{
- if (name[0] == '-' && name[1] == '\0')
- stdoutput=stdout;
- else if (!(stdoutput = fopen(name, "wb"))) {
- as_perror("FATAL: Can't create %s", name);
- exit(42);
- }
-} /* output_file_create() */
-
-
-
-void output_file_close(filename)
-char *filename;
-{
- if (EOF == fclose(stdoutput)) {
- as_perror ("FATAL: Can't close %s", filename);
- exit(42);
- }
- stdoutput = NULL; /* Trust nobody! */
-} /* output_file_close() */
-
-void output_file_append(where, length, filename)
-char *where;
-long length;
-char *filename;
-{
-
- for (; length; length--, where++) {
- (void) putc(*where, stdoutput);
- if (ferror(stdoutput))
- /* if ( EOF == (putc( *where, stdoutput )) ) */
- {
- as_perror("Failed to emit an object byte", filename);
- as_fatal("Can't continue");
- }
- }
-} /* output_file_append() */
-#endif
-
-/* end of output-file.c */
diff --git a/gnu/usr.bin/as/output-file.h b/gnu/usr.bin/as/output-file.h
deleted file mode 100644
index 641b599..0000000
--- a/gnu/usr.bin/as/output-file.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* This file is output-file.h
-
- Copyright (C) 1987-1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-#ifdef __STDC__
-
-void output_file_append(char *where, long length, char *filename);
-void output_file_close(char *filename);
-void output_file_create(char *name);
-
-#else /* __STDC__ */
-
-void output_file_append();
-void output_file_close();
-void output_file_create();
-
-#endif /* __STDC__ */
-
-
-/* end of output-file.h */
diff --git a/gnu/usr.bin/as/read.c b/gnu/usr.bin/as/read.c
deleted file mode 100644
index 9e8db59..0000000
--- a/gnu/usr.bin/as/read.c
+++ /dev/null
@@ -1,2384 +0,0 @@
-/* read.c - read a source file -
-
- Copyright (C) 1986, 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id: read.c,v 1.11 1997/04/29 02:11:48 jdp Exp $";
-#endif
-
-#define MASK_CHAR (0xFF) /* If your chars aren't 8 bits, you will
- change this a bit. But then, GNU isn't
- spozed to run on your machine anyway.
- (RMS is so shortsighted sometimes.)
- */
-
-#define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
-/* This is the largest known floating point */
-/* format (for now). It will grow when we */
-/* do 4361 style flonums. */
-
-
-/* Routines that read assembler source text to build spagetti in memory. */
-/* Another group of these functions is in the as-expr.c module */
-
-#include "as.h"
-
-#include "obstack.h"
-
-char *input_line_pointer; /*->next char of source file to parse. */
-
-#ifndef NOP_OPCODE
-# define NOP_OPCODE 0x00
-#endif
-
-#if BITS_PER_CHAR != 8
-The following table is indexed by [ (char) ] and will break if
- a char does not have exactly 256 states (hopefully 0:255!) !
-#endif
-
-#ifdef ALLOW_ATSIGN
-#define AT 2
-#else
-#define AT 0
-#endif
-
-#ifndef PIC
- const
-#endif
- char /* used by is_... macros. our ctype[] */
- lex_type[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
- 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
- AT, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, /* PQRSTUVWXYZ[\]^_ */
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, /* pqrstuvwxyz{|}~. */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
-
-
-/*
- * In: a character.
- * Out: 1 if this character ends a line.
- */
-#define _ (0)
-char is_end_of_line[256] = {
-#ifdef CR_EOL
- _, _, _, _, _, _, _, _, _, _,99, _, _, 99, _, _,/* @abcdefghijklmno */
-#else
- _, _, _, _, _, _, _, _, _, _,99, _, _, _, _, _, /* @abcdefghijklmno */
-#endif
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _,99, _, _, _, _, /* 0123456789:;<=>? */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ /* */
- };
-#undef _
-
-/* Functions private to this file. */
-
-extern const char line_comment_chars[];
-const char line_separator_chars[1];
-
-static char *buffer; /* 1st char of each buffer of lines is here. */
-static char *buffer_limit; /*->1 + last char in buffer. */
-
-static char *bignum_low; /* Lowest char of bignum. */
-static char *bignum_limit; /* 1st illegal address of bignum. */
-static char *bignum_high; /* Highest char of bignum. */
-/* May point to (bignum_start-1). */
-/* Never >= bignum_limit. */
-static char *old_buffer = 0; /* JF a hack */
-static char *old_input;
-static char *old_limit;
-
-/* Variables for handling include file directory list. */
-
-char **include_dirs; /* List of pointers to directories to
- search for .include's */
-int include_dir_count; /* How many are in the list */
-int include_dir_maxlen = 1; /* Length of longest in list */
-
-#ifndef WORKING_DOT_WORD
-struct broken_word *broken_words;
-int new_broken_words = 0;
-#endif
-
-#if __STDC__ == 1
-
-static char *demand_copy_string(int *lenP);
-int is_it_end_of_statement(void);
-unsigned int next_char_of_string(void);
-static segT get_known_segmented_expression(expressionS *expP);
-static void grow_bignum(void);
-static void pobegin(void);
-void stringer(int append_zero);
-
-#else /* __STDC__ */
-
-static char *demand_copy_string();
-int is_it_end_of_statement();
-unsigned int next_char_of_string();
-static segT get_known_segmented_expression();
-static void grow_bignum();
-static void pobegin();
-void stringer();
-
-#endif /* not __STDC__ */
-
-extern int listing;
-
-
-void
- read_begin()
-{
- const char *p;
-
- pobegin();
- obj_read_begin_hook();
-
- obstack_begin(&notes, 5000);
- obstack_begin(&cond_obstack, 960);
-
-#define BIGNUM_BEGIN_SIZE (16)
- bignum_low = xmalloc((long)BIGNUM_BEGIN_SIZE);
- bignum_limit = bignum_low + BIGNUM_BEGIN_SIZE;
-
- /* Use machine dependent syntax */
- for (p = line_separator_chars; *p; p++)
- is_end_of_line[*p] = 1;
- /* Use more. FIXME-SOMEDAY. */
-}
-
-/* set up pseudo-op tables */
-
-struct hash_control *
- po_hash = NULL; /* use before set up: NULL->address error */
-
-static const pseudo_typeS
- potable[] =
-{
- { "abort", s_abort, 0 },
- { "align", s_align_ptwo, 0 },
- { "ascii", stringer, 0 },
- { "asciz", stringer, 1 },
- /* block */
- { "byte", cons, 1 },
- { "comm", s_comm, 0 },
- { "data", s_data, 0 },
- /* dim */
- { "double", float_cons, 'd' },
- /* dsect */
-#ifdef NO_LISTING
- { "eject", s_ignore, 0 }, /* Formfeed listing */
-#else
- { "eject", listing_eject, 0 }, /* Formfeed listing */
-#endif /* NO_LISTING */
- { "else", s_else, 0 },
- { "end", s_end, 0 },
- { "endif", s_endif, 0 },
- /* endef */
- { "equ", s_set, 0 },
- /* err */
- /* extend */
- { "extern", s_ignore, 0 }, /* We treat all undef as ext */
- { "appline", s_app_line, 0 },
- { "appfile", s_app_file, 1 },
- { "file", s_app_file, 0 },
- { "fill", s_fill, 0 },
- { "float", float_cons, 'f' },
- { "global", s_globl, 0 },
- { "globl", s_globl, 0 },
- { "hword", cons, 2 },
- { "if", s_if, 0 },
- { "ifdef", s_ifdef, 0 },
- { "ifeqs", s_ifeqs, 0 },
- { "ifndef", s_ifdef, 1 },
- { "ifnes", s_ifeqs, 1 },
- { "ifnotdef", s_ifdef, 1 },
- { "include", s_include, 0 },
- { "int", cons, 4 },
- { "lcomm", s_lcomm, 0 },
-#ifdef NO_LISTING
- { "lflags", s_ignore, 0 }, /* Listing flags */
- { "list", s_ignore, 1 }, /* Turn listing on */
-#else
- { "lflags", listing_flags, 0 }, /* Listing flags */
- { "list", listing_list, 1 }, /* Turn listing on */
-#endif /* NO_LISTING */
- { "long", cons, 4 },
- { "lsym", s_lsym, 0 },
-#ifdef NO_LISTING
- { "nolist", s_ignore, 0 }, /* Turn listing off */
-#else
- { "nolist", listing_list, 0 }, /* Turn listing off */
-#endif /* NO_LISTING */
- { "octa", big_cons, 16 },
- { "org", s_org, 0 },
- { "p2align", s_align_ptwo, 0 },
-#ifdef NO_LISTING
- { "psize", s_ignore, 0 }, /* set paper size */
-#else
- { "psize", listing_psize, 0 }, /* set paper size */
-#endif /* NO_LISTING */
- /* print */
- { "quad", big_cons, 8 },
-#ifdef NO_LISTING
- { "sbttl", s_ignore, 1 }, /* Subtitle of listing */
-#else
- { "sbttl", listing_title, 1 }, /* Subtitle of listing */
-#endif /* NO_LISTING */
- /* scl */
- /* sect */
-#ifndef TC_M88K
- { "set", s_set, 0 },
-#endif /* TC_M88K */
- { "short", cons, 2 },
- { "single", float_cons, 'f' },
- /* size */
- { "space", s_space, 0 },
- /* tag */
- { "text", s_text, 0 },
-#ifdef NO_LISTING
- { "title", s_ignore, 0 }, /* Listing title */
-#else
- { "title", listing_title, 0 }, /* Listing title */
-#endif /* NO_LISTING */
- /* type */
- /* use */
- /* val */
- { "word", cons, 2 },
- { NULL} /* end sentinel */
-};
-
-static void pobegin() {
- char *errtxt; /* error text */
- const pseudo_typeS * pop;
-
- po_hash = hash_new();
-
- /* Do the target-specific pseudo ops. */
- for (pop = md_pseudo_table; pop->poc_name; pop++) {
- errtxt = hash_insert(po_hash, pop->poc_name, (char *)pop);
- if (errtxt && *errtxt) {
- as_fatal("error constructing md pseudo-op table");
- } /* on error */
- } /* for each op */
-
- /* Now object specific. Skip any that were in the target table. */
- for (pop = obj_pseudo_table; pop->poc_name; pop++) {
- errtxt = hash_insert(po_hash, pop->poc_name, (char *) pop);
- if (errtxt && *errtxt) {
- if (!strcmp(errtxt, "exists")) {
-#ifdef DIE_ON_OVERRIDES
- as_fatal("pseudo op \".%s\" overridden.\n", pop->poc_name);
-#endif /* DIE_ON_OVERRIDES */
- continue; /* OK if target table overrides. */
- } else {
- as_fatal("error constructing obj pseudo-op table");
- } /* if overridden */
- } /* on error */
- } /* for each op */
-
- /* Now portable ones. Skip any that we've seen already. */
- for (pop = potable; pop->poc_name; pop++) {
- errtxt = hash_insert(po_hash, pop->poc_name, (char *) pop);
- if (errtxt && *errtxt) {
- if (!strcmp (errtxt, "exists")) {
-#ifdef DIE_ON_OVERRIDES
- as_fatal("pseudo op \".%s\" overridden.\n", pop->poc_name);
-#endif /* DIE_ON_OVERRIDES */
- continue; /* OK if target table overrides. */
- } else {
- as_fatal("error constructing obj pseudo-op table");
- } /* if overridden */
- } /* on error */
- } /* for each op */
-
- return;
-} /* pobegin() */
-
-#define HANDLE_CONDITIONAL_ASSEMBLY() \
- if (ignore_input ()) \
-{ \
- while (! is_end_of_line[*input_line_pointer++]) \
- if (input_line_pointer == buffer_limit) \
- break; \
- continue; \
- }
-
-
-/* read_a_source_file()
- *
- * We read the file, putting things into a web that
- * represents what we have been reading.
- */
-void read_a_source_file(name)
-char *name;
-{
- register char c;
- register char * s; /* string of symbol, '\0' appended */
- register int temp;
- pseudo_typeS *pop = NULL;
-
- buffer = input_scrub_new_file(name);
-
- listing_file(name);
- listing_newline("");
-
- while ((buffer_limit = input_scrub_next_buffer(&input_line_pointer)) != 0) { /* We have another line to parse. */
- know(buffer_limit[-1] == '\n'); /* Must have a sentinel. */
- contin: /* JF this goto is my fault I admit it. Someone brave please re-write
- the whole input section here? Pleeze??? */
- while (input_line_pointer < buffer_limit) { /* We have more of this buffer to parse. */
-
- /*
- * We now have input_line_pointer->1st char of next line.
- * If input_line_pointer[-1] == '\n' then we just
- * scanned another line: so bump line counters.
- */
- if (input_line_pointer[-1] == '\n') {
- bump_line_counters();
- } /* just passed a newline */
-
-
-
- /*
- * We are at the begining of a line, or similar place.
- * We expect a well-formed assembler statement.
- * A "symbol-name:" is a statement.
- *
- * Depending on what compiler is used, the order of these tests
- * may vary to catch most common case 1st.
- * Each test is independent of all other tests at the (top) level.
- * PLEASE make a compiler that doesn't use this assembler.
- * It is crufty to waste a compiler's time encoding things for this
- * assembler, which then wastes more time decoding it.
- * (And communicating via (linear) files is silly!
- * If you must pass stuff, please pass a tree!)
- */
- if ((c = *input_line_pointer++) == '\t' || c == ' ' || c == '\f' || c == 0) {
- c = *input_line_pointer++;
- }
- know(c != ' '); /* No further leading whitespace. */
- LISTING_NEWLINE();
- /*
- * C is the 1st significant character.
- * Input_line_pointer points after that character.
- */
- if (is_name_beginner(c)) { /* want user-defined label or pseudo/opcode */
- HANDLE_CONDITIONAL_ASSEMBLY();
-
- s = input_line_pointer - 1;
- c = get_symbol_end(); /* name's delimiter */
- /*
- * C is character after symbol.
- * That character's place in the input line is now '\0'.
- * S points to the beginning of the symbol.
- * [In case of pseudo-op, s->'.'.]
- * Input_line_pointer->'\0' where c was.
- */
- if (c == ':') {
- colon(s); /* user-defined label */
- * input_line_pointer ++ = ':'; /* Put ':' back for error messages' sake. */
- /* Input_line_pointer->after ':'. */
- SKIP_WHITESPACE();
-
-
- } else if (c == '=' || input_line_pointer[1] == '=') { /* JF deal with FOO=BAR */
- equals(s);
- demand_empty_rest_of_line();
- } else { /* expect pseudo-op or machine instruction */
- if (*s == '.'
-#ifdef NO_DOT_PSEUDOS
- || (pop= (pseudo_typeS *) hash_find(po_hash, s))
-#endif
- ) {
- /*
- * PSEUDO - OP.
- *
- * WARNING: c has next char, which may be end-of-line.
- * We lookup the pseudo-op table with s+1 because we
- * already know that the pseudo-op begins with a '.'.
- */
-
-#ifdef NO_DOT_PSEUDOS
- if (*s == '.')
-#endif
- pop = (pseudo_typeS *) hash_find(po_hash, s+1);
-
- /* Print the error msg now, while we still can */
- if (!pop) {
- as_bad("Unknown pseudo-op: `%s'",s);
- *input_line_pointer = c;
- s_ignore(0);
- break;
- }
-
- /* Put it back for error messages etc. */
- *input_line_pointer = c;
- /* The following skip of whitespace is compulsory. */
- /* A well shaped space is sometimes all that separates keyword from operands. */
- if (c == ' ' || c == '\t') {
- input_line_pointer++;
- } /* Skip seperator after keyword. */
- /*
- * Input_line is restored.
- * Input_line_pointer->1st non-blank char
- * after pseudo-operation.
- */
- if (!pop) {
- ignore_rest_of_line();
- break;
- } else {
- (*pop->poc_handler)(pop->poc_val);
- } /* if we have one */
- } else { /* machine instruction */
- /* WARNING: c has char, which may be end-of-line. */
- /* Also: input_line_pointer->`\0` where c was. */
- * input_line_pointer = c;
- while (!is_end_of_line[*input_line_pointer]) {
- input_line_pointer++;
- }
- c = *input_line_pointer;
- *input_line_pointer = '\0';
- md_assemble(s); /* Assemble 1 instruction. */
- *input_line_pointer++ = c;
- /* We resume loop AFTER the end-of-line from this instruction */
- } /* if (*s == '.') */
-
- } /* if c == ':' */
- continue;
- } /* if (is_name_beginner(c) */
-
-
- if (is_end_of_line[c]) {
- continue;
- } /* empty statement */
-
-
- if (isdigit(c)) { /* local label ("4:") */
- HANDLE_CONDITIONAL_ASSEMBLY ();
-
- temp = c - '0';
-#ifdef LOCAL_LABELS_DOLLAR
- if (*input_line_pointer == '$')
- input_line_pointer++;
-#endif
- if (*input_line_pointer++ == ':') {
- local_colon (temp);
- } else {
- as_bad("Spurious digit %d.", temp);
- input_line_pointer -- ;
- ignore_rest_of_line();
- }
- continue;
- } /* local label ("4:") */
-
- if (c && strchr(line_comment_chars, c)) { /* Its a comment. Better say APP or NO_APP */
- char *ends;
- char *new_buf;
- char *new_tmp;
- int new_length;
- char *tmp_buf = 0;
- extern char *scrub_string, *scrub_last_string;
-
- bump_line_counters();
- s = input_line_pointer;
- if (strncmp(s,"APP\n",4))
- continue; /* We ignore it */
- s += 4;
-
- ends = strstr(s,"#NO_APP\n");
-
- if (!ends) {
- int tmp_len;
- int num;
-
- /* The end of the #APP wasn't in this buffer. We
- keep reading in buffers until we find the #NO_APP
- that goes with this #APP There is one. The specs
- guarentee it... */
- tmp_len = buffer_limit - s;
- tmp_buf = xmalloc(tmp_len);
- memcpy(tmp_buf, s, tmp_len);
- do {
- new_tmp = input_scrub_next_buffer(&buffer);
- if (!new_tmp)
- break;
- else
- buffer_limit = new_tmp;
- input_line_pointer = buffer;
- ends = strstr(buffer,"#NO_APP\n");
- if (ends)
- num = ends - buffer;
- else
- num = buffer_limit - buffer;
-
- tmp_buf = xrealloc(tmp_buf, tmp_len + num);
- memcpy(tmp_buf + tmp_len, buffer, num);
- tmp_len += num;
- } while (!ends);
-
- input_line_pointer = ends ? ends + 8 : NULL;
-
- s = tmp_buf;
- ends = s + tmp_len;
-
- } else {
- input_line_pointer = ends + 8;
- }
- new_buf=xmalloc(100);
- new_length=100;
- new_tmp=new_buf;
-
- scrub_string = s;
- scrub_last_string = ends;
- for (;;) {
- int ch;
-
- ch = do_scrub_next_char(scrub_from_string, scrub_to_string);
- if (ch == EOF) break;
- *new_tmp++ = ch;
- if (new_tmp == new_buf + new_length) {
- new_buf = xrealloc(new_buf, new_length + 100);
- new_tmp = new_buf + new_length;
- new_length += 100;
- }
- }
-
- if (tmp_buf)
- free(tmp_buf);
- old_buffer = buffer;
- old_input = input_line_pointer;
- old_limit = buffer_limit;
- buffer = new_buf;
- input_line_pointer = new_buf;
- buffer_limit = new_tmp;
- continue;
- }
-
- HANDLE_CONDITIONAL_ASSEMBLY();
-
- /* as_warn("Junk character %d.",c); Now done by ignore_rest */
- input_line_pointer--; /* Report unknown char as ignored. */
- ignore_rest_of_line();
- } /* while (input_line_pointer<buffer_limit) */
- if (old_buffer) {
- bump_line_counters();
- if (old_input != 0) {
- buffer=old_buffer;
- input_line_pointer=old_input;
- buffer_limit=old_limit;
- old_buffer = 0;
- goto contin;
- }
- }
- } /* while (more buffers to scan) */
- input_scrub_close(); /* Close the input file */
-
-} /* read_a_source_file() */
-
-void s_abort() {
- as_fatal(".abort detected. Abandoning ship.");
-} /* s_abort() */
-
-/* For machines where ".align 4" means align to a 4 byte boundary. */
-void s_align_bytes(arg)
-int arg;
-{
- register unsigned int temp;
- register long temp_fill;
- unsigned int i = 0;
- unsigned long max_alignment = 1 << 15;
-
- if (is_end_of_line[*input_line_pointer])
- temp = arg; /* Default value from pseudo-op table */
- else
- temp = get_absolute_expression();
-
- if (temp > max_alignment) {
- as_bad("Alignment too large: %d. assumed.", temp = max_alignment);
- }
-
- /*
- * For the sparc, `.align (1<<n)' actually means `.align n'
- * so we have to convert it.
- */
- if (temp != 0) {
- for (i = 0; (temp & 1) == 0; temp >>= 1, ++i)
- ;
- }
- if (temp != 1)
- as_bad("Alignment not a power of 2");
-
- temp = i;
-
- if (*input_line_pointer == ',') {
- input_line_pointer ++;
- temp_fill = get_absolute_expression();
- } else {
- temp_fill = NOP_OPCODE;
- }
- /* Only make a frag if we HAVE to... */
- if (temp && ! need_pass_2)
- frag_align(temp, (int)temp_fill);
-
- demand_empty_rest_of_line();
-} /* s_align_bytes() */
-
-/* For machines where ".align 4" means align to 2**4 boundary. */
-void s_align_ptwo() {
- register int temp;
- register long temp_fill;
- long max_alignment = 15;
-
- temp = get_absolute_expression();
- if (temp > max_alignment)
- as_bad("Alignment too large: %d. assumed.", temp = max_alignment);
- else if (temp < 0) {
- as_bad("Alignment negative. 0 assumed.");
- temp = 0;
- }
- if (*input_line_pointer == ',') {
- input_line_pointer ++;
- temp_fill = get_absolute_expression();
- } else
- temp_fill = NOP_OPCODE;
- /* Only make a frag if we HAVE to... */
- if (temp && ! need_pass_2)
- frag_align (temp, (int)temp_fill);
-
- record_alignment(now_seg, temp);
-
- demand_empty_rest_of_line();
-} /* s_align_ptwo() */
-
-void s_comm() {
- register char *name;
- register char c;
- register char *p;
- register int temp;
- register symbolS *symbolP;
-
- name = input_line_pointer;
- c = get_symbol_end();
- /* just after name is now '\0' */
- p = input_line_pointer;
- *p = c;
- SKIP_WHITESPACE();
- if (*input_line_pointer != ',') {
- as_bad("Expected comma after symbol-name: rest of line ignored.");
- ignore_rest_of_line();
- return;
- }
- input_line_pointer ++; /* skip ',' */
- if ((temp = get_absolute_expression()) < 0) {
- as_warn(".COMMon length (%d.) <0! Ignored.", temp);
- ignore_rest_of_line();
- return;
- }
- *p = 0;
- symbolP = symbol_find_or_make(name);
- *p = c;
- if (S_IS_DEFINED(symbolP)) {
- as_bad("Ignoring attempt to re-define symbol");
- ignore_rest_of_line();
- return;
- }
- if (S_GET_VALUE(symbolP)) {
- if (S_GET_VALUE(symbolP) != temp)
- as_bad("Length of .comm \"%s\" is already %d. Not changed to %d.",
- S_GET_NAME(symbolP),
- S_GET_VALUE(symbolP),
- temp);
- } else {
- S_SET_VALUE(symbolP, temp);
- S_SET_EXTERNAL(symbolP);
- }
-#ifdef OBJ_VMS
- if ( (!temp) || !flagseen['1'])
- S_GET_OTHER(symbolP) = const_flag;
-#endif /* not OBJ_VMS */
- know(symbolP->sy_frag == &zero_address_frag);
- demand_empty_rest_of_line();
-} /* s_comm() */
-
-void
- s_data()
-{
- register int temp;
-
- temp = get_absolute_expression();
- subseg_new (SEG_DATA, (subsegT)temp);
-
-#ifdef OBJ_VMS
- const_flag = 0;
-#endif /* not OBJ_VMS */
- demand_empty_rest_of_line();
-}
-
-/* Handle the .appfile pseudo-op. This is automatically generated by
- do_scrub_next_char when a preprocessor # line comment is seen with
- a file name. This default definition may be overridden by the
- object or CPU specific pseudo-ops. This function is also the
- default definition for .file; the APPFILE argument is 1 for
- .appfile, 0 for .file. */
-
-void s_app_file(appfile)
- int appfile;
-{
- register char *s;
- int length;
-
- /* Some assemblers tolerate immediately following '"' */
- if ((s = demand_copy_string(&length)) != 0) {
- /* If this is a fake .appfile, a fake newline was inserted
- * into the buffer. Passing -2 to new_logical_line tells it
- * to account for it.
- */
- new_logical_line (s, appfile ? -2 : -1);
- demand_empty_rest_of_line();
-#ifdef LISTING
- if (listing)
- listing_source_file (s);
-#endif
- }
-#ifdef OBJ_COFF
- c_dot_file_symbol(s);
-#endif /* OBJ_COFF */
-} /* s_app_file() */
-
-/* Handle the .appline pseudo-op. This is automatically generated by
- do_scrub_next_char when a preprocessor # line comment is seen.
- This default definition may be overridden by the object or CPU
- specific pseudo-ops. */
-
-void
-s_app_line (ignore)
- int ignore;
-{
- int l;
-
- /* The given number is that of the next line. */
- l = get_absolute_expression () - 1;
- new_logical_line ((char *) NULL, l);
-#ifdef LISTING
- if (listing)
- listing_source_line (l);
-#endif
- demand_empty_rest_of_line ();
-}
-
-void s_fill() {
- long temp_repeat;
- long temp_size;
- register long temp_fill;
- char *p;
-
- if (get_absolute_expression_and_terminator(& temp_repeat) != ',') {
- input_line_pointer --; /* Backup over what was not a ','. */
- as_bad("Expect comma after rep-size in .fill:");
- ignore_rest_of_line();
- return;
- }
- if (get_absolute_expression_and_terminator(& temp_size) != ',') {
- input_line_pointer --; /* Backup over what was not a ','. */
- as_bad("Expected comma after size in .fill");
- ignore_rest_of_line();
- return;
- }
- /*
- * This is to be compatible with BSD 4.2 AS, not for any rational reason.
- */
-#define BSD_FILL_SIZE_CROCK_8 (8)
- if (temp_size > BSD_FILL_SIZE_CROCK_8) {
- as_bad(".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8);
- temp_size = BSD_FILL_SIZE_CROCK_8 ;
- } if (temp_size < 0) {
- as_warn("Size negative: .fill ignored.");
- temp_size = 0;
- } else if (temp_repeat <= 0) {
- as_warn("Repeat < 0, .fill ignored");
- temp_size = 0;
- }
- temp_fill = get_absolute_expression();
- if (temp_size && !need_pass_2) {
- p = frag_var(rs_fill, (int)temp_size, (int)temp_size, (relax_substateT)0, (symbolS *)0, temp_repeat, (char *)0);
- memset(p, '\0', (int) temp_size);
- /*
- * The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX flavoured AS.
- * The following bizzare behaviour is to be compatible with above.
- * I guess they tried to take up to 8 bytes from a 4-byte expression
- * and they forgot to sign extend. Un*x Sux.
- */
-#define BSD_FILL_SIZE_CROCK_4 (4)
- md_number_to_chars (p, temp_fill, temp_size > BSD_FILL_SIZE_CROCK_4 ? BSD_FILL_SIZE_CROCK_4 : (int)temp_size);
- /*
- * Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
- * but emits no error message because it seems a legal thing to do.
- * It is a degenerate case of .fill but could be emitted by a compiler.
- */
- }
- demand_empty_rest_of_line();
-}
-
-void s_globl() {
- register char *name;
- register int c;
- register symbolS * symbolP;
-
- do {
- name = input_line_pointer;
- c = get_symbol_end();
- symbolP = symbol_find_or_make(name);
- * input_line_pointer = c;
- SKIP_WHITESPACE();
- S_SET_EXTERNAL(symbolP);
- if (c == ',') {
- input_line_pointer++;
- SKIP_WHITESPACE();
- if (*input_line_pointer == '\n')
- c='\n';
- }
- } while (c == ',');
- demand_empty_rest_of_line();
-} /* s_globl() */
-
-void s_lcomm(needs_align)
-int needs_align; /* 1 if this was a ".bss" directive, which may require
- * a 3rd argument (alignment).
- * 0 if it was an ".lcomm" (2 args only)
- */
-{
- register char *name;
- register char c;
- register char *p;
- register int temp;
- register symbolS * symbolP;
- const int max_alignment = 15;
- int align = 0;
-
- name = input_line_pointer;
- c = get_symbol_end();
- p = input_line_pointer;
- *p = c;
- SKIP_WHITESPACE();
- if (*input_line_pointer != ',') {
- as_bad("Expected comma after name");
- ignore_rest_of_line();
- return;
- }
-
- ++input_line_pointer;
-
- if (*input_line_pointer == '\n') {
- as_bad("Missing size expression");
- return;
- }
-
- if ((temp = get_absolute_expression()) < 0) {
- as_warn("BSS length (%d.) <0! Ignored.", temp);
- ignore_rest_of_line();
- return;
- }
-
- if (needs_align) {
- align = 0;
- SKIP_WHITESPACE();
- if (*input_line_pointer != ',') {
- as_bad("Expected comma after size");
- ignore_rest_of_line();
- return;
- }
- input_line_pointer++;
- SKIP_WHITESPACE();
- if (*input_line_pointer == '\n') {
- as_bad("Missing alignment");
- return;
- }
- align = get_absolute_expression();
- if (align > max_alignment){
- align = max_alignment;
- as_warn("Alignment too large: %d. assumed.", align);
- } else if (align < 0) {
- align = 0;
- as_warn("Alignment negative. 0 assumed.");
- }
- record_alignment(SEG_BSS, align);
- } /* if needs align */
-
- *p = 0;
- symbolP = symbol_find_or_make(name);
- *p = c;
-
- if (
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
- S_GET_OTHER(symbolP) == 0 &&
- S_GET_DESC(symbolP) == 0 &&
-#endif /* OBJ_AOUT or OBJ_BOUT */
- (((S_GET_SEGMENT(symbolP) == SEG_BSS) && (S_GET_VALUE(symbolP) == local_bss_counter))
- || (!S_IS_DEFINED(symbolP) && S_GET_VALUE(symbolP) == 0))) {
- if (needs_align){
- /* Align */
- align = ~ ((~0) << align); /* Convert to a mask */
- local_bss_counter =
- (local_bss_counter + align) & (~align);
- }
-
- S_SET_VALUE(symbolP, local_bss_counter);
- S_SET_SEGMENT(symbolP, SEG_BSS);
-#ifdef OBJ_COFF
- /* The symbol may already have been created with a preceding
- * ".globl" directive -- be careful not to step on storage
- * class in that case. Otherwise, set it to static.
- */
- if (S_GET_STORAGE_CLASS(symbolP) != C_EXT){
- S_SET_STORAGE_CLASS(symbolP, C_STAT);
- }
-#endif /* OBJ_COFF */
- symbolP->sy_frag = &bss_address_frag;
- local_bss_counter += temp;
- } else {
- as_bad("Ignoring attempt to re-define symbol from %d. to %d.",
- S_GET_VALUE(symbolP), local_bss_counter);
- }
- demand_empty_rest_of_line();
-
- return;
-} /* s_lcomm() */
-
-void
- s_long()
-{
- cons(4);
-}
-
-void
- s_int()
-{
- cons(4);
-}
-
-void s_lsym() {
- register char *name;
- register char c;
- register char *p;
- register segT segment;
- expressionS exp;
- register symbolS *symbolP;
-
- /* we permit ANY defined expression: BSD4.2 demands constants */
- name = input_line_pointer;
- c = get_symbol_end();
- p = input_line_pointer;
- *p = c;
- SKIP_WHITESPACE();
- if (* input_line_pointer != ',') {
- *p = 0;
- as_bad("Expected comma after name \"%s\"", name);
- *p = c;
- ignore_rest_of_line();
- return;
- }
- input_line_pointer ++;
- segment = expression(& exp);
- if (segment != SEG_ABSOLUTE && !SEG_NORMAL(segment) &&
- segment != SEG_REGISTER) {
- as_bad("Bad expression: %s", segment_name(segment));
- ignore_rest_of_line();
- return;
- }
- *p = 0;
- symbolP = symbol_find_or_make(name);
-
- /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0
- && symbolP->sy_desc == 0) out of this test
- because coff doesn't have those fields, and I
- can't see when they'd ever be tripped. I don't
- think I understand why they were here so I may
- have introduced a bug. As recently as 1.37 didn't
- have this test anyway. xoxorich. */
-
- if (S_GET_SEGMENT(symbolP) == SEG_UNKNOWN
- && S_GET_VALUE(symbolP) == 0) {
- /* The name might be an undefined .global symbol; be
- sure to keep the "external" bit. */
- S_SET_SEGMENT(symbolP, segment);
- S_SET_VALUE(symbolP, (valueT)(exp.X_add_number));
- } else {
- as_bad("Symbol %s already defined", name);
- }
- *p = c;
- demand_empty_rest_of_line();
-} /* s_lsym() */
-
-void s_org() {
- register segT segment;
- expressionS exp;
- register long temp_fill;
- register char *p;
- /*
- * Don't believe the documentation of BSD 4.2 AS.
- * There is no such thing as a sub-segment-relative origin.
- * Any absolute origin is given a warning, then assumed to be segment-relative.
- * Any segmented origin expression ("foo+42") had better be in the right
- * segment or the .org is ignored.
- *
- * BSD 4.2 AS warns if you try to .org backwards. We cannot because we
- * never know sub-segment sizes when we are reading code.
- * BSD will crash trying to emit -ve numbers of filler bytes in certain
- * .orgs. We don't crash, but see as-write for that code.
- */
- /*
- * Don't make frag if need_pass_2 == 1.
- */
- segment = get_known_segmented_expression(&exp);
- if (*input_line_pointer == ',') {
- input_line_pointer ++;
- temp_fill = get_absolute_expression();
- } else
- temp_fill = 0;
- if (! need_pass_2) {
- if (segment != now_seg && segment != SEG_ABSOLUTE)
- as_bad("Invalid segment \"%s\". Segment \"%s\" assumed.",
- segment_name(segment), segment_name(now_seg));
- p = frag_var (rs_org, 1, 1, (relax_substateT)0, exp.X_add_symbol,
- exp.X_add_number, (char *)0);
- * p = temp_fill;
- } /* if (ok to make frag) */
- demand_empty_rest_of_line();
-} /* s_org() */
-
-void s_set() {
- register char *name;
- register char delim;
- register char *end_name;
- register symbolS *symbolP;
-
- /*
- * Especial apologies for the random logic:
- * this just grew, and could be parsed much more simply!
- * Dean in haste.
- */
- name = input_line_pointer;
- delim = get_symbol_end();
- end_name = input_line_pointer;
- *end_name = delim;
- SKIP_WHITESPACE();
-
- if (*input_line_pointer != ',') {
- *end_name = 0;
- as_bad("Expected comma after name \"%s\"", name);
- *end_name = delim;
- ignore_rest_of_line();
- return;
- }
-
- input_line_pointer ++;
- *end_name = 0;
-
- if (name[0] == '.' && name[1] == '\0') {
- /* Turn '. = mumble' into a .org mumble */
- register segT segment;
- expressionS exp;
- register char *ptr;
-
- segment = get_known_segmented_expression(& exp);
-
- if (!need_pass_2) {
- if (segment != now_seg && segment != SEG_ABSOLUTE)
- as_bad("Invalid segment \"%s\". Segment \"%s\" assumed.",
- segment_name(segment),
- segment_name (now_seg));
- ptr = frag_var(rs_org, 1, 1, (relax_substateT)0, exp.X_add_symbol,
- exp.X_add_number, (char *)0);
- *ptr= 0;
- } /* if (ok to make frag) */
-
- *end_name = delim;
- return;
- }
-
- if ((symbolP = symbol_find(name)) == NULL
- && (symbolP = md_undefined_symbol(name)) == NULL) {
- symbolP = symbol_new(name,
- SEG_UNKNOWN,
- 0,
- &zero_address_frag);
-#ifdef OBJ_COFF
- /* "set" symbols are local unless otherwise specified. */
- SF_SET_LOCAL(symbolP);
-#endif /* OBJ_COFF */
-
- } /* make a new symbol */
-
- symbol_table_insert(symbolP);
-
- *end_name = delim;
- pseudo_set(symbolP);
- demand_empty_rest_of_line();
-} /* s_set() */
-
-void s_size() {
- register char *name;
- register char c;
- register char *p;
- register int temp;
- register symbolS *symbolP;
- expressionS *exp;
- segT seg;
-
- SKIP_WHITESPACE();
- name = input_line_pointer;
- c = get_symbol_end();
- /* just after name is now '\0' */
- p = input_line_pointer;
- *p = c;
- SKIP_WHITESPACE();
- if (*input_line_pointer != ',') {
- as_bad("Expected comma after symbol-name: rest of line ignored.");
- ignore_rest_of_line();
- return;
- }
- input_line_pointer ++; /* skip ',' */
- if ((exp = (expressionS *)malloc(sizeof(expressionS))) == NULL) {
- as_bad("Virtual memory exhausted");
- return;
- }
- switch (get_known_segmented_expression(exp)) {
- case SEG_ABSOLUTE:
- break;
- case SEG_DIFFERENCE:
- if (exp->X_add_symbol == NULL || exp->X_subtract_symbol == NULL
- || S_GET_SEGMENT(exp->X_add_symbol) !=
- S_GET_SEGMENT(exp->X_subtract_symbol)) {
- as_bad("Illegal .size expression");
- ignore_rest_of_line();
- return;
- }
- break;
- default:
- as_bad("Illegal .size expression");
- ignore_rest_of_line();
- return;
- }
- *p = 0;
- symbolP = symbol_find_or_make(name);
- *p = c;
- if (symbolP->sy_sizexp) {
- as_warn("\"%s\" already has a size", S_GET_NAME(symbolP));
- } else
- symbolP->sy_sizexp = (void *)exp;
-
- demand_empty_rest_of_line();
-} /* s_size() */
-
-void s_type() {
- register char *name, *type;
- register char c, c1;
- register char *p;
- register symbolS *symbolP;
- int aux;
-
- SKIP_WHITESPACE();
- name = input_line_pointer;
- c = get_symbol_end();
- /* just after name is now '\0' */
- p = input_line_pointer;
- *p = c;
- SKIP_WHITESPACE();
- if (*input_line_pointer != ',') {
- as_bad("Expected comma after symbol-name: rest of line ignored.");
- ignore_rest_of_line();
- return;
- }
- input_line_pointer ++; /* skip ',' */
- SKIP_WHITESPACE();
- if (*input_line_pointer != TYPE_OPERAND_FMT) {
- as_bad("Expected `%c' as start of operand: rest of line ignored.", TYPE_OPERAND_FMT);
- ignore_rest_of_line();
- return;
- }
- input_line_pointer ++; /* skip '@' */
- type = input_line_pointer;
- c1 = get_symbol_end();
- if (strcmp(type, "function") == 0) {
- aux = AUX_FUNC;
- } else if (strcmp(type, "object") == 0) {
- aux = AUX_OBJECT;
- } else {
- as_warn("Unrecognized .type operand: \"%s\": rest of line ignored.",
- type);
- ignore_rest_of_line();
- return;
- }
- *input_line_pointer = c1;
-
- *p = 0;
- symbolP = symbol_find_or_make(name);
- *p = c;
-
- if (symbolP->sy_aux && symbolP->sy_aux != aux) {
- as_bad("Type of \"%s\" is already %d. Not changed to %d.",
- S_GET_NAME(symbolP), symbolP->sy_aux, aux);
- } else
- symbolP->sy_aux = aux;
-
- demand_empty_rest_of_line();
-} /* s_type() */
-
-void s_weak() {
- register char *name;
- register int c;
- register symbolS * symbolP;
-
- do {
- name = input_line_pointer;
- c = get_symbol_end();
- symbolP = symbol_find_or_make(name);
- * input_line_pointer = c;
- SKIP_WHITESPACE();
- S_SET_EXTERNAL(symbolP);
- symbolP->sy_bind = BIND_WEAK;
- if (c == ',') {
- input_line_pointer++;
- SKIP_WHITESPACE();
- if (*input_line_pointer == '\n')
- c='\n';
- }
- } while (c == ',');
- demand_empty_rest_of_line();
-} /* s_weak() */
-
-void s_space() {
- long temp_repeat;
- register long temp_fill;
- register char *p;
-
- /* Just like .fill, but temp_size = 1 */
- if (get_absolute_expression_and_terminator(& temp_repeat) == ',') {
- temp_fill = get_absolute_expression();
- } else {
- input_line_pointer --; /* Backup over what was not a ','. */
- temp_fill = 0;
- }
- if (temp_repeat <= 0) {
- as_warn("Repeat < 0, .space ignored");
- ignore_rest_of_line();
- return;
- }
- if (! need_pass_2) {
- p = frag_var (rs_fill, 1, 1, (relax_substateT)0, (symbolS *)0,
- temp_repeat, (char *)0);
- * p = temp_fill;
- }
- demand_empty_rest_of_line();
-} /* s_space() */
-
-void
- s_text()
-{
- register int temp;
-
- temp = get_absolute_expression();
- subseg_new (SEG_TEXT, (subsegT)temp);
- demand_empty_rest_of_line();
-} /* s_text() */
-
-
-/*(JF was static, but can't be if machine dependent pseudo-ops are to use it */
-
-void demand_empty_rest_of_line() {
- SKIP_WHITESPACE();
- if (is_end_of_line[*input_line_pointer]) {
- input_line_pointer++;
- } else {
- ignore_rest_of_line();
- }
- /* Return having already swallowed end-of-line. */
-} /* Return pointing just after end-of-line. */
-
-void
- ignore_rest_of_line() /* For suspect lines: gives warning. */
-{
- if (!is_end_of_line[*input_line_pointer])
- {
- if (isprint(*input_line_pointer))
- as_bad("Rest of line ignored. First ignored character is `%c'.",
- *input_line_pointer);
- else
- as_bad("Rest of line ignored. First ignored character valued 0x%x.",
- *input_line_pointer);
- while (input_line_pointer < buffer_limit
- && !is_end_of_line[*input_line_pointer])
- {
- input_line_pointer ++;
- }
- }
- input_line_pointer ++; /* Return pointing just after end-of-line. */
- know(is_end_of_line[input_line_pointer[-1]]);
-}
-
-/*
- * pseudo_set()
- *
- * In: Pointer to a symbol.
- * Input_line_pointer->expression.
- *
- * Out: Input_line_pointer->just after any whitespace after expression.
- * Tried to set symbol to value of expression.
- * Will change symbols type, value, and frag;
- * May set need_pass_2 == 1.
- */
-void
- pseudo_set (symbolP)
-symbolS * symbolP;
-{
- expressionS exp;
- register segT segment;
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
- int ext;
-#endif /* OBJ_AOUT or OBJ_BOUT */
-
- know(symbolP); /* NULL pointer is logic error. */
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
- ext=S_IS_EXTERNAL(symbolP);
-#endif /* OBJ_AOUT or OBJ_BOUT */
-
- if ((segment = expression(& exp)) == SEG_ABSENT)
- {
- as_bad("Missing expression: absolute 0 assumed");
- exp.X_seg = SEG_ABSOLUTE;
- exp.X_add_number = 0;
- }
-
- switch (segment)
- {
- case SEG_BIG:
- as_bad("%s number invalid. Absolute 0 assumed.",
- exp.X_add_number > 0 ? "Bignum" : "Floating-Point");
- S_SET_SEGMENT(symbolP, SEG_ABSOLUTE);
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
- ext ? S_SET_EXTERNAL(symbolP) :
- S_CLEAR_EXTERNAL(symbolP);
-#endif /* OBJ_AOUT or OBJ_BOUT */
- S_SET_VALUE(symbolP, 0);
- symbolP->sy_frag = & zero_address_frag;
- break;
-
- case SEG_ABSENT:
- as_warn("No expression: Using absolute 0");
- S_SET_SEGMENT(symbolP, SEG_ABSOLUTE);
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
- ext ? S_SET_EXTERNAL(symbolP) :
- S_CLEAR_EXTERNAL(symbolP);
-#endif /* OBJ_AOUT or OBJ_BOUT */
- S_SET_VALUE(symbolP, 0);
- symbolP->sy_frag = & zero_address_frag;
- break;
-
- case SEG_DIFFERENCE:
- if (exp.X_add_symbol && exp.X_subtract_symbol
- && (S_GET_SEGMENT(exp.X_add_symbol) ==
- S_GET_SEGMENT(exp.X_subtract_symbol))) {
- if (exp.X_add_symbol->sy_frag != exp.X_subtract_symbol->sy_frag) {
- as_bad("Unknown expression: symbols %s and %s are in different frags.",
- S_GET_NAME(exp.X_add_symbol), S_GET_NAME(exp.X_subtract_symbol));
- need_pass_2++;
- }
- exp.X_add_number+=S_GET_VALUE(exp.X_add_symbol) -
- S_GET_VALUE(exp.X_subtract_symbol);
- } else
- as_bad("Complex expression. Absolute segment assumed.");
- case SEG_ABSOLUTE:
- S_SET_SEGMENT(symbolP, SEG_ABSOLUTE);
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
- ext ? S_SET_EXTERNAL(symbolP) :
- S_CLEAR_EXTERNAL(symbolP);
-#endif /* OBJ_AOUT or OBJ_BOUT */
- S_SET_VALUE(symbolP, exp.X_add_number);
- symbolP->sy_frag = & zero_address_frag;
- break;
-
- default:
- know(SEG_NORMAL(segment));
- S_SET_SEGMENT(symbolP, segment);
-#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
- if (ext) {
- S_SET_EXTERNAL(symbolP);
- } else {
- S_CLEAR_EXTERNAL(symbolP);
- } /* if external */
-#endif /* OBJ_AOUT or OBJ_BOUT */
-
- S_SET_VALUE(symbolP, exp.X_add_number + S_GET_VALUE(exp.X_add_symbol));
- symbolP->sy_frag = exp.X_add_symbol->sy_frag;
- symbolP->sy_aux = exp.X_add_symbol->sy_aux;
- break;
-
- case SEG_PASS1: /* Not an error. Just try another pass. */
- symbolP->sy_forward=exp.X_add_symbol;
- as_bad("Unknown expression");
- know(need_pass_2 == 1);
- break;
-
- case SEG_UNKNOWN:
- symbolP->sy_forward=exp.X_add_symbol;
- /* as_warn("unknown symbol"); */
- /* need_pass_2 = 1; */
- break;
-
-
-
- }
-}
-
-/*
- * cons()
- *
- * CONStruct more frag of .bytes, or .words etc.
- * Should need_pass_2 be 1 then emit no frag(s).
- * This understands EXPRESSIONS, as opposed to big_cons().
- *
- * Bug (?)
- *
- * This has a split personality. We use expression() to read the
- * value. We can detect if the value won't fit in a byte or word.
- * But we can't detect if expression() discarded significant digits
- * in the case of a long. Not worth the crocks required to fix it.
- */
-
-/* worker to do .byte etc statements */
-/* clobbers input_line_pointer, checks */
-/* end-of-line. */
-void cons(nbytes)
-register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */
-{
- register char c;
- register long mask; /* High-order bits we will left-truncate, */
- /* but includes sign bit also. */
- register long get; /* what we get */
- register long use; /* get after truncation. */
- register long unmask; /* what bits we will store */
- register char * p;
- register segT segment;
- expressionS exp;
-
- /*
- * Input_line_pointer->1st char after pseudo-op-code and could legally
- * be a end-of-line. (Or, less legally an eof - which we cope with.)
- */
- /* JF << of >= number of bits in the object is undefined. In particular
- SPARC (Sun 4) has problems */
-
- if (nbytes >= sizeof(long)) {
- mask = 0;
- } else {
- mask = ~0 << (BITS_PER_CHAR * nbytes); /* Don't store these bits. */
- } /* bigger than a long */
-
- unmask = ~mask; /* Do store these bits. */
-
-#ifdef NEVER
- "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
- mask = ~ (unmask >> 1); /* Includes sign bit now. */
-#endif
-
- /*
- * The following awkward logic is to parse ZERO or more expressions,
- * comma seperated. Recall an expression includes its leading &
- * trailing blanks. We fake a leading ',' if there is (supposed to
- * be) a 1st expression, and keep demanding 1 expression for each ','.
- */
- if (is_it_end_of_statement()) {
- c = 0; /* Skip loop. */
- input_line_pointer++; /* Matches end-of-loop 'correction'. */
- } else {
- c = ',';
- } /* if the end else fake it */
-
- /* Do loop. */
- while (c == ',') {
-#ifdef WANT_BITFIELDS
- unsigned int bits_available = BITS_PER_CHAR * nbytes;
- /* used for error messages and rescanning */
- char *hold = input_line_pointer;
-#endif /* WANT_BITFIELDS */
-
- /* At least scan over the expression. */
- segment = expression(&exp);
-
-#ifdef WANT_BITFIELDS
- /* Some other assemblers, (eg, asm960), allow
- bitfields after ".byte" as w:x,y:z, where w and
- y are bitwidths and x and y are values. They
- then pack them all together. We do a little
- better in that we allow them in words, longs,
- etc. and we'll pack them in target byte order
- for you.
-
- The rules are: pack least significat bit first,
- if a field doesn't entirely fit, put it in the
- next unit. Overflowing the bitfield is
- explicitly *not* even a warning. The bitwidth
- should be considered a "mask".
-
- FIXME-SOMEDAY: If this is considered generally
- useful, this logic should probably be reworked.
- xoxorich. */
-
- if (*input_line_pointer == ':') { /* bitfields */
- long value = 0;
-
- for (;;) {
- unsigned long width;
-
- if (*input_line_pointer != ':') {
- input_line_pointer = hold;
- break;
- } /* next piece is not a bitfield */
-
- /* In the general case, we can't allow
- full expressions with symbol
- differences and such. The relocation
- entries for symbols not defined in this
- assembly would require arbitrary field
- widths, positions, and masks which most
- of our current object formats don't
- support.
-
- In the specific case where a symbol
- *is* defined in this assembly, we
- *could* build fixups and track it, but
- this could lead to confusion for the
- backends. I'm lazy. I'll take any
- SEG_ABSOLUTE. I think that means that
- you can use a previous .set or
- .equ type symbol. xoxorich. */
-
- if (segment == SEG_ABSENT) {
- as_warn("Using a bit field width of zero.");
- exp.X_add_number = 0;
- segment = SEG_ABSOLUTE;
- } /* implied zero width bitfield */
-
- if (segment != SEG_ABSOLUTE) {
- *input_line_pointer = '\0';
- as_bad("Field width \"%s\" too complex for a bitfield.\n", hold);
- *input_line_pointer = ':';
- demand_empty_rest_of_line();
- return;
- } /* too complex */
-
- if ((width = exp.X_add_number) > (BITS_PER_CHAR * nbytes)) {
- as_warn("Field width %d too big to fit in %d bytes: truncated to %d bits.",
- width, nbytes, (BITS_PER_CHAR * nbytes));
- width = BITS_PER_CHAR * nbytes;
- } /* too big */
-
- if (width > bits_available) {
- /* FIXME-SOMEDAY: backing up and
- reparsing is wasteful */
- input_line_pointer = hold;
- exp.X_add_number = value;
- break;
- } /* won't fit */
-
- hold = ++input_line_pointer; /* skip ':' */
-
- if ((segment = expression(&exp)) != SEG_ABSOLUTE) {
- char cache = *input_line_pointer;
-
- *input_line_pointer = '\0';
- as_bad("Field value \"%s\" too complex for a bitfield.\n", hold);
- *input_line_pointer = cache;
- demand_empty_rest_of_line();
- return;
- } /* too complex */
-
- value |= (~(-1 << width) & exp.X_add_number)
- << ((BITS_PER_CHAR * nbytes) - bits_available);
-
- if ((bits_available -= width) == 0
- || is_it_end_of_statement()
- || *input_line_pointer != ',') {
- break;
- } /* all the bitfields we're gonna get */
-
- hold = ++input_line_pointer;
- segment = expression(&exp);
- } /* forever loop */
-
- exp.X_add_number = value;
- segment = SEG_ABSOLUTE;
- } /* if looks like a bitfield */
-#endif /* WANT_BITFIELDS */
-
- if (!need_pass_2) { /* Still worthwhile making frags. */
-
- /* Don't call this if we are going to junk this pass anyway! */
- know(segment != SEG_PASS1);
-
- if (segment == SEG_DIFFERENCE && exp.X_add_symbol == NULL) {
- as_bad("Subtracting symbol \"%s\"(segment\"%s\") is too hard. Absolute segment assumed.",
- S_GET_NAME(exp.X_subtract_symbol),
- segment_name(S_GET_SEGMENT(exp.X_subtract_symbol)));
- segment = SEG_ABSOLUTE;
- /* Leave exp.X_add_number alone. */
- }
-
- p = frag_more(nbytes);
-
- switch (segment) {
- case SEG_BIG:
- as_bad("%s number invalid. Absolute 0 assumed.",
- exp.X_add_number > 0 ? "Bignum" : "Floating-Point");
- md_number_to_chars (p, (long)0, nbytes);
- break;
-
- case SEG_ABSENT:
- as_warn("0 assumed for missing expression");
- exp.X_add_number = 0;
- know(exp.X_add_symbol == NULL);
- /* fall into SEG_ABSOLUTE */
- case SEG_ABSOLUTE:
- get = exp.X_add_number;
- use = get & unmask;
- if ((get & mask) && (get & mask) != mask)
- { /* Leading bits contain both 0s & 1s. */
- as_warn("Value 0x%x truncated to 0x%x.", get, use);
- }
- md_number_to_chars (p, use, nbytes); /* put bytes in right order. */
- break;
-
- case SEG_DIFFERENCE:
-#ifndef WORKING_DOT_WORD
- if (nbytes == 2) {
- struct broken_word *x;
-
- x = (struct broken_word *) xmalloc(sizeof(struct broken_word));
- x->next_broken_word = broken_words;
- broken_words = x;
- x->frag = frag_now;
- x->word_goes_here = p;
- x->dispfrag = 0;
- x->add = exp.X_add_symbol;
- x->sub = exp.X_subtract_symbol;
- x->addnum = exp.X_add_number;
- x->added = 0;
- new_broken_words++;
- break;
- }
- /* Else Fall through into... */
-#endif
- default:
- case SEG_UNKNOWN:
-#ifdef TC_NS32K
- fix_new_ns32k(frag_now, p - frag_now->fr_literal, nbytes,
- exp.X_add_symbol, exp.X_subtract_symbol,
- exp.X_add_number, 0, 0, 2, 0, 0, RELOC_32);
-#else
-#ifdef PIC
- fix_new(frag_now, p - frag_now->fr_literal, nbytes,
- exp.X_add_symbol, exp.X_subtract_symbol,
- exp.X_add_number, 0, RELOC_32,
- exp.X_got_symbol);
-#else
- fix_new(frag_now, p - frag_now->fr_literal, nbytes,
- exp.X_add_symbol, exp.X_subtract_symbol,
- exp.X_add_number, 0, RELOC_32);
-#endif
-#endif /* TC_NS32K */
- break;
- } /* switch (segment) */
- } /* if (!need_pass_2) */
- c = *input_line_pointer++;
- } /* while (c == ',') */
- input_line_pointer--; /* Put terminator back into stream. */
- demand_empty_rest_of_line();
-} /* cons() */
-
-/*
- * big_cons()
- *
- * CONStruct more frag(s) of .quads, or .octa etc.
- * Makes 0 or more new frags.
- * If need_pass_2 == 1, generate no frag.
- * This understands only bignums, not expressions. Cons() understands
- * expressions.
- *
- * Constants recognised are '0...'(octal) '0x...'(hex) '...'(decimal).
- *
- * This creates objects with struct obstack_control objs, destroying
- * any context objs held about a partially completed object. Beware!
- *
- *
- * I think it sucks to have 2 different types of integers, with 2
- * routines to read them, store them etc.
- * It would be nicer to permit bignums in expressions and only
- * complain if the result overflowed. However, due to "efficiency"...
- */
-/* worker to do .quad etc statements */
-/* clobbers input_line_pointer, checks */
-/* end-of-line. */
-/* 8=.quad 16=.octa ... */
-
-void big_cons(nbytes)
-register int nbytes;
-{
- register char c; /* input_line_pointer->c. */
- register int radix;
- register long length; /* Number of chars in an object. */
- register int digit; /* Value of 1 digit. */
- register int carry; /* For multi-precision arithmetic. */
- register int work; /* For multi-precision arithmetic. */
- register char * p; /* For multi-precision arithmetic. */
-
- extern const char hex_value[]; /* In hex_value.c. */
-
- /*
- * The following awkward logic is to parse ZERO or more strings,
- * comma seperated. Recall an expression includes its leading &
- * trailing blanks. We fake a leading ',' if there is (supposed to
- * be) a 1st expression, and keep demanding 1 expression for each ','.
- */
- if (is_it_end_of_statement())
- {
- c = 0; /* Skip loop. */
- }
- else
- {
- c = ','; /* Do loop. */
- -- input_line_pointer;
- }
- while (c == ',')
- {
- ++ input_line_pointer;
- SKIP_WHITESPACE();
- c = * input_line_pointer;
- /* C contains 1st non-blank character of what we hope is a number. */
- if (c == '0')
- {
- c = * ++ input_line_pointer;
- if (c == 'x' || c == 'X')
- {
- c = * ++ input_line_pointer;
- radix = 16;
- }
- else
- {
- radix = 8;
- }
- }
- else
- {
- radix = 10;
- }
- /*
- * This feature (?) is here to stop people worrying about
- * mysterious zero constants: which is what they get when
- * they completely omit digits.
- */
- if (hex_value[c] >= radix) {
- as_bad("Missing digits. 0 assumed.");
- }
- bignum_high = bignum_low - 1; /* Start constant with 0 chars. */
- for (; (digit = hex_value[c]) < radix; c = *++input_line_pointer)
- {
- /* Multiply existing number by radix, then add digit. */
- carry = digit;
- for (p=bignum_low; p <= bignum_high; p++)
- {
- work = (*p & MASK_CHAR) * radix + carry;
- *p = work & MASK_CHAR;
- carry = work >> BITS_PER_CHAR;
- }
- if (carry)
- {
- grow_bignum();
- * bignum_high = carry & MASK_CHAR;
- know((carry & ~ MASK_CHAR) == 0);
- }
- }
- length = bignum_high - bignum_low + 1;
- if (length > nbytes)
- {
- as_warn("Most significant bits truncated in integer constant.");
- }
- else
- {
- register long leading_zeroes;
-
- for (leading_zeroes = nbytes - length;
- leading_zeroes;
- leading_zeroes --)
- {
- grow_bignum();
- * bignum_high = 0;
- }
- }
- if (! need_pass_2)
- {
- p = frag_more (nbytes);
- memcpy(p, bignum_low, (int) nbytes);
- }
- /* C contains character after number. */
- SKIP_WHITESPACE();
- c = *input_line_pointer;
- /* C contains 1st non-blank character after number. */
- }
- demand_empty_rest_of_line();
-} /* big_cons() */
-
-/* Extend bignum by 1 char. */
-static void grow_bignum() {
- register long length;
-
- bignum_high ++;
- if (bignum_high >= bignum_limit)
- {
- length = bignum_limit - bignum_low;
- bignum_low = xrealloc(bignum_low, length + length);
- bignum_high = bignum_low + length;
- bignum_limit = bignum_low + length + length;
- }
-} /* grow_bignum(); */
-
-/*
- * float_cons()
- *
- * CONStruct some more frag chars of .floats .ffloats etc.
- * Makes 0 or more new frags.
- * If need_pass_2 == 1, no frags are emitted.
- * This understands only floating literals, not expressions. Sorry.
- *
- * A floating constant is defined by atof_generic(), except it is preceded
- * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
- * reading, I decided to be incompatible. This always tries to give you
- * rounded bits to the precision of the pseudo-op. Former AS did premature
- * truncatation, restored noisy bits instead of trailing 0s AND gave you
- * a choice of 2 flavours of noise according to which of 2 floating-point
- * scanners you directed AS to use.
- *
- * In: input_line_pointer->whitespace before, or '0' of flonum.
- *
- */
-
-void /* JF was static, but can't be if VAX.C is goning to use it */
- float_cons(float_type) /* Worker to do .float etc statements. */
-/* Clobbers input_line-pointer, checks end-of-line. */
-register int float_type; /* 'f':.ffloat ... 'F':.float ... */
-{
- register char * p;
- register char c;
- int length; /* Number of chars in an object. */
- register char * err; /* Error from scanning floating literal. */
- char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
-
- /*
- * The following awkward logic is to parse ZERO or more strings,
- * comma seperated. Recall an expression includes its leading &
- * trailing blanks. We fake a leading ',' if there is (supposed to
- * be) a 1st expression, and keep demanding 1 expression for each ','.
- */
- if (is_it_end_of_statement())
- {
- c = 0; /* Skip loop. */
- ++ input_line_pointer; /*->past termintor. */
- }
- else
- {
- c = ','; /* Do loop. */
- }
- while (c == ',') {
- /* input_line_pointer->1st char of a flonum (we hope!). */
- SKIP_WHITESPACE();
- /* Skip any 0{letter} that may be present. Don't even check if the
- * letter is legal. Someone may invent a "z" format and this routine
- * has no use for such information. Lusers beware: you get
- * diagnostics if your input is ill-conditioned.
- */
-
- if (input_line_pointer[0] == '0' && isalpha(input_line_pointer[1]))
- input_line_pointer+=2;
-
- err = md_atof (float_type, temp, &length);
- know(length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
- know(length > 0);
- if (* err) {
- as_bad("Bad floating literal: %s", err);
- ignore_rest_of_line();
- /* Input_line_pointer->just after end-of-line. */
- c = 0; /* Break out of loop. */
- } else {
- if (! need_pass_2) {
- p = frag_more (length);
- memcpy(p, temp, length);
- }
- SKIP_WHITESPACE();
- c = *input_line_pointer++;
- /* C contains 1st non-white character after number. */
- /* input_line_pointer->just after terminator (c). */
- }
- }
- --input_line_pointer; /*->terminator (is not ','). */
- demand_empty_rest_of_line();
-} /* float_cons() */
-
-/*
- * stringer() Worker to do .ascii etc statements. Checks end-of-line.
- *
- * We read 0 or more ',' seperated, double-quoted strings.
- *
- * Caller should have checked need_pass_2 is FALSE because we don't check it.
- */
-
-void stringer(append_zero)
-int append_zero; /* 0: don't append '\0', else 1 */
-{
- unsigned int c;
-
- /*
- * The following awkward logic is to parse ZERO or more strings,
- * comma seperated. Recall a string expression includes spaces
- * before the opening '\"' and spaces after the closing '\"'.
- * We fake a leading ',' if there is (supposed to be)
- * a 1st, expression. We keep demanding expressions for each
- * ','.
- */
- if (is_it_end_of_statement()) {
- c = 0; /* Skip loop. */
- ++ input_line_pointer; /* Compensate for end of loop. */
- } else {
- c = ','; /* Do loop. */
- }
-
- while (c == ',' || c == '<' || c == '"' || ('0' <= c && c <= '9')) {
- int i;
-
- SKIP_WHITESPACE();
- switch (*input_line_pointer) {
- case '\"':
- ++input_line_pointer; /* ->1st char of string. */
- while (is_a_char(c = next_char_of_string())) {
- FRAG_APPEND_1_CHAR(c);
- }
- if (append_zero) {
- FRAG_APPEND_1_CHAR(0);
- }
- know(input_line_pointer[-1] == '\"');
- break;
-
- case '<':
- input_line_pointer++;
- c = get_single_number();
- FRAG_APPEND_1_CHAR(c);
- if (*input_line_pointer != '>') {
- as_bad("Expected <nn>");
- }
- input_line_pointer++;
- break;
-
- case ',':
- input_line_pointer++;
- break;
-
- default:
- i = get_absolute_expression();
- FRAG_APPEND_1_CHAR(i);
- break;
- } /* switch on next char */
-
- SKIP_WHITESPACE();
- c = *input_line_pointer;
- }
-
- demand_empty_rest_of_line();
-} /* stringer() */
-
-/* FIXME-SOMEDAY: I had trouble here on characters with the
- high bits set. We'll probably also have trouble with
- multibyte chars, wide chars, etc. Also be careful about
- returning values bigger than 1 byte. xoxorich. */
-
-unsigned int next_char_of_string() {
- register unsigned int c;
-
- c = *input_line_pointer++ & CHAR_MASK;
- switch (c) {
- case '\"':
- c = NOT_A_CHAR;
- break;
-
- case '\\':
- switch (c = *input_line_pointer++) {
- case 'b':
- c = '\b';
- break;
-
- case 'f':
- c = '\f';
- break;
-
- case 'n':
- c = '\n';
- break;
-
- case 'r':
- c = '\r';
- break;
-
- case 't':
- c = '\t';
- break;
-
-#ifdef BACKSLASH_V
- case 'v':
- c = '\013';
- break;
-#endif
-
- case '\\':
- case '"':
- break; /* As itself. */
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9': {
- long number;
-
- for (number = 0; isdigit(c); c = *input_line_pointer++) {
- number = number * 8 + c - '0';
- }
- c = number & 0xff;
- }
- --input_line_pointer;
- break;
-
- case '\n':
- /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
- as_warn("Unterminated string: Newline inserted.");
- c = '\n';
- break;
-
- default:
-
-#ifdef ONLY_STANDARD_ESCAPES
- as_bad("Bad escaped character in string, '?' assumed");
- c = '?';
-#endif /* ONLY_STANDARD_ESCAPES */
-
- break;
- } /* switch on escaped char */
- break;
-
- default:
- break;
- } /* switch on char */
- return(c);
-} /* next_char_of_string() */
-
-static segT
- get_segmented_expression (expP)
-register expressionS * expP;
-{
- register segT retval;
-
- if ((retval = expression(expP)) == SEG_PASS1 || retval == SEG_ABSENT || retval == SEG_BIG)
- {
- as_bad("Expected address expression: absolute 0 assumed");
- retval = expP->X_seg = SEG_ABSOLUTE;
- expP->X_add_number = 0;
- expP->X_add_symbol = expP->X_subtract_symbol = 0;
- }
- return (retval); /* SEG_ ABSOLUTE,UNKNOWN,DATA,TEXT,BSS */
-}
-
-static segT get_known_segmented_expression(expP)
-register expressionS *expP;
-{
- register segT retval;
- register char * name1;
- register char * name2;
-
- if ((retval = get_segmented_expression (expP)) == SEG_UNKNOWN)
- {
- name1 = expP->X_add_symbol ? S_GET_NAME(expP->X_add_symbol) : "";
- name2 = expP->X_subtract_symbol ?
- S_GET_NAME(expP->X_subtract_symbol) :
- "";
- if (name1 && name2)
- {
- as_warn("Symbols \"%s\" \"%s\" are undefined: absolute 0 assumed.",
- name1, name2);
- }
- else
- {
- as_warn("Symbol \"%s\" undefined: absolute 0 assumed.",
- name1 ? name1 : name2);
- }
- retval = expP->X_seg = SEG_ABSOLUTE;
- expP->X_add_number = 0;
- expP->X_add_symbol = expP->X_subtract_symbol = NULL;
- }
-#ifndef MANY_SEGMENTS
- know(retval == SEG_ABSOLUTE || retval == SEG_DATA || retval == SEG_TEXT || retval == SEG_BSS || retval == SEG_DIFFERENCE);
-#endif
- return (retval);
-
-} /* get_known_segmented_expression() */
-
-
-
-/* static */ long /* JF was static, but can't be if the MD pseudos are to use it */
- get_absolute_expression()
-{
- expressionS exp;
- register segT s;
-
- if ((s = expression(&exp)) != SEG_ABSOLUTE) {
- if (s != SEG_ABSENT) {
- as_bad("Bad Absolute Expression, absolute 0 assumed.");
- }
- exp.X_add_number = 0;
- }
- return(exp.X_add_number);
-} /* get_absolute_expression() */
-
-char /* return terminator */
- get_absolute_expression_and_terminator(val_pointer)
-long * val_pointer; /* return value of expression */
-{
- *val_pointer = get_absolute_expression();
- return (*input_line_pointer++);
-}
-
-/*
- * demand_copy_C_string()
- *
- * Like demand_copy_string, but return NULL if the string contains any '\0's.
- * Give a warning if that happens.
- */
-char *
- demand_copy_C_string (len_pointer)
-int *len_pointer;
-{
- register char *s;
-
- if ((s = demand_copy_string(len_pointer)) != 0) {
- register int len;
-
- for (len = *len_pointer;
- len > 0;
- len--) {
- if (*s == 0) {
- s = 0;
- len = 1;
- *len_pointer = 0;
- as_bad("This string may not contain \'\\0\'");
- }
- }
- }
- return(s);
-}
-
-/*
- * demand_copy_string()
- *
- * Demand string, but return a safe (=private) copy of the string.
- * Return NULL if we can't read a string here.
- */
-static char *demand_copy_string(lenP)
-int *lenP;
-{
- register unsigned int c;
- register int len;
- char *retval;
-
- len = 0;
- SKIP_WHITESPACE();
- if (*input_line_pointer == '\"') {
- input_line_pointer++; /* Skip opening quote. */
-
- while (is_a_char(c = next_char_of_string())) {
- obstack_1grow(&notes, c);
- len ++;
- }
- /* JF this next line is so demand_copy_C_string will return a null
- termanated string. */
- obstack_1grow(&notes,'\0');
- retval=obstack_finish(&notes);
- } else {
- as_warn("Missing string");
- retval = NULL;
- ignore_rest_of_line();
- }
- *lenP = len;
- return(retval);
-} /* demand_copy_string() */
-
-/*
- * is_it_end_of_statement()
- *
- * In: Input_line_pointer->next character.
- *
- * Do: Skip input_line_pointer over all whitespace.
- *
- * Out: 1 if input_line_pointer->end-of-line.
- */
-int is_it_end_of_statement() {
- SKIP_WHITESPACE();
- return(is_end_of_line[*input_line_pointer]);
-} /* is_it_end_of_statement() */
-
-void equals(sym_name)
-char *sym_name;
-{
- register symbolS *symbolP; /* symbol we are working with */
-
- input_line_pointer++;
- if (*input_line_pointer == '=')
- input_line_pointer++;
-
- while (*input_line_pointer == ' ' || *input_line_pointer == '\t')
- input_line_pointer++;
-
- if (sym_name[0] == '.' && sym_name[1] == '\0') {
- /* Turn '. = mumble' into a .org mumble */
- register segT segment;
- expressionS exp;
- register char *p;
-
- segment = get_known_segmented_expression(& exp);
- if (! need_pass_2) {
- if (segment != now_seg && segment != SEG_ABSOLUTE)
- as_warn("Illegal segment \"%s\". Segment \"%s\" assumed.",
- segment_name(segment),
- segment_name(now_seg));
- p = frag_var(rs_org, 1, 1, (relax_substateT)0, exp.X_add_symbol,
- exp.X_add_number, (char *)0);
- * p = 0;
- } /* if (ok to make frag) */
- } else {
- symbolP=symbol_find_or_make(sym_name);
- pseudo_set(symbolP);
- }
-} /* equals() */
-
-/* .include -- include a file at this point. */
-
-/* ARGSUSED */
-void s_include(arg)
-int arg;
-{
- char *newbuf;
- char *filename;
- int i;
- FILE *try;
- char *path;
-
- filename = demand_copy_string(&i);
- demand_empty_rest_of_line();
- path = xmalloc(i + include_dir_maxlen + 5 /* slop */);
- for (i = 0; i < include_dir_count; i++) {
- strcpy(path, include_dirs[i]);
- strcat(path, "/");
- strcat(path, filename);
- if (0 != (try = fopen(path, "r")))
- {
- fclose (try);
- goto gotit;
- }
- }
- free(path);
- path = filename;
- gotit:
- /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
- newbuf = input_scrub_include_file (path, input_line_pointer);
- buffer_limit = input_scrub_next_buffer (&input_line_pointer);
-} /* s_include() */
-
-void add_include_dir(path)
-char *path;
-{
- int i;
-
- if (include_dir_count == 0)
- {
- include_dirs = (char **)xmalloc (2 * sizeof (*include_dirs));
- include_dirs[0] = "."; /* Current dir */
- include_dir_count = 2;
- }
- else
- {
- include_dir_count++;
- include_dirs = (char **) realloc(include_dirs,
- include_dir_count*sizeof (*include_dirs));
- }
-
- include_dirs[include_dir_count-1] = path; /* New one */
-
- i = strlen (path);
- if (i > include_dir_maxlen)
- include_dir_maxlen = i;
-} /* add_include_dir() */
-
-void s_ignore(arg)
-int arg;
-{
- while (!is_end_of_line[*input_line_pointer]) {
- ++input_line_pointer;
- }
- ++input_line_pointer;
-
- return;
-} /* s_ignore() */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of read.c */
diff --git a/gnu/usr.bin/as/read.h b/gnu/usr.bin/as/read.h
deleted file mode 100644
index 228dd96..0000000
--- a/gnu/usr.bin/as/read.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/* read.h - of read.c
-
- Copyright (C) 1986, 1990, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-extern char *input_line_pointer; /* -> char we are parsing now. */
-
-#define PERMIT_WHITESPACE /* Define to make whitespace be allowed in */
-/* many syntactically unnecessary places. */
-/* Normally undefined. For compatibility */
-/* with ancient GNU cc. */
-/* #undef PERMIT_WHITESPACE */
-
-#ifdef PERMIT_WHITESPACE
-#define SKIP_WHITESPACE() {if (* input_line_pointer == ' ') ++ input_line_pointer;}
-#else
-#define SKIP_WHITESPACE() know(*input_line_pointer != ' ' )
-#endif
-
-
-#define LEX_NAME (1) /* may continue a name */
-#define LEX_BEGIN_NAME (2) /* may begin a name */
-
-#define is_name_beginner(c) ( lex_type[c] & LEX_BEGIN_NAME )
-#define is_part_of_name(c) ( lex_type[c] & LEX_NAME )
-
-#ifndef is_a_char
-#define CHAR_MASK (0xff)
-#define NOT_A_CHAR (CHAR_MASK+1)
-#define is_a_char(c) (((unsigned)(c)) <= CHAR_MASK)
-#endif /* is_a_char() */
-
-#ifdef PIC
-/* We change some of the entries in lex_type on some archs */
-extern char lex_type[];
-#else
-extern const char lex_type[];
-#endif
-extern char is_end_of_line[];
-
-/* These are initialized by the CPU specific target files (tc-*.c). */
-extern const char comment_chars[];
-extern const char line_comment_chars[];
-extern const char line_separator_chars[];
-
-#if __STDC__ == 1
-
-char *demand_copy_C_string(int *len_pointer);
-char get_absolute_expression_and_terminator(long *val_pointer);
-long get_absolute_expression(void);
-void add_include_dir(char *path);
-void big_cons(int nbytes);
-void cons(unsigned int nbytes);
-void demand_empty_rest_of_line(void);
-void equals(char *sym_name);
-void float_cons(int float_type);
-void ignore_rest_of_line(void);
-void pseudo_set(symbolS *symbolP);
-void read_a_source_file(char *name);
-void read_begin(void);
-void s_abort(void);
-void s_align_bytes(int arg);
-void s_align_ptwo(void);
-void s_app_file(int);
-void s_app_line(int);
-void s_comm(void);
-void s_data(void);
-void s_else(int arg);
-void s_end(int arg);
-void s_endif(int arg);
-void s_fill(void);
-void s_globl(void);
-void s_if(int arg);
-void s_ifdef(int arg);
-void s_ifeqs(int arg);
-void s_ignore(int arg);
-void s_include(int arg);
-void s_lcomm(int needs_align);
-void s_lsym(void);
-void s_org(void);
-void s_set(void);
-void s_size(void);
-void s_space(void);
-void s_text(void);
-void s_type(void);
-void s_weak(void);
-
-#else /* not __STDC__ */
-
-char *demand_copy_C_string();
-char get_absolute_expression_and_terminator();
-long get_absolute_expression();
-void add_include_dir();
-void big_cons();
-void cons();
-void demand_empty_rest_of_line();
-void equals();
-void float_cons();
-void ignore_rest_of_line();
-void pseudo_set();
-void read_a_source_file();
-void read_begin();
-void s_abort();
-void s_align_bytes();
-void s_align_ptwo();
-void s_app_file();
-void s_app_line();
-void s_comm();
-void s_data();
-void s_else();
-void s_end();
-void s_endif();
-void s_fill();
-void s_globl();
-void s_if();
-void s_ifdef();
-void s_ifeqs();
-void s_ignore();
-void s_include();
-void s_lcomm();
-void s_lsym();
-void s_org();
-void s_set();
-void s_size();
-void s_space();
-void s_text();
-void s_type();
-void s_weak();
-
-#endif /* not __STDC__ */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of read.h */
diff --git a/gnu/usr.bin/as/struc-symbol.h b/gnu/usr.bin/as/struc-symbol.h
deleted file mode 100644
index e6ca65c..0000000
--- a/gnu/usr.bin/as/struc-symbol.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* struct_symbol.h - Internal symbol structure
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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.
-
- oYou should have received a copy of the GNU General Public License
- along with GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-#ifndef __struc_symbol_h__
-#define __struc_symbol_h__
-
-struct symbol /* our version of an nlist node */
-{
- obj_symbol_type sy_symbol; /* what we write in .o file (if permitted) */
- unsigned long sy_name_offset; /* 4-origin position of sy_name in symbols */
- /* part of object file. */
- /* 0 for (nameless) .stabd symbols. */
- /* Not used until write_object_file() time. */
- long sy_number; /* 24 bit symbol number. */
- /* Symbol numbers start at 0 and are */
- /* unsigned. */
- struct symbol *sy_next; /* forward chain, or NULL */
-#ifdef SYMBOLS_NEED_BACKPOINTERS
- struct symbol *sy_previous; /* backward chain, or NULL */
-#endif /* SYMBOLS_NEED_BACKPOINTERS */
- struct frag *sy_frag; /* NULL or -> frag this symbol attaches to. */
- struct symbol *sy_forward; /* value is really that of this other symbol */
- /* We will probably want to add a sy_segment here soon. */
-
-#ifdef PIC
- /* Force symbol into symbol table, even if local */
- int sy_forceout;
-#endif
- /* Size of symbol as given by the .size directive */
- void *sy_sizexp; /* (expressionS *) */
-
- /* Auxiliary type information as given by the .type directive */
- unsigned char sy_aux;
-#define AUX_OBJECT 1
-#define AUX_FUNC 2
- unsigned char sy_bind;
-#define BIND_LOCAL 0 /* currently not used */
-#define BIND_GLOBAL 1 /* currently not used */
-#define BIND_WEAK 2
-};
-
-typedef struct symbol symbolS;
-
-#ifdef PIC
-symbolS *GOT_symbol; /* Pre-defined "__GLOBAL_OFFSET_TABLE" */
-int got_referenced;
-#endif
-
-typedef unsigned valueT; /* The type of n_value. Helps casting. */
-
-#ifndef WORKING_DOT_WORD
-struct broken_word {
- struct broken_word *next_broken_word;/* One of these strucs per .word x-y */
- fragS *frag; /* Which frag its in */
- char *word_goes_here;/* Where in the frag it is */
- fragS *dispfrag; /* where to add the break */
- symbolS *add; /* symbol_x */
- symbolS *sub; /* - symbol_y */
- long addnum; /* + addnum */
- int added; /* nasty thing happend yet? */
- /* 1: added and has a long-jump */
- /* 2: added but uses someone elses long-jump */
- struct broken_word *use_jump; /* points to broken_word with a similar
- long-jump */
-};
-extern struct broken_word *broken_words;
-#endif /* ndef WORKING_DOT_WORD */
-
-#define SEGMENT_TO_SYMBOL_TYPE(seg) (seg_N_TYPE[(int) (seg)])
-extern const short seg_N_TYPE[]; /* subseg.c */
-
-#ifdef SYMBOLS_NEED_BACKPOINTERS
-#if __STDC__ == 1
-
-void symbol_clear_list_pointers(symbolS *symbolP);
-void symbol_insert(symbolS *addme, symbolS *target, symbolS **rootP, symbolS **lastP);
-void symbol_remove(symbolS *symbolP, symbolS **rootP, symbolS **lastP);
-void verify_symbol_chain(symbolS *rootP, symbolS *lastP);
-
-#else /* not __STDC__ */
-
-void symbol_clear_list_pointers();
-void symbol_insert();
-void symbol_remove();
-void verify_symbol_chain();
-
-#endif /* not __STDC__ */
-
-#define symbol_previous(s) ((s)->sy_previous)
-
-#else /* SYMBOLS_NEED_BACKPOINTERS */
-
-#define symbol_clear_list_pointers(clearme) {clearme->sy_next = NULL;}
-
-#endif /* SYMBOLS_NEED_BACKPOINTERS */
-
-#if __STDC__ == 1
-void symbol_append(symbolS *addme, symbolS *target, symbolS **rootP, symbolS **lastP);
-#else /* not __STDC__ */
-void symbol_append();
-#endif /* not __STDC__ */
-
-#define symbol_next(s) ((s)->sy_next)
-
-#endif /* __struc_symbol_h__ */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of struc-symbol.h */
diff --git a/gnu/usr.bin/as/subsegs.c b/gnu/usr.bin/as/subsegs.c
deleted file mode 100644
index 7501f42..0000000
--- a/gnu/usr.bin/as/subsegs.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/* subsegs.c - subsegments -
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Segments & sub-segments.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "as.h"
-
-#include "subsegs.h"
-#include "obstack.h"
-
-#ifdef MANY_SEGMENTS
-segment_info_type segment_info[SEG_MAXIMUM_ORDINAL];
-
-frchainS* frchain_root,
- * frchain_now;
-
-#else
-frchainS* frchain_root,
- * frchain_now, /* Commented in "subsegs.h". */
- * data0_frchainP;
-
-#endif
-char * const /* in: segT out: char* */
- seg_name[] = {
- "absolute",
-#ifdef MANY_SEGMENTS
- "e0","e1","e2","e3","e4","e5","e6","e7","e8","e9",
-#else
- "text",
- "data",
- "bss",
-#endif
- "unknown",
- "absent",
- "pass1",
- "ASSEMBLER-INTERNAL-LOGIC-ERROR!",
- "bignum/flonum",
- "difference",
- "debug",
- "transfert vector preload",
- "transfert vector postload",
- "register",
- "",
- }; /* Used by error reporters, dumpers etc. */
-
-
-void
- subsegs_begin()
-{
- /* Check table(s) seg_name[], seg_N_TYPE[] is in correct order */
-#ifdef MANY_SEGMENTS
-#else
- know(SEG_ABSOLUTE == 0);
- know(SEG_TEXT == 1);
- know(SEG_DATA == 2);
- know(SEG_BSS == 3);
- know(SEG_UNKNOWN == 4);
- know(SEG_ABSENT == 5);
- know(SEG_PASS1 == 6);
- know(SEG_GOOF == 7);
- know(SEG_BIG == 8);
- know(SEG_DIFFERENCE == 9);
- know(SEG_DEBUG == 10);
- know(SEG_NTV == 11);
- know(SEG_PTV == 12);
- know(SEG_REGISTER == 13);
- know(SEG_MAXIMUM_ORDINAL == SEG_REGISTER );
- /* know(segment_name(SEG_MAXIMUM_ORDINAL + 1)[0] == 0);*/
-#endif
-
- obstack_begin(&frags, 5000);
- frchain_root = NULL;
- frchain_now = NULL; /* Warn new_subseg() that we are booting. */
- /* Fake up 1st frag. */
- /* It won't be used=> is ok if obstack... */
- /* pads the end of it for alignment. */
- frag_now=(fragS *)obstack_alloc(&frags,SIZEOF_STRUCT_FRAG);
- memset(frag_now, SIZEOF_STRUCT_FRAG, 0);
- /* This 1st frag will not be in any frchain. */
- /* We simply give subseg_new somewhere to scribble. */
- now_subseg = 42; /* Lie for 1st call to subseg_new. */
-#ifdef MANY_SEGMENTS
- {
- int i;
- for (i = SEG_E0; i < SEG_UNKNOWN; i++) {
- subseg_new(i, 0);
- segment_info[i].frchainP = frchain_now;
- }
- }
-#else
- subseg_new(SEG_DATA, 0); /* .data 0 */
- data0_frchainP = frchain_now;
-#endif
-
-}
-
-/*
- * subseg_change()
- *
- * Change the subsegment we are in, BUT DO NOT MAKE A NEW FRAG for the
- * subsegment. If we are already in the correct subsegment, change nothing.
- * This is used eg as a worker for subseg_new [which does make a new frag_now]
- * and for changing segments after we have read the source. We construct eg
- * fixSs even after the source file is read, so we do have to keep the
- * segment context correct.
- */
-void
- subseg_change (seg, subseg)
-register segT seg;
-register int subseg;
-{
- now_seg = seg;
- now_subseg = subseg;
- know(SEG_NORMAL(seg));
-#ifdef MANY_SEGMENTS
- seg_fix_rootP = &segment_info[seg].fix_root;
- seg_fix_tailP = &segment_info[seg].fix_tail;
-#else
- switch (seg) {
- case SEG_DATA:
- seg_fix_rootP = &data_fix_root;
- seg_fix_tailP = &data_fix_tail;
- break;
- case SEG_TEXT:
- seg_fix_rootP = &text_fix_root;
- seg_fix_tailP = &text_fix_tail;
- break;
- case SEG_BSS:
- seg_fix_rootP = &bss_fix_root;
- seg_fix_tailP = &bss_fix_tail;
- break;
- }
-#endif
-}
-
-/*
- * subseg_new()
- *
- * If you attempt to change to the current subsegment, nothing happens.
- *
- * In: segT, subsegT code for new subsegment.
- * frag_now -> incomplete frag for current subsegment.
- * If frag_now == NULL, then there is no old, incomplete frag, so
- * the old frag is not closed off.
- *
- * Out: now_subseg, now_seg updated.
- * Frchain_now points to the (possibly new) struct frchain for this
- * sub-segment.
- * Frchain_root updated if needed.
- */
-
-void
- subseg_new (seg, subseg) /* begin assembly for a new sub-segment */
-register segT seg; /* SEG_DATA or SEG_TEXT */
-register subsegT subseg;
-{
- long tmp; /* JF for obstack alignment hacking */
- know(SEG_NORMAL(seg));
- if (seg != now_seg || subseg != now_subseg)
- { /* we just changed sub-segments */
- register frchainS * frcP; /* crawl frchain chain */
- register frchainS** lastPP; /* address of last pointer */
- frchainS *newP; /* address of new frchain */
- register fragS *former_last_fragP;
- register fragS *new_fragP;
-
- if (frag_now) /* If not bootstrapping. */
- {
- frag_now->fr_fix = obstack_next_free(& frags) - frag_now->fr_literal;
- frag_wane(frag_now); /* Close off any frag in old subseg. */
- }
- /*
- * It would be nice to keep an obstack for each subsegment, if we swap
- * subsegments a lot. Hence we would have much fewer frag_wanes().
- */
- {
-
- obstack_finish( &frags);
- /*
- * If we don't do the above, the next object we put on obstack frags
- * will appear to start at the fr_literal of the current frag.
- * Also, above ensures that the next object will begin on a
- * address that is aligned correctly for the engine that runs
- * this program.
- */
- }
- subseg_change (seg, (int)subseg);
- /*
- * Attempt to find or make a frchain for that sub seg.
- * Crawl along chain of frchainSs, begins @ frchain_root.
- * If we need to make a frchainS, link it into correct
- * position of chain rooted in frchain_root.
- */
- for (frcP = * (lastPP = & frchain_root);
- frcP
- && (int)(frcP->frch_seg) <= (int)seg;
- frcP = * ( lastPP = & frcP->frch_next)
- )
- {
- if ( (int)(frcP->frch_seg) == (int)seg
- && frcP->frch_subseg >= subseg)
- {
- break;
- }
- }
- /*
- * frcP: Address of the 1st frchainS in correct segment with
- * frch_subseg >= subseg.
- * We want to either use this frchainS, or we want
- * to insert a new frchainS just before it.
- *
- * If frcP == NULL, then we are at the end of the chain
- * of frchainS-s. A NULL frcP means we fell off the end
- * of the chain looking for a
- * frch_subseg >= subseg, so we
- * must make a new frchainS.
- *
- * If we ever maintain a pointer to
- * the last frchainS in the chain, we change that pointer
- * ONLY when frcP == NULL.
- *
- * lastPP: Address of the pointer with value frcP;
- * Never NULL.
- * May point to frchain_root.
- *
- */
- if ( ! frcP
- || ( (int)(frcP->frch_seg) > (int)seg
- || frcP->frch_subseg > subseg)) /* Kinky logic only works with 2 segments. */
- {
- /*
- * This should be the only code that creates a frchainS.
- */
- newP=(frchainS *)obstack_alloc(&frags,sizeof(frchainS));
- memset(newP, sizeof(frchainS), 0);
- /* This begines on a good boundary */
- /* because a obstack_done() preceeded it. */
- /* It implies an obstack_done(), so we */
- /* expect the next object allocated to */
- /* begin on a correct boundary. */
- *lastPP = newP;
- newP->frch_next = frcP; /* perhaps NULL */
- (frcP = newP)->frch_subseg = subseg;
- newP->frch_seg = seg;
- newP->frch_last = NULL;
- }
- /*
- * Here with frcP->ing to the frchainS for subseg.
- */
- frchain_now = frcP;
- /*
- * Make a fresh frag for the subsegment.
- */
- /* We expect this to happen on a correct */
- /* boundary since it was proceeded by a */
- /* obstack_done(). */
- tmp=obstack_alignment_mask(&frags); /* JF disable alignment */
- obstack_alignment_mask(&frags)=0;
- frag_now=(fragS *)obstack_alloc(&frags,SIZEOF_STRUCT_FRAG);
- obstack_alignment_mask(&frags)=tmp;
- /* know(frags.obstack_c_next_free == frag_now->fr_literal); */
- /* But we want any more chars to come */
- /* immediately after the structure we just made. */
- new_fragP = frag_now;
- new_fragP->fr_next = NULL;
- /*
- * Append new frag to current frchain.
- */
- former_last_fragP = frcP->frch_last;
- if (former_last_fragP)
- {
- know( former_last_fragP->fr_next == NULL );
- know( frchain_now->frch_root );
- former_last_fragP->fr_next = new_fragP;
- }
- else
- {
- frcP->frch_root = new_fragP;
- }
- frcP->frch_last = new_fragP;
- } /* if (changing subsegments) */
-} /* subseg_new() */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of subsegs.c */
diff --git a/gnu/usr.bin/as/subsegs.h b/gnu/usr.bin/as/subsegs.h
deleted file mode 100644
index 9b81631..0000000
--- a/gnu/usr.bin/as/subsegs.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* subsegs.h -> subsegs.c
-
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-/*
- * For every sub-segment the user mentions in the ASsembler program,
- * we make one struct frchain. Each sub-segment has exactly one struct frchain
- * and vice versa.
- *
- * Struct frchain's are forward chained (in ascending order of sub-segment
- * code number). The chain runs through frch_next of each subsegment.
- * This makes it hard to find a subsegment's frags
- * if programmer uses a lot of them. Most programs only use text0 and
- * data0, so they don't suffer. At least this way:
- * (1) There are no "arbitrary" restrictions on how many subsegments
- * can be programmed;
- * (2) Subsegments' frchain-s are (later) chained together in the order in
- * which they are emitted for object file viz text then data.
- *
- * From each struct frchain dangles a chain of struct frags. The frags
- * represent code fragments, for that sub-segment, forward chained.
- */
-
-struct frchain /* control building of a frag chain */
-{ /* FRCH = FRagment CHain control */
- struct frag * frch_root; /* 1st struct frag in chain, or NULL */
- struct frag * frch_last; /* last struct frag in chain, or NULL */
- struct frchain * frch_next; /* next in chain of struct frchain-s */
- segT frch_seg; /* SEG_TEXT or SEG_DATA. */
- subsegT frch_subseg; /* subsegment number of this chain */
-};
-
-typedef struct frchain frchainS;
-
-extern frchainS * frchain_root; /* NULL means no frchains yet. */
-/* all subsegments' chains hang off here */
-
-extern frchainS * frchain_now;
-/* Frchain we are assembling into now */
-/* That is, the current segment's frag */
-/* chain, even if it contains no (complete) */
-/* frags. */
-
-
-#ifdef MANY_SEGMENTS
-typedef struct
-{
- frchainS *frchainP;
- int hadone;
- int user_stuff;
- /* struct frag *frag_root;*/
- /* struct frag *last_frag;*/
- fixS *fix_root;
- fixS *fix_tail;
- struct internal_scnhdr scnhdr;
- symbolS *dot;
-
- struct lineno_list *lineno_list_head;
- struct lineno_list *lineno_list_tail;
-
-} segment_info_type;
-segment_info_type segment_info[];
-#else
-extern frchainS * data0_frchainP;
-extern frchainS * bss0_frchainP;
-/* Sentinel for frchain crawling. */
-/* Points to the 1st data-segment frchain. */
-/* (Which is pointed to by the last text- */
-/* segment frchain.) */
-
-#endif
-
-/* end of subsegs.h */
diff --git a/gnu/usr.bin/as/symbols.c b/gnu/usr.bin/as/symbols.c
deleted file mode 100644
index 44d7105..0000000
--- a/gnu/usr.bin/as/symbols.c
+++ /dev/null
@@ -1,654 +0,0 @@
-/* symbols.c -symbol table-
-
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "as.h"
-
-#include "obstack.h" /* For "symbols.h" */
-#include "subsegs.h"
-
-#ifndef WORKING_DOT_WORD
-extern int new_broken_words;
-#endif
-
-static
- struct hash_control *
- sy_hash; /* symbol-name => struct symbol pointer */
-
-/* Below are commented in "symbols.h". */
-unsigned int local_bss_counter;
-symbolS * symbol_rootP;
-symbolS * symbol_lastP;
-symbolS abs_symbol;
-
-symbolS* dot_text_symbol;
-symbolS* dot_data_symbol;
-symbolS* dot_bss_symbol;
-
-struct obstack notes;
-
-/*
- * Un*x idea of local labels. They are made by "n:" where n
- * is any decimal digit. Refer to them with
- * "nb" for previous (backward) n:
- * or "nf" for next (forward) n:.
- *
- * Like Un*x AS, we have one set of local label counters for entire assembly,
- * not one set per (sub)segment like in most assemblers. This implies that
- * one can refer to a label in another segment, and indeed some crufty
- * compilers have done just that.
- *
- * I document the symbol names here to save duplicating words elsewhere.
- * The mth occurence of label n: is turned into the symbol "Ln^Am" where
- * n is a digit and m is a decimal number. "L" makes it a label discarded
- * unless debugging and "^A"('\1') ensures no ordinary symbol SHOULD get the
- * same name as a local label symbol. The first "4:" is "L4^A1" - the m
- * numbers begin at 1.
- */
-
-typedef short unsigned int
- local_label_countT;
-
-static local_label_countT
- local_label_counter[10];
-
-static /* Returned to caller, then copied. */
- char symbol_name_build[12]; /* used for created names ("4f") */
-
-#ifdef LOCAL_LABELS_DOLLAR
-int local_label_defined[10];
-#endif
-
-
-void
- symbol_begin()
-{
- symbol_lastP = NULL;
- symbol_rootP = NULL; /* In case we have 0 symbols (!!) */
- sy_hash = hash_new();
- memset((char *)(& abs_symbol), '\0', sizeof(abs_symbol));
- S_SET_SEGMENT(&abs_symbol, SEG_ABSOLUTE); /* Can't initialise a union. Sigh. */
- memset((char *)(local_label_counter), '\0', sizeof(local_label_counter) );
- local_bss_counter = 0;
-}
-
-/*
- * local_label_name()
- *
- * Caller must copy returned name: we re-use the area for the next name.
- */
-
-char * /* Return local label name. */
- local_label_name(n, augend)
-register int n; /* we just saw "n:", "nf" or "nb" : n a digit */
-register int augend; /* 0 for nb, 1 for n:, nf */
-{
- register char * p;
- register char * q;
- char symbol_name_temporary[10]; /* build up a number, BACKWARDS */
-
- know( n >= 0 );
- know( augend == 0 || augend == 1 );
- p = symbol_name_build;
- * p ++ = 1; /* ^A */
- * p ++ = 'L';
- * p ++ = n + '0'; /* Make into ASCII */
- n = local_label_counter[ n ] + augend;
- /* version number of this local label */
- /*
- * Next code just does sprintf( {}, "%d", n);
- * It is more elegant to do the next part recursively, but a procedure
- * call for each digit emitted is considered too costly.
- */
- q = symbol_name_temporary;
- for (*q++=0; n; q++) /* emits NOTHING if n starts as 0 */
- {
- know(n>0); /* We expect n > 0 always */
- *q = n % 10 + '0';
- n /= 10;
- }
- while (( * p ++ = * -- q ) != '\0') ;;
-
- /* The label, as a '\0' ended string, starts at symbol_name_build. */
- return(symbol_name_build);
-} /* local_label_name() */
-
-
-void local_colon (n)
-int n; /* just saw "n:" */
-{
- local_label_counter[n] ++;
-#ifdef LOCAL_LABELS_DOLLAR
- local_label_defined[n]=1;
-#endif
- colon (local_label_name (n, 0));
-}
-
-/*
- * symbol_new()
- *
- * Return a pointer to a new symbol.
- * Die if we can't make a new symbol.
- * Fill in the symbol's values.
- * Add symbol to end of symbol chain.
- *
- *
- * Please always call this to create a new symbol.
- *
- * Changes since 1985: Symbol names may not contain '\0'. Sigh.
- * 2nd argument is now a SEG rather than a TYPE. The mapping between
- * segments and types is mostly encapsulated herein (actually, we inherit it
- * from macros in struc-symbol.h).
- */
-
-symbolS *symbol_new(name, segment, value, frag)
-char *name; /* It is copied, the caller can destroy/modify */
-segT segment; /* Segment identifier (SEG_<something>) */
-long value; /* Symbol value */
-fragS *frag; /* Associated fragment */
-{
- unsigned int name_length;
- char *preserved_copy_of_name;
- symbolS *symbolP;
-
- name_length = strlen(name) + 1; /* +1 for \0 */
- obstack_grow(&notes, name, name_length);
- preserved_copy_of_name = obstack_finish(&notes);
- symbolP = (symbolS *) obstack_alloc(&notes, sizeof(symbolS));
-
- /* symbol must be born in some fixed state. This seems as good as any. */
- memset(symbolP, 0, sizeof(symbolS));
-
-#ifdef STRIP_UNDERSCORE
- S_SET_NAME(symbolP, (*preserved_copy_of_name == '_'
- ? preserved_copy_of_name + 1
- : preserved_copy_of_name));
-#else /* STRIP_UNDERSCORE */
- S_SET_NAME(symbolP, preserved_copy_of_name);
-#endif /* STRIP_UNDERSCORE */
-
- S_SET_SEGMENT(symbolP, segment);
- S_SET_VALUE(symbolP, value);
- /* symbol_clear_list_pointers(symbolP); uneeded if symbol is born zeroed. */
-
- symbolP->sy_frag = frag;
- /* krm: uneeded if symbol is born zeroed.
- symbolP->sy_forward = NULL; */ /* JF */
- symbolP->sy_number = ~0;
- symbolP->sy_name_offset = ~0;
-
- /*
- * Link to end of symbol chain.
- */
- symbol_append(symbolP, symbol_lastP, &symbol_rootP, &symbol_lastP);
-
- obj_symbol_new_hook(symbolP);
-
-#ifdef DEBUG
- /* verify_symbol_chain(symbol_rootP, symbol_lastP); */
-#endif /* DEBUG */
-
- return(symbolP);
-} /* symbol_new() */
-
-
-/*
- * colon()
- *
- * We have just seen "<name>:".
- * Creates a struct symbol unless it already exists.
- *
- * Gripes if we are redefining a symbol incompatibly (and ignores it).
- *
- */
-void colon(sym_name) /* just seen "x:" - rattle symbols & frags */
-register char * sym_name; /* symbol name, as a cannonical string */
-/* We copy this string: OK to alter later. */
-{
- register symbolS * symbolP; /* symbol we are working with */
-
-#ifdef LOCAL_LABELS_DOLLAR
- /* Sun local labels go out of scope whenever a non-local symbol is defined. */
-
- if (*sym_name != 'L')
- memset((void *) local_label_defined, '\0', sizeof(local_label_defined));
-#endif
-
-#ifndef WORKING_DOT_WORD
- if (new_broken_words) {
- struct broken_word *a;
- int possible_bytes;
- fragS *frag_tmp;
- char *frag_opcode;
-
- extern const md_short_jump_size;
- extern const md_long_jump_size;
- possible_bytes=md_short_jump_size + new_broken_words * md_long_jump_size;
-
- frag_tmp=frag_now;
- frag_opcode=frag_var(rs_broken_word,
- possible_bytes,
- possible_bytes,
- (relax_substateT) 0,
- (symbolS *) broken_words,
- 0L,
- NULL);
-
- /* We want to store the pointer to where to insert the jump table in the
- fr_opcode of the rs_broken_word frag. This requires a little hackery */
- while (frag_tmp && (frag_tmp->fr_type != rs_broken_word || frag_tmp->fr_opcode))
- frag_tmp=frag_tmp->fr_next;
- know(frag_tmp);
- frag_tmp->fr_opcode=frag_opcode;
- new_broken_words = 0;
-
- for (a=broken_words;a && a->dispfrag == 0;a=a->next_broken_word)
- a->dispfrag=frag_tmp;
- }
-#endif
- if ((symbolP = symbol_find(sym_name)) != 0) {
-#ifdef OBJ_VMS
- /*
- * If the new symbol is .comm AND it has a size of zero,
- * we ignore it (i.e. the old symbol overrides it)
- */
- if ((SEGMENT_TO_SYMBOL_TYPE((int) now_seg) == (N_UNDF | N_EXT)) &&
- ((obstack_next_free(& frags) - frag_now->fr_literal) == 0))
- return;
- /*
- * If the old symbol is .comm and it has a size of zero,
- * we override it with the new symbol value.
- */
- if (S_IS_EXTERNAL(symbolP) && S_IS_DEFINED(symbolP)
- && (S_GET_VALUE(symbolP) == 0)) {
- symbolP->sy_frag = frag_now;
- S_GET_OTHER(symbolP) = const_flag;
- S_SET_VALUE(symbolP, obstack_next_free(& frags) - frag_now->fr_literal);
- symbolP->sy_symbol.n_type |=
- SEGMENT_TO_SYMBOL_TYPE((int) now_seg); /* keep N_EXT bit */
- return;
- }
-#endif /* OBJ_VMS */
- /*
- * Now check for undefined symbols
- */
- if (!S_IS_DEFINED(symbolP)) {
- if (S_GET_VALUE(symbolP) == 0) {
- symbolP->sy_frag = frag_now;
-#ifdef OBJ_VMS
- S_GET_OTHER(symbolP) = const_flag;
-#endif
- S_SET_VALUE(symbolP, obstack_next_free(&frags) - frag_now->fr_literal);
- S_SET_SEGMENT(symbolP, now_seg);
-#ifdef N_UNDF
- know(N_UNDF == 0);
-#endif /* if we have one, it better be zero. */
-
- } else {
- /*
- * There are still several cases to check:
- * A .comm/.lcomm symbol being redefined as
- * initialized data is OK
- * A .comm/.lcomm symbol being redefined with
- * a larger size is also OK
- *
- * This only used to be allowed on VMS gas, but Sun cc
- * on the sparc also depends on it.
- */
- /* char New_Type = SEGMENT_TO_SYMBOL_TYPE((int) now_seg); */
-
- if (((!S_IS_DEBUG(symbolP) && !S_IS_DEFINED(symbolP) && S_IS_EXTERNAL(symbolP))
- || (S_GET_SEGMENT(symbolP) == SEG_BSS))
- && ((now_seg == SEG_DATA)
- || (now_seg == S_GET_SEGMENT(symbolP)))) {
- /*
- * Select which of the 2 cases this is
- */
- if (now_seg != SEG_DATA) {
- /*
- * New .comm for prev .comm symbol.
- * If the new size is larger we just
- * change its value. If the new size
- * is smaller, we ignore this symbol
- */
- if (S_GET_VALUE(symbolP)
- < ((unsigned) (obstack_next_free(& frags) - frag_now->fr_literal))) {
- S_SET_VALUE(symbolP,
- obstack_next_free(& frags) -
- frag_now->fr_literal);
- }
- } else {
- /*
- * It is a .comm/.lcomm being converted
- * to initialized data.
- */
- symbolP->sy_frag = frag_now;
-#ifdef OBJ_VMS
- S_GET_OTHER(symbolP) = const_flag;
-#endif /* OBJ_VMS */
- S_SET_VALUE(symbolP, obstack_next_free(& frags) - frag_now->fr_literal);
- S_SET_SEGMENT(symbolP, now_seg); /* keep N_EXT bit */
- }
- } else {
-#ifdef OBJ_COFF
- as_fatal("Symbol \"%s\" is already defined as \"%s\"/%d.",
- sym_name,
- segment_name(S_GET_SEGMENT(symbolP)),
- S_GET_VALUE(symbolP));
-#else /* OBJ_COFF */
- as_fatal("Symbol \"%s\" is already defined as \"%s\"/%d.%d.%d.",
- sym_name,
- segment_name(S_GET_SEGMENT(symbolP)),
- S_GET_OTHER(symbolP), S_GET_DESC(symbolP),
- S_GET_VALUE(symbolP));
-#endif /* OBJ_COFF */
- }
- } /* if the undefined symbol has no value */
- } else
- {
- /* Don't blow up if the definition is the same */
- if (!(frag_now == symbolP->sy_frag
- && S_GET_VALUE(symbolP) == obstack_next_free(&frags) - frag_now->fr_literal
- && S_GET_SEGMENT(symbolP) == now_seg) )
- as_fatal("Symbol %s already defined.", sym_name);
- } /* if this symbol is not yet defined */
-
- } else {
- symbolP = symbol_new(sym_name,
- now_seg,
- (valueT)(obstack_next_free(&frags)-frag_now->fr_literal),
- frag_now);
-#ifdef OBJ_VMS
- S_SET_OTHER(symbolP, const_flag);
-#endif /* OBJ_VMS */
-
- symbol_table_insert(symbolP);
- } /* if we have seen this symbol before */
-
- return;
-} /* colon() */
-
-
-/*
- * symbol_table_insert()
- *
- * Die if we can't insert the symbol.
- *
- */
-
-void symbol_table_insert(symbolP)
-symbolS *symbolP;
-{
- register char *error_string;
-
- know(symbolP);
- know(S_GET_NAME(symbolP));
-
- if (*(error_string = hash_jam(sy_hash, S_GET_NAME(symbolP), (char *)symbolP))) {
- as_fatal("Inserting \"%s\" into symbol table failed: %s",
- S_GET_NAME(symbolP), error_string);
- } /* on error */
-} /* symbol_table_insert() */
-
-/*
- * symbol_find_or_make()
- *
- * If a symbol name does not exist, create it as undefined, and insert
- * it into the symbol table. Return a pointer to it.
- */
-symbolS *symbol_find_or_make(name)
-char *name;
-{
- register symbolS *symbolP;
-
- symbolP = symbol_find(name);
-
- if (symbolP == NULL) {
- symbolP = symbol_make(name);
-
- symbol_table_insert(symbolP);
- } /* if symbol wasn't found */
-
- return(symbolP);
-} /* symbol_find_or_make() */
-
-symbolS *symbol_make(name)
-char *name;
-{
- symbolS *symbolP;
-
- /* Let the machine description default it, e.g. for register names. */
- symbolP = md_undefined_symbol(name);
-
- if (!symbolP) {
- symbolP = symbol_new(name,
- SEG_UNKNOWN,
- 0,
- &zero_address_frag);
- } /* if md didn't build us a symbol */
-
- return(symbolP);
-} /* symbol_make() */
-
-/*
- * symbol_find()
- *
- * Implement symbol table lookup.
- * In: A symbol's name as a string: '\0' can't be part of a symbol name.
- * Out: NULL if the name was not in the symbol table, else the address
- * of a struct symbol associated with that name.
- */
-
-symbolS *symbol_find(name)
-char *name;
-{
-#ifdef STRIP_UNDERSCORE
- return(symbol_find_base(name, 1));
-#else /* STRIP_UNDERSCORE */
- return(symbol_find_base(name, 0));
-#endif /* STRIP_UNDERSCORE */
-} /* symbol_find() */
-
-symbolS *symbol_find_base(name, strip_underscore)
-char *name;
-int strip_underscore;
-{
- if (strip_underscore && *name == '_') name++;
- return ( (symbolS *) hash_find( sy_hash, name ));
-}
-
-/*
- * Once upon a time, symbols were kept in a singly linked list. At
- * least coff needs to be able to rearrange them from time to time, for
- * which a doubly linked list is much more convenient. Loic did these
- * as macros which seemed dangerous to me so they're now functions.
- * xoxorich.
- */
-
-/* Link symbol ADDME after symbol TARGET in the chain. */
-void symbol_append(addme, target, rootPP, lastPP)
-symbolS *addme;
-symbolS *target;
-symbolS **rootPP;
-symbolS **lastPP;
-{
- if (target == NULL) {
- know(*rootPP == NULL);
- know(*lastPP == NULL);
- *rootPP = addme;
- *lastPP = addme;
- return;
- } /* if the list is empty */
-
- if (target->sy_next != NULL) {
-#ifdef SYMBOLS_NEED_BACKPOINTERS
- target->sy_next->sy_previous = addme;
-#endif /* SYMBOLS_NEED_BACKPOINTERS */
- } else {
- know(*lastPP == target);
- *lastPP = addme;
- } /* if we have a next */
-
- addme->sy_next = target->sy_next;
- target->sy_next = addme;
-
-#ifdef SYMBOLS_NEED_BACKPOINTERS
- addme->sy_previous = target;
-#endif /* SYMBOLS_NEED_BACKPOINTERS */
-
-#ifdef DEBUG
- /* verify_symbol_chain(*rootPP, *lastPP); */
-#endif /* DEBUG */
-
- return;
-} /* symbol_append() */
-
-#ifdef SYMBOLS_NEED_BACKPOINTERS
-/* Remove SYMBOLP from the list. */
-void symbol_remove(symbolP, rootPP, lastPP)
-symbolS *symbolP;
-symbolS **rootPP;
-symbolS **lastPP;
-{
- if (symbolP == *rootPP) {
- *rootPP = symbolP->sy_next;
- } /* if it was the root */
-
- if (symbolP == *lastPP) {
- *lastPP = symbolP->sy_previous;
- } /* if it was the tail */
-
- if (symbolP->sy_next != NULL) {
- symbolP->sy_next->sy_previous = symbolP->sy_previous;
- } /* if not last */
-
- if (symbolP->sy_previous != NULL) {
- symbolP->sy_previous->sy_next = symbolP->sy_next;
- } /* if not first */
-
-#ifdef DEBUG
- verify_symbol_chain(*rootPP, *lastPP);
-#endif /* DEBUG */
-
- return;
-} /* symbol_remove() */
-
-/* Set the chain pointers of SYMBOL to null. */
-void symbol_clear_list_pointers(symbolP)
-symbolS *symbolP;
-{
- symbolP->sy_next = NULL;
- symbolP->sy_previous = NULL;
-} /* symbol_clear_list_pointers() */
-
-/* Link symbol ADDME before symbol TARGET in the chain. */
-void symbol_insert(addme, target, rootPP, lastPP)
-symbolS *addme;
-symbolS *target;
-symbolS **rootPP;
-symbolS **lastPP;
-{
- if (target->sy_previous != NULL) {
- target->sy_previous->sy_next = addme;
- } else {
- know(*rootPP == target);
- *rootPP = addme;
- } /* if not first */
-
- addme->sy_previous = target->sy_previous;
- target->sy_previous = addme;
- addme->sy_next = target;
-
-#ifdef DEBUG
- verify_symbol_chain(*rootPP, *lastPP);
-#endif /* DEBUG */
-
- return;
-} /* symbol_insert() */
-#endif /* SYMBOLS_NEED_BACKPOINTERS */
-
-void verify_symbol_chain(rootP, lastP)
-symbolS *rootP;
-symbolS *lastP;
-{
- symbolS *symbolP = rootP;
-
- if (symbolP == NULL) {
- return;
- } /* empty chain */
-
- for ( ; symbol_next(symbolP) != NULL; symbolP = symbol_next(symbolP)) {
-#ifdef SYMBOLS_NEED_BACKPOINTERS
- /*$if (symbolP->sy_previous) {
- know(symbolP->sy_previous->sy_next == symbolP);
- } else {
- know(symbolP == rootP);
- }$*/ /* both directions */
- know(symbolP->sy_next->sy_previous == symbolP);
-#else /* SYMBOLS_NEED_BACKPOINTERS */
- ;
-#endif /* SYMBOLS_NEED_BACKPOINTERS */
- } /* verify pointers */
-
- know(lastP == symbolP);
-
- return;
-} /* verify_symbol_chain() */
-
-
-/*
- * decode name that may have been generated by local_label_name() above. If
- * the name wasn't generated by local_label_name(), then return it unaltered.
- * This is used for error messages.
- */
-
-char *decode_local_label_name(s)
-char *s;
-{
- char *symbol_decode;
- int label_number;
- /* int label_version; */
- char *message_format = "\"%d\" (instance number %s of a local label)";
-
- if (s[0] != 'L'
- || s[2] != 1) {
- return(s);
- } /* not a local_label_name() generated name. */
-
- label_number = s[1] - '0';
-
- (void) sprintf(symbol_decode = obstack_alloc(&notes, strlen(s + 3) + strlen(message_format) + 10),
- message_format, label_number, s + 3);
-
- return(symbol_decode);
-} /* decode_local_label_name() */
-
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of symbols.c */
diff --git a/gnu/usr.bin/as/symbols.h b/gnu/usr.bin/as/symbols.h
deleted file mode 100644
index edd7ff1..0000000
--- a/gnu/usr.bin/as/symbols.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* symbols.h -
-
- Copyright (C) 1987, 1990, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-extern struct obstack notes; /* eg FixS live here. */
-
-extern struct obstack cond_obstack; /* this is where we track .ifdef/.endif
- (if we do that at all). */
-
-extern unsigned int local_bss_counter; /* Zeroed before a pass. */
-/* Only used by .lcomm directive. */
-
-extern symbolS *symbol_rootP; /* all the symbol nodes */
-extern symbolS *symbol_lastP; /* last struct symbol we made, or NULL */
-
-extern symbolS abs_symbol;
-
-extern symbolS *dot_text_symbol;
-extern symbolS *dot_data_symbol;
-extern symbolS *dot_bss_symbol;
-
-#if __STDC__ == 1
-
-char *decode_local_label_name(char *s);
-char *local_label_name(int n, int augend);
-symbolS *symbol_find(char *name);
-symbolS *symbol_find_base(char *name, int strip_underscore);
-symbolS *symbol_find_or_make(char *name);
-symbolS *symbol_make(char *name);
-symbolS *symbol_new(char *name, segT segment, long value, fragS *frag);
-void colon(char *sym_name);
-void local_colon(int n);
-void symbol_begin(void);
-void symbol_table_insert(symbolS *symbolP);
-void verify_symbol_chain(symbolS *rootP, symbolS *lastP);
-
-#else /* not __STDC__ */
-
-char *decode_local_label_name();
-char *local_label_name();
-symbolS *symbol_find();
-symbolS *symbol_find_base();
-symbolS *symbol_find_or_make();
-symbolS *symbol_make();
-symbolS *symbol_new();
-void colon();
-void local_colon();
-void symbol_begin();
-void symbol_table_insert();
-void verify_symbol_chain();
-
-#endif /* not __STDC__ */
-
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of symbols.h */
diff --git a/gnu/usr.bin/as/tc.h b/gnu/usr.bin/as/tc.h
deleted file mode 100644
index 4641cf7..0000000
--- a/gnu/usr.bin/as/tc.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* tc.h - target cpu dependent
-
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * $Id$
- */
-
-
-/* In theory (mine, at least!) the machine dependent part of the assembler
- should only have to include one file. This one. -- JF */
-
-extern const pseudo_typeS md_pseudo_table[];
-
-/* JF moved this here from as.h under the theory that nobody except MACHINE.c
- and write.c care about it anyway. */
-
-typedef struct
-{
- long rlx_forward; /* Forward reach. Signed number. > 0. */
- long rlx_backward; /* Backward reach. Signed number. < 0. */
- unsigned char rlx_length; /* Bytes length of this address. */
- relax_substateT rlx_more; /* Next longer relax-state. */
- /* 0 means there is no 'next' relax-state. */
-}
-relax_typeS;
-
-extern const relax_typeS md_relax_table[]; /* Define it in MACHINE.c */
-
-extern const int md_reloc_size; /* Size of a relocation record */
-
-extern void (*md_emit_relocations)();
-
-#if __STDC__ == 1
-
-char *md_atof(int what_statement_type, char *literalP, int *sizeP);
-int md_estimate_size_before_relax(fragS *fragP, segT segment);
-int md_parse_option(char **argP, int *cntP, char ***vecP);
-long md_pcrel_from(fixS *fixP);
-long md_section_align(segT seg, long align);
-short tc_coff_fix2rtype(fixS *fixP);
-symbolS *md_undefined_symbol(char *name);
-void md_apply_fix(fixS *fixP, long val);
-void md_assemble(char *str);
-void md_begin(void);
-void md_convert_frag(object_headers *headers, fragS *fragP);
-void md_create_long_jump(char *ptr, long from_addr, long to_addr, fragS *frag, symbolS *to_symbol);
-void md_create_short_jump(char *ptr, long from_addr, long to_addr, fragS *frag, symbolS *to_symbol);
-void md_end(void);
-void md_number_to_chars(char *buf, long val, int n);
-void md_operand(expressionS *expressionP);
-
-#ifndef tc_crawl_symbol_chain
-void tc_crawl_symbol_chain(object_headers *headers);
-#endif /* tc_crawl_symbol_chain */
-
-#ifndef tc_headers_hook
-void tc_headers_hook(object_headers *headers);
-#endif /* tc_headers_hook */
-
-#else
-
-char *md_atof();
-int md_estimate_size_before_relax();
-int md_parse_option();
-long md_pcrel_from();
-long md_section_align();
-short tc_coff_fix2rtype();
-symbolS *md_undefined_symbol();
-void md_apply_fix();
-void md_assemble();
-void md_begin();
-void md_convert_frag();
-void md_create_long_jump();
-void md_create_short_jump();
-void md_end();
-void md_number_to_chars();
-void md_operand();
-
-#ifndef tc_headers_hook
-void tc_headers_hook();
-#endif /* tc_headers_hook */
-
-#ifndef tc_crawl_symbol_chain
-void tc_crawl_symbol_chain();
-#endif /* tc_crawl_symbol_chain */
-
-#endif /* __STDC_ */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of tc.h */
diff --git a/gnu/usr.bin/as/testscripts/doboth b/gnu/usr.bin/as/testscripts/doboth
deleted file mode 100755
index a8c3358..0000000
--- a/gnu/usr.bin/as/testscripts/doboth
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-# $Id$
-
-x=$1 ; shift
-y=$1 ; shift
-
-rm tmp.0 > /dev/null 2>&1
-ln -s $x tmp.0
-$* tmp.0 > tmp.1
-
-rm tmp.0
-ln -s $y tmp.0
-$* tmp.0 > tmp.2
-
-rm tmp.0
-
-diff -c tmp.1 tmp.2
-exit
-
-#eof
diff --git a/gnu/usr.bin/as/testscripts/doobjcmp b/gnu/usr.bin/as/testscripts/doobjcmp
deleted file mode 100755
index 9fbe46b..0000000
--- a/gnu/usr.bin/as/testscripts/doobjcmp
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/bin/sh
-# $Id$
-# compare two object files, in depth.
-
-x=$1
-y=$2
-BOTH="$1 $2"
-
-
-# if they cmp, we're fine.
-if (cmp $BOTH > /dev/null)
-then
- exit 0
-fi
-
-# otherwise, we must look closer.
-if (doboth $BOTH size)
-then
- echo Sizes ok.
-else
- echo Sizes differ:
- size $BOTH
-# exit 1
-fi
-
-if (doboth $BOTH objdump +header)
-then
- echo Headers ok.
-else
- echo Header differences.
-# exit 1
-fi
-
-if (doboth $BOTH objdump +text > /dev/null)
-then
- echo Text ok.
-else
- echo Text differences.
-# doboth $BOTH objdump +text
-# exit 1
-fi
-
-if (doboth $BOTH objdump +data > /dev/null)
-then
- echo Data ok.
-else
- echo Data differences.
-# doboth $BOTH objdump +data
-# exit 1
-fi
-
-if (doboth $BOTH objdump +symbols > /dev/null)
-then
- echo Symbols ok.
-else
- echo -n Symbol differences...
-
- if (doboth $BOTH dounsortsymbols)
- then
- echo but symbols are simply ordered differently.
-# echo Now what to do about relocs'?'
-# exit 1
- else
- echo and symbols differ in content.
- exit 1
- fi
-fi
-
-# of course, if there were symbol diffs, then the reloc symbol indexes
-# will be off.
-
-if (doboth $BOTH objdump -r > /dev/null)
-then
- echo Reloc ok.
-else
- echo -n Reloc differences...
-
- if (doboth $BOTH dounsortreloc)
- then
- echo but relocs are simply ordered differently.
- else
- echo and relocs differ in content.
- exit 1
- fi
-fi
-
-exit
-
-# eof
diff --git a/gnu/usr.bin/as/testscripts/dostriptest b/gnu/usr.bin/as/testscripts/dostriptest
deleted file mode 100755
index 4b89df8..0000000
--- a/gnu/usr.bin/as/testscripts/dostriptest
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-# $Id$
-
-x=striptest.xx.$$
-y=striptest.yy.$$
-
-cp $1 $x
-strip $x
-cp $2 $y
-strip $y
-
-doobjcmp $x $y
-exit
-
-#eof
diff --git a/gnu/usr.bin/as/testscripts/dotest b/gnu/usr.bin/as/testscripts/dotest
deleted file mode 100755
index 8c7a28c..0000000
--- a/gnu/usr.bin/as/testscripts/dotest
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-# ad hoc debug tool
-# $Id$
-
-x=$1
-y=$2
-
-xout=`basename $x`.xxx.$$
-yout=`basename $x`.yyy.$$
-
-mkdir $xout
-mkdir $yout
-
-for i in *.s
-do
- echo Testing $i...
- object=`basename $i .s`.o
- $x $i -o $xout/$object
- $y $i -o $yout/$object
-
-# if they cmp, we're ok. Otherwise we have to look closer.
-
- if (cmp $xout/$object $yout/$object)
- then
- echo $i is ok.
- else
- if (doobjcmp $xout/$object $yout/$object)
- then
- echo Not the same but objcmp ok.
- else
- exit 1
- fi
- fi
-
- echo
-done
-
-rm -rf $xout $yout
-
-exit 0
-
-# EOF
-
-
diff --git a/gnu/usr.bin/as/testscripts/dounsortreloc b/gnu/usr.bin/as/testscripts/dounsortreloc
deleted file mode 100755
index d8da0a9..0000000
--- a/gnu/usr.bin/as/testscripts/dounsortreloc
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-# $Id$
-# objdump the reloc table, but strip off the headings and reloc
-# numbers and sort the result. Intended for use in comparing reloc
-# tables that may not be in the same order.
-
-objdump +reloc +omit-relocation-numbers +omit-symbol-numbers $1 \
- | sort
-#eof
diff --git a/gnu/usr.bin/as/testscripts/dounsortsymbols b/gnu/usr.bin/as/testscripts/dounsortsymbols
deleted file mode 100755
index 8fb6db3f..0000000
--- a/gnu/usr.bin/as/testscripts/dounsortsymbols
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-# $Id$
-# objdump the symbol table, but strip off the headings and symbol
-# numbers and sort the result. Intended for use in comparing symbol
-# tables that may not be in the same order.
-
-objdump +symbols +omit-symbol-numbers $1 \
- | sort
-#eof
diff --git a/gnu/usr.bin/as/version.c b/gnu/usr.bin/as/version.c
deleted file mode 100644
index 569b1ff..0000000
--- a/gnu/usr.bin/as/version.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#if (__STDC__ == 1) || defined(const)
-const
-#endif
-
-/* DO NOT PUT COMMENTS ABOUT CHANGES IN THIS FILE.
-
- This file exists only to define `version_string'.
-
- Log changes in ChangeLog. The easiest way to do this is with
- the Emacs command `add-change-log-entry'. If you don't use Emacs,
- add entries of the form:
-
- Thu Jan 1 00:00:00 1970 Dennis Ritchie (dmr at alice)
-
- universe.c (temporal_reality): Began Time.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-char version_string[] = "GNU assembler version 1.92.3, FreeBSD $Revision: 1.5 $\n";
-
-#ifdef HO_VMS
-dummy3()
-{
-}
-#endif
-
-/* end of version.c */
diff --git a/gnu/usr.bin/as/write.c b/gnu/usr.bin/as/write.c
deleted file mode 100644
index 896d6ee..0000000
--- a/gnu/usr.bin/as/write.c
+++ /dev/null
@@ -1,1224 +0,0 @@
-/* write.c - emit .o file
-
- Copyright (C) 1986, 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* This thing should be set up to do byteordering correctly. But... */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include "as.h"
-#include "subsegs.h"
-#include "obstack.h"
-#include "output-file.h"
-
-/* The NOP_OPCODE is for the alignment fill value.
- * fill it a nop instruction so that the disassembler does not choke
- * on it
- */
-#ifndef NOP_OPCODE
-#define NOP_OPCODE 0x00
-#endif
-
-#ifndef MANY_SEGMENTS
-static struct frag *text_frag_root;
-static struct frag *data_frag_root;
-
-static struct frag *text_last_frag; /* Last frag in segment. */
-static struct frag *data_last_frag; /* Last frag in segment. */
-#endif
-
-#ifndef WORKING_DOT_WORD
-extern const int md_short_jump_size;
-extern const int md_long_jump_size;
-#endif
-
-static object_headers headers;
-
-long string_byte_count;
-
-static char *the_object_file;
-
-char *next_object_file_charP; /* Tracks object file bytes. */
-
-/* static long length; JF unused */ /* String length, including trailing '\0'. */
-
-
-#if __STDC__ == 1
-
-static int is_dnrange(struct frag *f1, struct frag *f2);
-static long fixup_segment(fixS *fixP, segT this_segment_type);
-static relax_addressT relax_align(relax_addressT address, long alignment);
-void relax_segment(struct frag *segment_frag_root, segT segment_type);
-
-#else
-
-static int is_dnrange();
-static long fixup_segment();
-static relax_addressT relax_align();
-void relax_segment();
-
-#endif /* not __STDC__ */
-
-/*
- * fix_new()
- *
- * Create a fixS in obstack 'notes'.
- */
-#ifdef PIC
-fixS *fix_new(frag, where, size, add_symbol, sub_symbol, offset, pcrel, r_type, got_symbol)
-#else
-fixS *fix_new(frag, where, size, add_symbol, sub_symbol, offset, pcrel, r_type)
-#endif
-fragS *frag; /* Which frag? */
-int where; /* Where in that frag? */
-short int size; /* 1, 2, or 4 usually. */
-symbolS *add_symbol; /* X_add_symbol. */
-symbolS *sub_symbol; /* X_subtract_symbol. */
-#ifdef PIC
-symbolS *got_symbol; /* X_got. */
-#endif
-long offset; /* X_add_number. */
-int pcrel; /* TRUE if PC-relative relocation. */
-enum reloc_type r_type; /* Relocation type */
-{
- fixS *fixP;
-
- fixP = (fixS *) obstack_alloc(&notes, sizeof(fixS));
-
- fixP->fx_frag = frag;
- fixP->fx_where = where;
- fixP->fx_size = size;
- fixP->fx_addsy = add_symbol;
- fixP->fx_subsy = sub_symbol;
-#ifdef PIC
- fixP->fx_gotsy = got_symbol;
- if (got_symbol)
- pcrel = 1;
-#endif
- fixP->fx_offset = offset;
- fixP->fx_pcrel = pcrel;
- fixP->fx_r_type = r_type;
-
- /* JF these 'cuz of the NS32K stuff */
- fixP->fx_im_disp = 0;
- fixP->fx_pcrel_adjust = 0;
- fixP->fx_bsr = 0;
- fixP->fx_bit_fixP = 0;
-
- /* usually, we want relocs sorted numerically, but while
- comparing to older versions of gas that have relocs
- reverse sorted, it is convenient to have this compile
- time option. xoxorich. */
-
-#ifdef REVERSE_SORT_RELOCS
-
- fixP->fx_next = *seg_fix_rootP;
- *seg_fix_rootP = fixP;
-
-#else /* REVERSE_SORT_RELOCS */
-
- fixP->fx_next = NULL;
-
- if (*seg_fix_tailP)
- (*seg_fix_tailP)->fx_next = fixP;
- else
- *seg_fix_rootP = fixP;
- *seg_fix_tailP = fixP;
-
-#endif /* REVERSE_SORT_RELOCS */
-
- fixP->fx_callj = 0;
- return(fixP);
-} /* fix_new() */
-
-#ifndef BFD
-void write_object_file()
-{
- register struct frchain * frchainP; /* Track along all frchains. */
- register fragS * fragP; /* Track along all frags. */
- register struct frchain * next_frchainP;
- register fragS * * prev_fragPP;
- /* register char * name; */
- /* symbolS *symbolP; */
- /* register symbolS ** symbolPP; */
- /* register fixS * fixP; JF unused */
- unsigned int data_siz;
-
- long object_file_size;
-
-#ifdef OBJ_VMS
- /*
- * Under VMS we try to be compatible with VAX-11 "C". Thus, we
- * call a routine to check for the definition of the procedure
- * "_main", and if so -- fix it up so that it can be program
- * entry point.
- */
- VMS_Check_For_Main();
-#endif /* OBJ_VMS */
- /*
- * After every sub-segment, we fake an ".align ...". This conforms to BSD4.2
- * brane-damage. We then fake ".fill 0" because that is the kind of frag
- * that requires least thought. ".align" frags like to have a following
- * frag since that makes calculating their intended length trivial.
- */
-#ifndef SUB_SEGMENT_ALIGN
-#define SUB_SEGMENT_ALIGN (2)
-#endif
- for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next) {
-#ifdef OBJ_VMS
- /*
- * Under VAX/VMS, the linker (and PSECT specifications)
- * take care of correctly aligning the segments.
- * Doing the alignment here (on initialized data) can
- * mess up the calculation of global data PSECT sizes.
- */
-#undef SUB_SEGMENT_ALIGN
-#define SUB_SEGMENT_ALIGN ((frchainP->frch_seg != SEG_DATA) ? 2 : 0)
-#endif /* OBJ_VMS */
- subseg_new (frchainP->frch_seg, frchainP->frch_subseg);
- frag_align (SUB_SEGMENT_ALIGN, NOP_OPCODE);
- /* frag_align will have left a new frag. */
- /* Use this last frag for an empty ".fill". */
- /*
- * For this segment ...
- * Create a last frag. Do not leave a "being filled in frag".
- */
- frag_wane (frag_now);
- frag_now->fr_fix = 0;
- know( frag_now->fr_next == NULL );
- /* know(frags.obstack_c_base == frags.obstack_c_next_free); */
- /* Above shows we haven't left a half-completed object on obstack. */
- } /* walk the frag chain */
-
- /*
- * From now on, we don't care about sub-segments.
- * Build one frag chain for each segment. Linked thru fr_next.
- * We know that there is at least 1 text frchain & at least 1 data frchain.
- */
- prev_fragPP = &text_frag_root;
- for (frchainP = frchain_root; frchainP; frchainP = next_frchainP) {
- know( frchainP->frch_root );
- *prev_fragPP = frchainP->frch_root;
- prev_fragPP = & frchainP->frch_last->fr_next;
-
- if (((next_frchainP = frchainP->frch_next) == NULL)
- || next_frchainP == data0_frchainP) {
- prev_fragPP = &data_frag_root;
- if (next_frchainP) {
- text_last_frag = frchainP->frch_last;
- } else {
- data_last_frag = frchainP->frch_last;
- }
- }
- } /* walk the frag chain */
-
- /*
- * We have two segments. If user gave -R flag, then we must put the
- * data frags into the text segment. Do this before relaxing so
- * we know to take advantage of -R and make shorter addresses.
- */
- if (flagseen[ 'R' ]) {
- fixS *tmp;
-
- text_last_frag->fr_next = data_frag_root;
- text_last_frag = data_last_frag;
- data_last_frag = NULL;
- data_frag_root = NULL;
- if (text_fix_root) {
- for (tmp = text_fix_root; tmp->fx_next; tmp = tmp->fx_next) ;;
- tmp->fx_next = data_fix_root;
- } else
- text_fix_root = data_fix_root;
- data_fix_root = NULL;
- }
-
- relax_segment(text_frag_root, SEG_TEXT);
- relax_segment(data_frag_root, SEG_DATA);
- /*
- * Now the addresses of frags are correct within the segment.
- */
-
- know(text_last_frag->fr_type == rs_fill && text_last_frag->fr_offset == 0);
- H_SET_TEXT_SIZE(&headers, text_last_frag->fr_address);
- text_last_frag->fr_address = H_GET_TEXT_SIZE(&headers);
-
- /*
- * Join the 2 segments into 1 huge segment.
- * To do this, re-compute every rn_address in the SEG_DATA frags.
- * Then join the data frags after the text frags.
- *
- * Determine a_data [length of data segment].
- */
- if (data_frag_root) {
- register relax_addressT slide;
-
- know((text_last_frag->fr_type == rs_fill) && (text_last_frag->fr_offset == 0));
-
- H_SET_DATA_SIZE(&headers, data_last_frag->fr_address);
- data_last_frag->fr_address = H_GET_DATA_SIZE(&headers);
- slide = H_GET_TEXT_SIZE(&headers); /* & in file of the data segment. */
-
- for (fragP = data_frag_root; fragP; fragP = fragP->fr_next) {
- fragP->fr_address += slide;
- } /* for each data frag */
-
- know(text_last_frag != 0);
- text_last_frag->fr_next = data_frag_root;
- } else {
- H_SET_DATA_SIZE(&headers,0);
- data_siz = 0;
- }
-
- bss_address_frag.fr_address = (H_GET_TEXT_SIZE(&headers) +
- H_GET_DATA_SIZE(&headers));
-
- H_SET_BSS_SIZE(&headers,local_bss_counter);
-
- /*
- *
- * Crawl the symbol chain.
- *
- * For each symbol whose value depends on a frag, take the address of
- * that frag and subsume it into the value of the symbol.
- * After this, there is just one way to lookup a symbol value.
- * Values are left in their final state for object file emission.
- * We adjust the values of 'L' local symbols, even if we do
- * not intend to emit them to the object file, because their values
- * are needed for fix-ups.
- *
- * Unless we saw a -L flag, remove all symbols that begin with 'L'
- * from the symbol chain. (They are still pointed to by the fixes.)
- *
- * Count the remaining symbols.
- * Assign a symbol number to each symbol.
- * Count the number of string-table chars we will emit.
- * Put this info into the headers as appropriate.
- *
- */
- know(zero_address_frag.fr_address == 0);
- string_byte_count = sizeof(string_byte_count);
-
- obj_crawl_symbol_chain(&headers);
-
- if (string_byte_count == sizeof(string_byte_count)) {
- string_byte_count = 0;
- } /* if no strings, then no count. */
-
- H_SET_STRING_SIZE(&headers, string_byte_count);
-
- /*
- * Addresses of frags now reflect addresses we use in the object file.
- * Symbol values are correct.
- * Scan the frags, converting any ".org"s and ".align"s to ".fill"s.
- * Also converting any machine-dependent frags using md_convert_frag();
- */
- subseg_change(SEG_TEXT, 0);
-
- for (fragP = text_frag_root; fragP; fragP = fragP->fr_next) {
- switch (fragP->fr_type) {
- case rs_align:
- case rs_org:
- fragP->fr_type = rs_fill;
- know(fragP->fr_var == 1);
- know(fragP->fr_next != NULL);
-
- fragP->fr_offset = (fragP->fr_next->fr_address
- - fragP->fr_address
- - fragP->fr_fix);
- break;
-
- case rs_fill:
- break;
-
- case rs_machine_dependent:
- md_convert_frag(&headers, fragP);
-
- know((fragP->fr_next == NULL) || ((fragP->fr_next->fr_address - fragP->fr_address) == fragP->fr_fix));
-
- /*
- * After md_convert_frag, we make the frag into a ".space 0".
- * Md_convert_frag() should set up any fixSs and constants
- * required.
- */
- frag_wane(fragP);
- break;
-
-#ifndef WORKING_DOT_WORD
- case rs_broken_word: {
- struct broken_word *lie;
-
- if (fragP->fr_subtype) {
- fragP->fr_fix+=md_short_jump_size;
- for (lie=(struct broken_word *)(fragP->fr_symbol);lie && lie->dispfrag == fragP;lie=lie->next_broken_word)
- if (lie->added == 1)
- fragP->fr_fix+=md_long_jump_size;
- }
- frag_wane(fragP);
- }
- break;
-#endif
-
- default:
- BAD_CASE( fragP->fr_type );
- break;
- } /* switch (fr_type) */
-
- know((fragP->fr_next == NULL)
- || ((fragP->fr_next->fr_address - fragP->fr_address)
- == (fragP->fr_fix + (fragP->fr_offset * fragP->fr_var))));
- } /* for each frag. */
-
-#ifndef WORKING_DOT_WORD
- {
- struct broken_word *lie;
- struct broken_word **prevP;
-
- prevP = &broken_words;
- for (lie = broken_words; lie; lie = lie->next_broken_word)
- if (!lie->added) {
-#ifdef TC_NS32K
- fix_new_ns32k(lie->frag,
- lie->word_goes_here - lie->frag->fr_literal,
- 2,
- lie->add,
- lie->sub,
- lie->addnum,
- 0, 0, 2, 0, 0, NO_RELOC);
-#else /* TC_NS32K */
-#ifdef PIC
- fix_new(lie->frag, lie->word_goes_here - lie->frag->fr_literal,
- 2, lie->add,
- lie->sub, lie->addnum,
- 0, NO_RELOC, (symbolS *)0);
-#else
- fix_new(lie->frag, lie->word_goes_here - lie->frag->fr_literal,
- 2, lie->add,
- lie->sub, lie->addnum,
- 0, NO_RELOC);
-#endif
-#endif /* TC_NS32K */
- /* md_number_to_chars(lie->word_goes_here,
- S_GET_VALUE(lie->add)
- + lie->addnum
- - S_GET_VALUE(lie->sub),
- 2); */
- *prevP = lie->next_broken_word;
- } else
- prevP = &(lie->next_broken_word);
-
- for (lie = broken_words; lie;) {
- struct broken_word *untruth;
- char *table_ptr;
- long table_addr;
- long from_addr,
- to_addr;
- int n,
- m;
-
- fragP = lie->dispfrag;
-
- /* Find out how many broken_words go here */
- n=0;
- for (untruth = lie; untruth && untruth->dispfrag == fragP; untruth = untruth->next_broken_word)
- if (untruth->added == 1)
- n++;
-
- table_ptr = lie->dispfrag->fr_opcode;
- table_addr = lie->dispfrag->fr_address + (table_ptr - lie->dispfrag->fr_literal);
- /* Create the jump around the long jumps */
- /* This is a short jump from table_ptr+0 to table_ptr+n*long_jump_size */
- from_addr = table_addr;
- to_addr = table_addr + md_short_jump_size + n * md_long_jump_size;
- md_create_short_jump(table_ptr, from_addr, to_addr, lie->dispfrag, lie->add);
- table_ptr += md_short_jump_size;
- table_addr += md_short_jump_size;
-
- for (m = 0; lie && lie->dispfrag == fragP; m++, lie = lie->next_broken_word) {
- if (lie->added == 2)
- continue;
- /* Patch the jump table */
- /* This is the offset from ??? to table_ptr+0 */
- to_addr = table_addr
- - S_GET_VALUE(lie->sub);
- md_number_to_chars(lie->word_goes_here, to_addr, 2);
- for (untruth = lie->next_broken_word;
- untruth && untruth->dispfrag == fragP;
- untruth = untruth->next_broken_word) {
- if (untruth->use_jump == lie)
- md_number_to_chars(untruth->word_goes_here, to_addr, 2);
- }
-
- /* Install the long jump */
- /* this is a long jump from table_ptr+0 to the final target */
- from_addr = table_addr;
- to_addr = S_GET_VALUE(lie->add) + lie->addnum;
- md_create_long_jump(table_ptr, from_addr, to_addr, lie->dispfrag, lie->add);
- table_ptr += md_long_jump_size;
- table_addr += md_long_jump_size;
- }
- }
- }
-#endif /* not WORKING_DOT_WORD */
-
-#ifndef OBJ_VMS
- { /* not vms */
- /*
- * Scan every FixS performing fixups. We had to wait until now to do
- * this because md_convert_frag() may have made some fixSs.
- */
-
- H_SET_RELOCATION_SIZE(&headers,
- md_reloc_size * fixup_segment(text_fix_root, SEG_TEXT),
- md_reloc_size * fixup_segment(data_fix_root, SEG_DATA));
-
-
- obj_pre_write_hook(&headers);
-
- if ((had_warnings() && flagseen['Z'])
- || had_errors() > 0) {
- if (flagseen['Z']) {
- as_warn("%d error%s, %d warning%s, generating bad object file.\n",
- had_errors(), had_errors() == 1 ? "" : "s",
- had_warnings(), had_warnings() == 1 ? "" : "s");
- } else {
- as_fatal("%d error%s, %d warning%s, no object file generated.\n",
- had_errors(), had_errors() == 1 ? "" : "s",
- had_warnings(), had_warnings() == 1 ? "" : "s");
- } /* on want output */
- } /* on error condition */
-
- object_file_size = H_GET_FILE_SIZE(&headers);
- next_object_file_charP = the_object_file = xmalloc(object_file_size);
-
- output_file_create(out_file_name);
-
- obj_header_append(&next_object_file_charP, &headers);
-
- know((next_object_file_charP - the_object_file) == H_GET_HEADER_SIZE(&headers));
-
- /*
- * Emit code.
- */
- for (fragP = text_frag_root; fragP; fragP = fragP->fr_next) {
- register long count;
- register char *fill_literal;
- register long fill_size;
-
- know(fragP->fr_type == rs_fill);
- append(&next_object_file_charP, fragP->fr_literal, (unsigned long) fragP->fr_fix);
- fill_literal = fragP->fr_literal + fragP->fr_fix;
- fill_size = fragP->fr_var;
- know(fragP->fr_offset >= 0);
-
- for (count = fragP->fr_offset; count; count--) {
- append(&next_object_file_charP, fill_literal, (unsigned long) fill_size);
- } /* for each */
-
- } /* for each code frag. */
-
- know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers)));
-
- /*
- * Emit relocations.
- */
- obj_emit_relocations(&next_object_file_charP, text_fix_root, (relax_addressT)0);
- know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers)));
-#ifdef TC_I960
- /* Make addresses in data relocation directives relative to beginning of
- * first data fragment, not end of last text fragment: alignment of the
- * start of the data segment may place a gap between the segments.
- */
- obj_emit_relocations(&next_object_file_charP, data_fix_root, data0_frchainP->frch_root->fr_address);
-#else /* TC_I960 */
- obj_emit_relocations(&next_object_file_charP, data_fix_root, text_last_frag->fr_address);
-#endif /* TC_I960 */
-
- know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers)));
-
- /*
- * Emit line number entries.
- */
- OBJ_EMIT_LINENO(&next_object_file_charP, lineno_rootP, the_object_file);
- know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers) + H_GET_LINENO_SIZE(&headers)));
-
- /*
- * Emit symbols.
- */
- obj_emit_symbols(&next_object_file_charP, symbol_rootP);
- know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers) + H_GET_LINENO_SIZE(&headers) + H_GET_SYMBOL_TABLE_SIZE(&headers)));
-
- /*
- * Emit strings.
- */
-
- if (string_byte_count > 0) {
- obj_emit_strings(&next_object_file_charP);
- } /* only if we have a string table */
-
- /* know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers) + H_GET_LINENO_SIZE(&headers) + H_GET_SYMBOL_TABLE_SIZE(&headers) + H_GET_STRING_SIZE(&headers)));
- */
- /* know(next_object_file_charP == the_object_file + object_file_size);*/
-
-#ifdef BFD_HEADERS
- bfd_seek(stdoutput, 0, 0);
- bfd_write(the_object_file, 1, object_file_size, stdoutput);
-#else
-
- /* Write the data to the file */
- output_file_append(the_object_file, object_file_size, out_file_name);
-#endif
-
- output_file_close(out_file_name);
- } /* non vms output */
-#else /* OBJ_VMS */
- /*
- * Now do the VMS-dependent part of writing the object file
- */
- VMS_write_object_file(H_GET_TEXT_SIZE(&headers), H_GET_DATA_SIZE(&headers),
- text_frag_root, data_frag_root);
-#endif /* OBJ_VMS */
-} /* write_object_file() */
-#else
-#endif
-
-/*
- * relax_segment()
- *
- * Now we have a segment, not a crowd of sub-segments, we can make fr_address
- * values.
- *
- * Relax the frags.
- *
- * After this, all frags in this segment have addresses that are correct
- * within the segment. Since segments live in different file addresses,
- * these frag addresses may not be the same as final object-file addresses.
- */
-
-
-
-void relax_segment(segment_frag_root, segment)
-struct frag * segment_frag_root;
-segT segment; /* SEG_DATA or SEG_TEXT */
-{
- register struct frag * fragP;
- register relax_addressT address;
- /* register relax_addressT old_address; JF unused */
- /* register relax_addressT new_address; JF unused */
-#ifndef MANY_SEGMENTS
- know(segment == SEG_DATA || segment == SEG_TEXT);
-#endif
- /* In case md_estimate_size_before_relax() wants to make fixSs. */
- subseg_change(segment, 0);
-
- /*
- * For each frag in segment: count and store (a 1st guess of) fr_address.
- */
- address = 0;
- for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next) {
- fragP->fr_address = address;
- address += fragP->fr_fix;
-
- switch (fragP->fr_type) {
- case rs_fill:
- address += fragP->fr_offset * fragP->fr_var ;
- break;
-
- case rs_align:
- address += relax_align(address, fragP->fr_offset);
- break;
-
- case rs_org:
- /*
- * Assume .org is nugatory. It will grow with 1st relax.
- */
- break;
-
- case rs_machine_dependent:
- address += md_estimate_size_before_relax(fragP, segment);
- break;
-
-#ifndef WORKING_DOT_WORD
- /* Broken words don't concern us yet */
- case rs_broken_word:
- break;
-#endif
-
- default:
- BAD_CASE(fragP->fr_type);
- break;
- } /* switch (fr_type) */
- } /* for each frag in the segment */
-
- /*
- * Do relax().
- */
- {
- register long stretch; /* May be any size, 0 or negative. */
- /* Cumulative number of addresses we have */
- /* relaxed this pass. */
- /* We may have relaxed more than one address. */
- register long stretched; /* Have we stretched on this pass? */
- /* This is 'cuz stretch may be zero, when,
- in fact some piece of code grew, and
- another shrank. If a branch instruction
- doesn't fit anymore, we could be scrod */
-
- do {
- stretch = stretched = 0;
- for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next) {
- register long growth = 0;
- register unsigned long was_address;
- register long offset;
- register symbolS *symbolP;
- register long target;
- register long after;
- register long aim;
-
- was_address = fragP->fr_address;
- address = fragP->fr_address += stretch;
- symbolP = fragP->fr_symbol;
- offset = fragP->fr_offset;
-
- switch (fragP->fr_type) {
- case rs_fill: /* .fill never relaxes. */
- growth = 0;
- break;
-
-#ifndef WORKING_DOT_WORD
- /* JF: This is RMS's idea. I do *NOT* want to be blamed
- for it I do not want to write it. I do not want to have
- anything to do with it. This is not the proper way to
- implement this misfeature. */
- case rs_broken_word: {
- struct broken_word *lie;
- struct broken_word *untruth;
-
- /* Yes this is ugly (storing the broken_word pointer
- in the symbol slot). Still, this whole chunk of
- code is ugly, and I don't feel like doing anything
- about it. Think of it as stubbornness in action */
- growth=0;
- for (lie=(struct broken_word *)(fragP->fr_symbol);
- lie && lie->dispfrag == fragP;
- lie=lie->next_broken_word) {
-
- if (lie->added)
- continue;
-
- offset = lie->add->sy_frag->fr_address+ S_GET_VALUE(lie->add) + lie->addnum -
- (lie->sub->sy_frag->fr_address+ S_GET_VALUE(lie->sub));
- if (offset <= -32768 || offset >= 32767) {
-#if 0
- if (flagseen['K'])
- as_warn(".word %s-%s+%ld didn't fit",
- S_GET_NAME(lie->add),
- S_GET_NAME(lie->sub),
- lie->addnum);
-#endif
- lie->added=1;
- if (fragP->fr_subtype == 0) {
- fragP->fr_subtype++;
- growth+=md_short_jump_size;
- }
- for (untruth=lie->next_broken_word;untruth && untruth->dispfrag == lie->dispfrag;untruth=untruth->next_broken_word)
- if ((untruth->add->sy_frag == lie->add->sy_frag)
- && S_GET_VALUE(untruth->add) == S_GET_VALUE(lie->add)) {
- untruth->added=2;
- untruth->use_jump=lie;
- }
- growth += md_long_jump_size;
- }
- }
-
- break;
- } /* case rs_broken_word */
-#endif
- case rs_align:
- growth = relax_align((relax_addressT) (address + fragP->fr_fix), offset)
- - relax_align((relax_addressT) (was_address + fragP->fr_fix), offset);
- break;
-
- case rs_org:
- target = offset;
-
- if (symbolP) {
-#ifdef MANY_SEGMENTS
-#else
- know((S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || (S_GET_SEGMENT(symbolP) == SEG_DATA) || (S_GET_SEGMENT(symbolP) == SEG_TEXT));
- know(symbolP->sy_frag);
- know(!(S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || (symbolP->sy_frag == &zero_address_frag));
-#endif
- target += S_GET_VALUE(symbolP)
- + symbolP->sy_frag->fr_address;
- } /* if we have a symbol */
-
- know(fragP->fr_next);
- after = fragP->fr_next->fr_address;
- growth = ((target - after ) > 0) ? (target - after) : 0;
- /* Growth may be -ve, but variable part */
- /* of frag cannot have < 0 chars. */
- /* That is, we can't .org backwards. */
-
- growth -= stretch; /* This is an absolute growth factor */
- break;
-
- case rs_machine_dependent: {
- register const relax_typeS * this_type;
- register const relax_typeS * start_type;
- register relax_substateT next_state;
- register relax_substateT this_state;
-
- start_type = this_type = md_relax_table + (this_state = fragP->fr_subtype);
- target = offset;
-
- if (symbolP) {
-#ifndef MANY_SEGMENTS
- know((S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || (S_GET_SEGMENT(symbolP) == SEG_DATA) || (S_GET_SEGMENT(symbolP) == SEG_TEXT));
-#endif
- know(symbolP->sy_frag);
- know(!(S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || symbolP->sy_frag == &zero_address_frag );
- target +=
- S_GET_VALUE(symbolP)
- + symbolP->sy_frag->fr_address;
-
- /* If frag has yet to be reached on this pass,
- assume it will move by STRETCH just as we did.
- If this is not so, it will be because some frag
- between grows, and that will force another pass. */
-
- /* JF was just address */
- /* JF also added is_dnrange hack */
- /* There's gotta be a better/faster/etc way
- to do this... */
- /* gnu@cygnus.com: I changed this from > to >=
- because I ran into a zero-length frag (fr_fix=0)
- which was created when the obstack needed a new
- chunk JUST AFTER the opcode of a branch. Since
- fr_fix is zero, fr_address of this frag is the same
- as fr_address of the next frag. This
- zero-length frag was variable and jumped to .+2
- (in the next frag), but since the > comparison
- below failed (the two were =, not >), "stretch"
- was not added to the target. Stretch was 178, so
- the offset appeared to be .-176 instead, which did
- not fit into a byte branch, so the assembler
- relaxed the branch to a word. This didn't compare
- with what happened when the same source file was
- assembled on other machines, which is how I found it.
- You might want to think about what other places have
- trouble with zero length frags... */
-
- if (symbolP->sy_frag->fr_address >= was_address
- && is_dnrange(fragP,symbolP->sy_frag)) {
- target += stretch;
- } /* */
-
- } /* if there's a symbol attached */
-
- aim = target - address - fragP->fr_fix;
- /* The displacement is affected by the instruction size
- * for the 32k architecture. I think we ought to be able
- * to add fragP->fr_pcrel_adjust in all cases (it should be
- * zero if not used), but just in case it breaks something
- * else we'll put this inside #ifdef NS32K ... #endif
- */
-#ifdef TC_NS32K
- aim += fragP->fr_pcrel_adjust;
-#endif /* TC_NS32K */
-
- if (aim < 0) {
- /* Look backwards. */
- for (next_state = this_type->rlx_more; next_state; ) {
- if (aim >= this_type->rlx_backward) {
- next_state = 0;
- } else { /* Grow to next state. */
- this_type = md_relax_table + (this_state = next_state);
- next_state = this_type->rlx_more;
- }
- }
- } else {
-#ifdef DONTDEF
- /* JF these next few lines of code are for the mc68020 which can't handle short
- offsets of zero in branch instructions. What a kludge! */
- if (aim == 0 && this_state == (1<<2+0)) { /* FOO hard encoded from m.c */
- aim=this_type->rlx_forward+1; /* Force relaxation into word mode */
- }
-#endif
-#ifdef M68K_AIM_KLUDGE
- M68K_AIM_KLUDGE(aim, this_state, this_type);
-#endif
- /* JF end of 68020 code */
- /* Look forwards. */
- for (next_state = this_type->rlx_more; next_state; ) {
- if (aim <= this_type->rlx_forward) {
- next_state = 0;
- } else { /* Grow to next state. */
- this_type = md_relax_table + (this_state = next_state);
- next_state = this_type->rlx_more;
- }
- }
- }
-
- if ((growth = this_type->rlx_length - start_type->rlx_length) != 0)
- fragP->fr_subtype = this_state;
-
- break;
- } /* case rs_machine_dependent */
-
- default:
- BAD_CASE( fragP->fr_type );
- break;
- }
- if (growth) {
- stretch += growth;
- stretched++;
- }
- } /* For each frag in the segment. */
- } while (stretched); /* Until nothing further to relax. */
- } /* do_relax */
-
- /*
- * We now have valid fr_address'es for each frag.
- */
-
- /*
- * All fr_address's are correct, relative to their own segment.
- * We have made all the fixS we will ever make.
- */
-} /* relax_segment() */
-
-/*
- * Relax_align. Advance location counter to next address that has 'alignment'
- * lowest order bits all 0s.
- */
-
-/* How many addresses does the .align take? */
-static relax_addressT relax_align(address, alignment)
-register relax_addressT address; /* Address now. */
-register long alignment; /* Alignment (binary). */
-{
- relax_addressT mask;
- relax_addressT new_address;
-
- mask = ~ ( (~0) << alignment );
- new_address = (address + mask) & (~ mask);
- return (new_address - address);
-} /* relax_align() */
-
-/* fixup_segment()
-
- Go through all the fixS's in a segment and see which ones can be
- handled now. (These consist of fixS where we have since discovered
- the value of a symbol, or the address of the frag involved.)
- For each one, call md_apply_fix to put the fix into the frag data.
-
- Result is a count of how many relocation structs will be needed to
- handle the remaining fixS's that we couldn't completely handle here.
- These will be output later by emit_relocations(). */
-
-static long fixup_segment(fixP, this_segment_type)
-register fixS *fixP;
-segT this_segment_type; /* N_TYPE bits for segment. */
-{
- register long seg_reloc_count;
- register symbolS *add_symbolP;
- register symbolS *sub_symbolP;
- register long add_number;
- register int size;
- register char *place;
- register long where;
- register char pcrel;
- register fragS *fragP;
- register segT add_symbol_segment = SEG_ABSOLUTE;
-
- /* FIXME: remove this line */ /* fixS *orig = fixP; */
- seg_reloc_count = 0;
-
- for ( ; fixP; fixP = fixP->fx_next) {
- fragP = fixP->fx_frag;
- know(fragP);
- where = fixP->fx_where;
- place = fragP->fr_literal + where;
- size = fixP->fx_size;
- add_symbolP = fixP->fx_addsy;
-#ifdef TC_I960
- if (fixP->fx_callj && TC_S_IS_CALLNAME(add_symbolP)) {
- /* Relocation should be done via the
- associated 'bal' entry point
- symbol. */
-
- if (!TC_S_IS_BALNAME(tc_get_bal_of_call(add_symbolP))) {
- as_bad("No 'bal' entry point for leafproc %s",
- S_GET_NAME(add_symbolP));
- continue;
- }
- fixP->fx_addsy = add_symbolP = tc_get_bal_of_call(add_symbolP);
- } /* callj relocation */
-#endif
- sub_symbolP = fixP->fx_subsy;
- add_number = fixP->fx_offset;
- pcrel = fixP->fx_pcrel;
-
- if (add_symbolP) {
- add_symbol_segment = S_GET_SEGMENT(add_symbolP);
- } /* if there is an addend */
-
- if (sub_symbolP) {
- if (!add_symbolP) {
- /* Its just -sym */
- if (S_GET_SEGMENT(sub_symbolP) != SEG_ABSOLUTE) {
- as_bad("Negative of non-absolute symbol %s", S_GET_NAME(sub_symbolP));
- } /* not absolute */
-
- add_number -= S_GET_VALUE(sub_symbolP);
-
- /* if sub_symbol is in the same segment that add_symbol
- and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE */
- } else if ((S_GET_SEGMENT(sub_symbolP) == add_symbol_segment)
- && (SEG_NORMAL(add_symbol_segment)
- || (add_symbol_segment == SEG_ABSOLUTE))) {
- /* Difference of 2 symbols from same segment. */
- /* Can't make difference of 2 undefineds: 'value' means */
- /* something different for N_UNDF. */
-#ifdef TC_I960
- /* Makes no sense to use the difference of 2 arbitrary symbols
- * as the target of a call instruction.
- */
- if (fixP->fx_callj) {
- as_bad("callj to difference of 2 symbols");
- }
-#endif /* TC_I960 */
-#ifdef PIC
- if (picmode &&
- S_IS_EXTERNAL(add_symbolP)) {
- as_bad("Can't reduce difference of external symbols in PIC code");
- }
-#endif
- add_number += S_GET_VALUE(add_symbolP) -
- S_GET_VALUE(sub_symbolP);
-
- add_symbolP = NULL;
- fixP->fx_addsy = NULL;
- } else {
- /* Different segments in subtraction. */
- know(!(S_IS_EXTERNAL(sub_symbolP) && (S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)));
-
- if ((S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)) {
- add_number -= S_GET_VALUE(sub_symbolP);
- } else {
- as_bad("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.",
- segment_name(S_GET_SEGMENT(sub_symbolP)),
- S_GET_NAME(sub_symbolP), fragP->fr_address + where);
- } /* if absolute */
- }
- } /* if sub_symbolP */
-
-#ifdef PIC
- /*
- * Bring _GLOBAL_OFFSET_TABLE_ forward, now we've had the
- * chance to collapse any accompanying symbols into a number.
- * This is the sequel of the hack in expr.c to parse operands
- * of the form `_GLOBAL_OFFSET_TABLE_+(L1-L2)'. Note that
- * _GLOBAL_OFFSET_TABLE_ can only be an "add symbol".
- */
- if (add_symbolP == NULL && fixP->fx_gotsy != NULL) {
- add_symbolP = fixP->fx_addsy = fixP->fx_gotsy;
- add_symbol_segment = S_GET_SEGMENT(add_symbolP);
- }
-#endif
-
- if (add_symbolP) {
- if (add_symbol_segment == this_segment_type && pcrel) {
- /*
- * This fixup was made when the symbol's segment was
- * SEG_UNKNOWN, but it is now in the local segment.
- * So we know how to do the address without relocation.
- */
-#ifdef TC_I960
- /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal',
- * in which cases it modifies *fixP as appropriate. In the case
- * of a 'calls', no further work is required, and *fixP has been
- * set up to make the rest of the code below a no-op.
- */
- reloc_callj(fixP);
-#endif /* TC_I960 */
-
- add_number += S_GET_VALUE(add_symbolP);
- add_number -= md_pcrel_from(fixP);
- pcrel = 0; /* Lie. Don't want further pcrel processing. */
- fixP->fx_addsy = NULL; /* No relocations please. */
- } else {
- switch (add_symbol_segment) {
- case SEG_ABSOLUTE:
-#ifdef TC_I960
- reloc_callj(fixP); /* See comment about reloc_callj() above*/
-#endif /* TC_I960 */
- add_number += S_GET_VALUE(add_symbolP);
- fixP->fx_addsy = NULL;
- add_symbolP = NULL;
- break;
- default:
- seg_reloc_count ++;
-#ifdef PIC
- /*
- * Do not fixup refs to global data
- * even if defined here.
- */
- if (!picmode ||
-#ifdef TC_NS32K
- fixP->fx_pcrel ||
-#endif
- (fixP->fx_r_type != RELOC_GLOB_DAT &&
-#ifdef TC_I386
-/* XXX - This must be rationalized */
- fixP->fx_r_type != RELOC_GOT &&
- fixP->fx_r_type != RELOC_GOTOFF &&
-#endif
- (fixP->fx_r_type != RELOC_32 ||
- !S_IS_EXTERNAL(add_symbolP))))
-#endif
- add_number += S_GET_VALUE(add_symbolP);
- break;
-
- case SEG_UNKNOWN:
-#ifdef TC_I960
- if ((int)fixP->fx_bit_fixP == 13) {
- /* This is a COBR instruction. They have only a
- * 13-bit displacement and are only to be used
- * for local branches: flag as error, don't generate
- * relocation.
- */
- as_bad("can't use COBR format with external label");
- fixP->fx_addsy = NULL; /* No relocations please. */
- continue;
- } /* COBR */
-#endif /* TC_I960 */
-
-#ifdef OBJ_COFF
-#ifdef TE_I386AIX
- if (S_IS_COMMON(add_symbolP))
- add_number += S_GET_VALUE(add_symbolP);
-#endif /* TE_I386AIX */
-#endif /* OBJ_COFF */
- ++seg_reloc_count;
-
- break;
-
-
- } /* switch on symbol seg */
- } /* if not in local seg */
- } /* if there was a + symbol */
-
- if (pcrel) {
- add_number -= md_pcrel_from(fixP);
- if (add_symbolP == 0) {
- fixP->fx_addsy = & abs_symbol;
- ++seg_reloc_count;
- } /* if there's an add_symbol */
- } /* if pcrel */
-
- if (!fixP->fx_bit_fixP) {
- if ((size == 1 &&
- (add_number& ~0xFF) && (add_number & ~0xFF != (-1 & ~0xFF))) ||
- (size == 2 &&
- (add_number& ~0xFFFF) && (add_number & ~0xFFFF != (-1 & ~0xFFFF)))) {
- as_bad("Value of %d too large for field of %d bytes at 0x%x",
- add_number, size, fragP->fr_address + where);
- } /* generic error checking */
- } /* not a bit fix */
-
- md_apply_fix(fixP, add_number);
- } /* For each fixS in this segment. */
-
-#ifdef OBJ_COFF
-#ifdef TC_I960
- {
- fixS *topP = fixP;
-
- /* two relocs per callj under coff. */
- for (fixP = topP; fixP; fixP = fixP->fx_next) {
- if (fixP->fx_callj && fixP->fx_addsy != 0) {
- ++seg_reloc_count;
- } /* if callj and not already fixed. */
- } /* for each fix */
- }
-#endif /* TC_I960 */
-
-#endif /* OBJ_COFF */
- return(seg_reloc_count);
-} /* fixup_segment() */
-
-
-static int is_dnrange(f1,f2)
-struct frag *f1;
-struct frag *f2;
-{
- while (f1) {
- if (f1->fr_next == f2)
- return 1;
- f1=f1->fr_next;
- }
- return 0;
-} /* is_dnrange() */
-
-/* Append a string onto another string, bumping the pointer along. */
-void
- append (charPP, fromP, length)
-char **charPP;
-char *fromP;
-unsigned long length;
-{
- if (length) { /* Don't trust memcpy() of 0 chars. */
- memcpy(*charPP, fromP, (int) length);
- *charPP += length;
- }
-}
-
-int section_alignment[SEG_MAXIMUM_ORDINAL];
-
-/*
- * This routine records the largest alignment seen for each segment.
- * If the beginning of the segment is aligned on the worst-case
- * boundary, all of the other alignments within it will work. At
- * least one object format really uses this info.
- */
-void record_alignment(seg, align)
-segT seg; /* Segment to which alignment pertains */
-int align; /* Alignment, as a power of 2
- * (e.g., 1 => 2-byte boundary, 2 => 4-byte boundary, etc.)
- */
-{
-
- if ( align > section_alignment[(int) seg] ){
- section_alignment[(int) seg] = align;
- } /* if highest yet */
-
- return;
-} /* record_alignment() */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of write.c */
diff --git a/gnu/usr.bin/as/write.h b/gnu/usr.bin/as/write.h
deleted file mode 100644
index 8b51880..0000000
--- a/gnu/usr.bin/as/write.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* write.h
-
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * write.h,v 1.3 1993/10/02 20:58:02 pk Exp
- */
-
-
-#ifndef TC_I960
-#ifdef hpux
-#define EXEC_MACHINE_TYPE HP9000S200_ID
-#endif
-#endif /* TC_I960 */
-
-#ifndef LOCAL_LABEL
-#ifdef DOT_LABEL_PREFIX
-#define LOCAL_LABEL(name) (name[0] == '.' \
- && (name[1] == 'L' || name[1] == '.'))
-#else /* not defined DOT_LABEL_PREFIX */
-#define LOCAL_LABEL(name) (name[0] == 'L')
-#endif /* not defined DOT_LABEL_PREFIX */
-#endif /* LOCAL_LABEL */
-
-#define S_LOCAL_NAME(s) (LOCAL_LABEL(S_GET_NAME(s)))
-
-#include "bit_fix.h"
-
-/*
- * FixSs may be built up in any order.
- */
-
-struct fix {
- fragS *fx_frag; /* Which frag? */
- long fx_where; /* Where is the 1st byte to fix up? */
- symbolS *fx_addsy; /* NULL or Symbol whose value we add in. */
- symbolS *fx_subsy; /* NULL or Symbol whose value we subtract. */
-#ifdef PIC
- symbolS *fx_gotsy; /* NULL or __GLOBAL_OFFSET_TABLE_ . */
-#endif
- long fx_offset; /* Absolute number we add in. */
- struct fix *fx_next; /* NULL or -> next fixS. */
- short int fx_size; /* How many bytes are involved? */
- char fx_pcrel; /* TRUE: pc-relative. */
- char fx_pcrel_adjust; /* pc-relative offset adjust */
- char fx_im_disp; /* TRUE: value is a displacement */
- bit_fixS *fx_bit_fixP; /* IF NULL no bitfix's to do */
- char fx_bsr; /* sequent-hack */
- enum reloc_type fx_r_type; /* Sparc hacks */
- char fx_callj; /* TRUE if target is a 'callj' (used by i960) */
- long fx_addnumber;
-};
-
-typedef struct fix fixS;
-
-COMMON char *next_object_file_charP;
-
-#ifndef MANY_SEGMENTS
-COMMON fixS *text_fix_root, *text_fix_tail; /* Chains fixSs. */
-COMMON fixS *data_fix_root, *data_fix_tail; /* Chains fixSs. */
-COMMON fixS *bss_fix_root, *bss_fix_tail; /* Chains fixSs. */
-#endif
-COMMON fixS **seg_fix_rootP, **seg_fix_tailP; /* -> one of above. */
-extern long string_byte_count;
-extern int section_alignment[];
-
-#if __STDC__ == 1
-
-bit_fixS *bit_fix_new(int size, int offset, long base_type, long base_adj, long min, long max, long add);
-void append(char **charPP, char *fromP, unsigned long length);
-void record_alignment(segT seg, int align);
-void write_object_file(void);
-
-fixS *fix_new(fragS *frag,
- int where,
- int size,
- symbolS *add_symbol,
- symbolS *sub_symbol,
- long offset,
- int pcrel,
- enum reloc_type r_type
-#ifdef PIC
- ,symbolS *got_symbol);
-#else
- );
-#endif
-
-#else /* not __STDC__ */
-
-bit_fixS *bit_fix_new();
-fixS *fix_new();
-void append();
-void record_alignment();
-void write_object_file();
-
-#endif /* not __STDC__ */
-
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
-
-/* end of write.h */
diff --git a/gnu/usr.bin/as/xmalloc.c b/gnu/usr.bin/as/xmalloc.c
deleted file mode 100644
index 754ffa2..0000000
--- a/gnu/usr.bin/as/xmalloc.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* xmalloc.c - get memory or bust
-
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- NAME
- xmalloc() - get memory or bust
- INDEX
- xmalloc() uses malloc()
-
- SYNOPSIS
- char * my_memory;
-
- my_memory = xmalloc(42); / * my_memory gets address of 42 chars * /
-
- DESCRIPTION
-
- Use xmalloc() as an "error-free" malloc(). It does almost the same job.
- When it cannot honour your request for memory it BOMBS your program
- with a "virtual memory exceeded" message. Malloc() returns NULL and
- does not bomb your program.
-
- SEE ALSO
- malloc()
-
- */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-#include <stdio.h>
-
-#if __STDC__ == 1
-#include <stdlib.h>
-#else
-#ifdef USG
-#include <malloc.h>
-#else
-char * malloc();
-#endif /* USG */
-#endif /* not __STDC__ */
-
-#define error as_fatal
-
-char * xmalloc(n)
-long n;
-{
- char * retval;
- void error();
-
- if ((retval = malloc ((unsigned)n)) == NULL)
- {
- error("virtual memory exceeded");
- }
- return (retval);
-}
-
-/* end of xmalloc.c */
diff --git a/gnu/usr.bin/as/xrealloc.c b/gnu/usr.bin/as/xrealloc.c
deleted file mode 100644
index 933022b..0000000
--- a/gnu/usr.bin/as/xrealloc.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* xrealloc.c - new memory or bust
-
- Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS 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.
-
- GAS 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 GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
-/*
-
- NAME
- xrealloc () - get more memory or bust
- INDEX
- xrealloc () uses realloc ()
- SYNOPSIS
- char *my_memory;
-
- my_memory = xrealloc (my_memory, 42);
- / * my_memory gets (perhaps new) address of 42 chars * /
-
- DESCRIPTION
-
- Use xrealloc () as an "error-free" realloc ().It does almost the same
- job. When it cannot honour your request for memory it BOMBS your
- program with a "virtual memory exceeded" message. Realloc() returns
- NULL and does not bomb your program.
-
- SEE ALSO
- realloc ()
- */
-
-#ifndef lint
-static char rcsid[] = "$Id$";
-#endif
-
-
-#if __STDC__ == 1
-#include <stdlib.h>
-#else
-#ifdef USG
-#include <malloc.h>
-#else
-char *realloc ();
-#endif /* USG */
-#endif /* not __STDC__ */
-
-#define error as_fatal
-
-char *
- xrealloc (ptr, n)
-register char *ptr;
-long n;
-{
- void error();
-
- if ((ptr = realloc (ptr, (unsigned)n)) == 0)
- error ("virtual memory exceeded");
- return (ptr);
-}
-
-/* end of xrealloc.c */
diff --git a/gnu/usr.bin/awk/Makefile b/gnu/usr.bin/awk/Makefile
deleted file mode 100644
index 1db89d5..0000000
--- a/gnu/usr.bin/awk/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Makefile copyright James Raynard (jraynard@freebsd.org) 1997
-#
-# $Id: Makefile,v 1.9 1997/10/26 12:20:45 ache Exp $
-
-.include "${.CURDIR}/../Makefile.inc"
-
-.PATH: ${.CURDIR}/../../../contrib/awk
-
-PROG= awk
-SRCS= array.c awktab.c builtin.c eval.c field.c gawkmisc.c io.c main.c \
- msg.c node.c re.c version.c dfa.c getopt.c getopt1.c
-MAN1= doc/awk.1
-
-YACC = bison -y
-
-# Important for ctype macros!
-CFLAGS+= -funsigned-char
-
-CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../../../contrib/awk
-CFLAGS+= -DHAVE_CONFIG_H -DGAWK -DDEFPATH=\".\"
-CLEANFILES +=awktab.c y.output y.tab.h
-
-SUBDIR+= doc
-
-DPADD+= ${LIBGNUREGEX} ${LIBM}
-LDADD+= -lgnuregex -lm
-
-
-awktab.c: ${.CURDIR}/../../../contrib/awk/awk.y
- $(YACC) -v $> && mv y.tab.c awktab.c
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/awk/doc/Makefile b/gnu/usr.bin/awk/doc/Makefile
deleted file mode 100644
index 456e6e0..0000000
--- a/gnu/usr.bin/awk/doc/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# Makefile copyright James Raynard (jraynard@freebsd.org) 1997
-#
-# $Id: Makefile,v 1.5 1997/10/11 17:05:07 jraynard Exp $
-
-.PATH: ${.CURDIR}/../../../../contrib/awk/doc
-
-INFO = gawk
-INFOSECTION= "System Utilities"
-INFOENTRY_gawk= "* GAWK: (gawk). The GNU AWK language interpreter manual."
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/bc/COPYING b/gnu/usr.bin/bc/COPYING
deleted file mode 100644
index 86cf81a..0000000
--- a/gnu/usr.bin/bc/COPYING
+++ /dev/null
@@ -1,341 +0,0 @@
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
-
diff --git a/gnu/usr.bin/bc/Makefile b/gnu/usr.bin/bc/Makefile
deleted file mode 100644
index e4a2738..0000000
--- a/gnu/usr.bin/bc/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-PROG= bc
-
-BCSRCS= execute.c global.c load.c main.c number.c storage.c util.c
-GENSRCS= bc.c scan.c
-SRCS= ${GENSRCS} ${BCSRCS}
-
-CFLAGS+= -D_POSIX_SOURCE -I.
-CLEANFILES+= ${GENSRCS} y.tab.h
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/bc/bc.1 b/gnu/usr.bin/bc/bc.1
deleted file mode 100644
index 0244de0..0000000
--- a/gnu/usr.bin/bc/bc.1
+++ /dev/null
@@ -1,732 +0,0 @@
-.\"
-.\" bc.1 - the *roff document processor source for the bc manual
-.\"
-.\" This file is part of bc written initially for MINIX.
-.\" Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
-.\" the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-.\"
-.\" You may contact the author by:
-.\" e-mail: phil@cs.wwu.edu
-.\" us-mail: Philip A. Nelson
-.\" Computer Science Department, 9062
-.\" Western Washington University
-.\" Bellingham, WA 98226-9062
-.\"
-.\" $Id$
-.\"
-.TH bc 1 .\" "Command Manual" v1.03 "Nov 2, 1994"
-.SH NAME
-bc - An arbitrary precision calculator language
-.SH SYNTAX
-\fBbc\fR [ \fB-lws\fR ] [ \fI file ...\fR ]
-.SH VERSION
-This man page documents GNU bc version 1.03.
-.SH DESCRIPTION
-\fBbc\fR is a language that supports arbitrary precision numbers
-with interactive execution of statements. There are some similarities
-in the syntax to the C programming language.
-A standard math library is available by command line option.
-If requested, the math library is defined before processing any files.
-\fBbc\fR starts by processing code from all the files listed
-on the command line in the order listed. After all files have been
-processed, \fBbc\fR reads from the standard input. All code is
-executed as it is read. (If a file contains a command to halt the
-processor, \fBbc\fR will never read from the standard input.)
-.PP
-This version of \fBbc\fR contains several extensions beyond
-traditional \fBbc\fR implementations and the POSIX draft standard.
-Command line options can cause these extensions to print a warning
-or to be rejected. This
-document describes the language accepted by this processor.
-Extensions will be identified as such.
-.SS OPTIONS
-.IP -l
-Define the standard math library.
-.IP -w
-Give warnings for extensions to POSIX \fBbc\fR.
-.IP -s
-Process exactly the POSIX \fBbc\fR language.
-.SS NUMBERS
-The most basic element in \fBbc\fR is the number. Numbers are
-arbitrary precision numbers. This precision is both in the integer
-part and the fractional part. All numbers are represented internally
-in decimal and all computation is done in decimal. (This version
-truncates results from divide and multiply operations.) There are two
-attributes of numbers, the length and the scale. The length is the
-total number of significant decimal digits in a number and the scale
-is the total number of decimal digits after the decimal point. For
-example:
-.nf
-.RS
- .000001 has a length of 6 and scale of 6.
- 1935.000 has a length of 7 and a scale of 3.
-.RE
-.fi
-.SS VARIABLES
-Numbers are stored in two types of variables, simple variables and
-arrays. Both simple variables and array variables are named. Names
-begin with a letter followed by any number of letters, digits and
-underscores. All letters must be lower case. (Full alpha-numeric
-names are an extension. In POSIX \fBbc\fR all names are a single
-lower case letter.) The type of variable is clear by the context
-because all array variable names will be followed by brackets ([]).
-.PP
-There are four special variables, \fBscale, ibase, obase,\fR and
-\fBlast\fR. \fBscale\fR defines how some operations use digits after the
-decimal point. The default value of \fBscale\fR is 0. \fBibase\fR
-and \fBobase\fR define the conversion base for input and output
-numbers. The default for both input and output is base 10.
-\fBlast\fR (an extension) is a variable that has the value of the last
-printed number. These will be discussed in further detail where
-appropriate. All of these variables may have values assigned to them
-as well as used in expressions.
-.SS COMMENTS
-Comments in \fBbc\fR start with the characters \fB/*\fR and end with
-the characters \fB*/\fR. Comments may start anywhere and appear as a
-single space in the input. (This causes comments to delimit other
-input items. For example, a comment can not be found in the middle of
-a variable name.) Comments include any newlines (end of line) between
-the start and the end of the comment.
-.SS EXPRESSIONS
-The numbers are manipulated by expressions and statements. Since
-the language was designed to be interactive, statements and expressions
-are executed as soon as possible. There is no "main" program. Instead,
-code is executed as it is encountered. (Functions, discussed in
-detail later, are defined when encountered.)
-.PP
-A simple expression is just a constant. \fBbc\fR converts constants
-into internal decimal numbers using the current input base, specified
-by the variable \fBibase\fR. (There is an exception in functions.)
-The legal values of \fBibase\fR are 2 through 16 (F). Assigning a
-value outside this range to \fBibase\fR will result in a value of 2
-or 16. Input numbers may contain the characters 0-9 and A-F. (Note:
-They must be capitals. Lower case letters are variable names.)
-Single digit numbers always have the value of the digit regardless of
-the value of \fBibase\fR. (i.e. A = 10.) For multi-digit numbers,
-\fBbc\fR changes all input digits greater or equal to ibase to the
-value of \fBibase\fR-1. This makes the number \fBFFF\fR always be
-the largest 3 digit number of the input base.
-.PP
-Full expressions are similar to many other high level languages.
-Since there is only one kind of number, there are no rules for mixing
-types. Instead, there are rules on the scale of expressions. Every
-expression has a scale. This is derived from the scale of original
-numbers, the operation performed and in many cases, the value of the
-variable \fBscale\fR. Legal values of the variable \fBscale\fR are
-0 to the maximum number representable by a C integer.
-.PP
-In the following descriptions of legal expressions, "expr" refers to a
-complete expression and "var" refers to a simple or an array variable.
-A simple variable is just a
-.RS
-\fIname\fR
-.RE
-and an array variable is specified as
-.RS
-\fIname\fR[\fIexpr\fR]
-.RE
-Unless specifically
-mentioned the scale of the result is the maximum scale of the
-expressions involved.
-.IP "- expr"
-The result is the negation of the expression.
-.IP "++ var"
-The variable is incremented by one and the new value is the result of
-the expression.
-.IP "-- var"
-The variable
-is decremented by one and the new value is the result of the
-expression.
-.IP "var ++"
- The result of the expression is the value of
-the variable and then the variable is incremented by one.
-.IP "var --"
-The result of the expression is the value of the variable and then
-the variable is decremented by one.
-.IP "expr + expr"
-The result of the expression is the sum of the two expressions.
-.IP "expr - expr"
-The result of the expression is the difference of the two expressions.
-.IP "expr * expr"
-The result of the expression is the product of the two expressions.
-.IP "expr / expr"
-The result of the expression is the quotient of the two expressions.
-The scale of the result is the value of the variable \fBscale\fR.
-.IP "expr % expr"
-The result of the expression is the "remainder" and it is computed in the
-following way. To compute a%b, first a/b is computed to \fBscale\fR
-digits. That result is used to compute a-(a/b)*b to the scale of the
-maximum of \fBscale\fR+scale(b) and scale(a). If \fBscale\fR is set
-to zero and both expressions are integers this expression is the
-integer remainder function.
-.IP "expr ^ expr"
-The result of the expression is the value of the first raised to the
-second. The second expression must be an integer. (If the second
-expression is not an integer, a warning is generated and the
-expression is truncated to get an integer value.) The scale of the
-result is \fBscale\fR if the exponent is negative. If the exponent
-is positive the scale of the result is the minimum of the scale of the
-first expression times the value of the exponent and the maximum of
-\fBscale\fR and the scale of the first expression. (e.g. scale(a^b)
-= min(scale(a)*b, max( \fBscale,\fR scale(a))).) It should be noted
-that expr^0 will always return the value of 1.
-.IP "( expr )"
-This alters the standard precedence to force the evaluation of the
-expression.
-.IP "var = expr"
-The variable is assigned the value of the expression.
-.IP "var <op>= expr"
-This is equivalent to "var = var <op> expr" with the exception that
-the "var" part is evaluated only once. This can make a difference if
-"var" is an array.
-.PP
- Relational expressions are a special kind of expression
-that always evaluate to 0 or 1, 0 if the relation is false and 1 if
-the relation is true. These may appear in any legal expression.
-(POSIX bc requires that relational expressions are used only in if,
-while, and for statements and that only one relational test may be
-done in them.) The relational operators are
-.IP "expr1 < expr2"
-The result is 1 if expr1 is strictly less than expr2.
-.IP "expr1 <= expr2"
-The result is 1 if expr1 is less than or equal to expr2.
-.IP "expr1 > expr2"
-The result is 1 if expr1 is strictly greater than expr2.
-.IP "expr1 >= expr2"
-The result is 1 if expr1 is greater than or equal to expr2.
-.IP "expr1 == expr2"
-The result is 1 if expr1 is equal to expr2.
-.IP "expr1 != expr2"
-The result is 1 if expr1 is not equal to expr2.
-.PP
-Boolean operations are also legal. (POSIX \fBbc\fR does NOT have
-boolean operations). The result of all boolean operations are 0 and 1
-(for false and true) as in relational expressions. The boolean
-operators are:
-.IP "!expr"
-The result is 1 if expr is 0.
-.IP "expr && expr"
-The result is 1 if both expressions are non-zero.
-.IP "expr || expr"
-The result is 1 if either expression is non-zero.
-.PP
-The expression precedence is as follows: (lowest to highest)
-.nf
-.RS
-|| operator, left associative
-&& operator, left associative
-! operator, nonassociative
-Relational operators, left associative
-Assignment operator, right associative
-+ and - operators, left associative
-*, / and % operators, left associative
-^ operator, right associative
-unary - operator, nonassociative
-++ and -- operators, nonassociative
-.RE
-.fi
-.PP
-This precedence was chosen so that POSIX compliant \fBbc\fR programs
-will run correctly. This will cause the use of the relational and
-logical operators to have some unusual behavior when used with
-assignment expressions. Consider the expression:
-.RS
-a = 3 < 5
-.RE
-.PP
-Most C programmers would assume this would assign the result of "3 <
-5" (the value 1) to the variable "a". What this does in \fBbc\fR is
-assign the value 3 to the variable "a" and then compare 3 to 5. It is
-best to use parenthesis when using relational and logical operators
-with the assignment operators.
-.PP
-There are a few more special expressions that are provided in \fBbc\fR.
-These have to do with user defined functions and standard
-functions. They all appear as "\fIname\fB(\fIparameters\fB)\fR".
-See the section on functions for user defined functions. The standard
-functions are:
-.IP "length ( expression )"
-The value of the length function is the number of significant digits in the
-expression.
-.IP "read ( )"
-The read function (an extension) will read a number from the standard
-input, regardless of where the function occurs. Beware, this can
-cause problems with the mixing of data and program in the standard input.
-The best use for this function is in a previously written program that
-needs input from the user, but never allows program code to be input
-from the user. The value of the read function is the number read from
-the standard input using the current value of the variable
-\fBibase\fR for the conversion base.
-.IP "scale ( expression )"
-The value of the scale function is the number of digits after the decimal
-point in the expression.
-.IP "sqrt ( expression )"
-The value of the sqrt function is the square root of the expression. If
-the expression is negative, a run time error is generated.
-.SS STATEMENTS
-Statements (as in most algebraic languages) provide the sequencing of
-expression evaluation. In \fBbc\fR statements are executed "as soon
-as possible." Execution happens when a newline in encountered and
-there is one or more complete statements. Due to this immediate
-execution, newlines are very important in \fBbc\fR. In fact, both a
-semicolon and a newline are used as statement separators. An
-improperly placed newline will cause a syntax error. Because newlines
-are statement separators, it is possible to hide a newline by using
-the backslash character. The sequence "\e<nl>", where <nl> is the
-newline appears to \fBbc\fR as whitespace instead of a newline. A
-statement list is a series of statements separated by semicolons and
-newlines. The following is a list of \fBbc\fR statements and what
-they do: (Things enclosed in brackets ([]) are optional parts of the
-statement.)
-.IP "expression"
-This statement does one of two things. If the expression starts with
-"<variable> <assignment> ...", it is considered to be an assignment
-statement. If the expression is not an assignment statement, the
-expression is evaluated and printed to the output. After the number
-is printed, a newline is printed. For example, "a=1" is an assignment
-statement and "(a=1)" is an expression that has an embedded
-assignment. All numbers that are printed are printed in the base
-specified by the variable \fBobase\fR. The legal values for \fB
-obase\fR are 2 through BC_BASE_MAX. (See the section LIMITS.) For
-bases 2 through 16, the usual method of writing numbers is used. For
-bases greater than 16, \fBbc\fR uses a multi-character digit method
-of printing the numbers where each higher base digit is printed as a
-base 10 number. The multi-character digits are separated by spaces.
-Each digit contains the number of characters required to represent the
-base ten value of "obase-1". Since numbers are of arbitrary
-precision, some numbers may not be printable on a single output line.
-These long numbers will be split across lines using the "\e" as the
-last character on a line. The maximum number of characters printed
-per line is 70. Due to the interactive nature of \fBbc\fR printing
-a number cause the side effect of assigning the printed value the
-special variable \fBlast\fR. This allows the user to recover the
-last value printed without having to retype the expression that
-printed the number. Assigning to \fBlast\fR is legal and will
-overwrite the last printed value with the assigned value. The newly
-assigned value will remain until the next number is printed or another
-value is assigned to \fBlast\fR. (Some installations may allow the
-use of a single period (.) which is not part of a number as a short
-hand notation for for \fBlast\fR.)
-.IP "string"
-The string is printed to the output. Strings start with a double quote
-character and contain all characters until the next double quote character.
-All characters are take literally, including any newline. No newline
-character is printed after the string.
-.IP "\fBprint\fR list"
-The print statement (an extension) provides another method of output.
-The "list" is a list of strings and expressions separated by commas.
-Each string or expression is printed in the order of the list. No
-terminating newline is printed. Expressions are evaluated and their
-value is printed and assigned the variable \fBlast\fR. Strings
-in the print statement are printed to the output and may contain
-special characters. Special characters start with the backslash
-character (\e). The special characters recognized by \fBbc\fR are
-"a" (alert or bell), "b" (backspace), "f" (form feed), "n" (newline),
-"r" (carriage return), "q" (double quote), "t" (tab), and "\e" (backslash).
-Any other character following the backslash will be ignored.
-.IP "{ statement_list }"
-This is the compound statement. It allows multiple statements to be
-grouped together for execution.
-.IP "\fBif\fR ( expression ) \fBthen\fR statement1 [\fBelse\fR statement2]"
-The if statement evaluates the expression and executes statement1 or
-statement2 depending on the value of the expression. If the expression
-is non-zero, statement1 is executed. If statement2 is present and
-the value of the expression is 0, then statement2 is executed. (The
-else clause is an extension.)
-.IP "\fBwhile\fR ( expression ) statement"
-The while statement will execute the statement while the expression
-is non-zero. It evaluates the expression before each execution of
-the statement. Termination of the loop is caused by a zero
-expression value or the execution of a break statement.
-.IP "\fBfor\fR ( [expression1] ; [expression2] ; [expression3] ) statement"
-The for statement controls repeated execution of the statement.
-Expression1 is evaluated before the loop. Expression2 is evaluated
-before each execution of the statement. If it is non-zero, the statement
-is evaluated. If it is zero, the loop is terminated. After each
-execution of the statement, expression3 is evaluated before the reevaluation
-of expression2. If expression1 or expression3 are missing, nothing is
-evaluated at the point they would be evaluated.
-If expression2 is missing, it is the same as substituting
-the value 1 for expression2. (The optional expressions are an
-extension. POSIX \fBbc\fR requires all three expressions.)
-The following is equivalent code for the for statement:
-.nf
-.RS
-expression1;
-while (expression2) {
- statement;
- expression3;
-}
-.RE
-.fi
-.IP "\fBbreak\fR"
-This statement causes a forced exit of the most recent enclosing while
-statement or for statement.
-.IP "\fBcontinue\fR"
-The continue statement (an extension) causes the most recent enclosing
-for statement to start the next iteration.
-.IP "\fBhalt\fR"
-The halt statement (an extension) is an executed statement that causes
-the \fBbc\fR processor to quit only when it is executed. For example,
-"if (0 == 1) halt" will not cause \fBbc\fR to terminate because the halt is
-not executed.
-.IP "\fBreturn\fR"
-Return the value 0 from a function. (See the section on functions.)
-.IP "\fBreturn\fR ( expression )"
-Return the value of the expression from a function. (See the section on
-functions.)
-.SS PSEUDO STATEMENTS
-These statements are not statements in the traditional sense. They are
-not executed statements. Their function is performed at "compile" time.
-.IP "\fBlimits\fR"
-Print the local limits enforced by the local version of \fBbc\fR. This
-is an extension.
-.IP "\fBquit\fR"
-When the quit statement is read, the \fBbc\fR processor
-is terminated, regardless of where the quit statement is found. For
-example, "if (0 == 1) quit" will cause \fBbc\fR to terminate.
-.IP "\fBwarranty\fR"
-Print a longer warranty notice. This is an extension.
-.SS FUNCTIONS
-Functions provide a method of defining a computation that can be executed
-later. Functions in
-.B bc
-always compute a value and return it to the caller. Function definitions
-are "dynamic" in the sense that a function is undefined until a definition
-is encountered in the input. That definition is then used until another
-definition function for the same name is encountered. The new definition
-then replaces the older definition. A function is defined as follows:
-.nf
-.RS
-\fBdefine \fIname \fB( \fIparameters \fB) { \fInewline
-\fI auto_list statement_list \fB}\fR
-.RE
-.fi
-A function call is just an expression of the form
-"\fIname\fB(\fIparameters\fB)\fR".
-.PP
-Parameters are numbers or arrays (an extension). In the function definition,
-zero or more parameters are defined by listing their names separated by
-commas. Numbers are only call by value parameters. Arrays are only
-call by variable. Arrays are specified in the parameter definition by
-the notation "\fIname\fB[]\fR". In the function call, actual parameters
-are full expressions for number parameters. The same notation is used
-for passing arrays as for defining array parameters. The named array is
-passed by variable to the function. Since function definitions are dynamic,
-parameter numbers and types are checked when a function is called. Any
-mismatch in number or types of parameters will cause a runtime error.
-A runtime error will also occur for the call to an undefined function.
-.PP
-The \fIauto_list\fR is an optional list of variables that are for
-"local" use. The syntax of the auto list (if present) is "\fBauto
-\fIname\fR, ... ;". (The semicolon is optional.) Each \fIname\fR is
-the name of an auto variable. Arrays may be specified by using the
-same notation as used in parameters. These variables have their
-values pushed onto a stack at the start of the function. The
-variables are then initialized to zero and used throughout the
-execution of the function. At function exit, these variables are
-popped so that the original value (at the time of the function call)
-of these variables are restored. The parameters are really auto
-variables that are initialized to a value provided in the function
-call. Auto variables are different than traditional local variables
-in the fact that if function A calls function B, B may access function
-A's auto variables by just using the same name, unless function B has
-called them auto variables. Due to the fact that auto variables and
-parameters are pushed onto a stack, \fBbc\fR supports recursive functions.
-.PP
-The function body is a list of \fBbc\fR statements. Again, statements
-are separated by semicolons or newlines. Return statements cause the
-termination of a function and the return of a value. There are two
-versions of the return statement. The first form, "\fBreturn\fR", returns
-the value 0 to the calling expression. The second form,
-"\fBreturn ( \fIexpression \fB)\fR", computes the value of the expression
-and returns that value to the calling expression. There is an implied
-"\fBreturn (0)\fR" at the end of every function. This allows a function
-to terminate and return 0 without an explicit return statement.
-.PP
-Functions also change the usage of the variable \fBibase\fR. All
-constants in the function body will be converted using the value of
-\fBibase\fR at the time of the function call. Changes of \fBibase\fR
-will be ignored during the execution of the function except for the
-standard function \fBread\fR, which will always use the current value
-of \fBibase\fR for conversion of numbers.
-.SS MATH LIBRARY
-If \fBbc\fR is invoked with the \fB-l\fR option, a math library is preloaded
-and the default scale is set to 20. The math functions will calculate their
-results to the scale set at the time of their call.
-The math library defines the following functions:
-.IP "s (\fIx\fR)"
-The sine of x in radians.
-.IP "c (\fIx\fR)"
-The cosine of x in radians.
-.IP "a (\fIx\fR)"
-The arctangent of x.
-.IP "l (\fIx\fR)"
-The natural logarithm of x.
-.IP "e (\fIx\fR)"
-The exponential function of raising e to the value x.
-.IP "j (\fIn,x\fR)"
-The bessel function of integer order n of x.
-.SS EXAMPLES
-In /bin/sh, the following will assign the value of "pi" to the shell
-variable \fBpi\fR.
-.RS
-\f(CW
-pi=$(echo "scale=10; 4*a(1)" | bc -l)
-\fR
-.RE
-.PP
-The following is the definition of the exponential function used in the
-math library. This function is written in POSIX \fBbc\fR.
-.nf
-.RS
-\f(CW
-scale = 20
-
-/* Uses the fact that e^x = (e^(x/2))^2
- When x is small enough, we use the series:
- e^x = 1 + x + x^2/2! + x^3/3! + ...
-*/
-
-define e(x) {
- auto a, d, e, f, i, m, v, z
-
- /* Check the sign of x. */
- if (x<0) {
- m = 1
- x = -x
- }
-
- /* Precondition x. */
- z = scale;
- scale = 4 + z + .44*x;
- while (x > 1) {
- f += 1;
- x /= 2;
- }
-
- /* Initialize the variables. */
- v = 1+x
- a = x
- d = 1
-
- for (i=2; 1; i++) {
- e = (a *= x) / (d *= i)
- if (e == 0) {
- if (f>0) while (f--) v = v*v;
- scale = z
- if (m) return (1/v);
- return (v/1);
- }
- v += e
- }
-}
-\fR
-.RE
-.fi
-.PP
-The following is code that uses the extended features of \fBbc\fR to
-implement a simple program for calculating checkbook balances. This
-program is best kept in a file so that it can be used many times
-without having to retype it at every use.
-.nf
-.RS
-\f(CW
-scale=2
-print "\enCheck book program!\en"
-print " Remember, deposits are negative transactions.\en"
-print " Exit by a 0 transaction.\en\en"
-
-print "Initial balance? "; bal = read()
-bal /= 1
-print "\en"
-while (1) {
- "current balance = "; bal
- "transaction? "; trans = read()
- if (trans == 0) break;
- bal -= trans
- bal /= 1
-}
-quit
-\fR
-.RE
-.fi
-.PP
-The following is the definition of the recursive factorial function.
-.nf
-.RS
-\f(CW
-define f (x) {
- if (x <= 1) return (1);
- return (f(x-1) * x);
-}
-\fR
-.RE
-.fi
-.SS DIFFERENCES
-This version of
-.B bc
-was implemented from the POSIX P1003.2/D11 draft and contains
-several differences and extensions relative to the draft and
-traditional implementations.
-It is not implemented in the traditional way using
-.I dc(1).
-This version is a single process which parses and runs a byte code
-translation of the program. There is an "undocumented" option (-c)
-that causes the program to output the byte code to
-the standard output instead of running it. It was mainly used for
-debugging the parser and preparing the math library.
-.PP
-A major source of differences is
-extensions, where a feature is extended to add more functionality and
-additions, where new features are added.
-The following is the list of differences and extensions.
-.IP LANG environment
-This version does not conform to the POSIX standard in the processing
-of the LANG environment variable and all environment variables starting
-with LC_.
-.IP names
-Traditional and POSIX
-.B bc
-have single letter names for functions, variables and arrays. They have
-been extended to be multi-character names that start with a letter and
-may contain letters, numbers and the underscore character.
-.IP Strings
-Strings are not allowed to contain NUL characters. POSIX says all characters
-must be included in strings.
-.IP last
-POSIX \fBbc\fR does not have a \fBlast\fR variable. Some implementations
-of \fBbc\fR use the period (.) in a similar way.
-.IP comparisons
-POSIX \fBbc\fR allows comparisons only in the if statement, the while
-statement, and the second expression of the for statement. Also, only
-one relational operation is allowed in each of those statements.
-.IP "if statement, else clause"
-POSIX \fBbc\fR does not have an else clause.
-.IP "for statement"
-POSIX \fBbc\fR requires all expressions to be present in the for statement.
-.IP "&&, ||, !"
-POSIX \fBbc\fR does not have the logical operators.
-.IP "read function"
-POSIX \fBbc\fR does not have a read function.
-.IP "print statement"
-POSIX \fBbc\fR does not have a print statement .
-.IP "continue statement"
-POSIX \fBbc\fR does not have a continue statement.
-.IP "array parameters"
-POSIX \fBbc\fR does not have array parameters. Other implementations
-of \fBbc\fR may have call by value array parameters.
-.IP "=+, =-, =*, =/, =%, =^"
-POSIX \fBbc\fR does not require these "old style" assignment operators to
-be defined. This version may allow these "old style" assignments. Use
-the limits statement to see if the installed version supports them. If
-it does support the "old style" assignment operators, the statement
-"a =- 1" will decrement \fBa\fR by 1 instead of setting \fBa\fR to the
-value -1.
-.IP "spaces in numbers"
-Other implementations of \fBbc\fR allow spaces in numbers. For example,
-"x=1 3" would assign the value 13 to the variable x. The same statement
-would cause a syntax error in this version of \fBbc\fR.
-.IP "errors and execution"
-This implementation varies from other implementations in terms of what
-code will be executed when syntax and other errors are found in the
-program. If a syntax error is found in a function definition, error
-recovery tries to find the beginning of a statement and continue to
-parse the function. Once a syntax error is found in the function, the
-function will not be callable and becomes undefined.
-Syntax errors in the interactive execution code will invalidate the
-current execution block. The execution block is terminated by an
-end of line that appears after a complete sequence of statements.
-For example,
-.nf
-.RS
-a = 1
-b = 2
-.RE
-.fi
-has two execution blocks and
-.nf
-.RS
-{ a = 1
- b = 2 }
-.RE
-.fi
-has one execution block. Any runtime error will terminate the execution
-of the current execution block. A runtime warning will not terminate the
-current execution block.
-.IP "Interrupts"
-During an interactive session, the SIGINT signal (usually generated by
-the control-C character from the terminal) will cause execution of the
-current execution block to be interrupted. It will display a "runtime"
-error indicating which function was interrupted. After all runtime
-structures have been cleaned up, a message will be printed to notify the
-user that \fBbc\fR is ready for more input. All previously defined functions
-remain defined and the value of all non-auto variables are the value at
-the point of interruption. All auto variables and function parameters
-are removed during the
-clean up process. During a non-interactive
-session, the SIGINT signal will terminate the entire run of \fBbc\fR.
-.SS LIMITS
-The following are the limits currently in place for this
-.B bc
-processor. Some of them may have been changed by an installation.
-Use the limits statement to see the actual values.
-.IP BC_BASE_MAX
-The maximum output base is currently set at 999. The maximum input base
-is 16.
-.IP BC_DIM_MAX
-This is currently an arbitrary limit of 65535 as distributed. Your
-installation may be different.
-.IP BC_SCALE_MAX
-The number of digits after the decimal point is limited to INT_MAX digits.
-Also, the number of digits before the decimal point is limited to INT_MAX
-digits.
-.IP BC_STRING_MAX
-The limit on the number of characters in a string is INT_MAX characters.
-.IP exponent
-The value of the exponent in the raise operation (^) is limited to LONG_MAX.
-.IP multiply
-The multiply routine may yield incorrect results if a number
-has more than LONG_MAX / 90 total digits. For 32 bit longs, this number is
-23,860,929 digits.
-.IP "code size"
-Each function and the "main" program are limited to 16384 bytes of
-compiled byte code each. This limit (BC_MAX_SEGS) can be easily changed
-to have more than 16 segments of 1024 bytes.
-.IP "variable names"
-The current limit on the number of unique names is 32767 for each of
-simple variables, arrays and functions.
-.SH FILES
-In most installations, \fBbc\fR is completely self-contained.
-Where executable size is of importance or the C compiler does
-not deal with very long strings, \fBbc\fR will read
-the standard math library from the file /usr/local/lib/libmath.b.
-(The actual location may vary. It may be /lib/libmath.b.)
-.SH DIAGNOSTICS
-If any file on the command line can not be opened, \fBbc\fR will report
-that the file is unavailable and terminate. Also, there are compile
-and run time diagnostics that should be self-explanatory.
-.SH BUGS
-Error recovery is not very good yet.
-.SH AUTHOR
-.nf
-Philip A. Nelson
-phil@cs.wwu.edu
-.fi
-.SH ACKNOWLEDGEMENTS
-The author would like to thank Steve Sommars (Steve.Sommars@att.com) for
-his extensive help in testing the implementation. Many great suggestions
-were given. This is a much better product due to his involvement.
diff --git a/gnu/usr.bin/bc/bc.y b/gnu/usr.bin/bc/bc.y
deleted file mode 100644
index 2c888c3..0000000
--- a/gnu/usr.bin/bc/bc.y
+++ /dev/null
@@ -1,615 +0,0 @@
-%{
-/* bc.y: The grammar for a POSIX compatable bc processor with some
- extensions to the language. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-#include "bcdefs.h"
-#include "global.h"
-#include "proto.h"
-%}
-
-%start program
-
-%union {
- char *s_value;
- char c_value;
- int i_value;
- arg_list *a_value;
- }
-
-/* Extensions over POSIX bc.
- a) NAME was LETTER. This grammer allows longer names.
- Single letter names will still work.
- b) Relational_expression allowed only one comparison.
- This grammar has added boolean expressions with
- && (and) || (or) and ! (not) and allowed all of them in
- full expressions.
- c) Added an else to the if.
- d) Call by variable array parameters
- e) read() procedure that reads a number under program control from stdin.
- f) halt statement that halts the the program under program control. It
- is an executed statement.
- g) continue statement for for loops.
- h) optional expressions in the for loop.
- i) print statement to print multiple numbers per line.
- j) warranty statement to print an extended warranty notice.
- j) limits statement to print the processor's limits.
-*/
-
-%token <i_value> NEWLINE AND OR NOT
-%token <s_value> STRING NAME NUMBER
-/* '-', '+' are tokens themselves */
-%token <c_value> MUL_OP
-/* '*', '/', '%' */
-%token <c_value> ASSIGN_OP
-/* '=', '+=', '-=', '*=', '/=', '%=', '^=' */
-%token <s_value> REL_OP
-/* '==', '<=', '>=', '!=', '<', '>' */
-%token <c_value> INCR_DECR
-/* '++', '--' */
-%token <i_value> Define Break Quit Length
-/* 'define', 'break', 'quit', 'length' */
-%token <i_value> Return For If While Sqrt Else
-/* 'return', 'for', 'if', 'while', 'sqrt', 'else' */
-%token <i_value> Scale Ibase Obase Auto Read
-/* 'scale', 'ibase', 'obase', 'auto', 'read' */
-%token <i_value> Warranty, Halt, Last, Continue, Print, Limits
-/* 'warranty', 'halt', 'last', 'continue', 'print', 'limits' */
-
-/* Types of all other things. */
-%type <i_value> expression return_expression named_expression opt_expression
-%type <c_value> '+' '-'
-%type <a_value> opt_parameter_list opt_auto_define_list define_list
-%type <a_value> opt_argument_list argument_list
-%type <i_value> program input_item semicolon_list statement_list
-%type <i_value> statement function statement_or_error
-
-/* precedence */
-%left OR
-%left AND
-%nonassoc NOT
-%left REL_OP
-%right ASSIGN_OP
-%left '+' '-'
-%left MUL_OP
-%right '^'
-%nonassoc UNARY_MINUS
-%nonassoc INCR_DECR
-
-%%
-program : /* empty */
- {
- $$ = 0;
- if (interactive)
- {
- printf ("%s\n", BC_VERSION);
- welcome ();
- }
- }
- | program input_item
- ;
-input_item : semicolon_list NEWLINE
- { run_code (); }
- | function
- { run_code (); }
- | error NEWLINE
- {
- yyerrok;
- init_gen ();
- }
- ;
-semicolon_list : /* empty */
- { $$ = 0; }
- | statement_or_error
- | semicolon_list ';' statement_or_error
- | semicolon_list ';'
- ;
-statement_list : /* empty */
- { $$ = 0; }
- | statement_or_error
- | statement_list NEWLINE
- | statement_list NEWLINE statement_or_error
- | statement_list ';'
- | statement_list ';' statement
- ;
-statement_or_error : statement
- | error statement
- { $$ = $2; }
- ;
-statement : Warranty
- { warranty (""); }
- | Limits
- { limits (); }
- | expression
- {
- if ($1 & 2)
- warn ("comparison in expression");
- if ($1 & 1)
- generate ("W");
- else
- generate ("p");
- }
- | STRING
- {
- $$ = 0;
- generate ("w");
- generate ($1);
- free ($1);
- }
- | Break
- {
- if (break_label == 0)
- yyerror ("Break outside a for/while");
- else
- {
- sprintf (genstr, "J%1d:", break_label);
- generate (genstr);
- }
- }
- | Continue
- {
- warn ("Continue statement");
- if (continue_label == 0)
- yyerror ("Continue outside a for");
- else
- {
- sprintf (genstr, "J%1d:", continue_label);
- generate (genstr);
- }
- }
- | Quit
- { exit (0); }
- | Halt
- { generate ("h"); }
- | Return
- { generate ("0R"); }
- | Return '(' return_expression ')'
- { generate ("R"); }
- | For
- {
- $1 = break_label;
- break_label = next_label++;
- }
- '(' opt_expression ';'
- {
- if ($4 > 1)
- warn ("Comparison in first for expression");
- $4 = next_label++;
- if ($4 < 0)
- sprintf (genstr, "N%1d:", $4);
- else
- sprintf (genstr, "pN%1d:", $4);
- generate (genstr);
- }
- opt_expression ';'
- {
- if ($7 < 0) generate ("1");
- $7 = next_label++;
- sprintf (genstr, "B%1d:J%1d:", $7, break_label);
- generate (genstr);
- $<i_value>$ = continue_label;
- continue_label = next_label++;
- sprintf (genstr, "N%1d:", continue_label);
- generate (genstr);
- }
- opt_expression ')'
- {
- if ($10 > 1)
- warn ("Comparison in third for expression");
- if ($10 < 0)
- sprintf (genstr, "J%1d:N%1d:", $4, $7);
- else
- sprintf (genstr, "pJ%1d:N%1d:", $4, $7);
- generate (genstr);
- }
- statement
- {
- sprintf (genstr, "J%1d:N%1d:",
- continue_label, break_label);
- generate (genstr);
- break_label = $1;
- continue_label = $<i_value>9;
- }
- | If '(' expression ')'
- {
- $3 = if_label;
- if_label = next_label++;
- sprintf (genstr, "Z%1d:", if_label);
- generate (genstr);
- }
- statement opt_else
- {
- sprintf (genstr, "N%1d:", if_label);
- generate (genstr);
- if_label = $3;
- }
- | While
- {
- $1 = next_label++;
- sprintf (genstr, "N%1d:", $1);
- generate (genstr);
- }
- '(' expression
- {
- $4 = break_label;
- break_label = next_label++;
- sprintf (genstr, "Z%1d:", break_label);
- generate (genstr);
- }
- ')' statement
- {
- sprintf (genstr, "J%1d:N%1d:", $1, break_label);
- generate (genstr);
- break_label = $4;
- }
- | '{' statement_list '}'
- { $$ = 0; }
- | Print
- { warn ("print statement"); }
- print_list
- ;
-print_list : print_element
- | print_element ',' print_list
- ;
-print_element : STRING
- {
- generate ("O");
- generate ($1);
- free ($1);
- }
- | expression
- { generate ("P"); }
- ;
-opt_else : /* nothing */
- | Else
- {
- warn ("else clause in if statement");
- $1 = next_label++;
- sprintf (genstr, "J%d:N%1d:", $1, if_label);
- generate (genstr);
- if_label = $1;
- }
- statement
-function : Define NAME '(' opt_parameter_list ')' '{'
- NEWLINE opt_auto_define_list
- {
- /* Check auto list against parameter list? */
- check_params ($4,$8);
- sprintf (genstr, "F%d,%s.%s[",
- lookup($2,FUNCTDEF),
- arg_str ($4), arg_str ($8));
- generate (genstr);
- free_args ($4);
- free_args ($8);
- $1 = next_label;
- next_label = 1;
- }
- statement_list /* NEWLINE */ '}'
- {
- generate ("0R]");
- next_label = $1;
- }
- ;
-opt_parameter_list : /* empty */
- { $$ = NULL; }
- | define_list
- ;
-opt_auto_define_list : /* empty */
- { $$ = NULL; }
- | Auto define_list NEWLINE
- { $$ = $2; }
- | Auto define_list ';'
- { $$ = $2; }
- ;
-define_list : NAME
- { $$ = nextarg (NULL, lookup ($1,SIMPLE)); }
- | NAME '[' ']'
- { $$ = nextarg (NULL, lookup ($1,ARRAY)); }
- | define_list ',' NAME
- { $$ = nextarg ($1, lookup ($3,SIMPLE)); }
- | define_list ',' NAME '[' ']'
- { $$ = nextarg ($1, lookup ($3,ARRAY)); }
- ;
-opt_argument_list : /* empty */
- { $$ = NULL; }
- | argument_list
- ;
-argument_list : expression
- {
- if ($1 > 1) warn ("comparison in argument");
- $$ = nextarg (NULL,0);
- }
- | NAME '[' ']'
- {
- sprintf (genstr, "K%d:", -lookup ($1,ARRAY));
- generate (genstr);
- $$ = nextarg (NULL,1);
- }
- | argument_list ',' expression
- {
- if ($3 > 1) warn ("comparison in argument");
- $$ = nextarg ($1,0);
- }
- | argument_list ',' NAME '[' ']'
- {
- sprintf (genstr, "K%d:", -lookup ($3,ARRAY));
- generate (genstr);
- $$ = nextarg ($1,1);
- }
- ;
-opt_expression : /* empty */
- {
- $$ = -1;
- warn ("Missing expression in for statement");
- }
- | expression
- ;
-return_expression : /* empty */
- {
- $$ = 0;
- generate ("0");
- }
- | expression
- {
- if ($1 > 1)
- warn ("comparison in return expresion");
- }
- ;
-expression : named_expression ASSIGN_OP
- {
- if ($2 != '=')
- {
- if ($1 < 0)
- sprintf (genstr, "DL%d:", -$1);
- else
- sprintf (genstr, "l%d:", $1);
- generate (genstr);
- }
- }
- expression
- {
- if ($4 > 1) warn("comparison in assignment");
- if ($2 != '=')
- {
- sprintf (genstr, "%c", $2);
- generate (genstr);
- }
- if ($1 < 0)
- sprintf (genstr, "S%d:", -$1);
- else
- sprintf (genstr, "s%d:", $1);
- generate (genstr);
- $$ = 0;
- }
- ;
- | expression AND
- {
- warn("&& operator");
- $2 = next_label++;
- sprintf (genstr, "DZ%d:p", $2);
- generate (genstr);
- }
- expression
- {
- sprintf (genstr, "DZ%d:p1N%d:", $2, $2);
- generate (genstr);
- $$ = $1 | $4;
- }
- | expression OR
- {
- warn("|| operator");
- $2 = next_label++;
- sprintf (genstr, "B%d:", $2);
- generate (genstr);
- }
- expression
- {
- int tmplab;
- tmplab = next_label++;
- sprintf (genstr, "B%d:0J%d:N%d:1N%d:",
- $2, tmplab, $2, tmplab);
- generate (genstr);
- $$ = $1 | $4;
- }
- | NOT expression
- {
- $$ = $2;
- warn("! operator");
- generate ("!");
- }
- | expression REL_OP expression
- {
- $$ = 3;
- switch (*($2))
- {
- case '=':
- generate ("=");
- break;
-
- case '!':
- generate ("#");
- break;
-
- case '<':
- if ($2[1] == '=')
- generate ("{");
- else
- generate ("<");
- break;
-
- case '>':
- if ($2[1] == '=')
- generate ("}");
- else
- generate (">");
- break;
- }
- }
- | expression '+' expression
- {
- generate ("+");
- $$ = $1 | $3;
- }
- | expression '-' expression
- {
- generate ("-");
- $$ = $1 | $3;
- }
- | expression MUL_OP expression
- {
- genstr[0] = $2;
- genstr[1] = 0;
- generate (genstr);
- $$ = $1 | $3;
- }
- | expression '^' expression
- {
- generate ("^");
- $$ = $1 | $3;
- }
- | '-' expression %prec UNARY_MINUS
- {
- generate ("n");
- $$ = $2;
- }
- | named_expression
- {
- $$ = 1;
- if ($1 < 0)
- sprintf (genstr, "L%d:", -$1);
- else
- sprintf (genstr, "l%d:", $1);
- generate (genstr);
- }
- | NUMBER
- {
- int len = strlen($1);
- $$ = 1;
- if (len == 1 && *$1 == '0')
- generate ("0");
- else if (len == 1 && *$1 == '1')
- generate ("1");
- else
- {
- generate ("K");
- generate ($1);
- generate (":");
- }
- free ($1);
- }
- | '(' expression ')'
- { $$ = $2 | 1; }
- | NAME '(' opt_argument_list ')'
- {
- $$ = 1;
- if ($3 != NULL)
- {
- sprintf (genstr, "C%d,%s:",
- lookup ($1,FUNCT),
- call_str ($3));
- free_args ($3);
- }
- else
- {
- sprintf (genstr, "C%d:", lookup ($1,FUNCT));
- }
- generate (genstr);
- }
- | INCR_DECR named_expression
- {
- $$ = 1;
- if ($2 < 0)
- {
- if ($1 == '+')
- sprintf (genstr, "DA%d:L%d:", -$2, -$2);
- else
- sprintf (genstr, "DM%d:L%d:", -$2, -$2);
- }
- else
- {
- if ($1 == '+')
- sprintf (genstr, "i%d:l%d:", $2, $2);
- else
- sprintf (genstr, "d%d:l%d:", $2, $2);
- }
- generate (genstr);
- }
- | named_expression INCR_DECR
- {
- $$ = 1;
- if ($1 < 0)
- {
- sprintf (genstr, "DL%d:x", -$1);
- generate (genstr);
- if ($2 == '+')
- sprintf (genstr, "A%d:", -$1);
- else
- sprintf (genstr, "M%d:", -$1);
- }
- else
- {
- sprintf (genstr, "l%d:", $1);
- generate (genstr);
- if ($2 == '+')
- sprintf (genstr, "i%d:", $1);
- else
- sprintf (genstr, "d%d:", $1);
- }
- generate (genstr);
- }
- | Length '(' expression ')'
- { generate ("cL"); $$ = 1;}
- | Sqrt '(' expression ')'
- { generate ("cR"); $$ = 1;}
- | Scale '(' expression ')'
- { generate ("cS"); $$ = 1;}
- | Read '(' ')'
- {
- warn ("read function");
- generate ("cI"); $$ = 1;
- }
- ;
-named_expression : NAME
- { $$ = lookup($1,SIMPLE); }
- | NAME '[' expression ']'
- {
- if ($3 > 1) warn("comparison in subscript");
- $$ = lookup($1,ARRAY);
- }
- | Ibase
- { $$ = 0; }
- | Obase
- { $$ = 1; }
- | Scale
- { $$ = 2; }
- | Last
- { $$ = 3;
- warn ("Last variable");
- }
- ;
-%%
diff --git a/gnu/usr.bin/bc/bcdefs.h b/gnu/usr.bin/bc/bcdefs.h
deleted file mode 100644
index 455530d..0000000
--- a/gnu/usr.bin/bc/bcdefs.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/* bcdefs.h: The single file to include all constants and type definitions. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-/* Include the configuration file. */
-#include "config.h"
-
-/* Standard includes for all files. */
-#include <stdio.h>
-#include <sys/types.h>
-#include <ctype.h>
-#ifdef STRINGS_H
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-#ifndef NO_LIMITS
-#include <limits.h>
-#endif
-
-/* Include the other definitions. */
-#include "const.h"
-#include "number.h"
-
-
-/* These definitions define all the structures used in
- code and data storage. This includes the representation of
- labels. The "guiding" principle is to make structures that
- take a minimum of space when unused but can be built to contain
- the full structures. */
-
-/* Labels are first. Labels are generated sequentially in functions
- and full code. They just "point" to a single bye in the code. The
- "address" is the byte number. The byte number is used to get an
- actual character pointer. */
-
-typedef struct bc_label_group
- {
- long l_adrs [ BC_LABEL_GROUP ];
- struct bc_label_group *l_next;
- } bc_label_group;
-
-
-/* Each function has its own code segments and labels. There can be
- no jumps between functions so labels are unique to a function. */
-
-typedef struct arg_list
- {
- int av_name;
- struct arg_list *next;
- } arg_list;
-
-typedef struct
- {
- char f_defined; /* Is this function defined yet. */
- char *f_body[BC_MAX_SEGS];
- int f_code_size;
- bc_label_group *f_label;
- arg_list *f_params;
- arg_list *f_autos;
- } bc_function;
-
-/* Code addresses. */
-typedef struct {
- int pc_func;
- int pc_addr;
- } program_counter;
-
-
-/* Variables are "pushable" (auto) and thus we need a stack mechanism.
- This is built into the variable record. */
-
-typedef struct bc_var
- {
- bc_num v_value;
- struct bc_var *v_next;
- } bc_var;
-
-
-/* bc arrays can also be "auto" variables and thus need the same
- kind of stacking mechanisms. */
-
-typedef struct bc_array_node
- {
- union
- {
- bc_num n_num [NODE_SIZE];
- struct bc_array_node *n_down [NODE_SIZE];
- } n_items;
- } bc_array_node;
-
-typedef struct bc_array
- {
- bc_array_node *a_tree;
- short a_depth;
- } bc_array;
-
-typedef struct bc_var_array
- {
- bc_array *a_value;
- char a_param;
- struct bc_var_array *a_next;
- } bc_var_array;
-
-
-/* For the stacks, execution and function, we need records to allow
- for arbitrary size. */
-
-typedef struct estack_rec {
- bc_num s_num;
- struct estack_rec *s_next;
-} estack_rec;
-
-typedef struct fstack_rec {
- int s_val;
- struct fstack_rec *s_next;
-} fstack_rec;
-
-
-/* The following are for the name tree. */
-
-typedef struct id_rec {
- char *id; /* The program name. */
- /* A name == 0 => nothing assigned yet. */
- int a_name; /* The array variable name (number). */
- int f_name; /* The function name (number). */
- int v_name; /* The variable name (number). */
- short balance; /* For the balanced tree. */
- struct id_rec *left, *right; /* Tree pointers. */
-} id_rec;
diff --git a/gnu/usr.bin/bc/config.h b/gnu/usr.bin/bc/config.h
deleted file mode 100644
index a9bd0be..0000000
--- a/gnu/usr.bin/bc/config.h
+++ /dev/null
@@ -1,4 +0,0 @@
-/* config.h */
-#ifndef __STDC__
-#define VARARGS
-#endif
diff --git a/gnu/usr.bin/bc/const.h b/gnu/usr.bin/bc/const.h
deleted file mode 100644
index 1b55adc..0000000
--- a/gnu/usr.bin/bc/const.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* const.h: Constants for bc. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-
-/* Define INT_MAX and LONG_MAX if not defined. Assuming 32 bits... */
-
-#ifdef NO_LIMITS
-#define INT_MAX 0x7FFFFFFF
-#define LONG_MAX 0x7FFFFFFF
-#endif
-
-
-/* Define constants in some reasonable size. The next 4 constants are
- POSIX constants. */
-#if !defined(_POSIX_SOURCE)
-#define BC_BASE_MAX INT_MAX
-#define BC_SCALE_MAX INT_MAX
-#define BC_STRING_MAX INT_MAX
-
-/* Definitions for arrays. */
-
-#define BC_DIM_MAX 65535 /* this should be NODE_SIZE^NODE_DEPTH-1 */
-#endif
-
-#define NODE_SIZE 16 /* Must be a power of 2. */
-#define NODE_MASK 0xf /* Must be NODE_SIZE-1. */
-#define NODE_SHIFT 4 /* Number of 1 bits in NODE_MASK. */
-#define NODE_DEPTH 4
-
-
-/* Other BC limits defined but not part of POSIX. */
-
-#define BC_LABEL_GROUP 64
-#define BC_LABEL_LOG 6
-#define BC_MAX_SEGS 16 /* Code segments. */
-#define BC_SEG_SIZE 1024
-#define BC_SEG_LOG 10
-
-/* Maximum number of variables, arrays and functions and the
- allocation increment for the dynamic arrays. */
-
-#define MAX_STORE 32767
-#define STORE_INCR 32
-
-/* Other interesting constants. */
-
-#define FALSE 0
-#define TRUE 1
-
-/* for use with lookup (). */
-#define SIMPLE 0
-#define ARRAY 1
-#define FUNCT 2
-#define FUNCTDEF 3
-
-#define EXTERN extern
-#ifdef __STDC__
-#define CONST const
-#define VOID void
-#else
-#define CONST
-#define VOID
-#endif
-
-/* Include the version definition. */
-#include "version.h"
diff --git a/gnu/usr.bin/bc/execute.c b/gnu/usr.bin/bc/execute.c
deleted file mode 100644
index 1a89506..0000000
--- a/gnu/usr.bin/bc/execute.c
+++ /dev/null
@@ -1,785 +0,0 @@
-/* execute.c - run a bc program. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-#include "bcdefs.h"
-#include <signal.h>
-#include "global.h"
-#include "proto.h"
-
-
-/* The SIGINT interrupt handling routine. */
-
-int had_sigint;
-
-void
-stop_execution (sig)
- int sig;
-{
- had_sigint = TRUE;
- printf ("\n");
- rt_error ("interrupted execution");
-}
-
-
-/* Get the current byte and advance the PC counter. */
-
-unsigned char
-byte (pc)
- program_counter *pc;
-{
- int seg, offset;
-
- seg = pc->pc_addr >> BC_SEG_LOG;
- offset = pc->pc_addr++ % BC_SEG_SIZE;
- return (functions[pc->pc_func].f_body[seg][offset]);
-}
-
-
-/* The routine that actually runs the machine. */
-
-void
-execute ()
-{
- int label_num, l_gp, l_off;
- bc_label_group *gp;
-
- char inst, ch;
- int new_func;
- int var_name;
-
- int const_base;
-
- bc_num temp_num;
- arg_list *auto_list;
-
- /* Initialize this run... */
- pc.pc_func = 0;
- pc.pc_addr = 0;
- runtime_error = FALSE;
- init_num (&temp_num);
-
- /* Set up the interrupt mechanism for an interactive session. */
- if (interactive)
- {
- signal (SIGINT, stop_execution);
- had_sigint = FALSE;
- }
-
- while (pc.pc_addr < functions[pc.pc_func].f_code_size && !runtime_error)
- {
- inst = byte(&pc);
-
-#if DEBUG > 3
- { /* Print out address and the stack before each instruction.*/
- int depth; estack_rec *temp = ex_stack;
-
- printf ("func=%d addr=%d inst=%c\n",pc.pc_func, pc.pc_addr, inst);
- if (temp == NULL) printf ("empty stack.\n", inst);
- else
- {
- depth = 1;
- while (temp != NULL)
- {
- printf (" %d = ", depth);
- out_num (temp->s_num, 10, out_char);
- depth++;
- temp = temp->s_next;
- }
- }
- }
-#endif
-
- switch ( inst )
- {
-
- case 'A' : /* increment array variable (Add one). */
- var_name = byte(&pc);
- if ((var_name & 0x80) != 0)
- var_name = ((var_name << 8) & 0x7f) + byte(&pc);
- incr_array (var_name);
- break;
-
- case 'B' : /* Branch to a label if TOS != 0. Remove value on TOS. */
- case 'Z' : /* Branch to a label if TOS == 0. Remove value on TOS. */
- c_code = !is_zero (ex_stack->s_num);
- pop ();
- case 'J' : /* Jump to a label. */
- label_num = byte(&pc); /* Low order bits first. */
- label_num += byte(&pc) << 8;
- if (inst == 'J' || (inst == 'B' && c_code)
- || (inst == 'Z' && !c_code)) {
- gp = functions[pc.pc_func].f_label;
- l_gp = label_num >> BC_LABEL_LOG;
- l_off = label_num % BC_LABEL_GROUP;
- while (l_gp-- > 0) gp = gp->l_next;
- pc.pc_addr = gp->l_adrs[l_off];
- }
- break;
-
- case 'C' : /* Call a function. */
- /* Get the function number. */
- new_func = byte(&pc);
- if ((new_func & 0x80) != 0)
- new_func = ((new_func << 8) & 0x7f) + byte(&pc);
-
- /* Check to make sure it is defined. */
- if (!functions[new_func].f_defined)
- {
- rt_error ("Function %s not defined.", f_names[new_func]);
- break;
- }
-
- /* Check and push parameters. */
- process_params (&pc, new_func);
-
- /* Push auto variables. */
- for (auto_list = functions[new_func].f_autos;
- auto_list != NULL;
- auto_list = auto_list->next)
- auto_var (auto_list->av_name);
-
- /* Push pc and ibase. */
- fpush (pc.pc_func);
- fpush (pc.pc_addr);
- fpush (i_base);
-
- /* Reset pc to start of function. */
- pc.pc_func = new_func;
- pc.pc_addr = 0;
- break;
-
- case 'D' : /* Duplicate top of stack */
- push_copy (ex_stack->s_num);
- break;
-
- case 'K' : /* Push a constant */
- /* Get the input base and convert it to a bc number. */
- if (pc.pc_func == 0)
- const_base = i_base;
- else
- const_base = fn_stack->s_val;
- if (const_base == 10)
- push_b10_const (&pc);
- else
- push_constant (prog_char, const_base);
- break;
-
- case 'L' : /* load array variable */
- var_name = byte(&pc);
- if ((var_name & 0x80) != 0)
- var_name = ((var_name << 8) & 0x7f) + byte(&pc);
- load_array (var_name);
- break;
-
- case 'M' : /* decrement array variable (Minus!) */
- var_name = byte(&pc);
- if ((var_name & 0x80) != 0)
- var_name = ((var_name << 8) & 0x7f) + byte(&pc);
- decr_array (var_name);
- break;
-
- case 'O' : /* Write a string to the output with processing. */
- while ((ch = byte(&pc)) != '"')
- if (ch != '\\')
- out_char (ch);
- else
- {
- ch = byte(&pc);
- if (ch == '"') break;
- switch (ch)
- {
- case 'a': out_char (007); break;
- case 'b': out_char ('\b'); break;
- case 'f': out_char ('\f'); break;
- case 'n': out_char ('\n'); break;
- case 'q': out_char ('"'); break;
- case 'r': out_char ('\r'); break;
- case 't': out_char ('\t'); break;
- case '\\': out_char ('\\'); break;
- default: break;
- }
- }
- if (interactive) fflush (stdout);
- break;
-
- case 'R' : /* Return from function */
- if (pc.pc_func != 0)
- {
- /* "Pop" autos and parameters. */
- pop_vars(functions[pc.pc_func].f_autos);
- pop_vars(functions[pc.pc_func].f_params);
- /* reset the pc. */
- fpop ();
- pc.pc_addr = fpop ();
- pc.pc_func = fpop ();
- }
- else
- rt_error ("Return from main program.");
- break;
-
- case 'S' : /* store array variable */
- var_name = byte(&pc);
- if ((var_name & 0x80) != 0)
- var_name = ((var_name << 8) & 0x7f) + byte(&pc);
- store_array (var_name);
- break;
-
- case 'T' : /* Test tos for zero */
- c_code = is_zero (ex_stack->s_num);
- assign (c_code);
- break;
-
- case 'W' : /* Write the value on the top of the stack. */
- case 'P' : /* Write the value on the top of the stack. No newline. */
- out_num (ex_stack->s_num, o_base, out_char);
- if (inst == 'W') out_char ('\n');
- store_var (3); /* Special variable "last". */
- if (interactive) fflush (stdout);
- break;
-
- case 'c' : /* Call special function. */
- new_func = byte(&pc);
-
- switch (new_func)
- {
- case 'L': /* Length function. */
- /* For the number 0.xxxx, 0 is not significant. */
- if (ex_stack->s_num->n_len == 1 &&
- ex_stack->s_num->n_scale != 0 &&
- ex_stack->s_num->n_value[0] == 0 )
- int2num (&ex_stack->s_num, ex_stack->s_num->n_scale);
- else
- int2num (&ex_stack->s_num, ex_stack->s_num->n_len
- + ex_stack->s_num->n_scale);
- break;
-
- case 'S': /* Scale function. */
- int2num (&ex_stack->s_num, ex_stack->s_num->n_scale);
- break;
-
- case 'R': /* Square Root function. */
- if (!bc_sqrt (&ex_stack->s_num, scale))
- rt_error ("Square root of a negative number");
- break;
-
- case 'I': /* Read function. */
- push_constant (input_char, i_base);
- break;
- }
- break;
-
- case 'd' : /* Decrement number */
- var_name = byte(&pc);
- if ((var_name & 0x80) != 0)
- var_name = ((var_name << 8) & 0x7f) + byte(&pc);
- decr_var (var_name);
- break;
-
- case 'h' : /* Halt the machine. */
- exit (0);
-
- case 'i' : /* increment number */
- var_name = byte(&pc);
- if ((var_name & 0x80) != 0)
- var_name = ((var_name << 8) & 0x7f) + byte(&pc);
- incr_var (var_name);
- break;
-
- case 'l' : /* load variable */
- var_name = byte(&pc);
- if ((var_name & 0x80) != 0)
- var_name = ((var_name << 8) & 0x7f) + byte(&pc);
- load_var (var_name);
- break;
-
- case 'n' : /* Negate top of stack. */
- bc_sub (_zero_, ex_stack->s_num, &ex_stack->s_num);
- break;
-
- case 'p' : /* Pop the execution stack. */
- pop ();
- break;
-
- case 's' : /* store variable */
- var_name = byte(&pc);
- if ((var_name & 0x80) != 0)
- var_name = ((var_name << 8) & 0x7f) + byte(&pc);
- store_var (var_name);
- break;
-
- case 'w' : /* Write a string to the output. */
- while ((ch = byte(&pc)) != '"') out_char (ch);
- if (interactive) fflush (stdout);
- break;
-
- case 'x' : /* Exchange Top of Stack with the one under the tos. */
- if (check_stack(2)) {
- bc_num temp = ex_stack->s_num;
- ex_stack->s_num = ex_stack->s_next->s_num;
- ex_stack->s_next->s_num = temp;
- }
- break;
-
- case '0' : /* Load Constant 0. */
- push_copy (_zero_);
- break;
-
- case '1' : /* Load Constant 0. */
- push_copy (_one_);
- break;
-
- case '!' : /* Negate the boolean value on top of the stack. */
- c_code = is_zero (ex_stack->s_num);
- assign (c_code);
- break;
-
- case '&' : /* compare greater than */
- if (check_stack(2))
- {
- c_code = !is_zero (ex_stack->s_next->s_num)
- && !is_zero (ex_stack->s_num);
- pop ();
- assign (c_code);
- }
- break;
-
- case '|' : /* compare greater than */
- if (check_stack(2))
- {
- c_code = !is_zero (ex_stack->s_next->s_num)
- || !is_zero (ex_stack->s_num);
- pop ();
- assign (c_code);
- }
- break;
-
- case '+' : /* add */
- if (check_stack(2))
- {
- bc_add (ex_stack->s_next->s_num, ex_stack->s_num, &temp_num);
- pop();
- pop();
- push_num (temp_num);
- init_num (&temp_num);
- }
- break;
-
- case '-' : /* subtract */
- if (check_stack(2))
- {
- bc_sub (ex_stack->s_next->s_num, ex_stack->s_num, &temp_num);
- pop();
- pop();
- push_num (temp_num);
- init_num (&temp_num);
- }
- break;
-
- case '*' : /* multiply */
- if (check_stack(2))
- {
- bc_multiply (ex_stack->s_next->s_num, ex_stack->s_num,
- &temp_num, scale);
- pop();
- pop();
- push_num (temp_num);
- init_num (&temp_num);
- }
- break;
-
- case '/' : /* divide */
- if (check_stack(2))
- {
- if (bc_divide (ex_stack->s_next->s_num,
- ex_stack->s_num, &temp_num, scale) == 0)
- {
- pop();
- pop();
- push_num (temp_num);
- init_num (&temp_num);
- }
- else
- rt_error ("Divide by zero");
- }
- break;
-
- case '%' : /* remainder */
- if (check_stack(2))
- {
- if (is_zero (ex_stack->s_num))
- rt_error ("Modulo by zero");
- else
- {
- bc_modulo (ex_stack->s_next->s_num,
- ex_stack->s_num, &temp_num, scale);
- pop();
- pop();
- push_num (temp_num);
- init_num (&temp_num);
- }
- }
- break;
-
- case '^' : /* raise */
- if (check_stack(2))
- {
- bc_raise (ex_stack->s_next->s_num,
- ex_stack->s_num, &temp_num, scale);
- if (is_zero (ex_stack->s_next->s_num) && is_neg (ex_stack->s_num))
- rt_error ("divide by zero");
- pop();
- pop();
- push_num (temp_num);
- init_num (&temp_num);
- }
- break;
-
- case '=' : /* compare equal */
- if (check_stack(2))
- {
- c_code = bc_compare (ex_stack->s_next->s_num,
- ex_stack->s_num) == 0;
- pop ();
- assign (c_code);
- }
- break;
-
- case '#' : /* compare not equal */
- if (check_stack(2))
- {
- c_code = bc_compare (ex_stack->s_next->s_num,
- ex_stack->s_num) != 0;
- pop ();
- assign (c_code);
- }
- break;
-
- case '<' : /* compare less than */
- if (check_stack(2))
- {
- c_code = bc_compare (ex_stack->s_next->s_num,
- ex_stack->s_num) == -1;
- pop ();
- assign (c_code);
- }
- break;
-
- case '{' : /* compare less than or equal */
- if (check_stack(2))
- {
- c_code = bc_compare (ex_stack->s_next->s_num,
- ex_stack->s_num) <= 0;
- pop ();
- assign (c_code);
- }
- break;
-
- case '>' : /* compare greater than */
- if (check_stack(2))
- {
- c_code = bc_compare (ex_stack->s_next->s_num,
- ex_stack->s_num) == 1;
- pop ();
- assign (c_code);
- }
- break;
-
- case '}' : /* compare greater than or equal */
- if (check_stack(2))
- {
- c_code = bc_compare (ex_stack->s_next->s_num,
- ex_stack->s_num) >= 0;
- pop ();
- assign (c_code);
- }
- break;
-
- default : /* error! */
- rt_error ("bad instruction: inst=%c", inst);
- }
- }
-
- /* Clean up the function stack and pop all autos/parameters. */
- while (pc.pc_func != 0)
- {
- pop_vars(functions[pc.pc_func].f_autos);
- pop_vars(functions[pc.pc_func].f_params);
- fpop ();
- pc.pc_addr = fpop ();
- pc.pc_func = fpop ();
- }
-
- /* Clean up the execution stack. */
- while (ex_stack != NULL) pop();
-
- /* Clean up the interrupt stuff. */
- if (interactive)
- {
- signal (SIGINT, use_quit);
- if (had_sigint)
- printf ("Interruption completed.\n");
- }
-}
-
-
-/* Prog_char gets another byte from the program. It is used for
- conversion of text constants in the code to numbers. */
-
-char
-prog_char ()
-{
- return byte(&pc);
-}
-
-
-/* Read a character from the standard input. This function is used
- by the "read" function. */
-
-char
-input_char ()
-{
- char in_ch;
-
- /* Get a character from the standard input for the read function. */
- in_ch = getchar();
-
- /* Check for a \ quoted newline. */
- if (in_ch == '\\')
- {
- in_ch = getchar();
- if (in_ch == '\n')
- in_ch = getchar();
- }
-
- /* Classify and preprocess the input character. */
- if (isdigit(in_ch))
- return (in_ch - '0');
- if (in_ch >= 'A' && in_ch <= 'F')
- return (in_ch + 10 - 'A');
- if (in_ch >= 'a' && in_ch <= 'f')
- return (in_ch + 10 - 'a');
- if (in_ch == '.' || in_ch == '+' || in_ch == '-')
- return (in_ch);
- if (in_ch <= ' ')
- return (' ');
-
- return (':');
-}
-
-
-/* Push_constant converts a sequence of input characters as returned
- by IN_CHAR into a number. The number is pushed onto the execution
- stack. The number is converted as a number in base CONV_BASE. */
-
-void
-push_constant (in_char, conv_base)
- char (*in_char)(VOID);
- int conv_base;
-{
- int digits;
- bc_num build, temp, result, mult, divisor;
- char in_ch, first_ch;
- char negative;
-
- /* Initialize all bc numbers */
- init_num (&temp);
- init_num (&result);
- init_num (&mult);
- build = copy_num (_zero_);
- negative = FALSE;
-
- /* The conversion base. */
- int2num (&mult, conv_base);
-
- /* Get things ready. */
- in_ch = in_char();
- while (in_ch == ' ')
- in_ch = in_char();
-
- if (in_ch == '+')
- in_ch = in_char();
- else
- if (in_ch == '-')
- {
- negative = TRUE;
- in_ch = in_char();
- }
-
- /* Check for the special case of a single digit. */
- if (in_ch < 16)
- {
- first_ch = in_ch;
- in_ch = in_char();
- if (in_ch < 16 && first_ch >= conv_base)
- first_ch = conv_base - 1;
- int2num (&build, (int) first_ch);
- }
-
- /* Convert the integer part. */
- while (in_ch < 16)
- {
- if (in_ch < 16 && in_ch >= conv_base) in_ch = conv_base-1;
- bc_multiply (build, mult, &result, 0);
- int2num (&temp, (int) in_ch);
- bc_add (result, temp, &build);
- in_ch = in_char();
- }
- if (in_ch == '.')
- {
- in_ch = in_char();
- if (in_ch >= conv_base) in_ch = conv_base-1;
- free_num (&result);
- free_num (&temp);
- divisor = copy_num (_one_);
- result = copy_num (_zero_);
- digits = 0;
- while (in_ch < 16)
- {
- bc_multiply (result, mult, &result, 0);
- int2num (&temp, (int) in_ch);
- bc_add (result, temp, &result);
- bc_multiply (divisor, mult, &divisor, 0);
- digits++;
- in_ch = in_char();
- if (in_ch < 16 && in_ch >= conv_base) in_ch = conv_base-1;
- }
- bc_divide (result, divisor, &result, digits);
- bc_add (build, result, &build);
- }
-
- /* Final work. */
- if (negative)
- bc_sub (_zero_, build, &build);
-
- push_num (build);
- free_num (&temp);
- free_num (&result);
- free_num (&mult);
-}
-
-
-/* When converting base 10 constants from the program, we use this
- more efficient way to convert them to numbers. PC tells where
- the constant starts and is expected to be advanced to after
- the constant. */
-
-void
-push_b10_const (pc)
- program_counter *pc;
-{
- bc_num build;
- program_counter look_pc;
- int kdigits, kscale;
- char inchar;
- char *ptr;
-
- /* Count the digits and get things ready. */
- look_pc = *pc;
- kdigits = 0;
- kscale = 0;
- inchar = byte (&look_pc);
- while (inchar != '.' && inchar != ':')
- {
- kdigits++;
- inchar = byte(&look_pc);
- }
- if (inchar == '.' )
- {
- inchar = byte(&look_pc);
- while (inchar != ':')
- {
- kscale++;
- inchar = byte(&look_pc);
- }
- }
-
- /* Get the first character again and move the pc. */
- inchar = byte(pc);
-
- /* Secial cases of 0, 1, and A-F single inputs. */
- if (kdigits == 1 && kscale == 0)
- {
- if (inchar == 0)
- {
- push_copy (_zero_);
- inchar = byte(pc);
- return;
- }
- if (inchar == 1) {
- push_copy (_one_);
- inchar = byte(pc);
- return;
- }
- if (inchar > 9)
- {
- init_num (&build);
- int2num (&build, inchar);
- push_num (build);
- inchar = byte(pc);
- return;
- }
- }
-
- /* Build the new number. */
- if (kdigits == 0)
- {
- build = new_num (1,kscale);
- ptr = build->n_value;
- *ptr++ = 0;
- }
- else
- {
- build = new_num (kdigits,kscale);
- ptr = build->n_value;
- }
-
- while (inchar != ':')
- {
- if (inchar != '.')
- if (inchar > 9)
- *ptr++ = 9;
- else
- *ptr++ = inchar;
- inchar = byte(pc);
- }
- push_num (build);
-}
-
-
-/* Put the correct value on the stack for C_CODE. Frees TOS num. */
-
-void
-assign (c_code)
- char c_code;
-{
- free_num (&ex_stack->s_num);
- if (c_code)
- ex_stack->s_num = copy_num (_one_);
- else
- ex_stack->s_num = copy_num (_zero_);
-}
diff --git a/gnu/usr.bin/bc/global.c b/gnu/usr.bin/bc/global.c
deleted file mode 100644
index fc44ff6..0000000
--- a/gnu/usr.bin/bc/global.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* global.c: This defines the global variables. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-#include "bcdefs.h"
-
-/* Since we want to define them here, we use the following define. */
-#undef EXTERN
-#define EXTERN
-
-/* Define all the global variables for bc. */
-#include "global.h"
-
-#ifndef BC_MATH_FILE
-CONST char libmath[] =
-#include "math.h"
-;
-#endif
diff --git a/gnu/usr.bin/bc/global.h b/gnu/usr.bin/bc/global.h
deleted file mode 100644
index 2b339a8..0000000
--- a/gnu/usr.bin/bc/global.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* global.h: The global variables for bc. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-
-/* The current break level's label. */
-EXTERN int break_label;
-
-/* The current if statement's else label or label after else. */
-EXTERN int if_label;
-
-/* The current for statement label for continuing the loop. */
-EXTERN int continue_label;
-
-/* Next available label number. */
-EXTERN int next_label;
-
-/* Byte code character storage. Used in many places for generation of code. */
-EXTERN char genstr[80];
-
-/* Count of characters printed to the output in compile_only mode. */
-EXTERN int out_count;
-
-/* Have we generated any code since the last initialization of the code
- generator. */
-EXTERN char did_gen;
-
-/* Is this run an interactive execution. (Is stdin a terminal?) */
-EXTERN char interactive;
-
-/* Just generate the byte code. -c flag. */
-EXTERN char compile_only;
-
-/* Load the standard math functions. -l flag. */
-EXTERN char use_math;
-
-/* Give a warning on use of any non-standard feature (non-POSIX). -w flag. */
-EXTERN char warn_not_std;
-
-/* Accept POSIX bc only! -s flag. */
-EXTERN char std_only;
-
-/* global variables for the bc machine. All will be dynamic in size.*/
-/* Function storage. main is (0) and functions (1-f_count) */
-
-EXTERN bc_function *functions;
-EXTERN char **f_names;
-EXTERN int f_count;
-
-/* Variable stoarge and reverse names. */
-
-EXTERN bc_var **variables;
-EXTERN char **v_names;
-EXTERN int v_count;
-
-/* Array Variable storage and reverse names. */
-
-EXTERN bc_var_array **arrays;
-EXTERN char **a_names;
-EXTERN int a_count;
-
-/* Execution stack. */
-EXTERN estack_rec *ex_stack;
-
-/* Function return stack. */
-EXTERN fstack_rec *fn_stack;
-
-/* Other "storage". */
-EXTERN int i_base;
-EXTERN int o_base;
-EXTERN int scale;
-EXTERN char c_code;
-EXTERN int out_col;
-EXTERN char runtime_error;
-EXTERN program_counter pc;
-
-/* Input Line numbers and other error information. */
-EXTERN int line_no;
-EXTERN int had_error;
-
-/* For larger identifiers, a tree, and how many "storage" locations
- have been allocated. */
-
-EXTERN int next_array;
-EXTERN int next_func;
-EXTERN int next_var;
-
-EXTERN id_rec *name_tree;
-
-/* For error message production */
-EXTERN char **g_argv;
-EXTERN int g_argc;
-EXTERN char is_std_in;
-
-/* defined in number.c */
-extern bc_num _zero_;
-extern bc_num _one_;
-
-/* For use with getopt. Do not declare them here.*/
-extern int optind;
-
diff --git a/gnu/usr.bin/bc/load.c b/gnu/usr.bin/bc/load.c
deleted file mode 100644
index 53466e5..0000000
--- a/gnu/usr.bin/bc/load.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/* load.c: This code "loads" code into the code segments. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-#include "bcdefs.h"
-#include "global.h"
-#include "proto.h"
-
-/* Load variables. */
-
-program_counter load_adr;
-char load_str;
-char load_const;
-
-/* Initialize the load sequence. */
-void
-init_load ()
-{
- clear_func(0);
- load_adr.pc_func = 0;
- load_adr.pc_addr = 0;
- load_str = FALSE;
- load_const = FALSE;
-}
-
-/* addbyte adds one BYTE to the current code segment. */
-void
-addbyte (byte)
- char byte;
-{
- int seg, offset, func;
-
- /* If there was an error, don't continue. */
- if (had_error) return;
-
- /* Calculate the segment and offset. */
- seg = load_adr.pc_addr >> BC_SEG_LOG;
- offset = load_adr.pc_addr++ % BC_SEG_SIZE;
- func = load_adr.pc_func;
-
- if (seg >= BC_MAX_SEGS)
- {
- yyerror ("Function too big.");
- return;
- }
-
- if (functions[func].f_body[seg] == NULL)
- functions[func].f_body[seg] = (char *) bc_malloc (BC_SEG_SIZE);
-
- /* Store the byte. */
- functions[func].f_body[seg][offset] = byte;
- functions[func].f_code_size++;
-}
-
-
-/* Define a label LAB to be the current program counter. */
-
-void
-def_label (lab)
- long lab;
-{
- bc_label_group *temp;
- int group, offset, func;
-
- /* Get things ready. */
- group = lab >> BC_LABEL_LOG;
- offset = lab % BC_LABEL_GROUP;
- func = load_adr.pc_func;
-
- /* Make sure there is at least one label group. */
- if (functions[func].f_label == NULL)
- {
- functions[func].f_label =
- (bc_label_group *) bc_malloc (sizeof(bc_label_group));
- functions[func].f_label->l_next = NULL;
- }
-
- /* Add the label group. */
- temp = functions[func].f_label;
- while (group > 0)
- {
- if (temp->l_next == NULL)
- {
- temp->l_next = (bc_label_group *) bc_malloc (sizeof(bc_label_group));
- temp->l_next->l_next = NULL;
- }
- temp = temp->l_next;
- group --;
- }
-
- /* Define it! */
- temp->l_adrs [offset] = load_adr.pc_addr;
-}
-
-/* Several instructions have integers in the code. They
- are all known to be legal longs. So, no error code
- is added. STR is the pointer to the load string and
- must be moved to the last non-digit character. */
-
-long
-long_val (str)
- char **str;
-{ int val = 0;
- char neg = FALSE;
-
- if (**str == '-')
- {
- neg = TRUE;
- (*str)++;
- }
- while (isdigit(**str))
- val = val*10 + *(*str)++ - '0';
-
- if (neg)
- return -val;
- else
- return val;
-}
-
-
-/* load_code loads the CODE into the machine. */
-
-void
-load_code (code)
- char *code;
-{
- char *str;
- long ap_name; /* auto or parameter name. */
- long label_no;
- long vaf_name; /* variable, array or function number. */
- long func;
- program_counter save_adr;
-
- /* Initialize. */
- str = code;
-
- /* Scan the code. */
- while (*str != 0)
- {
- /* If there was an error, don't continue. */
- if (had_error) return;
-
- if (load_str)
- {
- if (*str == '"') load_str = FALSE;
- addbyte (*str++);
- }
- else
- if (load_const)
- {
- if (*str == '\n')
- str++;
- else
- {
- if (*str == ':')
- {
- load_const = FALSE;
- addbyte (*str++);
- }
- else
- if (*str == '.')
- addbyte (*str++);
- else
- if (*str >= 'A')
- addbyte (*str++ + 10 - 'A');
- else
- addbyte (*str++ - '0');
- }
- }
- else
- {
- switch (*str)
- {
-
- case '"': /* Starts a string. */
- load_str = TRUE;
- break;
-
- case 'N': /* A label */
- str++;
- label_no = long_val (&str);
- def_label (label_no);
- break;
-
- case 'B': /* Branch to label. */
- case 'J': /* Jump to label. */
- case 'Z': /* Branch Zero to label. */
- addbyte(*str++);
- label_no = long_val (&str);
- if (label_no > 65535L)
- { /* Better message? */
- fprintf (stderr,"Program too big.\n");
- exit(1);
- }
- addbyte ( (char) label_no & 0xFF);
- addbyte ( (char) label_no >> 8);
- break;
-
- case 'F': /* A function, get the name and initialize it. */
- str++;
- func = long_val (&str);
- clear_func (func);
-#if DEBUG > 2
- printf ("Loading function number %d\n", func);
-#endif
- /* get the parameters */
- while (*str++ != '.')
- {
- if (*str == '.')
- {
- str++;
- break;
- }
- ap_name = long_val (&str);
-#if DEBUG > 2
- printf ("parameter number %d\n", ap_name);
-#endif
- functions[(int)func].f_params =
- nextarg (functions[(int)func].f_params, ap_name);
- }
-
- /* get the auto vars */
- while (*str != '[')
- {
- if (*str == ',') str++;
- ap_name = long_val (&str);
-#if DEBUG > 2
- printf ("auto number %d\n", ap_name);
-#endif
- functions[(int)func].f_autos =
- nextarg (functions[(int)func].f_autos, ap_name);
- }
- save_adr = load_adr;
- load_adr.pc_func = func;
- load_adr.pc_addr = 0;
- break;
-
- case ']': /* A function end */
- functions[load_adr.pc_func].f_defined = TRUE;
- load_adr = save_adr;
- break;
-
- case 'C': /* Call a function. */
- addbyte (*str++);
- func = long_val (&str);
- if (func < 128)
- addbyte ( (char) func);
- else
- {
- addbyte (((func >> 8) & 0xff) | 0x80);
- addbyte (func & 0xff);
- }
- if (*str == ',') str++;
- while (*str != ':')
- addbyte (*str++);
- addbyte (':');
- break;
-
- case 'c': /* Call a special function. */
- addbyte (*str++);
- addbyte (*str);
- break;
-
- case 'K': /* A constant.... may have an "F" in it. */
- addbyte (*str);
- load_const = TRUE;
- break;
-
- case 'd': /* Decrement. */
- case 'i': /* Increment. */
- case 'l': /* Load. */
- case 's': /* Store. */
- case 'A': /* Array Increment */
- case 'M': /* Array Decrement */
- case 'L': /* Array Load */
- case 'S': /* Array Store */
- addbyte (*str++);
- vaf_name = long_val (&str);
- if (vaf_name < 128)
- addbyte (vaf_name);
- else
- {
- addbyte (((vaf_name >> 8) & 0xff) | 0x80);
- addbyte (vaf_name & 0xff);
- }
- break;
-
- case '@': /* A command! */
- switch (*(++str))
- {
- case 'i':
- init_load ();
- break;
- case 'r':
- execute ();
- break;
- }
- break;
-
- case '\n': /* Ignore the newlines */
- break;
-
- default: /* Anything else */
- addbyte (*str);
- }
- str++;
- }
- }
-}
diff --git a/gnu/usr.bin/bc/main.c b/gnu/usr.bin/bc/main.c
deleted file mode 100644
index 57bcd8c..0000000
--- a/gnu/usr.bin/bc/main.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/* main.c: The main program for bc. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-#include "bcdefs.h"
-#include <signal.h>
-#include "global.h"
-#include "proto.h"
-
-/* Variables for processing multiple files. */
-char first_file;
-extern FILE *yyin;
-
-
-/* The main program for bc. */
-int
-main (argc, argv)
- int argc;
- char *argv[];
-{
- int ch;
-
- /* Initialize many variables. */
- compile_only = FALSE;
- use_math = FALSE;
- warn_not_std = FALSE;
- std_only = FALSE;
- if (isatty(0) && isatty(1))
- interactive = TRUE;
- else
- interactive = FALSE;
-
- /* Parse the command line */
- ch = getopt (argc, argv, "lcisvw");
- while (ch != EOF)
- {
- switch (ch)
- {
- case 'c': /* compile only */
- compile_only = TRUE;
- break;
- case 'l': /* math lib */
- use_math = TRUE;
- break;
- case 'i': /* force interactive */
- interactive = TRUE;
- break;
- case 'w': /* Non standard features give warnings. */
- warn_not_std = TRUE;
- break;
- case 's': /* Non standard features give errors. */
- std_only = TRUE;
- break;
- case 'v': /* Print the version. */
- printf ("%s\n", BC_VERSION);
- break;
- }
- ch = getopt (argc, argv, "lcisvw");
- }
-
- /* Initialize the machine. */
- init_storage();
- init_load();
-
- /* Set up interrupts to print a message. */
- if (interactive)
- signal (SIGINT, use_quit);
-
- /* Initialize the front end. */
- init_tree();
- init_gen ();
- g_argv = argv;
- g_argc = argc;
- is_std_in = FALSE;
- first_file = TRUE;
- if (!open_new_file ())
- exit (1);
-
- /* Do the parse. */
- yyparse ();
-
- /* End the compile only output with a newline. */
- if (compile_only)
- printf ("\n");
-
- exit (0);
-}
-
-
-/* This is the function that opens all the files.
- It returns TRUE if the file was opened, otherwise
- it returns FALSE. */
-
-int
-open_new_file ()
-{
- FILE *new_file;
-
- /* Set the line number. */
- line_no = 1;
-
- /* Check to see if we are done. */
- if (is_std_in) return (FALSE);
-
- /* Open the other files. */
- if (use_math && first_file)
- {
-#ifdef BC_MATH_FILE
- /* Make the first file be the math library. */
- new_file = fopen (BC_MATH_FILE, "r");
- use_math = FALSE;
- if (new_file != NULL)
- {
- new_yy_file (new_file);
- return TRUE;
- }
- else
- {
- fprintf (stderr, "Math Library unavailable.\n");
- exit (1);
- }
-#else
- /* Load the code from a precompiled version of the math libarary. */
- extern char libmath[];
- char tmp;
- /* These MUST be in the order of first mention of each function.
- That is why "a" comes before "c" even though "a" is defined after
- after "c". "a" is used in "s"! */
- tmp = lookup ("e", FUNCT);
- tmp = lookup ("l", FUNCT);
- tmp = lookup ("s", FUNCT);
- tmp = lookup ("a", FUNCT);
- tmp = lookup ("c", FUNCT);
- tmp = lookup ("j", FUNCT);
- load_code (libmath);
-#endif
- }
-
- /* One of the argv values. */
- while (optind < g_argc)
- {
- new_file = fopen (g_argv[optind], "r");
- if (new_file != NULL)
- {
- new_yy_file (new_file);
- optind++;
- return TRUE;
- }
- fprintf (stderr, "File %s is unavailable.\n", g_argv[optind++]);
- exit (1);
- }
-
- /* If we fall through to here, we should return stdin. */
- new_yy_file (stdin);
- is_std_in = TRUE;
- return TRUE;
-}
-
-
-/* Set yyin to the new file. */
-
-void
-new_yy_file (file)
- FILE *file;
-{
- if (!first_file) fclose (yyin);
- yyin = file;
- first_file = FALSE;
-}
-
-
-/* Message to use quit. */
-
-void
-use_quit (sig)
- int sig;
-{
- printf ("\n(interrupt) use quit to exit.\n");
- signal (SIGINT, use_quit);
-}
diff --git a/gnu/usr.bin/bc/math.h b/gnu/usr.bin/bc/math.h
deleted file mode 100644
index fb5b03b..0000000
--- a/gnu/usr.bin/bc/math.h
+++ /dev/null
@@ -1,40 +0,0 @@
-"@iK20:s2:p@r\
-@iF1,4.5,6,7,8,9,10,11,12,13[l4:0<Z1:1s10:pl4:ns4:pN1:l2:s13:\
-pK6:l13:+K.44:l4:*+s11:pl4:cS1+s2:pN2:l4:1>Z3:l8:1+s8:pl4:K2:\
-/s4:pl2:1+s2:pJ2:N3:l11:s2:p1l4:+s12:pl4:s5:p1s6:pK2:s9:pN5:1\
-B6:J4:N7:l9:i9:pJ5:N6:l5:l4:*s5:l6:l9:*s6:/s7:pl7:0=Z8:l8:0>Z9:\
-N10:l8:d8:Z11:l12:l12:*s12:pJ10:N11:N9:l13:s2:pl10:Z12:1l12:/\
-RN12:l12:1/RN8:l12:l7:+s12:pJ7:N4:0R]@r\
-@iF2,4.7,8,9,10,11,12,13[l4:0{Z1:1K10:l2:^-RN1:l2:s13:pK6:l2:\
-+s2:pK2:s8:p0s9:pN2:l4:K2:}Z3:l8:K2:*s8:pl4:cRs4:pJ2:N3:N4:l4:\
-K.5:{Z5:l8:K2:*s8:pl4:cRs4:pJ4:N5:l4:1-l4:1+/s11:s12:pl11:l11:\
-*s10:pK3:s9:pN7:1B8:J6:N9:l9:K2:+s9:pJ7:N8:l11:l10:*s11:l9:/s7:\
-pl7:0=Z10:l8:l12:*s12:pl13:s2:pl12:1/RN10:l12:l7:+s12:pJ9:N6:\
-0R]@r\
-@iF3,4.7,9,10,11,14,12,13[l2:s13:pK1.1:l13:*K2:+s2:p1C4,0:s12:\
-pl4:0<Z1:1s10:pl4:ns4:pN1:0s2:pl4:l12:/K2:+K4:/s11:pl4:K4:l11:\
-*l12:*-s4:pl11:K2:%Z2:l4:ns4:pN2:l13:K2:+s2:pl4:s7:s12:pl4:nl4:\
-*s14:pK3:s9:pN4:1B5:J3:N6:l9:K2:+s9:pJ4:N5:l7:l14:l9:l9:1-*/*\
-s7:pl7:0=Z7:l13:s2:pl10:Z8:l12:n1/RN8:l12:1/RN7:l12:l7:+s12:p\
-J6:N3:0R]@r\
-@iF5,4.12[l2:1+s2:pl4:1C4,0:K2:*+C3,0:s12:pl2:1-s2:pl12:1/R0R]\
-@r\
-@iF4,4.5,7,8,9,10,11,14,12,13[1s10:pl4:0<Z1:1ns10:pl4:ns4:pN1:\
-l4:1=Z2:l2:K25:{Z3:K.7853981633974483096156608:l10:/RN3:l2:K40\
-:{Z4:K.7853981633974483096156608458198757210492:l10:/RN4:l2:K\
-60:{Z5:K.785398163397448309615660845819875721049292349843776455243736\
-:l10:/RN5:N2:l4:K.2:=Z6:l2:K25:{Z7:K.1973955598498807583700497\
-:l10:/RN7:l2:K40:{Z8:K.1973955598498807583700497651947902934475\
-:l10:/RN8:l2:K60:{Z9:K.197395559849880758370049765194790293447585103787852101517688\
-:l10:/RN9:N6:l2:s13:pl4:K.2:>Z10:l13:K5:+s2:pK.2:C4,0:s5:pN10:\
-l13:K3:+s2:pN11:l4:K.2:>Z12:l8:1+s8:pl4:K.2:-1l4:K.2:*+/s4:pJ11:N12:\
-l4:s11:s12:pl4:nl4:*s14:pK3:s9:pN14:1B15:J13:N16:l9:K2:+s9:pJ14:N15:\
-l11:l14:*s11:l9:/s7:pl7:0=Z17:l13:s2:pl8:l5:*l12:+l10:/RN17:l12:\
-l7:+s12:pJ16:N13:0R]@r\
-@iF6,11,4.5,6,7,8,9,10,14,12,13[l2:s13:p0s2:pl11:1/s11:pl11:0\
-<Z1:l11:ns11:pl11:K2:%1=Z2:1s10:pN2:N1:1s8:pK2:s9:pN4:l9:l11:\
-{B5:J3:N6:l9:i9:pJ4:N5:l8:l9:*s8:pJ6:N3:K1.5:l13:*s2:pl4:l11:\
-^K2:l11:^/l8:/s8:p1s7:s12:pl4:nl4:*K4:/s14:pK1.5:l13:*s2:p1s9:\
-pN8:1B9:J7:N10:l9:i9:pJ8:N9:l7:l14:*l9:/l11:l9:+/s7:pl7:0=Z11:\
-l13:s2:pl10:Z12:l8:nl12:*1/RN12:l8:l12:*1/RN11:l12:l7:+s12:pJ10:N7:\
-0R]@r"
diff --git a/gnu/usr.bin/bc/number.c b/gnu/usr.bin/bc/number.c
deleted file mode 100644
index ce078fe..0000000
--- a/gnu/usr.bin/bc/number.c
+++ /dev/null
@@ -1,1419 +0,0 @@
-/* number.c: Implements arbitrary precision numbers. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-#include "bcdefs.h"
-#include "proto.h"
-
-/* Storage used for special numbers. */
-bc_num _zero_;
-bc_num _one_;
-bc_num _two_;
-
-
-/* "Frees" a bc_num NUM. Actually decreases reference count and only
- frees the storage if reference count is zero. */
-
-void
-free_num (num)
- bc_num *num;
-{
- if (*num == NULL) return;
- (*num)->n_refs--;
- if ((*num)->n_refs == 0) free(*num);
- *num = NULL;
-}
-
-
-/* new_num allocates a number and sets fields to known values. */
-
-bc_num
-new_num (length, scale)
- int length, scale;
-{
- bc_num temp;
-
- temp = (bc_num) malloc (sizeof(bc_struct)+length+scale);
- if (temp == NULL) out_of_memory ();
- temp->n_sign = PLUS;
- temp->n_len = length;
- temp->n_scale = scale;
- temp->n_refs = 1;
- temp->n_value[0] = 0;
- return temp;
-}
-
-
-/* Intitialize the number package! */
-
-void
-init_numbers ()
-{
- _zero_ = new_num (1,0);
- _one_ = new_num (1,0);
- _one_->n_value[0] = 1;
- _two_ = new_num (1,0);
- _two_->n_value[0] = 2;
-}
-
-
-/* Make a copy of a number! Just increments the reference count! */
-
-bc_num
-copy_num (num)
- bc_num num;
-{
- num->n_refs++;
- return num;
-}
-
-
-/* Initialize a number NUM by making it a copy of zero. */
-
-void
-init_num (num)
- bc_num *num;
-{
- *num = copy_num (_zero_);
-}
-
-
-/* Convert an integer VAL to a bc number NUM. */
-
-void
-int2num (num, val)
- bc_num *num;
- int val;
-{
- char buffer[30];
- char *bptr, *vptr;
- int ix = 1;
- char neg = 0;
-
- /* Sign. */
- if (val < 0)
- {
- neg = 1;
- val = -val;
- }
-
- /* Get things going. */
- bptr = buffer;
- *bptr++ = val % 10;
- val = val / 10;
-
- /* Extract remaining digits. */
- while (val != 0)
- {
- *bptr++ = val % 10;
- val = val / 10;
- ix++; /* Count the digits. */
- }
-
- /* Make the number. */
- free_num (num);
- *num = new_num (ix, 0);
- if (neg) (*num)->n_sign = MINUS;
-
- /* Assign the digits. */
- vptr = (*num)->n_value;
- while (ix-- > 0)
- *vptr++ = *--bptr;
-}
-
-
-/* Convert a number NUM to a long. The function returns only the integer
- part of the number. For numbers that are too large to represent as
- a long, this function returns a zero. This can be detected by checking
- the NUM for zero after having a zero returned. */
-
-long
-num2long (num)
- bc_num num;
-{
- long val;
- char *nptr;
- int index;
-
- /* Extract the int value, ignore the fraction. */
- val = 0;
- nptr = num->n_value;
- for (index=num->n_len; (index>0) && (val<=(LONG_MAX/10)); index--)
- val = val*10 + *nptr++;
-
- /* Check for overflow. If overflow, return zero. */
- if (index>0) val = 0;
- if (val < 0) val = 0;
-
- /* Return the value. */
- if (num->n_sign == PLUS)
- return (val);
- else
- return (-val);
-}
-
-
-/* The following are some math routines for numbers. */
-_PROTOTYPE(static int _do_compare, (bc_num n1, bc_num n2, int use_sign,
- int ignore_last));
-_PROTOTYPE(static void _rm_leading_zeros, (bc_num num));
-_PROTOTYPE(static bc_num _do_add, (bc_num n1, bc_num n2));
-_PROTOTYPE(static bc_num _do_sub, (bc_num n1, bc_num n2));
-_PROTOTYPE(static void _one_mult, (unsigned char *num, int size, int digit,
- unsigned char *result));
-
-
-
-/* Compare two bc numbers. Return value is 0 if equal, -1 if N1 is less
- than N2 and +1 if N1 is greater than N2. If USE_SIGN is false, just
- compare the magnitudes. */
-
-static int
-_do_compare (n1, n2, use_sign, ignore_last)
- bc_num n1, n2;
- int use_sign;
- int ignore_last;
-{
- char *n1ptr, *n2ptr;
- int count;
-
- /* First, compare signs. */
- if (use_sign && n1->n_sign != n2->n_sign)
- {
- if (n1->n_sign == PLUS)
- return (1); /* Positive N1 > Negative N2 */
- else
- return (-1); /* Negative N1 < Positive N1 */
- }
-
- /* Now compare the magnitude. */
- if (n1->n_len != n2->n_len)
- {
- if (n1->n_len > n2->n_len)
- {
- /* Magnitude of n1 > n2. */
- if (!use_sign || n1->n_sign == PLUS)
- return (1);
- else
- return (-1);
- }
- else
- {
- /* Magnitude of n1 < n2. */
- if (!use_sign || n1->n_sign == PLUS)
- return (-1);
- else
- return (1);
- }
- }
-
- /* If we get here, they have the same number of integer digits.
- check the integer part and the equal length part of the fraction. */
- count = n1->n_len + MIN (n1->n_scale, n2->n_scale);
- n1ptr = n1->n_value;
- n2ptr = n2->n_value;
-
- while ((count > 0) && (*n1ptr == *n2ptr))
- {
- n1ptr++;
- n2ptr++;
- count--;
- }
- if (ignore_last && count == 1 && n1->n_scale == n2->n_scale)
- return (0);
- if (count != 0)
- {
- if (*n1ptr > *n2ptr)
- {
- /* Magnitude of n1 > n2. */
- if (!use_sign || n1->n_sign == PLUS)
- return (1);
- else
- return (-1);
- }
- else
- {
- /* Magnitude of n1 < n2. */
- if (!use_sign || n1->n_sign == PLUS)
- return (-1);
- else
- return (1);
- }
- }
-
- /* They are equal up to the last part of the equal part of the fraction. */
- if (n1->n_scale != n2->n_scale)
- if (n1->n_scale > n2->n_scale)
- {
- for (count = n1->n_scale-n2->n_scale; count>0; count--)
- if (*n1ptr++ != 0)
- {
- /* Magnitude of n1 > n2. */
- if (!use_sign || n1->n_sign == PLUS)
- return (1);
- else
- return (-1);
- }
- }
- else
- {
- for (count = n2->n_scale-n1->n_scale; count>0; count--)
- if (*n2ptr++ != 0)
- {
- /* Magnitude of n1 < n2. */
- if (!use_sign || n1->n_sign == PLUS)
- return (-1);
- else
- return (1);
- }
- }
-
- /* They must be equal! */
- return (0);
-}
-
-
-/* This is the "user callable" routine to compare numbers N1 and N2. */
-
-int
-bc_compare (n1, n2)
- bc_num n1, n2;
-{
- return _do_compare (n1, n2, TRUE, FALSE);
-}
-
-
-/* In some places we need to check if the number NUM is zero. */
-
-char
-is_zero (num)
- bc_num num;
-{
- int count;
- char *nptr;
-
- /* Quick check. */
- if (num == _zero_) return TRUE;
-
- /* Initialize */
- count = num->n_len + num->n_scale;
- nptr = num->n_value;
-
- /* The check */
- while ((count > 0) && (*nptr++ == 0)) count--;
-
- if (count != 0)
- return FALSE;
- else
- return TRUE;
-}
-
-
-/* In some places we need to check if the number is negative. */
-
-char
-is_neg (num)
- bc_num num;
-{
- return num->n_sign == MINUS;
-}
-
-
-/* For many things, we may have leading zeros in a number NUM.
- _rm_leading_zeros just moves the data to the correct
- place and adjusts the length. */
-
-static void
-_rm_leading_zeros (num)
- bc_num num;
-{
- int bytes;
- char *dst, *src;
-
- /* Do a quick check to see if we need to do it. */
- if (*num->n_value != 0) return;
-
- /* The first digit is 0, find the first non-zero digit in the 10's or
- greater place. */
- bytes = num->n_len;
- src = num->n_value;
- while (bytes > 1 && *src == 0) src++, bytes--;
- num->n_len = bytes;
- bytes += num->n_scale;
- dst = num->n_value;
- while (bytes-- > 0) *dst++ = *src++;
-
-}
-
-
-/* Perform addition: N1 is added to N2 and the value is
- returned. The signs of N1 and N2 are ignored. */
-
-static bc_num
-_do_add (n1, n2)
- bc_num n1, n2;
-{
- bc_num sum;
- int sum_scale, sum_digits;
- char *n1ptr, *n2ptr, *sumptr;
- int carry, n1bytes, n2bytes;
-
- /* Prepare sum. */
- sum_scale = MAX (n1->n_scale, n2->n_scale);
- sum_digits = MAX (n1->n_len, n2->n_len) + 1;
- sum = new_num (sum_digits,sum_scale);
-
- /* Start with the fraction part. Initialize the pointers. */
- n1bytes = n1->n_scale;
- n2bytes = n2->n_scale;
- n1ptr = (char *) (n1->n_value + n1->n_len + n1bytes - 1);
- n2ptr = (char *) (n2->n_value + n2->n_len + n2bytes - 1);
- sumptr = (char *) (sum->n_value + sum_scale + sum_digits - 1);
-
- /* Add the fraction part. First copy the longer fraction.*/
- if (n1bytes != n2bytes)
- {
- if (n1bytes > n2bytes)
- while (n1bytes>n2bytes)
- { *sumptr-- = *n1ptr--; n1bytes--;}
- else
- while (n2bytes>n1bytes)
- { *sumptr-- = *n2ptr--; n2bytes--;}
- }
-
- /* Now add the remaining fraction part and equal size integer parts. */
- n1bytes += n1->n_len;
- n2bytes += n2->n_len;
- carry = 0;
- while ((n1bytes > 0) && (n2bytes > 0))
- {
- *sumptr = *n1ptr-- + *n2ptr-- + carry;
- if (*sumptr > 9)
- {
- carry = 1;
- *sumptr -= 10;
- }
- else
- carry = 0;
- sumptr--;
- n1bytes--;
- n2bytes--;
- }
-
- /* Now add carry the longer integer part. */
- if (n1bytes == 0)
- { n1bytes = n2bytes; n1ptr = n2ptr; }
- while (n1bytes-- > 0)
- {
- *sumptr = *n1ptr-- + carry;
- if (*sumptr > 9)
- {
- carry = 1;
- *sumptr -= 10;
- }
- else
- carry = 0;
- sumptr--;
- }
-
- /* Set final carry. */
- if (carry == 1)
- *sumptr += 1;
-
- /* Adjust sum and return. */
- _rm_leading_zeros (sum);
- return sum;
-}
-
-
-/* Perform subtraction: N2 is subtracted from N1 and the value is
- returned. The signs of N1 and N2 are ignored. Also, N1 is
- assumed to be larger than N2. */
-
-static bc_num
-_do_sub (n1, n2)
- bc_num n1, n2;
-{
- bc_num diff;
- int diff_scale, diff_len;
- int min_scale, min_len;
- char *n1ptr, *n2ptr, *diffptr;
- int borrow, count, val;
-
- /* Allocate temporary storage. */
- diff_len = MAX (n1->n_len, n2->n_len);
- diff_scale = MAX (n1->n_scale, n2->n_scale);
- min_len = MIN (n1->n_len, n2->n_len);
- min_scale = MIN (n1->n_scale, n2->n_scale);
- diff = new_num (diff_len, diff_scale);
-
- /* Initialize the subtract. */
- n1ptr = (char *) (n1->n_value + n1->n_len + n1->n_scale -1);
- n2ptr = (char *) (n2->n_value + n2->n_len + n2->n_scale -1);
- diffptr = (char *) (diff->n_value + diff_len + diff_scale -1);
-
- /* Subtract the numbers. */
- borrow = 0;
-
- /* Take care of the longer scaled number. */
- if (n1->n_scale != min_scale)
- {
- /* n1 has the longer scale */
- for (count = n1->n_scale - min_scale; count > 0; count--)
- *diffptr-- = *n1ptr--;
- }
- else
- {
- /* n2 has the longer scale */
- for (count = n2->n_scale - min_scale; count > 0; count--)
- {
- val = - *n2ptr-- - borrow;
- if (val < 0)
- {
- val += 10;
- borrow = 1;
- }
- else
- borrow = 0;
- *diffptr-- = val;
- }
- }
-
- /* Now do the equal length scale and integer parts. */
-
- for (count = 0; count < min_len + min_scale; count++)
- {
- val = *n1ptr-- - *n2ptr-- - borrow;
- if (val < 0)
- {
- val += 10;
- borrow = 1;
- }
- else
- borrow = 0;
- *diffptr-- = val;
- }
-
- /* If n1 has more digits then n2, we now do that subtract. */
- if (diff_len != min_len)
- {
- for (count = diff_len - min_len; count > 0; count--)
- {
- val = *n1ptr-- - borrow;
- if (val < 0)
- {
- val += 10;
- borrow = 1;
- }
- else
- borrow = 0;
- *diffptr-- = val;
- }
- }
-
- /* Clean up and return. */
- _rm_leading_zeros (diff);
- return diff;
-}
-
-
-/* Here is the full add routine that takes care of negative numbers.
- N1 is added to N2 and the result placed into RESULT. */
-
-void
-bc_add ( n1, n2, result)
- bc_num n1, n2, *result;
-{
- bc_num sum = 0;
- int cmp_res;
-
- if (n1->n_sign == n2->n_sign)
- {
- sum = _do_add (n1, n2);
- sum->n_sign = n1->n_sign;
- }
- else
- {
- /* subtraction must be done. */
- cmp_res = _do_compare (n1, n2, FALSE, FALSE); /* Compare magnitudes. */
- switch (cmp_res)
- {
- case -1:
- /* n1 is less than n2, subtract n1 from n2. */
- sum = _do_sub (n2, n1);
- sum->n_sign = n2->n_sign;
- break;
- case 0:
- /* They are equal! return zero! */
- sum = copy_num (_zero_);
- break;
- case 1:
- /* n2 is less than n1, subtract n2 from n1. */
- sum = _do_sub (n1, n2);
- sum->n_sign = n1->n_sign;
- }
- }
-
- /* Clean up and return. */
- free_num (result);
- *result = sum;
-}
-
-
-/* Here is the full subtract routine that takes care of negative numbers.
- N2 is subtracted from N1 and the result placed in RESULT. */
-
-void
-bc_sub ( n1, n2, result)
- bc_num n1, n2, *result;
-{
- bc_num diff = 0;
- int cmp_res;
-
- if (n1->n_sign != n2->n_sign)
- {
- diff = _do_add (n1, n2);
- diff->n_sign = n1->n_sign;
- }
- else
- {
- /* subtraction must be done. */
- cmp_res = _do_compare (n1, n2, FALSE, FALSE); /* Compare magnitudes. */
- switch (cmp_res)
- {
- case -1:
- /* n1 is less than n2, subtract n1 from n2. */
- diff = _do_sub (n2, n1);
- diff->n_sign = (n2->n_sign == PLUS ? MINUS : PLUS);
- break;
- case 0:
- /* They are equal! return zero! */
- diff = copy_num (_zero_);
- break;
- case 1:
- /* n2 is less than n1, subtract n2 from n1. */
- diff = _do_sub (n1, n2);
- diff->n_sign = n1->n_sign;
- break;
- }
- }
-
- /* Clean up and return. */
- free_num (result);
- *result = diff;
-}
-
-
-/* The multiply routine. N2 time N1 is put int PROD with the scale of
- the result being MIN(N2 scale+N1 scale, MAX (SCALE, N2 scale, N1 scale)).
- */
-
-void
-bc_multiply (n1, n2, prod, scale)
- bc_num n1, n2, *prod;
- int scale;
-{
- bc_num pval; /* For the working storage. */
- char *n1ptr, *n2ptr, *pvptr; /* Work pointers. */
- char *n1end, *n2end; /* To the end of n1 and n2. */
-
- int indx;
- int len1, len2, total_digits;
- long sum;
- int full_scale, prod_scale;
- int toss;
-
- /* Initialize things. */
- len1 = n1->n_len + n1->n_scale;
- len2 = n2->n_len + n2->n_scale;
- total_digits = len1 + len2;
- full_scale = n1->n_scale + n2->n_scale;
- prod_scale = MIN(full_scale,MAX(scale,MAX(n1->n_scale,n2->n_scale)));
- toss = full_scale - prod_scale;
- pval = new_num (total_digits-full_scale, prod_scale);
- pval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS );
- n1end = (char *) (n1->n_value + len1 - 1);
- n2end = (char *) (n2->n_value + len2 - 1);
- pvptr = (char *) (pval->n_value + total_digits - toss - 1);
- sum = 0;
-
- /* Here are the loops... */
- for (indx = 0; indx < toss; indx++)
- {
- n1ptr = (char *) (n1end - MAX(0, indx-len2+1));
- n2ptr = (char *) (n2end - MIN(indx, len2-1));
- while ((n1ptr >= n1->n_value) && (n2ptr <= n2end))
- sum += *n1ptr-- * *n2ptr++;
- sum = sum / 10;
- }
- for ( ; indx < total_digits-1; indx++)
- {
- n1ptr = (char *) (n1end - MAX(0, indx-len2+1));
- n2ptr = (char *) (n2end - MIN(indx, len2-1));
- while ((n1ptr >= n1->n_value) && (n2ptr <= n2end))
- sum += *n1ptr-- * *n2ptr++;
- *pvptr-- = sum % 10;
- sum = sum / 10;
- }
- *pvptr-- = sum;
-
- /* Assign to prod and clean up the number. */
- free_num (prod);
- *prod = pval;
- _rm_leading_zeros (*prod);
- if (is_zero (*prod))
- (*prod)->n_sign = PLUS;
-}
-
-
-/* Some utility routines for the divide: First a one digit multiply.
- NUM (with SIZE digits) is multiplied by DIGIT and the result is
- placed into RESULT. It is written so that NUM and RESULT can be
- the same pointers. */
-
-static void
-_one_mult (num, size, digit, result)
- unsigned char *num;
- int size, digit;
- unsigned char *result;
-{
- int carry, value;
- unsigned char *nptr, *rptr;
-
- if (digit == 0)
- memset (result, 0, size);
- else
- {
- if (digit == 1)
- memcpy (result, num, size);
- else
- {
- /* Initialize */
- nptr = (unsigned char *) (num+size-1);
- rptr = (unsigned char *) (result+size-1);
- carry = 0;
-
- while (size-- > 0)
- {
- value = *nptr-- * digit + carry;
- *rptr-- = value % 10;
- carry = value / 10;
- }
-
- if (carry != 0) *rptr = carry;
- }
- }
-}
-
-
-/* The full division routine. This computes N1 / N2. It returns
- 0 if the division is ok and the result is in QUOT. The number of
- digits after the decimal point is SCALE. It returns -1 if division
- by zero is tried. The algorithm is found in Knuth Vol 2. p237. */
-
-int
-bc_divide (n1, n2, quot, scale)
- bc_num n1, n2, *quot;
- int scale;
-{
- bc_num qval;
- unsigned char *num1, *num2;
- unsigned char *ptr1, *ptr2, *n2ptr, *qptr;
- int scale1, val;
- unsigned int len1, len2, scale2, qdigits, extra, count;
- unsigned int qdig, qguess, borrow, carry;
- unsigned char *mval;
- char zero;
- unsigned int norm;
-
- /* Test for divide by zero. */
- if (is_zero (n2)) return -1;
-
- /* Test for divide by 1. If it is we must truncate. */
- if (n2->n_scale == 0)
- {
- if (n2->n_len == 1 && *n2->n_value == 1)
- {
- qval = new_num (n1->n_len, scale);
- qval->n_sign = (n1->n_sign == n2->n_sign ? PLUS : MINUS);
- memset (&qval->n_value[n1->n_len],0,scale);
- memcpy (qval->n_value, n1->n_value,
- n1->n_len + MIN(n1->n_scale,scale));
- free_num (quot);
- *quot = qval;
- }
- }
-
- /* Set up the divide. Move the decimal point on n1 by n2's scale.
- Remember, zeros on the end of num2 are wasted effort for dividing. */
- scale2 = n2->n_scale;
- n2ptr = (unsigned char *) n2->n_value+n2->n_len+scale2-1;
- while ((scale2 > 0) && (*n2ptr-- == 0)) scale2--;
-
- len1 = n1->n_len + scale2;
- scale1 = n1->n_scale - scale2;
- if (scale1 < scale)
- extra = scale - scale1;
- else
- extra = 0;
- num1 = (unsigned char *) malloc (n1->n_len+n1->n_scale+extra+2);
- if (num1 == NULL) out_of_memory();
- memset (num1, 0, n1->n_len+n1->n_scale+extra+2);
- memcpy (num1+1, n1->n_value, n1->n_len+n1->n_scale);
-
- len2 = n2->n_len + scale2;
- num2 = (unsigned char *) malloc (len2+1);
- if (num2 == NULL) out_of_memory();
- memcpy (num2, n2->n_value, len2);
- *(num2+len2) = 0;
- n2ptr = num2;
- while (*n2ptr == 0)
- {
- n2ptr++;
- len2--;
- }
-
- /* Calculate the number of quotient digits. */
- if (len2 > len1+scale)
- {
- qdigits = scale+1;
- zero = TRUE;
- }
- else
- {
- zero = FALSE;
- if (len2>len1)
- qdigits = scale+1; /* One for the zero integer part. */
- else
- qdigits = len1-len2+scale+1;
- }
-
- /* Allocate and zero the storage for the quotient. */
- qval = new_num (qdigits-scale,scale);
- memset (qval->n_value, 0, qdigits);
-
- /* Allocate storage for the temporary storage mval. */
- mval = (unsigned char *) malloc (len2+1);
- if (mval == NULL) out_of_memory ();
-
- /* Now for the full divide algorithm. */
- if (!zero)
- {
- /* Normalize */
- norm = 10 / ((int)*n2ptr + 1);
- if (norm != 1)
- {
- _one_mult (num1, len1+scale1+extra+1, norm, num1);
- _one_mult (n2ptr, len2, norm, n2ptr);
- }
-
- /* Initialize divide loop. */
- qdig = 0;
- if (len2 > len1)
- qptr = (unsigned char *) qval->n_value+len2-len1;
- else
- qptr = (unsigned char *) qval->n_value;
-
- /* Loop */
- while (qdig <= len1+scale-len2)
- {
- /* Calculate the quotient digit guess. */
- if (*n2ptr == num1[qdig])
- qguess = 9;
- else
- qguess = (num1[qdig]*10 + num1[qdig+1]) / *n2ptr;
-
- /* Test qguess. */
- if (n2ptr[1]*qguess >
- (num1[qdig]*10 + num1[qdig+1] - *n2ptr*qguess)*10
- + num1[qdig+2])
- {
- qguess--;
- /* And again. */
- if (n2ptr[1]*qguess >
- (num1[qdig]*10 + num1[qdig+1] - *n2ptr*qguess)*10
- + num1[qdig+2])
- qguess--;
- }
-
- /* Multiply and subtract. */
- borrow = 0;
- if (qguess != 0)
- {
- *mval = 0;
- _one_mult (n2ptr, len2, qguess, mval+1);
- ptr1 = (unsigned char *) num1+qdig+len2;
- ptr2 = (unsigned char *) mval+len2;
- for (count = 0; count < len2+1; count++)
- {
- val = (int) *ptr1 - (int) *ptr2-- - borrow;
- if (val < 0)
- {
- val += 10;
- borrow = 1;
- }
- else
- borrow = 0;
- *ptr1-- = val;
- }
- }
-
- /* Test for negative result. */
- if (borrow == 1)
- {
- qguess--;
- ptr1 = (unsigned char *) num1+qdig+len2;
- ptr2 = (unsigned char *) n2ptr+len2-1;
- carry = 0;
- for (count = 0; count < len2; count++)
- {
- val = (int) *ptr1 + (int) *ptr2-- + carry;
- if (val > 9)
- {
- val -= 10;
- carry = 1;
- }
- else
- carry = 0;
- *ptr1-- = val;
- }
- if (carry == 1) *ptr1 = (*ptr1 + 1) % 10;
- }
-
- /* We now know the quotient digit. */
- *qptr++ = qguess;
- qdig++;
- }
- }
-
- /* Clean up and return the number. */
- qval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS );
- if (is_zero (qval)) qval->n_sign = PLUS;
- _rm_leading_zeros (qval);
- free_num (quot);
- *quot = qval;
-
- /* Clean up temporary storage. */
- free (mval);
- free (num1);
- free (num2);
-
- return 0; /* Everything is OK. */
-}
-
-
-/* Modulo for numbers. This computes NUM1 % NUM2 and puts the
- result in RESULT. */
-
-int
-bc_modulo (num1, num2, result, scale)
- bc_num num1, num2, *result;
- int scale;
-{
- bc_num temp;
- int rscale;
-
- /* Check for correct numbers. */
- if (is_zero (num2)) return -1;
-
- /* Calculate final scale. */
- rscale = MAX (num1->n_scale, num2->n_scale+scale);
- init_num (&temp);
-
- /* Calculate it. */
- bc_divide (num1, num2, &temp, scale);
- bc_multiply (temp, num2, &temp, rscale);
- bc_sub (num1, temp, result);
- free_num (&temp);
-
- return 0; /* Everything is OK. */
-}
-
-
-/* Raise NUM1 to the NUM2 power. The result is placed in RESULT.
- Maximum exponent is LONG_MAX. If a NUM2 is not an integer,
- only the integer part is used. */
-
-void
-bc_raise (num1, num2, result, scale)
- bc_num num1, num2, *result;
- int scale;
-{
- bc_num temp, power;
- long exponent;
- int rscale;
- char neg;
-
- /* Check the exponent for scale digits and convert to a long. */
- if (num2->n_scale != 0)
- rt_warn ("non-zero scale in exponent");
- exponent = num2long (num2);
- if (exponent == 0 && (num2->n_len > 1 || num2->n_value[0] != 0))
- rt_error ("exponent too large in raise");
-
- /* Special case if exponent is a zero. */
- if (exponent == 0)
- {
- free_num (result);
- *result = copy_num (_one_);
- return;
- }
-
- /* Other initializations. */
- if (exponent < 0)
- {
- neg = TRUE;
- exponent = -exponent;
- rscale = scale;
- }
- else
- {
- neg = FALSE;
- rscale = MIN (num1->n_scale*exponent, MAX(scale, num1->n_scale));
- }
-
- /* Set initial value of temp. */
- power = copy_num (num1);
- while ((exponent & 1) == 0)
- {
- bc_multiply (power, power, &power, rscale);
- exponent = exponent >> 1;
- }
- temp = copy_num (power);
- exponent = exponent >> 1;
-
- /* Do the calculation. */
- while (exponent > 0)
- {
- bc_multiply (power, power, &power, rscale);
- if ((exponent & 1) == 1)
- bc_multiply (temp, power, &temp, rscale);
- exponent = exponent >> 1;
- }
-
- /* Assign the value. */
- if (neg)
- {
- bc_divide (_one_, temp, result, rscale);
- free_num (&temp);
- }
- else
- {
- free_num (result);
- *result = temp;
- }
- free_num (&power);
-}
-
-
-/* Take the square root NUM and return it in NUM with SCALE digits
- after the decimal place. */
-
-int
-bc_sqrt (num, scale)
- bc_num *num;
- int scale;
-{
- int rscale, cmp_res, done;
- int cscale;
- bc_num guess, guess1, point5;
-
- /* Initial checks. */
- cmp_res = bc_compare (*num, _zero_);
- if (cmp_res < 0)
- return 0; /* error */
- else
- {
- if (cmp_res == 0)
- {
- free_num (num);
- *num = copy_num (_zero_);
- return 1;
- }
- }
- cmp_res = bc_compare (*num, _one_);
- if (cmp_res == 0)
- {
- free_num (num);
- *num = copy_num (_one_);
- return 1;
- }
-
- /* Initialize the variables. */
- rscale = MAX (scale, (*num)->n_scale);
- init_num (&guess);
- init_num (&guess1);
- point5 = new_num (1,1);
- point5->n_value[1] = 5;
-
-
- /* Calculate the initial guess. */
- if (cmp_res < 0)
- /* The number is between 0 and 1. Guess should start at 1. */
- guess = copy_num (_one_);
- else
- {
- /* The number is greater than 1. Guess should start at 10^(exp/2). */
- int2num (&guess,10);
- int2num (&guess1,(*num)->n_len);
- bc_multiply (guess1, point5, &guess1, 0);
- guess1->n_scale = 0;
- bc_raise (guess, guess1, &guess, 0);
- free_num (&guess1);
- }
-
- /* Find the square root using Newton's algorithm. */
- done = FALSE;
- cscale = 2;
- while (!done)
- {
- free_num (&guess1);
- guess1 = copy_num (guess);
- bc_divide (*num,guess,&guess,cscale);
- bc_add (guess,guess1,&guess);
- bc_multiply (guess,point5,&guess,cscale);
- cmp_res = _do_compare (guess,guess1,FALSE,TRUE);
- if (cmp_res == 0)
- if (cscale < rscale+1)
- cscale = MIN (cscale*3, rscale+1);
- else
- done = TRUE;
- }
-
- /* Assign the number and clean up. */
- free_num (num);
- bc_divide (guess,_one_,num,rscale);
- free_num (&guess);
- free_num (&guess1);
- free_num (&point5);
- return 1;
-}
-
-
-/* The following routines provide output for bcd numbers package
- using the rules of POSIX bc for output. */
-
-/* This structure is used for saving digits in the conversion process. */
-typedef struct stk_rec {
- long digit;
- struct stk_rec *next;
-} stk_rec;
-
-/* The reference string for digits. */
-char ref_str[] = "0123456789ABCDEF";
-
-
-/* A special output routine for "multi-character digits." Exactly
- SIZE characters must be output for the value VAL. If SPACE is
- non-zero, we must output one space before the number. OUT_CHAR
- is the actual routine for writing the characters. */
-
-void
-out_long (val, size, space, out_char)
- long val;
- int size, space;
-#ifdef __STDC__
- void (*out_char)(int);
-#else
- void (*out_char)();
-#endif
-{
- char digits[40];
- int len, ix;
-
- if (space) (*out_char) (' ');
- sprintf (digits, "%ld", val);
- len = strlen (digits);
- while (size > len)
- {
- (*out_char) ('0');
- size--;
- }
- for (ix=0; ix < len; ix++)
- (*out_char) (digits[ix]);
-}
-
-/* Output of a bcd number. NUM is written in base O_BASE using OUT_CHAR
- as the routine to do the actual output of the characters. */
-
-void
-out_num (num, o_base, out_char)
- bc_num num;
- int o_base;
-#ifdef __STDC__
- void (*out_char)(int);
-#else
- void (*out_char)();
-#endif
-{
- char *nptr;
- int index, fdigit, pre_space;
- stk_rec *digits, *temp;
- bc_num int_part, frac_part, base, cur_dig, t_num, max_o_digit;
-
- /* The negative sign if needed. */
- if (num->n_sign == MINUS) (*out_char) ('-');
-
- /* Output the number. */
- if (is_zero (num))
- (*out_char) ('0');
- else
- if (o_base == 10)
- {
- /* The number is in base 10, do it the fast way. */
- nptr = num->n_value;
- if (num->n_len > 1 || *nptr != 0)
- for (index=num->n_len; index>0; index--)
- (*out_char) (BCD_CHAR(*nptr++));
- else
- nptr++;
-
- /* Now the fraction. */
- if (num->n_scale > 0)
- {
- (*out_char) ('.');
- for (index=0; index<num->n_scale; index++)
- (*out_char) (BCD_CHAR(*nptr++));
- }
- }
- else
- {
- /* The number is some other base. */
- digits = NULL;
- init_num (&int_part);
- bc_divide (num, _one_, &int_part, 0);
- init_num (&frac_part);
- init_num (&cur_dig);
- init_num (&base);
- bc_sub (num, int_part, &frac_part);
- /* Make the INT_PART and FRAC_PART positive. */
- int_part->n_sign = PLUS;
- frac_part->n_sign = PLUS;
- int2num (&base, o_base);
- init_num (&max_o_digit);
- int2num (&max_o_digit, o_base-1);
-
-
- /* Get the digits of the integer part and push them on a stack. */
- while (!is_zero (int_part))
- {
- bc_modulo (int_part, base, &cur_dig, 0);
- temp = (stk_rec *) malloc (sizeof(stk_rec));
- if (temp == NULL) out_of_memory();
- temp->digit = num2long (cur_dig);
- temp->next = digits;
- digits = temp;
- bc_divide (int_part, base, &int_part, 0);
- }
-
- /* Print the digits on the stack. */
- if (digits != NULL)
- {
- /* Output the digits. */
- while (digits != NULL)
- {
- temp = digits;
- digits = digits->next;
- if (o_base <= 16)
- (*out_char) (ref_str[ (int) temp->digit]);
- else
- out_long (temp->digit, max_o_digit->n_len, 1, out_char);
- free (temp);
- }
- }
-
- /* Get and print the digits of the fraction part. */
- if (num->n_scale > 0)
- {
- (*out_char) ('.');
- pre_space = 0;
- t_num = copy_num (_one_);
- while (t_num->n_len <= num->n_scale) {
- bc_multiply (frac_part, base, &frac_part, num->n_scale);
- fdigit = num2long (frac_part);
- int2num (&int_part, fdigit);
- bc_sub (frac_part, int_part, &frac_part);
- if (o_base <= 16)
- (*out_char) (ref_str[fdigit]);
- else {
- out_long (fdigit, max_o_digit->n_len, pre_space, out_char);
- pre_space = 1;
- }
- bc_multiply (t_num, base, &t_num, 0);
- }
- }
-
- /* Clean up. */
- free_num (&int_part);
- free_num (&frac_part);
- free_num (&base);
- free_num (&cur_dig);
- }
-}
-
-
-#if DEBUG > 0
-
-/* Debugging procedures. Some are just so one can call them from the
- debugger. */
-
-/* p_n prints the number NUM in base 10. */
-
-void
-p_n (num)
- bc_num num;
-{
- out_num (num, 10, out_char);
-}
-
-
-/* p_b prints a character array as if it was a string of bcd digits. */
-void
-p_v (name, num, len)
- char *name;
- unsigned char *num;
- int len;
-{
- int i;
- printf ("%s=", name);
- for (i=0; i<len; i++) printf ("%c",BCD_CHAR(num[i]));
- printf ("\n");
-}
-
-
-/* Convert strings to bc numbers. Base 10 only.*/
-
-void
-str2num (num, str, scale)
- bc_num *num;
- char *str;
- int scale;
-{
- int digits, strscale;
- char *ptr, *nptr;
- char zero_int;
-
- /* Prepare num. */
- free_num (num);
-
- /* Check for valid number and count digits. */
- ptr = str;
- digits = 0;
- strscale = 0;
- zero_int = FALSE;
- if ( (*ptr == '+') || (*ptr == '-')) ptr++; /* Sign */
- while (*ptr == '0') ptr++; /* Skip leading zeros. */
- while (isdigit(*ptr)) ptr++, digits++; /* digits */
- if (*ptr == '.') ptr++; /* decimal point */
- while (isdigit(*ptr)) ptr++, strscale++; /* digits */
- if ((*ptr != '\0') || (digits+strscale == 0))
- {
- *num = copy_num (_zero_);
- return;
- }
-
- /* Adjust numbers and allocate storage and initialize fields. */
- strscale = MIN(strscale, scale);
- if (digits == 0)
- {
- zero_int = TRUE;
- digits = 1;
- }
- *num = new_num (digits, strscale);
-
- /* Build the whole number. */
- ptr = str;
- if (*ptr == '-')
- {
- (*num)->n_sign = MINUS;
- ptr++;
- }
- else
- {
- (*num)->n_sign = PLUS;
- if (*ptr == '+') ptr++;
- }
- while (*ptr == '0') ptr++; /* Skip leading zeros. */
- nptr = (*num)->n_value;
- if (zero_int)
- {
- *nptr++ = 0;
- digits = 0;
- }
- for (;digits > 0; digits--)
- *nptr++ = CH_VAL(*ptr++);
-
-
- /* Build the fractional part. */
- if (strscale > 0)
- {
- ptr++; /* skip the decimal point! */
- for (;strscale > 0; strscale--)
- *nptr++ = CH_VAL(*ptr++);
- }
-}
-
-/* Convert a numbers to a string. Base 10 only.*/
-
-char
-*num2str (num)
- bc_num num;
-{
- char *str, *sptr;
- char *nptr;
- int index, signch;
-
- /* Allocate the string memory. */
- signch = ( num->n_sign == PLUS ? 0 : 1 ); /* Number of sign chars. */
- if (num->n_scale > 0)
- str = (char *) malloc (num->n_len + num->n_scale + 2 + signch);
- else
- str = (char *) malloc (num->n_len + 1 + signch);
- if (str == NULL) out_of_memory();
-
- /* The negative sign if needed. */
- sptr = str;
- if (signch) *sptr++ = '-';
-
- /* Load the whole number. */
- nptr = num->n_value;
- for (index=num->n_len; index>0; index--)
- *sptr++ = BCD_CHAR(*nptr++);
-
- /* Now the fraction. */
- if (num->n_scale > 0)
- {
- *sptr++ = '.';
- for (index=0; index<num->n_scale; index++)
- *sptr++ = BCD_CHAR(*nptr++);
- }
-
- /* Terminate the string and return it! */
- *sptr = '\0';
- return (str);
-}
-#endif
diff --git a/gnu/usr.bin/bc/number.h b/gnu/usr.bin/bc/number.h
deleted file mode 100644
index 325612e..0000000
--- a/gnu/usr.bin/bc/number.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* number.h: Arbitrary precision numbers header file. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-
-typedef enum {PLUS, MINUS} sign;
-
-typedef struct
- {
- sign n_sign;
- int n_len; /* The number of digits before the decimal point. */
- int n_scale; /* The number of digits after the decimal point. */
- int n_refs; /* The number of pointers to this number. */
- char n_value[1]; /* The storage. Not zero char terminated. It is
- allocated with all other fields. */
- } bc_struct;
-
-typedef bc_struct *bc_num;
-
-/* Some useful macros and constants. */
-
-#define CH_VAL(c) (c - '0')
-#define BCD_CHAR(d) (d + '0')
-
-#ifdef MIN
-#undef MIN
-#undef MAX
-#endif
-#define MAX(a,b) (a>b?a:b)
-#define MIN(a,b) (a>b?b:a)
-#define ODD(a) (a&1)
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
diff --git a/gnu/usr.bin/bc/proto.h b/gnu/usr.bin/bc/proto.h
deleted file mode 100644
index 37fb212..0000000
--- a/gnu/usr.bin/bc/proto.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/* proto.h: Prototype function definitions for "external" functions. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-/* For the pc version using k&r ACK. (minix1.5 and earlier.) */
-#ifdef SHORTNAMES
-#define init_numbers i_numbers
-#define push_constant push__constant
-#define load_const in_load_const
-#define yy_get_next_buffer yyget_next_buffer
-#define yy_init_buffer yyinit_buffer
-#define yy_last_accepting_state yylast_accepting_state
-#define arglist1 arg1list
-#endif
-
-/* Include the standard library header files. */
-#include <unistd.h>
-#include <stdlib.h>
-
-/* Define the _PROTOTYPE macro if it is needed. */
-
-#ifndef _PROTOTYPE
-#ifdef __STDC__
-#define _PROTOTYPE(func, args) func args
-#else
-#define _PROTOTYPE(func, args) func()
-#endif
-#endif
-
-/* From execute.c */
-_PROTOTYPE(void stop_execution, (int));
-_PROTOTYPE(unsigned char byte, (program_counter *pc));
-_PROTOTYPE(void execute, (void));
-_PROTOTYPE(char prog_char, (void));
-_PROTOTYPE(char input_char, (void));
-_PROTOTYPE(void push_constant, (char (*in_char)(void), int conv_base));
-_PROTOTYPE(void push_b10_const, (program_counter *pc));
-_PROTOTYPE(void assign, (int c_code));
-
-/* From util.c */
-_PROTOTYPE(char *strcopyof, (char *str));
-_PROTOTYPE(arg_list *nextarg, (arg_list *args, int val));
-_PROTOTYPE(char *arg_str, (arg_list *args));
-_PROTOTYPE(char *call_str, (arg_list *args));
-_PROTOTYPE(void free_args, (arg_list *args));
-_PROTOTYPE(void check_params, (arg_list *params, arg_list *autos));
-_PROTOTYPE(void init_gen, (void));
-_PROTOTYPE(void generate, (char *str));
-_PROTOTYPE(void run_code, (void));
-_PROTOTYPE(void out_char, (int ch));
-_PROTOTYPE(id_rec *find_id, (id_rec *tree, char *id));
-_PROTOTYPE(int insert_id_rec, (id_rec **root, id_rec *new_id));
-_PROTOTYPE(void init_tree, (void));
-_PROTOTYPE(int lookup, (char *name, int namekind));
-_PROTOTYPE(char *bc_malloc, (int));
-_PROTOTYPE(void out_of_memory, (void));
-_PROTOTYPE(void welcome, (void));
-_PROTOTYPE(void warranty, (char *));
-_PROTOTYPE(void limits, (void));
-_PROTOTYPE(void yyerror, (char *str ,...));
-_PROTOTYPE(void warn, (char *mesg ,...));
-_PROTOTYPE(void rt_error, (char *mesg ,...));
-_PROTOTYPE(void rt_warn, (char *mesg ,...));
-
-/* From load.c */
-_PROTOTYPE(void init_load, (void));
-_PROTOTYPE(void addbyte, (int byte));
-_PROTOTYPE(void def_label, (long lab));
-_PROTOTYPE(long long_val, (char **str));
-_PROTOTYPE(void load_code, (char *code));
-
-/* From main.c */
-_PROTOTYPE(int main, (int argc , char *argv []));
-_PROTOTYPE(int open_new_file, (void));
-_PROTOTYPE(void new_yy_file, (FILE *file));
-_PROTOTYPE(void use_quit, (int));
-
-/* From number.c */
-_PROTOTYPE(void free_num, (bc_num *num));
-_PROTOTYPE(bc_num new_num, (int length, int scale));
-_PROTOTYPE(void init_numbers, (void));
-_PROTOTYPE(bc_num copy_num, (bc_num num));
-_PROTOTYPE(void init_num, (bc_num *num));
-_PROTOTYPE(void str2num, (bc_num *num, char *str, int scale));
-_PROTOTYPE(char *num2str, (bc_num num));
-_PROTOTYPE(void int2num, (bc_num *num, int val));
-_PROTOTYPE(long num2long, (bc_num num));
-_PROTOTYPE(int bc_compare, (bc_num n1, bc_num n2));
-_PROTOTYPE(char is_zero, (bc_num num));
-_PROTOTYPE(char is_neg, (bc_num num));
-_PROTOTYPE(void bc_add, (bc_num n1, bc_num n2, bc_num *result));
-_PROTOTYPE(void bc_sub, (bc_num n1, bc_num n2, bc_num *result));
-_PROTOTYPE(void bc_multiply, (bc_num n1, bc_num n2, bc_num *prod, int scale));
-_PROTOTYPE(int bc_divide, (bc_num n1, bc_num n2, bc_num *quot, int scale));
-_PROTOTYPE(int bc_modulo, (bc_num num1, bc_num num2, bc_num *result, int scale));
-_PROTOTYPE(void bc_raise, (bc_num num1, bc_num num2, bc_num *result, int scale));
-_PROTOTYPE(int bc_sqrt, (bc_num *num, int scale));
-_PROTOTYPE(void out_long, (long val, int size, int space,
- void (*out_char)(int)));
-_PROTOTYPE(void out_num, (bc_num num, int o_base, void (* out_char)(int)));
-
-
-/* From storage.c */
-_PROTOTYPE(void init_storage, (void));
-_PROTOTYPE(void more_functions, (void));
-_PROTOTYPE(void more_variables, (void));
-_PROTOTYPE(void more_arrays, (void));
-_PROTOTYPE(void clear_func, (int func ));
-_PROTOTYPE(int fpop, (void));
-_PROTOTYPE(void fpush, (int val ));
-_PROTOTYPE(void pop, (void));
-_PROTOTYPE(void push_copy, (bc_num num ));
-_PROTOTYPE(void push_num, (bc_num num ));
-_PROTOTYPE(char check_stack, (int depth ));
-_PROTOTYPE(bc_var *get_var, (int var_name ));
-_PROTOTYPE(bc_num *get_array_num, (int var_index, long index ));
-_PROTOTYPE(void store_var, (int var_name ));
-_PROTOTYPE(void store_array, (int var_name ));
-_PROTOTYPE(void load_var, (int var_name ));
-_PROTOTYPE(void load_array, (int var_name ));
-_PROTOTYPE(void decr_var, (int var_name ));
-_PROTOTYPE(void decr_array, (int var_name ));
-_PROTOTYPE(void incr_var, (int var_name ));
-_PROTOTYPE(void incr_array, (int var_name ));
-_PROTOTYPE(void auto_var, (int name ));
-_PROTOTYPE(void free_a_tree, (bc_array_node *root, int depth ));
-_PROTOTYPE(void pop_vars, (arg_list *list ));
-_PROTOTYPE(void process_params, (program_counter *pc, int func ));
-
-/* For the scanner and parser.... */
-_PROTOTYPE(int yyparse, (void));
-_PROTOTYPE(int yylex, (void));
-
-/* Other things... */
-_PROTOTYPE (int getopt, (int, char * CONST [], CONST char *));
-
diff --git a/gnu/usr.bin/bc/scan.l b/gnu/usr.bin/bc/scan.l
deleted file mode 100644
index 8189364..0000000
--- a/gnu/usr.bin/bc/scan.l
+++ /dev/null
@@ -1,196 +0,0 @@
-%{
-/* scan.l: the (f)lex description file for the scanner. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-#include "bcdefs.h"
-#include "y.tab.h"
-#include "global.h"
-#include "proto.h"
-
-/* Using flex, we can ask for a smaller input buffer. With lex, this
- does nothing! */
-
-#ifdef SMALL_BUF
-#undef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 512
-#endif
-
-/* We want to define our own yywrap. */
-#undef yywrap
-_PROTOTYPE(int yywrap, (void));
-
-/* MINIX returns from read with < 0 if SIGINT is encountered.
- In flex, we can redefine YY_INPUT to the following. In lex, this
- does nothing! */
-#include <errno.h>
-#undef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- while ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
- if (errno != EINTR) \
- YY_FATAL_ERROR( "read() in flex scanner failed" );
-
-%}
-DIGIT [0-9A-F]
-LETTER [a-z]
-%%
-define return(Define);
-break return(Break);
-quit return(Quit);
-length return(Length);
-return return(Return);
-for return(For);
-if return(If);
-while return(While);
-sqrt return(Sqrt);
-scale return(Scale);
-ibase return(Ibase);
-obase return(Obase);
-auto return(Auto);
-else return(Else);
-read return(Read);
-halt return(Halt);
-last return(Last);
-warranty return(Warranty);
-continue return(Continue);
-print return(Print);
-limits return(Limits);
-"." {
-#ifdef DOT_IS_LAST
- return(Last);
-#else
- yyerror ("illegal character: %s",yytext);
-#endif
- }
-"+"|"-"|";"|"("|")"|"{"|"}"|"["|"]"|","|"^" { yylval.c_value = yytext[0];
- return((int)yytext[0]); }
-&& { return(AND); }
-\|\| { return(OR); }
-"!" { return(NOT); }
-"*"|"/"|"%" { yylval.c_value = yytext[0]; return(MUL_OP); }
-"="|\+=|-=|\*=|\/=|%=|\^= { yylval.c_value = yytext[0]; return(ASSIGN_OP); }
-=\+|=-|=\*|=\/|=%|=\^ {
-#ifdef OLD_EQ_OP
- char warn_save;
- warn_save = warn_not_std;
- warn_not_std = TRUE;
- warn ("Old fashioned =<op>");
- warn_not_std = warn_save;
- yylval.c_value = yytext[1];
-#else
- yylval.c_value = '=';
- yyless (1);
-#endif
- return(ASSIGN_OP);
- }
-==|\<=|\>=|\!=|"<"|">" { yylval.s_value = strcopyof(yytext); return(REL_OP); }
-\+\+|-- { yylval.c_value = yytext[0]; return(INCR_DECR); }
-"\n" { line_no++; return(NEWLINE); }
-\\\n { line_no++; /* ignore a "quoted" newline */ }
-[ \t]+ { /* ignore spaces and tabs */ }
-"/*" {
- int c;
-
- for (;;)
- {
- while ( ((c=input()) != '*') && (c != EOF))
- /* eat it */
- if (c == '\n') line_no++;
- if (c == '*')
- {
- while ( (c=input()) == '*') /* eat it*/;
- if (c == '/') break; /* at end of comment */
- if (c == '\n') line_no++;
- }
- if (c == EOF)
- {
- fprintf (stderr,"EOF encountered in a comment.\n");
- break;
- }
- }
- }
-[a-z][a-z0-9_]* { yylval.s_value = strcopyof(yytext); return(NAME); }
-\"[^\"]*\" {
- unsigned char *look;
- int count = 0;
- yylval.s_value = strcopyof(yytext);
- for (look = yytext; *look != 0; look++)
- {
- if (*look == '\n') line_no++;
- if (*look == '"') count++;
- }
- if (count != 2) yyerror ("NUL character in string.");
- return(STRING);
- }
-{DIGIT}({DIGIT}|\\\n)*("."({DIGIT}|\\\n)*)?|"."(\\\n)*{DIGIT}({DIGIT}|\\\n)* {
- unsigned char *src, *dst;
- int len;
- /* remove a trailing decimal point. */
- len = strlen(yytext);
- if (yytext[len-1] == '.')
- yytext[len-1] = 0;
- /* remove leading zeros. */
- src = yytext;
- dst = yytext;
- while (*src == '0') src++;
- if (*src == 0) src--;
- /* Copy strings removing the newlines. */
- while (*src != 0)
- {
- if (*src == '\\')
- {
- src++; src++;
- line_no++;
- }
- else
- *dst++ = *src++;
- }
- *dst = 0;
- yylval.s_value = strcopyof(yytext);
- return(NUMBER);
- }
-. {
- if (yytext[0] < ' ')
- yyerror ("illegal character: ^%c",yytext[0] + '@');
- else
- if (yytext[0] > '~')
- yyerror ("illegal character: \\%3d", (int) yytext[0]);
- else
- yyerror ("illegal character: %s",yytext);
- }
-%%
-
-
-
-/* This is the way to get multiple files input into lex. */
-
-int
-yywrap()
-{
- if (!open_new_file ()) return (1); /* EOF on standard in. */
- return (0); /* We have more input. */
-}
diff --git a/gnu/usr.bin/bc/storage.c b/gnu/usr.bin/bc/storage.c
deleted file mode 100644
index b4ed270..0000000
--- a/gnu/usr.bin/bc/storage.c
+++ /dev/null
@@ -1,963 +0,0 @@
-/* storage.c: Code and data storage manipulations. This includes labels. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-#include "bcdefs.h"
-#include "global.h"
-#include "proto.h"
-
-
-/* Initialize the storage at the beginning of the run. */
-
-void
-init_storage ()
-{
-
- /* Functions: we start with none and ask for more. */
- f_count = 0;
- more_functions ();
- f_names[0] = "(main)";
-
- /* Variables. */
- v_count = 0;
- more_variables ();
-
- /* Arrays. */
- a_count = 0;
- more_arrays ();
-
- /* Other things... */
- ex_stack = NULL;
- fn_stack = NULL;
- i_base = 10;
- o_base = 10;
- scale = 0;
- c_code = FALSE;
- init_numbers();
-}
-
-/* Three functions for increasing the number of functions, variables, or
- arrays that are needed. This adds another 32 of the requested object. */
-
-void
-more_functions (VOID)
-{
- int old_count;
- int indx1, indx2;
- bc_function *old_f;
- bc_function *f;
- char **old_names;
-
- /* Save old information. */
- old_count = f_count;
- old_f = functions;
- old_names = f_names;
-
- /* Add a fixed amount and allocate new space. */
- f_count += STORE_INCR;
- functions = (bc_function *) bc_malloc (f_count*sizeof (bc_function));
- f_names = (char **) bc_malloc (f_count*sizeof (char *));
-
- /* Copy old ones. */
- for (indx1 = 0; indx1 < old_count; indx1++)
- {
- functions[indx1] = old_f[indx1];
- f_names[indx1] = old_names[indx1];
- }
-
- /* Initialize the new ones. */
- for (; indx1 < f_count; indx1++)
- {
- f = &functions[indx1];
- f->f_defined = FALSE;
- for (indx2 = 0; indx2 < BC_MAX_SEGS; indx2++)
- f->f_body [indx2] = NULL;
- f->f_code_size = 0;
- f->f_label = NULL;
- f->f_autos = NULL;
- f->f_params = NULL;
- }
-
- /* Free the old elements. */
- if (old_count != 0)
- {
- free (old_f);
- free (old_names);
- }
-}
-
-void
-more_variables ()
-{
- int indx;
- int old_count;
- bc_var **old_var;
- char **old_names;
-
- /* Save the old values. */
- old_count = v_count;
- old_var = variables;
- old_names = v_names;
-
- /* Increment by a fixed amount and allocate. */
- v_count += STORE_INCR;
- variables = (bc_var **) bc_malloc (v_count*sizeof(bc_var *));
- v_names = (char **) bc_malloc (v_count*sizeof(char *));
-
- /* Copy the old variables. */
- for (indx = 3; indx < old_count; indx++)
- variables[indx] = old_var[indx];
-
- /* Initialize the new elements. */
- for (; indx < v_count; indx++)
- variables[indx] = NULL;
-
- /* Free the old elements. */
- if (old_count != 0)
- {
- free (old_var);
- free (old_names);
- }
-}
-
-void
-more_arrays ()
-{
- int indx;
- int old_count;
- bc_var_array **old_ary;
- char **old_names;
-
- /* Save the old values. */
- old_count = a_count;
- old_ary = arrays;
- old_names = a_names;
-
- /* Increment by a fixed amount and allocate. */
- a_count += STORE_INCR;
- arrays = (bc_var_array **) bc_malloc (a_count*sizeof(bc_var_array *));
- a_names = (char **) bc_malloc (a_count*sizeof(char *));
-
- /* Copy the old arrays. */
- for (indx = 1; indx < old_count; indx++)
- arrays[indx] = old_ary[indx];
-
-
- /* Initialize the new elements. */
- for (; indx < v_count; indx++)
- arrays[indx] = NULL;
-
- /* Free the old elements. */
- if (old_count != 0)
- {
- free (old_ary);
- free (old_names);
- }
-}
-
-
-/* clear_func clears out function FUNC and makes it ready to redefine. */
-
-void
-clear_func (func)
- char func;
-{
- bc_function *f;
- int indx;
- bc_label_group *lg;
-
- /* Set the pointer to the function. */
- f = &functions[func];
- f->f_defined = FALSE;
-
- /* Clear the code segments. */
- for (indx = 0; indx < BC_MAX_SEGS; indx++)
- {
- if (f->f_body[indx] != NULL)
- {
- free (f->f_body[indx]);
- f->f_body[indx] = NULL;
- }
- }
-
- f->f_code_size = 0;
- if (f->f_autos != NULL)
- {
- free_args (f->f_autos);
- f->f_autos = NULL;
- }
- if (f->f_params != NULL)
- {
- free_args (f->f_params);
- f->f_params = NULL;
- }
- while (f->f_label != NULL)
- {
- lg = f->f_label->l_next;
- free (f->f_label);
- f->f_label = lg;
- }
-}
-
-
-/* Pop the function execution stack and return the top. */
-
-int
-fpop()
-{
- fstack_rec *temp;
- int retval = 0;
-
- if (fn_stack != NULL)
- {
- temp = fn_stack;
- fn_stack = temp->s_next;
- retval = temp->s_val;
- free (temp);
- }
- return (retval);
-}
-
-
-/* Push VAL on to the function stack. */
-
-void
-fpush (val)
- int val;
-{
- fstack_rec *temp;
-
- temp = (fstack_rec *) bc_malloc (sizeof (fstack_rec));
- temp->s_next = fn_stack;
- temp->s_val = val;
- fn_stack = temp;
-}
-
-
-/* Pop and discard the top element of the regular execution stack. */
-
-void
-pop ()
-{
- estack_rec *temp;
-
- if (ex_stack != NULL)
- {
- temp = ex_stack;
- ex_stack = temp->s_next;
- free_num (&temp->s_num);
- free (temp);
- }
-}
-
-
-/* Push a copy of NUM on to the regular execution stack. */
-
-void
-push_copy (num)
- bc_num num;
-{
- estack_rec *temp;
-
- temp = (estack_rec *) bc_malloc (sizeof (estack_rec));
- temp->s_num = copy_num (num);
- temp->s_next = ex_stack;
- ex_stack = temp;
-}
-
-
-/* Push NUM on to the regular execution stack. Do NOT push a copy. */
-
-void
-push_num (num)
- bc_num num;
-{
- estack_rec *temp;
-
- temp = (estack_rec *) bc_malloc (sizeof (estack_rec));
- temp->s_num = num;
- temp->s_next = ex_stack;
- ex_stack = temp;
-}
-
-
-/* Make sure the ex_stack has at least DEPTH elements on it.
- Return TRUE if it has at least DEPTH elements, otherwise
- return FALSE. */
-
-char
-check_stack (depth)
- int depth;
-{
- estack_rec *temp;
-
- temp = ex_stack;
- while ((temp != NULL) && (depth > 0))
- {
- temp = temp->s_next;
- depth--;
- }
- if (depth > 0)
- {
- rt_error ("Stack error.");
- return FALSE;
- }
- return TRUE;
-}
-
-
-/* The following routines manipulate simple variables and
- array variables. */
-
-/* get_var returns a pointer to the variable VAR_NAME. If one does not
- exist, one is created. */
-
-bc_var *
-get_var (var_name)
- int var_name;
-{
- bc_var *var_ptr;
-
- var_ptr = variables[var_name];
- if (var_ptr == NULL)
- {
- var_ptr = variables[var_name] = (bc_var *) bc_malloc (sizeof (bc_var));
- init_num (&var_ptr->v_value);
- }
- return var_ptr;
-}
-
-
-/* get_array_num returns the address of the bc_num in the array
- structure. If more structure is requried to get to the index,
- this routine does the work to create that structure. VAR_INDEX
- is a zero based index into the arrays storage array. INDEX is
- the index into the bc array. */
-
-bc_num *
-get_array_num (var_index, index)
- int var_index;
- long index;
-{
- bc_var_array *ary_ptr;
- bc_array *a_var;
- bc_array_node *temp;
- int log, ix, ix1;
- int sub [NODE_DEPTH];
-
- /* Get the array entry. */
- ary_ptr = arrays[var_index];
- if (ary_ptr == NULL)
- {
- ary_ptr = arrays[var_index] =
- (bc_var_array *) bc_malloc (sizeof (bc_var_array));
- ary_ptr->a_value = NULL;
- ary_ptr->a_next = NULL;
- ary_ptr->a_param = FALSE;
- }
-
- a_var = ary_ptr->a_value;
- if (a_var == NULL) {
- a_var = ary_ptr->a_value = (bc_array *) bc_malloc (sizeof (bc_array));
- a_var->a_tree = NULL;
- a_var->a_depth = 0;
- }
-
- /* Get the index variable. */
- sub[0] = index & NODE_MASK;
- ix = index >> NODE_SHIFT;
- log = 1;
- while (ix > 0 || log < a_var->a_depth)
- {
- sub[log] = ix & NODE_MASK;
- ix >>= NODE_SHIFT;
- log++;
- }
-
- /* Build any tree that is necessary. */
- while (log > a_var->a_depth)
- {
- temp = (bc_array_node *) bc_malloc (sizeof(bc_array_node));
- if (a_var->a_depth != 0)
- {
- temp->n_items.n_down[0] = a_var->a_tree;
- for (ix=1; ix < NODE_SIZE; ix++)
- temp->n_items.n_down[ix] = NULL;
- }
- else
- {
- for (ix=0; ix < NODE_SIZE; ix++)
- temp->n_items.n_num[ix] = copy_num(_zero_);
- }
- a_var->a_tree = temp;
- a_var->a_depth++;
- }
-
- /* Find the indexed variable. */
- temp = a_var->a_tree;
- while ( log-- > 1)
- {
- ix1 = sub[log];
- if (temp->n_items.n_down[ix1] == NULL)
- {
- temp->n_items.n_down[ix1] =
- (bc_array_node *) bc_malloc (sizeof(bc_array_node));
- temp = temp->n_items.n_down[ix1];
- if (log > 1)
- for (ix=0; ix < NODE_SIZE; ix++)
- temp->n_items.n_down[ix] = NULL;
- else
- for (ix=0; ix < NODE_SIZE; ix++)
- temp->n_items.n_num[ix] = copy_num(_zero_);
- }
- else
- temp = temp->n_items.n_down[ix1];
- }
-
- /* Return the address of the indexed variable. */
- return &(temp->n_items.n_num[sub[0]]);
-}
-
-
-/* Store the top of the execution stack into VAR_NAME.
- This includes the special variables ibase, obase, and scale. */
-
-void
-store_var (var_name)
- int var_name;
-{
- bc_var *var_ptr;
- long temp = 0;
- char toobig;
-
- if (var_name > 2)
- {
- /* It is a simple variable. */
- var_ptr = get_var (var_name);
- if (var_ptr != NULL)
- {
- free_num(&var_ptr->v_value);
- var_ptr->v_value = copy_num (ex_stack->s_num);
- }
- }
- else
- {
- /* It is a special variable... */
- toobig = FALSE;
- if (is_neg (ex_stack->s_num))
- {
- switch (var_name)
- {
- case 0:
- rt_warn ("negative ibase, set to 2");
- temp = 2;
- break;
- case 1:
- rt_warn ("negative obase, set to 2");
- temp = 2;
- break;
- case 2:
- rt_warn ("negative scale, set to 0");
- temp = 0;
- break;
- }
- }
- else
- {
- temp = num2long (ex_stack->s_num);
- if (!is_zero (ex_stack->s_num) && temp == 0)
- toobig = TRUE;
- }
- switch (var_name)
- {
- case 0:
- if (temp < 2 && !toobig)
- {
- i_base = 2;
- rt_warn ("ibase too small, set to 2");
- }
- else
- if (temp > 16 || toobig)
- {
- i_base = 16;
- rt_warn ("ibase too large, set to 16");
- }
- else
- i_base = (int) temp;
- break;
-
- case 1:
- if (temp < 2 && !toobig)
- {
- o_base = 2;
- rt_warn ("obase too small, set to 2");
- }
- else
- if (temp > BC_BASE_MAX || toobig)
- {
- o_base = BC_BASE_MAX;
- rt_warn ("obase too large, set to %d", BC_BASE_MAX);
- }
- else
- o_base = (int) temp;
- break;
-
- case 2:
- /* WARNING: The following if statement may generate a compiler
- warning if INT_MAX == LONG_MAX. This is NOT a problem. */
- if (temp > BC_SCALE_MAX || toobig )
- {
- scale = BC_SCALE_MAX;
- rt_warn ("scale too large, set to %d", BC_SCALE_MAX);
- }
- else
- scale = (int) temp;
- }
- }
-}
-
-
-/* Store the top of the execution stack into array VAR_NAME.
- VAR_NAME is the name of an array, and the next to the top
- of stack for the index into the array. */
-
-void
-store_array (var_name)
- int var_name;
-{
- bc_num *num_ptr;
- long index;
-
- if (!check_stack(2)) return;
- index = num2long (ex_stack->s_next->s_num);
- if (index < 0 || index > BC_DIM_MAX ||
- (index == 0 && !is_zero(ex_stack->s_next->s_num)))
- rt_error ("Array %s subscript out of bounds.", a_names[var_name]);
- else
- {
- num_ptr = get_array_num (var_name, index);
- if (num_ptr != NULL)
- {
- free_num (num_ptr);
- *num_ptr = copy_num (ex_stack->s_num);
- free_num (&ex_stack->s_next->s_num);
- ex_stack->s_next->s_num = ex_stack->s_num;
- init_num (&ex_stack->s_num);
- pop();
- }
- }
-}
-
-
-/* Load a copy of VAR_NAME on to the execution stack. This includes
- the special variables ibase, obase and scale. */
-
-void
-load_var (var_name)
- int var_name;
-{
- bc_var *var_ptr;
-
- switch (var_name)
- {
-
- case 0:
- /* Special variable ibase. */
- push_copy (_zero_);
- int2num (&ex_stack->s_num, i_base);
- break;
-
- case 1:
- /* Special variable obase. */
- push_copy (_zero_);
- int2num (&ex_stack->s_num, o_base);
- break;
-
- case 2:
- /* Special variable scale. */
- push_copy (_zero_);
- int2num (&ex_stack->s_num, scale);
- break;
-
- default:
- /* It is a simple variable. */
- var_ptr = variables[var_name];
- if (var_ptr != NULL)
- push_copy (var_ptr->v_value);
- else
- push_copy (_zero_);
- }
-}
-
-
-/* Load a copy of VAR_NAME on to the execution stack. This includes
- the special variables ibase, obase and scale. */
-
-void
-load_array (var_name)
- int var_name;
-{
- bc_num *num_ptr;
- long index;
-
- if (!check_stack(1)) return;
- index = num2long (ex_stack->s_num);
- if (index < 0 || index > BC_DIM_MAX ||
- (index == 0 && !is_zero(ex_stack->s_num)))
- rt_error ("Array %s subscript out of bounds.", a_names[var_name]);
- else
- {
- num_ptr = get_array_num (var_name, index);
- if (num_ptr != NULL)
- {
- pop();
- push_copy (*num_ptr);
- }
- }
-}
-
-
-/* Decrement VAR_NAME by one. This includes the special variables
- ibase, obase, and scale. */
-
-void
-decr_var (var_name)
- int var_name;
-{
- bc_var *var_ptr;
-
- switch (var_name)
- {
-
- case 0: /* ibase */
- if (i_base > 2)
- i_base--;
- else
- rt_warn ("ibase too small in --");
- break;
-
- case 1: /* obase */
- if (o_base > 2)
- o_base--;
- else
- rt_warn ("obase too small in --");
- break;
-
- case 2: /* scale */
- if (scale > 0)
- scale--;
- else
- rt_warn ("scale can not be negative in -- ");
- break;
-
- default: /* It is a simple variable. */
- var_ptr = get_var (var_name);
- if (var_ptr != NULL)
- bc_sub (var_ptr->v_value,_one_,&var_ptr->v_value);
- }
-}
-
-
-/* Decrement VAR_NAME by one. VAR_NAME is an array, and the top of
- the execution stack is the index and it is popped off the stack. */
-
-void
-decr_array (var_name)
- char var_name;
-{
- bc_num *num_ptr;
- long index;
-
- /* It is an array variable. */
- if (!check_stack (1)) return;
- index = num2long (ex_stack->s_num);
- if (index < 0 || index > BC_DIM_MAX ||
- (index == 0 && !is_zero (ex_stack->s_num)))
- rt_error ("Array %s subscript out of bounds.", a_names[var_name]);
- else
- {
- num_ptr = get_array_num (var_name, index);
- if (num_ptr != NULL)
- {
- pop ();
- bc_sub (*num_ptr, _one_, num_ptr);
- }
- }
-}
-
-
-/* Increment VAR_NAME by one. This includes the special variables
- ibase, obase, and scale. */
-
-void
-incr_var (var_name)
- int var_name;
-{
- bc_var *var_ptr;
-
- switch (var_name)
- {
-
- case 0: /* ibase */
- if (i_base < 16)
- i_base++;
- else
- rt_warn ("ibase too big in ++");
- break;
-
- case 1: /* obase */
- if (o_base < BC_BASE_MAX)
- o_base++;
- else
- rt_warn ("obase too big in ++");
- break;
-
- case 2:
- if (scale < BC_SCALE_MAX)
- scale++;
- else
- rt_warn ("Scale too big in ++");
- break;
-
- default: /* It is a simple variable. */
- var_ptr = get_var (var_name);
- if (var_ptr != NULL)
- bc_add (var_ptr->v_value, _one_, &var_ptr->v_value);
-
- }
-}
-
-
-/* Increment VAR_NAME by one. VAR_NAME is an array and top of
- execution stack is the index and is popped off the stack. */
-
-void
-incr_array (var_name)
- int var_name;
-{
- bc_num *num_ptr;
- long index;
-
- if (!check_stack (1)) return;
- index = num2long (ex_stack->s_num);
- if (index < 0 || index > BC_DIM_MAX ||
- (index == 0 && !is_zero (ex_stack->s_num)))
- rt_error ("Array %s subscript out of bounds.", a_names[var_name]);
- else
- {
- num_ptr = get_array_num (var_name, index);
- if (num_ptr != NULL)
- {
- pop ();
- bc_add (*num_ptr, _one_, num_ptr);
- }
- }
-}
-
-
-/* Routines for processing autos variables and parameters. */
-
-/* NAME is an auto variable that needs to be pushed on its stack. */
-
-void
-auto_var (name)
- int name;
-{
- bc_var *v_temp;
- bc_var_array *a_temp;
- int ix;
-
- if (name > 0)
- {
- /* A simple variable. */
- ix = name;
- v_temp = (bc_var *) bc_malloc (sizeof (bc_var));
- v_temp->v_next = variables[ix];
- init_num (&v_temp->v_value);
- variables[ix] = v_temp;
- }
- else
- {
- /* An array variable. */
- ix = -name;
- a_temp = (bc_var_array *) bc_malloc (sizeof (bc_var_array));
- a_temp->a_next = arrays[ix];
- a_temp->a_value = NULL;
- a_temp->a_param = FALSE;
- arrays[ix] = a_temp;
- }
-}
-
-
-/* Free_a_tree frees everything associated with an array variable tree.
- This is used when popping an array variable off its auto stack. */
-
-void
-free_a_tree ( root, depth )
- bc_array_node *root;
- int depth;
-{
- int ix;
-
- if (root != NULL)
- {
- if (depth > 1)
- for (ix = 0; ix < NODE_SIZE; ix++)
- free_a_tree (root->n_items.n_down[ix], depth-1);
- else
- for (ix = 0; ix < NODE_SIZE; ix++)
- free_num ( &(root->n_items.n_num[ix]));
- free (root);
- }
-}
-
-
-/* LIST is an NULL terminated list of varible names that need to be
- popped off their auto stacks. */
-
-void
-pop_vars (list)
- arg_list *list;
-{
- bc_var *v_temp;
- bc_var_array *a_temp;
- int ix;
-
- while (list != NULL)
- {
- ix = list->av_name;
- if (ix > 0)
- {
- /* A simple variable. */
- v_temp = variables[ix];
- if (v_temp != NULL)
- {
- variables[ix] = v_temp->v_next;
- free_num (&v_temp->v_value);
- free (v_temp);
- }
- }
- else
- {
- /* An array variable. */
- ix = -ix;
- a_temp = arrays[ix];
- if (a_temp != NULL)
- {
- arrays[ix] = a_temp->a_next;
- if (!a_temp->a_param && a_temp->a_value != NULL)
- {
- free_a_tree (a_temp->a_value->a_tree,
- a_temp->a_value->a_depth);
- free (a_temp->a_value);
- }
- free (a_temp);
- }
- }
- list = list->next;
- }
-}
-
-
-/* A call is being made to FUNC. The call types are at PC. Process
- the parameters by doing an auto on the parameter variable and then
- store the value at the new variable or put a pointer the the array
- variable. */
-
-void
-process_params (pc, func)
- program_counter *pc;
- int func;
-{
- char ch;
- arg_list *params;
- int ix, ix1;
- bc_var *v_temp;
- bc_var_array *a_src, *a_dest;
- bc_num *n_temp;
-
- /* Get the parameter names from the function. */
- params = functions[func].f_params;
-
- while ((ch = byte(pc)) != ':')
- {
- if (params != NULL)
- {
- if ((ch == '0') && params->av_name > 0)
- {
- /* A simple variable. */
- ix = params->av_name;
- v_temp = (bc_var *) bc_malloc (sizeof(bc_var));
- v_temp->v_next = variables[ix];
- v_temp->v_value = ex_stack->s_num;
- init_num (&ex_stack->s_num);
- variables[ix] = v_temp;
- }
- else
- if ((ch == '1') && (params->av_name < 0))
- {
- /* The variables is an array variable. */
-
- /* Compute source index and make sure some structure exists. */
- ix = (int) num2long (ex_stack->s_num);
- n_temp = get_array_num (ix, 0);
-
- /* Push a new array and Compute Destination index */
- auto_var (params->av_name);
- ix1 = -params->av_name;
-
- /* Set up the correct pointers in the structure. */
- if (ix == ix1)
- a_src = arrays[ix]->a_next;
- else
- a_src = arrays[ix];
- a_dest = arrays[ix1];
- a_dest->a_param = TRUE;
- a_dest->a_value = a_src->a_value;
- }
- else
- {
- if (params->av_name < 0)
- rt_error ("Parameter type mismatch parameter %s.",
- a_names[-params->av_name]);
- else
- rt_error ("Parameter type mismatch, parameter %s.",
- v_names[params->av_name]);
- params++;
- }
- pop ();
- }
- else
- {
- rt_error ("Parameter number mismatch");
- return;
- }
- params = params->next;
- }
- if (params != NULL)
- rt_error ("Parameter number mismatch");
-}
diff --git a/gnu/usr.bin/bc/util.c b/gnu/usr.bin/bc/util.c
deleted file mode 100644
index fe7315a..0000000
--- a/gnu/usr.bin/bc/util.c
+++ /dev/null
@@ -1,820 +0,0 @@
-/* util.c: Utility routines for bc. */
-
-/* This file is part of bc written for MINIX.
- Copyright (C) 1991, 1992, 1993, 1994 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 of the License , 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; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- You may contact the author by:
- e-mail: phil@cs.wwu.edu
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
-
-
-#include "bcdefs.h"
-#ifndef VARARGS
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include "global.h"
-#include "proto.h"
-
-
-/* strcopyof mallocs new memory and copies a string to to the new
- memory. */
-
-char *
-strcopyof (str)
- char *str;
-{
- char *temp;
-
- temp = (char *) bc_malloc (strlen (str)+1);
- return (strcpy (temp,str));
-}
-
-
-/* nextarg adds another value to the list of arguments. */
-
-arg_list *
-nextarg (args, val)
- arg_list *args;
- int val;
-{ arg_list *temp;
-
- temp = (arg_list *) bc_malloc (sizeof (arg_list));
- temp->av_name = val;
- temp->next = args;
-
- return (temp);
-}
-
-
-/* For generate, we must produce a string in the form
- "val,val,...,val". We also need a couple of static variables
- for retaining old generated strings. It also uses a recursive
- function that builds the string. */
-
-static char *arglist1 = NULL, *arglist2 = NULL;
-
-
-/* make_arg_str does the actual construction of the argument string.
- ARGS is the pointer to the list and LEN is the maximum number of
- characters needed. 1 char is the minimum needed.
- */
-
-_PROTOTYPE (static char *make_arg_str, (arg_list *args, int len));
-
-static char *
-make_arg_str (args, len)
- arg_list *args;
- int len;
-{
- char *temp;
- char sval[20];
-
- /* Recursive call. */
- if (args != NULL)
- temp = make_arg_str (args->next, len+11);
- else
- {
- temp = (char *) bc_malloc (len);
- *temp = 0;
- return temp;
- }
-
- /* Add the current number to the end of the string. */
- if (len != 1)
- sprintf (sval, "%d,", args->av_name);
- else
- sprintf (sval, "%d", args->av_name);
- temp = strcat (temp, sval);
- return (temp);
-}
-
-char *
-arg_str (args)
- arg_list *args;
-{
- if (arglist2 != NULL)
- free (arglist2);
- arglist2 = arglist1;
- arglist1 = make_arg_str (args, 1);
- return (arglist1);
-}
-
-char *
-call_str (args)
- arg_list *args;
-{
- arg_list *temp;
- int arg_count;
- int ix;
-
- if (arglist2 != NULL)
- free (arglist2);
- arglist2 = arglist1;
-
- /* Count the number of args and add the 0's and 1's. */
- for (temp = args, arg_count = 0; temp != NULL; temp = temp->next)
- arg_count++;
- arglist1 = (char *) bc_malloc(arg_count+1);
- for (temp = args, ix=0; temp != NULL; temp = temp->next)
- arglist1[ix++] = ( temp->av_name ? '1' : '0');
- arglist1[ix] = 0;
-
- return (arglist1);
-}
-
-/* free_args frees an argument list ARGS. */
-
-void
-free_args (args)
- arg_list *args;
-{
- arg_list *temp;
-
- temp = args;
- while (temp != NULL)
- {
- args = args->next;
- free (temp);
- temp = args;
- }
-}
-
-
-/* Check for valid parameter (PARAMS) and auto (AUTOS) lists.
- There must be no duplicates any where. Also, this is where
- warnings are generated for array parameters. */
-
-void
-check_params ( params, autos )
- arg_list *params, *autos;
-{
- arg_list *tmp1, *tmp2;
-
- /* Check for duplicate parameters. */
- if (params != NULL)
- {
- tmp1 = params;
- while (tmp1 != NULL)
- {
- tmp2 = tmp1->next;
- while (tmp2 != NULL)
- {
- if (tmp2->av_name == tmp1->av_name)
- yyerror ("duplicate parameter names");
- tmp2 = tmp2->next;
- }
- if (tmp1->av_name < 0)
- warn ("Array parameter");
- tmp1 = tmp1->next;
- }
- }
-
- /* Check for duplicate autos. */
- if (autos != NULL)
- {
- tmp1 = autos;
- while (tmp1 != NULL)
- {
- tmp2 = tmp1->next;
- while (tmp2 != NULL)
- {
- if (tmp2->av_name == tmp1->av_name)
- yyerror ("duplicate auto variable names");
- tmp2 = tmp2->next;
- }
- tmp1 = tmp1->next;
- }
- }
-
- /* Check for duplicate between parameters and autos. */
- if ((params != NULL) && (autos != NULL))
- {
- tmp1 = params;
- while (tmp1 != NULL)
- {
- tmp2 = autos;
- while (tmp2 != NULL)
- {
- if (tmp2->av_name == tmp1->av_name)
- yyerror ("variable in both parameter and auto lists");
- tmp2 = tmp2->next;
- }
- tmp1 = tmp1->next;
- }
- }
-}
-
-
-/* Initialize the code generator the parser. */
-
-void
-init_gen ()
-{
- /* Get things ready. */
- break_label = 0;
- continue_label = 0;
- next_label = 1;
- out_count = 2;
- if (compile_only)
- printf ("@i");
- else
- init_load ();
- had_error = FALSE;
- did_gen = FALSE;
-}
-
-
-/* generate code STR for the machine. */
-
-void
-generate (str)
- char *str;
-{
- did_gen = TRUE;
- if (compile_only)
- {
- printf ("%s",str);
- out_count += strlen(str);
- if (out_count > 60)
- {
- printf ("\n");
- out_count = 0;
- }
- }
- else
- load_code (str);
-}
-
-
-/* Execute the current code as loaded. */
-
-void
-run_code()
-{
- /* If no compile errors run the current code. */
- if (!had_error && did_gen)
- {
- if (compile_only)
- {
- printf ("@r\n");
- out_count = 0;
- }
- else
- execute ();
- }
-
- /* Reinitialize the code generation and machine. */
- if (did_gen)
- init_gen();
- else
- had_error = FALSE;
-}
-
-
-/* Output routines: Write a character CH to the standard output.
- It keeps track of the number of characters output and may
- break the output with a "\<cr>". */
-
-void
-out_char (ch)
- char ch;
-{
- if (ch == '\n')
- {
- out_col = 0;
- putchar ('\n');
- }
- else
- {
- out_col++;
- if (out_col == 70)
- {
- putchar ('\\');
- putchar ('\n');
- out_col = 1;
- }
- putchar (ch);
- }
-}
-
-
-/* The following are "Symbol Table" routines for the parser. */
-
-/* find_id returns a pointer to node in TREE that has the correct
- ID. If there is no node in TREE with ID, NULL is returned. */
-
-id_rec *
-find_id (tree, id)
- id_rec *tree;
- char *id;
-{
- int cmp_result;
-
- /* Check for an empty tree. */
- if (tree == NULL)
- return NULL;
-
- /* Recursively search the tree. */
- cmp_result = strcmp (id, tree->id);
- if (cmp_result == 0)
- return tree; /* This is the item. */
- else if (cmp_result < 0)
- return find_id (tree->left, id);
- else
- return find_id (tree->right, id);
-}
-
-
-/* insert_id_rec inserts a NEW_ID rec into the tree whose ROOT is
- provided. insert_id_rec returns TRUE if the tree height from
- ROOT down is increased otherwise it returns FALSE. This is a
- recursive balanced binary tree insertion algorithm. */
-
-int insert_id_rec (root, new_id)
- id_rec **root;
- id_rec *new_id;
-{
- id_rec *A, *B;
-
- /* If root is NULL, this where it is to be inserted. */
- if (*root == NULL)
- {
- *root = new_id;
- new_id->left = NULL;
- new_id->right = NULL;
- new_id->balance = 0;
- return (TRUE);
- }
-
- /* We need to search for a leaf. */
- if (strcmp (new_id->id, (*root)->id) < 0)
- {
- /* Insert it on the left. */
- if (insert_id_rec (&((*root)->left), new_id))
- {
- /* The height increased. */
- (*root)->balance --;
-
- switch ((*root)->balance)
- {
- case 0: /* no height increase. */
- return (FALSE);
- case -1: /* height increase. */
- return (FALSE);
- case -2: /* we need to do a rebalancing act. */
- A = *root;
- B = (*root)->left;
- if (B->balance <= 0)
- {
- /* Single Rotate. */
- A->left = B->right;
- B->right = A;
- *root = B;
- A->balance = 0;
- B->balance = 0;
- }
- else
- {
- /* Double Rotate. */
- *root = B->right;
- B->right = (*root)->left;
- A->left = (*root)->right;
- (*root)->left = B;
- (*root)->right = A;
- switch ((*root)->balance)
- {
- case -1:
- A->balance = 1;
- B->balance = 0;
- break;
- case 0:
- A->balance = 0;
- B->balance = 0;
- break;
- case 1:
- A->balance = 0;
- B->balance = -1;
- break;
- }
- (*root)->balance = 0;
- }
- }
- }
- }
- else
- {
- /* Insert it on the right. */
- if (insert_id_rec (&((*root)->right), new_id))
- {
- /* The height increased. */
- (*root)->balance ++;
- switch ((*root)->balance)
- {
- case 0: /* no height increase. */
- return (FALSE);
- case 1: /* height increase. */
- return (FALSE);
- case 2: /* we need to do a rebalancing act. */
- A = *root;
- B = (*root)->right;
- if (B->balance >= 0)
- {
- /* Single Rotate. */
- A->right = B->left;
- B->left = A;
- *root = B;
- A->balance = 0;
- B->balance = 0;
- }
- else
- {
- /* Double Rotate. */
- *root = B->left;
- B->left = (*root)->right;
- A->right = (*root)->left;
- (*root)->left = A;
- (*root)->right = B;
- switch ((*root)->balance)
- {
- case -1:
- A->balance = 0;
- B->balance = 1;
- break;
- case 0:
- A->balance = 0;
- B->balance = 0;
- break;
- case 1:
- A->balance = -1;
- B->balance = 0;
- break;
- }
- (*root)->balance = 0;
- }
- }
- }
- }
-
- /* If we fall through to here, the tree did not grow in height. */
- return (FALSE);
-}
-
-
-/* Initialize variables for the symbol table tree. */
-
-void
-init_tree()
-{
- name_tree = NULL;
- next_array = 1;
- next_func = 1;
- next_var = 4; /* 0 => ibase, 1 => obase, 2 => scale, 3 => last. */
-}
-
-
-/* Lookup routines for symbol table names. */
-
-int
-lookup (name, namekind)
- char *name;
- int namekind;
-{
- id_rec *id;
-
- /* Warn about non-standard name. */
- if (strlen(name) != 1)
- warn ("multiple letter name - %s", name);
-
- /* Look for the id. */
- id = find_id (name_tree, name);
- if (id == NULL)
- {
- /* We need to make a new item. */
- id = (id_rec *) bc_malloc (sizeof (id_rec));
- id->id = strcopyof (name);
- id->a_name = 0;
- id->f_name = 0;
- id->v_name = 0;
- insert_id_rec (&name_tree, id);
- }
-
- /* Return the correct value. */
- switch (namekind)
- {
-
- case ARRAY:
- /* ARRAY variable numbers are returned as negative numbers. */
- if (id->a_name != 0)
- {
- free (name);
- return (-id->a_name);
- }
- id->a_name = next_array++;
- a_names[id->a_name] = name;
- if (id->a_name < MAX_STORE)
- {
- if (id->a_name >= a_count)
- more_arrays ();
- return (-id->a_name);
- }
- yyerror ("Too many array variables");
- exit (1);
-
- case FUNCT:
- case FUNCTDEF:
- if (id->f_name != 0)
- {
- free(name);
- /* Check to see if we are redefining a math lib function. */
- if (use_math && namekind == FUNCTDEF && id->f_name <= 6)
- id->f_name = next_func++;
- return (id->f_name);
- }
- id->f_name = next_func++;
- f_names[id->f_name] = name;
- if (id->f_name < MAX_STORE)
- {
- if (id->f_name >= f_count)
- more_functions ();
- return (id->f_name);
- }
- yyerror ("Too many functions");
- exit (1);
-
- case SIMPLE:
- if (id->v_name != 0)
- {
- free(name);
- return (id->v_name);
- }
- id->v_name = next_var++;
- v_names[id->v_name - 1] = name;
- if (id->v_name <= MAX_STORE)
- {
- if (id->v_name >= v_count)
- more_variables ();
- return (id->v_name);
- }
- yyerror ("Too many variables");
- exit (1);
- }
-
- return (0); /* NOT_REACHED */
-}
-
-
-/* Print the welcome banner. */
-
-void
-welcome()
-{
- printf ("This is free software with ABSOLUTELY NO WARRANTY.\n");
- printf ("For details type `warranty'. \n");
-}
-
-
-/* Print out the warranty information. */
-
-void
-warranty(prefix)
- char *prefix;
-{
- printf ("\n%s%s\n\n", prefix, BC_VERSION);
- printf ("%s%s%s%s%s%s%s%s%s%s%s",
-" This program is free software; you can redistribute it and/or modify\n",
-" it under the terms of the GNU General Public License as published by\n",
-" the Free Software Foundation; either version 2 of the License , or\n",
-" (at your option) any later version.\n\n",
-" This program is distributed in the hope that it will be useful,\n",
-" but WITHOUT ANY WARRANTY; without even the implied warranty of\n",
-" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n",
-" GNU General Public License for more details.\n\n",
-" You should have received a copy of the GNU General Public License\n",
-" along with this program. If not, write to the Free Software\n",
-" Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.\n\n");
-}
-
-/* Print out the limits of this program. */
-
-void
-limits()
-{
- printf ("BC_BASE_MAX = %d\n", BC_BASE_MAX);
- printf ("BC_DIM_MAX = %ld\n", (long) BC_DIM_MAX);
- printf ("BC_SCALE_MAX = %d\n", BC_SCALE_MAX);
- printf ("BC_STRING_MAX = %d\n", BC_STRING_MAX);
- printf ("MAX Exponent = %ld\n", (long) LONG_MAX);
- printf ("MAX code = %ld\n", (long) BC_MAX_SEGS * (long) BC_SEG_SIZE);
- printf ("multiply digits = %ld\n", (long) LONG_MAX / (long) 90);
- printf ("Number of vars = %ld\n", (long) MAX_STORE);
-#ifdef OLD_EQ_OP
- printf ("Old assignment operatiors are valid. (=-, =+, ...)\n");
-#endif
-}
-
-/* bc_malloc will check the return value so all other places do not
- have to do it! SIZE is the number of types to allocate. */
-
-char *
-bc_malloc (size)
- int size;
-{
- char *ptr;
-
- ptr = (char *) malloc (size);
- if (ptr == NULL)
- out_of_memory ();
-
- return ptr;
-}
-
-
-/* The following routines are error routines for various problems. */
-
-/* Malloc could not get enought memory. */
-
-void
-out_of_memory()
-{
- fprintf (stderr, "Fatal error: Out of memory for malloc.\n");
- exit (1);
-}
-
-
-
-/* The standard yyerror routine. Built with variable number of argumnets. */
-
-#ifndef VARARGS
-#ifdef __STDC__
-void
-yyerror (char *str, ...)
-#else
-void
-yyerror (str)
- char *str;
-#endif
-#else
-void
-yyerror (str, va_alist)
- char *str;
-#endif
-{
- char *name;
- va_list args;
-
-#ifndef VARARGS
- va_start (args, str);
-#else
- va_start (args);
-#endif
- if (is_std_in)
- name = "(standard_in)";
- else
- name = g_argv[optind-1];
- fprintf (stderr,"%s %d: ",name,line_no);
- vfprintf (stderr, str, args);
- fprintf (stderr, "\n");
- had_error = TRUE;
- va_end (args);
-}
-
-
-/* The routine to produce warnings about non-standard features
- found during parsing. */
-
-#ifndef VARARGS
-#ifdef __STDC__
-void
-warn (char *mesg, ...)
-#else
-void
-warn (mesg)
- char *mesg;
-#endif
-#else
-void
-warn (mesg, va_alist)
- char *mesg;
-#endif
-{
- char *name;
- va_list args;
-
-#ifndef VARARGS
- va_start (args, mesg);
-#else
- va_start (args);
-#endif
- if (std_only)
- {
- if (is_std_in)
- name = "(standard_in)";
- else
- name = g_argv[optind-1];
- fprintf (stderr,"%s %d: ",name,line_no);
- vfprintf (stderr, mesg, args);
- fprintf (stderr, "\n");
- had_error = TRUE;
- }
- else
- if (warn_not_std)
- {
- if (is_std_in)
- name = "(standard_in)";
- else
- name = g_argv[optind-1];
- fprintf (stderr,"%s %d: (Warning) ",name,line_no);
- vfprintf (stderr, mesg, args);
- fprintf (stderr, "\n");
- }
- va_end (args);
-}
-
-/* Runtime error will print a message and stop the machine. */
-
-#ifndef VARARGS
-#ifdef __STDC__
-void
-rt_error (char *mesg, ...)
-#else
-void
-rt_error (mesg)
- char *mesg;
-#endif
-#else
-void
-rt_error (mesg, va_alist)
- char *mesg;
-#endif
-{
- va_list args;
- char error_mesg [255];
-
-#ifndef VARARGS
- va_start (args, mesg);
-#else
- va_start (args);
-#endif
- vsprintf (error_mesg, mesg, args);
- va_end (args);
-
- fprintf (stderr, "Runtime error (func=%s, adr=%d): %s\n",
- f_names[pc.pc_func], pc.pc_addr, error_mesg);
- runtime_error = TRUE;
-}
-
-
-/* A runtime warning tells of some action taken by the processor that
- may change the program execution but was not enough of a problem
- to stop the execution. */
-
-#ifndef VARARGS
-#ifdef __STDC__
-void
-rt_warn (char *mesg, ...)
-#else
-void
-rt_warn (mesg)
- char *mesg;
-#endif
-#else
-void
-rt_warn (mesg, va_alist)
- char *mesg;
-#endif
-{
- va_list args;
- char error_mesg [255];
-
-#ifndef VARARGS
- va_start (args, mesg);
-#else
- va_start (args);
-#endif
- vsprintf (error_mesg, mesg, args);
- va_end (args);
-
- fprintf (stderr, "Runtime warning (func=%s, adr=%d): %s\n",
- f_names[pc.pc_func], pc.pc_addr, error_mesg);
-}
diff --git a/gnu/usr.bin/bc/version.h b/gnu/usr.bin/bc/version.h
deleted file mode 100644
index 6bf3ba3..0000000
--- a/gnu/usr.bin/bc/version.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#define BC_VERSION \
-"bc 1.03 (Nov 2, 1994)\nCopyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc."
-
diff --git a/gnu/usr.bin/binutils/gdb/Makefile b/gnu/usr.bin/binutils/gdb/Makefile
deleted file mode 100644
index 90b5696..0000000
--- a/gnu/usr.bin/binutils/gdb/Makefile
+++ /dev/null
@@ -1,117 +0,0 @@
-# $Id: Makefile,v 1.28 1997/05/02 11:22:51 gj Exp $
-
-PROG = gdb
-
-GDBDIR= ${.CURDIR}/../../../../contrib/gdb
-.PATH: ${GDBDIR}/gdb
-.PATH: ${GDBDIR}/opcodes
-
-BINDIR= /usr/bin
-XSRCS = annotate.c blockframe.c breakpoint.c buildsym.c c-lang.c \
- c-typeprint.c c-valprint.c ch-lang.c ch-typeprint.c \
- ch-valprint.c coffread.c command.c complaints.c copying.c \
- corelow.c cp-valprint.c \
- dcache.c dbxread.c demangle.c dwarfread.c \
- elfread.c environ.c eval.c exec.c expprint.c \
- findvar.c fork-child.c freebsd-nat.c gdbtypes.c \
- i386-tdep.c infcmd.c inflow.c infptrace.c \
- infrun.c inftarg.c language.c \
- m2-lang.c m2-typeprint.c m2-valprint.c main.c maint.c \
- mem-break.c minsyms.c objfiles.c parse.c \
- printcmd.c remote.c remote-utils.c solib.c source.c \
- stabsread.c stack.c symfile.c symmisc.c \
- symtab.c target.c thread.c top.c \
- typeprint.c utils.c valarith.c valops.c \
- valprint.c values.c version.c \
- serial.c ser-unix.c ser-tcp.c mdebugread.c \
- c-exp.c f-exp.c m2-exp.c i387-tdep.c \
- kvm-fbsd.c bcache.c \
- corefile.c ch-exp.c f-lang.c scm-exp.c scm-lang.c \
- scm-valprint.c f-typeprint.c f-valprint.c nlmread.c \
- callback.c
-XSRCS+= i386-dis.c dis-buf.c disassemble.c
-SRCS= init.c ${XSRCS}
-
-CFLAGS+= -I$(.CURDIR) -I${DESTDIR}/usr/include/readline -I$(.CURDIR)/../bfd
-# use phkmalloc
-CFLAGS+= -DNO_MMALLOC
-# uncomment the next line if you want to debug gdb
-#CFLAGS+= -g
-
-CLEANFILES+= c-exp.c f-exp.c m2-exp.c init.c y.tab.h init.c-tmp
-#beforedepend: c-exp.c f-exp.c m2-exp.c init.c
-.ORDER: c-exp.c f-exp.c m2-exp.c
-
-.if exists(${.OBJDIR}/../bfd)
-LDADD+= -L${.OBJDIR}/../bfd -lbfd
-DPADD+= ${.OBJDIR}/../bfd/libbfd.a
-.else
-LDADD+= -L${.CURDIR}/../bfd/ -lbfd
-DPADD+= ${.CURDIR}/../bfd/libbfd.a
-.endif
-
-DPADD+= ${LIBREADLINE} ${LIBGNUREGEX}
-LDADD+= -lreadline -lgnuregex
-
-.if exists(${.OBJDIR}/../libiberty)
-LDADD+= -L${.OBJDIR}/../libiberty -liberty
-DPADD+= ${.OBJDIR}/../libiberty/libiberty.a
-.else
-LDADD+= -L${.CURDIR}/../libiberty/ -liberty
-DPADD+= ${.CURDIR}/../libiberty/libiberty.a
-.endif
-
-DPADD+= ${LIBTERMCAP}
-LDADD+= -ltermcap
-
-.if exists(${.OBJDIR}/../libiberty)
-LDADD+= -L${.OBJDIR}/../libiberty -liberty
-DPADD+= ${.OBJDIR}/../libiberty/libiberty.a
-.else
-LDADD+= -L${.CURDIR}/../libiberty/ -liberty
-DPADD+= ${.CURDIR}/../libiberty/libiberty.a
-.endif
-
-# We do this by grepping through sources. If that turns out to be too slow,
-# maybe we could just require every .o file to have an initialization routine
-# of a given name (remote-udi.o -> _initialize_remote_udi, etc.).
-#
-# Formatting conventions: The name of the _initialize_* routines must start
-# in column zero, and must not be inside #if.
-#
-# Note that the set of files with init functions might change, or the names
-# of the functions might change, so this files needs to depend on all the
-# object files that will be linked into gdb.
-
-init.c: ${XSRCS}
- @echo Making ${.TARGET}
- @rm -f init.c-tmp
- @echo '/* Do not modify this file. */' >init.c-tmp
- @echo '/* It is created automatically by the Makefile. */'>>init.c-tmp
- @echo 'void initialize_all_files () {' >>init.c-tmp
- @for i in ${.ALLSRC} ; do \
- filename=`echo $$i | sed \
- -e '/^Onindy.c/d' \
- -e '/^nindy.c/d' \
- -e '/ttyflush.c/d' \
- -e '/xdr_ld.c/d' \
- -e '/xdr_ptrace.c/d' \
- -e '/xdr_rdb.c/d' \
- -e '/udr.c/d' \
- -e '/udip2soc.c/d' \
- -e '/udi2go32.c/d' \
- -e '/version.c/d' \
- -e '/^[a-z0-9A-Z_]*_[SU].c/d' \
- -e '/[a-z0-9A-Z_]*-exp.tab.c/d'` ; \
- case $$filename in \
- "") ;; \
- *) sed <$$filename >>init.c-tmp -n \
- -e '/^_initialize_[a-z_0-9A-Z]* *(/s/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (); \1 ();}/p' ; ;; \
- esac ; \
- done
- @echo '}' >>init.c-tmp
- @mv init.c-tmp ${.TARGET}
-
-.PRECIOUS: init.c
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/binutils/gdb/config.h b/gnu/usr.bin/binutils/gdb/config.h
deleted file mode 100644
index 29f0a3c..0000000
--- a/gnu/usr.bin/binutils/gdb/config.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* config.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if on AIX 3.
- System headers sometimes define this.
- We just want to avoid a redefinition error message. */
-#ifndef _ALL_SOURCE
-/* #undef _ALL_SOURCE */
-#endif
-
-/* Define if the `long double' type works. */
-#define HAVE_LONG_DOUBLE 1
-
-/* Define if you have a working `mmap' system call. */
-#define HAVE_MMAP 1
-
-/* Define if on MINIX. */
-/* #undef _MINIX */
-
-/* Define if the system does not provide POSIX.1 features except
- with this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define if you need to in order for stat and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if fpregset_t type is available. */
-/* #undef HAVE_FPREGSET_T */
-
-/* Define if gregset_t type is available. */
-/* #undef HAVE_GREGSET_T */
-
-/* Define if the "%Lg" format works to print long doubles. */
-#define PRINTF_HAS_LONG_DOUBLE 1
-
-/* Define if you have the getpagesize function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define if you have the sbrk function. */
-#define HAVE_SBRK 1
-
-/* Define if you have the setpgid function. */
-#define HAVE_SETPGID 1
-
-/* Define if you have the valloc function. */
-#define HAVE_VALLOC 1
-
-/* Define if you have the <endian.h> header file. */
-/* #undef HAVE_ENDIAN_H */
-
-/* Define if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <link.h> header file. */
-#define HAVE_LINK_H 1
-
-/* Define if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define if you have the <sgtty.h> header file. */
-#define HAVE_SGTTY_H 1
-
-/* Define if you have the <stddef.h> header file. */
-#define HAVE_STDDEF_H 1
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define if you have the <sys/procfs.h> header file. */
-/* #undef HAVE_SYS_PROCFS_H */
-
-/* Define if you have the <termio.h> header file. */
-/* #undef HAVE_TERMIO_H */
-
-/* Define if you have the <termios.h> header file. */
-#define HAVE_TERMIOS_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the dl library (-ldl). */
-/* #undef HAVE_LIBDL */
diff --git a/gnu/usr.bin/binutils/gdb/gdb.1 b/gnu/usr.bin/binutils/gdb/gdb.1
deleted file mode 100644
index f07c891..0000000
--- a/gnu/usr.bin/binutils/gdb/gdb.1
+++ /dev/null
@@ -1,385 +0,0 @@
-.\" Copyright (c) 1991 Free Software Foundation
-.\" See section COPYING for conditions for redistribution
-.\" $Id: gdb.1,v 1.3 1991/12/13 22:22:58 pesch Exp $
-.TH gdb 1 "4nov1991" "GNU Tools" "GNU Tools"
-.SH NAME
-gdb \- The GNU Debugger
-.SH SYNOPSIS
-.na
-.TP
-.B gdb
-.RB "[\|" \-help "\|]"
-.RB "[\|" \-nx "\|]"
-.RB "[\|" \-q "\|]"
-.RB "[\|" \-batch "\|]"
-.RB "[\|" \-cd=\c
-.I dir\c
-\|]
-.RB "[\|" \-f "\|]"
-.RB "[\|" \-k "\|]"
-.RB "[\|" \-wcore "\|]"
-.RB "[\|" "\-b\ "\c
-.IR bps "\|]"
-.RB "[\|" "\-tty="\c
-.IR dev "\|]"
-.RB "[\|" "\-s "\c
-.I symfile\c
-\&\|]
-.RB "[\|" "\-e "\c
-.I prog\c
-\&\|]
-.RB "[\|" "\-se "\c
-.I prog\c
-\&\|]
-.RB "[\|" "\-c "\c
-.I core\c
-\&\|]
-.RB "[\|" "\-x "\c
-.I cmds\c
-\&\|]
-.RB "[\|" "\-d "\c
-.I dir\c
-\&\|]
-.RB "[\|" \c
-.I prog\c
-.RB "[\|" \c
-.IR core \||\| procID\c
-\&\|]\&\|]
-.ad b
-.SH DESCRIPTION
-The purpose of a debugger such as GDB is to allow you to see what is
-going on ``inside'' another program while it executes\(em\&or what another
-program was doing at the moment it crashed.
-
-GDB can do four main kinds of things (plus other things in support of
-these) to help you catch bugs in the act:
-
-.TP
-\ \ \ \(bu
-Start your program, specifying anything that might affect its behavior.
-
-.TP
-\ \ \ \(bu
-Make your program stop on specified conditions.
-
-.TP
-\ \ \ \(bu
-Examine what has happened, when your program has stopped.
-
-.TP
-\ \ \ \(bu
-Change things in your program, so you can experiment with correcting the
-effects of one bug and go on to learn about another.
-.PP
-
-You can use GDB to debug programs written in C, C++, and Modula-2.
-Fortran support will be added when a GNU Fortran compiler is ready.
-
-GDB is invoked with the shell command \c
-.B gdb\c
-\&. Once started, it reads
-commands from the terminal until you tell it to exit with the GDB
-command \c
-.B quit\c
-\&. You can get online help from \c
-.B gdb\c
-\& itself
-by using the command \c
-.B help\c
-\&.
-
-You can run \c
-.B gdb\c
-\& with no arguments or options; but the most
-usual way to start GDB is with one argument or two, specifying an
-executable program as the argument:
-.sp
-.br
-gdb\ program
-.br
-.sp
-
-You can also start with both an executable program and a core file specified:
-.sp
-.br
-gdb\ program\ core
-.br
-.sp
-
-You can, instead, specify a process ID as a second argument, if you want
-to debug a running process:
-.sp
-.br
-gdb\ program\ 1234
-.br
-.sp
-
-would attach GDB to process \c
-.B 1234\c
-\& (unless you also have a file
-named `\|\c
-.B 1234\c
-\&\|'; GDB does check for a core file first).
-
-Here are some of the most frequently needed GDB commands:
-.TP
-.B break \fR[\|\fIfile\fB:\fR\|]\fIfunction
-\&
-Set a breakpoint at \c
-.I function\c
-\& (in \c
-.I file\c
-\&).
-.TP
-.B run \fR[\|\fIarglist\fR\|]
-Start your program (with \c
-.I arglist\c
-\&, if specified).
-.TP
-.B bt
-Backtrace: display the program stack.
-.TP
-.BI print " expr"\c
-\&
-Display the value of an expression.
-.TP
-.B c
-Continue running your program (after stopping, e.g. at a breakpoint).
-.TP
-.B next
-Execute next program line (after stopping); step \c
-.I over\c
-\& any
-function calls in the line.
-.TP
-.B step
-Execute next program line (after stopping); step \c
-.I into\c
-\& any
-function calls in the line.
-.TP
-.B help \fR[\|\fIname\fR\|]
-Show information about GDB command \c
-.I name\c
-\&, or general information
-about using GDB.
-.TP
-.B quit
-Exit from GDB.
-.PP
-For full details on GDB, see \c
-.I
-Using GDB: A Guide to the GNU Source-Level Debugger\c
-\&, by Richard M. Stallman and Roland H. Pesch. The same text is available online
-as the \c
-.B gdb\c
-\& entry in the \c
-.B info\c
-\& program.
-.SH OPTIONS
-Any arguments other than options specify an executable
-file and core file (or process ID); that is, the first argument
-encountered with no
-associated option flag is equivalent to a `\|\c
-.B \-se\c
-\&\|' option, and the
-second, if any, is equivalent to a `\|\c
-.B \-c\c
-\&\|' option if it's the name of a file. Many options have
-both long and short forms; both are shown here. The long forms are also
-recognized if you truncate them, so long as enough of the option is
-present to be unambiguous. (If you prefer, you can flag option
-arguments with `\|\c
-.B +\c
-\&\|' rather than `\|\c
-.B \-\c
-\&\|', though we illustrate the
-more usual convention.)
-
-All the options and command line arguments you give are processed
-in sequential order. The order makes a difference when the
-`\|\c
-.B \-x\c
-\&\|' option is used.
-
-.TP
-.B \-help
-.TP
-.B \-h
-List all options, with brief explanations.
-
-.TP
-.BI "\-symbols=" "file"\c
-.TP
-.BI "\-s " "file"\c
-\&
-Read symbol table from file \c
-.I file\c
-\&.
-
-.TP
-.BI "\-exec=" "file"\c
-.TP
-.BI "\-e " "file"\c
-\&
-Use file \c
-.I file\c
-\& as the executable file to execute when
-appropriate, and for examining pure data in conjunction with a core
-dump.
-
-.TP
-.BI "\-se=" "file"\c
-\&
-Read symbol table from file \c
-.I file\c
-\& and use it as the executable
-file.
-
-.TP
-.BI "\-core=" "file"\c
-.TP
-.BI "\-c " "file"\c
-\&
-Use file \c
-.I file\c
-\& as a core dump to examine.
-
-.TP
-.BI "\-command=" "file"\c
-.TP
-.BI "\-x " "file"\c
-\&
-Execute GDB commands from file \c
-.I file\c
-\&.
-
-.TP
-.BI "\-directory=" "directory"\c
-.TP
-.BI "\-d " "directory"\c
-\&
-Add \c
-.I directory\c
-\& to the path to search for source files.
-.PP
-
-.TP
-.B \-nx
-.TP
-.B \-n
-Do not execute commands from any `\|\c
-.B .gdbinit\c
-\&\|' initialization files.
-Normally, the commands in these files are executed after all the
-command options and arguments have been processed.
-
-
-.TP
-.B \-quiet
-.TP
-.B \-q
-``Quiet''. Do not print the introductory and copyright messages. These
-messages are also suppressed in batch mode.
-
-.TP
-.B \-batch
-Run in batch mode. Exit with status \c
-.B 0\c
-\& after processing all the command
-files specified with `\|\c
-.B \-x\c
-\&\|' (and `\|\c
-.B .gdbinit\c
-\&\|', if not inhibited).
-Exit with nonzero status if an error occurs in executing the GDB
-commands in the command files.
-
-Batch mode may be useful for running GDB as a filter, for example to
-download and run a program on another computer; in order to make this
-more useful, the message
-.sp
-.br
-Program\ exited\ normally.
-.br
-.sp
-
-(which is ordinarily issued whenever a program running under GDB control
-terminates) is not issued when running in batch mode.
-
-.TP
-.BI "\-cd=" "directory"\c
-\&
-Run GDB using \c
-.I directory\c
-\& as its working directory,
-instead of the current directory.
-
-.TP
-.B \-fullname
-.TP
-.B \-f
-Emacs sets this option when it runs GDB as a subprocess. It tells GDB
-to output the full file name and line number in a standard,
-recognizable fashion each time a stack frame is displayed (which
-includes each time the program stops). This recognizable format looks
-like two `\|\c
-.B \032\c
-\&\|' characters, followed by the file name, line number
-and character position separated by colons, and a newline. The
-Emacs-to-GDB interface program uses the two `\|\c
-.B \032\c
-\&\|' characters as
-a signal to display the source code for the frame.
-
-.TP
-.B \-kernel
-.TP
-.B \-k
-Use gdb in kernel debugging mode. The prompt is set to ``(kgdb)''.
-
-.TP
-.B \-wcore
-This option may only be used in kernel debugging mode while
-debugging a ``live'' kernel and makes the corefile (/dev/mem)
-writable.
-
-.TP
-.BI "\-b " "bps"\c
-\&
-Set the line speed (baud rate or bits per second) of any serial
-interface used by GDB for remote debugging.
-
-.TP
-.BI "\-tty=" "device"\c
-\&
-Run using \c
-.I device\c
-\& for your program's standard input and output.
-.PP
-
-.SH "SEE ALSO"
-.RB "`\|" gdb "\|'"
-entry in
-.B info\c
-\&;
-.I
-Using GDB: A Guide to the GNU Source-Level Debugger\c
-, Richard M. Stallman and Roland H. Pesch, July 1991.
-.SH COPYING
-Copyright (c) 1991 Free Software Foundation, Inc.
-.PP
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-.PP
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-.PP
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
diff --git a/gnu/usr.bin/binutils/gdb/i386/freebsd-nat.c b/gnu/usr.bin/binutils/gdb/i386/freebsd-nat.c
deleted file mode 100644
index e73f402..0000000
--- a/gnu/usr.bin/binutils/gdb/i386/freebsd-nat.c
+++ /dev/null
@@ -1,401 +0,0 @@
-/* Native-dependent code for BSD Unix running on i386's, for GDB.
- Copyright 1988, 1989, 1991, 1992, 1994, 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-
-#include <sys/types.h>
-#include <sys/ptrace.h>
-#include <machine/reg.h>
-#include <machine/frame.h>
-#include <sys/param.h>
-#include <sys/user.h>
-#include "gdbcore.h"
-#include "value.h"
-#include "inferior.h"
-
-/* this table must line up with REGISTER_NAMES in tm-i386v.h */
-/* symbols like 'tEAX' come from <machine/reg.h> */
-static int tregmap[] =
-{
- tEAX, tECX, tEDX, tEBX,
- tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS,
- tDS, tES, tFS, tGS,
-};
-
-static struct save87 pcb_savefpu;
-
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- struct reg inferior_registers; /* ptrace order, not gcc/gdb order */
- int r;
-
- ptrace (PT_GETREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_registers, 0);
-
- for (r = 0; r < NUM_REGS; r++)
- memcpy (&registers[REGISTER_BYTE (r)], ((int *)&inferior_registers) + tregmap[r], 4);
-
- registers_fetched ();
-}
-
-void
-store_inferior_registers (regno)
- int regno;
-{
- struct reg inferior_registers; /* ptrace order, not gcc/gdb order */
- int r;
-
- for (r = 0; r < NUM_REGS; r++)
- memcpy (((int *)&inferior_registers) + tregmap[r], &registers[REGISTER_BYTE (r)], 4);
-
- ptrace (PT_SETREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_registers, 0);
-}
-
-/* Extract the register values out of the core file and store
- them where `read_register' will find them.
- Extract the floating point state out of the core file and store
- it where `float_info' will find it.
-
- CORE_REG_SECT points to the register values themselves, read into memory.
- CORE_REG_SIZE is the size of that area.
- WHICH says which set of registers we are handling (0 = int, 2 = float
- on machines where they are discontiguous).
- REG_ADDR is the offset from u.u_ar0 to the register values relative to
- core_reg_sect. This is used with old-fashioned core files to
- locate the registers in a large upage-plus-stack ".reg" section.
- Original upage address X is at location core_reg_sect+x+reg_addr.
- */
-
-static void
-fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which;
- CORE_ADDR reg_addr;
-{
- register int regno;
- register int cregno;
- register int addr;
- int bad_reg = -1;
- int offset;
- struct user *tmp_uaddr;
-
- /*
- * First get virtual address of user structure. Then calculate offset.
- */
- memcpy(&tmp_uaddr,
- &((struct user *) core_reg_sect)->u_kproc.kp_proc.p_addr,
- sizeof(tmp_uaddr));
- offset = -reg_addr - (int) tmp_uaddr;
-
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- cregno = tregmap[regno];
- if (cregno == tFS)
- addr = offsetof (struct user, u_pcb) + offsetof (struct pcb, pcb_fs);
- else if (cregno == tGS)
- addr = offsetof (struct user, u_pcb) + offsetof (struct pcb, pcb_gs);
- else
- addr = offset + 4 * cregno;
- if (addr < 0 || addr >= core_reg_size)
- {
- if (bad_reg < 0)
- bad_reg = regno;
- }
- else
- {
- supply_register (regno, core_reg_sect + addr);
- }
- }
- if (bad_reg >= 0)
- {
- error ("Register %s not found in core file.", reg_names[bad_reg]);
- }
-
- addr = offsetof (struct user, u_pcb) + offsetof (struct pcb, pcb_savefpu);
- memcpy (&pcb_savefpu, core_reg_sect + addr, sizeof pcb_savefpu);
-}
-
-#ifdef FLOAT_INFO
-#include "expression.h"
-#include "language.h" /* for local_hex_string */
-#include "floatformat.h"
-
-#include <sys/param.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#include <a.out.h>
-
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/uio.h>
-#define curpcb Xcurpcb /* XXX avoid leaking declaration from pcb.h */
-#include <sys/user.h>
-#undef curpcb
-#include <sys/file.h>
-#include "gdb_stat.h"
-#include <sys/ptrace.h>
-
-extern void print_387_control_word (); /* i387-tdep.h */
-extern void print_387_status_word ();
-
-#define fpstate save87
-#define U_FPSTATE(u) u.u_pcb.pcb_savefpu
-
-static void
-i387_to_double (from, to)
- char *from;
- char *to;
-{
- long *lp;
- /* push extended mode on 387 stack, then pop in double mode
- *
- * first, set exception masks so no error is generated -
- * number will be rounded to inf or 0, if necessary
- */
- asm ("pushl %eax"); /* grab a stack slot */
- asm ("fstcw (%esp)"); /* get 387 control word */
- asm ("movl (%esp),%eax"); /* save old value */
- asm ("orl $0x3f,%eax"); /* mask all exceptions */
- asm ("pushl %eax");
- asm ("fldcw (%esp)"); /* load new value into 387 */
-
- asm ("movl 8(%ebp),%eax");
- asm ("fldt (%eax)"); /* push extended number on 387 stack */
- asm ("fwait");
- asm ("movl 12(%ebp),%eax");
- asm ("fstpl (%eax)"); /* pop double */
- asm ("fwait");
-
- asm ("popl %eax"); /* flush modified control word */
- asm ("fnclex"); /* clear exceptions */
- asm ("fldcw (%esp)"); /* restore original control word */
- asm ("popl %eax"); /* flush saved copy */
-}
-
-struct env387
-{
- unsigned short control;
- unsigned short r0;
- unsigned short status;
- unsigned short r1;
- unsigned short tag;
- unsigned short r2;
- unsigned long eip;
- unsigned short code_seg;
- unsigned short opcode;
- unsigned long operand;
- unsigned short operand_seg;
- unsigned short r3;
- unsigned char regs[8][10];
-};
-
-static void
-print_387_status (status, ep)
- unsigned short status;
- struct env387 *ep;
-{
- int i;
- int bothstatus;
- int top;
- int fpreg;
-
- bothstatus = ((status != 0) && (ep->status != 0));
- if (status != 0)
- {
- if (bothstatus)
- printf_unfiltered ("u: ");
- print_387_status_word ((unsigned int)status);
- }
-
- if (ep->status != 0)
- {
- if (bothstatus)
- printf_unfiltered ("e: ");
- print_387_status_word ((unsigned int)ep->status);
- }
-
- print_387_control_word ((unsigned int)ep->control);
- printf_unfiltered ("last instruction: ");
- printf_unfiltered ("opcode %s; ", local_hex_string(ep->opcode));
- printf_unfiltered ("pc %s:", local_hex_string(ep->code_seg));
- printf_unfiltered ("%s; ", local_hex_string(ep->eip));
- printf_unfiltered ("operand %s", local_hex_string(ep->operand_seg));
- printf_unfiltered (":%s\n", local_hex_string(ep->operand));
-
- top = (ep->status >> 11) & 7;
-
- printf_unfiltered (" regno tag msb lsb value\n");
- for (fpreg = 7; fpreg >= 0; fpreg--)
- {
- int exp;
- int mantissa_or;
- int normal;
- char *sign;
- int st_regno;
- unsigned short *usregs;
- double val;
-
- /* The physical regno `fpreg' is only relevant as an index into the
- * tag word. Logical `%st' numbers are required for indexing ep->regs.
- */
- st_regno = (fpreg + 8 - top) & 7;
-
- printf_unfiltered ("%%st(%d) %s ", st_regno, fpreg == top ? "=>" : " ");
-
- switch ((ep->tag >> (fpreg * 2)) & 3)
- {
- case 0: printf_unfiltered ("valid "); break;
- case 1: printf_unfiltered ("zero "); break;
- case 2: printf_unfiltered ("trap "); break;
- case 3: printf_unfiltered ("empty "); break;
- }
- for (i = 9; i >= 0; i--)
- printf_unfiltered ("%02x", ep->regs[st_regno][i]);
-
- printf_unfiltered (" ");
-
- /*
- * Handle weird cases better than floatformat_to_double () and
- * printf ().
- */
- usregs = (unsigned short *) ep->regs[st_regno];
- sign = usregs[4] & 0x8000 ? "-" : "";
- exp = usregs[4] & 0x7fff;
- normal = usregs[3] & 0x8000;
- mantissa_or = usregs[0] | usregs[1] | usregs[2] | (usregs[3] & 0x7fff);
- if (exp == 0)
- {
- if (normal)
- printf_unfiltered ("Pseudo Denormal (0 as a double)");
- else if (mantissa_or == 0)
- printf_unfiltered ("%s0", sign);
- else
- printf_unfiltered ("Denormal (0 as a double)");
- }
- else if (exp == 0x7fff)
- {
- if (!normal)
- printf_unfiltered ("Pseudo ");
- if (mantissa_or == 0)
- printf_unfiltered ("%sInf", sign);
- else
- printf_unfiltered ("%s NaN",
- usregs[3] & 0x4000 ? "Quiet" : "Signaling");
- if (!normal)
- printf_unfiltered (" (NaN)");
- }
- else if (!normal)
- printf_unfiltered ("Unnormal (NaN)");
- else
- {
-#if 0
- /* Use this we stop trapping on overflow. */
- floatformat_to_double(&floatformat_i387_ext,
- (char *) ep->regs[st_regno], &val);
-#else
- i387_to_double((char *) ep->regs[st_regno], (char *) &val);
-#endif
- printf_unfiltered ("%g", val);
- }
- printf_unfiltered ("\n");
- }
-}
-
-void
-i386_float_info ()
-{
- struct user u; /* just for address computations */
- int i;
- /* fpstate defined in <sys/user.h> */
- struct fpstate *fpstatep;
- char buf[sizeof (struct fpstate) + 2 * sizeof (int)];
- unsigned int uaddr;
- char fpvalid;
- unsigned int rounded_addr;
- unsigned int rounded_size;
- /*extern int corechan;*/
- int skip;
- extern int inferior_pid;
-
- uaddr = (char *)&U_FPSTATE(u) - (char *)&u;
- if (inferior_pid)
- {
- int *ip;
-
- rounded_addr = uaddr & -sizeof (int);
- rounded_size = (((uaddr + sizeof (struct fpstate)) - uaddr) +
- sizeof (int) - 1) / sizeof (int);
- skip = uaddr - rounded_addr;
-
- ip = (int *)buf;
- for (i = 0; i < rounded_size; i++)
- {
- *ip++ = ptrace (PT_READ_U, inferior_pid, (caddr_t)rounded_addr, 0);
- rounded_addr += sizeof (int);
- }
- fpstatep = (struct fpstate *)(buf + skip);
- }
- else
- fpstatep = &pcb_savefpu;
-
- print_387_status (fpstatep->sv_ex_sw, (struct env387 *)fpstatep);
-}
-#endif /* FLOAT_INFO */
-
-int
-kernel_u_size ()
-{
- return (sizeof (struct user));
-}
-
-#ifdef SETUP_ARBITRARY_FRAME
-#include "frame.h"
-struct frame_info *
-setup_arbitrary_frame (argc, argv)
- int argc;
- CORE_ADDR *argv;
-{
- if (argc != 2)
- error ("i386 frame specifications require two arguments: sp and pc");
-
- return create_new_frame (argv[0], argv[1]);
-}
-#endif /* SETUP_ARBITRARY_FRAME */
-
-/* Register that we are able to handle aout (trad-core) file formats. */
-
-static struct core_fns aout_core_fns =
-{
- bfd_target_unknown_flavour,
- fetch_core_registers,
- NULL
-};
-
-void
-_initialize_core_aout ()
-{
- add_core_fns (&aout_core_fns);
-}
diff --git a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c
deleted file mode 100644
index 5f93334..0000000
--- a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c
+++ /dev/null
@@ -1,970 +0,0 @@
-/* Live and postmortem kernel debugging functions for FreeBSD.
- Copyright 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/sysctl.h>
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include "frame.h" /* required by inferior.h */
-#include "inferior.h"
-#include "symtab.h"
-#include "command.h"
-#include "bfd.h"
-#include "target.h"
-#include "gdbcore.h"
-#include <sys/stat.h>
-#include <unistd.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-
-#include <machine/vmparam.h>
-#include <machine/pcb.h>
-#include <machine/tss.h>
-#include <machine/frame.h>
-
-static void kcore_files_info PARAMS ((struct target_ops *));
-
-static void kcore_close PARAMS ((int));
-
-static void get_kcore_registers PARAMS ((int));
-
-static int kcore_xfer_kmem PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
-
-static int xfer_umem PARAMS ((CORE_ADDR, char *, int, int));
-
-static CORE_ADDR ksym_lookup PARAMS ((const char *));
-
-static int read_pcb PARAMS ((int, CORE_ADDR));
-
-static struct proc * curProc PARAMS ((void));
-
-static int set_proc_context PARAMS ((CORE_ADDR paddr));
-
-static void kcore_open PARAMS ((char *filename, int from_tty));
-
-static void kcore_detach PARAMS ((char *args, int from_tty));
-
-static void set_proc_cmd PARAMS ((char *arg, int from_tty));
-
-static CORE_ADDR kvtophys PARAMS ((int, CORE_ADDR));
-
-static int physrd PARAMS ((int, u_int, char*, int));
-
-static int kvm_open PARAMS ((const char *efile, char *cfile, char *sfile,
- int perm, char *errout));
-
-static int kvm_close PARAMS ((int fd));
-
-static int kvm_write PARAMS ((int core_kd, CORE_ADDR memaddr,
- char *myaddr, int len));
-
-static int kvm_read PARAMS ((int core_kd, CORE_ADDR memaddr,
- char *myaddr, int len));
-
-static int kvm_uread PARAMS ((int core_kd, struct proc *p,
- CORE_ADDR memaddr, char *myaddr,
- int len));
-
-static int kernel_core_file_hook PARAMS ((int fd, CORE_ADDR addr,
- char *buf, int len));
-
-static struct kinfo_proc * kvm_getprocs PARAMS ((int cfd, int op,
- CORE_ADDR proc, int *cnt));
-
-extern struct target_ops kcore_ops; /* Forward decl */
-
-/* Non-zero means we are debugging a kernel core file */
-int kernel_debugging = 0;
-int kernel_writablecore = 0;
-
-static char *core_file;
-static int core_kd = -1;
-static struct proc *cur_proc;
-static CORE_ADDR kernel_start;
-
-/*
- * Read the "thing" at kernel address 'addr' into the space pointed to
- * by point. The length of the "thing" is determined by the type of p.
- * Result is non-zero if transfer fails.
- */
-#define kvread(addr, p) \
- (target_read_memory ((CORE_ADDR)(addr), (char *)(p), sizeof(*(p))))
-
-
-
-/*
- * The following is FreeBSD-specific hackery to decode special frames
- * and elide the assembly-language stub. This could be made faster by
- * defining a frame_type field in the machine-dependent frame information,
- * but we don't think that's too important right now.
- */
-enum frametype { tf_normal, tf_trap, tf_interrupt, tf_syscall };
-
-CORE_ADDR
-fbsd_kern_frame_saved_pc (fr)
-struct frame_info *fr;
-{
- struct minimal_symbol *sym;
- CORE_ADDR this_saved_pc;
- enum frametype frametype;
-
- this_saved_pc = read_memory_integer (fr->frame + 4, 4);
- sym = lookup_minimal_symbol_by_pc (this_saved_pc);
- frametype = tf_normal;
- if (sym != NULL) {
- if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0)
- frametype = tf_trap;
- else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0)
- frametype = tf_interrupt;
- else if (strcmp (SYMBOL_NAME(sym), "Xsyscall") == 0)
- frametype = tf_syscall;
- }
-
- switch (frametype) {
- case tf_normal:
- return (this_saved_pc);
-
-#define oEIP offsetof(struct trapframe, tf_eip)
-
- case tf_trap:
- return (read_memory_integer (fr->frame + 8 + oEIP, 4));
-
- case tf_interrupt:
- return (read_memory_integer (fr->frame + 16 + oEIP, 4));
-
- case tf_syscall:
- return (read_memory_integer (fr->frame + 8 + oEIP, 4));
-#undef oEIP
- }
-}
-
-CORE_ADDR
-fbsd_kern_frame_chain (fr)
-struct frame_info *fr;
-{
- struct minimal_symbol *sym;
- CORE_ADDR this_saved_pc;
- enum frametype frametype;
-
- this_saved_pc = read_memory_integer (fr->frame + 4, 4);
- sym = lookup_minimal_symbol_by_pc (this_saved_pc);
- frametype = tf_normal;
- if (sym != NULL) {
- if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0)
- frametype = tf_trap;
- else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0)
- frametype = tf_interrupt;
- else if (strcmp (SYMBOL_NAME(sym), "_Xsyscall") == 0)
- frametype = tf_syscall;
- }
-
- switch (frametype) {
- case tf_normal:
- return (read_memory_integer (fr->frame, 4));
-
-#define oEBP offsetof(struct trapframe, tf_ebp)
-
- case tf_trap:
- return (read_memory_integer (fr->frame + 8 + oEBP, 4));
-
- case tf_interrupt:
- return (read_memory_integer (fr->frame + 16 + oEBP, 4));
-
- case tf_syscall:
- return (read_memory_integer (fr->frame + 8 + oEBP, 4));
-#undef oEBP
- }
-}
-
-static CORE_ADDR
-ksym_lookup (name)
-const char *name;
-{
- struct minimal_symbol *sym;
-
- sym = lookup_minimal_symbol (name, NULL, NULL);
- if (sym == NULL)
- error ("kernel symbol `%s' not found.", name);
-
- return SYMBOL_VALUE_ADDRESS (sym);
-}
-
-static struct proc *
-curProc ()
-{
- struct proc *p;
- CORE_ADDR addr = ksym_lookup ("curproc");
-
- if (kvread (addr, &p))
- error ("cannot read proc pointer at %x\n", addr);
- return p;
-}
-
-/*
- * Set the process context to that of the proc structure at
- * system address paddr.
- */
-static int
-set_proc_context (paddr)
- CORE_ADDR paddr;
-{
- struct proc p;
-
- if (paddr < kernel_start)
- return (1);
-
- cur_proc = (struct proc *)paddr;
-#ifdef notyet
- set_kernel_boundaries (cur_proc);
-#endif
-
- /* Fetch all registers from core file */
- target_fetch_registers (-1);
-
- /* Now, set up the frame cache, and print the top of stack */
- flush_cached_frames ();
- set_current_frame (create_new_frame (read_fp (), read_pc ()));
- select_frame (get_current_frame (), 0);
- return (0);
-}
-
-/* Discard all vestiges of any previous core file
- and mark data and stack spaces as empty. */
-
-/* ARGSUSED */
-static void
-kcore_close (quitting)
- int quitting;
-{
- inferior_pid = 0; /* Avoid confusion from thread stuff */
-
- if (core_kd)
- {
- kvm_close (core_kd);
- free (core_file);
- core_file = NULL;
- core_kd = -1;
- }
-}
-
-/* This routine opens and sets up the core file bfd */
-
-static void
-kcore_open (filename, from_tty)
- char *filename;
- int from_tty;
-{
- const char *p;
- struct cleanup *old_chain;
- char buf[256], *cp;
- int ontop;
- CORE_ADDR addr;
- struct pcb pcb;
-
- target_preopen (from_tty);
-
- unpush_target (&kcore_ops);
-
- if (!filename)
- {
- /*error (core_kd?*/
- error ( (core_kd >= 0)?
- "No core file specified. (Use `detach' to stop debugging a core file.)"
- : "No core file specified.");
- }
-
- filename = tilde_expand (filename);
- if (filename[0] != '/')
- {
- cp = concat (current_directory, "/", filename, NULL);
- free (filename);
- filename = cp;
- }
-
- old_chain = make_cleanup (free, filename);
-
- /*
- * gdb doesn't really do anything if the exec-file couldn't
- * be opened (in that case exec_bfd is NULL). Usually that's
- * no big deal, but kvm_open needs the exec-file's name,
- * which results in dereferencing a NULL pointer, a real NO-NO !
- * So, check here if the open of the exec-file succeeded.
- */
- if (exec_bfd == NULL) /* the open failed */
- error ("kgdb could not open the exec-file, please check the name you used !");
-
- core_kd = kvm_open (exec_bfd->filename, filename, NULL,
- kernel_writablecore? O_RDWR : O_RDONLY, "kgdb: ");
- if (core_kd < 0)
- perror_with_name (filename);
-
- /* Looks semi-reasonable. Toss the old core file and work on the new. */
-
- discard_cleanups (old_chain); /* Don't free filename any more */
- core_file = filename;
- ontop = !push_target (&kcore_ops);
-
- kernel_start = bfd_get_start_address (exec_bfd); /* XXX */
-
- /* print out the panic string if there is one */
- if (kvread (ksym_lookup ("panicstr"), &addr) == 0
- && addr != 0
- && target_read_memory (addr, buf, sizeof (buf)) == 0)
- {
- for (cp = buf; cp < &buf[sizeof (buf)] && *cp; cp++)
- if (!isascii (*cp) || (!isprint (*cp) && !isspace (*cp)))
- *cp = '?';
- *cp = '\0';
- if (buf[0] != '\0')
- printf ("panicstr: %s\n", buf);
-
- printf ("panic messages:\n---\n");
- snprintf (buf, sizeof buf,
- "/sbin/dmesg -M %s | \
- /usr/bin/awk '/^(panic:|Fatal trap) / { printing = 1 } \
- { if (printing) print $0 }'",
- filename);
- system (buf);
- printf ("---\n");
- }
-
- if (!ontop)
- {
- warning ("you won't be able to access this core file until you terminate\n\
-your %s; do ``info files''", target_longname);
- return;
- }
-
- /* we may need this later */
- cur_proc = (struct proc *)curProc ();
- /* Now, set up the frame cache, and print the top of stack */
- flush_cached_frames ();
- set_current_frame (create_new_frame (read_fp (), read_pc ()));
- select_frame (get_current_frame (), 0);
- print_stack_frame (selected_frame, selected_frame_level, 1);
-}
-
-static void
-kcore_detach (args, from_tty)
- char *args;
- int from_tty;
-{
- if (args)
- error ("Too many arguments");
- unpush_target (&kcore_ops);
- reinit_frame_cache ();
- if (from_tty)
- printf_filtered ("No kernel core file now.\n");
-}
-
-/* Get the registers out of a core file. This is the machine-
- independent part. Fetch_core_registers is the machine-dependent
- part, typically implemented in the xm-file for each architecture. */
-
-/* We just get all the registers, so we don't use regno. */
-/* ARGSUSED */
-static void
-get_kcore_registers (regno)
- int regno;
-{
- struct user *uaddr;
-
- /* find the pcb for the current process */
- if (kvread (&cur_proc->p_addr, &uaddr))
- error ("cannot read u area ptr for proc at %#x", cur_proc);
- if (read_pcb (core_kd, (CORE_ADDR)&uaddr->u_pcb) < 0)
- error ("cannot read pcb at %#x", &uaddr->u_pcb);
-}
-
-static void
-kcore_files_info (t)
- struct target_ops *t;
-{
- printf ("\t`%s'\n", core_file);
-}
-
-static int
-kcore_xfer_kmem (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target;
-{
- int n;
-
- if (!memaddr)
- return (0);
-
- if (memaddr < kernel_start)
- return xfer_umem (memaddr, myaddr, len, write);
-
- n = write ?
- kvm_write (core_kd, memaddr, myaddr, len) :
- kvm_read (core_kd, memaddr, myaddr, len) ;
-
- if (n < 0)
- return 0;
- return n;
-}
-
-static int
-xfer_umem (memaddr, myaddr, len, write)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write; /* ignored */
-{
- int n;
- struct proc proc;
-
- if (kvread (cur_proc, &proc))
- error ("cannot read proc at %#x", cur_proc);
- n = kvm_uread (core_kd, &proc, memaddr, myaddr, len) ;
-
- if (n < 0)
- return 0;
- return n;
-}
-
-static void
-set_proc_cmd (arg, from_tty)
- char *arg;
- int from_tty;
-{
- CORE_ADDR paddr;
- struct kinfo_proc *kp;
- int cnt = 0;
-
- if (!arg)
- error_no_arg ("proc address for new current process");
- if (!kernel_debugging)
- error ("not debugging kernel");
-
- paddr = (CORE_ADDR)parse_and_eval_address (arg);
- /* assume it's a proc pointer if it's in the kernel */
- if (paddr >= kernel_start) {
- if (set_proc_context(paddr))
- error("invalid proc address");
- } else {
- kp = kvm_getprocs(core_kd, KERN_PROC_PID, paddr, &cnt);
- if (!cnt)
- error("invalid pid");
- if (set_proc_context((CORE_ADDR)kp->kp_eproc.e_paddr))
- error("invalid proc address");
- }
-}
-
-
-
-#define KERNOFF ((unsigned)KERNBASE)
-#define INKERNEL(x) ((x) >= KERNOFF)
-
-static CORE_ADDR sbr;
-static CORE_ADDR curpcb;
-static CORE_ADDR kstack;
-static int found_pcb;
-static int devmem;
-static int kfd;
-static struct pcb pcb;
-
-/* substitutes for the stuff in libkvm which doesn't work */
-/* most of this was taken from the old kgdb */
-
-/* we don't need all this stuff, but the call should look the same */
-
-static int
-kvm_open (efile, cfile, sfile, perm, errout)
- const char *efile;
- char *cfile;
- char *sfile; /* makes this kvm_open more compatible to the one in libkvm */
- int perm;
- char *errout; /* makes this kvm_open more compatible to the one in libkvm */
-{
- struct stat stb;
- CORE_ADDR addr;
- int cfd;
- struct i386tss cts;
-
- if ((cfd = open (cfile, perm, 0)) < 0)
- return (cfd);
-
- fstat (cfd, &stb);
- if ((stb.st_mode & S_IFMT) == S_IFCHR
- && stb.st_rdev == makedev (2, 0))
- {
- devmem = 1;
- kfd = open ("/dev/kmem", perm, 0);
- }
-
- physrd (cfd, ksym_lookup ("IdlePTD") - KERNOFF, (char*)&sbr, sizeof sbr);
- printf ("IdlePTD %x\n", sbr);
- curpcb = ksym_lookup ("curpcb") - KERNOFF;
- physrd (cfd, curpcb, (char*)&curpcb, sizeof curpcb);
- physrd (cfd, ksym_lookup ("common_tss") - KERNOFF, (char*)&cts, sizeof cts);
- kstack = cts.tss_ksp;
-
- found_pcb = 1; /* for vtophys */
- if (!devmem)
- read_pcb (cfd, ksym_lookup ("dumppcb") - KERNOFF);
- else
- read_pcb (cfd, kvtophys (cfd, kstack));
-
- return (cfd);
-}
-
-static int
-kvm_close (fd)
- int fd;
-{
- return (close (fd));
-}
-
-static int
-kvm_write (core_kd, memaddr, myaddr, len)
- int core_kd;
- CORE_ADDR memaddr;
- char *myaddr;
-{
- int cc;
-
- if (devmem)
- {
- if (kfd > 0)
- {
- /*
- * Just like kvm_read, only we write.
- */
- errno = 0;
- if (lseek (kfd, (off_t)memaddr, 0) < 0
- && errno != 0)
- {
- error ("kvm_write:invalid address (%x)", memaddr);
- return (0);
- }
- cc = write (kfd, myaddr, len);
- if (cc < 0)
- {
- error ("kvm_write:write failed");
- return (0);
- }
- else if (cc < len)
- error ("kvm_write:short write");
- return (cc);
- }
- else
- return (0);
- }
- else
- {
- printf ("kvm_write not implemented for dead kernels\n");
- return (0);
- }
- /* NOTREACHED */
-}
-
-static int
-kvm_read (core_kd, memaddr, myaddr, len)
- int core_kd;
- CORE_ADDR memaddr;
- char *myaddr;
-{
- return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
-}
-
-static int
-kvm_uread (core_kd, p, memaddr, myaddr, len)
- int core_kd;
- register struct proc *p;
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- register char *cp;
- char procfile[MAXPATHLEN];
- ssize_t amount;
- int fd;
-
- if (devmem)
- {
- cp = myaddr;
-
- sprintf (procfile, "/proc/%d/mem", p->p_pid);
- fd = open (procfile, O_RDONLY, 0);
-
- if (fd < 0)
- {
- error ("cannot open %s", procfile);
- close (fd);
- return (0);
- }
-
- while (len > 0)
- {
- if (lseek (fd, memaddr, 0) == -1 && errno != 0)
- {
- error ("invalid address (%x) in %s",
- memaddr, procfile);
- break;
- }
- amount = read (fd, cp, len);
- if (amount < 0)
- {
- error ("error reading %s", procfile);
- break;
- }
- cp += amount;
- memaddr += amount;
- len -= amount;
- }
-
- close (fd);
- return (ssize_t) (cp - myaddr);
- }
- else
- return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
-}
-
-static struct kinfo_proc kp;
-
-/*
- * try to do what kvm_proclist in libkvm would do
- */
-static int
-kvm_proclist (cfd, pid, p, cnt)
-int cfd, pid, *cnt;
-struct proc *p;
-{
- struct proc lp;
-
- for (; p != NULL; p = lp.p_list.le_next) {
- if (!kvm_read(cfd, (CORE_ADDR)p, (char *)&lp, sizeof (lp)))
- return (0);
- if (lp.p_pid != pid)
- continue;
- kp.kp_eproc.e_paddr = p;
- *cnt = 1;
- return (1);
- }
- *cnt = 0;
- return (0);
-}
-
-/*
- * try to do what kvm_deadprocs in libkvm would do
- */
-static struct kinfo_proc *
-kvm_deadprocs (cfd, pid, cnt)
-int cfd, pid, *cnt;
-{
- CORE_ADDR allproc, zombproc;
- struct proc *p;
-
- allproc = ksym_lookup("allproc");
- if (kvm_read(cfd, allproc, (char *)&p, sizeof (p)) == 0)
- return (NULL);
- kvm_proclist (cfd, pid, p, cnt);
- if (!*cnt) {
- zombproc = ksym_lookup("zombproc");
- if (kvm_read(cfd, zombproc, (char *)&p, sizeof (p)) == 0)
- return (NULL);
- kvm_proclist (cfd, pid, p, cnt);
- }
- return (&kp);
-}
-
-/*
- * try to do what kvm_getprocs in libkvm would do
- */
-static struct kinfo_proc *
-kvm_getprocs (cfd, op, proc, cnt)
-int cfd, op, *cnt;
-CORE_ADDR proc;
-{
- int mib[4], size;
-
- *cnt = 0;
- /* assume it's a pid */
- if (devmem) { /* "live" kernel, use sysctl */
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
- mib[2] = KERN_PROC_PID;
- mib[3] = (int)proc;
- size = sizeof (kp);
- if (sysctl (mib, 4, &kp, &size, NULL, 0) < 0) {
- perror("sysctl");
- *cnt = 0;
- return (NULL);
- }
- if (!size)
- *cnt = 0;
- else
- *cnt = 1;
- return (&kp);
- } else
- return (kvm_deadprocs (cfd, (int)proc, cnt));
-}
-
-static int
-physrd (cfd, addr, dat, len)
- int cfd;
- u_int addr;
- char *dat;
- int len;
-{
- if (lseek (cfd, (off_t)addr, L_SET) == -1)
- return (-1);
- return (read (cfd, dat, len));
-}
-
-static CORE_ADDR
-kvtophys (fd, addr)
- int fd;
- CORE_ADDR addr;
-{
- CORE_ADDR v;
- unsigned int pte;
- static CORE_ADDR PTD = -1;
- CORE_ADDR current_ptd;
-
- /*
- * If we're looking at the kernel stack,
- * munge the address to refer to the user space mapping instead;
- * that way we get the requested process's kstack, not the running one.
- */
- /*
- * this breaks xlating user addresses from a crash dump so only
- * do it for a "live" kernel.
- */
- if (devmem && addr >= kstack && addr < kstack + ctob (UPAGES))
- addr = (addr - kstack) + curpcb;
-
- /*
- * We may no longer have a linear system page table...
- *
- * Here's the scoop. IdlePTD contains the physical address
- * of a page table directory that always maps the kernel.
- * IdlePTD is in memory that is mapped 1-to-1, so we can
- * find it easily given its 'virtual' address from ksym_lookup().
- * For hysterical reasons, the value of IdlePTD is stored in sbr.
- *
- * To look up a kernel address, we first convert it to a 1st-level
- * address and look it up in IdlePTD. This gives us the physical
- * address of a page table page; we extract the 2nd-level part of
- * VA and read the 2nd-level pte. Finally, we add the offset part
- * of the VA into the physical address from the pte and return it.
- *
- * User addresses are a little more complicated. If we don't have
- * a current PCB from read_pcb(), we use PTD, which is the (fixed)
- * virtual address of the current ptd. Since it's NOT in 1-to-1
- * kernel space, we must look it up using IdlePTD. If we do have
- * a pcb, we get the ptd from pcb_ptd.
- */
-
- if (INKERNEL (addr))
- current_ptd = sbr;
- else if (found_pcb == 0)
- {
- if (PTD == -1)
- PTD = kvtophys (fd, ksym_lookup ("PTD"));
- current_ptd = PTD;
- }
- else
- current_ptd = pcb.pcb_cr3;
-
- /*
- * Read the first-level page table (ptd).
- */
- v = current_ptd + ( (unsigned)addr >> PDRSHIFT) * sizeof pte;
- if (physrd (fd, v, (char *)&pte, sizeof pte) < 0 || (pte&PG_V) == 0)
- return (~0);
-
- if (pte & PG_PS)
- {
- /*
- * No second-level page table; ptd describes one 4MB page.
- * (We assume that the kernel wouldn't set PG_PS without enabling
- * it cr0, and that the kernel doesn't support 36-bit physical
- * addresses).
- */
-#define PAGE4M_MASK (NBPDR - 1)
-#define PG_FRAME4M (~PAGE4M_MASK)
- addr = (pte & PG_FRAME4M) + (addr & PAGE4M_MASK);
- }
- else
- {
- /*
- * Read the second-level page table.
- */
- v = (pte&PG_FRAME) + ((addr >> PAGE_SHIFT)&(NPTEPG-1)) * sizeof pte;
- if (physrd (fd, v, (char *) &pte, sizeof (pte)) < 0 || (pte&PG_V) == 0)
- return (~0);
-
- addr = (pte & PG_FRAME) + (addr & PAGE_MASK);
- }
-#if 0
- printf ("vtophys (%x) -> %x\n", oldaddr, addr);
-#endif
- return (addr);
-}
-
-static int
-read_pcb (fd, uaddr)
- int fd;
- CORE_ADDR uaddr;
-{
- int i;
- int noreg;
- CORE_ADDR nuaddr = uaddr;
-
- /* need this for the `proc' command to work */
- if (INKERNEL(uaddr))
- nuaddr = kvtophys(fd, uaddr);
-
- if (physrd (fd, nuaddr, (char *)&pcb, sizeof pcb) < 0)
- {
- error ("cannot read pcb at %x\n", uaddr);
- return (-1);
- }
- printf ("current pcb at %x\n", uaddr);
-
- /*
- * get the register values out of the sys pcb and
- * store them where `read_register' will find them.
- */
- /*
- * XXX many registers aren't available.
- * XXX for the non-core case, the registers are stale - they are for
- * the last context switch to the debugger.
- * XXX gcc's register numbers aren't all #defined in tm-i386.h.
- */
- noreg = 0;
- for (i = 0; i < 3; ++i) /* eax,ecx,edx */
- supply_register (i, (char *)&noreg);
- supply_register (3, (char *)&pcb.pcb_ebx);
- supply_register (SP_REGNUM, (char *)&pcb.pcb_esp);
- supply_register (FP_REGNUM, (char *)&pcb.pcb_ebp);
- supply_register (6, (char *)&pcb.pcb_esi);
- supply_register (7, (char *)&pcb.pcb_edi);
- supply_register (PC_REGNUM, (char *)&pcb.pcb_eip);
- for (i = 9; i < 14; ++i) /* eflags, cs, ss, ds, es */
- supply_register (i, (char *)&noreg);
- supply_register (15, (char *)&pcb.pcb_fs);
- supply_register (16, (char *)&pcb.pcb_gs);
-
- /* XXX 80387 registers? */
-}
-
-/*
- * read len bytes from kernel virtual address 'addr' into local
- * buffer 'buf'. Return numbert of bytes if read ok, 0 otherwise. On read
- * errors, portion of buffer not read is zeroed.
- */
-
-static int
-kernel_core_file_hook (fd, addr, buf, len)
- int fd;
- CORE_ADDR addr;
- char *buf;
- int len;
-{
- int i;
- CORE_ADDR paddr;
- register char *cp;
- int cc;
-
- cp = buf;
-
- while (len > 0)
- {
- paddr = kvtophys (fd, addr);
- if (paddr == ~0)
- {
- memset (buf, '\000', len);
- break;
- }
- /* we can't read across a page boundary */
- i = min (len, PAGE_SIZE - (addr & PAGE_MASK));
- if ( (cc = physrd (fd, paddr, cp, i)) <= 0)
- {
- memset (cp, '\000', len);
- return (cp - buf);
- }
- cp += cc;
- addr += cc;
- len -= cc;
- }
- return (cp - buf);
-}
-
-struct target_ops kcore_ops = {
- "kcore", /* to_shortname */
- "Kernel core dump file", /* to_longname */
- "Use a core file as a target. Specify the filename of the core file.", /* to_doc */
- kcore_open, /* to_open */
- kcore_close, /* to_close */
- find_default_attach, /* to_attach */
- kcore_detach, /* to_detach */
- NULL, /* to_resume */
- NULL, /* to_wait */
- get_kcore_registers, /* to_fetch_registers */
- NULL, /* to_store_registers */
- NULL, /* to_prepare_to_store */
- kcore_xfer_kmem, /* to_xfer_memory */
- kcore_files_info, /* to_files_info */
- NULL, /* to_insert_breakpoint */
- NULL, /* to_remove_breakpoint */
- NULL, /* to_terminal_init */
- NULL, /* to_terminal_inferior */
- NULL, /* to_terminal_ours_for_output */
- NULL, /* to_terminal_ours */
- NULL, /* to_terminal_info */
- NULL, /* to_kill */
- NULL, /* to_load */
- NULL, /* to_lookup_symbol */
- find_default_create_inferior, /* to_create_inferior */
- NULL, /* to_mourn_inferior */
- 0, /* to_can_run */
- 0, /* to_notice_signals */
- NULL, /* to_thread_alive */
- 0, /* to_stop */
- kcore_stratum, /* to_stratum */
- NULL, /* to_next */
- 0, /* to_has_all_memory */
- 1, /* to_has_memory */
- 1, /* to_has_stack */
- 1, /* to_has_registers */
- 0, /* to_has_execution */
- NULL, /* sections */
- NULL, /* sections_end */
- OPS_MAGIC /* to_magic */
-};
-
-void
-_initialize_kcorelow()
-{
- add_target (&kcore_ops);
- add_com ("proc", class_obscure, set_proc_cmd, "Set current process context");
-}
diff --git a/gnu/usr.bin/binutils/gdb/i386/nm.h b/gnu/usr.bin/binutils/gdb/i386/nm.h
deleted file mode 100644
index 1edc1ce..0000000
--- a/gnu/usr.bin/binutils/gdb/i386/nm.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Native-dependent definitions for Intel 386 running BSD Unix, for GDB.
- Copyright 1986, 1987, 1989, 1992, 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef NM_FBSD_H
-#define NM_FBSD_H
-
-#define ATTACH_DETACH
-
-/* Be shared lib aware */
-#include "solib.h"
-
-/* This is the amount to subtract from u.u_ar0
- to get the offset in the core file of the register values. */
-
-#include <machine/vmparam.h>
-#define KERNEL_U_ADDR USRSTACK
-
-#define REGISTER_U_ADDR(addr, blockend, regno) \
- (addr) = i386_register_u_addr ((blockend),(regno));
-
-/* We define our own fetch/store methods */
-#define FETCH_INFERIOR_REGISTERS
-
-extern int
-i386_register_u_addr PARAMS ((int, int));
-
-#define PTRACE_ARG3_TYPE char*
-
-/* make structure definitions match up with those expected in solib.c */
-#define link_object sod
-#define lo_name sod_name
-#define lo_library sod_library
-#define lo_unused sod_reserved
-#define lo_major sod_major
-#define lo_minor sod_minor
-#define lo_next sod_next
-
-#define link_map so_map
-#define lm_addr som_addr
-#define lm_name som_path
-#define lm_next som_next
-#define lm_lop som_sod
-#define lm_lob som_sodbase
-#define lm_rwt som_write
-#define lm_ld som_dynamic
-#define lm_lpd som_spd
-
-#define link_dynamic_2 section_dispatch_table
-#define ld_loaded sdt_loaded
-#define ld_need sdt_sods
-#define ld_rules sdt_filler1
-#define ld_got sdt_got
-#define ld_plt sdt_plt
-#define ld_rel sdt_rel
-#define ld_hash sdt_hash
-#define ld_stab sdt_nzlist
-#define ld_stab_hash sdt_filler2
-#define ld_buckets sdt_buckets
-#define ld_symbols sdt_strings
-#define ld_symb_size sdt_str_sz
-#define ld_text sdt_text_sz
-#define ld_plt_sz sdt_plt_sz
-
-#define rtc_symb rt_symbol
-#define rtc_sp rt_sp
-#define rtc_next rt_next
-
-#define ld_debug so_debug
-#define ldd_version dd_version
-#define ldd_in_debugger dd_in_debugger
-#define ldd_sym_loaded dd_sym_loaded
-#define ldd_bp_addr dd_bpt_addr
-#define ldd_bp_inst dd_bpt_shadow
-#define ldd_cp dd_cc
-
-#define link_dynamic _dynamic
-#define ld_version d_version
-#define ldd d_debug
-#define ld_un d_un
-#define ld_2 d_sdt
-
-/* Return sizeof user struct to callers in less machine dependent routines */
-
-#define KERNEL_U_SIZE kernel_u_size()
-extern int kernel_u_size PARAMS ((void));
-
-#define ADDITIONAL_OPTIONS \
- {"kernel", no_argument, &kernel_debugging, 1}, \
- {"k", no_argument, &kernel_debugging, 1}, \
- {"wcore", no_argument, &kernel_writablecore, 1}, \
- {"w", no_argument, &kernel_writablecore, 1},
-
-#define ADDITIONAL_OPTION_HELP \
- "\
- --kernel Enable kernel debugging.\n\
- --wcore Make core file writable (only works for /dev/mem).\n\
- This option only works while debugging a kernel !!\n\
-"
-
-extern int kernel_debugging;
-extern int kernel_writablecore;
-
-#define DEFAULT_PROMPT kernel_debugging?"(kgdb) ":"(gdb) "
-
-/* misuse START_PROGRESS to test whether we're running as kgdb */
-/* START_PROGRESS is called at the top of main */
-#undef START_PROGRESS
-#define START_PROGRESS(STR,N) \
- if (!strcmp(STR, "kgdb")) \
- kernel_debugging = 1;
-
-#endif /* NM_FBSD_H */
diff --git a/gnu/usr.bin/binutils/gdb/i386/tm.h b/gnu/usr.bin/binutils/gdb/i386/tm.h
deleted file mode 100644
index 5ad8e76..0000000
--- a/gnu/usr.bin/binutils/gdb/i386/tm.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Macro definitions for x86 running under FreeBSD Unix.
- Copyright 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef TM_FBSD_H
-#define TM_FBSD_H 1
-
-#include "i386/tm-i386bsd.h"
-
-#undef NUM_REGS
-#define NUM_REGS 16
-
-extern struct frame_info *setup_arbitrary_frame PARAMS ((int, CORE_ADDR *));
-
-#define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
-
-extern void i386_float_info PARAMS ((void));
-
-#define FLOAT_INFO i386_float_info ()
-
-#define IN_SOLIB_CALL_TRAMPOLINE(pc, name) STREQ (name, "_DYNAMIC")
-
-/* FRAME_CHAIN takes a frame's nominal address and produces the frame's
- chain-pointer.
- In the case of the i386, the frame's nominal address
- is the address of a 4-byte word containing the calling frame's address. */
-
-extern CORE_ADDR fbsd_kern_frame_chain (struct frame_info *);
-#undef FRAME_CHAIN
-#define FRAME_CHAIN(thisframe) \
- (kernel_debugging ? fbsd_kern_frame_chain(thisframe) : \
- ((thisframe)->signal_handler_caller \
- ? (thisframe)->frame \
- : (!inside_entry_file ((thisframe)->pc) \
- ? read_memory_integer ((thisframe)->frame, 4) \
- : 0)))
-
-/* Saved Pc. Get it from sigcontext if within sigtramp. */
-
-extern CORE_ADDR fbsd_kern_frame_saved_pc (struct frame_info *);
-#undef FRAME_SAVED_PC
-#define FRAME_SAVED_PC(FRAME) \
- (kernel_debugging ? fbsd_kern_frame_saved_pc(FRAME) : \
- (((FRAME)->signal_handler_caller \
- ? sigtramp_saved_pc (FRAME) \
- : read_memory_integer ((FRAME)->frame + 4, 4)) \
- ))
-
-/* Sigtramp is not the same address as BSD/OS.. */
-#undef SIGTRAMP_START
-#undef SIGTRAMP_END
-#define SIGTRAMP_START 0xefbfdfc0
-#define SIGTRAMP_END 0xefbfe000
-
-#endif /* TM_FBSD_H */
diff --git a/gnu/usr.bin/binutils/gdb/i386/version.c b/gnu/usr.bin/binutils/gdb/i386/version.c
deleted file mode 100644
index 3d677fe..0000000
--- a/gnu/usr.bin/binutils/gdb/i386/version.c
+++ /dev/null
@@ -1,3 +0,0 @@
-char *version = "4.16";
-char *host_name = "i386-unknown-freebsd";
-char *target_name = "i386-unknown-freebsd";
diff --git a/gnu/usr.bin/binutils/gdb/i386/xm.h b/gnu/usr.bin/binutils/gdb/i386/xm.h
deleted file mode 100644
index 8a852a2..0000000
--- a/gnu/usr.bin/binutils/gdb/i386/xm.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Host-dependent definitions for Intel 386 running BSD Unix, for GDB.
- Copyright 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define HOST_BYTE_ORDER LITTLE_ENDIAN
-
-#include <machine/limits.h> /* for INT_MIN, to avoid "INT_MIN
- redefined" warnings from defs.h */
diff --git a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c
deleted file mode 100644
index 5f93334..0000000
--- a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c
+++ /dev/null
@@ -1,970 +0,0 @@
-/* Live and postmortem kernel debugging functions for FreeBSD.
- Copyright 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/sysctl.h>
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include "frame.h" /* required by inferior.h */
-#include "inferior.h"
-#include "symtab.h"
-#include "command.h"
-#include "bfd.h"
-#include "target.h"
-#include "gdbcore.h"
-#include <sys/stat.h>
-#include <unistd.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-
-#include <machine/vmparam.h>
-#include <machine/pcb.h>
-#include <machine/tss.h>
-#include <machine/frame.h>
-
-static void kcore_files_info PARAMS ((struct target_ops *));
-
-static void kcore_close PARAMS ((int));
-
-static void get_kcore_registers PARAMS ((int));
-
-static int kcore_xfer_kmem PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
-
-static int xfer_umem PARAMS ((CORE_ADDR, char *, int, int));
-
-static CORE_ADDR ksym_lookup PARAMS ((const char *));
-
-static int read_pcb PARAMS ((int, CORE_ADDR));
-
-static struct proc * curProc PARAMS ((void));
-
-static int set_proc_context PARAMS ((CORE_ADDR paddr));
-
-static void kcore_open PARAMS ((char *filename, int from_tty));
-
-static void kcore_detach PARAMS ((char *args, int from_tty));
-
-static void set_proc_cmd PARAMS ((char *arg, int from_tty));
-
-static CORE_ADDR kvtophys PARAMS ((int, CORE_ADDR));
-
-static int physrd PARAMS ((int, u_int, char*, int));
-
-static int kvm_open PARAMS ((const char *efile, char *cfile, char *sfile,
- int perm, char *errout));
-
-static int kvm_close PARAMS ((int fd));
-
-static int kvm_write PARAMS ((int core_kd, CORE_ADDR memaddr,
- char *myaddr, int len));
-
-static int kvm_read PARAMS ((int core_kd, CORE_ADDR memaddr,
- char *myaddr, int len));
-
-static int kvm_uread PARAMS ((int core_kd, struct proc *p,
- CORE_ADDR memaddr, char *myaddr,
- int len));
-
-static int kernel_core_file_hook PARAMS ((int fd, CORE_ADDR addr,
- char *buf, int len));
-
-static struct kinfo_proc * kvm_getprocs PARAMS ((int cfd, int op,
- CORE_ADDR proc, int *cnt));
-
-extern struct target_ops kcore_ops; /* Forward decl */
-
-/* Non-zero means we are debugging a kernel core file */
-int kernel_debugging = 0;
-int kernel_writablecore = 0;
-
-static char *core_file;
-static int core_kd = -1;
-static struct proc *cur_proc;
-static CORE_ADDR kernel_start;
-
-/*
- * Read the "thing" at kernel address 'addr' into the space pointed to
- * by point. The length of the "thing" is determined by the type of p.
- * Result is non-zero if transfer fails.
- */
-#define kvread(addr, p) \
- (target_read_memory ((CORE_ADDR)(addr), (char *)(p), sizeof(*(p))))
-
-
-
-/*
- * The following is FreeBSD-specific hackery to decode special frames
- * and elide the assembly-language stub. This could be made faster by
- * defining a frame_type field in the machine-dependent frame information,
- * but we don't think that's too important right now.
- */
-enum frametype { tf_normal, tf_trap, tf_interrupt, tf_syscall };
-
-CORE_ADDR
-fbsd_kern_frame_saved_pc (fr)
-struct frame_info *fr;
-{
- struct minimal_symbol *sym;
- CORE_ADDR this_saved_pc;
- enum frametype frametype;
-
- this_saved_pc = read_memory_integer (fr->frame + 4, 4);
- sym = lookup_minimal_symbol_by_pc (this_saved_pc);
- frametype = tf_normal;
- if (sym != NULL) {
- if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0)
- frametype = tf_trap;
- else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0)
- frametype = tf_interrupt;
- else if (strcmp (SYMBOL_NAME(sym), "Xsyscall") == 0)
- frametype = tf_syscall;
- }
-
- switch (frametype) {
- case tf_normal:
- return (this_saved_pc);
-
-#define oEIP offsetof(struct trapframe, tf_eip)
-
- case tf_trap:
- return (read_memory_integer (fr->frame + 8 + oEIP, 4));
-
- case tf_interrupt:
- return (read_memory_integer (fr->frame + 16 + oEIP, 4));
-
- case tf_syscall:
- return (read_memory_integer (fr->frame + 8 + oEIP, 4));
-#undef oEIP
- }
-}
-
-CORE_ADDR
-fbsd_kern_frame_chain (fr)
-struct frame_info *fr;
-{
- struct minimal_symbol *sym;
- CORE_ADDR this_saved_pc;
- enum frametype frametype;
-
- this_saved_pc = read_memory_integer (fr->frame + 4, 4);
- sym = lookup_minimal_symbol_by_pc (this_saved_pc);
- frametype = tf_normal;
- if (sym != NULL) {
- if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0)
- frametype = tf_trap;
- else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0)
- frametype = tf_interrupt;
- else if (strcmp (SYMBOL_NAME(sym), "_Xsyscall") == 0)
- frametype = tf_syscall;
- }
-
- switch (frametype) {
- case tf_normal:
- return (read_memory_integer (fr->frame, 4));
-
-#define oEBP offsetof(struct trapframe, tf_ebp)
-
- case tf_trap:
- return (read_memory_integer (fr->frame + 8 + oEBP, 4));
-
- case tf_interrupt:
- return (read_memory_integer (fr->frame + 16 + oEBP, 4));
-
- case tf_syscall:
- return (read_memory_integer (fr->frame + 8 + oEBP, 4));
-#undef oEBP
- }
-}
-
-static CORE_ADDR
-ksym_lookup (name)
-const char *name;
-{
- struct minimal_symbol *sym;
-
- sym = lookup_minimal_symbol (name, NULL, NULL);
- if (sym == NULL)
- error ("kernel symbol `%s' not found.", name);
-
- return SYMBOL_VALUE_ADDRESS (sym);
-}
-
-static struct proc *
-curProc ()
-{
- struct proc *p;
- CORE_ADDR addr = ksym_lookup ("curproc");
-
- if (kvread (addr, &p))
- error ("cannot read proc pointer at %x\n", addr);
- return p;
-}
-
-/*
- * Set the process context to that of the proc structure at
- * system address paddr.
- */
-static int
-set_proc_context (paddr)
- CORE_ADDR paddr;
-{
- struct proc p;
-
- if (paddr < kernel_start)
- return (1);
-
- cur_proc = (struct proc *)paddr;
-#ifdef notyet
- set_kernel_boundaries (cur_proc);
-#endif
-
- /* Fetch all registers from core file */
- target_fetch_registers (-1);
-
- /* Now, set up the frame cache, and print the top of stack */
- flush_cached_frames ();
- set_current_frame (create_new_frame (read_fp (), read_pc ()));
- select_frame (get_current_frame (), 0);
- return (0);
-}
-
-/* Discard all vestiges of any previous core file
- and mark data and stack spaces as empty. */
-
-/* ARGSUSED */
-static void
-kcore_close (quitting)
- int quitting;
-{
- inferior_pid = 0; /* Avoid confusion from thread stuff */
-
- if (core_kd)
- {
- kvm_close (core_kd);
- free (core_file);
- core_file = NULL;
- core_kd = -1;
- }
-}
-
-/* This routine opens and sets up the core file bfd */
-
-static void
-kcore_open (filename, from_tty)
- char *filename;
- int from_tty;
-{
- const char *p;
- struct cleanup *old_chain;
- char buf[256], *cp;
- int ontop;
- CORE_ADDR addr;
- struct pcb pcb;
-
- target_preopen (from_tty);
-
- unpush_target (&kcore_ops);
-
- if (!filename)
- {
- /*error (core_kd?*/
- error ( (core_kd >= 0)?
- "No core file specified. (Use `detach' to stop debugging a core file.)"
- : "No core file specified.");
- }
-
- filename = tilde_expand (filename);
- if (filename[0] != '/')
- {
- cp = concat (current_directory, "/", filename, NULL);
- free (filename);
- filename = cp;
- }
-
- old_chain = make_cleanup (free, filename);
-
- /*
- * gdb doesn't really do anything if the exec-file couldn't
- * be opened (in that case exec_bfd is NULL). Usually that's
- * no big deal, but kvm_open needs the exec-file's name,
- * which results in dereferencing a NULL pointer, a real NO-NO !
- * So, check here if the open of the exec-file succeeded.
- */
- if (exec_bfd == NULL) /* the open failed */
- error ("kgdb could not open the exec-file, please check the name you used !");
-
- core_kd = kvm_open (exec_bfd->filename, filename, NULL,
- kernel_writablecore? O_RDWR : O_RDONLY, "kgdb: ");
- if (core_kd < 0)
- perror_with_name (filename);
-
- /* Looks semi-reasonable. Toss the old core file and work on the new. */
-
- discard_cleanups (old_chain); /* Don't free filename any more */
- core_file = filename;
- ontop = !push_target (&kcore_ops);
-
- kernel_start = bfd_get_start_address (exec_bfd); /* XXX */
-
- /* print out the panic string if there is one */
- if (kvread (ksym_lookup ("panicstr"), &addr) == 0
- && addr != 0
- && target_read_memory (addr, buf, sizeof (buf)) == 0)
- {
- for (cp = buf; cp < &buf[sizeof (buf)] && *cp; cp++)
- if (!isascii (*cp) || (!isprint (*cp) && !isspace (*cp)))
- *cp = '?';
- *cp = '\0';
- if (buf[0] != '\0')
- printf ("panicstr: %s\n", buf);
-
- printf ("panic messages:\n---\n");
- snprintf (buf, sizeof buf,
- "/sbin/dmesg -M %s | \
- /usr/bin/awk '/^(panic:|Fatal trap) / { printing = 1 } \
- { if (printing) print $0 }'",
- filename);
- system (buf);
- printf ("---\n");
- }
-
- if (!ontop)
- {
- warning ("you won't be able to access this core file until you terminate\n\
-your %s; do ``info files''", target_longname);
- return;
- }
-
- /* we may need this later */
- cur_proc = (struct proc *)curProc ();
- /* Now, set up the frame cache, and print the top of stack */
- flush_cached_frames ();
- set_current_frame (create_new_frame (read_fp (), read_pc ()));
- select_frame (get_current_frame (), 0);
- print_stack_frame (selected_frame, selected_frame_level, 1);
-}
-
-static void
-kcore_detach (args, from_tty)
- char *args;
- int from_tty;
-{
- if (args)
- error ("Too many arguments");
- unpush_target (&kcore_ops);
- reinit_frame_cache ();
- if (from_tty)
- printf_filtered ("No kernel core file now.\n");
-}
-
-/* Get the registers out of a core file. This is the machine-
- independent part. Fetch_core_registers is the machine-dependent
- part, typically implemented in the xm-file for each architecture. */
-
-/* We just get all the registers, so we don't use regno. */
-/* ARGSUSED */
-static void
-get_kcore_registers (regno)
- int regno;
-{
- struct user *uaddr;
-
- /* find the pcb for the current process */
- if (kvread (&cur_proc->p_addr, &uaddr))
- error ("cannot read u area ptr for proc at %#x", cur_proc);
- if (read_pcb (core_kd, (CORE_ADDR)&uaddr->u_pcb) < 0)
- error ("cannot read pcb at %#x", &uaddr->u_pcb);
-}
-
-static void
-kcore_files_info (t)
- struct target_ops *t;
-{
- printf ("\t`%s'\n", core_file);
-}
-
-static int
-kcore_xfer_kmem (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target;
-{
- int n;
-
- if (!memaddr)
- return (0);
-
- if (memaddr < kernel_start)
- return xfer_umem (memaddr, myaddr, len, write);
-
- n = write ?
- kvm_write (core_kd, memaddr, myaddr, len) :
- kvm_read (core_kd, memaddr, myaddr, len) ;
-
- if (n < 0)
- return 0;
- return n;
-}
-
-static int
-xfer_umem (memaddr, myaddr, len, write)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write; /* ignored */
-{
- int n;
- struct proc proc;
-
- if (kvread (cur_proc, &proc))
- error ("cannot read proc at %#x", cur_proc);
- n = kvm_uread (core_kd, &proc, memaddr, myaddr, len) ;
-
- if (n < 0)
- return 0;
- return n;
-}
-
-static void
-set_proc_cmd (arg, from_tty)
- char *arg;
- int from_tty;
-{
- CORE_ADDR paddr;
- struct kinfo_proc *kp;
- int cnt = 0;
-
- if (!arg)
- error_no_arg ("proc address for new current process");
- if (!kernel_debugging)
- error ("not debugging kernel");
-
- paddr = (CORE_ADDR)parse_and_eval_address (arg);
- /* assume it's a proc pointer if it's in the kernel */
- if (paddr >= kernel_start) {
- if (set_proc_context(paddr))
- error("invalid proc address");
- } else {
- kp = kvm_getprocs(core_kd, KERN_PROC_PID, paddr, &cnt);
- if (!cnt)
- error("invalid pid");
- if (set_proc_context((CORE_ADDR)kp->kp_eproc.e_paddr))
- error("invalid proc address");
- }
-}
-
-
-
-#define KERNOFF ((unsigned)KERNBASE)
-#define INKERNEL(x) ((x) >= KERNOFF)
-
-static CORE_ADDR sbr;
-static CORE_ADDR curpcb;
-static CORE_ADDR kstack;
-static int found_pcb;
-static int devmem;
-static int kfd;
-static struct pcb pcb;
-
-/* substitutes for the stuff in libkvm which doesn't work */
-/* most of this was taken from the old kgdb */
-
-/* we don't need all this stuff, but the call should look the same */
-
-static int
-kvm_open (efile, cfile, sfile, perm, errout)
- const char *efile;
- char *cfile;
- char *sfile; /* makes this kvm_open more compatible to the one in libkvm */
- int perm;
- char *errout; /* makes this kvm_open more compatible to the one in libkvm */
-{
- struct stat stb;
- CORE_ADDR addr;
- int cfd;
- struct i386tss cts;
-
- if ((cfd = open (cfile, perm, 0)) < 0)
- return (cfd);
-
- fstat (cfd, &stb);
- if ((stb.st_mode & S_IFMT) == S_IFCHR
- && stb.st_rdev == makedev (2, 0))
- {
- devmem = 1;
- kfd = open ("/dev/kmem", perm, 0);
- }
-
- physrd (cfd, ksym_lookup ("IdlePTD") - KERNOFF, (char*)&sbr, sizeof sbr);
- printf ("IdlePTD %x\n", sbr);
- curpcb = ksym_lookup ("curpcb") - KERNOFF;
- physrd (cfd, curpcb, (char*)&curpcb, sizeof curpcb);
- physrd (cfd, ksym_lookup ("common_tss") - KERNOFF, (char*)&cts, sizeof cts);
- kstack = cts.tss_ksp;
-
- found_pcb = 1; /* for vtophys */
- if (!devmem)
- read_pcb (cfd, ksym_lookup ("dumppcb") - KERNOFF);
- else
- read_pcb (cfd, kvtophys (cfd, kstack));
-
- return (cfd);
-}
-
-static int
-kvm_close (fd)
- int fd;
-{
- return (close (fd));
-}
-
-static int
-kvm_write (core_kd, memaddr, myaddr, len)
- int core_kd;
- CORE_ADDR memaddr;
- char *myaddr;
-{
- int cc;
-
- if (devmem)
- {
- if (kfd > 0)
- {
- /*
- * Just like kvm_read, only we write.
- */
- errno = 0;
- if (lseek (kfd, (off_t)memaddr, 0) < 0
- && errno != 0)
- {
- error ("kvm_write:invalid address (%x)", memaddr);
- return (0);
- }
- cc = write (kfd, myaddr, len);
- if (cc < 0)
- {
- error ("kvm_write:write failed");
- return (0);
- }
- else if (cc < len)
- error ("kvm_write:short write");
- return (cc);
- }
- else
- return (0);
- }
- else
- {
- printf ("kvm_write not implemented for dead kernels\n");
- return (0);
- }
- /* NOTREACHED */
-}
-
-static int
-kvm_read (core_kd, memaddr, myaddr, len)
- int core_kd;
- CORE_ADDR memaddr;
- char *myaddr;
-{
- return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
-}
-
-static int
-kvm_uread (core_kd, p, memaddr, myaddr, len)
- int core_kd;
- register struct proc *p;
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- register char *cp;
- char procfile[MAXPATHLEN];
- ssize_t amount;
- int fd;
-
- if (devmem)
- {
- cp = myaddr;
-
- sprintf (procfile, "/proc/%d/mem", p->p_pid);
- fd = open (procfile, O_RDONLY, 0);
-
- if (fd < 0)
- {
- error ("cannot open %s", procfile);
- close (fd);
- return (0);
- }
-
- while (len > 0)
- {
- if (lseek (fd, memaddr, 0) == -1 && errno != 0)
- {
- error ("invalid address (%x) in %s",
- memaddr, procfile);
- break;
- }
- amount = read (fd, cp, len);
- if (amount < 0)
- {
- error ("error reading %s", procfile);
- break;
- }
- cp += amount;
- memaddr += amount;
- len -= amount;
- }
-
- close (fd);
- return (ssize_t) (cp - myaddr);
- }
- else
- return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
-}
-
-static struct kinfo_proc kp;
-
-/*
- * try to do what kvm_proclist in libkvm would do
- */
-static int
-kvm_proclist (cfd, pid, p, cnt)
-int cfd, pid, *cnt;
-struct proc *p;
-{
- struct proc lp;
-
- for (; p != NULL; p = lp.p_list.le_next) {
- if (!kvm_read(cfd, (CORE_ADDR)p, (char *)&lp, sizeof (lp)))
- return (0);
- if (lp.p_pid != pid)
- continue;
- kp.kp_eproc.e_paddr = p;
- *cnt = 1;
- return (1);
- }
- *cnt = 0;
- return (0);
-}
-
-/*
- * try to do what kvm_deadprocs in libkvm would do
- */
-static struct kinfo_proc *
-kvm_deadprocs (cfd, pid, cnt)
-int cfd, pid, *cnt;
-{
- CORE_ADDR allproc, zombproc;
- struct proc *p;
-
- allproc = ksym_lookup("allproc");
- if (kvm_read(cfd, allproc, (char *)&p, sizeof (p)) == 0)
- return (NULL);
- kvm_proclist (cfd, pid, p, cnt);
- if (!*cnt) {
- zombproc = ksym_lookup("zombproc");
- if (kvm_read(cfd, zombproc, (char *)&p, sizeof (p)) == 0)
- return (NULL);
- kvm_proclist (cfd, pid, p, cnt);
- }
- return (&kp);
-}
-
-/*
- * try to do what kvm_getprocs in libkvm would do
- */
-static struct kinfo_proc *
-kvm_getprocs (cfd, op, proc, cnt)
-int cfd, op, *cnt;
-CORE_ADDR proc;
-{
- int mib[4], size;
-
- *cnt = 0;
- /* assume it's a pid */
- if (devmem) { /* "live" kernel, use sysctl */
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
- mib[2] = KERN_PROC_PID;
- mib[3] = (int)proc;
- size = sizeof (kp);
- if (sysctl (mib, 4, &kp, &size, NULL, 0) < 0) {
- perror("sysctl");
- *cnt = 0;
- return (NULL);
- }
- if (!size)
- *cnt = 0;
- else
- *cnt = 1;
- return (&kp);
- } else
- return (kvm_deadprocs (cfd, (int)proc, cnt));
-}
-
-static int
-physrd (cfd, addr, dat, len)
- int cfd;
- u_int addr;
- char *dat;
- int len;
-{
- if (lseek (cfd, (off_t)addr, L_SET) == -1)
- return (-1);
- return (read (cfd, dat, len));
-}
-
-static CORE_ADDR
-kvtophys (fd, addr)
- int fd;
- CORE_ADDR addr;
-{
- CORE_ADDR v;
- unsigned int pte;
- static CORE_ADDR PTD = -1;
- CORE_ADDR current_ptd;
-
- /*
- * If we're looking at the kernel stack,
- * munge the address to refer to the user space mapping instead;
- * that way we get the requested process's kstack, not the running one.
- */
- /*
- * this breaks xlating user addresses from a crash dump so only
- * do it for a "live" kernel.
- */
- if (devmem && addr >= kstack && addr < kstack + ctob (UPAGES))
- addr = (addr - kstack) + curpcb;
-
- /*
- * We may no longer have a linear system page table...
- *
- * Here's the scoop. IdlePTD contains the physical address
- * of a page table directory that always maps the kernel.
- * IdlePTD is in memory that is mapped 1-to-1, so we can
- * find it easily given its 'virtual' address from ksym_lookup().
- * For hysterical reasons, the value of IdlePTD is stored in sbr.
- *
- * To look up a kernel address, we first convert it to a 1st-level
- * address and look it up in IdlePTD. This gives us the physical
- * address of a page table page; we extract the 2nd-level part of
- * VA and read the 2nd-level pte. Finally, we add the offset part
- * of the VA into the physical address from the pte and return it.
- *
- * User addresses are a little more complicated. If we don't have
- * a current PCB from read_pcb(), we use PTD, which is the (fixed)
- * virtual address of the current ptd. Since it's NOT in 1-to-1
- * kernel space, we must look it up using IdlePTD. If we do have
- * a pcb, we get the ptd from pcb_ptd.
- */
-
- if (INKERNEL (addr))
- current_ptd = sbr;
- else if (found_pcb == 0)
- {
- if (PTD == -1)
- PTD = kvtophys (fd, ksym_lookup ("PTD"));
- current_ptd = PTD;
- }
- else
- current_ptd = pcb.pcb_cr3;
-
- /*
- * Read the first-level page table (ptd).
- */
- v = current_ptd + ( (unsigned)addr >> PDRSHIFT) * sizeof pte;
- if (physrd (fd, v, (char *)&pte, sizeof pte) < 0 || (pte&PG_V) == 0)
- return (~0);
-
- if (pte & PG_PS)
- {
- /*
- * No second-level page table; ptd describes one 4MB page.
- * (We assume that the kernel wouldn't set PG_PS without enabling
- * it cr0, and that the kernel doesn't support 36-bit physical
- * addresses).
- */
-#define PAGE4M_MASK (NBPDR - 1)
-#define PG_FRAME4M (~PAGE4M_MASK)
- addr = (pte & PG_FRAME4M) + (addr & PAGE4M_MASK);
- }
- else
- {
- /*
- * Read the second-level page table.
- */
- v = (pte&PG_FRAME) + ((addr >> PAGE_SHIFT)&(NPTEPG-1)) * sizeof pte;
- if (physrd (fd, v, (char *) &pte, sizeof (pte)) < 0 || (pte&PG_V) == 0)
- return (~0);
-
- addr = (pte & PG_FRAME) + (addr & PAGE_MASK);
- }
-#if 0
- printf ("vtophys (%x) -> %x\n", oldaddr, addr);
-#endif
- return (addr);
-}
-
-static int
-read_pcb (fd, uaddr)
- int fd;
- CORE_ADDR uaddr;
-{
- int i;
- int noreg;
- CORE_ADDR nuaddr = uaddr;
-
- /* need this for the `proc' command to work */
- if (INKERNEL(uaddr))
- nuaddr = kvtophys(fd, uaddr);
-
- if (physrd (fd, nuaddr, (char *)&pcb, sizeof pcb) < 0)
- {
- error ("cannot read pcb at %x\n", uaddr);
- return (-1);
- }
- printf ("current pcb at %x\n", uaddr);
-
- /*
- * get the register values out of the sys pcb and
- * store them where `read_register' will find them.
- */
- /*
- * XXX many registers aren't available.
- * XXX for the non-core case, the registers are stale - they are for
- * the last context switch to the debugger.
- * XXX gcc's register numbers aren't all #defined in tm-i386.h.
- */
- noreg = 0;
- for (i = 0; i < 3; ++i) /* eax,ecx,edx */
- supply_register (i, (char *)&noreg);
- supply_register (3, (char *)&pcb.pcb_ebx);
- supply_register (SP_REGNUM, (char *)&pcb.pcb_esp);
- supply_register (FP_REGNUM, (char *)&pcb.pcb_ebp);
- supply_register (6, (char *)&pcb.pcb_esi);
- supply_register (7, (char *)&pcb.pcb_edi);
- supply_register (PC_REGNUM, (char *)&pcb.pcb_eip);
- for (i = 9; i < 14; ++i) /* eflags, cs, ss, ds, es */
- supply_register (i, (char *)&noreg);
- supply_register (15, (char *)&pcb.pcb_fs);
- supply_register (16, (char *)&pcb.pcb_gs);
-
- /* XXX 80387 registers? */
-}
-
-/*
- * read len bytes from kernel virtual address 'addr' into local
- * buffer 'buf'. Return numbert of bytes if read ok, 0 otherwise. On read
- * errors, portion of buffer not read is zeroed.
- */
-
-static int
-kernel_core_file_hook (fd, addr, buf, len)
- int fd;
- CORE_ADDR addr;
- char *buf;
- int len;
-{
- int i;
- CORE_ADDR paddr;
- register char *cp;
- int cc;
-
- cp = buf;
-
- while (len > 0)
- {
- paddr = kvtophys (fd, addr);
- if (paddr == ~0)
- {
- memset (buf, '\000', len);
- break;
- }
- /* we can't read across a page boundary */
- i = min (len, PAGE_SIZE - (addr & PAGE_MASK));
- if ( (cc = physrd (fd, paddr, cp, i)) <= 0)
- {
- memset (cp, '\000', len);
- return (cp - buf);
- }
- cp += cc;
- addr += cc;
- len -= cc;
- }
- return (cp - buf);
-}
-
-struct target_ops kcore_ops = {
- "kcore", /* to_shortname */
- "Kernel core dump file", /* to_longname */
- "Use a core file as a target. Specify the filename of the core file.", /* to_doc */
- kcore_open, /* to_open */
- kcore_close, /* to_close */
- find_default_attach, /* to_attach */
- kcore_detach, /* to_detach */
- NULL, /* to_resume */
- NULL, /* to_wait */
- get_kcore_registers, /* to_fetch_registers */
- NULL, /* to_store_registers */
- NULL, /* to_prepare_to_store */
- kcore_xfer_kmem, /* to_xfer_memory */
- kcore_files_info, /* to_files_info */
- NULL, /* to_insert_breakpoint */
- NULL, /* to_remove_breakpoint */
- NULL, /* to_terminal_init */
- NULL, /* to_terminal_inferior */
- NULL, /* to_terminal_ours_for_output */
- NULL, /* to_terminal_ours */
- NULL, /* to_terminal_info */
- NULL, /* to_kill */
- NULL, /* to_load */
- NULL, /* to_lookup_symbol */
- find_default_create_inferior, /* to_create_inferior */
- NULL, /* to_mourn_inferior */
- 0, /* to_can_run */
- 0, /* to_notice_signals */
- NULL, /* to_thread_alive */
- 0, /* to_stop */
- kcore_stratum, /* to_stratum */
- NULL, /* to_next */
- 0, /* to_has_all_memory */
- 1, /* to_has_memory */
- 1, /* to_has_stack */
- 1, /* to_has_registers */
- 0, /* to_has_execution */
- NULL, /* sections */
- NULL, /* sections_end */
- OPS_MAGIC /* to_magic */
-};
-
-void
-_initialize_kcorelow()
-{
- add_target (&kcore_ops);
- add_com ("proc", class_obscure, set_proc_cmd, "Set current process context");
-}
diff --git a/gnu/usr.bin/binutils/gdbreplay/Makefile b/gnu/usr.bin/binutils/gdbreplay/Makefile
deleted file mode 100644
index a7b6f51..0000000
--- a/gnu/usr.bin/binutils/gdbreplay/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id: Makefile,v 1.1.1.1 1997/04/25 22:25:22 pst Exp $
-
-GDBDIR= ${.CURDIR}/../../../../contrib/gdb
-.PATH: ${GDBDIR}/gdb/gdbserver
-.PATH: ${GDBDIR}/gdb
-.PATH: ${GDBDIR}/opcodes
-
-PROG= gdbreplay
-BINDIR= /usr/bin
-NOMAN= yes
-
-SRCS= gdbreplay.c
-
-CFLAGS+=-I${.CURDIR}/../gdb -I${.CURDIR}/../bfd
-CFLAGS+=-DNO_MMALLOC
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/binutils/gdbserver/Makefile b/gnu/usr.bin/binutils/gdbserver/Makefile
deleted file mode 100644
index 73abac8..0000000
--- a/gnu/usr.bin/binutils/gdbserver/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id: Makefile,v 1.1.1.1 1997/04/25 22:25:50 pst Exp $
-
-GDBDIR= ${.CURDIR}/../../../../contrib/gdb
-.PATH: ${GDBDIR}/gdb/gdbserver
-.PATH: ${GDBDIR}/gdb
-.PATH: ${GDBDIR}/opcodes
-
-PROG= gdbserver
-BINDIR= /usr/bin
-
-SRCS= remote-utils.c utils.c server.c
-SRCS+= low-fbsd.c
-
-CFLAGS+=-I${.CURDIR}/../gdb -I${.CURDIR}/../bfd
-CFLAGS+=-DNO_MMALLOC
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/binutils/gdbserver/low-fbsd.c b/gnu/usr.bin/binutils/gdbserver/low-fbsd.c
deleted file mode 100644
index bc85f36..0000000
--- a/gnu/usr.bin/binutils/gdbserver/low-fbsd.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/* Low level interface to ptrace, for the remote server for GDB.
- Copyright (C) 1995 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include <sys/wait.h>
-#include "frame.h"
-#include "inferior.h"
-
-#include <stdio.h>
-#include <sys/param.h>
-#include <dirent.h>
-#include <sys/user.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <sgtty.h>
-#include <fcntl.h>
-
-/***************Begin MY defs*********************/
-int quit_flag = 0;
-char registers[REGISTER_BYTES];
-
-/* Index within `registers' of the first byte of the space for
- register N. */
-
-
-char buf2[MAX_REGISTER_RAW_SIZE];
-/***************End MY defs*********************/
-
-#include <sys/ptrace.h>
-#include <machine/reg.h>
-
-extern char **environ;
-extern int inferior_pid;
-void quit (), perror_with_name ();
-int query ();
-
-/* Start an inferior process and returns its pid.
- ALLARGS is a vector of program-name and args.
- ENV is the environment vector to pass. */
-
-int
-create_inferior (program, allargs)
- char *program;
- char **allargs;
-{
- int pid;
-
- pid = fork ();
- if (pid < 0)
- perror_with_name ("fork");
-
- if (pid == 0)
- {
- ptrace (PT_TRACE_ME, 0, 0, 0);
-
- execv (program, allargs);
-
- fprintf (stderr, "Cannot exec %s: %s.\n", program, strerror(errno));
- fflush (stderr);
- _exit (0177);
- }
-
- return pid;
-}
-
-/* Kill the inferior process. Make us have no inferior. */
-
-void
-kill_inferior ()
-{
- if (inferior_pid == 0)
- return;
- ptrace (PT_KILL, inferior_pid, 0, 0);
- wait (0);
- /*************inferior_died ();****VK**************/
-}
-
-/* Return nonzero if the given thread is still alive. */
-int
-mythread_alive (pid)
- int pid;
-{
- return 1;
-}
-
-/* Wait for process, returns status */
-
-unsigned char
-mywait (status)
- char *status;
-{
- int pid;
- int w;
-
- pid = wait (&w);
- if (pid != inferior_pid)
- perror_with_name ("wait");
-
- if (WIFEXITED (w))
- {
- fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w));
- *status = 'W';
- return ((unsigned char) WEXITSTATUS (w));
- }
- else if (!WIFSTOPPED (w))
- {
- fprintf (stderr, "\nChild terminated with signal = %x \n", WTERMSIG (w));
- *status = 'X';
- return ((unsigned char) WTERMSIG (w));
- }
-
- fetch_inferior_registers (0);
-
- *status = 'T';
- return ((unsigned char) WSTOPSIG (w));
-}
-
-/* Resume execution of the inferior process.
- If STEP is nonzero, single-step it.
- If SIGNAL is nonzero, give it that signal. */
-
-void
-myresume (step, signal)
- int step;
- int signal;
-{
- errno = 0;
- ptrace (step ? PT_STEP : PT_CONTINUE, inferior_pid,
- (PTRACE_ARG3_TYPE) 1, signal);
- if (errno)
- perror_with_name ("ptrace");
-}
-
-
-#if !defined (offsetof)
-#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
-#endif
-
-/* U_REGS_OFFSET is the offset of the registers within the u area. */
-#if !defined (U_REGS_OFFSET)
-#define U_REGS_OFFSET \
- ptrace (PT_READ_U, inferior_pid, \
- (PTRACE_ARG3_TYPE) (offsetof (struct user, u_ar0)), 0) \
- - KERNEL_U_ADDR
-#endif
-
-unsigned int
-register_addr (regno, blockend)
- int regno;
- int blockend;
-{
- int addr;
-
- if (regno < 0 || regno >= ARCH_NUM_REGS)
- error ("Invalid register number %d.", regno);
-
- REGISTER_U_ADDR (addr, blockend, regno);
-
- return addr;
-}
-
-/* Fetch one register. */
-
-static void
-fetch_register (regno)
- int regno;
-{
- register unsigned int regaddr;
- char buf[MAX_REGISTER_RAW_SIZE];
- register int i;
-
- /* Offset of registers within the u area. */
- unsigned int offset;
-
- offset = U_REGS_OFFSET;
-
- regaddr = register_addr (regno, offset);
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
- {
- errno = 0;
- *(int *) &registers[ regno * sizeof(int) + i] =
- ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, 0);
- regaddr += sizeof (int);
- if (errno != 0)
- {
- /* Warning, not error, in case we are attached; sometimes the
- kernel doesn't let us at the registers. */
- char *err = strerror (errno);
- char *msg = alloca (strlen (err) + 128);
- sprintf (msg, "reading register %d: %s", regno, err);
- error (msg);
- goto error_exit;
- }
- }
- error_exit:;
-}
-
-/* Fetch all registers, or just one, from the child process. */
-
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- if (regno == -1 || regno == 0)
- for (regno = 0; regno < NUM_REGS; regno++)
- fetch_register (regno);
- else
- fetch_register (regno);
-}
-
-/* Store our register values back into the inferior.
- If REGNO is -1, do this for all registers.
- Otherwise, REGNO specifies which register (so we can save time). */
-
-void
-store_inferior_registers (regno)
- int regno;
-{
- register unsigned int regaddr;
- char buf[80];
- extern char registers[];
- register int i;
- unsigned int offset = U_REGS_OFFSET;
- int scratch;
-
- if (regno >= 0)
- {
- regaddr = register_addr (regno, offset);
- errno = 0;
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int))
- {
- errno = 0;
- ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
- *(int *) &registers[REGISTER_BYTE (regno) + i]);
- if (errno != 0)
- {
- /* Warning, not error, in case we are attached; sometimes the
- kernel doesn't let us at the registers. */
- char *err = strerror (errno);
- char *msg = alloca (strlen (err) + 128);
- sprintf (msg, "writing register %d: %s",
- regno, err);
- error (msg);
- return;
- }
- regaddr += sizeof(int);
- }
- }
- else
- for (regno = 0; regno < NUM_REGS; regno++)
- store_inferior_registers (regno);
-}
-
-/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory
- in the NEW_SUN_PTRACE case.
- It ought to be straightforward. But it appears that writing did
- not write the data that I specified. I cannot understand where
- it got the data that it actually did write. */
-
-/* Copy LEN bytes from inferior's memory starting at MEMADDR
- to debugger memory starting at MYADDR. */
-
-read_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- register int i;
- /* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr & -sizeof (int);
- /* Round ending address up; get number of longwords that makes. */
- register int count
- = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
- /* Allocate buffer of that many longwords. */
- register int *buffer = (int *) alloca (count * sizeof (int));
-
- /* Read all the longwords */
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- buffer[i] = ptrace (PT_READ_I, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
- }
-
- /* Copy appropriate bytes out of the buffer. */
- memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
-}
-
-/* Copy LEN bytes of data from debugger memory at MYADDR
- to inferior's memory at MEMADDR.
- On failure (cannot write the inferior)
- returns the value of errno. */
-
-int
-write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- register int i;
- /* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr & -sizeof (int);
- /* Round ending address up; get number of longwords that makes. */
- register int count
- = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
- /* Allocate buffer of that many longwords. */
- register int *buffer = (int *) alloca (count * sizeof (int));
- extern int errno;
-
- /* Fill start and end extra bytes of buffer with existing memory data. */
-
- buffer[0] = ptrace (PT_READ_I, inferior_pid,
- (PTRACE_ARG3_TYPE) addr, 0);
-
- if (count > 1)
- {
- buffer[count - 1]
- = ptrace (PT_READ_I, inferior_pid,
- (PTRACE_ARG3_TYPE) addr + (count - 1) * sizeof (int), 0);
- }
-
- /* Copy data to be written over corresponding part of buffer */
-
- memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
-
- /* Write the entire buffer. */
-
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- errno = 0;
- ptrace (PT_WRITE_I, inferior_pid, (PTRACE_ARG3_TYPE) addr, buffer[i]);
- if (errno)
- return errno;
- }
-
- return 0;
-}
-
-void
-initialize ()
-{
- inferior_pid = 0;
-}
-
-int
-have_inferior_p ()
-{
- return inferior_pid != 0;
-}
-
-/* Some systems don't provide all the registers on a trap. Use SS as a
- default if so. */
-
-#ifndef tDS
-#define tDS tSS
-#endif
-#ifndef tES
-#define tES tSS
-#endif
-#ifndef tFS
-#define tFS tSS
-#endif
-#ifndef tGS
-#define tGS tSS
-#endif
-
-/* These tables map between the registers on a trap frame, and the register
- order used by the rest of GDB. */
-/* this table must line up with REGISTER_NAMES in tm-i386.h */
-/* symbols like 'tEAX' come from <machine/reg.h> */
-static int tregmap[] =
-{
- tEAX, tECX, tEDX, tEBX,
- tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS,
- tDS, tES, tFS, tGS
-};
-
-#ifdef sEAX
-static int sregmap[] =
-{
- sEAX, sECX, sEDX, sEBX,
- sESP, sEBP, sESI, sEDI,
- sEIP, sEFLAGS, sCS, sSS
-};
-#else /* No sEAX */
-
-/* FreeBSD has decided to collapse the s* and t* symbols. So if the s*
- ones aren't around, use the t* ones for sregmap too. */
-
-static int sregmap[] =
-{
- tEAX, tECX, tEDX, tEBX,
- tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS,
- tDS, tES, tFS, tGS
-};
-#endif /* No sEAX */
-
-/* blockend is the value of u.u_ar0, and points to the
- place where ES is stored. */
-
-int
-i386_register_u_addr (blockend, regnum)
- int blockend;
- int regnum;
-{
- /* The following condition is a kludge to get at the proper register map
- depending upon the state of pcb_flag.
- The proper condition would be
- if (u.u_pcb.pcb_flag & FM_TRAP)
- but that would require a ptrace call here and wouldn't work
- for corefiles. */
-
- if (blockend < 0x1fcc)
- return (blockend + 4 * tregmap[regnum]);
- else
- return (blockend + 4 * sregmap[regnum]);
-}
diff --git a/gnu/usr.bin/bison/Makefile b/gnu/usr.bin/bison/Makefile
deleted file mode 100644
index 89f0ed5..0000000
--- a/gnu/usr.bin/bison/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-# $Id$
-
-.PATH: ${.CURDIR}/../../../contrib/bison
-
-SUBDIR= data doc
-
-PROG= bison
-MAN1= bison.1
-
-DATADIR= ${SHAREDIR}/misc
-
-CFLAGS+= -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_ALLOCA=1 \
- -DHAVE_STRERROR=1
-CFLAGS+= -DXPFILE=\"${DATADIR}/bison.simple\"
-CFLAGS+= -DXPFILE1=\"${DATADIR}/bison.hairy\"
-
-SRCS+= LR0.c allocate.c closure.c conflicts.c derives.c files.c \
- getargs.c gram.c lalr.c lex.c main.c nullable.c output.c \
- print.c reader.c reduce.c symtab.c warshall.c version.c \
- getopt.c getopt1.c
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/bison/data/Makefile b/gnu/usr.bin/bison/data/Makefile
deleted file mode 100644
index 140a6c4..0000000
--- a/gnu/usr.bin/bison/data/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $Id: Makefile,v 1.5 1997/02/22 15:44:44 peter Exp $
-
-BISONDIR=${.CURDIR}/../../../../contrib/bison
-
-.PATH: ${BISONDIR}
-
-DATADIR= ${SHAREDIR}/misc
-CLEANFILES+= bison.s1
-
-all: bison.s1
-
-# Copy bison.simple, inserting directory name into the #line commands.
-bison.s1: bison.simple
- sed -e "/^#line/ s|bison|${DATADIR}/bison|" \
- < ${BISONDIR}/bison.simple > bison.s1
-
-install:
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m 444 bison.s1 \
- ${DESTDIR}${DATADIR}/bison.simple
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 ${BISONDIR}/bison.hairy \
- ${DESTDIR}${DATADIR}
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/bison/doc/Makefile b/gnu/usr.bin/bison/doc/Makefile
deleted file mode 100644
index 8e29494..0000000
--- a/gnu/usr.bin/bison/doc/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Id$
-
-INFO = bison
-INFOSECTION= "Programming & development tools."
-INFOENTRY_bison= "* Bison: (bison). The GNU YACC-compatible parser generator."
-
-SRCDIR= ${.CURDIR}/../../../../contrib/bison
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/cc/Makefile b/gnu/usr.bin/cc/Makefile
deleted file mode 100644
index 22d967e..0000000
--- a/gnu/usr.bin/cc/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# $Id$
-#
-
-# The order of some of these are rather important. Some depend on previous
-# subdirs.
-
-SUBDIR= cc_tools cc_int cpp cc1 cc cc1obj cc1plus c++ f77 libgcc c++filt doc
-
-.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/cc/Makefile.inc b/gnu/usr.bin/cc/Makefile.inc
deleted file mode 100644
index 1b4fd4e..0000000
--- a/gnu/usr.bin/cc/Makefile.inc
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# $Id: Makefile.inc,v 1.19 1997/02/22 15:44:48 peter Exp $
-#
-
-# Sometimes this is .include'd several times...
-.if !defined(GCCDIR)
-GCCDIR= ${.CURDIR}/../../../../contrib/gcc
-.PATH: ../cc_tools ${GCCDIR} ${GCCDIR}/cp ${GCCDIR}/objc
-
-BISON?= bison
-
-# Machine description.
-MD_FILE= ${GCCDIR}/config/i386/i386.md
-OUT_FILE= i386.c
-OUT_OBJ= i386
-.PATH: ${GCCDIR}/config/i386
-
-# Pick aout for now. the elf config is not binary compatable.
-BINFORMAT?= aout
-#BINFORMAT?= elf
-
-.if ${BINFORMAT} == aout
-CFLAGS+= -DFREEBSD_AOUT
-target= i386-unknown-freebsd
-.endif
-.if ${BINFORMAT} == elf
-CFLAGS+= -DFREEBSD_ELF
-target= i386-unknown-freebsdelf
-.endif
-
-version!= sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/' < ${GCCDIR}/version.c
-
-CFLAGS+= -I${GCCDIR} -I${GCCDIR}/config
-CFLAGS+= -DFREEBSD_NATIVE
-CFLAGS+= -DDEFAULT_TARGET_VERSION=\"$(version)\"
-CFLAGS+= -DDEFAULT_TARGET_MACHINE=\"$(target)\"
-
-.if exists(${.OBJDIR}/../cc_tools)
-CFLAGS+= -I${.OBJDIR}/../cc_tools
-.else
-CFLAGS+= -I${.CURDIR}/../cc_tools
-.endif
-
-.if exists(${.OBJDIR}/../cc_int)
-LIBDESTDIR= ${.OBJDIR}/../cc_int
-.else
-LIBDESTDIR= ${.CURDIR}/../cc_int
-.endif
-
-LIBCC_INT= ${LIBDESTDIR}/libcc_int.a
-
-.endif
diff --git a/gnu/usr.bin/cc/c++/Makefile b/gnu/usr.bin/cc/c++/Makefile
deleted file mode 100644
index 5557c62..0000000
--- a/gnu/usr.bin/cc/c++/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# $Id$
-#
-
-PROG = c++
-SRCS = g++.c
-BINDIR= /usr/bin
-LINKS= ${BINDIR}/c++ ${BINDIR}/g++
-NOMAN= 1
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/c++filt/Makefile b/gnu/usr.bin/cc/c++filt/Makefile
deleted file mode 100644
index 5e801de..0000000
--- a/gnu/usr.bin/cc/c++filt/Makefile
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# $Id$
-#
-
-PROG = c++filt
-SRCS = cplus-dem.c getopt.c getopt1.c
-OBJS+= underscore.o # defeat 'make depend'
-BINDIR= /usr/bin
-NOMAN= 1
-CFLAGS+= -DMAIN -DIN_GCC -DVERSION=\"$(version)\"
-
-
-#
-# XXX This is a hack, but it seems to work. libgcc1.a is supposed to be
-# compiled by the native compiler, and libgcc2.a is meant to be compiled
-# by *this* version of gcc.
-#
-# Normally, this does not make any difference, since we only have gcc, but
-# when bootstrapping from gcc-2.6.3, we have to use the freshly built 2.7.2
-# compiler for some of the libgcc2.c __attribute__ stuff.
-#
-.if exists(${.OBJDIR}/../cc)
-XCC= ${.OBJDIR}/../cc/cc
-.else
-XCC= ${.CURDIR}/../cc/cc
-.endif
-
-.if exists(${.OBJDIR}/../cc1)
-XCC+= -B${.OBJDIR}/../cc1/
-.else
-XCC+= -B${.CURDIR}/../cc1/
-.endif
-
-.if exists(${.OBJDIR}/../cpp)
-XCC+= -B${.OBJDIR}/../cpp/
-.else
-XCC+= -B${.CURDIR}/../cpp/
-.endif
-
-CLEANFILES+= underscore.c
-underscore.o: underscore.c
-
-underscore.c:
- echo "int xxy_us_dummy;" >tmp-dum.c
- ${XCC} -S tmp-dum.c
- echo '/*WARNING: This file is automatically generated!*/' >underscore.c
- if grep _xxy_us_dummy tmp-dum.s > /dev/null ; then \
- echo "int prepends_underscore = 1;" >>underscore.c; \
- else \
- echo "int prepends_underscore = 0;" >>underscore.c; \
- fi
- rm -f tmp-dum.c tmp-dum.s
-
-.include <bsd.prog.mk>
-
diff --git a/gnu/usr.bin/cc/cc/Makefile b/gnu/usr.bin/cc/cc/Makefile
deleted file mode 100644
index 8fd206a..0000000
--- a/gnu/usr.bin/cc/cc/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# $Id$
-#
-
-PROG = cc
-MAN1 = gcc.1
-SRCS = gcc.c
-BINDIR= /usr/bin
-SRCS+= multilib.h obstack.c version.c
-LINKS= ${BINDIR}/cc ${BINDIR}/gcc
-MLINKS= gcc.1 cc.1 gcc.1 c++.1 gcc.1 g++.1
-CLEANFILES+= multilib.h
-
-CFLAGS+= -I. # I mean it!
-CFLAGS+= -I${.CURDIR}
-
-# I have NO idea what this is for, it appears to be m68k specific.
-multilib.h: genmultilib
- sh ${GCCDIR}/genmultilib "$(MULTILIB_OPTIONS)" \
- "$(MULTILIB_DIRNAMES)" "$(MULTILIB_MATCHES)" > multilib.h
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/cc/f2c-specs.h b/gnu/usr.bin/cc/cc/f2c-specs.h
deleted file mode 100644
index 0874d54..0000000
--- a/gnu/usr.bin/cc/cc/f2c-specs.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/***** ljo's Fortran rule *****/
- {".f", "@f2c"},
- {"@f2c",
- "f2c %{checksubscripts:-C} %{I2} %{onetrip} %{honorcase:-U} %{u} %{w}\
- %{ANSIC:-A} %{a} %{C++}\
- %{c} %{E} %{ec} %{ext} %{f} %{72} %{g} %{h} %{i2} %{kr} %{krd}\
- %{P} %{p} %{r} %{r8} %{s} %{w8} %{z} %{N*}\
- %i %{!pipe: -o %g.c} %{pipe:-o -}|\n",
- "cpp -lang-c %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
- %{C:%{!E:%eGNU C does not support -C without using -E}}\
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
- -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
- %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\
- %{!undef:%{!ansi:%p} %P} %{trigraphs} \
- %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
- %{traditional-cpp:-traditional}\
- %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*}\
- %{pipe:-} %{!pipe:%g.c} %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
- "%{!M:%{!MM:%{!E:cc1 %{!pipe:%g.i} %1 \
- %{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a}\
- %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \
- %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
- %{aux-info*}\
- %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
- %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
- %{!S:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
- %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%u.o}\
- %{!pipe:%g.s} %A\n }}}}"},
-/***** End of ljo's Fortran rule *****/
diff --git a/gnu/usr.bin/cc/cc1/Makefile b/gnu/usr.bin/cc/cc1/Makefile
deleted file mode 100644
index 9be4343..0000000
--- a/gnu/usr.bin/cc/cc1/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# $Id: Makefile,v 1.11 1997/02/22 15:44:53 peter Exp $
-#
-
-PROG = cc1
-SRCS = c-parse.c \
- c-aux-info.c c-convert.c c-decl.c c-iterate.c c-lang.c c-lex.c \
- c-typeck.c
-BINDIR= /usr/libexec
-NOMAN= 1
-NOSHARED=yes
-DPADD+= ${LIBCC_INT}
-LDADD+= ${LIBCC_INT}
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/cc1obj/Makefile b/gnu/usr.bin/cc/cc1obj/Makefile
deleted file mode 100644
index 05aac08..0000000
--- a/gnu/usr.bin/cc/cc1obj/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# $Id: Makefile,v 1.4 1997/02/22 15:44:54 peter Exp $
-#
-
-PROG = cc1obj
-SRCS = objc-parse.c objc-act.c
-# Ugh, compiled twice...
-SRCS += c-aux-info.c c-convert.c c-decl.c c-iterate.c c-lex.c c-typeck.c
-BINDIR= /usr/libexec
-NOMAN= 1
-NOSHARED=yes
-DPADD+= ${LIBCC_INT}
-LDADD+= ${LIBCC_INT}
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/cc1plus/Makefile b/gnu/usr.bin/cc/cc1plus/Makefile
deleted file mode 100644
index 5143507..0000000
--- a/gnu/usr.bin/cc/cc1plus/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# $Id: Makefile,v 1.12 1997/06/29 06:03:27 pst Exp $
-#
-
-#First, so that we get cp/tree.c and cp/expr.c instead of the C version
-.PATH: ${.CURDIR}/../../../../contrib/gcc/cp
-
-PROG = cc1plus
-SRCS = parse.c parse.h \
- call.c class.c cvt.c decl.c decl2.c edsel.c errfn.c \
- error.c except.c expr.c gc.c init.c lex.c method.c pt.c \
- ptree.c repo.c search.c sig.c spew.c tree.c typeck.c typeck2.c xref.c
-BINDIR= /usr/libexec
-NOMAN= 1
-NOSHARED=yes
-DPADD+= ${LIBCC_INT}
-LDADD+= ${LIBCC_INT}
-CFLAGS+= -I. # I mean it.
-
-.ORDER: parse.c parse.h
-parse.c parse.h: parse.y
- ${BISON} -d ${GCCDIR}/cp/parse.y -o parse.c
- grep '^#define[ ]*YYEMPTY' parse.c >>parse.h
-
-CLEANFILES+= parse.c parse.h
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/cc_int/Makefile b/gnu/usr.bin/cc/cc_int/Makefile
deleted file mode 100644
index 3b085c6..0000000
--- a/gnu/usr.bin/cc/cc_int/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# $Id$
-#
-.include "../Makefile.inc"
-
-SRCS= bc-emit.c bc-optab.c \
- c-common.c c-pragma.c \
- caller-save.c calls.c combine.c convert.c cse.c \
- dbxout.c dwarfout.c emit-rtl.c explow.c expmed.c expr.c \
- final.c flow.c fold-const.c function.c getpwd.c global.c \
- insn-attrtab.c insn-emit.c insn-extract.c insn-opinit.c \
- insn-output.c insn-peep.c insn-recog.c \
- integrate.c jump.c local-alloc.c loop.c obstack.c optabs.c \
- print-rtl.c print-tree.c real.c recog.c reg-stack.c regclass.c \
- reload.c reload1.c reorg.c rtl.c rtlanal.c \
- sched.c sdbout.c stmt.c stor-layout.c stupid.c \
- toplev.c tree.c unroll.c varasm.c version.c xcoffout.c \
- ${OUT_FILE}
-
-LIB= cc_int
-NOPROFILE= YES
-NOPIC= YES
-
-install:
- @true
-
-${OUT_OBJ}.o ${OUT_OBJ}.so: ${OUT_FILE}
-
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/cc/cc_tools/Makefile b/gnu/usr.bin/cc/cc_tools/Makefile
deleted file mode 100644
index 93d9038..0000000
--- a/gnu/usr.bin/cc/cc_tools/Makefile
+++ /dev/null
@@ -1,156 +0,0 @@
-#
-# $Id: Makefile,v 1.3 1997/02/22 15:44:58 peter Exp $
-#
-
-#
-# This could probably be merged with ../cc_int/Makefile, but bsd.lib.mk
-# is such a !@#!*#% nightmare because of how it reporgrams the dependencies,
-# suffix rules, SRCS, etc. It's easiest to cheat by using bsd.prog.mk and
-# SRCS to get dependencies.
-#
-
-.include "../Makefile.inc"
-
-#-----------------------------------------------------------------------
-# Bytecode components
-
-.for i in arity opcode opname
-bc-$i.h: bi-$i bytecode.def
- ./bi-$i < ${GCCDIR}/bytecode.def > bc-$i.h
-
-bi-$i: bi-$i.o bi-parser.o bi-lexer.o bi-reverse.o
- ${CC} ${.ALLSRC} -o ${.TARGET}
-
-CLEANFILES+= bi-$i bi-$i.o
-SRCS+= bc-$i.h
-
-.endfor
-
-.ORDER: bi-parser.c bi-parser.h
-bi-parser.c bi-parser.h: bi-parser.y
- ${BISON} ${BISONFLAGS} -d ${.ALLSRC} -o bi-parser.c
-
-SRCS+= bi-parser.c bi-parser.h
-
-CLEANFILES+= bi-lexer.o bi-parser.o bi-reverse.o
-
-#-----------------------------------------------------------------------
-# insn-* gunk
-
-.for i in config flags codes attr
-insn-$i.h: gen$i ${MD_FILE}
- ./gen$i ${MD_FILE} > insn-$i.h
-SRCS+= insn-$i.h
-.endfor
-
-.for i in emit recog opinit extract peep attrtab output
-insn-$i.c: gen$i ${MD_FILE}
- ./gen$i ${MD_FILE} > insn-$i.c
-SRCS+= insn-$i.c
-.endfor
-
-.for i in config flags codes emit opinit recog extract peep attr output
-gen$i: gen$i.o rtl.o obstack.o
- ${CC} ${.ALLSRC} -o ${.TARGET}
-
-gen$i.o: gen$i.c ${RTL_H}
-CLEANFILES+= gen$i gen$i.o
-.endfor
-
-.for i in attrtab
-gen$i: gen$i.o rtl.o rtlanal.o print-rtl.o obstack.o
- ${CC} ${.ALLSRC} -o ${.TARGET}
-
-gen$i.o: gen$i.c ${RTL_H}
-CLEANFILES+= gen$i gen$i.o
-.endfor
-
-CLEANFILES+= print-rtl.o rtl.o rtlanal.o obstack.o
-
-#-----------------------------------------------------------------------
-# C hash codes
-c-gperf.h: c-parse.gperf
- gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \
- ${GCCDIR}/c-parse.gperf > ${.TARGET}
-SRCS+= c-gperf.h
-
-#-----------------------------------------------------------------------
-# C++ hash codes
-hash.h: gxx.gperf
- gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
- ${GCCDIR}/cp/gxx.gperf >hash.h
-SRCS+= hash.h
-
-#-----------------------------------------------------------------------
-# C parser
-.ORDER: c-parse.c c-parse.h
-c-parse.c c-parse.h: c-parse.in
- sed -e "/^ifobjc$$/,/^end ifobjc$$/d" \
- -e "/^ifc$$/d" -e "/^end ifc$$/d" \
- ${GCCDIR}/c-parse.in > c-parse.y
- ${BISON} -d c-parse.y -o c-parse.c
- rm -f c-parse.y
-
-SRCS+= c-parse.c c-parse.h
-CLEANFILES+= c-parse.y # insurance
-
-#-----------------------------------------------------------------------
-# objc parser
-.ORDER: objc-parse.c objc-parse.h
-objc-parse.c objc-parse.h: c-parse.in
- sed -e "/^ifc$$/,/^end ifc$$/d" \
- -e "/^ifobjc$$/d" -e "/^end ifobjc$$/d" \
- ${GCCDIR}/c-parse.in > objc-parse.y
- ${BISON} -d objc-parse.y -o objc-parse.c
- rm -f objc-parse.y
-
-SRCS+= objc-parse.c objc-parse.h
-CLEANFILES+= objc-parse.y # insurance
-
-#-----------------------------------------------------------------------
-# C++ parser done in it's own makefile
-#-----------------------------------------------------------------------
-# CPP parser done in it's own makefile
-#-----------------------------------------------------------------------
-# All generates sources are cleaned
-CLEANFILES+= ${SRCS}
-
-#-----------------------------------------------------------------------
-all: ${BINFORMAT} ${SRCS}
-
-#-----------------------------------------------------------------------
-# Make 'depend' in compat mode
-.if make(depend)
-.SINGLESHELL:
-.endif
-
-beforedepend: ${BINFORMAT}
-
-#-----------------------------------------------------------------------
-# the host/target compiler config.
-
-aout:
- @rm -f elf
- echo '#include "i386/freebsd.h"' > tm.h
- echo '#include "i386/xm-freebsd.h"' > config.h
- echo '#include "i386/xm-freebsd.h"' > hconfig.h
- echo '#include "i386/xm-freebsd.h"' > tconfig.h
- echo '#include "cp/lang-options.h"' > options.h
- echo '#include "cp/lang-specs.h"' > specs.h
- echo '#include "f2c-specs.h"' >> specs.h
- @touch aout
-
-elf:
- @rm -f aout
- echo '#include "i386/freebsd-elf.h"' > tm.h
- echo '#include "i386/xm-freebsd.h"' > config.h
- echo '#include "i386/xm-freebsd.h"' > hconfig.h
- echo '#include "i386/xm-freebsd.h"' > tconfig.h
- echo '#include "cp/lang-options.h"' > options.h
- echo '#include "cp/lang-specs.h"' > specs.h
- echo '#include "f2c-specs.h"' >> specs.h
- @touch elf
-
-CLEANFILES+= config.h hconfig.h tconfig.h tm.h options.h specs.h elf aout
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/cccp/Makefile b/gnu/usr.bin/cc/cccp/Makefile
deleted file mode 100644
index f2fcf23..0000000
--- a/gnu/usr.bin/cc/cccp/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# $Id: Makefile,v 1.9 1997/02/22 15:44:59 peter Exp $
-#
-
-PROG = cpp
-SRCS = cccp.c cexp.c
-BINDIR= /usr/libexec
-SRCS+= obstack.c version.c
-MAN1= cccp.1
-MLINKS= cccp.1 cpp.1
-
-.ORDER: cexp.c cexp.h
-cexp.c cexp.h: cexp.y
- ${BISON} -d ${GCCDIR}/cexp.y -o cexp.c
-
-CLEANFILES+= cexp.c cexp.h
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/cpp/Makefile b/gnu/usr.bin/cc/cpp/Makefile
deleted file mode 100644
index f2fcf23..0000000
--- a/gnu/usr.bin/cc/cpp/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# $Id: Makefile,v 1.9 1997/02/22 15:44:59 peter Exp $
-#
-
-PROG = cpp
-SRCS = cccp.c cexp.c
-BINDIR= /usr/libexec
-SRCS+= obstack.c version.c
-MAN1= cccp.1
-MLINKS= cccp.1 cpp.1
-
-.ORDER: cexp.c cexp.h
-cexp.c cexp.h: cexp.y
- ${BISON} -d ${GCCDIR}/cexp.y -o cexp.c
-
-CLEANFILES+= cexp.c cexp.h
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/doc/Makefile b/gnu/usr.bin/cc/doc/Makefile
deleted file mode 100644
index 6d3b48c..0000000
--- a/gnu/usr.bin/cc/doc/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id: Makefile,v 1.6 1997/02/22 15:45:03 peter Exp $
-
-INFO = gcc cpp reno gxxint
-
-INFOSECTION= "Gcc Documentation"
-INFOENTRY_gcc= "* gcc: (gcc). The GNU C compiler."
-INFOENTRY_cpp= "* cpp: (cpp). The GNU C pre-processor."
-INFOENTRY_gxxint= "* gxxint: (gxxint). The GNU compiler family internal documentation."
-
-gcc.info: gcc.texi invoke.texi install.texi extend.texi rtl.texi md.texi \
- tm.texi
-
-reno.info: reno.texi templates.texi gpcompare.texi
-
-MAKEINFOFLAGS+= -I ${GCCDIR} -I ${GCCDIR}/cp
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/cc/f77/Makefile b/gnu/usr.bin/cc/f77/Makefile
deleted file mode 100644
index 95cc87c..0000000
--- a/gnu/usr.bin/cc/f77/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# $Id$
-#
-
-PROG = f77
-SRCS = f77.c
-BINDIR= /usr/bin
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/f77/f77.1 b/gnu/usr.bin/cc/f77/f77.1
deleted file mode 100644
index b4e4582..0000000
--- a/gnu/usr.bin/cc/f77/f77.1
+++ /dev/null
@@ -1,69 +0,0 @@
-.\" $Id$
-.\"
-.Dd July 22, 1995
-.Dt F77 1
-.Os FreeBSD
-.Sh NAME
-.Nm f77
-.Nd FORTRAN compiler driver
-.Sh SYNOPSIS
-.Nm f77
-.Op options | files
-.Sh DESCRIPTION
-.Nm f77
-is a simple driver for the FORTRAN compilation process under FreeBSD.
-.Pp
-.Nm f77
-calls the FORTRAN to C translator
-.Nm f2c
-to translate the FORTRAN source to C. Then it calls
-.Nm cc
-to compile the resulting C code and
-.Nm as
-to assemble it. After this stage it may call
-.Nm ld
-to link the resulting object files together with the
-.Nm f2c
-library
-.Nm libf2c
-, the
-.Nm math
-library
-.Nm libm
-and other user specified libraries into an executable. Files ending in other
-suffixes than .f (.o, .c, ...) are also accepted in the commandline and will
-processed by the appropriate program.
-.Pp
-From the user side of view this FORTRAN to C translation is completely
-transparent -
-.Nm f77
-looks like a traditional FORTRAN compiler.
-.Pp
-Available options:
-.Pp
-The options that
-.Nm f77
-recognizes are a superset of the
-.Nm f2c
-and the
-.Nm cc
-options - please refer to their manpages for more details.
-.Pp
-.Sh FILES
-file.f FORTRAN source file
-.Pp
-file.o object file
-.Pp
-a.out link edited output
-.Pp
-/usr/lib/libf2c.a f2c library (contains libF77 and libI77)
-.Pp
-/usr/lib/libf2c.so.x.y shared f2c library
-.Pp
-.Sh SEE ALSO
-.Xr as 1 ,
-.Xr cc 1 ,
-.Xr f2c 1 ,
-.Xr ld 1
-.Sh BUGS
-The input file must end in .f - for instance .for will give problems.
diff --git a/gnu/usr.bin/cc/f77/f77.c b/gnu/usr.bin/cc/f77/f77.c
deleted file mode 100644
index e846af8..0000000
--- a/gnu/usr.bin/cc/f77/f77.c
+++ /dev/null
@@ -1,576 +0,0 @@
-/* f77 driver dervied from g++.c by Jonas Olsson */
-/* converted from gcc-2.6.x(?) derivative to 2.7.2.1 by Peter Wemm */
-
-/* G++ preliminary semantic processing for the compiler driver.
- Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
- Contributed by Brendan Kehoe (brendan@cygnus.com).
-
-This file is part of GNU CC.
-
-GNU CC 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.
-
-GNU CC 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 GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* This program is a wrapper to the main `gcc' driver. For GNU C++,
- we need to do two special things: a) append `-lg++' in situations
- where it's appropriate, to link in libg++, and b) add `-xc++'..`-xnone'
- around file arguments named `foo.c' or `foo.i'. So, we do all of
- this semantic processing then just exec gcc with the new argument
- list.
-
- We used to do all of this in a small shell script, but many users
- found the performance of this as a shell script to be unacceptable.
- In situations where your PATH has a lot of NFS-mounted directories,
- using a script that runs sed and other things would be a nasty
- performance hit. With this program, we never search the PATH at all. */
-
-#include "config.h"
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include <stdio.h>
-#include <sys/types.h>
-#if !defined(_WIN32)
-#include <sys/file.h> /* May get R_OK, etc. on some systems. */
-#else
-#include <process.h>
-#endif
-
-/* Defined to the name of the compiler; if using a cross compiler, the
- Makefile should compile this file with the proper name
- (e.g., "i386-aout-gcc"). */
-#ifndef GCC_NAME
-#define GCC_NAME "gcc"
-#endif
-
-/* This bit is set if we saw a `-xfoo' language specification. */
-#define LANGSPEC (1<<1)
-/* This bit is set if they did `-lm' or `-lmath'. */
-#define MATHLIB (1<<2)
-/* This bit is set if they did `-lf2c'. */
-#define F2CLIB (1<<3)
-
-#ifndef MATH_LIBRARY
-#define MATH_LIBRARY "-lm"
-#endif
-
-/* On MSDOS, write temp files in current dir
- because there's no place else we can expect to use. */
-#ifdef __MSDOS__
-#ifndef P_tmpdir
-#define P_tmpdir "."
-#endif
-#ifndef R_OK
-#define R_OK 4
-#define W_OK 2
-#define X_OK 1
-#endif
-#endif
-
-#ifndef VPROTO
-#ifdef __STDC__
-#define PVPROTO(ARGS) ARGS
-#define VPROTO(ARGS) ARGS
-#define VA_START(va_list,var) va_start(va_list,var)
-#else
-#define PVPROTO(ARGS) ()
-#define VPROTO(ARGS) (va_alist) va_dcl
-#define VA_START(va_list,var) va_start(va_list)
-#endif
-#endif
-
-#ifndef errno
-extern int errno;
-#endif
-
-extern int sys_nerr;
-#ifndef HAVE_STRERROR
-#if defined(bsd4_4)
-extern const char *const sys_errlist[];
-#else
-extern char *sys_errlist[];
-#endif
-#else
-extern char *strerror();
-#endif
-
-/* Name with which this program was invoked. */
-static char *programname;
-
-char *
-my_strerror(e)
- int e;
-{
-
-#ifdef HAVE_STRERROR
- return strerror(e);
-
-#else
-
- static char buffer[30];
- if (!e)
- return "";
-
- if (e > 0 && e < sys_nerr)
- return sys_errlist[e];
-
- sprintf (buffer, "Unknown error %d", e);
- return buffer;
-#endif
-}
-
-#ifdef HAVE_VPRINTF
-/* Output an error message and exit */
-
-static void
-fatal VPROTO((char *format, ...))
-{
-#ifndef __STDC__
- char *format;
-#endif
- va_list ap;
-
- VA_START (ap, format);
-
-#ifndef __STDC__
- format = va_arg (ap, char*);
-#endif
-
- fprintf (stderr, "%s: ", programname);
- vfprintf (stderr, format, ap);
- va_end (ap);
- fprintf (stderr, "\n");
-#if 0
- /* XXX Not needed for g++ driver. */
- delete_temp_files ();
-#endif
- exit (1);
-}
-
-static void
-error VPROTO((char *format, ...))
-{
-#ifndef __STDC__
- char *format;
-#endif
- va_list ap;
-
- VA_START (ap, format);
-
-#ifndef __STDC__
- format = va_arg (ap, char*);
-#endif
-
- fprintf (stderr, "%s: ", programname);
- vfprintf (stderr, format, ap);
- va_end (ap);
-
- fprintf (stderr, "\n");
-}
-
-#else /* not HAVE_VPRINTF */
-
-static void
-error (msg, arg1, arg2)
- char *msg, *arg1, *arg2;
-{
- fprintf (stderr, "%s: ", programname);
- fprintf (stderr, msg, arg1, arg2);
- fprintf (stderr, "\n");
-}
-
-static void
-fatal (msg, arg1, arg2)
- char *msg, *arg1, *arg2;
-{
- error (msg, arg1, arg2);
-#if 0
- /* XXX Not needed for g++ driver. */
- delete_temp_files ();
-#endif
- exit (1);
-}
-
-#endif /* not HAVE_VPRINTF */
-
-/* More 'friendly' abort that prints the line and file.
- config.h can #define abort fancy_abort if you like that sort of thing. */
-
-void
-fancy_abort ()
-{
- fatal ("Internal f77 abort.");
-}
-
-char *
-xmalloc (size)
- unsigned size;
-{
- register char *value = (char *) malloc (size);
- if (value == 0)
- fatal ("virtual memory exhausted");
- return value;
-}
-
-/* Return a newly-allocated string whose contents concatenate those
- of s1, s2, s3. */
-static char *
-concat (s1, s2, s3)
- char *s1, *s2, *s3;
-{
- int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
- char *result = xmalloc (len1 + len2 + len3 + 1);
-
- strcpy (result, s1);
- strcpy (result + len1, s2);
- strcpy (result + len1 + len2, s3);
- *(result + len1 + len2 + len3) = 0;
-
- return result;
-}
-
-static void
-pfatal_with_name (name)
- char *name;
-{
- fatal (concat ("%s: ", my_strerror (errno), ""), name);
-}
-
-#ifdef __MSDOS__
-/* This is the common prefix we use to make temp file names. */
-char *temp_filename;
-
-/* Length of the prefix. */
-int temp_filename_length;
-
-/* Compute a string to use as the base of all temporary file names. */
-static char *
-choose_temp_base_try (try, base)
-char *try;
-char *base;
-{
- char *rv;
- if (base)
- rv = base;
- else if (try == (char *)0)
- rv = 0;
- else if (access (try, R_OK | W_OK) != 0)
- rv = 0;
- else
- rv = try;
- return rv;
-}
-
-static void
-choose_temp_base ()
-{
- char *base = 0;
- int len;
-
- base = choose_temp_base_try (getenv ("TMPDIR"), base);
- base = choose_temp_base_try (getenv ("TMP"), base);
- base = choose_temp_base_try (getenv ("TEMP"), base);
-
-#ifdef P_tmpdir
- base = choose_temp_base_try (P_tmpdir, base);
-#endif
-
- base = choose_temp_base_try ("/usr/tmp", base);
- base = choose_temp_base_try ("/tmp", base);
-
- /* If all else fails, use the current directory! */
- if (base == (char *)0)
- base = "./";
-
- len = strlen (base);
- temp_filename = xmalloc (len + sizeof("/ccXXXXXX"));
- strcpy (temp_filename, base);
- if (len > 0 && temp_filename[len-1] != '/')
- temp_filename[len++] = '/';
- strcpy (temp_filename + len, "ccXXXXXX");
-
- mktemp (temp_filename);
- temp_filename_length = strlen (temp_filename);
- if (temp_filename_length == 0)
- abort ();
-}
-
-static void
-perror_exec (name)
- char *name;
-{
- char *s;
-
- if (errno < sys_nerr)
- s = concat ("installation problem, cannot exec %s: ",
- my_strerror( errno ), "");
- else
- s = "installation problem, cannot exec %s";
- error (s, name);
-}
-
-/* This is almost exactly what's in gcc.c:pexecute for MSDOS. */
-void
-run_dos (program, argv)
- char *program;
- char *argv[];
-{
- char *scmd, *rf;
- FILE *argfile;
- int i;
-
- choose_temp_base (); /* not in gcc.c */
-
- scmd = (char *) malloc (strlen (program) + strlen (temp_filename) + 10);
- rf = scmd + strlen (program) + 6;
- sprintf (scmd, "%s.exe @%s.gp", program, temp_filename);
-
- argfile = fopen (rf, "w");
- if (argfile == 0)
- pfatal_with_name (rf);
-
- for (i=1; argv[i]; i++)
- {
- char *cp;
- for (cp = argv[i]; *cp; cp++)
- {
- if (*cp == '"' || *cp == '\'' || *cp == '\\' || isspace (*cp))
- fputc ('\\', argfile);
- fputc (*cp, argfile);
- }
- fputc ('\n', argfile);
- }
- fclose (argfile);
-
- i = system (scmd);
-
- remove (rf);
-
- if (i == -1)
- perror_exec (program);
-}
-#endif /* __MSDOS__ */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- register int i, j = 0;
- register char *p;
- int verbose = 0;
-
- /* This will be 0 if we encounter a situation where we should not
- link in libf2c */
- int library = 1;
-
- /* Used to track options that take arguments, so we don't go wrapping
- those with -xf2c/-xnone. */
- char *quote = NULL;
-
- /* The new argument list will be contained in this. */
- char **arglist;
-
- /* The name of the compiler we will want to run---by default, it
- will be the definition of `GCC_NAME', e.g., `gcc'. */
- char *gcc = GCC_NAME;
-
- /* Non-zero if we saw a `-xfoo' language specification on the
- command line. Used to avoid adding our own -xf2c if the user
- already gave a language for the file. */
- int saw_speclang = 0;
-
- /* Non-zero if we saw `-lm' or `-lmath' on the command line. */
- char *saw_math = 0;
-
- /* The number of arguments being added to what's in argv, other than
- libraries. We use this to track the number of times we've inserted
- -xf2c/-xnone. */
- int added = 0;
-
- /* An array used to flag each argument that needs a bit set for
- LANGSPEC or MATHLIB. */
- int *args;
-
- p = argv[0] + strlen (argv[0]);
-
- while (p != argv[0] && p[-1] != '/')
- --p;
- programname = p;
-
- if (argc == 1)
- fatal ("No input files specified");
-
-#ifndef __MSDOS__
- /* We do a little magic to find out where the main gcc executable
- is. If they ran us as /usr/local/bin/f77, then we will look
- for /usr/local/bin/gcc; similarly, if they just ran us as `f77',
- we'll just look for `gcc'. */
- if (p != argv[0])
- {
- *--p = '\0';
- gcc = (char *) malloc ((strlen (argv[0]) + 1 + strlen (GCC_NAME) + 1)
- * sizeof (char));
- sprintf (gcc, "%s/%s", argv[0], GCC_NAME);
- }
-#endif
-
- args = (int *) malloc (argc * sizeof (int));
- bzero (args, argc * sizeof (int));
-
- for (i = 1; i < argc; i++)
- {
- /* If the previous option took an argument, we swallow it here. */
- if (quote)
- {
- quote = NULL;
- continue;
- }
-
- if (argv[i][0] == '\0' || argv[i][1] == '\0')
- continue;
-
- if (argv[i][0] == '-')
- {
- if (library != 0 && strcmp (argv[i], "-nostdlib") == 0)
- {
- library = 0;
- }
- else if (strcmp (argv[i], "-lm") == 0
- || strcmp (argv[i], "-lmath") == 0)
- args[i] |= MATHLIB;
- else if (strcmp (argv[i], "-v") == 0)
- {
- verbose = 1;
- if (argc == 2)
- {
- /* If they only gave us `-v', don't try to link
- in libf2c. */
- library = 0;
- }
- }
- else if (strncmp (argv[i], "-x", 2) == 0)
- saw_speclang = 1;
- else if (((argv[i][2] == '\0'
- && (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL)
- || strcmp (argv[i], "-Tdata") == 0))
- quote = argv[i];
- else if (library != 0 && ((argv[i][2] == '\0'
- && (char *) strchr ("cSEM", argv[i][1]) != NULL)
- || strcmp (argv[i], "-MM") == 0))
- {
- /* Don't specify libraries if we won't link, since that would
- cause a warning. */
- library = 0;
- }
- else
- /* Pass other options through. */
- continue;
- }
- else
- {
- int len;
-
- if (saw_speclang)
- continue;
-
- /* If the filename ends in .c or .i, put options around it.
- But not if a specified -x option is currently active. */
- len = strlen (argv[i]);
- if (len > 2
- && (argv[i][len - 1] == 'c' || argv[i][len - 1] == 'i')
- && argv[i][len - 2] == '.')
- {
- args[i] |= LANGSPEC;
- added += 2;
- }
- }
- }
-
- if (quote)
- fatal ("argument to `%s' missing\n", quote);
-
- if (added || library)
- {
- arglist = (char **) malloc ((argc + added + 4) * sizeof (char *));
-
- for (i = 1, j = 1; i < argc; i++, j++)
- {
- arglist[j] = argv[i];
-
- /* Make sure -lf2c is before the math library, since libf2c
- itself uses those math routines. */
- if (!saw_math && (args[i] & MATHLIB) && library)
- {
- --j;
- saw_math = argv[i];
- }
- /* ljo: We want .i and .c treated as C, so don't do anything */
-#if 0
- /* Wrap foo.c and foo.i files in a language specification to
- force the gcc compiler driver to run cc1plus on them. */
- if (args[i] & LANGSPEC)
- {
- int len = strlen (argv[i]);
- if (argv[i][len - 1] == 'i')
- arglist[j++] = "-xc++-cpp-output";
- else
- arglist[j++] = "-xc++";
- arglist[j++] = argv[i];
- arglist[j] = "-xnone";
- }
-#endif
- }
-
- /* Add `-lf2c' if we haven't already done so. */
- if (library)
- arglist[j++] = "-lf2c";
- if (saw_math)
- arglist[j++] = saw_math;
- else if (library)
- arglist[j++] = MATH_LIBRARY;
-
- arglist[j] = NULL;
- }
- else
- /* No need to copy 'em all. */
- arglist = argv;
-
- arglist[0] = gcc;
-
- if (verbose)
- {
- if (j == 0)
- j = argc;
-
- for (i = 0; i < j; i++)
- fprintf (stderr, " %s", arglist[i]);
- fprintf (stderr, "\n");
- }
-#if !defined(OS2) && !defined (_WIN32)
-#ifdef __MSDOS__
- run_dos (gcc, arglist);
-#else /* !__MSDOS__ */
- if (execvp (gcc, arglist) < 0)
- pfatal_with_name (gcc);
-#endif /* __MSDOS__ */
-#else /* OS2 or _WIN32 */
- if (spawnvp (1, gcc, arglist) < 0)
- pfatal_with_name (gcc);
-#endif
-
- return 0;
-}
diff --git a/gnu/usr.bin/cc/libgcc/Makefile b/gnu/usr.bin/cc/libgcc/Makefile
deleted file mode 100644
index f9a1c3d..0000000
--- a/gnu/usr.bin/cc/libgcc/Makefile
+++ /dev/null
@@ -1,95 +0,0 @@
-#
-# $Id$
-#
-
-LIB= gcc
-
-# Install libgcc_pic.a, since ld.so uses it.
-INSTALL_PIC_ARCHIVE= yes
-
-#
-# XXX This is a hack, but it seems to work. libgcc1.a is supposed to be
-# compiled by the native compiler, and libgcc2.a is meant to be compiled
-# by *this* version of gcc.
-#
-# Normally, this does not make any difference, since we only have gcc, but
-# when bootstrapping from gcc-2.6.3, we have to use the freshly built 2.7.2
-# compiler for some of the libgcc2.c __attribute__ stuff.
-#
-.if exists(${.OBJDIR}/../cc)
-XCC= ${.OBJDIR}/../cc/cc
-.else
-XCC= ${.CURDIR}/../cc/cc
-.endif
-
-.if exists(${.OBJDIR}/../cc1)
-XCC+= -B${.OBJDIR}/../cc1/
-.else
-XCC+= -B${.CURDIR}/../cc1/
-.endif
-
-.if exists(${.OBJDIR}/../cpp)
-XCC+= -B${.OBJDIR}/../cpp/
-.else
-XCC+= -B${.CURDIR}/../cpp/
-.endif
-
-# Members of libgcc1.a.
-LIB1FUNCS= _mulsi3 _udivsi3 _divsi3 _umodsi3 _modsi3 \
- _lshrsi3 _ashrsi3 _ashlsi3 \
- _divdf3 _muldf3 _negdf2 _adddf3 _subdf3 \
- _fixdfsi _fixsfsi _floatsidf _floatsisf _truncdfsf2 _extendsfdf2 \
- _addsf3 _negsf2 _subsf3 _mulsf3 _divsf3 \
- _eqdf2 _nedf2 _gtdf2 _gedf2 _ltdf2 _ledf2 \
- _eqsf2 _nesf2 _gtsf2 _gesf2 _ltsf2 _lesf2
-
-# Library members defined in libgcc2.c.
-LIB2FUNCS= _muldi3 _divdi3 _moddi3 _udivdi3 _umoddi3 _negdi2 \
- _lshrdi3 _ashldi3 _ashrdi3 _ffsdi2 \
- _udiv_w_sdiv _udivmoddi4 _cmpdi2 _ucmpdi2 _floatdidf _floatdisf \
- _fixunsdfsi _fixunssfsi _fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi \
- _fixxfdi _fixunsxfdi _floatdixf _fixunsxfsi \
- _fixtfdi _fixunstfdi _floatditf \
- __gcc_bcmp _varargs _eprintf _op_new _op_vnew _new_handler \
- _op_delete \
- _op_vdel _bb _shtab _clear_cache _trampoline __main _exit _ctors \
- _eh _pure
-
-LIB1OBJS=${LIB1FUNCS:T:S@$@.o@}
-LIB2OBJS=${LIB2FUNCS:T:S@$@.o@}
-LIB1SOBJS=${LIB1FUNCS:T:S@$@.so@}
-LIB2SOBJS=${LIB2FUNCS:T:S@$@.so@}
-P1OBJS=${LIB1FUNCS:T:S@$@.po@}
-P2OBJS=${LIB2FUNCS:T:S@$@.po@}
-
-OBJS= ${LIB1OBJS} ${LIB2OBJS}
-
-${LIB1OBJS}: libgcc1.c
- ${CC} -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc1.c
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-${LIB2OBJS}: libgcc2.c
- ${XCC} -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc2.c
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-.if !defined(NOPIC)
-${LIB1SOBJS}: libgcc1.c
- ${CC} -c -fpic ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc1.c
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-
-${LIB2SOBJS}: libgcc2.c
- ${XCC} -c -fpic ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc2.c
- @${LD} -O ${.TARGET} -x -r ${.TARGET}
-.endif
-
-.if !defined(NOPROFILE)
-${P1OBJS}: libgcc1.c
- ${CC} -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc1.c
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-
-${P2OBJS}: libgcc2.c
- ${XCC} -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/libgcc2.c
- @${LD} -O ${.TARGET} -X -r ${.TARGET}
-.endif
-
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/cpio/Makefile b/gnu/usr.bin/cpio/Makefile
deleted file mode 100644
index 3030eee..0000000
--- a/gnu/usr.bin/cpio/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# Note that this files is under a "BSD" copyright (c) by David O'Brien 1997,
-# even though it may live in src/gnu/...
-
-# $Id: Makefile,v 1.2 1997/03/30 00:23:37 obrien Exp $
-
-.PATH: ${.CURDIR}/../../../contrib/cpio
-
-SUBDIR= doc
-
-PROG= cpio
-MAN1= cpio.1
-
-CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../../../contrib/cpio
-CFLAGS+= -DRETSIGTYPE=void -DHAVE_SYS_MTIO_H=1 -DSTDC_HEADERS=1 \
- -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_FCNTL_H=1 -DHAVE_UTIME_H=1 \
- -DHAVE_STRERROR=1 -DHAVE_VPRINTF=1 -DDIRENT=1 -DHAVE_LCHOWN \
- -DHAVE_SYS_PARAM_H=1
-
-SRCS = copyin.c copyout.c copypass.c defer.c dirname.c dstring.c error.c \
- filemode.c getopt.c getopt1.c global.c idcache.c main.c makepath.c \
- rtapelib.c stripslash.c tar.c userspec.c util.c version.c \
- xmalloc.c xstrdup.c
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cpio/doc/Makefile b/gnu/usr.bin/cpio/doc/Makefile
deleted file mode 100644
index e18df63..0000000
--- a/gnu/usr.bin/cpio/doc/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# Note that this files is under a "BSD" copyright (c) by David O'Brien 1997,
-# even though it may live in src/gnu/...
-
-# $Id: Makefile,v 1.1 1997/04/03 11:20:39 obrien Exp $
-
-.PATH: ${.CURDIR}/../../../../contrib/cpio
-
-INFO = cpio
-
-INFOSECTION= "Cpio Documentation"
-INFOENTRY_cpio="* CPIO: (cpio). Making tape (or disk) archives."
-
-SRCDIR= ${.CURDIR}/../../../../contrib/cpio
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/cvs/Makefile b/gnu/usr.bin/cvs/Makefile
deleted file mode 100644
index 70ba49f..0000000
--- a/gnu/usr.bin/cvs/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $Id$
-
-SUBDIR = lib cvs contrib cvsbug doc tools
-
-.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/cvs/Makefile.inc b/gnu/usr.bin/cvs/Makefile.inc
deleted file mode 100644
index e8a0c54..0000000
--- a/gnu/usr.bin/cvs/Makefile.inc
+++ /dev/null
@@ -1,17 +0,0 @@
-.if !defined(CVSDIR)
-
-CVSDIR= $(.CURDIR)/../../../../contrib/cvs
-
-.if exists(${.OBJDIR}/../lib)
-LIBDESTDIR= ${.OBJDIR}/../lib
-.else
-LIBDESTDIR= ${.CURDIR}/../lib
-.endif
-
-LIBCVS= ${LIBDESTDIR}/libcvs.a
-
-.if exists(${.CURDIR}/../../Makefile.inc)
-.include "${.CURDIR}/../../Makefile.inc"
-.endif
-
-.endif
diff --git a/gnu/usr.bin/cvs/contrib/Makefile b/gnu/usr.bin/cvs/contrib/Makefile
deleted file mode 100644
index efb912b..0000000
--- a/gnu/usr.bin/cvs/contrib/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-# $Id: Makefile,v 1.9 1997/02/22 15:45:11 peter Exp $
-
-.include "${.CURDIR}/../Makefile.inc"
-
-.PATH: ${CVSDIR}/contrib
-.PATH: ${CVSDIR}/man
-
-SCRIPTS= clmerge cln_hist commit_prep cvs2vendor cvs_acls cvscheck \
- log log_accum mfpipe rcs-to-cvs rcs2log rcslock sccs2rcs \
- easy-import
-
-FILES= README cvscheck.man cvshelp.man descend.man intro.doc
-
-EXAMPDIR= /usr/share/examples/cvs
-PERLPATH= /usr/bin/perl
-CLEANFILES+= $(SCRIPTS)
-
-.SUFFIXES: .sh .csh .pl
-
-all: ${SCRIPTS}
-
-.sh:
- cp $< $@
-
-.csh:
- sed -e 's,xCSH_PATHx,/bin/csh,' $< > $@
-
-.pl:
- sed -e 's,xPERL_PATHx,$(PERLPATH),' $< > $@
-
-
-beforeinstall:
-.for file in ${SCRIPTS}
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${file} ${DESTDIR}${EXAMPDIR}/contrib
-.endfor
-.for file in ${FILES}
- cd ${.CURDIR} ; \
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
- ${CVSDIR}/contrib/${file} ${DESTDIR}${EXAMPDIR}/contrib
-.endfor
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cvs/contrib/easy-import.pl b/gnu/usr.bin/cvs/contrib/easy-import.pl
deleted file mode 100644
index 4a13714..0000000
--- a/gnu/usr.bin/cvs/contrib/easy-import.pl
+++ /dev/null
@@ -1,403 +0,0 @@
-#! xPERL_PATHx
-#
-# Support for importing a source collection into CVS.
-# Tries to prevent the user from the most common pitfalls (like creating
-# new top-level repositories or second-level areas accidentally), and
-# cares to do some of the `dirty' work like maintaining the modules
-# database accordingly.
-#
-# Written by Jörg Wunsch, 95/03/07, and placed in the public domain.
-#
-# $Id: easy-import.pl,v 1.13 1997/06/09 10:08:07 jmg Exp $
-
-require "complete.pl";
-require "getopts.pl";
-
-
-sub scan_opts
-{
- local($status);
-
- $status = &Getopts("nv");
-
- $dont_do_it = "-n" if $opt_n;
- if($opt_v) {
- print STDERR '$Source: /home/ncvs/src/gnu/usr.bin/cvs/contrib/easy-import.pl,v $ $Revision: 1.13 $' . "\n"; # 'emacs kludge
- exit 0;
- }
- die "usage: $0 [-v] [-n] [moduledir]\n" .
- " -n: don't do any commit, show only\n" .
- " -v: show program version\n"
- unless $status && $#ARGV <= 0;
-
- if($#ARGV == 0) {
- $moduledir = $ARGV[0];
- shift;
- }
-}
-
-sub lsdir
-{
- # find all subdirectories under @_
- # ignore all CVS entries, dot entries, and non-directories
-
- local($base) = @_;
- local(@ls, @rv, $fname);
-
- opendir(DIR, $base) || die "Cannot find dir $base.\n";
-
- @ls = readdir(DIR);
- closedir(DIR);
-
- @rv = ();
-
- foreach $fname (@ls) {
- next if $fname =~ /^CVS/ || $fname eq "Attic"
- || $fname =~ /^\./ || ! -d "$base/$fname";
- @rv = (@rv, $fname);
- }
-
- return sort(@rv);
-}
-
-
-sub contains
-{
- # look if the first parameter is contained in the list following it
- local($item, @list) = @_;
- local($found, $i);
-
- $found = 0;
- foreach $i (@list) {
- return 1 if $i eq $item;
- }
- return 0;
-}
-
-
-
-sub term_init
-{
- # first, get some terminal attributes
-
- # try bold mode first
- $so = `tput md`; $se = `tput me`;
-
- # if no bold mode available, use standout mode
- if ($so eq "") {
- $so = `tput so`; $se = `tput se`;
- }
-
- # try if we can underscore
- $us = `tput us`; $ue = `tput ue`;
- # if we don't have it available, or same as bold/standout, disable it
- if ($us eq "" || $us eq $so) {
- $us = $ue = "";
- }
-
- # look how many columns we've got
- if($ENV{'COLUMNS'} ne "") {
- $columns = $ENV{'COLUMNS'};
- } elsif(-t STDIN) { # if we operate on a terminal...
- local($word, $tmp);
-
- open(STTY, "stty -a|");
- $_ = <STTY>; # try getting the tty win structure value
- close(STTY);
- chop;
- $columns = 0;
- foreach $word (split) {
- $columns = $tmp if $word eq "columns;"; # the number preceding
- $tmp = $word;
- }
- } else {
- $columns = 80;
- }
- # sanity
- $columns = 80 unless $columns >= 5;
-}
-
-
-sub list
-{
- # pretty-print a list
- # imports: global variable $columns
- local(@items) = @_;
- local($longest,$i,$item,$cols,$width);
-
- # find the longest item
- $longest = 0;
- foreach $item (@items) {
- $i = length($item);
- $longest = $i if $longest < $i;
- }
- $width = $longest + 1;
- $cols = int($columns / $width);
-
- $i = 0;
- foreach $item (@items) {
- print $item;
- if(++$i == $cols) {
- $i = 0; print "\n";
- } else {
- print ' ' x ($width - length($item));
- }
- }
- print "\n" unless $i == 0;
-}
-
-sub cvs_init
-{
- # get the CVS repository(s)
-
- die "You need to have the \$CVSROOT variable set.\n"
- unless $ENV{'CVSROOT'} ne "";
-
- # get the list of available repositories
- $cvsroot = $ENV{'CVSROOT'};
- $cvsroot = (split(/:/, $cvsroot, 2))[1] if $cvsroot =~ /:/;
- @reps = &lsdir($cvsroot);
-}
-
-
-sub lsmodules
-{
- # list all known CVS modules
- local(%rv, $mname, $mpath, $_);
-
- %rv = ();
-
- open(CVS, "cvs co -c|");
- while($_ = <CVS>) {
- chop;
- ($mname,$mpath) = split;
- next if $mname eq "";
- $rv{$mname} = $mpath;
- }
- close(CVS);
-
- return %rv;
-}
-
-
-sub checktag
-{
- # check a given string for tag rules
- local($s, $name) = @_;
- local($regexp);
-
- if($name eq "vendor") { $regexp = '^[A-Z][A-Z0-9_]*$'; }
- elsif($name eq "release") { $regexp = '^[a-z][a-z0-9_]*$'; }
- else {
- print STDERR "Internal error: unknown tag name $name\n";
- exit(2);
- }
-
- if($s !~ /$regexp/) {
- print "\a${us}Valid $name tags must match the regexp " .
- "$regexp.${ue}\n";
- return 0;
- }
- if($s =~ /^RELENG/) {
- print "\a${us}Tags must not start with the word \"RELENG\".${ue}\n";
- return 0;
- }
-
- return 1;
-}
-
-
-&scan_opts;
-&term_init;
-&cvs_init;
-
-if(! $moduledir) {
- @dirs = &lsdir(".");
- print "${so}Import from which directory?${se}\n";
- @dirs = (@dirs, ".");
- &list(@dirs);
- $moduledir = &Complete("Which? [.]: ", @dirs);
- $moduledir = "." unless $moduledir ne "";
-}
-
-chdir $moduledir || die "Cannot chdir to $moduledir\n";
-
-print "${so}Available repositories:${se}\n";
-&list(@reps);
-
-# the following kludge prevents the Complete package from starting
-# over with the string just selected; Complete should better provide
-# some reinitialize method
-$Complete'return = ""; $Complete'r = 0;
-
-$selected =
- &Complete("Enter repository (<TAB>=complete, ^D=show): ",
- @reps);
-
-die "\aYou cannot create new repositories with this script.\n"
- unless &contains($selected, @reps);
-
-$rep = $selected;
-
-print "\n${so}Selected repository:${se} ${us}$rep${ue}\n";
-
-
-@areas = &lsdir("$cvsroot/$rep");
-
-print "${so}Existent areas in this repository:${se}\n";
-&list(@areas);
-
-$Complete'return = ""; $Complete'r = 0;
-
-$selected =
- &Complete("Enter area name (<TAB>=complete, ^D=show): ",
- @areas);
-
-print "\a${us}Warning: this will create a new area.${ue}\n"
- unless &contains($selected, @areas);
-
-$area = "$rep/$selected";
-
-print "\n${so}[Working on:${se} ${us}$area${ue}${so}]${se}\n";
-
-%cvsmods = &lsmodules();
-
-for(;;) {
- $| = 1;
- print "${so}Gimme the module name:${se} ";
- $| = 0;
- $modname = <>;
- chop $modname;
- if ($modname eq "") {
- print "\a${us}You cannot use an empty module name.${ue}\n";
- next;
- }
- last if !$cvsmods{$modname};
- print "\a${us}This module name does already exist; do you intend to\n" .
- "perform a vendor-branch import to the existing sources?${ue}: ";
- $rep = <>;
- if ($rep =~ /\s*[yY]/) {
- ($area,$modpath) = split(/\//,$cvsmods{$modname},2);
- $branchimport = 1;
- last;
- }
- print "${us}Choose another name.${ue}\n";
-}
-
-
-if(!$branchimport) {
- for(;;) {
- $| = 1;
- print "${so}Enter the module path:${se} $area/";
- $| = 0;
- $modpath = <>;
- chop $modpath;
- if ($modpath eq "") {
- print "\a${us}You cannot use an empty module path.${ue}\n";
- next;
- }
- last if ! -d "$cvsroot/$area/$modpath";
- print "\a${us}This module path does already exist; " .
- "choose another one.${ue}\n";
- }
-
-
- @newdirs = ();
- $dir1 = "$cvsroot/$area";
- $dir2 = "$area";
-
- @newdirs = (@newdirs, "$dir2") if ! -d $dir1;
-
- foreach $ele (split(/\//, $modpath)) {
- $dir1 = "$dir1/$ele";
- $dir2 = "$dir2/$ele";
- @newdirs = (@newdirs, "$dir2") if ! -d $dir1;
- }
-
- print "${so}You're going to create the following new directories:${se}\n";
-
- &list(@newdirs);
-}
-
-for(;;) {
- $| = 1;
- print "${so}Enter a \`vendor\' tag (e. g. the authors ID):${se} ";
- $| = 0;
- $vtag = <>;
- chop $vtag;
- last if &checktag($vtag, "vendor");
-}
-
-for(;;) {
- $| = 1;
- print "${so}Enter a \`release\' tag (e. g. the version #):${se} ";
- $| = 0;
- $rtag = <>;
- chop $rtag;
- last if &checktag($rtag, "release");
-}
-
-
-$| = 1;
-print "${so}This is your last chance to interrupt, " .
- "hit <return> to go on:${se} ";
-$| = 0;
-<>;
-
-if (!$branchimport) {
- $mod = "";
- foreach $tmp (sort(keys(%cvsmods))) {
- if($tmp gt $modname) {
- $mod = $tmp;
- last;
- }
- }
- if($mod eq "") {
- # we are going to append our module
- $cmd = "\$\na\n";
- } else {
- # we can insert it
- $cmd = "/^${mod}[ \t]/\ni\n";
- }
-
- print "${so}Checking out the modules database...${se}\n";
- system("cvs co modules") && die "${us}failed.\n${ue}";
-
- print "${so}Inserting new module...${se}\n";
- open(ED, "|ed modules/modules") || die "${us}Cannot start ed${ue}\n";
- print(ED "${cmd}${modname} " . ' ' x (15 - length($modname)) .
- "$area/${modpath}\n.\nw\nq\n");
- close(ED);
-
- print "${so}Commiting new modules database...${se}\n";
- system("cvs $dont_do_it commit -m \" " .
- "${modname} --> $area/${modpath}\" modules")
- && die "Commit failed\n";
-
- # we always release "modules" to prevent duplicate
- system("cvs -Q release -d modules");
-}
-
-print "${so}Importing source. Enter a commit message in the editor.${se}\n";
-
-system("cvs $dont_do_it import $area/$modpath $vtag $rtag");
-
-print "${so}You are done now. Go to a different directory, perform a${se}\n".
- "${us}cvs co ${modname}${ue} ${so}command, and see if your new module" .
- " builds ok.${se}\n";
-
-print "\nPlease don't forget to edit the parent Makefile to add what you\n".
- "just imported.\n";
-
-if($dont_do_it) {
-print <<END
-
-
-${so}Since you did not allow to commit anything, you'll have${se}
-${so}to remove the edited modules' database yourself.${se}
-${so}To do this, perform a${se}
-${us}cd ${moduledir}; cvs -Q release -d modules${ue}
-${so}command.${se}
-END
-;
-}
diff --git a/gnu/usr.bin/cvs/cvs/Makefile b/gnu/usr.bin/cvs/cvs/Makefile
deleted file mode 100644
index 4ec4847..0000000
--- a/gnu/usr.bin/cvs/cvs/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-# $Id: Makefile,v 1.18 1997/10/10 04:03:17 peter Exp $
-
-.include "${.CURDIR}/../Makefile.inc"
-
-.PATH: ${CVSDIR}/src
-.PATH: ${CVSDIR}/lib
-.PATH: ${CVSDIR}/man
-
-PROG= cvs
-MAN1= cvs.1
-MAN5= cvs.5
-
-SRCS= add.c admin.c buffer.c checkin.c checkout.c classify.c client.c \
- commit.c create_adm.c cvsrc.c diff.c edit.c entries.c error.c \
- expand_path.c fileattr.c filesubr.c find_names.c hash.c history.c \
- ignore.c import.c lock.c log.c login.c logmsg.c main.c mkmodules.c \
- modules.c myndbm.c no_diff.c parseinfo.c patch.c rcs.c rcscmds.c \
- recurse.c release.c remove.c repos.c root.c rtag.c run.c scramble.c \
- server.c status.c subr.c tag.c update.c vers_ts.c version.c watch.c \
- wrapper.c zlib.c
-
-CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../lib -I${CVSDIR}/src -I${CVSDIR}/lib -DHAVE_CONFIG_H
-
-DPADD+= ${LIBCVS} ${LIBGNUREGEX} ${LIBMD} ${LIBCRYPT} ${LIBZ}
-LDADD+= -L${LIBDESTDIR} -lcvs -lgnuregex -lmd -lcrypt -lz
-
-.if exists(${DESTDIR}/usr/lib/libkrb.a) && defined(MAKE_KERBEROS4)
-CFLAGS+=-DHAVE_KERBEROS -DHAVE_KRB_GET_ERR_TEXT
-LDADD+= -lkrb -ldes
-DPADD+= ${LIBKRB} ${LIBDES}
-DISTRIBUTION= krb
-# XXX do we want to mess with this? It's probably not really worth it for
-# the public freebsd stuff, but others might want it. It's an optional
-# feature anyway, the -x switch is needed to activate it.
-CFLAGS+= -DENCRYPTION
-.endif
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cvs/cvs/options.h b/gnu/usr.bin/cvs/cvs/options.h
deleted file mode 100644
index 476d747..0000000
--- a/gnu/usr.bin/cvs/cvs/options.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright (c) 1992, Brian Berliner and Jeff Polk
- * Copyright (c) 1989-1992, Brian Berliner
- *
- * You may distribute under the terms of the GNU General Public License as
- * specified in the README file that comes with the CVS 1.4 kit.
- *
- * This file holds (most of) the configuration tweaks that can be made to
- * customize CVS for your site. CVS comes configured for a typical SunOS 4.x
- * environment. The comments for each configurable item are intended to be
- * self-explanatory. All #defines are tested first to see if an over-riding
- * option was specified on the "make" command line.
- *
- * If special libraries are needed, you will have to edit the Makefile.in file
- * or the configure script directly. Sorry.
- */
-
-/*
- * CVS provides the most features when used in conjunction with the
- * Version-5 release of RCS. Thus, it is the default. This also
- * assumes that GNU diff Version-1.15 is being used as well -- you
- * will have to configure your RCS V5 release separately to make this
- * the case. If you do not have RCS V5 and GNU diff V1.15, comment out
- * this define. You should not try mixing and matching other
- * combinations of these tools.
- */
-#ifndef HAVE_RCS5
-#define HAVE_RCS5
-#endif
-
-/*
- * For portability and heterogeneity reasons, CVS is shipped by
- * default using my own text-file version of the ndbm database library
- * in the src/myndbm.c file. If you want better performance and are
- * not concerned about heterogeneous hosts accessing your modules
- * file, turn this option off.
- */
-#ifndef MY_NDBM
-#define MY_NDBM
-#endif
-
-/*
- * The "diff" program to execute when creating patch output. This
- * "diff" must support the "-c" option for context diffing. Specify a
- * full pathname if your site wants to use a particular diff. Note
- * that unlike the diff used with RCS, you *must not* supply -a here
- * (doing so will cause the server to generate patches which patch
- * cannot handle in some cases).
- *
- * NOTE: this program is only used for the ``patch'' sub-command (and
- * for ``update'' if you are using the server). The other commands
- * use rcsdiff which will use whatever version of diff was specified
- * when rcsdiff was built on your system.
- */
-#ifndef DIFF
-#define DIFF "diff"
-#endif
-
-/*
- * The "patch" program to run when using the CVS server and accepting
- * patches across the network. Specify a full pathname if your site
- * wants to use a particular patch.
- */
-#ifndef PATCH_PROGRAM
-#define PATCH_PROGRAM "patch"
-#endif
-
-/*
- * By default, RCS programs are executed with the shell or through
- * execlp(), so the user's PATH environment variable is searched. If
- * you'd like to bind all RCS programs to a certain directory (perhaps
- * one not in most people's PATH) then set the default in RCSBIN_DFLT.
- * Note that setting this here will cause all RCS programs to be
- * executed from this directory, unless the user overrides the default
- * with the RCSBIN environment variable or the "-b" option to CVS.
- *
- * If you use the password-authenticating server, then you need to
- * make sure that the server can find the RCS programs to invoke them.
- * The authenticating server starts out running as root, and then
- * switches to run as the appropriate user once authentication is
- * complete. But no actual shell is ever started by that user, so the
- * PATH environment variable may not contain the directory with the
- * RCS binaries, even though if that user logged in normally, PATH
- * would include the directory.
- *
- * One way to solve this problem is to set RCSBIN_DFLT here. An
- * alternative is to make sure that root has the right directory in
- * its path already. Another, probably better alternative is to
- * specify -b in /etc/inetd.conf.
- *
- * You may also have to set RCSBIN_DFLT here if there's no global
- * start-up script run for users by rshd and your RCS programs are not
- * in a directory in the default PATH assigned by rshd.
- *
- * This define should be either the empty string ("") or a full
- * pathname to the directory containing all the installed programs
- * from the RCS distribution.
- */
-#ifndef RCSBIN_DFLT
-#define RCSBIN_DFLT ""
-#endif
-
-/* Directory used for storing temporary files, if not overridden by
- environment variables or the -T global option. There should be little
- need to change this (-T is a better mechanism if you need to use a
- different directory for temporary files). */
-#ifndef TMPDIR_DFLT
-#define TMPDIR_DFLT "/tmp"
-#endif
-
-/*
- * The default editor to use, if one does not specify the "-e" option
- * to cvs, or does not have an EDITOR environment variable. I set
- * this to just "vi", and use the shell to find where "vi" actually
- * is. This allows sites with /usr/bin/vi or /usr/ucb/vi to work
- * equally well (assuming that your PATH is reasonable).
- */
-#ifndef EDITOR_DFLT
-#define EDITOR_DFLT "vi"
-#endif
-
-/*
- * The default umask to use when creating or otherwise setting file or
- * directory permissions in the repository. Must be a value in the
- * range of 0 through 0777. For example, a value of 002 allows group
- * rwx access and world rx access; a value of 007 allows group rwx
- * access but no world access. This value is overridden by the value
- * of the CVSUMASK environment variable, which is interpreted as an
- * octal number.
- */
-#ifndef UMASK_DFLT
-#define UMASK_DFLT 002
-#endif
-
-/*
- * The cvs admin command is restricted to the members of the group
- * CVS_ADMIN_GROUP. If this group does not exist, all users are
- * allowed to run cvs admin. To disable the cvs admin for all users,
- * create an empty group CVS_ADMIN_GROUP. To disable access control
- * for cvs admin, comment out the define below.
- */
-#ifndef CVS_ADMIN_GROUP
-#define CVS_ADMIN_GROUP "cvsadmin"
-#endif
-
-/*
- * The Repository file holds the path to the directory within the
- * source repository that contains the RCS ,v files for each CVS
- * working directory. This path is either a full-path or a path
- * relative to CVSROOT.
- *
- * The only advantage that I can see to having a relative path is that
- * one can change the physical location of the master source
- * repository, change one's CVSROOT environment variable, and CVS will
- * work without problems. I recommend using full-paths.
- */
-#ifndef RELATIVE_REPOS
-/* #define RELATIVE_REPOS */
-#endif
-
-/*
- * When committing or importing files, you must enter a log message.
- * Normally, you can do this either via the -m flag on the command
- * line or an editor will be started for you. If you like to use
- * logging templates (the rcsinfo file within the $CVSROOT/CVSROOT
- * directory), you might want to force people to use the editor even
- * if they specify a message with -m. Enabling FORCE_USE_EDITOR will
- * cause the -m message to be appended to the temp file when the
- * editor is started.
- */
-#ifndef FORCE_USE_EDITOR
-/* #define FORCE_USE_EDITOR */
-#endif
-
-/*
- * When locking the repository, some sites like to remove locks and
- * assume the program that created them went away if the lock has
- * existed for a long time. This used to be the default for previous
- * versions of CVS. CVS now attempts to be much more robust, so lock
- * files should not be left around by mistake. The new behaviour will
- * never remove old locks (they must now be removed by hand).
- * Enabling CVS_FUDGELOCKS will cause CVS to remove locks that are
- * older than CVSLCKAGE seconds.
- *
- * Use of this option is NOT recommended.
- */
-#ifndef CVS_FUDGELOCKS
-/* #define CVS_FUDGELOCKS */
-#endif
-
-/*
- * When committing a permanent change, CVS and RCS make a log entry of
- * who committed the change. If you are committing the change logged
- * in as "root" (not under "su" or other root-priv giving program),
- * CVS/RCS cannot determine who is actually making the change.
- *
- * As such, by default, CVS disallows changes to be committed by users
- * logged in as "root". You can disable this option by commenting out
- * the lines below.
- */
-#ifndef CVS_BADROOT
-#define CVS_BADROOT
-#endif
-
-/* Define this to enable the SETXID support. The way to use this is
- to create a group with no users in it (except perhaps cvs
- administrators), set the cvs executable to setgid that group, chown
- all the repository files to that group, and change all directory
- permissions in the repository to 770. The last person to modify a
- file will own it, but as long as directory permissions are set
- right that won't matter. You'll need a system which inherits file
- groups from the parent directory (WARNING: using the wrong kind of
- system (I think Solaris 2.4 is the wrong kind, for example) will
- create a security hole! You will receive no warning other than the
- fact that files in the working directory are owned by the group
- which cvs is setgid to).
-
- One security hole which has been reported is that setgid is not
- turned off when the editor is invoked--most editors provide a way
- to execute a shell, or the user can specify an editor (this one is
- large enough to drive a truck through). Don't assume that the
- holes described here are the only ones; I don't know how carefully
- SETXID has been inspected for security holes. */
-#ifndef SETXID_SUPPORT
-/* #define SETXID_SUPPORT */
-#endif
-
-/*
- * Should we build the password-authenticating client? Whether to
- * include the password-authenticating _server_, on the other hand, is
- * set in config.h.
- */
-#ifdef CLIENT_SUPPORT
-#define AUTH_CLIENT_SUPPORT 1
-#endif
-
-/*
- * If you are working with a large remote repository and a 'cvs
- * checkout' is swamping your network and memory, define these to
- * enable flow control. You will end up with even less probability of
- * a consistent checkout (see Concurrency in cvs.texinfo), but CVS
- * doesn't try to guarantee that anyway. The master server process
- * will monitor how far it is getting behind, if it reaches the high
- * water mark, it will signal the child process to stop generating
- * data when convenient (ie: no locks are held, currently at the
- * beginning of a new directory). Once the buffer has drained
- * sufficiently to reach the low water mark, it will be signalled to
- * start again. You may override the default hi/low watermarks here
- * too.
- */
-#define SERVER_FLOWCONTROL
-#define SERVER_HI_WATER (2 * 1024 * 1024)
-#define SERVER_LO_WATER (1 * 1024 * 1024)
-
-/* End of CVS configuration section */
-
-/*
- * Externs that are included in libc, but are used frequently enough
- * to warrant defining here.
- */
-#ifndef STDC_HEADERS
-extern void exit ();
-#endif
-
-#ifndef getwd
-extern char *getwd ();
-#endif
-
diff --git a/gnu/usr.bin/cvs/cvsbug/Makefile b/gnu/usr.bin/cvs/cvsbug/Makefile
deleted file mode 100644
index b7714ac..0000000
--- a/gnu/usr.bin/cvs/cvsbug/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-# $Id: Makefile,v 1.7 1997/02/22 15:45:15 peter Exp $
-
-.include "${.CURDIR}/../Makefile.inc"
-
-.PATH: ${CVSDIR}/src
-.PATH: ${CVSDIR}/man
-
-MAN8= cvsbug.8
-
-CLEANFILES+= cvsbug ver
-
-.SUFFIXES: .sh
-
-all: cvsbug
-
-ver: version.c
- echo > ${.TARGET} cvs-`sed < ${.ALLSRC} \
- -e '/version_string/!d' \
- -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
- -e q`
-
-.sh: ver
- sed -e "s,xVERSIONx,`cat ver`,g" ${.IMPSRC} > ${.TARGET}
-
-beforeinstall:
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- cvsbug ${DESTDIR}${BINDIR}/cvsbug
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cvs/doc/Makefile b/gnu/usr.bin/cvs/doc/Makefile
deleted file mode 100644
index 5c6e365..0000000
--- a/gnu/usr.bin/cvs/doc/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $Id$
-
-.include "${.CURDIR}/../Makefile.inc"
-
-SRCDIR= ${CVSDIR}/doc
-
-INFO= cvs cvsclient
-INFOSECTION= "Programming & development tools."
-INFOENTRY_cvs= "* CVS: (cvs). CVS Reference Manual."
-INFOENTRY_cvsclient= "* CVS-CLIENT: (cvsclient). CVS client/server Reference Manual."
-
-
-cvs.info cvsclient.info: CVSvn.texi
-
-CLEANFILES+= CVSvn.texi
-
-CVSvn.texi: ${CVSDIR}/src/version.c
- echo "@set CVSVN `sed < ${CVSDIR}/src/version.c \
- -e '/version_string/!d' \
- -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
- -e q`" > $@
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/cvs/lib/Makefile b/gnu/usr.bin/cvs/lib/Makefile
deleted file mode 100644
index 9c74c4f..0000000
--- a/gnu/usr.bin/cvs/lib/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-# $Id: Makefile,v 1.13 1997/02/22 15:45:20 peter Exp $
-
-.include "${.CURDIR}/../Makefile.inc"
-
-.PATH: ${CVSDIR}/src
-.PATH: ${CVSDIR}/lib
-.PATH: ${CVSDIR}/man
-
-LIB= cvs
-
-NOPROFILE= yes
-NOPIC= yes
-
-CFLAGS+= -I${.CURDIR} -I${CVSDIR}/src -DHAVE_CONFIG_H
-
-SRCS = argmatch.c getdate.y getline.c \
- getopt.c getopt1.c savecwd.c \
- sighandle.c stripslash.c \
- xgetwd.c yesno.c
-
-CLEANFILES+= getdate.c y.tab.h
-
-install:
- @echo -n
-
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/cvs/lib/config.h b/gnu/usr.bin/cvs/lib/config.h
deleted file mode 100644
index e8128f4..0000000
--- a/gnu/usr.bin/cvs/lib/config.h
+++ /dev/null
@@ -1,227 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if on AIX 3.
- System headers sometimes define this.
- We just want to avoid a redefinition error message. */
-#ifndef _ALL_SOURCE
-/* #undef _ALL_SOURCE */
-#endif
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef gid_t */
-
-/* Define if you support file names longer than 14 characters. */
-#define HAVE_LONG_FILE_NAMES 1
-
-/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
-#define HAVE_SYS_WAIT_H 1
-
-/* Define if utime(file, NULL) sets file's timestamp to the present. */
-#define HAVE_UTIME_NULL 1
-
-/* Define if on MINIX. */
-/* #undef _MINIX */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef mode_t */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef pid_t */
-
-/* Define if the system does not provide POSIX.1 features except
- with this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define if you need to in order for stat and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define as the return type of signal handlers (int or void). */
-#define RETSIGTYPE void
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-/* #undef size_t */
-
-/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#define TIME_WITH_SYS_TIME 1
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef uid_t */
-
-/* Define if you have MIT Kerberos version 4 available. */
-/* #undef HAVE_KERBEROS */
-
-/* Define if you want CVS to be able to be a remote repository client. */
-#define CLIENT_SUPPORT 1
-
-/* Define if you want CVS to be able to serve repositories to remote
- clients. */
-#define SERVER_SUPPORT 1
-
-/* Define if you want to use the password authenticated server. */
-#define AUTH_SERVER_SUPPORT 1
-
-/* Define if you want encryption support. */
-/* #undef ENCRYPTION */
-
-/* Define if you have the connect function. */
-/* #undef HAVE_CONNECT */
-
-/* Define if you have the crypt function. */
-#define HAVE_CRYPT 1
-
-/* Define if you have the fchdir function. */
-#define HAVE_FCHDIR 1
-
-/* Define if you have the fchmod function. */
-#define HAVE_FCHMOD 1
-
-/* Define if you have the fsync function. */
-#define HAVE_FSYNC 1
-
-/* Define if you have the ftime function. */
-/* #undef HAVE_FTIME */
-
-/* Define if you have the ftruncate function. */
-#define HAVE_FTRUNCATE 1
-
-/* Define if you have the getpagesize function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define if you have the getspnam function. */
-/* #undef HAVE_GETSPNAM */
-
-/* Define if you have the initgroups function. */
-#define HAVE_INITGROUPS 1
-
-/* Define if you have the krb_get_err_text function. */
-/* #undef HAVE_KRB_GET_ERR_TEXT */
-
-/* Define if you have the mkfifo function. */
-#define HAVE_MKFIFO 1
-
-/* Define if you have the mktemp function. */
-#define HAVE_MKTEMP 1
-
-/* Define if you have the putenv function. */
-#define HAVE_PUTENV 1
-
-/* Define if you have the readlink function. */
-#define HAVE_READLINK 1
-
-/* Define if you have the sigaction function. */
-#define HAVE_SIGACTION 1
-
-/* Define if you have the sigblock function. */
-#define HAVE_SIGBLOCK 1
-
-/* Define if you have the sigprocmask function. */
-#define HAVE_SIGPROCMASK 1
-
-/* Define if you have the sigsetmask function. */
-#define HAVE_SIGSETMASK 1
-
-/* Define if you have the sigvec function. */
-#define HAVE_SIGVEC 1
-
-/* Define if you have the tempnam function. */
-#define HAVE_TEMPNAM 1
-
-/* Define if you have the timezone function. */
-#define HAVE_TIMEZONE 1
-
-/* Define if you have the tzset function. */
-#define HAVE_TZSET 1
-
-/* Define if you have the vfork function. */
-#define HAVE_VFORK 1
-
-/* Define if you have the vprintf function. */
-#define HAVE_VPRINTF 1
-
-/* Define if you have the wait3 function. */
-#define HAVE_WAIT3 1
-
-/* Define if you have the <direct.h> header file. */
-/* #undef HAVE_DIRECT_H */
-
-/* Define if you have the <dirent.h> header file. */
-#define HAVE_DIRENT_H 1
-
-/* Define if you have the <errno.h> header file. */
-#define HAVE_ERRNO_H 1
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <io.h> header file. */
-/* #undef HAVE_IO_H */
-
-/* Define if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define if you have the <ndbm.h> header file. */
-#define HAVE_NDBM_H 1
-
-/* Define if you have the <ndir.h> header file. */
-/* #undef HAVE_NDIR_H */
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <sys/bsdtypes.h> header file. */
-/* #undef HAVE_SYS_BSDTYPES_H */
-
-/* Define if you have the <sys/dir.h> header file. */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define if you have the <sys/ndir.h> header file. */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define if you have the <sys/param.h> header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define if you have the <sys/resource.h> header file. */
-#define HAVE_SYS_RESOURCE_H 1
-
-/* Define if you have the <sys/select.h> header file. */
-#define HAVE_SYS_SELECT_H 1
-
-/* Define if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define if you have the <sys/timeb.h> header file. */
-#define HAVE_SYS_TIMEB_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the <utime.h> header file. */
-#define HAVE_UTIME_H 1
-
-/* Define if you have the crypt library (-lcrypt). */
-#define HAVE_LIBCRYPT 1
-
-/* Define if you have the inet library (-linet). */
-/* #undef HAVE_LIBINET */
-
-/* Define if you have the nsl library (-lnsl). */
-/* #undef HAVE_LIBNSL */
-
-/* Define if you have the nsl_s library (-lnsl_s). */
-/* #undef HAVE_LIBNSL_S */
-
-/* Define if you have the sec library (-lsec). */
-/* #undef HAVE_LIBSEC */
-
-/* Define if you have the socket library (-lsocket). */
-/* #undef HAVE_LIBSOCKET */
diff --git a/gnu/usr.bin/cvs/lib/config.h.proto b/gnu/usr.bin/cvs/lib/config.h.proto
deleted file mode 100644
index e8128f4..0000000
--- a/gnu/usr.bin/cvs/lib/config.h.proto
+++ /dev/null
@@ -1,227 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if on AIX 3.
- System headers sometimes define this.
- We just want to avoid a redefinition error message. */
-#ifndef _ALL_SOURCE
-/* #undef _ALL_SOURCE */
-#endif
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef gid_t */
-
-/* Define if you support file names longer than 14 characters. */
-#define HAVE_LONG_FILE_NAMES 1
-
-/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
-#define HAVE_SYS_WAIT_H 1
-
-/* Define if utime(file, NULL) sets file's timestamp to the present. */
-#define HAVE_UTIME_NULL 1
-
-/* Define if on MINIX. */
-/* #undef _MINIX */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef mode_t */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef pid_t */
-
-/* Define if the system does not provide POSIX.1 features except
- with this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define if you need to in order for stat and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define as the return type of signal handlers (int or void). */
-#define RETSIGTYPE void
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-/* #undef size_t */
-
-/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#define TIME_WITH_SYS_TIME 1
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef uid_t */
-
-/* Define if you have MIT Kerberos version 4 available. */
-/* #undef HAVE_KERBEROS */
-
-/* Define if you want CVS to be able to be a remote repository client. */
-#define CLIENT_SUPPORT 1
-
-/* Define if you want CVS to be able to serve repositories to remote
- clients. */
-#define SERVER_SUPPORT 1
-
-/* Define if you want to use the password authenticated server. */
-#define AUTH_SERVER_SUPPORT 1
-
-/* Define if you want encryption support. */
-/* #undef ENCRYPTION */
-
-/* Define if you have the connect function. */
-/* #undef HAVE_CONNECT */
-
-/* Define if you have the crypt function. */
-#define HAVE_CRYPT 1
-
-/* Define if you have the fchdir function. */
-#define HAVE_FCHDIR 1
-
-/* Define if you have the fchmod function. */
-#define HAVE_FCHMOD 1
-
-/* Define if you have the fsync function. */
-#define HAVE_FSYNC 1
-
-/* Define if you have the ftime function. */
-/* #undef HAVE_FTIME */
-
-/* Define if you have the ftruncate function. */
-#define HAVE_FTRUNCATE 1
-
-/* Define if you have the getpagesize function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define if you have the getspnam function. */
-/* #undef HAVE_GETSPNAM */
-
-/* Define if you have the initgroups function. */
-#define HAVE_INITGROUPS 1
-
-/* Define if you have the krb_get_err_text function. */
-/* #undef HAVE_KRB_GET_ERR_TEXT */
-
-/* Define if you have the mkfifo function. */
-#define HAVE_MKFIFO 1
-
-/* Define if you have the mktemp function. */
-#define HAVE_MKTEMP 1
-
-/* Define if you have the putenv function. */
-#define HAVE_PUTENV 1
-
-/* Define if you have the readlink function. */
-#define HAVE_READLINK 1
-
-/* Define if you have the sigaction function. */
-#define HAVE_SIGACTION 1
-
-/* Define if you have the sigblock function. */
-#define HAVE_SIGBLOCK 1
-
-/* Define if you have the sigprocmask function. */
-#define HAVE_SIGPROCMASK 1
-
-/* Define if you have the sigsetmask function. */
-#define HAVE_SIGSETMASK 1
-
-/* Define if you have the sigvec function. */
-#define HAVE_SIGVEC 1
-
-/* Define if you have the tempnam function. */
-#define HAVE_TEMPNAM 1
-
-/* Define if you have the timezone function. */
-#define HAVE_TIMEZONE 1
-
-/* Define if you have the tzset function. */
-#define HAVE_TZSET 1
-
-/* Define if you have the vfork function. */
-#define HAVE_VFORK 1
-
-/* Define if you have the vprintf function. */
-#define HAVE_VPRINTF 1
-
-/* Define if you have the wait3 function. */
-#define HAVE_WAIT3 1
-
-/* Define if you have the <direct.h> header file. */
-/* #undef HAVE_DIRECT_H */
-
-/* Define if you have the <dirent.h> header file. */
-#define HAVE_DIRENT_H 1
-
-/* Define if you have the <errno.h> header file. */
-#define HAVE_ERRNO_H 1
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <io.h> header file. */
-/* #undef HAVE_IO_H */
-
-/* Define if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define if you have the <ndbm.h> header file. */
-#define HAVE_NDBM_H 1
-
-/* Define if you have the <ndir.h> header file. */
-/* #undef HAVE_NDIR_H */
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <sys/bsdtypes.h> header file. */
-/* #undef HAVE_SYS_BSDTYPES_H */
-
-/* Define if you have the <sys/dir.h> header file. */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define if you have the <sys/ndir.h> header file. */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define if you have the <sys/param.h> header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define if you have the <sys/resource.h> header file. */
-#define HAVE_SYS_RESOURCE_H 1
-
-/* Define if you have the <sys/select.h> header file. */
-#define HAVE_SYS_SELECT_H 1
-
-/* Define if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define if you have the <sys/timeb.h> header file. */
-#define HAVE_SYS_TIMEB_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the <utime.h> header file. */
-#define HAVE_UTIME_H 1
-
-/* Define if you have the crypt library (-lcrypt). */
-#define HAVE_LIBCRYPT 1
-
-/* Define if you have the inet library (-linet). */
-/* #undef HAVE_LIBINET */
-
-/* Define if you have the nsl library (-lnsl). */
-/* #undef HAVE_LIBNSL */
-
-/* Define if you have the nsl_s library (-lnsl_s). */
-/* #undef HAVE_LIBNSL_S */
-
-/* Define if you have the sec library (-lsec). */
-/* #undef HAVE_LIBSEC */
-
-/* Define if you have the socket library (-lsocket). */
-/* #undef HAVE_LIBSOCKET */
diff --git a/gnu/usr.bin/cvs/tools/Makefile b/gnu/usr.bin/cvs/tools/Makefile
deleted file mode 100644
index 23e2733..0000000
--- a/gnu/usr.bin/cvs/tools/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id: Makefile,v 1.3 1997/02/22 15:45:21 peter Exp $
-
-FILES= INSTALL NEWS README \
- pcl-cvs-lucid.el pcl-cvs-startup.el \
- pcl-cvs.el pcl-cvs.texinfo
-
-NOOBJ= noobj
-
-EXAMPDIR= /usr/share/examples/cvs
-
-beforeinstall:
-.for file in ${FILES}
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
- ${CVSDIR}/tools/pcl-cvs/${file} ${DESTDIR}${EXAMPDIR}/pcl-cvs
-.endfor
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/dc/COPYING b/gnu/usr.bin/dc/COPYING
deleted file mode 100644
index e77696a..0000000
--- a/gnu/usr.bin/dc/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/dc/Makefile b/gnu/usr.bin/dc/Makefile
deleted file mode 100644
index a20cee3..0000000
--- a/gnu/usr.bin/dc/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-PROG= dc
-SRCS= dc-array.c dc-eval.c dc-misc.c dc-number.c dc-stack.c dc-string.c number.c
-CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../bc -D_POSIX_SOURCE
-DPADD= ${LIBM}
-LDADD= -lm
-SUBDIR+= doc
-
-.PATH: ${.CURDIR}/../bc
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/dc/dc-array.c b/gnu/usr.bin/dc/dc-array.c
deleted file mode 100644
index dd16ed9..0000000
--- a/gnu/usr.bin/dc/dc-array.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * implement arrays for dc
- *
- * Copyright (C) 1994 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, you can either send email to this
- * program's author (see below) or write to: The Free Software Foundation,
- * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
- */
-
-/* This module is the only one that knows what arrays look like. */
-
-#include "config.h"
-
-#include <stdio.h> /* "dc-proto.h" wants this */
-#include <stdlib.h>
-#include "dc.h"
-#include "dc-proto.h"
-#include "dc-regdef.h"
-
-/* what's most useful: quick access or sparse arrays? */
-/* I'll go with sparse arrays for now */
-struct dc_array {
- int Index;
- dc_data value;
- struct dc_array *next;
-};
-typedef struct dc_array dc_array;
-
-/* I can find no reason not to place arrays in their own namespace... */
-static dc_array *dc_array_register[DC_REGCOUNT];
-
-
-/* initialize the arrays to their initial values */
-void
-dc_array_init DC_DECLVOID()
-{
- int i;
-
- for (i=0; i<DC_REGCOUNT; ++i)
- dc_array_register[i] = NULL;
-}
-
-/* store value into array_id[Index] */
-void
-dc_array_set DC_DECLARG((array_id, Index, value))
- int array_id DC_DECLSEP
- int Index DC_DECLSEP
- dc_data value DC_DECLEND
-{
- dc_array *cur;
- dc_array *prev=NULL;
- dc_array *newentry;
-
- array_id = regmap(array_id);
- cur = dc_array_register[array_id];
- while (cur && cur->Index < Index){
- prev = cur;
- cur = cur->next;
- }
- if (cur && cur->Index == Index){
- if (cur->value.dc_type == DC_NUMBER)
- dc_free_num(&cur->value.v.number);
- else if (cur->value.dc_type == DC_STRING)
- dc_free_str(&cur->value.v.string);
- else
- dc_garbage(" in array", array_id);
- cur->value = value;
- }else{
- newentry = dc_malloc(sizeof *newentry);
- newentry->Index = Index;
- newentry->value = value;
- newentry->next = cur;
- if (prev)
- prev->next = newentry;
- else
- dc_array_register[array_id] = newentry;
- }
-}
-
-/* retrieve a dup of a value from array_id[Index] */
-/* A zero value is returned if the specified value is unintialized. */
-dc_data
-dc_array_get DC_DECLARG((array_id, Index))
- int array_id DC_DECLSEP
- int Index DC_DECLEND
-{
- dc_array *cur;
-
- for (cur=dc_array_register[regmap(array_id)]; cur; cur=cur->next)
- if (cur->Index == Index)
- return dc_dup(cur->value);
- return dc_int2data(0);
-}
diff --git a/gnu/usr.bin/dc/dc-eval.c b/gnu/usr.bin/dc/dc-eval.c
deleted file mode 100644
index e368caa..0000000
--- a/gnu/usr.bin/dc/dc-eval.c
+++ /dev/null
@@ -1,569 +0,0 @@
-/*
- * evaluate the dc language, from a FILE* or a string
- *
- * Copyright (C) 1994 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, you can either send email to this
- * program's author (see below) or write to: The Free Software Foundation,
- * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
- */
-
-/* This is the only module which knows about the dc input language */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include "dc.h"
-#include "dc-proto.h"
-
-typedef enum {
- DC_OKAY, /* no further intervention needed for this command */
- DC_EATONE, /* caller needs to eat the lookahead char */
- DC_QUIT, /* quit out of unwind_depth levels of evaluation */
-
- /* with the following return values, the caller does not have to
- * fret about rescan_stdin's value
- */
- DC_INT, /* caller needs to parse a dc_num from input stream */
- DC_STR, /* caller needs to parse a dc_str from input stream */
- DC_SYSTEM, /* caller needs to run a system() on next input line */
- DC_COMMENT, /* caller needs to skip to the next input line */
-
- DC_EOF_ERROR /* unexpected end of input; abort current eval */
-} dc_status;
-
-static int dc_ibase=10; /* input base, 2 <= dc_ibase <= DC_IBASE_MAX */
-static int dc_obase=10; /* output base, 2 <= dc_obase */
-static int dc_scale=0; /* scale (see user documentaton) */
-
-/* forward reference */
-static dc_status dc_evalstr DC_PROTO((dc_data));
-
-/* for Quitting evaluations */
-static int unwind_depth=0;
-
-/* if true, active Quit will not exit program */
-static dc_boolean unwind_noexit=DC_FALSE;
-
-/* if true, stdin has been mucked with, dc_evalfile() needs to resyncronize */
-static dc_boolean rescan_stdin=DC_FALSE;
-
-
-/* input_fil and input_str are passed as arguments to dc_getnum */
-
-/* used by the input_* functions: */
-static FILE *input_fil_fp;
-static const char *input_str_string;
-
-/* Since we have a need for two characters of pushback, and
- * ungetc() only guarantees one, we place the second pushback here
- */
-static int input_pushback;
-
-/* passed as an argument to dc_getnum */
-static int
-input_fil DC_DECLVOID()
-{
- if (input_pushback != EOF){
- int c = input_pushback;
- input_pushback = EOF;
- return c;
- }
- return getc(input_fil_fp);
-}
-
-/* passed as an argument to dc_getnum */
-static int
-input_str DC_DECLVOID()
-{
- if (!*input_str_string)
- return EOF;
- return *input_str_string++;
-}
-
-
-
-/* takes a string and evals it; frees the string when done */
-/* Wrapper around dc_evalstr to avoid duplicating the free call
- * at all possible return points.
- */
-static dc_status
-dc_eval_and_free_str DC_DECLARG((string))
- dc_data string DC_DECLEND
-{
- dc_status status;
-
- status = dc_evalstr(string);
- if (string.dc_type == DC_STRING)
- dc_free_str(&string.v.string);
- return status;
-}
-
-
-/* dc_func does the grunt work of figuring out what each input
- * character means; used by both dc_evalstr and dc_evalfile
- *
- * c -> the "current" input character under consideration
- * peekc -> the lookahead input character
- */
-static dc_status
-dc_func DC_DECLARG((c, peekc))
- int c DC_DECLSEP
- int peekc DC_DECLEND
-{
- /* we occasionally need these for temporary data */
- /* Despite the GNU coding standards, it is much easier
- * to have these decared once here, since this function
- * is just one big switch statement.
- */
- dc_data datum;
- int tmpint;
-
- switch (c){
- case '_': case '.':
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- case '8': case '9': case 'A': case 'B':
- case 'C': case 'D': case 'E': case 'F':
- return DC_INT;
- case ' ':
- case '\t':
- case '\n':
- /* standard command separators */
- break;
-
- case '+': /* add top two stack elements */
- dc_binop(dc_add, dc_scale);
- break;
- case '-': /* subtract top two stack elements */
- dc_binop(dc_sub, dc_scale);
- break;
- case '*': /* multiply top two stack elements */
- dc_binop(dc_mul, dc_scale);
- break;
- case '/': /* divide top two stack elements */
- dc_binop(dc_div, dc_scale);
- break;
- case '%':
- /* take the remainder from division of the top two stack elements */
- dc_binop(dc_rem, dc_scale);
- break;
- case '^': /* exponientiation of the top two stack elements */
- dc_binop(dc_exp, dc_scale);
- break;
- case '<':
- /* eval register named by peekc if
- * less-than holds for top two stack elements
- */
- if (peekc == EOF)
- return DC_EOF_ERROR;
- if (dc_cmpop() < 0)
- if (dc_register_get(peekc, &datum) == DC_SUCCESS)
- if (dc_eval_and_free_str(datum) == DC_QUIT)
- return DC_QUIT;
- return DC_EATONE;
- case '=':
- /* eval register named by peekc if
- * equal-to holds for top two stack elements
- */
- if (peekc == EOF)
- return DC_EOF_ERROR;
- if (dc_cmpop() == 0)
- if (dc_register_get(peekc, &datum) == DC_SUCCESS)
- if (dc_eval_and_free_str(datum) == DC_QUIT)
- return DC_QUIT;
- return DC_EATONE;
- case '>':
- /* eval register named by peekc if
- * greater-than holds for top two stack elements
- */
- if (peekc == EOF)
- return DC_EOF_ERROR;
- if (dc_cmpop() > 0)
- if (dc_register_get(peekc, &datum) == DC_SUCCESS)
- if (dc_eval_and_free_str(datum) == DC_QUIT)
- return DC_QUIT;
- return DC_EATONE;
- case '?': /* read a lnie from standard-input and eval it */
- for (c=peekc; c=='\n'; c=getc(stdin))
- ;
- ungetc(c, stdin);
- if (dc_eval_and_free_str(dc_readstring(stdin, '\n', '\n')) == DC_QUIT)
- return DC_QUIT;
- rescan_stdin = DC_TRUE;
- return DC_OKAY;
- case '[': /* read to balancing ']' into a dc_str */
- return DC_STR;
- case '!': /* read to newline and call system() on resulting string */
- return DC_SYSTEM;
- case '#': /* comment; skip remainder of current line */
- return DC_COMMENT;
-
- case 'c': /* clear whole stack */
- dc_clear_stack();
- break;
- case 'd': /* duplicate the datum on the top of stack */
- if (dc_top_of_stack(&datum) == DC_SUCCESS)
- dc_push(dc_dup(datum));
- break;
- case 'f': /* print list of all stack items */
- dc_printall(dc_obase);
- break;
- case 'i': /* set input base to value on top of stack */
- if (dc_pop(&datum) == DC_SUCCESS){
- tmpint = 0;
- if (datum.dc_type == DC_NUMBER)
- tmpint = dc_num2int(datum.v.number, DC_TRUE);
- if ( ! (2 <= tmpint && tmpint <= DC_IBASE_MAX) )
- fprintf(stderr,
- "%s: input base must be a number \
-between 2 and %d (inclusive)\n",
- progname, DC_IBASE_MAX);
- else
- dc_ibase = tmpint;
- }
- break;
- case 'k': /* set scale to value on top of stack */
- if (dc_pop(&datum) == DC_SUCCESS){
- tmpint = -1;
- if (datum.dc_type == DC_NUMBER)
- tmpint = dc_num2int(datum.v.number, DC_TRUE);
- if ( ! (tmpint >= 0) )
- fprintf(stderr,
- "%s: scale must be a nonnegative number\n",
- progname);
- else
- dc_scale = tmpint;
- }
- break;
- case 'l': /* "load" -- push value on top of register stack named
- * by peekc onto top of evaluation stack; does not
- * modify the register stack
- */
- if (peekc == EOF)
- return DC_EOF_ERROR;
- if (dc_register_get(peekc, &datum) == DC_SUCCESS)
- dc_push(datum);
- return DC_EATONE;
- case 'o': /* set output base to value on top of stack */
- if (dc_pop(&datum) == DC_SUCCESS){
- tmpint = 0;
- if (datum.dc_type == DC_NUMBER)
- tmpint = dc_num2int(datum.v.number, DC_TRUE);
- if ( ! (tmpint > 1) )
- fprintf(stderr,
- "%s: output base must be a number greater than 1\n",
- progname);
- else
- dc_obase = tmpint;
- }
- break;
- case 'p': /* print the datum on the top of stack */
- if (dc_top_of_stack(&datum) == DC_SUCCESS)
- dc_print(datum, dc_obase);
- break;
- case 'q': /* quit two levels of evaluation, posibly exiting program */
- unwind_depth = 2;
- unwind_noexit = DC_FALSE;
- return DC_QUIT;
- case 's': /* "store" -- replace top of register stack named
- * by peekc with the value popped from the top
- * of the evaluation stack
- */
- if (peekc == EOF)
- return DC_EOF_ERROR;
- if (dc_pop(&datum) == DC_SUCCESS)
- dc_register_set(peekc, datum);
- return DC_EATONE;
- case 'v': /* replace top of stack with its square root */
- if (dc_pop(&datum) == DC_SUCCESS){
- dc_num tmpnum;
- if (datum.dc_type != DC_NUMBER){
- fprintf(stderr,
- "%s: square root of nonnumeric attempted\n",
- progname);
- }else if (dc_sqrt(datum.v.number, dc_scale, &tmpnum) == DC_SUCCESS){
- dc_free_num(&datum.v.number);
- datum.v.number = tmpnum;
- dc_push(datum);
- }
- }
- break;
- case 'x': /* eval the datum popped from top of stack */
- if (dc_pop(&datum) == DC_SUCCESS){
- if (datum.dc_type == DC_STRING){
- if (dc_eval_and_free_str(datum) == DC_QUIT)
- return DC_QUIT;
- }else if (datum.dc_type == DC_NUMBER){
- dc_push(datum);
- }else{
- dc_garbage("at top of stack", -1);
- }
- }
- break;
- case 'z': /* push the current stack depth onto the top of stack */
- dc_push(dc_int2data(dc_tell_stackdepth()));
- break;
-
- case 'I': /* push the current input base onto the stack */
- dc_push(dc_int2data(dc_ibase));
- break;
- case 'K': /* push the current scale onto the stack */
- dc_push(dc_int2data(dc_scale));
- break;
- case 'L': /* pop a value off of register stack named by peekc
- * and push it onto the evaluation stack
- */
- if (peekc == EOF)
- return DC_EOF_ERROR;
- if (dc_register_pop(peekc, &datum) == DC_SUCCESS)
- dc_push(datum);
- return DC_EATONE;
- case 'O': /* push the current output base onto the stack */
- dc_push(dc_int2data(dc_obase));
- break;
- case 'P': /* print the value popped off of top-of-stack;
- * do not add a trailing newline
- */
- if (dc_pop(&datum) == DC_SUCCESS){
- if (datum.dc_type == DC_STRING)
- dc_out_str(datum.v.string, DC_FALSE, DC_TRUE);
- else if (datum.dc_type == DC_NUMBER)
- dc_out_num(datum.v.number, dc_obase, DC_FALSE, DC_TRUE);
- else
- dc_garbage("at top of stack", -1);
- }
- break;
- case 'Q': /* quit out of top-of-stack nested evals;
- * pops value from stack;
- * does not exit program (stops short if necessary)
- */
- if (dc_pop(&datum) == DC_SUCCESS){
- unwind_depth = 0;
- unwind_noexit = DC_TRUE;
- if (datum.dc_type == DC_NUMBER)
- unwind_depth = dc_num2int(datum.v.number, DC_TRUE);
- if (unwind_depth > 0)
- return DC_QUIT;
- fprintf(stderr,
- "%s: Q command requires a positive number\n",
- progname);
- }
- break;
- case 'S': /* pop a value off of the evaluation stack
- * and push it onto the register stack named by peekc
- */
- if (peekc == EOF)
- return DC_EOF_ERROR;
- if (dc_pop(&datum) == DC_SUCCESS)
- dc_register_push(peekc, datum);
- return DC_EATONE;
- case 'X': /* replace the number on top-of-stack with its scale factor */
- if (dc_pop(&datum) == DC_SUCCESS){
- tmpint = 0;
- if (datum.dc_type == DC_NUMBER)
- tmpint = dc_tell_scale(datum.v.number, DC_TRUE);
- dc_push(dc_int2data(tmpint));
- }
- break;
- case 'Z': /* replace the datum on the top-of-stack with its length */
- if (dc_pop(&datum) == DC_SUCCESS)
- dc_push(dc_int2data(dc_tell_length(datum, DC_TRUE)));
- break;
-
- case ':': /* store into array */
- if (peekc == EOF)
- return DC_EOF_ERROR;
- if (dc_pop(&datum) == DC_SUCCESS){
- tmpint = -1;
- if (datum.dc_type == DC_NUMBER)
- tmpint = dc_num2int(datum.v.number, DC_TRUE);
- if (dc_pop(&datum) == DC_SUCCESS){
- if (tmpint < 0)
- fprintf(stderr,
- "%s: array index must be a nonnegative integer\n",
- progname);
- else
- dc_array_set(peekc, tmpint, datum);
- }
- }
- return DC_EATONE;
- case ';': /* retreive from array */
- if (peekc == EOF)
- return DC_EOF_ERROR;
- if (dc_pop(&datum) == DC_SUCCESS){
- tmpint = -1;
- if (datum.dc_type == DC_NUMBER)
- tmpint = dc_num2int(datum.v.number, DC_TRUE);
- if (tmpint < 0)
- fprintf(stderr,
- "%s: array index must be a nonnegative integer\n",
- progname);
- else
- dc_push(dc_array_get(peekc, tmpint));
- }
- return DC_EATONE;
-
- default: /* What did that user mean? */
- fprintf(stderr, "%s: ", progname);
- dc_show_id(stdout, c, " unimplemented\n");
- break;
- }
- return DC_OKAY;
-}
-
-
-/* takes a string and evals it */
-static dc_status
-dc_evalstr DC_DECLARG((string))
- dc_data string DC_DECLEND
-{
- const char *s;
- const char *end;
- const char *p;
- size_t len;
- int c;
- int peekc;
- int count;
-
- if (string.dc_type != DC_STRING){
- fprintf(stderr,
- "%s: eval called with non-string argument\n",
- progname);
- return DC_OKAY;
- }
- s = dc_str2charp(string.v.string);
- end = s + dc_strlen(string.v.string);
- while (s < end){
- c = *(const unsigned char *)s++;
- peekc = EOF;
- if (s < end)
- peekc = *(const unsigned char *)s;
- switch (dc_func(c, peekc)){
- case DC_OKAY:
- break;
- case DC_EATONE:
- if (peekc != EOF)
- ++s;
- break;
- case DC_QUIT:
- if (unwind_depth > 0){
- --unwind_depth;
- return DC_QUIT;
- }
- return DC_OKAY;
-
- case DC_INT:
- input_str_string = s - 1;
- dc_push(dc_getnum(input_str, dc_ibase, &peekc));
- s = input_str_string;
- if (peekc != EOF)
- --s;
- break;
- case DC_STR:
- count = 1;
- for (p=s; p<end && count>0; ++p)
- if (*p == ']')
- --count;
- else if (*p == '[')
- ++count;
- len = p - s;
- dc_push(dc_makestring(s, len-1));
- s = p;
- break;
- case DC_SYSTEM:
- s = dc_system(s);
- case DC_COMMENT:
- s = memchr(s, '\n', (size_t)(end-s));
- if (!s)
- s = end;
- ++s;
- break;
-
- case DC_EOF_ERROR:
- fprintf(stderr, "%s: unexpected EOS\n", progname);
- return DC_OKAY;
- }
- }
- return DC_OKAY;
-}
-
-
-/* This is the main function of the whole DC program.
- * Reads the file described by fp, calls dc_func to do
- * the dirty work, and takes care of dc_func's shortcomings.
- */
-int
-dc_evalfile DC_DECLARG((fp))
- FILE *fp DC_DECLEND
-{
- int c;
- int peekc;
- dc_data datum;
-
- for (c=getc(fp); c!=EOF; c=peekc){
- peekc = getc(fp);
- rescan_stdin = DC_FALSE;
- switch (dc_func(c, peekc)){
- case DC_OKAY:
- if (rescan_stdin == DC_TRUE && fp == stdin)
- peekc = getc(fp);
- break;
- case DC_EATONE:
- peekc = getc(fp);
- break;
- case DC_QUIT:
- if (unwind_noexit != DC_TRUE)
- return DC_SUCCESS;
- fprintf(stderr,
- "%s: Q command argument exceeded string execution depth\n",
- progname);
- if (rescan_stdin == DC_TRUE && fp == stdin)
- peekc = getc(fp);
- break;
-
- case DC_INT:
- input_fil_fp = fp;
- input_pushback = c;
- ungetc(peekc, fp);
- dc_push(dc_getnum(input_fil, dc_ibase, &peekc));
- break;
- case DC_STR:
- ungetc(peekc, fp);
- datum = dc_readstring(fp, '[', ']');
- dc_push(datum);
- peekc = getc(fp);
- break;
- case DC_SYSTEM:
- ungetc(peekc, fp);
- datum = dc_readstring(stdin, '\n', '\n');
- (void)dc_system(dc_str2charp(datum.v.string));
- dc_free_str(&datum.v.string);
- peekc = getc(fp);
- break;
- case DC_COMMENT:
- while (peekc!=EOF && peekc!='\n')
- peekc = getc(fp);
- if (peekc != EOF)
- peekc = getc(fp);
- break;
-
- case DC_EOF_ERROR:
- fprintf(stderr, "%s: unexpected EOF\n", progname);
- return DC_FAIL;
- }
- }
- return DC_SUCCESS;
-}
diff --git a/gnu/usr.bin/dc/dc-misc.c b/gnu/usr.bin/dc/dc-misc.c
deleted file mode 100644
index 6443c60..0000000
--- a/gnu/usr.bin/dc/dc-misc.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * implement the "dc" Desk Calculator language.
- *
- * Copyright (C) 1994 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, you can either send email to this
- * program's author (see below) or write to: The Free Software Foundation,
- * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
- */
-
-/* Written with strong hiding of implementation details
- * in their own specialized modules.
- */
-/* This module contains miscelaneous functions that have no
- * special knowledge of any private data structures.
- * They could all be moved to their own separate modules, but
- * are agglomerated here for convenience.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include "dc.h"
-#include "dc-proto.h"
-
-#include "dc-version.h"
-
-#ifndef EXIT_SUCCESS /* C89 <stdlib.h> */
-# define EXIT_SUCCESS 0
-#endif
-#ifndef EXIT_FAILURE /* C89 <stdlib.h> */
-# define EXIT_FAILURE 1
-#endif
-
-const char *progname; /* basename of program invocation */
-
-/* your generic usage function */
-static void
-usage DC_DECLARG((f))
- FILE *f DC_DECLEND
-{
- fprintf(f, "Usage: %s [OPTION]\n", progname);
- fprintf(f, " --help display this help and exit\n");
- fprintf(f, " --version output version information and exit\n");
-}
-
-/* returns a pointer to one past the last occurance of c in s,
- * or s if c does not occur in s.
- */
-static char *
-r1bindex DC_DECLARG((s, c))
- char *s DC_DECLSEP
- int c DC_DECLEND
-{
- char *p = strrchr(s, c);
-
- if (!p)
- return s;
- return p + 1;
-}
-
-
-int
-main DC_DECLARG((argc, argv))
- int argc DC_DECLSEP
- char **argv DC_DECLEND
-{
- progname = r1bindex(*argv, '/');
- if (argc>1 && strcmp(argv[1], "--version")==0){
- printf("%s\n", Version);
- return EXIT_SUCCESS;
- }else if (argc>1 && strcmp(argv[1], "--help")==0){
- usage(stdout);
- return EXIT_SUCCESS;
- }else if (argc==2 && strcmp(argv[1], "--")==0){
- /*just ignore it*/
- }else if (argc != 1){
- usage(stderr);
- return EXIT_FAILURE;
- }
-
- dc_math_init();
- dc_string_init();
- dc_register_init();
- dc_array_init();
- dc_evalfile(stdin);
- return EXIT_SUCCESS;
-}
-
-
-/* print an "out of memory" diagnostic and exit program */
-void
-dc_memfail DC_DECLVOID()
-{
- fprintf(stderr, "%s: out of memory\n", progname);
- exit(EXIT_FAILURE);
-}
-
-/* malloc or die */
-void *
-dc_malloc DC_DECLARG((len))
- size_t len DC_DECLEND
-{
- void *result = malloc(len);
-
- if (!result)
- dc_memfail();
- return result;
-}
-
-
-/* print the id in a human-understandable form
- * fp is the output stream to place the output on
- * id is the name of the register (or command) to be printed
- * suffix is a modifier (such as "stack") to be printed
- */
-void
-dc_show_id DC_DECLARG((fp, id, suffix))
- FILE *fp DC_DECLSEP
- int id DC_DECLSEP
- const char *suffix DC_DECLEND
-{
- if (isgraph(id))
- fprintf(fp, "'%c' (%#o)%s", id, id, suffix);
- else
- fprintf(fp, "%#o%s", id, suffix);
-}
-
-
-/* report that corrupt data has been detected;
- * use the msg and regid (if nonnegative) to give information
- * about where the garbage was found,
- *
- * will abort() so that a debugger might be used to help find
- * the bug
- */
-/* If this routine is called, then there is a bug in the code;
- * i.e. it is _not_ a data or user error
- */
-void
-dc_garbage DC_DECLARG((msg, regid))
- const char *msg DC_DECLSEP
- int regid DC_DECLEND
-{
- if (regid < 0){
- fprintf(stderr, "%s: garbage %s\n", progname, msg);
- }else{
- fprintf(stderr, "%s:%s register ", progname, msg);
- dc_show_id(stderr, regid, " is garbage\n");
- }
- abort();
-}
-
-
-/* call system() with the passed string;
- * if the string contains a newline, terminate the string
- * there before calling system.
- * Return a pointer to the first unused character in the string
- * (i.e. past the '\n' if there was one, to the '\0' otherwise).
- */
-const char *
-dc_system DC_DECLARG((s))
- const char *s DC_DECLEND
-{
- const char *p;
- char *tmpstr;
- size_t len;
-
- p = strchr(s, '\n');
- if (p){
- len = p - s;
- tmpstr = dc_malloc(len + 1);
- strncpy(tmpstr, s, len);
- tmpstr[len] = '\0';
- system(tmpstr);
- free(tmpstr);
- return p + 1;
- }
- system(s);
- return s + strlen(s);
-}
-
-
-/* print out the indicated value */
-void
-dc_print DC_DECLARG((value, obase))
- dc_data value DC_DECLSEP
- int obase DC_DECLEND
-{
- if (value.dc_type == DC_NUMBER){
- dc_out_num(value.v.number, obase, DC_TRUE, DC_FALSE);
- }else if (value.dc_type == DC_STRING){
- dc_out_str(value.v.string, DC_TRUE, DC_FALSE);
- }else{
- dc_garbage("in data being printed", -1);
- }
-}
-
-/* return a duplicate of the passed value, regardless of type */
-dc_data
-dc_dup DC_DECLARG((value))
- dc_data value DC_DECLEND
-{
- if (value.dc_type!=DC_NUMBER && value.dc_type!=DC_STRING)
- dc_garbage("in value being duplicated", -1);
- if (value.dc_type == DC_NUMBER)
- return dc_dup_num(value.v.number);
- /*else*/
- return dc_dup_str(value.v.string);
-}
diff --git a/gnu/usr.bin/dc/dc-number.c b/gnu/usr.bin/dc/dc-number.c
deleted file mode 100644
index 8007506..0000000
--- a/gnu/usr.bin/dc/dc-number.c
+++ /dev/null
@@ -1,478 +0,0 @@
-/*
- * interface dc to the bc numeric routines
- *
- * Copyright (C) 1994 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, you can either send email to this
- * program's author (see below) or write to: The Free Software Foundation,
- * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
- */
-
-/* This should be the only module that knows the internals of type dc_num */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include "bcdefs.h"
-#include "proto.h"
-#include "global.h"
-#include "dc.h"
-#include "dc-proto.h"
-
-/* convert an opaque dc_num into a real bc_num */
-#define CastNum(x) ((bc_num)(x))
-
-/* add two dc_nums, place into *result;
- * return DC_SUCCESS on success, DC_DOMAIN_ERROR on domain error
- */
-int
-dc_add DC_DECLARG((a, b, kscale, result))
- dc_num a DC_DECLSEP
- dc_num b DC_DECLSEP
- int kscale DC_DECLSEP
- dc_num *result DC_DECLEND
-{
- init_num((bc_num *)result);
- bc_add(CastNum(a), CastNum(b), (bc_num *)result);
- return DC_SUCCESS;
-}
-
-/* subtract two dc_nums, place into *result;
- * return DC_SUCCESS on success, DC_DOMAIN_ERROR on domain error
- */
-int
-dc_sub DC_DECLARG((a, b, kscale, result))
- dc_num a DC_DECLSEP
- dc_num b DC_DECLSEP
- int kscale DC_DECLSEP
- dc_num *result DC_DECLEND
-{
- init_num((bc_num *)result);
- bc_sub(CastNum(a), CastNum(b), (bc_num *)result);
- return DC_SUCCESS;
-}
-
-/* multiply two dc_nums, place into *result;
- * return DC_SUCCESS on success, DC_DOMAIN_ERROR on domain error
- */
-int
-dc_mul DC_DECLARG((a, b, kscale, result))
- dc_num a DC_DECLSEP
- dc_num b DC_DECLSEP
- int kscale DC_DECLSEP
- dc_num *result DC_DECLEND
-{
- init_num((bc_num *)result);
- bc_multiply(CastNum(a), CastNum(b), (bc_num *)result, kscale);
- return DC_SUCCESS;
-}
-
-/* divide two dc_nums, place into *result;
- * return DC_SUCCESS on success, DC_DOMAIN_ERROR on domain error
- */
-int
-dc_div DC_DECLARG((a, b, kscale, result))
- dc_num a DC_DECLSEP
- dc_num b DC_DECLSEP
- int kscale DC_DECLSEP
- dc_num *result DC_DECLEND
-{
- init_num((bc_num *)result);
- if (bc_divide(CastNum(a), CastNum(b), (bc_num *)result, kscale)){
- fprintf(stderr, "%s: divide by zero\n", progname);
- return DC_DOMAIN_ERROR;
- }
- return DC_SUCCESS;
-}
-
-/* place the reminder of dividing a by b into *result;
- * return DC_SUCCESS on success, DC_DOMAIN_ERROR on domain error
- */
-int
-dc_rem DC_DECLARG((a, b, kscale, result))
- dc_num a DC_DECLSEP
- dc_num b DC_DECLSEP
- int kscale DC_DECLSEP
- dc_num *result DC_DECLEND
-{
- init_num((bc_num *)result);
- if (bc_modulo(CastNum(a), CastNum(b), (bc_num *)result, kscale)){
- fprintf(stderr, "%s: remainder by zero\n", progname);
- return DC_DOMAIN_ERROR;
- }
- return DC_SUCCESS;
-}
-
-/* place the result of exponentiationg a by b into *result;
- * return DC_SUCCESS on success, DC_DOMAIN_ERROR on domain error
- */
-int
-dc_exp DC_DECLARG((a, b, kscale, result))
- dc_num a DC_DECLSEP
- dc_num b DC_DECLSEP
- int kscale DC_DECLSEP
- dc_num *result DC_DECLEND
-{
- init_num((bc_num *)result);
- bc_raise(CastNum(a), CastNum(b), (bc_num *)result, kscale);
- return DC_SUCCESS;
-}
-
-/* take the square root of the value, place into *result;
- * return DC_SUCCESS on success, DC_DOMAIN_ERROR on domain error
- */
-int
-dc_sqrt DC_DECLARG((value, kscale, result))
- dc_num value DC_DECLSEP
- int kscale DC_DECLSEP
- dc_num *result DC_DECLEND
-{
- bc_num tmp;
-
- tmp = copy_num(CastNum(value));
- if (!bc_sqrt(&tmp, kscale)){
- fprintf(stderr, "%s: square root of negative number\n", progname);
- free_num(&tmp);
- return DC_DOMAIN_ERROR;
- }
- *((bc_num *)result) = tmp;
- return DC_SUCCESS;
-}
-
-/* compare dc_nums a and b;
- * return a negative value if a < b;
- * return a positive value if a > b;
- * return zero value if a == b
- */
-int
-dc_compare DC_DECLARG((a, b))
- dc_num a DC_DECLSEP
- dc_num b DC_DECLEND
-{
- return bc_compare(CastNum(a), CastNum(b));
-}
-
-/* attempt to convert a dc_num to its corresponding int value
- * If discard_flag is true then deallocate the value after use.
- */
-int
-dc_num2int DC_DECLARG((value, discard_flag))
- dc_num value DC_DECLSEP
- dc_boolean discard_flag DC_DECLEND
-{
- long result;
-
- result = num2long(CastNum(value));
- if (discard_flag)
- dc_free_num(&value);
- return (int)result;
-}
-
-/* convert a C integer value into a dc_num */
-/* For convenience of the caller, package the dc_num
- * into a dc_data result.
- */
-dc_data
-dc_int2data DC_DECLARG((value))
- int value DC_DECLEND
-{
- dc_data result;
-
- init_num((bc_num *)&result.v.number);
- int2num((bc_num *)&result.v.number, value);
- result.dc_type = DC_NUMBER;
- return result;
-}
-
-/* get a dc_num from some input stream;
- * input is a function which knows how to read the desired input stream
- * ibase is the input base (2<=ibase<=DC_IBASE_MAX)
- * *readahead will be set to the readahead character consumed while
- * looking for the end-of-number
- */
-/* For convenience of the caller, package the dc_num
- * into a dc_data result.
- */
-dc_data
-dc_getnum DC_DECLARG((input, ibase, readahead))
- int (*input) DC_PROTO((void)) DC_DECLSEP
- int ibase DC_DECLSEP
- int *readahead DC_DECLEND
-{
- bc_num base;
- bc_num result;
- bc_num build;
- bc_num tmp;
- bc_num divisor;
- dc_data full_result;
- int negative = 0;
- int digit;
- int decimal;
- int c;
-
- init_num(&tmp);
- init_num(&build);
- init_num(&base);
- result = copy_num(_zero_);
- int2num(&base, ibase);
- c = (*input)();
- while (isspace(c))
- c = (*input)();
- if (c == '_' || c == '-'){
- negative = c;
- c = (*input)();
- }else if (c == '+'){
- c = (*input)();
- }
- while (isspace(c))
- c = (*input)();
- for (;;){
- if (isdigit(c))
- digit = c - '0';
- else if ('A' <= c && c <= 'F')
- digit = 10 + c - 'A';
- else
- break;
- c = (*input)();
- int2num(&tmp, digit);
- bc_multiply(result, base, &result, 0);
- bc_add(result, tmp, &result);
- }
- if (c == '.'){
- free_num(&build);
- free_num(&tmp);
- divisor = copy_num(_one_);
- build = copy_num(_zero_);
- decimal = 0;
- for (;;){
- c = (*input)();
- if (isdigit(c))
- digit = c - '0';
- else if ('A' <= c && c <= 'F')
- digit = 10 + c - 'A';
- else
- break;
- int2num(&tmp, digit);
- bc_multiply(build, base, &build, 0);
- bc_add(build, tmp, &build);
- bc_multiply(divisor, base, &divisor, 0);
- ++decimal;
- }
- bc_divide(build, divisor, &build, decimal);
- bc_add(result, build, &result);
- }
- /* Final work. */
- if (negative)
- bc_sub(_zero_, result, &result);
-
- free_num(&tmp);
- free_num(&build);
- free_num(&base);
- if (readahead)
- *readahead = c;
- full_result.v.number = (dc_num)result;
- full_result.dc_type = DC_NUMBER;
- return full_result;
-}
-
-
-/* return the "length" of the number */
-int
-dc_numlen DC_DECLARG((value))
- dc_num value DC_DECLEND
-{
- bc_num num = CastNum(value);
-
- /* is this right??? */
- return num->n_len + num->n_scale;
-}
-
-/* return the scale factor of the passed dc_num
- * If discard_flag is true then deallocate the value after use.
- */
-int
-dc_tell_scale DC_DECLARG((value, discard_flag))
- dc_num value DC_DECLSEP
- dc_boolean discard_flag DC_DECLEND
-{
- int kscale;
-
- kscale = CastNum(value)->n_scale;
- if (discard_flag)
- dc_free_num(&value);
- return kscale;
-}
-
-
-/* initialize the math subsystem */
-void
-dc_math_init DC_DECLVOID()
-{
- init_numbers();
-}
-
-/* print out a dc_num in output base obase to stdout;
- * if newline is true, terminate output with a '\n';
- * if discard_flag is true then deallocate the value after use
- */
-void
-dc_out_num DC_DECLARG((value, obase, newline, discard_flag))
- dc_num value DC_DECLSEP
- int obase DC_DECLSEP
- dc_boolean newline DC_DECLSEP
- dc_boolean discard_flag DC_DECLEND
-{
- out_num(CastNum(value), obase, out_char);
- if (newline)
- out_char('\n');
- if (discard_flag)
- dc_free_num(&value);
-}
-
-
-/* deallocate an instance of a dc_num */
-void
-dc_free_num DC_DECLARG((value))
- dc_num *value DC_DECLEND
-{
- free_num((bc_num *)value);
-}
-
-/* return a duplicate of the number in the passed value */
-/* The mismatched data types forces the caller to deal with
- * bad dc_type'd dc_data values, and makes it more convenient
- * for the caller to not have to do the grunge work of setting
- * up a dc_type result.
- */
-dc_data
-dc_dup_num DC_DECLARG((value))
- dc_num value DC_DECLEND
-{
- dc_data result;
-
- ++CastNum(value)->n_refs;
- result.v.number = value;
- result.dc_type = DC_NUMBER;
- return result;
-}
-
-
-
-/*---------------------------------------------------------------------------\
-| The rest of this file consists of stubs for bc routines called by number.c |
-| so as to minimize the amount of bc code needed to build dc. |
-| The bulk of the code was just lifted straight out of the bc source. |
-\---------------------------------------------------------------------------*/
-
-#include <stdlib.h>
-
-#if __STDC__
-# include <stdarg.h>
-#else
-# include <varargs.h>
-#endif
-
-
-int out_col = 0;
-
-/* Output routines: Write a character CH to the standard output.
- It keeps track of the number of characters output and may
- break the output with a "\<cr>". */
-
-void
-out_char (ch)
- char ch;
-{
-
- if (ch == '\n')
- {
- out_col = 0;
- putchar ('\n');
- }
- else
- {
- out_col++;
- if (out_col == 70)
- {
- putchar ('\\');
- putchar ('\n');
- out_col = 1;
- }
- putchar (ch);
- }
-}
-
-/* Malloc could not get enought memory. */
-
-void
-out_of_memory()
-{
- dc_memfail();
-}
-
-/* Runtime error will print a message and stop the machine. */
-
-#if __STDC__
-void
-rt_error (char *mesg, ...)
-#else
-void
-rt_error (mesg, va_alist)
- char *mesg;
- va_dcl
-#endif
-{
- va_list args;
- char error_mesg [255];
-
-#if __STDC__
- va_start (args, mesg);
-#else
- va_start (args);
-#endif
- vsprintf (error_mesg, mesg, args);
- va_end (args);
-
- fprintf (stderr, "Runtime error: %s\n", error_mesg);
-}
-
-
-/* A runtime warning tells of some action taken by the processor that
- may change the program execution but was not enough of a problem
- to stop the execution. */
-
-#if __STDC__
-void
-rt_warn (char *mesg, ...)
-#else
-void
-rt_warn (mesg, va_alist)
- char *mesg;
- va_dcl
-#endif
-{
- va_list args;
- char error_mesg [255];
-
-#if __STDC__
- va_start (args, mesg);
-#else
- va_start (args);
-#endif
- vsprintf (error_mesg, mesg, args);
- va_end (args);
-
- fprintf (stderr, "Runtime warning: %s\n", error_mesg);
-}
diff --git a/gnu/usr.bin/dc/dc-proto.h b/gnu/usr.bin/dc/dc-proto.h
deleted file mode 100644
index 97d7aff..0000000
--- a/gnu/usr.bin/dc/dc-proto.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * prototypes of all externally visible dc functions
- *
- * Copyright (C) 1994 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, you can either send email to this
- * program's author (see below) or write to: The Free Software Foundation,
- * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
- */
-
-extern const char *dc_str2charp DC_PROTO((dc_str));
-extern const char *dc_system DC_PROTO((const char *));
-extern void *dc_malloc DC_PROTO((size_t));
-
-extern void dc_array_set DC_PROTO((int, int, dc_data));
-extern void dc_array_init DC_PROTO((void));
-extern void dc_binop DC_PROTO((int (*)(dc_num, dc_num, int, dc_num *), int));
-extern void dc_clear_stack DC_PROTO((void));
-extern void dc_free_num DC_PROTO((dc_num *));
-extern void dc_free_str DC_PROTO((dc_str *));
-extern void dc_garbage DC_PROTO((const char *, int));
-extern void dc_math_init DC_PROTO((void));
-extern void dc_memfail DC_PROTO((void));
-extern void dc_out_num DC_PROTO((dc_num, int, dc_boolean, dc_boolean));
-extern void dc_out_str DC_PROTO((dc_str, dc_boolean, dc_boolean));
-extern void dc_print DC_PROTO((dc_data, int));
-extern void dc_printall DC_PROTO((int));
-extern void dc_push DC_PROTO((dc_data));
-extern void dc_register_init DC_PROTO((void));
-extern void dc_register_push DC_PROTO((int, dc_data));
-extern void dc_register_set DC_PROTO((int, dc_data));
-extern void dc_show_id DC_PROTO((FILE *, int, const char *));
-extern void dc_string_init DC_PROTO((void));
-
-extern int dc_cmpop DC_PROTO((void));
-extern int dc_compare DC_PROTO((dc_num, dc_num));
-extern int dc_evalfile DC_PROTO((FILE *));
-extern int dc_num2int DC_PROTO((dc_num, dc_boolean));
-extern int dc_numlen DC_PROTO((dc_num));
-extern int dc_pop DC_PROTO((dc_data *));
-extern int dc_register_get DC_PROTO((int, dc_data *));
-extern int dc_register_pop DC_PROTO((int, dc_data *));
-extern int dc_tell_length DC_PROTO((dc_data, dc_boolean));
-extern int dc_tell_scale DC_PROTO((dc_num, dc_boolean));
-extern int dc_tell_stackdepth DC_PROTO((void));
-extern int dc_top_of_stack DC_PROTO((dc_data *));
-
-extern size_t dc_strlen DC_PROTO((dc_str));
-
-extern dc_data dc_array_get DC_PROTO((int, int));
-extern dc_data dc_dup DC_PROTO((dc_data));
-extern dc_data dc_dup_num DC_PROTO((dc_num));
-extern dc_data dc_dup_str DC_PROTO((dc_str));
-extern dc_data dc_getnum DC_PROTO((int (*)(void), int, int *));
-extern dc_data dc_int2data DC_PROTO((int));
-extern dc_data dc_makestring DC_PROTO((const char *, size_t));
-extern dc_data dc_readstring DC_PROTO((FILE *, int , int));
-
-extern int dc_add DC_PROTO((dc_num, dc_num, int, dc_num *));
-extern int dc_div DC_PROTO((dc_num, dc_num, int, dc_num *));
-extern int dc_exp DC_PROTO((dc_num, dc_num, int, dc_num *));
-extern int dc_mul DC_PROTO((dc_num, dc_num, int, dc_num *));
-extern int dc_rem DC_PROTO((dc_num, dc_num, int, dc_num *));
-extern int dc_sub DC_PROTO((dc_num, dc_num, int, dc_num *));
-extern int dc_sqrt DC_PROTO((dc_num, int, dc_num *));
diff --git a/gnu/usr.bin/dc/dc-regdef.h b/gnu/usr.bin/dc/dc-regdef.h
deleted file mode 100644
index 4142205..0000000
--- a/gnu/usr.bin/dc/dc-regdef.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * definitions for dc's "register" declarations
- *
- * Copyright (C) 1994 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, you can either send email to this
- * program's author (see below) or write to: The Free Software Foundation,
- * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
- */
-
-#include <limits.h>
-
-/* determine how many register stacks there are */
-#ifndef DC_REGCOUNT
-# ifndef UCHAR_MAX
-# define DC_REGCOUNT 256
-# else
-# define DC_REGCOUNT (UCHAR_MAX+1)
-# endif
-#endif /* not DC_REGCOUNT */
-
-/* efficiency hack for masking arbritrary integers to 0..(DC_REGCOUNT-1) */
-#if (DC_REGCOUNT & (DC_REGCOUNT-1)) == 0 /* DC_REGCOUNT is power of 2 */
-# define regmap(r) ((r) & (DC_REGCOUNT-1))
-#else
-# define regmap(r) ((r) % DC_REGCOUNT)
-#endif
diff --git a/gnu/usr.bin/dc/dc-stack.c b/gnu/usr.bin/dc/dc-stack.c
deleted file mode 100644
index 76e61b3..0000000
--- a/gnu/usr.bin/dc/dc-stack.c
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * implement stack functions for dc
- *
- * Copyright (C) 1994 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, you can either send email to this
- * program's author (see below) or write to: The Free Software Foundation,
- * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
- */
-
-/* This module is the only one that knows what stacks (both the
- * regular evaluation stack and the named register stacks)
- * look like.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "dc.h"
-#include "dc-proto.h"
-#include "dc-regdef.h"
-
-/* an oft-used error message: */
-#define Empty_Stack fprintf(stderr, "%s: stack empty\n", progname)
-
-
-/* simple linked-list implementaion suffices: */
-struct dc_list {
- dc_data value;
- struct dc_list *link;
-};
-typedef struct dc_list dc_list;
-
-/* the anonymous evaluation stack */
-static dc_list *dc_stack=NULL;
-
-/* the named register stacks */
-static dc_list *dc_register[DC_REGCOUNT];
-
-
-/* allocate a new dc_list item */
-static dc_list *
-dc_alloc DC_DECLVOID()
-{
- dc_list *result;
-
- result = dc_malloc(sizeof *result);
- result->value.dc_type = DC_UNINITIALIZED;
- result->link = NULL;
- return result;
-}
-
-
-/* check that there are two numbers on top of the stack,
- * then call op with the popped numbers. Construct a dc_data
- * value from the dc_num returned by op and push it
- * on the stack.
- * If the op call doesn't return DC_SUCCESS, then leave the stack
- * unmodified.
- */
-void
-dc_binop DC_DECLARG((op, kscale))
- int (*op)DC_PROTO((dc_num, dc_num, int, dc_num *)) DC_DECLSEP
- int kscale DC_DECLEND
-{
- dc_data a;
- dc_data b;
- dc_data r;
-
- if (!dc_stack || !dc_stack->link){
- Empty_Stack;
- return;
- }
- if (dc_stack->value.dc_type!=DC_NUMBER
- || dc_stack->link->value.dc_type!=DC_NUMBER){
- fprintf(stderr, "%s: non-numeric value\n", progname);
- return;
- }
- (void)dc_pop(&b);
- (void)dc_pop(&a);
- if ((*op)(a.v.number, b.v.number, kscale, &r.v.number) == DC_SUCCESS){
- r.dc_type = DC_NUMBER;
- dc_push(r);
- dc_free_num(&a.v.number);
- dc_free_num(&b.v.number);
- }else{
- /* op failed; restore the stack */
- dc_push(a);
- dc_push(b);
- }
-}
-
-/* check that there are two numbers on top of the stack,
- * then call dc_compare with the popped numbers.
- * Return negative, zero, or positive based on the ordering
- * of the two numbers.
- */
-int
-dc_cmpop DC_DECLVOID()
-{
- int result;
- dc_data a;
- dc_data b;
-
- if (!dc_stack || !dc_stack->link){
- Empty_Stack;
- return 0;
- }
- if (dc_stack->value.dc_type!=DC_NUMBER
- || dc_stack->link->value.dc_type!=DC_NUMBER){
- fprintf(stderr, "%s: non-numeric value\n", progname);
- return 0;
- }
- (void)dc_pop(&b);
- (void)dc_pop(&a);
- result = dc_compare(b.v.number, a.v.number);
- dc_free_num(&a.v.number);
- dc_free_num(&b.v.number);
- return result;
-}
-
-
-/* initialize the register stacks to their initial values */
-void
-dc_register_init DC_DECLVOID()
-{
- int i;
-
- for (i=0; i<DC_REGCOUNT; ++i)
- dc_register[i] = NULL;
-}
-
-/* clear the evaluation stack */
-void
-dc_clear_stack DC_DECLVOID()
-{
- dc_list *n;
- dc_list *t;
-
- for (n=dc_stack; n; n=t){
- t = n->link;
- if (n->value.dc_type == DC_NUMBER)
- dc_free_num(&n->value.v.number);
- else if (n->value.dc_type == DC_STRING)
- dc_free_str(&n->value.v.string);
- else
- dc_garbage("in stack", -1);
- free(n);
- }
- dc_stack = NULL;
-}
-
-/* push a value onto the evaluation stack */
-void
-dc_push DC_DECLARG((value))
- dc_data value DC_DECLEND
-{
- dc_list *n = dc_alloc();
-
- if (value.dc_type!=DC_NUMBER && value.dc_type!=DC_STRING)
- dc_garbage("in data being pushed", -1);
- n->value = value;
- n->link = dc_stack;
- dc_stack = n;
-}
-
-/* push a value onto the named register stack */
-void
-dc_register_push DC_DECLARG((stackid, value))
- int stackid DC_DECLSEP
- dc_data value DC_DECLEND
-{
- dc_list *n = dc_alloc();
-
- stackid = regmap(stackid);
- n->value = value;
- n->link = dc_register[stackid];
- dc_register[stackid] = n;
-}
-
-/* set *result to the value on the top of the evaluation stack */
-/* The caller is responsible for duplicating the value if it
- * is to be maintained as anything more than a transient identity.
- *
- * DC_FAIL is returned if the stack is empty (and *result unchanged),
- * DC_SUCCESS is returned otherwise
- */
-int
-dc_top_of_stack DC_DECLARG((result))
- dc_data *result DC_DECLEND
-{
- if (!dc_stack){
- Empty_Stack;
- return DC_FAIL;
- }
- if (dc_stack->value.dc_type!=DC_NUMBER
- && dc_stack->value.dc_type!=DC_STRING)
- dc_garbage("at top of stack", -1);
- *result = dc_stack->value;
- return DC_SUCCESS;
-}
-
-/* set *result to a dup of the value on the top of the named register stack */
-/*
- * DC_FAIL is returned if the named stack is empty (and *result unchanged),
- * DC_SUCCESS is returned otherwise
- */
-int
-dc_register_get DC_DECLARG((regid, result))
- int regid DC_DECLSEP
- dc_data *result DC_DECLEND
-{
- dc_list *r;
-
- regid = regmap(regid);
- r = dc_register[regid];
- if ( ! r ){
- fprintf(stderr, "%s: register ", progname);
- dc_show_id(stderr, regid, " is empty\n");
- return DC_FAIL;
- }
- *result = dc_dup(r->value);
- return DC_SUCCESS;
-}
-
-/* set the top of the named register stack to the indicated value */
-/* If the named stack is empty, craft a stack entry to enter the
- * value into.
- */
-void
-dc_register_set DC_DECLARG((regid, value))
- int regid DC_DECLSEP
- dc_data value DC_DECLEND
-{
- dc_list *r;
-
- regid = regmap(regid);
- r = dc_register[regid];
- if ( ! r )
- dc_register[regid] = dc_alloc();
- else if (r->value.dc_type == DC_NUMBER)
- dc_free_num(&r->value.v.number);
- else if (r->value.dc_type == DC_STRING)
- dc_free_str(&r->value.v.string);
- else
- dc_garbage("", regid);
- dc_register[regid]->value = value;
-}
-
-/* pop from the evaluation stack
- *
- * DC_FAIL is returned if the stack is empty (and *result unchanged),
- * DC_SUCCESS is returned otherwise
- */
-int
-dc_pop DC_DECLARG((result))
- dc_data *result DC_DECLEND
-{
- dc_list *r;
-
- r = dc_stack;
- if (!r){
- Empty_Stack;
- return DC_FAIL;
- }
- if (r->value.dc_type!=DC_NUMBER && r->value.dc_type!=DC_STRING)
- dc_garbage("at top of stack", -1);
- *result = r->value;
- dc_stack = r->link;
- free(r);
- return DC_SUCCESS;
-}
-
-/* pop from the named register stack
- *
- * DC_FAIL is returned if the named stack is empty (and *result unchanged),
- * DC_SUCCESS is returned otherwise
- */
-int
-dc_register_pop DC_DECLARG((stackid, result))
- int stackid DC_DECLSEP
- dc_data *result DC_DECLEND
-{
- dc_list *r;
-
- stackid = regmap(stackid);
- r = dc_register[stackid];
- if (!r){
- fprintf(stderr, "%s: stack register ", progname);
- dc_show_id(stderr, stackid, " is empty\n");
- return DC_FAIL;
- }
- if (r->value.dc_type!=DC_NUMBER && r->value.dc_type!=DC_STRING)
- dc_garbage(" stack", stackid);
- *result = r->value;
- dc_register[stackid] = r->link;
- free(r);
- return DC_SUCCESS;
-}
-
-
-/* tell how many entries are currently on the evaluation stack */
-int
-dc_tell_stackdepth DC_DECLVOID()
-{
- dc_list *n;
- int depth=0;
-
- for (n=dc_stack; n; n=n->link)
- ++depth;
- return depth;
-}
-
-
-/* return the length of the indicated data value;
- * if discard_flag is true, the deallocate the value when done
- *
- * The definition of a datum's length is deligated to the
- * appropriate module.
- */
-int
-dc_tell_length DC_DECLARG((value, discard_flag))
- dc_data value DC_DECLSEP
- dc_boolean discard_flag DC_DECLEND
-{
- int length;
-
- if (value.dc_type == DC_NUMBER){
- length = dc_numlen(value.v.number);
- if (discard_flag == DC_TRUE)
- dc_free_num(&value.v.number);
- } else if (value.dc_type == DC_STRING) {
- length = dc_strlen(value.v.string);
- if (discard_flag == DC_TRUE)
- dc_free_str(&value.v.string);
- } else {
- dc_garbage("in tell_length", -1);
- /*NOTREACHED*/
- length = 0; /*just to suppress spurious compiler warnings*/
- }
- return length;
-}
-
-
-
-/* print out all of the values on the evaluation stack */
-void
-dc_printall DC_DECLARG((obase))
- int obase DC_DECLEND
-{
- dc_list *n;
-
- for (n=dc_stack; n; n=n->link)
- dc_print(n->value, obase);
-}
diff --git a/gnu/usr.bin/dc/dc-string.c b/gnu/usr.bin/dc/dc-string.c
deleted file mode 100644
index 262cb03..0000000
--- a/gnu/usr.bin/dc/dc-string.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * implement string functions for dc
- *
- * Copyright (C) 1994 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, you can either send email to this
- * program's author (see below) or write to: The Free Software Foundation,
- * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
- */
-
-/* This should be the only module that knows the internals of type dc_string */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include "dc.h"
-#include "dc-proto.h"
-
-struct dc_string {
- char *s_ptr; /* pointer to base of string */
- size_t s_len; /* length of counted string */
- int s_refs; /* reference count to cut down on memory use by duplicates */
-};
-
-
-/* return a duplicate of the string in the passed value */
-/* The mismatched data types forces the caller to deal with
- * bad dc_type'd dc_data values, and makes it more convenient
- * for the caller to not have to do the grunge work of setting
- * up a dc_type result.
- */
-dc_data
-dc_dup_str DC_DECLARG((value))
- dc_str value DC_DECLEND
-{
- dc_data result;
-
- ++((struct dc_string *)value)->s_refs;
- result.v.string = value;
- result.dc_type = DC_STRING;
- return result;
-}
-
-/* free an instance of a dc_str value */
-void
-dc_free_str DC_DECLARG((value))
- dc_str *value DC_DECLEND
-{
- struct dc_string *string = *value;
-
- if (--string->s_refs < 1){
- free(string->s_ptr);
- free(string);
- }
-}
-
-/* Output a dc_str value.
- * Add a trailing newline if "newline" is set.
- * Free the value after use if discard_flag is set.
- */
-void
-dc_out_str DC_DECLARG((value, newline, discard_flag))
- dc_str value DC_DECLSEP
- dc_boolean newline DC_DECLSEP
- dc_boolean discard_flag DC_DECLEND
-{
- struct dc_string *string = value;
-
- printf("%s", string->s_ptr);
- if (newline == DC_TRUE)
- printf("\n");
- if (discard_flag == DC_TRUE)
- dc_free_str(&value);
-}
-
-/* make a copy of a string (base s, length len)
- * into a dc_str value; return a dc_data result
- * with this value
- */
-dc_data
-dc_makestring DC_DECLARG((s, len))
- const char *s DC_DECLSEP
- size_t len DC_DECLEND
-{
- dc_data result;
- struct dc_string *string;
-
- string = dc_malloc(sizeof *string);
- string->s_ptr = dc_malloc(len+1);
- memcpy(string->s_ptr, s, len);
- string->s_ptr[len] = '\0'; /* nul terminated for those who need it */
- string->s_len = len;
- string->s_refs = 1;
- result.v.string = string;
- result.dc_type = DC_STRING;
- return result;
-}
-
-/* read a dc_str value from FILE *fp;
- * if ldelim == rdelim, then read until a ldelim char or EOF is reached;
- * if ldelim != rdelim, then read until a matching rdelim for the
- * (already eaten) first ldelim is read.
- * Return a dc_data result with the dc_str value as its contents.
- */
-dc_data
-dc_readstring DC_DECLARG((fp, ldelim, rdelim))
- FILE *fp DC_DECLSEP
- int ldelim DC_DECLSEP
- int rdelim DC_DECLEND
-{
- static char *line_buf = NULL; /* a buffer to build the string in */
- static size_t buflen = 0; /* the current size of line_buf */
- int depth=1;
- int c;
- char *p;
- const char *end;
-
- if (!line_buf){
- /* initial buflen should be large enough to handle most cases */
- buflen = 2016;
- line_buf = dc_malloc(buflen);
- }
- p = line_buf;
- end = line_buf + buflen;
- for (;;){
- c = getc(fp);
- if (c == EOF)
- break;
- else if (c == rdelim && --depth < 1)
- break;
- else if (c == ldelim)
- ++depth;
- if (p >= end){
- ptrdiff_t offset = p - line_buf;
- /* buflen increment should be big enough
- * to avoid execessive reallocs:
- */
- buflen += 2048;
- line_buf = realloc(line_buf, buflen);
- if (!line_buf)
- dc_memfail();
- p = line_buf + offset;
- end = line_buf + buflen;
- }
- *p++ = c;
- }
- return dc_makestring(line_buf, (size_t)(p-line_buf));
-}
-
-/* return the base pointer of the dc_str value;
- * This function is needed because no one else knows what dc_str
- * looks like.
- */
-const char *
-dc_str2charp DC_DECLARG((value))
- dc_str value DC_DECLEND
-{
- return ((struct dc_string *)value)->s_ptr;
-}
-
-/* return the length of the dc_str value;
- * This function is needed because no one else knows what dc_str
- * looks like, and strlen(dc_str2charp(value)) won't work
- * if there's an embedded '\0'.
- */
-size_t
-dc_strlen DC_DECLARG((value))
- dc_str value DC_DECLEND
-{
- return ((struct dc_string *)value)->s_len;
-}
-
-
-/* initialize the strings subsystem */
-void
-dc_string_init DC_DECLVOID()
-{
- /* nothing to do for this implementation */
-}
diff --git a/gnu/usr.bin/dc/dc-version.h b/gnu/usr.bin/dc/dc-version.h
deleted file mode 100644
index 917be94..0000000
--- a/gnu/usr.bin/dc/dc-version.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * dc version number
- *
- * Copyright (C) 1994 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, you can either send email to this
- * program's author (see below) or write to: The Free Software Foundation,
- * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
- */
-
-#define Version "dc 1.0"
diff --git a/gnu/usr.bin/dc/dc.1 b/gnu/usr.bin/dc/dc.1
deleted file mode 100644
index ce1eda1..0000000
--- a/gnu/usr.bin/dc/dc.1
+++ /dev/null
@@ -1,393 +0,0 @@
-.TH DC 1 "07 Apr 1994" "GNU Project"
-.ds dc \fIdc\fP
-.ds Dc \fIDc\fP
-.SH NAME
-dc \- an arbitrary precision calculator
-.SH SYNOPSIS
-dc
-.SH
-DESCRIPTION
-.PP
-\*(Dc is a reverse-polish desk calculator which supports
-unlimited precision arithmetic.
-It also allows you to define and call macros.
-Normally \*(dc reads from the standard input;
-if any command arguments are given to it, they are filenames,
-and \*(dc reads and executes the contents of the files before reading
-from standard input.
-All normal output is to standard output;
-all error output is to standard error.
-.PP
-A reverse-polish calculator stores numbers on a stack.
-Entering a number pushes it on the stack.
-Arithmetic operations pop arguments off the stack and push the results.
-.PP
-To enter a number in
-.IR dc ,
-type the digits with an optional decimal point.
-Exponential notation is not supported.
-To enter a negative number,
-begin the number with ``_''.
-``-'' cannot be used for this,
-as it is a binary operator for subtraction instead.
-To enter two numbers in succession,
-separate them with spaces or newlines.
-These have no meaning as commands.
-.PD
-.SH
-Printing Commands
-.TP
-.B p
-Prints the value on the top of the stack,
-without altering the stack.
-A newline is printed after the value.
-.TP
-.B P
-Prints the value on the top of the stack, popping it off,
-and does not print a newline after.
-.TP
-.B f
-Prints the entire contents of the stack
-.ig
-and the contents of all of the registers,
-..
-without altering anything.
-This is a good command to use if you are lost or want
-to figure out what the effect of some command has been.
-.PD
-.SH
-Arithmetic
-.TP
-.B +
-Pops two values off the stack, adds them,
-and pushes the result.
-The precision of the result is determined only
-by the values of the arguments,
-and is enough to be exact.
-.TP
-.B -
-Pops two values,
-subtracts the first one popped from the second one popped,
-and pushes the result.
-.TP
-.B *
-Pops two values, multiplies them, and pushes the result.
-The number of fraction digits in the result is controlled
-by the current precision value (see below) and does not
-depend on the values being multiplied.
-.TP
-.B /
-Pops two values,
-divides the second one popped from the first one popped,
-and pushes the result.
-The number of fraction digits is specified by the precision value.
-.TP
-.B %
-Pops two values,
-computes the remainder of the division that the
-.B /
-command would do,
-and pushes that.
-The division is done with as many fraction digits
-as the precision value specifies,
-and the remainder is also computed with that many fraction digits.
-.TP
-.B ^
-Pops two values and exponentiates,
-using the first value popped as the exponent
-and the second popped as the base.
-The fraction part of the exponent is ignored.
-The precision value specifies the number of fraction
-digits in the result.
-.TP
-.B v
-Pops one value,
-computes its square root,
-and pushes that.
-The precision value specifies the number of fraction digits in the result.
-.PP
-Most arithmetic operations are affected by the ``precision value'',
-which you can set with the
-.B k
-command.
-The default precision value is zero,
-which means that all arithmetic except for
-addition and subtraction produces integer results.
-.PP
-The remainder operation
-.B %
-requires some explanation:
-applied to arguments ``a'' and ``b'' it produces ``a - (b * (a / b))'',
-where ``a / b'' is computed in the current precision.
-.SH
-Stack Control
-.TP
-.B c
-Clears the stack, rendering it empty.
-.TP
-.B d
-Duplicates the value on the top of the stack,
-pushing another copy of it.
-Thus, ``4d*p'' computes 4 squared and prints it.
-.SH
-Registers
-.PP
-\*(Dc provides 256 memory registers,
-each named by a single character.
-You can store a number or a string in a register and retrieve it later.
-.TP
-.BI s r
-Pop the value off the top of the stack and store
-it into register
-.IR r .
-.TP
-.BI l r
-Copy the value in register
-.I r
-and push it onto the stack.
-This does not alter the contents of
-.IR r .
-.PP
-Each register also contains its own stack.
-The current register value is the top of the register's stack.
-.TP
-.BI S r
-Pop the value off the top of the (main) stack and
-push it onto the stack of register
-.IR r .
-The previous value of the register becomes inaccessible.
-.TP
-.BI L r
-Pop the value off the top of register
-.IR r 's
-stack and push it onto the main stack.
-The previous value
-in register
-.IR r 's
-stack, if any,
-is now accessible via the
-.BI l r
-command.
-.ig
-.PP
-The
-.B f
-command prints a list of all registers that have contents stored in them,
-together with their contents.
-Only the current contents of each register
-(the top of its stack)
-is printed.
-..
-.SH
-Parameters
-.PP
-\*(Dc has three parameters that control its operation:
-the precision, the input radix, and the output radix.
-The precision specifies the number
-of fraction digits to keep in the result of most arithmetic operations.
-The input radix controls the interpretation of numbers typed in;
-all numbers typed in use this radix.
-The output radix is used for printing numbers.
-.PP
-The input and output radices are separate parameters;
-you can make them unequal,
-which can be useful or confusing.
-The input radix must be between 2 and 36 inclusive.
-The output radix must be at least 2.
-The precision must be zero or greater.
-The precision is always measured in decimal digits,
-regardless of the current input or output radix.
-.TP
-.B i
-Pops the value off the top of the stack
-and uses it to set the input radix.
-.TP
-.B o
-Pops the value off the top of the stack
-and uses it to set the output radix.
-.TP
-.B k
-Pops the value off the top of the stack
-and uses it to set the precision.
-.TP
-.B I
-Pushes the current input radix on the stack.
-.TP
-.B O
-Pushes the current output radix on the stack.
-.TP
-.B K
-Pushes the current precision on the stack.
-.SH
-Strings
-.PP
-\*(Dc can operate on strings as well as on numbers.
-The only things you can do with strings are
-print them and execute them as macros
-(which means that the contents of the string are processed as
-\*(dc commands).
-All registers and the stack can hold strings,
-and \*(dc always knows whether any given object is a string or a number.
-Some commands such as arithmetic operations demand numbers
-as arguments and print errors if given strings.
-Other commands can accept either a number or a string;
-for example, the
-.B p
-command can accept either and prints the object
-according to its type.
-.TP
-.BI [ characters ]
-Makes a string containing
-.I characters
-(contained between balanced
-.B [
-and
-.B ]
-characters),
-and pushes it on the stack.
-For example,
-.B [foo]P
-prints the characters
-.B foo
-(with no newline).
-.TP
-.B x
-Pops a value off the stack and executes it as a macro.
-Normally it should be a string;
-if it is a number,
-it is simply pushed back onto the stack.
-For example,
-.B [1p]x
-executes the macro
-.B 1p
-which pushes
-.B 1
-on the stack and prints
-.B 1
-on a separate line.
-.PP
-Macros are most often stored in registers;
-.B [1p]sa
-stores a macro to print
-.B 1
-into register
-.BR a ,
-and
-.B lax
-invokes this macro.
-.TP
-.BI > r
-Pops two values off the stack and compares them
-assuming they are numbers,
-executing the contents of register
-.I r
-as a macro if the original top-of-stack
-is greater.
-Thus,
-.B 1 2>a
-will invoke register
-.BR a 's
-contents and
-.B 2 1>a
-will not.
-.TP
-.BI < r
-Similar but invokes the macro if the original top-of-stack is less.
-.TP
-.BI = r
-Similar but invokes the macro if the two numbers popped are equal.
-.ig
-This can also be validly used to compare two strings for equality.
-..
-.TP
-.B ?
-Reads a line from the terminal and executes it.
-This command allows a macro to request input from the user.
-.TP
-.B q
-exits from a macro and also from the macro which invoked it.
-If called from the top level,
-or from a macro which was called directly from the top level,
-the
-.B q
-command will cause \*(dc to exit.
-.TP
-.B Q
-Pops a value off the stack and uses it as a count
-of levels of macro execution to be exited.
-Thus,
-.B 3Q
-exits three levels.
-The
-.B Q
-command will never cause \*(dc to exit.
-.SH
-Status Inquiry
-.TP
-.B Z
-Pops a value off the stack,
-calculates the number of digits it has
-(or number of characters, if it is a string)
-and pushes that number.
-.TP
-.B X
-Pops a value off the stack,
-calculates the number of fraction digits it has,
-and pushes that number.
-For a string,
-the value pushed is
-.\" -1.
-0.
-.TP
-.B z
-Pushes the current stack depth;
-the number of objects on the stack before the execution of the
-.B z
-command.
-.SH
-Miscellaneous
-.TP
-.B !
-Will run the rest of the line as a system command.
-.TP
-.B #
-Will interpret the rest of the line as a comment.
-.TP
-.BI : r
-Will pop the top two values off of the stack.
-The old second-to-top value will be stored in the array
-.IR r ,
-indexed by the old top-of-stack value.
-.TP
-.BI ; r
-Pops the top-of-stack and uses it as an index into
-the array
-.IR r .
-The selected value is then pushed onto the stack.
-.SH
-NOTES
-.PP
-The array operations
-.B :
-and
-.B ;
-are usually only used by traditional implementations of
-.IR bc .
-(The GNU
-.I bc
-is self contained and does not need \*(dc to run.)
-The comment operator
-.B #
-is a new command not found in traditional implementations of
-.IR dc .
-.SH
-BUGS
-.PP
-Email bug reports to
-.BR bug-gnu-utils@prep.ai.mit.edu .
-Be sure to include the word ``dc'' somewhere in the ``Subject:'' field.
-.SH HISTORY
-A
-.I dc
-command appeared in
-Version 1 AT&T UNIX.
diff --git a/gnu/usr.bin/dc/dc.h b/gnu/usr.bin/dc/dc.h
deleted file mode 100644
index 7193aea..0000000
--- a/gnu/usr.bin/dc/dc.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Header file for dc routines
- *
- * Copyright (C) 1994 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, you can either send email to this
- * program's author (see below) or write to: The Free Software Foundation,
- * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
- */
-
-#ifndef DC_DEFS_H
-#define DC_DEFS_H
-
-/* 'I' is a command, and bases 17 and 18 are quite
- * unusual, so we limit ourselves to bases 2 to 16
- */
-#define DC_IBASE_MAX 16
-
-#define DC_SUCCESS 0
-#define DC_DOMAIN_ERROR 1
-#define DC_FAIL 2 /* generic failure */
-
-
-#ifndef __STDC__
-# define DC_PROTO(x) ()
-# define DC_DECLVOID() ()
-# define DC_DECLARG(arglist) arglist
-# define DC_DECLSEP ;
-# define DC_DECLEND ;
-#else /* __STDC__ */
-# define DC_PROTO(x) x
-# define DC_DECLVOID() (void)
-# define DC_DECLARG(arglist) (
-# define DC_DECLSEP ,
-# define DC_DECLEND )
-#endif /* __STDC__ */
-
-
-typedef enum {DC_FALSE, DC_TRUE} dc_boolean;
-
-
-/* type discriminant for dc_data */
-typedef enum {DC_UNINITIALIZED, DC_NUMBER, DC_STRING} dc_value_type;
-
-/* generic pointer for information hiding */
-typedef void *Opaque;
-
-/* only dc-math.c knows what dc_num's *really* look like */
-typedef Opaque dc_num;
-
-/* only dc-string.c knows what dc_str's *really* look like */
-typedef Opaque dc_str;
-
-
-/* except for the two implementation-specific modules, all
- * dc functions only know of this one generic type of object
- */
-typedef struct {
- dc_value_type dc_type; /* discriminant for union */
- union {
- dc_num number;
- dc_str string;
- } v;
-} dc_data;
-
-
-/* This is dc's only global variable: */
-extern const char *progname; /* basename of program invocation */
-
-#endif /* not DC_DEFS_H */
diff --git a/gnu/usr.bin/dc/doc/Makefile b/gnu/usr.bin/dc/doc/Makefile
deleted file mode 100644
index 41a1d4a..0000000
--- a/gnu/usr.bin/dc/doc/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-INFO = dc
-INFOSECTION= "System Utilities"
-INFOENTRY_dc= "* DC: (dc). The GNU desk calculator."
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/dc/doc/dc.texinfo b/gnu/usr.bin/dc/doc/dc.texinfo
deleted file mode 100644
index 73f687b..0000000
--- a/gnu/usr.bin/dc/doc/dc.texinfo
+++ /dev/null
@@ -1,425 +0,0 @@
-\input texinfo @c -*-texinfo-*-
-@c %**start of header
-@setfilename dc.info
-@settitle dc, an arbitrary precision calculator
-@c %**end of header
-
-@c This file has the new style title page commands.
-@c Run `makeinfo' rather than `texinfo-format-buffer'.
-
-@c smallbook
-
-@c tex
-@c \overfullrule=0pt
-@c end tex
-
-@c Combine indices.
-@synindex cp fn
-@syncodeindex vr fn
-@syncodeindex ky fn
-@syncodeindex pg fn
-@syncodeindex tp fn
-
-@ifinfo
-This file documents @sc{dc}, an arbitrary precision calculator.
-
-Published by the Free Software Foundation,
-675 Massachusetts Avenue,
-Cambridge, MA 02139 USA
-
-Copyright (C) 1984 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-@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
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the entire
-resulting derived work is distributed under the terms of a permission
-notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions,
-except that this permission notice may be stated in a translation approved
-by the Foundation.
-@end ifinfo
-
-@setchapternewpage off
-
-@titlepage
-@title dc, an arbitrary precision calculator
-
-@author by Ken Pizzini
-@author manual by Richard Stallman
-@page
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1994 Free Software Foundation, Inc.
-
-@sp 2
-Published by the Free Software Foundation, @*
-675 Massachusetts Avenue, @*
-Cambridge, MA 02139 USA
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the entire
-resulting derived work is distributed under the terms of a permission
-notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions,
-except that this permission notice may be stated in a translation approved
-by the Foundation.
-
-@end titlepage
-@page
-
-@node Top, Introduction, (dir), (dir)
-
-@menu
-* Introduction:: Introduction
-* Printing Commands:: Printing Commands
-* Arithmetic:: Arithmetic
-* Stack Control:: Stack Control
-* Registers:: Registers
-* Parameters:: Parameters
-* Strings:: Strings
-* Status Inquiry:: Status Inquiry
-* Miscellaneous:: Other commands
-* Notes:: Notes
-@end menu
-
-@node Introduction, Printing Commands, Top, Top
-@comment node-name, next, previous, up
-@chapter Introduction
-
-@sc{dc} is a reverse-polish desk calculator
-which supports unlimited precision arithmetic.
-It also allows you to define and call macros.
-Normally @sc{dc} reads from the standard input;
-if any command arguments are given to it, they are filenames,
-and @sc{dc} reads and executes the contents of the files
-before reading from standard input.
-All normal output is to standard output;
-all error messages are written to standard error.
-
-To exit, use @samp{q}.
-@kbd{C-c} does not exit;
-it is used to abort macros that are looping, etc.
-(Currently this is not true; @kbd{C-c} does exit.)
-
-A reverse-polish calculator stores numbers on a stack.
-Entering a number pushes it on the stack.
-Arithmetic operations pop arguments off the stack and push the results.
-
-To enter a number in @sc{dc}, type the digits,
-with an optional decimal point.
-Exponential notation is not supported.
-To enter a negative number, begin the number with @samp{_}.
-@samp{-} cannot be used for this, as it is a binary operator
-for subtraction instead.
-To enter two numbers in succession,
-separate them with spaces or newlines.
-These have no meaning as commands.
-
-@node Printing Commands, Arithmetic, Introduction, Top
-@chapter Printing Commands
-
-@table @samp
-@item p
-Prints the value on the top of the stack,
-without altering the stack.
-A newline is printed after the value.
-
-@item P
-Prints the value on the top of the stack, popping it off,
-and does not print a newline after.
-
-@item f
-Prints the entire contents of the stack
-@c and the contents of all of the registers,
-without altering anything.
-This is a good command to use if you are lost or want
-to figure out what the effect of some command has been.
-@end table
-
-@node Arithmetic, Stack Control, Printing Commands, Top
-@chapter Arithmetic
-
-@table @samp
-@item +
-Pops two values off the stack, adds them, and pushes the result.
-The precision of the result is determined only
-by the values of the arguments, and is enough to be exact.
-
-@item -
-Pops two values, subtracts the first one popped
-from the second one popped, and pushes the result.
-
-@item *
-Pops two values, multiplies them, and pushes the result.
-The number of fraction digits in the result is controlled
-by the current precision value (see below) and does not
-depend on the values being multiplied.
-
-@item /
-Pops two values, divides the second one popped
-from the first one popped, and pushes the result.
-The number of fraction digits is specified by the precision value.
-
-@item %
-Pops two values,
-computes the remainder of the division that
-the @samp{/} command would do,
-and pushes that.
-The division is done with as many fraction digits
-as the precision value specifies,
-and the remainder is also computed with that many fraction digits.
-
-@item ^
-Pops two values and exponentiates,
-using the first value popped as the exponent
-and the second popped as the base.
-The fraction part of the exponent is ignored.
-The precision value specifies the number of fraction
-digits in the result.
-
-@item v
-Pops one value, computes its square root, and pushes that.
-The precision value specifies the number of fraction digits
-in the result.
-@end table
-
-Most arithmetic operations are affected by the @emph{precision value},
-which you can set with the @samp{k} command.
-The default precision value is zero,
-which means that all arithmetic except for
-addition and subtraction produces integer results.
-
-The remainder operation (@samp{%}) requires some explanation:
-applied to arguments @samp{a} and @samp{b}
-it produces @samp{a - (b * (a / b))},
-where @samp{a / b} is computed in the current precision.
-
-@node Stack Control, Registers, Arithmetic, Top
-@chapter Stack Control
-
-@table @samp
-@item c
-Clears the stack, rendering it empty.
-
-@item d
-Duplicates the value on the top of the stack,
-pushing another copy of it.
-Thus, @samp{4d*p} computes 4 squared and prints it.
-@end table
-
-@node Registers, Parameters, Stack Control, Top
-@chapter Registers
-
-@sc{dc} provides 256 memory registers, each named by a single character.
-You can store a number in a register and retrieve it later.
-
-@table @samp
-@item s@var{r}
-Pop the value off the top of the stack and
-store it into register @var{r}.
-
-@item l@var{r}
-Copy the value in register @var{r},
-and push it onto the stack.
-This does not alter the contents of @var{r}.
-
-Each register also contains its own stack.
-The current register value is the top of the register's stack.
-
-@item S@var{r}
-Pop the value off the top of the (main) stack and
-push it onto the stack of register @var{r}.
-The previous value of the register becomes inaccessible.
-
-@item L@var{r}
-Pop the value off the top of register @var{r}'s stack
-and push it onto the main stack.
-The previous value in register @var{r}'s stack, if any,
-is now accessible via the @samp{l@var{r}} command.
-@end table
-@c
-@c The @samp{f} command prints a list of all registers that have contents
-@c stored in them, together with their contents.
-@c Only the current contents of each register (the top of its stack)
-@c is printed.
-
-@node Parameters, Strings, Registers, Top
-@chapter Parameters
-
-@sc{dc} has three parameters that control its operation:
-the precision, the input radix, and the output radix.
-The precision specifies the number of fraction digits
-to keep in the result of most arithmetic operations.
-The input radix controls the interpretation of numbers typed in;
-@emph{all} numbers typed in use this radix.
-The output radix is used for printing numbers.
-
-The input and output radices are separate parameters;
-you can make them unequal, which can be useful or confusing.
-The input radix must be between 2 and 36 inclusive.
-The output radix must be at least 2.
-The precision must be zero or greater.
-The precision is always measured in decimal digits,
-regardless of the current input or output radix.
-
-@table @samp
-@item i
-Pops the value off the top of the stack
-and uses it to set the input radix.
-
-@item o
-Pops the value off the top of the stack
-and uses it to set the output radix.
-
-@item k
-Pops the value off the top of the stack
-and uses it to set the precision.
-
-@item I
-Pushes the current input radix on the stack.
-
-@item O
-Pushes the current output radix on the stack.
-
-@item K
-Pushes the current precision on the stack.
-
-@end table
-
-@node Strings, Status Inquiry, Parameters, Top
-@chapter Strings
-
-@sc{dc} can operate on strings as well as on numbers.
-The only things you can do with strings are print them
-and execute them as macros
-(which means that the contents of the string are processed as @sc{dc} commands).
-Both registers and the stack can hold strings,
-and @sc{dc} always knows whether any given object is a string or a number.
-Some commands such as arithmetic operations demand numbers
-as arguments and print errors if given strings.
-Other commands can accept either a number or a string;
-for example, the @samp{p} command can accept either and prints the object
-according to its type.
-
-@table @samp
-@item [@var{characters}]
-Makes a string containing @var{characters} and pushes it on the stack.
-For example, @samp{[foo]P} prints the characters @samp{foo}
-(with no newline).
-
-@item x
-Pops a value off the stack and executes it as a macro.
-Normally it should be a string;
-if it is a number, it is simply pushed back onto the stack.
-For example, @samp{[1p]x} executes the macro @samp{1p},
-which pushes 1 on the stack and prints @samp{1} on a separate line.
-
-Macros are most often stored in registers;
-@samp{[1p]sa} stores a macro to print @samp{1} into register @samp{a},
-and @samp{lax} invokes the macro.
-
-@item >@var{r}
-Pops two values off the stack and compares them
-assuming they are numbers,
-executing the contents of register @var{r} as a macro
-if the original top-of-stack is greater.
-Thus, @samp{1 2>a} will invoke register @samp{a}'s contents
-and @samp{2 1>a} will not.
-
-@item <@var{r}
-Similar but invokes the macro if the original top-of-stack is less.
-
-@item =@var{r}
-Similar but invokes the macro if the two numbers popped are equal.
-@c This can also be validly used to compare two strings for equality.
-
-@item ?
-Reads a line from the terminal and executes it.
-This command allows a macro to request input from the user.
-
-@item q
-During the execution of a macro,
-this command exits from the macro and also from the macro which invoked it.
-If called from the top level,
-or from a macro which was called directly from the top level,
-the @samp{q} command will cause @sc{dc} to exit.
-
-@item Q
-Pops a value off the stack and uses it as a count
-of levels of macro execution to be exited.
-Thus, @samp{3Q} exits three levels.
-@end table
-
-@node Status Inquiry, Miscellaneous, Strings, Top
-@chapter Status Inquiry
-
-@table @samp
-@item Z
-Pops a value off the stack,
-calculates the number of digits it has
-(or number of characters, if it is a string)
-and pushes that number.
-
-@item X
-Pops a value off the stack,
-calculates the number of fraction digits it has,
-and pushes that number.
-For a string, the value pushed is
-@c -1.
-0.
-
-@item z
-Pushes the current stack depth;
-the number of objects on the stack
-before the execution of the @samp{z} command.
-@end table
-
-@node Miscellaneous, Notes, Status Inquiry, Top
-@chapter Miscellaneous
-
-@table @samp
-@item !
-Will run the rest of the line as a system command.
-
-@item #
-Will interpret the rest of the line as a comment.
-
-@item :@var{r}
-Will pop the top two values off of the stack.
-The old second-to-top value will be stored in the array @var{r},
-indexed by the old top-of-stack value.
-
-@item ;@var{r}
-Pops the top-of-stack and uses it as an index into
-the array @var{r}.
-The selected value is then pushed onto the stack.
-@end table
-
-@node Notes, , Miscellaneous, Top
-@chapter Notes
-
-The array operations @samp{:} and @samp{;} are usually
-only used by traditional implementations of BC.
-(The GNU BC is self contained and does not need @sc{dc} to run.)
-The comment operator @samp{#} is a new command
-not found in traditional implementations of @sc{dc}.
-
-@contents
-@bye
diff --git a/gnu/usr.bin/dialog/COPYING b/gnu/usr.bin/dialog/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/dialog/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/dialog/Makefile b/gnu/usr.bin/dialog/Makefile
deleted file mode 100644
index 1259141..0000000
--- a/gnu/usr.bin/dialog/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# Makefile for dialog
-# $Id$
-
-PROG= dialog
-MAN1= dialog.1
-
-CFLAGS+= -Wall -Wstrict-prototypes
-
-DPADD+= $(LIBDIALOG) $(LIBNCURSES) $(LIBMYTINFO)
-LDADD+= -ldialog -lncurses -lmytinfo
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/dialog/README b/gnu/usr.bin/dialog/README
deleted file mode 100644
index 975bdac..0000000
--- a/gnu/usr.bin/dialog/README
+++ /dev/null
@@ -1,161 +0,0 @@
-
- dialog - Display dialog boxes in shell script (version 0.3)
- ===========================================================
-
-This is a program that will enable you to present a variety of questions or
-display messages using dialog boxes from a shell script. Currently, these
-types of dialog boxes are implemented: yes/no box, menu box, input box,
-message box, text box, info box, checklist box. The idea of writing this
-program came from the fact that most questions asked in a shell script (and
-many interactive programs as well) can be classified into these few types:
-
-
- 1) One that requires the user to answer either yes or no.
-
- 2) One that presents a number of options for the user to choose.
-
- 3) One that requires the user to input a string.
-
- 4) One that displays a message and optionally wait for a key press
- before continuing.
-
- 5) One that presents a list of options that can be turned on or off.
-
-
-The program 'dialog' can, say for example, be called in a shell script to
-present the first type of questions like this:
-
-
- if dialog --yesno <question text> <height> <width>
- then
- ...
- fi
-
-
- e.g. if dialog --yesno "Do you want to continue?" 7 51
- then
- echo "Continuing..."
- else
- echo "Aborting..."
- fi
-
-
-I've included a sample shell script for each type of boxes in the directory
-samples. The program requires ncurses to compile. Running 'dialog' without
-arguments will display the usage.
-
-
-
-FEATURES
---------
-
- * Friendly dialog box interface with buttons, etc.
-
- * Auto wrap around of question text if it's too long to fit on
- one line.
-
- * "\n" can be inserted in question text to control line breaking
- explicitly. The real newline character '\n' can also be used.
-
- * run-time configruation of color settings and other options using
- a configuration file.
-
-
-
-WHAT'S NEW SINCE VERSION 0.21?
-------------------------------
-
- * some changes for faster screen update.
-
- * much more flexible color settings. Can use all 16 colors
- (8 normal, 8 highlight) of the Linux console.
-
- * added run-time configuration using configuration file.
-
- * some minor bug fixes and cleanups for menubox, checklist and
- textbox.
-
- * added a man page.
-
- * some changes for easier porting to other Unix systems (tested
- on Ultrix, SunOS and HPUX)
-
-
-
-INSTALLATION
-------------
-
- 1. cd ./src
-
- 2. Go to step 3 if your system has ncurses (e.g. Linux).
- Edit Makefile and remove -DHAVE_NCURSES from DEFS. Also
- remove rc.c from SRCS and rc.o from OBJS. Change LIBS as
- appropriate (Usually, it should be '-lcurses -ltermcap').
- Go to step 6.
-
- 3. Edit Makefile and remove -DBROKEN_WSCRL from DEFS if you
- are using ncurses 1.8.3 or newer. Menu scrolling should
- be faster. DON'T REMOVE IT IF YOU ARE NOT USING AT LEAST
- VERSION 1.8.3 OF NCURSES.
-
- 4. Edit dialog.h and change USE_SHADOW to FALSE if you don't
- want shadowed dialog boxes. Also change USE_COLORS to
- FALSE if you don't want colors. Note that 'dialog' will
- check if the terminal supports colors, and will use mono
- settings if it doesn't, so USE_COLORS won't do any harm
- even if you have a mono display. Also note that USE_SHADOW
- implies USE_COLORS. These two options can be changed at
- run-time using the run-time configuration file (see below).
-
- 5. Edit colors.h to change default color definitions if you
- don't like the defaults. These are only compiled in defaults,
- you can change them at run-time using the run-time
- configuration file.
-
- 6. 'make depend; make install' will compile and install the
- binaries in /usr/local/bin (change BINDIR in Makefile if
- you want to install elsewhere).
-
- 7. 'make install.man' will install the man page to
- /usr/local/man (change MANDIR in Makefile if you want to
- install elsewhere).
-
- 8. You can then try the sample shell scripts in the samples
- directory (make sure the environment variable DIALOG is
- not set, the scripts use it to find the dialog binary, if
- it's not set, "../src/dialog" will be used).
-
- 9. Don't forget to mail me (mail address at end of this file)
- if you find any bugs, have some good color settings to
- contribute or just want to tell me that you like it, Don't
- mail me if you don't like it :-)
-
-
-
-RUN-TIME CONFIGURATION
-----------------------
-
- 1. Create a sample configuration file by typing:
-
- "dialog --create-rc <file>"
-
- 2. At start, 'dialog' determines the settings to use as follows:
-
- a) if environment variable DIALOGRC is set, it's value
- determines the name of the configuration file.
-
- b) if the file in (a) can't be found, use the file
- $HOME/.dialogrc as the configuration file.
-
- c) if the file in (b) can't be found, use compiled in
- defaults.
-
- 3. Edit the sample configuration file and copy it to some place
- that 'dialog' can find, as stated in step 2 above.
-
-
-
-
-Comments and bug reports welcome.
-
-- Savio Lam (lam836@cs.cuhk.hk)
diff --git a/gnu/usr.bin/dialog/README.lib b/gnu/usr.bin/dialog/README.lib
deleted file mode 100644
index 472c206..0000000
--- a/gnu/usr.bin/dialog/README.lib
+++ /dev/null
@@ -1,3 +0,0 @@
-Now 'dialog' splitted to this sources and library of functions,
-see /usr/src/gnu/lib/libdialog for details.
- Ache.
diff --git a/gnu/usr.bin/dialog/TESTS/checklist b/gnu/usr.bin/dialog/TESTS/checklist
deleted file mode 100755
index 008e874..0000000
--- a/gnu/usr.bin/dialog/TESTS/checklist
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-DIALOG=${DIALOG=/usr/bin/dialog}
-
-$DIALOG --title "CHECKLIST BOX" --clear \
- --checklist "Hi, this is a checklist box. You can use this to \n\
-present a list of choices which can be turned on or \n\
-off. If there are more items than can fit on the \n\
-screen, the list will be scrolled. You can use the \n\
-UP/DOWN arrow keys, the first letter of the choice as a\n\
-hot key, or the number keys 1-9 to choose an option. \n\
-Press SPACE to toggle an option on/off. \n\n\
- Which of the following are fruits?" -1 -1 5 \
- "Apple" "It's an apple." off \
- "Dog" "No, that's not my dog." ON \
- "Orange" "Yeah, that's juicy." off \
- "Cat" "No, never put a dog and a cat together!" oN \
- "Fish" "Cats like fish." On \
- "Lemon" "You know how it tastes." on 2> /tmp/checklist.tmp.$$
-
-retval=$?
-
-choice=`cat /tmp/checklist.tmp.$$`
-rm -f /tmp/checklist.tmp.$$
-
-case $retval in
- 0)
- echo "'$choice' chosen.";;
- 1)
- echo "Cancel pressed.";;
- 255)
- [ -z "$choice" ] || echo $choice ;
- echo "ESC pressed.";;
-esac
diff --git a/gnu/usr.bin/dialog/TESTS/infobox b/gnu/usr.bin/dialog/TESTS/infobox
deleted file mode 100755
index 89d4736..0000000
--- a/gnu/usr.bin/dialog/TESTS/infobox
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-DIALOG=${DIALOG=/usr/bin/dialog}
-
-$DIALOG --title "INFO BOX" \
- --infobox "Hi, this is an information box. It is
-different from a message box in that it will
-not pause waiting for input after displaying
-the message. The pause here is only introduced
-by the sleep command, not by dialog.
-
-You have 10 seconds to read this..." -1 -1
-
-stty -echo
-sleep 10
-stty echo
diff --git a/gnu/usr.bin/dialog/TESTS/inputbox b/gnu/usr.bin/dialog/TESTS/inputbox
deleted file mode 100755
index 2acb846..0000000
--- a/gnu/usr.bin/dialog/TESTS/inputbox
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-DIALOG=${DIALOG=/usr/bin/dialog}
-
-$DIALOG --title "INPUT BOX" --clear \
- --inputbox "Hi, this is an input dialog box. You can use \n\
-this to ask questions that require the user \n\
-to input a string as the answer. You can \n\
-input strings of length longer than the \n\
-width of the input box, in that case, the \n\
-input field will be automatically scrolled. \n\
-You can use BACKSPACE, LEFT, RIGHT, HOME, END\n\
-to correct errors. \n\n\
-Try inputing your name below:" -1 -1 "John Smith" 2> /tmp/inputbox.tmp.$$
-
-retval=$?
-
-input=`cat /tmp/inputbox.tmp.$$`
-rm -f /tmp/inputbox.tmp.$$
-
-case $retval in
- 0)
- echo "Input string is '$input'";;
- 1)
- echo "Cancel pressed.";;
- 255)
- [ -z "$input" ] || echo $input ;
- echo "ESC pressed.";;
-esac
diff --git a/gnu/usr.bin/dialog/TESTS/menubox b/gnu/usr.bin/dialog/TESTS/menubox
deleted file mode 100755
index f5d4e92..0000000
--- a/gnu/usr.bin/dialog/TESTS/menubox
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-DIALOG=${DIALOG=/usr/bin/dialog}
-
-$DIALOG --clear --title "MENU BOX" \
- --hline "Press 1-9, Up/Down, first letter or Enter" \
- --menu "Hi, this is a menu box. You can use this to \n\
-present a list of choices for the user to \n\
-choose. If there are more items than can fit \n\
-on the screen, the menu will be scrolled. \n\
-You can use the UP/DOWN arrow keys, the first \n\
-letter of the choice as a hot key, or the \n\
-number keys 1-9 to choose an option.\n\
-Try it now!\n\n\
- Choose the OS you like:" -1 -1 4 \
- "FreeBSD 2.0" "A Real Operating System for Real Users" \
- "Linux" "Another free Unix Clone for 386/486" \
- "OS/2" "IBM OS/2" \
- "WIN NT" "Microsoft Windows NT" \
- "PCDOS" "IBM PC DOS" \
- "MSDOS" "Microsoft DOS" 2> /tmp/menu.tmp.$$
-
-retval=$?
-
-choice=`cat /tmp/menu.tmp.$$`
-rm -f /tmp/menu.tmp.$$
-
-case $retval in
- 0)
- echo "'$choice' chosen.";;
- 1)
- echo "Cancel pressed.";;
- 255)
- [ -z "$choice" ] || echo $choice ;
- echo "ESC pressed.";;
-esac
diff --git a/gnu/usr.bin/dialog/TESTS/msgbox b/gnu/usr.bin/dialog/TESTS/msgbox
deleted file mode 100755
index 7f1b1f8..0000000
--- a/gnu/usr.bin/dialog/TESTS/msgbox
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-DIALOG=${DIALOG=/usr/bin/dialog}
-
-$DIALOG --title "MESSAGE BOX" --clear \
- --msgbox "Hi, this is a simple message box. You can use this to\n\
-display any message you like. The box will remain until\n\
-you press the ENTER key." -1 -1
-
-case $? in
- 0)
- echo "OK";;
- 255)
- echo "ESC pressed.";;
-esac
diff --git a/gnu/usr.bin/dialog/TESTS/prgbox b/gnu/usr.bin/dialog/TESTS/prgbox
deleted file mode 100755
index 5a631f5..0000000
--- a/gnu/usr.bin/dialog/TESTS/prgbox
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-DIALOG=${DIALOG=/usr/bin/dialog}
-
-$DIALOG --title "PROGRAM BOX: 'cal'" --clear \
- --prgbox "cal" 13 27
-
-case $? in
- 0)
- echo "OK";;
- *)
- echo "Exit code:" $?;;
-esac
diff --git a/gnu/usr.bin/dialog/TESTS/radiolist b/gnu/usr.bin/dialog/TESTS/radiolist
deleted file mode 100755
index 7402790..0000000
--- a/gnu/usr.bin/dialog/TESTS/radiolist
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-DIALOG=${DIALOG=/usr/bin/dialog}
-
-$DIALOG --title "RADIOLIST BOX" --clear \
- --radiolist "Hi, this is a radiolist box. You can use this to \n\
-present a list of choices, one of them can be turned \n\
-on or off. If there are more items than can fit on the \n\
-screen, the list will be scrolled. You can use the \n\
-UP/DOWN arrow keys, the first letter of the choice as a\n\
-hot key, or the number keys 1-9 to choose an option. \n\
-Press SPACE to toggle an option on/off. \n\n\
- Which of the following are fruits?" -1 -1 5 \
- "Apple" "It's an apple." off \
- "Dog" "No, that's not my dog." ON \
- "Orange" "Yeah, that's juicy." off \
- "Cat" "No, never put a dog and a cat together!" oFF \
- "Fish" "Cats like fish." OFF \
- "Lemon" "You know how it tastes." oFF 2> /tmp/radiolist.tmp.$$
-
-retval=$?
-
-choice=`cat /tmp/radiolist.tmp.$$`
-rm -f /tmp/radiolist.tmp.$$
-
-case $retval in
- 0)
- echo "'$choice' chosen.";;
- 1)
- echo "Cancel pressed.";;
- 255)
- [ -z "$choice" ] || echo $choice ;
- echo "ESC pressed.";;
-esac
diff --git a/gnu/usr.bin/dialog/TESTS/textbox b/gnu/usr.bin/dialog/TESTS/textbox
deleted file mode 100755
index ed7c2d9..0000000
--- a/gnu/usr.bin/dialog/TESTS/textbox
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-DIALOG=${DIALOG=/usr/bin/dialog}
-
-cat << EOF > /tmp/textbox.tmp.$$
-Hi, this is a text dialog box. It can be used to display text from a file.
-The file should not contain any 'tab' characters, so you should 'expand'
-the file first if it contains 'tab' characters.
-
-It's like a simple text file viewer, with these keys implemented:
-
-PGDN/SPACE - Move down one page
-PGUP/'b' - Move up one page
-DOWN/'j' - Move down one line
-UP/'k' - Move up one line
-LEFT/'h' - Scroll left
-RIGHT/'l' - Scroll right
-'0' - Move to beginning of line
-HOME/'g' - Move to beginning of file
-END/'G' - Move to end of file
-'/' - Forward search
-'?' - Backward search
-'n' - Repeat last search (forward)
-'N' - Repeat last search (backward)
-
-
-The following is a sample text file:
-
-
-EOF
-
-cat ../COPYING | expand >> /tmp/textbox.tmp.$$
-
-$DIALOG --clear --title "TEXT BOX" --textbox "/tmp/textbox.tmp.$$" 22 77
-
-case $? in
- 0)
- echo "OK";;
- 255)
- echo "EXIT choosed.";;
-esac
-
-rm -f /tmp/textbox.tmp.$$
diff --git a/gnu/usr.bin/dialog/TESTS/yesno b/gnu/usr.bin/dialog/TESTS/yesno
deleted file mode 100755
index 36e95c8..0000000
--- a/gnu/usr.bin/dialog/TESTS/yesno
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-DIALOG=${DIALOG=/usr/bin/dialog}
-
-$DIALOG --title "YES/NO BOX" --clear \
- --hline "Press F1 or ? to see GNU GPL" \
- --hfile ../COPYING \
- --yesno "Hi, this is a yes/no dialog box. You can use this to ask \
- questions that have an answer of either yes or no. \
- BTW, do you notice that long lines will be automatically \
- wrapped around so that they can fit in the box? You can \
- also control line breaking explicitly by inserting \
- 'backslash n' at any place you like, but in this case, \
- auto wrap around will be disabled and you will have to \
- control line breaking yourself." 15 61
-
-case $? in
- 0)
- echo "Yes chosen.";;
- 1)
- echo "No chosen.";;
- 255)
- echo "ESC pressed.";;
-esac
diff --git a/gnu/usr.bin/dialog/dialog.1 b/gnu/usr.bin/dialog/dialog.1
deleted file mode 100644
index b0e07c6..0000000
--- a/gnu/usr.bin/dialog/dialog.1
+++ /dev/null
@@ -1,239 +0,0 @@
-.TH DIALOG 1 "10 January 1994"
-.SH NAME
-dialog \- display dialog boxes from shell scripts
-.SH SYNOPSIS
-.B dialog --clear
-.br
-.BI "dialog --create-rc " file
-.br
-.B dialog
-[
-.BI "\-\-title " title
-]
-[
-.B \-\-clear
-]
-[
-.BI "\-\-hline " line
-]
-[
-.BI "\-\-hfile " file
-]
-.B box-options
-.SH DESCRIPTION
-.B Dialog
-is a program which allows you to present a variety of questions or
-display messages in dialog box form from a shell script. The following
-types of dialog objects are currently supported:
-.LP
-.BR yes/no " box," " menu" " box," " input" " box,"
-.BR message " box," " text" " box," " info" " box,"
-.BR checklist " box and" " program" " box."
-.SH OPTIONS
-.TP
-.B \-\-clear
-The screen will be cleared to the
-.BR "screen attribute" " on exit."
-.TP
-.BI \-\-create-rc " file"
-.RB "Since " dialog " supports run-time configuration,"
-this can be used to dump a sample configuration file to the file specified
-by
-.IR file "."
-.TP
-.BI \-\-title " title"
-Specifies a
-.I title
-string to be displayed at the top of the dialog box.
-.TP
-.BI \-\-hline " line"
-Specifies a
-.I line
-string to be displayed at the bottom of the dialog box.
-.TP
-.BI \-\-hfile " file"
-Specifies a
-.I file
-to be displayed by pressing ? or F1.
-.TP
-.B Box Options
-.TP
-.BI \-\-yesno " text height width"
-.RB A " yes/no" " dialog box of size"
-.I height
-rows by
-.I width
-columns will be displayed. The string specified by
-.I text
-is displayed inside the dialog box. If this string is too long to fit
-in one line, it will be automatically divided into multiple lines at
-the appropriate points. The
-.I text
-string may also contain the sub-string
-.I
-"\en"
-or newline characters
-.I `\en\'
-to control line breaking explicitly. This dialog box is useful for
-asking questions that require the user to answer either yes or no.
-.RB "The dialog box has a" " Yes" " button and a " No
-button, in which the user can switch between by pressing the
-.IR TAB " key."
-.TP
-.BI \-\-msgbox " text height width"
-.RB A " message" " box is very similar to a" " yes/no" " box."
-The only difference between a
-.B message
-box and a
-.B yes/no
-box is that a
-.B message
-box has only a single
-.B OK
-button. You can use this dialog box to display any message you like.
-After reading the message, the user can press the
-.I ENTER
-key so that
-.B dialog
-will exit and the calling shell script can continue its operation.
-.TP
-.BI \-\-infobox " text height width"
-.RB An " info" " box is basically a" " message" " box."
-However, in this case,
-.B dialog
-will exit immediately after displaying the message to the user. The
-screen is not cleared when
-.B dialog
-exits, so that the message will remain on the screen until the calling
-shell script clears it later. This is useful when you want to inform
-the user that some operations are carrying on that may require some
-time to finish.
-.TP
-.BI \-\-inputbox " text height width"
-.RB "An " input " box is useful when you want to ask questions that"
-require the user to input a string as the answer. When inputing the
-string, the
-.I BACKSPACE
-key can be used to correct typing errors. If the input string is longer than
-can be fitted in the dialog box, the input field will be scrolled. On exit,
-the input string will be printed on
-.IR stderr "."
-.TP
-.BI \-\-textbox " file height width"
-.RB A " text" " box lets you display the contents of a text file in a"
-dialog box. It is like a simple text file viewer. The user can move
-through the file by using the
-.IR UP/DOWN ", " PGUP/PGDN
-.RI and " HOME/END" " keys available on most keyboards."
-If the lines are too long to be displayed in the box, the
-.I LEFT/RIGHT
-keys can be used to scroll the text region horizontally. For more
-convenience, forward and backward searching functions are also provided.
-.IP "\fB\-\-menu \fItext height width menu-height \fR[ \fItag item \fR] \fI..."
-As its name suggests, a
-.B menu
-box is a dialog box that can be used to present a list of choices in
-the form of a menu for the user to choose. Each menu entry consists of a
-.IR tag " string and an " item " string. The"
-.I tag
-gives the entry a name to distinguish it from the other entries in the
-menu. The
-.I item
-is a short description of the option that the entry represents. The
-user can move between the menu entries by pressing the
-.I UP/DOWN
-keys, the first letter of the
-.I tag
-as a hot-key, or the number keys
-.IR 1-9 ". There are"
-.I menu-height
-entries displayed in the menu at one time, but the menu will be
-scrolled if there are more entries than that. When
-.B dialog
-exits, the
-.I tag
-of the chosen menu entry will be printed on
-.IR stderr "."
-.TP
-.BI \-\-prgbox " command height width"
-.RB A " program" " box lets you display output of command in"
-dialog box.
-.IP "\fB\-\-checklist \fItext height width list-height \fR[ \fItag item status \fR] \fI..."
-.RB "A " checklist " box is similar to a " menu " box in that there are"
-multiple entries presented in the form of a menu. Instead of choosing
-one entry among the entries, each entry can be turned on or off by the
-user. The initial on/off state of each entry is specified by
-.IR status "."
-On exit, a list of the
-.I tag
-strings of those entries that are turned on will be printed on
-.IR stderr "."
-.SH "RUN-TIME CONFIGURATION"
-.TP 4
-1.
-Create a sample configuration file by typing:
-.LP
-.in +1i
-"dialog --create-rc <file>"
-.TP 4
-2.
-At start,
-.B dialog
-determines the settings to use as follows:
-.RS
-.TP 4
-a)
-if environment variable
-.B DIALOGRC
-is set, its value determines the name of the configuration file.
-.TP 4
-b)
-if the file in (a) can't be found, use the file
-.I $HOME/.dialogrc
-as the configuration file.
-.TP 4
-c)
-if the file in (b) can't be found, use compiled in defaults.
-.RE
-.TP 4
-3.
-Edit the sample configuration file and copy it to some place that
-.B dialog
-can find, as stated in step 2 above.
-.SH ENVIRONMENT
-.TP 15
-.B DIALOGRC
-Define this variable if you want to specify the name of the configuration file
-to use.
-.SH FILES
-.TP 20
-.I $HOME/.dialogrc
-default configuration file
-.SH DIAGNOSTICS
-Exit status is 0 if
-.BR dialog " is exited by pressing the " Yes " or " OK
-button, and 1 if the
-.BR No " or " Cancel
-button is pressed. Otherwise, if errors occur inside
-.B dialog
-or
-.B dialog
-is exited by pressing the
-.I ESC
-key, the exit status is -1.
-.SH SEE ALSO
-.Xr dialog 3
-
-.SH BUGS
-Text files containing
-.I tab
-characters may cause problems with
-.B text
-box.
-.I Tab
-characters in text files must first be expanded to spaces before being
-.RB "displayed by " text " box."
-.TP
-Screen update is too slow.
-.SH AUTHOR
-Savio Lam (lam836@cs.cuhk.hk)
diff --git a/gnu/usr.bin/dialog/dialog.c b/gnu/usr.bin/dialog/dialog.c
deleted file mode 100644
index aafd777..0000000
--- a/gnu/usr.bin/dialog/dialog.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * dialog - Display simple dialog boxes from shell scripts
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * 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
- * of the License, 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.
- *
- *
- * HISTORY:
- *
- * 17/12/93 - Version 0.1 released.
- *
- * 19/12/93 - menu will now scroll if there are more items than can fit
- * on the screen.
- * - added 'checklist', a dialog box with a list of options that
- * can be turned on or off. A list of options that are on is
- * returned on exit.
- *
- * 20/12/93 - Version 0.15 released.
- *
- * 29/12/93 - Incorporated patch from Patrick J. Volkerding
- * (volkerdi@mhd1.moorhead.msus.edu) that made these changes:
- * - increased MAX_LEN to 2048
- * - added 'infobox', equivalent to a message box without pausing
- * - added option '--clear' that will clear the screen
- * - Explicit line breaking when printing prompt text can be
- * invoked by real newline '\n' besides the string "\n"
- * - an optional parameter '--title <string>' can be used to
- * specify a title string for the dialog box
- *
- * 03/01/94 - added 'textbox', a dialog box for displaying text from a file.
- * - Version 0.2 released.
- *
- * 04/01/94 - some fixes and improvements for 'textbox':
- * - fixed a bug that will cause a segmentation violation when a
- * line is longer than MAX_LEN characters. Lines will now be
- * truncated if they are longer than MAX_LEN characters.
- * - removed wrefresh() from print_line(). This will increase
- * efficiency of print_page() which calls print_line().
- * - display current position in the form of percentage into file.
- * - Version 0.21 released.
- *
- * 05/01/94 - some changes for faster screen update.
- *
- * 07/01/94 - much more flexible color settings. Can use all 16 colors
- * (8 normal, 8 highlight) of the Linux console.
- *
- * 08/01/94 - added run-time configuration using configuration file.
- *
- * 09/01/94 - some minor bug fixes and cleanups for menubox, checklist and
- * textbox.
- *
- * 11/01/94 - added a man page.
- *
- * 13/01/94 - some changes for easier porting to other Unix systems (tested
- * on Ultrix, SunOS and HPUX)
- * - Version 0.3 released.
- *
- * 08/06/94 - Patches by Stuart Herbert - S.Herbert@shef.ac.uk
- * Fixed attr_clear and the textbox stuff to work with ncurses 1.8.5
- * Fixed the wordwrap routine - it'll actually wrap properly now
- * Added a more 3D look to everything - having your own rc file could
- * prove 'interesting' to say the least :-)
- * Added radiolist option
- * - Version 0.4 released.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <dialog.h>
-
-void Usage(unsigned char *name);
-
-int main(int argc, unsigned char *argv[])
-{
- int offset = 0, clear_screen = 0, end_common_opts = 0, retval;
- unsigned char *title = NULL;
- unsigned char result[MAX_LEN];
- char *hline = NULL, *hfile = NULL;
-
- if (argc < 2) {
- Usage(argv[0]);
- exit(-1);
- }
- else if (!strcmp(argv[1], "--create-rc")) {
-#ifdef HAVE_NCURSES
- if (argc != 3) {
- Usage(argv[0]);
- exit(-1);
- }
- dialog_create_rc(argv[2]);
- return 0;
-#else
- fprintf(stderr, "\nThis option is currently unsupported on your system.\n");
- return -1;
-#endif
- }
-
- while (offset < argc-1 && !end_common_opts) { /* Common options */
- if (!strcmp(argv[offset+1], "--title")) {
- if (argc-offset < 3 || title != NULL) { /* No two "--title" please! */
- Usage(argv[0]);
- exit(-1);
- }
- else {
- title = argv[offset+2];
- offset += 2;
- }
- }
- else if (!strcmp(argv[offset+1], "--hline")) {
- if (argc-offset < 3 || hline != NULL) { /* No two "--hline" please! */
- Usage(argv[0]);
- exit(-1);
- }
- else {
- hline = argv[offset+2];
- use_helpline(hline);
- offset += 2;
- }
- }
- else if (!strcmp(argv[offset+1], "--hfile")) {
- if (argc-offset < 3 || hfile != NULL) { /* No two "--hfile" please! */
- Usage(argv[0]);
- exit(-1);
- }
- else {
- hfile = argv[offset+2];
- use_helpfile(hfile);
- offset += 2;
- }
- }
- else if (!strcmp(argv[offset+1], "--clear")) {
- if (clear_screen) { /* Hey, "--clear" can't appear twice! */
- Usage(argv[0]);
- exit(-1);
- }
- else if (argc == 2) { /* we only want to clear the screen */
- init_dialog();
- dialog_update(); /* init_dialog() will clear the screen for us */
- end_dialog();
- return 0;
- }
- else {
- clear_screen = 1;
- offset++;
- }
- }
- else /* no more common options */
- end_common_opts = 1;
- }
-
- if (argc-1 == offset) { /* no more options */
- Usage(argv[0]);
- exit(-1);
- }
-
- /* Box options */
-
- if (!strcmp(argv[offset+1], "--yesno")) {
- if (argc-offset != 5) {
- Usage(argv[0]);
- exit(-1);
- }
- init_dialog();
- retval = dialog_yesno(title, argv[offset+2], atoi(argv[offset+3]),
- atoi(argv[offset+4]));
-
- dialog_update();
- if (clear_screen) /* clear screen before exit */
- dialog_clear();
- end_dialog();
- return retval;
- }
- else if (!strcmp(argv[offset+1], "--msgbox")) {
- if (argc-offset != 5) {
- Usage(argv[0]);
- exit(-1);
- }
- init_dialog();
- retval = dialog_msgbox(title, argv[offset+2], atoi(argv[offset+3]),
- atoi(argv[offset+4]), 1);
-
- dialog_update();
- if (clear_screen) /* clear screen before exit */
- dialog_clear();
- end_dialog();
- return retval;
- }
- else if (!strcmp(argv[offset+1], "--prgbox")) {
- if (argc-offset != 5) {
- Usage(argv[0]);
- exit(-1);
- }
- init_dialog();
- retval = dialog_prgbox(title, argv[offset+2], atoi(argv[offset+3]),
- atoi(argv[offset+4]), TRUE, TRUE);
-
- dialog_update();
- if (clear_screen) /* clear screen before exit */
- dialog_clear();
- end_dialog();
- return WEXITSTATUS(retval);
- }
- else if (!strcmp(argv[offset+1], "--infobox")) {
- if (argc-offset != 5) {
- Usage(argv[0]);
- exit(-1);
- }
- init_dialog();
- retval = dialog_msgbox(title, argv[offset+2], atoi(argv[offset+3]),
- atoi(argv[offset+4]), 0);
-
- dialog_update();
- if (clear_screen) /* clear screen before exit */
- dialog_clear();
- end_dialog();
- return retval;
- }
- else if (!strcmp(argv[offset+1], "--textbox")) {
- if (argc-offset != 5) {
- Usage(argv[0]);
- exit(-1);
- }
- init_dialog();
- retval = dialog_textbox(title, argv[offset+2], atoi(argv[offset+3]),
- atoi(argv[offset+4]));
-
- dialog_update();
- if (clear_screen) /* clear screen before exit */
- dialog_clear();
- end_dialog();
- return retval;
- }
- else if (!strcmp(argv[offset+1], "--menu")) {
- if (argc-offset < 8 || ((argc-offset) % 2)) {
- Usage(argv[0]);
- exit(-1);
- }
- init_dialog();
- retval = dialog_menu(title, argv[offset+2], atoi(argv[offset+3]),
- atoi(argv[offset+4]), atoi(argv[offset+5]),
- (argc-offset-6)/2, argv+offset + 6, result,
- NULL, NULL);
- dialog_update();
- if (retval == 0)
- fputs(result, stderr);
- if (clear_screen) /* clear screen before exit */
- dialog_clear();
- end_dialog();
- return retval;
- }
- else if (!strcmp(argv[offset+1], "--checklist")) {
- if (argc-offset < 9 || ((argc-offset-6) % 3)) {
- Usage(argv[0]);
- exit(-1);
- }
- init_dialog();
- retval = dialog_checklist(title, argv[offset+2], atoi(argv[offset+3]),
- atoi(argv[offset+4]), atoi(argv[offset+5]),
- (argc-offset-6)/3, argv+offset + 6, result);
-
- dialog_update();
- if (retval == 0) {
- unsigned char *s, *h; int first;
-
- h = result;
- first = 1;
- while ((s = strchr(h, '\n')) != NULL) {
- *s++ = '\0';
- if (!first)
- fputc(' ', stderr);
- else
- first = 0;
- fprintf(stderr, "\"%s\"", h);
- h = s;
- }
- }
- if (clear_screen) /* clear screen before exit */
- dialog_clear();
- end_dialog();
- return retval;
- }
- else if (!strcmp(argv[offset+1], "--radiolist")) {
- if (argc-offset < 9 || ((argc-offset-6) % 3)) {
- Usage(argv[0]);
- exit(-1);
- }
- init_dialog();
- retval = dialog_radiolist(title, argv[offset+2], atoi(argv[offset+3]),
- atoi(argv[offset+4]), atoi(argv[offset+5]),
- (argc-offset-6)/3, argv+offset + 6, result);
-
- dialog_update();
- if (retval == 0)
- fputs(result, stderr);
- if (clear_screen) /* clear screen before exit */
- dialog_clear();
- end_dialog();
- return retval;
- }
- else if (!strcmp(argv[offset+1], "--inputbox")) {
- if (argc-offset != 5 && argc-offset != 6) {
- Usage(argv[0]);
- exit(-1);
- }
- if (argc-offset == 6)
- strcpy(result, argv[offset+5]);
- else
- *result = '\0';
- init_dialog();
- retval = dialog_inputbox(title, argv[offset+2], atoi(argv[offset+3]),
- atoi(argv[offset+4]), result);
-
- dialog_update();
- if (retval == 0)
- fputs(result, stderr);
- if (clear_screen) /* clear screen before exit */
- dialog_clear();
- end_dialog();
- return retval;
- }
-
- Usage(argv[0]);
- exit(-1);
-}
-/* End of main() */
-
-
-/*
- * Print program usage
- */
-void Usage(unsigned char *name)
-{
- fprintf(stderr, "\
-\ndialog version 0.3, by Savio Lam (lam836@cs.cuhk.hk).\
-\n patched to version %s by Stuart Herbert (S.Herbert@shef.ac.uk)\
-\n Changes Copyright (C) 1995 by Andrey A. Chernov, Moscow, Russia\
-\n\
-\n* Display dialog boxes from shell scripts *\
-\n\
-\nUsage: %s --clear\
-\n %s --create-rc <file>\
-\n %s [--title <title>] [--clear] [--hline <line>] [--hfile <file>]\\\
-\n <Box options>\
-\n\
-\nBox options:\
-\n\
-\n --yesno <text> <height> <width>\
-\n --msgbox <text> <height> <width>\
-\n --prgbox \"<command line>\" <height> <width>\
-\n --infobox <text> <height> <width>\
-\n --inputbox <text> <height> <width> [<init string>]\
-\n --textbox <file> <height> <width>\
-\n --menu <text> <height> <width> <menu height> <tag1> <item1>...\
-\n --checklist <text> <height> <width> <list height> <tag1> <item1> <status1>...\
-\n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\n", VERSION, name, name, name);
-}
-/* End of Usage() */
diff --git a/gnu/usr.bin/diff/Makefile b/gnu/usr.bin/diff/Makefile
deleted file mode 100644
index 2aeebb0..0000000
--- a/gnu/usr.bin/diff/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-# $Id: Makefile,v 1.7 1997/02/22 15:45:24 peter Exp $
-
-.PATH: ${.CURDIR}/../../../contrib/diff
-
-PROG= diff
-SRCS= diff.c analyze.c io.c context.c ed.c normal.c ifdef.c util.c dir.c \
- version.c getopt.c getopt1.c side.c cmpbuf.c
-
-# Important for ctype macros!
-CFLAGS+=-funsigned-char
-
-CFLAGS+=-I${.CURDIR}/../../../contrib/diff
-CFLAGS+=-DHAVE_CONFIG_H
-CFLAGS+=-DPR_PROGRAM=\"/usr/bin/pr\"
-
-SUBDIR+= doc
-
-DPADD+= ${LIBGNUREGEX}
-LDADD+= -lgnuregex
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/diff/diff.1 b/gnu/usr.bin/diff/diff.1
deleted file mode 100644
index 4acd3c9..0000000
--- a/gnu/usr.bin/diff/diff.1
+++ /dev/null
@@ -1,470 +0,0 @@
-.TH DIFF 1 "22sep1993" "GNU Tools" "GNU Tools"
-.SH NAME
-diff \- find differences between two files
-.SH SYNOPSIS
-.B diff
-[options] from-file to-file
-.SH DESCRIPTION
-In the simplest case,
-.I diff
-compares the contents of the two files
-.I from-file
-and
-.IR to-file .
-A file name of
-.B \-
-stands for
-text read from the standard input. As a special case,
-.B "diff \- \-"
-compares a copy of standard input to itself.
-
-If
-.I from-file
-is a directory and
-.I to-file
-is not,
-.I diff
-compares the file in
-.I from-file
-whose file name is that of
-.IR to-file ,
-and vice versa. The non-directory file must not be
-.BR \- .
-
-If both
-.I from-file
-and
-.I to-file
-are directories,
-.I diff
-compares corresponding files in both directories, in
-alphabetical order; this comparison is not recursive unless the
-.B \-r
-or
-.B \-\-recursive
-option is given.
-.I diff
-never
-compares the actual contents of a directory as if it were a file. The
-file that is fully specified may not be standard input, because standard
-input is nameless and the notion of ``file with the same name'' does not
-apply.
-
-.B diff
-options begin with
-.BR \- ,
-so normally
-.I from-file
-and
-.I to-file
-may not begin with
-.BR \- .
-However,
-.B \-\-
-as an
-argument by itself treats the remaining arguments as file names even if
-they begin with
-.BR \- .
-.SS Options
-Below is a summary of all of the options that GNU
-.I diff
-accepts.
-Most options have two equivalent names, one of which is a single letter
-preceded by
-.BR \- ,
-and the other of which is a long name preceded by
-.BR \-\- .
-Multiple single letter options (unless they take an
-argument) can be combined into a single command line word:
-.B \-ac
-is
-equivalent to
-.BR "\-a \-c" .
-Long named options can be abbreviated to
-any unique prefix of their name. Brackets
-.RB ( [
-and
-.BR ] )
-indicate that an
-option takes an optional argument.
-.TP
-.BI \- lines
-Show
-.I lines
-(an integer) lines of context. This option does not
-specify an output format by itself; it has no effect unless it is
-combined with
-.B \-c
-or
-.BR \-u .
-This option is obsolete. For proper
-operation,
-.I patch
-typically needs at least two lines of context.
-.TP
-.B \-a
-Treat all files as text and compare them line-by-line, even if they
-do not seem to be text.
-.TP
-.B \-b
-Ignore changes in amount of white space.
-.TP
-.B \-B
-Ignore changes that just insert or delete blank lines.
-.TP
-.B \-\-brief
-Report only whether the files differ, not the details of the
-differences.
-.TP
-.B \-c
-Use the context output format.
-.TP
-.BI "\-C " lines
-.br
-.ns
-.TP
-.BI \-\-context[= lines ]
-Use the context output format, showing
-.I lines
-(an integer) lines of
-context, or three if
-.I lines
-is not given.
-For proper operation,
-.I patch
-typically needs at least two lines of
-context.
-.TP
-.BI \-\-changed\-group\-format= format
-Use
-.I format
-to output a line group containing differing lines from
-both files in if-then-else format.
-.TP
-.B \-d
-Change the algorithm to perhaps find a smaller set of changes. This makes
-.I diff
-slower (sometimes much slower).
-.TP
-.BI "\-D " name
-Make merged if-then-else format output, conditional on the preprocessor
-macro
-.IR name .
-.TP
-.B \-e
-.br
-.ns
-.TP
-.B \-\-ed
-Make output that is a valid
-.I ed
-script.
-.TP
-.BI \-\-exclude= pattern
-When comparing directories, ignore files and subdirectories whose basenames
-match
-.IR pattern .
-.TP
-.BI \-\-exclude\-from= file
-When comparing directories, ignore files and subdirectories whose basenames
-match any pattern contained in
-.IR file .
-.TP
-.B \-\-expand\-tabs
-Expand tabs to spaces in the output, to preserve the alignment of tabs
-in the input files.
-.TP
-.B \-f
-Make output that looks vaguely like an
-.I ed
-script but has changes
-in the order they appear in the file.
-.TP
-.BI "\-F " regexp
-In context and unified format, for each hunk of differences, show some
-of the last preceding line that matches
-.IR regexp .
-.TP
-.B \-\-forward\-ed
-Make output that looks vaguely like an
-.B ed
-script but has changes
-in the order they appear in the file.
-.TP
-.B \-h
-This option currently has no effect; it is present for Unix
-compatibility.
-.TP
-.B \-H
-Use heuristics to speed handling of large files that have numerous
-scattered small changes.
-.TP
-.BI \-\-horizon\-lines= lines
-Do not discard the last
-.I lines
-lines of the common prefix
-and the first
-.I lines
-lines of the common suffix.
-.TP
-.B \-i
-Ignore changes in case; consider upper- and lower-case letters
-equivalent.
-.TP
-.BI "\-I " regexp
-Ignore changes that just insert or delete lines that match
-.IR regexp .
-.TP
-.BI \-\-ifdef= name
-Make merged if-then-else format output, conditional on the preprocessor
-macro
-.IR name .
-.TP
-.B \-\-ignore\-all\-space
-Ignore white space when comparing lines.
-.TP
-.B \-\-ignore\-blank\-lines
-Ignore changes that just insert or delete blank lines.
-.TP
-.B \-\-ignore\-case
-Ignore changes in case; consider upper- and lower-case to be the same.
-.TP
-.BI \-\-ignore\-matching\-lines= regexp
-Ignore changes that just insert or delete lines that match
-.IR regexp .
-.TP
-.B \-\-ignore\-space\-change
-Ignore changes in amount of white space.
-.TP
-.B \-\-initial\-tab
-Output a tab rather than a space before the text of a line in normal or
-context format. This causes the alignment of tabs in the line to look
-normal.
-.TP
-.B \-l
-Pass the output through
-.I pr
-to paginate it.
-.TP
-.BI "\-L " label
-.br
-.ns
-.TP
-.BI \-\-label= label
-Use
-.I label
-instead of the file name in the context format
-and unified format
-headers.
-.TP
-.B \-\-left\-column
-Print only the left column of two common lines in side by side format.
-.TP
-.BI \-\-line\-format= format
-Use
-.I format
-to output all input lines in in-then-else format.
-.TP
-.B \-\-minimal
-Change the algorithm to perhaps find a smaller set of changes. This
-makes
-.I diff
-slower (sometimes much slower).
-.TP
-.B \-n
-Output RCS-format diffs; like
-.B \-f
-except that each command
-specifies the number of lines affected.
-.TP
-.B \-N
-.br
-.ns
-.TP
-.B \-\-new\-file
-In directory comparison, if a file is found in only one directory,
-treat it as present but empty in the other directory.
-.TP
-.BI \-\-new\-group\-format= format
-Use
-.I format
-to output a group of lines taken from just the second
-file in if-then-else format.
-.TP
-.BI \-\-new\-line\-format= format
-Use
-.I format
-to output a line taken from just the second file in
-if-then-else format.
-.TP
-.BI \-\-old\-group\-format= format
-Use
-.I format
-to output a group of lines taken from just the first
-file in if-then-else format.
-.TP
-.BI \-\-old\-line\-format= format
-Use
-.I format
-to output a line taken from just the first file in
-if-then-else format.
-.TP
-.B \-P
-When comparing directories, if a file appears only in the second
-directory of the two, treat it as present but empty in the other.
-.TP
-.B \-\-paginate
-Pass the output through
-.I pr
-to paginate it.
-.TP
-.B \-q
-Report only whether the files differ, not the details of the
-differences.
-.TP
-.B \-\-rcs
-Output RCS-format diffs; like
-.B \-f
-except that each command
-specifies the number of lines affected.
-.TP
-.B \-r
-.br
-.ns
-.TP
-.B \-\-recursive
-When comparing directories, recursively compare any subdirectories
-found.
-.TP
-.B \-s
-.br
-.ns
-.TP
-.B \-\-report\-identical\-files
-Report when two files are the same.
-.TP
-.BI "\-S " file
-When comparing directories, start with the file
-.IR file .
-This is
-used for resuming an aborted comparison.
-.TP
-.B \-\-sdiff\-merge\-assist
-Print extra information to help
-.IR sdiff .
-.I sdiff
-uses this
-option when it runs
-.IR diff .
-This option is not intended for users
-to use directly.
-.TP
-.B \-\-show\-c\-function
-Show which C function each change is in.
-.TP
-.BI \-\-show\-function\-line= regexp
-In context and unified format, for each hunk of differences, show some
-of the last preceding line that matches
-.IR regexp .
-.TP
-.B \-\-side\-by\-side
-Use the side by side output format.
-.TP
-.B \-\-speed\-large\-files
-Use heuristics to speed handling of large files that have numerous
-scattered small changes.
-.TP
-.BI \-\-starting\-file= file
-When comparing directories, start with the file
-.IR file .
-This is
-used for resuming an aborted comparison.
-.TP
-.B \-\-suppress\-common\-lines
-Do not print common lines in side by side format.
-.TP
-.B \-t
-Expand tabs to spaces in the output, to preserve the alignment of tabs
-in the input files.
-.TP
-.B \-T
-Output a tab rather than a space before the text of a line in normal or
-context format. This causes the alignment of tabs in the line to look
-normal.
-.TP
-.B \-\-text
-Treat all files as text and compare them line-by-line, even if they
-do not appear to be text.
-.TP
-.B \-u
-Use the unified output format.
-.TP
-.BI \-\-unchanged\-group\-format= format
-Use
-.I format
-to output a group of common lines taken from both files
-in if-then-else format.
-.TP
-.BI \-\-unchanged\-line\-format= format
-Use
-.I format
-to output a line common to both files in if-then-else
-format.
-.TP
-.B \-\-unidirectional\-new\-file
-When comparing directories, if a file appears only in the second
-directory of the two, treat it as present but empty in the other.
-.TP
-.BI "\-U " lines
-.br
-.ns
-.TP
-.BI \-\-unified[= lines ]
-Use the unified output format, showing
-.I lines
-(an integer) lines of
-context, or three if
-.I lines
-is not given.
-For proper operation,
-.I patch
-typically needs at least two lines of
-context.
-.TP
-.B \-v
-.br
-.ns
-.TP
-.B \-\-version
-Output the version number of
-.IR diff .
-.TP
-.B \-w
-Ignore white space when comparing lines.
-.TP
-.BI "\-W " columns
-.br
-.ns
-.TP
-.BI \-\-width= columns
-Use an output width of
-.I columns
-in side by side format.
-.TP
-.BI "\-x " pattern
-When comparing directories, ignore files and subdirectories whose basenames
-match
-.IR pattern .
-.TP
-.BI "\-X " file
-When comparing directories, ignore files and subdirectories whose basenames
-match any pattern contained in
-.IR file .
-.TP
-.B \-y
-Use the side by side output format.
-.SH SEE ALSO
-cmp(1), comm(1), diff3(1), ed(1), patch(1), pr(1), sdiff(1).
-.SH DIAGNOSTICS
-An exit status of 0 means no differences were found, 1 means some
-differences were found, and 2 means trouble.
diff --git a/gnu/usr.bin/diff/doc/Makefile b/gnu/usr.bin/diff/doc/Makefile
deleted file mode 100644
index 8910545..0000000
--- a/gnu/usr.bin/diff/doc/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Id: Makefile,v 1.4 1997/02/22 15:45:26 peter Exp $
-
-INFO = diff
-
-INFOENTRY_diff= "* DIFF: (diff). DIFF/PATCH Reference Manual."
-
-SRCDIR=${.CURDIR}/../../../../contrib/diff
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/diff3/Makefile b/gnu/usr.bin/diff3/Makefile
deleted file mode 100644
index b98c287..0000000
--- a/gnu/usr.bin/diff3/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $Id: Makefile,v 1.7 1997/02/22 15:45:24 peter Exp $
-
-.PATH: ${.CURDIR}/../../../contrib/diff
-
-PROG= diff3
-SRCS= diff3.c getopt.c getopt1.c version.c
-
-# Important for ctype macros!
-CFLAGS+=-funsigned-char
-
-CFLAGS+=-I${.CURDIR}/../../../contrib/diff
-CFLAGS+=-DHAVE_CONFIG_H
-CFLAGS+=-DDIFF_PROGRAM=\"/usr/bin/diff\"
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/diff3/diff3.1 b/gnu/usr.bin/diff3/diff3.1
deleted file mode 100644
index 9873b08..0000000
--- a/gnu/usr.bin/diff3/diff3.1
+++ /dev/null
@@ -1,210 +0,0 @@
-.TH DIFF3 1 "22sep1993" "GNU Tools" "GNU Tools"
-.SH NAME
-diff3 \- find differences between three files
-.SH SYNOPSIS
-.B diff3
-[options] mine older yours
-.SH DESCRIPTION
-The
-.I diff3
-command compares three files and outputs descriptions
-of their differences.
-
-The files to compare are
-.IR mine ,
-.IR older ,
-and
-.IR yours .
-At most one of these three file names may be
-.BR \- ,
-which tells
-.I diff3
-to read the standard input for that file.
-.SS Options
-Below is a summary of all of the options that GNU
-.I diff3
-accepts. Multiple single letter options (unless they take an argument)
-can be combined into a single command line argument.
-.TP
-.B \-a
-Treat all files as text and compare them line-by-line, even if they
-do not appear to be text.
-.TP
-.B \-A
-Incorporate all changes from
-.I older
-to
-.I yours
-into
-.IR mine ,
-surrounding all conflicts with bracket lines.
-.TP
-.B \-B
-Old behavior of -A. Shows non-conflicts.
-.TP
-.B \-e
-Generate an
-.I ed
-script that incorporates all the changes from
-.I older
-to
-.I yours
-into
-.IR mine .
-.TP
-.B \-E
-Like
-.BR \-e ,
-except bracket lines from overlapping changes' first
-and third files.
-With
-.BR \-e ,
-an overlapping change looks like this:
-.sp
-.nf
-<<<<<<< \fImine\fP
-lines from \fImine\fP
-=======
-lines from \fIyours\fP
->>>>>>> \fIyours\fP
-.fi
-.TP
-.B \-\-ed
-Generate an
-.I ed
-script that incorporates all the changes from
-.I older
-to
-.I yours
-into
-.IR mine .
-.TP
-.B \-\-easy\-only
-Like
-.BR \-e ,
-except output only the nonoverlapping changes.
-.TP
-.B \-i
-Generate
-.B w
-and
-.B q
-commands at the end of the
-.I ed
-script for System V compatibility. This option must be combined with
-one of the
-.B \-AeExX3
-options, and may not be combined with
-.BR \-m .
-.TP
-.B \-\-initial\-tab
-Output a tab rather than two spaces before the text of a line in normal format.
-This causes the alignment of tabs in the line to look normal.
-.TP
-.BI "\-L " label
-.ns
-.TP
-.BI \-\-label= label
-Use the label
-.I label
-for the brackets output by the
-.BR \-A ,
-.B \-E
-and
-.B \-X
-options. This option may be given up to three
-times, one for each input file. The default labels are the names of
-the input files. Thus
-.B "diff3 \-L X \-L Y \-L Z \-m A B C"
-acts like
-.BR "diff3 \-m A B C ,
-except that the output looks like it came from
-files named
-.BR X ,
-.B Y
-and
-.B Z
-rather than from files
-named
-.BR A ,
-.B B
-and
-.BR C .
-.TP
-.B \-m
-.br
-.ns
-.TP
-.B \-\-merge
-Apply the edit script to the first file and send the result to standard
-output. Unlike piping the output from
-.I diff3
-to
-.IR ed ,
-this
-works even for binary files and incomplete lines.
-.B \-A
-is assumed
-if no edit script option is specified.
-.TP
-.B \-\-overlap\-only
-Like
-.BR \-e ,
-except output only the overlapping changes.
-.TP
-.B \-\-show\-all
-Incorporate all unmerged changes from
-.I older
-to
-.I yours
-into
-.IR mine ,
-surrounding all overlapping changes with bracket lines.
-.TP
-.B \-\-show\-overlap
-Like
-.BR \-e ,
-except bracket lines from overlapping changes' first
-and third files.
-.TP
-.B \-T
-Output a tab rather than two spaces before the text of a line in normal format.
-This causes the alignment of tabs in the line to look normal.
-.TP
-.B \-\-text
-Treat all files as text and compare them line-by-line, even if they
-do not appear to be text.
-.TP
-.B \-v
-.br
-.ns
-.TP
-.B \-\-version
-Output the version number of
-.IR diff3 .
-.TP
-.B \-x
-Like
-.BR \-e ,
-except output only the overlapping changes.
-.TP
-.B \-X
-Like
-.BR \-E ,
-except output only the overlapping changes.
-In other words, like
-.BR \-x ,
-except bracket changes as in
-.BR \-E .
-.TP
-.B \-3
-Like
-.BR \-e ,
-except output only the nonoverlapping changes.
-.SH SEE ALSO
-cmp(1), comm(1), diff(1), ed(1), patch(1), sdiff(1).
-.SH DIAGNOSTICS
-An exit status of 0 means
-.I diff3
-was successful, 1 means some
-conflicts were found, and 2 means trouble.
diff --git a/gnu/usr.bin/gdb/Makefile b/gnu/usr.bin/gdb/Makefile
deleted file mode 100644
index 000bb74..0000000
--- a/gnu/usr.bin/gdb/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-SUBDIR= bfd libiberty gdb doc gdbreplay gdbserver
-
-.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/gdb/Makefile.inc b/gnu/usr.bin/gdb/Makefile.inc
deleted file mode 100644
index 2056d9b..0000000
--- a/gnu/usr.bin/gdb/Makefile.inc
+++ /dev/null
@@ -1,14 +0,0 @@
-# bsd.lib.mk causes this file to be loaded multiple times.
-.if !defined(GDB_MAKEFILE_INC_BEEN_HERE)
-GDB_MAKEFILE_INC_BEEN_HERE=yes
-
-# this may be defined in other places
-.if !defined(GDBDIR)
-GDBDIR= ${.CURDIR}/../../../../contrib/gdb
-.endif
-
-CFLAGS+= -I${GDBDIR}/include/. -I${GDBDIR}/gdb/. -I${GDBDIR}/bfd/.
-CFLAGS+= -I${GDBDIR}/libiberty/.
-CFLAGS+= -I${GDBDIR}/gdb/config/.
-CFLAGS+= -DHAVE_CONFIG_H
-.endif
diff --git a/gnu/usr.bin/gdb/bfd/Makefile b/gnu/usr.bin/gdb/bfd/Makefile
deleted file mode 100644
index e474809..0000000
--- a/gnu/usr.bin/gdb/bfd/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-LIB = bfd
-
-GDBDIR= ${.CURDIR}/../../../../contrib/gdb
-.PATH: ${GDBDIR}/bfd
-
-SRCS = libbfd.c opncls.c bfd.c archive.c targets.c cache.c \
- archures.c coff-i386.c aout32.c \
- srec.c \
- ecoff.c ecofflink.c \
- coffgen.c format.c \
- section.c syms.c stab-syms.c reloc.c init.c \
- trad-core.c \
- i386aout.c \
- i386freebsd.c i386bsd.c \
- cpu-i386.c \
- elf.c \
- hash.c linker.c corefile.c binary.c \
- tekhex.c ihex.c
-
-CFLAGS+= -I${.CURDIR}/. -I${.CURDIR}/../gdb/.
-CFLAGS+= -DDEFAULT_VECTOR=i386freebsd_vec \
- -DSELECT_VECS='&i386freebsd_vec,&i386bsd_vec' \
- -DSELECT_ARCHITECTURES='&bfd_i386_arch' -DTRAD_CORE
-
-NOPROFILE=no
-NOPIC=no
-
-install:
- @echo -n
-
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/gdb/bfd/bfd.h b/gnu/usr.bin/gdb/bfd/bfd.h
deleted file mode 100644
index c9b55d4..0000000
--- a/gnu/usr.bin/gdb/bfd/bfd.h
+++ /dev/null
@@ -1,2479 +0,0 @@
-/* Main header file for the bfd library -- portable access to object files.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Contributed by Cygnus Support.
-
-** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them;
-** instead, change bfd-in.h or the other BFD source files processed to
-** generate these files.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* bfd.h -- The only header file required by users of the bfd library
-
-The bfd.h file is generated from bfd-in.h and various .c files; if you
-change it, your changes will probably be lost.
-
-All the prototypes and definitions following the comment "THE FOLLOWING
-IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
-BFD. If you change it, someone oneday will extract it from the source
-again, and your changes will be lost. To save yourself from this bind,
-change the definitions in the source in the bfd directory. Type "make
-docs" and then "make headers" in that directory, and magically this file
-will change to reflect your changes.
-
-If you don't have the tools to perform the extraction, then you are
-safe from someone on your system trampling over your header files.
-You should still maintain the equivalence between the source and this
-file though; every change you make to the .c file should be reflected
-here. */
-
-#ifndef __BFD_H_SEEN__
-#define __BFD_H_SEEN__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "ansidecl.h"
-#include "obstack.h"
-
-/* These two lines get substitutions done by commands in Makefile.in. */
-#define BFD_VERSION "cygnus-2.6"
-#define BFD_ARCH_SIZE 32
-#define BFD_HOST_64BIT_LONG 0
-
-#if BFD_ARCH_SIZE >= 64
-#define BFD64
-#endif
-
-#ifndef INLINE
-#if __GNUC__ >= 2
-#define INLINE __inline__
-#else
-#define INLINE
-#endif
-#endif
-
-/* forward declaration */
-typedef struct _bfd bfd;
-
-/* To squelch erroneous compiler warnings ("illegal pointer
- combination") from the SVR3 compiler, we would like to typedef
- boolean to int (it doesn't like functions which return boolean.
- Making sure they are never implicitly declared to return int
- doesn't seem to help). But this file is not configured based on
- the host. */
-/* General rules: functions which are boolean return true on success
- and false on failure (unless they're a predicate). -- bfd.doc */
-/* I'm sure this is going to break something and someone is going to
- force me to change it. */
-/* typedef enum boolean {false, true} boolean; */
-/* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h> -fnf */
-/* It gets worse if the host also defines a true/false enum... -sts */
-/* And even worse if your compiler has built-in boolean types... -law */
-#if defined (__GNUG__) && (__GNUC_MINOR__ > 5)
-#define TRUE_FALSE_ALREADY_DEFINED
-#endif
-#ifdef MPW
-/* Pre-emptive strike - get the file with the enum. */
-#include <Types.h>
-#define TRUE_FALSE_ALREADY_DEFINED
-#endif /* MPW */
-#ifndef TRUE_FALSE_ALREADY_DEFINED
-typedef enum bfd_boolean {false, true} boolean;
-#define BFD_TRUE_FALSE
-#else
-/* Use enum names that will appear nowhere else. */
-typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
-#endif
-
-/* A pointer to a position in a file. */
-/* FIXME: This should be using off_t from <sys/types.h>.
- For now, try to avoid breaking stuff by not including <sys/types.h> here.
- This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
- Probably the best long-term answer is to avoid using file_ptr AND off_t
- in this header file, and to handle this in the BFD implementation
- rather than in its interface. */
-/* typedef off_t file_ptr; */
-typedef long int file_ptr;
-
-/* Support for different sizes of target format ints and addresses.
- If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
- set to 1 above. Otherwise, if gcc is being used, this code will
- use gcc's "long long" type. Otherwise, the compilation will fail
- if 64-bit targets are requested. */
-
-#ifdef BFD64
-
-#ifndef BFD_HOST_64_BIT
-#if BFD_HOST_64BIT_LONG
-#define BFD_HOST_64_BIT long
-#else
-#ifdef __GNUC__
-#define BFD_HOST_64_BIT long long
-#endif /* defined (__GNUC__) */
-#endif /* ! BFD_HOST_64BIT_LONG */
-#endif /* ! defined (BFD_HOST_64_BIT) */
-
-typedef unsigned BFD_HOST_64_BIT bfd_vma;
-typedef BFD_HOST_64_BIT bfd_signed_vma;
-typedef unsigned BFD_HOST_64_BIT bfd_size_type;
-typedef unsigned BFD_HOST_64_BIT symvalue;
-
-#ifndef fprintf_vma
-#if BFD_HOST_64BIT_LONG
-#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
-#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
-#else
-#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
-#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
-#define fprintf_vma(s,x) \
- fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
-#define sprintf_vma(s,x) \
- sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
-#endif
-#endif
-
-#else /* not BFD64 */
-
-/* Represent a target address. Also used as a generic unsigned type
- which is guaranteed to be big enough to hold any arithmetic types
- we need to deal with. */
-typedef unsigned long bfd_vma;
-
-/* A generic signed type which is guaranteed to be big enough to hold any
- arithmetic types we need to deal with. Can be assumed to be compatible
- with bfd_vma in the same way that signed and unsigned ints are compatible
- (as parameters, in assignment, etc). */
-typedef long bfd_signed_vma;
-
-typedef unsigned long symvalue;
-typedef unsigned long bfd_size_type;
-
-/* Print a bfd_vma x on stream s. */
-#define fprintf_vma(s,x) fprintf(s, "%08lx", x)
-#define sprintf_vma(s,x) sprintf(s, "%08lx", x)
-#endif /* not BFD64 */
-#define printf_vma(x) fprintf_vma(stdout,x)
-
-typedef unsigned int flagword; /* 32 bits of flags */
-typedef unsigned char bfd_byte;
-
-/** File formats */
-
-typedef enum bfd_format {
- bfd_unknown = 0, /* file format is unknown */
- bfd_object, /* linker/assember/compiler output */
- bfd_archive, /* object archive file */
- bfd_core, /* core dump */
- bfd_type_end} /* marks the end; don't use it! */
- bfd_format;
-
-/* Values that may appear in the flags field of a BFD. These also
- appear in the object_flags field of the bfd_target structure, where
- they indicate the set of flags used by that backend (not all flags
- are meaningful for all object file formats) (FIXME: at the moment,
- the object_flags values have mostly just been copied from backend
- to another, and are not necessarily correct). */
-
-/* No flags. */
-#define NO_FLAGS 0x00
-
-/* BFD contains relocation entries. */
-#define HAS_RELOC 0x01
-
-/* BFD is directly executable. */
-#define EXEC_P 0x02
-
-/* BFD has line number information (basically used for F_LNNO in a
- COFF header). */
-#define HAS_LINENO 0x04
-
-/* BFD has debugging information. */
-#define HAS_DEBUG 0x08
-
-/* BFD has symbols. */
-#define HAS_SYMS 0x10
-
-/* BFD has local symbols (basically used for F_LSYMS in a COFF
- header). */
-#define HAS_LOCALS 0x20
-
-/* BFD is a dynamic object. */
-#define DYNAMIC 0x40
-
-/* Text section is write protected (if D_PAGED is not set, this is
- like an a.out NMAGIC file) (the linker sets this by default, but
- clears it for -r or -N). */
-#define WP_TEXT 0x80
-
-/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
- linker sets this by default, but clears it for -r or -n or -N). */
-#define D_PAGED 0x100
-
-/* BFD is relaxable (this means that bfd_relax_section may be able to
- do something) (sometimes bfd_relax_section can do something even if
- this is not set). */
-#define BFD_IS_RELAXABLE 0x200
-
-/* This may be set before writing out a BFD to request using a
- traditional format. For example, this is used to request that when
- writing out an a.out object the symbols not be hashed to eliminate
- duplicates. */
-#define BFD_TRADITIONAL_FORMAT 0x400
-
-/* This flag indicates that the BFD contents are actually cached in
- memory. If this is set, iostream points to a bfd_in_memory struct. */
-#define BFD_IN_MEMORY 0x800
-
-/* symbols and relocation */
-
-/* A count of carsyms (canonical archive symbols). */
-typedef unsigned long symindex;
-
-/* How to perform a relocation. */
-typedef const struct reloc_howto_struct reloc_howto_type;
-
-#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
-
-/* General purpose part of a symbol X;
- target specific parts are in libcoff.h, libaout.h, etc. */
-
-#define bfd_get_section(x) ((x)->section)
-#define bfd_get_output_section(x) ((x)->section->output_section)
-#define bfd_set_section(x,y) ((x)->section) = (y)
-#define bfd_asymbol_base(x) ((x)->section->vma)
-#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
-#define bfd_asymbol_name(x) ((x)->name)
-/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
-#define bfd_asymbol_bfd(x) ((x)->the_bfd)
-#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
-
-/* A canonical archive symbol. */
-/* This is a type pun with struct ranlib on purpose! */
-typedef struct carsym {
- char *name;
- file_ptr file_offset; /* look here to find the file */
-} carsym; /* to make these you call a carsymogen */
-
-
-/* Used in generating armaps (archive tables of contents).
- Perhaps just a forward definition would do? */
-struct orl { /* output ranlib */
- char **name; /* symbol name */
- file_ptr pos; /* bfd* or file position */
- int namidx; /* index into string table */
-};
-
-
-/* Linenumber stuff */
-typedef struct lineno_cache_entry {
- unsigned int line_number; /* Linenumber from start of function*/
- union {
- struct symbol_cache_entry *sym; /* Function name */
- unsigned long offset; /* Offset into section */
- } u;
-} alent;
-
-/* object and core file sections */
-
-#define align_power(addr, align) \
- ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
-
-typedef struct sec *sec_ptr;
-
-#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
-#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
-#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
-#define bfd_section_name(bfd, ptr) ((ptr)->name)
-#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
-#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
-#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
-#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
-#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
-
-#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
-
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
-#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
-#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
-
-typedef struct stat stat_type;
-
-typedef enum bfd_print_symbol
-{
- bfd_print_symbol_name,
- bfd_print_symbol_more,
- bfd_print_symbol_all
-} bfd_print_symbol_type;
-
-/* Information about a symbol that nm needs. */
-
-typedef struct _symbol_info
-{
- symvalue value;
- char type;
- CONST char *name; /* Symbol name. */
- unsigned char stab_type; /* Stab type. */
- char stab_other; /* Stab other. */
- short stab_desc; /* Stab desc. */
- CONST char *stab_name; /* String for stab type. */
-} symbol_info;
-
-/* Get the name of a stabs type code. */
-
-extern const char *bfd_get_stab_name PARAMS ((int));
-
-/* Hash table routines. There is no way to free up a hash table. */
-
-/* An element in the hash table. Most uses will actually use a larger
- structure, and an instance of this will be the first field. */
-
-struct bfd_hash_entry
-{
- /* Next entry for this hash code. */
- struct bfd_hash_entry *next;
- /* String being hashed. */
- const char *string;
- /* Hash code. This is the full hash code, not the index into the
- table. */
- unsigned long hash;
-};
-
-/* A hash table. */
-
-struct bfd_hash_table
-{
- /* The hash array. */
- struct bfd_hash_entry **table;
- /* The number of slots in the hash table. */
- unsigned int size;
- /* A function used to create new elements in the hash table. The
- first entry is itself a pointer to an element. When this
- function is first invoked, this pointer will be NULL. However,
- having the pointer permits a hierarchy of method functions to be
- built each of which calls the function in the superclass. Thus
- each function should be written to allocate a new block of memory
- only if the argument is NULL. */
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
- /* An obstack for this hash table. */
- struct obstack memory;
-};
-
-/* Initialize a hash table. */
-extern boolean bfd_hash_table_init
- PARAMS ((struct bfd_hash_table *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-/* Initialize a hash table specifying a size. */
-extern boolean bfd_hash_table_init_n
- PARAMS ((struct bfd_hash_table *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *),
- unsigned int size));
-
-/* Free up a hash table. */
-extern void bfd_hash_table_free PARAMS ((struct bfd_hash_table *));
-
-/* Look up a string in a hash table. If CREATE is true, a new entry
- will be created for this string if one does not already exist. The
- COPY argument must be true if this routine should copy the string
- into newly allocated memory when adding an entry. */
-extern struct bfd_hash_entry *bfd_hash_lookup
- PARAMS ((struct bfd_hash_table *, const char *, boolean create,
- boolean copy));
-
-/* Replace an entry in a hash table. */
-extern void bfd_hash_replace
- PARAMS ((struct bfd_hash_table *, struct bfd_hash_entry *old,
- struct bfd_hash_entry *nw));
-
-/* Base method for creating a hash table entry. */
-extern struct bfd_hash_entry *bfd_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
- const char *));
-
-/* Grab some space for a hash table entry. */
-extern PTR bfd_hash_allocate PARAMS ((struct bfd_hash_table *,
- unsigned int));
-
-/* Traverse a hash table in a random order, calling a function on each
- element. If the function returns false, the traversal stops. The
- INFO argument is passed to the function. */
-extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *,
- boolean (*) (struct bfd_hash_entry *,
- PTR),
- PTR info));
-
-/* Semi-portable string concatenation in cpp.
- The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors.
- The problem is, "32_" is not a valid preprocessing token, and we don't
- want extra underscores (e.g., "nlm_32_"). The XCAT2 macro will cause the
- inner CAT macros to be evaluated first, producing still-valid pp-tokens.
- Then the final concatenation can be done. (Sigh.) */
-#ifndef CAT
-#ifdef SABER
-#define CAT(a,b) a##b
-#define CAT3(a,b,c) a##b##c
-#define CAT4(a,b,c,d) a##b##c##d
-#else
-#if defined(__STDC__) || defined(ALMOST_STDC)
-#define CAT(a,b) a##b
-#define CAT3(a,b,c) a##b##c
-#define XCAT2(a,b) CAT(a,b)
-#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d))
-#else
-#define CAT(a,b) a/**/b
-#define CAT3(a,b,c) a/**/b/**/c
-#define CAT4(a,b,c,d) a/**/b/**/c/**/d
-#endif
-#endif
-#endif
-
-#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table
-
-/* User program access to BFD facilities */
-
-/* Direct I/O routines, for programs which know more about the object
- file than BFD does. Use higher level routines if possible. */
-
-extern bfd_size_type bfd_read
- PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
-extern bfd_size_type bfd_write
- PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
-extern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction));
-extern long bfd_tell PARAMS ((bfd *abfd));
-extern int bfd_flush PARAMS ((bfd *abfd));
-extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
-
-
-/* Cast from const char * to char * so that caller can assign to
- a char * without a warning. */
-#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
-#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
-#define bfd_get_format(abfd) ((abfd)->format)
-#define bfd_get_target(abfd) ((abfd)->xvec->name)
-#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
-#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
-#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
-#define bfd_header_big_endian(abfd) \
- ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
-#define bfd_header_little_endian(abfd) \
- ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
-#define bfd_get_file_flags(abfd) ((abfd)->flags)
-#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
-#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
-#define bfd_my_archive(abfd) ((abfd)->my_archive)
-#define bfd_has_map(abfd) ((abfd)->has_armap)
-
-#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
-#define bfd_usrdata(abfd) ((abfd)->usrdata)
-
-#define bfd_get_start_address(abfd) ((abfd)->start_address)
-#define bfd_get_symcount(abfd) ((abfd)->symcount)
-#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
-#define bfd_count_sections(abfd) ((abfd)->section_count)
-
-#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
-
-#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean)(bool)), true)
-
-extern boolean bfd_record_phdr
- PARAMS ((bfd *, unsigned long, boolean, flagword, boolean, bfd_vma,
- boolean, boolean, unsigned int, struct sec **));
-
-/* Byte swapping routines. */
-
-bfd_vma bfd_getb64 PARAMS ((const unsigned char *));
-bfd_vma bfd_getl64 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getb_signed_64 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getl_signed_64 PARAMS ((const unsigned char *));
-bfd_vma bfd_getb32 PARAMS ((const unsigned char *));
-bfd_vma bfd_getl32 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getb_signed_32 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getl_signed_32 PARAMS ((const unsigned char *));
-bfd_vma bfd_getb16 PARAMS ((const unsigned char *));
-bfd_vma bfd_getl16 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getb_signed_16 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getl_signed_16 PARAMS ((const unsigned char *));
-void bfd_putb64 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putl64 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putb32 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putl32 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putb16 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putl16 PARAMS ((bfd_vma, unsigned char *));
-
-/* Externally visible ECOFF routines. */
-
-#if defined(__STDC__) || defined(ALMOST_STDC)
-struct ecoff_debug_info;
-struct ecoff_debug_swap;
-struct ecoff_extr;
-struct symbol_cache_entry;
-struct bfd_link_info;
-struct bfd_link_hash_entry;
-#endif
-extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd));
-extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value));
-extern boolean bfd_ecoff_set_regmasks
- PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask,
- unsigned long *cprmask));
-extern PTR bfd_ecoff_debug_init
- PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap,
- struct bfd_link_info *));
-extern void bfd_ecoff_debug_free
- PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap,
- struct bfd_link_info *));
-extern boolean bfd_ecoff_debug_accumulate
- PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap,
- bfd *input_bfd, struct ecoff_debug_info *input_debug,
- const struct ecoff_debug_swap *input_swap,
- struct bfd_link_info *));
-extern boolean bfd_ecoff_debug_accumulate_other
- PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
- struct bfd_link_info *));
-extern boolean bfd_ecoff_debug_externals
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap,
- boolean relocateable,
- boolean (*get_extr) (struct symbol_cache_entry *,
- struct ecoff_extr *),
- void (*set_index) (struct symbol_cache_entry *,
- bfd_size_type)));
-extern boolean bfd_ecoff_debug_one_external
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap,
- const char *name, struct ecoff_extr *esym));
-extern bfd_size_type bfd_ecoff_debug_size
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap));
-extern boolean bfd_ecoff_write_debug
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap, file_ptr where));
-extern boolean bfd_ecoff_write_accumulated_debug
- PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap,
- struct bfd_link_info *info, file_ptr where));
-extern boolean bfd_mips_ecoff_create_embedded_relocs
- PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
- char **));
-
-/* Externally visible ELF routines. */
-
-struct bfd_link_needed_list
-{
- struct bfd_link_needed_list *next;
- bfd *by;
- const char *name;
-};
-
-extern boolean bfd_elf32_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
-extern boolean bfd_elf64_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
-extern struct bfd_link_needed_list *bfd_elf_get_needed_list
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_elf32_size_dynamic_sections
- PARAMS ((bfd *, const char *, const char *, boolean,
- struct bfd_link_info *, struct sec **));
-extern boolean bfd_elf64_size_dynamic_sections
- PARAMS ((bfd *, const char *, const char *, boolean,
- struct bfd_link_info *, struct sec **));
-extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *));
-extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *));
-
-/* SunOS shared library support routines for the linker. */
-
-extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_sunos_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_sunos_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *, struct sec **, struct sec **,
- struct sec **));
-
-/* Linux shared library support routines for the linker. */
-
-extern boolean bfd_i386linux_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_m68klinux_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* mmap hacks */
-
-struct _bfd_window_internal;
-typedef struct _bfd_window_internal bfd_window_internal;
-
-typedef struct _bfd_window {
- /* What the user asked for. */
- PTR data;
- bfd_size_type size;
- /* The actual window used by BFD. Small user-requested read-only
- regions sharing a page may share a single window into the object
- file. Read-write versions shouldn't until I've fixed things to
- keep track of which portions have been claimed by the
- application; don't want to give the same region back when the
- application wants two writable copies! */
- struct _bfd_window_internal *i;
-} bfd_window;
-
-extern void bfd_init_window PARAMS ((bfd_window *));
-extern void bfd_free_window PARAMS ((bfd_window *));
-extern boolean bfd_get_file_window
- PARAMS ((bfd *, file_ptr, bfd_size_type, bfd_window *, boolean));
-
-/* XCOFF support routines for the linker. */
-
-extern boolean bfd_xcoff_link_record_set
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- bfd_size_type));
-extern boolean bfd_xcoff_import_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- bfd_vma, const char *, const char *, const char *));
-extern boolean bfd_xcoff_export_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- boolean));
-extern boolean bfd_xcoff_link_count_reloc
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_xcoff_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_xcoff_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
- unsigned long, unsigned long, unsigned long, boolean,
- int, boolean, boolean, struct sec **));
-
-/* And more from the source. */
-void
-bfd_init PARAMS ((void));
-
-bfd *
-bfd_openr PARAMS ((CONST char *filename, CONST char *target));
-
-bfd *
-bfd_fdopenr PARAMS ((CONST char *filename, CONST char *target, int fd));
-
-bfd *
-bfd_openstreamr PARAMS (());
-
-bfd *
-bfd_openw PARAMS ((CONST char *filename, CONST char *target));
-
-boolean
-bfd_close PARAMS ((bfd *abfd));
-
-boolean
-bfd_close_all_done PARAMS ((bfd *));
-
-bfd_size_type
-bfd_alloc_size PARAMS ((bfd *abfd));
-
-bfd *
-bfd_create PARAMS ((CONST char *filename, bfd *templ));
-
-
- /* Byte swapping macros for user section data. */
-
-#define bfd_put_8(abfd, val, ptr) \
- (*((unsigned char *)(ptr)) = (unsigned char)(val))
-#define bfd_put_signed_8 \
- bfd_put_8
-#define bfd_get_8(abfd, ptr) \
- (*(unsigned char *)(ptr))
-#define bfd_get_signed_8(abfd, ptr) \
- ((*(unsigned char *)(ptr) ^ 0x80) - 0x80)
-
-#define bfd_put_16(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
-#define bfd_put_signed_16 \
- bfd_put_16
-#define bfd_get_16(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx16, (ptr))
-#define bfd_get_signed_16(abfd, ptr) \
- BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
-
-#define bfd_put_32(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
-#define bfd_put_signed_32 \
- bfd_put_32
-#define bfd_get_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx32, (ptr))
-#define bfd_get_signed_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
-
-#define bfd_put_64(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
-#define bfd_put_signed_64 \
- bfd_put_64
-#define bfd_get_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx64, (ptr))
-#define bfd_get_signed_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
-
-
- /* Byte swapping macros for file header data. */
-
-#define bfd_h_put_8(abfd, val, ptr) \
- bfd_put_8 (abfd, val, ptr)
-#define bfd_h_put_signed_8(abfd, val, ptr) \
- bfd_put_8 (abfd, val, ptr)
-#define bfd_h_get_8(abfd, ptr) \
- bfd_get_8 (abfd, ptr)
-#define bfd_h_get_signed_8(abfd, ptr) \
- bfd_get_signed_8 (abfd, ptr)
-
-#define bfd_h_put_16(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
-#define bfd_h_put_signed_16 \
- bfd_h_put_16
-#define bfd_h_get_16(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx16,(ptr))
-#define bfd_h_get_signed_16(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr))
-
-#define bfd_h_put_32(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
-#define bfd_h_put_signed_32 \
- bfd_h_put_32
-#define bfd_h_get_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx32,(ptr))
-#define bfd_h_get_signed_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr))
-
-#define bfd_h_put_64(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
-#define bfd_h_put_signed_64 \
- bfd_h_put_64
-#define bfd_h_get_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx64,(ptr))
-#define bfd_h_get_signed_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
-
-typedef struct sec
-{
- /* The name of the section; the name isn't a copy, the pointer is
- the same as that passed to bfd_make_section. */
-
- CONST char *name;
-
- /* Which section is it; 0..nth. */
-
- int index;
-
- /* The next section in the list belonging to the BFD, or NULL. */
-
- struct sec *next;
-
- /* The field flags contains attributes of the section. Some
- flags are read in from the object file, and some are
- synthesized from other information. */
-
- flagword flags;
-
-#define SEC_NO_FLAGS 0x000
-
- /* Tells the OS to allocate space for this section when loading.
- This is clear for a section containing debug information
- only. */
-#define SEC_ALLOC 0x001
-
- /* Tells the OS to load the section from the file when loading.
- This is clear for a .bss section. */
-#define SEC_LOAD 0x002
-
- /* The section contains data still to be relocated, so there is
- some relocation information too. */
-#define SEC_RELOC 0x004
-
-#if 0 /* Obsolete ? */
-#define SEC_BALIGN 0x008
-#endif
-
- /* A signal to the OS that the section contains read only
- data. */
-#define SEC_READONLY 0x010
-
- /* The section contains code only. */
-#define SEC_CODE 0x020
-
- /* The section contains data only. */
-#define SEC_DATA 0x040
-
- /* The section will reside in ROM. */
-#define SEC_ROM 0x080
-
- /* The section contains constructor information. This section
- type is used by the linker to create lists of constructors and
- destructors used by <<g++>>. When a back end sees a symbol
- which should be used in a constructor list, it creates a new
- section for the type of name (e.g., <<__CTOR_LIST__>>), attaches
- the symbol to it, and builds a relocation. To build the lists
- of constructors, all the linker has to do is catenate all the
- sections called <<__CTOR_LIST__>> and relocate the data
- contained within - exactly the operations it would peform on
- standard data. */
-#define SEC_CONSTRUCTOR 0x100
-
- /* The section is a constuctor, and should be placed at the
- end of the text, data, or bss section(?). */
-#define SEC_CONSTRUCTOR_TEXT 0x1100
-#define SEC_CONSTRUCTOR_DATA 0x2100
-#define SEC_CONSTRUCTOR_BSS 0x3100
-
- /* The section has contents - a data section could be
- <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
- <<SEC_HAS_CONTENTS>> */
-#define SEC_HAS_CONTENTS 0x200
-
- /* An instruction to the linker to not output the section
- even if it has information which would normally be written. */
-#define SEC_NEVER_LOAD 0x400
-
- /* The section is a COFF shared library section. This flag is
- only for the linker. If this type of section appears in
- the input file, the linker must copy it to the output file
- without changing the vma or size. FIXME: Although this
- was originally intended to be general, it really is COFF
- specific (and the flag was renamed to indicate this). It
- might be cleaner to have some more general mechanism to
- allow the back end to control what the linker does with
- sections. */
-#define SEC_COFF_SHARED_LIBRARY 0x800
-
- /* The section is a common section (symbols may be defined
- multiple times, the value of a symbol is the amount of
- space it requires, and the largest symbol value is the one
- used). Most targets have exactly one of these (which we
- translate to bfd_com_section_ptr), but ECOFF has two. */
-#define SEC_IS_COMMON 0x8000
-
- /* The section contains only debugging information. For
- example, this is set for ELF .debug and .stab sections.
- strip tests this flag to see if a section can be
- discarded. */
-#define SEC_DEBUGGING 0x10000
-
- /* The contents of this section are held in memory pointed to
- by the contents field. This is checked by
- bfd_get_section_contents, and the data is retrieved from
- memory if appropriate. */
-#define SEC_IN_MEMORY 0x20000
-
- /* The contents of this section are to be excluded by the
- linker for executable and shared objects unless those
- objects are to be further relocated. */
-#define SEC_EXCLUDE 0x40000
-
- /* The contents of this section are to be sorted by the
- based on the address specified in the associated symbol
- table. */
-#define SEC_SORT_ENTRIES 0x80000
-
- /* End of section flags. */
-
- /* The virtual memory address of the section - where it will be
- at run time. The symbols are relocated against this. The
- user_set_vma flag is maintained by bfd; if it's not set, the
- backend can assign addresses (for example, in <<a.out>>, where
- the default address for <<.data>> is dependent on the specific
- target and various flags). */
-
- bfd_vma vma;
- boolean user_set_vma;
-
- /* The load address of the section - where it would be in a
- rom image; really only used for writing section header
- information. */
-
- bfd_vma lma;
-
- /* The size of the section in bytes, as it will be output.
- contains a value even if the section has no contents (e.g., the
- size of <<.bss>>). This will be filled in after relocation */
-
- bfd_size_type _cooked_size;
-
- /* The original size on disk of the section, in bytes. Normally this
- value is the same as the size, but if some relaxing has
- been done, then this value will be bigger. */
-
- bfd_size_type _raw_size;
-
- /* If this section is going to be output, then this value is the
- offset into the output section of the first byte in the input
- section. E.g., if this was going to start at the 100th byte in
- the output section, this value would be 100. */
-
- bfd_vma output_offset;
-
- /* The output section through which to map on output. */
-
- struct sec *output_section;
-
- /* The alignment requirement of the section, as an exponent of 2 -
- e.g., 3 aligns to 2^3 (or 8). */
-
- unsigned int alignment_power;
-
- /* If an input section, a pointer to a vector of relocation
- records for the data in this section. */
-
- struct reloc_cache_entry *relocation;
-
- /* If an output section, a pointer to a vector of pointers to
- relocation records for the data in this section. */
-
- struct reloc_cache_entry **orelocation;
-
- /* The number of relocation records in one of the above */
-
- unsigned reloc_count;
-
- /* Information below is back end specific - and not always used
- or updated. */
-
- /* File position of section data */
-
- file_ptr filepos;
-
- /* File position of relocation info */
-
- file_ptr rel_filepos;
-
- /* File position of line data */
-
- file_ptr line_filepos;
-
- /* Pointer to data for applications */
-
- PTR userdata;
-
- /* If the SEC_IN_MEMORY flag is set, this points to the actual
- contents. */
- unsigned char *contents;
-
- /* Attached line number information */
-
- alent *lineno;
-
- /* Number of line number records */
-
- unsigned int lineno_count;
-
- /* When a section is being output, this value changes as more
- linenumbers are written out */
-
- file_ptr moving_line_filepos;
-
- /* What the section number is in the target world */
-
- int target_index;
-
- PTR used_by_bfd;
-
- /* If this is a constructor section then here is a list of the
- relocations created to relocate items within it. */
-
- struct relent_chain *constructor_chain;
-
- /* The BFD which owns the section. */
-
- bfd *owner;
-
- boolean reloc_done;
- /* A symbol which points at this section only */
- struct symbol_cache_entry *symbol;
- struct symbol_cache_entry **symbol_ptr_ptr;
-
- struct bfd_link_order *link_order_head;
- struct bfd_link_order *link_order_tail;
-} asection ;
-
- /* These sections are global, and are managed by BFD. The application
- and target back end are not permitted to change the values in
- these sections. New code should use the section_ptr macros rather
- than referring directly to the const sections. The const sections
- may eventually vanish. */
-#define BFD_ABS_SECTION_NAME "*ABS*"
-#define BFD_UND_SECTION_NAME "*UND*"
-#define BFD_COM_SECTION_NAME "*COM*"
-#define BFD_IND_SECTION_NAME "*IND*"
-
- /* the absolute section */
-extern const asection bfd_abs_section;
-#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
-#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
- /* Pointer to the undefined section */
-extern const asection bfd_und_section;
-#define bfd_und_section_ptr ((asection *) &bfd_und_section)
-#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
- /* Pointer to the common section */
-extern const asection bfd_com_section;
-#define bfd_com_section_ptr ((asection *) &bfd_com_section)
- /* Pointer to the indirect section */
-extern const asection bfd_ind_section;
-#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
-#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
-
-extern const struct symbol_cache_entry * const bfd_abs_symbol;
-extern const struct symbol_cache_entry * const bfd_com_symbol;
-extern const struct symbol_cache_entry * const bfd_und_symbol;
-extern const struct symbol_cache_entry * const bfd_ind_symbol;
-#define bfd_get_section_size_before_reloc(section) \
- (section->reloc_done ? (abort(),1): (section)->_raw_size)
-#define bfd_get_section_size_after_reloc(section) \
- ((section->reloc_done) ? (section)->_cooked_size: (abort(),1))
-asection *
-bfd_get_section_by_name PARAMS ((bfd *abfd, CONST char *name));
-
-asection *
-bfd_make_section_old_way PARAMS ((bfd *abfd, CONST char *name));
-
-asection *
-bfd_make_section_anyway PARAMS ((bfd *abfd, CONST char *name));
-
-asection *
-bfd_make_section PARAMS ((bfd *, CONST char *name));
-
-boolean
-bfd_set_section_flags PARAMS ((bfd *abfd, asection *sec, flagword flags));
-
-void
-bfd_map_over_sections PARAMS ((bfd *abfd,
- void (*func)(bfd *abfd,
- asection *sect,
- PTR obj),
- PTR obj));
-
-boolean
-bfd_set_section_size PARAMS ((bfd *abfd, asection *sec, bfd_size_type val));
-
-boolean
-bfd_set_section_contents
- PARAMS ((bfd *abfd,
- asection *section,
- PTR data,
- file_ptr offset,
- bfd_size_type count));
-
-boolean
-bfd_get_section_contents
- PARAMS ((bfd *abfd, asection *section, PTR location,
- file_ptr offset, bfd_size_type count));
-
-boolean
-bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec, bfd *obfd, asection *osec));
-
-#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
- BFD_SEND (ibfd, _bfd_copy_private_section_data, \
- (ibfd, isection, obfd, osection))
-enum bfd_architecture
-{
- bfd_arch_unknown, /* File arch not known */
- bfd_arch_obscure, /* Arch known, not one of these */
- bfd_arch_m68k, /* Motorola 68xxx */
- bfd_arch_vax, /* DEC Vax */
- bfd_arch_i960, /* Intel 960 */
- /* The order of the following is important.
- lower number indicates a machine type that
- only accepts a subset of the instructions
- available to machines with higher numbers.
- The exception is the "ca", which is
- incompatible with all other machines except
- "core". */
-
-#define bfd_mach_i960_core 1
-#define bfd_mach_i960_ka_sa 2
-#define bfd_mach_i960_kb_sb 3
-#define bfd_mach_i960_mc 4
-#define bfd_mach_i960_xa 5
-#define bfd_mach_i960_ca 6
-#define bfd_mach_i960_jx 7
-#define bfd_mach_i960_hx 8
-
- bfd_arch_a29k, /* AMD 29000 */
- bfd_arch_sparc, /* SPARC */
-#define bfd_mach_sparc 1
- /* The difference between v8plus and v9 is that v9 is a true 64 bit env. */
-#define bfd_mach_sparc_v8plus 2
-#define bfd_mach_sparc_v8plusa 3 /* with ultrasparc add'ns */
-#define bfd_mach_sparc_v9 4
-#define bfd_mach_sparc_v9a 5 /* with ultrasparc add'ns */
- /* Nonzero if MACH has the v9 instruction set. */
-#define bfd_mach_sparc_v9_p(mach) ((mach) != bfd_mach_sparc)
- bfd_arch_mips, /* MIPS Rxxxx */
- bfd_arch_i386, /* Intel 386 */
- bfd_arch_we32k, /* AT&T WE32xxx */
- bfd_arch_tahoe, /* CCI/Harris Tahoe */
- bfd_arch_i860, /* Intel 860 */
- bfd_arch_romp, /* IBM ROMP PC/RT */
- bfd_arch_alliant, /* Alliant */
- bfd_arch_convex, /* Convex */
- bfd_arch_m88k, /* Motorola 88xxx */
- bfd_arch_pyramid, /* Pyramid Technology */
- bfd_arch_h8300, /* Hitachi H8/300 */
-#define bfd_mach_h8300 1
-#define bfd_mach_h8300h 2
- bfd_arch_powerpc, /* PowerPC */
- bfd_arch_rs6000, /* IBM RS/6000 */
- bfd_arch_hppa, /* HP PA RISC */
- bfd_arch_z8k, /* Zilog Z8000 */
-#define bfd_mach_z8001 1
-#define bfd_mach_z8002 2
- bfd_arch_h8500, /* Hitachi H8/500 */
- bfd_arch_sh, /* Hitachi SH */
- bfd_arch_alpha, /* Dec Alpha */
- bfd_arch_arm, /* Advanced Risc Machines ARM */
- bfd_arch_ns32k, /* National Semiconductors ns32000 */
- bfd_arch_w65, /* WDC 65816 */
- bfd_arch_last
- };
-
-typedef struct bfd_arch_info
-{
- int bits_per_word;
- int bits_per_address;
- int bits_per_byte;
- enum bfd_architecture arch;
- unsigned long mach;
- const char *arch_name;
- const char *printable_name;
- unsigned int section_align_power;
- /* true if this is the default machine for the architecture */
- boolean the_default;
- const struct bfd_arch_info * (*compatible)
- PARAMS ((const struct bfd_arch_info *a,
- const struct bfd_arch_info *b));
-
- boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *));
-
- const struct bfd_arch_info *next;
-} bfd_arch_info_type;
-const char *
-bfd_printable_name PARAMS ((bfd *abfd));
-
-const bfd_arch_info_type *
-bfd_scan_arch PARAMS ((const char *string));
-
-const bfd_arch_info_type *
-bfd_arch_get_compatible PARAMS ((
- const bfd *abfd,
- const bfd *bbfd));
-
-void
-bfd_set_arch_info PARAMS ((bfd *abfd, const bfd_arch_info_type *arg));
-
-enum bfd_architecture
-bfd_get_arch PARAMS ((bfd *abfd));
-
-unsigned long
-bfd_get_mach PARAMS ((bfd *abfd));
-
-unsigned int
-bfd_arch_bits_per_byte PARAMS ((bfd *abfd));
-
-unsigned int
-bfd_arch_bits_per_address PARAMS ((bfd *abfd));
-
-const bfd_arch_info_type *
-bfd_get_arch_info PARAMS ((bfd *abfd));
-
-const bfd_arch_info_type *
-bfd_lookup_arch
- PARAMS ((enum bfd_architecture
- arch,
- unsigned long machine));
-
-const char *
-bfd_printable_arch_mach
- PARAMS ((enum bfd_architecture arch, unsigned long machine));
-
-typedef enum bfd_reloc_status
-{
- /* No errors detected */
- bfd_reloc_ok,
-
- /* The relocation was performed, but there was an overflow. */
- bfd_reloc_overflow,
-
- /* The address to relocate was not within the section supplied. */
- bfd_reloc_outofrange,
-
- /* Used by special functions */
- bfd_reloc_continue,
-
- /* Unsupported relocation size requested. */
- bfd_reloc_notsupported,
-
- /* Unused */
- bfd_reloc_other,
-
- /* The symbol to relocate against was undefined. */
- bfd_reloc_undefined,
-
- /* The relocation was performed, but may not be ok - presently
- generated only when linking i960 coff files with i960 b.out
- symbols. If this type is returned, the error_message argument
- to bfd_perform_relocation will be set. */
- bfd_reloc_dangerous
- }
- bfd_reloc_status_type;
-
-
-typedef struct reloc_cache_entry
-{
- /* A pointer into the canonical table of pointers */
- struct symbol_cache_entry **sym_ptr_ptr;
-
- /* offset in section */
- bfd_size_type address;
-
- /* addend for relocation value */
- bfd_vma addend;
-
- /* Pointer to how to perform the required relocation */
- reloc_howto_type *howto;
-
-} arelent;
-enum complain_overflow
-{
- /* Do not complain on overflow. */
- complain_overflow_dont,
-
- /* Complain if the bitfield overflows, whether it is considered
- as signed or unsigned. */
- complain_overflow_bitfield,
-
- /* Complain if the value overflows when considered as signed
- number. */
- complain_overflow_signed,
-
- /* Complain if the value overflows when considered as an
- unsigned number. */
- complain_overflow_unsigned
-};
-
-struct reloc_howto_struct
-{
- /* The type field has mainly a documetary use - the back end can
- do what it wants with it, though normally the back end's
- external idea of what a reloc number is stored
- in this field. For example, a PC relative word relocation
- in a coff environment has the type 023 - because that's
- what the outside world calls a R_PCRWORD reloc. */
- unsigned int type;
-
- /* The value the final relocation is shifted right by. This drops
- unwanted data from the relocation. */
- unsigned int rightshift;
-
- /* The size of the item to be relocated. This is *not* a
- power-of-two measure. To get the number of bytes operated
- on by a type of relocation, use bfd_get_reloc_size. */
- int size;
-
- /* The number of bits in the item to be relocated. This is used
- when doing overflow checking. */
- unsigned int bitsize;
-
- /* Notes that the relocation is relative to the location in the
- data section of the addend. The relocation function will
- subtract from the relocation value the address of the location
- being relocated. */
- boolean pc_relative;
-
- /* The bit position of the reloc value in the destination.
- The relocated value is left shifted by this amount. */
- unsigned int bitpos;
-
- /* What type of overflow error should be checked for when
- relocating. */
- enum complain_overflow complain_on_overflow;
-
- /* If this field is non null, then the supplied function is
- called rather than the normal function. This allows really
- strange relocation methods to be accomodated (e.g., i960 callj
- instructions). */
- bfd_reloc_status_type (*special_function)
- PARAMS ((bfd *abfd,
- arelent *reloc_entry,
- struct symbol_cache_entry *symbol,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message));
-
- /* The textual name of the relocation type. */
- char *name;
-
- /* When performing a partial link, some formats must modify the
- relocations rather than the data - this flag signals this.*/
- boolean partial_inplace;
-
- /* The src_mask selects which parts of the read in data
- are to be used in the relocation sum. E.g., if this was an 8 bit
- bit of data which we read and relocated, this would be
- 0x000000ff. When we have relocs which have an addend, such as
- sun4 extended relocs, the value in the offset part of a
- relocating field is garbage so we never use it. In this case
- the mask would be 0x00000000. */
- bfd_vma src_mask;
-
- /* The dst_mask selects which parts of the instruction are replaced
- into the instruction. In most cases src_mask == dst_mask,
- except in the above special case, where dst_mask would be
- 0x000000ff, and src_mask would be 0x00000000. */
- bfd_vma dst_mask;
-
- /* When some formats create PC relative instructions, they leave
- the value of the pc of the place being relocated in the offset
- slot of the instruction, so that a PC relative relocation can
- be made just by adding in an ordinary offset (e.g., sun3 a.out).
- Some formats leave the displacement part of an instruction
- empty (e.g., m88k bcs); this flag signals the fact.*/
- boolean pcrel_offset;
-
-};
-#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
- {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
-#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
-
-#define HOWTO_PREPARE(relocation, symbol) \
- { \
- if (symbol != (asymbol *)NULL) { \
- if (bfd_is_com_section (symbol->section)) { \
- relocation = 0; \
- } \
- else { \
- relocation = symbol->value; \
- } \
- } \
-}
-int
-bfd_get_reloc_size PARAMS ((reloc_howto_type *));
-
-typedef struct relent_chain {
- arelent relent;
- struct relent_chain *next;
-} arelent_chain;
-bfd_reloc_status_type
-
-bfd_perform_relocation
- PARAMS ((bfd *abfd,
- arelent *reloc_entry,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message));
-
-bfd_reloc_status_type
-
-bfd_install_relocation
- PARAMS ((bfd *abfd,
- arelent *reloc_entry,
- PTR data, bfd_vma data_start,
- asection *input_section,
- char **error_message));
-
-enum bfd_reloc_code_real {
- _dummy_first_bfd_reloc_code_real,
-
-
-/* Basic absolute relocations of N bits. */
- BFD_RELOC_64,
- BFD_RELOC_32,
- BFD_RELOC_26,
- BFD_RELOC_16,
- BFD_RELOC_14,
- BFD_RELOC_8,
-
-/* PC-relative relocations. Sometimes these are relative to the address
-of the relocation itself; sometimes they are relative to the start of
-the section containing the relocation. It depends on the specific target.
-
-The 24-bit relocation is used in some Intel 960 configurations. */
- BFD_RELOC_64_PCREL,
- BFD_RELOC_32_PCREL,
- BFD_RELOC_24_PCREL,
- BFD_RELOC_16_PCREL,
- BFD_RELOC_12_PCREL,
- BFD_RELOC_8_PCREL,
-
-/* For ELF. */
- BFD_RELOC_32_GOT_PCREL,
- BFD_RELOC_16_GOT_PCREL,
- BFD_RELOC_8_GOT_PCREL,
- BFD_RELOC_32_GOTOFF,
- BFD_RELOC_16_GOTOFF,
- BFD_RELOC_LO16_GOTOFF,
- BFD_RELOC_HI16_GOTOFF,
- BFD_RELOC_HI16_S_GOTOFF,
- BFD_RELOC_8_GOTOFF,
- BFD_RELOC_32_PLT_PCREL,
- BFD_RELOC_24_PLT_PCREL,
- BFD_RELOC_16_PLT_PCREL,
- BFD_RELOC_8_PLT_PCREL,
- BFD_RELOC_32_PLTOFF,
- BFD_RELOC_16_PLTOFF,
- BFD_RELOC_LO16_PLTOFF,
- BFD_RELOC_HI16_PLTOFF,
- BFD_RELOC_HI16_S_PLTOFF,
- BFD_RELOC_8_PLTOFF,
-
-/* Relocations used by 68K ELF. */
- BFD_RELOC_68K_GLOB_DAT,
- BFD_RELOC_68K_JMP_SLOT,
- BFD_RELOC_68K_RELATIVE,
-
-/* Linkage-table relative. */
- BFD_RELOC_32_BASEREL,
- BFD_RELOC_16_BASEREL,
- BFD_RELOC_LO16_BASEREL,
- BFD_RELOC_HI16_BASEREL,
- BFD_RELOC_HI16_S_BASEREL,
- BFD_RELOC_8_BASEREL,
- BFD_RELOC_RVA,
-
-/* Absolute 8-bit relocation, but used to form an address like 0xFFnn. */
- BFD_RELOC_8_FFnn,
-
-/* These PC-relative relocations are stored as word displacements --
-i.e., byte displacements shifted right two bits. The 30-bit word
-displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
-SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The
-signed 16-bit displacement is used on the MIPS, and the 23-bit
-displacement is used on the Alpha. */
- BFD_RELOC_32_PCREL_S2,
- BFD_RELOC_16_PCREL_S2,
- BFD_RELOC_23_PCREL_S2,
-
-/* High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
-the target word. These are used on the SPARC. */
- BFD_RELOC_HI22,
- BFD_RELOC_LO10,
-
-/* For systems that allocate a Global Pointer register, these are
-displacements off that register. These relocation types are
-handled specially, because the value the register will have is
-decided relatively late. */
- BFD_RELOC_GPREL16,
- BFD_RELOC_GPREL32,
-
-/* Reloc types used for i960/b.out. */
- BFD_RELOC_I960_CALLJ,
-
-/* SPARC ELF relocations. There is probably some overlap with other
-relocation types already defined. */
- BFD_RELOC_NONE,
- BFD_RELOC_SPARC_WDISP22,
- BFD_RELOC_SPARC22,
- BFD_RELOC_SPARC13,
- BFD_RELOC_SPARC_GOT10,
- BFD_RELOC_SPARC_GOT13,
- BFD_RELOC_SPARC_GOT22,
- BFD_RELOC_SPARC_PC10,
- BFD_RELOC_SPARC_PC22,
- BFD_RELOC_SPARC_WPLT30,
- BFD_RELOC_SPARC_COPY,
- BFD_RELOC_SPARC_GLOB_DAT,
- BFD_RELOC_SPARC_JMP_SLOT,
- BFD_RELOC_SPARC_RELATIVE,
- BFD_RELOC_SPARC_UA32,
-
-/* I think these are specific to SPARC a.out (e.g., Sun 4). */
- BFD_RELOC_SPARC_BASE13,
- BFD_RELOC_SPARC_BASE22,
-
-/* Some relocations we're using for SPARC V9 -- subject to change. */
-#define BFD_RELOC_SPARC_64 BFD_RELOC_64
- BFD_RELOC_SPARC_10,
- BFD_RELOC_SPARC_11,
- BFD_RELOC_SPARC_OLO10,
- BFD_RELOC_SPARC_HH22,
- BFD_RELOC_SPARC_HM10,
- BFD_RELOC_SPARC_LM22,
- BFD_RELOC_SPARC_PC_HH22,
- BFD_RELOC_SPARC_PC_HM10,
- BFD_RELOC_SPARC_PC_LM22,
- BFD_RELOC_SPARC_WDISP16,
- BFD_RELOC_SPARC_WDISP19,
- BFD_RELOC_SPARC_GLOB_JMP,
- BFD_RELOC_SPARC_7,
- BFD_RELOC_SPARC_6,
- BFD_RELOC_SPARC_5,
-
-/* Alpha ECOFF relocations. Some of these treat the symbol or "addend"
-in some special way.
-For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
-writing; when reading, it will be the absolute section symbol. The
-addend is the displacement in bytes of the "lda" instruction from
-the "ldah" instruction (which is at the address of this reloc). */
- BFD_RELOC_ALPHA_GPDISP_HI16,
-
-/* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
-with GPDISP_HI16 relocs. The addend is ignored when writing the
-relocations out, and is filled in with the file's GP value on
-reading, for convenience. */
- BFD_RELOC_ALPHA_GPDISP_LO16,
-
-/* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
-the assembler turns it into a LDQ instruction to load the address of
-the symbol, and then fills in a register in the real instruction.
-
-The LITERAL reloc, at the LDQ instruction, refers to the .lita
-section symbol. The addend is ignored when writing, but is filled
-in with the file's GP value on reading, for convenience, as with the
-GPDISP_LO16 reloc.
-
-The LITUSE reloc, on the instruction using the loaded address, gives
-information to the linker that it might be able to use to optimize
-away some literal section references. The symbol is ignored (read
-as the absolute section symbol), and the "addend" indicates the type
-of instruction using the register:
-1 - "memory" fmt insn
-2 - byte-manipulation (byte offset reg)
-3 - jsr (target of branch)
-
-The GNU linker currently doesn't do any of this optimizing. */
- BFD_RELOC_ALPHA_LITERAL,
- BFD_RELOC_ALPHA_LITUSE,
-
-/* The HINT relocation indicates a value that should be filled into the
-"hint" field of a jmp/jsr/ret instruction, for possible branch-
-prediction logic which may be provided on some processors. */
- BFD_RELOC_ALPHA_HINT,
-
-/* Bits 27..2 of the relocation address shifted right 2 bits;
-simple reloc otherwise. */
- BFD_RELOC_MIPS_JMP,
-
-/* High 16 bits of 32-bit value; simple reloc. */
- BFD_RELOC_HI16,
-
-/* High 16 bits of 32-bit value but the low 16 bits will be sign
-extended and added to form the final result. If the low 16
-bits form a negative number, we need to add one to the high value
-to compensate for the borrow when the low bits are added. */
- BFD_RELOC_HI16_S,
-
-/* Low 16 bits. */
- BFD_RELOC_LO16,
-
-/* Like BFD_RELOC_HI16_S, but PC relative. */
- BFD_RELOC_PCREL_HI16_S,
-
-/* Like BFD_RELOC_LO16, but PC relative. */
- BFD_RELOC_PCREL_LO16,
-
-/* Relocation relative to the global pointer. */
-#define BFD_RELOC_MIPS_GPREL BFD_RELOC_GPREL16
-
-/* Relocation against a MIPS literal section. */
- BFD_RELOC_MIPS_LITERAL,
-
-/* MIPS ELF relocations. */
- BFD_RELOC_MIPS_GOT16,
- BFD_RELOC_MIPS_CALL16,
-#define BFD_RELOC_MIPS_GPREL32 BFD_RELOC_GPREL32
- BFD_RELOC_MIPS_GOT_HI16,
- BFD_RELOC_MIPS_GOT_LO16,
- BFD_RELOC_MIPS_CALL_HI16,
- BFD_RELOC_MIPS_CALL_LO16,
-
-/* i386/elf relocations */
- BFD_RELOC_386_GOT32,
- BFD_RELOC_386_PLT32,
- BFD_RELOC_386_COPY,
- BFD_RELOC_386_GLOB_DAT,
- BFD_RELOC_386_JUMP_SLOT,
- BFD_RELOC_386_RELATIVE,
- BFD_RELOC_386_GOTOFF,
- BFD_RELOC_386_GOTPC,
-
-/* ns32k relocations */
- BFD_RELOC_NS32K_IMM_8,
- BFD_RELOC_NS32K_IMM_16,
- BFD_RELOC_NS32K_IMM_32,
- BFD_RELOC_NS32K_IMM_8_PCREL,
- BFD_RELOC_NS32K_IMM_16_PCREL,
- BFD_RELOC_NS32K_IMM_32_PCREL,
- BFD_RELOC_NS32K_DISP_8,
- BFD_RELOC_NS32K_DISP_16,
- BFD_RELOC_NS32K_DISP_32,
- BFD_RELOC_NS32K_DISP_8_PCREL,
- BFD_RELOC_NS32K_DISP_16_PCREL,
- BFD_RELOC_NS32K_DISP_32_PCREL,
-
-/* Power(rs6000) and PowerPC relocations. */
- BFD_RELOC_PPC_B26,
- BFD_RELOC_PPC_BA26,
- BFD_RELOC_PPC_TOC16,
- BFD_RELOC_PPC_B16,
- BFD_RELOC_PPC_B16_BRTAKEN,
- BFD_RELOC_PPC_B16_BRNTAKEN,
- BFD_RELOC_PPC_BA16,
- BFD_RELOC_PPC_BA16_BRTAKEN,
- BFD_RELOC_PPC_BA16_BRNTAKEN,
- BFD_RELOC_PPC_COPY,
- BFD_RELOC_PPC_GLOB_DAT,
- BFD_RELOC_PPC_JMP_SLOT,
- BFD_RELOC_PPC_RELATIVE,
- BFD_RELOC_PPC_LOCAL24PC,
- BFD_RELOC_PPC_EMB_NADDR32,
- BFD_RELOC_PPC_EMB_NADDR16,
- BFD_RELOC_PPC_EMB_NADDR16_LO,
- BFD_RELOC_PPC_EMB_NADDR16_HI,
- BFD_RELOC_PPC_EMB_NADDR16_HA,
- BFD_RELOC_PPC_EMB_SDAI16,
- BFD_RELOC_PPC_EMB_SDA2I16,
- BFD_RELOC_PPC_EMB_SDA2REL,
- BFD_RELOC_PPC_EMB_SDA21,
- BFD_RELOC_PPC_EMB_MRKREF,
- BFD_RELOC_PPC_EMB_RELSEC16,
- BFD_RELOC_PPC_EMB_RELST_LO,
- BFD_RELOC_PPC_EMB_RELST_HI,
- BFD_RELOC_PPC_EMB_RELST_HA,
- BFD_RELOC_PPC_EMB_BIT_FLD,
- BFD_RELOC_PPC_EMB_RELSDA,
-
-/* The type of reloc used to build a contructor table - at the moment
-probably a 32 bit wide absolute relocation, but the target can choose.
-It generally does map to one of the other relocation types. */
- BFD_RELOC_CTOR,
-
-/* ARM 26 bit pc-relative branch. The lowest two bits must be zero and are
-not stored in the instruction. */
- BFD_RELOC_ARM_PCREL_BRANCH,
-
-/* These relocs are only used within the ARM assembler. They are not
-(at present) written to any object files. */
- BFD_RELOC_ARM_IMMEDIATE,
- BFD_RELOC_ARM_OFFSET_IMM,
- BFD_RELOC_ARM_SHIFT_IMM,
- BFD_RELOC_ARM_SWI,
- BFD_RELOC_ARM_MULTI,
- BFD_RELOC_ARM_CP_OFF_IMM,
- BFD_RELOC_ARM_ADR_IMM,
- BFD_RELOC_ARM_LDR_IMM,
- BFD_RELOC_ARM_LITERAL,
- BFD_RELOC_ARM_IN_POOL,
- BFD_RELOC_UNUSED };
-typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
-reloc_howto_type *
-
-bfd_reloc_type_lookup PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-
-const char *
-bfd_get_reloc_code_name PARAMS ((bfd_reloc_code_real_type code));
-
-
-typedef struct symbol_cache_entry
-{
- /* A pointer to the BFD which owns the symbol. This information
- is necessary so that a back end can work out what additional
- information (invisible to the application writer) is carried
- with the symbol.
-
- This field is *almost* redundant, since you can use section->owner
- instead, except that some symbols point to the global sections
- bfd_{abs,com,und}_section. This could be fixed by making
- these globals be per-bfd (or per-target-flavor). FIXME. */
-
- struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */
-
- /* The text of the symbol. The name is left alone, and not copied; the
- application may not alter it. */
- CONST char *name;
-
- /* The value of the symbol. This really should be a union of a
- numeric value with a pointer, since some flags indicate that
- a pointer to another symbol is stored here. */
- symvalue value;
-
- /* Attributes of a symbol: */
-
-#define BSF_NO_FLAGS 0x00
-
- /* The symbol has local scope; <<static>> in <<C>>. The value
- is the offset into the section of the data. */
-#define BSF_LOCAL 0x01
-
- /* The symbol has global scope; initialized data in <<C>>. The
- value is the offset into the section of the data. */
-#define BSF_GLOBAL 0x02
-
- /* The symbol has global scope and is exported. The value is
- the offset into the section of the data. */
-#define BSF_EXPORT BSF_GLOBAL /* no real difference */
-
- /* A normal C symbol would be one of:
- <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or
- <<BSF_GLOBAL>> */
-
- /* The symbol is a debugging record. The value has an arbitary
- meaning. */
-#define BSF_DEBUGGING 0x08
-
- /* The symbol denotes a function entry point. Used in ELF,
- perhaps others someday. */
-#define BSF_FUNCTION 0x10
-
- /* Used by the linker. */
-#define BSF_KEEP 0x20
-#define BSF_KEEP_G 0x40
-
- /* A weak global symbol, overridable without warnings by
- a regular global symbol of the same name. */
-#define BSF_WEAK 0x80
-
- /* This symbol was created to point to a section, e.g. ELF's
- STT_SECTION symbols. */
-#define BSF_SECTION_SYM 0x100
-
- /* The symbol used to be a common symbol, but now it is
- allocated. */
-#define BSF_OLD_COMMON 0x200
-
- /* The default value for common data. */
-#define BFD_FORT_COMM_DEFAULT_VALUE 0
-
- /* In some files the type of a symbol sometimes alters its
- location in an output file - ie in coff a <<ISFCN>> symbol
- which is also <<C_EXT>> symbol appears where it was
- declared and not at the end of a section. This bit is set
- by the target BFD part to convey this information. */
-
-#define BSF_NOT_AT_END 0x400
-
- /* Signal that the symbol is the label of constructor section. */
-#define BSF_CONSTRUCTOR 0x800
-
- /* Signal that the symbol is a warning symbol. The name is a
- warning. The name of the next symbol is the one to warn about;
- if a reference is made to a symbol with the same name as the next
- symbol, a warning is issued by the linker. */
-#define BSF_WARNING 0x1000
-
- /* Signal that the symbol is indirect. This symbol is an indirect
- pointer to the symbol with the same name as the next symbol. */
-#define BSF_INDIRECT 0x2000
-
- /* BSF_FILE marks symbols that contain a file name. This is used
- for ELF STT_FILE symbols. */
-#define BSF_FILE 0x4000
-
- /* Symbol is from dynamic linking information. */
-#define BSF_DYNAMIC 0x8000
-
- /* The symbol denotes a data object. Used in ELF, and perhaps
- others someday. */
-#define BSF_OBJECT 0x10000
-
- flagword flags;
-
- /* A pointer to the section to which this symbol is
- relative. This will always be non NULL, there are special
- sections for undefined and absolute symbols. */
- struct sec *section;
-
- /* Back end special data. */
- union
- {
- PTR p;
- bfd_vma i;
- } udata;
-
-} asymbol;
-#define bfd_get_symtab_upper_bound(abfd) \
- BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
-boolean
-bfd_is_local_label PARAMS ((bfd *abfd, asymbol *sym));
-
-#define bfd_is_local_label(abfd, sym) \
- BFD_SEND (abfd, _bfd_is_local_label,(abfd, sym))
-#define bfd_canonicalize_symtab(abfd, location) \
- BFD_SEND (abfd, _bfd_canonicalize_symtab,\
- (abfd, location))
-boolean
-bfd_set_symtab PARAMS ((bfd *abfd, asymbol **location, unsigned int count));
-
-void
-bfd_print_symbol_vandf PARAMS ((PTR file, asymbol *symbol));
-
-#define bfd_make_empty_symbol(abfd) \
- BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
-#define bfd_make_debug_symbol(abfd,ptr,size) \
- BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
-int
-bfd_decode_symclass PARAMS ((asymbol *symbol));
-
-void
-bfd_symbol_info PARAMS ((asymbol *symbol, symbol_info *ret));
-
-boolean
-bfd_copy_private_symbol_data PARAMS ((bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym));
-
-#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
- BFD_SEND (ibfd, _bfd_copy_private_symbol_data, \
- (ibfd, isymbol, obfd, osymbol))
-struct _bfd
-{
- /* The filename the application opened the BFD with. */
- CONST char *filename;
-
- /* A pointer to the target jump table. */
- const struct bfd_target *xvec;
-
- /* To avoid dragging too many header files into every file that
- includes `<<bfd.h>>', IOSTREAM has been declared as a "char
- *", and MTIME as a "long". Their correct types, to which they
- are cast when used, are "FILE *" and "time_t". The iostream
- is the result of an fopen on the filename. However, if the
- BFD_IN_MEMORY flag is set, then iostream is actually a pointer
- to a bfd_in_memory struct. */
- PTR iostream;
-
- /* Is the file descriptor being cached? That is, can it be closed as
- needed, and re-opened when accessed later? */
-
- boolean cacheable;
-
- /* Marks whether there was a default target specified when the
- BFD was opened. This is used to select which matching algorithm
- to use to choose the back end. */
-
- boolean target_defaulted;
-
- /* The caching routines use these to maintain a
- least-recently-used list of BFDs */
-
- struct _bfd *lru_prev, *lru_next;
-
- /* When a file is closed by the caching routines, BFD retains
- state information on the file here: */
-
- file_ptr where;
-
- /* and here: (``once'' means at least once) */
-
- boolean opened_once;
-
- /* Set if we have a locally maintained mtime value, rather than
- getting it from the file each time: */
-
- boolean mtime_set;
-
- /* File modified time, if mtime_set is true: */
-
- long mtime;
-
- /* Reserved for an unimplemented file locking extension.*/
-
- int ifd;
-
- /* The format which belongs to the BFD. (object, core, etc.) */
-
- bfd_format format;
-
- /* The direction the BFD was opened with*/
-
- enum bfd_direction {no_direction = 0,
- read_direction = 1,
- write_direction = 2,
- both_direction = 3} direction;
-
- /* Format_specific flags*/
-
- flagword flags;
-
- /* Currently my_archive is tested before adding origin to
- anything. I believe that this can become always an add of
- origin, with origin set to 0 for non archive files. */
-
- file_ptr origin;
-
- /* Remember when output has begun, to stop strange things
- from happening. */
- boolean output_has_begun;
-
- /* Pointer to linked list of sections*/
- struct sec *sections;
-
- /* The number of sections */
- unsigned int section_count;
-
- /* Stuff only useful for object files:
- The start address. */
- bfd_vma start_address;
-
- /* Used for input and output*/
- unsigned int symcount;
-
- /* Symbol table for output BFD (with symcount entries) */
- struct symbol_cache_entry **outsymbols;
-
- /* Pointer to structure which contains architecture information*/
- const struct bfd_arch_info *arch_info;
-
- /* Stuff only useful for archives:*/
- PTR arelt_data;
- struct _bfd *my_archive; /* The containing archive BFD. */
- struct _bfd *next; /* The next BFD in the archive. */
- struct _bfd *archive_head; /* The first BFD in the archive. */
- boolean has_armap;
-
- /* A chain of BFD structures involved in a link. */
- struct _bfd *link_next;
-
- /* A field used by _bfd_generic_link_add_archive_symbols. This will
- be used only for archive elements. */
- int archive_pass;
-
- /* Used by the back end to hold private data. */
-
- union
- {
- struct aout_data_struct *aout_data;
- struct artdata *aout_ar_data;
- struct _oasys_data *oasys_obj_data;
- struct _oasys_ar_data *oasys_ar_data;
- struct coff_tdata *coff_obj_data;
- struct pe_tdata *pe_obj_data;
- struct xcoff_tdata *xcoff_obj_data;
- struct ecoff_tdata *ecoff_obj_data;
- struct ieee_data_struct *ieee_data;
- struct ieee_ar_data_struct *ieee_ar_data;
- struct srec_data_struct *srec_data;
- struct ihex_data_struct *ihex_data;
- struct tekhex_data_struct *tekhex_data;
- struct elf_obj_tdata *elf_obj_data;
- struct nlm_obj_tdata *nlm_obj_data;
- struct bout_data_struct *bout_data;
- struct sun_core_struct *sun_core_data;
- struct trad_core_struct *trad_core_data;
- struct som_data_struct *som_data;
- struct hpux_core_struct *hpux_core_data;
- struct hppabsd_core_struct *hppabsd_core_data;
- struct sgi_core_struct *sgi_core_data;
- struct lynx_core_struct *lynx_core_data;
- struct osf_core_struct *osf_core_data;
- struct cisco_core_struct *cisco_core_data;
- struct versados_data_struct *versados_data;
- struct netbsd_core_struct *netbsd_core_data;
- PTR any;
- } tdata;
-
- /* Used by the application to hold private data*/
- PTR usrdata;
-
- /* Where all the allocated stuff under this BFD goes */
- struct obstack memory;
-};
-
-typedef enum bfd_error
-{
- bfd_error_no_error = 0,
- bfd_error_system_call,
- bfd_error_invalid_target,
- bfd_error_wrong_format,
- bfd_error_invalid_operation,
- bfd_error_no_memory,
- bfd_error_no_symbols,
- bfd_error_no_armap,
- bfd_error_no_more_archived_files,
- bfd_error_malformed_archive,
- bfd_error_file_not_recognized,
- bfd_error_file_ambiguously_recognized,
- bfd_error_no_contents,
- bfd_error_nonrepresentable_section,
- bfd_error_no_debug_section,
- bfd_error_bad_value,
- bfd_error_file_truncated,
- bfd_error_file_too_big,
- bfd_error_invalid_error_code
-} bfd_error_type;
-
-bfd_error_type
-bfd_get_error PARAMS ((void));
-
-void
-bfd_set_error PARAMS ((bfd_error_type error_tag));
-
-CONST char *
-bfd_errmsg PARAMS ((bfd_error_type error_tag));
-
-void
-bfd_perror PARAMS ((CONST char *message));
-
-typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...));
-
-bfd_error_handler_type
-bfd_set_error_handler PARAMS ((bfd_error_handler_type));
-
-void
-bfd_set_error_program_name PARAMS ((const char *));
-
-long
-bfd_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect));
-
-long
-bfd_canonicalize_reloc
- PARAMS ((bfd *abfd,
- asection *sec,
- arelent **loc,
- asymbol **syms));
-
-void
-bfd_set_reloc
- PARAMS ((bfd *abfd, asection *sec, arelent **rel, unsigned int count)
-
- );
-
-boolean
-bfd_set_file_flags PARAMS ((bfd *abfd, flagword flags));
-
-boolean
-bfd_set_start_address PARAMS ((bfd *abfd, bfd_vma vma));
-
-long
-bfd_get_mtime PARAMS ((bfd *abfd));
-
-long
-bfd_get_size PARAMS ((bfd *abfd));
-
-int
-bfd_get_gp_size PARAMS ((bfd *abfd));
-
-void
-bfd_set_gp_size PARAMS ((bfd *abfd, int i));
-
-bfd_vma
-bfd_scan_vma PARAMS ((CONST char *string, CONST char **end, int base));
-
-boolean
-bfd_copy_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd));
-
-#define bfd_copy_private_bfd_data(ibfd, obfd) \
- BFD_SEND (ibfd, _bfd_copy_private_bfd_data, \
- (ibfd, obfd))
-boolean
-bfd_merge_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd));
-
-#define bfd_merge_private_bfd_data(ibfd, obfd) \
- BFD_SEND (ibfd, _bfd_merge_private_bfd_data, \
- (ibfd, obfd))
-boolean
-bfd_set_private_flags PARAMS ((bfd *abfd, flagword flags));
-
-#define bfd_set_private_flags(abfd, flags) \
- BFD_SEND (abfd, _bfd_set_private_flags, \
- (abfd, flags))
-#define bfd_sizeof_headers(abfd, reloc) \
- BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
-
-#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
- BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line))
-
- /* Do these three do anything useful at all, for any back end? */
-#define bfd_debug_info_start(abfd) \
- BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
-
-#define bfd_debug_info_end(abfd) \
- BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
-
-#define bfd_debug_info_accumulate(abfd, section) \
- BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
-
-
-#define bfd_stat_arch_elt(abfd, stat) \
- BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
-
-#define bfd_update_armap_timestamp(abfd) \
- BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
-
-#define bfd_set_arch_mach(abfd, arch, mach)\
- BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
-
-#define bfd_relax_section(abfd, section, link_info, again) \
- BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
-
-#define bfd_link_hash_table_create(abfd) \
- BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
-
-#define bfd_link_add_symbols(abfd, info) \
- BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
-
-#define bfd_final_link(abfd, info) \
- BFD_SEND (abfd, _bfd_final_link, (abfd, info))
-
-#define bfd_free_cached_info(abfd) \
- BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
-
-#define bfd_get_dynamic_symtab_upper_bound(abfd) \
- BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
-
-#define bfd_print_private_bfd_data(abfd, file)\
- BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
-
-#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
- BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
-
-#define bfd_get_dynamic_reloc_upper_bound(abfd) \
- BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
-
-#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \
- BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
-
-extern bfd_byte *bfd_get_relocated_section_contents
- PARAMS ((bfd *, struct bfd_link_info *,
- struct bfd_link_order *, bfd_byte *,
- boolean, asymbol **));
-
-symindex
-bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym));
-
-boolean
-bfd_set_archive_head PARAMS ((bfd *output, bfd *new_head));
-
-bfd *
-bfd_openr_next_archived_file PARAMS ((bfd *archive, bfd *previous));
-
-CONST char *
-bfd_core_file_failing_command PARAMS ((bfd *abfd));
-
-int
-bfd_core_file_failing_signal PARAMS ((bfd *abfd));
-
-boolean
-core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
-
-#define BFD_SEND(bfd, message, arglist) \
- ((*((bfd)->xvec->message)) arglist)
-
-#ifdef DEBUG_BFD_SEND
-#undef BFD_SEND
-#define BFD_SEND(bfd, message, arglist) \
- (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
- ((*((bfd)->xvec->message)) arglist) : \
- (bfd_assert (__FILE__,__LINE__), NULL))
-#endif
-#define BFD_SEND_FMT(bfd, message, arglist) \
- (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
-
-#ifdef DEBUG_BFD_SEND
-#undef BFD_SEND_FMT
-#define BFD_SEND_FMT(bfd, message, arglist) \
- (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
- (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \
- (bfd_assert (__FILE__,__LINE__), NULL))
-#endif
-enum bfd_flavour {
- bfd_target_unknown_flavour,
- bfd_target_aout_flavour,
- bfd_target_coff_flavour,
- bfd_target_ecoff_flavour,
- bfd_target_elf_flavour,
- bfd_target_ieee_flavour,
- bfd_target_nlm_flavour,
- bfd_target_oasys_flavour,
- bfd_target_tekhex_flavour,
- bfd_target_srec_flavour,
- bfd_target_ihex_flavour,
- bfd_target_som_flavour,
- bfd_target_os9k_flavour,
- bfd_target_versados_flavour,
- bfd_target_msdos_flavour
-};
-
-enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
-
- /* Forward declaration. */
-typedef struct bfd_link_info _bfd_link_info;
-
-typedef struct bfd_target
-{
- char *name;
- enum bfd_flavour flavour;
- enum bfd_endian byteorder;
- enum bfd_endian header_byteorder;
- flagword object_flags;
- flagword section_flags;
- char symbol_leading_char;
- char ar_pad_char;
- unsigned short ar_max_namelen;
- bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
- void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *));
- void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *));
- void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *));
- void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *));
- void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
- void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
- const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
- boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
- boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
-
- /* Generic entry points. */
-#define BFD_JUMP_TABLE_GENERIC(NAME)\
-CAT(NAME,_close_and_cleanup),\
-CAT(NAME,_bfd_free_cached_info),\
-CAT(NAME,_new_section_hook),\
-CAT(NAME,_get_section_contents),\
-CAT(NAME,_get_section_contents_in_window)
-
- /* Called when the BFD is being closed to do any necessary cleanup. */
- boolean (*_close_and_cleanup) PARAMS ((bfd *));
- /* Ask the BFD to free all cached information. */
- boolean (*_bfd_free_cached_info) PARAMS ((bfd *));
- /* Called when a new section is created. */
- boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
- /* Read the contents of a section. */
- boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr, bfd_size_type));
- boolean (*_bfd_get_section_contents_in_window)
- PARAMS ((bfd *, sec_ptr, bfd_window *,
- file_ptr, bfd_size_type));
-
- /* Entry points to copy private data. */
-#define BFD_JUMP_TABLE_COPY(NAME)\
-CAT(NAME,_bfd_copy_private_bfd_data),\
-CAT(NAME,_bfd_merge_private_bfd_data),\
-CAT(NAME,_bfd_copy_private_section_data),\
-CAT(NAME,_bfd_copy_private_symbol_data),\
-CAT(NAME,_bfd_set_private_flags),\
-CAT(NAME,_bfd_print_private_bfd_data)\
- /* Called to copy BFD general private data from one object file
- to another. */
- boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
- /* Called to merge BFD general private data from one object file
- to a common output file when linking. */
- boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
- /* Called to copy BFD private section data from one object file
- to another. */
- boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
- bfd *, sec_ptr));
- /* Called to copy BFD private symbol data from one symbol
- to another. */
- boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
- bfd *, asymbol *));
- /* Called to set private backend flags */
- boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
-
- /* Called to print private BFD data */
- boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
-
- /* Core file entry points. */
-#define BFD_JUMP_TABLE_CORE(NAME)\
-CAT(NAME,_core_file_failing_command),\
-CAT(NAME,_core_file_failing_signal),\
-CAT(NAME,_core_file_matches_executable_p)
- char * (*_core_file_failing_command) PARAMS ((bfd *));
- int (*_core_file_failing_signal) PARAMS ((bfd *));
- boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *));
-
- /* Archive entry points. */
-#define BFD_JUMP_TABLE_ARCHIVE(NAME)\
-CAT(NAME,_slurp_armap),\
-CAT(NAME,_slurp_extended_name_table),\
-CAT(NAME,_construct_extended_name_table),\
-CAT(NAME,_truncate_arname),\
-CAT(NAME,_write_armap),\
-CAT(NAME,_read_ar_hdr),\
-CAT(NAME,_openr_next_archived_file),\
-CAT(NAME,_get_elt_at_index),\
-CAT(NAME,_generic_stat_arch_elt),\
-CAT(NAME,_update_armap_timestamp)
- boolean (*_bfd_slurp_armap) PARAMS ((bfd *));
- boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
- boolean (*_bfd_construct_extended_name_table)
- PARAMS ((bfd *, char **, bfd_size_type *, const char **));
- void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
- boolean (*write_armap) PARAMS ((bfd *arch,
- unsigned int elength,
- struct orl *map,
- unsigned int orl_count,
- int stridx));
- PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
- bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
-#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i))
- bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex));
- int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
- boolean (*_bfd_update_armap_timestamp) PARAMS ((bfd *));
-
- /* Entry points used for symbols. */
-#define BFD_JUMP_TABLE_SYMBOLS(NAME)\
-CAT(NAME,_get_symtab_upper_bound),\
-CAT(NAME,_get_symtab),\
-CAT(NAME,_make_empty_symbol),\
-CAT(NAME,_print_symbol),\
-CAT(NAME,_get_symbol_info),\
-CAT(NAME,_bfd_is_local_label),\
-CAT(NAME,_get_lineno),\
-CAT(NAME,_find_nearest_line),\
-CAT(NAME,_bfd_make_debug_symbol),\
-CAT(NAME,_read_minisymbols),\
-CAT(NAME,_minisymbol_to_symbol)
- long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *));
- long (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
- struct symbol_cache_entry **));
- struct symbol_cache_entry *
- (*_bfd_make_empty_symbol) PARAMS ((bfd *));
- void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
- struct symbol_cache_entry *,
- bfd_print_symbol_type));
-#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
- void (*_bfd_get_symbol_info) PARAMS ((bfd *,
- struct symbol_cache_entry *,
- symbol_info *));
-#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e))
- boolean (*_bfd_is_local_label) PARAMS ((bfd *, asymbol *));
-
- alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
- boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd,
- struct sec *section, struct symbol_cache_entry **symbols,
- bfd_vma offset, CONST char **file, CONST char **func,
- unsigned int *line));
- /* Back-door to allow format-aware applications to create debug symbols
- while using BFD for everything else. Currently used by the assembler
- when creating COFF files. */
- asymbol * (*_bfd_make_debug_symbol) PARAMS ((
- bfd *abfd,
- void *ptr,
- unsigned long size));
-#define bfd_read_minisymbols(b, d, m, s) \
- BFD_SEND (b, _read_minisymbols, (b, d, m, s))
- long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *,
- unsigned int *));
-#define bfd_minisymbol_to_symbol(b, d, m, f) \
- BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
- asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
- asymbol *));
-
- /* Routines for relocs. */
-#define BFD_JUMP_TABLE_RELOCS(NAME)\
-CAT(NAME,_get_reloc_upper_bound),\
-CAT(NAME,_canonicalize_reloc),\
-CAT(NAME,_bfd_reloc_type_lookup)
- long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
- long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
- struct symbol_cache_entry **));
- /* See documentation on reloc types. */
- reloc_howto_type *
- (*reloc_type_lookup) PARAMS ((bfd *abfd,
- bfd_reloc_code_real_type code));
-
- /* Routines used when writing an object file. */
-#define BFD_JUMP_TABLE_WRITE(NAME)\
-CAT(NAME,_set_arch_mach),\
-CAT(NAME,_set_section_contents)
- boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
- unsigned long));
- boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr, bfd_size_type));
-
- /* Routines used by the linker. */
-#define BFD_JUMP_TABLE_LINK(NAME)\
-CAT(NAME,_sizeof_headers),\
-CAT(NAME,_bfd_get_relocated_section_contents),\
-CAT(NAME,_bfd_relax_section),\
-CAT(NAME,_bfd_link_hash_table_create),\
-CAT(NAME,_bfd_link_add_symbols),\
-CAT(NAME,_bfd_final_link),\
-CAT(NAME,_bfd_link_split_section)
- int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
- bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
- struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *data, boolean relocateable,
- struct symbol_cache_entry **));
-
- boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
- struct bfd_link_info *, boolean *again));
-
- /* Create a hash table for the linker. Different backends store
- different information in this table. */
- struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
-
- /* Add symbols from this object file into the hash table. */
- boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
-
- /* Do a link based on the link_order structures attached to each
- section of the BFD. */
- boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
-
- /* Should this section be split up into smaller pieces during linking. */
- boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
-
- /* Routines to handle dynamic symbols and relocs. */
-#define BFD_JUMP_TABLE_DYNAMIC(NAME)\
-CAT(NAME,_get_dynamic_symtab_upper_bound),\
-CAT(NAME,_canonicalize_dynamic_symtab),\
-CAT(NAME,_get_dynamic_reloc_upper_bound),\
-CAT(NAME,_canonicalize_dynamic_reloc)
- /* Get the amount of memory required to hold the dynamic symbols. */
- long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
- /* Read in the dynamic symbols. */
- long (*_bfd_canonicalize_dynamic_symtab)
- PARAMS ((bfd *, struct symbol_cache_entry **));
- /* Get the amount of memory required to hold the dynamic relocs. */
- long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
- /* Read in the dynamic relocs. */
- long (*_bfd_canonicalize_dynamic_reloc)
- PARAMS ((bfd *, arelent **, struct symbol_cache_entry **));
-
- PTR backend_data;
-} bfd_target;
-const bfd_target *
-bfd_find_target PARAMS ((CONST char *target_name, bfd *abfd));
-
-const char **
-bfd_target_list PARAMS ((void));
-
-boolean
-bfd_check_format PARAMS ((bfd *abfd, bfd_format format));
-
-boolean
-bfd_check_format_matches PARAMS ((bfd *abfd, bfd_format format, char ***matching));
-
-boolean
-bfd_set_format PARAMS ((bfd *abfd, bfd_format format));
-
-CONST char *
-bfd_format_string PARAMS ((bfd_format format));
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/gnu/usr.bin/gdb/bfd/config.h b/gnu/usr.bin/gdb/bfd/config.h
deleted file mode 100644
index e039382..0000000
--- a/gnu/usr.bin/gdb/bfd/config.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* config.in. Generated automatically from configure.in by autoheader. */
-
-/* Whether malloc must be declared even if <stdlib.h> is included. */
-/* #undef NEED_DECLARATION_MALLOC */
-
-/* Whether free must be declared even if <stdlib.h> is included. */
-/* #undef NEED_DECLARATION_FREE */
-
-/* Define if you have a working `mmap' system call. */
-#define HAVE_MMAP 1
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#define TIME_WITH_SYS_TIME 1
-
-/* Do we need to use the b modifier when opening binary files? */
-/* #undef USE_BINARY_FOPEN */
-
-/* Name of host specific header file to include in trad-core.c. */
-#define TRAD_HEADER "i386freebsd.h"
-
-/* Define only if <sys/procfs.h> is available *and* it defines prstatus_t. */
-/* #undef HAVE_SYS_PROCFS_H */
-
-/* Do we really want to use mmap if it's available? */
-/* #undef USE_MMAP */
-
-/* Define if you have the fcntl function. */
-#define HAVE_FCNTL 1
-
-/* Define if you have the getpagesize function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define if you have the madvise function. */
-#define HAVE_MADVISE 1
-
-/* Define if you have the mprotect function. */
-#define HAVE_MPROTECT 1
-
-/* Define if you have the valloc function. */
-#define HAVE_VALLOC 1
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <stddef.h> header file. */
-#define HAVE_STDDEF_H 1
-
-/* Define if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define if you have the <sys/file.h> header file. */
-#define HAVE_SYS_FILE_H 1
-
-/* Define if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define if you have the <time.h> header file. */
-#define HAVE_TIME_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
diff --git a/gnu/usr.bin/gdb/bfd/i386freebsd.h b/gnu/usr.bin/gdb/bfd/i386freebsd.h
deleted file mode 100644
index 4859a37..0000000
--- a/gnu/usr.bin/gdb/bfd/i386freebsd.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Intel 386 running any FreeBSD Unix */
-
-#include <machine/param.h>
-#include <machine/vmparam.h>
-
-#define NBPG PAGE_SIZE
-#define HOST_PAGE_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_i386
-#define HOST_TEXT_START_ADDR USRTEXT
-
-/* Jolitz suggested defining HOST_STACK_END_ADDR to
- (u.u_kproc.kp_eproc.e_vm.vm_maxsaddr + MAXSSIZ), which should work on
- both BSDI and 386BSD, but that is believed not to work for BSD 4.4. */
-
-/* This seems to be the right thing for FreeBSD and BSDI */
-#define HOST_STACK_END_ADDR USRSTACK
-
-/* Leave HOST_DATA_START_ADDR undefined, since the default when it is not
- defined sort of works, and FreeBSD-2.0 through FreeBSD-2.2.2 do not
- set u.u_kproc.kp_eproc.e_vm.vm_daddr. */
-
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
- ((core_bfd)->tdata.trad_core_data->u.u_sig)
-#define u_comm u_kproc.kp_proc.p_comm
diff --git a/gnu/usr.bin/gdb/doc/Makefile b/gnu/usr.bin/gdb/doc/Makefile
deleted file mode 100644
index 896ba78..0000000
--- a/gnu/usr.bin/gdb/doc/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-INFO = gdb gdbint stabs annotate
-
-SRCDIR= ${.CURDIR}/../../../../contrib/gdb/gdb/doc
-
-INFOSECTION= "Gdb Documentation"
-INFOENTRY_annotate= "* GDB annotation: (annotate). Annotations for the GNU Debugger (GDB)."
-
-MAKEINFOFLAGS += -I ${.CURDIR}/../../../../contrib/libreadline/doc
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/gdb/doc/gdb-cfg.texi b/gnu/usr.bin/gdb/doc/gdb-cfg.texi
deleted file mode 100644
index 5b549c2..0000000
--- a/gnu/usr.bin/gdb/doc/gdb-cfg.texi
+++ /dev/null
@@ -1,120 +0,0 @@
-@c GDB MANUAL configuration file.
-@c Copyright (c) 1993 Free Software Foundation, Inc.
-@c
-@c NOTE: While the GDB manual is configurable (by changing these
-@c switches), its configuration is ***NOT*** automatically tied in to
-@c source configuration---because the authors expect that, save in
-@c unusual cases, the most inclusive form of the manual is appropriate
-@c no matter how the program itself is configured.
-@c
-@c The only automatically-varying variable is the GDB version number,
-@c which the Makefile rewrites based on the VERSION variable from
-@c `../Makefile.in'.
-@c
-@c GDB version number is recorded in the variable GDBVN
-@include GDBvn.texi
-@c
-@c ----------------------------------------------------------------------
-@c PLATFORM FLAGS:
-@set GENERIC
-@c
-@c Hitachi H8/300 target:
-@set H8
-@c Hitachi H8/300 target ONLY:
-@clear H8EXCLUSIVE
-@c
-@c remote MIPS target:
-@set MIPS
-@c
-@c SPARC target:
-@set SPARC
-@c
-@c AMD 29000 target:
-@set AMD29K
-@c
-@c Intel 960 target:
-@set I960
-@c
-@c Tandem ST2000 (phone switch) target:
-@set ST2000
-@c
-@c Zilog 8000 target:
-@set Z8K
-@c
-@c Lucid "Energize" environment:
-@clear LUCID
-@c
-@c Wind River Systems VxWorks environment:
-@set VXWORKS
-@c
-@c ----------------------------------------------------------------------
-@c DOC FEATURE FLAGS:
-@c
-@c Include change-from-old?
-@set NOVEL
-@c
-@c Bare-board target?
-@clear BARETARGET
-@c
-@c Restrict languages discussed to C?
-@c This is backward. As time permits, change this to language-specific
-@c switches for what to include.
-@clear CONLY
-@c Discuss Fortran?
-@set FORTRAN
-@c
-@c Discuss Modula 2?
-@set MOD2
-@c
-@c Specifically for host machine running DOS?
-@clear DOSHOST
-@c
-@c Talk about CPU simulator targets?
-@set SIMS
-@c
-@c Is manual stand-alone, or part of an agglomeration, with overall GPL?
-@clear AGGLOMERATION
-@c
-@c Remote serial line settings of interest?
-@set SERIAL
-@c
-@c Discuss features requiring Posix or similar OS environment?
-@set POSIX
-@c
-@c Discuss remote serial debugging stub?
-@set REMOTESTUB
-@c
-@c Discuss gdbserver?
-@set GDBSERVER
-@c
-@c Discuss gdbserve.nlm?
-@set GDBSERVE
-@c
-@c Refrain from discussing how to configure sw and format doc?
-@clear PRECONFIGURED
-@c
-@c Refrain from referring to unfree publications?
-@set FSFDOC
-@c
-@c ----------------------------------------------------------------------
-@c STRINGS:
-@c
-@c Name of GDB program. Used also for (gdb) prompt string.
-@set GDBP gdb
-@c
-@c Name of GDB product. Used in running text.
-@set GDBN GDB
-@c
-@c Name of GDB initialization file.
-@set GDBINIT .gdbinit
-@c
-@c Name of host. Should not be used in generic configs, but generic
-@c value may catch some flubs.
-@set HOST machine specific
-@c
-@c Name of GCC product
-@set NGCC GCC
-@c
-@c Name of GCC program
-@set GCC gcc
-
diff --git a/gnu/usr.bin/gdb/doc/inc-hist.texi b/gnu/usr.bin/gdb/doc/inc-hist.texi
deleted file mode 100644
index 914ebd5..0000000
--- a/gnu/usr.bin/gdb/doc/inc-hist.texi
+++ /dev/null
@@ -1,313 +0,0 @@
-@ignore
-This file should be completely identical to the version of hsuser.texinfo
-in src/contrib/libreadline/doc, except that it has the reference to the
-programming manual commented out. This should be done better! We don't
-use the version of this file distributed with gdb-4.16, since that isn't
-even almost completely identical with the old version of hsuser.texinfo
-distributied with gdb-4.16.
-
-@ignore
-This file documents the user interface to the GNU History library.
-
-Copyright (C) 1988, 1991, 1996 Free Software Foundation, Inc.
-Authored by Brian Fox and Chet Ramey.
-
-Permission is granted to make and distribute verbatim copies of this manual
-provided the copyright notice and this permission notice are preserved on
-all copies.
-
-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).
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that the
-GNU Copyright statement is available to the distributee, and provided that
-the entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions.
-@end ignore
-
-@node Using History Interactively
-@chapter Using History Interactively
-
-@ifset BashFeatures
-This chapter describes how to use the GNU History Library interactively,
-from a user's standpoint. It should be considered a user's guide. For
-information on using the GNU History Library in your own programs,
-see the GNU Readline Library Manual.
-@end ifset
-@ifclear BashFeatures
-This chapter describes how to use the GNU History Library interactively,
-from a user's standpoint.
-@c It should be considered a user's guide. For
-@c information on using the GNU History Library in your own programs,
-@c @pxref{Programming with GNU History}.
-@end ifclear
-
-@ifset BashFeatures
-@menu
-* Bash History Facilities:: How Bash lets you manipulate your command
- history.
-* History Interaction:: What it feels like using History as a user.
-@end menu
-@end ifset
-@ifclear BashFeatures
-@menu
-* History Interaction:: What it feels like using History as a user.
-@end menu
-@end ifclear
-
-@ifset BashFeatures
-@node Bash History Facilities
-@section Bash History Facilities
-@cindex command history
-@cindex history list
-
-When the @samp{-o history} option to the @code{set} builtin
-is enabled (@pxref{The Set Builtin}),
-the shell provides access to the @var{command history},
-the list of commands previously typed. The text of the last
-@code{HISTSIZE}
-commands (default 500) is saved in a history list. The shell
-stores each command in the history list prior to parameter and
-variable expansion
-but after history expansion is performed, subject to the
-values of the shell variables
-@code{HISTIGNORE} and @code{HISTCONTROL}.
-When the shell starts up, the history is initialized from the
-file named by the @code{HISTFILE} variable (default @file{~/.bash_history}).
-@code{HISTFILE} is truncated, if necessary, to contain no more than
-the number of lines specified by the value of the @code{HISTFILESIZE}
-variable. When an interactive shell exits, the last
-@code{HISTSIZE} lines are copied from the history list to @code{HISTFILE}.
-If the @code{histappend} shell option is set (@pxref{Bash Builtins}),
-the lines are appended to the history file,
-otherwise the history file is overwritten.
-If @code{HISTFILE}
-is unset, or if the history file is unwritable, the history is
-not saved. After saving the history, the history file is truncated
-to contain no more than @code{$HISTFILESIZE}
-lines. If @code{HISTFILESIZE} is not set, no truncation is performed.
-
-The builtin command @code{fc} (@pxref{Korn Shell Builtins})
-may be used to list or edit and re-execute a portion of
-the history list. The @code{history} builtin (@pxref{C Shell Builtins})
-can be used to display or modify the history list and
-manipulate the history file.
-When using the command-line editing, search commands
-are available in each editing mode that provide access to the
-history list.
-
-The shell allows control over which commands are saved on the history
-list. The @code{HISTCONTROL} and @code{HISTIGNORE}
-variables may be set to cause the shell to save only a subset of the
-commands entered.
-The @code{cmdhist}
-shell option, if enabled, causes the shell to attempt to save each
-line of a multi-line command in the same history entry, adding
-semicolons where necessary to preserve syntactic correctness.
-The @code{lithist}
-shell option causes the shell to save the command with embedded newlines
-instead of semicolons.
-@xref{Bash Builtins} for a description of @code{shopt}.
-@end ifset
-
-@node History Interaction
-@section Interactive History Expansion
-@cindex history expansion
-
-The History library provides a history expansion feature that is similar
-to the history expansion provided by @code{csh}. This section
-describes the syntax used to manipulate the history information.
-
-History expansions introduce words from the history list into
-the input stream, making it easy to repeat commands, insert the
-arguments to a previous command into the current input line, or
-fix errors in previous commands quickly.
-
-History expansion takes place in two parts. The first is to determine
-which line from the previous history should be used during substitution.
-The second is to select portions of that line for inclusion into the
-current one. The line selected from the previous history is called the
-@dfn{event}, and the portions of that line that are acted upon are
-called @dfn{words}. Various @dfn{modifiers} are available to manipulate
-the selected words. The line is broken into words in the same fashion
-that Bash does, so that several English (or Unix) words
-surrounded by quotes are considered as one word.
-History expansions are introduced by the appearance of the
-history expansion character, which is @samp{!} by default.
-@ifset BashFeatures
-Only @samp{\} and @samp{'} may be used to escape the history expansion
-character.
-@end ifset
-
-@ifset BashFeatures
-Several shell options settable with the @code{shopt}
-builtin (@pxref{Bash Builtins}) may be used to tailor
-the behavior of history expansion. If the
-@code{histverify} shell option is enabled, and Readline
-is being used, history substitutions are not immediately passed to
-the shell parser.
-Instead, the expanded line is reloaded into the Readline
-editing buffer for further modification.
-If Readline is being used, and the @code{histreedit}
-shell option is enabled, a failed history expansion will be
-reloaded into the Readline editing buffer for correction.
-The @samp{-p} option to the @code{history} builtin command
-may be used to see what a history expansion will do before using it.
-The @samp{-s} option to the @code{history} builtin may be used to
-add commands to the end of the history list without actually executing
-them, so that they are available for subsequent recall.
-
-The shell allows control of the various characters used by the
-history expansion mechanism with the @code{histchars} variable.
-@end ifset
-
-@menu
-* Event Designators:: How to specify which history line to use.
-* Word Designators:: Specifying which words are of interest.
-* Modifiers:: Modifying the results of substitution.
-@end menu
-
-@node Event Designators
-@subsection Event Designators
-@cindex event designators
-
-An event designator is a reference to a command line entry in the
-history list.
-@cindex history events
-
-@table @asis
-
-@item @code{!}
-Start a history substitution, except when followed by a space, tab,
-the end of the line, @key{=} or @key{(}.
-
-@item @code{!@var{n}}
-Refer to command line @var{n}.
-
-@item @code{!-@var{n}}
-Refer to the command @var{n} lines back.
-
-@item @code{!!}
-Refer to the previous command. This is a synonym for @samp{!-1}.
-
-@item @code{!@var{string}}
-Refer to the most recent command starting with @var{string}.
-
-@item @code{!?@var{string}[?]}
-Refer to the most recent command containing @var{string}. The trailing
-@samp{?} may be omitted if the @var{string} is followed immediately by
-a newline.
-
-@item @code{^@var{string1}^@var{string2}^}
-Quick Substitution. Repeat the last command, replacing @var{string1}
-with @var{string2}. Equivalent to
-@code{!!:s/@var{string1}/@var{string2}/}.
-
-@item @code{!#}
-The entire command line typed so far.
-
-@end table
-
-@node Word Designators
-@subsection Word Designators
-
-Word designators are used to select desired words from the event.
-A @samp{:} separates the event specification from the word designator. It
-can be omitted if the word designator begins with a @samp{^}, @samp{$},
-@samp{*}, @samp{-}, or @samp{%}. Words are numbered from the beginning
-of the line, with the first word being denoted by 0 (zero). Words are
-inserted into the current line separated by single spaces.
-
-@table @code
-
-@item 0 (zero)
-The @code{0}th word. For many applications, this is the command word.
-
-@item @var{n}
-The @var{n}th word.
-
-@item ^
-The first argument; that is, word 1.
-
-@item $
-The last argument.
-
-@item %
-The word matched by the most recent @samp{?@var{string}?} search.
-
-@item @var{x}-@var{y}
-A range of words; @samp{-@var{y}} abbreviates @samp{0-@var{y}}.
-
-@item *
-All of the words, except the @code{0}th. This is a synonym for @samp{1-$}.
-It is not an error to use @samp{*} if there is just one word in the event;
-the empty string is returned in that case.
-
-@item @var{x}*
-Abbreviates @samp{@var{x}-$}
-
-@item @var{x}-
-Abbreviates @samp{@var{x}-$} like @samp{@var{x}*}, but omits the last word.
-
-@end table
-
-If a word designator is supplied without an event specification, the
-previous command is used as the event.
-
-@node Modifiers
-@subsection Modifiers
-
-After the optional word designator, you can add a sequence of one or more
-of the following modifiers, each preceded by a @samp{:}.
-
-@table @code
-
-@item h
-Remove a trailing pathname component, leaving only the head.
-
-@item t
-Remove all leading pathname components, leaving the tail.
-
-@item r
-Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving
-the basename.
-
-@item e
-Remove all but the trailing suffix.
-
-@item p
-Print the new command but do not execute it.
-
-@ifset BashFeatures
-@item q
-Quote the substituted words, escaping further substitutions.
-
-@item x
-Quote the substituted words as with @samp{q},
-but break into words at spaces, tabs, and newlines.
-@end ifset
-
-@item s/@var{old}/@var{new}/
-Substitute @var{new} for the first occurrence of @var{old} in the
-event line. Any delimiter may be used in place of @samp{/}.
-The delimiter may be quoted in @var{old} and @var{new}
-with a single backslash. If @samp{&} appears in @var{new},
-it is replaced by @var{old}. A single backslash will quote
-the @samp{&}. The final delimiter is optional if it is the last
-character on the input line.
-
-@item &
-Repeat the previous substitution.
-
-@item g
-Cause changes to be applied over the entire event line. Used in
-conjunction with @samp{s}, as in @code{gs/@var{old}/@var{new}/},
-or with @samp{&}.
-
-@end table
diff --git a/gnu/usr.bin/gdb/gdb/Makefile b/gnu/usr.bin/gdb/gdb/Makefile
deleted file mode 100644
index 90b5696..0000000
--- a/gnu/usr.bin/gdb/gdb/Makefile
+++ /dev/null
@@ -1,117 +0,0 @@
-# $Id: Makefile,v 1.28 1997/05/02 11:22:51 gj Exp $
-
-PROG = gdb
-
-GDBDIR= ${.CURDIR}/../../../../contrib/gdb
-.PATH: ${GDBDIR}/gdb
-.PATH: ${GDBDIR}/opcodes
-
-BINDIR= /usr/bin
-XSRCS = annotate.c blockframe.c breakpoint.c buildsym.c c-lang.c \
- c-typeprint.c c-valprint.c ch-lang.c ch-typeprint.c \
- ch-valprint.c coffread.c command.c complaints.c copying.c \
- corelow.c cp-valprint.c \
- dcache.c dbxread.c demangle.c dwarfread.c \
- elfread.c environ.c eval.c exec.c expprint.c \
- findvar.c fork-child.c freebsd-nat.c gdbtypes.c \
- i386-tdep.c infcmd.c inflow.c infptrace.c \
- infrun.c inftarg.c language.c \
- m2-lang.c m2-typeprint.c m2-valprint.c main.c maint.c \
- mem-break.c minsyms.c objfiles.c parse.c \
- printcmd.c remote.c remote-utils.c solib.c source.c \
- stabsread.c stack.c symfile.c symmisc.c \
- symtab.c target.c thread.c top.c \
- typeprint.c utils.c valarith.c valops.c \
- valprint.c values.c version.c \
- serial.c ser-unix.c ser-tcp.c mdebugread.c \
- c-exp.c f-exp.c m2-exp.c i387-tdep.c \
- kvm-fbsd.c bcache.c \
- corefile.c ch-exp.c f-lang.c scm-exp.c scm-lang.c \
- scm-valprint.c f-typeprint.c f-valprint.c nlmread.c \
- callback.c
-XSRCS+= i386-dis.c dis-buf.c disassemble.c
-SRCS= init.c ${XSRCS}
-
-CFLAGS+= -I$(.CURDIR) -I${DESTDIR}/usr/include/readline -I$(.CURDIR)/../bfd
-# use phkmalloc
-CFLAGS+= -DNO_MMALLOC
-# uncomment the next line if you want to debug gdb
-#CFLAGS+= -g
-
-CLEANFILES+= c-exp.c f-exp.c m2-exp.c init.c y.tab.h init.c-tmp
-#beforedepend: c-exp.c f-exp.c m2-exp.c init.c
-.ORDER: c-exp.c f-exp.c m2-exp.c
-
-.if exists(${.OBJDIR}/../bfd)
-LDADD+= -L${.OBJDIR}/../bfd -lbfd
-DPADD+= ${.OBJDIR}/../bfd/libbfd.a
-.else
-LDADD+= -L${.CURDIR}/../bfd/ -lbfd
-DPADD+= ${.CURDIR}/../bfd/libbfd.a
-.endif
-
-DPADD+= ${LIBREADLINE} ${LIBGNUREGEX}
-LDADD+= -lreadline -lgnuregex
-
-.if exists(${.OBJDIR}/../libiberty)
-LDADD+= -L${.OBJDIR}/../libiberty -liberty
-DPADD+= ${.OBJDIR}/../libiberty/libiberty.a
-.else
-LDADD+= -L${.CURDIR}/../libiberty/ -liberty
-DPADD+= ${.CURDIR}/../libiberty/libiberty.a
-.endif
-
-DPADD+= ${LIBTERMCAP}
-LDADD+= -ltermcap
-
-.if exists(${.OBJDIR}/../libiberty)
-LDADD+= -L${.OBJDIR}/../libiberty -liberty
-DPADD+= ${.OBJDIR}/../libiberty/libiberty.a
-.else
-LDADD+= -L${.CURDIR}/../libiberty/ -liberty
-DPADD+= ${.CURDIR}/../libiberty/libiberty.a
-.endif
-
-# We do this by grepping through sources. If that turns out to be too slow,
-# maybe we could just require every .o file to have an initialization routine
-# of a given name (remote-udi.o -> _initialize_remote_udi, etc.).
-#
-# Formatting conventions: The name of the _initialize_* routines must start
-# in column zero, and must not be inside #if.
-#
-# Note that the set of files with init functions might change, or the names
-# of the functions might change, so this files needs to depend on all the
-# object files that will be linked into gdb.
-
-init.c: ${XSRCS}
- @echo Making ${.TARGET}
- @rm -f init.c-tmp
- @echo '/* Do not modify this file. */' >init.c-tmp
- @echo '/* It is created automatically by the Makefile. */'>>init.c-tmp
- @echo 'void initialize_all_files () {' >>init.c-tmp
- @for i in ${.ALLSRC} ; do \
- filename=`echo $$i | sed \
- -e '/^Onindy.c/d' \
- -e '/^nindy.c/d' \
- -e '/ttyflush.c/d' \
- -e '/xdr_ld.c/d' \
- -e '/xdr_ptrace.c/d' \
- -e '/xdr_rdb.c/d' \
- -e '/udr.c/d' \
- -e '/udip2soc.c/d' \
- -e '/udi2go32.c/d' \
- -e '/version.c/d' \
- -e '/^[a-z0-9A-Z_]*_[SU].c/d' \
- -e '/[a-z0-9A-Z_]*-exp.tab.c/d'` ; \
- case $$filename in \
- "") ;; \
- *) sed <$$filename >>init.c-tmp -n \
- -e '/^_initialize_[a-z_0-9A-Z]* *(/s/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (); \1 ();}/p' ; ;; \
- esac ; \
- done
- @echo '}' >>init.c-tmp
- @mv init.c-tmp ${.TARGET}
-
-.PRECIOUS: init.c
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/gdb/gdb/config.h b/gnu/usr.bin/gdb/gdb/config.h
deleted file mode 100644
index 29f0a3c..0000000
--- a/gnu/usr.bin/gdb/gdb/config.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* config.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if on AIX 3.
- System headers sometimes define this.
- We just want to avoid a redefinition error message. */
-#ifndef _ALL_SOURCE
-/* #undef _ALL_SOURCE */
-#endif
-
-/* Define if the `long double' type works. */
-#define HAVE_LONG_DOUBLE 1
-
-/* Define if you have a working `mmap' system call. */
-#define HAVE_MMAP 1
-
-/* Define if on MINIX. */
-/* #undef _MINIX */
-
-/* Define if the system does not provide POSIX.1 features except
- with this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define if you need to in order for stat and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if fpregset_t type is available. */
-/* #undef HAVE_FPREGSET_T */
-
-/* Define if gregset_t type is available. */
-/* #undef HAVE_GREGSET_T */
-
-/* Define if the "%Lg" format works to print long doubles. */
-#define PRINTF_HAS_LONG_DOUBLE 1
-
-/* Define if you have the getpagesize function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define if you have the sbrk function. */
-#define HAVE_SBRK 1
-
-/* Define if you have the setpgid function. */
-#define HAVE_SETPGID 1
-
-/* Define if you have the valloc function. */
-#define HAVE_VALLOC 1
-
-/* Define if you have the <endian.h> header file. */
-/* #undef HAVE_ENDIAN_H */
-
-/* Define if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <link.h> header file. */
-#define HAVE_LINK_H 1
-
-/* Define if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define if you have the <sgtty.h> header file. */
-#define HAVE_SGTTY_H 1
-
-/* Define if you have the <stddef.h> header file. */
-#define HAVE_STDDEF_H 1
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define if you have the <sys/procfs.h> header file. */
-/* #undef HAVE_SYS_PROCFS_H */
-
-/* Define if you have the <termio.h> header file. */
-/* #undef HAVE_TERMIO_H */
-
-/* Define if you have the <termios.h> header file. */
-#define HAVE_TERMIOS_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the dl library (-ldl). */
-/* #undef HAVE_LIBDL */
diff --git a/gnu/usr.bin/gdb/gdb/freebsd-nat.c b/gnu/usr.bin/gdb/gdb/freebsd-nat.c
deleted file mode 100644
index e73f402..0000000
--- a/gnu/usr.bin/gdb/gdb/freebsd-nat.c
+++ /dev/null
@@ -1,401 +0,0 @@
-/* Native-dependent code for BSD Unix running on i386's, for GDB.
- Copyright 1988, 1989, 1991, 1992, 1994, 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-
-#include <sys/types.h>
-#include <sys/ptrace.h>
-#include <machine/reg.h>
-#include <machine/frame.h>
-#include <sys/param.h>
-#include <sys/user.h>
-#include "gdbcore.h"
-#include "value.h"
-#include "inferior.h"
-
-/* this table must line up with REGISTER_NAMES in tm-i386v.h */
-/* symbols like 'tEAX' come from <machine/reg.h> */
-static int tregmap[] =
-{
- tEAX, tECX, tEDX, tEBX,
- tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS,
- tDS, tES, tFS, tGS,
-};
-
-static struct save87 pcb_savefpu;
-
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- struct reg inferior_registers; /* ptrace order, not gcc/gdb order */
- int r;
-
- ptrace (PT_GETREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_registers, 0);
-
- for (r = 0; r < NUM_REGS; r++)
- memcpy (&registers[REGISTER_BYTE (r)], ((int *)&inferior_registers) + tregmap[r], 4);
-
- registers_fetched ();
-}
-
-void
-store_inferior_registers (regno)
- int regno;
-{
- struct reg inferior_registers; /* ptrace order, not gcc/gdb order */
- int r;
-
- for (r = 0; r < NUM_REGS; r++)
- memcpy (((int *)&inferior_registers) + tregmap[r], &registers[REGISTER_BYTE (r)], 4);
-
- ptrace (PT_SETREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_registers, 0);
-}
-
-/* Extract the register values out of the core file and store
- them where `read_register' will find them.
- Extract the floating point state out of the core file and store
- it where `float_info' will find it.
-
- CORE_REG_SECT points to the register values themselves, read into memory.
- CORE_REG_SIZE is the size of that area.
- WHICH says which set of registers we are handling (0 = int, 2 = float
- on machines where they are discontiguous).
- REG_ADDR is the offset from u.u_ar0 to the register values relative to
- core_reg_sect. This is used with old-fashioned core files to
- locate the registers in a large upage-plus-stack ".reg" section.
- Original upage address X is at location core_reg_sect+x+reg_addr.
- */
-
-static void
-fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which;
- CORE_ADDR reg_addr;
-{
- register int regno;
- register int cregno;
- register int addr;
- int bad_reg = -1;
- int offset;
- struct user *tmp_uaddr;
-
- /*
- * First get virtual address of user structure. Then calculate offset.
- */
- memcpy(&tmp_uaddr,
- &((struct user *) core_reg_sect)->u_kproc.kp_proc.p_addr,
- sizeof(tmp_uaddr));
- offset = -reg_addr - (int) tmp_uaddr;
-
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- cregno = tregmap[regno];
- if (cregno == tFS)
- addr = offsetof (struct user, u_pcb) + offsetof (struct pcb, pcb_fs);
- else if (cregno == tGS)
- addr = offsetof (struct user, u_pcb) + offsetof (struct pcb, pcb_gs);
- else
- addr = offset + 4 * cregno;
- if (addr < 0 || addr >= core_reg_size)
- {
- if (bad_reg < 0)
- bad_reg = regno;
- }
- else
- {
- supply_register (regno, core_reg_sect + addr);
- }
- }
- if (bad_reg >= 0)
- {
- error ("Register %s not found in core file.", reg_names[bad_reg]);
- }
-
- addr = offsetof (struct user, u_pcb) + offsetof (struct pcb, pcb_savefpu);
- memcpy (&pcb_savefpu, core_reg_sect + addr, sizeof pcb_savefpu);
-}
-
-#ifdef FLOAT_INFO
-#include "expression.h"
-#include "language.h" /* for local_hex_string */
-#include "floatformat.h"
-
-#include <sys/param.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#include <a.out.h>
-
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/uio.h>
-#define curpcb Xcurpcb /* XXX avoid leaking declaration from pcb.h */
-#include <sys/user.h>
-#undef curpcb
-#include <sys/file.h>
-#include "gdb_stat.h"
-#include <sys/ptrace.h>
-
-extern void print_387_control_word (); /* i387-tdep.h */
-extern void print_387_status_word ();
-
-#define fpstate save87
-#define U_FPSTATE(u) u.u_pcb.pcb_savefpu
-
-static void
-i387_to_double (from, to)
- char *from;
- char *to;
-{
- long *lp;
- /* push extended mode on 387 stack, then pop in double mode
- *
- * first, set exception masks so no error is generated -
- * number will be rounded to inf or 0, if necessary
- */
- asm ("pushl %eax"); /* grab a stack slot */
- asm ("fstcw (%esp)"); /* get 387 control word */
- asm ("movl (%esp),%eax"); /* save old value */
- asm ("orl $0x3f,%eax"); /* mask all exceptions */
- asm ("pushl %eax");
- asm ("fldcw (%esp)"); /* load new value into 387 */
-
- asm ("movl 8(%ebp),%eax");
- asm ("fldt (%eax)"); /* push extended number on 387 stack */
- asm ("fwait");
- asm ("movl 12(%ebp),%eax");
- asm ("fstpl (%eax)"); /* pop double */
- asm ("fwait");
-
- asm ("popl %eax"); /* flush modified control word */
- asm ("fnclex"); /* clear exceptions */
- asm ("fldcw (%esp)"); /* restore original control word */
- asm ("popl %eax"); /* flush saved copy */
-}
-
-struct env387
-{
- unsigned short control;
- unsigned short r0;
- unsigned short status;
- unsigned short r1;
- unsigned short tag;
- unsigned short r2;
- unsigned long eip;
- unsigned short code_seg;
- unsigned short opcode;
- unsigned long operand;
- unsigned short operand_seg;
- unsigned short r3;
- unsigned char regs[8][10];
-};
-
-static void
-print_387_status (status, ep)
- unsigned short status;
- struct env387 *ep;
-{
- int i;
- int bothstatus;
- int top;
- int fpreg;
-
- bothstatus = ((status != 0) && (ep->status != 0));
- if (status != 0)
- {
- if (bothstatus)
- printf_unfiltered ("u: ");
- print_387_status_word ((unsigned int)status);
- }
-
- if (ep->status != 0)
- {
- if (bothstatus)
- printf_unfiltered ("e: ");
- print_387_status_word ((unsigned int)ep->status);
- }
-
- print_387_control_word ((unsigned int)ep->control);
- printf_unfiltered ("last instruction: ");
- printf_unfiltered ("opcode %s; ", local_hex_string(ep->opcode));
- printf_unfiltered ("pc %s:", local_hex_string(ep->code_seg));
- printf_unfiltered ("%s; ", local_hex_string(ep->eip));
- printf_unfiltered ("operand %s", local_hex_string(ep->operand_seg));
- printf_unfiltered (":%s\n", local_hex_string(ep->operand));
-
- top = (ep->status >> 11) & 7;
-
- printf_unfiltered (" regno tag msb lsb value\n");
- for (fpreg = 7; fpreg >= 0; fpreg--)
- {
- int exp;
- int mantissa_or;
- int normal;
- char *sign;
- int st_regno;
- unsigned short *usregs;
- double val;
-
- /* The physical regno `fpreg' is only relevant as an index into the
- * tag word. Logical `%st' numbers are required for indexing ep->regs.
- */
- st_regno = (fpreg + 8 - top) & 7;
-
- printf_unfiltered ("%%st(%d) %s ", st_regno, fpreg == top ? "=>" : " ");
-
- switch ((ep->tag >> (fpreg * 2)) & 3)
- {
- case 0: printf_unfiltered ("valid "); break;
- case 1: printf_unfiltered ("zero "); break;
- case 2: printf_unfiltered ("trap "); break;
- case 3: printf_unfiltered ("empty "); break;
- }
- for (i = 9; i >= 0; i--)
- printf_unfiltered ("%02x", ep->regs[st_regno][i]);
-
- printf_unfiltered (" ");
-
- /*
- * Handle weird cases better than floatformat_to_double () and
- * printf ().
- */
- usregs = (unsigned short *) ep->regs[st_regno];
- sign = usregs[4] & 0x8000 ? "-" : "";
- exp = usregs[4] & 0x7fff;
- normal = usregs[3] & 0x8000;
- mantissa_or = usregs[0] | usregs[1] | usregs[2] | (usregs[3] & 0x7fff);
- if (exp == 0)
- {
- if (normal)
- printf_unfiltered ("Pseudo Denormal (0 as a double)");
- else if (mantissa_or == 0)
- printf_unfiltered ("%s0", sign);
- else
- printf_unfiltered ("Denormal (0 as a double)");
- }
- else if (exp == 0x7fff)
- {
- if (!normal)
- printf_unfiltered ("Pseudo ");
- if (mantissa_or == 0)
- printf_unfiltered ("%sInf", sign);
- else
- printf_unfiltered ("%s NaN",
- usregs[3] & 0x4000 ? "Quiet" : "Signaling");
- if (!normal)
- printf_unfiltered (" (NaN)");
- }
- else if (!normal)
- printf_unfiltered ("Unnormal (NaN)");
- else
- {
-#if 0
- /* Use this we stop trapping on overflow. */
- floatformat_to_double(&floatformat_i387_ext,
- (char *) ep->regs[st_regno], &val);
-#else
- i387_to_double((char *) ep->regs[st_regno], (char *) &val);
-#endif
- printf_unfiltered ("%g", val);
- }
- printf_unfiltered ("\n");
- }
-}
-
-void
-i386_float_info ()
-{
- struct user u; /* just for address computations */
- int i;
- /* fpstate defined in <sys/user.h> */
- struct fpstate *fpstatep;
- char buf[sizeof (struct fpstate) + 2 * sizeof (int)];
- unsigned int uaddr;
- char fpvalid;
- unsigned int rounded_addr;
- unsigned int rounded_size;
- /*extern int corechan;*/
- int skip;
- extern int inferior_pid;
-
- uaddr = (char *)&U_FPSTATE(u) - (char *)&u;
- if (inferior_pid)
- {
- int *ip;
-
- rounded_addr = uaddr & -sizeof (int);
- rounded_size = (((uaddr + sizeof (struct fpstate)) - uaddr) +
- sizeof (int) - 1) / sizeof (int);
- skip = uaddr - rounded_addr;
-
- ip = (int *)buf;
- for (i = 0; i < rounded_size; i++)
- {
- *ip++ = ptrace (PT_READ_U, inferior_pid, (caddr_t)rounded_addr, 0);
- rounded_addr += sizeof (int);
- }
- fpstatep = (struct fpstate *)(buf + skip);
- }
- else
- fpstatep = &pcb_savefpu;
-
- print_387_status (fpstatep->sv_ex_sw, (struct env387 *)fpstatep);
-}
-#endif /* FLOAT_INFO */
-
-int
-kernel_u_size ()
-{
- return (sizeof (struct user));
-}
-
-#ifdef SETUP_ARBITRARY_FRAME
-#include "frame.h"
-struct frame_info *
-setup_arbitrary_frame (argc, argv)
- int argc;
- CORE_ADDR *argv;
-{
- if (argc != 2)
- error ("i386 frame specifications require two arguments: sp and pc");
-
- return create_new_frame (argv[0], argv[1]);
-}
-#endif /* SETUP_ARBITRARY_FRAME */
-
-/* Register that we are able to handle aout (trad-core) file formats. */
-
-static struct core_fns aout_core_fns =
-{
- bfd_target_unknown_flavour,
- fetch_core_registers,
- NULL
-};
-
-void
-_initialize_core_aout ()
-{
- add_core_fns (&aout_core_fns);
-}
diff --git a/gnu/usr.bin/gdb/gdb/gdb.1 b/gnu/usr.bin/gdb/gdb/gdb.1
deleted file mode 100644
index f07c891..0000000
--- a/gnu/usr.bin/gdb/gdb/gdb.1
+++ /dev/null
@@ -1,385 +0,0 @@
-.\" Copyright (c) 1991 Free Software Foundation
-.\" See section COPYING for conditions for redistribution
-.\" $Id: gdb.1,v 1.3 1991/12/13 22:22:58 pesch Exp $
-.TH gdb 1 "4nov1991" "GNU Tools" "GNU Tools"
-.SH NAME
-gdb \- The GNU Debugger
-.SH SYNOPSIS
-.na
-.TP
-.B gdb
-.RB "[\|" \-help "\|]"
-.RB "[\|" \-nx "\|]"
-.RB "[\|" \-q "\|]"
-.RB "[\|" \-batch "\|]"
-.RB "[\|" \-cd=\c
-.I dir\c
-\|]
-.RB "[\|" \-f "\|]"
-.RB "[\|" \-k "\|]"
-.RB "[\|" \-wcore "\|]"
-.RB "[\|" "\-b\ "\c
-.IR bps "\|]"
-.RB "[\|" "\-tty="\c
-.IR dev "\|]"
-.RB "[\|" "\-s "\c
-.I symfile\c
-\&\|]
-.RB "[\|" "\-e "\c
-.I prog\c
-\&\|]
-.RB "[\|" "\-se "\c
-.I prog\c
-\&\|]
-.RB "[\|" "\-c "\c
-.I core\c
-\&\|]
-.RB "[\|" "\-x "\c
-.I cmds\c
-\&\|]
-.RB "[\|" "\-d "\c
-.I dir\c
-\&\|]
-.RB "[\|" \c
-.I prog\c
-.RB "[\|" \c
-.IR core \||\| procID\c
-\&\|]\&\|]
-.ad b
-.SH DESCRIPTION
-The purpose of a debugger such as GDB is to allow you to see what is
-going on ``inside'' another program while it executes\(em\&or what another
-program was doing at the moment it crashed.
-
-GDB can do four main kinds of things (plus other things in support of
-these) to help you catch bugs in the act:
-
-.TP
-\ \ \ \(bu
-Start your program, specifying anything that might affect its behavior.
-
-.TP
-\ \ \ \(bu
-Make your program stop on specified conditions.
-
-.TP
-\ \ \ \(bu
-Examine what has happened, when your program has stopped.
-
-.TP
-\ \ \ \(bu
-Change things in your program, so you can experiment with correcting the
-effects of one bug and go on to learn about another.
-.PP
-
-You can use GDB to debug programs written in C, C++, and Modula-2.
-Fortran support will be added when a GNU Fortran compiler is ready.
-
-GDB is invoked with the shell command \c
-.B gdb\c
-\&. Once started, it reads
-commands from the terminal until you tell it to exit with the GDB
-command \c
-.B quit\c
-\&. You can get online help from \c
-.B gdb\c
-\& itself
-by using the command \c
-.B help\c
-\&.
-
-You can run \c
-.B gdb\c
-\& with no arguments or options; but the most
-usual way to start GDB is with one argument or two, specifying an
-executable program as the argument:
-.sp
-.br
-gdb\ program
-.br
-.sp
-
-You can also start with both an executable program and a core file specified:
-.sp
-.br
-gdb\ program\ core
-.br
-.sp
-
-You can, instead, specify a process ID as a second argument, if you want
-to debug a running process:
-.sp
-.br
-gdb\ program\ 1234
-.br
-.sp
-
-would attach GDB to process \c
-.B 1234\c
-\& (unless you also have a file
-named `\|\c
-.B 1234\c
-\&\|'; GDB does check for a core file first).
-
-Here are some of the most frequently needed GDB commands:
-.TP
-.B break \fR[\|\fIfile\fB:\fR\|]\fIfunction
-\&
-Set a breakpoint at \c
-.I function\c
-\& (in \c
-.I file\c
-\&).
-.TP
-.B run \fR[\|\fIarglist\fR\|]
-Start your program (with \c
-.I arglist\c
-\&, if specified).
-.TP
-.B bt
-Backtrace: display the program stack.
-.TP
-.BI print " expr"\c
-\&
-Display the value of an expression.
-.TP
-.B c
-Continue running your program (after stopping, e.g. at a breakpoint).
-.TP
-.B next
-Execute next program line (after stopping); step \c
-.I over\c
-\& any
-function calls in the line.
-.TP
-.B step
-Execute next program line (after stopping); step \c
-.I into\c
-\& any
-function calls in the line.
-.TP
-.B help \fR[\|\fIname\fR\|]
-Show information about GDB command \c
-.I name\c
-\&, or general information
-about using GDB.
-.TP
-.B quit
-Exit from GDB.
-.PP
-For full details on GDB, see \c
-.I
-Using GDB: A Guide to the GNU Source-Level Debugger\c
-\&, by Richard M. Stallman and Roland H. Pesch. The same text is available online
-as the \c
-.B gdb\c
-\& entry in the \c
-.B info\c
-\& program.
-.SH OPTIONS
-Any arguments other than options specify an executable
-file and core file (or process ID); that is, the first argument
-encountered with no
-associated option flag is equivalent to a `\|\c
-.B \-se\c
-\&\|' option, and the
-second, if any, is equivalent to a `\|\c
-.B \-c\c
-\&\|' option if it's the name of a file. Many options have
-both long and short forms; both are shown here. The long forms are also
-recognized if you truncate them, so long as enough of the option is
-present to be unambiguous. (If you prefer, you can flag option
-arguments with `\|\c
-.B +\c
-\&\|' rather than `\|\c
-.B \-\c
-\&\|', though we illustrate the
-more usual convention.)
-
-All the options and command line arguments you give are processed
-in sequential order. The order makes a difference when the
-`\|\c
-.B \-x\c
-\&\|' option is used.
-
-.TP
-.B \-help
-.TP
-.B \-h
-List all options, with brief explanations.
-
-.TP
-.BI "\-symbols=" "file"\c
-.TP
-.BI "\-s " "file"\c
-\&
-Read symbol table from file \c
-.I file\c
-\&.
-
-.TP
-.BI "\-exec=" "file"\c
-.TP
-.BI "\-e " "file"\c
-\&
-Use file \c
-.I file\c
-\& as the executable file to execute when
-appropriate, and for examining pure data in conjunction with a core
-dump.
-
-.TP
-.BI "\-se=" "file"\c
-\&
-Read symbol table from file \c
-.I file\c
-\& and use it as the executable
-file.
-
-.TP
-.BI "\-core=" "file"\c
-.TP
-.BI "\-c " "file"\c
-\&
-Use file \c
-.I file\c
-\& as a core dump to examine.
-
-.TP
-.BI "\-command=" "file"\c
-.TP
-.BI "\-x " "file"\c
-\&
-Execute GDB commands from file \c
-.I file\c
-\&.
-
-.TP
-.BI "\-directory=" "directory"\c
-.TP
-.BI "\-d " "directory"\c
-\&
-Add \c
-.I directory\c
-\& to the path to search for source files.
-.PP
-
-.TP
-.B \-nx
-.TP
-.B \-n
-Do not execute commands from any `\|\c
-.B .gdbinit\c
-\&\|' initialization files.
-Normally, the commands in these files are executed after all the
-command options and arguments have been processed.
-
-
-.TP
-.B \-quiet
-.TP
-.B \-q
-``Quiet''. Do not print the introductory and copyright messages. These
-messages are also suppressed in batch mode.
-
-.TP
-.B \-batch
-Run in batch mode. Exit with status \c
-.B 0\c
-\& after processing all the command
-files specified with `\|\c
-.B \-x\c
-\&\|' (and `\|\c
-.B .gdbinit\c
-\&\|', if not inhibited).
-Exit with nonzero status if an error occurs in executing the GDB
-commands in the command files.
-
-Batch mode may be useful for running GDB as a filter, for example to
-download and run a program on another computer; in order to make this
-more useful, the message
-.sp
-.br
-Program\ exited\ normally.
-.br
-.sp
-
-(which is ordinarily issued whenever a program running under GDB control
-terminates) is not issued when running in batch mode.
-
-.TP
-.BI "\-cd=" "directory"\c
-\&
-Run GDB using \c
-.I directory\c
-\& as its working directory,
-instead of the current directory.
-
-.TP
-.B \-fullname
-.TP
-.B \-f
-Emacs sets this option when it runs GDB as a subprocess. It tells GDB
-to output the full file name and line number in a standard,
-recognizable fashion each time a stack frame is displayed (which
-includes each time the program stops). This recognizable format looks
-like two `\|\c
-.B \032\c
-\&\|' characters, followed by the file name, line number
-and character position separated by colons, and a newline. The
-Emacs-to-GDB interface program uses the two `\|\c
-.B \032\c
-\&\|' characters as
-a signal to display the source code for the frame.
-
-.TP
-.B \-kernel
-.TP
-.B \-k
-Use gdb in kernel debugging mode. The prompt is set to ``(kgdb)''.
-
-.TP
-.B \-wcore
-This option may only be used in kernel debugging mode while
-debugging a ``live'' kernel and makes the corefile (/dev/mem)
-writable.
-
-.TP
-.BI "\-b " "bps"\c
-\&
-Set the line speed (baud rate or bits per second) of any serial
-interface used by GDB for remote debugging.
-
-.TP
-.BI "\-tty=" "device"\c
-\&
-Run using \c
-.I device\c
-\& for your program's standard input and output.
-.PP
-
-.SH "SEE ALSO"
-.RB "`\|" gdb "\|'"
-entry in
-.B info\c
-\&;
-.I
-Using GDB: A Guide to the GNU Source-Level Debugger\c
-, Richard M. Stallman and Roland H. Pesch, July 1991.
-.SH COPYING
-Copyright (c) 1991 Free Software Foundation, Inc.
-.PP
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-.PP
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-.PP
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
diff --git a/gnu/usr.bin/gdb/gdb/i386freebsd.h b/gnu/usr.bin/gdb/gdb/i386freebsd.h
deleted file mode 100644
index af011311..0000000
--- a/gnu/usr.bin/gdb/gdb/i386freebsd.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Intel 386 running any FreeBSD Unix */
-
-#include <machine/param.h>
-#include <machine/vmparam.h>
-
-#define NBPG PAGE_SIZE
-#define HOST_PAGE_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_i386
-#define HOST_TEXT_START_ADDR USRTEXT
-
-/* Jolitz suggested defining HOST_STACK_END_ADDR to
- (u.u_kproc.kp_eproc.e_vm.vm_maxsaddr + MAXSSIZ), which should work on
- both BSDI and 386BSD, but that is believed not to work for BSD 4.4. */
-
-/* This seems to be the right thing for FreeBSD and BSDI */
-#define HOST_STACK_END_ADDR USRSTACK
-
-/* BSDI defines this too (PST) */
-#define HOST_DATA_START_ADDR ((bfd_vma)u.u_kproc.kp_eproc.e_vm.vm_daddr)
-
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
- ((core_bfd)->tdata.trad_core_data->u.u_sig)
-#define u_comm u_kproc.kp_proc.p_comm
diff --git a/gnu/usr.bin/gdb/gdb/kvm-fbsd.c b/gnu/usr.bin/gdb/gdb/kvm-fbsd.c
deleted file mode 100644
index 5f93334..0000000
--- a/gnu/usr.bin/gdb/gdb/kvm-fbsd.c
+++ /dev/null
@@ -1,970 +0,0 @@
-/* Live and postmortem kernel debugging functions for FreeBSD.
- Copyright 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/sysctl.h>
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include "frame.h" /* required by inferior.h */
-#include "inferior.h"
-#include "symtab.h"
-#include "command.h"
-#include "bfd.h"
-#include "target.h"
-#include "gdbcore.h"
-#include <sys/stat.h>
-#include <unistd.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-
-#include <machine/vmparam.h>
-#include <machine/pcb.h>
-#include <machine/tss.h>
-#include <machine/frame.h>
-
-static void kcore_files_info PARAMS ((struct target_ops *));
-
-static void kcore_close PARAMS ((int));
-
-static void get_kcore_registers PARAMS ((int));
-
-static int kcore_xfer_kmem PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
-
-static int xfer_umem PARAMS ((CORE_ADDR, char *, int, int));
-
-static CORE_ADDR ksym_lookup PARAMS ((const char *));
-
-static int read_pcb PARAMS ((int, CORE_ADDR));
-
-static struct proc * curProc PARAMS ((void));
-
-static int set_proc_context PARAMS ((CORE_ADDR paddr));
-
-static void kcore_open PARAMS ((char *filename, int from_tty));
-
-static void kcore_detach PARAMS ((char *args, int from_tty));
-
-static void set_proc_cmd PARAMS ((char *arg, int from_tty));
-
-static CORE_ADDR kvtophys PARAMS ((int, CORE_ADDR));
-
-static int physrd PARAMS ((int, u_int, char*, int));
-
-static int kvm_open PARAMS ((const char *efile, char *cfile, char *sfile,
- int perm, char *errout));
-
-static int kvm_close PARAMS ((int fd));
-
-static int kvm_write PARAMS ((int core_kd, CORE_ADDR memaddr,
- char *myaddr, int len));
-
-static int kvm_read PARAMS ((int core_kd, CORE_ADDR memaddr,
- char *myaddr, int len));
-
-static int kvm_uread PARAMS ((int core_kd, struct proc *p,
- CORE_ADDR memaddr, char *myaddr,
- int len));
-
-static int kernel_core_file_hook PARAMS ((int fd, CORE_ADDR addr,
- char *buf, int len));
-
-static struct kinfo_proc * kvm_getprocs PARAMS ((int cfd, int op,
- CORE_ADDR proc, int *cnt));
-
-extern struct target_ops kcore_ops; /* Forward decl */
-
-/* Non-zero means we are debugging a kernel core file */
-int kernel_debugging = 0;
-int kernel_writablecore = 0;
-
-static char *core_file;
-static int core_kd = -1;
-static struct proc *cur_proc;
-static CORE_ADDR kernel_start;
-
-/*
- * Read the "thing" at kernel address 'addr' into the space pointed to
- * by point. The length of the "thing" is determined by the type of p.
- * Result is non-zero if transfer fails.
- */
-#define kvread(addr, p) \
- (target_read_memory ((CORE_ADDR)(addr), (char *)(p), sizeof(*(p))))
-
-
-
-/*
- * The following is FreeBSD-specific hackery to decode special frames
- * and elide the assembly-language stub. This could be made faster by
- * defining a frame_type field in the machine-dependent frame information,
- * but we don't think that's too important right now.
- */
-enum frametype { tf_normal, tf_trap, tf_interrupt, tf_syscall };
-
-CORE_ADDR
-fbsd_kern_frame_saved_pc (fr)
-struct frame_info *fr;
-{
- struct minimal_symbol *sym;
- CORE_ADDR this_saved_pc;
- enum frametype frametype;
-
- this_saved_pc = read_memory_integer (fr->frame + 4, 4);
- sym = lookup_minimal_symbol_by_pc (this_saved_pc);
- frametype = tf_normal;
- if (sym != NULL) {
- if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0)
- frametype = tf_trap;
- else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0)
- frametype = tf_interrupt;
- else if (strcmp (SYMBOL_NAME(sym), "Xsyscall") == 0)
- frametype = tf_syscall;
- }
-
- switch (frametype) {
- case tf_normal:
- return (this_saved_pc);
-
-#define oEIP offsetof(struct trapframe, tf_eip)
-
- case tf_trap:
- return (read_memory_integer (fr->frame + 8 + oEIP, 4));
-
- case tf_interrupt:
- return (read_memory_integer (fr->frame + 16 + oEIP, 4));
-
- case tf_syscall:
- return (read_memory_integer (fr->frame + 8 + oEIP, 4));
-#undef oEIP
- }
-}
-
-CORE_ADDR
-fbsd_kern_frame_chain (fr)
-struct frame_info *fr;
-{
- struct minimal_symbol *sym;
- CORE_ADDR this_saved_pc;
- enum frametype frametype;
-
- this_saved_pc = read_memory_integer (fr->frame + 4, 4);
- sym = lookup_minimal_symbol_by_pc (this_saved_pc);
- frametype = tf_normal;
- if (sym != NULL) {
- if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0)
- frametype = tf_trap;
- else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0)
- frametype = tf_interrupt;
- else if (strcmp (SYMBOL_NAME(sym), "_Xsyscall") == 0)
- frametype = tf_syscall;
- }
-
- switch (frametype) {
- case tf_normal:
- return (read_memory_integer (fr->frame, 4));
-
-#define oEBP offsetof(struct trapframe, tf_ebp)
-
- case tf_trap:
- return (read_memory_integer (fr->frame + 8 + oEBP, 4));
-
- case tf_interrupt:
- return (read_memory_integer (fr->frame + 16 + oEBP, 4));
-
- case tf_syscall:
- return (read_memory_integer (fr->frame + 8 + oEBP, 4));
-#undef oEBP
- }
-}
-
-static CORE_ADDR
-ksym_lookup (name)
-const char *name;
-{
- struct minimal_symbol *sym;
-
- sym = lookup_minimal_symbol (name, NULL, NULL);
- if (sym == NULL)
- error ("kernel symbol `%s' not found.", name);
-
- return SYMBOL_VALUE_ADDRESS (sym);
-}
-
-static struct proc *
-curProc ()
-{
- struct proc *p;
- CORE_ADDR addr = ksym_lookup ("curproc");
-
- if (kvread (addr, &p))
- error ("cannot read proc pointer at %x\n", addr);
- return p;
-}
-
-/*
- * Set the process context to that of the proc structure at
- * system address paddr.
- */
-static int
-set_proc_context (paddr)
- CORE_ADDR paddr;
-{
- struct proc p;
-
- if (paddr < kernel_start)
- return (1);
-
- cur_proc = (struct proc *)paddr;
-#ifdef notyet
- set_kernel_boundaries (cur_proc);
-#endif
-
- /* Fetch all registers from core file */
- target_fetch_registers (-1);
-
- /* Now, set up the frame cache, and print the top of stack */
- flush_cached_frames ();
- set_current_frame (create_new_frame (read_fp (), read_pc ()));
- select_frame (get_current_frame (), 0);
- return (0);
-}
-
-/* Discard all vestiges of any previous core file
- and mark data and stack spaces as empty. */
-
-/* ARGSUSED */
-static void
-kcore_close (quitting)
- int quitting;
-{
- inferior_pid = 0; /* Avoid confusion from thread stuff */
-
- if (core_kd)
- {
- kvm_close (core_kd);
- free (core_file);
- core_file = NULL;
- core_kd = -1;
- }
-}
-
-/* This routine opens and sets up the core file bfd */
-
-static void
-kcore_open (filename, from_tty)
- char *filename;
- int from_tty;
-{
- const char *p;
- struct cleanup *old_chain;
- char buf[256], *cp;
- int ontop;
- CORE_ADDR addr;
- struct pcb pcb;
-
- target_preopen (from_tty);
-
- unpush_target (&kcore_ops);
-
- if (!filename)
- {
- /*error (core_kd?*/
- error ( (core_kd >= 0)?
- "No core file specified. (Use `detach' to stop debugging a core file.)"
- : "No core file specified.");
- }
-
- filename = tilde_expand (filename);
- if (filename[0] != '/')
- {
- cp = concat (current_directory, "/", filename, NULL);
- free (filename);
- filename = cp;
- }
-
- old_chain = make_cleanup (free, filename);
-
- /*
- * gdb doesn't really do anything if the exec-file couldn't
- * be opened (in that case exec_bfd is NULL). Usually that's
- * no big deal, but kvm_open needs the exec-file's name,
- * which results in dereferencing a NULL pointer, a real NO-NO !
- * So, check here if the open of the exec-file succeeded.
- */
- if (exec_bfd == NULL) /* the open failed */
- error ("kgdb could not open the exec-file, please check the name you used !");
-
- core_kd = kvm_open (exec_bfd->filename, filename, NULL,
- kernel_writablecore? O_RDWR : O_RDONLY, "kgdb: ");
- if (core_kd < 0)
- perror_with_name (filename);
-
- /* Looks semi-reasonable. Toss the old core file and work on the new. */
-
- discard_cleanups (old_chain); /* Don't free filename any more */
- core_file = filename;
- ontop = !push_target (&kcore_ops);
-
- kernel_start = bfd_get_start_address (exec_bfd); /* XXX */
-
- /* print out the panic string if there is one */
- if (kvread (ksym_lookup ("panicstr"), &addr) == 0
- && addr != 0
- && target_read_memory (addr, buf, sizeof (buf)) == 0)
- {
- for (cp = buf; cp < &buf[sizeof (buf)] && *cp; cp++)
- if (!isascii (*cp) || (!isprint (*cp) && !isspace (*cp)))
- *cp = '?';
- *cp = '\0';
- if (buf[0] != '\0')
- printf ("panicstr: %s\n", buf);
-
- printf ("panic messages:\n---\n");
- snprintf (buf, sizeof buf,
- "/sbin/dmesg -M %s | \
- /usr/bin/awk '/^(panic:|Fatal trap) / { printing = 1 } \
- { if (printing) print $0 }'",
- filename);
- system (buf);
- printf ("---\n");
- }
-
- if (!ontop)
- {
- warning ("you won't be able to access this core file until you terminate\n\
-your %s; do ``info files''", target_longname);
- return;
- }
-
- /* we may need this later */
- cur_proc = (struct proc *)curProc ();
- /* Now, set up the frame cache, and print the top of stack */
- flush_cached_frames ();
- set_current_frame (create_new_frame (read_fp (), read_pc ()));
- select_frame (get_current_frame (), 0);
- print_stack_frame (selected_frame, selected_frame_level, 1);
-}
-
-static void
-kcore_detach (args, from_tty)
- char *args;
- int from_tty;
-{
- if (args)
- error ("Too many arguments");
- unpush_target (&kcore_ops);
- reinit_frame_cache ();
- if (from_tty)
- printf_filtered ("No kernel core file now.\n");
-}
-
-/* Get the registers out of a core file. This is the machine-
- independent part. Fetch_core_registers is the machine-dependent
- part, typically implemented in the xm-file for each architecture. */
-
-/* We just get all the registers, so we don't use regno. */
-/* ARGSUSED */
-static void
-get_kcore_registers (regno)
- int regno;
-{
- struct user *uaddr;
-
- /* find the pcb for the current process */
- if (kvread (&cur_proc->p_addr, &uaddr))
- error ("cannot read u area ptr for proc at %#x", cur_proc);
- if (read_pcb (core_kd, (CORE_ADDR)&uaddr->u_pcb) < 0)
- error ("cannot read pcb at %#x", &uaddr->u_pcb);
-}
-
-static void
-kcore_files_info (t)
- struct target_ops *t;
-{
- printf ("\t`%s'\n", core_file);
-}
-
-static int
-kcore_xfer_kmem (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target;
-{
- int n;
-
- if (!memaddr)
- return (0);
-
- if (memaddr < kernel_start)
- return xfer_umem (memaddr, myaddr, len, write);
-
- n = write ?
- kvm_write (core_kd, memaddr, myaddr, len) :
- kvm_read (core_kd, memaddr, myaddr, len) ;
-
- if (n < 0)
- return 0;
- return n;
-}
-
-static int
-xfer_umem (memaddr, myaddr, len, write)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write; /* ignored */
-{
- int n;
- struct proc proc;
-
- if (kvread (cur_proc, &proc))
- error ("cannot read proc at %#x", cur_proc);
- n = kvm_uread (core_kd, &proc, memaddr, myaddr, len) ;
-
- if (n < 0)
- return 0;
- return n;
-}
-
-static void
-set_proc_cmd (arg, from_tty)
- char *arg;
- int from_tty;
-{
- CORE_ADDR paddr;
- struct kinfo_proc *kp;
- int cnt = 0;
-
- if (!arg)
- error_no_arg ("proc address for new current process");
- if (!kernel_debugging)
- error ("not debugging kernel");
-
- paddr = (CORE_ADDR)parse_and_eval_address (arg);
- /* assume it's a proc pointer if it's in the kernel */
- if (paddr >= kernel_start) {
- if (set_proc_context(paddr))
- error("invalid proc address");
- } else {
- kp = kvm_getprocs(core_kd, KERN_PROC_PID, paddr, &cnt);
- if (!cnt)
- error("invalid pid");
- if (set_proc_context((CORE_ADDR)kp->kp_eproc.e_paddr))
- error("invalid proc address");
- }
-}
-
-
-
-#define KERNOFF ((unsigned)KERNBASE)
-#define INKERNEL(x) ((x) >= KERNOFF)
-
-static CORE_ADDR sbr;
-static CORE_ADDR curpcb;
-static CORE_ADDR kstack;
-static int found_pcb;
-static int devmem;
-static int kfd;
-static struct pcb pcb;
-
-/* substitutes for the stuff in libkvm which doesn't work */
-/* most of this was taken from the old kgdb */
-
-/* we don't need all this stuff, but the call should look the same */
-
-static int
-kvm_open (efile, cfile, sfile, perm, errout)
- const char *efile;
- char *cfile;
- char *sfile; /* makes this kvm_open more compatible to the one in libkvm */
- int perm;
- char *errout; /* makes this kvm_open more compatible to the one in libkvm */
-{
- struct stat stb;
- CORE_ADDR addr;
- int cfd;
- struct i386tss cts;
-
- if ((cfd = open (cfile, perm, 0)) < 0)
- return (cfd);
-
- fstat (cfd, &stb);
- if ((stb.st_mode & S_IFMT) == S_IFCHR
- && stb.st_rdev == makedev (2, 0))
- {
- devmem = 1;
- kfd = open ("/dev/kmem", perm, 0);
- }
-
- physrd (cfd, ksym_lookup ("IdlePTD") - KERNOFF, (char*)&sbr, sizeof sbr);
- printf ("IdlePTD %x\n", sbr);
- curpcb = ksym_lookup ("curpcb") - KERNOFF;
- physrd (cfd, curpcb, (char*)&curpcb, sizeof curpcb);
- physrd (cfd, ksym_lookup ("common_tss") - KERNOFF, (char*)&cts, sizeof cts);
- kstack = cts.tss_ksp;
-
- found_pcb = 1; /* for vtophys */
- if (!devmem)
- read_pcb (cfd, ksym_lookup ("dumppcb") - KERNOFF);
- else
- read_pcb (cfd, kvtophys (cfd, kstack));
-
- return (cfd);
-}
-
-static int
-kvm_close (fd)
- int fd;
-{
- return (close (fd));
-}
-
-static int
-kvm_write (core_kd, memaddr, myaddr, len)
- int core_kd;
- CORE_ADDR memaddr;
- char *myaddr;
-{
- int cc;
-
- if (devmem)
- {
- if (kfd > 0)
- {
- /*
- * Just like kvm_read, only we write.
- */
- errno = 0;
- if (lseek (kfd, (off_t)memaddr, 0) < 0
- && errno != 0)
- {
- error ("kvm_write:invalid address (%x)", memaddr);
- return (0);
- }
- cc = write (kfd, myaddr, len);
- if (cc < 0)
- {
- error ("kvm_write:write failed");
- return (0);
- }
- else if (cc < len)
- error ("kvm_write:short write");
- return (cc);
- }
- else
- return (0);
- }
- else
- {
- printf ("kvm_write not implemented for dead kernels\n");
- return (0);
- }
- /* NOTREACHED */
-}
-
-static int
-kvm_read (core_kd, memaddr, myaddr, len)
- int core_kd;
- CORE_ADDR memaddr;
- char *myaddr;
-{
- return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
-}
-
-static int
-kvm_uread (core_kd, p, memaddr, myaddr, len)
- int core_kd;
- register struct proc *p;
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- register char *cp;
- char procfile[MAXPATHLEN];
- ssize_t amount;
- int fd;
-
- if (devmem)
- {
- cp = myaddr;
-
- sprintf (procfile, "/proc/%d/mem", p->p_pid);
- fd = open (procfile, O_RDONLY, 0);
-
- if (fd < 0)
- {
- error ("cannot open %s", procfile);
- close (fd);
- return (0);
- }
-
- while (len > 0)
- {
- if (lseek (fd, memaddr, 0) == -1 && errno != 0)
- {
- error ("invalid address (%x) in %s",
- memaddr, procfile);
- break;
- }
- amount = read (fd, cp, len);
- if (amount < 0)
- {
- error ("error reading %s", procfile);
- break;
- }
- cp += amount;
- memaddr += amount;
- len -= amount;
- }
-
- close (fd);
- return (ssize_t) (cp - myaddr);
- }
- else
- return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
-}
-
-static struct kinfo_proc kp;
-
-/*
- * try to do what kvm_proclist in libkvm would do
- */
-static int
-kvm_proclist (cfd, pid, p, cnt)
-int cfd, pid, *cnt;
-struct proc *p;
-{
- struct proc lp;
-
- for (; p != NULL; p = lp.p_list.le_next) {
- if (!kvm_read(cfd, (CORE_ADDR)p, (char *)&lp, sizeof (lp)))
- return (0);
- if (lp.p_pid != pid)
- continue;
- kp.kp_eproc.e_paddr = p;
- *cnt = 1;
- return (1);
- }
- *cnt = 0;
- return (0);
-}
-
-/*
- * try to do what kvm_deadprocs in libkvm would do
- */
-static struct kinfo_proc *
-kvm_deadprocs (cfd, pid, cnt)
-int cfd, pid, *cnt;
-{
- CORE_ADDR allproc, zombproc;
- struct proc *p;
-
- allproc = ksym_lookup("allproc");
- if (kvm_read(cfd, allproc, (char *)&p, sizeof (p)) == 0)
- return (NULL);
- kvm_proclist (cfd, pid, p, cnt);
- if (!*cnt) {
- zombproc = ksym_lookup("zombproc");
- if (kvm_read(cfd, zombproc, (char *)&p, sizeof (p)) == 0)
- return (NULL);
- kvm_proclist (cfd, pid, p, cnt);
- }
- return (&kp);
-}
-
-/*
- * try to do what kvm_getprocs in libkvm would do
- */
-static struct kinfo_proc *
-kvm_getprocs (cfd, op, proc, cnt)
-int cfd, op, *cnt;
-CORE_ADDR proc;
-{
- int mib[4], size;
-
- *cnt = 0;
- /* assume it's a pid */
- if (devmem) { /* "live" kernel, use sysctl */
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
- mib[2] = KERN_PROC_PID;
- mib[3] = (int)proc;
- size = sizeof (kp);
- if (sysctl (mib, 4, &kp, &size, NULL, 0) < 0) {
- perror("sysctl");
- *cnt = 0;
- return (NULL);
- }
- if (!size)
- *cnt = 0;
- else
- *cnt = 1;
- return (&kp);
- } else
- return (kvm_deadprocs (cfd, (int)proc, cnt));
-}
-
-static int
-physrd (cfd, addr, dat, len)
- int cfd;
- u_int addr;
- char *dat;
- int len;
-{
- if (lseek (cfd, (off_t)addr, L_SET) == -1)
- return (-1);
- return (read (cfd, dat, len));
-}
-
-static CORE_ADDR
-kvtophys (fd, addr)
- int fd;
- CORE_ADDR addr;
-{
- CORE_ADDR v;
- unsigned int pte;
- static CORE_ADDR PTD = -1;
- CORE_ADDR current_ptd;
-
- /*
- * If we're looking at the kernel stack,
- * munge the address to refer to the user space mapping instead;
- * that way we get the requested process's kstack, not the running one.
- */
- /*
- * this breaks xlating user addresses from a crash dump so only
- * do it for a "live" kernel.
- */
- if (devmem && addr >= kstack && addr < kstack + ctob (UPAGES))
- addr = (addr - kstack) + curpcb;
-
- /*
- * We may no longer have a linear system page table...
- *
- * Here's the scoop. IdlePTD contains the physical address
- * of a page table directory that always maps the kernel.
- * IdlePTD is in memory that is mapped 1-to-1, so we can
- * find it easily given its 'virtual' address from ksym_lookup().
- * For hysterical reasons, the value of IdlePTD is stored in sbr.
- *
- * To look up a kernel address, we first convert it to a 1st-level
- * address and look it up in IdlePTD. This gives us the physical
- * address of a page table page; we extract the 2nd-level part of
- * VA and read the 2nd-level pte. Finally, we add the offset part
- * of the VA into the physical address from the pte and return it.
- *
- * User addresses are a little more complicated. If we don't have
- * a current PCB from read_pcb(), we use PTD, which is the (fixed)
- * virtual address of the current ptd. Since it's NOT in 1-to-1
- * kernel space, we must look it up using IdlePTD. If we do have
- * a pcb, we get the ptd from pcb_ptd.
- */
-
- if (INKERNEL (addr))
- current_ptd = sbr;
- else if (found_pcb == 0)
- {
- if (PTD == -1)
- PTD = kvtophys (fd, ksym_lookup ("PTD"));
- current_ptd = PTD;
- }
- else
- current_ptd = pcb.pcb_cr3;
-
- /*
- * Read the first-level page table (ptd).
- */
- v = current_ptd + ( (unsigned)addr >> PDRSHIFT) * sizeof pte;
- if (physrd (fd, v, (char *)&pte, sizeof pte) < 0 || (pte&PG_V) == 0)
- return (~0);
-
- if (pte & PG_PS)
- {
- /*
- * No second-level page table; ptd describes one 4MB page.
- * (We assume that the kernel wouldn't set PG_PS without enabling
- * it cr0, and that the kernel doesn't support 36-bit physical
- * addresses).
- */
-#define PAGE4M_MASK (NBPDR - 1)
-#define PG_FRAME4M (~PAGE4M_MASK)
- addr = (pte & PG_FRAME4M) + (addr & PAGE4M_MASK);
- }
- else
- {
- /*
- * Read the second-level page table.
- */
- v = (pte&PG_FRAME) + ((addr >> PAGE_SHIFT)&(NPTEPG-1)) * sizeof pte;
- if (physrd (fd, v, (char *) &pte, sizeof (pte)) < 0 || (pte&PG_V) == 0)
- return (~0);
-
- addr = (pte & PG_FRAME) + (addr & PAGE_MASK);
- }
-#if 0
- printf ("vtophys (%x) -> %x\n", oldaddr, addr);
-#endif
- return (addr);
-}
-
-static int
-read_pcb (fd, uaddr)
- int fd;
- CORE_ADDR uaddr;
-{
- int i;
- int noreg;
- CORE_ADDR nuaddr = uaddr;
-
- /* need this for the `proc' command to work */
- if (INKERNEL(uaddr))
- nuaddr = kvtophys(fd, uaddr);
-
- if (physrd (fd, nuaddr, (char *)&pcb, sizeof pcb) < 0)
- {
- error ("cannot read pcb at %x\n", uaddr);
- return (-1);
- }
- printf ("current pcb at %x\n", uaddr);
-
- /*
- * get the register values out of the sys pcb and
- * store them where `read_register' will find them.
- */
- /*
- * XXX many registers aren't available.
- * XXX for the non-core case, the registers are stale - they are for
- * the last context switch to the debugger.
- * XXX gcc's register numbers aren't all #defined in tm-i386.h.
- */
- noreg = 0;
- for (i = 0; i < 3; ++i) /* eax,ecx,edx */
- supply_register (i, (char *)&noreg);
- supply_register (3, (char *)&pcb.pcb_ebx);
- supply_register (SP_REGNUM, (char *)&pcb.pcb_esp);
- supply_register (FP_REGNUM, (char *)&pcb.pcb_ebp);
- supply_register (6, (char *)&pcb.pcb_esi);
- supply_register (7, (char *)&pcb.pcb_edi);
- supply_register (PC_REGNUM, (char *)&pcb.pcb_eip);
- for (i = 9; i < 14; ++i) /* eflags, cs, ss, ds, es */
- supply_register (i, (char *)&noreg);
- supply_register (15, (char *)&pcb.pcb_fs);
- supply_register (16, (char *)&pcb.pcb_gs);
-
- /* XXX 80387 registers? */
-}
-
-/*
- * read len bytes from kernel virtual address 'addr' into local
- * buffer 'buf'. Return numbert of bytes if read ok, 0 otherwise. On read
- * errors, portion of buffer not read is zeroed.
- */
-
-static int
-kernel_core_file_hook (fd, addr, buf, len)
- int fd;
- CORE_ADDR addr;
- char *buf;
- int len;
-{
- int i;
- CORE_ADDR paddr;
- register char *cp;
- int cc;
-
- cp = buf;
-
- while (len > 0)
- {
- paddr = kvtophys (fd, addr);
- if (paddr == ~0)
- {
- memset (buf, '\000', len);
- break;
- }
- /* we can't read across a page boundary */
- i = min (len, PAGE_SIZE - (addr & PAGE_MASK));
- if ( (cc = physrd (fd, paddr, cp, i)) <= 0)
- {
- memset (cp, '\000', len);
- return (cp - buf);
- }
- cp += cc;
- addr += cc;
- len -= cc;
- }
- return (cp - buf);
-}
-
-struct target_ops kcore_ops = {
- "kcore", /* to_shortname */
- "Kernel core dump file", /* to_longname */
- "Use a core file as a target. Specify the filename of the core file.", /* to_doc */
- kcore_open, /* to_open */
- kcore_close, /* to_close */
- find_default_attach, /* to_attach */
- kcore_detach, /* to_detach */
- NULL, /* to_resume */
- NULL, /* to_wait */
- get_kcore_registers, /* to_fetch_registers */
- NULL, /* to_store_registers */
- NULL, /* to_prepare_to_store */
- kcore_xfer_kmem, /* to_xfer_memory */
- kcore_files_info, /* to_files_info */
- NULL, /* to_insert_breakpoint */
- NULL, /* to_remove_breakpoint */
- NULL, /* to_terminal_init */
- NULL, /* to_terminal_inferior */
- NULL, /* to_terminal_ours_for_output */
- NULL, /* to_terminal_ours */
- NULL, /* to_terminal_info */
- NULL, /* to_kill */
- NULL, /* to_load */
- NULL, /* to_lookup_symbol */
- find_default_create_inferior, /* to_create_inferior */
- NULL, /* to_mourn_inferior */
- 0, /* to_can_run */
- 0, /* to_notice_signals */
- NULL, /* to_thread_alive */
- 0, /* to_stop */
- kcore_stratum, /* to_stratum */
- NULL, /* to_next */
- 0, /* to_has_all_memory */
- 1, /* to_has_memory */
- 1, /* to_has_stack */
- 1, /* to_has_registers */
- 0, /* to_has_execution */
- NULL, /* sections */
- NULL, /* sections_end */
- OPS_MAGIC /* to_magic */
-};
-
-void
-_initialize_kcorelow()
-{
- add_target (&kcore_ops);
- add_com ("proc", class_obscure, set_proc_cmd, "Set current process context");
-}
diff --git a/gnu/usr.bin/gdb/gdb/nm.h b/gnu/usr.bin/gdb/gdb/nm.h
deleted file mode 100644
index 1edc1ce..0000000
--- a/gnu/usr.bin/gdb/gdb/nm.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Native-dependent definitions for Intel 386 running BSD Unix, for GDB.
- Copyright 1986, 1987, 1989, 1992, 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef NM_FBSD_H
-#define NM_FBSD_H
-
-#define ATTACH_DETACH
-
-/* Be shared lib aware */
-#include "solib.h"
-
-/* This is the amount to subtract from u.u_ar0
- to get the offset in the core file of the register values. */
-
-#include <machine/vmparam.h>
-#define KERNEL_U_ADDR USRSTACK
-
-#define REGISTER_U_ADDR(addr, blockend, regno) \
- (addr) = i386_register_u_addr ((blockend),(regno));
-
-/* We define our own fetch/store methods */
-#define FETCH_INFERIOR_REGISTERS
-
-extern int
-i386_register_u_addr PARAMS ((int, int));
-
-#define PTRACE_ARG3_TYPE char*
-
-/* make structure definitions match up with those expected in solib.c */
-#define link_object sod
-#define lo_name sod_name
-#define lo_library sod_library
-#define lo_unused sod_reserved
-#define lo_major sod_major
-#define lo_minor sod_minor
-#define lo_next sod_next
-
-#define link_map so_map
-#define lm_addr som_addr
-#define lm_name som_path
-#define lm_next som_next
-#define lm_lop som_sod
-#define lm_lob som_sodbase
-#define lm_rwt som_write
-#define lm_ld som_dynamic
-#define lm_lpd som_spd
-
-#define link_dynamic_2 section_dispatch_table
-#define ld_loaded sdt_loaded
-#define ld_need sdt_sods
-#define ld_rules sdt_filler1
-#define ld_got sdt_got
-#define ld_plt sdt_plt
-#define ld_rel sdt_rel
-#define ld_hash sdt_hash
-#define ld_stab sdt_nzlist
-#define ld_stab_hash sdt_filler2
-#define ld_buckets sdt_buckets
-#define ld_symbols sdt_strings
-#define ld_symb_size sdt_str_sz
-#define ld_text sdt_text_sz
-#define ld_plt_sz sdt_plt_sz
-
-#define rtc_symb rt_symbol
-#define rtc_sp rt_sp
-#define rtc_next rt_next
-
-#define ld_debug so_debug
-#define ldd_version dd_version
-#define ldd_in_debugger dd_in_debugger
-#define ldd_sym_loaded dd_sym_loaded
-#define ldd_bp_addr dd_bpt_addr
-#define ldd_bp_inst dd_bpt_shadow
-#define ldd_cp dd_cc
-
-#define link_dynamic _dynamic
-#define ld_version d_version
-#define ldd d_debug
-#define ld_un d_un
-#define ld_2 d_sdt
-
-/* Return sizeof user struct to callers in less machine dependent routines */
-
-#define KERNEL_U_SIZE kernel_u_size()
-extern int kernel_u_size PARAMS ((void));
-
-#define ADDITIONAL_OPTIONS \
- {"kernel", no_argument, &kernel_debugging, 1}, \
- {"k", no_argument, &kernel_debugging, 1}, \
- {"wcore", no_argument, &kernel_writablecore, 1}, \
- {"w", no_argument, &kernel_writablecore, 1},
-
-#define ADDITIONAL_OPTION_HELP \
- "\
- --kernel Enable kernel debugging.\n\
- --wcore Make core file writable (only works for /dev/mem).\n\
- This option only works while debugging a kernel !!\n\
-"
-
-extern int kernel_debugging;
-extern int kernel_writablecore;
-
-#define DEFAULT_PROMPT kernel_debugging?"(kgdb) ":"(gdb) "
-
-/* misuse START_PROGRESS to test whether we're running as kgdb */
-/* START_PROGRESS is called at the top of main */
-#undef START_PROGRESS
-#define START_PROGRESS(STR,N) \
- if (!strcmp(STR, "kgdb")) \
- kernel_debugging = 1;
-
-#endif /* NM_FBSD_H */
diff --git a/gnu/usr.bin/gdb/gdb/tm.h b/gnu/usr.bin/gdb/gdb/tm.h
deleted file mode 100644
index 5ad8e76..0000000
--- a/gnu/usr.bin/gdb/gdb/tm.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Macro definitions for x86 running under FreeBSD Unix.
- Copyright 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef TM_FBSD_H
-#define TM_FBSD_H 1
-
-#include "i386/tm-i386bsd.h"
-
-#undef NUM_REGS
-#define NUM_REGS 16
-
-extern struct frame_info *setup_arbitrary_frame PARAMS ((int, CORE_ADDR *));
-
-#define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
-
-extern void i386_float_info PARAMS ((void));
-
-#define FLOAT_INFO i386_float_info ()
-
-#define IN_SOLIB_CALL_TRAMPOLINE(pc, name) STREQ (name, "_DYNAMIC")
-
-/* FRAME_CHAIN takes a frame's nominal address and produces the frame's
- chain-pointer.
- In the case of the i386, the frame's nominal address
- is the address of a 4-byte word containing the calling frame's address. */
-
-extern CORE_ADDR fbsd_kern_frame_chain (struct frame_info *);
-#undef FRAME_CHAIN
-#define FRAME_CHAIN(thisframe) \
- (kernel_debugging ? fbsd_kern_frame_chain(thisframe) : \
- ((thisframe)->signal_handler_caller \
- ? (thisframe)->frame \
- : (!inside_entry_file ((thisframe)->pc) \
- ? read_memory_integer ((thisframe)->frame, 4) \
- : 0)))
-
-/* Saved Pc. Get it from sigcontext if within sigtramp. */
-
-extern CORE_ADDR fbsd_kern_frame_saved_pc (struct frame_info *);
-#undef FRAME_SAVED_PC
-#define FRAME_SAVED_PC(FRAME) \
- (kernel_debugging ? fbsd_kern_frame_saved_pc(FRAME) : \
- (((FRAME)->signal_handler_caller \
- ? sigtramp_saved_pc (FRAME) \
- : read_memory_integer ((FRAME)->frame + 4, 4)) \
- ))
-
-/* Sigtramp is not the same address as BSD/OS.. */
-#undef SIGTRAMP_START
-#undef SIGTRAMP_END
-#define SIGTRAMP_START 0xefbfdfc0
-#define SIGTRAMP_END 0xefbfe000
-
-#endif /* TM_FBSD_H */
diff --git a/gnu/usr.bin/gdb/gdb/version.c b/gnu/usr.bin/gdb/gdb/version.c
deleted file mode 100644
index 3d677fe..0000000
--- a/gnu/usr.bin/gdb/gdb/version.c
+++ /dev/null
@@ -1,3 +0,0 @@
-char *version = "4.16";
-char *host_name = "i386-unknown-freebsd";
-char *target_name = "i386-unknown-freebsd";
diff --git a/gnu/usr.bin/gdb/gdb/xm.h b/gnu/usr.bin/gdb/gdb/xm.h
deleted file mode 100644
index 8a852a2..0000000
--- a/gnu/usr.bin/gdb/gdb/xm.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Host-dependent definitions for Intel 386 running BSD Unix, for GDB.
- Copyright 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define HOST_BYTE_ORDER LITTLE_ENDIAN
-
-#include <machine/limits.h> /* for INT_MIN, to avoid "INT_MIN
- redefined" warnings from defs.h */
diff --git a/gnu/usr.bin/gdb/gdbreplay/Makefile b/gnu/usr.bin/gdb/gdbreplay/Makefile
deleted file mode 100644
index a7b6f51..0000000
--- a/gnu/usr.bin/gdb/gdbreplay/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id: Makefile,v 1.1.1.1 1997/04/25 22:25:22 pst Exp $
-
-GDBDIR= ${.CURDIR}/../../../../contrib/gdb
-.PATH: ${GDBDIR}/gdb/gdbserver
-.PATH: ${GDBDIR}/gdb
-.PATH: ${GDBDIR}/opcodes
-
-PROG= gdbreplay
-BINDIR= /usr/bin
-NOMAN= yes
-
-SRCS= gdbreplay.c
-
-CFLAGS+=-I${.CURDIR}/../gdb -I${.CURDIR}/../bfd
-CFLAGS+=-DNO_MMALLOC
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/gdb/gdbserver/Makefile b/gnu/usr.bin/gdb/gdbserver/Makefile
deleted file mode 100644
index 73abac8..0000000
--- a/gnu/usr.bin/gdb/gdbserver/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id: Makefile,v 1.1.1.1 1997/04/25 22:25:50 pst Exp $
-
-GDBDIR= ${.CURDIR}/../../../../contrib/gdb
-.PATH: ${GDBDIR}/gdb/gdbserver
-.PATH: ${GDBDIR}/gdb
-.PATH: ${GDBDIR}/opcodes
-
-PROG= gdbserver
-BINDIR= /usr/bin
-
-SRCS= remote-utils.c utils.c server.c
-SRCS+= low-fbsd.c
-
-CFLAGS+=-I${.CURDIR}/../gdb -I${.CURDIR}/../bfd
-CFLAGS+=-DNO_MMALLOC
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/gdb/gdbserver/low-fbsd.c b/gnu/usr.bin/gdb/gdbserver/low-fbsd.c
deleted file mode 100644
index bc85f36..0000000
--- a/gnu/usr.bin/gdb/gdbserver/low-fbsd.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/* Low level interface to ptrace, for the remote server for GDB.
- Copyright (C) 1995 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include <sys/wait.h>
-#include "frame.h"
-#include "inferior.h"
-
-#include <stdio.h>
-#include <sys/param.h>
-#include <dirent.h>
-#include <sys/user.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <sgtty.h>
-#include <fcntl.h>
-
-/***************Begin MY defs*********************/
-int quit_flag = 0;
-char registers[REGISTER_BYTES];
-
-/* Index within `registers' of the first byte of the space for
- register N. */
-
-
-char buf2[MAX_REGISTER_RAW_SIZE];
-/***************End MY defs*********************/
-
-#include <sys/ptrace.h>
-#include <machine/reg.h>
-
-extern char **environ;
-extern int inferior_pid;
-void quit (), perror_with_name ();
-int query ();
-
-/* Start an inferior process and returns its pid.
- ALLARGS is a vector of program-name and args.
- ENV is the environment vector to pass. */
-
-int
-create_inferior (program, allargs)
- char *program;
- char **allargs;
-{
- int pid;
-
- pid = fork ();
- if (pid < 0)
- perror_with_name ("fork");
-
- if (pid == 0)
- {
- ptrace (PT_TRACE_ME, 0, 0, 0);
-
- execv (program, allargs);
-
- fprintf (stderr, "Cannot exec %s: %s.\n", program, strerror(errno));
- fflush (stderr);
- _exit (0177);
- }
-
- return pid;
-}
-
-/* Kill the inferior process. Make us have no inferior. */
-
-void
-kill_inferior ()
-{
- if (inferior_pid == 0)
- return;
- ptrace (PT_KILL, inferior_pid, 0, 0);
- wait (0);
- /*************inferior_died ();****VK**************/
-}
-
-/* Return nonzero if the given thread is still alive. */
-int
-mythread_alive (pid)
- int pid;
-{
- return 1;
-}
-
-/* Wait for process, returns status */
-
-unsigned char
-mywait (status)
- char *status;
-{
- int pid;
- int w;
-
- pid = wait (&w);
- if (pid != inferior_pid)
- perror_with_name ("wait");
-
- if (WIFEXITED (w))
- {
- fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w));
- *status = 'W';
- return ((unsigned char) WEXITSTATUS (w));
- }
- else if (!WIFSTOPPED (w))
- {
- fprintf (stderr, "\nChild terminated with signal = %x \n", WTERMSIG (w));
- *status = 'X';
- return ((unsigned char) WTERMSIG (w));
- }
-
- fetch_inferior_registers (0);
-
- *status = 'T';
- return ((unsigned char) WSTOPSIG (w));
-}
-
-/* Resume execution of the inferior process.
- If STEP is nonzero, single-step it.
- If SIGNAL is nonzero, give it that signal. */
-
-void
-myresume (step, signal)
- int step;
- int signal;
-{
- errno = 0;
- ptrace (step ? PT_STEP : PT_CONTINUE, inferior_pid,
- (PTRACE_ARG3_TYPE) 1, signal);
- if (errno)
- perror_with_name ("ptrace");
-}
-
-
-#if !defined (offsetof)
-#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
-#endif
-
-/* U_REGS_OFFSET is the offset of the registers within the u area. */
-#if !defined (U_REGS_OFFSET)
-#define U_REGS_OFFSET \
- ptrace (PT_READ_U, inferior_pid, \
- (PTRACE_ARG3_TYPE) (offsetof (struct user, u_ar0)), 0) \
- - KERNEL_U_ADDR
-#endif
-
-unsigned int
-register_addr (regno, blockend)
- int regno;
- int blockend;
-{
- int addr;
-
- if (regno < 0 || regno >= ARCH_NUM_REGS)
- error ("Invalid register number %d.", regno);
-
- REGISTER_U_ADDR (addr, blockend, regno);
-
- return addr;
-}
-
-/* Fetch one register. */
-
-static void
-fetch_register (regno)
- int regno;
-{
- register unsigned int regaddr;
- char buf[MAX_REGISTER_RAW_SIZE];
- register int i;
-
- /* Offset of registers within the u area. */
- unsigned int offset;
-
- offset = U_REGS_OFFSET;
-
- regaddr = register_addr (regno, offset);
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
- {
- errno = 0;
- *(int *) &registers[ regno * sizeof(int) + i] =
- ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, 0);
- regaddr += sizeof (int);
- if (errno != 0)
- {
- /* Warning, not error, in case we are attached; sometimes the
- kernel doesn't let us at the registers. */
- char *err = strerror (errno);
- char *msg = alloca (strlen (err) + 128);
- sprintf (msg, "reading register %d: %s", regno, err);
- error (msg);
- goto error_exit;
- }
- }
- error_exit:;
-}
-
-/* Fetch all registers, or just one, from the child process. */
-
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- if (regno == -1 || regno == 0)
- for (regno = 0; regno < NUM_REGS; regno++)
- fetch_register (regno);
- else
- fetch_register (regno);
-}
-
-/* Store our register values back into the inferior.
- If REGNO is -1, do this for all registers.
- Otherwise, REGNO specifies which register (so we can save time). */
-
-void
-store_inferior_registers (regno)
- int regno;
-{
- register unsigned int regaddr;
- char buf[80];
- extern char registers[];
- register int i;
- unsigned int offset = U_REGS_OFFSET;
- int scratch;
-
- if (regno >= 0)
- {
- regaddr = register_addr (regno, offset);
- errno = 0;
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int))
- {
- errno = 0;
- ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
- *(int *) &registers[REGISTER_BYTE (regno) + i]);
- if (errno != 0)
- {
- /* Warning, not error, in case we are attached; sometimes the
- kernel doesn't let us at the registers. */
- char *err = strerror (errno);
- char *msg = alloca (strlen (err) + 128);
- sprintf (msg, "writing register %d: %s",
- regno, err);
- error (msg);
- return;
- }
- regaddr += sizeof(int);
- }
- }
- else
- for (regno = 0; regno < NUM_REGS; regno++)
- store_inferior_registers (regno);
-}
-
-/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory
- in the NEW_SUN_PTRACE case.
- It ought to be straightforward. But it appears that writing did
- not write the data that I specified. I cannot understand where
- it got the data that it actually did write. */
-
-/* Copy LEN bytes from inferior's memory starting at MEMADDR
- to debugger memory starting at MYADDR. */
-
-read_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- register int i;
- /* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr & -sizeof (int);
- /* Round ending address up; get number of longwords that makes. */
- register int count
- = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
- /* Allocate buffer of that many longwords. */
- register int *buffer = (int *) alloca (count * sizeof (int));
-
- /* Read all the longwords */
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- buffer[i] = ptrace (PT_READ_I, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
- }
-
- /* Copy appropriate bytes out of the buffer. */
- memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
-}
-
-/* Copy LEN bytes of data from debugger memory at MYADDR
- to inferior's memory at MEMADDR.
- On failure (cannot write the inferior)
- returns the value of errno. */
-
-int
-write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- register int i;
- /* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr & -sizeof (int);
- /* Round ending address up; get number of longwords that makes. */
- register int count
- = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
- /* Allocate buffer of that many longwords. */
- register int *buffer = (int *) alloca (count * sizeof (int));
- extern int errno;
-
- /* Fill start and end extra bytes of buffer with existing memory data. */
-
- buffer[0] = ptrace (PT_READ_I, inferior_pid,
- (PTRACE_ARG3_TYPE) addr, 0);
-
- if (count > 1)
- {
- buffer[count - 1]
- = ptrace (PT_READ_I, inferior_pid,
- (PTRACE_ARG3_TYPE) addr + (count - 1) * sizeof (int), 0);
- }
-
- /* Copy data to be written over corresponding part of buffer */
-
- memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
-
- /* Write the entire buffer. */
-
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- errno = 0;
- ptrace (PT_WRITE_I, inferior_pid, (PTRACE_ARG3_TYPE) addr, buffer[i]);
- if (errno)
- return errno;
- }
-
- return 0;
-}
-
-void
-initialize ()
-{
- inferior_pid = 0;
-}
-
-int
-have_inferior_p ()
-{
- return inferior_pid != 0;
-}
-
-/* Some systems don't provide all the registers on a trap. Use SS as a
- default if so. */
-
-#ifndef tDS
-#define tDS tSS
-#endif
-#ifndef tES
-#define tES tSS
-#endif
-#ifndef tFS
-#define tFS tSS
-#endif
-#ifndef tGS
-#define tGS tSS
-#endif
-
-/* These tables map between the registers on a trap frame, and the register
- order used by the rest of GDB. */
-/* this table must line up with REGISTER_NAMES in tm-i386.h */
-/* symbols like 'tEAX' come from <machine/reg.h> */
-static int tregmap[] =
-{
- tEAX, tECX, tEDX, tEBX,
- tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS,
- tDS, tES, tFS, tGS
-};
-
-#ifdef sEAX
-static int sregmap[] =
-{
- sEAX, sECX, sEDX, sEBX,
- sESP, sEBP, sESI, sEDI,
- sEIP, sEFLAGS, sCS, sSS
-};
-#else /* No sEAX */
-
-/* FreeBSD has decided to collapse the s* and t* symbols. So if the s*
- ones aren't around, use the t* ones for sregmap too. */
-
-static int sregmap[] =
-{
- tEAX, tECX, tEDX, tEBX,
- tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS,
- tDS, tES, tFS, tGS
-};
-#endif /* No sEAX */
-
-/* blockend is the value of u.u_ar0, and points to the
- place where ES is stored. */
-
-int
-i386_register_u_addr (blockend, regnum)
- int blockend;
- int regnum;
-{
- /* The following condition is a kludge to get at the proper register map
- depending upon the state of pcb_flag.
- The proper condition would be
- if (u.u_pcb.pcb_flag & FM_TRAP)
- but that would require a ptrace call here and wouldn't work
- for corefiles. */
-
- if (blockend < 0x1fcc)
- return (blockend + 4 * tregmap[regnum]);
- else
- return (blockend + 4 * sregmap[regnum]);
-}
diff --git a/gnu/usr.bin/gdb/libiberty/Makefile b/gnu/usr.bin/gdb/libiberty/Makefile
deleted file mode 100644
index 25de36c..0000000
--- a/gnu/usr.bin/gdb/libiberty/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-LIB= iberty
-INTERNALLIB= true
-INTERNALSTATICLIB= true
-
-GDBDIR= ${.CURDIR}/../../../../contrib/gdb
-.PATH: ${GDBDIR}/libiberty
-
-SRCS= argv.c basename.c concat.c cplus-dem.c fdmatch.c getopt.c \
- getopt1.c getruntime.c hex.c floatformat.c obstack.c spaces.c \
- strsignal.c xatexit.c xexit.c \
- xmalloc.c xstrdup.c xstrerror.c insque.c
-
-CFLAGS+= -I$(.CURDIR) -I$(.CURDIR)/../gdb/.
-
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/gdb/libiberty/alloca-conf.h b/gnu/usr.bin/gdb/libiberty/alloca-conf.h
deleted file mode 100644
index 8d91b5a..0000000
--- a/gnu/usr.bin/gdb/libiberty/alloca-conf.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* "Normal" configuration for alloca. */
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not __GNUC__ */
-#ifdef sparc
-#include <alloca.h>
-extern char *__builtin_alloca(); /* Stupid include file doesn't declare it */
-#else
-#ifdef __STDC__
-PTR alloca (size_t);
-#else
-PTR alloca (); /* must agree with functions.def */
-#endif
-#endif /* sparc */
-#endif /* not __GNUC__ */
diff --git a/gnu/usr.bin/gdb/libiberty/config.h b/gnu/usr.bin/gdb/libiberty/config.h
deleted file mode 100644
index cff00a8..0000000
--- a/gnu/usr.bin/gdb/libiberty/config.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* !Automatically generated from ./functions.def - DO NOT EDIT! */
-#ifndef NEED_basename
-#define NEED_basename
-#endif
-#ifndef NEED_on_exit
-#define NEED_on_exit
-#endif
diff --git a/gnu/usr.bin/genclass/Makefile b/gnu/usr.bin/genclass/Makefile
deleted file mode 100644
index 93924ef..0000000
--- a/gnu/usr.bin/genclass/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# $Id: Makefile,v 1.4 1997/02/22 15:45:31 peter Exp $
-#
-
-GPPDIR= ${.CURDIR}/../../../contrib/libg++
-MAN1= genclass.1
-
-.PATH: ${GPPDIR}/libg++/src ${GPPDIR}/libg++/genclass
-
-all: genclass
-
-CLEANFILES+= genclass
-
-PROTODIR= /usr/share/libg++
-VERSION!= sed -n -e '/^VERSION/s/VERSION *= *\(.*\)/\1/p' \
- < ${GPPDIR}/libg++/Makefile.in
-
-#genclass prototypes
-GEN= AVLMap.ccP AVLMap.hP AVLSet.ccP AVLSet.hP AVec.ccP AVec.hP \
- BSTSet.ccP BSTSet.hP Bag.ccP Bag.hP CHBag.ccP CHBag.hP \
- CHMap.ccP CHMap.hP CHNode.ccP CHNode.hP CHSet.ccP CHSet.hP \
- DLDeque.ccP DLDeque.hP DLList.ccP DLList.hP Deque.ccP Deque.hP \
- FPQueue.ccP FPQueue.hP FPStack.ccP FPStack.hP FPlex.ccP FPlex.hP \
- List.ccP List.hP MPlex.ccP MPlex.hP Map.ccP Map.hP \
- OSLBag.ccP OSLBag.hP OSLSet.ccP OSLSet.hP OXPBag.ccP OXPBag.hP \
- OXPSet.ccP OXPSet.hP PHPQ.ccP PHPQ.hP PQ.ccP PQ.hP \
- PSList.hP PVec.hP Plex.ccP Plex.hP Queue.ccP Queue.hP \
- RAVLMap.ccP RAVLMap.hP RPlex.ccP RPlex.hP SLBag.ccP SLBag.hP \
- SLList.ccP SLList.hP SLQueue.ccP SLQueue.hP SLSet.ccP SLSet.hP \
- SLStack.ccP SLStack.hP Set.ccP Set.hP SkipBag.ccP SkipBag.hP \
- SkipMap.ccP SkipMap.hP SkipSet.ccP SkipSet.hP SplayBag.ccP SplayBag.hP \
- SplayMap.ccP SplayMap.hP SplayNode.ccP SplayNode.hP \
- SplayPQ.ccP SplayPQ.hP SplaySet.ccP SplaySet.hP Stack.ccP Stack.hP \
- VHBag.ccP VHBag.hP VHMap.ccP VHMap.hP VHSet.ccP VHSet.hP \
- VOHSet.ccP VOHSet.hP VQueue.ccP VQueue.hP VStack.ccP VStack.hP \
- Vec.ccP Vec.hP XPBag.ccP XPBag.hP XPDeque.ccP XPDeque.hP \
- XPPQ.ccP XPPQ.hP XPQueue.ccP XPQueue.hP XPSet.ccP XPSet.hP \
- XPStack.ccP XPStack.hP XPlex.ccP XPlex.hP \
- defs.hP intSList.hP intVec.hP
-
-
-genclass: genclass.sh
- sed -e 's@^PROTODIR=.*$$@PROTODIR=$$\{PROTODIR-${PROTODIR}\}@' \
- -e 's/<VERSION>/${VERSION}/' < ${.ALLSRC} > genclass
-
-beforeinstall:
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${GEN:S;^;${GPPDIR}/libg++/src/gen/;} \
- ${DESTDIR}${PROTODIR}
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} genclass \
- ${DESTDIR}${BINDIR}
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/gperf/Makefile b/gnu/usr.bin/gperf/Makefile
deleted file mode 100644
index 55c9e84..0000000
--- a/gnu/usr.bin/gperf/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# $Id$
-
-.PATH: ${.CURDIR}/../../../contrib/gperf
-.PATH: ${.CURDIR}/../../../contrib/gperf/src
-
-SUBDIR= doc
-
-PROG= gperf
-MAN1= gperf.1
-
-CFLAGS+= -D_HAVE_PARAM_H -DLO_CAL -DGATHER_STATISTICS #-DRLIMIT_STACK
-
-SRCS = options.c iterator.c main.c perfect.c keylist.c listnode.c xmalloc.c \
- hashtable.c boolarray.c readline.c stderr.c version.c getopt.c
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/gperf/doc/Makefile b/gnu/usr.bin/gperf/doc/Makefile
deleted file mode 100644
index e9ac21d..0000000
--- a/gnu/usr.bin/gperf/doc/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Id$
-
-INFO = gperf
-INFOSECTION= "Programming & development tools."
-INFOENTRY_gperf= "* Gperf: (gperf). The GNU perfect hash function generator."
-
-SRCDIR= ${.CURDIR}/../../../../contrib/gperf
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/grep/AUTHORS b/gnu/usr.bin/grep/AUTHORS
deleted file mode 100644
index e3e033b..0000000
--- a/gnu/usr.bin/grep/AUTHORS
+++ /dev/null
@@ -1,29 +0,0 @@
-Mike Haertel wrote the main program and the dfa and kwset matchers.
-
-Arthur David Olson contributed the heuristics for finding fixed substrings
-at the end of dfa.c.
-
-Richard Stallman and Karl Berry wrote the regex backtracking matcher.
-
-Henry Spencer wrote the original test suite from which grep's was derived.
-
-Scott Anderson invented the Khadafy test.
-
-David MacKenzie wrote the automatic configuration software use to
-produce the configure script.
-
-Authors of the replacements for standard library routines are identified
-in the corresponding source files.
-
-The idea of using Boyer-Moore type algorithms to quickly filter out
-non-matching text before calling the regexp matcher was originally due
-to James Woods. He also contributed some code to early versions of
-GNU grep.
-
-Finally, I would like to thank Andrew Hume for many fascinating discussions
-of string searching issues over the years. Hume & Sunday's excellent
-paper on fast string searching (AT&T Bell Laboratories CSTR #156)
-describes some of the history of the subject, as well as providing
-exhaustive performance analysis of various implementation alternatives.
-The inner loop of GNU grep is similar to Hume & Sunday's recommended
-"Tuned Boyer Moore" inner loop.
diff --git a/gnu/usr.bin/grep/COPYING b/gnu/usr.bin/grep/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/grep/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/grep/Makefile b/gnu/usr.bin/grep/Makefile
deleted file mode 100644
index a6ab6a1..0000000
--- a/gnu/usr.bin/grep/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-# $Id: Makefile,v 1.10 1997/12/20 18:46:06 wosch Exp $
-
-CFLAGS=-g
-GREP_LIBZ= YES
-GREP_FTS= YES
-
-PROG= grep
-SRCS= dfa.c grep.c getopt.c kwset.c obstack.c search.c
-CFLAGS+=-DGREP -DHAVE_STRING_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_UNISTD_H=1 \
- -DHAVE_GETPAGESIZE=1 -DHAVE_MEMCHR=1 -DHAVE_STRERROR=1 \
- -DHAVE_VALLOC=1
-
-LINKS+= ${BINDIR}/grep ${BINDIR}/egrep \
- ${BINDIR}/grep ${BINDIR}/fgrep
-MLINKS= grep.1 egrep.1 grep.1 fgrep.1
-
-DPADD+= ${LIBGNUREGEX}
-LDADD+= -lgnuregex
-
-.if defined(GREP_LIBZ) && !empty(GREP_LIBZ)
-LDADD+= -lz
-DPADD+= ${LIBZ}
-CFLAGS+= -DHAVE_LIBZ=1
-LINKS+= ${BINDIR}/grep ${BINDIR}/zgrep \
- ${BINDIR}/grep ${BINDIR}/zegrep \
- ${BINDIR}/grep ${BINDIR}/zfgrep
-.endif
-.if defined(GREP_FTS) && !empty(GREP_FTS)
-CFLAGS+= -DHAVE_FTS=1
-.endif
-
-check: all
- sh ${.CURDIR}/tests/check.sh ${.CURDIR}/tests
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/grep/NEWS b/gnu/usr.bin/grep/NEWS
deleted file mode 100644
index eb0b513..0000000
--- a/gnu/usr.bin/grep/NEWS
+++ /dev/null
@@ -1,35 +0,0 @@
-Version 2.0:
-
-The most important user visible change is that egrep and fgrep have
-disappeared as separate programs into the single grep program mandated
-by POSIX 1003.2. New options -G, -E, and -F have been added,
-selecting grep, egrep, and fgrep behavior respectively. For
-compatibility with historical practice, hard links named egrep and
-fgrep are also provided. See the manual page for details.
-
-In addition, the regular expression facilities described in Posix
-draft 11.2 are now supported, except for internationalization features
-related to locale-dependent collating sequence information.
-
-There is a new option, -L, which is like -l except it lists
-files which don't contain matches. The reason this option was
-added is because '-l -v' doesn't do what you expect.
-
-Performance has been improved; the amount of improvement is platform
-dependent, but (for example) grep 2.0 typically runs at least 30% faster
-than grep 1.6 on a DECstation using the MIPS compiler. Where possible,
-grep now uses mmap() for file input; on a Sun 4 running SunOS 4.1 this
-may cut system time by as much as half, for a total reduction in running
-time by nearly 50%. On machines that don't use mmap(), the buffering
-code has been rewritten to choose more favorable alignments and buffer
-sizes for read().
-
-Portability has been substantially cleaned up, and an automatic
-configure script is now provided.
-
-The internals have changed in ways too numerous to mention.
-People brave enough to reuse the DFA matcher in other programs
-will now have their bravery amply "rewarded", for the interface
-to that file has been completely changed. Some changes were
-necessary to track the evolution of the regex package, and since
-I was changing it anyway I decided to do a general cleanup.
diff --git a/gnu/usr.bin/grep/PROJECTS b/gnu/usr.bin/grep/PROJECTS
deleted file mode 100644
index 67e9a2a..0000000
--- a/gnu/usr.bin/grep/PROJECTS
+++ /dev/null
@@ -1,15 +0,0 @@
-Write Texinfo documentation for grep. The manual page would be a good
-place to start, but Info documents are also supposed to contain a
-tutorial and examples.
-
-Fix the DFA matcher to never use exponential space. (Fortunately, these
-cases are rare.)
-
-Improve the performance of the regex backtracking matcher. This matcher
-is agonizingly slow, and is responsible for grep sometimes being slower
-than Unix grep when backreferences are used.
-
-Provide support for the Posix [= =] and [. .] constructs. This is
-difficult because it requires locale-dependent details of the character
-set and collating sequence, but Posix does not standardize any method
-for accessing this information!
diff --git a/gnu/usr.bin/grep/README b/gnu/usr.bin/grep/README
deleted file mode 100644
index bc34a85..0000000
--- a/gnu/usr.bin/grep/README
+++ /dev/null
@@ -1,28 +0,0 @@
-This is GNU grep 2.0, the "fastest grep in the west" (we hope). All
-bugs reported in previous releases have been fixed. Many exciting new
-bugs have probably been introduced in this major revision.
-
-GNU grep is provided "as is" with no warranty. The exact terms
-under which you may use and (re)distribute this program are detailed
-in the GNU General Public License, in the file COPYING.
-
-GNU grep is based on a fast lazy-state deterministic matcher (about
-twice as fast as stock Unix egrep) hybridized with a Boyer-Moore-Gosper
-search for a fixed string that eliminates impossible text from being
-considered by the full regexp matcher without necessarily having to
-look at every character. The result is typically many times faster
-than Unix grep or egrep. (Regular expressions containing backreferencing
-will run more slowly, however.)
-
-See the file AUTHORS for a list of authors and other contributors.
-
-See the file INSTALL for compilation and installation instructions.
-
-See the file MANIFEST for a list of files in this distribution.
-
-See the file NEWS for a description of major changes in this release.
-
-See the file PROJECTS if you want to be mentioned in AUTHORS.
-
-Send bug reports to bug-gnu-utils@prep.ai.mit.edu. Be sure to
-include the word "grep" in your Subject: header field.
diff --git a/gnu/usr.bin/grep/dfa.c b/gnu/usr.bin/grep/dfa.c
deleted file mode 100644
index 4b9eb2e..0000000
--- a/gnu/usr.bin/grep/dfa.c
+++ /dev/null
@@ -1,2550 +0,0 @@
-/* dfa.c - deterministic extended regexp routines for GNU
- Copyright (C) 1988 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. */
-
-/* Written June, 1988 by Mike Haertel
- Modified July, 1988 by Arthur David Olson to assist BMG speedups */
-
-#include <assert.h>
-#include <ctype.h>
-#include <stdio.h>
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-#include <sys/types.h>
-extern char *calloc(), *malloc(), *realloc();
-extern void free();
-#endif
-
-#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
-#include <string.h>
-#undef index
-#define index strchr
-#else
-#include <strings.h>
-#endif
-
-#ifndef isgraph
-#define isgraph(C) (isprint((unsigned char)C) && !isspace((unsigned char)C))
-#endif
-
-#define ISALPHA(C) isalpha((unsigned char)C)
-#define ISUPPER(C) isupper((unsigned char)C)
-#define ISLOWER(C) islower((unsigned char)C)
-#define ISDIGIT(C) isdigit((unsigned char)C)
-#define ISXDIGIT(C) isxdigit((unsigned char)C)
-#define ISSPACE(C) isspace((unsigned char)C)
-#define ISPUNCT(C) ispunct((unsigned char)C)
-#define ISALNUM(C) isalnum((unsigned char)C)
-#define ISPRINT(C) isprint((unsigned char)C)
-#define ISGRAPH(C) isgraph((unsigned char)C)
-#define ISCNTRL(C) iscntrl((unsigned char)C)
-
-#include "dfa.h"
-#include <gnuregex.h>
-
-#if __STDC__
-typedef void *ptr_t;
-#else
-typedef char *ptr_t;
-#endif
-
-static void dfamust();
-
-#ifdef __FreeBSD__
-static int collate_range_cmp (a, b)
- int a, b;
-{
- int r;
- static char s[2][2];
-
- if ((unsigned char)a == (unsigned char)b)
- return 0;
- s[0][0] = a;
- s[1][0] = b;
- if ((r = strcoll(s[0], s[1])) == 0)
- r = (unsigned char)a - (unsigned char)b;
- return r;
-}
-#endif
-
-static ptr_t
-xcalloc(n, s)
- int n;
- size_t s;
-{
- ptr_t r = calloc(n, s);
-
- if (!r)
- dfaerror("Memory exhausted");
- return r;
-}
-
-static ptr_t
-xmalloc(n)
- size_t n;
-{
- ptr_t r = malloc(n);
-
- assert(n != 0);
- if (!r)
- dfaerror("Memory exhausted");
- return r;
-}
-
-static ptr_t
-xrealloc(p, n)
- ptr_t p;
- size_t n;
-{
- ptr_t r = realloc(p, n);
-
- assert(n != 0);
- if (!r)
- dfaerror("Memory exhausted");
- return r;
-}
-
-#define CALLOC(p, t, n) ((p) = (t *) xcalloc((n), sizeof (t)))
-#define MALLOC(p, t, n) ((p) = (t *) xmalloc((n) * sizeof (t)))
-#define REALLOC(p, t, n) ((p) = (t *) xrealloc((ptr_t) (p), (n) * sizeof (t)))
-
-/* Reallocate an array of type t if nalloc is too small for index. */
-#define REALLOC_IF_NECESSARY(p, t, nalloc, index) \
- if ((index) >= (nalloc)) \
- { \
- while ((index) >= (nalloc)) \
- (nalloc) *= 2; \
- REALLOC(p, t, nalloc); \
- }
-
-#ifdef DEBUG
-
-static void
-prtok(t)
- token t;
-{
- char *s;
-
- if (t < 0)
- fprintf(stderr, "END");
- else if (t < NOTCHAR)
- fprintf(stderr, "%c", t);
- else
- {
- switch (t)
- {
- case EMPTY: s = "EMPTY"; break;
- case BACKREF: s = "BACKREF"; break;
- case BEGLINE: s = "BEGLINE"; break;
- case ENDLINE: s = "ENDLINE"; break;
- case BEGWORD: s = "BEGWORD"; break;
- case ENDWORD: s = "ENDWORD"; break;
- case LIMWORD: s = "LIMWORD"; break;
- case NOTLIMWORD: s = "NOTLIMWORD"; break;
- case QMARK: s = "QMARK"; break;
- case STAR: s = "STAR"; break;
- case PLUS: s = "PLUS"; break;
- case CAT: s = "CAT"; break;
- case OR: s = "OR"; break;
- case ORTOP: s = "ORTOP"; break;
- case LPAREN: s = "LPAREN"; break;
- case RPAREN: s = "RPAREN"; break;
- default: s = "CSET"; break;
- }
- fprintf(stderr, "%s", s);
- }
-}
-#endif /* DEBUG */
-
-/* Stuff pertaining to charclasses. */
-
-static int
-tstbit(b, c)
- int b;
- charclass c;
-{
- return c[b / INTBITS] & 1 << b % INTBITS;
-}
-
-static void
-setbit(b, c)
- int b;
- charclass c;
-{
- c[b / INTBITS] |= 1 << b % INTBITS;
-}
-
-static void
-clrbit(b, c)
- int b;
- charclass c;
-{
- c[b / INTBITS] &= ~(1 << b % INTBITS);
-}
-
-static void
-copyset(src, dst)
- charclass src;
- charclass dst;
-{
- int i;
-
- for (i = 0; i < CHARCLASS_INTS; ++i)
- dst[i] = src[i];
-}
-
-static void
-zeroset(s)
- charclass s;
-{
- int i;
-
- for (i = 0; i < CHARCLASS_INTS; ++i)
- s[i] = 0;
-}
-
-static void
-notset(s)
- charclass s;
-{
- int i;
-
- for (i = 0; i < CHARCLASS_INTS; ++i)
- s[i] = ~s[i];
-}
-
-static int
-equal(s1, s2)
- charclass s1;
- charclass s2;
-{
- int i;
-
- for (i = 0; i < CHARCLASS_INTS; ++i)
- if (s1[i] != s2[i])
- return 0;
- return 1;
-}
-
-/* A pointer to the current dfa is kept here during parsing. */
-static struct dfa *dfa;
-
-/* Find the index of charclass s in dfa->charclasses, or allocate a new charclass. */
-static int
-charclass_index(s)
- charclass s;
-{
- int i;
-
- for (i = 0; i < dfa->cindex; ++i)
- if (equal(s, dfa->charclasses[i]))
- return i;
- REALLOC_IF_NECESSARY(dfa->charclasses, charclass, dfa->calloc, dfa->cindex);
- ++dfa->cindex;
- copyset(s, dfa->charclasses[i]);
- return i;
-}
-
-/* Syntax bits controlling the behavior of the lexical analyzer. */
-static int syntax_bits, syntax_bits_set;
-
-/* Flag for case-folding letters into sets. */
-static int case_fold;
-
-/* Entry point to set syntax options. */
-void
-dfasyntax(bits, fold)
- int bits;
- int fold;
-{
- syntax_bits_set = 1;
- syntax_bits = bits;
- case_fold = fold;
-}
-
-/* Lexical analyzer. All the dross that deals with the obnoxious
- GNU Regex syntax bits is located here. The poor, suffering
- reader is referred to the GNU Regex documentation for the
- meaning of the @#%!@#%^!@ syntax bits. */
-
-static char *lexstart; /* Pointer to beginning of input string. */
-static char *lexptr; /* Pointer to next input character. */
-static lexleft; /* Number of characters remaining. */
-static token lasttok; /* Previous token returned; initially END. */
-static int laststart; /* True if we're separated from beginning or (, |
- only by zero-width characters. */
-static int parens; /* Count of outstanding left parens. */
-static int minrep, maxrep; /* Repeat counts for {m,n}. */
-
-/* Note that characters become unsigned here. */
-#define FETCH(c, eoferr) \
- { \
- if (! lexleft) \
- if (eoferr != 0) \
- dfaerror(eoferr); \
- else \
- return END; \
- (c) = (unsigned char) *lexptr++; \
- --lexleft; \
- }
-
-#define FUNC(F, P) static int F(c) int c; { return P(c); }
-
-FUNC(is_alpha, ISALPHA)
-FUNC(is_upper, ISUPPER)
-FUNC(is_lower, ISLOWER)
-FUNC(is_digit, ISDIGIT)
-FUNC(is_xdigit, ISXDIGIT)
-FUNC(is_space, ISSPACE)
-FUNC(is_punct, ISPUNCT)
-FUNC(is_alnum, ISALNUM)
-FUNC(is_print, ISPRINT)
-FUNC(is_graph, ISGRAPH)
-FUNC(is_cntrl, ISCNTRL)
-
-/* The following list maps the names of the Posix named character classes
- to predicate functions that determine whether a given character is in
- the class. The leading [ has already been eaten by the lexical analyzer. */
-static struct {
- char *name;
- int (*pred)();
-} prednames[] = {
- ":alpha:]", is_alpha,
- ":upper:]", is_upper,
- ":lower:]", is_lower,
- ":digit:]", is_digit,
- ":xdigit:]", is_xdigit,
- ":space:]", is_space,
- ":punct:]", is_punct,
- ":alnum:]", is_alnum,
- ":print:]", is_print,
- ":graph:]", is_graph,
- ":cntrl:]", is_cntrl,
- 0
-};
-
-static int
-looking_at(s)
- char *s;
-{
- int len;
-
- len = strlen(s);
- if (lexleft < len)
- return 0;
- return strncmp(s, lexptr, len) == 0;
-}
-
-static token
-lex()
-{
- token c, c1, c2;
- int backslash = 0, invert;
- charclass ccl;
- int i;
-
- /* Basic plan: We fetch a character. If it's a backslash,
- we set the backslash flag and go through the loop again.
- On the plus side, this avoids having a duplicate of the
- main switch inside the backslash case. On the minus side,
- it means that just about every case begins with
- "if (backslash) ...". */
- for (i = 0; i < 2; ++i)
- {
- FETCH(c, 0);
- switch (c)
- {
- case '\\':
- if (backslash)
- goto normal_char;
- if (lexleft == 0)
- dfaerror("Unfinished \\ escape");
- backslash = 1;
- break;
-
- case '^':
- if (backslash)
- goto normal_char;
- if (syntax_bits & RE_CONTEXT_INDEP_ANCHORS
- || lasttok == END
- || lasttok == LPAREN
- || lasttok == OR)
- return lasttok = BEGLINE;
- goto normal_char;
-
- case '$':
- if (backslash)
- goto normal_char;
- if (syntax_bits & RE_CONTEXT_INDEP_ANCHORS
- || lexleft == 0
- || (syntax_bits & RE_NO_BK_PARENS
- ? lexleft > 0 && *lexptr == ')'
- : lexleft > 1 && lexptr[0] == '\\' && lexptr[1] == ')')
- || (syntax_bits & RE_NO_BK_VBAR
- ? lexleft > 0 && *lexptr == '|'
- : lexleft > 1 && lexptr[0] == '\\' && lexptr[1] == '|')
- || ((syntax_bits & RE_NEWLINE_ALT)
- && lexleft > 0 && *lexptr == '\n'))
- return lasttok = ENDLINE;
- goto normal_char;
-
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (backslash && !(syntax_bits & RE_NO_BK_REFS))
- {
- laststart = 0;
- return lasttok = BACKREF;
- }
- goto normal_char;
-
- case '<':
- if (backslash)
- return lasttok = BEGWORD;
- goto normal_char;
-
- case '>':
- if (backslash)
- return lasttok = ENDWORD;
- goto normal_char;
-
- case 'b':
- if (backslash)
- return lasttok = LIMWORD;
- goto normal_char;
-
- case 'B':
- if (backslash)
- return lasttok = NOTLIMWORD;
- goto normal_char;
-
- case '?':
- if (syntax_bits & RE_LIMITED_OPS)
- goto normal_char;
- if (backslash != ((syntax_bits & RE_BK_PLUS_QM) != 0))
- goto normal_char;
- if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart)
- goto normal_char;
- return lasttok = QMARK;
-
- case '*':
- if (backslash)
- goto normal_char;
- if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart)
- goto normal_char;
- return lasttok = STAR;
-
- case '+':
- if (syntax_bits & RE_LIMITED_OPS)
- goto normal_char;
- if (backslash != ((syntax_bits & RE_BK_PLUS_QM) != 0))
- goto normal_char;
- if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart)
- goto normal_char;
- return lasttok = PLUS;
-
- case '{':
- if (!(syntax_bits & RE_INTERVALS))
- goto normal_char;
- if (backslash != ((syntax_bits & RE_NO_BK_BRACES) == 0))
- goto normal_char;
- minrep = maxrep = 0;
- /* Cases:
- {M} - exact count
- {M,} - minimum count, maximum is infinity
- {,M} - 0 through M
- {M,N} - M through N */
- FETCH(c, "unfinished repeat count");
- if (ISDIGIT(c))
- {
- minrep = c - '0';
- for (;;)
- {
- FETCH(c, "unfinished repeat count");
- if (!ISDIGIT(c))
- break;
- minrep = 10 * minrep + c - '0';
- }
- }
- else if (c != ',')
- dfaerror("malformed repeat count");
- if (c == ',')
- for (;;)
- {
- FETCH(c, "unfinished repeat count");
- if (!ISDIGIT(c))
- break;
- maxrep = 10 * maxrep + c - '0';
- }
- else
- maxrep = minrep;
- if (!(syntax_bits & RE_NO_BK_BRACES))
- {
- if (c != '\\')
- dfaerror("malformed repeat count");
- FETCH(c, "unfinished repeat count");
- }
- if (c != '}')
- dfaerror("malformed repeat count");
- laststart = 0;
- return lasttok = REPMN;
-
- case '|':
- if (syntax_bits & RE_LIMITED_OPS)
- goto normal_char;
- if (backslash != ((syntax_bits & RE_NO_BK_VBAR) == 0))
- goto normal_char;
- laststart = 1;
- return lasttok = OR;
-
- case '\n':
- if (syntax_bits & RE_LIMITED_OPS
- || backslash
- || !(syntax_bits & RE_NEWLINE_ALT))
- goto normal_char;
- laststart = 1;
- return lasttok = OR;
-
- case '(':
- if (backslash != ((syntax_bits & RE_NO_BK_PARENS) == 0))
- goto normal_char;
- ++parens;
- laststart = 1;
- return lasttok = LPAREN;
-
- case ')':
- if (backslash != ((syntax_bits & RE_NO_BK_PARENS) == 0))
- goto normal_char;
- if (parens == 0 && syntax_bits & RE_UNMATCHED_RIGHT_PAREN_ORD)
- goto normal_char;
- --parens;
- laststart = 0;
- return lasttok = RPAREN;
-
- case '.':
- if (backslash)
- goto normal_char;
- zeroset(ccl);
- notset(ccl);
- if (!(syntax_bits & RE_DOT_NEWLINE))
- clrbit('\n', ccl);
- if (syntax_bits & RE_DOT_NOT_NULL)
- clrbit('\0', ccl);
- laststart = 0;
- return lasttok = CSET + charclass_index(ccl);
-
- case 'w':
- case 'W':
- if (!backslash)
- goto normal_char;
- zeroset(ccl);
- for (c2 = 0; c2 < NOTCHAR; ++c2)
- if (ISALNUM(c2))
- setbit(c2, ccl);
- if (c == 'W')
- notset(ccl);
- laststart = 0;
- return lasttok = CSET + charclass_index(ccl);
-
- case '[':
- if (backslash)
- goto normal_char;
- zeroset(ccl);
- FETCH(c, "Unbalanced [");
- if (c == '^')
- {
- FETCH(c, "Unbalanced [");
- invert = 1;
- }
- else
- invert = 0;
- do
- {
- /* Nobody ever said this had to be fast. :-)
- Note that if we're looking at some other [:...:]
- construct, we just treat it as a bunch of ordinary
- characters. We can do this because we assume
- regex has checked for syntax errors before
- dfa is ever called. */
- if (c == '[' && (syntax_bits & RE_CHAR_CLASSES))
- for (c1 = 0; prednames[c1].name; ++c1)
- if (looking_at(prednames[c1].name))
- {
- for (c2 = 0; c2 < NOTCHAR; ++c2)
- if ((*prednames[c1].pred)(c2))
- setbit(c2, ccl);
- lexptr += strlen(prednames[c1].name);
- lexleft -= strlen(prednames[c1].name);
- FETCH(c1, "Unbalanced [");
- goto skip;
- }
- if (c == '\\' && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS))
- FETCH(c, "Unbalanced [");
- FETCH(c1, "Unbalanced [");
- if (c1 == '-')
- {
- FETCH(c2, "Unbalanced [");
- if (c2 == ']')
- {
- /* In the case [x-], the - is an ordinary hyphen,
- which is left in c1, the lookahead character. */
- --lexptr;
- ++lexleft;
- c2 = c;
- }
- else
- {
- if (c2 == '\\'
- && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS))
- FETCH(c2, "Unbalanced [");
- FETCH(c1, "Unbalanced [");
- }
- }
- else
- c2 = c;
-#ifdef __FreeBSD__
- { token c3;
-
- if (collate_range_cmp(c, c2) > 0) {
- FETCH(c2, "Invalid range");
- goto skip;
- }
-
- for (c3 = 0; c3 < NOTCHAR; ++c3)
- if ( collate_range_cmp(c, c3) <= 0
- && collate_range_cmp(c3, c2) <= 0
- ) {
- setbit(c3, ccl);
- if (case_fold)
- if (ISUPPER(c3))
- setbit(tolower((unsigned char)c3), ccl);
- else if (ISLOWER(c3))
- setbit(toupper((unsigned char)c3), ccl);
- }
- }
-#else
- while (c <= c2)
- {
- setbit(c, ccl);
- if (case_fold)
- if (ISUPPER(c))
- setbit(tolower((unsigned char)c), ccl);
- else if (ISLOWER(c))
- setbit(toupper((unsigned char)c), ccl);
- ++c;
- }
-#endif
- skip:
- ;
- }
- while ((c = c1) != ']');
- if (invert)
- {
- notset(ccl);
- if (syntax_bits & RE_HAT_LISTS_NOT_NEWLINE)
- clrbit('\n', ccl);
- }
- laststart = 0;
- return lasttok = CSET + charclass_index(ccl);
-
- default:
- normal_char:
- laststart = 0;
- if (case_fold && ISALPHA(c))
- {
- zeroset(ccl);
- setbit(c, ccl);
- if (isupper((unsigned char)c))
- setbit(tolower((unsigned char)c), ccl);
- else
- setbit(toupper((unsigned char)c), ccl);
- return lasttok = CSET + charclass_index(ccl);
- }
- return c;
- }
- }
-
- /* The above loop should consume at most a backslash
- and some other character. */
- abort();
-}
-
-/* Recursive descent parser for regular expressions. */
-
-static token tok; /* Lookahead token. */
-static depth; /* Current depth of a hypothetical stack
- holding deferred productions. This is
- used to determine the depth that will be
- required of the real stack later on in
- dfaanalyze(). */
-
-/* Add the given token to the parse tree, maintaining the depth count and
- updating the maximum depth if necessary. */
-static void
-addtok(t)
- token t;
-{
- REALLOC_IF_NECESSARY(dfa->tokens, token, dfa->talloc, dfa->tindex);
- dfa->tokens[dfa->tindex++] = t;
-
- switch (t)
- {
- case QMARK:
- case STAR:
- case PLUS:
- break;
-
- case CAT:
- case OR:
- case ORTOP:
- --depth;
- break;
-
- default:
- ++dfa->nleaves;
- case EMPTY:
- ++depth;
- break;
- }
- if (depth > dfa->depth)
- dfa->depth = depth;
-}
-
-/* The grammar understood by the parser is as follows.
-
- regexp:
- regexp OR branch
- branch
-
- branch:
- branch closure
- closure
-
- closure:
- closure QMARK
- closure STAR
- closure PLUS
- atom
-
- atom:
- <normal character>
- CSET
- BACKREF
- BEGLINE
- ENDLINE
- BEGWORD
- ENDWORD
- LIMWORD
- NOTLIMWORD
- <empty>
-
- The parser builds a parse tree in postfix form in an array of tokens. */
-
-#if __STDC__
-static void regexp(int);
-#else
-static void regexp();
-#endif
-
-static void
-atom()
-{
- if ((tok >= 0 && tok < NOTCHAR) || tok >= CSET || tok == BACKREF
- || tok == BEGLINE || tok == ENDLINE || tok == BEGWORD
- || tok == ENDWORD || tok == LIMWORD || tok == NOTLIMWORD)
- {
- addtok(tok);
- tok = lex();
- }
- else if (tok == LPAREN)
- {
- tok = lex();
- regexp(0);
- if (tok != RPAREN)
- dfaerror("Unbalanced (");
- tok = lex();
- }
- else
- addtok(EMPTY);
-}
-
-/* Return the number of tokens in the given subexpression. */
-static int
-nsubtoks(tindex)
-{
- int ntoks1;
-
- switch (dfa->tokens[tindex - 1])
- {
- default:
- return 1;
- case QMARK:
- case STAR:
- case PLUS:
- return 1 + nsubtoks(tindex - 1);
- case CAT:
- case OR:
- case ORTOP:
- ntoks1 = nsubtoks(tindex - 1);
- return 1 + ntoks1 + nsubtoks(tindex - 1 - ntoks1);
- }
-}
-
-/* Copy the given subexpression to the top of the tree. */
-static void
-copytoks(tindex, ntokens)
- int tindex, ntokens;
-{
- int i;
-
- for (i = 0; i < ntokens; ++i)
- addtok(dfa->tokens[tindex + i]);
-}
-
-static void
-closure()
-{
- int tindex, ntokens, i;
-
- atom();
- while (tok == QMARK || tok == STAR || tok == PLUS || tok == REPMN)
- if (tok == REPMN)
- {
- ntokens = nsubtoks(dfa->tindex);
- tindex = dfa->tindex - ntokens;
- if (maxrep == 0)
- addtok(PLUS);
- if (minrep == 0)
- addtok(QMARK);
- for (i = 1; i < minrep; ++i)
- {
- copytoks(tindex, ntokens);
- addtok(CAT);
- }
- for (; i < maxrep; ++i)
- {
- copytoks(tindex, ntokens);
- addtok(QMARK);
- addtok(CAT);
- }
- tok = lex();
- }
- else
- {
- addtok(tok);
- tok = lex();
- }
-}
-
-static void
-branch()
-{
- closure();
- while (tok != RPAREN && tok != OR && tok >= 0)
- {
- closure();
- addtok(CAT);
- }
-}
-
-static void
-regexp(toplevel)
- int toplevel;
-{
- branch();
- while (tok == OR)
- {
- tok = lex();
- branch();
- if (toplevel)
- addtok(ORTOP);
- else
- addtok(OR);
- }
-}
-
-/* Main entry point for the parser. S is a string to be parsed, len is the
- length of the string, so s can include NUL characters. D is a pointer to
- the struct dfa to parse into. */
-void
-dfaparse(s, len, d)
- char *s;
- size_t len;
- struct dfa *d;
-
-{
- dfa = d;
- lexstart = lexptr = s;
- lexleft = len;
- lasttok = END;
- laststart = 1;
- parens = 0;
-
- if (! syntax_bits_set)
- dfaerror("No syntax specified");
-
- tok = lex();
- depth = d->depth;
-
- regexp(1);
-
- if (tok != END)
- dfaerror("Unbalanced )");
-
- addtok(END - d->nregexps);
- addtok(CAT);
-
- if (d->nregexps)
- addtok(ORTOP);
-
- ++d->nregexps;
-}
-
-/* Some primitives for operating on sets of positions. */
-
-/* Copy one set to another; the destination must be large enough. */
-static void
-copy(src, dst)
- position_set *src;
- position_set *dst;
-{
- int i;
-
- for (i = 0; i < src->nelem; ++i)
- dst->elems[i] = src->elems[i];
- dst->nelem = src->nelem;
-}
-
-/* Insert a position in a set. Position sets are maintained in sorted
- order according to index. If position already exists in the set with
- the same index then their constraints are logically or'd together.
- S->elems must point to an array large enough to hold the resulting set. */
-static void
-insert(p, s)
- position p;
- position_set *s;
-{
- int i;
- position t1, t2;
-
- for (i = 0; i < s->nelem && p.index < s->elems[i].index; ++i)
- ;
- if (i < s->nelem && p.index == s->elems[i].index)
- s->elems[i].constraint |= p.constraint;
- else
- {
- t1 = p;
- ++s->nelem;
- while (i < s->nelem)
- {
- t2 = s->elems[i];
- s->elems[i++] = t1;
- t1 = t2;
- }
- }
-}
-
-/* Merge two sets of positions into a third. The result is exactly as if
- the positions of both sets were inserted into an initially empty set. */
-static void
-merge(s1, s2, m)
- position_set *s1;
- position_set *s2;
- position_set *m;
-{
- int i = 0, j = 0;
-
- m->nelem = 0;
- while (i < s1->nelem && j < s2->nelem)
- if (s1->elems[i].index > s2->elems[j].index)
- m->elems[m->nelem++] = s1->elems[i++];
- else if (s1->elems[i].index < s2->elems[j].index)
- m->elems[m->nelem++] = s2->elems[j++];
- else
- {
- m->elems[m->nelem] = s1->elems[i++];
- m->elems[m->nelem++].constraint |= s2->elems[j++].constraint;
- }
- while (i < s1->nelem)
- m->elems[m->nelem++] = s1->elems[i++];
- while (j < s2->nelem)
- m->elems[m->nelem++] = s2->elems[j++];
-}
-
-/* Delete a position from a set. */
-static void
-delete(p, s)
- position p;
- position_set *s;
-{
- int i;
-
- for (i = 0; i < s->nelem; ++i)
- if (p.index == s->elems[i].index)
- break;
- if (i < s->nelem)
- for (--s->nelem; i < s->nelem; ++i)
- s->elems[i] = s->elems[i + 1];
-}
-
-/* Find the index of the state corresponding to the given position set with
- the given preceding context, or create a new state if there is no such
- state. Newline and letter tell whether we got here on a newline or
- letter, respectively. */
-static int
-state_index(d, s, newline, letter)
- struct dfa *d;
- position_set *s;
- int newline;
- int letter;
-{
- int hash = 0;
- int constraint;
- int i, j;
-
- newline = newline ? 1 : 0;
- letter = letter ? 1 : 0;
-
- for (i = 0; i < s->nelem; ++i)
- hash ^= s->elems[i].index + s->elems[i].constraint;
-
- /* Try to find a state that exactly matches the proposed one. */
- for (i = 0; i < d->sindex; ++i)
- {
- if (hash != d->states[i].hash || s->nelem != d->states[i].elems.nelem
- || newline != d->states[i].newline || letter != d->states[i].letter)
- continue;
- for (j = 0; j < s->nelem; ++j)
- if (s->elems[j].constraint
- != d->states[i].elems.elems[j].constraint
- || s->elems[j].index != d->states[i].elems.elems[j].index)
- break;
- if (j == s->nelem)
- return i;
- }
-
- /* We'll have to create a new state. */
- REALLOC_IF_NECESSARY(d->states, dfa_state, d->salloc, d->sindex);
- d->states[i].hash = hash;
- MALLOC(d->states[i].elems.elems, position, s->nelem);
- copy(s, &d->states[i].elems);
- d->states[i].newline = newline;
- d->states[i].letter = letter;
- d->states[i].backref = 0;
- d->states[i].constraint = 0;
- d->states[i].first_end = 0;
- for (j = 0; j < s->nelem; ++j)
- if (d->tokens[s->elems[j].index] < 0)
- {
- constraint = s->elems[j].constraint;
- if (SUCCEEDS_IN_CONTEXT(constraint, newline, 0, letter, 0)
- || SUCCEEDS_IN_CONTEXT(constraint, newline, 0, letter, 1)
- || SUCCEEDS_IN_CONTEXT(constraint, newline, 1, letter, 0)
- || SUCCEEDS_IN_CONTEXT(constraint, newline, 1, letter, 1))
- d->states[i].constraint |= constraint;
- if (! d->states[i].first_end)
- d->states[i].first_end = d->tokens[s->elems[j].index];
- }
- else if (d->tokens[s->elems[j].index] == BACKREF)
- {
- d->states[i].constraint = NO_CONSTRAINT;
- d->states[i].backref = 1;
- }
-
- ++d->sindex;
-
- return i;
-}
-
-/* Find the epsilon closure of a set of positions. If any position of the set
- contains a symbol that matches the empty string in some context, replace
- that position with the elements of its follow labeled with an appropriate
- constraint. Repeat exhaustively until no funny positions are left.
- S->elems must be large enough to hold the result. */
-void
-epsclosure(s, d)
- position_set *s;
- struct dfa *d;
-{
- int i, j;
- int *visited;
- position p, old;
-
- MALLOC(visited, int, d->tindex);
- for (i = 0; i < d->tindex; ++i)
- visited[i] = 0;
-
- for (i = 0; i < s->nelem; ++i)
- if (d->tokens[s->elems[i].index] >= NOTCHAR
- && d->tokens[s->elems[i].index] != BACKREF
- && d->tokens[s->elems[i].index] < CSET)
- {
- old = s->elems[i];
- p.constraint = old.constraint;
- delete(s->elems[i], s);
- if (visited[old.index])
- {
- --i;
- continue;
- }
- visited[old.index] = 1;
- switch (d->tokens[old.index])
- {
- case BEGLINE:
- p.constraint &= BEGLINE_CONSTRAINT;
- break;
- case ENDLINE:
- p.constraint &= ENDLINE_CONSTRAINT;
- break;
- case BEGWORD:
- p.constraint &= BEGWORD_CONSTRAINT;
- break;
- case ENDWORD:
- p.constraint &= ENDWORD_CONSTRAINT;
- break;
- case LIMWORD:
- p.constraint &= LIMWORD_CONSTRAINT;
- break;
- case NOTLIMWORD:
- p.constraint &= NOTLIMWORD_CONSTRAINT;
- break;
- default:
- break;
- }
- for (j = 0; j < d->follows[old.index].nelem; ++j)
- {
- p.index = d->follows[old.index].elems[j].index;
- insert(p, s);
- }
- /* Force rescan to start at the beginning. */
- i = -1;
- }
-
- free(visited);
-}
-
-/* Perform bottom-up analysis on the parse tree, computing various functions.
- Note that at this point, we're pretending constructs like \< are real
- characters rather than constraints on what can follow them.
-
- Nullable: A node is nullable if it is at the root of a regexp that can
- match the empty string.
- * EMPTY leaves are nullable.
- * No other leaf is nullable.
- * A QMARK or STAR node is nullable.
- * A PLUS node is nullable if its argument is nullable.
- * A CAT node is nullable if both its arguments are nullable.
- * An OR node is nullable if either argument is nullable.
-
- Firstpos: The firstpos of a node is the set of positions (nonempty leaves)
- that could correspond to the first character of a string matching the
- regexp rooted at the given node.
- * EMPTY leaves have empty firstpos.
- * The firstpos of a nonempty leaf is that leaf itself.
- * The firstpos of a QMARK, STAR, or PLUS node is the firstpos of its
- argument.
- * The firstpos of a CAT node is the firstpos of the left argument, union
- the firstpos of the right if the left argument is nullable.
- * The firstpos of an OR node is the union of firstpos of each argument.
-
- Lastpos: The lastpos of a node is the set of positions that could
- correspond to the last character of a string matching the regexp at
- the given node.
- * EMPTY leaves have empty lastpos.
- * The lastpos of a nonempty leaf is that leaf itself.
- * The lastpos of a QMARK, STAR, or PLUS node is the lastpos of its
- argument.
- * The lastpos of a CAT node is the lastpos of its right argument, union
- the lastpos of the left if the right argument is nullable.
- * The lastpos of an OR node is the union of the lastpos of each argument.
-
- Follow: The follow of a position is the set of positions that could
- correspond to the character following a character matching the node in
- a string matching the regexp. At this point we consider special symbols
- that match the empty string in some context to be just normal characters.
- Later, if we find that a special symbol is in a follow set, we will
- replace it with the elements of its follow, labeled with an appropriate
- constraint.
- * Every node in the firstpos of the argument of a STAR or PLUS node is in
- the follow of every node in the lastpos.
- * Every node in the firstpos of the second argument of a CAT node is in
- the follow of every node in the lastpos of the first argument.
-
- Because of the postfix representation of the parse tree, the depth-first
- analysis is conveniently done by a linear scan with the aid of a stack.
- Sets are stored as arrays of the elements, obeying a stack-like allocation
- scheme; the number of elements in each set deeper in the stack can be
- used to determine the address of a particular set's array. */
-void
-dfaanalyze(d, searchflag)
- struct dfa *d;
- int searchflag;
-{
- int *nullable; /* Nullable stack. */
- int *nfirstpos; /* Element count stack for firstpos sets. */
- position *firstpos; /* Array where firstpos elements are stored. */
- int *nlastpos; /* Element count stack for lastpos sets. */
- position *lastpos; /* Array where lastpos elements are stored. */
- int *nalloc; /* Sizes of arrays allocated to follow sets. */
- position_set tmp; /* Temporary set for merging sets. */
- position_set merged; /* Result of merging sets. */
- int wants_newline; /* True if some position wants newline info. */
- int *o_nullable;
- int *o_nfirst, *o_nlast;
- position *o_firstpos, *o_lastpos;
- int i, j;
- position *pos;
-
-#ifdef DEBUG
- fprintf(stderr, "dfaanalyze:\n");
- for (i = 0; i < d->tindex; ++i)
- {
- fprintf(stderr, " %d:", i);
- prtok(d->tokens[i]);
- }
- putc('\n', stderr);
-#endif
-
- d->searchflag = searchflag;
-
- MALLOC(nullable, int, d->depth);
- o_nullable = nullable;
- MALLOC(nfirstpos, int, d->depth);
- o_nfirst = nfirstpos;
- MALLOC(firstpos, position, d->nleaves);
- o_firstpos = firstpos, firstpos += d->nleaves;
- MALLOC(nlastpos, int, d->depth);
- o_nlast = nlastpos;
- MALLOC(lastpos, position, d->nleaves);
- o_lastpos = lastpos, lastpos += d->nleaves;
- MALLOC(nalloc, int, d->tindex);
- for (i = 0; i < d->tindex; ++i)
- nalloc[i] = 0;
- MALLOC(merged.elems, position, d->nleaves);
-
- CALLOC(d->follows, position_set, d->tindex);
-
- for (i = 0; i < d->tindex; ++i)
-#ifdef DEBUG
- { /* Nonsyntactic #ifdef goo... */
-#endif
- switch (d->tokens[i])
- {
- case EMPTY:
- /* The empty set is nullable. */
- *nullable++ = 1;
-
- /* The firstpos and lastpos of the empty leaf are both empty. */
- *nfirstpos++ = *nlastpos++ = 0;
- break;
-
- case STAR:
- case PLUS:
- /* Every element in the firstpos of the argument is in the follow
- of every element in the lastpos. */
- tmp.nelem = nfirstpos[-1];
- tmp.elems = firstpos;
- pos = lastpos;
- for (j = 0; j < nlastpos[-1]; ++j)
- {
- merge(&tmp, &d->follows[pos[j].index], &merged);
- REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems, position,
- nalloc[pos[j].index], merged.nelem - 1);
- copy(&merged, &d->follows[pos[j].index]);
- }
-
- case QMARK:
- /* A QMARK or STAR node is automatically nullable. */
- if (d->tokens[i] != PLUS)
- nullable[-1] = 1;
- break;
-
- case CAT:
- /* Every element in the firstpos of the second argument is in the
- follow of every element in the lastpos of the first argument. */
- tmp.nelem = nfirstpos[-1];
- tmp.elems = firstpos;
- pos = lastpos + nlastpos[-1];
- for (j = 0; j < nlastpos[-2]; ++j)
- {
- merge(&tmp, &d->follows[pos[j].index], &merged);
- REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems, position,
- nalloc[pos[j].index], merged.nelem - 1);
- copy(&merged, &d->follows[pos[j].index]);
- }
-
- /* The firstpos of a CAT node is the firstpos of the first argument,
- union that of the second argument if the first is nullable. */
- if (nullable[-2])
- nfirstpos[-2] += nfirstpos[-1];
- else
- firstpos += nfirstpos[-1];
- --nfirstpos;
-
- /* The lastpos of a CAT node is the lastpos of the second argument,
- union that of the first argument if the second is nullable. */
- if (nullable[-1])
- nlastpos[-2] += nlastpos[-1];
- else
- {
- pos = lastpos + nlastpos[-2];
- for (j = nlastpos[-1] - 1; j >= 0; --j)
- pos[j] = lastpos[j];
- lastpos += nlastpos[-2];
- nlastpos[-2] = nlastpos[-1];
- }
- --nlastpos;
-
- /* A CAT node is nullable if both arguments are nullable. */
- nullable[-2] = nullable[-1] && nullable[-2];
- --nullable;
- break;
-
- case OR:
- case ORTOP:
- /* The firstpos is the union of the firstpos of each argument. */
- nfirstpos[-2] += nfirstpos[-1];
- --nfirstpos;
-
- /* The lastpos is the union of the lastpos of each argument. */
- nlastpos[-2] += nlastpos[-1];
- --nlastpos;
-
- /* An OR node is nullable if either argument is nullable. */
- nullable[-2] = nullable[-1] || nullable[-2];
- --nullable;
- break;
-
- default:
- /* Anything else is a nonempty position. (Note that special
- constructs like \< are treated as nonempty strings here;
- an "epsilon closure" effectively makes them nullable later.
- Backreferences have to get a real position so we can detect
- transitions on them later. But they are nullable. */
- *nullable++ = d->tokens[i] == BACKREF;
-
- /* This position is in its own firstpos and lastpos. */
- *nfirstpos++ = *nlastpos++ = 1;
- --firstpos, --lastpos;
- firstpos->index = lastpos->index = i;
- firstpos->constraint = lastpos->constraint = NO_CONSTRAINT;
-
- /* Allocate the follow set for this position. */
- nalloc[i] = 1;
- MALLOC(d->follows[i].elems, position, nalloc[i]);
- break;
- }
-#ifdef DEBUG
- /* ... balance the above nonsyntactic #ifdef goo... */
- fprintf(stderr, "node %d:", i);
- prtok(d->tokens[i]);
- putc('\n', stderr);
- fprintf(stderr, nullable[-1] ? " nullable: yes\n" : " nullable: no\n");
- fprintf(stderr, " firstpos:");
- for (j = nfirstpos[-1] - 1; j >= 0; --j)
- {
- fprintf(stderr, " %d:", firstpos[j].index);
- prtok(d->tokens[firstpos[j].index]);
- }
- fprintf(stderr, "\n lastpos:");
- for (j = nlastpos[-1] - 1; j >= 0; --j)
- {
- fprintf(stderr, " %d:", lastpos[j].index);
- prtok(d->tokens[lastpos[j].index]);
- }
- putc('\n', stderr);
- }
-#endif
-
- /* For each follow set that is the follow set of a real position, replace
- it with its epsilon closure. */
- for (i = 0; i < d->tindex; ++i)
- if (d->tokens[i] < NOTCHAR || d->tokens[i] == BACKREF
- || d->tokens[i] >= CSET)
- {
-#ifdef DEBUG
- fprintf(stderr, "follows(%d:", i);
- prtok(d->tokens[i]);
- fprintf(stderr, "):");
- for (j = d->follows[i].nelem - 1; j >= 0; --j)
- {
- fprintf(stderr, " %d:", d->follows[i].elems[j].index);
- prtok(d->tokens[d->follows[i].elems[j].index]);
- }
- putc('\n', stderr);
-#endif
- copy(&d->follows[i], &merged);
- epsclosure(&merged, d);
- if (d->follows[i].nelem < merged.nelem)
- REALLOC(d->follows[i].elems, position, merged.nelem);
- copy(&merged, &d->follows[i]);
- }
-
- /* Get the epsilon closure of the firstpos of the regexp. The result will
- be the set of positions of state 0. */
- merged.nelem = 0;
- for (i = 0; i < nfirstpos[-1]; ++i)
- insert(firstpos[i], &merged);
- epsclosure(&merged, d);
-
- /* Check if any of the positions of state 0 will want newline context. */
- wants_newline = 0;
- for (i = 0; i < merged.nelem; ++i)
- if (PREV_NEWLINE_DEPENDENT(merged.elems[i].constraint))
- wants_newline = 1;
-
- /* Build the initial state. */
- d->salloc = 1;
- d->sindex = 0;
- MALLOC(d->states, dfa_state, d->salloc);
- state_index(d, &merged, wants_newline, 0);
-
- free(o_nullable);
- free(o_nfirst);
- free(o_firstpos);
- free(o_nlast);
- free(o_lastpos);
- free(nalloc);
- free(merged.elems);
-}
-
-/* Find, for each character, the transition out of state s of d, and store
- it in the appropriate slot of trans.
-
- We divide the positions of s into groups (positions can appear in more
- than one group). Each group is labeled with a set of characters that
- every position in the group matches (taking into account, if necessary,
- preceding context information of s). For each group, find the union
- of the its elements' follows. This set is the set of positions of the
- new state. For each character in the group's label, set the transition
- on this character to be to a state corresponding to the set's positions,
- and its associated backward context information, if necessary.
-
- If we are building a searching matcher, we include the positions of state
- 0 in every state.
-
- The collection of groups is constructed by building an equivalence-class
- partition of the positions of s.
-
- For each position, find the set of characters C that it matches. Eliminate
- any characters from C that fail on grounds of backward context.
-
- Search through the groups, looking for a group whose label L has nonempty
- intersection with C. If L - C is nonempty, create a new group labeled
- L - C and having the same positions as the current group, and set L to
- the intersection of L and C. Insert the position in this group, set
- C = C - L, and resume scanning.
-
- If after comparing with every group there are characters remaining in C,
- create a new group labeled with the characters of C and insert this
- position in that group. */
-void
-dfastate(s, d, trans)
- int s;
- struct dfa *d;
- int trans[];
-{
- position_set grps[NOTCHAR]; /* As many as will ever be needed. */
- charclass labels[NOTCHAR]; /* Labels corresponding to the groups. */
- int ngrps = 0; /* Number of groups actually used. */
- position pos; /* Current position being considered. */
- charclass matches; /* Set of matching characters. */
- int matchesf; /* True if matches is nonempty. */
- charclass intersect; /* Intersection with some label set. */
- int intersectf; /* True if intersect is nonempty. */
- charclass leftovers; /* Stuff in the label that didn't match. */
- int leftoversf; /* True if leftovers is nonempty. */
- static charclass letters; /* Set of characters considered letters. */
- static charclass newline; /* Set of characters that aren't newline. */
- position_set follows; /* Union of the follows of some group. */
- position_set tmp; /* Temporary space for merging sets. */
- int state; /* New state. */
- int wants_newline; /* New state wants to know newline context. */
- int state_newline; /* New state on a newline transition. */
- int wants_letter; /* New state wants to know letter context. */
- int state_letter; /* New state on a letter transition. */
- static initialized; /* Flag for static initialization. */
- int i, j, k;
-
- /* Initialize the set of letters, if necessary. */
- if (! initialized)
- {
- initialized = 1;
- for (i = 0; i < NOTCHAR; ++i)
- if (ISALNUM(i))
- setbit(i, letters);
- setbit('\n', newline);
- }
-
- zeroset(matches);
-
- for (i = 0; i < d->states[s].elems.nelem; ++i)
- {
- pos = d->states[s].elems.elems[i];
- if (d->tokens[pos.index] >= 0 && d->tokens[pos.index] < NOTCHAR)
- setbit(d->tokens[pos.index], matches);
- else if (d->tokens[pos.index] >= CSET)
- copyset(d->charclasses[d->tokens[pos.index] - CSET], matches);
- else
- continue;
-
- /* Some characters may need to be eliminated from matches because
- they fail in the current context. */
- if (pos.constraint != 0xFF)
- {
- if (! MATCHES_NEWLINE_CONTEXT(pos.constraint,
- d->states[s].newline, 1))
- clrbit('\n', matches);
- if (! MATCHES_NEWLINE_CONTEXT(pos.constraint,
- d->states[s].newline, 0))
- for (j = 0; j < CHARCLASS_INTS; ++j)
- matches[j] &= newline[j];
- if (! MATCHES_LETTER_CONTEXT(pos.constraint,
- d->states[s].letter, 1))
- for (j = 0; j < CHARCLASS_INTS; ++j)
- matches[j] &= ~letters[j];
- if (! MATCHES_LETTER_CONTEXT(pos.constraint,
- d->states[s].letter, 0))
- for (j = 0; j < CHARCLASS_INTS; ++j)
- matches[j] &= letters[j];
-
- /* If there are no characters left, there's no point in going on. */
- for (j = 0; j < CHARCLASS_INTS && !matches[j]; ++j)
- ;
- if (j == CHARCLASS_INTS)
- continue;
- }
-
- for (j = 0; j < ngrps; ++j)
- {
- /* If matches contains a single character only, and the current
- group's label doesn't contain that character, go on to the
- next group. */
- if (d->tokens[pos.index] >= 0 && d->tokens[pos.index] < NOTCHAR
- && !tstbit(d->tokens[pos.index], labels[j]))
- continue;
-
- /* Check if this group's label has a nonempty intersection with
- matches. */
- intersectf = 0;
- for (k = 0; k < CHARCLASS_INTS; ++k)
- (intersect[k] = matches[k] & labels[j][k]) ? intersectf = 1 : 0;
- if (! intersectf)
- continue;
-
- /* It does; now find the set differences both ways. */
- leftoversf = matchesf = 0;
- for (k = 0; k < CHARCLASS_INTS; ++k)
- {
- /* Even an optimizing compiler can't know this for sure. */
- int match = matches[k], label = labels[j][k];
-
- (leftovers[k] = ~match & label) ? leftoversf = 1 : 0;
- (matches[k] = match & ~label) ? matchesf = 1 : 0;
- }
-
- /* If there were leftovers, create a new group labeled with them. */
- if (leftoversf)
- {
- copyset(leftovers, labels[ngrps]);
- copyset(intersect, labels[j]);
- MALLOC(grps[ngrps].elems, position, d->nleaves);
- copy(&grps[j], &grps[ngrps]);
- ++ngrps;
- }
-
- /* Put the position in the current group. Note that there is no
- reason to call insert() here. */
- grps[j].elems[grps[j].nelem++] = pos;
-
- /* If every character matching the current position has been
- accounted for, we're done. */
- if (! matchesf)
- break;
- }
-
- /* If we've passed the last group, and there are still characters
- unaccounted for, then we'll have to create a new group. */
- if (j == ngrps)
- {
- copyset(matches, labels[ngrps]);
- zeroset(matches);
- MALLOC(grps[ngrps].elems, position, d->nleaves);
- grps[ngrps].nelem = 1;
- grps[ngrps].elems[0] = pos;
- ++ngrps;
- }
- }
-
- MALLOC(follows.elems, position, d->nleaves);
- MALLOC(tmp.elems, position, d->nleaves);
-
- /* If we are a searching matcher, the default transition is to a state
- containing the positions of state 0, otherwise the default transition
- is to fail miserably. */
- if (d->searchflag)
- {
- wants_newline = 0;
- wants_letter = 0;
- for (i = 0; i < d->states[0].elems.nelem; ++i)
- {
- if (PREV_NEWLINE_DEPENDENT(d->states[0].elems.elems[i].constraint))
- wants_newline = 1;
- if (PREV_LETTER_DEPENDENT(d->states[0].elems.elems[i].constraint))
- wants_letter = 1;
- }
- copy(&d->states[0].elems, &follows);
- state = state_index(d, &follows, 0, 0);
- if (wants_newline)
- state_newline = state_index(d, &follows, 1, 0);
- else
- state_newline = state;
- if (wants_letter)
- state_letter = state_index(d, &follows, 0, 1);
- else
- state_letter = state;
- for (i = 0; i < NOTCHAR; ++i)
- if (i == '\n')
- trans[i] = state_newline;
- else if (ISALNUM(i))
- trans[i] = state_letter;
- else
- trans[i] = state;
- }
- else
- for (i = 0; i < NOTCHAR; ++i)
- trans[i] = -1;
-
- for (i = 0; i < ngrps; ++i)
- {
- follows.nelem = 0;
-
- /* Find the union of the follows of the positions of the group.
- This is a hideously inefficient loop. Fix it someday. */
- for (j = 0; j < grps[i].nelem; ++j)
- for (k = 0; k < d->follows[grps[i].elems[j].index].nelem; ++k)
- insert(d->follows[grps[i].elems[j].index].elems[k], &follows);
-
- /* If we are building a searching matcher, throw in the positions
- of state 0 as well. */
- if (d->searchflag)
- for (j = 0; j < d->states[0].elems.nelem; ++j)
- insert(d->states[0].elems.elems[j], &follows);
-
- /* Find out if the new state will want any context information. */
- wants_newline = 0;
- if (tstbit('\n', labels[i]))
- for (j = 0; j < follows.nelem; ++j)
- if (PREV_NEWLINE_DEPENDENT(follows.elems[j].constraint))
- wants_newline = 1;
-
- wants_letter = 0;
- for (j = 0; j < CHARCLASS_INTS; ++j)
- if (labels[i][j] & letters[j])
- break;
- if (j < CHARCLASS_INTS)
- for (j = 0; j < follows.nelem; ++j)
- if (PREV_LETTER_DEPENDENT(follows.elems[j].constraint))
- wants_letter = 1;
-
- /* Find the state(s) corresponding to the union of the follows. */
- state = state_index(d, &follows, 0, 0);
- if (wants_newline)
- state_newline = state_index(d, &follows, 1, 0);
- else
- state_newline = state;
- if (wants_letter)
- state_letter = state_index(d, &follows, 0, 1);
- else
- state_letter = state;
-
- /* Set the transitions for each character in the current label. */
- for (j = 0; j < CHARCLASS_INTS; ++j)
- for (k = 0; k < INTBITS; ++k)
- if (labels[i][j] & 1 << k)
- {
- int c = j * INTBITS + k;
-
- if (c == '\n')
- trans[c] = state_newline;
- else if (ISALNUM(c))
- trans[c] = state_letter;
- else if (c < NOTCHAR)
- trans[c] = state;
- }
- }
-
- for (i = 0; i < ngrps; ++i)
- free(grps[i].elems);
- free(follows.elems);
- free(tmp.elems);
-}
-
-/* Some routines for manipulating a compiled dfa's transition tables.
- Each state may or may not have a transition table; if it does, and it
- is a non-accepting state, then d->trans[state] points to its table.
- If it is an accepting state then d->fails[state] points to its table.
- If it has no table at all, then d->trans[state] is NULL.
- TODO: Improve this comment, get rid of the unnecessary redundancy. */
-
-static void
-build_state(s, d)
- int s;
- struct dfa *d;
-{
- int *trans; /* The new transition table. */
- int i;
-
- /* Set an upper limit on the number of transition tables that will ever
- exist at once. 1024 is arbitrary. The idea is that the frequently
- used transition tables will be quickly rebuilt, whereas the ones that
- were only needed once or twice will be cleared away. */
- if (d->trcount >= 1024)
- {
- for (i = 0; i < d->tralloc; ++i)
- if (d->trans[i])
- {
- free((ptr_t) d->trans[i]);
- d->trans[i] = NULL;
- }
- else if (d->fails[i])
- {
- free((ptr_t) d->fails[i]);
- d->fails[i] = NULL;
- }
- d->trcount = 0;
- }
-
- ++d->trcount;
-
- /* Set up the success bits for this state. */
- d->success[s] = 0;
- if (ACCEPTS_IN_CONTEXT(d->states[s].newline, 1, d->states[s].letter, 0,
- s, *d))
- d->success[s] |= 4;
- if (ACCEPTS_IN_CONTEXT(d->states[s].newline, 0, d->states[s].letter, 1,
- s, *d))
- d->success[s] |= 2;
- if (ACCEPTS_IN_CONTEXT(d->states[s].newline, 0, d->states[s].letter, 0,
- s, *d))
- d->success[s] |= 1;
-
- MALLOC(trans, int, NOTCHAR);
- dfastate(s, d, trans);
-
- /* Now go through the new transition table, and make sure that the trans
- and fail arrays are allocated large enough to hold a pointer for the
- largest state mentioned in the table. */
- for (i = 0; i < NOTCHAR; ++i)
- if (trans[i] >= d->tralloc)
- {
- int oldalloc = d->tralloc;
-
- while (trans[i] >= d->tralloc)
- d->tralloc *= 2;
- REALLOC(d->realtrans, int *, d->tralloc + 1);
- d->trans = d->realtrans + 1;
- REALLOC(d->fails, int *, d->tralloc);
- REALLOC(d->success, int, d->tralloc);
- REALLOC(d->newlines, int, d->tralloc);
- while (oldalloc < d->tralloc)
- {
- d->trans[oldalloc] = NULL;
- d->fails[oldalloc++] = NULL;
- }
- }
-
- /* Keep the newline transition in a special place so we can use it as
- a sentinel. */
- d->newlines[s] = trans['\n'];
- trans['\n'] = -1;
-
- if (ACCEPTING(s, *d))
- d->fails[s] = trans;
- else
- d->trans[s] = trans;
-}
-
-static void
-build_state_zero(d)
- struct dfa *d;
-{
- d->tralloc = 1;
- d->trcount = 0;
- CALLOC(d->realtrans, int *, d->tralloc + 1);
- d->trans = d->realtrans + 1;
- CALLOC(d->fails, int *, d->tralloc);
- MALLOC(d->success, int, d->tralloc);
- MALLOC(d->newlines, int, d->tralloc);
- build_state(0, d);
-}
-
-/* Search through a buffer looking for a match to the given struct dfa.
- Find the first occurrence of a string matching the regexp in the buffer,
- and the shortest possible version thereof. Return a pointer to the first
- character after the match, or NULL if none is found. Begin points to
- the beginning of the buffer, and end points to the first character after
- its end. We store a newline in *end to act as a sentinel, so end had
- better point somewhere valid. Newline is a flag indicating whether to
- allow newlines to be in the matching string. If count is non-
- NULL it points to a place we're supposed to increment every time we
- see a newline. Finally, if backref is non-NULL it points to a place
- where we're supposed to store a 1 if backreferencing happened and the
- match needs to be verified by a backtracking matcher. Otherwise
- we store a 0 in *backref. */
-char *
-dfaexec(d, begin, end, newline, count, backref)
- struct dfa *d;
- char *begin;
- char *end;
- int newline;
- int *count;
- int *backref;
-{
- register s, s1, tmp; /* Current state. */
- register unsigned char *p; /* Current input character. */
- register **trans, *t; /* Copy of d->trans so it can be optimized
- into a register. */
- static sbit[NOTCHAR]; /* Table for anding with d->success. */
- static sbit_init;
-
- if (! sbit_init)
- {
- int i;
-
- sbit_init = 1;
- for (i = 0; i < NOTCHAR; ++i)
- if (i == '\n')
- sbit[i] = 4;
- else if (ISALNUM(i))
- sbit[i] = 2;
- else
- sbit[i] = 1;
- }
-
- if (! d->tralloc)
- build_state_zero(d);
-
- s = s1 = 0;
- p = (unsigned char *) begin;
- trans = d->trans;
- *end = '\n';
-
- for (;;)
- {
- /* The dreaded inner loop. */
- if ((t = trans[s]) != 0)
- do
- {
- s1 = t[*p++];
- if (! (t = trans[s1]))
- goto last_was_s;
- s = t[*p++];
- }
- while ((t = trans[s]) != 0);
- goto last_was_s1;
- last_was_s:
- tmp = s, s = s1, s1 = tmp;
- last_was_s1:
-
- if (s >= 0 && p <= (unsigned char *) end && d->fails[s])
- {
- if (d->success[s] & sbit[*p])
- {
- if (backref)
- if (d->states[s].backref)
- *backref = 1;
- else
- *backref = 0;
- return (char *) p;
- }
-
- s1 = s;
- s = d->fails[s][*p++];
- continue;
- }
-
- /* If the previous character was a newline, count it. */
- if (count && (char *) p <= end && p[-1] == '\n')
- ++*count;
-
- /* Check if we've run off the end of the buffer. */
- if ((char *) p > end)
- return NULL;
-
- if (s >= 0)
- {
- build_state(s, d);
- trans = d->trans;
- continue;
- }
-
- if (p[-1] == '\n' && newline)
- {
- s = d->newlines[s1];
- continue;
- }
-
- s = 0;
- }
-}
-
-/* Initialize the components of a dfa that the other routines don't
- initialize for themselves. */
-void
-dfainit(d)
- struct dfa *d;
-{
- d->calloc = 1;
- MALLOC(d->charclasses, charclass, d->calloc);
- d->cindex = 0;
-
- d->talloc = 1;
- MALLOC(d->tokens, token, d->talloc);
- d->tindex = d->depth = d->nleaves = d->nregexps = 0;
-
- d->searchflag = 0;
- d->tralloc = 0;
-
- d->musts = 0;
-}
-
-/* Parse and analyze a single string of the given length. */
-void
-dfacomp(s, len, d, searchflag)
- char *s;
- size_t len;
- struct dfa *d;
- int searchflag;
-{
- if (case_fold) /* dummy folding in service of dfamust() */
- {
- char *copy;
- int i;
-
- copy = malloc(len);
- if (!copy)
- dfaerror("out of memory");
-
- /* This is a kludge. */
- case_fold = 0;
- for (i = 0; i < len; ++i)
- if (ISUPPER(s[i]))
- copy[i] = tolower((unsigned char)s[i]);
- else
- copy[i] = s[i];
-
- dfainit(d);
- dfaparse(copy, len, d);
- free(copy);
- dfamust(d);
- d->cindex = d->tindex = d->depth = d->nleaves = d->nregexps = 0;
- case_fold = 1;
- dfaparse(s, len, d);
- dfaanalyze(d, searchflag);
- }
- else
- {
- dfainit(d);
- dfaparse(s, len, d);
- dfamust(d);
- dfaanalyze(d, searchflag);
- }
-}
-
-/* Free the storage held by the components of a dfa. */
-void
-dfafree(d)
- struct dfa *d;
-{
- int i;
- struct dfamust *dm, *ndm;
-
- free((ptr_t) d->charclasses);
- free((ptr_t) d->tokens);
- for (i = 0; i < d->sindex; ++i)
- free((ptr_t) d->states[i].elems.elems);
- free((ptr_t) d->states);
- for (i = 0; i < d->tindex; ++i)
- if (d->follows[i].elems)
- free((ptr_t) d->follows[i].elems);
- free((ptr_t) d->follows);
- for (i = 0; i < d->tralloc; ++i)
- if (d->trans[i])
- free((ptr_t) d->trans[i]);
- else if (d->fails[i])
- free((ptr_t) d->fails[i]);
- free((ptr_t) d->realtrans);
- free((ptr_t) d->fails);
- free((ptr_t) d->newlines);
- for (dm = d->musts; dm; dm = ndm)
- {
- ndm = dm->next;
- free(dm->must);
- free((ptr_t) dm);
- }
-}
-
-/* Having found the postfix representation of the regular expression,
- try to find a long sequence of characters that must appear in any line
- containing the r.e.
- Finding a "longest" sequence is beyond the scope here;
- we take an easy way out and hope for the best.
- (Take "(ab|a)b"--please.)
-
- We do a bottom-up calculation of sequences of characters that must appear
- in matches of r.e.'s represented by trees rooted at the nodes of the postfix
- representation:
- sequences that must appear at the left of the match ("left")
- sequences that must appear at the right of the match ("right")
- lists of sequences that must appear somewhere in the match ("in")
- sequences that must constitute the match ("is")
-
- When we get to the root of the tree, we use one of the longest of its
- calculated "in" sequences as our answer. The sequence we find is returned in
- d->must (where "d" is the single argument passed to "dfamust");
- the length of the sequence is returned in d->mustn.
-
- The sequences calculated for the various types of node (in pseudo ANSI c)
- are shown below. "p" is the operand of unary operators (and the left-hand
- operand of binary operators); "q" is the right-hand operand of binary
- operators.
-
- "ZERO" means "a zero-length sequence" below.
-
- Type left right is in
- ---- ---- ----- -- --
- char c # c # c # c # c
-
- CSET ZERO ZERO ZERO ZERO
-
- STAR ZERO ZERO ZERO ZERO
-
- QMARK ZERO ZERO ZERO ZERO
-
- PLUS p->left p->right ZERO p->in
-
- CAT (p->is==ZERO)? (q->is==ZERO)? (p->is!=ZERO && p->in plus
- p->left : q->right : q->is!=ZERO) ? q->in plus
- p->is##q->left p->right##q->is p->is##q->is : p->right##q->left
- ZERO
-
- OR longest common longest common (do p->is and substrings common to
- leading trailing q->is have same p->in and q->in
- (sub)sequence (sub)sequence length and
- of p->left of p->right content) ?
- and q->left and q->right p->is : NULL
-
- If there's anything else we recognize in the tree, all four sequences get set
- to zero-length sequences. If there's something we don't recognize in the tree,
- we just return a zero-length sequence.
-
- Break ties in favor of infrequent letters (choosing 'zzz' in preference to
- 'aaa')?
-
- And. . .is it here or someplace that we might ponder "optimizations" such as
- egrep 'psi|epsilon' -> egrep 'psi'
- egrep 'pepsi|epsilon' -> egrep 'epsi'
- (Yes, we now find "epsi" as a "string
- that must occur", but we might also
- simplify the *entire* r.e. being sought)
- grep '[c]' -> grep 'c'
- grep '(ab|a)b' -> grep 'ab'
- grep 'ab*' -> grep 'a'
- grep 'a*b' -> grep 'b'
-
- There are several issues:
-
- Is optimization easy (enough)?
-
- Does optimization actually accomplish anything,
- or is the automaton you get from "psi|epsilon" (for example)
- the same as the one you get from "psi" (for example)?
-
- Are optimizable r.e.'s likely to be used in real-life situations
- (something like 'ab*' is probably unlikely; something like is
- 'psi|epsilon' is likelier)? */
-
-static char *
-icatalloc(old, new)
- char *old;
- char *new;
-{
- char *result;
- int oldsize, newsize;
-
- newsize = (new == NULL) ? 0 : strlen(new);
- if (old == NULL)
- oldsize = 0;
- else if (newsize == 0)
- return old;
- else oldsize = strlen(old);
- if (old == NULL)
- result = (char *) malloc(newsize + 1);
- else
- result = (char *) realloc((void *) old, oldsize + newsize + 1);
- if (result != NULL && new != NULL)
- (void) strcpy(result + oldsize, new);
- return result;
-}
-
-static char *
-icpyalloc(string)
- char *string;
-{
- return icatalloc((char *) NULL, string);
-}
-
-static char *
-istrstr(lookin, lookfor)
- char *lookin;
- char *lookfor;
-{
- char *cp;
- int len;
-
- len = strlen(lookfor);
- for (cp = lookin; *cp != '\0'; ++cp)
- if (strncmp(cp, lookfor, len) == 0)
- return cp;
- return NULL;
-}
-
-static void
-ifree(cp)
- char *cp;
-{
- if (cp != NULL)
- free(cp);
-}
-
-static void
-freelist(cpp)
- char **cpp;
-{
- int i;
-
- if (cpp == NULL)
- return;
- for (i = 0; cpp[i] != NULL; ++i)
- {
- free(cpp[i]);
- cpp[i] = NULL;
- }
-}
-
-static char **
-enlist(cpp, new, len)
- char **cpp;
- char *new;
- int len;
-{
- int i, j;
-
- if (cpp == NULL)
- return NULL;
- if ((new = icpyalloc(new)) == NULL)
- {
- freelist(cpp);
- return NULL;
- }
- new[len] = '\0';
- /* Is there already something in the list that's new (or longer)? */
- for (i = 0; cpp[i] != NULL; ++i)
- if (istrstr(cpp[i], new) != NULL)
- {
- free(new);
- return cpp;
- }
- /* Eliminate any obsoleted strings. */
- j = 0;
- while (cpp[j] != NULL)
- if (istrstr(new, cpp[j]) == NULL)
- ++j;
- else
- {
- free(cpp[j]);
- if (--i == j)
- break;
- cpp[j] = cpp[i];
- cpp[i] = NULL;
- }
- /* Add the new string. */
- cpp = (char **) realloc((char *) cpp, (i + 2) * sizeof *cpp);
- if (cpp == NULL)
- return NULL;
- cpp[i] = new;
- cpp[i + 1] = NULL;
- return cpp;
-}
-
-/* Given pointers to two strings, return a pointer to an allocated
- list of their distinct common substrings. Return NULL if something
- seems wild. */
-static char **
-comsubs(left, right)
- char *left;
- char *right;
-{
- char **cpp;
- char *lcp;
- char *rcp;
- int i, len;
-
- if (left == NULL || right == NULL)
- return NULL;
- cpp = (char **) malloc(sizeof *cpp);
- if (cpp == NULL)
- return NULL;
- cpp[0] = NULL;
- for (lcp = left; *lcp != '\0'; ++lcp)
- {
- len = 0;
- rcp = index(right, *lcp);
- while (rcp != NULL)
- {
- for (i = 1; lcp[i] != '\0' && lcp[i] == rcp[i]; ++i)
- ;
- if (i > len)
- len = i;
- rcp = index(rcp + 1, *lcp);
- }
- if (len == 0)
- continue;
- if ((cpp = enlist(cpp, lcp, len)) == NULL)
- break;
- }
- return cpp;
-}
-
-static char **
-addlists(old, new)
-char **old;
-char **new;
-{
- int i;
-
- if (old == NULL || new == NULL)
- return NULL;
- for (i = 0; new[i] != NULL; ++i)
- {
- old = enlist(old, new[i], strlen(new[i]));
- if (old == NULL)
- break;
- }
- return old;
-}
-
-/* Given two lists of substrings, return a new list giving substrings
- common to both. */
-static char **
-inboth(left, right)
- char **left;
- char **right;
-{
- char **both;
- char **temp;
- int lnum, rnum;
-
- if (left == NULL || right == NULL)
- return NULL;
- both = (char **) malloc(sizeof *both);
- if (both == NULL)
- return NULL;
- both[0] = NULL;
- for (lnum = 0; left[lnum] != NULL; ++lnum)
- {
- for (rnum = 0; right[rnum] != NULL; ++rnum)
- {
- temp = comsubs(left[lnum], right[rnum]);
- if (temp == NULL)
- {
- freelist(both);
- return NULL;
- }
- both = addlists(both, temp);
- freelist(temp);
- if (both == NULL)
- return NULL;
- }
- }
- return both;
-}
-
-typedef struct
-{
- char **in;
- char *left;
- char *right;
- char *is;
-} must;
-
-static void
-resetmust(mp)
-must *mp;
-{
- mp->left[0] = mp->right[0] = mp->is[0] = '\0';
- freelist(mp->in);
-}
-
-static void
-dfamust(dfa)
-struct dfa *dfa;
-{
- must *musts;
- must *mp;
- char *result;
- int ri;
- int i;
- int exact;
- token t;
- static must must0;
- struct dfamust *dm;
-
- result = "";
- exact = 0;
- musts = (must *) malloc((dfa->tindex + 1) * sizeof *musts);
- if (musts == NULL)
- return;
- mp = musts;
- for (i = 0; i <= dfa->tindex; ++i)
- mp[i] = must0;
- for (i = 0; i <= dfa->tindex; ++i)
- {
- mp[i].in = (char **) malloc(sizeof *mp[i].in);
- mp[i].left = malloc(2);
- mp[i].right = malloc(2);
- mp[i].is = malloc(2);
- if (mp[i].in == NULL || mp[i].left == NULL ||
- mp[i].right == NULL || mp[i].is == NULL)
- goto done;
- mp[i].left[0] = mp[i].right[0] = mp[i].is[0] = '\0';
- mp[i].in[0] = NULL;
- }
-#ifdef DEBUG
- fprintf(stderr, "dfamust:\n");
- for (i = 0; i < dfa->tindex; ++i)
- {
- fprintf(stderr, " %d:", i);
- prtok(dfa->tokens[i]);
- }
- putc('\n', stderr);
-#endif
- for (ri = 0; ri < dfa->tindex; ++ri)
- {
- switch (t = dfa->tokens[ri])
- {
- case LPAREN:
- case RPAREN:
- goto done; /* "cannot happen" */
- case EMPTY:
- case BEGLINE:
- case ENDLINE:
- case BEGWORD:
- case ENDWORD:
- case LIMWORD:
- case NOTLIMWORD:
- case BACKREF:
- resetmust(mp);
- break;
- case STAR:
- case QMARK:
- if (mp <= musts)
- goto done; /* "cannot happen" */
- --mp;
- resetmust(mp);
- break;
- case OR:
- case ORTOP:
- if (mp < &musts[2])
- goto done; /* "cannot happen" */
- {
- char **new;
- must *lmp;
- must *rmp;
- int j, ln, rn, n;
-
- rmp = --mp;
- lmp = --mp;
- /* Guaranteed to be. Unlikely, but. . . */
- if (strcmp(lmp->is, rmp->is) != 0)
- lmp->is[0] = '\0';
- /* Left side--easy */
- i = 0;
- while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i])
- ++i;
- lmp->left[i] = '\0';
- /* Right side */
- ln = strlen(lmp->right);
- rn = strlen(rmp->right);
- n = ln;
- if (n > rn)
- n = rn;
- for (i = 0; i < n; ++i)
- if (lmp->right[ln - i - 1] != rmp->right[rn - i - 1])
- break;
- for (j = 0; j < i; ++j)
- lmp->right[j] = lmp->right[(ln - i) + j];
- lmp->right[j] = '\0';
- new = inboth(lmp->in, rmp->in);
- if (new == NULL)
- goto done;
- freelist(lmp->in);
- free((char *) lmp->in);
- lmp->in = new;
- }
- break;
- case PLUS:
- if (mp <= musts)
- goto done; /* "cannot happen" */
- --mp;
- mp->is[0] = '\0';
- break;
- case END:
- if (mp != &musts[1])
- goto done; /* "cannot happen" */
- for (i = 0; musts[0].in[i] != NULL; ++i)
- if (strlen(musts[0].in[i]) > strlen(result))
- result = musts[0].in[i];
- if (strcmp(result, musts[0].is) == 0)
- exact = 1;
- goto done;
- case CAT:
- if (mp < &musts[2])
- goto done; /* "cannot happen" */
- {
- must *lmp;
- must *rmp;
-
- rmp = --mp;
- lmp = --mp;
- /* In. Everything in left, plus everything in
- right, plus catenation of
- left's right and right's left. */
- lmp->in = addlists(lmp->in, rmp->in);
- if (lmp->in == NULL)
- goto done;
- if (lmp->right[0] != '\0' &&
- rmp->left[0] != '\0')
- {
- char *tp;
-
- tp = icpyalloc(lmp->right);
- if (tp == NULL)
- goto done;
- tp = icatalloc(tp, rmp->left);
- if (tp == NULL)
- goto done;
- lmp->in = enlist(lmp->in, tp,
- strlen(tp));
- free(tp);
- if (lmp->in == NULL)
- goto done;
- }
- /* Left-hand */
- if (lmp->is[0] != '\0')
- {
- lmp->left = icatalloc(lmp->left,
- rmp->left);
- if (lmp->left == NULL)
- goto done;
- }
- /* Right-hand */
- if (rmp->is[0] == '\0')
- lmp->right[0] = '\0';
- lmp->right = icatalloc(lmp->right, rmp->right);
- if (lmp->right == NULL)
- goto done;
- /* Guaranteed to be */
- if (lmp->is[0] != '\0' && rmp->is[0] != '\0')
- {
- lmp->is = icatalloc(lmp->is, rmp->is);
- if (lmp->is == NULL)
- goto done;
- }
- else
- lmp->is[0] = '\0';
- }
- break;
- default:
- if (t < END)
- {
- /* "cannot happen" */
- goto done;
- }
- else if (t == '\0')
- {
- /* not on *my* shift */
- goto done;
- }
- else if (t >= CSET)
- {
- /* easy enough */
- resetmust(mp);
- }
- else
- {
- /* plain character */
- resetmust(mp);
- mp->is[0] = mp->left[0] = mp->right[0] = t;
- mp->is[1] = mp->left[1] = mp->right[1] = '\0';
- mp->in = enlist(mp->in, mp->is, 1);
- if (mp->in == NULL)
- goto done;
- }
- break;
- }
-#ifdef DEBUG
- fprintf(stderr, " node: %d:", ri);
- prtok(dfa->tokens[ri]);
- fprintf(stderr, "\n in:");
- for (i = 0; mp->in[i]; ++i)
- fprintf(stderr, " \"%s\"", mp->in[i]);
- fprintf(stderr, "\n is: \"%s\"\n", mp->is);
- fprintf(stderr, " left: \"%s\"\n", mp->left);
- fprintf(stderr, " right: \"%s\"\n", mp->right);
-#endif
- ++mp;
- }
- done:
- if (strlen(result))
- {
- dm = (struct dfamust *) malloc(sizeof (struct dfamust));
- dm->exact = exact;
- dm->must = malloc(strlen(result) + 1);
- strcpy(dm->must, result);
- dm->next = dfa->musts;
- dfa->musts = dm;
- }
- mp = musts;
- for (i = 0; i <= dfa->tindex; ++i)
- {
- freelist(mp[i].in);
- ifree((char *) mp[i].in);
- ifree(mp[i].left);
- ifree(mp[i].right);
- ifree(mp[i].is);
- }
- free((char *) mp);
-}
diff --git a/gnu/usr.bin/grep/dfa.h b/gnu/usr.bin/grep/dfa.h
deleted file mode 100644
index 32e05fc..0000000
--- a/gnu/usr.bin/grep/dfa.h
+++ /dev/null
@@ -1,360 +0,0 @@
-/* dfa.h - declarations for GNU deterministic regexp compiler
- Copyright (C) 1988 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. */
-
-/* Written June, 1988 by Mike Haertel */
-
-/* FIXME:
- 2. We should not export so much of the DFA internals.
- In addition to clobbering modularity, we eat up valuable
- name space. */
-
-/* Number of bits in an unsigned char. */
-#define CHARBITS 8
-
-/* First integer value that is greater than any character code. */
-#define NOTCHAR (1 << CHARBITS)
-
-/* INTBITS need not be exact, just a lower bound. */
-#define INTBITS (CHARBITS * sizeof (int))
-
-/* Number of ints required to hold a bit for every character. */
-#define CHARCLASS_INTS ((NOTCHAR + INTBITS - 1) / INTBITS)
-
-/* Sets of unsigned characters are stored as bit vectors in arrays of ints. */
-typedef int charclass[CHARCLASS_INTS];
-
-/* The regexp is parsed into an array of tokens in postfix form. Some tokens
- are operators and others are terminal symbols. Most (but not all) of these
- codes are returned by the lexical analyzer. */
-
-typedef enum
-{
- END = -1, /* END is a terminal symbol that matches the
- end of input; any value of END or less in
- the parse tree is such a symbol. Accepting
- states of the DFA are those that would have
- a transition on END. */
-
- /* Ordinary character values are terminal symbols that match themselves. */
-
- EMPTY = NOTCHAR, /* EMPTY is a terminal symbol that matches
- the empty string. */
-
- BACKREF, /* BACKREF is generated by \<digit>; it
- it not completely handled. If the scanner
- detects a transition on backref, it returns
- a kind of "semi-success" indicating that
- the match will have to be verified with
- a backtracking matcher. */
-
- BEGLINE, /* BEGLINE is a terminal symbol that matches
- the empty string if it is at the beginning
- of a line. */
-
- ENDLINE, /* ENDLINE is a terminal symbol that matches
- the empty string if it is at the end of
- a line. */
-
- BEGWORD, /* BEGWORD is a terminal symbol that matches
- the empty string if it is at the beginning
- of a word. */
-
- ENDWORD, /* ENDWORD is a terminal symbol that matches
- the empty string if it is at the end of
- a word. */
-
- LIMWORD, /* LIMWORD is a terminal symbol that matches
- the empty string if it is at the beginning
- or the end of a word. */
-
- NOTLIMWORD, /* NOTLIMWORD is a terminal symbol that
- matches the empty string if it is not at
- the beginning or end of a word. */
-
- QMARK, /* QMARK is an operator of one argument that
- matches zero or one occurences of its
- argument. */
-
- STAR, /* STAR is an operator of one argument that
- matches the Kleene closure (zero or more
- occurrences) of its argument. */
-
- PLUS, /* PLUS is an operator of one argument that
- matches the positive closure (one or more
- occurrences) of its argument. */
-
- REPMN, /* REPMN is a lexical token corresponding
- to the {m,n} construct. REPMN never
- appears in the compiled token vector. */
-
- CAT, /* CAT is an operator of two arguments that
- matches the concatenation of its
- arguments. CAT is never returned by the
- lexical analyzer. */
-
- OR, /* OR is an operator of two arguments that
- matches either of its arguments. */
-
- ORTOP, /* OR at the toplevel in the parse tree.
- This is used for a boyer-moore heuristic. */
-
- LPAREN, /* LPAREN never appears in the parse tree,
- it is only a lexeme. */
-
- RPAREN, /* RPAREN never appears in the parse tree. */
-
- CSET /* CSET and (and any value greater) is a
- terminal symbol that matches any of a
- class of characters. */
-} token;
-
-/* Sets are stored in an array in the compiled dfa; the index of the
- array corresponding to a given set token is given by SET_INDEX(t). */
-#define SET_INDEX(t) ((t) - CSET)
-
-/* Sometimes characters can only be matched depending on the surrounding
- context. Such context decisions depend on what the previous character
- was, and the value of the current (lookahead) character. Context
- dependent constraints are encoded as 8 bit integers. Each bit that
- is set indicates that the constraint succeeds in the corresponding
- context.
-
- bit 7 - previous and current are newlines
- bit 6 - previous was newline, current isn't
- bit 5 - previous wasn't newline, current is
- bit 4 - neither previous nor current is a newline
- bit 3 - previous and current are word-constituents
- bit 2 - previous was word-constituent, current isn't
- bit 1 - previous wasn't word-constituent, current is
- bit 0 - neither previous nor current is word-constituent
-
- Word-constituent characters are those that satisfy isalnum().
-
- The macro SUCCEEDS_IN_CONTEXT determines whether a a given constraint
- succeeds in a particular context. Prevn is true if the previous character
- was a newline, currn is true if the lookahead character is a newline.
- Prevl and currl similarly depend upon whether the previous and current
- characters are word-constituent letters. */
-#define MATCHES_NEWLINE_CONTEXT(constraint, prevn, currn) \
- ((constraint) & 1 << (((prevn) ? 2 : 0) + ((currn) ? 1 : 0) + 4))
-#define MATCHES_LETTER_CONTEXT(constraint, prevl, currl) \
- ((constraint) & 1 << (((prevl) ? 2 : 0) + ((currl) ? 1 : 0)))
-#define SUCCEEDS_IN_CONTEXT(constraint, prevn, currn, prevl, currl) \
- (MATCHES_NEWLINE_CONTEXT(constraint, prevn, currn) \
- && MATCHES_LETTER_CONTEXT(constraint, prevl, currl))
-
-/* The following macros give information about what a constraint depends on. */
-#define PREV_NEWLINE_DEPENDENT(constraint) \
- (((constraint) & 0xc0) >> 2 != ((constraint) & 0x30))
-#define PREV_LETTER_DEPENDENT(constraint) \
- (((constraint) & 0x0c) >> 2 != ((constraint) & 0x03))
-
-/* Tokens that match the empty string subject to some constraint actually
- work by applying that constraint to determine what may follow them,
- taking into account what has gone before. The following values are
- the constraints corresponding to the special tokens previously defined. */
-#define NO_CONSTRAINT 0xff
-#define BEGLINE_CONSTRAINT 0xcf
-#define ENDLINE_CONSTRAINT 0xaf
-#define BEGWORD_CONSTRAINT 0xf2
-#define ENDWORD_CONSTRAINT 0xf4
-#define LIMWORD_CONSTRAINT 0xf6
-#define NOTLIMWORD_CONSTRAINT 0xf9
-
-/* States of the recognizer correspond to sets of positions in the parse
- tree, together with the constraints under which they may be matched.
- So a position is encoded as an index into the parse tree together with
- a constraint. */
-typedef struct
-{
- unsigned index; /* Index into the parse array. */
- unsigned constraint; /* Constraint for matching this position. */
-} position;
-
-/* Sets of positions are stored as arrays. */
-typedef struct
-{
- position *elems; /* Elements of this position set. */
- int nelem; /* Number of elements in this set. */
-} position_set;
-
-/* A state of the dfa consists of a set of positions, some flags,
- and the token value of the lowest-numbered position of the state that
- contains an END token. */
-typedef struct
-{
- int hash; /* Hash of the positions of this state. */
- position_set elems; /* Positions this state could match. */
- char newline; /* True if previous state matched newline. */
- char letter; /* True if previous state matched a letter. */
- char backref; /* True if this state matches a \<digit>. */
- unsigned char constraint; /* Constraint for this state to accept. */
- int first_end; /* Token value of the first END in elems. */
-} dfa_state;
-
-/* Element of a list of strings, at least one of which is known to
- appear in any R.E. matching the DFA. */
-struct dfamust
-{
- int exact;
- char *must;
- struct dfamust *next;
-};
-
-/* A compiled regular expression. */
-struct dfa
-{
- /* Stuff built by the scanner. */
- charclass *charclasses; /* Array of character sets for CSET tokens. */
- int cindex; /* Index for adding new charclasses. */
- int calloc; /* Number of charclasses currently allocated. */
-
- /* Stuff built by the parser. */
- token *tokens; /* Postfix parse array. */
- int tindex; /* Index for adding new tokens. */
- int talloc; /* Number of tokens currently allocated. */
- int depth; /* Depth required of an evaluation stack
- used for depth-first traversal of the
- parse tree. */
- int nleaves; /* Number of leaves on the parse tree. */
- int nregexps; /* Count of parallel regexps being built
- with dfaparse(). */
-
- /* Stuff owned by the state builder. */
- dfa_state *states; /* States of the dfa. */
- int sindex; /* Index for adding new states. */
- int salloc; /* Number of states currently allocated. */
-
- /* Stuff built by the structure analyzer. */
- position_set *follows; /* Array of follow sets, indexed by position
- index. The follow of a position is the set
- of positions containing characters that
- could conceivably follow a character
- matching the given position in a string
- matching the regexp. Allocated to the
- maximum possible position index. */
- int searchflag; /* True if we are supposed to build a searching
- as opposed to an exact matcher. A searching
- matcher finds the first and shortest string
- matching a regexp anywhere in the buffer,
- whereas an exact matcher finds the longest
- string matching, but anchored to the
- beginning of the buffer. */
-
- /* Stuff owned by the executor. */
- int tralloc; /* Number of transition tables that have
- slots so far. */
- int trcount; /* Number of transition tables that have
- actually been built. */
- int **trans; /* Transition tables for states that can
- never accept. If the transitions for a
- state have not yet been computed, or the
- state could possibly accept, its entry in
- this table is NULL. */
- int **realtrans; /* Trans always points to realtrans + 1; this
- is so trans[-1] can contain NULL. */
- int **fails; /* Transition tables after failing to accept
- on a state that potentially could do so. */
- int *success; /* Table of acceptance conditions used in
- dfaexec and computed in build_state. */
- int *newlines; /* Transitions on newlines. The entry for a
- newline in any transition table is always
- -1 so we can count lines without wasting
- too many cycles. The transition for a
- newline is stored separately and handled
- as a special case. Newline is also used
- as a sentinel at the end of the buffer. */
- struct dfamust *musts; /* List of strings, at least one of which
- is known to appear in any r.e. matching
- the dfa. */
-};
-
-/* Some macros for user access to dfa internals. */
-
-/* ACCEPTING returns true if s could possibly be an accepting state of r. */
-#define ACCEPTING(s, r) ((r).states[s].constraint)
-
-/* ACCEPTS_IN_CONTEXT returns true if the given state accepts in the
- specified context. */
-#define ACCEPTS_IN_CONTEXT(prevn, currn, prevl, currl, state, dfa) \
- SUCCEEDS_IN_CONTEXT((dfa).states[state].constraint, \
- prevn, currn, prevl, currl)
-
-/* FIRST_MATCHING_REGEXP returns the index number of the first of parallel
- regexps that a given state could accept. Parallel regexps are numbered
- starting at 1. */
-#define FIRST_MATCHING_REGEXP(state, dfa) (-(dfa).states[state].first_end)
-
-/* Entry points. */
-
-#if __STDC__
-
-/* dfasyntax() takes two arguments; the first sets the syntax bits described
- earlier in this file, and the second sets the case-folding flag. */
-extern void dfasyntax(int, int);
-
-/* Compile the given string of the given length into the given struct dfa.
- Final argument is a flag specifying whether to build a searching or an
- exact matcher. */
-extern void dfacomp(char *, size_t, struct dfa *, int);
-
-/* Execute the given struct dfa on the buffer of characters. The
- first char * points to the beginning, and the second points to the
- first character after the end of the buffer, which must be a writable
- place so a sentinel end-of-buffer marker can be stored there. The
- second-to-last argument is a flag telling whether to allow newlines to
- be part of a string matching the regexp. The next-to-last argument,
- if non-NULL, points to a place to increment every time we see a
- newline. The final argument, if non-NULL, points to a flag that will
- be set if further examination by a backtracking matcher is needed in
- order to verify backreferencing; otherwise the flag will be cleared.
- Returns NULL if no match is found, or a pointer to the first
- character after the first & shortest matching string in the buffer. */
-extern char *dfaexec(struct dfa *, char *, char *, int, int *, int *);
-
-/* Free the storage held by the components of a struct dfa. */
-extern void dfafree(struct dfa *);
-
-/* Entry points for people who know what they're doing. */
-
-/* Initialize the components of a struct dfa. */
-extern void dfainit(struct dfa *);
-
-/* Incrementally parse a string of given length into a struct dfa. */
-extern void dfaparse(char *, size_t, struct dfa *);
-
-/* Analyze a parsed regexp; second argument tells whether to build a searching
- or an exact matcher. */
-extern void dfaanalyze(struct dfa *, int);
-
-/* Compute, for each possible character, the transitions out of a given
- state, storing them in an array of integers. */
-extern void dfastate(int, struct dfa *, int []);
-
-/* Error handling. */
-
-/* dfaerror() is called by the regexp routines whenever an error occurs. It
- takes a single argument, a NUL-terminated string describing the error.
- The default dfaerror() prints the error message to stderr and exits.
- The user can provide a different dfafree() if so desired. */
-extern void dfaerror(char *);
-
-#else /* ! __STDC__ */
-extern void dfasyntax(), dfacomp(), dfafree(), dfainit(), dfaparse();
-extern void dfaanalyze(), dfastate(), dfaerror();
-extern char *dfaexec();
-#endif /* ! __STDC__ */
diff --git a/gnu/usr.bin/grep/getopt.c b/gnu/usr.bin/grep/getopt.c
deleted file mode 100644
index a59a013..0000000
--- a/gnu/usr.bin/grep/getopt.c
+++ /dev/null
@@ -1,731 +0,0 @@
-/* Getopt for GNU.
- NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
- before changing it!
-
- Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
- 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* NOTE!!! AIX requires this to be the first thing in the file.
- Do not put ANYTHING before it! */
-#if !defined (__GNUC__) && defined (_AIX)
- #pragma alloca
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not __GNUC__ */
-#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
-#include <alloca.h>
-#else
-#ifndef _AIX
-char *alloca ();
-#endif
-#endif /* alloca.h */
-#endif /* not __GNUC__ */
-
-#if !__STDC__ && !defined(const) && IN_GCC
-#define const
-#endif
-
-/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
-#ifndef _NO_PROTO
-#define _NO_PROTO
-#endif
-
-#include <stdio.h>
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-#undef alloca
-/* Don't include stdlib.h for non-GNU C libraries because some of them
- contain conflicting prototypes for getopt. */
-#include <stdlib.h>
-#else /* Not GNU C library. */
-#define __alloca alloca
-#endif /* GNU C library. */
-
-/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
- long-named option. Because this is not POSIX.2 compliant, it is
- being phased out. */
-/* #define GETOPT_COMPAT */
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- to intersperse the options with the other arguments.
-
- As `getopt' works, it permutes the elements of ARGV so that,
- when it is done, all the options precede everything else. Thus
- all application programs are extended to handle flexible argument order.
-
- Setting the environment variable POSIXLY_CORRECT disables permutation.
- Then the behavior is completely standard.
-
- GNU application programs can use a third alternative mode in which
- they can distinguish the relative order of options and other arguments. */
-
-#include "getopt.h"
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-char *optarg = 0;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-/* XXX 1003.2 says this must be 1 before any call. */
-int optind = 0;
-
-/* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
-static char *nextchar;
-
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-int optopt = '?';
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
- If the caller did not specify anything,
- the default is REQUIRE_ORDER if the environment variable
- POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
- REQUIRE_ORDER means don't recognize them as options;
- stop option processing when the first non-option is seen.
- This is what Unix does.
- This mode of operation is selected by either setting the environment
- variable POSIXLY_CORRECT, or using `+' as the first character
- of the list of option characters.
-
- PERMUTE is the default. We permute the contents of ARGV as we scan,
- so that eventually all the non-options are at the end. This allows options
- to be given in any order, even with programs that were not written to
- expect this.
-
- RETURN_IN_ORDER is an option available to programs that were written
- to expect options and other ARGV-elements in any order and that care about
- the ordering of the two. We describe each non-option ARGV-element
- as if it were the argument of an option with character code 1.
- Using `-' as the first character of the list of option characters
- selects this mode of operation.
-
- The special argument `--' forces an end of option-scanning regardless
- of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return EOF with `optind' != ARGC. */
-
-static enum
-{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-#ifdef __GNU_LIBRARY__
-/* We want to avoid inclusion of string.h with non-GNU libraries
- because there are many ways it can cause trouble.
- On some systems, it contains special magic macros that don't work
- in GCC. */
-#include <string.h>
-#define my_index strchr
-#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n))
-#else
-
-/* Avoid depending on library functions or files
- whose names are inconsistent. */
-
-char *getenv ();
-
-static char *
-my_index (str, chr)
- const char *str;
- int chr;
-{
- while (*str)
- {
- if (*str == chr)
- return (char *) str;
- str++;
- }
- return 0;
-}
-
-static void
-my_bcopy (from, to, size)
- const char *from;
- char *to;
- int size;
-{
- int i;
- for (i = 0; i < size; i++)
- to[i] = from[i];
-}
-#endif /* GNU C library. */
-
-/* Handle permutation of arguments. */
-
-/* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
-static int first_nonopt;
-static int last_nonopt;
-
-/* Exchange two adjacent subsequences of ARGV.
- One subsequence is elements [first_nonopt,last_nonopt)
- which contains all the non-options that have been skipped so far.
- The other is elements [last_nonopt,optind), which contains all
- the options processed since those non-options were skipped.
-
- `first_nonopt' and `last_nonopt' are relocated so that they describe
- the new indices of the non-options in ARGV after they are moved. */
-
-static void
-exchange (argv)
- char **argv;
-{
- int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *);
- char **temp = (char **) __alloca (nonopts_size);
-
- /* Interchange the two blocks of data in ARGV. */
-
- my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size);
- my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt],
- (optind - last_nonopt) * sizeof (char *));
- my_bcopy ((char *) temp,
- (char *) &argv[first_nonopt + optind - last_nonopt],
- nonopts_size);
-
- /* Update records for the slots the non-options now occupy. */
-
- first_nonopt += (optind - last_nonopt);
- last_nonopt = optind;
-}
-
-/* Scan elements of ARGV (whose length is ARGC) for option characters
- given in OPTSTRING.
-
- If an element of ARGV starts with '-', and is not exactly "-" or "--",
- then it is an option element. The characters of this element
- (aside from the initial '-') are option characters. If `getopt'
- is called repeatedly, it returns successively each of the option characters
- from each of the option elements.
-
- If `getopt' finds another option character, it returns that character,
- updating `optind' and `nextchar' so that the next call to `getopt' can
- resume the scan with the following option character or ARGV-element.
-
- If there are no more option characters, `getopt' returns `EOF'.
- Then `optind' is the index in ARGV of the first ARGV-element
- that is not an option. (The ARGV-elements have been permuted
- so that those that are not options now come last.)
-
- OPTSTRING is a string containing the legitimate option characters.
- If an option character is seen that is not listed in OPTSTRING,
- return '?' after printing an error message. If you set `opterr' to
- zero, the error message is suppressed but we still return '?'.
-
- If a char in OPTSTRING is followed by a colon, that means it wants an arg,
- so the following text in the same ARGV-element, or the text of the following
- ARGV-element, is returned in `optarg'. Two colons mean an option that
- wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `optarg', otherwise `optarg' is set to zero.
-
- If OPTSTRING starts with `-' or `+', it requests different methods of
- handling the non-option ARGV-elements.
- See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
-
- Long-named options begin with `--' instead of `-'.
- Their names may be abbreviated as long as the abbreviation is unique
- or is an exact match for some defined option. If they have an
- argument, it follows the option name in the same ARGV-element, separated
- from the option name by a `=', or else the in next ARGV-element.
- When `getopt' finds a long-named option, it returns 0 if that option's
- `flag' field is nonzero, the value of the option's `val' field
- if the `flag' field is zero.
-
- The elements of ARGV aren't really const, because we permute them.
- But we pretend they're const in the prototype to be compatible
- with other systems.
-
- LONGOPTS is a vector of `struct option' terminated by an
- element containing a name which is zero.
-
- LONGIND returns the index in LONGOPT of the long-named option found.
- It is only valid when a long-named option has been found by the most
- recent call.
-
- If LONG_ONLY is nonzero, '-' as well as '--' can introduce
- long-named options. */
-
-int
-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
- int argc;
- char *const *argv;
- const char *optstring;
- const struct option *longopts;
- int *longind;
- int long_only;
-{
- int option_index;
-
- optarg = 0;
-
- /* Initialize the internal data when the first call is made.
- Start processing options with ARGV-element 1 (since ARGV-element 0
- is the program name); the sequence of previously skipped
- non-option ARGV-elements is empty. */
-
- if (optind == 0)
- {
- first_nonopt = last_nonopt = optind = 1;
-
- nextchar = NULL;
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-')
- {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- }
- else if (optstring[0] == '+')
- {
- ordering = REQUIRE_ORDER;
- ++optstring;
- }
- else if (getenv ("POSIXLY_CORRECT") != NULL)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
- }
-
- if (nextchar == NULL || *nextchar == '\0')
- {
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Now skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < argc
- && (argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- optind++;
- last_nonopt = optind;
- }
-
- /* Special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp (argv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return EOF;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- {
- if (ordering == REQUIRE_ORDER)
- return EOF;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- Start decoding its characters. */
-
- nextchar = (argv[optind] + 1
- + (longopts != NULL && argv[optind][1] == '-'));
- }
-
- if (longopts != NULL
- && ((argv[optind][0] == '-'
- && (argv[optind][1] == '-' || long_only))
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- ))
- {
- const struct option *p;
- char *s = nextchar;
- int exact = 0;
- int ambig = 0;
- const struct option *pfound = NULL;
- int indfound;
-
- while (*s && *s != '=')
- s++;
-
- /* Test all options for either exact match or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name;
- p++, option_index++)
- if (!strncmp (p->name, nextchar, s - nextchar))
- {
- if (s - nextchar == strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' is ambiguous\n",
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- return '?';
- }
-
- if (pfound != NULL)
- {
- option_index = indfound;
- optind++;
- if (*s)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = s + 1;
- else
- {
- if (opterr)
- {
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- "%s: option `--%s' doesn't allow an argument\n",
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- "%s: option `%c%s' doesn't allow an argument\n",
- argv[0], argv[optind - 1][0], pfound->name);
- }
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' requires an argument\n",
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- /* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- || my_index (optstring, *nextchar) == NULL)
- {
- if (opterr)
- {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf (stderr, "%s: unrecognized option `--%s'\n",
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf (stderr, "%s: unrecognized option `%c%s'\n",
- argv[0], argv[optind][0], nextchar);
- }
- nextchar = (char *) "";
- optind++;
- return '?';
- }
- }
-
- /* Look at and handle the next option-character. */
-
- {
- char c = *nextchar++;
- char *temp = my_index (optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == '\0')
- ++optind;
-
- if (temp == NULL || c == ':')
- {
- if (opterr)
- {
-#if 0
- if (c < 040 || c >= 0177)
- fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
- argv[0], c);
- else
- fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
-#else
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
-#endif
- }
- optopt = c;
- return '?';
- }
- if (temp[1] == ':')
- {
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = 0;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
-#if 0
- fprintf (stderr, "%s: option `-%c' requires an argument\n",
- argv[0], c);
-#else
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, "%s: option requires an argument -- %c\n",
- argv[0], c);
-#endif
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
- }
- return c;
- }
-}
-
-int
-getopt (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
-{
- return _getopt_internal (argc, argv, optstring,
- (const struct option *) 0,
- (int *) 0,
- 0);
-}
-
-#endif /* _LIBC or not __GNU_LIBRARY__. */
-
-#ifdef TEST
-
-/* Compile with -DTEST to make an executable for use in testing
- the above definition of `getopt'. */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
-
- c = getopt (argc, argv, "abc:d:0123456789");
- if (c == EOF)
- break;
-
- switch (c)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/usr.bin/grep/getopt.h b/gnu/usr.bin/grep/getopt.h
deleted file mode 100644
index 45541f5..0000000
--- a/gnu/usr.bin/grep/getopt.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Declarations for getopt.
- Copyright (C) 1989, 1990, 1991, 1992, 1993 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef _GETOPT_H
-#define _GETOPT_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
-extern int opterr;
-
-/* Set to an option character which was unrecognized. */
-
-extern int optopt;
-
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
-struct option
-{
-#if __STDC__
- const char *name;
-#else
- char *name;
-#endif
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'. */
-
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
-
-#if __STDC__
-#if defined(__GNU_LIBRARY__)
-/* Many other libraries have conflicting prototypes for getopt, with
- differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
-extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* not __GNU_LIBRARY__ */
-extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-extern int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
-
-/* Internal only. Users should not call this directly. */
-extern int _getopt_internal (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
-#else /* not __STDC__ */
-extern int getopt ();
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-#endif /* not __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GETOPT_H */
diff --git a/gnu/usr.bin/grep/getpagesize.h b/gnu/usr.bin/grep/getpagesize.h
deleted file mode 100644
index e6bd561..0000000
--- a/gnu/usr.bin/grep/getpagesize.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifdef BSD
-#ifndef BSD4_1
-#define HAVE_GETPAGESIZE
-#endif
-#endif
-
-#ifndef HAVE_GETPAGESIZE
-
-#ifdef VMS
-#define getpagesize() 512
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef _SC_PAGESIZE
-#define getpagesize() sysconf(_SC_PAGESIZE)
-#else
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-
-#ifdef EXEC_PAGESIZE
-#define getpagesize() EXEC_PAGESIZE
-#else
-#ifdef NBPG
-#define getpagesize() NBPG * CLSIZE
-#ifndef CLSIZE
-#define CLSIZE 1
-#endif /* no CLSIZE */
-#else /* no NBPG */
-#define getpagesize() NBPC
-#endif /* no NBPG */
-#endif /* no EXEC_PAGESIZE */
-#else /* !HAVE_SYS_PARAM_H */
-#define getpagesize() 8192 /* punt totally */
-#endif /* !HAVE_SYS_PARAM_H */
-#endif /* no _SC_PAGESIZE */
-
-#endif /* not HAVE_GETPAGESIZE */
-
diff --git a/gnu/usr.bin/grep/grep.1 b/gnu/usr.bin/grep/grep.1
deleted file mode 100644
index 6f5c48a..0000000
--- a/gnu/usr.bin/grep/grep.1
+++ /dev/null
@@ -1,410 +0,0 @@
-.TH GREP 1 "1992 September 10" "GNU Project"
-.SH NAME
-grep, egrep, fgrep, zgrep \- print lines matching a pattern
-.SH SYNOPSIS
-.B grep
-[\-[AB] num]
-[\-HRPS]
-[\-CEFGLVabchilnqsvwx]
-[\-e expr]
-[\-f file]
-files...
-
-.SH DESCRIPTION
-.PP
-.B Grep
-searches the named input
-.I files
-(or standard input if no files are named, or
-the file name
-.B \-
-is given)
-for lines containing a match to the given
-.IR pattern .
-By default,
-.B grep
-prints the matching lines.
-.PP
-There are three major variants of
-.BR grep ,
-controlled by the following options.
-.PD 0
-.TP
-.B \-G
-Interpret
-.I pattern
-as a basic regular expression (see below). This is the default.
-.TP
-.B \-E
-Interpret
-.I pattern
-as an extended regular expression (see below).
-.TP
-.B \-F
-Interpret
-.I pattern
-as a list of fixed strings, separated by newlines,
-any of which is to be matched.
-.LP
-In addition, two variant programs
-.B egrep
-and
-.B fgrep
-are available.
-.B Egrep
-is similar (but not identical) to
-.BR "grep\ \-E" ,
-and is compatible with the historical Unix
-.BR egrep .
-.B Fgrep
-is the same as
-.BR "grep\ \-F" .
-When called as
-.BR zgrep ,
-the
-.BR \-Z
-option is assumed.
-.PD
-.LP
-All variants of
-.B grep
-understand the following options:
-.PD 0
-.TP
-.BI \- num
-Matches will be printed with
-.I num
-lines of leading and trailing context. However,
-.B grep
-will never print any given line more than once.
-.TP
-.BI \-A " num"
-Print
-.I num
-lines of trailing context after matching lines.
-.TP
-.BI \-B " num"
-Print
-.I num
-lines of leading context before matching lines.
-.TP
-.B \-C
-Equivalent to
-.BR \-2 .
-.TP
-.B \-V
-Print the version number of
-.B grep
-to standard error. This version number should
-be included in all bug reports (see below).
-.TP
-.B \-a
-Don't search in binary files.
-.TP
-.B \-b
-Print the byte offset within the input file before
-each line of output.
-.TP
-.B \-c
-Suppress normal output; instead print a count of
-matching lines for each input file.
-With the
-.B \-v
-option (see below), count non-matching lines.
-.TP
-.BI \-e " pattern"
-Use
-.I pattern
-as the pattern; useful to protect patterns beginning with
-.BR \- .
-.TP
-.BI \-f " file"
-Obtain the pattern from
-.IR file .
-.TP
-.B \-h
-Suppress the prefixing of filenames on output
-when multiple files are searched.
-.TP
-.B \-i
-Ignore case distinctions in both the
-.I pattern
-and the input files.
-.TP
-.B \-L
-Suppress normal output; instead print the name
-of each input file from which no output would
-normally have been printed.
-.TP
-.B \-l
-Suppress normal output; instead print
-the name of each input file from which output
-would normally have been printed.
-.TP
-.B \-n
-Prefix each line of output with the line number
-within its input file.
-.TP
-.B \-q
-Quiet; suppress normal output.
-.TP
-.B \-s
-Suppress error messages about nonexistent or unreadable files.
-.TP
-.B \-v
-Invert the sense of matching, to select non-matching lines.
-.TP
-.B \-w
-Select only those lines containing matches that form whole words.
-The test is that the matching substring must either be at the
-beginning of the line, or preceded by a non-word constituent
-character. Similarly, it must be either at the end of the line
-or followed by a non-word constituent character. Word-constituent
-characters are letters, digits, and the underscore.
-.TP
-.B \-x
-Select only those matches that exactly match the whole line.
-
-.PP
-Following options are only available if compiled with FTS library:
-.PD 0
-.TP
-.BI \-H
-If the
-.I \-R
-option is specified, symbolic links on the command line
-are followed. (Symbolic links encountered in the tree traversal
-are not followed.)
-.TP
-.BI \-L
-If the
-.I \-R
-option is specified, all symbolic links are followed.
-.TP
-.BI \-P
-If the
-.I \-R
-option is specified, no symbolic links are followed.
-.TP
-.BI \-R
-Search in the file hierarchies
-rooted in the files instead of just the files themselves.
-
-.LP
-Following option is only available if compiled with zlib library:
-.PD 0
-.TP
-.BI \-Z
-If the
-.I \-Z
-option is specified, the input data will be
-decompressed before searching.
-.TP
-.PD
-.SH "REGULAR EXPRESSIONS"
-.PP
-A regular expression is a pattern that describes a set of strings.
-Regular expressions are constructed analogously to arithmetic
-expressions, by using various operators to combine smaller expressions.
-.PP
-.B Grep
-understands two different versions of regular expression syntax:
-``basic'' and ``extended.'' In
-.RB "GNU\ " grep ,
-there is no difference in available functionality using either syntax.
-In other implementations, basic regular expressions are less powerful.
-The following description applies to extended regular expressions;
-differences for basic regular expressions are summarized afterwards.
-.PP
-The fundamental building blocks are the regular expressions that match
-a single character. Most characters, including all letters and digits,
-are regular expressions that match themselves. Any metacharacter with
-special meaning may be quoted by preceding it with a backslash.
-.PP
-A list of characters enclosed by
-.B [
-and
-.B ]
-matches any single
-character in that list; if the first character of the list
-is the caret
-.B ^
-then it matches any character
-.I not
-in the list.
-For example, the regular expression
-.B [0123456789]
-matches any single digit. A range of ASCII characters
-may be specified by giving the first and last characters, separated
-by a hyphen.
-Finally, certain named classes of characters are predefined.
-Their names are self explanatory, and they are
-.BR [:alnum:] ,
-.BR [:alpha:] ,
-.BR [:cntrl:] ,
-.BR [:digit:] ,
-.BR [:graph:] ,
-.BR [:lower:] ,
-.BR [:print:] ,
-.BR [:punct:] ,
-.BR [:space:] ,
-.BR [:upper:] ,
-and
-.BR [:xdigit:].
-For example,
-.B [[:alnum:]]
-means
-.BR [0-9A-Za-z] ,
-except the latter form is dependent upon the ASCII character encoding,
-whereas the former is portable.
-(Note that the brackets in these class names are part of the symbolic
-names, and must be included in addition to the brackets delimiting
-the bracket list.) Most metacharacters lose their special meaning
-inside lists. To include a literal
-.B ]
-place it first in the list. Similarly, to include a literal
-.B ^
-place it anywhere but first. Finally, to include a literal
-.B \-
-place it last.
-.PP
-The period
-.B .
-matches any single character.
-The symbol
-.B \ew
-is a synonym for
-.B [[:alnum:]]
-and
-.B \eW
-is a synonym for
-.BR [^[:alnum]] .
-.PP
-The caret
-.B ^
-and the dollar sign
-.B $
-are metacharacters that respectively match the empty string at the
-beginning and end of a line.
-The symbols
-.B \e<
-and
-.B \e>
-respectively match the empty string at the beginning and end of a word.
-The symbol
-.B \eb
-matches the empty string at the edge of a word,
-and
-.B \eB
-matches the empty string provided it's
-.I not
-at the edge of a word.
-.PP
-A regular expression matching a single character may be followed
-by one of several repetition operators:
-.PD 0
-.TP
-.B ?
-The preceding item is optional and matched at most once.
-.TP
-.B *
-The preceding item will be matched zero or more times.
-.TP
-.B +
-The preceding item will be matched one or more times.
-.TP
-.BI { n }
-The preceding item is matched exactly
-.I n
-times.
-.TP
-.BI { n ,}
-The preceding item is matched
-.I n
-or more times.
-.TP
-.BI {, m }
-The preceding item is optional and is matched at most
-.I m
-times.
-.TP
-.BI { n , m }
-The preceding item is matched at least
-.I n
-times, but not more than
-.I m
-times.
-.PD
-.PP
-Two regular expressions may be concatenated; the resulting
-regular expression matches any string formed by concatenating
-two substrings that respectively match the concatenated
-subexpressions.
-.PP
-Two regular expressions may be joined by the infix operator
-.BR | ;
-the resulting regular expression matches any string matching
-either subexpression.
-.PP
-Repetition takes precedence over concatenation, which in turn
-takes precedence over alternation. A whole subexpression may be
-enclosed in parentheses to override these precedence rules.
-.PP
-The backreference
-.BI \e n\c
-\&, where
-.I n
-is a single digit, matches the substring
-previously matched by the
-.IR n th
-parenthesized subexpression of the regular expression.
-.PP
-In basic regular expressions the metacharacters
-.BR ? ,
-.BR + ,
-.BR { ,
-.BR | ,
-.BR ( ,
-and
-.BR )
-lose their special meaning; instead use the backslashed
-versions
-.BR \e? ,
-.BR \e+ ,
-.BR \e{ ,
-.BR \e| ,
-.BR \e( ,
-and
-.BR \e) .
-.PP
-In
-.B egrep
-the metacharacter
-.B {
-loses its special meaning; instead use
-.BR \e{ .
-.SH DIAGNOSTICS
-.PP
-Normally, exit status is 0 if matches were found,
-and 1 if no matches were found. (The
-.B \-v
-option inverts the sense of the exit status.)
-Exit status is 2 if there were syntax errors
-in the pattern, inaccessible input files, or
-other system errors.
-.SH BUGS
-.PP
-Email bug reports to
-.BR bug-gnu-utils@prep.ai.mit.edu .
-Be sure to include the word ``grep'' somewhere in the ``Subject:'' field.
-.PP
-Large repetition counts in the
-.BI { m , n }
-construct may cause grep to use lots of memory.
-In addition,
-certain other obscure regular expressions require exponential time
-and space, and may cause
-.B grep
-to run out of memory.
-.PP
-Backreferences are very slow, and may require exponential time.
diff --git a/gnu/usr.bin/grep/grep.c b/gnu/usr.bin/grep/grep.c
deleted file mode 100644
index 9a0fe05..0000000
--- a/gnu/usr.bin/grep/grep.c
+++ /dev/null
@@ -1,1103 +0,0 @@
-/* grep.c - main driver file for grep.
- Copyright (C) 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Written July 1992 by Mike Haertel.
-
- Recursive searching and builtin decompression (libz)
- 1996/1997 by Wolfram Schneider <wosch@FreeBSD.org>. */
-
-#include <errno.h>
-#include <stdio.h>
-#ifdef __FreeBSD__
-#include <locale.h>
-#endif
-
-#ifndef errno
-extern int errno;
-#endif
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-#include <sys/types.h>
-extern char *malloc(), *realloc();
-extern void free();
-#endif
-
-#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
-#include <string.h>
-#ifdef NEED_MEMORY_H
-#include <memory.h>
-#endif
-#else
-#include <strings.h>
-#ifdef __STDC__
-extern void *memchr();
-#else
-extern char *memchr();
-#endif
-#define strrchr rindex
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#else
-#define O_RDONLY 0
-#define STDIN_FILENO 0
-extern int open(), read(), close();
-#endif
-
-#include "getpagesize.h"
-#include "grep.h"
-
-#undef MAX
-#define MAX(A,B) ((A) > (B) ? (A) : (B))
-
-/* Provide missing ANSI features if necessary. */
-
-#ifndef HAVE_STRERROR
-extern int sys_nerr;
-extern char *sys_errlist[];
-#define strerror(E) ((E) < sys_nerr ? sys_errlist[(E)] : "bogus error number")
-#endif
-
-#ifndef HAVE_MEMCHR
-#ifdef __STDC__
-#define VOID void
-#else
-#define VOID char
-#endif
-VOID *
-memchr(vp, c, n)
- VOID *vp;
- int c;
- size_t n;
-{
- unsigned char *p;
-
- for (p = (unsigned char *) vp; n--; ++p)
- if (*p == c)
- return (VOID *) p;
- return 0;
-}
-#endif
-
-/* traverse a file hierarchy library */
-#if HAVE_FTS > 0
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fts.h>
-#endif
-
-/* don't search in binary files */
-int aflag;
-
-/* Define flags declared in grep.h. */
-char *matcher;
-int match_icase;
-int match_words;
-int match_lines;
-
-/* Functions we'll use to search. */
-static void (*compile)();
-static char *(*execute)();
-
-/* For error messages. */
-static char *prog;
-static char *filename;
-static int errseen;
-
-/* Print a message and possibly an error string. Remember
- that something awful happened. */
-static void
-error(mesg, errnum)
-#ifdef __STDC__
- const
-#endif
- char *mesg;
- int errnum;
-{
- if (errnum)
- fprintf(stderr, "%s: %s: %s\n", prog, mesg, strerror(errnum));
- else
- fprintf(stderr, "%s: %s\n", prog, mesg);
- errseen = 1;
-}
-
-/* Like error(), but die horribly after printing. */
-void
-fatal(mesg, errnum)
-#ifdef __STDC__
- const
-#endif
- char *mesg;
- int errnum;
-{
- error(mesg, errnum);
- exit(2);
-}
-
-/* Interface to handle errors and fix library lossage. */
-char *
-xmalloc(size)
- size_t size;
-{
- char *result;
-
- result = malloc(size);
- if (size && !result)
- fatal("memory exhausted", 0);
- return result;
-}
-
-/* Interface to handle errors and fix some library lossage. */
-char *
-xrealloc(ptr, size)
- char *ptr;
- size_t size;
-{
- char *result;
-
- if (ptr)
- result = realloc(ptr, size);
- else
- result = malloc(size);
- if (size && !result)
- fatal("memory exhausted", 0);
- return result;
-}
-
-#if !defined(HAVE_VALLOC)
-#define valloc malloc
-#else
-#ifdef __STDC__
-extern void *valloc(size_t);
-#else
-extern char *valloc();
-#endif
-#endif
-
-/* Hairy buffering mechanism for grep. The intent is to keep
- all reads aligned on a page boundary and multiples of the
- page size. */
-
-static char *buffer; /* Base of buffer. */
-static size_t bufsalloc; /* Allocated size of buffer save region. */
-static size_t bufalloc; /* Total buffer size. */
-static int bufdesc; /* File descriptor. */
-static char *bufbeg; /* Beginning of user-visible stuff. */
-static char *buflim; /* Limit of user-visible stuff. */
-
-#if defined(HAVE_WORKING_MMAP)
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-
-static int bufmapped; /* True for ordinary files. */
-static struct stat bufstat; /* From fstat(). */
-static off_t bufoffset; /* What read() normally remembers. */
-#endif
-
-#if HAVE_LIBZ > 0
-#include <zlib.h>
-static gzFile gzbufdesc; /* zlib file descriptor. */
-static int Zflag; /* uncompress before searching */
-#endif
-
-/* Reset the buffer for a new file. Initialize
- on the first time through. */
-void
-reset(fd)
- int fd;
-{
- static int initialized;
-
- if (!initialized)
- {
- initialized = 1;
-#ifndef BUFSALLOC
- bufsalloc = MAX(8192, getpagesize());
-#else
- bufsalloc = BUFSALLOC;
-#endif
- bufalloc = 5 * bufsalloc;
- /* The 1 byte of overflow is a kludge for dfaexec(), which
- inserts a sentinel newline at the end of the buffer
- being searched. There's gotta be a better way... */
- buffer = valloc(bufalloc + 1);
- if (!buffer)
- fatal("memory exhausted", 0);
- bufbeg = buffer;
- buflim = buffer;
- }
-#if HAVE_LIBZ > 0
- if (Zflag) {
- gzbufdesc = gzdopen(fd, "r");
- if (gzbufdesc == NULL)
- fatal("memory exhausted", 0);
- }
-#endif
- bufdesc = fd;
-#if defined(HAVE_WORKING_MMAP)
- if (
-#if HAVE_LIBZ > 0
- Zflag ||
-#endif
- fstat(fd, &bufstat) < 0 || !S_ISREG(bufstat.st_mode))
- bufmapped = 0;
- else
- {
- bufmapped = 1;
- bufoffset = lseek(fd, 0, 1);
- }
-#endif
-}
-
-/* Read new stuff into the buffer, saving the specified
- amount of old stuff. When we're done, 'bufbeg' points
- to the beginning of the buffer contents, and 'buflim'
- points just after the end. Return count of new stuff. */
-static int
-fillbuf(save)
- size_t save;
-{
- char *nbuffer, *dp, *sp;
- int cc;
-#if defined(HAVE_WORKING_MMAP)
- caddr_t maddr;
-#endif
- static int pagesize;
-
- if (pagesize == 0 && (pagesize = getpagesize()) == 0)
- abort();
-
- if (save > bufsalloc)
- {
- while (save > bufsalloc)
- bufsalloc *= 2;
- bufalloc = 5 * bufsalloc;
- nbuffer = valloc(bufalloc + 1);
- if (!nbuffer)
- fatal("memory exhausted", 0);
- }
- else
- nbuffer = buffer;
-
- sp = buflim - save;
- dp = nbuffer + bufsalloc - save;
- bufbeg = dp;
- while (save--)
- *dp++ = *sp++;
-
- /* We may have allocated a new, larger buffer. Since
- there is no portable vfree(), we just have to forget
- about the old one. Sorry. */
- buffer = nbuffer;
-
-#if defined(HAVE_WORKING_MMAP)
- if (bufmapped && bufoffset % pagesize == 0
- && bufstat.st_size - bufoffset >= bufalloc - bufsalloc)
- {
- maddr = buffer + bufsalloc;
- maddr = mmap(maddr, bufalloc - bufsalloc, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_FIXED, bufdesc, bufoffset);
- if (maddr == (caddr_t) -1)
- {
- fprintf(stderr, "%s: warning: %s: %s\n", filename,
- strerror(errno));
- goto tryread;
- }
-#if 0
- /* You might thing this (or MADV_WILLNEED) would help,
- but it doesn't, at least not on a Sun running 4.1.
- In fact, it actually slows us down about 30%! */
- madvise(maddr, bufalloc - bufsalloc, MADV_SEQUENTIAL);
-#endif
- cc = bufalloc - bufsalloc;
- bufoffset += cc;
- }
- else
- {
- tryread:
- /* We come here when we're not going to use mmap() any more.
- Note that we need to synchronize the file offset the
- first time through. */
- if (bufmapped)
- {
- bufmapped = 0;
- lseek(bufdesc, bufoffset, 0);
- }
-#if HAVE_LIBZ > 0
- if (Zflag)
- cc = gzread(gzbufdesc, buffer + bufsalloc, bufalloc - bufsalloc);
- else
-#endif
- cc = read(bufdesc, buffer + bufsalloc, bufalloc - bufsalloc);
- }
-#else
-#if HAVE_LIBZ > 0
- if (Zflag)
- cc = gzread(gzbufdesc, buffer + bufsalloc, bufalloc - bufsalloc);
- else
-#endif
- cc = read(bufdesc, buffer + bufsalloc, bufalloc - bufsalloc);
-#endif
- if (cc > 0)
- buflim = buffer + bufsalloc + cc;
- else
- buflim = buffer + bufsalloc;
- return cc;
-}
-
-/* Flags controlling the style of output. */
-static int out_quiet; /* Suppress all normal output. */
-static int out_invert; /* Print nonmatching stuff. */
-static int out_file; /* Print filenames. */
-static int out_line; /* Print line numbers. */
-static int out_byte; /* Print byte offsets. */
-static int out_before; /* Lines of leading context. */
-static int out_after; /* Lines of trailing context. */
-static int count_matches; /* print a count of matching lines */
-
-/* Internal variables to keep track of byte count, context, etc. */
-static size_t totalcc; /* Total character count before bufbeg. */
-static char *lastnl; /* Pointer after last newline counted. */
-static char *lastout; /* Pointer after last character output;
- NULL if no character has been output
- or if it's conceptually before bufbeg. */
-static size_t totalnl; /* Total newline count before lastnl. */
-static int pending; /* Pending lines of output. */
-
-static void
-nlscan(lim)
- char *lim;
-{
- char *beg;
-
- for (beg = lastnl; beg < lim; ++beg)
- if (*beg == '\n')
- ++totalnl;
- lastnl = beg;
-}
-
-static void
-prline(beg, lim, sep)
- char *beg;
- char *lim;
- char sep;
-{
- if (out_file)
- printf("%s%c", filename, sep);
- if (out_line)
- {
- nlscan(beg);
- printf("%d%c", ++totalnl, sep);
- lastnl = lim;
- }
- if (out_byte)
- printf("%lu%c", totalcc + (beg - bufbeg), sep);
- fwrite(beg, 1, lim - beg, stdout);
- if (ferror(stdout))
- error("writing output", errno);
- lastout = lim;
-}
-
-/* Print pending lines of trailing context prior to LIM. */
-static void
-prpending(lim)
- char *lim;
-{
- char *nl;
-
- if (!lastout)
- lastout = bufbeg;
- while (pending > 0 && lastout < lim)
- {
- --pending;
- if ((nl = memchr(lastout, '\n', lim - lastout)) != 0)
- ++nl;
- else
- nl = lim;
- prline(lastout, nl, '-');
- }
-}
-
-/* Print the lines between BEG and LIM. Deal with context crap.
- If NLINESP is non-null, store a count of lines between BEG and LIM. */
-static void
-prtext(beg, lim, nlinesp)
- char *beg;
- char *lim;
- int *nlinesp;
-{
- static int used; /* avoid printing "--" before any output */
- char *bp, *p, *nl;
- int i, n;
-
- if (!out_quiet && pending > 0)
- prpending(beg);
-
- p = beg;
-
- if (!out_quiet)
- {
- /* Deal with leading context crap. */
-
- bp = lastout ? lastout : bufbeg;
- for (i = 0; i < out_before; ++i)
- if (p > bp)
- do
- --p;
- while (p > bp && p[-1] != '\n');
-
- /* We only print the "--" separator if our output is
- discontiguous from the last output in the file. */
- if ((out_before || out_after) && used && p != lastout)
- puts("--");
-
- while (p < beg)
- {
- nl = memchr(p, '\n', beg - p);
- prline(p, nl + 1, '-');
- p = nl + 1;
- }
- }
-
- if (nlinesp)
- {
- /* Caller wants a line count. */
- for (n = 0; p < lim; ++n)
- {
- if ((nl = memchr(p, '\n', lim - p)) != 0)
- ++nl;
- else
- nl = lim;
- if (!out_quiet)
- prline(p, nl, ':');
- p = nl;
- }
- *nlinesp = n;
- }
- else
- if (!out_quiet)
- prline(beg, lim, ':');
-
- pending = out_after;
- used = 1;
-}
-
-/* Scan the specified portion of the buffer, matching lines (or
- between matching lines if OUT_INVERT is true). Return a count of
- lines printed. */
-static int
-grepbuf(beg, lim)
- char *beg;
- char *lim;
-{
- int nlines, n;
- register char *p, *b;
- char *endp;
-
- nlines = 0;
- p = beg;
- while ((b = (*execute)(p, lim - p, &endp)) != 0)
- {
- /* Avoid matching the empty line at the end of the buffer. */
- if (b == lim && ((b > beg && b[-1] == '\n') || b == beg))
- break;
- if (!out_invert)
- {
- prtext(b, endp, (int *) 0);
- nlines += 1;
- }
- else if (p < b)
- {
- prtext(p, b, &n);
- nlines += n;
- }
- p = endp;
- }
- if (out_invert && p < lim)
- {
- prtext(p, lim, &n);
- nlines += n;
- }
- return nlines;
-}
-
-
-/*
- * try to guess if buf belong to a binary file
- */
-
-int isBinaryFile(buf, len)
- char *buf;
- int len;
-{
-#define BINARY_BUF_LEN 32
- int i;
-
- len = (len < BINARY_BUF_LEN ? len : BINARY_BUF_LEN);
-
- /* look for non-printable chars */
- for(i = 0; i < len; i++, buf++)
- if (!isprint(*buf) && !isspace(*buf))
- return(1);
-
- return(0);
-}
-
-
-
-/* Search a given file. Return a count of lines printed. */
-static int
-grep(fd)
- int fd;
-{
- int nlines, i;
- size_t residue, save;
- char *beg, *lim;
- int first, cc;
-
- reset(fd);
-
- totalcc = 0;
- lastout = 0;
- totalnl = 0;
- pending = 0;
-
- nlines = 0;
- residue = 0;
- save = 0;
- first = 0;
- cc = 0;
-
- for (;;)
- {
- if ((cc = fillbuf(save)) < 0)
- {
- error(filename, errno);
- return nlines;
- }
-
- /* skip binary files */
- if (!first && aflag && isBinaryFile(bufbeg, cc))
- return(0);
- first++;
-
- lastnl = bufbeg;
- if (lastout)
- lastout = bufbeg;
- if (buflim - bufbeg == save)
- break;
- beg = bufbeg + save - residue;
- for (lim = buflim; lim > beg && lim[-1] != '\n'; --lim)
- ;
- residue = buflim - lim;
- if (beg < lim)
- {
- nlines += grepbuf(beg, lim);
- if (pending)
- prpending(lim);
- /* optimization */
- if (nlines && out_quiet && !count_matches)
- return(nlines);
- }
- i = 0;
- beg = lim;
- while (i < out_before && beg > bufbeg && beg != lastout)
- {
- ++i;
- do
- --beg;
- while (beg > bufbeg && beg[-1] != '\n');
- }
- if (beg != lastout)
- lastout = 0;
- save = residue + lim - beg;
- totalcc += buflim - bufbeg - save;
- if (out_line)
- nlscan(beg);
- }
- if (residue)
- {
- nlines += grepbuf(bufbeg + save - residue, buflim);
- if (pending)
- prpending(buflim);
- }
- return nlines;
-}
-
-static char version[] = "GNU grep version 2.0";
-
-#define GETOPT_STD "0123456789A:B:CEFGLVX:abce:f:hilnqsvwxy"
-#if HAVE_FTS > 0
-#define GETOPT_FTS "HPRS"
-#else
-#define GETOPT_FTS ""
-#endif
-#if HAVE_LIBZ > 0
-#define GETOPT_Z "Z"
-#else
-#define GETOPT_Z ""
-#endif
-
-static void
-usage()
-{
- fprintf(stderr, "usage: %s [-[AB] <num>] [-CEFGLVX%s%s%s",
- prog, GETOPT_FTS, GETOPT_Z,
- "abchilnqsvwxy]\n [-e <expr>] [-f file] [files ...]\n");
- exit(2);
-}
-
-/* Go through the matchers vector and look for the specified matcher.
- If we find it, install it in compile and execute, and return 1. */
-int
-setmatcher(name)
- char *name;
-{
- int i;
-
- for (i = 0; matchers[i].name; ++i)
- if (strcmp(name, matchers[i].name) == 0)
- {
- compile = matchers[i].compile;
- execute = matchers[i].execute;
- return 1;
- }
- return 0;
-}
-
-
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- char *keys;
- size_t keycc, oldcc, keyalloc;
- int keyfound, no_filenames, list_files, suppress_errors;
- int opt, cc, desc, count, status;
- FILE *fp;
- extern char *optarg;
- extern int optind;
-#if HAVE_FTS > 0
- int Rflag, Hflag, Pflag, Lflag;
- FTS *ftsp;
- FTSENT *ftsent;
- int fts_options;
-#endif
-
-#ifdef __FreeBSD__
- (void) setlocale(LC_ALL, "");
-#endif
- prog = argv[0];
- if (prog && strrchr(prog, '/'))
- prog = strrchr(prog, '/') + 1;
-
- keys = NULL;
- keycc = 0;
- keyfound = 0;
- count_matches = 0;
- no_filenames = 0;
- list_files = 0;
- suppress_errors = 0;
- matcher = NULL;
- aflag = 0;
-#if HAVE_FTS > 0
- Rflag = Hflag = Pflag = Lflag = 0;
-#endif
-#if HAVE_LIBZ > 0
- if (*prog == 'z') {
- prog++;
- Zflag = 1;
- }
-#endif
-
- while ((opt = getopt(argc, argv,
- GETOPT_STD/**/GETOPT_FTS/**/GETOPT_Z)) != -1)
- switch (opt)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- out_before = 10 * out_before + opt - '0';
- out_after = 10 * out_after + opt - '0';
- break;
- case 'A':
- out_after = atoi(optarg);
- if (out_after < 0)
- usage();
- break;
- case 'B':
- out_before = atoi(optarg);
- if (out_before < 0)
- usage();
- break;
- case 'C':
- out_before = out_after = 2;
- break;
- case 'E':
- if (matcher && strcmp(matcher, "egrep") != 0)
- fatal("you may specify only one of -E, -F, or -G", 0);
- matcher = "posix-egrep";
- break;
- case 'F':
- if (matcher && strcmp(matcher, "fgrep") != 0)
- fatal("you may specify only one of -E, -F, or -G", 0);;
- matcher = "fgrep";
- break;
- case 'G':
- if (matcher && strcmp(matcher, "grep") != 0)
- fatal("you may specify only one of -E, -F, or -G", 0);
- matcher = "grep";
- break;
- case 'V':
- fprintf(stderr, "%s\n", version);
- break;
- case 'X':
- if (matcher)
- fatal("matcher already specified", 0);
- matcher = optarg;
- break;
-#if HAVE_LIBZ > 0
- case 'Z':
- Zflag = 1;
- break;
-#endif
-#if HAVE_FTS > 0
- /* symbolic links on the command line are followed */
- case 'H':
- Hflag = 1;
- Lflag = Pflag = 0;
- break;
-
- /* no symbolic links are followed */
- case 'P':
- Pflag = 1;
- Hflag = Lflag = 0;
- break;
-
- /* traverse file hierarchies */
- case 'R':
- Rflag = 1;
- break;
-
- /* all symbolic links are followed */
- case 'S':
- Lflag = 1;
- Hflag = Pflag = 0;
- break;
-#endif
- case 'a':
- aflag = 1;
- break;
- case 'b':
- out_byte = 1;
- break;
- case 'c':
- out_quiet = 1;
- count_matches = 1;
- break;
- case 'e':
- cc = strlen(optarg);
- keys = xrealloc(keys, keycc + cc + 1);
- if (keyfound)
- keys[keycc++] = '\n';
- strcpy(&keys[keycc], optarg);
- keycc += cc;
- keyfound = 1;
- break;
- case 'f':
- fp = strcmp(optarg, "-") != 0 ? fopen(optarg, "r") : stdin;
- if (!fp)
- fatal(optarg, errno);
- for (keyalloc = 1; keyalloc <= keycc; keyalloc *= 2)
- ;
- keys = xrealloc(keys, keyalloc);
- oldcc = keycc;
- if (keyfound)
- keys[keycc++] = '\n';
- while (!feof(fp)
- && (cc = fread(keys + keycc, 1, keyalloc - keycc, fp)) > 0)
- {
- keycc += cc;
- if (keycc == keyalloc)
- keys = xrealloc(keys, keyalloc *= 2);
- }
- if (fp != stdin)
- fclose(fp);
- /* Nuke the final newline to avoid matching a null string. */
- if (keycc - oldcc > 0 && keys[keycc - 1] == '\n')
- --keycc;
- keyfound = 1;
- break;
- case 'h':
- no_filenames = 1;
- break;
- case 'i':
- case 'y': /* For old-timers . . . */
- match_icase = 1;
- break;
- case 'L':
- /* Like -l, except list files that don't contain matches.
- Inspired by the same option in Hume's gre. */
- out_quiet = 1;
- list_files = -1;
- break;
- case 'l':
- out_quiet = 1;
- list_files = 1;
- break;
- case 'n':
- out_line = 1;
- break;
- case 'q':
- out_quiet = 1;
- break;
- case 's':
- suppress_errors = 1;
- break;
- case 'v':
- out_invert = 1;
- break;
- case 'w':
- match_words = 1;
- break;
- case 'x':
- match_lines = 1;
- break;
- default:
- usage();
- break;
- }
-
- if (!keyfound)
- if (optind < argc)
- {
- keys = argv[optind++];
- keycc = strlen(keys);
- }
- else
- usage();
-
- if (!matcher)
- matcher = prog;
-
- if (!setmatcher(matcher) && !setmatcher("default"))
- abort();
-
- (*compile)(keys, keycc);
-
-#if HAVE_FTS > 0
- if ((argc - optind > 1 || Rflag) && !no_filenames)
-#else
- if (argc - optind > 1 && !no_filenames)
-#endif
- out_file = 1;
-
- status = 1;
-
-#if HAVE_FTS > 0
- if (Rflag) {
- fts_options = FTS_PHYSICAL | FTS_NOCHDIR;
-
- if (Hflag)
- fts_options |= FTS_COMFOLLOW;
-
- if (Lflag) {
- fts_options |= FTS_LOGICAL;
- fts_options &= ~FTS_PHYSICAL;
- }
-
- if (Pflag) {
- fts_options &= ~FTS_LOGICAL & ~FTS_COMFOLLOW;
- fts_options |= FTS_PHYSICAL;
- }
- }
-
- if (Rflag && optind < argc) {
- int i;
-
- /* replace "-" with "/dev/stdin" */
- for (i = optind; i < argc; i++)
- if (strcmp(argv[i], "-") == 0)
- *(argv + i) = "/dev/stdin";
-
- if ((ftsp = fts_open(argv + optind, fts_options,
- (int(*)())NULL)) == NULL) {
- if (!suppress_errors)
- error("", errno);
- } else {
-
- while((ftsent = fts_read(ftsp)) != NULL) {
- filename = ftsent->fts_accpath;
-
- switch(ftsent->fts_info) {
-
- /* regular file */
- case FTS_F:
- break;
-
- /* directory */
- case FTS_D:
- case FTS_DC:
- case FTS_DP:
- continue; break;
-
- /* errors */
- case FTS_DNR:
- error(filename, errno);
- continue; break;
-
- case FTS_ERR:
- case FTS_NS:
- error(filename, ftsent->fts_errno);
- continue; break;
-
- /* dead symlink */
- case FTS_SLNONE:
- continue; break;
-
- /* symlink, don't skip */
- case FTS_SL:
- break;
-
- default:
- /*
- if (!suppress_errors)
- fprintf(stderr, "%s: ignored\n", filename);
- continue; break;
- */
-
- }
-
- if ((desc = open(filename, O_RDONLY)) == -1) {
- error(filename, errno);
- continue;
- }
-
- count = grep(desc);
- if (count_matches)
- {
- if (out_file)
- printf("%s:", filename);
- printf("%d\n", count);
- }
- if (count)
- {
- status = 0;
- if (list_files == 1)
- printf("%s\n", filename);
- }
- else if (list_files == -1)
- printf("%s\n", filename);
-
- if (desc != STDIN_FILENO) {
-#if HAVE_LIBZ > 0
- if (Zflag)
- gzclose(gzbufdesc);
- else
-#endif
- close(desc);
- }
- }
-
- if (fts_close(ftsp) == -1)
- error("fts_close", errno);
- }
-
- /* ! Rflag */
- } else
-
-#endif /* HAVE_FTS */
-
- /* search in file names from arguments, not from stdin */
- if (optind < argc)
-
- while (optind < argc)
- {
- desc = strcmp(argv[optind], "-") ?
- open(argv[optind], O_RDONLY) : STDIN_FILENO;
- if (desc < 0)
- {
- if (!suppress_errors)
- error(argv[optind], errno);
- }
- else
- {
- filename = desc == STDIN_FILENO ?
- "(standard input)" : argv[optind];
- count = grep(desc);
- if (count_matches)
- {
- if (out_file)
- printf("%s:", filename);
- printf("%d\n", count);
- }
- if (count)
- {
- status = 0;
- if (list_files == 1)
- printf("%s\n", filename);
- }
- else if (list_files == -1)
- printf("%s\n", filename);
-
- if (desc != STDIN_FILENO) {
-#if HAVE_LIBZ > 0
- if (Zflag)
- gzclose(gzbufdesc);
- else
-#endif
- close(desc);
-
- }
- }
- ++optind;
- }
-
- /* read input from stdin */
- else
- {
- filename = "(standard input)";
- count = grep(STDIN_FILENO);
- if (count_matches)
- printf("%d\n", count);
- if (count)
- {
- status = 0;
- if (list_files == 1)
- printf("(standard input)\n");
- }
- else if (list_files == -1)
- printf("(standard input)\n");
- }
-
- exit(errseen ? 2 : status);
-}
diff --git a/gnu/usr.bin/grep/grep.h b/gnu/usr.bin/grep/grep.h
deleted file mode 100644
index a3316c5..0000000
--- a/gnu/usr.bin/grep/grep.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* grep.h - interface to grep driver for searching subroutines.
- Copyright (C) 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if __STDC__
-
-extern void fatal(const char *, int);
-
-/* Grep.c expects the matchers vector to be terminated
- by an entry with a NULL name, and to contain at least
- an entry named "default". */
-
-extern struct matcher
-{
- char *name;
- void (*compile)(char *, size_t);
- char *(*execute)(char *, size_t, char **);
-} matchers[];
-
-#else
-
-extern void fatal();
-
-extern struct matcher
-{
- char *name;
- void (*compile)();
- char *(*execute)();
-} matchers[];
-
-#endif
-
-/* Exported from grep.c. */
-extern char *matcher;
-
-/* The following flags are exported from grep for the matchers
- to look at. */
-extern int match_icase; /* -i */
-extern int match_words; /* -w */
-extern int match_lines; /* -x */
diff --git a/gnu/usr.bin/grep/kwset.c b/gnu/usr.bin/grep/kwset.c
deleted file mode 100644
index afbeb64..0000000
--- a/gnu/usr.bin/grep/kwset.c
+++ /dev/null
@@ -1,805 +0,0 @@
-/* kwset.c - search for any of a set of keywords.
- Copyright 1989 Free Software Foundation
- Written August 1989 by Mike Haertel.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- 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.
-
- The author may be reached (Email) at the address mike@ai.mit.edu,
- or (US mail) as Mike Haertel c/o Free Software Foundation. */
-
-/* The algorithm implemented by these routines bears a startling resemblence
- to one discovered by Beate Commentz-Walter, although it is not identical.
- See "A String Matching Algorithm Fast on the Average," Technical Report,
- IBM-Germany, Scientific Center Heidelberg, Tiergartenstrasse 15, D-6900
- Heidelberg, Germany. See also Aho, A.V., and M. Corasick, "Efficient
- String Matching: An Aid to Bibliographic Search," CACM June 1975,
- Vol. 18, No. 6, which describes the failure function used below. */
-
-
-#ifdef STDC_HEADERS
-#include <limits.h>
-#include <stdlib.h>
-#else
-#define INT_MAX 2147483647
-#define UCHAR_MAX 255
-#ifdef __STDC__
-#include <stddef.h>
-#else
-#include <sys/types.h>
-#endif
-extern char *malloc();
-extern void free();
-#endif
-
-#ifdef HAVE_MEMCHR
-#include <string.h>
-#ifdef NEED_MEMORY_H
-#include <memory.h>
-#endif
-#else
-#ifdef __STDC__
-extern void *memchr();
-#else
-extern char *memchr();
-#endif
-#endif
-
-#ifdef GREP
-extern char *xmalloc();
-#define malloc xmalloc
-#endif
-
-#include "kwset.h"
-#include "obstack.h"
-
-#define NCHAR (UCHAR_MAX + 1)
-#define obstack_chunk_alloc malloc
-#define obstack_chunk_free free
-
-/* Balanced tree of edges and labels leaving a given trie node. */
-struct tree
-{
- struct tree *llink; /* Left link; MUST be first field. */
- struct tree *rlink; /* Right link (to larger labels). */
- struct trie *trie; /* Trie node pointed to by this edge. */
- unsigned char label; /* Label on this edge. */
- char balance; /* Difference in depths of subtrees. */
-};
-
-/* Node of a trie representing a set of reversed keywords. */
-struct trie
-{
- unsigned int accepting; /* Word index of accepted word, or zero. */
- struct tree *links; /* Tree of edges leaving this node. */
- struct trie *parent; /* Parent of this node. */
- struct trie *next; /* List of all trie nodes in level order. */
- struct trie *fail; /* Aho-Corasick failure function. */
- int depth; /* Depth of this node from the root. */
- int shift; /* Shift function for search failures. */
- int maxshift; /* Max shift of self and descendents. */
-};
-
-/* Structure returned opaquely to the caller, containing everything. */
-struct kwset
-{
- struct obstack obstack; /* Obstack for node allocation. */
- int words; /* Number of words in the trie. */
- struct trie *trie; /* The trie itself. */
- int mind; /* Minimum depth of an accepting node. */
- int maxd; /* Maximum depth of any node. */
- unsigned char delta[NCHAR]; /* Delta table for rapid search. */
- struct trie *next[NCHAR]; /* Table of children of the root. */
- char *target; /* Target string if there's only one. */
- int mind2; /* Used in Boyer-Moore search for one string. */
- char *trans; /* Character translation table. */
-};
-
-/* Allocate and initialize a keyword set object, returning an opaque
- pointer to it. Return NULL if memory is not available. */
-kwset_t
-kwsalloc(trans)
- char *trans;
-{
- struct kwset *kwset;
-
- kwset = (struct kwset *) malloc(sizeof (struct kwset));
- if (!kwset)
- return 0;
-
- obstack_init(&kwset->obstack);
- kwset->words = 0;
- kwset->trie
- = (struct trie *) obstack_alloc(&kwset->obstack, sizeof (struct trie));
- if (!kwset->trie)
- {
- kwsfree((kwset_t) kwset);
- return 0;
- }
- kwset->trie->accepting = 0;
- kwset->trie->links = 0;
- kwset->trie->parent = 0;
- kwset->trie->next = 0;
- kwset->trie->fail = 0;
- kwset->trie->depth = 0;
- kwset->trie->shift = 0;
- kwset->mind = INT_MAX;
- kwset->maxd = -1;
- kwset->target = 0;
- kwset->trans = trans;
-
- return (kwset_t) kwset;
-}
-
-/* Add the given string to the contents of the keyword set. Return NULL
- for success, an error message otherwise. */
-char *
-kwsincr(kws, text, len)
- kwset_t kws;
- char *text;
- size_t len;
-{
- struct kwset *kwset;
- register struct trie *trie;
- register unsigned char label;
- register struct tree *link;
- register int depth;
- struct tree *links[12];
- enum { L, R } dirs[12];
- struct tree *t, *r, *l, *rl, *lr;
-
- kwset = (struct kwset *) kws;
- trie = kwset->trie;
- text += len;
-
- /* Descend the trie (built of reversed keywords) character-by-character,
- installing new nodes when necessary. */
- while (len--)
- {
- label = kwset->trans ? kwset->trans[(unsigned char) *--text] : *--text;
-
- /* Descend the tree of outgoing links for this trie node,
- looking for the current character and keeping track
- of the path followed. */
- link = trie->links;
- links[0] = (struct tree *) &trie->links;
- dirs[0] = L;
- depth = 1;
-
- while (link && label != link->label)
- {
- links[depth] = link;
- if (label < link->label)
- dirs[depth++] = L, link = link->llink;
- else
- dirs[depth++] = R, link = link->rlink;
- }
-
- /* The current character doesn't have an outgoing link at
- this trie node, so build a new trie node and install
- a link in the current trie node's tree. */
- if (!link)
- {
- link = (struct tree *) obstack_alloc(&kwset->obstack,
- sizeof (struct tree));
- if (!link)
- return "memory exhausted";
- link->llink = 0;
- link->rlink = 0;
- link->trie = (struct trie *) obstack_alloc(&kwset->obstack,
- sizeof (struct trie));
- if (!link->trie)
- return "memory exhausted";
- link->trie->accepting = 0;
- link->trie->links = 0;
- link->trie->parent = trie;
- link->trie->next = 0;
- link->trie->fail = 0;
- link->trie->depth = trie->depth + 1;
- link->trie->shift = 0;
- link->label = label;
- link->balance = 0;
-
- /* Install the new tree node in its parent. */
- if (dirs[--depth] == L)
- links[depth]->llink = link;
- else
- links[depth]->rlink = link;
-
- /* Back up the tree fixing the balance flags. */
- while (depth && !links[depth]->balance)
- {
- if (dirs[depth] == L)
- --links[depth]->balance;
- else
- ++links[depth]->balance;
- --depth;
- }
-
- /* Rebalance the tree by pointer rotations if necessary. */
- if (depth && ((dirs[depth] == L && --links[depth]->balance)
- || (dirs[depth] == R && ++links[depth]->balance)))
- {
- switch (links[depth]->balance)
- {
- case (char) -2:
- switch (dirs[depth + 1])
- {
- case L:
- r = links[depth], t = r->llink, rl = t->rlink;
- t->rlink = r, r->llink = rl;
- t->balance = r->balance = 0;
- break;
- case R:
- r = links[depth], l = r->llink, t = l->rlink;
- rl = t->rlink, lr = t->llink;
- t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl;
- l->balance = t->balance != 1 ? 0 : -1;
- r->balance = t->balance != (char) -1 ? 0 : 1;
- t->balance = 0;
- break;
- }
- break;
- case 2:
- switch (dirs[depth + 1])
- {
- case R:
- l = links[depth], t = l->rlink, lr = t->llink;
- t->llink = l, l->rlink = lr;
- t->balance = l->balance = 0;
- break;
- case L:
- l = links[depth], r = l->rlink, t = r->llink;
- lr = t->llink, rl = t->rlink;
- t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl;
- l->balance = t->balance != 1 ? 0 : -1;
- r->balance = t->balance != (char) -1 ? 0 : 1;
- t->balance = 0;
- break;
- }
- break;
- }
-
- if (dirs[depth - 1] == L)
- links[depth - 1]->llink = t;
- else
- links[depth - 1]->rlink = t;
- }
- }
-
- trie = link->trie;
- }
-
- /* Mark the node we finally reached as accepting, encoding the
- index number of this word in the keyword set so far. */
- if (!trie->accepting)
- trie->accepting = 1 + 2 * kwset->words;
- ++kwset->words;
-
- /* Keep track of the longest and shortest string of the keyword set. */
- if (trie->depth < kwset->mind)
- kwset->mind = trie->depth;
- if (trie->depth > kwset->maxd)
- kwset->maxd = trie->depth;
-
- return 0;
-}
-
-/* Enqueue the trie nodes referenced from the given tree in the
- given queue. */
-static void
-enqueue(tree, last)
- struct tree *tree;
- struct trie **last;
-{
- if (!tree)
- return;
- enqueue(tree->llink, last);
- enqueue(tree->rlink, last);
- (*last) = (*last)->next = tree->trie;
-}
-
-/* Compute the Aho-Corasick failure function for the trie nodes referenced
- from the given tree, given the failure function for their parent as
- well as a last resort failure node. */
-static void
-treefails(tree, fail, recourse)
- register struct tree *tree;
- struct trie *fail;
- struct trie *recourse;
-{
- register struct tree *link;
-
- if (!tree)
- return;
-
- treefails(tree->llink, fail, recourse);
- treefails(tree->rlink, fail, recourse);
-
- /* Find, in the chain of fails going back to the root, the first
- node that has a descendent on the current label. */
- while (fail)
- {
- link = fail->links;
- while (link && tree->label != link->label)
- if (tree->label < link->label)
- link = link->llink;
- else
- link = link->rlink;
- if (link)
- {
- tree->trie->fail = link->trie;
- return;
- }
- fail = fail->fail;
- }
-
- tree->trie->fail = recourse;
-}
-
-/* Set delta entries for the links of the given tree such that
- the preexisting delta value is larger than the current depth. */
-static void
-treedelta(tree, depth, delta)
- register struct tree *tree;
- register unsigned int depth;
- unsigned char delta[];
-{
- if (!tree)
- return;
- treedelta(tree->llink, depth, delta);
- treedelta(tree->rlink, depth, delta);
- if (depth < delta[tree->label])
- delta[tree->label] = depth;
-}
-
-/* Return true if A has every label in B. */
-static int
-hasevery(a, b)
- register struct tree *a;
- register struct tree *b;
-{
- if (!b)
- return 1;
- if (!hasevery(a, b->llink))
- return 0;
- if (!hasevery(a, b->rlink))
- return 0;
- while (a && b->label != a->label)
- if (b->label < a->label)
- a = a->llink;
- else
- a = a->rlink;
- return !!a;
-}
-
-/* Compute a vector, indexed by character code, of the trie nodes
- referenced from the given tree. */
-static void
-treenext(tree, next)
- struct tree *tree;
- struct trie *next[];
-{
- if (!tree)
- return;
- treenext(tree->llink, next);
- treenext(tree->rlink, next);
- next[tree->label] = tree->trie;
-}
-
-/* Compute the shift for each trie node, as well as the delta
- table and next cache for the given keyword set. */
-char *
-kwsprep(kws)
- kwset_t kws;
-{
- register struct kwset *kwset;
- register int i;
- register struct trie *curr, *fail;
- register char *trans;
- unsigned char delta[NCHAR];
- struct trie *last, *next[NCHAR];
-
- kwset = (struct kwset *) kws;
-
- /* Initial values for the delta table; will be changed later. The
- delta entry for a given character is the smallest depth of any
- node at which an outgoing edge is labeled by that character. */
- if (kwset->mind < 256)
- for (i = 0; i < NCHAR; ++i)
- delta[i] = kwset->mind;
- else
- for (i = 0; i < NCHAR; ++i)
- delta[i] = 255;
-
- /* Check if we can use the simple boyer-moore algorithm, instead
- of the hairy commentz-walter algorithm. */
- if (kwset->words == 1 && kwset->trans == 0)
- {
- /* Looking for just one string. Extract it from the trie. */
- kwset->target = obstack_alloc(&kwset->obstack, kwset->mind);
- for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i)
- {
- kwset->target[i] = curr->links->label;
- curr = curr->links->trie;
- }
- /* Build the Boyer Moore delta. Boy that's easy compared to CW. */
- for (i = 0; i < kwset->mind; ++i)
- delta[(unsigned char) kwset->target[i]] = kwset->mind - (i + 1);
- kwset->mind2 = kwset->mind;
- /* Find the minimal delta2 shift that we might make after
- a backwards match has failed. */
- for (i = 0; i < kwset->mind - 1; ++i)
- if (kwset->target[i] == kwset->target[kwset->mind - 1])
- kwset->mind2 = kwset->mind - (i + 1);
- }
- else
- {
- /* Traverse the nodes of the trie in level order, simultaneously
- computing the delta table, failure function, and shift function. */
- for (curr = last = kwset->trie; curr; curr = curr->next)
- {
- /* Enqueue the immediate descendents in the level order queue. */
- enqueue(curr->links, &last);
-
- curr->shift = kwset->mind;
- curr->maxshift = kwset->mind;
-
- /* Update the delta table for the descendents of this node. */
- treedelta(curr->links, curr->depth, delta);
-
- /* Compute the failure function for the decendents of this node. */
- treefails(curr->links, curr->fail, kwset->trie);
-
- /* Update the shifts at each node in the current node's chain
- of fails back to the root. */
- for (fail = curr->fail; fail; fail = fail->fail)
- {
- /* If the current node has some outgoing edge that the fail
- doesn't, then the shift at the fail should be no larger
- than the difference of their depths. */
- if (!hasevery(fail->links, curr->links))
- if (curr->depth - fail->depth < fail->shift)
- fail->shift = curr->depth - fail->depth;
-
- /* If the current node is accepting then the shift at the
- fail and its descendents should be no larger than the
- difference of their depths. */
- if (curr->accepting && fail->maxshift > curr->depth - fail->depth)
- fail->maxshift = curr->depth - fail->depth;
- }
- }
-
- /* Traverse the trie in level order again, fixing up all nodes whose
- shift exceeds their inherited maxshift. */
- for (curr = kwset->trie->next; curr; curr = curr->next)
- {
- if (curr->maxshift > curr->parent->maxshift)
- curr->maxshift = curr->parent->maxshift;
- if (curr->shift > curr->maxshift)
- curr->shift = curr->maxshift;
- }
-
- /* Create a vector, indexed by character code, of the outgoing links
- from the root node. */
- for (i = 0; i < NCHAR; ++i)
- next[i] = 0;
- treenext(kwset->trie->links, next);
-
- if ((trans = kwset->trans) != 0)
- for (i = 0; i < NCHAR; ++i)
- kwset->next[i] = next[(unsigned char) trans[i]];
- else
- for (i = 0; i < NCHAR; ++i)
- kwset->next[i] = next[i];
- }
-
- /* Fix things up for any translation table. */
- if ((trans = kwset->trans) != 0)
- for (i = 0; i < NCHAR; ++i)
- kwset->delta[i] = delta[(unsigned char) trans[i]];
- else
- for (i = 0; i < NCHAR; ++i)
- kwset->delta[i] = delta[i];
-
- return 0;
-}
-
-#define U(C) ((unsigned char) (C))
-
-/* Fast boyer-moore search. */
-static char *
-bmexec(kws, text, size)
- kwset_t kws;
- char *text;
- size_t size;
-{
- struct kwset *kwset;
- register unsigned char *d1;
- register char *ep, *sp, *tp;
- register int d, gc, i, len, md2;
-
- kwset = (struct kwset *) kws;
- len = kwset->mind;
-
- if (len == 0)
- return text;
- if (len > size)
- return 0;
- if (len == 1)
- return memchr(text, kwset->target[0], size);
-
- d1 = kwset->delta;
- sp = kwset->target + len;
- gc = U(sp[-2]);
- md2 = kwset->mind2;
- tp = text + len;
-
- /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */
- if (size > 12 * len)
- /* 11 is not a bug, the initial offset happens only once. */
- for (ep = text + size - 11 * len;;)
- {
- while (tp <= ep)
- {
- d = d1[U(tp[-1])], tp += d;
- d = d1[U(tp[-1])], tp += d;
- if (d == 0)
- goto found;
- d = d1[U(tp[-1])], tp += d;
- d = d1[U(tp[-1])], tp += d;
- d = d1[U(tp[-1])], tp += d;
- if (d == 0)
- goto found;
- d = d1[U(tp[-1])], tp += d;
- d = d1[U(tp[-1])], tp += d;
- d = d1[U(tp[-1])], tp += d;
- if (d == 0)
- goto found;
- d = d1[U(tp[-1])], tp += d;
- d = d1[U(tp[-1])], tp += d;
- }
- break;
- found:
- if (U(tp[-2]) == gc)
- {
- for (i = 3; i <= len && U(tp[-i]) == U(sp[-i]); ++i)
- ;
- if (i > len)
- return tp - len;
- }
- tp += md2;
- }
-
- /* Now we have only a few characters left to search. We
- carefully avoid ever producing an out-of-bounds pointer. */
- ep = text + size;
- d = d1[U(tp[-1])];
- while (d <= ep - tp)
- {
- d = d1[U((tp += d)[-1])];
- if (d != 0)
- continue;
- if (tp[-2] == gc)
- {
- for (i = 3; i <= len && U(tp[-i]) == U(sp[-i]); ++i)
- ;
- if (i > len)
- return tp - len;
- }
- d = md2;
- }
-
- return 0;
-}
-
-/* Hairy multiple string search. */
-static char *
-cwexec(kws, text, len, kwsmatch)
- kwset_t kws;
- char *text;
- size_t len;
- struct kwsmatch *kwsmatch;
-{
- struct kwset *kwset;
- struct trie **next, *trie, *accept;
- char *beg, *lim, *mch, *lmch;
- register unsigned char c, *delta;
- register int d;
- register char *end, *qlim;
- register struct tree *tree;
- register char *trans;
-
- /* Initialize register copies and look for easy ways out. */
- kwset = (struct kwset *) kws;
- if (len < kwset->mind)
- return 0;
- next = kwset->next;
- delta = kwset->delta;
- trans = kwset->trans;
- lim = text + len;
- end = text;
- if ((d = kwset->mind) != 0)
- mch = 0;
- else
- {
- mch = text, accept = kwset->trie;
- goto match;
- }
-
- if (len >= 4 * kwset->mind)
- qlim = lim - 4 * kwset->mind;
- else
- qlim = 0;
-
- while (lim - end >= d)
- {
- if (qlim && end <= qlim)
- {
- end += d - 1;
- while ((d = delta[c = *end]) && end < qlim)
- {
- end += d;
- end += delta[(unsigned char) *end];
- end += delta[(unsigned char) *end];
- }
- ++end;
- }
- else
- d = delta[c = (end += d)[-1]];
- if (d)
- continue;
- beg = end - 1;
- trie = next[c];
- if (trie->accepting)
- {
- mch = beg;
- accept = trie;
- }
- d = trie->shift;
- while (beg > text)
- {
- c = trans ? trans[(unsigned char) *--beg] : *--beg;
- tree = trie->links;
- while (tree && c != tree->label)
- if (c < tree->label)
- tree = tree->llink;
- else
- tree = tree->rlink;
- if (tree)
- {
- trie = tree->trie;
- if (trie->accepting)
- {
- mch = beg;
- accept = trie;
- }
- }
- else
- break;
- d = trie->shift;
- }
- if (mch)
- goto match;
- }
- return 0;
-
- match:
- /* Given a known match, find the longest possible match anchored
- at or before its starting point. This is nearly a verbatim
- copy of the preceding main search loops. */
- if (lim - mch > kwset->maxd)
- lim = mch + kwset->maxd;
- lmch = 0;
- d = 1;
- while (lim - end >= d)
- {
- if ((d = delta[c = (end += d)[-1]]) != 0)
- continue;
- beg = end - 1;
- if (!(trie = next[c]))
- {
- d = 1;
- continue;
- }
- if (trie->accepting && beg <= mch)
- {
- lmch = beg;
- accept = trie;
- }
- d = trie->shift;
- while (beg > text)
- {
- c = trans ? trans[(unsigned char) *--beg] : *--beg;
- tree = trie->links;
- while (tree && c != tree->label)
- if (c < tree->label)
- tree = tree->llink;
- else
- tree = tree->rlink;
- if (tree)
- {
- trie = tree->trie;
- if (trie->accepting && beg <= mch)
- {
- lmch = beg;
- accept = trie;
- }
- }
- else
- break;
- d = trie->shift;
- }
- if (lmch)
- {
- mch = lmch;
- goto match;
- }
- if (!d)
- d = 1;
- }
-
- if (kwsmatch)
- {
- kwsmatch->index = accept->accepting / 2;
- kwsmatch->beg[0] = mch;
- kwsmatch->size[0] = accept->depth;
- }
- return mch;
-}
-
-/* Search through the given text for a match of any member of the
- given keyword set. Return a pointer to the first character of
- the matching substring, or NULL if no match is found. If FOUNDLEN
- is non-NULL store in the referenced location the length of the
- matching substring. Similarly, if FOUNDIDX is non-NULL, store
- in the referenced location the index number of the particular
- keyword matched. */
-char *
-kwsexec(kws, text, size, kwsmatch)
- kwset_t kws;
- char *text;
- size_t size;
- struct kwsmatch *kwsmatch;
-{
- struct kwset *kwset;
- char *ret;
-
- kwset = (struct kwset *) kws;
- if (kwset->words == 1 && kwset->trans == 0)
- {
- ret = bmexec(kws, text, size);
- if (kwsmatch != 0 && ret != 0)
- {
- kwsmatch->index = 0;
- kwsmatch->beg[0] = ret;
- kwsmatch->size[0] = kwset->mind;
- }
- return ret;
- }
- else
- return cwexec(kws, text, size, kwsmatch);
-}
-
-/* Free the components of the given keyword set. */
-void
-kwsfree(kws)
- kwset_t kws;
-{
- struct kwset *kwset;
-
- kwset = (struct kwset *) kws;
- obstack_free(&kwset->obstack, 0);
- free(kws);
-}
diff --git a/gnu/usr.bin/grep/kwset.h b/gnu/usr.bin/grep/kwset.h
deleted file mode 100644
index 95f62e7..0000000
--- a/gnu/usr.bin/grep/kwset.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* kwset.h - header declaring the keyword set library.
- Copyright 1989 Free Software Foundation
- Written August 1989 by Mike Haertel.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- 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.
-
- The author may be reached (Email) at the address mike@ai.mit.edu,
- or (US mail) as Mike Haertel c/o Free Software Foundation. */
-
-struct kwsmatch
-{
- int index; /* Index number of matching keyword. */
- char *beg[1]; /* Begin pointer for each submatch. */
- size_t size[1]; /* Length of each submatch. */
-};
-
-#if __STDC__
-
-typedef void *kwset_t;
-
-/* Return an opaque pointer to a newly allocated keyword set, or NULL
- if enough memory cannot be obtained. The argument if non-NULL
- specifies a table of character translations to be applied to all
- pattern and search text. */
-extern kwset_t kwsalloc(char *);
-
-/* Incrementally extend the keyword set to include the given string.
- Return NULL for success, or an error message. Remember an index
- number for each keyword included in the set. */
-extern char *kwsincr(kwset_t, char *, size_t);
-
-/* When the keyword set has been completely built, prepare it for
- use. Return NULL for success, or an error message. */
-extern char *kwsprep(kwset_t);
-
-/* Search through the given buffer for a member of the keyword set.
- Return a pointer to the leftmost longest match found, or NULL if
- no match is found. If foundlen is non-NULL, store the length of
- the matching substring in the integer it points to. Similarly,
- if foundindex is non-NULL, store the index of the particular
- keyword found therein. */
-extern char *kwsexec(kwset_t, char *, size_t, struct kwsmatch *);
-
-/* Deallocate the given keyword set and all its associated storage. */
-extern void kwsfree(kwset_t);
-
-#else
-
-typedef char *kwset_t;
-
-extern kwset_t kwsalloc();
-extern char *kwsincr();
-extern char *kwsprep();
-extern char *kwsexec();
-extern void kwsfree();
-
-#endif
diff --git a/gnu/usr.bin/grep/obstack.c b/gnu/usr.bin/grep/obstack.c
deleted file mode 100644
index 7b9d3b9..0000000
--- a/gnu/usr.bin/grep/obstack.c
+++ /dev/null
@@ -1,454 +0,0 @@
-/* obstack.c - subroutines used implicitly by object stack macros
- Copyright (C) 1988, 1993 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "obstack.h"
-
-/* This is just to get __GNU_LIBRARY__ defined. */
-#include <stdio.h>
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-
-
-#ifdef __STDC__
-#define POINTER void *
-#else
-#define POINTER char *
-#endif
-
-/* Determine default alignment. */
-struct fooalign {char x; double d;};
-#define DEFAULT_ALIGNMENT \
- ((PTR_INT_TYPE) ((char *)&((struct fooalign *) 0)->d - (char *)0))
-/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
- But in fact it might be less smart and round addresses to as much as
- DEFAULT_ROUNDING. So we prepare for it to do that. */
-union fooround {long x; double d;};
-#define DEFAULT_ROUNDING (sizeof (union fooround))
-
-/* When we copy a long block of data, this is the unit to do it with.
- On some machines, copying successive ints does not work;
- in such a case, redefine COPYING_UNIT to `long' (if that works)
- or `char' as a last resort. */
-#ifndef COPYING_UNIT
-#define COPYING_UNIT int
-#endif
-
-/* The non-GNU-C macros copy the obstack into this global variable
- to avoid multiple evaluation. */
-
-struct obstack *_obstack;
-
-/* Define a macro that either calls functions with the traditional malloc/free
- calling interface, or calls functions with the mmalloc/mfree interface
- (that adds an extra first argument), based on the state of use_extra_arg.
- For free, do not use ?:, since some compilers, like the MIPS compilers,
- do not allow (expr) ? void : void. */
-
-#define CALL_CHUNKFUN(h, size) \
- (((h) -> use_extra_arg) \
- ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
- : (*(h)->chunkfun) ((size)))
-
-#define CALL_FREEFUN(h, old_chunk) \
- do { \
- if ((h) -> use_extra_arg) \
- (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
- else \
- (*(h)->freefun) ((old_chunk)); \
- } while (0)
-
-
-/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
- Objects start on multiples of ALIGNMENT (0 means use default).
- CHUNKFUN is the function to use to allocate chunks,
- and FREEFUN the function to free them. */
-
-void
-_obstack_begin (h, size, alignment, chunkfun, freefun)
- struct obstack *h;
- int size;
- int alignment;
- POINTER (*chunkfun) ();
- void (*freefun) ();
-{
- register struct _obstack_chunk* chunk; /* points to new chunk */
-
- if (alignment == 0)
- alignment = DEFAULT_ALIGNMENT;
- if (size == 0)
- /* Default size is what GNU malloc can fit in a 4096-byte block. */
- {
- /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
- Use the values for range checking, because if range checking is off,
- the extra bytes won't be missed terribly, but if range checking is on
- and we used a larger request, a whole extra 4096 bytes would be
- allocated.
-
- These number are irrelevant to the new GNU malloc. I suspect it is
- less sensitive to the size of the request. */
- int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
- + 4 + DEFAULT_ROUNDING - 1)
- & ~(DEFAULT_ROUNDING - 1));
- size = 4096 - extra;
- }
-
- h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
- h->freefun = freefun;
- h->chunk_size = size;
- h->alignment_mask = alignment - 1;
- h->use_extra_arg = 0;
-
- chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
- h->next_free = h->object_base = chunk->contents;
- h->chunk_limit = chunk->limit
- = (char *) chunk + h->chunk_size;
- chunk->prev = 0;
- /* The initial chunk now contains no empty object. */
- h->maybe_empty_object = 0;
-}
-
-void
-_obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
- struct obstack *h;
- int size;
- int alignment;
- POINTER (*chunkfun) ();
- void (*freefun) ();
- POINTER arg;
-{
- register struct _obstack_chunk* chunk; /* points to new chunk */
-
- if (alignment == 0)
- alignment = DEFAULT_ALIGNMENT;
- if (size == 0)
- /* Default size is what GNU malloc can fit in a 4096-byte block. */
- {
- /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
- Use the values for range checking, because if range checking is off,
- the extra bytes won't be missed terribly, but if range checking is on
- and we used a larger request, a whole extra 4096 bytes would be
- allocated.
-
- These number are irrelevant to the new GNU malloc. I suspect it is
- less sensitive to the size of the request. */
- int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
- + 4 + DEFAULT_ROUNDING - 1)
- & ~(DEFAULT_ROUNDING - 1));
- size = 4096 - extra;
- }
-
- h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
- h->freefun = freefun;
- h->chunk_size = size;
- h->alignment_mask = alignment - 1;
- h->extra_arg = arg;
- h->use_extra_arg = 1;
-
- chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
- h->next_free = h->object_base = chunk->contents;
- h->chunk_limit = chunk->limit
- = (char *) chunk + h->chunk_size;
- chunk->prev = 0;
- /* The initial chunk now contains no empty object. */
- h->maybe_empty_object = 0;
-}
-
-/* Allocate a new current chunk for the obstack *H
- on the assumption that LENGTH bytes need to be added
- to the current object, or a new object of length LENGTH allocated.
- Copies any partial object from the end of the old chunk
- to the beginning of the new one. */
-
-void
-_obstack_newchunk (h, length)
- struct obstack *h;
- int length;
-{
- register struct _obstack_chunk* old_chunk = h->chunk;
- register struct _obstack_chunk* new_chunk;
- register long new_size;
- register int obj_size = h->next_free - h->object_base;
- register int i;
- int already;
-
- /* Compute size for new chunk. */
- new_size = (obj_size + length) + (obj_size >> 3) + 100;
- if (new_size < h->chunk_size)
- new_size = h->chunk_size;
-
- /* Allocate and initialize the new chunk. */
- new_chunk = h->chunk = CALL_CHUNKFUN (h, new_size);
- new_chunk->prev = old_chunk;
- new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
-
- /* Move the existing object to the new chunk.
- Word at a time is fast and is safe if the object
- is sufficiently aligned. */
- if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
- {
- for (i = obj_size / sizeof (COPYING_UNIT) - 1;
- i >= 0; i--)
- ((COPYING_UNIT *)new_chunk->contents)[i]
- = ((COPYING_UNIT *)h->object_base)[i];
- /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT,
- but that can cross a page boundary on a machine
- which does not do strict alignment for COPYING_UNITS. */
- already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
- }
- else
- already = 0;
- /* Copy remaining bytes one by one. */
- for (i = already; i < obj_size; i++)
- new_chunk->contents[i] = h->object_base[i];
-
- /* If the object just copied was the only data in OLD_CHUNK,
- free that chunk and remove it from the chain.
- But not if that chunk might contain an empty object. */
- if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
- {
- new_chunk->prev = old_chunk->prev;
- CALL_FREEFUN (h, old_chunk);
- }
-
- h->object_base = new_chunk->contents;
- h->next_free = h->object_base + obj_size;
- /* The new chunk certainly contains no empty object yet. */
- h->maybe_empty_object = 0;
-}
-
-/* Return nonzero if object OBJ has been allocated from obstack H.
- This is here for debugging.
- If you use it in a program, you are probably losing. */
-
-int
-_obstack_allocated_p (h, obj)
- struct obstack *h;
- POINTER obj;
-{
- register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */
- register struct _obstack_chunk* plp; /* point to previous chunk if any */
-
- lp = (h)->chunk;
- /* We use >= rather than > since the object cannot be exactly at
- the beginning of the chunk but might be an empty object exactly
- at the end of an adjacent chunk. */
- while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj))
- {
- plp = lp->prev;
- lp = plp;
- }
- return lp != 0;
-}
-
-/* Free objects in obstack H, including OBJ and everything allocate
- more recently than OBJ. If OBJ is zero, free everything in H. */
-
-#undef obstack_free
-
-/* This function has two names with identical definitions.
- This is the first one, called from non-ANSI code. */
-
-void
-_obstack_free (h, obj)
- struct obstack *h;
- POINTER obj;
-{
- register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */
- register struct _obstack_chunk* plp; /* point to previous chunk if any */
-
- lp = h->chunk;
- /* We use >= because there cannot be an object at the beginning of a chunk.
- But there can be an empty object at that address
- at the end of another chunk. */
- while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj))
- {
- plp = lp->prev;
- CALL_FREEFUN (h, lp);
- lp = plp;
- /* If we switch chunks, we can't tell whether the new current
- chunk contains an empty object, so assume that it may. */
- h->maybe_empty_object = 1;
- }
- if (lp)
- {
- h->object_base = h->next_free = (char *)(obj);
- h->chunk_limit = lp->limit;
- h->chunk = lp;
- }
- else if (obj != 0)
- /* obj is not in any of the chunks! */
- abort ();
-}
-
-/* This function is used from ANSI code. */
-
-void
-obstack_free (h, obj)
- struct obstack *h;
- POINTER obj;
-{
- register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */
- register struct _obstack_chunk* plp; /* point to previous chunk if any */
-
- lp = h->chunk;
- /* We use >= because there cannot be an object at the beginning of a chunk.
- But there can be an empty object at that address
- at the end of another chunk. */
- while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj))
- {
- plp = lp->prev;
- CALL_FREEFUN (h, lp);
- lp = plp;
- /* If we switch chunks, we can't tell whether the new current
- chunk contains an empty object, so assume that it may. */
- h->maybe_empty_object = 1;
- }
- if (lp)
- {
- h->object_base = h->next_free = (char *)(obj);
- h->chunk_limit = lp->limit;
- h->chunk = lp;
- }
- else if (obj != 0)
- /* obj is not in any of the chunks! */
- abort ();
-}
-
-#if 0
-/* These are now turned off because the applications do not use it
- and it uses bcopy via obstack_grow, which causes trouble on sysV. */
-
-/* Now define the functional versions of the obstack macros.
- Define them to simply use the corresponding macros to do the job. */
-
-#ifdef __STDC__
-/* These function definitions do not work with non-ANSI preprocessors;
- they won't pass through the macro names in parentheses. */
-
-/* The function names appear in parentheses in order to prevent
- the macro-definitions of the names from being expanded there. */
-
-POINTER (obstack_base) (obstack)
- struct obstack *obstack;
-{
- return obstack_base (obstack);
-}
-
-POINTER (obstack_next_free) (obstack)
- struct obstack *obstack;
-{
- return obstack_next_free (obstack);
-}
-
-int (obstack_object_size) (obstack)
- struct obstack *obstack;
-{
- return obstack_object_size (obstack);
-}
-
-int (obstack_room) (obstack)
- struct obstack *obstack;
-{
- return obstack_room (obstack);
-}
-
-void (obstack_grow) (obstack, pointer, length)
- struct obstack *obstack;
- POINTER pointer;
- int length;
-{
- obstack_grow (obstack, pointer, length);
-}
-
-void (obstack_grow0) (obstack, pointer, length)
- struct obstack *obstack;
- POINTER pointer;
- int length;
-{
- obstack_grow0 (obstack, pointer, length);
-}
-
-void (obstack_1grow) (obstack, character)
- struct obstack *obstack;
- int character;
-{
- obstack_1grow (obstack, character);
-}
-
-void (obstack_blank) (obstack, length)
- struct obstack *obstack;
- int length;
-{
- obstack_blank (obstack, length);
-}
-
-void (obstack_1grow_fast) (obstack, character)
- struct obstack *obstack;
- int character;
-{
- obstack_1grow_fast (obstack, character);
-}
-
-void (obstack_blank_fast) (obstack, length)
- struct obstack *obstack;
- int length;
-{
- obstack_blank_fast (obstack, length);
-}
-
-POINTER (obstack_finish) (obstack)
- struct obstack *obstack;
-{
- return obstack_finish (obstack);
-}
-
-POINTER (obstack_alloc) (obstack, length)
- struct obstack *obstack;
- int length;
-{
- return obstack_alloc (obstack, length);
-}
-
-POINTER (obstack_copy) (obstack, pointer, length)
- struct obstack *obstack;
- POINTER pointer;
- int length;
-{
- return obstack_copy (obstack, pointer, length);
-}
-
-POINTER (obstack_copy0) (obstack, pointer, length)
- struct obstack *obstack;
- POINTER pointer;
- int length;
-{
- return obstack_copy0 (obstack, pointer, length);
-}
-
-#endif /* __STDC__ */
-
-#endif /* 0 */
-
-#endif /* _LIBC or not __GNU_LIBRARY__. */
diff --git a/gnu/usr.bin/grep/obstack.h b/gnu/usr.bin/grep/obstack.h
deleted file mode 100644
index 09d2c32..0000000
--- a/gnu/usr.bin/grep/obstack.h
+++ /dev/null
@@ -1,484 +0,0 @@
-/* obstack.h - object stack macros
- Copyright (C) 1988, 1992 Free Software Foundation, Inc.
-
-This program is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Summary:
-
-All the apparent functions defined here are macros. The idea
-is that you would use these pre-tested macros to solve a
-very specific set of problems, and they would run fast.
-Caution: no side-effects in arguments please!! They may be
-evaluated MANY times!!
-
-These macros operate a stack of objects. Each object starts life
-small, and may grow to maturity. (Consider building a word syllable
-by syllable.) An object can move while it is growing. Once it has
-been "finished" it never changes address again. So the "top of the
-stack" is typically an immature growing object, while the rest of the
-stack is of mature, fixed size and fixed address objects.
-
-These routines grab large chunks of memory, using a function you
-supply, called `obstack_chunk_alloc'. On occasion, they free chunks,
-by calling `obstack_chunk_free'. You must define them and declare
-them before using any obstack macros.
-
-Each independent stack is represented by a `struct obstack'.
-Each of the obstack macros expects a pointer to such a structure
-as the first argument.
-
-One motivation for this package is the problem of growing char strings
-in symbol tables. Unless you are "fascist pig with a read-only mind"
---Gosper's immortal quote from HAKMEM item 154, out of context--you
-would not like to put any arbitrary upper limit on the length of your
-symbols.
-
-In practice this often means you will build many short symbols and a
-few long symbols. At the time you are reading a symbol you don't know
-how long it is. One traditional method is to read a symbol into a
-buffer, realloc()ating the buffer every time you try to read a symbol
-that is longer than the buffer. This is beaut, but you still will
-want to copy the symbol from the buffer to a more permanent
-symbol-table entry say about half the time.
-
-With obstacks, you can work differently. Use one obstack for all symbol
-names. As you read a symbol, grow the name in the obstack gradually.
-When the name is complete, finalize it. Then, if the symbol exists already,
-free the newly read name.
-
-The way we do this is to take a large chunk, allocating memory from
-low addresses. When you want to build a symbol in the chunk you just
-add chars above the current "high water mark" in the chunk. When you
-have finished adding chars, because you got to the end of the symbol,
-you know how long the chars are, and you can create a new object.
-Mostly the chars will not burst over the highest address of the chunk,
-because you would typically expect a chunk to be (say) 100 times as
-long as an average object.
-
-In case that isn't clear, when we have enough chars to make up
-the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
-so we just point to it where it lies. No moving of chars is
-needed and this is the second win: potentially long strings need
-never be explicitly shuffled. Once an object is formed, it does not
-change its address during its lifetime.
-
-When the chars burst over a chunk boundary, we allocate a larger
-chunk, and then copy the partly formed object from the end of the old
-chunk to the beginning of the new larger chunk. We then carry on
-accreting characters to the end of the object as we normally would.
-
-A special macro is provided to add a single char at a time to a
-growing object. This allows the use of register variables, which
-break the ordinary 'growth' macro.
-
-Summary:
- We allocate large chunks.
- We carve out one object at a time from the current chunk.
- Once carved, an object never moves.
- We are free to append data of any size to the currently
- growing object.
- Exactly one object is growing in an obstack at any one time.
- You can run one obstack per control block.
- You may have as many control blocks as you dare.
- Because of the way we do it, you can `unwind' an obstack
- back to a previous state. (You may remove objects much
- as you would with a stack.)
-*/
-
-
-/* Don't do the contents of this file more than once. */
-
-#ifndef __OBSTACKS__
-#define __OBSTACKS__
-
-/* We use subtraction of (char *)0 instead of casting to int
- because on word-addressable machines a simple cast to int
- may ignore the byte-within-word field of the pointer. */
-
-#ifndef __PTR_TO_INT
-#define __PTR_TO_INT(P) ((P) - (char *)0)
-#endif
-
-#ifndef __INT_TO_PTR
-#define __INT_TO_PTR(P) ((P) + (char *)0)
-#endif
-
-/* We need the type of the resulting object. In ANSI C it is ptrdiff_t
- but in traditional C it is usually long. If we are in ANSI C and
- don't already have ptrdiff_t get it. */
-
-#if defined (__STDC__) && ! defined (offsetof)
-#if defined (__GNUC__) && defined (IN_GCC)
-/* On Next machine, the system's stddef.h screws up if included
- after we have defined just ptrdiff_t, so include all of gstddef.h.
- Otherwise, define just ptrdiff_t, which is all we need. */
-#ifndef __NeXT__
-#define __need_ptrdiff_t
-#endif
-
-/* While building GCC, the stddef.h that goes with GCC has this name. */
-#include "gstddef.h"
-#else
-#include <stddef.h>
-#endif
-#endif
-
-#ifdef __STDC__
-#define PTR_INT_TYPE ptrdiff_t
-#else
-#define PTR_INT_TYPE long
-#endif
-
-struct _obstack_chunk /* Lives at front of each chunk. */
-{
- char *limit; /* 1 past end of this chunk */
- struct _obstack_chunk *prev; /* address of prior chunk or NULL */
- char contents[4]; /* objects begin here */
-};
-
-struct obstack /* control current object in current chunk */
-{
- long chunk_size; /* preferred size to allocate chunks in */
- struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */
- char *object_base; /* address of object we are building */
- char *next_free; /* where to add next char to current object */
- char *chunk_limit; /* address of char after current chunk */
- PTR_INT_TYPE temp; /* Temporary for some macros. */
- int alignment_mask; /* Mask of alignment for each object. */
- struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */
- void (*freefun) (); /* User's function to free a chunk. */
- char *extra_arg; /* first arg for chunk alloc/dealloc funcs */
- unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */
- unsigned maybe_empty_object:1;/* There is a possibility that the current
- chunk contains a zero-length object. This
- prevents freeing the chunk if we allocate
- a bigger chunk to replace it. */
-};
-
-/* Declare the external functions we use; they are in obstack.c. */
-
-#ifdef __STDC__
-extern void _obstack_newchunk (struct obstack *, int);
-extern void _obstack_free (struct obstack *, void *);
-extern void _obstack_begin (struct obstack *, int, int,
- void *(*) (), void (*) ());
-extern void _obstack_begin_1 (struct obstack *, int, int,
- void *(*) (), void (*) (), void *);
-#else
-extern void _obstack_newchunk ();
-extern void _obstack_free ();
-extern void _obstack_begin ();
-extern void _obstack_begin_1 ();
-#endif
-
-#ifdef __STDC__
-
-/* Do the function-declarations after the structs
- but before defining the macros. */
-
-void obstack_init (struct obstack *obstack);
-
-void * obstack_alloc (struct obstack *obstack, int size);
-
-void * obstack_copy (struct obstack *obstack, void *address, int size);
-void * obstack_copy0 (struct obstack *obstack, void *address, int size);
-
-void obstack_free (struct obstack *obstack, void *block);
-
-void obstack_blank (struct obstack *obstack, int size);
-
-void obstack_grow (struct obstack *obstack, void *data, int size);
-void obstack_grow0 (struct obstack *obstack, void *data, int size);
-
-void obstack_1grow (struct obstack *obstack, int data_char);
-void obstack_ptr_grow (struct obstack *obstack, void *data);
-void obstack_int_grow (struct obstack *obstack, int data);
-
-void * obstack_finish (struct obstack *obstack);
-
-int obstack_object_size (struct obstack *obstack);
-
-int obstack_room (struct obstack *obstack);
-void obstack_1grow_fast (struct obstack *obstack, int data_char);
-void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
-void obstack_int_grow_fast (struct obstack *obstack, int data);
-void obstack_blank_fast (struct obstack *obstack, int size);
-
-void * obstack_base (struct obstack *obstack);
-void * obstack_next_free (struct obstack *obstack);
-int obstack_alignment_mask (struct obstack *obstack);
-int obstack_chunk_size (struct obstack *obstack);
-
-#endif /* __STDC__ */
-
-/* Non-ANSI C cannot really support alternative functions for these macros,
- so we do not declare them. */
-
-/* Pointer to beginning of object being allocated or to be allocated next.
- Note that this might not be the final address of the object
- because a new chunk might be needed to hold the final size. */
-
-#define obstack_base(h) ((h)->object_base)
-
-/* Size for allocating ordinary chunks. */
-
-#define obstack_chunk_size(h) ((h)->chunk_size)
-
-/* Pointer to next byte not yet allocated in current chunk. */
-
-#define obstack_next_free(h) ((h)->next_free)
-
-/* Mask specifying low bits that should be clear in address of an object. */
-
-#define obstack_alignment_mask(h) ((h)->alignment_mask)
-
-#define obstack_init(h) \
- _obstack_begin ((h), 0, 0, \
- (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
-
-#define obstack_begin(h, size) \
- _obstack_begin ((h), (size), 0, \
- (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
-
-#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
- _obstack_begin ((h), (size), (alignment), \
- (void *(*) ()) (chunkfun), (void (*) ()) (freefun))
-
-#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
- _obstack_begin_1 ((h), (size), (alignment), \
- (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg))
-
-#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
-
-#define obstack_blank_fast(h,n) ((h)->next_free += (n))
-
-#if defined (__GNUC__) && defined (__STDC__)
-#if __GNUC__ < 2 || defined(NeXT)
-#define __extension__
-#endif
-
-/* For GNU C, if not -traditional,
- we can define these macros to compute all args only once
- without using a global variable.
- Also, we can avoid using the `temp' slot, to make faster code. */
-
-#define obstack_object_size(OBSTACK) \
- __extension__ \
- ({ struct obstack *__o = (OBSTACK); \
- (unsigned) (__o->next_free - __o->object_base); })
-
-#define obstack_room(OBSTACK) \
- __extension__ \
- ({ struct obstack *__o = (OBSTACK); \
- (unsigned) (__o->chunk_limit - __o->next_free); })
-
-/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
- so that we can avoid having void expressions
- in the arms of the conditional expression.
- Casting the third operand to void was tried before,
- but some compilers won't accept it. */
-#define obstack_grow(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- ((__o->next_free + __len > __o->chunk_limit) \
- ? (_obstack_newchunk (__o, __len), 0) : 0); \
- bcopy (where, __o->next_free, __len); \
- __o->next_free += __len; \
- (void) 0; })
-
-#define obstack_grow0(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- ((__o->next_free + __len + 1 > __o->chunk_limit) \
- ? (_obstack_newchunk (__o, __len + 1), 0) : 0), \
- bcopy (where, __o->next_free, __len), \
- __o->next_free += __len, \
- *(__o->next_free)++ = 0; \
- (void) 0; })
-
-#define obstack_1grow(OBSTACK,datum) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- ((__o->next_free + 1 > __o->chunk_limit) \
- ? (_obstack_newchunk (__o, 1), 0) : 0), \
- *(__o->next_free)++ = (datum); \
- (void) 0; })
-
-/* These assume that the obstack alignment is good enough for pointers or ints,
- and that the data added so far to the current object
- shares that much alignment. */
-
-#define obstack_ptr_grow(OBSTACK,datum) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- ((__o->next_free + sizeof (void *) > __o->chunk_limit) \
- ? (_obstack_newchunk (__o, sizeof (void *)), 0) : 0), \
- *((void **)__o->next_free)++ = ((void *)datum); \
- (void) 0; })
-
-#define obstack_int_grow(OBSTACK,datum) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- ((__o->next_free + sizeof (int) > __o->chunk_limit) \
- ? (_obstack_newchunk (__o, sizeof (int)), 0) : 0), \
- *((int *)__o->next_free)++ = ((int)datum); \
- (void) 0; })
-
-#define obstack_ptr_grow_fast(h,aptr) (*((void **)(h)->next_free)++ = (void *)aptr)
-#define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint)
-
-#define obstack_blank(OBSTACK,length) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- ((__o->chunk_limit - __o->next_free < __len) \
- ? (_obstack_newchunk (__o, __len), 0) : 0); \
- __o->next_free += __len; \
- (void) 0; })
-
-#define obstack_alloc(OBSTACK,length) \
-__extension__ \
-({ struct obstack *__h = (OBSTACK); \
- obstack_blank (__h, (length)); \
- obstack_finish (__h); })
-
-#define obstack_copy(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__h = (OBSTACK); \
- obstack_grow (__h, (where), (length)); \
- obstack_finish (__h); })
-
-#define obstack_copy0(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__h = (OBSTACK); \
- obstack_grow0 (__h, (where), (length)); \
- obstack_finish (__h); })
-
-/* The local variable is named __o1 to avoid a name conflict
- when obstack_blank is called. */
-#define obstack_finish(OBSTACK) \
-__extension__ \
-({ struct obstack *__o1 = (OBSTACK); \
- void *value = (void *) __o1->object_base; \
- if (__o1->next_free == value) \
- __o1->maybe_empty_object = 1; \
- __o1->next_free \
- = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
- & ~ (__o1->alignment_mask)); \
- ((__o1->next_free - (char *)__o1->chunk \
- > __o1->chunk_limit - (char *)__o1->chunk) \
- ? (__o1->next_free = __o1->chunk_limit) : 0); \
- __o1->object_base = __o1->next_free; \
- value; })
-
-#define obstack_free(OBSTACK, OBJ) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- void *__obj = (OBJ); \
- if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
- __o->next_free = __o->object_base = __obj; \
- else (obstack_free) (__o, __obj); })
-
-#else /* not __GNUC__ or not __STDC__ */
-
-#define obstack_object_size(h) \
- (unsigned) ((h)->next_free - (h)->object_base)
-
-#define obstack_room(h) \
- (unsigned) ((h)->chunk_limit - (h)->next_free)
-
-#define obstack_grow(h,where,length) \
-( (h)->temp = (length), \
- (((h)->next_free + (h)->temp > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
- bcopy (where, (h)->next_free, (h)->temp), \
- (h)->next_free += (h)->temp)
-
-#define obstack_grow0(h,where,length) \
-( (h)->temp = (length), \
- (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
- bcopy (where, (h)->next_free, (h)->temp), \
- (h)->next_free += (h)->temp, \
- *((h)->next_free)++ = 0)
-
-#define obstack_1grow(h,datum) \
-( (((h)->next_free + 1 > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), 1), 0) : 0), \
- *((h)->next_free)++ = (datum))
-
-#define obstack_ptr_grow(h,datum) \
-( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
- *((char **)(((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *)datum))
-
-#define obstack_int_grow(h,datum) \
-( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
- *((int *)(((h)->next_free+=sizeof(int))-sizeof(int))) = ((int)datum))
-
-#define obstack_ptr_grow_fast(h,aptr) (*((char **)(h)->next_free)++ = (char *)aptr)
-#define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint)
-
-#define obstack_blank(h,length) \
-( (h)->temp = (length), \
- (((h)->chunk_limit - (h)->next_free < (h)->temp) \
- ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
- (h)->next_free += (h)->temp)
-
-#define obstack_alloc(h,length) \
- (obstack_blank ((h), (length)), obstack_finish ((h)))
-
-#define obstack_copy(h,where,length) \
- (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
-
-#define obstack_copy0(h,where,length) \
- (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
-
-#define obstack_finish(h) \
-( ((h)->next_free == (h)->object_base \
- ? (((h)->maybe_empty_object = 1), 0) \
- : 0), \
- (h)->temp = __PTR_TO_INT ((h)->object_base), \
- (h)->next_free \
- = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
- & ~ ((h)->alignment_mask)), \
- (((h)->next_free - (char *)(h)->chunk \
- > (h)->chunk_limit - (char *)(h)->chunk) \
- ? ((h)->next_free = (h)->chunk_limit) : 0), \
- (h)->object_base = (h)->next_free, \
- __INT_TO_PTR ((h)->temp))
-
-#ifdef __STDC__
-#define obstack_free(h,obj) \
-( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \
- (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
- ? (int) ((h)->next_free = (h)->object_base \
- = (h)->temp + (char *) (h)->chunk) \
- : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
-#else
-#define obstack_free(h,obj) \
-( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \
- (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
- ? (int) ((h)->next_free = (h)->object_base \
- = (h)->temp + (char *) (h)->chunk) \
- : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
-#endif
-
-#endif /* not __GNUC__ or not __STDC__ */
-
-#endif /* not __OBSTACKS__ */
diff --git a/gnu/usr.bin/grep/search.c b/gnu/usr.bin/grep/search.c
deleted file mode 100644
index f0e3d5c..0000000
--- a/gnu/usr.bin/grep/search.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/* search.c - searching subroutines using dfa, kwset and regex for grep.
- Copyright (C) 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Written August 1992 by Mike Haertel. */
-
-#include <ctype.h>
-
-#ifdef STDC_HEADERS
-#include <limits.h>
-#include <stdlib.h>
-#else
-#define UCHAR_MAX 255
-#include <sys/types.h>
-extern char *malloc();
-#endif
-
-#ifdef HAVE_MEMCHR
-#include <string.h>
-#ifdef NEED_MEMORY_H
-#include <memory.h>
-#endif
-#else
-#ifdef __STDC__
-extern void *memchr();
-#else
-extern char *memchr();
-#endif
-#endif
-
-#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
-#undef bcopy
-#define bcopy(s, d, n) memcpy((d), (s), (n))
-#endif
-
-#if defined(isascii) && !defined(__FreeBSD__)
-#define ISALNUM(C) (isascii(C) && isalnum(C))
-#define ISUPPER(C) (isascii(C) && isupper(C))
-#else
-#define ISALNUM(C) isalnum((unsigned char)C)
-#define ISUPPER(C) isupper((unsigned char)C)
-#endif
-
-#define TOLOWER(C) (ISUPPER(C) ? tolower((unsigned char)C) : (C))
-
-#include "grep.h"
-#include "dfa.h"
-#include "kwset.h"
-#include "gnuregex.h"
-
-#define NCHAR (UCHAR_MAX + 1)
-
-#if __STDC__
-static void Gcompile(char *, size_t);
-static void Ecompile(char *, size_t);
-static char *EGexecute(char *, size_t, char **);
-static void Fcompile(char *, size_t);
-static char *Fexecute(char *, size_t, char **);
-#else
-static void Gcompile();
-static void Ecompile();
-static char *EGexecute();
-static void Fcompile();
-static char *Fexecute();
-#endif
-
-/* Here is the matchers vector for the main program. */
-struct matcher matchers[] = {
- { "default", Gcompile, EGexecute },
- { "grep", Gcompile, EGexecute },
- { "ggrep", Gcompile, EGexecute },
- { "egrep", Ecompile, EGexecute },
- { "posix-egrep", Ecompile, EGexecute },
- { "gegrep", Ecompile, EGexecute },
- { "fgrep", Fcompile, Fexecute },
- { "gfgrep", Fcompile, Fexecute },
- { 0, 0, 0 },
-};
-
-/* For -w, we also consider _ to be word constituent. */
-#define WCHAR(C) (ISALNUM(C) || (C) == '_')
-
-/* DFA compiled regexp. */
-static struct dfa dfa;
-
-/* Regex compiled regexp. */
-static struct re_pattern_buffer regex;
-
-/* KWset compiled pattern. For Ecompile and Gcompile, we compile
- a list of strings, at least one of which is known to occur in
- any string matching the regexp. */
-static kwset_t kwset;
-
-/* Last compiled fixed string known to exactly match the regexp.
- If kwsexec() returns < lastexact, then we don't need to
- call the regexp matcher at all. */
-static int lastexact;
-
-void
-dfaerror(mesg)
- char *mesg;
-{
- fatal(mesg, 0);
-}
-
-static void
-kwsinit()
-{
- static char trans[NCHAR];
- int i;
-
- if (match_icase)
- for (i = 0; i < NCHAR; ++i)
- trans[i] = TOLOWER(i);
-
- if (!(kwset = kwsalloc(match_icase ? trans : (char *) 0)))
- fatal("memory exhausted", 0);
-}
-
-/* If the DFA turns out to have some set of fixed strings one of
- which must occur in the match, then we build a kwset matcher
- to find those strings, and thus quickly filter out impossible
- matches. */
-static void
-kwsmusts()
-{
- struct dfamust *dm;
- char *err;
-
- if (dfa.musts)
- {
- kwsinit();
- /* First, we compile in the substrings known to be exact
- matches. The kwset matcher will return the index
- of the matching string that it chooses. */
- for (dm = dfa.musts; dm; dm = dm->next)
- {
- if (!dm->exact)
- continue;
- ++lastexact;
- if ((err = kwsincr(kwset, dm->must, strlen(dm->must))) != 0)
- fatal(err, 0);
- }
- /* Now, we compile the substrings that will require
- the use of the regexp matcher. */
- for (dm = dfa.musts; dm; dm = dm->next)
- {
- if (dm->exact)
- continue;
- if ((err = kwsincr(kwset, dm->must, strlen(dm->must))) != 0)
- fatal(err, 0);
- }
- if ((err = kwsprep(kwset)) != 0)
- fatal(err, 0);
- }
-}
-
-static void
-Gcompile(pattern, size)
- char *pattern;
- size_t size;
-{
-#ifdef __STDC__
- const
-#endif
- char *err;
-
- re_set_syntax(RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE);
- dfasyntax(RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE, match_icase);
-
- if ((err = re_compile_pattern(pattern, size, &regex)) != 0)
- fatal(err, 0);
-
- dfainit(&dfa);
-
- /* In the match_words and match_lines cases, we use a different pattern
- for the DFA matcher that will quickly throw out cases that won't work.
- Then if DFA succeeds we do some hairy stuff using the regex matcher
- to decide whether the match should really count. */
- if (match_words || match_lines)
- {
- /* In the whole-word case, we use the pattern:
- (^|[^A-Za-z_])(userpattern)([^A-Za-z_]|$).
- In the whole-line case, we use the pattern:
- ^(userpattern)$.
- BUG: Using [A-Za-z_] is locale-dependent! */
-
- char *n = malloc(size + 50);
- int i = 0;
-
- strcpy(n, "");
-
- if (match_lines)
- strcpy(n, "^\\(");
- if (match_words)
- strcpy(n, "\\(^\\|[^0-9A-Za-z_]\\)\\(");
-
- i = strlen(n);
- bcopy(pattern, n + i, size);
- i += size;
-
- if (match_words)
- strcpy(n + i, "\\)\\([^0-9A-Za-z_]\\|$\\)");
- if (match_lines)
- strcpy(n + i, "\\)$");
-
- i += strlen(n + i);
- dfacomp(n, i, &dfa, 1);
- }
- else
- dfacomp(pattern, size, &dfa, 1);
-
- kwsmusts();
-}
-
-static void
-Ecompile(pattern, size)
- char *pattern;
- size_t size;
-{
-#ifdef __STDC__
- const
-#endif
- char *err;
-
- if (strcmp(matcher, "posix-egrep") == 0)
- {
- re_set_syntax(RE_SYNTAX_POSIX_EGREP);
- dfasyntax(RE_SYNTAX_POSIX_EGREP, match_icase);
- }
- else
- {
- re_set_syntax(RE_SYNTAX_EGREP);
- dfasyntax(RE_SYNTAX_EGREP, match_icase);
- }
-
- if ((err = re_compile_pattern(pattern, size, &regex)) != 0)
- fatal(err, 0);
-
- dfainit(&dfa);
-
- /* In the match_words and match_lines cases, we use a different pattern
- for the DFA matcher that will quickly throw out cases that won't work.
- Then if DFA succeeds we do some hairy stuff using the regex matcher
- to decide whether the match should really count. */
- if (match_words || match_lines)
- {
- /* In the whole-word case, we use the pattern:
- (^|[^A-Za-z_])(userpattern)([^A-Za-z_]|$).
- In the whole-line case, we use the pattern:
- ^(userpattern)$.
- BUG: Using [A-Za-z_] is locale-dependent! */
-
- char *n = malloc(size + 50);
- int i = 0;
-
- strcpy(n, "");
-
- if (match_lines)
- strcpy(n, "^(");
- if (match_words)
- strcpy(n, "(^|[^0-9A-Za-z_])(");
-
- i = strlen(n);
- bcopy(pattern, n + i, size);
- i += size;
-
- if (match_words)
- strcpy(n + i, ")([^0-9A-Za-z_]|$)");
- if (match_lines)
- strcpy(n + i, ")$");
-
- i += strlen(n + i);
- dfacomp(n, i, &dfa, 1);
- }
- else
- dfacomp(pattern, size, &dfa, 1);
-
- kwsmusts();
-}
-
-static char *
-EGexecute(buf, size, endp)
- char *buf;
- size_t size;
- char **endp;
-{
- register char *buflim, *beg, *end, save;
- int backref, start, len;
- struct kwsmatch kwsm;
- static struct re_registers regs; /* This is static on account of a BRAIN-DEAD
- Q@#%!# library interface in regex.c. */
-
- buflim = buf + size;
-
- for (beg = end = buf; end < buflim; beg = end + 1)
- {
- if (kwset)
- {
- /* Find a possible match using the KWset matcher. */
- beg = kwsexec(kwset, beg, buflim - beg, &kwsm);
- if (!beg)
- goto failure;
- /* Narrow down to the line containing the candidate, and
- run it through DFA. */
- end = memchr(beg, '\n', buflim - beg);
- if (!end)
- end = buflim;
- while (beg > buf && beg[-1] != '\n')
- --beg;
- save = *end;
- if (kwsm.index < lastexact)
- goto success;
- if (!dfaexec(&dfa, beg, end, 0, (int *) 0, &backref))
- {
- *end = save;
- continue;
- }
- *end = save;
- /* Successful, no backreferences encountered. */
- if (!backref)
- goto success;
- }
- else
- {
- /* No good fixed strings; start with DFA. */
- save = *buflim;
- beg = dfaexec(&dfa, beg, buflim, 0, (int *) 0, &backref);
- *buflim = save;
- if (!beg)
- goto failure;
- /* Narrow down to the line we've found. */
- end = memchr(beg, '\n', buflim - beg);
- if (!end)
- end = buflim;
- while (beg > buf && beg[-1] != '\n')
- --beg;
- /* Successful, no backreferences encountered! */
- if (!backref)
- goto success;
- }
- /* If we've made it to this point, this means DFA has seen
- a probable match, and we need to run it through Regex. */
- regex.not_eol = 0;
- if ((start = re_search(&regex, beg, end - beg, 0, end - beg, &regs)) >= 0)
- {
- len = regs.end[0] - start;
- if (!match_lines && !match_words || match_lines && len == end - beg)
- goto success;
- /* If -w, check if the match aligns with word boundaries.
- We do this iteratively because:
- (a) the line may contain more than one occurence of the pattern, and
- (b) Several alternatives in the pattern might be valid at a given
- point, and we may need to consider a shorter one to find a word
- boundary. */
- if (match_words)
- while (start >= 0)
- {
- if ((start == 0 || !WCHAR(beg[start - 1]))
- && (len == end - beg || !WCHAR(beg[start + len])))
- goto success;
- if (len > 0)
- {
- /* Try a shorter length anchored at the same place. */
- --len;
- regex.not_eol = 1;
- len = re_match(&regex, beg, start + len, start, &regs);
- }
- if (len <= 0)
- {
- /* Try looking further on. */
- if (start == end - beg)
- break;
- ++start;
- regex.not_eol = 0;
- start = re_search(&regex, beg, end - beg,
- start, end - beg - start, &regs);
- len = regs.end[0] - start;
- }
- }
- }
- }
-
- failure:
- return 0;
-
- success:
- *endp = end < buflim ? end + 1 : end;
- return beg;
-}
-
-static void
-Fcompile(pattern, size)
- char *pattern;
- size_t size;
-{
- char *beg, *lim, *err;
-
- kwsinit();
- beg = pattern;
- do
- {
- for (lim = beg; lim < pattern + size && *lim != '\n'; ++lim)
- ;
- if ((err = kwsincr(kwset, beg, lim - beg)) != 0)
- fatal(err, 0);
- if (lim < pattern + size)
- ++lim;
- beg = lim;
- }
- while (beg < pattern + size);
-
- if ((err = kwsprep(kwset)) != 0)
- fatal(err, 0);
-}
-
-static char *
-Fexecute(buf, size, endp)
- char *buf;
- size_t size;
- char **endp;
-{
- register char *beg, *try, *end;
- register size_t len;
- struct kwsmatch kwsmatch;
-
- for (beg = buf; beg <= buf + size; ++beg)
- {
- if (!(beg = kwsexec(kwset, beg, buf + size - beg, &kwsmatch)))
- return 0;
- len = kwsmatch.size[0];
- if (match_lines)
- {
- if (beg > buf && beg[-1] != '\n')
- continue;
- if (beg + len < buf + size && beg[len] != '\n')
- continue;
- goto success;
- }
- else if (match_words)
- for (try = beg; len && try;)
- {
- if (try > buf && WCHAR((unsigned char) try[-1]))
- break;
- if (try + len < buf + size && WCHAR((unsigned char) try[len]))
- {
- try = kwsexec(kwset, beg, --len, &kwsmatch);
- len = kwsmatch.size[0];
- }
- else
- goto success;
- }
- else
- goto success;
- }
-
- return 0;
-
- success:
- if ((end = memchr(beg + len, '\n', (buf + size) - (beg + len))) != 0)
- ++end;
- else
- end = buf + size;
- *endp = end;
- while (beg > buf && beg[-1] != '\n')
- --beg;
- return beg;
-}
diff --git a/gnu/usr.bin/grep/tests/check.sh b/gnu/usr.bin/grep/tests/check.sh
deleted file mode 100644
index d2c8fdb..0000000
--- a/gnu/usr.bin/grep/tests/check.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#! /bin/sh
-# Regression test for GNU grep.
-# Usage: regress.sh [testdir]
-
-testdir=${1-tests}
-
-failures=0
-
-# The Khadafy test is brought to you by Scott Anderson . . .
-./grep -E -f $testdir/khadafy.regexp $testdir/khadafy.lines > khadafy.out
-if cmp $testdir/khadafy.lines khadafy.out
-then
- :
-else
- echo Khadafy test failed -- output left on khadafy.out
- failures=1
-fi
-
-# . . . and the following by Henry Spencer.
-
-${AWK-awk} -F: -f $testdir/scriptgen.awk $testdir/spencer.tests > tmp.script
-
-sh tmp.script && exit $failures
-exit 1
diff --git a/gnu/usr.bin/grep/tests/khadafy.lines b/gnu/usr.bin/grep/tests/khadafy.lines
deleted file mode 100644
index 57e21a1..0000000
--- a/gnu/usr.bin/grep/tests/khadafy.lines
+++ /dev/null
@@ -1,32 +0,0 @@
-1) Muammar Qaddafi
-2) Mo'ammar Gadhafi
-3) Muammar Kaddafi
-4) Muammar Qadhafi
-5) Moammar El Kadhafi
-6) Muammar Gadafi
-7) Mu'ammar al-Qadafi
-8) Moamer El Kazzafi
-9) Moamar al-Gaddafi
-10) Mu'ammar Al Qathafi
-11) Muammar Al Qathafi
-12) Mo'ammar el-Gadhafi
-13) Moamar El Kadhafi
-14) Muammar al-Qadhafi
-15) Mu'ammar al-Qadhdhafi
-16) Mu'ammar Qadafi
-17) Moamar Gaddafi
-18) Mu'ammar Qadhdhafi
-19) Muammar Khaddafi
-20) Muammar al-Khaddafi
-21) Mu'amar al-Kadafi
-22) Muammar Ghaddafy
-23) Muammar Ghadafi
-24) Muammar Ghaddafi
-25) Muamar Kaddafi
-26) Muammar Quathafi
-27) Muammar Gheddafi
-28) Muamar Al-Kaddafi
-29) Moammar Khadafy
-30) Moammar Qudhafi
-31) Mu'ammar al-Qaddafi
-32) Mulazim Awwal Mu'ammar Muhammad Abu Minyar al-Qadhafi
diff --git a/gnu/usr.bin/grep/tests/khadafy.regexp b/gnu/usr.bin/grep/tests/khadafy.regexp
deleted file mode 100644
index 46fe8dd..0000000
--- a/gnu/usr.bin/grep/tests/khadafy.regexp
+++ /dev/null
@@ -1 +0,0 @@
-M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]
diff --git a/gnu/usr.bin/grep/tests/scriptgen.awk b/gnu/usr.bin/grep/tests/scriptgen.awk
deleted file mode 100644
index 44ef4df..0000000
--- a/gnu/usr.bin/grep/tests/scriptgen.awk
+++ /dev/null
@@ -1,10 +0,0 @@
-BEGIN { print "failures=0"; }
-$0 !~ /^#/ && NF == 3 {
- print "echo '" $3 "' | ./grep -E -e '" $2 "' > /dev/null 2>&1";
- print "if [ $? != " $1 " ]"
- print "then"
- printf "\techo Spencer test \\#%d failed\n", ++n
- print "\tfailures=1"
- print "fi"
-}
-END { print "exit $failures"; }
diff --git a/gnu/usr.bin/grep/tests/spencer.tests b/gnu/usr.bin/grep/tests/spencer.tests
deleted file mode 100644
index cb506d7..0000000
--- a/gnu/usr.bin/grep/tests/spencer.tests
+++ /dev/null
@@ -1,122 +0,0 @@
-0:abc:abc
-1:abc:xbc
-1:abc:axc
-1:abc:abx
-0:abc:xabcy
-0:abc:ababc
-0:ab*c:abc
-0:ab*bc:abc
-0:ab*bc:abbc
-0:ab*bc:abbbbc
-0:ab+bc:abbc
-1:ab+bc:abc
-1:ab+bc:abq
-0:ab+bc:abbbbc
-0:ab?bc:abbc
-0:ab?bc:abc
-1:ab?bc:abbbbc
-0:ab?c:abc
-0:^abc$:abc
-1:^abc$:abcc
-0:^abc:abcc
-1:^abc$:aabc
-0:abc$:aabc
-0:^:abc
-0:$:abc
-0:a.c:abc
-0:a.c:axc
-0:a.*c:axyzc
-1:a.*c:axyzd
-1:a[bc]d:abc
-0:a[bc]d:abd
-1:a[b-d]e:abd
-0:a[b-d]e:ace
-0:a[b-d]:aac
-0:a[-b]:a-
-0:a[b-]:a-
-2:a[b-a]:-
-2:a[]b:-
-2:a[:-
-0:a]:a]
-0:a[]]b:a]b
-0:a[^bc]d:aed
-1:a[^bc]d:abd
-0:a[^-b]c:adc
-1:a[^-b]c:a-c
-1:a[^]b]c:a]c
-0:a[^]b]c:adc
-0:ab|cd:abc
-0:ab|cd:abcd
-0:()ef:def
-0:()*:-
-1:*a:-
-0:^*:-
-0:$*:-
-1:(*)b:-
-1:$b:b
-2:a\:-
-0:a\(b:a(b
-0:a\(*b:ab
-0:a\(*b:a((b
-1:a\x:a\x
-2:abc):-
-2:(abc:-
-0:((a)):abc
-0:(a)b(c):abc
-0:a+b+c:aabbabc
-0:a**:-
-0:a*?:-
-0:(a*)*:-
-0:(a*)+:-
-0:(a|)*:-
-0:(a*|b)*:-
-0:(a+|b)*:ab
-0:(a+|b)+:ab
-0:(a+|b)?:ab
-0:[^ab]*:cde
-0:(^)*:-
-0:(ab|)*:-
-2:)(:-
-1:abc:
-1:abc:
-0:a*:
-0:([abc])*d:abbbcd
-0:([abc])*bcd:abcd
-0:a|b|c|d|e:e
-0:(a|b|c|d|e)f:ef
-0:((a*|b))*:-
-0:abcd*efg:abcdefg
-0:ab*:xabyabbbz
-0:ab*:xayabbbz
-0:(ab|cd)e:abcde
-0:[abhgefdc]ij:hij
-1:^(ab|cd)e:abcde
-0:(abc|)ef:abcdef
-0:(a|b)c*d:abcd
-0:(ab|ab*)bc:abc
-0:a([bc]*)c*:abc
-0:a([bc]*)(c*d):abcd
-0:a([bc]+)(c*d):abcd
-0:a([bc]*)(c+d):abcd
-0:a[bcd]*dcdcde:adcdcde
-1:a[bcd]+dcdcde:adcdcde
-0:(ab|a)b*c:abc
-0:((a)(b)c)(d):abcd
-0:[A-Za-z_][A-Za-z0-9_]*:alpha
-0:^a(bc+|b[eh])g|.h$:abh
-0:(bc+d$|ef*g.|h?i(j|k)):effgz
-0:(bc+d$|ef*g.|h?i(j|k)):ij
-1:(bc+d$|ef*g.|h?i(j|k)):effg
-1:(bc+d$|ef*g.|h?i(j|k)):bcdd
-0:(bc+d$|ef*g.|h?i(j|k)):reffgz
-1:((((((((((a)))))))))):-
-0:(((((((((a))))))))):a
-1:multiple words of text:uh-uh
-0:multiple words:multiple words, yeah
-0:(.*)c(.*):abcde
-1:\((.*),:(.*)\)
-1:[k]:ab
-0:abcd:abcd
-0:a(bc)d:abcd
-0:a[-]?c:ac
-0:(....).*\1:beriberi
diff --git a/gnu/usr.bin/groff/Makefile b/gnu/usr.bin/groff/Makefile
deleted file mode 100644
index 8a94ac0..0000000
--- a/gnu/usr.bin/groff/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Makefile for groff
-#
-# $Id$
-
-SUBDIR= libgroff libdriver libbib \
- addftinfo eqn \
- grodvi groff grolj4 grops grotty \
- indxbib lkbib lookbib man mm nroff \
- pfbtops pic psbb refer tbl tfmtodit tmac troff \
- devX100 devX100-12 devX75 devX75-12 devascii devdvi \
- devlatin1 devkoi8-r devlj4 devps
-
-# BSD already provides soelim and we don't want xditview compiled be default
-MISC= soelim afmtodit doc grog hpftodit xditview
-
-.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/groff/Makefile.cfg b/gnu/usr.bin/groff/Makefile.cfg
deleted file mode 100644
index 6ebc08f..0000000
--- a/gnu/usr.bin/groff/Makefile.cfg
+++ /dev/null
@@ -1,132 +0,0 @@
-# $Id: Makefile.cfg,v 2.4 1997/03/08 19:06:23 bde Exp $
-
-BINDIR?= /usr/bin
-SHELL= /bin/sh
-
-# Define `page' to be letter if your PostScript printer uses 8.5x11
-# paper (USA) and define it to be A4, if it uses A4 paper (rest of the
-# world).
-PAGE=letter
-
-# Normally the Postscript driver, grops, produces output that conforms
-# to version 3.0 of the Adobe Document Structuring Conventions.
-# Unfortunately some spoolers and previewers can't handle such output.
-# The BROKEN_SPOOLER_FLAGS variable tells grops what it should do to
-# make its output acceptable to such programs. This variable controls
-# only the default behaviour of grops; the behaviour can be changed at
-# runtime by the grops -b option (and so by groff -P-b).
-# Use a value of 0 if your spoolers and previewers are able to handle
-# conforming PostScript correctly.
-# Add 1 if no %%{Begin,End}DocumentSetup comments should be generated;
-# this is needed for early versions of TranScript that get confused by
-# anything between the %%EndProlog line and the first %%Page: comment.
-# Add 2 if lines in included files beginning with %! should be
-# stripped out; this is needed for the OpenWindows 2.0 pageview previewer.
-# Add 4 if %%Page, %%Trailer and %%EndProlog comments should be
-# stripped out of included files; this is needed for spoolers that
-# don't understand the %%{Begin,End}Document comments. I suspect this
-# includes early versions of TranScript.
-# Add 8 if the first line of the PostScript output should be %!PS-Adobe-2.0
-# rather than %!PS-Adobe-3.0; this is needed when using Sun's Newsprint
-# with a printer that requires page reversal.
-BROKEN_SPOOLER_FLAGS=7
-
-# PSPRINT is the command to use for printing a PostScript file,
-# for example `lpr'.
-PSPRINT=lpr
-
-# DVIPRINT is the command to use for printing a TeX dvi file,
-# for example `lpr -d'.
-DVIPRINT=lpr -d
-########################################################################
-# Don't touch...
-
-g=
-tmac_s_prefix=s
-tmac_m_prefix=m
-device=ps
-fontdir=/usr/share/groff_font
-fontpath=$(fontdir)
-tmacdir=/usr/share/tmac
-tmacpath=$(tmacdir)
-indexext=.i
-common_words_file=/usr/share/dict/eign
-indexdir=/usr/share/dict/papers
-indexname=Ind
-
-########################################################################
-# Libraries
-
-# Bad assumption, if one exists they all exist
-.if exists(${.OBJDIR}/../libgroff)
-LIBGROFF= $(.OBJDIR)/../libgroff/libgroff.a
-LIBDRIVER= $(.OBJDIR)/../libdriver/libdriver.a
-LIBBIB= $(.OBJDIR)/../libbib/libbib.a
-.else
-LIBGROFF= $(.CURDIR)/../libgroff/libgroff.a
-LIBDRIVER= $(.CURDIR)/../libdriver/libdriver.a
-LIBBIB= $(.CURDIR)/../libbib/libbib.a
-.endif
-
-DEFINES= -DHAVE_UNISTD_H=1\
- -DHAVE_DIRENT_H=1\
- -DHAVE_LIMITS_H=1\
- -DHAVE_SYS_DIR_H=1\
- -DHAVE_STDLIB_H=1\
- -DUNISTD_H_DECLARES_GETOPT=1\
- -DSTDLIB_H_DECLARES_PUTENV=1\
- -DSTDIO_H_DECLARES_POPEN=1\
- -DSTDIO_H_DECLARE_PCLOSE=1\
- -DHAVE_CC_OSFCN_H=1\
- -DHAVE_CC_LIMITS_H=1\
- -DRETSIGTYPE=void\
- -DHAVE_STRUCT_EXCEPTION=1\
- -DHAVE_RENAME=1\
- -DHAVE_MKSTEMP=1\
- -DSYS_SIGLIST_DECLARED=1
-
-INCLUDES= -I$(GROFF_DIST)/include -I$(.CURDIR)/include
-
-CFLAGS+=$(DEFINES) $(INCLUDES)
-
-.y.o:
- $(YACC) $(YFLAGS) $(.IMPSRC)
- mv -f y.tab.c $(.PREFIX).cc
- mv -f y.tab.h $(.PREFIX).tab.h
- ${CXX} ${CXXFLAGS} -c $(.PREFIX).cc -o ${.TARGET}
-
-.y.cc:
- $(YACC) $(YFLAGS) $(.IMPSRC)
- mv -f y.tab.c $(.PREFIX).cc
- mv -f y.tab.h $(.PREFIX).tab.h
-
-.SUFFIXES: .man .1 .2 .3 .4 .5 .6 .7 .8
-
-#.8.man .7.man .6.man .5.man .4.man .3.man .2.man .1.man:
-
-.man.8 .man.7 .man.6 .man.5 .man.4 .man.3 .man.2 .man.1:
- @${ECHO} Making $@ from $<
- @-rm -f $@
- @sed -e "s;@FONTDIR@;$(fontdir);g" \
- -e "s;@FONTPATH@;$(fontpath);g" \
- -e "s;@MACRODIR@;$(tmacdir);g" \
- -e "s;@MACROPATH@;$(tmacpath);g" \
- -e "s;@DEVICE@;$(device);g" \
- -e "s;@DEFAULT_INDEX@;$(indexdir)/$(indexname);g" \
- -e "s;@DEFAULT_INDEX_NAME@;$(indexname);g" \
- -e "s;@INDEX_SUFFIX@;$(indexext);g" \
- -e "s;@COMMON_WORDS_FILE@;$(common_words_file);g" \
- -e "s;@MAN1EXT@;1;g" \
- -e "s;@MAN5EXT@;5;g" \
- -e "s;@MAN7EXT@;7;g" \
- -e "s;@TMAC_S_PREFIX@;$(tmac_s_prefix);g" \
- -e "s;@TMAC_M_PREFIX@;$(tmac_m_prefix);g" \
- -e "s;@TMAC_MDIR@;$(tmacdir)/mm;g" \
- -e "s;@BROKEN_SPOOLER_FLAGS@;$(BROKEN_SPOOLER_FLAGS);g" \
- -e "s;@VERSION@;`cat ${GROFF_DIST}/VERSION`;g" \
- -e "s;@MDATE@;`$(SHELL) ${GROFF_DIST}/mdate.sh $<`;g" \
- -e "s;@g@;$(g);g" \
- -e "s;@G@;`echo $(g) | tr [a-z] [A-Z]`;g" \
- $< >$@
-
-MANSRC=${.OBJDIR}
diff --git a/gnu/usr.bin/groff/Makefile.dev b/gnu/usr.bin/groff/Makefile.dev
deleted file mode 100644
index 2dcbf5a..0000000
--- a/gnu/usr.bin/groff/Makefile.dev
+++ /dev/null
@@ -1,33 +0,0 @@
-# @(#)Makefile.dev 6.2 (Berkeley) 3/16/91
-# Client Makefiles define DEV and DEVFILES and provide rules for
-# individual font files
-#
-# $Id: Makefile.dev,v 2.4 1997/02/22 15:45:42 peter Exp $
-
-.include "../Makefile.cfg"
-
-FONTDIR?= /usr/share/groff_font
-DEVICEDIR?= $(FONTDIR)/dev$(DEV)
-FONTOWN?= ${BINOWN}
-FONTGRP?= ${BINGRP}
-FONTMODE?= ${NOBINMODE}
-
-all: $(DEVFILES)
-
-.for f in $(DEVFILES)
-.if exists(${.OBJDIR}/$f)
-beforeinstall:: ${.OBJDIR}/$f
- $(INSTALL) -c -o $(FONTOWN) -g $(FONTGRP) -m $(FONTMODE) \
- ${.OBJDIR}/$f $(DESTDIR)$(DEVICEDIR)
-.elif exists(${.CURDIR}/$f)
-beforeinstall:: ${.CURDIR}/$f
- $(INSTALL) -c -o $(FONTOWN) -g $(FONTGRP) -m $(FONTMODE) \
- ${.CURDIR}/$f $(DESTDIR)$(DEVICEDIR)
-.else
-beforeinstall:: $(DIST_DIR)/$f
- $(INSTALL) -c -o $(FONTOWN) -g $(FONTGRP) -m $(FONTMODE) \
- $(DIST_DIR)/$f $(DESTDIR)$(DEVICEDIR)
-.endif
-.endfor
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/Makefile.inc b/gnu/usr.bin/groff/Makefile.inc
deleted file mode 100644
index dfe0a09..0000000
--- a/gnu/usr.bin/groff/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-GROFF_DIST?= ${.CURDIR}/../../../../contrib/groff
-DIST_DIR= ${GROFF_DIST}/${.CURDIR:T}
-CFLAGS+= -fno-for-scope
-
-.PATH: ${DIST_DIR}
diff --git a/gnu/usr.bin/groff/Makefile.tty b/gnu/usr.bin/groff/Makefile.tty
deleted file mode 100644
index b745c02..0000000
--- a/gnu/usr.bin/groff/Makefile.tty
+++ /dev/null
@@ -1,55 +0,0 @@
-# @(#)Makefile.tty 6.1 (Berkeley) 3/3/91
-#
-# Modified for Berkeley Unix by Donn Seeley, donn@okeeffe.berkeley.edu
-#
-#Copyright (C) 1989, 1990 Free Software Foundation, Inc.
-# Written by James Clark (jjc@jclark.uucp)
-#
-#This file is part of groff.
-#
-#groff is free software; you can redistribute it and/or modify it under
-#the terms of the GNU General Public License as published by the Free
-#Software Foundation; either version 1, or (at your option) any later
-#version.
-#
-#groff 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 groff; see the file LICENSE. If not, write to the Free Software
-#Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-.MAIN: all
-
-RES=240
-CPI=10
-LPI=6
-FONTS=R I B BI S L
-
-DEVFILES=$(FONTS) DESC
-CLEANFILES=$(DEVFILES)
-
-$(FONTS): R.proto
- @${ECHO} Making $@
- @(charwidth=`echo $(RES) / $(CPI) | bc` ; \
- sed -e "s/^name [A-Z]*$$/name $@/" \
- -e "s/^\\([^ ]*\\) [0-9]+ /\\1 $$charwidth /" \
- -e "s/^spacewidth [0-9]+$$/spacewidth $$charwidth/" \
- -e "s/^internalname .*$$/internalname $@/" \
- -e "/^internalname/s/BI/3/" \
- -e "/^internalname/s/B/2/" \
- -e "/^internalname/s/I/1/" \
- -e "/^internalname .*[^ 0-9]/d" \
- ${DIST_DIR}/R.proto >$@)
-
-DESC: DESC.proto
- @${ECHO} Making $@
- @sed -e "s/^res .*$$/res $(RES)/" \
- -e "s/^hor .*$$/hor `echo $(RES) / $(CPI) | bc`/" \
- -e "s/^vert .*$$/vert `echo $(RES) / $(LPI) | bc`/" \
- -e "s/^fonts .*$$/fonts `set $(FONTS); echo $$#` $(FONTS)/" \
- ${DIST_DIR}/DESC.proto >$@
-
-beforeinstall:: ${DEVFILES}
diff --git a/gnu/usr.bin/groff/addftinfo/Makefile b/gnu/usr.bin/groff/addftinfo/Makefile
deleted file mode 100644
index 7ca9a60..0000000
--- a/gnu/usr.bin/groff/addftinfo/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for addftinfo
-
-PROG= addftinfo
-SRCS= addftinfo.cc guess.cc
-#CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBGROFF}
-DPADD+= ${LIBGROFF}
-
-MANDEPEND= addftinfo.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/devX100-12/Makefile b/gnu/usr.bin/groff/devX100-12/Makefile
deleted file mode 100644
index bca6c84..0000000
--- a/gnu/usr.bin/groff/devX100-12/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Id$
-#
-# Generic groff font makefile
-#
-.include "${.CURDIR}/../Makefile.inc"
-.include "${DIST_DIR}/Makefile.sub"
-.include "${.CURDIR}/../Makefile.dev"
diff --git a/gnu/usr.bin/groff/devX100/Makefile b/gnu/usr.bin/groff/devX100/Makefile
deleted file mode 100644
index bca6c84..0000000
--- a/gnu/usr.bin/groff/devX100/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Id$
-#
-# Generic groff font makefile
-#
-.include "${.CURDIR}/../Makefile.inc"
-.include "${DIST_DIR}/Makefile.sub"
-.include "${.CURDIR}/../Makefile.dev"
diff --git a/gnu/usr.bin/groff/devX75-12/Makefile b/gnu/usr.bin/groff/devX75-12/Makefile
deleted file mode 100644
index bca6c84..0000000
--- a/gnu/usr.bin/groff/devX75-12/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Id$
-#
-# Generic groff font makefile
-#
-.include "${.CURDIR}/../Makefile.inc"
-.include "${DIST_DIR}/Makefile.sub"
-.include "${.CURDIR}/../Makefile.dev"
diff --git a/gnu/usr.bin/groff/devX75/Makefile b/gnu/usr.bin/groff/devX75/Makefile
deleted file mode 100644
index bca6c84..0000000
--- a/gnu/usr.bin/groff/devX75/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Id$
-#
-# Generic groff font makefile
-#
-.include "${.CURDIR}/../Makefile.inc"
-.include "${DIST_DIR}/Makefile.sub"
-.include "${.CURDIR}/../Makefile.dev"
diff --git a/gnu/usr.bin/groff/devascii/Makefile b/gnu/usr.bin/groff/devascii/Makefile
deleted file mode 100644
index 71fe942..0000000
--- a/gnu/usr.bin/groff/devascii/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# Makefile for devascii
-
-DEV= ascii
-
-.include "../Makefile.inc"
-.include "../Makefile.tty"
-.include "../Makefile.dev"
diff --git a/gnu/usr.bin/groff/devdvi/Makefile b/gnu/usr.bin/groff/devdvi/Makefile
deleted file mode 100644
index 788b4f0..0000000
--- a/gnu/usr.bin/groff/devdvi/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-DEV= dvi
-FONTFILES= R I B BI CW MI S EX H HI HB SA SB DESC $(DEVGENFILES)
-DEVGENFILES= generate/CompileFonts generate/Makefile generate/msam.map\
- generate/msbm.map generate/texb.map generate/texex.map \
- generate/texi.map generate/texmi.map generate/texr.map \
- generate/texsy.map generate/textt.map generate/cork.map
-
-CLEANFILES+= DESC
-
-DEVFILES= $(FONTFILES)
-
-.include "../Makefile.inc"
-
-DESC: DESC.in
- cat ${DIST_DIR}/DESC.in >DESC
- test -z '${DVIPRINT}' || echo print '${DVIPRINT}' >>DESC
-
-.include "../Makefile.dev"
diff --git a/gnu/usr.bin/groff/devkoi8-r/Makefile b/gnu/usr.bin/groff/devkoi8-r/Makefile
deleted file mode 100644
index 8dc2530..0000000
--- a/gnu/usr.bin/groff/devkoi8-r/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# Makefile for devkoi8-r
-
-DEV= koi8-r
-
-.include "../Makefile.tty"
-.include "../Makefile.dev"
diff --git a/gnu/usr.bin/groff/devlatin1/Makefile b/gnu/usr.bin/groff/devlatin1/Makefile
deleted file mode 100644
index a3d9e40..0000000
--- a/gnu/usr.bin/groff/devlatin1/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# Makefile for devlatin1
-
-DEV= latin1
-
-.include "../Makefile.tty"
-.include "../Makefile.dev"
diff --git a/gnu/usr.bin/groff/devlj4/Makefile b/gnu/usr.bin/groff/devlj4/Makefile
deleted file mode 100644
index 94d19f5..0000000
--- a/gnu/usr.bin/groff/devlj4/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-DEV= lj4
-LJ4RES= 300
-LJ4PRINT= $(PSPRINT)
-DEVFILES= $(FONTS) $(SUPPORT) $(DEVGENFILES) DESC
-FONTS= ALBB ALBR AOB AOI AOR CB CBI CI CR GB GBI GI GR \
- LGB LGI LGR OB OBI OI OR TB TBI TI TR UB UBI UI UR \
- UCB UCBI UCI UCR CLARENDON CORONET MARIGOLD S
-#DEVGENFILES= generate/Makefile generate/text.map generate/special.map
-CLEANFILES+= DESC
-
-.include "../Makefile.inc"
-
-DESC: DESC.in
- -rm -f DESC
- echo "res $(LJ4RES)" >DESC
- echo "unitwidth `expr 7620000 / $(LJ4RES)`" >>DESC
- cat ${DIST_DIR}/DESC.in >>DESC
- if test "$(PAGE)" = A4; then \
- echo "papersize a4" >>DESC; \
- else \
- echo "papersize letter" >>DESC; \
- fi
- test -z '$(LJ4PRINT)' || echo print '$(LJ4PRINT)' >>DESC
-
-fonts: DESC
- $(MAKE) -f ${DIST_DIR}/generate/Makefile \
- srcdir=${DIST_DIR}/generate DESC=${DIST_DIR}/DESC.in \
- HPFTODIT=${.CURDIR}/../hpftodit/hpftodit
-
-.include "../Makefile.dev"
diff --git a/gnu/usr.bin/groff/devps/Makefile b/gnu/usr.bin/groff/devps/Makefile
deleted file mode 100644
index fd8cfc0..0000000
--- a/gnu/usr.bin/groff/devps/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-DEV= ps
-FONTS= S ZD ZDR SS AB ABI AI AR BMB BMBI BMI BMR \
- CB CBI CI CR HB HBI HI HR HNB HNBI HNI HNR \
- NB NBI NI NR PB PBI PI PR TB TBI TI TR ZCMI
-SUPPORT= download prologue symbolsl.pfa text.enc zapfdr.pfa
-DEVGENFILES= generate/Makefile generate/afmname generate/dingbatsmap \
- generate/dingbatsrmap generate/lgreekmap generate/symbol.sed \
- generate/symbolchars generate/symbolsl.afm generate/textmap
-PSFILES= prologue symbolsl.pfa zapfdr.pfa
-FONTFILES= $(FONTS) $(SUPPORT) $(DEVGENFILES) DESC
-DEVFILES= $(FONTFILES)
-
-CLEANFILES+= DESC ${PSFILES}
-
-.include "../Makefile.inc"
-
-DESC: DESC.in
- -rm -f DESC
- cat ${DIST_DIR}/DESC.in >DESC
- echo broken ${BROKEN_SPOOLER_FLAGS} >>DESC
- if test "${PAGE}" = A4; then \
- echo "paperlength 841890" >>DESC; \
- else \
- echo "paperlength 792000" >>DESC; \
- fi
- test -z '${PSPRINT}' || echo print '${PSPRINT}' >>DESC
-
-${PSFILES}:
- -rm -f $@
- sed -f ${DIST_DIR}/psstrip.sed $? >$@
-
-fonts: DESC
- ${MAKE} -f ${DIST_DIR}/generate/Makefile \
- srcdir=${DIST_DIR}/generate DESC=${DIST_DIR}/DESC.in
-
-prologue: ${DIST_DIR}/prologue.ps
-zapfdr.pfa: ${DIST_DIR}/zapfdr.ps
-symbolsl.pfa: ${DIST_DIR}/symbolsl.ps
-
-.include "../Makefile.dev"
diff --git a/gnu/usr.bin/groff/eqn/Makefile b/gnu/usr.bin/groff/eqn/Makefile
deleted file mode 100644
index c7773cc..0000000
--- a/gnu/usr.bin/groff/eqn/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-# Makefile for eqn
-
-PROG= eqn
-MAN1= eqn.1 neqn.1
-SRCS= main.cc lex.cc box.cc limit.cc list.cc over.cc text.cc\
- script.cc mark.cc other.cc delim.cc sqrt.cc pile.cc special.cc
-OBJS= eqn.o
-#CFLAGS+= -I. -I${.CURDIR}/../include
-LDADD+= ${LIBGROFF}
-DPADD+= ${LIBGROFF}
-
-MANDEPEND= neqn.1 eqn.1
-CLEANFILES+= eqn.cc eqn.tab.h neqn ${MANDEPEND}
-
-afterinstall: neqn
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} neqn \
- ${DESTDIR}${BINDIR}
-
-beforedepend: eqn.cc
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
-
-neqn: ${DIST_DIR}/neqn.sh
- sed -e 's/@g@/${g}/g' ${DIST_DIR}/neqn.sh > neqn
-
diff --git a/gnu/usr.bin/groff/font/Makefile.dev b/gnu/usr.bin/groff/font/Makefile.dev
deleted file mode 100644
index 2dcbf5a..0000000
--- a/gnu/usr.bin/groff/font/Makefile.dev
+++ /dev/null
@@ -1,33 +0,0 @@
-# @(#)Makefile.dev 6.2 (Berkeley) 3/16/91
-# Client Makefiles define DEV and DEVFILES and provide rules for
-# individual font files
-#
-# $Id: Makefile.dev,v 2.4 1997/02/22 15:45:42 peter Exp $
-
-.include "../Makefile.cfg"
-
-FONTDIR?= /usr/share/groff_font
-DEVICEDIR?= $(FONTDIR)/dev$(DEV)
-FONTOWN?= ${BINOWN}
-FONTGRP?= ${BINGRP}
-FONTMODE?= ${NOBINMODE}
-
-all: $(DEVFILES)
-
-.for f in $(DEVFILES)
-.if exists(${.OBJDIR}/$f)
-beforeinstall:: ${.OBJDIR}/$f
- $(INSTALL) -c -o $(FONTOWN) -g $(FONTGRP) -m $(FONTMODE) \
- ${.OBJDIR}/$f $(DESTDIR)$(DEVICEDIR)
-.elif exists(${.CURDIR}/$f)
-beforeinstall:: ${.CURDIR}/$f
- $(INSTALL) -c -o $(FONTOWN) -g $(FONTGRP) -m $(FONTMODE) \
- ${.CURDIR}/$f $(DESTDIR)$(DEVICEDIR)
-.else
-beforeinstall:: $(DIST_DIR)/$f
- $(INSTALL) -c -o $(FONTOWN) -g $(FONTGRP) -m $(FONTMODE) \
- $(DIST_DIR)/$f $(DESTDIR)$(DEVICEDIR)
-.endif
-.endfor
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/font/Makefile.tty b/gnu/usr.bin/groff/font/Makefile.tty
deleted file mode 100644
index b745c02..0000000
--- a/gnu/usr.bin/groff/font/Makefile.tty
+++ /dev/null
@@ -1,55 +0,0 @@
-# @(#)Makefile.tty 6.1 (Berkeley) 3/3/91
-#
-# Modified for Berkeley Unix by Donn Seeley, donn@okeeffe.berkeley.edu
-#
-#Copyright (C) 1989, 1990 Free Software Foundation, Inc.
-# Written by James Clark (jjc@jclark.uucp)
-#
-#This file is part of groff.
-#
-#groff is free software; you can redistribute it and/or modify it under
-#the terms of the GNU General Public License as published by the Free
-#Software Foundation; either version 1, or (at your option) any later
-#version.
-#
-#groff 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 groff; see the file LICENSE. If not, write to the Free Software
-#Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-.MAIN: all
-
-RES=240
-CPI=10
-LPI=6
-FONTS=R I B BI S L
-
-DEVFILES=$(FONTS) DESC
-CLEANFILES=$(DEVFILES)
-
-$(FONTS): R.proto
- @${ECHO} Making $@
- @(charwidth=`echo $(RES) / $(CPI) | bc` ; \
- sed -e "s/^name [A-Z]*$$/name $@/" \
- -e "s/^\\([^ ]*\\) [0-9]+ /\\1 $$charwidth /" \
- -e "s/^spacewidth [0-9]+$$/spacewidth $$charwidth/" \
- -e "s/^internalname .*$$/internalname $@/" \
- -e "/^internalname/s/BI/3/" \
- -e "/^internalname/s/B/2/" \
- -e "/^internalname/s/I/1/" \
- -e "/^internalname .*[^ 0-9]/d" \
- ${DIST_DIR}/R.proto >$@)
-
-DESC: DESC.proto
- @${ECHO} Making $@
- @sed -e "s/^res .*$$/res $(RES)/" \
- -e "s/^hor .*$$/hor `echo $(RES) / $(CPI) | bc`/" \
- -e "s/^vert .*$$/vert `echo $(RES) / $(LPI) | bc`/" \
- -e "s/^fonts .*$$/fonts `set $(FONTS); echo $$#` $(FONTS)/" \
- ${DIST_DIR}/DESC.proto >$@
-
-beforeinstall:: ${DEVFILES}
diff --git a/gnu/usr.bin/groff/font/devkoi8-r/DESC.proto b/gnu/usr.bin/groff/font/devkoi8-r/DESC.proto
deleted file mode 100644
index 041ceba..0000000
--- a/gnu/usr.bin/groff/font/devkoi8-r/DESC.proto
+++ /dev/null
@@ -1,8 +0,0 @@
-res 240
-hor 24
-vert 40
-unitwidth 10
-sizes 10 0
-fonts 6 R I B BI S L
-tcommand
-postpro grotty
diff --git a/gnu/usr.bin/groff/font/devkoi8-r/R.proto b/gnu/usr.bin/groff/font/devkoi8-r/R.proto
deleted file mode 100644
index 7ccb83f..0000000
--- a/gnu/usr.bin/groff/font/devkoi8-r/R.proto
+++ /dev/null
@@ -1,239 +0,0 @@
-name R
-internalname 0
-spacewidth 24
-charset
-! 24 0 0041
-" 24 0 0042
-lq "
-rq "
-# 24 0 0043
-sh "
-$ 24 0 0044
-Do "
-% 24 0 0045
-& 24 0 0046
-' 24 0 0047
-aa "
-fm "
-aq "
-( 24 0 0050
-) 24 0 0051
-* 24 0 0052
-** "
-+ 24 0 0053
-pl "
-, 24 0 0054
-\- 24 0 0055
-hy "
-- "
-mi "
-en "
-. 24 0 0056
-/ 24 0 0057
-sl "
-f/ "
-0 24 0 0060
-1 24 0 0061
-2 24 0 0062
-3 24 0 0063
-4 24 0 0064
-5 24 0 0065
-6 24 0 0066
-7 24 0 0067
-8 24 0 0070
-9 24 0 0071
-: 24 0 0072
-; 24 0 0073
-< 24 0 0074
-la "
-fo "
-= 24 0 0075
-eq "
-> 24 0 0076
-ra "
-fc "
-? 24 0 0077
-@ 24 0 0100
-at "
-A 24 0 0101
-*A "
-B 24 0 0102
-*B "
-C 24 0 0103
-D 24 0 0104
-E 24 0 0105
-*E "
-F 24 0 0106
-G 24 0 0107
-H 24 0 0110
-*Y "
-I 24 0 0111
-*I "
-J 24 0 0112
-K 24 0 0113
-*K "
-L 24 0 0114
-M 24 0 0115
-*M "
-N 24 0 0116
-*N "
-O 24 0 0117
-ci "
-*O "
-P 24 0 0120
-*R "
-Q 24 0 0121
-R 24 0 0122
-S 24 0 0123
-T 24 0 0124
-*T "
-U 24 0 0125
-V 24 0 0126
-W 24 0 0127
-X 24 0 0130
-*X "
-Y 24 0 0131
-*U "
-Z 24 0 0132
-*Z "
-[ 24 0 0133
-lB "
-\ 24 0 0134
-rs "
-] 24 0 0135
-rB "
-a^ 24 0 0136
-^ "
-ha "
-_ 24 0 0137
-ru "
-ul "
-` 24 0 0140
-oq "
-ga "
-a 24 0 0141
-b 24 0 0142
-c 24 0 0143
-d 24 0 0144
-e 24 0 0145
-f 24 0 0146
-g 24 0 0147
-h 24 0 0150
-i 24 0 0151
-.i "
-j 24 0 0152
-k 24 0 0153
-l 24 0 0154
-m 24 0 0155
-n 24 0 0156
-o 24 0 0157
-*o "
-p 24 0 0160
-q 24 0 0161
-r 24 0 0162
-s 24 0 0163
-t 24 0 0164
-u 24 0 0165
-v 24 0 0166
-w 24 0 0167
-x 24 0 0170
-mu "
-y 24 0 0171
-z 24 0 0172
-lC 24 0 0173
-{ "
-ba 24 0 0174
-or "
-bv "
-br "
-| "
-lb "
-lc "
-lf "
-lk "
-lt "
-rb "
-rc "
-rf "
-rk "
-rt "
-rC 24 0 0175
-} "
-a~ 24 0 0176
-~ "
-ap "
-ti "
-em 24 0 0200
-bu 24 0 0224
-~= 24 0 0227
-<= 24 0 0230
->= 24 0 0231
-de 24 0 0234
-di 24 0 0237
-char163 24 0 0243
-char179 24 0 0263
-co 24 0 0277
-char192 24 0 0300
-char193 24 0 0301
-char194 24 0 0302
-char195 24 0 0303
-char196 24 0 0304
-char197 24 0 0305
-char198 24 0 0306
-char199 24 0 0307
-char200 24 0 0310
-char201 24 0 0311
-char202 24 0 0312
-char203 24 0 0313
-char204 24 0 0314
-char205 24 0 0315
-char206 24 0 0316
-char207 24 0 0317
-char208 24 0 0320
-char209 24 0 0321
-char210 24 0 0322
-char211 24 0 0323
-char212 24 0 0324
-char213 24 0 0325
-char214 24 0 0326
-char215 24 0 0327
-char216 24 0 0330
-char217 24 0 0331
-char218 24 0 0332
-char219 24 0 0333
-char220 24 0 0334
-char221 24 0 0335
-char222 24 0 0336
-char223 24 0 0337
-char224 24 0 0340
-char225 24 0 0341
-char226 24 0 0342
-char227 24 0 0343
-char228 24 0 0344
-char229 24 0 0345
-char230 24 0 0346
-char231 24 0 0347
-char232 24 0 0350
-char233 24 0 0351
-char234 24 0 0352
-char235 24 0 0353
-char236 24 0 0354
-char237 24 0 0355
-char238 24 0 0356
-char239 24 0 0357
-char240 24 0 0360
-char241 24 0 0361
-char242 24 0 0362
-char243 24 0 0363
-char244 24 0 0364
-char245 24 0 0365
-char246 24 0 0366
-char247 24 0 0367
-char248 24 0 0370
-char249 24 0 0371
-char250 24 0 0372
-char251 24 0 0373
-char252 24 0 0374
-char253 24 0 0375
-char254 24 0 0376
-char255 24 0 0377
diff --git a/gnu/usr.bin/groff/grodvi/Makefile b/gnu/usr.bin/groff/grodvi/Makefile
deleted file mode 100644
index aa87393..0000000
--- a/gnu/usr.bin/groff/grodvi/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for grodvi
-
-PROG= grodvi
-SRCS= dvi.cc
-#CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBDRIVER} ${LIBGROFF} -lm
-DPADD+= ${LIBDRIVER} ${LIBGROFF} ${LIBM}
-
-MANDEPEND= grodvi.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/groff/Makefile b/gnu/usr.bin/groff/groff/Makefile
deleted file mode 100644
index 9539f70..0000000
--- a/gnu/usr.bin/groff/groff/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for groff
-
-PROG= groff
-SRCS= groff.cc pipeline.c
-CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBGROFF} -lm
-DPADD+= ${LIBGROFF} ${LIBM}
-
-MANDEPEND= groff.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/grolj4/Makefile b/gnu/usr.bin/groff/grolj4/Makefile
deleted file mode 100644
index b5594e6..0000000
--- a/gnu/usr.bin/groff/grolj4/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for grolj4
-
-PROG= grolj4
-SRCS= lj4.cc
-#CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBDRIVER} ${LIBGROFF} -lm
-DPADD+= ${LIBDRIVER} ${LIBGROFF} ${LIBM}
-
-MANDEPEND= grolj4.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/grops/Makefile b/gnu/usr.bin/groff/grops/Makefile
deleted file mode 100644
index 2a5b8a2..0000000
--- a/gnu/usr.bin/groff/grops/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for grops
-
-PROG= grops
-SRCS= ps.cc psrm.cc
-#CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBDRIVER} ${LIBGROFF} -lm
-DPADD+= ${LIBDRIVER} ${LIBGROFF} ${LIBM}
-
-MANDEPEND= grops.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/grotty/Makefile b/gnu/usr.bin/groff/grotty/Makefile
deleted file mode 100644
index 68f7316..0000000
--- a/gnu/usr.bin/groff/grotty/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for grotty
-
-PROG= grotty
-SRCS= tty.cc
-#CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBDRIVER} ${LIBGROFF} -lm
-DPADD+= ${LIBDRIVER} ${LIBGROFF} ${LIBM}
-
-MANDEPEND= grotty.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/include/defs.h b/gnu/usr.bin/groff/include/defs.h
deleted file mode 100644
index df2efba..0000000
--- a/gnu/usr.bin/groff/include/defs.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#define PROG_PREFIX ""
-#define DEVICE "ps"
-#define FONTPATH "/usr/share/groff_font"
-#define MACROPATH "/usr/share/tmac"
-#define INDEX_SUFFIX ".i"
-#define COMMON_WORDS_FILE "/usr/share/dict/eign"
-#define DEFAULT_INDEX_DIR "/usr/share/dict/papers"
-#define DEFAULT_INDEX_NAME "Ind"
-#define DEFAULT_INDEX "/usr/share/dict/papers/Ind"
diff --git a/gnu/usr.bin/groff/indxbib/Makefile b/gnu/usr.bin/groff/indxbib/Makefile
deleted file mode 100644
index 1e5768a..0000000
--- a/gnu/usr.bin/groff/indxbib/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# Makefile for indxbib
-
-PROG= indxbib
-SRCS= indxbib.cc dirnamemax.c signal.c
-CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBBIB} ${LIBGROFF} -lm
-DPADD+= ${LIBBIB} ${LIBGROFF} ${LIBM}
-
-MANDEPEND= indxbib.1
-CLEANFILES+= ${MANDEPEND}
-
-beforeinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
- ${DIST_DIR}/eign ${DESTDIR}${SHAREDIR}/dict/
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/libbib/Makefile b/gnu/usr.bin/groff/libbib/Makefile
deleted file mode 100644
index df2c5a9..0000000
--- a/gnu/usr.bin/groff/libbib/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for libbib
-
-LIB= bib
-SRCS= common.cc index.cc linear.cc search.cc map.c
-CFLAGS+= -I$(.CURDIR)/../include
-
-NOMAN= noman
-NOPROFILE= noprofile
-
-install:
-
-.include "../Makefile.cfg"
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/groff/libdriver/Makefile b/gnu/usr.bin/groff/libdriver/Makefile
deleted file mode 100644
index f1522d1..0000000
--- a/gnu/usr.bin/groff/libdriver/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for libdriver
-
-LIB= driver
-SRCS= input.cc printer.cc
-CFLAGS+= -I$(DIST_DIR)/../include
-
-NOMAN= noman
-NOPROFILE= noprofile
-
-install:
-
-.include "../Makefile.cfg"
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/groff/libgroff/Makefile b/gnu/usr.bin/groff/libgroff/Makefile
deleted file mode 100644
index 1061ea6..0000000
--- a/gnu/usr.bin/groff/libgroff/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-# Makefile for libgroff
-#
-# $Id$
-#
-.include "../Makefile.inc"
-
-LIB= groff
-SRCS= assert.cc change_lf.cc cmap.cc cset.cc device.cc errarg.cc\
- error.cc fatal.cc filename.cc font.cc fontfile.cc lf.cc\
- lineno.cc macropath.cc nametoindex.cc new.cc prime.cc\
- progname.cc ptable.cc searchpath.cc string.cc strsave.cc\
- tmpfile.cc illegal.cc version.cc
-SRCS+= iftoa.c itoa.c matherr.c
-CFLAGS+= -I$(.CURDIR)/../include
-
-NOMAN= noman
-NOPROFILE= noprofile
-
-CLEANFILES+= version.cc
-
-version.cc: $(GROFF_DIST)/VERSION
- @${ECHO} Making version.cc
- @echo const char \*version_string = \"`cat $(GROFF_DIST)/VERSION`\"\; >$@
-
-install:
-
-.include "../Makefile.cfg"
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/groff/lkbib/Makefile b/gnu/usr.bin/groff/lkbib/Makefile
deleted file mode 100644
index d00f0f6..0000000
--- a/gnu/usr.bin/groff/lkbib/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for lkbib
-
-PROG= lkbib
-SRCS= lkbib.cc
-CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBBIB} ${LIBGROFF} -lm
-DPADD+= ${LIBBIB} ${LIBGROFF} ${LIBM}
-
-MANDEPEND= lkbib.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/lookbib/Makefile b/gnu/usr.bin/groff/lookbib/Makefile
deleted file mode 100644
index fb1a65c..0000000
--- a/gnu/usr.bin/groff/lookbib/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for lookbib
-
-PROG= lookbib
-SRCS= lookbib.cc
-CFLAGS+= -I$(.CURDIR)/../include
-LDADD+= $(LIBBIB) $(LIBGROFF) -lm
-DPADD+= $(LIBBIB) $(LIBGROFF) $(LIBM)
-
-MANDEPEND= lookbib.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/man/Makefile b/gnu/usr.bin/groff/man/Makefile
deleted file mode 100644
index 4723c0a..0000000
--- a/gnu/usr.bin/groff/man/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# Makefile for manpages
-
-MAN5= groff_font.5 groff_out.5
-MAN7= groff_char.7
-
-MANDEPEND= ${MAN5} ${MAN7}
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/mm/Makefile b/gnu/usr.bin/groff/mm/Makefile
deleted file mode 100644
index 8ca6a1b..0000000
--- a/gnu/usr.bin/groff/mm/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-TMACOWN?= ${BINOWN}
-TMACGRP?= ${BINGRP}
-TMACMODE?= ${NOBINMODE}
-TMACDIR?= /usr/share/tmac
-
-FILES= 0.MT 5.MT 4.MT ms.cov se_ms.cov
-LOCALE= locale se_locale
-
-MAN7= groff_mm.7 groff_mmse.7
-MLINKS= groff_mm.7 mm.7 groff_mmse.7 mmse.7
-
-MANDEPEND= ${MAN7}
-CLEANFILES+= ${MANDEPEND}
-
-beforeinstall:
- ${INSTALL} -c -o ${TMACOWN} -g ${TMACGRP} -m ${TMACMODE} \
- ${DIST_DIR}/tmac.m ${DESTDIR}${TMACDIR}/
- ${INSTALL} -c -o ${TMACOWN} -g ${TMACGRP} -m ${TMACMODE} \
- ${DIST_DIR}/tmac.m ${DESTDIR}${TMACDIR}/tmac.mse
-.for file in ${FILES}
- ${INSTALL} -c -o ${TMACOWN} -g ${TMACGRP} -m ${TMACMODE} \
- ${DIST_DIR}/mm/${file} ${DESTDIR}${TMACDIR}/mm/
-.endfor
-.for locale in ${LOCALE}
-.if !exists(${locale}) || empty(${locale})
- ${INSTALL} -c -o ${TMACOWN} -g ${TMACGRP} -m ${TMACMODE} \
- /dev/null ${DESTDIR}${TMACDIR}/mm/${locale}
-.endif
-.endfor
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/nroff/Makefile b/gnu/usr.bin/groff/nroff/Makefile
deleted file mode 100644
index fbd7422..0000000
--- a/gnu/usr.bin/groff/nroff/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-MAN1= nroff.1 psroff.1
-MANDEPEND= nroff.1 psroff.1
-
-CLEANFILES+= ${MANDEPEND}
-
-afterinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- $(DIST_DIR)/nroff.sh $(DESTDIR)$(BINDIR)/nroff
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- $(DIST_DIR)/psroff.sh $(DESTDIR)$(BINDIR)/psroff
-
-.include <../Makefile.cfg>
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/pfbtops/Makefile b/gnu/usr.bin/groff/pfbtops/Makefile
deleted file mode 100644
index b2773a8..0000000
--- a/gnu/usr.bin/groff/pfbtops/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# Makefile for pfbtops
-
-PROG= pfbtops
-SRCS= pfbtops.c
-LDADD+= ${LIBGROFF}
-DPADD+= ${LIBGROFF}
-
-MANDEPEND= pfbtops.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/pic/Makefile b/gnu/usr.bin/groff/pic/Makefile
deleted file mode 100644
index 5a0e171..0000000
--- a/gnu/usr.bin/groff/pic/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Makefile for pic
-
-PROG= pic
-SRCS= lex.cc main.cc object.cc common.cc troff.cc tex.cc
-OBJS= pic.o
-CFLAGS+= -I. -I${.CURDIR}/../include
-LDADD+= ${LIBGROFF} -lm
-DPADD+= ${LIBGROFF} ${LIBM}
-
-MANDEPEND= pic.1
-CLEANFILES+= pic.cc pic.tab.h ${MANDEPEND}
-
-beforedepend: pic.cc
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/psbb/Makefile b/gnu/usr.bin/groff/psbb/Makefile
deleted file mode 100644
index 1339f53..0000000
--- a/gnu/usr.bin/groff/psbb/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# Makefile for psbb
-
-PROG= psbb
-SRCS= psbb.c
-
-MANDEPEND= psbb.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/refer/Makefile b/gnu/usr.bin/groff/refer/Makefile
deleted file mode 100644
index ac8d5f0..0000000
--- a/gnu/usr.bin/groff/refer/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# Makefile for refer
-
-PROG= refer
-SRCS= command.cc ref.cc refer.cc token.cc
-OBJS= label.o
-CFLAGS+= -I. -I${.CURDIR}/../include
-LDADD+= ${LIBBIB} ${LIBGROFF} -lm
-DPADD+= ${LIBBIB} ${LIBGROFF} ${LIBM}
-
-MANDEPEND= refer.1
-CLEANFILES+= label.cc label.tab.h ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/src/include/defs.h b/gnu/usr.bin/groff/src/include/defs.h
deleted file mode 100644
index df2efba..0000000
--- a/gnu/usr.bin/groff/src/include/defs.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#define PROG_PREFIX ""
-#define DEVICE "ps"
-#define FONTPATH "/usr/share/groff_font"
-#define MACROPATH "/usr/share/tmac"
-#define INDEX_SUFFIX ".i"
-#define COMMON_WORDS_FILE "/usr/share/dict/eign"
-#define DEFAULT_INDEX_DIR "/usr/share/dict/papers"
-#define DEFAULT_INDEX_NAME "Ind"
-#define DEFAULT_INDEX "/usr/share/dict/papers/Ind"
diff --git a/gnu/usr.bin/groff/src/roff/psroff/psroff.sh b/gnu/usr.bin/groff/src/roff/psroff/psroff.sh
deleted file mode 100644
index 8a90082..0000000
--- a/gnu/usr.bin/groff/src/roff/psroff/psroff.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#! /bin/sh -
-exec groff -Tps -l -C ${1+"$@"}
diff --git a/gnu/usr.bin/groff/tbl/Makefile b/gnu/usr.bin/groff/tbl/Makefile
deleted file mode 100644
index bdf9431..0000000
--- a/gnu/usr.bin/groff/tbl/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for tbl
-
-PROG= tbl
-SRCS= main.cc table.cc
-CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBGROFF} -lm
-DPADD+= ${LIBGROFF} ${LIBM}
-
-MANDEPEND= tbl.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/tfmtodit/Makefile b/gnu/usr.bin/groff/tfmtodit/Makefile
deleted file mode 100644
index 5413986..0000000
--- a/gnu/usr.bin/groff/tfmtodit/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for tfmtodit
-
-PROG= tfmtodit
-SRCS= tfmtodit.cc
-CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBGROFF} -lm
-DPADD+= ${LIBGROFF} ${LIBM}
-
-MANDEPEND= tfmtodit.1
-CLEANFILES+= ${MANDEPEND}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/tmac/Makefile b/gnu/usr.bin/groff/tmac/Makefile
deleted file mode 100644
index 25689e1..0000000
--- a/gnu/usr.bin/groff/tmac/Makefile
+++ /dev/null
@@ -1,48 +0,0 @@
-# Makefile for groff macros
-
-TMACOWN?= ${BINOWN}
-TMACGRP?= ${BINGRP}
-TMACMODE?= ${NOBINMODE}
-TMACDIR?= /usr/share/tmac
-MDOCDIR?= ${TMACDIR}/mdoc
-
-MAN7= groff_ms.7 me.7
-MLINKS= groff_ms.7 ms.7 me.7 groff_me.7
-LINKS= ${TMACDIR}/tmac.andoc ${TMACDIR}/tmac.an
-
-MANDEPEND= ${MAN7}
-CLEANFILES+= temp ${MANDEPEND} tmac.groff_an
-
-FILES= tmac.andoc tmac.pic tmac.ps tmac.psnew tmac.psold\
- tmac.pspic tmac.psatk tmac.dvi tmac.tty tmac.tty-char tmac.X\
- tmac.Xps tmac.latin1 tmac.lj4 eqnrc troffrc
-STRIPFILES= tmac.e tmac.s tmac.doc
-MDOCFILES= doc-common doc-ditroff doc-nroff doc-syms
-
-
-beforeinstall:
- for f in ${FILES}; do \
- ${INSTALL} -c -o ${TMACOWN} -g ${TMACGRP} -m ${TMACMODE} \
- ${DIST_DIR}/$$f ${DESTDIR}${TMACDIR}; \
- done
- sed -f ${DIST_DIR}/strip.sed ${DIST_DIR}/tmac.an >tmac.groff_an
- ${INSTALL} ${COPY} -o ${TMACOWN} -g ${TMACGRP} -m ${TMACMODE} \
- tmac.groff_an ${DESTDIR}${TMACDIR}
- for f in ${STRIPFILES}; do \
- rm -f temp; \
- sed -f ${DIST_DIR}/strip.sed ${DIST_DIR}/$$f >temp; \
- ${INSTALL} ${COPY} -o ${TMACOWN} -g ${TMACGRP} -m ${TMACMODE} \
- temp ${DESTDIR}${TMACDIR}/$$f; \
- done
- for f in ${MDOCFILES}; do \
- rm -f temp; \
- sed -f ${DIST_DIR}/strip.sed ${DIST_DIR}/$$f >temp; \
- ${INSTALL} ${COPY} -o ${TMACOWN} -g ${TMACGRP} -m ${TMACMODE} \
- temp ${DESTDIR}${MDOCDIR}/$$f; \
- done
- test -f ${DESTDIR}${TMACDIR}/man.local || \
- ${INSTALL} -c -o ${TMACOWN} -g ${TMACGRP} -m ${TMACMODE} \
- ${DIST_DIR}/man.local ${DESTDIR}${TMACDIR}
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/tmac/hyphen.us-ru b/gnu/usr.bin/groff/tmac/hyphen.us-ru
deleted file mode 100644
index 3ccef48..0000000
--- a/gnu/usr.bin/groff/tmac/hyphen.us-ru
+++ /dev/null
@@ -1,4833 +0,0 @@
-% Hyphenation patterns for US English and Russian (koi8-r).
-% These are the standard Plain TeX hyphenation patterns (in hyphen.tex).
-.ach4
-.ad4der
-.af1t
-.al3t
-.am5at
-.an5c
-.ang4
-.ani5m
-.ant4
-.an3te
-.anti5s
-.ar5s
-.ar4tie
-.ar4ty
-.as3c
-.as1p
-.as1s
-.aster5
-.atom5
-.au1d
-.av4i
-.awn4
-.ba4g
-.ba5na
-.bas4e
-.ber4
-.be5ra
-.be3sm
-.be5sto
-.bri2
-.but4ti
-.cam4pe
-.can5c
-.capa5b
-.car5ol
-.ca4t
-.ce4la
-.ch4
-.chill5i
-.ci2
-.cit5r
-.co3e
-.co4r
-.cor5ner
-.de4moi
-.de3o
-.de3ra
-.de3ri
-.des4c
-.dictio5
-.do4t
-.du4c
-.dumb5
-.earth5
-.eas3i
-.eb4
-.eer4
-.eg2
-.el5d
-.el3em
-.enam3
-.en3g
-.en3s
-.eq5ui5t
-.er4ri
-.es3
-.eu3
-.eye5
-.fes3
-.for5mer
-.ga2
-.ge2
-.gen3t4
-.ge5og
-.gi5a
-.gi4b
-.go4r
-.hand5i
-.han5k
-.he2
-.hero5i
-.hes3
-.het3
-.hi3b
-.hi3er
-.hon5ey
-.hon3o
-.hov5
-.id4l
-.idol3
-.im3m
-.im5pin
-.in1
-.in3ci
-.ine2
-.in2k
-.in3s
-.ir5r
-.is4i
-.ju3r
-.la4cy
-.la4m
-.lat5er
-.lath5
-.le2
-.leg5e
-.len4
-.lep5
-.lev1
-.li4g
-.lig5a
-.li2n
-.li3o
-.li4t
-.mag5a5
-.mal5o
-.man5a
-.mar5ti
-.me2
-.mer3c
-.me5ter
-.mis1
-.mist5i
-.mon3e
-.mo3ro
-.mu5ta
-.muta5b
-.ni4c
-.od2
-.odd5
-.of5te
-.or5ato
-.or3c
-.or1d
-.or3t
-.os3
-.os4tl
-.oth3
-.out3
-.ped5al
-.pe5te
-.pe5tit
-.pi4e
-.pio5n
-.pi2t
-.pre3m
-.ra4c
-.ran4t
-.ratio5na
-.ree2
-.re5mit
-.res2
-.re5stat
-.ri4g
-.rit5u
-.ro4q
-.ros5t
-.row5d
-.ru4d
-.sci3e
-.self5
-.sell5
-.se2n
-.se5rie
-.sh2
-.si2
-.sing4
-.st4
-.sta5bl
-.sy2
-.ta4
-.te4
-.ten5an
-.th2
-.ti2
-.til4
-.tim5o5
-.ting4
-.tin5k
-.ton4a
-.to4p
-.top5i
-.tou5s
-.trib5ut
-.un1a
-.un3ce
-.under5
-.un1e
-.un5k
-.un5o
-.un3u
-.up3
-.ure3
-.us5a
-.ven4de
-.ve5ra
-.wil5i
-.ye4
-4ab.
-a5bal
-a5ban
-abe2
-ab5erd
-abi5a
-ab5it5ab
-ab5lat
-ab5o5liz
-4abr
-ab5rog
-ab3ul
-a4car
-ac5ard
-ac5aro
-a5ceou
-ac1er
-a5chet
-4a2ci
-a3cie
-ac1in
-a3cio
-ac5rob
-act5if
-ac3ul
-ac4um
-a2d
-ad4din
-ad5er.
-2adi
-a3dia
-ad3ica
-adi4er
-a3dio
-a3dit
-a5diu
-ad4le
-ad3ow
-ad5ran
-ad4su
-4adu
-a3duc
-ad5um
-ae4r
-aeri4e
-a2f
-aff4
-a4gab
-aga4n
-ag5ell
-age4o
-4ageu
-ag1i
-4ag4l
-ag1n
-a2go
-3agog
-ag3oni
-a5guer
-ag5ul
-a4gy
-a3ha
-a3he
-ah4l
-a3ho
-ai2
-a5ia
-a3ic.
-ai5ly
-a4i4n
-ain5in
-ain5o
-ait5en
-a1j
-ak1en
-al5ab
-al3ad
-a4lar
-4aldi
-2ale
-al3end
-a4lenti
-a5le5o
-al1i
-al4ia.
-ali4e
-al5lev
-4allic
-4alm
-a5log.
-a4ly.
-4alys
-5a5lyst
-5alyt
-3alyz
-4ama
-am5ab
-am3ag
-ama5ra
-am5asc
-a4matis
-a4m5ato
-am5era
-am3ic
-am5if
-am5ily
-am1in
-ami4no
-a2mo
-a5mon
-amor5i
-amp5en
-a2n
-an3age
-3analy
-a3nar
-an3arc
-anar4i
-a3nati
-4and
-ande4s
-an3dis
-an1dl
-an4dow
-a5nee
-a3nen
-an5est.
-a3neu
-2ang
-ang5ie
-an1gl
-a4n1ic
-a3nies
-an3i3f
-an4ime
-a5nimi
-a5nine
-an3io
-a3nip
-an3ish
-an3it
-a3niu
-an4kli
-5anniz
-ano4
-an5ot
-anoth5
-an2sa
-an4sco
-an4sn
-an2sp
-ans3po
-an4st
-an4sur
-antal4
-an4tie
-4anto
-an2tr
-an4tw
-an3ua
-an3ul
-a5nur
-4ao
-apar4
-ap5at
-ap5ero
-a3pher
-4aphi
-a4pilla
-ap5illar
-ap3in
-ap3ita
-a3pitu
-a2pl
-apoc5
-ap5ola
-apor5i
-apos3t
-aps5es
-a3pu
-aque5
-2a2r
-ar3act
-a5rade
-ar5adis
-ar3al
-a5ramete
-aran4g
-ara3p
-ar4at
-a5ratio
-ar5ativ
-a5rau
-ar5av4
-araw4
-arbal4
-ar4chan
-ar5dine
-ar4dr
-ar5eas
-a3ree
-ar3ent
-a5ress
-ar4fi
-ar4fl
-ar1i
-ar5ial
-ar3ian
-a3riet
-ar4im
-ar5inat
-ar3io
-ar2iz
-ar2mi
-ar5o5d
-a5roni
-a3roo
-ar2p
-ar3q
-arre4
-ar4sa
-ar2sh
-4as.
-as4ab
-as3ant
-ashi4
-a5sia.
-a3sib
-a3sic
-5a5si4t
-ask3i
-as4l
-a4soc
-as5ph
-as4sh
-as3ten
-as1tr
-asur5a
-a2ta
-at3abl
-at5ac
-at3alo
-at5ap
-ate5c
-at5ech
-at3ego
-at3en.
-at3era
-ater5n
-a5terna
-at3est
-at5ev
-4ath
-ath5em
-a5then
-at4ho
-ath5om
-4ati.
-a5tia
-at5i5b
-at1ic
-at3if
-ation5ar
-at3itu
-a4tog
-a2tom
-at5omiz
-a4top
-a4tos
-a1tr
-at5rop
-at4sk
-at4tag
-at5te
-at4th
-a2tu
-at5ua
-at5ue
-at3ul
-at3ura
-a2ty
-au4b
-augh3
-au3gu
-au4l2
-aun5d
-au3r
-au5sib
-aut5en
-au1th
-a2va
-av3ag
-a5van
-ave4no
-av3era
-av5ern
-av5ery
-av1i
-avi4er
-av3ig
-av5oc
-a1vor
-3away
-aw3i
-aw4ly
-aws4
-ax4ic
-ax4id
-ay5al
-aye4
-ays4
-azi4er
-azz5i
-5ba.
-bad5ger
-ba4ge
-bal1a
-ban5dag
-ban4e
-ban3i
-barbi5
-bari4a
-bas4si
-1bat
-ba4z
-2b1b
-b2be
-b3ber
-bbi4na
-4b1d
-4be.
-beak4
-beat3
-4be2d
-be3da
-be3de
-be3di
-be3gi
-be5gu
-1bel
-be1li
-be3lo
-4be5m
-be5nig
-be5nu
-4bes4
-be3sp
-be5str
-3bet
-bet5iz
-be5tr
-be3tw
-be3w
-be5yo
-2bf
-4b3h
-bi2b
-bi4d
-3bie
-bi5en
-bi4er
-2b3if
-1bil
-bi3liz
-bina5r4
-bin4d
-bi5net
-bi3ogr
-bi5ou
-bi2t
-3bi3tio
-bi3tr
-3bit5ua
-b5itz
-b1j
-bk4
-b2l2
-blath5
-b4le.
-blen4
-5blesp
-b3lis
-b4lo
-blun4t
-4b1m
-4b3n
-bne5g
-3bod
-bod3i
-bo4e
-bol3ic
-bom4bi
-bon4a
-bon5at
-3boo
-5bor.
-4b1ora
-bor5d
-5bore
-5bori
-5bos4
-b5ota
-both5
-bo4to
-bound3
-4bp
-4brit
-broth3
-2b5s2
-bsor4
-2bt
-bt4l
-b4to
-b3tr
-buf4fer
-bu4ga
-bu3li
-bumi4
-bu4n
-bunt4i
-bu3re
-bus5ie
-buss4e
-5bust
-4buta
-3butio
-b5uto
-b1v
-4b5w
-5by.
-bys4
-1ca
-cab3in
-ca1bl
-cach4
-ca5den
-4cag4
-2c5ah
-ca3lat
-cal4la
-call5in
-4calo
-can5d
-can4e
-can4ic
-can5is
-can3iz
-can4ty
-cany4
-ca5per
-car5om
-cast5er
-cas5tig
-4casy
-ca4th
-4cativ
-cav5al
-c3c
-ccha5
-cci4a
-ccompa5
-ccon4
-ccou3t
-2ce.
-4ced.
-4ceden
-3cei
-5cel.
-3cell
-1cen
-3cenc
-2cen4e
-4ceni
-3cent
-3cep
-ce5ram
-4cesa
-3cessi
-ces5si5b
-ces5t
-cet4
-c5e4ta
-cew4
-2ch
-4ch.
-4ch3ab
-5chanic
-ch5a5nis
-che2
-cheap3
-4ched
-che5lo
-3chemi
-ch5ene
-ch3er.
-ch3ers
-4ch1in
-5chine.
-ch5iness
-5chini
-5chio
-3chit
-chi2z
-3cho2
-ch4ti
-1ci
-3cia
-ci2a5b
-cia5r
-ci5c
-4cier
-5cific.
-4cii
-ci4la
-3cili
-2cim
-2cin
-c4ina
-3cinat
-cin3em
-c1ing
-c5ing.
-5cino
-cion4
-4cipe
-ci3ph
-4cipic
-4cista
-4cisti
-2c1it
-cit3iz
-5ciz
-ck1
-ck3i
-1c4l4
-4clar
-c5laratio
-5clare
-cle4m
-4clic
-clim4
-cly4
-c5n
-1co
-co5ag
-coe2
-2cog
-co4gr
-coi4
-co3inc
-col5i
-5colo
-col3or
-com5er
-con4a
-c4one
-con3g
-con5t
-co3pa
-cop3ic
-co4pl
-4corb
-coro3n
-cos4e
-cov1
-cove4
-cow5a
-coz5e
-co5zi
-c1q
-cras5t
-5crat.
-5cratic
-cre3at
-5cred
-4c3reta
-cre4v
-cri2
-cri5f
-c4rin
-cris4
-5criti
-cro4pl
-crop5o
-cros4e
-cru4d
-4c3s2
-2c1t
-cta4b
-ct5ang
-c5tant
-c2te
-c3ter
-c4ticu
-ctim3i
-ctu4r
-c4tw
-cud5
-c4uf
-c4ui
-cu5ity
-5culi
-cul4tis
-3cultu
-cu2ma
-c3ume
-cu4mi
-3cun
-cu3pi
-cu5py
-cur5a4b
-cu5ria
-1cus
-cuss4i
-3c4ut
-cu4tie
-4c5utiv
-4cutr
-1cy
-cze4
-1d2a
-5da.
-2d3a4b
-dach4
-4daf
-2dag
-da2m2
-dan3g
-dard5
-dark5
-4dary
-3dat
-4dativ
-4dato
-5dav4
-dav5e
-5day
-d1b
-d5c
-d1d4
-2de.
-deaf5
-deb5it
-de4bon
-decan4
-de4cil
-de5com
-2d1ed
-4dee.
-de5if
-deli4e
-del5i5q
-de5lo
-d4em
-5dem.
-3demic
-dem5ic.
-de5mil
-de4mons
-demor5
-1den
-de4nar
-de3no
-denti5f
-de3nu
-de1p
-de3pa
-depi4
-de2pu
-d3eq
-d4erh
-5derm
-dern5iz
-der5s
-des2
-d2es.
-de1sc
-de2s5o
-des3ti
-de3str
-de4su
-de1t
-de2to
-de1v
-dev3il
-4dey
-4d1f
-d4ga
-d3ge4t
-dg1i
-d2gy
-d1h2
-5di.
-1d4i3a
-dia5b
-di4cam
-d4ice
-3dict
-3did
-5di3en
-d1if
-di3ge
-di4lato
-d1in
-1dina
-3dine.
-5dini
-di5niz
-1dio
-dio5g
-di4pl
-dir2
-di1re
-dirt5i
-dis1
-5disi
-d4is3t
-d2iti
-1di1v
-d1j
-d5k2
-4d5la
-3dle.
-3dled
-3dles.
-4dless
-2d3lo
-4d5lu
-2dly
-d1m
-4d1n4
-1do
-3do.
-do5de
-5doe
-2d5of
-d4og
-do4la
-doli4
-do5lor
-dom5iz
-do3nat
-doni4
-doo3d
-dop4p
-d4or
-3dos
-4d5out
-do4v
-3dox
-d1p
-1dr
-drag5on
-4drai
-dre4
-drea5r
-5dren
-dri4b
-dril4
-dro4p
-4drow
-5drupli
-4dry
-2d1s2
-ds4p
-d4sw
-d4sy
-d2th
-1du
-d1u1a
-du2c
-d1uca
-duc5er
-4duct.
-4ducts
-du5el
-du4g
-d3ule
-dum4be
-du4n
-4dup
-du4pe
-d1v
-d1w
-d2y
-5dyn
-dy4se
-dys5p
-e1a4b
-e3act
-ead1
-ead5ie
-ea4ge
-ea5ger
-ea4l
-eal5er
-eal3ou
-eam3er
-e5and
-ear3a
-ear4c
-ear5es
-ear4ic
-ear4il
-ear5k
-ear2t
-eart3e
-ea5sp
-e3ass
-east3
-ea2t
-eat5en
-eath3i
-e5atif
-e4a3tu
-ea2v
-eav3en
-eav5i
-eav5o
-2e1b
-e4bel.
-e4bels
-e4ben
-e4bit
-e3br
-e4cad
-ecan5c
-ecca5
-e1ce
-ec5essa
-ec2i
-e4cib
-ec5ificat
-ec5ifie
-ec5ify
-ec3im
-eci4t
-e5cite
-e4clam
-e4clus
-e2col
-e4comm
-e4compe
-e4conc
-e2cor
-ec3ora
-eco5ro
-e1cr
-e4crem
-ec4tan
-ec4te
-e1cu
-e4cul
-ec3ula
-2e2da
-4ed3d
-e4d1er
-ede4s
-4edi
-e3dia
-ed3ib
-ed3ica
-ed3im
-ed1it
-edi5z
-4edo
-e4dol
-edon2
-e4dri
-e4dul
-ed5ulo
-ee2c
-eed3i
-ee2f
-eel3i
-ee4ly
-ee2m
-ee4na
-ee4p1
-ee2s4
-eest4
-ee4ty
-e5ex
-e1f
-e4f3ere
-1eff
-e4fic
-5efici
-efil4
-e3fine
-ef5i5nite
-3efit
-efor5es
-e4fuse.
-4egal
-eger4
-eg5ib
-eg4ic
-eg5ing
-e5git5
-eg5n
-e4go.
-e4gos
-eg1ul
-e5gur
-5egy
-e1h4
-eher4
-ei2
-e5ic
-ei5d
-eig2
-ei5gl
-e3imb
-e3inf
-e1ing
-e5inst
-eir4d
-eit3e
-ei3th
-e5ity
-e1j
-e4jud
-ej5udi
-eki4n
-ek4la
-e1la
-e4la.
-e4lac
-elan4d
-el5ativ
-e4law
-elaxa4
-e3lea
-el5ebra
-5elec
-e4led
-el3ega
-e5len
-e4l1er
-e1les
-el2f
-el2i
-e3libe
-e4l5ic.
-el3ica
-e3lier
-el5igib
-e5lim
-e4l3ing
-e3lio
-e2lis
-el5ish
-e3liv3
-4ella
-el4lab
-ello4
-e5loc
-el5og
-el3op.
-el2sh
-el4ta
-e5lud
-el5ug
-e4mac
-e4mag
-e5man
-em5ana
-em5b
-e1me
-e2mel
-e4met
-em3ica
-emi4e
-em5igra
-em1in2
-em5ine
-em3i3ni
-e4mis
-em5ish
-e5miss
-em3iz
-5emniz
-emo4g
-emoni5o
-em3pi
-e4mul
-em5ula
-emu3n
-e3my
-en5amo
-e4nant
-ench4er
-en3dic
-e5nea
-e5nee
-en3em
-en5ero
-en5esi
-en5est
-en3etr
-e3new
-en5ics
-e5nie
-e5nil
-e3nio
-en3ish
-en3it
-e5niu
-5eniz
-4enn
-4eno
-eno4g
-e4nos
-en3ov
-en4sw
-ent5age
-4enthes
-en3ua
-en5uf
-e3ny.
-4en3z
-e5of
-eo2g
-e4oi4
-e3ol
-eop3ar
-e1or
-eo3re
-eo5rol
-eos4
-e4ot
-eo4to
-e5out
-e5ow
-e2pa
-e3pai
-ep5anc
-e5pel
-e3pent
-ep5etitio
-ephe4
-e4pli
-e1po
-e4prec
-ep5reca
-e4pred
-ep3reh
-e3pro
-e4prob
-ep4sh
-ep5ti5b
-e4put
-ep5uta
-e1q
-equi3l
-e4q3ui3s
-er1a
-era4b
-4erand
-er3ar
-4erati.
-2erb
-er4bl
-er3ch
-er4che
-2ere.
-e3real
-ere5co
-ere3in
-er5el.
-er3emo
-er5ena
-er5ence
-4erene
-er3ent
-ere4q
-er5ess
-er3est
-eret4
-er1h
-er1i
-e1ria4
-5erick
-e3rien
-eri4er
-er3ine
-e1rio
-4erit
-er4iu
-eri4v
-e4riva
-er3m4
-er4nis
-4ernit
-5erniz
-er3no
-2ero
-er5ob
-e5roc
-ero4r
-er1ou
-er1s
-er3set
-ert3er
-4ertl
-er3tw
-4eru
-eru4t
-5erwau
-e1s4a
-e4sage.
-e4sages
-es2c
-e2sca
-es5can
-e3scr
-es5cu
-e1s2e
-e2sec
-es5ecr
-es5enc
-e4sert.
-e4serts
-e4serva
-4esh
-e3sha
-esh5en
-e1si
-e2sic
-e2sid
-es5iden
-es5igna
-e2s5im
-es4i4n
-esis4te
-esi4u
-e5skin
-es4mi
-e2sol
-es3olu
-e2son
-es5ona
-e1sp
-es3per
-es5pira
-es4pre
-2ess
-es4si4b
-estan4
-es3tig
-es5tim
-4es2to
-e3ston
-2estr
-e5stro
-estruc5
-e2sur
-es5urr
-es4w
-eta4b
-eten4d
-e3teo
-ethod3
-et1ic
-e5tide
-etin4
-eti4no
-e5tir
-e5titio
-et5itiv
-4etn
-et5ona
-e3tra
-e3tre
-et3ric
-et5rif
-et3rog
-et5ros
-et3ua
-et5ym
-et5z
-4eu
-e5un
-e3up
-eu3ro
-eus4
-eute4
-euti5l
-eu5tr
-eva2p5
-e2vas
-ev5ast
-e5vea
-ev3ell
-evel3o
-e5veng
-even4i
-ev1er
-e5verb
-e1vi
-ev3id
-evi4l
-e4vin
-evi4v
-e5voc
-e5vu
-e1wa
-e4wag
-e5wee
-e3wh
-ewil5
-ew3ing
-e3wit
-1exp
-5eyc
-5eye.
-eys4
-1fa
-fa3bl
-fab3r
-fa4ce
-4fag
-fain4
-fall5e
-4fa4ma
-fam5is
-5far
-far5th
-fa3ta
-fa3the
-4fato
-fault5
-4f5b
-4fd
-4fe.
-feas4
-feath3
-fe4b
-4feca
-5fect
-2fed
-fe3li
-fe4mo
-fen2d
-fend5e
-fer1
-5ferr
-fev4
-4f1f
-f4fes
-f4fie
-f5fin.
-f2f5is
-f4fly
-f2fy
-4fh
-1fi
-fi3a
-2f3ic.
-4f3ical
-f3ican
-4ficate
-f3icen
-fi3cer
-fic4i
-5ficia
-5ficie
-4fics
-fi3cu
-fi5del
-fight5
-fil5i
-fill5in
-4fily
-2fin
-5fina
-fin2d5
-fi2ne
-f1in3g
-fin4n
-fis4ti
-f4l2
-f5less
-flin4
-flo3re
-f2ly5
-4fm
-4fn
-1fo
-5fon
-fon4de
-fon4t
-fo2r
-fo5rat
-for5ay
-fore5t
-for4i
-fort5a
-fos5
-4f5p
-fra4t
-f5rea
-fres5c
-fri2
-fril4
-frol5
-2f3s
-2ft
-f4to
-f2ty
-3fu
-fu5el
-4fug
-fu4min
-fu5ne
-fu3ri
-fusi4
-fus4s
-4futa
-1fy
-1ga
-gaf4
-5gal.
-3gali
-ga3lo
-2gam
-ga5met
-g5amo
-gan5is
-ga3niz
-gani5za
-4gano
-gar5n4
-gass4
-gath3
-4gativ
-4gaz
-g3b
-gd4
-2ge.
-2ged
-geez4
-gel4in
-ge5lis
-ge5liz
-4gely
-1gen
-ge4nat
-ge5niz
-4geno
-4geny
-1geo
-ge3om
-g4ery
-5gesi
-geth5
-4geto
-ge4ty
-ge4v
-4g1g2
-g2ge
-g3ger
-gglu5
-ggo4
-gh3in
-gh5out
-gh4to
-5gi.
-1gi4a
-gia5r
-g1ic
-5gicia
-g4ico
-gien5
-5gies.
-gil4
-g3imen
-3g4in.
-gin5ge
-5g4ins
-5gio
-3gir
-gir4l
-g3isl
-gi4u
-5giv
-3giz
-gl2
-gla4
-glad5i
-5glas
-1gle
-gli4b
-g3lig
-3glo
-glo3r
-g1m
-g4my
-gn4a
-g4na.
-gnet4t
-g1ni
-g2nin
-g4nio
-g1no
-g4non
-1go
-3go.
-gob5
-5goe
-3g4o4g
-go3is
-gon2
-4g3o3na
-gondo5
-go3ni
-5goo
-go5riz
-gor5ou
-5gos.
-gov1
-g3p
-1gr
-4grada
-g4rai
-gran2
-5graph.
-g5rapher
-5graphic
-4graphy
-4gray
-gre4n
-4gress.
-4grit
-g4ro
-gruf4
-gs2
-g5ste
-gth3
-gu4a
-3guard
-2gue
-5gui5t
-3gun
-3gus
-4gu4t
-g3w
-1gy
-2g5y3n
-gy5ra
-h3ab4l
-hach4
-hae4m
-hae4t
-h5agu
-ha3la
-hala3m
-ha4m
-han4ci
-han4cy
-5hand.
-han4g
-hang5er
-hang5o
-h5a5niz
-han4k
-han4te
-hap3l
-hap5t
-ha3ran
-ha5ras
-har2d
-hard3e
-har4le
-harp5en
-har5ter
-has5s
-haun4
-5haz
-haz3a
-h1b
-1head
-3hear
-he4can
-h5ecat
-h4ed
-he5do5
-he3l4i
-hel4lis
-hel4ly
-h5elo
-hem4p
-he2n
-hena4
-hen5at
-heo5r
-hep5
-h4era
-hera3p
-her4ba
-here5a
-h3ern
-h5erou
-h3ery
-h1es
-he2s5p
-he4t
-het4ed
-heu4
-h1f
-h1h
-hi5an
-hi4co
-high5
-h4il2
-himer4
-h4ina
-hion4e
-hi4p
-hir4l
-hi3ro
-hir4p
-hir4r
-his3el
-his4s
-hith5er
-hi2v
-4hk
-4h1l4
-hlan4
-h2lo
-hlo3ri
-4h1m
-hmet4
-2h1n
-h5odiz
-h5ods
-ho4g
-hoge4
-hol5ar
-3hol4e
-ho4ma
-home3
-hon4a
-ho5ny
-3hood
-hoon4
-hor5at
-ho5ris
-hort3e
-ho5ru
-hos4e
-ho5sen
-hos1p
-1hous
-house3
-hov5el
-4h5p
-4hr4
-hree5
-hro5niz
-hro3po
-4h1s2
-h4sh
-h4tar
-ht1en
-ht5es
-h4ty
-hu4g
-hu4min
-hun5ke
-hun4t
-hus3t4
-hu4t
-h1w
-h4wart
-hy3pe
-hy3ph
-hy2s
-2i1a
-i2al
-iam4
-iam5ete
-i2an
-4ianc
-ian3i
-4ian4t
-ia5pe
-iass4
-i4ativ
-ia4tric
-i4atu
-ibe4
-ib3era
-ib5ert
-ib5ia
-ib3in
-ib5it.
-ib5ite
-i1bl
-ib3li
-i5bo
-i1br
-i2b5ri
-i5bun
-4icam
-5icap
-4icar
-i4car.
-i4cara
-icas5
-i4cay
-iccu4
-4iceo
-4ich
-2ici
-i5cid
-ic5ina
-i2cip
-ic3ipa
-i4cly
-i2c5oc
-4i1cr
-5icra
-i4cry
-ic4te
-ictu2
-ic4t3ua
-ic3ula
-ic4um
-ic5uo
-i3cur
-2id
-i4dai
-id5anc
-id5d
-ide3al
-ide4s
-i2di
-id5ian
-idi4ar
-i5die
-id3io
-idi5ou
-id1it
-id5iu
-i3dle
-i4dom
-id3ow
-i4dr
-i2du
-id5uo
-2ie4
-ied4e
-5ie5ga
-ield3
-ien5a4
-ien4e
-i5enn
-i3enti
-i1er.
-i3esc
-i1est
-i3et
-4if.
-if5ero
-iff5en
-if4fr
-4ific.
-i3fie
-i3fl
-4ift
-2ig
-iga5b
-ig3era
-ight3i
-4igi
-i3gib
-ig3il
-ig3in
-ig3it
-i4g4l
-i2go
-ig3or
-ig5ot
-i5gre
-igu5i
-ig1ur
-i3h
-4i5i4
-i3j
-4ik
-i1la
-il3a4b
-i4lade
-i2l5am
-ila5ra
-i3leg
-il1er
-ilev4
-il5f
-il1i
-il3ia
-il2ib
-il3io
-il4ist
-2ilit
-il2iz
-ill5ab
-4iln
-il3oq
-il4ty
-il5ur
-il3v
-i4mag
-im3age
-ima5ry
-imenta5r
-4imet
-im1i
-im5ida
-imi5le
-i5mini
-4imit
-im4ni
-i3mon
-i2mu
-im3ula
-2in.
-i4n3au
-4inav
-incel4
-in3cer
-4ind
-in5dling
-2ine
-i3nee
-iner4ar
-i5ness
-4inga
-4inge
-in5gen
-4ingi
-in5gling
-4ingo
-4ingu
-2ini
-i5ni.
-i4nia
-in3io
-in1is
-i5nite.
-5initio
-in3ity
-4ink
-4inl
-2inn
-2i1no
-i4no4c
-ino4s
-i4not
-2ins
-in3se
-insur5a
-2int.
-2in4th
-in1u
-i5nus
-4iny
-2io
-4io.
-ioge4
-io2gr
-i1ol
-io4m
-ion3at
-ion4ery
-ion3i
-io5ph
-ior3i
-i4os
-io5th
-i5oti
-io4to
-i4our
-2ip
-ipe4
-iphras4
-ip3i
-ip4ic
-ip4re4
-ip3ul
-i3qua
-iq5uef
-iq3uid
-iq3ui3t
-4ir
-i1ra
-ira4b
-i4rac
-ird5e
-ire4de
-i4ref
-i4rel4
-i4res
-ir5gi
-ir1i
-iri5de
-ir4is
-iri3tu
-5i5r2iz
-ir4min
-iro4g
-5iron.
-ir5ul
-2is.
-is5ag
-is3ar
-isas5
-2is1c
-is3ch
-4ise
-is3er
-3isf
-is5han
-is3hon
-ish5op
-is3ib
-isi4d
-i5sis
-is5itiv
-4is4k
-islan4
-4isms
-i2so
-iso5mer
-is1p
-is2pi
-is4py
-4is1s
-is4sal
-issen4
-is4ses
-is4ta.
-is1te
-is1ti
-ist4ly
-4istral
-i2su
-is5us
-4ita.
-ita4bi
-i4tag
-4ita5m
-i3tan
-i3tat
-2ite
-it3era
-i5teri
-it4es
-2ith
-i1ti
-4itia
-4i2tic
-it3ica
-5i5tick
-it3ig
-it5ill
-i2tim
-2itio
-4itis
-i4tism
-i2t5o5m
-4iton
-i4tram
-it5ry
-4itt
-it3uat
-i5tud
-it3ul
-4itz.
-i1u
-2iv
-iv3ell
-iv3en.
-i4v3er.
-i4vers.
-iv5il.
-iv5io
-iv1it
-i5vore
-iv3o3ro
-i4v3ot
-4i5w
-ix4o
-4iy
-4izar
-izi4
-5izont
-5ja
-jac4q
-ja4p
-1je
-jer5s
-4jestie
-4jesty
-jew3
-jo4p
-5judg
-3ka.
-k3ab
-k5ag
-kais4
-kal4
-k1b
-k2ed
-1kee
-ke4g
-ke5li
-k3en4d
-k1er
-kes4
-k3est.
-ke4ty
-k3f
-kh4
-k1i
-5ki.
-5k2ic
-k4ill
-kilo5
-k4im
-k4in.
-kin4de
-k5iness
-kin4g
-ki4p
-kis4
-k5ish
-kk4
-k1l
-4kley
-4kly
-k1m
-k5nes
-1k2no
-ko5r
-kosh4
-k3ou
-kro5n
-4k1s2
-k4sc
-ks4l
-k4sy
-k5t
-k1w
-lab3ic
-l4abo
-laci4
-l4ade
-la3dy
-lag4n
-lam3o
-3land
-lan4dl
-lan5et
-lan4te
-lar4g
-lar3i
-las4e
-la5tan
-4lateli
-4lativ
-4lav
-la4v4a
-2l1b
-lbin4
-4l1c2
-lce4
-l3ci
-2ld
-l2de
-ld4ere
-ld4eri
-ldi4
-ld5is
-l3dr
-l4dri
-le2a
-le4bi
-left5
-5leg.
-5legg
-le4mat
-lem5atic
-4len.
-3lenc
-5lene.
-1lent
-le3ph
-le4pr
-lera5b
-ler4e
-3lerg
-3l4eri
-l4ero
-les2
-le5sco
-5lesq
-3less
-5less.
-l3eva
-lev4er.
-lev4era
-lev4ers
-3ley
-4leye
-2lf
-l5fr
-4l1g4
-l5ga
-lgar3
-l4ges
-lgo3
-2l3h
-li4ag
-li2am
-liar5iz
-li4as
-li4ato
-li5bi
-5licio
-li4cor
-4lics
-4lict.
-l4icu
-l3icy
-l3ida
-lid5er
-3lidi
-lif3er
-l4iff
-li4fl
-5ligate
-3ligh
-li4gra
-3lik
-4l4i4l
-lim4bl
-lim3i
-li4mo
-l4im4p
-l4ina
-1l4ine
-lin3ea
-lin3i
-link5er
-li5og
-4l4iq
-lis4p
-l1it
-l2it.
-5litica
-l5i5tics
-liv3er
-l1iz
-4lj
-lka3
-l3kal
-lka4t
-l1l
-l4law
-l2le
-l5lea
-l3lec
-l3leg
-l3lel
-l3le4n
-l3le4t
-ll2i
-l2lin4
-l5lina
-ll4o
-lloqui5
-ll5out
-l5low
-2lm
-l5met
-lm3ing
-l4mod
-lmon4
-2l1n2
-3lo.
-lob5al
-lo4ci
-4lof
-3logic
-l5ogo
-3logu
-lom3er
-5long
-lon4i
-l3o3niz
-lood5
-5lope.
-lop3i
-l3opm
-lora4
-lo4rato
-lo5rie
-lor5ou
-5los.
-los5et
-5losophiz
-5losophy
-los4t
-lo4ta
-loun5d
-2lout
-4lov
-2lp
-lpa5b
-l3pha
-l5phi
-lp5ing
-l3pit
-l4pl
-l5pr
-4l1r
-2l1s2
-l4sc
-l2se
-l4sie
-4lt
-lt5ag
-ltane5
-l1te
-lten4
-ltera4
-lth3i
-l5ties.
-ltis4
-l1tr
-ltu2
-ltur3a
-lu5a
-lu3br
-luch4
-lu3ci
-lu3en
-luf4
-lu5id
-lu4ma
-5lumi
-l5umn.
-5lumnia
-lu3o
-luo3r
-4lup
-luss4
-lus3te
-1lut
-l5ven
-l5vet4
-2l1w
-1ly
-4lya
-4lyb
-ly5me
-ly3no
-2lys4
-l5yse
-1ma
-2mab
-ma2ca
-ma5chine
-ma4cl
-mag5in
-5magn
-2mah
-maid5
-4mald
-ma3lig
-ma5lin
-mal4li
-mal4ty
-5mania
-man5is
-man3iz
-4map
-ma5rine.
-ma5riz
-mar4ly
-mar3v
-ma5sce
-mas4e
-mas1t
-5mate
-math3
-ma3tis
-4matiza
-4m1b
-mba4t5
-m5bil
-m4b3ing
-mbi4v
-4m5c
-4me.
-2med
-4med.
-5media
-me3die
-m5e5dy
-me2g
-mel5on
-mel4t
-me2m
-mem1o3
-1men
-men4a
-men5ac
-men4de
-4mene
-men4i
-mens4
-mensu5
-3ment
-men4te
-me5on
-m5ersa
-2mes
-3mesti
-me4ta
-met3al
-me1te
-me5thi
-m4etr
-5metric
-me5trie
-me3try
-me4v
-4m1f
-2mh
-5mi.
-mi3a
-mid4a
-mid4g
-mig4
-3milia
-m5i5lie
-m4ill
-min4a
-3mind
-m5inee
-m4ingl
-min5gli
-m5ingly
-min4t
-m4inu
-miot4
-m2is
-mis4er.
-mis5l
-mis4ti
-m5istry
-4mith
-m2iz
-4mk
-4m1l
-m1m
-mma5ry
-4m1n
-mn4a
-m4nin
-mn4o
-1mo
-4mocr
-5mocratiz
-mo2d1
-mo4go
-mois2
-moi5se
-4mok
-mo5lest
-mo3me
-mon5et
-mon5ge
-moni3a
-mon4ism
-mon4ist
-mo3niz
-monol4
-mo3ny.
-mo2r
-4mora.
-mos2
-mo5sey
-mo3sp
-moth3
-m5ouf
-3mous
-mo2v
-4m1p
-mpara5
-mpa5rab
-mpar5i
-m3pet
-mphas4
-m2pi
-mpi4a
-mp5ies
-m4p1in
-m5pir
-mp5is
-mpo3ri
-mpos5ite
-m4pous
-mpov5
-mp4tr
-m2py
-4m3r
-4m1s2
-m4sh
-m5si
-4mt
-1mu
-mula5r4
-5mult
-multi3
-3mum
-mun2
-4mup
-mu4u
-4mw
-1na
-2n1a2b
-n4abu
-4nac.
-na4ca
-n5act
-nag5er.
-nak4
-na4li
-na5lia
-4nalt
-na5mit
-n2an
-nanci4
-nan4it
-nank4
-nar3c
-4nare
-nar3i
-nar4l
-n5arm
-n4as
-nas4c
-nas5ti
-n2at
-na3tal
-nato5miz
-n2au
-nau3se
-3naut
-nav4e
-4n1b4
-ncar5
-n4ces.
-n3cha
-n5cheo
-n5chil
-n3chis
-nc1in
-nc4it
-ncour5a
-n1cr
-n1cu
-n4dai
-n5dan
-n1de
-nd5est.
-ndi4b
-n5d2if
-n1dit
-n3diz
-n5duc
-ndu4r
-nd2we
-2ne.
-n3ear
-ne2b
-neb3u
-ne2c
-5neck
-2ned
-ne4gat
-neg5ativ
-5nege
-ne4la
-nel5iz
-ne5mi
-ne4mo
-1nen
-4nene
-3neo
-ne4po
-ne2q
-n1er
-nera5b
-n4erar
-n2ere
-n4er5i
-ner4r
-1nes
-2nes.
-4nesp
-2nest
-4nesw
-3netic
-ne4v
-n5eve
-ne4w
-n3f
-n4gab
-n3gel
-nge4n4e
-n5gere
-n3geri
-ng5ha
-n3gib
-ng1in
-n5git
-n4gla
-ngov4
-ng5sh
-n1gu
-n4gum
-n2gy
-4n1h4
-nha4
-nhab3
-nhe4
-3n4ia
-ni3an
-ni4ap
-ni3ba
-ni4bl
-ni4d
-ni5di
-ni4er
-ni2fi
-ni5ficat
-n5igr
-nik4
-n1im
-ni3miz
-n1in
-5nine.
-nin4g
-ni4o
-5nis.
-nis4ta
-n2it
-n4ith
-3nitio
-n3itor
-ni3tr
-n1j
-4nk2
-n5kero
-n3ket
-nk3in
-n1kl
-4n1l
-n5m
-nme4
-nmet4
-4n1n2
-nne4
-nni3al
-nni4v
-nob4l
-no3ble
-n5ocl
-4n3o2d
-3noe
-4nog
-noge4
-nois5i
-no5l4i
-5nologis
-3nomic
-n5o5miz
-no4mo
-no3my
-no4n
-non4ag
-non5i
-n5oniz
-4nop
-5nop5o5li
-nor5ab
-no4rary
-4nosc
-nos4e
-nos5t
-no5ta
-1nou
-3noun
-nov3el3
-nowl3
-n1p4
-npi4
-npre4c
-n1q
-n1r
-nru4
-2n1s2
-ns5ab
-nsati4
-ns4c
-n2se
-n4s3es
-nsid1
-nsig4
-n2sl
-ns3m
-n4soc
-ns4pe
-n5spi
-nsta5bl
-n1t
-nta4b
-nter3s
-nt2i
-n5tib
-nti4er
-nti2f
-n3tine
-n4t3ing
-nti4p
-ntrol5li
-nt4s
-ntu3me
-nu1a
-nu4d
-nu5en
-nuf4fe
-n3uin
-3nu3it
-n4um
-nu1me
-n5umi
-3nu4n
-n3uo
-nu3tr
-n1v2
-n1w4
-nym4
-nyp4
-4nz
-n3za
-4oa
-oad3
-o5a5les
-oard3
-oas4e
-oast5e
-oat5i
-ob3a3b
-o5bar
-obe4l
-o1bi
-o2bin
-ob5ing
-o3br
-ob3ul
-o1ce
-och4
-o3chet
-ocif3
-o4cil
-o4clam
-o4cod
-oc3rac
-oc5ratiz
-ocre3
-5ocrit
-octor5a
-oc3ula
-o5cure
-od5ded
-od3ic
-odi3o
-o2do4
-odor3
-od5uct.
-od5ucts
-o4el
-o5eng
-o3er
-oe4ta
-o3ev
-o2fi
-of5ite
-ofit4t
-o2g5a5r
-og5ativ
-o4gato
-o1ge
-o5gene
-o5geo
-o4ger
-o3gie
-1o1gis
-og3it
-o4gl
-o5g2ly
-3ogniz
-o4gro
-ogu5i
-1ogy
-2ogyn
-o1h2
-ohab5
-oi2
-oic3es
-oi3der
-oiff4
-oig4
-oi5let
-o3ing
-oint5er
-o5ism
-oi5son
-oist5en
-oi3ter
-o5j
-2ok
-o3ken
-ok5ie
-o1la
-o4lan
-olass4
-ol2d
-old1e
-ol3er
-o3lesc
-o3let
-ol4fi
-ol2i
-o3lia
-o3lice
-ol5id.
-o3li4f
-o5lil
-ol3ing
-o5lio
-o5lis.
-ol3ish
-o5lite
-o5litio
-o5liv
-olli4e
-ol5ogiz
-olo4r
-ol5pl
-ol2t
-ol3ub
-ol3ume
-ol3un
-o5lus
-ol2v
-o2ly
-om5ah
-oma5l
-om5atiz
-om2be
-om4bl
-o2me
-om3ena
-om5erse
-o4met
-om5etry
-o3mia
-om3ic.
-om3ica
-o5mid
-om1in
-o5mini
-5ommend
-omo4ge
-o4mon
-om3pi
-ompro5
-o2n
-on1a
-on4ac
-o3nan
-on1c
-3oncil
-2ond
-on5do
-o3nen
-on5est
-on4gu
-on1ic
-o3nio
-on1is
-o5niu
-on3key
-on4odi
-on3omy
-on3s
-onspi4
-onspir5a
-onsu4
-onten4
-on3t4i
-ontif5
-on5um
-onva5
-oo2
-ood5e
-ood5i
-oo4k
-oop3i
-o3ord
-oost5
-o2pa
-ope5d
-op1er
-3opera
-4operag
-2oph
-o5phan
-o5pher
-op3ing
-o3pit
-o5pon
-o4posi
-o1pr
-op1u
-opy5
-o1q
-o1ra
-o5ra.
-o4r3ag
-or5aliz
-or5ange
-ore5a
-o5real
-or3ei
-ore5sh
-or5est.
-orew4
-or4gu
-4o5ria
-or3ica
-o5ril
-or1in
-o1rio
-or3ity
-o3riu
-or2mi
-orn2e
-o5rof
-or3oug
-or5pe
-3orrh
-or4se
-ors5en
-orst4
-or3thi
-or3thy
-or4ty
-o5rum
-o1ry
-os3al
-os2c
-os4ce
-o3scop
-4oscopi
-o5scr
-os4i4e
-os5itiv
-os3ito
-os3ity
-osi4u
-os4l
-o2so
-os4pa
-os4po
-os2ta
-o5stati
-os5til
-os5tit
-o4tan
-otele4g
-ot3er.
-ot5ers
-o4tes
-4oth
-oth5esi
-oth3i4
-ot3ic.
-ot5ica
-o3tice
-o3tif
-o3tis
-oto5s
-ou2
-ou3bl
-ouch5i
-ou5et
-ou4l
-ounc5er
-oun2d
-ou5v
-ov4en
-over4ne
-over3s
-ov4ert
-o3vis
-oviti4
-o5v4ol
-ow3der
-ow3el
-ow5est
-ow1i
-own5i
-o4wo
-oy1a
-1pa
-pa4ca
-pa4ce
-pac4t
-p4ad
-5pagan
-p3agat
-p4ai
-pain4
-p4al
-pan4a
-pan3el
-pan4ty
-pa3ny
-pa1p
-pa4pu
-para5bl
-par5age
-par5di
-3pare
-par5el
-p4a4ri
-par4is
-pa2te
-pa5ter
-5pathic
-pa5thy
-pa4tric
-pav4
-3pay
-4p1b
-pd4
-4pe.
-3pe4a
-pear4l
-pe2c
-2p2ed
-3pede
-3pedi
-pedia4
-ped4ic
-p4ee
-pee4d
-pek4
-pe4la
-peli4e
-pe4nan
-p4enc
-pen4th
-pe5on
-p4era.
-pera5bl
-p4erag
-p4eri
-peri5st
-per4mal
-perme5
-p4ern
-per3o
-per3ti
-pe5ru
-per1v
-pe2t
-pe5ten
-pe5tiz
-4pf
-4pg
-4ph.
-phar5i
-phe3no
-ph4er
-ph4es.
-ph1ic
-5phie
-ph5ing
-5phisti
-3phiz
-ph2l
-3phob
-3phone
-5phoni
-pho4r
-4phs
-ph3t
-5phu
-1phy
-pi3a
-pian4
-pi4cie
-pi4cy
-p4id
-p5ida
-pi3de
-5pidi
-3piec
-pi3en
-pi4grap
-pi3lo
-pi2n
-p4in.
-pind4
-p4ino
-3pi1o
-pion4
-p3ith
-pi5tha
-pi2tu
-2p3k2
-1p2l2
-3plan
-plas5t
-pli3a
-pli5er
-4plig
-pli4n
-ploi4
-plu4m
-plum4b
-4p1m
-2p3n
-po4c
-5pod.
-po5em
-po3et5
-5po4g
-poin2
-5point
-poly5t
-po4ni
-po4p
-1p4or
-po4ry
-1pos
-pos1s
-p4ot
-po4ta
-5poun
-4p1p
-ppa5ra
-p2pe
-p4ped
-p5pel
-p3pen
-p3per
-p3pet
-ppo5site
-pr2
-pray4e
-5preci
-pre5co
-pre3em
-pref5ac
-pre4la
-pre3r
-p3rese
-3press
-pre5ten
-pre3v
-5pri4e
-prin4t3
-pri4s
-pris3o
-p3roca
-prof5it
-pro3l
-pros3e
-pro1t
-2p1s2
-p2se
-ps4h
-p4sib
-2p1t
-pt5a4b
-p2te
-p2th
-pti3m
-ptu4r
-p4tw
-pub3
-pue4
-puf4
-pul3c
-pu4m
-pu2n
-pur4r
-5pus
-pu2t
-5pute
-put3er
-pu3tr
-put4ted
-put4tin
-p3w
-qu2
-qua5v
-2que.
-3quer
-3quet
-2rab
-ra3bi
-rach4e
-r5acl
-raf5fi
-raf4t
-r2ai
-ra4lo
-ram3et
-r2ami
-rane5o
-ran4ge
-r4ani
-ra5no
-rap3er
-3raphy
-rar5c
-rare4
-rar5ef
-4raril
-r2as
-ration4
-rau4t
-ra5vai
-rav3el
-ra5zie
-r1b
-r4bab
-r4bag
-rbi2
-rbi4f
-r2bin
-r5bine
-rb5ing.
-rb4o
-r1c
-r2ce
-rcen4
-r3cha
-rch4er
-r4ci4b
-rc4it
-rcum3
-r4dal
-rd2i
-rdi4a
-rdi4er
-rdin4
-rd3ing
-2re.
-re1al
-re3an
-re5arr
-5reav
-re4aw
-r5ebrat
-rec5oll
-rec5ompe
-re4cre
-2r2ed
-re1de
-re3dis
-red5it
-re4fac
-re2fe
-re5fer.
-re3fi
-re4fy
-reg3is
-re5it
-re1li
-re5lu
-r4en4ta
-ren4te
-re1o
-re5pin
-re4posi
-re1pu
-r1er4
-r4eri
-rero4
-re5ru
-r4es.
-re4spi
-ress5ib
-res2t
-re5stal
-re3str
-re4ter
-re4ti4z
-re3tri
-reu2
-re5uti
-rev2
-re4val
-rev3el
-r5ev5er.
-re5vers
-re5vert
-re5vil
-rev5olu
-re4wh
-r1f
-rfu4
-r4fy
-rg2
-rg3er
-r3get
-r3gic
-rgi4n
-rg3ing
-r5gis
-r5git
-r1gl
-rgo4n
-r3gu
-rh4
-4rh.
-4rhal
-ri3a
-ria4b
-ri4ag
-r4ib
-rib3a
-ric5as
-r4ice
-4rici
-5ricid
-ri4cie
-r4ico
-rid5er
-ri3enc
-ri3ent
-ri1er
-ri5et
-rig5an
-5rigi
-ril3iz
-5riman
-rim5i
-3rimo
-rim4pe
-r2ina
-5rina.
-rin4d
-rin4e
-rin4g
-ri1o
-5riph
-riph5e
-ri2pl
-rip5lic
-r4iq
-r2is
-r4is.
-ris4c
-r3ish
-ris4p
-ri3ta3b
-r5ited.
-rit5er.
-rit5ers
-rit3ic
-ri2tu
-rit5ur
-riv5el
-riv3et
-riv3i
-r3j
-r3ket
-rk4le
-rk4lin
-r1l
-rle4
-r2led
-r4lig
-r4lis
-rl5ish
-r3lo4
-r1m
-rma5c
-r2me
-r3men
-rm5ers
-rm3ing
-r4ming.
-r4mio
-r3mit
-r4my
-r4nar
-r3nel
-r4ner
-r5net
-r3ney
-r5nic
-r1nis4
-r3nit
-r3niv
-rno4
-r4nou
-r3nu
-rob3l
-r2oc
-ro3cr
-ro4e
-ro1fe
-ro5fil
-rok2
-ro5ker
-5role.
-rom5ete
-rom4i
-rom4p
-ron4al
-ron4e
-ro5n4is
-ron4ta
-1room
-5root
-ro3pel
-rop3ic
-ror3i
-ro5ro
-ros5per
-ros4s
-ro4the
-ro4ty
-ro4va
-rov5el
-rox5
-r1p
-r4pea
-r5pent
-rp5er.
-r3pet
-rp4h4
-rp3ing
-r3po
-r1r4
-rre4c
-rre4f
-r4reo
-rre4st
-rri4o
-rri4v
-rron4
-rros4
-rrys4
-4rs2
-r1sa
-rsa5ti
-rs4c
-r2se
-r3sec
-rse4cr
-rs5er.
-rs3es
-rse5v2
-r1sh
-r5sha
-r1si
-r4si4b
-rson3
-r1sp
-r5sw
-rtach4
-r4tag
-r3teb
-rten4d
-rte5o
-r1ti
-rt5ib
-rti4d
-r4tier
-r3tig
-rtil3i
-rtil4l
-r4tily
-r4tist
-r4tiv
-r3tri
-rtroph4
-rt4sh
-ru3a
-ru3e4l
-ru3en
-ru4gl
-ru3in
-rum3pl
-ru2n
-runk5
-run4ty
-r5usc
-ruti5n
-rv4e
-rvel4i
-r3ven
-rv5er.
-r5vest
-r3vey
-r3vic
-rvi4v
-r3vo
-r1w
-ry4c
-5rynge
-ry3t
-sa2
-2s1ab
-5sack
-sac3ri
-s3act
-5sai
-salar4
-sal4m
-sa5lo
-sal4t
-3sanc
-san4de
-s1ap
-sa5ta
-5sa3tio
-sat3u
-sau4
-sa5vor
-5saw
-4s5b
-scan4t5
-sca4p
-scav5
-s4ced
-4scei
-s4ces
-sch2
-s4cho
-3s4cie
-5scin4d
-scle5
-s4cli
-scof4
-4scopy
-scour5a
-s1cu
-4s5d
-4se.
-se4a
-seas4
-sea5w
-se2c3o
-3sect
-4s4ed
-se4d4e
-s5edl
-se2g
-seg3r
-5sei
-se1le
-5self
-5selv
-4seme
-se4mol
-sen5at
-4senc
-sen4d
-s5ened
-sen5g
-s5enin
-4sentd
-4sentl
-sep3a3
-4s1er.
-s4erl
-ser4o
-4servo
-s1e4s
-se5sh
-ses5t
-5se5um
-5sev
-sev3en
-sew4i
-5sex
-4s3f
-2s3g
-s2h
-2sh.
-sh1er
-5shev
-sh1in
-sh3io
-3ship
-shiv5
-sho4
-sh5old
-shon3
-shor4
-short5
-4shw
-si1b
-s5icc
-3side.
-5sides
-5sidi
-si5diz
-4signa
-sil4e
-4sily
-2s1in
-s2ina
-5sine.
-s3ing
-1sio
-5sion
-sion5a
-si2r
-sir5a
-1sis
-3sitio
-5siu
-1siv
-5siz
-sk2
-4ske
-s3ket
-sk5ine
-sk5ing
-s1l2
-s3lat
-s2le
-slith5
-2s1m
-s3ma
-small3
-sman3
-smel4
-s5men
-5smith
-smol5d4
-s1n4
-1so
-so4ce
-soft3
-so4lab
-sol3d2
-so3lic
-5solv
-3som
-3s4on.
-sona4
-son4g
-s4op
-5sophic
-s5ophiz
-s5ophy
-sor5c
-sor5d
-4sov
-so5vi
-2spa
-5spai
-spa4n
-spen4d
-2s5peo
-2sper
-s2phe
-3spher
-spho5
-spil4
-sp5ing
-4spio
-s4ply
-s4pon
-spor4
-4spot
-squal4l
-s1r
-2ss
-s1sa
-ssas3
-s2s5c
-s3sel
-s5seng
-s4ses.
-s5set
-s1si
-s4sie
-ssi4er
-ss5ily
-s4sl
-ss4li
-s4sn
-sspend4
-ss2t
-ssur5a
-ss5w
-2st.
-s2tag
-s2tal
-stam4i
-5stand
-s4ta4p
-5stat.
-s4ted
-stern5i
-s5tero
-ste2w
-stew5a
-s3the
-st2i
-s4ti.
-s5tia
-s1tic
-5stick
-s4tie
-s3tif
-st3ing
-5stir
-s1tle
-5stock
-stom3a
-5stone
-s4top
-3store
-st4r
-s4trad
-5stratu
-s4tray
-s4trid
-4stry
-4st3w
-s2ty
-1su
-su1al
-su4b3
-su2g3
-su5is
-suit3
-s4ul
-su2m
-sum3i
-su2n
-su2r
-4sv
-sw2
-4swo
-s4y
-4syc
-3syl
-syn5o
-sy5rin
-1ta
-3ta.
-2tab
-ta5bles
-5taboliz
-4taci
-ta5do
-4taf4
-tai5lo
-ta2l
-ta5la
-tal5en
-tal3i
-4talk
-tal4lis
-ta5log
-ta5mo
-tan4de
-tanta3
-ta5per
-ta5pl
-tar4a
-4tarc
-4tare
-ta3riz
-tas4e
-ta5sy
-4tatic
-ta4tur
-taun4
-tav4
-2taw
-tax4is
-2t1b
-4tc
-t4ch
-tch5et
-4t1d
-4te.
-tead4i
-4teat
-tece4
-5tect
-2t1ed
-te5di
-1tee
-teg4
-te5ger
-te5gi
-3tel.
-teli4
-5tels
-te2ma2
-tem3at
-3tenan
-3tenc
-3tend
-4tenes
-1tent
-ten4tag
-1teo
-te4p
-te5pe
-ter3c
-5ter3d
-1teri
-ter5ies
-ter3is
-teri5za
-5ternit
-ter5v
-4tes.
-4tess
-t3ess.
-teth5e
-3teu
-3tex
-4tey
-2t1f
-4t1g
-2th.
-than4
-th2e
-4thea
-th3eas
-the5at
-the3is
-3thet
-th5ic.
-th5ica
-4thil
-5think
-4thl
-th5ode
-5thodic
-4thoo
-thor5it
-tho5riz
-2ths
-1tia
-ti4ab
-ti4ato
-2ti2b
-4tick
-t4ico
-t4ic1u
-5tidi
-3tien
-tif2
-ti5fy
-2tig
-5tigu
-till5in
-1tim
-4timp
-tim5ul
-2t1in
-t2ina
-3tine.
-3tini
-1tio
-ti5oc
-tion5ee
-5tiq
-ti3sa
-3tise
-tis4m
-ti5so
-tis4p
-5tistica
-ti3tl
-ti4u
-1tiv
-tiv4a
-1tiz
-ti3za
-ti3zen
-2tl
-t5la
-tlan4
-3tle.
-3tled
-3tles.
-t5let.
-t5lo
-4t1m
-tme4
-2t1n2
-1to
-to3b
-to5crat
-4todo
-2tof
-to2gr
-to5ic
-to2ma
-tom4b
-to3my
-ton4ali
-to3nat
-4tono
-4tony
-to2ra
-to3rie
-tor5iz
-tos2
-5tour
-4tout
-to3war
-4t1p
-1tra
-tra3b
-tra5ch
-traci4
-trac4it
-trac4te
-tras4
-tra5ven
-trav5es5
-tre5f
-tre4m
-trem5i
-5tria
-tri5ces
-5tricia
-4trics
-2trim
-tri4v
-tro5mi
-tron5i
-4trony
-tro5phe
-tro3sp
-tro3v
-tru5i
-trus4
-4t1s2
-t4sc
-tsh4
-t4sw
-4t3t2
-t4tes
-t5to
-ttu4
-1tu
-tu1a
-tu3ar
-tu4bi
-tud2
-4tue
-4tuf4
-5tu3i
-3tum
-tu4nis
-2t3up.
-3ture
-5turi
-tur3is
-tur5o
-tu5ry
-3tus
-4tv
-tw4
-4t1wa
-twis4
-4two
-1ty
-4tya
-2tyl
-type3
-ty5ph
-4tz
-tz4e
-4uab
-uac4
-ua5na
-uan4i
-uar5ant
-uar2d
-uar3i
-uar3t
-u1at
-uav4
-ub4e
-u4bel
-u3ber
-u4bero
-u1b4i
-u4b5ing
-u3ble.
-u3ca
-uci4b
-uc4it
-ucle3
-u3cr
-u3cu
-u4cy
-ud5d
-ud3er
-ud5est
-udev4
-u1dic
-ud3ied
-ud3ies
-ud5is
-u5dit
-u4don
-ud4si
-u4du
-u4ene
-uens4
-uen4te
-uer4il
-3ufa
-u3fl
-ugh3en
-ug5in
-2ui2
-uil5iz
-ui4n
-u1ing
-uir4m
-uita4
-uiv3
-uiv4er.
-u5j
-4uk
-u1la
-ula5b
-u5lati
-ulch4
-5ulche
-ul3der
-ul4e
-u1len
-ul4gi
-ul2i
-u5lia
-ul3ing
-ul5ish
-ul4lar
-ul4li4b
-ul4lis
-4ul3m
-u1l4o
-4uls
-uls5es
-ul1ti
-ultra3
-4ultu
-u3lu
-ul5ul
-ul5v
-um5ab
-um4bi
-um4bly
-u1mi
-u4m3ing
-umor5o
-um2p
-unat4
-u2ne
-un4er
-u1ni
-un4im
-u2nin
-un5ish
-uni3v
-un3s4
-un4sw
-unt3ab
-un4ter.
-un4tes
-unu4
-un5y
-un5z
-u4ors
-u5os
-u1ou
-u1pe
-uper5s
-u5pia
-up3ing
-u3pl
-up3p
-upport5
-upt5ib
-uptu4
-u1ra
-4ura.
-u4rag
-u4ras
-ur4be
-urc4
-ur1d
-ure5at
-ur4fer
-ur4fr
-u3rif
-uri4fic
-ur1in
-u3rio
-u1rit
-ur3iz
-ur2l
-url5ing.
-ur4no
-uros4
-ur4pe
-ur4pi
-urs5er
-ur5tes
-ur3the
-urti4
-ur4tie
-u3ru
-2us
-u5sad
-u5san
-us4ap
-usc2
-us3ci
-use5a
-u5sia
-u3sic
-us4lin
-us1p
-us5sl
-us5tere
-us1tr
-u2su
-usur4
-uta4b
-u3tat
-4ute.
-4utel
-4uten
-uten4i
-4u1t2i
-uti5liz
-u3tine
-ut3ing
-ution5a
-u4tis
-5u5tiz
-u4t1l
-ut5of
-uto5g
-uto5matic
-u5ton
-u4tou
-uts4
-u3u
-uu4m
-u1v2
-uxu3
-uz4e
-1va
-5va.
-2v1a4b
-vac5il
-vac3u
-vag4
-va4ge
-va5lie
-val5o
-val1u
-va5mo
-va5niz
-va5pi
-var5ied
-3vat
-4ve.
-4ved
-veg3
-v3el.
-vel3li
-ve4lo
-v4ely
-ven3om
-v5enue
-v4erd
-5vere.
-v4erel
-v3eren
-ver5enc
-v4eres
-ver3ie
-vermi4n
-3verse
-ver3th
-v4e2s
-4ves.
-ves4te
-ve4te
-vet3er
-ve4ty
-vi5ali
-5vian
-5vide.
-5vided
-4v3iden
-5vides
-5vidi
-v3if
-vi5gn
-vik4
-2vil
-5vilit
-v3i3liz
-v1in
-4vi4na
-v2inc
-vin5d
-4ving
-vio3l
-v3io4r
-vi1ou
-vi4p
-vi5ro
-vis3it
-vi3so
-vi3su
-4viti
-vit3r
-4vity
-3viv
-5vo.
-voi4
-3vok
-vo4la
-v5ole
-5volt
-3volv
-vom5i
-vor5ab
-vori4
-vo4ry
-vo4ta
-4votee
-4vv4
-v4y
-w5abl
-2wac
-wa5ger
-wag5o
-wait5
-w5al.
-wam4
-war4t
-was4t
-wa1te
-wa5ver
-w1b
-wea5rie
-weath3
-wed4n
-weet3
-wee5v
-wel4l
-w1er
-west3
-w3ev
-whi4
-wi2
-wil2
-will5in
-win4de
-win4g
-wir4
-3wise
-with3
-wiz5
-w4k
-wl4es
-wl3in
-w4no
-1wo2
-wom1
-wo5ven
-w5p
-wra4
-wri4
-writa4
-w3sh
-ws4l
-ws4pe
-w5s4t
-4wt
-wy4
-x1a
-xac5e
-x4ago
-xam3
-x4ap
-xas5
-x3c2
-x1e
-xe4cuto
-x2ed
-xer4i
-xe5ro
-x1h
-xhi2
-xhil5
-xhu4
-x3i
-xi5a
-xi5c
-xi5di
-x4ime
-xi5miz
-x3o
-x4ob
-x3p
-xpan4d
-xpecto5
-xpe3d
-x1t2
-x3ti
-x1u
-xu3a
-xx4
-y5ac
-3yar4
-y5at
-y1b
-y1c
-y2ce
-yc5er
-y3ch
-ych4e
-ycom4
-ycot4
-y1d
-y5ee
-y1er
-y4erf
-yes4
-ye4t
-y5gi
-4y3h
-y1i
-y3la
-ylla5bl
-y3lo
-y5lu
-ymbol5
-yme4
-ympa3
-yn3chr
-yn5d
-yn5g
-yn5ic
-5ynx
-y1o4
-yo5d
-y4o5g
-yom4
-yo5net
-y4ons
-y4os
-y4ped
-yper5
-yp3i
-y3po
-y4poc
-yp2ta
-y5pu
-yra5m
-yr5ia
-y3ro
-yr4r
-ys4c
-y3s2e
-ys3ica
-ys3io
-3ysis
-y4so
-yss4
-ys1t
-ys3ta
-ysur4
-y3thin
-yt3ic
-y1w
-za1
-z5a2b
-zar2
-4zb
-2ze
-ze4n
-ze4p
-z1er
-ze3ro
-zet4
-2z1i
-z4il
-z4is
-5zl
-4zm
-1zo
-zo4m
-zo5ol
-zte4
-4z1z2
-z4zy
-Á1Á
-Á1Å
-Á1É
-Á1Ï
-Á1Õ
-Á1Ù
-Á1Ü
-Á1À
-Á1Ñ
-Å1Á
-Å1Å
-Å1É
-Å1Ï
-Å1Õ
-Å1Ù
-Å1Ü
-Å1À
-Å1Ñ
-É1Á
-É1Å
-É1É
-É1Ï
-É1Õ
-É1Ù
-É1Ü
-É1À
-É1Ñ
-Ï1Á
-Ï1Å
-Ï1É
-Ï1Ï
-Ï1Õ
-Ï1Ù
-Ï1Ü
-Ï1À
-Ï1Ñ
-Õ1Á
-Õ1Å
-Õ1É
-Õ1Ï
-Õ1Õ
-Õ1Ù
-Õ1Ü
-Õ1À
-Õ1Ñ
-Ù1Á
-Ù1Å
-Ù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
-.×ÓÔ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
-.ÛÔÒ2
-1ÂÁ
-1ÂÅ
-1ÂÉ
-1ÂÏ
-1ÂÕ
-1ÂÙ
-1ÂÑ
-1×Á
-1×Å
-1×É
-1×Ï
-1×Õ
-1×Ù
-1×Ñ
-1ÇÁ
-1ÇÅ
-1ÇÉ
-1ÇÏ
-1ÇÕ
-1ÄÁ
-1ÄÅ
-1ÄÉ
-1ÄÏ
-1ÄÕ
-1ÄÙ
-1ÄÀ
-1ÄÑ
-1ÖÁ
-1ÖÅ
-1ÖÉ
-1ÖÏ
-1ÖÕ
-1ÖÙ
-1ÚÁ
-1ÚÅ
-1ÚÉ
-1ÚÏ
-1ÚÕ
-1ÚÙ
-1ÚÑ
-1ËÁ
-1ËÅ
-1ËÉ
-1ËÏ
-1ËÕ
-1ÌÁ
-1ÌÅ
-1ÌÉ
-1ÌÏ
-1ÌÕ
-1ÌÙ
-1ÌÀ
-1ÌÑ
-1ÍÁ
-1ÍÅ
-1ÍÉ
-1ÍÏ
-1ÍÕ
-1ÍÙ
-1ÍÑ
-1ÎÁ
-1ÎÅ
-1ÎÉ
-1ÎÏ
-1ÎÕ
-1ÎÙ
-1ÎÀ
-1ÎÑ
-1ÐÁ
-1ÐÅ
-1ÐÉ
-1ÐÏ
-1ÐÕ
-1ÐÙ
-1ÐÑ
-1ÒÁ
-1ÒÅ
-1ÒÉ
-1ÒÏ
-1ÒÕ
-1ÒÙ
-1ÒÀ
-1ÒÑ
-1ÓÁ
-1ÓÅ
-1ÓÉ
-1ÓÏ
-1ÓÕ
-1ÓÙ
-1ÓÑ
-1ÔÁ
-1ÔÅ
-1ÔÉ
-1ÔÏ
-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ÝÏ
diff --git a/gnu/usr.bin/groff/troff/Makefile b/gnu/usr.bin/groff/troff/Makefile
deleted file mode 100644
index 41de42c..0000000
--- a/gnu/usr.bin/groff/troff/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-# $Id$
-
-PROG= troff
-SRCS= env.cc node.cc input.cc div.cc symbol.cc dictionary.cc reg.cc \
- number.cc majorminor.cc
-CFLAGS+= -I${.CURDIR}/../include
-LDADD+= ${LIBGROFF} -lm
-DPADD+= ${LIBGROFF} ${LIBM}
-MANDEPEND= troff.1
-
-CLEANFILES+= majorminor.cc ${MANDEPEND}
-
-.include "../Makefile.inc"
-
-majorminor.cc: ${GROFF_DIST}/VERSION
- @${ECHO} Making $@
- @-rm -f $@
- @echo const char \*major_version = \
- \"`sed -e 's/^\([^.]*\)\..*$$/\1/' ${GROFF_DIST}/VERSION`\"\; >$@
- @echo const char \*minor_version = \
- \"`sed -e 's/^[^.]*\.\([0-9]*\).*$$/\1/' ${GROFF_DIST}/VERSION`\"\; >>$@
-
-afterinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 ${DIST_DIR}/hyphen.us \
- ${DESTDIR}${tmacdir}/hyphen.us
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${DIST_DIR}/hyphen.us-ru ${DESTDIR}${tmacdir}/hyphen.us-ru
-
-.include "../Makefile.cfg"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/gzip/COPYING b/gnu/usr.bin/gzip/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/gzip/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/gzip/ChangeLog b/gnu/usr.bin/gzip/ChangeLog
deleted file mode 100644
index 7dd0f86..0000000
--- a/gnu/usr.bin/gzip/ChangeLog
+++ /dev/null
@@ -1,587 +0,0 @@
-Wed Aug 18 09:34:23 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.2.4
- By default, do not restore file name and timestamp from those saved
- inside the .gz file (behave as 'compress'). Added the --name option
- to force name and timestamp restoration.
- Accept - as synonym for stdin.
- Use manlinks=so or ln to support either hard links or .so in man pages
- Accept foo.gz~ in zdiff.
- Added support for Windows NT
- Handle ENAMETOOLONG for strict Posix systems
- Use --recursive instead of --recurse to comply with Webster and
- the GNU stdandard.
- Allow installation of shell scripts with a g prefix: make G=g install
- Install by default zcat as gzcat if gzcat already exists in path.
- Let zmore behave as more when invoked without parameters (give help)
- Let gzip --list reject files not in gzip format even with --force.
- Don't complain about non gzip files for options -rt or -rl.
- Added advice in INSTALL for several systems.
- Added makefile entries for NeXTstep 3.1 (if configure fails)
- Avoid problem with memcpy on Pyramid (gave crc error on some files)
- Support the -r option when compiled with Borland C++ on msdos.
- Force lower case file names only for FAT file systems (not HPFS)
- Rewrite one expression in inflate.c to avoid cc bug on Solaris x86.
- In the msdos makefiles, get match.asm from the msdos subdirectory.
- Catch SIGTERM and SIGHUP only if they are not ignored.
- getopt.c: on Amiga, "#if !defined(const)" does not compile.
- Use register parameters on Amiga.
- Do not force names to lower case on Amiga.
- Fix support of Atari TOS (Makefile.st and tailor.h)
- In unlzw.c, do not suggest using zcat if zcat already used.
- In INSTALL, suggest using bsdinst for HPUX.
- Document Turbo C++ 1.0 bug in INSTALL.
- Improved the documentation relative to the --no-name option.
- Avoid signed/unsigned warnings in several files.
- Added pointer to jka-compr19.el in README.
- Added pointer to OS/2 executables in README.
- Added --block-compress in tar -z example (gzip.1 and gzip.texi).
- Don't keep rcsid in executable (avoid compilation warnings).
- Check also the correctness of the first byte of an .Z file.
- Return non zero status for an invalid option.
- Remove "NEWFILES" from os2/gzip.def for Borland C++ on OS/2.
- Remove "time stamp restored" message (just obey the -N request).
-
-Thu Jun 24 10:27:57 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.2.3
- Don't display the output name when decompressing except with --verbose.
- Remove usage of alloca in getopt.c and all makefiles.
- Use ASCPP instead of CPP to avoid breaking AC_HEADER_CHECK on RiscOS.
- Added the zfile shell script in subdirectory sample.
- Moved the list of compiler bugs from README to INSTALL.
- Added vms/Readme.vms.
- Fix DIST_BUFSIZE check in unlzh.c for 16 bit machines.
- Fix REGSIGTYP macro in configure.in.
- Use 'define' instead of == in vms/gzip.hlp.
- Avoid warnings in unlzh.c
- Allow separate installation of binaries and man pages.
- Simplified handling of file names with spaces in zgrep and znew.
- Fix dependencies and remove rule for trees.c in amiga/Makefile.sasc
- Add missing quote in gzexe.
-
-Thu Jun 17 13:47:05 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.2.2
- Fix a compilation error in gzip.c on Sun with cc (worked with gcc).
-
-Wed Jun 16 11:20:27 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.2.1
- Let zmore act as more if the data is not gzipped.
- By default, display output name only when name was actually truncated.
- Use absolute path names in gzexe'd programs for better security.
- In gzexe, use chmod 700 instead of 755 and don't gzexe tail,rm,etc...
- Update vms/gzip.hlp.
- Added a note about the fast options (-1 to -3) in algorithm.doc.
- Improved man page for zgrep.
- Minor fixes to gzip.texi.
- Always set LC_ALL and LANG in configure (for tr on HPUX)
-
-Mon Jun 14 10:03:24 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.2
- Added the --list option to display the file characteristics.
- Added the --no-name option: do not save or restore original filename
- Save the original name by default.
- Allow gunzip --suffix "" to attempt decompression on any file
- regardless of its extension if an original name is present.
- Add support for the SCO compress -H format.
- gzip --fast now compresses faster (speed close to that of compress)
- with degraded compression ratio (but still better than compress).
- Default level changed to -6 (acts exactly as previous level -5) to
- be a better indication of its placement in the speed/ratio range.
- Use smart name truncation: 123456789012.c -> 123456789.c.gz
- instead of 12345678901.gz
- With --force, let zcat pass non gzip'ed data unchanged (zcat == cat)
- Added the zgrep shell script.
- Made sub.c useful for 16 bit sound, 24 bit images, etc..
- Supress warnings about suffix for gunzip -r, except with --verbose.
- Moved the sample programs to a subdirectory sample.
- On MSDOS, use .gz extension when possible (files without extension)
- Added a "Special targets" section in INSTALL.
- Use stty -g correctly in zmore.in.
- Use cheaper test for gzipness in zforce.in.
- Remove space before $ in match.S (no longer accepted by gas 2.x)
- For the shell scripts, do not assume that gzip is in the path.
- Fix syntax error and define lnk$library in vms/Makefile.mms
- REGSIGTYPE is void on the Amiga.
- Do not write empty line when decompressing stdin with --verbose.
- Fix the 1.1.2 fix for VMS (bug in get_suffix)
- Added warning in README about compiler bug on Solaris 2.1 for x86.
- Added warning about 'rehash' in INSTALL.
- Removed default value of read_buf in bits.c (supermax doesn't like).
- In tailor.h, added support for Borland C and Zortech C on OS/2.
- Added warning in gzexe about Ultrix buggy sh (use /bin/sh5 instead).
- Added warning in zdiff about AIX buggy sh (use /bin/ksh instead).
- In configure.in, do not try the asm code if DEFS contains NO_ASM
-
-Fri Jun 4 09:49:33 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.1.2
- Fix serious bug for VMS (-gz not removed when decompressing).
- Allow suffix other than .gz in znew.
- Do not display compression ratio when decompressing stdin.
- In zmore.in, work around brain damaged stty -g (Ultrix).
- Display a correct compression ratio for .Z files.
- Added .z to .gz renaming script in INTALL.
- Allow setting CFLAGS in configure.
- Add warning in README about bug in Concentrix cc compiler.
- Avoid || in Makefile.in (at least one make doesn't support this).
- Disable useless --ascii option for the Amiga.
- Add a pointer to the Primos executable in README.
- Added description of extra field in algorithm.doc.
- Do not redefine NULL in alloca.c.
- Added check for unsupported compression methods.
- Avoid getopt redeclaration on OSF/1.
-
-Tue Jun 1 09:07:15 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.1.1
- Fix serious bug in vms.c (== instead of =).
- Added --ascii option.
- Add workaround in configure.in for Ultrix (quote eval argument)
- Do not use unset in znew (not supported on Ultrix)
- Use tar.gz instead of tar.z for the distribution of gzip.
- Add missing menu item in gzip.texi.
- Use size_t instead of unsigned, add AC_SIZE_T in configure.in.
-
-Fri May 28 11:40:01 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.1
- Use .gz suffix by default, add --suffix option.
- Let gunzip accept a "_z" suffix (used by one 'compress' on Vax/VMS).
- Quit when reading garbage from stdin instead of reporting an error.
- Added sub.c and add.c for compression of 8 bit images.
- Added makefile for VAX/MMS and support for wildcards on VMS.
- Added support for MSC under OS/2.
- Added support for Prime/PRIMOS.
- Display compression ratio also when decompressing.
- Quit after --version (GNU standard)
- Use --force to bypass isatty() check.
- Accept --silent as synonym for --quiet (see longopts.table)
- Accept --to-stdout as synonym for --stdout (see longopts.table)
- Accept -H and -? in addition to -h and --help.
- Added comparison of zip and gzip in the readme file.
- Return an error code in all main compression/decompression functions.
- Continue processing other files in case of recoverable error.
- Add description of -f in znew.1.
- Do not keep uncompressed version for znew -t if .gz already exists.
- On Unix, use only st_ino and st_dev in same_file().
- Use S_IRUSR and S_IWUSR if they exist.
- "test $1 = -d" -> "test x$1 = x-d" in gzexe.
- In match.S, use symbol sysV68 to detect the Motorola Delta.
- Do not include memory.h with gcc (conflicting declarations on Sun).
- Fix more typos.
- On VMS, define unlink as delete also for gcc.
- In "make check", unset LANG because "wc -c" fails on Kanji.
- Renamed shdir as scriptdir.
- Use the 68020 code instead of 68000 code on the NeXT.
- Documented --uncompress as synonym for --decompress.
- Include the standard header files before gzip.h (needed on Bull).
- Do not assume that _POSIX_VERSION implies dirent.h present.
- Removed gzip-tar.patch since tar 1.11.2 handles gzip directly.
- Use less memory when compiled with -DSMALL_MEM (for MSDOS).
- Optimized updcrc().
- Don't complain if cc -E does not work correctly.
- Do not attempt reading 64K bytes on 16 bit Unix systems.
- Do not use the variable name 'overhead' which is reserved on Lynx!
- One BULL compiler does not like *p++ in inflate.c => *p, p++.
- Use casts on free and memcmp to avoid warnings.
- Remove the "off by more than one minute" time stamp kludge, but
- document how to avoid saving the time stamp on pipes if desired.
- Include crypt.h in inflate.c (one system predefines the CRYPT symbol).
- Add links to gunzip and (g)zcat in the default make rule.
- Create installation directories if they do not exist.
- Clarified --prefix option in INSTALL.
- Use symbol mc68k in match.S for the DIAB DS90.
- Guard against zero length _match.s in configure.in.
- In zmore, restore all tty options using stty -g.
- Added support for MacOS
- Simplified makecrc.c.
- Avoid warnings in getopt.c, util.c, unlzw.c.
- Use autoconf 1.4, in particular for INSTALL and AC_HAVE_POUNDBANG
- Use .so instead of hard links for zcat.1, gunzip.1 and zcmp.1.
- Fixed declration of sig_type.
- Make consistency check in fcfree.
- Added ztouch.
- Do not complain if utime fails on a directory (for OS/2).
-
-Thu Mar 18 18:56:43 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.0.7
- Allow zmore to read from standard input (like more).
- Support the 68000 (Atari ST) in match.S.
- Retry partial writes (required on Linux when gzip is suspended in
- a pipe).
- Allow full pathnames and renamings in gzexe.
- Don't let gzexe compress setuid executables or gzip itself.
- Added vms/Makefile.gcc for gcc on the Vax.
- Give a pointer to Solaris and VMS executables of gzip in README.
- Allow installation of binaries and shell scripts in different dirs.
- Do not use alloca on the Cray.
- Provide strspn and strcspn if string.h does not exist.
- Define O_CREAT and O_EXCL from FCREAT and FEXCL if necessary.
- Remove gzip.doc in make realclean.
- Fixed many typos. (Corrections to my English are welcome.)
- Put "make manext=l install" at the correct place in INSTALL.
- Fix incorrect examples in INSTALL and give more examples.
- Include zdiff.1 for install and uninstall.
- Allows complex PAGER variable in zmore (e.g.: PAGER="col -x | more")
- Avoid warning on unused indfound in getopt.c.
- Cast memset arg to void* (required by some buggy compilers).
- Include sys/types.h before dirent.h in acgeneral.m4.
- Fix acgeneral.m4 AC_COMPILE_CHECK to avoid warnings.
- Don't use alloca.c with gcc. (One NeXT user did not have alloca.h).
- Change all error messages according to GNU standards.
- Restore time stamp only if off by more than one minute.
- Allow installation of zcat as gzcat.
- Suppress help message and send compressed data to the terminal when
- gzip is invoked without parameters and without redirection.
- (Explicit request from Noah Friedman.)
- Add compile option GNU_STANDARD to respect the GNU coding standards:
- with -DGNU_STANDARD, behave as gzip even if invoked under the
- name gunzip. (Complaints to /dev/null or the FSF, not to me!)
-
-Fri Mar 10 13:27:18 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.0.6
- Let gzexe detect executables that are already gzexe'd.
- Don't try restoring record format on VMS (the simple 1.0.5 code
- worked correctly only on fixed-512 files). Suppress text_mode.
- Added asm version for 68000 in amiga/match.a.
- Use asm version for Atari TT.
- Fix "make clean" in vms/Makefile.vms.
- For OS/2, assume HPFS by default, add flag OS2FAT if necessary.
- Fixed some bugs in zdiff and define zcmp as a link to zdiff.
- Added zdiff.1
- Remove configure hack for NeXT; add general fix to autoconf instead
- Do not strip a ".z" extension if this results in an empty name.
- Avoid array overflow in get_prefix() for extensions > 10 chars.
- Accept either q or e to quit zmore.
- In zmore, try restoring tty mode in all cases.
- Use Motorola style for match.S on the NeXT.
- configure.in: unsetenv *hangs* with the Siemens csh...
- Update vms/gzip.hlp.
-
-Thu Mar 4 14:13:34 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.0.5
- For VMS, restore the file type for variable record format, otherwise
- extract in fixed length format (not perfect, but better than
- forcing all files to be in stream_LF format).
- Use "-z" suffix for VMS.
- Use only .z, .*-z, .tgz, .taz as valid gzip extensions; update
- zforce accordingly.
- Allow a version number in input file names for VMS.
- Added sample program zread.c.
- Fix "make check" for some implementations of /bin/sh.
- Don't rely on stat() for filenames with extension > 3 chars
- on MSDOS, OS2 and Atari.
- Garbage collect files in /tmp created by gzexe.
- Quote $opt in znew.
- Use TOUCH env variable in znew if it exists.
- Better error message for gunzip on empty or truncated file.
- Allow prototypes in getopt.h when __STDC__ defined but 0.
- Added "make clean" in vms/Makefile.vms.
- Removed -g from default CFLAGS (with Noah's permission!)
- Avoid too many HAVE_xxx_H for most systems; use common defaults.
- Moved default Atari flags into tailor.h for consistency.
- Use memzero() to clear the hash table.
- Update vms/gzip.hlp to reflect the VMS behavior.
- Fix OS_CODE (to fit in a byte).
- Add utime.h for the Amiga.
- Add gcc support for the Amiga.
- Work around incorrect dirent.h for NeXT 2.0.
- Added Makefile entry for Coherent.
-
-Fri Feb 22 11:20:49 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.0.4
- Added optimized asm version for 68020.
- Add support for DJGPP.
- Add support for the Atari ST.
- Added zforce to rename gzip'ed files with truncated names.
- Do not install with name uncompress (some systems rely on the
- absence of any check in the old uncompress).
- Added missing function (fcfree) in msdos/tailor.c
- Let gunzip handle .tgz files, and let gzip skip them.
- Added 'stty min 1' in zmore for SysV and fixed trap code.
- Suppress .PHONY in Makefile.in, which breaks old makes.
- Added documentation about pcat and unpack in INSTALL.
- Add cast to getenv for systems without stdlib.h.
- Use VAXC instead of VMS to avoid confusion for gcc.
- Add -K to znew.1.
- Add gzexe.1.
- Try preserving file permissions in gzexe.
- Added -d option for gzexe.
- Guard against spaces in file names in gzexe.
- Use CMP env. variable in zcmp.
- Return a warning exit status for gzip of file with .z suffix.
- Suppress usage of d_ino which is not portable to all systems.
- Use #ifdef instead of #if for consistency.
- For VMS, use "cc util.c" instead of "cc util" (pb with logical names)
- Added utime() for Amiga.
- Renamed gzcat.1 as zcat.1.
- Include fcntl.h for Amiga (for read and write).
- For VMS, add definition of symbols and links in the makefiles.
- Give a VMS look to vms/gzip.hlp.
- Save the original name only when necessary.
- Add a mode parameter for open in read mode (required by VMS).
- For VMS, remove the version suffix from the original name.
- Accept both / and \ as path separator for MSDOS.
- Let gunzip extract stored .zip files correctly.
- Added warning about VFC format in vms/gzip.hlp.
- In znew, skip a bad file but process the others.
- Cleanup tailor.h.
- Use GZIP_OPT for VMS to avoid conflict with program name.
- Added description of GZIP variable in gzip.texi.
-
-Thu Feb 11 17:21:32 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.0.3
- Add -K option for znew to keep old .Z files if smaller.
- Add -q option (quiet) to cancel -v in GZIP env variable.
- For Turbo C, normalize pointers before freeing them.
- Add more safety checks in add_envopt().
- Add do_exit() for uniform exit path (always free memory).
- Reduce MAX_PATH_LEN for MSDOS.
- Include sys/types.h before signal.h
- Avoid strdup, the NeXT does not have it.
- Made gzexe safer on systems with filename limitation to 14 chars.
-
-Fri Feb 10 09:45:49 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.0.2
- Added env variable GZIP for default options.
- Added support for the Amiga.
- znew now keeps the old .Z if it is smaller than the .z file.
- Added gzexe to compress rarely used executables.
- Reduce memory usage when using static allocation (no DYN_ALLOC).
- Better separation of warning and error return codes.
- Fix unlzw.c to make DYN_ALLOC and MAXSEG_64K independent options.
- Allow INBUFSIZ to be >= 32K in unlzw (don't use sign of rsize)
- Generate tar file in old format to avoid problems with old systems.
- Preserve time stamp in znew -P if touch -r works.
- Use ${PAGER-more} instead of ${PAGER:-more} in zmore.
- Do not use unsigned instead of mode_t.
- Better error message for trailing garbage in .z file; ignore this
- garbage on VMS.
- In zmore, use icanon instead of -cbreak on SYSV.
- Add trap handler in zmore.
- Use char* instead of void* for non STDC compilers.
- Added makefile entry for Xenix on 286.
- Return an error code when existing file was not overwritten.
- Use prototype of lzw.h for lzw.c.
- Fix znew with -P option alone.
- Give warning for directories even without -v.
- Close output file before unlink() in case of error.
- Suppress all target dependent ifdef from the portable files.
- Free all dynamically allocated variables upon exit.
-
-Thu Feb 4 18:23:56 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.0.1
- Fixed some trivial errors in msdos/Makefile.bor
-
-Thu Feb 4 10:00:59 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * version 1.0
- gzip now runs on Vax/VMS (Amiga support will come in next version).
- Do not overwrite files without -f when using /bin/sh.
- Support the test option -t for compressed (.Z) files.
- Flush output for bad compressed files. Add warning in README.
- Added makefiles for MSDOS.
- Don't rely on presence of csh in configure
- Added gunzip.1 and gzcat.1.
- Updated znew.1.
- Check reserved flags in unlzw().
- Return dummy value in main to avoid lint warning.
- Define OF in lzw.h for lint.
- Allow both "znew -v -t" and "znew -vt".
- Don't overwrite the output file name for multiple parts.
- Echo just a warning if configure is out of date.
- Use ; instead of , in trees.c (confuses the SAS Amiga compiler).
- In INSTALL, document "DEFS='-DM_XENIX' ./configure".
- Use OTHER_PATH_SEP for more portability (DOS, OS2, VMS, AMIGA).
- Make all directories world writable for broken versions of tar.
- Use gzip -cd instead of zcat in zmore, zcmp, zdiff.
- Don't use GNU tar for distributions, some systems can't untar.
- Do not exit() for gzip --version.
-
-Mon Jan 26 10:26:42 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * Beta version 0.8.2
- Avoid 'far' declarations for MSDOS.
- Use test -f instead of test -x in configure.in (for Ultrix)
- Add empty else part to if in Makefile.in for broken shells.
- Use NO_UNDERLINE instead of UNDERLINE (pb with Linux cpp)
- Accept continuation files with -ff (for damage recovery)
- Small patch to Makefile.os2
- Use memzero instead of bzero to avoid potential conflicts
- Document restriction on extraction of zip files.
- Fix quoting in ACL_HAVE_SHELL_HACK.
- Do not check file size on MSDOS because of bug in DIET.
- Allow zcat on a file with multiple links.
- Add fix in inflate.c for compatibility with pkzip 2.04c.
- Release gzip in tar.z and tar format. (No tar.Z).
-
-Fri Jan 22 10:04:13 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * Beta version 0.8.1
- Fixed Makefile.os2
- Fixed #if directives that TurboC does not like.
- Don't rely on uncompress in znew, use gzip -d.
- Add the pipe option -P in znew.
- Add some more ideas in TODO.
- Support both NDIR and SYSNDIR.
-
-Sat Jan 21 15:46:38 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * Beta version 0.8
- Support unpack.
- Check for _match.o in configure.in in addition to return status.
- Include <sys/types.h> in zip.c
- Define local variables and functions as local.
- Accept more alternative names for the program (pcat, gzcat, ...).
- Accept .exe as well as .EXE.
- Uncompress files with multiple links only with -f.
- Better error message for gunzip of non-existent file.z.
- Fix the entry for /etc/magic in INSTALL.
- Use AC_HAVE_HEADERS uniformly instead of special macros.
- Install the man pages as .1 by default instead of .l.
- Document crypt++.el in README.
- Fix for unlzw() on 16-bit machines (bitmask must be unsigned).
- Complain if input and output files are identical.
- Create a correct output name for files of exactly 13 chars.
- Do not overwrite CPP if set
- Check for i386 before trying to assemble match.s
- Check for underline in external name before assembling
- Add patch for tar 1.11.1.
-
-Mon Jan 5 10:16:24 1993 Jean-loup Gailly (jloup@chorus.fr)
-
- * Beta version 0.7
- Use "make check" instead of "make test".
- Do not rely on dirname in znew.
- Keep time stamp and pass options to gzip in znew.
- Rename .l files back to .1 to avoid conflict with lex
- Do not create .z.z files with gzip -r.
- Use nice_match in match.asm
- Unroll loops in deflate.c
- Do not attempt matches beyond the window end
- Allow again gunzip .zip files (was working in 0.5)
- Allow again compilation with TurboC 2.0 (was working in 0.4)
-
-Tue Dec 30 20:00:19 1992 Jean-loup Gailly (jloup@chorus.fr)
-
- * Beta version 0.6
- The .z extension is used by pack, not compact (README, gzip.1)
- Accept gzcat in addition to zcat.
- Use PAGER in zmore if defined.
- Man pages for /usr/local/man/manl should have extension .l.
- Don't redefine bzero on the NeXT
- Allow incomplete Huffman table if there is only one code.
- Don't lookahead more than 7 bits (caused premature EOF).
- Added "make test" to check for compiler bugs.
- Don't rely on `i386`; try to assemble directly
- Change magic header to avoid conflict with freeze 1.x.
- Added entry for /etc/magic in INSTALL.
- Do not destroy an input .zip file with more than one member.
- Display "untested" instead of "OK" for gzip -t foo.Z
- With -t, skip stdin in .Z format
- Allow multiple compressed members in an input file.
- Ignore a zero time stamp.
- Made znew safer.
-
-Tue Dec 29 10:00:19 1992 Noah Friedman (friedman@gnu.ai.mit.edu)
-
- Added test for #!/bin/sh in configure.in.
- Fix some references to $srcdir in Makefile.in
-
-Mon Dec 21 17:33:35 1992 Jean-Loup Gailly (jloup@chorus.fr)
-
- * Beta version 0.5
- Put RCS ids in all files.
- Added znew to recompress old .Z files with gzip.
- Avoid "already .z suffix" messages for -r and no -v.
- Put back check for d_ino in treat_dir().
- Use HAVE_STRING_H instead of USG.
- Added os2/Makefile.os2
- Use SYSUTIME on OS/2.
- Info dir is $(prefix)/info, not $(prefix)/lib/info.
- Support long options, added getopt and alloca
- Support -V and -t
- Reorder configure.in according to suggestions in autoconf.info
- Allow links when not removing original file
- Allow either .z or .Z in zdiff
-
-Wed Nov 25 11:40:04 1992 Jean-loup Gailly (jloup@chorus.fr)
-
- * Beta version 0.4.1
- Save only the original base name, don't include any directory prefix.
- Don't use HAVE_LONG_FILE_NAMES (support multiple file system types).
- Fix declaration of abort_gzip in gzip.h.
- Include unistd.h when it exists to avoid warnings with gcc -Wall.
-
-Mon Nov 23 12:39:01 1992 Jean-loup Gailly (jloup@chorus.fr)
-
- * Beta version 0.4
- Lots of cleanup
- Use autoconf generated 'configure'
- Fixed the NO_MULTIPLE_DOTS code
- Fixed the save_orig_name code
- Support for MSDOS (Turbo C)
-
-Thu Nov 19 15:18:22 1992 Jean-loup Gailly (jloup@chorus.fr)
-
- * Beta version 0.3
- Added auto configuration. Just type "make" now.
- Don't overwrite compress by default in "make install". Use
- "make install_compress" to overwrite.
- Add match.s for 386 boxes.
- Added documentation in texinfo format.
- Provide help for "gunzip" invoked without redirected input.
- Save original file name when necessary.
- Support OS/2 (Kai-Uwe Rommel).
-
-Tue Nov 17 14:32:53 1992 Jean-loup Gailly (jloup@chorus.fr)
-
- * Alpha version 0.2.4
- Return 0 in get_istat() when ok (caused error with zcat).
- Don't update crc on compressed data (caused crc errors on
- large files).
-
-Fri Nov 13 15:04:12 1992 Jean-loup Gailly (jloup@chorus.fr)
-
- * Alpha version 0.2.3
- Initialize rsize in unlzw.c
- Initialize ofd for zcat.
- Do not use volatile ifname as argument of treat_dir.
- Add -1 to -9 in gzip.1.
-
-Sat Oct 31 18:30:00 1992 Jean-loup Gailly (jloup@chorus.fr)
-
- * Alpha version 0.2.2.
- Fix error messages.
- Accept gunzip on zip files.
-
-Sat Oct 31 17:15:00 1992 Jean-loup Gailly (jloup@chorus.fr)
-
- * Alpha version 0.2.1
- Use ctype.h in util.c (problem on SysV).
- Create BINDIR if it does not exist.
- Use cc by default.
- Added zcmp, zmore, zdiff.
- Fixed the man page gzip.1.
-
-Sat Oct 31 17:00:00 1992 Jean-loup Gailly (jloup@chorus.fr)
-
- * Alpha version 0.2
- Fixed compilation problems with gcc
-
-Sat Oct 31 12:46:00 1992 Jean-loup Gailly (jloup@chorus.fr)
-
- * Alpha version 0.1 released (under time pressure), so it's not
- much tested, sorry.
-
diff --git a/gnu/usr.bin/gzip/Makefile b/gnu/usr.bin/gzip/Makefile
deleted file mode 100644
index 71603d5..0000000
--- a/gnu/usr.bin/gzip/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-# @(#)Makefile 5.3 (Berkeley) 5/12/90
-# $Id: Makefile,v 1.17 1997/12/21 19:15:12 wosch Exp $
-
-PROG= gzip
-SRCS= gzip.c zip.c deflate.c trees.c bits.c unzip.c inflate.c util.c \
- crypt.c lzw.c unlzw.c unlzh.c unpack.c getopt.c match.S
-MAN1= gzexe.1 gzip.1 zdiff.1 zforce.1 zmore.1 znew.1
-CFLAGS+=-DASMV -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DDIRENT=1
-GREP_LIBZ?= YES
-
-MLINKS= gzip.1 gunzip.1 gzip.1 zcat.1 gzip.1 gzcat.1
-MLINKS+= zdiff.1 zcmp.1
-
-LINKS+= ${BINDIR}/gzip ${BINDIR}/gunzip
-LINKS+= ${BINDIR}/gzip ${BINDIR}/gzcat
-LINKS+= ${BINDIR}/gzip ${BINDIR}/zcat
-LINKS+= ${BINDIR}/zdiff ${BINDIR}/zcmp
-.if defined(GREP_LIBZ) && empty(GREP_LIBZ)
-LINKS+= ${BINDIR}/zgrep ${BINDIR}/zegrep
-LINKS+= ${BINDIR}/zgrep ${BINDIR}/zfgrep
-MLINKS+= zgrep.1 zfgrep.1 zgrep.1 zegrep.1
-MAN1+= zgrep.1
-.endif
-
-NOSHARED?=yes
-ZGREP=zgrep.getopt
-
-beforeinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/zforce ${.CURDIR}/gzexe ${.CURDIR}/znew \
- ${.CURDIR}/zmore ${.CURDIR}/zdiff \
- ${DESTDIR}${BINDIR}
-.if defined(GREP_LIBZ) && empty(GREP_LIBZ)
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/${ZGREP} ${DESTDIR}${BINDIR}/zgrep
-.endif
-
-match.o: ${.CURDIR}/match.S
- $(CPP) ${.CURDIR}/match.S >_match.s
- $(CC) -c _match.s
- mv -f _match.o match.o
- rm -f _match.s
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/gzip/NEWS b/gnu/usr.bin/gzip/NEWS
deleted file mode 100644
index ef5f833..0000000
--- a/gnu/usr.bin/gzip/NEWS
+++ /dev/null
@@ -1,221 +0,0 @@
-Current Version: 1.2.4.
-See the file ChangeLog for the details of all changes.
-
-Major changes from 1.2.3 to 1.2.4
-* By default, do not restore file name and timestamp from those saved
- inside the .gz file (behave as 'compress'). Added the --name option
- to force name and timestamp restoration.
-* Accept - as synonym for stdin.
-* Use manlinks=so or ln to support either hard links or .so in man pages
-* Accept foo.gz~ in zdiff.
-* Added support for Windows NT
-* Handle ENAMETOOLONG for strict Posix systems
-* Use --recursive instead of --recurse to comply with Webster and
- the GNU stdandard.
-* Allow installation of shell scripts with a g prefix: make G=g install
-* Install by default zcat as gzcat if gzcat already exists in path.
-* Let zmore behave as more when invoked without parameters (give help)
-* Let gzip --list reject files not in gzip format even with --force.
-* Don't complain about non gzip files for options -rt or -rl.
-* Added advice in INSTALL for several systems.
-
-Major changes from 1.2.2 to 1.2.3
-* Don't display the output name when decompressing except with --verbose.
-* Remove usage of alloca in getopt.c and all makefiles.
-* Added the zfile shell script in subdirectory sample.
-* Moved the list of compiler bugs from README to INSTALL.
-* Added vms/Readme.vms.
-
-Major changes from 1.2.1 to 1.2.2
-* Fix a compilation error on Sun with cc (worked with gcc).
-
-Major changes from 1.2 to 1.2.1
-* Let zmore act as more if the data is not gzipped.
-* made gzexe more secure (don't rely on PATH).
-* By default, display output name only when the name was actually truncated.
-
-Major changes from 1.1.2 to 1.2
-* Added the --list option to display the file characteristics.
-* Added the --no-name option: do not save or restore original filename
- Save the original name by default.
-* Allow gunzip --suffix "" to attempt decompression on any file
- regardless of its extension if an original name is present.
-* Add support for the SCO compress -H format.
-* gzip --fast now compresses faster (speed close to that of compress)
- with degraded compression ratio (but still better than compress).
- Default level changed to -6 (acts exactly as previous level -5) to
- be a better indication of its placement in the speed/ratio range.
-* Use smart name truncation: 123456789012.c -> 123456789.c.gz
- instead of 12345678901.gz
-* With --force, let zcat pass non gzip'ed data unchanged (zcat == cat)
-* Added the zgrep shell script.
-* Made sub.c useful for 16 bit sound, 24 bit images, etc..
-* Supress warnings about suffix for gunzip -r, except with --verbose.
-* On MSDOS, use .gz extension when possible (files without extension)
-* Moved the sample programs to a subdirectory sample.
-* Added a "Special targets" section in INSTALL.
-
-Major changes from 1.1.1 to 1.1.2.
-* Fix serious bug for VMS (-gz not removed when decompressing).
-* Allow suffix other than .gz in znew.
-* Do not display compression ratio when decompressing stdin.
-* In zmore.in, work around brain damaged stty -g (Ultrix).
-* Display a correct compression ratio for .Z files.
-* Added .z to .gz renaming script in INTALL.
-* Allow setting CFLAGS in configure.
-
-Major changes from 1.1 to 1.1.1.
-* Fix serious bug in vms.c (affects Vax/VMS only).
-* Added --ascii option.
-* Add workaround in configure.in for Ultrix (quote eval argument)
-
-Major changes from 1.0.7 to 1.1.
-* Use .gz suffix by default, add --suffix option.
-* Let gunzip accept a "_z" suffix (used by one 'compress' on Vax/VMS).
-* Quit when reading garbage from stdin instead of reporting an error.
-* Added makefile for VAX/MMS and support for wildcards on VMS.
-* Added support for MSC under OS/2.
-* Added support for Prime/PRIMOS.
-* Display compression ratio also when decompressing (with --verbose).
-* Quit after --version (GNU standard)
-* Use --force to bypass isatty() check
-* Continue processing other files in case of recoverable error.
-* Added comparison of zip and gzip in the readme file.
-* Added small sample programs (ztouch, sub, add)
-* Use less memory when compiled with -DSMALL_MEM (for MSDOS).
-* Remove the "off by more than one minute" time stamp kludge
-
-Major changes from 1.0.6 to 1.0.7.
-* Allow zmore to read from standard input (like more).
-* Support the 68000 (Atari ST) in match.S.
-* Retry partial writes (required on Linux when gzip is suspended in a pipe).
-* Allow full pathnames and renamings in gzexe.
-* Don't let gzexe compress setuid executables or gzip itself.
-* Added vms/Makefile.gcc for gcc on the Vax.
-* Allow installation of binaries and shell scripts in different dirs.
-* Allows complex PAGER variable in zmore (e.g.: PAGER="col -x | more")
-* Allow installation of zcat as gzcat.
-* Several small changes for portability to old or weird systems.
-* Suppress help message and send compressed data to the terminal when
- gzip is invoked without parameters and without redirection.
-* Add compile option GNU_STANDARD to respect the GNU coding standards:
- with -DGNU_STANDARD, behave as gzip even if invoked under the name gunzip.
-(I don't like the last two changes, which were requested by the FSF.)
-
-Major changes from 1.0.5 to 1.0.6.
-* Let gzexe detect executables that are already gzexe'd.
-* Keep file attributes in znew and gzexe if cpmod is available.
-* Don't try restoring record format on VMS (1.0.5 did not work correctly)
-* Added asm version for 68000 in amiga/match.a.
- Use asm version for Atari TT and NeXT.
-* For OS/2, assume HPFS by default, add flag OS2FAT if necessary.
-* Fixed some bugs in zdiff and define zcmp as a link to zdiff.
-
-
-Major changes from 1.0.4 to 1.0.5.
-* For VMS, restore the file type for variable record format, otherwise
- extract in fixed length format (not perfect, but better than
- forcing all files to be in stream_LF format).
-* For VMS, use "-z" default suffix and accept a version number in file names.
-* For Unix, allow compression of files with name ending in 'z'. Use only
- .z, .*-z, .tgz, .taz as valid gzip extensions. In the last two cases,
- extract to .tar by default.
-* On some versions of MSDOS, files with a 3 character extension could not
- be compressed.
-* Garbage collect files in /tmp created by gzexe.
-* Fix the 'OS code' byte in the gzip header.
-* For the Amiga, add the missing utime.h and add support for gcc.
-
-
-Major changes from 1.0.3 to 1.0.4.
-* Added optimized asm version for 68020.
-* Add support for DJGPP.
-
-* Add support for the Atari ST.
-* Added zforce to rename gzip'ed files with truncated names.
-* Do not install with name uncompress (some systems rely on the
- absence of any check in the old uncompress).
-* Added missing function (fcfree) in msdos/tailor.c
-* Let gunzip handle .tgz files, and let gzip skip them.
-* Added -d option (decompress) for gzexe and try preserving file permissions.
-* Suppress all warnings with -q.
-* Use GZIP_OPT for VMS to avoid conflict with program name.
-* ... and many other small changes (see ChangeLog)
-
-
-Major changes from 1.0.2 to 1.0.3
-* Added -K option for znew to keep old .Z files if smaller
-* Added -q option (quiet) to cancel -v in GZIP env variable.
-* Made gzexe safer on systems with filename limitation to 14 chars.
-* Fixed bugs in handling of GZIP env variable and incorrect free with Turbo C.
-
-
-Major changes from 1.0.1 to 1.0.2
-* Added env variable GZIP for default options. Example:
- for sh: GZIP="-8 -v"; export GZIP
- for csh: setenv GZIP "-8 -v"
-* Added support for the Amiga.
-* znew now keeps the old .Z if it is smaller than the .z file.
- This can happen for some large and very redundant files.
-* Do not complain about trailing garbage for record oriented IO (Vax/VMS).
- This implies however that multi-part gzip files are not supported
- on such systems.
-* Added gzexe to compress rarely used executables.
-* Reduce memory usage (required for MSDOS and useful on all systems).
-* Preserve time stamp in znew -P (pipe option) if touch -r works.
-
-
-Major changes from 1.0 to 1.0.1
-* fix trivial errors in the Borland makefile (msdos/Makefile.bor)
-
-
-Major changes from 0.8.2 to 1.0
-* gzip now runs on Vax/VMS
-* gzip will not not overwrite files without -f when using /bin/sh in
- background.
-* Support the test option -t for compressed (.Z) files.
- Allow some data recovery for bad .Z files.
-* Added makefiles for MSDOS (Only tested for MSC, not Borland).
-* still more changes to configure for several systems
-
-
-Major changes from 0.8.1 to 0.8.2:
-* yet more changes to configure for Linux and other systems
-* Allow zcat on a file with multiple links.
-
-
-Major changes from 0.8 to 0.8.1:
-* znew has now a pipe option -P to reduce the disk space requirements,
- but this option does not preserve timestamps.
-* Fixed some #if directives for compilation with TurboC.
-
-
-Major changes from 0.7 to 0.8:
-* gzip can now extract .z files created by 'pack'.
-* configure should no longer believe that every machine is a 386
-* Fix the entry for /etc/magic in INSTALL.
-* Add patch for GNU tar 1.11.1 and a pointer to crypt++.el
-* Uncompress files with multiple links only with -f.
-* Fix for uncompress of .Z files on 16-bit machines
-* Create a correct output name for file names of exactly N-1 chars when
- the system has a limit of N chars.
-
-
-Major changes from 0.6 to 0.7:
-* Use "make check" instead of "make test".
-* Keep time stamp and pass options to gzip in znew.
-* Do not create .z.z files with gzip -r.
-* Allow again gunzip .zip files (was working in 0.5)
-* Allow again compilation with TurboC 2.0 (was working in 0.4)
-
-
-Major changes form 0.5 to 0.6:
-* gunzip reported an error when extracting certain .z files. The .z files
- produced by gzip 0.5 are correct and can be read by gunzip 0.6.
-* gunzip now supports multiple compressed members within a single .z file.
-* Fix the check for i386 in configure.
-* Added "make test" to check for compiler bugs. (gcc -finline-functions
- is broken at least on the NeXT.)
-* Use environment variable PAGER in zmore if it is defined.
-* Accept gzcat in addition to zcat for people having /usr/bin before
- /usr/local/bin in their path.
diff --git a/gnu/usr.bin/gzip/README b/gnu/usr.bin/gzip/README
deleted file mode 100644
index fdd7311..0000000
--- a/gnu/usr.bin/gzip/README
+++ /dev/null
@@ -1,144 +0,0 @@
-This is the file README for the gzip distribution, version 1.2.4.
-
-gzip (GNU zip) is a compression utility designed to be a replacement
-for 'compress'. Its main advantages over compress are much better
-compression and freedom from patented algorithms. The GNU Project
-uses it as the standard compression program for its system.
-
-gzip currently uses by default the LZ77 algorithm used in zip 1.9 (the
-portable pkzip compatible archiver). The gzip format was however
-designed to accommodate several compression algorithms. See below
-for a comparison of zip and gzip.
-
-gunzip can currently decompress files created by gzip, compress or
-pack. The detection of the input format is automatic. For the
-gzip format, gunzip checks a 32 bit CRC. For pack, gunzip checks the
-uncompressed length. The 'compress' format was not designed to allow
-consistency checks. However gunzip is sometimes able to detect a bad
-.Z file because there is some redundancy in the .Z compression format.
-If you get an error when uncompressing a .Z file, do not assume that
-the .Z file is correct simply because the standard uncompress does not
-complain. This generally means that the standard uncompress does not
-check its input, and happily generates garbage output.
-
-gzip produces files with a .gz extension. Previous versions of gzip
-used the .z extension, which was already used by the 'pack'
-Huffman encoder. gunzip is able to decompress .z files (packed
-or gzip'ed).
-
-Several planned features are not yet supported (see the file TODO).
-See the file NEWS for a summary of changes since 0.5. See the file
-INSTALL for installation instructions. Some answers to frequently
-asked questions are given in the file INSTALL, please read it. (In
-particular, please don't ask me once more for an /etc/magic entry.)
-
-WARNING: on several systems, compiler bugs cause gzip to fail, in
-particular when optimization options are on. See the section "Special
-targets" at the end of the INSTALL file for a list of known problems.
-For all machines, use "make check" to check that gzip was compiled
-correctly. Try compiling gzip without any optimization if you have a
-problem.
-
-Please send all comments and bug reports by electronic mail to:
- Jean-loup Gailly <jloup@chorus.fr>
-
-or, if this fails, to bug-gnu-utils@prep.ai.mit.edu.
-Bug reports should ideally include:
-
- * The complete output of "gzip -V" (or the contents of revision.h
- if you can't get gzip to compile)
- * The hardware and operating system (try "uname -a")
- * The compiler used to compile (if it is gcc, use "gcc -v")
- * A description of the bug behavior
- * The input to gzip, that triggered the bug
-
-If you send me patches for machines I don't have access to, please test them
-very carefully. gzip is used for backups, it must be extremely reliable.
-
-The package crypt++.el is highly recommended to manipulate gzip'ed
-file from emacs. It recognizes automatically encrypted and compressed
-files when they are first visited or written. It is available via
-anonymous ftp to roebling.poly.edu [128.238.5.31] in /pub/crypt++.el.
-The same directory contains also patches to dired, ange-ftp and info.
-GNU tar 1.11.2 has a -z option to invoke directly gzip, so you don't have to
-patch it. The package ftp.uu.net:/languages/emacs-lisp/misc/jka-compr19.el.Z
-also supports gzip'ed files.
-
-The znew and gzexe shell scripts provided with gzip benefit from
-(but do not require) the cpmod utility to transfer file attributes.
-It is available by anonymous ftp on gatekeeper.dec.com in
-/.0/usenet/comp.sources.unix/volume11/cpmod.Z.
-
-The sample programs zread.c, sub.c and add.c in subdirectory sample
-are provided as examples of useful complements to gzip. Read the
-comments inside each source file. The perl script ztouch is also
-provided as example (not installed by default since it relies on perl).
-
-
-gzip is free software, you can redistribute it and/or modify it under
-the terms of the GNU General Public License, a copy of which is
-provided under the name COPYING. The latest version of gzip are always
-available by ftp in prep.ai.mit.edu:/pub/gnu, or in any of the prep
-mirror sites:
-
-- sources in gzip-*.tar (or .shar or .tar.gz).
-- Solaris 2 executables in sparc-sun-solaris2/gzip-binaries-*.tar
-- MSDOS lha self-extracting exe in gzip-msdos-*.exe. Once extracted,
- copy gzip.exe to gunzip.exe and zcat.exe, or use "gzip -d" to decompress.
- gzip386.exe runs much faster but only on 386 and above; it is compiled with
- djgpp 1.10 available in directory omnigate.clarkson.edu:/pub/msdos/djgpp.
-
-A VMS executable is available in ftp.spc.edu:[.macro32.savesets]gzip-1-*.zip
-(use [.macro32]unzip.exe to extract). A PRIMOS executable is available
-in ftp.lysator.liu.se:/pub/primos/run/gzip.run.
-OS/2 executables (16 and 32 bits versions) are available in
-ftp.tu-muenchen.de:/pub/comp/os/os2/archiver/gz*-[16,32].zip
-
-Some ftp servers can automatically make a tar.Z from a tar file. If
-you are getting gzip for the first time, you can ask for a tar.Z file
-instead of the much larger tar file.
-
-Many thanks to those who provided me with bug reports and feedback.
-See the files THANKS and ChangeLog for more details.
-
-
- Note about zip vs. gzip:
-
-The name 'gzip' was a very unfortunate choice, because zip and gzip
-are two really different programs, although the actual compression and
-decompression sources were written by the same persons. A different
-name should have been used for gzip, but it is too late to change now.
-
-zip is an archiver: it compresses several files into a single archive
-file. gzip is a simple compressor: each file is compressed separately.
-Both share the same compression and decompression code for the
-'deflate' method. unzip can also decompress old zip archives
-(implode, shrink and reduce methods). gunzip can also decompress files
-created by compress and pack. zip 1.9 and gzip do not support
-compression methods other than deflation. (zip 1.0 supports shrink and
-implode). Better compression methods may be added in future versions
-of gzip. zip will always stick to absolute compatibility with pkzip,
-it is thus constrained by PKWare, which is a commercial company. The
-gzip header format is deliberately different from that of pkzip to
-avoid such a constraint.
-
-On Unix, gzip is mostly useful in combination with tar. GNU tar
-1.11.2 has a -z option to invoke gzip automatically. "tar -z"
-compresses better than zip, since gzip can then take advantage of
-redundancy between distinct files. The drawback is that you must
-scan the whole tar.gz file in order to extract a single file near
-the end; unzip can directly seek to the end of the zip file. There
-is no overhead when you extract the whole archive anyway.
-If a member of a .zip archive is damaged, other files can still
-be recovered. If a .tar.gz file is damaged, files beyond the failure
-point cannot be recovered. (Future versions of gzip will have
-error recovery features.)
-
-gzip and gunzip are distributed as a single program. zip and unzip
-are, for historical reasons, two separate programs, although the
-authors of these two programs work closely together in the info-zip
-team. zip and unzip are not associated with the GNU project.
-The sources are available by ftp in
-
- oak.oakland.edu:/pub/misc/unix/zip19p1.zip
- oak.oakland.edu:/pub/misc/unix/unz50p1.tar-z
diff --git a/gnu/usr.bin/gzip/THANKS b/gnu/usr.bin/gzip/THANKS
deleted file mode 100644
index 6a545cb..0000000
--- a/gnu/usr.bin/gzip/THANKS
+++ /dev/null
@@ -1,276 +0,0 @@
-gzip was written by Jean-loup Gailly <jloup@chorus.fr>, with portions
-written by Mark Adler (inflate.c), Peter Jannesen (unlzw.c) and
-Haruhiko Okumura (unlzh.c). The zip deflate format was defined by Phil Katz.
-Thanks to those who reported problems and suggested various
-improvements. Here is a partial list of them:
-
-Robert Abramovitz bromo@cougar.tandem.com
-Jay Adams jka@ece.cmu.edu
-Mark Adler madler@cco.caltech.edu
-Edwin Allum edwin@csri.toronto.edu
-Joseph Arceneaux jla@gnu.ai.mit.edu
-Tim Auckland tda10@cus.cam.ac.uk
-Ken-ichiro Aoki aoki@madonna.physics.ucla.edu
-David Ascher da@marlowe.cog.brown.edu
-Eric Backus ericb@lsid.hp.com
-Becky A. Badgett badgett@cs.utexas.edu
-Bo Nygaard Bai bai@iesd.auc.dk
-Dave Barber dbarber@apocalypse.bbn.com
-Rene Beaulieu reneb@distri.hydro.qc.ca
-Neal Becker neal@ctd.comsat.com
-Dieter Becker becker@med-in.uni-sb.de
-Nelson H. F. Beebe beebe@geronimo.math.utah.edu
-Jeff Beadles jeff@onion.rain.com
-David J. N. Begley dbegley@st.nepean.uws.edu.au
-Bob Beresh rberesh@rd.hydro.on.ca
-Jim Bernard jbernard@iola.mines.colorado.edu
-Karl Berry karl@cs.umb.edu
-James W. Birdsall jwbirdsa@picarefy.picarefy.com
-Scott Bolte scott@craycos.com
-Wayne E. Bouchard web@paladine.hacks.arizona.edu
-Marc Boucher marc@cam.org
-Ola Brahammar pt90ob@pt.hk-r.se
-Dave Brennan brennan@hal.com
-Alan Brown dogbowl@dogbox.acme.gen.nz
-Michael L. Brown brown@wi.extrel.com
-Rodney Brown rdb@mel.cocam.oz.au
-Bruce bde@runx.oz.au
-Bill Bumgarner bbum@stone.com
-Leila Burrell-Davis leilabd@syma.sussex.ac.uk
-Roger Butenuth butenuth@ira.uka.de
-Jon Cargille jcargill@cs.wisc.edu
-Bud Carlson bud@isle.pegasus.com
-Lim Fung Chai fclim@i1sin.daq.semi.harris.com
-Wes Chalfant wes@kofax.com
-Andrew A. Chernov ache@astral.msk.su
-Paul Close pdc@lunch.wpd.sgi.com
-Jeff Coffler coffler@jac.enet.dec.com
-Will Colley wcc3@occs.cs.oberlin.edu
-Roger Cornelius sherpa!rac@uunet.uu.net
-Kevin Cosgrove kevinc@tekig6.pen.tek.com
-Stephen J Cowley s.j.cowley@amtp.cam.ac.uk
-Ron Cox roncox@indirect.com
-Frank Crawford frank@photon.ansto.gov.au
-James R. Crawford qralston@cislabs.pitt.edu
-Lawrence Crowl crowl@research.cs.orst.edu
-Klaus Dahlenburg kdburg@incoahe.hanse.de
-William E Davidsen davidsen@ariel.crd.ge.com
-John M. DeDourek dedourek@aixive2.cs.unb.ca
-Jeff Deifik jdeifik@isi.edu
-Vince DeMarco vince@whatnxt.cuc.ab.ca
-Michael De La Rue p91152@cplab.physics.edinburgh.ac.uk
-Jeff Delinck delinck@pa621a.inland.com
-John DeRoo deroo@grout.adv.shr.dec.com
-Jim Diamond zsd@axe.drea.dnd.ca
-Stefano Diomedi sd@teculx.tecsiel.it
-Lawrence R. Dodd dodd@roebling.poly.edu
-Matthew Donadio donadio@mxd120.rh.psu.edu
-Andy Dougherty andy@crystal.phys.lafayette.edu
-Darrell Duane dduane@mason1.gmu.edu
-John Eaton jwe@che.utexas.edu
-Will Edgington wedgingt@ptolemy.arc.nasa.gov
-Brian Edmonds edmonds@edmonds.home.cs.ubc.ca
-Paul Eggert eggert@twinsun.com
-Enami enami@sys.ptg.sony.co.jp
-Kristoffer Eriksson ske@pkmab.se
-Daniel Eriksson m91der@bellatrix.tdb.uu.se
-Rik Faith faith@cs.unc.edu
-Larry Fahnoe fahnoe@c1mpls.mn.org
-Cristian Ferretti cfs@poincare.mat.puc.cl
-Karl-Jose Filler pla_jfi@pki-nbg.philips.de
-Valery Fine fine@vxcern.cern.ch
-Bob Fischer bobf@milne.geology.yale.edu
-Per Foreby perf@efd.lth.se
-Alexander Fraser alex@cs.umb.edu
-Noah Friedman friedman@gnu.ai.mit.edu
-Bob Friesenhahn bfriesen@iphase.com
-Gerhard Friesland-Koepke frieslan@rzdspc3.informatik.uni-hamburg.de
-Andy Fyfe andy@scp.caltech.edu
-Geoff geoff@frs.faxon.com
-Arnd Gerns gerns@informatik.uni-hildesheim.de
-Kaveh R. Ghazi ghazi@staccato.rutgers.edu
-Torbjorn Granlund tege@sics.se
-Carl Greco cgreco@parrot.creighton.edu
-Bruno Haible haible@ma2s2.mathematik.uni-karlsruhe.de
-Junio Hamano junio@shadow.twinsun.com
-Harald Hanche-Olsen hanche@ams.sunysb.edu
-Darrel R. Hankerson hankedr@mail.auburn.edu
-Mark Hanning-Lee markhl@romeo.caltech.edu
-Lars Hecking st000002@hrz1.hrz.th-darmstadt.de
-Ruediger Helsch ruediger@ramz.ing.tu-bs.de
-Mark C. Henderson mch@sqwest.wimsey.bc.ca
-Karl Heuer karl@kelp.boston.ma.us
-Jarkko Hietaniemi jhi@dol-guldur.hut.fi
-Thomas Hiller hiller@fzi.de
-Eiji Hirai hirai@cc.swarthmore.edu
-Kjetil Torgrim Homme kjetilho@ifi.uio.no
-Robert D. Houk rdh@sli.com
-Jim Howard jim_howard@mentorg.com
-Preston Hunt gt5708a@prism.gatech.edu
-Shane C Hutchins sch@nymph.msel.unh.edu
-Hutch hutchinson@wrair-emh1.army.mil
-Lester Ingber ingber@alumni.caltech.edu
-Ken Ishii ishii@sni-usa.com
-Per Steinar Iversen iversen@vsfys1.fi.uib.no
-Chris Jacobsen jacobsen@xray1.physics.sunysb.edu
-Michal Jaegermann ntomczak@vm.ucs.ualberta.ca
-Brian Jones brianj@skat.usc.edu
-Denny de Jonge witaddj@dutrex.tudelft.nl
-Arne H. Juul arnej@lise.unit.no
-Dana Jacobsen jacobsd@solar.cor2.epa.gov
-Peter Jannesen peter@ncs.nl
-Brian D. Johnston johnstonb@med.ge.com
-Walter W. Jones wwj@candela.cfr.nist.gov
-Tom Judson judson@scf.usc.edu
-Henry G. Juengst juengst@saph2.physik.uni-bonn.de
-Sarantos Kapidakis sarantos%manteion@ics.forth.gr
-Amir J. Katz amir@matis.ingr.com
-Steve Kelem kelem@castor.xilinx.com
-Steven Kimball kimball@shrew.sanders.lockheed.com
-Randy Kirchhof rkk@posms.aus.tx.us
-Ned Kittlitz kittlitz@seagoon.sw.stratus.com
-Sakai Kiyotaka ksakai@mtl.t.u-tokyo.ac.jp
-Philip C Kizer pckizer@gonzo.tamu.edu
-Pete Klammer pklammer@ouray.denver.colorado.edu
-Fritz Kleemann kleemann@informatik.uni-wuerzburg.dbp.de
-Wilhelm B. Kloke wb@ifado.arb-phys.uni-dortmund.de
-Tom Kloos tk@sequent.com
-Carsten Koch carsten.koch@icem.de
-Winfried Koenig win@in.rhein-main.de
-Mathias Koerber mathias@solomon.technet.sg
-Steph Konigsdorfer s.konigsdorfer@frmy.bull.fr
-Leif Kornstaedt leif@rumtifsl.ruessel.sub.org
-Michael D. Lawler mdlawler@bsu-cs.bsu.edu
-Kevin Layer layer@franz.com
-Howard D. Leadmon howardl@wb3ffv.ampr.org
-Alexander Lehmann alex@hal.rhein-main.de
-Simon Leinen simon@lia.di.epfl.ch
-Burt Leland burt@molecular.com
-Tony Leneis tony@plaza.adp.ds.com
-Hugues Leroy hugues.leroy@irisa.fr
-Marty Leisner leisner@eso.mc.xerox.com
-Charles Levert charles@aramis.comm.polymtl.ca
-Richard Levitte levitte@e.kth.se
-Torbj|rn Lindh toobii@elixir.e.kth.se
-David R. Linn drl@vuse.vanderbilt.edu
-Antonio Lioy cat@athena.polito.it
-Jamie Lokier u90jl@ecs.oxford.ac.uk
-Richard Lloyd R.K.Lloyd@csc.liv.ac.uk
-David J. MacKenzie djm@eng.umd.edu
-John R MacMillan john@chance.gts.org
-Ron Male male@eso.mc.xerox.com
-Don R. Maszle maze@bea.lbl.gov
-Jaye Mathisen osyjm@cs.montana.edu
-Telly Mavroidis mavroidi@acf2.nyu.edu
-Imed Eddine Mbarki mbarki@pacific.cmpe.psu.edu
-Steeve McCauley steeve@pooh.geophys.mcgill.ca
-Tom McConnell tmcconne@sedona.intel.com
-Tod McQuillin mcquill@ccit05.duq.edu
-Tye McQueen tye@spillman.com
-Bernd Melchers melchers@chemie.fu-berlin.de
-Jason Merrill jason@jarthur.claremont.edu
-Dean S. Messing deanm@medulla.labs.tek.com
-M. Mesturino mesturino@cselt.stet.it
-Luke Mewburn zak@rmit.edu.au
-Jim Meyering meyering@cs.utexas.edu
-Dragan Milicic milicic@math.utah.edu
-Frederic Miserey none.fred@applelink.apple.com
-Marcel J.E. Mol marcel@duteca.et.tudelft.nl
-Soren Juul Moller sjm@dde.dk
-Chris Moore moore@src.bae.co.uk
-Dan Mosedale mosedale@genome.stanford.edu
-Helmut Muelner hmuelner@fiicmds04.tu-graz.ac.at
-Urban D Mueller umueller@amiga.physik.unizh.ch
-Ulrich Mueller ulm@vsnhdb.cern.ch
-Timothy Murphy tim@maths.tcd.ie
-Greg Naber greg@squally.halcyon.com
-Jay Nayegandhi jayng@bbiv02.enet.dec.com
-Paul K. Neville II pkn2@idsi.com
-Karl L. Noell noell@informatik.fh-wiesbaden.dbp.de
-Demizu Noritoshi nori-d@is.aist-nara.ac.jp
-Todd Ogasawara todd@protege.pegasus.com
-Helge Oldach helge.oldach@stollmann.de
-Arthur David Olson ado@elsie.nci.nih.gov
-Piet van Oostrum piet@cs.ruu.nl
-Rafael R. Pappalardo rafapa@obelix.cica.es
-Mike Pearlman canuck@masc38.rice.edu
-Yves Perrenoud pyves@nuga.alphanet.ch
-Hal Peterson hrp@pecan.cray.com
-Pascal Petit petit@cadillac.ibp.fr
-Bruno Pillard bp@chorus.fr
-Franc,ois Pinard pinard@iro.umontreal.ca
-Jay Pinkos pinkos@butyng.bu.edu
-Thomas Plass thomas@cogsci.ed.ac.uk
-Mike Polo mikep@cfsmo.honeywell.com
-Francesco Potorti pot@fly.cnuce.cnr.it
-Will Priest bpriest@lobby.ti.com
-David Purves purves@apogee.com
-Andreas Raab ar@nvmr.robin.de
-Eric S. Raymond esr@snark.thyrsus.com
-Klaus Reimann kr@cip.physik.uni-stuttgart.de
-Michael Rendell michael@mercury.cs.mun.ca
-Hal Render render@massive.uccs.edu
-Julian F. Reschke julian@math.uni-muenster.de
-Phil Richards Phil.Richards@prg.oxford.ac.uk
-Roland B Roberts roberts@nsrl31.nsrl.rochester.edu
-Arnold Robbins arnold@cc.gatech.edu
-Kevin Rodgers kevin@rolling-stone.den.mmc.com
-Kai Uwe Rommel rommel@informatik.tu-muenchen.de
-Paul Rubin phr@america.telebit.com
-Wolfgang Rupprecht wolfgang@wsrcc.com
-Jonathan Ryshpan jon@amito.hitachi.com
-Paul A Sand pas@unh.edu
-Tony Sanders sanders@bsdi.com
-Mike Sangrey mike@sojurn.lns.pa.us
-Niimi Satoshi a01309@cfi.waseda.ac.jp
-Marc Schaefer sysadm@alphanet.ch
-Andreas Schwab schwab@lamothe.informatik.uni-dortmund.de
-Eric Schenk schenk@cs.toronto.edu
-Eric P. Scott eps@cs.sfsu.edu
-Olaf Seibert rhialto@mbfys.kun.nl
-Sunando Sen sens@fasecon.econ.nyu.edu
-Harry Shamansky hts@hertz.eng.ohio-state.edu
-Amos Shapira amoss@cs.huji.ac.il
-Rick Sladkey jrs@world.std.com
-Daniel L Smith dls@autodesk.com
-Fred Smith fredex%fcshome@merk.merk.com
-Stephen Soliday soliday@ncat.edu
-Paul Southworth pauls@css.itd.umich.edu
-Rob Spencer robbie@winkle.bhpese.oz.au
-Richard Stallman rms@gnu.ai.mit.edu
-Carsten Steger carsten.steger@informatik.tu-muenchen.de
-David Sundstrom sunds@anon.asic.sc.ti.com
-Ed Sznyter ews@babel.babel.com
-Hideaki Tanabe arctanx@iyeyasu.ynl.t.u-tokyo.ac.jp
-Andrew Telford ajt@peregrin.resmel.bhp.com.au
-Glenn E. Thobe thobe@getunx.info.com
-Kei Thomsen kt@keihh.hanse.de
-Karsten Thygesen karthy@dannug.dk
-Mark Towfiq towfiq@microdyne.com
-Jeff Treece treece@sabbagh.com
-Oliver Trepte oliver@ikaros.fysik4.kth.se
-Stephane Tsacas slt@is21.isoft.fr
-Stephen Tweedie sct@dcs.ed.ac.uk
-John R. Vanderpool fish@daacdev1.stx.com
-Sotiris Vassilopoulos vassilopoulos@virginia.edu
-Pedro A. M. Vazquez vazquez@iqm.unicamp.br
-Arjan de Vet devet@win.tue.nl
-Larry W. Virden lvirden@cas.org
-Vadim V. Vlasov vvlasov@inucres.msk.su
-Eduard Vopicka eduard.vopicka@vse.cs
-Theo Vosse vosse@ruls41.leidenuniv.nl
-Darin Wayrynen darin@pcg.uucp
-Marcel Waldvogel marcel@nice.usergroup.ethz.ch
-Stephen J. Walick steve@nshore.org
-Gray Watson gray@antaire.com
-David Watt dmwatt@smersh.cambridge.ma.us
-Scott Weikart scott@igc.apc.org
-Ivo Welch iwelch@agsm.ucla.edu
-Jochen Wiedmann zrawi01@zmcipdec1.zdv.uni-tuebingen.de
-Gijsb. Wiesenekker wiesenecker@sara.nl
-Wietze van Winden wietze@swi.psy.uva.nl
-Frank Wuebbeling wuebbel@math.uni-muenster.de
-Larry W. Virden lwv26@cas.org
-Bill Wohler wohler@sap-ag.de
-Jamie Zawinski jwz@lucid.com
-Christos Zoulas christos@deshaw.com
diff --git a/gnu/usr.bin/gzip/TODO b/gnu/usr.bin/gzip/TODO
deleted file mode 100644
index 865be92..0000000
--- a/gnu/usr.bin/gzip/TODO
+++ /dev/null
@@ -1,58 +0,0 @@
-TODO file for gzip.
-
-Some of the planned features include:
-
-- Structure the sources so that the compression and decompression code
- form a library usable by any program, and write both gzip and zip on
- top of this library. This would ideally be a reentrant (thread safe)
- library, but this would degrade performance. In the meantime, you can
- look at the sample program zread.c.
-
- The library should have one mode in which compressed data is sent
- as soon as input is available, instead of waiting for complete
- blocks. This can be useful for sending compressed data to/from interactive
- programs.
-
-- Make it convenient to define alternative user interfaces (in
- particular for windowing environments).
-
-- Support in-memory compression for arbitrarily large amounts of data
- (zip currently supports in-memory compression only for a single buffer.)
-
-- Map files in memory when possible, this is generally much faster
- than read/write. (zip currently maps entire files at once, this
- should be done in chunks to reduce memory usage.)
-
-- Add a super-fast compression method, suitable for implementing
- file systems with transparent compression. One problem is that the
- best candidate (lzrw1) is patented twice (Waterworth 4,701,745
- and Gibson & Graybill 5,049,881). The lzrw series of algorithms
- are available by ftp in ftp.adelaide.edu.au:/pub/compression/lzrw*.
-
-- Add a super-tight (but slow) compression method, suitable for long
- term archives. One problem is that the best versions of arithmetic
- coding are patented (4,286,256 4,295,125 4,463,342 4,467,317
- 4,633,490 4,652,856 4,891,643 4,905,297 4,935,882 4,973,961
- 5,023,611 5,025,258).
-
- Note: I will introduce new compression methods only if they are
- significantly better in either speed or compression ratio than the
- existing method(s). So the total number of different methods should
- reasonably not exceed 3. (The current 9 compression levels are just
- tuning parameters for a single method, deflation.)
-
-- Add optional error correction. One problem is that the current version
- of ecc cannot recover from inserted or missing bytes. It would be
- nice to recover from the most common error (transfer of a binary
- file in ascii mode).
-
-- Add a block size (-b) option to improve error recovery in case of
- failure of a complete sector. Each block could be extracted
- independently, but this reduces the compression ratio.
-
-- Use a larger window size to deal with some large redundant files that
- 'compress' currently handles better than gzip.
-
-- Implement the -e (encrypt) option.
-
-Send comments to Jean-loup Gailly <jloup@chorus.fr>.
diff --git a/gnu/usr.bin/gzip/algorithm.doc b/gnu/usr.bin/gzip/algorithm.doc
deleted file mode 100644
index 24f7619..0000000
--- a/gnu/usr.bin/gzip/algorithm.doc
+++ /dev/null
@@ -1,164 +0,0 @@
-1. Algorithm
-
-The deflation algorithm used by zip and gzip is a variation of LZ77
-(Lempel-Ziv 1977, see reference below). It finds duplicated strings in
-the input data. The second occurrence of a string is replaced by a
-pointer to the previous string, in the form of a pair (distance,
-length). Distances are limited to 32K bytes, and lengths are limited
-to 258 bytes. When a string does not occur anywhere in the previous
-32K bytes, it is emitted as a sequence of literal bytes. (In this
-description, 'string' must be taken as an arbitrary sequence of bytes,
-and is not restricted to printable characters.)
-
-Literals or match lengths are compressed with one Huffman tree, and
-match distances are compressed with another tree. The trees are stored
-in a compact form at the start of each block. The blocks can have any
-size (except that the compressed data for one block must fit in
-available memory). A block is terminated when zip determines that it
-would be useful to start another block with fresh trees. (This is
-somewhat similar to compress.)
-
-Duplicated strings are found using a hash table. All input strings of
-length 3 are inserted in the hash table. A hash index is computed for
-the next 3 bytes. If the hash chain for this index is not empty, all
-strings in the chain are compared with the current input string, and
-the longest match is selected.
-
-The hash chains are searched starting with the most recent strings, to
-favor small distances and thus take advantage of the Huffman encoding.
-The hash chains are singly linked. There are no deletions from the
-hash chains, the algorithm simply discards matches that are too old.
-
-To avoid a worst-case situation, very long hash chains are arbitrarily
-truncated at a certain length, determined by a runtime option (zip -1
-to -9). So zip does not always find the longest possible match but
-generally finds a match which is long enough.
-
-zip also defers the selection of matches with a lazy evaluation
-mechanism. After a match of length N has been found, zip searches for a
-longer match at the next input byte. If a longer match is found, the
-previous match is truncated to a length of one (thus producing a single
-literal byte) and the longer match is emitted afterwards. Otherwise,
-the original match is kept, and the next match search is attempted only
-N steps later.
-
-The lazy match evaluation is also subject to a runtime parameter. If
-the current match is long enough, zip reduces the search for a longer
-match, thus speeding up the whole process. If compression ratio is more
-important than speed, zip attempts a complete second search even if
-the first match is already long enough.
-
-The lazy match evaluation is no performed for the fastest compression
-modes (speed options -1 to -3). For these fast modes, new strings
-are inserted in the hash table only when no match was found, or
-when the match is not too long. This degrades the compression ratio
-but saves time since there are both fewer insertions and fewer searches.
-
-
-2. gzip file format
-
-The pkzip format imposes a lot of overhead in various headers, which
-are useful for an archiver but not necessary when only one file is
-compressed. gzip uses a much simpler structure. Numbers are in little
-endian format, and bit 0 is the least significant bit.
-A gzip file is a sequence of compressed members. Each member has the
-following structure:
-
-2 bytes magic header 0x1f, 0x8b (\037 \213)
-1 byte compression method (0..7 reserved, 8 = deflate)
-1 byte flags
- bit 0 set: file probably ascii text
- bit 1 set: continuation of multi-part gzip file
- bit 2 set: extra field present
- bit 3 set: original file name present
- bit 4 set: file comment present
- bit 5 set: file is encrypted
- bit 6,7: reserved
-4 bytes file modification time in Unix format
-1 byte extra flags (depend on compression method)
-1 byte operating system on which compression took place
-
-2 bytes optional part number (second part=1)
-2 bytes optional extra field length
-? bytes optional extra field
-? bytes optional original file name, zero terminated
-? bytes optional file comment, zero terminated
-12 bytes optional encryption header
-? bytes compressed data
-4 bytes crc32
-4 bytes uncompressed input size modulo 2^32
-
-The format was designed to allow single pass compression without any
-backwards seek, and without a priori knowledge of the uncompressed
-input size or the available size on the output media. If input does
-not come from a regular disk file, the file modification time is set
-to the time at which compression started.
-
-The time stamp is useful mainly when one gzip file is transferred over
-a network. In this case it would not help to keep ownership
-attributes. In the local case, the ownership attributes are preserved
-by gzip when compressing/decompressing the file. A time stamp of zero
-is ignored.
-
-Bit 0 in the flags is only an optional indication, which can be set by
-a small lookahead in the input data. In case of doubt, the flag is
-cleared indicating binary data. For systems which have different
-file formats for ascii text and binary data, the decompressor can
-use the flag to choose the appropriate format.
-
-The extra field, if present, must consist of one or more subfields,
-each with the following format:
-
- subfield id : 2 bytes
- subfield size : 2 bytes (little-endian format)
- subfield data
-
-The subfield id can consist of two letters with some mnemonic value.
-Please send any such id to jloup@chorus.fr. Ids with a zero second
-byte are reserved for future use. The following ids are defined:
-
- Ap (0x41, 0x70) : Apollo file type information
-
-The subfield size is the size of the subfield data and does not
-include the id and the size itself. The field 'extra field length' is
-the total size of the extra field, including subfield ids and sizes.
-
-It must be possible to detect the end of the compressed data with any
-compression format, regardless of the actual size of the compressed
-data. If the compressed data cannot fit in one file (in particular for
-diskettes), each part starts with a header as described above, but
-only the last part has the crc32 and uncompressed size. A decompressor
-may prompt for additional data for multipart compressed files. It is
-desirable but not mandatory that multiple parts be extractable
-independently so that partial data can be recovered if one of the
-parts is damaged. This is possible only if no compression state is
-kept from one part to the other. The compression-type dependent flags
-can indicate this.
-
-If the file being compressed is on a file system with case insensitive
-names, the original name field must be forced to lower case. There is
-no original file name if the data was compressed from standard input.
-
-Compression is always performed, even if the compressed file is
-slightly larger than the original. The worst case expansion is
-a few bytes for the gzip file header, plus 5 bytes every 32K block,
-or an expansion ratio of 0.015% for large files. Note that the actual
-number of used disk blocks almost never increases.
-
-The encryption is that of zip 1.9. For the encryption check, the
-last byte of the decoded encryption header must be zero. The time
-stamp of an encrypted file might be set to zero to avoid giving a clue
-about the construction of the random header.
-
-Jean-loup Gailly
-jloup@chorus.fr
-
-References:
-
-[LZ77] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data
-Compression", IEEE Transactions on Information Theory", Vol. 23, No. 3,
-pp. 337-343.
-
-APPNOTE.TXT documentation file in PKZIP 1.93a. It is available by
-ftp in ftp.cso.uiuc.edu:/pc/exec-pc/pkz193a.exe [128.174.5.59]
-Use "unzip pkz193a.exe APPNOTE.TXT" to extract.
diff --git a/gnu/usr.bin/gzip/bits.c b/gnu/usr.bin/gzip/bits.c
deleted file mode 100644
index 079434a..0000000
--- a/gnu/usr.bin/gzip/bits.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* bits.c -- output variable-length bit strings
- * Copyright (C) 1992-1993 Jean-loup Gailly
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-
-/*
- * PURPOSE
- *
- * Output variable-length bit strings. Compression can be done
- * to a file or to memory. (The latter is not supported in this version.)
- *
- * DISCUSSION
- *
- * The PKZIP "deflate" file format interprets compressed file data
- * as a sequence of bits. Multi-bit strings in the file may cross
- * byte boundaries without restriction.
- *
- * The first bit of each byte is the low-order bit.
- *
- * The routines in this file allow a variable-length bit value to
- * be output right-to-left (useful for literal values). For
- * left-to-right output (useful for code strings from the tree routines),
- * the bits must have been reversed first with bi_reverse().
- *
- * For in-memory compression, the compressed bit stream goes directly
- * into the requested output buffer. The input data is read in blocks
- * by the mem_read() function. The buffer is limited to 64K on 16 bit
- * machines.
- *
- * INTERFACE
- *
- * void bi_init (FILE *zipfile)
- * Initialize the bit string routines.
- *
- * void send_bits (int value, int length)
- * Write out a bit string, taking the source bits right to
- * left.
- *
- * int bi_reverse (int value, int length)
- * Reverse the bits of a bit string, taking the source bits left to
- * right and emitting them right to left.
- *
- * void bi_windup (void)
- * Write out any remaining bits in an incomplete byte.
- *
- * void copy_block(char *buf, unsigned len, int header)
- * Copy a stored block to the zip file, storing first the length and
- * its one's complement if requested.
- *
- */
-
-#include "tailor.h"
-#include "gzip.h"
-#include "crypt.h"
-
-#ifdef DEBUG
-# include <stdio.h>
-#endif
-
-#ifdef RCSID
-static char rcsid[] = "$Id$";
-#endif
-
-/* ===========================================================================
- * Local data used by the "bit string" routines.
- */
-
-local file_t zfile; /* output gzip file */
-
-local unsigned short bi_buf;
-/* Output buffer. bits are inserted starting at the bottom (least significant
- * bits).
- */
-
-#define Buf_size (8 * 2*sizeof(char))
-/* Number of bits used within bi_buf. (bi_buf might be implemented on
- * more than 16 bits on some systems.)
- */
-
-local int bi_valid;
-/* Number of valid bits in bi_buf. All bits above the last valid bit
- * are always zero.
- */
-
-int (*read_buf) OF((char *buf, unsigned size));
-/* Current input function. Set to mem_read for in-memory compression */
-
-#ifdef DEBUG
- ulg bits_sent; /* bit length of the compressed data */
-#endif
-
-/* ===========================================================================
- * Initialize the bit string routines.
- */
-void bi_init (zipfile)
- file_t zipfile; /* output zip file, NO_FILE for in-memory compression */
-{
- zfile = zipfile;
- bi_buf = 0;
- bi_valid = 0;
-#ifdef DEBUG
- bits_sent = 0L;
-#endif
-
- /* Set the defaults for file compression. They are set by memcompress
- * for in-memory compression.
- */
- if (zfile != NO_FILE) {
- read_buf = file_read;
- }
-}
-
-/* ===========================================================================
- * Send a value on a given number of bits.
- * IN assertion: length <= 16 and value fits in length bits.
- */
-void send_bits(value, length)
- int value; /* value to send */
- int length; /* number of bits */
-{
-#ifdef DEBUG
- Tracev((stderr," l %2d v %4x ", length, value));
- Assert(length > 0 && length <= 15, "invalid length");
- bits_sent += (ulg)length;
-#endif
- /* If not enough room in bi_buf, use (valid) bits from bi_buf and
- * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
- * unused bits in value.
- */
- if (bi_valid > (int)Buf_size - length) {
- bi_buf |= (value << bi_valid);
- put_short(bi_buf);
- bi_buf = (ush)value >> (Buf_size - bi_valid);
- bi_valid += length - Buf_size;
- } else {
- bi_buf |= value << bi_valid;
- bi_valid += length;
- }
-}
-
-/* ===========================================================================
- * Reverse the first len bits of a code, using straightforward code (a faster
- * method would use a table)
- * IN assertion: 1 <= len <= 15
- */
-unsigned bi_reverse(code, len)
- unsigned code; /* the value to invert */
- int len; /* its bit length */
-{
- register unsigned res = 0;
- do {
- res |= code & 1;
- code >>= 1, res <<= 1;
- } while (--len > 0);
- return res >> 1;
-}
-
-/* ===========================================================================
- * Write out any remaining bits in an incomplete byte.
- */
-void bi_windup()
-{
- if (bi_valid > 8) {
- put_short(bi_buf);
- } else if (bi_valid > 0) {
- put_byte(bi_buf);
- }
- bi_buf = 0;
- bi_valid = 0;
-#ifdef DEBUG
- bits_sent = (bits_sent+7) & ~7;
-#endif
-}
-
-/* ===========================================================================
- * Copy a stored block to the zip file, storing first the length and its
- * one's complement if requested.
- */
-void copy_block(buf, len, header)
- char *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
-{
- bi_windup(); /* align on byte boundary */
-
- if (header) {
- put_short((ush)len);
- put_short((ush)~len);
-#ifdef DEBUG
- bits_sent += 2*16;
-#endif
- }
-#ifdef DEBUG
- bits_sent += (ulg)len<<3;
-#endif
- while (len--) {
-#ifdef CRYPT
- int t;
- if (key) zencode(*buf, t);
-#endif
- put_byte(*buf++);
- }
-}
diff --git a/gnu/usr.bin/gzip/crypt.c b/gnu/usr.bin/gzip/crypt.c
deleted file mode 100644
index 0233368..0000000
--- a/gnu/usr.bin/gzip/crypt.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* crypt.c (dummy version) -- do not perform encryption
- * Hardly worth copyrighting :-)
- */
-#ifdef RCSID
-static char rcsid[] = "$Id$";
-#endif
diff --git a/gnu/usr.bin/gzip/crypt.h b/gnu/usr.bin/gzip/crypt.h
deleted file mode 100644
index 2a4c203..0000000
--- a/gnu/usr.bin/gzip/crypt.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* crypt.h (dummy version) -- do not perform encryption
- * Hardly worth copyrighting :-)
- */
-
-#ifdef CRYPT
-# undef CRYPT /* dummy version */
-#endif
-
-#define RAND_HEAD_LEN 12 /* length of encryption random header */
-
-#define zencode
-#define zdecode
diff --git a/gnu/usr.bin/gzip/deflate.c b/gnu/usr.bin/gzip/deflate.c
deleted file mode 100644
index a544c35..0000000
--- a/gnu/usr.bin/gzip/deflate.c
+++ /dev/null
@@ -1,763 +0,0 @@
-/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1992-1993 Jean-loup Gailly
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-/*
- * PURPOSE
- *
- * Identify new text as repetitions of old text within a fixed-
- * length sliding window trailing behind the new text.
- *
- * DISCUSSION
- *
- * The "deflation" process depends on being able to identify portions
- * of the input text which are identical to earlier input (within a
- * sliding window trailing behind the input currently being processed).
- *
- * The most straightforward technique turns out to be the fastest for
- * most input files: try all possible matches and select the longest.
- * The key feature of this algorithm is that insertions into the string
- * dictionary are very simple and thus fast, and deletions are avoided
- * completely. Insertions are performed at each input character, whereas
- * string matches are performed only when the previous match ends. So it
- * is preferable to spend more time in matches to allow very fast string
- * insertions and avoid deletions. The matching algorithm for small
- * strings is inspired from that of Rabin & Karp. A brute force approach
- * is used to find longer strings when a small match has been found.
- * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
- * (by Leonid Broukhis).
- * A previous version of this file used a more sophisticated algorithm
- * (by Fiala and Greene) which is guaranteed to run in linear amortized
- * time, but has a larger average cost, uses more memory and is patented.
- * However the F&G algorithm may be faster for some highly redundant
- * files if the parameter max_chain_length (described below) is too large.
- *
- * ACKNOWLEDGEMENTS
- *
- * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
- * I found it in 'freeze' written by Leonid Broukhis.
- * Thanks to many info-zippers for bug reports and testing.
- *
- * REFERENCES
- *
- * APPNOTE.TXT documentation file in PKZIP 1.93a distribution.
- *
- * A description of the Rabin and Karp algorithm is given in the book
- * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
- *
- * Fiala,E.R., and Greene,D.H.
- * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
- *
- * INTERFACE
- *
- * void lm_init (int pack_level, ush *flags)
- * Initialize the "longest match" routines for a new file
- *
- * ulg deflate (void)
- * Processes a new input file and return its compressed length. Sets
- * the compressed length, crc, deflate flags and internal file
- * attributes.
- */
-
-#include <stdio.h>
-
-#include "tailor.h"
-#include "gzip.h"
-#include "lzw.h" /* just for consistency checking */
-
-#ifdef RCSID
-static char rcsid[] = "$Id$";
-#endif
-
-/* ===========================================================================
- * Configuration parameters
- */
-
-/* Compile with MEDIUM_MEM to reduce the memory requirements or
- * with SMALL_MEM to use as little memory as possible. Use BIG_MEM if the
- * entire input file can be held in memory (not possible on 16 bit systems).
- * Warning: defining these symbols affects HASH_BITS (see below) and thus
- * affects the compression ratio. The compressed output
- * is still correct, and might even be smaller in some cases.
- */
-
-#ifdef SMALL_MEM
-# define HASH_BITS 13 /* Number of bits used to hash strings */
-#endif
-#ifdef MEDIUM_MEM
-# define HASH_BITS 14
-#endif
-#ifndef HASH_BITS
-# define HASH_BITS 15
- /* For portability to 16 bit machines, do not use values above 15. */
-#endif
-
-/* To save space (see unlzw.c), we overlay prev+head with tab_prefix and
- * window with tab_suffix. Check that we can do this:
- */
-#if (WSIZE<<1) > (1<<BITS)
- error: cannot overlay window with tab_suffix and prev with tab_prefix0
-#endif
-#if HASH_BITS > BITS-1
- error: cannot overlay head with tab_prefix1
-#endif
-
-#define HASH_SIZE (unsigned)(1<<HASH_BITS)
-#define HASH_MASK (HASH_SIZE-1)
-#define WMASK (WSIZE-1)
-/* HASH_SIZE and WSIZE must be powers of two */
-
-#define NIL 0
-/* Tail of hash chains */
-
-#define FAST 4
-#define SLOW 2
-/* speed options for the general purpose bit flag */
-
-#ifndef TOO_FAR
-# define TOO_FAR 4096
-#endif
-/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
-
-/* ===========================================================================
- * Local data used by the "longest match" routines.
- */
-
-typedef ush Pos;
-typedef unsigned IPos;
-/* A Pos is an index in the character window. We use short instead of int to
- * save space in the various tables. IPos is used only for parameter passing.
- */
-
-/* DECLARE(uch, window, 2L*WSIZE); */
-/* Sliding window. Input bytes are read into the second half of the window,
- * and move to the first half later to keep a dictionary of at least WSIZE
- * bytes. With this organization, matches are limited to a distance of
- * WSIZE-MAX_MATCH bytes, but this ensures that IO is always
- * performed with a length multiple of the block size. Also, it limits
- * the window size to 64K, which is quite useful on MSDOS.
- * To do: limit the window size to WSIZE+BSZ if SMALL_MEM (the code would
- * be less efficient).
- */
-
-/* DECLARE(Pos, prev, WSIZE); */
-/* Link to older string with same hash index. To limit the size of this
- * array to 64K, this link is maintained only for the last 32K strings.
- * An index in this array is thus a window index modulo 32K.
- */
-
-/* DECLARE(Pos, head, 1<<HASH_BITS); */
-/* Heads of the hash chains or NIL. */
-
-ulg window_size = (ulg)2*WSIZE;
-/* window size, 2*WSIZE except for MMAP or BIG_MEM, where it is the
- * input file length plus MIN_LOOKAHEAD.
- */
-
-long block_start;
-/* window position at the beginning of the current output block. Gets
- * negative when the window is moved backwards.
- */
-
-local unsigned ins_h; /* hash index of string to be inserted */
-
-#define H_SHIFT ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH)
-/* Number of bits by which ins_h and del_h must be shifted at each
- * input step. It must be such that after MIN_MATCH steps, the oldest
- * byte no longer takes part in the hash key, that is:
- * H_SHIFT * MIN_MATCH >= HASH_BITS
- */
-
-unsigned int near prev_length;
-/* Length of the best match at previous step. Matches not greater than this
- * are discarded. This is used in the lazy match evaluation.
- */
-
- unsigned near strstart; /* start of string to insert */
- unsigned near match_start; /* start of matching string */
-local int eofile; /* flag set at end of input file */
-local unsigned lookahead; /* number of valid bytes ahead in window */
-
-unsigned near max_chain_length;
-/* To speed up deflation, hash chains are never searched beyond this length.
- * A higher limit improves compression ratio but degrades the speed.
- */
-
-local unsigned int max_lazy_match;
-/* Attempt to find a better match only when the current match is strictly
- * smaller than this value. This mechanism is used only for compression
- * levels >= 4.
- */
-#define max_insert_length max_lazy_match
-/* Insert new strings in the hash table only if the match length
- * is not greater than this length. This saves time but degrades compression.
- * max_insert_length is used only for compression levels <= 3.
- */
-
-local int compr_level;
-/* compression level (1..9) */
-
-unsigned near good_match;
-/* Use a faster search when the previous match is longer than this */
-
-
-/* Values for max_lazy_match, good_match and max_chain_length, depending on
- * the desired pack level (0..9). The values given below have been tuned to
- * exclude worst case performance for pathological files. Better values may be
- * found for specific files.
- */
-
-typedef struct config {
- ush good_length; /* reduce lazy search above this match length */
- ush max_lazy; /* do not perform lazy search above this match length */
- ush nice_length; /* quit search above this match length */
- ush max_chain;
-} config;
-
-#ifdef FULL_SEARCH
-# define nice_match MAX_MATCH
-#else
- int near nice_match; /* Stop searching when current match exceeds this */
-#endif
-
-local config configuration_table[10] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0}, /* store only */
-/* 1 */ {4, 4, 8, 4}, /* maximum speed, no lazy matches */
-/* 2 */ {4, 5, 16, 8},
-/* 3 */ {4, 6, 32, 32},
-
-/* 4 */ {4, 4, 16, 16}, /* lazy matches */
-/* 5 */ {8, 16, 32, 32},
-/* 6 */ {8, 16, 128, 128},
-/* 7 */ {8, 32, 128, 256},
-/* 8 */ {32, 128, 258, 1024},
-/* 9 */ {32, 258, 258, 4096}}; /* maximum compression */
-
-/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
- * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
- * meaning.
- */
-
-#define EQUAL 0
-/* result of memcmp for equal strings */
-
-/* ===========================================================================
- * Prototypes for local functions.
- */
-local void fill_window OF((void));
-local ulg deflate_fast OF((void));
-
- int longest_match OF((IPos cur_match));
-#ifdef ASMV
- void match_init OF((void)); /* asm code initialization */
-#endif
-
-#ifdef DEBUG
-local void check_match OF((IPos start, IPos match, int length));
-#endif
-
-/* ===========================================================================
- * Update a hash value with the given input byte
- * IN assertion: all calls to to UPDATE_HASH are made with consecutive
- * input characters, so that a running hash key can be computed from the
- * previous key instead of complete recalculation each time.
- */
-#define UPDATE_HASH(h,c) (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK)
-
-/* ===========================================================================
- * Insert string s in the dictionary and set match_head to the previous head
- * of the hash chain (the most recent string with same hash key). Return
- * the previous length of the hash chain.
- * IN assertion: all calls to to INSERT_STRING are made with consecutive
- * input characters and the first MIN_MATCH bytes of s are valid
- * (except for the last MIN_MATCH-1 bytes of the input file).
- */
-#define INSERT_STRING(s, match_head) \
- (UPDATE_HASH(ins_h, window[(s) + MIN_MATCH-1]), \
- prev[(s) & WMASK] = match_head = head[ins_h], \
- head[ins_h] = (s))
-
-/* ===========================================================================
- * Initialize the "longest match" routines for a new file
- */
-void lm_init (pack_level, flags)
- int pack_level; /* 0: store, 1: best speed, 9: best compression */
- ush *flags; /* general purpose bit flag */
-{
- register unsigned j;
-
- if (pack_level < 1 || pack_level > 9) error("bad pack level");
- compr_level = pack_level;
-
- /* Initialize the hash table. */
-#if defined(MAXSEG_64K) && HASH_BITS == 15
- for (j = 0; j < HASH_SIZE; j++) head[j] = NIL;
-#else
- memzero((char*)head, HASH_SIZE*sizeof(*head));
-#endif
- /* prev will be initialized on the fly */
-
- /* Set the default configuration parameters:
- */
- max_lazy_match = configuration_table[pack_level].max_lazy;
- good_match = configuration_table[pack_level].good_length;
-#ifndef FULL_SEARCH
- nice_match = configuration_table[pack_level].nice_length;
-#endif
- max_chain_length = configuration_table[pack_level].max_chain;
- if (pack_level == 1) {
- *flags |= FAST;
- } else if (pack_level == 9) {
- *flags |= SLOW;
- }
- /* ??? reduce max_chain_length for binary files */
-
- strstart = 0;
- block_start = 0L;
-#ifdef ASMV
- match_init(); /* initialize the asm code */
-#endif
-
- lookahead = read_buf((char*)window,
- sizeof(int) <= 2 ? (unsigned)WSIZE : 2*WSIZE);
-
- if (lookahead == 0 || lookahead == (unsigned)EOF) {
- eofile = 1, lookahead = 0;
- return;
- }
- eofile = 0;
- /* Make sure that we always have enough lookahead. This is important
- * if input comes from a device such as a tty.
- */
- while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window();
-
- ins_h = 0;
- for (j=0; j<MIN_MATCH-1; j++) UPDATE_HASH(ins_h, window[j]);
- /* If lookahead < MIN_MATCH, ins_h is garbage, but this is
- * not important since only literal bytes will be emitted.
- */
-}
-
-/* ===========================================================================
- * Set match_start to the longest match starting at the given string and
- * return its length. Matches shorter or equal to prev_length are discarded,
- * in which case the result is equal to prev_length and match_start is
- * garbage.
- * IN assertions: cur_match is the head of the hash chain for the current
- * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
- */
-#ifndef ASMV
-/* For MSDOS, OS/2 and 386 Unix, an optimized version is in match.asm or
- * match.s. The code is functionally equivalent, so you can use the C version
- * if desired.
- */
-int longest_match(cur_match)
- IPos cur_match; /* current match */
-{
- unsigned chain_length = max_chain_length; /* max hash chain length */
- register uch *scan = window + strstart; /* current string */
- register uch *match; /* matched string */
- register int len; /* length of current match */
- int best_len = prev_length; /* best match length so far */
- IPos limit = strstart > (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL;
- /* Stop when cur_match becomes <= limit. To simplify the code,
- * we prevent matches with the string of window index 0.
- */
-
-/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
-#if HASH_BITS < 8 || MAX_MATCH != 258
- error: Code too clever
-#endif
-
-#ifdef UNALIGNED_OK
- /* Compare two bytes at a time. Note: this is not always beneficial.
- * Try with and without -DUNALIGNED_OK to check.
- */
- register uch *strend = window + strstart + MAX_MATCH - 1;
- register ush scan_start = *(ush*)scan;
- register ush scan_end = *(ush*)(scan+best_len-1);
-#else
- register uch *strend = window + strstart + MAX_MATCH;
- register uch scan_end1 = scan[best_len-1];
- register uch scan_end = scan[best_len];
-#endif
-
- /* Do not waste too much time if we already have a good match: */
- if (prev_length >= good_match) {
- chain_length >>= 2;
- }
- Assert(strstart <= window_size-MIN_LOOKAHEAD, "insufficient lookahead");
-
- do {
- Assert(cur_match < strstart, "no future");
- match = window + cur_match;
-
- /* Skip to next match if the match length cannot increase
- * or if the match length is less than 2:
- */
-#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
- /* This code assumes sizeof(unsigned short) == 2. Do not use
- * UNALIGNED_OK if your compiler uses a different size.
- */
- if (*(ush*)(match+best_len-1) != scan_end ||
- *(ush*)match != scan_start) continue;
-
- /* It is not necessary to compare scan[2] and match[2] since they are
- * always equal when the other bytes match, given that the hash keys
- * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
- * strstart+3, +5, ... up to strstart+257. We check for insufficient
- * lookahead only every 4th comparison; the 128th check will be made
- * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
- * necessary to put more guard bytes at the end of the window, or
- * to check more often for insufficient lookahead.
- */
- scan++, match++;
- do {
- } while (*(ush*)(scan+=2) == *(ush*)(match+=2) &&
- *(ush*)(scan+=2) == *(ush*)(match+=2) &&
- *(ush*)(scan+=2) == *(ush*)(match+=2) &&
- *(ush*)(scan+=2) == *(ush*)(match+=2) &&
- scan < strend);
- /* The funny "do {}" generates better code on most compilers */
-
- /* Here, scan <= window+strstart+257 */
- Assert(scan <= window+(unsigned)(window_size-1), "wild scan");
- if (*scan == *match) scan++;
-
- len = (MAX_MATCH - 1) - (int)(strend-scan);
- scan = strend - (MAX_MATCH-1);
-
-#else /* UNALIGNED_OK */
-
- if (match[best_len] != scan_end ||
- match[best_len-1] != scan_end1 ||
- *match != *scan ||
- *++match != scan[1]) continue;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match++;
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- len = MAX_MATCH - (int)(strend - scan);
- scan = strend - MAX_MATCH;
-
-#endif /* UNALIGNED_OK */
-
- if (len > best_len) {
- match_start = cur_match;
- best_len = len;
- if (len >= nice_match) break;
-#ifdef UNALIGNED_OK
- scan_end = *(ush*)(scan+best_len-1);
-#else
- scan_end1 = scan[best_len-1];
- scan_end = scan[best_len];
-#endif
- }
- } while ((cur_match = prev[cur_match & WMASK]) > limit
- && --chain_length != 0);
-
- return best_len;
-}
-#endif /* ASMV */
-
-#ifdef DEBUG
-/* ===========================================================================
- * Check that the match at match_start is indeed a match.
- */
-local void check_match(start, match, length)
- IPos start, match;
- int length;
-{
- /* check that the match is indeed a match */
- if (memcmp((char*)window + match,
- (char*)window + start, length) != EQUAL) {
- fprintf(stderr,
- " start %d, match %d, length %d\n",
- start, match, length);
- error("invalid match");
- }
- if (verbose > 1) {
- fprintf(stderr,"\\[%d,%d]", start-match, length);
- do { putc(window[start++], stderr); } while (--length != 0);
- }
-}
-#else
-# define check_match(start, match, length)
-#endif
-
-/* ===========================================================================
- * Fill the window when the lookahead becomes insufficient.
- * Updates strstart and lookahead, and sets eofile if end of input file.
- * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0
- * OUT assertions: at least one byte has been read, or eofile is set;
- * file reads are performed for at least two bytes (required for the
- * translate_eol option).
- */
-local void fill_window()
-{
- register unsigned n, m;
- unsigned more = (unsigned)(window_size - (ulg)lookahead - (ulg)strstart);
- /* Amount of free space at the end of the window. */
-
- /* If the window is almost full and there is insufficient lookahead,
- * move the upper half to the lower one to make room in the upper half.
- */
- if (more == (unsigned)EOF) {
- /* Very unlikely, but possible on 16 bit machine if strstart == 0
- * and lookahead == 1 (input done one byte at time)
- */
- more--;
- } else if (strstart >= WSIZE+MAX_DIST) {
- /* By the IN assertion, the window is not empty so we can't confuse
- * more == 0 with more == 64K on a 16 bit machine.
- */
- Assert(window_size == (ulg)2*WSIZE, "no sliding with BIG_MEM");
-
- memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE);
- match_start -= WSIZE;
- strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */
-
- block_start -= (long) WSIZE;
-
- for (n = 0; n < HASH_SIZE; n++) {
- m = head[n];
- head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
- }
- for (n = 0; n < WSIZE; n++) {
- m = prev[n];
- prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
- /* If n is not on any hash chain, prev[n] is garbage but
- * its value will never be used.
- */
- }
- more += WSIZE;
- }
- /* At this point, more >= 2 */
- if (!eofile) {
- n = read_buf((char*)window+strstart+lookahead, more);
- if (n == 0 || n == (unsigned)EOF) {
- eofile = 1;
- } else {
- lookahead += n;
- }
- }
-}
-
-/* ===========================================================================
- * Flush the current block, with given end-of-file flag.
- * IN assertion: strstart is set to the end of the current match.
- */
-#define FLUSH_BLOCK(eof) \
- flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \
- (char*)NULL, (long)strstart - block_start, (eof))
-
-/* ===========================================================================
- * Processes a new input file and return its compressed length. This
- * function does not perform lazy evaluationof matches and inserts
- * new strings in the dictionary only for unmatched strings or for short
- * matches. It is used only for the fast compression options.
- */
-local ulg deflate_fast()
-{
- IPos hash_head; /* head of the hash chain */
- int flush; /* set if current block must be flushed */
- unsigned match_length = 0; /* length of best match */
-
- prev_length = MIN_MATCH-1;
- while (lookahead != 0) {
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- INSERT_STRING(strstart, hash_head);
-
- /* Find the longest match, discarding those <= prev_length.
- * At this point we have always match_length < MIN_MATCH
- */
- if (hash_head != NIL && strstart - hash_head <= MAX_DIST) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
- match_length = longest_match (hash_head);
- /* longest_match() sets match_start */
- if (match_length > lookahead) match_length = lookahead;
- }
- if (match_length >= MIN_MATCH) {
- check_match(strstart, match_start, match_length);
-
- flush = ct_tally(strstart-match_start, match_length - MIN_MATCH);
-
- lookahead -= match_length;
-
- /* Insert new strings in the hash table only if the match length
- * is not too large. This saves time but degrades compression.
- */
- if (match_length <= max_insert_length) {
- match_length--; /* string at strstart already in hash table */
- do {
- strstart++;
- INSERT_STRING(strstart, hash_head);
- /* strstart never exceeds WSIZE-MAX_MATCH, so there are
- * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH
- * these bytes are garbage, but it does not matter since
- * the next lookahead bytes will be emitted as literals.
- */
- } while (--match_length != 0);
- strstart++;
- } else {
- strstart += match_length;
- match_length = 0;
- ins_h = window[strstart];
- UPDATE_HASH(ins_h, window[strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- }
- } else {
- /* No match, output a literal byte */
- Tracevv((stderr,"%c",window[strstart]));
- flush = ct_tally (0, window[strstart]);
- lookahead--;
- strstart++;
- }
- if (flush) FLUSH_BLOCK(0), block_start = strstart;
-
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window();
-
- }
- return FLUSH_BLOCK(1); /* eof */
-}
-
-/* ===========================================================================
- * Same as above, but achieves better compression. We use a lazy
- * evaluation for matches: a match is finally adopted only if there is
- * no better match at the next window position.
- */
-ulg deflate()
-{
- IPos hash_head; /* head of hash chain */
- IPos prev_match; /* previous match */
- int flush; /* set if current block must be flushed */
- int match_available = 0; /* set if previous match exists */
- register unsigned match_length = MIN_MATCH-1; /* length of best match */
-#ifdef DEBUG
- extern long isize; /* byte length of input file, for debug only */
-#endif
-
- if (compr_level <= 3) return deflate_fast(); /* optimized for speed */
-
- /* Process the input block. */
- while (lookahead != 0) {
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- INSERT_STRING(strstart, hash_head);
-
- /* Find the longest match, discarding those <= prev_length.
- */
- prev_length = match_length, prev_match = match_start;
- match_length = MIN_MATCH-1;
-
- if (hash_head != NIL && prev_length < max_lazy_match &&
- strstart - hash_head <= MAX_DIST) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
- match_length = longest_match (hash_head);
- /* longest_match() sets match_start */
- if (match_length > lookahead) match_length = lookahead;
-
- /* Ignore a length 3 match if it is too distant: */
- if (match_length == MIN_MATCH && strstart-match_start > TOO_FAR){
- /* If prev_match is also MIN_MATCH, match_start is garbage
- * but we will ignore the current match anyway.
- */
- match_length--;
- }
- }
- /* If there was a match at the previous step and the current
- * match is not better, output the previous match:
- */
- if (prev_length >= MIN_MATCH && match_length <= prev_length) {
-
- check_match(strstart-1, prev_match, prev_length);
-
- flush = ct_tally(strstart-1-prev_match, prev_length - MIN_MATCH);
-
- /* Insert in hash table all strings up to the end of the match.
- * strstart-1 and strstart are already inserted.
- */
- lookahead -= prev_length-1;
- prev_length -= 2;
- do {
- strstart++;
- INSERT_STRING(strstart, hash_head);
- /* strstart never exceeds WSIZE-MAX_MATCH, so there are
- * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH
- * these bytes are garbage, but it does not matter since the
- * next lookahead bytes will always be emitted as literals.
- */
- } while (--prev_length != 0);
- match_available = 0;
- match_length = MIN_MATCH-1;
- strstart++;
- if (flush) FLUSH_BLOCK(0), block_start = strstart;
-
- } else if (match_available) {
- /* If there was no match at the previous position, output a
- * single literal. If there was a match but the current match
- * is longer, truncate the previous match to a single literal.
- */
- Tracevv((stderr,"%c",window[strstart-1]));
- if (ct_tally (0, window[strstart-1])) {
- FLUSH_BLOCK(0), block_start = strstart;
- }
- strstart++;
- lookahead--;
- } else {
- /* There is no previous match to compare with, wait for
- * the next step to decide.
- */
- match_available = 1;
- strstart++;
- lookahead--;
- }
- Assert (strstart <= isize && lookahead <= isize, "a bit too far");
-
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window();
- }
- if (match_available) ct_tally (0, window[strstart-1]);
-
- return FLUSH_BLOCK(1); /* eof */
-}
diff --git a/gnu/usr.bin/gzip/getopt.c b/gnu/usr.bin/gzip/getopt.c
deleted file mode 100644
index 55fad84..0000000
--- a/gnu/usr.bin/gzip/getopt.c
+++ /dev/null
@@ -1,755 +0,0 @@
-/* Getopt for GNU.
- NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
- before changing it!
-
- Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
- 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifndef __STDC__
-# ifndef const
-# define const
-# endif
-#endif
-
-/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
-#ifndef _NO_PROTO
-#define _NO_PROTO
-#endif
-
-#include <stdio.h>
-#include "tailor.h"
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-/* Don't include stdlib.h for non-GNU C libraries because some of them
- contain conflicting prototypes for getopt. */
-#include <stdlib.h>
-#endif /* GNU C library. */
-
-/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
- long-named option. Because this is not POSIX.2 compliant, it is
- being phased out. */
-/* #define GETOPT_COMPAT */
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- to intersperse the options with the other arguments.
-
- As `getopt' works, it permutes the elements of ARGV so that,
- when it is done, all the options precede everything else. Thus
- all application programs are extended to handle flexible argument order.
-
- Setting the environment variable POSIXLY_CORRECT disables permutation.
- Then the behavior is completely standard.
-
- GNU application programs can use a third alternative mode in which
- they can distinguish the relative order of options and other arguments. */
-
-#include "getopt.h"
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-char *optarg = 0;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-/* XXX 1003.2 says this must be 1 before any call. */
-int optind = 0;
-
-/* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
-static char *nextchar;
-
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-#define BAD_OPTION '\0'
-int optopt = BAD_OPTION;
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
- If the caller did not specify anything,
- the default is REQUIRE_ORDER if the environment variable
- POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
- REQUIRE_ORDER means don't recognize them as options;
- stop option processing when the first non-option is seen.
- This is what Unix does.
- This mode of operation is selected by either setting the environment
- variable POSIXLY_CORRECT, or using `+' as the first character
- of the list of option characters.
-
- PERMUTE is the default. We permute the contents of ARGV as we scan,
- so that eventually all the non-options are at the end. This allows options
- to be given in any order, even with programs that were not written to
- expect this.
-
- RETURN_IN_ORDER is an option available to programs that were written
- to expect options and other ARGV-elements in any order and that care about
- the ordering of the two. We describe each non-option ARGV-element
- as if it were the argument of an option with character code 1.
- Using `-' as the first character of the list of option characters
- selects this mode of operation.
-
- The special argument `--' forces an end of option-scanning regardless
- of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return EOF with `optind' != ARGC. */
-
-static enum
-{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-#ifdef __GNU_LIBRARY__
-/* We want to avoid inclusion of string.h with non-GNU libraries
- because there are many ways it can cause trouble.
- On some systems, it contains special magic macros that don't work
- in GCC. */
-#include <string.h>
-#define my_index strchr
-#define my_strlen strlen
-#else
-
-/* Avoid depending on library functions or files
- whose names are inconsistent. */
-
-#if __STDC__ || defined(PROTO)
-extern char *getenv(const char *name);
-extern int strcmp (const char *s1, const char *s2);
-extern int strncmp(const char *s1, const char *s2, int n);
-
-static int my_strlen(const char *s);
-static char *my_index (const char *str, int chr);
-#else
-extern char *getenv ();
-#endif
-
-static int
-my_strlen (str)
- const char *str;
-{
- int n = 0;
- while (*str++)
- n++;
- return n;
-}
-
-static char *
-my_index (str, chr)
- const char *str;
- int chr;
-{
- while (*str)
- {
- if (*str == chr)
- return (char *) str;
- str++;
- }
- return 0;
-}
-
-#endif /* GNU C library. */
-
-/* Handle permutation of arguments. */
-
-/* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
-static int first_nonopt;
-static int last_nonopt;
-
-/* Exchange two adjacent subsequences of ARGV.
- One subsequence is elements [first_nonopt,last_nonopt)
- which contains all the non-options that have been skipped so far.
- The other is elements [last_nonopt,optind), which contains all
- the options processed since those non-options were skipped.
-
- `first_nonopt' and `last_nonopt' are relocated so that they describe
- the new indices of the non-options in ARGV after they are moved.
-
- To perform the swap, we first reverse the order of all elements. So
- all options now come before all non options, but they are in the
- wrong order. So we put back the options and non options in original
- order by reversing them again. For example:
- original input: a b c -x -y
- reverse all: -y -x c b a
- reverse options: -x -y c b a
- reverse non options: -x -y a b c
-*/
-
-#if __STDC__ || defined(PROTO)
-static void exchange (char **argv);
-#endif
-
-static void
-exchange (argv)
- char **argv;
-{
- char *temp, **first, **last;
-
- /* Reverse all the elements [first_nonopt, optind) */
- first = &argv[first_nonopt];
- last = &argv[optind-1];
- while (first < last) {
- temp = *first; *first = *last; *last = temp; first++; last--;
- }
- /* Put back the options in order */
- first = &argv[first_nonopt];
- first_nonopt += (optind - last_nonopt);
- last = &argv[first_nonopt - 1];
- while (first < last) {
- temp = *first; *first = *last; *last = temp; first++; last--;
- }
-
- /* Put back the non options in order */
- first = &argv[first_nonopt];
- last_nonopt = optind;
- last = &argv[last_nonopt-1];
- while (first < last) {
- temp = *first; *first = *last; *last = temp; first++; last--;
- }
-}
-
-/* Scan elements of ARGV (whose length is ARGC) for option characters
- given in OPTSTRING.
-
- If an element of ARGV starts with '-', and is not exactly "-" or "--",
- then it is an option element. The characters of this element
- (aside from the initial '-') are option characters. If `getopt'
- is called repeatedly, it returns successively each of the option characters
- from each of the option elements.
-
- If `getopt' finds another option character, it returns that character,
- updating `optind' and `nextchar' so that the next call to `getopt' can
- resume the scan with the following option character or ARGV-element.
-
- If there are no more option characters, `getopt' returns `EOF'.
- Then `optind' is the index in ARGV of the first ARGV-element
- that is not an option. (The ARGV-elements have been permuted
- so that those that are not options now come last.)
-
- OPTSTRING is a string containing the legitimate option characters.
- If an option character is seen that is not listed in OPTSTRING,
- return BAD_OPTION after printing an error message. If you set `opterr' to
- zero, the error message is suppressed but we still return BAD_OPTION.
-
- If a char in OPTSTRING is followed by a colon, that means it wants an arg,
- so the following text in the same ARGV-element, or the text of the following
- ARGV-element, is returned in `optarg'. Two colons mean an option that
- wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `optarg', otherwise `optarg' is set to zero.
-
- If OPTSTRING starts with `-' or `+', it requests different methods of
- handling the non-option ARGV-elements.
- See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
-
- Long-named options begin with `--' instead of `-'.
- Their names may be abbreviated as long as the abbreviation is unique
- or is an exact match for some defined option. If they have an
- argument, it follows the option name in the same ARGV-element, separated
- from the option name by a `=', or else the in next ARGV-element.
- When `getopt' finds a long-named option, it returns 0 if that option's
- `flag' field is nonzero, the value of the option's `val' field
- if the `flag' field is zero.
-
- The elements of ARGV aren't really const, because we permute them.
- But we pretend they're const in the prototype to be compatible
- with other systems.
-
- LONGOPTS is a vector of `struct option' terminated by an
- element containing a name which is zero.
-
- LONGIND returns the index in LONGOPT of the long-named option found.
- It is only valid when a long-named option has been found by the most
- recent call.
-
- If LONG_ONLY is nonzero, '-' as well as '--' can introduce
- long-named options. */
-
-int
-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
- int argc;
- char *const *argv;
- const char *optstring;
- const struct option *longopts;
- int *longind;
- int long_only;
-{
- int option_index;
-
- optarg = 0;
-
- /* Initialize the internal data when the first call is made.
- Start processing options with ARGV-element 1 (since ARGV-element 0
- is the program name); the sequence of previously skipped
- non-option ARGV-elements is empty. */
-
- if (optind == 0)
- {
- first_nonopt = last_nonopt = optind = 1;
-
- nextchar = NULL;
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-')
- {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- }
- else if (optstring[0] == '+')
- {
- ordering = REQUIRE_ORDER;
- ++optstring;
- }
- else if (getenv ("POSIXLY_CORRECT") != NULL)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
- }
-
- if (nextchar == NULL || *nextchar == '\0')
- {
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Now skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < argc
- && (argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- optind++;
- last_nonopt = optind;
- }
-
- /* Special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp (argv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return EOF;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- {
- if (ordering == REQUIRE_ORDER)
- return EOF;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- Start decoding its characters. */
-
- nextchar = (argv[optind] + 1
- + (longopts != NULL && argv[optind][1] == '-'));
- }
-
- if (longopts != NULL
- && ((argv[optind][0] == '-'
- && (argv[optind][1] == '-' || long_only))
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- ))
- {
- const struct option *p;
- char *s = nextchar;
- int exact = 0;
- int ambig = 0;
- const struct option *pfound = NULL;
- int indfound = 0;
-
- while (*s && *s != '=')
- s++;
-
- /* Test all options for either exact match or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name;
- p++, option_index++)
- if (!strncmp (p->name, nextchar, s - nextchar))
- {
- if (s - nextchar == my_strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' is ambiguous\n",
- argv[0], argv[optind]);
- nextchar += my_strlen (nextchar);
- optind++;
- return BAD_OPTION;
- }
-
- if (pfound != NULL)
- {
- option_index = indfound;
- optind++;
- if (*s)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = s + 1;
- else
- {
- if (opterr)
- {
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- "%s: option `--%s' doesn't allow an argument\n",
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- "%s: option `%c%s' doesn't allow an argument\n",
- argv[0], argv[optind - 1][0], pfound->name);
- }
- nextchar += my_strlen (nextchar);
- return BAD_OPTION;
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' requires an argument\n",
- argv[0], argv[optind - 1]);
- nextchar += my_strlen (nextchar);
- return optstring[0] == ':' ? ':' : BAD_OPTION;
- }
- }
- nextchar += my_strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- /* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- || my_index (optstring, *nextchar) == NULL)
- {
- if (opterr)
- {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf (stderr, "%s: unrecognized option `--%s'\n",
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf (stderr, "%s: unrecognized option `%c%s'\n",
- argv[0], argv[optind][0], nextchar);
- }
- nextchar = (char *) "";
- optind++;
- return BAD_OPTION;
- }
- }
-
- /* Look at and handle the next option-character. */
-
- {
- char c = *nextchar++;
- char *temp = my_index (optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == '\0')
- ++optind;
-
- if (temp == NULL || c == ':')
- {
- if (opterr)
- {
-#if 0
- if (c < 040 || c >= 0177)
- fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
- argv[0], c);
- else
- fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
-#else
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
-#endif
- }
- optopt = c;
- return BAD_OPTION;
- }
- if (temp[1] == ':')
- {
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = 0;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
-#if 0
- fprintf (stderr, "%s: option `-%c' requires an argument\n",
- argv[0], c);
-#else
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, "%s: option requires an argument -- %c\n",
- argv[0], c);
-#endif
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = BAD_OPTION;
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
- }
- return c;
- }
-}
-
-int
-getopt (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
-{
- return _getopt_internal (argc, argv, optstring,
- (const struct option *) 0,
- (int *) 0,
- 0);
-}
-
-int
-getopt_long (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
-}
-
-#endif /* _LIBC or not __GNU_LIBRARY__. */
-
-#ifdef TEST
-
-/* Compile with -DTEST to make an executable for use in testing
- the above definition of `getopt'. */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
-
- c = getopt (argc, argv, "abc:d:0123456789");
- if (c == EOF)
- break;
-
- switch (c)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case BAD_OPTION:
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/usr.bin/gzip/getopt.h b/gnu/usr.bin/gzip/getopt.h
deleted file mode 100644
index 0abce6e..0000000
--- a/gnu/usr.bin/gzip/getopt.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Declarations for getopt.
- Copyright (C) 1989, 1990, 1991, 1992, 1993 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef _GETOPT_H
-#define _GETOPT_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
-extern int opterr;
-
-/* Set to an option character which was unrecognized. */
-
-extern int optopt;
-
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
-struct option
-{
-#if __STDC__
- const char *name;
-#else
- char *name;
-#endif
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'. */
-
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
-
-#if __STDC__ || defined(PROTO)
-#if defined(__GNU_LIBRARY__)
-/* Many other libraries have conflicting prototypes for getopt, with
- differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
-extern int getopt (int argc, char *const *argv, const char *shortopts);
-#endif /* not __GNU_LIBRARY__ */
-extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-extern int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
-
-/* Internal only. Users should not call this directly. */
-extern int _getopt_internal (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
-#else /* not __STDC__ */
-extern int getopt ();
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-#endif /* not __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GETOPT_H */
diff --git a/gnu/usr.bin/gzip/gzexe b/gnu/usr.bin/gzip/gzexe
deleted file mode 100644
index 27b697b..0000000
--- a/gnu/usr.bin/gzip/gzexe
+++ /dev/null
@@ -1,150 +0,0 @@
-#!/bin/sh
-# gzexe: compressor for Unix executables.
-# Use this only for binaries that you do not use frequently.
-#
-# The compressed version is a shell script which decompresses itself after
-# skipping $skip lines of shell commands. We try invoking the compressed
-# executable with the original name (for programs looking at their name).
-# We also try to retain the original file permissions on the compressed file.
-# For safety reasons, gzexe will not create setuid or setgid shell scripts.
-
-# WARNING: the first line of this file must be either : or #!/bin/sh
-# The : is required for some old versions of csh.
-# On Ultrix, /bin/sh is too buggy, change the first line to: #!/bin/sh5
-
-x=`basename $0`
-if test $# = 0; then
- echo compress executables. original file foo is renamed to foo~
- echo usage: ${x} [-d] files...
- echo " -d decompress the executables"
- exit 1
-fi
-
-tmp=gz$$
-trap "rm -f $tmp; exit 1" 1 2 3 5 10 13 15
-
-decomp=0
-res=0
-test "$x" = "ungzexe" && decomp=1
-if test "x$1" = "x-d"; then
- decomp=1
- shift
-fi
-
-echo hi > zfoo1$$
-echo hi > zfoo2$$
-if test -z "`(${CPMOD-cpmod} zfoo1$$ zfoo2$$) 2>&1`"; then
- cpmod=${CPMOD-cpmod}
-fi
-rm -f zfoo[12]$$
-
-tail=""
-IFS="${IFS= }"; saveifs="$IFS"; IFS="${IFS}:"
-for dir in $PATH; do
- test -z "$dir" && dir=.
- if test -f $dir/tail; then
- tail="$dir/tail"
- break
- fi
-done
-IFS="$saveifs"
-if test -z "$tail"; then
- echo cannot find tail
- exit 1
-fi
-
-for i do
- if test ! -f "$i" ; then
- echo ${x}: $i not a file
- res=1
- continue
- fi
- if test $decomp -eq 0; then
- if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then
- echo "${x}: $i is already gzexe'd"
- continue
- fi
- fi
- if ls -l "$i" | grep '^...[sS]' > /dev/null; then
- echo "${x}: $i has setuid permission, unchanged"
- continue
- fi
- if ls -l "$i" | grep '^......[sS]' > /dev/null; then
- echo "${x}: $i has setgid permission, unchanged"
- continue
- fi
- case "`basename $i`" in
- sh | gzip | tail | chmod | ln | sleep | rm)
- echo "${x}: $i would depend on itself"; continue ;;
- esac
- if test -z "$cpmod"; then
- cp -p "$i" $tmp 2>/dev/null || cp "$i" $tmp
- if test -w $tmp 2>/dev/null; then
- writable=1
- else
- writable=0
- chmod u+w $tmp 2>/dev/null
- fi
- fi
- if test $decomp -eq 0; then
- sed 1q $0 > $tmp
- sed "s|^if tail|if $tail|" >> $tmp <<'EOF'
-skip=18
-if tail +$skip $0 | gzip -cd > /tmp/gztmp$$; then
- chmod 700 /tmp/gztmp$$
- prog="`echo $0 | sed 's|^.*/||'`"
- if /bin/ln /tmp/gztmp$$ "/tmp/$prog" 2>/dev/null; then
- trap '/bin/rm -f /tmp/gztmp$$ "/tmp/$prog"; exit $res' 0
- (/bin/sleep 5; /bin/rm -f /tmp/gztmp$$ "/tmp/$prog") 2>/dev/null &
- /tmp/"$prog" ${1+"$@"}; res=$?
- else
- trap '/bin/rm -f /tmp/gztmp$$; exit $res' 0
- (/bin/sleep 5; /bin/rm -f /tmp/gztmp$$) 2>/dev/null &
- /tmp/gztmp$$ ${1+"$@"}; res=$?
- fi
-else
- echo Cannot decompress $0; exit 1
-fi; exit $res
-EOF
- gzip -cv9 "$i" >> $tmp || {
- /bin/rm -f $tmp
- echo ${x}: compression not possible for $i, file unchanged.
- res=1
- continue
- }
-
- else
- # decompression
- skip=18
- if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then
- eval `sed -e 1d -e 2q "$i"`
- fi
- if tail +$skip "$i" | gzip -cd > $tmp; then
- :
- else
- echo ${x}: $i probably not in gzexe format, file unchanged.
- res=1
- continue
- fi
- fi
- rm -f "$i~"
- mv "$i" "$i~" || {
- echo ${x}: cannot backup $i as $i~
- rm -f $tmp
- res=1
- continue
- }
- mv $tmp "$i" || cp -p $tmp "$i" 2>/dev/null || cp $tmp "$i" || {
- echo ${x}: cannot create $i
- rm -f $tmp
- res=1
- continue
- }
- rm -f $tmp
- if test -n "$cpmod"; then
- $cpmod "$i~" "$i" 2>/dev/null
- elif test $writable -eq 0; then
- chmod u-w $i 2>/dev/null
- fi
-done
-exit $res
diff --git a/gnu/usr.bin/gzip/gzexe.1 b/gnu/usr.bin/gzip/gzexe.1
deleted file mode 100644
index 8b62cd6..0000000
--- a/gnu/usr.bin/gzip/gzexe.1
+++ /dev/null
@@ -1,43 +0,0 @@
-.TH GZEXE 1
-.SH NAME
-gzexe \- compress executable files in place
-.SH SYNOPSIS
-.B gzexe
-[ name ... ]
-.SH DESCRIPTION
-The
-.I gzexe
-utility allows you to compress executables in place and have them
-automatically uncompress and execute when you run them (at a penalty
-in performance). For example if you execute ``gzexe /bin/cat'' it
-will create the following two files:
-.nf
-.br
- -r-xr-xr-x 1 root bin 9644 Feb 11 11:16 /bin/cat
- -r-xr-xr-x 1 bin bin 24576 Nov 23 13:21 /bin/cat~
-.fi
-/bin/cat~ is the original file and /bin/cat is the self-uncompressing
-executable file. You can remove /bin/cat~ once you are sure that
-/bin/cat works properly.
-.PP
-This utility is most useful on systems with very small disks.
-.SH OPTIONS
-.TP
-.B \-d
-Decompress the given executables instead of compressing them.
-.SH "SEE ALSO"
-gzip(1), znew(1), zmore(1), zcmp(1), zforce(1)
-.SH CAVEATS
-The compressed executable is a shell script. This may create some
-security holes. In particular, the compressed executable relies
-on the PATH environment variable to find
-.I gzip
-and some other utilities
-.I (tail, chmod, ln, sleep).
-.SH "BUGS"
-.I gzexe
-attempts to retain the original file attributes on the compressed executable,
-but you may have to fix them manually in some cases, using
-.I chmod
-or
-.I chown.
diff --git a/gnu/usr.bin/gzip/gzip.1 b/gnu/usr.bin/gzip/gzip.1
deleted file mode 100644
index 2d1e1a4..0000000
--- a/gnu/usr.bin/gzip/gzip.1
+++ /dev/null
@@ -1,477 +0,0 @@
-.PU
-.TH GZIP 1
-.SH NAME
-gzip, gunzip, zcat \- compress or expand files
-.SH SYNOPSIS
-.ll +8
-.B gzip
-.RB [ " \-acdfhlLnNrtvV19 " ]
-.RB [ \-S\ suffix ]
-[
-.I "name \&..."
-]
-.ll -8
-.br
-.B gunzip
-.RB [ " \-acfhlLnNrtvV " ]
-.RB [ \-S\ suffix ]
-[
-.I "name \&..."
-]
-.br
-.B zcat
-.RB [ " \-fhLV " ]
-[
-.I "name \&..."
-]
-.SH DESCRIPTION
-.I Gzip
-reduces the size of the named files using Lempel-Ziv coding (LZ77).
-Whenever possible,
-each file is replaced by one with the extension
-.B "\&.gz,"
-while keeping the same ownership modes, access and modification times.
-(The default extension is
-.B "\-gz"
-for VMS,
-.B "z"
-for MSDOS, OS/2 FAT, Windows NT FAT and Atari.)
-If no files are specified, or if a file name is "-", the standard input is
-compressed to the standard output.
-.I Gzip
-will only attempt to compress regular files.
-In particular, it will ignore symbolic links.
-.PP
-If the compressed file name is too long for its file system,
-.I gzip
-truncates it.
-.I Gzip
-attempts to truncate only the parts of the file name longer than 3 characters.
-(A part is delimited by dots.) If the name consists of small parts only,
-the longest parts are truncated. For example, if file names are limited
-to 14 characters, gzip.msdos.exe is compressed to gzi.msd.exe.gz.
-Names are not truncated on systems which do not have a limit on file name
-length.
-.PP
-By default,
-.I gzip
-keeps the original file name and timestamp in the compressed file. These
-are used when decompressing the file with the
-.B \-N
-option. This is useful when the compressed file name was truncated or
-when the time stamp was not preserved after a file transfer.
-.PP
-Compressed files can be restored to their original form using
-.I gzip -d
-or
-.I gunzip
-or
-.I zcat.
-If the original name saved in the compressed file is not suitable for its
-file system, a new name is constructed from the original one to make it
-legal.
-.PP
-.I gunzip
-takes a list of files on its command line and replaces each
-file whose name ends with .gz, -gz, .z, -z, _z or .Z
-and which begins with the correct magic number with an uncompressed
-file without the original extension.
-.I gunzip
-also recognizes the special extensions
-.B "\&.tgz"
-and
-.B "\&.taz"
-as shorthands for
-.B "\&.tar.gz"
-and
-.B "\&.tar.Z"
-respectively.
-When compressing,
-.I gzip
-uses the
-.B "\&.tgz"
-extension if necessary instead of truncating a file with a
-.B "\&.tar"
-extension.
-.PP
-.I gunzip
-can currently decompress files created by
-.I gzip, zip, compress, compress -H
-or
-.I pack.
-The detection of the input format is automatic. When using
-the first two formats,
-.I gunzip
-checks a 32 bit CRC. For
-.I pack, gunzip
-checks the uncompressed length. The standard
-.I compress
-format was not designed to allow consistency checks. However
-.I gunzip
-is sometimes able to detect a bad .Z file. If you get an error
-when uncompressing a .Z file, do not assume that the .Z file is
-correct simply because the standard
-.I uncompress
-does not complain. This generally means that the standard
-.I uncompress
-does not check its input, and happily generates garbage output.
-The SCO compress -H format (lzh compression method) does not include a CRC
-but also allows some consistency checks.
-.PP
-Files created by
-.I zip
-can be uncompressed by gzip only if they have a single member compressed
-with the 'deflation' method. This feature is only intended to help
-conversion of tar.zip files to the tar.gz format. To extract zip files
-with several members, use
-.I unzip
-instead of
-.I gunzip.
-.PP
-.I zcat
-is identical to
-.I gunzip
-.B \-c.
-(On some systems,
-.I zcat
-may be installed as
-.I gzcat
-to preserve the original link to
-.I compress.)
-.I zcat
-uncompresses either a list of files on the command line or its
-standard input and writes the uncompressed data on standard output.
-.I zcat
-will uncompress files that have the correct magic number whether
-they have a
-.B "\&.gz"
-suffix or not.
-.PP
-.I Gzip
-uses the Lempel-Ziv algorithm used in
-.I zip
-and PKZIP.
-The amount of compression obtained depends on the size of the
-input and the distribution of common substrings.
-Typically, text such as source code or English
-is reduced by 60\-70%.
-Compression is generally much better than that achieved by
-LZW (as used in
-.IR compress ),
-Huffman coding (as used in
-.IR pack ),
-or adaptive Huffman coding
-.RI ( compact ).
-.PP
-Compression is always performed, even if the compressed file is
-slightly larger than the original. The worst case expansion is
-a few bytes for the gzip file header, plus 5 bytes every 32K block,
-or an expansion ratio of 0.015% for large files. Note that the actual
-number of used disk blocks almost never increases.
-.I gzip
-preserves the mode, ownership and timestamps of files when compressing
-or decompressing.
-
-.SH OPTIONS
-.TP
-.B \-a --ascii
-Ascii text mode: convert end-of-lines using local conventions. This option
-is supported only on some non-Unix systems. For MSDOS, CR LF is converted
-to LF when compressing, and LF is converted to CR LF when decompressing.
-.TP
-.B \-c --stdout --to-stdout
-Write output on standard output; keep original files unchanged.
-If there are several input files, the output consists of a sequence of
-independently compressed members. To obtain better compression,
-concatenate all input files before compressing them.
-.TP
-.B \-d --decompress --uncompress
-Decompress.
-.TP
-.B \-f --force
-Force compression or decompression even if the file has multiple links
-or the corresponding file already exists, or if the compressed data
-is read from or written to a terminal. If the input data is not in
-a format recognized by
-.I gzip,
-and if the option --stdout is also given, copy the input data without change
-to the standard output: let
-.I zcat
-behave as
-.I cat.
-If
-.B \-f
-is not given,
-and when not running in the background,
-.I gzip
-prompts to verify whether an existing file should be overwritten.
-.TP
-.B \-h --help
-Display a help screen and quit.
-.TP
-.B \-l --list
-For each compressed file, list the following fields:
-
- compressed size: size of the compressed file
- uncompressed size: size of the uncompressed file
- ratio: compression ratio (0.0% if unknown)
- uncompressed_name: name of the uncompressed file
-
-The uncompressed size is given as -1 for files not in gzip format,
-such as compressed .Z files. To get the uncompressed size for such a file,
-you can use:
-
- zcat file.Z | wc -c
-
-In combination with the --verbose option, the following fields are also
-displayed:
-
- method: compression method
- crc: the 32-bit CRC of the uncompressed data
- date & time: time stamp for the uncompressed file
-
-The compression methods currently supported are deflate, compress, lzh
-(SCO compress -H) and pack. The crc is given as ffffffff for a file
-not in gzip format.
-
-With --name, the uncompressed name, date and time are
-those stored within the compress file if present.
-
-With --verbose, the size totals and compression ratio for all files
-is also displayed, unless some sizes are unknown. With --quiet,
-the title and totals lines are not displayed.
-.TP
-.B \-L --license
-Display the
-.I gzip
-license and quit.
-.TP
-.B \-n --no-name
-When compressing, do not save the original file name and time stamp by
-default. (The original name is always saved if the name had to be
-truncated.) When decompressing, do not restore the original file name
-if present (remove only the
-.I gzip
-suffix from the compressed file name) and do not restore the original
-time stamp if present (copy it from the compressed file). This option
-is the default when decompressing.
-.TP
-.B \-N --name
-When compressing, always save the original file name and time stamp; this
-is the default. When decompressing, restore the original file name and
-time stamp if present. This option is useful on systems which have
-a limit on file name length or when the time stamp has been lost after
-a file transfer.
-.TP
-.B \-q --quiet
-Suppress all warnings.
-.TP
-.B \-r --recursive
-Travel the directory structure recursively. If any of the file names
-specified on the command line are directories,
-.I gzip
-will descend into the directory and compress all the files it finds there
-(or decompress them in the case of
-.I gunzip
-).
-.TP
-.B \-S .suf --suffix .suf
-Use suffix .suf instead of .gz. Any suffix can be given, but suffixes
-other than .z and .gz should be avoided to avoid confusion when files
-are transferred to other systems. A null suffix forces gunzip to try
-decompression on all given files regardless of suffix, as in:
-
- gunzip -S "" * (*.* for MSDOS)
-
-Previous versions of gzip used
-the .z suffix. This was changed to avoid a conflict with
-.IR pack "(1)".
-.TP
-.B \-t --test
-Test. Check the compressed file integrity.
-.TP
-.B \-v --verbose
-Verbose. Display the name and percentage reduction for each file compressed
-or decompressed.
-.TP
-.B \-V --version
-Version. Display the version number and compilation options then quit.
-.TP
-.B \-# --fast --best
-Regulate the speed of compression using the specified digit
-.IR # ,
-where
-.B \-1
-or
-.B \-\-fast
-indicates the fastest compression method (less compression)
-and
-.B \-9
-or
-.B \-\-best
-indicates the slowest compression method (best compression).
-The default compression level is
-.BR \-6
-(that is, biased towards high compression at expense of speed).
-.SH "ADVANCED USAGE"
-Multiple compressed files can be concatenated. In this case,
-.I gunzip
-will extract all members at once. For example:
-
- gzip -c file1 > foo.gz
- gzip -c file2 >> foo.gz
-
-Then
- gunzip -c foo
-
-is equivalent to
-
- cat file1 file2
-
-In case of damage to one member of a .gz file, other members can
-still be recovered (if the damaged member is removed). However,
-you can get better compression by compressing all members at once:
-
- cat file1 file2 | gzip > foo.gz
-
-compresses better than
-
- gzip -c file1 file2 > foo.gz
-
-If you want to recompress concatenated files to get better compression, do:
-
- gzip -cd old.gz | gzip > new.gz
-
-If a compressed file consists of several members, the uncompressed
-size and CRC reported by the --list option applies to the last member
-only. If you need the uncompressed size for all members, you can use:
-
- gzip -cd file.gz | wc -c
-
-If you wish to create a single archive file with multiple members so
-that members can later be extracted independently, use an archiver
-such as tar or zip. GNU tar supports the -z option to invoke gzip
-transparently. gzip is designed as a complement to tar, not as a
-replacement.
-.SH "ENVIRONMENT"
-The environment variable
-.B GZIP
-can hold a set of default options for
-.I gzip.
-These options are interpreted first and can be overwritten by
-explicit command line parameters. For example:
- for sh: GZIP="-8v --name"; export GZIP
- for csh: setenv GZIP "-8v --name"
- for MSDOS: set GZIP=-8v --name
-
-On Vax/VMS, the name of the environment variable is GZIP_OPT, to
-avoid a conflict with the symbol set for invocation of the program.
-.SH "SEE ALSO"
-znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), compress(1)
-.SH "DIAGNOSTICS"
-Exit status is normally 0;
-if an error occurs, exit status is 1. If a warning occurs, exit status is 2.
-.PP
-Usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
-.in +8
-Invalid options were specified on the command line.
-.in -8
-.IR file :
-not in gzip format
-.in +8
-The file specified to
-.I gunzip
-has not been compressed.
-.in -8
-.IR file:
-Corrupt input. Use zcat to recover some data.
-.in +8
-The compressed file has been damaged. The data up to the point of failure
-can be recovered using
-.in +8
-zcat file > recover
-.in -16
-.IR file :
-compressed with
-.I xx
-bits, can only handle
-.I yy
-bits
-.in +8
-.I File
-was compressed (using LZW) by a program that could deal with
-more
-.I bits
-than the decompress code on this machine.
-Recompress the file with gzip, which compresses better and uses
-less memory.
-.in -8
-.IR file :
-already has .gz suffix -- no change
-.in +8
-The file is assumed to be already compressed.
-Rename the file and try again.
-.in -8
-.I file
-already exists; do you wish to overwrite (y or n)?
-.in +8
-Respond "y" if you want the output file to be replaced; "n" if not.
-.in -8
-gunzip: corrupt input
-.in +8
-A SIGSEGV violation was detected which usually means that the input file has
-been corrupted.
-.in -8
-.I "xx.x%"
-.in +8
-Percentage of the input saved by compression.
-(Relevant only for
-.BR \-v
-and
-.BR \-l \.)
-.in -8
--- not a regular file or directory: ignored
-.in +8
-When the input file is not a regular file or directory,
-(e.g. a symbolic link, socket, FIFO, device file), it is
-left unaltered.
-.in -8
--- has
-.I xx
-other links: unchanged
-.in +8
-The input file has links; it is left unchanged. See
-.IR ln "(1)"
-for more information. Use the
-.B \-f
-flag to force compression of multiply-linked files.
-.in -8
-.SH CAVEATS
-When writing compressed data to a tape, it is generally necessary to
-pad the output with zeroes up to a block boundary. When the data is
-read and the whole block is passed to
-.I gunzip
-for decompression,
-.I gunzip
-detects that there is extra trailing garbage after the compressed data
-and emits a warning by default. You have to use the --quiet option to
-suppress the warning. This option can be set in the
-.B GZIP
-environment variable as in:
- for sh: GZIP="-q" tar -xfz --block-compress /dev/rst0
- for csh: (setenv GZIP -q; tar -xfz --block-compr /dev/rst0
-
-In the above example, gzip is invoked implicitly by the -z option of
-GNU tar. Make sure that the same block size (-b option of tar) is used
-for reading and writing compressed data on tapes. (This example
-assumes you are using the GNU version of tar.)
-.SH BUGS
-The --list option reports incorrect sizes if they exceed 2 gigabytes.
-The --list option reports sizes as -1 and crc as ffffffff if the
-compressed file is on a non seekable media.
-
-In some rare cases, the --best option gives worse compression than
-the default compression level (-6). On some highly redundant files,
-.I compress
-compresses better than
-.I gzip.
diff --git a/gnu/usr.bin/gzip/gzip.c b/gnu/usr.bin/gzip/gzip.c
deleted file mode 100644
index 7a666ba..0000000
--- a/gnu/usr.bin/gzip/gzip.c
+++ /dev/null
@@ -1,1749 +0,0 @@
-/* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
- * Copyright (C) 1992-1993 Jean-loup Gailly
- * The unzip code was written and put in the public domain by Mark Adler.
- * Portions of the lzw code are derived from the public domain 'compress'
- * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
- * Ken Turkowski, Dave Mack and Peter Jannesen.
- *
- * See the license_msg below and the file COPYING for the software license.
- * See the file algorithm.doc for the compression algorithms and file formats.
- */
-
-static char *license_msg[] = {
-" Copyright (C) 1992-1993 Jean-loup Gailly",
-" 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.",
-0};
-
-/* Compress files with zip algorithm and 'compress' interface.
- * See usage() and help() functions below for all options.
- * Outputs:
- * file.gz: compressed file with same mode, owner, and utimes
- * or stdout with -c option or if stdin used as input.
- * If the output file name had to be truncated, the original name is kept
- * in the compressed file.
- * On MSDOS, file.tmp -> file.tmz. On VMS, file.tmp -> file.tmp-gz.
- *
- * Using gz on MSDOS would create too many file name conflicts. For
- * example, foo.txt -> foo.tgz (.tgz must be reserved as shorthand for
- * tar.gz). Similarly, foo.dir and foo.doc would both be mapped to foo.dgz.
- * I also considered 12345678.txt -> 12345txt.gz but this truncates the name
- * too heavily. There is no ideal solution given the MSDOS 8+3 limitation.
- *
- * For the meaning of all compilation flags, see comments in Makefile.in.
- */
-
-#ifdef RCSID
-static char rcsid[] = "$Id: gzip.c,v 1.7 1997/03/15 22:43:58 guido Exp $";
-#endif
-
-#include <ctype.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/stat.h>
-#include <errno.h>
-
-#include "tailor.h"
-#include "gzip.h"
-#include "lzw.h"
-#include "revision.h"
-#include "getopt.h"
-
- /* configuration */
-
-#ifdef NO_TIME_H
-# include <sys/time.h>
-#else
-# include <time.h>
-#endif
-
-#ifndef NO_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H)
-# include <stdlib.h>
-#else
- extern int errno;
-#endif
-
-#if defined(DIRENT)
-# include <dirent.h>
- typedef struct dirent dir_type;
-# define NLENGTH(dirent) ((int)strlen((dirent)->d_name))
-# define DIR_OPT "DIRENT"
-#else
-# define NLENGTH(dirent) ((dirent)->d_namlen)
-# ifdef SYSDIR
-# include <sys/dir.h>
- typedef struct direct dir_type;
-# define DIR_OPT "SYSDIR"
-# else
-# ifdef SYSNDIR
-# include <sys/ndir.h>
- typedef struct direct dir_type;
-# define DIR_OPT "SYSNDIR"
-# else
-# ifdef NDIR
-# include <ndir.h>
- typedef struct direct dir_type;
-# define DIR_OPT "NDIR"
-# else
-# define NO_DIR
-# define DIR_OPT "NO_DIR"
-# endif
-# endif
-# endif
-#endif
-
-#ifndef NO_UTIME
-# ifndef NO_UTIME_H
-# include <utime.h>
-# define TIME_OPT "UTIME"
-# else
-# ifdef HAVE_SYS_UTIME_H
-# include <sys/utime.h>
-# define TIME_OPT "SYS_UTIME"
-# else
- struct utimbuf {
- time_t actime;
- time_t modtime;
- };
-# define TIME_OPT ""
-# endif
-# endif
-#else
-# define TIME_OPT "NO_UTIME"
-#endif
-
-#if !defined(S_ISDIR) && defined(S_IFDIR)
-# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-#endif
-#if !defined(S_ISREG) && defined(S_IFREG)
-# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#endif
-
-typedef RETSIGTYPE (*sig_type) OF((int));
-
-#ifndef O_BINARY
-# define O_BINARY 0 /* creation mode for open() */
-#endif
-
-#ifndef O_CREAT
- /* Pure BSD system? */
-# include <sys/file.h>
-# ifndef O_CREAT
-# define O_CREAT FCREAT
-# endif
-# ifndef O_EXCL
-# define O_EXCL FEXCL
-# endif
-#endif
-
-#ifndef S_IRUSR
-# define S_IRUSR 0400
-#endif
-#ifndef S_IWUSR
-# define S_IWUSR 0200
-#endif
-#define RW_USER (S_IRUSR | S_IWUSR) /* creation mode for open() */
-
-#ifndef MAX_PATH_LEN
-# define MAX_PATH_LEN 1024 /* max pathname length */
-#endif
-
-#ifndef SEEK_END
-# define SEEK_END 2
-#endif
-
-#ifdef NO_OFF_T
- typedef long off_t;
- off_t lseek OF((int fd, off_t offset, int whence));
-#endif
-
-/* Separator for file name parts (see shorten_name()) */
-#ifdef NO_MULTIPLE_DOTS
-# define PART_SEP "-"
-#else
-# define PART_SEP "."
-#endif
-
- /* global buffers */
-
-DECLARE(uch, inbuf, INBUFSIZ +INBUF_EXTRA);
-DECLARE(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
-DECLARE(ush, d_buf, DIST_BUFSIZE);
-DECLARE(uch, window, 2L*WSIZE);
-#ifndef MAXSEG_64K
- DECLARE(ush, tab_prefix, 1L<<BITS);
-#else
- DECLARE(ush, tab_prefix0, 1L<<(BITS-1));
- DECLARE(ush, tab_prefix1, 1L<<(BITS-1));
-#endif
-
- /* local variables */
-
-int ascii = 0; /* convert end-of-lines to local OS conventions */
-int to_stdout = 0; /* output to stdout (-c) */
-int decompress = 0; /* decompress (-d) */
-int force = 0; /* don't ask questions, compress links (-f) */
-int no_name = -1; /* don't save or restore the original file name */
-int no_time = -1; /* don't save or restore the original file time */
-int recursive = 0; /* recurse through directories (-r) */
-int list = 0; /* list the file contents (-l) */
-int verbose = 0; /* be verbose (-v) */
-int quiet = 0; /* be very quiet (-q) */
-int do_lzw = 0; /* generate output compatible with old compress (-Z) */
-int test = 0; /* test .gz file integrity */
-int foreground; /* set if program run in foreground */
-char *progname; /* program name */
-int maxbits = BITS; /* max bits per code for LZW */
-int method = DEFLATED;/* compression method */
-int level = 6; /* compression level */
-int exit_code = OK; /* program exit code */
-int save_orig_name; /* set if original name must be saved */
-int last_member; /* set for .zip and .Z files */
-int part_nb; /* number of parts in .gz file */
-long time_stamp; /* original time stamp (modification time) */
-long ifile_size; /* input file size, -1 for devices (debug only) */
-char *env; /* contents of GZIP env variable */
-char **args = NULL; /* argv pointer if GZIP env variable defined */
-char z_suffix[MAX_SUFFIX+1]; /* default suffix (can be set with --suffix) */
-int z_len; /* strlen(z_suffix) */
-
-long bytes_in; /* number of input bytes */
-long bytes_out; /* number of output bytes */
-long total_in = 0; /* input bytes for all files */
-long total_out = 0; /* output bytes for all files */
-char ifname[MAX_PATH_LEN]; /* input file name */
-char ofname[MAX_PATH_LEN]; /* output file name */
-int remove_ofname = 0; /* remove output file on error */
-struct stat istat; /* status for input file */
-int ifd; /* input file descriptor */
-int ofd; /* output file descriptor */
-unsigned insize; /* valid bytes in inbuf */
-unsigned inptr; /* index of next byte to be processed in inbuf */
-unsigned outcnt; /* bytes in output buffer */
-
-struct option longopts[] =
-{
- /* { name has_arg *flag val } */
- {"ascii", 0, 0, 'a'}, /* ascii text mode */
- {"to-stdout", 0, 0, 'c'}, /* write output on standard output */
- {"stdout", 0, 0, 'c'}, /* write output on standard output */
- {"decompress", 0, 0, 'd'}, /* decompress */
- {"uncompress", 0, 0, 'd'}, /* decompress */
- /* {"encrypt", 0, 0, 'e'}, encrypt */
- {"force", 0, 0, 'f'}, /* force overwrite of output file */
- {"help", 0, 0, 'h'}, /* give help */
- /* {"pkzip", 0, 0, 'k'}, force output in pkzip format */
- {"list", 0, 0, 'l'}, /* list .gz file contents */
- {"license", 0, 0, 'L'}, /* display software license */
- {"no-name", 0, 0, 'n'}, /* don't save or restore original name & time */
- {"name", 0, 0, 'N'}, /* save or restore original name & time */
- {"quiet", 0, 0, 'q'}, /* quiet mode */
- {"silent", 0, 0, 'q'}, /* quiet mode */
- {"recursive", 0, 0, 'r'}, /* recurse through directories */
- {"suffix", 1, 0, 'S'}, /* use given suffix instead of .gz */
- {"test", 0, 0, 't'}, /* test compressed file integrity */
- {"no-time", 0, 0, 'T'}, /* don't save or restore the time stamp */
- {"verbose", 0, 0, 'v'}, /* verbose mode */
- {"version", 0, 0, 'V'}, /* display version number */
- {"fast", 0, 0, '1'}, /* compress faster */
- {"best", 0, 0, '9'}, /* compress better */
- {"lzw", 0, 0, 'Z'}, /* make output compatible with old compress */
- {"bits", 1, 0, 'b'}, /* max number of bits per code (implies -Z) */
- { 0, 0, 0, 0 }
-};
-
-/* local functions */
-
-local void usage OF((void));
-local void help OF((void));
-local void license OF((void));
-local void version OF((void));
-local void treat_stdin OF((void));
-local void treat_file OF((char *iname));
-local int create_outfile OF((void));
-local int do_stat OF((char *name, struct stat *sbuf));
-local char *get_suffix OF((char *name));
-local int get_istat OF((char *iname, struct stat *sbuf));
-local int make_ofname OF((void));
-local int same_file OF((struct stat *stat1, struct stat *stat2));
-local int name_too_long OF((char *name, struct stat *statb));
-local void shorten_name OF((char *name));
-local int get_method OF((int in));
-local void do_list OF((int ifd, int method));
-local int check_ofname OF((void));
-local void copy_stat OF((struct stat *ifstat));
-local void do_exit OF((int exitcode));
- int main OF((int argc, char **argv));
-int (*work) OF((int infile, int outfile)) = zip; /* function to call */
-
-#ifndef NO_DIR
-local void treat_dir OF((char *dir));
-#endif
-#ifndef NO_UTIME
-local void reset_times OF((char *name, struct stat *statb));
-#endif
-
-#define strequ(s1, s2) (strcmp((s1),(s2)) == 0)
-
-/* ======================================================================== */
-local void usage()
-{
- fprintf(stderr, "usage: %s [-%scdfhlLnN%stvV19] [-S suffix] [file ...]\n",
- progname,
-#if O_BINARY
- "a",
-#else
- "",
-#endif
-#ifdef NO_DIR
- ""
-#else
- "r"
-#endif
- );
-}
-
-/* ======================================================================== */
-local void help()
-{
- static char *help_msg[] = {
-#if O_BINARY
- " -a --ascii ascii text; convert end-of-lines using local conventions",
-#endif
- " -c --stdout write on standard output, keep original files unchanged",
- " -d --decompress decompress",
-/* -e --encrypt encrypt */
- " -f --force force overwrite of output file and compress links",
- " -h --help give this help",
-/* -k --pkzip force output in pkzip format */
- " -l --list list compressed file contents",
- " -L --license display software license",
-#ifdef UNDOCUMENTED
- " -m --no-time do not save or restore the original modification time",
- " -M --time save or restore the original modification time",
-#endif
- " -n --no-name do not save or restore the original name and time stamp",
- " -N --name save or restore the original name and time stamp",
- " -q --quiet suppress all warnings",
-#ifndef NO_DIR
- " -r --recursive operate recursively on directories",
-#endif
- " -S .suf --suffix .suf use suffix .suf on compressed files",
- " -t --test test compressed file integrity",
- " -v --verbose verbose mode",
- " -V --version display version number",
- " -1 --fast compress faster",
- " -9 --best compress better",
-#ifdef LZW
- " -Z --lzw produce output compatible with old compress",
- " -b --bits maxbits max number of bits per code (implies -Z)",
-#endif
- " file... files to (de)compress. If none given, use standard input.",
- 0};
- char **p = help_msg;
-
- fprintf(stderr,"%s %s (%s)\n", progname, VERSION, REVDATE);
- usage();
- while (*p) fprintf(stderr, "%s\n", *p++);
-}
-
-/* ======================================================================== */
-local void license()
-{
- char **p = license_msg;
-
- fprintf(stderr,"%s %s (%s)\n", progname, VERSION, REVDATE);
- while (*p) fprintf(stderr, "%s\n", *p++);
-}
-
-/* ======================================================================== */
-local void version()
-{
- fprintf(stderr,"%s %s (%s)\n", progname, VERSION, REVDATE);
-
- fprintf(stderr, "Compilation options:\n%s %s ", DIR_OPT, TIME_OPT);
-#ifdef STDC_HEADERS
- fprintf(stderr, "STDC_HEADERS ");
-#endif
-#ifdef HAVE_UNISTD_H
- fprintf(stderr, "HAVE_UNISTD_H ");
-#endif
-#ifdef NO_MEMORY_H
- fprintf(stderr, "NO_MEMORY_H ");
-#endif
-#ifdef NO_STRING_H
- fprintf(stderr, "NO_STRING_H ");
-#endif
-#ifdef NO_SYMLINK
- fprintf(stderr, "NO_SYMLINK ");
-#endif
-#ifdef NO_MULTIPLE_DOTS
- fprintf(stderr, "NO_MULTIPLE_DOTS ");
-#endif
-#ifdef NO_CHOWN
- fprintf(stderr, "NO_CHOWN ");
-#endif
-#ifdef PROTO
- fprintf(stderr, "PROTO ");
-#endif
-#ifdef ASMV
- fprintf(stderr, "ASMV ");
-#endif
-#ifdef DEBUG
- fprintf(stderr, "DEBUG ");
-#endif
-#ifdef DYN_ALLOC
- fprintf(stderr, "DYN_ALLOC ");
-#endif
-#ifdef MAXSEG_64K
- fprintf(stderr, "MAXSEG_64K");
-#endif
- fprintf(stderr, "\n");
-}
-
-/* ======================================================================== */
-int main (argc, argv)
- int argc;
- char **argv;
-{
- int file_count; /* number of files to precess */
- int proglen; /* length of progname */
- int optc; /* current option */
-
- EXPAND(argc, argv); /* wild card expansion if necessary */
-
- progname = basename(argv[0]);
- proglen = strlen(progname);
-
- /* Suppress .exe for MSDOS, OS/2 and VMS: */
- if (proglen > 4 && strequ(progname+proglen-4, ".exe")) {
- progname[proglen-4] = '\0';
- }
-
- /* Add options in GZIP environment variable if there is one */
- env = add_envopt(&argc, &argv, OPTIONS_VAR);
- if (env != NULL) args = argv;
-
- foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
- if (foreground) {
- (void) signal (SIGINT, (sig_type)abort_gzip);
- }
-#ifdef SIGTERM
- if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
- (void) signal(SIGTERM, (sig_type)abort_gzip);
- }
-#endif
-#ifdef SIGHUP
- if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
- (void) signal(SIGHUP, (sig_type)abort_gzip);
- }
-#endif
-
-#ifndef GNU_STANDARD
- /* For compatibility with old compress, use program name as an option.
- * If you compile with -DGNU_STANDARD, this program will behave as
- * gzip even if it is invoked under the name gunzip or zcat.
- *
- * Systems which do not support links can still use -d or -dc.
- * Ignore an .exe extension for MSDOS, OS/2 and VMS.
- */
- if ( strncmp(progname, "un", 2) == 0 /* ungzip, uncompress */
- || strncmp(progname, "gun", 3) == 0) { /* gunzip */
- decompress = 1;
- } else if (strequ(progname+1, "cat") /* zcat, pcat, gcat */
- || strequ(progname, "gzcat")) { /* gzcat */
- decompress = to_stdout = 1;
- }
-#endif
-
- strncpy(z_suffix, Z_SUFFIX, sizeof(z_suffix)-1);
- z_len = strlen(z_suffix);
-
- while ((optc = getopt_long (argc, argv, "ab:cdfhH?lLmMnNqrS:tvVZ123456789",
- longopts, (int *)0)) != EOF) {
- switch (optc) {
- case 'a':
- ascii = 1; break;
- case 'b':
- maxbits = atoi(optarg);
- break;
- case 'c':
- to_stdout = 1; break;
- case 'd':
- decompress = 1; break;
- case 'f':
- force++; break;
- case 'h': case 'H': case '?':
- help(); do_exit(OK); break;
- case 'l':
- list = decompress = to_stdout = 1; break;
- case 'L':
- license(); do_exit(OK); break;
- case 'm': /* undocumented, may change later */
- no_time = 1; break;
- case 'M': /* undocumented, may change later */
- no_time = 0; break;
- case 'n':
- no_name = no_time = 1; break;
- case 'N':
- no_name = no_time = 0; break;
- case 'q':
- quiet = 1; verbose = 0; break;
- case 'r':
-#ifdef NO_DIR
- fprintf(stderr, "%s: -r not supported on this system\n", progname);
- usage();
- do_exit(ERROR); break;
-#else
- recursive = 1; break;
-#endif
- case 'S':
-#ifdef NO_MULTIPLE_DOTS
- if (*optarg == '.') optarg++;
-#endif
- z_len = strlen(optarg);
- strcpy(z_suffix, optarg);
- break;
- case 't':
- test = decompress = to_stdout = 1;
- break;
- case 'v':
- verbose++; quiet = 0; break;
- case 'V':
- version(); do_exit(OK); break;
- case 'Z':
-#ifdef LZW
- do_lzw = 1; break;
-#else
- fprintf(stderr, "%s: -Z not supported in this version\n",
- progname);
- usage();
- do_exit(ERROR); break;
-#endif
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- level = optc - '0';
- break;
- default:
- /* Error message already emitted by getopt_long. */
- usage();
- do_exit(ERROR);
- }
- } /* loop on all arguments */
-
- /* By default, save name and timestamp on compression but do not
- * restore them on decompression.
- */
- if (no_time < 0) no_time = decompress;
- if (no_name < 0) no_name = decompress;
-
- file_count = argc - optind;
-
-#if O_BINARY
-#else
- if (ascii && !quiet) {
- fprintf(stderr, "%s: option --ascii ignored on this system\n",
- progname);
- }
-#endif
- if ((z_len == 0 && !decompress) || z_len > MAX_SUFFIX) {
- fprintf(stderr, "%s: incorrect suffix '%s'\n",
- progname, optarg);
- do_exit(ERROR);
- }
- if (do_lzw && !decompress) work = lzw;
-
- /* Allocate all global buffers (for DYN_ALLOC option) */
- ALLOC(uch, inbuf, INBUFSIZ +INBUF_EXTRA);
- ALLOC(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
- ALLOC(ush, d_buf, DIST_BUFSIZE);
- ALLOC(uch, window, 2L*WSIZE);
-#ifndef MAXSEG_64K
- ALLOC(ush, tab_prefix, 1L<<BITS);
-#else
- ALLOC(ush, tab_prefix0, 1L<<(BITS-1));
- ALLOC(ush, tab_prefix1, 1L<<(BITS-1));
-#endif
-
- /* And get to work */
- if (file_count != 0) {
- if (to_stdout && !test && !list && (!decompress || !ascii)) {
- SET_BINARY_MODE(fileno(stdout));
- }
- while (optind < argc) {
- treat_file(argv[optind++]);
- }
- } else { /* Standard input */
- treat_stdin();
- }
- if (list && !quiet && file_count > 1) {
- do_list(-1, -1); /* print totals */
- }
- do_exit(exit_code);
- return exit_code; /* just to avoid lint warning */
-}
-
-/* ========================================================================
- * Compress or decompress stdin
- */
-local void treat_stdin()
-{
- if (!force && !list &&
- isatty(fileno((FILE *)(decompress ? stdin : stdout)))) {
- /* Do not send compressed data to the terminal or read it from
- * the terminal. We get here when user invoked the program
- * without parameters, so be helpful. According to the GNU standards:
- *
- * If there is one behavior you think is most useful when the output
- * is to a terminal, and another that you think is most useful when
- * the output is a file or a pipe, then it is usually best to make
- * the default behavior the one that is useful with output to a
- * terminal, and have an option for the other behavior.
- *
- * Here we use the --force option to get the other behavior.
- */
- fprintf(stderr,
- "%s: compressed data not %s a terminal. Use -f to force %scompression.\n",
- progname, decompress ? "read from" : "written to",
- decompress ? "de" : "");
- fprintf(stderr,"For help, type: %s -h\n", progname);
- do_exit(ERROR);
- }
-
- if (decompress || !ascii) {
- SET_BINARY_MODE(fileno(stdin));
- }
- if (!test && !list && (!decompress || !ascii)) {
- SET_BINARY_MODE(fileno(stdout));
- }
- strcpy(ifname, "stdin");
- strcpy(ofname, "stdout");
-
- /* Get the time stamp on the input file. */
- time_stamp = 0; /* time unknown by default */
-
-#ifndef NO_STDIN_FSTAT
- if (list || !no_time) {
- if (fstat(fileno(stdin), &istat) != 0) {
- error("fstat(stdin)");
- }
-# ifdef NO_PIPE_TIMESTAMP
- if (S_ISREG(istat.st_mode))
-# endif
- time_stamp = istat.st_mtime;
-#endif /* NO_STDIN_FSTAT */
- }
- ifile_size = -1L; /* convention for unknown size */
-
- clear_bufs(); /* clear input and output buffers */
- to_stdout = 1;
- part_nb = 0;
-
- if (decompress) {
- method = get_method(ifd);
- if (method < 0) {
- do_exit(exit_code); /* error message already emitted */
- }
- }
- if (list) {
- do_list(ifd, method);
- return;
- }
-
- /* Actually do the compression/decompression. Loop over zipped members.
- */
- for (;;) {
- if ((*work)(fileno(stdin), fileno(stdout)) != OK) return;
-
- if (!decompress || last_member || inptr == insize) break;
- /* end of file */
-
- method = get_method(ifd);
- if (method < 0) return; /* error message already emitted */
- bytes_out = 0; /* required for length check */
- }
-
- if (verbose) {
- if (test) {
- fprintf(stderr, " OK\n");
-
- } else if (!decompress) {
- display_ratio(bytes_in-(bytes_out-header_bytes), bytes_in, stderr);
- fprintf(stderr, "\n");
-#ifdef DISPLAY_STDIN_RATIO
- } else {
- display_ratio(bytes_out-(bytes_in-header_bytes), bytes_out,stderr);
- fprintf(stderr, "\n");
-#endif
- }
- }
-}
-
-/* ========================================================================
- * Compress or decompress the given file
- */
-local void treat_file(iname)
- char *iname;
-{
- /* Accept "-" as synonym for stdin */
- if (strequ(iname, "-")) {
- int cflag = to_stdout;
- treat_stdin();
- to_stdout = cflag;
- return;
- }
-
- /* Check if the input file is present, set ifname and istat: */
- if (get_istat(iname, &istat) != OK) return;
-
- /* If the input name is that of a directory, recurse or ignore: */
- if (S_ISDIR(istat.st_mode)) {
-#ifndef NO_DIR
- if (recursive) {
- struct stat st;
- st = istat;
- treat_dir(iname);
- /* Warning: ifname is now garbage */
-# ifndef NO_UTIME
- reset_times (iname, &st);
-# endif
- } else
-#endif
- WARN((stderr,"%s: %s is a directory -- ignored\n", progname, ifname));
- return;
- }
- if (!S_ISREG(istat.st_mode)) {
- WARN((stderr,
- "%s: %s is not a directory or a regular file - ignored\n",
- progname, ifname));
- return;
- }
- if (istat.st_nlink > 1 && !to_stdout && !force) {
- WARN((stderr, "%s: %s has %d other link%c -- unchanged\n",
- progname, ifname,
- (int)istat.st_nlink - 1, istat.st_nlink > 2 ? 's' : ' '));
- return;
- }
-
- ifile_size = istat.st_size;
- time_stamp = no_time && !list ? 0 : istat.st_mtime;
-
- /* Generate output file name. For -r and (-t or -l), skip files
- * without a valid gzip suffix (check done in make_ofname).
- */
- if (to_stdout && !list && !test) {
- strcpy(ofname, "stdout");
-
- } else if (make_ofname() != OK) {
- return;
- }
-
- /* Open the input file and determine compression method. The mode
- * parameter is ignored but required by some systems (VMS) and forbidden
- * on other systems (MacOS).
- */
- ifd = OPEN(ifname, ascii && !decompress ? O_RDONLY : O_RDONLY | O_BINARY,
- RW_USER);
- if (ifd == -1) {
- fprintf(stderr, "%s: ", progname);
- perror(ifname);
- exit_code = ERROR;
- return;
- }
- clear_bufs(); /* clear input and output buffers */
- part_nb = 0;
-
- if (decompress) {
- method = get_method(ifd); /* updates ofname if original given */
- if (method < 0) {
- close(ifd);
- return; /* error message already emitted */
- }
- }
- if (list) {
- do_list(ifd, method);
- close(ifd);
- return;
- }
-
- /* If compressing to a file, check if ofname is not ambiguous
- * because the operating system truncates names. Otherwise, generate
- * a new ofname and save the original name in the compressed file.
- */
- if (to_stdout) {
- ofd = fileno(stdout);
- /* keep remove_ofname as zero */
- } else {
- if (create_outfile() != OK) return;
-
- if (!decompress && save_orig_name && !verbose && !quiet) {
- fprintf(stderr, "%s: %s compressed to %s\n",
- progname, ifname, ofname);
- }
- }
- /* Keep the name even if not truncated except with --no-name: */
- if (!save_orig_name) save_orig_name = !no_name;
-
- if (verbose) {
- fprintf(stderr, "%s:\t%s", ifname, (int)strlen(ifname) >= 15 ?
- "" : ((int)strlen(ifname) >= 7 ? "\t" : "\t\t"));
- }
-
- /* Actually do the compression/decompression. Loop over zipped members.
- */
- for (;;) {
- if ((*work)(ifd, ofd) != OK) {
- method = -1; /* force cleanup */
- break;
- }
- if (!decompress || last_member || inptr == insize) break;
- /* end of file */
-
- method = get_method(ifd);
- if (method < 0) break; /* error message already emitted */
- bytes_out = 0; /* required for length check */
- }
-
- close(ifd);
- if (!to_stdout && close(ofd)) {
- write_error();
- }
- if (method == -1) {
- if (!to_stdout) unlink (ofname);
- return;
- }
- /* Display statistics */
- if(verbose) {
- if (test) {
- fprintf(stderr, " OK");
- } else if (decompress) {
- display_ratio(bytes_out-(bytes_in-header_bytes), bytes_out,stderr);
- } else {
- display_ratio(bytes_in-(bytes_out-header_bytes), bytes_in, stderr);
- }
- if (!test && !to_stdout) {
- fprintf(stderr, " -- replaced with %s", ofname);
- }
- fprintf(stderr, "\n");
- }
- /* Copy modes, times, ownership, and remove the input file */
- if (!to_stdout) {
- copy_stat(&istat);
- }
-}
-
-/* ========================================================================
- * Create the output file. Return OK or ERROR.
- * Try several times if necessary to avoid truncating the z_suffix. For
- * example, do not create a compressed file of name "1234567890123."
- * Sets save_orig_name to true if the file name has been truncated.
- * IN assertions: the input file has already been open (ifd is set) and
- * ofname has already been updated if there was an original name.
- * OUT assertions: ifd and ofd are closed in case of error.
- */
-local int create_outfile()
-{
- struct stat ostat; /* stat for ofname */
- int flags = O_WRONLY | O_CREAT | O_EXCL | O_BINARY;
-
- if (ascii && decompress) {
- flags &= ~O_BINARY; /* force ascii text mode */
- }
- for (;;) {
- /* Make sure that ofname is not an existing file */
- if (check_ofname() != OK) {
- close(ifd);
- return ERROR;
- }
- /* Create the output file */
- remove_ofname = 1;
- ofd = OPEN(ofname, flags, RW_USER);
- if (ofd == -1) {
- perror(ofname);
- close(ifd);
- exit_code = ERROR;
- return ERROR;
- }
-
- /* Check for name truncation on new file (1234567890123.gz) */
-#ifdef NO_FSTAT
- if (stat(ofname, &ostat) != 0) {
-#else
- if (fstat(ofd, &ostat) != 0) {
-#endif
- fprintf(stderr, "%s: ", progname);
- perror(ofname);
- close(ifd); close(ofd);
- unlink(ofname);
- exit_code = ERROR;
- return ERROR;
- }
- if (!name_too_long(ofname, &ostat)) return OK;
-
- if (decompress) {
- /* name might be too long if an original name was saved */
- WARN((stderr, "%s: %s: warning, name truncated\n",
- progname, ofname));
- return OK;
- }
- close(ofd);
- unlink(ofname);
-#ifdef NO_MULTIPLE_DOTS
- /* Should never happen, see check_ofname() */
- fprintf(stderr, "%s: %s: name too long\n", progname, ofname);
- do_exit(ERROR);
-#endif
- shorten_name(ofname);
- }
-}
-
-/* ========================================================================
- * Use lstat if available, except for -c or -f. Use stat otherwise.
- * This allows links when not removing the original file.
- */
-local int do_stat(name, sbuf)
- char *name;
- struct stat *sbuf;
-{
- errno = 0;
-#if (defined(S_IFLNK) || defined (S_ISLNK)) && !defined(NO_SYMLINK)
- if (!to_stdout && !force) {
- return lstat(name, sbuf);
- }
-#endif
- return stat(name, sbuf);
-}
-
-/* ========================================================================
- * Return a pointer to the 'z' suffix of a file name, or NULL. For all
- * systems, ".gz", ".z", ".Z", ".taz", ".tgz", "-gz", "-z" and "_z" are
- * accepted suffixes, in addition to the value of the --suffix option.
- * ".tgz" is a useful convention for tar.z files on systems limited
- * to 3 characters extensions. On such systems, ".?z" and ".??z" are
- * also accepted suffixes. For Unix, we do not want to accept any
- * .??z suffix as indicating a compressed file; some people use .xyz
- * to denote volume data.
- * On systems allowing multiple versions of the same file (such as VMS),
- * this function removes any version suffix in the given name.
- */
-local char *get_suffix(name)
- char *name;
-{
- int nlen, slen;
- char suffix[MAX_SUFFIX+3]; /* last chars of name, forced to lower case */
- static char *known_suffixes[] =
- {z_suffix, ".gz", ".z", ".taz", ".tgz", "-gz", "-z", "_z",
-#ifdef MAX_EXT_CHARS
- "z",
-#endif
- NULL};
- char **suf = known_suffixes;
-
- if (strequ(z_suffix, "z")) suf++; /* check long suffixes first */
-
-#ifdef SUFFIX_SEP
- /* strip a version number from the file name */
- {
- char *v = strrchr(name, SUFFIX_SEP);
- if (v != NULL) *v = '\0';
- }
-#endif
- nlen = strlen(name);
- if (nlen <= MAX_SUFFIX+2) {
- strcpy(suffix, name);
- } else {
- strcpy(suffix, name+nlen-MAX_SUFFIX-2);
- }
- strlwr(suffix);
- slen = strlen(suffix);
- do {
- int s = strlen(*suf);
- if (slen > s && suffix[slen-s-1] != PATH_SEP
- && strequ(suffix + slen - s, *suf)) {
- return name+nlen-s;
- }
- } while (*++suf != NULL);
-
- return NULL;
-}
-
-
-/* ========================================================================
- * Set ifname to the input file name (with a suffix appended if necessary)
- * and istat to its stats. For decompression, if no file exists with the
- * original name, try adding successively z_suffix, .gz, .z, -z and .Z.
- * For MSDOS, we try only z_suffix and z.
- * Return OK or ERROR.
- */
-local int get_istat(iname, sbuf)
- char *iname;
- struct stat *sbuf;
-{
- int ilen; /* strlen(ifname) */
- static char *suffixes[] = {z_suffix, ".gz", ".z", "-z", ".Z", NULL};
- char **suf = suffixes;
- char *s;
-#ifdef NO_MULTIPLE_DOTS
- char *dot; /* pointer to ifname extension, or NULL */
-#endif
-
- if (strlen(iname) >= sizeof(ifname) - 3) {
- errno = ENAMETOOLONG;
- perror(iname);
- exit_code = ERROR;
- return ERROR;
- }
-
- strcpy(ifname, iname);
-
- /* If input file exists, return OK. */
- if (do_stat(ifname, sbuf) == 0) return OK;
-
- if (!decompress || errno != ENOENT) {
- perror(ifname);
- exit_code = ERROR;
- return ERROR;
- }
- /* file.ext doesn't exist, try adding a suffix (after removing any
- * version number for VMS).
- */
- s = get_suffix(ifname);
- if (s != NULL) {
- perror(ifname); /* ifname already has z suffix and does not exist */
- exit_code = ERROR;
- return ERROR;
- }
-#ifdef NO_MULTIPLE_DOTS
- dot = strrchr(ifname, '.');
- if (dot == NULL) {
- strcat(ifname, ".");
- dot = strrchr(ifname, '.');
- }
-#endif
- ilen = strlen(ifname);
- if (strequ(z_suffix, ".gz")) suf++;
-
- /* Search for all suffixes */
- do {
- s = *suf;
-#ifdef NO_MULTIPLE_DOTS
- if (*s == '.') s++;
-#endif
-#ifdef MAX_EXT_CHARS
- strcpy(ifname, iname);
- /* Needed if the suffixes are not sorted by increasing length */
-
- if (*dot == '\0') strcpy(dot, ".");
- dot[MAX_EXT_CHARS+1-strlen(s)] = '\0';
-#endif
- strcat(ifname, s);
- if (do_stat(ifname, sbuf) == 0) return OK;
- ifname[ilen] = '\0';
- } while (*++suf != NULL);
-
- /* No suffix found, complain using z_suffix: */
-#ifdef MAX_EXT_CHARS
- strcpy(ifname, iname);
- if (*dot == '\0') strcpy(dot, ".");
- dot[MAX_EXT_CHARS+1-z_len] = '\0';
-#endif
- strcat(ifname, z_suffix);
- perror(ifname);
- exit_code = ERROR;
- return ERROR;
-}
-
-/* ========================================================================
- * Generate ofname given ifname. Return OK, or WARNING if file must be skipped.
- * Sets save_orig_name to true if the file name has been truncated.
- */
-local int make_ofname()
-{
- char *suff; /* ofname z suffix */
-
- strcpy(ofname, ifname);
- /* strip a version number if any and get the gzip suffix if present: */
- suff = get_suffix(ofname);
-
- if (decompress) {
- if (suff == NULL) {
- /* Whith -t or -l, try all files (even without .gz suffix)
- * except with -r (behave as with just -dr).
- */
- if (!recursive && (list || test)) return OK;
-
- /* Avoid annoying messages with -r */
- if (verbose || (!recursive && !quiet)) {
- WARN((stderr,"%s: %s: unknown suffix -- ignored\n",
- progname, ifname));
- }
- return WARNING;
- }
- /* Make a special case for .tgz and .taz: */
- strlwr(suff);
- if (strequ(suff, ".tgz") || strequ(suff, ".taz")) {
- strcpy(suff, ".tar");
- } else {
- *suff = '\0'; /* strip the z suffix */
- }
- /* ofname might be changed later if infile contains an original name */
-
- } else if (suff != NULL) {
- /* Avoid annoying messages with -r (see treat_dir()) */
- if (verbose || (!recursive && !quiet)) {
- fprintf(stderr, "%s: %s already has %s suffix -- unchanged\n",
- progname, ifname, suff);
- }
- if (exit_code == OK) exit_code = WARNING;
- return WARNING;
- } else {
- save_orig_name = 0;
-
-#ifdef NO_MULTIPLE_DOTS
- suff = strrchr(ofname, '.');
- if (suff == NULL) {
- strcat(ofname, ".");
-# ifdef MAX_EXT_CHARS
- if (strequ(z_suffix, "z")) {
- strcat(ofname, "gz"); /* enough room */
- return OK;
- }
- /* On the Atari and some versions of MSDOS, name_too_long()
- * does not work correctly because of a bug in stat(). So we
- * must truncate here.
- */
- } else if (strlen(suff)-1 + z_len > MAX_SUFFIX) {
- suff[MAX_SUFFIX+1-z_len] = '\0';
- save_orig_name = 1;
-# endif
- }
-#endif /* NO_MULTIPLE_DOTS */
- strcat(ofname, z_suffix);
-
- } /* decompress ? */
- return OK;
-}
-
-
-/* ========================================================================
- * Check the magic number of the input file and update ofname if an
- * original name was given and to_stdout is not set.
- * Return the compression method, -1 for error, -2 for warning.
- * Set inptr to the offset of the next byte to be processed.
- * Updates time_stamp if there is one and --no-time is not used.
- * This function may be called repeatedly for an input file consisting
- * of several contiguous gzip'ed members.
- * IN assertions: there is at least one remaining compressed member.
- * If the member is a zip file, it must be the only one.
- */
-local int get_method(in)
- int in; /* input file descriptor */
-{
- uch flags; /* compression flags */
- char magic[2]; /* magic header */
- ulg stamp; /* time stamp */
-
- /* If --force and --stdout, zcat == cat, so do not complain about
- * premature end of file: use try_byte instead of get_byte.
- */
- if (force && to_stdout) {
- magic[0] = (char)try_byte();
- magic[1] = (char)try_byte();
- /* If try_byte returned EOF, magic[1] == 0xff */
- } else {
- magic[0] = (char)get_byte();
- magic[1] = (char)get_byte();
- }
- method = -1; /* unknown yet */
- part_nb++; /* number of parts in gzip file */
- header_bytes = 0;
- last_member = RECORD_IO;
- /* assume multiple members in gzip file except for record oriented I/O */
-
- if (memcmp(magic, GZIP_MAGIC, 2) == 0
- || memcmp(magic, OLD_GZIP_MAGIC, 2) == 0) {
-
- method = (int)get_byte();
- if (method != DEFLATED) {
- fprintf(stderr,
- "%s: %s: unknown method %d -- get newer version of gzip\n",
- progname, ifname, method);
- exit_code = ERROR;
- return -1;
- }
- work = unzip;
- flags = (uch)get_byte();
-
- if ((flags & ENCRYPTED) != 0) {
- fprintf(stderr,
- "%s: %s is encrypted -- get newer version of gzip\n",
- progname, ifname);
- exit_code = ERROR;
- return -1;
- }
- if ((flags & CONTINUATION) != 0) {
- fprintf(stderr,
- "%s: %s is a a multi-part gzip file -- get newer version of gzip\n",
- progname, ifname);
- exit_code = ERROR;
- if (force <= 1) return -1;
- }
- if ((flags & RESERVED) != 0) {
- fprintf(stderr,
- "%s: %s has flags 0x%x -- get newer version of gzip\n",
- progname, ifname, flags);
- exit_code = ERROR;
- if (force <= 1) return -1;
- }
- stamp = (ulg)get_byte();
- stamp |= ((ulg)get_byte()) << 8;
- stamp |= ((ulg)get_byte()) << 16;
- stamp |= ((ulg)get_byte()) << 24;
- if (stamp != 0 && !no_time) time_stamp = stamp;
-
- (void)get_byte(); /* Ignore extra flags for the moment */
- (void)get_byte(); /* Ignore OS type for the moment */
-
- if ((flags & CONTINUATION) != 0) {
- unsigned part = (unsigned)get_byte();
- part |= ((unsigned)get_byte())<<8;
- if (verbose) {
- fprintf(stderr,"%s: %s: part number %u\n",
- progname, ifname, part);
- }
- }
- if ((flags & EXTRA_FIELD) != 0) {
- unsigned len = (unsigned)get_byte();
- len |= ((unsigned)get_byte())<<8;
- if (verbose) {
- fprintf(stderr,"%s: %s: extra field of %u bytes ignored\n",
- progname, ifname, len);
- }
- while (len--) (void)get_byte();
- }
-
- /* Get original file name if it was truncated */
- if ((flags & ORIG_NAME) != 0) {
- if (no_name || (to_stdout && !list) || part_nb > 1) {
- /* Discard the old name */
- char c; /* dummy used for NeXTstep 3.0 cc optimizer bug */
- do {c=get_byte();} while (c != 0);
- } else {
- /* Copy the base name. Keep a directory prefix intact. */
- char *p = basename(ofname);
- char *base = p;
- for (;;) {
- *p = (char)get_char();
- if (*p++ == '\0') break;
- if (p >= ofname+sizeof(ofname)) {
- error("corrupted input -- file name too large");
- }
- }
- /* If necessary, adapt the name to local OS conventions: */
- if (!list) {
- MAKE_LEGAL_NAME(base);
- if (base) list=0; /* avoid warning about unused variable */
- }
- } /* no_name || to_stdout */
- } /* ORIG_NAME */
-
- /* Discard file comment if any */
- if ((flags & COMMENT) != 0) {
- while (get_char() != 0) /* null */ ;
- }
- if (part_nb == 1) {
- header_bytes = inptr + 2*sizeof(long); /* include crc and size */
- }
-
- } else if (memcmp(magic, PKZIP_MAGIC, 2) == 0 && inptr == 2
- && memcmp((char*)inbuf, PKZIP_MAGIC, 4) == 0) {
- /* To simplify the code, we support a zip file when alone only.
- * We are thus guaranteed that the entire local header fits in inbuf.
- */
- inptr = 0;
- work = unzip;
- if (check_zipfile(in) != OK) return -1;
- /* check_zipfile may get ofname from the local header */
- last_member = 1;
-
- } else if (memcmp(magic, PACK_MAGIC, 2) == 0) {
- work = unpack;
- method = PACKED;
-
- } else if (memcmp(magic, LZW_MAGIC, 2) == 0) {
- work = unlzw;
- method = COMPRESSED;
- last_member = 1;
-
- } else if (memcmp(magic, LZH_MAGIC, 2) == 0) {
- work = unlzh;
- method = LZHED;
- last_member = 1;
-
- } else if (force && to_stdout && !list) { /* pass input unchanged */
- method = STORED;
- work = copy;
- inptr = 0;
- last_member = 1;
- }
- if (method >= 0) return method;
-
- if (part_nb == 1) {
- fprintf(stderr, "\n%s: %s: not in gzip format\n", progname, ifname);
- exit_code = ERROR;
- return -1;
- } else {
- WARN((stderr, "\n%s: %s: decompression OK, trailing garbage ignored\n",
- progname, ifname));
- return -2;
- }
-}
-
-/* ========================================================================
- * Display the characteristics of the compressed file.
- * If the given method is < 0, display the accumulated totals.
- * IN assertions: time_stamp, header_bytes and ifile_size are initialized.
- */
-local void do_list(ifd, method)
- int ifd; /* input file descriptor */
- int method; /* compression method */
-{
- ulg crc; /* original crc */
- static int first_time = 1;
- static char* methods[MAX_METHODS] = {
- "store", /* 0 */
- "compr", /* 1 */
- "pack ", /* 2 */
- "lzh ", /* 3 */
- "", "", "", "", /* 4 to 7 reserved */
- "defla"}; /* 8 */
- char *date;
-
- if (first_time && method >= 0) {
- first_time = 0;
- if (verbose) {
- printf("method crc date time ");
- }
- if (!quiet) {
- printf("compressed uncompr. ratio uncompressed_name\n");
- }
- } else if (method < 0) {
- if (total_in <= 0 || total_out <= 0) return;
- if (verbose) {
- printf(" %9lu %9lu ",
- total_in, total_out);
- } else if (!quiet) {
- printf("%9ld %9ld ", total_in, total_out);
- }
- display_ratio(total_out-(total_in-header_bytes), total_out, stdout);
- /* header_bytes is not meaningful but used to ensure the same
- * ratio if there is a single file.
- */
- printf(" (totals)\n");
- return;
- }
- crc = (ulg)~0; /* unknown */
- bytes_out = -1L;
- bytes_in = ifile_size;
-
-#if RECORD_IO == 0
- if (method == DEFLATED && !last_member) {
- /* Get the crc and uncompressed size for gzip'ed (not zip'ed) files.
- * If the lseek fails, we could use read() to get to the end, but
- * --list is used to get quick results.
- * Use "gunzip < foo.gz | wc -c" to get the uncompressed size if
- * you are not concerned about speed.
- */
- bytes_in = (long)lseek(ifd, (off_t)(-8), SEEK_END);
- if (bytes_in != -1L) {
- uch buf[8];
- bytes_in += 8L;
- if (read(ifd, (char*)buf, sizeof(buf)) != sizeof(buf)) {
- read_error();
- }
- crc = LG(buf);
- bytes_out = LG(buf+4);
- }
- }
-#endif /* RECORD_IO */
- date = ctime((time_t*)&time_stamp) + 4; /* skip the day of the week */
- date[12] = '\0'; /* suppress the 1/100sec and the year */
- if (verbose) {
- printf("%5s %08lx %11s ", methods[method], crc, date);
- }
- printf("%9ld %9ld ", bytes_in, bytes_out);
- if (bytes_in == -1L) {
- total_in = -1L;
- bytes_in = bytes_out = header_bytes = 0;
- } else if (total_in >= 0) {
- total_in += bytes_in;
- }
- if (bytes_out == -1L) {
- total_out = -1L;
- bytes_in = bytes_out = header_bytes = 0;
- } else if (total_out >= 0) {
- total_out += bytes_out;
- }
- display_ratio(bytes_out-(bytes_in-header_bytes), bytes_out, stdout);
- printf(" %s\n", ofname);
-}
-
-/* ========================================================================
- * Return true if the two stat structures correspond to the same file.
- */
-local int same_file(stat1, stat2)
- struct stat *stat1;
- struct stat *stat2;
-{
- return stat1->st_ino == stat2->st_ino
- && stat1->st_dev == stat2->st_dev
-#ifdef NO_ST_INO
- /* Can't rely on st_ino and st_dev, use other fields: */
- && stat1->st_mode == stat2->st_mode
- && stat1->st_uid == stat2->st_uid
- && stat1->st_gid == stat2->st_gid
- && stat1->st_size == stat2->st_size
- && stat1->st_atime == stat2->st_atime
- && stat1->st_mtime == stat2->st_mtime
- && stat1->st_ctime == stat2->st_ctime
-#endif
- ;
-}
-
-/* ========================================================================
- * Return true if a file name is ambiguous because the operating system
- * truncates file names.
- */
-local int name_too_long(name, statb)
- char *name; /* file name to check */
- struct stat *statb; /* stat buf for this file name */
-{
- int s = strlen(name);
- char c = name[s-1];
- struct stat tstat; /* stat for truncated name */
- int res;
-
- tstat = *statb; /* Just in case OS does not fill all fields */
- name[s-1] = '\0';
- res = stat(name, &tstat) == 0 && same_file(statb, &tstat);
- name[s-1] = c;
- Trace((stderr, " too_long(%s) => %d\n", name, res));
- return res;
-}
-
-/* ========================================================================
- * Shorten the given name by one character, or replace a .tar extension
- * with .tgz. Truncate the last part of the name which is longer than
- * MIN_PART characters: 1234.678.012.gz -> 123.678.012.gz. If the name
- * has only parts shorter than MIN_PART truncate the longest part.
- * For decompression, just remove the last character of the name.
- *
- * IN assertion: for compression, the suffix of the given name is z_suffix.
- */
-local void shorten_name(name)
- char *name;
-{
- int len; /* length of name without z_suffix */
- char *trunc = NULL; /* character to be truncated */
- int plen; /* current part length */
- int min_part = MIN_PART; /* current minimum part length */
- char *p;
-
- len = strlen(name);
- if (decompress) {
- if (len <= 1) error("name too short");
- name[len-1] = '\0';
- return;
- }
- p = get_suffix(name);
- if (p == NULL) error("can't recover suffix\n");
- *p = '\0';
- save_orig_name = 1;
-
- /* compress 1234567890.tar to 1234567890.tgz */
- if (len > 4 && strequ(p-4, ".tar")) {
- strcpy(p-4, ".tgz");
- return;
- }
- /* Try keeping short extensions intact:
- * 1234.678.012.gz -> 123.678.012.gz
- */
- do {
- p = strrchr(name, PATH_SEP);
- p = p ? p+1 : name;
- while (*p) {
- plen = strcspn(p, PART_SEP);
- p += plen;
- if (plen > min_part) trunc = p-1;
- if (*p) p++;
- }
- } while (trunc == NULL && --min_part != 0);
-
- if (trunc != NULL) {
- do {
- trunc[0] = trunc[1];
- } while (*trunc++);
- trunc--;
- } else {
- trunc = strrchr(name, PART_SEP[0]);
- if (trunc == NULL) error("internal error in shorten_name");
- if (trunc[1] == '\0') trunc--; /* force truncation */
- }
- strcpy(trunc, z_suffix);
-}
-
-/* ========================================================================
- * If compressing to a file, check if ofname is not ambiguous
- * because the operating system truncates names. Otherwise, generate
- * a new ofname and save the original name in the compressed file.
- * If the compressed file already exists, ask for confirmation.
- * The check for name truncation is made dynamically, because different
- * file systems on the same OS might use different truncation rules (on SVR4
- * s5 truncates to 14 chars and ufs does not truncate).
- * This function returns -1 if the file must be skipped, and
- * updates save_orig_name if necessary.
- * IN assertions: save_orig_name is already set if ofname has been
- * already truncated because of NO_MULTIPLE_DOTS. The input file has
- * already been open and istat is set.
- */
-local int check_ofname()
-{
- struct stat ostat; /* stat for ofname */
-
-#ifdef ENAMETOOLONG
- /* Check for strictly conforming Posix systems (which return ENAMETOOLONG
- * instead of silently truncating filenames).
- */
- errno = 0;
- while (stat(ofname, &ostat) != 0) {
- if (errno != ENAMETOOLONG) return 0; /* ofname does not exist */
- shorten_name(ofname);
- }
-#else
- if (stat(ofname, &ostat) != 0) return 0;
-#endif
- /* Check for name truncation on existing file. Do this even on systems
- * defining ENAMETOOLONG, because on most systems the strict Posix
- * behavior is disabled by default (silent name truncation allowed).
- */
- if (!decompress && name_too_long(ofname, &ostat)) {
- shorten_name(ofname);
- if (stat(ofname, &ostat) != 0) return 0;
- }
-
- /* Check that the input and output files are different (could be
- * the same by name truncation or links).
- */
- if (same_file(&istat, &ostat)) {
- if (strequ(ifname, ofname)) {
- fprintf(stderr, "%s: %s: cannot %scompress onto itself\n",
- progname, ifname, decompress ? "de" : "");
- } else {
- fprintf(stderr, "%s: %s and %s are the same file\n",
- progname, ifname, ofname);
- }
- exit_code = ERROR;
- return ERROR;
- }
- /* Ask permission to overwrite the existing file */
- if (!force) {
- char response[80];
- strcpy(response,"n");
- fprintf(stderr, "%s: %s already exists;", progname, ofname);
- if (foreground && isatty(fileno(stdin))) {
- fprintf(stderr, " do you wish to overwrite (y or n)? ");
- fflush(stderr);
- (void)fgets(response, sizeof(response)-1, stdin);
- }
- if (tolow(*response) != 'y') {
- fprintf(stderr, "\tnot overwritten\n");
- if (exit_code == OK) exit_code = WARNING;
- return ERROR;
- }
- }
- if (unlink(ofname)) {
- fprintf(stderr, "%s: ", progname);
- perror(ofname);
- exit_code = ERROR;
- return ERROR;
- }
- return OK;
-}
-
-
-#ifndef NO_UTIME
-/* ========================================================================
- * Set the access and modification times from the given stat buffer.
- */
-local void reset_times (name, statb)
- char *name;
- struct stat *statb;
-{
- struct utimbuf timep;
-
- /* Copy the time stamp */
- timep.actime = statb->st_atime;
- timep.modtime = statb->st_mtime;
-
- /* Some systems (at least OS/2) do not support utime on directories */
- if (utime(name, &timep) && !S_ISDIR(statb->st_mode)) {
- WARN((stderr, "%s: ", progname));
- if (!quiet) perror(ofname);
- }
-}
-#endif
-
-
-/* ========================================================================
- * Copy modes, times, ownership from input file to output file.
- * IN assertion: to_stdout is false.
- */
-local void copy_stat(ifstat)
- struct stat *ifstat;
-{
-#ifndef NO_UTIME
- if (decompress && time_stamp != 0 && ifstat->st_mtime != time_stamp) {
- ifstat->st_mtime = time_stamp;
- if (verbose > 1) {
- fprintf(stderr, "%s: time stamp restored\n", ofname);
- }
- }
- reset_times(ofname, ifstat);
-#endif
- /* Copy the protection modes */
- if (chmod(ofname, ifstat->st_mode & 07777)) {
- WARN((stderr, "%s: ", progname));
- if (!quiet) perror(ofname);
- }
-#ifndef NO_CHOWN
- chown(ofname, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */
-#endif
- remove_ofname = 0;
- /* It's now safe to remove the input file: */
- if (unlink(ifname)) {
- WARN((stderr, "%s: ", progname));
- if (!quiet) perror(ifname);
- }
-}
-
-#ifndef NO_DIR
-
-/* ========================================================================
- * Recurse through the given directory. This code is taken from ncompress.
- */
-local void treat_dir(dir)
- char *dir;
-{
- dir_type *dp;
- DIR *dirp;
- char nbuf[MAX_PATH_LEN];
- int len;
-
- dirp = opendir(dir);
-
- if (dirp == NULL) {
- fprintf(stderr, "%s: %s unreadable\n", progname, dir);
- exit_code = ERROR;
- return ;
- }
- /*
- ** WARNING: the following algorithm could occasionally cause
- ** compress to produce error warnings of the form "<filename>.gz
- ** already has .gz suffix - ignored". This occurs when the
- ** .gz output file is inserted into the directory below
- ** readdir's current pointer.
- ** These warnings are harmless but annoying, so they are suppressed
- ** with option -r (except when -v is on). An alternative
- ** to allowing this would be to store the entire directory
- ** list in memory, then compress the entries in the stored
- ** list. Given the depth-first recursive algorithm used here,
- ** this could use up a tremendous amount of memory. I don't
- ** think it's worth it. -- Dave Mack
- ** (An other alternative might be two passes to avoid depth-first.)
- */
-
- while ((dp = readdir(dirp)) != NULL) {
-
- if (strequ(dp->d_name,".") || strequ(dp->d_name,"..")) {
- continue;
- }
- len = strlen(dir);
- if (len + NLENGTH(dp) + 1 < MAX_PATH_LEN - 1) {
- strcpy(nbuf,dir);
- if (len != 0 /* dir = "" means current dir on Amiga */
-#ifdef PATH_SEP2
- && dir[len-1] != PATH_SEP2
-#endif
-#ifdef PATH_SEP3
- && dir[len-1] != PATH_SEP3
-#endif
- ) {
- nbuf[len++] = PATH_SEP;
- }
- strcpy(nbuf+len, dp->d_name);
- treat_file(nbuf);
- } else {
- fprintf(stderr,"%s: %s/%s: pathname too long\n",
- progname, dir, dp->d_name);
- exit_code = ERROR;
- }
- }
- closedir(dirp);
-}
-#endif /* ? NO_DIR */
-
-/* ========================================================================
- * Free all dynamically allocated variables and exit with the given code.
- */
-local void do_exit(exitcode)
- int exitcode;
-{
- static int in_exit = 0;
-
- if (in_exit) exit(exitcode);
- in_exit = 1;
- if (env != NULL) free(env), env = NULL;
- if (args != NULL) free((char*)args), args = NULL;
- FREE(inbuf);
- FREE(outbuf);
- FREE(d_buf);
- FREE(window);
-#ifndef MAXSEG_64K
- FREE(tab_prefix);
-#else
- FREE(tab_prefix0);
- FREE(tab_prefix1);
-#endif
- exit(exitcode);
-}
-
-/* ========================================================================
- * Signal and error handler.
- */
-RETSIGTYPE abort_gzip()
-{
- if (remove_ofname) {
- close(ofd);
- unlink (ofname);
- }
- do_exit(ERROR);
-}
diff --git a/gnu/usr.bin/gzip/gzip.h b/gnu/usr.bin/gzip/gzip.h
deleted file mode 100644
index 1ec96cb..0000000
--- a/gnu/usr.bin/gzip/gzip.h
+++ /dev/null
@@ -1,315 +0,0 @@
-/* gzip.h -- common declarations for all gzip modules
- * Copyright (C) 1992-1993 Jean-loup Gailly.
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#if defined(__STDC__) || defined(PROTO)
-# define OF(args) args
-#else
-# define OF(args) ()
-#endif
-
-#ifdef __STDC__
- typedef void *voidp;
-#else
- typedef char *voidp;
-#endif
-
-/* I don't like nested includes, but the string and io functions are used
- * too often
- */
-#include <stdio.h>
-#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
-# include <string.h>
-# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
-# include <memory.h>
-# endif
-# define memzero(s, n) memset ((voidp)(s), 0, (n))
-#else
-# include <strings.h>
-# define strchr index
-# define strrchr rindex
-# define memcpy(d, s, n) bcopy((s), (d), (n))
-# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
-# define memzero(s, n) bzero((s), (n))
-#endif
-
-#ifndef RETSIGTYPE
-# define RETSIGTYPE void
-#endif
-
-#define local static
-
-typedef unsigned char uch;
-typedef unsigned short ush;
-typedef unsigned long ulg;
-
-/* Return codes from gzip */
-#define OK 0
-#define ERROR 1
-#define WARNING 2
-
-/* Compression methods (see algorithm.doc) */
-#define STORED 0
-#define COMPRESSED 1
-#define PACKED 2
-#define LZHED 3
-/* methods 4 to 7 reserved */
-#define DEFLATED 8
-#define MAX_METHODS 9
-extern int method; /* compression method */
-
-/* To save memory for 16 bit systems, some arrays are overlaid between
- * the various modules:
- * deflate: prev+head window d_buf l_buf outbuf
- * unlzw: tab_prefix tab_suffix stack inbuf outbuf
- * inflate: window inbuf
- * unpack: window inbuf prefix_len
- * unlzh: left+right window c_table inbuf c_len
- * For compression, input is done in window[]. For decompression, output
- * is done in window except for unlzw.
- */
-
-#ifndef INBUFSIZ
-# ifdef SMALL_MEM
-# define INBUFSIZ 0x2000 /* input buffer size */
-# else
-# define INBUFSIZ 0x8000 /* input buffer size */
-# endif
-#endif
-#define INBUF_EXTRA 64 /* required by unlzw() */
-
-#ifndef OUTBUFSIZ
-# ifdef SMALL_MEM
-# define OUTBUFSIZ 8192 /* output buffer size */
-# else
-# define OUTBUFSIZ 16384 /* output buffer size */
-# endif
-#endif
-#define OUTBUF_EXTRA 2048 /* required by unlzw() */
-
-#ifndef DIST_BUFSIZE
-# ifdef SMALL_MEM
-# define DIST_BUFSIZE 0x2000 /* buffer for distances, see trees.c */
-# else
-# define DIST_BUFSIZE 0x8000 /* buffer for distances, see trees.c */
-# endif
-#endif
-
-#ifdef DYN_ALLOC
-# define EXTERN(type, array) extern type * near array
-# define DECLARE(type, array, size) type * near array
-# define ALLOC(type, array, size) { \
- array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) error("insufficient memory"); \
- }
-# define FREE(array) {if (array != NULL) fcfree(array), array=NULL;}
-#else
-# define EXTERN(type, array) extern type array[]
-# define DECLARE(type, array, size) type array[size]
-# define ALLOC(type, array, size)
-# define FREE(array)
-#endif
-
-EXTERN(uch, inbuf); /* input buffer */
-EXTERN(uch, outbuf); /* output buffer */
-EXTERN(ush, d_buf); /* buffer for distances, see trees.c */
-EXTERN(uch, window); /* Sliding window and suffix table (unlzw) */
-#define tab_suffix window
-#ifndef MAXSEG_64K
-# define tab_prefix prev /* hash link (see deflate.c) */
-# define head (prev+WSIZE) /* hash head (see deflate.c) */
- EXTERN(ush, tab_prefix); /* prefix code (see unlzw.c) */
-#else
-# define tab_prefix0 prev
-# define head tab_prefix1
- EXTERN(ush, tab_prefix0); /* prefix for even codes */
- EXTERN(ush, tab_prefix1); /* prefix for odd codes */
-#endif
-
-extern unsigned insize; /* valid bytes in inbuf */
-extern unsigned inptr; /* index of next byte to be processed in inbuf */
-extern unsigned outcnt; /* bytes in output buffer */
-
-extern long bytes_in; /* number of input bytes */
-extern long bytes_out; /* number of output bytes */
-extern long header_bytes;/* number of bytes in gzip header */
-
-#define isize bytes_in
-/* for compatibility with old zip sources (to be cleaned) */
-
-extern int ifd; /* input file descriptor */
-extern int ofd; /* output file descriptor */
-extern char ifname[]; /* input file name or "stdin" */
-extern char ofname[]; /* output file name or "stdout" */
-extern char *progname; /* program name */
-
-extern long time_stamp; /* original time stamp (modification time) */
-extern long ifile_size; /* input file size, -1 for devices (debug only) */
-
-typedef int file_t; /* Do not use stdio */
-#define NO_FILE (-1) /* in memory compression */
-
-
-#define PACK_MAGIC "\037\036" /* Magic header for packed files */
-#define GZIP_MAGIC "\037\213" /* Magic header for gzip files, 1F 8B */
-#define OLD_GZIP_MAGIC "\037\236" /* Magic header for gzip 0.5 = freeze 1.x */
-#define LZH_MAGIC "\037\240" /* Magic header for SCO LZH Compress files*/
-#define PKZIP_MAGIC "\120\113\003\004" /* Magic header for pkzip files */
-
-/* gzip flag byte */
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
-#define RESERVED 0xC0 /* bit 6,7: reserved */
-
-/* internal file attribute */
-#define UNKNOWN 0xffff
-#define BINARY 0
-#define ASCII 1
-
-#ifndef WSIZE
-# define WSIZE 0x8000 /* window size--must be a power of two, and */
-#endif /* at least 32K for zip's deflate method */
-
-#define MIN_MATCH 3
-#define MAX_MATCH 258
-/* The minimum and maximum match lengths */
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-#define MAX_DIST (WSIZE-MIN_LOOKAHEAD)
-/* In order to simplify the code, particularly on 16 bit machines, match
- * distances are limited to MAX_DIST instead of WSIZE.
- */
-
-extern int decrypt; /* flag to turn on decryption */
-extern int exit_code; /* program exit code */
-extern int verbose; /* be verbose (-v) */
-extern int quiet; /* be quiet (-q) */
-extern int level; /* compression level */
-extern int test; /* check .z file integrity */
-extern int to_stdout; /* output to stdout (-c) */
-extern int save_orig_name; /* set if original name must be saved */
-
-#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf(0))
-#define try_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf(1))
-
-/* put_byte is used for the compressed output, put_ubyte for the
- * uncompressed output. However unlzw() uses window for its
- * suffix table instead of its output buffer, so it does not use put_ubyte
- * (to be cleaned up).
- */
-#define put_byte(c) {outbuf[outcnt++]=(uch)(c); if (outcnt==OUTBUFSIZ)\
- flush_outbuf();}
-#define put_ubyte(c) {window[outcnt++]=(uch)(c); if (outcnt==WSIZE)\
- flush_window();}
-
-/* Output a 16 bit value, lsb first */
-#define put_short(w) \
-{ if (outcnt < OUTBUFSIZ-2) { \
- outbuf[outcnt++] = (uch) ((w) & 0xff); \
- outbuf[outcnt++] = (uch) ((ush)(w) >> 8); \
- } else { \
- put_byte((uch)((w) & 0xff)); \
- put_byte((uch)((ush)(w) >> 8)); \
- } \
-}
-
-/* Output a 32 bit value to the bit stream, lsb first */
-#define put_long(n) { \
- put_short((n) & 0xffff); \
- put_short(((ulg)(n)) >> 16); \
-}
-
-#define seekable() 0 /* force sequential output */
-#define translate_eol 0 /* no option -a yet */
-
-#define tolow(c) (isupper(c) ? (c)-'A'+'a' : (c)) /* force to lower case */
-
-/* Macros for getting two-byte and four-byte header values */
-#define SH(p) ((ush)(uch)((p)[0]) | ((ush)(uch)((p)[1]) << 8))
-#define LG(p) ((ulg)(SH(p)) | ((ulg)(SH((p)+2)) << 16))
-
-/* Diagnostic functions */
-#ifdef DEBUG
-# define Assert(cond,msg) {if(!(cond)) error(msg);}
-# define Trace(x) fprintf x
-# define Tracev(x) {if (verbose) fprintf x ;}
-# define Tracevv(x) {if (verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-#define WARN(msg) {if (!quiet) fprintf msg ; \
- if (exit_code == OK) exit_code = WARNING;}
-
- /* in zip.c: */
-extern int zip OF((int in, int out));
-extern int file_read OF((char *buf, unsigned size));
-
- /* in unzip.c */
-extern int unzip OF((int in, int out));
-extern int check_zipfile OF((int in));
-
- /* in unpack.c */
-extern int unpack OF((int in, int out));
-
- /* in unlzh.c */
-extern int unlzh OF((int in, int out));
-
- /* in gzip.c */
-RETSIGTYPE abort_gzip OF((void));
-
- /* in deflate.c */
-void lm_init OF((int pack_level, ush *flags));
-ulg deflate OF((void));
-
- /* in trees.c */
-void ct_init OF((ush *attr, int *method));
-int ct_tally OF((int dist, int lc));
-ulg flush_block OF((char *buf, ulg stored_len, int eof));
-
- /* in bits.c */
-void bi_init OF((file_t zipfile));
-void send_bits OF((int value, int length));
-unsigned bi_reverse OF((unsigned value, int length));
-void bi_windup OF((void));
-void copy_block OF((char *buf, unsigned len, int header));
-extern int (*read_buf) OF((char *buf, unsigned size));
-
- /* in util.c: */
-extern int copy OF((int in, int out));
-extern ulg updcrc OF((uch *s, unsigned n));
-extern void clear_bufs OF((void));
-extern int fill_inbuf OF((int eof_ok));
-extern void flush_outbuf OF((void));
-extern void flush_window OF((void));
-extern void write_buf OF((int fd, voidp buf, unsigned cnt));
-extern char *strlwr OF((char *s));
-extern char *basename OF((char *fname));
-extern void make_simple_name OF((char *name));
-extern char *add_envopt OF((int *argcp, char ***argvp, char *env));
-extern void error OF((char *m));
-extern void warn OF((char *a, char *b));
-extern void read_error OF((void));
-extern void write_error OF((void));
-extern void display_ratio OF((long num, long den, FILE *file));
-extern voidp xmalloc OF((unsigned int size));
-
- /* in inflate.c */
-extern int inflate OF((void));
diff --git a/gnu/usr.bin/gzip/inflate.c b/gnu/usr.bin/gzip/inflate.c
deleted file mode 100644
index e741662..0000000
--- a/gnu/usr.bin/gzip/inflate.c
+++ /dev/null
@@ -1,956 +0,0 @@
-/* inflate.c -- Not copyrighted 1992 by Mark Adler
- version c10p1, 10 January 1993 */
-
-/* You can do whatever you like with this source file, though I would
- prefer that if you modify it and redistribute it that you include
- comments to that effect with your name and the date. Thank you.
- [The history has been moved to the file ChangeLog.]
- */
-
-/*
- Inflate deflated (PKZIP's method 8 compressed) data. The compression
- method searches for as much of the current string of bytes (up to a
- length of 258) in the previous 32K bytes. If it doesn't find any
- matches (of at least length 3), it codes the next byte. Otherwise, it
- codes the length of the matched string and its distance backwards from
- the current position. There is a single Huffman code that codes both
- single bytes (called "literals") and match lengths. A second Huffman
- code codes the distance information, which follows a length code. Each
- length or distance code actually represents a base value and a number
- of "extra" (sometimes zero) bits to get to add to the base value. At
- the end of each deflated block is a special end-of-block (EOB) literal/
- length code. The decoding process is basically: get a literal/length
- code; if EOB then done; if a literal, emit the decoded byte; if a
- length then get the distance and emit the referred-to bytes from the
- sliding window of previously emitted data.
-
- There are (currently) three kinds of inflate blocks: stored, fixed, and
- dynamic. The compressor deals with some chunk of data at a time, and
- decides which method to use on a chunk-by-chunk basis. A chunk might
- typically be 32K or 64K. If the chunk is uncompressible, then the
- "stored" method is used. In this case, the bytes are simply stored as
- is, eight bits per byte, with none of the above coding. The bytes are
- preceded by a count, since there is no longer an EOB code.
-
- If the data is compressible, then either the fixed or dynamic methods
- are used. In the dynamic method, the compressed data is preceded by
- an encoding of the literal/length and distance Huffman codes that are
- to be used to decode this block. The representation is itself Huffman
- coded, and so is preceded by a description of that code. These code
- descriptions take up a little space, and so for small blocks, there is
- a predefined set of codes, called the fixed codes. The fixed method is
- used if the block codes up smaller that way (usually for quite small
- chunks), otherwise the dynamic method is used. In the latter case, the
- codes are customized to the probabilities in the current block, and so
- can code it much better than the pre-determined fixed codes.
-
- The Huffman codes themselves are decoded using a mutli-level table
- lookup, in order to maximize the speed of decoding plus the speed of
- building the decoding tables. See the comments below that precede the
- lbits and dbits tuning parameters.
- */
-
-
-/*
- Notes beyond the 1.93a appnote.txt:
-
- 1. Distance pointers never point before the beginning of the output
- stream.
- 2. Distance pointers can point back across blocks, up to 32k away.
- 3. There is an implied maximum of 7 bits for the bit length table and
- 15 bits for the actual data.
- 4. If only one code exists, then it is encoded using one bit. (Zero
- would be more efficient, but perhaps a little confusing.) If two
- codes exist, they are coded using one bit each (0 and 1).
- 5. There is no way of sending zero distance codes--a dummy must be
- sent if there are none. (History: a pre 2.0 version of PKZIP would
- store blocks with no distance codes, but this was discovered to be
- too harsh a criterion.) Valid only for 1.93a. 2.04c does allow
- zero distance codes, which is sent as one code of zero bits in
- length.
- 6. There are up to 286 literal/length codes. Code 256 represents the
- end-of-block. Note however that the static length tree defines
- 288 codes just to fill out the Huffman codes. Codes 286 and 287
- cannot be used though, since there is no length base or extra bits
- defined for them. Similarly, there are up to 30 distance codes.
- However, static trees define 32 codes (all 5 bits) to fill out the
- Huffman codes, but the last two had better not show up in the data.
- 7. Unzip can check dynamic Huffman blocks for complete code sets.
- The exception is that a single code would not be complete (see #4).
- 8. The five bits following the block type is really the number of
- literal codes sent minus 257.
- 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
- (1+6+6). Therefore, to output three times the length, you output
- three codes (1+1+1), whereas to output four times the same length,
- you only need two codes (1+3). Hmm.
- 10. In the tree reconstruction algorithm, Code = Code + Increment
- only if BitLength(i) is not zero. (Pretty obvious.)
- 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19)
- 12. Note: length code 284 can represent 227-258, but length code 285
- really is 258. The last length deserves its own, short code
- since it gets used a lot in very redundant files. The length
- 258 is special since 258 - 3 (the min match length) is 255.
- 13. The literal/length and distance code bit lengths are read as a
- single stream of lengths. It is possible (and advantageous) for
- a repeat code (16, 17, or 18) to go across the boundary between
- the two sets of lengths.
- */
-
-#ifdef RCSID
-static char rcsid[] = "$Id: inflate.c,v 1.6 1997/02/22 15:45:58 peter Exp $";
-#endif
-
-#include <sys/types.h>
-
-#include "tailor.h"
-
-#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H)
-# include <stdlib.h>
-#endif
-
-#include "gzip.h"
-#define slide window
-
-/* Huffman code lookup table entry--this entry is four bytes for machines
- that have 16-bit pointers (e.g. PC's in the small or medium model).
- Valid extra bits are 0..13. e == 15 is EOB (end of block), e == 16
- means that v is a literal, 16 < e < 32 means that v is a pointer to
- the next table, which codes e - 16 bits, and lastly e == 99 indicates
- an unused code. If a code with e == 99 is looked up, this implies an
- error in the data. */
-struct huft {
- uch e; /* number of extra bits or operation */
- uch b; /* number of bits in this code or subcode */
- union {
- ush n; /* literal, length base, or distance base */
- struct huft *t; /* pointer to next level of table */
- } v;
-};
-
-
-/* Function prototypes */
-int huft_build OF((unsigned *, unsigned, unsigned, ush *, ush *,
- struct huft **, int *));
-int huft_free OF((struct huft *));
-int inflate_codes OF((struct huft *, struct huft *, int, int));
-int inflate_stored OF((void));
-int inflate_fixed OF((void));
-int inflate_dynamic OF((void));
-int inflate_block OF((int *));
-int inflate OF((void));
-
-
-/* The inflate algorithm uses a sliding 32K byte window on the uncompressed
- stream to find repeated byte strings. This is implemented here as a
- circular buffer. The index is updated simply by incrementing and then
- and'ing with 0x7fff (32K-1). */
-/* It is left to other modules to supply the 32K area. It is assumed
- to be usable as if it were declared "uch slide[32768];" or as just
- "uch *slide;" and then malloc'ed in the latter case. The definition
- must be in unzip.h, included above. */
-/* unsigned wp; current position in slide */
-#define wp outcnt
-#define flush_output(w) (wp=(w),flush_window())
-
-/* Tables for deflate from PKZIP's appnote.txt. */
-static unsigned border[] = { /* Order of the bit length code lengths */
- 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-static ush cplens[] = { /* Copy lengths for literal codes 257..285 */
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
- /* note: see note #13 above about the 258 in this list. */
-static ush cplext[] = { /* Extra bits for literal codes 257..285 */
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
- 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */
-static ush cpdist[] = { /* Copy offsets for distance codes 0..29 */
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
- 8193, 12289, 16385, 24577};
-static ush cpdext[] = { /* Extra bits for distance codes */
- 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
- 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
- 12, 12, 13, 13};
-
-
-
-/* Macros for inflate() bit peeking and grabbing.
- The usage is:
-
- NEEDBITS(j)
- x = b & mask_bits[j];
- DUMPBITS(j)
-
- where NEEDBITS makes sure that b has at least j bits in it, and
- DUMPBITS removes the bits from b. The macros use the variable k
- for the number of bits in b. Normally, b and k are register
- variables for speed, and are initialized at the beginning of a
- routine that uses these macros from a global bit buffer and count.
-
- If we assume that EOB will be the longest code, then we will never
- ask for bits with NEEDBITS that are beyond the end of the stream.
- So, NEEDBITS should not read any more bytes than are needed to
- meet the request. Then no bytes need to be "returned" to the buffer
- at the end of the last block.
-
- However, this assumption is not true for fixed blocks--the EOB code
- is 7 bits, but the other literal/length codes can be 8 or 9 bits.
- (The EOB code is shorter than other codes because fixed blocks are
- generally short. So, while a block always has an EOB, many other
- literal/length codes have a significantly lower probability of
- showing up at all.) However, by making the first table have a
- lookup of seven bits, the EOB code will be found in that first
- lookup, and so will not require that too many bits be pulled from
- the stream.
- */
-
-ulg bb; /* bit buffer */
-unsigned bk; /* bits in bit buffer */
-
-ush mask_bits[] = {
- 0x0000,
- 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
- 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
-};
-
-#ifdef CRYPT
- uch cc;
-# define NEXTBYTE() \
- (decrypt ? (cc = get_byte(), zdecode(cc), cc) : get_byte())
-#else
-# define NEXTBYTE() (uch)get_byte()
-#endif
-#define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE())<<k;k+=8;}}
-#define DUMPBITS(n) {b>>=(n);k-=(n);}
-
-
-/*
- Huffman code decoding is performed using a multi-level table lookup.
- The fastest way to decode is to simply build a lookup table whose
- size is determined by the longest code. However, the time it takes
- to build this table can also be a factor if the data being decoded
- is not very long. The most common codes are necessarily the
- shortest codes, so those codes dominate the decoding time, and hence
- the speed. The idea is you can have a shorter table that decodes the
- shorter, more probable codes, and then point to subsidiary tables for
- the longer codes. The time it costs to decode the longer codes is
- then traded against the time it takes to make longer tables.
-
- This results of this trade are in the variables lbits and dbits
- below. lbits is the number of bits the first level table for literal/
- length codes can decode in one step, and dbits is the same thing for
- the distance codes. Subsequent tables are also less than or equal to
- those sizes. These values may be adjusted either when all of the
- codes are shorter than that, in which case the longest code length in
- bits is used, or when the shortest code is *longer* than the requested
- table size, in which case the length of the shortest code in bits is
- used.
-
- There are two different values for the two tables, since they code a
- different number of possibilities each. The literal/length table
- codes 286 possible values, or in a flat code, a little over eight
- bits. The distance table codes 30 possible values, or a little less
- than five bits, flat. The optimum values for speed end up being
- about one bit more than those, so lbits is 8+1 and dbits is 5+1.
- The optimum values may differ though from machine to machine, and
- possibly even between compilers. Your mileage may vary.
- */
-
-
-int lbits = 9; /* bits in base literal/length lookup table */
-int dbits = 6; /* bits in base distance lookup table */
-
-
-/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
-#define BMAX 16 /* maximum bit length of any code (16 for explode) */
-#define N_MAX 288 /* maximum number of codes in any set */
-
-
-unsigned hufts; /* track memory usage */
-
-
-int huft_build(b, n, s, d, e, t, m)
-unsigned *b; /* code lengths in bits (all assumed <= BMAX) */
-unsigned n; /* number of codes (assumed <= N_MAX) */
-unsigned s; /* number of simple-valued codes (0..s-1) */
-ush *d; /* list of base values for non-simple codes */
-ush *e; /* list of extra bits for non-simple codes */
-struct huft **t; /* result: starting table */
-int *m; /* maximum lookup bits, returns actual */
-/* Given a list of code lengths and a maximum table size, make a set of
- tables to decode that set of codes. Return zero on success, one if
- the given code set is incomplete (the tables are still built in this
- case), two if the input is invalid (all zero length codes or an
- oversubscribed set of lengths), and three if not enough memory. */
-{
- unsigned a; /* counter for codes of length k */
- unsigned c[BMAX+1]; /* bit length count table */
- unsigned f; /* i repeats in table every f entries */
- int g; /* maximum code length */
- int h; /* table level */
- register unsigned i; /* counter, current code */
- register unsigned j; /* counter */
- register int k; /* number of bits in current code */
- int l; /* bits per table (returned in m) */
- register unsigned *p; /* pointer into c[], b[], or v[] */
- register struct huft *q; /* points to current table */
- struct huft r; /* table entry for structure assignment */
- struct huft *u[BMAX]; /* table stack */
- unsigned v[N_MAX]; /* values in order of bit length */
- register int w; /* bits before this table == (l * h) */
- unsigned x[BMAX+1]; /* bit offsets, then code stack */
- unsigned *xp; /* pointer into x */
- int y; /* number of dummy codes added */
- unsigned z; /* number of entries in current table */
-
-
- /* Generate counts for each bit length */
- memzero(c, sizeof(c));
- p = b; i = n;
- do {
- Tracecv(*p, (stderr, (n-i >= ' ' && n-i <= '~' ? "%c %d\n" : "0x%x %d\n"),
- n-i, *p));
- c[*p]++; /* assume all entries <= BMAX */
- p++; /* Can't combine with above line (Solaris bug) */
- } while (--i);
- if (c[0] == n) /* null input--all zero length codes */
- {
- *t = (struct huft *)NULL;
- *m = 0;
- return 0;
- }
-
-
- /* Find minimum and maximum length, bound *m by those */
- l = *m;
- for (j = 1; j <= BMAX; j++)
- if (c[j])
- break;
- k = j; /* minimum code length */
- if ((unsigned)l < j)
- l = j;
- for (i = BMAX; i; i--)
- if (c[i])
- break;
- g = i; /* maximum code length */
- if ((unsigned)l > i)
- l = i;
- *m = l;
-
-
- /* Adjust last length count to fill out codes, if needed */
- for (y = 1 << j; j < i; j++, y <<= 1)
- if ((y -= c[j]) < 0)
- return 2; /* bad input: more codes than bits */
- if ((y -= c[i]) < 0)
- return 2;
- c[i] += y;
-
-
- /* Generate starting offsets into the value table for each length */
- x[1] = j = 0;
- p = c + 1; xp = x + 2;
- while (--i) { /* note that i == g from above */
- *xp++ = (j += *p++);
- }
-
-
- /* Make a table of values in order of bit lengths */
- p = b; i = 0;
- do {
- if ((j = *p++) != 0)
- v[x[j]++] = i;
- } while (++i < n);
-
-
- /* Generate the Huffman codes and for each, make the table entries */
- x[0] = i = 0; /* first Huffman code is zero */
- p = v; /* grab values in bit order */
- h = -1; /* no tables yet--level -1 */
- w = -l; /* bits decoded == (l * h) */
- u[0] = (struct huft *)NULL; /* just to keep compilers happy */
- q = (struct huft *)NULL; /* ditto */
- z = 0; /* ditto */
-
- /* go through the bit lengths (k already is bits in shortest code) */
- for (; k <= g; k++)
- {
- a = c[k];
- while (a--)
- {
- /* here i is the Huffman code of length k bits for value *p */
- /* make tables up to required level */
- while (k > w + l)
- {
- h++;
- w += l; /* previous table always l bits */
-
- /* compute minimum size table less than or equal to l bits */
- z = (z = g - w) > (unsigned)l ? l : z; /* upper limit on table size */
- if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
- { /* too few codes for k-w bit table */
- f -= a + 1; /* deduct codes from patterns left */
- xp = c + k;
- while (++j < z) /* try smaller tables up to z bits */
- {
- if ((f <<= 1) <= *++xp)
- break; /* enough codes to use up j bits */
- f -= *xp; /* else deduct codes from patterns */
- }
- }
- z = 1 << j; /* table entries for j-bit table */
-
- /* allocate and link in new table */
- if ((q = (struct huft *)malloc((z + 1)*sizeof(struct huft))) ==
- (struct huft *)NULL)
- {
- if (h)
- huft_free(u[0]);
- return 3; /* not enough memory */
- }
- hufts += z + 1; /* track memory usage */
- *t = q + 1; /* link to list for huft_free() */
- *(t = &(q->v.t)) = (struct huft *)NULL;
- u[h] = ++q; /* table starts after link */
-
- /* connect to last table, if there is one */
- if (h)
- {
- x[h] = i; /* save pattern for backing up */
- r.b = (uch)l; /* bits to dump before this table */
- r.e = (uch)(16 + j); /* bits in this table */
- r.v.t = q; /* pointer to this table */
- j = i >> (w - l); /* (get around Turbo C bug) */
- u[h-1][j] = r; /* connect to last table */
- }
- }
-
- /* set up table entry in r */
- r.b = (uch)(k - w);
- if (p >= v + n)
- r.e = 99; /* out of values--invalid code */
- else if (*p < s)
- {
- r.e = (uch)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */
- r.v.n = (ush)(*p); /* simple code is just the value */
- p++; /* one compiler does not like *p++ */
- }
- else
- {
- r.e = (uch)e[*p - s]; /* non-simple--look up in lists */
- r.v.n = d[*p++ - s];
- }
-
- /* fill code-like entries with r */
- f = 1 << (k - w);
- for (j = i >> w; j < z; j += f)
- q[j] = r;
-
- /* backwards increment the k-bit code i */
- for (j = 1 << (k - 1); i & j; j >>= 1)
- i ^= j;
- i ^= j;
-
- /* backup over finished tables */
- while ((i & ((1 << w) - 1)) != x[h])
- {
- h--; /* don't need to update q */
- w -= l;
- }
- }
- }
-
-
- /* Return true (1) if we were given an incomplete table */
- return y != 0 && g != 1;
-}
-
-
-
-int huft_free(t)
-struct huft *t; /* table to free */
-/* Free the malloc'ed tables built by huft_build(), which makes a linked
- list of the tables it made, with the links in a dummy first entry of
- each table. */
-{
- register struct huft *p, *q;
-
-
- /* Go through linked list, freeing from the malloced (t[-1]) address. */
- p = t;
- while (p != (struct huft *)NULL)
- {
- q = (--p)->v.t;
- free((char*)p);
- p = q;
- }
- return 0;
-}
-
-
-int inflate_codes(tl, td, bl, bd)
-struct huft *tl, *td; /* literal/length and distance decoder tables */
-int bl, bd; /* number of bits decoded by tl[] and td[] */
-/* inflate (decompress) the codes in a deflated (compressed) block.
- Return an error code or zero if it all goes ok. */
-{
- register unsigned e; /* table entry flag/number of extra bits */
- unsigned n, d; /* length and index for copy */
- unsigned w; /* current window position */
- struct huft *t; /* pointer to table entry */
- unsigned ml, md; /* masks for bl and bd bits */
- register ulg b; /* bit buffer */
- register unsigned k; /* number of bits in bit buffer */
-
-
- /* make local copies of globals */
- b = bb; /* initialize bit buffer */
- k = bk;
- w = wp; /* initialize window position */
-
- /* inflate the coded data */
- ml = mask_bits[bl]; /* precompute masks for speed */
- md = mask_bits[bd];
- for (;;) /* do until end of block */
- {
- NEEDBITS((unsigned)bl)
- if ((e = (t = tl + ((unsigned)b & ml))->e) > 16)
- do {
- if (e == 99)
- return 1;
- DUMPBITS(t->b)
- e -= 16;
- NEEDBITS(e)
- } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16);
- DUMPBITS(t->b)
- if (e == 16) /* then it's a literal */
- {
- slide[w++] = (uch)t->v.n;
- Tracevv((stderr, "%c", slide[w-1]));
- if (w == WSIZE)
- {
- flush_output(w);
- w = 0;
- }
- }
- else /* it's an EOB or a length */
- {
- /* exit if end of block */
- if (e == 15)
- break;
-
- /* get length of block to copy */
- NEEDBITS(e)
- n = t->v.n + ((unsigned)b & mask_bits[e]);
- DUMPBITS(e);
-
- /* decode distance of block to copy */
- NEEDBITS((unsigned)bd)
- if ((e = (t = td + ((unsigned)b & md))->e) > 16)
- do {
- if (e == 99)
- return 1;
- DUMPBITS(t->b)
- e -= 16;
- NEEDBITS(e)
- } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16);
- DUMPBITS(t->b)
- NEEDBITS(e)
- d = w - t->v.n - ((unsigned)b & mask_bits[e]);
- DUMPBITS(e)
- Tracevv((stderr,"\\[%d,%d]", w-d, n));
-
- /* do the copy */
- do {
- n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e);
-#if !defined(NOMEMCPY) && !defined(DEBUG)
- if (w - d >= e) /* (this test assumes unsigned comparison) */
- {
- memcpy(slide + w, slide + d, e);
- w += e;
- d += e;
- }
- else /* do it slow to avoid memcpy() overlap */
-#endif /* !NOMEMCPY */
- do {
- slide[w++] = slide[d++];
- Tracevv((stderr, "%c", slide[w-1]));
- } while (--e);
- if (w == WSIZE)
- {
- flush_output(w);
- w = 0;
- }
- } while (n);
- }
- }
-
-
- /* restore the globals from the locals */
- wp = w; /* restore global window pointer */
- bb = b; /* restore global bit buffer */
- bk = k;
-
- /* done */
- return 0;
-}
-
-
-
-int inflate_stored()
-/* "decompress" an inflated type 0 (stored) block. */
-{
- unsigned n; /* number of bytes in block */
- unsigned w; /* current window position */
- register ulg b; /* bit buffer */
- register unsigned k; /* number of bits in bit buffer */
-
-
- /* make local copies of globals */
- b = bb; /* initialize bit buffer */
- k = bk;
- w = wp; /* initialize window position */
-
-
- /* go to byte boundary */
- n = k & 7;
- DUMPBITS(n);
-
-
- /* get the length and its complement */
- NEEDBITS(16)
- n = ((unsigned)b & 0xffff);
- DUMPBITS(16)
- NEEDBITS(16)
- if (n != (unsigned)((~b) & 0xffff))
- return 1; /* error in compressed data */
- DUMPBITS(16)
-
-
- /* read and output the compressed data */
- while (n--)
- {
- NEEDBITS(8)
- slide[w++] = (uch)b;
- if (w == WSIZE)
- {
- flush_output(w);
- w = 0;
- }
- DUMPBITS(8)
- }
-
-
- /* restore the globals from the locals */
- wp = w; /* restore global window pointer */
- bb = b; /* restore global bit buffer */
- bk = k;
- return 0;
-}
-
-
-
-int inflate_fixed()
-/* decompress an inflated type 1 (fixed Huffman codes) block. We should
- either replace this with a custom decoder, or at least precompute the
- Huffman tables. */
-{
- int i; /* temporary variable */
- struct huft *tl; /* literal/length code table */
- struct huft *td; /* distance code table */
- int bl; /* lookup bits for tl */
- int bd; /* lookup bits for td */
- unsigned l[288]; /* length list for huft_build */
-
-
- /* set up literal table */
- for (i = 0; i < 144; i++)
- l[i] = 8;
- for (; i < 256; i++)
- l[i] = 9;
- for (; i < 280; i++)
- l[i] = 7;
- for (; i < 288; i++) /* make a complete, but wrong code set */
- l[i] = 8;
- bl = 7;
- if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0)
- return i;
-
-
- /* set up distance table */
- for (i = 0; i < 30; i++) /* make an incomplete code set */
- l[i] = 5;
- bd = 5;
- if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1)
- {
- huft_free(tl);
- return i;
- }
-
-
- /* decompress until an end-of-block code */
- if (inflate_codes(tl, td, bl, bd))
- return 1;
-
-
- /* free the decoding tables, return */
- huft_free(tl);
- huft_free(td);
- return 0;
-}
-
-
-
-int inflate_dynamic()
-/* decompress an inflated type 2 (dynamic Huffman codes) block. */
-{
- int i; /* temporary variables */
- unsigned j;
- unsigned l; /* last length */
- unsigned m; /* mask for bit lengths table */
- unsigned n; /* number of lengths to get */
- struct huft *tl; /* literal/length code table */
- struct huft *td; /* distance code table */
- int bl; /* lookup bits for tl */
- int bd; /* lookup bits for td */
- unsigned nb; /* number of bit length codes */
- unsigned nl; /* number of literal/length codes */
- unsigned nd; /* number of distance codes */
-#ifdef PKZIP_BUG_WORKAROUND
- unsigned ll[288+32]; /* literal/length and distance code lengths */
-#else
- unsigned ll[286+30]; /* literal/length and distance code lengths */
-#endif
- register ulg b; /* bit buffer */
- register unsigned k; /* number of bits in bit buffer */
-
-
- /* make local bit buffer */
- b = bb;
- k = bk;
-
-
- /* read in table lengths */
- NEEDBITS(5)
- nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes */
- DUMPBITS(5)
- NEEDBITS(5)
- nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */
- DUMPBITS(5)
- NEEDBITS(4)
- nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */
- DUMPBITS(4)
-#ifdef PKZIP_BUG_WORKAROUND
- if (nl > 288 || nd > 32)
-#else
- if (nl > 286 || nd > 30)
-#endif
- return 1; /* bad lengths */
-
-
- /* read in bit-length-code lengths */
- for (j = 0; j < nb; j++)
- {
- NEEDBITS(3)
- ll[border[j]] = (unsigned)b & 7;
- DUMPBITS(3)
- }
- for (; j < 19; j++)
- ll[border[j]] = 0;
-
-
- /* build decoding table for trees--single level, 7 bit lookup */
- bl = 7;
- if ((i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl)) != 0)
- {
- if (i == 1)
- huft_free(tl);
- return i; /* incomplete code set */
- }
-
- if (tl == NULL) /* Grrrhhh */
- return 2;
-
- /* read in literal and distance code lengths */
- n = nl + nd;
- m = mask_bits[bl];
- i = l = 0;
- while ((unsigned)i < n)
- {
- NEEDBITS((unsigned)bl)
- j = (td = tl + ((unsigned)b & m))->b;
- DUMPBITS(j)
- j = td->v.n;
- if (j < 16) /* length of code in bits (0..15) */
- ll[i++] = l = j; /* save last length in l */
- else if (j == 16) /* repeat last length 3 to 6 times */
- {
- NEEDBITS(2)
- j = 3 + ((unsigned)b & 3);
- DUMPBITS(2)
- if ((unsigned)i + j > n)
- return 1;
- while (j--)
- ll[i++] = l;
- }
- else if (j == 17) /* 3 to 10 zero length codes */
- {
- NEEDBITS(3)
- j = 3 + ((unsigned)b & 7);
- DUMPBITS(3)
- if ((unsigned)i + j > n)
- return 1;
- while (j--)
- ll[i++] = 0;
- l = 0;
- }
- else /* j == 18: 11 to 138 zero length codes */
- {
- NEEDBITS(7)
- j = 11 + ((unsigned)b & 0x7f);
- DUMPBITS(7)
- if ((unsigned)i + j > n)
- return 1;
- while (j--)
- ll[i++] = 0;
- l = 0;
- }
- }
-
-
- /* free decoding table for trees */
- huft_free(tl);
-
-
- /* restore the global bit buffer */
- bb = b;
- bk = k;
-
-
- /* build the decoding tables for literal/length and distance codes */
- bl = lbits;
- if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0)
- {
- if (i == 1) {
- fprintf(stderr, " incomplete literal tree\n");
- huft_free(tl);
- }
- return i; /* incomplete code set */
- }
- bd = dbits;
- if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
- {
- if (i == 1) {
- fprintf(stderr, " incomplete distance tree\n");
-#ifdef PKZIP_BUG_WORKAROUND
- i = 0;
- }
-#else
- huft_free(td);
- }
- huft_free(tl);
- return i; /* incomplete code set */
-#endif
- }
-
-
- /* decompress until an end-of-block code */
- if (inflate_codes(tl, td, bl, bd))
- return 1;
-
-
- /* free the decoding tables, return */
- huft_free(tl);
- huft_free(td);
- return 0;
-}
-
-
-
-int inflate_block(e)
-int *e; /* last block flag */
-/* decompress an inflated block */
-{
- unsigned t; /* block type */
- register ulg b; /* bit buffer */
- register unsigned k; /* number of bits in bit buffer */
-
-
- /* make local bit buffer */
- b = bb;
- k = bk;
-
-
- /* read in last block bit */
- NEEDBITS(1)
- *e = (int)b & 1;
- DUMPBITS(1)
-
-
- /* read in block type */
- NEEDBITS(2)
- t = (unsigned)b & 3;
- DUMPBITS(2)
-
-
- /* restore the global bit buffer */
- bb = b;
- bk = k;
-
-
- /* inflate that block type */
- if (t == 2)
- return inflate_dynamic();
- if (t == 0)
- return inflate_stored();
- if (t == 1)
- return inflate_fixed();
-
-
- /* bad block type */
- return 2;
-}
-
-
-
-int inflate()
-/* decompress an inflated entry */
-{
- int e; /* last block flag */
- int r; /* result code */
- unsigned h; /* maximum struct huft's malloc'ed */
-
-
- /* initialize window, bit buffer */
- wp = 0;
- bk = 0;
- bb = 0;
-
-
- /* decompress until the last block */
- h = 0;
- do {
- hufts = 0;
- if ((r = inflate_block(&e)) != 0)
- return r;
- if (hufts > h)
- h = hufts;
- } while (!e);
-
- /* Undo too much lookahead. The next read will be byte aligned so we
- * can discard unused bits in the last meaningful byte.
- */
- while (bk >= 8) {
- bk -= 8;
- inptr--;
- }
-
- /* flush out slide */
- flush_output(wp);
-
-
- /* return success */
-#ifdef DEBUG
- fprintf(stderr, "<%u> ", h);
-#endif /* DEBUG */
- return 0;
-}
diff --git a/gnu/usr.bin/gzip/lzw.c b/gnu/usr.bin/gzip/lzw.c
deleted file mode 100644
index eb67d46..0000000
--- a/gnu/usr.bin/gzip/lzw.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* lzw.c -- compress files in LZW format.
- * This is a dummy version avoiding patent problems.
- */
-
-#ifdef RCSID
-static char rcsid[] = "$Id$";
-#endif
-
-#include "tailor.h"
-#include "gzip.h"
-#include "lzw.h"
-
-static int msg_done = 0;
-
-/* Compress in to out with lzw method. */
-int lzw(in, out)
- int in, out;
-{
- if (msg_done) return ERROR;
- msg_done = 1;
- fprintf(stderr,"output in compress .Z format not supported\n");
- if (in != out) { /* avoid warnings on unused variables */
- exit_code = ERROR;
- }
- return ERROR;
-}
diff --git a/gnu/usr.bin/gzip/lzw.h b/gnu/usr.bin/gzip/lzw.h
deleted file mode 100644
index 4b7ac86..0000000
--- a/gnu/usr.bin/gzip/lzw.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* lzw.h -- define the lzw functions.
- * Copyright (C) 1992-1993 Jean-loup Gailly.
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#if !defined(OF) && defined(lint)
-# include "gzip.h"
-#endif
-
-#ifndef BITS
-# define BITS 16
-#endif
-#define INIT_BITS 9 /* Initial number of bits per code */
-
-#define LZW_MAGIC "\037\235" /* Magic header for lzw files, 1F 9D */
-
-#define BIT_MASK 0x1f /* Mask for 'number of compression bits' */
-/* Mask 0x20 is reserved to mean a fourth header byte, and 0x40 is free.
- * It's a pity that old uncompress does not check bit 0x20. That makes
- * extension of the format actually undesirable because old compress
- * would just crash on the new format instead of giving a meaningful
- * error message. It does check the number of bits, but it's more
- * helpful to say "unsupported format, get a new version" than
- * "can only handle 16 bits".
- */
-
-#define BLOCK_MODE 0x80
-/* Block compression: if table is full and compression rate is dropping,
- * clear the dictionary.
- */
-
-#define LZW_RESERVED 0x60 /* reserved bits */
-
-#define CLEAR 256 /* flush the dictionary */
-#define FIRST (CLEAR+1) /* first free entry */
-
-extern int maxbits; /* max bits per code for LZW */
-extern int block_mode; /* block compress mode -C compatible with 2.0 */
-
-extern int lzw OF((int in, int out));
-extern int unlzw OF((int in, int out));
diff --git a/gnu/usr.bin/gzip/match.S b/gnu/usr.bin/gzip/match.S
deleted file mode 100644
index c0f933c..0000000
--- a/gnu/usr.bin/gzip/match.S
+++ /dev/null
@@ -1,379 +0,0 @@
-/* match.s -- optional optimized asm version of longest match in deflate.c
- * Copyright (C) 1992-1993 Jean-loup Gailly
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- *
- * The 68020 version has been written by Francesco Potorti` <pot@cnuce.cnr.it>
- * with adaptations by Carsten Steger <stegerc@informatik.tu-muenchen.de>,
- * Andreas Schwab <schwab@lamothe.informatik.uni-dortmund.de> and
- * Kristoffer Eriksson <ske@pkmab.se>
- */
-
-/* $Id: match.S,v 1.5 1997/02/22 15:45:59 peter Exp $ */
-
-/* Preprocess with -DNO_UNDERLINE if your C compiler does not prefix
- * external symbols with an underline character '_'.
- */
-#ifdef __ELF__ /* NO_UNDERLINE */
-# define _prev prev
-# define _window window
-# define _match_start match_start
-# define _prev_length prev_length
-# define _good_match good_match
-# define _nice_match nice_match
-# define _strstart strstart
-# define _max_chain_length max_chain_length
-
-# define _match_init match_init
-# define _longest_match longest_match
-#endif
-
-#ifdef DYN_ALLOC
- error: DYN_ALLOC not yet supported in match.s
-#endif
-
-#if defined(i386) || defined(_I386)
-
-/* This version is for 386 Unix or OS/2 in 32 bit mode.
- * Warning: it uses the AT&T syntax: mov source,dest
- * This file is only optional. If you want to force the C version,
- * add -DNO_ASM to CFLAGS in Makefile and set OBJA to an empty string.
- * If you have reduced WSIZE in gzip.h, then change its value below.
- * This version assumes static allocation of the arrays (-DDYN_ALLOC not used).
- */
-
- .file "match.S"
-
-#define MAX_MATCH 258
-#define MAX_MATCH2 $128 /* MAX_MATCH/2-1 */
-#define MIN_MATCH 3
-#define WSIZE $32768
-#define MAX_DIST WSIZE - MAX_MATCH - MIN_MATCH - 1
-
- .globl _match_init
- .globl _longest_match
-
- .text
-
-_match_init:
- ret
-
-/*-----------------------------------------------------------------------
- * Set match_start to the longest match starting at the given string and
- * return its length. Matches shorter or equal to prev_length are discarded,
- * in which case the result is equal to prev_length and match_start is
- * garbage.
- * IN assertions: cur_match is the head of the hash chain for the current
- * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
- */
-
-_longest_match: /* int longest_match(cur_match) */
-
-#define cur_match 20(%esp)
- /* return address */ /* esp+16 */
- push %ebp /* esp+12 */
- push %edi /* esp+8 */
- push %esi /* esp+4 */
- push %ebx /* esp */
-
-/*
- * match equ esi
- * scan equ edi
- * chain_length equ ebp
- * best_len equ ebx
- * limit equ edx
- */
- mov cur_match,%esi
- mov _max_chain_length,%ebp /* chain_length = max_chain_length */
- mov _strstart,%edi
- mov %edi,%edx
- sub MAX_DIST,%edx /* limit = strstart-MAX_DIST */
- jae limit_ok
- sub %edx,%edx /* limit = NIL */
-limit_ok:
- add $2+_window,%edi /* edi = offset(window+strstart+2) */
- mov _prev_length,%ebx /* best_len = prev_length */
- movw -3(%ebx,%edi),%ax /* ax = scan[best_len-1..best_len] */
- movw -2(%edi),%cx /* cx = scan[0..1] */
- cmp _good_match,%ebx /* do we have a good match already? */
- jb do_scan
- shr $2,%ebp /* chain_length >>= 2 */
- jmp do_scan
-
- .align 4
-long_loop:
-/* at this point, edi == scan+2, esi == cur_match */
- movw -3(%ebx,%edi),%ax /* ax = scan[best_len-1..best_len] */
- movw -2(%edi),%cx /* cx = scan[0..1] */
-short_loop:
-/*
- * at this point, di == scan+2, si == cur_match,
- * ax = scan[best_len-1..best_len] and cx = scan[0..1]
- */
- and WSIZE-1, %esi
- movw _prev(%esi,%esi),%si /* cur_match = prev[cur_match] */
- /* top word of esi is still 0 */
- cmp %edx,%esi /* cur_match <= limit ? */
- jbe the_end
- dec %ebp /* --chain_length */
- jz the_end
-do_scan:
- cmpw _window-1(%ebx,%esi),%ax/* check match at best_len-1 */
- jne short_loop
- cmpw _window(%esi),%cx /* check min_match_length match */
- jne short_loop
-
- lea _window+2(%esi),%esi /* si = match */
- mov %edi,%eax /* ax = scan+2 */
- mov MAX_MATCH2,%ecx /* scan for at most MAX_MATCH bytes */
- rep; cmpsw /* loop until mismatch */
- je maxmatch /* match of length MAX_MATCH? */
-mismatch:
- movb -2(%edi),%cl /* mismatch on first or second byte? */
- subb -2(%esi),%cl /* cl = 0 if first bytes equal */
- xchg %edi,%eax /* edi = scan+2, eax = end of scan */
- sub %edi,%eax /* eax = len */
- sub %eax,%esi /* esi = cur_match + 2 + offset(window) */
- sub $2+_window,%esi /* esi = cur_match */
- subb $1,%cl /* set carry if cl == 0 (cannot use DEC) */
- adc $0,%eax /* eax = carry ? len+1 : len */
- cmp %ebx,%eax /* len > best_len ? */
- jle long_loop
- mov %esi,_match_start /* match_start = cur_match */
- mov %eax,%ebx /* ebx = best_len = len */
- cmp _nice_match,%eax /* len >= nice_match ? */
- jl long_loop
-the_end:
- mov %ebx,%eax /* result = eax = best_len */
- pop %ebx
- pop %esi
- pop %edi
- pop %ebp
- ret
-maxmatch:
- cmpsb
- jmp mismatch
-
-#else
-
-/* ======================== 680x0 version ================================= */
-
-#if defined(m68k)||defined(mc68k)||defined(__mc68000__)||defined(__MC68000__)
-# ifndef mc68000
-# define mc68000
-# endif
-#endif
-
-#if defined(__mc68020__) || defined(__MC68020__) || defined(sysV68)
-# ifndef mc68020
-# define mc68020
-# endif
-#endif
-
-#if defined(mc68020) || defined(mc68000)
-
-#if (defined(mc68020) || defined(NeXT)) && !defined(UNALIGNED_OK)
-# define UNALIGNED_OK
-#endif
-
-#ifdef sysV68 /* Try Motorola Delta style */
-
-# define GLOBAL(symbol) global symbol
-# define TEXT text
-# define FILE(filename) file filename
-# define invert_maybe(src,dst) dst,src
-# define imm(data) &data
-# define reg(register) %register
-
-# define addl add.l
-# define addql addq.l
-# define blos blo.b
-# define bhis bhi.b
-# define bras bra.b
-# define clrl clr.l
-# define cmpmb cmpm.b
-# define cmpw cmp.w
-# define cmpl cmp.l
-# define lslw lsl.w
-# define lsrl lsr.l
-# define movel move.l
-# define movew move.w
-# define moveb move.b
-# define moveml movem.l
-# define subl sub.l
-# define subw sub.w
-# define subql subq.l
-
-# define IndBase(bd,An) (bd,An)
-# define IndBaseNdxl(bd,An,Xn) (bd,An,Xn.l)
-# define IndBaseNdxw(bd,An,Xn) (bd,An,Xn.w)
-# define predec(An) -(An)
-# define postinc(An) (An)+
-
-#else /* default style (Sun 3, NeXT, Amiga, Atari) */
-
-# define GLOBAL(symbol) .globl symbol
-# define TEXT .text
-# define FILE(filename) .even
-# define invert_maybe(src,dst) src,dst
-# if defined(sun) || defined(mc68k)
-# define imm(data) #data
-# else
-# define imm(data) \#data
-# endif
-# define reg(register) register
-
-# define blos bcss
-# if defined(sun) || defined(mc68k)
-# define movel movl
-# define movew movw
-# define moveb movb
-# endif
-# define IndBase(bd,An) An@(bd)
-# define IndBaseNdxl(bd,An,Xn) An@(bd,Xn:l)
-# define IndBaseNdxw(bd,An,Xn) An@(bd,Xn:w)
-# define predec(An) An@-
-# define postinc(An) An@+
-
-#endif /* styles */
-
-#define Best_Len reg(d0) /* unsigned */
-#define Cur_Match reg(d1) /* Ipos */
-#define Loop_Counter reg(d2) /* int */
-#define Scan_Start reg(d3) /* unsigned short */
-#define Scan_End reg(d4) /* unsigned short */
-#define Limit reg(d5) /* IPos */
-#define Chain_Length reg(d6) /* unsigned */
-#define Scan_Test reg(d7)
-#define Scan reg(a0) /* *uch */
-#define Match reg(a1) /* *uch */
-#define Prev_Address reg(a2) /* *Pos */
-#define Scan_Ini reg(a3) /* *uch */
-#define Match_Ini reg(a4) /* *uch */
-#define Stack_Pointer reg(sp)
-
-#define MAX_MATCH 258
-#define MIN_MATCH 3
-#define WSIZE 32768
-#define MAX_DIST (WSIZE - MAX_MATCH - MIN_MATCH - 1)
-
- GLOBAL (_match_init)
- GLOBAL (_longest_match)
-
- TEXT
-
- FILE ("match.S")
-
-_match_init:
- rts
-
-/*-----------------------------------------------------------------------
- * Set match_start to the longest match starting at the given string and
- * return its length. Matches shorter or equal to prev_length are discarded,
- * in which case the result is equal to prev_length and match_start is
- * garbage.
- * IN assertions: cur_match is the head of the hash chain for the current
- * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
- */
-
-/* int longest_match (cur_match) */
-
-#ifdef UNALIGNED_OK
-# define pushreg 15928 /* d2-d6/a2-a4 */
-# define popreg 7292
-#else
-# define pushreg 16184 /* d2-d7/a2-a4 */
-# define popreg 7420
-#endif
-
-_longest_match:
- movel IndBase(4,Stack_Pointer),Cur_Match
- moveml imm(pushreg),predec(Stack_Pointer)
- movel _max_chain_length,Chain_Length
- movel _prev_length,Best_Len
- movel imm(_prev),Prev_Address
- movel imm(_window+MIN_MATCH),Match_Ini
- movel _strstart,Limit
- movel Match_Ini,Scan_Ini
- addl Limit,Scan_Ini
- subw imm(MAX_DIST),Limit
- bhis L__limit_ok
- clrl Limit
-L__limit_ok:
- cmpl invert_maybe(_good_match,Best_Len)
- blos L__length_ok
- lsrl imm(2),Chain_Length
-L__length_ok:
- subql imm(1),Chain_Length
-#ifdef UNALIGNED_OK
- movew IndBase(-MIN_MATCH,Scan_Ini),Scan_Start
- movew IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End
-#else
- moveb IndBase(-MIN_MATCH,Scan_Ini),Scan_Start
- lslw imm(8),Scan_Start
- moveb IndBase(-MIN_MATCH+1,Scan_Ini),Scan_Start
- moveb IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End
- lslw imm(8),Scan_End
- moveb IndBaseNdxw(-MIN_MATCH,Scan_Ini,Best_Len),Scan_End
-#endif
- bras L__do_scan
-
-L__long_loop:
-#ifdef UNALIGNED_OK
- movew IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End
-#else
- moveb IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End
- lslw imm(8),Scan_End
- moveb IndBaseNdxw(-MIN_MATCH,Scan_Ini,Best_Len),Scan_End
-#endif
-
-L__short_loop:
- lslw imm(1),Cur_Match
- movew IndBaseNdxl(0,Prev_Address,Cur_Match),Cur_Match
- cmpw invert_maybe(Limit,Cur_Match)
- dbls Chain_Length,L__do_scan
- bras L__return
-
-L__do_scan:
- movel Match_Ini,Match
- addl Cur_Match,Match
-#ifdef UNALIGNED_OK
- cmpw invert_maybe(IndBaseNdxw(-MIN_MATCH-1,Match,Best_Len),Scan_End)
- bne L__short_loop
- cmpw invert_maybe(IndBase(-MIN_MATCH,Match),Scan_Start)
- bne L__short_loop
-#else
- moveb IndBaseNdxw(-MIN_MATCH-1,Match,Best_Len),Scan_Test
- lslw imm(8),Scan_Test
- moveb IndBaseNdxw(-MIN_MATCH,Match,Best_Len),Scan_Test
- cmpw invert_maybe(Scan_Test,Scan_End)
- bne L__short_loop
- moveb IndBase(-MIN_MATCH,Match),Scan_Test
- lslw imm(8),Scan_Test
- moveb IndBase(-MIN_MATCH+1,Match),Scan_Test
- cmpw invert_maybe(Scan_Test,Scan_Start)
- bne L__short_loop
-#endif
-
- movew imm((MAX_MATCH-MIN_MATCH+1)-1),Loop_Counter
- movel Scan_Ini,Scan
-L__scan_loop:
- cmpmb postinc(Match),postinc(Scan)
- dbne Loop_Counter,L__scan_loop
-
- subl Scan_Ini,Scan
- addql imm(MIN_MATCH-1),Scan
- cmpl invert_maybe(Best_Len,Scan)
- bls L__short_loop
- movel Scan,Best_Len
- movel Cur_Match,_match_start
- cmpl invert_maybe(_nice_match,Best_Len)
- blos L__long_loop
-L__return:
- moveml postinc(Stack_Pointer),imm(popreg)
- rts
-
-#else
- error: this asm version is for 386 or 680x0 only
-#endif /* mc68000 || mc68020 */
-#endif /* i386 || _I386 */
diff --git a/gnu/usr.bin/gzip/revision.h b/gnu/usr.bin/gzip/revision.h
deleted file mode 100644
index 9bbb5a9..0000000
--- a/gnu/usr.bin/gzip/revision.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* revision.h -- define the version number
- * Copyright (C) 1992-1993 Jean-loup Gailly.
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#define VERSION "1.2.4"
-#define PATCHLEVEL 0
-#define REVDATE "18 Aug 93"
-
-/* This version does not support compression into old compress format: */
-#ifdef LZW
-# undef LZW
-#endif
-
-/* $Id$ */
diff --git a/gnu/usr.bin/gzip/tailor.h b/gnu/usr.bin/gzip/tailor.h
deleted file mode 100644
index 75e4a19..0000000
--- a/gnu/usr.bin/gzip/tailor.h
+++ /dev/null
@@ -1,328 +0,0 @@
-/* tailor.h -- target dependent definitions
- * Copyright (C) 1992-1993 Jean-loup Gailly.
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-/* The target dependent definitions should be defined here only.
- * The target dependent functions should be defined in tailor.c.
- */
-
-/* $Id$ */
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-
-#if defined(__OS2__) && !defined(OS2)
-# define OS2
-#endif
-
-#if defined(OS2) && defined(MSDOS) /* MS C under OS/2 */
-# undef MSDOS
-#endif
-
-#ifdef MSDOS
-# ifdef __GNUC__
- /* DJGPP version 1.09+ on MS-DOS.
- * The DJGPP 1.09 stat() function must be upgraded before gzip will
- * fully work.
- * No need for DIRENT, since <unistd.h> defines POSIX_SOURCE which
- * implies DIRENT.
- */
-# define near
-# else
-# define MAXSEG_64K
-# ifdef __TURBOC__
-# define NO_OFF_T
-# ifdef __BORLANDC__
-# define DIRENT
-# else
-# define NO_UTIME
-# endif
-# else /* MSC */
-# define HAVE_SYS_UTIME_H
-# define NO_UTIME_H
-# endif
-# endif
-# define PATH_SEP2 '\\'
-# define PATH_SEP3 ':'
-# define MAX_PATH_LEN 128
-# define NO_MULTIPLE_DOTS
-# define MAX_EXT_CHARS 3
-# define Z_SUFFIX "z"
-# define NO_CHOWN
-# define PROTO
-# define STDC_HEADERS
-# define NO_SIZE_CHECK
-# define casemap(c) tolow(c) /* Force file names to lower case */
-# include <io.h>
-# define OS_CODE 0x00
-# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
-# if !defined(NO_ASM) && !defined(ASMV)
-# define ASMV
-# endif
-#else
-# define near
-#endif
-
-#ifdef OS2
-# define PATH_SEP2 '\\'
-# define PATH_SEP3 ':'
-# define MAX_PATH_LEN 260
-# ifdef OS2FAT
-# define NO_MULTIPLE_DOTS
-# define MAX_EXT_CHARS 3
-# define Z_SUFFIX "z"
-# define casemap(c) tolow(c)
-# endif
-# define NO_CHOWN
-# define PROTO
-# define STDC_HEADERS
-# include <io.h>
-# define OS_CODE 0x06
-# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
-# ifdef _MSC_VER
-# define HAVE_SYS_UTIME_H
-# define NO_UTIME_H
-# define MAXSEG_64K
-# undef near
-# define near _near
-# endif
-# ifdef __EMX__
-# define HAVE_SYS_UTIME_H
-# define NO_UTIME_H
-# define DIRENT
-# define EXPAND(argc,argv) \
- {_response(&argc, &argv); _wildcard(&argc, &argv);}
-# endif
-# ifdef __BORLANDC__
-# define DIRENT
-# endif
-# ifdef __ZTC__
-# define NO_DIR
-# define NO_UTIME_H
-# include <dos.h>
-# define EXPAND(argc,argv) \
- {response_expand(&argc, &argv);}
-# endif
-#endif
-
-#ifdef WIN32 /* Windows NT */
-# define HAVE_SYS_UTIME_H
-# define NO_UTIME_H
-# define PATH_SEP2 '\\'
-# define PATH_SEP3 ':'
-# define MAX_PATH_LEN 260
-# define NO_CHOWN
-# define PROTO
-# define STDC_HEADERS
-# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
-# include <io.h>
-# include <malloc.h>
-# ifdef NTFAT
-# define NO_MULTIPLE_DOTS
-# define MAX_EXT_CHARS 3
-# define Z_SUFFIX "z"
-# define casemap(c) tolow(c) /* Force file names to lower case */
-# endif
-# define OS_CODE 0x0b
-#endif
-
-#ifdef MSDOS
-# ifdef __TURBOC__
-# include <alloc.h>
-# define DYN_ALLOC
- /* Turbo C 2.0 does not accept static allocations of large arrays */
- void * fcalloc (unsigned items, unsigned size);
- void fcfree (void *ptr);
-# else /* MSC */
-# include <malloc.h>
-# define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize))
-# define fcfree(ptr) hfree(ptr)
-# endif
-#else
-# ifdef MAXSEG_64K
-# define fcalloc(items,size) calloc((items),(size))
-# else
-# define fcalloc(items,size) malloc((size_t)(items)*(size_t)(size))
-# endif
-# define fcfree(ptr) free(ptr)
-#endif
-
-#if defined(VAXC) || defined(VMS)
-# define PATH_SEP ']'
-# define PATH_SEP2 ':'
-# define SUFFIX_SEP ';'
-# define NO_MULTIPLE_DOTS
-# define Z_SUFFIX "-gz"
-# define RECORD_IO 1
-# define casemap(c) tolow(c)
-# define OS_CODE 0x02
-# define OPTIONS_VAR "GZIP_OPT"
-# define STDC_HEADERS
-# define NO_UTIME
-# define EXPAND(argc,argv) vms_expand_args(&argc,&argv);
-# include <file.h>
-# define unlink delete
-# ifdef VAXC
-# define NO_FCNTL_H
-# include <unixio.h>
-# endif
-#endif
-
-#ifdef AMIGA
-# define PATH_SEP2 ':'
-# define STDC_HEADERS
-# define OS_CODE 0x01
-# define ASMV
-# ifdef __GNUC__
-# define DIRENT
-# define HAVE_UNISTD_H
-# else /* SASC */
-# define NO_STDIN_FSTAT
-# define SYSDIR
-# define NO_SYMLINK
-# define NO_CHOWN
-# define NO_FCNTL_H
-# include <fcntl.h> /* for read() and write() */
-# define direct dirent
- extern void _expand_args(int *argc, char ***argv);
-# define EXPAND(argc,argv) _expand_args(&argc,&argv);
-# undef O_BINARY /* disable useless --ascii option */
-# endif
-#endif
-
-#if defined(ATARI) || defined(atarist)
-# ifndef STDC_HEADERS
-# define STDC_HEADERS
-# define HAVE_UNISTD_H
-# define DIRENT
-# endif
-# define ASMV
-# define OS_CODE 0x05
-# ifdef TOSFS
-# define PATH_SEP2 '\\'
-# define PATH_SEP3 ':'
-# define MAX_PATH_LEN 128
-# define NO_MULTIPLE_DOTS
-# define MAX_EXT_CHARS 3
-# define Z_SUFFIX "z"
-# define NO_CHOWN
-# define casemap(c) tolow(c) /* Force file names to lower case */
-# define NO_SYMLINK
-# endif
-#endif
-
-#ifdef MACOS
-# define PATH_SEP ':'
-# define DYN_ALLOC
-# define PROTO
-# define NO_STDIN_FSTAT
-# define NO_CHOWN
-# define NO_UTIME
-# define chmod(file, mode) (0)
-# define OPEN(name, flags, mode) open(name, flags)
-# define OS_CODE 0x07
-# ifdef MPW
-# define isatty(fd) ((fd) <= 2)
-# endif
-#endif
-
-#ifdef __50SERIES /* Prime/PRIMOS */
-# define PATH_SEP '>'
-# define STDC_HEADERS
-# define NO_MEMORY_H
-# define NO_UTIME_H
-# define NO_UTIME
-# define NO_CHOWN
-# define NO_STDIN_FSTAT
-# define NO_SIZE_CHECK
-# define NO_SYMLINK
-# define RECORD_IO 1
-# define casemap(c) tolow(c) /* Force file names to lower case */
-# define put_char(c) put_byte((c) & 0x7F)
-# define get_char(c) ascii2pascii(get_byte())
-# define OS_CODE 0x0F /* temporary, subject to change */
-# ifdef SIGTERM
-# undef SIGTERM /* We don't want a signal handler for SIGTERM */
-# endif
-#endif
-
-#if defined(pyr) && !defined(NOMEMCPY) /* Pyramid */
-# define NOMEMCPY /* problem with overlapping copies */
-#endif
-
-#ifdef TOPS20
-# define OS_CODE 0x0a
-#endif
-
-#ifndef unix
-# define NO_ST_INO /* don't rely on inode numbers */
-#endif
-
-
- /* Common defaults */
-
-#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
-#endif
-
-#ifndef PATH_SEP
-# define PATH_SEP '/'
-#endif
-
-#ifndef casemap
-# define casemap(c) (c)
-#endif
-
-#ifndef OPTIONS_VAR
-# define OPTIONS_VAR "GZIP"
-#endif
-
-#ifndef Z_SUFFIX
-# define Z_SUFFIX ".gz"
-#endif
-
-#ifdef MAX_EXT_CHARS
-# define MAX_SUFFIX MAX_EXT_CHARS
-#else
-# define MAX_SUFFIX 30
-#endif
-
-#ifndef MAKE_LEGAL_NAME
-# ifdef NO_MULTIPLE_DOTS
-# define MAKE_LEGAL_NAME(name) make_simple_name(name)
-# else
-# define MAKE_LEGAL_NAME(name)
-# endif
-#endif
-
-#ifndef MIN_PART
-# define MIN_PART 3
- /* keep at least MIN_PART chars between dots in a file name. */
-#endif
-
-#ifndef EXPAND
-# define EXPAND(argc,argv)
-#endif
-
-#ifndef RECORD_IO
-# define RECORD_IO 0
-#endif
-
-#ifndef SET_BINARY_MODE
-# define SET_BINARY_MODE(fd)
-#endif
-
-#ifndef OPEN
-# define OPEN(name, flags, mode) open(name, flags, mode)
-#endif
-
-#ifndef get_char
-# define get_char() get_byte()
-#endif
-
-#ifndef put_char
-# define put_char(c) put_byte(c)
-#endif
diff --git a/gnu/usr.bin/gzip/trees.c b/gnu/usr.bin/gzip/trees.c
deleted file mode 100644
index a9b35be..0000000
--- a/gnu/usr.bin/gzip/trees.c
+++ /dev/null
@@ -1,1075 +0,0 @@
-/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1992-1993 Jean-loup Gailly
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-/*
- * PURPOSE
- *
- * Encode various sets of source values using variable-length
- * binary code trees.
- *
- * DISCUSSION
- *
- * The PKZIP "deflation" process uses several Huffman trees. The more
- * common source values are represented by shorter bit sequences.
- *
- * Each code tree is stored in the ZIP file in a compressed form
- * which is itself a Huffman encoding of the lengths of
- * all the code strings (in ascending order by source values).
- * The actual code strings are reconstructed from the lengths in
- * the UNZIP process, as described in the "application note"
- * (APPNOTE.TXT) distributed as part of PKWARE's PKZIP program.
- *
- * REFERENCES
- *
- * Lynch, Thomas J.
- * Data Compression: Techniques and Applications, pp. 53-55.
- * Lifetime Learning Publications, 1985. ISBN 0-534-03418-7.
- *
- * Storer, James A.
- * Data Compression: Methods and Theory, pp. 49-50.
- * Computer Science Press, 1988. ISBN 0-7167-8156-5.
- *
- * Sedgewick, R.
- * Algorithms, p290.
- * Addison-Wesley, 1983. ISBN 0-201-06672-6.
- *
- * INTERFACE
- *
- * void ct_init (ush *attr, int *methodp)
- * Allocate the match buffer, initialize the various tables and save
- * the location of the internal file attribute (ascii/binary) and
- * method (DEFLATE/STORE)
- *
- * void ct_tally (int dist, int lc);
- * Save the match info and tally the frequency counts.
- *
- * long flush_block (char *buf, ulg stored_len, int eof)
- * Determine the best encoding for the current block: dynamic trees,
- * static trees or store, and output the encoded block to the zip
- * file. Returns the total compressed length for the file so far.
- *
- */
-
-#include <ctype.h>
-
-#include "tailor.h"
-#include "gzip.h"
-
-#ifdef RCSID
-static char rcsid[] = "$Id: trees.c,v 1.6 1997/02/22 15:46:01 peter Exp $";
-#endif
-
-/* ===========================================================================
- * Constants
- */
-
-#define MAX_BITS 15
-/* All codes must not exceed MAX_BITS bits */
-
-#define MAX_BL_BITS 7
-/* Bit length codes must not exceed MAX_BL_BITS bits */
-
-#define LENGTH_CODES 29
-/* number of length codes, not counting the special END_BLOCK code */
-
-#define LITERALS 256
-/* number of literal bytes 0..255 */
-
-#define END_BLOCK 256
-/* end of block literal code */
-
-#define L_CODES (LITERALS+1+LENGTH_CODES)
-/* number of Literal or Length codes, including the END_BLOCK code */
-
-#define D_CODES 30
-/* number of distance codes */
-
-#define BL_CODES 19
-/* number of codes used to transfer the bit lengths */
-
-
-local int near extra_lbits[LENGTH_CODES] /* extra bits for each length code */
- = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-
-local int near extra_dbits[D_CODES] /* extra bits for each distance code */
- = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-
-local int near extra_blbits[BL_CODES]/* extra bits for each bit length code */
- = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES 2
-/* The three kinds of block type */
-
-#ifndef LIT_BUFSIZE
-# ifdef SMALL_MEM
-# define LIT_BUFSIZE 0x2000
-# else
-# ifdef MEDIUM_MEM
-# define LIT_BUFSIZE 0x4000
-# else
-# define LIT_BUFSIZE 0x8000
-# endif
-# endif
-#endif
-#ifndef DIST_BUFSIZE
-# define DIST_BUFSIZE LIT_BUFSIZE
-#endif
-/* Sizes of match buffers for literals/lengths and distances. There are
- * 4 reasons for limiting LIT_BUFSIZE to 64K:
- * - frequencies can be kept in 16 bit counters
- * - if compression is not successful for the first block, all input data is
- * still in the window so we can still emit a stored block even when input
- * comes from standard input. (This can also be done for all blocks if
- * LIT_BUFSIZE is not greater than 32K.)
- * - if compression is not successful for a file smaller than 64K, we can
- * even emit a stored file instead of a stored block (saving 5 bytes).
- * - creating new Huffman trees less frequently may not provide fast
- * adaptation to changes in the input data statistics. (Take for
- * example a binary file with poorly compressible code followed by
- * a highly compressible string table.) Smaller buffer sizes give
- * fast adaptation but have of course the overhead of transmitting trees
- * more frequently.
- * - I can't count above 4
- * The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to save
- * memory at the expense of compression). Some optimizations would be possible
- * if we rely on DIST_BUFSIZE == LIT_BUFSIZE.
- */
-#if LIT_BUFSIZE > INBUFSIZ
- error cannot overlay l_buf and inbuf
-#endif
-
-#define REP_3_6 16
-/* repeat previous bit length 3-6 times (2 bits of repeat count) */
-
-#define REPZ_3_10 17
-/* repeat a zero length 3-10 times (3 bits of repeat count) */
-
-#define REPZ_11_138 18
-/* repeat a zero length 11-138 times (7 bits of repeat count) */
-
-/* ===========================================================================
- * Local data
- */
-
-/* Data structure describing a single value and its code string. */
-typedef struct ct_data {
- union {
- ush freq; /* frequency count */
- ush code; /* bit string */
- } fc;
- union {
- ush dad; /* father node in Huffman tree */
- ush len; /* length of bit string */
- } dl;
-} ct_data;
-
-#define Freq fc.freq
-#define Code fc.code
-#define Dad dl.dad
-#define Len dl.len
-
-#define HEAP_SIZE (2*L_CODES+1)
-/* maximum heap size */
-
-local ct_data near dyn_ltree[HEAP_SIZE]; /* literal and length tree */
-local ct_data near dyn_dtree[2*D_CODES+1]; /* distance tree */
-
-local ct_data near static_ltree[L_CODES+2];
-/* The static literal tree. Since the bit lengths are imposed, there is no
- * need for the L_CODES extra codes used during heap construction. However
- * The codes 286 and 287 are needed to build a canonical tree (see ct_init
- * below).
- */
-
-local ct_data near static_dtree[D_CODES];
-/* The static distance tree. (Actually a trivial tree since all codes use
- * 5 bits.)
- */
-
-local ct_data near bl_tree[2*BL_CODES+1];
-/* Huffman tree for the bit lengths */
-
-typedef struct tree_desc {
- ct_data near *dyn_tree; /* the dynamic tree */
- ct_data near *static_tree; /* corresponding static tree or NULL */
- int near *extra_bits; /* extra bits for each code or NULL */
- int extra_base; /* base index for extra_bits */
- int elems; /* max number of elements in the tree */
- int max_length; /* max bit length for the codes */
- int max_code; /* largest code with non zero frequency */
-} tree_desc;
-
-local tree_desc near l_desc =
-{dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0};
-
-local tree_desc near d_desc =
-{dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0};
-
-local tree_desc near bl_desc =
-{bl_tree, (ct_data near *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0};
-
-
-local ush near bl_count[MAX_BITS+1];
-/* number of codes at each bit length for an optimal tree */
-
-local uch near bl_order[BL_CODES]
- = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-/* The lengths of the bit length codes are sent in order of decreasing
- * probability, to avoid transmitting the lengths for unused bit length codes.
- */
-
-local int near heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
-local int heap_len; /* number of elements in the heap */
-local int heap_max; /* element of largest frequency */
-/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
- * The same heap array is used to build all trees.
- */
-
-local uch near depth[2*L_CODES+1];
-/* Depth of each subtree used as tie breaker for trees of equal frequency */
-
-local uch length_code[MAX_MATCH-MIN_MATCH+1];
-/* length code for each normalized match length (0 == MIN_MATCH) */
-
-local uch dist_code[512];
-/* distance codes. The first 256 values correspond to the distances
- * 3 .. 258, the last 256 values correspond to the top 8 bits of
- * the 15 bit distances.
- */
-
-local int near base_length[LENGTH_CODES];
-/* First normalized length for each code (0 = MIN_MATCH) */
-
-local int near base_dist[D_CODES];
-/* First normalized distance for each code (0 = distance of 1) */
-
-#define l_buf inbuf
-/* DECLARE(uch, l_buf, LIT_BUFSIZE); buffer for literals or lengths */
-
-/* DECLARE(ush, d_buf, DIST_BUFSIZE); buffer for distances */
-
-local uch near flag_buf[(LIT_BUFSIZE/8)];
-/* flag_buf is a bit array distinguishing literals from lengths in
- * l_buf, thus indicating the presence or absence of a distance.
- */
-
-local unsigned last_lit; /* running index in l_buf */
-local unsigned last_dist; /* running index in d_buf */
-local unsigned last_flags; /* running index in flag_buf */
-local uch flags; /* current flags not yet saved in flag_buf */
-local uch flag_bit; /* current bit used in flags */
-/* bits are filled in flags starting at bit 0 (least significant).
- * Note: these flags are overkill in the current code since we don't
- * take advantage of DIST_BUFSIZE == LIT_BUFSIZE.
- */
-
-local ulg opt_len; /* bit length of current block with optimal trees */
-local ulg static_len; /* bit length of current block with static trees */
-
-local ulg compressed_len; /* total bit length of compressed file */
-
-local ulg input_len; /* total byte length of input file */
-/* input_len is for debugging only since we can get it by other means. */
-
-ush *file_type; /* pointer to UNKNOWN, BINARY or ASCII */
-int *file_method; /* pointer to DEFLATE or STORE */
-
-#ifdef DEBUG
-extern ulg bits_sent; /* bit length of the compressed data */
-extern long isize; /* byte length of input file */
-#endif
-
-extern long block_start; /* window offset of current block */
-extern unsigned near strstart; /* window offset of current string */
-
-/* ===========================================================================
- * Local (static) routines in this file.
- */
-
-local void init_block OF((void));
-local void pqdownheap OF((ct_data near *tree, int k));
-local void gen_bitlen OF((tree_desc near *desc));
-local void gen_codes OF((ct_data near *tree, int max_code));
-local void build_tree OF((tree_desc near *desc));
-local void scan_tree OF((ct_data near *tree, int max_code));
-local void send_tree OF((ct_data near *tree, int max_code));
-local int build_bl_tree OF((void));
-local void send_all_trees OF((int lcodes, int dcodes, int blcodes));
-local void compress_block OF((ct_data near *ltree, ct_data near *dtree));
-local void set_file_type OF((void));
-
-
-#ifndef DEBUG
-# define send_code(c, tree) send_bits(tree[c].Code, tree[c].Len)
- /* Send a code of the given tree. c and tree must not have side effects */
-
-#else /* DEBUG */
-# define send_code(c, tree) \
- { if (verbose>1) fprintf(stderr,"\ncd %3d ",(c)); \
- send_bits(tree[c].Code, tree[c].Len); }
-#endif
-
-#define d_code(dist) \
- ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)])
-/* Mapping from a distance to a distance code. dist is the distance - 1 and
- * must not have side effects. dist_code[256] and dist_code[257] are never
- * used.
- */
-
-#define MAX(a,b) (a >= b ? a : b)
-/* the arguments must not have side effects */
-
-/* ===========================================================================
- * Allocate the match buffer, initialize the various tables and save the
- * location of the internal file attribute (ascii/binary) and method
- * (DEFLATE/STORE).
- */
-void ct_init(attr, methodp)
- ush *attr; /* pointer to internal file attribute */
- int *methodp; /* pointer to compression method */
-{
- int n; /* iterates over tree elements */
- int bits; /* bit counter */
- int length; /* length value */
- int code; /* code value */
- int dist; /* distance index */
-
- file_type = attr;
- file_method = methodp;
- compressed_len = input_len = 0L;
-
- if (static_dtree[0].Len != 0) return; /* ct_init already called */
-
- /* Initialize the mapping length (0..255) -> length code (0..28) */
- length = 0;
- for (code = 0; code < LENGTH_CODES-1; code++) {
- base_length[code] = length;
- for (n = 0; n < (1<<extra_lbits[code]); n++) {
- length_code[length++] = (uch)code;
- }
- }
- Assert (length == 256, "ct_init: length != 256");
- /* Note that the length 255 (match length 258) can be represented
- * in two different ways: code 284 + 5 bits or code 285, so we
- * overwrite length_code[255] to use the best encoding:
- */
- length_code[length-1] = (uch)code;
-
- /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
- dist = 0;
- for (code = 0 ; code < 16; code++) {
- base_dist[code] = dist;
- for (n = 0; n < (1<<extra_dbits[code]); n++) {
- dist_code[dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "ct_init: dist != 256");
- dist >>= 7; /* from now on, all distances are divided by 128 */
- for ( ; code < D_CODES; code++) {
- base_dist[code] = dist << 7;
- for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
- dist_code[256 + dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "ct_init: 256+dist != 512");
-
- /* Construct the codes of the static literal tree */
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
- n = 0;
- while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
- while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
- while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
- while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
- /* Codes 286 and 287 do not exist, but we must include them in the
- * tree construction to get a canonical Huffman tree (longest code
- * all ones)
- */
- gen_codes((ct_data near *)static_ltree, L_CODES+1);
-
- /* The static distance tree is trivial: */
- for (n = 0; n < D_CODES; n++) {
- static_dtree[n].Len = 5;
- static_dtree[n].Code = bi_reverse(n, 5);
- }
-
- /* Initialize the first block of the first file: */
- init_block();
-}
-
-/* ===========================================================================
- * Initialize a new block.
- */
-local void init_block()
-{
- int n; /* iterates over tree elements */
-
- /* Initialize the trees. */
- for (n = 0; n < L_CODES; n++) dyn_ltree[n].Freq = 0;
- for (n = 0; n < D_CODES; n++) dyn_dtree[n].Freq = 0;
- for (n = 0; n < BL_CODES; n++) bl_tree[n].Freq = 0;
-
- dyn_ltree[END_BLOCK].Freq = 1;
- opt_len = static_len = 0L;
- last_lit = last_dist = last_flags = 0;
- flags = 0; flag_bit = 1;
-}
-
-#define SMALLEST 1
-/* Index within the heap array of least frequent node in the Huffman tree */
-
-
-/* ===========================================================================
- * Remove the smallest element from the heap and recreate the heap with
- * one less element. Updates heap and heap_len.
- */
-#define pqremove(tree, top) \
-{\
- top = heap[SMALLEST]; \
- heap[SMALLEST] = heap[heap_len--]; \
- pqdownheap(tree, SMALLEST); \
-}
-
-/* ===========================================================================
- * Compares to subtrees, using the tree depth as tie breaker when
- * the subtrees have equal frequency. This minimizes the worst case length.
- */
-#define smaller(tree, n, m) \
- (tree[n].Freq < tree[m].Freq || \
- (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
-
-/* ===========================================================================
- * Restore the heap property by moving down the tree starting at node k,
- * exchanging a node with the smallest of its two sons if necessary, stopping
- * when the heap property is re-established (each father smaller than its
- * two sons).
- */
-local void pqdownheap(tree, k)
- ct_data near *tree; /* the tree to restore */
- int k; /* node to move down */
-{
- int v = heap[k];
- int j = k << 1; /* left son of k */
- while (j <= heap_len) {
- /* Set j to the smallest of the two sons: */
- if (j < heap_len && smaller(tree, heap[j+1], heap[j])) j++;
-
- /* Exit if v is smaller than both sons */
- if (smaller(tree, v, heap[j])) break;
-
- /* Exchange v with the smallest son */
- heap[k] = heap[j]; k = j;
-
- /* And continue down the tree, setting j to the left son of k */
- j <<= 1;
- }
- heap[k] = v;
-}
-
-/* ===========================================================================
- * Compute the optimal bit lengths for a tree and update the total bit length
- * for the current block.
- * IN assertion: the fields freq and dad are set, heap[heap_max] and
- * above are the tree nodes sorted by increasing frequency.
- * OUT assertions: the field len is set to the optimal bit length, the
- * array bl_count contains the frequencies for each bit length.
- * The length opt_len is updated; static_len is also updated if stree is
- * not null.
- */
-local void gen_bitlen(desc)
- tree_desc near *desc; /* the tree descriptor */
-{
- ct_data near *tree = desc->dyn_tree;
- int near *extra = desc->extra_bits;
- int base = desc->extra_base;
- int max_code = desc->max_code;
- int max_length = desc->max_length;
- ct_data near *stree = desc->static_tree;
- int h; /* heap index */
- int n, m; /* iterate over the tree elements */
- int bits; /* bit length */
- int xbits; /* extra bits */
- ush f; /* frequency */
- int overflow = 0; /* number of elements with bit length too large */
-
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
-
- /* In a first pass, compute the optimal bit lengths (which may
- * overflow in the case of the bit length tree).
- */
- tree[heap[heap_max]].Len = 0; /* root of the heap */
-
- for (h = heap_max+1; h < HEAP_SIZE; h++) {
- n = heap[h];
- bits = tree[tree[n].Dad].Len + 1;
- if (bits > max_length) bits = max_length, overflow++;
- tree[n].Len = (ush)bits;
- /* We overwrite tree[n].Dad which is no longer needed */
-
- if (n > max_code) continue; /* not a leaf node */
-
- bl_count[bits]++;
- xbits = 0;
- if (n >= base) xbits = extra[n-base];
- f = tree[n].Freq;
- opt_len += (ulg)f * (bits + xbits);
- if (stree) static_len += (ulg)f * (stree[n].Len + xbits);
- }
- if (overflow == 0) return;
-
- Trace((stderr,"\nbit length overflow\n"));
- /* This happens for example on obj2 and pic of the Calgary corpus */
-
- /* Find the first bit length which could increase: */
- do {
- bits = max_length-1;
- while (bl_count[bits] == 0) bits--;
- bl_count[bits]--; /* move one leaf down the tree */
- bl_count[bits+1] += 2; /* move one overflow item as its brother */
- bl_count[max_length]--;
- /* The brother of the overflow item also moves one step up,
- * but this does not affect bl_count[max_length]
- */
- overflow -= 2;
- } while (overflow > 0);
-
- /* Now recompute all bit lengths, scanning in increasing frequency.
- * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
- * lengths instead of fixing only the wrong ones. This idea is taken
- * from 'ar' written by Haruhiko Okumura.)
- */
- for (bits = max_length; bits != 0; bits--) {
- n = bl_count[bits];
- while (n != 0) {
- m = heap[--h];
- if (m > max_code) continue;
- if (tree[m].Len != (unsigned) bits) {
- Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
- opt_len += ((long)bits-(long)tree[m].Len)*(long)tree[m].Freq;
- tree[m].Len = (ush)bits;
- }
- n--;
- }
- }
-}
-
-/* ===========================================================================
- * Generate the codes for a given tree and bit counts (which need not be
- * optimal).
- * IN assertion: the array bl_count contains the bit length statistics for
- * the given tree and the field len is set for all tree elements.
- * OUT assertion: the field code is set for all tree elements of non
- * zero code length.
- */
-local void gen_codes (tree, max_code)
- ct_data near *tree; /* the tree to decorate */
- int max_code; /* largest code with non zero frequency */
-{
- ush next_code[MAX_BITS+1]; /* next code value for each bit length */
- ush code = 0; /* running code value */
- int bits; /* bit index */
- int n; /* code index */
-
- /* The distribution counts are first used to generate the code values
- * without bit reversal.
- */
- for (bits = 1; bits <= MAX_BITS; bits++) {
- next_code[bits] = code = (code + bl_count[bits-1]) << 1;
- }
- /* Check that the bit counts in bl_count are consistent. The last code
- * must be all ones.
- */
- Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
- "inconsistent bit counts");
- Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
-
- for (n = 0; n <= max_code; n++) {
- int len = tree[n].Len;
- if (len == 0) continue;
- /* Now reverse the bits */
- tree[n].Code = bi_reverse(next_code[len]++, len);
-
- Tracec(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
- n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
- }
-}
-
-/* ===========================================================================
- * Construct one Huffman tree and assigns the code bit strings and lengths.
- * Update the total bit length for the current block.
- * IN assertion: the field freq is set for all tree elements.
- * OUT assertions: the fields len and code are set to the optimal bit length
- * and corresponding code. The length opt_len is updated; static_len is
- * also updated if stree is not null. The field max_code is set.
- */
-local void build_tree(desc)
- tree_desc near *desc; /* the tree descriptor */
-{
- ct_data near *tree = desc->dyn_tree;
- ct_data near *stree = desc->static_tree;
- int elems = desc->elems;
- int n, m; /* iterate over heap elements */
- int max_code = -1; /* largest code with non zero frequency */
- int node = elems; /* next internal node of the tree */
-
- /* Construct the initial heap, with least frequent element in
- * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
- * heap[0] is not used.
- */
- heap_len = 0, heap_max = HEAP_SIZE;
-
- for (n = 0; n < elems; n++) {
- if (tree[n].Freq != 0) {
- heap[++heap_len] = max_code = n;
- depth[n] = 0;
- } else {
- tree[n].Len = 0;
- }
- }
-
- /* The pkzip format requires that at least one distance code exists,
- * and that at least one bit should be sent even if there is only one
- * possible code. So to avoid special checks later on we force at least
- * two codes of non zero frequency.
- */
- while (heap_len < 2) {
- int new = heap[++heap_len] = (max_code < 2 ? ++max_code : 0);
- tree[new].Freq = 1;
- depth[new] = 0;
- opt_len--; if (stree) static_len -= stree[new].Len;
- /* new is 0 or 1 so it does not have extra bits */
- }
- desc->max_code = max_code;
-
- /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
- * establish sub-heaps of increasing lengths:
- */
- for (n = heap_len/2; n >= 1; n--) pqdownheap(tree, n);
-
- /* Construct the Huffman tree by repeatedly combining the least two
- * frequent nodes.
- */
- do {
- pqremove(tree, n); /* n = node of least frequency */
- m = heap[SMALLEST]; /* m = node of next least frequency */
-
- heap[--heap_max] = n; /* keep the nodes sorted by frequency */
- heap[--heap_max] = m;
-
- /* Create a new node father of n and m */
- tree[node].Freq = tree[n].Freq + tree[m].Freq;
- depth[node] = (uch) (MAX(depth[n], depth[m]) + 1);
- tree[n].Dad = tree[m].Dad = (ush)node;
-#ifdef DUMP_BL_TREE
- if (tree == bl_tree) {
- fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
- node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
- }
-#endif
- /* and insert the new node in the heap */
- heap[SMALLEST] = node++;
- pqdownheap(tree, SMALLEST);
-
- } while (heap_len >= 2);
-
- heap[--heap_max] = heap[SMALLEST];
-
- /* At this point, the fields freq and dad are set. We can now
- * generate the bit lengths.
- */
- gen_bitlen((tree_desc near *)desc);
-
- /* The field len is now set, we can generate the bit codes */
- gen_codes ((ct_data near *)tree, max_code);
-}
-
-/* ===========================================================================
- * Scan a literal or distance tree to determine the frequencies of the codes
- * in the bit length tree. Updates opt_len to take into account the repeat
- * counts. (The contribution of the bit length codes will be added later
- * during the construction of bl_tree.)
- */
-local void scan_tree (tree, max_code)
- ct_data near *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- if (nextlen == 0) max_count = 138, min_count = 3;
- tree[max_code+1].Len = (ush)0xffff; /* guard */
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- bl_tree[curlen].Freq += count;
- } else if (curlen != 0) {
- if (curlen != prevlen) bl_tree[curlen].Freq++;
- bl_tree[REP_3_6].Freq++;
- } else if (count <= 10) {
- bl_tree[REPZ_3_10].Freq++;
- } else {
- bl_tree[REPZ_11_138].Freq++;
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Send a literal or distance tree in compressed form, using the codes in
- * bl_tree.
- */
-local void send_tree (tree, max_code)
- ct_data near *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- /* tree[max_code+1].Len = -1; */ /* guard already set */
- if (nextlen == 0) max_count = 138, min_count = 3;
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- do { send_code(curlen, bl_tree); } while (--count != 0);
-
- } else if (curlen != 0) {
- if (curlen != prevlen) {
- send_code(curlen, bl_tree); count--;
- }
- Assert(count >= 3 && count <= 6, " 3_6?");
- send_code(REP_3_6, bl_tree); send_bits(count-3, 2);
-
- } else if (count <= 10) {
- send_code(REPZ_3_10, bl_tree); send_bits(count-3, 3);
-
- } else {
- send_code(REPZ_11_138, bl_tree); send_bits(count-11, 7);
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Construct the Huffman tree for the bit lengths and return the index in
- * bl_order of the last bit length code to send.
- */
-local int build_bl_tree()
-{
- int max_blindex; /* index of last bit length code of non zero freq */
-
- /* Determine the bit length frequencies for literal and distance trees */
- scan_tree((ct_data near *)dyn_ltree, l_desc.max_code);
- scan_tree((ct_data near *)dyn_dtree, d_desc.max_code);
-
- /* Build the bit length tree: */
- build_tree((tree_desc near *)(&bl_desc));
- /* opt_len now includes the length of the tree representations, except
- * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
- */
-
- /* Determine the number of bit length codes to send. The pkzip format
- * requires that at least 4 bit length codes be sent. (appnote.txt says
- * 3 but the actual value used is 4.)
- */
- for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
- if (bl_tree[bl_order[max_blindex]].Len != 0) break;
- }
- /* Update opt_len to include the bit length tree and counts */
- opt_len += 3*(max_blindex+1) + 5+5+4;
- Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", opt_len, static_len));
-
- return max_blindex;
-}
-
-/* ===========================================================================
- * Send the header for a block using dynamic Huffman trees: the counts, the
- * lengths of the bit length codes, the literal tree and the distance tree.
- * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
- */
-local void send_all_trees(lcodes, dcodes, blcodes)
- int lcodes, dcodes, blcodes; /* number of codes for each tree */
-{
- int rank; /* index in bl_order */
-
- Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
- Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
- "too many codes");
- Tracev((stderr, "\nbl counts: "));
- send_bits(lcodes-257, 5); /* not +255 as stated in appnote.txt */
- send_bits(dcodes-1, 5);
- send_bits(blcodes-4, 4); /* not -3 as stated in appnote.txt */
- for (rank = 0; rank < blcodes; rank++) {
- Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
- send_bits(bl_tree[bl_order[rank]].Len, 3);
- }
- Tracev((stderr, "\nbl tree: sent %ld", bits_sent));
-
- send_tree((ct_data near *)dyn_ltree, lcodes-1); /* send the literal tree */
- Tracev((stderr, "\nlit tree: sent %ld", bits_sent));
-
- send_tree((ct_data near *)dyn_dtree, dcodes-1); /* send the distance tree */
- Tracev((stderr, "\ndist tree: sent %ld", bits_sent));
-}
-
-/* ===========================================================================
- * Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file. This function
- * returns the total compressed length for the file so far.
- */
-ulg flush_block(buf, stored_len, eof)
- char *buf; /* input block, or NULL if too old */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
-{
- ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
- int max_blindex; /* index of last bit length code of non zero freq */
-
- flag_buf[last_flags] = flags; /* Save the flags for the last 8 items */
-
- /* Check if the file is ascii or binary */
- if (*file_type == (ush)UNKNOWN) set_file_type();
-
- /* Construct the literal and distance trees */
- build_tree((tree_desc near *)(&l_desc));
- Tracev((stderr, "\nlit data: dyn %ld, stat %ld", opt_len, static_len));
-
- build_tree((tree_desc near *)(&d_desc));
- Tracev((stderr, "\ndist data: dyn %ld, stat %ld", opt_len, static_len));
- /* At this point, opt_len and static_len are the total bit lengths of
- * the compressed block data, excluding the tree representations.
- */
-
- /* Build the bit length tree for the above two trees, and get the index
- * in bl_order of the last bit length code to send.
- */
- max_blindex = build_bl_tree();
-
- /* Determine the best encoding. Compute first the block length in bytes */
- opt_lenb = (opt_len+3+7)>>3;
- static_lenb = (static_len+3+7)>>3;
- input_len += stored_len; /* for debugging only */
-
- Trace((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
- opt_lenb, opt_len, static_lenb, static_len, stored_len,
- last_lit, last_dist));
-
- if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
-
- /* If compression failed and this is the first and last block,
- * and if the zip file can be seeked (to rewrite the local header),
- * the whole file is transformed into a stored file:
- */
-#ifdef FORCE_METHOD
- if (level == 1 && eof && compressed_len == 0L) { /* force stored file */
-#else
- if (stored_len <= opt_lenb && eof && compressed_len == 0L && seekable()) {
-#endif
- /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
- if (buf == (char*)0) error ("block vanished");
-
- copy_block(buf, (unsigned)stored_len, 0); /* without header */
- compressed_len = stored_len << 3;
- *file_method = STORED;
-
-#ifdef FORCE_METHOD
- } else if (level == 2 && buf != (char*)0) { /* force stored block */
-#else
- } else if (stored_len+4 <= opt_lenb && buf != (char*)0) {
- /* 4: two words for the lengths */
-#endif
- /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
- * Otherwise we can't have processed more than WSIZE input bytes since
- * the last block flush, because compression would have been
- * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
- * transform a block into a stored block.
- */
- send_bits((STORED_BLOCK<<1)+eof, 3); /* send block type */
- compressed_len = (compressed_len + 3 + 7) & ~7L;
- compressed_len += (stored_len + 4) << 3;
-
- copy_block(buf, (unsigned)stored_len, 1); /* with header */
-
-#ifdef FORCE_METHOD
- } else if (level == 3) { /* force static trees */
-#else
- } else if (static_lenb == opt_lenb) {
-#endif
- send_bits((STATIC_TREES<<1)+eof, 3);
- compress_block((ct_data near *)static_ltree, (ct_data near *)static_dtree);
- compressed_len += 3 + static_len;
- } else {
- send_bits((DYN_TREES<<1)+eof, 3);
- send_all_trees(l_desc.max_code+1, d_desc.max_code+1, max_blindex+1);
- compress_block((ct_data near *)dyn_ltree, (ct_data near *)dyn_dtree);
- compressed_len += 3 + opt_len;
- }
- Assert (compressed_len == bits_sent, "bad compressed size");
- init_block();
-
- if (eof) {
- Assert (input_len == isize, "bad input size");
- bi_windup();
- compressed_len += 7; /* align on byte boundary */
- }
- Tracev((stderr,"\ncomprlen %lu(%lu) ", compressed_len>>3,
- compressed_len-7*eof));
-
- return compressed_len >> 3;
-}
-
-/* ===========================================================================
- * Save the match info and tally the frequency counts. Return true if
- * the current block must be flushed.
- */
-int ct_tally (dist, lc)
- int dist; /* distance of matched string */
- int lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
-{
- l_buf[last_lit++] = (uch)lc;
- if (dist == 0) {
- /* lc is the unmatched char */
- dyn_ltree[lc].Freq++;
- } else {
- /* Here, lc is the match length - MIN_MATCH */
- dist--; /* dist = match distance - 1 */
- Assert((ush)dist < (ush)MAX_DIST &&
- (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
- (ush)d_code(dist) < (ush)D_CODES, "ct_tally: bad match");
-
- dyn_ltree[length_code[lc]+LITERALS+1].Freq++;
- dyn_dtree[d_code(dist)].Freq++;
-
- d_buf[last_dist++] = (ush)dist;
- flags |= flag_bit;
- }
- flag_bit <<= 1;
-
- /* Output the flags if they fill a byte: */
- if ((last_lit & 7) == 0) {
- flag_buf[last_flags++] = flags;
- flags = 0, flag_bit = 1;
- }
- /* Try to guess if it is profitable to stop the current block here */
- if (level > 2 && (last_lit & 0xfff) == 0) {
- /* Compute an upper bound for the compressed length */
- ulg out_length = (ulg)last_lit*8L;
- ulg in_length = (ulg)strstart-block_start;
- int dcode;
- for (dcode = 0; dcode < D_CODES; dcode++) {
- out_length += (ulg)dyn_dtree[dcode].Freq*(5L+extra_dbits[dcode]);
- }
- out_length >>= 3;
- Trace((stderr,"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
- last_lit, last_dist, in_length, out_length,
- 100L - out_length*100L/in_length));
- if (last_dist < last_lit/2 && out_length < in_length/2) return 1;
- }
- return (last_lit == LIT_BUFSIZE-1 || last_dist == DIST_BUFSIZE);
- /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K
- * on 16 bit machines and because stored blocks are restricted to
- * 64K-1 bytes.
- */
-}
-
-/* ===========================================================================
- * Send the block data compressed using the given Huffman trees
- */
-local void compress_block(ltree, dtree)
- ct_data near *ltree; /* literal tree */
- ct_data near *dtree; /* distance tree */
-{
- unsigned dist; /* distance of matched string */
- int lc; /* match length or unmatched char (if dist == 0) */
- unsigned lx = 0; /* running index in l_buf */
- unsigned dx = 0; /* running index in d_buf */
- unsigned fx = 0; /* running index in flag_buf */
- uch flag = 0; /* current flags */
- unsigned code; /* the code to send */
- int extra; /* number of extra bits to send */
-
- if (last_lit != 0) do {
- if ((lx & 7) == 0) flag = flag_buf[fx++];
- lc = l_buf[lx++];
- if ((flag & 1) == 0) {
- send_code(lc, ltree); /* send a literal byte */
- Tracecv(isgraph(lc), (stderr," '%c' ", lc));
- } else {
- /* Here, lc is the match length - MIN_MATCH */
- code = length_code[lc];
- send_code(code+LITERALS+1, ltree); /* send the length code */
- extra = extra_lbits[code];
- if (extra != 0) {
- lc -= base_length[code];
- send_bits(lc, extra); /* send the extra length bits */
- }
- dist = d_buf[dx++];
- /* Here, dist is the match distance - 1 */
- code = d_code(dist);
- Assert (code < D_CODES, "bad d_code");
-
- send_code(code, dtree); /* send the distance code */
- extra = extra_dbits[code];
- if (extra != 0) {
- dist -= base_dist[code];
- send_bits(dist, extra); /* send the extra distance bits */
- }
- } /* literal or match pair ? */
- flag >>= 1;
- } while (lx < last_lit);
-
- send_code(END_BLOCK, ltree);
-}
-
-/* ===========================================================================
- * Set the file type to ASCII or BINARY, using a crude approximation:
- * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.
- * IN assertion: the fields freq of dyn_ltree are set and the total of all
- * frequencies does not exceed 64K (to fit in an int on 16 bit machines).
- */
-local void set_file_type()
-{
- int n = 0;
- unsigned ascii_freq = 0;
- unsigned bin_freq = 0;
- while (n < 7) bin_freq += dyn_ltree[n++].Freq;
- while (n < 128) ascii_freq += dyn_ltree[n++].Freq;
- while (n < LITERALS) bin_freq += dyn_ltree[n++].Freq;
- *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
- if (*file_type == BINARY && translate_eol) {
- WARN((stderr, "-l used on binary file", ""));
- }
-}
diff --git a/gnu/usr.bin/gzip/unlzh.c b/gnu/usr.bin/gzip/unlzh.c
deleted file mode 100644
index f639911..0000000
--- a/gnu/usr.bin/gzip/unlzh.c
+++ /dev/null
@@ -1,401 +0,0 @@
-/* unlzh.c -- decompress files in SCO compress -H (LZH) format.
- * The code in this file is directly derived from the public domain 'ar002'
- * written by Haruhiko Okumura.
- */
-
-#ifdef RCSID
-static char rcsid[] = "$Id$";
-#endif
-
-#include <stdio.h>
-
-#include "tailor.h"
-#include "gzip.h"
-#include "lzw.h" /* just for consistency checking */
-
-/* decode.c */
-
-local unsigned decode OF((unsigned count, uch buffer[]));
-local void decode_start OF((void));
-
-/* huf.c */
-local void huf_decode_start OF((void));
-local unsigned decode_c OF((void));
-local unsigned decode_p OF((void));
-local void read_pt_len OF((int nn, int nbit, int i_special));
-local void read_c_len OF((void));
-
-/* io.c */
-local void fillbuf OF((int n));
-local unsigned getbits OF((int n));
-local void init_getbits OF((void));
-
-/* maketbl.c */
-
-local void make_table OF((int nchar, uch bitlen[],
- int tablebits, ush table[]));
-
-
-#define DICBIT 13 /* 12(-lh4-) or 13(-lh5-) */
-#define DICSIZ ((unsigned) 1 << DICBIT)
-
-#ifndef CHAR_BIT
-# define CHAR_BIT 8
-#endif
-
-#ifndef UCHAR_MAX
-# define UCHAR_MAX 255
-#endif
-
-#define BITBUFSIZ (CHAR_BIT * 2 * sizeof(char))
-/* Do not use CHAR_BIT * sizeof(bitbuf), does not work on machines
- * for which short is not on 16 bits (Cray).
- */
-
-/* encode.c and decode.c */
-
-#define MAXMATCH 256 /* formerly F (not more than UCHAR_MAX + 1) */
-#define THRESHOLD 3 /* choose optimal value */
-
-/* huf.c */
-
-#define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD)
- /* alphabet = {0, 1, 2, ..., NC - 1} */
-#define CBIT 9 /* $\lfloor \log_2 NC \rfloor + 1$ */
-#define CODE_BIT 16 /* codeword length */
-
-#define NP (DICBIT + 1)
-#define NT (CODE_BIT + 3)
-#define PBIT 4 /* smallest integer such that (1U << PBIT) > NP */
-#define TBIT 5 /* smallest integer such that (1U << TBIT) > NT */
-#if NT > NP
-# define NPT NT
-#else
-# define NPT NP
-#endif
-
-/* local ush left[2 * NC - 1]; */
-/* local ush right[2 * NC - 1]; */
-#define left prev
-#define right head
-#if NC > (1<<(BITS-2))
- error cannot overlay left+right and prev
-#endif
-
-/* local uch c_len[NC]; */
-#define c_len outbuf
-#if NC > OUTBUFSIZ
- error cannot overlay c_len and outbuf
-#endif
-
-local uch pt_len[NPT];
-local unsigned blocksize;
-local ush pt_table[256];
-
-/* local ush c_table[4096]; */
-#define c_table d_buf
-#if (DIST_BUFSIZE-1) < 4095
- error cannot overlay c_table and d_buf
-#endif
-
-/***********************************************************
- io.c -- input/output
-***********************************************************/
-
-local ush bitbuf;
-local unsigned subbitbuf;
-local int bitcount;
-
-local void fillbuf(n) /* Shift bitbuf n bits left, read n bits */
- int n;
-{
- bitbuf <<= n;
- while (n > bitcount) {
- bitbuf |= subbitbuf << (n -= bitcount);
- subbitbuf = (unsigned)try_byte();
- if ((int)subbitbuf == EOF) subbitbuf = 0;
- bitcount = CHAR_BIT;
- }
- bitbuf |= subbitbuf >> (bitcount -= n);
-}
-
-local unsigned getbits(n)
- int n;
-{
- unsigned x;
-
- x = bitbuf >> (BITBUFSIZ - n); fillbuf(n);
- return x;
-}
-
-local void init_getbits()
-{
- bitbuf = 0; subbitbuf = 0; bitcount = 0;
- fillbuf(BITBUFSIZ);
-}
-
-/***********************************************************
- maketbl.c -- make table for decoding
-***********************************************************/
-
-local void make_table(nchar, bitlen, tablebits, table)
- int nchar;
- uch bitlen[];
- int tablebits;
- ush table[];
-{
- ush count[17], weight[17], start[18], *p;
- unsigned i, k, len, ch, jutbits, avail, nextcode, mask;
-
- for (i = 1; i <= 16; i++) count[i] = 0;
- for (i = 0; i < (unsigned)nchar; i++) count[bitlen[i]]++;
-
- start[1] = 0;
- for (i = 1; i <= 16; i++)
- start[i + 1] = start[i] + (count[i] << (16 - i));
- if ((start[17] & 0xffff) != 0)
- error("Bad table\n");
-
- jutbits = 16 - tablebits;
- for (i = 1; i <= (unsigned)tablebits; i++) {
- start[i] >>= jutbits;
- weight[i] = (unsigned) 1 << (tablebits - i);
- }
- while (i <= 16) {
- weight[i] = (unsigned) 1 << (16 - i);
- i++;
- }
-
- i = start[tablebits + 1] >> jutbits;
- if (i != 0) {
- k = 1 << tablebits;
- while (i != k) table[i++] = 0;
- }
-
- avail = nchar;
- mask = (unsigned) 1 << (15 - tablebits);
- for (ch = 0; ch < (unsigned)nchar; ch++) {
- if ((len = bitlen[ch]) == 0) continue;
- nextcode = start[len] + weight[len];
- if (len <= (unsigned)tablebits) {
- for (i = start[len]; i < nextcode; i++) table[i] = ch;
- } else {
- k = start[len];
- p = &table[k >> jutbits];
- i = len - tablebits;
- while (i != 0) {
- if (*p == 0) {
- right[avail] = left[avail] = 0;
- *p = avail++;
- }
- if (k & mask) p = &right[*p];
- else p = &left[*p];
- k <<= 1; i--;
- }
- *p = ch;
- }
- start[len] = nextcode;
- }
-}
-
-/***********************************************************
- huf.c -- static Huffman
-***********************************************************/
-
-local void read_pt_len(nn, nbit, i_special)
- int nn;
- int nbit;
- int i_special;
-{
- int i, c, n;
- unsigned mask;
-
- n = getbits(nbit);
- if (n == 0) {
- c = getbits(nbit);
- for (i = 0; i < nn; i++) pt_len[i] = 0;
- for (i = 0; i < 256; i++) pt_table[i] = c;
- } else {
- i = 0;
- while (i < n) {
- c = bitbuf >> (BITBUFSIZ - 3);
- if (c == 7) {
- mask = (unsigned) 1 << (BITBUFSIZ - 1 - 3);
- while (mask & bitbuf) { mask >>= 1; c++; }
- }
- fillbuf((c < 7) ? 3 : c - 3);
- pt_len[i++] = c;
- if (i == i_special) {
- c = getbits(2);
- while (--c >= 0) pt_len[i++] = 0;
- }
- }
- while (i < nn) pt_len[i++] = 0;
- make_table(nn, pt_len, 8, pt_table);
- }
-}
-
-local void read_c_len()
-{
- int i, c, n;
- unsigned mask;
-
- n = getbits(CBIT);
- if (n == 0) {
- c = getbits(CBIT);
- for (i = 0; i < NC; i++) c_len[i] = 0;
- for (i = 0; i < 4096; i++) c_table[i] = c;
- } else {
- i = 0;
- while (i < n) {
- c = pt_table[bitbuf >> (BITBUFSIZ - 8)];
- if (c >= NT) {
- mask = (unsigned) 1 << (BITBUFSIZ - 1 - 8);
- do {
- if (bitbuf & mask) c = right[c];
- else c = left [c];
- mask >>= 1;
- } while (c >= NT);
- }
- fillbuf((int) pt_len[c]);
- if (c <= 2) {
- if (c == 0) c = 1;
- else if (c == 1) c = getbits(4) + 3;
- else c = getbits(CBIT) + 20;
- while (--c >= 0) c_len[i++] = 0;
- } else c_len[i++] = c - 2;
- }
- while (i < NC) c_len[i++] = 0;
- make_table(NC, c_len, 12, c_table);
- }
-}
-
-local unsigned decode_c()
-{
- unsigned j, mask;
-
- if (blocksize == 0) {
- blocksize = getbits(16);
- if (blocksize == 0) {
- return NC; /* end of file */
- }
- read_pt_len(NT, TBIT, 3);
- read_c_len();
- read_pt_len(NP, PBIT, -1);
- }
- blocksize--;
- j = c_table[bitbuf >> (BITBUFSIZ - 12)];
- if (j >= NC) {
- mask = (unsigned) 1 << (BITBUFSIZ - 1 - 12);
- do {
- if (bitbuf & mask) j = right[j];
- else j = left [j];
- mask >>= 1;
- } while (j >= NC);
- }
- fillbuf((int) c_len[j]);
- return j;
-}
-
-local unsigned decode_p()
-{
- unsigned j, mask;
-
- j = pt_table[bitbuf >> (BITBUFSIZ - 8)];
- if (j >= NP) {
- mask = (unsigned) 1 << (BITBUFSIZ - 1 - 8);
- do {
- if (bitbuf & mask) j = right[j];
- else j = left [j];
- mask >>= 1;
- } while (j >= NP);
- }
- fillbuf((int) pt_len[j]);
- if (j != 0) j = ((unsigned) 1 << (j - 1)) + getbits((int) (j - 1));
- return j;
-}
-
-local void huf_decode_start()
-{
- init_getbits(); blocksize = 0;
-}
-
-/***********************************************************
- decode.c
-***********************************************************/
-
-local int j; /* remaining bytes to copy */
-local int done; /* set at end of input */
-
-local void decode_start()
-{
- huf_decode_start();
- j = 0;
- done = 0;
-}
-
-/* Decode the input and return the number of decoded bytes put in buffer
- */
-local unsigned decode(count, buffer)
- unsigned count;
- uch buffer[];
- /* The calling function must keep the number of
- bytes to be processed. This function decodes
- either 'count' bytes or 'DICSIZ' bytes, whichever
- is smaller, into the array 'buffer[]' of size
- 'DICSIZ' or more.
- Call decode_start() once for each new file
- before calling this function.
- */
-{
- local unsigned i;
- unsigned r, c;
-
- r = 0;
- while (--j >= 0) {
- buffer[r] = buffer[i];
- i = (i + 1) & (DICSIZ - 1);
- if (++r == count) return r;
- }
- for ( ; ; ) {
- c = decode_c();
- if (c == NC) {
- done = 1;
- return r;
- }
- if (c <= UCHAR_MAX) {
- buffer[r] = c;
- if (++r == count) return r;
- } else {
- j = c - (UCHAR_MAX + 1 - THRESHOLD);
- i = (r - decode_p() - 1) & (DICSIZ - 1);
- while (--j >= 0) {
- buffer[r] = buffer[i];
- i = (i + 1) & (DICSIZ - 1);
- if (++r == count) return r;
- }
- }
- }
-}
-
-
-/* ===========================================================================
- * Unlzh in to out. Return OK or ERROR.
- */
-int unlzh(in, out)
- int in;
- int out;
-{
- unsigned n;
- ifd = in;
- ofd = out;
-
- decode_start();
- while (!done) {
- n = decode((unsigned) DICSIZ, window);
- if (!test && n > 0) {
- write_buf(out, (char*)window, n);
- }
- }
- return OK;
-}
diff --git a/gnu/usr.bin/gzip/unlzw.c b/gnu/usr.bin/gzip/unlzw.c
deleted file mode 100644
index 470d0ed..0000000
--- a/gnu/usr.bin/gzip/unlzw.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/* unlzw.c -- decompress files in LZW format.
- * The code in this file is directly derived from the public domain 'compress'
- * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
- * Ken Turkowski, Dave Mack and Peter Jannesen.
- *
- * This is a temporary version which will be rewritten in some future version
- * to accommodate in-memory decompression.
- */
-
-#ifdef RCSID
-static char rcsid[] = "$Id$";
-#endif
-
-#include <sys/types.h>
-
-#include "tailor.h"
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifndef NO_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#include "gzip.h"
-#include "lzw.h"
-
-typedef unsigned char char_type;
-typedef long code_int;
-typedef unsigned long count_int;
-typedef unsigned short count_short;
-typedef unsigned long cmp_code_int;
-
-#define MAXCODE(n) (1L << (n))
-
-#ifndef REGISTERS
-# define REGISTERS 2
-#endif
-#define REG1
-#define REG2
-#define REG3
-#define REG4
-#define REG5
-#define REG6
-#define REG7
-#define REG8
-#define REG9
-#define REG10
-#define REG11
-#define REG12
-#define REG13
-#define REG14
-#define REG15
-#define REG16
-#if REGISTERS >= 1
-# undef REG1
-# define REG1 register
-#endif
-#if REGISTERS >= 2
-# undef REG2
-# define REG2 register
-#endif
-#if REGISTERS >= 3
-# undef REG3
-# define REG3 register
-#endif
-#if REGISTERS >= 4
-# undef REG4
-# define REG4 register
-#endif
-#if REGISTERS >= 5
-# undef REG5
-# define REG5 register
-#endif
-#if REGISTERS >= 6
-# undef REG6
-# define REG6 register
-#endif
-#if REGISTERS >= 7
-# undef REG7
-# define REG7 register
-#endif
-#if REGISTERS >= 8
-# undef REG8
-# define REG8 register
-#endif
-#if REGISTERS >= 9
-# undef REG9
-# define REG9 register
-#endif
-#if REGISTERS >= 10
-# undef REG10
-# define REG10 register
-#endif
-#if REGISTERS >= 11
-# undef REG11
-# define REG11 register
-#endif
-#if REGISTERS >= 12
-# undef REG12
-# define REG12 register
-#endif
-#if REGISTERS >= 13
-# undef REG13
-# define REG13 register
-#endif
-#if REGISTERS >= 14
-# undef REG14
-# define REG14 register
-#endif
-#if REGISTERS >= 15
-# undef REG15
-# define REG15 register
-#endif
-#if REGISTERS >= 16
-# undef REG16
-# define REG16 register
-#endif
-
-#ifndef BYTEORDER
-# define BYTEORDER 0000
-#endif
-
-#ifndef NOALLIGN
-# define NOALLIGN 0
-#endif
-
-
-union bytes {
- long word;
- struct {
-#if BYTEORDER == 4321
- char_type b1;
- char_type b2;
- char_type b3;
- char_type b4;
-#else
-#if BYTEORDER == 1234
- char_type b4;
- char_type b3;
- char_type b2;
- char_type b1;
-#else
-# undef BYTEORDER
- int dummy;
-#endif
-#endif
- } bytes;
-};
-
-#if BYTEORDER == 4321 && NOALLIGN == 1
-# define input(b,o,c,n,m){ \
- (c) = (*(long *)(&(b)[(o)>>3])>>((o)&0x7))&(m); \
- (o) += (n); \
- }
-#else
-# define input(b,o,c,n,m){ \
- REG1 char_type *p = &(b)[(o)>>3]; \
- (c) = ((((long)(p[0]))|((long)(p[1])<<8)| \
- ((long)(p[2])<<16))>>((o)&0x7))&(m); \
- (o) += (n); \
- }
-#endif
-
-#ifndef MAXSEG_64K
- /* DECLARE(ush, tab_prefix, (1<<BITS)); -- prefix code */
-# define tab_prefixof(i) tab_prefix[i]
-# define clear_tab_prefixof() memzero(tab_prefix, 256);
-#else
- /* DECLARE(ush, tab_prefix0, (1<<(BITS-1)); -- prefix for even codes */
- /* DECLARE(ush, tab_prefix1, (1<<(BITS-1)); -- prefix for odd codes */
- ush *tab_prefix[2];
-# define tab_prefixof(i) tab_prefix[(i)&1][(i)>>1]
-# define clear_tab_prefixof() \
- memzero(tab_prefix0, 128), \
- memzero(tab_prefix1, 128);
-#endif
-#define de_stack ((char_type *)(&d_buf[DIST_BUFSIZE-1]))
-#define tab_suffixof(i) tab_suffix[i]
-
-int block_mode = BLOCK_MODE; /* block compress mode -C compatible with 2.0 */
-
-/* ============================================================================
- * Decompress in to out. This routine adapts to the codes in the
- * file building the "string" table on-the-fly; requiring no table to
- * be stored in the compressed file.
- * IN assertions: the buffer inbuf contains already the beginning of
- * the compressed data, from offsets iptr to insize-1 included.
- * The magic header has already been checked and skipped.
- * bytes_in and bytes_out have been initialized.
- */
-int unlzw(in, out)
- int in, out; /* input and output file descriptors */
-{
- REG2 char_type *stackp;
- REG3 code_int code;
- REG4 int finchar;
- REG5 code_int oldcode;
- REG6 code_int incode;
- REG7 long inbits;
- REG8 long posbits;
- REG9 int outpos;
-/* REG10 int insize; (global) */
- REG11 unsigned bitmask;
- REG12 code_int free_ent;
- REG13 code_int maxcode;
- REG14 code_int maxmaxcode;
- REG15 int n_bits;
- REG16 int rsize;
-
-#ifdef MAXSEG_64K
- tab_prefix[0] = tab_prefix0;
- tab_prefix[1] = tab_prefix1;
-#endif
- maxbits = get_byte();
- block_mode = maxbits & BLOCK_MODE;
- if ((maxbits & LZW_RESERVED) != 0) {
- WARN((stderr, "\n%s: %s: warning, unknown flags 0x%x\n",
- progname, ifname, maxbits & LZW_RESERVED));
- }
- maxbits &= BIT_MASK;
- maxmaxcode = MAXCODE(maxbits);
-
- if (maxbits > BITS) {
- fprintf(stderr,
- "\n%s: %s: compressed with %d bits, can only handle %d bits\n",
- progname, ifname, maxbits, BITS);
- exit_code = ERROR;
- return ERROR;
- }
- rsize = insize;
- maxcode = MAXCODE(n_bits = INIT_BITS)-1;
- bitmask = (1<<n_bits)-1;
- oldcode = -1;
- finchar = 0;
- outpos = 0;
- posbits = inptr<<3;
-
- free_ent = ((block_mode) ? FIRST : 256);
-
- clear_tab_prefixof(); /* Initialize the first 256 entries in the table. */
-
- for (code = 255 ; code >= 0 ; --code) {
- tab_suffixof(code) = (char_type)code;
- }
- do {
- REG1 int i;
- int e;
- int o;
-
- resetbuf:
- e = insize-(o = (posbits>>3));
-
- for (i = 0 ; i < e ; ++i) {
- inbuf[i] = inbuf[i+o];
- }
- insize = e;
- posbits = 0;
-
- if (insize < INBUF_EXTRA) {
- if ((rsize = read(in, (char*)inbuf+insize, INBUFSIZ)) == EOF) {
- read_error();
- }
- insize += rsize;
- bytes_in += (ulg)rsize;
- }
- inbits = ((rsize != 0) ? ((long)insize - insize%n_bits)<<3 :
- ((long)insize<<3)-(n_bits-1));
-
- while (inbits > posbits) {
- if (free_ent > maxcode) {
- posbits = ((posbits-1) +
- ((n_bits<<3)-(posbits-1+(n_bits<<3))%(n_bits<<3)));
- ++n_bits;
- if (n_bits == maxbits) {
- maxcode = maxmaxcode;
- } else {
- maxcode = MAXCODE(n_bits)-1;
- }
- bitmask = (1<<n_bits)-1;
- goto resetbuf;
- }
- input(inbuf,posbits,code,n_bits,bitmask);
- Tracev((stderr, "%d ", code));
-
- if (oldcode == -1) {
- if (code >= 256) error("corrupt input.");
- outbuf[outpos++] = (char_type)(finchar = (int)(oldcode=code));
- continue;
- }
- if (code == CLEAR && block_mode) {
- clear_tab_prefixof();
- free_ent = FIRST - 1;
- posbits = ((posbits-1) +
- ((n_bits<<3)-(posbits-1+(n_bits<<3))%(n_bits<<3)));
- maxcode = MAXCODE(n_bits = INIT_BITS)-1;
- bitmask = (1<<n_bits)-1;
- goto resetbuf;
- }
- incode = code;
- stackp = de_stack;
-
- if (code >= free_ent) { /* Special case for KwKwK string. */
- if (code > free_ent) {
-#ifdef DEBUG
- char_type *p;
-
- posbits -= n_bits;
- p = &inbuf[posbits>>3];
- fprintf(stderr,
- "code:%ld free_ent:%ld n_bits:%d insize:%u\n",
- code, free_ent, n_bits, insize);
- fprintf(stderr,
- "posbits:%ld inbuf:%02X %02X %02X %02X %02X\n",
- posbits, p[-1],p[0],p[1],p[2],p[3]);
-#endif
- if (!test && outpos > 0) {
- write_buf(out, (char*)outbuf, outpos);
- bytes_out += (ulg)outpos;
- }
- error(to_stdout ? "corrupt input." :
- "corrupt input. Use zcat to recover some data.");
- }
- *--stackp = (char_type)finchar;
- code = oldcode;
- }
-
- while ((cmp_code_int)code >= (cmp_code_int)256) {
- /* Generate output characters in reverse order */
- *--stackp = tab_suffixof(code);
- code = tab_prefixof(code);
- }
- *--stackp = (char_type)(finchar = tab_suffixof(code));
-
- /* And put them out in forward order */
- {
- REG1 int i;
-
- if (outpos+(i = (de_stack-stackp)) >= OUTBUFSIZ) {
- do {
- if (i > OUTBUFSIZ-outpos) i = OUTBUFSIZ-outpos;
-
- if (i > 0) {
- memcpy(outbuf+outpos, stackp, i);
- outpos += i;
- }
- if (outpos >= OUTBUFSIZ) {
- if (!test) {
- write_buf(out, (char*)outbuf, outpos);
- bytes_out += (ulg)outpos;
- }
- outpos = 0;
- }
- stackp+= i;
- } while ((i = (de_stack-stackp)) > 0);
- } else {
- memcpy(outbuf+outpos, stackp, i);
- outpos += i;
- }
- }
-
- if ((code = free_ent) < maxmaxcode) { /* Generate the new entry. */
-
- tab_prefixof(code) = (unsigned short)oldcode;
- tab_suffixof(code) = (char_type)finchar;
- free_ent = code+1;
- }
- oldcode = incode; /* Remember previous code. */
- }
- } while (rsize != 0);
-
- if (!test && outpos > 0) {
- write_buf(out, (char*)outbuf, outpos);
- bytes_out += (ulg)outpos;
- }
- return OK;
-}
diff --git a/gnu/usr.bin/gzip/unpack.c b/gnu/usr.bin/gzip/unpack.c
deleted file mode 100644
index a9bc18e..0000000
--- a/gnu/usr.bin/gzip/unpack.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/* unpack.c -- decompress files in pack format.
- * Copyright (C) 1992-1993 Jean-loup Gailly
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#ifdef RCSID
-static char rcsid[] = "$Id$";
-#endif
-
-#include "tailor.h"
-#include "gzip.h"
-#include "crypt.h"
-
-#define MIN(a,b) ((a) <= (b) ? (a) : (b))
-/* The arguments must not have side effects. */
-
-#define MAX_BITLEN 25
-/* Maximum length of Huffman codes. (Minor modifications to the code
- * would be needed to support 32 bits codes, but pack never generates
- * more than 24 bits anyway.)
- */
-
-#define LITERALS 256
-/* Number of literals, excluding the End of Block (EOB) code */
-
-#define MAX_PEEK 12
-/* Maximum number of 'peek' bits used to optimize traversal of the
- * Huffman tree.
- */
-
-local ulg orig_len; /* original uncompressed length */
-local int max_len; /* maximum bit length of Huffman codes */
-
-local uch literal[LITERALS];
-/* The literal bytes present in the Huffman tree. The EOB code is not
- * represented.
- */
-
-local int lit_base[MAX_BITLEN+1];
-/* All literals of a given bit length are contiguous in literal[] and
- * have contiguous codes. literal[code+lit_base[len]] is the literal
- * for a code of len bits.
- */
-
-local int leaves [MAX_BITLEN+1]; /* Number of leaves for each bit length */
-local int parents[MAX_BITLEN+1]; /* Number of parents for each bit length */
-
-local int peek_bits; /* Number of peek bits currently used */
-
-/* local uch prefix_len[1 << MAX_PEEK]; */
-#define prefix_len outbuf
-/* For each bit pattern b of peek_bits bits, prefix_len[b] is the length
- * of the Huffman code starting with a prefix of b (upper bits), or 0
- * if all codes of prefix b have more than peek_bits bits. It is not
- * necessary to have a huge table (large MAX_PEEK) because most of the
- * codes encountered in the input stream are short codes (by construction).
- * So for most codes a single lookup will be necessary.
- */
-#if (1<<MAX_PEEK) > OUTBUFSIZ
- error cannot overlay prefix_len and outbuf
-#endif
-
-local ulg bitbuf;
-/* Bits are added on the low part of bitbuf and read from the high part. */
-
-local int valid; /* number of valid bits in bitbuf */
-/* all bits above the last valid bit are always zero */
-
-/* Set code to the next 'bits' input bits without skipping them. code
- * must be the name of a simple variable and bits must not have side effects.
- * IN assertions: bits <= 25 (so that we still have room for an extra byte
- * when valid is only 24), and mask = (1<<bits)-1.
- */
-#define look_bits(code,bits,mask) \
-{ \
- while (valid < (bits)) bitbuf = (bitbuf<<8) | (ulg)get_byte(), valid += 8; \
- code = (bitbuf >> (valid-(bits))) & (mask); \
-}
-
-/* Skip the given number of bits (after having peeked at them): */
-#define skip_bits(bits) (valid -= (bits))
-
-#define clear_bitbuf() (valid = 0, bitbuf = 0)
-
-/* Local functions */
-
-local void read_tree OF((void));
-local void build_tree OF((void));
-
-/* ===========================================================================
- * Read the Huffman tree.
- */
-local void read_tree()
-{
- int len; /* bit length */
- int base; /* base offset for a sequence of leaves */
- int n;
-
- /* Read the original input size, MSB first */
- orig_len = 0;
- for (n = 1; n <= 4; n++) orig_len = (orig_len << 8) | (ulg)get_byte();
-
- max_len = (int)get_byte(); /* maximum bit length of Huffman codes */
- if (max_len > MAX_BITLEN) {
- error("invalid compressed data -- Huffman code > 32 bits");
- }
-
- /* Get the number of leaves at each bit length */
- n = 0;
- for (len = 1; len <= max_len; len++) {
- leaves[len] = (int)get_byte();
- n += leaves[len];
- }
- if (n > LITERALS) {
- error("too many leaves in Huffman tree");
- }
- Trace((stderr, "orig_len %ld, max_len %d, leaves %d\n",
- orig_len, max_len, n));
- /* There are at least 2 and at most 256 leaves of length max_len.
- * (Pack arbitrarily rejects empty files and files consisting of
- * a single byte even repeated.) To fit the last leaf count in a
- * byte, it is offset by 2. However, the last literal is the EOB
- * code, and is not transmitted explicitly in the tree, so we must
- * adjust here by one only.
- */
- leaves[max_len]++;
-
- /* Now read the leaves themselves */
- base = 0;
- for (len = 1; len <= max_len; len++) {
- /* Remember where the literals of this length start in literal[] : */
- lit_base[len] = base;
- /* And read the literals: */
- for (n = leaves[len]; n > 0; n--) {
- literal[base++] = (uch)get_byte();
- }
- }
- leaves[max_len]++; /* Now include the EOB code in the Huffman tree */
-}
-
-/* ===========================================================================
- * Build the Huffman tree and the prefix table.
- */
-local void build_tree()
-{
- int nodes = 0; /* number of nodes (parents+leaves) at current bit length */
- int len; /* current bit length */
- uch *prefixp; /* pointer in prefix_len */
-
- for (len = max_len; len >= 1; len--) {
- /* The number of parent nodes at this level is half the total
- * number of nodes at parent level:
- */
- nodes >>= 1;
- parents[len] = nodes;
- /* Update lit_base by the appropriate bias to skip the parent nodes
- * (which are not represented in the literal array):
- */
- lit_base[len] -= nodes;
- /* Restore nodes to be parents+leaves: */
- nodes += leaves[len];
- }
- /* Construct the prefix table, from shortest leaves to longest ones.
- * The shortest code is all ones, so we start at the end of the table.
- */
- peek_bits = MIN(max_len, MAX_PEEK);
- prefixp = &prefix_len[1<<peek_bits];
- for (len = 1; len <= peek_bits; len++) {
- int prefixes = leaves[len] << (peek_bits-len); /* may be 0 */
- while (prefixes--) *--prefixp = (uch)len;
- }
- /* The length of all other codes is unknown: */
- while (prefixp > prefix_len) *--prefixp = 0;
-}
-
-/* ===========================================================================
- * Unpack in to out. This routine does not support the old pack format
- * with magic header \037\037.
- *
- * IN assertions: the buffer inbuf contains already the beginning of
- * the compressed data, from offsets inptr to insize-1 included.
- * The magic header has already been checked. The output buffer is cleared.
- */
-int unpack(in, out)
- int in, out; /* input and output file descriptors */
-{
- int len; /* Bit length of current code */
- unsigned eob; /* End Of Block code */
- register unsigned peek; /* lookahead bits */
- unsigned peek_mask; /* Mask for peek_bits bits */
-
- ifd = in;
- ofd = out;
-
- read_tree(); /* Read the Huffman tree */
- build_tree(); /* Build the prefix table */
- clear_bitbuf(); /* Initialize bit input */
- peek_mask = (1<<peek_bits)-1;
-
- /* The eob code is the largest code among all leaves of maximal length: */
- eob = leaves[max_len]-1;
- Trace((stderr, "eob %d %x\n", max_len, eob));
-
- /* Decode the input data: */
- for (;;) {
- /* Since eob is the longest code and not shorter than max_len,
- * we can peek at max_len bits without having the risk of reading
- * beyond the end of file.
- */
- look_bits(peek, peek_bits, peek_mask);
- len = prefix_len[peek];
- if (len > 0) {
- peek >>= peek_bits - len; /* discard the extra bits */
- } else {
- /* Code of more than peek_bits bits, we must traverse the tree */
- ulg mask = peek_mask;
- len = peek_bits;
- do {
- len++, mask = (mask<<1)+1;
- look_bits(peek, len, mask);
- } while (peek < (unsigned)parents[len]);
- /* loop as long as peek is a parent node */
- }
- /* At this point, peek is the next complete code, of len bits */
- if (peek == eob && len == max_len) break; /* end of file? */
- put_ubyte(literal[peek+lit_base[len]]);
- Tracev((stderr,"%02d %04x %c\n", len, peek,
- literal[peek+lit_base[len]]));
- skip_bits(len);
- } /* for (;;) */
-
- flush_window();
- Trace((stderr, "bytes_out %ld\n", bytes_out));
- if (orig_len != (ulg)bytes_out) {
- error("invalid compressed data--length error");
- }
- return OK;
-}
diff --git a/gnu/usr.bin/gzip/unzip.c b/gnu/usr.bin/gzip/unzip.c
deleted file mode 100644
index cd3d50e..0000000
--- a/gnu/usr.bin/gzip/unzip.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/* unzip.c -- decompress files in gzip or pkzip format.
- * Copyright (C) 1992-1993 Jean-loup Gailly
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- *
- * The code in this file is derived from the file funzip.c written
- * and put in the public domain by Mark Adler.
- */
-
-/*
- This version can extract files in gzip or pkzip format.
- For the latter, only the first entry is extracted, and it has to be
- either deflated or stored.
- */
-
-#ifdef RCSID
-static char rcsid[] = "$Id$";
-#endif
-
-#include "tailor.h"
-#include "gzip.h"
-#include "crypt.h"
-
-/* PKZIP header definitions */
-#define LOCSIG 0x04034b50L /* four-byte lead-in (lsb first) */
-#define LOCFLG 6 /* offset of bit flag */
-#define CRPFLG 1 /* bit for encrypted entry */
-#define EXTFLG 8 /* bit for extended local header */
-#define LOCHOW 8 /* offset of compression method */
-#define LOCTIM 10 /* file mod time (for decryption) */
-#define LOCCRC 14 /* offset of crc */
-#define LOCSIZ 18 /* offset of compressed size */
-#define LOCLEN 22 /* offset of uncompressed length */
-#define LOCFIL 26 /* offset of file name field length */
-#define LOCEXT 28 /* offset of extra field length */
-#define LOCHDR 30 /* size of local header, including sig */
-#define EXTHDR 16 /* size of extended local header, inc sig */
-
-
-/* Globals */
-
-int decrypt; /* flag to turn on decryption */
-char *key; /* not used--needed to link crypt.c */
-int pkzip = 0; /* set for a pkzip file */
-int ext_header = 0; /* set if extended local header */
-
-/* ===========================================================================
- * Check zip file and advance inptr to the start of the compressed data.
- * Get ofname from the local header if necessary.
- */
-int check_zipfile(in)
- int in; /* input file descriptors */
-{
- uch *h = inbuf + inptr; /* first local header */
-
- ifd = in;
-
- /* Check validity of local header, and skip name and extra fields */
- inptr += LOCHDR + SH(h + LOCFIL) + SH(h + LOCEXT);
-
- if (inptr > insize || LG(h) != LOCSIG) {
- fprintf(stderr, "\n%s: %s: not a valid zip file\n",
- progname, ifname);
- exit_code = ERROR;
- return ERROR;
- }
- method = h[LOCHOW];
- if (method != STORED && method != DEFLATED) {
- fprintf(stderr,
- "\n%s: %s: first entry not deflated or stored -- use unzip\n",
- progname, ifname);
- exit_code = ERROR;
- return ERROR;
- }
-
- /* If entry encrypted, decrypt and validate encryption header */
- if ((decrypt = h[LOCFLG] & CRPFLG) != 0) {
- fprintf(stderr, "\n%s: %s: encrypted file -- use unzip\n",
- progname, ifname);
- exit_code = ERROR;
- return ERROR;
- }
-
- /* Save flags for unzip() */
- ext_header = (h[LOCFLG] & EXTFLG) != 0;
- pkzip = 1;
-
- /* Get ofname and time stamp from local header (to be done) */
- return OK;
-}
-
-/* ===========================================================================
- * Unzip in to out. This routine works on both gzip and pkzip files.
- *
- * IN assertions: the buffer inbuf contains already the beginning of
- * the compressed data, from offsets inptr to insize-1 included.
- * The magic header has already been checked. The output buffer is cleared.
- */
-int unzip(in, out)
- int in, out; /* input and output file descriptors */
-{
- ulg orig_crc = 0; /* original crc */
- ulg orig_len = 0; /* original uncompressed length */
- int n;
- uch buf[EXTHDR]; /* extended local header */
-
- ifd = in;
- ofd = out;
-
- updcrc(NULL, 0); /* initialize crc */
-
- if (pkzip && !ext_header) { /* crc and length at the end otherwise */
- orig_crc = LG(inbuf + LOCCRC);
- orig_len = LG(inbuf + LOCLEN);
- }
-
- /* Decompress */
- if (method == DEFLATED) {
-
- int res = inflate();
-
- if (res == 3) {
- error("out of memory");
- } else if (res != 0) {
- error("invalid compressed data--format violated");
- }
-
- } else if (pkzip && method == STORED) {
-
- register ulg n = LG(inbuf + LOCLEN);
-
- if (n != LG(inbuf + LOCSIZ) - (decrypt ? RAND_HEAD_LEN : 0)) {
-
- fprintf(stderr, "len %ld, siz %ld\n", n, LG(inbuf + LOCSIZ));
- error("invalid compressed data--length mismatch");
- }
- while (n--) {
- uch c = (uch)get_byte();
-#ifdef CRYPT
- if (decrypt) zdecode(c);
-#endif
- put_ubyte(c);
- }
- flush_window();
- } else {
- error("internal error, invalid method");
- }
-
- /* Get the crc and original length */
- if (!pkzip) {
- /* crc32 (see algorithm.doc)
- * uncompressed input size modulo 2^32
- */
- for (n = 0; n < 8; n++) {
- buf[n] = (uch)get_byte(); /* may cause an error if EOF */
- }
- orig_crc = LG(buf);
- orig_len = LG(buf+4);
-
- } else if (ext_header) { /* If extended header, check it */
- /* signature - 4bytes: 0x50 0x4b 0x07 0x08
- * CRC-32 value
- * compressed size 4-bytes
- * uncompressed size 4-bytes
- */
- for (n = 0; n < EXTHDR; n++) {
- buf[n] = (uch)get_byte(); /* may cause an error if EOF */
- }
- orig_crc = LG(buf+4);
- orig_len = LG(buf+12);
- }
-
- /* Validate decompression */
- if (orig_crc != updcrc(outbuf, 0)) {
- error("invalid compressed data--crc error");
- }
- if (orig_len != (ulg)bytes_out) {
- error("invalid compressed data--length error");
- }
-
- /* Check if there are more entries in a pkzip file */
- if (pkzip && inptr + 4 < insize && LG(inbuf+inptr) == LOCSIG) {
- if (to_stdout) {
- WARN((stderr,
- "%s: %s has more than one entry--rest ignored\n",
- progname, ifname));
- } else {
- /* Don't destroy the input zip file */
- fprintf(stderr,
- "%s: %s has more than one entry -- unchanged\n",
- progname, ifname);
- exit_code = ERROR;
- ext_header = pkzip = 0;
- return ERROR;
- }
- }
- ext_header = pkzip = 0; /* for next file */
- return OK;
-}
diff --git a/gnu/usr.bin/gzip/util.c b/gnu/usr.bin/gzip/util.c
deleted file mode 100644
index 58fef08..0000000
--- a/gnu/usr.bin/gzip/util.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/* util.c -- utility functions for gzip support
- * Copyright (C) 1992-1993 Jean-loup Gailly
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#ifdef RCSID
-static char rcsid[] = "$Id: util.c,v 1.6 1997/02/22 15:46:10 peter Exp $";
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#include "tailor.h"
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifndef NO_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H)
-# include <stdlib.h>
-#else
- extern int errno;
-#endif
-
-#include "gzip.h"
-#include "crypt.h"
-
-extern ulg crc_32_tab[]; /* crc table, defined below */
-
-/* ===========================================================================
- * Copy input to output unchanged: zcat == cat with --force.
- * IN assertion: insize bytes have already been read in inbuf.
- */
-int copy(in, out)
- int in, out; /* input and output file descriptors */
-{
- errno = 0;
- while (insize != 0 && (int)insize != EOF) {
- write_buf(out, (char*)inbuf, insize);
- bytes_out += insize;
- insize = read(in, (char*)inbuf, INBUFSIZ);
- }
- if ((int)insize == EOF && errno != 0) {
- read_error();
- }
- bytes_in = bytes_out;
- return OK;
-}
-
-/* ===========================================================================
- * Run a set of bytes through the crc shift register. If s is a NULL
- * pointer, then initialize the crc shift register contents instead.
- * Return the current crc in either case.
- */
-ulg updcrc(s, n)
- uch *s; /* pointer to bytes to pump through */
- unsigned n; /* number of bytes in s[] */
-{
- register ulg c; /* temporary variable */
-
- static ulg crc = (ulg)0xffffffffL; /* shift register contents */
-
- if (s == NULL) {
- c = 0xffffffffL;
- } else {
- c = crc;
- if (n) do {
- c = crc_32_tab[((int)c ^ (*s++)) & 0xff] ^ (c >> 8);
- } while (--n);
- }
- crc = c;
- return c ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */
-}
-
-/* ===========================================================================
- * Clear input and output buffers
- */
-void clear_bufs()
-{
- outcnt = 0;
- insize = inptr = 0;
- bytes_in = bytes_out = 0L;
-}
-
-/* ===========================================================================
- * Fill the input buffer. This is called only when the buffer is empty.
- */
-int fill_inbuf(eof_ok)
- int eof_ok; /* set if EOF acceptable as a result */
-{
- int len;
-
- /* Read as much as possible */
- insize = 0;
- errno = 0;
- do {
- len = read(ifd, (char*)inbuf+insize, INBUFSIZ-insize);
- if (len == 0 || len == EOF) break;
- insize += len;
- } while (insize < INBUFSIZ);
-
- if (insize == 0) {
- if (eof_ok) return EOF;
- read_error();
- }
- bytes_in += (ulg)insize;
- inptr = 1;
- return inbuf[0];
-}
-
-/* ===========================================================================
- * Write the output buffer outbuf[0..outcnt-1] and update bytes_out.
- * (used for the compressed data only)
- */
-void flush_outbuf()
-{
- if (outcnt == 0) return;
-
- write_buf(ofd, (char *)outbuf, outcnt);
- bytes_out += (ulg)outcnt;
- outcnt = 0;
-}
-
-/* ===========================================================================
- * Write the output window window[0..outcnt-1] and update crc and bytes_out.
- * (Used for the decompressed data only.)
- */
-void flush_window()
-{
- if (outcnt == 0) return;
- updcrc(window, outcnt);
-
- if (!test) {
- write_buf(ofd, (char *)window, outcnt);
- }
- bytes_out += (ulg)outcnt;
- outcnt = 0;
-}
-
-/* ===========================================================================
- * Does the same as write(), but also handles partial pipe writes and checks
- * for error return.
- */
-void write_buf(fd, buf, cnt)
- int fd;
- voidp buf;
- unsigned cnt;
-{
- unsigned n;
-
- while ((n = write(fd, buf, cnt)) != cnt) {
- if (n == (unsigned)(-1)) {
- write_error();
- }
- cnt -= n;
- buf = (voidp)((char*)buf+n);
- }
-}
-
-/* ========================================================================
- * Put string s in lower case, return s.
- */
-char *strlwr(s)
- char *s;
-{
- char *t;
- for (t = s; *t; t++) *t = tolow(*t);
- return s;
-}
-
-/* ========================================================================
- * Return the base name of a file (remove any directory prefix and
- * any version suffix). For systems with file names that are not
- * case sensitive, force the base name to lower case.
- */
-char *basename(fname)
- char *fname;
-{
- char *p;
-
- if ((p = strrchr(fname, PATH_SEP)) != NULL) fname = p+1;
-#ifdef PATH_SEP2
- if ((p = strrchr(fname, PATH_SEP2)) != NULL) fname = p+1;
-#endif
-#ifdef PATH_SEP3
- if ((p = strrchr(fname, PATH_SEP3)) != NULL) fname = p+1;
-#endif
-#ifdef SUFFIX_SEP
- if ((p = strrchr(fname, SUFFIX_SEP)) != NULL) *p = '\0';
-#endif
- if (casemap('A') == 'a') strlwr(fname);
- return fname;
-}
-
-/* ========================================================================
- * Make a file name legal for file systems not allowing file names with
- * multiple dots or starting with a dot (such as MSDOS), by changing
- * all dots except the last one into underlines. A target dependent
- * function can be used instead of this simple function by defining the macro
- * MAKE_LEGAL_NAME in tailor.h and providing the function in a target
- * dependent module.
- */
-void make_simple_name(name)
- char *name;
-{
- char *p = strrchr(name, '.');
- if (p == NULL) return;
- if (p == name) p++;
- do {
- if (*--p == '.') *p = '_';
- } while (p != name);
-}
-
-
-#if defined(NO_STRING_H) && !defined(STDC_HEADERS)
-
-/* Provide missing strspn and strcspn functions. */
-
-# ifndef __STDC__
-# define const
-# endif
-
-int strspn OF((const char *s, const char *accept));
-int strcspn OF((const char *s, const char *reject));
-
-/* ========================================================================
- * Return the length of the maximum initial segment
- * of s which contains only characters in accept.
- */
-int strspn(s, accept)
- const char *s;
- const char *accept;
-{
- register const char *p;
- register const char *a;
- register int count = 0;
-
- for (p = s; *p != '\0'; ++p) {
- for (a = accept; *a != '\0'; ++a) {
- if (*p == *a) break;
- }
- if (*a == '\0') return count;
- ++count;
- }
- return count;
-}
-
-/* ========================================================================
- * Return the length of the maximum inital segment of s
- * which contains no characters from reject.
- */
-int strcspn(s, reject)
- const char *s;
- const char *reject;
-{
- register int count = 0;
-
- while (*s != '\0') {
- if (strchr(reject, *s++) != NULL) return count;
- ++count;
- }
- return count;
-}
-
-#endif /* NO_STRING_H */
-
-/* ========================================================================
- * Add an environment variable (if any) before argv, and update argc.
- * Return the expanded environment variable to be freed later, or NULL
- * if no options were added to argv.
- */
-#define SEPARATOR " \t" /* separators in env variable */
-
-char *add_envopt(argcp, argvp, env)
- int *argcp; /* pointer to argc */
- char ***argvp; /* pointer to argv */
- char *env; /* name of environment variable */
-{
- char *p; /* running pointer through env variable */
- char **oargv; /* runs through old argv array */
- char **nargv; /* runs through new argv array */
- int oargc = *argcp; /* old argc */
- int nargc = 0; /* number of arguments in env variable */
-
- env = (char*)getenv(env);
- if (env == NULL) return NULL;
-
- p = (char*)xmalloc(strlen(env)+1);
- env = strcpy(p, env); /* keep env variable intact */
-
- for (p = env; *p; nargc++ ) { /* move through env */
- p += strspn(p, SEPARATOR); /* skip leading separators */
- if (*p == '\0') break;
-
- p += strcspn(p, SEPARATOR); /* find end of word */
- if (*p) *p++ = '\0'; /* mark it */
- }
- if (nargc == 0) {
- free(env);
- return NULL;
- }
- *argcp += nargc;
- /* Allocate the new argv array, with an extra element just in case
- * the original arg list did not end with a NULL.
- */
- nargv = (char**)calloc(*argcp+1, sizeof(char *));
- if (nargv == NULL) error("out of memory");
- oargv = *argvp;
- *argvp = nargv;
-
- /* Copy the program name first */
- if (oargc-- < 0) error("argc<=0");
- *(nargv++) = *(oargv++);
-
- /* Then copy the environment args */
- for (p = env; nargc > 0; nargc--) {
- p += strspn(p, SEPARATOR); /* skip separators */
- *(nargv++) = p; /* store start */
- while (*p++) ; /* skip over word */
- }
-
- /* Finally copy the old args and add a NULL (usual convention) */
- while (oargc--) *(nargv++) = *(oargv++);
- *nargv = NULL;
- return env;
-}
-
-/* ========================================================================
- * Error handlers.
- */
-void error(m)
- char *m;
-{
- fprintf(stderr, "\n%s: %s: %s\n", progname, ifname, m);
- abort_gzip();
-}
-
-void read_error()
-{
- fprintf(stderr, "\n%s: ", progname);
- if (errno != 0) {
- perror(ifname);
- } else {
- fprintf(stderr, "%s: unexpected end of file\n", ifname);
- }
- abort_gzip();
-}
-
-void write_error()
-{
- fprintf(stderr, "\n%s: ", progname);
- perror(ofname);
- abort_gzip();
-}
-
-/* ========================================================================
- * Display compression ratio on the given stream on 6 characters.
- */
-void display_ratio(num, den, file)
- long num;
- long den;
- FILE *file;
-{
- long ratio; /* 1000 times the compression ratio */
-
- if (den == 0) {
- ratio = 0; /* no compression */
- } else if (den < 2147483L) { /* (2**31 -1)/1000 */
- ratio = 1000L*num/den;
- } else {
- ratio = num/(den/1000L);
- }
- if (ratio < 0) {
- putc('-', file);
- ratio = -ratio;
- } else {
- putc(' ', file);
- }
- fprintf(file, "%2ld.%1ld%%", ratio / 10L, ratio % 10L);
-}
-
-
-/* ========================================================================
- * Semi-safe malloc -- never returns NULL.
- */
-voidp xmalloc (size)
- unsigned size;
-{
- voidp cp = (voidp)malloc (size);
-
- if (cp == NULL) error("out of memory");
- return cp;
-}
-
-/* ========================================================================
- * Table of CRC-32's of all single-byte values (made by makecrc.c)
- */
-ulg crc_32_tab[] = {
- 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
- 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
- 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
- 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
- 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
- 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
- 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
- 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
- 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
- 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
- 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
- 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
- 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
- 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
- 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
- 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
- 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
- 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
- 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
- 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
- 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
- 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
- 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
- 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
- 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
- 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
- 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
- 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
- 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
- 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
- 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
- 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
- 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
- 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
- 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
- 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
- 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
- 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
- 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
- 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
- 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
- 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
- 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
- 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
- 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
- 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
- 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
- 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
- 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
- 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
- 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
- 0x2d02ef8dL
-};
diff --git a/gnu/usr.bin/gzip/zdiff b/gnu/usr.bin/gzip/zdiff
deleted file mode 100644
index 84e65d3..0000000
--- a/gnu/usr.bin/gzip/zdiff
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/bin/sh
-# sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh
-
-# Zcmp and zdiff are used to invoke the cmp or the diff pro-
-# gram on compressed files. All options specified are passed
-# directly to cmp or diff. If only 1 file is specified, then
-# the files compared are file1 and an uncompressed file1.gz.
-# If two files are specified, then they are uncompressed (if
-# necessary) and fed to cmp or diff. The exit status from cmp
-# or diff is preserved.
-
-PATH="/usr/local/bin:$PATH"; export PATH
-prog=`echo $0 | sed 's|.*/||'`
-case "$prog" in
- *cmp) comp=${CMP-cmp} ;;
- *) comp=${DIFF-diff} ;;
-esac
-
-OPTIONS=
-FILES=
-for ARG
-do
- case "$ARG" in
- -*) OPTIONS="$OPTIONS $ARG";;
- *) if test -f "$ARG"; then
- FILES="$FILES $ARG"
- else
- echo "${prog}: $ARG not found or not a regular file"
- exit 1
- fi ;;
- esac
-done
-if test -z "$FILES"; then
- echo "Usage: $prog [${comp}_options] file [file]"
- exit 1
-fi
-set $FILES
-if test $# -eq 1; then
- FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'`
- gzip -cd "$1" | $comp $OPTIONS - "$FILE"
- STAT="$?"
-
-elif test $# -eq 2; then
- case "$1" in
- *[-.]gz* | *[-.][zZ] | *.t[ga]z)
- case "$2" in
- *[-.]gz* | *[-.][zZ] | *.t[ga]z)
- F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*||'`
- gzip -cdfq "$2" > /tmp/"$F".$$
- gzip -cdfq "$1" | $comp $OPTIONS - /tmp/"$F".$$
- STAT="$?"
- /bin/rm -f /tmp/"$F".$$;;
-
- *) gzip -cdfq "$1" | $comp $OPTIONS - "$2"
- STAT="$?";;
- esac;;
- *) case "$2" in
- *[-.]gz* | *[-.][zZ] | *.t[ga]z)
- gzip -cdfq "$2" | $comp $OPTIONS "$1" -
- STAT="$?";;
- *) $comp $OPTIONS "$1" "$2"
- STAT="$?";;
- esac;;
- esac
- exit "$STAT"
-else
- echo "Usage: $prog [${comp}_options] file [file]"
- exit 1
-fi
diff --git a/gnu/usr.bin/gzip/zdiff.1 b/gnu/usr.bin/gzip/zdiff.1
deleted file mode 100644
index ea3bf41..0000000
--- a/gnu/usr.bin/gzip/zdiff.1
+++ /dev/null
@@ -1,44 +0,0 @@
-.TH ZDIFF 1
-.SH NAME
-zcmp, zdiff \- compare compressed files
-.SH SYNOPSIS
-.B zcmp
-[ cmp_options ] file1
-[ file2 ]
-.br
-.B zdiff
-[ diff_options ] file1
-[ file2 ]
-.SH DESCRIPTION
-.I Zcmp
-and
-.I zdiff
-are used to invoke the
-.I cmp
-or the
-.I diff
-program on compressed files. All options specified are passed directly to
-.I cmp
-or
-.IR diff "."
-If only 1 file is specified, then the files compared are
-.I file1
-and an uncompressed
-.IR file1 ".gz."
-If two files are specified, then they are uncompressed if necessary and fed to
-.I cmp
-or
-.IR diff "."
-The exit status from
-.I cmp
-or
-.I diff
-is preserved.
-.SH "SEE ALSO"
-cmp(1), diff(1), zmore(1), zgrep(1), znew(1), zforce(1), gzip(1), gzexe(1)
-.SH BUGS
-Messages from the
-.I cmp
-or
-.I diff
-programs refer to temporary filenames instead of those specified.
diff --git a/gnu/usr.bin/gzip/zforce b/gnu/usr.bin/gzip/zforce
deleted file mode 100644
index 17258a4..0000000
--- a/gnu/usr.bin/gzip/zforce
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# zforce: force a gz extension on all gzip files so that gzip will not
-# compress them twice.
-#
-# This can be useful for files with names truncated after a file transfer.
-# 12345678901234 is renamed to 12345678901.gz
-
-PATH="/usr/local/bin:$PATH"; export PATH
-x=`basename $0`
-if test $# = 0; then
- echo "force a '.gz' extension on all gzip files"
- echo usage: $x files...
- exit 1
-fi
-
-res=0
-for i do
- if test ! -f "$i" ; then
- echo ${x}: $i not a file
- res=1
- continue
- fi
- test `expr "$i" : '.*[.-]z$'` -eq 0 || continue
- test `expr "$i" : '.*[.-]gz$'` -eq 0 || continue
- test `expr "$i" : '.*[.]t[ag]z$'` -eq 0 || continue
-
- if gzip -l < "$i" 2>/dev/null | grep '^defl' > /dev/null; then
-
- if test `expr "$i" : '^............'` -eq 12; then
- new=`expr "$i" : '\(.*\)...$`.gz
- else
- new="$i.gz"
- fi
- if mv "$i" "$new" 2>/dev/null; then
- echo $i -- replaced with $new
- continue
- fi
- res=1; echo ${x}: cannot rename $i to $new
- fi
-done
-exit $res
diff --git a/gnu/usr.bin/gzip/zforce.1 b/gnu/usr.bin/gzip/zforce.1
deleted file mode 100644
index 37c6aba..0000000
--- a/gnu/usr.bin/gzip/zforce.1
+++ /dev/null
@@ -1,20 +0,0 @@
-.TH ZFORCE 1
-.SH NAME
-zforce \- force a '.gz' extension on all gzip files
-.SH SYNOPSIS
-.B zforce
-[ name ... ]
-.SH DESCRIPTION
-.I zforce
-forces a .gz extension on all
-.I gzip
-files so that
-.I gzip
-will not compress them twice.
-This can be useful for files with names truncated after a file transfer.
-On systems with a 14 char limitation on file names, the original name
-is truncated to make room for the .gz suffix. For example,
-12345678901234 is renamed to 12345678901.gz. A file name such as foo.tgz
-is left intact.
-.SH "SEE ALSO"
-gzip(1), znew(1), zmore(1), zgrep(1), zdiff(1), gzexe(1)
diff --git a/gnu/usr.bin/gzip/zgrep b/gnu/usr.bin/gzip/zgrep
deleted file mode 100644
index bcc10cc..0000000
--- a/gnu/usr.bin/gzip/zgrep
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-
-# zgrep -- a wrapper around a grep program that decompresses files as needed
-# Adapted from a version sent by Charles Levert <charles@comm.polymtl.ca>
-
-PATH="/usr/local/bin:$PATH"; export PATH
-
-prog=`echo $0 | sed 's|.*/||'`
-case "$prog" in
- *egrep) grep=${EGREP-egrep} ;;
- *fgrep) grep=${FGREP-fgrep} ;;
- *) grep=${GREP-grep} ;;
-esac
-A=
-fileno=0
-pat=""
-while test $# -ne 0; do
- case "$1" in
- -e | -f) opt="$opt $1"; shift; pat="$1"
- if test "$grep" = grep; then # grep is buggy with -e on SVR4
- grep=egrep
- fi;;
- -*) opt="$opt $1";;
- *) if test -z "$pat"; then
- pat="$1"
- else
- fileno=`expr $fileno + 1`
- eval A$fileno=\$1
- A="$A \"\$A$fileno\""
- fi
- ;;
- esac
- shift
-done
-
-if test -z "$pat"; then
- echo "grep through gzip files"
- echo "usage: $prog [grep_options] pattern [files]"
- exit 1
-fi
-
-list=0
-silent=0
-op=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
-case "$op" in
- *l*) list=1
-esac
-case "$op" in
- *h*) silent=1
-esac
-
-if test $fileno -eq 0; then
- gzip -cdfq | $grep $opt "$pat"
- exit $?
-fi
-eval set "$A" # files in $1, $2 ...
-
-res=0
-for i do
- if test $list -eq 1; then
- gzip -cdfq "$i" | $grep $opt "$pat" > /dev/null && echo $i
- r=$?
- elif test $# -eq 1 -o $silent -eq 1; then
- gzip -cdfq "$i" | $grep $opt "$pat"
- r=$?
- else
- gzip -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${i}:|"
- r=$?
- fi
- test "$r" -ne 0 && res="$r"
-done
-exit $res
diff --git a/gnu/usr.bin/gzip/zgrep.1 b/gnu/usr.bin/gzip/zgrep.1
deleted file mode 100644
index a52a88a..0000000
--- a/gnu/usr.bin/gzip/zgrep.1
+++ /dev/null
@@ -1,44 +0,0 @@
-.TH ZGREP 1
-.SH NAME
-zgrep \- search possibly compressed files for a regular expression
-.SH SYNOPSIS
-.B zgrep
-[ grep_options ]
-.BI [\ -e\ ] " pattern"
-.IR filename ".\|.\|."
-.SH DESCRIPTION
-.IR Zgrep
-is used to invoke the
-.I grep
-on compress'ed or gzip'ed files. All options specified are passed directly to
-.I grep.
-If no file is specified, then the standard input is decompressed
-if necessary and fed to grep.
-Otherwise the given files are uncompressed if necessary and fed to
-.I grep.
-.PP
-If
-.I zgrep
-is invoked as
-.I zegrep
-or
-.I zfgrep
-then
-.I egrep
-or
-.I fgrep
-is used instead of
-.I grep.
-If the GREP environment variable is set,
-.I zgrep
-uses it as the
-.I grep
-program to be invoked. For example:
-
- for sh: GREP=fgrep zgrep string files
- for csh: (setenv GREP fgrep; zgrep string files)
-.SH AUTHOR
-Charles Levert (charles@comm.polymtl.ca)
-.SH "SEE ALSO"
-grep(1), egrep(1), fgrep(1), zdiff(1), zmore(1), znew(1), zforce(1),
-gzip(1), gzexe(1)
diff --git a/gnu/usr.bin/gzip/zgrep.getopt b/gnu/usr.bin/gzip/zgrep.getopt
deleted file mode 100644
index 58564b3..0000000
--- a/gnu/usr.bin/gzip/zgrep.getopt
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) April 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 [your name] 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.
-#
-# zgrep - search possibly compressed files for a regular expression
-#
-# $Id: zgrep.getopt,v 1.5 1997/04/19 20:06:57 wosch Exp $
-
-
-PATH=/bin:/usr/bin:$PATH; export PATH
-
-# grep variant
-case "$0" in
- *egrep) grep=${EGREP-egrep} ;;
- *fgrep) grep=${FGREP-fgrep} ;;
- *) grep=${GREP-grep} ;;
-esac
-
-gzip=gzip gzipopt="-cdfq" pattern= grepopt= files= line= header=
-
-# check options
-while getopts "0123456789A:B:CEFGVX:bce:f:hiLlnqsvwxy" option
-do
- case "$option" in
- e|f) pattern="-$option $OPTARG";; # -f file
- l|L) line=-$option; grepopt="$grepopt -$option";;
- h|q) header=-h; grepopt="$grepopt -$option";;
- # rest
- [0-9CEFGVbchiLlnqsvwxy]) grepopt="$grepopt -$option";;
- [ABXef]) grepopt="$grepopt -$option $OPTARG";;
- esac
-done
-shift $(($OPTIND - 1))
-
-# check pattern
-case X"$pattern" in
- X) case $# in
- 0) echo "usage: $0 [grep_options] pattern [files]"; exit 1;;
- *) pattern=$1; shift;;
- esac
-esac
-
-
-files="$@"
-# no shell loop neccessary for option -q or -h
-# and a single file or reading from stdin
-case "$header"X"$#" in
- -h*|-q*|X0|X1) $gzip $gzipopt -- $files | $grep $grepopt -- "$pattern"
- exit $?;;
-esac
-
-for f in $files
-do
- case "$line" in
- -l) if $gzip $gzipopt -- $f |
- $grep $grepopt -- "$pattern" >/dev/null
- then
- echo $f
- fi
- ;;
- -L) if $gzip $gzipopt -- $f |
- $grep $grepopt -- "$pattern" >/dev/null; then :
- else
- echo $f
- fi
- ;;
-
- *) $gzip $gzipopt -- $f | $grep $grepopt -- "$pattern" |
- sed "s%^%${f}:%"
- ;;
- esac
-done
diff --git a/gnu/usr.bin/gzip/zgrep.libz b/gnu/usr.bin/gzip/zgrep.libz
deleted file mode 100644
index 07d5267..0000000
--- a/gnu/usr.bin/gzip/zgrep.libz
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-# Copyright (c) Dec 1997 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
-# Public Domain.
-#
-# zgrep - Search possibly compressed files for a regular expression. This
-# version of zgrep(1) depend on a grep(1) linked with libz.
-#
-# $Id$
-
-PATH=/bin:/usr/bin; export PATH
-
-case "$0" in # grep variant
- *egrep) grep=${EGREP-egrep};;
- *fgrep) grep=${FGREP-fgrep};;
- *) grep=${GREP-grep};;
-esac
-
-exec ${grep} -Z "$@"
diff --git a/gnu/usr.bin/gzip/zip.c b/gnu/usr.bin/gzip/zip.c
deleted file mode 100644
index 145116d..0000000
--- a/gnu/usr.bin/gzip/zip.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* zip.c -- compress files to the gzip or pkzip format
- * Copyright (C) 1992-1993 Jean-loup Gailly
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#ifdef RCSID
-static char rcsid[] = "$Id$";
-#endif
-
-#include <ctype.h>
-#include <sys/types.h>
-
-#include "tailor.h"
-#include "gzip.h"
-#include "crypt.h"
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifndef NO_FCNTL_H
-# include <fcntl.h>
-#endif
-
-local ulg crc; /* crc on uncompressed file data */
-long header_bytes; /* number of bytes in gzip header */
-
-/* ===========================================================================
- * Deflate in to out.
- * IN assertions: the input and output buffers are cleared.
- * The variables time_stamp and save_orig_name are initialized.
- */
-int zip(in, out)
- int in, out; /* input and output file descriptors */
-{
- uch flags = 0; /* general purpose bit flags */
- ush attr = 0; /* ascii/binary flag */
- ush deflate_flags = 0; /* pkzip -es, -en or -ex equivalent */
-
- ifd = in;
- ofd = out;
- outcnt = 0;
-
- /* Write the header to the gzip file. See algorithm.doc for the format */
-
- method = DEFLATED;
- put_byte(GZIP_MAGIC[0]); /* magic header */
- put_byte(GZIP_MAGIC[1]);
- put_byte(DEFLATED); /* compression method */
-
- if (save_orig_name) {
- flags |= ORIG_NAME;
- }
- put_byte(flags); /* general flags */
- put_long(time_stamp);
-
- /* Write deflated file to zip file */
- crc = updcrc(0, 0);
-
- bi_init(out);
- ct_init(&attr, &method);
- lm_init(level, &deflate_flags);
-
- put_byte((uch)deflate_flags); /* extra flags */
- put_byte(OS_CODE); /* OS identifier */
-
- if (save_orig_name) {
- char *p = basename(ifname); /* Don't save the directory part. */
- do {
- put_char(*p);
- } while (*p++);
- }
- header_bytes = (long)outcnt;
-
- (void)deflate();
-
-#if !defined(NO_SIZE_CHECK) && !defined(RECORD_IO)
- /* Check input size (but not in VMS -- variable record lengths mess it up)
- * and not on MSDOS -- diet in TSR mode reports an incorrect file size)
- */
- if (ifile_size != -1L && isize != (ulg)ifile_size) {
- Trace((stderr, " actual=%ld, read=%ld ", ifile_size, isize));
- fprintf(stderr, "%s: %s: file size changed while zipping\n",
- progname, ifname);
- }
-#endif
-
- /* Write the crc and uncompressed size */
- put_long(crc);
- put_long(isize);
- header_bytes += 2*sizeof(long);
-
- flush_outbuf();
- return OK;
-}
-
-
-/* ===========================================================================
- * Read a new buffer from the current input file, perform end-of-line
- * translation, and update the crc and input file size.
- * IN assertion: size >= 2 (for end-of-line translation)
- */
-int file_read(buf, size)
- char *buf;
- unsigned size;
-{
- unsigned len;
-
- Assert(insize == 0, "inbuf not empty");
-
- len = read(ifd, buf, size);
- if (len == (unsigned)(-1) || len == 0) return (int)len;
-
- crc = updcrc((uch*)buf, len);
- isize += (ulg)len;
- return (int)len;
-}
diff --git a/gnu/usr.bin/gzip/zmore b/gnu/usr.bin/gzip/zmore
deleted file mode 100644
index ca933c7..0000000
--- a/gnu/usr.bin/gzip/zmore
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/sh
-
-PATH="/usr/local/bin:$PATH"; export PATH
-if test "`echo -n a`" = "-n a"; then
- # looks like a SysV system:
- n1=''; n2='\c'
-else
- n1='-n'; n2=''
-fi
-oldtty=`stty -g 2>/dev/null`
-if stty -cbreak 2>/dev/null; then
- cb='cbreak'; ncb='-cbreak'
-else
- # 'stty min 1' resets eof to ^a on both SunOS and SysV!
- cb='min 1 -icanon'; ncb='icanon eof ^d'
-fi
-if test $? -eq 0 -a -n "$oldtty"; then
- trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
-else
- trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
-fi
-
-if test $# = 0; then
- if test -t 0; then
- echo usage: zmore files...
- else
- gzip -cdfq | eval ${PAGER-more}
- fi
-else
- FIRST=1
- for FILE
- do
- if test $FIRST -eq 0; then
- echo $n1 "--More--(Next file: $FILE)$n2"
- stty $cb -echo 2>/dev/null
- ANS=`dd bs=1 count=1 2>/dev/null`
- stty $ncb echo 2>/dev/null
- echo " "
- if test "$ANS" = 'e' -o "$ANS" = 'q'; then
- exit
- fi
- fi
- if test "$ANS" != 's'; then
- echo "------> $FILE <------"
- gzip -cdfq "$FILE" | eval ${PAGER-more}
- fi
- if test -t; then
- FIRST=0
- fi
- done
-fi
diff --git a/gnu/usr.bin/gzip/zmore.1 b/gnu/usr.bin/gzip/zmore.1
deleted file mode 100644
index f7f1843..0000000
--- a/gnu/usr.bin/gzip/zmore.1
+++ /dev/null
@@ -1,145 +0,0 @@
-.TH ZMORE 1
-.SH NAME
-zmore \- file perusal filter for crt viewing of compressed text
-.SH SYNOPSIS
-.B zmore
-[ name ... ]
-.SH DESCRIPTION
-.I Zmore
-is a filter which allows examination of compressed or plain text files
-one screenful at a time on a soft-copy terminal.
-.I zmore
-works on files compressed with
-.I compress, pack
-or
-.I gzip,
-and also on uncompressed files.
-If a file does not exist,
-.I zmore
-looks for a file of the same name with the addition of a .gz, .z or .Z suffix.
-.PP
-.I Zmore
-normally pauses after each screenful, printing --More--
-at the bottom of the screen.
-If the user then types a carriage return, one more line is displayed.
-If the user hits a space,
-another screenful is displayed. Other possibilities are enumerated later.
-.PP
-.I Zmore
-looks in the file
-.I /etc/termcap
-to determine terminal characteristics,
-and to determine the default window size.
-On a terminal capable of displaying 24 lines,
-the default window size is 22 lines.
-To use a pager other than the default
-.I more,
-set environment variable PAGER to the name of the desired program, such as
-.I less.
-.PP
-Other sequences which may be typed when
-.I zmore
-pauses, and their effects, are as follows (\fIi\fP is an optional integer
-argument, defaulting to 1) :
-.PP
-.IP \fIi\|\fP<space>
-display
-.I i
-more lines, (or another screenful if no argument is given)
-.PP
-.IP ^D
-display 11 more lines (a ``scroll'').
-If
-.I i
-is given, then the scroll size is set to \fIi\|\fP.
-.PP
-.IP d
-same as ^D (control-D)
-.PP
-.IP \fIi\|\fPz
-same as typing a space except that \fIi\|\fP, if present, becomes the new
-window size. Note that the window size reverts back to the default at the
-end of the current file.
-.PP
-.IP \fIi\|\fPs
-skip \fIi\|\fP lines and print a screenful of lines
-.PP
-.IP \fIi\|\fPf
-skip \fIi\fP screenfuls and print a screenful of lines
-.PP
-.IP "q or Q"
-quit reading the current file; go on to the next (if any)
-.PP
-.IP "e or q"
-When the prompt --More--(Next file:
-.IR file )
-is printed, this command causes zmore to exit.
-.PP
-.IP s
-When the prompt --More--(Next file:
-.IR file )
-is printed, this command causes zmore to skip the next file and continue.
-.PP
-.IP =
-Display the current line number.
-.PP
-.IP \fIi\|\fP/expr
-search for the \fIi\|\fP-th occurrence of the regular expression \fIexpr.\fP
-If the pattern is not found,
-.I zmore
-goes on to the next file (if any).
-Otherwise, a screenful is displayed, starting two lines before the place
-where the expression was found.
-The user's erase and kill characters may be used to edit the regular
-expression.
-Erasing back past the first column cancels the search command.
-.PP
-.IP \fIi\|\fPn
-search for the \fIi\|\fP-th occurrence of the last regular expression entered.
-.PP
-.IP !command
-invoke a shell with \fIcommand\|\fP.
-The character `!' in "command" are replaced with the
-previous shell command. The sequence "\\!" is replaced by "!".
-.PP
-.IP ":q or :Q"
-quit reading the current file; go on to the next (if any)
-(same as q or Q).
-.PP
-.IP .
-(dot) repeat the previous command.
-.PP
-The commands take effect immediately, i.e., it is not necessary to
-type a carriage return.
-Up to the time when the command character itself is given,
-the user may hit the line kill character to cancel the numerical
-argument being formed.
-In addition, the user may hit the erase character to redisplay the
---More-- message.
-.PP
-At any time when output is being sent to the terminal, the user can
-hit the quit key (normally control\-\\).
-.I Zmore
-will stop sending output, and will display the usual --More--
-prompt.
-The user may then enter one of the above commands in the normal manner.
-Unfortunately, some output is lost when this is done, due to the
-fact that any characters waiting in the terminal's output queue
-are flushed when the quit signal occurs.
-.PP
-The terminal is set to
-.I noecho
-mode by this program so that the output can be continuous.
-What you type will thus not show on your terminal, except for the / and !
-commands.
-.PP
-If the standard output is not a teletype, then
-.I zmore
-acts just like
-.I zcat,
-except that a header is printed before each file.
-.SH FILES
-.DT
-/etc/termcap Terminal data base
-.SH "SEE ALSO"
-more(1), gzip(1), zdiff(1), zgrep(1), znew(1), zforce(1), gzexe(1)
diff --git a/gnu/usr.bin/gzip/znew b/gnu/usr.bin/gzip/znew
deleted file mode 100644
index 5c832e8..0000000
--- a/gnu/usr.bin/gzip/znew
+++ /dev/null
@@ -1,145 +0,0 @@
-#!/bin/sh
-
-PATH="/usr/local/bin:$PATH"; export PATH
-check=0
-pipe=0
-opt=
-files=
-keep=0
-res=0
-old=0
-new=0
-block=1024
-# block is the disk block size (best guess, need not be exact)
-
-warn="(does not preserve modes and timestamp)"
-tmp=/tmp/zfoo.$$
-echo hi > $tmp.1
-echo hi > $tmp.2
-if test -z "`(${CPMOD-cpmod} $tmp.1 $tmp.2) 2>&1`"; then
- cpmod=${CPMOD-cpmod}
- warn=""
-fi
-
-if test -z "$cpmod" && ${TOUCH-touch} -r $tmp.1 $tmp.2 2>/dev/null; then
- cpmod="${TOUCH-touch}"
- cpmodarg="-r"
- warn="(does not preserve file modes)"
-fi
-
-# check if GZIP env. variable uses -S or --suffix
-gzip -q $tmp.1
-ext=`echo $tmp.1* | sed "s|$tmp.1||"`
-rm -f $tmp.[12]*
-if test -z "$ext"; then
- echo znew: error determining gzip extension
- exit 1
-fi
-if test "$ext" = ".Z"; then
- echo znew: cannot use .Z as gzip extension.
- exit 1
-fi
-
-for arg
-do
- case "$arg" in
- -*) opt="$opt $arg"; shift;;
- *) break;;
- esac
-done
-
-if test $# -eq 0; then
- echo "recompress .Z files into $ext (gzip) files"
- echo usage: `echo $0 | sed 's,^.*/,,'` "[-tv9KP]" file.Z...
- echo " -t tests the new files before deleting originals"
- echo " -v be verbose"
- echo " -9 use the slowest compression method (optimal compression)"
- echo " -K keep a .Z file when it is smaller than the $ext file"
- echo " -P use pipes for the conversion $warn"
- exit 1
-fi
-
-opt=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
-case "$opt" in
- *t*) check=1; opt=`echo "$opt" | sed 's/t//g'`
-esac
-case "$opt" in
- *K*) keep=1; opt=`echo "$opt" | sed 's/K//g'`
-esac
-case "$opt" in
- *P*) pipe=1; opt=`echo "$opt" | sed 's/P//g'`
-esac
-if test -n "$opt"; then
- opt="-$opt"
-fi
-
-for i do
- n=`echo $i | sed 's/.Z$//'`
- if test ! -f "$n.Z" ; then
- echo $n.Z not found
- res=1; continue
- fi
- test $keep -eq 1 && old=`wc -c < "$n.Z"`
- if test $pipe -eq 1; then
- if gzip -d < "$n.Z" | gzip $opt > "$n$ext"; then
- # Copy file attributes from old file to new one, if possible.
- test -n "$cpmod" && $cpmod $cpmodarg "$n.Z" "$n$ext" 2> /dev/null
- else
- echo error while recompressing $n.Z
- res=1; continue
- fi
- else
- if test $check -eq 1; then
- if cp -p "$n.Z" "$n.$$" 2> /dev/null || cp "$n.Z" "$n.$$"; then
- :
- else
- echo cannot backup "$n.Z"
- res=1; continue
- fi
- fi
- if gzip -d "$n.Z"; then
- :
- else
- test $check -eq 1 && mv "$n.$$" "$n.Z"
- echo error while uncompressing $n.Z
- res=1; continue
- fi
- if gzip $opt "$n"; then
- :
- else
- if test $check -eq 1; then
- mv "$n.$$" "$n.Z" && rm -f "$n"
- echo error while recompressing $n
- else
- # compress $n (might be dangerous if disk full)
- echo error while recompressing $n, left uncompressed
- fi
- res=1; continue
- fi
- fi
- test $keep -eq 1 && new=`wc -c < "$n$ext"`
- if test $keep -eq 1 -a `expr \( $old + $block - 1 \) / $block` -lt \
- `expr \( $new + $block - 1 \) / $block`; then
- if test $pipe -eq 1; then
- rm -f "$n$ext"
- elif test $check -eq 1; then
- mv "$n.$$" "$n.Z" && rm -f "$n$ext"
- else
- gzip -d "$n$ext" && compress "$n" && rm -f "$n$ext"
- fi
- echo "$n.Z smaller than $n$ext -- unchanged"
-
- elif test $check -eq 1; then
- if gzip -t "$n$ext" ; then
- rm -f "$n.$$" "$n.Z"
- else
- test $pipe -eq 0 && mv "$n.$$" "$n.Z"
- rm -f "$n$ext"
- echo error while testing $n$ext, $n.Z unchanged
- res=1; continue
- fi
- elif test $pipe -eq 1; then
- rm -f "$n.Z"
- fi
-done
-exit $res
diff --git a/gnu/usr.bin/gzip/znew.1 b/gnu/usr.bin/gzip/znew.1
deleted file mode 100644
index 5cfb472..0000000
--- a/gnu/usr.bin/gzip/znew.1
+++ /dev/null
@@ -1,39 +0,0 @@
-.TH ZNEW 1
-.SH NAME
-znew \- recompress .Z files to .gz files
-.SH SYNOPSIS
-.B znew
-[ -ftv9PK] [ name.Z ... ]
-.SH DESCRIPTION
-.I Znew
-recompresses files from .Z (compress) format to .gz (gzip) format.
-If you want to recompress a file already in gzip format, rename the file
-to force a .Z extension then apply znew.
-.SH OPTIONS
-.TP
-.B \-f
-Force recompression from .Z to .gz format even if a .gz file already exists.
-.TP
-.B \-t
-Tests the new files before deleting originals.
-.TP
-.B \-v
-Verbose. Display the name and percentage reduction for each file compressed.
-.TP
-.B \-9
-Use the slowest compression method (optimal compression).
-.TP
-.B \-P
-Use pipes for the conversion to reduce disk space usage.
-.TP
-.B \-K
-Keep a .Z file when it is smaller than the .gz file
-.SH "SEE ALSO"
-gzip(1), zmore(1), zdiff(1), zgrep(1), zforce(1), gzexe(1), compress(1)
-.SH BUGS
-.I Znew
-does not maintain the time stamp with the -P option if
-.I cpmod(1)
-is not available and
-.I touch(1)
-does not support the -r option.
diff --git a/gnu/usr.bin/ld/Makefile b/gnu/usr.bin/ld/Makefile
deleted file mode 100644
index 1c60e2b..0000000
--- a/gnu/usr.bin/ld/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# $Id: Makefile,v 1.21 1997/02/22 15:46:17 peter Exp $
-#
-
-PROG= ld
-SRCS= ld.c symbol.c lib.c shlib.c warnings.c support.c rrs.c xbits.c md.c \
- cplus-dem.c
-CFLAGS+= -I$(.CURDIR) -I$(.CURDIR)/$(MACHINE) \
- -I$(GCCDIR) -DIN_GCC -DDEMANGLE_CPLUSPLUS
-NOSHARED?= yes
-
-GCCDIR= ${.CURDIR}/../../../contrib/gcc
-
-SUBDIR= ldconfig ldd
-.if !defined(NOPIC)
-SUBDIR+= rtld
-.endif
-
-.PATH: $(.CURDIR)/$(MACHINE) $(GCCDIR)
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/ld/PORTING b/gnu/usr.bin/ld/PORTING
deleted file mode 100644
index e9f7614..0000000
--- a/gnu/usr.bin/ld/PORTING
+++ /dev/null
@@ -1,194 +0,0 @@
-$Id$
-
-This document describes some of the machine dependent parts in ld(1) and rtld(?)
-Most of the machine dependencies are a result of different ways in which
-relocation information is conveyed in an architecture's object files.
-Especially RISC architectures are likely candidates to have deviated from the
-traditional relocation record structure due a tendency to use odd sized
-"bitfields" to denote immediate operands within their fixed size instructions.
-
-Also, there may be slight differences in the model used for Position
-Independent Code generation by the compiler.
-
-Lastly, both ld and rtld must fiddle with actual machine instructions to setup
-a transfer vector to accommodate PIC code and dynamic linking.
-
-
-Machine dependent macros and data structures.
-
-typedef struct jmpslot { ... } jmpslot_t;
-
- The Procedure Linkage Table (PLT) is an array of these structures.
- The structure contains room for a control transfer instruction
- and a relocation index. md_make_jmpslot() and md_fix_jmpslot()
- are responsible for filling these in.
-
-JMPSLOT_NEEDS_RELOC()
-
- Macro indicating whether or not a jmpslot entry needs a run-time
- relocation when ld has already resolved the symbolic reference
- (eg. when `-Bsymbolic' was given). Usually the case if the control
- transfer instruction is PC relative or something.
-
-RELOC_STATICS_THROUGH_GOT_P(r)
-
- Predicate taking a `struct relocation_info *' as an argument. It
- decides whether variables with file scope are addressed relative to
- the start Global Offset Table (1) or an entry in GOT must be
- allocated (0). The compiler has a say in this.
-
-
-Some other random macros:
-
-BAD_MID(ex)
-
- Tells whether the machine ID in an input file header is acceptable.
-
-N_SET_FLAG(ex,f)
-
- Set flags F in a.out header. Must account for possible non-NetBSD
- headers; QMAGIC is still a documented ld output format.
-
-N_IS_DYNAMIC(ex)
-
- Return true if this appears to be a dynamically linked object.
-
-#define relocation_info reloc_info_<machine>
-
- Define (possibly machine dependent) relocation record format.
- Should convert to a typedef someday for greater opacity.
-
-md_got_reloc(r)
-
- Adjustment to be applied to the relocation value of references
- to "_GLOBAL_OFFSET_TABLE". It's here because of Sun's sparc as(1),
- (it's is a *bug*), and could have been `#ifdef SUN_COMPAT' if I
- had not let it slip into NetBSD's gas for compatibility.
-
-md_get_rt_segment_addend(r,a)
-
- Another SunOS bug workaround.
-
-
-The macros below have defaults defined in ld.h for the traditional relocation
-structure format; each takes a `struct relocation_info *' argument (see
-ld.h for more detailed comments):
-
-RELOC_ADDRESS(r) - the address at which to relocate
-RELOC_EXTERN_P(r) - relocation for external symbol
-RELOC_TYPE(r) - segment (text/data/bss), non-external relocs
-RELOC_SYMBOL(r) - symbol index, external relocs
-RELOC_MEMORY_SUB_P(r) - relocation involves something to subtract
-RELOC_MEMORY_ADD_P(r) - relocation involves something to add
-RELOC_ADD_EXTRA(r) - <disused> (moved into MD files)
-RELOC_PCREL_P(r) - relocation is PC relative
-RELOC_VALUE_RIGHTSHIFT(r) - <disused>
-RELOC_TARGET_SIZE(r) - size (in bytes) of relocated value
-RELOC_TARGET_BITPOS(r) - <disused> (moved into MD files)
-RELOC_TARGET_BITSIZE(r) - <disused> (moved into MD files)
-RELOC_JMPTAB_P(r) - relocation is for a PLT entry
-RELOC_BASEREL_P(r) - relocation is for a GOT entry
-RELOC_RELATIVE_P(r) - relocation is load address relative
-RELOC_COPY_P(r) - relocation involves an initialization
-RELOC_INIT_SEGMENT_RELOC(r) - initialize a relocation record pertaining to
- a segment; traditional archs can use bzero().
-RELOC_LAZY_P(r) - (run-time) resolution can be lazy.
-CHECK_GOT_RELOC(r) - consistency check on relocations involving
- the "_GLOBAL_OFFSET_TABLE" symbol
-
-
-
-Things which are currently defined as routines in <machine>/md.c:
-
-
-md_init_header(struct exec *hp, int magic, int flags)
-
- Initializes the output file header. Straightforward, unless
- multiple OS'es are supported.
-
-
-md_swap*_exec_hdr(struct exec *)
-
- Input/output a.out header in target byte-order.
-
-
-md_swap*_reloc(struct relocation_info *, n)
-
- Input/output N relocation records in target byte-order.
-
-
-md_get_addend(struct relocation_info *rp, char *addr)
-
- Return a relocation addend. Traditionally found in the object file
- at address ADDR. The relocation record determines the data width
- in bytes (using RELOC_TARGET_SIZE()).
-
-md_relocate(struct relocation_info *rp, long reloc, char *addr,
- int relocatable_output)
-
- Perform a relocation at the given address, usually by entering
- the specified value RELOC into the object file. Some architectures
- may store the relocation in RP when RELOCATABLE_OUTPUT is set.
- Again, the byte size of the relocation value is determined from
- RP through RELOC_TARGET_SIZE().
-
-md_make_reloc(struct relocation_info *rp, int type)
-
- Construct the machine dependent part of a relocation record used
- for run-time relocation. Sets RP's type field or one or more
- bitfields according to TYPE which is ld's internal relocation
- representation of the type of (run-time) relocation. TYPE is a
- combination of the following bits:
-
- RELTYPE_EXTERN - relocation is for unresolved symbol
- RELTYPE_JMPSLOT - relocation is for a PLT entry
- RELTYPE_BASEREL - <not used>
- RELTYPE_RELATIVE - relocation is load address relative
- RELTYPE_COPY - relocation is an initalization
-
-md_make_jmpreloc(struct relocation_info *rp, *r, int type)
-
- Set up a run-time relocation record pertaining to a jmpslot.
- This usually sets a bit or a relocation type dedicated to jmpslot
- relocations. R is the relocation record to be updated (ie. the
- run-time relocation record), while RP points at the relocation
- record from the object file on behalf of which we allocated a
- PLT entry. RP may not be needed.
-
-md_make_gotreloc(struct relocation_info *rp, *r, int type)
-
- Set up a run-time relocation record pertaining to a GOT entry.
- This usually sets a bit or a relocation type dedicated to GOT
- relocations. R is the relocation record to be updated (ie. the
- run-time relocation record), while RP points at the relocation
- record from the object file on behalf of which we allocated a
- GOT entry.
-
-md_make_cpyreloc(struct relocation_info *rp, *r)
-
- Mark the relocation record as pertaining to a location that needs
- run-time initializing from some shared object source.
- R and RP same as above.
-
-md_make_jmpslot(jmpslot_t *sp, long offset, long index)
-
- Construct a jmpslot, ie. fill in the machine opcodes that comprise
- a transfer to slot 0 of the PLT. OFFSET is the location of SP
- relative to the start of the PLT (ie. (int)sp - (int)&PLT[0] ).
- INDEX is the entry in the run-time relocation record table which
- determines what symbol this jmpslot is supposed to resolve.
-
-md_fix_jmpslot(jmpslot_t *sp, long offset, long addr)
-
- Fix up a jmpslot so that it will transfer directly to ADDR
- in stead of to PLT[0]. OFFSET has the same meaning as in
- md_make_jmpslot(). This function is called by binder() after
- it has resolved a symbol into a (run-time) address.
-
-md_set_breakpoint(long where, long *savep)
-
- Set a breakpoint. Used when run under a debugger. The breakpoint
- instruction is to be set at location WHERE. The original contents
- of *WHERE is to be saved in *SAVEP.
-
-
diff --git a/gnu/usr.bin/ld/dynamic.h b/gnu/usr.bin/ld/dynamic.h
deleted file mode 100644
index c1890db..0000000
--- a/gnu/usr.bin/ld/dynamic.h
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id: dynamic.h,v 1.3 1997/02/22 15:46:18 peter Exp $
- */
-
-#ifndef __DYNAMIC_H__
-#define __DYNAMIC_H__
-
-#define SUN_COMPAT
-
-#include "md.h"
-#include "link.h"
-
-#ifndef RELOC_JMPTAB_P
-
-#define RELOC_JMPTAB_P(r) ((r)->r_jmptable)
-#define RELOC_BASEREL_P(r) ((r)->r_baserel)
-#define RELOC_RELATIVE_P(r) ((r)->r_relative)
-#define RELOC_COPY_P(r) ((r)->r_copy)
-#define RELOC_LAZY_P(r) ((r)->r_jmptable)
-
-#define CHECK_GOT_RELOC(r) ((r)->r_pcrel)
-#define RELOC_PIC_TYPE(r) ((r)->r_baserel? \
- PIC_TYPE_LARGE:PIC_TYPE_NONE)
-#endif
-
-#ifndef RELOC_INIT_SEGMENT_RELOC
-#define RELOC_INIT_SEGMENT_RELOC(r)
-#endif
-
-#ifndef MAX_GOTOFF
-#define MAX_GOTOFF(x) (LONG_MAX)
-#endif
-
-#ifndef MIN_GOTOFF
-#define MIN_GOTOFF(x) (LONG_MIN)
-#endif
-
-/*
- * Internal representation of relocation types
- */
-#define RELTYPE_EXTERN 1
-#define RELTYPE_JMPSLOT 2
-#define RELTYPE_BASEREL 4
-#define RELTYPE_RELATIVE 8
-#define RELTYPE_COPY 16
-
-#define N_ISWEAK(p) (N_BIND(p) & BIND_WEAK)
-
-typedef struct localsymbol {
- struct nzlist nzlist; /* n[z]list from file */
- struct glosym *symbol; /* Corresponding global symbol,
- if any */
- struct localsymbol *next; /* List of definitions */
- struct file_entry *entry; /* Backpointer to file */
- long gotslot_offset; /* Position in GOT, if any */
- int symbolnum; /* Position in output nlist */
- int flags;
-#define LS_L_SYMBOL 1 /* Local symbol starts with an `L' */
-#define LS_WRITE 2 /* Symbol goes in output symtable */
-#define LS_RENAME 4 /* xlat name to `<file>.<name>' */
-#define LS_HASGOTSLOT 8 /* This symbol has a GOT entry */
-#define LS_WARNING 16 /* Second part of a N_WARNING duo */
-} localsymbol_t;
-
-/*
- * Global symbol data is recorded in these structures, one for each global
- * symbol. They are found via hashing in 'symtab', which points to a vector
- * of buckets. Each bucket is a chain of these structures through the link
- * field.
- *
- * Rewritten version to support extra info for dynamic linking.
- */
-
-struct glosym {
- struct glosym *link; /* Next symbol hash bucket. */
- char *name; /* Name of this symbol. */
- long value; /* Value of this symbol */
- localsymbol_t *refs; /* Chain of local symbols from object
- files pertaining to this global
- symbol */
- localsymbol_t *sorefs;/* Same for local symbols from shared
- object files. */
-
- char *warning; /* message, from N_WARNING nlists */
- int common_size; /* Common size */
- int symbolnum; /* Symbol index in output symbol table */
- int rrs_symbolnum; /* Symbol index in RRS symbol table */
-
- localsymbol_t *def_lsp; /* The local symbol that gave this
- global symbol its definition */
-
- char defined; /* Definition of this symbol */
- char so_defined; /* Definition of this symbol in a shared
- object. These go into the RRS symbol table */
- u_char undef_refs; /* Count of number of "undefined"
- messages printed for this symbol */
- u_char mult_defs; /* Same for "multiply defined" symbols */
- struct glosym *alias; /* For symbols of type N_INDR, this
- points at the real symbol. */
- int setv_count; /* Number of elements in N_SETV symbols */
- int size; /* Size of this symbol (either from N_SIZE
- symbols or a from shared object's RRS */
- int aux; /* Auxiliary type information conveyed in
- the `n_other' field of nlists */
-
- /* The offset into one of the RRS tables, -1 if not used */
- long jmpslot_offset;
- long gotslot_offset;
-
- long flags;
-
-#define GS_DEFINED 0x1 /* Symbol has definition (notyetused)*/
-#define GS_REFERENCED 0x2 /* Symbol is referred to by something
- interesting */
-#define GS_TRACE 0x4 /* Symbol will be traced */
-#define GS_HASJMPSLOT 0x8 /* */
-#define GS_HASGOTSLOT 0x10 /* Some state bits concerning */
-#define GS_CPYRELOCRESERVED 0x20 /* entries in GOT and PLT tables */
-#define GS_CPYRELOCCLAIMED 0x40 /* */
-#define GS_WEAK 0x80 /* Symbol is weakly defined */
-
-};
-#ifndef __symbol_defined__
-#define __symbol_defined__
-typedef struct glosym symbol;
-#endif
-
-/* The symbol hash table: a vector of SYMTABSIZE pointers to struct glosym. */
-extern symbol *symtab[];
-#define FOR_EACH_SYMBOL(i,sp) { \
- int i; \
- for (i = 0; i < SYMTABSIZE; i++) { \
- register symbol *sp; \
- for (sp = symtab[i]; sp; sp = sp->link)
-
-#define END_EACH_SYMBOL }}
-
-extern symbol *got_symbol; /* the symbol __GLOBAL_OFFSET_TABLE_ */
-extern symbol *dynamic_symbol; /* the symbol __DYNAMIC */
-
-/*
- * Each input file, and each library member ("subfile") being loaded, has a
- * `file_entry' structure for it.
- *
- * For files specified by command args, these are contained in the vector which
- * `file_table' points to.
- *
- * For library members, they are dynamically allocated, and chained through the
- * `chain' field. The chain is found in the `subfiles' field of the
- * `file_entry'. The `file_entry' objects for the members have `superfile'
- * fields pointing to the one for the library.
- *
- * Rewritten version to support extra info for dynamic linking.
- */
-
-struct file_entry {
- char *filename; /* Name of this file. */
- /*
- * Name to use for the symbol giving address of text start Usually
- * the same as filename, but for a file spec'd with -l this is the -l
- * switch itself rather than the filename.
- */
- char *local_sym_name;
- struct exec header; /* The file's a.out header. */
- localsymbol_t *symbols; /* Symbol table of the file. */
- int nsymbols; /* Number of symbols in above array. */
- int string_size; /* Size in bytes of string table. */
- char *strings; /* Pointer to the string table when
- in core, NULL otherwise */
- int strings_offset; /* Offset of string table,
- (normally N_STROFF() + 4) */
- /*
- * Next two used only if `relocatable_output' or if needed for
- * output of undefined reference line numbers.
- */
- struct relocation_info *textrel; /* Text relocations */
- int ntextrel; /* # of text relocations */
- struct relocation_info *datarel; /* Data relocations */
- int ndatarel; /* # of data relocations */
-
- /*
- * Relation of this file's segments to the output file.
- */
- int text_start_address; /* Start of this file's text segment
- in the output file core image. */
- int data_start_address; /* Start of this file's data segment
- in the output file core image. */
- int bss_start_address; /* Start of this file's bss segment
- in the output file core image. */
- struct file_entry *subfiles; /* For a library, points to chain of
- entries for the library members. */
- struct file_entry *superfile; /* For library member, points to the
- library's own entry. */
- struct file_entry *chain; /* For library member, points to next
- entry for next member. */
- int starting_offset; /* For a library member, offset of the
- member within the archive. Zero for
- files that are not library members.*/
- int total_size; /* Size of contents of this file,
- if library member. */
-#ifdef SUN_COMPAT
- struct file_entry *silly_archive;/* For shared libraries which have
- a .sa companion */
-#endif
- int lib_major, lib_minor; /* Version numbers of a shared object */
-
- int flags;
-#define E_IS_LIBRARY 1 /* File is a an archive */
-#define E_HEADER_VALID 2 /* File's header has been read */
-#define E_SEARCH_DIRS 4 /* Search directories for file */
-#define E_SEARCH_DYNAMIC 8 /* Search for shared libs allowed */
-#define E_JUST_SYMS 0x10 /* File is used for incremental load */
-#define E_DYNAMIC 0x20 /* File is a shared object */
-#define E_SCRAPPED 0x40 /* Ignore this file */
-#define E_SYMBOLS_USED 0x80 /* Symbols from this entry were used */
-#define E_SECONDCLASS 0x100 /* Shared object is a subsidiary */
-};
-
-/*
- * Runtime Relocation Section (RRS).
- * This describes the data structures that go into the output text and data
- * segments to support the run-time linker. The RRS can be empty (plain old
- * static linking), or can just exist of GOT and PLT entries (in case of
- * statically linked PIC code).
- */
-extern int rrs_section_type; /* What's in the RRS section */
-#define RRS_NONE 0
-#define RRS_PARTIAL 1
-#define RRS_FULL 2
-extern int rrs_text_size; /* Size of RRS text additions */
-extern int rrs_text_start; /* Location of above */
-extern int rrs_data_size; /* Size of RRS data additions */
-extern int rrs_data_start; /* Location of above */
-extern char *rrs_search_paths; /* `-L' RT paths */
-
-/* Version number to put in __DYNAMIC (set by -V) */
-extern int soversion;
-#ifndef DEFAULT_SOVERSION
-#define DEFAULT_SOVERSION LD_VERSION_BSD
-#endif
-
-extern int pc_relocation; /* Current PC reloc value */
-
-extern int number_of_shobjs; /* # of shared objects linked in */
-
-/* Current link mode */
-extern int link_mode;
-#define DYNAMIC 1 /* Consider shared libraries */
-#define SYMBOLIC 2 /* Force symbolic resolution */
-#define FORCEARCHIVE 4 /* Force inclusion of all members
- of archives */
-#define SHAREABLE 8 /* Build a shared object */
-#define SILLYARCHIVE 16 /* Process .sa companions, if any */
-#define FORCEDYNAMIC 32 /* Force dynamic output even if no
- shared libraries included */
-#define WARNRRSTEXT 64 /* Warn about rrs in text */
-
-extern FILE *outstream; /* Output file. */
-extern struct exec outheader; /* Output file header. */
-extern int magic; /* Output file magic. */
-extern int oldmagic;
-extern int relocatable_output;
-extern int pic_type;
-#define PIC_TYPE_NONE 0
-#define PIC_TYPE_SMALL 1
-#define PIC_TYPE_LARGE 2
-
-void read_header __P((int, struct file_entry *));
-void read_entry_symbols __P((int, struct file_entry *));
-void read_entry_strings __P((int, struct file_entry *));
-void read_entry_relocation __P((int, struct file_entry *));
-void enter_file_symbols __P((struct file_entry *));
-void read_file_symbols __P((struct file_entry *));
-int set_element_prefixed_p __P((char *));
-int text_offset __P((struct file_entry *));
-int file_open __P((struct file_entry *));
-void each_file __P((void (*)(), void *));
-void each_full_file __P((void (*)(), void *));
-unsigned long check_each_file __P((unsigned long (*)(), void *));
-void mywrite __P((void *, int, int, FILE *));
-void padfile __P((int, FILE *));
-
-/* In warnings.c: */
-void perror_name __P((char *));
-void perror_file __P((struct file_entry *));
-void print_symbols __P((FILE *));
-char *get_file_name __P((struct file_entry *));
-void print_file_name __P((struct file_entry *, FILE *));
-void prline_file_name __P((struct file_entry *, FILE *));
-int do_warnings __P((FILE *));
-
-/* In etc.c: */
-#include "support.h"
-
-/* In symbol.c: */
-void symtab_init __P((int));
-symbol *getsym __P((char *)), *getsym_soft __P((char *));
-
-/* In lib.c: */
-void search_library __P((int, struct file_entry *));
-void read_shared_object __P((int, struct file_entry *));
-int findlib __P((struct file_entry *));
-
-/* In shlib.c: */
-#include "shlib.h"
-
-/* In rrs.c: */
-void init_rrs __P((void));
-int rrs_add_shobj __P((struct file_entry *));
-void alloc_rrs_reloc __P((struct file_entry *, symbol *));
-void alloc_rrs_segment_reloc __P((struct file_entry *, struct relocation_info *));
-void alloc_rrs_jmpslot __P((struct file_entry *, symbol *));
-void alloc_rrs_gotslot __P((struct file_entry *, struct relocation_info *, localsymbol_t *));
-void alloc_rrs_cpy_reloc __P((struct file_entry *, symbol *));
-
-int claim_rrs_reloc __P((struct file_entry *, struct relocation_info *, symbol *, long *));
-long claim_rrs_jmpslot __P((struct file_entry *, struct relocation_info *, symbol *, long));
-long claim_rrs_gotslot __P((struct file_entry *, struct relocation_info *, struct localsymbol *, long));
-long claim_rrs_internal_gotslot __P((struct file_entry *, struct relocation_info *, struct localsymbol *, long));
-void claim_rrs_cpy_reloc __P((struct file_entry *, struct relocation_info *, symbol *));
-void claim_rrs_segment_reloc __P((struct file_entry *, struct relocation_info *));
-void consider_rrs_section_lengths __P((void));
-void relocate_rrs_addresses __P((void));
-void write_rrs __P((void));
-
-/* In <md>.c */
-void md_init_header __P((struct exec *, int, int));
-long md_get_addend __P((struct relocation_info *, unsigned char *));
-void md_relocate __P((struct relocation_info *, long, unsigned char *, int));
-void md_make_jmpslot __P((jmpslot_t *, long, long));
-void md_fix_jmpslot __P((jmpslot_t *, long, u_long));
-int md_make_reloc __P((struct relocation_info *, struct relocation_info *, int));
-void md_make_jmpreloc __P((struct relocation_info *, struct relocation_info *, int));
-void md_make_gotreloc __P((struct relocation_info *, struct relocation_info *, int));
-void md_make_copyreloc __P((struct relocation_info *, struct relocation_info *));
-void md_set_breakpoint __P((long, long *));
-
-#ifdef NEED_SWAP
-/* In xbits.c: */
-void swap_longs __P((long *, int));
-void swap_symbols __P((struct nlist *, int));
-void swap_zsymbols __P((struct nzlist *, int));
-void swap_ranlib_hdr __P((struct ranlib *, int));
-void swap__dynamic __P((struct link_dynamic *));
-void swap_section_dispatch_table __P((struct section_dispatch_table *));
-void swap_so_debug __P((struct so_debug *));
-void swapin_sod __P((struct sod *, int));
-void swapout_sod __P((struct sod *, int));
-void swapout_fshash __P((struct fshash *, int));
-#endif
-
-#endif /* __DYNAMIC_H__ */
diff --git a/gnu/usr.bin/ld/i386/md-static-funcs.c b/gnu/usr.bin/ld/i386/md-static-funcs.c
deleted file mode 100644
index 758a4b2..0000000
--- a/gnu/usr.bin/ld/i386/md-static-funcs.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * $Id$
- *
- * Called by ld.so when onanating.
- * This *must* be a static function, so it is not called through a jmpslot.
- */
-
-static void
-md_relocate_simple(r, relocation, addr)
-struct relocation_info *r;
-long relocation;
-char *addr;
-{
- if (r->r_relative)
- *(long *)addr += relocation;
-}
-
diff --git a/gnu/usr.bin/ld/i386/md.c b/gnu/usr.bin/ld/i386/md.c
deleted file mode 100644
index 8e945e8..0000000
--- a/gnu/usr.bin/ld/i386/md.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id$
- */
-
-#include <sys/param.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <err.h>
-#include <fcntl.h>
-#include <a.out.h>
-#include <stab.h>
-#include <string.h>
-
-#include "dynamic.h"
-
-#if defined(RTLD) && defined(SUN_COMPAT)
-#define REL_SIZE(r) (2) /* !!!!! Sun BUG compatible */
-#else
-#define REL_SIZE(r) ((r)->r_length)
-#endif
-
-/*
- * Get relocation addend corresponding to relocation record RP
- * from address ADDR
- */
-long
-md_get_addend(rp, addr)
-struct relocation_info *rp;
-unsigned char *addr;
-{
- switch (REL_SIZE(rp)) {
- case 0:
- return get_byte(addr);
- case 1:
- return get_short(addr);
- case 2:
- return get_long(addr);
- default:
- errx(1, "Unsupported relocation size: %x",
- REL_SIZE(rp));
- }
-}
-
-/*
- * Put RELOCATION at ADDR according to relocation record RP.
- */
-void
-md_relocate(rp, relocation, addr, relocatable_output)
-struct relocation_info *rp;
-long relocation;
-unsigned char *addr;
-int relocatable_output;
-{
- switch (REL_SIZE(rp)) {
- case 0:
- put_byte(addr, relocation);
- break;
- case 1:
- put_short(addr, relocation);
- break;
- case 2:
- put_long(addr, relocation);
- break;
- default:
- errx(1, "Unsupported relocation size: %x",
- REL_SIZE(rp));
- }
-}
-
-/*
- * Machine dependent part of claim_rrs_reloc().
- * Set RRS relocation type.
- */
-int
-md_make_reloc(rp, r, type)
-struct relocation_info *rp, *r;
-int type;
-{
- /* Relocation size */
- r->r_length = rp->r_length;
-
- if (rp->r_pcrel)
- r->r_pcrel = 1;
-
- if (type & RELTYPE_RELATIVE)
- r->r_relative = 1;
-
- if (type & RELTYPE_COPY)
- r->r_copy = 1;
-
- return 0;
-}
-
-/*
- * Set up a transfer from jmpslot at OFFSET (relative to the PLT table)
- * to the binder slot (which is at offset 0 of the PLT).
- */
-void
-md_make_jmpslot(sp, offset, index)
-jmpslot_t *sp;
-long offset;
-long index;
-{
- /*
- * i386 PC-relative "fixed point" is located right after the
- * instruction it pertains to.
- */
- u_long fudge = - (sizeof(sp->opcode) + sizeof(sp->addr) + offset);
-
- sp->opcode = CALL;
-#if 0
- sp->addr = fudge;
-#else
- sp->addr[0] = fudge & 0xffff;
- sp->addr[1] = fudge >> 16;
-#endif
- sp->reloc_index = index;
-}
-
-/*
- * Set up a "direct" transfer (ie. not through the run-time binder) from
- * jmpslot at OFFSET to ADDR. Used by `ld' when the SYMBOLIC flag is on,
- * and by `ld.so' after resolving the symbol.
- * On the i386, we use the JMP instruction which is PC relative, so no
- * further RRS relocations will be necessary for such a jmpslot.
- */
-void
-md_fix_jmpslot(sp, offset, addr)
-jmpslot_t *sp;
-long offset;
-u_long addr;
-{
- u_long fudge = addr - (sizeof(sp->opcode) + sizeof(sp->addr) + offset);
-
- sp->opcode = JUMP;
-#if 0
- sp->addr = fudge;
-#else
- sp->addr[0] = fudge & 0xffff;
- sp->addr[1] = fudge >> 16;
-#endif
- sp->reloc_index = 0;
-}
-
-/*
- * Bind a jmpslot to its target address. TARGET is where the jmpslot
- * should jump to, and WHERE is a pointer to the jmpslot's address field.
- * This is called by the dynamic linker when LD_BIND_NOW is set in the
- * environment.
- */
-void
-md_bind_jmpslot(target, where)
-u_long target;
-caddr_t where;
-{
- jmpslot_t *sp =
- (jmpslot_t *) (where - offsetof(jmpslot_t, addr[0]));
-
- md_fix_jmpslot(sp, (long) sp, target);
-}
-
-/*
- * Update the relocation record for a RRS jmpslot.
- */
-void
-md_make_jmpreloc(rp, r, type)
-struct relocation_info *rp, *r;
-int type;
-{
- jmpslot_t *sp;
-
- /*
- * Fix relocation address to point to the correct
- * location within this jmpslot.
- */
- r->r_address += sizeof(sp->opcode);
-
- /* Relocation size */
- r->r_length = 2;
-
- /* Set relocation type */
- r->r_jmptable = 1;
- if (type & RELTYPE_RELATIVE)
- r->r_relative = 1;
-
-}
-
-/*
- * Set relocation type for a RRS GOT relocation.
- */
-void
-md_make_gotreloc(rp, r, type)
-struct relocation_info *rp, *r;
-int type;
-{
- r->r_baserel = 1;
- if (type & RELTYPE_RELATIVE)
- r->r_relative = 1;
-
- /* Relocation size */
- r->r_length = 2;
-}
-
-/*
- * Set relocation type for a RRS copy operation.
- */
-void
-md_make_cpyreloc(rp, r)
-struct relocation_info *rp, *r;
-{
- /* Relocation size */
- r->r_length = 2;
-
- r->r_copy = 1;
-}
-
-void
-md_set_breakpoint(where, savep)
-long where;
-long *savep;
-{
- *savep = *(long *)where;
- *(char *)where = TRAP;
-}
-
-#ifndef RTLD
-
-#ifdef __FreeBSD__
-int netzmagic;
-#endif
-
-/*
- * Initialize (output) exec header such that useful values are
- * obtained from subsequent N_*() macro evaluations.
- */
-void
-md_init_header(hp, magic, flags)
-struct exec *hp;
-int magic, flags;
-{
-#ifdef NetBSD
- if (oldmagic || magic == QMAGIC)
- hp->a_midmag = magic;
- else
- N_SETMAGIC((*hp), magic, MID_I386, flags);
-#endif
-#ifdef __FreeBSD__
- if (oldmagic)
- hp->a_midmag = magic;
- else if (netzmagic)
- N_SETMAGIC_NET((*hp), magic, MID_I386, flags);
- else
- N_SETMAGIC((*hp), magic, MID_I386, flags);
-#endif
-
- /* TEXT_START depends on the value of outheader.a_entry. */
- if (!(link_mode & SHAREABLE))
- hp->a_entry = PAGSIZ;
-}
-#endif /* RTLD */
-
-
-#ifdef NEED_SWAP
-/*
- * Byte swap routines for cross-linking.
- */
-
-void
-md_swapin_exec_hdr(h)
-struct exec *h;
-{
- int skip = 0;
-
- if (!N_BADMAG(*h))
- skip = 1;
-
- swap_longs((long *)h + skip, sizeof(*h)/sizeof(long) - skip);
-}
-
-void
-md_swapout_exec_hdr(h)
-struct exec *h;
-{
- /* NetBSD: Always leave magic alone */
- int skip = 1;
-#if 0
- if (N_GETMAGIC(*h) == OMAGIC)
- skip = 0;
-#endif
-
- swap_longs((long *)h + skip, sizeof(*h)/sizeof(long) - skip);
-}
-
-
-void
-md_swapin_reloc(r, n)
-struct relocation_info *r;
-int n;
-{
- int bits;
-
- for (; n; n--, r++) {
- r->r_address = md_swap_long(r->r_address);
- bits = ((int *)r)[1];
- r->r_symbolnum = md_swap_long(bits) & 0x00ffffff;
- r->r_pcrel = (bits & 1);
- r->r_length = (bits >> 1) & 3;
- r->r_extern = (bits >> 3) & 1;
- r->r_baserel = (bits >> 4) & 1;
- r->r_jmptable = (bits >> 5) & 1;
- r->r_relative = (bits >> 6) & 1;
-#ifdef N_SIZE
- r->r_copy = (bits >> 7) & 1;
-#endif
- }
-}
-
-void
-md_swapout_reloc(r, n)
-struct relocation_info *r;
-int n;
-{
- int bits;
-
- for (; n; n--, r++) {
- r->r_address = md_swap_long(r->r_address);
- bits = md_swap_long(r->r_symbolnum) & 0xffffff00;
- bits |= (r->r_pcrel & 1);
- bits |= (r->r_length & 3) << 1;
- bits |= (r->r_extern & 1) << 3;
- bits |= (r->r_baserel & 1) << 4;
- bits |= (r->r_jmptable & 1) << 5;
- bits |= (r->r_relative & 1) << 6;
-#ifdef N_SIZE
- bits |= (r->r_copy & 1) << 7;
-#endif
- ((int *)r)[1] = bits;
- }
-}
-
-void
-md_swapout_jmpslot(j, n)
-jmpslot_t *j;
-int n;
-{
- for (; n; n--, j++) {
- j->opcode = md_swap_short(j->opcode);
- j->addr[0] = md_swap_short(j->addr[0]);
- j->addr[1] = md_swap_short(j->addr[1]);
- j->reloc_index = md_swap_short(j->reloc_index);
- }
-}
-
-#endif /* NEED_SWAP */
diff --git a/gnu/usr.bin/ld/i386/md.h b/gnu/usr.bin/ld/i386/md.h
deleted file mode 100644
index 84785de..0000000
--- a/gnu/usr.bin/ld/i386/md.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id: md.h,v 1.16 1997/02/22 15:46:34 peter Exp $
- */
-
-#ifndef __MD_H__
-#define __MD_H__
-
-#if defined(CROSS_LINKER) && defined(XHOST) && XHOST==sparc
-#define NEED_SWAP
-#endif
-
-#define MAX_ALIGNMENT (sizeof (long))
-
-#ifdef NetBSD
-#define PAGSIZ __LDPGSZ
-#else
-#define PAGSIZ 4096
-#endif
-
-#if defined(NetBSD) || defined(CROSS_LINKER)
-
-#define N_SET_FLAG(ex,f) (oldmagic || N_GETMAGIC(ex)==QMAGIC ? (0) : \
- N_SETMAGIC(ex, \
- N_GETMAGIC(ex), \
- MID_MACHINE, \
- N_GETFLAG(ex)|(f)))
-
-#define N_IS_DYNAMIC(ex) ((N_GETFLAG(ex) & EX_DYNAMIC))
-
-#define N_BADMID(ex) \
- (N_GETMID(ex) != 0 && N_GETMID(ex) != MID_MACHINE)
-
-#endif
-
-/*
- * FreeBSD does it differently
- */
-#ifdef __FreeBSD__
-#define N_SET_FLAG(ex,f) (oldmagic ? (0) : \
- (netzmagic == 0 ? \
- N_SETMAGIC(ex, \
- N_GETMAGIC(ex), \
- MID_MACHINE, \
- N_GETFLAG(ex)|(f)) : \
- N_SETMAGIC_NET(ex, \
- N_GETMAGIC_NET(ex), \
- MID_MACHINE, \
- N_GETFLAG_NET(ex)|(f)) ))
-
-#define N_IS_DYNAMIC(ex) ((N_GETMAGIC_NET(ex) == ZMAGIC) ? \
- ((N_GETFLAG_NET(ex) & EX_DYNAMIC)) : \
- ((N_GETFLAG(ex) & EX_DYNAMIC) ))
-#define N_BADMID(ex) 0
-#endif
-
-/*
- * Should be handled by a.out.h ?
- */
-#define N_ADJUST(ex) (((ex).a_entry < PAGSIZ) ? -PAGSIZ : 0)
-#define TEXT_START(ex) (N_TXTADDR(ex) + N_ADJUST(ex))
-#define DATA_START(ex) (N_DATADDR(ex) + N_ADJUST(ex))
-
-#define RELOC_STATICS_THROUGH_GOT_P(r) (0)
-#define JMPSLOT_NEEDS_RELOC (0)
-
-#define md_got_reloc(r) (0)
-
-#define md_get_rt_segment_addend(r,a) md_get_addend(r,a)
-
-#define RELOC_INIT_SEGMENT_RELOC(r) ((r)->r_length = 2)
-
-/* Width of a Global Offset Table entry */
-#define GOT_ENTRY_SIZE 4
-typedef long got_t;
-
-typedef struct jmpslot {
- u_short opcode;
- u_short addr[2];
- u_short reloc_index;
-#define JMPSLOT_RELOC_MASK 0xffff
-} jmpslot_t;
-
-#define NOP 0x90
-#define CALL 0xe890 /* NOP + CALL opcode */
-#define JUMP 0xe990 /* NOP + JMP opcode */
-#define TRAP 0xcc /* INT 3 */
-
-/*
- * Byte swap defs for cross linking
- */
-
-#if !defined(NEED_SWAP)
-
-#define md_swapin_exec_hdr(h)
-#define md_swapout_exec_hdr(h)
-#define md_swapin_symbols(s,n)
-#define md_swapout_symbols(s,n)
-#define md_swapin_zsymbols(s,n)
-#define md_swapout_zsymbols(s,n)
-#define md_swapin_reloc(r,n)
-#define md_swapout_reloc(r,n)
-#define md_swapin__dynamic(l)
-#define md_swapout__dynamic(l)
-#define md_swapin_section_dispatch_table(l)
-#define md_swapout_section_dispatch_table(l)
-#define md_swapin_so_debug(d)
-#define md_swapout_so_debug(d)
-#define md_swapin_rrs_hash(f,n)
-#define md_swapout_rrs_hash(f,n)
-#define md_swapin_sod(l,n)
-#define md_swapout_sod(l,n)
-#define md_swapout_jmpslot(j,n)
-#define md_swapout_got(g,n)
-#define md_swapin_ranlib_hdr(h,n)
-#define md_swapout_ranlib_hdr(h,n)
-
-#endif /* NEED_SWAP */
-
-#ifdef CROSS_LINKER
-
-#define get_byte(p) ( ((unsigned char *)(p))[0] )
-
-#define get_short(p) ( ( ((unsigned char *)(p))[0] << 8) | \
- ( ((unsigned char *)(p))[1] ) \
- )
-
-#define get_long(p) ( ( ((unsigned char *)(p))[0] << 24) | \
- ( ((unsigned char *)(p))[1] << 16) | \
- ( ((unsigned char *)(p))[2] << 8 ) | \
- ( ((unsigned char *)(p))[3] ) \
- )
-
-#define put_byte(p, v) { ((unsigned char *)(p))[0] = ((unsigned long)(v)); }
-
-#define put_short(p, v) { ((unsigned char *)(p))[0] = \
- ((((unsigned long)(v)) >> 8) & 0xff); \
- ((unsigned char *)(p))[1] = \
- ((((unsigned long)(v)) ) & 0xff); }
-
-#define put_long(p, v) { ((unsigned char *)(p))[0] = \
- ((((unsigned long)(v)) >> 24) & 0xff); \
- ((unsigned char *)(p))[1] = \
- ((((unsigned long)(v)) >> 16) & 0xff); \
- ((unsigned char *)(p))[2] = \
- ((((unsigned long)(v)) >> 8) & 0xff); \
- ((unsigned char *)(p))[3] = \
- ((((unsigned long)(v)) ) & 0xff); }
-
-#ifdef NEED_SWAP
-
-/* Define IO byte swapping routines */
-
-void md_swapin_exec_hdr __P((struct exec *));
-void md_swapout_exec_hdr __P((struct exec *));
-void md_swapin_reloc __P((struct relocation_info *, int));
-void md_swapout_reloc __P((struct relocation_info *, int));
-void md_swapout_jmpslot __P((jmpslot_t *, int));
-
-#define md_swapin_symbols(s,n) swap_symbols(s,n)
-#define md_swapout_symbols(s,n) swap_symbols(s,n)
-#define md_swapin_zsymbols(s,n) swap_zsymbols(s,n)
-#define md_swapout_zsymbols(s,n) swap_zsymbols(s,n)
-#define md_swapin__dynamic(l) swap__dynamic(l)
-#define md_swapout__dynamic(l) swap__dynamic(l)
-#define md_swapin_section_dispatch_table(l) swap_section_dispatch_table(l)
-#define md_swapout_section_dispatch_table(l) swap_section_dispatch_table(l)
-#define md_swapin_so_debug(d) swap_so_debug(d)
-#define md_swapout_so_debug(d) swap_so_debug(d)
-#define md_swapin_rrs_hash(f,n) swap_rrs_hash(f,n)
-#define md_swapout_rrs_hash(f,n) swap_rrs_hash(f,n)
-#define md_swapin_sod(l,n) swapin_sod(l,n)
-#define md_swapout_sod(l,n) swapout_sod(l,n)
-#define md_swapout_got(g,n) swap_longs((long*)(g),n)
-#define md_swapin_ranlib_hdr(h,n) swap_ranlib_hdr(h,n)
-#define md_swapout_ranlib_hdr(h,n) swap_ranlib_hdr(h,n)
-
-#define md_swap_short(x) ( (((x) >> 8) & 0xff) | (((x) & 0xff) << 8) )
-
-#define md_swap_long(x) ( (((x) >> 24) & 0xff ) | (((x) >> 8 ) & 0xff00 ) | \
- (((x) << 8 ) & 0xff0000) | (((x) << 24) & 0xff000000))
-
-#else /* We need not swap, but must pay attention to alignment: */
-
-#define md_swap_short(x) (x)
-#define md_swap_long(x) (x)
-
-#endif /* NEED_SWAP */
-
-#else /* Not a cross linker: use native */
-
-#define md_swap_short(x) (x)
-#define md_swap_long(x) (x)
-
-#define get_byte(where) (*(char *)(where))
-#define get_short(where) (*(short *)(where))
-#define get_long(where) (*(long *)(where))
-
-#define put_byte(where,what) (*(char *)(where) = (what))
-#define put_short(where,what) (*(short *)(where) = (what))
-#define put_long(where,what) (*(long *)(where) = (what))
-
-#endif /* CROSS_LINKER */
-
-void md_init_header __P((struct exec *, int, int));
-long md_get_addend __P((struct relocation_info *, unsigned char *));
-void md_relocate __P((struct relocation_info *, long, unsigned char *, int));
-void md_make_jmpslot __P((jmpslot_t *, long, long));
-void md_fix_jmpslot __P((jmpslot_t *, long, u_long));
-void md_bind_jmpslot __P((u_long, caddr_t));
-int md_make_reloc __P((struct relocation_info *, struct relocation_info *, int));
-void md_make_jmpreloc __P((struct relocation_info *, struct relocation_info *, int));
-void md_make_gotreloc __P((struct relocation_info *, struct relocation_info *, int));
-void md_make_copyreloc __P((struct relocation_info *, struct relocation_info *));
-void md_set_breakpoint __P((long, long *));
-
-
-#endif /* __MD_H__ */
diff --git a/gnu/usr.bin/ld/i386/mdprologue.S b/gnu/usr.bin/ld/i386/mdprologue.S
deleted file mode 100644
index 091fe7f..0000000
--- a/gnu/usr.bin/ld/i386/mdprologue.S
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id$
- */
-
-/*
- * i386 run-time link editor entry points.
- */
-
-#include <sys/syscall.h>
-
- .text
- .globl _binder, _binder_entry
-
-/*
- * _rtl(int version, struct crt_ldso *crtp)
- */
-
-_rtl: # crt0 calls us here
- pushl %ebp # Allocate stack frame
- movl %esp,%ebp
- pushl %ebx
-
- call 1f # PIC function prologue
-1:
- popl %ebx
- addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx
-
- movl 12(%ebp),%eax # Extract data from interface structure
- movl (%eax),%eax # base address of ld.so (first field)
- # setup arguments for rtld()
- movl (%ebx),%ecx # 1st entry in GOT is our __DYNAMIC
- addl %eax,%ecx # add load address
- pushl %ecx # 3rd arg
- pushl 12(%ebp) # 2nd arg == &crt.
- pushl 8(%ebp) # 1st arg == version
- addl _rtld@GOT(%ebx),%eax # relocate address of function
- call %eax # _rtld(version, crtp, DYNAMIC)
- addl $12,%esp # pop arguments
-
- popl %ebx
- leave # remove stack frame
- ret
-
- # First call to a procedure generally comes through here for
- # binding.
-
-_binder_entry:
- pushl %ebp # setup a stack frame
- movl %esp,%ebp
- pusha # save all regs
-
- xorl %eax,%eax # clear
- movl 4(%ebp),%esi # return address in PLT
- movw (%esi),%ax # get hold of relocation number
- subl $6,%esi # make it point to the jmpslot
-
- pushl %eax # pushd arguments
- pushl %esi #
- call _binder@PLT # _binder(rpc, index)
- addl $8,%esp # pop arguments
- movl %eax,4(%ebp) # return value from _binder() == actual
- # address of function
- popa # restore regs
- leave # remove our stack frame
- ret
diff --git a/gnu/usr.bin/ld/ld.1 b/gnu/usr.bin/ld/ld.1
deleted file mode 100644
index 81e7684..0000000
--- a/gnu/usr.bin/ld/ld.1
+++ /dev/null
@@ -1,293 +0,0 @@
-.\"
-.\" Copyright (c) 1993 Paul Kranenburg
-.\" 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 Paul Kranenburg.
-.\" 3. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
-.\"
-.\" $Id: ld.1,v 1.18 1997/05/31 04:28:53 jdp Exp $
-.\"
-.Dd October 14, 1993
-.Dt LD 1
-.Os FreeBSD
-.Sh NAME
-.Nm ld
-.Nd link editor
-.Sh SYNOPSIS
-.Nm ld
-.Op Fl fMNnrSstXxz
-.Bk -words
-.Op Fl A Ar symbol-file
-.Op Fl assert Ar keyword
-.Op Fl B Ns Ar linkmode
-.Op Fl D Ar datasize
-.Op Fl d Ar c
-.Op Fl d Ar p
-.Op Fl e Ar entry
-.Op Fl l Ns Ar library-specifier
-.Op Fl L Ns Ar library-search-path
-.Op Fl nostdlib
-.Op Fl O Ar filename
-.Op Fl o Ar filename
-.Op Fl R Ns Ar record-library-search-path
-.Op Fl T Ar address
-.Op Fl u Ar symbol
-.Op Fl V Ar shlib-version
-.Op Fl y Ar symbol
-.Ek
-.Sh DESCRIPTION
-.Nm
-combines the object and archive files given on the command line into a new
-object file. The output object file is either an executable program, a
-shared object suitable for loading at run-time, or an object file that can
-once again be processed by
-.Nm ld.
-Object files and archives are processed in the order given on the command line.
-.Pp
-The options are as follows:
-.Pp
-.Bl -tag -width indent
-.It Fl A Ar symbol-file
-The the symbol-file is taken as a base for link-editing the object files
-on the command line.
-.It Fl assert Ar keyword
-This option is here mainly for compatibility with SunOS
-.Nm ld .
-Most conditions which would cause a Sun assertion to fail will
-currently always cause error or warning messages from
-.Nm ld .
-The only keyword implemented by
-.Nm ld
-is
-.Nm pure-text ,
-which generates a warning if a position independent object is being
-created and some of the files being linked are not position
-independent.
-.It Fl B Ns Ar dynamic
-Specifies that linking against dynamic libraries can take place. If a library
-specifier of the form -lx appears on the command line,
-.Nm ld
-searches for a library of the from libx.so.n.m
-.Po see the \&
-.Fl l
-option
-.Pc
-according to the search rules in effect. If such a file can not be
-found a traditional archive is looked for.
-This options can appear anywhere on the command line and is complementary
-to
-.Fl B Ns Ar static.
-.It Fl B Ns Ar forcedynamic
-This is similar to
-.Fl B Ns Ar dynamic
-except that if no dynamic libraries are linked against,
-.Nm ld
-will still produce a dynamic executable. This is useful for programs
-which are static but still need to load dynamic objects at runtime.
-.It Fl B Ns Ar static
-The counterpart of
-.Fl B Ns Ar dynamic .
-This option turns off dynamic linking for
-all library specifiers until a
-.Fl B Ns Ar dynamic
-is once again given. Any explicitly
-mentioned shared object encountered on the command line while this option is
-in effect is flagged as an error.
-.It Fl B Ns Ar shareable
-Instructs the linker to build a shared object from the object files rather
-than a normal executable image.
-.It Fl B Ns Ar symbolic
-This option causes all symbolic references in the output to be resolved in
-this link-edit session. The only remaining run-time relocation requirements are
-.Em base-relative
-relocations, ie. translation with respect to the load address. Failure to
-resolve any symbolic reference causes an error to be reported.
-.It Fl B Ns Ar forcearchive
-Force all members of archives to be loaded, whether or not such members
-contribute a definition to any plain object files. Useful for making a
-shared library from an archive of PIC objects without having to unpack
-the archive.
-.It Fl B Ns Ar silly
-Search for
-.Em \.sa
-silly archive companions of shared objects. Useful for compatibility with
-version 3 shared objects.
-.It Fl D Ar data-size
-Set the size of the data segment. For sanity's sake, this should be larger
-than the cumulative data sizes of the input files.
-.It Fl d Ar c
-Force allocation of commons even producing relocatable output.
-.It Fl d Ar p
-Force alias definitions of procedure calls in non-PIC code. Useful to
-obtain shareable code in the presence of run-time relocations as such
-calls will be re-directed through the Procedure Linkage Table (see
-.Xr link 5)
-.It Fl e Ar entry-symbol
-Specifies the entry symbol for an executable.
-.It Fl f
-List the resolved paths of all the object files and libraries on the
-standard output, and exit.
-.It Fl L Ns Ar path
-Add
-.Ar path
-to the list of directories to search for libraries specified with the
-.Fl l
-option.
-.It Fl l Ns Ar lib-spec
-This option specifies a library to be considered for inclusion in the
-output. If the
-.Fl B Ns Ar dynamic
-option is in effect, a shared library of the
-form lib<spec>.so.m.n
-.Po where \&
-.Em m
-is the major, and
-.Em n
-is the minor version number, respectively
-.Pc is searched for first. The
-library with the highest version found in the search path is selected.
-If no shared library is found or the
-.Fl B Ns Ar static
-options is in effect, an archive of the form lib<spec>.a is looked for in
-the library search path.
-.It Fl M
-Produce output about the mapping of segments of the input files and the
-values assigned to
-.Pq global
-symbols in the output file.
-.It Fl N
-Produce a
-.Dv OMAGIC
-output file.
-.It Fl n
-Produce a
-.Dv NMAGIC
-output file.
-.It Fl nostdlib
-Do not search the built-in path
-.Po
-usually
-.Dq /usr/lib
-.Pc
-for
-.Fl l
-specified libraries.
-.It Fl O Ar filename
-Specifies the name of the output file.
-The file is created as
-.Ar filename .tmp
-and when output is complete renamed to
-.Ar filename .
-.It Fl o Ar filename
-Specifies the name of the output file. Defaults to
-.Dq a.out.
-.It Fl Q
-Produce a
-.Dv QMAGIC
-(FreeBSD/BSDi-i386) output file. This is the default.
-.It Fl r
-Produce relocatable object file, suitable for another pass through
-.Nm ld.
-.It Fl R
-Record the given path within the executable for run-time library search.
-This only applies to dynamically linked executables.
-.It Fl S
-Strip all debugger symbols from the output.
-.It Fl s
-Strip all symbols from the output.
-.It Fl T
-Specifies the start address of the text segment, with respect to which
-all input files will be relocated.
-.It Fl t
-Leave a trace of the input files as they are processed.
-.It Fl u Ar symbol
-Force
-.Ar symbol
-to be marked as undefined. Useful to force loading of an archive member
-in the absence of any other references to that member.
-.It Fl V Ar version
-Put the given version number into the output shared library
-.Pq if one is created .
-Useful to make shared libraries compatible with other operating
-systems. E.g., SunOS 4.x libraries use version number 3. Defaults to 8.
-.It Fl X
-Discard local symbols in the input files that start with the letter
-.Dq L
-.It Fl x
-Discard all local symbols in the input files.
-.It Fl y Ar symbol
-Trace the manipulations inflicted on
-.Ar symbol
-.It Fl Z
-Make a 386BSD
-.Dv ZMAGIC
-output file.
-.It Fl z
-Make a NetBSD
-.Dv ZMAGIC
-output file.
-.Sh ENVIRONMENT
-.Nm
-utilizes the following environment variables:
-.Bl -tag -width "LD_LIBRARY_PATH"
-.It Ev LD_LIBRARY_PATH
-This colon-separated list of directories is inserted into the search
-path for libraries following any directories specified via
-.Fl L
-options and preceding the built-in path.
-.\" .It Ev LD_NOSTD_PATH
-.\" When set, do not search the built-in path for libraries.
-.\" This is an alternative to the
-.\" .Fl nostdlib
-.\" command-line flag.
-.El
-.Sh FILES
-.Sh SEE ALSO
-.Xr rtld 1 ,
-.Xr link 5 ,
-.Xr ldconfig 8
-.Sh CAVEATS
-An entry point must now explicitly be given if the output is intended to be
-a normal executable program. This was not the case for the previous version of
-.Nm ld .
-.Sh BUGS
-Shared objects are not properly checked for undefined symbols.
-.Pp
-Cascading of shared object defeats the
-.Dq -Bstatic
-option.
-.Pp
-All shared objects presented to
-.Nm ld
-are marked for run-time loading in the output file, even if no symbols
-are needed from them.
-.Sh HISTORY
-A
-.Nm
-command appeared in
-.At v1 .
-The shared library model employed by
-.Nm
-appeared first in SunOS 4.0
diff --git a/gnu/usr.bin/ld/ld.1aout b/gnu/usr.bin/ld/ld.1aout
deleted file mode 100644
index 81e7684..0000000
--- a/gnu/usr.bin/ld/ld.1aout
+++ /dev/null
@@ -1,293 +0,0 @@
-.\"
-.\" Copyright (c) 1993 Paul Kranenburg
-.\" 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 Paul Kranenburg.
-.\" 3. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
-.\"
-.\" $Id: ld.1,v 1.18 1997/05/31 04:28:53 jdp Exp $
-.\"
-.Dd October 14, 1993
-.Dt LD 1
-.Os FreeBSD
-.Sh NAME
-.Nm ld
-.Nd link editor
-.Sh SYNOPSIS
-.Nm ld
-.Op Fl fMNnrSstXxz
-.Bk -words
-.Op Fl A Ar symbol-file
-.Op Fl assert Ar keyword
-.Op Fl B Ns Ar linkmode
-.Op Fl D Ar datasize
-.Op Fl d Ar c
-.Op Fl d Ar p
-.Op Fl e Ar entry
-.Op Fl l Ns Ar library-specifier
-.Op Fl L Ns Ar library-search-path
-.Op Fl nostdlib
-.Op Fl O Ar filename
-.Op Fl o Ar filename
-.Op Fl R Ns Ar record-library-search-path
-.Op Fl T Ar address
-.Op Fl u Ar symbol
-.Op Fl V Ar shlib-version
-.Op Fl y Ar symbol
-.Ek
-.Sh DESCRIPTION
-.Nm
-combines the object and archive files given on the command line into a new
-object file. The output object file is either an executable program, a
-shared object suitable for loading at run-time, or an object file that can
-once again be processed by
-.Nm ld.
-Object files and archives are processed in the order given on the command line.
-.Pp
-The options are as follows:
-.Pp
-.Bl -tag -width indent
-.It Fl A Ar symbol-file
-The the symbol-file is taken as a base for link-editing the object files
-on the command line.
-.It Fl assert Ar keyword
-This option is here mainly for compatibility with SunOS
-.Nm ld .
-Most conditions which would cause a Sun assertion to fail will
-currently always cause error or warning messages from
-.Nm ld .
-The only keyword implemented by
-.Nm ld
-is
-.Nm pure-text ,
-which generates a warning if a position independent object is being
-created and some of the files being linked are not position
-independent.
-.It Fl B Ns Ar dynamic
-Specifies that linking against dynamic libraries can take place. If a library
-specifier of the form -lx appears on the command line,
-.Nm ld
-searches for a library of the from libx.so.n.m
-.Po see the \&
-.Fl l
-option
-.Pc
-according to the search rules in effect. If such a file can not be
-found a traditional archive is looked for.
-This options can appear anywhere on the command line and is complementary
-to
-.Fl B Ns Ar static.
-.It Fl B Ns Ar forcedynamic
-This is similar to
-.Fl B Ns Ar dynamic
-except that if no dynamic libraries are linked against,
-.Nm ld
-will still produce a dynamic executable. This is useful for programs
-which are static but still need to load dynamic objects at runtime.
-.It Fl B Ns Ar static
-The counterpart of
-.Fl B Ns Ar dynamic .
-This option turns off dynamic linking for
-all library specifiers until a
-.Fl B Ns Ar dynamic
-is once again given. Any explicitly
-mentioned shared object encountered on the command line while this option is
-in effect is flagged as an error.
-.It Fl B Ns Ar shareable
-Instructs the linker to build a shared object from the object files rather
-than a normal executable image.
-.It Fl B Ns Ar symbolic
-This option causes all symbolic references in the output to be resolved in
-this link-edit session. The only remaining run-time relocation requirements are
-.Em base-relative
-relocations, ie. translation with respect to the load address. Failure to
-resolve any symbolic reference causes an error to be reported.
-.It Fl B Ns Ar forcearchive
-Force all members of archives to be loaded, whether or not such members
-contribute a definition to any plain object files. Useful for making a
-shared library from an archive of PIC objects without having to unpack
-the archive.
-.It Fl B Ns Ar silly
-Search for
-.Em \.sa
-silly archive companions of shared objects. Useful for compatibility with
-version 3 shared objects.
-.It Fl D Ar data-size
-Set the size of the data segment. For sanity's sake, this should be larger
-than the cumulative data sizes of the input files.
-.It Fl d Ar c
-Force allocation of commons even producing relocatable output.
-.It Fl d Ar p
-Force alias definitions of procedure calls in non-PIC code. Useful to
-obtain shareable code in the presence of run-time relocations as such
-calls will be re-directed through the Procedure Linkage Table (see
-.Xr link 5)
-.It Fl e Ar entry-symbol
-Specifies the entry symbol for an executable.
-.It Fl f
-List the resolved paths of all the object files and libraries on the
-standard output, and exit.
-.It Fl L Ns Ar path
-Add
-.Ar path
-to the list of directories to search for libraries specified with the
-.Fl l
-option.
-.It Fl l Ns Ar lib-spec
-This option specifies a library to be considered for inclusion in the
-output. If the
-.Fl B Ns Ar dynamic
-option is in effect, a shared library of the
-form lib<spec>.so.m.n
-.Po where \&
-.Em m
-is the major, and
-.Em n
-is the minor version number, respectively
-.Pc is searched for first. The
-library with the highest version found in the search path is selected.
-If no shared library is found or the
-.Fl B Ns Ar static
-options is in effect, an archive of the form lib<spec>.a is looked for in
-the library search path.
-.It Fl M
-Produce output about the mapping of segments of the input files and the
-values assigned to
-.Pq global
-symbols in the output file.
-.It Fl N
-Produce a
-.Dv OMAGIC
-output file.
-.It Fl n
-Produce a
-.Dv NMAGIC
-output file.
-.It Fl nostdlib
-Do not search the built-in path
-.Po
-usually
-.Dq /usr/lib
-.Pc
-for
-.Fl l
-specified libraries.
-.It Fl O Ar filename
-Specifies the name of the output file.
-The file is created as
-.Ar filename .tmp
-and when output is complete renamed to
-.Ar filename .
-.It Fl o Ar filename
-Specifies the name of the output file. Defaults to
-.Dq a.out.
-.It Fl Q
-Produce a
-.Dv QMAGIC
-(FreeBSD/BSDi-i386) output file. This is the default.
-.It Fl r
-Produce relocatable object file, suitable for another pass through
-.Nm ld.
-.It Fl R
-Record the given path within the executable for run-time library search.
-This only applies to dynamically linked executables.
-.It Fl S
-Strip all debugger symbols from the output.
-.It Fl s
-Strip all symbols from the output.
-.It Fl T
-Specifies the start address of the text segment, with respect to which
-all input files will be relocated.
-.It Fl t
-Leave a trace of the input files as they are processed.
-.It Fl u Ar symbol
-Force
-.Ar symbol
-to be marked as undefined. Useful to force loading of an archive member
-in the absence of any other references to that member.
-.It Fl V Ar version
-Put the given version number into the output shared library
-.Pq if one is created .
-Useful to make shared libraries compatible with other operating
-systems. E.g., SunOS 4.x libraries use version number 3. Defaults to 8.
-.It Fl X
-Discard local symbols in the input files that start with the letter
-.Dq L
-.It Fl x
-Discard all local symbols in the input files.
-.It Fl y Ar symbol
-Trace the manipulations inflicted on
-.Ar symbol
-.It Fl Z
-Make a 386BSD
-.Dv ZMAGIC
-output file.
-.It Fl z
-Make a NetBSD
-.Dv ZMAGIC
-output file.
-.Sh ENVIRONMENT
-.Nm
-utilizes the following environment variables:
-.Bl -tag -width "LD_LIBRARY_PATH"
-.It Ev LD_LIBRARY_PATH
-This colon-separated list of directories is inserted into the search
-path for libraries following any directories specified via
-.Fl L
-options and preceding the built-in path.
-.\" .It Ev LD_NOSTD_PATH
-.\" When set, do not search the built-in path for libraries.
-.\" This is an alternative to the
-.\" .Fl nostdlib
-.\" command-line flag.
-.El
-.Sh FILES
-.Sh SEE ALSO
-.Xr rtld 1 ,
-.Xr link 5 ,
-.Xr ldconfig 8
-.Sh CAVEATS
-An entry point must now explicitly be given if the output is intended to be
-a normal executable program. This was not the case for the previous version of
-.Nm ld .
-.Sh BUGS
-Shared objects are not properly checked for undefined symbols.
-.Pp
-Cascading of shared object defeats the
-.Dq -Bstatic
-option.
-.Pp
-All shared objects presented to
-.Nm ld
-are marked for run-time loading in the output file, even if no symbols
-are needed from them.
-.Sh HISTORY
-A
-.Nm
-command appeared in
-.At v1 .
-The shared library model employed by
-.Nm
-appeared first in SunOS 4.0
diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c
deleted file mode 100644
index 089dba4..0000000
--- a/gnu/usr.bin/ld/ld.c
+++ /dev/null
@@ -1,3825 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- *
- * Modified 1993 by Paul Kranenburg, Erasmus University
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91";
-#endif /* not lint */
-
-/* Linker `ld' for GNU
- Copyright (C) 1988 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- 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. */
-
-/* Written by Richard Stallman with some help from Eric Albert.
- Set, indirect, and warning symbol features added by Randy Smith. */
-
-/*
- * $Id: ld.c,v 1.44 1997/04/25 19:43:19 bde Exp $
- */
-
-/* Define how to initialize system-dependent header fields. */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <err.h>
-#include <fcntl.h>
-#include <ar.h>
-#include <ranlib.h>
-#include <a.out.h>
-#include <stab.h>
-#include <string.h>
-
-#include "ld.h"
-#include "dynamic.h"
-
-/* Vector of entries for input files specified by arguments.
- These are all the input files except for members of specified libraries. */
-struct file_entry *file_table;
-int number_of_files;
-
-/* 1 => write relocation into output file so can re-input it later. */
-int relocatable_output;
-
-/* 1 => building a shared object, set by `-Bshareable'. */
-int building_shared_object;
-
-/* 1 => create the output executable. */
-int make_executable;
-
-/* Force the executable to be output, even if there are non-fatal errors */
-int force_executable;
-
-/* 1 => assign space to common symbols even if `relocatable_output'. */
-int force_common_definition;
-
-/* 1 => assign jmp slots to text symbols in shared objects even if non-PIC */
-int force_alias_definition;
-
-/* 1 => some files contain PIC code, affects relocation bits
- if `relocatable_output'. */
-int pic_code_seen;
-
-/* 1 => segments must be page aligned (ZMAGIC, QMAGIC) */
-int page_align_segments;
-
-/* 1 => data segment must be page aligned, even if `-n' or `-N' */
-int page_align_data;
-
-/* 1 => do not use standard library search path */
-int nostdlib;
-
-/* Version number to put in __DYNAMIC (set by -V) */
-int soversion;
-
-int text_size; /* total size of text. */
-int text_start; /* start of text */
-int text_pad; /* clear space between text and data */
-int data_size; /* total size of data. */
-int data_start; /* start of data */
-int data_pad; /* part of bss segment as part of data */
-
-int bss_size; /* total size of bss. */
-int bss_start; /* start of bss */
-
-int text_reloc_size; /* total size of text relocation. */
-int data_reloc_size; /* total size of data relocation. */
-
-int rrs_section_type; /* What's in the RRS section */
-int rrs_text_size; /* Size of RRS text additions */
-int rrs_text_start; /* Location of above */
-int rrs_data_size; /* Size of RRS data additions */
-int rrs_data_start; /* Location of above */
-
-/* Specifications of start and length of the area reserved at the end
- of the data segment for the set vectors. Computed in 'digest_symbols' */
-int set_sect_start; /* start of set element vectors */
-int set_sect_size; /* size of above */
-
-int link_mode; /* Current link mode */
-int pic_type; /* PIC type */
-
-/*
- * When loading the text and data, we can avoid doing a close
- * and another open between members of the same library.
- *
- * These two variables remember the file that is currently open.
- * Both are zero if no file is open.
- *
- * See `each_file' and `file_close'.
- */
-struct file_entry *input_file;
-int input_desc;
-
-/* The name of the file to write; "a.out" by default. */
-char *output_filename; /* Output file name. */
-char *real_output_filename; /* Output file name. */
-FILE *outstream; /* Output file descriptor. */
-struct exec outheader; /* Output file header. */
-int magic; /* Output file magic. */
-int oldmagic;
-int relocatable_output; /* `-r'-ed output */
-
-symbol *entry_symbol; /* specified by `-e' */
-int entry_offset; /* program entry if no `-e' given */
-
-int page_size; /* Size of a page (machine dependent) */
-
-/*
- * Keep a list of any symbols referenced from the command line (so
- * that error messages for these guys can be generated). This list is
- * zero terminated.
- */
-symbol **cmdline_references;
-int cl_refs_allocated;
-
-/*
- * Which symbols should be stripped (omitted from the output): none, all, or
- * debugger symbols.
- */
-enum {
- STRIP_NONE, STRIP_ALL, STRIP_DEBUGGER
-} strip_symbols;
-
-/*
- * Which local symbols should be omitted: none, all, or those starting with L.
- * This is irrelevant if STRIP_NONE.
- */
-enum {
- DISCARD_NONE, DISCARD_ALL, DISCARD_L
-} discard_locals;
-
-int global_sym_count; /* # of nlist entries for global symbols */
-int size_sym_count; /* # of N_SIZE nlist entries for output
- (relocatable_output only) */
-int local_sym_count; /* # of nlist entries for local symbols. */
-int non_L_local_sym_count; /* # of nlist entries for non-L symbols */
-int debugger_sym_count; /* # of nlist entries for debugger info. */
-int undefined_global_sym_count; /* # of global symbols referenced and
- not defined. */
-int undefined_shobj_sym_count; /* # of undefined symbols referenced
- by shared objects */
-int multiple_def_count; /* # of multiply defined symbols. */
-int defined_global_sym_count; /* # of defined global symbols. */
-int common_defined_global_count; /* # of common symbols. */
-int undefined_weak_sym_count; /* # of weak symbols referenced and
- not defined. */
-
-#if notused
-int special_sym_count; /* # of linker defined symbols. */
- /* XXX - Currently, only __DYNAMIC and _G_O_T_ go here if required,
- * perhaps _etext, _edata and _end should go here too.
- */
-#endif
-int global_alias_count; /* # of aliased symbols */
-int set_symbol_count; /* # of N_SET* symbols. */
-int set_vector_count; /* # of set vectors in output. */
-int warn_sym_count; /* # of warning symbols encountered. */
-int flag_list_files; /* 1 => print pathnames of files, don't link */
-int list_warning_symbols; /* 1 => warning symbols referenced */
-
-struct string_list_element *set_element_prefixes;
-
-int trace_files; /* print names of input files as processed (`-t'). */
-int write_map; /* write a load map (`-M') */
-
-/*
- * `text-start' address is normally this much plus a page boundary.
- * This is not a user option; it is fixed for each system.
- */
-int text_start_alignment;
-
-/*
- * Nonzero if -T was specified in the command line.
- * This prevents text_start from being set later to default values.
- */
-int T_flag_specified;
-
-/*
- * Nonzero if -Tdata was specified in the command line.
- * This prevents data_start from being set later to default values.
- */
-int Tdata_flag_specified;
-
-/*
- * Size to pad data section up to.
- * We simply increase the size of the data section, padding with zeros,
- * and reduce the size of the bss section to match.
- */
-int specified_data_size;
-
-long *set_vectors;
-int setv_fill_count;
-
-static void decode_option __P((char *, char *));
-static void decode_command __P((int, char **));
-static int classify_arg __P((char *));
-static void load_symbols __P((void));
-static void enter_global_ref __P((struct localsymbol *,
- char *, struct file_entry *));
-static void digest_symbols __P((void));
-static void digest_pass1 __P((void)), digest_pass2 __P((void));
-static void consider_file_section_lengths __P((struct file_entry *));
-static void relocate_file_addresses __P((struct file_entry *));
-static void consider_relocation __P((struct file_entry *, int));
-static void consider_local_symbols __P((struct file_entry *));
-static void perform_relocation __P((char *, int,
- struct relocation_info *, int,
- struct file_entry *, int));
-static void copy_text __P((struct file_entry *));
-static void copy_data __P((struct file_entry *));
-static void coptxtrel __P((struct file_entry *));
-static void copdatrel __P((struct file_entry *));
-static void write_output __P((void));
-static void write_header __P((void));
-static void write_text __P((void));
-static void write_data __P((void));
-static void write_rel __P((void));
-static void write_syms __P((void));
-static void assign_symbolnums __P((struct file_entry *, int *));
-static void cleanup __P((void));
-static int parse __P((char *, char *, char *));
-static void list_files __P((void));
-
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
-
- /* Added this to stop ld core-dumping on very large .o files. */
-#ifdef RLIMIT_STACK
- /* Get rid of any avoidable limit on stack size. */
- {
- struct rlimit rlim;
-
- /* Set the stack limit huge so that alloca does not fail. */
- if (getrlimit(RLIMIT_STACK, &rlim) != 0)
- warn("getrlimit");
- else {
- rlim.rlim_cur = rlim.rlim_max;
- if (setrlimit(RLIMIT_STACK, &rlim) != 0)
- warn("setrlimit");
- }
- }
-#endif /* RLIMIT_STACK */
-
- page_size = PAGSIZ;
-
- /* Clear the cumulative info on the output file. */
-
- text_size = 0;
- data_size = 0;
- bss_size = 0;
- text_reloc_size = 0;
- data_reloc_size = 0;
-
- data_pad = 0;
- text_pad = 0;
- page_align_segments = 0;
- page_align_data = 0;
-
- /* Initialize the data about options. */
-
- specified_data_size = 0;
- strip_symbols = STRIP_NONE;
- trace_files = 0;
- discard_locals = DISCARD_NONE;
- entry_symbol = 0;
- write_map = 0;
- relocatable_output = 0;
- force_common_definition = 0;
- T_flag_specified = 0;
- Tdata_flag_specified = 0;
- magic = DEFAULT_MAGIC;
- make_executable = 1;
- force_executable = 0;
- link_mode = DYNAMIC;
-#ifdef SUNOS4
- link_mode |= SILLYARCHIVE;
-#endif
- soversion = DEFAULT_SOVERSION;
-
- /* Initialize the cumulative counts of symbols. */
-
- local_sym_count = 0;
- non_L_local_sym_count = 0;
- debugger_sym_count = 0;
- undefined_global_sym_count = 0;
- warn_sym_count = 0;
- list_warning_symbols = 0;
- multiple_def_count = 0;
- common_defined_global_count = 0;
-
- /* Keep a list of symbols referenced from the command line */
- cl_refs_allocated = 10;
- cmdline_references = (symbol **)
- xmalloc(cl_refs_allocated * sizeof(symbol *));
- *cmdline_references = 0;
-
- /* Completely decode ARGV. */
- decode_command(argc, argv);
-
- if (flag_list_files)
- list_files();
-
- building_shared_object =
- (!relocatable_output && (link_mode & SHAREABLE));
-
- if (building_shared_object && entry_symbol) {
- errx(1,"`-Bshareable' and `-e' options are mutually exclusive");
- }
-
- /* Create the symbols `etext', `edata' and `end'. */
- symtab_init(relocatable_output);
-
- /*
- * Determine whether to count the header as part of the text size,
- * and initialize the text size accordingly. This depends on the kind
- * of system and on the output format selected.
- */
-
- if (magic == ZMAGIC || magic == QMAGIC)
- page_align_segments = 1;
-
- md_init_header(&outheader, magic, 0);
-
- text_size = sizeof(struct exec);
- text_size -= N_TXTOFF(outheader);
-
- if (text_size < 0)
- text_size = 0;
- entry_offset = text_size;
-
- if (!T_flag_specified && !relocatable_output)
- text_start = TEXT_START(outheader);
-
- /* The text-start address is normally this far past a page boundary. */
- text_start_alignment = text_start % page_size;
-
- /*
- * Load symbols of all input files. Also search all libraries and
- * decide which library members to load.
- */
- load_symbols();
-
- /* Compute where each file's sections go, and relocate symbols. */
- digest_symbols();
-
- /*
- * Print error messages for any missing symbols, for any warning
- * symbols, and possibly multiple definitions
- */
- make_executable &= do_warnings(stderr);
-
- /* Print a map, if requested. */
- if (write_map)
- print_symbols(stdout);
-
- /* Write the output file. */
- if (make_executable || force_executable)
- write_output();
-
- exit(!make_executable);
-}
-
-/*
- * Analyze a command line argument. Return 0 if the argument is a filename.
- * Return 1 if the argument is a option complete in itself. Return 2 if the
- * argument is a option which uses an argument.
- *
- * Thus, the value is the number of consecutive arguments that are part of
- * options.
- */
-
-static int
-classify_arg(arg)
- register char *arg;
-{
- if (*arg != '-')
- return 0;
- switch (arg[1]) {
- case 'a':
- if (!strcmp(&arg[2], "ssert"))
- return 2;
- case 'A':
- case 'D':
- case 'e':
- case 'L':
- case 'l':
- case 'O':
- case 'o':
- case 'R':
- case 'u':
- case 'V':
- case 'y':
- if (arg[2])
- return 1;
- return 2;
-
- case 'B':
- if (!strcmp(&arg[2], "static"))
- return 1;
- if (!strcmp(&arg[2], "dynamic"))
- return 1;
- if (!strcmp(&arg[2], "forcedynamic"))
- return 1;
-
- case 'T':
- if (arg[2] == 0)
- return 2;
- if (!strcmp(&arg[2], "text"))
- return 2;
- if (!strcmp(&arg[2], "data"))
- return 2;
- return 1;
- }
-
- return 1;
-}
-
-/*
- * Process the command arguments, setting up file_table with an entry for
- * each input file, and setting variables according to the options.
- */
-
-static void
-decode_command(argc, argv)
- int argc;
- char **argv;
-{
- register int i;
- register struct file_entry *p;
-
- number_of_files = 0;
- output_filename = "a.out";
-
- /*
- * First compute number_of_files so we know how long to make
- * file_table.
- * Also process most options completely.
- */
-
- for (i = 1; i < argc; i++) {
- register int code = classify_arg(argv[i]);
- if (code) {
- if (i + code > argc)
- errx(1, "no argument following %s", argv[i]);
-
- decode_option(argv[i], argv[i + 1]);
-
- if (argv[i][1] == 'l' || argv[i][1] == 'A')
- number_of_files++;
-
- i += code - 1;
- } else
- number_of_files++;
- }
-
- if (!number_of_files) {
- if (flag_list_files)
- exit(0);
- errx(1, "No input files specified");
- }
-
- p = file_table = (struct file_entry *)
- xmalloc(number_of_files * sizeof(struct file_entry));
- bzero(p, number_of_files * sizeof(struct file_entry));
-
- /* Now scan again and fill in file_table. */
- /* All options except -A and -l are ignored here. */
-
- for (i = 1; i < argc; i++) {
- char *string;
- register int code = classify_arg(argv[i]);
-
- if (code == 0) {
- p->filename = argv[i];
- p->local_sym_name = argv[i];
- p++;
- continue;
- }
- if (code == 2)
- string = argv[i + 1];
- else
- string = &argv[i][2];
-
- if (argv[i][1] == 'B') {
- if (strcmp(string, "static") == 0)
- link_mode &= ~DYNAMIC;
- else if (strcmp(string, "dynamic") == 0)
- link_mode |= DYNAMIC;
- else if (strcmp(string, "forcedynamic") == 0)
- link_mode |= DYNAMIC|FORCEDYNAMIC;
- else if (strcmp(string, "symbolic") == 0)
- link_mode |= SYMBOLIC;
- else if (strcmp(string, "forcearchive") == 0)
- link_mode |= FORCEARCHIVE;
- else if (strcmp(string, "shareable") == 0)
- link_mode |= SHAREABLE;
-#ifdef SUN_COMPAT
- else if (strcmp(string, "silly") == 0)
- link_mode |= SILLYARCHIVE;
- else if (strcmp(string, "~silly") == 0)
- link_mode &= ~SILLYARCHIVE;
-#endif
- }
- if (!strcmp(argv[i] + 1, "assert")) {
- if (!strcmp(string, "pure-text"))
- link_mode |= WARNRRSTEXT;
- }
- if (argv[i][1] == 'A') {
- if (p != file_table)
- errx(1, "-A specified before an input file other than the first");
- p->filename = string;
- p->local_sym_name = string;
- p->flags |= E_JUST_SYMS;
- link_mode &= ~DYNAMIC;
- p++;
- }
- if (argv[i][1] == 'l') {
- p->filename = string;
- p->local_sym_name = concat("-l", string, "");
- p->flags |= E_SEARCH_DIRS;
- if (link_mode & DYNAMIC && !relocatable_output)
- p->flags |= E_SEARCH_DYNAMIC;
- p++;
- }
- i += code - 1;
- }
-
- /* Now check some option settings for consistency. */
-
- if (page_align_segments &&
- (text_start - text_start_alignment) & (page_size - 1))
- errx(1, "incorrect alignment of text start address");
-
- /* Append the standard search directories to the user-specified ones. */
- add_search_path(getenv("LD_LIBRARY_PATH"));
- if (!nostdlib)
- std_search_path();
-}
-
-void
-add_cmdline_ref(sp)
- symbol *sp;
-{
- symbol **ptr;
-
- for (ptr = cmdline_references;
- ptr < cmdline_references + cl_refs_allocated && *ptr;
- ptr++);
-
- if (ptr >= cmdline_references + cl_refs_allocated - 1) {
- int diff = ptr - cmdline_references;
-
- cl_refs_allocated *= 2;
- cmdline_references = (symbol **)
- xrealloc(cmdline_references,
- cl_refs_allocated * sizeof(symbol *));
- ptr = cmdline_references + diff;
- }
- *ptr++ = sp;
- *ptr = (symbol *)0;
-}
-
-int
-set_element_prefixed_p(name)
- char *name;
-{
- struct string_list_element *p;
- int i;
-
- for (p = set_element_prefixes; p; p = p->next) {
-
- for (i = 0; p->str[i] != '\0' && (p->str[i] == name[i]); i++);
- if (p->str[i] == '\0')
- return 1;
- }
- return 0;
-}
-
-/*
- * Record an option and arrange to act on it later. ARG should be the
- * following command argument, which may or may not be used by this option.
- *
- * The `l' and `A' options are ignored here since they actually specify input
- * files.
- */
-
-static void
-decode_option(swt, arg)
- register char *swt, *arg;
-{
- if (!strcmp(swt + 1, "Bstatic"))
- return;
- if (!strcmp(swt + 1, "Bdynamic"))
- return;
- if (!strcmp(swt + 1, "Bforcedynamic"))
- return;
- if (!strcmp(swt + 1, "Bsymbolic"))
- return;
- if (!strcmp(swt + 1, "Bforcearchive"))
- return;
- if (!strcmp(swt + 1, "Bshareable"))
- return;
- if (!strcmp(swt + 1, "assert"))
- return;
-#ifdef SUN_COMPAT
- if (!strcmp(swt + 1, "Bsilly"))
- return;
-#endif
- if (!strcmp(swt + 1, "Ttext")) {
- text_start = parse(arg, "%x", "invalid argument to -Ttext");
- T_flag_specified = 1;
- return;
- }
- if (!strcmp(swt + 1, "Tdata")) {
- rrs_data_start = parse(arg, "%x", "invalid argument to -Tdata");
- Tdata_flag_specified = 1;
- return;
- }
- if (!strcmp(swt + 1, "noinhibit-exec")) {
- force_executable = 1;
- return;
- }
- if (!strcmp(swt + 1, "nostdlib")) {
- nostdlib = 1;
- return;
- }
- if (swt[2] != 0)
- arg = &swt[2];
-
- switch (swt[1]) {
- case 'A':
- return;
-
- case 'D':
- specified_data_size = parse(arg, "%x", "invalid argument to -D");
- return;
-
- case 'd':
- if (swt[2] == 0 || *arg == 'c')
- force_common_definition = 1;
- else if (*arg == 'p')
- force_alias_definition = 1;
- else
- errx(1, "-d option takes 'c' or 'p' argument");
- return;
-
- case 'e':
- entry_symbol = getsym(arg);
- if (!entry_symbol->defined &&
- !(entry_symbol->flags & GS_REFERENCED))
- undefined_global_sym_count++;
- entry_symbol->flags |= GS_REFERENCED;
- add_cmdline_ref(entry_symbol);
- return;
-
- case 'f':
- flag_list_files = 1;
- return;
-
- case 'l':
- return;
-
- case 'L':
- add_search_dir(arg);
- return;
-
- case 'M':
- write_map = 1;
- return;
-
- case 'N':
- magic = OMAGIC;
- return;
-
- case 'n':
- magic = NMAGIC;
- return;
-
- case 'O':
- output_filename = xmalloc(strlen(arg)+5);
- strcpy(output_filename, arg);
- strcat(output_filename, ".tmp");
- real_output_filename = arg;
- return;
-
- case 'o':
- output_filename = arg;
- return;
-
- case 'p':
- page_align_data = 1;
- return;
-
-#ifdef QMAGIC
- case 'Q':
- magic = QMAGIC;
- return;
-#endif
-
- case 'r':
- relocatable_output = 1;
- magic = OMAGIC;
- text_start = 0;
- return;
-
- case 'R':
- rrs_search_paths = (rrs_search_paths == NULL)
- ? strdup(arg)
- : concat(rrs_search_paths, ":", arg);
- return;
-
- case 'S':
- strip_symbols = STRIP_DEBUGGER;
- return;
-
- case 's':
- strip_symbols = STRIP_ALL;
- return;
-
- case 'T':
- text_start = parse(arg, "%x", "invalid argument to -T");
- T_flag_specified = 1;
- return;
-
- case 't':
- trace_files = 1;
- return;
-
- case 'u':
- {
- register symbol *sp = getsym(arg);
-
- if (!sp->defined && !(sp->flags & GS_REFERENCED))
- undefined_global_sym_count++;
- sp->flags |= GS_REFERENCED;
- add_cmdline_ref(sp);
- }
- return;
-
-#if 1
- case 'V':
- soversion = parse(arg, "%d", "invalid argument to -V");
- return;
-#endif
-
- case 'X':
- discard_locals = DISCARD_L;
- return;
-
- case 'x':
- discard_locals = DISCARD_ALL;
- return;
-
- case 'y':
- {
- register symbol *sp = getsym(&swt[2]);
- sp->flags |= GS_TRACE;
- }
- return;
-
- case 'z':
- magic = ZMAGIC;
- oldmagic = 0;
-#ifdef __FreeBSD__
- netzmagic = 1;
-#endif
- return;
-
- case 'Z':
- magic = oldmagic = ZMAGIC;
-#ifdef __FreeBSD__
- netzmagic = 0;
-#endif
- return;
-
- default:
- errx(1, "invalid command option `%s'", swt);
- }
-}
-
-/* Convenient functions for operating on one or all files being loaded. */
-
-/*
- * Call FUNCTION on each input file entry. Do not call for entries for
- * libraries; instead, call once for each library member that is being
- * loaded.
- *
- * FUNCTION receives two arguments: the entry, and ARG.
- */
-
-void
-each_file(function, arg)
- register void (*function)();
- register void *arg;
-{
- register int i;
-
- for (i = 0; i < number_of_files; i++) {
- register struct file_entry *entry = &file_table[i];
- register struct file_entry *subentry;
-
- if (entry->flags & E_SCRAPPED)
- continue;
-
- if (!(entry->flags & E_IS_LIBRARY))
- (*function)(entry, arg);
-
- subentry = entry->subfiles;
- for (; subentry; subentry = subentry->chain) {
- if (subentry->flags & E_SCRAPPED)
- continue;
- (*function)(subentry, arg);
- }
-
-#ifdef SUN_COMPAT
- if (entry->silly_archive) {
-
- if (!(entry->flags & E_DYNAMIC))
- warnx("Silly");
-
- if (!(entry->silly_archive->flags & E_IS_LIBRARY))
- warnx("Sillier");
-
- subentry = entry->silly_archive->subfiles;
- for (; subentry; subentry = subentry->chain) {
- if (subentry->flags & E_SCRAPPED)
- continue;
- (*function)(subentry, arg);
- }
- }
-#endif
- }
-}
-
-/*
- * Call FUNCTION on each input file entry until it returns a non-zero value.
- * Return this value. Do not call for entries for libraries; instead, call
- * once for each library member that is being loaded.
- *
- * FUNCTION receives two arguments: the entry, and ARG. It must be a function
- * returning unsigned long (though this can probably be fudged).
- */
-
-unsigned long
-check_each_file(function, arg)
- register unsigned long (*function)();
- register void *arg;
-{
- register int i;
- register unsigned long return_val;
-
- for (i = 0; i < number_of_files; i++) {
- register struct file_entry *entry = &file_table[i];
- if (entry->flags & E_SCRAPPED)
- continue;
- if (entry->flags & E_IS_LIBRARY) {
- register struct file_entry *subentry = entry->subfiles;
- for (; subentry; subentry = subentry->chain) {
- if (subentry->flags & E_SCRAPPED)
- continue;
- if ( (return_val = (*function)(subentry, arg)) )
- return return_val;
- }
- } else if ( (return_val = (*function)(entry, arg)) )
- return return_val;
- }
- return 0;
-}
-
-/* Like `each_file' but ignore files that were just for symbol definitions. */
-
-void
-each_full_file(function, arg)
- register void (*function)();
- register void *arg;
-{
- register int i;
-
- for (i = 0; i < number_of_files; i++) {
- register struct file_entry *entry = &file_table[i];
- register struct file_entry *subentry;
-
- if (entry->flags & (E_SCRAPPED | E_JUST_SYMS))
- continue;
-
-#ifdef SUN_COMPAT
- if (entry->silly_archive) {
-
- if (!(entry->flags & E_DYNAMIC))
- warnx("Silly");
-
- if (!(entry->silly_archive->flags & E_IS_LIBRARY))
- warnx("Sillier");
-
- subentry = entry->silly_archive->subfiles;
- for (; subentry; subentry = subentry->chain) {
- if (subentry->flags & E_SCRAPPED)
- continue;
- (*function)(subentry, arg);
- }
- }
-#endif
- if (entry->flags & E_DYNAMIC)
- continue;
-
- if (!(entry->flags & E_IS_LIBRARY))
- (*function)(entry, arg);
-
- subentry = entry->subfiles;
- for (; subentry; subentry = subentry->chain) {
- if (subentry->flags & E_SCRAPPED)
- continue;
- (*function)(subentry, arg);
- }
-
- }
-}
-
-/* Close the input file that is now open. */
-
-void
-file_close()
-{
- close(input_desc);
- input_desc = 0;
- input_file = 0;
-}
-
-/*
- * Open the input file specified by 'entry', and return a descriptor. The
- * open file is remembered; if the same file is opened twice in a row, a new
- * open is not actually done.
- */
-int
-file_open(entry)
- register struct file_entry *entry;
-{
- register int fd;
-
- if (entry->superfile && (entry->superfile->flags & E_IS_LIBRARY))
- return file_open(entry->superfile);
-
- if (entry == input_file)
- return input_desc;
-
- if (input_file)
- file_close();
-
- if (entry->flags & E_SEARCH_DIRS) {
- fd = findlib(entry);
- } else
- fd = open(entry->filename, O_RDONLY, 0);
-
- if (fd >= 0) {
- input_file = entry;
- input_desc = fd;
- return fd;
- }
-
- if (entry->flags & E_SEARCH_DIRS)
- errx(1, "%s: no match", entry->local_sym_name);
- else
- err(1, "%s", entry->filename);
- return fd;
-}
-
-int
-text_offset(entry)
- struct file_entry *entry;
-{
- return entry->starting_offset + N_TXTOFF (entry->header);
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Read a file's header into the proper place in the file_entry. FD is the
- * descriptor on which the file is open. ENTRY is the file's entry.
- */
-void
-read_header(fd, entry)
- int fd;
- struct file_entry *entry;
-{
- register int len;
-
- if (lseek(fd, entry->starting_offset, L_SET) !=
- entry->starting_offset)
- err(1, "%s: read_header: lseek", get_file_name(entry));
-
- len = read(fd, &entry->header, sizeof(struct exec));
- if (len != sizeof (struct exec))
- err(1, "%s: read_header: read", get_file_name(entry));
-
- md_swapin_exec_hdr(&entry->header);
-
- if (N_BADMAG (entry->header))
- errx(1, "%s: bad magic", get_file_name(entry));
-
- if (N_BADMID(entry->header))
- errx(1, "%s: non-native input file", get_file_name(entry));
-
- entry->flags |= E_HEADER_VALID;
-}
-
-/*
- * Read the symbols of file ENTRY into core. Assume it is already open, on
- * descriptor FD. Also read the length of the string table, which follows
- * the symbol table, but don't read the contents of the string table.
- */
-
-void
-read_entry_symbols(fd, entry)
- struct file_entry *entry;
- int fd;
-{
- int str_size;
- struct nlist *np;
- int i;
-
- if (!(entry->flags & E_HEADER_VALID))
- read_header(fd, entry);
-
- np = (struct nlist *)alloca(entry->header.a_syms);
- entry->nsymbols = entry->header.a_syms / sizeof(struct nlist);
- if (entry->nsymbols == 0)
- return;
-
- entry->symbols = (struct localsymbol *)
- xmalloc(entry->nsymbols * sizeof(struct localsymbol));
-
- if (lseek(fd, N_SYMOFF(entry->header) + entry->starting_offset, L_SET)
- != N_SYMOFF(entry->header) + entry->starting_offset)
- err(1, "%s: read_symbols: lseek(syms)", get_file_name(entry));
-
- if (entry->header.a_syms != read(fd, np, entry->header.a_syms))
- errx(1, "%s: read_symbols: premature end of file in symbols",
- get_file_name(entry));
-
- md_swapin_symbols(np, entry->header.a_syms / sizeof(struct nlist));
-
- for (i = 0; i < entry->nsymbols; i++) {
- entry->symbols[i].nzlist.nlist = *np++;
- entry->symbols[i].nzlist.nz_size = 0;
- entry->symbols[i].symbol = NULL;
- entry->symbols[i].next = NULL;
- entry->symbols[i].entry = entry;
- entry->symbols[i].gotslot_offset = -1;
- entry->symbols[i].flags = 0;
- }
-
- entry->strings_offset = N_STROFF(entry->header) +
- entry->starting_offset;
- if (lseek(fd, entry->strings_offset, 0) == (off_t)-1)
- err(1, "%s: read_symbols: lseek(strings)",
- get_file_name(entry));
- if (sizeof str_size != read(fd, &str_size, sizeof str_size))
- errx(1, "%s: read_symbols: cannot read string table size",
- get_file_name(entry));
-
- entry->string_size = md_swap_long(str_size);
-}
-
-/*
- * Read the string table of file ENTRY open on descriptor FD, into core.
- */
-void
-read_entry_strings(fd, entry)
- struct file_entry *entry;
- int fd;
-{
-
- if (entry->string_size == 0)
- return;
-
- if (!(entry->flags & E_HEADER_VALID) || !entry->strings_offset)
- errx(1, "%s: read_strings: string table unavailable",
- get_file_name(entry));
-
- if (lseek(fd, entry->strings_offset, L_SET) !=
- entry->strings_offset)
- err(1, "%s: read_strings: lseek",
- get_file_name(entry));
-
- if (read(fd, entry->strings, entry->string_size) !=
- entry->string_size)
- errx(1, "%s: read_strings: premature end of file in strings",
- get_file_name(entry));
-
- return;
-}
-
-/* Read in the relocation sections of ENTRY if necessary */
-
-void
-read_entry_relocation(fd, entry)
- int fd;
- struct file_entry *entry;
-{
- register struct relocation_info *reloc;
- off_t pos;
-
- if (!entry->textrel) {
-
- reloc = (struct relocation_info *)
- xmalloc(entry->header.a_trsize);
-
- pos = text_offset(entry) +
- entry->header.a_text + entry->header.a_data;
-
- if (lseek(fd, pos, L_SET) != pos)
- err(1, "%s: read_reloc(text): lseek",
- get_file_name(entry));
-
- if (read(fd, reloc, entry->header.a_trsize) !=
- entry->header.a_trsize)
- errx(1, "%s: read_reloc(text): premature EOF",
- get_file_name(entry));
-
- md_swapin_reloc(reloc, entry->header.a_trsize / sizeof(*reloc));
- entry->textrel = reloc;
- entry->ntextrel = entry->header.a_trsize / sizeof(*reloc);
-
- }
-
- if (!entry->datarel) {
-
- reloc = (struct relocation_info *)
- xmalloc(entry->header.a_drsize);
-
- pos = text_offset(entry) + entry->header.a_text +
- entry->header.a_data + entry->header.a_trsize;
-
- if (lseek(fd, pos, L_SET) != pos)
- err(1, "%s: read_reloc(data): lseek",
- get_file_name(entry));
-
- if (read(fd, reloc, entry->header.a_drsize) !=
- entry->header.a_drsize)
- errx(1, "%s: read_reloc(data): premature EOF",
- get_file_name(entry));
-
- md_swapin_reloc(reloc, entry->header.a_drsize / sizeof(*reloc));
- entry->datarel = reloc;
- entry->ndatarel = entry->header.a_drsize / sizeof(*reloc);
-
- }
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Read in the symbols of all input files.
- */
-static void
-load_symbols()
-{
- register int i;
-
- if (trace_files)
- fprintf(stderr, "Loading symbols:\n\n");
-
- for (i = 0; i < number_of_files; i++)
- read_file_symbols(&file_table[i]);
-
- if (trace_files)
- fprintf(stderr, "\n");
-}
-
-/*
- * If ENTRY is a rel file, read its symbol and string sections into core. If
- * it is a library, search it and load the appropriate members (which means
- * calling this function recursively on those members).
- */
-
-void
-read_file_symbols(entry)
- register struct file_entry *entry;
-{
- register int fd;
- register int len;
- struct exec hdr;
-
- fd = file_open(entry);
-
- len = read(fd, &hdr, sizeof hdr);
- if (len != sizeof hdr)
- errx(1, "%s: read_file_symbols(header): premature EOF",
- get_file_name(entry));
-
- md_swapin_exec_hdr(&hdr);
-
- if (!N_BADMAG (hdr)) {
- if (N_IS_DYNAMIC(hdr) && !(entry->flags & E_JUST_SYMS)) {
- if (relocatable_output) {
- errx(1,
- "%s: -r and shared objects currently not supported",
- get_file_name(entry));
- return;
- }
-#if notyet /* Compatibility */
- if (!(N_GETFLAG(hdr) & EX_PIC))
- warnx("%s: EX_PIC not set",
- get_file_name(entry));
-#endif
- entry->flags |= E_DYNAMIC;
- if (entry->superfile || rrs_add_shobj(entry))
- read_shared_object(fd, entry);
- else
- entry->flags |= E_SCRAPPED;
- } else {
- if (N_GETFLAG(hdr) & EX_PIC)
- pic_code_seen = 1;
- read_entry_symbols(fd, entry);
- entry->strings = (char *)alloca(entry->string_size);
- read_entry_strings(fd, entry);
- read_entry_relocation(fd, entry);
- enter_file_symbols(entry);
- entry->strings = 0;
- }
- } else {
- char armag[SARMAG];
-
- lseek (fd, 0, 0);
- if (SARMAG != read(fd, armag, SARMAG) ||
- strncmp (armag, ARMAG, SARMAG))
- errx(1,
- "%s: malformed input file (not rel or archive)",
- get_file_name(entry));
- entry->flags |= E_IS_LIBRARY;
- search_library(fd, entry);
- }
-
- file_close();
-}
-
-
-/*
- * Enter the external symbol defs and refs of ENTRY in the hash table.
- */
-
-void
-enter_file_symbols(entry)
- struct file_entry *entry;
-{
- struct localsymbol *lsp, *lspend;
-
- if (trace_files)
- prline_file_name(entry, stderr);
-
- lspend = entry->symbols + entry->nsymbols;
-
- for (lsp = entry->symbols; lsp < lspend; lsp++) {
- register struct nlist *p = &lsp->nzlist.nlist;
-
- if (p->n_type == (N_SETV | N_EXT))
- continue;
-
- /*
- * Turn magically prefixed symbols into set symbols of
- * a corresponding type.
- */
- if (set_element_prefixes &&
- set_element_prefixed_p(entry->strings+lsp->nzlist.nz_strx))
- lsp->nzlist.nz_type += (N_SETA - N_ABS);
-
- if (SET_ELEMENT_P(p->n_type)) {
- set_symbol_count++;
- if (!relocatable_output)
- enter_global_ref(lsp,
- p->n_un.n_strx + entry->strings, entry);
- } else if (p->n_type == N_WARNING) {
- char *msg = p->n_un.n_strx + entry->strings;
-
- /* Grab the next entry. */
- lsp++;
- p = &lsp->nzlist.nlist;
- if (p->n_type != (N_UNDF | N_EXT)) {
- warnx(
- "%s: Warning symbol without external reference following.",
- get_file_name(entry));
- make_executable = 0;
- lsp--; /* Process normally. */
- } else {
- symbol *sp;
- char *name = p->n_un.n_strx + entry->strings;
- /* Deal with the warning symbol. */
- lsp->flags |= LS_WARNING;
- enter_global_ref(lsp, name, entry);
- sp = getsym(name);
- if (sp->warning == NULL) {
- sp->warning = (char *)
- xmalloc(strlen(msg)+1);
- strcpy(sp->warning, msg);
- warn_sym_count++;
- } else if (strcmp(sp->warning, msg))
- warnx(
- "%s: multiple definitions for warning symbol `%s'",
- get_file_name(entry), demangle(sp->name));
- }
- } else if (p->n_type & N_EXT) {
- enter_global_ref(lsp,
- p->n_un.n_strx + entry->strings, entry);
- } else if (p->n_un.n_strx &&
- (p->n_un.n_strx + entry->strings)[0] == LPREFIX)
- lsp->flags |= LS_L_SYMBOL;
- }
-
-}
-
-/*
- * Enter one global symbol in the hash table. LSP points to the `struct
- * localsymbol' from the file that describes the global symbol. NAME is the
- * symbol's name. ENTRY is the file entry for the file the symbol comes from.
- *
- * LSP is put on the chain of all such structs that refer to the same symbol.
- * This chain starts in the `refs' for symbols from relocatable objects. A
- * backpointer to the global symbol is kept in LSP.
- *
- * Symbols from shared objects are linked through `soref'. For such symbols
- * that's all we do at this stage, with the exception of the case where the
- * symbol is a common. The `referenced' bit is only set for references from
- * relocatable objects.
- *
- */
-
-static void
-enter_global_ref(lsp, name, entry)
- struct localsymbol *lsp;
- char *name;
- struct file_entry *entry;
-{
- register struct nzlist *nzp = &lsp->nzlist;
- register symbol *sp = getsym(name);
- register int type = nzp->nz_type;
- int oldref = (sp->flags & GS_REFERENCED);
- int olddef = sp->defined;
- int com = sp->defined && sp->common_size;
-
- if (type == (N_INDR | N_EXT) && !olddef) {
- sp->alias = getsym(entry->strings + (lsp + 1)->nzlist.nz_strx);
- if (sp == sp->alias) {
- warnx("%s: %s is alias for itself",
- get_file_name(entry), name);
- /* Rewrite symbol as global text symbol with value 0 */
- lsp->nzlist.nz_type = N_TEXT|N_EXT;
- lsp->nzlist.nz_value = 0;
- make_executable = 0;
- }
-#if 0
- if (sp->flags & GS_REFERENCED)
- sp->alias->flags |= GS_REFERENCED;
-#endif
- }
-
- if (entry->flags & E_DYNAMIC) {
- lsp->next = sp->sorefs;
- sp->sorefs = lsp;
- lsp->symbol = sp;
-
- /*
- * Handle commons from shared objects:
- * 1) If symbol hitherto undefined, turn it into a common.
- * 2) If symbol already common, update size if necessary.
- */
-/*XXX - look at case where commons are only in shared objects */
- if (type == (N_UNDF | N_EXT) && nzp->nz_value) {
- if (!olddef) {
- if (oldref)
- undefined_global_sym_count--;
- common_defined_global_count++;
- sp->common_size = nzp->nz_value;
- sp->defined = N_UNDF | N_EXT;
- } else if (com && sp->common_size < nzp->nz_value) {
- sp->common_size = nzp->nz_value;
- }
- } else if (type != (N_UNDF | N_EXT) && !oldref) {
- /*
- * This is an ex common...
- */
- if (com)
- common_defined_global_count--;
- sp->common_size = 0;
- sp->defined = 0;
- }
-
- /*
- * Handle size information in shared objects.
- */
- if (nzp->nz_size > sp->size)
- sp->size = nzp->nz_size;
-
- if ((lsp->flags & LS_WARNING) && (sp->flags & GS_REFERENCED))
- /*
- * Prevent warning symbols from getting
- * gratuitously referenced.
- */
- list_warning_symbols = 1;
- return;
- }
-
- lsp->next = sp->refs;
- sp->refs = lsp;
- lsp->symbol = sp;
-
- if (lsp->flags & LS_WARNING) {
- /*
- * Prevent warning symbols from getting
- * gratuitously referenced.
- */
- if (sp->flags & GS_REFERENCED)
- list_warning_symbols = 1;
- return;
- }
-
- if (sp->warning)
- list_warning_symbols = 1;
-
- sp->flags |= GS_REFERENCED;
-
- if (sp == dynamic_symbol || sp == got_symbol) {
- if (type != (N_UNDF | N_EXT) && !(entry->flags & E_JUST_SYMS))
- errx(1,"Linker reserved symbol %s defined as type %x ",
- name, type);
- return;
- }
-
- if (olddef && N_ISWEAK(&nzp->nlist) && !(sp->flags & GS_WEAK)) {
-#ifdef DEBUG
- printf("%s: not overridden by weak symbol from %s\n",
- demangle(sp->name), get_file_name(entry));
-#endif
- return;
- }
-
- if (type == (N_SIZE | N_EXT)) {
-
- if (relocatable_output && nzp->nz_value != 0 && sp->size == 0)
- size_sym_count++;
- if (sp->size < nzp->nz_value)
- sp->size = nzp->nz_value;
-
- } else if (type != (N_UNDF | N_EXT) || nzp->nz_value) {
-
- /*
- * Set `->defined' here, so commons and undefined globals
- * can be counted correctly.
- */
- if (!sp->defined || sp->defined == (N_UNDF | N_EXT)) {
- sp->defined = type;
- }
-
- if ((sp->flags & GS_WEAK) && !N_ISWEAK(&nzp->nlist)) {
- /*
- * Upgrade an existing weak definition.
- * We fake it by pretending the symbol is undefined;
- * must undo any common fiddling, however.
- */
- if (!oldref)
- errx(1, "internal error: enter_glob_ref: "
- "weak symbol not referenced");
- if (!olddef && !com)
- undefined_weak_sym_count--;
- undefined_global_sym_count++;
- sp->defined = type;
- sp->flags &= ~GS_WEAK;
- olddef = 0;
- if (com)
- common_defined_global_count--;
- com = 0;
- sp->common_size = 0;
- }
- if (oldref && !olddef) {
- /*
- * It used to be undefined and we're defining it.
- */
- undefined_global_sym_count--;
- if (sp->flags & GS_WEAK)
- /* Used to be a weak reference */
- undefined_weak_sym_count--;
- if (undefined_global_sym_count < 0 ||
- undefined_weak_sym_count < 0)
- errx(1, "internal error: enter_glob_ref: "
- "undefined_global_sym_count = %d, "
- "undefined_weak_sym_count = %d",
- undefined_global_sym_count,
- undefined_weak_sym_count);
-
- }
-
- if (N_ISWEAK(&nzp->nlist))
- /* The definition is weak */
- sp->flags |= GS_WEAK;
-
- if (!olddef && type == (N_UNDF | N_EXT) && nzp->nz_value) {
- /*
- * First definition and it's common.
- */
- common_defined_global_count++;
- sp->common_size = nzp->nz_value;
- } else if (com && type != (N_UNDF | N_EXT)) {
- /*
- * It used to be common and we're defining
- * it as something else.
- */
- common_defined_global_count--;
- sp->common_size = 0;
- } else if (com && type == (N_UNDF | N_EXT) &&
- sp->common_size < nzp->nz_value)
- /*
- * It used to be common and this is a new common entry
- * to which we need to pay attention.
- */
- sp->common_size = nzp->nz_value;
-
- if (SET_ELEMENT_P(type) && (!olddef || com))
- set_vector_count++;
-
- } else if (!oldref && !com) {
- /*
- * An unreferenced symbol can already be defined
- * as common by shared objects.
- */
- undefined_global_sym_count++;
- if (N_ISWEAK(&nzp->nlist)) {
- /* The reference is weak */
- sp->flags |= GS_WEAK;
- undefined_weak_sym_count++;
- }
- }
-
- if (sp == end_symbol && (entry->flags & E_JUST_SYMS) &&
- !T_flag_specified)
- text_start = nzp->nz_value;
-
- if (sp->flags & GS_TRACE) {
- register char *reftype;
- switch (type & N_TYPE) {
- case N_UNDF:
- reftype = nzp->nz_value
- ? "defined as common" : "referenced";
- break;
-
- case N_ABS:
- reftype = "defined as absolute";
- break;
-
- case N_TEXT:
- reftype = "defined in text section";
- break;
-
- case N_DATA:
- reftype = "defined in data section";
- break;
-
- case N_BSS:
- reftype = "defined in BSS section";
- break;
-
- case N_INDR:
- reftype = "alias";
- break;
-
- case N_SIZE:
- reftype = "size spec";
- break;
-
- default:
- reftype = "I don't know this type";
- break;
- }
-
- fprintf(stderr, "symbol %s %s%s in ", demangle(sp->name),
- (N_ISWEAK(&nzp->nlist))?"weakly ":"", reftype);
- print_file_name (entry, stderr);
- fprintf(stderr, "\n");
- }
-}
-
-/*
- * This returns 0 if the given file entry's symbol table does *not* contain
- * the nlist point entry, and it returns the files entry pointer (cast to
- * unsigned long) if it does.
- */
-
-unsigned long
-contains_symbol(entry, np)
- struct file_entry *entry;
- register struct nlist *np;
-{
- if (np >= &entry->symbols->nzlist.nlist &&
- np < &(entry->symbols + entry->nsymbols)->nzlist.nlist)
- return (unsigned long) entry;
- return 0;
-}
-
-
-/*
- * Having entered all the global symbols and found the sizes of sections of
- * all files to be linked, make all appropriate deductions from this data.
- *
- * We propagate global symbol values from definitions to references. We compute
- * the layout of the output file and where each input file's contents fit
- * into it.
- *
- * This is now done in several stages.
- *
- * 1) All global symbols are examined for definitions in relocatable (.o)
- * files. The symbols' type is set according to the definition found,
- * but its value can not yet be determined. In stead, we keep a pointer
- * to the file entry's localsymbol that bequeathed the global symbol with
- * its definition. Also, multiple (incompatible) definitions are checked
- * for in this pass. If no definition comes forward, the set of local
- * symbols originating from shared objects is searched for a definition.
- *
- * 2) Then the relocation information of each relocatable file is examined
- * for possible contributions to the RRS section.
- *
- * 3) When this is done, the sizes and start addresses are set of all segments
- * that will appear in the output file (including the RRS segment).
- *
- * 4) Finally, all symbols are relocated according according to the start
- * of the entry they are part of. Then global symbols are assigned their
- * final values. Also, space for commons and imported data are allocated
- * during this pass, if the link mode in effect so demands.
- *
- */
-
-static void
-digest_symbols()
-{
-
- if (trace_files)
- fprintf(stderr, "Digesting symbol information:\n\n");
-
- if (!relocatable_output) {
- /*
- * The set sector size is the number of set elements + a word
- * for each symbol for the length word at the beginning of
- * the vector, plus a word for each symbol for a zero at the
- * end of the vector (for incremental linking).
- */
- set_sect_size = (set_symbol_count + 2 * set_vector_count) *
- sizeof (unsigned long);
- set_vectors = (long *)xmalloc (set_sect_size);
- setv_fill_count = 0;
- }
-
- /* Pass 1: check and define symbols */
- defined_global_sym_count = 0;
- digest_pass1();
-
- each_full_file(consider_relocation, (void *)0); /* Text */
- each_full_file(consider_relocation, (void *)1); /* Data */
-
- each_file(consider_local_symbols, (void *)0);
-
- /*
- * Compute total size of sections.
- * RRS data is the first output data section, RRS text is the last
- * text section. Thus, DATA_START is calculated from RRS_DATA_START
- * and RRS_DATA_SIZE, while RRS_TEXT_START is derived from TEXT_START
- * and TEXT_SIZE.
- */
- consider_rrs_section_lengths();
- each_full_file(consider_file_section_lengths, 0);
- rrs_text_start = text_start + text_size;
- text_size += rrs_text_size;
- data_size += rrs_data_size;
-
- /*
- * If necessary, pad text section to full page in the file. Include
- * the padding in the text segment size.
- */
-
- if (page_align_segments || page_align_data) {
- int text_end = text_size + N_TXTOFF(outheader);
- text_pad = PALIGN(text_end, page_size) - text_end;
- text_size += text_pad;
- }
- outheader.a_text = text_size;
-
- /*
- * Make the data segment address start in memory on a suitable
- * boundary.
- */
-
- if (!Tdata_flag_specified)
- rrs_data_start = text_start +
- DATA_START(outheader) - TEXT_START(outheader);
-
- data_start = rrs_data_start + rrs_data_size;
- if (!relocatable_output) {
- set_sect_start = rrs_data_start + data_size;
- data_size += MALIGN(set_sect_size);
- }
- bss_start = rrs_data_start + data_size;
-
-#ifdef DEBUG
-printf("textstart = %#x, textsize = %#x, rrs_text_start = %#x, rrs_text_size %#x\n",
- text_start, text_size, rrs_text_start, rrs_text_size);
-printf("datastart = %#x, datasize = %#x, rrs_data_start %#x, rrs_data_size %#x\n",
- data_start, data_size, rrs_data_start, rrs_data_size);
-printf("bssstart = %#x, bsssize = %#x\n",
- bss_start, bss_size);
-printf("set_sect_start = %#x, set_sect_size = %#x\n",
- set_sect_start, set_sect_size);
-#endif
-
- /* Compute start addresses of each file's sections and symbols. */
-
- each_full_file(relocate_file_addresses, 0);
- relocate_rrs_addresses();
-
- /* Pass 2: assign values to symbols */
- digest_pass2();
-
- if (end_symbol) { /* These are null if -r. */
- etext_symbol->value = text_start + text_size - text_pad;
- edata_symbol->value = rrs_data_start + data_size;
- end_symbol->value = rrs_data_start + data_size + bss_size;
- }
- /*
- * Figure the data_pad now, so that it overlaps with the bss
- * addresses.
- */
-
- if (specified_data_size && specified_data_size > data_size)
- data_pad = specified_data_size - data_size;
-
- if (page_align_segments)
- data_pad = PALIGN(data_pad + data_size, page_size) - data_size;
-
- bss_size -= data_pad;
- if (bss_size < 0)
- bss_size = 0;
-
- data_size += data_pad;
-
- /*
- * Calculate total number of symbols that will go into
- * the output symbol table (barring DISCARD_* settings).
- */
- global_sym_count = defined_global_sym_count +
- undefined_global_sym_count;
-
- if (dynamic_symbol->flags & GS_REFERENCED)
- global_sym_count++;
-
- if (got_symbol->flags & GS_REFERENCED)
- global_sym_count++;
-
- if (relocatable_output || building_shared_object) {
- /* For each alias we write out two struct nlists */
- global_sym_count += global_alias_count;
- /* Propagate warning symbols; costs two extra struct nlists */
- global_sym_count += 2 * warn_sym_count;
- }
-
- if (relocatable_output)
- /* We write out the original N_SIZE symbols */
- global_sym_count += size_sym_count;
-
-#ifdef DEBUG
-printf(
-"global symbols %d "
-"(defined %d, undefined %d, weak %d, aliases %d, warnings 2 * %d, "
-"size symbols %d)\ncommons %d, locals: %d, debug symbols: %d, set_symbols %d\n",
- global_sym_count,
- defined_global_sym_count, undefined_global_sym_count,
- undefined_weak_sym_count,
- global_alias_count, warn_sym_count, size_sym_count,
- common_defined_global_count, local_sym_count,
- debugger_sym_count, set_symbol_count);
-#endif
-}
-
-/*
- * Determine the definition of each global symbol.
- */
-static void
-digest_pass1()
-{
-
- /*
- * For each symbol, verify that it is defined globally at most
- * once within relocatable files (except when building a shared lib).
- * and set the `defined' field if there is a definition.
- *
- * Then check the shared object symbol chain for any remaining
- * undefined symbols. Set the `so_defined' field for any
- * definition find this way.
- */
- FOR_EACH_SYMBOL(i, sp) {
- symbol *spsave;
- struct localsymbol *lsp;
- int defs = 0;
-
- if (!(sp->flags & GS_REFERENCED)) {
-#if 0
- /* Check for undefined symbols in shared objects */
- int type;
- for (lsp = sp->sorefs; lsp; lsp = lsp->next) {
- type = lsp->nzlist.nlist.n_type;
- if ((type & N_EXT) && type != (N_UNDF | N_EXT))
- break;
- }
- if ((type & N_EXT) && type == (N_UNDF | N_EXT))
- undefined_shobj_sym_count++;
-#endif
-
- /* Superfluous symbol from shared object */
- continue;
- }
- if (sp->so_defined)
- /* Already examined; must have been an alias */
- continue;
-
- if (sp == got_symbol || sp == dynamic_symbol)
- continue;
-
- for (lsp = sp->refs; lsp; lsp = lsp->next) {
- register struct nlist *p = &lsp->nzlist.nlist;
- register int type = p->n_type;
-
- if (SET_ELEMENT_P(type)) {
- if (relocatable_output)
- errx(1,
- "internal error: global ref to set el %s with -r",
- demangle(sp->name));
- if (!defs++) {
- sp->defined = N_SETV | N_EXT;
- sp->value =
- setv_fill_count++ * sizeof(long);
- } else if ((sp->defined & N_TYPE) != N_SETV) {
- sp->mult_defs = 1;
- multiple_def_count++;
- }
- /* Keep count and remember symbol */
- sp->setv_count++;
- set_vectors[setv_fill_count++] = (long)p;
- if (building_shared_object) {
- struct relocation_info reloc;
-
- /*
- * Make sure to relocate the contents
- * of this set vector.
- */
- bzero(&reloc, sizeof(reloc));
- RELOC_INIT_SEGMENT_RELOC(&reloc);
- RELOC_ADDRESS(&reloc) =
- setv_fill_count * sizeof(long);
- alloc_rrs_segment_reloc(NULL, &reloc);
- }
-
- } else if ((type & N_EXT) && type != (N_UNDF | N_EXT)
- && (type & N_TYPE) != N_FN
- && (type & N_TYPE) != N_SIZE) {
- /* non-common definition */
- if (!N_ISWEAK(p))
- ++defs;
- if (defs > 1) {
- sp->mult_defs = 1;
- multiple_def_count++;
- } else if (!N_ISWEAK(p) ||
- (!sp->def_lsp && !sp->common_size)) {
- sp->def_lsp = lsp;
- lsp->entry->flags |= E_SYMBOLS_USED;
- sp->defined = type;
- sp->aux = N_AUX(p);
- }
- }
- }
-
- /*
- * If this symbol has acquired final definition, we're done.
- * Commons must be allowed to bind to shared object data
- * definitions.
- */
- if (sp->defined &&
- (sp->common_size == 0 ||
- relocatable_output || building_shared_object)) {
- if ((sp->defined & N_TYPE) == N_SETV)
- /* Allocate zero entry in set vector */
- setv_fill_count++;
- /*
- * At this stage, we do not know whether an alias
- * is going to be defined for real here, or whether
- * it refers to a shared object symbol. The decision
- * is deferred until digest_pass2().
- */
- if (!sp->alias)
- defined_global_sym_count++;
- continue;
- }
-
- if (relocatable_output)
- /* We're done */
- continue;
-
- /*
- * Still undefined, search the shared object symbols for a
- * definition. This symbol must go into the RRS.
- */
- if (building_shared_object) {
- /* Just punt for now */
- undefined_global_sym_count--;
- if (undefined_global_sym_count < 0)
- errx(1,
- "internal error: digest_pass1,1: %s: undefined_global_sym_count = %d",
- demangle(sp->name), undefined_global_sym_count);
- continue;
- }
-
- spsave=sp; /*XXX*/
- again:
- for (lsp = sp->sorefs; lsp; lsp = lsp->next) {
- register struct nlist *p = &lsp->nzlist.nlist;
- register int type = p->n_type;
-
- if ((type & N_EXT) && type != (N_UNDF | N_EXT) &&
- (type & N_TYPE) != N_FN) {
- /* non-common definition */
- if (sp->common_size) {
- /*
- * This common has an so defn; switch
- * to it iff defn is: data, first-class
- * and not weak.
- */
- if (N_AUX(p) != AUX_OBJECT ||
- N_ISWEAK(p) ||
- (lsp->entry->flags & E_SECONDCLASS))
- continue;
-
- /*
- * Change common to so ref. First,
- * downgrade common to undefined.
- */
- sp->common_size = 0;
- sp->defined = 0;
- common_defined_global_count--;
- undefined_global_sym_count++;
- }
- sp->def_lsp = lsp;
- sp->so_defined = type;
- sp->aux = N_AUX(p);
- if (lsp->entry->flags & E_SECONDCLASS)
- /* Keep looking for something better */
- continue;
- if (N_ISWEAK(p))
- /* Keep looking for something better */
- continue;
- break;
- }
- }
- if (sp->def_lsp) {
-#ifdef DEBUG
-printf("pass1: SO definition for %s, type %x in %s at %#x\n",
- demangle(sp->name), sp->so_defined, get_file_name(sp->def_lsp->entry),
- sp->def_lsp->nzlist.nz_value);
-#endif
- sp->def_lsp->entry->flags |= E_SYMBOLS_USED;
- if (sp->flags & GS_REFERENCED) {
- undefined_global_sym_count--;
- } else
- sp->flags |= GS_REFERENCED;
- if (undefined_global_sym_count < 0)
- errx(1, "internal error: digest_pass1,2: "
- "%s: undefined_global_sym_count = %d",
- demangle(sp->name), undefined_global_sym_count);
- if (sp->alias &&
- !(sp->alias->flags & GS_REFERENCED)) {
- sp = sp->alias;
- goto again;
- }
- } else if (sp->defined) {
- if (sp->common_size == 0)
- errx(1, "internal error: digest_pass1,3: "
- "%s: not a common: %x",
- demangle(sp->name), sp->defined);
- /*
- * Common not bound to shared object data; treat
- * it now like other defined symbols were above.
- */
- if (!sp->alias)
- defined_global_sym_count++;
- }
- sp=spsave; /*XXX*/
- } END_EACH_SYMBOL;
-
- if (setv_fill_count != set_sect_size/sizeof(long))
- errx(1, "internal error: allocated set symbol space (%d) "
- "doesn't match actual (%d)",
- set_sect_size/sizeof(long), setv_fill_count);
-}
-
-
-/*
- * Scan relocation info in ENTRY for contributions to the RRS section
- * of the output file.
- */
-static void
-consider_relocation(entry, dataseg)
- struct file_entry *entry;
- int dataseg;
-{
- struct relocation_info *reloc, *end;
- struct localsymbol *lsp;
- symbol *sp;
-
- if (dataseg == 0) {
- /* Text relocations */
- reloc = entry->textrel;
- end = entry->textrel + entry->ntextrel;
- } else {
- /* Data relocations */
- reloc = entry->datarel;
- end = entry->datarel + entry->ndatarel;
- }
-
- for (; reloc < end; reloc++) {
-
- if (relocatable_output) {
- lsp = &entry->symbols[reloc->r_symbolnum];
- if (RELOC_BASEREL_P(reloc)) {
- pic_code_seen = 1; /* Compatibility */
- if (!RELOC_EXTERN_P(reloc))
- lsp->flags |= LS_RENAME;
- }
- continue;
- }
-
- /*
- * First, do the PIC specific relocs.
- * r_relative and r_copy should not occur at this point
- * (we do output them). The others break down to these
- * combinations:
- *
- * jmptab: extern: needs jmp slot
- * !extern: "intersegment" jump/call,
- * should get resolved in output
- *
- * baserel: extern: need GOT entry
- * !extern: may need GOT entry,
- * machine dependent
- *
- * baserel's always refer to symbol through `r_symbolnum'
- * whether extern or not. Internal baserels refer to statics
- * that must be accessed either *through* the GOT table like
- * global data, or by means of an offset from the GOT table.
- * The macro RELOC_STATICS_THROUGH_GOT_P() determines which
- * applies, since this is a machine (compiler?) dependent
- * addressing mode.
- */
-
- if (RELOC_JMPTAB_P(reloc)) {
-
- if (!RELOC_EXTERN_P(reloc))
- continue;
-
- lsp = &entry->symbols[reloc->r_symbolnum];
- sp = lsp->symbol;
- if (sp->alias)
- sp = sp->alias;
- if (sp->flags & GS_TRACE) {
- fprintf(stderr, "symbol %s has jmpslot in %s\n",
- demangle(sp->name), get_file_name(entry));
- }
- alloc_rrs_jmpslot(entry, sp);
-
- } else if (RELOC_BASEREL_P(reloc)) {
-
- lsp = &entry->symbols[reloc->r_symbolnum];
- alloc_rrs_gotslot(entry, reloc, lsp);
- if (pic_type != PIC_TYPE_NONE &&
- RELOC_PIC_TYPE(reloc) != pic_type)
- errx(1, "%s: illegal reloc type mix",
- get_file_name(entry));
- pic_type = RELOC_PIC_TYPE(reloc);
-
- } else if (RELOC_EXTERN_P(reloc)) {
-
- /*
- * Non-PIC relocations.
- * If the definition comes from a shared object
- * we need a relocation entry in RRS.
- *
- * If the .so definition is N_TEXT a jmpslot is
- * allocated.
- *
- * If it is N_DATA we allocate an address in BSS (?)
- * and arrange for the data to be copied at run-time.
- * The symbol is temporarily marked with N_SIZE in
- * the `defined' field, so we know what to do in
- * pass2() and during actual relocation. We convert
- * the type back to something real again when writing
- * out the symbols.
- *
- */
- lsp = &entry->symbols[reloc->r_symbolnum];
- sp = lsp->symbol;
- if (sp == NULL)
- errx(1, "%s: bogus relocation record",
- get_file_name(entry));
-
- if (sp->alias)
- sp = sp->alias;
-
- /*
- * Skip refs to _GLOBAL_OFFSET_TABLE_ and __DYNAMIC
- */
- if (sp == got_symbol) {
- if (!CHECK_GOT_RELOC(reloc))
- errx(1,
- "%s: Unexpected relocation type for GOT symbol",
- get_file_name(entry));
- continue;
- }
-
- /*
- * This symbol gives rise to a RRS entry
- */
-
- if (building_shared_object) {
- if (sp->flags & GS_TRACE) {
- fprintf(stderr,
- "symbol %s RRS entry in %s\n",
- demangle(sp->name), get_file_name(entry));
- }
- alloc_rrs_reloc(entry, sp);
- continue;
- }
-
- if (force_alias_definition && sp->so_defined &&
- sp->aux == AUX_FUNC) {
-
- /* Call to shared library procedure */
- alloc_rrs_jmpslot(entry, sp);
-
- } else if (sp->size && sp->so_defined &&
- sp->aux == AUX_OBJECT) {
-
- /* Reference to shared library data */
- alloc_rrs_cpy_reloc(entry, sp);
- sp->defined = N_SIZE;
-
- } else if (!sp->defined && sp->common_size == 0 &&
- sp->so_defined)
- alloc_rrs_reloc(entry, sp);
-
- } else {
- /*
- * Segment relocation.
- * Prepare an RRS relocation as these are load
- * address dependent.
- */
- if (building_shared_object && !RELOC_PCREL_P(reloc)) {
- alloc_rrs_segment_reloc(entry, reloc);
- }
- }
- }
-}
-
-/*
- * Determine the disposition of each local symbol.
- */
-static void
-consider_local_symbols(entry)
- register struct file_entry *entry;
-{
- register struct localsymbol *lsp, *lspend;
-
- if (entry->flags & E_DYNAMIC)
- return;
-
- lspend = entry->symbols + entry->nsymbols;
-
- /*
- * For each symbol determine whether it should go
- * in the output symbol table.
- */
-
- for (lsp = entry->symbols; lsp < lspend; lsp++) {
- register struct nlist *p = &lsp->nzlist.nlist;
- register int type = p->n_type;
-
- if (type == N_WARNING)
- continue;
-
- if (SET_ELEMENT_P (type)) {
- /*
- * This occurs even if global. These types of
- * symbols are never written globally, though
- * they are stored globally.
- */
- if (relocatable_output)
- lsp->flags |= LS_WRITE;
-
- } else if (!(type & (N_STAB | N_EXT))) {
-
- /*
- * Ordinary local symbol
- */
- if ((lsp->flags & LS_RENAME) || (
- discard_locals != DISCARD_ALL &&
- !(discard_locals == DISCARD_L &&
- (lsp->flags & LS_L_SYMBOL))) ) {
-
- lsp->flags |= LS_WRITE;
- local_sym_count++;
- }
-
- } else if (!(type & N_EXT)) {
-
- /*
- * Debugger symbol
- */
- if (strip_symbols == STRIP_NONE) {
- lsp->flags |= LS_WRITE;
- debugger_sym_count++;
- }
- }
- }
-
- /*
- * Count one for the local symbol that we generate,
- * whose name is the file's name (usually) and whose address
- * is the start of the file's text.
- */
- if (discard_locals != DISCARD_ALL)
- local_sym_count++;
-}
-
-/*
- * Accumulate the section sizes of input file ENTRY into the section sizes of
- * the output file.
- */
-static void
-consider_file_section_lengths(entry)
- register struct file_entry *entry;
-{
-
- entry->text_start_address = text_size;
- /* If there were any vectors, we need to chop them off */
- text_size += entry->header.a_text;
- entry->data_start_address = data_size;
- data_size += entry->header.a_data;
- entry->bss_start_address = bss_size;
- bss_size += MALIGN(entry->header.a_bss);
-
- text_reloc_size += entry->header.a_trsize;
- data_reloc_size += entry->header.a_drsize;
-}
-
-/*
- * Determine where the sections of ENTRY go into the output file,
- * whose total section sizes are already known.
- * Also relocate the addresses of the file's local and debugger symbols.
- */
-static void
-relocate_file_addresses(entry)
- register struct file_entry *entry;
-{
- register struct localsymbol *lsp, *lspend;
-
- entry->text_start_address += text_start;
- /*
- * Note that `data_start' and `data_size' have not yet been
- * adjusted for `data_pad'. If they had been, we would get the wrong
- * results here.
- */
- entry->data_start_address += data_start;
- entry->bss_start_address += bss_start;
-#ifdef DEBUG
-printf("%s: datastart: %#x, bss %#x\n", get_file_name(entry),
- entry->data_start_address, entry->bss_start_address);
-#endif
-
- lspend = entry->symbols + entry->nsymbols;
-
- for (lsp = entry->symbols; lsp < lspend; lsp++) {
- register struct nlist *p = &lsp->nzlist.nlist;
- register int type = p->n_type;
-
- /*
- * If this belongs to a section, update it
- * by the section's start address
- */
-
- switch (type & N_TYPE) {
- case N_TEXT:
- case N_SETT:
- p->n_value += entry->text_start_address;
- break;
- case N_DATA:
- case N_SETD:
- case N_SETV:
- /*
- * A symbol whose value is in the data section is
- * present in the input file as if the data section
- * started at an address equal to the length of the
- * file's text.
- */
- p->n_value += entry->data_start_address -
- entry->header.a_text;
- break;
- case N_BSS:
- case N_SETB:
- /* likewise for symbols with value in BSS. */
- p->n_value += entry->bss_start_address -
- (entry->header.a_text +
- entry->header.a_data);
- break;
- }
-
- }
-
-}
-
-/*
- * Assign a value to each global symbol.
- */
-static void
-digest_pass2()
-{
- FOR_EACH_SYMBOL(i, sp) {
- int size;
- int align = sizeof(int);
-
- if (!(sp->flags & GS_REFERENCED))
- continue;
-
- if (sp->alias &&
- (relocatable_output || building_shared_object ||
- (sp->alias->defined && !sp->alias->so_defined))) {
- /*
- * The alias points at a defined symbol, so it
- * must itself be counted as one too, in order to
- * compute the correct number of symbol table entries.
- */
- if (!sp->defined) {
- /*
- * Change aliased symbol's definition too.
- * These things happen if shared object commons
- * or data is going into our symbol table.
- */
- if (sp->so_defined != (N_INDR+N_EXT))
- warnx( "pass2: %s: alias isn't",
- demangle(sp->name));
- sp->defined = sp->so_defined;
- sp->so_defined = 0;
- }
- defined_global_sym_count++;
- }
-
- /*
- * Count the aliases that will appear in the output.
- */
- if (sp->alias && !sp->so_defined && !sp->alias->so_defined &&
- (sp->defined || relocatable_output ||
- !building_shared_object))
- global_alias_count++;
-
- if ((sp->defined & N_TYPE) == N_SETV) {
- /*
- * Set length word at front of vector and zero byte
- * at end. Reverse the vector itself to put it in
- * file order.
- */
- unsigned long i, *p, *q;
- unsigned long length_word_index =
- sp->value / sizeof(long);
-
- /* Relocate symbol value */
- sp->value += set_sect_start;
-
- set_vectors[length_word_index] = sp->setv_count;
-
- /*
- * Relocate vector to final address.
- */
- for (i = 0; i < sp->setv_count; i++) {
- struct nlist *p = (struct nlist *)
- set_vectors[1+i+length_word_index];
-
- set_vectors[1+i+length_word_index] = p->n_value;
- if (building_shared_object) {
- struct relocation_info reloc;
-
- bzero(&reloc, sizeof(reloc));
- RELOC_INIT_SEGMENT_RELOC(&reloc);
- RELOC_ADDRESS(&reloc) =
- (1 + i + length_word_index) *
- sizeof(long)
- + set_sect_start;
- RELOC_TYPE(&reloc) =
- (p->n_type - (N_SETA - N_ABS)) & N_TYPE;
- claim_rrs_segment_reloc(NULL, &reloc);
- }
- }
-
- /*
- * Reverse the vector.
- */
- p = &set_vectors[length_word_index + 1];
- q = &set_vectors[length_word_index + sp->setv_count];
- while (p < q) {
- unsigned long tmp = *p;
- *p++ = *q;
- *q-- = tmp;
- }
-
- /* Clear terminating entry */
- set_vectors[length_word_index + sp->setv_count + 1] = 0;
- continue;
- }
-
- if (sp->def_lsp) {
- if (sp->defined && (sp->defined & ~N_EXT) != N_SETV)
- sp->value = sp->def_lsp->nzlist.nz_value;
- if (sp->so_defined &&
- (sp->def_lsp->entry->flags & E_SECONDCLASS))
- /* Flag second-hand definitions */
- undefined_global_sym_count++;
- if (sp->flags & GS_TRACE)
- printf("symbol %s assigned to location %#lx\n",
- demangle(sp->name), sp->value);
- }
-
- /*
- * If not -r'ing, allocate common symbols in the BSS section.
- */
- if (building_shared_object && !(link_mode & SYMBOLIC))
- /* No common allocation in shared objects */
- continue;
-
- if ((size = sp->common_size) != 0) {
- /*
- * It's a common.
- */
- if (sp->defined != (N_UNDF + N_EXT))
- errx(1, "%s: common isn't", demangle(sp->name));
-
- } else if ((size = sp->size) != 0 && sp->defined == N_SIZE) {
- /*
- * It's data from shared object with size info.
- */
- if (!sp->so_defined)
- errx(1, "%s: Bogus N_SIZE item", demangle(sp->name));
-
- } else
- /*
- * It's neither
- */
- continue;
-
-
- if (relocatable_output && !force_common_definition) {
- sp->defined = 0;
- undefined_global_sym_count++;
- defined_global_sym_count--;
- continue;
- }
-
- /*
- * Round up to nearest sizeof (int). I don't know whether
- * this is necessary or not (given that alignment is taken
- * care of later), but it's traditional, so I'll leave it in.
- * Note that if this size alignment is ever removed, ALIGN
- * above will have to be initialized to 1 instead of sizeof
- * (int).
- */
-
- size = PALIGN(size, sizeof(int));
-
- while (align < MAX_ALIGNMENT && !(size & align))
- align <<= 1;
-
- bss_size = PALIGN(bss_size + data_size + rrs_data_start, align)
- - (data_size + rrs_data_start);
-
- sp->value = rrs_data_start + data_size + bss_size;
- if (sp->defined == (N_UNDF | N_EXT))
- sp->defined = N_BSS | N_EXT;
- else {
- sp->so_defined = 0;
- defined_global_sym_count++;
- }
- bss_size += size;
- if (write_map)
- printf("Allocating %s %s: %x at %lx\n",
- sp->defined==(N_BSS|N_EXT)?"common":"data",
- demangle(sp->name), size, sp->value);
-
- } END_EACH_SYMBOL;
-}
-
-
-/* -------------------------------------------------------------------*/
-
-/* Write the output file */
-void
-write_output()
-{
- struct stat statbuf;
- int filemode;
- mode_t u_mask;
-
- if (lstat(output_filename, &statbuf) == 0) {
- if (S_ISREG(statbuf.st_mode))
- (void)unlink(output_filename);
- }
-
- u_mask = umask(0);
- (void)umask(u_mask);
-
- outstream = fopen(output_filename, "w");
- if (outstream == NULL)
- err(1, "fopen: %s", output_filename);
-
- if (atexit(cleanup))
- err(1, "atexit");
-
- if (fstat(fileno(outstream), &statbuf) < 0)
- err(1, "fstat: %s", output_filename);
-
- filemode = statbuf.st_mode;
-
- if (S_ISREG(statbuf.st_mode) &&
- chmod(output_filename, filemode & ~0111) == -1)
- err(1, "chmod: %s", output_filename);
-
- /* Output the a.out header. */
- write_header();
-
- /* Output the text and data segments, relocating as we go. */
- write_text();
- write_data();
-
- /* Output the merged relocation info, if requested with `-r'. */
- if (relocatable_output)
- write_rel();
-
- /* Output the symbol table (both globals and locals). */
- write_syms();
-
- /* Output the RSS section */
- write_rrs();
-
- if (chmod (output_filename, filemode | (0111 & ~u_mask)) == -1)
- err(1, "chmod: %s", output_filename);
-
- fflush(outstream);
- /* Report I/O error such as disk full. */
- if (ferror(outstream) || fclose(outstream) != 0)
- err(1, "write_output: %s", output_filename);
- outstream = 0;
- if (real_output_filename)
- if (rename(output_filename, real_output_filename))
- err(1, "rename output: %s to %s",
- output_filename, real_output_filename);
-}
-
-/* Total number of symbols to be written in the output file. */
-static int nsyms;
-
-void
-write_header()
-{
- int flags;
-
- if (link_mode & SHAREABLE)
- /* Output is shared object */
- flags = EX_DYNAMIC | EX_PIC;
- else if (relocatable_output && pic_code_seen)
- /* Output is relocatable and contains PIC code */
- flags = EX_PIC;
- else if (rrs_section_type == RRS_FULL)
- /* Output is a dynamic executable */
- flags = EX_DYNAMIC;
- else
- /*
- * Output is a static executable
- * or a non-PIC relocatable object
- */
- flags = 0;
-
- if (oldmagic && (flags & EX_DPMASK) && !(link_mode & FORCEDYNAMIC))
- warnx("Cannot set flag in old magic headers\n");
-
- N_SET_FLAG (outheader, flags);
-
- outheader.a_text = text_size;
- outheader.a_data = data_size;
- outheader.a_bss = bss_size;
- outheader.a_entry = (entry_symbol ? entry_symbol->value
- : text_start + entry_offset);
-
- if (strip_symbols == STRIP_ALL)
- nsyms = 0;
- else
- nsyms = global_sym_count + local_sym_count + debugger_sym_count;
-
- if (relocatable_output)
- nsyms += set_symbol_count;
-
- outheader.a_syms = nsyms * sizeof (struct nlist);
-
- if (relocatable_output) {
- outheader.a_trsize = text_reloc_size;
- outheader.a_drsize = data_reloc_size;
- } else {
- outheader.a_trsize = 0;
- outheader.a_drsize = 0;
- }
-
- md_swapout_exec_hdr(&outheader);
- mywrite(&outheader, 1, sizeof (struct exec), outstream);
- md_swapin_exec_hdr(&outheader);
-
- /*
- * Output whatever padding is required in the executable file
- * between the header and the start of the text.
- */
-
-#ifndef COFF_ENCAPSULATE
- padfile(N_TXTOFF(outheader) - sizeof outheader, outstream);
-#endif
-}
-
-/*
- * Relocate the text segment of each input file
- * and write to the output file.
- */
-void
-write_text()
-{
-
- if (trace_files)
- fprintf(stderr, "Copying and relocating text:\n\n");
-
- each_full_file(copy_text, 0);
- file_close();
-
- if (trace_files)
- fprintf(stderr, "\n");
-
- padfile(text_pad, outstream);
-}
-
-/*
- * Read the text segment contents of ENTRY, relocate them, and write the
- * result to the output file. If `-r', save the text relocation for later
- * reuse.
- */
-void
-copy_text(entry)
- struct file_entry *entry;
-{
- register char *bytes;
- register int fd;
-
- if (trace_files)
- prline_file_name(entry, stderr);
-
- fd = file_open(entry);
-
- /* Allocate space for the file's text section */
- bytes = (char *)alloca(entry->header.a_text);
-
- /* Deal with relocation information however is appropriate */
- if (entry->textrel == NULL)
- errx(1, "%s: no text relocation", get_file_name(entry));
-
- /* Read the text section into core. */
- if (lseek(fd, text_offset(entry), L_SET) == (off_t)-1)
- err(1, "%s: copy_text: lseek", get_file_name(entry));
- if (entry->header.a_text != read(fd, bytes, entry->header.a_text))
- errx(1, "%s: copy_text: premature EOF", get_file_name(entry));
-
- /* Relocate the text according to the text relocation. */
- perform_relocation (bytes, entry->header.a_text,
- entry->textrel, entry->ntextrel, entry, 0);
-
- /* Write the relocated text to the output file. */
- mywrite(bytes, entry->header.a_text, 1, outstream);
-}
-
-/*
- * Relocate the data segment of each input file
- * and write to the output file.
- */
-
-void
-write_data()
-{
- off_t pos;
-
- if (trace_files)
- fprintf(stderr, "Copying and relocating data:\n\n");
-
- pos = N_DATOFF(outheader) + data_start - rrs_data_start;
- if (fseek(outstream, pos, SEEK_SET) != 0)
- errx(1, "write_data: fseek");
-
- each_full_file(copy_data, 0);
- file_close();
-
- /*
- * Write out the set element vectors. See digest symbols for
- * description of length of the set vector section.
- */
-
- if (set_vector_count) {
- swap_longs(set_vectors, set_symbol_count + 2*set_vector_count);
- mywrite(set_vectors, set_symbol_count + 2*set_vector_count,
- sizeof (unsigned long), outstream);
- }
-
- if (trace_files)
- fprintf(stderr, "\n");
-
- padfile(data_pad, outstream);
-}
-
-/*
- * Read the data segment contents of ENTRY, relocate them, and write the
- * result to the output file. If `-r', save the data relocation for later
- * reuse. See comments in `copy_text'.
- */
-void
-copy_data(entry)
- struct file_entry *entry;
-{
- register char *bytes;
- register int fd;
-
- if (trace_files)
- prline_file_name (entry, stderr);
-
- fd = file_open(entry);
-
- bytes = (char *)alloca(entry->header.a_data);
-
- if (entry->datarel == NULL)
- errx(1, "%s: no data relocation", get_file_name(entry));
-
- if (lseek(fd, text_offset(entry) + entry->header.a_text, L_SET) ==
- (off_t)-1)
- err(1, "%s: copy_data: lseek", get_file_name(entry));
- if (entry->header.a_data != read(fd, bytes, entry->header.a_data))
- errx(1, "%s: copy_data: premature EOF", get_file_name(entry));
-
- perform_relocation(bytes, entry->header.a_data,
- entry->datarel, entry->ndatarel, entry, 1);
-
- mywrite(bytes, entry->header.a_data, 1, outstream);
-}
-
-/*
- * Relocate ENTRY's text or data section contents. DATA is the address of the
- * contents, in core. DATA_SIZE is the length of the contents. PC_RELOCATION
- * is the difference between the address of the contents in the output file
- * and its address in the input file. RELOC is the address of the
- * relocation info, in core. NRELOC says how many there are.
- */
-
-int pc_relocation;
-
-void
-perform_relocation(data, data_size, reloc, nreloc, entry, dataseg)
- char *data;
- int data_size;
- struct relocation_info *reloc;
- int nreloc;
- struct file_entry *entry;
- int dataseg;
-{
-
- register struct relocation_info *r = reloc;
- struct relocation_info *end = reloc + nreloc;
-
- int text_relocation = entry->text_start_address;
- int data_relocation = entry->data_start_address - entry->header.a_text;
- int bss_relocation = entry->bss_start_address -
- entry->header.a_text - entry->header.a_data;
- pc_relocation = dataseg
- ? entry->data_start_address - entry->header.a_text
- : entry->text_start_address;
-
- for (; r < end; r++) {
- int addr = RELOC_ADDRESS(r);
- long addend = md_get_addend(r, data+addr);
- long relocation;
-
- /*
- * Loop over the relocations again as we did in
- * consider_relocation(), claiming the reserved RRS
- * relocations.
- */
-
- if (addr >= data_size)
- errx(1, "%s: relocation address out of range",
- get_file_name(entry));
-
- if (RELOC_JMPTAB_P(r)) {
-
- int symindex = RELOC_SYMBOL(r);
- struct localsymbol *lsp = &entry->symbols[symindex];
- symbol *sp;
-
- if (symindex >= entry->nsymbols)
- errx(1, "%s: relocation symbolnum out of range",
- get_file_name(entry));
-
- sp = lsp->symbol;
- if (sp == NULL)
- errx(1, "%s: bogus relocation record",
- get_file_name(entry));
- if (sp->alias)
- sp = sp->alias;
-
- if (relocatable_output)
- relocation = addend;
- else if (!RELOC_EXTERN_P(r)) {
- relocation = addend +
- data_relocation - text_relocation;
- } else
- relocation = addend +
- claim_rrs_jmpslot(entry, r, sp, addend);
-
- } else if (RELOC_BASEREL_P(r)) {
-
- int symindex = RELOC_SYMBOL(r);
- struct localsymbol *lsp = &entry->symbols[symindex];
-
- if (symindex >= entry->nsymbols)
- errx(1, "%s: relocation symbolnum out of range",
- get_file_name(entry));
-
- if (relocatable_output)
- relocation = addend;
- else if (!RELOC_EXTERN_P(r))
- relocation = claim_rrs_internal_gotslot(
- entry, r, lsp, addend);
- else
- relocation = claim_rrs_gotslot(
- entry, r, lsp, addend);
-
- } else if (RELOC_EXTERN_P(r)) {
-
- int symindex = RELOC_SYMBOL(r);
- symbol *sp;
-
- if (symindex >= entry->nsymbols)
- errx(1, "%s: relocation symbolnum out of range",
- get_file_name(entry));
-
- sp = entry->symbols[symindex].symbol;
- if (sp == NULL)
- errx(1, "%s: bogus relocation record",
- get_file_name(entry));
- if (sp->alias)
- sp = sp->alias;
-
- if (relocatable_output) {
- relocation = addend;
- /*
- * In PIC code, we keep the reference to the
- * external symbol, even if defined now.
- */
- if (!pic_code_seen)
- relocation += sp->value;
- } else if (sp->defined) {
- if (sp->flags & GS_TRACE) {
- fprintf(stderr,
- "symbol %s defined as %x in %s\n",
- demangle(sp->name), sp->defined,
- get_file_name(entry) );
- }
- if (sp == got_symbol) {
- /* Handle _GOT_ refs */
- relocation = addend + sp->value
- + md_got_reloc(r);
- } else if (building_shared_object) {
- /*
- * Normal (non-PIC) relocation needs
- * to be converted into an RRS reloc
- * when building a shared object.
- */
- r->r_address += dataseg?
- entry->data_start_address:
- entry->text_start_address;
- relocation = addend;
- if (claim_rrs_reloc(
- entry, r, sp, &relocation))
- continue;
- } else if (sp->defined == N_SIZE) {
- /*
- * If size is known, arrange a
- * run-time copy.
- */
- if (!sp->size)
- errx(1, "Copy item isn't: %s",
- demangle(sp->name));
-
- relocation = addend + sp->value;
- r->r_address = sp->value;
- claim_rrs_cpy_reloc(entry, r, sp);
- } else
- /* Plain old relocation */
- relocation = addend + sp->value;
- } else {
- /*
- * If the symbol is undefined, we relocate it
- * in a way similar to -r case. We use an
- * RRS relocation to resolve the symbol at
- * run-time. The r_address field is updated
- * to reflect the changed position in the
- * output file.
- */
- if (sp->flags & GS_TRACE) {
- fprintf(stderr,
- "symbol %s claims RRS in %s%s\n",
- demangle(sp->name), get_file_name(entry),
- (sp->so_defined == (N_TEXT+N_EXT) &&
- sp->flags & GS_HASJMPSLOT)?
- " (JMPSLOT)":"");
- }
- if (sp->so_defined == (N_TEXT+N_EXT) &&
- sp->flags & GS_HASJMPSLOT) {
- /*
- * Claim a jmpslot if one was allocated.
- *
- * At this point, a jmpslot can only
- * result from a shared object reference
- * while `force_alias' is in effect.
- */
- relocation = addend +
- claim_rrs_jmpslot(
- entry, r, sp, addend);
- } else {
- r->r_address += dataseg?
- entry->data_start_address:
- entry->text_start_address;
- relocation = addend;
- if ((building_shared_object ||
- sp->so_defined) &&
- claim_rrs_reloc(entry, r, sp,
- &relocation))
- continue;
- }
- }
-
- } else {
-
- switch (RELOC_TYPE(r)) {
- case N_TEXT:
- case N_TEXT | N_EXT:
- relocation = addend + text_relocation;
- break;
-
- case N_DATA:
- case N_DATA | N_EXT:
- /*
- * A word that points to beginning of the the
- * data section initially contains not 0 but
- * rather the "address" of that section in
- * the input file, which is the length of the
- * file's text.
- */
- relocation = addend + data_relocation;
- break;
-
- case N_BSS:
- case N_BSS | N_EXT:
- /*
- * Similarly, an input word pointing to the
- * beginning of the bss initially contains
- * the length of text plus data of the file.
- */
- relocation = addend + bss_relocation;
- break;
-
- case N_ABS:
- case N_ABS | N_EXT:
- /*
- * Don't know why this code would occur, but
- * apparently it does.
- */
- break;
-
- default:
- errx(1, "%s: nonexternal relocation invalid",
- get_file_name(entry));
- }
-
- /*
- * When building a shared object, these segment
- * relocations need a "load address relative"
- * RRS fixup.
- */
- if (building_shared_object && !RELOC_PCREL_P(r)) {
- r->r_address += dataseg?
- entry->data_start_address:
- entry->text_start_address;
- claim_rrs_segment_reloc(entry, r);
- }
- }
-
- if (RELOC_PCREL_P(r))
- relocation -= pc_relocation;
-
- md_relocate(r, relocation, data+addr, relocatable_output);
-
- }
-}
-
-
-/*
- * For relocatable_output only: write out the relocation,
- * relocating the addresses-to-be-relocated.
- */
-void
-write_rel()
-{
- int count = 0;
-
- if (trace_files)
- fprintf(stderr, "Writing text relocation:\n\n");
-
- /*
- * Assign each global symbol a sequence number, giving the order
- * in which `write_syms' will write it.
- * This is so we can store the proper symbolnum fields
- * in relocation entries we write.
- */
-
- /* BLECH - Assign number 0 to __DYNAMIC (!! Sun compatibility) */
-
- if (dynamic_symbol->flags & GS_REFERENCED)
- dynamic_symbol->symbolnum = count++;
- FOR_EACH_SYMBOL(i, sp) {
- if (sp == dynamic_symbol)
- continue;
- if (sp->warning)
- count += 2;
- if (!(sp->flags & GS_REFERENCED))
- continue;
- sp->symbolnum = count++;
- if (sp->size)
- count++;
- if (sp->alias)
- count++;
- } END_EACH_SYMBOL;
-
- if (count != global_sym_count)
- errx(1, "internal error: write_rel: count = %d", count);
-
- each_full_file(assign_symbolnums, &count);
-
- /* Write out the relocations of all files, remembered from copy_text. */
- each_full_file(coptxtrel, 0);
-
- if (trace_files)
- fprintf(stderr, "\nWriting data relocation:\n\n");
-
- each_full_file(copdatrel, 0);
-
- if (trace_files)
- fprintf(stderr, "\n");
-}
-
-
-/*
- * Assign symbol ordinal numbers to local symbols in each entry.
- */
-static void
-assign_symbolnums(entry, countp)
- struct file_entry *entry;
- int *countp;
-{
- struct localsymbol *lsp, *lspend;
- int n = *countp;
-
- lspend = entry->symbols + entry->nsymbols;
-
- if (discard_locals != DISCARD_ALL)
- /* Count the N_FN symbol for this entry */
- n++;
-
- for (lsp = entry->symbols; lsp < lspend; lsp++) {
- if (lsp->flags & LS_WRITE)
- lsp->symbolnum = n++;
- }
- *countp = n;
-}
-
-static void
-coptxtrel(entry)
- struct file_entry *entry;
-{
- register struct relocation_info *r, *end;
- register int reloc = entry->text_start_address;
-
- r = entry->textrel;
- end = r + entry->ntextrel;
-
- for (; r < end; r++) {
- register int symindex;
- struct localsymbol *lsp;
- symbol *sp;
-
- RELOC_ADDRESS(r) += reloc;
-
- symindex = RELOC_SYMBOL(r);
- lsp = &entry->symbols[symindex];
-
- if (!RELOC_EXTERN_P(r)) {
- if (!pic_code_seen)
- continue;
- if (RELOC_BASEREL_P(r))
- RELOC_SYMBOL(r) = lsp->symbolnum;
- continue;
- }
-
- if (symindex >= entry->nsymbols)
- errx(1, "%s: relocation symbolnum out of range",
- get_file_name(entry));
-
- sp = lsp->symbol;
-
-#ifdef N_INDR
- /* Resolve indirection. */
- if ((sp->defined & ~N_EXT) == N_INDR) {
- if (sp->alias == NULL)
- errx(1, "internal error: alias in hyperspace");
- sp = sp->alias;
- }
-#endif
-
- /*
- * If the symbol is now defined, change the external
- * relocation to an internal one.
- */
-
- if (sp->defined) {
- if (!pic_code_seen) {
- RELOC_EXTERN_P(r) = 0;
- RELOC_SYMBOL(r) = (sp->defined & N_TYPE);
- } else
- RELOC_SYMBOL(r) = sp->symbolnum;
- } else
- /*
- * Global symbols come first.
- */
- RELOC_SYMBOL(r) = sp->symbolnum;
- }
- md_swapout_reloc(entry->textrel, entry->ntextrel);
- mywrite(entry->textrel, entry->ntextrel,
- sizeof(struct relocation_info), outstream);
-}
-
-static void
-copdatrel(entry)
- struct file_entry *entry;
-{
- register struct relocation_info *r, *end;
- /*
- * Relocate the address of the relocation. Old address is relative to
- * start of the input file's data section. New address is relative to
- * start of the output file's data section.
- */
- register int reloc = entry->data_start_address - text_size;
-
- r = entry->datarel;
- end = r + entry->ndatarel;
-
- for (; r < end; r++) {
- register int symindex;
- symbol *sp;
- int symtype;
-
- RELOC_ADDRESS(r) += reloc;
-
- if (!RELOC_EXTERN_P(r)) {
- if (RELOC_BASEREL_P(r))
- errx(1, "%s: Unsupported relocation type",
- get_file_name(entry));
- continue;
- }
-
- symindex = RELOC_SYMBOL(r);
- sp = entry->symbols[symindex].symbol;
-
- if (symindex >= entry->header.a_syms)
- errx(1, "%s: relocation symbolnum out of range",
- get_file_name(entry));
-
-#ifdef N_INDR
- /* Resolve indirection. */
- if ((sp->defined & ~N_EXT) == N_INDR) {
- if (sp->alias == NULL)
- errx(1, "internal error: alias in hyperspace");
- sp = sp->alias;
- }
-#endif
-
- symtype = sp->defined & N_TYPE;
-
- if (!pic_code_seen && ( symtype == N_BSS ||
- symtype == N_DATA ||
- symtype == N_TEXT ||
- symtype == N_ABS)) {
- RELOC_EXTERN_P(r) = 0;
- RELOC_SYMBOL(r) = symtype;
- } else
- /*
- * Global symbols come first.
- */
- RELOC_SYMBOL(r) =
- entry->symbols[symindex].symbol->symbolnum;
- }
- md_swapout_reloc(entry->datarel, entry->ndatarel);
- mywrite(entry->datarel, entry->ndatarel,
- sizeof(struct relocation_info), outstream);
-}
-
-void write_file_syms __P((struct file_entry *, int *));
-void write_string_table __P((void));
-
-/* Offsets and current lengths of symbol and string tables in output file. */
-
-static int symtab_offset;
-static int symtab_len;
-
-/* Address in output file where string table starts. */
-static int strtab_offset;
-
-/* Offset within string table
- where the strings in `strtab_vector' should be written. */
-static int strtab_len;
-
-/* Total size of string table strings allocated so far,
- including strings in `strtab_vector'. */
-static int strtab_size;
-
-/* Vector whose elements are strings to be added to the string table. */
-static char **strtab_vector;
-
-/* Vector whose elements are the lengths of those strings. */
-static int *strtab_lens;
-
-/* Index in `strtab_vector' at which the next string will be stored. */
-static int strtab_index;
-
-/*
- * Add the string NAME to the output file string table. Record it in
- * `strtab_vector' to be output later. Return the index within the string
- * table that this string will have.
- */
-
-static int
-assign_string_table_index(name)
- char *name;
-{
- register int index = strtab_size;
- register int len = strlen(name) + 1;
-
- strtab_size += len;
- strtab_vector[strtab_index] = name;
- strtab_lens[strtab_index++] = len;
-
- return index;
-}
-
-/*
- * Write the contents of `strtab_vector' into the string table. This is done
- * once for each file's local&debugger symbols and once for the global
- * symbols.
- */
-void
-write_string_table()
-{
- register int i;
-
- if (fseek(outstream, strtab_offset + strtab_len, SEEK_SET) != 0)
- err(1, "write_string_table: %s: fseek", output_filename);
-
- for (i = 0; i < strtab_index; i++) {
- mywrite(strtab_vector[i], strtab_lens[i], 1, outstream);
- strtab_len += strtab_lens[i];
- }
-}
-
-/* Write the symbol table and string table of the output file. */
-
-void
-write_syms()
-{
- /* Number of symbols written so far. */
- int syms_written = 0;
- struct nlist nl;
-
- /*
- * Buffer big enough for all the global symbols. One extra struct
- * for each indirect symbol to hold the extra reference following.
- */
- struct nlist *buf = (struct nlist *)
- alloca(global_sym_count * sizeof(struct nlist));
- /* Pointer for storing into BUF. */
- register struct nlist *bufp = buf;
-
- /* Size of string table includes the bytes that store the size. */
- strtab_size = sizeof strtab_size;
-
- symtab_offset = N_SYMOFF(outheader);
- symtab_len = 0;
- strtab_offset = N_STROFF(outheader);
- strtab_len = strtab_size;
-
- if (strip_symbols == STRIP_ALL)
- return;
-
- /* First, write out the global symbols. */
-
- /*
- * Allocate two vectors that record the data to generate the string
- * table from the global symbols written so far. This must include
- * extra space for the references following indirect outputs.
- */
-
- strtab_vector = (char **)alloca((global_sym_count) * sizeof(char *));
- strtab_lens = (int *)alloca((global_sym_count) * sizeof(int));
- strtab_index = 0;
-
- /*
- * __DYNAMIC symbol *must* be first for Sun compatibility, as Sun's
- * ld.so reads the shared object's first symbol. This means that
- * (Sun's) shared libraries cannot be stripped! (We only assume
- * that __DYNAMIC is the first item in the data segment)
- *
- * If defined (ie. not relocatable_output), make it look
- * like an internal symbol.
- */
- if (dynamic_symbol->flags & GS_REFERENCED) {
- nl.n_other = 0;
- nl.n_desc = 0;
- nl.n_type = dynamic_symbol->defined;
- if (nl.n_type == N_UNDF)
- nl.n_type |= N_EXT;
- else
- nl.n_type &= ~N_EXT;
- nl.n_value = dynamic_symbol->value;
- nl.n_un.n_strx = assign_string_table_index(dynamic_symbol->name);
- *bufp++ = nl;
- syms_written++;
- }
-
- /* Scan the symbol hash table, bucket by bucket. */
-
- FOR_EACH_SYMBOL(i, sp) {
-
- if (sp == dynamic_symbol)
- /* Already dealt with above */
- continue;
-
- /*
- * Propagate N_WARNING symbols.
- */
- if ((relocatable_output || building_shared_object)
- && sp->warning) {
- nl.n_type = N_WARNING;
- nl.n_un.n_strx = assign_string_table_index(sp->warning);
- nl.n_value = 0;
- nl.n_other = 0;
- nl.n_desc = 0;
- *bufp++ = nl;
- syms_written++;
-
- nl.n_type = N_UNDF + N_EXT;
- nl.n_un.n_strx = assign_string_table_index(sp->name);
- nl.n_value = 0;
- nl.n_other = 0;
- nl.n_desc = 0;
- *bufp++ = nl;
- syms_written++;
- }
-
- if (!(sp->flags & GS_REFERENCED))
- /* Came from shared object but was not used */
- continue;
-
- if (sp->so_defined || (sp->alias && sp->alias->so_defined))
- /*
- * Definition came from shared object,
- * don't mention it here
- */
- continue;
-
- if (!sp->defined && !relocatable_output) {
- /*
- * We're building a shared object and there
- * are still undefined symbols. Don't output
- * these, symbol was discounted in digest_pass1()
- * (they are in the RRS symbol table).
- */
- if (building_shared_object)
- continue;
- if (!(sp->flags & GS_WEAK))
- warnx("symbol %s remains undefined", demangle(sp->name));
- }
-
- if (syms_written >= global_sym_count)
- errx(1,
- "internal error: number of symbols exceeds alloc'd %d",
- global_sym_count);
-
- /*
- * Construct a `struct nlist' for the symbol.
- */
- nl.n_other = 0;
- nl.n_desc = 0;
-
- if (sp->defined > 1) {
- /*
- * defined with known type
- */
- if (!relocatable_output && !building_shared_object &&
- sp->alias && sp->alias->defined > 1) {
- /*
- * If the target of an indirect symbol has
- * been defined and we are outputting an
- * executable, resolve the indirection; it's
- * no longer needed.
- */
- nl.n_type = sp->alias->defined;
- nl.n_value = sp->alias->value;
- nl.n_other = N_OTHER(0, sp->alias->aux);
- } else {
- int bind = 0;
-
- if (sp->defined == N_SIZE)
- nl.n_type = N_DATA | N_EXT;
- else
- nl.n_type = sp->defined;
- if (nl.n_type == (N_INDR|N_EXT) &&
- sp->value != 0)
- errx(1, "%s: N_INDR has value %#x",
- demangle(sp->name), sp->value);
- nl.n_value = sp->value;
- if (sp->def_lsp)
- bind = N_BIND(&sp->def_lsp->nzlist.nlist);
- nl.n_other = N_OTHER(bind, sp->aux);
- }
-
- } else if (sp->common_size) {
- /*
- * defined as common but not allocated,
- * happens only with -r and not -d, write out
- * a common definition.
- *
- * common condition needs to be before undefined
- * condition because unallocated commons are set
- * undefined in digest_symbols.
- */
- nl.n_type = N_UNDF | N_EXT;
- nl.n_value = sp->common_size;
- } else if (!sp->defined) {
- /* undefined -- legit only if -r */
- nl.n_type = N_UNDF | N_EXT;
- nl.n_value = 0;
- } else
- errx(1,
- "internal error: %s defined in mysterious way",
- demangle(sp->name));
-
- /*
- * Allocate string table space for the symbol name.
- */
-
- nl.n_un.n_strx = assign_string_table_index(sp->name);
-
- /* Output to the buffer and count it. */
-
- *bufp++ = nl;
- syms_written++;
-
- /*
- * Write second symbol of an alias pair.
- */
- if (nl.n_type == N_INDR + N_EXT) {
- if (sp->alias == NULL)
- errx(1, "internal error: alias in hyperspace");
- nl.n_type = N_UNDF + N_EXT;
- nl.n_un.n_strx =
- assign_string_table_index(sp->alias->name);
- nl.n_value = 0;
- nl.n_other = 0;
- nl.n_desc = 0;
- *bufp++ = nl;
- syms_written++;
- }
-
- /*
- * Write N_SIZE symbol for a symbol with a known size.
- */
- if (relocatable_output && sp->size) {
- nl.n_type = N_SIZE + N_EXT;
- nl.n_un.n_strx = assign_string_table_index(sp->name);
- nl.n_value = sp->size;
- nl.n_other = 0;
- nl.n_desc = 0;
- *bufp++ = nl;
- syms_written++;
- }
-
-#ifdef DEBUG
-printf("writesym(#%d): %s, type %x\n", syms_written, demangle(sp->name), sp->defined);
-#endif
- } END_EACH_SYMBOL;
-
- if (syms_written != strtab_index || strtab_index != global_sym_count)
- errx(1, "internal error: wrong number (%d) of global symbols "
- "written into output file, should be %d",
- syms_written, global_sym_count);
-
- /* Output the buffer full of `struct nlist's. */
-
- if (fseek(outstream, symtab_offset + symtab_len, SEEK_SET) != 0)
- err(1, "write_syms: fseek");
- md_swapout_symbols(buf, bufp - buf);
- mywrite(buf, bufp - buf, sizeof(struct nlist), outstream);
- symtab_len += sizeof(struct nlist) * (bufp - buf);
-
- /* Write the strings for the global symbols. */
- write_string_table();
-
- /* Write the local symbols defined by the various files. */
- each_file(write_file_syms, (void *)&syms_written);
- file_close();
-
- if (syms_written != nsyms)
- errx(1, "internal error: wrong number of symbols (%d) "
- "written into output file, should be %d",
- syms_written, nsyms);
-
- if (symtab_offset + symtab_len != strtab_offset)
- errx(1,
- "internal error: inconsistent symbol table length: %d vs %s",
- symtab_offset + symtab_len, strtab_offset);
-
- if (fseek(outstream, strtab_offset, SEEK_SET) != 0)
- err(1, "write_syms: fseek");
- strtab_size = md_swap_long(strtab_size);
- mywrite(&strtab_size, sizeof(int), 1, outstream);
-}
-
-
-/*
- * Write the local and debugger symbols of file ENTRY. Increment
- * *SYMS_WRITTEN_ADDR for each symbol that is written.
- */
-
-/*
- * Note that we do not combine identical names of local symbols. dbx or gdb
- * would be confused if we did that.
- */
-void
-write_file_syms(entry, syms_written_addr)
- struct file_entry *entry;
- int *syms_written_addr;
-{
- struct localsymbol *lsp, *lspend;
-
- /* Upper bound on number of syms to be written here. */
- int max_syms = entry->nsymbols + 1;
-
- /*
- * Buffer to accumulate all the syms before writing them. It has one
- * extra slot for the local symbol we generate here.
- */
- struct nlist *buf = (struct nlist *)
- alloca(max_syms * sizeof(struct nlist));
-
- register struct nlist *bufp = buf;
-
- if (entry->flags & E_DYNAMIC)
- return;
-
- /*
- * Make tables that record, for each symbol, its name and its name's
- * length. The elements are filled in by `assign_string_table_index'.
- */
-
- strtab_vector = (char **)alloca(max_syms * sizeof(char *));
- strtab_lens = (int *)alloca(max_syms * sizeof(int));
- strtab_index = 0;
-
- /* Generate a local symbol for the start of this file's text. */
-
- if (discard_locals != DISCARD_ALL) {
- struct nlist nl;
-
- nl.n_type = N_FN | N_EXT;
- nl.n_un.n_strx =
- assign_string_table_index(entry->local_sym_name);
- nl.n_value = entry->text_start_address;
- nl.n_desc = 0;
- nl.n_other = 0;
- *bufp++ = nl;
- (*syms_written_addr)++;
- }
- /* Read the file's string table. */
-
- entry->strings = (char *)alloca(entry->string_size);
- read_entry_strings(file_open(entry), entry);
-
- lspend = entry->symbols + entry->nsymbols;
-
- for (lsp = entry->symbols; lsp < lspend; lsp++) {
- register struct nlist *p = &lsp->nzlist.nlist;
- char *name;
-
- if (!(lsp->flags & LS_WRITE))
- continue;
-
- if (discard_locals == DISCARD_ALL ||
- (discard_locals == DISCARD_L &&
- (lsp->flags & LS_L_SYMBOL))) {
- /*
- * The user wants to discard this symbol, but it
- * is referenced by a relocation. We can still
- * save some file space by suppressing the unique
- * renaming of the symbol.
- */
- lsp->flags &= ~LS_RENAME;
- }
-
- if (p->n_un.n_strx == 0)
- name = NULL;
- else if (!(lsp->flags & LS_RENAME))
- name = p->n_un.n_strx + entry->strings;
- else {
- char *cp = p->n_un.n_strx + entry->strings;
- name = (char *)alloca(
- strlen(entry->local_sym_name) +
- strlen(cp) + 2 );
- (void)sprintf(name, "%s.%s", entry->local_sym_name, cp);
- }
-
- /*
- * If this symbol has a name, allocate space for it
- * in the output string table.
- */
-
- if (name)
- p->n_un.n_strx = assign_string_table_index(name);
-
- /* Output this symbol to the buffer and count it. */
-
- *bufp++ = *p;
- (*syms_written_addr)++;
- }
-
- /* All the symbols are now in BUF; write them. */
-
- if (fseek(outstream, symtab_offset + symtab_len, SEEK_SET) != 0)
- err(1, "write local symbols: fseek");
- md_swapout_symbols(buf, bufp - buf);
- mywrite(buf, bufp - buf, sizeof(struct nlist), outstream);
- symtab_len += sizeof(struct nlist) * (bufp - buf);
-
- /*
- * Write the string-table data for the symbols just written, using
- * the data in vectors `strtab_vector' and `strtab_lens'.
- */
-
- write_string_table();
- entry->strings = 0; /* Since it will disappear anyway. */
-}
-
-/*
- * Parse the string ARG using scanf format FORMAT, and return the result.
- * If it does not parse, report fatal error
- * generating the error message using format string ERROR and ARG as arg.
- */
-
-static int
-parse(arg, format, error)
- char *arg, *format, *error;
-{
- int x;
-
- if (1 != sscanf(arg, format, &x))
- errx(1, error, arg);
- return x;
-}
-
-/*
- * Output COUNT*ELTSIZE bytes of data at BUF to the descriptor FD.
- */
-void
-mywrite(buf, count, eltsize, fd)
- void *buf;
- int count;
- int eltsize;
- FILE *fd;
-{
-
- if (fwrite(buf, eltsize, count, fd) != count)
- err(1, "write");
-}
-
-static void
-cleanup()
-{
- struct stat statbuf;
-
- if (outstream == 0)
- return;
-
- if (fstat(fileno(outstream), &statbuf) == 0) {
- if (S_ISREG(statbuf.st_mode))
- (void)unlink(output_filename);
- }
-}
-
-/*
- * Output PADDING zero-bytes to descriptor FD.
- * PADDING may be negative; in that case, do nothing.
- */
-void
-padfile(padding, fd)
- int padding;
- FILE *fd;
-{
- register char *buf;
- if (padding <= 0)
- return;
-
- buf = (char *)alloca(padding);
- bzero(buf, padding);
- mywrite(buf, padding, 1, fd);
-}
-
-static void
-list_files()
-{
- int error, i;
-
- error = 0;
- for (i = 0; i < number_of_files; i++) {
- register struct file_entry *entry = &file_table[i];
- int fd;
-
- if (entry->flags & E_SEARCH_DIRS)
- fd = findlib(entry);
- else
- fd = open(entry->filename, O_RDONLY, 0);
- if (fd < 0)
- error = 1;
- else
- close(fd);
-
- /*
- * Print the name even if the file doesn't exist except in
- * the -lfoo case. This allows `ld -f' to work as well as
- * possible when it is used to generate dependencies before
- * the libraries exist.
- */
- if (fd >= 0 || !(entry->flags & E_SEARCH_DIRS))
- printf("%s\n", entry->filename);
- }
- exit(error);
-}
diff --git a/gnu/usr.bin/ld/ld.h b/gnu/usr.bin/ld/ld.h
deleted file mode 100644
index 6bd4098..0000000
--- a/gnu/usr.bin/ld/ld.h
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * $Id$
- */
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- */
-
-#define SUN_COMPAT
-
-#ifndef N_SIZE
-#define N_SIZE 0xc
-#endif
-
-#ifndef min
-#define min(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
-#ifndef __P
-#ifndef __STDC__
-#define __P(a) ()
-#else
-#define __P(a) a
-#endif
-#endif
-
-/* If compiled with GNU C, use the built-in alloca */
-#if defined(__GNUC__) || defined(sparc)
-#define alloca __builtin_alloca
-#endif
-
-#include "md.h"
-#include "link.h"
-
-/* Macro to control the number of undefined references printed */
-#define MAX_UREFS_PRINTED 10
-
-/* Align to power-of-two boundary */
-#define PALIGN(x,p) (((x) + (u_long)(p) - 1) & (-(u_long)(p)))
-
-/* Align to machine dependent boundary */
-#define MALIGN(x) PALIGN(x,MAX_ALIGNMENT)
-
-/* Define this to specify the default executable format. */
-#ifndef DEFAULT_MAGIC
-#ifdef __FreeBSD__
-#define DEFAULT_MAGIC QMAGIC
-extern int netzmagic;
-#else
-#define DEFAULT_MAGIC ZMAGIC
-#endif
-#endif
-
-#ifdef DEMANGLE_CPLUSPLUS
-extern char *demangle __P((char*));
-#else
-#define demangle(name) name
-#endif
-
-/*
- * Ok. Following are the relocation information macros. If your
- * system should not be able to use the default set (below), you must
- * define the following:
-
- * relocation_info: This must be typedef'd (or #define'd) to the type
- * of structure that is stored in the relocation info section of your
- * a.out files. Often this is defined in the a.out.h for your system.
- *
- * RELOC_ADDRESS (rval): Offset into the current section of the
- * <whatever> to be relocated. *Must be an lvalue*.
- *
- * RELOC_EXTERN_P (rval): Is this relocation entry based on an
- * external symbol (1), or was it fully resolved upon entering the
- * loader (0) in which case some combination of the value in memory
- * (if RELOC_MEMORY_ADD_P) and the extra (if RELOC_ADD_EXTRA) contains
- * what the value of the relocation actually was. *Must be an lvalue*.
- *
- * RELOC_TYPE (rval): If this entry was fully resolved upon
- * entering the loader, what type should it be relocated as?
- *
- * RELOC_SYMBOL (rval): If this entry was not fully resolved upon
- * entering the loader, what is the index of it's symbol in the symbol
- * table? *Must be a lvalue*.
- *
- * RELOC_MEMORY_ADD_P (rval): This should return true if the final
- * relocation value output here should be added to memory, or if the
- * section of memory described should simply be set to the relocation
- * value.
- *
- * RELOC_ADD_EXTRA (rval): (Optional) This macro, if defined, gives
- * an extra value to be added to the relocation value based on the
- * individual relocation entry. *Must be an lvalue if defined*.
- *
- * RELOC_PCREL_P (rval): True if the relocation value described is
- * pc relative.
- *
- * RELOC_VALUE_RIGHTSHIFT (rval): Number of bits right to shift the
- * final relocation value before putting it where it belongs.
- *
- * RELOC_TARGET_SIZE (rval): log to the base 2 of the number of
- * bytes of size this relocation entry describes; 1 byte == 0; 2 bytes
- * == 1; 4 bytes == 2, and etc. This is somewhat redundant (we could
- * do everything in terms of the bit operators below), but having this
- * macro could end up producing better code on machines without fancy
- * bit twiddling. Also, it's easier to understand/code big/little
- * endian distinctions with this macro.
- *
- * RELOC_TARGET_BITPOS (rval): The starting bit position within the
- * object described in RELOC_TARGET_SIZE in which the relocation value
- * will go.
- *
- * RELOC_TARGET_BITSIZE (rval): How many bits are to be replaced
- * with the bits of the relocation value. It may be assumed by the
- * code that the relocation value will fit into this many bits. This
- * may be larger than RELOC_TARGET_SIZE if such be useful.
- *
- *
- * Things I haven't implemented
- * ----------------------------
- *
- * Values for RELOC_TARGET_SIZE other than 0, 1, or 2.
- *
- * Pc relative relocation for External references.
- *
- *
- */
-
-
-/* Default macros */
-#ifndef RELOC_ADDRESS
-
-#define RELOC_ADDRESS(r) ((r)->r_address)
-#define RELOC_EXTERN_P(r) ((r)->r_extern)
-#define RELOC_TYPE(r) ((r)->r_symbolnum)
-#define RELOC_SYMBOL(r) ((r)->r_symbolnum)
-#define RELOC_MEMORY_SUB_P(r) 0
-#define RELOC_MEMORY_ADD_P(r) 1
-#undef RELOC_ADD_EXTRA
-#define RELOC_PCREL_P(r) ((r)->r_pcrel)
-#define RELOC_VALUE_RIGHTSHIFT(r) 0
-#if defined(RTLD) && defined(SUN_COMPAT)
-#define RELOC_TARGET_SIZE(r) (2) /* !!!!! Sun BUG compatible */
-#else
-#define RELOC_TARGET_SIZE(r) ((r)->r_length)
-#endif
-#define RELOC_TARGET_BITPOS(r) 0
-#define RELOC_TARGET_BITSIZE(r) 32
-
-#endif
-
-#ifdef nounderscore
-#define LPREFIX '.'
-#else
-#define LPREFIX 'L'
-#endif
-
-#ifndef TEXT_START
-#define TEXT_START(x) N_TXTADDR(x)
-#endif
-
-#ifndef DATA_START
-#define DATA_START(x) N_DATADDR(x)
-#endif
-
-/* If a this type of symbol is encountered, its name is a warning
- message to print each time the symbol referenced by the next symbol
- table entry is referenced.
-
- This feature may be used to allow backwards compatibility with
- certain functions (eg. gets) but to discourage programmers from
- their use.
-
- So if, for example, you wanted to have ld print a warning whenever
- the function "gets" was used in their C program, you would add the
- following to the assembler file in which gets is defined:
-
- .stabs "Obsolete function \"gets\" referenced",30,0,0,0
- .stabs "_gets",1,0,0,0
-
- These .stabs do not necessarily have to be in the same file as the
- gets function, they simply must exist somewhere in the compilation. */
-
-#ifndef N_WARNING
-#define N_WARNING 0x1E /* Warning message to print if symbol
- included */
-#endif /* This is input to ld */
-
-/* Special global symbol types understood by GNU LD. */
-
-/* The following type indicates the definition of a symbol as being
- an indirect reference to another symbol. The other symbol
- appears as an undefined reference, immediately following this symbol.
-
- Indirection is asymmetrical. The other symbol's value will be used
- to satisfy requests for the indirect symbol, but not vice versa.
- If the other symbol does not have a definition, libraries will
- be searched to find a definition.
-
- So, for example, the following two lines placed in an assembler
- input file would result in an object file which would direct gnu ld
- to resolve all references to symbol "foo" as references to symbol
- "bar".
-
- .stabs "_foo",11,0,0,0
- .stabs "_bar",1,0,0,0
-
- Note that (11 == (N_INDR | N_EXT)) and (1 == (N_UNDF | N_EXT)). */
-
-#ifndef N_INDR
-#define N_INDR 0xa
-#endif
-
-/* The following symbols refer to set elements. These are expected
- only in input to the loader; they should not appear in loader
- output (unless relocatable output is requested). To be recognized
- by the loader, the input symbols must have their N_EXT bit set.
- All the N_SET[ATDB] symbols with the same name form one set. The
- loader collects all of these elements at load time and outputs a
- vector for each name.
- Space (an array of 32 bit words) is allocated for the set in the
- data section, and the n_value field of each set element value is
- stored into one word of the array.
- The first word of the array is the length of the set (number of
- elements). The last word of the vector is set to zero for possible
- use by incremental loaders. The array is ordered by the linkage
- order; the first symbols which the linker encounters will be first
- in the array.
-
- In C syntax this looks like:
-
- struct set_vector {
- unsigned int length;
- unsigned int vector[length];
- unsigned int always_zero;
- };
-
- Before being placed into the array, each element is relocated
- according to its type. This allows the loader to create an array
- of pointers to objects automatically. N_SETA type symbols will not
- be relocated.
-
- The address of the set is made into an N_SETV symbol
- whose name is the same as the name of the set.
- This symbol acts like a N_DATA global symbol
- in that it can satisfy undefined external references.
-
- For the purposes of determining whether or not to load in a library
- file, set element definitions are not considered "real
- definitions"; they will not cause the loading of a library
- member.
-
- If relocatable output is requested, none of this processing is
- done. The symbols are simply relocated and passed through to the
- output file.
-
- So, for example, the following three lines of assembler code
- (whether in one file or scattered between several different ones)
- will produce a three element vector (total length is five words;
- see above), referenced by the symbol "_xyzzy", which will have the
- addresses of the routines _init1, _init2, and _init3.
-
- *NOTE*: If symbolic addresses are used in the n_value field of the
- defining .stabs, those symbols must be defined in the same file as
- that containing the .stabs.
-
- .stabs "_xyzzy",23,0,0,_init1
- .stabs "_xyzzy",23,0,0,_init2
- .stabs "_xyzzy",23,0,0,_init3
-
- Note that (23 == (N_SETT | N_EXT)). */
-
-#ifndef N_SETA
-#define N_SETA 0x14 /* Absolute set element symbol */
-#endif /* This is input to LD, in a .o file. */
-
-#ifndef N_SETT
-#define N_SETT 0x16 /* Text set element symbol */
-#endif /* This is input to LD, in a .o file. */
-
-#ifndef N_SETD
-#define N_SETD 0x18 /* Data set element symbol */
-#endif /* This is input to LD, in a .o file. */
-
-#ifndef N_SETB
-#define N_SETB 0x1A /* Bss set element symbol */
-#endif /* This is input to LD, in a .o file. */
-
-/* Macros dealing with the set element symbols defined in a.out.h */
-#define SET_ELEMENT_P(x) ((x) >= N_SETA && (x) <= (N_SETB|N_EXT))
-#define TYPE_OF_SET_ELEMENT(x) ((x) - N_SETA + N_ABS)
-
-#ifndef N_SETV
-#define N_SETV 0x1C /* Pointer to set vector in data area. */
-#endif /* This is output from LD. */
-
-
-#ifndef __GNU_STAB__
-/* Line number for the data section. This is to be used to describe
- the source location of a variable declaration. */
-#ifndef N_DSLINE
-#define N_DSLINE (N_SLINE+N_DATA-N_TEXT)
-#endif
-
-/* Line number for the bss section. This is to be used to describe
- the source location of a variable declaration. */
-#ifndef N_BSLINE
-#define N_BSLINE (N_SLINE+N_BSS-N_TEXT)
-#endif
-#endif /* not __GNU_STAB__ */
-
-
-/* Number of buckets in symbol hash table */
-#define SYMTABSIZE 1009
-
-/* # of global symbols referenced and not defined. */
-extern int undefined_global_sym_count;
-
-/* # of weak symbols referenced and not defined. */
-extern int undefined_weak_sym_count;
-
-/* # of undefined symbols referenced by shared objects */
-extern int undefined_shobj_sym_count;
-
-/* # of multiply defined symbols. */
-extern int multiple_def_count;
-
-/* # of common symbols. */
-extern int common_defined_global_count;
-
-/* # of warning symbols encountered. */
-extern int warn_sym_count;
-extern int list_warning_symbols;
-
-/*
- * Define a linked list of strings which define symbols which should be
- * treated as set elements even though they aren't. Any symbol with a prefix
- * matching one of these should be treated as a set element.
- *
- * This is to make up for deficiencies in many assemblers which aren't willing
- * to pass any stabs through to the loader which they don't understand.
- */
-struct string_list_element {
- char *str;
- struct string_list_element *next;
-};
-
-struct glosym;
-#ifndef __symbol_defined__
-#define __symbol_defined__
-typedef struct glosym symbol;
-#endif
-
-extern symbol *entry_symbol; /* the entry symbol, if any */
-extern symbol *edata_symbol; /* the symbol _edata */
-extern symbol *etext_symbol; /* the symbol _etext */
-extern symbol *end_symbol; /* the symbol _end */
-
-/*
- * Section start addresses.
- */
-extern int text_size; /* total size of text. */
-extern int text_start; /* start of text */
-extern int text_pad; /* clear space between text and data */
-extern int data_size; /* total size of data. */
-extern int data_start; /* start of data */
-extern int data_pad; /* part of bss segment within data */
-
-extern int bss_size; /* total size of bss. */
-extern int bss_start; /* start of bss */
-
-extern int text_reloc_size; /* total size of text relocation. */
-extern int data_reloc_size; /* total size of data relocation. */
-
-extern int magic; /* Output file magic. */
-extern int relocatable_output;
-
-/* Size of a page. */
-extern int page_size;
-
-extern char **search_dirs; /* Directories to search for libraries. */
-extern int n_search_dirs; /* Length of above. */
-
-extern int write_map; /* write a load map (`-M') */
-
-#include "dynamic.h"
diff --git a/gnu/usr.bin/ld/ldconfig/Makefile b/gnu/usr.bin/ld/ldconfig/Makefile
deleted file mode 100644
index d305363..0000000
--- a/gnu/usr.bin/ld/ldconfig/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# $Id: Makefile,v 1.10 1997/02/22 15:46:37 peter Exp $
-
-PROG= ldconfig
-SRCS= ldconfig.c shlib.c support.c
-LDDIR?= $(.CURDIR)/..
-CFLAGS+=-I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE)
-NOSHARED?= yes
-BINDIR= /sbin
-MAN8= ldconfig.8
-
-.PATH: $(LDDIR) $(LDDIR)/$(MACHINE)
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/ld/ldconfig/ldconfig.8 b/gnu/usr.bin/ld/ldconfig/ldconfig.8
deleted file mode 100644
index 1f79ce8..0000000
--- a/gnu/usr.bin/ld/ldconfig/ldconfig.8
+++ /dev/null
@@ -1,147 +0,0 @@
-.\"
-.\" Copyright (c) 1993 Paul Kranenburg
-.\" 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 Paul Kranenburg.
-.\" 3. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
-.\"
-.\" $Id: ldconfig.8,v 1.14 1997/08/22 04:42:12 peter Exp $
-.\"
-.Dd October 3, 1993
-.Dt LDCONFIG 8
-.Os FreeBSD
-.Sh NAME
-.Nm ldconfig
-.Nd configure the shared library cache
-.Sh SYNOPSIS
-.Nm ldconfig
-.Op Fl Rmrsv
-.Op Fl f Ar hints_file
-.Op Ar directory | file Ar ...
-.Sh DESCRIPTION
-.Nm
-is used to prepare a set of
-.Dq hints
-for use by the run-time linker
-.Xr ld.so 1
-to facilitate quick lookup of shared libraries available in multiple
-directories. It scans a set of built-in system directories and any
-.Ar directories
-specified on the command line (in the given order) looking for shared
-libraries and stores the results in the file
-.Pa /var/run/ld.so.hints
-to forestall the overhead that would otherwise result from the
-directory search operations
-.Xr ld.so 1
-would have to perform to load the required shared libraries.
-.Pp
-Files named on the command line are expected to contain directories
-to scan for shared libraries. Each directory's pathname must start on a new
-line. Blank lines and lines starting with the comment character
-.Ql \&#
-are ignored. A standard name for this file is
-.Xr /etc/ld.so.conf.
-.Pp
-The shared libraries so found will be automatically available for loading
-if needed by the program being prepared for execution. This obviates the need
-for storing search paths within the executable.
-.Pp
-The
-.Ev LD_LIBRARY_PATH
-environment variable can be used to override the use of
-directories (or the order thereof) from the cache or to specify additional
-directories where shared libraries might be found.
-.Ev LD_LIBRARY_PATH
-is a
-.Sq \:
-separated list of directory paths which are searched by
-.Xr ld.so 1
-when it needs to load a shared library. It can be viewed as the run-time
-equivalent of the
-.Fl L
-switch of
-.Xr ld 1 .
-.Pp
-.Nm Ldconfig
-is typically run as part of the boot sequence.
-.Pp
-The following options recognized by
-.Nm ldconfig:
-.Bl -tag -width indent
-.It Fl R
-Rescan the previously configured directories. This opens the previous hints
-file and fetches the directory list from the header. Any additional pathnames
-on the command line are also processed.
-.It Fl f Ar hints_file
-Read and/or update the specified hints file, instead of
-.Pa /var/run/ld.so.hints .
-This option is provided primarily for testing.
-.It Fl m
-Instead of replacing the contents of the hints file
-with those found in the directories specified,
-.Dq merge
-in new entries.
-Directories recorded in the hints file by previous runs of
-.Nm
-are also rescanned for new shared libraries.
-.It Fl r
-List the current contents of the hints file
-on the standard output. The hints file is not modified. The list of
-directories stored in the hints file is included.
-.It Fl s
-Do not scan the built-in system directory
-.Pq Dq /usr/lib
-for shared libraries.
-.It Fl v
-Switch on verbose mode.
-.Sh Security
-Special care must be taken when loading shared libraries into the address
-space of
-.Ev set-user-Id
-programs. Whenever such a program is run,
-.Nm ld.so
-will only load shared libraries from the hints
-file. In particular, the
-.Ev LD_LIBRARY_PATH
-is not used to search for libraries. Thus, the role of ldconfig is dual. In
-addition to building a set of hints for quick lookup, it also serves to
-specify the trusted collection of directories from which shared objects can
-be safely loaded. It is presumed that the set of directories specified to
-.Nm ldconfig
-are under control of the system's administrator.
-.Sh FILES
-.Bl -tag -width /var/run/ld.so.hintsxxx -compact
-.It Pa /var/run/ld.so.hints
-Default
-.Dq hints
-file.
-.Sh SEE ALSO
-.Xr ld 1 ,
-.Xr link 5
-.Sh HISTORY
-A
-.Nm
-utility first appeared in SunOS 4.0, it appeared in its current form
-in FreeBSD 1.1.
diff --git a/gnu/usr.bin/ld/ldconfig/ldconfig.c b/gnu/usr.bin/ld/ldconfig/ldconfig.c
deleted file mode 100644
index 1f54178..0000000
--- a/gnu/usr.bin/ld/ldconfig/ldconfig.c
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * Copyright (c) 1993,1995 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id: ldconfig.c,v 1.19 1997/07/11 14:45:41 jkh Exp $
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/mman.h>
-#include <sys/resource.h>
-#include <dirent.h>
-#include <errno.h>
-#include <err.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <ar.h>
-#include <ranlib.h>
-#include <a.out.h>
-#include <stab.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <machine/param.h>
-
-#include <link.h>
-#include "shlib.h"
-#include "support.h"
-
-#if DEBUG
-/* test */
-#undef _PATH_LD_HINTS
-#define _PATH_LD_HINTS "./ld.so.hints"
-#endif
-
-#undef major
-#undef minor
-
-static int verbose;
-static int nostd;
-static int justread;
-static int merge;
-static int rescan;
-static char *hints_file = _PATH_LD_HINTS;
-
-struct shlib_list {
- /* Internal list of shared libraries found */
- char *name;
- char *path;
- int dewey[MAXDEWEY];
- int ndewey;
-#define major dewey[0]
-#define minor dewey[1]
- struct shlib_list *next;
-};
-
-static struct shlib_list *shlib_head = NULL, **shlib_tail = &shlib_head;
-static char *dir_list;
-
-static void enter __P((char *, char *, char *, int *, int));
-static int dodir __P((char *, int));
-static int buildhints __P((void));
-static int readhints __P((void));
-static void listhints __P((void));
-
-int
-main(argc, argv)
-int argc;
-char *argv[];
-{
- int i, c;
- int rval = 0;
-
- while ((c = getopt(argc, argv, "Rf:mrsv")) != EOF) {
- switch (c) {
- case 'R':
- rescan = 1;
- break;
- case 'f':
- hints_file = optarg;
- break;
- case 'm':
- merge = 1;
- break;
- case 'r':
- justread = 1;
- break;
- case 's':
- nostd = 1;
- break;
- case 'v':
- verbose = 1;
- break;
- default:
- errx(1, "Usage: %s [-Rmrsv] [-f hints_file] "
- "[dir | file ...]", argv[0]);
- break;
- }
- }
-
- dir_list = strdup("");
-
- if (justread || merge || rescan) {
- if ((rval = readhints()) != 0)
- return rval;
- }
-
- if (!nostd && !merge && !rescan)
- std_search_path();
-
- /* Add any directories/files from the command line */
- if (!justread) {
- for (i = optind; i < argc; i++) {
- struct stat stbuf;
-
- if (stat(argv[i], &stbuf) == -1) {
- warn("%s", argv[i]);
- rval = -1;
- } else {
- /*
- * See if this is a directory-containing
- * file instead of a directory
- */
- if (S_ISREG(stbuf.st_mode))
- rval |= dofile(argv[i], 0);
- else
- add_search_path(argv[i]);
- }
- }
- }
-
- for (i = 0; i < n_search_dirs; i++) {
- char *cp = concat(dir_list, *dir_list?":":"", search_dirs[i]);
- free(dir_list);
- dir_list = cp;
- }
-
- if (justread) {
- listhints();
- return 0;
- }
-
- for (i = 0; i < n_search_dirs; i++)
- rval |= dodir(search_dirs[i], 1);
-
- rval |= buildhints();
-
- return rval;
-}
-
-int
-dofile(fname, silent)
-char *fname;
-int silent;
-{
- FILE *hfp;
- char buf[MAXPATHLEN];
- int rval = 0;
- char *cp, *sp;
-
- if ((hfp = fopen(fname, "r")) == NULL) {
- warn("%s", fname);
- return -1;
- }
-
- while (fgets(buf, sizeof(buf), hfp)) {
- cp = buf;
- while (isspace(*cp))
- cp++;
- if (*cp == '#' || *cp == '\0')
- continue;
- sp = cp;
- while (!isspace(*cp) && *cp != '\0')
- cp++;
-
- if (*cp != '\n') {
- *cp = '\0';
- warnx("%s: Trailing characters ignored", sp);
- }
-
- *cp = '\0';
-
- rval |= dodir(sp, silent);
- }
-
- (void)fclose(hfp);
- return rval;
-}
-
-int
-dodir(dir, silent)
-char *dir;
-int silent;
-{
- DIR *dd;
- struct dirent *dp;
- char name[MAXPATHLEN];
- int dewey[MAXDEWEY], ndewey;
-
- if ((dd = opendir(dir)) == NULL) {
- if (silent && errno == ENOENT) /* Ignore the error */
- return 0;
- warn("%s", dir);
- return -1;
- }
-
- while ((dp = readdir(dd)) != NULL) {
- register int n;
- register char *cp;
-
- /* Check for `lib' prefix */
- if (dp->d_name[0] != 'l' ||
- dp->d_name[1] != 'i' ||
- dp->d_name[2] != 'b')
- continue;
-
- /* Copy the entry minus prefix */
- (void)strcpy(name, dp->d_name + 3);
- n = strlen(name);
- if (n < 4)
- continue;
-
- /* Find ".so." in name */
- for (cp = name + n - 4; cp > name; --cp) {
- if (cp[0] == '.' &&
- cp[1] == 's' &&
- cp[2] == 'o' &&
- cp[3] == '.')
- break;
- }
- if (cp <= name)
- continue;
-
- *cp = '\0';
- if (!isdigit(*(cp+4)))
- continue;
-
- bzero((caddr_t)dewey, sizeof(dewey));
- ndewey = getdewey(dewey, cp + 4);
- enter(dir, dp->d_name, name, dewey, ndewey);
- }
-
- closedir(dd);
- return 0;
-}
-
-static void
-enter(dir, file, name, dewey, ndewey)
-char *dir, *file, *name;
-int dewey[], ndewey;
-{
- struct shlib_list *shp;
-
- for (shp = shlib_head; shp; shp = shp->next) {
- if (strcmp(name, shp->name) != 0 || major != shp->major)
- continue;
-
- /* Name matches existing entry */
- if (cmpndewey(dewey, ndewey, shp->dewey, shp->ndewey) > 0) {
-
- /* Update this entry with higher versioned lib */
- if (verbose)
- printf("Updating lib%s.%d.%d to %s/%s\n",
- shp->name, shp->major, shp->minor,
- dir, file);
-
- free(shp->name);
- shp->name = strdup(name);
- free(shp->path);
- shp->path = concat(dir, "/", file);
- bcopy(dewey, shp->dewey, sizeof(shp->dewey));
- shp->ndewey = ndewey;
- }
- break;
- }
-
- if (shp)
- /* Name exists: older version or just updated */
- return;
-
- /* Allocate new list element */
- if (verbose)
- printf("Adding %s/%s\n", dir, file);
-
- shp = (struct shlib_list *)xmalloc(sizeof *shp);
- shp->name = strdup(name);
- shp->path = concat(dir, "/", file);
- bcopy(dewey, shp->dewey, MAXDEWEY);
- shp->ndewey = ndewey;
- shp->next = NULL;
-
- *shlib_tail = shp;
- shlib_tail = &shp->next;
-}
-
-
-int
-hinthash(cp, vmajor)
-char *cp;
-int vmajor;
-{
- int k = 0;
-
- while (*cp)
- k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff;
-
- k = (((k << 1) + (k >> 14)) ^ (vmajor*257)) & 0x3fff;
-
- return k;
-}
-
-int
-buildhints()
-{
- struct hints_header hdr;
- struct hints_bucket *blist;
- struct shlib_list *shp;
- char *strtab;
- int i, n, str_index = 0;
- int strtab_sz = 0; /* Total length of strings */
- int nhints = 0; /* Total number of hints */
- int fd;
- char *tmpfile;
-
- for (shp = shlib_head; shp; shp = shp->next) {
- strtab_sz += 1 + strlen(shp->name);
- strtab_sz += 1 + strlen(shp->path);
- nhints++;
- }
-
- /* Fill hints file header */
- hdr.hh_magic = HH_MAGIC;
- hdr.hh_version = LD_HINTS_VERSION_2;
- hdr.hh_nbucket = 1 * nhints;
- n = hdr.hh_nbucket * sizeof(struct hints_bucket);
- hdr.hh_hashtab = sizeof(struct hints_header);
- hdr.hh_strtab = hdr.hh_hashtab + n;
- hdr.hh_dirlist = strtab_sz;
- strtab_sz += 1 + strlen(dir_list);
- hdr.hh_strtab_sz = strtab_sz;
- hdr.hh_ehints = hdr.hh_strtab + hdr.hh_strtab_sz;
-
- if (verbose)
- printf("Totals: entries %d, buckets %ld, string size %d\n",
- nhints, hdr.hh_nbucket, strtab_sz);
-
- /* Allocate buckets and string table */
- blist = (struct hints_bucket *)xmalloc(n);
- bzero((char *)blist, n);
- for (i = 0; i < hdr.hh_nbucket; i++)
- /* Empty all buckets */
- blist[i].hi_next = -1;
-
- strtab = (char *)xmalloc(strtab_sz);
-
- /* Enter all */
- for (shp = shlib_head; shp; shp = shp->next) {
- struct hints_bucket *bp;
-
- bp = blist +
- (hinthash(shp->name, shp->major) % hdr.hh_nbucket);
-
- if (bp->hi_pathx) {
- int i;
-
- for (i = 0; i < hdr.hh_nbucket; i++) {
- if (blist[i].hi_pathx == 0)
- break;
- }
- if (i == hdr.hh_nbucket) {
- warnx("Bummer!");
- return -1;
- }
- while (bp->hi_next != -1)
- bp = &blist[bp->hi_next];
- bp->hi_next = i;
- bp = blist + i;
- }
-
- /* Insert strings in string table */
- bp->hi_namex = str_index;
- strcpy(strtab + str_index, shp->name);
- str_index += 1 + strlen(shp->name);
-
- bp->hi_pathx = str_index;
- strcpy(strtab + str_index, shp->path);
- str_index += 1 + strlen(shp->path);
-
- /* Copy versions */
- bcopy(shp->dewey, bp->hi_dewey, sizeof(bp->hi_dewey));
- bp->hi_ndewey = shp->ndewey;
- }
-
- /* Copy search directories */
- strcpy(strtab + str_index, dir_list);
- str_index += 1 + strlen(dir_list);
-
- /* Sanity check */
- if (str_index != strtab_sz) {
- errx(1, "str_index(%d) != strtab_sz(%d)", str_index, strtab_sz);
- }
-
- tmpfile = concat(hints_file, ".XXXXXX", "");
- if ((tmpfile = mktemp(tmpfile)) == NULL) {
- warn("%s", tmpfile);
- return -1;
- }
-
- umask(0); /* Create with exact permissions */
- if ((fd = open(tmpfile, O_RDWR|O_CREAT|O_TRUNC, 0444)) == -1) {
- warn("%s", hints_file);
- return -1;
- }
-
- if (write(fd, &hdr, sizeof(struct hints_header)) !=
- sizeof(struct hints_header)) {
- warn("%s", hints_file);
- return -1;
- }
- if (write(fd, blist, hdr.hh_nbucket * sizeof(struct hints_bucket)) !=
- hdr.hh_nbucket * sizeof(struct hints_bucket)) {
- warn("%s", hints_file);
- return -1;
- }
- if (write(fd, strtab, strtab_sz) != strtab_sz) {
- warn("%s", hints_file);
- return -1;
- }
- if (close(fd) != 0) {
- warn("%s", hints_file);
- return -1;
- }
-
- /* Install it */
- if (unlink(hints_file) != 0 && errno != ENOENT) {
- warn("%s", hints_file);
- return -1;
- }
-
- if (rename(tmpfile, hints_file) != 0) {
- warn("%s", hints_file);
- return -1;
- }
-
- return 0;
-}
-
-static int
-readhints()
-{
- int fd;
- caddr_t addr;
- long msize;
- struct hints_header *hdr;
- struct hints_bucket *blist;
- char *strtab;
- struct shlib_list *shp;
- int i;
-
- if ((fd = open(hints_file, O_RDONLY, 0)) == -1) {
- warn("%s", hints_file);
- return -1;
- }
-
- msize = PAGE_SIZE;
- addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0);
-
- if (addr == (caddr_t)-1) {
- warn("%s", hints_file);
- return -1;
- }
-
- hdr = (struct hints_header *)addr;
- if (HH_BADMAG(*hdr)) {
- warnx("%s: Bad magic: %o",
- hints_file, hdr->hh_magic);
- return -1;
- }
-
- if (hdr->hh_version != LD_HINTS_VERSION_1 &&
- hdr->hh_version != LD_HINTS_VERSION_2) {
- warnx("Unsupported version: %d", hdr->hh_version);
- return -1;
- }
-
- if (hdr->hh_ehints > msize) {
- if (mmap(addr+msize, hdr->hh_ehints - msize,
- PROT_READ, MAP_COPY|MAP_FIXED,
- fd, msize) != (caddr_t)(addr+msize)) {
-
- warn("%s", hints_file);
- return -1;
- }
- }
- close(fd);
-
- blist = (struct hints_bucket *)(addr + hdr->hh_hashtab);
- strtab = (char *)(addr + hdr->hh_strtab);
-
- if (hdr->hh_version >= LD_HINTS_VERSION_2)
- add_search_path(strtab + hdr->hh_dirlist);
- else if (rescan)
- errx(1, "%s too old and does not contain the search path",
- hints_file);
-
- if (rescan)
- return 0;
-
- for (i = 0; i < hdr->hh_nbucket; i++) {
- struct hints_bucket *bp = &blist[i];
-
- /* Sanity check */
- if (bp->hi_namex >= hdr->hh_strtab_sz) {
- warnx("Bad name index: %#x", bp->hi_namex);
- return -1;
- }
- if (bp->hi_pathx >= hdr->hh_strtab_sz) {
- warnx("Bad path index: %#x", bp->hi_pathx);
- return -1;
- }
-
- /* Allocate new list element */
- shp = (struct shlib_list *)xmalloc(sizeof *shp);
- shp->name = strdup(strtab + bp->hi_namex);
- shp->path = strdup(strtab + bp->hi_pathx);
- bcopy(bp->hi_dewey, shp->dewey, sizeof(shp->dewey));
- shp->ndewey = bp->hi_ndewey;
- shp->next = NULL;
-
- *shlib_tail = shp;
- shlib_tail = &shp->next;
- }
-
- return 0;
-}
-
-static void
-listhints()
-{
- struct shlib_list *shp;
- int i;
-
- printf("%s:\n", hints_file);
- printf("\tsearch directories: %s\n", dir_list);
-
- for (i = 0, shp = shlib_head; shp; i++, shp = shp->next)
- printf("\t%d:-l%s.%d.%d => %s\n",
- i, shp->name, shp->major, shp->minor, shp->path);
-
- return;
-}
diff --git a/gnu/usr.bin/ld/ldd/Makefile b/gnu/usr.bin/ld/ldd/Makefile
deleted file mode 100644
index e52f626..0000000
--- a/gnu/usr.bin/ld/ldd/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $Id: Makefile,v 1.6 1997/02/22 15:46:40 peter Exp $
-
-PROG= ldd
-SRCS= ldd.c sods.c
-CFLAGS+= -Wall
-BINDIR= /usr/bin
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/ld/ldd/ldd.1 b/gnu/usr.bin/ld/ldd/ldd.1
deleted file mode 100644
index 4eeb5a7..0000000
--- a/gnu/usr.bin/ld/ldd/ldd.1
+++ /dev/null
@@ -1,47 +0,0 @@
-.Dd October 22, 1993
-.Dt LDD 1
-.Os FreeBSD
-.Sh NAME
-.Nm ldd
-.Nd list dynamic object dependencies
-.Sh SYNOPSIS
-.Nm ldd
-.Op Fl v
-.Op Fl f Ar format
-.Ar program ...
-.Sh DESCRIPTION
-.Nm ldd
-displays all shared objects that are needed to run the given program.
-Contrary to nm(1), the list includes
-.Dq indirect
-dependencies that are the result of needed shared objects which themselves
-depend on yet other shared objects.
-.Pp
-Zero, one or two
-.Fl f
-options may be given. The argument is a format string passed to
-.Xr rtld 1
-and allows customization of
-.Nm ldd Ns 's
-output. See
-.Xr rtld 1
-for a list of recognized conversion characters.
-.Pp
-The
-.Fl v
-option displays an verbose listing of the dynamic linking headers
-encoded in the executable. See the source code and include
-files for the definitive meaning of all the fields.
-.Sh SEE ALSO
-.Xr ld 1 ,
-.Xr ld.so 1 ,
-.Xr nm 1
-.Sh HISTORY
-A
-.Nm ldd
-utility first appeared in SunOS 4.0, it appeared in its current form
-in FreeBSD 1.1.
-.Pp
-The
-.Fl v
-support is based on code written by John Polstra <jdp@polstra.com>
diff --git a/gnu/usr.bin/ld/ldd/ldd.c b/gnu/usr.bin/ld/ldd/ldd.c
deleted file mode 100644
index d940261..0000000
--- a/gnu/usr.bin/ld/ldd/ldd.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id: ldd.c,v 1.13 1997/02/22 15:46:43 peter Exp $
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-#include <a.out.h>
-#include <err.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-extern void dump_file __P((const char *));
-extern int error_count;
-
-void
-usage()
-{
- fprintf(stderr, "usage: ldd [-v] [-f format] program ...\n");
- exit(1);
-}
-
-int
-main(argc, argv)
-int argc;
-char *argv[];
-{
- char *fmt1 = NULL, *fmt2 = NULL;
- int rval;
- int c;
- int vflag = 0;
-
- while ((c = getopt(argc, argv, "vf:")) != EOF) {
- switch (c) {
- case 'v':
- vflag++;
- break;
- case 'f':
- if (fmt1) {
- if (fmt2)
- errx(1, "Too many formats");
- fmt2 = optarg;
- } else
- fmt1 = optarg;
- break;
- default:
- usage();
- /*NOTREACHED*/
- }
- }
- argc -= optind;
- argv += optind;
-
- if (vflag && fmt1)
- errx(1, "-v may not be used with -f");
-
- if (argc <= 0) {
- usage();
- /*NOTREACHED*/
- }
-
- if (vflag) {
- for (c = 0; c < argc; c++)
- dump_file(argv[c]);
- exit(error_count == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
- }
-
- /* ld.so magic */
- setenv("LD_TRACE_LOADED_OBJECTS", "1", 1);
- if (fmt1)
- setenv("LD_TRACE_LOADED_OBJECTS_FMT1", fmt1, 1);
- if (fmt2)
- setenv("LD_TRACE_LOADED_OBJECTS_FMT2", fmt2, 1);
-
- rval = 0;
- while (argc--) {
- int fd;
- struct exec hdr;
- int status;
-
- if ((fd = open(*argv, O_RDONLY, 0)) < 0) {
- warn("%s", *argv);
- rval |= 1;
- argv++;
- continue;
- }
- if (read(fd, &hdr, sizeof hdr) != sizeof hdr
- || (N_GETFLAG(hdr) & EX_DPMASK) != EX_DYNAMIC
-#if 1 /* Compatibility */
- || hdr.a_entry < __LDPGSZ
-#endif
- ) {
-
- warnx("%s: not a dynamic executable", *argv);
- (void)close(fd);
- rval |= 1;
- argv++;
- continue;
- }
- (void)close(fd);
-
- setenv("LD_TRACE_LOADED_OBJECTS_PROGNAME", *argv, 1);
- if (fmt1 == NULL && fmt2 == NULL)
- /* Default formats */
- printf("%s:\n", *argv);
-
- fflush(stdout);
-
- switch (fork()) {
- case -1:
- err(1, "fork");
- break;
- default:
- if (wait(&status) <= 0) {
- warn("wait");
- rval |= 1;
- } else if (WIFSIGNALED(status)) {
- fprintf(stderr, "%s: signal %d\n",
- *argv, WTERMSIG(status));
- rval |= 1;
- } else if (WIFEXITED(status) && WEXITSTATUS(status)) {
- fprintf(stderr, "%s: exit status %d\n",
- *argv, WEXITSTATUS(status));
- rval |= 1;
- }
- break;
- case 0:
- rval |= execl(*argv, *argv, NULL) != 0;
- perror(*argv);
- _exit(1);
- }
- argv++;
- }
-
- return rval;
-}
diff --git a/gnu/usr.bin/ld/ldd/sods.c b/gnu/usr.bin/ld/ldd/sods.c
deleted file mode 100644
index 3e28746..0000000
--- a/gnu/usr.bin/ld/ldd/sods.c
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
- * Copyright (C) 1996-1997 John D. Polstra. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN D. POLSTRA 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 JOHN D. POLSTRA 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.
- *
- * $Id: sods.c,v 1.5 1997/09/02 21:54:39 jdp Exp $
- */
-
-#include <assert.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-
-#include <a.out.h>
-#include <link.h>
-#include <stab.h>
-
-#define PAGE_SIZE 4096 /* i386 specific */
-
-#ifndef N_SETA
-#define N_SETA 0x14 /* Absolute set element symbol */
-#endif /* This is input to LD, in a .o file. */
-
-#ifndef N_SETT
-#define N_SETT 0x16 /* Text set element symbol */
-#endif /* This is input to LD, in a .o file. */
-
-#ifndef N_SETD
-#define N_SETD 0x18 /* Data set element symbol */
-#endif /* This is input to LD, in a .o file. */
-
-#ifndef N_SETB
-#define N_SETB 0x1A /* Bss set element symbol */
-#endif /* This is input to LD, in a .o file. */
-
-#ifndef N_SETV
-#define N_SETV 0x1C /* Pointer to set vector in data area. */
-#endif /* This is output from LD. */
-
-#ifdef STANDALONE
-static
-#endif
-void dump_file(const char *);
-
-static void dump_rels(const char *, const struct relocation_info *,
- unsigned long, const char *(*)(unsigned long), unsigned char *);
-static void dump_segs();
-static void dump_sods();
-static void dump_sym(const struct nlist *);
-static void dump_syms();
-
-static void dump_rtsyms();
-
-static void error(const char *, ...);
-static const char *rtsym_name(unsigned long);
-static const char *sym_name(unsigned long);
-
-#ifdef STANDALONE
-static
-#endif
-int error_count;
-
-/*
- * Variables ending in _base are pointers to things in our address space,
- * i.e., in the file itself.
- *
- * Variables ending in _addr are adjusted according to where things would
- * actually appear in memory if the file were loaded.
- */
-static const char *file_base;
-static const char *text_base;
-static const char *data_base;
-static const struct relocation_info *rel_base;
-static const struct nlist *sym_base;
-static const char *str_base;
-
-static const struct relocation_info *rtrel_base;
-static const struct nzlist *rtsym_base;
-static const char *rtstr_base;
-
-static const struct exec *ex;
-static const struct _dynamic *dyn;
-static const struct section_dispatch_table *sdt;
-
-static const char *text_addr;
-static const char *data_addr;
-
-static unsigned long rel_count;
-static unsigned long sym_count;
-
-static unsigned long rtrel_count;
-static unsigned long rtsym_count;
-
-/* Dynamically allocated flags, 1 byte per symbol, to record whether each
- symbol was referenced by a relocation entry. */
-static unsigned char *sym_used;
-static unsigned char *rtsym_used;
-
-static unsigned long origin; /* What values are relocated relative to */
-
-#ifdef STANDALONE
-main(int argc, char *argv[])
-{
- int i;
-
- for (i = 1; i < argc; ++i)
- dump_file(argv[i]);
-
- return error_count == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
-}
-#endif
-
-#ifdef STANDALONE
-static
-#endif
-void
-dump_file(const char *fname)
-{
- int fd;
- struct stat sb;
- caddr_t objbase;
-
- if (stat(fname, &sb) == -1) {
- error("Cannot stat \"%s\"", fname);
- return;
- }
-
- if ((sb.st_mode & S_IFMT) != S_IFREG) {
- error("\"%s\" is not a regular file", fname);
- return;
- }
-
- if ((fd = open(fname, O_RDONLY, 0)) == -1) {
- error("Cannot open \"%s\"", fname);
- return;
- }
-
- objbase = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
- if (objbase == (caddr_t) -1) {
- error("Cannot mmap \"%s\"", fname);
- close(fd);
- return;
- }
-
- close(fd);
-
- file_base = (const char *) objbase; /* Makes address arithmetic easier */
-
- ex = (const struct exec *) file_base;
-
- printf("%s: a_midmag = 0x%lx\n", fname, ex->a_midmag);
- printf(" magic = 0x%lx = 0%lo, netmagic = 0x%lx = 0%lo\n",
- N_GETMAGIC(*ex), N_GETMAGIC(*ex),
- N_GETMAGIC_NET(*ex), N_GETMAGIC_NET(*ex));
-
- if (N_BADMAG(*ex)) {
- error("%s: Bad magic number", fname);
- munmap(objbase, sb.st_size);
- return;
- }
-
- printf(" a_text = 0x%lx\n", ex->a_text);
- printf(" a_data = 0x%lx\n", ex->a_data);
- printf(" a_bss = 0x%lx\n", ex->a_bss);
- printf(" a_syms = 0x%lx\n", ex->a_syms);
- printf(" a_entry = 0x%lx\n", ex->a_entry);
- printf(" a_trsize = 0x%lx\n", ex->a_trsize);
- printf(" a_drsize = 0x%lx\n", ex->a_drsize);
-
- text_base = file_base + N_TXTOFF(*ex);
- data_base = file_base + N_DATOFF(*ex);
- rel_base = (const struct relocation_info *) (file_base + N_RELOFF(*ex));
- sym_base = (const struct nlist *) (file_base + N_SYMOFF(*ex));
- str_base = file_base + N_STROFF(*ex);
-
- rel_count = (ex->a_trsize + ex->a_drsize) / sizeof rel_base[0];
- assert(rel_count * sizeof rel_base[0] == ex->a_trsize + ex->a_drsize);
- sym_count = ex->a_syms / sizeof sym_base[0];
- assert(sym_count * sizeof sym_base[0] == ex->a_syms);
-
- if (sym_count != 0) {
- sym_used = (unsigned char *) calloc(sym_count, sizeof(unsigned char));
- assert(sym_used != NULL);
- }
-
- printf(" Entry = 0x%lx\n", ex->a_entry);
- printf(" Text offset = %x, address = %x\n", N_TXTOFF(*ex),
- N_TXTADDR(*ex));
- printf(" Data offset = %lx, address = %lx\n", N_DATOFF(*ex),
- N_DATADDR(*ex));
-
- /*
- * In an executable program file, everything is relocated relative to
- * the assumed run-time load address, i.e., N_TXTADDR(*ex), i.e., 0x1000.
- *
- * In a shared library file, everything is relocated relative to the
- * start of the file, i.e., N_TXTOFF(*ex), i.e., 0.
- *
- * The way to tell the difference is by looking at ex->a_entry. If it
- * is >= 0x1000, then we have an executable program. Otherwise, we
- * have a shared library.
- *
- * When a program is executed, the entire file is mapped into memory,
- * including the a.out header and so forth. But it is not mapped at
- * address 0; rather it is mapped at address 0x1000. The first page
- * of the user's address space is left unmapped in order to catch null
- * pointer dereferences.
- *
- * In this program, when we map in an executable program, we have to
- * simulate the empty page by decrementing our assumed base address by
- * a pagesize.
- */
-
- text_addr = text_base;
- data_addr = data_base;
- origin = 0;
-
- if (ex->a_entry >= PAGE_SIZE) { /* Executable, not a shared library */
- /*
- * The fields in the object have already been relocated on the
- * assumption that the object will be loaded at N_TXTADDR(*ex).
- * We have to compensate for that.
- */
- text_addr -= PAGE_SIZE;
- data_addr -= PAGE_SIZE;
- origin = PAGE_SIZE;
- printf(" Program, origin = %lx\n", origin);
- } else if (N_GETFLAG(*ex) & EX_DYNAMIC)
- printf(" Shared library, origin = %lx\n", origin);
- else
- printf(" Object file, origin = %lx\n", origin);
-
- if (N_GETFLAG(*ex) & EX_DYNAMIC) {
- dyn = (const struct _dynamic *) data_base;
- printf(" Dynamic version = %d\n", dyn->d_version);
-
- sdt = (const struct section_dispatch_table *)
- (text_addr + (unsigned long) dyn->d_un.d_sdt);
-
- rtrel_base =
- (const struct relocation_info *) (text_addr + sdt->sdt_rel);
- rtrel_count = (sdt->sdt_hash - sdt->sdt_rel) / sizeof rtrel_base[0];
- assert(rtrel_count * sizeof rtrel_base[0] ==
- sdt->sdt_hash - sdt->sdt_rel);
-
- rtsym_base = (const struct nzlist *) (text_addr + sdt->sdt_nzlist);
- rtsym_count = (sdt->sdt_strings - sdt->sdt_nzlist) /
- sizeof rtsym_base[0];
- assert(rtsym_count * sizeof rtsym_base[0] ==
- sdt->sdt_strings - sdt->sdt_nzlist);
-
- if (rtsym_count != 0) {
- rtsym_used = (unsigned char *) calloc(rtsym_count,
- sizeof(unsigned char));
- assert(rtsym_used != NULL);
- }
-
- rtstr_base = text_addr + sdt->sdt_strings;
- }
-
- dump_segs();
- dump_sods();
- dump_rels("Relocations", rel_base, rel_count, sym_name, sym_used);
- dump_syms();
-
- dump_rels("Run-time relocations", rtrel_base, rtrel_count, rtsym_name,
- rtsym_used);
- dump_rtsyms();
-
- if (rtsym_used != NULL) {
- free(rtsym_used);
- rtsym_used = NULL;
- }
- if (sym_used != NULL) {
- free(sym_used);
- sym_used = NULL;
- }
- munmap(objbase, sb.st_size);
-}
-
-static void
-dump_rels(const char *label, const struct relocation_info *base,
- unsigned long count, const char *(*name)(unsigned long),
- unsigned char *sym_used_flags)
-{
- unsigned long i;
-
- printf(" %s:\n", label);
- for (i = 0; i < count; ++i) {
- const struct relocation_info *r = &base[i];
- unsigned int size;
- char contents[16];
-
- size = 1u << r->r_length;
-
- if (origin <= r->r_address
- && r->r_address < origin + ex->a_text + ex->a_data
- && 1 <= size && size <= 4) {
- /*
- * XXX - This can cause unaligned accesses. OK for the
- * i386, not so for other architectures.
- */
- switch (size) {
- case 1:
- snprintf(contents, sizeof contents, " [%02x]",
- *(unsigned char *)(text_addr + r->r_address));
- break;
- case 2:
- snprintf(contents, sizeof contents, " [%04x]",
- *(unsigned short *)(text_addr + r->r_address));
- break;
- case 4:
- snprintf(contents, sizeof contents, "[%08lx]",
- *(unsigned long *)(text_addr + r->r_address));
- break;
- }
- } else
- snprintf(contents, sizeof contents, " ");
-
- printf(" %6lu %8x/%u %s %c%c%c%c%c%c", i,
- r->r_address, size,
- contents,
- r->r_extern ? 'e' : '-',
- r->r_jmptable ? 'j' : '-',
- r->r_relative ? 'r' : '-',
- r->r_baserel ? 'b' : '-',
- r->r_pcrel ? 'p' : '-',
- r->r_copy ? 'c' : '-');
-
- if (r->r_extern || r->r_baserel || r->r_jmptable || r->r_copy) {
- printf(" %4u %s", r->r_symbolnum, name(r->r_symbolnum));
- sym_used_flags[r->r_symbolnum] = 1;
- }
-
- printf("\n");
- }
-}
-
-static void
-dump_rtsyms()
-{
- unsigned long i;
-
- printf(" Run-time symbols:\n");
- for (i = 0; i < rtsym_count; ++i) {
- printf(" %6lu%c ", i, rtsym_used[i] ? '*' : ' ');
- dump_sym(&rtsym_base[i].nlist);
- printf("/%-5ld %s\n", rtsym_base[i].nz_size, rtsym_name(i));
- }
-}
-
-static void
-dump_segs()
-{
- printf(" Text segment starts at address %lx\n", origin + N_TXTOFF(*ex));
- if (N_GETFLAG(*ex) & EX_DYNAMIC) {
- printf(" rel starts at %lx\n", sdt->sdt_rel);
- printf(" hash starts at %lx\n", sdt->sdt_hash);
- printf(" nzlist starts at %lx\n", sdt->sdt_nzlist);
- printf(" strings starts at %lx\n", sdt->sdt_strings);
- }
-
- printf(" Data segment starts at address %lx\n", origin + N_DATOFF(*ex));
- if (N_GETFLAG(*ex) & EX_DYNAMIC) {
- printf(" _dynamic starts at %lx\n", origin + N_DATOFF(*ex));
- printf(" so_debug starts at %lx\n", (unsigned long) dyn->d_debug);
- printf(" sdt starts at %lx\n", (unsigned long) dyn->d_un.d_sdt);
- printf(" got starts at %lx\n", sdt->sdt_got);
- printf(" plt starts at %lx\n", sdt->sdt_plt);
- printf(" rest of stuff starts at %lx\n",
- sdt->sdt_plt + sdt->sdt_plt_sz);
- }
-}
-
-static void
-dump_sods()
-{
- long sod_offset;
- long paths_offset;
-
- if (dyn == NULL) /* Not a shared object */
- return;
-
- sod_offset = sdt->sdt_sods;
- printf(" Shared object dependencies:\n");
- while (sod_offset != 0) {
- const struct sod *sodp = (const struct sod *) (text_addr + sod_offset);
- const char *name = (const char *) (text_addr + sodp->sod_name);
-
- if (sodp->sod_library)
- printf(" -l%-16s version %d.%d\n", name, sodp->sod_major,
- sodp->sod_minor);
- else
- printf(" %s\n", name);
- sod_offset = sodp->sod_next;
- }
- paths_offset = sdt->sdt_paths;
- printf(" Shared object additional paths:\n");
- if (paths_offset != 0) {
- char *path = (char *)(text_addr + paths_offset);
- printf(" %s\n", path);
- } else {
- printf(" (none)\n");
- }
-}
-
-static void
-dump_sym(const struct nlist *np)
-{
- char type[8];
- char aux[8];
- char weak;
- char *p;
-
- switch (np->n_type & ~N_EXT) {
- case N_UNDF: strcpy(type, "undf"); break;
- case N_ABS: strcpy(type, "abs"); break;
- case N_TEXT: strcpy(type, "text"); break;
- case N_DATA: strcpy(type, "data"); break;
- case N_BSS: strcpy(type, "bss"); break;
- case N_INDR: strcpy(type, "indr"); break;
- case N_SIZE: strcpy(type, "size"); break;
- case N_COMM: strcpy(type, "comm"); break;
- case N_SETA: strcpy(type, "seta"); break;
- case N_SETT: strcpy(type, "sett"); break;
- case N_SETD: strcpy(type, "setd"); break;
- case N_SETB: strcpy(type, "setb"); break;
- case N_SETV: strcpy(type, "setv"); break;
- case N_FN: strcpy(type, np->n_type&N_EXT ? "fn" : "warn"); break;
- case N_GSYM: strcpy(type, "gsym"); break;
- case N_FNAME: strcpy(type, "fname"); break;
- case N_FUN: strcpy(type, "fun"); break;
- case N_STSYM: strcpy(type, "stsym"); break;
- case N_LCSYM: strcpy(type, "lcsym"); break;
- case N_MAIN: strcpy(type, "main"); break;
- case N_PC: strcpy(type, "pc"); break;
- case N_RSYM: strcpy(type, "rsym"); break;
- case N_SLINE: strcpy(type, "sline"); break;
- case N_DSLINE: strcpy(type, "dsline"); break;
- case N_BSLINE: strcpy(type, "bsline"); break;
- case N_SSYM: strcpy(type, "ssym"); break;
- case N_SO: strcpy(type, "so"); break;
- case N_LSYM: strcpy(type, "lsym"); break;
- case N_BINCL: strcpy(type, "bincl"); break;
- case N_SOL: strcpy(type, "sol"); break;
- case N_PSYM: strcpy(type, "psym"); break;
- case N_EINCL: strcpy(type, "eincl"); break;
- case N_ENTRY: strcpy(type, "entry"); break;
- case N_LBRAC: strcpy(type, "lbrac"); break;
- case N_EXCL: strcpy(type, "excl"); break;
- case N_RBRAC: strcpy(type, "rbrac"); break;
- case N_BCOMM: strcpy(type, "bcomm"); break;
- case N_ECOMM: strcpy(type, "ecomm"); break;
- case N_ECOML: strcpy(type, "ecoml"); break;
- case N_LENG: strcpy(type, "leng"); break;
- default:
- snprintf(type, sizeof type, "%#02x", np->n_type);
- break;
- }
-
- if (np->n_type & N_EXT && type[0] != '0')
- for (p = type; *p != '\0'; ++p)
- *p = toupper(*p);
-
- switch (N_AUX(np)) {
- case 0: strcpy(aux, ""); break;
- case AUX_OBJECT: strcpy(aux, "objt"); break;
- case AUX_FUNC: strcpy(aux, "func"); break;
- default: snprintf(aux, sizeof aux, "%#01x", N_AUX(np)); break;
- }
-
- weak = N_BIND(np) == BIND_WEAK ? 'w' : ' ';
-
- printf("%c%-6s %-4s %8lx", weak, type, aux, np->n_value);
-}
-
-static void
-dump_syms()
-{
- unsigned long i;
-
- printf(" Symbols:\n");
- for (i = 0; i < sym_count; ++i) {
- printf(" %6lu%c ", i, sym_used[i] ? '*' : ' ');
- dump_sym(&sym_base[i]);
- printf(" %s\n", sym_name(i));
- }
-}
-
-static void
-error(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
- putc('\n', stderr);
-
- ++error_count;
-}
-
-static const char *
-rtsym_name(unsigned long n)
-{
- assert(n < rtsym_count);
- if (rtsym_base[n].nz_strx == 0)
- return "";
- return rtstr_base + rtsym_base[n].nz_strx;
-}
-
-static const char *
-sym_name(unsigned long n)
-{
- assert(n < sym_count);
- if (sym_base[n].n_un.n_strx == 0)
- return "";
- return str_base + sym_base[n].n_un.n_strx;
-}
diff --git a/gnu/usr.bin/ld/lib.c b/gnu/usr.bin/ld/lib.c
deleted file mode 100644
index 1281933..0000000
--- a/gnu/usr.bin/ld/lib.c
+++ /dev/null
@@ -1,876 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- *
- * Modified 1993 by Paul Kranenburg, Erasmus University
- */
-
-/* Derived from ld.c: "@(#)ld.c 6.10 (Berkeley) 5/22/91"; */
-
-/* Linker `ld' for GNU
- Copyright (C) 1988 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- 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. */
-
-/* Written by Richard Stallman with some help from Eric Albert.
- Set, indirect, and warning symbol features added by Randy Smith. */
-
-/*
- * $Id$ - library routines
- */
-
-#include <sys/param.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <err.h>
-#include <fcntl.h>
-#include <ar.h>
-#include <ranlib.h>
-#include <a.out.h>
-#include <stab.h>
-#include <string.h>
-#include <dirent.h>
-#include <ctype.h>
-
-#include "ld.h"
-#include "dynamic.h"
-
-static void linear_library __P((int, struct file_entry *));
-static void symdef_library __P((int, struct file_entry *, int));
-static struct file_entry *decode_library_subfile __P((int,
- struct file_entry *,
- int, int *));
-
-/*
- * Search the library ENTRY, already open on descriptor FD. This means
- * deciding which library members to load, making a chain of `struct
- * file_entry' for those members, and entering their global symbols in the
- * hash table.
- */
-
-void
-search_library(fd, entry)
- int fd;
- struct file_entry *entry;
-{
- int member_length;
- register char *name;
- register struct file_entry *subentry;
-
- if (!(link_mode & FORCEARCHIVE) && !undefined_global_sym_count)
- return;
-
- /* Examine its first member, which starts SARMAG bytes in. */
- subentry = decode_library_subfile(fd, entry, SARMAG, &member_length);
- if (!subentry)
- return;
-
- name = subentry->filename;
- free(subentry);
-
- /* Search via __.SYMDEF if that exists, else linearly. */
-
- if (!strcmp(name, "__.SYMDEF"))
- symdef_library(fd, entry, member_length);
- else
- linear_library(fd, entry);
-}
-
-/*
- * Construct and return a file_entry for a library member. The library's
- * file_entry is library_entry, and the library is open on FD.
- * SUBFILE_OFFSET is the byte index in the library of this member's header.
- * We store the length of the member into *LENGTH_LOC.
- */
-
-static struct file_entry *
-decode_library_subfile(fd, library_entry, subfile_offset, length_loc)
- int fd;
- struct file_entry *library_entry;
- int subfile_offset;
- int *length_loc;
-{
- int bytes_read;
- register int namelen;
- int member_length, content_length;
- int starting_offset;
- register char *name;
- struct ar_hdr hdr1;
- register struct file_entry *subentry;
-
- lseek(fd, subfile_offset, 0);
-
- bytes_read = read(fd, &hdr1, sizeof hdr1);
- if (!bytes_read)
- return 0; /* end of archive */
-
- if (sizeof hdr1 != bytes_read)
- errx(1, "%s: malformed library archive",
- get_file_name(library_entry));
-
- if (sscanf(hdr1.ar_size, "%d", &member_length) != 1)
- errx(1, "%s: malformatted header of archive member: %.*s",
- get_file_name(library_entry),
- sizeof(hdr1.ar_name), hdr1.ar_name);
-
- subentry = (struct file_entry *) xmalloc(sizeof(struct file_entry));
- bzero(subentry, sizeof(struct file_entry));
-
- for (namelen = 0;
- namelen < sizeof hdr1.ar_name
- && hdr1.ar_name[namelen] != 0 && hdr1.ar_name[namelen] != ' '
- && hdr1.ar_name[namelen] != '/';
- namelen++);
-
- starting_offset = subfile_offset + sizeof hdr1;
- content_length = member_length;
-
-#ifdef AR_EFMT1
- /*
- * BSD 4.4 extended AR format: #1/<namelen>, with name as the
- * first <namelen> bytes of the file
- */
- if (strncmp(hdr1.ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 &&
- isdigit(hdr1.ar_name[sizeof(AR_EFMT1) - 1])) {
-
- namelen = atoi(&hdr1.ar_name[sizeof(AR_EFMT1) - 1]);
- name = (char *)xmalloc(namelen + 1);
- if (read(fd, name, namelen) != namelen)
- errx(1, "%s: malformatted archive member: %.*s",
- get_file_name(library_entry),
- sizeof(hdr1.ar_name), hdr1.ar_name);
- name[namelen] = 0;
- content_length -= namelen;
- starting_offset += namelen;
- } else
-
-#endif
- {
- name = (char *)xmalloc(namelen + 1);
- strncpy(name, hdr1.ar_name, namelen);
- name[namelen] = 0;
- }
-
- subentry->filename = name;
- subentry->local_sym_name = name;
- subentry->starting_offset = starting_offset;
- subentry->superfile = library_entry;
- subentry->total_size = content_length;
-#if 0
- subentry->symbols = 0;
- subentry->strings = 0;
- subentry->subfiles = 0;
- subentry->chain = 0;
- subentry->flags = 0;
-#endif
-
- (*length_loc) = member_length;
-
- return subentry;
-}
-
-static int subfile_wanted_p __P((struct file_entry *));
-
-/*
- * Search a library that has a __.SYMDEF member. FD is a descriptor on
- * which the library is open. The file pointer is assumed to point at the
- * __.SYMDEF data. ENTRY is the library's file_entry. MEMBER_LENGTH is the
- * length of the __.SYMDEF data.
- */
-
-static void
-symdef_library(fd, entry, member_length)
- int fd;
- struct file_entry *entry;
- int member_length;
-{
- int *symdef_data = (int *) xmalloc(member_length);
- register struct ranlib *symdef_base;
- char *sym_name_base;
- int nsymdefs;
- int length_of_strings;
- int not_finished;
- int bytes_read;
- register int i;
- struct file_entry *prev = 0;
- int prev_offset = 0;
-
- bytes_read = read(fd, symdef_data, member_length);
- if (bytes_read != member_length)
- errx(1, "%s: malformatted __.SYMDEF",
- get_file_name(entry));
-
- nsymdefs = md_swap_long(*symdef_data) / sizeof(struct ranlib);
- if (nsymdefs < 0 ||
- nsymdefs * sizeof(struct ranlib) + 2 * sizeof(int) > member_length)
- errx(1, "%s: malformatted __.SYMDEF",
- get_file_name(entry));
-
- symdef_base = (struct ranlib *) (symdef_data + 1);
- length_of_strings = md_swap_long(*(int *) (symdef_base + nsymdefs));
-
- if (length_of_strings < 0
- || nsymdefs * sizeof(struct ranlib) + length_of_strings
- + 2 * sizeof(int) > member_length)
- errx(1, "%s: malformatted __.SYMDEF",
- get_file_name(entry));
-
- sym_name_base = sizeof(int) + (char *) (symdef_base + nsymdefs);
-
- /* Check all the string indexes for validity. */
- md_swapin_ranlib_hdr(symdef_base, nsymdefs);
- for (i = 0; i < nsymdefs; i++) {
- register int index = symdef_base[i].ran_un.ran_strx;
- if (index < 0 || index >= length_of_strings
- || (index && *(sym_name_base + index - 1)))
- errx(1, "%s: malformatted __.SYMDEF",
- get_file_name(entry));
- }
-
- /*
- * Search the symdef data for members to load. Do this until one
- * whole pass finds nothing to load.
- */
-
- not_finished = 1;
- while (not_finished) {
-
- not_finished = 0;
-
- /*
- * Scan all the symbols mentioned in the symdef for ones that
- * we need. Load the library members that contain such
- * symbols.
- */
-
- for (i = 0; (i < nsymdefs &&
- ((link_mode & FORCEARCHIVE) ||
- undefined_global_sym_count ||
- common_defined_global_count)); i++) {
-
- register symbol *sp;
- int junk;
- register int j;
- register int offset = symdef_base[i].ran_off;
- struct file_entry *subentry;
-
-
- if (symdef_base[i].ran_un.ran_strx < 0)
- continue;
-
- sp = getsym_soft(sym_name_base
- + symdef_base[i].ran_un.ran_strx);
-
- /*
- * If we find a symbol that appears to be needed,
- * think carefully about the archive member that the
- * symbol is in.
- */
-
- /*
- * Per Mike Karels' recommendation, we no longer load
- * library files if the only reference(s) that would
- * be satisfied are 'common' references. This
- * prevents some problems with name pollution (e.g. a
- * global common 'utime' linked to a function).
- *
- * If we're not forcing the archive in then we don't
- * need to bother if: we've never heard of the symbol,
- * or if it is already defined. The last clause causes
- * archive members to be searched for definitions
- * satisfying undefined shared object symbols.
- */
- if (!(link_mode & FORCEARCHIVE) &&
- (!sp || sp->defined ||
- (!(sp->flags & GS_REFERENCED) &&
- !sp->sorefs)))
- continue;
-
- /*
- * Don't think carefully about any archive member
- * more than once in a given pass.
- */
-
- if (prev_offset == offset)
- continue;
- prev_offset = offset;
-
- /*
- * Read the symbol table of the archive member.
- */
-
- subentry = decode_library_subfile(fd,
- entry, offset, &junk);
- if (subentry == 0)
- errx(1,
- "invalid offset for %s in symbol table of %s",
- sym_name_base
- + symdef_base[i].ran_un.ran_strx,
- entry->filename);
-
- read_entry_symbols(fd, subentry);
- subentry->strings = (char *)
- alloca(subentry->string_size);
- read_entry_strings(fd, subentry);
-
- /*
- * Now scan the symbol table and decide whether to
- * load.
- */
-
- if (!(link_mode & FORCEARCHIVE) &&
- !subfile_wanted_p(subentry)) {
- if (subentry->symbols)
- free(subentry->symbols);
- free(subentry);
- } else {
- /*
- * This member is needed; load it. Since we
- * are loading something on this pass, we
- * must make another pass through the symdef
- * data.
- */
-
- not_finished = 1;
-
- read_entry_relocation(fd, subentry);
- enter_file_symbols(subentry);
-
- if (prev)
- prev->chain = subentry;
- else
- entry->subfiles = subentry;
- prev = subentry;
-
- /*
- * Clear out this member's symbols from the
- * symdef data so that following passes won't
- * waste time on them.
- */
-
- for (j = 0; j < nsymdefs; j++) {
- if (symdef_base[j].ran_off == offset)
- symdef_base[j].ran_un.ran_strx = -1;
- }
-
- /*
- * We'll read the strings again
- * if we need them.
- */
- subentry->strings = 0;
- }
- }
- }
-
- free(symdef_data);
-}
-
-/*
- * Search a library that has no __.SYMDEF. ENTRY is the library's file_entry.
- * FD is the descriptor it is open on.
- */
-
-static void
-linear_library(fd, entry)
- int fd;
- struct file_entry *entry;
-{
- register struct file_entry *prev = 0;
- register int this_subfile_offset = SARMAG;
-
- while ((link_mode & FORCEARCHIVE) ||
- undefined_global_sym_count || common_defined_global_count) {
-
- int member_length;
- register struct file_entry *subentry;
-
- subentry = decode_library_subfile(fd, entry,
- this_subfile_offset, &member_length);
-
- if (!subentry)
- return;
-
- read_entry_symbols(fd, subentry);
- subentry->strings = (char *)alloca(subentry->string_size);
- read_entry_strings(fd, subentry);
-
- if (!(link_mode & FORCEARCHIVE) &&
- !subfile_wanted_p(subentry)) {
- if (subentry->symbols)
- free(subentry->symbols);
- free(subentry);
- } else {
- read_entry_relocation(fd, subentry);
- enter_file_symbols(subentry);
-
- if (prev)
- prev->chain = subentry;
- else
- entry->subfiles = subentry;
- prev = subentry;
- subentry->strings = 0; /* Since space will dissapear
- * on return */
- }
-
- this_subfile_offset += member_length + sizeof(struct ar_hdr);
- if (this_subfile_offset & 1)
- this_subfile_offset++;
- }
-}
-
-/*
- * ENTRY is an entry for a library member. Its symbols have been read into
- * core, but not entered. Return nonzero if we ought to load this member.
- */
-
-static int
-subfile_wanted_p(entry)
- struct file_entry *entry;
-{
- struct localsymbol *lsp, *lspend;
-#ifdef DOLLAR_KLUDGE
- register int dollar_cond = 0;
-#endif
-
- lspend = entry->symbols + entry->nsymbols;
-
- for (lsp = entry->symbols; lsp < lspend; lsp++) {
- register struct nlist *p = &lsp->nzlist.nlist;
- register int type = p->n_type;
- register char *name = p->n_un.n_strx + entry->strings;
- register symbol *sp = getsym_soft(name);
-
- /*
- * If the symbol has an interesting definition, we could
- * potentially want it.
- */
- if (! (type & N_EXT)
- || (type == (N_UNDF | N_EXT) && p->n_value == 0
-
-#ifdef DOLLAR_KLUDGE
- && name[1] != '$'
-#endif
- )
-#ifdef SET_ELEMENT_P
- || SET_ELEMENT_P(type)
- || set_element_prefixed_p(name)
-#endif
- )
- continue;
-
-
-#ifdef DOLLAR_KLUDGE
- if (name[1] == '$') {
- sp = getsym_soft(&name[2]);
- dollar_cond = 1;
- if (!sp)
- continue;
- if (sp->flags & SP_REFERENCED) {
- if (write_map) {
- print_file_name(entry, stdout);
- fprintf(stdout, " needed due to $-conditional %s\n", name);
- }
- return 1;
- }
- continue;
- }
-#endif
-
- /*
- * If this symbol has not been hashed, we can't be
- * looking for it.
- */
-
- if (!sp)
- continue;
-
- /*
- * We don't load a file if it merely satisfies a
- * common reference (see explanation above in
- * symdef_library()).
- */
- if ((sp->flags & GS_REFERENCED) && !sp->defined) {
- /*
- * This is a symbol we are looking for. It
- * is either not yet defined or defined as a
- * common.
- */
-#ifdef DOLLAR_KLUDGE
- if (dollar_cond)
- continue;
-#endif
- if (type == (N_UNDF | N_EXT)) {
- /*
- * Symbol being defined as common.
- * Remember this, but don't load
- * subfile just for this.
- */
-
- /*
- * If it didn't used to be common, up
- * the count of common symbols.
- */
- if (!sp->common_size)
- common_defined_global_count++;
-
- if (sp->common_size < p->n_value)
- sp->common_size = p->n_value;
- if (!sp->defined)
- undefined_global_sym_count--;
- sp->defined = type;
- continue;
- }
- if (sp->flags & GS_WEAK)
- /* Weak symbols don't pull archive members */
- continue;
- if (write_map) {
- print_file_name(entry, stdout);
- fprintf(stdout, " needed due to %s\n", demangle(sp->name));
- }
- return 1;
- } else if (!sp->defined && sp->sorefs) {
- /*
- * Check for undefined symbols or commons
- * in shared objects.
- */
- struct localsymbol *lsp;
-
- for (lsp = sp->sorefs; lsp; lsp = lsp->next) {
- int type = lsp->nzlist.nlist.n_type;
- if ( (type & N_EXT) &&
- (type & N_STAB) == 0 &&
- type != (N_UNDF | N_EXT))
- break; /* We don't need it */
- }
- if (lsp != NULL)
- /*
- * We have a worthy definition in a shared
- * object that was specified ahead of the
- * archive we're examining now. So, punt.
- */
- continue;
-
- /*
- * At this point, we have an undefined shared
- * object reference. Again, if the archive member
- * defines a common we just note the its size.
- * Otherwise, the member gets included.
- */
-
- if (type == (N_UNDF|N_EXT) && p->n_value) {
- /*
- * New symbol is common, just takes its
- * size, but don't load.
- */
- sp->common_size = p->n_value;
- sp->defined = type;
- continue;
- }
-
- /*
- * THIS STILL MISSES the case where one shared
- * object defines a common and the next defines
- * more strongly; fix this someday by making
- * `struct glosym' and enter_global_ref() more
- * symmetric.
- */
-
- if (write_map) {
- print_file_name(entry, stdout);
- fprintf(stdout,
- " needed due to shared lib ref %s (%d)\n",
- demangle(sp->name),
- lsp ? lsp->nzlist.nlist.n_type : -1);
- }
- return 1;
- }
- }
-
- return 0;
-}
-
-/*
- * Read the symbols of dynamic entity ENTRY into core. Assume it is already
- * open, on descriptor FD.
- */
-void
-read_shared_object(fd, entry)
- struct file_entry *entry;
- int fd;
-{
- struct _dynamic dyn;
- struct section_dispatch_table sdt;
- struct nlist *np;
- struct nzlist *nzp;
- int n, i, has_nz = 0;
-
- if (!(entry->flags & E_HEADER_VALID))
- read_header(fd, entry);
-
- /* Read DYNAMIC structure (first in data segment) */
- if (lseek(fd, text_offset(entry) + entry->header.a_text, L_SET) ==
- (off_t)-1)
- err(1, "%s: lseek", get_file_name(entry));
- if (read(fd, &dyn, sizeof dyn) != sizeof dyn) {
- errx(1, "%s: premature EOF reading _dynamic",
- get_file_name(entry));
- }
- md_swapin__dynamic(&dyn);
-
- /* Check version */
- switch (dyn.d_version) {
- default:
- errx(1, "%s: unsupported _DYNAMIC version: %d",
- get_file_name(entry), dyn.d_version);
- break;
- case LD_VERSION_SUN:
- break;
- case LD_VERSION_BSD:
- has_nz = 1;
- break;
- }
-
- /* Read Section Dispatch Table (from data segment) */
- if (lseek(fd,
- text_offset(entry) + (long)dyn.d_un.d_sdt -
- (DATA_START(entry->header) - N_DATOFF(entry->header)),
- L_SET) == (off_t)-1)
- err(1, "%s: lseek", get_file_name(entry));
- if (read(fd, &sdt, sizeof sdt) != sizeof sdt)
- errx(1, "%s: premature EOF reading sdt",
- get_file_name(entry));
- md_swapin_section_dispatch_table(&sdt);
-
- /* Read symbols (text segment) */
- n = sdt.sdt_strings - sdt.sdt_nzlist;
- entry->nsymbols = n /
- (has_nz ? sizeof(struct nzlist) : sizeof(struct nlist));
- nzp = (struct nzlist *)(np = (struct nlist *)alloca (n));
- entry->symbols = (struct localsymbol *)
- xmalloc(entry->nsymbols * sizeof(struct localsymbol));
-
- if (lseek(fd,
- text_offset(entry) + (long)sdt.sdt_nzlist -
- (TEXT_START(entry->header) - N_TXTOFF(entry->header)),
- L_SET) == (off_t)-1)
- err(1, "%s: lseek", get_file_name(entry));
- if (read(fd, (char *)nzp, n) != n)
- errx(1, "%s: premature EOF reading symbols ",
- get_file_name(entry));
-
- if (has_nz)
- md_swapin_zsymbols(nzp, entry->nsymbols);
- else
- md_swapin_symbols(np, entry->nsymbols);
-
- /* Convert to structs localsymbol */
- for (i = 0; i < entry->nsymbols; i++) {
- if (has_nz) {
- entry->symbols[i].nzlist = *nzp++;
- } else {
- entry->symbols[i].nzlist.nlist = *np++;
- entry->symbols[i].nzlist.nz_size = 0;
- }
- entry->symbols[i].symbol = NULL;
- entry->symbols[i].next = NULL;
- entry->symbols[i].entry = entry;
- entry->symbols[i].gotslot_offset = -1;
- entry->symbols[i].flags = 0;
- }
-
- /* Read strings (text segment) */
- n = entry->string_size = sdt.sdt_str_sz;
- entry->strings = (char *)alloca(n);
- entry->strings_offset = text_offset(entry) + sdt.sdt_strings;
- if (lseek(fd,
- entry->strings_offset -
- (TEXT_START(entry->header) - N_TXTOFF(entry->header)),
- L_SET) == (off_t)-1)
- err(1, "%s: lseek", get_file_name(entry));
- if (read(fd, entry->strings, n) != n)
- errx(1, "%s: premature EOF reading strings",
- get_file_name(entry));
- enter_file_symbols (entry);
- entry->strings = 0;
-
- /*
- * Load any subsidiary shared objects.
- */
- if (sdt.sdt_sods) {
- struct sod sod;
- off_t offset;
- struct file_entry *prev = NULL;
-
- offset = (off_t)sdt.sdt_sods;
- while (1) {
- struct file_entry *subentry;
- char *libname, name[MAXPATHLEN]; /*XXX*/
-
- subentry = (struct file_entry *)
- xmalloc(sizeof(struct file_entry));
- bzero(subentry, sizeof(struct file_entry));
- subentry->superfile = entry;
- subentry->flags = E_SECONDCLASS;
-
- if (lseek(fd,
- offset - (TEXT_START(entry->header) -
- N_TXTOFF(entry->header)),
- L_SET) == (off_t)-1)
- err(1, "%s: lseek", get_file_name(entry));
- if (read(fd, &sod, sizeof(sod)) != sizeof(sod))
- errx(1, "%s: premature EOF reding sod",
- get_file_name(entry));
- md_swapin_sod(&sod, 1);
- if (lseek(fd,
- (off_t)sod.sod_name - (TEXT_START(entry->header) -
- N_TXTOFF(entry->header)),
- L_SET) == (off_t)-1)
- err(1, "%s: lseek", get_file_name(entry));
- (void)read(fd, name, sizeof(name)); /*XXX*/
- if (sod.sod_library) {
- int sod_major = sod.sod_major;
- int sod_minor = sod.sod_minor;
-
- libname = findshlib(name,
- &sod_major, &sod_minor, 0);
- if (libname == NULL)
- errx(1,"no shared -l%s.%d.%d available",
- name, sod.sod_major, sod.sod_minor);
- subentry->filename = libname;
- subentry->local_sym_name = concat("-l", name, "");
- } else {
- subentry->filename = strdup(name);
- subentry->local_sym_name = strdup(name);
- }
- read_file_symbols(subentry);
-
- if (prev)
- prev->chain = subentry;
- else
- entry->subfiles = subentry;
- prev = subentry;
- fd = file_open(entry);
- if ((offset = (off_t)sod.sod_next) == 0)
- break;
- }
- }
-#ifdef SUN_COMPAT
- if (link_mode & SILLYARCHIVE) {
- char *cp, *sa_name;
- char armag[SARMAG];
- int fd;
- struct file_entry *subentry;
-
- sa_name = strdup(entry->filename);
- if (sa_name == NULL)
- goto out;
- cp = sa_name + strlen(sa_name) - 1;
- while (cp > sa_name) {
- if (!isdigit(*cp) && *cp != '.')
- break;
- --cp;
- }
- if (cp <= sa_name || *cp != 'o') {
- /* Not in `libxxx.so.n.m' form */
- free(sa_name);
- goto out;
- }
-
- *cp = 'a';
- if ((fd = open(sa_name, O_RDONLY, 0)) < 0)
- goto out;
-
- /* Read archive magic */
- bzero(armag, SARMAG);
- (void)read(fd, armag, SARMAG);
- (void)close(fd);
- if (strncmp(armag, ARMAG, SARMAG) != 0) {
- warnx("%s: malformed silly archive",
- get_file_name(entry));
- goto out;
- }
-
- subentry = (struct file_entry *)
- xmalloc(sizeof(struct file_entry));
- bzero(subentry, sizeof(struct file_entry));
-
- entry->silly_archive = subentry;
- subentry->superfile = entry;
- subentry->filename = sa_name;
- subentry->local_sym_name = sa_name;
- subentry->flags |= E_IS_LIBRARY;
- search_library(file_open(subentry), subentry);
-out:
- ;
- }
-#endif
-}
-
-#undef major
-#undef minor
-
-int
-findlib(p)
-struct file_entry *p;
-{
- int i;
- int fd = -1;
- int major = -1, minor = -1;
- char *cp, *fname = NULL;
-
- if (!(p->flags & E_SEARCH_DYNAMIC))
- goto dot_a;
-
- fname = findshlib(p->filename, &major, &minor, 1);
-
- if (fname && (fd = open(fname, O_RDONLY, 0)) >= 0) {
- p->filename = fname;
- p->lib_major = major;
- p->lib_minor = minor;
- p->flags &= ~E_SEARCH_DIRS;
- return fd;
- }
- (void)free(fname);
-
-dot_a:
- p->flags &= ~E_SEARCH_DYNAMIC;
- if ( (cp = strrchr(p->filename, '/')) ) {
- *cp++ = '\0';
- fname = concat(concat(p->filename, "/lib", cp), ".a", "");
- *(--cp) = '/';
- } else
- fname = concat("lib", p->filename, ".a");
-
- for (i = 0; i < n_search_dirs; i++) {
- register char *path
- = concat(search_dirs[i], "/", fname);
- fd = open(path, O_RDONLY, 0);
- if (fd >= 0) {
- p->filename = path;
- p->flags &= ~E_SEARCH_DIRS;
- break;
- }
- (void)free(path);
- }
- (void)free(fname);
- return fd;
-}
diff --git a/gnu/usr.bin/ld/rrs.c b/gnu/usr.bin/ld/rrs.c
deleted file mode 100644
index 3502ee0..0000000
--- a/gnu/usr.bin/ld/rrs.c
+++ /dev/null
@@ -1,1272 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id: rrs.c,v 1.21 1997/04/25 15:26:12 jdp Exp $
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <err.h>
-#include <fcntl.h>
-#include <ar.h>
-#include <ranlib.h>
-#include <a.out.h>
-#include <stab.h>
-#include <string.h>
-
-#include "ld.h"
-#include "dynamic.h"
-
-static struct _dynamic rrs_dyn; /* defined in link.h */
-static struct so_debug rrs_so_debug; /* defined in link.h */
-static struct section_dispatch_table rrs_sdt; /* defined in link.h */
-static got_t *rrs_got;
-static jmpslot_t *rrs_plt; /* defined in md.h */
-static struct relocation_info *rrs_reloc;
-static struct nzlist *rrs_symbols; /* RRS symbol table */
-static char *rrs_strtab; /* RRS strings */
-static struct rrs_hash *rrs_hashtab; /* RT hash table */
-static struct shobj *rrs_shobjs;
-char *rrs_search_paths; /* `-L' RT search */
-static int rrs_search_paths_size;
-
-static int reserved_rrs_relocs;
-static int claimed_rrs_relocs;
-static int discarded_rrs_relocs;
-
-static int number_of_gotslots = 1;
-static int number_of_jmpslots = 1;
-static int number_of_rrs_hash_entries;
-static int number_of_rrs_symbols;
-static int rrs_strtab_size;
-static int rrs_symbol_size;
-
-static int current_jmpslot_offset;
-static int current_got_offset;
-static int max_got_offset;
-static int min_got_offset;
-static int got_origin;
-static int current_reloc_offset;
-static int current_hash_index;
-int number_of_shobjs;
-
-/* Convert a GOT offset into a table entry */
-#define GOTP(off) ((got_t *)((long)rrs_got + got_origin + (off)))
-
-struct shobj {
- struct shobj *next;
- struct file_entry *entry;
-};
-
-/*
-RRS text segment:
- +-------------------+ <-- sdt_rel (rrs_text_start)
- | |
- | relocation |
- | |
- +-------------------+ <-- <sdt>.sdt_hash
- | |
- | hash buckets |
- | |
- +-------------------+ <-- <sdt>.sdt_nzlist
- | |
- | symbols |
- | |
- +-------------------+ <-- <sdt>.sdt_strings
- | |
- | strings |
- | |
- +-------------------+ <-- <sdt>.sdt_sods
- | |
- | shobjs |
- | |
- +-------------------+
- | |
- | shobjs strings | <-- <shobj>.sod_name
- | |
- +-------------------+
-
-
-RRS data segment:
-
- +-------------------+ <-- __DYNAMIC (rrs_data_start)
- | |
- | _dymamic |
- | |
- +-------------------+ <-- __DYNAMIC.d_debug
- | |
- | so_debug |
- | |
- +-------------------+ <-- __DYNAMIC.d_un.d_sdt
- | |
- | sdt |
- | |
- +-------------------+ <-- sdt_got
- | |
- | _GOT_ | <-- _GLOBAL_OFFSET_TABLE_
- | | ( == sdt_got + got_origin)
- | |
- +-------------------+ <-- sdt_plt
- | |
- | PLT |
- | |
- +-------------------+
-*/
-
-/*
- * Add NAME to the list of needed run-time objects.
- * Return 1 if ENTRY was added to the list.
- */
-int
-rrs_add_shobj(entry)
- struct file_entry *entry;
-{
- struct shobj **p;
-
- for (p = &rrs_shobjs; *p != NULL; p = &(*p)->next)
- if (strcmp((*p)->entry->filename, entry->filename) == 0)
- return 0;
- *p = (struct shobj *)xmalloc(sizeof(struct shobj));
- (*p)->next = NULL;
- (*p)->entry = entry;
-
- number_of_shobjs++;
- return 1;
-}
-
-void
-alloc_rrs_reloc(entry, sp)
- struct file_entry *entry;
- symbol *sp;
-{
-#ifdef DEBUG
-printf("alloc_rrs_reloc: %s in %s\n", demangle(sp->name), get_file_name(entry));
-#endif
- reserved_rrs_relocs++;
-}
-
-void
-alloc_rrs_segment_reloc(entry, r)
- struct file_entry *entry;
- struct relocation_info *r;
-{
-#ifdef DEBUG
-printf("alloc_rrs_segment_reloc at %#x in %s\n",
- r->r_address, get_file_name(entry));
-#endif
- reserved_rrs_relocs++;
-}
-
-void
-alloc_rrs_jmpslot(entry, sp)
- struct file_entry *entry;
- symbol *sp;
-{
- if (sp->flags & GS_HASJMPSLOT)
- return;
-
- sp->flags |= GS_HASJMPSLOT;
- number_of_jmpslots++;
- reserved_rrs_relocs++;
-}
-
-void
-alloc_rrs_gotslot(entry, r, lsp)
- struct file_entry *entry;
- struct relocation_info *r;
- struct localsymbol *lsp;
-{
- symbol *sp = lsp->symbol;
-
- if (!RELOC_EXTERN_P(r)) {
-
- if (sp != NULL) {
- warnx("%s: relocation for internal symbol "
- "expected at %#x",
- get_file_name(entry), RELOC_ADDRESS(r));
- return;
- }
-
- if (!RELOC_STATICS_THROUGH_GOT_P(r))
- /* No need for a GOT slot */
- return;
-
- if (lsp->flags & LS_HASGOTSLOT)
- return;
-
- lsp->flags |= LS_HASGOTSLOT;
-
- } else {
-
- if (sp == NULL) {
- warnx("%s: relocation must refer "
- "to global symbol at %#x",
- get_file_name(entry), RELOC_ADDRESS(r));
- return;
- }
-
- if (sp->alias)
- sp = sp->alias;
-
- if (sp->flags & GS_HASGOTSLOT)
- return;
-
- sp->flags |= GS_HASGOTSLOT;
- }
-
- number_of_gotslots++;
- reserved_rrs_relocs++;
-}
-
-void
-alloc_rrs_cpy_reloc(entry, sp)
- struct file_entry *entry;
- symbol *sp;
-{
- if (sp->flags & GS_CPYRELOCRESERVED)
- return;
-#ifdef DEBUG
-printf("alloc_rrs_copy: %s in %s\n", demangle(sp->name), get_file_name(entry));
-#endif
- sp->flags |= GS_CPYRELOCRESERVED;
- reserved_rrs_relocs++;
-}
-
-static struct relocation_info *
-rrs_next_reloc()
-{
- struct relocation_info *r;
-
- r = rrs_reloc + claimed_rrs_relocs++;
- if (claimed_rrs_relocs > reserved_rrs_relocs)
- errx(1, "internal error: RRS relocs exceed allocation %d",
- reserved_rrs_relocs);
- return r;
-}
-
-/*
- * Claim a RRS relocation as a result of a regular (ie. non-PIC)
- * relocation record in a rel file.
- *
- * Return 1 if the output file needs no further updating.
- * Return 0 if the relocation value pointed to by RELOCATION must
- * written to a.out.
- */
-int
-claim_rrs_reloc(entry, rp, sp, relocation)
- struct file_entry *entry;
- struct relocation_info *rp;
- symbol *sp;
- long *relocation;
-{
- struct relocation_info *r = rrs_next_reloc();
-
- if (rp->r_address < text_start + text_size
- && (link_mode & WARNRRSTEXT))
- warnx("%s: RRS text relocation at %#x for \"%s\"",
- get_file_name(entry), rp->r_address, demangle(sp->name));
-
-#ifdef DEBUG
-printf("claim_rrs_reloc: %s in %s\n", demangle(sp->name), get_file_name(entry));
-#endif
- r->r_address = rp->r_address;
- r->r_symbolnum = sp->rrs_symbolnum;
-
- if (link_mode & SYMBOLIC) {
- if (!sp->defined)
- warnx("Cannot reduce symbol \"%s\" in %s",
- demangle(sp->name), get_file_name(entry));
- RELOC_EXTERN_P(r) = 0;
- *relocation += sp->value;
- (void) md_make_reloc(rp, r, RELTYPE_RELATIVE);
- return 0;
- } else {
- RELOC_EXTERN_P(r) = 1;
- return md_make_reloc(rp, r, RELTYPE_EXTERN);
- }
-}
-
-/*
- * Claim a jmpslot. Setup RRS relocation if claimed for the first time.
- */
-long
-claim_rrs_jmpslot(entry, rp, sp, addend)
- struct file_entry *entry;
- struct relocation_info *rp;
- symbol *sp;
- long addend;
-{
- struct relocation_info *r;
-
- if (!(sp->flags & GS_HASJMPSLOT))
- errx(1, "internal error: "
- "%s: claim_rrs_jmpslot: %s: no reservation",
- get_file_name(entry),
- demangle(sp->name));
-
- if (sp->jmpslot_offset != -1)
- return rrs_sdt.sdt_plt + sp->jmpslot_offset;
-
- sp->jmpslot_offset = current_jmpslot_offset;
- current_jmpslot_offset += sizeof(jmpslot_t);
-
-#ifdef DEBUG
-printf("claim_rrs_jmpslot: %s: %s(%d) -> offset %x\n",
- get_file_name(entry),
- demangle(sp->name), sp->rrs_symbolnum, sp->jmpslot_offset);
-#endif
-
- if ((link_mode & SYMBOLIC) || rrs_section_type == RRS_PARTIAL) {
- if (!sp->defined)
- warnx("Cannot reduce symbol \"%s\" in %s",
- demangle(sp->name), get_file_name(entry));
-
- md_fix_jmpslot( rrs_plt + sp->jmpslot_offset/sizeof(jmpslot_t),
- rrs_sdt.sdt_plt + sp->jmpslot_offset,
- sp->value);
- if (rrs_section_type == RRS_PARTIAL || !JMPSLOT_NEEDS_RELOC) {
- /* PLT is self-contained */
- discarded_rrs_relocs++;
- return rrs_sdt.sdt_plt + sp->jmpslot_offset;
- }
- } else {
- md_make_jmpslot(rrs_plt + sp->jmpslot_offset/sizeof(jmpslot_t),
- sp->jmpslot_offset,
- claimed_rrs_relocs);
- }
-
- /*
- * Install a run-time relocation for this PLT entry.
- */
- r = rrs_next_reloc();
-
- RELOC_SYMBOL(r) = sp->rrs_symbolnum;
-
- r->r_address = (long)rrs_sdt.sdt_plt + sp->jmpslot_offset;
-
- if (link_mode & SYMBOLIC) {
- RELOC_EXTERN_P(r) = 0;
- md_make_jmpreloc(rp, r, RELTYPE_RELATIVE);
- } else {
- RELOC_EXTERN_P(r) = 1;
- md_make_jmpreloc(rp, r, 0);
- }
-
- return rrs_sdt.sdt_plt + sp->jmpslot_offset;
-}
-
-/*
- * Claim GOT entry for a global symbol. If this is the first relocation
- * claiming the entry, setup a RRS relocation for it.
- * Return offset into the GOT allocated to this symbol.
- */
-long
-claim_rrs_gotslot(entry, rp, lsp, addend)
- struct file_entry *entry;
- struct relocation_info *rp;
- struct localsymbol *lsp;
- long addend;
-{
- struct relocation_info *r;
- symbol *sp = lsp->symbol;
- int reloc_type = 0;
-
- if (sp == NULL) {
- return 0;
- }
-
- if (sp->alias)
- sp = sp->alias;
-
- if (!(sp->flags & GS_HASGOTSLOT))
- errx(1, "internal error: "
- "%s: claim_rrs_gotslot: %s: no reservation",
- get_file_name(entry), demangle(sp->name));
-
- if (sp->gotslot_offset != -1) {
-#ifdef DIAGNOSTIC
- if (*GOTP(sp->gotslot_offset) != addend +
- ((!(link_mode & SHAREABLE) || (link_mode & SYMBOLIC))
- ? sp->value : 0))
- errx(1, "%s: %s: gotslot at %#x is multiple valued, "
- "*got = %#x, addend = %#x, sp->value = %#x",
- get_file_name(entry), demangle(sp->name),
- sp->gotslot_offset,
- *GOTP(sp->gotslot_offset), addend, sp->value);
-#endif
- /* This symbol already passed here before. */
- return sp->gotslot_offset;
- }
-
- if (current_got_offset == 0)
- /* GOT offset 0 is reserved */
- current_got_offset += sizeof(got_t);
-
- if (current_got_offset > max_got_offset)
- errx(1, "%s: GOT overflow on symbol `%s' at %#x",
- get_file_name(entry), demangle(sp->name), RELOC_ADDRESS(rp));
-
- sp->gotslot_offset = current_got_offset;
- current_got_offset += sizeof(got_t);
-
-#ifdef DEBUG
-printf("claim_rrs_gotslot: %s(%d,%#x) slot offset %#x, addend %#x\n",
- demangle(sp->name), sp->rrs_symbolnum, sp->value, sp->gotslot_offset, addend);
-#endif
-
- if (sp->defined &&
- (!(link_mode & SHAREABLE) || (link_mode & SYMBOLIC))) {
-
- /*
- * Reduce to just a base-relative translation.
- */
-
- *GOTP(sp->gotslot_offset) = sp->value + addend;
- reloc_type = RELTYPE_RELATIVE;
-
- } else if ((link_mode & SYMBOLIC) || rrs_section_type == RRS_PARTIAL) {
- /*
- * SYMBOLIC: all symbols must be known.
- * RRS_PARTIAL: we don't link against shared objects,
- * so again all symbols must be known.
- */
- warnx("Cannot reduce symbol \"%s\" in %s",
- demangle(sp->name), get_file_name(entry));
-
- } else {
-
- /*
- * This gotslot will be updated with symbol value at run-time.
- */
-
- *GOTP(sp->gotslot_offset) = addend;
- }
-
- if (rrs_section_type == RRS_PARTIAL) {
- /*
- * Base address is known, gotslot should be fully
- * relocated by now.
- * NOTE: RRS_PARTIAL implies !SHAREABLE.
- */
- if (!sp->defined)
- warnx("Cannot reduce symbol \"%s\" in %s",
- demangle(sp->name), get_file_name(entry));
- discarded_rrs_relocs++;
- return sp->gotslot_offset;
- }
-
- /*
- * Claim a relocation entry.
- * If symbol is defined and in "main" (!SHAREABLE)
- * we still put out a relocation as we cannot easily
- * undo the allocation.
- * `RELTYPE_RELATIVE' relocations have the external bit off
- * as no symbol need be looked up at run-time.
- */
- r = rrs_next_reloc();
- r->r_address = got_symbol->value + sp->gotslot_offset;
- RELOC_SYMBOL(r) = sp->rrs_symbolnum;
- RELOC_EXTERN_P(r) = !(reloc_type == RELTYPE_RELATIVE);
- md_make_gotreloc(rp, r, reloc_type);
-
- return sp->gotslot_offset;
-}
-
-/*
- * Claim a GOT entry for a static symbol. Return offset of the
- * allocated GOT entry. If RELOC_STATICS_THROUGH_GOT_P is in effect,
- * return the offset of the symbol with respect to the *location* of
- * the GOT.
- */
-long
-claim_rrs_internal_gotslot(entry, rp, lsp, addend)
- struct file_entry *entry;
- struct relocation_info *rp;
- struct localsymbol *lsp;
- long addend;
-{
- struct relocation_info *r;
-
- addend += lsp->nzlist.nz_value;
-
- if (!RELOC_STATICS_THROUGH_GOT_P(r))
- return addend - got_symbol->value;
-
- if (!(lsp->flags & LS_HASGOTSLOT))
- errx(1, "internal error: "
- "%s: claim_rrs_internal_gotslot at %#x: no reservation",
- get_file_name(entry), RELOC_ADDRESS(rp));
-
- if (lsp->gotslot_offset != -1) {
- /* Already claimed */
- if (*GOTP(lsp->gotslot_offset) != addend)
- errx(1, "%s: gotslot at %#x is multiple valued",
- get_file_name(entry), lsp->gotslot_offset);
- return lsp->gotslot_offset;
- }
-
- if (current_got_offset == 0)
- /* GOT offset 0 is reserved */
- current_got_offset += sizeof(got_t);
-
- if (current_got_offset > max_got_offset)
- errx(1, "%s: GOT overflow for relocation at %#x",
- get_file_name(entry), RELOC_ADDRESS(rp));
-
- lsp->gotslot_offset = current_got_offset;
- current_got_offset += sizeof(got_t);
-
- *GOTP(lsp->gotslot_offset) = addend;
-
-#ifdef DEBUG
-printf("claim_rrs_internal_gotslot: %s: slot offset %#x, addend = %#x\n",
- get_file_name(entry), lsp->gotslot_offset, addend);
-#endif
-
- if (rrs_section_type == RRS_PARTIAL) {
- discarded_rrs_relocs++;
- return lsp->gotslot_offset;
- }
-
- /*
- * Relocation entry needed for this static GOT entry.
- */
- r = rrs_next_reloc();
- r->r_address = got_symbol->value + lsp->gotslot_offset;
- RELOC_EXTERN_P(r) = 0;
- md_make_gotreloc(rp, r, RELTYPE_RELATIVE);
- return lsp->gotslot_offset;
-}
-
-void
-claim_rrs_cpy_reloc(entry, rp, sp)
- struct file_entry *entry;
- struct relocation_info *rp;
- symbol *sp;
-{
- struct relocation_info *r;
-
- if (sp->flags & GS_CPYRELOCCLAIMED)
- return;
-
- if (!(sp->flags & GS_CPYRELOCRESERVED))
- errx(1, "internal error: "
- "%s: claim_cpy_reloc: %s: no reservation",
- get_file_name(entry), demangle(sp->name));
-
-#ifdef DEBUG
-printf("claim_rrs_copy: %s: %s -> %x\n",
- get_file_name(entry), demangle(sp->name), sp->so_defined);
-#endif
-
- r = rrs_next_reloc();
- sp->flags |= GS_CPYRELOCCLAIMED;
- r->r_address = rp->r_address;
- RELOC_SYMBOL(r) = sp->rrs_symbolnum;
- RELOC_EXTERN_P(r) = RELOC_EXTERN_P(rp);
- md_make_cpyreloc(rp, r);
-}
-
-void
-claim_rrs_segment_reloc(entry, rp)
- struct file_entry *entry;
- struct relocation_info *rp;
-{
- struct relocation_info *r = rrs_next_reloc();
-
-#ifdef DEBUG
-printf("claim_rrs_segment_reloc: %s at %#x\n",
- get_file_name(entry), rp->r_address);
-#endif
-
- r->r_address = rp->r_address;
- RELOC_TYPE(r) = RELOC_TYPE(rp);
- RELOC_EXTERN_P(r) = 0;
- md_make_reloc(rp, r, RELTYPE_RELATIVE);
-
-}
-
-/*
- * Fill the RRS hash table for the given symbol name.
- * NOTE: the hash value computation must match the one in rtld.
- */
-void
-rrs_insert_hash(cp, index)
- char *cp;
- int index;
-{
- int hashval = 0;
- struct rrs_hash *hp;
-
- for (; *cp; cp++)
- hashval = (hashval << 1) + *cp;
-
- hashval = (hashval & 0x7fffffff) % rrs_sdt.sdt_buckets;
-
- /* Get to the bucket */
- hp = rrs_hashtab + hashval;
- if (hp->rh_symbolnum == -1) {
- /* Empty bucket, use it */
- hp->rh_symbolnum = index;
- hp->rh_next = 0;
- return;
- }
-
- while (hp->rh_next != 0)
- hp = rrs_hashtab + hp->rh_next;
-
- hp->rh_next = current_hash_index++;
- hp = rrs_hashtab + hp->rh_next;
- hp->rh_symbolnum = index;
- hp->rh_next = 0;
-}
-
-/*
- * There are two interesting cases to consider here.
- *
- * 1) No shared objects were loaded, but there were PIC input rel files.
- * In this case we must output a _GLOBAL_OFFSET_TABLE_ but no other
- * RRS data. Also, the entries in the GOT must be fully resolved.
- *
- * 2) It's a genuine dynamically linked program, so the whole RRS scoop
- * goes into a.out.
- */
-void
-consider_rrs_section_lengths()
-{
- int n;
- struct shobj *shp;
-
-#ifdef notyet
- struct shobj **shpp;
-/* We run into trouble with this as long as shared object symbols
- are not checked for definitions */
- /*
- * First, determine the real number of shared objects we need.
- */
- for (shpp = &rrs_shobjs; *shpp; shpp = &(*shpp)->next) {
- while (*shpp && !((*shpp)->entry->flags & E_SYMBOLS_USED)) {
- if (--number_of_shobjs < 0)
- errx(1, "internal error: number_of_shobjs < 0");
- *shpp = (*shpp)->next;
- }
- if (*shpp == NULL)
- break;
- }
-#endif
-
- /* First, determine what of the RRS we want */
- if (relocatable_output)
- rrs_section_type = RRS_NONE;
- else if (link_mode & SHAREABLE)
- rrs_section_type = RRS_FULL;
- else if (number_of_shobjs == 0 && !(link_mode & FORCEDYNAMIC)) {
- /*
- * First slots in both tables are reserved
- * hence the "> 1" condition
- */
- if (number_of_gotslots > 1 || number_of_jmpslots > 1)
- rrs_section_type = RRS_PARTIAL;
- else
- rrs_section_type = RRS_NONE;
- } else
- rrs_section_type = RRS_FULL;
-
- if (rrs_section_type == RRS_NONE) {
- got_symbol->defined = 0;
- if (reserved_rrs_relocs > 0)
- errx(1, "internal error: empty RRS has reservations");
- return;
- }
-
- rrs_symbol_size = LD_VERSION_NZLIST_P(soversion) ?
- sizeof(struct nzlist) : sizeof(struct nlist);
-
- /*
- * If there is an entry point, __DYNAMIC must be referenced (usually
- * from crt0), as this is the method used to determine whether the
- * run-time linker must be called.
- */
- if (!(link_mode & SHAREABLE) && !(dynamic_symbol->flags & GS_REFERENCED))
- errx(1, "No reference to __DYNAMIC");
-
- dynamic_symbol->flags |= GS_REFERENCED;
-
- if (number_of_gotslots > 1)
- got_symbol->flags |= GS_REFERENCED;
-
-
- /* Next, allocate relocs, got and plt */
- n = reserved_rrs_relocs * sizeof(struct relocation_info);
- rrs_reloc = (struct relocation_info *)xmalloc(n);
- bzero(rrs_reloc, n);
-
- n = number_of_gotslots * sizeof(got_t);
- rrs_got = (got_t *)xmalloc(n);
- bzero(rrs_got, n);
-
- n = number_of_jmpslots * sizeof(jmpslot_t);
- rrs_plt = (jmpslot_t *)xmalloc(n);
- bzero(rrs_plt, n);
-
- /* Initialize first jmpslot */
- md_fix_jmpslot(rrs_plt, 0, 0);
-
- if (rrs_section_type == RRS_PARTIAL) {
- rrs_data_size = number_of_gotslots * sizeof(got_t);
- rrs_data_size += number_of_jmpslots * sizeof(jmpslot_t);
- return;
- }
-
- /*
- * Walk the symbol table, assign RRS symbol numbers
- * and calculate string space.
- * Assign number 0 to __DYNAMIC (!! Sun compatibility)
- */
- dynamic_symbol->rrs_symbolnum = number_of_rrs_symbols++;
- FOR_EACH_SYMBOL(i ,sp) {
- if ((link_mode & SHAREABLE) && sp->warning) {
- /* Allocate N_WARNING & co */
- rrs_strtab_size +=
- 2 + strlen(sp->name) + strlen(sp->warning);
- number_of_rrs_symbols += 2;
- }
-
- if (!(sp->flags & GS_REFERENCED))
- continue;
-
- rrs_strtab_size += 1 + strlen(sp->name);
- if (sp != dynamic_symbol)
- sp->rrs_symbolnum = number_of_rrs_symbols++;
- if (sp->alias) {
- /*
- * (sigh) Always allocate space to hold the
- * indirection. At this point there's not
- * enough information to decide whether it's
- * actually needed or not.
- */
- number_of_rrs_symbols++;
- rrs_strtab_size += 1 + strlen(sp->alias->name);
- }
- } END_EACH_SYMBOL;
-
- /*
- * Now that we know how many RRS symbols there are going to be,
- * allocate and initialize the RRS symbol hash table.
- */
- rrs_sdt.sdt_buckets = number_of_rrs_symbols/4;
- if (rrs_sdt.sdt_buckets < 4)
- rrs_sdt.sdt_buckets = 4;
-
- number_of_rrs_hash_entries = rrs_sdt.sdt_buckets +
- number_of_rrs_symbols;
- rrs_hashtab = (struct rrs_hash *)xmalloc(
- number_of_rrs_hash_entries * sizeof(struct rrs_hash));
- for (n = 0; n < rrs_sdt.sdt_buckets; n++)
- rrs_hashtab[n].rh_symbolnum = -1;
- current_hash_index = rrs_sdt.sdt_buckets;
-
- /*
- * Get symbols into hash table now, so we can fine tune the size
- * of the latter. We adjust the value of `number_of_rrs_hash_entries'
- * to the number of hash link slots actually used.
- */
- FOR_EACH_SYMBOL(i ,sp) {
- if (sp->flags & GS_REFERENCED)
- rrs_insert_hash(sp->name, sp->rrs_symbolnum);
- } END_EACH_SYMBOL;
- number_of_rrs_hash_entries = current_hash_index;
-
- /*
- * Calculate RRS section sizes.
- */
- rrs_data_size = sizeof(struct _dynamic);
- rrs_data_size += sizeof(struct so_debug);
- rrs_data_size += sizeof(struct section_dispatch_table);
- rrs_data_size += number_of_gotslots * sizeof(got_t);
- rrs_data_size += number_of_jmpslots * sizeof(jmpslot_t);
- rrs_data_size = MALIGN(rrs_data_size);
-
- rrs_text_size = reserved_rrs_relocs * sizeof(struct relocation_info);
- rrs_text_size += number_of_rrs_hash_entries * sizeof(struct rrs_hash);
- rrs_text_size += number_of_rrs_symbols * rrs_symbol_size;
- rrs_search_paths_size = rrs_search_paths
- ? strlen(rrs_search_paths) + 1
- : 0;
- rrs_search_paths_size = MALIGN(rrs_search_paths_size);
- rrs_text_size += rrs_search_paths_size;
-
- /* Align strings size */
- rrs_strtab_size = MALIGN(rrs_strtab_size);
- rrs_text_size += rrs_strtab_size;
-
- /* Process needed shared objects */
- for (shp = rrs_shobjs; shp; shp = shp->next) {
- char *name = shp->entry->local_sym_name;
-
- if (*name == '-' && *(name+1) == 'l')
- name += 2;
-
- rrs_text_size += sizeof(struct sod);
- rrs_text_size += 1 + strlen(name);
- }
-
- /* Finally, align size */
- rrs_text_size = MALIGN(rrs_text_size);
-}
-
-void
-relocate_rrs_addresses()
-{
- int gotsize;
-
- dynamic_symbol->value = 0;
-
- /*
- * Get ready to allocate linkage table offsets.
- * First jmpslot is reserved for the run-time binder
- * GOT entry at offset 0 is reserved for `__DYNAMIC'.
- */
- current_jmpslot_offset = sizeof(jmpslot_t);
- current_got_offset = 0;
- max_got_offset = MAX_GOTOFF(pic_type);
- min_got_offset = MIN_GOTOFF(pic_type);
- gotsize = number_of_gotslots * sizeof(got_t);
-
- if (gotsize + min_got_offset - (int)sizeof(got_t) > max_got_offset)
- warnx("Global Offset Table overflow (use `-fPIC')");
-
- if (gotsize > max_got_offset)
- /* Position at "two-complements" origin */
- current_got_offset += min_got_offset;
-
- got_origin = -current_got_offset;
-
- if (rrs_section_type == RRS_NONE)
- return;
-
- if (rrs_section_type == RRS_PARTIAL) {
- rrs_sdt.sdt_got = rrs_data_start;
- got_symbol->value = rrs_sdt.sdt_got + got_origin;
- rrs_sdt.sdt_plt = rrs_sdt.sdt_got +
- number_of_gotslots * sizeof(got_t);
- return;
- }
-
- /*
- * RRS data relocations.
- */
- rrs_dyn.d_version = soversion;
- rrs_dyn.d_debug = (struct so_debug *)
- (rrs_data_start + sizeof(struct _dynamic));
- rrs_dyn.d_un.d_sdt = (struct section_dispatch_table *)
- ((long)rrs_dyn.d_debug + sizeof(struct so_debug));
-
- rrs_sdt.sdt_got = (long)rrs_dyn.d_un.d_sdt +
- sizeof(struct section_dispatch_table);
- rrs_sdt.sdt_plt = rrs_sdt.sdt_got + number_of_gotslots*sizeof(got_t);
-
- /*
- * RRS text relocations.
- */
- rrs_sdt.sdt_rel = rrs_text_start;
- /*
- * Sun BUG compatibility alert.
- * Main program's RRS text values are relative to TXTADDR? WHY??
- */
-#ifdef SUN_COMPAT
- if (soversion == LD_VERSION_SUN && !(link_mode & SHAREABLE))
- rrs_sdt.sdt_rel -= N_TXTADDR(outheader);
-#endif
-
- rrs_sdt.sdt_hash = rrs_sdt.sdt_rel +
- reserved_rrs_relocs * sizeof(struct relocation_info);
- rrs_sdt.sdt_nzlist = rrs_sdt.sdt_hash +
- number_of_rrs_hash_entries * sizeof(struct rrs_hash);
- rrs_sdt.sdt_strings = rrs_sdt.sdt_nzlist +
- number_of_rrs_symbols * rrs_symbol_size;
- rrs_sdt.sdt_paths = rrs_search_paths
- ? rrs_sdt.sdt_strings + rrs_strtab_size
- : 0;
- rrs_sdt.sdt_sods = rrs_shobjs
- ? rrs_sdt.sdt_strings + rrs_strtab_size +
- rrs_search_paths_size
- : 0;
- rrs_sdt.sdt_filler2 = 0;
- rrs_sdt.sdt_str_sz = rrs_strtab_size;
- rrs_sdt.sdt_text_sz = text_size;
- rrs_sdt.sdt_plt_sz = number_of_jmpslots * sizeof(jmpslot_t);
-
- /*
- * Assign addresses to _GLOBAL_OFFSET_TABLE_ and __DYNAMIC.
- * The value `&__DYNAMIC' is in the GOT table at offset 0.
- */
- got_symbol->value = rrs_sdt.sdt_got + got_origin;
- *GOTP(0) = dynamic_symbol->value = rrs_data_start;
-
-}
-
-void
-write_rrs_data()
-{
- long pos;
-
- if (rrs_section_type == RRS_NONE)
- return;
-
- pos = rrs_data_start + N_TXTOFF(outheader) - text_start;
- if (fseek(outstream, pos, SEEK_SET) != 0)
- err(1, "write_rrs_data: fseek");
-
- if (rrs_section_type == RRS_PARTIAL) {
- /*
- * Only a GOT and PLT are needed.
- */
- md_swapout_got(rrs_got, number_of_gotslots);
- mywrite(rrs_got, number_of_gotslots, sizeof(got_t), outstream);
-
- md_swapout_jmpslot(rrs_plt, number_of_jmpslots);
- mywrite(rrs_plt, number_of_jmpslots,
- sizeof(jmpslot_t), outstream);
-
- return;
- }
-
- md_swapout__dynamic(&rrs_dyn);
- mywrite(&rrs_dyn, 1, sizeof(struct _dynamic), outstream);
-
- md_swapout_so_debug(&rrs_so_debug);
- mywrite(&rrs_so_debug, 1, sizeof(struct so_debug), outstream);
-
- md_swapout_section_dispatch_table(&rrs_sdt);
- mywrite(&rrs_sdt, 1, sizeof(struct section_dispatch_table), outstream);
-
- md_swapout_got(rrs_got, number_of_gotslots);
- mywrite(rrs_got, number_of_gotslots, sizeof(got_t), outstream);
-
- md_swapout_jmpslot(rrs_plt, number_of_jmpslots);
- mywrite(rrs_plt, number_of_jmpslots, sizeof(jmpslot_t), outstream);
-}
-
-void
-write_rrs_text()
-{
- long pos;
- int i;
- int symsize;
- struct nzlist *nlp;
- int offset = 0;
- int aligned_offset;
- struct shobj *shp;
- struct sod *sodp;
- int bind;
-
- if (rrs_section_type == RRS_PARTIAL)
- return;
-
- pos = rrs_text_start + N_TXTOFF(outheader) - text_start;
- if (fseek(outstream, pos, SEEK_SET) != 0)
- err(1, "write_rrs_text: fseek");
-
- /* Write relocation records */
- md_swapout_reloc(rrs_reloc, reserved_rrs_relocs);
- mywrite(rrs_reloc, reserved_rrs_relocs,
- sizeof(struct relocation_info), outstream);
-
- /* Write the RRS symbol hash tables */
- md_swapout_rrs_hash(rrs_hashtab, number_of_rrs_hash_entries);
- mywrite(rrs_hashtab, number_of_rrs_hash_entries,
- sizeof(struct rrs_hash), outstream);
-
- /*
- * Determine size of an RRS symbol entry, allocate space
- * to collect them in.
- */
- symsize = number_of_rrs_symbols * rrs_symbol_size;
- nlp = rrs_symbols = (struct nzlist *)alloca(symsize);
- rrs_strtab = (char *)alloca(rrs_strtab_size);
-
-#define INCR_NLP(p) ((p) = (struct nzlist *)((long)(p) + rrs_symbol_size))
-
- /* __DYNAMIC symbol *must* be first for Sun compatibility */
- nlp->nz_desc = nlp->nz_other = 0;
- if (LD_VERSION_NZLIST_P(soversion))
- nlp->nz_size = 0;
- nlp->nz_type = dynamic_symbol->defined;
- nlp->nz_value = dynamic_symbol->value;
- nlp->nz_value = dynamic_symbol->value;
- nlp->nz_strx = offset;
- strcpy(rrs_strtab + offset, dynamic_symbol->name);
- offset += 1 + strlen(dynamic_symbol->name);
- INCR_NLP(nlp);
-
- /*
- * Now, for each global symbol, construct a nzlist element
- * for inclusion in the RRS symbol table.
- */
- FOR_EACH_SYMBOL(i, sp) {
-
- if (sp == dynamic_symbol)
- continue;
-
- if ((link_mode & SHAREABLE) && sp->warning) {
- /*
- * Write a N_WARNING duo.
- */
- nlp->nz_type = N_WARNING;
- nlp->nz_un.n_strx = offset;
- nlp->nz_value = 0;
- nlp->nz_other = 0;
- nlp->nz_desc = 0;
- nlp->nz_size = 0;
- strcpy(rrs_strtab + offset, sp->warning);
- offset += 1 + strlen(sp->warning);
- INCR_NLP(nlp);
-
- nlp->nz_type = N_UNDF + N_EXT;
- nlp->nz_un.n_strx = offset;
- nlp->nz_value = 0;
- nlp->nz_other = 0;
- nlp->nz_desc = 0;
- nlp->nz_size = 0;
- strcpy(rrs_strtab + offset, sp->name);
- offset += 1 + strlen(sp->name);
- INCR_NLP(nlp);
- }
-
- if (!(sp->flags & GS_REFERENCED))
- continue;
-
- if ((long)nlp - (long)rrs_symbols >=
- number_of_rrs_symbols * rrs_symbol_size)
- errx(1, "internal error: "
- "rrs symbols exceed allocation %d",
- number_of_rrs_symbols);
-
- nlp->nz_desc = 0;
- nlp->nz_other = 0;
- if (LD_VERSION_NZLIST_P(soversion))
- nlp->nz_size = 0;
-
- bind = (sp->flags & GS_WEAK) ? BIND_WEAK : 0;
-
- if (sp->defined > 1) {
- /* defined with known type */
- if (!(link_mode & SHAREABLE) &&
- sp->alias && sp->alias->defined > 1) {
- /*
- * If the target of an indirect symbol has
- * been defined and we are outputting an
- * executable, resolve the indirection; it's
- * no longer needed.
- */
- nlp->nz_type = sp->alias->defined;
- nlp->nz_value = sp->alias->value;
- nlp->nz_other = N_OTHER(bind, sp->alias->aux);
- } else if (sp->defined == N_SIZE) {
- /*
- * Make sure this symbol isn't going
- * to define anything.
- */
- nlp->nz_type = N_UNDF;
- nlp->nz_value = 0;
- } else {
- nlp->nz_type = sp->defined;
- nlp->nz_value = sp->value;
- nlp->nz_other = N_OTHER(bind, sp->aux);
- }
- if (LD_VERSION_NZLIST_P(soversion))
- nlp->nz_size = sp->size;
- } else if (sp->common_size) {
- /*
- * A common definition.
- */
- nlp->nz_type = N_UNDF | N_EXT;
- nlp->nz_value = sp->common_size;
- nlp->nz_other = N_OTHER(bind, 0);
- } else if (!sp->defined) {
- /* undefined */
- nlp->nz_type = N_UNDF | N_EXT;
- nlp->nz_value = 0;
- if (sp->so_defined && sp->jmpslot_offset != -1) {
- /*
- * A PLT entry. The auxiliary type -- which
- * must be AUX_FUNC -- is used by the run-time
- * linker to unambiguously resolve function
- * address references.
- */
- if (sp->aux != AUX_FUNC)
- errx(1, "%s: non-function jmpslot",
- demangle(sp->name));
- nlp->nz_other = N_OTHER(bind, sp->aux);
- nlp->nz_value =
- rrs_sdt.sdt_plt + sp->jmpslot_offset;
- }
- } else
- errx(1, "internal error: %s defined in mysterious way",
- demangle(sp->name));
-
- /* Set symbol's name */
- nlp->nz_strx = offset;
- strcpy(rrs_strtab + offset, sp->name);
- offset += 1 + strlen(sp->name);
-
- if (sp->alias) {
- /*
- * Write an extra symbol for indirections (possibly
- * just a dummy).
- */
- int t = (nlp->nz_type == N_INDR + N_EXT);
-
- INCR_NLP(nlp);
- nlp->nz_type = N_UNDF + (t ? N_EXT : 0);
- nlp->nz_un.n_strx = offset;
- nlp->nz_value = 0;
- nlp->nz_other = 0;
- nlp->nz_desc = 0;
- nlp->nz_size = 0;
- strcpy(rrs_strtab + offset, sp->alias->name);
- offset += 1 + strlen(sp->alias->name);
- }
-
- INCR_NLP(nlp);
-
- } END_EACH_SYMBOL;
-
- aligned_offset = MALIGN(offset);
- while (offset < aligned_offset) /* Pad deterministically */
- rrs_strtab[offset++] = '\0';
- if (offset != rrs_strtab_size)
- errx(1, "internal error: "
- "inconsistent RRS string table length: %d, expected %d",
- offset, rrs_strtab_size);
-
- /* Write the symbol table */
- if (rrs_symbol_size == sizeof(struct nlist))
- md_swapout_symbols(rrs_symbols, number_of_rrs_symbols);
- else
- md_swapout_zsymbols(rrs_symbols, number_of_rrs_symbols);
- mywrite(rrs_symbols, symsize, 1, outstream);
-
- /* Write the strings */
- mywrite(rrs_strtab, rrs_strtab_size, 1, outstream);
-
- /* Write RT search path */
- mywrite(rrs_search_paths, rrs_search_paths_size, 1, outstream);
-
- /*
- * Write the names of the shared objects needed at run-time
- */
- pos = rrs_sdt.sdt_sods + number_of_shobjs * sizeof(struct sod);
- sodp = (struct sod *)alloca( number_of_shobjs * sizeof(struct sod));
-
- for (i = 0, shp = rrs_shobjs; shp; i++, shp = shp->next) {
- char *name = shp->entry->local_sym_name;
-
- if (i >= number_of_shobjs)
- errx(1, "internal error: # of link objects exceeds %d",
- number_of_shobjs);
-
- sodp[i].sod_name = pos;
- sodp[i].sod_major = shp->entry->lib_major;
- sodp[i].sod_minor = shp->entry->lib_minor;
-
- if (*name == '-' && *(name+1) == 'l') {
- name += 2;
- sodp[i].sod_library = 1;
- } else
- sodp[i].sod_library = 0;
- sodp[i].sod_reserved = 0;
-
- pos += 1 + strlen(name);
- sodp[i].sod_next = (i == number_of_shobjs - 1) ? 0 :
- (rrs_sdt.sdt_sods + (i+1)*sizeof(struct sod));
- }
-
- if (i < number_of_shobjs)
- errx(1, "internal error: "
- "# of link objects less then expected %d",
- number_of_shobjs);
-
- md_swapout_sod(sodp, number_of_shobjs);
- mywrite(sodp, number_of_shobjs, sizeof(struct sod), outstream);
-
- for (i = 0, shp = rrs_shobjs; shp; i++, shp = shp->next) {
- char *name = shp->entry->local_sym_name;
-
- if (*name == '-' && *(name+1) == 'l') {
- name += 2;
- }
-
- mywrite(name, strlen(name) + 1, 1, outstream);
- }
-}
-
-void
-write_rrs()
-{
-
- /*
- * First, do some consistency checks on the RRS segment.
- */
- if (rrs_section_type == RRS_NONE) {
- if (reserved_rrs_relocs > 1)
- errx(1, "internal error: "
- "RRS relocs in static program: %d",
- reserved_rrs_relocs-1);
- return;
- }
-
-#ifdef DEBUG
-printf("rrs_relocs: reserved %d claimed %d discarded %d, gotslots %d jmpslots %d\n",
- reserved_rrs_relocs, claimed_rrs_relocs, discarded_rrs_relocs,
- number_of_gotslots-1, number_of_jmpslots-1);
-#endif
-
- /* Final consistency check */
- if (claimed_rrs_relocs + discarded_rrs_relocs != reserved_rrs_relocs) {
- errx(1, "internal error: "
- "reserved relocs(%d) != claimed(%d) + discarded(%d)",
- reserved_rrs_relocs,
- claimed_rrs_relocs,
- discarded_rrs_relocs);
- }
-
- /* Write the RRS segments. */
- write_rrs_text ();
- write_rrs_data ();
-}
diff --git a/gnu/usr.bin/ld/rtld/Makefile b/gnu/usr.bin/ld/rtld/Makefile
deleted file mode 100644
index 13c8de8..0000000
--- a/gnu/usr.bin/ld/rtld/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# $Id: Makefile,v 1.24 1997/04/16 11:31:32 bde Exp $
-PROG= ld.so
-SRCS= mdprologue.S rtld.c shlib.c md.c support.c
-MAN1= rtld.1
-LDDIR?= $(.CURDIR)/..
-# As there is relocation going on behind GCC's back, don't cache function addresses.
-PICFLAG=-fpic -fno-function-cse
-CFLAGS+=-I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) $(PICFLAG) -DRTLD -Wall
-LDFLAGS+=-nostdlib -Wl,-Bshareable,-Bsymbolic,-assert,nosymbolic
-ASFLAGS+=-k
-DPADD+= ${LIBC:S/c.a/c_pic.a/} ${LIBC:S/c.a/gcc_pic.a/}
-LDADD+= -lc_pic -lgcc_pic
-BINDIR= /usr/libexec
-INSTALLFLAGS+= -fschg -C # -C to install as atomically as possible
-MLINKS= rtld.1 ld.so.1
-
-.PATH: $(LDDIR) $(LDDIR)/$(MACHINE)
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/ld/rtld/md-prologue.c b/gnu/usr.bin/ld/rtld/md-prologue.c
deleted file mode 100644
index dae455e..0000000
--- a/gnu/usr.bin/ld/rtld/md-prologue.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * rtld entry pseudo code - turn into assembler and tweak it
- */
-
-#include <sys/types.h>
-#include <sys/types.h>
-#include <a.out.h>
-#include "link.h"
-#include "md.h"
-
-extern long _GOT_[];
-extern void (*rtld)();
-extern void (*binder())();
-
-void
-rtld_entry(version, crtp)
-int version;
-struct crt *crtp;
-{
- register struct link_dynamic *dp;
- register void (*f)();
-
- /* __DYNAMIC is first entry in GOT */
- dp = (struct link_dynamic *) (_GOT_[0]+crtp->crt_ba);
-
- f = (void (*)())((long)rtld + crtp->crt_ba);
- (*f)(version, crtp, dp);
-}
-
-void
-binder_entry()
-{
- extern int PC;
- struct jmpslot *sp;
- void (*func)();
-
- func = binder(PC, sp->reloc_index & 0x003fffff);
- (*func)();
-}
diff --git a/gnu/usr.bin/ld/rtld/rtld.1 b/gnu/usr.bin/ld/rtld/rtld.1
deleted file mode 100644
index 90e9d54..0000000
--- a/gnu/usr.bin/ld/rtld/rtld.1
+++ /dev/null
@@ -1,224 +0,0 @@
-.\" $Id: rtld.1,v 1.14 1997/05/27 13:46:40 max Exp $
-.\"
-.\" Copyright (c) 1995 Paul Kranenburg
-.\" 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 acknowledgment:
-.\" This product includes software developed by Paul Kranenburg.
-.\" 3. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
-.\"
-.Dd June 27, 1995
-.Dt RTLD 1
-.Os FreeBSD
-.Sh NAME
-.Nm ld.so
-.Nd run-time link-editor
-.Sh DESCRIPTION
-.Nm
-is a self-contained, position independent program image providing run-time
-support for loading and link-editing shared objects into a process'
-address space. It uses the data structures
-.Po
-see
-.Xr link 5
-.Pc
-contained within dynamically linked programs to determine which shared
-libraries are needed and loads them at a convenient virtual address
-using the
-.Xr mmap 2
-system call.
-.Pp
-After all shared libraries have been successfully loaded,
-.Nm
-proceeds to resolve external references from both the main program and
-all objects loaded. A mechanism is provided for initialization routines
-to be called, on a per-object basis, giving a shared object an opportunity
-to perform any extra set-up, before execution of the program proper begins.
-This is useful for C++ libraries that contain static constructors.
-.Pp
-.Nm
-is itself a shared object that is initially loaded by the startup module
-.Em crt0 .
-Since
-.Xr a.out 5
-formats do not provide easy access to the file header from within a running
-process,
-.Em crt0
-uses the special symbol
-.Va _DYNAMIC
-to determine whether a program is in fact dynamically linked or not. Whenever
-the linker
-.Xr ld 1
-has relocated this symbol to a location other than 0,
-.Em crt0
-assumes the services of
-.Nm
-are needed
-.Po
-see
-.Xr link 5
-for details
-.Pc \&.
-.Em crt0
-passes control to
-.Nm
-\&'s entry point before the program's
-.Fn main
-routine is called. Thus,
-.Nm
-can complete the link-editing process before the dynamic program calls upon
-services of any dynamic library.
-.Pp
-To quickly locate the required shared objects in the filesystem,
-.Nm
-may use a
-.Dq hints
-file, prepared by the
-.Xr ldconfig 8
-utility, in which the full path specification of the shared objects can be
-looked up by hashing on the 3-tuple
-.Ao
-library-name, major-version-number, minor-version-number
-.Ac \&.
-.Pp
-.Nm
-recognizes a number of environment variables that can be used to modify
-its behaviour as follows:
-.Pp
-.Bl -tag -width "LD_IGNORE_MISSING_OBJECTS"
-.It Ev LD_LIBRARY_PATH
-A colon separated list of directories, overriding the default search path
-for shared libraries.
-This is ignored for set-user-ID and set-group-ID programs.
-.It Ev LD_PRELOAD
-A colon separated list of shared libraries, to be linked in before any
-other shared libraries. If the directory is not specified then
-the directories specified by LD_LIBRARY_PATH will be searched first
-followed by the set of built-in standard directories.
-This is ignored for set-user-ID and set-group-ID programs.
-.It Ev LD_BIND_NOW
-When set to a nonempty string, causes
-.Nm
-to relocate all external function calls before starting execution of the
-program. Normally, function calls are bound lazily, at the first call
-of each function.
-.Ev LD_BIND_NOW
-increases the start-up time of a program, but it avoids run-time
-surprises caused by unexpectedly undefined functions.
-.It Ev LD_WARN_NON_PURE_CODE
-When set to a nonempty string, issue a warning whenever a link-editing
-operation requires modification of the text segment of some loaded
-object. This is usually indicative of an incorrectly built library.
-.It Ev LD_SUPPRESS_WARNINGS
-When set to a nonempty string, no warning messages of any kind are
-issued. Normally, a warning is given if satisfactorily versioned
-library could not be found.
-.It Ev LD_IGNORE_MISSING_OBJECTS
-When set to a nonempty string, makes it a nonfatal condition if
-one or more required shared objects cannot be loaded.
-Loading and execution proceeds using the objects that are
-available.
-A warning is produced for each missing object, unless the environment
-variable
-.Ev LD_SUPPRESS_WARNINGS
-is set to a nonempty string.
-.Pp
-This is ignored for set-user-ID and set-group-ID programs.
-.Pp
-Missing shared objects can be ignored without errors if all the
-following conditions hold:
-.Bl -bullet
-.It
-They do not supply definitions for any required data symbols.
-.It
-No functions defined by them are called during program execution.
-.It
-The environment variable
-.Ev LD_BIND_NOW
-is unset or is set to the empty string.
-.El
-.It Ev LD_TRACE_LOADED_OBJECTS
-When set to a nonempty string, causes
-.Nm
-to exit after loading the shared objects and printing a summary which includes
-the absolute pathnames of all objects, to standard output.
-.It Ev LD_TRACE_LOADED_OBJECTS_FMT1
-.It Ev LD_TRACE_LOADED_OBJECTS_FMT2
-When set, these variables are interpreted as format strings a la
-.Xr printf 3
-to customize the trace output and are used by
-.Xr ldd 1 's
-.Fl f
-option and allows
-.Xr ldd 1
-to be operated as a filter more conveniently.
-The following conversions can be used:
-.Bl -tag -indent "LD_TRACE_LOADED_OBJECTS_FMT1 " -width "xxxx"
-.It \&%a
-The main program's name
-.Po also known as
-.Dq __progname
-.Pc .
-.It \&%A
-The value of the environment variable
-.Ev LD_TRACE_LOADED_OBJECTS_PROGNAME
-.It \&%o
-The library name.
-.It \&%m
-The library's major version number.
-.It \&%n
-The library's minor version number.
-.It \&%p
-The full pathname as determined by
-.Nm rtld Ns 's
-library search rules.
-.It \&%x
-The library's load address.
-.El
-.Pp
-Additionally,
-.Sy \en
-and
-.Sy \et
-are recognized and have their usual meaning.
-.\" .It Ev LD_NO_INTERN_SEARCH
-.\" When set,
-.\" .Nm
-.\" does not process any internal search paths that were recorded in the
-.\" executable.
-.\" .It Ev LD_NOSTD_PATH
-.\" When set, do not include a set of built-in standard directory paths for
-.\" searching. This might be useful when running on a system with a completely
-.\" non-standard filesystem layout.
-.El
-.Pp
-.Sh FILES
-/var/run/ld.so.hints
-.Pp
-.Sh SEE ALSO
-.Xr ld 1 ,
-.Xr link 5 ,
-.Xr ldconfig 8
-.Sh HISTORY
-The shared library model employed first appeared in SunOS 4.0
diff --git a/gnu/usr.bin/ld/rtld/rtld.c b/gnu/usr.bin/ld/rtld/rtld.c
deleted file mode 100644
index b331cde..0000000
--- a/gnu/usr.bin/ld/rtld/rtld.c
+++ /dev/null
@@ -1,2371 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id: rtld.c,v 1.50 1997/11/29 03:32:47 jdp Exp $
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/errno.h>
-#include <sys/mman.h>
-#ifndef MAP_COPY
-#define MAP_COPY MAP_PRIVATE
-#endif
-#include <dlfcn.h>
-#include <err.h>
-#include <fcntl.h>
-#include <a.out.h>
-#include <stab.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <link.h>
-
-#include "md.h"
-#include "shlib.h"
-#include "support.h"
-#include "dynamic.h"
-
-#ifndef MAP_ANON
-#define MAP_ANON 0
-#define anon_open() do { \
- if ((anon_fd = open("/dev/zero", O_RDWR, 0)) == -1) \
- err("open: %s", "/dev/zero"); \
-} while (0)
-#define anon_close() do { \
- (void)close(anon_fd); \
- anon_fd = -1; \
-} while (0)
-#else
-#define anon_open()
-#define anon_close()
-#endif
-
-/*
- * Structure for building a list of shared objects.
- */
-struct so_list {
- struct so_map *sol_map; /* Link map for shared object */
- struct so_list *sol_next; /* Next entry in the list */
-};
-
-/*
- * Loader private data, hung off <so_map>->som_spd
- */
-struct somap_private {
- int spd_version;
- struct so_map *spd_parent;
- struct so_list *spd_children;
- struct so_map *spd_prev;
- dev_t spd_dev;
- ino_t spd_ino;
- int spd_refcount;
- int spd_flags;
-#define RTLD_MAIN 0x01
-#define RTLD_RTLD 0x02
-#define RTLD_DL 0x04
-#define RTLD_INIT 0x08
- unsigned long a_text; /* text size, if known */
- unsigned long a_data; /* initialized data size */
- unsigned long a_bss; /* uninitialized data size */
-
-#ifdef SUN_COMPAT
- long spd_offset; /* Correction for Sun main programs */
-#endif
-};
-
-#define LM_PRIVATE(smp) ((struct somap_private *)(smp)->som_spd)
-
-#ifdef SUN_COMPAT
-#define LM_OFFSET(smp) (LM_PRIVATE(smp)->spd_offset)
-#else
-#define LM_OFFSET(smp) (0)
-#endif
-
-/* Base address for section_dispatch_table entries */
-#define LM_LDBASE(smp) (smp->som_addr + LM_OFFSET(smp))
-
-/* Start of text segment */
-#define LM_TXTADDR(smp) (smp->som_addr == (caddr_t)0 ? PAGSIZ : 0)
-
-/* Start of run-time relocation_info */
-#define LM_REL(smp) ((struct relocation_info *) \
- (smp->som_addr + LM_OFFSET(smp) + LD_REL((smp)->som_dynamic)))
-
-/* Start of symbols */
-#define LM_SYMBOL(smp, i) ((struct nzlist *) \
- (smp->som_addr + LM_OFFSET(smp) + LD_SYMBOL((smp)->som_dynamic) + \
- i * (LD_VERSION_NZLIST_P(smp->som_dynamic->d_version) ? \
- sizeof(struct nzlist) : sizeof(struct nlist))))
-
-/* Start of hash table */
-#define LM_HASH(smp) ((struct rrs_hash *) \
- ((smp)->som_addr + LM_OFFSET(smp) + LD_HASH((smp)->som_dynamic)))
-
-/* Start of strings */
-#define LM_STRINGS(smp) ((char *) \
- ((smp)->som_addr + LM_OFFSET(smp) + LD_STRINGS((smp)->som_dynamic)))
-
-/* Start of search paths */
-#define LM_PATHS(smp) ((char *) \
- ((smp)->som_addr + LM_OFFSET(smp) + LD_PATHS((smp)->som_dynamic)))
-
-/* End of text */
-#define LM_ETEXT(smp) ((char *) \
- ((smp)->som_addr + LM_TXTADDR(smp) + LD_TEXTSZ((smp)->som_dynamic)))
-
-/* Needed shared objects */
-#define LM_NEED(smp) ((struct sod *) \
- ((smp)->som_addr + LM_TXTADDR(smp) + LD_NEED((smp)->som_dynamic)))
-
-/* PLT is in data segment, so don't use LM_OFFSET here */
-#define LM_PLT(smp) ((jmpslot_t *) \
- ((smp)->som_addr + LD_PLT((smp)->som_dynamic)))
-
-/* Parent of link map */
-#define LM_PARENT(smp) (LM_PRIVATE(smp)->spd_parent)
-
-#ifndef RELOC_EXTERN_P
-#define RELOC_EXTERN_P(s) ((s)->r_extern)
-#endif
-
-#ifndef RELOC_SYMBOL
-#define RELOC_SYMBOL(s) ((s)->r_symbolnum)
-#endif
-
-#ifndef RELOC_PCREL_P
-#define RELOC_PCREL_P(s) ((s)->r_pcrel)
-#endif
-
-static char __main_progname[] = "main";
-static char *main_progname = __main_progname;
-static char us[] = "/usr/libexec/ld.so";
-
-char **environ;
-char *__progname;
-int errno;
-
-static uid_t uid, euid;
-static gid_t gid, egid;
-static int careful;
-static int anon_fd = -1;
-
-static char *ld_bind_now;
-static char *ld_ignore_missing_objects;
-static char *ld_library_path;
-static char *ld_preload;
-static char *ld_tracing;
-static char *ld_suppress_warnings;
-static char *ld_warn_non_pure_code;
-
-struct so_map *link_map_head;
-struct so_map *link_map_tail;
-struct rt_symbol *rt_symbol_head;
-
-static void *__dlopen __P((const char *, int));
-static int __dlclose __P((void *));
-static void *__dlsym __P((void *, const char *));
-static const char *__dlerror __P((void));
-static void __dlexit __P((void));
-static void *__dlsym3 __P((void *, const char *, void *));
-
-static struct ld_entry ld_entry = {
- __dlopen, __dlclose, __dlsym, __dlerror, __dlexit, __dlsym3
-};
-
- void xprintf __P((char *, ...));
-static struct so_map *map_object __P(( const char *,
- struct sod *,
- struct so_map *));
-static int map_preload __P((void));
-static int map_sods __P((struct so_map *));
-static int reloc_dag __P((struct so_map *, int));
-static void unmap_object __P((struct so_map *, int));
-static struct so_map *alloc_link_map __P(( const char *, struct sod *,
- struct so_map *, caddr_t,
- struct _dynamic *));
-static void init_link_map __P(( struct so_map *,
- struct somap_private *,
- const char *, struct sod *,
- struct so_map *, caddr_t,
- struct _dynamic *));
-static void free_link_map __P((struct so_map *));
-static inline int check_text_reloc __P(( struct relocation_info *,
- struct so_map *,
- caddr_t));
-static int reloc_map __P((struct so_map *, int));
-static void reloc_copy __P((struct so_map *));
-static void init_dag __P((struct so_map *));
-static void init_sods __P((struct so_list *));
-static void init_internal_malloc __P((void));
-static void init_external_malloc __P((void));
-static int call_map __P((struct so_map *, char *));
-static char *findhint __P((char *, int, int *));
-static char *rtfindlib __P((char *, int, int));
-static char *rtfindfile __P((char *));
-void binder_entry __P((void));
-long binder __P((jmpslot_t *));
-static struct nzlist *lookup __P((char *, struct so_map **, int));
-static inline struct rt_symbol *lookup_rts __P((char *, unsigned long));
-static struct nzlist *lookup_in_obj __P((char *, unsigned long,
- struct so_map *, int));
-static struct rt_symbol *enter_rts __P((char *, unsigned long, long, int,
- caddr_t, long, struct so_map *));
-static void *sym_addr __P((char *));
-static void die __P((void));
-static void generror __P((char *, ...));
-static int maphints __P((void));
-static void unmaphints __P((void));
-static void ld_trace __P((struct so_map *));
-static void rt_readenv __P((void));
-static int hinthash __P((char *, int));
-int rtld __P((int, struct crt_ldso *, struct _dynamic *));
-
-/*
- * Compute a hash value for symbol tables. Don't change this -- the
- * algorithm is dictated by the way the linker builds the symbol
- * tables in the shared objects.
- */
-static inline unsigned long
-sym_hash(s)
- const char *s;
-{
- unsigned long h;
-
- h = 0;
- while (*s != '\0')
- h = (h << 1) + *s++;
- return h & 0x7fffffffUL;
-}
-
-static inline int
-strcmp (register const char *s1, register const char *s2)
-{
- while (*s1 == *s2++)
- if (*s1++ == 0)
- return (0);
- return (*(unsigned char *)s1 - *(unsigned char *)--s2);
-}
-
-#include "md-static-funcs.c"
-
-/*
- * Called from assembler stub that has set up crtp (passed from crt0)
- * and dp (our __DYNAMIC).
- */
-int
-rtld(version, crtp, dp)
-int version;
-struct crt_ldso *crtp;
-struct _dynamic *dp;
-{
- struct relocation_info *reloc;
- struct relocation_info *reloc_limit; /* End+1 of relocation */
- struct so_debug *ddp;
- struct so_map *main_map;
- struct so_map *smp;
- char *add_paths;
-
- /* Check version */
- if (version != CRT_VERSION_BSD_2 &&
- version != CRT_VERSION_BSD_3 &&
- version != CRT_VERSION_BSD_4 &&
- version != CRT_VERSION_SUN)
- return -1;
-
- /* Fixup __DYNAMIC structure */
- (long)dp->d_un.d_sdt += crtp->crt_ba;
-
- /* Relocate ourselves */
- reloc = (struct relocation_info *) (LD_REL(dp) + crtp->crt_ba);
- reloc_limit =
- (struct relocation_info *) ((char *) reloc + LD_RELSZ(dp));
- while(reloc < reloc_limit) {
- /*
- * Objects linked with "-Bsymbolic" (in particular, ld.so
- * itself) can end up having unused relocation entries at
- * the end. These can be detected by the fact that they
- * have an address of 0.
- */
- if(reloc->r_address == 0) /* We're done */
- break;
- md_relocate_simple(reloc, crtp->crt_ba,
- reloc->r_address + crtp->crt_ba);
- ++reloc;
- }
-
- if (version >= CRT_VERSION_BSD_4)
- __progname = crtp->crt_ldso;
- if (version >= CRT_VERSION_BSD_3)
- main_progname = crtp->crt_prog;
-
- /* Some buggy versions of crt0.o have crt_ldso filled in as NULL. */
- if (__progname == NULL)
- __progname = us;
-
- /* Fill in some fields in _DYNAMIC or crt structure */
- if (version >= CRT_VERSION_BSD_4)
- crtp->crt_ldentry = &ld_entry; /* crt */
- else
- crtp->crt_dp->d_entry = &ld_entry; /* _DYNAMIC */
-
- /* Initialize our internal malloc package. */
- init_internal_malloc();
-
- /* Setup out (private) environ variable */
- environ = crtp->crt_ep;
-
- /* Get user and group identifiers */
- uid = getuid(); euid = geteuid();
- gid = getgid(); egid = getegid();
-
- careful = (uid != euid) || (gid != egid);
-
- rt_readenv();
-
- anon_open();
-
- /* Make a link map entry for the main program */
- main_map = alloc_link_map(main_progname,
- (struct sod *) NULL, (struct so_map *) NULL,
- (caddr_t) 0, crtp->crt_dp);
- LM_PRIVATE(main_map)->spd_refcount++;
- LM_PRIVATE(main_map)->spd_flags |= RTLD_MAIN;
-
- /* Make a link map entry for ourselves */
- smp = alloc_link_map(us,
- (struct sod *) NULL, (struct so_map *) NULL,
- (caddr_t) crtp->crt_ba, dp);
- LM_PRIVATE(smp)->spd_refcount++;
- LM_PRIVATE(smp)->spd_flags |= RTLD_RTLD;
-
- /*
- * Setup the executable's run path
- */
- if (version >= CRT_VERSION_BSD_4) {
- add_paths = LM_PATHS(main_map);
- if (add_paths)
- add_search_path(add_paths);
- }
-
- /*
- * Setup the directory search list for findshlib. We use only
- * the standard search path. Any extra directories from
- * LD_LIBRARY_PATH are searched explicitly, in rtfindlib.
- */
- std_search_path();
-
- /* Map in LD_PRELOADs before the main program's shared objects so we
- can intercept those calls */
- if (ld_preload != NULL) {
- if(map_preload() == -1) /* Failed */
- die();
- }
-
- /* Map all the shared objects that the main program depends upon */
- if(map_sods(main_map) == -1)
- die();
-
- if(ld_tracing) { /* We're done */
- ld_trace(link_map_head);
- exit(0);
- }
-
- crtp->crt_dp->d_un.d_sdt->sdt_loaded = link_map_head->som_next;
-
- /* Relocate all mapped objects. */
- if(reloc_dag(main_map, ld_bind_now != NULL) == -1) /* Failed */
- die();
-
- /*
- * Switch to the same malloc that the program uses. We do
- * this before initializing the loaded objects, because their
- * initialization functions may well call malloc, and it won't
- * work right until we have set it up.
- */
- init_external_malloc();
-
- /* Initialize all mapped objects. */
- init_dag(main_map);
-
- ddp = crtp->crt_dp->d_debug;
- ddp->dd_cc = rt_symbol_head;
- if (ddp->dd_in_debugger) {
- caddr_t addr = (caddr_t)((long)crtp->crt_bp & (~(PAGSIZ - 1)));
-
- /* Set breakpoint for the benefit of debuggers */
- if (mprotect(addr, PAGSIZ,
- PROT_READ|PROT_WRITE|PROT_EXEC) == -1) {
- err(1, "Cannot set breakpoint (%s)", main_progname);
- }
- md_set_breakpoint((long)crtp->crt_bp, (long *)&ddp->dd_bpt_shadow);
- if (mprotect(addr, PAGSIZ, PROT_READ|PROT_EXEC) == -1) {
- err(1, "Cannot re-protect breakpoint (%s)",
- main_progname);
- }
-
- ddp->dd_bpt_addr = crtp->crt_bp;
- if (link_map_head)
- ddp->dd_sym_loaded = 1;
- }
-
- /* Close the hints file */
- unmaphints();
-
- /* Close our file descriptor */
- (void)close(crtp->crt_ldfd);
- anon_close();
-
- return LDSO_VERSION_HAS_DLSYM3;
-}
-
-void
-ld_trace(smp)
- struct so_map *smp;
-{
- char *fmt1, *fmt2, *fmt, *main_local;
- int c;
-
- if ((main_local = getenv("LD_TRACE_LOADED_OBJECTS_PROGNAME")) == NULL)
- main_local = "";
-
- if ((fmt1 = getenv("LD_TRACE_LOADED_OBJECTS_FMT1")) == NULL)
- fmt1 = "\t-l%o.%m => %p (%x)\n";
-
- if ((fmt2 = getenv("LD_TRACE_LOADED_OBJECTS_FMT2")) == NULL)
- fmt2 = "\t%o (%x)\n";
-
- for (; smp; smp = smp->som_next) {
- struct sod *sodp;
- char *name, *path;
-
- if ((sodp = smp->som_sod) == NULL)
- continue;
-
- name = (char *)sodp->sod_name;
- if (LM_PARENT(smp))
- name += (long)LM_LDBASE(LM_PARENT(smp));
-
- if ((path = smp->som_path) == NULL)
- path = "not found";
-
- fmt = sodp->sod_library ? fmt1 : fmt2;
- while ((c = *fmt++) != '\0') {
- switch (c) {
- default:
- putchar(c);
- continue;
- case '\\':
- switch (c = *fmt) {
- case '\0':
- continue;
- case 'n':
- putchar('\n');
- break;
- case 't':
- putchar('\t');
- break;
- }
- break;
- case '%':
- switch (c = *fmt) {
- case '\0':
- continue;
- case '%':
- default:
- putchar(c);
- break;
- case 'A':
- printf("%s", main_local);
- break;
- case 'a':
- printf("%s", main_progname);
- break;
- case 'o':
- printf("%s", name);
- break;
- case 'm':
- printf("%d", sodp->sod_major);
- break;
- case 'n':
- printf("%d", sodp->sod_minor);
- break;
- case 'p':
- printf("%s", path);
- break;
- case 'x':
- printf("%p", smp->som_addr);
- break;
- }
- break;
- }
- ++fmt;
- }
- }
-}
-
-/*
- * Allocate a new link map and return a pointer to it.
- *
- * PATH is the pathname of the shared object.
- *
- * SODP is a pointer to the shared object dependency structure responsible
- * for causing the new object to be loaded. PARENT is the shared object
- * into which SODP points. Both can be NULL if the new object is not
- * being loaded as a result of a shared object dependency.
- *
- * ADDR is the address at which the object has been mapped. DP is a pointer
- * to its _dynamic structure.
- */
-static struct so_map *
-alloc_link_map(path, sodp, parent, addr, dp)
- const char *path;
- struct sod *sodp;
- struct so_map *parent;
- caddr_t addr;
- struct _dynamic *dp;
-{
- struct so_map *smp;
- struct somap_private *smpp;
-
-#ifdef DEBUG /* { */
- xprintf("alloc_link_map: \"%s\" at %p\n", path, addr);
-#endif /* } */
-
- smp = (struct so_map *)xmalloc(sizeof(struct so_map));
- smpp = (struct somap_private *)xmalloc(sizeof(struct somap_private));
- init_link_map(smp, smpp, path, sodp, parent, addr, dp);
-
- /* Link the new entry into the list of link maps */
- smpp->spd_prev = link_map_tail;
- if(link_map_tail == NULL) /* First link map entered into list */
- link_map_head = link_map_tail = smp;
- else { /* Append to end of list */
- link_map_tail->som_next = smp;
- link_map_tail = smp;
- }
-
- return smp;
-}
-
-/*
- * Initialize a link map entry that has already been allocated.
- */
-static void
-init_link_map(smp, smpp, path, sodp, parent, addr, dp)
- struct so_map *smp;
- struct somap_private *smpp;
- const char *path;
- struct sod *sodp;
- struct so_map *parent;
- caddr_t addr;
- struct _dynamic *dp;
-{
- memset(smp, 0, sizeof *smp);
- memset(smpp, 0, sizeof *smpp);
- smp->som_spd = (caddr_t)smpp;
- smp->som_addr = addr;
- smp->som_path = path ? strdup(path) : NULL;
- smp->som_sod = sodp;
- smp->som_dynamic = dp;
- smpp->spd_parent = parent;
-#ifdef SUN_COMPAT
- smpp->spd_offset =
- (addr==0 && dp && dp->d_version==LD_VERSION_SUN) ? PAGSIZ : 0;
-#endif
-}
-
-/*
- * Remove the specified link map entry from the list of link maps, and free
- * the associated storage.
- */
-static void
-free_link_map(smp)
- struct so_map *smp;
-{
- struct somap_private *smpp = LM_PRIVATE(smp);
-
-#ifdef DEBUG /* { */
- xprintf("free_link_map: \"%s\"\n", smp->som_path);
-#endif /* } */
-
- if(smpp->spd_prev == NULL) /* Removing first entry in list */
- link_map_head = smp->som_next;
- else /* Update link of previous entry */
- smpp->spd_prev->som_next = smp->som_next;
-
- if(smp->som_next == NULL) /* Removing last entry in list */
- link_map_tail = smpp->spd_prev;
- else /* Update back link of next entry */
- LM_PRIVATE(smp->som_next)->spd_prev = smpp->spd_prev;
-
- if (smp->som_path != NULL)
- free(smp->som_path);
- free(smpp);
- free(smp);
-}
-
-/*
- * Map the shared object specified by PATH into memory, if it is not
- * already mapped. Increment the object's reference count, and return a
- * pointer to its link map.
- *
- * As a special case, if PATH is NULL, it is taken to refer to the main
- * program.
- *
- * SODP is a pointer to the shared object dependency structure that caused
- * this object to be requested. PARENT is a pointer to the link map of
- * the shared object containing that structure. For a shared object not
- * being mapped as a result of a shared object dependency, these pointers
- * should be NULL. An example of this is a shared object that is explicitly
- * loaded via dlopen().
- *
- * The return value is a pointer to the link map for the requested object.
- * If the operation failed, the return value is NULL. In that case, an
- * error message can be retrieved by calling dlerror().
- */
-static struct so_map *
-map_object(path, sodp, parent)
- const char *path;
- struct sod *sodp;
- struct so_map *parent;
-{
- struct so_map *smp;
- struct stat statbuf;
-
- if(path == NULL) /* Special case for the main program itself */
- smp = link_map_head;
- else {
- /*
- * Check whether the shared object is already mapped.
- * We check first for an exact match by pathname. That
- * will detect the usual case. If no match is found by
- * pathname, then stat the file, and check for a match by
- * device and inode. That will detect the less common case
- * involving multiple links to the same library.
- */
- for(smp = link_map_head; smp != NULL; smp = smp->som_next) {
- if(!(LM_PRIVATE(smp)->spd_flags & (RTLD_MAIN|RTLD_RTLD))
- && smp->som_path != NULL
- && strcmp(smp->som_path, path) == 0)
- break;
- }
- if(smp == NULL) { /* Check for a match by device and inode */
- if (stat(path, &statbuf) == -1) {
- generror ("cannot stat \"%s\" : %s",
- path, strerror(errno));
- return NULL;
- }
- for (smp = link_map_head; smp != NULL;
- smp = smp->som_next) {
- struct somap_private *smpp = LM_PRIVATE(smp);
-
- if (!(smpp->spd_flags & (RTLD_MAIN | RTLD_RTLD))
- && smpp->spd_ino == statbuf.st_ino
- && smpp->spd_dev == statbuf.st_dev)
- break;
- }
- }
- }
-
- if (smp == NULL) { /* We must map the object */
- struct _dynamic *dp;
- int fd;
- caddr_t addr;
- struct exec hdr;
- struct somap_private *smpp;
-
- if ((fd = open(path, O_RDONLY, 0)) == -1) {
- generror ("open failed for \"%s\" : %s",
- path, strerror (errno));
- return NULL;
- }
-
- if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
- generror ("header read failed for \"%s\"", path);
- (void)close(fd);
- return NULL;
- }
-
- if (N_BADMAG(hdr)) {
- generror ("bad magic number in \"%s\"", path);
- (void)close(fd);
- return NULL;
- }
-
- /*
- * Map the entire address space of the object. It is
- * tempting to map just the text segment at first, in
- * order to avoid having to use mprotect to change the
- * protections of the data segment. But that would not
- * be correct. Mmap might find a group of free pages
- * large enough to hold the text segment, but not large
- * enough for the entire object. When we then mapped
- * in the data and BSS segments, they would either be
- * non-contiguous with the text segment (if we didn't
- * specify MAP_FIXED), or they would map over some
- * previously mapped region (if we did use MAP_FIXED).
- * The only way we can be sure of getting a contigous
- * region that is large enough is to map the entire
- * region at once.
- */
- if ((addr = mmap(0, hdr.a_text + hdr.a_data + hdr.a_bss,
- PROT_READ|PROT_EXEC,
- MAP_COPY, fd, 0)) == (caddr_t)-1) {
- generror ("mmap failed for \"%s\" : %s",
- path, strerror (errno));
- (void)close(fd);
- return NULL;
- }
-
- (void)close(fd);
-
- /* Change the data segment to writable */
- if (mprotect(addr + hdr.a_text, hdr.a_data,
- PROT_READ|PROT_WRITE|PROT_EXEC) != 0) {
- generror ("mprotect failed for \"%s\" : %s",
- path, strerror (errno));
- (void)munmap(addr, hdr.a_text + hdr.a_data + hdr.a_bss);
- return NULL;
- }
-
- /* Map in pages of zeros for the BSS segment */
- if (mmap(addr + hdr.a_text + hdr.a_data, hdr.a_bss,
- PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_ANON|MAP_COPY|MAP_FIXED,
- anon_fd, 0) == (caddr_t)-1) {
- generror ("mmap failed for \"%s\" : %s",
- path, strerror (errno));
- (void)munmap(addr, hdr.a_text + hdr.a_data + hdr.a_bss);
- return NULL;
- }
-
- /* Assume _DYNAMIC is the first data item */
- dp = (struct _dynamic *)(addr+hdr.a_text);
-
- /* Fixup __DYNAMIC structure */
- (long)dp->d_un.d_sdt += (long)addr;
-
- smp = alloc_link_map(path, sodp, parent, addr, dp);
-
- /* save segment sizes for unmap. */
- smpp = LM_PRIVATE(smp);
- smpp->a_text = hdr.a_text;
- smpp->a_data = hdr.a_data;
- smpp->a_bss = hdr.a_bss;
-
- /*
- * Save the device and inode, so we can detect multiple links
- * to the same library. Note, if we reach this point, then
- * statbuf is guaranteed to have been filled in.
- */
- smpp->spd_dev = statbuf.st_dev;
- smpp->spd_ino = statbuf.st_ino;
- }
-
- LM_PRIVATE(smp)->spd_refcount++;
- if(LM_PRIVATE(smp)->spd_refcount == 1) { /* First use of object */
- /*
- * Recursively map all of the shared objects that this
- * one depends upon.
- */
- if(map_sods(smp) == -1) { /* Failed */
- unmap_object(smp, 0); /* Clean up */
- return NULL;
- }
- }
-
- return smp;
-}
-
-/*
- * Map all the shared libraries named in the LD_PRELOAD environment
- * variable.
- *
- * Returns 0 on success, -1 on failure. On failure, an error message can
- * be gotten via dlerror().
- */
- static int
-map_preload __P((void)) {
- char *ld_name = ld_preload;
- char *name;
-
- while ((name = strsep(&ld_name, ":")) != NULL) {
- char *path = NULL;
- struct so_map *smp = NULL;
-
- if (*name != '\0') {
- path = (strchr(name, '/') != NULL) ? strdup(name) :
- rtfindfile(name);
- }
- if (path == NULL) {
- generror("Can't find LD_PRELOAD shared"
- " library \"%s\"", name);
- } else {
- smp = map_object(path, (struct sod *) NULL,
- (struct so_map *) NULL);
- free(path);
- }
- if (ld_name != NULL)
- *(ld_name - 1) = ':';
- if (smp == NULL) {
- /*
- * We don't bother to unmap already-loaded libraries
- * on failure, because in that case the program is
- * about to die anyway.
- */
- return -1;
- }
- }
- return 0;
-}
-
-/*
- * Map all of the shared objects that a given object depends upon. PARENT is
- * a pointer to the link map for the shared object whose dependencies are
- * to be mapped.
- *
- * Returns 0 on success. Returns -1 on failure. In that case, an error
- * message can be retrieved by calling dlerror().
- */
-static int
-map_sods(parent)
- struct so_map *parent;
-{
- struct somap_private *parpp = LM_PRIVATE(parent);
- struct so_list **soltail = &parpp->spd_children;
- long next = LD_NEED(parent->som_dynamic);
-
- while(next != 0) {
- struct sod *sodp =
- (struct sod *) (LM_LDBASE(parent) + next);
- char *name =
- (char *) (LM_LDBASE(parent) + sodp->sod_name);
- char *path = NULL;
- struct so_map *smp = NULL;
-
- if(sodp->sod_library) {
- path = rtfindlib(name, sodp->sod_major,
- sodp->sod_minor);
- if(path == NULL && !ld_tracing) {
- generror ("Can't find shared library"
- " \"lib%s.so.%d.%d\"", name,
- sodp->sod_major, sodp->sod_minor);
- }
- } else {
- if(careful && name[0] != '/') {
- generror("Shared library path must start"
- " with \"/\" for \"%s\"", name);
- } else
- path = strdup(name);
- }
-
- if(path != NULL) {
- smp = map_object(path, sodp, parent);
- free(path);
- }
-
- if(smp != NULL) {
- struct so_list *solp = (struct so_list *)
- xmalloc(sizeof(struct so_list));
- solp->sol_map = smp;
- solp->sol_next = NULL;
- *soltail = solp;
- soltail = &solp->sol_next;
- } else if(ld_tracing) {
- /*
- * Allocate a dummy map entry so that we will get the
- * "not found" message.
- */
- (void)alloc_link_map(NULL, sodp, parent, 0, 0);
- } else if (ld_ignore_missing_objects) {
- const char *msg;
- /*
- * Call __dlerror() even it we're not going to use
- * the message, in order to clear the saved message.
- */
- msg = __dlerror(); /* Should never be NULL */
- if (!ld_suppress_warnings)
- warnx("warning: %s", msg);
- } else /* Give up */
- break;
-
- next = sodp->sod_next;
- }
-
- if(next != 0) {
- /*
- * Oh drat, we have to clean up a mess.
- *
- * We failed to load a shared object that we depend upon.
- * So now we have to unload any dependencies that we had
- * already successfully loaded prior to the error.
- *
- * Cleaning up doesn't matter so much for the initial
- * loading of the program, since any failure is going to
- * terminate the program anyway. But it is very important
- * to clean up properly when something is being loaded
- * via dlopen().
- */
- struct so_list *solp;
-
- while((solp = parpp->spd_children) != NULL) {
- unmap_object(solp->sol_map, 0);
- parpp->spd_children = solp->sol_next;
- free(solp);
- }
-
- return -1;
- }
-
- return 0;
-}
-
-/*
- * Relocate the DAG of shared objects rooted at the given link map
- * entry. Returns 0 on success, or -1 on failure. On failure, an
- * error message can be retrieved via dlerror().
- */
-static int
-reloc_dag(root, bind_now)
- struct so_map *root;
- int bind_now;
-{
- struct so_map *smp;
-
- /*
- * Relocate all newly-loaded objects. We avoid recursion for this
- * step by taking advantage of a few facts. This function is called
- * only when there are in fact some newly-loaded objects to process.
- * Furthermore, all newly-loaded objects will have their link map
- * entries at the end of the link map list. And, the root of the
- * tree of objects just loaded will have been the first to be loaded
- * and therefore the first new object in the link map list. Finally,
- * we take advantage of the fact that we can relocate the newly-loaded
- * objects in any order.
- *
- * All these facts conspire to let us simply loop over the tail
- * portion of the link map list, relocating each object so
- * encountered.
- */
- for(smp = root; smp != NULL; smp = smp->som_next) {
- if(!(LM_PRIVATE(smp)->spd_flags & RTLD_RTLD)) {
- if(reloc_map(smp, bind_now) < 0)
- return -1;
- }
- }
-
- /*
- * Copy any relocated initialized data. Again, we can just loop
- * over the appropriate portion of the link map list.
- */
- for(smp = root; smp != NULL; smp = smp->som_next) {
- if(!(LM_PRIVATE(smp)->spd_flags & RTLD_RTLD))
- reloc_copy(smp);
- }
-
- return 0;
-}
-
-/*
- * Remove a reference to the shared object specified by SMP. If no
- * references remain, unmap the object and, recursively, its descendents.
- * This function also takes care of calling the finalization routines for
- * objects that are removed.
- *
- * If KEEP is true, then the actual calls to munmap() are skipped,
- * and the object is kept in memory. That is used only for finalization,
- * from dlexit(), when the program is exiting. There are two reasons
- * for it. First, the program is exiting and there is no point in
- * spending the time to explicitly unmap its shared objects. Second,
- * even after dlexit() has been called, there are still a couple of
- * calls that are made to functions in libc. (This is really a bug
- * in crt0.) So libc and the main program, at least, must remain
- * mapped in that situation.
- *
- * Under no reasonable circumstances should this function fail. If
- * anything goes wrong, we consider it an internal error, and report
- * it with err().
- */
-static void
-unmap_object(smp, keep)
- struct so_map *smp;
- int keep;
-{
- struct somap_private *smpp = LM_PRIVATE(smp);
-
- smpp->spd_refcount--;
- if(smpp->spd_refcount == 0) { /* Finished with this object */
- struct so_list *solp;
-
- if(smpp->spd_flags & RTLD_INIT) { /* Was initialized */
- /*
- * Call the object's finalization routine. For
- * backward compatibility, we first try to call
- * ".fini". If that does not exist, we call
- * "__fini".
- */
- if(call_map(smp, ".fini") == -1)
- call_map(smp, "__fini");
- }
-
- /* Recursively unreference the object's descendents */
- while((solp = smpp->spd_children) != NULL) {
- unmap_object(solp->sol_map, keep);
- smpp->spd_children = solp->sol_next;
- free(solp);
- }
-
- if(!keep) { /* Unmap the object from memory */
- if(munmap(smp->som_addr,
- smpp->a_text + smpp->a_data + smpp->a_bss) < 0)
- err(1, "internal error 1: munmap failed");
-
- /* Unlink and free the object's link map entry */
- free_link_map(smp);
- }
- }
-}
-
-static inline int
-check_text_reloc(r, smp, addr)
-struct relocation_info *r;
-struct so_map *smp;
-caddr_t addr;
-{
- char *sym;
-
- if (addr >= LM_ETEXT(smp))
- return 0;
-
- if (RELOC_EXTERN_P(r))
- sym = LM_STRINGS(smp) +
- LM_SYMBOL(smp, RELOC_SYMBOL(r))->nz_strx;
- else
- sym = "";
-
- if (!ld_suppress_warnings && ld_warn_non_pure_code)
- warnx("warning: non pure code in %s at %x (%s)",
- smp->som_path, r->r_address, sym);
-
- if (smp->som_write == 0 &&
- mprotect(smp->som_addr + LM_TXTADDR(smp),
- LD_TEXTSZ(smp->som_dynamic),
- PROT_READ|PROT_WRITE|PROT_EXEC) == -1) {
- generror ("mprotect failed for \"%s\" : %s",
- smp->som_path, strerror (errno));
- return -1;
- }
-
- smp->som_write = 1;
- return 0;
-}
-
-static int
-reloc_map(smp, bind_now)
- struct so_map *smp;
- int bind_now;
-{
- /*
- * Caching structure for reducing the number of calls to
- * lookup() during relocation.
- *
- * While relocating a given shared object, the dynamic linker
- * maintains a caching vector that is directly indexed by
- * the symbol number in the relocation entry. The first time
- * a given symbol is looked up, the caching vector is
- * filled in with a pointer to the symbol table entry, and
- * a pointer to the so_map of the shared object in which the
- * symbol was defined. On subsequent uses of the same symbol,
- * that information is retrieved directly from the caching
- * vector, without calling lookup() again.
- *
- * A symbol that is referenced in a relocation entry is
- * typically referenced in many relocation entries, so this
- * caching reduces the number of calls to lookup()
- * dramatically. The overall improvement in the speed of
- * dynamic linking is also dramatic -- as much as a factor
- * of three for programs that use many shared libaries.
- */
- struct cacheent {
- struct nzlist *np; /* Pointer to symbol entry */
- struct so_map *src_map; /* Shared object that defined symbol */
- };
-
- struct _dynamic *dp = smp->som_dynamic;
- struct relocation_info *r = LM_REL(smp);
- struct relocation_info *rend = r + LD_RELSZ(dp)/sizeof(*r);
- long symbolbase = (long)LM_SYMBOL(smp, 0);
- char *stringbase = LM_STRINGS(smp);
- int symsize = LD_VERSION_NZLIST_P(dp->d_version) ?
- sizeof(struct nzlist) :
- sizeof(struct nlist);
- long numsyms = LD_STABSZ(dp) / symsize;
- size_t cachebytes = numsyms * sizeof(struct cacheent);
- struct cacheent *symcache =
- (struct cacheent *) alloca(cachebytes);
-
- if(symcache == NULL) {
- generror("Cannot allocate symbol caching vector for %s",
- smp->som_path);
- return -1;
- }
- bzero(symcache, cachebytes);
-
- if (LD_PLTSZ(dp))
- md_fix_jmpslot(LM_PLT(smp),
- (long)LM_PLT(smp), (long)binder_entry);
-
- for (; r < rend; r++) {
- char *sym;
- caddr_t addr;
-
- /*
- * Objects linked with "-Bsymbolic" can end up having unused
- * relocation entries at the end. These can be detected by
- * the fact that they have an address of 0.
- */
- if(r->r_address == 0) /* Finished relocating this object */
- break;
-
- addr = smp->som_addr + r->r_address;
- if (check_text_reloc(r, smp, addr) < 0)
- return -1;
-
- if (RELOC_EXTERN_P(r)) {
- struct so_map *src_map = NULL;
- struct nzlist *p, *np;
- long relocation;
-
- if (RELOC_JMPTAB_P(r) && !bind_now)
- continue;
-
- p = (struct nzlist *)
- (symbolbase + symsize * RELOC_SYMBOL(r));
-
- if (p->nz_type == (N_SETV + N_EXT))
- src_map = smp;
-
- sym = stringbase + p->nz_strx;
-
- /*
- * Look up the symbol, checking the caching
- * vector first.
- */
- np = symcache[RELOC_SYMBOL(r)].np;
- if(np != NULL) /* Symbol already cached */
- src_map = symcache[RELOC_SYMBOL(r)].src_map;
- else { /* Symbol not cached yet */
- np = lookup(sym, &src_map, RELOC_JMPTAB_P(r));
- /*
- * Record the needed information about
- * the symbol in the caching vector,
- * so that we won't have to call
- * lookup the next time we encounter
- * the symbol.
- */
- symcache[RELOC_SYMBOL(r)].np = np;
- symcache[RELOC_SYMBOL(r)].src_map = src_map;
- }
-
- if (np == NULL) {
- generror ("Undefined symbol \"%s\" in %s:%s",
- sym, main_progname, smp->som_path);
- return -1;
- }
-
- /*
- * Found symbol definition.
- * If it's in a link map, adjust value
- * according to the load address of that map.
- * Otherwise it's a run-time allocated common
- * whose value is already up-to-date.
- */
- relocation = np->nz_value;
- if (src_map)
- relocation += (long)src_map->som_addr;
-
- if (RELOC_JMPTAB_P(r)) {
- md_bind_jmpslot(relocation, addr);
- continue;
- }
-
- relocation += md_get_addend(r, addr);
-
- if (RELOC_PCREL_P(r))
- relocation -= (long)smp->som_addr;
-
- if (RELOC_COPY_P(r) && src_map) {
- (void)enter_rts(sym, sym_hash(sym),
- (long)addr,
- N_DATA + N_EXT,
- src_map->som_addr + np->nz_value,
- np->nz_size, src_map);
- continue;
- }
-
- md_relocate(r, relocation, addr, 0);
- } else {
- md_relocate(r,
-#ifdef SUN_COMPAT
- md_get_rt_segment_addend(r, addr)
-#else
- md_get_addend(r, addr)
-#endif
- + (long)smp->som_addr, addr, 0);
- }
-
- }
-
- if (smp->som_write) {
- if (mprotect(smp->som_addr + LM_TXTADDR(smp),
- LD_TEXTSZ(smp->som_dynamic),
- PROT_READ|PROT_EXEC) == -1) {
- generror ("mprotect failed for \"%s\" : %s",
- smp->som_path, strerror (errno));
- return -1;
- }
- smp->som_write = 0;
- }
- return 0;
-}
-
-static void
-reloc_copy(smp)
- struct so_map *smp;
-{
- struct rt_symbol *rtsp;
-
- for (rtsp = rt_symbol_head; rtsp; rtsp = rtsp->rt_next)
- if ((rtsp->rt_smp == NULL || rtsp->rt_smp == smp) &&
- rtsp->rt_sp->nz_type == N_DATA + N_EXT) {
- bcopy(rtsp->rt_srcaddr, (caddr_t)rtsp->rt_sp->nz_value,
- rtsp->rt_sp->nz_size);
- }
-}
-
-/*
- * Initialize the DAG of shared objects rooted at the given object.
- */
-static void
-init_dag(smp)
- struct so_map *smp;
-{
- struct somap_private *smpp = LM_PRIVATE(smp);
-
- if(!(smpp->spd_flags & RTLD_INIT)) { /* Not initialized yet */
- smpp->spd_flags |= RTLD_INIT;
-
- /* Make sure all the children are initialized */
- if(smpp->spd_children != NULL)
- init_sods(smpp->spd_children);
-
- if(call_map(smp, ".init") == -1)
- call_map(smp, "__init");
- }
-}
-
-static void
-init_sods(solp)
- struct so_list *solp;
-{
- /* Recursively initialize the rest of the list */
- if(solp->sol_next != NULL)
- init_sods(solp->sol_next);
-
- /* Initialize the first element of the list */
- init_dag(solp->sol_map);
-}
-
-
-/*
- * Call a function in a given shared object. SMP is the shared object, and
- * SYM is the name of the function.
- *
- * Returns 0 on success, or -1 if the symbol was not found. Failure is not
- * necessarily an error condition, so no error message is generated.
- */
-static int
-call_map(smp, sym)
- struct so_map *smp;
- char *sym;
-{
- struct so_map *src_map = smp;
- struct nzlist *np;
-
- np = lookup(sym, &src_map, 1);
- if (np) {
- (*(void (*)())(src_map->som_addr + np->nz_value))();
- return 0;
- }
-
- return -1;
-}
-
-/*
- * Run-time common symbol table.
- */
-
-#define RTC_TABSIZE 57
-static struct rt_symbol *rt_symtab[RTC_TABSIZE];
-
-/*
- * Look up a symbol in the run-time common symbol table. For efficiency,
- * the symbol's hash value must be passed in too.
- */
-static inline struct rt_symbol *
-lookup_rts(name, hash)
- char *name;
- unsigned long hash;
-{
- register struct rt_symbol *rtsp;
-
- for (rtsp = rt_symtab[hash % RTC_TABSIZE]; rtsp; rtsp = rtsp->rt_link)
- if (strcmp(name, rtsp->rt_sp->nz_name) == 0)
- return rtsp;
-
- return NULL;
-}
-
-/*
- * Enter a symbol into the run-time common symbol table. For efficiency,
- * the symbol's hash value must be passed in too.
- */
-static struct rt_symbol *
-enter_rts(name, hash, value, type, srcaddr, size, smp)
- char *name;
- unsigned long hash;
- long value;
- int type;
- caddr_t srcaddr;
- long size;
- struct so_map *smp;
-{
- register struct rt_symbol *rtsp, **rpp;
-
- /* Find end of bucket */
- for (rpp = &rt_symtab[hash % RTC_TABSIZE]; *rpp; rpp = &(*rpp)->rt_link)
- continue;
-
- /* Allocate new common symbol */
- rtsp = (struct rt_symbol *)xmalloc(sizeof(struct rt_symbol));
- rtsp->rt_sp = (struct nzlist *)xmalloc(sizeof(struct nzlist));
- rtsp->rt_sp->nz_name = strdup(name);
- rtsp->rt_sp->nz_value = value;
- rtsp->rt_sp->nz_type = type;
- rtsp->rt_sp->nz_size = size;
- rtsp->rt_srcaddr = srcaddr;
- rtsp->rt_smp = smp;
- rtsp->rt_link = NULL;
-
- /* Link onto linear list as well */
- rtsp->rt_next = rt_symbol_head;
- rt_symbol_head = rtsp;
-
- *rpp = rtsp;
-
- return rtsp;
-}
-
-
-/*
- * Lookup NAME in the link maps. The link map producing a definition
- * is returned in SRC_MAP. If SRC_MAP is not NULL on entry the search
- * is confined to that map.
- *
- * REAL_DEF_ONLY is a boolean which specifies whether certain special
- * symbols for functions should satisfy the lookup or not. The
- * reasons behind it are somewhat complicated. They are motivated
- * by the scenario in which the address of a single function is
- * taken from several shared objects. The address should come out
- * the same in all cases, because the application code might decide
- * to use it in comparisons. To make this work, the linker creates
- * a symbol entry for the function in the main executable, with a
- * type of N_UNDF+N_EXT, an N_AUX of AUX_FUNC, and a value that
- * refers to the PLT entry for the function in the main executable.
- * If REAL_DEF_ONLY is false, then this kind of special symbol is
- * considered a "definition" when lookup up the symbol. Since the
- * main executable is at the beginning of the shared object search
- * list, the result is that references from all shared objects will
- * resolve to the main program's PLT entry, and thus the function
- * addresses will compare equal as they should.
- *
- * When relocating the PLT entry itself, we obviously must match
- * only the true defining symbol for the function. In that case, we
- * set REAL_DEF_ONLY to true, which disables matching the special
- * N_UNDF+N_EXT entries.
- *
- * It is not so clear how to set this flag for a lookup done from
- * dlsym. If the lookup specifies a particular shared object other
- * than the main executable, the flag makes no difference -- only the
- * true definition will be matched. (That is because the special
- * symbols are only present in the main executable, which will not
- * be searched.) But when the lookup is over all the shared objects
- * (i.e., dlsym's "fd" parameter is NULL), then the flag does have an
- * effect. We elect to match only the true definition even in that
- * case.
- *
- * The upshot of all this is the following rule of thumb: Set
- * REAL_DEF_ONLY in all cases except when processing a non-PLT
- * relocation.
- */
-static struct nzlist *
-lookup(name, src_map, real_def_only)
- char *name;
- struct so_map **src_map; /* IN/OUT */
- int real_def_only;
-{
- unsigned long hash;
-
- hash = sym_hash(name);
-
- if (*src_map != NULL) /* Look in just one specific object */
- return lookup_in_obj(name, hash, *src_map, real_def_only);
- else { /* Search runtime symbols and all loaded objects */
- unsigned long common_size;
- struct so_map *smp;
- struct rt_symbol *rtsp;
- struct nzlist *np;
-
- if ((rtsp = lookup_rts(name, hash)) != NULL)
- return rtsp->rt_sp;
-
- common_size = 0;
- for (smp = link_map_head; smp; smp = smp->som_next) {
- if (LM_PRIVATE(smp)->spd_flags & RTLD_RTLD)
- continue;
- np = lookup_in_obj(name, hash, smp, real_def_only);
- if (np == NULL)
- continue;
- /* We know that np->nz_value > 0 at this point. */
- if (np->nz_type == N_UNDF+N_EXT &&
- N_AUX(&np->nlist) != AUX_FUNC) { /* Common */
- if (common_size < np->nz_value)
- common_size = np->nz_value;
- continue;
- }
-
- /* We found the symbol definition. */
- *src_map = smp;
- return np;
- }
- if (common_size > 0) { /* It is a common symbol. */
- void *mem;
-
- mem = memset(xmalloc(common_size), 0, common_size);
- rtsp = enter_rts(name, hash, (long)mem, N_UNDF + N_EXT,
- 0, common_size, NULL);
- return rtsp->rt_sp;
- }
-
- /* No definition was found for the symbol. */
- return NULL;
- }
-}
-
-/*
- * Lookup a symbol in one specific shared object. The hash
- * value is passed in for efficiency. For an explanation of the
- * "real_def_only" flag, see the comment preceding the "lookup"
- * function.
- */
-static struct nzlist *
-lookup_in_obj(name, hash, smp, real_def_only)
- char *name;
- unsigned long hash;
- struct so_map *smp;
- int real_def_only;
-{
- unsigned long buckets;
- struct rrs_hash *hp;
- char *cp;
- struct nzlist *np;
- char *symbolbase;
- struct rrs_hash *hashbase;
- char *stringbase;
- size_t symsize;
-
- if ((buckets = LD_BUCKETS(smp->som_dynamic)) == 0)
- return NULL;
-
- hashbase = LM_HASH(smp);
-
-restart:
- hp = &hashbase[hash % buckets];
- if (hp->rh_symbolnum == -1)
- return NULL;
-
- symbolbase = (char *)LM_SYMBOL(smp, 0);
- stringbase = LM_STRINGS(smp);
- symsize = LD_VERSION_NZLIST_P(smp->som_dynamic->d_version)?
- sizeof(struct nzlist) : sizeof(struct nlist);
- for ( ; ; ) {
- np = (struct nzlist *)(symbolbase + hp->rh_symbolnum*symsize);
- cp = stringbase + np->nz_strx;
- if (strcmp(cp, name) == 0)
- break;
- if (hp->rh_next == 0) /* End of hash chain */
- return NULL;
- hp = hashbase + hp->rh_next;
- }
-
- /*
- * We have a symbol with the name we're looking for.
- */
- if (np->nz_type == N_INDR+N_EXT) {
- /*
- * Next symbol gives the aliased name. Restart
- * search with new name.
- */
- name = stringbase + (++np)->nz_strx;
- hash = sym_hash(name);
- goto restart;
- }
-
- if (np->nz_value == 0) /* It's not a definition */
- return NULL;
-
- if (real_def_only) /* Don't match special function symbols. */
- if (np->nz_type == N_UNDF+N_EXT &&
- N_AUX(&np->nlist) == AUX_FUNC)
- return NULL;
-
- return np;
-}
-
-/*
- * Return the value of a symbol in the user's program. This is used
- * internally for a few symbols which must exist. If the requested
- * symbol is not found, this simply exits with a fatal error.
- */
-static void *
-sym_addr(name)
- char *name;
-{
- struct so_map *smp;
- struct nzlist *np;
-
- smp = NULL;
- np = lookup(name, &smp, 1);
- if (np == NULL)
- errx(1, "Program has no symbol \"%s\"", name);
- return ((smp == NULL) ? NULL : smp->som_addr) + np->nz_value;
-}
-
-/*
- * This routine is called from the jumptable to resolve
- * procedure calls to shared objects.
- */
-long
-binder(jsp)
- jmpslot_t *jsp;
-{
- struct so_map *smp, *src_map = NULL;
- long addr;
- char *sym;
- struct nzlist *np;
- int index;
-
- /*
- * Find the PLT map that contains JSP.
- */
- for (smp = link_map_head; smp; smp = smp->som_next) {
- if (LM_PLT(smp) < jsp &&
- jsp < LM_PLT(smp) + LD_PLTSZ(smp->som_dynamic)/sizeof(*jsp))
- break;
- }
-
- if (smp == NULL)
- errx(1, "Call to binder from unknown location: %p\n", jsp);
-
- index = jsp->reloc_index & JMPSLOT_RELOC_MASK;
-
- /* Get the local symbol this jmpslot refers to */
- sym = LM_STRINGS(smp) +
- LM_SYMBOL(smp,RELOC_SYMBOL(&LM_REL(smp)[index]))->nz_strx;
-
- np = lookup(sym, &src_map, 1);
- if (np == NULL)
- errx(1, "Undefined symbol \"%s\" called from %s:%s at %p",
- sym, main_progname, smp->som_path, jsp);
-
- /* Fixup jmpslot so future calls transfer directly to target */
- addr = np->nz_value;
- if (src_map)
- addr += (long)src_map->som_addr;
-
- md_fix_jmpslot(jsp, (long)jsp, addr);
-
-#if DEBUG
- xprintf(" BINDER: %s located at = %#x in %s\n", sym, addr,
- src_map->som_path);
-#endif
- return addr;
-}
-
-static struct hints_header *hheader; /* NULL means not mapped */
-static struct hints_bucket *hbuckets;
-static char *hstrtab;
-
-/*
- * Map the hints file into memory, if it is not already mapped. Returns
- * 0 on success, or -1 on failure.
- */
-static int
-maphints __P((void))
-{
- static int hints_bad; /* TRUE if hints are unusable */
- static int paths_added;
- int hfd;
- struct hints_header hdr;
- caddr_t addr;
-
- if (hheader != NULL) /* Already mapped */
- return 0;
-
- if (hints_bad) /* Known to be corrupt or unavailable */
- return -1;
-
- if ((hfd = open(_PATH_LD_HINTS, O_RDONLY, 0)) == -1) {
- hints_bad = 1;
- return -1;
- }
-
- /* Read the header and check it */
-
- if (read(hfd, &hdr, sizeof hdr) != sizeof hdr ||
- HH_BADMAG(hdr) ||
- (hdr.hh_version != LD_HINTS_VERSION_1 &&
- hdr.hh_version != LD_HINTS_VERSION_2)) {
- close(hfd);
- hints_bad = 1;
- return -1;
- }
-
- /* Map the hints into memory */
-
- addr = mmap(0, hdr.hh_ehints, PROT_READ, MAP_SHARED, hfd, 0);
- if (addr == (caddr_t)-1) {
- close(hfd);
- hints_bad = 1;
- return -1;
- }
-
- close(hfd);
-
- hheader = (struct hints_header *)addr;
- hbuckets = (struct hints_bucket *)(addr + hheader->hh_hashtab);
- hstrtab = (char *)(addr + hheader->hh_strtab);
- /* pluck out the system ldconfig path */
- if (hheader->hh_version >= LD_HINTS_VERSION_2 && !paths_added) {
- add_search_path(hstrtab + hheader->hh_dirlist);
- paths_added = 1;
- }
-
- return 0;
-}
-
-/*
- * Unmap the hints file, if it is currently mapped.
- */
-static void
-unmaphints()
-{
- if (hheader != NULL) {
- munmap((caddr_t)hheader, hheader->hh_ehints);
- hheader = NULL;
- }
-}
-
-int
-hinthash(cp, vmajor)
- char *cp;
- int vmajor;
-{
- int k = 0;
-
- while (*cp)
- k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff;
-
- k = (((k << 1) + (k >> 14)) ^ (vmajor*257)) & 0x3fff;
-
- return k;
-}
-
-#undef major
-#undef minor
-
-/*
- * Search for a library in the hints generated by ldconfig. On success,
- * returns the full pathname of the matching library. This string is
- * always dynamically allocated on the heap.
- *
- * Returns the minor number of the matching library via the pointer
- * argument MINORP.
- *
- * Returns NULL if the library cannot be found.
- */
-static char *
-findhint(name, major, minorp)
- char *name;
- int major;
- int *minorp;
-{
- struct hints_bucket *bp =
- hbuckets + (hinthash(name, major) % hheader->hh_nbucket);
-
- while (1) {
- /* Sanity check */
- if (bp->hi_namex >= hheader->hh_strtab_sz) {
- warnx("Bad name index: %#x\n", bp->hi_namex);
- break;
- }
- if (bp->hi_pathx >= hheader->hh_strtab_sz) {
- warnx("Bad path index: %#x\n", bp->hi_pathx);
- break;
- }
-
- /*
- * We accept the current hints entry if its name matches
- * and its major number matches. We don't have to search
- * for the best minor number, because that was already
- * done by "ldconfig" when it built the hints file.
- */
- if (strcmp(name, hstrtab + bp->hi_namex) == 0 &&
- bp->hi_major == major) {
- struct stat s;
-
- if (stat(hstrtab + bp->hi_pathx, &s) == -1)
- return NULL; /* Doesn't actually exist */
- *minorp = bp->hi_ndewey >= 2 ? bp->hi_minor : -1;
- return strdup(hstrtab + bp->hi_pathx);
- }
-
- if (bp->hi_next == -1)
- break;
-
- /* Move on to next in bucket */
- bp = &hbuckets[bp->hi_next];
- }
-
- /* No hints available for name */
- return NULL;
-}
-
-/*
- * Search for the given shared library. On success, returns a string
- * containing the full pathname for the library. This string is always
- * dynamically allocated on the heap.
- *
- * Returns NULL if the library cannot be found.
- */
-static char *
-rtfindlib(name, major, minor)
- char *name;
- int major, minor;
-{
- char *ld_path = ld_library_path;
- char *path = NULL;
- int realminor = -1;
-
- if (ld_path != NULL) { /* First, search the directories in ld_path */
- /*
- * There is no point in trying to use the hints file for this.
- */
- char *dir;
-
- while (path == NULL && (dir = strsep(&ld_path, ":")) != NULL) {
- path = search_lib_dir(dir, name, &major, &realminor, 0);
- if (ld_path != NULL)
- *(ld_path - 1) = ':';
- }
- }
-
- if (path == NULL && maphints() == 0) /* Search the hints file */
- path = findhint(name, major, &realminor);
-
- if (path == NULL) /* Search the standard directories */
- path = findshlib(name, &major, &realminor, 0);
-
- if (path != NULL && realminor < minor && !ld_suppress_warnings) {
- warnx("warning: %s: minor version %d"
- " older than expected %d, using it anyway",
- path, realminor, minor);
- }
-
- return path;
-}
-
-/*
- * Search for the given shared library file. This is similar to rtfindlib,
- * except that the argument is the actual name of the desired library file.
- * Thus there is no need to worry about version numbers. The return value
- * is a string containing the full pathname for the library. This string
- * is always dynamically allocated on the heap.
- *
- * Returns NULL if the library cannot be found.
- */
-static char *
-rtfindfile(name)
- char *name;
-{
- char *ld_path = ld_library_path;
- char *path = NULL;
-
- if (ld_path != NULL) { /* First, search the directories in ld_path */
- char *dir;
-
- while (path == NULL && (dir = strsep(&ld_path, ":")) != NULL) {
- struct stat sb;
-
- path = concat(dir, "/", name);
- if (lstat(path, &sb) == -1) { /* Does not exist */
- free(path);
- path = NULL;
- }
- if (ld_path != NULL)
- *(ld_path - 1) = ':';
- }
- }
-
- /*
- * We don't search the hints file. It is organized around major
- * and minor version numbers, so it is not suitable for finding
- * a specific file name.
- */
-
- if (path == NULL) /* Search the standard directories */
- path = find_lib_file(name);
-
- return path;
-}
-
-/*
- * Buffer for error messages and a pointer that is set to point to the buffer
- * when a error occurs. It acts as a last error flag, being set to NULL
- * after an error is returned.
- */
-#define DLERROR_BUF_SIZE 512
-static char dlerror_buf [DLERROR_BUF_SIZE];
-static char *dlerror_msg = NULL;
-
-
-static void *
-__dlopen(path, mode)
- const char *path;
- int mode;
-{
- struct so_map *old_tail = link_map_tail;
- struct so_map *smp;
- int bind_now = mode == RTLD_NOW;
-
- /*
- * path == NULL is handled by map_object()
- */
-
- anon_open();
-
- /* Map the object, and the objects on which it depends */
- smp = map_object(path, (struct sod *) NULL, (struct so_map *) NULL);
- if(smp == NULL) /* Failed */
- return NULL;
- LM_PRIVATE(smp)->spd_flags |= RTLD_DL;
-
- /* Relocate and initialize all newly-mapped objects */
- if(link_map_tail != old_tail) { /* We have mapped some new objects */
- if(reloc_dag(smp, bind_now) == -1) /* Failed */
- return NULL;
- init_dag(smp);
- }
-
- unmaphints();
- anon_close();
-
- return smp;
-}
-
-static int
-__dlclose(fd)
- void *fd;
-{
- struct so_map *smp = (struct so_map *)fd;
- struct so_map *scanp;
-
-#ifdef DEBUG
- xprintf("dlclose(%s): refcount = %d\n", smp->som_path,
- LM_PRIVATE(smp)->spd_refcount);
-#endif
- /* Check the argument for validity */
- for(scanp = link_map_head; scanp != NULL; scanp = scanp->som_next)
- if(scanp == smp) /* We found the map in the list */
- break;
- if(scanp == NULL || !(LM_PRIVATE(smp)->spd_flags & RTLD_DL)) {
- generror("Invalid argument to dlclose");
- return -1;
- }
-
- unmap_object(smp, 0);
-
- return 0;
-}
-
-/*
- * This form of dlsym is obsolete. Current versions of crt0 don't call
- * it. It can still be called by old executables that were linked with
- * old versions of crt0.
- */
-static void *
-__dlsym(fd, sym)
- void *fd;
- const char *sym;
-{
- if (fd == RTLD_NEXT) {
- generror("RTLD_NEXT not supported by this version of"
- " /usr/lib/crt0.o");
- return NULL;
- }
- return __dlsym3(fd, sym, NULL);
-}
-
-static void *
-resolvesym(fd, sym, retaddr)
- void *fd;
- char *sym;
- void *retaddr;
-{
- struct so_map *smp;
- struct so_map *src_map;
- struct nzlist *np;
- long addr;
-
- if (fd == RTLD_NEXT) {
- /* Find the shared object that contains the caller. */
- for (smp = link_map_head; smp != NULL; smp = smp->som_next) {
- void *textbase = smp->som_addr + LM_TXTADDR(smp);
- void *textlimit = LM_ETEXT(smp);
-
- if (textbase <= retaddr && retaddr < textlimit)
- break;
- }
- if (smp == NULL) {
- generror("Cannot determine caller's shared object");
- return NULL;
- }
- smp = smp->som_next;
- if (smp != NULL && LM_PRIVATE(smp)->spd_flags & RTLD_RTLD)
- smp = smp->som_next;
- if (smp == NULL) {
- generror("No next shared object for RTLD_NEXT");
- return NULL;
- }
- do {
- src_map = smp;
- np = lookup(sym, &src_map, 1);
- } while (np == NULL && (smp = smp->som_next) != NULL);
- } else {
- smp = (struct so_map *)fd;
- src_map = NULL;
-
- /*
- * Restrict search to passed map if dlopen()ed.
- */
- if (smp != NULL && LM_PRIVATE(smp)->spd_flags & RTLD_DL)
- src_map = smp;
-
- np = lookup(sym, &src_map, 1);
- }
-
- if (np == NULL) {
- generror("Undefined symbol");
- return NULL;
- }
-
- addr = np->nz_value;
- if (src_map)
- addr += (long)src_map->som_addr;
-
- return (void *)addr;
-}
-
-static void *
-__dlsym3(fd, sym, retaddr)
- void *fd;
- const char *sym;
- void *retaddr;
-{
- void *result;
-
- result = resolvesym(fd, sym, retaddr);
- /*
- * XXX - Ugly, but it makes the least impact on the run-time loader
- * sources. We assume that most of the time the error is a
- * undefined symbol error from above, so we try again. If it's
- * not an undefined symbol we end up getting the same error twice,
- * but that's acceptable.
- */
- if (result == NULL) {
- /* Prepend an underscore and try again */
- char *newsym = xmalloc(strlen(sym) + 2);
-
- newsym[0] = '_';
- strcpy(&newsym[1], sym);
- result = resolvesym(fd, newsym, retaddr);
- free(newsym);
- }
- return result;
-}
-
-static const char *
-__dlerror __P((void))
-{
- const char *err;
-
- err = dlerror_msg;
- dlerror_msg = NULL; /* Next call will return NULL */
-
- return err;
-}
-
-static void
-__dlexit __P((void))
-{
-#ifdef DEBUG
-xprintf("__dlexit called\n");
-#endif
-
- unmap_object(link_map_head, 1);
-}
-
-/*
- * Print the current error message and exit with failure status.
- */
-static void
-die __P((void))
-{
- const char *msg;
-
- fprintf(stderr, "ld.so failed");
- if ((msg = __dlerror()) != NULL)
- fprintf(stderr, ": %s", msg);
- putc('\n', stderr);
- _exit(1);
-}
-
-
-/*
- * Generate an error message that can be later be retrieved via dlerror.
- */
-static void
-#if __STDC__
-generror(char *fmt, ...)
-#else
-generror(fmt, va_alist)
-char *fmt;
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- vsnprintf (dlerror_buf, DLERROR_BUF_SIZE, fmt, ap);
- dlerror_msg = dlerror_buf;
-
- va_end(ap);
-}
-
-void
-#if __STDC__
-xprintf(char *fmt, ...)
-#else
-xprintf(fmt, va_alist)
-char *fmt;
-#endif
-{
- char buf[256];
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
-
- vsnprintf(buf, sizeof(buf), fmt, ap);
- (void)write(1, buf, strlen(buf));
- va_end(ap);
-}
-
-/*
- * rt_readenv() etc.
- *
- * Do a sweep over the environment once only, pick up what
- * looks interesting.
- *
- * This is pretty obscure, but is relatively simple. Simply
- * look at each environment variable, if it starts with "LD_" then
- * look closer at it. If it's in our table, set the variable
- * listed. effectively, this is like:
- * ld_preload = careful ? NULL : getenv("LD_PRELOAD");
- * except that the environment is scanned once only to pick up all
- * known variables, rather than scanned multiple times for each
- * variable.
- *
- * If an environment variable of interest is set to the empty string, we
- * treat it as if it were unset.
- */
-
-#define L(n, u, v) { n, sizeof(n) - 1, u, v },
-struct env_scan_tab {
- char *name;
- int len;
- int unsafe;
- char **value;
-} scan_tab[] = {
- L("LD_LIBRARY_PATH=", 1, &ld_library_path)
- L("LD_PRELOAD=", 1, &ld_preload)
- L("LD_IGNORE_MISSING_OBJECTS=", 1, &ld_ignore_missing_objects)
- L("LD_TRACE_LOADED_OBJECTS=", 0, &ld_tracing)
- L("LD_BIND_NOW=", 0, &ld_bind_now)
- L("LD_SUPPRESS_WARNINGS=", 0, &ld_suppress_warnings)
- L("LD_WARN_NON_PURE_CODE=", 0, &ld_warn_non_pure_code)
- { NULL, 0, 0, NULL }
-};
-#undef L
-
-static void
-rt_readenv()
-{
- char **p = environ;
- char *v;
- struct env_scan_tab *t;
-
- /* for each string in the environment... */
- while ((v = *p++)) {
-
- /* check for LD_xxx */
- if (v[0] != 'L' || v[1] != 'D' || v[2] != '_')
- continue;
-
- for (t = scan_tab; t->name; t++) {
- if (careful && t->unsafe)
- continue; /* skip for set[ug]id */
- if (strncmp(t->name, v, t->len) == 0) {
- if (*(v + t->len) != '\0') /* Not empty */
- *t->value = v + t->len;
- break;
- }
- }
- }
-}
-
-/*
- * Malloc implementation for use within the dynamic linker. At first
- * we do a simple allocation using sbrk. After the user's program
- * has been loaded, we switch to using whatever malloc functions are
- * defined there.
- */
-
-/* Symbols related to the sbrk and brk implementations. */
-#define CURBRK_SYM "curbrk"
-#define MINBRK_SYM "minbrk"
-#define END_SYM "_end"
-
-/* Symbols related to malloc. */
-#define FREE_SYM "_free"
-#define MALLOC_SYM "_malloc"
-#define REALLOC_SYM "_realloc"
-
-/* Hooks into the implementation of sbrk and brk. */
-extern char *curbrk __asm__(CURBRK_SYM);
-extern char *minbrk __asm__(MINBRK_SYM);
-
-/* Pointers to the user program's malloc functions. */
-static void *(*p_malloc) __P((size_t));
-static void *(*p_realloc) __P((void *, size_t));
-static void (*p_free) __P((void *));
-
-/* Upper limit of the memory allocated by our internal malloc. */
-static char *rtld_alloc_lev;
-
-/*
- * Set up the internal malloc so that it will take its memory from the
- * main program's sbrk arena.
- */
-static void
-init_internal_malloc __P((void))
-{
- const struct exec *hdr;
-
- /*
- * Before anything calls sbrk or brk, we have to initialize
- * its idea of the current break level to just beyond the main
- * program's address space. Strictly speaking, the right
- * way to do that is to look up the value of "_end" in the
- * application's run time symbol table.
- *
- * That is what we used to do, and it works correctly for
- * every valid program. Unfortunately, it doesn't work right
- * for "unexec"ed versions of emacs. They are incorrectly
- * generated with a wrong value for "_end". (xemacs gets it
- * right.)
- *
- * To work around this, we peek at the exec header to get the
- * sizes of the text, data, and bss segments. Luckily, the
- * header is in memory at the start of the first mapped page.
- * From the segment sizes, we can calculate a proper initial
- * value for the break level.
- */
- hdr = (const struct exec *)PAGSIZ;
- if (N_BADMAG(*hdr)) /* Sanity check */
- errx(1, "Cannot find program's a.out header");
- rtld_alloc_lev = curbrk = minbrk =
- (char *)hdr + hdr->a_text + hdr->a_data + hdr->a_bss;
-}
-
-/*
- * Set things up so that the dynamic linker can use the program's
- * malloc functions.
- */
-static void
-init_external_malloc __P((void))
-{
- /*
- * Patch the program's idea of the current break address to
- * what it really is as a result of the allocations we have
- * already done.
- */
- *(char **)(sym_addr(CURBRK_SYM)) = curbrk;
-
- /*
- * Set the minimum break level too. Otherwise, "unexec"ed
- * emacs sets the break too low and wipes out our tables of
- * shared objects.
- */
- *(char **)(sym_addr(MINBRK_SYM)) = curbrk;
-
- /*
- * Set up pointers to the program's allocation functions, so
- * that we can use them from now on.
- */
- p_malloc = (void *(*)(size_t))(sym_addr(MALLOC_SYM));
- p_free = (void (*)(void *))(sym_addr(FREE_SYM));
- p_realloc = (void *(*)(void *, size_t))(sym_addr(REALLOC_SYM));
-}
-
-void *
-malloc(size)
- size_t size;
-{
- char *p;
-
- /* If we are far enough along, we can use the system malloc. */
- if (p_malloc != NULL)
- return (*p_malloc)(size);
-
- /*
- * Otherwise we use our simple built-in malloc. We get the
- * memory from brk() in increments of one page. We store the
- * allocated size in the first word, so that realloc can be
- * made to work.
- */
- if (rtld_alloc_lev == NULL)
- errx(1, "Internal error: internal malloc called before"
- " being initialized");
-
- p = (char *)ALIGN(rtld_alloc_lev);
- rtld_alloc_lev = p + sizeof(size_t) + size;
-
- if (rtld_alloc_lev > curbrk) { /* Get memory from system */
- char *newbrk;
-
- newbrk = (char *)
- roundup2((unsigned long)rtld_alloc_lev, PAGSIZ);
- if (brk(newbrk) == (char *)-1)
- return NULL;
- }
-
- *(size_t *)p = size;
- return p + sizeof(size_t);
-}
-
-void *
-realloc(ptr, size)
- void *ptr;
- size_t size;
-{
- size_t old_size;
- void *new_ptr;
-
- if (ptr == NULL)
- return malloc(size);
-
- /*
- * If we are far enough along, and if the memory originally came
- * from the system malloc, we can use the system realloc.
- */
- if (p_realloc != NULL && (char *)ptr >= rtld_alloc_lev)
- return (*p_realloc)(ptr, size);
-
- old_size = *((size_t *)ptr - 1);
- if (old_size >= size) /* Not expanding the region */
- return ptr;
-
- new_ptr = malloc(size);
- if (new_ptr != NULL)
- memcpy(new_ptr, ptr, old_size);
- return new_ptr;
-}
-
-void
-free(ptr)
- void *ptr;
-{
- if (ptr == NULL)
- return;
-
- /*
- * If we are far enough along, and if the memory originally came
- * from the system malloc, we can use the system free. Otherwise
- * we can't free the memory and we just let it go to waste.
- */
- if (p_free != NULL && (char *)ptr >= rtld_alloc_lev)
- (*p_free)(ptr);
-}
diff --git a/gnu/usr.bin/ld/shlib.c b/gnu/usr.bin/ld/shlib.c
deleted file mode 100644
index efb0bb6..0000000
--- a/gnu/usr.bin/ld/shlib.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id$
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <a.out.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <err.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <link.h>
-#include "shlib.h"
-#include "support.h"
-
-/*
- * Standard directories to search for files specified by -l.
- */
-#ifndef STANDARD_SEARCH_DIRS
-#define STANDARD_SEARCH_DIRS "/usr/lib"
-#endif
-
-/*
- * Actual vector of library search directories,
- * including `-L'ed and LD_LIBRARY_PATH spec'd ones.
- */
-char **search_dirs;
-int n_search_dirs;
-
-char *standard_search_dirs[] = {
- STANDARD_SEARCH_DIRS
-};
-
-
-void
-add_search_dir(name)
- char *name;
-{
- int n;
-
- for (n = 0; n < n_search_dirs; n++)
- if (strcmp(search_dirs[n], name) == 0)
- return;
- n_search_dirs++;
- search_dirs = (char **)
- xrealloc(search_dirs, n_search_dirs * sizeof search_dirs[0]);
- search_dirs[n_search_dirs - 1] = strdup(name);
-}
-
-void
-add_search_path(path)
-char *path;
-{
- register char *cp, *dup;
-
- if (path == NULL)
- return;
-
- /* Add search directories from `path' */
- path = dup = strdup(path);
- while ((cp = strsep(&path, ":")) != NULL)
- add_search_dir(cp);
- free(dup);
-}
-
-void
-std_search_path()
-{
- int i, n;
-
- /* Append standard search directories */
- n = sizeof standard_search_dirs / sizeof standard_search_dirs[0];
- for (i = 0; i < n; i++)
- add_search_dir(standard_search_dirs[i]);
-}
-
-/*
- * Return true if CP points to a valid dewey number.
- * Decode and leave the result in the array DEWEY.
- * Return the number of decoded entries in DEWEY.
- */
-
-int
-getdewey(dewey, cp)
-int dewey[];
-char *cp;
-{
- int i, n;
-
- for (n = 0, i = 0; i < MAXDEWEY; i++) {
- if (*cp == '\0')
- break;
-
- if (*cp == '.') cp++;
- if (!isdigit(*cp))
- return 0;
-
- dewey[n++] = strtol(cp, &cp, 10);
- }
-
- return n;
-}
-
-/*
- * Compare two dewey arrays.
- * Return -1 if `d1' represents a smaller value than `d2'.
- * Return 1 if `d1' represents a greater value than `d2'.
- * Return 0 if equal.
- */
-int
-cmpndewey(d1, n1, d2, n2)
-int d1[], d2[];
-int n1, n2;
-{
- register int i;
-
- for (i = 0; i < n1 && i < n2; i++) {
- if (d1[i] < d2[i])
- return -1;
- if (d1[i] > d2[i])
- return 1;
- }
-
- if (n1 == n2)
- return 0;
-
- if (i == n1)
- return -1;
-
- if (i == n2)
- return 1;
-
- errx(1, "cmpndewey: cant happen");
- return 0;
-}
-
-/*
- * Search directories for a shared library matching the given
- * major and minor version numbers. See search_lib_dir() below for
- * the detailed matching rules.
- *
- * As soon as a directory with an acceptable match is found, the search
- * terminates. Subsequent directories are not searched for a better
- * match. This is in conformance with the SunOS searching rules. Also,
- * it avoids a lot of directory searches that are virtually guaranteed to
- * be fruitless.
- *
- * The return value is a full pathname to the matching library. The
- * string is dynamically allocated. If no matching library is found, the
- * function returns NULL.
- */
-
-char *
-findshlib(name, majorp, minorp, do_dot_a)
-char *name;
-int *majorp, *minorp;
-int do_dot_a;
-{
- int i;
-
- for (i = 0; i < n_search_dirs; i++) {
- char *path;
-
- path = search_lib_dir(search_dirs[i], name, majorp, minorp,
- do_dot_a);
- if(path != NULL)
- return path;
- }
-
- return NULL;
-}
-
-/*
- * Search library directories for a file with the given name. The
- * return value is a full pathname to the matching file. The string
- * is dynamically allocated. If no matching file is found, the function
- * returns NULL.
- */
-
-char *
-find_lib_file(name)
- char *name;
-{
- int i;
-
- for (i = 0; i < n_search_dirs; i++) {
- char *path = concat(search_dirs[i], "/", name);
- struct stat sb;
-
- if (lstat(path, &sb) != -1) /* We found it */
- return path;
-
- free(path);
- }
-
- return NULL;
-}
-
-/*
- * Search a given directory for a library (preferably shared) satisfying
- * the given criteria.
- *
- * The matching rules are as follows:
- *
- * if(*majorp == -1)
- * find the library with the highest major version;
- * else
- * insist on a major version identical to *majorp;
- *
- * Always find the library with the highest minor version;
- * if(*minorp != -1)
- * insist on a minor version >= *minorp;
- *
- * It is invalid to specify a specific minor number while wildcarding
- * the major number.
- *
- * The actual major and minor numbers found are returned via the pointer
- * arguments.
- *
- * A suitable shared library is always preferred over a static (.a) library.
- * If do_dot_a is false, then a static library will not be accepted in
- * any case.
- *
- * The return value is a full pathname to the matching library. The
- * string is dynamically allocated. If no matching library is found, the
- * function returns NULL.
- */
-
-char *
-search_lib_dir(dir, name, majorp, minorp, do_dot_a)
- char *dir;
- char *name;
- int *majorp;
- int *minorp;
- int do_dot_a;
-{
- int namelen;
- DIR *dd;
- struct dirent *dp;
- int best_dewey[MAXDEWEY];
- int best_ndewey;
- char dot_a_name[MAXNAMLEN+1];
- char dot_so_name[MAXNAMLEN+1];
-
- if((dd = opendir(dir)) == NULL)
- return NULL;
-
- namelen = strlen(name);
- best_ndewey = 0;
- dot_a_name[0] = '\0';
- dot_so_name[0] = '\0';
-
- while((dp = readdir(dd)) != NULL) {
- char *extension;
-
- if(strlen(dp->d_name) < 3 + namelen + 2 || /* lib+xxx+.a */
- strncmp(dp->d_name, "lib", 3) != 0 ||
- strncmp(dp->d_name + 3, name, namelen) != 0 ||
- dp->d_name[3+namelen] != '.')
- continue;
-
- extension = dp->d_name + 3 + namelen + 1; /* a or so.* */
-
- if(strncmp(extension, "so.", 3) == 0) {
- int cur_dewey[MAXDEWEY];
- int cur_ndewey;
-
- cur_ndewey = getdewey(cur_dewey, extension+3);
- if(cur_ndewey == 0) /* No version number */
- continue;
-
- if(*majorp != -1) { /* Need exact match on major */
- if(cur_dewey[0] != *majorp)
- continue;
- if(*minorp != -1) { /* Need minor >= minimum */
- if(cur_ndewey < 2 ||
- cur_dewey[1] < *minorp)
- continue;
- }
- }
-
- if(cmpndewey(cur_dewey, cur_ndewey, best_dewey,
- best_ndewey) <= 0) /* No better than prior match */
- continue;
-
- /* We found a better match */
- strcpy(dot_so_name, dp->d_name);
- bcopy(cur_dewey, best_dewey,
- cur_ndewey * sizeof best_dewey[0]);
- best_ndewey = cur_ndewey;
- } else if(do_dot_a && strcmp(extension, "a") == 0)
- strcpy(dot_a_name, dp->d_name);
- }
- closedir(dd);
-
- if(dot_so_name[0] != '\0') {
- *majorp = best_dewey[0];
- if(best_ndewey >= 2)
- *minorp = best_dewey[1];
- return concat(dir, "/", dot_so_name);
- }
-
- if(dot_a_name[0] != '\0')
- return concat(dir, "/", dot_a_name);
-
- return NULL;
-}
diff --git a/gnu/usr.bin/ld/shlib.h b/gnu/usr.bin/ld/shlib.h
deleted file mode 100644
index 796d37e..0000000
--- a/gnu/usr.bin/ld/shlib.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * Copyright (C) 1996
- * Peter Wemm. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *-
- * $Id$
- */
-
-/*
- * prototypes for shlib.c. Big deal.
- */
-
-extern char **search_dirs;
-extern int n_search_dirs;
-
-void add_search_dir __P((char *));
-void add_search_path __P((char *));
-void std_search_path __P((void));
-int getdewey __P((int[], char *));
-int cmpndewey __P((int[], int, int[], int));
-char *findshlib __P((char *, int *, int *, int));
-char *find_lib_file __P((char *));
-char *search_lib_dir __P((char *, char *, int *, int *, int));
diff --git a/gnu/usr.bin/ld/sparc/md-static-funcs.c b/gnu/usr.bin/ld/sparc/md-static-funcs.c
deleted file mode 100644
index 346bd8f..0000000
--- a/gnu/usr.bin/ld/sparc/md-static-funcs.c
+++ /dev/null
@@ -1,37 +0,0 @@
-
-/*
- * $Id$
- *
- * Simple SPARC relocations for the benefit of self-relocation of ld.so
- * avoiding the use of global variables (ie. reloc_bitshift[] et. al.).
- * Only types supported are RELOC_32 and RELOC_RELATIVE.
- *
- * This *must* be a static function, so it is not called through a jmpslot.
- */
-static void
-md_relocate_simple(r, relocation, addr)
-struct relocation_info *r;
-long relocation;
-char *addr;
-{
- register unsigned long mask;
- register unsigned long shift;
-
- switch (r->r_type) {
- case RELOC_32:
- mask = 0xffffffff;
- shift = 0;
- break;
- case RELOC_RELATIVE:
- mask = 0x003fffff;
- shift = 10;
- break;
- }
- relocation += (*(long *)addr & mask) << shift;
- relocation >>= shift;
- relocation &= mask;
-
- *(long *) (addr) &= ~mask;
- *(long *) (addr) |= relocation;
-}
-
diff --git a/gnu/usr.bin/ld/sparc/md.c b/gnu/usr.bin/ld/sparc/md.c
deleted file mode 100644
index b1af3dd..0000000
--- a/gnu/usr.bin/ld/sparc/md.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id$
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <a.out.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <err.h>
-#include <fcntl.h>
-#include <stab.h>
-#include <string.h>
-
-#include "dynamic.h"
-
-/*
- * Relocation masks and sizes for the Sparc architecture.
- *
- * Note that these are very dependent on the order of the enums in
- * enum reloc_type (in a.out.h); if they change the following must be
- * changed.
- * Also, note that RELOC_RELATIVE is handled as if it were a RELOC_HI22.
- * This should work provided that relocations values have zeroes in their
- * least significant 10 bits. As RELOC_RELATIVE is used only to relocate
- * with load address values - which are page aligned - this condition is
- * fulfilled as long as the system's page size is > 1024 (and a power of 2).
- */
-static int reloc_target_rightshift[] = {
- 0, 0, 0, /* RELOC_8, _16, _32 */
- 0, 0, 0, 2, 2, /* DISP8, DISP16, DISP32, WDISP30, WDISP22 */
- 10, 0, /* HI22, _22 */
- 0, 0, /* RELOC_13, _LO10 */
- 0, 0, /* _SFA_BASE, _SFA_OFF13 */
- 0, 0, 10, /* _BASE10, _BASE13, _BASE22 */
- 0, 10, /* _PC10, _PC22 */
- 2, 0, /* _JMP_TBL, _SEGOFF16 */
- 0, 0, 0 /* _GLOB_DAT, JMP_SLOT, _RELATIVE */
-};
-static int reloc_target_size[] = {
- 0, 1, 2, /* RELOC_8, _16, _32 */
- 0, 1, 2, 2, 2, /* DISP8, DISP16, DISP32, WDISP30, WDISP22 */
- 2, 2, /* HI22, _22 */
- 2, 2, /* RELOC_13, _LO10 */
- 2, 2, /* _SFA_BASE, _SFA_OFF13 */
- 2, 2, 2, /* _BASE10, _BASE13, _BASE22 */
- 2, 2, /* _PC10, _PC22 */
- 2, 0, /* _JMP_TBL, _SEGOFF16 */
- 2, 0, 2 /* _GLOB_DAT, JMP_SLOT, _RELATIVE */
-};
-static int reloc_target_bitsize[] = {
- 8, 16, 32, /* RELOC_8, _16, _32 */
- 8, 16, 32, 30, 22, /* DISP8, DISP16, DISP32, WDISP30, WDISP22 */
- 22, 22, /* HI22, _22 */
- 13, 10, /* RELOC_13, _LO10 */
- 32, 32, /* _SFA_BASE, _SFA_OFF13 */
- 10, 13, 22, /* _BASE10, _BASE13, _BASE22 */
- 10, 22, /* _PC10, _PC22 */
- 30, 0, /* _JMP_TBL, _SEGOFF16 */
- 32, 0, 22 /* _GLOB_DAT, JMP_SLOT, _RELATIVE */
-};
-
-
-/*
- * Get relocation addend corresponding to relocation record RP
- * ADDR unused by SPARC impl.
- */
-long
-md_get_addend(r, addr)
-struct relocation_info *r;
-unsigned char *addr;
-{
- return r->r_addend;
-}
-
-void
-md_relocate(r, relocation, addr, relocatable_output)
-struct relocation_info *r;
-long relocation;
-unsigned char *addr;
-int relocatable_output;
-{
- register unsigned long mask;
-
-#ifndef RTLD
- if (relocatable_output) {
- /*
- * Non-PC relative relocations which are absolute or
- * which have become non-external now have fixed
- * relocations. Set the ADD_EXTRA of this relocation
- * to be the relocation we have now determined.
- */
- if (!RELOC_PCREL_P(r)) {
- if ((int) r->r_type <= RELOC_32
- || RELOC_EXTERN_P(r) == 0)
- RELOC_ADD_EXTRA(r) = relocation;
- } else if (RELOC_EXTERN_P(r))
- /*
- * External PC-relative relocations continue
- * to move around; update their relocations
- * by the amount they have moved so far.
- */
- RELOC_ADD_EXTRA(r) -= pc_relocation;
- return;
- }
-#endif
-
- relocation >>= RELOC_VALUE_RIGHTSHIFT(r);
-
- /* Unshifted mask for relocation */
- mask = 1 << RELOC_TARGET_BITSIZE(r) - 1;
- mask |= mask - 1;
- relocation &= mask;
-
- /* Shift everything up to where it's going to be used */
- relocation <<= RELOC_TARGET_BITPOS(r);
- mask <<= RELOC_TARGET_BITPOS(r);
-
- switch (RELOC_TARGET_SIZE(r)) {
- case 0:
- if (RELOC_MEMORY_ADD_P(r))
- relocation += (mask & *(u_char *) (addr));
- *(u_char *) (addr) &= ~mask;
- *(u_char *) (addr) |= relocation;
- break;
-
- case 1:
- if (RELOC_MEMORY_ADD_P(r))
- relocation += (mask & *(u_short *) (addr));
- *(u_short *) (addr) &= ~mask;
- *(u_short *) (addr) |= relocation;
- break;
-
- case 2:
- if (RELOC_MEMORY_ADD_P(r))
- relocation += (mask & *(u_long *) (addr));
- *(u_long *) (addr) &= ~mask;
- *(u_long *) (addr) |= relocation;
- break;
- default:
- errx(1, "Unimplemented relocation field length: %d",
- RELOC_TARGET_SIZE(r));
- }
-}
-
-#ifndef RTLD
-/*
- * Machine dependent part of claim_rrs_reloc().
- * On the Sparc the relocation offsets are stored in the r_addend member.
- */
-int
-md_make_reloc(rp, r, type)
-struct relocation_info *rp, *r;
-int type;
-{
- r->r_type = rp->r_type;
- r->r_addend = rp->r_addend;
-
-#if 1
- /*
- * This wouldn't be strictly necessary - we could record the
- * relocation value "in situ" in stead of in the r_addend field -
- * but we are being Sun compatible here. Besides, Sun's ld.so
- * has a bug that prevents it from handling this alternate method.
- *
- * IT WOULD BE REALLY NICE TO HAVE CONSISTENCY THROUGHOUT THE ENTIRE
- * RELOCATION PROCESS, ie. using `r_addend' for storing all partially
- * completed relocations, in stead of mixing them in both relocation
- * records and in the segment data.
- */
- if (RELOC_PCREL_P(rp))
- r->r_addend -= pc_relocation;
-#endif
-
- return 1;
-}
-#endif
-
-/*
- * Set up a transfer from jmpslot at OFFSET (relative to the PLT table)
- * to the binder slot (which is at offset 0 of the PLT).
- */
-void
-md_make_jmpslot(sp, offset, index)
-jmpslot_t *sp;
-long offset;
-long index;
-{
- u_long fudge = (u_long) -(sizeof(sp->opcode1) + offset);
- sp->opcode1 = SAVE;
- /* The following is a RELOC_WDISP30 relocation */
- sp->opcode2 = CALL | ((fudge >> 2) & 0x3fffffff);
- sp->reloc_index = NOP | index;
-}
-
-/*
- * Set up a "direct" transfer (ie. not through the run-time binder) from
- * jmpslot at OFFSET to ADDR. Used by `ld' when the SYMBOLIC flag is on,
- * and by `ld.so' after resolving the symbol.
- * On the i386, we use the JMP instruction which is PC relative, so no
- * further RRS relocations will be necessary for such a jmpslot.
- *
- * OFFSET unused on Sparc.
- */
-void
-md_fix_jmpslot(sp, offset, addr)
-jmpslot_t *sp;
-long offset;
-u_long addr;
-{
- /*
- * Here comes a RELOC_{LO10,HI22} relocation pair
- * The resulting code is:
- * sethi %hi(addr), %g1
- * jmp %g1+%lo(addr)
- * nop ! delay slot
- */
- sp->opcode1 = SETHI | ((addr >> 10) & 0x003fffff);
- sp->opcode2 = JMP | (addr & 0x000003ff);
- sp->reloc_index = NOP;
-}
-
-/*
- * Update the relocation record for a jmpslot.
- */
-void
-md_make_jmpreloc(rp, r, type)
-struct relocation_info *rp, *r;
-int type;
-{
- if (type & RELTYPE_RELATIVE)
- r->r_type = RELOC_RELATIVE;
- else
- r->r_type = RELOC_JMP_SLOT;
-
- r->r_addend = rp->r_addend;
-}
-
-/*
- * Set relocation type for a GOT RRS relocation.
- */
-void
-md_make_gotreloc(rp, r, type)
-struct relocation_info *rp, *r;
-int type;
-{
- /*
- * GOT value resolved (symbolic or entry point): R_32
- * GOT not resolved: GLOB_DAT
- *
- * NOTE: I don't think it makes a difference.
- */
- if (type & RELTYPE_RELATIVE)
- r->r_type = RELOC_32;
- else
- r->r_type = RELOC_GLOB_DAT;
-
- r->r_addend = 0;
-}
-
-/*
- * Set relocation type for a RRS copy operation.
- */
-void
-md_make_cpyreloc(rp, r)
-struct relocation_info *rp, *r;
-{
- r->r_type = RELOC_COPY_DAT;
- r->r_addend = 0;
-}
-
-void
-md_set_breakpoint(where, savep)
-long where;
-long *savep;
-{
- *savep = *(long *)where;
- *(long *)where = TRAP;
-}
-
-#ifndef RTLD
-/*
- * Initialize (output) exec header such that useful values are
- * obtained from subsequent N_*() macro evaluations.
- */
-void
-md_init_header(hp, magic, flags)
-struct exec *hp;
-int magic, flags;
-{
-#ifdef NetBSD
- N_SETMAGIC((*hp), magic, MID_MACHINE, flags);
-
- /* TEXT_START depends on the value of outheader.a_entry. */
- if (!(link_mode & SHAREABLE)) /*WAS: if (entry_symbol) */
- hp->a_entry = PAGSIZ;
-#else
- hp->a_magic = magic;
- hp->a_machtype = M_SPARC;
- hp->a_toolversion = 1;
- hp->a_dynamic = ((flags) & EX_DYNAMIC);
-
- /* SunOS 4.1 N_TXTADDR depends on the value of outheader.a_entry. */
- if (!(link_mode & SHAREABLE)) /*WAS: if (entry_symbol) */
- hp->a_entry = N_PAGSIZ(*hp);
-#endif
-}
-
-/*
- * Check for acceptable foreign machine Ids
- */
-int
-md_midcompat(hp)
-struct exec *hp;
-{
-#ifdef NetBSD
-#define SUN_M_SPARC 3
- return (((md_swap_long(hp->a_midmag)&0x00ff0000) >> 16) == SUN_M_SPARC);
-#else
- return hp->a_machtype == M_SPARC;
-#endif
-}
-#endif /* RTLD */
diff --git a/gnu/usr.bin/ld/sparc/md.h b/gnu/usr.bin/ld/sparc/md.h
deleted file mode 100644
index ffa5853..0000000
--- a/gnu/usr.bin/ld/sparc/md.h
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id$
- */
-
-/*
- * SPARC machine dependent definitions
- */
-
-
-#define MAX_ALIGNMENT (sizeof (double))
-
-#ifdef NetBSD
-#define PAGSIZ __LDPGSZ
-
-#define N_SET_FLAG(ex,f) N_SETMAGIC(ex,N_GETMAGIC(ex), \
- MID_MACHINE, N_GETFLAG(ex)|(f))
-#define N_IS_DYNAMIC(ex) ((N_GETFLAG(ex) & EX_DYNAMIC))
-
-/*
- * Should be handled by a.out.h ?
- */
-#define N_ADJUST(ex) (((ex).a_entry < PAGSIZ) ? -PAGSIZ : 0)
-#define TEXT_START(ex) (N_TXTADDR(ex) + N_ADJUST(ex))
-#define DATA_START(ex) (N_DATADDR(ex) + N_ADJUST(ex))
-
-#else
-
-/* Get the SunOS a.out and relocation nomenclature */
-#define EX_DYNAMIC 1
-
-#define N_IS_DYNAMIC(ex) ((ex).a_dynamic)
-
-#define N_SET_FLAG(ex, f) { \
- (ex).a_dynamic = ((f) & EX_DYNAMIC); \
-}
-
-#undef relocation_info
-#define relocation_info reloc_info_sparc
-#define r_symbolnum r_index
-#endif /* NetBSD */
-
-#define N_BADMID(ex) \
- (N_GETMID(ex) != 0 && N_GETMID(ex) != MID_MACHINE && \
- !md_midcompat(&(ex)))
-
-/* Sparc (Sun 4) macros */
-#define RELOC_ADDRESS(r) ((r)->r_address)
-#define RELOC_EXTERN_P(r) ((r)->r_extern)
-#define RELOC_TYPE(r) ((r)->r_symbolnum)
-#define RELOC_SYMBOL(r) ((r)->r_symbolnum)
-#define RELOC_MEMORY_SUB_P(r) 0
-#ifdef RTLD
-/* XXX - consider this making SUN_COMPAT --> repercussions on rrs.c */
-#define RELOC_MEMORY_ADD_P(r) 1
-#else
-#define RELOC_MEMORY_ADD_P(r) 0
-#endif
-#define RELOC_ADD_EXTRA(r) ((r)->r_addend)
-#define RELOC_PCREL_P(r) \
- (((r)->r_type >= RELOC_DISP8 && (r)->r_type <= RELOC_WDISP22) \
- || ((r)->r_type == RELOC_PC10 || (r)->r_type == RELOC_PC22) \
- || (r)->r_type == RELOC_JMP_TBL)
-#define RELOC_VALUE_RIGHTSHIFT(r) (reloc_target_rightshift[(r)->r_type])
-#define RELOC_TARGET_SIZE(r) (reloc_target_size[(r)->r_type])
-#define RELOC_TARGET_BITPOS(r) 0
-#define RELOC_TARGET_BITSIZE(r) (reloc_target_bitsize[(r)->r_type])
-
-#define RELOC_JMPTAB_P(r) ((r)->r_type == RELOC_JMP_TBL)
-
-#define RELOC_BASEREL_P(r) \
- ((r)->r_type >= RELOC_BASE10 && (r)->r_type <= RELOC_BASE22)
-
-#define RELOC_RELATIVE_P(r) ((r)->r_type == RELOC_RELATIVE)
-#define RELOC_COPY_DAT (RELOC_RELATIVE+1) /*XXX*/
-#define RELOC_COPY_P(r) ((r)->r_type == RELOC_COPY_DAT)
-#define RELOC_LAZY_P(r) ((r)->r_type == RELOC_JMP_SLOT)
-
-#define RELOC_STATICS_THROUGH_GOT_P(r) (1)
-#define JMPSLOT_NEEDS_RELOC (1)
-
-/*
- * Define the range of usable Global Offset Table offsets
- * when using sparc 13 bit relocation types (-4096 - 4092).
- */
-#define MAX_GOTSIZE (8192)
-#define MAX_GOTOFF (4092)
-#define MIN_GOTOFF (-4096)
-
-#define CHECK_GOT_RELOC(r) \
- ((r)->r_type == RELOC_PC10 || (r)->r_type == RELOC_PC22)
-
-#define md_got_reloc(r) (-(r)->r_address)
-
-#define RELOC_INIT_SEGMENT_RELOC(r) ((r)->r_type = RELOC_32)
-
-#ifdef SUN_COMPAT
-/*
- * Sun plays games with `r_addend'
- */
-#define md_get_rt_segment_addend(r,a) (0)
-#endif
-
-/* Width of a Global Offset Table entry */
-typedef long got_t;
-
-typedef struct jmpslot {
- u_long opcode1;
- u_long opcode2;
- u_long reloc_index;
-#define JMPSLOT_RELOC_MASK (0x003fffff) /* 22 bits */
-} jmpslot_t;
-
-#define SAVE 0x9de3bfa0 /* Build stack frame (opcode1) */
-#define SETHI 0x03000000 /* %hi(addr) -> %g1 (opcode1) */
-#define CALL 0x40000000 /* Call instruction (opcode2) */
-#define JMP 0x81c06000 /* Jump %g1 instruction (opcode2) */
-#define NOP 0x01000000 /* Delay slot NOP for (reloc_index) */
-#define TRAP 0x91d02001 /* ta 0x1 */
-
-
-/*
- * Byte swap defs for cross linking
- */
-
-#if !defined(NEED_SWAP)
-
-#define md_swapin_exec_hdr(h)
-#define md_swapout_exec_hdr(h)
-#define md_swapin_symbols(s,n)
-#define md_swapout_symbols(s,n)
-#define md_swapin_zsymbols(s,n)
-#define md_swapout_zsymbols(s,n)
-#define md_swapin_reloc(r,n)
-#define md_swapout_reloc(r,n)
-#define md_swapin__dynamic(l)
-#define md_swapout__dynamic(l)
-#define md_swapin_section_dispatch_table(l)
-#define md_swapout_section_dispatch_table(l)
-#define md_swapin_so_debug(d)
-#define md_swapout_so_debug(d)
-#define md_swapin_rrs_hash(f,n)
-#define md_swapout_rrs_hash(f,n)
-#define md_swapin_sod(l,n)
-#define md_swapout_sod(l,n)
-#define md_swapout_jmpslot(j,n)
-#define md_swapout_got(g,n)
-#define md_swapin_ranlib_hdr(h,n)
-#define md_swapout_ranlib_hdr(h,n)
-
-#endif /* NEED_SWAP */
-
-#ifdef CROSS_LINKER
-
-#ifdef NEED_SWAP
-
-/* Define IO byte swapping routines */
-
-void md_swapin_exec_hdr __P((struct exec *));
-void md_swapout_exec_hdr __P((struct exec *));
-void md_swapin_reloc __P((struct relocation_info *, int));
-void md_swapout_reloc __P((struct relocation_info *, int));
-void md_swapout_jmpslot __P((jmpslot_t *, int));
-
-#define md_swapin_symbols(s,n) swap_symbols(s,n)
-#define md_swapout_symbols(s,n) swap_symbols(s,n)
-#define md_swapin_zsymbols(s,n) swap_zsymbols(s,n)
-#define md_swapout_zsymbols(s,n) swap_zsymbols(s,n)
-#define md_swapin__dynamic(l) swap__dynamic(l)
-#define md_swapout__dynamic(l) swap__dynamic(l)
-#define md_swapin_section_dispatch_table(l) swap_section_dispatch_table(l)
-#define md_swapout_section_dispatch_table(l) swap_section_dispatch_table(l)
-#define md_swapin_so_debug(d) swap_so_debug(d)
-#define md_swapout_so_debug(d) swap_so_debug(d)
-#define md_swapin_rrs_hash(f,n) swap_rrs_hash(f,n)
-#define md_swapout_rrs_hash(f,n) swap_rrs_hash(f,n)
-#define md_swapin_sod(l,n) swapin_sod(l,n)
-#define md_swapout_sod(l,n) swapout_sod(l,n)
-#define md_swapout_got(g,n) swap_longs((long*)(g),n)
-#define md_swapin_ranlib_hdr(h,n) swap_ranlib_hdr(h,n)
-#define md_swapout_ranlib_hdr(h,n) swap_ranlib_hdr(h,n)
-
-#define md_swap_short(x) ( (((x) >> 8) & 0xff) | (((x) & 0xff) << 8) )
-
-#define md_swap_long(x) ( (((x) >> 24) & 0xff ) | (((x) >> 8 ) & 0xff00 ) | \
- (((x) << 8 ) & 0xff0000) | (((x) << 24) & 0xff000000))
-
-#define get_byte(p) ( ((unsigned char *)(p))[0] )
-
-#define get_short(p) ( ( ((unsigned char *)(p))[1] << 8) | \
- ( ((unsigned char *)(p))[0] ) \
- )
-#define get_long(p) ( ( ((unsigned char *)(p))[3] << 24) | \
- ( ((unsigned char *)(p))[2] << 16) | \
- ( ((unsigned char *)(p))[1] << 8 ) | \
- ( ((unsigned char *)(p))[0] ) \
- )
-
-#define put_byte(p, v) { ((unsigned char *)(p))[0] = ((unsigned long)(v)); }
-
-#define put_short(p, v) { ((unsigned char *)(p))[1] = \
- ((((unsigned long)(v)) >> 8) & 0xff); \
- ((unsigned char *)(p))[0] = \
- ((((unsigned long)(v)) ) & 0xff); }
-
-#define put_long(p, v) { ((unsigned char *)(p))[3] = \
- ((((unsigned long)(v)) >> 24) & 0xff); \
- ((unsigned char *)(p))[2] = \
- ((((unsigned long)(v)) >> 16) & 0xff); \
- ((unsigned char *)(p))[1] = \
- ((((unsigned long)(v)) >> 8) & 0xff); \
- ((unsigned char *)(p))[0] = \
- ((((unsigned long)(v)) ) & 0xff); }
-
-#else /* We need not swap, but must pay attention to alignment: */
-
-#define md_swap_short(x) (x)
-#define md_swap_long(x) (x)
-
-#define get_byte(p) ( ((unsigned char *)(p))[0] )
-
-#define get_short(p) ( ( ((unsigned char *)(p))[0] << 8) | \
- ( ((unsigned char *)(p))[1] ) \
- )
-
-#define get_long(p) ( ( ((unsigned char *)(p))[0] << 24) | \
- ( ((unsigned char *)(p))[1] << 16) | \
- ( ((unsigned char *)(p))[2] << 8 ) | \
- ( ((unsigned char *)(p))[3] ) \
- )
-
-
-#define put_byte(p, v) { ((unsigned char *)(p))[0] = ((unsigned long)(v)); }
-
-#define put_short(p, v) { ((unsigned char *)(p))[0] = \
- ((((unsigned long)(v)) >> 8) & 0xff); \
- ((unsigned char *)(p))[1] = \
- ((((unsigned long)(v)) ) & 0xff); }
-
-#define put_long(p, v) { ((unsigned char *)(p))[0] = \
- ((((unsigned long)(v)) >> 24) & 0xff); \
- ((unsigned char *)(p))[1] = \
- ((((unsigned long)(v)) >> 16) & 0xff); \
- ((unsigned char *)(p))[2] = \
- ((((unsigned long)(v)) >> 8) & 0xff); \
- ((unsigned char *)(p))[3] = \
- ((((unsigned long)(v)) ) & 0xff); }
-
-#endif /* NEED_SWAP */
-
-#else /* Not a cross linker: use native */
-
-#define md_swap_short(x) (x)
-#define md_swap_long(x) (x)
-
-#define get_byte(where) (*(char *)(where))
-#define get_short(where) (*(short *)(where))
-#define get_long(where) (*(long *)(where))
-
-#define put_byte(where,what) (*(char *)(where) = (what))
-#define put_short(where,what) (*(short *)(where) = (what))
-#define put_long(where,what) (*(long *)(where) = (what))
-
-#endif /* CROSS_LINKER */
-
-void md_init_header __P((struct exec *, int, int));
-long md_get_addend __P((struct relocation_info *, unsigned char *));
-void md_relocate __P((struct relocation_info *, long, unsigned char *, int));
-void md_make_jmpslot __P((jmpslot_t *, long, long));
-void md_fix_jmpslot __P((jmpslot_t *, long, u_long));
-int md_make_reloc __P((struct relocation_info *, struct relocation_info *, int));
-void md_make_jmpreloc __P((struct relocation_info *, struct relocation_info *, int));
-void md_make_gotreloc __P((struct relocation_info *, struct relocation_info *, int));
-void md_make_copyreloc __P((struct relocation_info *, struct relocation_info *));
-void md_set_breakpoint __P((long, long *));
diff --git a/gnu/usr.bin/ld/sparc/mdprologue.S b/gnu/usr.bin/ld/sparc/mdprologue.S
deleted file mode 100644
index df146ee..0000000
--- a/gnu/usr.bin/ld/sparc/mdprologue.S
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id$
- */
-
-/*
- * SPARC run-time link editor entry points.
- */
-
-#define CRT_VERSION_SUN 1
-
- .seg "text" ! [internal]
- .proc 16
- .global _rtld_entry
-_rtld_entry:
-!#PROLOGUE# 0
- save %sp,-96,%sp
-L.1B:
- call L.2B
- sethi %hi((__GLOBAL_OFFSET_TABLE_-(L.1B-.))),%l7
-L.2B:
-!#PROLOGUE# 1
- or %l7,%lo((__GLOBAL_OFFSET_TABLE_-(L.1B-.))),%l7
- add %l7,%o7,%l7
-
- cmp %i0, CRT_VERSION_SUN ! is crtp passed in Sun style,
- bne 1f ! ie. relative to stack frame ?
- nop
- add %i1, %fp, %i1 ! if so, adjust to absolute address
-1:
- ld [%i1], %o3 ! load base address (crtp->crt_ba)
- ld [%l7], %o2 ! get __DYNAMIC address
- ! from 1st GOT entry
- add %o2, %o3, %o2 ! relocate and make it 3rd arg.
-
- ld [%l7 + _rtld], %g1 ! get address of rtld()
- add %g1, %o3, %g1 ! relocate
-
- mov %i1, %o1 ! set up args, #2: crtp
- call %g1 ! rtld(version, crtp, dp)
- mov %i0, %o0 ! arg #1: version
-
- ret
- restore
- .seg "data" ! [internal]
-
- .seg "text"
- .global _binder_entry
-_binder_entry:
-!#PROLOGUE# 0
- save %sp,-96,%sp
-!L.1C:
-! call L.2C
-! sethi %hi((__GLOBAL_OFFSET_TABLE_-(L.1C-.))),%l7
-!L.2C:
-! or %l7,%lo((__GLOBAL_OFFSET_TABLE_-(L.1C-.))),%l7
-!#PROLOGUE# 1
-
- sub %i7, 4, %o0 ! get to jmpslot through pc
- ld [%i7+4], %o1 ! get relocation index
- sethi %hi(0x3fffff), %o2 ! -> reloc_index & 0x003fffff
- or %o2, %lo(0x3fffff), %o2 ! [internal]
- call _binder ! and call binder(jsp, reloc_index)
- and %o1, %o2, %o1
-
- mov %o0, %g1 ! return value == function address
-
- restore ! get rid of our context
- jmp %g1 ! and go.
- restore ! and the jmpslot context
- nop
-
- .seg "data" ! [internal]
-
diff --git a/gnu/usr.bin/ld/support.c b/gnu/usr.bin/ld/support.c
deleted file mode 100644
index 0d9df2a..0000000
--- a/gnu/usr.bin/ld/support.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Generic "support" routines to replace those obtained from libiberty for ld.
- *
- * I've collected these from random bits of (published) code I've written
- * over the years, not that they are a big deal. peter@freebsd.org
- *-
- * Copyright (C) 1996
- * Peter Wemm. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *-
- * $Id$
- */
-#include <sys/types.h>
-#include <string.h>
-#include <stdlib.h>
-#include <err.h>
-
-#include "support.h"
-
-char *
-concat(s1, s2, s3)
- const char *s1, *s2, *s3;
-{
- int len = 1;
- char *s;
- if (s1)
- len += strlen(s1);
- if (s2)
- len += strlen(s2);
- if (s3)
- len += strlen(s3);
- s = xmalloc(len);
- s[0] = '\0';
- if (s1)
- strcat(s, s1);
- if (s2)
- strcat(s, s2);
- if (s3)
- strcat(s, s3);
- return s;
-}
-
-void *
-xmalloc(n)
- size_t n;
-{
- char *p = malloc(n);
-
- if (p == NULL)
- errx(1, "Could not allocate memory");
-
- return p;
-}
-
-void *
-xrealloc(p, n)
- void *p;
- size_t n;
-{
- p = realloc(p, n);
-
- if (p == NULL)
- errx(1, "Could not allocate memory");
-
- return p;
-}
diff --git a/gnu/usr.bin/ld/support.h b/gnu/usr.bin/ld/support.h
deleted file mode 100644
index 5be1e31..0000000
--- a/gnu/usr.bin/ld/support.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (C) 1996
- * Peter Wemm. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *-
- * $Id$
- */
-
-/*
- * prototypes for support.c. Big deal.
- */
-
-void *xmalloc __P((size_t));
-void *xrealloc __P((void *, size_t));
-char *concat __P((const char *, const char *, const char *));
diff --git a/gnu/usr.bin/ld/symbol.c b/gnu/usr.bin/ld/symbol.c
deleted file mode 100644
index d37a1a3..0000000
--- a/gnu/usr.bin/ld/symbol.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- *
- * Modified 1993 by Paul Kranenburg, Erasmus University
- */
-
-/* Derived from ld.c: "@(#)ld.c 6.10 (Berkeley) 5/22/91"; */
-
-/* Linker `ld' for GNU
- Copyright (C) 1988 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- 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. */
-
-/* Written by Richard Stallman with some help from Eric Albert.
- Set, indirect, and warning symbol features added by Randy Smith. */
-
-/*
- * symbol table routines
- * $Id$
- */
-
-/* Create the symbol table entries for `etext', `edata' and `end'. */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <a.out.h>
-#include <stab.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "ld.h"
-#include "dynamic.h"
-
-symbol *symtab[SYMTABSIZE]; /* The symbol table. */
-int num_hash_tab_syms; /* Number of symbols in symbol hash table. */
-
-symbol *edata_symbol; /* the symbol _edata */
-symbol *etext_symbol; /* the symbol _etext */
-symbol *end_symbol; /* the symbol _end */
-symbol *got_symbol; /* the symbol __GLOBAL_OFFSET_TABLE_ */
-symbol *dynamic_symbol; /* the symbol __DYNAMIC */
-
-void
-symtab_init(relocatable_output)
- int relocatable_output;
-{
- /*
- * Put linker reserved symbols into symbol table.
- */
-#ifndef nounderscore
-#define ETEXT_SYM "_etext"
-#define EDATA_SYM "_edata"
-#define END_SYM "_end"
-#define DYN_SYM "__DYNAMIC"
-#define GOT_SYM "__GLOBAL_OFFSET_TABLE_"
-#else
-#define ETEXT_SYM "etext"
-#define EDATA_SYM "edata"
-#define END_SYM "end"
-#define DYN_SYM "_DYNAMIC"
-#define GOT_SYM "_GLOBAL_OFFSET_TABLE_"
-#endif
-
- dynamic_symbol = getsym(DYN_SYM);
- dynamic_symbol->defined = relocatable_output?N_UNDF:(N_DATA | N_EXT);
-
- got_symbol = getsym(GOT_SYM);
- got_symbol->defined = N_DATA | N_EXT;
-
- if (relocatable_output)
- return;
-
- etext_symbol = getsym(ETEXT_SYM);
- edata_symbol = getsym(EDATA_SYM);
- end_symbol = getsym(END_SYM);
-
- etext_symbol->defined = N_TEXT | N_EXT;
- edata_symbol->defined = N_DATA | N_EXT;
- end_symbol->defined = N_BSS | N_EXT;
-
- etext_symbol->flags |= GS_REFERENCED;
- edata_symbol->flags |= GS_REFERENCED;
- end_symbol->flags |= GS_REFERENCED;
-}
-
-/*
- * Compute the hash code for symbol name KEY.
- */
-
-int
-hash_string (key)
- char *key;
-{
- register char *cp;
- register int k;
-
- cp = key;
- k = 0;
- while (*cp)
- k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff;
-
- return k;
-}
-
-/*
- * Get the symbol table entry for the global symbol named KEY.
- * Create one if there is none.
- */
-
-symbol *
-getsym(key)
- char *key;
-{
- register int hashval;
- register symbol *bp;
-
- /* Determine the proper bucket. */
- hashval = hash_string(key) % SYMTABSIZE;
-
- /* Search the bucket. */
- for (bp = symtab[hashval]; bp; bp = bp->link)
- if (strcmp(key, bp->name) == 0)
- return bp;
-
- /* Nothing was found; create a new symbol table entry. */
- bp = (symbol *)xmalloc(sizeof(symbol));
- bp->name = (char *)xmalloc(strlen(key) + 1);
- strcpy (bp->name, key);
- bp->refs = 0;
- bp->defined = 0;
- bp->value = 0;
- bp->common_size = 0;
- bp->warning = 0;
- bp->undef_refs = 0;
- bp->mult_defs = 0;
- bp->alias = 0;
- bp->setv_count = 0;
- bp->symbolnum = 0;
- bp->rrs_symbolnum = 0;
-
- bp->size = 0;
- bp->aux = 0;
- bp->sorefs = 0;
- bp->so_defined = 0;
- bp->def_lsp = 0;
- bp->jmpslot_offset = -1;
- bp->gotslot_offset = -1;
- bp->flags = 0;
-
- /* Add the entry to the bucket. */
- bp->link = symtab[hashval];
- symtab[hashval] = bp;
-
- ++num_hash_tab_syms;
-
- return bp;
-}
-
-/* Like `getsym' but return 0 if the symbol is not already known. */
-
-symbol *
-getsym_soft (key)
- char *key;
-{
- register int hashval;
- register symbol *bp;
-
- /* Determine which bucket. */
- hashval = hash_string(key) % SYMTABSIZE;
-
- /* Search the bucket. */
- for (bp = symtab[hashval]; bp; bp = bp->link)
- if (strcmp(key, bp->name) == 0)
- return bp;
-
- return 0;
-}
diff --git a/gnu/usr.bin/ld/symseg.h b/gnu/usr.bin/ld/symseg.h
deleted file mode 100644
index 116a8b2..0000000
--- a/gnu/usr.bin/ld/symseg.h
+++ /dev/null
@@ -1,359 +0,0 @@
-/*-
- *
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * from: @(#)symseg.h 5.4 (Berkeley) 4/30/91
- * $Id$
- */
-
-/* GDB symbol table format definitions.
- Copyright (C) 1987, 1988 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GNU CC 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 GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Format of GDB symbol table data.
- There is one symbol segment for each source file or
- independant compilation. These segments are simply concatenated
- to form the GDB symbol table. A zero word where the beginning
- of a segment is expected indicates there are no more segments.
-
-Format of a symbol segment:
-
- The symbol segment begins with a word containing 1
- if it is in the format described here. Other formats may
- be designed, with other code numbers.
-
- The segment contains many objects which point at each other.
- The pointers are offsets in bytes from the beginning of the segment.
- Thus, each segment can be loaded into core and its pointers relocated
- to make valid in-core pointers.
-
- All the data objects in the segment can be found indirectly from
- one of them, the root object, of type `struct symbol_root'.
- It appears at the beginning of the segment.
-
- The total size of the segment, in bytes, appears as the `length'
- field of this object. This size includes the size of the
- root object.
-
- All the object data types are defined here to contain pointer types
- appropriate for in-core use on a relocated symbol segment.
- Casts to and from type int are required for working with
- unrelocated symbol segments such as are found in the file.
-
- The ldsymaddr word is filled in by the loader to contain
- the offset (in bytes) within the ld symbol table
- of the first nonglobal symbol from this compilation.
- This makes it possible to match those symbols
- (which contain line number information) reliably with
- the segment they go with.
-
- Core addresses within the program that appear in the symbol segment
- are not relocated by the loader. They are inserted by the assembler
- and apply to addresses as output by the assembler, so GDB must
- relocate them when it loads the symbol segment. It gets the information
- on how to relocate from the textrel, datarel, bssrel, databeg and bssbeg
- words of the root object.
-
- The words textrel, datarel and bssrel
- are filled in by ld with the amounts to relocate within-the-file
- text, data and bss addresses by; databeg and bssbeg can be
- used to tell which kind of relocation an address needs. */
-
-enum language {language_c};
-
-struct symbol_root
-{
- int format; /* Data format version */
- int length; /* # bytes in this symbol segment */
- int ldsymoff; /* Offset in ld symtab of this file's syms */
- int textrel; /* Relocation for text addresses */
- int datarel; /* Relocation for data addresses */
- int bssrel; /* Relocation for bss addresses */
- char *filename; /* Name of main source file compiled */
- char *filedir; /* Name of directory it was reached from */
- struct blockvector *blockvector; /* Vector of all symbol-naming blocks */
- struct typevector *typevector; /* Vector of all data types */
- enum language language; /* Code identifying the language used */
- char *version; /* Version info. Not fully specified */
- char *compilation; /* Compilation info. Not fully specified */
- int databeg; /* Address within the file of data start */
- int bssbeg; /* Address within the file of bss start */
- struct sourcevector *sourcevector; /* Vector of line-number info */
-};
-
-/* All data types of symbols in the compiled program
- are represented by `struct type' objects.
- All of these objects are pointed to by the typevector.
- The type vector may have empty slots that contain zero. */
-
-struct typevector
-{
- int length; /* Number of types described */
- struct type *type[1];
-};
-
-/* Different kinds of data types are distinguished by the `code' field. */
-
-enum type_code
-{
- TYPE_CODE_UNDEF, /* Not used; catches errors */
- TYPE_CODE_PTR, /* Pointer type */
- TYPE_CODE_ARRAY, /* Array type, lower bound zero */
- TYPE_CODE_STRUCT, /* C struct or Pascal record */
- TYPE_CODE_UNION, /* C union or Pascal variant part */
- TYPE_CODE_ENUM, /* Enumeration type */
- TYPE_CODE_FUNC, /* Function type */
- TYPE_CODE_INT, /* Integer type */
- TYPE_CODE_FLT, /* Floating type */
- TYPE_CODE_VOID, /* Void type (values zero length) */
- TYPE_CODE_SET, /* Pascal sets */
- TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */
- TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */
-};
-
-/* This appears in a type's flags word for an unsigned integer type. */
-#define TYPE_FLAG_UNSIGNED 1
-
-/* Other flag bits are used with GDB. */
-
-struct type
-{
- /* Code for kind of type */
- enum type_code code;
- /* Name of this type, or zero if none.
- This is used for printing only.
- Type names specified as input are defined by symbols. */
- char *name;
- /* Length in bytes of storage for a value of this type */
- int length;
- /* For a pointer type, describes the type of object pointed to.
- For an array type, describes the type of the elements.
- For a function type, describes the type of the value.
- Unused otherwise. */
- struct type *target_type;
- /* Type that is a pointer to this type.
- Zero if no such pointer-to type is known yet.
- The debugger may add the address of such a type
- if it has to construct one later. */
- struct type *pointer_type;
- /* Type that is a function returning this type.
- Zero if no such function type is known here.
- The debugger may add the address of such a type
- if it has to construct one later. */
- struct type *function_type;
- /* Flags about this type. */
- short flags;
- /* Number of fields described for this type */
- short nfields;
- /* For structure and union types, a description of each field.
- For set and pascal array types, there is one "field",
- whose type is the domain type of the set or array.
- For range types, there are two "fields",
- the minimum and maximum values (both inclusive).
- For enum types, each possible value is described by one "field".
- For range types, there are two "fields", that record constant values
- (inclusive) for the minimum and maximum.
-
- Using a pointer to a separate array of fields
- allows all types to have the same size, which is useful
- because we can allocate the space for a type before
- we know what to put in it. */
- struct field
- {
- /* Position of this field, counting in bits from start of
- containing structure. For a function type, this is the
- position in the argument list of this argument.
- For a range bound or enum value, this is the value itself. */
- int bitpos;
- /* Size of this field, in bits, or zero if not packed.
- For an unpacked field, the field's type's length
- says how many bytes the field occupies. */
- int bitsize;
- /* In a struct or enum type, type of this field.
- In a function type, type of this argument.
- In an array type, the domain-type of the array. */
- struct type *type;
- /* Name of field, value or argument.
- Zero for range bounds and array domains. */
- char *name;
- } *fields;
-};
-
-/* All of the name-scope contours of the program
- are represented by `struct block' objects.
- All of these objects are pointed to by the blockvector.
-
- Each block represents one name scope.
- Each lexical context has its own block.
-
- The first two blocks in the blockvector are special.
- The first one contains all the symbols defined in this compilation
- whose scope is the entire program linked together.
- The second one contains all the symbols whose scope is the
- entire compilation excluding other separate compilations.
- In C, these correspond to global symbols and static symbols.
-
- Each block records a range of core addresses for the code that
- is in the scope of the block. The first two special blocks
- give, for the range of code, the entire range of code produced
- by the compilation that the symbol segment belongs to.
-
- The blocks appear in the blockvector
- in order of increasing starting-address,
- and, within that, in order of decreasing ending-address.
-
- This implies that within the body of one function
- the blocks appear in the order of a depth-first tree walk. */
-
-struct blockvector
-{
- /* Number of blocks in the list. */
- int nblocks;
- /* The blocks themselves. */
- struct block *block[1];
-};
-
-struct block
-{
- /* Addresses in the executable code that are in this block.
- Note: in an unrelocated symbol segment in a file,
- these are always zero. They can be filled in from the
- N_LBRAC and N_RBRAC symbols in the loader symbol table. */
- int startaddr, endaddr;
- /* The symbol that names this block,
- if the block is the body of a function;
- otherwise, zero.
- Note: In an unrelocated symbol segment in an object file,
- this field may be zero even when the block has a name.
- That is because the block is output before the name
- (since the name resides in a higher block).
- Since the symbol does point to the block (as its value),
- it is possible to find the block and set its name properly. */
- struct symbol *function;
- /* The `struct block' for the containing block, or 0 if none. */
- /* Note that in an unrelocated symbol segment in an object file
- this pointer may be zero when the correct value should be
- the second special block (for symbols whose scope is one compilation).
- This is because the compiler ouptuts the special blocks at the
- very end, after the other blocks. */
- struct block *superblock;
- /* Number of local symbols. */
- int nsyms;
- /* The symbols. */
- struct symbol *sym[1];
-};
-
-/* Represent one symbol name; a variable, constant, function or typedef. */
-
-/* Different name spaces for symbols. Looking up a symbol specifies
- a namespace and ignores symbol definitions in other name spaces.
-
- VAR_NAMESPACE is the usual namespace.
- In C, this contains variables, function names, typedef names
- and enum type values.
-
- STRUCT_NAMESPACE is used in C to hold struct, union and enum type names.
- Thus, if `struct foo' is used in a C program,
- it produces a symbol named `foo' in the STRUCT_NAMESPACE.
-
- LABEL_NAMESPACE may be used for names of labels (for gotos);
- currently it is not used and labels are not recorded at all. */
-
-/* For a non-global symbol allocated statically,
- the correct core address cannot be determined by the compiler.
- The compiler puts an index number into the symbol's value field.
- This index number can be matched with the "desc" field of
- an entry in the loader symbol table. */
-
-enum namespace
-{
- UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE,
-};
-
-/* An address-class says where to find the value of the symbol in core. */
-
-enum address_class
-{
- LOC_UNDEF, /* Not used; catches errors */
- LOC_CONST, /* Value is constant int */
- LOC_STATIC, /* Value is at fixed address */
- LOC_REGISTER, /* Value is in register */
- LOC_ARG, /* Value is at spec'd position in arglist */
- LOC_LOCAL, /* Value is at spec'd pos in stack frame */
- LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE
- Symbols in the namespace STRUCT_NAMESPACE
- all have this class. */
- LOC_LABEL, /* Value is address in the code */
- LOC_BLOCK, /* Value is address of a `struct block'.
- Function names have this class. */
- LOC_EXTERNAL, /* Value is at address not in this compilation.
- This is used for .comm symbols
- and for extern symbols within functions.
- Inside GDB, this is changed to LOC_STATIC once the
- real address is obtained from a loader symbol. */
- LOC_CONST_BYTES /* Value is a constant byte-sequence. */
-};
-
-struct symbol
-{
- /* Symbol name */
- char *name;
- /* Name space code. */
- enum namespace namespace;
- /* Address class */
- enum address_class class;
- /* Data type of value */
- struct type *type;
- /* constant value, or address if static, or register number,
- or offset in arguments, or offset in stack frame. */
- union
- {
- long value;
- struct block *block; /* for LOC_BLOCK */
- char *bytes; /* for LOC_CONST_BYTES */
- }
- value;
-};
-
-/* Source-file information.
- This describes the relation between source files and line numbers
- and addresses in the program text. */
-
-struct sourcevector
-{
- int length; /* Number of source files described */
- struct source *source[1]; /* Descriptions of the files */
-};
-
-/* Line number and address of one line. */
-
-struct line
-{
- int linenum;
- int address;
-};
-
-/* All the information on one source file. */
-
-struct source
-{
- char *name; /* Name of file */
- int nlines; /* Number of lines that follow */
- struct line lines[1]; /* Information on each line */
-};
diff --git a/gnu/usr.bin/ld/warnings.c b/gnu/usr.bin/ld/warnings.c
deleted file mode 100644
index 76df8f7..0000000
--- a/gnu/usr.bin/ld/warnings.c
+++ /dev/null
@@ -1,805 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- *
- * Modified 1993 by Paul Kranenburg, Erasmus University
- */
-
-/* Derived from ld.c: "@(#)ld.c 6.10 (Berkeley) 5/22/91"; */
-
-/* Linker `ld' for GNU
- Copyright (C) 1988 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- 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. */
-
-/* Written by Richard Stallman with some help from Eric Albert.
- Set, indirect, and warning symbol features added by Randy Smith. */
-
-/*
- * $Id$
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/errno.h>
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <ar.h>
-#include <ranlib.h>
-#include <a.out.h>
-#include <stab.h>
-#include <string.h>
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include "ld.h"
-#include "dynamic.h"
-
-static int reported_undefineds;
-
-#ifdef DEMANGLE_CPLUSPLUS
-#include "demangle.h"
-
-char *demangle(name)
- char *name;
-{
- static char* saved_result = NULL;
-
- if (saved_result)
- free (saved_result);
-
- saved_result = cplus_demangle (name[0] == '_' ? name + 1 : name, DMGL_PARAMS | DMGL_ANSI);
-
- if (saved_result)
- return saved_result;
- else
- return name;
-}
-#endif
-
-/*
- * Print the filename of ENTRY on OUTFILE (a stdio stream),
- * and then a newline.
- */
-
-void
-prline_file_name (entry, outfile)
- struct file_entry *entry;
- FILE *outfile;
-{
- print_file_name (entry, outfile);
- fprintf (outfile, "\n");
-}
-
-/*
- * Print the filename of ENTRY on OUTFILE (a stdio stream).
- */
-
-void
-print_file_name (entry, outfile)
- struct file_entry *entry;
- FILE *outfile;
-{
- if (entry == NULL) {
- fprintf (outfile, "NULL");
- }
-
- if (entry->superfile) {
- print_file_name (entry->superfile, outfile);
- fprintf (outfile, "(%s)", entry->filename);
- } else
- fprintf (outfile, "%s", entry->filename);
-}
-
-/*
- * Return the filename of entry as a string (malloc'd for the purpose)
- */
-
-char *
-get_file_name (entry)
- struct file_entry *entry;
-{
- char *result, *supfile;
-
- if (entry == NULL) {
- return (char *)strdup("NULL");
- }
-
- if (entry->superfile) {
- supfile = get_file_name(entry->superfile);
- result = (char *)
- xmalloc(strlen(supfile) + strlen(entry->filename) + 3);
- (void)sprintf(result, "%s(%s)", supfile, entry->filename);
- free(supfile);
-
- } else {
- result = (char *)xmalloc(strlen(entry->filename) + 1);
- strcpy(result, entry->filename);
- }
- return result;
-}
-
-/* Print a complete or partial map of the output file. */
-
-static void describe_file_sections __P((struct file_entry *, FILE *));
-static void list_file_locals __P((struct file_entry *, FILE *));
-
-void
-print_symbols(outfile)
- FILE *outfile;
-{
- fprintf(outfile, "\nFiles:\n\n");
- each_file(describe_file_sections, (void *)outfile);
-
- fprintf(outfile, "\nGlobal symbols:\n\n");
- FOR_EACH_SYMBOL(i, sp) {
- fprintf(outfile, " %s: ", demangle(sp->name));
- if (!(sp->flags & GS_REFERENCED))
- fprintf(outfile, "unreferenced");
- else if (sp->so_defined)
- fprintf(outfile, "sodefined");
- else if (!sp->defined)
- fprintf(outfile, "undefined");
- else if (sp->defined == (N_UNDF|N_EXT))
- fprintf(outfile, "common: size %#x", sp->common_size);
- else
- fprintf(outfile, "type %d, value %#lx, size %#x",
- sp->defined, sp->value, sp->size);
- if (sp->alias)
- fprintf(outfile, ", aliased to %s", demangle(sp->alias->name));
- fprintf(outfile, "\n");
- } END_EACH_SYMBOL;
-
- each_file(list_file_locals, (void *)outfile);
-}
-
-static void
-describe_file_sections(entry, outfile)
- struct file_entry *entry;
- FILE *outfile;
-{
- fprintf(outfile, " ");
- print_file_name(entry, outfile);
- if (entry->flags & (E_JUST_SYMS | E_DYNAMIC))
- fprintf(outfile, " symbols only\n");
- else
- fprintf(outfile, " text %x(%lx), data %x(%lx), bss %x(%lx) hex\n",
- entry->text_start_address, entry->header.a_text,
- entry->data_start_address, entry->header.a_data,
- entry->bss_start_address, entry->header.a_bss);
-}
-
-static void
-list_file_locals (entry, outfile)
- struct file_entry *entry;
- FILE *outfile;
-{
- struct localsymbol *lsp, *lspend;
-
- entry->strings = (char *)alloca(entry->string_size);
- read_entry_strings (file_open(entry), entry);
-
- fprintf (outfile, "\nLocal symbols of ");
- print_file_name (entry, outfile);
- fprintf (outfile, ":\n\n");
-
- lspend = entry->symbols + entry->nsymbols;
- for (lsp = entry->symbols; lsp < lspend; lsp++) {
- register struct nlist *p = &lsp->nzlist.nlist;
- /*
- * If this is a definition,
- * update it if necessary by this file's start address.
- */
- if (!(p->n_type & (N_STAB | N_EXT)))
- fprintf(outfile, " %s: 0x%lx\n",
- entry->strings + p->n_un.n_strx, p->n_value);
- }
-
- entry->strings = 0; /* All done with them. */
-}
-
-
-/* Static vars for do_warnings and subroutines of it */
-static int list_unresolved_refs; /* List unresolved refs */
-static int list_multiple_defs; /* List multiple definitions */
-
-static struct line_debug_entry *init_debug_scan __P((int, struct file_entry *));
-static int next_debug_entry __P((int, struct line_debug_entry *));
-
-/*
- * Structure for communication between do_file_warnings and it's
- * helper routines. Will in practice be an array of three of these:
- * 0) Current line, 1) Next line, 2) Source file info.
- */
-struct line_debug_entry
-{
- int line;
- char *filename;
- struct localsymbol *sym;
-};
-
-/*
- * Helper routines for do_file_warnings.
- */
-
-/*
- * Return an integer less than, equal to, or greater than 0 as per the
- * relation between the two relocation entries. Used by qsort.
- */
-
-static int
-reloc_cmp(rel1, rel2)
- struct relocation_info *rel1, *rel2;
-{
- return RELOC_ADDRESS(rel1) - RELOC_ADDRESS(rel2);
-}
-
-/*
- * Moves to the next debugging symbol in the file. USE_DATA_SYMBOLS
- * determines the type of the debugging symbol to look for (DSLINE or
- * SLINE). STATE_POINTER keeps track of the old and new locatiosn in
- * the file. It assumes that state_pointer[1] is valid; ie
- * that it.sym points into some entry in the symbol table. If
- * state_pointer[1].sym == 0, this routine should not be called.
- */
-
-static int
-next_debug_entry(use_data_symbols, state_pointer)
- register int use_data_symbols;
- /* Next must be passed by reference! */
- struct line_debug_entry state_pointer[3];
-{
- register struct line_debug_entry
- *current = state_pointer,
- *next = state_pointer + 1,
- /* Used to store source file */
- *source = state_pointer + 2;
-
- struct file_entry *entry = (struct file_entry *)source->sym;
- struct localsymbol *lspend = entry->symbols + entry->nsymbols;
-
-
- current->sym = next->sym;
- current->line = next->line;
- current->filename = next->filename;
-
- while (++(next->sym) < lspend) {
-
- struct nlist *np = &next->sym->nzlist.nlist;
-
- /*
- * n_type is a char, and N_SOL, N_EINCL and N_BINCL are > 0x80,
- * so may look negative...therefore, must mask to low bits
- */
- switch (np->n_type & 0xff) {
- case N_SLINE:
- if (use_data_symbols)
- continue;
- next->line = np->n_desc;
- return 1;
- case N_DSLINE:
- if (!use_data_symbols)
- continue;
- next->line = np->n_desc;
- return 1;
-#ifdef HAVE_SUN_STABS
- case N_EINCL:
- next->filename = source->filename;
- continue;
-#endif
- case N_SO:
- source->filename = np->n_un.n_strx + entry->strings;
- source->line++;
-#ifdef HAVE_SUN_STABS
- case N_BINCL:
-#endif
- case N_SOL:
- next->filename = np->n_un.n_strx + entry->strings;
- default:
- continue;
- }
- }
- next->sym = (struct localsymbol *)0;
- return 0;
-}
-
-/*
- * Create a structure to save the state of a scan through the debug symbols.
- * USE_DATA_SYMBOLS is set if we should be scanning for DSLINE's instead of
- * SLINE's. ENTRY is the file entry which points at the symbols to use.
- */
-
-static struct line_debug_entry *
-init_debug_scan(use_data_symbols, entry)
- int use_data_symbols;
- struct file_entry *entry;
-{
- register struct localsymbol *lsp, *lspend;
- struct line_debug_entry *state_pointer, *current, *next, *source;
-
- state_pointer = (struct line_debug_entry *)
- xmalloc(3 * sizeof(*state_pointer));
-
- current = state_pointer,
- next = state_pointer + 1,
- source = state_pointer + 2; /* Used to store source file */
-
- lspend = entry->symbols+entry->nsymbols;
-
- for (lsp = entry->symbols; lsp < lspend; lsp++)
- if (lsp->nzlist.nlist.n_type == N_SO)
- break;
-
- if (lsp >= lspend) {
- /* I believe this translates to "We lose" */
- current->filename = next->filename = entry->filename;
- current->line = next->line = -1;
- current->sym = next->sym = (struct localsymbol *)0;
- return state_pointer;
- }
- next->line = source->line = 0;
- next->filename = source->filename
- = (lsp->nzlist.nlist.n_un.n_strx + entry->strings);
- source->sym = (struct localsymbol *)entry;
- next->sym = lsp;
-
- /* To setup next */
- next_debug_entry(use_data_symbols, state_pointer);
-
- if (!next->sym) { /* No line numbers for this section; */
- /* setup output results as appropriate */
- if (source->line) {
- current->filename = source->filename = entry->filename;
- current->line = -1; /* Don't print lineno */
- } else {
- current->filename = source->filename;
- current->line = 0;
- }
- return state_pointer;
- }
- /* To setup current */
- next_debug_entry(use_data_symbols, state_pointer);
-
- return state_pointer;
-}
-
-/*
- * Takes an ADDRESS (in either text or data space) and a STATE_POINTER which
- * describes the current location in the implied scan through the debug
- * symbols within the file which ADDRESS is within, and returns the source
- * line number which corresponds to ADDRESS.
- */
-
-static int
-address_to_line(address, state_pointer)
- unsigned long address;
-/* Next must be passed by reference! */
- struct line_debug_entry state_pointer[3];
-{
- struct line_debug_entry *current, *next, *tmp_pointer;
- int use_data_symbols;
-
- current = state_pointer;
- next = state_pointer + 1;
-
- if (next->sym)
- use_data_symbols =
- (next->sym->nzlist.nlist.n_type & N_TYPE) == N_DATA;
- else
- return current->line;
-
- /* Go back to the beginning if we've already passed it. */
- if (current->sym->nzlist.nlist.n_value > address) {
- tmp_pointer = init_debug_scan(use_data_symbols,
- (struct file_entry *)
- ((state_pointer + 2)->sym));
- state_pointer[0] = tmp_pointer[0];
- state_pointer[1] = tmp_pointer[1];
- state_pointer[2] = tmp_pointer[2];
- free(tmp_pointer);
- }
-
- /* If we're still in a bad way, return -1, meaning invalid line. */
- if (current->sym->nzlist.nlist.n_value > address)
- return -1;
-
- while (next->sym
- && next->sym->nzlist.nlist.n_value <= address
- && next_debug_entry(use_data_symbols, state_pointer));
-
- return current->line;
-}
-
-
-/* Macros for manipulating bitvectors. */
-#define BIT_SET_P(bv, index) ((bv)[(index) >> 3] & 1 << ((index) & 0x7))
-#define SET_BIT(bv, index) ((bv)[(index) >> 3] |= 1 << ((index) & 0x7))
-
-/*
- * This routine will scan through the relocation data of file ENTRY, printing
- * out references to undefined symbols and references to symbols defined in
- * files with N_WARNING symbols. If DATA_SEGMENT is non-zero, it will scan
- * the data relocation segment (and use N_DSLINE symbols to track line
- * number); otherwise it will scan the text relocation segment. Warnings
- * will be printed on the output stream OUTFILE. Eventually, every nlist
- * symbol mapped through will be marked in the NLIST_BITVECTOR, so we don't
- * repeat ourselves when we scan the nlists themselves.
- */
-
-static void
-do_relocation_warnings(entry, data_segment, outfile, nlist_bitvector)
- struct file_entry *entry;
- int data_segment;
- FILE *outfile;
- unsigned char *nlist_bitvector;
-{
- struct relocation_info *rp, *erp;
- int start_of_segment;
- struct localsymbol *start_of_syms;
- struct line_debug_entry *state_pointer, *current;
- /* Assigned to generally static values; should not be written into. */
- char *errfmt;
- /*
- * Assigned to alloca'd values cand copied into; should be freed when
- * done.
- */
- char *errmsg;
- int invalidate_line_number;
-
- rp = data_segment ? entry->datarel : entry->textrel;
- erp = data_segment ? (rp + entry->ndatarel) : (rp + entry->ntextrel);
- start_of_syms = entry->symbols;
- start_of_segment = (data_segment ?
- entry->data_start_address :
- entry->text_start_address);
- state_pointer = init_debug_scan(data_segment != 0, entry);
- current = state_pointer;
-
- /*
- * We need to sort the relocation info here. Sheesh, so much effort
- * for one lousy error optimization.
- */
- qsort(rp, erp - rp, sizeof(rp[0]), reloc_cmp);
-
- for (; rp < erp; rp++) {
- register struct localsymbol *lsp;
- register symbol *g;
-
- /*
- * If the relocation isn't resolved through a symbol, continue.
- */
- if (!RELOC_EXTERN_P(rp))
- continue;
-
- lsp = &entry->symbols[RELOC_SYMBOL(rp)];
-
- /*
- * Local symbols shouldn't ever be used by relocation info,
- * so the next should be safe. This is, of course, wrong.
- * References to local BSS symbols can be the targets of
- * relocation info, and they can (must) be resolved through
- * symbols. However, these must be defined properly, (the
- * assembler would have caught it otherwise), so we can
- * ignore these cases.
- */
-
- if ((g = lsp->symbol) == NULL)
- continue;
-
- if (!(lsp->nzlist.nz_type & N_EXT) &&
- !SET_ELEMENT_P(lsp->nzlist.nz_type)) {
- warnx("internal error: `%s' N_EXT not set", demangle(g->name));
- continue;
- }
-
- errmsg = 0;
-
- if (!g->defined && !g->so_defined && list_unresolved_refs) {
- /* Mark as being noted by relocation warning pass. */
- SET_BIT(nlist_bitvector, lsp - start_of_syms);
-
- if (g->undef_refs == 0)
- reported_undefineds++;
- if (g->undef_refs >= MAX_UREFS_PRINTED)
- /* Listed too many */
- continue;
- /* Undefined symbol which we should mention */
-
- if (++(g->undef_refs) == MAX_UREFS_PRINTED) {
- errfmt = "More undefined symbol %s refs follow";
- invalidate_line_number = 1;
- } else {
- errfmt =
- "Undefined symbol `%s' referenced from %s segment";
- invalidate_line_number = 0;
- }
- } else { /* Defined */
- /* Potential symbol warning here */
- if (!g->warning)
- continue;
-
- if (BIT_SET_P(nlist_bitvector, lsp - start_of_syms))
- continue;
-
- /* Mark as being noted by relocation warning pass. */
- SET_BIT(nlist_bitvector, lsp - start_of_syms);
-
- errfmt = 0;
- errmsg = g->warning;
- invalidate_line_number = 0;
- }
-
-
- /* If errfmt == 0, errmsg has already been defined. */
- if (errfmt != 0) {
- char *nm = demangle(g->name);
- errmsg = (char *)
- xmalloc(strlen(errfmt) + strlen(nm) + 1);
- sprintf(errmsg, errfmt, nm, data_segment?"data":"text");
- }
- address_to_line(RELOC_ADDRESS(rp) + start_of_segment,
- state_pointer);
-
- if (current->line >= 0)
- fprintf(outfile, "%s:%d: %s\n",
- current->filename,
- invalidate_line_number ? 0 : current->line,
- errmsg);
- else
- fprintf(outfile, "%s: %s\n", current->filename, errmsg);
-
- if (errfmt != 0)
- free(errmsg);
- }
-
- free(state_pointer);
-}
-
-/*
- * Print on OUTFILE a list of all warnings generated by references and/or
- * definitions in the file ENTRY. List source file and line number if
- * possible, just the .o file if not.
- */
-
-void
-do_file_warnings (entry, outfile)
- struct file_entry *entry;
- FILE *outfile;
-{
- int nsym;
- int i;
- char *errfmt, *file_name;
- int line_number;
- int dont_allow_symbol_name;
- u_char *nlist_bitvector;
- struct line_debug_entry *text_scan, *data_scan;
-
- nsym = entry->nsymbols;
- nlist_bitvector = (u_char *)alloca((nsym >> 3) + 1);
- bzero(nlist_bitvector, (nsym >> 3) + 1);
-
- /* Read in the strings */
- entry->strings = (char *)alloca(entry->string_size);
- read_entry_strings(file_open(entry), entry);
-
- if (!(entry->flags & E_DYNAMIC)) {
- /* Do text warnings based on a scan through the reloc info. */
- do_relocation_warnings(entry, 0, outfile, nlist_bitvector);
-
- /* Do data warnings based on a scan through the reloc info. */
- do_relocation_warnings(entry, 1, outfile, nlist_bitvector);
- }
-
- /*
- * Scan through all of the nlist entries in this file and pick up
- * anything that the scan through the relocation stuff didn't.
- */
- text_scan = init_debug_scan(0, entry);
- data_scan = init_debug_scan(1, entry);
-
- for (i = 0; i < nsym; i++) {
- struct nlist *np;
- symbol *g;
-
- g = entry->symbols[i].symbol;
- np = &entry->symbols[i].nzlist.nlist;
-
- if (g == NULL)
- continue;
-
- if (!(np->n_type & N_EXT) && !SET_ELEMENT_P(np->n_type)) {
- warnx("internal error: `%s' N_EXT not set", demangle(g->name));
- continue;
- }
-
- if (!(g->flags & GS_REFERENCED)) {
-#if 0
- /* Check for undefined shobj symbols */
- struct localsymbol *lsp;
- register int type;
-
- for (lsp = g->sorefs; lsp; lsp = lsp->next) {
- type = lsp->nzlist.nz_type;
- if ((type & N_EXT) &&
- type != (N_UNDF | N_EXT)) {
- break;
- }
- }
- if (type == (N_UNDF | N_EXT)) {
- fprintf(stderr,
- "Undefined symbol %s referenced from %s\n",
- demangle(g->name),
- get_file_name(entry));
- }
-#endif
- continue;
- }
-
- dont_allow_symbol_name = 0;
-
- if (list_multiple_defs && g->mult_defs) {
-
- errfmt = "Definition of symbol `%s' (multiply defined)";
- switch (np->n_type) {
- case N_TEXT | N_EXT:
- line_number =
- address_to_line(np->n_value, text_scan);
- file_name = text_scan[0].filename;
- break;
-
- case N_DATA | N_EXT:
- line_number =
- address_to_line(np->n_value, data_scan);
- file_name = data_scan[0].filename;
- break;
-
- case N_SETA | N_EXT:
- case N_SETT | N_EXT:
- case N_SETD | N_EXT:
- case N_SETB | N_EXT:
- if (g->mult_defs == 2)
- continue;
- errfmt =
- "First set element definition of symbol `%s' (multiply defined)";
- line_number = -1;
- break;
-
- case N_SIZE | N_EXT:
- errfmt =
- "Size element definition of symbol `%s' (multiply defined)";
- line_number = -1;
- break;
-
- case N_INDR | N_EXT:
- errfmt =
- "Alias definition of symbol `%s' (multiply defined)";
- line_number = -1;
- break;
-
- case N_UNDF | N_EXT:
- /* Don't print out multiple defs at references.*/
- continue;
-
- default:
- warnx("%s: unexpected multiple definitions "
- "of symbol `%s', type %#x",
- get_file_name(entry),
- demangle(g->name), np->n_type);
- break;
- }
-
- } else if (BIT_SET_P(nlist_bitvector, i)) {
- continue;
- } else if (list_unresolved_refs &&
- !g->defined && !g->so_defined) {
-
- if (g->undef_refs == 0)
- reported_undefineds++;
- if (g->undef_refs >= MAX_UREFS_PRINTED)
- continue;
- if (++(g->undef_refs) == MAX_UREFS_PRINTED)
- errfmt = "More undefined `%s' refs follow";
- else
- errfmt = "Undefined symbol `%s' referenced";
- line_number = -1;
- } else if (g->def_lsp && g->def_lsp->entry != entry &&
- !(entry->flags & E_DYNAMIC) &&
- g->def_lsp->entry->flags & E_SECONDCLASS) {
- fprintf(outfile,
- "%s: Undefined symbol `%s' referenced (use %s ?)\n",
- get_file_name(entry),
- demangle(g->name),
- g->def_lsp->entry->local_sym_name);
- continue;
- } else if (g->warning) {
- /*
- * There are two cases in which we don't want to do
- * this. The first is if this is a definition instead
- * of a reference. The second is if it's the reference
- * used by the warning stabs itself.
- */
- if (np->n_type != (N_EXT | N_UNDF) ||
- (entry->symbols[i].flags & LS_WARNING))
- continue;
-
- errfmt = g->warning;
- line_number = -1;
- dont_allow_symbol_name = 1;
- } else
- continue;
-
- if (line_number == -1)
- fprintf(outfile, "%s: ", get_file_name(entry));
- else
- fprintf(outfile, "%s:%d: ", file_name, line_number);
-
- if (dont_allow_symbol_name)
- fprintf(outfile, "%s", errfmt);
- else
- fprintf(outfile, errfmt, demangle(g->name));
-
- fputc('\n', outfile);
- }
- free(text_scan);
- free(data_scan);
- entry->strings = 0; /* Since it will disappear anyway. */
-}
-
-int
-do_warnings(outfile)
- FILE *outfile;
-{
-
- list_unresolved_refs = !relocatable_output &&
- ( (undefined_global_sym_count - undefined_weak_sym_count) > 0
- || undefined_shobj_sym_count
- );
- list_multiple_defs = multiple_def_count != 0;
-
- if (!(list_unresolved_refs ||
- list_warning_symbols ||
- list_multiple_defs))
- /* No need to run this routine */
- return 1;
-
- if (entry_symbol && !entry_symbol->defined)
- fprintf(outfile, "Undefined entry symbol `%s'\n",
- demangle(entry_symbol->name));
-
- each_file(do_file_warnings, (void *)outfile);
-
- if (list_unresolved_refs &&
- reported_undefineds !=
- (undefined_global_sym_count - undefined_weak_sym_count))
- warnx("Spurious undefined symbols: "
- "# undefined symbols %d, reported %d",
- (undefined_global_sym_count - undefined_weak_sym_count),
- reported_undefineds);
-
- if (list_unresolved_refs || list_multiple_defs)
- return 0;
-
- return 1;
-}
diff --git a/gnu/usr.bin/ld/xbits.c b/gnu/usr.bin/ld/xbits.c
deleted file mode 100644
index 850c646..0000000
--- a/gnu/usr.bin/ld/xbits.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 1993 Paul Kranenburg
- * 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 Paul Kranenburg.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $Id$
- */
-
-/*
- * "Generic" byte-swap routines.
- */
-
-#include <sys/param.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <ar.h>
-#include <ranlib.h>
-#include <a.out.h>
-#include <stab.h>
-#include <string.h>
-
-#include "ld.h"
-#include "dynamic.h"
-
-void
-swap_longs(lp, n)
-int n;
-long *lp;
-{
- for (; n > 0; n--, lp++)
- *lp = md_swap_long(*lp);
-}
-
-void
-swap_symbols(s, n)
-struct nlist *s;
-int n;
-{
- for (; n; n--, s++) {
- s->n_un.n_strx = md_swap_long(s->n_un.n_strx);
- s->n_desc = md_swap_short(s->n_desc);
- s->n_value = md_swap_long(s->n_value);
- }
-}
-
-void
-swap_zsymbols(s, n)
-struct nzlist *s;
-int n;
-{
- for (; n; n--, s++) {
- s->nz_strx = md_swap_long(s->nz_strx);
- s->nz_desc = md_swap_short(s->nz_desc);
- s->nz_value = md_swap_long(s->nz_value);
- s->nz_size = md_swap_long(s->nz_size);
- }
-}
-
-
-void
-swap_ranlib_hdr(rlp, n)
-struct ranlib *rlp;
-int n;
-{
- for (; n; n--, rlp++) {
- rlp->ran_un.ran_strx = md_swap_long(rlp->ran_un.ran_strx);
- rlp->ran_off = md_swap_long(rlp->ran_off);
- }
-}
-
-void
-swap__dynamic(dp)
-struct _dynamic *dp;
-{
- dp->d_version = md_swap_long(dp->d_version);
- dp->d_debug = (struct so_debug *)md_swap_long((long)dp->d_debug);
- dp->d_un.d_sdt = (struct section_dispatch_table *)
- md_swap_long((long)dp->d_un.d_sdt);
- dp->d_entry = (struct ld_entry *)md_swap_long((long)dp->d_entry);
-}
-
-void
-swap_section_dispatch_table(sdp)
-struct section_dispatch_table *sdp;
-{
- swap_longs((long *)sdp, sizeof(*sdp)/sizeof(long));
-}
-
-void
-swap_so_debug(ddp)
-struct so_debug *ddp;
-{
- swap_longs((long *)ddp, sizeof(*ddp)/sizeof(long));
-}
-
-void
-swapin_sod(sodp, n)
-struct sod *sodp;
-int n;
-{
- unsigned long bits;
-
- for (; n; n--, sodp++) {
- sodp->sod_name = md_swap_long(sodp->sod_name);
- sodp->sod_major = md_swap_short(sodp->sod_major);
- sodp->sod_minor = md_swap_short(sodp->sod_minor);
- sodp->sod_next = md_swap_long(sodp->sod_next);
- bits = ((unsigned long *)sodp)[1];
- sodp->sod_library = ((bits >> 24) & 1);
- }
-}
-
-void
-swapout_sod(sodp, n)
-struct sod *sodp;
-int n;
-{
- unsigned long bits;
-
- for (; n; n--, sodp++) {
- sodp->sod_name = md_swap_long(sodp->sod_name);
- sodp->sod_major = md_swap_short(sodp->sod_major);
- sodp->sod_minor = md_swap_short(sodp->sod_minor);
- sodp->sod_next = md_swap_long(sodp->sod_next);
- bits = (unsigned long)(sodp->sod_library) << 24;
- ((unsigned long *)sodp)[1] = bits;
- }
-}
-
-void
-swap_rrs_hash(fsp, n)
-struct rrs_hash *fsp;
-int n;
-{
- for (; n; n--, fsp++) {
- fsp->rh_symbolnum = md_swap_long(fsp->rh_symbolnum);
- fsp->rh_next = md_swap_long(fsp->rh_next);
- }
-}
-
diff --git a/gnu/usr.bin/man/COPYING b/gnu/usr.bin/man/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/man/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/man/Makefile b/gnu/usr.bin/man/Makefile
deleted file mode 100644
index 2529d8d..0000000
--- a/gnu/usr.bin/man/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# Master Makefile for man, manpath, apropos, whatis, and makewhatis
-#
-# You may distribute under the terms of the GNU General Public
-# License as specified in the README file that comes with the man 1.0
-# distribution.
-#
-
-SUBDIR = lib man manpath apropos makewhatis catman
-
-.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/man/Makefile.inc b/gnu/usr.bin/man/Makefile.inc
deleted file mode 100644
index b8a3e55..0000000
--- a/gnu/usr.bin/man/Makefile.inc
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Set a bunch of things to hardcoded paths so that we don't accidently
-# pick up a user's own version of some utility and hose ourselves.
-#
-BINDIR?= /usr/bin
-libdir= /etc
-bindir= ${BINDIR}
-pager= more -s
-manpath_config_file= /etc/manpath.config
-troff= /usr/bin/groff -man
-nroff= /usr/bin/groff -Wall -mtty-char -Tascii -man
-apropos= /usr/bin/apropos
-whatis= /usr/bin/whatis
-neqn= /usr/bin/eqn -Tascii
-tbl= /usr/bin/tbl
-col= /usr/bin/col
-vgrind= /usr/bin/vgrind
-refer= /usr/bin/refer
-grap= # no grap
-pic= /usr/bin/pic
-zcat= /usr/bin/zcat
-compress= /usr/bin/gzip -c
-compext= .gz
diff --git a/gnu/usr.bin/man/Makefile.shprog b/gnu/usr.bin/man/Makefile.shprog
deleted file mode 100644
index 665a194..0000000
--- a/gnu/usr.bin/man/Makefile.shprog
+++ /dev/null
@@ -1,30 +0,0 @@
-# $Id$
-
-# This may become bsd.shprog.mk. The general version would have to handle:
-# - arbitrary sed substitutions.
-# - programs without man pages.
-# - programs with man pages in sections other than section 1.
-
-MAN1= ${SHPROG:S/$/.1/g}
-
-CLEANFILES+= ${SHPROG} ${MAN1}
-
-all: ${SHPROG}
-
-.sh:
- sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
- -e 's,%pager%,${pager},' \
- ${.ALLSRC} > ${.TARGET}
-
-.SUFFIXES: .man .1
-.man.1:
- sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
- -e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \
- -e 's,%manpath_config_file%,${manpath_config_file},' \
- ${.ALLSRC} > ${.TARGET}
-
-beforeinstall:
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${SHPROG} ${DESTDIR}${BINDIR}
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/man/README b/gnu/usr.bin/man/README
deleted file mode 100644
index d8fc4d4..0000000
--- a/gnu/usr.bin/man/README
+++ /dev/null
@@ -1,134 +0,0 @@
-README file for man(1).
-
-This is a replacement for Un*x man(1), apropos(1), whatis(1), and
-manpath(1). It has all kinds of neat features that other versions of
-man don't, including support for multiple man page directory trees,
-preformatted man pages, and troff. It is provided without any
-warranty whatever. I hope you find it useful.
-
-This program is not a GNU product but it is distributed under the
-terms of the GNU copyleft which is described in the file COPYING.
-
-There is a solution written in perl which is probably superior in
-every way, but, like me, you may prefer this one anyway.
-:-)
-
-If you compile with support for preformatted man pages, man(1) will
-try to update the preformatted page if the man page source is newer.
-
-If you compile with support for troff, you can say things like
-`man -t foo | psdit > foo.ps' and have fabulous printed documentation
-as well.
-
-I have resisted the temptation to handle all the bizarre ways various
-vendors have of organizing man pages. This version of man assumes
-that directory trees have the structure:
-
- .../man
- /manSect
- /foo.Sect*
- ...
- /catSect
- /foo.Sect*
- ...
-
-where Sect is some number or string and should be listed in the set of
-sections to be searched. It is not necessary to have both the cat*
-and man* subdirectories, but you must have at least one. :-)
-
-
-INSTALLATION
-
-1. Run configure. This will grope around your system a bit and then
- ask you a number of questions. It will create a Makefile from the
- file Makefile.in, and a config.h file from config.h.in. You may
- have to do some fine tuning to get things to work exactly right on
- your system. If you do, I'd like to know what changes you had to
- make to get things working.
-
-2. Edit the manpath.config file. This determines the system-wide
- mappings for bin directories and man page directories.
-
-3. Do a `make all', try it out, and then if you're happy with that, do
- a `make install'. You don't need to be root to use this set of
- programs.
-
-4. Install the whatis database(s) by running makewhatis. If you want
- to keep things absolutely current, you'll need to run this whenever
- you add new man pages. You might want to add an entry in your
- crontab.
-
-BUGS
-
-If you find one of these, please tell me about it. If you have a fix,
-that's even better. If not, I can't guarantee that I'll fix it, but I
-would like to know about them.
-
-John Eaton
-jwe@che.utexas.edu
-Department of Chemical Engineering
-The University of Texas at Austin
-Austin, Texas 78712
-
-
-CHANGES
-
-Partial list of changes since version 1.0:
-
-Installation made easier (this was the intent anyway) with the
-introduction of a configure script.
-
-Commands like `man 3f intro' handled properly when the name of the
-file we want is something like .../man3/intro.3f.
-
-Man can now run set uid to a special user so formatted man pages don't
-have to be world writable.
-
-Man now works with compressed (.Z) frozen (.F) and yabba (.Y) cat
-files. Frozen files are compressed files using freeze/melt, some
-combination of LZW and tree coding. Sources for it came out on
-comp.sources.misc or alt.sources or ... a few months ago. Yabba files
-are compressed using yabba/unyabba, a data compression scheme posted
-to alt.sources by Dan Bernstein.
-
-Man now uses a more reasonable default for the search order:
-1, n, l, 6, 8, 2, 3, 4, 5, 7, p, o
-
-Man now allows for user-definable section search order via -S or
-MANSECT.
-
-Glob.c can work even if you don't have alloca, and works properly on
-Suns with the Sun C compiler.
-
-There is now a way to automatically to run preprocessors like the Sun
-man program. The first line of the man page indicates which
-preprocessors should be run:
-
- If the first line is a string of the form:
-
- '\" X
-
- where X is separated from the the `"' by a single SPACE and
- consists of any combination of characters in the following
- list, man pipes its input to troff(1) or nroff(1) through
- the corresponding preprocessors.
-
- e eqn(1), or neqn for nroff
- g grap(1)
- p pic(1)
- r refer(1)
- t tbl(1), and col(1V) for nroff
- v vgrind(1)
-
-Preprocessors may also be set on the command line with -p or from the
-environment with MANROFFSEQ.
-
-The tbl preprocessor is run by default.
-
-Manpath now stat()'s the directories in MANPATH to avoid including
-directories that don't exist.
-
-The output of apropos and whatis are now piped through PAGER.
-
-There is a new option to show where you would find a man page
-(-w option) and in what order (-w with -a).
diff --git a/gnu/usr.bin/man/TODO b/gnu/usr.bin/man/TODO
deleted file mode 100644
index 19060ad..0000000
--- a/gnu/usr.bin/man/TODO
+++ /dev/null
@@ -1,123 +0,0 @@
-Things that would be nice but aren't really necessary:
-
-0. Update the documentation.
-
-XX Come up with an easier way to install this thing. There are now
- lots of options and dependent flags to set. Should I worry too
- much about this?
-
-XX Properly handle commands like `man 3f intro' when the name of the
- file we want is something like .../man3/intro.3f. The way this is
- done right now seems sort of kludgey but it mostly works. See
- man.c for details.
-
-2. Malloc everything instead of having fixed limits... Or at least
- check the limits everywhere. If you're paranoid about this, make
- the limits big (famous last words: really, there aren't that many
- things that could go wrong :-).
-
-3. Try to do a little better job of memory management. There are a
- lot of little temporary strings that are malloc'd and never freed.
- This is probably ok for a standalone program but not so good if
- you wanted to call man() from another program.
-
-XX Come up with a clear view of the cat directory file permissions
- problem. What's a good solution, other than having man run setuid
- to some special user? (Make directories writable by all, cat
- files 666.)
-
-XX Allow a compile time option that makes man run setuid to some
- other user that owns all the cat pages, so that they don't have to
- be world writable.
-
-XX Allow man to deal with compressed (.Z) frozen (.F) and yabba (.Y)
- cat files. Frozen files are compressed files using freeze/melt,
- some combination of LZW and tree coding. Sources for it came out
- on comp.sources.misc or alt.sources or ... a few months ago.
- Yabba files are compressed using yabba/unyabba, a data compression
- scheme posted to alt.sources by Dan Bernstein.
-
-XX Choose a more reasonable default for the search order. Perhaps
- this: 1, n, l, 6, 8, 2, 3, 4, 5, 7, p, o
-
-XX Fix glob.c so it doesn't need alloca, and/or fix it so that it can
- work on a Sun:
-
- #ifdef __GNUC__
- #define alloca __builtin_alloca
- #else /* !__GNUC__ */
- #ifdef sparc
- #include <alloca.h>
- #endif /* sparc */
- #endif /* __GNUC__ */
-
-XX Add some way to automatically to run preprocessors. The Sun man
- program has a convention that the first line of the man page can
- indicate which preprocessors should be run. Here's an excerpt from
- its man page:
-
- Preprocessing Manual Pages
- If the first line is a string of the form:
-
- '\" X
-
- where X is separated from the the `"' by a single SPACE and
- consists of any combination of characters in the following
- list, man pipes its input to troff(1) or nroff(1) through
- the corresponding preprocessors.
-
- e eqn(1), or neqn for nroff
- r refer(1)
- t tbl(1), and col(1V) for nroff
- v vgrind(1)
-
- If eqn or neqn is invoked, it will automatically read the
- file /usr/pub/eqnchar (see eqnchar(7)).
-
-XX Have manpath stat() the directories in MANPATH to avoid including
- directories that don't exist. Some versions of man and whatis
- complain when the directories (like /usr/new/man) don't exist.
-
-XX Pipe the output of apropos and whatis through a pager.
-
-XX I've been using your man(1) package for a while now and I ran into
- a problem with the X man pages that use tbl commands. Is it
- possible to configure your man(1) package to use a general command
- string. For example, a user could set an environment variable:
-
- setenv ROFFLINE 'pic $* | tbl | nroff -man'
-
-13. Fix makewhatis so that it can handle stuff like this (from the
- Motif 1.1 man pages):
-
- .TH XmRowColumn 3X "" "" "" ""
- .SH NAME
- .mc |
- \fBXmRowColumn \(em the RowColumn widget class.\fP
- .mc
- .iX "XmRowColumn"
- .iX "widget class" "RowColumn"
- .sp 1
- .SH SYNOPSIS
-
-14. Consider changing the format of the awk command's printf to use
- "%s" instead of the standard 20.20s to accomodate the extra long
- file names used by Motif. Maybe there's a better way to handle
- this?
-
-15. Add ability to run man on a local file
-
-16. Handle per-tree tmac macros
-
-XX Allow user-definable section search order via -S or $MANSECT.
- Thus programmers can get stty(3) before stty(1).
-
-XX Show all the places you would find a man page (-w option) and in
- what order.
-
-19. Support for multi-char sections like man1m/*.1m or manavs/*.avs
- (can I have a section that doesn't start with a numeral?)
-
-20. Implement man -K for regexp apropos
-
-21. An option to grep through all the man pages in $MANPATH
diff --git a/gnu/usr.bin/man/apropos/Makefile b/gnu/usr.bin/man/apropos/Makefile
deleted file mode 100644
index d19c285..0000000
--- a/gnu/usr.bin/man/apropos/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Id$
-
-SHPROG= apropos
-
-MLINKS= apropos.1 whatis.1
-LINKS= ${BINDIR}/apropos ${BINDIR}/whatis
-
-.include "../../Makefile.inc"
-.include "../Makefile.shprog"
diff --git a/gnu/usr.bin/man/apropos/apropos.man b/gnu/usr.bin/man/apropos/apropos.man
deleted file mode 100644
index 8cac9a9..0000000
--- a/gnu/usr.bin/man/apropos/apropos.man
+++ /dev/null
@@ -1,40 +0,0 @@
-.\" Man page for apropos an whatis
-.\"
-.\" Copyright (c) 1990, 1991, John W. Eaton.
-.\"
-.\" You may distribute under the terms of the GNU General Public
-.\" License as specified in the README file that comes with the man 1.0
-.\" distribution.
-.\"
-.\" John W. Eaton
-.\" jwe@che.utexas.edu
-.\" Department of Chemical Engineering
-.\" The University of Texas at Austin
-.\" Austin, Texas 78712
-.\"
-.Dd Jan 15, 1991
-.Dt APROPOS 1
-.Os
-.Sh NAME
-.Nm apropos , whatis
-.Nd search the whatis database
-.Sh SYNOPSIS
-.Nm apropos
-.Ar keyword ...
-.br
-.Nm whatis
-.Ar keyword ...
-.Sh DESCRIPTION
-.Nm apropos
-searches a set of database files containing short descriptions
-of system commands for keywords and displays the result on the
-standard output.
-.Nm whatis
-displays only complete word matches.
-.Sh RETURN VALUES
-The
-.Nm apropos
-utility exits 0 on success, and 1 if no keyword matched.
-.Sh SEE ALSO
-.Xr man 1 ,
-.Xr makewhatis 1
diff --git a/gnu/usr.bin/man/apropos/apropos.sh b/gnu/usr.bin/man/apropos/apropos.sh
deleted file mode 100644
index 1b548a6..0000000
--- a/gnu/usr.bin/man/apropos/apropos.sh
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/bin/sh
-#
-# apropos -- search the whatis database for keywords.
-#
-# Copyright (c) February 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
-# Copyright (c) 1990, 1991, John W. Eaton.
-#
-# You may distribute under the terms of the GNU General Public
-# License as specified in the README file that comes with the man
-# distribution.
-#
-# John W. Eaton
-# jwe@che.utexas.edu
-# Department of Chemical Engineering
-# The University of Texas at Austin
-# Austin, Texas 78712
-#
-# $Id$
-
-
-PATH=/bin:/usr/bin:$PATH
-db=whatis # name of whatis data base
-grepopt=''
-
-# man -k complain if exit_nomatch=1 and no keyword matched
-: ${exit_nomatch=0}
-exit_error=2
-
-# argument test
-case $# in 0)
- echo "usage: `basename $0` keyword ..." >&2
- exit $exit_error
- ;;
-esac
-
-case "$0" in
- *whatis) grepopt='-w';; # run as whatis(1)
- *) grepopt='';; # otherwise run as apropos(1)
-esac
-
-# test manpath
-manpath=`%bindir%/manpath -q | tr : '\040'`
-case X"$manpath" in X)
- echo "`basename $0`: manpath is null, use \"/usr/share/man\"" >&2
- manpath=/usr/share/man
- ;;
-esac
-
-
-# reset $PAGER if $PAGER is empty
-case X"$PAGER" in X)
- PAGER="%pager%"
- ;;
-esac
-
-# search for existing */whatis databases
-mandir=''
-for d in $manpath
-do
- if [ -f "$d/$db" -a -r "$d/$db" ]
- then
- mandir="$mandir $d/$db"
- fi
-done
-
-case X"$mandir" in X)
- echo "`basename $0`: no whatis databases in $manpath" >&2
- exit $exit_error
-esac
-
-
-for manpage
-do
- if grep -hi $grepopt -- "$manpage" $mandir; then :
- else
- echo "$manpage: nothing appropriate"
- fi
-done |
-
-( # start $PAGER only if we find a manual page
- while read line
- do
- case $line in
- # collect error(s)
- *": nothing appropriate") line2="$line2$line\n";;
- # matched line or EOF
- *) break;;
- esac
- done
-
- # nothing found, exit
- if test -z "$line" -a ! -z "$line2"; then
- printf -- "$line2"
- exit $exit_nomatch
- else
- ( printf -- "$line2"; echo $line; cat ) | $PAGER
- fi
-)
diff --git a/gnu/usr.bin/man/catman/Makefile b/gnu/usr.bin/man/catman/Makefile
deleted file mode 100644
index 3b919e1..0000000
--- a/gnu/usr.bin/man/catman/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-MAN1= catman.1
-
-beforeinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/catman.perl ${DESTDIR}${BINDIR}/catman
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/man/catman/catman.1 b/gnu/usr.bin/man/catman/catman.1
deleted file mode 100644
index b23a6c6..0000000
--- a/gnu/usr.bin/man/catman/catman.1
+++ /dev/null
@@ -1,133 +0,0 @@
-.\" Copyright (c) March 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-.\"
-.\" /usr/bin/catman - preformat man pages
-.\"
-.\" $Id: catman.1,v 1.12 1997/02/22 15:46:59 peter Exp $
-.Dd Mar 12, 1995
-.Dt CATMAN 1
-.Os
-.Sh NAME
-.Nm catman
-.Nd preformat man pages
-.Sh SYNOPSIS
-.Nm catman
-.Op Fl f | Fl force
-.Op Fl h | Fl help
-.Op Fl p | Fl print
-.Op Fl r | Fl remove
-.Op Fl v | Fl verbose
-.Op Ar directories...
-.Sh DESCRIPTION
-.Nm Catman
-format man pages to ASCII. It's like typing
-.Sq man program
-for all man pages in
-.Ar directories .
-.Ar Directories
-is a list of man directories or subdirectories separated
-by spaces or colons.
-Use
-.Ar /usr/share/man
-if no
-.Ar directories
-defined.
-.Sh OPTIONS
-.Bl -tag -width Ds
-.It Fl f , Fl force
-Force overwriting old cat pages. Normally only those pages will be formatted
-which are not up to date. This option is a waste of time, CPU and RAM.
-.It Fl h , Fl help
-Print options and exit.
-.It Fl p , Fl print
-Don't actually format man pages. Show what would be done.
-.It Fl r , Fl remove
-Remove garbage, e.\& g. catpage without manpage, uncompressed catpage but
-a compressed catpage exist, filenames with non-alphanumeric
-characters, uncompressed manpage but a compressed manpage exist.
-.It Fl v , Fl verbose
-More warnings.
-.Sh EXAMPLES
-.Pp
-.Dl $ catman
-.Pp
-Format man pages in
-.Ar /usr/share/man
-if necessary.
-.Pp
-.Dl $ catman $MANPATH
-.Pp
-Format all your man pages if necessary.
-.Pp
-.Dl $ catman -f /usr/local/man/man1 /usr/local/man/manl
-.Pp
-Force reformatting of all man pages in
-.Pa /usr/local/man/man1
-and
-.Pa /usr/local/man/manl .
-.Pp
-.Dl $ catman -p /usr/X11/man
-.Pp
-Show only.
-.Sh FILES
-.Bl -tag -width /etc/weeklyxxx -compact
-.Pa /etc/weekly
-Starts this program
-.Po
-or
-.Pa /etc/daily
-.Pc
-.El
-.Sh FEATURES
-Very fast if all man pages already formatted.
-Does not support the
-.Fl w
-option as some other systems do. Use
-.Xr makewhatis 1
-to rebuild the
-.Ql whatis
-database.
-.Sh BUGS
-.Xr man 1
-is a setuid program. Be careful that user
-.Sq man
-has write permissions to the catman directories.
-.Nm Catman
-does not check for any
-.Sq .so
-in man page sources. Use hard or symlinks
-to avoid redundant formatted man pages.
-.Sh SEE ALSO
-.Xr makewhatis 1 ,
-.Xr man 1 ,
-.Xr manpath 1
-.Sh HISTORY
-This version of
-.Nm catman
-command appeared in
-.Fx 2.1 .
-.Sh AUTHOR
-Wolfram Schneider
-.Aq wosch@FreeBSD.org ,
-Berlin.
diff --git a/gnu/usr.bin/man/catman/catman.perl b/gnu/usr.bin/man/catman/catman.perl
deleted file mode 100644
index 70be35f..0000000
--- a/gnu/usr.bin/man/catman/catman.perl
+++ /dev/null
@@ -1,386 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) March 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# /usr/bin/catman - preformat man pages
-#
-# $Id$
-
-
-sub usage {
-
-warn <<EOF;
-usage: catman [-h|-help] [-f|-force] [-p|-print] [-r|remove]
- [-v|-verbose] [directories ...]
-EOF
-
-exit 1;
-}
-
-sub variables {
- $force = 0; # force overwriting existing catpages
- $verbose = 0; # more warnings
- $print = 0; # show only, do nothing
- $remove = 0; # unlink forgotten man/catpages
-
- # if no argument for directories given
- @defaultmanpath = ( '/usr/share/man' );
-
- $exit = 0; # exit code
- $ext = ".gz"; # extension
- umask(022);
-
- # Signals
- $SIG{'INT'} = 'Exit';
- $SIG{'HUP'} = 'Exit';
- $SIG{'TRAP'} = 'Exit';
- $SIG{'QUIT'} = 'Exit';
- $SIG{'TERM'} = 'Exit';
- $tmp = ''; # tmp file
-
- $ENV{'PATH'} = '/bin:/usr/bin';
-}
-
-sub Exit {
- unlink($tmp) if $tmp ne ""; # unlink if a filename
- die "$0: die on signal SIG@_\n";
-}
-
-sub parse {
- local(@argv) = @_;
-
- while($_ = $argv[0], /^-/) {
- shift @argv;
- last if /^--$/;
- if (/^--?(f|force)$/) { $force = 1 }
- elsif (/^--?(p|print)$/) { $print = 1 }
- elsif (/^--?(r|remove)$/) { $remove = 1 }
- elsif (/^--?(v|verbose)$/) { $verbose = 1 }
- else { &usage }
- }
-
- return &absolute_path(@argv) if $#argv >= 0;
- return @defaultmanpath if $#defaultmanpath >= 0;
-
- warn "Missing directories\n"; &usage;
-}
-
-# make relative path to absolute path
-sub absolute_path {
- local(@dirlist) = @_;
- local($pwd, $dir, @a);
-
- $pwd = $ENV{'PWD'};
-
- foreach $dir (@dirlist) {
- if ($dir !~ "^/") {
- chop($pwd = `pwd`) if (!$pwd || $pwd !~ /^\//);
- push(@a, "$pwd/$dir");
- } else {
- push(@a, $dir);
- }
- }
- return @a;
-}
-
-# strip unused '/'
-# e.g.: //usr///home// -> /usr/home
-sub stripdir {
- local($dir) = @_;
-
- $dir =~ s|/+|/|g; # delete double '/'
- $dir =~ s|/$||; # delete '/' at end
- $dir =~ s|/(\.\/)+|/|g; # delete ././././
-
- $dir =~ s|/+|/|g; # delete double '/'
- $dir =~ s|/$||; # delete '/' at end
- $dir =~ s|/\.$||; # delete /. at end
- return $dir if $dir ne "";
- return '/';
-}
-
-# read man directory
-sub parse_dir {
- local($dir) = @_;
- local($subdir, $catdir);
- local($dev,$ino) = (stat($dir))[01];
-
- # already visit
- if ($dir_visit{$dev,$ino}) {
- warn "$dir already parsed: $dir_visit{$dev,$ino}\n";
- return 1;
- }
- $dir_visit{$dev,$ino} = $dir;
-
- # Manpath, /usr/local/man
- if ($dir =~ /man$/) {
- warn "open manpath directory ``$dir''\n" if $verbose;
- if (!opendir(DIR, $dir)) {
- warn "opendir ``$dir'':$!\n"; $exit = 1; return 0;
- }
-
- warn "chdir to: $dir\n" if $verbose;
- chdir($dir) || do { warn "$dir: $!\n"; $exit = 1; return 0 };
-
- foreach $subdir (sort(readdir(DIR))) {
- if ($subdir =~ /^man\w+$/) {
- $subdir = "$dir/$subdir";
- &catdir_create($subdir) && &parse_subdir($subdir);
- }
- }
- closedir DIR
-
- # subdir, /usr/local/man/man1
- } elsif ($dir =~ /man\w+$/) {
- local($parentdir) = $dir;
- $parentdir =~ s|/[^/]+$||;
- warn "chdir to: $parentdir\n" if $verbose;
- chdir($parentdir) || do {
- warn "$parentdir: $!\n"; $exit = 1; return 0 };
-
- &catdir_create($dir) && &parse_subdir($dir);
- } else {
- warn "Assume ``$dir'' is not a man directory.\n";
- $exit = 1;
- }
-}
-
-# create cat subdirectory if neccessary
-# e.g.: man9 exist, but cat9 not
-sub catdir_create {
- local($subdir) = @_;
- local($catdir) = $subdir;
-
- $catdir = &man2cat($subdir);
- if (-d $catdir) {
- return 1 if -w _;
- if (!chmod(755, $catdir)) {
- warn "Cannot write $catdir, chmod: $!\n";
- $exit = 1;
- return 0;
- }
- return 1;
- }
-
- warn "mkdir ``$catdir''\n" if $verbose || $print;
- unless ($print) {
- unlink($catdir); # be paranoid
- if (!mkdir($catdir, 0755)) {
- warn "Cannot make $catdir: $!\n";
- $exit = 1;
- return 0;
- }
- return 1;
- }
-}
-
-# I: /usr/share/man/man9
-# O: /usr/share/man/cat9
-sub man2cat {
- local($man) = @_;
-
- $man =~ s/man(\w+)$/cat$1/;
- return $man;
-}
-
-sub parse_subdir {
- local($subdir) = @_;
- local($file, $f, $catdir, $catdir_short, $mandir, $mandir_short);
- local($mtime_man, $mtime_cat);
- local(%read);
-
-
- $mandir = $subdir;
- $catdir = &man2cat($mandir);
-
- ($mandir_short = $mandir) =~ s|.*/(.*)|$1|;
- ($catdir_short = $catdir) =~ s|.*/(.*)|$1|;
-
- warn "open man directory: ``$mandir''\n" if $verbose;
- if (!opendir(D, $mandir)) {
- warn "opendir ``$mandir'': $!\n"; $exit = 1; return 0;
- }
-
- foreach $file (readdir(D)) {
- # skip current and parent directory
- next if $file eq "." || $file eq "..";
-
- # fo_09-o.bar0
- if ($file !~ /^[\w\-\+\[\.]+\.\w+$/) {
- &garbage("$mandir/$file", "Assume garbage")
- unless -d "$mandir/$file";
- next;
- }
-
- if ($file !~ /\.gz$/) {
- if (-e "$mandir/$file.gz") {
- &garbage("$mandir/$file",
- "Manpage unused, see compressed version");
- next;
- }
- warn "$mandir/$file is uncompressed\n" if $verbose;
- $cfile = "$file.gz";
- } else {
- $cfile = "$file";
- }
-
- if (!(($mtime_man = ((stat("$mandir_short/$file"))[9])) && -r _ && -f _)) {
- if (! -d _) {
- warn "Cannot read file: ``$mandir/$file''\n";
- $exit = 1;
- if ($remove && -l "$mandir/$file") {
- &garbage("$mandir/$file", "Assume wrong symlink");
- }
- next;
- }
- warn "Ignore subsubdirectory: ``$mandir/$file''\n"
- if $verbose;
- next;
- }
-
- $read{$file} = 1;
-
- # Assume catpages always compressed
- if (($mtime_cat = ((stat("$catdir_short/$cfile"))[9]))
- && -r _ && -f _) {
- if ($mtime_man > $mtime_cat || $force) {
- &nroff("$mandir/$file", "$catdir/$cfile");
- } else {
- warn "up to date: $mandir/$file\n" if $verbose;
- #print STDERR "." if $verbose;
- }
- } else {
- &nroff("$mandir/$file", "$catdir/$cfile");
- }
- }
- closedir D;
-
- if (!opendir(D, $catdir)) {
- warn "opendir ``$catdir'': $!\n"; return 0;
- }
-
- warn "open cat directory: ``$catdir''\n" if $verbose;
- foreach $file (readdir(D)) {
- next if $file =~ /^(\.|\.\.)$/; # skip current and parent directory
-
- if ($file !~ /^[\w\-\+\[\.]+\.\w+$/) {
- &garbage("$catdir/$file", "Assume garbage")
- unless -d "$catdir/$file";
- next;
- }
-
- if ($file !~ /\.gz$/ && $read{"$file.gz"}) {
- &garbage("$catdir/$file",
- "Catpage unused, see compressed version");
- } elsif (!$read{$file}) {
- # maybe a bug in man(1)
- # if both manpage and catpage are uncompressed, man reformats
- # the manpage and puts a compressed catpage to the
- # already existing uncompressed catpage
- ($f = $file) =~ s/\.gz$//;
-
- # man page is uncompressed, catpage is compressed
- next if $read{$f};
- &garbage("$catdir/$file", "Catpage without manpage");
- }
- }
- closedir D;
-}
-
-sub garbage {
- local($file, @text) = @_;
-
- warn "@text: ``$file''\n";
- if ($remove) {
- warn "unlink $file\n";
- unless ($print) {
- unlink($file) || warn "unlink $file: $!\n" ;
- }
- }
-}
-
-sub nroff {
- local($man,$cat) = @_;
- local($nroff) = "nroff -Tascii -man | col";
- local($dev, $ino) = (stat($man))[01];
-
- # It's a link
- if ($link{"$dev.$ino"}) {
- warn "Link: $link{\"$dev.$ino\"} -> $cat\n" if $verbose || $print;
-
- return if $print; # done
- unlink($cat); # remove possible old link
-
- unless (link($link{"$dev.$ino"}, $cat)) {
- warn "Link $cat: $!\n";
- $exit = 1;
- }
- return;
- } else {
- $cat = "$cat$ext" if $cat !~ /$ext$/;
- warn "Format: $man -> $cat\n" if $verbose || $print;
-
- unless($print) {
- # man page is compressed
- if ($man =~ /$ext$/) {
- $nroff = "zcat $man | tbl | $nroff";
- } else {
- $nroff = "tbl $man | $nroff";
- }
-
- # start formatting
- $tmp = "$cat.$tmp"; # for cleanup after signals
- system("$nroff | gzip > $cat.tmp");
- if ($?) {
- # assume a fatal signal to nroff
- &Exit("INT to system() function") if ($? == 2);
- } else {
- rename("$cat.tmp", $cat);
- }
- }
- }
-
- # dev/ino from manpage, path from catpage
- $link{"$dev.$ino"} = $cat;
-}
-
-#############
-# main
-warn "Don't start this program as root, use:\n" .
- "echo $0 @ARGV | nice -5 su -m man\n" unless $>;
-
-&variables;
-foreach $dir (&parse(split(/[ :]/, join($", @ARGV)))) { #"
- if (-e $dir && -d _ && -r _ && -x _) {
- warn "``$dir'' is not writable for you,\n" .
- "can only write to existing cat subdirs (if any)\n"
- if ! -w _ && $verbose;
- &parse_dir(&stripdir($dir));
- } else {
- warn "``$dir'' is not a directory or not read-/searchable for you\n";
- $exit = 1;
- }
-}
-exit($exit);
diff --git a/gnu/usr.bin/man/lib/Makefile b/gnu/usr.bin/man/lib/Makefile
deleted file mode 100644
index 0419db38..0000000
--- a/gnu/usr.bin/man/lib/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-LIB= man
-INTERNALLIB= true
-INTERNALSTATICLIB= true
-
-CFLAGS+= -DSTDC_HEADERS
-CLEANFILES+= config.h
-SRCS= gripes.c util.c
-
-# Kludge to create config.h for other modules. The library itself doesn't
-# depend on config.h.
-all beforedepend: config.h
-
-config.h: ${.CURDIR}/config.h_dist ${.CURDIR}/../Makefile.inc
- sed -e 's,%apropos%,${apropos},' -e 's,%whatis%,${whatis},' \
- -e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \
- -e 's,%nroff%,${nroff},' -e 's,%tbl%,${tbl},' \
- -e 's,%col%,${col},' -e 's,%pic%,${pic},' \
- -e 's,%eqn%,${eqn},' -e 's,%neqn%,${neqn},' \
- -e 's,%vgrind%,${vgrind},' -e 's,%refer%,${refer},' \
- -e 's,%grap%,${grap},' -e 's,%zcat%,${zcat},' \
- -e 's,%manpath_config_file%,${manpath_config_file},' \
- -e 's,%compress%,${compress},' \
- -e 's,%compext%,${compext},' \
- ${.CURDIR}/config.h_dist > ${.TARGET}
-
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/man/lib/config.h_dist b/gnu/usr.bin/man/lib/config.h_dist
deleted file mode 100644
index 381ce13..0000000
--- a/gnu/usr.bin/man/lib/config.h_dist
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * config.h
- *
- * If you haven't read the README file, now might be a good time.
- *
- * This file is edited by configure, so you shouldn't have to.
- * If that doesn't work, edit this file to match your site.
- *
- * Sorry it's so long, but there are lots of things you might want to
- * customize for your site.
- *
- * Copyright (c) 1990, 1991, John W. Eaton.
- *
- * You may distribute under the terms of the GNU General Public
- * License as specified in the file COPYING that comes with the man
- * distribution.
- *
- * John W. Eaton
- * jwe@che.utexas.edu
- * Department of Chemical Engineering
- * The University of Texas at Austin
- * Austin, Texas 78712
- */
-
-/*
- * This is the size of a number of internal buffers. It should
- * probably not be less than 512.
- */
-#ifndef BUFSIZ
-#define BUFSIZ 1024
-#endif
-
-/*
- * This should be at least the size of the longest path.
- */
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
-#endif
-
-/*
- * This is the maximum number of directories expected in the manpath.
- */
-#ifndef MAXDIRS
-#define MAXDIRS 64
-#endif
-
-/*
- * This is the name of the group that owns the preformatted man pages.
- * If you are running man as a setgid program, you should make sure
- * that all of the preformatted man pages and the directories that
- * they live in are readable and writeable and owned by this group.
- */
-#ifdef SECURE_MAN_UID
-#define MAN_USER ""
-#endif
-
-/*
- * It's probably best to define absolute paths to all of these. If
- * you don't, you'll be depending on the user's path to be correct
- * when system () is called. This can result in weird behavior that's
- * hard to track down, especially after you forget how this program
- * works... If you don't have some of these programs, simply define
- * them to be empty strings (i.e. ""). As a minimum, you must have
- * nroff installed.
- */
-#ifndef APROPOS
-#define APROPOS "%apropos%"
-#endif
-
-#ifndef WHATIS
-#define WHATIS "%whatis%"
-#endif
-
-#ifndef PAGER
-#define PAGER "%pager%"
-#endif
-
-#ifdef HAS_TROFF
-#ifndef TROFF
-#define TROFF "%troff%"
-#endif
-#endif
-
-#ifndef NROFF
-#define NROFF "%nroff%"
-#endif
-
-#ifndef EQN
-#define EQN "%eqn%"
-#endif
-
-#ifndef NEQN
-#define NEQN "%neqn%"
-#endif
-
-#ifndef TBL
-#define TBL "%tbl%"
-#endif
-
-#ifndef COL
-#define COL "%col%"
-#endif
-
-#ifndef VGRIND
-#define VGRIND "%vgrind%"
-#endif
-
-#ifndef REFER
-#define REFER "%refer%"
-#endif
-
-#ifndef GRAP
-#define GRAP "%grap%"
-#endif
-
-#ifndef PIC
-#define PIC "%pic%"
-#endif
-
-/*
- * Define the absolute path to the configuration file.
- */
-#ifndef MAN_MAIN
- static char config_file[] = "%manpath_config_file%" ;
-#endif
-
-/*
- * Define the uncompression program(s) to use for those preformatted
- * pages that end in the given character. If you add extras here, you
- * may need to change man.c. [I have no idea what FCAT and YCAT files
- * are! - I will leave them in for now.. -jkh]
- */
-/* .F files */
-#define FCAT ""
-/* .Y files */
-#define YCAT ""
-/* .Z files */
-#define ZCAT "%zcat%"
-
-/*
- * This is the standard program to use on this system for compressing
- * pages once they have been formatted, and the character to tack on
- * to the end of those files. The program listed is expected to read
- * from the standard input and write compressed output to the standard
- * output. These won't actually be used unless compression is enabled.
- */
-#ifdef DO_COMPRESS
-#define COMPRESSOR "%compress%"
-#define COMPRESS_EXT "%compext%"
-#endif
-
-/*
- * Define the standard manual sections. For example, if your man
- * directory tree has subdirectories man1, man2, man3, mann,
- * and man3foo, std_sections[] would have "1", "2", "3", "n", and
- * "3foo". Directories are searched in the order they appear. Having
- * extras isn't fatal, it just slows things down a bit.
- *
- * Note that this is just for directories to search. If you have
- * files like .../man3/foobar.3Xtc, you don't need to have "3Xtc" in
- * the list below -- this is handled separately, so that `man 3Xtc foobar',
- * `man 3 foobar', and `man foobar' should find the file .../man3/foo.3Xtc,
- * (assuming, of course, that there isn't a .../man1/foo.1 or somesuch
- * that we would find first).
- *
- * Note that this list should be in the order that you want the
- * directories to be searched. Is there a standard for this? What is
- * the normal order? If anyone knows, please tell me!
- */
-#ifndef MANPATH_MAIN
- static char *std_sections[] =
- {
- "1", "8", "2", "3", "n", "4", "5", "6", "7", "9", "l", NULL
- };
-#endif
-
-/*
- * Not all systems define these in stat.h.
- */
-#ifndef S_IRUSR
-#define S_IRUSR 00400 /* read permission: owner */
-#endif
-#ifndef S_IWUSR
-#define S_IWUSR 00200 /* write permission: owner */
-#endif
-#ifndef S_IRGRP
-#define S_IRGRP 00040 /* read permission: group */
-#endif
-#ifndef S_IWGRP
-#define S_IWGRP 00020 /* write permission: group */
-#endif
-#ifndef S_IROTH
-#define S_IROTH 00004 /* read permission: other */
-#endif
-#ifndef S_IWOTH
-#define S_IWOTH 00002 /* write permission: other */
-#endif
-
-/*
- * This is the mode used for formatted pages that we create. If you
- * are using the setgid option, you should use 664. If you are not,
- * you should use 666 and make the cat* directories mode 777.
- */
-#ifndef CATMODE
-#ifdef SECURE_MAN_UID
-#define CATMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH
-#else
-#define CATMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
-#endif
-#endif
diff --git a/gnu/usr.bin/man/lib/gripes.c b/gnu/usr.bin/man/lib/gripes.c
deleted file mode 100644
index 466f0bc..0000000
--- a/gnu/usr.bin/man/lib/gripes.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * gripes.c
- *
- * Copyright (c) 1990, 1991, John W. Eaton.
- *
- * You may distribute under the terms of the GNU General Public
- * License as specified in the file COPYING that comes with the man
- * distribution.
- *
- * John W. Eaton
- * jwe@che.utexas.edu
- * Department of Chemical Engineering
- * The University of Texas at Austin
- * Austin, Texas 78712
- */
-
-#include <stdio.h>
-#include "gripes.h"
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-extern int fprintf ();
-extern int fflush ();
-extern int exit ();
-#endif
-
-extern char *prognam;
-
-void
-gripe_no_name (section)
- char *section;
-{
- if (section)
- fprintf (stderr, "What manual page do you want from section %s?\n",
- section);
- else
- fprintf (stderr, "What manual page do you want?\n");
-
- fflush (stderr);
-}
-
-void
-gripe_reading_man_file (name)
- char *name;
-{
- fprintf (stderr, "Read access denied for file %s\n", name);
-
- fflush (stderr);
-}
-
-void
-gripe_converting_name (name, to_cat)
- char *name;
- int to_cat;
-{
- if (to_cat)
- fprintf (stderr, "Error converting %s to cat name\n", name);
- else
- fprintf (stderr, "Error converting %s to man name\n", name);
-
- fflush (stderr);
-
- exit (1);
-}
-
-void
-gripe_system_command (status)
- int status;
-{
- fprintf (stderr, "Error executing formatting or display command.\n");
- fprintf (stderr, "system command exited with status %d\n", status);
-
- fflush (stderr);
-}
-
-void
-gripe_not_found (name, section)
- char *name, *section;
-{
- if (section)
- fprintf (stderr, "No entry for %s in section %s of the manual\n",
- name, section);
- else
- fprintf (stderr, "No manual entry for %s\n", name);
-
- fflush (stderr);
-}
-
-void
-gripe_incompatible (s)
- char *s;
-{
- fprintf (stderr, "%s: incompatible options %s\n", prognam, s);
-
- fflush (stderr);
-
- exit (1);
-}
-
-void
-gripe_getting_mp_config (file)
- char *file;
-{
- fprintf (stderr, "%s: unable to find the file %s\n", prognam, file);
-
- fflush (stderr);
-
- exit (1);
-}
-
-void
-gripe_reading_mp_config (file)
- char *file;
-{
- fprintf (stderr, "%s: unable to make sense of the file %s\n", prognam, file);
-
- fflush (stderr);
-
- exit (1);
-}
-
-void
-gripe_invalid_section (section)
- char *section;
-{
- fprintf (stderr, "%s: invalid section (%s) selected\n", prognam, section);
-
- fflush (stderr);
-
- exit (1);
-}
-
-void
-gripe_manpath ()
-{
- fprintf (stderr, "%s: manpath is null\n", prognam);
-
- fflush (stderr);
-
- exit (1);
-}
-
-void
-gripe_alloc (bytes, object)
- int bytes;
- char *object;
-{
- fprintf (stderr, "%s: can't malloc %d bytes for %s\n",
- prognam, bytes, object);
-
- fflush (stderr);
-
- exit (1);
-}
-
-void
-gripe_roff_command_from_file (file)
- char *file;
-{
- fprintf (stderr, "Error parsing *roff command from file %s\n", file);
-
- fflush (stderr);
-}
-
-void
-gripe_roff_command_from_env ()
-{
- fprintf (stderr, "Error parsing MANROFFSEQ. Using system defaults.\n");
-
- fflush (stderr);
-}
-
-void
-gripe_roff_command_from_command_line ()
-{
- fprintf (stderr, "Error parsing *roff command from command line.\n");
-
- fflush (stderr);
-}
diff --git a/gnu/usr.bin/man/lib/gripes.h b/gnu/usr.bin/man/lib/gripes.h
deleted file mode 100644
index 5fd59b2..0000000
--- a/gnu/usr.bin/man/lib/gripes.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * gripes.h
- *
- * Copyright (c) 1990, 1991, John W. Eaton.
- *
- * You may distribute under the terms of the GNU General Public
- * License as specified in the file COPYING that comes with the man
- * distribution.
- *
- * John W. Eaton
- * jwe@che.utexas.edu
- * Department of Chemical Engineering
- * The University of Texas at Austin
- * Austin, Texas 78712
- */
-
-extern void gripe_no_name ();
-extern void gripe_converting_name ();
-extern void gripe_system_command ();
-extern void gripe_reading_man_file ();
-extern void gripe_not_found ();
-extern void gripe_invalid_section ();
-extern void gripe_manpath ();
-extern void gripe_alloc ();
-extern void gripe_incompatible ();
-extern void gripe_getting_mp_config ();
-extern void gripe_reading_mp_config ();
-extern void gripe_roff_command_from_file ();
-extern void gripe_roff_command_from_env ();
-extern void gripe_roff_command_from_command_line ();
diff --git a/gnu/usr.bin/man/lib/util.c b/gnu/usr.bin/man/lib/util.c
deleted file mode 100644
index 995d318..0000000
--- a/gnu/usr.bin/man/lib/util.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * util.c
- *
- * Copyright (c) 1990, 1991, John W. Eaton.
- *
- * You may distribute under the terms of the GNU General Public
- * License as specified in the file COPYING that comes with the man
- * distribution.
- *
- * John W. Eaton
- * jwe@che.utexas.edu
- * Department of Chemical Engineering
- * The University of Texas at Austin
- * Austin, Texas 78712
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-extern int fprintf ();
-extern int tolower ();
-#endif
-
-extern char *strdup ();
-extern int system ();
-
-#include "gripes.h"
-
-/*
- * Extract last element of a name like /foo/bar/baz.
- */
-char *
-mkprogname (s)
- register char *s;
-{
- char *t;
-
- t = strrchr (s, '/');
- if (t == (char *)NULL)
- t = s;
- else
- t++;
-
- return strdup (t);
-}
-
-void
-downcase (s)
- char *s;
-{
- register char c;
- while ((c = *s) != '\0')
- {
- if (isalpha (c))
- *s = tolower (c);
- s++;
- }
-}
-
-/*
- * Is file a newer than file b?
- *
- * case:
- *
- * a newer than b returns 1
- * a older than b returns 0
- * stat on a fails returns -1
- * stat on b fails returns -2
- * stat on a and b fails returns -3
- */
-int
-is_newer (fa, fb)
- register char *fa;
- register char *fb;
-{
- struct stat fa_sb;
- struct stat fb_sb;
- register int fa_stat;
- register int fb_stat;
- register int status = 0;
-
- fa_stat = stat (fa, &fa_sb);
- if (fa_stat != 0)
- status = 1;
-
- fb_stat = stat (fb, &fb_sb);
- if (fb_stat != 0)
- status |= 2;
-
- if (status != 0)
- return -status;
-
- return (fa_sb.st_mtime > fb_sb.st_mtime);
-}
-
-/*
- * Is path a directory?
- */
-int
-is_directory (path)
- char *path;
-{
- struct stat sb;
- register int status;
-
- status = stat (path, &sb);
-
- if (status != 0)
- return -1;
-
- return ((sb.st_mode & S_IFDIR) == S_IFDIR);
-
-}
-
-/*
- * Attempt a system () call. Return 1 for success and 0 for failure
- * (handy for counting successes :-).
- */
-int
-do_system_command (command)
- char *command;
-{
- int status = 0;
- extern int debug;
-
- /*
- * If we're debugging, don't really execute the command -- you never
- * know what might be in that mangled string :-O.
- */
- if (debug)
- fprintf (stderr, "\ntrying command: %s\n", command);
- else
- status = system (command);
-
- /* check return value from system() function first */
- if (status == -1) {
- fprintf(stderr,
- "wait() for exit status of shell failed in function system()\n");
- return 0;
- } else if (status == 127 || status == (127 << 8)) {
- fprintf(stderr, "execution of the shell failed in function system()\n");
- return 0;
- }
-
- if (WIFSIGNALED(status))
- return -1;
- else if (WEXITSTATUS(status)) {
- gripe_system_command (status);
- return 0;
- }
- else
- return 1;
-}
diff --git a/gnu/usr.bin/man/makewhatis/Makefile b/gnu/usr.bin/man/makewhatis/Makefile
deleted file mode 100644
index 7849d73..0000000
--- a/gnu/usr.bin/man/makewhatis/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-MAN1= makewhatis.1
-MAN8= makewhatis.local.8
-MLINKS= makewhatis.local.8 catman.local.8
-
-libexecdir=/usr/libexec
-LINKS=${libexecdir}/makewhatis.local ${libexecdir}/catman.local
-
-beforeinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/makewhatis.perl ${DESTDIR}${BINDIR}/makewhatis
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/makewhatis.local.sh \
- ${DESTDIR}${libexecdir}/makewhatis.local
-
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.1 b/gnu/usr.bin/man/makewhatis/makewhatis.1
deleted file mode 100644
index f42aeff..0000000
--- a/gnu/usr.bin/man/makewhatis/makewhatis.1
+++ /dev/null
@@ -1,142 +0,0 @@
-.\" Copyright (c) 1994-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-.\"
-.\" $Id: makewhatis.1,v 1.10 1997/02/22 15:47:02 peter Exp $
-.Dd January 12, 1995
-.Dt MAKEWHATIS 1
-.Os FreeBSD 2.1
-.Sh NAME
-.Nm makewhatis
-.Nd create whatis database
-.Sh SYNOPSIS
-.Nm
-.Op Fl a | Fl append
-.Op Fl h | Fl help
-.Op Fl i | Fl indent Ar column
-.Op Fl n | Fl name Ar name
-.Op Fl o | Fl outfile Ar file
-.Op Fl v | Fl verbose
-.Op Ar directories ...
-.Sh DESCRIPTION
-.Nm
-extracts the name and a short description from unformatted manpages
-and creates the
-.Xr whatis 1
-database.
-.Nm
-can read gzip'ed manpages.
-.Ar Directory
-names a directory containing manpage subdirectories
-.Pq named Pa man.+ .
-Colons are treated as spaces, hence
-.Ic makewhatis $MANPATH
-or
-.Ic makewhatis `manpath`
-are allowed.
-.Sh OPTIONS
-.Bl -tag -width Ds
-.It Fl a , Fl append
-Append mode. Don't delete old entries in whatis database. Note:
-the new database will be sorted without repeated lines and
-.Nm
-does not check if old entries are valid.
-.It Fl h , Fl help
-Print options and exit.
-.It Fl i , Fl indent Ar column
-Justify description strings to
-.Ar column Pq default 24 .
-.It Fl n , Fl name Ar name
-Use
-.Ar name
-instead of
-.Pa whatis Ns .
-.It Fl o , Fl outfile Ar file
-Write all output to
-.Ar file
-instead of
-.Pa dirname/whatis Ns .
-.It Fl v, Fl verbose
-Issue more warnings
-.Pq to stderr .
-For every parsed man page write a single char:
-.Ql \&.
-for an uncompressed page,
-.Ql *
-for a compressed page, and
-.Ql +
-for a link.
-.El
-.Sh EXAMPLES
-.Pp
-.Ic makewhatis $MANPATH
-.Pp
-Create whatis database for all directories in your
-.Pa $MANPATH Ns .
-.Pp
-.Ic makewhatis -outfile /tmp/mywhatis /usr/local/man $HOME/man
-.Pp
-Create whatis database
-.Pa /tmp/mywhatis .
-Traverse directories
-.Pa /usr/local/man
-and
-.Pa $HOME/man Ns .
-Don't create
-.Pa /usr/local/man/whatis
-or
-.Pa $HOME/man/whatis Ns .
-.Pp
-.Ic makewhatis -name windex $HOME/man
-.Pp
-Create whatis database
-.Pa windex
-instead of
-.Pa whatis Ns .
-May be useful for Solaris.
-.Sh FILES
-.Bl -tag -width /etc/master.passwdxx -compact
-.It Pa */man/whatis
-whatis database
-.It Pa /etc/weekly
-run
-.Nm makewhatis.local
-every week
-.El
-.Sh SEE ALSO
-.Xr apropos 1 ,
-.Xr catman 1 ,
-.Xr getNAME 1 ,
-.Xr man 1 ,
-.Xr manpath 1 ,
-.Xr sort 1 ,
-.Xr uniq 1 ,
-.Xr whatis 1 ,
-.Xr makewhatis.local 8 .
-.Sh HISTORY
-This
-.Nm
-command appeared in
-.Fx 2.1 .
-.Sh AUTHOR
-Wolfram Schneider, Berlin.
diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.local.8 b/gnu/usr.bin/man/makewhatis/makewhatis.local.8
deleted file mode 100644
index b7fd62f..0000000
--- a/gnu/usr.bin/man/makewhatis/makewhatis.local.8
+++ /dev/null
@@ -1,70 +0,0 @@
-.\" Copyright (c) April 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-.\"
-.\" $Id: makewhatis.local.8,v 1.5 1997/02/22 15:47:02 peter Exp $
-.Dd April 26, 1996
-.Dt MAKEWHATIS.LOCAL 8
-.Os FreeBSD 2.2
-.Sh NAME
-.Nm makewhatis.local , catman.local
-.Nd start makewhatis for local file systems
-.Sh SYNOPSIS
-.Nm /usr/libexec/makewhatis.local
-.Op options
-.Ar directories ...
-.Nm /usr/libexec/catman.local
-.Op options
-.Ar directories ...
-.Sh DESCRIPTION
-.Nm
-start
-.Xr makewhatis 1
-only for file systems physically mounted on the system
-where the
-.Nm
-is being executed. Running makewhatis
-from
-.Pa /etc/weekly
-for rw nfs-mounted /usr may kill
-your NFS server -- all NFS clients start makewhatis at the same time!
-So use this wrapper for
-.Xr cron 8
-instead of calling makewhatis directly.
-.Sh FILES
-.Bl -tag -width /etc/weekly.XXX -compact
-.It Pa /etc/weekly
-run
-.Nm
-every week
-.El
-.Sh SEE ALSO
-.Xr catman 1 ,
-.Xr find 1 ,
-.Xr makewhatis 1 ,
-.Xr cron 8 .
-.Sh HISTORY
-The
-.Nm
-command appeared in
-.Fx 2.2 .
diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.local.sh b/gnu/usr.bin/man/makewhatis/makewhatis.local.sh
deleted file mode 100644
index 9ad997b..0000000
--- a/gnu/usr.bin/man/makewhatis/makewhatis.local.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) April 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# makewhatis.local - start makewhatis(1) only for file systems
-# physically mounted on the system
-#
-# Running makewhatis from /etc/weekly for rw nfs-mounted /usr may kill
-# your NFS server -- all clients start makewhatis at the same time!
-# So use this wrapper instead calling makewhatis directly.
-#
-# PS: this wrapper works also for catman(1)
-#
-# $Id$
-
-PATH=/bin:/usr/bin:$PATH; export PATH
-opt= dirs= localdirs=
-
-for arg
-do
- case "$arg" in
- -*) opt="$opt $arg";;
- *) dirs="$dirs $arg";;
- esac
-done
-
-dirs=`echo $dirs | sed 's/:/ /g'`
-case X"$dirs" in X) echo "usage: $0 [options] directories ..."; exit 1;; esac
-
-localdirs=`find -H $dirs -fstype local -type d -prune -print`
-
-case X"$localdirs" in
- X) echo "$0: no local-mounted manual directories found: $dirs"
- exit 1;;
- *) exec `basename $0 .local` $opt $localdirs;;
-esac
diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.perl b/gnu/usr.bin/man/makewhatis/makewhatis.perl
deleted file mode 100644
index b3ceeaa..0000000
--- a/gnu/usr.bin/man/makewhatis/makewhatis.perl
+++ /dev/null
@@ -1,519 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 1994-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# makewhatis -- update the whatis database in the man directories.
-#
-# $Id: makewhatis.perl,v 1.16 1997/03/14 21:58:43 wosch Exp $
-
-
-sub usage {
-
- warn <<EOF;
-usage: makewhatis [-a|-append ] [-h|-help] [-i|-indent colum]
- [-n|-name name] [-o|-outfile file] [-v|-verbose]
- [directories ...]
-EOF
- exit 1;
-}
-
-
-# Format output
-sub open_output {
- local($dir) = @_;
-
- die "Name for whatis is empty\n" if $whatis_name eq "";
-
- if ($outfile) { # Write all Output to $outfile
- $whatisdb = $outfile;
- } else { # Use man/whatis
- $whatisdb = $dir . "/$whatis_name.tmp";
- }
- $tmp = $whatisdb; # for signals
-
-
- # Array of all entries
- @a = ();
-
-
- # Append mode
- if ($append) {
- local($file) = $whatisdb;
- $file =~ s/\.tmp$// if !$outfile;
-
- if (open(A, "$file")) {
- warn "Open $file for append mode\n" if $verbose;
- while(<A>) {
- push(@a, $_);
- }
- close A;
- }
-
- else {
- warn "$whatisdb: $!\n" if lstat($file) && $verbose; #
- }
- undef $file;
- }
-
-
- warn "Open $whatisdb\n" if $verbose;
- if (!open(A, "> $whatisdb")) {
- die "$whatisdb: $!\n" if $outfile;
-
- warn "$whatisdb: $!\n"; $err++; return 0;
- }
-
- select A;
- return 1;
-}
-
-sub close_output {
- local($success) = @_;
- local($w) = $whatisdb;
- local($counter) = 0;
- local($i, $last,@b);
-
- $w =~ s/\.tmp$//;
- if ($success) { # success
-
- # uniq
- warn "\n" if $verbose && $pointflag;
- warn "sort -u > $whatisdb\n" if $verbose;
- foreach $i (sort @a) {
- if ($i ne $last) {
- push(@b, $i);
- }
- $last =$i;
- }
-
- $counter = $#b + 1;
- print @b; close A; select STDOUT;
-
- if (!$outfile) {
- warn "Rename $whatisdb to $w\n" if $verbose;
- rename($whatisdb, $w) || warn "rename $whatisdb $w\n";
- $counter_all += $counter;
- warn "$counter entries in $w\n" if $verbose;
- } else {
- $counter_all = $counter;
- }
- } else { # building whatisdb failed
- unlink($whatisdb);
- warn "building whatisdb: $whatisdb failed\n" if $verbose;
- }
- return 1;
-}
-
-sub parse_subdir {
- local($dir) = @_;
- local($file, $dev,$ino);
-
- warn "\n" if $pointflag;
- warn "traverse $dir\n" if $verbose;
- $pointflag = 0;
-
- if (!opendir(M, $dir)) {
- warn "$dir: $!\n"; $err++; return 0;
- }
-
- $| = 1 if $verbose;
- foreach $file (readdir(M)) {
- next if $file =~ /^(\.|\.\.)$/;
-
- ($dev, $ino) = ((stat("$dir/$file"))[01]);
- if (-f _) {
- if ($man_red{"$dev.$ino"}) {
- # Link
- print STDERR "+" if $verbose;
- $pointflag++ if $verbose;
- } else {
- &manual("$dir/$file");
- }
- $man_red{"$dev.$ino"} = 1;
- } elsif (! -d _) {
- warn "Cannot find file: $dir/$file\n"; $err++;
- }
- }
- closedir M;
- return 1;
-}
-
-# read man directory
-sub parse_dir {
- local($dir) = @_;
- local($subdir, $file);
-
- # clean up, in case mandir and subdirs are called simultaneously
- # e. g.: ~/man/man1 ~/man/man2 ~/man
- #~/man/ man1 and ~/man/man2 are a subset of ~/man
- foreach $file (keys %man_red) {
- delete $man_red{$file};
- }
-
- if ($dir =~ /man/) {
- warn "\n" if $verbose && $pointflag;
- warn "open manpath directory ``$dir''\n" if $verbose;
- $pointflag = 0;
- if (!opendir(DIR, $dir)) {
- warn "opendir ``$dir'':$!\n"; $err = 1; return 0;
- }
- foreach $subdir (sort(readdir(DIR))) {
- if ($subdir =~ /^man\w+$/) {
- $subdir = "$dir/$subdir";
- &parse_subdir($subdir);
- }
- }
- closedir DIR
-
- } elsif ($dir =~ /man\w+$/) {
- &parse_subdir($dir);
- } else {
- warn "Assume ``$dir'' is not a man directory.\n";
- $err = 1; return 0;
- }
- return 1;
-}
-
-sub dir_redundant {
- local($dir) = @_;
-
- local ($dev,$ino) = (stat($dir))[0..1];
-
- if ($dir_redundant{"$dev.$ino"}) {
- warn "$dir is equal to: $dir_redundant{\"$dev.$ino\"}\n" if $verbose;
- return 0;
- }
- $dir_redundant{"$dev.$ino"} = $dir;
- return 1;
-}
-
-
-# ``/usr/man/man1/foo.l'' -> ``l''
-sub ext {
- local($filename) = @_;
- local($extension) = $filename;
-
- $extension =~ s/$ext$//g; # strip .gz
- $extension =~ s/.*\///g; # basename
-
- if ($extension !~ m%[^/]+\.[^.]+$%) { # no dot
- $extension = $filename;
- #$extension =~ s|/[^/]+$||;
- $extension =~ s%.*man([^/]+)/[^/]+%$1%; # last character
- warn "\n" if $verbose && $pointflag;
- warn "$filename has no extension, try section ``$extension''\n"
- if $verbose;
- $pointflag = 0;
- } else {
- $extension =~ s/.*\.//g; # foo.bla.1 -> 1
- }
- return "$extension";
-}
-
-# ``/usr/man/man1/foo.1'' -> ``foo''
-sub name {
- local($name) = @_;
-
- $name =~ s=.*/==;
- $name =~ s=$ext$==o;
- $name =~ s=\.[^\.]+$==;
-
- return "$name";
-}
-
-# output
-sub out {
- local($list) = @_;
- local($delim) = " - ";
- $_ = $list;
-
- # delete italic etc.
- s/^\.[^ -]+[ -]+//;
- s/\\\((em|mi)//;
- s/\\f[IRBP]//g;
- s/\\\*p//g;
- s/\(OBSOLETED\)[ ]?//;
- s/\\&//g;
- s/^\@INDOT\@//;
- s/[\"\\]//g; #"
- s/[. \t-]+$//;
-
- s/ / - / unless / - /;
- ($man,$desc) = split(/ - /);
-
- $man = $name unless $man;
- $man =~ s/[,. ]+$//;
- $man =~ s/,/($extension),/g;
- $man .= "($extension)";
-
- &manpagename;
-
- $desc =~ s/^[ \t]+//;
-
- for($i = length($man); $i < $indent && $desc; $i++) {
- $man .= ' ';
- }
- if ($desc) {
- push(@a, "$man$delim$desc\n");
- } else {
- push(@a, "$man\n");
- }
-}
-
-# The filename of manual page is not a keyword.
-# This is bad, because you don't find the manpage
-# whith: $ man <section> <keyword>
-#
-# Add filename if a) filename is not a keyword and b) no keyword(s)
-# exist as file in same mansection
-#
-sub manpagename {
- foreach (split(/,\s+/, $man)) {
- s/\(.+//;
- # filename is keyword
- return if $name eq $_;
- }
-
- local($f) = $file; $f =~ s%/*[^/]+$%%; # dirname
- local($e) = $file; $e =~ s/$ext$//; $e =~ s%.*(\.[^.]+)$%$1%; # .1
-
- foreach (split(/,\s+/, $man)) {
- s/\(.+//;
-
- # a keyword exist as file
- return if -e "$f/$_$e" || -e "$f/$_$e$ext";
- }
-
- $man = "$name($extension), $man";
-}
-
-# looking for NAME
-sub manual {
- local($file) = @_;
- local($list, $desc, $extension);
- local($ofile) = $file;
-
- # Compressed man pages
- if ($ofile =~ /$ext$/) {
- $ofile = "gzcat $file |";
- print STDERR "*" if $verbose;
- } else {
- print STDERR "." if $verbose;
- }
- $pointflag++ if $verbose;
-
- if (!open(F, "$ofile")) {
- warn "Cannot open file: $ofile\n"; $err++;
- return 0;
- }
- # extension/section
- $extension = &ext($file);
- $name = &name($file);
-
- local($source) = 0;
- local($list);
- while(<F>) {
- # ``man'' style pages
- # &&: it takes you only half the user time, regexp is slow!!!
- if (/^\.SH/ && /^\.SH[ \t]+["]?(NAME|Name|NAMN|BEZEICHNUNG|̾¾Î)["]?/) {
- #while(<F>) { last unless /^\./ } # Skip
- #chop; $list = $_;
- while(<F>) {
- last if /^\.SH[ \t]/;
- chop;
- s/^\.IX\s.*//; # delete perlpod garbage
- s/^\.[A-Z]+[ ]+[0-9]+$//; # delete commands
- s/^\.[A-Za-z]+[ \t]*//; # delete commands
- s/^\.\\".*$//; #" delete comments
- s/^[ \t]+//;
- if ($_) {
- $list .= $_;
- $list .= ' ';
- }
- }
- &out($list); close F; return 1;
- } elsif (/^\.Sh/ && /^\.Sh[ \t]+["]?(NAME|Name|BEZEICHNUNG|̾¾Î)["]?/) {
- # ``doc'' style pages
- local($flag) = 0;
- while(<F>) {
- last if /^\.Sh/;
- chop;
- s/^\.\\".*$//; #" delete comments
- if (/^\.Nm/) {
- s/^\.Nm[ \t]*//;
- s/ ,/,/g;
- s/[ \t]+$//;
- $list .= $_;
- $list .= ' ';
- } else {
- $list .= '- ' if (!$flag && !/-/);
- $flag++;
- s/^\.[A-Z][a-z][ \t]*//;
- s/[ \t]+$//;
- $list .= $_;
- $list .= ' ';
- }
- }
- &out($list); close F; return 1;
-
- } elsif(/^\.so/ && /^\.so[ \t]+man/) {
- close F; return 1;
- }
- }
- if (!$source && $verbose) {
- warn "\n" if $pointflag;
- warn "Maybe $file is not a manpage\n" ;
- $pointflag = 0;
- }
- return 0;
-}
-
-# make relative path to absolute path
-sub absolute_path {
- local(@dirlist) = @_;
- local($pwd, $dir, @a);
-
- $pwd = $ENV{'PWD'};
- foreach $dir (@dirlist) {
- if ($dir !~ "^/") {
- chop($pwd = `pwd`) if (!$pwd || $pwd !~ /^\//);
- push(@a, "$pwd/$dir");
- } else {
- push(@a, $dir);
- }
- }
- return @a;
-}
-
-# strip unused '/'
-# e.g.: //usr///home// -> /usr/home
-sub stripdir {
- local($dir) = @_;
-
- $dir =~ s|/+|/|g; # delete double '/'
- $dir =~ s|/$||; # delete '/' at end
- $dir =~ s|/(\.\/)+|/|g; # delete ././././
-
- $dir =~ s|/+|/|g; # delete double '/'
- $dir =~ s|/$||; # delete '/' at end
- $dir =~ s|/\.$||; # delete /. at end
- return $dir if $dir ne "";
- return '/';
-}
-
-sub variables {
- $verbose = 0; # Verbose
- $indent = 24; # indent for description
- $outfile = 0; # Don't write to ./whatis
- $whatis_name = "whatis"; # Default name for DB
- $append = 0; # Don't delete old entries
-
- # if no argument for directories given
- @defaultmanpath = ( '/usr/share/man' );
-
- $ext = '.gz'; # extension
- umask(022);
-
- $err = 0; # exit code
- $whatisdb = '';
- $counter_all = 0;
- $dir_redundant = ''; # redundant directories
- $man_red = ''; # redundant man pages
- @a = (); # Array for output
-
- # Signals
- $SIG{'INT'} = 'Exit';
- $SIG{'HUP'} = 'Exit';
- $SIG{'TRAP'} = 'Exit';
- $SIG{'QUIT'} = 'Exit';
- $SIG{'TERM'} = 'Exit';
- $tmp = ''; # tmp file
-
- $ENV{'PATH'} = "/bin:/usr/bin:$ENV{'PATH'}";
-}
-
-sub Exit {
- unlink($tmp) if $tmp ne ""; # unlink if a filename
- die "$0: die on signal SIG@_\n";
-}
-
-sub parse {
- local(@argv) = @_;
- local($i);
-
- while ($_ = $argv[0], /^-/) {
- shift @argv;
- last if /^--$/;
- if (/^--?(v|verbose)$/) { $verbose = 1 }
- elsif (/^--?(h|help|\?)$/) { &usage }
- elsif (/^--?(o|outfile)$/) { $outfile = $argv[0]; shift @argv }
- elsif (/^--?(f|format|i|indent)$/) { $i = $argv[0]; shift @argv }
- elsif (/^--?(n|name)$/) { $whatis_name = $argv[0];shift @argv }
- elsif (/^--?(a|append)$/) { $append = 1 }
- else { &usage }
- }
-
- if ($i ne "") {
- if ($i =~ /^[0-9]+$/) {
- $indent = $i;
- } else {
- warn "Ignoring wrong indent value: ``$i''\n";
- }
- }
-
- return &absolute_path(@argv) if $#argv >= 0;
- return @defaultmanpath if $#defaultmanpath >= 0;
-
- warn "Missing directories\n"; &usage;
-}
-
-
-##
-## Main
-##
-
-&variables;
-# allow colons in dir: ``makewhatis dir1:dir2:dir3''
-@argv = &parse(split(/[: ]/, join($", @ARGV))); # "
-
-
-if ($outfile) {
- if(&open_output($outfile)){
- foreach $dir (@argv) {
- $dir = &stripdir($dir);
- &dir_redundant($dir) && &parse_dir($dir);
- }
- }
- &close_output(1);
-} else {
- foreach $dir (@argv) {
- $dir = &stripdir($dir);
- &dir_redundant($dir) &&
- &close_output(&open_output($dir) && &parse_dir($dir));
- }
-}
-
-warn "Total entries: $counter_all\n" if $verbose && ($#argv > 0 || $outfile);
-exit $err;
diff --git a/gnu/usr.bin/man/man/Makefile b/gnu/usr.bin/man/man/Makefile
deleted file mode 100644
index 86d6197..0000000
--- a/gnu/usr.bin/man/man/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-PROG= man
-SRCS= man.c manpath.c glob.c
-MAN1= man.1
-BINOWN= man
-BINMODE=4555
-INSTALLFLAGS+= -fschg
-
-.if exists(${.OBJDIR}/../lib)
-LIBDESTDIR= ${.OBJDIR}/../lib
-.else
-LIBDESTDIR= ${.CURDIR}/../lib
-.endif
-CFLAGS+= -I${LIBDESTDIR}
-DPADD= ${LIBDESTDIR}/libman.a
-LDADD= -L${LIBDESTDIR} -lman
-
-CFLAGS+= -I${.CURDIR}/../lib -DSTDC_HEADERS -DPOSIX -DHAS_TROFF
-CFLAGS+= -DDO_COMPRESS -DALT_SYSTEMS -DSETREUID -DCATMODE=0644
-CLEANFILES+= ${MAN1}
-MANDEPEND+= ${MAN1}
-
-.PATH: ${.CURDIR}/../manpath
-
-${MAN1}: ${.CURDIR}/man.man
- @${ECHO} echo Making ${.TARGET:T} from ${.ALLSRC:T}; \
- sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
- -e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \
- -e 's,%manpath_config_file%,${manpath_config_file},' \
- -e 's,%compress%,${compress},' \
- ${.CURDIR}/man.man > ${MAN1}
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/man/man/glob.c b/gnu/usr.bin/man/man/glob.c
deleted file mode 100644
index 65eb1fa..0000000
--- a/gnu/usr.bin/man/man/glob.c
+++ /dev/null
@@ -1,712 +0,0 @@
-/* File-name wildcard pattern matching for GNU.
- Copyright (C) 1985, 1988, 1989, 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 1, 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. */
-
-/* To whomever it may concern: I have never seen the code which most
- Unix programs use to perform this function. I wrote this from scratch
- based on specifications for the pattern matching. --RMS. */
-
-#ifdef SHELL
-#include "config.h"
-#endif /* SHELL */
-
-#include <sys/types.h>
-
-#if defined (USGr3) && !defined (DIRENT)
-#define DIRENT
-#endif /* USGr3 */
-#if defined (Xenix) && !defined (SYSNDIR)
-#define SYSNDIR
-#endif /* Xenix */
-
-#if defined (POSIX) || defined (DIRENT) || defined (__GNU_LIBRARY__)
-#include <dirent.h>
-#define direct dirent
-#define D_NAMLEN(d) strlen((d)->d_name)
-#else /* not POSIX or DIRENT or __GNU_LIBRARY__ */
-#define D_NAMLEN(d) ((d)->d_namlen)
-#ifdef USG
-#if defined (SYSNDIR)
-#include <sys/ndir.h>
-#else /* SYSNDIR */
-#include "ndir.h"
-#endif /* not SYSNDIR */
-#else /* not USG */
-#include <sys/dir.h>
-#endif /* USG */
-#endif /* POSIX or DIRENT or __GNU_LIBRARY__ */
-
-#if defined (_POSIX_SOURCE)
-/* Posix does not require that the d_ino field be present, and some
- systems do not provide it. */
-#define REAL_DIR_ENTRY(dp) 1
-#else
-#define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
-#endif /* _POSIX_SOURCE */
-
-#if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
-#include <stdlib.h>
-#include <string.h>
-#define STDC_STRINGS
-#else /* STDC_HEADERS or __GNU_LIBRARY__ */
-
-#if defined (USG)
-#include <string.h>
-#ifndef POSIX
-#include <memory.h>
-#endif /* POSIX */
-#define STDC_STRINGS
-#else /* not USG */
-#ifdef NeXT
-#include <string.h>
-#else /* NeXT */
-#include <strings.h>
-#endif /* NeXT */
-/* Declaring bcopy causes errors on systems whose declarations are different.
- If the declaration is omitted, everything works fine. */
-#endif /* not USG */
-
-extern char *malloc ();
-extern char *realloc ();
-extern void free ();
-
-#ifndef NULL
-#define NULL 0
-#endif
-#endif /* Not STDC_HEADERS or __GNU_LIBRARY__. */
-
-#ifdef STDC_STRINGS
-#define bcopy(s, d, n) memcpy ((d), (s), (n))
-#define index strchr
-#define rindex strrchr
-#endif /* STDC_STRINGS */
-
-#ifndef alloca
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* Not GCC. */
-#ifdef sparc
-#include <alloca.h>
-#else /* Not sparc. */
-extern char *alloca ();
-#endif /* sparc. */
-#endif /* GCC. */
-#endif
-
-/* Nonzero if '*' and '?' do not match an initial '.' for glob_filename. */
-int noglob_dot_filenames = 1;
-
-static int glob_match_after_star ();
-
-#ifdef __FreeBSD__
-static int collate_range_cmp (a, b)
- int a, b;
-{
- int r;
- static char s[2][2];
-
- if ((unsigned char)a == (unsigned char)b)
- return 0;
- s[0][0] = a;
- s[1][0] = b;
- if ((r = strcoll(s[0], s[1])) == 0)
- r = (unsigned char)a - (unsigned char)b;
- return r;
-}
-#endif
-
-/* Return nonzero if PATTERN has any special globbing chars in it. */
-
-int
-glob_pattern_p (pattern)
- char *pattern;
-{
- register char *p = pattern;
- register char c;
- int open = 0;
-
- while ((c = *p++) != '\0')
- switch (c)
- {
- case '?':
- case '*':
- return 1;
-
- case '[': /* Only accept an open brace if there is a close */
- open++; /* brace to match it. Bracket expressions must be */
- continue; /* complete, according to Posix.2 */
- case ']':
- if (open)
- return 1;
- continue;
-
- case '\\':
- if (*p++ == '\0')
- return 0;
- }
-
- return 0;
-}
-
-
-/* Match the pattern PATTERN against the string TEXT;
- return 1 if it matches, 0 otherwise.
-
- A match means the entire string TEXT is used up in matching.
-
- In the pattern string, `*' matches any sequence of characters,
- `?' matches any character, [SET] matches any character in the specified set,
- [!SET] matches any character not in the specified set.
-
- A set is composed of characters or ranges; a range looks like
- character hyphen character (as in 0-9 or A-Z).
- [0-9a-zA-Z_] is the set of characters allowed in C identifiers.
- Any other character in the pattern must be matched exactly.
-
- To suppress the special syntactic significance of any of `[]*?!-\',
- and match the character exactly, precede it with a `\'.
-
- If DOT_SPECIAL is nonzero,
- `*' and `?' do not match `.' at the beginning of TEXT. */
-
-int
-glob_match (pattern, text, dot_special)
- char *pattern, *text;
- int dot_special;
-{
- register char *p = pattern, *t = text;
- register char c;
-
- while ((c = *p++) != '\0')
- switch (c)
- {
- case '?':
- if (*t == '\0' || (dot_special && t == text && *t == '.'))
- return 0;
- else
- ++t;
- break;
-
- case '\\':
- if (*p++ != *t++)
- return 0;
- break;
-
- case '*':
- if (dot_special && t == text && *t == '.')
- return 0;
- return glob_match_after_star (p, t);
-
- case '[':
- {
- register char c1 = *t++;
- int invert;
- char *cp1 = p;
-
- if (c1 == '\0')
- return 0;
-
- invert = (*p == '!');
-
- if (invert)
- p++;
-
- c = *p++;
- while (1)
- {
- register char cstart = c, cend = c;
-
- if (c == '\\')
- {
- cstart = *p++;
- cend = cstart;
- }
-
- if (cstart == '\0')
- {
- /* Missing ']'. */
- if (c1 != '[')
- return 0;
- /* matched a single bracket */
- p = cp1;
- goto breakbracket;
- }
-
- c = *p++;
-
- if (c == '-')
- {
- cend = *p++;
- if (cend == '\\')
- cend = *p++;
- if (cend == '\0')
- return 0;
- c = *p++;
- }
-#ifdef __FreeBSD__
- if ( collate_range_cmp (c1, cstart) >= 0
- && collate_range_cmp (c1, cend) <= 0
- )
-#else
- if (c1 >= cstart && c1 <= cend)
-#endif
- goto match;
- if (c == ']')
- break;
- }
- if (!invert)
- return 0;
- break;
-
- match:
- /* Skip the rest of the [...] construct that already matched. */
- while (c != ']')
- {
- if (c == '\0')
- return 0;
- c = *p++;
- if (c == '\0')
- return 0;
- if (c == '\\')
- p++;
- }
- if (invert)
- return 0;
- breakbracket:
- break;
- }
-
- default:
- if (c != *t++)
- return 0;
- }
-
- return *t == '\0';
-}
-
-/* Like glob_match, but match PATTERN against any final segment of TEXT. */
-
-static int
-glob_match_after_star (pattern, text)
- char *pattern, *text;
-{
- register char *p = pattern, *t = text;
- register char c, c1;
-
- while ((c = *p++) == '?' || c == '*')
- if (c == '?' && *t++ == '\0')
- return 0;
-
- if (c == '\0')
- return 1;
-
- if (c == '\\')
- c1 = *p;
- else
- c1 = c;
-
- --p;
- while (1)
- {
- if ((c == '[' || *t == c1) && glob_match (p, t, 0))
- return 1;
- if (*t++ == '\0')
- return 0;
- }
-}
-
-/* Return a vector of names of files in directory DIR
- whose names match glob pattern PAT.
- The names are not in any particular order.
- Wildcards at the beginning of PAT do not match an initial period
- if noglob_dot_filenames is nonzero.
-
- The vector is terminated by an element that is a null pointer.
-
- To free the space allocated, first free the vector's elements,
- then free the vector.
-
- Return NULL if cannot get enough memory to hold the pointer
- and the names.
-
- Return -1 if cannot access directory DIR.
- Look in errno for more information. */
-
-char **
-glob_vector (pat, dir)
- char *pat;
- char *dir;
-{
- struct globval
- {
- struct globval *next;
- char *name;
- };
-
- DIR *d;
- register struct direct *dp;
- struct globval *lastlink;
- register struct globval *nextlink;
- register char *nextname;
- unsigned int count;
- int lose;
- register char **name_vector;
- register unsigned int i;
-#ifdef ALLOCA_MISSING
- struct globval *templink;
-#endif
-
- d = opendir (dir);
- if (d == NULL)
- return (char **) -1;
-
- lastlink = NULL;
- count = 0;
- lose = 0;
-
- /* Scan the directory, finding all names that match.
- For each name that matches, allocate a struct globval
- on the stack and store the name in it.
- Chain those structs together; lastlink is the front of the chain. */
- while (1)
- {
-#if defined (SHELL)
- /* Make globbing interruptible in the bash shell. */
- extern int interrupt_state;
-
- if (interrupt_state)
- {
- closedir (d);
- lose = 1;
- goto lost;
- }
-#endif /* SHELL */
-
- dp = readdir (d);
- if (dp == NULL)
- break;
- if (REAL_DIR_ENTRY (dp)
- && glob_match (pat, dp->d_name, noglob_dot_filenames))
- {
-#ifdef ALLOCA_MISSING
- nextlink = (struct globval *) malloc (sizeof (struct globval));
-#else
- nextlink = (struct globval *) alloca (sizeof (struct globval));
-#endif
- nextlink->next = lastlink;
- i = D_NAMLEN (dp) + 1;
- nextname = (char *) malloc (i);
- if (nextname == NULL)
- {
- lose = 1;
- break;
- }
- lastlink = nextlink;
- nextlink->name = nextname;
- bcopy (dp->d_name, nextname, i);
- count++;
- }
- }
- closedir (d);
-
- if (!lose)
- {
- name_vector = (char **) malloc ((count + 1) * sizeof (char *));
- lose |= name_vector == NULL;
- }
-
- /* Have we run out of memory? */
-#ifdef SHELL
- lost:
-#endif
- if (lose)
- {
- /* Here free the strings we have got. */
- while (lastlink)
- {
- free (lastlink->name);
-#ifdef ALLOCA_MISSING
- templink = lastlink->next;
- free ((char *) lastlink);
- lastlink = templink;
-#else
- lastlink = lastlink->next;
-#endif
- }
- return NULL;
- }
-
- /* Copy the name pointers from the linked list into the vector. */
- for (i = 0; i < count; ++i)
- {
- name_vector[i] = lastlink->name;
-#ifdef ALLOCA_MISSING
- templink = lastlink->next;
- free ((char *) lastlink);
- lastlink = templink;
-#else
- lastlink = lastlink->next;
-#endif
- }
-
- name_vector[count] = NULL;
- return name_vector;
-}
-
-/* Return a new array, replacing ARRAY, which is the concatenation
- of each string in ARRAY to DIR.
- Return NULL if out of memory. */
-
-static char **
-glob_dir_to_array (dir, array)
- char *dir, **array;
-{
- register unsigned int i, l;
- int add_slash = 0;
- char **result;
-
- l = strlen (dir);
- if (l == 0)
- return array;
-
- if (dir[l - 1] != '/')
- add_slash++;
-
- for (i = 0; array[i] != NULL; i++)
- ;
-
- result = (char **) malloc ((i + 1) * sizeof (char *));
- if (result == NULL)
- return NULL;
-
- for (i = 0; array[i] != NULL; i++)
- {
- result[i] = (char *) malloc (1 + l + add_slash + strlen (array[i]));
- if (result[i] == NULL)
- return NULL;
- strcpy (result[i], dir);
- if (add_slash)
- result[i][l] = '/';
- strcpy (result[i] + l + add_slash, array[i]);
- }
- result[i] = NULL;
-
- /* Free the input array. */
- for (i = 0; array[i] != NULL; i++)
- free (array[i]);
- free ((char *) array);
- return result;
-}
-
-/* Do globbing on PATHNAME. Return an array of pathnames that match,
- marking the end of the array with a null-pointer as an element.
- If no pathnames match, then the array is empty (first element is null).
- If there isn't enough memory, then return NULL.
- If a file system error occurs, return -1; `errno' has the error code.
-
- Wildcards at the beginning of PAT, or following a slash,
- do not match an initial period if noglob_dot_filenames is nonzero. */
-
-char **
-glob_filename (pathname)
- char *pathname;
-{
- char **result;
- unsigned int result_size;
- char *directory_name, *filename;
- unsigned int directory_len;
-
- result = (char **) malloc (sizeof (char *));
- result_size = 1;
- if (result == NULL)
- return NULL;
-
- result[0] = NULL;
-
- /* Find the filename. */
- filename = rindex (pathname, '/');
- if (filename == NULL)
- {
- filename = pathname;
- directory_name = "";
- directory_len = 0;
- }
- else
- {
- directory_len = (filename - pathname) + 1;
-#ifdef ALLOCA_MISSING
- directory_name = (char *) malloc (directory_len + 1);
-#else
- directory_name = (char *) alloca (directory_len + 1);
-#endif
- bcopy (pathname, directory_name, directory_len);
- directory_name[directory_len] = '\0';
- ++filename;
- }
-
- /* If directory_name contains globbing characters, then we
- have to expand the previous levels. Just recurse. */
- if (glob_pattern_p (directory_name))
- {
- char **directories;
- register unsigned int i;
-
- if (directory_name[directory_len - 1] == '/')
- directory_name[directory_len - 1] = '\0';
-
- directories = glob_filename (directory_name);
-#ifdef ALLOCA_MISSING
- free ((char *) directory_name);
-#endif
- if (directories == NULL)
- goto memory_error;
- else if (directories == (char **) -1)
- return (char **) -1;
- else if (*directories == NULL)
- {
- free ((char *) directories);
- return (char **) -1;
- }
-
- /* We have successfully globbed the preceding directory name.
- For each name in DIRECTORIES, call glob_vector on it and
- FILENAME. Concatenate the results together. */
- for (i = 0; directories[i] != NULL; i++)
- {
- char **temp_results = glob_vector (filename, directories[i]);
- if (temp_results == NULL)
- goto memory_error;
- else if (temp_results == (char **) -1)
- /* This filename is probably not a directory. Ignore it. */
- ;
- else
- {
- char **array = glob_dir_to_array (directories[i], temp_results);
- register unsigned int l;
-
- l = 0;
- while (array[l] != NULL)
- ++l;
-
- result = (char **) realloc (result,
- (result_size + l) * sizeof (char *));
- if (result == NULL)
- goto memory_error;
-
- for (l = 0; array[l] != NULL; ++l)
- result[result_size++ - 1] = array[l];
- result[result_size - 1] = NULL;
- free ((char *) array);
- }
- }
- /* Free the directories. */
- for (i = 0; directories[i] != NULL; i++)
- free (directories[i]);
- free ((char *) directories);
-
- return result;
- }
-
- /* If there is only a directory name, return it. */
- if (*filename == '\0')
- {
- result = (char **) realloc ((char *) result, 2 * sizeof (char *));
- if (result != NULL)
- {
- result[0] = (char *) malloc (directory_len + 1);
- if (result[0] == NULL)
- {
-#ifdef ALLOCA_MISSING
- free ((char *) directory_name);
-#endif
- goto memory_error;
- }
- bcopy (directory_name, result[0], directory_len + 1);
- result[1] = NULL;
- }
-#ifdef ALLOCA_MISSING
- free ((char *) directory_name);
-#endif
- return result;
- }
- else
- {
- /* Otherwise, just return what glob_vector
- returns appended to the directory name. */
- char **temp_results = glob_vector (filename,
- (directory_len == 0
- ? "." : directory_name));
-
- if (temp_results == NULL || temp_results == (char **) -1)
- {
-#ifdef NO_ALLOCA
- free ((char *) directory_name);
-#endif
- return temp_results;
- }
-
- temp_results = glob_dir_to_array (directory_name, temp_results);
-#ifdef NO_ALLOCA
- free ((char *) directory_name);
-#endif
- return temp_results;
- }
-
- /* We get to memory error if the program has run out of memory, or
- if this is the shell, and we have been interrupted. */
- memory_error:
- if (result != NULL)
- {
- register unsigned int i;
- for (i = 0; result[i] != NULL; ++i)
- free (result[i]);
- free ((char *) result);
- }
-#if defined (SHELL)
- {
- extern int interrupt_state;
-
- if (interrupt_state)
- throw_to_top_level ();
- }
-#endif /* SHELL */
- return NULL;
-}
-
-#ifdef TEST
-
-main (argc, argv)
- int argc;
- char **argv;
-{
- char **value;
- int i, optind;
-
- for (optind = 1; optind < argc; optind++)
- {
- value = glob_filename (argv[optind]);
- if (value == NULL)
- puts ("virtual memory exhausted");
- else if (value == (char **) -1)
- perror (argv[optind]);
- else
- for (i = 0; value[i] != NULL; i++)
- puts (value[i]);
- }
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/usr.bin/man/man/man.c b/gnu/usr.bin/man/man/man.c
deleted file mode 100644
index 6407939..0000000
--- a/gnu/usr.bin/man/man/man.c
+++ /dev/null
@@ -1,1544 +0,0 @@
-/*
- * man.c
- *
- * Copyright (c) 1990, 1991, John W. Eaton.
- *
- * You may distribute under the terms of the GNU General Public
- * License as specified in the file COPYING that comes with the man
- * distribution.
- *
- * John W. Eaton
- * jwe@che.utexas.edu
- * Department of Chemical Engineering
- * The University of Texas at Austin
- * Austin, Texas 78712
- */
-
-#define MAN_MAIN
-
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <ctype.h>
-#include <errno.h>
-#ifdef __FreeBSD__
-#include <locale.h>
-#endif
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
-#include "config.h"
-#include "gripes.h"
-#include "version.h"
-
-#ifndef POSIX
-#include <unistd.h>
-#else
-#ifndef R_OK
-#define R_OK 4
-#endif
-#endif
-
-#ifdef SECURE_MAN_UID
-extern uid_t getuid ();
-extern int setuid ();
-#endif
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-extern char *malloc ();
-extern char *getenv ();
-extern void free ();
-extern int system ();
-extern int strcmp ();
-extern int strncmp ();
-extern int exit ();
-extern int fflush ();
-extern int printf ();
-extern int fprintf ();
-extern FILE *fopen ();
-extern int fclose ();
-extern char *sprintf ();
-#endif
-
-extern char **glob_filename ();
-extern int is_newer ();
-extern int is_directory ();
-extern int do_system_command ();
-
-char *prognam;
-static char *pager;
-static char *manp;
-static char *manpathlist[MAXDIRS];
-static char *section;
-static char *colon_sep_section_list;
-static char **section_list;
-static char *roff_directive;
-static int apropos;
-static int whatis;
-static int findall;
-static int print_where;
-
-#ifdef ALT_SYSTEMS
-static int alt_system;
-static char *alt_system_name;
-#endif
-
-static int troff = 0;
-
-int debug;
-
-#ifdef HAS_TROFF
-#ifdef ALT_SYSTEMS
-static char args[] = "M:P:S:adfhkm:p:tw?";
-#else
-static char args[] = "M:P:S:adfhkp:tw?";
-#endif
-#else
-#ifdef ALT_SYSTEMS
-static char args[] = "M:P:S:adfhkm:p:w?";
-#else
-static char args[] = "M:P:S:adfhkp:w?";
-#endif
-#endif
-
-#ifdef SETREUID
-uid_t ruid;
-uid_t euid;
-uid_t rgid;
-uid_t egid;
-#endif
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int status = 0;
- char *nextarg;
- char *tmp;
- extern int optind;
- extern char *mkprogname ();
- char *is_section ();
- char **get_section_list ();
- void man_getopt ();
- void do_apropos ();
- void do_whatis ();
- int man ();
-
- prognam = mkprogname (argv[0]);
-
- unsetenv("IFS");
-#ifdef __FreeBSD__
- (void) setlocale(LC_ALL, "");
-#endif
- man_getopt (argc, argv);
-
- if (optind == argc)
- gripe_no_name ((char *)NULL);
-
- section_list = get_section_list ();
-
- if (optind == argc - 1)
- {
- tmp = is_section (argv[optind]);
-
- if (tmp != NULL)
- gripe_no_name (tmp);
- }
-
-#ifdef SETREUID
- ruid = getuid();
- rgid = getgid();
- euid = geteuid();
- egid = getegid();
- setreuid(-1, ruid);
- setregid(-1, rgid);
-#endif
-
- while (optind < argc)
- {
- nextarg = argv[optind++];
-
- /*
- * See if this argument is a valid section name. If not,
- * is_section returns NULL.
- */
- tmp = is_section (nextarg);
-
- if (tmp != NULL)
- {
- section = tmp;
-
- if (debug)
- fprintf (stderr, "\nsection: %s\n", section);
-
- continue;
- }
-
- if (apropos) {
- do_apropos (nextarg);
- status = (status ? 0 : 1); /* reverts status, see below */
- }
- else if (whatis) {
- do_whatis (nextarg);
- status = (status ? 0 : 1); /* reverts status, see below */
- }
- else
- {
- status = man (nextarg);
-
- if (status == 0)
- gripe_not_found (nextarg, section);
- }
- }
- return (status==0); /* status==1 --> exit(0),
- status==0 --> exit(1) */
-}
-
-void
-usage ()
-{
- static char usage_string[1024] = "%s, version %s\n\n";
-
-#ifdef HAS_TROFF
-#ifdef ALT_SYSTEMS
- static char s1[] =
- "usage: %s [-adfhktw] [section] [-M path] [-P pager] [-S list]\n\
- [-m system] [-p string] name ...\n\n";
-#else
- static char s1[] =
- "usage: %s [-adfhktw] [section] [-M path] [-P pager] [-S list]\n\
- [-p string] name ...\n\n";
-#endif
-#else
-#ifdef ALT_SYSTEMS
- static char s1[] =
- "usage: %s [-adfhkw] [section] [-M path] [-P pager] [-S list]\n\
- [-m system] [-p string] name ...\n\n";
-#else
- static char s1[] =
- "usage: %s [-adfhkw] [section] [-M path] [-P pager] [-S list]\n\
- [-p string] name ...\n\n";
-#endif
-#endif
-
-static char s2[] = " a : find all matching entries\n\
- d : print gobs of debugging information\n\
- f : same as whatis(1)\n\
- h : print this help message\n\
- k : same as apropos(1)\n";
-
-#ifdef HAS_TROFF
- static char s3[] = " t : use troff to format pages for printing\n";
-#endif
-
- static char s4[] = " w : print location of man page(s) that would be displayed\n\n\
- M path : set search path for manual pages to `path'\n\
- P pager : use program `pager' to display pages\n\
- S list : colon separated section list\n";
-
-#ifdef ALT_SYSTEMS
- static char s5[] = " m system : search for alternate system's man pages\n";
-#endif
-
- static char s6[] = " p string : string tells which preprocessors to run\n\
- e - [n]eqn(1) p - pic(1) t - tbl(1)\n\
- g - grap(1) r - refer(1) v - vgrind(1)\n";
-
- strcat (usage_string, s1);
- strcat (usage_string, s2);
-
-#ifdef HAS_TROFF
- strcat (usage_string, s3);
-#endif
-
- strcat (usage_string, s4);
-
-#ifdef ALT_SYSTEMS
- strcat (usage_string, s5);
-#endif
-
- strcat (usage_string, s6);
-
- fprintf (stderr, usage_string, prognam, version, prognam);
- exit(1);
-}
-
-char **
-add_dir_to_mpath_list (mp, p)
- char **mp;
- char *p;
-{
- int status;
-
- status = is_directory (p);
-
- if (status < 0 && debug)
- {
- fprintf (stderr, "Warning: couldn't stat file %s!\n", p);
- }
- else if (status == 0 && debug)
- {
- fprintf (stderr, "Warning: %s isn't a directory!\n", p);
- }
- else if (status == 1)
- {
- if (debug)
- fprintf (stderr, "adding %s to manpathlist\n", p);
-
- *mp++ = strdup (p);
- }
- return mp;
-}
-
-/*
- * Get options from the command line and user environment.
- */
-void
-man_getopt (argc, argv)
- register int argc;
- register char **argv;
-{
- register int c;
- register char *p;
- register char *end;
- register char **mp;
- extern char *optarg;
- extern int getopt ();
- extern void downcase ();
- extern char *manpath ();
-
- while ((c = getopt (argc, argv, args)) != EOF)
- {
- switch (c)
- {
- case 'M':
- manp = strdup (optarg);
- break;
- case 'P':
- pager = strdup (optarg);
- if (setenv("PAGER", pager, 1) != 0)
- (void)fprintf(stderr, "setenv PAGER=%s\n", pager);
- break;
- case 'S':
- colon_sep_section_list = strdup (optarg);
- break;
- case 'a':
- findall++;
- break;
- case 'd':
- debug++;
- break;
- case 'f':
- if (troff)
- gripe_incompatible ("-f and -t");
- if (apropos)
- gripe_incompatible ("-f and -k");
- if (print_where)
- gripe_incompatible ("-f and -w");
- whatis++;
- break;
- case 'k':
- if (troff)
- gripe_incompatible ("-k and -t");
- if (whatis)
- gripe_incompatible ("-k and -f");
- if (print_where)
- gripe_incompatible ("-k and -w");
- apropos++;
- break;
-#ifdef ALT_SYSTEMS
- case 'm':
- alt_system++;
- alt_system_name = strdup (optarg);
- break;
-#endif
- case 'p':
- roff_directive = strdup (optarg);
- break;
-#ifdef HAS_TROFF
- case 't':
- if (apropos)
- gripe_incompatible ("-t and -k");
- if (whatis)
- gripe_incompatible ("-t and -f");
- if (print_where)
- gripe_incompatible ("-t and -w");
- troff++;
- break;
-#endif
- case 'w':
- if (apropos)
- gripe_incompatible ("-w and -k");
- if (whatis)
- gripe_incompatible ("-w and -f");
- if (troff)
- gripe_incompatible ("-w and -t");
- print_where++;
- break;
- case 'h':
- case '?':
- default:
- usage();
- break;
- }
- }
-
- if (pager == NULL || *pager == '\0')
- if ((pager = getenv ("PAGER")) == NULL)
- pager = strdup (PAGER);
-
- if (debug)
- fprintf (stderr, "\nusing %s as pager\n", pager);
-
- if (manp == NULL)
- {
- if ((manp = manpath (0)) == NULL)
- gripe_manpath ();
-
- if (debug)
- fprintf (stderr,
- "\nsearch path for pages determined by manpath is\n%s\n\n",
- manp);
- }
-
-#ifdef ALT_SYSTEMS
- if (alt_system_name == NULL || *alt_system_name == '\0')
- if ((alt_system_name = getenv ("SYSTEM")) != NULL)
- alt_system_name = strdup (alt_system_name);
-
- if (alt_system_name != NULL && *alt_system_name != '\0')
- downcase (alt_system_name);
-#endif
-
- /*
- * Expand the manpath into a list for easier handling.
- */
- mp = manpathlist;
- for (p = manp; ; p = end+1)
- {
- if (mp == manpathlist + MAXDIRS - 1) {
- fprintf (stderr, "Warning: too many directories in manpath, truncated!\n");
- break;
- }
- if ((end = strchr (p, ':')) != NULL)
- *end = '\0';
-
-#ifdef ALT_SYSTEMS
- if (alt_system)
- {
- char buf[FILENAME_MAX];
-
- if (debug)
- fprintf (stderr, "Alternate system `%s' specified\n",
- alt_system_name);
-
- snprintf(buf, sizeof(buf), "%s/%s", p, alt_system_name);
-
- mp = add_dir_to_mpath_list (mp, buf);
- }
- else
- {
- mp = add_dir_to_mpath_list (mp, p);
- }
-#else
- mp = add_dir_to_mpath_list (mp, p);
-#endif
- if (end == NULL)
- break;
-
- *end = ':';
- }
- *mp = NULL;
-}
-
-/*
- * Check to see if the argument is a valid section number. If the
- * first character of name is a numeral, or the name matches one of
- * the sections listed in section_list, we'll assume that it's a section.
- * The list of sections in config.h simply allows us to specify oddly
- * named directories like .../man3f. Yuk.
- */
-char *
-is_section (name)
- register char *name;
-{
- register char **vs;
-
- for (vs = section_list; *vs != NULL; vs++)
- if ((strcmp (*vs, name) == 0)
- || (isdigit (name[0]) && strlen(name) == 1))
- return strdup (name);
-
- return NULL;
-}
-
-/*
- * Handle the apropos option. Cheat by using another program.
- */
-void
-do_apropos (name)
- register char *name;
-{
- register int len;
- register char *command;
-
- len = strlen (APROPOS) + strlen (name) + 2;
-
- if ((command = (char *) malloc(len)) == NULL)
- gripe_alloc (len, "command");
-
- sprintf (command, "%s %s", APROPOS, name);
-
- (void) do_system_command (command);
-
- free (command);
-}
-
-/*
- * Handle the whatis option. Cheat by using another program.
- */
-void
-do_whatis (name)
- register char *name;
-{
- register int len;
- register char *command;
-
- len = strlen (WHATIS) + strlen (name) + 2;
-
- if ((command = (char *) malloc(len)) == NULL)
- gripe_alloc (len, "command");
-
- sprintf (command, "%s %s", WHATIS, name);
-
- (void) do_system_command (command);
-
- free (command);
-}
-
-/*
- * Change a name of the form ...man/man1/name.1 to ...man/cat1/name.1
- * or a name of the form ...man/cat1/name.1 to ...man/man1/name.1
- */
-char *
-convert_name (name, to_cat)
- register char *name;
- register int to_cat;
-{
- register char *to_name;
- register char *t1;
- register char *t2 = NULL;
-
-#ifdef DO_COMPRESS
- if (to_cat)
- {
- int olen = strlen(name);
- int cextlen = strlen(COMPRESS_EXT);
- int len = olen + cextlen;
-
- to_name = malloc (len+1);
- if (to_name == NULL)
- gripe_alloc (len+1, "to_name");
- strcpy (to_name, name);
- olen -= cextlen;
- /* Avoid tacking it on twice */
- if (olen >= 1 && strcmp(name + olen, COMPRESS_EXT) != 0)
- strcat (to_name, COMPRESS_EXT);
- }
- else
- to_name = strdup (name);
-#else
- to_name = strdup (name);
-#endif
-
- t1 = strrchr (to_name, '/');
- if (t1 != NULL)
- {
- *t1 = '\0';
- t2 = strrchr (to_name, '/');
- *t1 = '/';
- }
-
- if (t2 == NULL)
- gripe_converting_name (name, to_cat);
-
- if (to_cat)
- {
- *(++t2) = 'c';
- *(t2+2) = 't';
- }
- else
- {
- *(++t2) = 'm';
- *(t2+2) = 'n';
- }
-
- if (debug)
- fprintf (stderr, "to_name in convert_name () is: %s\n", to_name);
-
- return to_name;
-}
-
-/*
- * Try to find the man page corresponding to the given name. The
- * reason we do this with globbing is because some systems have man
- * page directories named man3 which contain files with names like
- * XtPopup.3Xt. Rather than requiring that this program know about
- * all those possible names, we simply try to match things like
- * .../man[sect]/name[sect]*. This is *much* easier.
- *
- * Note that globbing is only done when the section is unspecified.
- */
-char **
-glob_for_file (path, section, name, cat)
- register char *path;
- register char *section;
- register char *name;
- register int cat;
-{
- char pathname[FILENAME_MAX];
- char **gf;
-
- if (cat)
- snprintf (pathname, sizeof(pathname), "%s/cat%s/%s.%s*", path, section, name, section);
- else
- snprintf (pathname, sizeof(pathname), "%s/man%s/%s.%s*", path, section, name, section);
-
- if (debug)
- fprintf (stderr, "globbing %s\n", pathname);
-
- gf = glob_filename (pathname);
-
- if ((gf == (char **) -1 || *gf == NULL) && isdigit (*section))
- {
- if (cat)
- snprintf (pathname, sizeof(pathname), "%s/cat%s/%s.%c*", path, section, name, *section);
- else
- snprintf (pathname, sizeof(pathname), "%s/man%s/%s.%c*", path, section, name, *section);
-
- gf = glob_filename (pathname);
- }
- if ((gf == (char **) -1 || *gf == NULL) && isdigit (*section))
- {
- if (cat)
- snprintf (pathname, sizeof(pathname), "%s/cat%s/%s.0*", path, section, name);
- else
- snprintf (pathname, sizeof(pathname), "%s/man%s/%s.0*", path, section, name);
- if (debug)
- fprintf (stderr, "globbing %s\n", pathname);
- gf = glob_filename (pathname);
- }
- return gf;
-}
-
-/*
- * Return an un-globbed name in the same form as if we were doing
- * globbing.
- */
-char **
-make_name (path, section, name, cat)
- register char *path;
- register char *section;
- register char *name;
- register int cat;
-{
- register int i = 0;
- static char *names[3];
- char buf[FILENAME_MAX];
-
- if (cat)
- snprintf (buf, sizeof(buf), "%s/cat%s/%s.%s", path, section, name, section);
- else
- snprintf (buf, sizeof(buf), "%s/man%s/%s.%s", path, section, name, section);
-
- if (access (buf, R_OK) == 0)
- names[i++] = strdup (buf);
-
- /*
- * If we're given a section that looks like `3f', we may want to try
- * file names like .../man3/foo.3f as well. This seems a bit
- * kludgey to me, but what the hey...
- */
- if (section[1] != '\0')
- {
- if (cat)
- snprintf (buf, sizeof(buf), "%s/cat%c/%s.%s", path, section[0], name, section);
- else
- snprintf (buf, sizeof(buf), "%s/man%c/%s.%s", path, section[0], name, section);
-
- if (access (buf, R_OK) == 0)
- names[i++] = strdup (buf);
- }
-
- names[i] = NULL;
-
- return &names[0];
-}
-
-char *
-get_expander (file)
- char *file;
-{
- char *end = file + (strlen (file) - 1);
-
- while (end > file && end[-1] != '.')
- --end;
- if (end == file)
- return NULL;
-#ifdef FCAT
- if (*end == 'F')
- return FCAT;
-#endif /* FCAT */
-#ifdef YCAT
- if (*end == 'Y')
- return YCAT;
-#endif /* YCAT */
-#ifdef ZCAT
- if (*end == 'Z' || !strcmp(end, "gz"))
- return ZCAT;
-#endif /* ZCAT */
- return NULL;
-}
-
-/*
- * Simply display the preformatted page.
- */
-int
-display_cat_file (file)
- register char *file;
-{
- register int found;
- char command[FILENAME_MAX];
-
- found = 0;
-
- if (access (file, R_OK) == 0)
- {
- char *expander = get_expander (file);
-
- if (expander != NULL)
- snprintf (command, sizeof(command), "%s %s | %s", expander, file, pager);
- else
- snprintf (command, sizeof(command), "%s %s", pager, file);
-
- found = do_system_command (command);
- }
- return found;
-}
-
-/*
- * Try to find the ultimate source file. If the first line of the
- * current file is not of the form
- *
- * .so man3/printf.3s
- *
- * the input file name is returned.
- */
-char *
-ultimate_source (name, path)
- char *name;
- char *path;
-{
- static char buf[BUFSIZ];
- static char ult[FILENAME_MAX];
-
- FILE *fp;
- char *beg;
- char *end;
-
- strncpy (ult, name, sizeof(ult)-1);
- ult[sizeof(ult)-1] = '\0';
- strncpy (buf, name, sizeof(buf)-1);
- ult[sizeof(buf)-1] = '\0';
-
- next:
-
- if ((fp = fopen (ult, "r")) == NULL)
- return ult;
-
- end = fgets (buf, BUFSIZ, fp);
- fclose(fp);
-
- if (!end || strlen (buf) < 5)
- return ult;
-
- beg = buf;
- if (*beg++ == '.' && *beg++ == 's' && *beg++ == 'o')
- {
- while ((*beg == ' ' || *beg == '\t') && *beg != '\0')
- beg++;
-
- end = beg;
- while (*end != ' ' && *end != '\t' && *end != '\n' && *end != '\0')
- end++;
-
- *end = '\0';
-
- snprintf(ult, sizeof(ult), "%s/%s", path, beg);
- snprintf(buf, sizeof(buf), "%s", ult);
-
- goto next;
- }
-
- if (debug)
- fprintf (stderr, "found ultimate source file %s\n", ult);
-
- return ult;
-}
-
-void
-add_directive (first, d, file, buf, bufsize)
- int *first;
- char *d;
- char *file;
- char *buf;
- int bufsize;
-{
- if (strcmp (d, "") != 0)
- {
- if (*first)
- {
- *first = 0;
- snprintf(buf, bufsize, "%s %s", d, file);
- }
- else
- {
- strncat (buf, " | ", bufsize-strlen(buf)-1);
- strncat (buf, d, bufsize-strlen(buf)-1);
- }
- }
-}
-
-int
-parse_roff_directive (cp, file, buf, bufsize)
- char *cp;
- char *file;
- char *buf;
- int bufsize;
-{
- char c;
- int first = 1;
- int tbl_found = 0;
-
- while ((c = *cp++) != '\0')
- {
- switch (c)
- {
- case 'e':
-
- if (debug)
- fprintf (stderr, "found eqn(1) directive\n");
-
- if (troff)
- add_directive (&first, EQN, file, buf, bufsize);
- else
- add_directive (&first, NEQN, file, buf, bufsize);
-
- break;
-
- case 'g':
-
- if (debug)
- fprintf (stderr, "found grap(1) directive\n");
-
- add_directive (&first, GRAP, file, buf, bufsize);
-
- break;
-
- case 'p':
-
- if (debug)
- fprintf (stderr, "found pic(1) directive\n");
-
- add_directive (&first, PIC, file, buf, bufsize);
-
- break;
-
- case 't':
-
- if (debug)
- fprintf (stderr, "found tbl(1) directive\n");
-
- tbl_found++;
- add_directive (&first, TBL, file, buf, bufsize);
- break;
-
- case 'v':
-
- if (debug)
- fprintf (stderr, "found vgrind(1) directive\n");
-
- add_directive (&first, VGRIND, file, buf, bufsize);
- break;
-
- case 'r':
-
- if (debug)
- fprintf (stderr, "found refer(1) directive\n");
-
- add_directive (&first, REFER, file, buf, bufsize);
- break;
-
- case ' ':
- case '\t':
- case '\n':
-
- goto done;
-
- default:
-
- return -1;
- }
- }
-
- done:
-
- if (first)
- return 1;
-
-#ifdef HAS_TROFF
- if (troff)
- {
- strncat (buf, " | ", bufsize-strlen(buf)-1);
- strncat (buf, TROFF, bufsize-strlen(buf)-1);
- }
- else
-#endif
- {
- strncat (buf, " | ", bufsize-strlen(buf)-1);
- strncat (buf, NROFF, bufsize-strlen(buf)-1);
- }
- if (tbl_found && !troff && strcmp (COL, "") != 0)
- {
- strncat (buf, " | ", bufsize-strlen(buf)-1);
- strncat (buf, COL, bufsize-strlen(buf)-1);
- }
-
- return 0;
-}
-
-char *
-make_roff_command (file)
- char *file;
-{
- FILE *fp;
- char line [BUFSIZ];
- static char buf [BUFSIZ];
- int status;
- char *cp;
-
- if (roff_directive != NULL)
- {
- if (debug)
- fprintf (stderr, "parsing directive from command line\n");
-
- status = parse_roff_directive (roff_directive, file, buf, sizeof(buf));
-
- if (status == 0)
- return buf;
-
- if (status == -1)
- gripe_roff_command_from_command_line (file);
- }
-
- if ((fp = fopen (file, "r")) != NULL)
- {
- cp = line;
- fgets (line, BUFSIZ, fp);
- fclose(fp);
- if (*cp++ == '\'' && *cp++ == '\\' && *cp++ == '"' && *cp++ == ' ')
- {
- if (debug)
- fprintf (stderr, "parsing directive from file\n");
-
- status = parse_roff_directive (cp, file, buf, sizeof(buf));
-
- if (status == 0)
- return buf;
-
- if (status == -1)
- gripe_roff_command_from_file (file);
- }
- }
- else
- {
- /*
- * Is there really any point in continuing to look for
- * preprocessor options if we can't even read the man page source?
- */
- gripe_reading_man_file (file);
- return NULL;
- }
-
- if ((cp = getenv ("MANROFFSEQ")) != NULL)
- {
- if (debug)
- fprintf (stderr, "parsing directive from environment\n");
-
- status = parse_roff_directive (cp, file, buf, sizeof(buf));
-
- if (status == 0)
- return buf;
-
- if (status == -1)
- gripe_roff_command_from_env ();
- }
-
- if (debug)
- fprintf (stderr, "using default preprocessor sequence\n");
-
- if ((cp = get_expander(file)) == NULL)
- cp = "/bin/cat";
- snprintf(buf, sizeof(buf), "%s %s | ", cp, file);
-#ifdef HAS_TROFF
- if (troff)
- {
- if (strcmp (TBL, "") != 0)
- {
- strncat(buf, TBL, sizeof(buf)-strlen(buf)-1);
- strncat(buf, " | ", sizeof(buf)-strlen(buf)-1);
- strncat(buf, TROFF, sizeof(buf)-strlen(buf)-1);
- }
- else
- {
- strncat(buf, TROFF, sizeof(buf)-strlen(buf)-1);
- }
- }
- else
-#endif
- {
- if (strcmp (TBL, "") != 0)
- {
- strncat(buf, TBL, sizeof(buf)-strlen(buf)-1);
- strncat(buf, " | ", sizeof(buf)-strlen(buf)-1);
- strncat(buf, NROFF, sizeof(buf)-strlen(buf)-1);
- }
- else
- {
- strncpy (buf, NROFF, sizeof(buf));
- }
-
- if (strcmp (COL, "") != 0)
- {
- strncat (buf, " | ", sizeof(buf)-strlen(buf)-1);
- strncat (buf, COL, sizeof(buf)-strlen(buf)-1);
- }
- }
- return buf;
-}
-
-sig_t ohup, oint, oquit, oterm;
-static char temp[FILENAME_MAX];
-
-void cleantmp()
-{
- unlink(temp);
- exit(1);
-}
-
-void
-set_sigs()
-{
- ohup = signal(SIGHUP, cleantmp);
- oint = signal(SIGINT, cleantmp);
- oquit = signal(SIGQUIT, cleantmp);
- oterm = signal(SIGTERM, cleantmp);
-}
-
-void
-restore_sigs()
-{
- signal(SIGHUP, ohup);
- signal(SIGINT, oint);
- signal(SIGQUIT, oquit);
- signal(SIGTERM, oterm);
-}
-
-/*
- * Try to format the man page and create a new formatted file. Return
- * 1 for success and 0 for failure.
- */
-int
-make_cat_file (path, man_file, cat_file, manid)
- register char *path;
- register char *man_file;
- register char *cat_file;
-{
- int s, f;
- FILE *fp, *pp;
- char *roff_command;
- char command[FILENAME_MAX];
-
- roff_command = make_roff_command (man_file);
- if (roff_command == NULL)
- return 0;
-
- snprintf(temp, sizeof(temp), "%s.tmpXXXXXX", cat_file);
- if ((f = mkstemp(temp)) >= 0 && (fp = fdopen(f, "w")) != NULL)
- {
- set_sigs();
-
- if (fchmod (f, CATMODE) < 0) {
- perror("fchmod");
- unlink(temp);
- restore_sigs();
- fclose(fp);
- return 0;
- } else if (debug)
- fprintf (stderr, "mode of %s is now %o\n", temp, CATMODE);
-
-#ifdef DO_COMPRESS
- snprintf (command, sizeof(command), "(cd %s ; %s | %s)", path,
- roff_command, COMPRESSOR);
-#else
- snprintf (command, sizeof(command), "(cd %s ; %s)", path,
- roff_command);
-#endif
- fprintf (stderr, "Formatting page, please wait...");
- fflush(stderr);
-
- if (debug)
- fprintf (stderr, "\ntrying command: %s\n", command);
- else {
-
-#ifdef SETREUID
- if (manid) {
- setreuid(-1, ruid);
- setregid(-1, rgid);
- }
-#endif
- if ((pp = popen(command, "r")) == NULL) {
- s = errno;
- fprintf(stderr, "Failed.\n");
- errno = s;
- perror("popen");
-#ifdef SETREUID
- if (manid) {
- setreuid(-1, euid);
- setregid(-1, egid);
- }
-#endif
- unlink(temp);
- restore_sigs();
- fclose(fp);
- return 0;
- }
-#ifdef SETREUID
- if (manid) {
- setreuid(-1, euid);
- setregid(-1, egid);
- }
-#endif
-
- while ((s = getc(pp)) != EOF)
- putc(s, fp);
-
- if ((s = pclose(pp)) == -1) {
- s = errno;
- fprintf(stderr, "Failed.\n");
- errno = s;
- perror("pclose");
- unlink(temp);
- restore_sigs();
- fclose(fp);
- return 0;
- }
-
- if (s != 0) {
- fprintf(stderr, "Failed.\n");
- gripe_system_command(s);
- unlink(temp);
- restore_sigs();
- fclose(fp);
- return 0;
- }
- }
-
- if (debug)
- unlink(temp);
- else if (rename(temp, cat_file) == -1) {
- s = errno;
- fprintf(stderr,
- "\nHmm! Can't seem to rename %s to %s, check permissions on man dir!\n",
- temp, cat_file);
- errno = s;
- perror("rename");
- unlink(temp);
- restore_sigs();
- fclose(fp);
- return 0;
- }
- restore_sigs();
-
- if (fclose(fp)) {
- s = errno;
- if (!debug)
- unlink(cat_file);
- fprintf(stderr, "Failed.\n");
- errno = s;
- perror("fclose");
- return 0;
- }
-
- if (debug) {
- fprintf(stderr, "No output, debug mode.\n");
- return 0;
- }
-
- fprintf(stderr, "Done.\n");
-
- return 1;
- }
- else
- {
- if (f >= 0) {
- s = errno;
- unlink(temp);
- errno = s;
- }
- if (debug) {
- s = errno;
- fprintf (stderr, "Couldn't open %s for writing.\n", temp);
- errno = s;
- }
- if (f >= 0) {
- perror("fdopen");
- close(f);
- }
-
- return 0;
- }
-}
-
-/*
- * Try to format the man page source and save it, then display it. If
- * that's not possible, try to format the man page source and display
- * it directly.
- *
- * Note that we've already been handed the name of the ultimate source
- * file at this point.
- */
-int
-format_and_display (path, man_file, cat_file)
- register char *path;
- register char *man_file;
- register char *cat_file;
-{
- int status;
- register int found;
- char *roff_command;
- char command[FILENAME_MAX];
-
- found = 0;
-
- if (access (man_file, R_OK) != 0)
- return 0;
-
- if (troff)
- {
- roff_command = make_roff_command (man_file);
- if (roff_command == NULL)
- return 0;
- else
- snprintf (command, sizeof(command), "(cd %s ; %s)", path, roff_command);
-
- found = do_system_command (command);
- }
- else
- {
- status = is_newer (man_file, cat_file);
- if (debug)
- fprintf (stderr, "status from is_newer() = %d\n", status);
-
- if (status == 1 || status == -2)
- {
- /*
- * Cat file is out of date. Try to format and save it.
- */
- if (print_where)
- {
- printf ("%s\n", man_file);
- found++;
- }
- else
- {
-
-#ifdef SETREUID
- setreuid(-1, euid);
- setregid(-1, egid);
- found = make_cat_file (path, man_file, cat_file, 1);
-#else
- found = make_cat_file (path, man_file, cat_file, 0);
-#endif
-#ifdef SETREUID
- setreuid(-1, ruid);
- setregid(-1, rgid);
-
- if (!found)
- {
- /* Try again as real user - see note below.
- By running with
- effective group (user) ID == real group (user) ID
- except for the call above, I believe the problems
- of reading private man pages is avoided. */
- found = make_cat_file (path, man_file, cat_file, 0);
- }
-#endif
-#ifdef SECURE_MAN_UID
- if (!found)
- {
- /*
- * Try again as real user. Note that for private
- * man pages, we won't even get this far unless the
- * effective user can read the real user's man page
- * source. Also, if we are trying to find all the
- * man pages, this will probably make it impossible
- * to make cat files in the system directories if
- * the real user's man directories are searched
- * first, because there's no way to undo this (is
- * there?). Yikes, am I missing something obvious?
- */
- setuid (getuid ());
-
- found = make_cat_file (path, man_file, cat_file, 0);
- }
-#endif
- if (found)
- {
- /*
- * Creating the cat file worked. Now just display it.
- */
- (void) display_cat_file (cat_file);
- }
- else
- {
- /*
- * Couldn't create cat file. Just format it and
- * display it through the pager.
- */
- roff_command = make_roff_command (man_file);
- if (roff_command == NULL)
- return 0;
- else
- snprintf (command, sizeof(command), "(cd %s ; %s | %s)", path,
- roff_command, pager);
-
- found = do_system_command (command);
- }
- }
- }
- else if (access (cat_file, R_OK) == 0)
- {
- /*
- * Formatting not necessary. Cat file is newer than source
- * file, or source file is not present but cat file is.
- */
- if (print_where)
- {
- printf ("%s (source: %s)\n", cat_file, man_file);
- found++;
- }
- else
- {
- found = display_cat_file (cat_file);
- }
- }
- }
- return found;
-}
-
-/*
- * See if the preformatted man page or the source exists in the given
- * section.
- */
-int
-try_section (path, section, name, glob)
- register char *path;
- register char *section;
- register char *name;
- register int glob;
-{
- register int found = 0;
- register int to_cat;
- register int cat;
- register char **names;
- register char **np;
-
- if (debug)
- {
- if (glob)
- fprintf (stderr, "trying section %s with globbing\n", section);
- else
- fprintf (stderr, "trying section %s without globbing\n", section);
- }
-
-#ifndef NROFF_MISSING
- /*
- * Look for man page source files.
- */
- cat = 0;
- if (glob)
- names = glob_for_file (path, section, name, cat);
- else
- names = make_name (path, section, name, cat);
-
- if (names == (char **) -1 || *names == NULL)
- /*
- * No files match. See if there's a preformatted page around that
- * we can display.
- */
-#endif /* NROFF_MISSING */
- {
- if (!troff)
- {
- cat = 1;
- if (glob)
- names = glob_for_file (path, section, name, cat);
- else
- names = make_name (path, section, name, cat);
-
- if (names != (char **) -1 && *names != NULL)
- {
- for (np = names; *np != NULL; np++)
- {
- if (print_where)
- {
- printf ("%s\n", *np);
- found++;
- }
- else
- {
- found += display_cat_file (*np);
- }
- }
- }
- }
- }
-#ifndef NROFF_MISSING
- else
- {
- for (np = names; *np != NULL; np++)
- {
- register char *cat_file = NULL;
- register char *man_file;
-
- man_file = ultimate_source (*np, path);
-
- if (!troff)
- {
- to_cat = 1;
-
- cat_file = convert_name (man_file, to_cat);
-
- if (debug)
- fprintf (stderr, "will try to write %s if needed\n", cat_file);
- }
-
- found += format_and_display (path, man_file, cat_file);
- }
- }
-#endif /* NROFF_MISSING */
- return found;
-}
-
-/*
- * Search for manual pages.
- *
- * If preformatted manual pages are supported, look for the formatted
- * file first, then the man page source file. If they both exist and
- * the man page source file is newer, or only the source file exists,
- * try to reformat it and write the results in the cat directory. If
- * it is not possible to write the cat file, simply format and display
- * the man file.
- *
- * If preformatted pages are not supported, or the troff option is
- * being used, only look for the man page source file.
- *
- */
-int
-man (name)
- char *name;
-{
- register int found;
- register int glob;
- register char **mp;
- register char **sp;
-
- found = 0;
-
- fflush (stdout);
- if (section != NULL)
- {
- for (mp = manpathlist; *mp != NULL; mp++)
- {
- if (debug)
- fprintf (stderr, "\nsearching in %s\n", *mp);
-
- glob = 1;
-
- found += try_section (*mp, section, name, glob);
-
- if (found && !findall) /* i.e. only do this section... */
- return found;
- }
- }
- else
- {
- for (sp = section_list; *sp != NULL; sp++)
- {
- for (mp = manpathlist; *mp != NULL; mp++)
- {
- if (debug)
- fprintf (stderr, "\nsearching in %s\n", *mp);
-
- glob = 1;
-
- found += try_section (*mp, *sp, name, glob);
-
- if (found && !findall) /* i.e. only do this section... */
- return found;
- }
- }
- }
- return found;
-}
-
-char **
-get_section_list ()
-{
- int i;
- char *p;
- char *end;
-#define TMP_SECTION_LIST_SIZE 100
- static char *tmp_section_list[TMP_SECTION_LIST_SIZE];
-
- if (colon_sep_section_list == NULL)
- {
- if ((p = getenv ("MANSECT")) == NULL)
- {
- return std_sections;
- }
- else
- {
- colon_sep_section_list = strdup (p);
- }
- }
-
- i = 0;
- for (p = colon_sep_section_list; i < TMP_SECTION_LIST_SIZE ; p = end+1)
- {
- if ((end = strchr (p, ':')) != NULL)
- *end = '\0';
-
- tmp_section_list[i++] = strdup (p);
-
- if (end == NULL)
- break;
- }
-
- tmp_section_list [i] = NULL;
- return tmp_section_list;
-}
diff --git a/gnu/usr.bin/man/man/man.man b/gnu/usr.bin/man/man/man.man
deleted file mode 100644
index d16a59a..0000000
--- a/gnu/usr.bin/man/man/man.man
+++ /dev/null
@@ -1,139 +0,0 @@
-.\" Man page for man
-.\"
-.\" Copyright (c) 1990, 1991, John W. Eaton.
-.\"
-.\" You may distribute under the terms of the GNU General Public
-.\" License as specified in the README file that comes with the man 1.0
-.\" distribution.
-.\"
-.\" John W. Eaton
-.\" jwe@che.utexas.edu
-.\" Department of Chemical Engineering
-.\" The University of Texas at Austin
-.\" Austin, Texas 78712
-.\"
-.Dd Jan 5, 1991
-.Dt MAN 1
-.Sh NAME
-.Nm man
-.Nd format and display the on-line manual pages
-.Sh SYNOPSIS
-.Nm man
-.Op Fl adfhktw
-.Op Fl m Ar system
-.Op Fl p Ar string
-.Op Fl M Ar path
-.Op Fl P Ar pager
-.Op Fl S Ar list
-.Op Ar section
-.Ar name ...
-.Sh DESCRIPTION
-.Nm Man
-formats and displays the on-line manual pages. This version knows
-about the
-.Ev MANPATH
-and
-.Ev PAGER
-environment variables, so you can have
-your own set(s) of personal man pages and choose whatever program you
-like to display the formatted pages. If section is specified, man
-only looks in that section of the manual. You may also specify the
-order to search the sections for entries and which preprocessors to
-run on the source files via command line options or environment
-variables. If enabled by the system administrator, formatted man
-pages will also be compressed with the `%compress%' command to save
-space.
-.Pp
-The options are as follows:
-.Bl -tag -width Fl
-.It Fl M Ar path
-Specify an alternate manpath. By default, man uses
-.Nm manpath
-to determine the path to search. This option overrides the
-.Ev MANPATH
-environment variable.
-.It Fl P Ar pager
-Specify which pager to use. By default, man uses
-.Nm %pager% ,
-This option overrides the
-.Ev PAGER
-environment variable.
-.It Fl S Ar list
-List is a colon separated list of manual sections to search.
-This option overrides the
-.Ev MANSECT
-environment variable.
-.It Fl a
-By default, man will exit after displaying the first manual page it
-finds. Using this option forces man to display all the manual pages
-that match
-.Ar name ,
-not just the first.
-.It Fl d
-Don't actually display the man pages, but do print gobs of debugging
-information.
-.It Fl f
-Equivalent to
-.Nm whatis .
-.It Fl h
-Print a one line help message and exit.
-.It Fl k
-Equivalent to
-.Nm apropos .
-.It Fl m Ar system
-Specify an alternate set of man pages to search based on the system
-name given.
-.It Fl p Ar string
-Specify the sequence of preprocessors to run before nroff or troff.
-Not all installations will have a full set of preprocessors.
-Some of the preprocessors and the letters used to designate them are:
-eqn (e), grap (g), pic (p), tbl (t), vgrind (v), refer (r).
-This option overrides the
-.Ev MANROFFSEQ
-environment variable.
-.It Fl t
-Use
-.Nm %troff%
-to format the manual page, passing the output to stdout.
-The output from
-.Nm %troff%
-may need to be passed through some filter or another before being
-printed.
-.It Fl w
-Don't actually display the man pages, but do print the location(s) of
-the files that would be formatted or displayed.
-.El
-.Sh ENVIRONMENT
-.Bl -tag -width MANROFFSEQ -compact
-.It Ev MANPATH
-If
-.Ev MANPATH
-is set, its value is used as the path to search for manual pages.
-.It Ev MANROFFSEQ
-If
-.Ev MANROFFSEQ
-is set, its value is used to determine the set of preprocessors run
-before running nroff or troff. By default, pages are passed through
-the table preprocessor before nroff.
-.It Ev MANSEC
-If
-.Ev MANSEC
-is set, its value is used to determine which manual sections to search.
-.It Ev PAGER
-If
-.Ev PAGER
-is set, its value is used as the name of the program to use to display
-the man page. By default,
-.Nm %pager%
-is used.
-.El
-.Sh SEE ALSO
-.Xr apropos 1 ,
-.Xr whatis 1 ,
-.Xr manpath 1 ,
-.Xr more 1 ,
-.Xr groff 1
-.Sh BUGS
-The
-.Fl t
-option only works if a troff-like program is installed.
diff --git a/gnu/usr.bin/man/man/ndir.h b/gnu/usr.bin/man/man/ndir.h
deleted file mode 100644
index 438d5c2..0000000
--- a/gnu/usr.bin/man/man/ndir.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- <dir.h> -- definitions for 4.2BSD-compatible directory access
-
- last edit: 09-Jul-1983 D A Gwyn
-*/
-
-#ifdef VMS
-#ifndef FAB$C_BID
-#include <fab.h>
-#endif
-#ifndef NAM$C_BID
-#include <nam.h>
-#endif
-#ifndef RMS$_SUC
-#include <rmsdef.h>
-#endif
-#include "dir.h"
-#endif /* VMS */
-
-#define DIRBLKSIZ 512 /* size of directory block */
-#ifdef VMS
-#define MAXNAMLEN (DIR$S_NAME + 7) /* 80 plus room for version #. */
-#define MAXFULLSPEC NAM$C_MAXRSS /* Maximum full spec */
-#else
-#define MAXNAMLEN 15 /* maximum filename length */
-#endif /* VMS */
- /* NOTE: MAXNAMLEN must be one less than a multiple of 4 */
-
-struct direct /* data from readdir() */
- {
- long d_ino; /* inode number of entry */
- unsigned short d_reclen; /* length of this record */
- unsigned short d_namlen; /* length of string in d_name */
- char d_name[MAXNAMLEN+1]; /* name of file */
- };
-
-typedef struct
- {
- int dd_fd; /* file descriptor */
- int dd_loc; /* offset in block */
- int dd_size; /* amount of valid data */
- char dd_buf[DIRBLKSIZ]; /* directory block */
- } DIR; /* stream data from opendir() */
-
-extern DIR *opendir();
-extern struct direct *readdir();
-extern long telldir();
-extern void seekdir();
-extern void closedir();
-
-#define rewinddir( dirp ) seekdir( dirp, 0L )
diff --git a/gnu/usr.bin/man/man/version.h b/gnu/usr.bin/man/man/version.h
deleted file mode 100644
index 2ec5c22..0000000
--- a/gnu/usr.bin/man/man/version.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * version.h
- *
- * Copyright (c) 1990, 1991, John W. Eaton.
- *
- * You may distribute under the terms of the GNU General Public
- * License as specified in the file COPYING that comes with the man
- * distribution.
- *
- * John W. Eaton
- * jwe@che.utexas.edu
- * Department of Chemical Engineering
- * The University of Texas at Austin
- * Austin, Texas 78712
- */
-
-static char version[] = "1.1";
diff --git a/gnu/usr.bin/man/manpath/Makefile b/gnu/usr.bin/man/manpath/Makefile
deleted file mode 100644
index d3fa6b6..0000000
--- a/gnu/usr.bin/man/manpath/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-PROG= manpath
-SRCS= manpath.c
-MAN1= manpath.1
-
-.if exists(${.OBJDIR}/../lib)
-LIBDESTDIR= ${.OBJDIR}/../lib
-.else
-LIBDESTDIR= ${.CURDIR}/../lib
-.endif
-DPADD= ${LIBDESTDIR}/libman.a
-LDADD= -L${LIBDESTDIR} -lman
-
-CFLAGS+= -DMAIN -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -DDO_UNCOMPRESS
-CFLAGS+= -DALT_SYSTEMS -I${.CURDIR}/../lib -I${.OBJDIR}/../lib
-CLEANFILES+= ${MAN1}
-MANDEPEND+= ${MAN1}
-
-${MAN1}: ${.CURDIR}/manpath.man
- @${ECHO} Making ${.TARGET:T} from ${.ALLSRC:T}; \
- sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
- -e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \
- -e 's,%manpath_config_file%,${manpath_config_file},' \
- ${.CURDIR}/manpath.man > ${MAN1}
-
-afterinstall:
- ${INSTALL} -c -o bin -g bin -m 644 ${.CURDIR}/manpath.config \
- ${DESTDIR}${manpath_config_file}.sample
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/man/manpath/manpath.c b/gnu/usr.bin/man/manpath/manpath.c
deleted file mode 100644
index c988cd2ac..0000000
--- a/gnu/usr.bin/man/manpath/manpath.c
+++ /dev/null
@@ -1,525 +0,0 @@
-/*
- * manpath.c
- *
- * Copyright (c) 1990, 1991, John W. Eaton.
- *
- * You may distribute under the terms of the GNU General Public
- * License as specified in the file COPYING that comes with the man
- * distribution.
- *
- * John W. Eaton
- * jwe@che.utexas.edu
- * Department of Chemical Engineering
- * The University of Texas at Austin
- * Austin, Texas 78712
- */
-
-#define MANPATH_MAIN
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "config.h"
-#include "manpath.h"
-#include "gripes.h"
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-extern int fprintf ();
-extern int strcmp ();
-extern int strncmp ();
-extern char *memcpy ();
-extern char *getenv();
-extern char *malloc();
-extern void free ();
-extern int exit ();
-#endif
-
-extern char *strdup ();
-extern int is_directory ();
-
-#ifndef MAIN
-extern int debug;
-#endif
-
-#ifdef MAIN
-
-#ifndef STDC_HEADERS
-extern char *strcpy ();
-extern int fflush ();
-#endif
-
-char *prognam;
-int debug;
-
-/*
- * Examine user's PATH and print a reasonable MANPATH.
- */
-int
-main(argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int quiet;
- char *mp;
- extern int getopt ();
- extern char *mkprogname ();
- void usage ();
- char *manpath ();
-
- quiet = 1;
-
- prognam = mkprogname (argv[0]);
-
- while ((c = getopt (argc, argv, "dhq?")) != EOF)
- {
- switch (c)
- {
- case 'd':
- debug++;
- break;
- case 'q':
- quiet = 0;
- break;
- case '?':
- case 'h':
- default:
- usage();
- break;
- }
- }
-
- mp = manpath (quiet);
-
- fprintf (stdout, "%s\n", mp);
- fflush (stdout);
-
- return 0;
-}
-
-void
-usage ()
-{
- fprintf (stderr, "usage: %s [-q]\n", prognam);
- exit (1);
-}
-#endif /* MAIN */
-
-/*
- * If the environment variable MANPATH is set, return it.
- * If the environment variable PATH is set and has a nonzero length,
- * try to determine the corresponding manpath, otherwise, return the
- * default manpath.
- *
- * The manpath.config file is used to map system wide /bin directories
- * to top level man page directories.
- *
- * For directories which are in the user's path but not in the
- * manpath.config file, see if there is a subdirectory `man' or `MAN'.
- * If so, add that directory to the path. Example: user has
- * $HOME/bin in his path and the directory $HOME/bin/man exists -- the
- * directory $HOME/bin/man will be added to the manpath.
- */
-char *
-manpath (perrs)
- register int perrs;
-{
- register int len;
- register char *manpathlist;
- register char *path;
- int get_dirlist ();
- char *def_path ();
- char *get_manpath ();
-
- if (get_dirlist ())
- gripe_reading_mp_config (config_file);
-
- if ((manpathlist = getenv ("MANPATH")) != NULL)
- /*
- * This must be it.
- */
- {
- if (perrs)
- fprintf (stderr, "(Warning: MANPATH environment variable set)\n");
- return strdup (manpathlist);
- }
- else if ((path = getenv ("PATH")) == NULL)
- /*
- * Things aren't going to work well, but hey...
- */
- {
- if (perrs)
- fprintf (stderr, "Warning: path not set\n");
- return def_path (perrs);
- }
- else
- {
- if ((len = strlen (path)) == 0)
- /*
- * Things aren't going to work well here either...
- */
- {
- if (perrs)
- fprintf (stderr, "Warning: path set but has zero length\n");
- return def_path (perrs);
- }
- return get_manpath (perrs, path);
- }
-}
-
-/*
- * Get the list of bin directories and the corresponding man
- * directories from the manpath.config file.
- *
- * This is ugly.
- */
-int
-get_dirlist ()
-{
- int i;
- char *bp;
- char *p;
- char buf[BUFSIZ];
- DIRLIST *dlp = list;
- FILE *config;
-
- if ((config = fopen (config_file, "r")) == NULL)
- gripe_getting_mp_config (config_file);
-
- while ((bp = fgets (buf, BUFSIZ, config)) != NULL)
- {
- while (*bp && (*bp == ' ' || *bp == '\t'))
- bp++;
-
- if (*bp == '#' || *bp == '\n')
- continue;
-
- if (!strncmp ("MANBIN", bp, 6))
- continue;
-
- if (!strncmp ("MANDATORY_MANPATH", bp, 17))
- {
- if ((p = strchr (bp, ' ')) == NULL &&
- (p = strchr (bp, '\t')) == NULL) {
- fclose(config);
- return -1;
- }
-
- bp = p;
-
- dlp->mandatory = 1;
-
- while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
- bp++;
-
- i = 0;
- while (*bp && *bp != '\n' && *bp != ' ' && *bp != '\t')
- dlp->mandir[i++] = *bp++;
- dlp->mandir[i] = '\0';
-
- if (debug)
- fprintf (stderr, "found mandatory man directory %s\n",
- dlp->mandir);
- }
- else if (!strncmp ("MANPATH_MAP", bp, 11))
- {
- if ((p = strchr (bp, ' ')) == NULL &&
- (p = strchr (bp, '\t')) == NULL) {
- fclose(config);
- return -1;
- }
-
- bp = p;
-
- dlp->mandatory = 0;
-
- while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
- bp++;
-
- i = 0;
- while (*bp && *bp != '\n' && *bp != ' ' && *bp != '\t')
- dlp->bin[i++] = *bp++;
- dlp->bin[i] = '\0';
-
- while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
- bp++;
-
- i = 0;
- while (*bp && *bp != '\n' && *bp != ' ' && *bp != '\t')
- dlp->mandir[i++] = *bp++;
- dlp->mandir[i] = '\0';
-
- if (debug)
- fprintf (stderr, "found manpath map %s --> %s\n",
- dlp->bin, dlp->mandir);
- }
- else
- {
- gripe_reading_mp_config (config_file);
- }
- dlp++;
- }
-
- fclose(config);
- dlp->bin[0] = '\0';
- dlp->mandir[0] = '\0';
- dlp->mandatory = 0;
-
- return 0;
-}
-
-/*
- * Construct the default manpath. This picks up mandatory manpaths
- * only.
- */
-char *
-def_path (perrs)
- int perrs;
-{
- register int len;
- register char *manpathlist, *p;
- register DIRLIST *dlp;
-
- len = 0;
- dlp = list;
- while (dlp->mandatory != 0)
- {
- len += strlen (dlp->mandir) + 1;
- dlp++;
- }
-
- manpathlist = (char *) malloc (len);
- if (manpathlist == NULL)
- gripe_alloc (len, "manpathlist");
-
- *manpathlist = '\0';
-
- dlp = list;
- p = manpathlist;
- while (dlp->mandatory != 0)
- {
- int status;
- char *path = dlp->mandir;
-
- status = is_directory(path);
-
- if (status < 0 && perrs)
- {
- fprintf (stderr, "Warning: couldn't stat file %s!\n", path);
- }
- else if (status == 0 && perrs)
- {
- fprintf (stderr, "Warning: standard directory %s doesn't exist!\n",
- path);
- }
- else if (status == 1)
- {
- len = strlen (path);
- memcpy (p, path, len);
- p += len;
- *p++ = ':';
- dlp++;
- }
- }
-
- p[-1] = '\0';
-
- return manpathlist;
-}
-
-/*
- * For each directory in the user's path, see if it is one of the
- * directories listed in the manpath.config file. If so, and it is
- * not already in the manpath, add it. If the directory is not listed
- * in the manpath.config file, see if there is a subdirectory `man' or
- * `MAN'. If so, and it is not already in the manpath, add it.
- * Example: user has $HOME/bin in his path and the directory
- * $HOME/bin/man exists -- the directory $HOME/bin/man will be added
- * to the manpath.
- */
-char *
-get_manpath (perrs, path)
- register int perrs;
- register char *path;
-{
- register int len;
- register char *tmppath;
- register char *t;
- register char *p;
- register char **lp;
- register char *end;
- register char *manpathlist;
- register DIRLIST *dlp;
- void add_dir_to_list ();
- char *has_subdirs ();
-
- tmppath = strdup (path);
-
- for (p = tmppath; ; p = end+1)
- {
- if (end = strchr(p, ':'))
- *end = '\0';
-
- if (debug)
- fprintf (stderr, "\npath directory %s ", p);
-
- /*
- * The directory we're working on is in the config file.
- * If we haven't added it to the list yet, do.
- */
- for (dlp = list; dlp->mandir[0] != '\0'; dlp++)
- if (dlp->bin[0] != '\0' && !strcmp (p, dlp->bin))
- {
- if (debug)
- fprintf (stderr, "is in the config file\n");
-
- add_dir_to_list (tmplist, dlp->mandir, perrs);
- goto found;
- }
-
- /*
- * The directory we're working on isn't in the config file. See
- * if it has man or MAN subdirectories. If so, and it hasn't
- * been added to the list, do.
- */
- if (debug)
- fprintf (stderr, "is not in the config file\n");
-
- t = has_subdirs (p);
- if (t != NULL)
- {
- if (debug)
- fprintf (stderr, "but it does have a man or MAN subdirectory\n");
-
- add_dir_to_list (tmplist, t, perrs);
- free (t);
- }
- else
- {
- if (debug)
- fprintf (stderr, "and doesn't have man or MAN subdirectories\n");
- }
-
- found:
-
- if (!end)
- break;
- }
-
- if (debug)
- fprintf (stderr, "\nadding mandatory man directories\n\n");
-
- dlp = list;
- while (dlp->mandatory != 0)
- {
- add_dir_to_list (tmplist, dlp->mandir, perrs);
- dlp++;
- }
-
- len = 0;
- lp = tmplist;
- while (*lp != NULL)
- {
- len += strlen (*lp) + 1;
- lp++;
- }
-
- manpathlist = (char *) malloc (len);
- if (manpathlist == NULL)
- gripe_alloc (len, "manpathlist");
-
- *manpathlist = '\0';
-
- lp = tmplist;
- p = manpathlist;
- while (*lp != NULL)
- {
- len = strlen (*lp);
- memcpy (p, *lp, len);
- p += len;
- *p++ = ':';
- lp++;
- }
-
- p[-1] = '\0';
-
- return manpathlist;
-}
-
-/*
- * Add a directory to the manpath list if it isn't already there.
- */
-void
-add_dir_to_list (lp, dir, perrs)
- char **lp;
- char *dir;
- int perrs;
-{
- extern char *strdup ();
- int status;
-
- while (*lp != NULL)
- {
- if (!strcmp (*lp, dir))
- {
- if (debug)
- fprintf (stderr, "%s is already in the manpath\n", dir);
- return;
- }
- lp++;
- }
- /*
- * Not found -- add it.
- */
- status = is_directory(dir);
-
- if (status < 0 && perrs)
- {
- fprintf (stderr, "Warning: couldn't stat file %s!\n", dir);
- }
- else if (status == 0 && perrs)
- {
- fprintf (stderr, "Warning: %s isn't a directory!\n", dir);
- }
- else if (status == 1)
- {
- if (debug)
- fprintf (stderr, "adding %s to manpath\n", dir);
-
- *lp = strdup (dir);
- }
-}
-
-/*
- * Check to see if the current directory has man or MAN
- * subdirectories.
- */
-char *
-has_subdirs (p)
- register char *p;
-{
- int len;
- register char *t;
-
- len = strlen (p);
-
- t = (char *) malloc ((unsigned) len + 5);
- if (t == NULL)
- gripe_alloc (len+5, "p\n");
-
- memcpy (t, p, len);
- strcpy (t + len, "/man");
-
- if (is_directory (t) == 1)
- return t;
-
- strcpy (t + len, "/MAN");
-
- if (is_directory (t) == 1)
- return t;
-
- return NULL;
-}
diff --git a/gnu/usr.bin/man/manpath/manpath.config b/gnu/usr.bin/man/manpath/manpath.config
deleted file mode 100644
index 64be439..0000000
--- a/gnu/usr.bin/man/manpath/manpath.config
+++ /dev/null
@@ -1,28 +0,0 @@
-# manpath.config
-#
-# This file is read by manpath to configure the mandatory manpath, to
-# map each path element to a manpath element and to determine where the
-# "man" binary lives. The format is:
-#
-# MANBIN pathname
-# MANDATORY_MANPATH manpath_element
-# MANPATH_MAP path_element manpath_element
-#
-# MANBIN is optional
-#
-#MANBIN /usr/local/bin/man
-#
-# every automatically generated MANPATH includes these fields
-#
-MANDATORY_MANPATH /usr/share/man
-MANDATORY_MANPATH /usr/local/man
-#MANDATORY_MANPATH /usr/X386/man
-MANDATORY_MANPATH /usr/X11R6/man
-#
-# set up PATH to MANPATH mapping
-#
-MANPATH_MAP /bin /usr/share/man
-MANPATH_MAP /usr/bin /usr/share/man
-MANPATH_MAP /usr/local/bin /usr/local/man
-#MANPATH_MAP /usr/X386/bin /usr/X386/man
-MANPATH_MAP /usr/X11R6/bin /usr/X11R6/man
diff --git a/gnu/usr.bin/man/manpath/manpath.h b/gnu/usr.bin/man/manpath/manpath.h
deleted file mode 100644
index 3039bd9..0000000
--- a/gnu/usr.bin/man/manpath/manpath.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * manpath.h
- *
- * Copyright (c) 1990, 1991, John W. Eaton.
- *
- * You may distribute under the terms of the GNU General Public
- * License as specified in the file COPYING that comes with the man
- * distribution.
- *
- * John W. Eaton
- * jwe@che.utexas.edu
- * Department of Chemical Engineering
- * The University of Texas at Austin
- * Austin, Texas 78712
- */
-
-typedef struct
-{
- char mandir[MAXPATHLEN];
- char bin[MAXPATHLEN];
- int mandatory;
-} DIRLIST;
-
-DIRLIST list[MAXDIRS];
-
-char *tmplist[MAXDIRS];
diff --git a/gnu/usr.bin/man/manpath/manpath.man b/gnu/usr.bin/man/manpath/manpath.man
deleted file mode 100644
index 3a80dbc..0000000
--- a/gnu/usr.bin/man/manpath/manpath.man
+++ /dev/null
@@ -1,67 +0,0 @@
-.\" Man page for manpath
-.\"
-.\" Copyright (c) 1990, 1991, John W. Eaton.
-.\"
-.\" You may distribute under the terms of the GNU General Public
-.\" License as specified in the README file that comes with the man 1.0
-.\" distribution.
-.\"
-.\" John W. Eaton
-.\" jwe@che.utexas.edu
-.\" Department of Chemical Engineering
-.\" The University of Texas at Austin
-.\" Austin, Texas 78712
-.\"
-.Dd Jan 5, 1991
-.Dt MANPATH 1
-.Os
-.Sh NAME
-.Nm manpath
-.Nd determine user's search path for man pages
-.Sh SYNOPSIS
-.Nm
-.Op Fl q
-.Sh DESCRIPTION
-.Nm manpath
-tries to determine the user's manpath from a set of system
-defaults and the user's
-.Ev PATH ,
-echoing the result to the standard output. Warnings and errors are
-written to the standard error.
-If a directory in the user's path is not listed in the manpath.config
-file, manpath looks for the subdirectories man or MAN. If they exist,
-they are added to the search path.
-.Pp
-.Nm
-is used by
-.Nm man
-to determine the search path, so user's normally don't need to set the
-.Ev MANPATH
-environment variable directly.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl q
-Operate quietly. Only echo the final manpath.
-.El
-.Sh ENVIRONMENT
-.Bl -tag -width MANPATH -compact
-.It Ev MANPATH
-If
-.Ev MANPATH
-is set,
-.Nm manpath
-echoes its value on the standard output and issues a warning on the
-standard error.
-.El
-.Sh FILES
-.Bl -tag -width %manpath_config_file% -compact
-.It Pa %manpath_config_file%
-System configuration file.
-.El
-.Sh SEE ALSO
-.Xr apropos 1 ,
-.Xr whatis 1 ,
-.Xr man 1
-.Sh BUGS
-None known.
diff --git a/gnu/usr.bin/patch/Makefile b/gnu/usr.bin/patch/Makefile
deleted file mode 100644
index b744022..0000000
--- a/gnu/usr.bin/patch/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# $Id: Makefile,v 1.9 1997/10/29 17:35:54 ache Exp $
-
-.PATH: ${.CURDIR}/../../../contrib/patch
-
-PROG= patch
-
-LIBSRCS = getopt.c getopt1.c
-SRCS = addext.c argmatch.c backupfile.c basename.c inp.c maketime.c \
- partime.c patch.c pch.c quotearg.c util.c version.c $(LIBSRCS)
-
-CFLAGS+= -I${.CURDIR}
-CFLAGS+= -I${.CURDIR}/../../../contrib/patch
-CFLAGS+= -DHAVE_CONFIG_H
-CFLAGS+= -Ded_PROGRAM=\"/bin/ed\"
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/patch/config.h b/gnu/usr.bin/patch/config.h
deleted file mode 100644
index 54d3a4b..0000000
--- a/gnu/usr.bin/patch/config.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* config.hin. Generated automatically from configure.in by autoheader. */
-
-/* Define if on AIX 3.
- System headers sometimes define this.
- We just want to avoid a redefinition error message. */
-#ifndef _ALL_SOURCE
-/* #undef _ALL_SOURCE */
-#endif
-
-/* Define if the closedir function returns void instead of int. */
-/* #undef CLOSEDIR_VOID */
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define if you don't have vprintf but do have _doprnt. */
-/* #undef HAVE_DOPRNT */
-
-/* Define if you support file names longer than 14 characters. */
-#define HAVE_LONG_FILE_NAMES 1
-
-/* Define if you have the vprintf function. */
-#define HAVE_VPRINTF 1
-
-/* Define if on MINIX. */
-/* #undef _MINIX */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef mode_t */
-
-/* Define to `long' if <sys/types.h> doesn't define. */
-/* #undef off_t */
-
-/* Define if the system does not provide POSIX.1 features except
- with this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define if you need to in order for stat and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define as the return type of signal handlers (int or void). */
-#define RETSIGTYPE void
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-/* #undef size_t */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if there is a member named d_ino in the struct describing
- directory headers. */
-#define D_INO_IN_DIRENT 1
-
-/* Define if memchr works. */
-#define HAVE_MEMCHR 1
-
-/* Define if `struct utimbuf' is declared -- usually in <utime.h>. */
-#define HAVE_STRUCT_UTIMBUF 1
-
-/* Define if you have the _doprintf function. */
-/* #undef HAVE__DOPRINTF */
-
-/* Define if you have the isascii function. */
-#define HAVE_ISASCII 1
-
-/* Define if you have the memchr function. */
-#define HAVE_MEMCHR 1
-
-/* Define if you have the memcmp function. */
-#define HAVE_MEMCMP 1
-
-/* Define if you have the mkdir function. */
-#define HAVE_MKDIR 1
-
-/* Define if you have the mktemp function. */
-#define HAVE_MKTEMP 1
-
-/* Define if you have the pathconf function. */
-#define HAVE_PATHCONF 1
-
-/* Define if you have the raise function. */
-#define HAVE_RAISE 1
-
-/* Define if you have the rename function. */
-#define HAVE_RENAME 1
-
-/* Define if you have the sigaction function. */
-#define HAVE_SIGACTION 1
-
-/* Define if you have the sigprocmask function. */
-#define HAVE_SIGPROCMASK 1
-
-/* Define if you have the sigsetmask function. */
-#define HAVE_SIGSETMASK 1
-
-/* Define if you have the <dirent.h> header file. */
-#define HAVE_DIRENT_H 1
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <ndir.h> header file. */
-/* #undef HAVE_NDIR_H */
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <sys/dir.h> header file. */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define if you have the <sys/ndir.h> header file. */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the <utime.h> header file. */
-#define HAVE_UTIME_H 1
-
-/* Define if you have the <varargs.h> header file. */
-#define HAVE_VARARGS_H 1
diff --git a/gnu/usr.bin/patch/patchlevel.h b/gnu/usr.bin/patch/patchlevel.h
deleted file mode 100644
index 8a7559b..0000000
--- a/gnu/usr.bin/patch/patchlevel.h
+++ /dev/null
@@ -1 +0,0 @@
-#define PATCH_VERSION "2.5"
diff --git a/gnu/usr.bin/perl/Artistic b/gnu/usr.bin/perl/Artistic
deleted file mode 100644
index fbf7989..0000000
--- a/gnu/usr.bin/perl/Artistic
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
- The "Artistic License"
-
- Preamble
-
-The intent of this document is to state the conditions under which a
-Package may be copied, such that the Copyright Holder maintains some
-semblance of artistic control over the development of the package,
-while giving the users of the package the right to use and distribute
-the Package in a more-or-less customary fashion, plus the right to make
-reasonable modifications.
-
-Definitions:
-
- "Package" refers to the collection of files distributed by the
- Copyright Holder, and derivatives of that collection of files
- created through textual modification.
-
- "Standard Version" refers to such a Package if it has not been
- modified, or has been modified in accordance with the wishes
- of the Copyright Holder.
-
- "Copyright Holder" is whoever is named in the copyright or
- copyrights for the package.
-
- "You" is you, if you're thinking about copying or distributing
- this Package.
-
- "Reasonable copying fee" is whatever you can justify on the
- basis of media cost, duplication charges, time of people involved,
- and so on. (You will not be required to justify it to the
- Copyright Holder, but only to the computing community at large
- as a market that must bear the fee.)
-
- "Freely Available" means that no fee is charged for the item
- itself, though there may be fees involved in handling the item.
- It also means that recipients of the item may redistribute it
- under the same conditions they received it.
-
-1. You may make and give away verbatim copies of the source form of the
-Standard Version of this Package without restriction, provided that you
-duplicate all of the original copyright notices and associated disclaimers.
-
-2. You may apply bug fixes, portability fixes and other modifications
-derived from the Public Domain or from the Copyright Holder. A Package
-modified in such a way shall still be considered the Standard Version.
-
-3. You may otherwise modify your copy of this Package in any way, provided
-that you insert a prominent notice in each changed file stating how and
-when you changed that file, and provided that you do at least ONE of the
-following:
-
- a) place your modifications in the Public Domain or otherwise make them
- Freely Available, such as by posting said modifications to Usenet or
- an equivalent medium, or placing the modifications on a major archive
- site such as uunet.uu.net, or by allowing the Copyright Holder to include
- your modifications in the Standard Version of the Package.
-
- b) use the modified Package only within your corporation or organization.
-
- c) rename any non-standard executables so the names do not conflict
- with standard executables, which must also be provided, and provide
- a separate manual page for each non-standard executable that clearly
- documents how it differs from the Standard Version.
-
- d) make other distribution arrangements with the Copyright Holder.
-
-4. You may distribute the programs of this Package in object code or
-executable form, provided that you do at least ONE of the following:
-
- a) distribute a Standard Version of the executables and library files,
- together with instructions (in the manual page or equivalent) on where
- to get the Standard Version.
-
- b) accompany the distribution with the machine-readable source of
- the Package with your modifications.
-
- c) accompany any non-standard executables with their corresponding
- Standard Version executables, giving the non-standard executables
- non-standard names, and clearly documenting the differences in manual
- pages (or equivalent), together with instructions on where to get
- the Standard Version.
-
- d) make other distribution arrangements with the Copyright Holder.
-
-5. You may charge a reasonable copying fee for any distribution of this
-Package. You may charge any fee you choose for support of this Package.
-You may not charge a fee for this Package itself. However,
-you may distribute this Package in aggregate with other (possibly
-commercial) programs as part of a larger (possibly commercial) software
-distribution provided that you do not advertise this Package as a
-product of your own.
-
-6. The scripts and library files supplied as input to or produced as
-output from the programs of this Package do not automatically fall
-under the copyright of this Package, but belong to whomever generated
-them, and may be sold commercially, and may be aggregated with this
-Package.
-
-7. C subroutines supplied by you and linked into this Package in order
-to emulate subroutines and variables of the language defined by this
-Package shall not be considered part of this Package, but are the
-equivalent of input as in Paragraph 6, provided these subroutines do
-not change the language in any way that would cause it to fail the
-regression tests for the language.
-
-8. The name of the Copyright Holder may not be used to endorse or promote
-products derived from this software without specific prior written permission.
-
-9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
- The End
diff --git a/gnu/usr.bin/perl/Copying b/gnu/usr.bin/perl/Copying
deleted file mode 100644
index 3c68f02..0000000
--- a/gnu/usr.bin/perl/Copying
+++ /dev/null
@@ -1,248 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 1, February 1989
-
- Copyright (C) 1989 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The license agreements of most software companies try to keep users
-at the mercy of those companies. By contrast, our General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. The
-General Public License applies to the Free Software Foundation's
-software and to any other program whose authors commit to using it.
-You can use it for your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Specifically, the General Public License is designed to make
-sure that you have the freedom to give away or sell copies of free
-software, that you receive source code or can get it if you want it,
-that you can change the software or use pieces of it in new free
-programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of a such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must tell them their rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any program or other work which
-contains a notice placed by the copyright holder saying it may be
-distributed under the terms of this General Public License. The
-"Program", below, refers to any such program or work, and a "work based
-on the Program" means either the Program or any work containing the
-Program or a portion of it, either verbatim or with modifications. Each
-licensee is addressed as "you".
-
- 1. You may copy and distribute verbatim copies of the Program's source
-code as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice and
-disclaimer of warranty; keep intact all the notices that refer to this
-General Public License and to the absence of any warranty; and give any
-other recipients of the Program a copy of this General Public License
-along with the Program. You may charge a fee for the physical act of
-transferring a copy.
-
- 2. You may modify your copy or copies of the Program or any portion of
-it, and copy and distribute such modifications under the terms of Paragraph
-1 above, provided that you also do the following:
-
- a) cause the modified files to carry prominent notices stating that
- you changed the files and the date of any change; and
-
- b) cause the whole of any work that you distribute or publish, that
- in whole or in part contains the Program or any part thereof, either
- with or without modifications, to be licensed at no charge to all
- third parties under the terms of this General Public License (except
- that you may choose to grant warranty protection to some or all
- third parties, at your option).
-
- c) If the modified program normally reads commands interactively when
- run, you must cause it, when started running for such interactive use
- in the simplest and most usual way, to print or display an
- announcement including an appropriate copyright notice and a notice
- that there is no warranty (or else, saying that you provide a
- warranty) and that users may redistribute the program under these
- conditions, and telling the user how to view a copy of this General
- Public License.
-
- d) You may charge a fee for the physical act of transferring a
- copy, and you may at your option offer warranty protection in
- exchange for a fee.
-
-Mere aggregation of another independent work with the Program (or its
-derivative) on a volume of a storage or distribution medium does not bring
-the other work under the scope of these terms.
-
- 3. You may copy and distribute the Program (or a portion or derivative of
-it, under Paragraph 2) in object code or executable form under the terms of
-Paragraphs 1 and 2 above provided that you also do one of the following:
-
- a) accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of
- Paragraphs 1 and 2 above; or,
-
- b) accompany it with a written offer, valid for at least three
- years, to give any third party free (except for a nominal charge
- for the cost of distribution) a complete machine-readable copy of the
- corresponding source code, to be distributed under the terms of
- Paragraphs 1 and 2 above; or,
-
- c) accompany it with the information you received as to where the
- corresponding source code may be obtained. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form alone.)
-
-Source code for a work means the preferred form of the work for making
-modifications to it. For an executable file, complete source code means
-all the source code for all modules it contains; but, as a special
-exception, it need not include source code for modules which are standard
-libraries that accompany the operating system on which the executable
-file runs, or for standard header files or definitions files that
-accompany that operating system.
-
- 4. You may not copy, modify, sublicense, distribute or transfer the
-Program except as expressly provided under this General Public License.
-Any attempt otherwise to copy, modify, sublicense, distribute or transfer
-the Program is void, and will automatically terminate your rights to use
-the Program under this License. However, parties who have received
-copies, or rights to use copies, from you under this General Public
-License will not have their licenses terminated so long as such parties
-remain in full compliance.
-
- 5. By copying, distributing or modifying the Program (or any work based
-on the Program) you indicate your acceptance of this license to do so,
-and all its terms and conditions.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the original
-licensor to copy, distribute or modify the Program subject to these
-terms and conditions. You may not impose any further restrictions on the
-recipients' exercise of the rights granted herein.
-
- 7. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of the license which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-the license, you may choose any version ever published by the Free Software
-Foundation.
-
- 8. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to humanity, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these
-terms.
-
- To do so, attach the following notices to the program. It is safest to
-attach them to the start of each source file to most effectively convey
-the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19xx name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the
-appropriate parts of the General Public License. Of course, the
-commands you use may be called something other than `show w' and `show
-c'; they could even be mouse-clicks or menu items--whatever suits your
-program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- program `Gnomovision' (a program to direct compilers to make passes
- at assemblers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/gnu/usr.bin/perl/Makefile b/gnu/usr.bin/perl/Makefile
deleted file mode 100644
index 385033a..0000000
--- a/gnu/usr.bin/perl/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# Bmake file for perl 4.036
-#
-# Note: I'm not sure what to do with c2ph located in misc...
-#
-
-SUBDIR= perl tperl sperl usub lib x2p
-
-.include <bsd.subdir.mk>
-
diff --git a/gnu/usr.bin/perl/README b/gnu/usr.bin/perl/README
deleted file mode 100644
index c52c7f4..0000000
--- a/gnu/usr.bin/perl/README
+++ /dev/null
@@ -1,195 +0,0 @@
-
- Perl Kit, Version 4.0
-
- Copyright (c) 1989,1990,1991, Larry Wall
- All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of either:
-
- a) the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any
- later version, or
-
- b) the "Artistic License" which comes with this Kit.
-
- 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 either
- the GNU General Public License or the Artistic License for more details.
-
- You should have received a copy of the Artistic License with this
- Kit, in the file named "Artistic". If not, I'll be glad to provide one.
-
- You should also 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.
-
- For those of you that choose to use the GNU General Public License,
- my interpretation of the GNU General Public License is that no Perl
- script falls under the terms of the GPL unless you explicitly put
- said script under the terms of the GPL yourself. Furthermore, any
- object code linked with uperl.o does not automatically fall under the
- terms of the GPL, provided such object code only adds definitions
- of subroutines and variables, and does not otherwise impair the
- resulting interpreter from executing any standard Perl script. I
- consider linking in C subroutines in this manner to be the moral
- equivalent of defining subroutines in the Perl language itself. You
- may sell such an object file as proprietary provided that you provide
- or offer to provide the Perl source, as specified by the GNU General
- Public License. (This is merely an alternate way of specifying input
- to the program.) You may also sell a binary produced by the dumping of
- a running Perl script that belongs to you, provided that you provide or
- offer to provide the Perl source as specified by the GPL. (The
- fact that a Perl interpreter and your code are in the same binary file
- is, in this case, a form of mere aggregation.) This is my interpretation
- of the GPL. If you still have concerns or difficulties understanding
- my intent, feel free to contact me. Of course, the Artistic License
- spells all this out for your protection, so you may prefer to use that.
-
---------------------------------------------------------------------------
-
-Perl is a language that combines some of the features of C, sed, awk and shell.
-See the manual page for more hype. There's also a Nutshell Handbook published
-by O'Reilly & Assoc. Their U.S. number is 1-800-338-6887 (dev-nuts) and
-their international number is 1-707-829-0515. E-mail to nuts@ora.com.
-
-Perl will probably not run on machines with a small address space.
-
-Please read all the directions below before you proceed any further, and
-then follow them carefully.
-
-After you have unpacked your kit, you should have all the files listed
-in MANIFEST.
-
-Installation
-
-1) Run Configure. This will figure out various things about your system.
- Some things Configure will figure out for itself, other things it will
- ask you about. It will then proceed to make config.h, config.sh, and
- Makefile. If you're a hotshot, run Configure -d to take all the
- defaults and then edit config.sh to patch up any flaws.
-
- You might possibly have to trim # comments from the front of Configure
- if your sh doesn't handle them, but all other # comments will be taken
- care of.
-
- (If you don't have sh, you'll have to copy the sample file config.H to
- config.h and edit the config.h to reflect your system's peculiarities.)
-
-2) Glance through config.h to make sure system dependencies are correct.
- Most of them should have been taken care of by running the Configure script.
-
- If you have any additional changes to make to the C definitions, they
- can be done in cflags.SH. For instance, to turn off the optimizer
- on eval.c, find the line in the switch structure for eval.c and
- put the command $optimize='-g' before the ;;. You will probably
- want to change the entry for teval.c too. To change the C flags
- for all the files, edit config.sh and change either $ccflags or $optimize.
-
-3) make depend
-
- This will look for all the includes and modify Makefile accordingly.
- Configure will offer to do this for you.
-
-4) make
-
- This will attempt to make perl in the current directory.
-
- If you can't compile successfully, try adding a -DCRIPPLED_CC flag.
- (Just because you get no errors doesn't mean it compiled right!)
- This simplifies some complicated expressions for compilers that
- get indigestion easily. If that has no effect, try turning off
- optimization. If you have missing routines, you probably need to
- add some library or other, or you need to undefine some feature that
- Configure thought was there but is defective or incomplete.
-
- Some compilers will not compile or optimize the larger files without
- some extra switches to use larger jump offsets or allocate larger
- internal tables. You can customize the switches for each file in
- cflags.SH. It's okay to insert rules for specific files into
- Makefile.SH, since a default rule only takes effect in the
- absence of a specific rule.
-
- Most of the following hints are now done automatically by Configure.
-
- The 3b2 needs to turn off -O.
- Compilers with limited switch tables may have to define -DSMALLSWITCHES
- Domain/OS 10.3 (at least) native C 6.7 may need -opt 2 for eval.c
- AIX/RT may need a -a switch and -DCRIPPLED_CC.
- AIX RS/6000 needs to use system malloc and avoid -O on eval.c and toke.c.
- AIX RS/6000 needs -D_NO_PROTO.
- SUNOS 4.0.[12] needs -DFPUTS_BOTCH.
- SUNOS 3.[45] should use the system malloc.
- SGI machines may need -Ddouble="long float" and -O1.
- Vax-based systems may need to hand assemble teval.s with a -J switch.
- Ultrix on MIPS machines may need -DLANGUAGE_C.
- Ultrix 4.0 on MIPS machines may need -Olimit 2900 or so.
- Ultrix 3.[01] on MIPS needs to undefine WAITPID--the system call is busted.
- MIPS machines need /bin before /bsd43/bin in PATH.
- MIPS machines may need to undef d_volatile.
- MIPS machines may need to turn off -O on cmd.c, perl.c and tperl.c.
- Some MIPS machines may need to undefine CASTNEGFLOAT.
- Xenix 386 needs -Sm11000 for yacc, and may need -UM_I86.
- SCO Xenix may need -m25000 for yacc. See also README.xenix.
- Genix needs to use libc rather than libc_s, or #undef VARARGS.
- NCR Tower 32 (OS 2.01.01) may need -W2,-Sl,2000 and #undef MKDIR.
- A/UX may appears to work with -O -B/usr/lib/big/ optimizer flags.
- A/UX needs -lposix to find rewinddir.
- A/UX may need -ZP -DPOSIX, and -g if big cc is used.
- FPS machines may need -J and -DBADSWITCH.
- UTS may need one or more of -DCRIPPLED_CC, -K or -g, and undef LSTAT.
- dynix may need to undefine CASTNEGFLOAT (d_castneg='undef' in config.sh).
- Dnix (not dynix) may need to remove -O.
- IRIX 3.3 may need to undefine VFORK.
- HP/UX may need to pull cerror.o and syscall.o out of libc.a and link
- them in explicitly.
- If you get syntax errors on '(', try -DCRIPPLED_CC or -DBADSWITCH or both.
- Machines with half-implemented dbm routines will need to #undef ODBM & NDBM.
- If you have GDBM available and want it instead of NDBM, say -DHAS_GDBM.
- C's that don't try to restore registers on longjmp() may need -DJMPCLOBBER.
- (Try this if you get random glitches.)
- If you get duplicates upon linking for malloc et al, say -DHIDEMYMALLOC.
- Turn on support for 64-bit integers (long longs) with -DQUAD.
-
-5) make test
-
- This will run the regression tests on the perl you just made.
- If it doesn't say "All tests successful" then something went wrong.
- See the README in the t subdirectory. Note that you can't run it
- in background if this disables opening of /dev/tty. If "make test"
- bombs out, just cd to the t directory and run TEST by hand to see if
- it makes any difference. If individual tests bomb, you can run
- them by hand, e.g., ./perl op/groups.t
-
-6) make install
-
- This will put perl into a public directory (such as /usr/local/bin).
- It will also try to put the man pages in a reasonable place. It will not
- nroff the man page, however. You may need to be root to do this. If
- you are not root, you must own the directories in question and you should
- ignore any messages about chown not working.
-
-7) Read the manual entry before running perl.
-
-8) IMPORTANT! Help save the world! Communicate any problems and suggested
- patches to me, lwall@netlabs.com (Larry Wall), so we can
- keep the world in sync. If you have a problem, there's someone else
- out there who either has had or will have the same problem.
-
- If possible, send in patches such that the patch program will apply them.
- Context diffs are the best, then normal diffs. Don't send ed scripts--
- I've probably changed my copy since the version you have. It's also
- helpful if you send the output of "uname -a".
-
- Watch for perl patches in comp.lang.perl. Patches will generally be
- in a form usable by the patch program. If you are just now bringing up
- perl and aren't sure how many patches there are, write to me and I'll
- send any you don't have. Your current patch level is shown in patchlevel.h.
-
-
-Just a personal note: I want you to know that I create nice things like this
-because it pleases the Author of my story. If this bothers you, then your
-notion of Authorship needs some revision. But you can use perl anyway. :-)
-
- The author.
diff --git a/gnu/usr.bin/perl/VERSION b/gnu/usr.bin/perl/VERSION
deleted file mode 100644
index 2b80880..0000000
--- a/gnu/usr.bin/perl/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-Perl 4.0 patchlevel 36
diff --git a/gnu/usr.bin/perl/Wishlist b/gnu/usr.bin/perl/Wishlist
deleted file mode 100644
index 3290834..0000000
--- a/gnu/usr.bin/perl/Wishlist
+++ /dev/null
@@ -1,9 +0,0 @@
-built-in cpp
-perl to C translator
-multi-threading
-make more easily embeddable
-built-in globbing
-compile to threaded code
-rewrite regexp parser for better integrated optimization
-add structured types and objects
-allow for lexical scoping
diff --git a/gnu/usr.bin/perl/eg/ADB b/gnu/usr.bin/perl/eg/ADB
deleted file mode 100644
index 09b93c3..0000000
--- a/gnu/usr.bin/perl/eg/ADB
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/ADB,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-
-# This script is only useful when used in your crash directory.
-
-$num = shift;
-exec 'adb', '-k', "vmunix.$num", "vmcore.$num";
diff --git a/gnu/usr.bin/perl/eg/README b/gnu/usr.bin/perl/eg/README
deleted file mode 100644
index 87cfc33..0000000
--- a/gnu/usr.bin/perl/eg/README
+++ /dev/null
@@ -1,22 +0,0 @@
-Although supplied with the perl package, the perl scripts in this eg
-directory and its subdirectories are placed in the public domain, and
-you may do anything with them that you wish.
-
-This stuff is supplied on an as-is basis--little attempt has been made to make
-any of it portable. It's mostly here to give you an idea of what perl code
-looks like, and what tricks and idioms are used.
-
-System administrators responsible for many computers will enjoy the items
-down in the g directory very much. The scan directory contains the beginnings
-of a system to check on and report various kinds of anomalies.
-
-If you machine doesn't support #!, the first thing you'll want to do is
-replace the #! with a couple of lines that look like this:
-
- eval "exec /usr/bin/perl -S $0 $*"
- if $running_under_some_shell;
-
-being sure to include any flags that were on the #! line. A supplied script
-called "nih" will translate perl scripts in place for you:
-
- nih g/g??
diff --git a/gnu/usr.bin/perl/eg/changes b/gnu/usr.bin/perl/eg/changes
deleted file mode 100644
index 9835e1b..0000000
--- a/gnu/usr.bin/perl/eg/changes
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/perl -P
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/changes,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-
-($dir, $days) = @ARGV;
-$dir = '/' if $dir eq '';
-$days = '14' if $days eq '';
-
-# Masscomps do things differently from Suns
-
-#if defined(mc300) || defined(mc500) || defined(mc700)
-open(Find, "find $dir -mtime -$days -print |") ||
- die "changes: can't run find";
-#else
-open(Find, "find $dir \\( -fstype nfs -prune \\) -o -mtime -$days -ls |") ||
- die "changes: can't run find";
-#endif
-
-while (<Find>) {
-
-#if defined(mc300) || defined(mc500) || defined(mc700)
- $x = `/bin/ls -ild $_`;
- $_ = $x;
- ($inode,$perm,$links,$owner,$group,$size,$month,$day,$time,$name)
- = split(' ');
-#else
- ($inode,$blocks,$perm,$links,$owner,$group,$size,$month,$day,$time,$name)
- = split(' ');
-#endif
-
- printf("%10s%3s %-8s %-8s%9s %3s %2s %s\n",
- $perm,$links,$owner,$group,$size,$month,$day,$name);
-}
-
diff --git a/gnu/usr.bin/perl/eg/client b/gnu/usr.bin/perl/eg/client
deleted file mode 100644
index 5900c90..0000000
--- a/gnu/usr.bin/perl/eg/client
+++ /dev/null
@@ -1,34 +0,0 @@
-#!./perl
-
-$pat = 'S n C4 x8';
-$inet = 2;
-$echo = 7;
-$smtp = 25;
-$nntp = 119;
-$test = 2345;
-
-$SIG{'INT'} = 'dokill';
-
-$this = pack($pat,$inet,0, 128,149,13,43);
-$that = pack($pat,$inet,$test,127,0,0,1);
-
-if (socket(S,2,1,6)) { print "socket ok\n"; } else { die $!; }
-if (bind(S,$this)) { print "bind ok\n"; } else { die $!; }
-if (connect(S,$that)) { print "connect ok\n"; } else { die $!; }
-
-select(S); $| = 1; select(stdout);
-
-if ($child = fork) {
- while (<STDIN>) {
- print S;
- }
- sleep 3;
- do dokill();
-}
-else {
- while (<S>) {
- print;
- }
-}
-
-sub dokill { kill 9,$child if $child; }
diff --git a/gnu/usr.bin/perl/eg/down b/gnu/usr.bin/perl/eg/down
deleted file mode 100644
index bbb0d06..0000000
--- a/gnu/usr.bin/perl/eg/down
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-
-$| = 1;
-if ($#ARGV >= 0) {
- $cmd = join(' ',@ARGV);
-}
-else {
- print "Command: ";
- $cmd = <stdin>;
- chop($cmd);
- while ($cmd =~ s/\\$//) {
- print "+ ";
- $cmd .= <stdin>;
- chop($cmd);
- }
-}
-$cwd = `pwd`; chop($cwd);
-
-open(FIND,'find . -type d -print|') || die "Can't run find";
-
-while (<FIND>) {
- chop;
- unless (chdir $_) {
- print stderr "Can't cd to $_\n";
- next;
- }
- print "\t--> ",$_,"\n";
- system $cmd;
- chdir $cwd;
-}
diff --git a/gnu/usr.bin/perl/eg/dus b/gnu/usr.bin/perl/eg/dus
deleted file mode 100644
index 94c648b..0000000
--- a/gnu/usr.bin/perl/eg/dus
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/dus,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-
-# This script does a du -s on any directories in the current directory that
-# are not mount points for another filesystem.
-
-($mydev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('.');
-
-open(ls,'ls -F1|');
-
-while (<ls>) {
- chop;
- next unless s|/$||;
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat($_);
- next unless $dev == $mydev;
- push(@ary,$_);
-}
-
-exec 'du', '-s', @ary;
diff --git a/gnu/usr.bin/perl/eg/findcp b/gnu/usr.bin/perl/eg/findcp
deleted file mode 100644
index 47e4438..0000000
--- a/gnu/usr.bin/perl/eg/findcp
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/findcp,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-
-# This is a wrapper around the find command that pretends find has a switch
-# of the form -cp host:destination. It presumes your find implements -ls.
-# It uses tar to do the actual copy. If your tar knows about the I switch
-# you may prefer to use findtar, since this one has to do the tar in batches.
-
-sub copy {
- `tar cf - $list | rsh $desthost cd $destdir '&&' tar xBpf -`;
-}
-
-$sourcedir = $ARGV[0];
-if ($sourcedir =~ /^\//) {
- $ARGV[0] = '.';
- unless (chdir($sourcedir)) { die "Can't find directory $sourcedir: $!"; }
-}
-
-$args = join(' ',@ARGV);
-if ($args =~ s/-cp *([^ ]+)/-ls/) {
- $dest = $1;
- if ($dest =~ /(.*):(.*)/) {
- $desthost = $1;
- $destdir = $2;
- }
- else {
- die "Malformed destination--should be host:directory";
- }
-}
-else {
- die("No destination specified");
-}
-
-open(find,"find $args |") || die "Can't run find for you: $!";
-
-while (<find>) {
- @x = split(' ');
- if ($x[2] =~ /^d/) { next;}
- chop($filename = $x[10]);
- if (length($list) > 5000) {
- do copy();
- $list = '';
- }
- else {
- $list .= ' ';
- }
- $list .= $filename;
-}
-
-if ($list) {
- do copy();
-}
diff --git a/gnu/usr.bin/perl/eg/findtar b/gnu/usr.bin/perl/eg/findtar
deleted file mode 100644
index a60f10f..0000000
--- a/gnu/usr.bin/perl/eg/findtar
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/findtar,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-
-# findtar takes find-style arguments and spits out a tarfile on stdout.
-# It won't work unless your find supports -ls and your tar the I flag.
-
-$args = join(' ',@ARGV);
-open(find,"/usr/bin/find $args -ls |") || die "Can't run find for you.";
-
-open(tar,"| /bin/tar cIf - -") || die "Can't run tar for you: $!";
-
-while (<find>) {
- @x = split(' ');
- if ($x[2] =~ /^d/) { print tar '-d ';}
- print tar $x[10],"\n";
-}
diff --git a/gnu/usr.bin/perl/eg/g/gcp b/gnu/usr.bin/perl/eg/g/gcp
deleted file mode 100644
index 3e44a9c..0000000
--- a/gnu/usr.bin/perl/eg/g/gcp
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/g/gcp,v 1.1.1.1 1993/08/23 21:29:44 nate Exp $
-
-# Here is a script to do global rcps. See man page.
-
-$#ARGV >= 1 || die "Not enough arguments.\n";
-
-if ($ARGV[0] eq '-r') {
- $rcp = 'rcp -r';
- shift;
-} else {
- $rcp = 'rcp';
-}
-$args = $rcp;
-$dest = $ARGV[$#ARGV];
-
-$SIG{'QUIT'} = 'CLEANUP';
-$SIG{'INT'} = 'CONT';
-
-while ($arg = shift) {
- if ($arg =~ /^([-a-zA-Z0-9_+]+):/) {
- if ($systype && $systype ne $1) {
- die "Can't mix system type specifers ($systype vs $1).\n";
- }
- $#ARGV < 0 || $arg !~ /:$/ || die "No source file specified.\n";
- $systype = $1;
- $args .= " $arg";
- } else {
- if ($#ARGV >= 0) {
- if ($arg =~ /^[\/~]/) {
- $arg =~ /^(.*)\// && ($dir = $1);
- } else {
- if (!$pwd) {
- chop($pwd = `pwd`);
- }
- $dir = $pwd;
- }
- }
- if ($olddir && $dir ne $olddir && $dest =~ /:$/) {
- $args .= " $dest$olddir; $rcp";
- }
- $olddir = $dir;
- $args .= " $arg";
- }
-}
-
-die "No system type specified.\n" unless $systype;
-
-$args =~ s/:$/:$olddir/;
-
-chop($thishost = `hostname`);
-
-$one_of_these = ":$systype:";
-if ($systype =~ s/\+/[+]/g) {
- $one_of_these =~ s/\+/:/g;
-}
-$one_of_these =~ s/-/:-/g;
-
-@ARGV = ();
-push(@ARGV,'.grem') if -f '.grem';
-push(@ARGV,'.ghosts') if -f '.ghosts';
-push(@ARGV,'/etc/ghosts');
-
-$remainder = '';
-
-line: while (<>) {
- s/[ \t]*\n//;
- if (!$_ || /^#/) {
- next line;
- }
- if (/^([a-zA-Z_0-9]+)=(.+)/) {
- $name = $1; $repl = $2;
- $repl =~ s/\+/:/g;
- $repl =~ s/-/:-/g;
- $one_of_these =~ s/:$name:/:$repl:/;
- $repl =~ s/:/:-/g;
- $one_of_these =~ s/:-$name:/:-$repl:/g;
- next line;
- }
- @gh = split(' ');
- $host = $gh[0];
- next line if $host eq $thishost; # should handle aliases too
- $wanted = 0;
- foreach $class (@gh) {
- $wanted++ if index($one_of_these,":$class:") >= 0;
- $wanted = -9999 if index($one_of_these,":-$class:") >= 0;
- }
- if ($wanted > 0) {
- ($cmd = $args) =~ s/[ \t]$systype:/ $host:/g;
- print "$cmd\n";
- $result = `$cmd 2>&1`;
- $remainder .= "$host+" if
- $result =~ /Connection timed out|Permission denied/;
- print $result;
- }
-}
-
-if ($remainder) {
- chop($remainder);
- open(grem,">.grem") || (printf stderr "Can't create .grem: $!\n");
- print grem 'rem=', $remainder, "\n";
- close(grem);
- print 'rem=', $remainder, "\n";
-}
-
-sub CLEANUP {
- exit;
-}
-
-sub CONT {
- print "Continuing...\n"; # Just ignore the signal that kills rcp
- $remainder .= "$host+";
-}
diff --git a/gnu/usr.bin/perl/eg/g/gcp.man b/gnu/usr.bin/perl/eg/g/gcp.man
deleted file mode 100644
index 8985742..0000000
--- a/gnu/usr.bin/perl/eg/g/gcp.man
+++ /dev/null
@@ -1,77 +0,0 @@
-.\" $Header: /home/cvs/386BSD/ports/lang/perl/eg/g/gcp.man,v 1.1.1.1 1993/08/23 21:29:44 nate Exp $
-.TH GCP 1C "13 May 1988"
-.SH NAME
-gcp \- global file copy
-.SH SYNOPSIS
-.B gcp
-file1 file2
-.br
-.B gcp
-[
-.B \-r
-] file ... directory
-.SH DESCRIPTION
-.I gcp
-works just like rcp(1C) except that you may specify a set of hosts to copy files
-from or to.
-The host sets are defined in the file /etc/ghosts.
-(An individual host name can be used as a set containing one member.)
-You can give a command like
-
- gcp /etc/motd sun:
-
-to copy your /etc/motd file to /etc/motd on all the Suns.
-If, on the other hand, you say
-
- gcp /a/foo /b/bar sun:/tmp
-
-then your files will be copied to /tmp on all the Suns.
-The general rule is that if you don't specify the destination directory,
-files go to the same directory they are in currently.
-.P
-You may specify the union of two or more sets by using + as follows:
-
- gcp /a/foo /b/bar 750+mc:
-
-which will copy /a/foo to /a/foo on all 750's and Masscomps, and then copy
-/b/bar to /b/bar on all 750's and Masscomps.
-.P
-Commonly used sets should be defined in /etc/ghosts.
-For example, you could add a line that says
-
- pep=manny+moe+jack
-
-Another way to do that would be to add the word "pep" after each of the host
-entries:
-
- manny sun3 pep
-.br
- moe sun3 pep
-.br
- jack sun3 pep
-
-Hosts and sets of host can also be excluded:
-
- foo=sun-sun2
-
-Any host so excluded will never be included, even if a subsequent set on the
-line includes it:
-
- foo=abc+def
-.br
- bar=xyz-abc+foo
-
-comes out to xyz+def.
-
-You can define private host sets by creating .ghosts in your current directory
-with entries just like /etc/ghosts.
-Also, if there is a file .grem, it defines "rem" to be the remaining hosts
-from the last gsh or gcp that didn't succeed everywhere.
-.PP
-Interrupting with a SIGINT will cause the rcp to the current host to be skipped
-and execution resumed with the next host.
-To stop completely, send a SIGQUIT.
-.SH SEE ALSO
-rcp(1C)
-.SH BUGS
-All the bugs of rcp, since it calls rcp.
diff --git a/gnu/usr.bin/perl/eg/g/ged b/gnu/usr.bin/perl/eg/g/ged
deleted file mode 100644
index d296a84..0000000
--- a/gnu/usr.bin/perl/eg/g/ged
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/g/ged,v 1.1.1.1 1993/08/23 21:29:44 nate Exp $
-
-# Does inplace edits on a set of files on a set of machines.
-#
-# Typical invokation:
-#
-# ged vax+sun /etc/passwd
-# s/Freddy/Freddie/;
-# ^D
-#
-
-$class = shift;
-$files = join(' ',@ARGV);
-
-die "Usage: ged class files <perlcmds\n" unless $files;
-
-exec "gsh", $class, "-d", "perl -pi.bak - $files";
-
-die "Couldn't execute gsh for some reason, stopped";
diff --git a/gnu/usr.bin/perl/eg/g/ghosts b/gnu/usr.bin/perl/eg/g/ghosts
deleted file mode 100644
index 96ec771..0000000
--- a/gnu/usr.bin/perl/eg/g/ghosts
+++ /dev/null
@@ -1,33 +0,0 @@
-# This first section gives alternate sets defined in terms of the sets given
-# by the second section. The order is important--all references must be
-# forward references.
-
-Nnd=sun-nd
-all=sun+mc+vax
-baseline=sun+mc
-sun=sun2+sun3
-vax=750+8600
-pep=manny+moe+jack
-
-# This second section defines the basic sets. Each host should have a line
-# that specifies which sets it is a member of. Extra sets should be separated
-# by white space. (The first section isn't strictly necessary, since all sets
-# could be defined in the second section, but then it wouldn't be so readable.)
-
-basvax 8600 src
-cdb0 sun3 sys
-cdb1 sun3 sys
-cdb2 sun3 sys
-chief sun3 src
-tis0 sun3
-manny sun3 sys
-moe sun3 sys
-jack sun3 sys
-disney sun3 sys
-huey sun3 nd
-dewey sun3 nd
-louie sun3 nd
-bizet sun2 src sys
-gif0 mc src
-mc0 mc
-dtv0 mc
diff --git a/gnu/usr.bin/perl/eg/g/gsh b/gnu/usr.bin/perl/eg/g/gsh
deleted file mode 100644
index 3322a02..0000000
--- a/gnu/usr.bin/perl/eg/g/gsh
+++ /dev/null
@@ -1,117 +0,0 @@
-#! /usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/g/gsh,v 1.1.1.1 1993/08/23 21:29:44 nate Exp $
-
-# Do rsh globally--see man page
-
-$SIG{'QUIT'} = 'quit'; # install signal handler for SIGQUIT
-
-sub getswitches {
- while ($ARGV[0] =~ /^-/) { # parse switches
- $ARGV[0] =~ /^-h/ && ($showhost++,$silent++,shift(@ARGV),next);
- $ARGV[0] =~ /^-s/ && ($silent++,shift(@ARGV),next);
- $ARGV[0] =~ /^-d/ && ($dodist++,shift(@ARGV),next);
- $ARGV[0] =~ /^-n/ && ($n=' -n',shift(@ARGV),next);
- $ARGV[0] =~ /^-l/ && ($l=' -l ' . $ARGV[1],shift(@ARGV),shift(@ARGV),
- next);
- last;
- }
-}
-
-do getswitches(); # get any switches before class
-$systype = shift; # get name representing set of hosts
-do getswitches(); # same switches allowed after class
-
-if ($dodist) { # distribute input over all rshes?
- `cat >/tmp/gsh$$`; # get input into a handy place
- $dist = " </tmp/gsh$$"; # each rsh takes input from there
-}
-
-$cmd = join(' ',@ARGV); # remaining args constitute the command
-$cmd =~ s/'/'"'"'/g; # quote any embedded single quotes
-
-$one_of_these = ":$systype:"; # prepare to expand "macros"
-$one_of_these =~ s/\+/:/g; # we hope to end up with list of
-$one_of_these =~ s/-/:-/g; # colon separated attributes
-
-@ARGV = ();
-push(@ARGV,'.grem') if -f '.grem';
-push(@ARGV,'.ghosts') if -f '.ghosts';
-push(@ARGV,'/etc/ghosts');
-
-$remainder = '';
-
-line: while (<>) { # for each line of ghosts
-
- s/[ \t]*\n//; # trim trailing whitespace
- if (!$_ || /^#/) { # skip blank line or comment
- next line;
- }
-
- if (/^(\w+)=(.+)/) { # a macro line?
- $name = $1; $repl = $2;
- $repl =~ s/\+/:/g;
- $repl =~ s/-/:-/g;
- $one_of_these =~ s/:$name:/:$repl:/; # do expansion in "wanted" list
- $repl =~ s/:/:-/g;
- $one_of_these =~ s/:-$name:/:-$repl:/;
- next line;
- }
-
- # we have a normal line
-
- @attr = split(' '); # a list of attributes to match against
- # which we put into an array
- $host = $attr[0]; # the first attribute is the host name
- if ($showhost) {
- $showhost = "$host:\t";
- }
-
- $wanted = 0;
- foreach $attr (@attr) { # iterate over attribute array
- $wanted++ if index($one_of_these,":$attr:") >= 0;
- $wanted = -9999 if index($one_of_these,":-$attr:") >= 0;
- }
- if ($wanted > 0) {
- print "rsh $host$l$n '$cmd'\n" unless $silent;
- $SIG{'INT'} = 'DEFAULT';
- if (open(PIPE,"rsh $host$l$n '$cmd'$dist 2>&1|")) { # start an rsh
- $SIG{'INT'} = 'cont';
- for ($iter=0; <PIPE>; $iter++) {
- unless ($iter) {
- $remainder .= "$host+"
- if /Connection timed out|Permission denied/;
- }
- print $showhost,$_;
- }
- close(PIPE);
- } else {
- print "(Can't execute rsh: $!)\n";
- $SIG{'INT'} = 'cont';
- }
- }
-}
-
-unlink "/tmp/gsh$$" if $dodist;
-
-if ($remainder) {
- chop($remainder);
- open(grem,">.grem") || (printf stderr "Can't make a .grem file: $!\n");
- print grem 'rem=', $remainder, "\n";
- close(grem);
- print 'rem=', $remainder, "\n";
-}
-
-# here are a couple of subroutines that serve as signal handlers
-
-sub cont {
- print "\rContinuing...\n";
- $remainder .= "$host+";
-}
-
-sub quit {
- $| = 1;
- print "\r";
- $SIG{'INT'} = '';
- kill 2, $$;
-}
diff --git a/gnu/usr.bin/perl/eg/g/gsh.man b/gnu/usr.bin/perl/eg/g/gsh.man
deleted file mode 100644
index 00eafb6..0000000
--- a/gnu/usr.bin/perl/eg/g/gsh.man
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" $Header: /home/cvs/386BSD/ports/lang/perl/eg/g/gsh.man,v 1.1.1.1 1993/08/23 21:29:44 nate Exp $
-.TH GSH 8 "13 May 1988"
-.SH NAME
-gsh \- global shell
-.SH SYNOPSIS
-.B gsh
-[options]
-.I host
-[options]
-.I command
-.SH DESCRIPTION
-.I gsh
-works just like rsh(1C) except that you may specify a set of hosts to execute
-the command on.
-The host sets are defined in the file /etc/ghosts.
-(An individual host name can be used as a set containing one member.)
-You can give a command like
-
- gsh sun /etc/mungmotd
-
-to run /etc/mungmotd on all your Suns.
-.P
-You may specify the union of two or more sets by using + as follows:
-
- gsh 750+mc /etc/mungmotd
-
-which will run mungmotd on all 750's and Masscomps.
-.P
-Commonly used sets should be defined in /etc/ghosts.
-For example, you could add a line that says
-
- pep=manny+moe+jack
-
-Another way to do that would be to add the word "pep" after each of the host
-entries:
-
- manny sun3 pep
-.br
- moe sun3 pep
-.br
- jack sun3 pep
-
-Hosts and sets of host can also be excluded:
-
- foo=sun-sun2
-
-Any host so excluded will never be included, even if a subsequent set on the
-line includes it:
-
- foo=abc+def
- bar=xyz-abc+foo
-
-comes out to xyz+def.
-
-You can define private host sets by creating .ghosts in your current directory
-with entries just like /etc/ghosts.
-Also, if there is a file .grem, it defines "rem" to be the remaining hosts
-from the last gsh or gcp that didn't succeed everywhere.
-
-Options include all those defined by rsh, as well as
-
-.IP "\-d" 8
-Causes gsh to collect input till end of file, and then distribute that input
-to each invokation of rsh.
-.IP "\-h" 8
-Rather than print out the command followed by the output, merely prepends the
-host name to each line of output.
-.IP "\-s" 8
-Do work silently.
-.PP
-Interrupting with a SIGINT will cause the rsh to the current host to be skipped
-and execution resumed with the next host.
-To stop completely, send a SIGQUIT.
-.SH SEE ALSO
-rsh(1C)
-.SH BUGS
-All the bugs of rsh, since it calls rsh.
-
-Also, will not properly return data from the remote execution that contains
-null characters.
diff --git a/gnu/usr.bin/perl/eg/muck b/gnu/usr.bin/perl/eg/muck
deleted file mode 100644
index 873539b..0000000
--- a/gnu/usr.bin/perl/eg/muck
+++ /dev/null
@@ -1,141 +0,0 @@
-#!../perl
-
-$M = '-M';
-$M = '-m' if -d '/usr/uts' && -f '/etc/master';
-
-do 'getopt.pl';
-do Getopt('f');
-
-if ($opt_f) {
- $makefile = $opt_f;
-}
-elsif (-f 'makefile') {
- $makefile = 'makefile';
-}
-elsif (-f 'Makefile') {
- $makefile = 'Makefile';
-}
-else {
- die "No makefile\n";
-}
-
-$MF = 'mf00';
-
-while(($key,$val) = each(ENV)) {
- $mac{$key} = $val;
-}
-
-do scan($makefile);
-
-$co = $action{'.c.o'};
-$co = ' ' unless $co;
-
-$missing = "Missing dependencies:\n";
-foreach $key (sort keys(o)) {
- if ($oc{$key}) {
- $src = $oc{$key};
- $action = $action{$key};
- }
- else {
- $action = '';
- }
- if (!$action) {
- if ($co && ($c = $key) =~ s/\.o$/.c/ && -f $c) {
- $src = $c;
- $action = $co;
- }
- else {
- print "No source found for $key $c\n";
- next;
- }
- }
- $I = '';
- $D = '';
- $I .= $1 while $action =~ s/(-I\S+\s*)//;
- $D .= $1 . ' ' while $action =~ s/(-D\w+)//;
- if ($opt_v) {
- $cmd = "Checking $key: cc $M $D $I $src";
- $cmd =~ s/\s\s+/ /g;
- print stderr $cmd,"\n";
- }
- open(CPP,"cc $M $D $I $src|") || die "Can't run C preprocessor: $!";
- while (<CPP>) {
- ($name,$dep) = split;
- $dep =~ s|^\./||;
- (print $missing,"$key: $dep\n"),($missing='')
- unless ($dep{"$key: $dep"} += 2) > 2;
- }
-}
-
-$extra = "\nExtraneous dependencies:\n";
-foreach $key (sort keys(dep)) {
- if ($key =~ /\.o: .*\.h$/ && $dep{$key} == 1) {
- print $extra,$key,"\n";
- $extra = '';
- }
-}
-
-sub scan {
- local($makefile) = @_;
- local($MF) = $MF;
- print stderr "Analyzing $makefile.\n" if $opt_v;
- $MF++;
- open($MF,$makefile) || die "Can't open $makefile: $!";
- while (<$MF>) {
- chop;
- chop($_ = $_ . <$MF>) while s/\\$//;
- next if /^#/;
- next if /^$/;
- s/\$\((\w+):([^=)]*)=([^)]*)\)/do subst("$1","$2","$3")/eg;
- s/\$\((\w+)\)/$mac{$1}/eg;
- $mac{$1} = $2, next if /^(\w+)\s*=\s*(.*)/;
- if (/^include\s+(.*)/) {
- do scan($1);
- print stderr "Continuing $makefile.\n" if $opt_v;
- next;
- }
- if (/^([^:]+):\s*(.*)/) {
- $left = $1;
- $right = $2;
- if ($right =~ /^([^;]*);(.*)/) {
- $right = $1;
- $action = $2;
- }
- else {
- $action = '';
- }
- while (<$MF>) {
- last unless /^\t/;
- chop;
- chop($_ = $_ . <$MF>) while s/\\$//;
- next if /^#/;
- last if /^$/;
- s/\$\((\w+):([^=)]*)=([^)]*)\)/do subst("$1","$2","$3")/eg;
- s/\$\((\w+)\)/$mac{$1}/eg;
- $action .= $_;
- }
- foreach $targ (split(' ',$left)) {
- $targ =~ s|^\./||;
- foreach $src (split(' ',$right)) {
- $src =~ s|^\./||;
- $deplist{$targ} .= ' ' . $src;
- $dep{"$targ: $src"} = 1;
- $o{$src} = 1 if $src =~ /\.o$/;
- $oc{$targ} = $src if $targ =~ /\.o$/ && $src =~ /\.[yc]$/;
- }
- $action{$targ} .= $action;
- }
- redo if $_;
- }
- }
- close($MF);
-}
-
-sub subst {
- local($foo,$from,$to) = @_;
- $foo = $mac{$foo};
- $from =~ s/\./[.]/;
- y/a/a/;
- $foo =~ s/\b$from\b/$to/g;
- $foo;
-}
diff --git a/gnu/usr.bin/perl/eg/muck.man b/gnu/usr.bin/perl/eg/muck.man
deleted file mode 100644
index 1b45ee0..0000000
--- a/gnu/usr.bin/perl/eg/muck.man
+++ /dev/null
@@ -1,21 +0,0 @@
-.\" $Header: /home/cvs/386BSD/ports/lang/perl/eg/muck.man,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-.TH MUCK 1 "10 Jan 1989"
-.SH NAME
-muck \- make usage checker
-.SH SYNOPSIS
-.B muck
-[options]
-.SH DESCRIPTION
-.I muck
-looks at your current makefile and complains if you've left out any dependencies
-between .o and .h files.
-It also complains about extraneous dependencies.
-.PP
-You can use the -f FILENAME option to specify an alternate name for your
-makefile.
-The -v option is a little more verbose about what muck is mucking around
-with at the moment.
-.SH SEE ALSO
-make(1)
-.SH BUGS
-Only knows about .h, .c and .o files.
diff --git a/gnu/usr.bin/perl/eg/myrup b/gnu/usr.bin/perl/eg/myrup
deleted file mode 100644
index b318589..0000000
--- a/gnu/usr.bin/perl/eg/myrup
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/myrup,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-
-# This was a customization of ruptime requested by someone here who wanted
-# to be able to find the least loaded machine easily. It uses the
-# /etc/ghosts file that's defined for gsh and gcp to prune down the
-# number of entries to those hosts we have administrative control over.
-
-print "node load (u)\n------- --------\n";
-
-open(ghosts,'/etc/ghosts') || die "Can't open /etc/ghosts: $!";
-line: while (<ghosts>) {
- next line if /^#/;
- next line if /^$/;
- next line if /=/;
- ($host) = split;
- $wanted{$host} = 1;
-}
-
-open(ruptime,'ruptime|') || die "Can't run ruptime: $!";
-open(sort,'|sort +1n');
-
-while (<ruptime>) {
- ($host,$upness,$foo,$users,$foo,$foo,$load) = split(/[\s,]+/);
- if ($wanted{$host} && $upness eq 'up') {
- printf sort "%s\t%s (%d)\n", $host, $load, $users;
- }
-}
diff --git a/gnu/usr.bin/perl/eg/nih b/gnu/usr.bin/perl/eg/nih
deleted file mode 100644
index a376142..0000000
--- a/gnu/usr.bin/perl/eg/nih
+++ /dev/null
@@ -1,10 +0,0 @@
-eval "exec /usr/bin/perl -Spi.bak $0 $*"
- if $running_under_some_shell;
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/nih,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-
-# This script makes #! scripts directly executable on machines that don't
-# support #!. It edits in place any scripts mentioned on the command line.
-
-s|^#!(.*)|#!$1\neval "exec $1 -S \$0 \$*"\n\tif \$running_under_some_shell;|
- if $. == 1;
diff --git a/gnu/usr.bin/perl/eg/perlsh b/gnu/usr.bin/perl/eg/perlsh
deleted file mode 100644
index 2b2cccd..0000000
--- a/gnu/usr.bin/perl/eg/perlsh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/perl
-
-# Poor man's perl shell.
-
-# Simply type two carriage returns every time you want to evaluate.
-# Note that it must be a complete perl statement--don't type double
-# carriage return in the middle of a loop.
-
-$/ = "\n\n"; # set paragraph mode
-$SHlinesep = "\n";
-while ($SHcmd = <>) {
- $/ = $SHlinesep;
- eval $SHcmd; print $@ || "\n";
- $SHlinesep = $/; $/ = '';
-}
diff --git a/gnu/usr.bin/perl/eg/relink b/gnu/usr.bin/perl/eg/relink
deleted file mode 100644
index 69956c9..0000000
--- a/gnu/usr.bin/perl/eg/relink
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/perl
-'di';
-'ig00';
-#
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/relink,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-#
-# $Log: relink,v $
-# Revision 1.1.1.1 1993/08/23 21:29:43 nate
-# PERL!
-#
-# Revision 4.0 91/03/20 01:11:40 lwall
-# 4.0 baseline.
-#
-# Revision 3.0.1.2 90/08/09 03:17:44 lwall
-# patch19: added man page for relink and rename
-#
-
-($op = shift) || die "Usage: relink perlexpr [filenames]\n";
-if (!@ARGV) {
- @ARGV = <STDIN>;
- chop(@ARGV);
-}
-for (@ARGV) {
- next unless -l; # symbolic link?
- $name = $_;
- $_ = readlink($_);
- $was = $_;
- eval $op;
- die $@ if $@;
- if ($was ne $_) {
- unlink($name);
- symlink($_, $name);
- }
-}
-##############################################################################
-
- # These next few lines are legal in both Perl and nroff.
-
-.00; # finish .ig
-
-'di \" finish diversion--previous line must be blank
-.nr nl 0-1 \" fake up transition to first page again
-.nr % 0 \" start at page 1
-';<<'.ex'; #__END__ ############# From here on it's a standard manual page ############
-.TH RELINK 1 "July 30, 1990"
-.AT 3
-.SH LINK
-relink \- relinks multiple symbolic links
-.SH SYNOPSIS
-.B relink perlexpr [symlinknames]
-.SH DESCRIPTION
-.I Relink
-relinks the symbolic links given according to the rule specified as the
-first argument.
-The argument is a Perl expression which is expected to modify the $_
-string in Perl for at least some of the names specified.
-For each symbolic link named on the command line, the Perl expression
-will be executed on the contents of the symbolic link with that name.
-If a given symbolic link's contents is not modified by the expression,
-it will not be changed.
-If a name given on the command line is not a symbolic link, it will be ignored.
-If no names are given on the command line, names will be read
-via standard input.
-.PP
-For example, to relink all symbolic links in the current directory
-pointing to somewhere in X11R3 so that they point to X11R4, you might say
-.nf
-
- relink 's/X11R3/X11R4/' *
-
-.fi
-To change all occurences of links in the system from /usr/spool to /var/spool,
-you'd say
-.nf
-
- find / -type l -print | relink 's#/usr/spool#/var/spool#'
-
-.fi
-.SH ENVIRONMENT
-No environment variables are used.
-.SH FILES
-.SH AUTHOR
-Larry Wall
-.SH "SEE ALSO"
-ln(1)
-.br
-perl(1)
-.SH DIAGNOSTICS
-If you give an invalid Perl expression you'll get a syntax error.
-.SH BUGS
-.ex
diff --git a/gnu/usr.bin/perl/eg/rename b/gnu/usr.bin/perl/eg/rename
deleted file mode 100644
index b568406..0000000
--- a/gnu/usr.bin/perl/eg/rename
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/perl
-'di';
-'ig00';
-#
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/rename,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-#
-# $Log: rename,v $
-# Revision 1.1.1.1 1993/08/23 21:29:43 nate
-# PERL!
-#
-# Revision 4.0 91/03/20 01:11:53 lwall
-# 4.0 baseline.
-#
-# Revision 3.0.1.2 90/08/09 03:17:57 lwall
-# patch19: added man page for relink and rename
-#
-
-($op = shift) || die "Usage: rename perlexpr [filenames]\n";
-if (!@ARGV) {
- @ARGV = <STDIN>;
- chop(@ARGV);
-}
-for (@ARGV) {
- $was = $_;
- eval $op;
- die $@ if $@;
- rename($was,$_) unless $was eq $_;
-}
-##############################################################################
-
- # These next few lines are legal in both Perl and nroff.
-
-.00; # finish .ig
-
-'di \" finish diversion--previous line must be blank
-.nr nl 0-1 \" fake up transition to first page again
-.nr % 0 \" start at page 1
-';<<'.ex'; #__END__ ############# From here on it's a standard manual page ############
-.TH RENAME 1 "July 30, 1990"
-.AT 3
-.SH NAME
-rename \- renames multiple files
-.SH SYNOPSIS
-.B rename perlexpr [files]
-.SH DESCRIPTION
-.I Rename
-renames the filenames supplied according to the rule specified as the
-first argument.
-The argument is a Perl expression which is expected to modify the $_
-string in Perl for at least some of the filenames specified.
-If a given filename is not modified by the expression, it will not be
-renamed.
-If no filenames are given on the command line, filenames will be read
-via standard input.
-.PP
-For example, to rename all files matching *.bak to strip the extension,
-you might say
-.nf
-
- rename 's/\e.bak$//' *.bak
-
-.fi
-To translate uppercase names to lower, you'd use
-.nf
-
- rename 'y/A-Z/a-z/' *
-
-.fi
-.SH ENVIRONMENT
-No environment variables are used.
-.SH FILES
-.SH AUTHOR
-Larry Wall
-.SH "SEE ALSO"
-mv(1)
-.br
-perl(1)
-.SH DIAGNOSTICS
-If you give an invalid Perl expression you'll get a syntax error.
-.SH BUGS
-.I Rename
-does not check for the existence of target filenames, so use with care.
-.ex
diff --git a/gnu/usr.bin/perl/eg/rmfrom b/gnu/usr.bin/perl/eg/rmfrom
deleted file mode 100644
index 0c8fa2c..0000000
--- a/gnu/usr.bin/perl/eg/rmfrom
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/perl -n
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/rmfrom,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-
-# A handy (but dangerous) script to put after a find ... -print.
-
-chop; unlink;
diff --git a/gnu/usr.bin/perl/eg/scan/scan_df b/gnu/usr.bin/perl/eg/scan/scan_df
deleted file mode 100644
index 6887387..0000000
--- a/gnu/usr.bin/perl/eg/scan/scan_df
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/perl -P
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/scan/scan_df,v 1.1.1.1 1993/08/23 21:29:44 nate Exp $
-
-# This report points out filesystems that are in danger of overflowing.
-
-(chdir '/usr/adm/private/memories') || die "Can't cd to memories: $!\n";
-`df >newdf`;
-open(Df, 'olddf');
-
-while (<Df>) {
- ($fs,$kbytes,$used,$avail,$capacity,$mounted_on) = split;
- next if $fs =~ /:/;
- next if $fs eq '';
- $oldused{$fs} = $used;
-}
-
-open(Df, 'newdf') || die "scan_df: can't open newdf";
-
-while (<Df>) {
- ($fs,$kbytes,$used,$avail,$capacity,$mounted_on) = split;
- next if $fs =~ /:/;
- next if $fs eq '';
- $oldused = $oldused{$fs};
- next if ($oldused == $used && $capacity < 99); # inactive filesystem
- if ($capacity >= 90) {
-#if defined(mc300) || defined(mc500) || defined(mc700)
- $_ = substr($_,0,13) . ' ' . substr($_,13,1000);
- $kbytes /= 2; # translate blocks to K
- $used /= 2;
- $oldused /= 2;
- $avail /= 2;
-#endif
- $diff = int($used - $oldused);
- if ($avail < $diff * 2) { # mark specially if in danger
- $mounted_on .= ' *';
- }
- next if $diff < 50 && $mounted_on eq '/';
- $fs =~ s|/dev/||;
- if ($diff >= 0) {
- $diff = '(+' . $diff . ')';
- }
- else {
- $diff = '(' . $diff . ')';
- }
- printf "%-8s%8d%8d %-8s%8d%7s %s\n",
- $fs,$kbytes,$used,$diff,$avail,$capacity,$mounted_on;
- }
-}
-
-rename('newdf','olddf');
diff --git a/gnu/usr.bin/perl/eg/scan/scan_last b/gnu/usr.bin/perl/eg/scan/scan_last
deleted file mode 100644
index 6621120..0000000
--- a/gnu/usr.bin/perl/eg/scan/scan_last
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/perl -P
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/scan/scan_last,v 1.1.1.1 1993/08/23 21:29:45 nate Exp $
-
-# This reports who was logged on at weird hours
-
-($dy, $mo, $lastdt) = split(/ +/,`date`);
-
-open(Last, 'exec last 2>&1 |') || die "scan_last: can't run last";
-
-while (<Last>) {
-#if defined(mc300) || defined(mc500) || defined(mc700)
- $_ = substr($_,0,19) . substr($_,23,100);
-#endif
- next if /^$/;
- (print),next if m|^/|;
- $login = substr($_,0,8);
- $tty = substr($_,10,7);
- $from = substr($_,19,15);
- $day = substr($_,36,3);
- $mo = substr($_,40,3);
- $dt = substr($_,44,2);
- $hr = substr($_,47,2);
- $min = substr($_,50,2);
- $dash = substr($_,53,1);
- $tohr = substr($_,55,2);
- $tomin = substr($_,58,2);
- $durhr = substr($_,63,2);
- $durmin = substr($_,66,2);
-
- next unless $hr;
- next if $login eq 'reboot ';
- next if $login eq 'shutdown';
-
- if ($dt != $lastdt) {
- if ($lastdt < $dt) {
- $seen += $dt - $lastdt;
- }
- else {
- $seen++;
- }
- $lastdt = $dt;
- }
-
- $inat = $hr + $min / 60;
- if ($tohr =~ /^[a-z]/) {
- $outat = 12; # something innocuous
- } else {
- $outat = $tohr + $tomin / 60;
- }
-
- last if $seen + ($inat < 8) > 1;
-
- if ($inat < 5 || $inat > 21 || $outat < 6 || $outat > 23) {
- print;
- }
-}
diff --git a/gnu/usr.bin/perl/eg/scan/scan_messages b/gnu/usr.bin/perl/eg/scan/scan_messages
deleted file mode 100644
index a28cda8..0000000
--- a/gnu/usr.bin/perl/eg/scan/scan_messages
+++ /dev/null
@@ -1,222 +0,0 @@
-#!/usr/bin/perl -P
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/scan/scan_messages,v 1.1.1.1 1993/08/23 21:29:44 nate Exp $
-
-# This prints out extraordinary console messages. You'll need to customize.
-
-chdir('/usr/adm/private/memories') || die "Can't cd to memories: $!\n";
-
-$maxpos = `cat oldmsgs 2>&1`;
-
-#if defined(mc300) || defined(mc500) || defined(mc700)
-open(Msgs, '/dev/null') || die "scan_messages: can't open messages";
-#else
-open(Msgs, '/usr/adm/messages') || die "scan_messages: can't open messages";
-#endif
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat(Msgs);
-
-if ($size < $maxpos) { # Did somebody truncate messages file?
- $maxpos = 0;
-}
-
-seek(Msgs,$maxpos,0); # Start where we left off last time.
-
-while (<Msgs>) {
- s/\[(\d+)\]/#/ && s/$1/#/g;
-#ifdef vax
- $_ =~ s/[A-Z][a-z][a-z] +\w+ +[0-9:]+ +\w+ +//;
- next if /root@.*:/;
- next if /^vmunix: 4.3 BSD UNIX/;
- next if /^vmunix: Copyright/;
- next if /^vmunix: avail mem =/;
- next if /^vmunix: SBIA0 at /;
- next if /^vmunix: disk ra81 is/;
- next if /^vmunix: dmf. at uba/;
- next if /^vmunix: dmf.:.*asynch/;
- next if /^vmunix: ex. at uba/;
- next if /^vmunix: ex.: HW/;
- next if /^vmunix: il. at uba/;
- next if /^vmunix: il.: hardware/;
- next if /^vmunix: ra. at uba/;
- next if /^vmunix: ra.: media/;
- next if /^vmunix: real mem/;
- next if /^vmunix: syncing disks/;
- next if /^vmunix: tms/;
- next if /^vmunix: tmscp. at uba/;
- next if /^vmunix: uba. at /;
- next if /^vmunix: uda. at /;
- next if /^vmunix: uda.: unit . ONLIN/;
- next if /^vmunix: .*buffers containing/;
- next if /^syslogd: .*newslog/;
-#endif
- next if /unknown service/;
- next if /^\.\.\.$/;
- if (/^[A-Z][a-z][a-z] [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]/) {
- $pfx = '';
- next;
- }
- next if /^[ \t]*$/;
- next if /^[ 0-9]*done$/;
- if (/^A/) {
- next if /^Accounting [sr]/;
- }
- elsif (/^C/) {
- next if /^Called from/;
- next if /^Copyright/;
- }
- elsif (/^E/) {
- next if /^End traceback/;
- next if /^Ethernet address =/;
- }
- elsif (/^K/) {
- next if /^KERNEL MODE/;
- }
- elsif (/^R/) {
- next if /^Rebooting Unix/;
- }
- elsif (/^S/) {
- next if /^Sun UNIX 4\.2 Release/;
- }
- elsif (/^W/) {
- next if /^WARNING: clock gained/;
- }
- elsif (/^a/) {
- next if /^arg /;
- next if /^avail mem =/;
- }
- elsif (/^b/) {
- next if /^bwtwo[0-9] at /;
- }
- elsif (/^c/) {
- next if /^cgone[0-9] at /;
- next if /^cdp[0-9] at /;
- next if /^csr /;
- }
- elsif (/^d/) {
- next if /^dcpa: init/;
- next if /^done$/;
- next if /^dts/;
- next if /^dump i\/o error/;
- next if /^dumping to dev/;
- next if /^dump succeeded/;
- $pfx = '*' if /^dev = /;
- }
- elsif (/^e/) {
- next if /^end \*\*/;
- next if /^error in copy/;
- }
- elsif (/^f/) {
- next if /^found /;
- }
- elsif (/^i/) {
- next if /^ib[0-9] at /;
- next if /^ie[0-9] at /;
- }
- elsif (/^l/) {
- next if /^le[0-9] at /;
- }
- elsif (/^m/) {
- next if /^mem = /;
- next if /^mt[0-9] at /;
- next if /^mti[0-9] at /;
- $pfx = '*' if /^mode = /;
- }
- elsif (/^n/) {
- next if /^not found /;
- }
- elsif (/^p/) {
- next if /^page map /;
- next if /^pi[0-9] at /;
- $pfx = '*' if /^panic/;
- }
- elsif (/^q/) {
- next if /^qqq /;
- }
- elsif (/^r/) {
- next if /^read /;
- next if /^revarp: Requesting/;
- next if /^root [od]/;
- }
- elsif (/^s/) {
- next if /^sc[0-9] at /;
- next if /^sd[0-9] at /;
- next if /^sd[0-9]: </;
- next if /^si[0-9] at /;
- next if /^si_getstatus/;
- next if /^sk[0-9] at /;
- next if /^skioctl/;
- next if /^skopen/;
- next if /^skprobe/;
- next if /^skread/;
- next if /^skwrite/;
- next if /^sky[0-9] at /;
- next if /^st[0-9] at /;
- next if /^st0:.*load/;
- next if /^stat1 = /;
- next if /^syncing disks/;
- next if /^syslogd: going down on signal 15/;
- }
- elsif (/^t/) {
- next if /^timeout [0-9]/;
- next if /^tm[0-9] at /;
- next if /^tod[0-9] at /;
- next if /^tv [0-9]/;
- $pfx = '*' if /^trap address/;
- }
- elsif (/^u/) {
- next if /^unit nsk/;
- next if /^use one of/;
- $pfx = '' if /^using/;
- next if /^using [0-9]+ buffers/;
- }
- elsif (/^x/) {
- next if /^xy[0-9] at /;
- next if /^write [0-9]/;
- next if /^xy[0-9]: </;
- next if /^xyc[0-9] at /;
- }
- elsif (/^y/) {
- next if /^yyy [0-9]/;
- }
- elsif (/^z/) {
- next if /^zs[0-9] at /;
- }
- $pfx = '*' if /^[a-z]+:$/;
- s/pid [0-9]+: //;
- if (/last message repeated ([0-9]+) time/) {
- $seen{$last} += $1;
- next;
- }
- s/^/$pfx/ if $pfx;
- unless ($seen{$_}++) {
- push(@seen,$_);
- }
- $last = $_;
-}
-$max = tell(Msgs);
-
-open(tmp,'|sort >oldmsgs.tmp') || die "Can't create tmp file: $!\n";
-while ($_ = pop(@seen)) {
- print tmp $_;
-}
-close(tmp);
-open(tmp,'oldmsgs.tmp') || die "Can't reopen tmp file: $!\n";
-while (<tmp>) {
- if (/^nd:/) {
- next if $seen{$_} < 20;
- }
- if (/NFS/) {
- next if $seen{$_} < 20;
- }
- if (/no carrier/) {
- next if $seen{$_} < 20;
- }
- if (/silo overflow/) {
- next if $seen{$_} < 20;
- }
- print $seen{$_},":\t",$_;
-}
-
-print `rm -f oldmsgs.tmp 2>&1; echo $max > oldmsgs 2>&1`;
diff --git a/gnu/usr.bin/perl/eg/scan/scan_passwd b/gnu/usr.bin/perl/eg/scan/scan_passwd
deleted file mode 100644
index f9c53c7d..0000000
--- a/gnu/usr.bin/perl/eg/scan/scan_passwd
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/scan/scan_passwd,v 1.1.1.1 1993/08/23 21:29:45 nate Exp $
-
-# This scans passwd file for security holes.
-
-open(Pass,'/etc/passwd') || die "Can't open passwd file: $!\n";
-# $dotriv = (`date` =~ /^Mon/);
-$dotriv = 1;
-
-while (<Pass>) {
- ($login,$pass,$uid,$gid,$gcos,$home,$shell) = split(/:/);
- if ($shell eq '') {
- print "Short: $_";
- }
- next if /^[+]/;
- if ($pass eq '') {
- if (index(":sync:lpq:+:", ":$login:") < 0) {
- print "No pass: $login\t$gcos\n";
- }
- }
- elsif ($dotriv && crypt($login,substr($pass,0,2)) eq $pass) {
- print "Trivial: $login\t$gcos\n";
- }
- if ($uid == 0) {
- if ($login !~ /^.?root$/ && $pass ne '*') {
- print "Extra root: $_";
- }
- }
-}
diff --git a/gnu/usr.bin/perl/eg/scan/scan_ps b/gnu/usr.bin/perl/eg/scan/scan_ps
deleted file mode 100644
index b0480d5..0000000
--- a/gnu/usr.bin/perl/eg/scan/scan_ps
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/perl -P
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/scan/scan_ps,v 1.1.1.1 1993/08/23 21:29:45 nate Exp $
-
-# This looks for looping processes.
-
-#if defined(mc300) || defined(mc500) || defined(mc700)
-open(Ps, '/bin/ps -el|') || die "scan_ps: can't run ps";
-
-while (<Ps>) {
- next if /rwhod/;
- print if index(' T', substr($_,62,1)) < 0;
-}
-#else
-open(Ps, '/bin/ps auxww|') || die "scan_ps: can't run ps";
-
-while (<Ps>) {
- next if /dataserver/;
- next if /nfsd/;
- next if /update/;
- next if /ypserv/;
- next if /rwhod/;
- next if /routed/;
- next if /pagedaemon/;
-#ifdef vax
- ($user,$pid,$cpu,$mem,$sz,$rss,$tt,$stat,$start,$time) = split;
-#else
- ($user,$pid,$cpu,$mem,$sz,$rss,$tt,$stat,$time) = split;
-#endif
- print if length($time) > 4;
-}
-#endif
diff --git a/gnu/usr.bin/perl/eg/scan/scan_sudo b/gnu/usr.bin/perl/eg/scan/scan_sudo
deleted file mode 100644
index a95a609..0000000
--- a/gnu/usr.bin/perl/eg/scan/scan_sudo
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/perl -P
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/scan/scan_sudo,v 1.1.1.1 1993/08/23 21:29:45 nate Exp $
-
-# Analyze the sudo log.
-
-chdir('/usr/adm/private/memories') || die "Can't cd to memories: $!\n";
-
-if (open(Oldsudo,'oldsudo')) {
- $maxpos = <Oldsudo>;
- close Oldsudo;
-}
-else {
- $maxpos = 0;
- `echo 0 >oldsudo`;
-}
-
-unless (open(Sudo, '/usr/adm/sudo.log')) {
- print "Somebody removed sudo.log!!!\n" if $maxpos;
- exit 0;
-}
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat(Sudo);
-
-if ($size < $maxpos) {
- $maxpos = 0;
- print "Somebody reset sudo.log!!!\n";
-}
-
-seek(Sudo,$maxpos,0);
-
-while (<Sudo>) {
- s/^.* :[ \t]+//;
- s/ipcrm.*/ipcrm/;
- s/kill.*/kill/;
- unless ($seen{$_}++) {
- push(@seen,$_);
- }
- $last = $_;
-}
-$max = tell(Sudo);
-
-open(tmp,'|sort >oldsudo.tmp') || die "Can't create tmp file: $!\n";
-while ($_ = pop(@seen)) {
- print tmp $_;
-}
-close(tmp);
-open(tmp,'oldsudo.tmp') || die "Can't reopen tmp file: $!\n";
-while (<tmp>) {
- print $seen{$_},":\t",$_;
-}
-
-print `(rm -f oldsudo.tmp; echo $max > oldsudo) 2>&1`;
diff --git a/gnu/usr.bin/perl/eg/scan/scan_suid b/gnu/usr.bin/perl/eg/scan/scan_suid
deleted file mode 100644
index a730e0a..0000000
--- a/gnu/usr.bin/perl/eg/scan/scan_suid
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/perl -P
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/scan/scan_suid,v 1.1.1.1 1993/08/23 21:29:44 nate Exp $
-
-# Look for new setuid root files.
-
-chdir '/usr/adm/private/memories' || die "Can't cd to memories: $!\n";
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('oldsuid');
-if ($nlink) {
- $lasttime = $mtime;
- $tmp = $ctime - $atime;
- if ($tmp <= 0 || $tmp >= 10) {
- print "WARNING: somebody has read oldsuid!\n";
- }
- $tmp = $ctime - $mtime;
- if ($tmp <= 0 || $tmp >= 10) {
- print "WARNING: somebody has modified oldsuid!!!\n";
- }
-} else {
- $lasttime = time - 60 * 60 * 24; # one day ago
-}
-$thistime = time;
-
-#if defined(mc300) || defined(mc500) || defined(mc700)
-open(Find, 'find / -perm -04000 -print |') ||
- die "scan_find: can't run find";
-#else
-open(Find, 'find / \( -fstype nfs -prune \) -o -perm -04000 -ls |') ||
- die "scan_find: can't run find";
-#endif
-
-open(suid, '>newsuid.tmp');
-
-while (<Find>) {
-
-#if defined(mc300) || defined(mc500) || defined(mc700)
- $x = `/bin/ls -il $_`;
- $_ = $x;
- s/^ *//;
- ($inode,$perm,$links,$owner,$group,$size,$month,$day,$time,$name)
- = split;
-#else
- s/^ *//;
- ($inode,$blocks,$perm,$links,$owner,$group,$size,$month,$day,$time,$name)
- = split;
-#endif
-
- if ($perm =~ /[sS]/ && $owner eq 'root') {
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat($name);
- $foo = sprintf("%10s%3s %-8s %-8s%9s %3s %2s %s %s\n",
- $perm,$links,$owner,$group,$size,$month,$day,$name,$inode);
- print suid $foo;
- if ($ctime > $lasttime) {
- if ($ctime > $thistime) {
- print "Future file: $foo";
- }
- else {
- $ct .= $foo;
- }
- }
- }
-}
-close(suid);
-
-print `sort +7 -8 newsuid.tmp >newsuid 2>&1`;
-$foo = `/bin/diff oldsuid newsuid 2>&1`;
-print "Differences in suid info:\n",$foo if $foo;
-print `mv oldsuid oldoldsuid 2>&1; mv newsuid oldsuid 2>&1`;
-print `touch oldsuid 2>&1;sleep 2 2>&1;chmod o+w oldsuid 2>&1`;
-print `rm -f newsuid.tmp 2>&1`;
-
-@ct = split(/\n/,$ct);
-$ct = '';
-$* = 1;
-while ($#ct >= 0) {
- $tmp = shift(@ct);
- unless ($foo =~ "^>.*$tmp\n") { $ct .= "$tmp\n"; }
-}
-
-print "Inode changed since last time:\n",$ct if $ct;
-
diff --git a/gnu/usr.bin/perl/eg/scan/scanner b/gnu/usr.bin/perl/eg/scan/scanner
deleted file mode 100644
index f773e87..0000000
--- a/gnu/usr.bin/perl/eg/scan/scanner
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/scan/scanner,v 1.1.1.1 1993/08/23 21:29:44 nate Exp $
-
-# This runs all the scan_* routines on all the machines in /etc/ghosts.
-# We run this every morning at about 6 am:
-
-# !/bin/sh
-# cd /usr/adm/private
-# decrypt scanner | perl >scan.out 2>&1
-# mail admin <scan.out
-
-# Note that the scan_* files should be encrypted with the key "-inquire", and
-# scanner should be encrypted somehow so that people can't find that key.
-# I leave it up to you to figure out how to unencrypt it before executing.
-
-$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/ucb:.';
-
-$| = 1; # command buffering on stdout
-
-print "Subject: bizarre happenings\n\n";
-
-(chdir '/usr/adm/private') || die "Can't cd to /usr/adm/private: $!\n";
-
-if ($#ARGV >= 0) {
- @scanlist = @ARGV;
-} else {
- @scanlist = split(/[ \t\n]+/,`echo scan_*`);
-}
-
-scan: while ($scan = shift(@scanlist)) {
- print "\n********** $scan **********\n";
- $showhost++;
-
- $systype = 'all';
-
- open(ghosts, '/etc/ghosts') || die 'No /etc/ghosts file';
-
- $one_of_these = ":$systype:";
- if ($systype =~ s/\+/[+]/g) {
- $one_of_these =~ s/\+/:/g;
- }
-
- line: while (<ghosts>) {
- s/[ \t]*\n//;
- if (!$_ || /^#/) {
- next line;
- }
- if (/^([a-zA-Z_0-9]+)=(.+)/) {
- $name = $1; $repl = $2;
- $repl =~ s/\+/:/g;
- $one_of_these =~ s/:$name:/:$repl:/;
- next line;
- }
- @gh = split;
- $host = $gh[0];
- if ($showhost) { $showhost = "$host:\t"; }
- class: while ($class = pop(gh)) {
- if (index($one_of_these,":$class:") >=0) {
- $iter = 0;
- `exec crypt -inquire <$scan >.x 2>/dev/null`;
- unless (open(scan,'.x')) {
- print "Can't run $scan: $!\n";
- next scan;
- }
- $cmd = <scan>;
- unless ($cmd =~ s/#!(.*)\n/$1/) {
- $cmd = '/usr/bin/perl';
- }
- close(scan);
- if (open(PIPE,"exec rsh $host '$cmd' <.x|")) {
- sleep(5);
- unlink '.x';
- while (<PIPE>) {
- last if $iter++ > 1000; # must be looping
- next if /^[0-9.]+u [0-9.]+s/;
- print $showhost,$_;
- }
- close(PIPE);
- } else {
- print "(Can't execute rsh: $!)\n";
- }
- last class;
- }
- }
- }
-}
diff --git a/gnu/usr.bin/perl/eg/server b/gnu/usr.bin/perl/eg/server
deleted file mode 100644
index 49a140a..0000000
--- a/gnu/usr.bin/perl/eg/server
+++ /dev/null
@@ -1,27 +0,0 @@
-#!./perl
-
-$pat = 'S n C4 x8';
-$inet = 2;
-$echo = 7;
-$smtp = 25;
-$nntp = 119;
-
-$this = pack($pat,$inet,2345, 0,0,0,0);
-select(NS); $| = 1; select(stdout);
-
-if (socket(S,2,1,6)) { print "socket ok\n"; } else { die $!; }
-if (bind(S,$this)) { print "bind ok\n"; } else { die $!; }
-if (listen(S,5)) { print "listen ok\n"; } else { die $!; }
-for (;;) {
- print "Listening again\n";
- if ($addr = accept(NS,S)) { print "accept ok\n"; } else { die $!; }
-
- @ary = unpack($pat,$addr);
- $, = ' ';
- print @ary; print "\n";
-
- while (<NS>) {
- print;
- print NS;
- }
-}
diff --git a/gnu/usr.bin/perl/eg/shmkill b/gnu/usr.bin/perl/eg/shmkill
deleted file mode 100644
index e8d1b11..0000000
--- a/gnu/usr.bin/perl/eg/shmkill
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/shmkill,v 1.1.1.1 1993/08/23 21:29:43 nate Exp $
-
-# A script to call from crontab periodically when people are leaving shared
-# memory sitting around unattached.
-
-open(ipcs,'ipcs -m -o|') || die "Can't run ipcs: $!";
-
-while (<ipcs>) {
- $tmp = index($_,'NATTCH');
- $pos = $tmp if $tmp >= 0;
- if (/^m/) {
- ($m,$id,$key,$mode,$owner,$group,$attach) = split;
- if ($attach != substr($_,$pos,6)) {
- die "Different ipcs format--can't parse!\n";
- }
- if ($attach == 0) {
- push(@goners,'-m',$id);
- }
- }
-}
-
-exec 'ipcrm', @goners if $#goners >= 0;
diff --git a/gnu/usr.bin/perl/eg/sysvipc/README b/gnu/usr.bin/perl/eg/sysvipc/README
deleted file mode 100644
index 54094f1..0000000
--- a/gnu/usr.bin/perl/eg/sysvipc/README
+++ /dev/null
@@ -1,9 +0,0 @@
-FYEnjoyment, here are the test scripts I used while implementing SysV
-IPC in Perl. Each of them must be run with the parameter "s" for
-"send" or "r" for "receive"; in each case, the receiver is the server
-and the sender is the client.
-
---
-Chip Salzenberg at ComDev/TCT <chip@tct.uucp>, <uunet!ateng!tct!chip>
-
-
diff --git a/gnu/usr.bin/perl/eg/sysvipc/ipcmsg b/gnu/usr.bin/perl/eg/sysvipc/ipcmsg
deleted file mode 100644
index 317e027..0000000
--- a/gnu/usr.bin/perl/eg/sysvipc/ipcmsg
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/perl
-eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
- if 0;
-
-require 'sys/ipc.ph';
-require 'sys/msg.ph';
-
-$| = 1;
-
-$mode = shift;
-die "usage: ipcmsg {r|s}\n" unless $mode =~ /^[rs]$/;
-$send = ($mode eq "s");
-
-$id = msgget(0x1234, ($send ? 0 : &IPC_CREAT) | 0644);
-die "Can't get message queue: $!\n" unless defined($id);
-print "message queue id: $id\n";
-
-if ($send) {
- while (<STDIN>) {
- chop;
- unless (msgsnd($id, pack("LA*", $., $_), 0)) {
- die "Can't send message: $!\n";
- }
- }
-}
-else {
- $SIG{'INT'} = $SIG{'QUIT'} = "leave";
- for (;;) {
- unless (msgrcv($id, $_, 512, 0, 0)) {
- die "Can't receive message: $!\n";
- }
- ($type, $message) = unpack("La*", $_);
- printf "[%d] %s\n", $type, $message;
- }
-}
-
-&leave;
-
-sub leave {
- if (!$send) {
- $x = msgctl($id, &IPC_RMID, 0);
- if (!defined($x) || $x < 0) {
- die "Can't remove message queue: $!\n";
- }
- }
- exit;
-}
diff --git a/gnu/usr.bin/perl/eg/sysvipc/ipcsem b/gnu/usr.bin/perl/eg/sysvipc/ipcsem
deleted file mode 100644
index d72a2dd..0000000
--- a/gnu/usr.bin/perl/eg/sysvipc/ipcsem
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/perl
-eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
- if 0;
-
-require 'sys/ipc.ph';
-require 'sys/msg.ph';
-
-$| = 1;
-
-$mode = shift;
-die "usage: ipcmsg {r|s}\n" unless $mode =~ /^[rs]$/;
-$signal = ($mode eq "s");
-
-$id = semget(0x1234, 1, ($signal ? 0 : &IPC_CREAT) | 0644);
-die "Can't get semaphore: $!\n" unless defined($id);
-print "semaphore id: $id\n";
-
-if ($signal) {
- while (<STDIN>) {
- print "Signalling\n";
- unless (semop($id, 0, pack("sss", 0, 1, 0))) {
- die "Can't signal semaphore: $!\n";
- }
- }
-}
-else {
- $SIG{'INT'} = $SIG{'QUIT'} = "leave";
- for (;;) {
- unless (semop($id, 0, pack("sss", 0, -1, 0))) {
- die "Can't wait for semaphore: $!\n";
- }
- print "Unblocked\n";
- }
-}
-
-&leave;
-
-sub leave {
- if (!$signal) {
- $x = semctl($id, 0, &IPC_RMID, 0);
- if (!defined($x) || $x < 0) {
- die "Can't remove semaphore: $!\n";
- }
- }
- exit;
-}
diff --git a/gnu/usr.bin/perl/eg/sysvipc/ipcshm b/gnu/usr.bin/perl/eg/sysvipc/ipcshm
deleted file mode 100644
index d40e46b..0000000
--- a/gnu/usr.bin/perl/eg/sysvipc/ipcshm
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/perl
-eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
- if 0;
-
-require 'sys/ipc.ph';
-require 'sys/shm.ph';
-
-$| = 1;
-
-$mode = shift;
-die "usage: ipcshm {r|s}\n" unless $mode =~ /^[rs]$/;
-$send = ($mode eq "s");
-
-$SIZE = 32;
-$id = shmget(0x1234, $SIZE, ($send ? 0 : &IPC_CREAT) | 0644);
-die "Can't get shared memory: $!\n" unless defined($id);
-print "shared memory id: $id\n";
-
-if ($send) {
- while (<STDIN>) {
- chop;
- unless (shmwrite($id, pack("La*", length($_), $_), 0, $SIZE)) {
- die "Can't write to shared memory: $!\n";
- }
- }
-}
-else {
- $SIG{'INT'} = $SIG{'QUIT'} = "leave";
- for (;;) {
- $_ = <STDIN>;
- unless (shmread($id, $_, 0, $SIZE)) {
- die "Can't read shared memory: $!\n";
- }
- $len = unpack("L", $_);
- $message = substr($_, length(pack("L",0)), $len);
- printf "[%d] %s\n", $len, $message;
- }
-}
-
-&leave;
-
-sub leave {
- if (!$send) {
- $x = shmctl($id, &IPC_RMID, 0);
- if (!defined($x) || $x < 0) {
- die "Can't remove shared memory: $!\n";
- }
- }
- exit;
-}
diff --git a/gnu/usr.bin/perl/eg/travesty b/gnu/usr.bin/perl/eg/travesty
deleted file mode 100644
index 7e6f983..0000000
--- a/gnu/usr.bin/perl/eg/travesty
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/perl
-
-while (<>) {
- next if /^\./;
- next if /^From / .. /^$/;
- next if /^Path: / .. /^$/;
- s/^\W+//;
- push(@ary,split(' '));
- while ($#ary > 1) {
- $a = $p;
- $p = $n;
- $w = shift(@ary);
- $n = $num{$w};
- if ($n eq '') {
- push(@word,$w);
- $n = pack('S',$#word);
- $num{$w} = $n;
- }
- $lookup{$a . $p} .= $n;
- }
-}
-
-for (;;) {
- $n = $lookup{$a . $p};
- ($foo,$n) = each(lookup) if $n eq '';
- $n = substr($n,int(rand(length($n))) & 0177776,2);
- $a = $p;
- $p = $n;
- ($w) = unpack('S',$n);
- $w = $word[$w];
- $col += length($w) + 1;
- if ($col >= 65) {
- $col = 0;
- print "\n";
- }
- else {
- print ' ';
- }
- print $w;
- if ($w =~ /\.$/) {
- if (rand() < .1) {
- print "\n";
- $col = 80;
- }
- }
-}
diff --git a/gnu/usr.bin/perl/eg/van/empty b/gnu/usr.bin/perl/eg/van/empty
deleted file mode 100644
index ee656e6..0000000
--- a/gnu/usr.bin/perl/eg/van/empty
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/van/empty,v 1.1.1.1 1993/08/23 21:29:45 nate Exp $
-
-# This script empties a trashcan.
-
-$recursive = shift if $ARGV[0] eq '-r';
-
-@ARGV = '.' if $#ARGV < 0;
-
-chop($pwd = `pwd`);
-
-dir: foreach $dir (@ARGV) {
- unless (chdir $dir) {
- print stderr "Can't find directory $dir: $!\n";
- next dir;
- }
- if ($recursive) {
- do cmd('find . -name .deleted -exec /bin/rm -rf {} ;');
- }
- else {
- if (-d '.deleted') {
- do cmd('rm -rf .deleted');
- }
- else {
- if ($dir eq '.' && $pwd =~ m|/\.deleted$|) {
- chdir '..';
- do cmd('rm -rf .deleted');
- }
- else {
- print stderr "No trashcan found in directory $dir\n";
- }
- }
- }
-}
-continue {
- chdir $pwd;
-}
-
-# force direct execution with no shell
-
-sub cmd {
- system split(' ',join(' ',@_));
-}
-
diff --git a/gnu/usr.bin/perl/eg/van/unvanish b/gnu/usr.bin/perl/eg/van/unvanish
deleted file mode 100644
index 5045982..0000000
--- a/gnu/usr.bin/perl/eg/van/unvanish
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/van/unvanish,v 1.1.1.1 1993/08/23 21:29:45 nate Exp $
-
-sub it {
- if ($olddir ne '.') {
- chop($pwd = `pwd`) if $pwd eq '';
- (chdir $olddir) || die "Directory $olddir is not accesible";
- }
- unless ($olddir eq '.deleted') {
- if (-d '.deleted') {
- chdir '.deleted' || die "Directory .deleted is not accesible";
- }
- else {
- chop($pwd = `pwd`) if $pwd eq '';
- die "Directory .deleted does not exist" unless $pwd =~ /\.deleted$/;
- }
- }
- print `mv $startfiles$filelist..$force`;
- if ($olddir ne '.') {
- (chdir $pwd) || die "Can't get back to original directory $pwd: $!\n";
- }
-}
-
-if ($#ARGV < 0) {
- open(lastcmd,'.deleted/.lastcmd') ||
- open(lastcmd,'.lastcmd') ||
- die "No previous vanish in this dir";
- $ARGV = <lastcmd>;
- close(lastcmd);
- @ARGV = split(/[\n ]+/,$ARGV);
-}
-
-while ($ARGV[0] =~ /^-/) {
- $_ = shift;
- /^-f/ && ($force = ' >/dev/null 2>&1');
- /^-i/ && ($interactive = 1);
- if (/^-+$/) {
- $startfiles = '- ';
- last;
- }
-}
-
-while ($file = shift) {
- if ($file =~ s|^(.*)/||) {
- $dir = $1;
- }
- else {
- $dir = '.';
- }
-
- if ($dir ne $olddir) {
- do it() if $olddir;
- $olddir = $dir;
- }
-
- if ($interactive) {
- print "unvanish: restore $dir/$file? ";
- next unless <stdin> =~ /^y/i;
- }
-
- $filelist .= $file; $filelist .= ' ';
-
-}
-
-do it() if $olddir;
diff --git a/gnu/usr.bin/perl/eg/van/vanexp b/gnu/usr.bin/perl/eg/van/vanexp
deleted file mode 100644
index 79b7885..0000000
--- a/gnu/usr.bin/perl/eg/van/vanexp
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/van/vanexp,v 1.1.1.1 1993/08/23 21:29:45 nate Exp $
-
-# This is for running from a find at night to expire old .deleteds
-
-$can = $ARGV[0];
-
-exit 1 unless $can =~ /.deleted$/;
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat($can);
-
-exit 0 unless $size;
-
-if (time - $mtime > 2 * 24 * 60 * 60) {
- `/bin/rm -rf $can`;
-}
-else {
- `find $can -ctime +2 -exec rm -f {} \;`;
-}
diff --git a/gnu/usr.bin/perl/eg/van/vanish b/gnu/usr.bin/perl/eg/van/vanish
deleted file mode 100644
index b79776a..0000000
--- a/gnu/usr.bin/perl/eg/van/vanish
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/eg/van/vanish,v 1.1.1.1 1993/08/23 21:29:45 nate Exp $
-
-sub it {
- if ($olddir ne '.') {
- chop($pwd = `pwd`) if $pwd eq '';
- (chdir $olddir) || die "Directory $olddir is not accesible";
- }
- if (!-d .deleted) {
- print `mkdir .deleted; chmod 775 .deleted`;
- die "You can't remove files from $olddir" if $?;
- }
- $filelist =~ s/ $//;
- $filelist =~ s/#/\\#/g;
- if ($filelist !~ /^[ \t]*$/) {
- open(lastcmd,'>.deleted/.lastcmd');
- print lastcmd $filelist,"\n";
- close(lastcmd);
- print `/bin/mv $startfiles$filelist .deleted$force`;
- }
- if ($olddir ne '.') {
- (chdir $pwd) || die "Can't get back to original directory $pwd: $!\n";
- }
-}
-
-while ($ARGV[0] =~ /^-/) {
- $_ = shift;
- /^-f/ && ($force = ' >/dev/null 2>&1');
- /^-i/ && ($interactive = 1);
- if (/^-+$/) {
- $startfiles = '- ';
- last;
- }
-}
-
-chop($pwd = `pwd`);
-
-while ($file = shift) {
- if ($file =~ s|^(.*)/||) {
- $dir = $1;
- }
- else {
- $dir = '.';
- }
-
- if ($interactive) {
- print "vanish: remove $dir/$file? ";
- next unless <stdin> =~ /^y/i;
- }
-
- if ($file eq '.deleted') {
- print stderr "To delete .deleted (the trashcan) use the 'empty' command.\n";
- next;
- }
-
- if ($dir ne $olddir) {
- do it() if $olddir;
- $olddir = $dir;
- }
-
- $filelist .= $file; $filelist .= ' ';
-}
-
-do it() if $olddir;
diff --git a/gnu/usr.bin/perl/eg/who b/gnu/usr.bin/perl/eg/who
deleted file mode 100644
index ac15246..0000000
--- a/gnu/usr.bin/perl/eg/who
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/perl
-# This assumes your /etc/utmp file looks like ours
-open(UTMP,'/etc/utmp');
-@mo = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
-while (read(UTMP,$utmp,36)) {
- ($line,$name,$host,$time) = unpack('A8A8A16l',$utmp);
- if ($name) {
- $host = "($host)" if ord($host);
- ($sec,$min,$hour,$mday,$mon) = localtime($time);
- printf "%-9s%-8s%s %2d %02d:%02d %s\n",
- $name,$line,$mo[$mon],$mday,$hour,$min,$host;
- }
-}
diff --git a/gnu/usr.bin/perl/emacs/perl-mode.el b/gnu/usr.bin/perl/emacs/perl-mode.el
deleted file mode 100644
index cb6195d..0000000
--- a/gnu/usr.bin/perl/emacs/perl-mode.el
+++ /dev/null
@@ -1,631 +0,0 @@
-;; Perl code editing commands for GNU Emacs
-;; Copyright (C) 1990 William F. Mann
-;; Adapted from C code editing commands 'c-mode.el', Copyright 1987 by the
-;; Free Software Foundation, under terms of its General Public License.
-
-;; This file may be made part of GNU Emacs at the option of the FSF, or
-;; of the perl distribution at the option of Larry Wall.
-
-;; This code is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY. No author or distributor
-;; accepts responsibility to anyone for the consequences of using it
-;; or for whether it serves any particular purpose or works at all,
-;; unless he says so in writing. Refer to the GNU Emacs General Public
-;; License for full details.
-
-;; Everyone is granted permission to copy, modify and redistribute
-;; this code, but only under the conditions described in the
-;; GNU Emacs General Public License. A copy of this license is
-;; supposed to have been given to you along with GNU Emacs so you
-;; can know your rights and responsibilities. It should be in a
-;; file named COPYING. Among other things, the copyright notice
-;; and this notice must be preserved on all copies.
-
-;; To enter perl-mode automatically, add (autoload 'perl-mode "perl-mode")
-;; to your .emacs file and change the first line of your perl script to:
-;; #!/usr/bin/perl -- # -*-Perl-*-
-;; With argments to perl:
-;; #!/usr/bin/perl -P- # -*-Perl-*-
-;; To handle files included with do 'filename.pl';, add something like
-;; (setq auto-mode-alist (append (list (cons "\\.pl$" 'perl-mode))
-;; auto-mode-alist))
-;; to your .emacs file; otherwise the .pl suffix defaults to prolog-mode.
-
-;; This code is based on the 18.53 version c-mode.el, with extensive
-;; rewriting. Most of the features of c-mode survived intact.
-
-;; I added a new feature which adds functionality to TAB; it is controlled
-;; by the variable perl-tab-to-comment. With it enabled, TAB does the
-;; first thing it can from the following list: change the indentation;
-;; move past leading white space; delete an empty comment; reindent a
-;; comment; move to end of line; create an empty comment; tell you that
-;; the line ends in a quoted string, or has a # which should be a \#.
-
-;; If your machine is slow, you may want to remove some of the bindings
-;; to electric-perl-terminator. I changed the indenting defaults to be
-;; what Larry Wall uses in perl/lib, but left in all the options.
-
-;; I also tuned a few things: comments and labels starting in column
-;; zero are left there by indent-perl-exp; perl-beginning-of-function
-;; goes back to the first open brace/paren in column zero, the open brace
-;; in 'sub ... {', or the equal sign in 'format ... ='; indent-perl-exp
-;; (meta-^q) indents from the current line through the close of the next
-;; brace/paren, so you don't need to start exactly at a brace or paren.
-
-;; It may be good style to put a set of redundant braces around your
-;; main program. This will let you reindent it with meta-^q.
-
-;; Known problems (these are all caused by limitations in the elisp
-;; parsing routine (parse-partial-sexp), which was not designed for such
-;; a rich language; writing a more suitable parser would be a big job):
-;; 1) Regular expression delimitors do not act as quotes, so special
-;; characters such as `'"#:;[](){} may need to be backslashed
-;; in regular expressions and in both parts of s/// and tr///.
-;; 2) The globbing syntax <pattern> is not recognized, so special
-;; characters in the pattern string must be backslashed.
-;; 3) The q, qq, and << quoting operators are not recognized; see below.
-;; 4) \ (backslash) always quotes the next character, so '\' is
-;; treated as the start of a string. Use "\\" as a work-around.
-;; 5) To make variables such a $' and $#array work, perl-mode treats
-;; $ just like backslash, so '$' is the same as problem 5.
-;; 6) Unfortunately, treating $ like \ makes ${var} be treated as an
-;; unmatched }. See below.
-;; 7) When ' (quote) is used as a package name separator, perl-mode
-;; doesn't understand, and thinks it is seeing a quoted string.
-
-;; Here are some ugly tricks to bypass some of these problems: the perl
-;; expression /`/ (that's a back-tick) usually evaluates harmlessly,
-;; but will trick perl-mode into starting a quoted string, which
-;; can be ended with another /`/. Assuming you have no embedded
-;; back-ticks, this can used to help solve problem 3:
-;;
-;; /`/; $ugly = q?"'$?; /`/;
-;;
-;; To solve problem 6, add a /{/; before each use of ${var}:
-;; /{/; while (<${glob_me}>) ...
-;;
-;; Problem 7 is even worse, but this 'fix' does work :-(
-;; $DB'stop#'
-;; [$DB'line#'
-;; ] =~ s/;9$//;
-
-
-(defvar perl-mode-abbrev-table nil
- "Abbrev table in use in perl-mode buffers.")
-(define-abbrev-table 'perl-mode-abbrev-table ())
-
-(defvar perl-mode-map ()
- "Keymap used in Perl mode.")
-(if perl-mode-map
- ()
- (setq perl-mode-map (make-sparse-keymap))
- (define-key perl-mode-map "{" 'electric-perl-terminator)
- (define-key perl-mode-map "}" 'electric-perl-terminator)
- (define-key perl-mode-map ";" 'electric-perl-terminator)
- (define-key perl-mode-map ":" 'electric-perl-terminator)
- (define-key perl-mode-map "\e\C-a" 'perl-beginning-of-function)
- (define-key perl-mode-map "\e\C-e" 'perl-end-of-function)
- (define-key perl-mode-map "\e\C-h" 'mark-perl-function)
- (define-key perl-mode-map "\e\C-q" 'indent-perl-exp)
- (define-key perl-mode-map "\177" 'backward-delete-char-untabify)
- (define-key perl-mode-map "\t" 'perl-indent-command))
-
-(autoload 'c-macro-expand "cmacexp"
- "Display the result of expanding all C macros occurring in the region.
-The expansion is entirely correct because it uses the C preprocessor."
- t)
-
-(defvar perl-mode-syntax-table nil
- "Syntax table in use in perl-mode buffers.")
-
-(if perl-mode-syntax-table
- ()
- (setq perl-mode-syntax-table (make-syntax-table (standard-syntax-table)))
- (modify-syntax-entry ?\n ">" perl-mode-syntax-table)
- (modify-syntax-entry ?# "<" perl-mode-syntax-table)
- (modify-syntax-entry ?$ "/" perl-mode-syntax-table)
- (modify-syntax-entry ?% "." perl-mode-syntax-table)
- (modify-syntax-entry ?& "." perl-mode-syntax-table)
- (modify-syntax-entry ?\' "\"" perl-mode-syntax-table)
- (modify-syntax-entry ?* "." perl-mode-syntax-table)
- (modify-syntax-entry ?+ "." perl-mode-syntax-table)
- (modify-syntax-entry ?- "." perl-mode-syntax-table)
- (modify-syntax-entry ?/ "." perl-mode-syntax-table)
- (modify-syntax-entry ?< "." perl-mode-syntax-table)
- (modify-syntax-entry ?= "." perl-mode-syntax-table)
- (modify-syntax-entry ?> "." perl-mode-syntax-table)
- (modify-syntax-entry ?\\ "\\" perl-mode-syntax-table)
- (modify-syntax-entry ?` "\"" perl-mode-syntax-table)
- (modify-syntax-entry ?| "." perl-mode-syntax-table)
-)
-
-(defconst perl-indent-level 4
- "*Indentation of Perl statements with respect to containing block.")
-(defconst perl-continued-statement-offset 4
- "*Extra indent for lines not starting new statements.")
-(defconst perl-continued-brace-offset -4
- "*Extra indent for substatements that start with open-braces.
-This is in addition to perl-continued-statement-offset.")
-(defconst perl-brace-offset 0
- "*Extra indentation for braces, compared with other text in same context.")
-(defconst perl-brace-imaginary-offset 0
- "*Imagined indentation of an open brace that actually follows a statement.")
-(defconst perl-label-offset -2
- "*Offset of Perl label lines relative to usual indentation.")
-
-(defconst perl-tab-always-indent t
- "*Non-nil means TAB in Perl mode should always indent the current line,
-regardless of where in the line point is when the TAB command is used.")
-
-(defconst perl-tab-to-comment t
- "*Non-nil means that for lines which don't need indenting, TAB will
-either indent an existing comment, move to end-of-line, or if at end-of-line
-already, create a new comment.")
-
-(defconst perl-nochange ";?#\\|\f\\|\\s(\\|\\(\\w\\|\\s_\\)+:"
- "*Lines starting with this regular expression will not be auto-indented.")
-
-(defun perl-mode ()
- "Major mode for editing Perl code.
-Expression and list commands understand all Perl brackets.
-Tab indents for Perl code.
-Comments are delimited with # ... \\n.
-Paragraphs are separated by blank lines only.
-Delete converts tabs to spaces as it moves back.
-\\{perl-mode-map}
-Variables controlling indentation style:
- perl-tab-always-indent
- Non-nil means TAB in Perl mode should always indent the current line,
- regardless of where in the line point is when the TAB command is used.
- perl-tab-to-comment
- Non-nil means that for lines which don't need indenting, TAB will
- either delete an empty comment, indent an existing comment, move
- to end-of-line, or if at end-of-line already, create a new comment.
- perl-nochange
- Lines starting with this regular expression will not be auto-indented.
- perl-indent-level
- Indentation of Perl statements within surrounding block.
- The surrounding block's indentation is the indentation
- of the line on which the open-brace appears.
- perl-continued-statement-offset
- Extra indentation given to a substatement, such as the
- then-clause of an if or body of a while.
- perl-continued-brace-offset
- Extra indentation given to a brace that starts a substatement.
- This is in addition to perl-continued-statement-offset.
- perl-brace-offset
- Extra indentation for line if it starts with an open brace.
- perl-brace-imaginary-offset
- An open brace following other text is treated as if it were
- this far to the right of the start of its line.
- perl-label-offset
- Extra indentation for line that is a label.
-
-Various indentation styles: K&R BSD BLK GNU LW
- perl-indent-level 5 8 0 2 4
- perl-continued-statement-offset 5 8 4 2 4
- perl-continued-brace-offset 0 0 0 0 -4
- perl-brace-offset -5 -8 0 0 0
- perl-brace-imaginary-offset 0 0 4 0 0
- perl-label-offset -5 -8 -2 -2 -2
-
-Turning on Perl mode calls the value of the variable perl-mode-hook with no
-args, if that value is non-nil."
- (interactive)
- (kill-all-local-variables)
- (use-local-map perl-mode-map)
- (setq major-mode 'perl-mode)
- (setq mode-name "Perl")
- (setq local-abbrev-table perl-mode-abbrev-table)
- (set-syntax-table perl-mode-syntax-table)
- (make-local-variable 'paragraph-start)
- (setq paragraph-start (concat "^$\\|" page-delimiter))
- (make-local-variable 'paragraph-separate)
- (setq paragraph-separate paragraph-start)
- (make-local-variable 'paragraph-ignore-fill-prefix)
- (setq paragraph-ignore-fill-prefix t)
- (make-local-variable 'indent-line-function)
- (setq indent-line-function 'perl-indent-line)
- (make-local-variable 'require-final-newline)
- (setq require-final-newline t)
- (make-local-variable 'comment-start)
- (setq comment-start "# ")
- (make-local-variable 'comment-end)
- (setq comment-end "")
- (make-local-variable 'comment-column)
- (setq comment-column 32)
- (make-local-variable 'comment-start-skip)
- (setq comment-start-skip "\\(^\\|\\s-\\);?#+ *")
- (make-local-variable 'comment-indent-hook)
- (setq comment-indent-hook 'perl-comment-indent)
- (make-local-variable 'parse-sexp-ignore-comments)
- (setq parse-sexp-ignore-comments nil)
- (run-hooks 'perl-mode-hook))
-
-;; This is used by indent-for-comment
-;; to decide how much to indent a comment in Perl code
-;; based on its context.
-(defun perl-comment-indent ()
- (if (and (bolp) (not (eolp)))
- 0 ;Existing comment at bol stays there.
- (save-excursion
- (skip-chars-backward " \t")
- (max (1+ (current-column)) ;Else indent at comment column
- comment-column)))) ; except leave at least one space.
-
-(defun electric-perl-terminator (arg)
- "Insert character. If at end-of-line, and not in a comment or a quote,
-correct the line's indentation."
- (interactive "P")
- (let ((insertpos (point)))
- (and (not arg) ; decide whether to indent
- (eolp)
- (save-excursion
- (beginning-of-line)
- (and (not ; eliminate comments quickly
- (re-search-forward comment-start-skip insertpos t))
- (or (/= last-command-char ?:)
- ;; Colon is special only after a label ....
- (looking-at "\\s-*\\(\\w\\|\\s_\\)+$"))
- (let ((pps (parse-partial-sexp
- (perl-beginning-of-function) insertpos)))
- (not (or (nth 3 pps) (nth 4 pps) (nth 5 pps))))))
- (progn ; must insert, indent, delete
- (insert-char last-command-char 1)
- (perl-indent-line)
- (delete-char -1))))
- (self-insert-command (prefix-numeric-value arg)))
-
-;; not used anymore, but may be useful someday:
-;;(defun perl-inside-parens-p ()
-;; (condition-case ()
-;; (save-excursion
-;; (save-restriction
-;; (narrow-to-region (point)
-;; (perl-beginning-of-function))
-;; (goto-char (point-max))
-;; (= (char-after (or (scan-lists (point) -1 1) (point-min))) ?\()))
-;; (error nil)))
-
-(defun perl-indent-command (&optional arg)
- "Indent current line as Perl code, or optionally, insert a tab character.
-
-With an argument, indent the current line, regardless of other options.
-
-If perl-tab-always-indent is nil and point is not in the indentation
-area at the beginning of the line, simply insert a tab.
-
-Otherwise, indent the current line. If point was within the indentation
-area it is moved to the end of the indentation area. If the line was
-already indented properly and point was not within the indentation area,
-and if perl-tab-to-comment is non-nil (the default), then do the first
-possible action from the following list:
-
- 1) delete an empty comment
- 2) move forward to start of comment, indenting if necessary
- 3) move forward to end of line
- 4) create an empty comment
- 5) move backward to start of comment, indenting if necessary."
- (interactive "P")
- (if arg ; If arg, just indent this line
- (perl-indent-line "\f")
- (if (and (not perl-tab-always-indent)
- (<= (current-column) (current-indentation)))
- (insert-tab)
- (let (bof lsexp delta (oldpnt (point)))
- (beginning-of-line)
- (setq lsexp (point))
- (setq bof (perl-beginning-of-function))
- (goto-char oldpnt)
- (setq delta (perl-indent-line "\f\\|;?#" bof))
- (and perl-tab-to-comment
- (= oldpnt (point)) ; done if point moved
- (if (listp delta) ; if line starts in a quoted string
- (setq lsexp (or (nth 2 delta) bof))
- (= delta 0)) ; done if indenting occurred
- (let (eol state)
- (end-of-line)
- (setq eol (point))
- (if (= (char-after bof) ?=)
- (if (= oldpnt eol)
- (message "In a format statement"))
- (setq state (parse-partial-sexp lsexp eol))
- (if (nth 3 state)
- (if (= oldpnt eol) ; already at eol in a string
- (message "In a string which starts with a %c."
- (nth 3 state)))
- (if (not (nth 4 state))
- (if (= oldpnt eol) ; no comment, create one?
- (indent-for-comment))
- (beginning-of-line)
- (if (re-search-forward comment-start-skip eol 'move)
- (if (eolp)
- (progn ; kill existing comment
- (goto-char (match-beginning 0))
- (skip-chars-backward " \t")
- (kill-region (point) eol))
- (if (or (< oldpnt (point)) (= oldpnt eol))
- (indent-for-comment) ; indent existing comment
- (end-of-line)))
- (if (/= oldpnt eol)
- (end-of-line)
- (message "Use backslash to quote # characters.")
- (ding t))))))))))))
-
-(defun perl-indent-line (&optional nochange parse-start)
- "Indent current line as Perl code. Return the amount the indentation
-changed by, or (parse-state) if line starts in a quoted string."
- (let ((case-fold-search nil)
- (pos (- (point-max) (point)))
- (bof (or parse-start (save-excursion (perl-beginning-of-function))))
- beg indent shift-amt)
- (beginning-of-line)
- (setq beg (point))
- (setq shift-amt
- (cond ((= (char-after bof) ?=) 0)
- ((listp (setq indent (calculate-perl-indent bof))) indent)
- ((looking-at (or nochange perl-nochange)) 0)
- (t
- (skip-chars-forward " \t\f")
- (cond ((looking-at "\\(\\w\\|\\s_\\)+:")
- (setq indent (max 1 (+ indent perl-label-offset))))
- ((= (following-char) ?})
- (setq indent (- indent perl-indent-level)))
- ((= (following-char) ?{)
- (setq indent (+ indent perl-brace-offset))))
- (- indent (current-column)))))
- (skip-chars-forward " \t\f")
- (if (and (numberp shift-amt) (/= 0 shift-amt))
- (progn (delete-region beg (point))
- (indent-to indent)))
- ;; If initial point was within line's indentation,
- ;; position after the indentation. Else stay at same point in text.
- (if (> (- (point-max) pos) (point))
- (goto-char (- (point-max) pos)))
- shift-amt))
-
-(defun calculate-perl-indent (&optional parse-start)
- "Return appropriate indentation for current line as Perl code.
-In usual case returns an integer: the column to indent to.
-Returns (parse-state) if line starts inside a string."
- (save-excursion
- (beginning-of-line)
- (let ((indent-point (point))
- (case-fold-search nil)
- (colon-line-end 0)
- state containing-sexp)
- (if parse-start ;used to avoid searching
- (goto-char parse-start)
- (perl-beginning-of-function))
- (while (< (point) indent-point) ;repeat until right sexp
- (setq parse-start (point))
- (setq state (parse-partial-sexp (point) indent-point 0))
-; state = (depth_in_parens innermost_containing_list last_complete_sexp
-; string_terminator_or_nil inside_commentp following_quotep
-; minimum_paren-depth_this_scan)
-; Parsing stops if depth in parentheses becomes equal to third arg.
- (setq containing-sexp (nth 1 state)))
- (cond ((nth 3 state) state) ; In a quoted string?
- ((null containing-sexp) ; Line is at top level.
- (skip-chars-forward " \t\f")
- (if (= (following-char) ?{)
- 0 ; move to beginning of line if it starts a function body
- ;; indent a little if this is a continuation line
- (perl-backward-to-noncomment)
- (if (or (bobp)
- (memq (preceding-char) '(?\; ?\})))
- 0 perl-continued-statement-offset)))
- ((/= (char-after containing-sexp) ?{)
- ;; line is expression, not statement:
- ;; indent to just after the surrounding open.
- (goto-char (1+ containing-sexp))
- (current-column))
- (t
- ;; Statement level. Is it a continuation or a new statement?
- ;; Find previous non-comment character.
- (perl-backward-to-noncomment)
- ;; Back up over label lines, since they don't
- ;; affect whether our line is a continuation.
- (while (or (eq (preceding-char) ?\,)
- (and (eq (preceding-char) ?:)
- (memq (char-syntax (char-after (- (point) 2)))
- '(?w ?_))))
- (if (eq (preceding-char) ?\,)
- (perl-backward-to-start-of-continued-exp containing-sexp))
- (beginning-of-line)
- (perl-backward-to-noncomment))
- ;; Now we get the answer.
- (if (not (memq (preceding-char) '(?\; ?\} ?\{)))
- ;; This line is continuation of preceding line's statement;
- ;; indent perl-continued-statement-offset more than the
- ;; previous line of the statement.
- (progn
- (perl-backward-to-start-of-continued-exp containing-sexp)
- (+ perl-continued-statement-offset (current-column)
- (if (save-excursion (goto-char indent-point)
- (looking-at "[ \t]*{"))
- perl-continued-brace-offset 0)))
- ;; This line starts a new statement.
- ;; Position at last unclosed open.
- (goto-char containing-sexp)
- (or
- ;; If open paren is in col 0, close brace is special
- (and (bolp)
- (save-excursion (goto-char indent-point)
- (looking-at "[ \t]*}"))
- perl-indent-level)
- ;; Is line first statement after an open-brace?
- ;; If no, find that first statement and indent like it.
- (save-excursion
- (forward-char 1)
- ;; Skip over comments and labels following openbrace.
- (while (progn
- (skip-chars-forward " \t\f\n")
- (cond ((looking-at ";?#")
- (forward-line 1) t)
- ((looking-at "\\(\\w\\|\\s_\\)+:")
- (save-excursion
- (end-of-line)
- (setq colon-line-end (point)))
- (search-forward ":")))))
- ;; The first following code counts
- ;; if it is before the line we want to indent.
- (and (< (point) indent-point)
- (if (> colon-line-end (point))
- (- (current-indentation) perl-label-offset)
- (current-column))))
- ;; If no previous statement,
- ;; indent it relative to line brace is on.
- ;; For open paren in column zero, don't let statement
- ;; start there too. If perl-indent-level is zero,
- ;; use perl-brace-offset + perl-continued-statement-offset
- ;; For open-braces not the first thing in a line,
- ;; add in perl-brace-imaginary-offset.
- (+ (if (and (bolp) (zerop perl-indent-level))
- (+ perl-brace-offset perl-continued-statement-offset)
- perl-indent-level)
- ;; Move back over whitespace before the openbrace.
- ;; If openbrace is not first nonwhite thing on the line,
- ;; add the perl-brace-imaginary-offset.
- (progn (skip-chars-backward " \t")
- (if (bolp) 0 perl-brace-imaginary-offset))
- ;; If the openbrace is preceded by a parenthesized exp,
- ;; move to the beginning of that;
- ;; possibly a different line
- (progn
- (if (eq (preceding-char) ?\))
- (forward-sexp -1))
- ;; Get initial indentation of the line we are on.
- (current-indentation))))))))))
-
-(defun perl-backward-to-noncomment ()
- "Move point backward to after the first non-white-space, skipping comments."
- (interactive)
- (let (opoint stop)
- (while (not stop)
- (setq opoint (point))
- (beginning-of-line)
- (if (re-search-forward comment-start-skip opoint 'move 1)
- (progn (goto-char (match-end 1))
- (skip-chars-forward ";")))
- (skip-chars-backward " \t\f")
- (setq stop (or (bobp)
- (not (bolp))
- (forward-char -1))))))
-
-(defun perl-backward-to-start-of-continued-exp (lim)
- (if (= (preceding-char) ?\))
- (forward-sexp -1))
- (beginning-of-line)
- (if (<= (point) lim)
- (goto-char (1+ lim)))
- (skip-chars-forward " \t\f"))
-
-;; note: this may be slower than the c-mode version, but I can understand it.
-(defun indent-perl-exp ()
- "Indent each line of the Perl grouping following point."
- (interactive)
- (let* ((case-fold-search nil)
- (oldpnt (point-marker))
- (bof-mark (save-excursion
- (end-of-line 2)
- (perl-beginning-of-function)
- (point-marker)))
- eol last-mark lsexp-mark delta)
- (if (= (char-after (marker-position bof-mark)) ?=)
- (message "Can't indent a format statement")
- (message "Indenting Perl expression...")
- (save-excursion (end-of-line) (setq eol (point)))
- (save-excursion ; locate matching close paren
- (while (and (not (eobp)) (<= (point) eol))
- (parse-partial-sexp (point) (point-max) 0))
- (setq last-mark (point-marker)))
- (setq lsexp-mark bof-mark)
- (beginning-of-line)
- (while (< (point) (marker-position last-mark))
- (setq delta (perl-indent-line nil (marker-position bof-mark)))
- (if (numberp delta) ; unquoted start-of-line?
- (progn
- (if (eolp)
- (delete-horizontal-space))
- (setq lsexp-mark (point-marker))))
- (end-of-line)
- (setq eol (point))
- (if (nth 4 (parse-partial-sexp (marker-position lsexp-mark) eol))
- (progn ; line ends in a comment
- (beginning-of-line)
- (if (or (not (looking-at "\\s-*;?#"))
- (listp delta)
- (and (/= 0 delta)
- (= (- (current-indentation) delta) comment-column)))
- (if (re-search-forward comment-start-skip eol t)
- (indent-for-comment))))) ; indent existing comment
- (forward-line 1))
- (goto-char (marker-position oldpnt))
- (message "Indenting Perl expression...done"))))
-
-(defun perl-beginning-of-function (&optional arg)
- "Move backward to next beginning-of-function, or as far as possible.
-With argument, repeat that many times; negative args move forward.
-Returns new value of point in all cases."
- (interactive "p")
- (or arg (setq arg 1))
- (if (< arg 0) (forward-char 1))
- (and (/= arg 0)
- (re-search-backward "^\\s(\\|^\\s-*sub\\b[^{]+{\\|^\\s-*format\\b[^=]*=\\|^\\."
- nil 'move arg)
- (goto-char (1- (match-end 0))))
- (point))
-
-;; note: this routine is adapted directly from emacs lisp.el, end-of-defun;
-;; no bugs have been removed :-)
-(defun perl-end-of-function (&optional arg)
- "Move forward to next end-of-function.
-The end of a function is found by moving forward from the beginning of one.
-With argument, repeat that many times; negative args move backward."
- (interactive "p")
- (or arg (setq arg 1))
- (let ((first t))
- (while (and (> arg 0) (< (point) (point-max)))
- (let ((pos (point)) npos)
- (while (progn
- (if (and first
- (progn
- (forward-char 1)
- (perl-beginning-of-function 1)
- (not (bobp))))
- nil
- (or (bobp) (forward-char -1))
- (perl-beginning-of-function -1))
- (setq first nil)
- (forward-list 1)
- (skip-chars-forward " \t")
- (if (looking-at "[#\n]")
- (forward-line 1))
- (<= (point) pos))))
- (setq arg (1- arg)))
- (while (< arg 0)
- (let ((pos (point)))
- (perl-beginning-of-function 1)
- (forward-sexp 1)
- (forward-line 1)
- (if (>= (point) pos)
- (if (progn (perl-beginning-of-function 2) (not (bobp)))
- (progn
- (forward-list 1)
- (skip-chars-forward " \t")
- (if (looking-at "[#\n]")
- (forward-line 1)))
- (goto-char (point-min)))))
- (setq arg (1+ arg)))))
-
-(defun mark-perl-function ()
- "Put mark at end of Perl function, point at beginning."
- (interactive)
- (push-mark (point))
- (perl-end-of-function)
- (push-mark (point))
- (perl-beginning-of-function)
- (backward-paragraph))
-
-;;;;;;;; That's all, folks! ;;;;;;;;;
diff --git a/gnu/usr.bin/perl/emacs/perldb.el b/gnu/usr.bin/perl/emacs/perldb.el
deleted file mode 100644
index 66951be..0000000
--- a/gnu/usr.bin/perl/emacs/perldb.el
+++ /dev/null
@@ -1,423 +0,0 @@
-;; Run perl -d under Emacs
-;; Based on gdb.el, as written by W. Schelter, and modified by rms.
-;; Modified for Perl by Ray Lischner (uunet!mntgfx!lisch), Nov 1990.
-
-;; This file is part of GNU Emacs.
-;; Copyright (C) 1988,1990 Free Software Foundation, Inc.
-
-;; GNU Emacs is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
-;; to anyone for the consequences of using it or for whether it serves
-;; any particular purpose or works at all, unless he says so in writing.
-;; Refer to the GNU Emacs General Public License for full details.
-
-;; Everyone is granted permission to copy, modify and redistribute GNU
-;; Emacs, but only under the conditions described in the GNU Emacs
-;; General Public License. A copy of this license is supposed to have
-;; been given to you along with GNU Emacs so you can know your rights and
-;; responsibilities. It should be in a file named COPYING. Among other
-;; things, the copyright notice and this notice must be preserved on all
-;; copies.
-
-;; Description of perl -d interface:
-
-;; A facility is provided for the simultaneous display of the source code
-;; in one window, while using perldb to step through a function in the
-;; other. A small arrow in the source window, indicates the current
-;; line.
-
-;; Starting up:
-
-;; In order to use this facility, invoke the command PERLDB to obtain a
-;; shell window with the appropriate command bindings. You will be asked
-;; for the name of a file to run and additional command line arguments.
-;; Perldb will be invoked on this file, in a window named *perldb-foo*
-;; if the file is foo.
-
-;; M-s steps by one line, and redisplays the source file and line.
-
-;; You may easily create additional commands and bindings to interact
-;; with the display. For example to put the perl debugger command n on \M-n
-;; (def-perldb n "\M-n")
-
-;; This causes the emacs command perldb-next to be defined, and runs
-;; perldb-display-frame after the command.
-
-;; perldb-display-frame is the basic display function. It tries to display
-;; in the other window, the file and line corresponding to the current
-;; position in the perldb window. For example after a perldb-step, it would
-;; display the line corresponding to the position for the last step. Or
-;; if you have done a backtrace in the perldb buffer, and move the cursor
-;; into one of the frames, it would display the position corresponding to
-;; that frame.
-
-;; perldb-display-frame is invoked automatically when a filename-and-line-number
-;; appears in the output.
-
-
-(require 'shell)
-
-(defvar perldb-prompt-pattern "^ DB<[0-9]+> "
- "A regexp to recognize the prompt for perldb.")
-
-(defvar perldb-mode-map nil
- "Keymap for perldb-mode.")
-
-(if perldb-mode-map
- nil
- (setq perldb-mode-map (copy-keymap shell-mode-map))
- (define-key perldb-mode-map "\C-l" 'perldb-refresh))
-
-(define-key ctl-x-map " " 'perldb-break)
-(define-key ctl-x-map "&" 'send-perldb-command)
-
-;;Of course you may use `def-perldb' with any other perldb command, including
-;;user defined ones.
-
-(defmacro def-perldb (name key &optional doc)
- (let* ((fun (intern (concat "perldb-" name))))
- (` (progn
- (defun (, fun) (arg)
- (, (or doc ""))
- (interactive "p")
- (perldb-call (if (not (= 1 arg))
- (concat (, name) arg)
- (, name))))
- (define-key perldb-mode-map (, key) (quote (, fun)))))))
-
-(def-perldb "s" "\M-s" "Step one source line with display")
-(def-perldb "n" "\M-n" "Step one source line (skip functions)")
-(def-perldb "c" "\M-c" "Continue with display")
-(def-perldb "r" "\C-c\C-r" "Return from current subroutine")
-(def-perldb "A" "\C-c\C-a" "Delete all actions")
-
-(defun perldb-mode ()
- "Major mode for interacting with an inferior Perl debugger process.
-The following commands are available:
-
-\\{perldb-mode-map}
-
-\\[perldb-display-frame] displays in the other window
-the last line referred to in the perldb buffer.
-
-\\[perldb-s],\\[perldb-n], and \\[perldb-n] in the perldb window,
-call perldb to step, next or continue and then update the other window
-with the current file and position.
-
-If you are in a source file, you may select a point to break
-at, by doing \\[perldb-break].
-
-Commands:
-Many commands are inherited from shell mode.
-Additionally we have:
-
-\\[perldb-display-frame] display frames file in other window
-\\[perldb-s] advance one line in program
-\\[perldb-n] advance one line in program (skip over calls).
-\\[send-perldb-command] used for special printing of an arg at the current point.
-C-x SPACE sets break point at current line."
- (interactive)
- (kill-all-local-variables)
- (setq major-mode 'perldb-mode)
- (setq mode-name "Inferior Perl")
- (setq mode-line-process '(": %s"))
- (use-local-map perldb-mode-map)
- (make-local-variable 'last-input-start)
- (setq last-input-start (make-marker))
- (make-local-variable 'last-input-end)
- (setq last-input-end (make-marker))
- (make-local-variable 'perldb-last-frame)
- (setq perldb-last-frame nil)
- (make-local-variable 'perldb-last-frame-displayed-p)
- (setq perldb-last-frame-displayed-p t)
- (make-local-variable 'perldb-delete-prompt-marker)
- (setq perldb-delete-prompt-marker nil)
- (make-local-variable 'perldb-filter-accumulator)
- (setq perldb-filter-accumulator nil)
- (make-local-variable 'shell-prompt-pattern)
- (setq shell-prompt-pattern perldb-prompt-pattern)
- (run-hooks 'shell-mode-hook 'perldb-mode-hook))
-
-(defvar current-perldb-buffer nil)
-
-(defvar perldb-command-name "perl"
- "Pathname for executing perl -d.")
-
-(defun end-of-quoted-arg (argstr start end)
- (let* ((chr (substring argstr start (1+ start)))
- (idx (string-match (concat "[^\\]" chr) argstr (1+ start))))
- (and idx (1+ idx))
- )
-)
-
-(defun parse-args-helper (arglist argstr start end)
- (while (and (< start end) (string-match "[ \t\n\f\r\b]"
- (substring argstr start (1+ start))))
- (setq start (1+ start)))
- (cond
- ((= start end) arglist)
- ((string-match "[\"']" (substring argstr start (1+ start)))
- (let ((next (end-of-quoted-arg argstr start end)))
- (parse-args-helper (cons (substring argstr (1+ start) next) arglist)
- argstr (1+ next) end)))
- (t (let ((next (string-match "[ \t\n\f\b\r]" argstr start)))
- (if next
- (parse-args-helper (cons (substring argstr start next) arglist)
- argstr (1+ next) end)
- (cons (substring argstr start) arglist))))
- )
- )
-
-(defun parse-args (args)
- "Extract arguments from a string ARGS.
-White space separates arguments, with single or double quotes
-used to protect spaces. A list of strings is returned, e.g.,
-(parse-args \"foo bar 'two args'\") => (\"foo\" \"bar\" \"two args\")."
- (nreverse (parse-args-helper '() args 0 (length args)))
-)
-
-(defun perldb (path args)
- "Run perldb on program FILE in buffer *perldb-FILE*.
-The default directory for the current buffer becomes the initial
-working directory, by analogy with gdb . If you wish to change this, use
-the Perl command `chdir(DIR)'."
- (interactive "FRun perl -d on file: \nsCommand line arguments: ")
- (setq path (expand-file-name path))
- (let ((file (file-name-nondirectory path))
- (dir default-directory))
- (switch-to-buffer (concat "*perldb-" file "*"))
- (setq default-directory dir)
- (or (bolp) (newline))
- (insert "Current directory is " default-directory "\n")
- (apply 'make-shell
- (concat "perldb-" file) perldb-command-name nil "-d" path "-emacs"
- (parse-args args))
- (perldb-mode)
- (set-process-filter (get-buffer-process (current-buffer)) 'perldb-filter)
- (set-process-sentinel (get-buffer-process (current-buffer)) 'perldb-sentinel)
- (perldb-set-buffer)))
-
-(defun perldb-set-buffer ()
- (cond ((eq major-mode 'perldb-mode)
- (setq current-perldb-buffer (current-buffer)))))
-
-;; This function is responsible for inserting output from Perl
-;; into the buffer.
-;; Aside from inserting the text, it notices and deletes
-;; each filename-and-line-number;
-;; that Perl prints to identify the selected frame.
-;; It records the filename and line number, and maybe displays that file.
-(defun perldb-filter (proc string)
- (let ((inhibit-quit t))
- (if perldb-filter-accumulator
- (perldb-filter-accumulate-marker proc
- (concat perldb-filter-accumulator string))
- (perldb-filter-scan-input proc string))))
-
-(defun perldb-filter-accumulate-marker (proc string)
- (setq perldb-filter-accumulator nil)
- (if (> (length string) 1)
- (if (= (aref string 1) ?\032)
- (let ((end (string-match "\n" string)))
- (if end
- (progn
- (let* ((first-colon (string-match ":" string 2))
- (second-colon
- (string-match ":" string (1+ first-colon))))
- (setq perldb-last-frame
- (cons (substring string 2 first-colon)
- (string-to-int
- (substring string (1+ first-colon)
- second-colon)))))
- (setq perldb-last-frame-displayed-p nil)
- (perldb-filter-scan-input proc
- (substring string (1+ end))))
- (setq perldb-filter-accumulator string)))
- (perldb-filter-insert proc "\032")
- (perldb-filter-scan-input proc (substring string 1)))
- (setq perldb-filter-accumulator string)))
-
-(defun perldb-filter-scan-input (proc string)
- (if (equal string "")
- (setq perldb-filter-accumulator nil)
- (let ((start (string-match "\032" string)))
- (if start
- (progn (perldb-filter-insert proc (substring string 0 start))
- (perldb-filter-accumulate-marker proc
- (substring string start)))
- (perldb-filter-insert proc string)))))
-
-(defun perldb-filter-insert (proc string)
- (let ((moving (= (point) (process-mark proc)))
- (output-after-point (< (point) (process-mark proc)))
- (old-buffer (current-buffer))
- start)
- (set-buffer (process-buffer proc))
- (unwind-protect
- (save-excursion
- ;; Insert the text, moving the process-marker.
- (goto-char (process-mark proc))
- (setq start (point))
- (insert string)
- (set-marker (process-mark proc) (point))
- (perldb-maybe-delete-prompt)
- ;; Check for a filename-and-line number.
- (perldb-display-frame
- ;; Don't display the specified file
- ;; unless (1) point is at or after the position where output appears
- ;; and (2) this buffer is on the screen.
- (or output-after-point
- (not (get-buffer-window (current-buffer))))
- ;; Display a file only when a new filename-and-line-number appears.
- t))
- (set-buffer old-buffer))
- (if moving (goto-char (process-mark proc)))))
-
-(defun perldb-sentinel (proc msg)
- (cond ((null (buffer-name (process-buffer proc)))
- ;; buffer killed
- ;; Stop displaying an arrow in a source file.
- (setq overlay-arrow-position nil)
- (set-process-buffer proc nil))
- ((memq (process-status proc) '(signal exit))
- ;; Stop displaying an arrow in a source file.
- (setq overlay-arrow-position nil)
- ;; Fix the mode line.
- (setq mode-line-process
- (concat ": "
- (symbol-name (process-status proc))))
- (let* ((obuf (current-buffer)))
- ;; save-excursion isn't the right thing if
- ;; process-buffer is current-buffer
- (unwind-protect
- (progn
- ;; Write something in *compilation* and hack its mode line,
- (set-buffer (process-buffer proc))
- ;; Force mode line redisplay soon
- (set-buffer-modified-p (buffer-modified-p))
- (if (eobp)
- (insert ?\n mode-name " " msg)
- (save-excursion
- (goto-char (point-max))
- (insert ?\n mode-name " " msg)))
- ;; If buffer and mode line will show that the process
- ;; is dead, we can delete it now. Otherwise it
- ;; will stay around until M-x list-processes.
- (delete-process proc))
- ;; Restore old buffer, but don't restore old point
- ;; if obuf is the perldb buffer.
- (set-buffer obuf))))))
-
-
-(defun perldb-refresh ()
- "Fix up a possibly garbled display, and redraw the arrow."
- (interactive)
- (redraw-display)
- (perldb-display-frame))
-
-(defun perldb-display-frame (&optional nodisplay noauto)
- "Find, obey and delete the last filename-and-line marker from PERLDB.
-The marker looks like \\032\\032FILENAME:LINE:CHARPOS\\n.
-Obeying it means displaying in another window the specified file and line."
- (interactive)
- (perldb-set-buffer)
- (and perldb-last-frame (not nodisplay)
- (or (not perldb-last-frame-displayed-p) (not noauto))
- (progn (perldb-display-line (car perldb-last-frame) (cdr perldb-last-frame))
- (setq perldb-last-frame-displayed-p t))))
-
-;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen
-;; and that its line LINE is visible.
-;; Put the overlay-arrow on the line LINE in that buffer.
-
-(defun perldb-display-line (true-file line)
- (let* ((buffer (find-file-noselect true-file))
- (window (display-buffer buffer t))
- (pos))
- (save-excursion
- (set-buffer buffer)
- (save-restriction
- (widen)
- (goto-line line)
- (setq pos (point))
- (setq overlay-arrow-string "=>")
- (or overlay-arrow-position
- (setq overlay-arrow-position (make-marker)))
- (set-marker overlay-arrow-position (point) (current-buffer)))
- (cond ((or (< pos (point-min)) (> pos (point-max)))
- (widen)
- (goto-char pos))))
- (set-window-point window overlay-arrow-position)))
-
-(defun perldb-call (command)
- "Invoke perldb COMMAND displaying source in other window."
- (interactive)
- (goto-char (point-max))
- (setq perldb-delete-prompt-marker (point-marker))
- (perldb-set-buffer)
- (send-string (get-buffer-process current-perldb-buffer)
- (concat command "\n")))
-
-(defun perldb-maybe-delete-prompt ()
- (if (and perldb-delete-prompt-marker
- (> (point-max) (marker-position perldb-delete-prompt-marker)))
- (let (start)
- (goto-char perldb-delete-prompt-marker)
- (setq start (point))
- (beginning-of-line)
- (delete-region (point) start)
- (setq perldb-delete-prompt-marker nil))))
-
-(defun perldb-break ()
- "Set PERLDB breakpoint at this source line."
- (interactive)
- (let ((line (save-restriction
- (widen)
- (1+ (count-lines 1 (point))))))
- (send-string (get-buffer-process current-perldb-buffer)
- (concat "b " line "\n"))))
-
-(defun perldb-read-token()
- "Return a string containing the token found in the buffer at point.
-A token can be a number or an identifier. If the token is a name prefaced
-by `$', `@', or `%', the leading character is included in the token."
- (save-excursion
- (let (begin)
- (or (looking-at "[$@%]")
- (re-search-backward "[^a-zA-Z_0-9]" (point-min) 'move))
- (setq begin (point))
- (or (looking-at "[$@%]") (setq begin (+ begin 1)))
- (forward-char 1)
- (buffer-substring begin
- (if (re-search-forward "[^a-zA-Z_0-9]"
- (point-max) 'move)
- (- (point) 1)
- (point)))
-)))
-
-(defvar perldb-commands nil
- "List of strings or functions used by send-perldb-command.
-It is for customization by the user.")
-
-(defun send-perldb-command (arg)
- "Issue a Perl debugger command selected by the prefix arg. A numeric
-arg selects the ARG'th member COMMAND of the list perldb-commands.
-The token under the cursor is passed to the command. If COMMAND is a
-string, (format COMMAND TOKEN) is inserted at the end of the perldb
-buffer, otherwise (funcall COMMAND TOKEN) is inserted. If there is
-no such COMMAND, then the token itself is inserted. For example,
-\"p %s\" is a possible string to be a member of perldb-commands,
-or \"p $ENV{%s}\"."
- (interactive "P")
- (let (comm token)
- (if arg (setq comm (nth arg perldb-commands)))
- (setq token (perldb-read-token))
- (if (eq (current-buffer) current-perldb-buffer)
- (set-mark (point)))
- (cond (comm
- (setq comm
- (if (stringp comm) (format comm token) (funcall comm token))))
- (t (setq comm token)))
- (switch-to-buffer-other-window current-perldb-buffer)
- (goto-char (dot-max))
- (insert-string comm)))
diff --git a/gnu/usr.bin/perl/emacs/perldb.pl b/gnu/usr.bin/perl/emacs/perldb.pl
deleted file mode 100644
index 7c9e651..0000000
--- a/gnu/usr.bin/perl/emacs/perldb.pl
+++ /dev/null
@@ -1,568 +0,0 @@
-package DB;
-
-# modified Perl debugger, to be run from Emacs in perldb-mode
-# Ray Lischner (uunet!mntgfx!lisch) as of 5 Nov 1990
-
-$header = '$Header: /home/cvs/386BSD/ports/lang/perl/emacs/perldb.pl,v 1.1.1.1 1993/08/23 21:29:46 nate Exp $';
-#
-# This file is automatically included if you do perl -d.
-# It's probably not useful to include this yourself.
-#
-# Perl supplies the values for @line and %sub. It effectively inserts
-# a do DB'DB(<linenum>); in front of every place that can
-# have a breakpoint. It also inserts a do 'perldb.pl' before the first line.
-#
-# $Log: perldb.pl,v $
-# Revision 1.1.1.1 1993/08/23 21:29:46 nate
-# PERL!
-#
-# Revision 4.0 91/03/20 01:18:58 lwall
-# 4.0 baseline.
-#
-# Revision 3.0.1.6 91/01/11 18:08:58 lwall
-# patch42: @_ couldn't be accessed from debugger
-#
-# Revision 3.0.1.5 90/11/10 01:40:26 lwall
-# patch38: the debugger wouldn't stop correctly or do action routines
-#
-# Revision 3.0.1.4 90/10/15 17:40:38 lwall
-# patch29: added caller
-# patch29: the debugger now understands packages and evals
-# patch29: scripts now run at almost full speed under the debugger
-# patch29: more variables are settable from debugger
-#
-# Revision 3.0.1.3 90/08/09 04:00:58 lwall
-# patch19: debugger now allows continuation lines
-# patch19: debugger can now dump lists of variables
-# patch19: debugger can now add aliases easily from prompt
-#
-# Revision 3.0.1.2 90/03/12 16:39:39 lwall
-# patch13: perl -d didn't format stack traces of *foo right
-# patch13: perl -d wiped out scalar return values of subroutines
-#
-# Revision 3.0.1.1 89/10/26 23:14:02 lwall
-# patch1: RCS expanded an unintended $Header in lib/perldb.pl
-#
-# Revision 3.0 89/10/18 15:19:46 lwall
-# 3.0 baseline
-#
-# Revision 2.0 88/06/05 00:09:45 root
-# Baseline version 2.0.
-#
-#
-
-open(IN, "</dev/tty") || open(IN, "<&STDIN"); # so we don't dingle stdin
-open(OUT,">/dev/tty") || open(OUT, ">&STDOUT"); # so we don't dongle stdout
-select(OUT);
-$| = 1; # for DB'OUT
-select(STDOUT);
-$| = 1; # for real STDOUT
-$sub = '';
-
-# Is Perl being run from Emacs?
-$emacs = $main'ARGV[$[] eq '-emacs';
-shift(@main'ARGV) if $emacs;
-
-$header =~ s/.Header: ([^,]+),v(\s+\S+\s+\S+).*$/$1$2/;
-print OUT "\nLoading DB routines from $header\n\nEnter h for help.\n\n";
-
-sub DB {
- &save;
- ($package, $filename, $line) = caller;
- $usercontext = '($@, $!, $[, $,, $/, $\) = @saved;' .
- "package $package;"; # this won't let them modify, alas
- local(*dbline) = "_<$filename";
- $max = $#dbline;
- if (($stop,$action) = split(/\0/,$dbline{$line})) {
- if ($stop eq '1') {
- $signal |= 1;
- }
- else {
- $evalarg = "\$DB'signal |= do {$stop;}"; &eval;
- $dbline{$line} =~ s/;9($|\0)/$1/;
- }
- }
- if ($single || $trace || $signal) {
- if ($emacs) {
- print OUT "\032\032$filename:$line:0\n";
- } else {
- print OUT "$package'" unless $sub =~ /'/;
- print OUT "$sub($filename:$line):\t",$dbline[$line];
- for ($i = $line + 1; $i <= $max && $dbline[$i] == 0; ++$i) {
- last if $dbline[$i] =~ /^\s*(}|#|\n)/;
- print OUT "$sub($filename:$i):\t",$dbline[$i];
- }
- }
- }
- $evalarg = $action, &eval if $action;
- if ($single || $signal) {
- $evalarg = $pre, &eval if $pre;
- print OUT $#stack . " levels deep in subroutine calls!\n"
- if $single & 4;
- $start = $line;
- while ((print OUT " DB<", $#hist+1, "> "), $cmd=&gets) {
- $single = 0;
- $signal = 0;
- $cmd eq '' && exit 0;
- chop($cmd);
- $cmd =~ s/\\$// && do {
- print OUT " cont: ";
- $cmd .= &gets;
- redo;
- };
- $cmd =~ /^q$/ && exit 0;
- $cmd =~ /^$/ && ($cmd = $laststep);
- push(@hist,$cmd) if length($cmd) > 1;
- ($i) = split(/\s+/,$cmd);
- eval "\$cmd =~ $alias{$i}", print OUT $@ if $alias{$i};
- $cmd =~ /^h$/ && do {
- print OUT "
-T Stack trace.
-s Single step.
-n Next, steps over subroutine calls.
-r Return from current subroutine.
-c [line] Continue; optionally inserts a one-time-only breakpoint
- at the specified line.
-<CR> Repeat last n or s.
-l min+incr List incr+1 lines starting at min.
-l min-max List lines.
-l line List line;
-l List next window.
-- List previous window.
-w line List window around line.
-l subname List subroutine.
-f filename Switch to filename.
-/pattern/ Search forwards for pattern; final / is optional.
-?pattern? Search backwards for pattern.
-L List breakpoints and actions.
-S List subroutine names.
-t Toggle trace mode.
-b [line] [condition]
- Set breakpoint; line defaults to the current execution line;
- condition breaks if it evaluates to true, defaults to \'1\'.
-b subname [condition]
- Set breakpoint at first line of subroutine.
-d [line] Delete breakpoint.
-D Delete all breakpoints.
-a [line] command
- Set an action to be done before the line is executed.
- Sequence is: check for breakpoint, print line if necessary,
- do action, prompt user if breakpoint or step, evaluate line.
-A Delete all actions.
-V [pkg [vars]] List some (default all) variables in package (default current).
-X [vars] Same as \"V currentpackage [vars]\".
-< command Define command before prompt.
-| command Define command after prompt.
-! number Redo command (default previous command).
-! -number Redo number\'th to last command.
-H -number Display last number commands (default all).
-q or ^D Quit.
-p expr Same as \"print DB'OUT expr\" in current package.
-= [alias value] Define a command alias, or list current aliases.
-command Execute as a perl statement in current package.
-
-";
- next; };
- $cmd =~ /^t$/ && do {
- $trace = !$trace;
- print OUT "Trace = ".($trace?"on":"off")."\n";
- next; };
- $cmd =~ /^S$/ && do {
- foreach $subname (sort(keys %sub)) {
- print OUT $subname,"\n";
- }
- next; };
- $cmd =~ s/^X\b/V $package/;
- $cmd =~ /^V$/ && do {
- $cmd = 'V $package'; };
- $cmd =~ /^V\s*(\S+)\s*(.*)/ && do {
- $packname = $1;
- @vars = split(' ',$2);
- do 'dumpvar.pl' unless defined &main'dumpvar;
- if (defined &main'dumpvar) {
- &main'dumpvar($packname,@vars);
- }
- else {
- print DB'OUT "dumpvar.pl not available.\n";
- }
- next; };
- $cmd =~ /^f\s*(.*)/ && do {
- $file = $1;
- if (!$file) {
- print OUT "The old f command is now the r command.\n";
- print OUT "The new f command switches filenames.\n";
- next;
- }
- if (!defined $_main{'_<' . $file}) {
- if (($try) = grep(m#^_<.*$file#, keys %_main)) {
- $file = substr($try,2);
- print "\n$file:\n";
- }
- }
- if (!defined $_main{'_<' . $file}) {
- print OUT "There's no code here anything matching $file.\n";
- next;
- }
- elsif ($file ne $filename) {
- *dbline = "_<$file";
- $max = $#dbline;
- $filename = $file;
- $start = 1;
- $cmd = "l";
- } };
- $cmd =~ /^l\s*(['A-Za-z_]['\w]*)/ && do {
- $subname = $1;
- $subname = "main'" . $subname unless $subname =~ /'/;
- $subname = "main" . $subname if substr($subname,0,1) eq "'";
- ($file,$subrange) = split(/:/,$sub{$subname});
- if ($file ne $filename) {
- *dbline = "_<$file";
- $max = $#dbline;
- $filename = $file;
- }
- if ($subrange) {
- if (eval($subrange) < -$window) {
- $subrange =~ s/-.*/+/;
- }
- $cmd = "l $subrange";
- } else {
- print OUT "Subroutine $1 not found.\n";
- next;
- } };
- $cmd =~ /^w\s*(\d*)$/ && do {
- $incr = $window - 1;
- $start = $1 if $1;
- $start -= $preview;
- $cmd = 'l ' . $start . '-' . ($start + $incr); };
- $cmd =~ /^-$/ && do {
- $incr = $window - 1;
- $cmd = 'l ' . ($start-$window*2) . '+'; };
- $cmd =~ /^l$/ && do {
- $incr = $window - 1;
- $cmd = 'l ' . $start . '-' . ($start + $incr); };
- $cmd =~ /^l\s*(\d*)\+(\d*)$/ && do {
- $start = $1 if $1;
- $incr = $2;
- $incr = $window - 1 unless $incr;
- $cmd = 'l ' . $start . '-' . ($start + $incr); };
- $cmd =~ /^l\s*(([\d\$\.]+)([-,]([\d\$\.]+))?)?/ && do {
- $end = (!$2) ? $max : ($4 ? $4 : $2);
- $end = $max if $end > $max;
- $i = $2;
- $i = $line if $i eq '.';
- $i = 1 if $i < 1;
- if ($emacs) {
- print OUT "\032\032$filename:$i:0\n";
- $i = $end;
- } else {
- for (; $i <= $end; $i++) {
- print OUT "$i:\t", $dbline[$i];
- last if $signal;
- }
- }
- $start = $i; # remember in case they want more
- $start = $max if $start > $max;
- next; };
- $cmd =~ /^D$/ && do {
- print OUT "Deleting all breakpoints...\n";
- for ($i = 1; $i <= $max ; $i++) {
- if (defined $dbline{$i}) {
- $dbline{$i} =~ s/^[^\0]+//;
- if ($dbline{$i} =~ s/^\0?$//) {
- delete $dbline{$i};
- }
- }
- }
- next; };
- $cmd =~ /^L$/ && do {
- for ($i = 1; $i <= $max; $i++) {
- if (defined $dbline{$i}) {
- print OUT "$i:\t", $dbline[$i];
- ($stop,$action) = split(/\0/, $dbline{$i});
- print OUT " break if (", $stop, ")\n"
- if $stop;
- print OUT " action: ", $action, "\n"
- if $action;
- last if $signal;
- }
- }
- next; };
- $cmd =~ /^b\s*(['A-Za-z_]['\w]*)\s*(.*)/ && do {
- $subname = $1;
- $cond = $2 || '1';
- $subname = "$package'" . $subname unless $subname =~ /'/;
- $subname = "main" . $subname if substr($subname,0,1) eq "'";
- ($filename,$i) = split(/[:-]/, $sub{$subname});
- if ($i) {
- *dbline = "_<$filename";
- ++$i while $dbline[$i] == 0 && $i < $#dbline;
- $dbline{$i} =~ s/^[^\0]*/$cond/;
- } else {
- print OUT "Subroutine $subname not found.\n";
- }
- next; };
- $cmd =~ /^b\s*(\d*)\s*(.*)/ && do {
- $i = ($1?$1:$line);
- $cond = $2 || '1';
- if ($dbline[$i] == 0) {
- print OUT "Line $i not breakable.\n";
- } else {
- $dbline{$i} =~ s/^[^\0]*/$cond/;
- }
- next; };
- $cmd =~ /^d\s*(\d+)?/ && do {
- $i = ($1?$1:$line);
- $dbline{$i} =~ s/^[^\0]*//;
- delete $dbline{$i} if $dbline{$i} eq '';
- next; };
- $cmd =~ /^A$/ && do {
- for ($i = 1; $i <= $max ; $i++) {
- if (defined $dbline{$i}) {
- $dbline{$i} =~ s/\0[^\0]*//;
- delete $dbline{$i} if $dbline{$i} eq '';
- }
- }
- next; };
- $cmd =~ /^<\s*(.*)/ && do {
- $pre = do action($1);
- next; };
- $cmd =~ /^>\s*(.*)/ && do {
- $post = do action($1);
- next; };
- $cmd =~ /^a\s*(\d+)(\s+(.*))?/ && do {
- $i = $1;
- if ($dbline[$i] == 0) {
- print OUT "Line $i may not have an action.\n";
- } else {
- $dbline{$i} =~ s/\0[^\0]*//;
- $dbline{$i} .= "\0" . do action($3);
- }
- next; };
- $cmd =~ /^n$/ && do {
- $single = 2;
- $laststep = $cmd;
- last; };
- $cmd =~ /^s$/ && do {
- $single = 1;
- $laststep = $cmd;
- last; };
- $cmd =~ /^c\s*(\d*)\s*$/ && do {
- $i = $1;
- if ($i) {
- if ($dbline[$i] == 0) {
- print OUT "Line $i not breakable.\n";
- next;
- }
- $dbline{$i} =~ s/(\0|$)/;9$1/; # add one-time-only b.p.
- }
- for ($i=0; $i <= $#stack; ) {
- $stack[$i++] &= ~1;
- }
- last; };
- $cmd =~ /^r$/ && do {
- $stack[$#stack] |= 2;
- last; };
- $cmd =~ /^T$/ && do {
- local($p,$f,$l,$s,$h,$a,@a,@sub);
- for ($i = 1; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
- @a = @args;
- for (@a) {
- if (/^StB\000/ && length($_) == length($_main{'_main'})) {
- $_ = sprintf("%s",$_);
- }
- else {
- s/'/\\'/g;
- s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
- s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
- s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
- }
- }
- $w = $w ? '@ = ' : '$ = ';
- $a = $h ? '(' . join(', ', @a) . ')' : '';
- push(@sub, "$w&$s$a from file $f line $l\n");
- last if $signal;
- }
- for ($i=0; $i <= $#sub; $i++) {
- last if $signal;
- print OUT $sub[$i];
- }
- next; };
- $cmd =~ /^\/(.*)$/ && do {
- $inpat = $1;
- $inpat =~ s:([^\\])/$:$1:;
- if ($inpat ne "") {
- eval '$inpat =~ m'."\n$inpat\n";
- if ($@ ne "") {
- print OUT "$@";
- next;
- }
- $pat = $inpat;
- }
- $end = $start;
- eval '
- for (;;) {
- ++$start;
- $start = 1 if ($start > $max);
- last if ($start == $end);
- if ($dbline[$start] =~ m'."\n$pat\n".'i) {
- if ($emacs) {
- print OUT "\032\032$filename:$start:0\n";
- } else {
- print OUT "$start:\t", $dbline[$start], "\n";
- }
- last;
- }
- } ';
- print OUT "/$pat/: not found\n" if ($start == $end);
- next; };
- $cmd =~ /^\?(.*)$/ && do {
- $inpat = $1;
- $inpat =~ s:([^\\])\?$:$1:;
- if ($inpat ne "") {
- eval '$inpat =~ m'."\n$inpat\n";
- if ($@ ne "") {
- print OUT "$@";
- next;
- }
- $pat = $inpat;
- }
- $end = $start;
- eval '
- for (;;) {
- --$start;
- $start = $max if ($start <= 0);
- last if ($start == $end);
- if ($dbline[$start] =~ m'."\n$pat\n".'i) {
- if ($emacs) {
- print OUT "\032\032$filename:$start:0\n";
- } else {
- print OUT "$start:\t", $dbline[$start], "\n";
- }
- last;
- }
- } ';
- print OUT "?$pat?: not found\n" if ($start == $end);
- next; };
- $cmd =~ /^!+\s*(-)?(\d+)?$/ && do {
- pop(@hist) if length($cmd) > 1;
- $i = ($1?($#hist-($2?$2:1)):($2?$2:$#hist));
- $cmd = $hist[$i] . "\n";
- print OUT $cmd;
- redo; };
- $cmd =~ /^!(.+)$/ && do {
- $pat = "^$1";
- pop(@hist) if length($cmd) > 1;
- for ($i = $#hist; $i; --$i) {
- last if $hist[$i] =~ $pat;
- }
- if (!$i) {
- print OUT "No such command!\n\n";
- next;
- }
- $cmd = $hist[$i] . "\n";
- print OUT $cmd;
- redo; };
- $cmd =~ /^H\s*(-(\d+))?/ && do {
- $end = $2?($#hist-$2):0;
- $hist = 0 if $hist < 0;
- for ($i=$#hist; $i>$end; $i--) {
- print OUT "$i: ",$hist[$i],"\n"
- unless $hist[$i] =~ /^.?$/;
- };
- next; };
- $cmd =~ s/^p( .*)?$/print DB'OUT$1/;
- $cmd =~ /^=/ && do {
- if (local($k,$v) = ($cmd =~ /^=\s*(\S+)\s+(.*)/)) {
- $alias{$k}="s~$k~$v~";
- print OUT "$k = $v\n";
- } elsif ($cmd =~ /^=\s*$/) {
- foreach $k (sort keys(%alias)) {
- if (($v = $alias{$k}) =~ s~^s\~$k\~(.*)\~$~$1~) {
- print OUT "$k = $v\n";
- } else {
- print OUT "$k\t$alias{$k}\n";
- };
- };
- };
- next; };
- $evalarg = $cmd; &eval;
- print OUT "\n";
- }
- if ($post) {
- $evalarg = $post; &eval;
- }
- }
- ($@, $!, $[, $,, $/, $\) = @saved;
-}
-
-sub save {
- @saved = ($@, $!, $[, $,, $/, $\);
- $[ = 0; $, = ""; $/ = "\n"; $\ = "";
-}
-
-# The following takes its argument via $evalarg to preserve current @_
-
-sub eval {
- eval "$usercontext $evalarg; &DB'save";
- print OUT $@;
-}
-
-sub action {
- local($action) = @_;
- while ($action =~ s/\\$//) {
- print OUT "+ ";
- $action .= &gets;
- }
- $action;
-}
-
-sub gets {
- local($.);
- <IN>;
-}
-
-sub catch {
- $signal = 1;
-}
-
-sub sub {
- push(@stack, $single);
- $single &= 1;
- $single |= 4 if $#stack == $deep;
- if (wantarray) {
- @i = &$sub;
- $single |= pop(@stack);
- @i;
- }
- else {
- $i = &$sub;
- $single |= pop(@stack);
- $i;
- }
-}
-
-$single = 1; # so it stops on first executable statement
-@hist = ('?');
-$SIG{'INT'} = "DB'catch";
-$deep = 100; # warning if stack gets this deep
-$window = 10;
-$preview = 3;
-
-@stack = (0);
-@ARGS = @ARGV;
-for (@args) {
- s/'/\\'/g;
- s/(.*)/'$1'/ unless /^-?[\d.]+$/;
-}
-
-if (-f '.perldb') {
- do './.perldb';
-}
-elsif (-f "$ENV{'LOGDIR'}/.perldb") {
- do "$ENV{'LOGDIR'}/.perldb";
-}
-elsif (-f "$ENV{'HOME'}/.perldb") {
- do "$ENV{'HOME'}/.perldb";
-}
-
-1;
diff --git a/gnu/usr.bin/perl/emacs/tedstuff b/gnu/usr.bin/perl/emacs/tedstuff
deleted file mode 100644
index 257bbc8..0000000
--- a/gnu/usr.bin/perl/emacs/tedstuff
+++ /dev/null
@@ -1,296 +0,0 @@
-Article 4417 of comp.lang.perl:
-Path: jpl-devvax!elroy.jpl.nasa.gov!decwrl!mcnc!uvaarpa!mmdf
-From: ted@evi.com (Ted Stefanik)
-Newsgroups: comp.lang.perl
-Subject: Correction to Perl fatal error marking in GNU Emacs
-Message-ID: <1991Feb27.065853.15801@uvaarpa.Virginia.EDU>
-Date: 27 Feb 91 06:58:53 GMT
-Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System)
-Reply-To: ted@evi.com (Ted Stefanik)
-Organization: The Internet
-Lines: 282
-
-Reading my own message, it occurred to me that I didn't quite satisfy the
-request of stef@zweig.sun (Stephane Payrard):
-
-| Does anyone has extended perdb/perdb.el to position the
-| point to the first syntax error? It would be cool.
-
-What I posted is a way to use the "M-x compile" command to test perl scripts.
-(Needless to say, the script cannot be not interactive; you can't provide input
-to a *compilation* buffer). When creating new Perl programs, I use "M-x
-compile" until I'm sure that they are syntatically correct; if syntax errors
-occur, C-x` takes me to each in sequence. After I'm sure the syntax is
-correct, I start worrying about semantics, and switch to "M-x perldb" if
-necessary.
-
-Therefore, the stuff I posted works great with "M-x compile", but not at all
-with "M-x perldb".
-
-Next, let me update what I posted. I found that perl's die() command doesn't
-print the same format error message as perl does when it dies with a syntax
-error. If you put the following in your ".emacs" file, it causes C-x` to
-recognize both kinds of errors:
-
-(load-library "compile")
-(setq compilation-error-regexp
- "\\([^ :\n]+\\(: *\\|, line \\|(\\)[0-9]+\\)\\|\\([0-9]+ *of *[^ \n]+\\|[^ \n]+ \\(at \\)*line [0-9]+\\)")
-
-Last, so I don't look like a total fool, let me propose a way to satisfy
-Stephane Payrard's original request (repeated again):
-
-| Does anyone has extended perdb/perdb.el to position the
-| point to the first syntax error? It would be cool.
-
-I'm not satisfied with just the "first syntax error". Perl's parser is better
-than most about not getting out of sync; therefore, if it reports multiple
-errors, you can usually be assured they are all real errors.
-
-So... I hacked in the "next-error" function from "compile.el" to form
-"perldb-next-error". You can apply the patches at the end of this message
-to add "perldb-next-error" to your "perldb.el".
-
-Notes:
- 1) The patch binds "perldb-next-error" to C-x~ (because ~ is the shift
- of ` on my keyboard, and C-x~ is not yet taken in my version of EMACS).
-
- 2) "next-error" is meant to work on a single *compilation* buffer; any new
- "M-x compile" or "M-x grep" command will clear the old *compilation*
- buffer and reset the compilation-error parser to start at the top of the
- *compilation* buffer.
-
- "perldb-next-error", on the other hand, has to deal with multiple
- *perldb-<foo>* buffers, each of which keep growing. "perldb-next-error"
- correctly handles the constantly growing *perldb-<foo>* buffers by
- keeping track of the last reported error in the "current-perldb-buffer".
-
- Sadly however, when you invoke a new "M-x perldb" on a different Perl
- script, "perldb-next-error" will start parsing the new *perldb-<bar>*
- buffer at the top (even if it was previously parsed), and will completely
- lose the marker of the last reported error in *perldb-<foo>*.
-
- 3) "perldb-next-error" still uses "compilation-error-regexp" to find
- fatal errors. Therefore, both the "M-x compile"/C-x` scheme and
- the "M-x perldb"/C-x~ scheme can be used to find fatal errors that
- match the common "compilation-error-regexp". You *will* want to install
- that "compilation-error-regexp" stuff into your .emacs file.
-
- 4) The patch was developed and tested with GNU Emacs 18.55.
-
- 5) Since the patch was ripped off from compile.el, the code is (of
- course) subject to the GNU copyleft.
-
-*** perldb.el.orig Wed Feb 27 00:44:27 1991
---- perldb.el Wed Feb 27 00:44:30 1991
-***************
-*** 199,205 ****
-
- (defun perldb-set-buffer ()
- (cond ((eq major-mode 'perldb-mode)
-! (setq current-perldb-buffer (current-buffer)))))
-
- ;; This function is responsible for inserting output from Perl
- ;; into the buffer.
---- 199,211 ----
-
- (defun perldb-set-buffer ()
- (cond ((eq major-mode 'perldb-mode)
-! (cond ((not (eq current-perldb-buffer (current-buffer)))
-! (perldb-forget-errors)
-! (setq perldb-parsing-end 2)) ;; 2 to defeat grep defeater
-! (t
-! (if (> perldb-parsing-end (point-max))
-! (setq perldb-parsing-end (max (point-max) 2)))))
-! (setq current-perldb-buffer (current-buffer)))))
-
- ;; This function is responsible for inserting output from Perl
- ;; into the buffer.
-***************
-*** 291,297 ****
- ;; process-buffer is current-buffer
- (unwind-protect
- (progn
-! ;; Write something in *compilation* and hack its mode line,
- (set-buffer (process-buffer proc))
- ;; Force mode line redisplay soon
- (set-buffer-modified-p (buffer-modified-p))
---- 297,303 ----
- ;; process-buffer is current-buffer
- (unwind-protect
- (progn
-! ;; Write something in *perldb-<foo>* and hack its mode line,
- (set-buffer (process-buffer proc))
- ;; Force mode line redisplay soon
- (set-buffer-modified-p (buffer-modified-p))
-***************
-*** 421,423 ****
---- 427,593 ----
- (switch-to-buffer-other-window current-perldb-buffer)
- (goto-char (dot-max))
- (insert-string comm)))
-+
-+ (defvar perldb-error-list nil
-+ "List of error message descriptors for visiting erring functions.
-+ Each error descriptor is a list of length two.
-+ Its car is a marker pointing to an error message.
-+ Its cadr is a marker pointing to the text of the line the message is about,
-+ or nil if that is not interesting.
-+ The value may be t instead of a list;
-+ this means that the buffer of error messages should be reparsed
-+ the next time the list of errors is wanted.")
-+
-+ (defvar perldb-parsing-end nil
-+ "Position of end of buffer when last error messages parsed.")
-+
-+ (defvar perldb-error-message "No more fatal Perl errors"
-+ "Message to print when no more matches for compilation-error-regexp are found")
-+
-+ (defun perldb-next-error (&optional argp)
-+ "Visit next perldb error message and corresponding source code.
-+ This operates on the output from the \\[perldb] command.
-+ If all preparsed error messages have been processed,
-+ the error message buffer is checked for new ones.
-+ A non-nil argument (prefix arg, if interactive)
-+ means reparse the error message buffer and start at the first error."
-+ (interactive "P")
-+ (if (or (eq perldb-error-list t)
-+ argp)
-+ (progn (perldb-forget-errors)
-+ (setq perldb-parsing-end 2))) ;; 2 to defeat grep defeater
-+ (if perldb-error-list
-+ nil
-+ (save-excursion
-+ (switch-to-buffer current-perldb-buffer)
-+ (perldb-parse-errors)))
-+ (let ((next-error (car perldb-error-list)))
-+ (if (null next-error)
-+ (error (concat perldb-error-message
-+ (if (and (get-buffer-process current-perldb-buffer)
-+ (eq (process-status
-+ (get-buffer-process
-+ current-perldb-buffer))
-+ 'run))
-+ " yet" ""))))
-+ (setq perldb-error-list (cdr perldb-error-list))
-+ (if (null (car (cdr next-error)))
-+ nil
-+ (switch-to-buffer (marker-buffer (car (cdr next-error))))
-+ (goto-char (car (cdr next-error)))
-+ (set-marker (car (cdr next-error)) nil))
-+ (let* ((pop-up-windows t)
-+ (w (display-buffer (marker-buffer (car next-error)))))
-+ (set-window-point w (car next-error))
-+ (set-window-start w (car next-error)))
-+ (set-marker (car next-error) nil)))
-+
-+ ;; Set perldb-error-list to nil, and
-+ ;; unchain the markers that point to the error messages and their text,
-+ ;; so that they no longer slow down gap motion.
-+ ;; This would happen anyway at the next garbage collection,
-+ ;; but it is better to do it right away.
-+ (defun perldb-forget-errors ()
-+ (if (eq perldb-error-list t)
-+ (setq perldb-error-list nil))
-+ (while perldb-error-list
-+ (let ((next-error (car perldb-error-list)))
-+ (set-marker (car next-error) nil)
-+ (if (car (cdr next-error))
-+ (set-marker (car (cdr next-error)) nil)))
-+ (setq perldb-error-list (cdr perldb-error-list))))
-+
-+ (defun perldb-parse-errors ()
-+ "Parse the current buffer as error messages.
-+ This makes a list of error descriptors, perldb-error-list.
-+ For each source-file, line-number pair in the buffer,
-+ the source file is read in, and the text location is saved in perldb-error-list.
-+ The function next-error, assigned to \\[next-error], takes the next error off the list
-+ and visits its location."
-+ (setq perldb-error-list nil)
-+ (message "Parsing error messages...")
-+ (let (text-buffer
-+ last-filename last-linenum)
-+ ;; Don't reparse messages already seen at last parse.
-+ (goto-char perldb-parsing-end)
-+ ;; Don't parse the first two lines as error messages.
-+ ;; This matters for grep.
-+ (if (bobp)
-+ (forward-line 2))
-+ (while (re-search-forward compilation-error-regexp nil t)
-+ (let (linenum filename
-+ error-marker text-marker)
-+ ;; Extract file name and line number from error message.
-+ (save-restriction
-+ (narrow-to-region (match-beginning 0) (match-end 0))
-+ (goto-char (point-max))
-+ (skip-chars-backward "[0-9]")
-+ ;; If it's a lint message, use the last file(linenum) on the line.
-+ ;; Normally we use the first on the line.
-+ (if (= (preceding-char) ?\()
-+ (progn
-+ (narrow-to-region (point-min) (1+ (buffer-size)))
-+ (end-of-line)
-+ (re-search-backward compilation-error-regexp)
-+ (skip-chars-backward "^ \t\n")
-+ (narrow-to-region (point) (match-end 0))
-+ (goto-char (point-max))
-+ (skip-chars-backward "[0-9]")))
-+ ;; Are we looking at a "filename-first" or "line-number-first" form?
-+ (if (looking-at "[0-9]")
-+ (progn
-+ (setq linenum (read (current-buffer)))
-+ (goto-char (point-min)))
-+ ;; Line number at start, file name at end.
-+ (progn
-+ (goto-char (point-min))
-+ (setq linenum (read (current-buffer)))
-+ (goto-char (point-max))
-+ (skip-chars-backward "^ \t\n")))
-+ (setq filename (perldb-grab-filename)))
-+ ;; Locate the erring file and line.
-+ (if (and (equal filename last-filename)
-+ (= linenum last-linenum))
-+ nil
-+ (beginning-of-line 1)
-+ (setq error-marker (point-marker))
-+ ;; text-buffer gets the buffer containing this error's file.
-+ (if (not (equal filename last-filename))
-+ (setq text-buffer
-+ (and (file-exists-p (setq last-filename filename))
-+ (find-file-noselect filename))
-+ last-linenum 0))
-+ (if text-buffer
-+ ;; Go to that buffer and find the erring line.
-+ (save-excursion
-+ (set-buffer text-buffer)
-+ (if (zerop last-linenum)
-+ (progn
-+ (goto-char 1)
-+ (setq last-linenum 1)))
-+ (forward-line (- linenum last-linenum))
-+ (setq last-linenum linenum)
-+ (setq text-marker (point-marker))
-+ (setq perldb-error-list
-+ (cons (list error-marker text-marker)
-+ perldb-error-list)))))
-+ (forward-line 1)))
-+ (setq perldb-parsing-end (point-max)))
-+ (message "Parsing error messages...done")
-+ (setq perldb-error-list (nreverse perldb-error-list)))
-+
-+ (defun perldb-grab-filename ()
-+ "Return a string which is a filename, starting at point.
-+ Ignore quotes and parentheses around it, as well as trailing colons."
-+ (if (eq (following-char) ?\")
-+ (save-restriction
-+ (narrow-to-region (point)
-+ (progn (forward-sexp 1) (point)))
-+ (goto-char (point-min))
-+ (read (current-buffer)))
-+ (buffer-substring (point)
-+ (progn
-+ (skip-chars-forward "^ :,\n\t(")
-+ (point)))))
-+
-+ (define-key ctl-x-map "~" 'perldb-next-error)
-
-
diff --git a/gnu/usr.bin/perl/h2pl/README b/gnu/usr.bin/perl/h2pl/README
deleted file mode 100644
index 5fe8ae7..0000000
--- a/gnu/usr.bin/perl/h2pl/README
+++ /dev/null
@@ -1,71 +0,0 @@
-[This file of Tom Christiansen's has been edited to change makelib to h2ph
-and .h to .ph where appropriate--law.]
-
-This directory contains files to help you convert the *.ph files generated my
-h2ph out of the perl source directory into *.pl files with all the
-indirection of the subroutine calls removed. The .ph version will be more
-safely portable, because if something isn't defined on the new system, like
-&TIOCGETP, then you'll get a fatal run-time error on the system lacking that
-function. Using the .pl version means that the subsequent scripts will give
-you a 0 $TIOCGETP and God only knows what may then happen. Still, I like the
-.pl stuff because they're faster to load.
-
-FIrst, you need to run h2ph on things like sys/ioctl.h to get stuff
-into the perl library directory, often /usr/local/lib/perl. For example,
- # h2ph sys/ioctl.h
-takes /usr/include/sys/ioctl.h as input and writes (without i/o redirection)
-the file /usr/local/lib/perl/sys/ioctl.ph, which looks like this
-
- eval 'sub TIOCM_RTS {0004;}';
- eval 'sub TIOCM_ST {0010;}';
- eval 'sub TIOCM_SR {0020;}';
- eval 'sub TIOCM_CTS {0040;}';
- eval 'sub TIOCM_CAR {0100;}';
-
-and much worse, rather than what Larry's ioctl.pl from the perl source dir has,
-which is:
-
- $TIOCM_RTS = 0004;
- $TIOCM_ST = 0010;
- $TIOCM_SR = 0020;
- $TIOCM_CTS = 0040;
- $TIOCM_CAR = 0100;
-
-[Workaround for fixed bug in makedir/h2ph deleted--law.]
-
-The more complicated ioctl subs look like this:
-
- eval 'sub TIOCGSIZE {&TIOCGWINSZ;}';
- eval 'sub TIOCGWINSZ {&_IOR("t", 104, \'struct winsize\');}';
- eval 'sub TIOCSETD {&_IOW("t", 1, \'int\');}';
- eval 'sub TIOCGETP {&_IOR("t", 8,\'struct sgttyb\');}';
-
-The _IO[RW] routines use a %sizeof array, which (presumably)
-is keyed on the type name with the value being the size in bytes.
-
-To build %sizeof, try running this in this directory:
-
- % ./getioctlsizes
-
-Which will tell you which things the %sizeof array needs
-to hold. You can try to build a sizeof.ph file with:
-
- % ./getioctlsizes | ./mksizes > sizeof.ph
-
-Note that mksizes hardcodes the #include files for all the types, so it will
-probably require customization. Once you have sizeof.ph, install it in the
-perl library directory. Run my tcbreak script to see whether you can do
-ioctls in perl now. You'll get some kind of fatal run-time error if you
-can't. That script should be included in this directory.
-
-If this works well, now you can try to convert the *.ph files into
-*.pl files. Try this:
-
- foreach file ( sysexits.ph sys/{errno.ph,ioctl.ph} )
- ./mkvars $file > t/$file:r.pl
- end
-
-The last one will be the hardest. If it works, should be able to
-run tcbreak2 and have it work the same as tcbreak.
-
-Good luck.
diff --git a/gnu/usr.bin/perl/h2pl/cbreak.pl b/gnu/usr.bin/perl/h2pl/cbreak.pl
deleted file mode 100644
index 422185e..0000000
--- a/gnu/usr.bin/perl/h2pl/cbreak.pl
+++ /dev/null
@@ -1,34 +0,0 @@
-$sgttyb_t = 'C4 S';
-
-sub cbreak {
- &set_cbreak(1);
-}
-
-sub cooked {
- &set_cbreak(0);
-}
-
-sub set_cbreak {
- local($on) = @_;
-
- require 'sizeof.ph';
- require 'sys/ioctl.ph';
-
- ioctl(STDIN,&TIOCGETP,$sgttyb)
- || die "Can't ioctl TIOCGETP: $!";
-
- @ary = unpack($sgttyb_t,$sgttyb);
- if ($on) {
- $ary[4] |= &CBREAK;
- $ary[4] &= ~&ECHO;
- } else {
- $ary[4] &= ~&CBREAK;
- $ary[4] |= &ECHO;
- }
- $sgttyb = pack($sgttyb_t,@ary);
- ioctl(STDIN,&TIOCSETP,$sgttyb)
- || die "Can't ioctl TIOCSETP: $!";
-
-}
-
-1;
diff --git a/gnu/usr.bin/perl/h2pl/cbreak2.pl b/gnu/usr.bin/perl/h2pl/cbreak2.pl
deleted file mode 100644
index 8ac55a3..0000000
--- a/gnu/usr.bin/perl/h2pl/cbreak2.pl
+++ /dev/null
@@ -1,33 +0,0 @@
-$sgttyb_t = 'C4 S';
-
-sub cbreak {
- &set_cbreak(1);
-}
-
-sub cooked {
- &set_cbreak(0);
-}
-
-sub set_cbreak {
- local($on) = @_;
-
- require 'sys/ioctl.pl';
-
- ioctl(STDIN,$TIOCGETP,$sgttyb)
- || die "Can't ioctl TIOCGETP: $!";
-
- @ary = unpack($sgttyb_t,$sgttyb);
- if ($on) {
- $ary[4] |= $CBREAK;
- $ary[4] &= ~$ECHO;
- } else {
- $ary[4] &= ~$CBREAK;
- $ary[4] |= $ECHO;
- }
- $sgttyb = pack($sgttyb_t,@ary);
- ioctl(STDIN,$TIOCSETP,$sgttyb)
- || die "Can't ioctl TIOCSETP: $!";
-
-}
-
-1;
diff --git a/gnu/usr.bin/perl/h2pl/eg/sizeof.ph b/gnu/usr.bin/perl/h2pl/eg/sizeof.ph
deleted file mode 100644
index 285bff1..0000000
--- a/gnu/usr.bin/perl/h2pl/eg/sizeof.ph
+++ /dev/null
@@ -1,14 +0,0 @@
-$sizeof{'char'} = 1;
-$sizeof{'int'} = 4;
-$sizeof{'long'} = 4;
-$sizeof{'struct arpreq'} = 36;
-$sizeof{'struct ifconf'} = 8;
-$sizeof{'struct ifreq'} = 32;
-$sizeof{'struct ltchars'} = 6;
-$sizeof{'struct pcntl'} = 116;
-$sizeof{'struct rtentry'} = 52;
-$sizeof{'struct sgttyb'} = 6;
-$sizeof{'struct tchars'} = 6;
-$sizeof{'struct ttychars'} = 14;
-$sizeof{'struct winsize'} = 8;
-$sizeof{'struct termios'} = 132;
diff --git a/gnu/usr.bin/perl/h2pl/eg/sys/errno.pl b/gnu/usr.bin/perl/h2pl/eg/sys/errno.pl
deleted file mode 100644
index d9ba3be..0000000
--- a/gnu/usr.bin/perl/h2pl/eg/sys/errno.pl
+++ /dev/null
@@ -1,92 +0,0 @@
-$EPERM = 0x1;
-$ENOENT = 0x2;
-$ESRCH = 0x3;
-$EINTR = 0x4;
-$EIO = 0x5;
-$ENXIO = 0x6;
-$E2BIG = 0x7;
-$ENOEXEC = 0x8;
-$EBADF = 0x9;
-$ECHILD = 0xA;
-$EAGAIN = 0xB;
-$ENOMEM = 0xC;
-$EACCES = 0xD;
-$EFAULT = 0xE;
-$ENOTBLK = 0xF;
-$EBUSY = 0x10;
-$EEXIST = 0x11;
-$EXDEV = 0x12;
-$ENODEV = 0x13;
-$ENOTDIR = 0x14;
-$EISDIR = 0x15;
-$EINVAL = 0x16;
-$ENFILE = 0x17;
-$EMFILE = 0x18;
-$ENOTTY = 0x19;
-$ETXTBSY = 0x1A;
-$EFBIG = 0x1B;
-$ENOSPC = 0x1C;
-$ESPIPE = 0x1D;
-$EROFS = 0x1E;
-$EMLINK = 0x1F;
-$EPIPE = 0x20;
-$EDOM = 0x21;
-$ERANGE = 0x22;
-$EWOULDBLOCK = 0x23;
-$EINPROGRESS = 0x24;
-$EALREADY = 0x25;
-$ENOTSOCK = 0x26;
-$EDESTADDRREQ = 0x27;
-$EMSGSIZE = 0x28;
-$EPROTOTYPE = 0x29;
-$ENOPROTOOPT = 0x2A;
-$EPROTONOSUPPORT = 0x2B;
-$ESOCKTNOSUPPORT = 0x2C;
-$EOPNOTSUPP = 0x2D;
-$EPFNOSUPPORT = 0x2E;
-$EAFNOSUPPORT = 0x2F;
-$EADDRINUSE = 0x30;
-$EADDRNOTAVAIL = 0x31;
-$ENETDOWN = 0x32;
-$ENETUNREACH = 0x33;
-$ENETRESET = 0x34;
-$ECONNABORTED = 0x35;
-$ECONNRESET = 0x36;
-$ENOBUFS = 0x37;
-$EISCONN = 0x38;
-$ENOTCONN = 0x39;
-$ESHUTDOWN = 0x3A;
-$ETOOMANYREFS = 0x3B;
-$ETIMEDOUT = 0x3C;
-$ECONNREFUSED = 0x3D;
-$ELOOP = 0x3E;
-$ENAMETOOLONG = 0x3F;
-$EHOSTDOWN = 0x40;
-$EHOSTUNREACH = 0x41;
-$ENOTEMPTY = 0x42;
-$EPROCLIM = 0x43;
-$EUSERS = 0x44;
-$EDQUOT = 0x45;
-$ESTALE = 0x46;
-$EREMOTE = 0x47;
-$EDEADLK = 0x48;
-$ENOLCK = 0x49;
-$MTH_UNDEF_SQRT = 0x12C;
-$MTH_OVF_EXP = 0x12D;
-$MTH_UNDEF_LOG = 0x12E;
-$MTH_NEG_BASE = 0x12F;
-$MTH_ZERO_BASE = 0x130;
-$MTH_OVF_POW = 0x131;
-$MTH_LRG_SIN = 0x132;
-$MTH_LRG_COS = 0x133;
-$MTH_LRG_TAN = 0x134;
-$MTH_LRG_COT = 0x135;
-$MTH_OVF_TAN = 0x136;
-$MTH_OVF_COT = 0x137;
-$MTH_UNDEF_ASIN = 0x138;
-$MTH_UNDEF_ACOS = 0x139;
-$MTH_UNDEF_ATAN2 = 0x13A;
-$MTH_OVF_SINH = 0x13B;
-$MTH_OVF_COSH = 0x13C;
-$MTH_UNDEF_ZLOG = 0x13D;
-$MTH_UNDEF_ZDIV = 0x13E;
diff --git a/gnu/usr.bin/perl/h2pl/eg/sys/ioctl.pl b/gnu/usr.bin/perl/h2pl/eg/sys/ioctl.pl
deleted file mode 100644
index 0b552ca..0000000
--- a/gnu/usr.bin/perl/h2pl/eg/sys/ioctl.pl
+++ /dev/null
@@ -1,186 +0,0 @@
-$_IOCTL_ = 0x1;
-$TIOCGSIZE = 0x40087468;
-$TIOCSSIZE = 0x80087467;
-$IOCPARM_MASK = 0x7F;
-$IOC_VOID = 0x20000000;
-$IOC_OUT = 0x40000000;
-$IOC_IN = 0x80000000;
-$IOC_INOUT = 0xC0000000;
-$TIOCGETD = 0x40047400;
-$TIOCSETD = 0x80047401;
-$TIOCHPCL = 0x20007402;
-$TIOCMODG = 0x40047403;
-$TIOCMODS = 0x80047404;
-$TIOCM_LE = 0x1;
-$TIOCM_DTR = 0x2;
-$TIOCM_RTS = 0x4;
-$TIOCM_ST = 0x8;
-$TIOCM_SR = 0x10;
-$TIOCM_CTS = 0x20;
-$TIOCM_CAR = 0x40;
-$TIOCM_CD = 0x40;
-$TIOCM_RNG = 0x80;
-$TIOCM_RI = 0x80;
-$TIOCM_DSR = 0x100;
-$TIOCGETP = 0x40067408;
-$TIOCSETP = 0x80067409;
-$TIOCSETN = 0x8006740A;
-$TIOCEXCL = 0x2000740D;
-$TIOCNXCL = 0x2000740E;
-$TIOCFLUSH = 0x80047410;
-$TIOCSETC = 0x80067411;
-$TIOCGETC = 0x40067412;
-$TIOCSET = 0x80047413;
-$TIOCBIS = 0x80047414;
-$TIOCBIC = 0x80047415;
-$TIOCGET = 0x40047416;
-$TANDEM = 0x1;
-$CBREAK = 0x2;
-$LCASE = 0x4;
-$ECHO = 0x8;
-$CRMOD = 0x10;
-$RAW = 0x20;
-$ODDP = 0x40;
-$EVENP = 0x80;
-$ANYP = 0xC0;
-$NLDELAY = 0x300;
-$NL0 = 0x0;
-$NL1 = 0x100;
-$NL2 = 0x200;
-$NL3 = 0x300;
-$TBDELAY = 0xC00;
-$TAB0 = 0x0;
-$TAB1 = 0x400;
-$TAB2 = 0x800;
-$XTABS = 0xC00;
-$CRDELAY = 0x3000;
-$CR0 = 0x0;
-$CR1 = 0x1000;
-$CR2 = 0x2000;
-$CR3 = 0x3000;
-$VTDELAY = 0x4000;
-$FF0 = 0x0;
-$FF1 = 0x4000;
-$BSDELAY = 0x8000;
-$BS0 = 0x0;
-$BS1 = 0x8000;
-$ALLDELAY = 0xFF00;
-$CRTBS = 0x10000;
-$PRTERA = 0x20000;
-$CRTERA = 0x40000;
-$TILDE = 0x80000;
-$MDMBUF = 0x100000;
-$LITOUT = 0x200000;
-$TOSTOP = 0x400000;
-$FLUSHO = 0x800000;
-$NOHANG = 0x1000000;
-$L001000 = 0x2000000;
-$CRTKIL = 0x4000000;
-$L004000 = 0x8000000;
-$CTLECH = 0x10000000;
-$PENDIN = 0x20000000;
-$DECCTQ = 0x40000000;
-$NOFLSH = 0x80000000;
-$TIOCCSET = 0x800E7417;
-$TIOCCGET = 0x400E7418;
-$TIOCLBIS = 0x8004747F;
-$TIOCLBIC = 0x8004747E;
-$TIOCLSET = 0x8004747D;
-$TIOCLGET = 0x4004747C;
-$LCRTBS = 0x1;
-$LPRTERA = 0x2;
-$LCRTERA = 0x4;
-$LTILDE = 0x8;
-$LMDMBUF = 0x10;
-$LLITOUT = 0x20;
-$LTOSTOP = 0x40;
-$LFLUSHO = 0x80;
-$LNOHANG = 0x100;
-$LCRTKIL = 0x400;
-$LCTLECH = 0x1000;
-$LPENDIN = 0x2000;
-$LDECCTQ = 0x4000;
-$LNOFLSH = 0x8000;
-$TIOCSBRK = 0x2000747B;
-$TIOCCBRK = 0x2000747A;
-$TIOCSDTR = 0x20007479;
-$TIOCCDTR = 0x20007478;
-$TIOCGPGRP = 0x40047477;
-$TIOCSPGRP = 0x80047476;
-$TIOCSLTC = 0x80067475;
-$TIOCGLTC = 0x40067474;
-$TIOCOUTQ = 0x40047473;
-$TIOCSTI = 0x80017472;
-$TIOCNOTTY = 0x20007471;
-$TIOCPKT = 0x80047470;
-$TIOCPKT_DATA = 0x0;
-$TIOCPKT_FLUSHREAD = 0x1;
-$TIOCPKT_FLUSHWRITE = 0x2;
-$TIOCPKT_STOP = 0x4;
-$TIOCPKT_START = 0x8;
-$TIOCPKT_NOSTOP = 0x10;
-$TIOCPKT_DOSTOP = 0x20;
-$TIOCSTOP = 0x2000746F;
-$TIOCSTART = 0x2000746E;
-$TIOCREMOTE = 0x20007469;
-$TIOCGWINSZ = 0x40087468;
-$TIOCSWINSZ = 0x80087467;
-$TIOCRESET = 0x20007466;
-$OTTYDISC = 0x0;
-$NETLDISC = 0x1;
-$NTTYDISC = 0x2;
-$FIOCLEX = 0x20006601;
-$FIONCLEX = 0x20006602;
-$FIONREAD = 0x4004667F;
-$FIONBIO = 0x8004667E;
-$FIOASYNC = 0x8004667D;
-$FIOSETOWN = 0x8004667C;
-$FIOGETOWN = 0x4004667B;
-$STPUTTABLE = 0x8004667A;
-$STGETTABLE = 0x80046679;
-$SIOCSHIWAT = 0x80047300;
-$SIOCGHIWAT = 0x40047301;
-$SIOCSLOWAT = 0x80047302;
-$SIOCGLOWAT = 0x40047303;
-$SIOCATMARK = 0x40047307;
-$SIOCSPGRP = 0x80047308;
-$SIOCGPGRP = 0x40047309;
-$SIOCADDRT = 0x8034720A;
-$SIOCDELRT = 0x8034720B;
-$SIOCSIFADDR = 0x8020690C;
-$SIOCGIFADDR = 0xC020690D;
-$SIOCSIFDSTADDR = 0x8020690E;
-$SIOCGIFDSTADDR = 0xC020690F;
-$SIOCSIFFLAGS = 0x80206910;
-$SIOCGIFFLAGS = 0xC0206911;
-$SIOCGIFBRDADDR = 0xC0206912;
-$SIOCSIFBRDADDR = 0x80206913;
-$SIOCGIFCONF = 0xC0086914;
-$SIOCGIFNETMASK = 0xC0206915;
-$SIOCSIFNETMASK = 0x80206916;
-$SIOCGIFMETRIC = 0xC0206917;
-$SIOCSIFMETRIC = 0x80206918;
-$SIOCSARP = 0x8024691E;
-$SIOCGARP = 0xC024691F;
-$SIOCDARP = 0x80246920;
-$PIXCONTINUE = 0x80747000;
-$PIXSTEP = 0x80747001;
-$PIXTERMINATE = 0x20007002;
-$PIGETFLAGS = 0x40747003;
-$PIXINHERIT = 0x80747004;
-$PIXDETACH = 0x20007005;
-$PIXGETSUBCODE = 0xC0747006;
-$PIXRDREGS = 0xC0747007;
-$PIXWRREGS = 0xC0747008;
-$PIXRDVREGS = 0xC0747009;
-$PIXWRVREGS = 0xC074700A;
-$PIXRDVSTATE = 0xC074700B;
-$PIXWRVSTATE = 0xC074700C;
-$PIXRDCREGS = 0xC074700D;
-$PIXWRCREGS = 0xC074700E;
-$PIRDSDRS = 0xC074700F;
-$PIXGETSIGACTION = 0xC0747010;
-$PIGETU = 0xC0747011;
-$PISETRWTID = 0xC0747012;
-$PIXGETTHCOUNT = 0xC0747013;
-$PIXRUN = 0x20007014;
diff --git a/gnu/usr.bin/perl/h2pl/eg/sysexits.pl b/gnu/usr.bin/perl/h2pl/eg/sysexits.pl
deleted file mode 100644
index f4cb777..0000000
--- a/gnu/usr.bin/perl/h2pl/eg/sysexits.pl
+++ /dev/null
@@ -1,16 +0,0 @@
-$EX_OK = 0x0;
-$EX__BASE = 0x40;
-$EX_USAGE = 0x40;
-$EX_DATAERR = 0x41;
-$EX_NOINPUT = 0x42;
-$EX_NOUSER = 0x43;
-$EX_NOHOST = 0x44;
-$EX_UNAVAILABLE = 0x45;
-$EX_SOFTWARE = 0x46;
-$EX_OSERR = 0x47;
-$EX_OSFILE = 0x48;
-$EX_CANTCREAT = 0x49;
-$EX_IOERR = 0x4A;
-$EX_TEMPFAIL = 0x4B;
-$EX_PROTOCOL = 0x4C;
-$EX_NOPERM = 0x4D;
diff --git a/gnu/usr.bin/perl/h2pl/getioctlsizes b/gnu/usr.bin/perl/h2pl/getioctlsizes
deleted file mode 100644
index 403fffa..0000000
--- a/gnu/usr.bin/perl/h2pl/getioctlsizes
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/perl
-
-open (IOCTLS,'/usr/include/sys/ioctl.h') || die "ioctl open failed";
-
-while (<IOCTLS>) {
- if (/^\s*#\s*define\s+\w+\s+_IO(R|W|WR)\('?\w+'?,\s*\w+,\s*([^)]+)/) {
- $need{$2}++;
- }
-}
-
-foreach $key ( sort keys %need ) {
- print $key,"\n";
-}
diff --git a/gnu/usr.bin/perl/h2pl/mksizes b/gnu/usr.bin/perl/h2pl/mksizes
deleted file mode 100644
index a39c83a..0000000
--- a/gnu/usr.bin/perl/h2pl/mksizes
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/perl
-
-($iam = $0) =~ s%.*/%%;
-$tmp = "$iam.$$";
-open (CODE,">$tmp.c") || die "$iam: cannot create $tmp.c: $!\n";
-
-$mask = q/printf ("$sizeof{'%s'} = %d;\n"/;
-
-# write C program
-select(CODE);
-
-print <<EO_C_PROGRAM;
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if_arp.h>
-#include <net/if.h>
-#include <net/route.h>
-#include <sys/ioctl.h>
-
-main() {
-EO_C_PROGRAM
-
-while ( <> ) {
- chop;
- printf "\t%s, \n\t\t\"%s\", sizeof(%s));\n", $mask, $_,$_;
-}
-
-print "\n}\n";
-
-close CODE;
-
-# compile C program
-
-select(STDOUT);
-
-system "cc $tmp.c -o $tmp";
-die "couldn't compile $tmp.c" if $?;
-system "./$tmp";
-die "couldn't run $tmp" if $?;
-
-unlink "$tmp.c", $tmp;
diff --git a/gnu/usr.bin/perl/h2pl/mkvars b/gnu/usr.bin/perl/h2pl/mkvars
deleted file mode 100644
index 16317aa..0000000
--- a/gnu/usr.bin/perl/h2pl/mkvars
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/perl
-
-require 'sizeof.ph';
-
-$LIB = '/usr/share/perl';
-
-foreach $include (@ARGV) {
- printf STDERR "including %s\n", $include;
- do $include;
- warn "sourcing $include: $@\n" if ($@);
- if (!open (INCLUDE,"$LIB/$include")) {
- warn "can't open $LIB/$include: $!\n";
- next;
- }
- while (<INCLUDE>) {
- chop;
- if (/^\s*eval\s+'sub\s+(\w+)\s.*[^{]$/ || /^\s*sub\s+(\w+)\s.*[^{]$/) {
- $var = $1;
- $val = eval "&$var;";
- if ($@) {
- warn "$@: $_";
- print <<EOT;
-warn "\$$var isn't correctly set" if defined \$_main{'$var'};
-EOT
- next;
- }
- ( $nval = sprintf ("%x",$val ) ) =~ tr/a-z/A-Z/;
- printf "\$%s = 0x%s;\n", $var, $nval;
- }
- }
-}
diff --git a/gnu/usr.bin/perl/h2pl/tcbreak b/gnu/usr.bin/perl/h2pl/tcbreak
deleted file mode 100644
index 2677cc9..0000000
--- a/gnu/usr.bin/perl/h2pl/tcbreak
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/perl
-
-require 'cbreak.pl';
-
-&cbreak;
-
-$| = 1;
-
-print "gimme a char: ";
-
-$c = getc;
-
-print "$c\n";
-
-printf "you gave me `%s', which is 0x%02x\n", $c, ord($c);
-
-&cooked;
diff --git a/gnu/usr.bin/perl/h2pl/tcbreak2 b/gnu/usr.bin/perl/h2pl/tcbreak2
deleted file mode 100644
index fcbf926..0000000
--- a/gnu/usr.bin/perl/h2pl/tcbreak2
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/perl
-
-require 'cbreak2.pl';
-
-&cbreak;
-
-$| = 1;
-
-print "gimme a char: ";
-
-$c = getc;
-
-print "$c\n";
-
-printf "you gave me `%s', which is 0x%02x\n", $c, ord($c);
-
-&cooked;
diff --git a/gnu/usr.bin/perl/lib/Makefile b/gnu/usr.bin/perl/lib/Makefile
deleted file mode 100644
index 158cbfa..0000000
--- a/gnu/usr.bin/perl/lib/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-PLIBDIR= ${DESTDIR}/usr/share/perl
-
-PLIB+= abbrev.pl assert.pl bigfloat.pl bigint.pl bigrat.pl cacheout.pl
-PLIB+= chat2.pl complete.pl ctime.pl dumpvar.pl exceptions.pl fastcwd.pl
-PLIB+= find.pl finddepth.pl flush.pl getcwd.pl gethostname.pl getopts.pl
-PLIB+= importenv.pl look.pl newgetopt.pl open2.pl perldb.pl pwd.pl
-PLIB+= shellwords.pl stat.pl syslog.pl termcap.pl timelocal.pl validate.pl
-
-NOOBJ=
-
-install:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 ${PLIB} ${PLIBDIR}
-
-clean:
-cleandir:
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/perl/lib/abbrev.pl b/gnu/usr.bin/perl/lib/abbrev.pl
deleted file mode 100644
index c233d4a..0000000
--- a/gnu/usr.bin/perl/lib/abbrev.pl
+++ /dev/null
@@ -1,33 +0,0 @@
-;# Usage:
-;# %foo = ();
-;# &abbrev(*foo,LIST);
-;# ...
-;# $long = $foo{$short};
-
-package abbrev;
-
-sub main'abbrev {
- local(*domain) = @_;
- shift(@_);
- @cmp = @_;
- local($[) = 0;
- foreach $name (@_) {
- @extra = split(//,$name);
- $abbrev = shift(@extra);
- $len = 1;
- foreach $cmp (@cmp) {
- next if $cmp eq $name;
- while (substr($cmp,0,$len) eq $abbrev) {
- $abbrev .= shift(@extra);
- ++$len;
- }
- }
- $domain{$abbrev} = $name;
- while ($#extra >= 0) {
- $abbrev .= shift(@extra);
- $domain{$abbrev} = $name;
- }
- }
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/assert.pl b/gnu/usr.bin/perl/lib/assert.pl
deleted file mode 100644
index cfda70c..0000000
--- a/gnu/usr.bin/perl/lib/assert.pl
+++ /dev/null
@@ -1,52 +0,0 @@
-# assert.pl
-# tchrist@convex.com (Tom Christiansen)
-#
-# Usage:
-#
-# &assert('@x > @y');
-# &assert('$var > 10', $var, $othervar, @various_info);
-#
-# That is, if the first expression evals false, we blow up. The
-# rest of the args, if any, are nice to know because they will
-# be printed out by &panic, which is just the stack-backtrace
-# routine shamelessly borrowed from the perl debugger.
-
-sub assert {
- &panic("ASSERTION BOTCHED: $_[0]",$@) unless eval $_[0];
-}
-
-sub panic {
- select(STDERR);
-
- print "\npanic: @_\n";
-
- exit 1 if $] <= 4.003; # caller broken
-
- # stack traceback gratefully borrowed from perl debugger
-
- local($i,$_);
- local($p,$f,$l,$s,$h,$a,@a,@sub);
- for ($i = 0; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
- @a = @DB'args;
- for (@a) {
- if (/^StB\000/ && length($_) == length($_main{'_main'})) {
- $_ = sprintf("%s",$_);
- }
- else {
- s/'/\\'/g;
- s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
- s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
- s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
- }
- }
- $w = $w ? '@ = ' : '$ = ';
- $a = $h ? '(' . join(', ', @a) . ')' : '';
- push(@sub, "$w&$s$a from file $f line $l\n");
- }
- for ($i=0; $i <= $#sub; $i++) {
- print $sub[$i];
- }
- exit 1;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/bigfloat.pl b/gnu/usr.bin/perl/lib/bigfloat.pl
deleted file mode 100644
index 278f11d..0000000
--- a/gnu/usr.bin/perl/lib/bigfloat.pl
+++ /dev/null
@@ -1,233 +0,0 @@
-package bigfloat;
-require "bigint.pl";
-# Arbitrary length float math package
-#
-# by Mark Biggar
-#
-# number format
-# canonical strings have the form /[+-]\d+E[+-]\d+/
-# Input values can have inbedded whitespace
-# Error returns
-# 'NaN' An input parameter was "Not a Number" or
-# divide by zero or sqrt of negative number
-# Division is computed to
-# max($div_scale,length(dividend).length(divisor))
-# digits by default.
-# Also used for default sqrt scale
-
-$div_scale = 40;
-
-# Rounding modes one of 'even', 'odd', '+inf', '-inf', 'zero' or 'trunc'.
-
-$rnd_mode = 'even';
-
-# bigfloat routines
-#
-# fadd(NSTR, NSTR) return NSTR addition
-# fsub(NSTR, NSTR) return NSTR subtraction
-# fmul(NSTR, NSTR) return NSTR multiplication
-# fdiv(NSTR, NSTR[,SCALE]) returns NSTR division to SCALE places
-# fneg(NSTR) return NSTR negation
-# fabs(NSTR) return NSTR absolute value
-# fcmp(NSTR,NSTR) return CODE compare undef,<0,=0,>0
-# fround(NSTR, SCALE) return NSTR round to SCALE digits
-# ffround(NSTR, SCALE) return NSTR round at SCALEth place
-# fnorm(NSTR) return (NSTR) normalize
-# fsqrt(NSTR[, SCALE]) return NSTR sqrt to SCALE places
-
-# Convert a number to canonical string form.
-# Takes something that looks like a number and converts it to
-# the form /^[+-]\d+E[+-]\d+$/.
-sub main'fnorm { #(string) return fnum_str
- local($_) = @_;
- s/\s+//g; # strip white space
- if (/^([+-]?)(\d*)(\.(\d*))?([Ee]([+-]?\d+))?$/ && "$2$4" ne '') {
- &norm(($1 ? "$1$2$4" : "+$2$4"),(($4 ne '') ? $6-length($4) : $6));
- } else {
- 'NaN';
- }
-}
-
-# normalize number -- for internal use
-sub norm { #(mantissa, exponent) return fnum_str
- local($_, $exp) = @_;
- if ($_ eq 'NaN') {
- 'NaN';
- } else {
- s/^([+-])0+/$1/; # strip leading zeros
- if (length($_) == 1) {
- '+0E+0';
- } else {
- $exp += length($1) if (s/(0+)$//); # strip trailing zeros
- sprintf("%sE%+ld", $_, $exp);
- }
- }
-}
-
-# negation
-sub main'fneg { #(fnum_str) return fnum_str
- local($_) = &'fnorm($_[0]);
- vec($_,0,8) ^= ord('+') ^ ord('-') unless $_ eq '+0E+0'; # flip sign
- s/^H/N/;
- $_;
-}
-
-# absolute value
-sub main'fabs { #(fnum_str) return fnum_str
- local($_) = &'fnorm($_[0]);
- s/^-/+/; # mash sign
- $_;
-}
-
-# multiplication
-sub main'fmul { #(fnum_str, fnum_str) return fnum_str
- local($x,$y) = (&'fnorm($_[0]),&'fnorm($_[1]));
- if ($x eq 'NaN' || $y eq 'NaN') {
- 'NaN';
- } else {
- local($xm,$xe) = split('E',$x);
- local($ym,$ye) = split('E',$y);
- &norm(&'bmul($xm,$ym),$xe+$ye);
- }
-}
-
-# addition
-sub main'fadd { #(fnum_str, fnum_str) return fnum_str
- local($x,$y) = (&'fnorm($_[0]),&'fnorm($_[1]));
- if ($x eq 'NaN' || $y eq 'NaN') {
- 'NaN';
- } else {
- local($xm,$xe) = split('E',$x);
- local($ym,$ye) = split('E',$y);
- ($xm,$xe,$ym,$ye) = ($ym,$ye,$xm,$xe) if ($xe < $ye);
- &norm(&'badd($ym,$xm.('0' x ($xe-$ye))),$ye);
- }
-}
-
-# subtraction
-sub main'fsub { #(fnum_str, fnum_str) return fnum_str
- &'fadd($_[0],&'fneg($_[1]));
-}
-
-# division
-# args are dividend, divisor, scale (optional)
-# result has at most max(scale, length(dividend), length(divisor)) digits
-sub main'fdiv #(fnum_str, fnum_str[,scale]) return fnum_str
-{
- local($x,$y,$scale) = (&'fnorm($_[0]),&'fnorm($_[1]),$_[2]);
- if ($x eq 'NaN' || $y eq 'NaN' || $y eq '+0E+0') {
- 'NaN';
- } else {
- local($xm,$xe) = split('E',$x);
- local($ym,$ye) = split('E',$y);
- $scale = $div_scale if (!$scale);
- $scale = length($xm)-1 if (length($xm)-1 > $scale);
- $scale = length($ym)-1 if (length($ym)-1 > $scale);
- $scale = $scale + length($ym) - length($xm);
- &norm(&round(&'bdiv($xm.('0' x $scale),$ym),$ym),
- $xe-$ye-$scale);
- }
-}
-
-# round int $q based on fraction $r/$base using $rnd_mode
-sub round { #(int_str, int_str, int_str) return int_str
- local($q,$r,$base) = @_;
- if ($q eq 'NaN' || $r eq 'NaN') {
- 'NaN';
- } elsif ($rnd_mode eq 'trunc') {
- $q; # just truncate
- } else {
- local($cmp) = &'bcmp(&'bmul($r,'+2'),$base);
- if ( $cmp < 0 ||
- ($cmp == 0 &&
- ( $rnd_mode eq 'zero' ||
- ($rnd_mode eq '-inf' && (substr($q,0,1) eq '+')) ||
- ($rnd_mode eq '+inf' && (substr($q,0,1) eq '-')) ||
- ($rnd_mode eq 'even' && $q =~ /[24680]$/) ||
- ($rnd_mode eq 'odd' && $q =~ /[13579]$/) )) ) {
- $q; # round down
- } else {
- &'badd($q, ((substr($q,0,1) eq '-') ? '-1' : '+1'));
- # round up
- }
- }
-}
-
-# round the mantissa of $x to $scale digits
-sub main'fround { #(fnum_str, scale) return fnum_str
- local($x,$scale) = (&'fnorm($_[0]),$_[1]);
- if ($x eq 'NaN' || $scale <= 0) {
- $x;
- } else {
- local($xm,$xe) = split('E',$x);
- if (length($xm)-1 <= $scale) {
- $x;
- } else {
- &norm(&round(substr($xm,0,$scale+1),
- "+0".substr($xm,$scale+1,1),"+10"),
- $xe+length($xm)-$scale-1);
- }
- }
-}
-
-# round $x at the 10 to the $scale digit place
-sub main'ffround { #(fnum_str, scale) return fnum_str
- local($x,$scale) = (&'fnorm($_[0]),$_[1]);
- if ($x eq 'NaN') {
- 'NaN';
- } else {
- local($xm,$xe) = split('E',$x);
- if ($xe >= $scale) {
- $x;
- } else {
- $xe = length($xm)+$xe-$scale;
- if ($xe < 1) {
- '+0E+0';
- } elsif ($xe == 1) {
- &norm(&round('+0',"+0".substr($xm,1,1),"+10"), $scale);
- } else {
- &norm(&round(substr($xm,0,$trunc),
- "+0".substr($xm,$trunc,1),"+10"), $scale);
- }
- }
- }
-}
-
-# compare 2 values returns one of undef, <0, =0, >0
-# returns undef if either or both input value are not numbers
-sub main'fcmp #(fnum_str, fnum_str) return cond_code
-{
- local($x, $y) = (&'fnorm($_[0]),&'fnorm($_[1]));
- if ($x eq "NaN" || $y eq "NaN") {
- undef;
- } else {
- ord($y) <=> ord($x)
- ||
- ( local($xm,$xe,$ym,$ye) = split('E', $x."E$y"),
- (($xe <=> $ye) * (substr($x,0,1).'1')
- || &bigint'cmp($xm,$ym))
- );
- }
-}
-
-# square root by Newtons method.
-sub main'fsqrt { #(fnum_str[, scale]) return fnum_str
- local($x, $scale) = (&'fnorm($_[0]), $_[1]);
- if ($x eq 'NaN' || $x =~ /^-/) {
- 'NaN';
- } elsif ($x eq '+0E+0') {
- '+0E+0';
- } else {
- local($xm, $xe) = split('E',$x);
- $scale = $div_scale if (!$scale);
- $scale = length($xm)-1 if ($scale < length($xm)-1);
- local($gs, $guess) = (1, sprintf("1E%+d", (length($xm)+$xe-1)/2));
- while ($gs < 2*$scale) {
- $guess = &'fmul(&'fadd($guess,&'fdiv($x,$guess,$gs*2)),".5");
- $gs *= 2;
- }
- &'fround($guess, $scale);
- }
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/bigint.pl b/gnu/usr.bin/perl/lib/bigint.pl
deleted file mode 100644
index 5c79da9..0000000
--- a/gnu/usr.bin/perl/lib/bigint.pl
+++ /dev/null
@@ -1,271 +0,0 @@
-package bigint;
-
-# arbitrary size integer math package
-#
-# by Mark Biggar
-#
-# Canonical Big integer value are strings of the form
-# /^[+-]\d+$/ with leading zeros suppressed
-# Input values to these routines may be strings of the form
-# /^\s*[+-]?[\d\s]+$/.
-# Examples:
-# '+0' canonical zero value
-# ' -123 123 123' canonical value '-123123123'
-# '1 23 456 7890' canonical value '+1234567890'
-# Output values always always in canonical form
-#
-# Actual math is done in an internal format consisting of an array
-# whose first element is the sign (/^[+-]$/) and whose remaining
-# elements are base 100000 digits with the least significant digit first.
-# The string 'NaN' is used to represent the result when input arguments
-# are not numbers, as well as the result of dividing by zero
-#
-# routines provided are:
-#
-# bneg(BINT) return BINT negation
-# babs(BINT) return BINT absolute value
-# bcmp(BINT,BINT) return CODE compare numbers (undef,<0,=0,>0)
-# badd(BINT,BINT) return BINT addition
-# bsub(BINT,BINT) return BINT subtraction
-# bmul(BINT,BINT) return BINT multiplication
-# bdiv(BINT,BINT) return (BINT,BINT) division (quo,rem) just quo if scalar
-# bmod(BINT,BINT) return BINT modulus
-# bgcd(BINT,BINT) return BINT greatest common divisor
-# bnorm(BINT) return BINT normalization
-#
-
-# normalize string form of number. Strip leading zeros. Strip any
-# white space and add a sign, if missing.
-# Strings that are not numbers result the value 'NaN'.
-sub main'bnorm { #(num_str) return num_str
- local($_) = @_;
- s/\s+//g; # strip white space
- if (s/^([+-]?)0*(\d+)$/$1$2/) { # test if number
- substr($_,0,0) = '+' unless $1; # Add missing sign
- s/^-0/+0/;
- $_;
- } else {
- 'NaN';
- }
-}
-
-# Convert a number from string format to internal base 100000 format.
-# Assumes normalized value as input.
-sub internal { #(num_str) return int_num_array
- local($d) = @_;
- ($is,$il) = (substr($d,0,1),length($d)-2);
- substr($d,0,1) = '';
- ($is, reverse(unpack("a" . ($il%5+1) . ("a5" x ($il/5)), $d)));
-}
-
-# Convert a number from internal base 100000 format to string format.
-# This routine scribbles all over input array.
-sub external { #(int_num_array) return num_str
- $es = shift;
- grep($_ > 9999 || ($_ = substr('0000'.$_,-5)), @_); # zero pad
- &'bnorm(join('', $es, reverse(@_))); # reverse concat and normalize
-}
-
-# Negate input value.
-sub main'bneg { #(num_str) return num_str
- local($_) = &'bnorm(@_);
- vec($_,0,8) ^= ord('+') ^ ord('-') unless $_ eq '+0';
- s/^H/N/;
- $_;
-}
-
-# Returns the absolute value of the input.
-sub main'babs { #(num_str) return num_str
- &abs(&'bnorm(@_));
-}
-
-sub abs { # post-normalized abs for internal use
- local($_) = @_;
- s/^-/+/;
- $_;
-}
-
-# Compares 2 values. Returns one of undef, <0, =0, >0. (suitable for sort)
-sub main'bcmp { #(num_str, num_str) return cond_code
- local($x,$y) = (&'bnorm($_[0]),&'bnorm($_[1]));
- if ($x eq 'NaN') {
- undef;
- } elsif ($y eq 'NaN') {
- undef;
- } else {
- &cmp($x,$y);
- }
-}
-
-sub cmp { # post-normalized compare for internal use
- local($cx, $cy) = @_;
- $cx cmp $cy
- &&
- (
- ord($cy) <=> ord($cx)
- ||
- ($cx cmp ',') * (length($cy) <=> length($cx) || $cy cmp $cx)
- );
-}
-
-sub main'badd { #(num_str, num_str) return num_str
- local(*x, *y); ($x, $y) = (&'bnorm($_[0]),&'bnorm($_[1]));
- if ($x eq 'NaN') {
- 'NaN';
- } elsif ($y eq 'NaN') {
- 'NaN';
- } else {
- @x = &internal($x); # convert to internal form
- @y = &internal($y);
- local($sx, $sy) = (shift @x, shift @y); # get signs
- if ($sx eq $sy) {
- &external($sx, &add(*x, *y)); # if same sign add
- } else {
- ($x, $y) = (&abs($x),&abs($y)); # make abs
- if (&cmp($y,$x) > 0) {
- &external($sy, &sub(*y, *x));
- } else {
- &external($sx, &sub(*x, *y));
- }
- }
- }
-}
-
-sub main'bsub { #(num_str, num_str) return num_str
- &'badd($_[0],&'bneg($_[1]));
-}
-
-# GCD -- Euclids algorithm Knuth Vol 2 pg 296
-sub main'bgcd { #(num_str, num_str) return num_str
- local($x,$y) = (&'bnorm($_[0]),&'bnorm($_[1]));
- if ($x eq 'NaN' || $y eq 'NaN') {
- 'NaN';
- } else {
- ($x, $y) = ($y,&'bmod($x,$y)) while $y ne '+0';
- $x;
- }
-}
-
-# routine to add two base 1e5 numbers
-# stolen from Knuth Vol 2 Algorithm A pg 231
-# there are separate routines to add and sub as per Kunth pg 233
-sub add { #(int_num_array, int_num_array) return int_num_array
- local(*x, *y) = @_;
- $car = 0;
- for $x (@x) {
- last unless @y || $car;
- $x -= 1e5 if $car = (($x += shift(@y) + $car) >= 1e5);
- }
- for $y (@y) {
- last unless $car;
- $y -= 1e5 if $car = (($y += $car) >= 1e5);
- }
- (@x, @y, $car);
-}
-
-# subtract base 1e5 numbers -- stolen from Knuth Vol 2 pg 232, $x > $y
-sub sub { #(int_num_array, int_num_array) return int_num_array
- local(*sx, *sy) = @_;
- $bar = 0;
- for $sx (@sx) {
- last unless @y || $bar;
- $sx += 1e5 if $bar = (($sx -= shift(@sy) + $bar) < 0);
- }
- @sx;
-}
-
-# multiply two numbers -- stolen from Knuth Vol 2 pg 233
-sub main'bmul { #(num_str, num_str) return num_str
- local(*x, *y); ($x, $y) = (&'bnorm($_[0]), &'bnorm($_[1]));
- if ($x eq 'NaN') {
- 'NaN';
- } elsif ($y eq 'NaN') {
- 'NaN';
- } else {
- @x = &internal($x);
- @y = &internal($y);
- local($signr) = (shift @x ne shift @y) ? '-' : '+';
- @prod = ();
- for $x (@x) {
- ($car, $cty) = (0, 0);
- for $y (@y) {
- $prod = $x * $y + $prod[$cty] + $car;
- $prod[$cty++] =
- $prod - ($car = int($prod * 1e-5)) * 1e5;
- }
- $prod[$cty] += $car if $car;
- $x = shift @prod;
- }
- &external($signr, @x, @prod);
- }
-}
-
-# modulus
-sub main'bmod { #(num_str, num_str) return num_str
- (&'bdiv(@_))[1];
-}
-
-sub main'bdiv { #(dividend: num_str, divisor: num_str) return num_str
- local (*x, *y); ($x, $y) = (&'bnorm($_[0]), &'bnorm($_[1]));
- return wantarray ? ('NaN','NaN') : 'NaN'
- if ($x eq 'NaN' || $y eq 'NaN' || $y eq '+0');
- return wantarray ? ('+0',$x) : '+0' if (&cmp(&abs($x),&abs($y)) < 0);
- @x = &internal($x); @y = &internal($y);
- $srem = $y[0];
- $sr = (shift @x ne shift @y) ? '-' : '+';
- $car = $bar = $prd = 0;
- if (($dd = int(1e5/($y[$#y]+1))) != 1) {
- for $x (@x) {
- $x = $x * $dd + $car;
- $x -= ($car = int($x * 1e-5)) * 1e5;
- }
- push(@x, $car); $car = 0;
- for $y (@y) {
- $y = $y * $dd + $car;
- $y -= ($car = int($y * 1e-5)) * 1e5;
- }
- }
- else {
- push(@x, 0);
- }
- @q = (); ($v2,$v1) = @y[$#y-1,$#y];
- while ($#x > $#y) {
- ($u2,$u1,$u0) = @x[($#x-2)..$#x];
- $q = (($u0 == $v1) ? 99999 : int(($u0*1e5+$u1)/$v1));
- --$q while ($v2*$q > ($u0*1e5+$u1-$q*$v1)*1e5+$u2);
- if ($q) {
- ($car, $bar) = (0,0);
- for ($y = 0, $x = $#x-$#y-1; $y <= $#y; ++$y,++$x) {
- $prd = $q * $y[$y] + $car;
- $prd -= ($car = int($prd * 1e-5)) * 1e5;
- $x[$x] += 1e5 if ($bar = (($x[$x] -= $prd + $bar) < 0));
- }
- if ($x[$#x] < $car + $bar) {
- $car = 0; --$q;
- for ($y = 0, $x = $#x-$#y-1; $y <= $#y; ++$y,++$x) {
- $x[$x] -= 1e5
- if ($car = (($x[$x] += $y[$y] + $car) > 1e5));
- }
- }
- }
- pop(@x); unshift(@q, $q);
- }
- if (wantarray) {
- @d = ();
- if ($dd != 1) {
- $car = 0;
- for $x (reverse @x) {
- $prd = $car * 1e5 + $x;
- $car = $prd - ($tmp = int($prd / $dd)) * $dd;
- unshift(@d, $tmp);
- }
- }
- else {
- @d = @x;
- }
- (&external($sr, @q), &external($srem, @d, 0));
- } else {
- &external($sr, @q);
- }
-}
-1;
diff --git a/gnu/usr.bin/perl/lib/bigrat.pl b/gnu/usr.bin/perl/lib/bigrat.pl
deleted file mode 100644
index fb10cf3..0000000
--- a/gnu/usr.bin/perl/lib/bigrat.pl
+++ /dev/null
@@ -1,148 +0,0 @@
-package bigrat;
-require "bigint.pl";
-
-# Arbitrary size rational math package
-#
-# by Mark Biggar
-#
-# Input values to these routines consist of strings of the form
-# m|^\s*[+-]?[\d\s]+(/[\d\s]+)?$|.
-# Examples:
-# "+0/1" canonical zero value
-# "3" canonical value "+3/1"
-# " -123/123 123" canonical value "-1/1001"
-# "123 456/7890" canonical value "+20576/1315"
-# Output values always include a sign and no leading zeros or
-# white space.
-# This package makes use of the bigint package.
-# The string 'NaN' is used to represent the result when input arguments
-# that are not numbers, as well as the result of dividing by zero and
-# the sqrt of a negative number.
-# Extreamly naive algorthims are used.
-#
-# Routines provided are:
-#
-# rneg(RAT) return RAT negation
-# rabs(RAT) return RAT absolute value
-# rcmp(RAT,RAT) return CODE compare numbers (undef,<0,=0,>0)
-# radd(RAT,RAT) return RAT addition
-# rsub(RAT,RAT) return RAT subtraction
-# rmul(RAT,RAT) return RAT multiplication
-# rdiv(RAT,RAT) return RAT division
-# rmod(RAT) return (RAT,RAT) integer and fractional parts
-# rnorm(RAT) return RAT normalization
-# rsqrt(RAT, cycles) return RAT square root
-
-# Convert a number to the canonical string form m|^[+-]\d+/\d+|.
-sub main'rnorm { #(string) return rat_num
- local($_) = @_;
- s/\s+//g;
- if (m#^([+-]?\d+)(/(\d*[1-9]0*))?$#) {
- &norm($1, $3 ? $3 : '+1');
- } else {
- 'NaN';
- }
-}
-
-# Normalize by reducing to lowest terms
-sub norm { #(bint, bint) return rat_num
- local($num,$dom) = @_;
- if ($num eq 'NaN') {
- 'NaN';
- } elsif ($dom eq 'NaN') {
- 'NaN';
- } elsif ($dom =~ /^[+-]?0+$/) {
- 'NaN';
- } else {
- local($gcd) = &'bgcd($num,$dom);
- if ($gcd ne '+1') {
- $num = &'bdiv($num,$gcd);
- $dom = &'bdiv($dom,$gcd);
- } else {
- $num = &'bnorm($num);
- $dom = &'bnorm($dom);
- }
- substr($dom,0,1) = '';
- "$num/$dom";
- }
-}
-
-# negation
-sub main'rneg { #(rat_num) return rat_num
- local($_) = &'rnorm($_[0]);
- tr/-+/+-/ if ($_ ne '+0/1');
- $_;
-}
-
-# absolute value
-sub main'rabs { #(rat_num) return $rat_num
- local($_) = &'rnorm($_[0]);
- substr($_,0,1) = '+' unless $_ eq 'NaN';
- $_;
-}
-
-# multipication
-sub main'rmul { #(rat_num, rat_num) return rat_num
- local($xn,$xd) = split('/',&'rnorm($_[0]));
- local($yn,$yd) = split('/',&'rnorm($_[1]));
- &norm(&'bmul($xn,$yn),&'bmul($xd,$yd));
-}
-
-# division
-sub main'rdiv { #(rat_num, rat_num) return rat_num
- local($xn,$xd) = split('/',&'rnorm($_[0]));
- local($yn,$yd) = split('/',&'rnorm($_[1]));
- &norm(&'bmul($xn,$yd),&'bmul($xd,$yn));
-}
-
-# addition
-sub main'radd { #(rat_num, rat_num) return rat_num
- local($xn,$xd) = split('/',&'rnorm($_[0]));
- local($yn,$yd) = split('/',&'rnorm($_[1]));
- &norm(&'badd(&'bmul($xn,$yd),&'bmul($yn,$xd)),&'bmul($xd,$yd));
-}
-
-# subtraction
-sub main'rsub { #(rat_num, rat_num) return rat_num
- local($xn,$xd) = split('/',&'rnorm($_[0]));
- local($yn,$yd) = split('/',&'rnorm($_[1]));
- &norm(&'bsub(&'bmul($xn,$yd),&'bmul($yn,$xd)),&'bmul($xd,$yd));
-}
-
-# comparison
-sub main'rcmp { #(rat_num, rat_num) return cond_code
- local($xn,$xd) = split('/',&'rnorm($_[0]));
- local($yn,$yd) = split('/',&'rnorm($_[1]));
- &bigint'cmp(&'bmul($xn,$yd),&'bmul($yn,$xd));
-}
-
-# int and frac parts
-sub main'rmod { #(rat_num) return (rat_num,rat_num)
- local($xn,$xd) = split('/',&'rnorm($_[0]));
- local($i,$f) = &'bdiv($xn,$xd);
- if (wantarray) {
- ("$i/1", "$f/$xd");
- } else {
- "$i/1";
- }
-}
-
-# square root by Newtons method.
-# cycles specifies the number of iterations default: 5
-sub main'rsqrt { #(fnum_str[, cycles]) return fnum_str
- local($x, $scale) = (&'rnorm($_[0]), $_[1]);
- if ($x eq 'NaN') {
- 'NaN';
- } elsif ($x =~ /^-/) {
- 'NaN';
- } else {
- local($gscale, $guess) = (0, '+1/1');
- $scale = 5 if (!$scale);
- while ($gscale++ < $scale) {
- $guess = &'rmul(&'radd($guess,&'rdiv($x,$guess)),"+1/2");
- }
- "$guess"; # quotes necessary due to perl bug
- }
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/cacheout.pl b/gnu/usr.bin/perl/lib/cacheout.pl
deleted file mode 100644
index 513c25b..0000000
--- a/gnu/usr.bin/perl/lib/cacheout.pl
+++ /dev/null
@@ -1,40 +0,0 @@
-# Open in their package.
-
-sub cacheout'open {
- open($_[0], $_[1]);
-}
-
-# But only this sub name is visible to them.
-
-sub cacheout {
- package cacheout;
-
- ($file) = @_;
- if (!$isopen{$file}) {
- if (++$numopen > $maxopen) {
- local(@lru) = sort {$isopen{$a} <=> $isopen{$b};} keys(%isopen);
- splice(@lru, $maxopen / 3);
- $numopen -= @lru;
- for (@lru) { close $_; delete $isopen{$_}; }
- }
- &open($file, ($saw{$file}++ ? '>>' : '>') . $file)
- || die "Can't create $file: $!\n";
- }
- $isopen{$file} = ++$seq;
-}
-
-package cacheout;
-
-$seq = 0;
-$numopen = 0;
-
-if (open(PARAM,'/usr/include/sys/param.h')) {
- local($.);
- while (<PARAM>) {
- $maxopen = $1 - 4 if /^\s*#\s*define\s+NOFILE\s+(\d+)/;
- }
- close PARAM;
-}
-$maxopen = 16 unless $maxopen;
-
-1;
diff --git a/gnu/usr.bin/perl/lib/chat2.pl b/gnu/usr.bin/perl/lib/chat2.pl
deleted file mode 100644
index 662872c..0000000
--- a/gnu/usr.bin/perl/lib/chat2.pl
+++ /dev/null
@@ -1,339 +0,0 @@
-## chat.pl: chat with a server
-## V2.01.alpha.7 91/06/16
-## Randal L. Schwartz
-
-package chat;
-
-$sockaddr = 'S n a4 x8';
-chop($thishost = `hostname`); $thisaddr = (gethostbyname($thishost))[4];
-$thisproc = pack($sockaddr, 2, 0, $thisaddr);
-
-# *S = symbol for current I/O, gets assigned *chatsymbol....
-$next = "chatsymbol000000"; # next one
-$nextpat = "^chatsymbol"; # patterns that match next++, ++, ++, ++
-
-
-## $handle = &chat'open_port("server.address",$port_number);
-## opens a named or numbered TCP server
-
-sub open_port { ## public
- local($server, $port) = @_;
-
- local($serveraddr,$serverproc);
-
- *S = ++$next;
- if ($server =~ /^(\d+)+\.(\d+)\.(\d+)\.(\d+)$/) {
- $serveraddr = pack('C4', $1, $2, $3, $4);
- } else {
- local(@x) = gethostbyname($server);
- return undef unless @x;
- $serveraddr = $x[4];
- }
- $serverproc = pack($sockaddr, 2, $port, $serveraddr);
- unless (socket(S, 2, 1, 6)) {
- # XXX hardwired $AF_SOCKET, $SOCK_STREAM, 'tcp'
- # but who the heck would change these anyway? (:-)
- ($!) = ($!, close(S)); # close S while saving $!
- return undef;
- }
- unless (bind(S, $thisproc)) {
- ($!) = ($!, close(S)); # close S while saving $!
- return undef;
- }
- unless (connect(S, $serverproc)) {
- ($!) = ($!, close(S)); # close S while saving $!
- return undef;
- }
- select((select(S), $| = 1)[0]);
- $next; # return symbol for switcharound
-}
-
-## ($host, $port, $handle) = &chat'open_listen([$port_number]);
-## opens a TCP port on the current machine, ready to be listened to
-## if $port_number is absent or zero, pick a default port number
-## process must be uid 0 to listen to a low port number
-
-sub open_listen { ## public
-
- *S = ++$next;
- local($thisport) = shift || 0;
- local($thisproc_local) = pack($sockaddr, 2, $thisport, $thisaddr);
- local(*NS) = "__" . time;
- unless (socket(NS, 2, 1, 6)) {
- # XXX hardwired $AF_SOCKET, $SOCK_STREAM, 'tcp'
- # but who the heck would change these anyway? (:-)
- ($!) = ($!, close(NS));
- return undef;
- }
- unless (bind(NS, $thisproc_local)) {
- ($!) = ($!, close(NS));
- return undef;
- }
- unless (listen(NS, 1)) {
- ($!) = ($!, close(NS));
- return undef;
- }
- select((select(NS), $| = 1)[0]);
- local($family, $port, @myaddr) =
- unpack("S n C C C C x8", getsockname(NS));
- $S{"needs_accept"} = *NS; # so expect will open it
- (@myaddr, $port, $next); # returning this
-}
-
-## $handle = &chat'open_proc("command","arg1","arg2",...);
-## opens a /bin/sh on a pseudo-tty
-
-sub open_proc { ## public
- local(@cmd) = @_;
-
- *S = ++$next;
- local(*TTY) = "__TTY" . time;
- local($pty,$tty) = &_getpty(S,TTY);
- die "Cannot find a new pty" unless defined $pty;
- local($pid) = fork;
- die "Cannot fork: $!" unless defined $pid;
- unless ($pid) {
- close STDIN; close STDOUT; close STDERR;
- setpgrp(0,$$);
- if (open(DEVTTY, "/dev/tty")) {
- ioctl(DEVTTY,0x20007471,0); # XXX s/b &TIOCNOTTY
- close DEVTTY;
- }
- open(STDIN,"<&TTY");
- open(STDOUT,">&TTY");
- open(STDERR,">&STDOUT");
- die "Oops" unless fileno(STDERR) == 2; # sanity
- close(S);
- exec @cmd;
- die "Cannot exec @cmd: $!";
- }
- close(TTY);
- $PID{$next} = $pid;
- $next; # return symbol for switcharound
-}
-
-# $S is the read-ahead buffer
-
-## $return = &chat'expect([$handle,] $timeout_time,
-## $pat1, $body1, $pat2, $body2, ... )
-## $handle is from previous &chat'open_*().
-## $timeout_time is the time (either relative to the current time, or
-## absolute, ala time(2)) at which a timeout event occurs.
-## $pat1, $pat2, and so on are regexs which are matched against the input
-## stream. If a match is found, the entire matched string is consumed,
-## and the corresponding body eval string is evaled.
-##
-## Each pat is a regular-expression (probably enclosed in single-quotes
-## in the invocation). ^ and $ will work, respecting the current value of $*.
-## If pat is 'TIMEOUT', the body is executed if the timeout is exceeded.
-## If pat is 'EOF', the body is executed if the process exits before
-## the other patterns are seen.
-##
-## Pats are scanned in the order given, so later pats can contain
-## general defaults that won't be examined unless the earlier pats
-## have failed.
-##
-## The result of eval'ing body is returned as the result of
-## the invocation. Recursive invocations are not thought
-## through, and may work only accidentally. :-)
-##
-## undef is returned if either a timeout or an eof occurs and no
-## corresponding body has been defined.
-## I/O errors of any sort are treated as eof.
-
-$nextsubname = "expectloop000000"; # used for subroutines
-
-sub expect { ## public
- if ($_[0] =~ /$nextpat/) {
- *S = shift;
- }
- local($endtime) = shift;
-
- local($timeout,$eof) = (1,1);
- local($caller) = caller;
- local($rmask, $nfound, $timeleft, $thisbuf);
- local($cases, $pattern, $action, $subname);
- $endtime += time if $endtime < 600_000_000;
-
- if (defined $S{"needs_accept"}) { # is it a listen socket?
- local(*NS) = $S{"needs_accept"};
- delete $S{"needs_accept"};
- $S{"needs_close"} = *NS;
- unless(accept(S,NS)) {
- ($!) = ($!, close(S), close(NS));
- return undef;
- }
- select((select(S), $| = 1)[0]);
- }
-
- # now see whether we need to create a new sub:
-
- unless ($subname = $expect_subname{$caller,@_}) {
- # nope. make a new one:
- $expect_subname{$caller,@_} = $subname = $nextsubname++;
-
- $cases .= <<"EDQ"; # header is funny to make everything elsif's
-sub $subname {
- LOOP: {
- if (0) { ; }
-EDQ
- while (@_) {
- ($pattern,$action) = splice(@_,0,2);
- if ($pattern =~ /^eof$/i) {
- $cases .= <<"EDQ";
- elsif (\$eof) {
- package $caller;
- $action;
- }
-EDQ
- $eof = 0;
- } elsif ($pattern =~ /^timeout$/i) {
- $cases .= <<"EDQ";
- elsif (\$timeout) {
- package $caller;
- $action;
- }
-EDQ
- $timeout = 0;
- } else {
- $pattern =~ s#/#\\/#g;
- $cases .= <<"EDQ";
- elsif (\$S =~ /$pattern/) {
- \$S = \$';
- package $caller;
- $action;
- }
-EDQ
- }
- }
- $cases .= <<"EDQ" if $eof;
- elsif (\$eof) {
- undef;
- }
-EDQ
- $cases .= <<"EDQ" if $timeout;
- elsif (\$timeout) {
- undef;
- }
-EDQ
- $cases .= <<'ESQ';
- else {
- $rmask = "";
- vec($rmask,fileno(S),1) = 1;
- ($nfound, $rmask) =
- select($rmask, undef, undef, $endtime - time);
- if ($nfound) {
- $nread = sysread(S, $thisbuf, 1024);
- if ($nread > 0) {
- $S .= $thisbuf;
- } else {
- $eof++, redo LOOP; # any error is also eof
- }
- } else {
- $timeout++, redo LOOP; # timeout
- }
- redo LOOP;
- }
- }
-}
-ESQ
- eval $cases; die "$cases:\n$@" if $@;
- }
- $eof = $timeout = 0;
- do $subname();
-}
-
-## &chat'print([$handle,] @data)
-## $handle is from previous &chat'open().
-## like print $handle @data
-
-sub print { ## public
- if ($_[0] =~ /$nextpat/) {
- *S = shift;
- }
- print S @_;
-}
-
-## &chat'close([$handle,])
-## $handle is from previous &chat'open().
-## like close $handle
-
-sub close { ## public
- local($pid);
- if ($_[0] =~ /$nextpat/) {
- $pid = $PID{$_[0]};
- *S = shift;
- } else {
- $pid = $PID{$next};
- }
- close(S);
- waitpid($pid,0);
- if (defined $S{"needs_close"}) { # is it a listen socket?
- local(*NS) = $S{"needs_close"};
- delete $S{"needs_close"};
- close(NS);
- }
-}
-
-## @ready_handles = &chat'select($timeout, @handles)
-## select()'s the handles with a timeout value of $timeout seconds.
-## Returns an array of handles that are ready for I/O.
-## Both user handles and chat handles are supported (but beware of
-## stdio's buffering for user handles).
-
-sub select { ## public
- local($timeout) = shift;
- local(@handles) = @_;
- local(%handlename) = ();
- local(%ready) = ();
- local($caller) = caller;
- local($rmask) = "";
- for (@handles) {
- if (/$nextpat/o) { # one of ours... see if ready
- local(*SYM) = $_;
- if (length($SYM)) {
- $timeout = 0; # we have a winner
- $ready{$_}++;
- }
- $handlename{fileno($_)} = $_;
- } else {
- $handlename{fileno(/'/ ? $_ : "$caller\'$_")} = $_;
- }
- }
- for (sort keys %handlename) {
- vec($rmask, $_, 1) = 1;
- }
- select($rmask, undef, undef, $timeout);
- for (sort keys %handlename) {
- $ready{$handlename{$_}}++ if vec($rmask,$_,1);
- }
- sort keys %ready;
-}
-
-# ($pty,$tty) = $chat'_getpty(PTY,TTY):
-# internal procedure to get the next available pty.
-# opens pty on handle PTY, and matching tty on handle TTY.
-# returns undef if can't find a pty.
-
-sub _getpty { ## private
- local($_PTY,$_TTY) = @_;
- $_PTY =~ s/^([^']+)$/(caller)[$[]."'".$1/e;
- $_TTY =~ s/^([^']+)$/(caller)[$[]."'".$1/e;
- local($pty,$tty);
- for $bank (112..127) {
- next unless -e sprintf("/dev/pty%c0", $bank);
- for $unit (48..57) {
- $pty = sprintf("/dev/pty%c%c", $bank, $unit);
- open($_PTY,"+>$pty") || next;
- select((select($_PTY), $| = 1)[0]);
- ($tty = $pty) =~ s/pty/tty/;
- open($_TTY,"+>$tty") || next;
- select((select($_TTY), $| = 1)[0]);
- system "stty nl>$tty";
- return ($pty,$tty);
- }
- }
- undef;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/complete.pl b/gnu/usr.bin/perl/lib/complete.pl
deleted file mode 100644
index dabf8f6..0000000
--- a/gnu/usr.bin/perl/lib/complete.pl
+++ /dev/null
@@ -1,110 +0,0 @@
-;#
-;# @(#)complete.pl,v1.1 (me@anywhere.EBay.Sun.COM) 09/23/91
-;#
-;# Author: Wayne Thompson
-;#
-;# Description:
-;# This routine provides word completion.
-;# (TAB) attempts word completion.
-;# (^D) prints completion list.
-;# (These may be changed by setting $Complete'complete, etc.)
-;#
-;# Diagnostics:
-;# Bell when word completion fails.
-;#
-;# Dependencies:
-;# The tty driver is put into raw mode.
-;#
-;# Bugs:
-;#
-;# Usage:
-;# $input = &Complete('prompt_string', *completion_list);
-;# or
-;# $input = &Complete('prompt_string', @completion_list);
-;#
-
-CONFIG: {
- package Complete;
-
- $complete = "\004";
- $kill = "\025";
- $erase1 = "\177";
- $erase2 = "\010";
-}
-
-sub Complete {
- package Complete;
-
- local($[) = 0;
- if ($_[1] =~ /^StB\0/) {
- ($prompt, *_) = @_;
- }
- else {
- $prompt = shift(@_);
- }
- @cmp_lst = sort(@_);
-
- system('stty raw -echo');
- LOOP: {
- print($prompt, $return);
- while (($_ = getc(STDIN)) ne "\r") {
- CASE: {
- # (TAB) attempt completion
- $_ eq "\t" && do {
- @match = grep(/^$return/, @cmp_lst);
- $l = length($test = shift(@match));
- unless ($#match < 0) {
- foreach $cmp (@match) {
- until (substr($cmp, 0, $l) eq substr($test, 0, $l)) {
- $l--;
- }
- }
- print("\a");
- }
- print($test = substr($test, $r, $l - $r));
- $r = length($return .= $test);
- last CASE;
- };
-
- # (^D) completion list
- $_ eq $complete && do {
- print(join("\r\n", '', grep(/^$return/, @cmp_lst)), "\r\n");
- redo LOOP;
- };
-
- # (^U) kill
- $_ eq $kill && do {
- if ($r) {
- undef($r, $return);
- print("\r\n");
- redo LOOP;
- }
- last CASE;
- };
-
- # (DEL) || (BS) erase
- ($_ eq $erase1 || $_ eq $erase2) && do {
- if($r) {
- print("\b \b");
- chop($return);
- $r--;
- }
- last CASE;
- };
-
- # printable char
- ord >= 32 && do {
- $return .= $_;
- $r++;
- print;
- last CASE;
- };
- }
- }
- }
- system('stty -raw echo');
- print("\n");
- $return;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/ctime.pl b/gnu/usr.bin/perl/lib/ctime.pl
deleted file mode 100644
index 4c59754..0000000
--- a/gnu/usr.bin/perl/lib/ctime.pl
+++ /dev/null
@@ -1,51 +0,0 @@
-;# ctime.pl is a simple Perl emulation for the well known ctime(3C) function.
-;#
-;# Waldemar Kebsch, Federal Republic of Germany, November 1988
-;# kebsch.pad@nixpbe.UUCP
-;# Modified March 1990, Feb 1991 to properly handle timezones
-;# $RCSfile: ctime.pl,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:29:52 $
-;# Marion Hakanson (hakanson@cse.ogi.edu)
-;# Oregon Graduate Institute of Science and Technology
-;#
-;# usage:
-;#
-;# #include <ctime.pl> # see the -P and -I option in perl.man
-;# $Date = &ctime(time);
-
-CONFIG: {
- package ctime;
-
- @DoW = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
- @MoY = ('Jan','Feb','Mar','Apr','May','Jun',
- 'Jul','Aug','Sep','Oct','Nov','Dec');
-}
-
-sub ctime {
- package ctime;
-
- local($time) = @_;
- local($[) = 0;
- local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
-
- # Determine what time zone is in effect.
- # Use GMT if TZ is defined as null, local time if TZ undefined.
- # There's no portable way to find the system default timezone.
-
- $TZ = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : '';
- ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
- ($TZ eq 'GMT') ? gmtime($time) : localtime($time);
-
- # Hack to deal with 'PST8PDT' format of TZ
- # Note that this can't deal with all the esoteric forms, but it
- # does recognize the most common: [:]STDoff[DST[off][,rule]]
-
- if($TZ=~/^([^:\d+\-,]{3,})([+-]?\d{1,2}(:\d{1,2}){0,2})([^\d+\-,]{3,})?/){
- $TZ = $isdst ? $4 : $1;
- }
- $TZ .= ' ' unless $TZ eq '';
-
- $year += ($year < 70) ? 2000 : 1900;
- sprintf("%s %s %2d %2d:%02d:%02d %s%4d\n",
- $DoW[$wday], $MoY[$mon], $mday, $hour, $min, $sec, $TZ, $year);
-}
-1;
diff --git a/gnu/usr.bin/perl/lib/dumpvar.pl b/gnu/usr.bin/perl/lib/dumpvar.pl
deleted file mode 100644
index 5427494..0000000
--- a/gnu/usr.bin/perl/lib/dumpvar.pl
+++ /dev/null
@@ -1,37 +0,0 @@
-package dumpvar;
-
-# translate control chars to ^X - Randal Schwartz
-sub unctrl {
- local($_) = @_;
- s/([\001-\037\177])/'^'.pack('c',ord($1)^64)/eg;
- $_;
-}
-sub main'dumpvar {
- ($package,@vars) = @_;
- local(*stab) = eval("*_$package");
- while (($key,$val) = each(%stab)) {
- {
- next if @vars && !grep($key eq $_,@vars);
- local(*entry) = $val;
- if (defined $entry) {
- print "\$$key = '",&unctrl($entry),"'\n";
- }
- if (defined @entry) {
- print "\@$key = (\n";
- foreach $num ($[ .. $#entry) {
- print " $num\t'",&unctrl($entry[$num]),"'\n";
- }
- print ")\n";
- }
- if ($key ne "_$package" && $key ne "_DB" && defined %entry) {
- print "\%$key = (\n";
- foreach $key (sort keys(%entry)) {
- print " $key\t'",&unctrl($entry{$key}),"'\n";
- }
- print ")\n";
- }
- }
- }
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/exceptions.pl b/gnu/usr.bin/perl/lib/exceptions.pl
deleted file mode 100644
index 02c4498..0000000
--- a/gnu/usr.bin/perl/lib/exceptions.pl
+++ /dev/null
@@ -1,54 +0,0 @@
-# exceptions.pl
-# tchrist@convex.com
-#
-# Here's a little code I use for exception handling. It's really just
-# glorfied eval/die. The way to use use it is when you might otherwise
-# exit, use &throw to raise an exception. The first enclosing &catch
-# handler looks at the exception and decides whether it can catch this kind
-# (catch takes a list of regexps to catch), and if so, it returns the one it
-# caught. If it *can't* catch it, then it will reraise the exception
-# for someone else to possibly see, or to die otherwise.
-#
-# I use oddly named variables in order to make darn sure I don't conflict
-# with my caller. I also hide in my own package, and eval the code in his.
-#
-# The EXCEPTION: prefix is so you can tell whether it's a user-raised
-# exception or a perl-raised one (eval error).
-#
-# --tom
-#
-# examples:
-# if (&catch('/$user_input/', 'regexp', 'syntax error') {
-# warn "oops try again";
-# redo;
-# }
-#
-# if ($error = &catch('&subroutine()')) { # catches anything
-#
-# &throw('bad input') if /^$/;
-
-sub catch {
- package exception;
- local($__code__, @__exceptions__) = @_;
- local($__package__) = caller;
- local($__exception__);
-
- eval "package $__package__; $__code__";
- if ($__exception__ = &'thrown) {
- for (@__exceptions__) {
- return $__exception__ if /$__exception__/;
- }
- &'throw($__exception__);
- }
-}
-
-sub throw {
- local($exception) = @_;
- die "EXCEPTION: $exception\n";
-}
-
-sub thrown {
- $@ =~ /^(EXCEPTION: )+(.+)/ && $2;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/fastcwd.pl b/gnu/usr.bin/perl/lib/fastcwd.pl
deleted file mode 100644
index 6b452e8..0000000
--- a/gnu/usr.bin/perl/lib/fastcwd.pl
+++ /dev/null
@@ -1,35 +0,0 @@
-# By John Bazik
-#
-# Usage: $cwd = &fastcwd;
-#
-# This is a faster version of getcwd. It's also more dangerous because
-# you might chdir out of a directory that you can't chdir back into.
-
-sub fastcwd {
- local($odev, $oino, $cdev, $cino, $tdev, $tino);
- local(@path, $path);
- local(*DIR);
-
- ($cdev, $cino) = stat('.');
- for (;;) {
- ($odev, $oino) = ($cdev, $cino);
- chdir('..');
- ($cdev, $cino) = stat('.');
- last if $odev == $cdev && $oino == $cino;
- opendir(DIR, '.');
- for (;;) {
- $_ = readdir(DIR);
- next if $_ eq '.';
- next if $_ eq '..';
-
- last unless $_;
- ($tdev, $tino) = lstat($_);
- last unless $tdev != $odev || $tino != $oino;
- }
- closedir(DIR);
- unshift(@path, $_);
- }
- chdir($path = '/' . join('/', @path));
- $path;
-}
-1;
diff --git a/gnu/usr.bin/perl/lib/find.pl b/gnu/usr.bin/perl/lib/find.pl
deleted file mode 100644
index 8dab054..0000000
--- a/gnu/usr.bin/perl/lib/find.pl
+++ /dev/null
@@ -1,106 +0,0 @@
-# Usage:
-# require "find.pl";
-#
-# &find('/foo','/bar');
-#
-# sub wanted { ... }
-# where wanted does whatever you want. $dir contains the
-# current directory name, and $_ the current filename within
-# that directory. $name contains "$dir/$_". You are cd'ed
-# to $dir when the function is called. The function may
-# set $prune to prune the tree.
-#
-# This library is primarily for find2perl, which, when fed
-#
-# find2perl / -name .nfs\* -mtime +7 -exec rm -f {} \; -o -fstype nfs -prune
-#
-# spits out something like this
-#
-# sub wanted {
-# /^\.nfs.*$/ &&
-# (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
-# int(-M _) > 7 &&
-# unlink($_)
-# ||
-# ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
-# $dev < 0 &&
-# ($prune = 1);
-# }
-
-sub find {
- chop($cwd = `pwd`);
- foreach $topdir (@_) {
- (($topdev,$topino,$topmode,$topnlink) = stat($topdir))
- || (warn("Can't stat $topdir: $!\n"), next);
- if (-d _) {
- if (chdir($topdir)) {
- ($dir,$_) = ($topdir,'.');
- $name = $topdir;
- &wanted;
- $topdir =~ s,/$,, ;
- &finddir($topdir,$topnlink);
- }
- else {
- warn "Can't cd to $topdir: $!\n";
- }
- }
- else {
- unless (($dir,$_) = $topdir =~ m#^(.*/)(.*)$#) {
- ($dir,$_) = ('.', $topdir);
- }
- $name = $topdir;
- chdir $dir && &wanted;
- }
- chdir $cwd;
- }
-}
-
-sub finddir {
- local($dir,$nlink) = @_;
- local($dev,$ino,$mode,$subcount);
- local($name);
-
- # Get the list of files in the current directory.
-
- opendir(DIR,'.') || (warn "Can't open $dir: $!\n", return);
- local(@filenames) = readdir(DIR);
- closedir(DIR);
-
- if ($nlink == 2) { # This dir has no subdirectories.
- for (@filenames) {
- next if $_ eq '.';
- next if $_ eq '..';
- $name = "$dir/$_";
- $nlink = 0;
- &wanted;
- }
- }
- else { # This dir has subdirectories.
- $subcount = $nlink - 2;
- for (@filenames) {
- next if $_ eq '.';
- next if $_ eq '..';
- $nlink = $prune = 0;
- $name = "$dir/$_";
- &wanted;
- if ($subcount > 0) { # Seen all the subdirs?
-
- # Get link count and check for directoriness.
-
- ($dev,$ino,$mode,$nlink) = lstat($_) unless $nlink;
-
- if (-d _) {
-
- # It really is a directory, so do it recursively.
-
- if (!$prune && chdir $_) {
- &finddir($name,$nlink);
- chdir '..';
- }
- --$subcount;
- }
- }
- }
- }
-}
-1;
diff --git a/gnu/usr.bin/perl/lib/finddepth.pl b/gnu/usr.bin/perl/lib/finddepth.pl
deleted file mode 100644
index 15e4daf..0000000
--- a/gnu/usr.bin/perl/lib/finddepth.pl
+++ /dev/null
@@ -1,105 +0,0 @@
-# Usage:
-# require "finddepth.pl";
-#
-# &finddepth('/foo','/bar');
-#
-# sub wanted { ... }
-# where wanted does whatever you want. $dir contains the
-# current directory name, and $_ the current filename within
-# that directory. $name contains "$dir/$_". You are cd'ed
-# to $dir when the function is called. The function may
-# set $prune to prune the tree.
-#
-# This library is primarily for find2perl, which, when fed
-#
-# find2perl / -name .nfs\* -mtime +7 -exec rm -f {} \; -o -fstype nfs -prune
-#
-# spits out something like this
-#
-# sub wanted {
-# /^\.nfs.*$/ &&
-# (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
-# int(-M _) > 7 &&
-# unlink($_)
-# ||
-# ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
-# $dev < 0 &&
-# ($prune = 1);
-# }
-
-sub finddepth {
- chop($cwd = `pwd`);
- foreach $topdir (@_) {
- (($topdev,$topino,$topmode,$topnlink) = stat($topdir))
- || (warn("Can't stat $topdir: $!\n"), next);
- if (-d _) {
- if (chdir($topdir)) {
- $topdir =~ s,/$,, ;
- &finddepthdir($topdir,$topnlink);
- ($dir,$_) = ($topdir,'.');
- $name = $topdir;
- &wanted;
- }
- else {
- warn "Can't cd to $topdir: $!\n";
- }
- }
- else {
- unless (($dir,$_) = $topdir =~ m#^(.*/)(.*)$#) {
- ($dir,$_) = ('.', $topdir);
- }
- chdir $dir && &wanted;
- }
- chdir $cwd;
- }
-}
-
-sub finddepthdir {
- local($dir,$nlink) = @_;
- local($dev,$ino,$mode,$subcount);
- local($name);
-
- # Get the list of files in the current directory.
-
- opendir(DIR,'.') || warn "Can't open $dir: $!\n";
- local(@filenames) = readdir(DIR);
- closedir(DIR);
-
- if ($nlink == 2) { # This dir has no subdirectories.
- for (@filenames) {
- next if $_ eq '.';
- next if $_ eq '..';
- $name = "$dir/$_";
- $nlink = 0;
- &wanted;
- }
- }
- else { # This dir has subdirectories.
- $subcount = $nlink - 2;
- for (@filenames) {
- next if $_ eq '.';
- next if $_ eq '..';
- $nlink = $prune = 0;
- $name = "$dir/$_";
- if ($subcount > 0) { # Seen all the subdirs?
-
- # Get link count and check for directoriness.
-
- ($dev,$ino,$mode,$nlink) = lstat($_) unless $nlink;
-
- if (-d _) {
-
- # It really is a directory, so do it recursively.
-
- if (!$prune && chdir $_) {
- &finddepthdir($name,$nlink);
- chdir '..';
- }
- --$subcount;
- }
- }
- &wanted;
- }
- }
-}
-1;
diff --git a/gnu/usr.bin/perl/lib/flush.pl b/gnu/usr.bin/perl/lib/flush.pl
deleted file mode 100644
index 55002b9..0000000
--- a/gnu/usr.bin/perl/lib/flush.pl
+++ /dev/null
@@ -1,23 +0,0 @@
-;# Usage: &flush(FILEHANDLE)
-;# flushes the named filehandle
-
-;# Usage: &printflush(FILEHANDLE, "prompt: ")
-;# prints arguments and flushes filehandle
-
-sub flush {
- local($old) = select(shift);
- $| = 1;
- print "";
- $| = 0;
- select($old);
-}
-
-sub printflush {
- local($old) = select(shift);
- $| = 1;
- print @_;
- $| = 0;
- select($old);
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/getcwd.pl b/gnu/usr.bin/perl/lib/getcwd.pl
deleted file mode 100644
index a3214ba..0000000
--- a/gnu/usr.bin/perl/lib/getcwd.pl
+++ /dev/null
@@ -1,62 +0,0 @@
-# By Brandon S. Allbery
-#
-# Usage: $cwd = &getcwd;
-
-sub getcwd
-{
- local($dotdots, $cwd, @pst, @cst, $dir, @tst);
-
- unless (@cst = stat('.'))
- {
- warn "stat(.): $!";
- return '';
- }
- $cwd = '';
- do
- {
- $dotdots .= '/' if $dotdots;
- $dotdots .= '..';
- @pst = @cst;
- unless (opendir(getcwd'PARENT, $dotdots)) #'))
- {
- warn "opendir($dotdots): $!";
- return '';
- }
- unless (@cst = stat($dotdots))
- {
- warn "stat($dotdots): $!";
- closedir(getcwd'PARENT); #');
- return '';
- }
- if ($pst[$[] == $cst[$[] && $pst[$[ + 1] == $cst[$[ + 1])
- {
- $dir = '';
- }
- else
- {
- do
- {
- unless ($dir = readdir(getcwd'PARENT)) #'))
- {
- warn "readdir($dotdots): $!";
- closedir(getcwd'PARENT); #');
- return '';
- }
- unless (@tst = lstat("$dotdots/$dir"))
- {
- warn "lstat($dotdots/$dir): $!";
- closedir(getcwd'PARENT); #');
- return '';
- }
- }
- while ($dir eq '.' || $dir eq '..' || $tst[$[] != $pst[$[] ||
- $tst[$[ + 1] != $pst[$[ + 1]);
- }
- $cwd = "$dir/$cwd";
- closedir(getcwd'PARENT); #');
- } while ($dir);
- chop($cwd);
- $cwd;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/gethostname.pl b/gnu/usr.bin/perl/lib/gethostname.pl
deleted file mode 100644
index 0d359b3..0000000
--- a/gnu/usr.bin/perl/lib/gethostname.pl
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Simple package to get the hostname via __sysctl(2).
-#
-# Written 13-Feb-96 by Jörg Wunsch, interface business GmbH Dresden.
-# Placed in the public domain.
-#
-# $Id$
-#
-
-package gethostname;
-
-require "sys/syscall.ph";
-require "sys/sysctl.ph";
-
-#
-# usage:
-#
-# require "gethostname.pl";
-# printf "This machine is named \"%s\".\n", &gethostname;
-#
-
-sub main'gethostname {
- # get hostname via sysctl(2)
- local($name, $oldval, $oldlen, $len);
- $name = pack("LL", &CTL_KERN, &KERN_HOSTNAME);
- # 64-byte string to get the hostname
- $oldval = " " x 64;
- $oldlen = pack("L", length($oldval));
- syscall(&SYS___sysctl, $name, 2, $oldval, $oldlen, 0, 0) != -1 ||
- die "Cannot get hostname via sysctl(2), errno = $!\n";
-
- ($len) = unpack("L", $oldlen);
- return substr($oldval, 0, $len - 1);
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/getopt.pl b/gnu/usr.bin/perl/lib/getopt.pl
deleted file mode 100644
index 6772d54..0000000
--- a/gnu/usr.bin/perl/lib/getopt.pl
+++ /dev/null
@@ -1,41 +0,0 @@
-;# $RCSfile: getopt.pl,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:29:52 $
-
-;# Process single-character switches with switch clustering. Pass one argument
-;# which is a string containing all switches that take an argument. For each
-;# switch found, sets $opt_x (where x is the switch name) to the value of the
-;# argument, or 1 if no argument. Switches which take an argument don't care
-;# whether there is a space between the switch and the argument.
-
-;# Usage:
-;# do Getopt('oDI'); # -o, -D & -I take arg. Sets opt_* as a side effect.
-
-sub Getopt {
- local($argumentative) = @_;
- local($_,$first,$rest);
- local($[) = 0;
-
- while (@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
- ($first,$rest) = ($1,$2);
- if (index($argumentative,$first) >= $[) {
- if ($rest ne '') {
- shift(@ARGV);
- }
- else {
- shift(@ARGV);
- $rest = shift(@ARGV);
- }
- eval "\$opt_$first = \$rest;";
- }
- else {
- eval "\$opt_$first = 1;";
- if ($rest ne '') {
- $ARGV[0] = "-$rest";
- }
- else {
- shift(@ARGV);
- }
- }
- }
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/getopts.pl b/gnu/usr.bin/perl/lib/getopts.pl
deleted file mode 100644
index a0818d1..0000000
--- a/gnu/usr.bin/perl/lib/getopts.pl
+++ /dev/null
@@ -1,50 +0,0 @@
-;# getopts.pl - a better getopt.pl
-
-;# Usage:
-;# do Getopts('a:bc'); # -a takes arg. -b & -c not. Sets opt_* as a
-;# # side effect.
-
-sub Getopts {
- local($argumentative) = @_;
- local(@args,$_,$first,$rest);
- local($errs) = 0;
- local($[) = 0;
-
- @args = split( / */, $argumentative );
- while(@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
- ($first,$rest) = ($1,$2);
- $pos = index($argumentative,$first);
- if($pos >= $[) {
- if($args[$pos+1] eq ':') {
- shift(@ARGV);
- if($rest eq '') {
- ++$errs unless @ARGV;
- $rest = shift(@ARGV);
- }
- eval "\$opt_$first = \$rest;";
- }
- else {
- eval "\$opt_$first = 1";
- if($rest eq '') {
- shift(@ARGV);
- }
- else {
- $ARGV[0] = "-$rest";
- }
- }
- }
- else {
- print STDERR "Unknown option: $first\n";
- ++$errs;
- if($rest ne '') {
- $ARGV[0] = "-$rest";
- }
- else {
- shift(@ARGV);
- }
- }
- }
- $errs == 0;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/importenv.pl b/gnu/usr.bin/perl/lib/importenv.pl
deleted file mode 100644
index c9ad330..0000000
--- a/gnu/usr.bin/perl/lib/importenv.pl
+++ /dev/null
@@ -1,16 +0,0 @@
-;# $Header: /home/cvs/386BSD/ports/lang/perl/lib/importenv.pl,v 1.1.1.1 1993/08/23 21:29:53 nate Exp $
-
-;# This file, when interpreted, pulls the environment into normal variables.
-;# Usage:
-;# require 'importenv.pl';
-;# or
-;# #include <importenv.pl>
-
-local($tmp,$key) = '';
-
-foreach $key (keys(ENV)) {
- $tmp .= "\$$key = \$ENV{'$key'};" if $key =~ /^[A-Za-z]\w*$/;
-}
-eval $tmp;
-
-1;
diff --git a/gnu/usr.bin/perl/lib/look.pl b/gnu/usr.bin/perl/lib/look.pl
deleted file mode 100644
index 4c14e64..0000000
--- a/gnu/usr.bin/perl/lib/look.pl
+++ /dev/null
@@ -1,44 +0,0 @@
-;# Usage: &look(*FILEHANDLE,$key,$dict,$fold)
-
-;# Sets file position in FILEHANDLE to be first line greater than or equal
-;# (stringwise) to $key. Pass flags for dictionary order and case folding.
-
-sub look {
- local(*FH,$key,$dict,$fold) = @_;
- local($max,$min,$mid,$_);
- local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat(FH);
- $blksize = 8192 unless $blksize;
- $key =~ s/[^\w\s]//g if $dict;
- $key =~ y/A-Z/a-z/ if $fold;
- $max = int($size / $blksize);
- while ($max - $min > 1) {
- $mid = int(($max + $min) / 2);
- seek(FH,$mid * $blksize,0);
- $_ = <FH> if $mid; # probably a partial line
- $_ = <FH>;
- chop;
- s/[^\w\s]//g if $dict;
- y/A-Z/a-z/ if $fold;
- if ($_ lt $key) {
- $min = $mid;
- }
- else {
- $max = $mid;
- }
- }
- $min *= $blksize;
- seek(FH,$min,0);
- <FH> if $min;
- while (<FH>) {
- chop;
- s/[^\w\s]//g if $dict;
- y/A-Z/a-z/ if $fold;
- last if $_ ge $key;
- $min = tell(FH);
- }
- seek(FH,$min,0);
- $min;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/newgetopt.pl b/gnu/usr.bin/perl/lib/newgetopt.pl
deleted file mode 100644
index 0e4cbfd..0000000
--- a/gnu/usr.bin/perl/lib/newgetopt.pl
+++ /dev/null
@@ -1,271 +0,0 @@
-# newgetopt.pl -- new options parsing
-
-# SCCS Status : @(#)@ newgetopt.pl 1.13
-# Author : Johan Vromans
-# Created On : Tue Sep 11 15:00:12 1990
-# Last Modified By: Johan Vromans
-# Last Modified On: Tue Jun 2 11:24:03 1992
-# Update Count : 75
-# Status : Okay
-
-# This package implements a new getopt function. This function adheres
-# to the new syntax (long option names, no bundling).
-#
-# Arguments to the function are:
-#
-# - a list of possible options. These should designate valid perl
-# identifiers, optionally followed by an argument specifier ("="
-# for mandatory arguments or ":" for optional arguments) and an
-# argument type specifier: "n" or "i" for integer numbers, "f" for
-# real (fix) numbers or "s" for strings.
-# If an "@" sign is appended, the option is treated as an array.
-# Value(s) are not set, but pushed.
-#
-# - if the first option of the list consists of non-alphanumeric
-# characters only, it is interpreted as a generic option starter.
-# Everything starting with one of the characters from the starter
-# will be considered an option.
-# Likewise, a double occurrence (e.g. "--") signals end of
-# the options list.
-# The default value for the starter is "-", "--" or "+".
-#
-# Upon return, the option variables, prefixed with "opt_", are defined
-# and set to the respective option arguments, if any.
-# Options that do not take an argument are set to 1. Note that an
-# option with an optional argument will be defined, but set to '' if
-# no actual argument has been supplied.
-# A return status of 0 (false) indicates that the function detected
-# one or more errors.
-#
-# Special care is taken to give a correct treatment to optional arguments.
-#
-# E.g. if option "one:i" (i.e. takes an optional integer argument),
-# then the following situations are handled:
-#
-# -one -two -> $opt_one = '', -two is next option
-# -one -2 -> $opt_one = -2
-#
-# Also, assume "foo=s" and "bar:s" :
-#
-# -bar -xxx -> $opt_bar = '', '-xxx' is next option
-# -foo -bar -> $opt_foo = '-bar'
-# -foo -- -> $opt_foo = '--'
-#
-# HISTORY
-# 2-Jun-1992 Johan Vromans
-# Do not use //o to allow multiple NGetOpt calls with different delimeters.
-# Prevent typeless option from using previous $array state.
-# Prevent empty option from being eaten as a (negative) number.
-
-# 25-May-1992 Johan Vromans
-# Add array options. "foo=s@" will return an array @opt_foo that
-# contains all values that were supplied. E.g. "-foo one -foo -two" will
-# return @opt_foo = ("one", "-two");
-# Correct bug in handling options that allow for a argument when followed
-# by another option.
-
-# 4-May-1992 Johan Vromans
-# Add $ignorecase to match options in either case.
-# Allow '' option.
-
-# 19-Mar-1992 Johan Vromans
-# Allow require from packages.
-# NGetOpt is now defined in the package that requires it.
-# @ARGV and $opt_... are taken from the package that calls it.
-# Use standard (?) option prefixes: -, -- and +.
-
-# 20-Sep-1990 Johan Vromans
-# Set options w/o argument to 1.
-# Correct the dreadful semicolon/require bug.
-
-
-{ package newgetopt;
- $debug = 0; # for debugging
- $ignorecase = 1; # ignore case when matching options
-}
-
-sub NGetOpt {
-
- @newgetopt'optionlist = @_;
- *newgetopt'ARGV = *ARGV;
-
- package newgetopt;
-
- local ($[) = 0;
- local ($genprefix) = "(--|-|\\+)";
- local ($argend) = "--";
- local ($error) = 0;
- local ($opt, $optx, $arg, $type, $mand, %opctl);
- local ($pkg) = (caller)[0];
-
- print STDERR "NGetOpt 1.13 -- called from $pkg\n" if $debug;
-
- # See if the first element of the optionlist contains option
- # starter characters.
- if ( $optionlist[0] =~ /^\W+$/ ) {
- $genprefix = shift (@optionlist);
- # Turn into regexp.
- $genprefix =~ s/(\W)/\\\1/g;
- $genprefix = "[" . $genprefix . "]";
- undef $argend;
- }
-
- # Verify correctness of optionlist.
- %opctl = ();
- foreach $opt ( @optionlist ) {
- $opt =~ tr/A-Z/a-z/ if $ignorecase;
- if ( $opt !~ /^(\w*)([=:][infse]@?)?$/ ) {
- print STDERR ("Error in option spec: \"", $opt, "\"\n");
- $error++;
- next;
- }
- $opctl{$1} = defined $2 ? $2 : "";
- }
-
- return 0 if $error;
-
- if ( $debug ) {
- local ($arrow, $k, $v);
- $arrow = "=> ";
- while ( ($k,$v) = each(%opctl) ) {
- print STDERR ($arrow, "\$opctl{\"$k\"} = \"$v\"\n");
- $arrow = " ";
- }
- }
-
- # Process argument list
-
- while ( $#ARGV >= 0 ) {
-
- # >>> See also the continue block <<<
-
- # Get next argument
- $opt = shift (@ARGV);
- print STDERR ("=> option \"", $opt, "\"\n") if $debug;
- $arg = undef;
-
- # Check for exhausted list.
- if ( $opt =~ /^$genprefix/ ) {
- # Double occurrence is terminator
- return ($error == 0)
- if ($opt eq "$+$+") || ((defined $argend) && $opt eq $argend);
- $opt = $'; # option name (w/o prefix)
- }
- else {
- # Apparently not an option - push back and exit.
- unshift (@ARGV, $opt);
- return ($error == 0);
- }
-
- # Look it up.
- $opt =~ tr/A-Z/a-z/ if $ignorecase;
- unless ( defined ( $type = $opctl{$opt} ) ) {
- print STDERR ("Unknown option: ", $opt, "\n");
- $error++;
- next;
- }
-
- # Determine argument status.
- print STDERR ("=> found \"$type\" for ", $opt, "\n") if $debug;
-
- # If it is an option w/o argument, we're almost finished with it.
- if ( $type eq "" ) {
- $arg = 1; # supply explicit value
- $array = 0;
- next;
- }
-
- # Get mandatory status and type info.
- ($mand, $type, $array) = $type =~ /^(.)(.)(@?)$/;
-
- # Check if the argument list is exhausted.
- if ( $#ARGV < 0 ) {
-
- # Complain if this option needs an argument.
- if ( $mand eq "=" ) {
- print STDERR ("Option ", $opt, " requires an argument\n");
- $error++;
- }
- if ( $mand eq ":" ) {
- $arg = $type eq "s" ? "" : 0;
- }
- next;
- }
-
- # Get (possibly optional) argument.
- $arg = shift (@ARGV);
-
- # Check if it is a valid argument. A mandatory string takes
- # anything.
- if ( "$mand$type" ne "=s" && $arg =~ /^$genprefix/ ) {
-
- # Check for option list terminator.
- if ( $arg eq "$+$+" ||
- ((defined $argend) && $arg eq $argend)) {
- # Push back so the outer loop will terminate.
- unshift (@ARGV, $arg);
- # Complain if an argument is required.
- if ($mand eq "=") {
- print STDERR ("Option ", $opt, " requires an argument\n");
- $error++;
- undef $arg; # don't assign it
- }
- else {
- # Supply empty value.
- $arg = $type eq "s" ? "" : 0;
- }
- next;
- }
-
- # Maybe the optional argument is the next option?
- if ( $mand eq ":" && ($' eq "" || $' =~ /[a-zA-Z_]/) ) {
- # Yep. Push back.
- unshift (@ARGV, $arg);
- $arg = $type eq "s" ? "" : 0;
- next;
- }
- }
-
- if ( $type eq "n" || $type eq "i" ) { # numeric/integer
- if ( $arg !~ /^-?[0-9]+$/ ) {
- print STDERR ("Value \"", $arg, "\" invalid for option ",
- $opt, " (number expected)\n");
- $error++;
- undef $arg; # don't assign it
- }
- next;
- }
-
- if ( $type eq "f" ) { # fixed real number, int is also ok
- if ( $arg !~ /^-?[0-9.]+$/ ) {
- print STDERR ("Value \"", $arg, "\" invalid for option ",
- $opt, " (real number expected)\n");
- $error++;
- undef $arg; # don't assign it
- }
- next;
- }
-
- if ( $type eq "s" ) { # string
- next;
- }
-
- }
- continue {
- if ( defined $arg ) {
- if ( $array ) {
- print STDERR ('=> push (@', $pkg, '\'opt_', $opt, ", \"$arg\")\n")
- if $debug;
- eval ('push(@' . $pkg . '\'opt_' . $opt . ", \$arg);");
- }
- else {
- print STDERR ('=> $', $pkg, '\'opt_', $opt, " = \"$arg\"\n")
- if $debug;
- eval ('$' . $pkg . '\'opt_' . $opt . " = \$arg;");
- }
- }
- }
-
- return ($error == 0);
-}
-1;
diff --git a/gnu/usr.bin/perl/lib/open2.pl b/gnu/usr.bin/perl/lib/open2.pl
deleted file mode 100644
index dcd68a8..0000000
--- a/gnu/usr.bin/perl/lib/open2.pl
+++ /dev/null
@@ -1,54 +0,0 @@
-# &open2: tom christiansen, <tchrist@convex.com>
-#
-# usage: $pid = &open2('rdr', 'wtr', 'some cmd and args');
-# or $pid = &open2('rdr', 'wtr', 'some', 'cmd', 'and', 'args');
-#
-# spawn the given $cmd and connect $rdr for
-# reading and $wtr for writing. return pid
-# of child, or 0 on failure.
-#
-# WARNING: this is dangerous, as you may block forever
-# unless you are very careful.
-#
-# $wtr is left unbuffered.
-#
-# abort program if
-# rdr or wtr are null
-# pipe or fork or exec fails
-
-package open2;
-$fh = 'FHOPEN000'; # package static in case called more than once
-
-sub main'open2 {
- local($kidpid);
- local($dad_rdr, $dad_wtr, @cmd) = @_;
-
- $dad_rdr ne '' || die "open2: rdr should not be null";
- $dad_wtr ne '' || die "open2: wtr should not be null";
-
- # force unqualified filehandles into callers' package
- local($package) = caller;
- $dad_rdr =~ s/^[^']+$/$package'$&/;
- $dad_wtr =~ s/^[^']+$/$package'$&/;
-
- local($kid_rdr) = ++$fh;
- local($kid_wtr) = ++$fh;
-
- pipe($dad_rdr, $kid_wtr) || die "open2: pipe 1 failed: $!";
- pipe($kid_rdr, $dad_wtr) || die "open2: pipe 2 failed: $!";
-
- if (($kidpid = fork) < 0) {
- die "open2: fork failed: $!";
- } elsif ($kidpid == 0) {
- close $dad_rdr; close $dad_wtr;
- open(STDIN, "<&$kid_rdr");
- open(STDOUT, ">&$kid_wtr");
- warn "execing @cmd\n" if $debug;
- exec @cmd;
- die "open2: exec of @cmd failed";
- }
- close $kid_rdr; close $kid_wtr;
- select((select($dad_wtr), $| = 1)[0]); # unbuffer pipe
- $kidpid;
-}
-1; # so require is happy
diff --git a/gnu/usr.bin/perl/lib/perldb.pl b/gnu/usr.bin/perl/lib/perldb.pl
deleted file mode 100644
index 1aadb93..0000000
--- a/gnu/usr.bin/perl/lib/perldb.pl
+++ /dev/null
@@ -1,598 +0,0 @@
-package DB;
-
-# modified Perl debugger, to be run from Emacs in perldb-mode
-# Ray Lischner (uunet!mntgfx!lisch) as of 5 Nov 1990
-# Johan Vromans -- upgrade to 4.0 pl 10
-
-$header = '$RCSfile: perldb.pl,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:29:51 $';
-#
-# This file is automatically included if you do perl -d.
-# It's probably not useful to include this yourself.
-#
-# Perl supplies the values for @line and %sub. It effectively inserts
-# a do DB'DB(<linenum>); in front of every place that can
-# have a breakpoint. It also inserts a do 'perldb.pl' before the first line.
-#
-# $Log: perldb.pl,v $
-# Revision 1.1.1.1 1993/08/23 21:29:51 nate
-# PERL!
-#
-# Revision 4.0.1.3 92/06/08 13:43:57 lwall
-# patch20: support for MSDOS folded into perldb.pl
-# patch20: perldb couldn't debug file containing '-', such as STDIN designator
-#
-# Revision 4.0.1.2 91/11/05 17:55:58 lwall
-# patch11: perldb.pl modified to run within emacs in perldb-mode
-#
-# Revision 4.0.1.1 91/06/07 11:17:44 lwall
-# patch4: added $^P variable to control calling of perldb routines
-# patch4: debugger sometimes listed wrong number of lines for a statement
-#
-# Revision 4.0 91/03/20 01:25:50 lwall
-# 4.0 baseline.
-#
-# Revision 3.0.1.6 91/01/11 18:08:58 lwall
-# patch42: @_ couldn't be accessed from debugger
-#
-# Revision 3.0.1.5 90/11/10 01:40:26 lwall
-# patch38: the debugger wouldn't stop correctly or do action routines
-#
-# Revision 3.0.1.4 90/10/15 17:40:38 lwall
-# patch29: added caller
-# patch29: the debugger now understands packages and evals
-# patch29: scripts now run at almost full speed under the debugger
-# patch29: more variables are settable from debugger
-#
-# Revision 3.0.1.3 90/08/09 04:00:58 lwall
-# patch19: debugger now allows continuation lines
-# patch19: debugger can now dump lists of variables
-# patch19: debugger can now add aliases easily from prompt
-#
-# Revision 3.0.1.2 90/03/12 16:39:39 lwall
-# patch13: perl -d didn't format stack traces of *foo right
-# patch13: perl -d wiped out scalar return values of subroutines
-#
-# Revision 3.0.1.1 89/10/26 23:14:02 lwall
-# patch1: RCS expanded an unintended $Header in lib/perldb.pl
-#
-# Revision 3.0 89/10/18 15:19:46 lwall
-# 3.0 baseline
-#
-# Revision 2.0 88/06/05 00:09:45 root
-# Baseline version 2.0.
-#
-#
-
-if (-e "/dev/tty") {
- $console = "/dev/tty";
- $rcfile=".perldb";
-}
-else {
- $console = "con";
- $rcfile="perldb.ini";
-}
-
-open(IN, "<$console") || open(IN, "<&STDIN"); # so we don't dingle stdin
-open(OUT,">$console") || open(OUT, ">&STDOUT"); # so we don't dongle stdout
-select(OUT);
-$| = 1; # for DB'OUT
-select(STDOUT);
-$| = 1; # for real STDOUT
-$sub = '';
-
-# Is Perl being run from Emacs?
-$emacs = $main'ARGV[$[] eq '-emacs';
-shift(@main'ARGV) if $emacs;
-
-$header =~ s/.Header: ([^,]+),v(\s+\S+\s+\S+).*$/$1$2/;
-print OUT "\nLoading DB routines from $header\n";
-print OUT ("Emacs support ",
- $emacs ? "enabled" : "available",
- ".\n");
-print OUT "\nEnter h for help.\n\n";
-
-sub DB {
- &save;
- ($package, $filename, $line) = caller;
- $usercontext = '($@, $!, $[, $,, $/, $\) = @saved;' .
- "package $package;"; # this won't let them modify, alas
- local($^P) = 0; # don't debug our own evals
- local(*dbline) = "_<$filename";
- $max = $#dbline;
- if (($stop,$action) = split(/\0/,$dbline{$line})) {
- if ($stop eq '1') {
- $signal |= 1;
- }
- else {
- $evalarg = "\$DB'signal |= do {$stop;}"; &eval;
- $dbline{$line} =~ s/;9($|\0)/$1/;
- }
- }
- if ($single || $trace || $signal) {
- if ($emacs) {
- print OUT "\032\032$filename:$line:0\n";
- } else {
- print OUT "$package'" unless $sub =~ /'/;
- print OUT "$sub($filename:$line):\t",$dbline[$line];
- for ($i = $line + 1; $i <= $max && $dbline[$i] == 0; ++$i) {
- last if $dbline[$i] =~ /^\s*(}|#|\n)/;
- print OUT "$sub($filename:$i):\t",$dbline[$i];
- }
- }
- }
- $evalarg = $action, &eval if $action;
- if ($single || $signal) {
- $evalarg = $pre, &eval if $pre;
- print OUT $#stack . " levels deep in subroutine calls!\n"
- if $single & 4;
- $start = $line;
- CMD:
- while ((print OUT " DB<", $#hist+1, "> "), $cmd=&gets) {
- {
- $single = 0;
- $signal = 0;
- $cmd eq '' && exit 0;
- chop($cmd);
- $cmd =~ s/\\$// && do {
- print OUT " cont: ";
- $cmd .= &gets;
- redo CMD;
- };
- $cmd =~ /^q$/ && exit 0;
- $cmd =~ /^$/ && ($cmd = $laststep);
- push(@hist,$cmd) if length($cmd) > 1;
- ($i) = split(/\s+/,$cmd);
- eval "\$cmd =~ $alias{$i}", print OUT $@ if $alias{$i};
- $cmd =~ /^h$/ && do {
- print OUT "
-T Stack trace.
-s Single step.
-n Next, steps over subroutine calls.
-r Return from current subroutine.
-c [line] Continue; optionally inserts a one-time-only breakpoint
- at the specified line.
-<CR> Repeat last n or s.
-l min+incr List incr+1 lines starting at min.
-l min-max List lines.
-l line List line;
-l List next window.
-- List previous window.
-w line List window around line.
-l subname List subroutine.
-f filename Switch to filename.
-/pattern/ Search forwards for pattern; final / is optional.
-?pattern? Search backwards for pattern.
-L List breakpoints and actions.
-S List subroutine names.
-t Toggle trace mode.
-b [line] [condition]
- Set breakpoint; line defaults to the current execution line;
- condition breaks if it evaluates to true, defaults to \'1\'.
-b subname [condition]
- Set breakpoint at first line of subroutine.
-d [line] Delete breakpoint.
-D Delete all breakpoints.
-a [line] command
- Set an action to be done before the line is executed.
- Sequence is: check for breakpoint, print line if necessary,
- do action, prompt user if breakpoint or step, evaluate line.
-A Delete all actions.
-V [pkg [vars]] List some (default all) variables in package (default current).
-X [vars] Same as \"V currentpackage [vars]\".
-< command Define command before prompt.
-> command Define command after prompt.
-! number Redo command (default previous command).
-! -number Redo number\'th to last command.
-H -number Display last number commands (default all).
-q or ^D Quit.
-p expr Same as \"print DB'OUT expr\" in current package.
-= [alias value] Define a command alias, or list current aliases.
-command Execute as a perl statement in current package.
-
-";
- next CMD; };
- $cmd =~ /^t$/ && do {
- $trace = !$trace;
- print OUT "Trace = ".($trace?"on":"off")."\n";
- next CMD; };
- $cmd =~ /^S$/ && do {
- foreach $subname (sort(keys %sub)) {
- print OUT $subname,"\n";
- }
- next CMD; };
- $cmd =~ s/^X\b/V $package/;
- $cmd =~ /^V$/ && do {
- $cmd = 'V $package'; };
- $cmd =~ /^V\b\s*(\S+)\s*(.*)/ && do {
- $packname = $1;
- @vars = split(' ',$2);
- do 'dumpvar.pl' unless defined &main'dumpvar;
- if (defined &main'dumpvar) {
- &main'dumpvar($packname,@vars);
- }
- else {
- print DB'OUT "dumpvar.pl not available.\n";
- }
- next CMD; };
- $cmd =~ /^f\b\s*(.*)/ && do {
- $file = $1;
- if (!$file) {
- print OUT "The old f command is now the r command.\n";
- print OUT "The new f command switches filenames.\n";
- next CMD;
- }
- if (!defined $_main{'_<' . $file}) {
- if (($try) = grep(m#^_<.*$file#, keys %_main)) {
- $file = substr($try,2);
- print "\n$file:\n";
- }
- }
- if (!defined $_main{'_<' . $file}) {
- print OUT "There's no code here anything matching $file.\n";
- next CMD;
- }
- elsif ($file ne $filename) {
- *dbline = "_<$file";
- $max = $#dbline;
- $filename = $file;
- $start = 1;
- $cmd = "l";
- } };
- $cmd =~ /^l\b\s*(['A-Za-z_]['\w]*)/ && do {
- $subname = $1;
- $subname = "main'" . $subname unless $subname =~ /'/;
- $subname = "main" . $subname if substr($subname,0,1) eq "'";
- ($file,$subrange) = split(/:/,$sub{$subname});
- if ($file ne $filename) {
- *dbline = "_<$file";
- $max = $#dbline;
- $filename = $file;
- }
- if ($subrange) {
- if (eval($subrange) < -$window) {
- $subrange =~ s/-.*/+/;
- }
- $cmd = "l $subrange";
- } else {
- print OUT "Subroutine $1 not found.\n";
- next CMD;
- } };
- $cmd =~ /^w\b\s*(\d*)$/ && do {
- $incr = $window - 1;
- $start = $1 if $1;
- $start -= $preview;
- $cmd = 'l ' . $start . '-' . ($start + $incr); };
- $cmd =~ /^-$/ && do {
- $incr = $window - 1;
- $cmd = 'l ' . ($start-$window*2) . '+'; };
- $cmd =~ /^l$/ && do {
- $incr = $window - 1;
- $cmd = 'l ' . $start . '-' . ($start + $incr); };
- $cmd =~ /^l\b\s*(\d*)\+(\d*)$/ && do {
- $start = $1 if $1;
- $incr = $2;
- $incr = $window - 1 unless $incr;
- $cmd = 'l ' . $start . '-' . ($start + $incr); };
- $cmd =~ /^l\b\s*(([\d\$\.]+)([-,]([\d\$\.]+))?)?/ && do {
- $end = (!$2) ? $max : ($4 ? $4 : $2);
- $end = $max if $end > $max;
- $i = $2;
- $i = $line if $i eq '.';
- $i = 1 if $i < 1;
- if ($emacs) {
- print OUT "\032\032$filename:$i:0\n";
- $i = $end;
- } else {
- for (; $i <= $end; $i++) {
- print OUT "$i:\t", $dbline[$i];
- last if $signal;
- }
- }
- $start = $i; # remember in case they want more
- $start = $max if $start > $max;
- next CMD; };
- $cmd =~ /^D$/ && do {
- print OUT "Deleting all breakpoints...\n";
- for ($i = 1; $i <= $max ; $i++) {
- if (defined $dbline{$i}) {
- $dbline{$i} =~ s/^[^\0]+//;
- if ($dbline{$i} =~ s/^\0?$//) {
- delete $dbline{$i};
- }
- }
- }
- next CMD; };
- $cmd =~ /^L$/ && do {
- for ($i = 1; $i <= $max; $i++) {
- if (defined $dbline{$i}) {
- print OUT "$i:\t", $dbline[$i];
- ($stop,$action) = split(/\0/, $dbline{$i});
- print OUT " break if (", $stop, ")\n"
- if $stop;
- print OUT " action: ", $action, "\n"
- if $action;
- last if $signal;
- }
- }
- next CMD; };
- $cmd =~ /^b\b\s*(['A-Za-z_]['\w]*)\s*(.*)/ && do {
- $subname = $1;
- $cond = $2 || '1';
- $subname = "$package'" . $subname unless $subname =~ /'/;
- $subname = "main" . $subname if substr($subname,0,1) eq "'";
- ($filename,$i) = split(/:/, $sub{$subname});
- $i += 0;
- if ($i) {
- *dbline = "_<$filename";
- ++$i while $dbline[$i] == 0 && $i < $#dbline;
- $dbline{$i} =~ s/^[^\0]*/$cond/;
- } else {
- print OUT "Subroutine $subname not found.\n";
- }
- next CMD; };
- $cmd =~ /^b\b\s*(\d*)\s*(.*)/ && do {
- $i = ($1?$1:$line);
- $cond = $2 || '1';
- if ($dbline[$i] == 0) {
- print OUT "Line $i not breakable.\n";
- } else {
- $dbline{$i} =~ s/^[^\0]*/$cond/;
- }
- next CMD; };
- $cmd =~ /^d\b\s*(\d+)?/ && do {
- $i = ($1?$1:$line);
- $dbline{$i} =~ s/^[^\0]*//;
- delete $dbline{$i} if $dbline{$i} eq '';
- next CMD; };
- $cmd =~ /^A$/ && do {
- for ($i = 1; $i <= $max ; $i++) {
- if (defined $dbline{$i}) {
- $dbline{$i} =~ s/\0[^\0]*//;
- delete $dbline{$i} if $dbline{$i} eq '';
- }
- }
- next CMD; };
- $cmd =~ /^<\s*(.*)/ && do {
- $pre = do action($1);
- next CMD; };
- $cmd =~ /^>\s*(.*)/ && do {
- $post = do action($1);
- next CMD; };
- $cmd =~ /^a\b\s*(\d+)(\s+(.*))?/ && do {
- $i = $1;
- if ($dbline[$i] == 0) {
- print OUT "Line $i may not have an action.\n";
- } else {
- $dbline{$i} =~ s/\0[^\0]*//;
- $dbline{$i} .= "\0" . do action($3);
- }
- next CMD; };
- $cmd =~ /^n$/ && do {
- $single = 2;
- $laststep = $cmd;
- last CMD; };
- $cmd =~ /^s$/ && do {
- $single = 1;
- $laststep = $cmd;
- last CMD; };
- $cmd =~ /^c\b\s*(\d*)\s*$/ && do {
- $i = $1;
- if ($i) {
- if ($dbline[$i] == 0) {
- print OUT "Line $i not breakable.\n";
- next CMD;
- }
- $dbline{$i} =~ s/(\0|$)/;9$1/; # add one-time-only b.p.
- }
- for ($i=0; $i <= $#stack; ) {
- $stack[$i++] &= ~1;
- }
- last CMD; };
- $cmd =~ /^r$/ && do {
- $stack[$#stack] |= 2;
- last CMD; };
- $cmd =~ /^T$/ && do {
- local($p,$f,$l,$s,$h,$a,@a,@sub);
- for ($i = 1; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
- @a = @args;
- for (@a) {
- if (/^StB\000/ && length($_) == length($_main{'_main'})) {
- $_ = sprintf("%s",$_);
- }
- else {
- s/'/\\'/g;
- s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
- s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
- s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
- }
- }
- $w = $w ? '@ = ' : '$ = ';
- $a = $h ? '(' . join(', ', @a) . ')' : '';
- push(@sub, "$w&$s$a from file $f line $l\n");
- last if $signal;
- }
- for ($i=0; $i <= $#sub; $i++) {
- last if $signal;
- print OUT $sub[$i];
- }
- next CMD; };
- $cmd =~ /^\/(.*)$/ && do {
- $inpat = $1;
- $inpat =~ s:([^\\])/$:$1:;
- if ($inpat ne "") {
- eval '$inpat =~ m'."\n$inpat\n";
- if ($@ ne "") {
- print OUT "$@";
- next CMD;
- }
- $pat = $inpat;
- }
- $end = $start;
- eval '
- for (;;) {
- ++$start;
- $start = 1 if ($start > $max);
- last if ($start == $end);
- if ($dbline[$start] =~ m'."\n$pat\n".'i) {
- if ($emacs) {
- print OUT "\032\032$filename:$start:0\n";
- } else {
- print OUT "$start:\t", $dbline[$start], "\n";
- }
- last;
- }
- } ';
- print OUT "/$pat/: not found\n" if ($start == $end);
- next CMD; };
- $cmd =~ /^\?(.*)$/ && do {
- $inpat = $1;
- $inpat =~ s:([^\\])\?$:$1:;
- if ($inpat ne "") {
- eval '$inpat =~ m'."\n$inpat\n";
- if ($@ ne "") {
- print OUT "$@";
- next CMD;
- }
- $pat = $inpat;
- }
- $end = $start;
- eval '
- for (;;) {
- --$start;
- $start = $max if ($start <= 0);
- last if ($start == $end);
- if ($dbline[$start] =~ m'."\n$pat\n".'i) {
- if ($emacs) {
- print OUT "\032\032$filename:$start:0\n";
- } else {
- print OUT "$start:\t", $dbline[$start], "\n";
- }
- last;
- }
- } ';
- print OUT "?$pat?: not found\n" if ($start == $end);
- next CMD; };
- $cmd =~ /^!+\s*(-)?(\d+)?$/ && do {
- pop(@hist) if length($cmd) > 1;
- $i = ($1?($#hist-($2?$2:1)):($2?$2:$#hist));
- $cmd = $hist[$i] . "\n";
- print OUT $cmd;
- redo CMD; };
- $cmd =~ /^!(.+)$/ && do {
- $pat = "^$1";
- pop(@hist) if length($cmd) > 1;
- for ($i = $#hist; $i; --$i) {
- last if $hist[$i] =~ $pat;
- }
- if (!$i) {
- print OUT "No such command!\n\n";
- next CMD;
- }
- $cmd = $hist[$i] . "\n";
- print OUT $cmd;
- redo CMD; };
- $cmd =~ /^H\b\s*(-(\d+))?/ && do {
- $end = $2?($#hist-$2):0;
- $hist = 0 if $hist < 0;
- for ($i=$#hist; $i>$end; $i--) {
- print OUT "$i: ",$hist[$i],"\n"
- unless $hist[$i] =~ /^.?$/;
- };
- next CMD; };
- $cmd =~ s/^p( .*)?$/print DB'OUT$1/;
- $cmd =~ /^=/ && do {
- if (local($k,$v) = ($cmd =~ /^=\s*(\S+)\s+(.*)/)) {
- $alias{$k}="s~$k~$v~";
- print OUT "$k = $v\n";
- } elsif ($cmd =~ /^=\s*$/) {
- foreach $k (sort keys(%alias)) {
- if (($v = $alias{$k}) =~ s~^s\~$k\~(.*)\~$~$1~) {
- print OUT "$k = $v\n";
- } else {
- print OUT "$k\t$alias{$k}\n";
- };
- };
- };
- next CMD; };
- }
- $evalarg = $cmd; &eval;
- print OUT "\n";
- }
- if ($post) {
- $evalarg = $post; &eval;
- }
- }
- ($@, $!, $[, $,, $/, $\) = @saved;
-}
-
-sub save {
- @saved = ($@, $!, $[, $,, $/, $\);
- $[ = 0; $, = ""; $/ = "\n"; $\ = "";
-}
-
-# The following takes its argument via $evalarg to preserve current @_
-
-sub eval {
- eval "$usercontext $evalarg; &DB'save";
- print OUT $@;
-}
-
-sub action {
- local($action) = @_;
- while ($action =~ s/\\$//) {
- print OUT "+ ";
- $action .= &gets;
- }
- $action;
-}
-
-sub gets {
- local($.);
- <IN>;
-}
-
-sub catch {
- $signal = 1;
-}
-
-sub sub {
- push(@stack, $single);
- $single &= 1;
- $single |= 4 if $#stack == $deep;
- if (wantarray) {
- @i = &$sub;
- $single |= pop(@stack);
- @i;
- }
- else {
- $i = &$sub;
- $single |= pop(@stack);
- $i;
- }
-}
-
-$single = 1; # so it stops on first executable statement
-@hist = ('?');
-$SIG{'INT'} = "DB'catch";
-$deep = 100; # warning if stack gets this deep
-$window = 10;
-$preview = 3;
-
-@stack = (0);
-@ARGS = @ARGV;
-for (@args) {
- s/'/\\'/g;
- s/(.*)/'$1'/ unless /^-?[\d.]+$/;
-}
-
-if (-f $rcfile) {
- do "./$rcfile";
-}
-elsif (-f "$ENV{'LOGDIR'}/$rcfile") {
- do "$ENV{'LOGDIR'}/$rcfile";
-}
-elsif (-f "$ENV{'HOME'}/$rcfile") {
- do "$ENV{'HOME'}/$rcfile";
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/pwd.pl b/gnu/usr.bin/perl/lib/pwd.pl
deleted file mode 100644
index 16baadc..0000000
--- a/gnu/usr.bin/perl/lib/pwd.pl
+++ /dev/null
@@ -1,72 +0,0 @@
-;# pwd.pl - keeps track of current working directory in PWD environment var
-;#
-;# $RCSfile: pwd.pl,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:29:52 $
-;#
-;# $Log: pwd.pl,v $
-# Revision 1.1.1.1 1993/08/23 21:29:52 nate
-# PERL!
-#
-;# Revision 4.0.1.1 92/06/08 13:45:22 lwall
-;# patch20: support added to pwd.pl to strip automounter crud
-;#
-;# Revision 4.0 91/03/20 01:26:03 lwall
-;# 4.0 baseline.
-;#
-;# Revision 3.0.1.2 91/01/11 18:09:24 lwall
-;# patch42: some .pl files were missing their trailing 1;
-;#
-;# Revision 3.0.1.1 90/08/09 04:01:24 lwall
-;# patch19: Initial revision
-;#
-;#
-;# Usage:
-;# require "pwd.pl";
-;# &initpwd;
-;# ...
-;# &chdir($newdir);
-
-package pwd;
-
-sub main'initpwd {
- if ($ENV{'PWD'}) {
- local($dd,$di) = stat('.');
- local($pd,$pi) = stat($ENV{'PWD'});
- if ($di != $pi || $dd != $pd) {
- chop($ENV{'PWD'} = `pwd`);
- }
- }
- else {
- chop($ENV{'PWD'} = `pwd`);
- }
- if ($ENV{'PWD'} =~ m|(/[^/]+(/[^/]+/[^/]+))(.*)|) {
- local($pd,$pi) = stat($2);
- local($dd,$di) = stat($1);
- if ($di == $pi && $dd == $pd) {
- $ENV{'PWD'}="$2$3";
- }
- }
-}
-
-sub main'chdir {
- local($newdir) = shift;
- if (chdir $newdir) {
- if ($newdir =~ m#^/#) {
- $ENV{'PWD'} = $newdir;
- }
- else {
- local(@curdir) = split(m#/#,$ENV{'PWD'});
- @curdir = '' unless @curdir;
- foreach $component (split(m#/#, $newdir)) {
- next if $component eq '.';
- pop(@curdir),next if $component eq '..';
- push(@curdir,$component);
- }
- $ENV{'PWD'} = join('/',@curdir) || '/';
- }
- }
- else {
- 0;
- }
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/shellwords.pl b/gnu/usr.bin/perl/lib/shellwords.pl
deleted file mode 100644
index 5d593da..0000000
--- a/gnu/usr.bin/perl/lib/shellwords.pl
+++ /dev/null
@@ -1,48 +0,0 @@
-;# shellwords.pl
-;#
-;# Usage:
-;# require 'shellwords.pl';
-;# @words = &shellwords($line);
-;# or
-;# @words = &shellwords(@lines);
-;# or
-;# @words = &shellwords; # defaults to $_ (and clobbers it)
-
-sub shellwords {
- package shellwords;
- local($_) = join('', @_) if @_;
- local(@words,$snippet,$field);
-
- s/^\s+//;
- while ($_ ne '') {
- $field = '';
- for (;;) {
- if (s/^"(([^"\\]|\\[\\"])*)"//) {
- ($snippet = $1) =~ s#\\(.)#$1#g;
- }
- elsif (/^"/) {
- die "Unmatched double quote: $_\n";
- }
- elsif (s/^'(([^'\\]|\\[\\'])*)'//) {
- ($snippet = $1) =~ s#\\(.)#$1#g;
- }
- elsif (/^'/) {
- die "Unmatched single quote: $_\n";
- }
- elsif (s/^\\(.)//) {
- $snippet = $1;
- }
- elsif (s/^([^\s\\'"]+)//) {
- $snippet = $1;
- }
- else {
- s/^\s+//;
- last;
- }
- $field .= $snippet;
- }
- push(@words, $field);
- }
- @words;
-}
-1;
diff --git a/gnu/usr.bin/perl/lib/stat.pl b/gnu/usr.bin/perl/lib/stat.pl
deleted file mode 100644
index 6186f54..0000000
--- a/gnu/usr.bin/perl/lib/stat.pl
+++ /dev/null
@@ -1,31 +0,0 @@
-;# $Header: /home/cvs/386BSD/ports/lang/perl/lib/stat.pl,v 1.1.1.1 1993/08/23 21:29:53 nate Exp $
-
-;# Usage:
-;# require 'stat.pl';
-;# @ary = stat(foo);
-;# $st_dev = @ary[$ST_DEV];
-;#
-$ST_DEV = 0 + $[;
-$ST_INO = 1 + $[;
-$ST_MODE = 2 + $[;
-$ST_NLINK = 3 + $[;
-$ST_UID = 4 + $[;
-$ST_GID = 5 + $[;
-$ST_RDEV = 6 + $[;
-$ST_SIZE = 7 + $[;
-$ST_ATIME = 8 + $[;
-$ST_MTIME = 9 + $[;
-$ST_CTIME = 10 + $[;
-$ST_BLKSIZE = 11 + $[;
-$ST_BLOCKS = 12 + $[;
-
-;# Usage:
-;# require 'stat.pl';
-;# do Stat('foo'); # sets st_* as a side effect
-;#
-sub Stat {
- ($st_dev,$st_ino,$st_mode,$st_nlink,$st_uid,$st_gid,$st_rdev,$st_size,
- $st_atime,$st_mtime,$st_ctime,$st_blksize,$st_blocks) = stat(shift(@_));
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/syslog.pl b/gnu/usr.bin/perl/lib/syslog.pl
deleted file mode 100644
index 94a4f6a..0000000
--- a/gnu/usr.bin/perl/lib/syslog.pl
+++ /dev/null
@@ -1,224 +0,0 @@
-#
-# syslog.pl
-#
-# $Log: syslog.pl,v $
-# Revision 1.1.1.1 1993/08/23 21:29:51 nate
-# PERL!
-#
-# Revision 4.0.1.1 92/06/08 13:48:05 lwall
-# patch20: new warning for ambiguous use of unary operators
-#
-# Revision 4.0 91/03/20 01:26:24 lwall
-# 4.0 baseline.
-#
-# Revision 3.0.1.4 90/11/10 01:41:11 lwall
-# patch38: syslog.pl was referencing an absolute path
-#
-# Revision 3.0.1.3 90/10/15 17:42:18 lwall
-# patch29: various portability fixes
-#
-# Revision 3.0.1.1 90/08/09 03:57:17 lwall
-# patch19: Initial revision
-#
-# Revision 1.2 90/06/11 18:45:30 18:45:30 root ()
-# - Changed 'warn' to 'mail|warning' in test call (to give example of
-# facility specification, and because 'warn' didn't work on HP-UX).
-# - Fixed typo in &openlog ("ncons" should be "cons").
-# - Added (package-global) $maskpri, and &setlogmask.
-# - In &syslog:
-# - put argument test ahead of &connect (why waste cycles?),
-# - allowed facility to be specified in &syslog's first arg (temporarily
-# overrides any $facility set in &openlog), just as in syslog(3C),
-# - do a return 0 when bit for $numpri not set in log mask (see syslog(3C)),
-# - changed $whoami code to use getlogin, getpwuid($<) and 'syslog'
-# (in that order) when $ident is null,
-# - made PID logging consistent with syslog(3C) and subject to $lo_pid only,
-# - fixed typo in "print CONS" statement ($<facility should be <$facility).
-# - changed \n to \r in print CONS (\r is useful, $message already has a \n).
-# - Changed &xlate to return -1 for an unknown name, instead of croaking.
-#
-#
-# tom christiansen <tchrist@convex.com>
-# modified to use sockets by Larry Wall <lwall@jpl-devvax.jpl.nasa.gov>
-# NOTE: openlog now takes three arguments, just like openlog(3)
-#
-# call syslog() with a string priority and a list of printf() args
-# like syslog(3)
-#
-# usage: require 'syslog.pl';
-#
-# then (put these all in a script to test function)
-#
-#
-# do openlog($program,'cons,pid','user');
-# do syslog('info','this is another test');
-# do syslog('mail|warning','this is a better test: %d', time);
-# do closelog();
-#
-# do syslog('debug','this is the last test');
-# do openlog("$program $$",'ndelay','user');
-# do syslog('notice','fooprogram: this is really done');
-#
-# $! = 55;
-# do syslog('info','problem was %m'); # %m == $! in syslog(3)
-
-package syslog;
-
-$host = 'localhost' unless $host; # set $syslog'host to change
-
-require 'syslog.ph';
-
-$maskpri = &LOG_UPTO(&LOG_DEBUG);
-
-sub main'openlog {
- ($ident, $logopt, $facility) = @_; # package vars
- $lo_pid = $logopt =~ /\bpid\b/;
- $lo_ndelay = $logopt =~ /\bndelay\b/;
- $lo_cons = $logopt =~ /\bcons\b/;
- $lo_nowait = $logopt =~ /\bnowait\b/;
- &connect if $lo_ndelay;
-}
-
-sub main'closelog {
- $facility = $ident = '';
- &disconnect;
-}
-
-sub main'setlogmask {
- local($oldmask) = $maskpri;
- $maskpri = shift;
- $oldmask;
-}
-
-sub main'syslog {
- local($priority) = shift;
- local($mask) = shift;
- local($message, $whoami);
- local(@words, $num, $numpri, $numfac, $sum);
- local($facility) = $facility; # may need to change temporarily.
-
- die "syslog: expected both priority and mask" unless $mask && $priority;
-
- @words = split(/\W+/, $priority, 2);# Allow "level" or "level|facility".
- undef $numpri;
- undef $numfac;
- foreach (@words) {
- $num = &xlate($_); # Translate word to number.
- if (/^kern$/ || $num < 0) {
- die "syslog: invalid level/facility: $_\n";
- }
- elsif ($num <= &LOG_PRIMASK) {
- die "syslog: too many levels given: $_\n" if defined($numpri);
- $numpri = $num;
- return 0 unless &LOG_MASK($numpri) & $maskpri;
- }
- else {
- die "syslog: too many facilities given: $_\n" if defined($numfac);
- $facility = $_;
- $numfac = $num;
- }
- }
-
- die "syslog: level must be given\n" unless defined($numpri);
-
- if (!defined($numfac)) { # Facility not specified in this call.
- $facility = 'user' unless $facility;
- $numfac = &xlate($facility);
- }
-
- &connect unless $connected;
-
- $whoami = $ident;
-
- if (!$ident && $mask =~ /^(\S.*):\s?(.*)/) {
- $whoami = $1;
- $mask = $2;
- }
-
- unless ($whoami) {
- ($whoami = getlogin) ||
- ($whoami = getpwuid($<)) ||
- ($whoami = 'syslog');
- }
-
- $whoami .= "[$$]" if $lo_pid;
-
- $mask =~ s/%m/$!/g;
- $mask .= "\n" unless $mask =~ /\n$/;
- $message = sprintf ($mask, @_);
-
- $sum = $numpri + $numfac;
- unless (send(SYSLOG,"<$sum>$whoami: $message",0)) {
- if ($lo_cons) {
- if ($pid = fork) {
- unless ($lo_nowait) {
- do {$died = wait;} until $died == $pid || $died < 0;
- }
- }
- else {
- open(CONS,">/dev/console");
- print CONS "<$facility.$priority>$whoami: $message\r";
- exit if defined $pid; # if fork failed, we're parent
- close CONS;
- }
- }
- }
-}
-
-sub xlate {
- local($name) = @_;
- $name =~ y/a-z/A-Z/;
- $name = "LOG_$name" unless $name =~ /^LOG_/;
- $name = "syslog'$name";
- eval(&$name) || -1;
-}
-
-sub connect {
- $pat = 'S n C4 x8';
-
- $af_unix = 1;
- $af_inet = 2;
-
- $stream = 1;
- $datagram = 2;
-
- ($name,$aliases,$proto) = getprotobyname('udp');
- $udp = $proto;
-
- ($name,$aliase,$port,$proto) = getservbyname('syslog','udp');
- $syslog = $port;
-
- if (chop($myname = `hostname`)) {
- ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname($myname);
- die "Can't lookup $myname\n" unless $name;
- @bytes = unpack("C4",$addrs[0]);
- }
- else {
- @bytes = (0,0,0,0);
- }
- $this = pack($pat, $af_inet, 0, @bytes);
-
- if ($host =~ /^\d+\./) {
- @bytes = split(/\./,$host);
- }
- else {
- ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname($host);
- die "Can't lookup $host\n" unless $name;
- @bytes = unpack("C4",$addrs[0]);
- }
- $that = pack($pat,$af_inet,$syslog,@bytes);
-
- socket(SYSLOG,$af_inet,$datagram,$udp) || die "socket: $!\n";
- bind(SYSLOG,$this) || die "bind: $!\n";
- connect(SYSLOG,$that) || die "connect: $!\n";
-
- local($old) = select(SYSLOG); $| = 1; select($old);
- $connected = 1;
-}
-
-sub disconnect {
- close SYSLOG;
- $connected = 0;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/termcap.pl b/gnu/usr.bin/perl/lib/termcap.pl
deleted file mode 100644
index 81556db..0000000
--- a/gnu/usr.bin/perl/lib/termcap.pl
+++ /dev/null
@@ -1,165 +0,0 @@
-;# $RCSfile: termcap.pl,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:29:52 $
-;#
-;# Usage:
-;# require 'ioctl.pl';
-;# ioctl(TTY,$TIOCGETP,$foo);
-;# ($ispeed,$ospeed) = unpack('cc',$foo);
-;# require 'termcap.pl';
-;# &Tgetent('vt100'); # sets $TC{'cm'}, etc.
-;# &Tputs(&Tgoto($TC{'cm'},$col,$row), 0, 'FILEHANDLE');
-;# &Tputs($TC{'dl'},$affcnt,'FILEHANDLE');
-;#
-sub Tgetent {
- local($TERM) = @_;
- local($TERMCAP,$_,$entry,$loop,$field);
-
- warn "Tgetent: no ospeed set" unless $ospeed;
- foreach $key (keys(TC)) {
- delete $TC{$key};
- }
- $TERM = $ENV{'TERM'} unless $TERM;
- $TERMCAP = $ENV{'TERMCAP'};
- $TERMCAP = '/etc/termcap' unless $TERMCAP;
- if ($TERMCAP !~ m:^/:) {
- if ($TERMCAP !~ /(^|\|)$TERM[:\|]/) {
- $TERMCAP = '/etc/termcap';
- }
- }
- if ($TERMCAP =~ m:^/:) {
- $entry = '';
- do {
- $loop = "
- open(TERMCAP,'<$TERMCAP') || die \"Can't open $TERMCAP\";
- while (<TERMCAP>) {
- next if /^#/;
- next if /^\t/;
- if (/(^|\\|)$TERM[:\\|]/) {
- chop;
- while (chop eq '\\\\') {
- \$_ .= <TERMCAP>;
- chop;
- }
- \$_ .= ':';
- last;
- }
- }
- close TERMCAP;
- \$entry .= \$_;
- ";
- eval $loop;
- } while s/:tc=([^:]+):/:/ && ($TERM = $1);
- $TERMCAP = $entry;
- }
-
- foreach $field (split(/:[\s:\\]*/,$TERMCAP)) {
- if ($field =~ /^\w\w$/) {
- $TC{$field} = 1;
- }
- elsif ($field =~ /^(\w\w)#(.*)/) {
- $TC{$1} = $2 if $TC{$1} eq '';
- }
- elsif ($field =~ /^(\w\w)=(.*)/) {
- $entry = $1;
- $_ = $2;
- s/\\E/\033/g;
- s/\\(\d\d\d)/pack('c',$1 & 0177)/eg;
- s/\\n/\n/g;
- s/\\r/\r/g;
- s/\\t/\t/g;
- s/\\b/\b/g;
- s/\\f/\f/g;
- s/\\\^/\377/g;
- s/\^\?/\177/g;
- s/\^(.)/pack('c',ord($1) & 31)/eg;
- s/\\(.)/$1/g;
- s/\377/^/g;
- $TC{$entry} = $_ if $TC{$entry} eq '';
- }
- }
- $TC{'pc'} = "\0" if $TC{'pc'} eq '';
- $TC{'bc'} = "\b" if $TC{'bc'} eq '';
-}
-
-@Tputs = (0,200,133.3,90.9,74.3,66.7,50,33.3,16.7,8.3,5.5,4.1,2,1,.5,.2);
-
-sub Tputs {
- local($string,$affcnt,$FH) = @_;
- local($ms);
- if ($string =~ /(^[\d.]+)(\*?)(.*)$/) {
- $ms = $1;
- $ms *= $affcnt if $2;
- $string = $3;
- $decr = $Tputs[$ospeed];
- if ($decr > .1) {
- $ms += $decr / 2;
- $string .= $TC{'pc'} x ($ms / $decr);
- }
- }
- print $FH $string if $FH;
- $string;
-}
-
-sub Tgoto {
- local($string) = shift(@_);
- local($result) = '';
- local($after) = '';
- local($code,$tmp) = @_;
- local(@tmp);
- @tmp = ($tmp,$code);
- local($online) = 0;
- while ($string =~ /^([^%]*)%(.)(.*)/) {
- $result .= $1;
- $code = $2;
- $string = $3;
- if ($code eq 'd') {
- $result .= sprintf("%d",shift(@tmp));
- }
- elsif ($code eq '.') {
- $tmp = shift(@tmp);
- if ($tmp == 0 || $tmp == 4 || $tmp == 10) {
- if ($online) {
- ++$tmp, $after .= $TC{'up'} if $TC{'up'};
- }
- else {
- ++$tmp, $after .= $TC{'bc'};
- }
- }
- $result .= sprintf("%c",$tmp);
- $online = !$online;
- }
- elsif ($code eq '+') {
- $result .= sprintf("%c",shift(@tmp)+ord($string));
- $string = substr($string,1,99);
- $online = !$online;
- }
- elsif ($code eq 'r') {
- ($code,$tmp) = @tmp;
- @tmp = ($tmp,$code);
- $online = !$online;
- }
- elsif ($code eq '>') {
- ($code,$tmp,$string) = unpack("CCa99",$string);
- if ($tmp[$[] > $code) {
- $tmp[$[] += $tmp;
- }
- }
- elsif ($code eq '2') {
- $result .= sprintf("%02d",shift(@tmp));
- $online = !$online;
- }
- elsif ($code eq '3') {
- $result .= sprintf("%03d",shift(@tmp));
- $online = !$online;
- }
- elsif ($code eq 'i') {
- ($code,$tmp) = @tmp;
- @tmp = ($code+1,$tmp+1);
- }
- else {
- return "OOPS";
- }
- }
- $result . $string . $after;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/timelocal.pl b/gnu/usr.bin/perl/lib/timelocal.pl
deleted file mode 100644
index 7028c8e..0000000
--- a/gnu/usr.bin/perl/lib/timelocal.pl
+++ /dev/null
@@ -1,83 +0,0 @@
-;# timelocal.pl
-;#
-;# Usage:
-;# $time = timelocal($sec,$min,$hours,$mday,$mon,$year);
-;# $time = timegm($sec,$min,$hours,$mday,$mon,$year);
-
-;# These routines are quite efficient and yet are always guaranteed to agree
-;# with localtime() and gmtime(). We manage this by caching the start times
-;# of any months we've seen before. If we know the start time of the month,
-;# we can always calculate any time within the month. The start times
-;# themselves are guessed by successive approximation starting at the
-;# current time, since most dates seen in practice are close to the
-;# current date. Unlike algorithms that do a binary search (calling gmtime
-;# once for each bit of the time value, resulting in 32 calls), this algorithm
-;# calls it at most 6 times, and usually only once or twice. If you hit
-;# the month cache, of course, it doesn't call it at all.
-
-;# timelocal is implemented using the same cache. We just assume that we're
-;# translating a GMT time, and then fudge it when we're done for the timezone
-;# and daylight savings arguments. The timezone is determined by examining
-;# the result of localtime(0) when the package is initialized. The daylight
-;# savings offset is currently assumed to be one hour.
-
-CONFIG: {
- package timelocal;
-
- local($[) = 0;
- @epoch = localtime(0);
- $tzmin = $epoch[2] * 60 + $epoch[1]; # minutes east of GMT
- if ($tzmin > 0) {
- $tzmin = 24 * 60 - $tzmin; # minutes west of GMT
- $tzmin -= 24 * 60 if $epoch[5] == 70; # account for the date line
- }
-
- $SEC = 1;
- $MIN = 60 * $SEC;
- $HR = 60 * $MIN;
- $DAYS = 24 * $HR;
- $YearFix = ((gmtime(946684800))[5] == 100) ? 100 : 0;
- 1;
-}
-
-sub timegm {
- package timelocal;
-
- local($[) = 0;
- $ym = pack(C2, @_[5,4]);
- $cheat = $cheat{$ym} || &cheat;
- $cheat + $_[0] * $SEC + $_[1] * $MIN + $_[2] * $HR + ($_[3]-1) * $DAYS;
-}
-
-sub timelocal {
- package timelocal;
-
- local($[) = 0;
- $time = &main'timegm + $tzmin*$MIN;
- @test = localtime($time);
- $time -= $HR if $test[2] != $_[2];
- $time;
-}
-
-package timelocal;
-
-sub cheat {
- $year = $_[5];
- $month = $_[4];
- die "Month out of range 0..11 in ctime.pl\n" if $month > 11;
- $guess = $^T;
- @g = gmtime($guess);
- $year += $YearFix if $year < $epoch[5];
- while ($diff = $year - $g[5]) {
- $guess += $diff * (363 * $DAYS);
- @g = gmtime($guess);
- }
- while ($diff = $month - $g[4]) {
- $guess += $diff * (27 * $DAYS);
- @g = gmtime($guess);
- }
- $g[3]--;
- $guess -= $g[0] * $SEC + $g[1] * $MIN + $g[2] * $HR + $g[3] * $DAYS;
- $cheat{$ym} = $guess;
-}
-1;
diff --git a/gnu/usr.bin/perl/lib/validate.pl b/gnu/usr.bin/perl/lib/validate.pl
deleted file mode 100644
index 4b901b6..0000000
--- a/gnu/usr.bin/perl/lib/validate.pl
+++ /dev/null
@@ -1,104 +0,0 @@
-;# $Header: /home/cvs/386BSD/ports/lang/perl/lib/validate.pl,v 1.1.1.1 1993/08/23 21:29:51 nate Exp $
-
-;# The validate routine takes a single multiline string consisting of
-;# lines containing a filename plus a file test to try on it. (The
-;# file test may also be a 'cd', causing subsequent relative filenames
-;# to be interpreted relative to that directory.) After the file test
-;# you may put '|| die' to make it a fatal error if the file test fails.
-;# The default is '|| warn'. The file test may optionally have a ! prepended
-;# to test for the opposite condition. If you do a cd and then list some
-;# relative filenames, you may want to indent them slightly for readability.
-;# If you supply your own "die" or "warn" message, you can use $file to
-;# interpolate the filename.
-
-;# Filetests may be bunched: -rwx tests for all of -r, -w and -x.
-;# Only the first failed test of the bunch will produce a warning.
-
-;# The routine returns the number of warnings issued.
-
-;# Usage:
-;# require "validate.pl";
-;# $warnings += do validate('
-;# /vmunix -e || die
-;# /boot -e || die
-;# /bin cd
-;# csh -ex
-;# csh !-ug
-;# sh -ex
-;# sh !-ug
-;# /usr -d || warn "What happened to $file?\n"
-;# ');
-
-sub validate {
- local($file,$test,$warnings,$oldwarnings);
- foreach $check (split(/\n/,$_[0])) {
- next if $check =~ /^#/;
- next if $check =~ /^$/;
- ($file,$test) = split(' ',$check,2);
- if ($test =~ s/^(!?-)(\w{2,}\b)/$1Z/) {
- $testlist = $2;
- @testlist = split(//,$testlist);
- }
- else {
- @testlist = ('Z');
- }
- $oldwarnings = $warnings;
- foreach $one (@testlist) {
- $this = $test;
- $this =~ s/(-\w\b)/$1 \$file/g;
- $this =~ s/-Z/-$one/;
- $this .= ' || warn' unless $this =~ /\|\|/;
- $this =~ s/^(.*\S)\s*\|\|\s*(die|warn)$/$1 || do valmess('$2','$1')/;
- $this =~ s/\bcd\b/chdir (\$cwd = \$file)/g;
- eval $this;
- last if $warnings > $oldwarnings;
- }
- }
- $warnings;
-}
-
-sub valmess {
- local($disposition,$this) = @_;
- $file = $cwd . '/' . $file unless $file =~ m|^/|;
- if ($this =~ /^(!?)-(\w)\s+\$file\s*$/) {
- $neg = $1;
- $tmp = $2;
- $tmp eq 'r' && ($mess = "$file is not readable by uid $>.");
- $tmp eq 'w' && ($mess = "$file is not writable by uid $>.");
- $tmp eq 'x' && ($mess = "$file is not executable by uid $>.");
- $tmp eq 'o' && ($mess = "$file is not owned by uid $>.");
- $tmp eq 'R' && ($mess = "$file is not readable by you.");
- $tmp eq 'W' && ($mess = "$file is not writable by you.");
- $tmp eq 'X' && ($mess = "$file is not executable by you.");
- $tmp eq 'O' && ($mess = "$file is not owned by you.");
- $tmp eq 'e' && ($mess = "$file does not exist.");
- $tmp eq 'z' && ($mess = "$file does not have zero size.");
- $tmp eq 's' && ($mess = "$file does not have non-zero size.");
- $tmp eq 'f' && ($mess = "$file is not a plain file.");
- $tmp eq 'd' && ($mess = "$file is not a directory.");
- $tmp eq 'l' && ($mess = "$file is not a symbolic link.");
- $tmp eq 'p' && ($mess = "$file is not a named pipe (FIFO).");
- $tmp eq 'S' && ($mess = "$file is not a socket.");
- $tmp eq 'b' && ($mess = "$file is not a block special file.");
- $tmp eq 'c' && ($mess = "$file is not a character special file.");
- $tmp eq 'u' && ($mess = "$file does not have the setuid bit set.");
- $tmp eq 'g' && ($mess = "$file does not have the setgid bit set.");
- $tmp eq 'k' && ($mess = "$file does not have the sticky bit set.");
- $tmp eq 'T' && ($mess = "$file is not a text file.");
- $tmp eq 'B' && ($mess = "$file is not a binary file.");
- if ($neg eq '!') {
- $mess =~ s/ is not / should not be / ||
- $mess =~ s/ does not / should not / ||
- $mess =~ s/ not / /;
- }
- print stderr $mess,"\n";
- }
- else {
- $this =~ s/\$file/'$file'/g;
- print stderr "Can't do $this.\n";
- }
- if ($disposition eq 'die') { exit 1; }
- ++$warnings;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/misc/c2ph b/gnu/usr.bin/perl/misc/c2ph
deleted file mode 100644
index 1a2e4b8..0000000
--- a/gnu/usr.bin/perl/misc/c2ph
+++ /dev/null
@@ -1,1071 +0,0 @@
-#!/usr/bin/perl
-#
-#
-# c2ph (aka pstruct)
-# Tom Christiansen, <tchrist@convex.com>
-#
-# As pstruct, dump C structures as generated from 'cc -g -S' stabs.
-# As c2ph, do this PLUS generate perl code for getting at the structures.
-#
-# See the usage message for more. If this isn't enough, read the code.
-#
-
-$RCSID = '$RCSfile: c2ph,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:31 $';
-
-
-######################################################################
-
-# some handy data definitions. many of these can be reset later.
-
-$bitorder = 'b'; # ascending; set to B for descending bit fields
-
-%intrinsics =
-%template = (
- 'char', 'c',
- 'unsigned char', 'C',
- 'short', 's',
- 'short int', 's',
- 'unsigned short', 'S',
- 'unsigned short int', 'S',
- 'short unsigned int', 'S',
- 'int', 'i',
- 'unsigned int', 'I',
- 'long', 'l',
- 'long int', 'l',
- 'unsigned long', 'L',
- 'unsigned long', 'L',
- 'long unsigned int', 'L',
- 'unsigned long int', 'L',
- 'long long', 'q',
- 'long long int', 'q',
- 'unsigned long long', 'Q',
- 'unsigned long long int', 'Q',
- 'float', 'f',
- 'double', 'd',
- 'pointer', 'p',
- 'null', 'x',
- 'neganull', 'X',
- 'bit', $bitorder,
-);
-
-&buildscrunchlist;
-delete $intrinsics{'neganull'};
-delete $intrinsics{'bit'};
-delete $intrinsics{'null'};
-
-# use -s to recompute sizes
-%sizeof = (
- 'char', '1',
- 'unsigned char', '1',
- 'short', '2',
- 'short int', '2',
- 'unsigned short', '2',
- 'unsigned short int', '2',
- 'short unsigned int', '2',
- 'int', '4',
- 'unsigned int', '4',
- 'long', '4',
- 'long int', '4',
- 'unsigned long', '4',
- 'unsigned long int', '4',
- 'long unsigned int', '4',
- 'long long', '8',
- 'long long int', '8',
- 'unsigned long long', '8',
- 'unsigned long long int', '8',
- 'float', '4',
- 'double', '8',
- 'pointer', '4',
-);
-
-($type_width, $member_width, $offset_width, $size_width) = (20, 20, 6, 5);
-
-($offset_fmt, $size_fmt) = ('d', 'd');
-
-$indent = 2;
-
-$CC = 'cc';
-$CFLAGS = '-g -S';
-$DEFINES = '';
-
-$perl++ if $0 =~ m#/?c2ph$#;
-
-require 'getopts.pl';
-
-eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
-
-&Getopts('aixdpvtnws:') || &usage(0);
-
-$opt_d && $debug++;
-$opt_t && $trace++;
-$opt_p && $perl++;
-$opt_v && $verbose++;
-$opt_n && ($perl = 0);
-
-if ($opt_w) {
- ($type_width, $member_width, $offset_width) = (45, 35, 8);
-}
-if ($opt_x) {
- ($offset_fmt, $offset_width, $size_fmt, $size_width) = ( 'x', '08', 'x', 04 );
-}
-
-eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
-
-sub PLUMBER {
- select(STDERR);
- print "oops, apperent pager foulup\n";
- $isatty++;
- &usage(1);
-}
-
-sub usage {
- local($oops) = @_;
- unless (-t STDOUT) {
- select(STDERR);
- } elsif (!$oops) {
- $isatty++;
- $| = 1;
- print "hit <RETURN> for further explanation: ";
- <STDIN>;
- open (PIPE, "|". ($ENV{PAGER} || 'more'));
- $SIG{PIPE} = PLUMBER;
- select(PIPE);
- }
-
- print "usage: $0 [-dpnP] [var=val] [files ...]\n";
-
- exit unless $isatty;
-
- print <<EOF;
-
-Options:
-
--w wide; short for: type_width=45 member_width=35 offset_width=8
--x hex; short for: offset_fmt=x offset_width=08 size_fmt=x size_width=04
-
--n do not generate perl code (default when invoked as pstruct)
--p generate perl code (default when invoked as c2ph)
--v generate perl code, with C decls as comments
-
--i do NOT recompute sizes for intrinsic datatypes
--a dump information on intrinsics also
-
--t trace execution
--d spew reams of debugging output
-
--slist give comma-separated list a structures to dump
-
-
-Var Name Default Value Meaning
-
-EOF
-
- &defvar('CC', 'which_compiler to call');
- &defvar('CFLAGS', 'how to generate *.s files with stabs');
- &defvar('DEFINES','any extra cflags or cpp defines, like -I, -D, -U');
-
- print "\n";
-
- &defvar('type_width', 'width of type field (column 1)');
- &defvar('member_width', 'width of member field (column 2)');
- &defvar('offset_width', 'width of offset field (column 3)');
- &defvar('size_width', 'width of size field (column 4)');
-
- print "\n";
-
- &defvar('offset_fmt', 'sprintf format type for offset');
- &defvar('size_fmt', 'sprintf format type for size');
-
- print "\n";
-
- &defvar('indent', 'how far to indent each nesting level');
-
- print <<'EOF';
-
- If any *.[ch] files are given, these will be catted together into
- a temporary *.c file and sent through:
- $CC $CFLAGS $DEFINES
- and the resulting *.s groped for stab information. If no files are
- supplied, then stdin is read directly with the assumption that it
- contains stab information. All other liens will be ignored. At
- most one *.s file should be supplied.
-
-EOF
- close PIPE;
- exit 1;
-}
-
-sub defvar {
- local($var, $msg) = @_;
- printf "%-16s%-15s %s\n", $var, eval "\$$var", $msg;
-}
-
-$recurse = 1;
-
-if (@ARGV) {
- if (grep(!/\.[csh]$/,@ARGV)) {
- warn "Only *.[csh] files expected!\n";
- &usage;
- }
- elsif (grep(/\.s$/,@ARGV)) {
- if (@ARGV > 1) {
- warn "Only one *.s file allowed!\n";
- &usage;
- }
- }
- elsif (@ARGV == 1 && $ARGV[0] =~ /\.c$/) {
- local($dir, $file) = $ARGV[0] =~ m#(.*/)?(.*)$#;
- $chdir = "cd $dir; " if $dir;
- &system("$chdir$CC $CFLAGS $DEFINES $file") && exit 1;
- $ARGV[0] =~ s/\.c$/.s/;
- }
- else {
- $TMP = "/tmp/c2ph.$$.c";
- &system("cat @ARGV > $TMP") && exit 1;
- &system("cd /tmp; $CC $CFLAGS $DEFINES $TMP") && exit 1;
- unlink $TMP;
- $TMP =~ s/\.c$/.s/;
- @ARGV = ($TMP);
- }
-}
-
-if ($opt_s) {
- for (split(/[\s,]+/, $opt_s)) {
- $interested{$_}++;
- }
-}
-
-
-$| = 1 if $debug;
-
-main: {
-
- if ($trace) {
- if (-t && !@ARGV) {
- print STDERR "reading from your keyboard: ";
- } else {
- print STDERR "reading from " . (@ARGV ? "@ARGV" : "<STDIN>").": ";
- }
- }
-
-STAB: while (<>) {
- if ($trace && !($. % 10)) {
- $lineno = $..'';
- print STDERR $lineno, "\b" x length($lineno);
- }
- next unless /^\s*\.stabs\s+/;
- $line = $_;
- s/^\s*\.stabs\s+//;
- &stab;
- }
- print STDERR "$.\n" if $trace;
- unlink $TMP if $TMP;
-
- &compute_intrinsics if $perl && !$opt_i;
-
- print STDERR "resolving types\n" if $trace;
-
- &resolve_types;
- &adjust_start_addrs;
-
- $sum = 2 + $type_width + $member_width;
- $pmask1 = "%-${type_width}s %-${member_width}s";
- $pmask2 = "%-${sum}s %${offset_width}${offset_fmt}%s %${size_width}${size_fmt}%s";
-
- if ($perl) {
- # resolve template -- should be in stab define order, but even this isn't enough.
- print STDERR "\nbuilding type templates: " if $trace;
- for $i (reverse 0..$#type) {
- next unless defined($name = $type[$i]);
- next unless defined $struct{$name};
- $build_recursed = 0;
- &build_template($name) unless defined $template{&psou($name)} ||
- $opt_s && !$interested{$name};
- }
- print STDERR "\n\n" if $trace;
- }
-
- print STDERR "dumping structs: " if $trace;
-
-
- foreach $name (sort keys %struct) {
- next if $opt_s && !$interested{$name};
- print STDERR "$name " if $trace;
-
- undef @sizeof;
- undef @typedef;
- undef @offsetof;
- undef @indices;
- undef @typeof;
-
- $mname = &munge($name);
-
- $fname = &psou($name);
-
- print "# " if $perl && $verbose;
- $pcode = '';
- print "$fname {\n" if !$perl || $verbose;
- $template{$fname} = &scrunch($template{$fname}) if $perl;
- &pstruct($name,$name,0);
- print "# " if $perl && $verbose;
- print "}\n" if !$perl || $verbose;
- print "\n" if $perl && $verbose;
-
- if ($perl) {
- print "$pcode";
-
- printf("\nsub %-32s { %4d; }\n\n", "${mname}'struct", $countof{$name});
-
- print <<EOF;
-sub ${mname}'typedef {
- local(\$${mname}'index) = shift;
- defined \$${mname}'index
- ? \$${mname}'typedef[\$${mname}'index]
- : \$${mname}'typedef;
-}
-EOF
-
- print <<EOF;
-sub ${mname}'sizeof {
- local(\$${mname}'index) = shift;
- defined \$${mname}'index
- ? \$${mname}'sizeof[\$${mname}'index]
- : \$${mname}'sizeof;
-}
-EOF
-
- print <<EOF;
-sub ${mname}'offsetof {
- local(\$${mname}'index) = shift;
- defined \$${mname}index
- ? \$${mname}'offsetof[\$${mname}'index]
- : \$${mname}'sizeof;
-}
-EOF
-
- print <<EOF;
-sub ${mname}'typeof {
- local(\$${mname}'index) = shift;
- defined \$${mname}index
- ? \$${mname}'typeof[\$${mname}'index]
- : '$name';
-}
-EOF
-
-
- print "\$${mname}'typedef = '" . &scrunch($template{$fname})
- . "';\n";
-
- print "\$${mname}'sizeof = $sizeof{$name};\n\n";
-
-
- print "\@${mname}'indices = (", &squishseq(@indices), ");\n";
-
- print "\n";
-
- print "\@${mname}'typedef[\@${mname}'indices] = (",
- join("\n\t", '', @typedef), "\n );\n\n";
- print "\@${mname}'sizeof[\@${mname}'indices] = (",
- join("\n\t", '', @sizeof), "\n );\n\n";
- print "\@${mname}'offsetof[\@${mname}'indices] = (",
- join("\n\t", '', @offsetof), "\n );\n\n";
- print "\@${mname}'typeof[\@${mname}'indices] = (",
- join("\n\t", '', @typeof), "\n );\n\n";
-
- $template_printed{$fname}++;
- $size_printed{$fname}++;
- }
- print "\n";
- }
-
- print STDERR "\n" if $trace;
-
- unless ($perl && $opt_a) {
- print "\n1;\n";
- exit;
- }
-
-
-
- foreach $name (sort bysizevalue keys %intrinsics) {
- next if $size_printed{$name};
- print '$',&munge($name),"'sizeof = ", $sizeof{$name}, ";\n";
- }
-
- print "\n";
-
- sub bysizevalue { $sizeof{$a} <=> $sizeof{$b}; }
-
-
- foreach $name (sort keys %intrinsics) {
- print '$',&munge($name),"'typedef = '", $template{$name}, "';\n";
- }
-
- print "\n1;\n";
-
- exit;
-}
-
-########################################################################################
-
-
-sub stab {
- next unless /:[\$\w]+(\(\d+,\d+\))?=[\*\$\w]+/; # (\d+,\d+) is for sun
- s/"// || next;
- s/",([x\d]+),([x\d]+),([x\d]+),.*// || next;
-
- next if /^\s*$/;
-
- $size = $3 if $3;
-
-
- $line = $_;
-
- if (($name, $pdecl) = /^([\$ \w]+):[tT]((\d+)(=[rufs*](\d+))+)$/) {
- print "$name is a typedef for some funky pointers: $pdecl\n" if $debug;
- &pdecl($pdecl);
- next;
- }
-
-
-
- if (/(([ \w]+):t(\d+|\(\d+,\d+\)))=r?(\d+|\(\d+,\d+\))(;\d+;\d+;)?/) {
- local($ident) = $2;
- push(@intrinsics, $ident);
- $typeno = &typeno($3);
- $type[$typeno] = $ident;
- print STDERR "intrinsic $ident in new type $typeno\n" if $debug;
- next;
- }
-
- if (($name, $typeordef, $typeno, $extra, $struct, $_)
- = /^([\$ \w]+):([ustT])(\d+|\(\d+,\d+\))(=[rufs*](\d+))?(.*)$/)
- {
- $typeno = &typeno($typeno); # sun foolery
- }
- elsif (/^[\$\w]+:/) {
- next; # variable
- }
- else {
- warn "can't grok stab: <$_> in: $line " if $_;
- next;
- }
-
- #warn "got size $size for $name\n";
- $sizeof{$name} = $size if $size;
-
- s/;[-\d]*;[-\d]*;$//; # we don't care about ranges
-
- $typenos{$name} = $typeno;
-
- unless (defined $type[$typeno]) {
- &panic("type 0??") unless $typeno;
- $type[$typeno] = $name unless defined $type[$typeno];
- printf "new type $typeno is $name" if $debug;
- if ($extra =~ /\*/ && defined $type[$struct]) {
- print ", a typedef for a pointer to " , $type[$struct] if $debug;
- }
- } else {
- printf "%s is type %d", $name, $typeno if $debug;
- print ", a typedef for " , $type[$typeno] if $debug;
- }
- print "\n" if $debug;
- #next unless $extra =~ /[su*]/;
-
- #$type[$struct] = $name;
-
- if ($extra =~ /[us*]/) {
- &sou($name, $extra);
- $_ = &sdecl($name, $_, 0);
- }
- elsif (/^=ar/) {
- print "it's a bare array typedef -- that's pretty sick\n" if $debug;
- $_ = "$typeno$_";
- $scripts = '';
- $_ = &adecl($_,1);
-
- }
- elsif (s/((\w+):t(\d+|\(\d+,\d+\)))?=r?(;\d+;\d+;)?//) { # the ?'s are for gcc
- push(@intrinsics, $2);
- $typeno = &typeno($3);
- $type[$typeno] = $2;
- print STDERR "intrinsic $2 in new type $typeno\n" if $debug;
- }
- elsif (s/^=e//) { # blessed by thy compiler; mine won't do this
- &edecl;
- }
- else {
- warn "Funny remainder for $name on line $_ left in $line " if $_;
- }
-}
-
-sub typeno { # sun thinks types are (0,27) instead of just 27
- local($_) = @_;
- s/\(\d+,(\d+)\)/$1/;
- $_;
-}
-
-sub pstruct {
- local($what,$prefix,$base) = @_;
- local($field, $fieldname, $typeno, $count, $offset, $entry);
- local($fieldtype);
- local($type, $tname);
- local($mytype, $mycount, $entry2);
- local($struct_count) = 0;
- local($pad, $revpad, $length, $prepad, $lastoffset, $lastlength, $fmt);
- local($bits,$bytes);
- local($template);
-
-
- local($mname) = &munge($name);
-
- sub munge {
- local($_) = @_;
- s/[\s\$\.]/_/g;
- $_;
- }
-
- local($sname) = &psou($what);
-
- $nesting++;
-
- for $field (split(/;/, $struct{$what})) {
- $pad = $prepad = 0;
- $entry = '';
- ($fieldname, $typeno, $count, $offset, $length) = split(/,/, $field);
-
- $type = $type[$typeno];
-
- $type =~ /([^[]*)(\[.*\])?/;
- $mytype = $1;
- $count .= $2;
- $fieldtype = &psou($mytype);
-
- local($fname) = &psou($name);
-
- if ($build_templates) {
-
- $pad = ($offset - ($lastoffset + $lastlength))/8
- if defined $lastoffset;
-
- if (! $finished_template{$sname}) {
- if ($isaunion{$what}) {
- $template{$sname} .= 'X' x $revpad . ' ' if $revpad;
- } else {
- $template{$sname} .= 'x' x $pad . ' ' if $pad;
- }
- }
-
- $template = &fetch_template($type) x
- ($count ? &scripts2count($count) : 1);
-
- if (! $finished_template{$sname}) {
- $template{$sname} .= $template;
- }
-
- $revpad = $length/8 if $isaunion{$what};
-
- ($lastoffset, $lastlength) = ($offset, $length);
-
- } else {
- print '# ' if $perl && $verbose;
- $entry = sprintf($pmask1,
- ' ' x ($nesting * $indent) . $fieldtype,
- "$prefix.$fieldname" . $count);
-
- $entry =~ s/(\*+)( )/$2$1/;
-
- printf $pmask2,
- $entry,
- ($base+$offset)/8,
- ($bits = ($base+$offset)%8) ? ".$bits" : " ",
- $length/8,
- ($bits = $length % 8) ? ".$bits": ""
- if !$perl || $verbose;
-
-
- if ($perl && $nesting == 1) {
- $template = &scrunch(&fetch_template($type) x
- ($count ? &scripts2count($count) : 1));
- push(@sizeof, int($length/8) .",\t# $fieldname");
- push(@offsetof, int($offset/8) .",\t# $fieldname");
- push(@typedef, "'$template', \t# $fieldname");
- $type =~ s/(struct|union) //;
- push(@typeof, "'$type" . ($count ? $count : '') .
- "',\t# $fieldname");
- }
-
- print ' ', ' ' x $indent x $nesting, $template
- if $perl && $verbose;
-
- print "\n" if !$perl || $verbose;
-
- }
- if ($perl) {
- local($mycount) = defined $struct{$mytype} ? $countof{$mytype} : 1;
- $mycount *= &scripts2count($count) if $count;
- if ($nesting==1 && !$build_templates) {
- $pcode .= sprintf("sub %-32s { %4d; }\n",
- "${mname}'${fieldname}", $struct_count);
- push(@indices, $struct_count);
- }
- $struct_count += $mycount;
- }
-
-
- &pstruct($type, "$prefix.$fieldname", $base+$offset)
- if $recurse && defined $struct{$type};
- }
-
- $countof{$what} = $struct_count unless defined $countof{$whati};
-
- $template{$sname} .= '$' if $build_templates;
- $finished_template{$sname}++;
-
- if ($build_templates && !defined $sizeof{$name}) {
- local($fmt) = &scrunch($template{$sname});
- print STDERR "no size for $name, punting with $fmt..." if $debug;
- eval '$sizeof{$name} = length(pack($fmt, ()))';
- if ($@) {
- chop $@;
- warn "couldn't get size for \$name: $@";
- } else {
- print STDERR $sizeof{$name}, "\n" if $debUg;
- }
- }
-
- --$nesting;
-}
-
-
-sub psize {
- local($me) = @_;
- local($amstruct) = $struct{$me} ? 'struct ' : '';
-
- print '$sizeof{\'', $amstruct, $me, '\'} = ';
- printf "%d;\n", $sizeof{$me};
-}
-
-sub pdecl {
- local($pdecl) = @_;
- local(@pdecls);
- local($tname);
-
- warn "pdecl: $pdecl\n" if $debug;
-
- $pdecl =~ s/\(\d+,(\d+)\)/$1/g;
- $pdecl =~ s/\*//g;
- @pdecls = split(/=/, $pdecl);
- $typeno = $pdecls[0];
- $tname = pop @pdecls;
-
- if ($tname =~ s/^f//) { $tname = "$tname&"; }
- #else { $tname = "$tname*"; }
-
- for (reverse @pdecls) {
- $tname .= s/^f// ? "&" : "*";
- #$tname =~ s/^f(.*)/$1&/;
- print "type[$_] is $tname\n" if $debug;
- $type[$_] = $tname unless defined $type[$_];
- }
-}
-
-
-
-sub adecl {
- ($arraytype, $unknown, $lower, $upper) = ();
- #local($typeno);
- # global $typeno, @type
- local($_, $typedef) = @_;
-
- while (s/^((\d+)=)?ar(\d+);//) {
- ($arraytype, $unknown) = ($2, $3);
- if (s/^(\d+);(\d+);//) {
- ($lower, $upper) = ($1, $2);
- $scripts .= '[' . ($upper+1) . ']';
- } else {
- warn "can't find array bounds: $_";
- }
- }
- if (s/^([\d*f=]*),(\d+),(\d+);//) {
- ($start, $length) = ($2, $3);
- local($whatis) = $1;
- if ($whatis =~ /^(\d+)=/) {
- $typeno = $1;
- &pdecl($whatis);
- } else {
- $typeno = $whatis;
- }
- } elsif (s/^(\d+)(=[*suf]\d*)//) {
- local($whatis) = $2;
-
- if ($whatis =~ /[f*]/) {
- &pdecl($whatis);
- } elsif ($whatis =~ /[su]/) { #
- print "$prefix.$fieldname is an array$scripts anon structs; disgusting\n"
- if $debug;
- #$type[$typeno] = $name unless defined $type[$typeno];
- ##printf "new type $typeno is $name" if $debug;
- $typeno = $1;
- $type[$typeno] = "$prefix.$fieldname";
- local($name) = $type[$typeno];
- &sou($name, $whatis);
- $_ = &sdecl($name, $_, $start+$offset);
- 1;
- $start = $start{$name};
- $offset = $sizeof{$name};
- $length = $offset;
- } else {
- warn "what's this? $whatis in $line ";
- }
- } elsif (/^\d+$/) {
- $typeno = $_;
- } else {
- warn "bad array stab: $_ in $line ";
- next STAB;
- }
- #local($wasdef) = defined($type[$typeno]) && $debug;
- #if ($typedef) {
- #print "redefining $type[$typeno] to " if $wasdef;
- #$type[$typeno] = "$whatis$scripts"; # unless defined $type[$typeno];
- #print "$type[$typeno]\n" if $wasdef;
- #} else {
- #$type[$arraytype] = $type[$typeno] unless defined $type[$arraytype];
- #}
- $type[$arraytype] = "$type[$typeno]$scripts" if defined $type[$typeno];
- print "type[$arraytype] is $type[$arraytype]\n" if $debug;
- print "$prefix.$fieldname is an array of $type[$arraytype]\n" if $debug;
- $_;
-}
-
-
-
-sub sdecl {
- local($prefix, $_, $offset) = @_;
-
- local($fieldname, $scripts, $type, $arraytype, $unknown,
- $whatis, $pdecl, $upper,$lower, $start,$length) = ();
- local($typeno,$sou);
-
-
-SFIELD:
- while (/^([^;]+);/) {
- $scripts = '';
- warn "sdecl $_\n" if $debug;
- if (s/^([\$\w]+)://) {
- $fieldname = $1;
- } elsif (s/(\d+)=([us])(\d+|\(\d+,\d+\))//) { #
- $typeno = &typeno($1);
- $type[$typeno] = "$prefix.$fieldname";
- local($name) = "$prefix.$fieldname";
- &sou($name,$2);
- $_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
- $start = $start{$name};
- $offset += $sizeof{$name};
- #print "done with anon, start is $start, offset is $offset\n";
- #next SFIELD;
- } else {
- warn "weird field $_ of $line" if $debug;
- next STAB;
- #$fieldname = &gensym;
- #$_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
- }
-
- if (/^\d+=ar/) {
- $_ = &adecl($_);
- }
- elsif (s/^(\d+|\(\d+,\d+\))?,(\d+),(\d+);//) {
- ($start, $length) = ($2, $3);
- &panic("no length?") unless $length;
- $typeno = &typeno($1) if $1;
- }
- elsif (s/^((\d+|\(\d+,\d+\))(=[*f](\d+|\(\d+,\d+\)))+),(\d+),(\d+);//) {
- ($pdecl, $start, $length) = ($1,$5,$6);
- &pdecl($pdecl);
- }
- elsif (s/(\d+)=([us])(\d+|\(\d+,\d+\))//) { # the dratted anon struct
- ($typeno, $sou) = ($1, $2);
- $typeno = &typeno($typeno);
- if (defined($type[$typeno])) {
- warn "now how did we get type $1 in $fieldname of $line?";
- } else {
- print "anon type $typeno is $prefix.$fieldname\n" if $debug;
- $type[$typeno] = "$prefix.$fieldname" unless defined $type[$typeno];
- };
- local($name) = "$prefix.$fieldname";
- &sou($name,$sou);
- print "anon ".($isastruct{$name}) ? "struct":"union"." for $prefix.$fieldname\n" if $debug;
- $type[$typeno] = "$prefix.$fieldname";
- $_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
- $start = $start{$name};
- $length = $sizeof{$name};
- }
- else {
- warn "can't grok stab for $name ($_) in line $line ";
- next STAB;
- }
-
- &panic("no length for $prefix.$fieldname") unless $length;
- $struct{$name} .= join(',', $fieldname, $typeno, $scripts, $start, $length) . ';';
- }
- if (s/;\d*,(\d+),(\d+);//) {
- local($start, $size) = ($1, $2);
- $sizeof{$prefix} = $size;
- print "start of $prefix is $start, size of $sizeof{$prefix}\n" if $debug;
- $start{$prefix} = $start;
- }
- $_;
-}
-
-sub edecl {
- s/;$//;
- $enum{$name} = $_;
- $_ = '';
-}
-
-sub resolve_types {
- local($sou);
- for $i (0 .. $#type) {
- next unless defined $type[$i];
- $_ = $type[$i];
- unless (/\d/) {
- print "type[$i] $type[$i]\n" if $debug;
- next;
- }
- print "type[$i] $_ ==> " if $debug;
- s/^(\d+)(\**)\&\*(\**)/"$2($3".&type($1) . ')()'/e;
- s/^(\d+)\&/&type($1)/e;
- s/^(\d+)/&type($1)/e;
- s/(\*+)([^*]+)(\*+)/$1$3$2/;
- s/\((\*+)(\w+)(\*+)\)/$3($1$2)/;
- s/^(\d+)([\*\[].*)/&type($1).$2/e;
- #s/(\d+)(\*|(\[[\[\]\d\*]+]\])+)/&type($1).$2/ge;
- $type[$i] = $_;
- print "$_\n" if $debug;
- }
-}
-sub type { &psou($type[$_[0]] || "<UNDEFINED>"); }
-
-sub adjust_start_addrs {
- for (sort keys %start) {
- ($basename = $_) =~ s/\.[^.]+$//;
- $start{$_} += $start{$basename};
- print "start: $_ @ $start{$_}\n" if $debug;
- }
-}
-
-sub sou {
- local($what, $_) = @_;
- /u/ && $isaunion{$what}++;
- /s/ && $isastruct{$what}++;
-}
-
-sub psou {
- local($what) = @_;
- local($prefix) = '';
- if ($isaunion{$what}) {
- $prefix = 'union ';
- } elsif ($isastruct{$what}) {
- $prefix = 'struct ';
- }
- $prefix . $what;
-}
-
-sub scrunch {
- local($_) = @_;
-
- study;
-
- s/\$//g;
- s/ / /g;
- 1 while s/(\w) \1/$1$1/g;
-
- # i wanna say this, but perl resists my efforts:
- # s/(\w)(\1+)/$2 . length($1)/ge;
-
- &quick_scrunch;
-
- s/ $//;
-
- $_;
-}
-
-sub buildscrunchlist {
- $scrunch_code = "sub quick_scrunch {\n";
- for (values %intrinsics) {
- $scrunch_code .= "\ts/($_{2,})/'$_' . length(\$1)/ge;\n";
- }
- $scrunch_code .= "}\n";
- print "$scrunch_code" if $debug;
- eval $scrunch_code;
- &panic("can't eval scrunch_code $@ \nscrunch_code") if $@;
-}
-
-sub fetch_template {
- local($mytype) = @_;
- local($fmt);
- local($count) = 1;
-
- &panic("why do you care?") unless $perl;
-
- if ($mytype =~ s/(\[\d+\])+$//) {
- $count .= $1;
- }
-
- if ($mytype =~ /\*/) {
- $fmt = $template{'pointer'};
- }
- elsif (defined $template{$mytype}) {
- $fmt = $template{$mytype};
- }
- elsif (defined $struct{$mytype}) {
- if (!defined $template{&psou($mytype)}) {
- &build_template($mytype) unless $mytype eq $name;
- }
- elsif ($template{&psou($mytype)} !~ /\$$/) {
- #warn "incomplete template for $mytype\n";
- }
- $fmt = $template{&psou($mytype)} || '?';
- }
- else {
- warn "unknown fmt for $mytype\n";
- $fmt = '?';
- }
-
- $fmt x $count . ' ';
-}
-
-sub compute_intrinsics {
- local($TMP) = "/tmp/c2ph-i.$$.c";
- open (TMP, ">$TMP") || die "can't open $TMP: $!";
- select(TMP);
-
- print STDERR "computing intrinsic sizes: " if $trace;
-
- undef %intrinsics;
-
- print <<'EOF';
-main() {
- char *mask = "%d %s\n";
-EOF
-
- for $type (@intrinsics) {
- next if $type eq 'void';
- print <<"EOF";
- printf(mask,sizeof($type), "$type");
-EOF
- }
-
- print <<'EOF';
- printf(mask,sizeof(char *), "pointer");
- exit(0);
-}
-EOF
- close TMP;
-
- select(STDOUT);
- open(PIPE, "cd /tmp && $CC $TMP && /tmp/a.out|");
- while (<PIPE>) {
- chop;
- split(' ',$_,2);;
- print "intrinsic $_[1] is size $_[0]\n" if $debug;
- $sizeof{$_[1]} = $_[0];
- $intrinsics{$_[1]} = $template{$_[0]};
- }
- close(PIPE) || die "couldn't read intrinsics!";
- unlink($TMP, '/tmp/a.out');
- print STDERR "done\n" if $trace;
-}
-
-sub scripts2count {
- local($_) = @_;
-
- s/^\[//;
- s/\]$//;
- s/\]\[/*/g;
- $_ = eval;
- &panic("$_: $@") if $@;
- $_;
-}
-
-sub system {
- print STDERR "@_\n" if $trace;
- system @_;
-}
-
-sub build_template {
- local($name) = @_;
-
- &panic("already got a template for $name") if defined $template{$name};
-
- local($build_templates) = 1;
-
- local($lparen) = '(' x $build_recursed;
- local($rparen) = ')' x $build_recursed;
-
- print STDERR "$lparen$name$rparen " if $trace;
- $build_recursed++;
- &pstruct($name,$name,0);
- print STDERR "TEMPLATE for $name is ", $template{&psou($name)}, "\n" if $debug;
- --$build_recursed;
-}
-
-
-sub panic {
-
- select(STDERR);
-
- print "\npanic: @_\n";
-
- exit 1 if $] <= 4.003; # caller broken
-
- local($i,$_);
- local($p,$f,$l,$s,$h,$a,@a,@sub);
- for ($i = 0; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
- @a = @DB'args;
- for (@a) {
- if (/^StB\000/ && length($_) == length($_main{'_main'})) {
- $_ = sprintf("%s",$_);
- }
- else {
- s/'/\\'/g;
- s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
- s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
- s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
- }
- }
- $w = $w ? '@ = ' : '$ = ';
- $a = $h ? '(' . join(', ', @a) . ')' : '';
- push(@sub, "$w&$s$a from file $f line $l\n");
- last if $signal;
- }
- for ($i=0; $i <= $#sub; $i++) {
- last if $signal;
- print $sub[$i];
- }
- exit 1;
-}
-
-sub squishseq {
- local($num);
- local($last) = -1e8;
- local($string);
- local($seq) = '..';
-
- while (defined($num = shift)) {
- if ($num == ($last + 1)) {
- $string .= $seq unless $inseq++;
- $last = $num;
- next;
- } elsif ($inseq) {
- $string .= $last unless $last == -1e8;
- }
-
- $string .= ',' if defined $string;
- $string .= $num;
- $last = $num;
- $inseq = 0;
- }
- $string .= $last if $inseq && $last != -e18;
- $string;
-}
diff --git a/gnu/usr.bin/perl/misc/c2ph.1 b/gnu/usr.bin/perl/misc/c2ph.1
deleted file mode 100644
index 316e775..0000000
--- a/gnu/usr.bin/perl/misc/c2ph.1
+++ /dev/null
@@ -1,191 +0,0 @@
-Article 484 of comp.lang.perl:
-Xref: netlabs comp.lang.perl:484 comp.lang.c:983 alt.sources:134
-Path: netlabs!psinntp!iggy.GW.Vitalink.COM!lll-winken!sun-barr!cronkite.Central.Sun.COM!spdev!texsun!convex!tchrist
-From: tchrist@convex.com (Tom Christiansen)
-Newsgroups: comp.lang.perl,comp.lang.c,alt.sources
-Subject: pstruct -- a C structure formatter; AKA c2ph, a C to perl header translator
-Keywords: C perl tranlator
-Message-ID: <1991Jul25.081021.8104@convex.com>
-Date: 25 Jul 91 08:10:21 GMT
-Sender: usenet@convex.com (news access account)
-Followup-To: comp.lang.perl
-Organization: CONVEX Computer Corporation, Richardson, Tx., USA
-Lines: 1208
-Nntp-Posting-Host: pixel.convex.com
-
-Once upon a time, I wrote a program called pstruct. It was a perl
-program that tried to parse out C structures and display their member
-offsets for you. This was especially useful for people looking at
-binary dumps or poking around the kernel.
-
-Pstruct was not a pretty program. Neither was it particularly robust.
-The problem, you see, was that the C compiler was much better at parsing
-C than I could ever hope to be.
-
-So I got smart: I decided to be lazy and let the C compiler parse the C,
-which would spit out debugger stabs for me to read. These were much
-easier to parse. It's still not a pretty program, but at least it's more
-robust.
-
-Pstruct takes any .c or .h files, or preferably .s ones, since that's
-the format it is going to massage them into anyway, and spits out
-listings like this:
-
-struct tty {
- int tty.t_locker 000 4
- int tty.t_mutex_index 004 4
- struct tty * tty.t_tp_virt 008 4
- struct clist tty.t_rawq 00c 20
- int tty.t_rawq.c_cc 00c 4
- int tty.t_rawq.c_cmax 010 4
- int tty.t_rawq.c_cfx 014 4
- int tty.t_rawq.c_clx 018 4
- struct tty * tty.t_rawq.c_tp_cpu 01c 4
- struct tty * tty.t_rawq.c_tp_iop 020 4
- unsigned char * tty.t_rawq.c_buf_cpu 024 4
- unsigned char * tty.t_rawq.c_buf_iop 028 4
- struct clist tty.t_canq 02c 20
- int tty.t_canq.c_cc 02c 4
- int tty.t_canq.c_cmax 030 4
- int tty.t_canq.c_cfx 034 4
- int tty.t_canq.c_clx 038 4
- struct tty * tty.t_canq.c_tp_cpu 03c 4
- struct tty * tty.t_canq.c_tp_iop 040 4
- unsigned char * tty.t_canq.c_buf_cpu 044 4
- unsigned char * tty.t_canq.c_buf_iop 048 4
- struct clist tty.t_outq 04c 20
- int tty.t_outq.c_cc 04c 4
- int tty.t_outq.c_cmax 050 4
- int tty.t_outq.c_cfx 054 4
- int tty.t_outq.c_clx 058 4
- struct tty * tty.t_outq.c_tp_cpu 05c 4
- struct tty * tty.t_outq.c_tp_iop 060 4
- unsigned char * tty.t_outq.c_buf_cpu 064 4
- unsigned char * tty.t_outq.c_buf_iop 068 4
- (*int)() tty.t_oproc_cpu 06c 4
- (*int)() tty.t_oproc_iop 070 4
- (*int)() tty.t_stopproc_cpu 074 4
- (*int)() tty.t_stopproc_iop 078 4
- struct thread * tty.t_rsel 07c 4
-
- etc.
-
-
-Actually, this was generated by a particular set of options. You can control
-the formatting of each column, whether you prefer wide or fat, hex or decimal,
-leading zeroes or whatever.
-
-All you need to be able to use this is a C compiler than generates
-BSD/GCC-style stabs. The -g option on native BSD compilers and GCC
-should get this for you.
-
-To learn more, just type a bogus option, like -\?, and a long usage message
-will be provided. There are a fair number of possibilities.
-
-If you're only a C programmer, than this is the end of the message for you.
-You can quit right now, and if you care to, save off the source and run it
-when you feel like it. Or not.
-
-
-
-But if you're a perl programmer, then for you I have something much more
-wondrous than just a structure offset printer.
-
-You see, if you call pstruct by its other incybernation, c2ph, you have a code
-generator that translates C code into perl code! Well, structure and union
-declarations at least, but that's quite a bit.
-
-Prior to this point, anyone programming in perl who wanted to interact
-with C programs, like the kernel, was forced to guess the layouts of the C
-strutures, and then hardwire these into his program. Of course, when you
-took your wonderfully to a system where the sgtty structure was laid out
-differently, you program broke. Which is a shame.
-
-We've had Larry's h2ph translator, which helped, but that only works on
-cpp symbols, not real C, which was also very much needed. What I offer
-you is a symbolic way of getting at all the C structures. I've couched
-them in terms of packages and functions. Consider the following program:
-
- #!/usr/bin/perl
-
- require 'syscall.ph';
- require 'sys/time.ph';
- require 'sys/resource.ph';
-
- $ru = "\0" x &rusage'sizeof();
-
- syscall(&SYS_getrusage, &RUSAGE_SELF, $ru) && die "getrusage: $!";
-
- @ru = unpack($t = &rusage'typedef(), $ru);
-
- $utime = $ru[ &rusage'ru_utime + &timeval'tv_sec ]
- + ($ru[ &rusage'ru_utime + &timeval'tv_usec ]) / 1e6;
-
- $stime = $ru[ &rusage'ru_stime + &timeval'tv_sec ]
- + ($ru[ &rusage'ru_stime + &timeval'tv_usec ]) / 1e6;
-
- printf "you have used %8.3fs+%8.3fu seconds.\n", $utime, $stime;
-
-
-As you see, the name of the package is the name of the structure. Regular
-fields are just their own names. Plus the follwoing accessor functions are
-provided for your convenience:
-
- struct This takes no arguments, and is merely the number of first-level
- elements in the structure. You would use this for indexing
- into arrays of structures, perhaps like this
-
-
- $usec = $u[ &user'u_utimer
- + (&ITIMER_VIRTUAL * &itimerval'struct)
- + &itimerval'it_value
- + &timeval'tv_usec
- ];
-
- sizeof Returns the bytes in the structure, or the member if
- you pass it an argument, such as
-
- &rusage'sizeof(&rusage'ru_utime)
-
- typedef This is the perl format definition for passing to pack and
- unpack. If you ask for the typedef of a nothing, you get
- the whole structure, otherwise you get that of the member
- you ask for. Padding is taken care of, as is the magic to
- guarantee that a union is unpacked into all its aliases.
- Bitfields are not quite yet supported however.
-
- offsetof This function is the byte offset into the array of that
- member. You may wish to use this for indexing directly
- into the packed structure with vec() if you're too lazy
- to unpack it.
-
- typeof Not to be confused with the typedef accessor function, this
- one returns the C type of that field. This would allow
- you to print out a nice structured pretty print of some
- structure without knoning anything about it beforehand.
- No args to this one is a noop. Someday I'll post such
- a thing to dump out your u structure for you.
-
-
-The way I see this being used is like basically this:
-
- % h2ph <some_include_file.h > /usr/lib/perl/tmp.ph
- % c2ph some_include_file.h >> /usr/lib/perl/tmp.ph
- % install
-
-It's a little tricker with c2ph because you have to get the includes right.
-I can't know this for your system, but it's not usually too terribly difficult.
-
-The code isn't pretty as I mentioned -- I never thought it would be a 1000-
-line program when I started, or I might not have begun. :-) But I would have
-been less cavalier in how the parts of the program communicated with each
-other, etc. It might also have helped if I didn't have to divine the makeup
-of the stabs on the fly, and then account for micro differences between my
-compiler and gcc.
-
-Anyway, here it is. Should run on perl v4 or greater. Maybe less.
-
-
---tom
-
-
diff --git a/gnu/usr.bin/perl/misc/pstruct b/gnu/usr.bin/perl/misc/pstruct
deleted file mode 100644
index 5dfea04..0000000
--- a/gnu/usr.bin/perl/misc/pstruct
+++ /dev/null
@@ -1,1071 +0,0 @@
-#!/usr/bin/perl
-#
-#
-# c2ph (aka pstruct)
-# Tom Christiansen, <tchrist@convex.com>
-#
-# As pstruct, dump C structures as generated from 'cc -g -S' stabs.
-# As c2ph, do this PLUS generate perl code for getting at the structures.
-#
-# See the usage message for more. If this isn't enough, read the code.
-#
-
-$RCSID = '$RCSfile: pstruct,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:31 $';
-
-
-######################################################################
-
-# some handy data definitions. many of these can be reset later.
-
-$bitorder = 'b'; # ascending; set to B for descending bit fields
-
-%intrinsics =
-%template = (
- 'char', 'c',
- 'unsigned char', 'C',
- 'short', 's',
- 'short int', 's',
- 'unsigned short', 'S',
- 'unsigned short int', 'S',
- 'short unsigned int', 'S',
- 'int', 'i',
- 'unsigned int', 'I',
- 'long', 'l',
- 'long int', 'l',
- 'unsigned long', 'L',
- 'unsigned long', 'L',
- 'long unsigned int', 'L',
- 'unsigned long int', 'L',
- 'long long', 'q',
- 'long long int', 'q',
- 'unsigned long long', 'Q',
- 'unsigned long long int', 'Q',
- 'float', 'f',
- 'double', 'd',
- 'pointer', 'p',
- 'null', 'x',
- 'neganull', 'X',
- 'bit', $bitorder,
-);
-
-&buildscrunchlist;
-delete $intrinsics{'neganull'};
-delete $intrinsics{'bit'};
-delete $intrinsics{'null'};
-
-# use -s to recompute sizes
-%sizeof = (
- 'char', '1',
- 'unsigned char', '1',
- 'short', '2',
- 'short int', '2',
- 'unsigned short', '2',
- 'unsigned short int', '2',
- 'short unsigned int', '2',
- 'int', '4',
- 'unsigned int', '4',
- 'long', '4',
- 'long int', '4',
- 'unsigned long', '4',
- 'unsigned long int', '4',
- 'long unsigned int', '4',
- 'long long', '8',
- 'long long int', '8',
- 'unsigned long long', '8',
- 'unsigned long long int', '8',
- 'float', '4',
- 'double', '8',
- 'pointer', '4',
-);
-
-($type_width, $member_width, $offset_width, $size_width) = (20, 20, 6, 5);
-
-($offset_fmt, $size_fmt) = ('d', 'd');
-
-$indent = 2;
-
-$CC = 'cc';
-$CFLAGS = '-g -S';
-$DEFINES = '';
-
-$perl++ if $0 =~ m#/?c2ph$#;
-
-require 'getopts.pl';
-
-eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
-
-&Getopts('aixdpvtnws:') || &usage(0);
-
-$opt_d && $debug++;
-$opt_t && $trace++;
-$opt_p && $perl++;
-$opt_v && $verbose++;
-$opt_n && ($perl = 0);
-
-if ($opt_w) {
- ($type_width, $member_width, $offset_width) = (45, 35, 8);
-}
-if ($opt_x) {
- ($offset_fmt, $offset_width, $size_fmt, $size_width) = ( 'x', '08', 'x', 04 );
-}
-
-eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
-
-sub PLUMBER {
- select(STDERR);
- print "oops, apperent pager foulup\n";
- $isatty++;
- &usage(1);
-}
-
-sub usage {
- local($oops) = @_;
- unless (-t STDOUT) {
- select(STDERR);
- } elsif (!$oops) {
- $isatty++;
- $| = 1;
- print "hit <RETURN> for further explanation: ";
- <STDIN>;
- open (PIPE, "|". ($ENV{PAGER} || 'more'));
- $SIG{PIPE} = PLUMBER;
- select(PIPE);
- }
-
- print "usage: $0 [-dpnP] [var=val] [files ...]\n";
-
- exit unless $isatty;
-
- print <<EOF;
-
-Options:
-
--w wide; short for: type_width=45 member_width=35 offset_width=8
--x hex; short for: offset_fmt=x offset_width=08 size_fmt=x size_width=04
-
--n do not generate perl code (default when invoked as pstruct)
--p generate perl code (default when invoked as c2ph)
--v generate perl code, with C decls as comments
-
--i do NOT recompute sizes for intrinsic datatypes
--a dump information on intrinsics also
-
--t trace execution
--d spew reams of debugging output
-
--slist give comma-separated list a structures to dump
-
-
-Var Name Default Value Meaning
-
-EOF
-
- &defvar('CC', 'which_compiler to call');
- &defvar('CFLAGS', 'how to generate *.s files with stabs');
- &defvar('DEFINES','any extra cflags or cpp defines, like -I, -D, -U');
-
- print "\n";
-
- &defvar('type_width', 'width of type field (column 1)');
- &defvar('member_width', 'width of member field (column 2)');
- &defvar('offset_width', 'width of offset field (column 3)');
- &defvar('size_width', 'width of size field (column 4)');
-
- print "\n";
-
- &defvar('offset_fmt', 'sprintf format type for offset');
- &defvar('size_fmt', 'sprintf format type for size');
-
- print "\n";
-
- &defvar('indent', 'how far to indent each nesting level');
-
- print <<'EOF';
-
- If any *.[ch] files are given, these will be catted together into
- a temporary *.c file and sent through:
- $CC $CFLAGS $DEFINES
- and the resulting *.s groped for stab information. If no files are
- supplied, then stdin is read directly with the assumption that it
- contains stab information. All other liens will be ignored. At
- most one *.s file should be supplied.
-
-EOF
- close PIPE;
- exit 1;
-}
-
-sub defvar {
- local($var, $msg) = @_;
- printf "%-16s%-15s %s\n", $var, eval "\$$var", $msg;
-}
-
-$recurse = 1;
-
-if (@ARGV) {
- if (grep(!/\.[csh]$/,@ARGV)) {
- warn "Only *.[csh] files expected!\n";
- &usage;
- }
- elsif (grep(/\.s$/,@ARGV)) {
- if (@ARGV > 1) {
- warn "Only one *.s file allowed!\n";
- &usage;
- }
- }
- elsif (@ARGV == 1 && $ARGV[0] =~ /\.c$/) {
- local($dir, $file) = $ARGV[0] =~ m#(.*/)?(.*)$#;
- $chdir = "cd $dir; " if $dir;
- &system("$chdir$CC $CFLAGS $DEFINES $file") && exit 1;
- $ARGV[0] =~ s/\.c$/.s/;
- }
- else {
- $TMP = "/tmp/c2ph.$$.c";
- &system("cat @ARGV > $TMP") && exit 1;
- &system("cd /tmp; $CC $CFLAGS $DEFINES $TMP") && exit 1;
- unlink $TMP;
- $TMP =~ s/\.c$/.s/;
- @ARGV = ($TMP);
- }
-}
-
-if ($opt_s) {
- for (split(/[\s,]+/, $opt_s)) {
- $interested{$_}++;
- }
-}
-
-
-$| = 1 if $debug;
-
-main: {
-
- if ($trace) {
- if (-t && !@ARGV) {
- print STDERR "reading from your keyboard: ";
- } else {
- print STDERR "reading from " . (@ARGV ? "@ARGV" : "<STDIN>").": ";
- }
- }
-
-STAB: while (<>) {
- if ($trace && !($. % 10)) {
- $lineno = $..'';
- print STDERR $lineno, "\b" x length($lineno);
- }
- next unless /^\s*\.stabs\s+/;
- $line = $_;
- s/^\s*\.stabs\s+//;
- &stab;
- }
- print STDERR "$.\n" if $trace;
- unlink $TMP if $TMP;
-
- &compute_intrinsics if $perl && !$opt_i;
-
- print STDERR "resolving types\n" if $trace;
-
- &resolve_types;
- &adjust_start_addrs;
-
- $sum = 2 + $type_width + $member_width;
- $pmask1 = "%-${type_width}s %-${member_width}s";
- $pmask2 = "%-${sum}s %${offset_width}${offset_fmt}%s %${size_width}${size_fmt}%s";
-
- if ($perl) {
- # resolve template -- should be in stab define order, but even this isn't enough.
- print STDERR "\nbuilding type templates: " if $trace;
- for $i (reverse 0..$#type) {
- next unless defined($name = $type[$i]);
- next unless defined $struct{$name};
- $build_recursed = 0;
- &build_template($name) unless defined $template{&psou($name)} ||
- $opt_s && !$interested{$name};
- }
- print STDERR "\n\n" if $trace;
- }
-
- print STDERR "dumping structs: " if $trace;
-
-
- foreach $name (sort keys %struct) {
- next if $opt_s && !$interested{$name};
- print STDERR "$name " if $trace;
-
- undef @sizeof;
- undef @typedef;
- undef @offsetof;
- undef @indices;
- undef @typeof;
-
- $mname = &munge($name);
-
- $fname = &psou($name);
-
- print "# " if $perl && $verbose;
- $pcode = '';
- print "$fname {\n" if !$perl || $verbose;
- $template{$fname} = &scrunch($template{$fname}) if $perl;
- &pstruct($name,$name,0);
- print "# " if $perl && $verbose;
- print "}\n" if !$perl || $verbose;
- print "\n" if $perl && $verbose;
-
- if ($perl) {
- print "$pcode";
-
- printf("\nsub %-32s { %4d; }\n\n", "${mname}'struct", $countof{$name});
-
- print <<EOF;
-sub ${mname}'typedef {
- local(\$${mname}'index) = shift;
- defined \$${mname}'index
- ? \$${mname}'typedef[\$${mname}'index]
- : \$${mname}'typedef;
-}
-EOF
-
- print <<EOF;
-sub ${mname}'sizeof {
- local(\$${mname}'index) = shift;
- defined \$${mname}'index
- ? \$${mname}'sizeof[\$${mname}'index]
- : \$${mname}'sizeof;
-}
-EOF
-
- print <<EOF;
-sub ${mname}'offsetof {
- local(\$${mname}'index) = shift;
- defined \$${mname}index
- ? \$${mname}'offsetof[\$${mname}'index]
- : \$${mname}'sizeof;
-}
-EOF
-
- print <<EOF;
-sub ${mname}'typeof {
- local(\$${mname}'index) = shift;
- defined \$${mname}index
- ? \$${mname}'typeof[\$${mname}'index]
- : '$name';
-}
-EOF
-
-
- print "\$${mname}'typedef = '" . &scrunch($template{$fname})
- . "';\n";
-
- print "\$${mname}'sizeof = $sizeof{$name};\n\n";
-
-
- print "\@${mname}'indices = (", &squishseq(@indices), ");\n";
-
- print "\n";
-
- print "\@${mname}'typedef[\@${mname}'indices] = (",
- join("\n\t", '', @typedef), "\n );\n\n";
- print "\@${mname}'sizeof[\@${mname}'indices] = (",
- join("\n\t", '', @sizeof), "\n );\n\n";
- print "\@${mname}'offsetof[\@${mname}'indices] = (",
- join("\n\t", '', @offsetof), "\n );\n\n";
- print "\@${mname}'typeof[\@${mname}'indices] = (",
- join("\n\t", '', @typeof), "\n );\n\n";
-
- $template_printed{$fname}++;
- $size_printed{$fname}++;
- }
- print "\n";
- }
-
- print STDERR "\n" if $trace;
-
- unless ($perl && $opt_a) {
- print "\n1;\n";
- exit;
- }
-
-
-
- foreach $name (sort bysizevalue keys %intrinsics) {
- next if $size_printed{$name};
- print '$',&munge($name),"'sizeof = ", $sizeof{$name}, ";\n";
- }
-
- print "\n";
-
- sub bysizevalue { $sizeof{$a} <=> $sizeof{$b}; }
-
-
- foreach $name (sort keys %intrinsics) {
- print '$',&munge($name),"'typedef = '", $template{$name}, "';\n";
- }
-
- print "\n1;\n";
-
- exit;
-}
-
-########################################################################################
-
-
-sub stab {
- next unless /:[\$\w]+(\(\d+,\d+\))?=[\*\$\w]+/; # (\d+,\d+) is for sun
- s/"// || next;
- s/",([x\d]+),([x\d]+),([x\d]+),.*// || next;
-
- next if /^\s*$/;
-
- $size = $3 if $3;
-
-
- $line = $_;
-
- if (($name, $pdecl) = /^([\$ \w]+):[tT]((\d+)(=[rufs*](\d+))+)$/) {
- print "$name is a typedef for some funky pointers: $pdecl\n" if $debug;
- &pdecl($pdecl);
- next;
- }
-
-
-
- if (/(([ \w]+):t(\d+|\(\d+,\d+\)))=r?(\d+|\(\d+,\d+\))(;\d+;\d+;)?/) {
- local($ident) = $2;
- push(@intrinsics, $ident);
- $typeno = &typeno($3);
- $type[$typeno] = $ident;
- print STDERR "intrinsic $ident in new type $typeno\n" if $debug;
- next;
- }
-
- if (($name, $typeordef, $typeno, $extra, $struct, $_)
- = /^([\$ \w]+):([ustT])(\d+|\(\d+,\d+\))(=[rufs*](\d+))?(.*)$/)
- {
- $typeno = &typeno($typeno); # sun foolery
- }
- elsif (/^[\$\w]+:/) {
- next; # variable
- }
- else {
- warn "can't grok stab: <$_> in: $line " if $_;
- next;
- }
-
- #warn "got size $size for $name\n";
- $sizeof{$name} = $size if $size;
-
- s/;[-\d]*;[-\d]*;$//; # we don't care about ranges
-
- $typenos{$name} = $typeno;
-
- unless (defined $type[$typeno]) {
- &panic("type 0??") unless $typeno;
- $type[$typeno] = $name unless defined $type[$typeno];
- printf "new type $typeno is $name" if $debug;
- if ($extra =~ /\*/ && defined $type[$struct]) {
- print ", a typedef for a pointer to " , $type[$struct] if $debug;
- }
- } else {
- printf "%s is type %d", $name, $typeno if $debug;
- print ", a typedef for " , $type[$typeno] if $debug;
- }
- print "\n" if $debug;
- #next unless $extra =~ /[su*]/;
-
- #$type[$struct] = $name;
-
- if ($extra =~ /[us*]/) {
- &sou($name, $extra);
- $_ = &sdecl($name, $_, 0);
- }
- elsif (/^=ar/) {
- print "it's a bare array typedef -- that's pretty sick\n" if $debug;
- $_ = "$typeno$_";
- $scripts = '';
- $_ = &adecl($_,1);
-
- }
- elsif (s/((\w+):t(\d+|\(\d+,\d+\)))?=r?(;\d+;\d+;)?//) { # the ?'s are for gcc
- push(@intrinsics, $2);
- $typeno = &typeno($3);
- $type[$typeno] = $2;
- print STDERR "intrinsic $2 in new type $typeno\n" if $debug;
- }
- elsif (s/^=e//) { # blessed by thy compiler; mine won't do this
- &edecl;
- }
- else {
- warn "Funny remainder for $name on line $_ left in $line " if $_;
- }
-}
-
-sub typeno { # sun thinks types are (0,27) instead of just 27
- local($_) = @_;
- s/\(\d+,(\d+)\)/$1/;
- $_;
-}
-
-sub pstruct {
- local($what,$prefix,$base) = @_;
- local($field, $fieldname, $typeno, $count, $offset, $entry);
- local($fieldtype);
- local($type, $tname);
- local($mytype, $mycount, $entry2);
- local($struct_count) = 0;
- local($pad, $revpad, $length, $prepad, $lastoffset, $lastlength, $fmt);
- local($bits,$bytes);
- local($template);
-
-
- local($mname) = &munge($name);
-
- sub munge {
- local($_) = @_;
- s/[\s\$\.]/_/g;
- $_;
- }
-
- local($sname) = &psou($what);
-
- $nesting++;
-
- for $field (split(/;/, $struct{$what})) {
- $pad = $prepad = 0;
- $entry = '';
- ($fieldname, $typeno, $count, $offset, $length) = split(/,/, $field);
-
- $type = $type[$typeno];
-
- $type =~ /([^[]*)(\[.*\])?/;
- $mytype = $1;
- $count .= $2;
- $fieldtype = &psou($mytype);
-
- local($fname) = &psou($name);
-
- if ($build_templates) {
-
- $pad = ($offset - ($lastoffset + $lastlength))/8
- if defined $lastoffset;
-
- if (! $finished_template{$sname}) {
- if ($isaunion{$what}) {
- $template{$sname} .= 'X' x $revpad . ' ' if $revpad;
- } else {
- $template{$sname} .= 'x' x $pad . ' ' if $pad;
- }
- }
-
- $template = &fetch_template($type) x
- ($count ? &scripts2count($count) : 1);
-
- if (! $finished_template{$sname}) {
- $template{$sname} .= $template;
- }
-
- $revpad = $length/8 if $isaunion{$what};
-
- ($lastoffset, $lastlength) = ($offset, $length);
-
- } else {
- print '# ' if $perl && $verbose;
- $entry = sprintf($pmask1,
- ' ' x ($nesting * $indent) . $fieldtype,
- "$prefix.$fieldname" . $count);
-
- $entry =~ s/(\*+)( )/$2$1/;
-
- printf $pmask2,
- $entry,
- ($base+$offset)/8,
- ($bits = ($base+$offset)%8) ? ".$bits" : " ",
- $length/8,
- ($bits = $length % 8) ? ".$bits": ""
- if !$perl || $verbose;
-
-
- if ($perl && $nesting == 1) {
- $template = &scrunch(&fetch_template($type) x
- ($count ? &scripts2count($count) : 1));
- push(@sizeof, int($length/8) .",\t# $fieldname");
- push(@offsetof, int($offset/8) .",\t# $fieldname");
- push(@typedef, "'$template', \t# $fieldname");
- $type =~ s/(struct|union) //;
- push(@typeof, "'$type" . ($count ? $count : '') .
- "',\t# $fieldname");
- }
-
- print ' ', ' ' x $indent x $nesting, $template
- if $perl && $verbose;
-
- print "\n" if !$perl || $verbose;
-
- }
- if ($perl) {
- local($mycount) = defined $struct{$mytype} ? $countof{$mytype} : 1;
- $mycount *= &scripts2count($count) if $count;
- if ($nesting==1 && !$build_templates) {
- $pcode .= sprintf("sub %-32s { %4d; }\n",
- "${mname}'${fieldname}", $struct_count);
- push(@indices, $struct_count);
- }
- $struct_count += $mycount;
- }
-
-
- &pstruct($type, "$prefix.$fieldname", $base+$offset)
- if $recurse && defined $struct{$type};
- }
-
- $countof{$what} = $struct_count unless defined $countof{$whati};
-
- $template{$sname} .= '$' if $build_templates;
- $finished_template{$sname}++;
-
- if ($build_templates && !defined $sizeof{$name}) {
- local($fmt) = &scrunch($template{$sname});
- print STDERR "no size for $name, punting with $fmt..." if $debug;
- eval '$sizeof{$name} = length(pack($fmt, ()))';
- if ($@) {
- chop $@;
- warn "couldn't get size for \$name: $@";
- } else {
- print STDERR $sizeof{$name}, "\n" if $debUg;
- }
- }
-
- --$nesting;
-}
-
-
-sub psize {
- local($me) = @_;
- local($amstruct) = $struct{$me} ? 'struct ' : '';
-
- print '$sizeof{\'', $amstruct, $me, '\'} = ';
- printf "%d;\n", $sizeof{$me};
-}
-
-sub pdecl {
- local($pdecl) = @_;
- local(@pdecls);
- local($tname);
-
- warn "pdecl: $pdecl\n" if $debug;
-
- $pdecl =~ s/\(\d+,(\d+)\)/$1/g;
- $pdecl =~ s/\*//g;
- @pdecls = split(/=/, $pdecl);
- $typeno = $pdecls[0];
- $tname = pop @pdecls;
-
- if ($tname =~ s/^f//) { $tname = "$tname&"; }
- #else { $tname = "$tname*"; }
-
- for (reverse @pdecls) {
- $tname .= s/^f// ? "&" : "*";
- #$tname =~ s/^f(.*)/$1&/;
- print "type[$_] is $tname\n" if $debug;
- $type[$_] = $tname unless defined $type[$_];
- }
-}
-
-
-
-sub adecl {
- ($arraytype, $unknown, $lower, $upper) = ();
- #local($typeno);
- # global $typeno, @type
- local($_, $typedef) = @_;
-
- while (s/^((\d+)=)?ar(\d+);//) {
- ($arraytype, $unknown) = ($2, $3);
- if (s/^(\d+);(\d+);//) {
- ($lower, $upper) = ($1, $2);
- $scripts .= '[' . ($upper+1) . ']';
- } else {
- warn "can't find array bounds: $_";
- }
- }
- if (s/^([\d*f=]*),(\d+),(\d+);//) {
- ($start, $length) = ($2, $3);
- local($whatis) = $1;
- if ($whatis =~ /^(\d+)=/) {
- $typeno = $1;
- &pdecl($whatis);
- } else {
- $typeno = $whatis;
- }
- } elsif (s/^(\d+)(=[*suf]\d*)//) {
- local($whatis) = $2;
-
- if ($whatis =~ /[f*]/) {
- &pdecl($whatis);
- } elsif ($whatis =~ /[su]/) { #
- print "$prefix.$fieldname is an array$scripts anon structs; disgusting\n"
- if $debug;
- #$type[$typeno] = $name unless defined $type[$typeno];
- ##printf "new type $typeno is $name" if $debug;
- $typeno = $1;
- $type[$typeno] = "$prefix.$fieldname";
- local($name) = $type[$typeno];
- &sou($name, $whatis);
- $_ = &sdecl($name, $_, $start+$offset);
- 1;
- $start = $start{$name};
- $offset = $sizeof{$name};
- $length = $offset;
- } else {
- warn "what's this? $whatis in $line ";
- }
- } elsif (/^\d+$/) {
- $typeno = $_;
- } else {
- warn "bad array stab: $_ in $line ";
- next STAB;
- }
- #local($wasdef) = defined($type[$typeno]) && $debug;
- #if ($typedef) {
- #print "redefining $type[$typeno] to " if $wasdef;
- #$type[$typeno] = "$whatis$scripts"; # unless defined $type[$typeno];
- #print "$type[$typeno]\n" if $wasdef;
- #} else {
- #$type[$arraytype] = $type[$typeno] unless defined $type[$arraytype];
- #}
- $type[$arraytype] = "$type[$typeno]$scripts" if defined $type[$typeno];
- print "type[$arraytype] is $type[$arraytype]\n" if $debug;
- print "$prefix.$fieldname is an array of $type[$arraytype]\n" if $debug;
- $_;
-}
-
-
-
-sub sdecl {
- local($prefix, $_, $offset) = @_;
-
- local($fieldname, $scripts, $type, $arraytype, $unknown,
- $whatis, $pdecl, $upper,$lower, $start,$length) = ();
- local($typeno,$sou);
-
-
-SFIELD:
- while (/^([^;]+);/) {
- $scripts = '';
- warn "sdecl $_\n" if $debug;
- if (s/^([\$\w]+)://) {
- $fieldname = $1;
- } elsif (s/(\d+)=([us])(\d+|\(\d+,\d+\))//) { #
- $typeno = &typeno($1);
- $type[$typeno] = "$prefix.$fieldname";
- local($name) = "$prefix.$fieldname";
- &sou($name,$2);
- $_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
- $start = $start{$name};
- $offset += $sizeof{$name};
- #print "done with anon, start is $start, offset is $offset\n";
- #next SFIELD;
- } else {
- warn "weird field $_ of $line" if $debug;
- next STAB;
- #$fieldname = &gensym;
- #$_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
- }
-
- if (/^\d+=ar/) {
- $_ = &adecl($_);
- }
- elsif (s/^(\d+|\(\d+,\d+\))?,(\d+),(\d+);//) {
- ($start, $length) = ($2, $3);
- &panic("no length?") unless $length;
- $typeno = &typeno($1) if $1;
- }
- elsif (s/^((\d+|\(\d+,\d+\))(=[*f](\d+|\(\d+,\d+\)))+),(\d+),(\d+);//) {
- ($pdecl, $start, $length) = ($1,$5,$6);
- &pdecl($pdecl);
- }
- elsif (s/(\d+)=([us])(\d+|\(\d+,\d+\))//) { # the dratted anon struct
- ($typeno, $sou) = ($1, $2);
- $typeno = &typeno($typeno);
- if (defined($type[$typeno])) {
- warn "now how did we get type $1 in $fieldname of $line?";
- } else {
- print "anon type $typeno is $prefix.$fieldname\n" if $debug;
- $type[$typeno] = "$prefix.$fieldname" unless defined $type[$typeno];
- };
- local($name) = "$prefix.$fieldname";
- &sou($name,$sou);
- print "anon ".($isastruct{$name}) ? "struct":"union"." for $prefix.$fieldname\n" if $debug;
- $type[$typeno] = "$prefix.$fieldname";
- $_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
- $start = $start{$name};
- $length = $sizeof{$name};
- }
- else {
- warn "can't grok stab for $name ($_) in line $line ";
- next STAB;
- }
-
- &panic("no length for $prefix.$fieldname") unless $length;
- $struct{$name} .= join(',', $fieldname, $typeno, $scripts, $start, $length) . ';';
- }
- if (s/;\d*,(\d+),(\d+);//) {
- local($start, $size) = ($1, $2);
- $sizeof{$prefix} = $size;
- print "start of $prefix is $start, size of $sizeof{$prefix}\n" if $debug;
- $start{$prefix} = $start;
- }
- $_;
-}
-
-sub edecl {
- s/;$//;
- $enum{$name} = $_;
- $_ = '';
-}
-
-sub resolve_types {
- local($sou);
- for $i (0 .. $#type) {
- next unless defined $type[$i];
- $_ = $type[$i];
- unless (/\d/) {
- print "type[$i] $type[$i]\n" if $debug;
- next;
- }
- print "type[$i] $_ ==> " if $debug;
- s/^(\d+)(\**)\&\*(\**)/"$2($3".&type($1) . ')()'/e;
- s/^(\d+)\&/&type($1)/e;
- s/^(\d+)/&type($1)/e;
- s/(\*+)([^*]+)(\*+)/$1$3$2/;
- s/\((\*+)(\w+)(\*+)\)/$3($1$2)/;
- s/^(\d+)([\*\[].*)/&type($1).$2/e;
- #s/(\d+)(\*|(\[[\[\]\d\*]+]\])+)/&type($1).$2/ge;
- $type[$i] = $_;
- print "$_\n" if $debug;
- }
-}
-sub type { &psou($type[$_[0]] || "<UNDEFINED>"); }
-
-sub adjust_start_addrs {
- for (sort keys %start) {
- ($basename = $_) =~ s/\.[^.]+$//;
- $start{$_} += $start{$basename};
- print "start: $_ @ $start{$_}\n" if $debug;
- }
-}
-
-sub sou {
- local($what, $_) = @_;
- /u/ && $isaunion{$what}++;
- /s/ && $isastruct{$what}++;
-}
-
-sub psou {
- local($what) = @_;
- local($prefix) = '';
- if ($isaunion{$what}) {
- $prefix = 'union ';
- } elsif ($isastruct{$what}) {
- $prefix = 'struct ';
- }
- $prefix . $what;
-}
-
-sub scrunch {
- local($_) = @_;
-
- study;
-
- s/\$//g;
- s/ / /g;
- 1 while s/(\w) \1/$1$1/g;
-
- # i wanna say this, but perl resists my efforts:
- # s/(\w)(\1+)/$2 . length($1)/ge;
-
- &quick_scrunch;
-
- s/ $//;
-
- $_;
-}
-
-sub buildscrunchlist {
- $scrunch_code = "sub quick_scrunch {\n";
- for (values %intrinsics) {
- $scrunch_code .= "\ts/($_{2,})/'$_' . length(\$1)/ge;\n";
- }
- $scrunch_code .= "}\n";
- print "$scrunch_code" if $debug;
- eval $scrunch_code;
- &panic("can't eval scrunch_code $@ \nscrunch_code") if $@;
-}
-
-sub fetch_template {
- local($mytype) = @_;
- local($fmt);
- local($count) = 1;
-
- &panic("why do you care?") unless $perl;
-
- if ($mytype =~ s/(\[\d+\])+$//) {
- $count .= $1;
- }
-
- if ($mytype =~ /\*/) {
- $fmt = $template{'pointer'};
- }
- elsif (defined $template{$mytype}) {
- $fmt = $template{$mytype};
- }
- elsif (defined $struct{$mytype}) {
- if (!defined $template{&psou($mytype)}) {
- &build_template($mytype) unless $mytype eq $name;
- }
- elsif ($template{&psou($mytype)} !~ /\$$/) {
- #warn "incomplete template for $mytype\n";
- }
- $fmt = $template{&psou($mytype)} || '?';
- }
- else {
- warn "unknown fmt for $mytype\n";
- $fmt = '?';
- }
-
- $fmt x $count . ' ';
-}
-
-sub compute_intrinsics {
- local($TMP) = "/tmp/c2ph-i.$$.c";
- open (TMP, ">$TMP") || die "can't open $TMP: $!";
- select(TMP);
-
- print STDERR "computing intrinsic sizes: " if $trace;
-
- undef %intrinsics;
-
- print <<'EOF';
-main() {
- char *mask = "%d %s\n";
-EOF
-
- for $type (@intrinsics) {
- next if $type eq 'void';
- print <<"EOF";
- printf(mask,sizeof($type), "$type");
-EOF
- }
-
- print <<'EOF';
- printf(mask,sizeof(char *), "pointer");
- exit(0);
-}
-EOF
- close TMP;
-
- select(STDOUT);
- open(PIPE, "cd /tmp && $CC $TMP && /tmp/a.out|");
- while (<PIPE>) {
- chop;
- split(' ',$_,2);;
- print "intrinsic $_[1] is size $_[0]\n" if $debug;
- $sizeof{$_[1]} = $_[0];
- $intrinsics{$_[1]} = $template{$_[0]};
- }
- close(PIPE) || die "couldn't read intrinsics!";
- unlink($TMP, '/tmp/a.out');
- print STDERR "done\n" if $trace;
-}
-
-sub scripts2count {
- local($_) = @_;
-
- s/^\[//;
- s/\]$//;
- s/\]\[/*/g;
- $_ = eval;
- &panic("$_: $@") if $@;
- $_;
-}
-
-sub system {
- print STDERR "@_\n" if $trace;
- system @_;
-}
-
-sub build_template {
- local($name) = @_;
-
- &panic("already got a template for $name") if defined $template{$name};
-
- local($build_templates) = 1;
-
- local($lparen) = '(' x $build_recursed;
- local($rparen) = ')' x $build_recursed;
-
- print STDERR "$lparen$name$rparen " if $trace;
- $build_recursed++;
- &pstruct($name,$name,0);
- print STDERR "TEMPLATE for $name is ", $template{&psou($name)}, "\n" if $debug;
- --$build_recursed;
-}
-
-
-sub panic {
-
- select(STDERR);
-
- print "\npanic: @_\n";
-
- exit 1 if $] <= 4.003; # caller broken
-
- local($i,$_);
- local($p,$f,$l,$s,$h,$a,@a,@sub);
- for ($i = 0; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
- @a = @DB'args;
- for (@a) {
- if (/^StB\000/ && length($_) == length($_main{'_main'})) {
- $_ = sprintf("%s",$_);
- }
- else {
- s/'/\\'/g;
- s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
- s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
- s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
- }
- }
- $w = $w ? '@ = ' : '$ = ';
- $a = $h ? '(' . join(', ', @a) . ')' : '';
- push(@sub, "$w&$s$a from file $f line $l\n");
- last if $signal;
- }
- for ($i=0; $i <= $#sub; $i++) {
- last if $signal;
- print $sub[$i];
- }
- exit 1;
-}
-
-sub squishseq {
- local($num);
- local($last) = -1e8;
- local($string);
- local($seq) = '..';
-
- while (defined($num = shift)) {
- if ($num == ($last + 1)) {
- $string .= $seq unless $inseq++;
- $last = $num;
- next;
- } elsif ($inseq) {
- $string .= $last unless $last == -1e8;
- }
-
- $string .= ',' if defined $string;
- $string .= $num;
- $last = $num;
- $inseq = 0;
- }
- $string .= $last if $inseq && $last != -e18;
- $string;
-}
diff --git a/gnu/usr.bin/perl/perl/EXTERN.h b/gnu/usr.bin/perl/perl/EXTERN.h
deleted file mode 100644
index fec95bf..0000000
--- a/gnu/usr.bin/perl/perl/EXTERN.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* $RCSfile: EXTERN.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:34 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: EXTERN.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:33 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 10:10:32 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 00:58:26 lwall
- * 4.0 baseline.
- *
- */
-
-#undef EXT
-#define EXT extern
-
-#undef INIT
-#define INIT(x)
-
-#undef DOINIT
diff --git a/gnu/usr.bin/perl/perl/INTERN.h b/gnu/usr.bin/perl/perl/INTERN.h
deleted file mode 100644
index d1792d8..0000000
--- a/gnu/usr.bin/perl/perl/INTERN.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* $RCSfile: INTERN.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:34 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: INTERN.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:33 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 10:10:42 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 00:58:35 lwall
- * 4.0 baseline.
- *
- */
-
-#undef EXT
-#define EXT
-
-#undef INIT
-#define INIT(x) = x
-
-#define DOINIT
diff --git a/gnu/usr.bin/perl/perl/Makefile b/gnu/usr.bin/perl/perl/Makefile
deleted file mode 100644
index 876f0e1..0000000
--- a/gnu/usr.bin/perl/perl/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-#
-
-PROG= perl
-
-SRCS+= array.c cmd.c cons.c consarg.c doarg.c doio.c dolist.c dump.c
-SRCS+= eval.c form.c hash.c perl.c perly.c regcomp.c regexec.c
-SRCS+= stab.c str.c toke.c util.c usersub.c
-CFLAGS+= -I${.CURDIR}
-LDADD= -lm
-DPADD= ${LIBM}
-
-DPADD+= ${LIBCRYPT}
-LDADD+= -lcrypt
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/perl/perl/arg.h b/gnu/usr.bin/perl/perl/arg.h
deleted file mode 100644
index b3f8d5a..0000000
--- a/gnu/usr.bin/perl/perl/arg.h
+++ /dev/null
@@ -1,1001 +0,0 @@
-/* $RCSfile: arg.h,v $$Revision: 1.2 $$Date: 1994/09/11 03:17:24 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: arg.h,v $
- * Revision 1.2 1994/09/11 03:17:24 gclarkii
- * Changed AF_LOCAL to AF_LOCAL_XX so as not to conflict with 4.4 socket.h
- * Added casts to shutup warnings in doio.c
- *
- * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:34 nate
- * PERL!
- *
- * Revision 4.0.1.3 92/06/08 11:44:06 lwall
- * patch20: O_PIPE conflicted with Atari
- * patch20: clarified debugging output for literals and double-quoted strings
- *
- * Revision 4.0.1.2 91/11/05 15:51:05 lwall
- * patch11: added eval {}
- * patch11: added sort {} LIST
- *
- * Revision 4.0.1.1 91/06/07 10:18:30 lwall
- * patch4: length($`), length($&), length($') now optimized to avoid string copy
- * patch4: new copyright notice
- * patch4: many, many itty-bitty portability fixes
- *
- * Revision 4.0 91/03/20 01:03:09 lwall
- * 4.0 baseline.
- *
- */
-
-#define O_NULL 0
-#define O_RCAT 1
-#define O_ITEM 2
-#define O_SCALAR 3
-#define O_ITEM2 4
-#define O_ITEM3 5
-#define O_CONCAT 6
-#define O_REPEAT 7
-#define O_MATCH 8
-#define O_NMATCH 9
-#define O_SUBST 10
-#define O_NSUBST 11
-#define O_ASSIGN 12
-#define O_LOCAL 13
-#define O_AASSIGN 14
-#define O_SASSIGN 15
-#define O_CHOP 16
-#define O_DEFINED 17
-#define O_UNDEF 18
-#define O_STUDY 19
-#define O_POW 20
-#define O_MULTIPLY 21
-#define O_DIVIDE 22
-#define O_MODULO 23
-#define O_ADD 24
-#define O_SUBTRACT 25
-#define O_LEFT_SHIFT 26
-#define O_RIGHT_SHIFT 27
-#define O_LT 28
-#define O_GT 29
-#define O_LE 30
-#define O_GE 31
-#define O_EQ 32
-#define O_NE 33
-#define O_NCMP 34
-#define O_BIT_AND 35
-#define O_XOR 36
-#define O_BIT_OR 37
-#define O_AND 38
-#define O_OR 39
-#define O_COND_EXPR 40
-#define O_COMMA 41
-#define O_NEGATE 42
-#define O_NOT 43
-#define O_COMPLEMENT 44
-#define O_SELECT 45
-#define O_WRITE 46
-#define O_DBMOPEN 47
-#define O_DBMCLOSE 48
-#define O_OPEN 49
-#define O_TRANS 50
-#define O_NTRANS 51
-#define O_CLOSE 52
-#define O_EACH 53
-#define O_VALUES 54
-#define O_KEYS 55
-#define O_LARRAY 56
-#define O_ARRAY 57
-#define O_AELEM 58
-#define O_DELETE 59
-#define O_LHASH 60
-#define O_HASH 61
-#define O_HELEM 62
-#define O_LAELEM 63
-#define O_LHELEM 64
-#define O_LSLICE 65
-#define O_ASLICE 66
-#define O_HSLICE 67
-#define O_LASLICE 68
-#define O_LHSLICE 69
-#define O_SPLICE 70
-#define O_PUSH 71
-#define O_POP 72
-#define O_SHIFT 73
-#define O_UNPACK 74
-#define O_SPLIT 75
-#define O_LENGTH 76
-#define O_SPRINTF 77
-#define O_SUBSTR 78
-#define O_PACK 79
-#define O_GREP 80
-#define O_JOIN 81
-#define O_SLT 82
-#define O_SGT 83
-#define O_SLE 84
-#define O_SGE 85
-#define O_SEQ 86
-#define O_SNE 87
-#define O_SCMP 88
-#define O_SUBR 89
-#define O_DBSUBR 90
-#define O_CALLER 91
-#define O_SORT 92
-#define O_REVERSE 93
-#define O_WARN 94
-#define O_DIE 95
-#define O_PRTF 96
-#define O_PRINT 97
-#define O_CHDIR 98
-#define O_EXIT 99
-#define O_RESET 100
-#define O_LIST 101
-#define O_EOF 102
-#define O_GETC 103
-#define O_TELL 104
-#define O_RECV 105
-#define O_READ 106
-#define O_SYSREAD 107
-#define O_SYSWRITE 108
-#define O_SEND 109
-#define O_SEEK 110
-#define O_RETURN 111
-#define O_REDO 112
-#define O_NEXT 113
-#define O_LAST 114
-#define O_DUMP 115
-#define O_GOTO 116
-#define O_INDEX 117
-#define O_RINDEX 118
-#define O_TIME 119
-#define O_TMS 120
-#define O_LOCALTIME 121
-#define O_GMTIME 122
-#define O_TRUNCATE 123
-#define O_LSTAT 124
-#define O_STAT 125
-#define O_CRYPT 126
-#define O_ATAN2 127
-#define O_SIN 128
-#define O_COS 129
-#define O_RAND 130
-#define O_SRAND 131
-#define O_EXP 132
-#define O_LOG 133
-#define O_SQRT 134
-#define O_INT 135
-#define O_ORD 136
-#define O_ALARM 137
-#define O_SLEEP 138
-#define O_RANGE 139
-#define O_F_OR_R 140
-#define O_FLIP 141
-#define O_FLOP 142
-#define O_FORK 143
-#define O_WAIT 144
-#define O_WAITPID 145
-#define O_SYSTEM 146
-#define O_EXEC_OP 147
-#define O_HEX 148
-#define O_OCT 149
-#define O_CHOWN 150
-#define O_KILL 151
-#define O_UNLINK 152
-#define O_CHMOD 153
-#define O_UTIME 154
-#define O_UMASK 155
-#define O_MSGGET 156
-#define O_SHMGET 157
-#define O_SEMGET 158
-#define O_MSGCTL 159
-#define O_SHMCTL 160
-#define O_SEMCTL 161
-#define O_MSGSND 162
-#define O_MSGRCV 163
-#define O_SEMOP 164
-#define O_SHMREAD 165
-#define O_SHMWRITE 166
-#define O_RENAME 167
-#define O_LINK 168
-#define O_MKDIR 169
-#define O_RMDIR 170
-#define O_GETPPID 171
-#define O_GETPGRP 172
-#define O_SETPGRP 173
-#define O_GETPRIORITY 174
-#define O_SETPRIORITY 175
-#define O_CHROOT 176
-#define O_FCNTL 177
-#define O_IOCTL 178
-#define O_FLOCK 179
-#define O_UNSHIFT 180
-#define O_REQUIRE 181
-#define O_DOFILE 182
-#define O_EVAL 183
-#define O_FTRREAD 184
-#define O_FTRWRITE 185
-#define O_FTREXEC 186
-#define O_FTEREAD 187
-#define O_FTEWRITE 188
-#define O_FTEEXEC 189
-#define O_FTIS 190
-#define O_FTEOWNED 191
-#define O_FTROWNED 192
-#define O_FTZERO 193
-#define O_FTSIZE 194
-#define O_FTMTIME 195
-#define O_FTATIME 196
-#define O_FTCTIME 197
-#define O_FTSOCK 198
-#define O_FTCHR 199
-#define O_FTBLK 200
-#define O_FTFILE 201
-#define O_FTDIR 202
-#define O_FTPIPE 203
-#define O_FTLINK 204
-#define O_SYMLINK 205
-#define O_READLINK 206
-#define O_FTSUID 207
-#define O_FTSGID 208
-#define O_FTSVTX 209
-#define O_FTTTY 210
-#define O_FTTEXT 211
-#define O_FTBINARY 212
-#define O_SOCKET 213
-#define O_BIND 214
-#define O_CONNECT 215
-#define O_LISTEN 216
-#define O_ACCEPT 217
-#define O_GHBYNAME 218
-#define O_GHBYADDR 219
-#define O_GHOSTENT 220
-#define O_GNBYNAME 221
-#define O_GNBYADDR 222
-#define O_GNETENT 223
-#define O_GPBYNAME 224
-#define O_GPBYNUMBER 225
-#define O_GPROTOENT 226
-#define O_GSBYNAME 227
-#define O_GSBYPORT 228
-#define O_GSERVENT 229
-#define O_SHOSTENT 230
-#define O_SNETENT 231
-#define O_SPROTOENT 232
-#define O_SSERVENT 233
-#define O_EHOSTENT 234
-#define O_ENETENT 235
-#define O_EPROTOENT 236
-#define O_ESERVENT 237
-#define O_SOCKPAIR 238
-#define O_SHUTDOWN 239
-#define O_GSOCKOPT 240
-#define O_SSOCKOPT 241
-#define O_GETSOCKNAME 242
-#define O_GETPEERNAME 243
-#define O_SSELECT 244
-#define O_FILENO 245
-#define O_BINMODE 246
-#define O_VEC 247
-#define O_GPWNAM 248
-#define O_GPWUID 249
-#define O_GPWENT 250
-#define O_SPWENT 251
-#define O_EPWENT 252
-#define O_GGRNAM 253
-#define O_GGRGID 254
-#define O_GGRENT 255
-#define O_SGRENT 256
-#define O_EGRENT 257
-#define O_GETLOGIN 258
-#define O_OPEN_DIR 259
-#define O_READDIR 260
-#define O_TELLDIR 261
-#define O_SEEKDIR 262
-#define O_REWINDDIR 263
-#define O_CLOSEDIR 264
-#define O_SYSCALL 265
-#define O_PIPE_OP 266
-#define O_TRY 267
-#define O_EVALONCE 268
-#define MAXO 269
-
-#ifndef DOINIT
-extern char *opname[];
-#else
-char *opname[] = {
- "NULL",
- "RCAT",
- "ITEM",
- "SCALAR",
- "ITEM2",
- "ITEM3",
- "CONCAT",
- "REPEAT",
- "MATCH",
- "NMATCH",
- "SUBST",
- "NSUBST",
- "ASSIGN",
- "LOCAL",
- "AASSIGN",
- "SASSIGN",
- "CHOP",
- "DEFINED",
- "UNDEF",
- "STUDY",
- "POW",
- "MULTIPLY",
- "DIVIDE",
- "MODULO",
- "ADD",
- "SUBTRACT",
- "LEFT_SHIFT",
- "RIGHT_SHIFT",
- "LT",
- "GT",
- "LE",
- "GE",
- "EQ",
- "NE",
- "NCMP",
- "BIT_AND",
- "XOR",
- "BIT_OR",
- "AND",
- "OR",
- "COND_EXPR",
- "COMMA",
- "NEGATE",
- "NOT",
- "COMPLEMENT",
- "SELECT",
- "WRITE",
- "DBMOPEN",
- "DBMCLOSE",
- "OPEN",
- "TRANS",
- "NTRANS",
- "CLOSE",
- "EACH",
- "VALUES",
- "KEYS",
- "LARRAY",
- "ARRAY",
- "AELEM",
- "DELETE",
- "LHASH",
- "HASH",
- "HELEM",
- "LAELEM",
- "LHELEM",
- "LSLICE",
- "ASLICE",
- "HSLICE",
- "LASLICE",
- "LHSLICE",
- "SPLICE",
- "PUSH",
- "POP",
- "SHIFT",
- "UNPACK",
- "SPLIT",
- "LENGTH",
- "SPRINTF",
- "SUBSTR",
- "PACK",
- "GREP",
- "JOIN",
- "SLT",
- "SGT",
- "SLE",
- "SGE",
- "SEQ",
- "SNE",
- "SCMP",
- "SUBR",
- "DBSUBR",
- "CALLER",
- "SORT",
- "REVERSE",
- "WARN",
- "DIE",
- "PRINTF",
- "PRINT",
- "CHDIR",
- "EXIT",
- "RESET",
- "LIST",
- "EOF",
- "GETC",
- "TELL",
- "RECV",
- "READ",
- "SYSREAD",
- "SYSWRITE",
- "SEND",
- "SEEK",
- "RETURN",
- "REDO",
- "NEXT",
- "LAST",
- "DUMP",
- "GOTO",/* shudder */
- "INDEX",
- "RINDEX",
- "TIME",
- "TIMES",
- "LOCALTIME",
- "GMTIME",
- "TRUNCATE",
- "LSTAT",
- "STAT",
- "CRYPT",
- "ATAN2",
- "SIN",
- "COS",
- "RAND",
- "SRAND",
- "EXP",
- "LOG",
- "SQRT",
- "INT",
- "ORD",
- "ALARM",
- "SLEEP",
- "RANGE",
- "FLIP_OR_RANGE",
- "FLIP",
- "FLOP",
- "FORK",
- "WAIT",
- "WAITPID",
- "SYSTEM",
- "EXEC",
- "HEX",
- "OCT",
- "CHOWN",
- "KILL",
- "UNLINK",
- "CHMOD",
- "UTIME",
- "UMASK",
- "MSGGET",
- "SHMGET",
- "SEMGET",
- "MSGCTL",
- "SHMCTL",
- "SEMCTL",
- "MSGSND",
- "MSGRCV",
- "SEMOP",
- "SHMREAD",
- "SHMWRITE",
- "RENAME",
- "LINK",
- "MKDIR",
- "RMDIR",
- "GETPPID",
- "GETPGRP",
- "SETPGRP",
- "GETPRIORITY",
- "SETPRIORITY",
- "CHROOT",
- "FCNTL",
- "SYSIOCTL",
- "FLOCK",
- "UNSHIFT",
- "REQUIRE",
- "DOFILE",
- "EVAL",
- "FTRREAD",
- "FTRWRITE",
- "FTREXEC",
- "FTEREAD",
- "FTEWRITE",
- "FTEEXEC",
- "FTIS",
- "FTEOWNED",
- "FTROWNED",
- "FTZERO",
- "FTSIZE",
- "FTMTIME",
- "FTATIME",
- "FTCTIME",
- "FTSOCK",
- "FTCHR",
- "FTBLK",
- "FTFILE",
- "FTDIR",
- "FTPIPE",
- "FTLINK",
- "SYMLINK",
- "READLINK",
- "FTSUID",
- "FTSGID",
- "FTSVTX",
- "FTTTY",
- "FTTEXT",
- "FTBINARY",
- "SOCKET",
- "BIND",
- "CONNECT",
- "LISTEN",
- "ACCEPT",
- "GHBYNAME",
- "GHBYADDR",
- "GHOSTENT",
- "GNBYNAME",
- "GNBYADDR",
- "GNETENT",
- "GPBYNAME",
- "GPBYNUMBER",
- "GPROTOENT",
- "GSBYNAME",
- "GSBYPORT",
- "GSERVENT",
- "SHOSTENT",
- "SNETENT",
- "SPROTOENT",
- "SSERVENT",
- "EHOSTENT",
- "ENETENT",
- "EPROTOENT",
- "ESERVENT",
- "SOCKPAIR",
- "SHUTDOWN",
- "GSOCKOPT",
- "SSOCKOPT",
- "GETSOCKNAME",
- "GETPEERNAME",
- "SSELECT",
- "FILENO",
- "BINMODE",
- "VEC",
- "GPWNAM",
- "GPWUID",
- "GPWENT",
- "SPWENT",
- "EPWENT",
- "GGRNAM",
- "GGRGID",
- "GGRENT",
- "SGRENT",
- "EGRENT",
- "GETLOGIN",
- "OPENDIR",
- "READDIR",
- "TELLDIR",
- "SEEKDIR",
- "REWINDDIR",
- "CLOSEDIR",
- "SYSCALL",
- "PIPE",
- "TRY",
- "EVALONCE",
- "269"
-};
-#endif
-
-#define A_NULL 0
-#define A_EXPR 1
-#define A_CMD 2
-#define A_STAB 3
-#define A_LVAL 4
-#define A_SINGLE 5
-#define A_DOUBLE 6
-#define A_BACKTICK 7
-#define A_READ 8
-#define A_SPAT 9
-#define A_LEXPR 10
-#define A_ARYLEN 11
-#define A_ARYSTAB 12
-#define A_LARYLEN 13
-#define A_GLOB 14
-#define A_WORD 15
-#define A_INDREAD 16
-#define A_LARYSTAB 17
-#define A_STAR 18
-#define A_LSTAR 19
-#define A_WANTARRAY 20
-#define A_LENSTAB 21
-
-#define A_MASK 31
-#define A_DONT 32 /* or this into type to suppress evaluation */
-
-#ifndef DOINIT
-extern char *argname[];
-#else
-char *argname[] = {
- "A_NULL",
- "EXPR",
- "CMD",
- "STAB",
- "LVAL",
- "LITERAL",
- "DOUBLEQUOTE",
- "BACKTICK",
- "READ",
- "SPAT",
- "LEXPR",
- "ARYLEN",
- "ARYSTAB",
- "LARYLEN",
- "GLOB",
- "WORD",
- "INDREAD",
- "LARYSTAB",
- "STAR",
- "LSTAR",
- "WANTARRAY",
- "LENSTAB",
- "22"
-};
-#endif
-
-#ifndef DOINIT
-extern bool hoistable[];
-#else
-bool hoistable[] =
- {0, /* A_NULL */
- 0, /* EXPR */
- 1, /* CMD */
- 1, /* STAB */
- 0, /* LVAL */
- 1, /* SINGLE */
- 0, /* DOUBLE */
- 0, /* BACKTICK */
- 0, /* READ */
- 0, /* SPAT */
- 0, /* LEXPR */
- 1, /* ARYLEN */
- 1, /* ARYSTAB */
- 0, /* LARYLEN */
- 0, /* GLOB */
- 1, /* WORD */
- 0, /* INDREAD */
- 0, /* LARYSTAB */
- 1, /* STAR */
- 1, /* LSTAR */
- 1, /* WANTARRAY */
- 0, /* LENSTAB */
- 0, /* 21 */
-};
-#endif
-
-union argptr {
- ARG *arg_arg;
- char *arg_cval;
- STAB *arg_stab;
- SPAT *arg_spat;
- CMD *arg_cmd;
- STR *arg_str;
- HASH *arg_hash;
-};
-
-struct arg {
- union argptr arg_ptr;
- short arg_len;
- unsigned short arg_type;
- unsigned short arg_flags;
-};
-
-#define AF_ARYOK 1 /* op can handle multiple values here */
-#define AF_POST 2 /* post *crement this item */
-#define AF_PRE 4 /* pre *crement this item */
-#define AF_UP 8 /* increment rather than decrement */
-#define AF_COMMON 16 /* left and right have symbols in common */
-#define AF_DEPR 32 /* an older form of the construct */
-#define AF_LISTISH 64 /* turn into list if important */
-#define AF_LOCAL_XX 128 /* list of local variables */
-
-/*
- * Most of the ARG pointers are used as pointers to arrays of ARG. When
- * so used, the 0th element is special, and represents the operator to
- * use on the list of arguments following. The arg_len in the 0th element
- * gives the maximum argument number, and the arg_str is used to store
- * the return value in a more-or-less static location. Sorry it's not
- * re-entrant (yet), but it sure makes it efficient. The arg_type of the
- * 0th element is an operator (O_*) rather than an argument type (A_*).
- */
-
-#define Nullarg Null(ARG*)
-
-#ifndef DOINIT
-EXT unsigned short opargs[MAXO+1];
-#else
-#define A(e1,e2,e3) (e1+(e2<<2)+(e3<<4))
-#define A5(e1,e2,e3,e4,e5) (e1+(e2<<2)+(e3<<4)+(e4<<6)+(e5<<8))
-unsigned short opargs[MAXO+1] = {
- A(0,0,0), /* NULL */
- A(1,1,0), /* RCAT */
- A(1,0,0), /* ITEM */
- A(1,0,0), /* SCALAR */
- A(0,0,0), /* ITEM2 */
- A(0,0,0), /* ITEM3 */
- A(1,1,0), /* CONCAT */
- A(3,1,0), /* REPEAT */
- A(1,0,0), /* MATCH */
- A(1,0,0), /* NMATCH */
- A(1,0,0), /* SUBST */
- A(1,0,0), /* NSUBST */
- A(1,1,0), /* ASSIGN */
- A(1,0,0), /* LOCAL */
- A(3,3,0), /* AASSIGN */
- A(0,0,0), /* SASSIGN */
- A(3,0,0), /* CHOP */
- A(1,0,0), /* DEFINED */
- A(1,0,0), /* UNDEF */
- A(1,0,0), /* STUDY */
- A(1,1,0), /* POW */
- A(1,1,0), /* MULTIPLY */
- A(1,1,0), /* DIVIDE */
- A(1,1,0), /* MODULO */
- A(1,1,0), /* ADD */
- A(1,1,0), /* SUBTRACT */
- A(1,1,0), /* LEFT_SHIFT */
- A(1,1,0), /* RIGHT_SHIFT */
- A(1,1,0), /* LT */
- A(1,1,0), /* GT */
- A(1,1,0), /* LE */
- A(1,1,0), /* GE */
- A(1,1,0), /* EQ */
- A(1,1,0), /* NE */
- A(1,1,0), /* NCMP */
- A(1,1,0), /* BIT_AND */
- A(1,1,0), /* XOR */
- A(1,1,0), /* BIT_OR */
- A(1,0,0), /* AND */
- A(1,0,0), /* OR */
- A(1,0,0), /* COND_EXPR */
- A(1,1,0), /* COMMA */
- A(1,0,0), /* NEGATE */
- A(1,0,0), /* NOT */
- A(1,0,0), /* COMPLEMENT */
- A(1,0,0), /* SELECT */
- A(1,0,0), /* WRITE */
- A(1,1,1), /* DBMOPEN */
- A(1,0,0), /* DBMCLOSE */
- A(1,1,0), /* OPEN */
- A(1,0,0), /* TRANS */
- A(1,0,0), /* NTRANS */
- A(1,0,0), /* CLOSE */
- A(0,0,0), /* EACH */
- A(0,0,0), /* VALUES */
- A(0,0,0), /* KEYS */
- A(0,0,0), /* LARRAY */
- A(0,0,0), /* ARRAY */
- A(0,1,0), /* AELEM */
- A(0,1,0), /* DELETE */
- A(0,0,0), /* LHASH */
- A(0,0,0), /* HASH */
- A(0,1,0), /* HELEM */
- A(0,1,0), /* LAELEM */
- A(0,1,0), /* LHELEM */
- A(0,3,3), /* LSLICE */
- A(0,3,0), /* ASLICE */
- A(0,3,0), /* HSLICE */
- A(0,3,0), /* LASLICE */
- A(0,3,0), /* LHSLICE */
- A(0,3,1), /* SPLICE */
- A(0,3,0), /* PUSH */
- A(0,0,0), /* POP */
- A(0,0,0), /* SHIFT */
- A(1,1,0), /* UNPACK */
- A(1,0,1), /* SPLIT */
- A(1,0,0), /* LENGTH */
- A(3,0,0), /* SPRINTF */
- A(1,1,1), /* SUBSTR */
- A(1,3,0), /* PACK */
- A(0,3,0), /* GREP */
- A(1,3,0), /* JOIN */
- A(1,1,0), /* SLT */
- A(1,1,0), /* SGT */
- A(1,1,0), /* SLE */
- A(1,1,0), /* SGE */
- A(1,1,0), /* SEQ */
- A(1,1,0), /* SNE */
- A(1,1,0), /* SCMP */
- A(0,3,0), /* SUBR */
- A(0,3,0), /* DBSUBR */
- A(1,0,0), /* CALLER */
- A(1,3,0), /* SORT */
- A(0,3,0), /* REVERSE */
- A(0,3,0), /* WARN */
- A(0,3,0), /* DIE */
- A(1,3,0), /* PRINTF */
- A(1,3,0), /* PRINT */
- A(1,0,0), /* CHDIR */
- A(1,0,0), /* EXIT */
- A(1,0,0), /* RESET */
- A(3,0,0), /* LIST */
- A(1,0,0), /* EOF */
- A(1,0,0), /* GETC */
- A(1,0,0), /* TELL */
- A5(1,1,1,1,0), /* RECV */
- A(1,1,3), /* READ */
- A(1,1,3), /* SYSREAD */
- A(1,1,3), /* SYSWRITE */
- A(1,1,3), /* SEND */
- A(1,1,1), /* SEEK */
- A(0,3,0), /* RETURN */
- A(0,0,0), /* REDO */
- A(0,0,0), /* NEXT */
- A(0,0,0), /* LAST */
- A(0,0,0), /* DUMP */
- A(0,0,0), /* GOTO */
- A(1,1,1), /* INDEX */
- A(1,1,1), /* RINDEX */
- A(0,0,0), /* TIME */
- A(0,0,0), /* TIMES */
- A(1,0,0), /* LOCALTIME */
- A(1,0,0), /* GMTIME */
- A(1,1,0), /* TRUNCATE */
- A(1,0,0), /* LSTAT */
- A(1,0,0), /* STAT */
- A(1,1,0), /* CRYPT */
- A(1,1,0), /* ATAN2 */
- A(1,0,0), /* SIN */
- A(1,0,0), /* COS */
- A(1,0,0), /* RAND */
- A(1,0,0), /* SRAND */
- A(1,0,0), /* EXP */
- A(1,0,0), /* LOG */
- A(1,0,0), /* SQRT */
- A(1,0,0), /* INT */
- A(1,0,0), /* ORD */
- A(1,0,0), /* ALARM */
- A(1,0,0), /* SLEEP */
- A(1,1,0), /* RANGE */
- A(1,0,0), /* F_OR_R */
- A(1,0,0), /* FLIP */
- A(0,1,0), /* FLOP */
- A(0,0,0), /* FORK */
- A(0,0,0), /* WAIT */
- A(1,1,0), /* WAITPID */
- A(1,3,0), /* SYSTEM */
- A(1,3,0), /* EXEC */
- A(1,0,0), /* HEX */
- A(1,0,0), /* OCT */
- A(0,3,0), /* CHOWN */
- A(0,3,0), /* KILL */
- A(0,3,0), /* UNLINK */
- A(0,3,0), /* CHMOD */
- A(0,3,0), /* UTIME */
- A(1,0,0), /* UMASK */
- A(1,1,0), /* MSGGET */
- A(1,1,1), /* SHMGET */
- A(1,1,1), /* SEMGET */
- A(1,1,1), /* MSGCTL */
- A(1,1,1), /* SHMCTL */
- A5(1,1,1,1,0), /* SEMCTL */
- A(1,1,1), /* MSGSND */
- A5(1,1,1,1,1), /* MSGRCV */
- A(1,1,1), /* SEMOP */
- A5(1,1,1,1,0), /* SHMREAD */
- A5(1,1,1,1,0), /* SHMWRITE */
- A(1,1,0), /* RENAME */
- A(1,1,0), /* LINK */
- A(1,1,0), /* MKDIR */
- A(1,0,0), /* RMDIR */
- A(0,0,0), /* GETPPID */
- A(1,0,0), /* GETPGRP */
- A(1,1,0), /* SETPGRP */
- A(1,1,0), /* GETPRIORITY */
- A(1,1,1), /* SETPRIORITY */
- A(1,0,0), /* CHROOT */
- A(1,1,1), /* FCNTL */
- A(1,1,1), /* SYSIOCTL */
- A(1,1,0), /* FLOCK */
- A(0,3,0), /* UNSHIFT */
- A(1,0,0), /* REQUIRE */
- A(1,0,0), /* DOFILE */
- A(1,0,0), /* EVAL */
- A(1,0,0), /* FTRREAD */
- A(1,0,0), /* FTRWRITE */
- A(1,0,0), /* FTREXEC */
- A(1,0,0), /* FTEREAD */
- A(1,0,0), /* FTEWRITE */
- A(1,0,0), /* FTEEXEC */
- A(1,0,0), /* FTIS */
- A(1,0,0), /* FTEOWNED */
- A(1,0,0), /* FTROWNED */
- A(1,0,0), /* FTZERO */
- A(1,0,0), /* FTSIZE */
- A(1,0,0), /* FTMTIME */
- A(1,0,0), /* FTATIME */
- A(1,0,0), /* FTCTIME */
- A(1,0,0), /* FTSOCK */
- A(1,0,0), /* FTCHR */
- A(1,0,0), /* FTBLK */
- A(1,0,0), /* FTFILE */
- A(1,0,0), /* FTDIR */
- A(1,0,0), /* FTPIPE */
- A(1,0,0), /* FTLINK */
- A(1,1,0), /* SYMLINK */
- A(1,0,0), /* READLINK */
- A(1,0,0), /* FTSUID */
- A(1,0,0), /* FTSGID */
- A(1,0,0), /* FTSVTX */
- A(1,0,0), /* FTTTY */
- A(1,0,0), /* FTTEXT */
- A(1,0,0), /* FTBINARY */
- A5(1,1,1,1,0), /* SOCKET */
- A(1,1,0), /* BIND */
- A(1,1,0), /* CONNECT */
- A(1,1,0), /* LISTEN */
- A(1,1,0), /* ACCEPT */
- A(1,0,0), /* GHBYNAME */
- A(1,1,0), /* GHBYADDR */
- A(0,0,0), /* GHOSTENT */
- A(1,0,0), /* GNBYNAME */
- A(1,1,0), /* GNBYADDR */
- A(0,0,0), /* GNETENT */
- A(1,0,0), /* GPBYNAME */
- A(1,0,0), /* GPBYNUMBER */
- A(0,0,0), /* GPROTOENT */
- A(1,1,0), /* GSBYNAME */
- A(1,1,0), /* GSBYPORT */
- A(0,0,0), /* GSERVENT */
- A(1,0,0), /* SHOSTENT */
- A(1,0,0), /* SNETENT */
- A(1,0,0), /* SPROTOENT */
- A(1,0,0), /* SSERVENT */
- A(0,0,0), /* EHOSTENT */
- A(0,0,0), /* ENETENT */
- A(0,0,0), /* EPROTOENT */
- A(0,0,0), /* ESERVENT */
- A5(1,1,1,1,1), /* SOCKPAIR */
- A(1,1,0), /* SHUTDOWN */
- A(1,1,1), /* GSOCKOPT */
- A5(1,1,1,1,0), /* SSOCKOPT */
- A(1,0,0), /* GETSOCKNAME */
- A(1,0,0), /* GETPEERNAME */
- A5(1,1,1,1,0), /* SSELECT */
- A(1,0,0), /* FILENO */
- A(1,0,0), /* BINMODE */
- A(1,1,1), /* VEC */
- A(1,0,0), /* GPWNAM */
- A(1,0,0), /* GPWUID */
- A(0,0,0), /* GPWENT */
- A(0,0,0), /* SPWENT */
- A(0,0,0), /* EPWENT */
- A(1,0,0), /* GGRNAM */
- A(1,0,0), /* GGRGID */
- A(0,0,0), /* GGRENT */
- A(0,0,0), /* SGRENT */
- A(0,0,0), /* EGRENT */
- A(0,0,0), /* GETLOGIN */
- A(1,1,0), /* OPENDIR */
- A(1,0,0), /* READDIR */
- A(1,0,0), /* TELLDIR */
- A(1,1,0), /* SEEKDIR */
- A(1,0,0), /* REWINDDIR */
- A(1,0,0), /* CLOSEDIR */
- A(1,3,0), /* SYSCALL */
- A(1,1,0), /* PIPE */
- A(0,0,0), /* TRY */
- A(1,0,0), /* EVALONCE */
- 0
-};
-#undef A
-#undef A5
-#endif
-
-int do_trans();
-int do_split();
-bool do_eof();
-long do_tell();
-bool do_seek();
-int do_tms();
-int do_time();
-int do_stat();
-STR *do_push();
-FILE *nextargv();
-STR *do_fttext();
-int do_slice();
diff --git a/gnu/usr.bin/perl/perl/array.c b/gnu/usr.bin/perl/perl/array.c
deleted file mode 100644
index a413e3b..0000000
--- a/gnu/usr.bin/perl/perl/array.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/* $RCSfile: array.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:31 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: array.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:31 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:34 nate
- * PERL!
- *
- * Revision 4.0.1.3 92/06/08 11:45:05 lwall
- * patch20: Perl now distinguishes overlapped copies from non-overlapped
- *
- * Revision 4.0.1.2 91/11/05 16:00:14 lwall
- * patch11: random cleanup
- * patch11: passing non-existend array elements to subrouting caused core dump
- *
- * Revision 4.0.1.1 91/06/07 10:19:08 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:03:32 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-STR *
-afetch(ar,key,lval)
-register ARRAY *ar;
-int key;
-int lval;
-{
- STR *str;
-
- if (key < 0 || key > ar->ary_fill) {
- if (lval && key >= 0) {
- if (ar->ary_flags & ARF_REAL)
- str = Str_new(5,0);
- else
- str = str_mortal(&str_undef);
- (void)astore(ar,key,str);
- return str;
- }
- else
- return &str_undef;
- }
- if (!ar->ary_array[key]) {
- if (lval) {
- str = Str_new(6,0);
- (void)astore(ar,key,str);
- return str;
- }
- return &str_undef;
- }
- return ar->ary_array[key];
-}
-
-bool
-astore(ar,key,val)
-register ARRAY *ar;
-int key;
-STR *val;
-{
- int retval;
-
- if (key < 0)
- return FALSE;
- if (key > ar->ary_max) {
- int newmax;
-
- if (ar->ary_alloc != ar->ary_array) {
- retval = ar->ary_array - ar->ary_alloc;
- Move(ar->ary_array, ar->ary_alloc, ar->ary_max+1, STR*);
- Zero(ar->ary_alloc+ar->ary_max+1, retval, STR*);
- ar->ary_max += retval;
- ar->ary_array -= retval;
- if (key > ar->ary_max - 10) {
- newmax = key + ar->ary_max;
- goto resize;
- }
- }
- else {
- if (ar->ary_alloc) {
- newmax = key + ar->ary_max / 5;
- resize:
- Renew(ar->ary_alloc,newmax+1, STR*);
- Zero(&ar->ary_alloc[ar->ary_max+1], newmax - ar->ary_max, STR*);
- }
- else {
- newmax = key < 4 ? 4 : key;
- Newz(2,ar->ary_alloc, newmax+1, STR*);
- }
- ar->ary_array = ar->ary_alloc;
- ar->ary_max = newmax;
- }
- }
- if (ar->ary_flags & ARF_REAL) {
- if (ar->ary_fill < key) {
- while (++ar->ary_fill < key) {
- if (ar->ary_array[ar->ary_fill] != Nullstr) {
- str_free(ar->ary_array[ar->ary_fill]);
- ar->ary_array[ar->ary_fill] = Nullstr;
- }
- }
- }
- retval = (ar->ary_array[key] != Nullstr);
- if (retval)
- str_free(ar->ary_array[key]);
- }
- else
- retval = 0;
- ar->ary_array[key] = val;
- return retval;
-}
-
-ARRAY *
-anew(stab)
-STAB *stab;
-{
- register ARRAY *ar;
-
- New(1,ar,1,ARRAY);
- ar->ary_magic = Str_new(7,0);
- ar->ary_alloc = ar->ary_array = 0;
- str_magic(ar->ary_magic, stab, '#', Nullch, 0);
- ar->ary_max = ar->ary_fill = -1;
- ar->ary_flags = ARF_REAL;
- return ar;
-}
-
-ARRAY *
-afake(stab,size,strp)
-STAB *stab;
-register int size;
-register STR **strp;
-{
- register ARRAY *ar;
-
- New(3,ar,1,ARRAY);
- New(4,ar->ary_alloc,size+1,STR*);
- Copy(strp,ar->ary_alloc,size,STR*);
- ar->ary_array = ar->ary_alloc;
- ar->ary_magic = Str_new(8,0);
- str_magic(ar->ary_magic, stab, '#', Nullch, 0);
- ar->ary_fill = size - 1;
- ar->ary_max = size - 1;
- ar->ary_flags = 0;
- while (size--) {
- if (*strp)
- (*strp)->str_pok &= ~SP_TEMP;
- strp++;
- }
- return ar;
-}
-
-void
-aclear(ar)
-register ARRAY *ar;
-{
- register int key;
-
- if (!ar || !(ar->ary_flags & ARF_REAL) || ar->ary_max < 0)
- return;
- /*SUPPRESS 560*/
- if (key = ar->ary_array - ar->ary_alloc) {
- ar->ary_max += key;
- ar->ary_array -= key;
- }
- for (key = 0; key <= ar->ary_max; key++)
- str_free(ar->ary_array[key]);
- ar->ary_fill = -1;
- Zero(ar->ary_array, ar->ary_max+1, STR*);
-}
-
-void
-afree(ar)
-register ARRAY *ar;
-{
- register int key;
-
- if (!ar)
- return;
- /*SUPPRESS 560*/
- if (key = ar->ary_array - ar->ary_alloc) {
- ar->ary_max += key;
- ar->ary_array -= key;
- }
- if (ar->ary_flags & ARF_REAL) {
- for (key = 0; key <= ar->ary_max; key++)
- str_free(ar->ary_array[key]);
- }
- str_free(ar->ary_magic);
- Safefree(ar->ary_alloc);
- Safefree(ar);
-}
-
-bool
-apush(ar,val)
-register ARRAY *ar;
-STR *val;
-{
- return astore(ar,++(ar->ary_fill),val);
-}
-
-STR *
-apop(ar)
-register ARRAY *ar;
-{
- STR *retval;
-
- if (ar->ary_fill < 0)
- return Nullstr;
- retval = ar->ary_array[ar->ary_fill];
- ar->ary_array[ar->ary_fill--] = Nullstr;
- return retval;
-}
-
-void
-aunshift(ar,num)
-register ARRAY *ar;
-register int num;
-{
- register int i;
- register STR **sstr,**dstr;
-
- if (num <= 0)
- return;
- if (ar->ary_array - ar->ary_alloc >= num) {
- ar->ary_max += num;
- ar->ary_fill += num;
- while (num--)
- *--ar->ary_array = Nullstr;
- }
- else {
- (void)astore(ar,ar->ary_fill+num,(STR*)0); /* maybe extend array */
- dstr = ar->ary_array + ar->ary_fill;
- sstr = dstr - num;
-#ifdef BUGGY_MSC5
- # pragma loop_opt(off) /* don't loop-optimize the following code */
-#endif /* BUGGY_MSC5 */
- for (i = ar->ary_fill - num; i >= 0; i--) {
- *dstr-- = *sstr--;
-#ifdef BUGGY_MSC5
- # pragma loop_opt() /* loop-optimization back to command-line setting */
-#endif /* BUGGY_MSC5 */
- }
- Zero(ar->ary_array, num, STR*);
- }
-}
-
-STR *
-ashift(ar)
-register ARRAY *ar;
-{
- STR *retval;
-
- if (ar->ary_fill < 0)
- return Nullstr;
- retval = *ar->ary_array;
- *(ar->ary_array++) = Nullstr;
- ar->ary_max--;
- ar->ary_fill--;
- return retval;
-}
-
-int
-alen(ar)
-register ARRAY *ar;
-{
- return ar->ary_fill;
-}
-
-void
-afill(ar, fill)
-register ARRAY *ar;
-int fill;
-{
- if (fill < 0)
- fill = -1;
- if (fill <= ar->ary_max)
- ar->ary_fill = fill;
- else
- (void)astore(ar,fill,Nullstr);
-}
diff --git a/gnu/usr.bin/perl/perl/array.h b/gnu/usr.bin/perl/perl/array.h
deleted file mode 100644
index 9b2207b..0000000
--- a/gnu/usr.bin/perl/perl/array.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $RCSfile: array.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:34 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: array.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:34 nate
- * PERL!
- *
- * Revision 4.0.1.2 92/06/08 11:45:57 lwall
- * patch20: removed implicit int declarations on funcions
- *
- * Revision 4.0.1.1 91/06/07 10:19:20 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:03:44 lwall
- * 4.0 baseline.
- *
- */
-
-struct atbl {
- STR **ary_array;
- STR **ary_alloc;
- STR *ary_magic;
- int ary_max;
- int ary_fill;
- char ary_flags;
-};
-
-#define ARF_REAL 1 /* free old entries */
-
-STR *afetch();
-bool astore();
-STR *apop();
-STR *ashift();
-void afree();
-void aclear();
-bool apush();
-int alen();
-ARRAY *anew();
-ARRAY *afake();
-void aunshift();
-void afill();
diff --git a/gnu/usr.bin/perl/perl/cflags b/gnu/usr.bin/perl/perl/cflags
deleted file mode 100755
index 672dfc6..0000000
--- a/gnu/usr.bin/perl/perl/cflags
+++ /dev/null
@@ -1,91 +0,0 @@
-case "$0" in
-*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
-esac
-case $CONFIG in
-'')
- if test ! -f config.sh; then
- ln ../config.sh . || \
- ln ../../config.sh . || \
- ln ../../../config.sh . || \
- (echo "Can't find config.sh."; exit 1)
- fi 2>/dev/null
- . ./config.sh
- ;;
-esac
-
-also=': '
-case $# in
-1) also='echo 1>&2 " CCCMD = "'
-esac
-
-case $# in
-0) set *.c; echo "The current C flags are:" ;;
-esac
-
-set `echo "$* " | sed 's/\.[oc] / /g'`
-
-for file do
-
- case "$#" in
- 1) ;;
- *) echo $n " $file.c $c" ;;
- esac
-
- : allow variables like toke_cflags to be evaluated
-
- eval 'eval ${'"${file}_cflags"'-""}'
-
- : or customize here
-
- case "$file" in
- array) ;;
- cmd) ;;
- cons) ;;
- consarg) ;;
- doarg) ;;
- doio) ;;
- dolist) ;;
- dump) ;;
- eval) ;;
- form) ;;
- hash) ;;
- malloc) ;;
- perl) ;;
- perly) ;;
- regcomp) ;;
- regexec) ;;
- stab) ;;
- str) ;;
- toke) ;;
- usersub) ;;
- util) ;;
- tarray) ;;
- tcmd) ;;
- tcons) ;;
- tconsarg) ;;
- tdoarg) ;;
- tdoio) ;;
- tdolist) ;;
- tdump) ;;
- teval) ;;
- tform) ;;
- thash) ;;
- tmalloc) ;;
- tperl) ;;
- tperly) ;;
- tregcomp) ;;
- tregexec) ;;
- tstab) ;;
- tstr) ;;
- ttoke) ;;
- tusersub) ;;
- tutil) ;;
- *) ;;
- esac
-
- echo "$cc -c $ccflags $optimize $large $split"
- eval "$also "'"$cc -c $ccflags $optimize $large $split"'
-
- . ./config.sh
-
-done
diff --git a/gnu/usr.bin/perl/perl/cmd.c b/gnu/usr.bin/perl/perl/cmd.c
deleted file mode 100644
index 162926d..0000000
--- a/gnu/usr.bin/perl/perl/cmd.c
+++ /dev/null
@@ -1,1266 +0,0 @@
-/* $RCSfile: cmd.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:32 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: cmd.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:32 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:35 nate
- * PERL!
- *
- * Revision 4.0.1.5 92/06/08 12:00:39 lwall
- * patch20: the switch optimizer didn't do anything in subroutines
- * patch20: removed implicit int declarations on funcions
- *
- * Revision 4.0.1.4 91/11/11 16:29:33 lwall
- * patch19: do {$foo ne "bar";} returned wrong value
- * patch19: some earlier patches weren't propagated to alternate 286 code
- *
- * Revision 4.0.1.3 91/11/05 16:07:43 lwall
- * patch11: random cleanup
- * patch11: "foo\0" eq "foo" was sometimes optimized to true
- * patch11: foreach on null list could spring memory leak
- *
- * Revision 4.0.1.2 91/06/07 10:26:45 lwall
- * patch4: new copyright notice
- * patch4: made some allowances for "semi-standard" C
- *
- * Revision 4.0.1.1 91/04/11 17:36:16 lwall
- * patch1: you may now use "die" and "caller" in a signal handler
- *
- * Revision 4.0 91/03/20 01:04:18 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-#ifdef I_VARARGS
-# include <varargs.h>
-#endif
-
-static STR strchop;
-
-void grow_dlevel();
-
-/* do longjmps() clobber register variables? */
-
-#if defined(cray) || defined(STANDARD_C)
-#define JMPCLOBBER
-#endif
-
-/* This is the main command loop. We try to spend as much time in this loop
- * as possible, so lots of optimizations do their activities in here. This
- * means things get a little sloppy.
- */
-
-int
-cmd_exec(cmdparm,gimme,sp)
-CMD *VOLATILE cmdparm;
-VOLATILE int gimme;
-VOLATILE int sp;
-{
- register CMD *cmd = cmdparm;
- SPAT *VOLATILE oldspat;
- VOLATILE int firstsave = savestack->ary_fill;
- VOLATILE int oldsave;
- VOLATILE int aryoptsave;
-#ifdef DEBUGGING
- VOLATILE int olddlevel;
- VOLATILE int entdlevel;
-#endif
- register STR *retstr = &str_undef;
- register char *tmps;
- register int cmdflags;
- register int match;
- register char *go_to = goto_targ;
- register int newsp = -2;
- register STR **st = stack->ary_array;
- FILE *VOLATILE fp;
- ARRAY *VOLATILE ar;
-
- lastsize = 0;
-#ifdef DEBUGGING
- entdlevel = dlevel;
-#endif
-tail_recursion_entry:
-#ifdef DEBUGGING
- dlevel = entdlevel;
- if (debug & 4)
- deb("mortals = (%d/%d) stack, = (%d/%d)\n",
- tmps_max, tmps_base,
- savestack->ary_fill, firstsave);
-#endif
-#ifdef TAINT
- tainted = 0; /* Each statement is presumed innocent */
-#endif
- if (cmd == Nullcmd) {
- if (gimme == G_ARRAY && newsp > -2)
- return newsp;
- else {
- st[++sp] = retstr;
- return sp;
- }
- }
- cmdflags = cmd->c_flags; /* hopefully load register */
- if (go_to) {
- if (cmd->c_label && strEQ(go_to,cmd->c_label))
- goto_targ = go_to = Nullch; /* here at last */
- else {
- switch (cmd->c_type) {
- case C_IF:
- oldspat = curspat;
- oldsave = savestack->ary_fill;
-#ifdef DEBUGGING
- olddlevel = dlevel;
-#endif
- retstr = &str_yes;
- newsp = -2;
- if (cmd->ucmd.ccmd.cc_true) {
-#ifdef DEBUGGING
- if (debug) {
- debname[dlevel] = 't';
- debdelim[dlevel] = '_';
- if (++dlevel >= dlmax)
- grow_dlevel();
- }
-#endif
- newsp = cmd_exec(cmd->ucmd.ccmd.cc_true,gimme && (cmdflags & CF_TERM),sp);
- st = stack->ary_array; /* possibly reallocated */
- retstr = st[newsp];
- }
- if (!goto_targ)
- go_to = Nullch;
- curspat = oldspat;
- if (savestack->ary_fill > oldsave)
- restorelist(oldsave);
-#ifdef DEBUGGING
- dlevel = olddlevel;
-#endif
- cmd = cmd->ucmd.ccmd.cc_alt;
- goto tail_recursion_entry;
- case C_ELSE:
- oldspat = curspat;
- oldsave = savestack->ary_fill;
-#ifdef DEBUGGING
- olddlevel = dlevel;
-#endif
- retstr = &str_undef;
- newsp = -2;
- if (cmd->ucmd.ccmd.cc_true) {
-#ifdef DEBUGGING
- if (debug) {
- debname[dlevel] = 'e';
- debdelim[dlevel] = '_';
- if (++dlevel >= dlmax)
- grow_dlevel();
- }
-#endif
- newsp = cmd_exec(cmd->ucmd.ccmd.cc_true,gimme && (cmdflags & CF_TERM),sp);
- st = stack->ary_array; /* possibly reallocated */
- retstr = st[newsp];
- }
- if (!goto_targ)
- go_to = Nullch;
- curspat = oldspat;
- if (savestack->ary_fill > oldsave)
- restorelist(oldsave);
-#ifdef DEBUGGING
- dlevel = olddlevel;
-#endif
- break;
- case C_BLOCK:
- case C_WHILE:
- if (!(cmdflags & CF_ONCE)) {
- cmdflags |= CF_ONCE;
- if (++loop_ptr >= loop_max) {
- loop_max += 128;
- Renew(loop_stack, loop_max, struct loop);
- }
- loop_stack[loop_ptr].loop_label = cmd->c_label;
- loop_stack[loop_ptr].loop_sp = sp;
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Pushing label #%d %s)\n",
- loop_ptr, cmd->c_label ? cmd->c_label : "");
- }
-#endif
- }
-#ifdef JMPCLOBBER
- cmdparm = cmd;
-#endif
- match = setjmp(loop_stack[loop_ptr].loop_env);
- if (match) {
- st = stack->ary_array; /* possibly reallocated */
-#ifdef JMPCLOBBER
- cmd = cmdparm;
- cmdflags = cmd->c_flags|CF_ONCE;
-#endif
- if (savestack->ary_fill > oldsave)
- restorelist(oldsave);
- switch (match) {
- default:
- fatal("longjmp returned bad value (%d)",match);
- case O_LAST: /* not done unless go_to found */
- go_to = Nullch;
- if (lastretstr) {
- retstr = lastretstr;
- newsp = -2;
- }
- else {
- newsp = sp + lastsize;
- retstr = st[newsp];
- }
-#ifdef DEBUGGING
- olddlevel = dlevel;
-#endif
- curspat = oldspat;
- goto next_cmd;
- case O_NEXT: /* not done unless go_to found */
- go_to = Nullch;
-#ifdef JMPCLOBBER
- newsp = -2;
- retstr = &str_undef;
-#endif
- goto next_iter;
- case O_REDO: /* not done unless go_to found */
- go_to = Nullch;
-#ifdef JMPCLOBBER
- newsp = -2;
- retstr = &str_undef;
-#endif
- goto doit;
- }
- }
- oldspat = curspat;
- oldsave = savestack->ary_fill;
-#ifdef DEBUGGING
- olddlevel = dlevel;
-#endif
- if (cmd->ucmd.ccmd.cc_true) {
-#ifdef DEBUGGING
- if (debug) {
- debname[dlevel] = 't';
- debdelim[dlevel] = '_';
- if (++dlevel >= dlmax)
- grow_dlevel();
- }
-#endif
- newsp = cmd_exec(cmd->ucmd.ccmd.cc_true,gimme && (cmdflags & CF_TERM),sp);
- st = stack->ary_array; /* possibly reallocated */
- if (newsp >= 0)
- retstr = st[newsp];
- }
- if (!goto_targ) {
- go_to = Nullch;
- goto next_iter;
- }
-#ifdef DEBUGGING
- dlevel = olddlevel;
-#endif
- if (cmd->ucmd.ccmd.cc_alt) {
-#ifdef DEBUGGING
- if (debug) {
- debname[dlevel] = 'a';
- debdelim[dlevel] = '_';
- if (++dlevel >= dlmax)
- grow_dlevel();
- }
-#endif
- newsp = cmd_exec(cmd->ucmd.ccmd.cc_alt,gimme && (cmdflags & CF_TERM),sp);
- st = stack->ary_array; /* possibly reallocated */
- if (newsp >= 0)
- retstr = st[newsp];
- }
- if (goto_targ)
- break;
- go_to = Nullch;
- goto finish_while;
- }
- cmd = cmd->c_next;
- if (cmd && cmd->c_head == cmd)
- /* reached end of while loop */
- return sp; /* targ isn't in this block */
- if (cmdflags & CF_ONCE) {
-#ifdef DEBUGGING
- if (debug & 4) {
- tmps = loop_stack[loop_ptr].loop_label;
- deb("(Popping label #%d %s)\n",loop_ptr,
- tmps ? tmps : "" );
- }
-#endif
- loop_ptr--;
- }
- goto tail_recursion_entry;
- }
- }
-
-until_loop:
-
- /* Set line number so run-time errors can be located */
-
- curcmd = cmd;
-
-#ifdef DEBUGGING
- if (debug) {
- if (debug & 2) {
- deb("%s (%lx) r%lx t%lx a%lx n%lx cs%lx\n",
- cmdname[cmd->c_type],cmd,cmd->c_expr,
- cmd->ucmd.ccmd.cc_true,cmd->ucmd.ccmd.cc_alt,cmd->c_next,
- curspat);
- }
- debname[dlevel] = cmdname[cmd->c_type][0];
- debdelim[dlevel] = '!';
- if (++dlevel >= dlmax)
- grow_dlevel();
- }
-#endif
-
- /* Here is some common optimization */
-
- if (cmdflags & CF_COND) {
- switch (cmdflags & CF_OPTIMIZE) {
-
- case CFT_FALSE:
- retstr = cmd->c_short;
- newsp = -2;
- match = FALSE;
- if (cmdflags & CF_NESURE)
- goto maybe;
- break;
- case CFT_TRUE:
- retstr = cmd->c_short;
- newsp = -2;
- match = TRUE;
- if (cmdflags & CF_EQSURE)
- goto flipmaybe;
- break;
-
- case CFT_REG:
- retstr = STAB_STR(cmd->c_stab);
- newsp = -2;
- match = str_true(retstr); /* => retstr = retstr, c2 should fix */
- if (cmdflags & (match ? CF_EQSURE : CF_NESURE))
- goto flipmaybe;
- break;
-
- case CFT_ANCHOR: /* /^pat/ optimization */
- if (multiline) {
- if (*cmd->c_short->str_ptr && !(cmdflags & CF_EQSURE))
- goto scanner; /* just unanchor it */
- else
- break; /* must evaluate */
- }
- match = 0;
- goto strop;
-
- case CFT_STROP: /* string op optimization */
- match = 1;
- strop:
- retstr = STAB_STR(cmd->c_stab);
- newsp = -2;
-#ifndef I286
- if (*cmd->c_short->str_ptr == *str_get(retstr) &&
- (match ? retstr->str_cur == cmd->c_slen - 1 :
- retstr->str_cur >= cmd->c_slen) &&
- bcmp(cmd->c_short->str_ptr, str_get(retstr),
- cmd->c_slen) == 0 ) {
- if (cmdflags & CF_EQSURE) {
- if (sawampersand && (cmdflags & CF_OPTIMIZE) != CFT_STROP) {
- curspat = Nullspat;
- if (leftstab)
- str_nset(stab_val(leftstab),"",0);
- if (amperstab)
- str_sset(stab_val(amperstab),cmd->c_short);
- if (rightstab)
- str_nset(stab_val(rightstab),
- retstr->str_ptr + cmd->c_slen,
- retstr->str_cur - cmd->c_slen);
- }
- if (cmd->c_spat)
- lastspat = cmd->c_spat;
- match = !(cmdflags & CF_FIRSTNEG);
- retstr = match ? &str_yes : &str_no;
- goto flipmaybe;
- }
- }
- else if (cmdflags & CF_NESURE) {
- match = cmdflags & CF_FIRSTNEG;
- retstr = match ? &str_yes : &str_no;
- goto flipmaybe;
- }
-#else
- {
- char *zap1, *zap2, zap1c, zap2c;
- int zaplen;
- int lenok;
-
- zap1 = cmd->c_short->str_ptr;
- zap2 = str_get(retstr);
- zap1c = *zap1;
- zap2c = *zap2;
- zaplen = cmd->c_slen;
- if (match)
- lenok = (retstr->str_cur == cmd->c_slen - 1);
- else
- lenok = (retstr->str_cur >= cmd->c_slen);
- if ((zap1c == zap2c) && lenok && (bcmp(zap1, zap2, zaplen) == 0)) {
- if (cmdflags & CF_EQSURE) {
- if (sawampersand &&
- (cmdflags & CF_OPTIMIZE) != CFT_STROP) {
- curspat = Nullspat;
- if (leftstab)
- str_nset(stab_val(leftstab),"",0);
- if (amperstab)
- str_sset(stab_val(amperstab),cmd->c_short);
- if (rightstab)
- str_nset(stab_val(rightstab),
- retstr->str_ptr + cmd->c_slen,
- retstr->str_cur - cmd->c_slen);
- }
- if (cmd->c_spat)
- lastspat = cmd->c_spat;
- match = !(cmdflags & CF_FIRSTNEG);
- retstr = match ? &str_yes : &str_no;
- goto flipmaybe;
- }
- }
- else if (cmdflags & CF_NESURE) {
- match = cmdflags & CF_FIRSTNEG;
- retstr = match ? &str_yes : &str_no;
- goto flipmaybe;
- }
- }
-#endif
- break; /* must evaluate */
-
- case CFT_SCAN: /* non-anchored search */
- scanner:
- retstr = STAB_STR(cmd->c_stab);
- newsp = -2;
- if (retstr->str_pok & SP_STUDIED)
- if (screamfirst[cmd->c_short->str_rare] >= 0)
- tmps = screaminstr(retstr, cmd->c_short);
- else
- tmps = Nullch;
- else {
- tmps = str_get(retstr); /* make sure it's pok */
-#ifndef lint
- tmps = fbminstr((unsigned char*)tmps,
- (unsigned char*)tmps + retstr->str_cur, cmd->c_short);
-#endif
- }
- if (tmps) {
- if (cmdflags & CF_EQSURE) {
- ++cmd->c_short->str_u.str_useful;
- if (sawampersand) {
- curspat = Nullspat;
- if (leftstab)
- str_nset(stab_val(leftstab),retstr->str_ptr,
- tmps - retstr->str_ptr);
- if (amperstab)
- str_nset(stab_val(amperstab),
- tmps, cmd->c_short->str_cur);
- if (rightstab)
- str_nset(stab_val(rightstab),
- tmps + cmd->c_short->str_cur,
- retstr->str_cur - (tmps - retstr->str_ptr) -
- cmd->c_short->str_cur);
- }
- lastspat = cmd->c_spat;
- match = !(cmdflags & CF_FIRSTNEG);
- retstr = match ? &str_yes : &str_no;
- goto flipmaybe;
- }
- else
- hint = tmps;
- }
- else {
- if (cmdflags & CF_NESURE) {
- ++cmd->c_short->str_u.str_useful;
- match = cmdflags & CF_FIRSTNEG;
- retstr = match ? &str_yes : &str_no;
- goto flipmaybe;
- }
- }
- if (--cmd->c_short->str_u.str_useful < 0) {
- cmdflags &= ~CF_OPTIMIZE;
- cmdflags |= CFT_EVAL; /* never try this optimization again */
- cmd->c_flags = (cmdflags & ~CF_ONCE);
- }
- break; /* must evaluate */
-
- case CFT_NUMOP: /* numeric op optimization */
- retstr = STAB_STR(cmd->c_stab);
- newsp = -2;
- switch (cmd->c_slen) {
- case O_EQ:
- if (dowarn) {
- if ((!retstr->str_nok && !looks_like_number(retstr)))
- warn("Possible use of == on string value");
- }
- match = (str_gnum(retstr) == cmd->c_short->str_u.str_nval);
- break;
- case O_NE:
- match = (str_gnum(retstr) != cmd->c_short->str_u.str_nval);
- break;
- case O_LT:
- match = (str_gnum(retstr) < cmd->c_short->str_u.str_nval);
- break;
- case O_LE:
- match = (str_gnum(retstr) <= cmd->c_short->str_u.str_nval);
- break;
- case O_GT:
- match = (str_gnum(retstr) > cmd->c_short->str_u.str_nval);
- break;
- case O_GE:
- match = (str_gnum(retstr) >= cmd->c_short->str_u.str_nval);
- break;
- }
- if (match) {
- if (cmdflags & CF_EQSURE) {
- retstr = &str_yes;
- goto flipmaybe;
- }
- }
- else if (cmdflags & CF_NESURE) {
- retstr = &str_no;
- goto flipmaybe;
- }
- break; /* must evaluate */
-
- case CFT_INDGETS: /* while (<$foo>) */
- last_in_stab = stabent(str_get(STAB_STR(cmd->c_stab)),TRUE);
- if (!stab_io(last_in_stab))
- stab_io(last_in_stab) = stio_new();
- goto dogets;
- case CFT_GETS: /* really a while (<file>) */
- last_in_stab = cmd->c_stab;
- dogets:
- fp = stab_io(last_in_stab)->ifp;
- retstr = stab_val(defstab);
- newsp = -2;
- keepgoing:
- if (fp && str_gets(retstr, fp, 0)) {
- if (*retstr->str_ptr == '0' && retstr->str_cur == 1)
- match = FALSE;
- else
- match = TRUE;
- stab_io(last_in_stab)->lines++;
- }
- else if (stab_io(last_in_stab)->flags & IOF_ARGV) {
- if (!fp)
- goto doeval; /* first time through */
- fp = nextargv(last_in_stab);
- if (fp)
- goto keepgoing;
- (void)do_close(last_in_stab,FALSE);
- stab_io(last_in_stab)->flags |= IOF_START;
- retstr = &str_undef;
- match = FALSE;
- }
- else {
- retstr = &str_undef;
- match = FALSE;
- }
- goto flipmaybe;
- case CFT_EVAL:
- break;
- case CFT_UNFLIP:
- while (tmps_max > tmps_base) { /* clean up after last eval */
- str_free(tmps_list[tmps_max]);
- tmps_list[tmps_max--] = Nullstr;
- }
- newsp = eval(cmd->c_expr,gimme && (cmdflags & CF_TERM),sp);
- st = stack->ary_array; /* possibly reallocated */
- retstr = st[newsp];
- match = str_true(retstr);
- if (cmd->c_expr->arg_type == O_FLIP) /* undid itself? */
- cmdflags = copyopt(cmd,cmd->c_expr[3].arg_ptr.arg_cmd);
- goto maybe;
- case CFT_CHOP:
- retstr = stab_val(cmd->c_stab);
- newsp = -2;
- match = (retstr->str_cur != 0);
- tmps = str_get(retstr);
- tmps += retstr->str_cur - match;
- str_nset(&strchop,tmps,match);
- *tmps = '\0';
- retstr->str_nok = 0;
- retstr->str_cur = tmps - retstr->str_ptr;
- STABSET(retstr);
- retstr = &strchop;
- goto flipmaybe;
- case CFT_ARRAY:
- match = cmd->c_short->str_u.str_useful; /* just to get register */
-
- if (match < 0) { /* first time through here? */
- ar = stab_array(cmd->c_expr[1].arg_ptr.arg_stab);
- aryoptsave = savestack->ary_fill;
- savesptr(&stab_val(cmd->c_stab));
- savelong(&cmd->c_short->str_u.str_useful);
- }
- else {
- ar = stab_xarray(cmd->c_expr[1].arg_ptr.arg_stab);
- if (cmd->c_type != C_WHILE && savestack->ary_fill > firstsave)
- restorelist(firstsave);
- }
-
- if (match >= ar->ary_fill) { /* we're in LAST, probably */
- if (match < 0 && /* er, probably not... */
- savestack->ary_fill > aryoptsave)
- restorelist(aryoptsave);
- retstr = &str_undef;
- cmd->c_short->str_u.str_useful = -1; /* actually redundant */
- match = FALSE;
- }
- else {
- match++;
- if (!(retstr = ar->ary_array[match]))
- retstr = afetch(ar,match,TRUE);
- stab_val(cmd->c_stab) = retstr;
- cmd->c_short->str_u.str_useful = match;
- match = TRUE;
- }
- newsp = -2;
- goto maybe;
- case CFT_D1:
- break;
- case CFT_D0:
- if (DBsingle->str_u.str_nval != 0)
- break;
- if (DBsignal->str_u.str_nval != 0)
- break;
- if (DBtrace->str_u.str_nval != 0)
- break;
- goto next_cmd;
- }
-
- /* we have tried to make this normal case as abnormal as possible */
-
- doeval:
- if (gimme == G_ARRAY) {
- lastretstr = Nullstr;
- lastspbase = sp;
- lastsize = newsp - sp;
- if (lastsize < 0)
- lastsize = 0;
- }
- else
- lastretstr = retstr;
- while (tmps_max > tmps_base) { /* clean up after last eval */
- str_free(tmps_list[tmps_max]);
- tmps_list[tmps_max--] = Nullstr;
- }
- newsp = eval(cmd->c_expr,
- gimme && (cmdflags & CF_TERM) && cmd->c_type == C_EXPR &&
- !cmd->ucmd.acmd.ac_expr,
- sp);
- st = stack->ary_array; /* possibly reallocated */
- retstr = st[newsp];
- if (newsp > sp && retstr)
- match = str_true(retstr);
- else
- match = FALSE;
- goto maybe;
-
- /* if flipflop was true, flop it */
-
- flipmaybe:
- if (match && cmdflags & CF_FLIP) {
- while (tmps_max > tmps_base) { /* clean up after last eval */
- str_free(tmps_list[tmps_max]);
- tmps_list[tmps_max--] = Nullstr;
- }
- if (cmd->c_expr->arg_type == O_FLOP) { /* currently toggled? */
- newsp = eval(cmd->c_expr,G_SCALAR,sp);/*let eval undo it*/
- cmdflags = copyopt(cmd,cmd->c_expr[3].arg_ptr.arg_cmd);
- }
- else {
- newsp = eval(cmd->c_expr,G_SCALAR,sp);/* let eval do it */
- if (cmd->c_expr->arg_type == O_FLOP) /* still toggled? */
- cmdflags = copyopt(cmd,cmd->c_expr[4].arg_ptr.arg_cmd);
- }
- }
- else if (cmdflags & CF_FLIP) {
- if (cmd->c_expr->arg_type == O_FLOP) { /* currently toggled? */
- match = TRUE; /* force on */
- }
- }
-
- /* at this point, match says whether our expression was true */
-
- maybe:
- if (cmdflags & CF_INVERT)
- match = !match;
- if (!match)
- goto next_cmd;
- }
-#ifdef TAINT
- tainted = 0; /* modifier doesn't affect regular expression */
-#endif
-
- /* now to do the actual command, if any */
-
- switch (cmd->c_type) {
- case C_NULL:
- fatal("panic: cmd_exec");
- case C_EXPR: /* evaluated for side effects */
- if (cmd->ucmd.acmd.ac_expr) { /* more to do? */
- if (gimme == G_ARRAY) {
- lastretstr = Nullstr;
- lastspbase = sp;
- lastsize = newsp - sp;
- if (lastsize < 0)
- lastsize = 0;
- }
- else
- lastretstr = retstr;
- while (tmps_max > tmps_base) { /* clean up after last eval */
- str_free(tmps_list[tmps_max]);
- tmps_list[tmps_max--] = Nullstr;
- }
- newsp = eval(cmd->ucmd.acmd.ac_expr,gimme && (cmdflags&CF_TERM),sp);
- st = stack->ary_array; /* possibly reallocated */
- retstr = st[newsp];
- }
- break;
- case C_NSWITCH:
- {
- double value = str_gnum(STAB_STR(cmd->c_stab));
-
- match = (int)value;
- if (value < 0.0) {
- if (((double)match) > value)
- --match; /* was fractional--truncate other way */
- }
- }
- goto doswitch;
- case C_CSWITCH:
- if (multiline) {
- cmd = cmd->c_next; /* can't assume anything */
- goto tail_recursion_entry;
- }
- match = *(str_get(STAB_STR(cmd->c_stab))) & 255;
- doswitch:
- match -= cmd->ucmd.scmd.sc_offset;
- if (match < 0)
- match = 0;
- else if (match > cmd->ucmd.scmd.sc_max)
- match = cmd->ucmd.scmd.sc_max;
- cmd = cmd->ucmd.scmd.sc_next[match];
- goto tail_recursion_entry;
- case C_NEXT:
- cmd = cmd->ucmd.ccmd.cc_alt;
- goto tail_recursion_entry;
- case C_ELSIF:
- fatal("panic: ELSIF");
- case C_IF:
- oldspat = curspat;
- oldsave = savestack->ary_fill;
-#ifdef DEBUGGING
- olddlevel = dlevel;
-#endif
- retstr = &str_yes;
- newsp = -2;
- if (cmd->ucmd.ccmd.cc_true) {
-#ifdef DEBUGGING
- if (debug) {
- debname[dlevel] = 't';
- debdelim[dlevel] = '_';
- if (++dlevel >= dlmax)
- grow_dlevel();
- }
-#endif
- newsp = cmd_exec(cmd->ucmd.ccmd.cc_true,gimme && (cmdflags & CF_TERM),sp);
- st = stack->ary_array; /* possibly reallocated */
- retstr = st[newsp];
- }
- curspat = oldspat;
- if (savestack->ary_fill > oldsave)
- restorelist(oldsave);
-#ifdef DEBUGGING
- dlevel = olddlevel;
-#endif
- cmd = cmd->ucmd.ccmd.cc_alt;
- goto tail_recursion_entry;
- case C_ELSE:
- oldspat = curspat;
- oldsave = savestack->ary_fill;
-#ifdef DEBUGGING
- olddlevel = dlevel;
-#endif
- retstr = &str_undef;
- newsp = -2;
- if (cmd->ucmd.ccmd.cc_true) {
-#ifdef DEBUGGING
- if (debug) {
- debname[dlevel] = 'e';
- debdelim[dlevel] = '_';
- if (++dlevel >= dlmax)
- grow_dlevel();
- }
-#endif
- newsp = cmd_exec(cmd->ucmd.ccmd.cc_true,gimme && (cmdflags & CF_TERM),sp);
- st = stack->ary_array; /* possibly reallocated */
- retstr = st[newsp];
- }
- curspat = oldspat;
- if (savestack->ary_fill > oldsave)
- restorelist(oldsave);
-#ifdef DEBUGGING
- dlevel = olddlevel;
-#endif
- break;
- case C_BLOCK:
- case C_WHILE:
- if (!(cmdflags & CF_ONCE)) { /* first time through here? */
- cmdflags |= CF_ONCE;
- if (++loop_ptr >= loop_max) {
- loop_max += 128;
- Renew(loop_stack, loop_max, struct loop);
- }
- loop_stack[loop_ptr].loop_label = cmd->c_label;
- loop_stack[loop_ptr].loop_sp = sp;
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Pushing label #%d %s)\n",
- loop_ptr, cmd->c_label ? cmd->c_label : "");
- }
-#endif
- }
-#ifdef JMPCLOBBER
- cmdparm = cmd;
-#endif
- match = setjmp(loop_stack[loop_ptr].loop_env);
- if (match) {
- st = stack->ary_array; /* possibly reallocated */
-#ifdef JMPCLOBBER
- cmd = cmdparm;
- cmdflags = cmd->c_flags|CF_ONCE;
- go_to = goto_targ;
-#endif
- if (savestack->ary_fill > oldsave)
- restorelist(oldsave);
- switch (match) {
- default:
- fatal("longjmp returned bad value (%d)",match);
- case O_LAST:
- if (lastretstr) {
- retstr = lastretstr;
- newsp = -2;
- }
- else {
- newsp = sp + lastsize;
- retstr = st[newsp];
- }
- curspat = oldspat;
- goto next_cmd;
- case O_NEXT:
-#ifdef JMPCLOBBER
- newsp = -2;
- retstr = &str_undef;
-#endif
- goto next_iter;
- case O_REDO:
-#ifdef DEBUGGING
- dlevel = olddlevel;
-#endif
-#ifdef JMPCLOBBER
- newsp = -2;
- retstr = &str_undef;
-#endif
- goto doit;
- }
- }
- oldspat = curspat;
- oldsave = savestack->ary_fill;
-#ifdef DEBUGGING
- olddlevel = dlevel;
-#endif
- doit:
- if (cmd->ucmd.ccmd.cc_true) {
-#ifdef DEBUGGING
- if (debug) {
- debname[dlevel] = 't';
- debdelim[dlevel] = '_';
- if (++dlevel >= dlmax)
- grow_dlevel();
- }
-#endif
- newsp = cmd_exec(cmd->ucmd.ccmd.cc_true,gimme && (cmdflags & CF_TERM),sp);
- st = stack->ary_array; /* possibly reallocated */
- retstr = st[newsp];
- }
- /* actually, this spot is rarely reached anymore since the above
- * cmd_exec() returns through longjmp(). Hooray for structure.
- */
- next_iter:
-#ifdef DEBUGGING
- dlevel = olddlevel;
-#endif
- if (cmd->ucmd.ccmd.cc_alt) {
-#ifdef DEBUGGING
- if (debug) {
- debname[dlevel] = 'a';
- debdelim[dlevel] = '_';
- if (++dlevel >= dlmax)
- grow_dlevel();
- }
-#endif
- newsp = cmd_exec(cmd->ucmd.ccmd.cc_alt,gimme && (cmdflags & CF_TERM),sp);
- st = stack->ary_array; /* possibly reallocated */
- retstr = st[newsp];
- }
- finish_while:
- curspat = oldspat;
- if (savestack->ary_fill > oldsave) {
- if (cmdflags & CF_TERM) {
- for (match = sp + 1; match <= newsp; match++)
- st[match] = str_mortal(st[match]);
- retstr = st[newsp];
- }
- restorelist(oldsave);
- }
-#ifdef DEBUGGING
- dlevel = olddlevel - 1;
-#endif
- if (cmd->c_type != C_BLOCK)
- goto until_loop; /* go back and evaluate conditional again */
- }
- if (cmdflags & CF_LOOP) {
- cmdflags |= CF_COND; /* now test the condition */
-#ifdef DEBUGGING
- dlevel = entdlevel;
-#endif
- goto until_loop;
- }
- next_cmd:
- if (cmdflags & CF_ONCE) {
-#ifdef DEBUGGING
- if (debug & 4) {
- tmps = loop_stack[loop_ptr].loop_label;
- deb("(Popping label #%d %s)\n",loop_ptr, tmps ? tmps : "");
- }
-#endif
- loop_ptr--;
- if ((cmdflags & CF_OPTIMIZE) == CFT_ARRAY &&
- savestack->ary_fill > aryoptsave)
- restorelist(aryoptsave);
- }
- cmd = cmd->c_next;
- goto tail_recursion_entry;
-}
-
-#ifdef DEBUGGING
-# ifndef I_VARARGS
-/*VARARGS1*/
-void deb(pat,a1,a2,a3,a4,a5,a6,a7,a8)
-char *pat;
-{
- register int i;
-
- fprintf(stderr,"%-4ld",(long)curcmd->c_line);
- for (i=0; i<dlevel; i++)
- fprintf(stderr,"%c%c ",debname[i],debdelim[i]);
- fprintf(stderr,pat,a1,a2,a3,a4,a5,a6,a7,a8);
-}
-# else
-/*VARARGS1*/
-void deb(va_alist)
-va_dcl
-{
- va_list args;
- char *pat;
- register int i;
-
- va_start(args);
- fprintf(stderr,"%-4ld",(long)curcmd->c_line);
- for (i=0; i<dlevel; i++)
- fprintf(stderr,"%c%c ",debname[i],debdelim[i]);
-
- pat = va_arg(args, char *);
- (void) vfprintf(stderr,pat,args);
- va_end( args );
-}
-# endif
-#endif
-
-int
-copyopt(cmd,which)
-register CMD *cmd;
-register CMD *which;
-{
- cmd->c_flags &= CF_ONCE|CF_COND|CF_LOOP;
- cmd->c_flags |= which->c_flags;
- cmd->c_short = which->c_short;
- cmd->c_slen = which->c_slen;
- cmd->c_stab = which->c_stab;
- return cmd->c_flags;
-}
-
-ARRAY *
-saveary(stab)
-STAB *stab;
-{
- register STR *str;
-
- str = Str_new(10,0);
- str->str_state = SS_SARY;
- str->str_u.str_stab = stab;
- if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_ptr = Nullch;
- str->str_len = 0;
- }
- str->str_ptr = (char*)stab_array(stab);
- (void)apush(savestack,str); /* save array ptr */
- stab_xarray(stab) = Null(ARRAY*);
- return stab_xarray(aadd(stab));
-}
-
-HASH *
-savehash(stab)
-STAB *stab;
-{
- register STR *str;
-
- str = Str_new(11,0);
- str->str_state = SS_SHASH;
- str->str_u.str_stab = stab;
- if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_ptr = Nullch;
- str->str_len = 0;
- }
- str->str_ptr = (char*)stab_hash(stab);
- (void)apush(savestack,str); /* save hash ptr */
- stab_xhash(stab) = Null(HASH*);
- return stab_xhash(hadd(stab));
-}
-
-void
-saveitem(item)
-register STR *item;
-{
- register STR *str;
-
- (void)apush(savestack,item); /* remember the pointer */
- str = Str_new(12,0);
- str_sset(str,item);
- (void)apush(savestack,str); /* remember the value */
-}
-
-void
-saveint(intp)
-int *intp;
-{
- register STR *str;
-
- str = Str_new(13,0);
- str->str_state = SS_SINT;
- str->str_u.str_useful = (long)*intp; /* remember value */
- if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_len = 0;
- }
- str->str_ptr = (char*)intp; /* remember pointer */
- (void)apush(savestack,str);
-}
-
-void
-savelong(longp)
-long *longp;
-{
- register STR *str;
-
- str = Str_new(14,0);
- str->str_state = SS_SLONG;
- str->str_u.str_useful = *longp; /* remember value */
- if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_len = 0;
- }
- str->str_ptr = (char*)longp; /* remember pointer */
- (void)apush(savestack,str);
-}
-
-void
-savesptr(sptr)
-STR **sptr;
-{
- register STR *str;
-
- str = Str_new(15,0);
- str->str_state = SS_SSTRP;
- str->str_magic = *sptr; /* remember value */
- if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_len = 0;
- }
- str->str_ptr = (char*)sptr; /* remember pointer */
- (void)apush(savestack,str);
-}
-
-void
-savenostab(stab)
-STAB *stab;
-{
- register STR *str;
-
- str = Str_new(16,0);
- str->str_state = SS_SNSTAB;
- str->str_magic = (STR*)stab; /* remember which stab to free */
- (void)apush(savestack,str);
-}
-
-void
-savehptr(hptr)
-HASH **hptr;
-{
- register STR *str;
-
- str = Str_new(17,0);
- str->str_state = SS_SHPTR;
- str->str_u.str_hash = *hptr; /* remember value */
- if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_len = 0;
- }
- str->str_ptr = (char*)hptr; /* remember pointer */
- (void)apush(savestack,str);
-}
-
-void
-saveaptr(aptr)
-ARRAY **aptr;
-{
- register STR *str;
-
- str = Str_new(17,0);
- str->str_state = SS_SAPTR;
- str->str_u.str_array = *aptr; /* remember value */
- if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_len = 0;
- }
- str->str_ptr = (char*)aptr; /* remember pointer */
- (void)apush(savestack,str);
-}
-
-void
-savelist(sarg,maxsarg)
-register STR **sarg;
-int maxsarg;
-{
- register STR *str;
- register int i;
-
- for (i = 1; i <= maxsarg; i++) {
- (void)apush(savestack,sarg[i]); /* remember the pointer */
- str = Str_new(18,0);
- str_sset(str,sarg[i]);
- (void)apush(savestack,str); /* remember the value */
- sarg[i]->str_u.str_useful = -1;
- }
-}
-
-void
-restorelist(base)
-int base;
-{
- register STR *str;
- register STR *value;
- register STAB *stab;
-
- if (base < -1)
- fatal("panic: corrupt saved stack index");
- while (savestack->ary_fill > base) {
- value = apop(savestack);
- switch (value->str_state) {
- case SS_NORM: /* normal string */
- case SS_INCR:
- str = apop(savestack);
- str_replace(str,value);
- STABSET(str);
- break;
- case SS_SARY: /* array reference */
- stab = value->str_u.str_stab;
- afree(stab_xarray(stab));
- stab_xarray(stab) = (ARRAY*)value->str_ptr;
- value->str_ptr = Nullch;
- str_free(value);
- break;
- case SS_SHASH: /* hash reference */
- stab = value->str_u.str_stab;
- (void)hfree(stab_xhash(stab), FALSE);
- stab_xhash(stab) = (HASH*)value->str_ptr;
- value->str_ptr = Nullch;
- str_free(value);
- break;
- case SS_SINT: /* int reference */
- *((int*)value->str_ptr) = (int)value->str_u.str_useful;
- value->str_ptr = Nullch;
- str_free(value);
- break;
- case SS_SLONG: /* long reference */
- *((long*)value->str_ptr) = value->str_u.str_useful;
- value->str_ptr = Nullch;
- str_free(value);
- break;
- case SS_SSTRP: /* STR* reference */
- *((STR**)value->str_ptr) = value->str_magic;
- value->str_magic = Nullstr;
- value->str_ptr = Nullch;
- str_free(value);
- break;
- case SS_SHPTR: /* HASH* reference */
- *((HASH**)value->str_ptr) = value->str_u.str_hash;
- value->str_ptr = Nullch;
- str_free(value);
- break;
- case SS_SAPTR: /* ARRAY* reference */
- *((ARRAY**)value->str_ptr) = value->str_u.str_array;
- value->str_ptr = Nullch;
- str_free(value);
- break;
- case SS_SNSTAB:
- stab = (STAB*)value->str_magic;
- value->str_magic = Nullstr;
- (void)stab_clear(stab);
- str_free(value);
- break;
- case SS_SCSV: /* callsave structure */
- {
- CSV *csv = (CSV*) value->str_ptr;
-
- curcmd = csv->curcmd;
- curcsv = csv->curcsv;
- csv->sub->depth = csv->depth;
- if (csv->hasargs) { /* put back old @_ */
- afree(csv->argarray);
- stab_xarray(defstab) = csv->savearray;
- }
- str_free(value);
- }
- break;
- default:
- fatal("panic: restorelist inconsistency");
- }
- }
-}
-
-#ifdef DEBUGGING
-void
-grow_dlevel()
-{
- dlmax += 128;
- Renew(debname, dlmax, char);
- Renew(debdelim, dlmax, char);
-}
-#endif
diff --git a/gnu/usr.bin/perl/perl/cmd.h b/gnu/usr.bin/perl/perl/cmd.h
deleted file mode 100644
index da0fa8e..0000000
--- a/gnu/usr.bin/perl/perl/cmd.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/* $RCSfile: cmd.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:34 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: cmd.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:35 nate
- * PERL!
- *
- * Revision 4.0.1.2 92/06/08 12:01:02 lwall
- * patch20: removed implicit int declarations on funcions
- *
- * Revision 4.0.1.1 91/06/07 10:28:50 lwall
- * patch4: new copyright notice
- * patch4: length($`), length($&), length($') now optimized to avoid string copy
- *
- * Revision 4.0 91/03/20 01:04:34 lwall
- * 4.0 baseline.
- *
- */
-
-#define C_NULL 0
-#define C_IF 1
-#define C_ELSE 2
-#define C_WHILE 3
-#define C_BLOCK 4
-#define C_EXPR 5
-#define C_NEXT 6
-#define C_ELSIF 7 /* temporary--turns into an IF + ELSE */
-#define C_CSWITCH 8 /* created by switch optimization in block_head() */
-#define C_NSWITCH 9 /* likewise */
-
-#ifdef DEBUGGING
-#ifndef DOINIT
-extern char *cmdname[];
-#else
-char *cmdname[] = {
- "NULL",
- "IF",
- "ELSE",
- "WHILE",
- "BLOCK",
- "EXPR",
- "NEXT",
- "ELSIF",
- "CSWITCH",
- "NSWITCH",
- "10"
-};
-#endif
-#endif /* DEBUGGING */
-
-#define CF_OPTIMIZE 077 /* type of optimization */
-#define CF_FIRSTNEG 0100/* conditional is ($register NE 'string') */
-#define CF_NESURE 0200 /* if short doesn't match we're sure */
-#define CF_EQSURE 0400 /* if short does match we're sure */
-#define CF_COND 01000 /* test c_expr as conditional first, if not null. */
- /* Set for everything except do {} while currently */
-#define CF_LOOP 02000 /* loop on the c_expr conditional (loop modifiers) */
-#define CF_INVERT 04000 /* it's an "unless" or an "until" */
-#define CF_ONCE 010000 /* we've already pushed the label on the stack */
-#define CF_FLIP 020000 /* on a match do flipflop */
-#define CF_TERM 040000 /* value of this cmd might be returned */
-#define CF_DBSUB 0100000 /* this is an inserted cmd for debugging */
-
-#define CFT_FALSE 0 /* c_expr is always false */
-#define CFT_TRUE 1 /* c_expr is always true */
-#define CFT_REG 2 /* c_expr is a simple register */
-#define CFT_ANCHOR 3 /* c_expr is an anchored search /^.../ */
-#define CFT_STROP 4 /* c_expr is a string comparison */
-#define CFT_SCAN 5 /* c_expr is an unanchored search /.../ */
-#define CFT_GETS 6 /* c_expr is <filehandle> */
-#define CFT_EVAL 7 /* c_expr is not optimized, so call eval() */
-#define CFT_UNFLIP 8 /* 2nd half of range not optimized */
-#define CFT_CHOP 9 /* c_expr is a chop on a register */
-#define CFT_ARRAY 10 /* this is a foreach loop */
-#define CFT_INDGETS 11 /* c_expr is <$variable> */
-#define CFT_NUMOP 12 /* c_expr is a numeric comparison */
-#define CFT_CCLASS 13 /* c_expr must start with one of these characters */
-#define CFT_D0 14 /* no special breakpoint at this line */
-#define CFT_D1 15 /* possible special breakpoint at this line */
-
-#ifdef DEBUGGING
-#ifndef DOINIT
-extern char *cmdopt[];
-#else
-char *cmdopt[] = {
- "FALSE",
- "TRUE",
- "REG",
- "ANCHOR",
- "STROP",
- "SCAN",
- "GETS",
- "EVAL",
- "UNFLIP",
- "CHOP",
- "ARRAY",
- "INDGETS",
- "NUMOP",
- "CCLASS",
- "14"
-};
-#endif
-#endif /* DEBUGGING */
-
-struct acmd {
- STAB *ac_stab; /* a symbol table entry */
- ARG *ac_expr; /* any associated expression */
-};
-
-struct ccmd {
- CMD *cc_true; /* normal code to do on if and while */
- CMD *cc_alt; /* else cmd ptr or continue code */
-};
-
-struct scmd {
- CMD **sc_next; /* array of pointers to commands */
- short sc_offset; /* first value - 1 */
- short sc_max; /* last value + 1 */
-};
-
-struct cmd {
- CMD *c_next; /* the next command at this level */
- ARG *c_expr; /* conditional expression */
- CMD *c_head; /* head of this command list */
- STR *c_short; /* string to match as shortcut */
- STAB *c_stab; /* a symbol table entry, mostly for fp */
- SPAT *c_spat; /* pattern used by optimization */
- char *c_label; /* label for this construct */
- union ucmd {
- struct acmd acmd; /* normal command */
- struct ccmd ccmd; /* compound command */
- struct scmd scmd; /* switch command */
- } ucmd;
- short c_slen; /* len of c_short, if not null */
- VOLATILE short c_flags; /* optimization flags--see above */
- HASH *c_stash; /* package line was compiled in */
- STAB *c_filestab; /* file the following line # is from */
- line_t c_line; /* line # of this command */
- char c_type; /* what this command does */
-};
-
-#define Nullcmd Null(CMD*)
-#define Nullcsv Null(CSV*)
-
-EXT CMD * VOLATILE main_root INIT(Nullcmd);
-EXT CMD * VOLATILE eval_root INIT(Nullcmd);
-
-EXT CMD compiling;
-EXT CMD * VOLATILE curcmd INIT(&compiling);
-EXT CSV * VOLATILE curcsv INIT(Nullcsv);
-
-struct callsave {
- SUBR *sub;
- STAB *stab;
- CSV *curcsv;
- CMD *curcmd;
- ARRAY *savearray;
- ARRAY *argarray;
- long depth;
- int wantarray;
- char hasargs;
-};
-
-struct compcmd {
- CMD *comp_true;
- CMD *comp_alt;
-};
-
-void opt_arg();
-ARG* evalstatic();
-int cmd_exec();
-#ifdef DEBUGGING
-void deb();
-#endif
-int copyopt();
diff --git a/gnu/usr.bin/perl/perl/config.H b/gnu/usr.bin/perl/perl/config.H
deleted file mode 100644
index e3d054e..0000000
--- a/gnu/usr.bin/perl/perl/config.H
+++ /dev/null
@@ -1,892 +0,0 @@
-#ifndef config_h
-#define config_h
-/* config.h
- * This file was produced by running the config.h.SH script, which
- * gets its values from config.sh, which is generally produced by
- * running Configure.
- *
- * Feel free to modify any of this as the need arises. Note, however,
- * that running config.h.SH again will wipe out any changes you've made.
- * For a more permanent change edit config.sh and rerun config.h.SH.
- */
- /*SUPPRESS 460*/
-
-
-/* EUNICE
- * This symbol, if defined, indicates that the program is being compiled
- * under the EUNICE package under VMS. The program will need to handle
- * things like files that don't go away the first time you unlink them,
- * due to version numbering. It will also need to compensate for lack
- * of a respectable link() command.
- */
-/* VMS
- * This symbol, if defined, indicates that the program is running under
- * VMS. It is currently only set in conjunction with the EUNICE symbol.
- */
-/*#undef EUNICE /**/
-/*#undef VMS /**/
-
-/* LOC_SED
- * This symbol holds the complete pathname to the sed program.
- */
-#define LOC_SED "/bin/sed" /**/
-
-/* ALIGN_BYTES
- * This symbol contains the number of bytes required to align a double.
- * Usual values are 2, 4, and 8.
- */
-#define ALIGN_BYTES 8 /**/
-
-/* BIN
- * This symbol holds the name of the directory in which the user wants
- * to keep publicly executable images for the package in question. It
- * is most often a local directory such as /usr/local/bin.
- */
-#define BIN "/usr/bin" /**/
-
-/* BYTEORDER
- * This symbol contains an encoding of the order of bytes in a long.
- * Usual values (in hex) are 0x1234, 0x4321, 0x2143, 0x3412...
- */
-#define BYTEORDER 0x4321 /**/
-
-/* CPPSTDIN
- * This symbol contains the first part of the string which will invoke
- * the C preprocessor on the standard input and produce to standard
- * output. Typical value of "cc -E" or "/lib/cpp".
- */
-/* CPPMINUS
- * This symbol contains the second part of the string which will invoke
- * the C preprocessor on the standard input and produce to standard
- * output. This symbol will have the value "-" if CPPSTDIN needs a minus
- * to specify standard input, otherwise the value is "".
- */
-#define CPPSTDIN "/usr/lib/cpp"
-#define CPPMINUS ""
-
-/* HAS_BCMP
- * This symbol, if defined, indicates that the bcmp routine is available
- * to compare blocks of memory. If undefined, use memcmp. If that's
- * not available, roll your own.
- */
-#define HAS_BCMP /**/
-
-/* HAS_BCOPY
- * This symbol, if defined, indicates that the bcopy routine is available
- * to copy blocks of memory. Otherwise you should probably use memcpy().
- * If neither is defined, roll your own.
- */
-/* SAFE_BCOPY
- * This symbol, if defined, indicates that the bcopy routine is available
- * to copy potentially overlapping copy blocks of bcopy. Otherwise you
- * should probably use memmove() or memcpy(). If neither is defined,
- * roll your own.
- */
-#define HAS_BCOPY /**/
-#define SAFE_BCOPY /**/
-
-/* HAS_BZERO
- * This symbol, if defined, indicates that the bzero routine is available
- * to zero blocks of memory. Otherwise you should probably use memset()
- * or roll your own.
- */
-#define HAS_BZERO /**/
-
-/* CASTNEGFLOAT
- * This symbol, if defined, indicates that this C compiler knows how to
- * cast negative or large floating point numbers to unsigned longs, ints
- * and shorts.
- */
-/* CASTFLAGS
- * This symbol contains flags that say what difficulties the compiler
- * has casting odd floating values to unsigned long:
- * 1 = couldn't cast < 0
- * 2 = couldn't cast >= 0x80000000
- */
-#define CASTNEGFLOAT /**/
-#define CASTFLAGS 0 /**/
-
-/* CHARSPRINTF
- * This symbol is defined if this system declares "char *sprintf()" in
- * stdio.h. The trend seems to be to declare it as "int sprintf()". It
- * is up to the package author to declare sprintf correctly based on the
- * symbol.
- */
-#define CHARSPRINTF /**/
-
-/* HAS_CHSIZE
- * This symbol, if defined, indicates that the chsize routine is available
- * to truncate files. You might need a -lx to get this routine.
- */
-/*#undef HAS_CHSIZE /**/
-
-/* HAS_CRYPT
- * This symbol, if defined, indicates that the crypt routine is available
- * to encrypt passwords and the like.
- */
-#define HAS_CRYPT /**/
-
-/* CSH
- * This symbol, if defined, indicates that the C-shell exists.
- * If defined, contains the full pathname of csh.
- */
-#define CSH "/bin/csh" /**/
-
-/* DOSUID
- * This symbol, if defined, indicates that the C program should
- * check the script that it is executing for setuid/setgid bits, and
- * attempt to emulate setuid/setgid on systems that have disabled
- * setuid #! scripts because the kernel can't do it securely.
- * It is up to the package designer to make sure that this emulation
- * is done securely. Among other things, it should do an fstat on
- * the script it just opened to make sure it really is a setuid/setgid
- * script, it should make sure the arguments passed correspond exactly
- * to the argument on the #! line, and it should not trust any
- * subprocesses to which it must pass the filename rather than the
- * file descriptor of the script to be executed.
- */
-/*#undef DOSUID /**/
-
-/* HAS_DUP2
- * This symbol, if defined, indicates that the dup2 routine is available
- * to dup file descriptors. Otherwise you should use dup().
- */
-#define HAS_DUP2 /**/
-
-/* HAS_FCHMOD
- * This symbol, if defined, indicates that the fchmod routine is available
- * to change mode of opened files. If unavailable, use chmod().
- */
-#define HAS_FCHMOD /**/
-
-/* HAS_FCHOWN
- * This symbol, if defined, indicates that the fchown routine is available
- * to change ownership of opened files. If unavailable, use chown().
- */
-#define HAS_FCHOWN /**/
-
-/* HAS_FCNTL
- * This symbol, if defined, indicates to the C program that
- * the fcntl() function exists.
- */
-#define HAS_FCNTL /**/
-
-/* FLEXFILENAMES
- * This symbol, if defined, indicates that the system supports filenames
- * longer than 14 characters.
- */
-#define FLEXFILENAMES /**/
-
-/* HAS_FLOCK
- * This symbol, if defined, indicates that the flock() routine is
- * available to do file locking.
- */
-#define HAS_FLOCK /**/
-
-/* HAS_GETGROUPS
- * This symbol, if defined, indicates that the getgroups() routine is
- * available to get the list of process groups. If unavailable, multiple
- * groups are probably not supported.
- */
-#define HAS_GETGROUPS /**/
-
-/* HAS_GETHOSTENT
- * This symbol, if defined, indicates that the gethostent() routine is
- * available to lookup host names in some data base or other.
- */
-#define HAS_GETHOSTENT /**/
-
-/* HAS_GETPGRP
- * This symbol, if defined, indicates that the getpgrp() routine is
- * available to get the current process group.
- */
-#define HAS_GETPGRP /**/
-
-/* HAS_GETPGRP2
- * This symbol, if defined, indicates that the getpgrp2() (as in DG/UX)
- * routine is available to get the current process group.
- */
-/*#undef HAS_GETPGRP2 /**/
-
-/* HAS_GETPRIORITY
- * This symbol, if defined, indicates that the getpriority() routine is
- * available to get a process's priority.
- */
-#define HAS_GETPRIORITY /**/
-
-/* HAS_HTONS
- * This symbol, if defined, indicates that the htons routine (and friends)
- * are available to do network order byte swapping.
- */
-/* HAS_HTONL
- * This symbol, if defined, indicates that the htonl routine (and friends)
- * are available to do network order byte swapping.
- */
-/* HAS_NTOHS
- * This symbol, if defined, indicates that the ntohs routine (and friends)
- * are available to do network order byte swapping.
- */
-/* HAS_NTOHL
- * This symbol, if defined, indicates that the ntohl routine (and friends)
- * are available to do network order byte swapping.
- */
-#define HAS_HTONS /**/
-#define HAS_HTONL /**/
-#define HAS_NTOHS /**/
-#define HAS_NTOHL /**/
-
-/* index
- * This preprocessor symbol is defined, along with rindex, if the system
- * uses the strchr and strrchr routines instead.
- */
-/* rindex
- * This preprocessor symbol is defined, along with index, if the system
- * uses the strchr and strrchr routines instead.
- */
-/*#undef index strchr /* cultural */
-/*#undef rindex strrchr /* differences? */
-
-/* HAS_ISASCII
- * This symbol, if defined, indicates that the isascii routine is available
- * to test characters for asciiness.
- */
-#define HAS_ISASCII /**/
-
-/* HAS_KILLPG
- * This symbol, if defined, indicates that the killpg routine is available
- * to kill process groups. If unavailable, you probably should use kill
- * with a negative process number.
- */
-#define HAS_KILLPG /**/
-
-/* HAS_LSTAT
- * This symbol, if defined, indicates that the lstat() routine is
- * available to stat symbolic links.
- */
-#define HAS_LSTAT /**/
-
-/* HAS_MEMCMP
- * This symbol, if defined, indicates that the memcmp routine is available
- * to compare blocks of memory. If undefined, roll your own.
- */
-#define HAS_MEMCMP /**/
-
-/* HAS_MEMCPY
- * This symbol, if defined, indicates that the memcpy routine is available
- * to copy blocks of memory. Otherwise you should probably use bcopy().
- * If neither is defined, roll your own.
- */
-/* SAFE_MEMCPY
- * This symbol, if defined, indicates that the memcpy routine is available
- * to copy potentially overlapping copy blocks of memory. Otherwise you
- * should probably use memmove() or bcopy(). If neither is defined,
- * roll your own.
- */
-#define HAS_MEMCPY /**/
-/*#undef SAFE_MEMCPY /**/
-
-/* HAS_MEMMOVE
- * This symbol, if defined, indicates that the memmove routine is available
- * to move potentially overlapping blocks of memory. Otherwise you
- * should use bcopy() or roll your own.
- */
-/*#undef HAS_MEMMOVE /**/
-
-/* HAS_MEMSET
- * This symbol, if defined, indicates that the memset routine is available
- * to set a block of memory to a character. If undefined, roll your own.
- */
-#define HAS_MEMSET /**/
-
-/* HAS_MKDIR
- * This symbol, if defined, indicates that the mkdir routine is available
- * to create directories. Otherwise you should fork off a new process to
- * exec /bin/mkdir.
- */
-#define HAS_MKDIR /**/
-
-/* HAS_MSG
- * This symbol, if defined, indicates that the entire msg*(2) library is
- * supported.
- */
-#define HAS_MSG /**/
-
-/* HAS_MSGCTL
- * This symbol, if defined, indicates that the msgctl() routine is
- * available to control message passing.
- */
-#define HAS_MSGCTL /**/
-
-/* HAS_MSGGET
- * This symbol, if defined, indicates that the msgget() routine is
- * available to get messages.
- */
-#define HAS_MSGGET /**/
-
-/* HAS_MSGRCV
- * This symbol, if defined, indicates that the msgrcv() routine is
- * available to receive messages.
- */
-#define HAS_MSGRCV /**/
-
-/* HAS_MSGSND
- * This symbol, if defined, indicates that the msgsnd() routine is
- * available to send messages.
- */
-#define HAS_MSGSND /**/
-
-/* HAS_NDBM
- * This symbol, if defined, indicates that ndbm.h exists and should
- * be included.
- */
-#define HAS_NDBM /**/
-
-/* HAS_ODBM
- * This symbol, if defined, indicates that dbm.h exists and should
- * be included.
- */
-#define HAS_ODBM /**/
-
-/* HAS_OPEN3
- * This manifest constant lets the C program know that the three
- * argument form of open(2) is available.
- */
-#define HAS_OPEN3 /**/
-
-/* HAS_READDIR
- * This symbol, if defined, indicates that the readdir routine is available
- * from the C library to read directories.
- */
-#define HAS_READDIR /**/
-
-/* HAS_RENAME
- * This symbol, if defined, indicates that the rename routine is available
- * to rename files. Otherwise you should do the unlink(), link(), unlink()
- * trick.
- */
-#define HAS_RENAME /**/
-
-/* HAS_REWINDDIR
- * This symbol, if defined, indicates that the rewindir routine is
- * available to rewind directories.
- */
-#define HAS_REWINDDIR /**/
-
-/* HAS_RMDIR
- * This symbol, if defined, indicates that the rmdir routine is available
- * to remove directories. Otherwise you should fork off a new process to
- * exec /bin/rmdir.
- */
-#define HAS_RMDIR /**/
-
-/* HAS_SEEKDIR
- * This symbol, if defined, indicates that the seekdir routine is
- * available to seek into directories.
- */
-#define HAS_SEEKDIR /**/
-
-/* HAS_SELECT
- * This symbol, if defined, indicates that the select() subroutine
- * exists.
- */
-#define HAS_SELECT /**/
-
-/* HAS_SEM
- * This symbol, if defined, indicates that the entire sem*(2) library is
- * supported.
- */
-#define HAS_SEM /**/
-
-/* HAS_SEMCTL
- * This symbol, if defined, indicates that the semctl() routine is
- * available to control semaphores.
- */
-#define HAS_SEMCTL /**/
-
-/* HAS_SEMGET
- * This symbol, if defined, indicates that the semget() routine is
- * available to get semaphores ids.
- */
-#define HAS_SEMGET /**/
-
-/* HAS_SEMOP
- * This symbol, if defined, indicates that the semop() routine is
- * available to perform semaphore operations.
- */
-#define HAS_SEMOP /**/
-
-/* HAS_SETEGID
- * This symbol, if defined, indicates that the setegid routine is available
- * to change the effective gid of the current program.
- */
-#define HAS_SETEGID /**/
-
-/* HAS_SETEUID
- * This symbol, if defined, indicates that the seteuid routine is available
- * to change the effective uid of the current program.
- */
-#define HAS_SETEUID /**/
-
-/* HAS_SETPGRP
- * This symbol, if defined, indicates that the setpgrp() routine is
- * available to set the current process group.
- */
-#define HAS_SETPGRP /**/
-
-/* HAS_SETPGRP2
- * This symbol, if defined, indicates that the setpgrp2() (as in DG/UX)
- * routine is available to set the current process group.
- */
-/*#undef HAS_SETPGRP2 /**/
-
-/* HAS_SETPRIORITY
- * This symbol, if defined, indicates that the setpriority() routine is
- * available to set a process's priority.
- */
-#define HAS_SETPRIORITY /**/
-
-/* HAS_SETREGID
- * This symbol, if defined, indicates that the setregid routine is
- * available to change the real and effective gid of the current program.
- */
-/* HAS_SETRESGID
- * This symbol, if defined, indicates that the setresgid routine is
- * available to change the real, effective and saved gid of the current
- * program.
- */
-#define HAS_SETREGID /**/
-/*#undef HAS_SETRESGID /**/
-
-/* HAS_SETREUID
- * This symbol, if defined, indicates that the setreuid routine is
- * available to change the real and effective uid of the current program.
- */
-/* HAS_SETRESUID
- * This symbol, if defined, indicates that the setresuid routine is
- * available to change the real, effective and saved uid of the current
- * program.
- */
-#define HAS_SETREUID /**/
-/*#undef HAS_SETRESUID /**/
-
-/* HAS_SETRGID
- * This symbol, if defined, indicates that the setrgid routine is available
- * to change the real gid of the current program.
- */
-#define HAS_SETRGID /**/
-
-/* HAS_SETRUID
- * This symbol, if defined, indicates that the setruid routine is available
- * to change the real uid of the current program.
- */
-#define HAS_SETRUID /**/
-
-/* HAS_SHM
- * This symbol, if defined, indicates that the entire shm*(2) library is
- * supported.
- */
-#define HAS_SHM /**/
-
-/* HAS_SHMAT
- * This symbol, if defined, indicates that the shmat() routine is
- * available to attach a shared memory segment.
- */
-/* VOID_SHMAT
- * This symbol, if defined, indicates that the shmat() routine
- * returns a pointer of type void*.
- */
-#define HAS_SHMAT /**/
-
-/*#undef VOIDSHMAT /**/
-
-/* HAS_SHMCTL
- * This symbol, if defined, indicates that the shmctl() routine is
- * available to control a shared memory segment.
- */
-#define HAS_SHMCTL /**/
-
-/* HAS_SHMDT
- * This symbol, if defined, indicates that the shmdt() routine is
- * available to detach a shared memory segment.
- */
-#define HAS_SHMDT /**/
-
-/* HAS_SHMGET
- * This symbol, if defined, indicates that the shmget() routine is
- * available to get a shared memory segment id.
- */
-#define HAS_SHMGET /**/
-
-/* HAS_SOCKET
- * This symbol, if defined, indicates that the BSD socket interface is
- * supported.
- */
-/* HAS_SOCKETPAIR
- * This symbol, if defined, indicates that the BSD socketpair call is
- * supported.
- */
-/* OLDSOCKET
- * This symbol, if defined, indicates that the 4.1c BSD socket interface
- * is supported instead of the 4.2/4.3 BSD socket interface.
- */
-#define HAS_SOCKET /**/
-
-#define HAS_SOCKETPAIR /**/
-
-/*#undef OLDSOCKET /**/
-
-/* STATBLOCKS
- * This symbol is defined if this system has a stat structure declaring
- * st_blksize and st_blocks.
- */
-#define STATBLOCKS /**/
-
-/* STDSTDIO
- * This symbol is defined if this system has a FILE structure declaring
- * _ptr and _cnt in stdio.h.
- */
-#define STDSTDIO /**/
-
-/* STRUCTCOPY
- * This symbol, if defined, indicates that this C compiler knows how
- * to copy structures. If undefined, you'll need to use a block copy
- * routine of some sort instead.
- */
-#define STRUCTCOPY /**/
-
-/* HAS_STRERROR
- * This symbol, if defined, indicates that the strerror() routine is
- * available to translate error numbers to strings.
- */
-/*#undef HAS_STRERROR /**/
-
-/* HAS_SYMLINK
- * This symbol, if defined, indicates that the symlink routine is available
- * to create symbolic links.
- */
-#define HAS_SYMLINK /**/
-
-/* HAS_SYSCALL
- * This symbol, if defined, indicates that the syscall routine is available
- * to call arbitrary system calls. If undefined, that's tough.
- */
-#define HAS_SYSCALL /**/
-
-/* HAS_TELLDIR
- * This symbol, if defined, indicates that the telldir routine is
- * available to tell your location in directories.
- */
-#define HAS_TELLDIR /**/
-
-/* HAS_TRUNCATE
- * This symbol, if defined, indicates that the truncate routine is
- * available to truncate files.
- */
-#define HAS_TRUNCATE /**/
-
-/* HAS_VFORK
- * This symbol, if defined, indicates that vfork() exists.
- */
-#define HAS_VFORK /**/
-
-/* VOIDSIG
- * This symbol is defined if this system declares "void (*signal())()" in
- * signal.h. The old way was to declare it as "int (*signal())()". It
- * is up to the package author to declare things correctly based on the
- * symbol.
- */
-/* TO_SIGNAL
- * This symbol's value is either "void" or "int", corresponding to the
- * appropriate return "type" of a signal handler. Thus, one can declare
- * a signal handler using "TO_SIGNAL (*handler())()", and define the
- * handler using "TO_SIGNAL handler(sig)".
- */
-#define VOIDSIG /**/
-#define TO_SIGNAL int /**/
-
-/* HASVOLATILE
- * This symbol, if defined, indicates that this C compiler knows about
- * the volatile declaration.
- */
-/*#undef HASVOLATILE /**/
-
-/* HAS_VPRINTF
- * This symbol, if defined, indicates that the vprintf routine is available
- * to printf with a pointer to an argument list. If unavailable, you
- * may need to write your own, probably in terms of _doprnt().
- */
-/* CHARVSPRINTF
- * This symbol is defined if this system has vsprintf() returning type
- * (char*). The trend seems to be to declare it as "int vsprintf()". It
- * is up to the package author to declare vsprintf correctly based on the
- * symbol.
- */
-#define HAS_VPRINTF /**/
-#define CHARVSPRINTF /**/
-
-/* HAS_WAIT4
- * This symbol, if defined, indicates that wait4() exists.
- */
-#define HAS_WAIT4 /**/
-
-/* HAS_WAITPID
- * This symbol, if defined, indicates that waitpid() exists.
- */
-#define HAS_WAITPID /**/
-
-/* GIDTYPE
- * This symbol has a value like gid_t, int, ushort, or whatever type is
- * used to declare group ids in the kernel.
- */
-#define GIDTYPE gid_t /**/
-
-/* GROUPSTYPE
- * This symbol has a value like gid_t, int, ushort, or whatever type is
- * used in the return value of getgroups().
- */
-#define GROUPSTYPE int /**/
-
-/* I_FCNTL
- * This manifest constant tells the C program to include <fcntl.h>.
- */
-/*#undef I_FCNTL /**/
-
-/* I_GDBM
- * This symbol, if defined, indicates that gdbm.h exists and should
- * be included.
- */
-/*#undef I_GDBM /**/
-
-/* I_GRP
- * This symbol, if defined, indicates to the C program that it should
- * include grp.h.
- */
-#define I_GRP /**/
-
-/* I_NETINET_IN
- * This symbol, if defined, indicates to the C program that it should
- * include netinet/in.h.
- */
-/* I_SYS_IN
- * This symbol, if defined, indicates to the C program that it should
- * include sys/in.h.
- */
-#define I_NETINET_IN /**/
-/*#undef I_SYS_IN /**/
-
-/* I_PWD
- * This symbol, if defined, indicates to the C program that it should
- * include pwd.h.
- */
-/* PWQUOTA
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_quota.
- */
-/* PWAGE
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_age.
- */
-/* PWCHANGE
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_change.
- */
-/* PWCLASS
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_class.
- */
-/* PWEXPIRE
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_expire.
- */
-/* PWCOMMENT
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_comment.
- */
-#define I_PWD /**/
-/*#undef PWQUOTA /**/
-#define PWAGE /**/
-/*#undef PWCHANGE /**/
-/*#undef PWCLASS /**/
-/*#undef PWEXPIRE /**/
-#define PWCOMMENT /**/
-
-/* I_SYS_FILE
- * This manifest constant tells the C program to include <sys/file.h>.
- */
-#define I_SYS_FILE /**/
-
-/* I_SYSIOCTL
- * This symbol, if defined, indicates that sys/ioctl.h exists and should
- * be included.
- */
-#define I_SYSIOCTL /**/
-
-/* I_TIME
- * This symbol is defined if the program should include <time.h>.
- */
-/* I_SYS_TIME
- * This symbol is defined if the program should include <sys/time.h>.
- */
-/* SYSTIMEKERNEL
- * This symbol is defined if the program should include <sys/time.h>
- * with KERNEL defined.
- */
-/* I_SYS_SELECT
- * This symbol is defined if the program should include <sys/select.h>.
- */
-/*#undef I_TIME /**/
-#define I_SYS_TIME /**/
-/*#undef SYSTIMEKERNEL /**/
-/*#undef I_SYS_SELECT /**/
-
-/* I_UTIME
- * This symbol, if defined, indicates to the C program that it should
- * include utime.h.
- */
-#define I_UTIME /**/
-
-/* I_VARARGS
- * This symbol, if defined, indicates to the C program that it should
- * include varargs.h.
- */
-#define I_VARARGS /**/
-
-/* I_VFORK
- * This symbol, if defined, indicates to the C program that it should
- * include vfork.h.
- */
-#define I_VFORK /**/
-
-/* INTSIZE
- * This symbol contains the size of an int, so that the C preprocessor
- * can make decisions based on it.
- */
-#define INTSIZE 4 /**/
-
-/* I_DIRENT
- * This symbol, if defined, indicates that the program should use the
- * P1003-style directory routines, and include <dirent.h>.
- */
-/* I_SYS_DIR
- * This symbol, if defined, indicates that the program should use the
- * directory functions by including <sys/dir.h>.
- */
-/* I_NDIR
- * This symbol, if defined, indicates that the program should include the
- * system's version of ndir.h, rather than the one with this package.
- */
-/* I_SYS_NDIR
- * This symbol, if defined, indicates that the program should include the
- * system's version of sys/ndir.h, rather than the one with this package.
- */
-/* I_MY_DIR
- * This symbol, if defined, indicates that the program should compile
- * the ndir.c code provided with the package.
- */
-/* DIRNAMLEN
- * This symbol, if defined, indicates to the C program that the length
- * of directory entry names is provided by a d_namlen field. Otherwise
- * you need to do strlen() on the d_name field.
- */
-#define I_DIRENT /**/
-/*#undef I_SYS_DIR /**/
-/*#undef I_NDIR /**/
-/*#undef I_SYS_NDIR /**/
-/*#undef I_MY_DIR /**/
-/*#undef DIRNAMLEN /**/
-
-/* MYMALLOC
- * This symbol, if defined, indicates that we're using our own malloc.
- */
-/* MALLOCPTRTYPE
- * This symbol defines the kind of ptr returned by malloc and realloc.
- */
-#define MYMALLOC /**/
-
-#define MALLOCPTRTYPE char /**/
-
-
-/* RANDBITS
- * This symbol contains the number of bits of random number the rand()
- * function produces. Usual values are 15, 16, and 31.
- */
-#define RANDBITS 31 /**/
-
-/* SCRIPTDIR
- * This symbol holds the name of the directory in which the user wants
- * to keep publicly executable scripts for the package in question. It
- * is often a directory that is mounted across diverse architectures.
- */
-#define SCRIPTDIR "/usr/bin" /**/
-
-/* SIG_NAME
- * This symbol contains an list of signal names in order.
- */
-#define SIG_NAME "ZERO","HUP","INT","QUIT","ILL","TRAP","ABRT","EMT","FPE","KILL","BUS","SEGV","SYS","PIPE","ALRM","TERM","URG","STOP","TSTP","CONT","CLD","TTIN","TTOU","IO","XCPU","XFSZ","VTALRM","PROF","WINCH","LOST","USR1","USR2" /**/
-
-/* STDCHAR
- * This symbol is defined to be the type of char used in stdio.h.
- * It has the values "unsigned char" or "char".
- */
-#define STDCHAR unsigned char /**/
-
-/* UIDTYPE
- * This symbol has a value like uid_t, int, ushort, or whatever type is
- * used to declare user ids in the kernel.
- */
-#define UIDTYPE uid_t /**/
-
-/* VOIDHAVE
- * This symbol indicates how much support of the void type is given by this
- * compiler. What various bits mean:
- *
- * 1 = supports declaration of void
- * 2 = supports arrays of pointers to functions returning void
- * 4 = supports comparisons between pointers to void functions and
- * addresses of void functions
- *
- * The package designer should define VOIDWANT to indicate the requirements
- * of the package. This can be done either by #defining VOIDWANT before
- * including config.h, or by defining voidwant in Myinit.U. If the level
- * of void support necessary is not present, config.h defines void to "int",
- * VOID to the empty string, and VOIDP to "char *".
- */
-/* void
- * This symbol is used for void casts. On implementations which support
- * void appropriately, its value is "void". Otherwise, its value maps
- * to "int".
- */
-/* VOID
- * This symbol's value is "void" if the implementation supports void
- * appropriately. Otherwise, its value is the empty string. The primary
- * use of this symbol is in specifying void parameter lists for function
- * prototypes.
- */
-/* VOIDP
- * This symbol is used for casting generic pointers. On implementations
- * which support void appropriately, its value is "void *". Otherwise,
- * its value is "char *".
- */
-#ifndef VOIDWANT
-#define VOIDWANT 7
-#endif
-#define VOIDHAVE 7
-#if (VOIDHAVE & VOIDWANT) != VOIDWANT
-#define void int /* is void to be avoided? */
-#define VOID
-#define VOIDP (char *)
-#define M_VOID /* Xenix strikes again */
-#else
-#define VOID void
-#define VOIDP (void *)
-#endif
-
-/* PRIVLIB
- * This symbol contains the name of the private library for this package.
- * The library is private in the sense that it needn't be in anyone's
- * execution path, but it should be accessible by the world. The program
- * should be prepared to do ~ expansion.
- */
-#define PRIVLIB "/usr/share/perl" /**/
-
-#endif
diff --git a/gnu/usr.bin/perl/perl/config.h b/gnu/usr.bin/perl/perl/config.h
deleted file mode 100644
index 79f6a6c..0000000
--- a/gnu/usr.bin/perl/perl/config.h
+++ /dev/null
@@ -1,771 +0,0 @@
-#ifndef config_h
-#define config_h
-/* config.h
- * This file was produced by running the config.h.SH script, which
- * gets its values from config.sh, which is generally produced by
- * running Configure.
- *
- * Feel free to modify any of this as the need arises. Note, however,
- * that running config.h.SH again will wipe out any changes you've made.
- * For a more permanent change edit config.sh and rerun config.h.SH.
- */
- /*SUPPRESS 460*/
-
-
-/*#undef EUNICE */
-/*#undef VMS */
-
-/* LOC_SED
- * This symbol holds the complete pathname to the sed program.
- */
-#define LOC_SED "/usr/bin/sed" /**/
-
-/* ALIGN_BYTES
- * This symbol contains the number of bytes required to align a double.
- * Usual values are 2, 4, and 8.
- */
-#define ALIGN_BYTES 4 /**/
-
-/* BIN
- * This symbol holds the name of the directory in which the user wants
- * to keep publicly executable images for the package in question. It
- * is most often a local directory such as /usr/local/bin.
- */
-#define BIN "/usr/bin" /**/
-
-/* BYTEORDER
- * This symbol contains an encoding of the order of bytes in a long.
- * Usual values (in hex) are 0x1234, 0x4321, 0x2143, 0x3412...
- */
-#define BYTEORDER 0x1234 /**/
-
-/* CPPSTDIN
- * This symbol contains the first part of the string which will invoke
- * the C preprocessor on the standard input and produce to standard
- * output. Typical value of "cc -E" or "/lib/cpp".
- */
-/* CPPMINUS
- * This symbol contains the second part of the string which will invoke
- * the C preprocessor on the standard input and produce to standard
- * output. This symbol will have the value "-" if CPPSTDIN needs a minus
- * to specify standard input, otherwise the value is "".
- */
-#define CPPSTDIN "cc -E"
-#define CPPMINUS "-"
-
-/* HAS_BCMP
- * This symbol, if defined, indicates that the bcmp routine is available
- * to compare blocks of memory. If undefined, use memcmp. If that's
- * not available, roll your own.
- */
-#define HAS_BCMP /**/
-
-/* HAS_BCOPY
- * This symbol, if defined, indicates that the bcopy routine is available
- * to copy blocks of memory. Otherwise you should probably use memcpy().
- * If neither is defined, roll your own.
- */
-/* SAFE_BCOPY
- * This symbol, if defined, indicates that the bcopy routine is available
- * to copy potentially overlapping copy blocks of bcopy. Otherwise you
- * should probably use memmove() or memcpy(). If neither is defined,
- * roll your own.
- */
-#define HAS_BCOPY /**/
-#define SAFE_BCOPY /**/
-
-/* HAS_BZERO
- * This symbol, if defined, indicates that the bzero routine is available
- * to zero blocks of memory. Otherwise you should probably use memset()
- * or roll your own.
- */
-#define HAS_BZERO /**/
-
-/* CASTNEGFLOAT
- * This symbol, if defined, indicates that this C compiler knows how to
- * cast negative or large floating point numbers to unsigned longs, ints
- * and shorts.
- */
-/* CASTFLAGS
- * This symbol contains flags that say what difficulties the compiler
- * has casting odd floating values to unsigned long:
- * 1 = couldn't cast < 0
- * 2 = couldn't cast >= 0x80000000
- */
-#define CASTNEGFLOAT /**/
-#define CASTFLAGS 0 /**/
-
-/* CHARSPRINTF
- * This symbol is defined if this system declares "char *sprintf()" in
- * stdio.h. The trend seems to be to declare it as "int sprintf()". It
- * is up to the package author to declare sprintf correctly based on the
- * symbol.
- */
-/*#undef CHARSPRINTF */
-
-/* HAS_CHSIZE
- * This symbol, if defined, indicates that the chsize routine is available
- * to truncate files. You might need a -lx to get this routine.
- */
-/*#undef HAS_CHSIZE */
-
-/* HAS_CRYPT
- * This symbol, if defined, indicates that the crypt routine is available
- * to encrypt passwords and the like.
- */
-#define HAS_CRYPT /**/
-
-/* CSH
- * This symbol, if defined, indicates that the C-shell exists.
- * If defined, contains the full pathname of csh.
- */
-#define CSH "/bin/csh" /**/
-
-/* DOSUID
- * This symbol, if defined, indicates that the C program should
- * check the script that it is executing for setuid/setgid bits, and
- * attempt to emulate setuid/setgid on systems that have disabled
- * setuid #! scripts because the kernel can't do it securely.
- * It is up to the package designer to make sure that this emulation
- * is done securely. Among other things, it should do an fstat on
- * the script it just opened to make sure it really is a setuid/setgid
- * script, it should make sure the arguments passed correspond exactly
- * to the argument on the #! line, and it should not trust any
- * subprocesses to which it must pass the filename rather than the
- * file descriptor of the script to be executed.
- */
-/*#undef DOSUID */
-
-/* HAS_DUP2
- * This symbol, if defined, indicates that the dup2 routine is available
- * to dup file descriptors. Otherwise you should use dup().
- */
-#define HAS_DUP2 /**/
-
-/* HAS_FCHMOD
- * This symbol, if defined, indicates that the fchmod routine is available
- * to change mode of opened files. If unavailable, use chmod().
- */
-#define HAS_FCHMOD /**/
-
-/* HAS_FCHOWN
- * This symbol, if defined, indicates that the fchown routine is available
- * to change ownership of opened files. If unavailable, use chown().
- */
-#define HAS_FCHOWN /**/
-
-/* HAS_FCNTL
- * This symbol, if defined, indicates to the C program that
- * the fcntl() function exists.
- */
-#define HAS_FCNTL /**/
-
-/* FLEXFILENAMES
- * This symbol, if defined, indicates that the system supports filenames
- * longer than 14 characters.
- */
-#define FLEXFILENAMES /**/
-
-/* HAS_FLOCK
- * This symbol, if defined, indicates that the flock() routine is
- * available to do file locking.
- */
-#define HAS_FLOCK /**/
-
-/* HAS_GETGROUPS
- * This symbol, if defined, indicates that the getgroups() routine is
- * available to get the list of process groups. If unavailable, multiple
- * groups are probably not supported.
- */
-#define HAS_GETGROUPS /**/
-
-/* HAS_GETHOSTENT
- * This symbol, if defined, indicates that the gethostent() routine is
- * available to lookup host names in some data base or other.
- */
-/*#undef HAS_GETHOSTENT */
-
-/* HAS_GETPGRP
- * This symbol, if defined, indicates that the getpgrp() routine is
- * available to get the current process group.
- */
-#define HAS_GETPGRP /**/
-
-/* HAS_GETPGRP2
- * This symbol, if defined, indicates that the getpgrp2() (as in DG/UX)
- * routine is available to get the current process group.
- */
-/*#undef HAS_GETPGRP2 */
-
-/* HAS_GETPRIORITY
- * This symbol, if defined, indicates that the getpriority() routine is
- * available to get a process's priority.
- */
-#define HAS_GETPRIORITY /**/
-
-/* HAS_HTONS
- * This symbol, if defined, indicates that the htons routine (and friends)
- * are available to do network order byte swapping.
- */
-/* HAS_HTONL
- * This symbol, if defined, indicates that the htonl routine (and friends)
- * are available to do network order byte swapping.
- */
-/* HAS_NTOHS
- * This symbol, if defined, indicates that the ntohs routine (and friends)
- * are available to do network order byte swapping.
- */
-/* HAS_NTOHL
- * This symbol, if defined, indicates that the ntohl routine (and friends)
- * are available to do network order byte swapping.
- */
-#define HAS_HTONS /**/
-#define HAS_HTONL /**/
-#define HAS_NTOHS /**/
-#define HAS_NTOHL /**/
-
-/* index
- * This preprocessor symbol is defined, along with rindex, if the system
- * uses the strchr and strrchr routines instead.
- */
-/* rindex
- * This preprocessor symbol is defined, along with index, if the system
- * uses the strchr and strrchr routines instead.
- */
-
-/* HAS_ISASCII
- * This symbol, if defined, indicates that the isascii routine is available
- * to test characters for asciiness.
- */
-#define HAS_ISASCII /**/
-
-/* HAS_KILLPG
- * This symbol, if defined, indicates that the killpg routine is available
- * to kill process groups. If unavailable, you probably should use kill
- * with a negative process number.
- */
-#define HAS_KILLPG /**/
-
-/* HAS_LSTAT
- * This symbol, if defined, indicates that the lstat() routine is
- * available to stat symbolic links.
- */
-#define HAS_LSTAT /**/
-
-/* HAS_MEMCMP
- * This symbol, if defined, indicates that the memcmp routine is available
- * to compare blocks of memory. If undefined, roll your own.
- */
-#define HAS_MEMCMP /**/
-
-/* HAS_MEMCPY
- * This symbol, if defined, indicates that the memcpy routine is available
- * to copy blocks of memory. Otherwise you should probably use bcopy().
- * If neither is defined, roll your own.
- */
-/* SAFE_MEMCPY
- * This symbol, if defined, indicates that the memcpy routine is available
- * to copy potentially overlapping copy blocks of memory. Otherwise you
- * should probably use memmove() or bcopy(). If neither is defined,
- * roll your own.
- */
-#define HAS_MEMCPY /**/
-#define SAFE_MEMCPY /**/
-
-/* HAS_MEMMOVE
- * This symbol, if defined, indicates that the memmove routine is available
- * to move potentially overlapping blocks of memory. Otherwise you
- * should use bcopy() or roll your own.
- */
-#define HAS_MEMMOVE /**/
-
-/* HAS_MEMSET
- * This symbol, if defined, indicates that the memset routine is available
- * to set a block of memory to a character. If undefined, roll your own.
- */
-#define HAS_MEMSET /**/
-
-/* HAS_MKDIR
- * This symbol, if defined, indicates that the mkdir routine is available
- * to create directories. Otherwise you should fork off a new process to
- * exec /bin/mkdir.
- */
-#define HAS_MKDIR /**/
-
-
-/* HAS_NDBM
- * This symbol, if defined, indicates that ndbm.h exists and should
- * be included.
- */
-#define HAS_NDBM /**/
-
-/* HAS_ODBM
- * This symbol, if defined, indicates that dbm.h exists and should
- * be included.
- */
-
-/* HAS_OPEN3
- * This manifest constant lets the C program know that the three
- * argument form of open(2) is available.
- */
-#define HAS_OPEN3 /**/
-
-/* HAS_READDIR
- * This symbol, if defined, indicates that the readdir routine is available
- * from the C library to read directories.
- */
-#define HAS_READDIR /**/
-
-/* HAS_RENAME
- * This symbol, if defined, indicates that the rename routine is available
- * to rename files. Otherwise you should do the unlink(), link(), unlink()
- * trick.
- */
-#define HAS_RENAME /**/
-
-/* HAS_REWINDDIR
- * This symbol, if defined, indicates that the rewindir routine is
- * available to rewind directories.
- */
-#define HAS_REWINDDIR /**/
-
-/* HAS_RMDIR
- * This symbol, if defined, indicates that the rmdir routine is available
- * to remove directories. Otherwise you should fork off a new process to
- * exec /bin/rmdir.
- */
-#define HAS_RMDIR /**/
-
-/* HAS_SEEKDIR
- * This symbol, if defined, indicates that the seekdir routine is
- * available to seek into directories.
- */
-#define HAS_SEEKDIR /**/
-
-/* HAS_SELECT
- * This symbol, if defined, indicates that the select() subroutine
- * exists.
- */
-#define HAS_SELECT /**/
-
-/* HAS_SETEGID
- * This symbol, if defined, indicates that the setegid routine is available
- * to change the effective gid of the current program.
- * Do not use on systems with _POSIX_SAVED_IDS support.
- */
-/*#undef HAS_SETEGID /**/
-
-/* HAS_SETEUID
- * This symbol, if defined, indicates that the seteuid routine is available
- * to change the effective uid of the current program.
- * Do not use on systems with _POSIX_SAVED_IDS support.
- */
-/*#undef HAS_SETEUID /**/
-
-/* HAS_SETPGRP
- * This symbol, if defined, indicates that the setpgrp() routine is
- * available to set the current process group.
- */
-#define HAS_SETPGRP /**/
-
-/* HAS_SETPGRP2
- * This symbol, if defined, indicates that the setpgrp2() (as in DG/UX)
- * routine is available to set the current process group.
- */
-
-/* HAS_SETPRIORITY
- * This symbol, if defined, indicates that the setpriority() routine is
- * available to set a process's priority.
- */
-#define HAS_SETPRIORITY /**/
-
-/* HAS_SETREGID
- * This symbol, if defined, indicates that the setregid routine is
- * available to change the real and effective gid of the current program.
- */
-/* HAS_SETRESGID
- * This symbol, if defined, indicates that the setresgid routine is
- * available to change the real, effective and saved gid of the current
- * program.
- */
-#define HAS_SETREGID /**/
-
-/* HAS_SETREUID
- * This symbol, if defined, indicates that the setreuid routine is
- * available to change the real and effective uid of the current program.
- */
-/* HAS_SETRESUID
- * This symbol, if defined, indicates that the setresuid routine is
- * available to change the real, effective and saved uid of the current
- * program.
- */
-#define HAS_SETREUID /**/
-
-/* HAS_SETRGID
- * This symbol, if defined, indicates that the setrgid routine is available
- * to change the real gid of the current program.
- */
-#define HAS_SETRGID /**/
-
-/* HAS_SETRUID
- * This symbol, if defined, indicates that the setruid routine is available
- * to change the real uid of the current program.
- */
-#define HAS_SETRUID /**/
-
-
-/* HAS_SOCKET
- * This symbol, if defined, indicates that the BSD socket interface is
- * supported.
- */
-/* HAS_SOCKETPAIR
- * This symbol, if defined, indicates that the BSD socketpair call is
- * supported.
- */
-/* OLDSOCKET
- * This symbol, if defined, indicates that the 4.1c BSD socket interface
- * is supported instead of the 4.2/4.3 BSD socket interface.
- */
-#define HAS_SOCKET /**/
-
-#define HAS_SOCKETPAIR /**/
-
-
-/* STATBLOCKS
- * This symbol is defined if this system has a stat structure declaring
- * st_blksize and st_blocks.
- */
-#define STATBLOCKS /**/
-
-/* STDSTDIO
- * This symbol is defined if this system has a FILE structure declaring
- * _ptr and _cnt in stdio.h.
- */
-
-/* STRUCTCOPY
- * This symbol, if defined, indicates that this C compiler knows how
- * to copy structures. If undefined, you'll need to use a block copy
- * routine of some sort instead.
- */
-#define STRUCTCOPY /**/
-
-/* HAS_STRERROR
- * This symbol, if defined, indicates that the strerror() routine is
- * available to translate error numbers to strings.
- */
-#define HAS_STRERROR /**/
-
-/* HAS_SYMLINK
- * This symbol, if defined, indicates that the symlink routine is available
- * to create symbolic links.
- */
-#define HAS_SYMLINK /**/
-
-/* HAS_SYSCALL
- * This symbol, if defined, indicates that the syscall routine is available
- * to call arbitrary system calls. If undefined, that's tough.
- */
-#define HAS_SYSCALL /**/
-
-/* HAS_TELLDIR
- * This symbol, if defined, indicates that the telldir routine is
- * available to tell your location in directories.
- */
-#define HAS_TELLDIR /**/
-
-/* HAS_TRUNCATE
- * This symbol, if defined, indicates that the truncate routine is
- * available to truncate files.
- */
-#define HAS_TRUNCATE /**/
-
-/* HAS_VFORK
- * This symbol, if defined, indicates that vfork() exists.
- */
-#define HAS_VFORK /**/
-
-/* VOIDSIG
- * This symbol is defined if this system declares "void (*signal())()" in
- * signal.h. The old way was to declare it as "int (*signal())()". It
- * is up to the package author to declare things correctly based on the
- * symbol.
- */
-/* TO_SIGNAL
- * This symbol's value is either "void" or "int", corresponding to the
- * appropriate return "type" of a signal handler. Thus, one can declare
- * a signal handler using "TO_SIGNAL (*handler())()", and define the
- * handler using "TO_SIGNAL handler(sig)".
- */
-#define VOIDSIG /**/
-#define TO_SIGNAL int /**/
-
-/* HASVOLATILE
- * This symbol, if defined, indicates that this C compiler knows about
- * the volatile declaration.
- */
-#define HASVOLATILE /**/
-
-/* HAS_VPRINTF
- * This symbol, if defined, indicates that the vprintf routine is available
- * to printf with a pointer to an argument list. If unavailable, you
- * may need to write your own, probably in terms of _doprnt().
- */
-/* CHARVSPRINTF
- * This symbol is defined if this system has vsprintf() returning type
- * (char*). The trend seems to be to declare it as "int vsprintf()". It
- * is up to the package author to declare vsprintf correctly based on the
- * symbol.
- */
-#define HAS_VPRINTF /**/
-
-/* HAS_WAIT4
- * This symbol, if defined, indicates that wait4() exists.
- */
-#define HAS_WAIT4 /**/
-
-/* HAS_WAITPID
- * This symbol, if defined, indicates that waitpid() exists.
- */
-#define HAS_WAITPID /**/
-
-/* GIDTYPE
- * This symbol has a value like gid_t, int, ushort, or whatever type is
- * used to declare group ids in the kernel.
- */
-#define GIDTYPE gid_t /**/
-
-/* GROUPSTYPE
- * This symbol has a value like gid_t, int, ushort, or whatever type is
- * used in the return value of getgroups().
- */
-#define GROUPSTYPE gid_t /**/
-
-/* I_FCNTL
- * This manifest constant tells the C program to include <fcntl.h>.
- */
-
-/* I_GDBM
- * This symbol, if defined, indicates that gdbm.h exists and should
- * be included.
- */
-
-/* I_GRP
- * This symbol, if defined, indicates to the C program that it should
- * include grp.h.
- */
-#define I_GRP /**/
-
-/* I_NETINET_IN
- * This symbol, if defined, indicates to the C program that it should
- * include netinet/in.h.
- */
-/* I_SYS_IN
- * This symbol, if defined, indicates to the C program that it should
- * include sys/in.h.
- */
-#define I_NETINET_IN /**/
-
-/* I_PWD
- * This symbol, if defined, indicates to the C program that it should
- * include pwd.h.
- */
-/* PWQUOTA
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_quota.
- */
-/* PWAGE
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_age.
- */
-/* PWCHANGE
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_change.
- */
-/* PWCLASS
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_class.
- */
-/* PWEXPIRE
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_expire.
- */
-/* PWCOMMENT
- * This symbol, if defined, indicates to the C program that struct passwd
- * contains pw_comment.
- */
-#define I_PWD /**/
-#define PWCHANGE /**/
-#define PWCLASS /**/
-#define PWEXPIRE /**/
-
-/* I_SYS_FILE
- * This manifest constant tells the C program to include <sys/file.h>.
- */
-#define I_SYS_FILE /**/
-
-/* I_SYSIOCTL
- * This symbol, if defined, indicates that sys/ioctl.h exists and should
- * be included.
- */
-#define I_SYSIOCTL /**/
-
-/* I_TIME
- * This symbol is defined if the program should include <time.h>.
- */
-/* I_SYS_TIME
- * This symbol is defined if the program should include <sys/time.h>.
- */
-/* SYSTIMEKERNEL
- * This symbol is defined if the program should include <sys/time.h>
- * with KERNEL defined.
- */
-/* I_SYS_SELECT
- * This symbol is defined if the program should include <sys/select.h>.
- */
-#define I_SYS_TIME /**/
-
-/* I_UTIME
- * This symbol, if defined, indicates to the C program that it should
- * include utime.h.
- */
-#define I_UTIME /**/
-
-/* I_VARARGS
- * This symbol, if defined, indicates to the C program that it should
- * include varargs.h.
- */
-#define I_VARARGS /**/
-
-/* I_VFORK
- * This symbol, if defined, indicates to the C program that it should
- * include vfork.h.
- */
-
-/* INTSIZE
- * This symbol contains the size of an int, so that the C preprocessor
- * can make decisions based on it.
- */
-#define INTSIZE 4 /**/
-
-/* I_DIRENT
- * This symbol, if defined, indicates that the program should use the
- * P1003-style directory routines, and include <dirent.h>.
- */
-/* I_SYS_DIR
- * This symbol, if defined, indicates that the program should use the
- * directory functions by including <sys/dir.h>.
- */
-/* I_NDIR
- * This symbol, if defined, indicates that the program should include the
- * system's version of ndir.h, rather than the one with this package.
- */
-/* I_SYS_NDIR
- * This symbol, if defined, indicates that the program should include the
- * system's version of sys/ndir.h, rather than the one with this package.
- */
-/* I_MY_DIR
- * This symbol, if defined, indicates that the program should compile
- * the ndir.c code provided with the package.
- */
-/* DIRNAMLEN
- * This symbol, if defined, indicates to the C program that the length
- * of directory entry names is provided by a d_namlen field. Otherwise
- * you need to do strlen() on the d_name field.
- */
-#define I_DIRENT /**/
-
-/* MYMALLOC
- * This symbol, if defined, indicates that we're using our own malloc.
- */
-/* MALLOCPTRTYPE
- * This symbol defines the kind of ptr returned by malloc and realloc.
- */
-#define MYMALLOC /**/
-
-#define MALLOCPTRTYPE void /**/
-
-
-/* RANDBITS
- * This symbol contains the number of bits of random number the rand()
- * function produces. Usual values are 15, 16, and 31.
- */
-#define RANDBITS 31 /**/
-
-/* SCRIPTDIR
- * This symbol holds the name of the directory in which the user wants
- * to keep publicly executable scripts for the package in question. It
- * is often a directory that is mounted across diverse architectures.
- */
-#define SCRIPTDIR "/usr/bin" /**/
-
-/* SIG_NAME
- * This symbol contains an list of signal names in order.
- */
-#define SIG_NAME "ZERO","HUP","INT","QUIT","ILL","TRAP","ABRT","EMT","FPE","KILL","BUS","SEGV","SYS","PIPE","ALRM","TERM","URG","STOP","TSTP","CONT","CHLD","TTIN","TTOU","IO","XCPU","XFSZ","VTALRM","PROF","WINCH","INFO","USR1","USR2" /**/
-
-/* STDCHAR
- * This symbol is defined to be the type of char used in stdio.h.
- * It has the values "unsigned char" or "char".
- */
-#define STDCHAR char /**/
-
-/* UIDTYPE
- * This symbol has a value like uid_t, int, ushort, or whatever type is
- * used to declare user ids in the kernel.
- */
-#define UIDTYPE uid_t /**/
-
-/* VOIDHAVE
- * This symbol indicates how much support of the void type is given by this
- * compiler. What various bits mean:
- *
- * 1 = supports declaration of void
- * 2 = supports arrays of pointers to functions returning void
- * 4 = supports comparisons between pointers to void functions and
- * addresses of void functions
- *
- * The package designer should define VOIDWANT to indicate the requirements
- * of the package. This can be done either by #defining VOIDWANT before
- * including config.h, or by defining voidwant in Myinit.U. If the level
- * of void support necessary is not present, config.h defines void to "int",
- * VOID to the empty string, and VOIDP to "char *".
- */
-/* void
- * This symbol is used for void casts. On implementations which support
- * void appropriately, its value is "void". Otherwise, its value maps
- * to "int".
- */
-/* VOID
- * This symbol's value is "void" if the implementation supports void
- * appropriately. Otherwise, its value is the empty string. The primary
- * use of this symbol is in specifying void parameter lists for function
- * prototypes.
- */
-/* VOIDP
- * This symbol is used for casting generic pointers. On implementations
- * which support void appropriately, its value is "void *". Otherwise,
- * its value is "char *".
- */
-#ifndef VOIDWANT
-#define VOIDWANT 7
-#endif
-#define VOIDHAVE 7
-#if (VOIDHAVE & VOIDWANT) != VOIDWANT
-#define void int /* is void to be avoided? */
-#define VOID
-#define VOIDP (char *)
-#define M_VOID /* Xenix strikes again */
-#else
-#define VOID void
-#define VOIDP (void *)
-#endif
-
-/* PRIVLIB
- * This symbol contains the name of the private library for this package.
- * The library is private in the sense that it needn't be in anyone's
- * execution path, but it should be accessible by the world. The program
- * should be prepared to do ~ expansion.
- */
-#define PRIVLIB "/usr/share/perl" /**/
-
-#endif
diff --git a/gnu/usr.bin/perl/perl/config.sh b/gnu/usr.bin/perl/perl/config.sh
deleted file mode 100644
index a4196bd..0000000
--- a/gnu/usr.bin/perl/perl/config.sh
+++ /dev/null
@@ -1,268 +0,0 @@
-#!/bin/sh
-# config.sh
-# This file was produced by running the Configure script.
-d_eunice='undef'
-define='define'
-eunicefix=':'
-loclist='
-cat
-cp
-echo
-expr
-grep
-mkdir
-mv
-rm
-sed
-sort
-tr
-uniq
-'
-expr='/bin/expr'
-sed='/usr/bin/sed'
-echo='/bin/echo'
-cat='/bin/cat'
-rm='/bin/rm'
-mv='/bin/mv'
-cp='/bin/cp'
-tail=''
-tr='/usr/bin/tr'
-mkdir='/bin/mkdir'
-sort='/usr/bin/sort'
-uniq='/usr/bin/uniq'
-grep='/usr/bin/grep'
-trylist='
-Mcc
-bison
-cpp
-csh
-egrep
-line
-nroff
-perl
-test
-uname
-yacc
-'
-test='test'
-inews=''
-egrep='/usr/bin/egrep'
-more=''
-pg=''
-Mcc='Mcc'
-vi=''
-mailx=''
-mail=''
-cpp='/usr/bin/cpp'
-perl='perl'
-emacs=''
-ls=''
-rmail=''
-sendmail=''
-shar=''
-smail=''
-tbl=''
-troff=''
-nroff='/usr/bin/nroff'
-uname='uname'
-uuname=''
-line='line'
-chgrp=''
-chmod=''
-lint=''
-sleep=''
-pr=''
-tar=''
-ln=''
-lpr=''
-lp=''
-touch=''
-make=''
-date=''
-csh='/bin/csh'
-bash=''
-ksh=''
-lex=''
-flex=''
-bison='bison'
-Log='$Log'
-Header='$Header'
-Id='$Id'
-lastuname='uname: not found'
-alignbytes='4'
-bin='/usr/bin'
-installbin='/usr/bin'
-byteorder='1234'
-contains='grep'
-cppstdin='/usr/bin/cpp'
-cppminus=''
-d_bcmp='define'
-d_bcopy='define'
-d_safebcpy='define'
-d_bzero='define'
-d_castneg='define'
-castflags='0'
-d_charsprf='undef'
-d_chsize='undef'
-d_crypt='define'
-cryptlib='-lcrypt'
-d_csh='define'
-d_dosuid='define'
-d_dup2='define'
-d_fchmod='define'
-d_fchown='define'
-d_fcntl='define'
-d_flexfnam='define'
-d_flock='define'
-d_getgrps='define'
-d_gethent='undef'
-d_getpgrp='define'
-d_getpgrp2='undef'
-d_getprior='define'
-d_htonl='define'
-d_index='undef'
-d_isascii='undef'
-d_killpg='define'
-d_lstat='define'
-d_memcmp='define'
-d_memcpy='define'
-d_safemcpy='define'
-d_memmove='define'
-d_memset='define'
-d_mkdir='define'
-d_msg='define'
-d_msgctl='define'
-d_msgget='define'
-d_msgrcv='define'
-d_msgsnd='define'
-d_ndbm='define'
-d_odbm='undef'
-d_open3='define'
-d_readdir='define'
-d_rename='define'
-d_rewindir='define'
-d_rmdir='define'
-d_seekdir='define'
-d_select='define'
-d_sem='define'
-d_semctl='define'
-d_semget='define'
-d_semop='define'
-d_setegid='define'
-d_seteuid='define'
-d_setpgrp='define'
-d_setpgrp2='undef'
-d_setprior='define'
-d_setregid='define'
-d_setresgid='undef'
-d_setreuid='define'
-d_setresuid='undef'
-d_setrgid='define'
-d_setruid='define'
-d_shm='define'
-d_shmat='define'
-d_voidshmat='define'
-d_shmctl='define'
-d_shmdt='define'
-d_shmget='define'
-d_socket='define'
-d_sockpair='define'
-d_oldsock='undef'
-socketlib=''
-d_statblks='define'
-d_stdstdio='undef'
-d_strctcpy='define'
-d_strerror='define'
-d_symlink='define'
-d_syscall='define'
-d_telldir='define'
-d_truncate='define'
-d_vfork='define'
-d_voidsig='define'
-d_tosignal='int'
-d_volatile='define'
-d_vprintf='define'
-d_charvspr='undef'
-d_wait4='define'
-d_waitpid='define'
-gidtype='gid_t'
-groupstype='int'
-i_fcntl='undef'
-i_gdbm='undef'
-i_grp='define'
-i_niin='define'
-i_sysin='undef'
-i_pwd='define'
-d_pwquota='undef'
-d_pwage='undef'
-d_pwchange='define'
-d_pwclass='define'
-d_pwexpire='define'
-d_pwcomment='undef'
-i_sys_file='define'
-i_sysioctl='define'
-i_time='undef'
-i_sys_time='define'
-i_sys_select='undef'
-d_systimekernel='undef'
-i_utime='define'
-i_varargs='define'
-i_vfork='undef'
-intsize='4'
-libc='/usr/lib/libc.so.1.0'
-nm_opts=''
-libndir=''
-i_my_dir='undef'
-i_ndir='undef'
-i_sys_ndir='undef'
-i_dirent='define'
-i_sys_dir='undef'
-d_dirnamlen='define'
-ndirc=''
-ndiro=''
-mallocsrc='malloc.c'
-mallocobj='malloc.o'
-d_mymalloc='define'
-mallocptrtype='void'
-mansrc='/usr/man/man1'
-manext='1'
-models='none'
-split=''
-small=''
-medium=''
-large=''
-huge=''
-optimize='-O'
-ccflags=''
-cppflags=''
-ldflags=''
-cc='cc'
-nativegcc=''
-libs='-lm'
-n='-n'
-c=''
-package='perl'
-randbits='31'
-scriptdir='/usr/bin'
-installscr='/usr/bin'
-sig_name='ZERO HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH INFO USR1 USR2'
-spitshell='cat'
-shsharp='true'
-sharpbang='#!'
-startsh='#!/bin/sh'
-stdchar='char'
-uidtype='uid_t'
-usrinclude='/usr/include'
-inclPath=''
-void=''
-voidhave='7'
-voidwant='7'
-w_localtim='1'
-w_s_timevl='1'
-w_s_tm='1'
-yacc='/usr/bin/yacc'
-lib=''
-privlib='/usr/share/perl'
-installprivlib='/usr/share/perl'
-PATCHLEVEL=36
-CONFIG=true
diff --git a/gnu/usr.bin/perl/perl/cons.c b/gnu/usr.bin/perl/perl/cons.c
deleted file mode 100644
index bbf783e..0000000
--- a/gnu/usr.bin/perl/perl/cons.c
+++ /dev/null
@@ -1,1453 +0,0 @@
-/* $RCSfile: cons.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:32 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: cons.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:32 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:35 nate
- * PERL!
- *
- * Revision 4.0.1.4 1993/02/05 19:30:15 lwall
- * patch36: fixed various little coredump bugs
- *
- * Revision 4.0.1.3 92/06/08 12:18:35 lwall
- * patch20: removed implicit int declarations on funcions
- * patch20: deleted some minor memory leaks
- * patch20: fixed double debug break in foreach with implicit array assignment
- * patch20: fixed confusion between a *var's real name and its effective name
- * patch20: Perl now distinguishes overlapped copies from non-overlapped
- * patch20: debugger sometimes displayed wrong source line
- * patch20: various error messages have been clarified
- * patch20: an eval block containing a null block or statement could dump core
- *
- * Revision 4.0.1.2 91/11/05 16:15:13 lwall
- * patch11: debugger got confused over nested subroutine definitions
- * patch11: prepared for ctype implementations that don't define isascii()
- *
- * Revision 4.0.1.1 91/06/07 10:31:15 lwall
- * patch4: new copyright notice
- * patch4: added global modifier for pattern matches
- *
- * Revision 4.0 91/03/20 01:05:51 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-#include "perly.h"
-
-extern char *tokename[];
-extern int yychar;
-
-static int cmd_tosave();
-static int arg_tosave();
-static int spat_tosave();
-static void make_cswitch();
-static void make_nswitch();
-
-static bool saw_return;
-
-SUBR *
-make_sub(name,cmd)
-char *name;
-CMD *cmd;
-{
- register SUBR *sub;
- STAB *stab = stabent(name,TRUE);
-
- if (sub = stab_sub(stab)) {
- if (dowarn) {
- CMD *oldcurcmd = curcmd;
-
- if (cmd)
- curcmd = cmd;
- warn("Subroutine %s redefined",name);
- curcmd = oldcurcmd;
- }
- if (!sub->usersub && sub->cmd) {
- cmd_free(sub->cmd);
- sub->cmd = Nullcmd;
- afree(sub->tosave);
- }
- Safefree(sub);
- }
- Newz(101,sub,1,SUBR);
- stab_sub(stab) = sub;
- sub->filestab = curcmd->c_filestab;
- saw_return = FALSE;
- tosave = anew(Nullstab);
- tosave->ary_fill = 0; /* make 1 based */
- (void)cmd_tosave(cmd,FALSE); /* this builds the tosave array */
- sub->tosave = tosave;
- if (saw_return) {
- struct compcmd mycompblock;
-
- mycompblock.comp_true = cmd;
- mycompblock.comp_alt = Nullcmd;
- cmd = add_label(savestr("_SUB_"),make_ccmd(C_BLOCK,0,
- Nullarg,mycompblock));
- saw_return = FALSE;
- cmd->c_flags |= CF_TERM;
- cmd->c_head = cmd;
- }
- sub->cmd = cmd;
- if (perldb) {
- STR *str;
- STR *tmpstr = str_mortal(&str_undef);
-
- sprintf(buf,"%s:%ld",stab_val(curcmd->c_filestab)->str_ptr, subline);
- str = str_make(buf,0);
- str_cat(str,"-");
- sprintf(buf,"%ld",(long)curcmd->c_line);
- str_cat(str,buf);
- stab_efullname(tmpstr,stab);
- hstore(stab_xhash(DBsub), tmpstr->str_ptr, tmpstr->str_cur, str, 0);
- }
- Safefree(name);
- return sub;
-}
-
-SUBR *
-make_usub(name, ix, subaddr, filename)
-char *name;
-int ix;
-int (*subaddr)();
-char *filename;
-{
- register SUBR *sub;
- STAB *stab = stabent(name,allstabs);
-
- if (!stab) /* unused function */
- return Null(SUBR*);
- if (sub = stab_sub(stab)) {
- if (dowarn)
- warn("Subroutine %s redefined",name);
- if (!sub->usersub && sub->cmd) {
- cmd_free(sub->cmd);
- sub->cmd = Nullcmd;
- afree(sub->tosave);
- }
- Safefree(sub);
- }
- Newz(101,sub,1,SUBR);
- stab_sub(stab) = sub;
- sub->filestab = fstab(filename);
- sub->usersub = subaddr;
- sub->userindex = ix;
- return sub;
-}
-
-void
-make_form(stab,fcmd)
-STAB *stab;
-FCMD *fcmd;
-{
- if (stab_form(stab)) {
- FCMD *tmpfcmd;
- FCMD *nextfcmd;
-
- for (tmpfcmd = stab_form(stab); tmpfcmd; tmpfcmd = nextfcmd) {
- nextfcmd = tmpfcmd->f_next;
- if (tmpfcmd->f_expr)
- arg_free(tmpfcmd->f_expr);
- if (tmpfcmd->f_unparsed)
- str_free(tmpfcmd->f_unparsed);
- if (tmpfcmd->f_pre)
- Safefree(tmpfcmd->f_pre);
- Safefree(tmpfcmd);
- }
- }
- stab_form(stab) = fcmd;
-}
-
-CMD *
-block_head(tail)
-register CMD *tail;
-{
- CMD *head;
- register int opt;
- register int last_opt = 0;
- register STAB *last_stab = Nullstab;
- register int count = 0;
- register CMD *switchbeg = Nullcmd;
-
- if (tail == Nullcmd) {
- return tail;
- }
- head = tail->c_head;
-
- for (tail = head; tail; tail = tail->c_next) {
-
- /* save one measly dereference at runtime */
- if (tail->c_type == C_IF) {
- if (!(tail->ucmd.ccmd.cc_alt = tail->ucmd.ccmd.cc_alt->c_next))
- tail->c_flags |= CF_TERM;
- }
- else if (tail->c_type == C_EXPR) {
- ARG *arg;
-
- if (tail->ucmd.acmd.ac_expr)
- arg = tail->ucmd.acmd.ac_expr;
- else
- arg = tail->c_expr;
- if (arg) {
- if (arg->arg_type == O_RETURN)
- tail->c_flags |= CF_TERM;
- else if (arg->arg_type == O_ITEM && arg[1].arg_type == A_CMD)
- tail->c_flags |= CF_TERM;
- }
- }
- if (!tail->c_next)
- tail->c_flags |= CF_TERM;
-
- if (tail->c_expr && (tail->c_flags & CF_OPTIMIZE) == CFT_FALSE)
- opt_arg(tail,1, tail->c_type == C_EXPR);
-
- /* now do a little optimization on case-ish structures */
- switch(tail->c_flags & (CF_OPTIMIZE|CF_FIRSTNEG|CF_INVERT)) {
- case CFT_ANCHOR:
- case CFT_STROP:
- opt = (tail->c_flags & CF_NESURE) ? CFT_STROP : 0;
- break;
- case CFT_CCLASS:
- opt = CFT_STROP;
- break;
- case CFT_NUMOP:
- opt = (tail->c_slen == O_NE ? 0 : CFT_NUMOP);
- if ((tail->c_flags&(CF_NESURE|CF_EQSURE)) != (CF_NESURE|CF_EQSURE))
- opt = 0;
- break;
- default:
- opt = 0;
- }
- if (opt && opt == last_opt && tail->c_stab == last_stab)
- count++;
- else {
- if (count >= 3) { /* is this the breakeven point? */
- if (last_opt == CFT_NUMOP)
- make_nswitch(switchbeg,count);
- else
- make_cswitch(switchbeg,count);
- }
- if (opt) {
- count = 1;
- switchbeg = tail;
- }
- else
- count = 0;
- }
- last_opt = opt;
- last_stab = tail->c_stab;
- }
- if (count >= 3) { /* is this the breakeven point? */
- if (last_opt == CFT_NUMOP)
- make_nswitch(switchbeg,count);
- else
- make_cswitch(switchbeg,count);
- }
- return head;
-}
-
-/* We've spotted a sequence of CMDs that all test the value of the same
- * spat. Thus we can insert a SWITCH in front and jump directly
- * to the correct one.
- */
-static void
-make_cswitch(head,count)
-register CMD *head;
-int count;
-{
- register CMD *cur;
- register CMD **loc;
- register int i;
- register int min = 255;
- register int max = 0;
-
- /* make a new head in the exact same spot */
- New(102,cur, 1, CMD);
- StructCopy(head,cur,CMD);
- Zero(head,1,CMD);
- head->c_head = cur->c_head;
- head->c_type = C_CSWITCH;
- head->c_next = cur; /* insert new cmd at front of list */
- head->c_stab = cur->c_stab;
-
- Newz(103,loc,258,CMD*);
- loc++; /* lie a little */
- while (count--) {
- if ((cur->c_flags & CF_OPTIMIZE) == CFT_CCLASS) {
- for (i = 0; i <= 255; i++) {
- if (!loc[i] && cur->c_short->str_ptr[i>>3] & (1 << (i&7))) {
- loc[i] = cur;
- if (i < min)
- min = i;
- if (i > max)
- max = i;
- }
- }
- }
- else {
- i = *cur->c_short->str_ptr & 255;
- if (!loc[i]) {
- loc[i] = cur;
- if (i < min)
- min = i;
- if (i > max)
- max = i;
- }
- }
- cur = cur->c_next;
- }
- max++;
- if (min > 0)
- Move(&loc[min],&loc[0], max - min, CMD*);
- loc--;
- min--;
- max -= min;
- for (i = 0; i <= max; i++)
- if (!loc[i])
- loc[i] = cur;
- Renew(loc,max+1,CMD*); /* chop it down to size */
- head->ucmd.scmd.sc_offset = min;
- head->ucmd.scmd.sc_max = max;
- head->ucmd.scmd.sc_next = loc;
-}
-
-static void
-make_nswitch(head,count)
-register CMD *head;
-int count;
-{
- register CMD *cur = head;
- register CMD **loc;
- register int i;
- register int min = 32767;
- register int max = -32768;
- int origcount = count;
- double value; /* or your money back! */
- short changed; /* so triple your money back! */
-
- while (count--) {
- i = (int)str_gnum(cur->c_short);
- value = (double)i;
- if (value != cur->c_short->str_u.str_nval)
- return; /* fractional values--just forget it */
- changed = i;
- if (changed != i)
- return; /* too big for a short */
- if (cur->c_slen == O_LE)
- i++;
- else if (cur->c_slen == O_GE) /* we only do < or > here */
- i--;
- if (i < min)
- min = i;
- if (i > max)
- max = i;
- cur = cur->c_next;
- }
- count = origcount;
- if (max - min > count * 2 + 10) /* too sparse? */
- return;
-
- /* now make a new head in the exact same spot */
- New(104,cur, 1, CMD);
- StructCopy(head,cur,CMD);
- Zero(head,1,CMD);
- head->c_head = cur->c_head;
- head->c_type = C_NSWITCH;
- head->c_next = cur; /* insert new cmd at front of list */
- head->c_stab = cur->c_stab;
-
- Newz(105,loc, max - min + 3, CMD*);
- loc++;
- max -= min;
- max++;
- while (count--) {
- i = (int)str_gnum(cur->c_short);
- i -= min;
- switch(cur->c_slen) {
- case O_LE:
- i++;
- case O_LT:
- for (i--; i >= -1; i--)
- if (!loc[i])
- loc[i] = cur;
- break;
- case O_GE:
- i--;
- case O_GT:
- for (i++; i <= max; i++)
- if (!loc[i])
- loc[i] = cur;
- break;
- case O_EQ:
- if (!loc[i])
- loc[i] = cur;
- break;
- }
- cur = cur->c_next;
- }
- loc--;
- min--;
- max++;
- for (i = 0; i <= max; i++)
- if (!loc[i])
- loc[i] = cur;
- head->ucmd.scmd.sc_offset = min;
- head->ucmd.scmd.sc_max = max;
- head->ucmd.scmd.sc_next = loc;
-}
-
-CMD *
-append_line(head,tail)
-register CMD *head;
-register CMD *tail;
-{
- if (tail == Nullcmd)
- return head;
- if (!tail->c_head) /* make sure tail is well formed */
- tail->c_head = tail;
- if (head != Nullcmd) {
- tail = tail->c_head; /* get to start of tail list */
- if (!head->c_head)
- head->c_head = head; /* start a new head list */
- while (head->c_next) {
- head->c_next->c_head = head->c_head;
- head = head->c_next; /* get to end of head list */
- }
- head->c_next = tail; /* link to end of old list */
- tail->c_head = head->c_head; /* propagate head pointer */
- }
- while (tail->c_next) {
- tail->c_next->c_head = tail->c_head;
- tail = tail->c_next;
- }
- return tail;
-}
-
-CMD *
-dodb(cur)
-CMD *cur;
-{
- register CMD *cmd;
- register CMD *head = cur->c_head;
- STR *str;
-
- if (!head)
- head = cur;
- if (!head->c_line)
- return cur;
- str = afetch(stab_xarray(curcmd->c_filestab),(int)head->c_line,FALSE);
- if (str == &str_undef || str->str_nok)
- return cur;
- str->str_u.str_nval = (double)head->c_line;
- str->str_nok = 1;
- Newz(106,cmd,1,CMD);
- str_magic(str, curcmd->c_filestab, 0, Nullch, 0);
- str->str_magic->str_u.str_cmd = cmd;
- cmd->c_type = C_EXPR;
- cmd->ucmd.acmd.ac_stab = Nullstab;
- cmd->ucmd.acmd.ac_expr = Nullarg;
- cmd->c_expr = make_op(O_SUBR, 2,
- stab2arg(A_WORD,DBstab),
- Nullarg,
- Nullarg);
- /*SUPPRESS 53*/
- cmd->c_flags |= CF_COND|CF_DBSUB|CFT_D0;
- cmd->c_line = head->c_line;
- cmd->c_label = head->c_label;
- cmd->c_filestab = curcmd->c_filestab;
- cmd->c_stash = curstash;
- return append_line(cmd, cur);
-}
-
-CMD *
-make_acmd(type,stab,cond,arg)
-int type;
-STAB *stab;
-ARG *cond;
-ARG *arg;
-{
- register CMD *cmd;
-
- Newz(107,cmd,1,CMD);
- cmd->c_type = type;
- cmd->ucmd.acmd.ac_stab = stab;
- cmd->ucmd.acmd.ac_expr = arg;
- cmd->c_expr = cond;
- if (cond)
- cmd->c_flags |= CF_COND;
- if (cmdline == NOLINE)
- cmd->c_line = curcmd->c_line;
- else {
- cmd->c_line = cmdline;
- cmdline = NOLINE;
- }
- cmd->c_filestab = curcmd->c_filestab;
- cmd->c_stash = curstash;
- if (perldb)
- cmd = dodb(cmd);
- return cmd;
-}
-
-CMD *
-make_ccmd(type,debuggable,arg,cblock)
-int type;
-int debuggable;
-ARG *arg;
-struct compcmd cblock;
-{
- register CMD *cmd;
-
- Newz(108,cmd, 1, CMD);
- cmd->c_type = type;
- cmd->c_expr = arg;
- cmd->ucmd.ccmd.cc_true = cblock.comp_true;
- cmd->ucmd.ccmd.cc_alt = cblock.comp_alt;
- if (arg)
- cmd->c_flags |= CF_COND;
- if (cmdline == NOLINE)
- cmd->c_line = curcmd->c_line;
- else {
- cmd->c_line = cmdline;
- cmdline = NOLINE;
- }
- cmd->c_filestab = curcmd->c_filestab;
- cmd->c_stash = curstash;
- if (perldb && debuggable)
- cmd = dodb(cmd);
- return cmd;
-}
-
-CMD *
-make_icmd(type,arg,cblock)
-int type;
-ARG *arg;
-struct compcmd cblock;
-{
- register CMD *cmd;
- register CMD *alt;
- register CMD *cur;
- register CMD *head;
- struct compcmd ncblock;
-
- Newz(109,cmd, 1, CMD);
- head = cmd;
- cmd->c_type = type;
- cmd->c_expr = arg;
- cmd->ucmd.ccmd.cc_true = cblock.comp_true;
- cmd->ucmd.ccmd.cc_alt = cblock.comp_alt;
- if (arg)
- cmd->c_flags |= CF_COND;
- if (cmdline == NOLINE)
- cmd->c_line = curcmd->c_line;
- else {
- cmd->c_line = cmdline;
- cmdline = NOLINE;
- }
- cmd->c_filestab = curcmd->c_filestab;
- cmd->c_stash = curstash;
- cur = cmd;
- alt = cblock.comp_alt;
- while (alt && alt->c_type == C_ELSIF) {
- cur = alt;
- alt = alt->ucmd.ccmd.cc_alt;
- }
- if (alt) { /* a real life ELSE at the end? */
- ncblock.comp_true = alt;
- ncblock.comp_alt = Nullcmd;
- alt = append_line(cur,make_ccmd(C_ELSE,1,Nullarg,ncblock));
- cur->ucmd.ccmd.cc_alt = alt;
- }
- else
- alt = cur; /* no ELSE, so cur is proxy ELSE */
-
- cur = cmd;
- while (cmd) { /* now point everyone at the ELSE */
- cur = cmd;
- cmd = cur->ucmd.ccmd.cc_alt;
- cur->c_head = head;
- if (cur->c_type == C_ELSIF)
- cur->c_type = C_IF;
- if (cur->c_type == C_IF)
- cur->ucmd.ccmd.cc_alt = alt;
- if (cur == alt)
- break;
- cur->c_next = cmd;
- }
- if (perldb)
- cur = dodb(cur);
- return cur;
-}
-
-void
-opt_arg(cmd,fliporflop,acmd)
-register CMD *cmd;
-int fliporflop;
-int acmd;
-{
- register ARG *arg;
- int opt = CFT_EVAL;
- int sure = 0;
- ARG *arg2;
- int context = 0; /* 0 = normal, 1 = before &&, 2 = before || */
- int flp = fliporflop;
-
- if (!cmd)
- return;
- if (!(arg = cmd->c_expr)) {
- cmd->c_flags &= ~CF_COND;
- return;
- }
-
- /* Can we turn && and || into if and unless? */
-
- if (acmd && !cmd->ucmd.acmd.ac_expr && !(cmd->c_flags & CF_TERM) &&
- (arg->arg_type == O_AND || arg->arg_type == O_OR) ) {
- dehoist(arg,1);
- arg[2].arg_type &= A_MASK; /* don't suppress eval */
- dehoist(arg,2);
- cmd->ucmd.acmd.ac_expr = arg[2].arg_ptr.arg_arg;
- cmd->c_expr = arg[1].arg_ptr.arg_arg;
- if (arg->arg_type == O_OR)
- cmd->c_flags ^= CF_INVERT; /* || is like unless */
- arg->arg_len = 0;
- free_arg(arg);
- arg = cmd->c_expr;
- }
-
- /* Turn "if (!expr)" into "unless (expr)" */
-
- if (!(cmd->c_flags & CF_TERM)) { /* unless return value wanted */
- while (arg->arg_type == O_NOT) {
- dehoist(arg,1);
- cmd->c_flags ^= CF_INVERT; /* flip sense of cmd */
- cmd->c_expr = arg[1].arg_ptr.arg_arg; /* hoist the rest of expr */
- free_arg(arg);
- arg = cmd->c_expr; /* here we go again */
- }
- }
-
- if (!arg->arg_len) { /* sanity check */
- cmd->c_flags |= opt;
- return;
- }
-
- /* for "cond .. cond" we set up for the initial check */
-
- if (arg->arg_type == O_FLIP)
- context |= 4;
-
- /* for "cond && expr" and "cond || expr" we can ignore expr, sort of */
-
- morecontext:
- if (arg->arg_type == O_AND)
- context |= 1;
- else if (arg->arg_type == O_OR)
- context |= 2;
- if (context && (arg[flp].arg_type & A_MASK) == A_EXPR) {
- arg = arg[flp].arg_ptr.arg_arg;
- flp = 1;
- if (arg->arg_type == O_AND || arg->arg_type == O_OR)
- goto morecontext;
- }
- if ((context & 3) == 3)
- return;
-
- if (arg[flp].arg_flags & (AF_PRE|AF_POST)) {
- cmd->c_flags |= opt;
- if (acmd && !cmd->ucmd.acmd.ac_expr && !(cmd->c_flags & CF_TERM)
- && cmd->c_expr->arg_type == O_ITEM) {
- arg[flp].arg_flags &= ~AF_POST; /* prefer ++$foo to $foo++ */
- arg[flp].arg_flags |= AF_PRE; /* if value not wanted */
- }
- return; /* side effect, can't optimize */
- }
-
- if (arg->arg_type == O_ITEM || arg->arg_type == O_FLIP ||
- arg->arg_type == O_AND || arg->arg_type == O_OR) {
- if ((arg[flp].arg_type & A_MASK) == A_SINGLE) {
- opt = (str_true(arg[flp].arg_ptr.arg_str) ? CFT_TRUE : CFT_FALSE);
- cmd->c_short = str_smake(arg[flp].arg_ptr.arg_str);
- goto literal;
- }
- else if ((arg[flp].arg_type & A_MASK) == A_STAB ||
- (arg[flp].arg_type & A_MASK) == A_LVAL) {
- cmd->c_stab = arg[flp].arg_ptr.arg_stab;
- if (!context)
- arg[flp].arg_ptr.arg_stab = Nullstab;
- opt = CFT_REG;
- literal:
- if (!context) { /* no && or ||? */
- arg_free(arg);
- cmd->c_expr = Nullarg;
- }
- if (!(context & 1))
- cmd->c_flags |= CF_EQSURE;
- if (!(context & 2))
- cmd->c_flags |= CF_NESURE;
- }
- }
- else if (arg->arg_type == O_MATCH || arg->arg_type == O_SUBST ||
- arg->arg_type == O_NMATCH || arg->arg_type == O_NSUBST) {
- if ((arg[1].arg_type == A_STAB || arg[1].arg_type == A_LVAL) &&
- (arg[2].arg_type & A_MASK) == A_SPAT &&
- arg[2].arg_ptr.arg_spat->spat_short &&
- (arg->arg_type == O_SUBST || arg->arg_type == O_NSUBST ||
- (arg[2].arg_ptr.arg_spat->spat_flags & SPAT_GLOBAL) == 0 )) {
- cmd->c_stab = arg[1].arg_ptr.arg_stab;
- cmd->c_short = str_smake(arg[2].arg_ptr.arg_spat->spat_short);
- cmd->c_slen = arg[2].arg_ptr.arg_spat->spat_slen;
- if (arg[2].arg_ptr.arg_spat->spat_flags & SPAT_ALL &&
- !(arg[2].arg_ptr.arg_spat->spat_flags & SPAT_ONCE) &&
- (arg->arg_type == O_MATCH || arg->arg_type == O_NMATCH) )
- sure |= CF_EQSURE; /* (SUBST must be forced even */
- /* if we know it will work.) */
- if (arg->arg_type != O_SUBST) {
- str_free(arg[2].arg_ptr.arg_spat->spat_short);
- arg[2].arg_ptr.arg_spat->spat_short = Nullstr;
- arg[2].arg_ptr.arg_spat->spat_slen = 0; /* only one chk */
- }
- sure |= CF_NESURE; /* normally only sure if it fails */
- if (arg->arg_type == O_NMATCH || arg->arg_type == O_NSUBST)
- cmd->c_flags |= CF_FIRSTNEG;
- if (context & 1) { /* only sure if thing is false */
- if (cmd->c_flags & CF_FIRSTNEG)
- sure &= ~CF_NESURE;
- else
- sure &= ~CF_EQSURE;
- }
- else if (context & 2) { /* only sure if thing is true */
- if (cmd->c_flags & CF_FIRSTNEG)
- sure &= ~CF_EQSURE;
- else
- sure &= ~CF_NESURE;
- }
- if (sure & (CF_EQSURE|CF_NESURE)) { /* if we know anything*/
- if (arg[2].arg_ptr.arg_spat->spat_flags & SPAT_SCANFIRST)
- opt = CFT_SCAN;
- else
- opt = CFT_ANCHOR;
- if (sure == (CF_EQSURE|CF_NESURE) /* really sure? */
- && arg->arg_type == O_MATCH
- && context & 4
- && fliporflop == 1) {
- spat_free(arg[2].arg_ptr.arg_spat);
- arg[2].arg_ptr.arg_spat = Nullspat; /* don't do twice */
- }
- else
- cmd->c_spat = arg[2].arg_ptr.arg_spat;
- cmd->c_flags |= sure;
- }
- }
- }
- else if (arg->arg_type == O_SEQ || arg->arg_type == O_SNE ||
- arg->arg_type == O_SLT || arg->arg_type == O_SGT) {
- if (arg[1].arg_type == A_STAB || arg[1].arg_type == A_LVAL) {
- if (arg[2].arg_type == A_SINGLE) {
- /*SUPPRESS 594*/
- char *junk = str_get(arg[2].arg_ptr.arg_str);
-
- cmd->c_stab = arg[1].arg_ptr.arg_stab;
- cmd->c_short = str_smake(arg[2].arg_ptr.arg_str);
- cmd->c_slen = cmd->c_short->str_cur+1;
- switch (arg->arg_type) {
- case O_SLT: case O_SGT:
- sure |= CF_EQSURE;
- cmd->c_flags |= CF_FIRSTNEG;
- break;
- case O_SNE:
- cmd->c_flags |= CF_FIRSTNEG;
- /* FALL THROUGH */
- case O_SEQ:
- sure |= CF_NESURE|CF_EQSURE;
- break;
- }
- if (context & 1) { /* only sure if thing is false */
- if (cmd->c_flags & CF_FIRSTNEG)
- sure &= ~CF_NESURE;
- else
- sure &= ~CF_EQSURE;
- }
- else if (context & 2) { /* only sure if thing is true */
- if (cmd->c_flags & CF_FIRSTNEG)
- sure &= ~CF_EQSURE;
- else
- sure &= ~CF_NESURE;
- }
- if (sure & (CF_EQSURE|CF_NESURE)) {
- opt = CFT_STROP;
- cmd->c_flags |= sure;
- }
- }
- }
- }
- else if (arg->arg_type == O_EQ || arg->arg_type == O_NE ||
- arg->arg_type == O_LE || arg->arg_type == O_GE ||
- arg->arg_type == O_LT || arg->arg_type == O_GT) {
- if (arg[1].arg_type == A_STAB || arg[1].arg_type == A_LVAL) {
- if (arg[2].arg_type == A_SINGLE) {
- cmd->c_stab = arg[1].arg_ptr.arg_stab;
- if (dowarn) {
- STR *str = arg[2].arg_ptr.arg_str;
-
- if ((!str->str_nok && !looks_like_number(str)))
- warn("Possible use of == on string value");
- }
- cmd->c_short = str_nmake(str_gnum(arg[2].arg_ptr.arg_str));
- cmd->c_slen = arg->arg_type;
- sure |= CF_NESURE|CF_EQSURE;
- if (context & 1) { /* only sure if thing is false */
- sure &= ~CF_EQSURE;
- }
- else if (context & 2) { /* only sure if thing is true */
- sure &= ~CF_NESURE;
- }
- if (sure & (CF_EQSURE|CF_NESURE)) {
- opt = CFT_NUMOP;
- cmd->c_flags |= sure;
- }
- }
- }
- }
- else if (arg->arg_type == O_ASSIGN &&
- (arg[1].arg_type == A_STAB || arg[1].arg_type == A_LVAL) &&
- arg[1].arg_ptr.arg_stab == defstab &&
- arg[2].arg_type == A_EXPR ) {
- arg2 = arg[2].arg_ptr.arg_arg;
- if (arg2->arg_type == O_ITEM && arg2[1].arg_type == A_READ) {
- opt = CFT_GETS;
- cmd->c_stab = arg2[1].arg_ptr.arg_stab;
- if (!(stab_io(arg2[1].arg_ptr.arg_stab)->flags & IOF_ARGV)) {
- free_arg(arg2);
- arg[2].arg_ptr.arg_arg = Nullarg;
- free_arg(arg);
- cmd->c_expr = Nullarg;
- }
- }
- }
- else if (arg->arg_type == O_CHOP &&
- (arg[1].arg_type == A_STAB || arg[1].arg_type == A_LVAL) ) {
- opt = CFT_CHOP;
- cmd->c_stab = arg[1].arg_ptr.arg_stab;
- free_arg(arg);
- cmd->c_expr = Nullarg;
- }
- if (context & 4)
- opt |= CF_FLIP;
- cmd->c_flags |= opt;
-
- if (cmd->c_flags & CF_FLIP) {
- if (fliporflop == 1) {
- arg = cmd->c_expr; /* get back to O_FLIP arg */
- New(110,arg[3].arg_ptr.arg_cmd, 1, CMD);
- Copy(cmd, arg[3].arg_ptr.arg_cmd, 1, CMD);
- New(111,arg[4].arg_ptr.arg_cmd,1,CMD);
- Copy(cmd, arg[4].arg_ptr.arg_cmd, 1, CMD);
- opt_arg(arg[4].arg_ptr.arg_cmd,2,acmd);
- arg->arg_len = 2; /* this is a lie */
- }
- else {
- if ((opt & CF_OPTIMIZE) == CFT_EVAL)
- cmd->c_flags = (cmd->c_flags & ~CF_OPTIMIZE) | CFT_UNFLIP;
- }
- }
-}
-
-CMD *
-add_label(lbl,cmd)
-char *lbl;
-register CMD *cmd;
-{
- if (cmd)
- cmd->c_label = lbl;
- return cmd;
-}
-
-CMD *
-addcond(cmd, arg)
-register CMD *cmd;
-register ARG *arg;
-{
- cmd->c_expr = arg;
- cmd->c_flags |= CF_COND;
- return cmd;
-}
-
-CMD *
-addloop(cmd, arg)
-register CMD *cmd;
-register ARG *arg;
-{
- void while_io();
-
- cmd->c_expr = arg;
- cmd->c_flags |= CF_COND|CF_LOOP;
-
- if (!(cmd->c_flags & CF_INVERT))
- while_io(cmd); /* add $_ =, if necessary */
-
- if (cmd->c_type == C_BLOCK)
- cmd->c_flags &= ~CF_COND;
- else {
- arg = cmd->ucmd.acmd.ac_expr;
- if (arg && arg->arg_type == O_ITEM && arg[1].arg_type == A_CMD)
- cmd->c_flags &= ~CF_COND; /* "do {} while" happens at least once */
- if (arg && (arg->arg_flags & AF_DEPR) &&
- (arg->arg_type == O_SUBR || arg->arg_type == O_DBSUBR) )
- cmd->c_flags &= ~CF_COND; /* likewise for "do subr() while" */
- }
- return cmd;
-}
-
-CMD *
-invert(cmd)
-CMD *cmd;
-{
- register CMD *targ = cmd;
- if (targ->c_head)
- targ = targ->c_head;
- if (targ->c_flags & CF_DBSUB)
- targ = targ->c_next;
- targ->c_flags ^= CF_INVERT;
- return cmd;
-}
-
-void
-cpy7bit(d,s,l)
-register char *d;
-register char *s;
-register int l;
-{
- while (l--)
- *d++ = *s++ & 127;
- *d = '\0';
-}
-
-int
-yyerror(s)
-char *s;
-{
- char tmpbuf[258];
- char tmp2buf[258];
- char *tname = tmpbuf;
-
- if (bufptr > oldoldbufptr && bufptr - oldoldbufptr < 200 &&
- oldoldbufptr != oldbufptr && oldbufptr != bufptr) {
- while (isSPACE(*oldoldbufptr))
- oldoldbufptr++;
- cpy7bit(tmp2buf, oldoldbufptr, bufptr - oldoldbufptr);
- sprintf(tname,"next 2 tokens \"%s\"",tmp2buf);
- }
- else if (bufptr > oldbufptr && bufptr - oldbufptr < 200 &&
- oldbufptr != bufptr) {
- while (isSPACE(*oldbufptr))
- oldbufptr++;
- cpy7bit(tmp2buf, oldbufptr, bufptr - oldbufptr);
- sprintf(tname,"next token \"%s\"",tmp2buf);
- }
- else if (yychar > 256)
- tname = "next token ???";
- else if (!yychar)
- (void)strcpy(tname,"at EOF");
- else if (yychar < 32)
- (void)sprintf(tname,"next char ^%c",yychar+64);
- else if (yychar == 127)
- (void)strcpy(tname,"at EOF");
- else
- (void)sprintf(tname,"next char %c",yychar);
- (void)sprintf(buf, "%s in file %s at line %d, %s\n",
- s,stab_val(curcmd->c_filestab)->str_ptr,curcmd->c_line,tname);
- if (curcmd->c_line == multi_end && multi_start < multi_end)
- sprintf(buf+strlen(buf),
- " (Might be a runaway multi-line %c%c string starting on line %d)\n",
- multi_open,multi_close,multi_start);
- if (in_eval)
- str_cat(stab_val(stabent("@",TRUE)),buf);
- else
- fputs(buf,stderr);
- if (++error_count >= 10)
- fatal("%s has too many errors.\n",
- stab_val(curcmd->c_filestab)->str_ptr);
-}
-
-void
-while_io(cmd)
-register CMD *cmd;
-{
- register ARG *arg = cmd->c_expr;
- STAB *asgnstab;
-
- /* hoist "while (<channel>)" up into command block */
-
- if (arg && arg->arg_type == O_ITEM && arg[1].arg_type == A_READ) {
- cmd->c_flags &= ~CF_OPTIMIZE; /* clear optimization type */
- cmd->c_flags |= CFT_GETS; /* and set it to do the input */
- cmd->c_stab = arg[1].arg_ptr.arg_stab;
- if (stab_io(arg[1].arg_ptr.arg_stab)->flags & IOF_ARGV) {
- cmd->c_expr = l(make_op(O_ASSIGN, 2, /* fake up "$_ =" */
- stab2arg(A_LVAL,defstab), arg, Nullarg));
- }
- else {
- free_arg(arg);
- cmd->c_expr = Nullarg;
- }
- }
- else if (arg && arg->arg_type == O_ITEM && arg[1].arg_type == A_INDREAD) {
- cmd->c_flags &= ~CF_OPTIMIZE; /* clear optimization type */
- cmd->c_flags |= CFT_INDGETS; /* and set it to do the input */
- cmd->c_stab = arg[1].arg_ptr.arg_stab;
- free_arg(arg);
- cmd->c_expr = Nullarg;
- }
- else if (arg && arg->arg_type == O_ITEM && arg[1].arg_type == A_GLOB) {
- if ((cmd->c_flags & CF_OPTIMIZE) == CFT_ARRAY)
- asgnstab = cmd->c_stab;
- else
- asgnstab = defstab;
- cmd->c_expr = l(make_op(O_ASSIGN, 2, /* fake up "$foo =" */
- stab2arg(A_LVAL,asgnstab), arg, Nullarg));
- cmd->c_flags &= ~CF_OPTIMIZE; /* clear optimization type */
- }
-}
-
-CMD *
-wopt(cmd)
-register CMD *cmd;
-{
- register CMD *tail;
- CMD *newtail;
- register int i;
-
- if (cmd->c_expr && (cmd->c_flags & CF_OPTIMIZE) == CFT_FALSE)
- opt_arg(cmd,1, cmd->c_type == C_EXPR);
-
- while_io(cmd); /* add $_ =, if necessary */
-
- /* First find the end of the true list */
-
- tail = cmd->ucmd.ccmd.cc_true;
- if (tail == Nullcmd)
- return cmd;
- New(112,newtail, 1, CMD); /* guaranteed continue */
- for (;;) {
- /* optimize "next" to point directly to continue block */
- if (tail->c_type == C_EXPR &&
- tail->ucmd.acmd.ac_expr &&
- tail->ucmd.acmd.ac_expr->arg_type == O_NEXT &&
- (tail->ucmd.acmd.ac_expr->arg_len == 0 ||
- (cmd->c_label &&
- strEQ(cmd->c_label,
- tail->ucmd.acmd.ac_expr[1].arg_ptr.arg_str->str_ptr) )))
- {
- arg_free(tail->ucmd.acmd.ac_expr);
- tail->ucmd.acmd.ac_expr = Nullarg;
- tail->c_type = C_NEXT;
- if (cmd->ucmd.ccmd.cc_alt != Nullcmd)
- tail->ucmd.ccmd.cc_alt = cmd->ucmd.ccmd.cc_alt;
- else
- tail->ucmd.ccmd.cc_alt = newtail;
- tail->ucmd.ccmd.cc_true = Nullcmd;
- }
- else if (tail->c_type == C_IF && !tail->ucmd.ccmd.cc_alt) {
- if (cmd->ucmd.ccmd.cc_alt != Nullcmd)
- tail->ucmd.ccmd.cc_alt = cmd->ucmd.ccmd.cc_alt;
- else
- tail->ucmd.ccmd.cc_alt = newtail;
- }
- else if (tail->c_type == C_CSWITCH || tail->c_type == C_NSWITCH) {
- if (cmd->ucmd.ccmd.cc_alt != Nullcmd) {
- for (i = tail->ucmd.scmd.sc_max; i >= 0; i--)
- if (!tail->ucmd.scmd.sc_next[i])
- tail->ucmd.scmd.sc_next[i] = cmd->ucmd.ccmd.cc_alt;
- }
- else {
- for (i = tail->ucmd.scmd.sc_max; i >= 0; i--)
- if (!tail->ucmd.scmd.sc_next[i])
- tail->ucmd.scmd.sc_next[i] = newtail;
- }
- }
-
- if (!tail->c_next)
- break;
- tail = tail->c_next;
- }
-
- /* if there's a continue block, link it to true block and find end */
-
- if (cmd->ucmd.ccmd.cc_alt != Nullcmd) {
- tail->c_next = cmd->ucmd.ccmd.cc_alt;
- tail = tail->c_next;
- for (;;) {
- /* optimize "next" to point directly to continue block */
- if (tail->c_type == C_EXPR &&
- tail->ucmd.acmd.ac_expr &&
- tail->ucmd.acmd.ac_expr->arg_type == O_NEXT &&
- (tail->ucmd.acmd.ac_expr->arg_len == 0 ||
- (cmd->c_label &&
- strEQ(cmd->c_label,
- tail->ucmd.acmd.ac_expr[1].arg_ptr.arg_str->str_ptr) )))
- {
- arg_free(tail->ucmd.acmd.ac_expr);
- tail->ucmd.acmd.ac_expr = Nullarg;
- tail->c_type = C_NEXT;
- tail->ucmd.ccmd.cc_alt = newtail;
- tail->ucmd.ccmd.cc_true = Nullcmd;
- }
- else if (tail->c_type == C_IF && !tail->ucmd.ccmd.cc_alt) {
- tail->ucmd.ccmd.cc_alt = newtail;
- }
- else if (tail->c_type == C_CSWITCH || tail->c_type == C_NSWITCH) {
- for (i = tail->ucmd.scmd.sc_max; i >= 0; i--)
- if (!tail->ucmd.scmd.sc_next[i])
- tail->ucmd.scmd.sc_next[i] = newtail;
- }
-
- if (!tail->c_next)
- break;
- tail = tail->c_next;
- }
- /*SUPPRESS 530*/
- for ( ; tail->c_next; tail = tail->c_next) ;
- }
-
- /* Here's the real trick: link the end of the list back to the beginning,
- * inserting a "last" block to break out of the loop. This saves one or
- * two procedure calls every time through the loop, because of how cmd_exec
- * does tail recursion.
- */
-
- tail->c_next = newtail;
- tail = newtail;
- if (!cmd->ucmd.ccmd.cc_alt)
- cmd->ucmd.ccmd.cc_alt = tail; /* every loop has a continue now */
-
-#ifndef lint
- Copy((char *)cmd, (char *)tail, 1, CMD);
-#endif
- tail->c_type = C_EXPR;
- tail->c_flags ^= CF_INVERT; /* turn into "last unless" */
- tail->c_next = tail->ucmd.ccmd.cc_true; /* loop directly back to top */
- tail->ucmd.acmd.ac_expr = make_op(O_LAST,0,Nullarg,Nullarg,Nullarg);
- tail->ucmd.acmd.ac_stab = Nullstab;
- return cmd;
-}
-
-CMD *
-over(eachstab,cmd)
-STAB *eachstab;
-register CMD *cmd;
-{
- /* hoist "for $foo (@bar)" up into command block */
-
- cmd->c_flags &= ~CF_OPTIMIZE; /* clear optimization type */
- cmd->c_flags |= CFT_ARRAY; /* and set it to do the iteration */
- cmd->c_stab = eachstab;
- cmd->c_short = Str_new(23,0); /* just to save a field in struct cmd */
- cmd->c_short->str_u.str_useful = -1;
-
- return cmd;
-}
-
-void
-cmd_free(cmd)
-register CMD *cmd;
-{
- register CMD *tofree;
- register CMD *head = cmd;
-
- if (!cmd)
- return;
- if (cmd->c_head != cmd)
- warn("Malformed cmd links\n");
- while (cmd) {
- if (cmd->c_type != C_WHILE) { /* WHILE block is duplicated */
- if (cmd->c_label) {
- Safefree(cmd->c_label);
- cmd->c_label = Nullch;
- }
- if (cmd->c_short) {
- str_free(cmd->c_short);
- cmd->c_short = Nullstr;
- }
- if (cmd->c_expr) {
- arg_free(cmd->c_expr);
- cmd->c_expr = Nullarg;
- }
- }
- switch (cmd->c_type) {
- case C_WHILE:
- case C_BLOCK:
- case C_ELSE:
- case C_IF:
- if (cmd->ucmd.ccmd.cc_true) {
- cmd_free(cmd->ucmd.ccmd.cc_true);
- cmd->ucmd.ccmd.cc_true = Nullcmd;
- }
- break;
- case C_EXPR:
- if (cmd->ucmd.acmd.ac_expr) {
- arg_free(cmd->ucmd.acmd.ac_expr);
- cmd->ucmd.acmd.ac_expr = Nullarg;
- }
- break;
- }
- tofree = cmd;
- cmd = cmd->c_next;
- if (tofree != head) /* to get Saber to shut up */
- Safefree(tofree);
- if (cmd && cmd == head) /* reached end of while loop */
- break;
- }
- Safefree(head);
-}
-
-void
-arg_free(arg)
-register ARG *arg;
-{
- register int i;
-
- if (!arg)
- return;
- for (i = 1; i <= arg->arg_len; i++) {
- switch (arg[i].arg_type & A_MASK) {
- case A_NULL:
- if (arg->arg_type == O_TRANS) {
- Safefree(arg[i].arg_ptr.arg_cval);
- arg[i].arg_ptr.arg_cval = Nullch;
- }
- break;
- case A_LEXPR:
- if (arg->arg_type == O_AASSIGN &&
- arg[i].arg_ptr.arg_arg->arg_type == O_LARRAY) {
- char *name =
- stab_name(arg[i].arg_ptr.arg_arg[1].arg_ptr.arg_stab);
-
- if (strnEQ("_GEN_",name, 5)) /* array for foreach */
- hdelete(defstash,name,strlen(name));
- }
- /* FALL THROUGH */
- case A_EXPR:
- arg_free(arg[i].arg_ptr.arg_arg);
- arg[i].arg_ptr.arg_arg = Nullarg;
- break;
- case A_CMD:
- cmd_free(arg[i].arg_ptr.arg_cmd);
- arg[i].arg_ptr.arg_cmd = Nullcmd;
- break;
- case A_WORD:
- case A_STAB:
- case A_LVAL:
- case A_READ:
- case A_GLOB:
- case A_ARYLEN:
- case A_LARYLEN:
- case A_ARYSTAB:
- case A_LARYSTAB:
- break;
- case A_SINGLE:
- case A_DOUBLE:
- case A_BACKTICK:
- str_free(arg[i].arg_ptr.arg_str);
- arg[i].arg_ptr.arg_str = Nullstr;
- break;
- case A_SPAT:
- spat_free(arg[i].arg_ptr.arg_spat);
- arg[i].arg_ptr.arg_spat = Nullspat;
- break;
- }
- }
- free_arg(arg);
-}
-
-void
-spat_free(spat)
-register SPAT *spat;
-{
- register SPAT *sp;
- HENT *entry;
-
- if (!spat)
- return;
- if (spat->spat_runtime) {
- arg_free(spat->spat_runtime);
- spat->spat_runtime = Nullarg;
- }
- if (spat->spat_repl) {
- arg_free(spat->spat_repl);
- spat->spat_repl = Nullarg;
- }
- if (spat->spat_short) {
- str_free(spat->spat_short);
- spat->spat_short = Nullstr;
- }
- if (spat->spat_regexp) {
- regfree(spat->spat_regexp);
- spat->spat_regexp = Null(REGEXP*);
- }
-
- /* now unlink from spat list */
-
- for (entry = defstash->tbl_array['_']; entry; entry = entry->hent_next) {
- register HASH *stash;
- STAB *stab = (STAB*)entry->hent_val;
-
- if (!stab)
- continue;
- stash = stab_hash(stab);
- if (!stash || stash->tbl_spatroot == Null(SPAT*))
- continue;
- if (stash->tbl_spatroot == spat)
- stash->tbl_spatroot = spat->spat_next;
- else {
- for (sp = stash->tbl_spatroot;
- sp && sp->spat_next != spat;
- sp = sp->spat_next)
- /*SUPPRESS 530*/
- ;
- if (sp)
- sp->spat_next = spat->spat_next;
- }
- }
- Safefree(spat);
-}
-
-/* Recursively descend a command sequence and push the address of any string
- * that needs saving on recursion onto the tosave array.
- */
-
-static int
-cmd_tosave(cmd,willsave)
-register CMD *cmd;
-int willsave; /* willsave passes down the tree */
-{
- register CMD *head = cmd;
- int shouldsave = FALSE; /* shouldsave passes up the tree */
- int tmpsave;
- register CMD *lastcmd = Nullcmd;
-
- while (cmd) {
- if (cmd->c_expr)
- shouldsave |= arg_tosave(cmd->c_expr,willsave);
- switch (cmd->c_type) {
- case C_WHILE:
- if (cmd->ucmd.ccmd.cc_true) {
- tmpsave = cmd_tosave(cmd->ucmd.ccmd.cc_true,willsave);
-
- /* Here we check to see if the temporary array generated for
- * a foreach needs to be localized because of recursion.
- */
- if (tmpsave && (cmd->c_flags & CF_OPTIMIZE) == CFT_ARRAY) {
- if (lastcmd &&
- lastcmd->c_type == C_EXPR &&
- lastcmd->c_expr) {
- ARG *arg = lastcmd->c_expr;
-
- if (arg->arg_type == O_ASSIGN &&
- arg[1].arg_type == A_LEXPR &&
- arg[1].arg_ptr.arg_arg->arg_type == O_LARRAY &&
- strnEQ("_GEN_",
- stab_name(
- arg[1].arg_ptr.arg_arg[1].arg_ptr.arg_stab),
- 5)) { /* array generated for foreach */
- (void)localize(arg);
- }
- }
-
- /* in any event, save the iterator */
-
- if (cmd->c_short) /* Better safe than sorry */
- (void)apush(tosave,cmd->c_short);
- }
- shouldsave |= tmpsave;
- }
- break;
- case C_BLOCK:
- case C_ELSE:
- case C_IF:
- if (cmd->ucmd.ccmd.cc_true)
- shouldsave |= cmd_tosave(cmd->ucmd.ccmd.cc_true,willsave);
- break;
- case C_EXPR:
- if (cmd->ucmd.acmd.ac_expr)
- shouldsave |= arg_tosave(cmd->ucmd.acmd.ac_expr,willsave);
- break;
- }
- lastcmd = cmd;
- cmd = cmd->c_next;
- if (cmd && cmd == head) /* reached end of while loop */
- break;
- }
- return shouldsave;
-}
-
-static int
-arg_tosave(arg,willsave)
-register ARG *arg;
-int willsave;
-{
- register int i;
- int shouldsave = FALSE;
-
- for (i = arg->arg_len; i >= 1; i--) {
- switch (arg[i].arg_type & A_MASK) {
- case A_NULL:
- break;
- case A_LEXPR:
- case A_EXPR:
- shouldsave |= arg_tosave(arg[i].arg_ptr.arg_arg,shouldsave);
- break;
- case A_CMD:
- shouldsave |= cmd_tosave(arg[i].arg_ptr.arg_cmd,shouldsave);
- break;
- case A_WORD:
- case A_STAB:
- case A_LVAL:
- case A_READ:
- case A_GLOB:
- case A_ARYLEN:
- case A_SINGLE:
- case A_DOUBLE:
- case A_BACKTICK:
- break;
- case A_SPAT:
- shouldsave |= spat_tosave(arg[i].arg_ptr.arg_spat);
- break;
- }
- }
- switch (arg->arg_type) {
- case O_RETURN:
- saw_return = TRUE;
- break;
- case O_EVAL:
- case O_SUBR:
- shouldsave = TRUE;
- break;
- }
- if (willsave && arg->arg_ptr.arg_str)
- (void)apush(tosave,arg->arg_ptr.arg_str);
- return shouldsave;
-}
-
-static int
-spat_tosave(spat)
-register SPAT *spat;
-{
- int shouldsave = FALSE;
-
- if (spat->spat_runtime)
- shouldsave |= arg_tosave(spat->spat_runtime,FALSE);
- if (spat->spat_repl) {
- shouldsave |= arg_tosave(spat->spat_repl,FALSE);
- }
-
- return shouldsave;
-}
-
diff --git a/gnu/usr.bin/perl/perl/consarg.c b/gnu/usr.bin/perl/perl/consarg.c
deleted file mode 100644
index f673863..0000000
--- a/gnu/usr.bin/perl/perl/consarg.c
+++ /dev/null
@@ -1,1302 +0,0 @@
-/* $RCSfile: consarg.c,v $$Revision: 1.3 $$Date: 1995/05/30 05:02:57 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: consarg.c,v $
- * Revision 1.3 1995/05/30 05:02:57 rgrimes
- * Remove trailing whitespace.
- *
- * Revision 1.2 1994/09/11 03:17:29 gclarkii
- * Changed AF_LOCAL to AF_LOCAL_XX so as not to conflict with 4.4 socket.h
- * Added casts to shutup warnings in doio.c
- *
- * Revision 1.1.1.1 1994/09/10 06:27:32 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:35 nate
- * PERL!
- *
- * Revision 4.0.1.4 92/06/08 12:26:27 lwall
- * patch20: new warning for use of x with non-numeric right operand
- * patch20: modulus with highest bit in left operand set didn't always work
- * patch20: illegal lvalue message could be followed by core dump
- * patch20: deleted some minor memory leaks
- *
- * Revision 4.0.1.3 91/11/05 16:21:16 lwall
- * patch11: random cleanup
- * patch11: added eval {}
- * patch11: added sort {} LIST
- * patch11: "foo" x -1 dumped core
- * patch11: substr() and vec() weren't allowed in an lvalue list
- *
- * Revision 4.0.1.2 91/06/07 10:33:12 lwall
- * patch4: new copyright notice
- * patch4: length($`), length($&), length($') now optimized to avoid string copy
- *
- * Revision 4.0.1.1 91/04/11 17:38:34 lwall
- * patch1: fixed "Bad free" error
- *
- * Revision 4.0 91/03/20 01:06:15 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-static int nothing_in_common();
-static int arg_common();
-static int spat_common();
-
-ARG *
-make_split(stab,arg,limarg)
-register STAB *stab;
-register ARG *arg;
-ARG *limarg;
-{
- register SPAT *spat;
-
- if (arg->arg_type != O_MATCH) {
- Newz(201,spat,1,SPAT);
- spat->spat_next = curstash->tbl_spatroot; /* link into spat list */
- curstash->tbl_spatroot = spat;
-
- spat->spat_runtime = arg;
- arg = make_match(O_MATCH,stab2arg(A_STAB,defstab),spat);
- }
- Renew(arg,4,ARG);
- arg->arg_len = 3;
- if (limarg) {
- if (limarg->arg_type == O_ITEM) {
- Copy(limarg+1,arg+3,1,ARG);
- limarg[1].arg_type = A_NULL;
- arg_free(limarg);
- }
- else {
- arg[3].arg_flags = 0;
- arg[3].arg_len = 0;
- arg[3].arg_type = A_EXPR;
- arg[3].arg_ptr.arg_arg = limarg;
- }
- }
- else {
- arg[3].arg_flags = 0;
- arg[3].arg_len = 0;
- arg[3].arg_type = A_NULL;
- arg[3].arg_ptr.arg_arg = Nullarg;
- }
- arg->arg_type = O_SPLIT;
- spat = arg[2].arg_ptr.arg_spat;
- spat->spat_repl = stab2arg(A_STAB,aadd(stab));
- if (spat->spat_short) { /* exact match can bypass regexec() */
- if (!((spat->spat_flags & SPAT_SCANFIRST) &&
- (spat->spat_flags & SPAT_ALL) )) {
- str_free(spat->spat_short);
- spat->spat_short = Nullstr;
- }
- }
- return arg;
-}
-
-ARG *
-mod_match(type,left,pat)
-register ARG *left;
-register ARG *pat;
-{
-
- register SPAT *spat;
- register ARG *newarg;
-
- if (!pat)
- return Nullarg;
-
- if ((pat->arg_type == O_MATCH ||
- pat->arg_type == O_SUBST ||
- pat->arg_type == O_TRANS ||
- pat->arg_type == O_SPLIT
- ) &&
- pat[1].arg_ptr.arg_stab == defstab ) {
- switch (pat->arg_type) {
- case O_MATCH:
- newarg = make_op(type == O_MATCH ? O_MATCH : O_NMATCH,
- pat->arg_len,
- left,Nullarg,Nullarg);
- break;
- case O_SUBST:
- newarg = l(make_op(type == O_MATCH ? O_SUBST : O_NSUBST,
- pat->arg_len,
- left,Nullarg,Nullarg));
- break;
- case O_TRANS:
- newarg = l(make_op(type == O_MATCH ? O_TRANS : O_NTRANS,
- pat->arg_len,
- left,Nullarg,Nullarg));
- break;
- case O_SPLIT:
- newarg = make_op(type == O_MATCH ? O_SPLIT : O_SPLIT,
- pat->arg_len,
- left,Nullarg,Nullarg);
- break;
- }
- if (pat->arg_len >= 2) {
- newarg[2].arg_type = pat[2].arg_type;
- newarg[2].arg_ptr = pat[2].arg_ptr;
- newarg[2].arg_len = pat[2].arg_len;
- newarg[2].arg_flags = pat[2].arg_flags;
- if (pat->arg_len >= 3) {
- newarg[3].arg_type = pat[3].arg_type;
- newarg[3].arg_ptr = pat[3].arg_ptr;
- newarg[3].arg_len = pat[3].arg_len;
- newarg[3].arg_flags = pat[3].arg_flags;
- }
- }
- free_arg(pat);
- }
- else {
- Newz(202,spat,1,SPAT);
- spat->spat_next = curstash->tbl_spatroot; /* link into spat list */
- curstash->tbl_spatroot = spat;
-
- spat->spat_runtime = pat;
- newarg = make_op(type,2,left,Nullarg,Nullarg);
- newarg[2].arg_type = A_SPAT | A_DONT;
- newarg[2].arg_ptr.arg_spat = spat;
- }
-
- return newarg;
-}
-
-ARG *
-make_op(type,newlen,arg1,arg2,arg3)
-int type;
-int newlen;
-ARG *arg1;
-ARG *arg2;
-ARG *arg3;
-{
- register ARG *arg;
- register ARG *chld;
- register unsigned doarg;
- register int i;
- extern ARG *arg4; /* should be normal arguments, really */
- extern ARG *arg5;
-
- arg = op_new(newlen);
- arg->arg_type = type;
- /*SUPPRESS 560*/
- if (chld = arg1) {
- if (chld->arg_type == O_ITEM &&
- (hoistable[ i = (chld[1].arg_type&A_MASK)] || i == A_LVAL ||
- (i == A_LEXPR &&
- (chld[1].arg_ptr.arg_arg->arg_type == O_LIST ||
- chld[1].arg_ptr.arg_arg->arg_type == O_ARRAY ||
- chld[1].arg_ptr.arg_arg->arg_type == O_HASH ))))
- {
- arg[1].arg_type = chld[1].arg_type;
- arg[1].arg_ptr = chld[1].arg_ptr;
- arg[1].arg_flags |= chld[1].arg_flags;
- arg[1].arg_len = chld[1].arg_len;
- free_arg(chld);
- }
- else {
- arg[1].arg_type = A_EXPR;
- arg[1].arg_ptr.arg_arg = chld;
- }
- }
- /*SUPPRESS 560*/
- if (chld = arg2) {
- if (chld->arg_type == O_ITEM &&
- (hoistable[chld[1].arg_type&A_MASK] ||
- (type == O_ASSIGN &&
- ((chld[1].arg_type == A_READ && !(arg[1].arg_type & A_DONT))
- ||
- (chld[1].arg_type == A_INDREAD && !(arg[1].arg_type & A_DONT))
- ||
- (chld[1].arg_type == A_GLOB && !(arg[1].arg_type & A_DONT))
- ) ) ) ) {
- arg[2].arg_type = chld[1].arg_type;
- arg[2].arg_ptr = chld[1].arg_ptr;
- arg[2].arg_len = chld[1].arg_len;
- free_arg(chld);
- }
- else {
- arg[2].arg_type = A_EXPR;
- arg[2].arg_ptr.arg_arg = chld;
- }
- }
- /*SUPPRESS 560*/
- if (chld = arg3) {
- if (chld->arg_type == O_ITEM && hoistable[chld[1].arg_type&A_MASK]) {
- arg[3].arg_type = chld[1].arg_type;
- arg[3].arg_ptr = chld[1].arg_ptr;
- arg[3].arg_len = chld[1].arg_len;
- free_arg(chld);
- }
- else {
- arg[3].arg_type = A_EXPR;
- arg[3].arg_ptr.arg_arg = chld;
- }
- }
- if (newlen >= 4 && (chld = arg4)) {
- if (chld->arg_type == O_ITEM && hoistable[chld[1].arg_type&A_MASK]) {
- arg[4].arg_type = chld[1].arg_type;
- arg[4].arg_ptr = chld[1].arg_ptr;
- arg[4].arg_len = chld[1].arg_len;
- free_arg(chld);
- }
- else {
- arg[4].arg_type = A_EXPR;
- arg[4].arg_ptr.arg_arg = chld;
- }
- }
- if (newlen >= 5 && (chld = arg5)) {
- if (chld->arg_type == O_ITEM && hoistable[chld[1].arg_type&A_MASK]) {
- arg[5].arg_type = chld[1].arg_type;
- arg[5].arg_ptr = chld[1].arg_ptr;
- arg[5].arg_len = chld[1].arg_len;
- free_arg(chld);
- }
- else {
- arg[5].arg_type = A_EXPR;
- arg[5].arg_ptr.arg_arg = chld;
- }
- }
- doarg = opargs[type];
- for (i = 1; i <= newlen; ++i) {
- if (!(doarg & 1))
- arg[i].arg_type |= A_DONT;
- if (doarg & 2)
- arg[i].arg_flags |= AF_ARYOK;
- doarg >>= 2;
- }
-#ifdef DEBUGGING
- if (debug & 16) {
- fprintf(stderr,"%lx <= make_op(%s",arg,opname[arg->arg_type]);
- if (arg1)
- fprintf(stderr,",%s=%lx",
- argname[arg[1].arg_type&A_MASK],arg[1].arg_ptr.arg_arg);
- if (arg2)
- fprintf(stderr,",%s=%lx",
- argname[arg[2].arg_type&A_MASK],arg[2].arg_ptr.arg_arg);
- if (arg3)
- fprintf(stderr,",%s=%lx",
- argname[arg[3].arg_type&A_MASK],arg[3].arg_ptr.arg_arg);
- if (newlen >= 4)
- fprintf(stderr,",%s=%lx",
- argname[arg[4].arg_type&A_MASK],arg[4].arg_ptr.arg_arg);
- if (newlen >= 5)
- fprintf(stderr,",%s=%lx",
- argname[arg[5].arg_type&A_MASK],arg[5].arg_ptr.arg_arg);
- fprintf(stderr,")\n");
- }
-#endif
- arg = evalstatic(arg); /* see if we can consolidate anything */
- return arg;
-}
-
-ARG *
-evalstatic(arg)
-register ARG *arg;
-{
- static STR *str = Nullstr;
- register STR *s1;
- register STR *s2;
- double value; /* must not be register */
- register char *tmps;
- int i;
- unsigned long tmplong;
- long tmp2;
- double exp(), log(), sqrt(), modf();
- char *crypt();
- double sin(), cos(), atan2(), pow();
-
- if (!arg || !arg->arg_len)
- return arg;
-
- if (!str)
- str = Str_new(20,0);
-
- if (arg[1].arg_type == A_SINGLE)
- s1 = arg[1].arg_ptr.arg_str;
- else
- s1 = Nullstr;
- if (arg->arg_len >= 2 && arg[2].arg_type == A_SINGLE)
- s2 = arg[2].arg_ptr.arg_str;
- else
- s2 = Nullstr;
-
-#define CHECK1 if (!s1) return arg
-#define CHECK2 if (!s2) return arg
-#define CHECK12 if (!s1 || !s2) return arg
-
- switch (arg->arg_type) {
- default:
- return arg;
- case O_SORT:
- if (arg[1].arg_type == A_CMD)
- arg[1].arg_type |= A_DONT;
- return arg;
- case O_EVAL:
- if (arg[1].arg_type == A_CMD) {
- arg->arg_type = O_TRY;
- arg[1].arg_type |= A_DONT;
- return arg;
- }
- CHECK1;
- arg->arg_type = O_EVALONCE;
- return arg;
- case O_AELEM:
- CHECK2;
- i = (int)str_gnum(s2);
- if (i < 32767 && i >= 0) {
- arg->arg_type = O_ITEM;
- arg->arg_len = 1;
- arg[1].arg_type = A_ARYSTAB; /* $abc[123] is hoistable now */
- arg[1].arg_len = i;
- str_free(s2);
- Renew(arg, 2, ARG);
- }
- return arg;
- case O_CONCAT:
- CHECK12;
- str_sset(str,s1);
- str_scat(str,s2);
- break;
- case O_REPEAT:
- CHECK2;
- if (dowarn && !s2->str_nok && !looks_like_number(s2))
- warn("Right operand of x is not numeric");
- CHECK1;
- i = (int)str_gnum(s2);
- tmps = str_get(s1);
- str_nset(str,"",0);
- if (i > 0) {
- STR_GROW(str, i * s1->str_cur + 1);
- repeatcpy(str->str_ptr, tmps, s1->str_cur, i);
- str->str_cur = i * s1->str_cur;
- str->str_ptr[str->str_cur] = '\0';
- }
- break;
- case O_MULTIPLY:
- CHECK12;
- value = str_gnum(s1);
- str_numset(str,value * str_gnum(s2));
- break;
- case O_DIVIDE:
- CHECK12;
- value = str_gnum(s2);
- if (value == 0.0)
- yyerror("Illegal division by constant zero");
- else
-#ifdef SLOPPYDIVIDE
- /* insure that 20./5. == 4. */
- {
- double x;
- int k;
- x = str_gnum(s1);
- if ((double)(int)x == x &&
- (double)(int)value == value &&
- (k = (int)x/(int)value)*(int)value == (int)x) {
- value = k;
- } else {
- value = x/value;
- }
- str_numset(str,value);
- }
-#else
- str_numset(str,str_gnum(s1) / value);
-#endif
- break;
- case O_MODULO:
- CHECK12;
- tmplong = (unsigned long)str_gnum(s2);
- if (tmplong == 0L) {
- yyerror("Illegal modulus of constant zero");
- return arg;
- }
- value = str_gnum(s1);
-#ifndef lint
- if (value >= 0.0)
- str_numset(str,(double)(((unsigned long)value) % tmplong));
- else {
- tmp2 = (long)value;
- str_numset(str,(double)((tmplong-((-tmp2 - 1) % tmplong)) - 1));
- }
-#else
- tmp2 = tmp2;
-#endif
- break;
- case O_ADD:
- CHECK12;
- value = str_gnum(s1);
- str_numset(str,value + str_gnum(s2));
- break;
- case O_SUBTRACT:
- CHECK12;
- value = str_gnum(s1);
- str_numset(str,value - str_gnum(s2));
- break;
- case O_LEFT_SHIFT:
- CHECK12;
- value = str_gnum(s1);
- i = (int)str_gnum(s2);
-#ifndef lint
- str_numset(str,(double)(((long)value) << i));
-#endif
- break;
- case O_RIGHT_SHIFT:
- CHECK12;
- value = str_gnum(s1);
- i = (int)str_gnum(s2);
-#ifndef lint
- str_numset(str,(double)(((long)value) >> i));
-#endif
- break;
- case O_LT:
- CHECK12;
- value = str_gnum(s1);
- str_numset(str,(value < str_gnum(s2)) ? 1.0 : 0.0);
- break;
- case O_GT:
- CHECK12;
- value = str_gnum(s1);
- str_numset(str,(value > str_gnum(s2)) ? 1.0 : 0.0);
- break;
- case O_LE:
- CHECK12;
- value = str_gnum(s1);
- str_numset(str,(value <= str_gnum(s2)) ? 1.0 : 0.0);
- break;
- case O_GE:
- CHECK12;
- value = str_gnum(s1);
- str_numset(str,(value >= str_gnum(s2)) ? 1.0 : 0.0);
- break;
- case O_EQ:
- CHECK12;
- if (dowarn) {
- if ((!s1->str_nok && !looks_like_number(s1)) ||
- (!s2->str_nok && !looks_like_number(s2)) )
- warn("Possible use of == on string value");
- }
- value = str_gnum(s1);
- str_numset(str,(value == str_gnum(s2)) ? 1.0 : 0.0);
- break;
- case O_NE:
- CHECK12;
- value = str_gnum(s1);
- str_numset(str,(value != str_gnum(s2)) ? 1.0 : 0.0);
- break;
- case O_NCMP:
- CHECK12;
- value = str_gnum(s1);
- value -= str_gnum(s2);
- if (value > 0.0)
- value = 1.0;
- else if (value < 0.0)
- value = -1.0;
- str_numset(str,value);
- break;
- case O_BIT_AND:
- CHECK12;
- value = str_gnum(s1);
-#ifndef lint
- str_numset(str,(double)(U_L(value) & U_L(str_gnum(s2))));
-#endif
- break;
- case O_XOR:
- CHECK12;
- value = str_gnum(s1);
-#ifndef lint
- str_numset(str,(double)(U_L(value) ^ U_L(str_gnum(s2))));
-#endif
- break;
- case O_BIT_OR:
- CHECK12;
- value = str_gnum(s1);
-#ifndef lint
- str_numset(str,(double)(U_L(value) | U_L(str_gnum(s2))));
-#endif
- break;
- case O_AND:
- CHECK12;
- if (str_true(s1))
- str_sset(str,s2);
- else
- str_sset(str,s1);
- break;
- case O_OR:
- CHECK12;
- if (str_true(s1))
- str_sset(str,s1);
- else
- str_sset(str,s2);
- break;
- case O_COND_EXPR:
- CHECK12;
- if ((arg[3].arg_type & A_MASK) != A_SINGLE)
- return arg;
- if (str_true(s1))
- str_sset(str,s2);
- else
- str_sset(str,arg[3].arg_ptr.arg_str);
- str_free(arg[3].arg_ptr.arg_str);
- Renew(arg, 3, ARG);
- break;
- case O_NEGATE:
- CHECK1;
- str_numset(str,(double)(-str_gnum(s1)));
- break;
- case O_NOT:
- CHECK1;
-#ifdef NOTNOT
- { char xxx = str_true(s1); str_numset(str,(double)!xxx); }
-#else
- str_numset(str,(double)(!str_true(s1)));
-#endif
- break;
- case O_COMPLEMENT:
- CHECK1;
-#ifndef lint
- str_numset(str,(double)(~U_L(str_gnum(s1))));
-#endif
- break;
- case O_SIN:
- CHECK1;
- str_numset(str,sin(str_gnum(s1)));
- break;
- case O_COS:
- CHECK1;
- str_numset(str,cos(str_gnum(s1)));
- break;
- case O_ATAN2:
- CHECK12;
- value = str_gnum(s1);
- str_numset(str,atan2(value, str_gnum(s2)));
- break;
- case O_POW:
- CHECK12;
- value = str_gnum(s1);
- str_numset(str,pow(value, str_gnum(s2)));
- break;
- case O_LENGTH:
- if (arg[1].arg_type == A_STAB) {
- arg->arg_type = O_ITEM;
- arg[1].arg_type = A_LENSTAB;
- return arg;
- }
- CHECK1;
- str_numset(str, (double)str_len(s1));
- break;
- case O_SLT:
- CHECK12;
- str_numset(str,(double)(str_cmp(s1,s2) < 0));
- break;
- case O_SGT:
- CHECK12;
- str_numset(str,(double)(str_cmp(s1,s2) > 0));
- break;
- case O_SLE:
- CHECK12;
- str_numset(str,(double)(str_cmp(s1,s2) <= 0));
- break;
- case O_SGE:
- CHECK12;
- str_numset(str,(double)(str_cmp(s1,s2) >= 0));
- break;
- case O_SEQ:
- CHECK12;
- str_numset(str,(double)(str_eq(s1,s2)));
- break;
- case O_SNE:
- CHECK12;
- str_numset(str,(double)(!str_eq(s1,s2)));
- break;
- case O_SCMP:
- CHECK12;
- str_numset(str,(double)(str_cmp(s1,s2)));
- break;
- case O_CRYPT:
- CHECK12;
-#ifdef HAS_CRYPT
- tmps = str_get(s1);
- str_set(str,crypt(tmps,str_get(s2)));
-#else
- yyerror(
- "The crypt() function is unimplemented due to excessive paranoia.");
-#endif
- break;
- case O_EXP:
- CHECK1;
- str_numset(str,exp(str_gnum(s1)));
- break;
- case O_LOG:
- CHECK1;
- str_numset(str,log(str_gnum(s1)));
- break;
- case O_SQRT:
- CHECK1;
- str_numset(str,sqrt(str_gnum(s1)));
- break;
- case O_INT:
- CHECK1;
- value = str_gnum(s1);
- if (value >= 0.0)
- (void)modf(value,&value);
- else {
- (void)modf(-value,&value);
- value = -value;
- }
- str_numset(str,value);
- break;
- case O_ORD:
- CHECK1;
-#ifndef I286
- str_numset(str,(double)(*str_get(s1)));
-#else
- {
- int zapc;
- char *zaps;
-
- zaps = str_get(s1);
- zapc = (int) *zaps;
- str_numset(str,(double)(zapc));
- }
-#endif
- break;
- }
- arg->arg_type = O_ITEM; /* note arg1 type is already SINGLE */
- str_free(s1);
- arg[1].arg_ptr.arg_str = str;
- if (s2) {
- str_free(s2);
- arg[2].arg_ptr.arg_str = Nullstr;
- arg[2].arg_type = A_NULL;
- }
- str = Nullstr;
-
- return arg;
-}
-
-ARG *
-l(arg)
-register ARG *arg;
-{
- register int i;
- register ARG *arg1;
- register ARG *arg2;
- SPAT *spat;
- int arghog = 0;
-
- i = arg[1].arg_type & A_MASK;
-
- arg->arg_flags |= AF_COMMON; /* assume something in common */
- /* which forces us to copy things */
-
- if (i == A_ARYLEN) {
- arg[1].arg_type = A_LARYLEN;
- return arg;
- }
- if (i == A_ARYSTAB) {
- arg[1].arg_type = A_LARYSTAB;
- return arg;
- }
-
- /* see if it's an array reference */
-
- if (i == A_EXPR || i == A_LEXPR) {
- arg1 = arg[1].arg_ptr.arg_arg;
-
- if (arg1->arg_type == O_LIST || arg1->arg_type == O_ITEM) {
- /* assign to list */
- if (arg->arg_len > 1) {
- dehoist(arg,2);
- arg2 = arg[2].arg_ptr.arg_arg;
- if (nothing_in_common(arg1,arg2))
- arg->arg_flags &= ~AF_COMMON;
- if (arg->arg_type == O_ASSIGN) {
- if (arg1->arg_flags & AF_LOCAL_XX)
- arg->arg_flags |= AF_LOCAL_XX;
- arg[1].arg_flags |= AF_ARYOK;
- arg[2].arg_flags |= AF_ARYOK;
- }
- }
- else if (arg->arg_type != O_CHOP)
- arg->arg_type = O_ASSIGN; /* possible local(); */
- for (i = arg1->arg_len; i >= 1; i--) {
- switch (arg1[i].arg_type) {
- case A_STAR: case A_LSTAR:
- arg1[i].arg_type = A_LSTAR;
- break;
- case A_STAB: case A_LVAL:
- arg1[i].arg_type = A_LVAL;
- break;
- case A_ARYLEN: case A_LARYLEN:
- arg1[i].arg_type = A_LARYLEN;
- break;
- case A_ARYSTAB: case A_LARYSTAB:
- arg1[i].arg_type = A_LARYSTAB;
- break;
- case A_EXPR: case A_LEXPR:
- arg1[i].arg_type = A_LEXPR;
- switch(arg1[i].arg_ptr.arg_arg->arg_type) {
- case O_ARRAY: case O_LARRAY:
- arg1[i].arg_ptr.arg_arg->arg_type = O_LARRAY;
- arghog = 1;
- break;
- case O_AELEM: case O_LAELEM:
- arg1[i].arg_ptr.arg_arg->arg_type = O_LAELEM;
- break;
- case O_HASH: case O_LHASH:
- arg1[i].arg_ptr.arg_arg->arg_type = O_LHASH;
- arghog = 1;
- break;
- case O_HELEM: case O_LHELEM:
- arg1[i].arg_ptr.arg_arg->arg_type = O_LHELEM;
- break;
- case O_ASLICE: case O_LASLICE:
- arg1[i].arg_ptr.arg_arg->arg_type = O_LASLICE;
- break;
- case O_HSLICE: case O_LHSLICE:
- arg1[i].arg_ptr.arg_arg->arg_type = O_LHSLICE;
- break;
- case O_SUBSTR: case O_VEC:
- (void)l(arg1[i].arg_ptr.arg_arg);
- Renewc(arg1[i].arg_ptr.arg_arg->arg_ptr.arg_str, 1,
- struct lstring, STR);
- /* grow string struct to hold an lstring struct */
- break;
- default:
- goto ill_item;
- }
- break;
- default:
- ill_item:
- (void)sprintf(tokenbuf, "Illegal item (%s) as lvalue",
- argname[arg1[i].arg_type&A_MASK]);
- yyerror(tokenbuf);
- }
- }
- if (arg->arg_len > 1) {
- if (arg2->arg_type == O_SPLIT && !arg2[3].arg_type && !arghog) {
- arg2[3].arg_type = A_SINGLE;
- arg2[3].arg_ptr.arg_str =
- str_nmake((double)arg1->arg_len + 1); /* limit split len*/
- }
- }
- }
- else if (arg1->arg_type == O_AELEM || arg1->arg_type == O_LAELEM)
- if (arg->arg_type == O_DEFINED)
- arg1->arg_type = O_AELEM;
- else
- arg1->arg_type = O_LAELEM;
- else if (arg1->arg_type == O_ARRAY || arg1->arg_type == O_LARRAY) {
- arg1->arg_type = O_LARRAY;
- if (arg->arg_len > 1) {
- dehoist(arg,2);
- arg2 = arg[2].arg_ptr.arg_arg;
- if (arg2->arg_type == O_SPLIT) { /* use split's builtin =?*/
- spat = arg2[2].arg_ptr.arg_spat;
- if (!(spat->spat_flags & SPAT_ONCE) &&
- nothing_in_common(arg1,spat->spat_repl)) {
- spat->spat_repl[1].arg_ptr.arg_stab =
- arg1[1].arg_ptr.arg_stab;
- arg1[1].arg_ptr.arg_stab = Nullstab;
- spat->spat_flags |= SPAT_ONCE;
- arg_free(arg1); /* recursive */
- arg[1].arg_ptr.arg_arg = Nullarg;
- free_arg(arg); /* non-recursive */
- return arg2; /* split has builtin assign */
- }
- }
- else if (nothing_in_common(arg1,arg2))
- arg->arg_flags &= ~AF_COMMON;
- if (arg->arg_type == O_ASSIGN) {
- arg[1].arg_flags |= AF_ARYOK;
- arg[2].arg_flags |= AF_ARYOK;
- }
- }
- else if (arg->arg_type == O_ASSIGN)
- arg[1].arg_flags |= AF_ARYOK;
- }
- else if (arg1->arg_type == O_HELEM || arg1->arg_type == O_LHELEM)
- if (arg->arg_type == O_DEFINED)
- arg1->arg_type = O_HELEM; /* avoid creating one */
- else
- arg1->arg_type = O_LHELEM;
- else if (arg1->arg_type == O_HASH || arg1->arg_type == O_LHASH) {
- arg1->arg_type = O_LHASH;
- if (arg->arg_len > 1) {
- dehoist(arg,2);
- arg2 = arg[2].arg_ptr.arg_arg;
- if (nothing_in_common(arg1,arg2))
- arg->arg_flags &= ~AF_COMMON;
- if (arg->arg_type == O_ASSIGN) {
- arg[1].arg_flags |= AF_ARYOK;
- arg[2].arg_flags |= AF_ARYOK;
- }
- }
- else if (arg->arg_type == O_ASSIGN)
- arg[1].arg_flags |= AF_ARYOK;
- }
- else if (arg1->arg_type == O_ASLICE) {
- arg1->arg_type = O_LASLICE;
- if (arg->arg_type == O_ASSIGN) {
- dehoist(arg,2);
- arg[1].arg_flags |= AF_ARYOK;
- arg[2].arg_flags |= AF_ARYOK;
- }
- }
- else if (arg1->arg_type == O_HSLICE) {
- arg1->arg_type = O_LHSLICE;
- if (arg->arg_type == O_ASSIGN) {
- dehoist(arg,2);
- arg[1].arg_flags |= AF_ARYOK;
- arg[2].arg_flags |= AF_ARYOK;
- }
- }
- else if ((arg->arg_type == O_DEFINED || arg->arg_type == O_UNDEF) &&
- (arg1->arg_type == (perldb ? O_DBSUBR : O_SUBR)) ) {
- arg[1].arg_type |= A_DONT;
- }
- else if (arg1->arg_type == O_SUBSTR || arg1->arg_type == O_VEC) {
- (void)l(arg1);
- Renewc(arg1->arg_ptr.arg_str, 1, struct lstring, STR);
- /* grow string struct to hold an lstring struct */
- }
- else if (arg1->arg_type == O_ASSIGN)
- /*SUPPRESS 530*/
- ;
- else {
- (void)sprintf(tokenbuf,
- "Illegal expression (%s) as lvalue",opname[arg1->arg_type]);
- yyerror(tokenbuf);
- return arg;
- }
- arg[1].arg_type = A_LEXPR | (arg[1].arg_type & A_DONT);
- if (arg->arg_type == O_ASSIGN && (arg1[1].arg_flags & AF_ARYOK)) {
- arg[1].arg_flags |= AF_ARYOK;
- if (arg->arg_len > 1)
- arg[2].arg_flags |= AF_ARYOK;
- }
-#ifdef DEBUGGING
- if (debug & 16)
- fprintf(stderr,"lval LEXPR\n");
-#endif
- return arg;
- }
- if (i == A_STAR || i == A_LSTAR) {
- arg[1].arg_type = A_LSTAR | (arg[1].arg_type & A_DONT);
- return arg;
- }
-
- /* not an array reference, should be a register name */
-
- if (i != A_STAB && i != A_LVAL) {
- (void)sprintf(tokenbuf,
- "Illegal item (%s) as lvalue",argname[arg[1].arg_type&A_MASK]);
- yyerror(tokenbuf);
- return arg;
- }
- arg[1].arg_type = A_LVAL | (arg[1].arg_type & A_DONT);
-#ifdef DEBUGGING
- if (debug & 16)
- fprintf(stderr,"lval LVAL\n");
-#endif
- return arg;
-}
-
-ARG *
-fixl(type,arg)
-int type;
-ARG *arg;
-{
- if (type == O_DEFINED || type == O_UNDEF) {
- if (arg->arg_type != O_ITEM)
- arg = hide_ary(arg);
- if (arg->arg_type == O_ITEM) {
- type = arg[1].arg_type & A_MASK;
- if (type == A_EXPR || type == A_LEXPR)
- arg[1].arg_type = A_LEXPR|A_DONT;
- }
- }
- return arg;
-}
-
-void
-dehoist(arg,i)
-ARG *arg;
-{
- ARG *tmparg;
-
- if (arg[i].arg_type != A_EXPR) { /* dehoist */
- tmparg = make_op(O_ITEM,1,Nullarg,Nullarg,Nullarg);
- tmparg[1] = arg[i];
- arg[i].arg_ptr.arg_arg = tmparg;
- arg[i].arg_type = A_EXPR;
- }
-}
-
-ARG *
-addflags(i,flags,arg)
-register ARG *arg;
-{
- arg[i].arg_flags |= flags;
- return arg;
-}
-
-ARG *
-hide_ary(arg)
-ARG *arg;
-{
- if (arg->arg_type == O_ARRAY || arg->arg_type == O_HASH)
- return make_op(O_ITEM,1,arg,Nullarg,Nullarg);
- return arg;
-}
-
-/* maybe do a join on multiple array dimensions */
-
-ARG *
-jmaybe(arg)
-register ARG *arg;
-{
- if (arg && arg->arg_type == O_COMMA) {
- arg = listish(arg);
- arg = make_op(O_JOIN, 2,
- stab2arg(A_STAB,stabent(";",TRUE)),
- make_list(arg),
- Nullarg);
- }
- return arg;
-}
-
-ARG *
-make_list(arg)
-register ARG *arg;
-{
- register int i;
- register ARG *node;
- register ARG *nxtnode;
- register int j;
- STR *tmpstr;
-
- if (!arg) {
- arg = op_new(0);
- arg->arg_type = O_LIST;
- }
- if (arg->arg_type != O_COMMA) {
- if (arg->arg_type != O_ARRAY)
- arg->arg_flags |= AF_LISTISH; /* see listish() below */
- arg->arg_flags |= AF_LISTISH; /* see listish() below */
- return arg;
- }
- for (i = 2, node = arg; ; i++) {
- if (node->arg_len < 2)
- break;
- if (node[1].arg_type != A_EXPR)
- break;
- node = node[1].arg_ptr.arg_arg;
- if (node->arg_type != O_COMMA)
- break;
- }
- if (i > 2) {
- node = arg;
- arg = op_new(i);
- tmpstr = arg->arg_ptr.arg_str;
- StructCopy(node, arg, ARG); /* copy everything except the STR */
- arg->arg_ptr.arg_str = tmpstr;
- for (j = i; ; ) {
- StructCopy(node+2, arg+j, ARG);
- arg[j].arg_flags |= AF_ARYOK;
- --j; /* Bug in Xenix compiler */
- if (j < 2) {
- StructCopy(node+1, arg+1, ARG);
- free_arg(node);
- break;
- }
- nxtnode = node[1].arg_ptr.arg_arg;
- free_arg(node);
- node = nxtnode;
- }
- }
- arg[1].arg_flags |= AF_ARYOK;
- arg[2].arg_flags |= AF_ARYOK;
- arg->arg_type = O_LIST;
- arg->arg_len = i;
- str_free(arg->arg_ptr.arg_str);
- arg->arg_ptr.arg_str = Nullstr;
- return arg;
-}
-
-/* turn a single item into a list */
-
-ARG *
-listish(arg)
-ARG *arg;
-{
- if (arg && arg->arg_flags & AF_LISTISH)
- arg = make_op(O_LIST,1,arg,Nullarg,Nullarg);
- return arg;
-}
-
-ARG *
-maybelistish(optype, arg)
-int optype;
-ARG *arg;
-{
- ARG *tmparg = arg;
-
- if (optype == O_RETURN && arg->arg_type == O_ITEM &&
- arg[1].arg_type == A_EXPR && (tmparg = arg[1].arg_ptr.arg_arg) &&
- ((tmparg->arg_flags & AF_LISTISH) || (tmparg->arg_type == O_ARRAY) )) {
- tmparg = listish(tmparg);
- free_arg(arg);
- arg = tmparg;
- }
- else if (optype == O_PRTF ||
- (arg->arg_type == O_ASLICE || arg->arg_type == O_HSLICE ||
- arg->arg_type == O_F_OR_R) )
- arg = listish(arg);
- return arg;
-}
-
-/* mark list of local variables */
-
-ARG *
-localize(arg)
-ARG *arg;
-{
- arg->arg_flags |= AF_LOCAL_XX;
- return arg;
-}
-
-ARG *
-rcatmaybe(arg)
-ARG *arg;
-{
- ARG *arg2;
-
- if (arg->arg_type == O_CONCAT && arg[2].arg_type == A_EXPR) {
- arg2 = arg[2].arg_ptr.arg_arg;
- if (arg2->arg_type == O_ITEM && arg2[1].arg_type == A_READ) {
- arg->arg_type = O_RCAT;
- arg[2].arg_type = arg2[1].arg_type;
- arg[2].arg_ptr = arg2[1].arg_ptr;
- free_arg(arg2);
- }
- }
- return arg;
-}
-
-ARG *
-stab2arg(atype,stab)
-int atype;
-register STAB *stab;
-{
- register ARG *arg;
-
- arg = op_new(1);
- arg->arg_type = O_ITEM;
- arg[1].arg_type = atype;
- arg[1].arg_ptr.arg_stab = stab;
- return arg;
-}
-
-ARG *
-cval_to_arg(cval)
-register char *cval;
-{
- register ARG *arg;
-
- arg = op_new(1);
- arg->arg_type = O_ITEM;
- arg[1].arg_type = A_SINGLE;
- arg[1].arg_ptr.arg_str = str_make(cval,0);
- Safefree(cval);
- return arg;
-}
-
-ARG *
-op_new(numargs)
-int numargs;
-{
- register ARG *arg;
-
- Newz(203,arg, numargs + 1, ARG);
- arg->arg_ptr.arg_str = Str_new(21,0);
- arg->arg_len = numargs;
- return arg;
-}
-
-void
-free_arg(arg)
-ARG *arg;
-{
- str_free(arg->arg_ptr.arg_str);
- Safefree(arg);
-}
-
-ARG *
-make_match(type,expr,spat)
-int type;
-ARG *expr;
-SPAT *spat;
-{
- register ARG *arg;
-
- arg = make_op(type,2,expr,Nullarg,Nullarg);
-
- arg[2].arg_type = A_SPAT|A_DONT;
- arg[2].arg_ptr.arg_spat = spat;
-#ifdef DEBUGGING
- if (debug & 16)
- fprintf(stderr,"make_match SPAT=%lx\n",(long)spat);
-#endif
-
- if (type == O_SUBST || type == O_NSUBST) {
- if (arg[1].arg_type != A_STAB) {
- yyerror("Illegal lvalue");
- }
- arg[1].arg_type = A_LVAL;
- }
- return arg;
-}
-
-ARG *
-cmd_to_arg(cmd)
-CMD *cmd;
-{
- register ARG *arg;
-
- arg = op_new(1);
- arg->arg_type = O_ITEM;
- arg[1].arg_type = A_CMD;
- arg[1].arg_ptr.arg_cmd = cmd;
- return arg;
-}
-
-/* Check two expressions to see if there is any identifier in common */
-
-static int
-nothing_in_common(arg1,arg2)
-ARG *arg1;
-ARG *arg2;
-{
- static int thisexpr = 0; /* I don't care if this wraps */
-
- thisexpr++;
- if (arg_common(arg1,thisexpr,1))
- return 0; /* hit eval or do {} */
- stab_lastexpr(defstab) = thisexpr; /* pretend to hit @_ */
- if (arg_common(arg2,thisexpr,0))
- return 0; /* hit identifier again */
- return 1;
-}
-
-/* Recursively descend an expression and mark any identifier or check
- * it to see if it was marked already.
- */
-
-static int
-arg_common(arg,exprnum,marking)
-register ARG *arg;
-int exprnum;
-int marking;
-{
- register int i;
-
- if (!arg)
- return 0;
- for (i = arg->arg_len; i >= 1; i--) {
- switch (arg[i].arg_type & A_MASK) {
- case A_NULL:
- break;
- case A_LEXPR:
- case A_EXPR:
- if (arg_common(arg[i].arg_ptr.arg_arg,exprnum,marking))
- return 1;
- break;
- case A_CMD:
- return 1; /* assume hanky panky */
- case A_STAR:
- case A_LSTAR:
- case A_STAB:
- case A_LVAL:
- case A_ARYLEN:
- case A_LARYLEN:
- if (marking)
- stab_lastexpr(arg[i].arg_ptr.arg_stab) = exprnum;
- else if (stab_lastexpr(arg[i].arg_ptr.arg_stab) == exprnum)
- return 1;
- break;
- case A_DOUBLE:
- case A_BACKTICK:
- {
- register char *s = arg[i].arg_ptr.arg_str->str_ptr;
- register char *send = s + arg[i].arg_ptr.arg_str->str_cur;
- register STAB *stab;
-
- while (*s) {
- if (*s == '$' && s[1]) {
- s = scanident(s,send,tokenbuf,sizeof tokenbuf);
- stab = stabent(tokenbuf,TRUE);
- if (marking)
- stab_lastexpr(stab) = exprnum;
- else if (stab_lastexpr(stab) == exprnum)
- return 1;
- continue;
- }
- else if (*s == '\\' && s[1])
- s++;
- s++;
- }
- }
- break;
- case A_SPAT:
- if (spat_common(arg[i].arg_ptr.arg_spat,exprnum,marking))
- return 1;
- break;
- case A_READ:
- case A_INDREAD:
- case A_GLOB:
- case A_WORD:
- case A_SINGLE:
- break;
- }
- }
- switch (arg->arg_type) {
- case O_ARRAY:
- case O_LARRAY:
- if ((arg[1].arg_type & A_MASK) == A_STAB)
- (void)aadd(arg[1].arg_ptr.arg_stab);
- break;
- case O_HASH:
- case O_LHASH:
- if ((arg[1].arg_type & A_MASK) == A_STAB)
- (void)hadd(arg[1].arg_ptr.arg_stab);
- break;
- case O_EVAL:
- case O_SUBR:
- case O_DBSUBR:
- return 1;
- }
- return 0;
-}
-
-static int
-spat_common(spat,exprnum,marking)
-register SPAT *spat;
-int exprnum;
-int marking;
-{
- if (spat->spat_runtime)
- if (arg_common(spat->spat_runtime,exprnum,marking))
- return 1;
- if (spat->spat_repl) {
- if (arg_common(spat->spat_repl,exprnum,marking))
- return 1;
- }
- return 0;
-}
diff --git a/gnu/usr.bin/perl/perl/crypt.c b/gnu/usr.bin/perl/perl/crypt.c
deleted file mode 100644
index 3e95f45..0000000
--- a/gnu/usr.bin/perl/perl/crypt.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Tom Truscott.
- *
- * 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)
-/* from static char sccsid[] = "@(#)crypt.c 5.11 (Berkeley) 6/25/91"; */
-static char rcsid[] = "$Header: /home/ncvs/src/gnu/usr.bin/perl/perl/crypt.c,v 1.1.1.1 1994/09/10 06:27:37 gclarkii Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <unistd.h>
-#include <stdio.h>
-
-/*
- * UNIX password, and DES, encryption.
- *
- * since this is non-exportable, this is just a dummy. if you want real
- * encryption, make sure you've got libcrypt.a around.
- */
-
-#define SCRAMBLE /* Don't leave them in plaintext */
-
-#ifndef SCRAMBLE
-static char cryptresult[1+4+4+11+1]; /* "encrypted" result */
-
-char *
-crypt(key, setting)
- register const char *key;
- register const char *setting;
-{
- fprintf(stderr, "WARNING! crypt(3) not present in the system!\n");
- strncpy(cryptresult, key, sizeof cryptresult);
- cryptresult[sizeof cryptresult - 1] = '\0';
- return (cryptresult);
-}
-
-#else
-
-char *
-crypt(pw, salt)
- register const char *pw;
- register const char *salt;
-{
- static char password[14];
- long matrix[128], *m, vector[2];
- char a, b, *p;
- int i, value;
- unsigned short crc;
- unsigned long t;
-
- /* Ugly hack, but I'm too lazy to find the real problem - NW */
- bzero(matrix, 128 * sizeof(long));
-
- if (salt[0]) {
- a = salt[0];
- if (salt[1])
- b = salt[1];
- else
- b = a;
- } else
- a = b = '0';
- password[0] = a;
- password[1] = b;
- if (a > 'Z')
- a -= 6;
- if (a > '9')
- a -= 7;
- if (b > 'Z')
- b -= 6;
- if (b > '9')
- b -= 7;
- a -= '.';
- b -= '.';
- value = (a | (b << 6)) & 07777;
-
- crc = value;
- value += 1000;
- b = 0;
- p = (char *)pw;
- while (value--) {
- if (crc & 0x8000)
- crc = (crc << 1) ^ 0x1021;
- else
- crc <<= 1;
- if (!b) {
- b = 8;
- if (!(i = *p++)) {
- p = (char *)pw;
- i = *p++;
- }
- }
- if (i & 0x80)
- crc ^= 1;
- i <<= 1;
- b--;
- }
-
- m = matrix;
- matrix[0] = 0;
- a = 32;
- for (value = 07777; value >= 0; value--) {
- *m <<= 1;
- if (crc & 0x8000) {
- *m |= 1;
- crc = (crc << 1) ^ 0x1021;
- } else
- crc <<= 1;
- if (!b) {
- b = 8;
- if (!(i = *p++)) {
- p = (char *)pw;
- i = *p++;
- }
- }
- if (i & 0x80)
- crc ^= 1;
- i <<= 1;
- b--;
- if (!(a--)) {
- a = 32;
- *++m = 0;
- }
- }
-
- vector[0] = 0;
- vector[1] = 0;
- p = (char *) vector;
- for (i = 0; i < 7; i++)
- if (pw[i])
- *p++ = pw[i];
- else
- break;
-
- p = password + 2;
- a = 6;
- m = matrix;
- *p = 0;
- for (i = 077; i >= 0; i--) {
- t = *m++;
- t = t ^ *m++;
- t = t ^ vector[0];
- t = t ^ vector[1];
- b = 0;
- while (t) {
- if (t & 1)
- b = 1 - b;
- t >>= 1;
- }
- a--;
- if (b)
- *p |= 1 << a;
- if (!a) {
- a = 6;
- *++p = 0;
- }
- }
-
- for (i = 2; i < 13; i++) {
- password[i] += '.';
- if (password[i] > '9')
- password[i] += 7;
- if (password[i] > 'Z')
- password[i] += 6;
- }
- password[13] = 0;
-
- return password;
-}
-#endif
diff --git a/gnu/usr.bin/perl/perl/doarg.c b/gnu/usr.bin/perl/perl/doarg.c
deleted file mode 100644
index 2a64787..0000000
--- a/gnu/usr.bin/perl/perl/doarg.c
+++ /dev/null
@@ -1,1856 +0,0 @@
-/* $RCSfile: doarg.c,v $$Revision: 1.2 $$Date: 1994/09/11 03:17:30 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: doarg.c,v $
- * Revision 1.2 1994/09/11 03:17:30 gclarkii
- * Changed AF_LOCAL to AF_LOCAL_XX so as not to conflict with 4.4 socket.h
- * Added casts to shutup warnings in doio.c
- *
- * Revision 1.1.1.1 1994/09/10 06:27:32 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:35 nate
- * PERL!
- *
- * Revision 4.0.1.8 1993/02/05 19:32:27 lwall
- * patch36: substitution didn't always invalidate numericity
- *
- * Revision 4.0.1.7 92/06/11 21:07:11 lwall
- * patch34: join with null list attempted negative allocation
- * patch34: sprintf("%6.4s", "abcdefg") didn't print "abcd "
- *
- * Revision 4.0.1.6 92/06/08 12:34:30 lwall
- * patch20: removed implicit int declarations on funcions
- * patch20: pattern modifiers i and o didn't interact right
- * patch20: join() now pre-extends target string to avoid excessive copying
- * patch20: fixed confusion between a *var's real name and its effective name
- * patch20: subroutines didn't localize $`, $&, $', $1 et al correctly
- * patch20: usersub routines didn't reclaim temp values soon enough
- * patch20: ($<,$>) = ... didn't work on some architectures
- * patch20: added Atari ST portability
- *
- * Revision 4.0.1.5 91/11/11 16:31:58 lwall
- * patch19: added little-endian pack/unpack options
- *
- * Revision 4.0.1.4 91/11/05 16:35:06 lwall
- * patch11: /$foo/o optimizer could access deallocated data
- * patch11: minimum match length calculation in regexp is now cumulative
- * patch11: added some support for 64-bit integers
- * patch11: prepared for ctype implementations that don't define isascii()
- * patch11: sprintf() now supports any length of s field
- * patch11: indirect subroutine calls through magic vars (e.g. &$1) didn't work
- * patch11: defined(&$foo) and undef(&$foo) didn't work
- *
- * Revision 4.0.1.3 91/06/10 01:18:41 lwall
- * patch10: pack(hh,1) dumped core
- *
- * Revision 4.0.1.2 91/06/07 10:42:17 lwall
- * patch4: new copyright notice
- * patch4: // wouldn't use previous pattern if it started with a null character
- * patch4: //o and s///o now optimize themselves fully at runtime
- * patch4: added global modifier for pattern matches
- * patch4: undef @array disabled "@array" interpolation
- * patch4: chop("") was returning "\0" rather than ""
- * patch4: vector logical operations &, | and ^ sometimes returned null string
- * patch4: syscall couldn't pass numbers with most significant bit set on sparcs
- *
- * Revision 4.0.1.1 91/04/11 17:40:14 lwall
- * patch1: fixed undefined environ problem
- * patch1: fixed debugger coredump on subroutines
- *
- * Revision 4.0 91/03/20 01:06:42 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX)
-#include <signal.h>
-#endif
-
-extern unsigned char fold[];
-
-#ifdef BUGGY_MSC
- #pragma function(memcmp)
-#endif /* BUGGY_MSC */
-
-static void doencodes();
-
-int
-do_subst(str,arg,sp)
-STR *str;
-ARG *arg;
-int sp;
-{
- register SPAT *spat;
- SPAT *rspat;
- register STR *dstr;
- register char *s = str_get(str);
- char *strend = s + str->str_cur;
- register char *m;
- char *c;
- register char *d;
- int clen;
- int iters = 0;
- int maxiters = (strend - s) + 10;
- register int i;
- bool once;
- char *orig;
- int safebase;
-
- rspat = spat = arg[2].arg_ptr.arg_spat;
- if (!spat || !s)
- fatal("panic: do_subst");
- else if (spat->spat_runtime) {
- nointrp = "|)";
- (void)eval(spat->spat_runtime,G_SCALAR,sp);
- m = str_get(dstr = stack->ary_array[sp+1]);
- nointrp = "";
- if (spat->spat_regexp) {
- regfree(spat->spat_regexp);
- spat->spat_regexp = Null(REGEXP*); /* required if regcomp pukes */
- }
- spat->spat_regexp = regcomp(m,m+dstr->str_cur,
- spat->spat_flags & SPAT_FOLD);
- if (spat->spat_flags & SPAT_KEEP) {
- if (!(spat->spat_flags & SPAT_FOLD))
- scanconst(spat, m, dstr->str_cur);
- arg_free(spat->spat_runtime); /* it won't change, so */
- spat->spat_runtime = Nullarg; /* no point compiling again */
- hoistmust(spat);
- if (curcmd->c_expr && (curcmd->c_flags & CF_OPTIMIZE) == CFT_EVAL) {
- curcmd->c_flags &= ~CF_OPTIMIZE;
- opt_arg(curcmd, 1, curcmd->c_type == C_EXPR);
- }
- }
- }
-#ifdef DEBUGGING
- if (debug & 8) {
- deb("2.SPAT /%s/\n",spat->spat_regexp->precomp);
- }
-#endif
- safebase = ((!spat->spat_regexp || !spat->spat_regexp->nparens) &&
- !sawampersand);
- if (!spat->spat_regexp->prelen && lastspat)
- spat = lastspat;
- orig = m = s;
- if (hint) {
- if (hint < s || hint > strend)
- fatal("panic: hint in do_match");
- s = hint;
- hint = Nullch;
- if (spat->spat_regexp->regback >= 0) {
- s -= spat->spat_regexp->regback;
- if (s < m)
- s = m;
- }
- else
- s = m;
- }
- else if (spat->spat_short) {
- if (spat->spat_flags & SPAT_SCANFIRST) {
- if (str->str_pok & SP_STUDIED) {
- if (screamfirst[spat->spat_short->str_rare] < 0)
- goto nope;
- else if (!(s = screaminstr(str,spat->spat_short)))
- goto nope;
- }
-#ifndef lint
- else if (!(s = fbminstr((unsigned char*)s, (unsigned char*)strend,
- spat->spat_short)))
- goto nope;
-#endif
- if (s && spat->spat_regexp->regback >= 0) {
- ++spat->spat_short->str_u.str_useful;
- s -= spat->spat_regexp->regback;
- if (s < m)
- s = m;
- }
- else
- s = m;
- }
- else if (!multiline && (*spat->spat_short->str_ptr != *s ||
- bcmp(spat->spat_short->str_ptr, s, spat->spat_slen) ))
- goto nope;
- if (--spat->spat_short->str_u.str_useful < 0) {
- str_free(spat->spat_short);
- spat->spat_short = Nullstr; /* opt is being useless */
- }
- }
- once = !(rspat->spat_flags & SPAT_GLOBAL);
- if (rspat->spat_flags & SPAT_CONST) { /* known replacement string? */
- if ((rspat->spat_repl[1].arg_type & A_MASK) == A_SINGLE)
- dstr = rspat->spat_repl[1].arg_ptr.arg_str;
- else { /* constant over loop, anyway */
- (void)eval(rspat->spat_repl,G_SCALAR,sp);
- dstr = stack->ary_array[sp+1];
- }
- c = str_get(dstr);
- clen = dstr->str_cur;
- if (clen <= spat->spat_regexp->minlen) {
- /* can do inplace substitution */
- if (regexec(spat->spat_regexp, s, strend, orig, 0,
- str->str_pok & SP_STUDIED ? str : Nullstr, safebase)) {
- if (spat->spat_regexp->subbase) /* oops, no we can't */
- goto long_way;
- d = s;
- lastspat = spat;
- str->str_pok = SP_VALID; /* disable possible screamer */
- if (once) {
- m = spat->spat_regexp->startp[0];
- d = spat->spat_regexp->endp[0];
- s = orig;
- if (m - s > strend - d) { /* faster to shorten from end */
- if (clen) {
- Copy(c, m, clen, char);
- m += clen;
- }
- i = strend - d;
- if (i > 0) {
- Move(d, m, i, char);
- m += i;
- }
- *m = '\0';
- str->str_cur = m - s;
- STABSET(str);
- str_numset(arg->arg_ptr.arg_str, 1.0);
- stack->ary_array[++sp] = arg->arg_ptr.arg_str;
- str->str_nok = 0;
- return sp;
- }
- /*SUPPRESS 560*/
- else if (i = m - s) { /* faster from front */
- d -= clen;
- m = d;
- str_chop(str,d-i);
- s += i;
- while (i--)
- *--d = *--s;
- if (clen)
- Copy(c, m, clen, char);
- STABSET(str);
- str_numset(arg->arg_ptr.arg_str, 1.0);
- stack->ary_array[++sp] = arg->arg_ptr.arg_str;
- str->str_nok = 0;
- return sp;
- }
- else if (clen) {
- d -= clen;
- str_chop(str,d);
- Copy(c,d,clen,char);
- STABSET(str);
- str_numset(arg->arg_ptr.arg_str, 1.0);
- stack->ary_array[++sp] = arg->arg_ptr.arg_str;
- str->str_nok = 0;
- return sp;
- }
- else {
- str_chop(str,d);
- STABSET(str);
- str_numset(arg->arg_ptr.arg_str, 1.0);
- stack->ary_array[++sp] = arg->arg_ptr.arg_str;
- str->str_nok = 0;
- return sp;
- }
- /* NOTREACHED */
- }
- do {
- if (iters++ > maxiters)
- fatal("Substitution loop");
- m = spat->spat_regexp->startp[0];
- /*SUPPRESS 560*/
- if (i = m - s) {
- if (s != d)
- Move(s,d,i,char);
- d += i;
- }
- if (clen) {
- Copy(c,d,clen,char);
- d += clen;
- }
- s = spat->spat_regexp->endp[0];
- } while (regexec(spat->spat_regexp, s, strend, orig, s == m,
- Nullstr, TRUE)); /* (don't match same null twice) */
- if (s != d) {
- i = strend - s;
- str->str_cur = d - str->str_ptr + i;
- Move(s,d,i+1,char); /* include the Null */
- }
- STABSET(str);
- str_numset(arg->arg_ptr.arg_str, (double)iters);
- stack->ary_array[++sp] = arg->arg_ptr.arg_str;
- str->str_nok = 0;
- return sp;
- }
- str_numset(arg->arg_ptr.arg_str, 0.0);
- stack->ary_array[++sp] = arg->arg_ptr.arg_str;
- return sp;
- }
- }
- else
- c = Nullch;
- if (regexec(spat->spat_regexp, s, strend, orig, 0,
- str->str_pok & SP_STUDIED ? str : Nullstr, safebase)) {
- long_way:
- dstr = Str_new(25,str_len(str));
- str_nset(dstr,m,s-m);
- if (spat->spat_regexp->subbase)
- curspat = spat;
- lastspat = spat;
- do {
- if (iters++ > maxiters)
- fatal("Substitution loop");
- if (spat->spat_regexp->subbase
- && spat->spat_regexp->subbase != orig) {
- m = s;
- s = orig;
- orig = spat->spat_regexp->subbase;
- s = orig + (m - s);
- strend = s + (strend - m);
- }
- m = spat->spat_regexp->startp[0];
- str_ncat(dstr,s,m-s);
- s = spat->spat_regexp->endp[0];
- if (c) {
- if (clen)
- str_ncat(dstr,c,clen);
- }
- else {
- char *mysubbase = spat->spat_regexp->subbase;
-
- spat->spat_regexp->subbase = Nullch; /* so recursion works */
- (void)eval(rspat->spat_repl,G_SCALAR,sp);
- str_scat(dstr,stack->ary_array[sp+1]);
- if (spat->spat_regexp->subbase)
- Safefree(spat->spat_regexp->subbase);
- spat->spat_regexp->subbase = mysubbase;
- }
- if (once)
- break;
- } while (regexec(spat->spat_regexp, s, strend, orig, s == m, Nullstr,
- safebase));
- str_ncat(dstr,s,strend - s);
- str_replace(str,dstr);
- STABSET(str);
- str_numset(arg->arg_ptr.arg_str, (double)iters);
- stack->ary_array[++sp] = arg->arg_ptr.arg_str;
- str->str_nok = 0;
- return sp;
- }
- str_numset(arg->arg_ptr.arg_str, 0.0);
- stack->ary_array[++sp] = arg->arg_ptr.arg_str;
- return sp;
-
-nope:
- ++spat->spat_short->str_u.str_useful;
- str_numset(arg->arg_ptr.arg_str, 0.0);
- stack->ary_array[++sp] = arg->arg_ptr.arg_str;
- return sp;
-}
-#ifdef BUGGY_MSC
- #pragma intrinsic(memcmp)
-#endif /* BUGGY_MSC */
-
-int
-do_trans(str,arg)
-STR *str;
-ARG *arg;
-{
- register short *tbl;
- register char *s;
- register int matches = 0;
- register int ch;
- register char *send;
- register char *d;
- register int squash = arg[2].arg_len & 1;
-
- tbl = (short*) arg[2].arg_ptr.arg_cval;
- s = str_get(str);
- send = s + str->str_cur;
- if (!tbl || !s)
- fatal("panic: do_trans");
-#ifdef DEBUGGING
- if (debug & 8) {
- deb("2.TBL\n");
- }
-#endif
- if (!arg[2].arg_len) {
- while (s < send) {
- if ((ch = tbl[*s & 0377]) >= 0) {
- matches++;
- *s = ch;
- }
- s++;
- }
- }
- else {
- d = s;
- while (s < send) {
- if ((ch = tbl[*s & 0377]) >= 0) {
- *d = ch;
- if (matches++ && squash) {
- if (d[-1] == *d)
- matches--;
- else
- d++;
- }
- else
- d++;
- }
- else if (ch == -1) /* -1 is unmapped character */
- *d++ = *s; /* -2 is delete character */
- s++;
- }
- matches += send - d; /* account for disappeared chars */
- *d = '\0';
- str->str_cur = d - str->str_ptr;
- }
- STABSET(str);
- return matches;
-}
-
-void
-do_join(str,arglast)
-register STR *str;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- int sp = arglast[1];
- register int items = arglast[2] - sp;
- register char *delim = str_get(st[sp]);
- register STRLEN len;
- int delimlen = st[sp]->str_cur;
-
- st += sp + 1;
-
- len = (items > 0 ? (delimlen * (items - 1) ) : 0);
- if (str->str_len < len + items) { /* current length is way too short */
- while (items-- > 0) {
- if (*st)
- len += (*st)->str_cur;
- st++;
- }
- STR_GROW(str, len + 1); /* so try to pre-extend */
-
- items = arglast[2] - sp;
- st -= items;
- }
-
- if (items-- > 0)
- str_sset(str, *st++);
- else
- str_set(str,"");
- len = delimlen;
- if (len) {
- for (; items > 0; items--,st++) {
- str_ncat(str,delim,len);
- str_scat(str,*st);
- }
- }
- else {
- for (; items > 0; items--,st++)
- str_scat(str,*st);
- }
- STABSET(str);
-}
-
-void
-do_pack(str,arglast)
-register STR *str;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int items;
- register char *pat = str_get(st[sp]);
- register char *patend = pat + st[sp]->str_cur;
- register int len;
- int datumtype;
- STR *fromstr;
- /*SUPPRESS 442*/
- static char *null10 = "\0\0\0\0\0\0\0\0\0\0";
- static char *space10 = " ";
-
- /* These must not be in registers: */
- char achar;
- short ashort;
- int aint;
- unsigned int auint;
- long along;
- unsigned long aulong;
-#ifdef QUAD
- quad aquad;
- unsigned quad auquad;
-#endif
- char *aptr;
- float afloat;
- double adouble;
-
- items = arglast[2] - sp;
- st += ++sp;
- str_nset(str,"",0);
- while (pat < patend) {
-#define NEXTFROM (items-- > 0 ? *st++ : &str_no)
- datumtype = *pat++;
- if (*pat == '*') {
- len = index("@Xxu",datumtype) ? 0 : items;
- pat++;
- }
- else if (isDIGIT(*pat)) {
- len = *pat++ - '0';
- while (isDIGIT(*pat))
- len = (len * 10) + (*pat++ - '0');
- }
- else
- len = 1;
- switch(datumtype) {
- default:
- break;
- case '%':
- fatal("% may only be used in unpack");
- case '@':
- len -= str->str_cur;
- if (len > 0)
- goto grow;
- len = -len;
- if (len > 0)
- goto shrink;
- break;
- case 'X':
- shrink:
- if (str->str_cur < len)
- fatal("X outside of string");
- str->str_cur -= len;
- str->str_ptr[str->str_cur] = '\0';
- break;
- case 'x':
- grow:
- while (len >= 10) {
- str_ncat(str,null10,10);
- len -= 10;
- }
- str_ncat(str,null10,len);
- break;
- case 'A':
- case 'a':
- fromstr = NEXTFROM;
- aptr = str_get(fromstr);
- if (pat[-1] == '*')
- len = fromstr->str_cur;
- if (fromstr->str_cur > len)
- str_ncat(str,aptr,len);
- else {
- str_ncat(str,aptr,fromstr->str_cur);
- len -= fromstr->str_cur;
- if (datumtype == 'A') {
- while (len >= 10) {
- str_ncat(str,space10,10);
- len -= 10;
- }
- str_ncat(str,space10,len);
- }
- else {
- while (len >= 10) {
- str_ncat(str,null10,10);
- len -= 10;
- }
- str_ncat(str,null10,len);
- }
- }
- break;
- case 'B':
- case 'b':
- {
- char *savepat = pat;
- int saveitems;
-
- fromstr = NEXTFROM;
- saveitems = items;
- aptr = str_get(fromstr);
- if (pat[-1] == '*')
- len = fromstr->str_cur;
- pat = aptr;
- aint = str->str_cur;
- str->str_cur += (len+7)/8;
- STR_GROW(str, str->str_cur + 1);
- aptr = str->str_ptr + aint;
- if (len > fromstr->str_cur)
- len = fromstr->str_cur;
- aint = len;
- items = 0;
- if (datumtype == 'B') {
- for (len = 0; len++ < aint;) {
- items |= *pat++ & 1;
- if (len & 7)
- items <<= 1;
- else {
- *aptr++ = items & 0xff;
- items = 0;
- }
- }
- }
- else {
- for (len = 0; len++ < aint;) {
- if (*pat++ & 1)
- items |= 128;
- if (len & 7)
- items >>= 1;
- else {
- *aptr++ = items & 0xff;
- items = 0;
- }
- }
- }
- if (aint & 7) {
- if (datumtype == 'B')
- items <<= 7 - (aint & 7);
- else
- items >>= 7 - (aint & 7);
- *aptr++ = items & 0xff;
- }
- pat = str->str_ptr + str->str_cur;
- while (aptr <= pat)
- *aptr++ = '\0';
-
- pat = savepat;
- items = saveitems;
- }
- break;
- case 'H':
- case 'h':
- {
- char *savepat = pat;
- int saveitems;
-
- fromstr = NEXTFROM;
- saveitems = items;
- aptr = str_get(fromstr);
- if (pat[-1] == '*')
- len = fromstr->str_cur;
- pat = aptr;
- aint = str->str_cur;
- str->str_cur += (len+1)/2;
- STR_GROW(str, str->str_cur + 1);
- aptr = str->str_ptr + aint;
- if (len > fromstr->str_cur)
- len = fromstr->str_cur;
- aint = len;
- items = 0;
- if (datumtype == 'H') {
- for (len = 0; len++ < aint;) {
- if (isALPHA(*pat))
- items |= ((*pat++ & 15) + 9) & 15;
- else
- items |= *pat++ & 15;
- if (len & 1)
- items <<= 4;
- else {
- *aptr++ = items & 0xff;
- items = 0;
- }
- }
- }
- else {
- for (len = 0; len++ < aint;) {
- if (isALPHA(*pat))
- items |= (((*pat++ & 15) + 9) & 15) << 4;
- else
- items |= (*pat++ & 15) << 4;
- if (len & 1)
- items >>= 4;
- else {
- *aptr++ = items & 0xff;
- items = 0;
- }
- }
- }
- if (aint & 1)
- *aptr++ = items & 0xff;
- pat = str->str_ptr + str->str_cur;
- while (aptr <= pat)
- *aptr++ = '\0';
-
- pat = savepat;
- items = saveitems;
- }
- break;
- case 'C':
- case 'c':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- aint = (int)str_gnum(fromstr);
- achar = aint;
- str_ncat(str,&achar,sizeof(char));
- }
- break;
- /* Float and double added by gnb@melba.bby.oz.au 22/11/89 */
- case 'f':
- case 'F':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- afloat = (float)str_gnum(fromstr);
- str_ncat(str, (char *)&afloat, sizeof (float));
- }
- break;
- case 'd':
- case 'D':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- adouble = (double)str_gnum(fromstr);
- str_ncat(str, (char *)&adouble, sizeof (double));
- }
- break;
- case 'n':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- ashort = (short)str_gnum(fromstr);
-#ifdef HAS_HTONS
- ashort = htons(ashort);
-#endif
- str_ncat(str,(char*)&ashort,sizeof(short));
- }
- break;
- case 'v':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- ashort = (short)str_gnum(fromstr);
-#ifdef HAS_HTOVS
- ashort = htovs(ashort);
-#endif
- str_ncat(str,(char*)&ashort,sizeof(short));
- }
- break;
- case 'S':
- case 's':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- ashort = (short)str_gnum(fromstr);
- str_ncat(str,(char*)&ashort,sizeof(short));
- }
- break;
- case 'I':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- auint = U_I(str_gnum(fromstr));
- str_ncat(str,(char*)&auint,sizeof(unsigned int));
- }
- break;
- case 'i':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- aint = (int)str_gnum(fromstr);
- str_ncat(str,(char*)&aint,sizeof(int));
- }
- break;
- case 'N':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- aulong = U_L(str_gnum(fromstr));
-#ifdef HAS_HTONL
- aulong = htonl(aulong);
-#endif
- str_ncat(str,(char*)&aulong,sizeof(unsigned long));
- }
- break;
- case 'V':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- aulong = U_L(str_gnum(fromstr));
-#ifdef HAS_HTOVL
- aulong = htovl(aulong);
-#endif
- str_ncat(str,(char*)&aulong,sizeof(unsigned long));
- }
- break;
- case 'L':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- aulong = U_L(str_gnum(fromstr));
- str_ncat(str,(char*)&aulong,sizeof(unsigned long));
- }
- break;
- case 'l':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- along = (long)str_gnum(fromstr);
- str_ncat(str,(char*)&along,sizeof(long));
- }
- break;
-#ifdef QUAD
- case 'Q':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- auquad = (unsigned quad)str_gnum(fromstr);
- str_ncat(str,(char*)&auquad,sizeof(unsigned quad));
- }
- break;
- case 'q':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- aquad = (quad)str_gnum(fromstr);
- str_ncat(str,(char*)&aquad,sizeof(quad));
- }
- break;
-#endif /* QUAD */
- case 'p':
- while (len-- > 0) {
- fromstr = NEXTFROM;
- aptr = str_get(fromstr);
- str_ncat(str,(char*)&aptr,sizeof(char*));
- }
- break;
- case 'u':
- fromstr = NEXTFROM;
- aptr = str_get(fromstr);
- aint = fromstr->str_cur;
- STR_GROW(str,aint * 4 / 3);
- if (len <= 1)
- len = 45;
- else
- len = len / 3 * 3;
- while (aint > 0) {
- int todo;
-
- if (aint > len)
- todo = len;
- else
- todo = aint;
- doencodes(str, aptr, todo);
- aint -= todo;
- aptr += todo;
- }
- break;
- }
- }
- STABSET(str);
-}
-#undef NEXTFROM
-
-static void
-doencodes(str, s, len)
-register STR *str;
-register char *s;
-register int len;
-{
- char hunk[5];
-
- *hunk = len + ' ';
- str_ncat(str, hunk, 1);
- hunk[4] = '\0';
- while (len > 0) {
- hunk[0] = ' ' + (077 & (*s >> 2));
- hunk[1] = ' ' + (077 & ((*s << 4) & 060 | (s[1] >> 4) & 017));
- hunk[2] = ' ' + (077 & ((s[1] << 2) & 074 | (s[2] >> 6) & 03));
- hunk[3] = ' ' + (077 & (s[2] & 077));
- str_ncat(str, hunk, 4);
- s += 3;
- len -= 3;
- }
- for (s = str->str_ptr; *s; s++) {
- if (*s == ' ')
- *s = '`';
- }
- str_ncat(str, "\n", 1);
-}
-
-void
-do_sprintf(str,len,sarg)
-register STR *str;
-register int len;
-register STR **sarg;
-{
- register char *s;
- register char *t;
- register char *f;
- bool dolong;
-#ifdef QUAD
- bool doquad;
-#endif /* QUAD */
- char ch;
- static STR *sargnull = &str_no;
- register char *send;
- register STR *arg;
- char *xs;
- int xlen;
- int pre;
- int post;
- double value;
-
- str_set(str,"");
- len--; /* don't count pattern string */
- t = s = str_get(*sarg);
- send = s + (*sarg)->str_cur;
- sarg++;
- for ( ; ; len--) {
-
- /*SUPPRESS 560*/
- if (len <= 0 || !(arg = *sarg++))
- arg = sargnull;
-
- /*SUPPRESS 530*/
- for ( ; t < send && *t != '%'; t++) ;
- if (t >= send)
- break; /* end of format string, ignore extra args */
- f = t;
- *buf = '\0';
- xs = buf;
-#ifdef QUAD
- doquad =
-#endif /* QUAD */
- dolong = FALSE;
- pre = post = 0;
- for (t++; t < send; t++) {
- switch (*t) {
- default:
- ch = *(++t);
- *t = '\0';
- (void)sprintf(xs,f);
- len++, sarg--;
- xlen = strlen(xs);
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case '.': case '#': case '-': case '+': case ' ':
- continue;
- case 'l':
-#ifdef QUAD
- if (dolong) {
- dolong = FALSE;
- doquad = TRUE;
- } else
-#endif
- dolong = TRUE;
- continue;
- case 'c':
- ch = *(++t);
- *t = '\0';
- xlen = (int)str_gnum(arg);
- if (strEQ(f,"%c")) { /* some printfs fail on null chars */
- *xs = xlen;
- xs[1] = '\0';
- xlen = 1;
- }
- else {
- (void)sprintf(xs,f,xlen);
- xlen = strlen(xs);
- }
- break;
- case 'D':
- dolong = TRUE;
- /* FALL THROUGH */
- case 'd':
- ch = *(++t);
- *t = '\0';
-#ifdef QUAD
- if (doquad)
- (void)sprintf(buf,s,(quad)str_gnum(arg));
- else
-#endif
- if (dolong)
- (void)sprintf(xs,f,(long)str_gnum(arg));
- else
- (void)sprintf(xs,f,(int)str_gnum(arg));
- xlen = strlen(xs);
- break;
- case 'X': case 'O':
- dolong = TRUE;
- /* FALL THROUGH */
- case 'x': case 'o': case 'u':
- ch = *(++t);
- *t = '\0';
- value = str_gnum(arg);
-#ifdef QUAD
- if (doquad)
- (void)sprintf(buf,s,(unsigned quad)value);
- else
-#endif
- if (dolong)
- (void)sprintf(xs,f,U_L(value));
- else
- (void)sprintf(xs,f,U_I(value));
- xlen = strlen(xs);
- break;
- case 'E': case 'e': case 'f': case 'G': case 'g':
- ch = *(++t);
- *t = '\0';
- (void)sprintf(xs,f,str_gnum(arg));
- xlen = strlen(xs);
- break;
- case 's':
- ch = *(++t);
- *t = '\0';
- xs = str_get(arg);
- xlen = arg->str_cur;
- if (*xs == 'S' && xs[1] == 't' && xs[2] == 'B' && xs[3] == '\0'
- && xlen == sizeof(STBP)) {
- STR *tmpstr = Str_new(24,0);
-
- stab_efullname(tmpstr, ((STAB*)arg)); /* a stab value! */
- sprintf(tokenbuf,"*%s",tmpstr->str_ptr);
- /* reformat to non-binary */
- xs = tokenbuf;
- xlen = strlen(tokenbuf);
- str_free(tmpstr);
- }
- if (strEQ(f,"%s")) { /* some printfs fail on >128 chars */
- break; /* so handle simple cases */
- }
- else if (f[1] == '-') {
- char *mp = index(f, '.');
- int min = atoi(f+2);
-
- if (mp) {
- int max = atoi(mp+1);
-
- if (xlen > max)
- xlen = max;
- }
- if (xlen < min)
- post = min - xlen;
- break;
- }
- else if (isDIGIT(f[1])) {
- char *mp = index(f, '.');
- int min = atoi(f+1);
-
- if (mp) {
- int max = atoi(mp+1);
-
- if (xlen > max)
- xlen = max;
- }
- if (xlen < min)
- pre = min - xlen;
- break;
- }
- strcpy(tokenbuf+64,f); /* sprintf($s,...$s...) */
- *t = ch;
- (void)sprintf(buf,tokenbuf+64,xs);
- xs = buf;
- xlen = strlen(xs);
- break;
- }
- /* end of switch, copy results */
- *t = ch;
- STR_GROW(str, str->str_cur + (f - s) + xlen + 1 + pre + post);
- str_ncat(str, s, f - s);
- if (pre) {
- repeatcpy(str->str_ptr + str->str_cur, " ", 1, pre);
- str->str_cur += pre;
- }
- str_ncat(str, xs, xlen);
- if (post) {
- repeatcpy(str->str_ptr + str->str_cur, " ", 1, post);
- str->str_cur += post;
- }
- s = t;
- break; /* break from for loop */
- }
- }
- str_ncat(str, s, t - s);
- STABSET(str);
-}
-
-STR *
-do_push(ary,arglast)
-register ARRAY *ary;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int items = arglast[2] - sp;
- register STR *str = &str_undef;
-
- for (st += ++sp; items > 0; items--,st++) {
- str = Str_new(26,0);
- if (*st)
- str_sset(str,*st);
- (void)apush(ary,str);
- }
- return str;
-}
-
-void
-do_unshift(ary,arglast)
-register ARRAY *ary;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int items = arglast[2] - sp;
- register STR *str;
- register int i;
-
- aunshift(ary,items);
- i = 0;
- for (st += ++sp; i < items; i++,st++) {
- str = Str_new(27,0);
- str_sset(str,*st);
- (void)astore(ary,i,str);
- }
-}
-
-int
-do_subr(arg,gimme,arglast)
-register ARG *arg;
-int gimme;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int items = arglast[2] - sp;
- register SUBR *sub;
- SPAT * VOLATILE oldspat = curspat;
- STR *str;
- STAB *stab;
- int oldsave = savestack->ary_fill;
- int oldtmps_base = tmps_base;
- int hasargs = ((arg[2].arg_type & A_MASK) != A_NULL);
- register CSV *csv;
-
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else {
- STR *tmpstr = STAB_STR(arg[1].arg_ptr.arg_stab);
-
- if (tmpstr)
- stab = stabent(str_get(tmpstr),TRUE);
- else
- stab = Nullstab;
- }
- if (!stab)
- fatal("Undefined subroutine called");
- if (!(sub = stab_sub(stab))) {
- STR *tmpstr = arg[0].arg_ptr.arg_str;
-
- stab_efullname(tmpstr, stab);
- fatal("Undefined subroutine \"%s\" called",tmpstr->str_ptr);
- }
- if (arg->arg_type == O_DBSUBR && !sub->usersub) {
- str = stab_val(DBsub);
- saveitem(str);
- stab_efullname(str,stab);
- sub = stab_sub(DBsub);
- if (!sub)
- fatal("No DBsub routine");
- }
- str = Str_new(15, sizeof(CSV));
- str->str_state = SS_SCSV;
- (void)apush(savestack,str);
- csv = (CSV*)str->str_ptr;
- csv->sub = sub;
- csv->stab = stab;
- csv->curcsv = curcsv;
- csv->curcmd = curcmd;
- csv->depth = sub->depth;
- csv->wantarray = gimme;
- csv->hasargs = hasargs;
- curcsv = csv;
- tmps_base = tmps_max;
- if (sub->usersub) {
- csv->hasargs = 0;
- csv->savearray = Null(ARRAY*);;
- csv->argarray = Null(ARRAY*);
- st[sp] = arg->arg_ptr.arg_str;
- if (!hasargs)
- items = 0;
- sp = (*sub->usersub)(sub->userindex,sp,items);
- }
- else {
- if (hasargs) {
- csv->savearray = stab_xarray(defstab);
- csv->argarray = afake(defstab, items, &st[sp+1]);
- stab_xarray(defstab) = csv->argarray;
- }
- sub->depth++;
- if (sub->depth >= 2) { /* save temporaries on recursion? */
- if (sub->depth == 100 && dowarn)
- warn("Deep recursion on subroutine \"%s\"",stab_ename(stab));
- savelist(sub->tosave->ary_array,sub->tosave->ary_fill);
- }
- sp = cmd_exec(sub->cmd,gimme, --sp); /* so do it already */
- }
-
- st = stack->ary_array;
- tmps_base = oldtmps_base;
- for (items = arglast[0] + 1; items <= sp; items++)
- st[items] = str_mortal(st[items]);
- /* in case restore wipes old str */
- restorelist(oldsave);
- curspat = oldspat;
- return sp;
-}
-
-int
-do_assign(arg,gimme,arglast)
-register ARG *arg;
-int gimme;
-int *arglast;
-{
-
- register STR **st = stack->ary_array;
- STR **firstrelem = st + arglast[1] + 1;
- STR **firstlelem = st + arglast[0] + 1;
- STR **lastrelem = st + arglast[2];
- STR **lastlelem = st + arglast[1];
- register STR **relem;
- register STR **lelem;
-
- register STR *str;
- register ARRAY *ary;
- register int makelocal;
- HASH *hash;
- int i;
-
- makelocal = (arg->arg_flags & AF_LOCAL_XX) != 0;
- localizing = makelocal;
- delaymagic = DM_DELAY; /* catch simultaneous items */
-
- /* If there's a common identifier on both sides we have to take
- * special care that assigning the identifier on the left doesn't
- * clobber a value on the right that's used later in the list.
- */
- if (arg->arg_flags & AF_COMMON) {
- for (relem = firstrelem; relem <= lastrelem; relem++) {
- /*SUPPRESS 560*/
- if (str = *relem)
- *relem = str_mortal(str);
- }
- }
- relem = firstrelem;
- lelem = firstlelem;
- ary = Null(ARRAY*);
- hash = Null(HASH*);
- while (lelem <= lastlelem) {
- str = *lelem++;
- if (str->str_state >= SS_HASH) {
- if (str->str_state == SS_ARY) {
- if (makelocal)
- ary = saveary(str->str_u.str_stab);
- else {
- ary = stab_array(str->str_u.str_stab);
- ary->ary_fill = -1;
- }
- i = 0;
- while (relem <= lastrelem) { /* gobble up all the rest */
- str = Str_new(28,0);
- if (*relem)
- str_sset(str,*relem);
- *(relem++) = str;
- (void)astore(ary,i++,str);
- }
- }
- else if (str->str_state == SS_HASH) {
- char *tmps;
- STR *tmpstr;
- int magic = 0;
- STAB *tmpstab = str->str_u.str_stab;
-
- if (makelocal)
- hash = savehash(str->str_u.str_stab);
- else {
- hash = stab_hash(str->str_u.str_stab);
- if (tmpstab == envstab) {
- magic = 'E';
- environ[0] = Nullch;
- }
- else if (tmpstab == sigstab) {
- magic = 'S';
-#ifndef NSIG
-#define NSIG 32
-#endif
- for (i = 1; i < NSIG; i++)
- signal(i, SIG_DFL); /* crunch, crunch, crunch */
- }
-#ifdef SOME_DBM
- else if (hash->tbl_dbm)
- magic = 'D';
-#endif
- hclear(hash, magic == 'D'); /* wipe any dbm file too */
-
- }
- while (relem < lastrelem) { /* gobble up all the rest */
- if (*relem)
- str = *(relem++);
- else
- str = &str_no, relem++;
- tmps = str_get(str);
- tmpstr = Str_new(29,0);
- if (*relem)
- str_sset(tmpstr,*relem); /* value */
- *(relem++) = tmpstr;
- (void)hstore(hash,tmps,str->str_cur,tmpstr,0);
- if (magic) {
- str_magic(tmpstr, tmpstab, magic, tmps, str->str_cur);
- stabset(tmpstr->str_magic, tmpstr);
- }
- }
- }
- else
- fatal("panic: do_assign");
- }
- else {
- if (makelocal)
- saveitem(str);
- if (relem <= lastrelem) {
- str_sset(str, *relem);
- *(relem++) = str;
- }
- else {
- str_sset(str, &str_undef);
- if (gimme == G_ARRAY) {
- i = ++lastrelem - firstrelem;
- relem++; /* tacky, I suppose */
- astore(stack,i,str);
- if (st != stack->ary_array) {
- st = stack->ary_array;
- firstrelem = st + arglast[1] + 1;
- firstlelem = st + arglast[0] + 1;
- lastlelem = st + arglast[1];
- lastrelem = st + i;
- relem = lastrelem + 1;
- }
- }
- }
- STABSET(str);
- }
- }
- if (delaymagic & ~DM_DELAY) {
- if (delaymagic & DM_UID) {
-#ifdef HAS_SETREUID
- (void)setreuid(uid,euid);
-#else /* not HAS_SETREUID */
-#ifdef HAS_SETRUID
- if ((delaymagic & DM_UID) == DM_RUID) {
- (void)setruid(uid);
- delaymagic =~ DM_RUID;
- }
-#endif /* HAS_SETRUID */
-#ifdef HAS_SETEUID
- if ((delaymagic & DM_UID) == DM_EUID) {
- (void)seteuid(uid);
- delaymagic =~ DM_EUID;
- }
-#endif /* HAS_SETEUID */
- if (delaymagic & DM_UID) {
- if (uid != euid)
- fatal("No setreuid available");
- (void)setuid(uid);
- }
-#endif /* not HAS_SETREUID */
- uid = (int)getuid();
- euid = (int)geteuid();
- }
- if (delaymagic & DM_GID) {
-#ifdef HAS_SETREGID
- (void)setregid(gid,egid);
-#else /* not HAS_SETREGID */
-#ifdef HAS_SETRGID
- if ((delaymagic & DM_GID) == DM_RGID) {
- (void)setrgid(gid);
- delaymagic =~ DM_RGID;
- }
-#endif /* HAS_SETRGID */
-#ifdef HAS_SETEGID
- if ((delaymagic & DM_GID) == DM_EGID) {
- (void)setegid(gid);
- delaymagic =~ DM_EGID;
- }
-#endif /* HAS_SETEGID */
- if (delaymagic & DM_GID) {
- if (gid != egid)
- fatal("No setregid available");
- (void)setgid(gid);
- }
-#endif /* not HAS_SETREGID */
- gid = (int)getgid();
- egid = (int)getegid();
- }
- }
- delaymagic = 0;
- localizing = FALSE;
- if (gimme == G_ARRAY) {
- i = lastrelem - firstrelem + 1;
- if (ary || hash)
- Copy(firstrelem, firstlelem, i, STR*);
- return arglast[0] + i;
- }
- else {
- str_numset(arg->arg_ptr.arg_str,(double)(arglast[2] - arglast[1]));
- *firstlelem = arg->arg_ptr.arg_str;
- return arglast[0] + 1;
- }
-}
-
-int /*SUPPRESS 590*/
-do_study(str,arg,gimme,arglast)
-STR *str;
-ARG *arg;
-int gimme;
-int *arglast;
-{
- register unsigned char *s;
- register int pos = str->str_cur;
- register int ch;
- register int *sfirst;
- register int *snext;
- static int maxscream = -1;
- static STR *lastscream = Nullstr;
- int retval;
- int retarg = arglast[0] + 1;
-
-#ifndef lint
- s = (unsigned char*)(str_get(str));
-#else
- s = Null(unsigned char*);
-#endif
- if (lastscream)
- lastscream->str_pok &= ~SP_STUDIED;
- lastscream = str;
- if (pos <= 0) {
- retval = 0;
- goto ret;
- }
- if (pos > maxscream) {
- if (maxscream < 0) {
- maxscream = pos + 80;
- New(301,screamfirst, 256, int);
- New(302,screamnext, maxscream, int);
- }
- else {
- maxscream = pos + pos / 4;
- Renew(screamnext, maxscream, int);
- }
- }
-
- sfirst = screamfirst;
- snext = screamnext;
-
- if (!sfirst || !snext)
- fatal("do_study: out of memory");
-
- for (ch = 256; ch; --ch)
- *sfirst++ = -1;
- sfirst -= 256;
-
- while (--pos >= 0) {
- ch = s[pos];
- if (sfirst[ch] >= 0)
- snext[pos] = sfirst[ch] - pos;
- else
- snext[pos] = -pos;
- sfirst[ch] = pos;
-
- /* If there were any case insensitive searches, we must assume they
- * all are. This speeds up insensitive searches much more than
- * it slows down sensitive ones.
- */
- if (sawi)
- sfirst[fold[ch]] = pos;
- }
-
- str->str_pok |= SP_STUDIED;
- retval = 1;
- ret:
- str_numset(arg->arg_ptr.arg_str,(double)retval);
- stack->ary_array[retarg] = arg->arg_ptr.arg_str;
- return retarg;
-}
-
-int /*SUPPRESS 590*/
-do_defined(str,arg,gimme,arglast)
-STR *str;
-register ARG *arg;
-int gimme;
-int *arglast;
-{
- register int type;
- register int retarg = arglast[0] + 1;
- int retval;
- ARRAY *ary;
- HASH *hash;
-
- if ((arg[1].arg_type & A_MASK) != A_LEXPR)
- fatal("Illegal argument to defined()");
- arg = arg[1].arg_ptr.arg_arg;
- type = arg->arg_type;
-
- if (type == O_SUBR || type == O_DBSUBR) {
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- retval = stab_sub(arg[1].arg_ptr.arg_stab) != 0;
- else {
- STR *tmpstr = STAB_STR(arg[1].arg_ptr.arg_stab);
-
- retval = tmpstr && stab_sub(stabent(str_get(tmpstr),TRUE)) != 0;
- }
- }
- else if (type == O_ARRAY || type == O_LARRAY ||
- type == O_ASLICE || type == O_LASLICE )
- retval = ((ary = stab_xarray(arg[1].arg_ptr.arg_stab)) != 0
- && ary->ary_max >= 0 );
- else if (type == O_HASH || type == O_LHASH ||
- type == O_HSLICE || type == O_LHSLICE )
- retval = ((hash = stab_xhash(arg[1].arg_ptr.arg_stab)) != 0
- && hash->tbl_array);
- else
- retval = FALSE;
- str_numset(str,(double)retval);
- stack->ary_array[retarg] = str;
- return retarg;
-}
-
-int /*SUPPRESS 590*/
-do_undef(str,arg,gimme,arglast)
-STR *str;
-register ARG *arg;
-int gimme;
-int *arglast;
-{
- register int type;
- register STAB *stab;
- int retarg = arglast[0] + 1;
-
- if ((arg[1].arg_type & A_MASK) != A_LEXPR)
- fatal("Illegal argument to undef()");
- arg = arg[1].arg_ptr.arg_arg;
- type = arg->arg_type;
-
- if (type == O_ARRAY || type == O_LARRAY) {
- stab = arg[1].arg_ptr.arg_stab;
- afree(stab_xarray(stab));
- stab_xarray(stab) = anew(stab); /* so "@array" still works */
- }
- else if (type == O_HASH || type == O_LHASH) {
- stab = arg[1].arg_ptr.arg_stab;
- if (stab == envstab)
- environ[0] = Nullch;
- else if (stab == sigstab) {
- int i;
-
- for (i = 1; i < NSIG; i++)
- signal(i, SIG_DFL); /* munch, munch, munch */
- }
- (void)hfree(stab_xhash(stab), TRUE);
- stab_xhash(stab) = Null(HASH*);
- }
- else if (type == O_SUBR || type == O_DBSUBR) {
- stab = arg[1].arg_ptr.arg_stab;
- if ((arg[1].arg_type & A_MASK) != A_WORD) {
- STR *tmpstr = STAB_STR(arg[1].arg_ptr.arg_stab);
-
- if (tmpstr)
- stab = stabent(str_get(tmpstr),TRUE);
- else
- stab = Nullstab;
- }
- if (stab && stab_sub(stab)) {
- cmd_free(stab_sub(stab)->cmd);
- stab_sub(stab)->cmd = Nullcmd;
- afree(stab_sub(stab)->tosave);
- Safefree(stab_sub(stab));
- stab_sub(stab) = Null(SUBR*);
- }
- }
- else
- fatal("Can't undefine that kind of object");
- str_numset(str,0.0);
- stack->ary_array[retarg] = str;
- return retarg;
-}
-
-int
-do_vec(lvalue,astr,arglast)
-int lvalue;
-STR *astr;
-int *arglast;
-{
- STR **st = stack->ary_array;
- int sp = arglast[0];
- register STR *str = st[++sp];
- register int offset = (int)str_gnum(st[++sp]);
- register int size = (int)str_gnum(st[++sp]);
- unsigned char *s = (unsigned char*)str_get(str);
- unsigned long retnum;
- int len;
-
- sp = arglast[1];
- offset *= size; /* turn into bit offset */
- len = (offset + size + 7) / 8;
- if (offset < 0 || size < 1)
- retnum = 0;
- else if (!lvalue && len > str->str_cur)
- retnum = 0;
- else {
- if (len > str->str_cur) {
- STR_GROW(str,len);
- (void)memzero(str->str_ptr + str->str_cur, len - str->str_cur);
- str->str_cur = len;
- }
- s = (unsigned char*)str_get(str);
- if (size < 8)
- retnum = (s[offset >> 3] >> (offset & 7)) & ((1 << size) - 1);
- else {
- offset >>= 3;
- if (size == 8)
- retnum = s[offset];
- else if (size == 16)
- retnum = ((unsigned long) s[offset] << 8) + s[offset+1];
- else if (size == 32)
- retnum = ((unsigned long) s[offset] << 24) +
- ((unsigned long) s[offset + 1] << 16) +
- (s[offset + 2] << 8) + s[offset+3];
- }
-
- if (lvalue) { /* it's an lvalue! */
- struct lstring *lstr = (struct lstring*)astr;
-
- astr->str_magic = str;
- st[sp]->str_rare = 'v';
- lstr->lstr_offset = offset;
- lstr->lstr_len = size;
- }
- }
-
- str_numset(astr,(double)retnum);
- st[sp] = astr;
- return sp;
-}
-
-void
-do_vecset(mstr,str)
-STR *mstr;
-STR *str;
-{
- struct lstring *lstr = (struct lstring*)str;
- register int offset;
- register int size;
- register unsigned char *s = (unsigned char*)mstr->str_ptr;
- register unsigned long lval = U_L(str_gnum(str));
- int mask;
-
- mstr->str_rare = 0;
- str->str_magic = Nullstr;
- offset = lstr->lstr_offset;
- size = lstr->lstr_len;
- if (size < 8) {
- mask = (1 << size) - 1;
- size = offset & 7;
- lval &= mask;
- offset >>= 3;
- s[offset] &= ~(mask << size);
- s[offset] |= lval << size;
- }
- else {
- if (size == 8)
- s[offset] = lval & 255;
- else if (size == 16) {
- s[offset] = (lval >> 8) & 255;
- s[offset+1] = lval & 255;
- }
- else if (size == 32) {
- s[offset] = (lval >> 24) & 255;
- s[offset+1] = (lval >> 16) & 255;
- s[offset+2] = (lval >> 8) & 255;
- s[offset+3] = lval & 255;
- }
- }
-}
-
-void
-do_chop(astr,str)
-register STR *astr;
-register STR *str;
-{
- register char *tmps;
- register int i;
- ARRAY *ary;
- HASH *hash;
- HENT *entry;
-
- if (!str)
- return;
- if (str->str_state == SS_ARY) {
- ary = stab_array(str->str_u.str_stab);
- for (i = 0; i <= ary->ary_fill; i++)
- do_chop(astr,ary->ary_array[i]);
- return;
- }
- if (str->str_state == SS_HASH) {
- hash = stab_hash(str->str_u.str_stab);
- (void)hiterinit(hash);
- /*SUPPRESS 560*/
- while (entry = hiternext(hash))
- do_chop(astr,hiterval(hash,entry));
- return;
- }
- tmps = str_get(str);
- if (tmps && str->str_cur) {
- tmps += str->str_cur - 1;
- str_nset(astr,tmps,1); /* remember last char */
- *tmps = '\0'; /* wipe it out */
- str->str_cur = tmps - str->str_ptr;
- str->str_nok = 0;
- STABSET(str);
- }
- else
- str_nset(astr,"",0);
-}
-
-void
-do_vop(optype,str,left,right)
-STR *str;
-STR *left;
-STR *right;
-{
- register char *s;
- register char *l = str_get(left);
- register char *r = str_get(right);
- register int len;
-
- len = left->str_cur;
- if (len > right->str_cur)
- len = right->str_cur;
- if (str->str_cur > len)
- str->str_cur = len;
- else if (str->str_cur < len) {
- STR_GROW(str,len);
- (void)memzero(str->str_ptr + str->str_cur, len - str->str_cur);
- str->str_cur = len;
- }
- str->str_pok = 1;
- str->str_nok = 0;
- s = str->str_ptr;
- if (!s) {
- str_nset(str,"",0);
- s = str->str_ptr;
- }
- switch (optype) {
- case O_BIT_AND:
- while (len--)
- *s++ = *l++ & *r++;
- break;
- case O_XOR:
- while (len--)
- *s++ = *l++ ^ *r++;
- goto mop_up;
- case O_BIT_OR:
- while (len--)
- *s++ = *l++ | *r++;
- mop_up:
- len = str->str_cur;
- if (right->str_cur > len)
- str_ncat(str,right->str_ptr+len,right->str_cur - len);
- else if (left->str_cur > len)
- str_ncat(str,left->str_ptr+len,left->str_cur - len);
- break;
- }
-}
-
-int
-do_syscall(arglast)
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int items = arglast[2] - sp;
-#ifdef atarist
- unsigned long arg[14]; /* yes, we really need that many ! */
-#else
- unsigned long arg[8];
-#endif
- register int i = 0;
- int retval = -1;
-
-#ifdef HAS_SYSCALL
-#ifdef TAINT
- for (st += ++sp; items--; st++)
- tainted |= (*st)->str_tainted;
- st = stack->ary_array;
- sp = arglast[1];
- items = arglast[2] - sp;
-#endif
-#ifdef TAINT
- taintproper("Insecure dependency in syscall");
-#endif
- /* This probably won't work on machines where sizeof(long) != sizeof(int)
- * or where sizeof(long) != sizeof(char*). But such machines will
- * not likely have syscall implemented either, so who cares?
- */
- while (items--) {
- if (st[++sp]->str_nok || !i)
- arg[i++] = (unsigned long)str_gnum(st[sp]);
-#ifndef lint
- else
- arg[i++] = (unsigned long)st[sp]->str_ptr;
-#endif /* lint */
- }
- sp = arglast[1];
- items = arglast[2] - sp;
- switch (items) {
- case 0:
- fatal("Too few args to syscall");
- case 1:
- retval = syscall(arg[0]);
- break;
- case 2:
- retval = syscall(arg[0],arg[1]);
- break;
- case 3:
- retval = syscall(arg[0],arg[1],arg[2]);
- break;
- case 4:
- retval = syscall(arg[0],arg[1],arg[2],arg[3]);
- break;
- case 5:
- retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4]);
- break;
- case 6:
- retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5]);
- break;
- case 7:
- retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6]);
- break;
- case 8:
- retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],
- arg[7]);
- break;
-#ifdef atarist
- case 9:
- retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],
- arg[7], arg[8]);
- break;
- case 10:
- retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],
- arg[7], arg[8], arg[9]);
- break;
- case 11:
- retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],
- arg[7], arg[8], arg[9], arg[10]);
- break;
- case 12:
- retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],
- arg[7], arg[8], arg[9], arg[10], arg[11]);
- break;
- case 13:
- retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],
- arg[7], arg[8], arg[9], arg[10], arg[11], arg[12]);
- break;
- case 14:
- retval = syscall(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],
- arg[7], arg[8], arg[9], arg[10], arg[11], arg[12], arg[13]);
- break;
-#endif /* atarist */
- }
- return retval;
-#else
- fatal("syscall() unimplemented");
-#endif
-}
-
-
diff --git a/gnu/usr.bin/perl/perl/doio.c b/gnu/usr.bin/perl/perl/doio.c
deleted file mode 100644
index 0ace377..0000000
--- a/gnu/usr.bin/perl/perl/doio.c
+++ /dev/null
@@ -1,2978 +0,0 @@
-/* $RCSfile: doio.c,v $$Revision: 1.3 $$Date: 1995/05/30 05:03:00 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: doio.c,v $
- * Revision 1.3 1995/05/30 05:03:00 rgrimes
- * Remove trailing whitespace.
- *
- * Revision 1.2 1994/09/11 03:17:32 gclarkii
- * Changed AF_LOCAL to AF_LOCAL_XX so as not to conflict with 4.4 socket.h
- * Added casts to shutup warnings in doio.c
- *
- * Revision 1.1.1.1 1994/09/10 06:27:32 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.2 1994/03/09 22:24:27 ache
- * (cast) added for last argument of semctl
- *
- * Revision 1.1.1.1 1993/08/23 21:29:36 nate
- * PERL!
- *
- * Revision 4.0.1.6 92/06/11 21:08:16 lwall
- * patch34: some systems don't declare h_errno extern in header files
- *
- * Revision 4.0.1.5 92/06/08 13:00:21 lwall
- * patch20: some machines don't define ENOTSOCK in errno.h
- * patch20: new warnings for failed use of stat operators on filenames with \n
- * patch20: wait failed when STDOUT or STDERR reopened to a pipe
- * patch20: end of file latch not reset on reopen of STDIN
- * patch20: seek(HANDLE, 0, 1) went to eof because of ancient Ultrix workaround
- * patch20: fixed memory leak on system() for vfork() machines
- * patch20: get*by* routines now return something useful in a scalar context
- * patch20: h_errno now accessible via $?
- *
- * Revision 4.0.1.4 91/11/05 16:51:43 lwall
- * patch11: prepared for ctype implementations that don't define isascii()
- * patch11: perl mistook some streams for sockets because they return mode 0 too
- * patch11: reopening STDIN, STDOUT and STDERR failed on some machines
- * patch11: certain perl errors should set EBADF so that $! looks better
- * patch11: truncate on a closed filehandle could dump
- * patch11: stats of _ forgot whether prior stat was actually lstat
- * patch11: -T returned true on NFS directory
- *
- * Revision 4.0.1.3 91/06/10 01:21:19 lwall
- * patch10: read didn't work from character special files open for writing
- * patch10: close-on-exec wrongly set on system file descriptors
- *
- * Revision 4.0.1.2 91/06/07 10:53:39 lwall
- * patch4: new copyright notice
- * patch4: system fd's are now treated specially
- * patch4: added $^F variable to specify maximum system fd, default 2
- * patch4: character special files now opened with bidirectional stdio buffers
- * patch4: taintchecks could improperly modify parent in vfork()
- * patch4: many, many itty-bitty portability fixes
- *
- * Revision 4.0.1.1 91/04/11 17:41:06 lwall
- * patch1: hopefully straightened out some of the Xenix mess
- *
- * Revision 4.0 91/03/20 01:07:06 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-
-#ifdef HAS_SOCKET
-#include <sys/socket.h>
-#include <netdb.h>
-#ifndef ENOTSOCK
-#include <net/errno.h>
-#endif
-#endif
-
-#ifdef HAS_SELECT
-#ifdef I_SYS_SELECT
-#ifndef I_SYS_TIME
-#include <sys/select.h>
-#endif
-#endif
-#endif
-
-#ifdef HOST_NOT_FOUND
-extern int h_errno;
-#endif
-
-#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
-#include <sys/ipc.h>
-#ifdef HAS_MSG
-#include <sys/msg.h>
-#endif
-#ifdef HAS_SEM
-#include <sys/sem.h>
-#endif
-#ifdef HAS_SHM
-#include <sys/shm.h>
-#endif
-#endif
-
-#ifdef I_PWD
-#include <pwd.h>
-#endif
-#ifdef I_GRP
-#include <grp.h>
-#endif
-#ifdef I_UTIME
-#include <utime.h>
-#endif
-#ifdef I_FCNTL
-#include <fcntl.h>
-#endif
-#ifdef I_SYS_FILE
-#include <sys/file.h>
-#endif
-
-int laststatval = -1;
-int laststype = O_STAT;
-
-static char* warn_nl = "Unsuccessful %s on filename containing newline";
-
-bool
-do_open(stab,name,len)
-STAB *stab;
-register char *name;
-int len;
-{
- FILE *fp;
- register STIO *stio = stab_io(stab);
- char *myname = savestr(name);
- int result;
- int fd;
- int writing = 0;
- char mode[3]; /* stdio file mode ("r\0" or "r+\0") */
- FILE *saveifp = Nullfp;
- FILE *saveofp = Nullfp;
- char savetype = ' ';
-
- mode[0] = mode[1] = mode[2] = '\0';
- name = myname;
- forkprocess = 1; /* assume true if no fork */
- while (len && isSPACE(name[len-1]))
- name[--len] = '\0';
- if (!stio)
- stio = stab_io(stab) = stio_new();
- else if (stio->ifp) {
- fd = fileno(stio->ifp);
- if (stio->type == '-')
- result = 0;
- else if (fd <= maxsysfd) {
- saveifp = stio->ifp;
- saveofp = stio->ofp;
- savetype = stio->type;
- result = 0;
- }
- else if (stio->type == '|')
- result = mypclose(stio->ifp);
- else if (stio->ifp != stio->ofp) {
- if (stio->ofp) {
- result = fclose(stio->ofp);
- fclose(stio->ifp); /* clear stdio, fd already closed */
- }
- else
- result = fclose(stio->ifp);
- }
- else
- result = fclose(stio->ifp);
- if (result == EOF && fd > maxsysfd)
- fprintf(stderr,"Warning: unable to close filehandle %s properly.\n",
- stab_ename(stab));
- stio->ofp = stio->ifp = Nullfp;
- }
- if (*name == '+' && len > 1 && name[len-1] != '|') { /* scary */
- mode[1] = *name++;
- mode[2] = '\0';
- --len;
- writing = 1;
- }
- else {
- mode[1] = '\0';
- }
- stio->type = *name;
- if (*name == '|') {
- /*SUPPRESS 530*/
- for (name++; isSPACE(*name); name++) ;
-#ifdef TAINT
- taintenv();
- taintproper("Insecure dependency in piped open");
-#endif
- fp = mypopen(name,"w");
- writing = 1;
- }
- else if (*name == '>') {
-#ifdef TAINT
- taintproper("Insecure dependency in open");
-#endif
- name++;
- if (*name == '>') {
- mode[0] = stio->type = 'a';
- name++;
- }
- else
- mode[0] = 'w';
- writing = 1;
- if (*name == '&') {
- duplicity:
- name++;
- while (isSPACE(*name))
- name++;
- if (isDIGIT(*name))
- fd = atoi(name);
- else {
- stab = stabent(name,FALSE);
- if (!stab || !stab_io(stab)) {
-#ifdef EINVAL
- errno = EINVAL;
-#endif
- goto say_false;
- }
- if (stab_io(stab) && stab_io(stab)->ifp) {
- fd = fileno(stab_io(stab)->ifp);
- if (stab_io(stab)->type == 's')
- stio->type = 's';
- }
- else
- fd = -1;
- }
- if (!(fp = fdopen(fd = dup(fd),mode))) {
- close(fd);
- }
- }
- else {
- while (isSPACE(*name))
- name++;
- if (strEQ(name,"-")) {
- fp = stdout;
- stio->type = '-';
- }
- else {
- fp = fopen(name,mode);
- }
- }
- }
- else {
- if (*name == '<') {
- mode[0] = 'r';
- name++;
- while (isSPACE(*name))
- name++;
- if (*name == '&')
- goto duplicity;
- if (strEQ(name,"-")) {
- fp = stdin;
- stio->type = '-';
- }
- else
- fp = fopen(name,mode);
- }
- else if (name[len-1] == '|') {
-#ifdef TAINT
- taintenv();
- taintproper("Insecure dependency in piped open");
-#endif
- name[--len] = '\0';
- while (len && isSPACE(name[len-1]))
- name[--len] = '\0';
- /*SUPPRESS 530*/
- for (; isSPACE(*name); name++) ;
- fp = mypopen(name,"r");
- stio->type = '|';
- }
- else {
- stio->type = '<';
- /*SUPPRESS 530*/
- for (; isSPACE(*name); name++) ;
- if (strEQ(name,"-")) {
- fp = stdin;
- stio->type = '-';
- }
- else
- fp = fopen(name,"r");
- }
- }
- if (!fp) {
- if (dowarn && stio->type == '<' && index(name, '\n'))
- warn(warn_nl, "open");
- Safefree(myname);
- goto say_false;
- }
- Safefree(myname);
- if (stio->type &&
- stio->type != '|' && stio->type != '-') {
- if (fstat(fileno(fp),&statbuf) < 0) {
- (void)fclose(fp);
- goto say_false;
- }
- if (S_ISSOCK(statbuf.st_mode))
- stio->type = 's'; /* in case a socket was passed in to us */
-#ifdef HAS_SOCKET
- else if (
-#ifdef S_IFMT
- !(statbuf.st_mode & S_IFMT)
-#else
- !statbuf.st_mode
-#endif
- ) {
- int buflen = sizeof tokenbuf;
- if (getsockname(fileno(fp), (struct sockaddr * )tokenbuf, &buflen) >= 0
- || errno != ENOTSOCK)
- stio->type = 's'; /* some OS's return 0 on fstat()ed socket */
- /* but some return 0 for streams too, sigh */
- }
-#endif
- }
- if (saveifp) { /* must use old fp? */
- fd = fileno(saveifp);
- if (saveofp) {
- fflush(saveofp); /* emulate fclose() */
- if (saveofp != saveifp) { /* was a socket? */
- fclose(saveofp);
- if (fd > 2)
- Safefree(saveofp);
- }
- }
- if (fd != fileno(fp)) {
- int pid;
- STR *str;
-
- dup2(fileno(fp), fd);
- str = afetch(fdpid,fileno(fp),TRUE);
- pid = str->str_u.str_useful;
- str->str_u.str_useful = 0;
- str = afetch(fdpid,fd,TRUE);
- str->str_u.str_useful = pid;
- fclose(fp);
-
- }
- fp = saveifp;
- clearerr(fp);
- }
-#if defined(HAS_FCNTL) && defined(F_SETFD)
- fd = fileno(fp);
- fcntl(fd,F_SETFD,fd > maxsysfd);
-#endif
- stio->ifp = fp;
- if (writing) {
- if (stio->type == 's'
- || (stio->type == '>' && S_ISCHR(statbuf.st_mode)) ) {
- if (!(stio->ofp = fdopen(fileno(fp),"w"))) {
- fclose(fp);
- stio->ifp = Nullfp;
- goto say_false;
- }
- }
- else
- stio->ofp = fp;
- }
- return TRUE;
-
-say_false:
- stio->ifp = saveifp;
- stio->ofp = saveofp;
- stio->type = savetype;
- return FALSE;
-}
-
-FILE *
-nextargv(stab)
-register STAB *stab;
-{
- register STR *str;
-#ifndef FLEXFILENAMES
- int filedev;
- int fileino;
-#endif
- int fileuid;
- int filegid;
- static int filemode = 0;
- static int lastfd;
- static char *oldname;
-
- if (!argvoutstab)
- argvoutstab = stabent("ARGVOUT",TRUE);
- if (filemode & (S_ISUID|S_ISGID)) {
- fflush(stab_io(argvoutstab)->ifp); /* chmod must follow last write */
-#ifdef HAS_FCHMOD
- (void)fchmod(lastfd,filemode);
-#else
- (void)chmod(oldname,filemode);
-#endif
- }
- filemode = 0;
- while (alen(stab_xarray(stab)) >= 0) {
- str = ashift(stab_xarray(stab));
- str_sset(stab_val(stab),str);
- STABSET(stab_val(stab));
- oldname = str_get(stab_val(stab));
- if (do_open(stab,oldname,stab_val(stab)->str_cur)) {
- if (inplace) {
-#ifdef TAINT
- taintproper("Insecure dependency in inplace open");
-#endif
- if (strEQ(oldname,"-")) {
- str_free(str);
- defoutstab = stabent("STDOUT",TRUE);
- return stab_io(stab)->ifp;
- }
-#ifndef FLEXFILENAMES
- filedev = statbuf.st_dev;
- fileino = statbuf.st_ino;
-#endif
- filemode = statbuf.st_mode;
- fileuid = statbuf.st_uid;
- filegid = statbuf.st_gid;
- if (!S_ISREG(filemode)) {
- warn("Can't do inplace edit: %s is not a regular file",
- oldname );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
- if (*inplace) {
-#ifdef SUFFIX
- add_suffix(str,inplace);
-#else
- str_cat(str,inplace);
-#endif
-#ifndef FLEXFILENAMES
- if (stat(str->str_ptr,&statbuf) >= 0
- && statbuf.st_dev == filedev
- && statbuf.st_ino == fileino ) {
- warn("Can't do inplace edit: %s > 14 characters",
- str->str_ptr );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
-#endif
-#ifdef HAS_RENAME
-#ifndef DOSISH
- if (rename(oldname,str->str_ptr) < 0) {
- warn("Can't rename %s to %s: %s, skipping file",
- oldname, str->str_ptr, strerror(errno) );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
-#else
- do_close(stab,FALSE);
- (void)unlink(str->str_ptr);
- (void)rename(oldname,str->str_ptr);
- do_open(stab,str->str_ptr,stab_val(stab)->str_cur);
-#endif /* MSDOS */
-#else
- (void)UNLINK(str->str_ptr);
- if (link(oldname,str->str_ptr) < 0) {
- warn("Can't rename %s to %s: %s, skipping file",
- oldname, str->str_ptr, strerror(errno) );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
- (void)UNLINK(oldname);
-#endif
- }
- else {
-#ifndef DOSISH
- if (UNLINK(oldname) < 0) {
- warn("Can't rename %s to %s: %s, skipping file",
- oldname, str->str_ptr, strerror(errno) );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
-#else
- fatal("Can't do inplace edit without backup");
-#endif
- }
-
- str_nset(str,">",1);
- str_cat(str,oldname);
- errno = 0; /* in case sprintf set errno */
- if (!do_open(argvoutstab,str->str_ptr,str->str_cur)) {
- warn("Can't do inplace edit on %s: %s",
- oldname, strerror(errno) );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
- defoutstab = argvoutstab;
- lastfd = fileno(stab_io(argvoutstab)->ifp);
- (void)fstat(lastfd,&statbuf);
-#ifdef HAS_FCHMOD
- (void)fchmod(lastfd,filemode);
-#else
- (void)chmod(oldname,filemode);
-#endif
- if (fileuid != statbuf.st_uid || filegid != statbuf.st_gid) {
-#ifdef HAS_FCHOWN
- (void)fchown(lastfd,fileuid,filegid);
-#else
-#ifdef HAS_CHOWN
- (void)chown(oldname,fileuid,filegid);
-#endif
-#endif
- }
- }
- str_free(str);
- return stab_io(stab)->ifp;
- }
- else
- fprintf(stderr,"Can't open %s: %s\n",str_get(str), strerror(errno));
- str_free(str);
- }
- if (inplace) {
- (void)do_close(argvoutstab,FALSE);
- defoutstab = stabent("STDOUT",TRUE);
- }
- return Nullfp;
-}
-
-#ifdef HAS_PIPE
-void
-do_pipe(str, rstab, wstab)
-STR *str;
-STAB *rstab;
-STAB *wstab;
-{
- register STIO *rstio;
- register STIO *wstio;
- int fd[2];
-
- if (!rstab)
- goto badexit;
- if (!wstab)
- goto badexit;
-
- rstio = stab_io(rstab);
- wstio = stab_io(wstab);
-
- if (!rstio)
- rstio = stab_io(rstab) = stio_new();
- else if (rstio->ifp)
- do_close(rstab,FALSE);
- if (!wstio)
- wstio = stab_io(wstab) = stio_new();
- else if (wstio->ifp)
- do_close(wstab,FALSE);
-
- if (pipe(fd) < 0)
- goto badexit;
- rstio->ifp = fdopen(fd[0], "r");
- wstio->ofp = fdopen(fd[1], "w");
- wstio->ifp = wstio->ofp;
- rstio->type = '<';
- wstio->type = '>';
- if (!rstio->ifp || !wstio->ofp) {
- if (rstio->ifp) fclose(rstio->ifp);
- else close(fd[0]);
- if (wstio->ofp) fclose(wstio->ofp);
- else close(fd[1]);
- goto badexit;
- }
-
- str_sset(str,&str_yes);
- return;
-
-badexit:
- str_sset(str,&str_undef);
- return;
-}
-#endif
-
-bool
-do_close(stab,explicit)
-STAB *stab;
-bool explicit;
-{
- bool retval = FALSE;
- register STIO *stio;
- int status;
-
- if (!stab)
- stab = argvstab;
- if (!stab) {
- errno = EBADF;
- return FALSE;
- }
- stio = stab_io(stab);
- if (!stio) { /* never opened */
- if (dowarn && explicit)
- warn("Close on unopened file <%s>",stab_ename(stab));
- return FALSE;
- }
- if (stio->ifp) {
- if (stio->type == '|') {
- status = mypclose(stio->ifp);
- retval = (status == 0);
- statusvalue = (unsigned short)status & 0xffff;
- }
- else if (stio->type == '-')
- retval = TRUE;
- else {
- if (stio->ofp && stio->ofp != stio->ifp) { /* a socket */
- retval = (fclose(stio->ofp) != EOF);
- fclose(stio->ifp); /* clear stdio, fd already closed */
- }
- else
- retval = (fclose(stio->ifp) != EOF);
- }
- stio->ofp = stio->ifp = Nullfp;
- }
- if (explicit)
- stio->lines = 0;
- stio->type = ' ';
- return retval;
-}
-
-bool
-do_eof(stab)
-STAB *stab;
-{
- register STIO *stio;
- int ch;
-
- if (!stab) { /* eof() */
- if (argvstab)
- stio = stab_io(argvstab);
- else
- return TRUE;
- }
- else
- stio = stab_io(stab);
-
- if (!stio)
- return TRUE;
-
- while (stio->ifp) {
-
-#ifdef STDSTDIO /* (the code works without this) */
- if (stio->ifp->_cnt > 0) /* cheat a little, since */
- return FALSE; /* this is the most usual case */
-#endif
-
- ch = getc(stio->ifp);
- if (ch != EOF) {
- (void)ungetc(ch, stio->ifp);
- return FALSE;
- }
-#ifdef STDSTDIO
- if (stio->ifp->_cnt < -1)
- stio->ifp->_cnt = -1;
-#endif
- if (!stab) { /* not necessarily a real EOF yet? */
- if (!nextargv(argvstab)) /* get another fp handy */
- return TRUE;
- }
- else
- return TRUE; /* normal fp, definitely end of file */
- }
- return TRUE;
-}
-
-long
-do_tell(stab)
-STAB *stab;
-{
- register STIO *stio;
-
- if (!stab)
- goto phooey;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto phooey;
-
-#ifdef ULTRIX_STDIO_BOTCH
- if (feof(stio->ifp))
- (void)fseek (stio->ifp, 0L, 2); /* ultrix 1.2 workaround */
-#endif
-
- return ftell(stio->ifp);
-
-phooey:
- if (dowarn)
- warn("tell() on unopened file");
- errno = EBADF;
- return -1L;
-}
-
-bool
-do_seek(stab, pos, whence)
-STAB *stab;
-long pos;
-int whence;
-{
- register STIO *stio;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
-#ifdef ULTRIX_STDIO_BOTCH
- if (feof(stio->ifp))
- (void)fseek (stio->ifp, 0L, 2); /* ultrix 1.2 workaround */
-#endif
-
- return fseek(stio->ifp, pos, whence) >= 0;
-
-nuts:
- if (dowarn)
- warn("seek() on unopened file");
- errno = EBADF;
- return FALSE;
-}
-
-int
-do_ctl(optype,stab,func,argstr)
-int optype;
-STAB *stab;
-int func;
-STR *argstr;
-{
- register STIO *stio;
- register char *s;
- int retval;
-
- if (!stab || !argstr || !(stio = stab_io(stab)) || !stio->ifp) {
- errno = EBADF; /* well, sort of... */
- return -1;
- }
-
- if (argstr->str_pok || !argstr->str_nok) {
- if (!argstr->str_pok)
- s = str_get(argstr);
-
-#ifdef IOCPARM_MASK
-#ifndef IOCPARM_LEN
-#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
-#endif
-#endif
-#ifdef IOCPARM_LEN
- retval = IOCPARM_LEN(func); /* on BSDish systes we're safe */
-#else
- retval = 256; /* otherwise guess at what's safe */
-#endif
- if (argstr->str_cur < retval) {
- Str_Grow(argstr,retval+1);
- argstr->str_cur = retval;
- }
-
- s = argstr->str_ptr;
- s[argstr->str_cur] = 17; /* a little sanity check here */
- }
- else {
- retval = (int)str_gnum(argstr);
-#ifdef DOSISH
- s = (char*)(long)retval; /* ouch */
-#else
- s = (char*)retval; /* ouch */
-#endif
- }
-
-#ifndef lint
- if (optype == O_IOCTL)
- retval = ioctl(fileno(stio->ifp), func, s);
- else
-#ifdef DOSISH
- fatal("fcntl is not implemented");
-#else
-#ifdef HAS_FCNTL
- retval = fcntl(fileno(stio->ifp), func, s);
-#else
- fatal("fcntl is not implemented");
-#endif
-#endif
-#else /* lint */
- retval = 0;
-#endif /* lint */
-
- if (argstr->str_pok) {
- if (s[argstr->str_cur] != 17)
- fatal("Return value overflowed string");
- s[argstr->str_cur] = 0; /* put our null back */
- }
- return retval;
-}
-
-int
-do_stat(str,arg,gimme,arglast)
-STR *str;
-register ARG *arg;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0] + 1;
- int max = 13;
-
- if ((arg[1].arg_type & A_MASK) == A_WORD) {
- tmpstab = arg[1].arg_ptr.arg_stab;
- if (tmpstab != defstab) {
- laststype = O_STAT;
- statstab = tmpstab;
- str_set(statname,"");
- if (!stab_io(tmpstab) || !stab_io(tmpstab)->ifp ||
- fstat(fileno(stab_io(tmpstab)->ifp),&statcache) < 0) {
- max = 0;
- laststatval = -1;
- }
- }
- else if (laststatval < 0)
- max = 0;
- }
- else {
- str_set(statname,str_get(ary->ary_array[sp]));
- statstab = Nullstab;
-#ifdef HAS_LSTAT
- laststype = arg->arg_type;
- if (arg->arg_type == O_LSTAT)
- laststatval = lstat(str_get(statname),&statcache);
- else
-#endif
- laststatval = stat(str_get(statname),&statcache);
- if (laststatval < 0) {
- if (dowarn && index(str_get(statname), '\n'))
- warn(warn_nl, "stat");
- max = 0;
- }
- }
-
- if (gimme != G_ARRAY) {
- if (max)
- str_sset(str,&str_yes);
- else
- str_sset(str,&str_undef);
- STABSET(str);
- ary->ary_array[sp] = str;
- return sp;
- }
- sp--;
- if (max) {
-#ifndef lint
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_dev)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_ino)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_mode)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_nlink)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_uid)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_gid)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_rdev)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_size)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_atime)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_mtime)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_ctime)));
-#ifdef STATBLOCKS
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_blksize)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_blocks)));
-#else
- (void)astore(ary,++sp,
- str_2mortal(str_make("",0)));
- (void)astore(ary,++sp,
- str_2mortal(str_make("",0)));
-#endif
-#else /* lint */
- (void)astore(ary,++sp,str_nmake(0.0));
-#endif /* lint */
- }
- return sp;
-}
-
-#if !defined(HAS_TRUNCATE) && !defined(HAS_CHSIZE) && defined(F_FREESP)
- /* code courtesy of William Kucharski */
-#define HAS_CHSIZE
-
-int chsize(fd, length)
-int fd; /* file descriptor */
-off_t length; /* length to set file to */
-{
- extern long lseek();
- struct flock fl;
- struct stat filebuf;
-
- if (fstat(fd, &filebuf) < 0)
- return -1;
-
- if (filebuf.st_size < length) {
-
- /* extend file length */
-
- if ((lseek(fd, (length - 1), 0)) < 0)
- return -1;
-
- /* write a "0" byte */
-
- if ((write(fd, "", 1)) != 1)
- return -1;
- }
- else {
- /* truncate length */
-
- fl.l_whence = 0;
- fl.l_len = 0;
- fl.l_start = length;
- fl.l_type = F_WRLCK; /* write lock on file space */
-
- /*
- * This relies on the UNDOCUMENTED F_FREESP argument to
- * fcntl(2), which truncates the file so that it ends at the
- * position indicated by fl.l_start.
- *
- * Will minor miracles never cease?
- */
-
- if (fcntl(fd, F_FREESP, &fl) < 0)
- return -1;
-
- }
-
- return 0;
-}
-#endif /* F_FREESP */
-
-int /*SUPPRESS 590*/
-do_truncate(str,arg,gimme,arglast)
-STR *str;
-register ARG *arg;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0] + 1;
- off_t len = (off_t)str_gnum(ary->ary_array[sp+1]);
- int result = 1;
- STAB *tmpstab;
-
-#if defined(HAS_TRUNCATE) || defined(HAS_CHSIZE)
-#ifdef HAS_TRUNCATE
- if ((arg[1].arg_type & A_MASK) == A_WORD) {
- tmpstab = arg[1].arg_ptr.arg_stab;
- if (!stab_io(tmpstab) || !stab_io(tmpstab)->ifp ||
- ftruncate(fileno(stab_io(tmpstab)->ifp), len) < 0)
- result = 0;
- }
- else if (truncate(str_get(ary->ary_array[sp]), len) < 0)
- result = 0;
-#else
- if ((arg[1].arg_type & A_MASK) == A_WORD) {
- tmpstab = arg[1].arg_ptr.arg_stab;
- if (!stab_io(tmpstab) || !stab_io(tmpstab)->ifp ||
- chsize(fileno(stab_io(tmpstab)->ifp), len) < 0)
- result = 0;
- }
- else {
- int tmpfd;
-
- if ((tmpfd = open(str_get(ary->ary_array[sp]), 0)) < 0)
- result = 0;
- else {
- if (chsize(tmpfd, len) < 0)
- result = 0;
- close(tmpfd);
- }
- }
-#endif
-
- if (result)
- str_sset(str,&str_yes);
- else
- str_sset(str,&str_undef);
- STABSET(str);
- ary->ary_array[sp] = str;
- return sp;
-#else
- fatal("truncate not implemented");
-#endif
-}
-
-int
-looks_like_number(str)
-STR *str;
-{
- register char *s;
- register char *send;
-
- if (!str->str_pok)
- return TRUE;
- s = str->str_ptr;
- send = s + str->str_cur;
- while (isSPACE(*s))
- s++;
- if (s >= send)
- return FALSE;
- if (*s == '+' || *s == '-')
- s++;
- while (isDIGIT(*s))
- s++;
- if (s == send)
- return TRUE;
- if (*s == '.')
- s++;
- else if (s == str->str_ptr)
- return FALSE;
- while (isDIGIT(*s))
- s++;
- if (s == send)
- return TRUE;
- if (*s == 'e' || *s == 'E') {
- s++;
- if (*s == '+' || *s == '-')
- s++;
- while (isDIGIT(*s))
- s++;
- }
- while (isSPACE(*s))
- s++;
- if (s >= send)
- return TRUE;
- return FALSE;
-}
-
-bool
-do_print(str,fp)
-register STR *str;
-FILE *fp;
-{
- register char *tmps;
-
- if (!fp) {
- if (dowarn)
- warn("print to unopened file");
- errno = EBADF;
- return FALSE;
- }
- if (!str)
- return TRUE;
- if (ofmt &&
- ((str->str_nok && str->str_u.str_nval != 0.0)
- || (looks_like_number(str) && str_gnum(str) != 0.0) ) ) {
- fprintf(fp, ofmt, str->str_u.str_nval);
- return !ferror(fp);
- }
- else {
- tmps = str_get(str);
- if (*tmps == 'S' && tmps[1] == 't' && tmps[2] == 'B' && tmps[3] == '\0'
- && str->str_cur == sizeof(STBP) && strlen(tmps) < str->str_cur) {
- STR *tmpstr = str_mortal(&str_undef);
- stab_efullname(tmpstr,((STAB*)str));/* a stab value, be nice */
- str = tmpstr;
- tmps = str->str_ptr;
- putc('*',fp);
- }
- if (str->str_cur && (fwrite(tmps,1,str->str_cur,fp) == 0 || ferror(fp)))
- return FALSE;
- }
- return TRUE;
-}
-
-bool
-do_aprint(arg,fp,arglast)
-register ARG *arg;
-register FILE *fp;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int retval;
- register int items = arglast[2] - sp;
-
- if (!fp) {
- if (dowarn)
- warn("print to unopened file");
- errno = EBADF;
- return FALSE;
- }
- st += ++sp;
- if (arg->arg_type == O_PRTF) {
- do_sprintf(arg->arg_ptr.arg_str,items,st);
- retval = do_print(arg->arg_ptr.arg_str,fp);
- }
- else {
- retval = (items <= 0);
- for (; items > 0; items--,st++) {
- if (retval && ofslen) {
- if (fwrite(ofs, 1, ofslen, fp) == 0 || ferror(fp)) {
- retval = FALSE;
- break;
- }
- }
- if (!(retval = do_print(*st, fp)))
- break;
- }
- if (retval && orslen)
- if (fwrite(ors, 1, orslen, fp) == 0 || ferror(fp))
- retval = FALSE;
- }
- return retval;
-}
-
-int
-mystat(arg,str)
-ARG *arg;
-STR *str;
-{
- STIO *stio;
-
- if (arg[1].arg_type & A_DONT) {
- stio = stab_io(arg[1].arg_ptr.arg_stab);
- if (stio && stio->ifp) {
- statstab = arg[1].arg_ptr.arg_stab;
- str_set(statname,"");
- laststype = O_STAT;
- return (laststatval = fstat(fileno(stio->ifp), &statcache));
- }
- else {
- if (arg[1].arg_ptr.arg_stab == defstab)
- return laststatval;
- if (dowarn)
- warn("Stat on unopened file <%s>",
- stab_ename(arg[1].arg_ptr.arg_stab));
- statstab = Nullstab;
- str_set(statname,"");
- return (laststatval = -1);
- }
- }
- else {
- statstab = Nullstab;
- str_set(statname,str_get(str));
- laststype = O_STAT;
- laststatval = stat(str_get(str),&statcache);
- if (laststatval < 0 && dowarn && index(str_get(str), '\n'))
- warn(warn_nl, "stat");
- return laststatval;
- }
-}
-
-int
-mylstat(arg,str)
-ARG *arg;
-STR *str;
-{
- if (arg[1].arg_type & A_DONT) {
- if (arg[1].arg_ptr.arg_stab == defstab) {
- if (laststype != O_LSTAT)
- fatal("The stat preceding -l _ wasn't an lstat");
- return laststatval;
- }
- fatal("You can't use -l on a filehandle");
- }
-
- laststype = O_LSTAT;
- statstab = Nullstab;
- str_set(statname,str_get(str));
-#ifdef HAS_LSTAT
- laststatval = lstat(str_get(str),&statcache);
-#else
- laststatval = stat(str_get(str),&statcache);
-#endif
- if (laststatval < 0 && dowarn && index(str_get(str), '\n'))
- warn(warn_nl, "lstat");
- return laststatval;
-}
-
-STR *
-do_fttext(arg,str)
-register ARG *arg;
-STR *str;
-{
- int i;
- int len;
- int odd = 0;
- STDCHAR tbuf[512];
- register STDCHAR *s;
- register STIO *stio;
-
- if (arg[1].arg_type & A_DONT) {
- if (arg[1].arg_ptr.arg_stab == defstab) {
- if (statstab)
- stio = stab_io(statstab);
- else {
- str = statname;
- goto really_filename;
- }
- }
- else {
- statstab = arg[1].arg_ptr.arg_stab;
- str_set(statname,"");
- stio = stab_io(statstab);
- }
- if (stio && stio->ifp) {
-#if defined(STDSTDIO) || defined(atarist) /* this will work with atariST */
- fstat(fileno(stio->ifp),&statcache);
- if (S_ISDIR(statcache.st_mode)) /* handle NFS glitch */
- return arg->arg_type == O_FTTEXT ? &str_no : &str_yes;
- if (stio->ifp->_cnt <= 0) {
- i = getc(stio->ifp);
- if (i != EOF)
- (void)ungetc(i,stio->ifp);
- }
- if (stio->ifp->_cnt <= 0) /* null file is anything */
- return &str_yes;
- len = stio->ifp->_cnt + (stio->ifp->_ptr - stio->ifp->_base);
- s = stio->ifp->_base;
-#else
-#if (defined(BSD) && (BSD >= 199103))
- fstat(fileno(stio->ifp),&statcache);
- if (S_ISDIR(statcache.st_mode)) /* handle NFS glitch */
- return arg->arg_type == O_FTTEXT ? &str_no : &str_yes;
-
- if (stio->ifp->_bf._size <= 0) {
- i = getc(stio->ifp);
- if (i != EOF)
- (void)ungetc(i,stio->ifp);
- }
-
- if (stio->ifp->_bf._size <= 0)
- return &str_yes;
- len = stio->ifp->_bf._size+(stio->ifp->_p - stio->ifp->_bf._base);
- s = stio->ifp->_bf._base;
-#else
- fatal("-T and -B not implemented on filehandles");
-#endif
-#endif
- }
- else {
- if (dowarn)
- warn("Test on unopened file <%s>",
- stab_ename(arg[1].arg_ptr.arg_stab));
- errno = EBADF;
- return &str_undef;
- }
- }
- else {
- statstab = Nullstab;
- str_set(statname,str_get(str));
- really_filename:
- i = open(str_get(str),0);
- if (i < 0) {
- if (dowarn && index(str_get(str), '\n'))
- warn(warn_nl, "open");
- return &str_undef;
- }
- fstat(i,&statcache);
- len = read(i,tbuf,512);
- (void)close(i);
- if (len <= 0) {
- if (S_ISDIR(statcache.st_mode) && arg->arg_type == O_FTTEXT)
- return &str_no; /* special case NFS directories */
- return &str_yes; /* null file is anything */
- }
- s = tbuf;
- }
-
- /* now scan s to look for textiness */
-
- for (i = 0; i < len; i++,s++) {
- if (!*s) { /* null never allowed in text */
- odd += len;
- break;
- }
- else if (*s & 128)
- odd++;
- else if (*s < 32 &&
- *s != '\n' && *s != '\r' && *s != '\b' &&
- *s != '\t' && *s != '\f' && *s != 27)
- odd++;
- }
-
- if ((odd * 10 > len) == (arg->arg_type == O_FTTEXT)) /* allow 10% odd */
- return &str_no;
- else
- return &str_yes;
-}
-
-static char **Argv = Null(char **);
-static char *Cmd = Nullch;
-
-bool
-do_aexec(really,arglast)
-STR *really;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int items = arglast[2] - sp;
- register char **a;
- char *tmps;
-
- if (items) {
- New(401,Argv, items+1, char*);
- a = Argv;
- for (st += ++sp; items > 0; items--,st++) {
- if (*st)
- *a++ = str_get(*st);
- else
- *a++ = "";
- }
- *a = Nullch;
-#ifdef TAINT
- if (*Argv[0] != '/') /* will execvp use PATH? */
- taintenv(); /* testing IFS here is overkill, probably */
-#endif
- if (really && *(tmps = str_get(really)))
- execvp(tmps,Argv);
- else
- execvp(Argv[0],Argv);
- }
- do_execfree();
- return FALSE;
-}
-
-void
-do_execfree()
-{
- if (Argv) {
- Safefree(Argv);
- Argv = Null(char **);
- }
- if (Cmd) {
- Safefree(Cmd);
- Cmd = Nullch;
- }
-}
-
-bool
-do_exec(cmd)
-char *cmd;
-{
- register char **a;
- register char *s;
- char flags[10];
-
- /* save an extra exec if possible */
-
-#ifdef CSH
- if (strnEQ(cmd,cshname,cshlen) && strnEQ(cmd+cshlen," -c",3)) {
- strcpy(flags,"-c");
- s = cmd+cshlen+3;
- if (*s == 'f') {
- s++;
- strcat(flags,"f");
- }
- if (*s == ' ')
- s++;
- if (*s++ == '\'') {
- char *ncmd = s;
-
- while (*s)
- s++;
- if (s[-1] == '\n')
- *--s = '\0';
- if (s[-1] == '\'') {
- *--s = '\0';
- execl(cshname,"csh", flags,ncmd,(char*)0);
- *s = '\'';
- return FALSE;
- }
- }
- }
-#endif /* CSH */
-
- /* see if there are shell metacharacters in it */
-
- /*SUPPRESS 530*/
- for (s = cmd; *s && isALPHA(*s); s++) ; /* catch VAR=val gizmo */
- if (*s == '=')
- goto doshell;
- for (s = cmd; *s; s++) {
- if (*s != ' ' && !isALPHA(*s) && index("$&*(){}[]'\";\\|?<>~`\n",*s)) {
- if (*s == '\n' && !s[1]) {
- *s = '\0';
- break;
- }
- doshell:
- execl("/bin/sh","sh","-c",cmd,(char*)0);
- return FALSE;
- }
- }
- New(402,Argv, (s - cmd) / 2 + 2, char*);
- Cmd = nsavestr(cmd, s-cmd);
- a = Argv;
- for (s = Cmd; *s;) {
- while (*s && isSPACE(*s)) s++;
- if (*s)
- *(a++) = s;
- while (*s && !isSPACE(*s)) s++;
- if (*s)
- *s++ = '\0';
- }
- *a = Nullch;
- if (Argv[0]) {
- execvp(Argv[0],Argv);
- if (errno == ENOEXEC) { /* for system V NIH syndrome */
- do_execfree();
- goto doshell;
- }
- }
- do_execfree();
- return FALSE;
-}
-
-#ifdef HAS_SOCKET
-int
-do_socket(stab, arglast)
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- int domain, type, protocol, fd;
-
- if (!stab) {
- errno = EBADF;
- return FALSE;
- }
-
- stio = stab_io(stab);
- if (!stio)
- stio = stab_io(stab) = stio_new();
- else if (stio->ifp)
- do_close(stab,FALSE);
-
- domain = (int)str_gnum(st[++sp]);
- type = (int)str_gnum(st[++sp]);
- protocol = (int)str_gnum(st[++sp]);
-#ifdef TAINT
- taintproper("Insecure dependency in socket");
-#endif
- fd = socket(domain,type,protocol);
- if (fd < 0)
- return FALSE;
- stio->ifp = fdopen(fd, "r"); /* stdio gets confused about sockets */
- stio->ofp = fdopen(fd, "w");
- stio->type = 's';
- if (!stio->ifp || !stio->ofp) {
- if (stio->ifp) fclose(stio->ifp);
- if (stio->ofp) fclose(stio->ofp);
- if (!stio->ifp && !stio->ofp) close(fd);
- return FALSE;
- }
-
- return TRUE;
-}
-
-int
-do_bind(stab, arglast)
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- char *addr;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- addr = str_get(st[++sp]);
-#ifdef TAINT
- taintproper("Insecure dependency in bind");
-#endif
- return bind(fileno(stio->ifp), (struct sockaddr * ) addr, st[sp]->str_cur) >= 0;
-
-nuts:
- if (dowarn)
- warn("bind() on closed fd");
- errno = EBADF;
- return FALSE;
-
-}
-
-int
-do_connect(stab, arglast)
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- char *addr;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- addr = str_get(st[++sp]);
-#ifdef TAINT
- taintproper("Insecure dependency in connect");
-#endif
- return connect(fileno(stio->ifp), (struct sockaddr *) addr, st[sp]->str_cur) >= 0;
-
-nuts:
- if (dowarn)
- warn("connect() on closed fd");
- errno = EBADF;
- return FALSE;
-
-}
-
-int
-do_listen(stab, arglast)
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- int backlog;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- backlog = (int)str_gnum(st[++sp]);
- return listen(fileno(stio->ifp), backlog) >= 0;
-
-nuts:
- if (dowarn)
- warn("listen() on closed fd");
- errno = EBADF;
- return FALSE;
-}
-
-void
-do_accept(str, nstab, gstab)
-STR *str;
-STAB *nstab;
-STAB *gstab;
-{
- register STIO *nstio;
- register STIO *gstio;
- int len = sizeof buf;
- int fd;
-
- if (!nstab)
- goto badexit;
- if (!gstab)
- goto nuts;
-
- gstio = stab_io(gstab);
- nstio = stab_io(nstab);
-
- if (!gstio || !gstio->ifp)
- goto nuts;
- if (!nstio)
- nstio = stab_io(nstab) = stio_new();
- else if (nstio->ifp)
- do_close(nstab,FALSE);
-
- fd = accept(fileno(gstio->ifp),(struct sockaddr *)buf,&len);
- if (fd < 0)
- goto badexit;
- nstio->ifp = fdopen(fd, "r");
- nstio->ofp = fdopen(fd, "w");
- nstio->type = 's';
- if (!nstio->ifp || !nstio->ofp) {
- if (nstio->ifp) fclose(nstio->ifp);
- if (nstio->ofp) fclose(nstio->ofp);
- if (!nstio->ifp && !nstio->ofp) close(fd);
- goto badexit;
- }
-
- str_nset(str, buf, len);
- return;
-
-nuts:
- if (dowarn)
- warn("accept() on closed fd");
- errno = EBADF;
-badexit:
- str_sset(str,&str_undef);
- return;
-}
-
-int
-do_shutdown(stab, arglast)
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- int how;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- how = (int)str_gnum(st[++sp]);
- return shutdown(fileno(stio->ifp), how) >= 0;
-
-nuts:
- if (dowarn)
- warn("shutdown() on closed fd");
- errno = EBADF;
- return FALSE;
-
-}
-
-int
-do_sopt(optype, stab, arglast)
-int optype;
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- int fd;
- unsigned int lvl;
- unsigned int optname;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- fd = fileno(stio->ifp);
- lvl = (unsigned int)str_gnum(st[sp+1]);
- optname = (unsigned int)str_gnum(st[sp+2]);
- switch (optype) {
- case O_GSOCKOPT:
- st[sp] = str_2mortal(Str_new(22,257));
- st[sp]->str_cur = 256;
- st[sp]->str_pok = 1;
- if (getsockopt(fd, lvl, optname, st[sp]->str_ptr,
- (int*)&st[sp]->str_cur) < 0)
- goto nuts;
- break;
- case O_SSOCKOPT:
- st[sp] = st[sp+3];
- if (setsockopt(fd, lvl, optname, st[sp]->str_ptr, st[sp]->str_cur) < 0)
- goto nuts;
- st[sp] = &str_yes;
- break;
- }
-
- return sp;
-
-nuts:
- if (dowarn)
- warn("[gs]etsockopt() on closed fd");
- st[sp] = &str_undef;
- errno = EBADF;
- return sp;
-
-}
-
-int
-do_getsockname(optype, stab, arglast)
-int optype;
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- int fd;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- st[sp] = str_2mortal(Str_new(22,257));
- st[sp]->str_cur = 256;
- st[sp]->str_pok = 1;
- fd = fileno(stio->ifp);
- switch (optype) {
- case O_GETSOCKNAME:
- if (getsockname(fd, (struct sockaddr *) st[sp]->str_ptr, (int*)&st[sp]->str_cur) < 0)
- goto nuts2;
- break;
- case O_GETPEERNAME:
- if (getpeername(fd, (struct sockaddr *) st[sp]->str_ptr, (int*)&st[sp]->str_cur) < 0)
- goto nuts2;
- break;
- }
-
- return sp;
-
-nuts:
- if (dowarn)
- warn("get{sock,peer}name() on closed fd");
- errno = EBADF;
-nuts2:
- st[sp] = &str_undef;
- return sp;
-
-}
-
-int
-do_ghent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register char **elem;
- register STR *str;
- struct hostent *gethostbyname();
- struct hostent *gethostbyaddr();
-#ifdef HAS_GETHOSTENT
- struct hostent *gethostent();
-#endif
- struct hostent *hent;
- unsigned long len;
-
- if (which == O_GHBYNAME) {
- char *name = str_get(ary->ary_array[sp+1]);
-
- hent = gethostbyname(name);
- }
- else if (which == O_GHBYADDR) {
- STR *addrstr = ary->ary_array[sp+1];
- int addrtype = (int)str_gnum(ary->ary_array[sp+2]);
- char *addr = str_get(addrstr);
-
- hent = gethostbyaddr(addr,addrstr->str_cur,addrtype);
- }
- else
-#ifdef HAS_GETHOSTENT
- hent = gethostent();
-#else
- fatal("gethostent not implemented");
-#endif
-
-#ifdef HOST_NOT_FOUND
- if (!hent)
- statusvalue = (unsigned short)h_errno & 0xffff;
-#endif
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (hent) {
- if (which == O_GHBYNAME) {
-#ifdef h_addr
- str_nset(str, *hent->h_addr, hent->h_length);
-#else
- str_nset(str, hent->h_addr, hent->h_length);
-#endif
- }
- else
- str_set(str, hent->h_name);
- }
- return sp;
- }
-
- if (hent) {
-#ifndef lint
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, hent->h_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- for (elem = hent->h_aliases; *elem; elem++) {
- str_cat(str, *elem);
- if (elem[1])
- str_ncat(str," ",1);
- }
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)hent->h_addrtype);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- len = hent->h_length;
- str_numset(str, (double)len);
-#ifdef h_addr
- for (elem = hent->h_addr_list; *elem; elem++) {
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_nset(str, *elem, len);
- }
-#else
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_nset(str, hent->h_addr, len);
-#endif /* h_addr */
-#else /* lint */
- elem = Nullch;
- elem = elem;
- (void)astore(ary, ++sp, str_mortal(&str_no));
-#endif /* lint */
- }
-
- return sp;
-}
-
-int
-do_gnent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register char **elem;
- register STR *str;
- struct netent *getnetbyname();
- struct netent *getnetbyaddr();
- struct netent *getnetent();
- struct netent *nent;
-
- if (which == O_GNBYNAME) {
- char *name = str_get(ary->ary_array[sp+1]);
-
- nent = getnetbyname(name);
- }
- else if (which == O_GNBYADDR) {
- unsigned long addr = U_L(str_gnum(ary->ary_array[sp+1]));
- int addrtype = (int)str_gnum(ary->ary_array[sp+2]);
-
- nent = getnetbyaddr((long)addr,addrtype);
- }
- else
- nent = getnetent();
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (nent) {
- if (which == O_GNBYNAME)
- str_numset(str, (double)nent->n_net);
- else
- str_set(str, nent->n_name);
- }
- return sp;
- }
-
- if (nent) {
-#ifndef lint
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, nent->n_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- for (elem = nent->n_aliases; *elem; elem++) {
- str_cat(str, *elem);
- if (elem[1])
- str_ncat(str," ",1);
- }
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)nent->n_addrtype);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)nent->n_net);
-#else /* lint */
- elem = Nullch;
- elem = elem;
- (void)astore(ary, ++sp, str_mortal(&str_no));
-#endif /* lint */
- }
-
- return sp;
-}
-
-int
-do_gpent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register char **elem;
- register STR *str;
- struct protoent *getprotobyname();
- struct protoent *getprotobynumber();
- struct protoent *getprotoent();
- struct protoent *pent;
-
- if (which == O_GPBYNAME) {
- char *name = str_get(ary->ary_array[sp+1]);
-
- pent = getprotobyname(name);
- }
- else if (which == O_GPBYNUMBER) {
- int proto = (int)str_gnum(ary->ary_array[sp+1]);
-
- pent = getprotobynumber(proto);
- }
- else
- pent = getprotoent();
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (pent) {
- if (which == O_GPBYNAME)
- str_numset(str, (double)pent->p_proto);
- else
- str_set(str, pent->p_name);
- }
- return sp;
- }
-
- if (pent) {
-#ifndef lint
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pent->p_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- for (elem = pent->p_aliases; *elem; elem++) {
- str_cat(str, *elem);
- if (elem[1])
- str_ncat(str," ",1);
- }
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)pent->p_proto);
-#else /* lint */
- elem = Nullch;
- elem = elem;
- (void)astore(ary, ++sp, str_mortal(&str_no));
-#endif /* lint */
- }
-
- return sp;
-}
-
-int
-do_gsent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register char **elem;
- register STR *str;
- struct servent *getservbyname();
- struct servent *getservbynumber();
- struct servent *getservent();
- struct servent *sent;
-
- if (which == O_GSBYNAME) {
- char *name = str_get(ary->ary_array[sp+1]);
- char *proto = str_get(ary->ary_array[sp+2]);
-
- if (proto && !*proto)
- proto = Nullch;
-
- sent = getservbyname(name,proto);
- }
- else if (which == O_GSBYPORT) {
- int port = (int)str_gnum(ary->ary_array[sp+1]);
- char *proto = str_get(ary->ary_array[sp+2]);
-
- sent = getservbyport(port,proto);
- }
- else
- sent = getservent();
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (sent) {
- if (which == O_GSBYNAME) {
-#ifdef HAS_NTOHS
- str_numset(str, (double)ntohs(sent->s_port));
-#else
- str_numset(str, (double)(sent->s_port));
-#endif
- }
- else
- str_set(str, sent->s_name);
- }
- return sp;
- }
-
- if (sent) {
-#ifndef lint
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, sent->s_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- for (elem = sent->s_aliases; *elem; elem++) {
- str_cat(str, *elem);
- if (elem[1])
- str_ncat(str," ",1);
- }
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
-#ifdef HAS_NTOHS
- str_numset(str, (double)ntohs(sent->s_port));
-#else
- str_numset(str, (double)(sent->s_port));
-#endif
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, sent->s_proto);
-#else /* lint */
- elem = Nullch;
- elem = elem;
- (void)astore(ary, ++sp, str_mortal(&str_no));
-#endif /* lint */
- }
-
- return sp;
-}
-
-#endif /* HAS_SOCKET */
-
-#ifdef HAS_SELECT
-int
-do_select(gimme,arglast)
-int gimme;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- register int i;
- register int j;
- register char *s;
- register STR *str;
- double value;
- int maxlen = 0;
- int nfound;
- struct timeval timebuf;
- struct timeval *tbuf = &timebuf;
- int growsize;
-#if BYTEORDER != 0x1234 && BYTEORDER != 0x12345678
- int masksize;
- int offset;
- char *fd_sets[4];
- int k;
-
-#if BYTEORDER & 0xf0000
-#define ORDERBYTE (0x88888888 - BYTEORDER)
-#else
-#define ORDERBYTE (0x4444 - BYTEORDER)
-#endif
-
-#endif
-
- for (i = 1; i <= 3; i++) {
- j = st[sp+i]->str_cur;
- if (maxlen < j)
- maxlen = j;
- }
-
-#if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678
- growsize = maxlen; /* little endians can use vecs directly */
-#else
-#ifdef NFDBITS
-
-#ifndef NBBY
-#define NBBY 8
-#endif
-
- masksize = NFDBITS / NBBY;
-#else
- masksize = sizeof(long); /* documented int, everyone seems to use long */
-#endif
- growsize = maxlen + (masksize - (maxlen % masksize));
- Zero(&fd_sets[0], 4, char*);
-#endif
-
- for (i = 1; i <= 3; i++) {
- str = st[sp+i];
- j = str->str_len;
- if (j < growsize) {
- if (str->str_pok) {
- Str_Grow(str,growsize);
- s = str_get(str) + j;
- while (++j <= growsize) {
- *s++ = '\0';
- }
- }
- else if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_ptr = Nullch;
- }
- }
-#if BYTEORDER != 0x1234 && BYTEORDER != 0x12345678
- s = str->str_ptr;
- if (s) {
- New(403, fd_sets[i], growsize, char);
- for (offset = 0; offset < growsize; offset += masksize) {
- for (j = 0, k=ORDERBYTE; j < masksize; j++, (k >>= 4))
- fd_sets[i][j+offset] = s[(k % masksize) + offset];
- }
- }
-#endif
- }
- str = st[sp+4];
- if (str->str_nok || str->str_pok) {
- value = str_gnum(str);
- if (value < 0.0)
- value = 0.0;
- timebuf.tv_sec = (long)value;
- value -= (double)timebuf.tv_sec;
- timebuf.tv_usec = (long)(value * 1000000.0);
- }
- else
- tbuf = Null(struct timeval*);
-
-#if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678
- nfound = select(
- maxlen * 8,
- (fd_set *) st[sp+1]->str_ptr,
- (fd_set *) st[sp+2]->str_ptr,
- (fd_set *) st[sp+3]->str_ptr,
- tbuf);
-#else
- nfound = select(
- maxlen * 8,
- fd_sets[1],
- fd_sets[2],
- fd_sets[3],
- tbuf);
- for (i = 1; i <= 3; i++) {
- if (fd_sets[i]) {
- str = st[sp+i];
- s = str->str_ptr;
- for (offset = 0; offset < growsize; offset += masksize) {
- for (j = 0, k=ORDERBYTE; j < masksize; j++, (k >>= 4))
- s[(k % masksize) + offset] = fd_sets[i][j+offset];
- }
- Safefree(fd_sets[i]);
- }
- }
-#endif
-
- st[++sp] = str_mortal(&str_no);
- str_numset(st[sp], (double)nfound);
- if (gimme == G_ARRAY && tbuf) {
- value = (double)(timebuf.tv_sec) +
- (double)(timebuf.tv_usec) / 1000000.0;
- st[++sp] = str_mortal(&str_no);
- str_numset(st[sp], value);
- }
- return sp;
-}
-#endif /* SELECT */
-
-#ifdef HAS_SOCKET
-int
-do_spair(stab1, stab2, arglast)
-STAB *stab1;
-STAB *stab2;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[2];
- register STIO *stio1;
- register STIO *stio2;
- int domain, type, protocol, fd[2];
-
- if (!stab1 || !stab2)
- return FALSE;
-
- stio1 = stab_io(stab1);
- stio2 = stab_io(stab2);
- if (!stio1)
- stio1 = stab_io(stab1) = stio_new();
- else if (stio1->ifp)
- do_close(stab1,FALSE);
- if (!stio2)
- stio2 = stab_io(stab2) = stio_new();
- else if (stio2->ifp)
- do_close(stab2,FALSE);
-
- domain = (int)str_gnum(st[++sp]);
- type = (int)str_gnum(st[++sp]);
- protocol = (int)str_gnum(st[++sp]);
-#ifdef TAINT
- taintproper("Insecure dependency in socketpair");
-#endif
-#ifdef HAS_SOCKETPAIR
- if (socketpair(domain,type,protocol,fd) < 0)
- return FALSE;
-#else
- fatal("Socketpair unimplemented");
-#endif
- stio1->ifp = fdopen(fd[0], "r");
- stio1->ofp = fdopen(fd[0], "w");
- stio1->type = 's';
- stio2->ifp = fdopen(fd[1], "r");
- stio2->ofp = fdopen(fd[1], "w");
- stio2->type = 's';
- if (!stio1->ifp || !stio1->ofp || !stio2->ifp || !stio2->ofp) {
- if (stio1->ifp) fclose(stio1->ifp);
- if (stio1->ofp) fclose(stio1->ofp);
- if (!stio1->ifp && !stio1->ofp) close(fd[0]);
- if (stio2->ifp) fclose(stio2->ifp);
- if (stio2->ofp) fclose(stio2->ofp);
- if (!stio2->ifp && !stio2->ofp) close(fd[1]);
- return FALSE;
- }
-
- return TRUE;
-}
-
-#endif /* HAS_SOCKET */
-
-int
-do_gpwent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
-#ifdef I_PWD
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register STR *str;
- struct passwd *getpwnam();
- struct passwd *getpwuid();
- struct passwd *getpwent();
- struct passwd *pwent;
-
- if (which == O_GPWNAM) {
- char *name = str_get(ary->ary_array[sp+1]);
-
- pwent = getpwnam(name);
- }
- else if (which == O_GPWUID) {
- int uid = (int)str_gnum(ary->ary_array[sp+1]);
-
- pwent = getpwuid(uid);
- }
- else
- pwent = getpwent();
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (pwent) {
- if (which == O_GPWNAM)
- str_numset(str, (double)pwent->pw_uid);
- else
- str_set(str, pwent->pw_name);
- }
- return sp;
- }
-
- if (pwent) {
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pwent->pw_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pwent->pw_passwd);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)pwent->pw_uid);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)pwent->pw_gid);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
-#ifdef PWCHANGE
- str_numset(str, (double)pwent->pw_change);
-#else
-#ifdef PWQUOTA
- str_numset(str, (double)pwent->pw_quota);
-#else
-#ifdef PWAGE
- str_set(str, pwent->pw_age);
-#endif
-#endif
-#endif
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
-#ifdef PWCLASS
- str_set(str,pwent->pw_class);
-#else
-#ifdef PWCOMMENT
- str_set(str, pwent->pw_comment);
-#endif
-#endif
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pwent->pw_gecos);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pwent->pw_dir);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pwent->pw_shell);
-#ifdef PWEXPIRE
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)pwent->pw_expire);
-#endif
- }
-
- return sp;
-#else
- fatal("password routines not implemented");
-#endif
-}
-
-int
-do_ggrent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
-#ifdef I_GRP
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register char **elem;
- register STR *str;
- struct group *getgrnam();
- struct group *getgrgid();
- struct group *getgrent();
- struct group *grent;
-
- if (which == O_GGRNAM) {
- char *name = str_get(ary->ary_array[sp+1]);
-
- grent = getgrnam(name);
- }
- else if (which == O_GGRGID) {
- int gid = (int)str_gnum(ary->ary_array[sp+1]);
-
- grent = getgrgid(gid);
- }
- else
- grent = getgrent();
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (grent) {
- if (which == O_GGRNAM)
- str_numset(str, (double)grent->gr_gid);
- else
- str_set(str, grent->gr_name);
- }
- return sp;
- }
-
- if (grent) {
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, grent->gr_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, grent->gr_passwd);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)grent->gr_gid);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- for (elem = grent->gr_mem; *elem; elem++) {
- str_cat(str, *elem);
- if (elem[1])
- str_ncat(str," ",1);
- }
- }
-
- return sp;
-#else
- fatal("group routines not implemented");
-#endif
-}
-
-int
-do_dirop(optype,stab,gimme,arglast)
-int optype;
-STAB *stab;
-int gimme;
-int *arglast;
-{
-#if defined(DIRENT) && defined(HAS_READDIR)
- register ARRAY *ary = stack;
- register STR **st = ary->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- long along;
-#ifndef apollo
- struct DIRENT *readdir();
-#endif
- register struct DIRENT *dp;
-
- if (!stab)
- goto nope;
- if (!(stio = stab_io(stab)))
- stio = stab_io(stab) = stio_new();
- if (!stio->dirp && optype != O_OPEN_DIR)
- goto nope;
- st[sp] = &str_yes;
- switch (optype) {
- case O_OPEN_DIR:
- if (stio->dirp)
- closedir(stio->dirp);
- if (!(stio->dirp = opendir(str_get(st[sp+1]))))
- goto nope;
- break;
- case O_READDIR:
- if (gimme == G_ARRAY) {
- --sp;
- /*SUPPRESS 560*/
- while (dp = readdir(stio->dirp)) {
-#ifdef DIRNAMLEN
- (void)astore(ary,++sp,
- str_2mortal(str_make(dp->d_name,dp->d_namlen)));
-#else
- (void)astore(ary,++sp,
- str_2mortal(str_make(dp->d_name,0)));
-#endif
- }
- }
- else {
- if (!(dp = readdir(stio->dirp)))
- goto nope;
- st[sp] = str_mortal(&str_undef);
-#ifdef DIRNAMLEN
- str_nset(st[sp], dp->d_name, dp->d_namlen);
-#else
- str_set(st[sp], dp->d_name);
-#endif
- }
- break;
-#if defined(HAS_TELLDIR) || defined(telldir)
- case O_TELLDIR: {
-#ifndef telldir
- long telldir();
-#endif
- st[sp] = str_mortal(&str_undef);
- str_numset(st[sp], (double)telldir(stio->dirp));
- break;
- }
-#endif
-#if defined(HAS_SEEKDIR) || defined(seekdir)
- case O_SEEKDIR:
- st[sp] = str_mortal(&str_undef);
- along = (long)str_gnum(st[sp+1]);
- (void)seekdir(stio->dirp,along);
- break;
-#endif
-#if defined(HAS_REWINDDIR) || defined(rewinddir)
- case O_REWINDDIR:
- st[sp] = str_mortal(&str_undef);
- (void)rewinddir(stio->dirp);
- break;
-#endif
- case O_CLOSEDIR:
- st[sp] = str_mortal(&str_undef);
- (void)closedir(stio->dirp);
- stio->dirp = 0;
- break;
- default:
- goto phooey;
- }
- return sp;
-
-nope:
- st[sp] = &str_undef;
- if (!errno)
- errno = EBADF;
- return sp;
-
-#endif
-phooey:
- fatal("Unimplemented directory operation");
-}
-
-int
-apply(type,arglast)
-int type;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int items = arglast[2] - sp;
- register int val;
- register int val2;
- register int tot = 0;
- char *s;
-
-#ifdef TAINT
- for (st += ++sp; items--; st++)
- tainted |= (*st)->str_tainted;
- st = stack->ary_array;
- sp = arglast[1];
- items = arglast[2] - sp;
-#endif
- switch (type) {
- case O_CHMOD:
-#ifdef TAINT
- taintproper("Insecure dependency in chmod");
-#endif
- if (--items > 0) {
- tot = items;
- val = (int)str_gnum(st[++sp]);
- while (items--) {
- if (chmod(str_get(st[++sp]),val))
- tot--;
- }
- }
- break;
-#ifdef HAS_CHOWN
- case O_CHOWN:
-#ifdef TAINT
- taintproper("Insecure dependency in chown");
-#endif
- if (items > 2) {
- items -= 2;
- tot = items;
- val = (int)str_gnum(st[++sp]);
- val2 = (int)str_gnum(st[++sp]);
- while (items--) {
- if (chown(str_get(st[++sp]),val,val2))
- tot--;
- }
- }
- break;
-#endif
-#ifdef HAS_KILL
- case O_KILL:
-#ifdef TAINT
- taintproper("Insecure dependency in kill");
-#endif
- if (--items > 0) {
- tot = items;
- s = str_get(st[++sp]);
- if (isUPPER(*s)) {
- if (*s == 'S' && s[1] == 'I' && s[2] == 'G')
- s += 3;
- if (!(val = whichsig(s)))
- fatal("Unrecognized signal name \"%s\"",s);
- }
- else
- val = (int)str_gnum(st[sp]);
- if (val < 0) {
- val = -val;
- while (items--) {
- int proc = (int)str_gnum(st[++sp]);
-#ifdef HAS_KILLPG
- if (killpg(proc,val)) /* BSD */
-#else
- if (kill(-proc,val)) /* SYSV */
-#endif
- tot--;
- }
- }
- else {
- while (items--) {
- if (kill((int)(str_gnum(st[++sp])),val))
- tot--;
- }
- }
- }
- break;
-#endif
- case O_UNLINK:
-#ifdef TAINT
- taintproper("Insecure dependency in unlink");
-#endif
- tot = items;
- while (items--) {
- s = str_get(st[++sp]);
- if (euid || unsafe) {
- if (UNLINK(s))
- tot--;
- }
- else { /* don't let root wipe out directories without -U */
-#ifdef HAS_LSTAT
- if (lstat(s,&statbuf) < 0 || S_ISDIR(statbuf.st_mode))
-#else
- if (stat(s,&statbuf) < 0 || S_ISDIR(statbuf.st_mode))
-#endif
- tot--;
- else {
- if (UNLINK(s))
- tot--;
- }
- }
- }
- break;
- case O_UTIME:
-#ifdef TAINT
- taintproper("Insecure dependency in utime");
-#endif
- if (items > 2) {
-#ifdef I_UTIME
- struct utimbuf utbuf;
-#else
- struct {
- long actime;
- long modtime;
- } utbuf;
-#endif
-
- Zero(&utbuf, sizeof utbuf, char);
- utbuf.actime = (long)str_gnum(st[++sp]); /* time accessed */
- utbuf.modtime = (long)str_gnum(st[++sp]); /* time modified */
- items -= 2;
-#ifndef lint
- tot = items;
- while (items--) {
- if (utime(str_get(st[++sp]),&utbuf))
- tot--;
- }
-#endif
- }
- else
- items = 0;
- break;
- }
- return tot;
-}
-
-/* Do the permissions allow some operation? Assumes statcache already set. */
-
-int
-cando(bit, effective, statbufp)
-int bit;
-int effective;
-register struct stat *statbufp;
-{
-#ifdef DOSISH
- /* [Comments and code from Len Reed]
- * MS-DOS "user" is similar to UNIX's "superuser," but can't write
- * to write-protected files. The execute permission bit is set
- * by the Miscrosoft C library stat() function for the following:
- * .exe files
- * .com files
- * .bat files
- * directories
- * All files and directories are readable.
- * Directories and special files, e.g. "CON", cannot be
- * write-protected.
- * [Comment by Tom Dinger -- a directory can have the write-protect
- * bit set in the file system, but DOS permits changes to
- * the directory anyway. In addition, all bets are off
- * here for networked software, such as Novell and
- * Sun's PC-NFS.]
- */
-
- /* Atari stat() does pretty much the same thing. we set x_bit_set_in_stat
- * too so it will actually look into the files for magic numbers
- */
- return (bit & statbufp->st_mode) ? TRUE : FALSE;
-
-#else /* ! MSDOS */
- if ((effective ? euid : uid) == 0) { /* root is special */
- if (bit == S_IXUSR) {
- if (statbufp->st_mode & 0111 || S_ISDIR(statbufp->st_mode))
- return TRUE;
- }
- else
- return TRUE; /* root reads and writes anything */
- return FALSE;
- }
- if (statbufp->st_uid == (effective ? euid : uid) ) {
- if (statbufp->st_mode & bit)
- return TRUE; /* ok as "user" */
- }
- else if (ingroup((int)statbufp->st_gid,effective)) {
- if (statbufp->st_mode & bit >> 3)
- return TRUE; /* ok as "group" */
- }
- else if (statbufp->st_mode & bit >> 6)
- return TRUE; /* ok as "other" */
- return FALSE;
-#endif /* ! MSDOS */
-}
-
-int
-ingroup(testgid,effective)
-int testgid;
-int effective;
-{
- if (testgid == (effective ? egid : gid))
- return TRUE;
-#ifdef HAS_GETGROUPS
-#ifndef NGROUPS
-#define NGROUPS 32
-#endif
- {
- GROUPSTYPE gary[NGROUPS];
- int anum;
-
- anum = getgroups(NGROUPS,gary);
- while (--anum >= 0)
- if (gary[anum] == testgid)
- return TRUE;
- }
-#endif
- return FALSE;
-}
-
-#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
-
-int
-do_ipcget(optype, arglast)
-int optype;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- key_t key;
- int n, flags;
-
- key = (key_t)str_gnum(st[++sp]);
- n = (optype == O_MSGGET) ? 0 : (int)str_gnum(st[++sp]);
- flags = (int)str_gnum(st[++sp]);
- errno = 0;
- switch (optype)
- {
-#ifdef HAS_MSG
- case O_MSGGET:
- return msgget(key, flags);
-#endif
-#ifdef HAS_SEM
- case O_SEMGET:
- return semget(key, n, flags);
-#endif
-#ifdef HAS_SHM
- case O_SHMGET:
- return shmget(key, n, flags);
-#endif
-#if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM)
- default:
- fatal("%s not implemented", opname[optype]);
-#endif
- }
- return -1; /* should never happen */
-}
-
-int
-do_ipcctl(optype, arglast)
-int optype;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- STR *astr;
- char *a;
- int id, n, cmd, infosize, getinfo, ret;
-
- id = (int)str_gnum(st[++sp]);
- n = (optype == O_SEMCTL) ? (int)str_gnum(st[++sp]) : 0;
- cmd = (int)str_gnum(st[++sp]);
- astr = st[++sp];
-
- infosize = 0;
- getinfo = (cmd == IPC_STAT);
-
- switch (optype)
- {
-#ifdef HAS_MSG
- case O_MSGCTL:
- if (cmd == IPC_STAT || cmd == IPC_SET)
- infosize = sizeof(struct msqid_ds);
- break;
-#endif
-#ifdef HAS_SHM
- case O_SHMCTL:
- if (cmd == IPC_STAT || cmd == IPC_SET)
- infosize = sizeof(struct shmid_ds);
- break;
-#endif
-#ifdef HAS_SEM
- case O_SEMCTL:
- if (cmd == IPC_STAT || cmd == IPC_SET)
- infosize = sizeof(struct semid_ds);
- else if (cmd == GETALL || cmd == SETALL)
- {
- struct semid_ds semds;
- if (semctl(id, 0, IPC_STAT, (union semun)&semds) == -1)
- return -1;
- getinfo = (cmd == GETALL);
- infosize = semds.sem_nsems * sizeof(short);
- /* "short" is technically wrong but much more portable
- than guessing about u_?short(_t)? */
- }
- break;
-#endif
-#if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM)
- default:
- fatal("%s not implemented", opname[optype]);
-#endif
- }
-
- if (infosize)
- {
- if (getinfo)
- {
- STR_GROW(astr, infosize+1);
- a = str_get(astr);
- }
- else
- {
- a = str_get(astr);
- if (astr->str_cur != infosize)
- {
- errno = EINVAL;
- return -1;
- }
- }
- }
- else
- {
- int i = (int)str_gnum(astr);
- a = (char *)i; /* ouch */
- }
- errno = 0;
- switch (optype)
- {
-#ifdef HAS_MSG
- case O_MSGCTL:
- ret = msgctl(id, cmd, (struct msqid_ds *)a);
- break;
-#endif
-#ifdef HAS_SEM
- case O_SEMCTL:
- ret = semctl(id, n, cmd, (union semun)((int)a));
- break;
-#endif
-#ifdef HAS_SHM
- case O_SHMCTL:
- ret = shmctl(id, cmd, (struct shmid_ds *)a);
- break;
-#endif
- }
- if (getinfo && ret >= 0) {
- astr->str_cur = infosize;
- astr->str_ptr[infosize] = '\0';
- }
- return ret;
-}
-
-int
-do_msgsnd(arglast)
-int *arglast;
-{
-#ifdef HAS_MSG
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- STR *mstr;
- char *mbuf;
- int id, msize, flags;
-
- id = (int)str_gnum(st[++sp]);
- mstr = st[++sp];
- flags = (int)str_gnum(st[++sp]);
- mbuf = str_get(mstr);
- if ((msize = mstr->str_cur - sizeof(long)) < 0) {
- errno = EINVAL;
- return -1;
- }
- errno = 0;
- return msgsnd(id, (struct msgbuf *)mbuf, msize, flags);
-#else
- fatal("msgsnd not implemented");
-#endif
-}
-
-int
-do_msgrcv(arglast)
-int *arglast;
-{
-#ifdef HAS_MSG
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- STR *mstr;
- char *mbuf;
- long mtype;
- int id, msize, flags, ret;
-
- id = (int)str_gnum(st[++sp]);
- mstr = st[++sp];
- msize = (int)str_gnum(st[++sp]);
- mtype = (long)str_gnum(st[++sp]);
- flags = (int)str_gnum(st[++sp]);
- mbuf = str_get(mstr);
- if (mstr->str_cur < sizeof(long)+msize+1) {
- STR_GROW(mstr, sizeof(long)+msize+1);
- mbuf = str_get(mstr);
- }
- errno = 0;
- ret = msgrcv(id, (struct msgbuf *)mbuf, msize, mtype, flags);
- if (ret >= 0) {
- mstr->str_cur = sizeof(long)+ret;
- mstr->str_ptr[sizeof(long)+ret] = '\0';
- }
- return ret;
-#else
- fatal("msgrcv not implemented");
-#endif
-}
-
-int
-do_semop(arglast)
-int *arglast;
-{
-#ifdef HAS_SEM
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- STR *opstr;
- char *opbuf;
- int id, opsize;
-
- id = (int)str_gnum(st[++sp]);
- opstr = st[++sp];
- opbuf = str_get(opstr);
- opsize = opstr->str_cur;
- if (opsize < sizeof(struct sembuf)
- || (opsize % sizeof(struct sembuf)) != 0) {
- errno = EINVAL;
- return -1;
- }
- errno = 0;
- return semop(id, (struct sembuf *)opbuf, opsize/sizeof(struct sembuf));
-#else
- fatal("semop not implemented");
-#endif
-}
-
-int
-do_shmio(optype, arglast)
-int optype;
-int *arglast;
-{
-#ifdef HAS_SHM
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- STR *mstr;
- char *mbuf, *shm;
- int id, mpos, msize;
- struct shmid_ds shmds;
-#ifndef VOIDSHMAT
- extern char *shmat();
-#endif
-
- id = (int)str_gnum(st[++sp]);
- mstr = st[++sp];
- mpos = (int)str_gnum(st[++sp]);
- msize = (int)str_gnum(st[++sp]);
- errno = 0;
- if (shmctl(id, IPC_STAT, &shmds) == -1)
- return -1;
- if (mpos < 0 || msize < 0 || mpos + msize > shmds.shm_segsz) {
- errno = EFAULT; /* can't do as caller requested */
- return -1;
- }
- shm = (char*)shmat(id, (char*)NULL, (optype == O_SHMREAD) ? SHM_RDONLY : 0);
- if (shm == (char *)-1) /* I hate System V IPC, I really do */
- return -1;
- mbuf = str_get(mstr);
- if (optype == O_SHMREAD) {
- if (mstr->str_cur < msize) {
- STR_GROW(mstr, msize+1);
- mbuf = str_get(mstr);
- }
- Copy(shm + mpos, mbuf, msize, char);
- mstr->str_cur = msize;
- mstr->str_ptr[msize] = '\0';
- }
- else {
- int n;
-
- if ((n = mstr->str_cur) > msize)
- n = msize;
- Copy(mbuf, shm + mpos, n, char);
- if (n < msize)
- memzero(shm + mpos + n, msize - n);
- }
- return shmdt(shm);
-#else
- fatal("shm I/O not implemented");
-#endif
-}
-
-#endif /* SYSV IPC */
diff --git a/gnu/usr.bin/perl/perl/dolist.c b/gnu/usr.bin/perl/perl/dolist.c
deleted file mode 100644
index 448a260..0000000
--- a/gnu/usr.bin/perl/perl/dolist.c
+++ /dev/null
@@ -1,1976 +0,0 @@
-/* $RCSfile: dolist.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:32 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: dolist.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:32 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:36 nate
- * PERL!
- *
- * Revision 4.0.1.5 92/06/08 13:13:27 lwall
- * patch20: g pattern modifer sometimes returned extra values
- * patch20: m/$pattern/g didn't work
- * patch20: pattern modifiers i and o didn't interact right
- * patch20: @ in unpack failed too often
- * patch20: Perl now distinguishes overlapped copies from non-overlapped
- * patch20: slice on null list in scalar context returned random value
- * patch20: splice with negative offset didn't work with $[ = 1
- * patch20: fixed some memory leaks in splice
- * patch20: scalar keys %array now counts keys for you
- *
- * Revision 4.0.1.4 91/11/11 16:33:19 lwall
- * patch19: added little-endian pack/unpack options
- * patch19: sort $subname was busted by changes in 4.018
- *
- * Revision 4.0.1.3 91/11/05 17:07:02 lwall
- * patch11: prepared for ctype implementations that don't define isascii()
- * patch11: /$foo/o optimizer could access deallocated data
- * patch11: certain optimizations of //g in array context returned too many values
- * patch11: regexp with no parens in array context returned wacky $`, $& and $'
- * patch11: $' not set right on some //g
- * patch11: added some support for 64-bit integers
- * patch11: grep of a split lost its values
- * patch11: added sort {} LIST
- * patch11: multiple reallocations now avoided in 1 .. 100000
- *
- * Revision 4.0.1.2 91/06/10 01:22:15 lwall
- * patch10: //g only worked first time through
- *
- * Revision 4.0.1.1 91/06/07 10:58:28 lwall
- * patch4: new copyright notice
- * patch4: added global modifier for pattern matches
- * patch4: // wouldn't use previous pattern if it started with a null character
- * patch4: //o and s///o now optimize themselves fully at runtime
- * patch4: $` was busted inside s///
- * patch4: caller($arg) didn't work except under debugger
- *
- * Revision 4.0 91/03/20 01:08:03 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-static int sortcmp();
-static int sortsub();
-
-#ifdef BUGGY_MSC
- #pragma function(memcmp)
-#endif /* BUGGY_MSC */
-
-int
-do_match(str,arg,gimme,arglast)
-STR *str;
-register ARG *arg;
-int gimme;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register SPAT *spat = arg[2].arg_ptr.arg_spat;
- register char *t;
- register int sp = arglast[0] + 1;
- STR *srchstr = st[sp];
- register char *s = str_get(st[sp]);
- char *strend = s + st[sp]->str_cur;
- STR *tmpstr;
- char *myhint = hint;
- int global;
- int safebase;
- char *truebase = s;
- register REGEXP *rx = spat->spat_regexp;
-
- hint = Nullch;
- if (!spat) {
- if (gimme == G_ARRAY)
- return --sp;
- str_set(str,Yes);
- STABSET(str);
- st[sp] = str;
- return sp;
- }
- global = spat->spat_flags & SPAT_GLOBAL;
- safebase = (gimme == G_ARRAY) || global;
- if (!s)
- fatal("panic: do_match");
- if (spat->spat_flags & SPAT_USED) {
-#ifdef DEBUGGING
- if (debug & 8)
- deb("2.SPAT USED\n");
-#endif
- if (gimme == G_ARRAY)
- return --sp;
- str_set(str,No);
- STABSET(str);
- st[sp] = str;
- return sp;
- }
- --sp;
- if (spat->spat_runtime) {
- nointrp = "|)";
- sp = eval(spat->spat_runtime,G_SCALAR,sp);
- st = stack->ary_array;
- t = str_get(tmpstr = st[sp--]);
- nointrp = "";
-#ifdef DEBUGGING
- if (debug & 8)
- deb("2.SPAT /%s/\n",t);
-#endif
- if (!global && rx)
- regfree(rx);
- spat->spat_regexp = Null(REGEXP*); /* crucial if regcomp aborts */
- spat->spat_regexp = regcomp(t,t+tmpstr->str_cur,
- spat->spat_flags & SPAT_FOLD);
- if (!spat->spat_regexp->prelen && lastspat)
- spat = lastspat;
- if (spat->spat_flags & SPAT_KEEP) {
- if (!(spat->spat_flags & SPAT_FOLD))
- scanconst(spat,spat->spat_regexp->precomp,
- spat->spat_regexp->prelen);
- if (spat->spat_runtime)
- arg_free(spat->spat_runtime); /* it won't change, so */
- spat->spat_runtime = Nullarg; /* no point compiling again */
- hoistmust(spat);
- if (curcmd->c_expr && (curcmd->c_flags & CF_OPTIMIZE) == CFT_EVAL) {
- curcmd->c_flags &= ~CF_OPTIMIZE;
- opt_arg(curcmd, 1, curcmd->c_type == C_EXPR);
- }
- }
- if (global) {
- if (rx) {
- if (rx->startp[0]) {
- s = rx->endp[0];
- if (s == rx->startp[0])
- s++;
- if (s > strend) {
- regfree(rx);
- rx = spat->spat_regexp;
- goto nope;
- }
- }
- regfree(rx);
- }
- }
- else if (!spat->spat_regexp->nparens)
- gimme = G_SCALAR; /* accidental array context? */
- rx = spat->spat_regexp;
- if (regexec(rx, s, strend, s, 0,
- srchstr->str_pok & SP_STUDIED ? srchstr : Nullstr,
- safebase)) {
- if (rx->subbase || global)
- curspat = spat;
- lastspat = spat;
- goto gotcha;
- }
- else {
- if (gimme == G_ARRAY)
- return sp;
- str_sset(str,&str_no);
- STABSET(str);
- st[++sp] = str;
- return sp;
- }
- }
- else {
-#ifdef DEBUGGING
- if (debug & 8) {
- char ch;
-
- if (spat->spat_flags & SPAT_ONCE)
- ch = '?';
- else
- ch = '/';
- deb("2.SPAT %c%s%c\n",ch,rx->precomp,ch);
- }
-#endif
- if (!rx->prelen && lastspat) {
- spat = lastspat;
- rx = spat->spat_regexp;
- }
- t = s;
- play_it_again:
- if (global && rx->startp[0]) {
- t = s = rx->endp[0];
- if (s == rx->startp[0])
- s++,t++;
- if (s > strend)
- goto nope;
- }
- if (myhint) {
- if (myhint < s || myhint > strend)
- fatal("panic: hint in do_match");
- s = myhint;
- if (rx->regback >= 0) {
- s -= rx->regback;
- if (s < t)
- s = t;
- }
- else
- s = t;
- }
- else if (spat->spat_short) {
- if (spat->spat_flags & SPAT_SCANFIRST) {
- if (srchstr->str_pok & SP_STUDIED) {
- if (screamfirst[spat->spat_short->str_rare] < 0)
- goto nope;
- else if (!(s = screaminstr(srchstr,spat->spat_short)))
- goto nope;
- else if (spat->spat_flags & SPAT_ALL)
- goto yup;
- }
-#ifndef lint
- else if (!(s = fbminstr((unsigned char*)s,
- (unsigned char*)strend, spat->spat_short)))
- goto nope;
-#endif
- else if (spat->spat_flags & SPAT_ALL)
- goto yup;
- if (s && rx->regback >= 0) {
- ++spat->spat_short->str_u.str_useful;
- s -= rx->regback;
- if (s < t)
- s = t;
- }
- else
- s = t;
- }
- else if (!multiline && (*spat->spat_short->str_ptr != *s ||
- bcmp(spat->spat_short->str_ptr, s, spat->spat_slen) ))
- goto nope;
- if (--spat->spat_short->str_u.str_useful < 0) {
- str_free(spat->spat_short);
- spat->spat_short = Nullstr; /* opt is being useless */
- }
- }
- if (!rx->nparens && !global) {
- gimme = G_SCALAR; /* accidental array context? */
- safebase = FALSE;
- }
- if (regexec(rx, s, strend, truebase, 0,
- srchstr->str_pok & SP_STUDIED ? srchstr : Nullstr,
- safebase)) {
- if (rx->subbase || global)
- curspat = spat;
- lastspat = spat;
- if (spat->spat_flags & SPAT_ONCE)
- spat->spat_flags |= SPAT_USED;
- goto gotcha;
- }
- else {
- if (global)
- rx->startp[0] = Nullch;
- if (gimme == G_ARRAY)
- return sp;
- str_sset(str,&str_no);
- STABSET(str);
- st[++sp] = str;
- return sp;
- }
- }
- /*NOTREACHED*/
-
- gotcha:
- if (gimme == G_ARRAY) {
- int iters, i, len;
-
- iters = rx->nparens;
- if (global && !iters)
- i = 1;
- else
- i = 0;
- if (sp + iters + i >= stack->ary_max) {
- astore(stack,sp + iters + i, Nullstr);
- st = stack->ary_array; /* possibly realloced */
- }
-
- for (i = !i; i <= iters; i++) {
- st[++sp] = str_mortal(&str_no);
- /*SUPPRESS 560*/
- if (s = rx->startp[i]) {
- len = rx->endp[i] - s;
- if (len > 0)
- str_nset(st[sp],s,len);
- }
- }
- if (global) {
- truebase = rx->subbeg;
- goto play_it_again;
- }
- return sp;
- }
- else {
- str_sset(str,&str_yes);
- STABSET(str);
- st[++sp] = str;
- return sp;
- }
-
-yup:
- ++spat->spat_short->str_u.str_useful;
- lastspat = spat;
- if (spat->spat_flags & SPAT_ONCE)
- spat->spat_flags |= SPAT_USED;
- if (global) {
- rx->subbeg = t;
- rx->subend = strend;
- rx->startp[0] = s;
- rx->endp[0] = s + spat->spat_short->str_cur;
- curspat = spat;
- goto gotcha;
- }
- if (sawampersand) {
- char *tmps;
-
- if (rx->subbase)
- Safefree(rx->subbase);
- tmps = rx->subbase = nsavestr(t,strend-t);
- rx->subbeg = tmps;
- rx->subend = tmps + (strend-t);
- tmps = rx->startp[0] = tmps + (s - t);
- rx->endp[0] = tmps + spat->spat_short->str_cur;
- curspat = spat;
- }
- str_sset(str,&str_yes);
- STABSET(str);
- st[++sp] = str;
- return sp;
-
-nope:
- rx->startp[0] = Nullch;
- if (spat->spat_short)
- ++spat->spat_short->str_u.str_useful;
- if (gimme == G_ARRAY)
- return sp;
- str_sset(str,&str_no);
- STABSET(str);
- st[++sp] = str;
- return sp;
-}
-
-#ifdef BUGGY_MSC
- #pragma intrinsic(memcmp)
-#endif /* BUGGY_MSC */
-
-int
-do_split(str,spat,limit,gimme,arglast)
-STR *str;
-register SPAT *spat;
-register int limit;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- STR **st = ary->ary_array;
- register int sp = arglast[0] + 1;
- register char *s = str_get(st[sp]);
- char *strend = s + st[sp--]->str_cur;
- register STR *dstr;
- register char *m;
- int iters = 0;
- int maxiters = (strend - s) + 10;
- int i;
- char *orig;
- int origlimit = limit;
- int realarray = 0;
-
- if (!spat || !s)
- fatal("panic: do_split");
- else if (spat->spat_runtime) {
- nointrp = "|)";
- sp = eval(spat->spat_runtime,G_SCALAR,sp);
- st = stack->ary_array;
- m = str_get(dstr = st[sp--]);
- nointrp = "";
- if (*m == ' ' && dstr->str_cur == 1) {
- str_set(dstr,"\\s+");
- m = dstr->str_ptr;
- spat->spat_flags |= SPAT_SKIPWHITE;
- }
- if (spat->spat_regexp) {
- regfree(spat->spat_regexp);
- spat->spat_regexp = Null(REGEXP*); /* avoid possible double free */
- }
- spat->spat_regexp = regcomp(m,m+dstr->str_cur,
- spat->spat_flags & SPAT_FOLD);
- if (spat->spat_flags & SPAT_KEEP ||
- (spat->spat_runtime->arg_type == O_ITEM &&
- (spat->spat_runtime[1].arg_type & A_MASK) == A_SINGLE) ) {
- arg_free(spat->spat_runtime); /* it won't change, so */
- spat->spat_runtime = Nullarg; /* no point compiling again */
- }
- }
-#ifdef DEBUGGING
- if (debug & 8) {
- deb("2.SPAT /%s/\n",spat->spat_regexp->precomp);
- }
-#endif
- ary = stab_xarray(spat->spat_repl[1].arg_ptr.arg_stab);
- if (ary && (gimme != G_ARRAY || (spat->spat_flags & SPAT_ONCE))) {
- realarray = 1;
- if (!(ary->ary_flags & ARF_REAL)) {
- ary->ary_flags |= ARF_REAL;
- for (i = ary->ary_fill; i >= 0; i--)
- ary->ary_array[i] = Nullstr; /* don't free mere refs */
- }
- ary->ary_fill = -1;
- sp = -1; /* temporarily switch stacks */
- }
- else
- ary = stack;
- orig = s;
- if (spat->spat_flags & SPAT_SKIPWHITE) {
- while (isSPACE(*s))
- s++;
- }
- if (!limit)
- limit = maxiters + 2;
- if (strEQ("\\s+",spat->spat_regexp->precomp)) {
- while (--limit) {
- /*SUPPRESS 530*/
- for (m = s; m < strend && !isSPACE(*m); m++) ;
- if (m >= strend)
- break;
- dstr = Str_new(30,m-s);
- str_nset(dstr,s,m-s);
- if (!realarray)
- str_2mortal(dstr);
- (void)astore(ary, ++sp, dstr);
- /*SUPPRESS 530*/
- for (s = m + 1; s < strend && isSPACE(*s); s++) ;
- }
- }
- else if (strEQ("^",spat->spat_regexp->precomp)) {
- while (--limit) {
- /*SUPPRESS 530*/
- for (m = s; m < strend && *m != '\n'; m++) ;
- m++;
- if (m >= strend)
- break;
- dstr = Str_new(30,m-s);
- str_nset(dstr,s,m-s);
- if (!realarray)
- str_2mortal(dstr);
- (void)astore(ary, ++sp, dstr);
- s = m;
- }
- }
- else if (spat->spat_short) {
- i = spat->spat_short->str_cur;
- if (i == 1) {
- int fold = (spat->spat_flags & SPAT_FOLD);
-
- i = *spat->spat_short->str_ptr;
- if (fold && isUPPER(i))
- i = tolower(i);
- while (--limit) {
- if (fold) {
- for ( m = s;
- m < strend && *m != i &&
- (!isUPPER(*m) || tolower(*m) != i);
- m++) /*SUPPRESS 530*/
- ;
- }
- else /*SUPPRESS 530*/
- for (m = s; m < strend && *m != i; m++) ;
- if (m >= strend)
- break;
- dstr = Str_new(30,m-s);
- str_nset(dstr,s,m-s);
- if (!realarray)
- str_2mortal(dstr);
- (void)astore(ary, ++sp, dstr);
- s = m + 1;
- }
- }
- else {
-#ifndef lint
- while (s < strend && --limit &&
- (m=fbminstr((unsigned char*)s, (unsigned char*)strend,
- spat->spat_short)) )
-#endif
- {
- dstr = Str_new(31,m-s);
- str_nset(dstr,s,m-s);
- if (!realarray)
- str_2mortal(dstr);
- (void)astore(ary, ++sp, dstr);
- s = m + i;
- }
- }
- }
- else {
- maxiters += (strend - s) * spat->spat_regexp->nparens;
- while (s < strend && --limit &&
- regexec(spat->spat_regexp, s, strend, orig, 1, Nullstr, TRUE) ) {
- if (spat->spat_regexp->subbase
- && spat->spat_regexp->subbase != orig) {
- m = s;
- s = orig;
- orig = spat->spat_regexp->subbase;
- s = orig + (m - s);
- strend = s + (strend - m);
- }
- m = spat->spat_regexp->startp[0];
- dstr = Str_new(32,m-s);
- str_nset(dstr,s,m-s);
- if (!realarray)
- str_2mortal(dstr);
- (void)astore(ary, ++sp, dstr);
- if (spat->spat_regexp->nparens) {
- for (i = 1; i <= spat->spat_regexp->nparens; i++) {
- s = spat->spat_regexp->startp[i];
- m = spat->spat_regexp->endp[i];
- dstr = Str_new(33,m-s);
- str_nset(dstr,s,m-s);
- if (!realarray)
- str_2mortal(dstr);
- (void)astore(ary, ++sp, dstr);
- }
- }
- s = spat->spat_regexp->endp[0];
- }
- }
- if (realarray)
- iters = sp + 1;
- else
- iters = sp - arglast[0];
- if (iters > maxiters)
- fatal("Split loop");
- if (s < strend || origlimit) { /* keep field after final delim? */
- dstr = Str_new(34,strend-s);
- str_nset(dstr,s,strend-s);
- if (!realarray)
- str_2mortal(dstr);
- (void)astore(ary, ++sp, dstr);
- iters++;
- }
- else {
-#ifndef I286x
- while (iters > 0 && ary->ary_array[sp]->str_cur == 0)
- iters--,sp--;
-#else
- char *zaps;
- int zapb;
-
- if (iters > 0) {
- zaps = str_get(afetch(ary,sp,FALSE));
- zapb = (int) *zaps;
- }
-
- while (iters > 0 && (!zapb)) {
- iters--,sp--;
- if (iters > 0) {
- zaps = str_get(afetch(ary,iters-1,FALSE));
- zapb = (int) *zaps;
- }
- }
-#endif
- }
- if (realarray) {
- ary->ary_fill = sp;
- if (gimme == G_ARRAY) {
- sp++;
- astore(stack, arglast[0] + 1 + sp, Nullstr);
- Copy(ary->ary_array, stack->ary_array + arglast[0] + 1, sp, STR*);
- return arglast[0] + sp;
- }
- }
- else {
- if (gimme == G_ARRAY)
- return sp;
- }
- sp = arglast[0] + 1;
- str_numset(str,(double)iters);
- STABSET(str);
- st[sp] = str;
- return sp;
-}
-
-int
-do_unpack(str,gimme,arglast)
-STR *str;
-int gimme;
-int *arglast;
-{
- STR **st = stack->ary_array;
- register int sp = arglast[0] + 1;
- register char *pat = str_get(st[sp++]);
- register char *s = str_get(st[sp]);
- char *strend = s + st[sp--]->str_cur;
- char *strbeg = s;
- register char *patend = pat + st[sp]->str_cur;
- int datumtype;
- register int len;
- register int bits;
-
- /* These must not be in registers: */
- short ashort;
- int aint;
- long along;
-#ifdef QUAD
- quad aquad;
-#endif
- unsigned short aushort;
- unsigned int auint;
- unsigned long aulong;
-#ifdef QUAD
- unsigned quad auquad;
-#endif
- char *aptr;
- float afloat;
- double adouble;
- int checksum = 0;
- unsigned long culong;
- double cdouble;
-
- if (gimme != G_ARRAY) { /* arrange to do first one only */
- /*SUPPRESS 530*/
- for (patend = pat; !isALPHA(*patend) || *patend == 'x'; patend++) ;
- if (index("aAbBhH", *patend) || *pat == '%') {
- patend++;
- while (isDIGIT(*patend) || *patend == '*')
- patend++;
- }
- else
- patend++;
- }
- sp--;
- while (pat < patend) {
- reparse:
- datumtype = *pat++;
- if (pat >= patend)
- len = 1;
- else if (*pat == '*') {
- len = strend - strbeg; /* long enough */
- pat++;
- }
- else if (isDIGIT(*pat)) {
- len = *pat++ - '0';
- while (isDIGIT(*pat))
- len = (len * 10) + (*pat++ - '0');
- }
- else
- len = (datumtype != '@');
- switch(datumtype) {
- default:
- break;
- case '%':
- if (len == 1 && pat[-1] != '1')
- len = 16;
- checksum = len;
- culong = 0;
- cdouble = 0;
- if (pat < patend)
- goto reparse;
- break;
- case '@':
- if (len > strend - strbeg)
- fatal("@ outside of string");
- s = strbeg + len;
- break;
- case 'X':
- if (len > s - strbeg)
- fatal("X outside of string");
- s -= len;
- break;
- case 'x':
- if (len > strend - s)
- fatal("x outside of string");
- s += len;
- break;
- case 'A':
- case 'a':
- if (len > strend - s)
- len = strend - s;
- if (checksum)
- goto uchar_checksum;
- str = Str_new(35,len);
- str_nset(str,s,len);
- s += len;
- if (datumtype == 'A') {
- aptr = s; /* borrow register */
- s = str->str_ptr + len - 1;
- while (s >= str->str_ptr && (!*s || isSPACE(*s)))
- s--;
- *++s = '\0';
- str->str_cur = s - str->str_ptr;
- s = aptr; /* unborrow register */
- }
- (void)astore(stack, ++sp, str_2mortal(str));
- break;
- case 'B':
- case 'b':
- if (pat[-1] == '*' || len > (strend - s) * 8)
- len = (strend - s) * 8;
- str = Str_new(35, len + 1);
- str->str_cur = len;
- str->str_pok = 1;
- aptr = pat; /* borrow register */
- pat = str->str_ptr;
- if (datumtype == 'b') {
- aint = len;
- for (len = 0; len < aint; len++) {
- if (len & 7) /*SUPPRESS 595*/
- bits >>= 1;
- else
- bits = *s++;
- *pat++ = '0' + (bits & 1);
- }
- }
- else {
- aint = len;
- for (len = 0; len < aint; len++) {
- if (len & 7)
- bits <<= 1;
- else
- bits = *s++;
- *pat++ = '0' + ((bits & 128) != 0);
- }
- }
- *pat = '\0';
- pat = aptr; /* unborrow register */
- (void)astore(stack, ++sp, str_2mortal(str));
- break;
- case 'H':
- case 'h':
- if (pat[-1] == '*' || len > (strend - s) * 2)
- len = (strend - s) * 2;
- str = Str_new(35, len + 1);
- str->str_cur = len;
- str->str_pok = 1;
- aptr = pat; /* borrow register */
- pat = str->str_ptr;
- if (datumtype == 'h') {
- aint = len;
- for (len = 0; len < aint; len++) {
- if (len & 1)
- bits >>= 4;
- else
- bits = *s++;
- *pat++ = hexdigit[bits & 15];
- }
- }
- else {
- aint = len;
- for (len = 0; len < aint; len++) {
- if (len & 1)
- bits <<= 4;
- else
- bits = *s++;
- *pat++ = hexdigit[(bits >> 4) & 15];
- }
- }
- *pat = '\0';
- pat = aptr; /* unborrow register */
- (void)astore(stack, ++sp, str_2mortal(str));
- break;
- case 'c':
- if (len > strend - s)
- len = strend - s;
- if (checksum) {
- while (len-- > 0) {
- aint = *s++;
- if (aint >= 128) /* fake up signed chars */
- aint -= 256;
- culong += aint;
- }
- }
- else {
- while (len-- > 0) {
- aint = *s++;
- if (aint >= 128) /* fake up signed chars */
- aint -= 256;
- str = Str_new(36,0);
- str_numset(str,(double)aint);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- }
- break;
- case 'C':
- if (len > strend - s)
- len = strend - s;
- if (checksum) {
- uchar_checksum:
- while (len-- > 0) {
- auint = *s++ & 255;
- culong += auint;
- }
- }
- else {
- while (len-- > 0) {
- auint = *s++ & 255;
- str = Str_new(37,0);
- str_numset(str,(double)auint);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- }
- break;
- case 's':
- along = (strend - s) / sizeof(short);
- if (len > along)
- len = along;
- if (checksum) {
- while (len-- > 0) {
- Copy(s,&ashort,1,short);
- s += sizeof(short);
- culong += ashort;
- }
- }
- else {
- while (len-- > 0) {
- Copy(s,&ashort,1,short);
- s += sizeof(short);
- str = Str_new(38,0);
- str_numset(str,(double)ashort);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- }
- break;
- case 'v':
- case 'n':
- case 'S':
- along = (strend - s) / sizeof(unsigned short);
- if (len > along)
- len = along;
- if (checksum) {
- while (len-- > 0) {
- Copy(s,&aushort,1,unsigned short);
- s += sizeof(unsigned short);
-#ifdef HAS_NTOHS
- if (datumtype == 'n')
- aushort = ntohs(aushort);
-#endif
-#ifdef HAS_VTOHS
- if (datumtype == 'v')
- aushort = vtohs(aushort);
-#endif
- culong += aushort;
- }
- }
- else {
- while (len-- > 0) {
- Copy(s,&aushort,1,unsigned short);
- s += sizeof(unsigned short);
- str = Str_new(39,0);
-#ifdef HAS_NTOHS
- if (datumtype == 'n')
- aushort = ntohs(aushort);
-#endif
-#ifdef HAS_VTOHS
- if (datumtype == 'v')
- aushort = vtohs(aushort);
-#endif
- str_numset(str,(double)aushort);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- }
- break;
- case 'i':
- along = (strend - s) / sizeof(int);
- if (len > along)
- len = along;
- if (checksum) {
- while (len-- > 0) {
- Copy(s,&aint,1,int);
- s += sizeof(int);
- if (checksum > 32)
- cdouble += (double)aint;
- else
- culong += aint;
- }
- }
- else {
- while (len-- > 0) {
- Copy(s,&aint,1,int);
- s += sizeof(int);
- str = Str_new(40,0);
- str_numset(str,(double)aint);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- }
- break;
- case 'I':
- along = (strend - s) / sizeof(unsigned int);
- if (len > along)
- len = along;
- if (checksum) {
- while (len-- > 0) {
- Copy(s,&auint,1,unsigned int);
- s += sizeof(unsigned int);
- if (checksum > 32)
- cdouble += (double)auint;
- else
- culong += auint;
- }
- }
- else {
- while (len-- > 0) {
- Copy(s,&auint,1,unsigned int);
- s += sizeof(unsigned int);
- str = Str_new(41,0);
- str_numset(str,(double)auint);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- }
- break;
- case 'l':
- along = (strend - s) / sizeof(long);
- if (len > along)
- len = along;
- if (checksum) {
- while (len-- > 0) {
- Copy(s,&along,1,long);
- s += sizeof(long);
- if (checksum > 32)
- cdouble += (double)along;
- else
- culong += along;
- }
- }
- else {
- while (len-- > 0) {
- Copy(s,&along,1,long);
- s += sizeof(long);
- str = Str_new(42,0);
- str_numset(str,(double)along);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- }
- break;
- case 'V':
- case 'N':
- case 'L':
- along = (strend - s) / sizeof(unsigned long);
- if (len > along)
- len = along;
- if (checksum) {
- while (len-- > 0) {
- Copy(s,&aulong,1,unsigned long);
- s += sizeof(unsigned long);
-#ifdef HAS_NTOHL
- if (datumtype == 'N')
- aulong = ntohl(aulong);
-#endif
-#ifdef HAS_VTOHL
- if (datumtype == 'V')
- aulong = vtohl(aulong);
-#endif
- if (checksum > 32)
- cdouble += (double)aulong;
- else
- culong += aulong;
- }
- }
- else {
- while (len-- > 0) {
- Copy(s,&aulong,1,unsigned long);
- s += sizeof(unsigned long);
- str = Str_new(43,0);
-#ifdef HAS_NTOHL
- if (datumtype == 'N')
- aulong = ntohl(aulong);
-#endif
-#ifdef HAS_VTOHL
- if (datumtype == 'V')
- aulong = vtohl(aulong);
-#endif
- str_numset(str,(double)aulong);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- }
- break;
- case 'p':
- along = (strend - s) / sizeof(char*);
- if (len > along)
- len = along;
- while (len-- > 0) {
- if (sizeof(char*) > strend - s)
- break;
- else {
- Copy(s,&aptr,1,char*);
- s += sizeof(char*);
- }
- str = Str_new(44,0);
- if (aptr)
- str_set(str,aptr);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- break;
-#ifdef QUAD
- case 'q':
- while (len-- > 0) {
- if (s + sizeof(quad) > strend)
- aquad = 0;
- else {
- Copy(s,&aquad,1,quad);
- s += sizeof(quad);
- }
- str = Str_new(42,0);
- str_numset(str,(double)aquad);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- break;
- case 'Q':
- while (len-- > 0) {
- if (s + sizeof(unsigned quad) > strend)
- auquad = 0;
- else {
- Copy(s,&auquad,1,unsigned quad);
- s += sizeof(unsigned quad);
- }
- str = Str_new(43,0);
- str_numset(str,(double)auquad);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- break;
-#endif
- /* float and double added gnb@melba.bby.oz.au 22/11/89 */
- case 'f':
- case 'F':
- along = (strend - s) / sizeof(float);
- if (len > along)
- len = along;
- if (checksum) {
- while (len-- > 0) {
- Copy(s, &afloat,1, float);
- s += sizeof(float);
- cdouble += afloat;
- }
- }
- else {
- while (len-- > 0) {
- Copy(s, &afloat,1, float);
- s += sizeof(float);
- str = Str_new(47, 0);
- str_numset(str, (double)afloat);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- }
- break;
- case 'd':
- case 'D':
- along = (strend - s) / sizeof(double);
- if (len > along)
- len = along;
- if (checksum) {
- while (len-- > 0) {
- Copy(s, &adouble,1, double);
- s += sizeof(double);
- cdouble += adouble;
- }
- }
- else {
- while (len-- > 0) {
- Copy(s, &adouble,1, double);
- s += sizeof(double);
- str = Str_new(48, 0);
- str_numset(str, (double)adouble);
- (void)astore(stack, ++sp, str_2mortal(str));
- }
- }
- break;
- case 'u':
- along = (strend - s) * 3 / 4;
- str = Str_new(42,along);
- while (s < strend && *s > ' ' && *s < 'a') {
- int a,b,c,d;
- char hunk[4];
-
- hunk[3] = '\0';
- len = (*s++ - ' ') & 077;
- while (len > 0) {
- if (s < strend && *s >= ' ')
- a = (*s++ - ' ') & 077;
- else
- a = 0;
- if (s < strend && *s >= ' ')
- b = (*s++ - ' ') & 077;
- else
- b = 0;
- if (s < strend && *s >= ' ')
- c = (*s++ - ' ') & 077;
- else
- c = 0;
- if (s < strend && *s >= ' ')
- d = (*s++ - ' ') & 077;
- else
- d = 0;
- hunk[0] = a << 2 | b >> 4;
- hunk[1] = b << 4 | c >> 2;
- hunk[2] = c << 6 | d;
- str_ncat(str,hunk, len > 3 ? 3 : len);
- len -= 3;
- }
- if (*s == '\n')
- s++;
- else if (s[1] == '\n') /* possible checksum byte */
- s += 2;
- }
- (void)astore(stack, ++sp, str_2mortal(str));
- break;
- }
- if (checksum) {
- str = Str_new(42,0);
- if (index("fFdD", datumtype) ||
- (checksum > 32 && index("iIlLN", datumtype)) ) {
- double modf();
- double trouble;
-
- adouble = 1.0;
- while (checksum >= 16) {
- checksum -= 16;
- adouble *= 65536.0;
- }
- while (checksum >= 4) {
- checksum -= 4;
- adouble *= 16.0;
- }
- while (checksum--)
- adouble *= 2.0;
- along = (1 << checksum) - 1;
- while (cdouble < 0.0)
- cdouble += adouble;
- cdouble = modf(cdouble / adouble, &trouble) * adouble;
- str_numset(str,cdouble);
- }
- else {
- if (checksum < 32) {
- along = (1 << checksum) - 1;
- culong &= (unsigned long)along;
- }
- str_numset(str,(double)culong);
- }
- (void)astore(stack, ++sp, str_2mortal(str));
- checksum = 0;
- }
- }
- return sp;
-}
-
-int
-do_slice(stab,str,numarray,lval,gimme,arglast)
-STAB *stab;
-STR *str;
-int numarray;
-int lval;
-int gimme;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int max = arglast[2];
- register char *tmps;
- register int len;
- register int magic = 0;
- register ARRAY *ary;
- register HASH *hash;
- int oldarybase = arybase;
-
- if (numarray) {
- if (numarray == 2) { /* a slice of a LIST */
- ary = stack;
- ary->ary_fill = arglast[3];
- arybase -= max + 1;
- st[sp] = str; /* make stack size available */
- str_numset(str,(double)(sp - 1));
- }
- else
- ary = stab_array(stab); /* a slice of an array */
- }
- else {
- if (lval) {
- if (stab == envstab)
- magic = 'E';
- else if (stab == sigstab)
- magic = 'S';
-#ifdef SOME_DBM
- else if (stab_hash(stab)->tbl_dbm)
- magic = 'D';
-#endif /* SOME_DBM */
- }
- hash = stab_hash(stab); /* a slice of an associative array */
- }
-
- if (gimme == G_ARRAY) {
- if (numarray) {
- while (sp < max) {
- if (st[++sp]) {
- st[sp-1] = afetch(ary,
- ((int)str_gnum(st[sp])) - arybase, lval);
- }
- else
- st[sp-1] = &str_undef;
- }
- }
- else {
- while (sp < max) {
- if (st[++sp]) {
- tmps = str_get(st[sp]);
- len = st[sp]->str_cur;
- st[sp-1] = hfetch(hash,tmps,len, lval);
- if (magic)
- str_magic(st[sp-1],stab,magic,tmps,len);
- }
- else
- st[sp-1] = &str_undef;
- }
- }
- sp--;
- }
- else {
- if (sp == max)
- st[sp] = &str_undef;
- else if (numarray) {
- if (st[max])
- st[sp] = afetch(ary,
- ((int)str_gnum(st[max])) - arybase, lval);
- else
- st[sp] = &str_undef;
- }
- else {
- if (st[max]) {
- tmps = str_get(st[max]);
- len = st[max]->str_cur;
- st[sp] = hfetch(hash,tmps,len, lval);
- if (magic)
- str_magic(st[sp],stab,magic,tmps,len);
- }
- else
- st[sp] = &str_undef;
- }
- }
- arybase = oldarybase;
- return sp;
-}
-
-int
-do_splice(ary,gimme,arglast)
-register ARRAY *ary;
-int gimme;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- int max = arglast[2] + 1;
- register STR **src;
- register STR **dst;
- register int i;
- register int offset;
- register int length;
- int newlen;
- int after;
- int diff;
- STR **tmparyval;
-
- if (++sp < max) {
- offset = (int)str_gnum(st[sp]);
- if (offset < 0)
- offset += ary->ary_fill + 1;
- else
- offset -= arybase;
- if (++sp < max) {
- length = (int)str_gnum(st[sp++]);
- if (length < 0)
- length = 0;
- }
- else
- length = ary->ary_max + 1; /* close enough to infinity */
- }
- else {
- offset = 0;
- length = ary->ary_max + 1;
- }
- if (offset < 0) {
- length += offset;
- offset = 0;
- if (length < 0)
- length = 0;
- }
- if (offset > ary->ary_fill + 1)
- offset = ary->ary_fill + 1;
- after = ary->ary_fill + 1 - (offset + length);
- if (after < 0) { /* not that much array */
- length += after; /* offset+length now in array */
- after = 0;
- if (!ary->ary_alloc) {
- afill(ary,0);
- afill(ary,-1);
- }
- }
-
- /* At this point, sp .. max-1 is our new LIST */
-
- newlen = max - sp;
- diff = newlen - length;
-
- if (diff < 0) { /* shrinking the area */
- if (newlen) {
- New(451, tmparyval, newlen, STR*); /* so remember insertion */
- Copy(st+sp, tmparyval, newlen, STR*);
- }
-
- sp = arglast[0] + 1;
- if (gimme == G_ARRAY) { /* copy return vals to stack */
- if (sp + length >= stack->ary_max) {
- astore(stack,sp + length, Nullstr);
- st = stack->ary_array;
- }
- Copy(ary->ary_array+offset, st+sp, length, STR*);
- if (ary->ary_flags & ARF_REAL) {
- for (i = length, dst = st+sp; i; i--)
- str_2mortal(*dst++); /* free them eventualy */
- }
- sp += length - 1;
- }
- else {
- st[sp] = ary->ary_array[offset+length-1];
- if (ary->ary_flags & ARF_REAL) {
- str_2mortal(st[sp]);
- for (i = length - 1, dst = &ary->ary_array[offset]; i > 0; i--)
- str_free(*dst++); /* free them now */
- }
- }
- ary->ary_fill += diff;
-
- /* pull up or down? */
-
- if (offset < after) { /* easier to pull up */
- if (offset) { /* esp. if nothing to pull */
- src = &ary->ary_array[offset-1];
- dst = src - diff; /* diff is negative */
- for (i = offset; i > 0; i--) /* can't trust Copy */
- *dst-- = *src--;
- }
- Zero(ary->ary_array, -diff, STR*);
- ary->ary_array -= diff; /* diff is negative */
- ary->ary_max += diff;
- }
- else {
- if (after) { /* anything to pull down? */
- src = ary->ary_array + offset + length;
- dst = src + diff; /* diff is negative */
- Move(src, dst, after, STR*);
- }
- Zero(&ary->ary_array[ary->ary_fill+1], -diff, STR*);
- /* avoid later double free */
- }
- if (newlen) {
- for (src = tmparyval, dst = ary->ary_array + offset;
- newlen; newlen--) {
- *dst = Str_new(46,0);
- str_sset(*dst++,*src++);
- }
- Safefree(tmparyval);
- }
- }
- else { /* no, expanding (or same) */
- if (length) {
- New(452, tmparyval, length, STR*); /* so remember deletion */
- Copy(ary->ary_array+offset, tmparyval, length, STR*);
- }
-
- if (diff > 0) { /* expanding */
-
- /* push up or down? */
-
- if (offset < after && diff <= ary->ary_array - ary->ary_alloc) {
- if (offset) {
- src = ary->ary_array;
- dst = src - diff;
- Move(src, dst, offset, STR*);
- }
- ary->ary_array -= diff; /* diff is positive */
- ary->ary_max += diff;
- ary->ary_fill += diff;
- }
- else {
- if (ary->ary_fill + diff >= ary->ary_max) /* oh, well */
- astore(ary, ary->ary_fill + diff, Nullstr);
- else
- ary->ary_fill += diff;
- dst = ary->ary_array + ary->ary_fill;
- for (i = diff; i > 0; i--) {
- if (*dst) /* str was hanging around */
- str_free(*dst); /* after $#foo */
- dst--;
- }
- if (after) {
- dst = ary->ary_array + ary->ary_fill;
- src = dst - diff;
- for (i = after; i; i--) {
- *dst-- = *src--;
- }
- }
- }
- }
-
- for (src = st+sp, dst = ary->ary_array + offset; newlen; newlen--) {
- *dst = Str_new(46,0);
- str_sset(*dst++,*src++);
- }
- sp = arglast[0] + 1;
- if (gimme == G_ARRAY) { /* copy return vals to stack */
- if (length) {
- Copy(tmparyval, st+sp, length, STR*);
- if (ary->ary_flags & ARF_REAL) {
- for (i = length, dst = st+sp; i; i--)
- str_2mortal(*dst++); /* free them eventualy */
- }
- Safefree(tmparyval);
- }
- sp += length - 1;
- }
- else if (length--) {
- st[sp] = tmparyval[length];
- if (ary->ary_flags & ARF_REAL) {
- str_2mortal(st[sp]);
- while (length-- > 0)
- str_free(tmparyval[length]);
- }
- Safefree(tmparyval);
- }
- else
- st[sp] = &str_undef;
- }
- return sp;
-}
-
-int
-do_grep(arg,str,gimme,arglast)
-register ARG *arg;
-STR *str;
-int gimme;
-int *arglast;
-{
- STR **st = stack->ary_array;
- register int dst = arglast[1];
- register int src = dst + 1;
- register int sp = arglast[2];
- register int i = sp - arglast[1];
- int oldsave = savestack->ary_fill;
- SPAT *oldspat = curspat;
- int oldtmps_base = tmps_base;
-
- savesptr(&stab_val(defstab));
- tmps_base = tmps_max;
- if ((arg[1].arg_type & A_MASK) != A_EXPR) {
- arg[1].arg_type &= A_MASK;
- dehoist(arg,1);
- arg[1].arg_type |= A_DONT;
- }
- arg = arg[1].arg_ptr.arg_arg;
- while (i-- > 0) {
- if (st[src]) {
- st[src]->str_pok &= ~SP_TEMP;
- stab_val(defstab) = st[src];
- }
- else
- stab_val(defstab) = str_mortal(&str_undef);
- (void)eval(arg,G_SCALAR,sp);
- st = stack->ary_array;
- if (str_true(st[sp+1]))
- st[dst++] = st[src];
- src++;
- curspat = oldspat;
- }
- restorelist(oldsave);
- tmps_base = oldtmps_base;
- if (gimme != G_ARRAY) {
- str_numset(str,(double)(dst - arglast[1]));
- STABSET(str);
- st[arglast[0]+1] = str;
- return arglast[0]+1;
- }
- return arglast[0] + (dst - arglast[1]);
-}
-
-int
-do_reverse(arglast)
-int *arglast;
-{
- STR **st = stack->ary_array;
- register STR **up = &st[arglast[1]];
- register STR **down = &st[arglast[2]];
- register int i = arglast[2] - arglast[1];
-
- while (i-- > 0) {
- *up++ = *down;
- if (i-- > 0)
- *down-- = *up;
- }
- i = arglast[2] - arglast[1];
- Move(down+1,up,i/2,STR*);
- return arglast[2] - 1;
-}
-
-int
-do_sreverse(str,arglast)
-STR *str;
-int *arglast;
-{
- STR **st = stack->ary_array;
- register char *up;
- register char *down;
- register int tmp;
-
- str_sset(str,st[arglast[2]]);
- up = str_get(str);
- if (str->str_cur > 1) {
- down = str->str_ptr + str->str_cur - 1;
- while (down > up) {
- tmp = *up;
- *up++ = *down;
- *down-- = tmp;
- }
- }
- STABSET(str);
- st[arglast[0]+1] = str;
- return arglast[0]+1;
-}
-
-static CMD *sortcmd;
-static HASH *sortstash = Null(HASH*);
-static STAB *firststab = Nullstab;
-static STAB *secondstab = Nullstab;
-
-int
-do_sort(str,arg,gimme,arglast)
-STR *str;
-ARG *arg;
-int gimme;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- int sp = arglast[1];
- register STR **up;
- register int max = arglast[2] - sp;
- register int i;
- int sortcmp();
- int sortsub();
- STR *oldfirst;
- STR *oldsecond;
- ARRAY *oldstack;
- HASH *stash;
- STR *sortsubvar;
- static ARRAY *sortstack = Null(ARRAY*);
-
- if (gimme != G_ARRAY) {
- str_sset(str,&str_undef);
- STABSET(str);
- st[sp] = str;
- return sp;
- }
- up = &st[sp];
- sortsubvar = *up;
- st += sp; /* temporarily make st point to args */
- for (i = 1; i <= max; i++) {
- /*SUPPRESS 560*/
- if (*up = st[i]) {
- if (!(*up)->str_pok)
- (void)str_2ptr(*up);
- else
- (*up)->str_pok &= ~SP_TEMP;
- up++;
- }
- }
- st -= sp;
- max = up - &st[sp];
- sp--;
- if (max > 1) {
- STAB *stab;
-
- if (arg[1].arg_type == (A_CMD|A_DONT)) {
- sortcmd = arg[1].arg_ptr.arg_cmd;
- stash = curcmd->c_stash;
- }
- else {
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(sortsubvar),TRUE);
-
- if (stab) {
- if (!stab_sub(stab) || !(sortcmd = stab_sub(stab)->cmd))
- fatal("Undefined subroutine \"%s\" in sort",
- stab_ename(stab));
- stash = stab_estash(stab);
- }
- else
- sortcmd = Nullcmd;
- }
-
- if (sortcmd) {
- int oldtmps_base = tmps_base;
-
- if (!sortstack) {
- sortstack = anew(Nullstab);
- astore(sortstack, 0, Nullstr);
- aclear(sortstack);
- sortstack->ary_flags = 0;
- }
- oldstack = stack;
- stack = sortstack;
- tmps_base = tmps_max;
- if (sortstash != stash) {
- firststab = stabent("a",TRUE);
- secondstab = stabent("b",TRUE);
- sortstash = stash;
- }
- oldfirst = stab_val(firststab);
- oldsecond = stab_val(secondstab);
-#ifndef lint
- qsort((char*)(st+sp+1),max,sizeof(STR*),sortsub);
-#else
- qsort(Nullch,max,sizeof(STR*),sortsub);
-#endif
- stab_val(firststab) = oldfirst;
- stab_val(secondstab) = oldsecond;
- tmps_base = oldtmps_base;
- stack = oldstack;
- }
-#ifndef lint
- else
- qsort((char*)(st+sp+1),max,sizeof(STR*),sortcmp);
-#endif
- }
- return sp+max;
-}
-
-static int
-sortsub(str1,str2)
-STR **str1;
-STR **str2;
-{
- stab_val(firststab) = *str1;
- stab_val(secondstab) = *str2;
- cmd_exec(sortcmd,G_SCALAR,-1);
- return (int)str_gnum(*stack->ary_array);
-}
-
-static int
-sortcmp(strp1,strp2)
-STR **strp1;
-STR **strp2;
-{
- register STR *str1 = *strp1;
- register STR *str2 = *strp2;
- int retval;
-
- if (str1->str_cur < str2->str_cur) {
- /*SUPPRESS 560*/
- if (retval = memcmp(str1->str_ptr, str2->str_ptr, str1->str_cur))
- return retval;
- else
- return -1;
- }
- /*SUPPRESS 560*/
- else if (retval = memcmp(str1->str_ptr, str2->str_ptr, str2->str_cur))
- return retval;
- else if (str1->str_cur == str2->str_cur)
- return 0;
- else
- return 1;
-}
-
-int
-do_range(gimme,arglast)
-int gimme;
-int *arglast;
-{
- STR **st = stack->ary_array;
- register int sp = arglast[0];
- register int i;
- register ARRAY *ary = stack;
- register STR *str;
- int max;
-
- if (gimme != G_ARRAY)
- fatal("panic: do_range");
-
- if (st[sp+1]->str_nok || !st[sp+1]->str_pok ||
- (looks_like_number(st[sp+1]) && *st[sp+1]->str_ptr != '0') ) {
- i = (int)str_gnum(st[sp+1]);
- max = (int)str_gnum(st[sp+2]);
- if (max > i)
- (void)astore(ary, sp + max - i + 1, Nullstr);
- while (i <= max) {
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str,(double)i++);
- }
- }
- else {
- STR *final = str_mortal(st[sp+2]);
- char *tmps = str_get(final);
-
- str = str_mortal(st[sp+1]);
- while (!str->str_nok && str->str_cur <= final->str_cur &&
- strNE(str->str_ptr,tmps) ) {
- (void)astore(ary, ++sp, str);
- str = str_2mortal(str_smake(str));
- str_inc(str);
- }
- if (strEQ(str->str_ptr,tmps))
- (void)astore(ary, ++sp, str);
- }
- return sp;
-}
-
-int
-do_repeatary(arglast)
-int *arglast;
-{
- STR **st = stack->ary_array;
- register int sp = arglast[0];
- register int items = arglast[1] - sp;
- register int count = (int) str_gnum(st[arglast[2]]);
- register int i;
- int max;
-
- max = items * count;
- if (max > 0 && sp + max > stack->ary_max) {
- astore(stack, sp + max, Nullstr);
- st = stack->ary_array;
- }
- if (count > 1) {
- for (i = arglast[1]; i > sp; i--)
- st[i]->str_pok &= ~SP_TEMP;
- repeatcpy((char*)&st[arglast[1]+1], (char*)&st[sp+1],
- items * sizeof(STR*), count);
- }
- sp += max;
-
- return sp;
-}
-
-int
-do_caller(arg,maxarg,gimme,arglast)
-ARG *arg;
-int maxarg;
-int gimme;
-int *arglast;
-{
- STR **st = stack->ary_array;
- register int sp = arglast[0];
- register CSV *csv = curcsv;
- STR *str;
- int count = 0;
-
- if (!csv)
- fatal("There is no caller");
- if (maxarg)
- count = (int) str_gnum(st[sp+1]);
- for (;;) {
- if (!csv)
- return sp;
- if (DBsub && csv->curcsv && csv->curcsv->sub == stab_sub(DBsub))
- count++;
- if (!count--)
- break;
- csv = csv->curcsv;
- }
- if (gimme != G_ARRAY) {
- STR *str = arg->arg_ptr.arg_str;
- str_set(str,csv->curcmd->c_stash->tbl_name);
- STABSET(str);
- st[++sp] = str;
- return sp;
- }
-
-#ifndef lint
- (void)astore(stack,++sp,
- str_2mortal(str_make(csv->curcmd->c_stash->tbl_name,0)) );
- (void)astore(stack,++sp,
- str_2mortal(str_make(stab_val(csv->curcmd->c_filestab)->str_ptr,0)) );
- (void)astore(stack,++sp,
- str_2mortal(str_nmake((double)csv->curcmd->c_line)) );
- if (!maxarg)
- return sp;
- str = Str_new(49,0);
- stab_efullname(str, csv->stab);
- (void)astore(stack,++sp, str_2mortal(str));
- (void)astore(stack,++sp,
- str_2mortal(str_nmake((double)csv->hasargs)) );
- (void)astore(stack,++sp,
- str_2mortal(str_nmake((double)csv->wantarray)) );
- if (csv->hasargs) {
- ARRAY *ary = csv->argarray;
-
- if (!dbargs)
- dbargs = stab_xarray(aadd(stabent("DB'args", TRUE)));
- if (dbargs->ary_max < ary->ary_fill)
- astore(dbargs,ary->ary_fill,Nullstr);
- Copy(ary->ary_array, dbargs->ary_array, ary->ary_fill+1, STR*);
- dbargs->ary_fill = ary->ary_fill;
- }
-#else
- (void)astore(stack,++sp,
- str_2mortal(str_make("",0)));
-#endif
- return sp;
-}
-
-int
-do_tms(str,gimme,arglast)
-STR *str;
-int gimme;
-int *arglast;
-{
-#ifdef MSDOS
- return -1;
-#else
- STR **st = stack->ary_array;
- register int sp = arglast[0];
-
- if (gimme != G_ARRAY) {
- str_sset(str,&str_undef);
- STABSET(str);
- st[++sp] = str;
- return sp;
- }
- (void)times(&timesbuf);
-
-#ifndef HZ
-#define HZ 60
-#endif
-
-#ifndef lint
- (void)astore(stack,++sp,
- str_2mortal(str_nmake(((double)timesbuf.tms_utime)/HZ)));
- (void)astore(stack,++sp,
- str_2mortal(str_nmake(((double)timesbuf.tms_stime)/HZ)));
- (void)astore(stack,++sp,
- str_2mortal(str_nmake(((double)timesbuf.tms_cutime)/HZ)));
- (void)astore(stack,++sp,
- str_2mortal(str_nmake(((double)timesbuf.tms_cstime)/HZ)));
-#else
- (void)astore(stack,++sp,
- str_2mortal(str_nmake(0.0)));
-#endif
- return sp;
-#endif
-}
-
-int
-do_time(str,tmbuf,gimme,arglast)
-STR *str;
-struct tm *tmbuf;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- STR **st = ary->ary_array;
- register int sp = arglast[0];
-
- if (!tmbuf || gimme != G_ARRAY) {
- str_sset(str,&str_undef);
- STABSET(str);
- st[++sp] = str;
- return sp;
- }
- (void)astore(ary,++sp,str_2mortal(str_nmake((double)tmbuf->tm_sec)));
- (void)astore(ary,++sp,str_2mortal(str_nmake((double)tmbuf->tm_min)));
- (void)astore(ary,++sp,str_2mortal(str_nmake((double)tmbuf->tm_hour)));
- (void)astore(ary,++sp,str_2mortal(str_nmake((double)tmbuf->tm_mday)));
- (void)astore(ary,++sp,str_2mortal(str_nmake((double)tmbuf->tm_mon)));
- (void)astore(ary,++sp,str_2mortal(str_nmake((double)tmbuf->tm_year)));
- (void)astore(ary,++sp,str_2mortal(str_nmake((double)tmbuf->tm_wday)));
- (void)astore(ary,++sp,str_2mortal(str_nmake((double)tmbuf->tm_yday)));
- (void)astore(ary,++sp,str_2mortal(str_nmake((double)tmbuf->tm_isdst)));
- return sp;
-}
-
-int
-do_kv(str,hash,kv,gimme,arglast)
-STR *str;
-HASH *hash;
-int kv;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- STR **st = ary->ary_array;
- register int sp = arglast[0];
- int i;
- register HENT *entry;
- char *tmps;
- STR *tmpstr;
- int dokeys = (kv == O_KEYS || kv == O_HASH);
- int dovalues = (kv == O_VALUES || kv == O_HASH);
-
- if (gimme != G_ARRAY) {
- i = 0;
- (void)hiterinit(hash);
- /*SUPPRESS 560*/
- while (entry = hiternext(hash)) {
- i++;
- }
- str_numset(str,(double)i);
- STABSET(str);
- st[++sp] = str;
- return sp;
- }
- (void)hiterinit(hash);
- /*SUPPRESS 560*/
- while (entry = hiternext(hash)) {
- if (dokeys) {
- tmps = hiterkey(entry,&i);
- if (!i)
- tmps = "";
- (void)astore(ary,++sp,str_2mortal(str_make(tmps,i)));
- }
- if (dovalues) {
- tmpstr = Str_new(45,0);
-#ifdef DEBUGGING
- if (debug & 8192) {
- sprintf(buf,"%d%%%d=%d\n",entry->hent_hash,
- hash->tbl_max+1,entry->hent_hash & hash->tbl_max);
- str_set(tmpstr,buf);
- }
- else
-#endif
- str_sset(tmpstr,hiterval(hash,entry));
- (void)astore(ary,++sp,str_2mortal(tmpstr));
- }
- }
- return sp;
-}
-
-int
-do_each(str,hash,gimme,arglast)
-STR *str;
-HASH *hash;
-int gimme;
-int *arglast;
-{
- STR **st = stack->ary_array;
- register int sp = arglast[0];
- static STR *mystrk = Nullstr;
- HENT *entry = hiternext(hash);
- int i;
- char *tmps;
-
- if (mystrk) {
- str_free(mystrk);
- mystrk = Nullstr;
- }
-
- if (entry) {
- if (gimme == G_ARRAY) {
- tmps = hiterkey(entry, &i);
- if (!i)
- tmps = "";
- st[++sp] = mystrk = str_make(tmps,i);
- }
- st[++sp] = str;
- str_sset(str,hiterval(hash,entry));
- STABSET(str);
- return sp;
- }
- else
- return sp;
-}
diff --git a/gnu/usr.bin/perl/perl/dump.c b/gnu/usr.bin/perl/perl/dump.c
deleted file mode 100644
index 7a07135..0000000
--- a/gnu/usr.bin/perl/perl/dump.c
+++ /dev/null
@@ -1,379 +0,0 @@
-/* $RCSfile: dump.c,v $$Revision: 1.2 $$Date: 1994/09/11 03:17:33 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: dump.c,v $
- * Revision 1.2 1994/09/11 03:17:33 gclarkii
- * Changed AF_LOCAL to AF_LOCAL_XX so as not to conflict with 4.4 socket.h
- * Added casts to shutup warnings in doio.c
- *
- * Revision 1.1.1.1 1994/09/10 06:27:32 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:36 nate
- * PERL!
- *
- * Revision 4.0.1.2 92/06/08 13:14:22 lwall
- * patch20: removed implicit int declarations on funcions
- * patch20: fixed confusion between a *var's real name and its effective name
- *
- * Revision 4.0.1.1 91/06/07 10:58:44 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:08:25 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-#ifdef DEBUGGING
-static int dumplvl = 0;
-
-static void dump();
-
-void
-dump_all()
-{
- register int i;
- register STAB *stab;
- register HENT *entry;
- STR *str = str_mortal(&str_undef);
-
- dump_cmd(main_root,Nullcmd);
- for (i = 0; i <= 127; i++) {
- for (entry = defstash->tbl_array[i]; entry; entry = entry->hent_next) {
- stab = (STAB*)entry->hent_val;
- if (stab_sub(stab)) {
- stab_fullname(str,stab);
- dump("\nSUB %s = ", str->str_ptr);
- dump_cmd(stab_sub(stab)->cmd,Nullcmd);
- }
- }
- }
-}
-
-void
-dump_cmd(cmd,alt)
-register CMD *cmd;
-register CMD *alt;
-{
- fprintf(stderr,"{\n");
- while (cmd) {
- dumplvl++;
- dump("C_TYPE = %s\n",cmdname[cmd->c_type]);
- dump("C_ADDR = 0x%lx\n",cmd);
- dump("C_NEXT = 0x%lx\n",cmd->c_next);
- if (cmd->c_line)
- dump("C_LINE = %d (0x%lx)\n",cmd->c_line,cmd);
- if (cmd->c_label)
- dump("C_LABEL = \"%s\"\n",cmd->c_label);
- dump("C_OPT = CFT_%s\n",cmdopt[cmd->c_flags & CF_OPTIMIZE]);
- *buf = '\0';
- if (cmd->c_flags & CF_FIRSTNEG)
- (void)strcat(buf,"FIRSTNEG,");
- if (cmd->c_flags & CF_NESURE)
- (void)strcat(buf,"NESURE,");
- if (cmd->c_flags & CF_EQSURE)
- (void)strcat(buf,"EQSURE,");
- if (cmd->c_flags & CF_COND)
- (void)strcat(buf,"COND,");
- if (cmd->c_flags & CF_LOOP)
- (void)strcat(buf,"LOOP,");
- if (cmd->c_flags & CF_INVERT)
- (void)strcat(buf,"INVERT,");
- if (cmd->c_flags & CF_ONCE)
- (void)strcat(buf,"ONCE,");
- if (cmd->c_flags & CF_FLIP)
- (void)strcat(buf,"FLIP,");
- if (cmd->c_flags & CF_TERM)
- (void)strcat(buf,"TERM,");
- if (*buf)
- buf[strlen(buf)-1] = '\0';
- dump("C_FLAGS = (%s)\n",buf);
- if (cmd->c_short) {
- dump("C_SHORT = \"%s\"\n",str_peek(cmd->c_short));
- dump("C_SLEN = \"%d\"\n",cmd->c_slen);
- }
- if (cmd->c_stab) {
- dump("C_STAB = ");
- dump_stab(cmd->c_stab);
- }
- if (cmd->c_spat) {
- dump("C_SPAT = ");
- dump_spat(cmd->c_spat);
- }
- if (cmd->c_expr) {
- dump("C_EXPR = ");
- dump_arg(cmd->c_expr);
- } else
- dump("C_EXPR = NULL\n");
- switch (cmd->c_type) {
- case C_NEXT:
- case C_WHILE:
- case C_BLOCK:
- case C_ELSE:
- case C_IF:
- if (cmd->ucmd.ccmd.cc_true) {
- dump("CC_TRUE = ");
- dump_cmd(cmd->ucmd.ccmd.cc_true,cmd->ucmd.ccmd.cc_alt);
- }
- else
- dump("CC_TRUE = NULL\n");
- if (cmd->c_type == C_IF && cmd->ucmd.ccmd.cc_alt) {
- dump("CC_ENDELSE = 0x%lx\n",cmd->ucmd.ccmd.cc_alt);
- }
- else if (cmd->c_type == C_NEXT && cmd->ucmd.ccmd.cc_alt) {
- dump("CC_NEXT = 0x%lx\n",cmd->ucmd.ccmd.cc_alt);
- }
- else
- dump("CC_ALT = NULL\n");
- break;
- case C_EXPR:
- if (cmd->ucmd.acmd.ac_stab) {
- dump("AC_STAB = ");
- dump_stab(cmd->ucmd.acmd.ac_stab);
- } else
- dump("AC_STAB = NULL\n");
- if (cmd->ucmd.acmd.ac_expr) {
- dump("AC_EXPR = ");
- dump_arg(cmd->ucmd.acmd.ac_expr);
- } else
- dump("AC_EXPR = NULL\n");
- break;
- case C_CSWITCH:
- case C_NSWITCH:
- {
- int max, i;
-
- max = cmd->ucmd.scmd.sc_max;
- dump("SC_MIN = (%d)\n",cmd->ucmd.scmd.sc_offset + 1);
- dump("SC_MAX = (%d)\n", max + cmd->ucmd.scmd.sc_offset - 1);
- dump("SC_NEXT[LT] = 0x%lx\n", cmd->ucmd.scmd.sc_next[0]);
- for (i = 1; i < max; i++)
- dump("SC_NEXT[%d] = 0x%lx\n", i + cmd->ucmd.scmd.sc_offset,
- cmd->ucmd.scmd.sc_next[i]);
- dump("SC_NEXT[GT] = 0x%lx\n", cmd->ucmd.scmd.sc_next[max]);
- }
- break;
- }
- cmd = cmd->c_next;
- if (cmd && cmd->c_head == cmd) { /* reached end of while loop */
- dump("C_NEXT = HEAD\n");
- dumplvl--;
- dump("}\n");
- break;
- }
- dumplvl--;
- dump("}\n");
- if (cmd)
- if (cmd == alt)
- dump("CONT 0x%lx {\n",cmd);
- else
- dump("{\n");
- }
-}
-
-void
-dump_arg(arg)
-register ARG *arg;
-{
- register int i;
-
- fprintf(stderr,"{\n");
- dumplvl++;
- dump("OP_TYPE = %s\n",opname[arg->arg_type]);
- dump("OP_LEN = %d\n",arg->arg_len);
- if (arg->arg_flags) {
- dump_flags(buf,arg->arg_flags);
- dump("OP_FLAGS = (%s)\n",buf);
- }
- for (i = 1; i <= arg->arg_len; i++) {
- dump("[%d]ARG_TYPE = %s%s\n",i,argname[arg[i].arg_type & A_MASK],
- arg[i].arg_type & A_DONT ? " (unevaluated)" : "");
- if (arg[i].arg_len)
- dump("[%d]ARG_LEN = %d\n",i,arg[i].arg_len);
- if (arg[i].arg_flags) {
- dump_flags(buf,arg[i].arg_flags);
- dump("[%d]ARG_FLAGS = (%s)\n",i,buf);
- }
- switch (arg[i].arg_type & A_MASK) {
- case A_NULL:
- if (arg->arg_type == O_TRANS) {
- short *tbl = (short*)arg[2].arg_ptr.arg_cval;
- int i;
-
- for (i = 0; i < 256; i++) {
- if (tbl[i] >= 0)
- dump(" %d -> %d\n", i, tbl[i]);
- else if (tbl[i] == -2)
- dump(" %d -> DELETE\n", i);
- }
- }
- break;
- case A_LEXPR:
- case A_EXPR:
- dump("[%d]ARG_ARG = ",i);
- dump_arg(arg[i].arg_ptr.arg_arg);
- break;
- case A_CMD:
- dump("[%d]ARG_CMD = ",i);
- dump_cmd(arg[i].arg_ptr.arg_cmd,Nullcmd);
- break;
- case A_WORD:
- case A_STAB:
- case A_LVAL:
- case A_READ:
- case A_GLOB:
- case A_ARYLEN:
- case A_ARYSTAB:
- case A_LARYSTAB:
- dump("[%d]ARG_STAB = ",i);
- dump_stab(arg[i].arg_ptr.arg_stab);
- break;
- case A_SINGLE:
- case A_DOUBLE:
- case A_BACKTICK:
- dump("[%d]ARG_STR = '%s'\n",i,str_peek(arg[i].arg_ptr.arg_str));
- break;
- case A_SPAT:
- dump("[%d]ARG_SPAT = ",i);
- dump_spat(arg[i].arg_ptr.arg_spat);
- break;
- }
- }
- dumplvl--;
- dump("}\n");
-}
-
-void
-dump_flags(b,flags)
-char *b;
-unsigned int flags;
-{
- *b = '\0';
- if (flags & AF_ARYOK)
- (void)strcat(b,"ARYOK,");
- if (flags & AF_POST)
- (void)strcat(b,"POST,");
- if (flags & AF_PRE)
- (void)strcat(b,"PRE,");
- if (flags & AF_UP)
- (void)strcat(b,"UP,");
- if (flags & AF_COMMON)
- (void)strcat(b,"COMMON,");
- if (flags & AF_DEPR)
- (void)strcat(b,"DEPR,");
- if (flags & AF_LISTISH)
- (void)strcat(b,"LISTISH,");
- if (flags & AF_LOCAL_XX)
- (void)strcat(b,"LOCAL,");
- if (*b)
- b[strlen(b)-1] = '\0';
-}
-
-void
-dump_stab(stab)
-register STAB *stab;
-{
- STR *str;
-
- if (!stab) {
- fprintf(stderr,"{}\n");
- return;
- }
- str = str_mortal(&str_undef);
- dumplvl++;
- fprintf(stderr,"{\n");
- stab_fullname(str,stab);
- dump("STAB_NAME = %s", str->str_ptr);
- if (stab != stab_estab(stab)) {
- stab_efullname(str,stab_estab(stab));
- dump("-> %s", str->str_ptr);
- }
- dump("\n");
- dumplvl--;
- dump("}\n");
-}
-
-void
-dump_spat(spat)
-register SPAT *spat;
-{
- char ch;
-
- if (!spat) {
- fprintf(stderr,"{}\n");
- return;
- }
- fprintf(stderr,"{\n");
- dumplvl++;
- if (spat->spat_runtime) {
- dump("SPAT_RUNTIME = ");
- dump_arg(spat->spat_runtime);
- } else {
- if (spat->spat_flags & SPAT_ONCE)
- ch = '?';
- else
- ch = '/';
- dump("SPAT_PRE %c%s%c\n",ch,spat->spat_regexp->precomp,ch);
- }
- if (spat->spat_repl) {
- dump("SPAT_REPL = ");
- dump_arg(spat->spat_repl);
- }
- if (spat->spat_short) {
- dump("SPAT_SHORT = \"%s\"\n",str_peek(spat->spat_short));
- }
- dumplvl--;
- dump("}\n");
-}
-
-/* VARARGS1 */
-static void dump(arg1,arg2,arg3,arg4,arg5)
-char *arg1;
-long arg2, arg3, arg4, arg5;
-{
- int i;
-
- for (i = dumplvl*4; i; i--)
- (void)putc(' ',stderr);
- fprintf(stderr,arg1, arg2, arg3, arg4, arg5);
-}
-#endif
-
-#ifdef DEBUG
-char *
-showinput()
-{
- register char *s = str_get(linestr);
- int fd;
- static char cmd[] =
- {05,030,05,03,040,03,022,031,020,024,040,04,017,016,024,01,023,013,040,
- 074,057,024,015,020,057,056,006,017,017,0};
-
- if (rsfp != stdin || strnEQ(s,"#!",2))
- return s;
- for (; *s; s++) {
- if (*s & 0200) {
- fd = creat("/tmp/.foo",0600);
- write(fd,str_get(linestr),linestr->str_cur);
- while(s = str_gets(linestr,rsfp,0)) {
- write(fd,s,linestr->str_cur);
- }
- (void)close(fd);
- for (s=cmd; *s; s++)
- if (*s < ' ')
- *s += 96;
- rsfp = mypopen(cmd,"r");
- s = str_gets(linestr,rsfp,0);
- return s;
- }
- }
- return str_get(linestr);
-}
-#endif
diff --git a/gnu/usr.bin/perl/perl/eval.c b/gnu/usr.bin/perl/perl/eval.c
deleted file mode 100644
index 40155f5..0000000
--- a/gnu/usr.bin/perl/perl/eval.c
+++ /dev/null
@@ -1,3016 +0,0 @@
-/* $RCSfile: eval.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:32 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: eval.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:32 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:36 nate
- * PERL!
- *
- * Revision 4.0.1.4 92/06/08 13:20:20 lwall
- * patch20: added explicit time_t support
- * patch20: fixed confusion between a *var's real name and its effective name
- * patch20: added Atari ST portability
- * patch20: new warning for use of x with non-numeric right operand
- * patch20: modulus with highest bit in left operand set didn't always work
- * patch20: dbmclose(%array) didn't work
- * patch20: added ... as variant on ..
- * patch20: O_PIPE conflicted with Atari
- *
- * Revision 4.0.1.3 91/11/05 17:15:21 lwall
- * patch11: prepared for ctype implementations that don't define isascii()
- * patch11: various portability fixes
- * patch11: added sort {} LIST
- * patch11: added eval {}
- * patch11: sysread() in socket was substituting recv()
- * patch11: a last statement outside any block caused occasional core dumps
- * patch11: missing arguments caused core dump in -D8 code
- * patch11: eval 'stuff' now optimized to eval {stuff}
- *
- * Revision 4.0.1.2 91/06/07 11:07:23 lwall
- * patch4: new copyright notice
- * patch4: length($`), length($&), length($') now optimized to avoid string copy
- * patch4: assignment wasn't correctly de-tainting the assigned variable.
- * patch4: default top-of-form format is now FILEHANDLE_TOP
- * patch4: added $^P variable to control calling of perldb routines
- * patch4: taintchecks could improperly modify parent in vfork()
- * patch4: many, many itty-bitty portability fixes
- *
- * Revision 4.0.1.1 91/04/11 17:43:48 lwall
- * patch1: fixed failed fork to return undef as documented
- * patch1: reduced maximum branch distance in eval.c
- *
- * Revision 4.0 91/03/20 01:16:48 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX)
-#include <signal.h>
-#endif
-
-#ifdef I_FCNTL
-#include <fcntl.h>
-#endif
-#ifdef MSDOS
-/* I_FCNTL *MUST* not be defined for MS-DOS and OS/2
- but fcntl.h is required for O_BINARY */
-#include <fcntl.h>
-#endif
-#ifdef I_SYS_FILE
-#include <sys/file.h>
-#endif
-#ifdef I_VFORK
-# include <vfork.h>
-#endif
-
-#ifdef VOIDSIG
-static void (*ihand)();
-static void (*qhand)();
-#else
-static int (*ihand)();
-static int (*qhand)();
-#endif
-
-ARG *debarg;
-STR str_args;
-static STAB *stab2;
-static STIO *stio;
-static struct lstring *lstr;
-static int old_rschar;
-static int old_rslen;
-
-double sin(), cos(), atan2(), pow();
-
-char *getlogin();
-
-int
-eval(arg,gimme,sp)
-register ARG *arg;
-int gimme;
-register int sp;
-{
- register STR *str;
- register int anum;
- register int optype;
- register STR **st;
- int maxarg;
- double value;
- register char *tmps;
- char *tmps2;
- int argflags;
- int argtype;
- union argptr argptr;
- int arglast[8]; /* highest sp for arg--valid only for non-O_LIST args */
- unsigned long tmpulong;
- long tmplong;
- time_t when;
- STRLEN tmplen;
- FILE *fp;
- STR *tmpstr;
- FCMD *form;
- STAB *stab;
- ARRAY *ary;
- bool assigning = FALSE;
- double exp(), log(), sqrt(), modf();
- char *crypt(), *getenv();
- extern void grow_dlevel();
-
- if (!arg)
- goto say_undef;
- optype = arg->arg_type;
- maxarg = arg->arg_len;
- arglast[0] = sp;
- str = arg->arg_ptr.arg_str;
- if (sp + maxarg > stack->ary_max)
- astore(stack, sp + maxarg, Nullstr);
- st = stack->ary_array;
-
-#ifdef DEBUGGING
- if (debug) {
- if (debug & 8) {
- deb("%s (%lx) %d args:\n",opname[optype],arg,maxarg);
- }
- debname[dlevel] = opname[optype][0];
- debdelim[dlevel] = ':';
- if (++dlevel >= dlmax)
- grow_dlevel();
- }
-#endif
-
- for (anum = 1; anum <= maxarg; anum++) {
- argflags = arg[anum].arg_flags;
- argtype = arg[anum].arg_type;
- argptr = arg[anum].arg_ptr;
- re_eval:
- switch (argtype) {
- default:
- st[++sp] = &str_undef;
-#ifdef DEBUGGING
- tmps = "NULL";
-#endif
- break;
- case A_EXPR:
-#ifdef DEBUGGING
- if (debug & 8) {
- tmps = "EXPR";
- deb("%d.EXPR =>\n",anum);
- }
-#endif
- sp = eval(argptr.arg_arg,
- (argflags & AF_ARYOK) ? G_ARRAY : G_SCALAR, sp);
- if (sp + (maxarg - anum) > stack->ary_max)
- astore(stack, sp + (maxarg - anum), Nullstr);
- st = stack->ary_array; /* possibly reallocated */
- break;
- case A_CMD:
-#ifdef DEBUGGING
- if (debug & 8) {
- tmps = "CMD";
- deb("%d.CMD (%lx) =>\n",anum,argptr.arg_cmd);
- }
-#endif
- sp = cmd_exec(argptr.arg_cmd, gimme, sp);
- if (sp + (maxarg - anum) > stack->ary_max)
- astore(stack, sp + (maxarg - anum), Nullstr);
- st = stack->ary_array; /* possibly reallocated */
- break;
- case A_LARYSTAB:
- ++sp;
- switch (optype) {
- case O_ITEM2: argtype = 2; break;
- case O_ITEM3: argtype = 3; break;
- default: argtype = anum; break;
- }
- str = afetch(stab_array(argptr.arg_stab),
- arg[argtype].arg_len - arybase, TRUE);
-#ifdef DEBUGGING
- if (debug & 8) {
- (void)sprintf(buf,"LARYSTAB $%s[%d]",stab_name(argptr.arg_stab),
- arg[argtype].arg_len);
- tmps = buf;
- }
-#endif
- goto do_crement;
- case A_ARYSTAB:
- switch (optype) {
- case O_ITEM2: argtype = 2; break;
- case O_ITEM3: argtype = 3; break;
- default: argtype = anum; break;
- }
- st[++sp] = afetch(stab_array(argptr.arg_stab),
- arg[argtype].arg_len - arybase, FALSE);
-#ifdef DEBUGGING
- if (debug & 8) {
- (void)sprintf(buf,"ARYSTAB $%s[%d]",stab_name(argptr.arg_stab),
- arg[argtype].arg_len);
- tmps = buf;
- }
-#endif
- break;
- case A_STAR:
- stab = argptr.arg_stab;
- st[++sp] = (STR*)stab;
- if (!stab_xarray(stab))
- aadd(stab);
- if (!stab_xhash(stab))
- hadd(stab);
- if (!stab_io(stab))
- stab_io(stab) = stio_new();
-#ifdef DEBUGGING
- if (debug & 8) {
- (void)sprintf(buf,"STAR *%s -> *%s",
- stab_name(argptr.arg_stab), stab_ename(argptr.arg_stab));
- tmps = buf;
- }
-#endif
- break;
- case A_LSTAR:
- str = st[++sp] = (STR*)argptr.arg_stab;
-#ifdef DEBUGGING
- if (debug & 8) {
- (void)sprintf(buf,"LSTAR *%s -> *%s",
- stab_name(argptr.arg_stab), stab_ename(argptr.arg_stab));
- tmps = buf;
- }
-#endif
- break;
- case A_STAB:
- st[++sp] = STAB_STR(argptr.arg_stab);
-#ifdef DEBUGGING
- if (debug & 8) {
- (void)sprintf(buf,"STAB $%s",stab_name(argptr.arg_stab));
- tmps = buf;
- }
-#endif
- break;
- case A_LENSTAB:
- str_numset(str, (double)STAB_LEN(argptr.arg_stab));
- st[++sp] = str;
-#ifdef DEBUGGING
- if (debug & 8) {
- (void)sprintf(buf,"LENSTAB $%s",stab_name(argptr.arg_stab));
- tmps = buf;
- }
-#endif
- break;
- case A_LEXPR:
-#ifdef DEBUGGING
- if (debug & 8) {
- tmps = "LEXPR";
- deb("%d.LEXPR =>\n",anum);
- }
-#endif
- if (argflags & AF_ARYOK) {
- sp = eval(argptr.arg_arg, G_ARRAY, sp);
- if (sp + (maxarg - anum) > stack->ary_max)
- astore(stack, sp + (maxarg - anum), Nullstr);
- st = stack->ary_array; /* possibly reallocated */
- }
- else {
- sp = eval(argptr.arg_arg, G_SCALAR, sp);
- st = stack->ary_array; /* possibly reallocated */
- str = st[sp];
- goto do_crement;
- }
- break;
- case A_LVAL:
-#ifdef DEBUGGING
- if (debug & 8) {
- (void)sprintf(buf,"LVAL $%s",stab_name(argptr.arg_stab));
- tmps = buf;
- }
-#endif
- ++sp;
- str = STAB_STR(argptr.arg_stab);
- if (!str)
- fatal("panic: A_LVAL");
- do_crement:
- assigning = TRUE;
- if (argflags & AF_PRE) {
- if (argflags & AF_UP)
- str_inc(str);
- else
- str_dec(str);
- STABSET(str);
- st[sp] = str;
- str = arg->arg_ptr.arg_str;
- }
- else if (argflags & AF_POST) {
- st[sp] = str_mortal(str);
- if (argflags & AF_UP)
- str_inc(str);
- else
- str_dec(str);
- STABSET(str);
- str = arg->arg_ptr.arg_str;
- }
- else
- st[sp] = str;
- break;
- case A_LARYLEN:
- ++sp;
- stab = argptr.arg_stab;
- str = stab_array(argptr.arg_stab)->ary_magic;
- if (optype != O_SASSIGN || argflags & (AF_PRE|AF_POST))
- str_numset(str,(double)(stab_array(stab)->ary_fill+arybase));
-#ifdef DEBUGGING
- tmps = "LARYLEN";
-#endif
- if (!str)
- fatal("panic: A_LEXPR");
- goto do_crement;
- case A_ARYLEN:
- stab = argptr.arg_stab;
- st[++sp] = stab_array(stab)->ary_magic;
- str_numset(st[sp],(double)(stab_array(stab)->ary_fill+arybase));
-#ifdef DEBUGGING
- tmps = "ARYLEN";
-#endif
- break;
- case A_SINGLE:
- st[++sp] = argptr.arg_str;
-#ifdef DEBUGGING
- tmps = "SINGLE";
-#endif
- break;
- case A_DOUBLE:
- (void) interp(str,argptr.arg_str,sp);
- st = stack->ary_array;
- st[++sp] = str;
-#ifdef DEBUGGING
- tmps = "DOUBLE";
-#endif
- break;
- case A_BACKTICK:
- tmps = str_get(interp(str,argptr.arg_str,sp));
- st = stack->ary_array;
-#ifdef TAINT
- taintproper("Insecure dependency in ``");
-#endif
- fp = mypopen(tmps,"r");
- str_set(str,"");
- if (fp) {
- if (gimme == G_SCALAR) {
- while (str_gets(str,fp,str->str_cur) != Nullch)
- /*SUPPRESS 530*/
- ;
- }
- else {
- for (;;) {
- if (++sp > stack->ary_max) {
- astore(stack, sp, Nullstr);
- st = stack->ary_array;
- }
- str = st[sp] = Str_new(56,80);
- if (str_gets(str,fp,0) == Nullch) {
- sp--;
- break;
- }
- if (str->str_len - str->str_cur > 20) {
- str->str_len = str->str_cur+1;
- Renew(str->str_ptr, str->str_len, char);
- }
- str_2mortal(str);
- }
- }
- statusvalue = mypclose(fp);
- }
- else
- statusvalue = -1;
-
- if (gimme == G_SCALAR)
- st[++sp] = str;
-#ifdef DEBUGGING
- tmps = "BACK";
-#endif
- break;
- case A_WANTARRAY:
- {
- if (curcsv->wantarray == G_ARRAY)
- st[++sp] = &str_yes;
- else
- st[++sp] = &str_no;
- }
-#ifdef DEBUGGING
- tmps = "WANTARRAY";
-#endif
- break;
- case A_INDREAD:
- last_in_stab = stabent(str_get(STAB_STR(argptr.arg_stab)),TRUE);
- old_rschar = rschar;
- old_rslen = rslen;
- goto do_read;
- case A_GLOB:
- argflags |= AF_POST; /* enable newline chopping */
- last_in_stab = argptr.arg_stab;
- old_rschar = rschar;
- old_rslen = rslen;
- rslen = 1;
-#ifdef DOSISH
- rschar = 0;
-#else
-#ifdef CSH
- rschar = 0;
-#else
- rschar = '\n';
-#endif /* !CSH */
-#endif /* !MSDOS */
- goto do_read;
- case A_READ:
- last_in_stab = argptr.arg_stab;
- old_rschar = rschar;
- old_rslen = rslen;
- do_read:
- if (anum > 1) /* assign to scalar */
- gimme = G_SCALAR; /* force context to scalar */
- if (gimme == G_ARRAY)
- str = Str_new(57,0);
- ++sp;
- fp = Nullfp;
- if (stab_io(last_in_stab)) {
- fp = stab_io(last_in_stab)->ifp;
- if (!fp) {
- if (stab_io(last_in_stab)->flags & IOF_ARGV) {
- if (stab_io(last_in_stab)->flags & IOF_START) {
- stab_io(last_in_stab)->flags &= ~IOF_START;
- stab_io(last_in_stab)->lines = 0;
- if (alen(stab_array(last_in_stab)) < 0) {
- tmpstr = str_make("-",1); /* assume stdin */
- (void)apush(stab_array(last_in_stab), tmpstr);
- }
- }
- fp = nextargv(last_in_stab);
- if (!fp) { /* Note: fp != stab_io(last_in_stab)->ifp */
- (void)do_close(last_in_stab,FALSE); /* now it does*/
- stab_io(last_in_stab)->flags |= IOF_START;
- }
- }
- else if (argtype == A_GLOB) {
- (void) interp(str,stab_val(last_in_stab),sp);
- st = stack->ary_array;
- tmpstr = Str_new(55,0);
-#ifdef DOSISH
- str_set(tmpstr, "perlglob ");
- str_scat(tmpstr,str);
- str_cat(tmpstr," |");
-#else
-#ifdef CSH
- str_nset(tmpstr,cshname,cshlen);
- str_cat(tmpstr," -cf 'set nonomatch; glob ");
- str_scat(tmpstr,str);
- str_cat(tmpstr,"'|");
-#else
- str_set(tmpstr, "echo ");
- str_scat(tmpstr,str);
- str_cat(tmpstr,
- "|tr -s ' \t\f\r' '\\012\\012\\012\\012'|");
-#endif /* !CSH */
-#endif /* !MSDOS */
- (void)do_open(last_in_stab,tmpstr->str_ptr,
- tmpstr->str_cur);
- fp = stab_io(last_in_stab)->ifp;
- str_free(tmpstr);
- }
- }
- }
- if (!fp && dowarn)
- warn("Read on closed filehandle <%s>",stab_ename(last_in_stab));
- tmplen = str->str_len; /* remember if already alloced */
- if (!tmplen)
- Str_Grow(str,80); /* try short-buffering it */
- keepgoing:
- if (!fp)
- st[sp] = &str_undef;
- else if (!str_gets(str,fp, optype == O_RCAT ? str->str_cur : 0)) {
- clearerr(fp);
- if (stab_io(last_in_stab)->flags & IOF_ARGV) {
- fp = nextargv(last_in_stab);
- if (fp)
- goto keepgoing;
- (void)do_close(last_in_stab,FALSE);
- stab_io(last_in_stab)->flags |= IOF_START;
- }
- else if (argflags & AF_POST) {
- (void)do_close(last_in_stab,FALSE);
- }
- st[sp] = &str_undef;
- rschar = old_rschar;
- rslen = old_rslen;
- if (gimme == G_ARRAY) {
- --sp;
- str_2mortal(str);
- goto array_return;
- }
- break;
- }
- else {
- stab_io(last_in_stab)->lines++;
- st[sp] = str;
-#ifdef TAINT
- str->str_tainted = 1; /* Anything from the outside world...*/
-#endif
- if (argflags & AF_POST) {
- if (str->str_cur > 0)
- str->str_cur--;
- if (str->str_ptr[str->str_cur] == rschar)
- str->str_ptr[str->str_cur] = '\0';
- else
- str->str_cur++;
- for (tmps = str->str_ptr; *tmps; tmps++)
- if (!isALPHA(*tmps) && !isDIGIT(*tmps) &&
- index("$&*(){}[]'\";\\|?<>~`",*tmps))
- break;
- if (*tmps && stat(str->str_ptr,&statbuf) < 0)
- goto keepgoing; /* unmatched wildcard? */
- }
- if (gimme == G_ARRAY) {
- if (str->str_len - str->str_cur > 20) {
- str->str_len = str->str_cur+1;
- Renew(str->str_ptr, str->str_len, char);
- }
- str_2mortal(str);
- if (++sp > stack->ary_max) {
- astore(stack, sp, Nullstr);
- st = stack->ary_array;
- }
- str = Str_new(58,80);
- goto keepgoing;
- }
- else if (!tmplen && str->str_len - str->str_cur > 80) {
- /* try to reclaim a bit of scalar space on 1st alloc */
- if (str->str_cur < 60)
- str->str_len = 80;
- else
- str->str_len = str->str_cur+40; /* allow some slop */
- Renew(str->str_ptr, str->str_len, char);
- }
- }
- rschar = old_rschar;
- rslen = old_rslen;
-#ifdef DEBUGGING
- tmps = "READ";
-#endif
- break;
- }
-#ifdef DEBUGGING
- if (debug & 8)
- deb("%d.%s = '%s'\n",anum,tmps,str_peek(st[sp]));
-#endif
- if (anum < 8)
- arglast[anum] = sp;
- }
-
- st += arglast[0];
-#ifdef SMALLSWITCHES
- if (optype < O_CHOWN)
-#endif
- switch (optype) {
- case O_RCAT:
- STABSET(str);
- break;
- case O_ITEM:
- if (gimme == G_ARRAY)
- goto array_return;
- /* FALL THROUGH */
- case O_SCALAR:
- STR_SSET(str,st[1]);
- STABSET(str);
- break;
- case O_ITEM2:
- if (gimme == G_ARRAY)
- goto array_return;
- --anum;
- STR_SSET(str,st[arglast[anum]-arglast[0]]);
- STABSET(str);
- break;
- case O_ITEM3:
- if (gimme == G_ARRAY)
- goto array_return;
- --anum;
- STR_SSET(str,st[arglast[anum]-arglast[0]]);
- STABSET(str);
- break;
- case O_CONCAT:
- STR_SSET(str,st[1]);
- str_scat(str,st[2]);
- STABSET(str);
- break;
- case O_REPEAT:
- if (gimme == G_ARRAY && arg[1].arg_flags & AF_ARYOK) {
- sp = do_repeatary(arglast);
- goto array_return;
- }
- STR_SSET(str,st[1]);
- anum = (int)str_gnum(st[2]);
- if (anum >= 1) {
- tmpstr = Str_new(50, 0);
- tmps = str_get(str);
- str_nset(tmpstr,tmps,str->str_cur);
- tmps = str_get(tmpstr); /* force to be string */
- STR_GROW(str, (anum * str->str_cur) + 1);
- repeatcpy(str->str_ptr, tmps, tmpstr->str_cur, anum);
- str->str_cur *= anum;
- str->str_ptr[str->str_cur] = '\0';
- str->str_nok = 0;
- str_free(tmpstr);
- }
- else {
- if (dowarn && st[2]->str_pok && !looks_like_number(st[2]))
- warn("Right operand of x is not numeric");
- str_sset(str,&str_no);
- }
- STABSET(str);
- break;
- case O_MATCH:
- sp = do_match(str,arg,
- gimme,arglast);
- if (gimme == G_ARRAY)
- goto array_return;
- STABSET(str);
- break;
- case O_NMATCH:
- sp = do_match(str,arg,
- G_SCALAR,arglast);
- str_sset(str, str_true(str) ? &str_no : &str_yes);
- STABSET(str);
- break;
- case O_SUBST:
- sp = do_subst(str,arg,arglast[0]);
- goto array_return;
- case O_NSUBST:
- sp = do_subst(str,arg,arglast[0]);
- str = arg->arg_ptr.arg_str;
- str_set(str, str_true(str) ? No : Yes);
- goto array_return;
- case O_ASSIGN:
- if (arg[1].arg_flags & AF_ARYOK) {
- if (arg->arg_len == 1) {
- arg->arg_type = O_LOCAL;
- goto local;
- }
- else {
- arg->arg_type = O_AASSIGN;
- goto aassign;
- }
- }
- else {
- arg->arg_type = O_SASSIGN;
- goto sassign;
- }
- case O_LOCAL:
- local:
- arglast[2] = arglast[1]; /* push a null array */
- /* FALL THROUGH */
- case O_AASSIGN:
- aassign:
- sp = do_assign(arg,
- gimme,arglast);
- goto array_return;
- case O_SASSIGN:
- sassign:
-#ifdef TAINT
- if (tainted && !st[2]->str_tainted)
- tainted = 0;
-#endif
- STR_SSET(str, st[2]);
- STABSET(str);
- break;
- case O_CHOP:
- st -= arglast[0];
- str = arg->arg_ptr.arg_str;
- for (sp = arglast[0] + 1; sp <= arglast[1]; sp++)
- do_chop(str,st[sp]);
- st += arglast[0];
- break;
- case O_DEFINED:
- if (arg[1].arg_type & A_DONT) {
- sp = do_defined(str,arg,
- gimme,arglast);
- goto array_return;
- }
- else if (str->str_pok || str->str_nok)
- goto say_yes;
- goto say_no;
- case O_UNDEF:
- if (arg[1].arg_type & A_DONT) {
- sp = do_undef(str,arg,
- gimme,arglast);
- goto array_return;
- }
- else if (str != stab_val(defstab)) {
- if (str->str_len) {
- if (str->str_state == SS_INCR)
- Str_Grow(str,0);
- Safefree(str->str_ptr);
- str->str_ptr = Nullch;
- str->str_len = 0;
- }
- str->str_pok = str->str_nok = 0;
- STABSET(str);
- }
- goto say_undef;
- case O_STUDY:
- sp = do_study(str,arg,
- gimme,arglast);
- goto array_return;
- case O_POW:
- value = str_gnum(st[1]);
- value = pow(value,str_gnum(st[2]));
- goto donumset;
- case O_MULTIPLY:
- value = str_gnum(st[1]);
- value *= str_gnum(st[2]);
- goto donumset;
- case O_DIVIDE:
- if ((value = str_gnum(st[2])) == 0.0)
- fatal("Illegal division by zero");
-#ifdef SLOPPYDIVIDE
- /* insure that 20./5. == 4. */
- {
- double x;
- int k;
- x = str_gnum(st[1]);
- if ((double)(int)x == x &&
- (double)(int)value == value &&
- (k = (int)x/(int)value)*(int)value == (int)x) {
- value = k;
- } else {
- value = x/value;
- }
- }
-#else
- value = str_gnum(st[1]) / value;
-#endif
- goto donumset;
- case O_MODULO:
- tmpulong = (unsigned long) str_gnum(st[2]);
- if (tmpulong == 0L)
- fatal("Illegal modulus zero");
-#ifndef lint
- value = str_gnum(st[1]);
- if (value >= 0.0)
- value = (double)(((unsigned long)value) % tmpulong);
- else {
- tmplong = (long)value;
- value = (double)(tmpulong - ((-tmplong - 1) % tmpulong)) - 1;
- }
-#endif
- goto donumset;
- case O_ADD:
- value = str_gnum(st[1]);
- value += str_gnum(st[2]);
- goto donumset;
- case O_SUBTRACT:
- value = str_gnum(st[1]);
- value -= str_gnum(st[2]);
- goto donumset;
- case O_LEFT_SHIFT:
- value = str_gnum(st[1]);
- anum = (int)str_gnum(st[2]);
-#ifndef lint
- value = (double)(U_L(value) << anum);
-#endif
- goto donumset;
- case O_RIGHT_SHIFT:
- value = str_gnum(st[1]);
- anum = (int)str_gnum(st[2]);
-#ifndef lint
- value = (double)(U_L(value) >> anum);
-#endif
- goto donumset;
- case O_LT:
- value = str_gnum(st[1]);
- value = (value < str_gnum(st[2])) ? 1.0 : 0.0;
- goto donumset;
- case O_GT:
- value = str_gnum(st[1]);
- value = (value > str_gnum(st[2])) ? 1.0 : 0.0;
- goto donumset;
- case O_LE:
- value = str_gnum(st[1]);
- value = (value <= str_gnum(st[2])) ? 1.0 : 0.0;
- goto donumset;
- case O_GE:
- value = str_gnum(st[1]);
- value = (value >= str_gnum(st[2])) ? 1.0 : 0.0;
- goto donumset;
- case O_EQ:
- if (dowarn) {
- if ((!st[1]->str_nok && !looks_like_number(st[1])) ||
- (!st[2]->str_nok && !looks_like_number(st[2])) )
- warn("Possible use of == on string value");
- }
- value = str_gnum(st[1]);
- value = (value == str_gnum(st[2])) ? 1.0 : 0.0;
- goto donumset;
- case O_NE:
- value = str_gnum(st[1]);
- value = (value != str_gnum(st[2])) ? 1.0 : 0.0;
- goto donumset;
- case O_NCMP:
- value = str_gnum(st[1]);
- value -= str_gnum(st[2]);
- if (value > 0.0)
- value = 1.0;
- else if (value < 0.0)
- value = -1.0;
- goto donumset;
- case O_BIT_AND:
- if (!sawvec || st[1]->str_nok || st[2]->str_nok) {
- value = str_gnum(st[1]);
-#ifndef lint
- value = (double)(U_L(value) & U_L(str_gnum(st[2])));
-#endif
- goto donumset;
- }
- else
- do_vop(optype,str,st[1],st[2]);
- break;
- case O_XOR:
- if (!sawvec || st[1]->str_nok || st[2]->str_nok) {
- value = str_gnum(st[1]);
-#ifndef lint
- value = (double)(U_L(value) ^ U_L(str_gnum(st[2])));
-#endif
- goto donumset;
- }
- else
- do_vop(optype,str,st[1],st[2]);
- break;
- case O_BIT_OR:
- if (!sawvec || st[1]->str_nok || st[2]->str_nok) {
- value = str_gnum(st[1]);
-#ifndef lint
- value = (double)(U_L(value) | U_L(str_gnum(st[2])));
-#endif
- goto donumset;
- }
- else
- do_vop(optype,str,st[1],st[2]);
- break;
-/* use register in evaluating str_true() */
- case O_AND:
- if (str_true(st[1])) {
- anum = 2;
- optype = O_ITEM2;
- argflags = arg[anum].arg_flags;
- if (gimme == G_ARRAY)
- argflags |= AF_ARYOK;
- argtype = arg[anum].arg_type & A_MASK;
- argptr = arg[anum].arg_ptr;
- maxarg = anum = 1;
- sp = arglast[0];
- st -= sp;
- goto re_eval;
- }
- else {
- if (assigning) {
- str_sset(str, st[1]);
- STABSET(str);
- }
- else
- str = st[1];
- break;
- }
- case O_OR:
- if (str_true(st[1])) {
- if (assigning) {
- str_sset(str, st[1]);
- STABSET(str);
- }
- else
- str = st[1];
- break;
- }
- else {
- anum = 2;
- optype = O_ITEM2;
- argflags = arg[anum].arg_flags;
- if (gimme == G_ARRAY)
- argflags |= AF_ARYOK;
- argtype = arg[anum].arg_type & A_MASK;
- argptr = arg[anum].arg_ptr;
- maxarg = anum = 1;
- sp = arglast[0];
- st -= sp;
- goto re_eval;
- }
- case O_COND_EXPR:
- anum = (str_true(st[1]) ? 2 : 3);
- optype = (anum == 2 ? O_ITEM2 : O_ITEM3);
- argflags = arg[anum].arg_flags;
- if (gimme == G_ARRAY)
- argflags |= AF_ARYOK;
- argtype = arg[anum].arg_type & A_MASK;
- argptr = arg[anum].arg_ptr;
- maxarg = anum = 1;
- sp = arglast[0];
- st -= sp;
- goto re_eval;
- case O_COMMA:
- if (gimme == G_ARRAY)
- goto array_return;
- str = st[2];
- break;
- case O_NEGATE:
- value = -str_gnum(st[1]);
- goto donumset;
- case O_NOT:
-#ifdef NOTNOT
- { char xxx = str_true(st[1]); value = (double) !xxx; }
-#else
- value = (double) !str_true(st[1]);
-#endif
- goto donumset;
- case O_COMPLEMENT:
- if (!sawvec || st[1]->str_nok) {
-#ifndef lint
- value = (double) ~U_L(str_gnum(st[1]));
-#endif
- goto donumset;
- }
- else {
- STR_SSET(str,st[1]);
- tmps = str_get(str);
- for (anum = str->str_cur; anum; anum--, tmps++)
- *tmps = ~*tmps;
- }
- break;
- case O_SELECT:
- stab_efullname(str,defoutstab);
- if (maxarg > 0) {
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- defoutstab = arg[1].arg_ptr.arg_stab;
- else
- defoutstab = stabent(str_get(st[1]),TRUE);
- if (!stab_io(defoutstab))
- stab_io(defoutstab) = stio_new();
- curoutstab = defoutstab;
- }
- STABSET(str);
- break;
- case O_WRITE:
- if (maxarg == 0)
- stab = defoutstab;
- else if ((arg[1].arg_type & A_MASK) == A_WORD) {
- if (!(stab = arg[1].arg_ptr.arg_stab))
- stab = defoutstab;
- }
- else
- stab = stabent(str_get(st[1]),TRUE);
- if (!stab_io(stab)) {
- str_set(str, No);
- STABSET(str);
- break;
- }
- curoutstab = stab;
- fp = stab_io(stab)->ofp;
- debarg = arg;
- if (stab_io(stab)->fmt_stab)
- form = stab_form(stab_io(stab)->fmt_stab);
- else
- form = stab_form(stab);
- if (!form || !fp) {
- if (dowarn) {
- if (form)
- warn("No format for filehandle");
- else {
- if (stab_io(stab)->ifp)
- warn("Filehandle only opened for input");
- else
- warn("Write on closed filehandle");
- }
- }
- str_set(str, No);
- STABSET(str);
- break;
- }
- format(&outrec,form,sp);
- do_write(&outrec,stab,sp);
- if (stab_io(stab)->flags & IOF_FLUSH)
- (void)fflush(fp);
- str_set(str, Yes);
- STABSET(str);
- break;
- case O_DBMOPEN:
-#ifdef SOME_DBM
- anum = arg[1].arg_type & A_MASK;
- if (anum == A_WORD || anum == A_STAB)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if (st[3]->str_nok || st[3]->str_pok)
- anum = (int)str_gnum(st[3]);
- else
- anum = -1;
- value = (double)hdbmopen(stab_hash(stab),str_get(st[2]),anum);
- goto donumset;
-#else
- fatal("No dbm or ndbm on this machine");
-#endif
- case O_DBMCLOSE:
-#ifdef SOME_DBM
- anum = arg[1].arg_type & A_MASK;
- if (anum == A_WORD || anum == A_STAB)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- hdbmclose(stab_hash(stab));
- goto say_yes;
-#else
- fatal("No dbm or ndbm on this machine");
-#endif
- case O_OPEN:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- tmps = str_get(st[2]);
- if (do_open(stab,tmps,st[2]->str_cur)) {
- value = (double)forkprocess;
- stab_io(stab)->lines = 0;
- goto donumset;
- }
- else if (forkprocess == 0) /* we are a new child */
- goto say_zero;
- else
- goto say_undef;
- /* break; */
- case O_TRANS:
- value = (double) do_trans(str,arg);
- str = arg->arg_ptr.arg_str;
- goto donumset;
- case O_NTRANS:
- str_set(arg->arg_ptr.arg_str, do_trans(str,arg) == 0 ? Yes : No);
- str = arg->arg_ptr.arg_str;
- break;
- case O_CLOSE:
- if (maxarg == 0)
- stab = defoutstab;
- else if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- str_set(str, do_close(stab,TRUE) ? Yes : No );
- STABSET(str);
- break;
- case O_EACH:
- sp = do_each(str,stab_hash(arg[1].arg_ptr.arg_stab),
- gimme,arglast);
- goto array_return;
- case O_VALUES:
- case O_KEYS:
- sp = do_kv(str,stab_hash(arg[1].arg_ptr.arg_stab), optype,
- gimme,arglast);
- goto array_return;
- case O_LARRAY:
- str->str_nok = str->str_pok = 0;
- str->str_u.str_stab = arg[1].arg_ptr.arg_stab;
- str->str_state = SS_ARY;
- break;
- case O_ARRAY:
- ary = stab_array(arg[1].arg_ptr.arg_stab);
- maxarg = ary->ary_fill + 1;
- if (gimme == G_ARRAY) { /* array wanted */
- sp = arglast[0];
- st -= sp;
- if (maxarg > 0 && sp + maxarg > stack->ary_max) {
- astore(stack,sp + maxarg, Nullstr);
- st = stack->ary_array;
- }
- st += sp;
- Copy(ary->ary_array, &st[1], maxarg, STR*);
- sp += maxarg;
- goto array_return;
- }
- else {
- value = (double)maxarg;
- goto donumset;
- }
- case O_AELEM:
- anum = ((int)str_gnum(st[2])) - arybase;
- str = afetch(stab_array(arg[1].arg_ptr.arg_stab),anum,FALSE);
- break;
- case O_DELETE:
- tmpstab = arg[1].arg_ptr.arg_stab;
- tmps = str_get(st[2]);
- str = hdelete(stab_hash(tmpstab),tmps,st[2]->str_cur);
- if (tmpstab == envstab)
- my_setenv(tmps,Nullch);
- if (!str)
- goto say_undef;
- break;
- case O_LHASH:
- str->str_nok = str->str_pok = 0;
- str->str_u.str_stab = arg[1].arg_ptr.arg_stab;
- str->str_state = SS_HASH;
- break;
- case O_HASH:
- if (gimme == G_ARRAY) { /* array wanted */
- sp = do_kv(str,stab_hash(arg[1].arg_ptr.arg_stab), optype,
- gimme,arglast);
- goto array_return;
- }
- else {
- tmpstab = arg[1].arg_ptr.arg_stab;
- if (!stab_hash(tmpstab)->tbl_fill)
- goto say_zero;
- sprintf(buf,"%d/%d",stab_hash(tmpstab)->tbl_fill,
- stab_hash(tmpstab)->tbl_max+1);
- str_set(str,buf);
- }
- break;
- case O_HELEM:
- tmpstab = arg[1].arg_ptr.arg_stab;
- tmps = str_get(st[2]);
- str = hfetch(stab_hash(tmpstab),tmps,st[2]->str_cur,FALSE);
- break;
- case O_LAELEM:
- anum = ((int)str_gnum(st[2])) - arybase;
- str = afetch(stab_array(arg[1].arg_ptr.arg_stab),anum,TRUE);
- if (!str || str == &str_undef)
- fatal("Assignment to non-creatable value, subscript %d",anum);
- break;
- case O_LHELEM:
- tmpstab = arg[1].arg_ptr.arg_stab;
- tmps = str_get(st[2]);
- anum = st[2]->str_cur;
- str = hfetch(stab_hash(tmpstab),tmps,anum,TRUE);
- if (!str || str == &str_undef)
- fatal("Assignment to non-creatable value, subscript \"%s\"",tmps);
- if (tmpstab == envstab) /* heavy wizardry going on here */
- str_magic(str, tmpstab, 'E', tmps, anum); /* str is now magic */
- /* he threw the brick up into the air */
- else if (tmpstab == sigstab)
- str_magic(str, tmpstab, 'S', tmps, anum);
-#ifdef SOME_DBM
- else if (stab_hash(tmpstab)->tbl_dbm)
- str_magic(str, tmpstab, 'D', tmps, anum);
-#endif
- else if (tmpstab == DBline)
- str_magic(str, tmpstab, 'L', tmps, anum);
- break;
- case O_LSLICE:
- anum = 2;
- argtype = FALSE;
- goto do_slice_already;
- case O_ASLICE:
- anum = 1;
- argtype = FALSE;
- goto do_slice_already;
- case O_HSLICE:
- anum = 0;
- argtype = FALSE;
- goto do_slice_already;
- case O_LASLICE:
- anum = 1;
- argtype = TRUE;
- goto do_slice_already;
- case O_LHSLICE:
- anum = 0;
- argtype = TRUE;
- do_slice_already:
- sp = do_slice(arg[1].arg_ptr.arg_stab,str,anum,argtype,
- gimme,arglast);
- goto array_return;
- case O_SPLICE:
- sp = do_splice(stab_array(arg[1].arg_ptr.arg_stab),gimme,arglast);
- goto array_return;
- case O_PUSH:
- if (arglast[2] - arglast[1] != 1)
- str = do_push(stab_array(arg[1].arg_ptr.arg_stab),arglast);
- else {
- str = Str_new(51,0); /* must copy the STR */
- str_sset(str,st[2]);
- (void)apush(stab_array(arg[1].arg_ptr.arg_stab),str);
- }
- break;
- case O_POP:
- str = apop(ary = stab_array(arg[1].arg_ptr.arg_stab));
- goto staticalization;
- case O_SHIFT:
- str = ashift(ary = stab_array(arg[1].arg_ptr.arg_stab));
- staticalization:
- if (!str)
- goto say_undef;
- if (ary->ary_flags & ARF_REAL)
- (void)str_2mortal(str);
- break;
- case O_UNPACK:
- sp = do_unpack(str,gimme,arglast);
- goto array_return;
- case O_SPLIT:
- value = str_gnum(st[3]);
- sp = do_split(str, arg[2].arg_ptr.arg_spat, (int)value,
- gimme,arglast);
- goto array_return;
- case O_LENGTH:
- if (maxarg < 1)
- value = (double)str_len(stab_val(defstab));
- else
- value = (double)str_len(st[1]);
- goto donumset;
- case O_SPRINTF:
- do_sprintf(str, sp-arglast[0], st+1);
- break;
- case O_SUBSTR:
- anum = ((int)str_gnum(st[2])) - arybase; /* anum=where to start*/
- tmps = str_get(st[1]); /* force conversion to string */
- /*SUPPRESS 560*/
- if (argtype = (str == st[1]))
- str = arg->arg_ptr.arg_str;
- if (anum < 0)
- anum += st[1]->str_cur + arybase;
- if (anum < 0 || anum > st[1]->str_cur)
- str_nset(str,"",0);
- else {
- optype = maxarg < 3 ? st[1]->str_cur : (int)str_gnum(st[3]);
- if (optype < 0)
- optype = 0;
- tmps += anum;
- anum = st[1]->str_cur - anum; /* anum=how many bytes left*/
- if (anum > optype)
- anum = optype;
- str_nset(str, tmps, anum);
- if (argtype) { /* it's an lvalue! */
- lstr = (struct lstring*)str;
- str->str_magic = st[1];
- st[1]->str_rare = 's';
- lstr->lstr_offset = tmps - str_get(st[1]);
- lstr->lstr_len = anum;
- }
- }
- break;
- case O_PACK:
- /*SUPPRESS 701*/
- (void)do_pack(str,arglast);
- break;
- case O_GREP:
- sp = do_grep(arg,str,gimme,arglast);
- goto array_return;
- case O_JOIN:
- do_join(str,arglast);
- break;
- case O_SLT:
- tmps = str_get(st[1]);
- value = (double) (str_cmp(st[1],st[2]) < 0);
- goto donumset;
- case O_SGT:
- tmps = str_get(st[1]);
- value = (double) (str_cmp(st[1],st[2]) > 0);
- goto donumset;
- case O_SLE:
- tmps = str_get(st[1]);
- value = (double) (str_cmp(st[1],st[2]) <= 0);
- goto donumset;
- case O_SGE:
- tmps = str_get(st[1]);
- value = (double) (str_cmp(st[1],st[2]) >= 0);
- goto donumset;
- case O_SEQ:
- tmps = str_get(st[1]);
- value = (double) str_eq(st[1],st[2]);
- goto donumset;
- case O_SNE:
- tmps = str_get(st[1]);
- value = (double) !str_eq(st[1],st[2]);
- goto donumset;
- case O_SCMP:
- tmps = str_get(st[1]);
- value = (double) str_cmp(st[1],st[2]);
- goto donumset;
- case O_SUBR:
- sp = do_subr(arg,gimme,arglast);
- st = stack->ary_array + arglast[0]; /* maybe realloced */
- goto array_return;
- case O_DBSUBR:
- sp = do_subr(arg,gimme,arglast);
- st = stack->ary_array + arglast[0]; /* maybe realloced */
- goto array_return;
- case O_CALLER:
- sp = do_caller(arg,maxarg,gimme,arglast);
- st = stack->ary_array + arglast[0]; /* maybe realloced */
- goto array_return;
- case O_SORT:
- sp = do_sort(str,arg,
- gimme,arglast);
- goto array_return;
- case O_REVERSE:
- if (gimme == G_ARRAY)
- sp = do_reverse(arglast);
- else
- sp = do_sreverse(str, arglast);
- goto array_return;
- case O_WARN:
- if (arglast[2] - arglast[1] != 1) {
- do_join(str,arglast);
- tmps = str_get(str);
- }
- else {
- str = st[2];
- tmps = str_get(st[2]);
- }
- if (!tmps || !*tmps)
- tmps = "Warning: something's wrong";
- warn("%s",tmps);
- goto say_yes;
- case O_DIE:
- if (arglast[2] - arglast[1] != 1) {
- do_join(str,arglast);
- tmps = str_get(str);
- }
- else {
- str = st[2];
- tmps = str_get(st[2]);
- }
- if (!tmps || !*tmps)
- tmps = "Died";
- fatal("%s",tmps);
- goto say_zero;
- case O_PRTF:
- case O_PRINT:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if (!stab)
- stab = defoutstab;
- if (!stab_io(stab)) {
- if (dowarn)
- warn("Filehandle never opened");
- goto say_zero;
- }
- if (!(fp = stab_io(stab)->ofp)) {
- if (dowarn) {
- if (stab_io(stab)->ifp)
- warn("Filehandle opened only for input");
- else
- warn("Print on closed filehandle");
- }
- goto say_zero;
- }
- else {
- if (optype == O_PRTF || arglast[2] - arglast[1] != 1)
- value = (double)do_aprint(arg,fp,arglast);
- else {
- value = (double)do_print(st[2],fp);
- if (orslen && optype == O_PRINT)
- if (fwrite(ors, 1, orslen, fp) == 0)
- goto say_zero;
- }
- if (stab_io(stab)->flags & IOF_FLUSH)
- if (fflush(fp) == EOF)
- goto say_zero;
- }
- goto donumset;
- case O_CHDIR:
- if (maxarg < 1)
- tmps = Nullch;
- else
- tmps = str_get(st[1]);
- if (!tmps || !*tmps) {
- tmpstr = hfetch(stab_hash(envstab),"HOME",4,FALSE);
- tmps = str_get(tmpstr);
- }
- if (!tmps || !*tmps) {
- tmpstr = hfetch(stab_hash(envstab),"LOGDIR",6,FALSE);
- tmps = str_get(tmpstr);
- }
-#ifdef TAINT
- taintproper("Insecure dependency in chdir");
-#endif
- value = (double)(chdir(tmps) >= 0);
- goto donumset;
- case O_EXIT:
- if (maxarg < 1)
- anum = 0;
- else
- anum = (int)str_gnum(st[1]);
- exit(anum);
- goto say_zero;
- case O_RESET:
- if (maxarg < 1)
- tmps = "";
- else
- tmps = str_get(st[1]);
- str_reset(tmps,curcmd->c_stash);
- value = 1.0;
- goto donumset;
- case O_LIST:
- if (gimme == G_ARRAY)
- goto array_return;
- if (maxarg > 0)
- str = st[sp - arglast[0]]; /* unwanted list, return last item */
- else
- str = &str_undef;
- break;
- case O_EOF:
- if (maxarg <= 0)
- stab = last_in_stab;
- else if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- str_set(str, do_eof(stab) ? Yes : No);
- STABSET(str);
- break;
- case O_GETC:
- if (maxarg <= 0)
- stab = stdinstab;
- else if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if (!stab)
- stab = argvstab;
- if (!stab || do_eof(stab)) /* make sure we have fp with something */
- goto say_undef;
- else {
-#ifdef TAINT
- tainted = 1;
-#endif
- str_set(str," ");
- *str->str_ptr = getc(stab_io(stab)->ifp); /* should never be EOF */
- }
- STABSET(str);
- break;
- case O_TELL:
- if (maxarg <= 0)
- stab = last_in_stab;
- else if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
-#ifndef lint
- value = (double)do_tell(stab);
-#else
- (void)do_tell(stab);
-#endif
- goto donumset;
- case O_RECV:
- case O_READ:
- case O_SYSREAD:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- tmps = str_get(st[2]);
- anum = (int)str_gnum(st[3]);
- errno = 0;
- maxarg = sp - arglast[0];
- if (maxarg > 4)
- warn("Too many args on read");
- if (maxarg == 4)
- maxarg = (int)str_gnum(st[4]);
- else
- maxarg = 0;
- if (!stab_io(stab) || !stab_io(stab)->ifp)
- goto say_undef;
-#ifdef HAS_SOCKET
- if (optype == O_RECV) {
- argtype = sizeof buf;
- STR_GROW(st[2], anum+1), (tmps = str_get(st[2])); /* sneaky */
- anum = recvfrom(fileno(stab_io(stab)->ifp), tmps, anum, maxarg,
- buf, &argtype);
- if (anum >= 0) {
- st[2]->str_cur = anum;
- st[2]->str_ptr[anum] = '\0';
- str_nset(str,buf,argtype);
- }
- else
- str_sset(str,&str_undef);
- break;
- }
-#else
- if (optype == O_RECV)
- goto badsock;
-#endif
- STR_GROW(st[2], anum+maxarg+1), (tmps = str_get(st[2])); /* sneaky */
- if (optype == O_SYSREAD) {
- anum = read(fileno(stab_io(stab)->ifp), tmps+maxarg, anum);
- }
- else
-#ifdef HAS_SOCKET
- if (stab_io(stab)->type == 's') {
- argtype = sizeof buf;
- anum = recvfrom(fileno(stab_io(stab)->ifp), tmps+maxarg, anum, 0,
- buf, &argtype);
- }
- else
-#endif
- anum = fread(tmps+maxarg, 1, anum, stab_io(stab)->ifp);
- if (anum < 0)
- goto say_undef;
- st[2]->str_cur = anum+maxarg;
- st[2]->str_ptr[anum+maxarg] = '\0';
- value = (double)anum;
- goto donumset;
- case O_SYSWRITE:
- case O_SEND:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- tmps = str_get(st[2]);
- anum = (int)str_gnum(st[3]);
- errno = 0;
- stio = stab_io(stab);
- maxarg = sp - arglast[0];
- if (!stio || !stio->ifp) {
- anum = -1;
- if (dowarn) {
- if (optype == O_SYSWRITE)
- warn("Syswrite on closed filehandle");
- else
- warn("Send on closed socket");
- }
- }
- else if (optype == O_SYSWRITE) {
- if (maxarg > 4)
- warn("Too many args on syswrite");
- if (maxarg == 4)
- optype = (int)str_gnum(st[4]);
- else
- optype = 0;
- anum = write(fileno(stab_io(stab)->ifp), tmps+optype, anum);
- }
-#ifdef HAS_SOCKET
- else if (maxarg >= 4) {
- if (maxarg > 4)
- warn("Too many args on send");
- tmps2 = str_get(st[4]);
- anum = sendto(fileno(stab_io(stab)->ifp), tmps, st[2]->str_cur,
- anum, tmps2, st[4]->str_cur);
- }
- else
- anum = send(fileno(stab_io(stab)->ifp), tmps, st[2]->str_cur, anum);
-#else
- else
- goto badsock;
-#endif
- if (anum < 0)
- goto say_undef;
- value = (double)anum;
- goto donumset;
- case O_SEEK:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- value = str_gnum(st[2]);
- str_set(str, do_seek(stab,
- (long)value, (int)str_gnum(st[3]) ) ? Yes : No);
- STABSET(str);
- break;
- case O_RETURN:
- tmps = "_SUB_"; /* just fake up a "last _SUB_" */
- optype = O_LAST;
- if (curcsv && curcsv->wantarray == G_ARRAY) {
- lastretstr = Nullstr;
- lastspbase = arglast[1];
- lastsize = arglast[2] - arglast[1];
- }
- else
- lastretstr = str_mortal(st[arglast[2] - arglast[0]]);
- goto dopop;
- case O_REDO:
- case O_NEXT:
- case O_LAST:
- tmps = Nullch;
- if (maxarg > 0) {
- tmps = str_get(arg[1].arg_ptr.arg_str);
- dopop:
- while (loop_ptr >= 0 && (!loop_stack[loop_ptr].loop_label ||
- strNE(tmps,loop_stack[loop_ptr].loop_label) )) {
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Skipping label #%d %s)\n",loop_ptr,
- loop_stack[loop_ptr].loop_label);
- }
-#endif
- loop_ptr--;
- }
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Found label #%d %s)\n",loop_ptr,
- loop_stack[loop_ptr].loop_label);
- }
-#endif
- }
- if (loop_ptr < 0) {
- if (tmps && strEQ(tmps, "_SUB_"))
- fatal("Can't return outside a subroutine");
- fatal("Bad label: %s", maxarg > 0 ? tmps : "<null>");
- }
- if (!lastretstr && optype == O_LAST && lastsize) {
- st -= arglast[0];
- st += lastspbase + 1;
- optype = loop_stack[loop_ptr].loop_sp - lastspbase; /* negative */
- if (optype) {
- for (anum = lastsize; anum > 0; anum--,st++)
- st[optype] = str_mortal(st[0]);
- }
- longjmp(loop_stack[loop_ptr].loop_env, O_LAST);
- }
- longjmp(loop_stack[loop_ptr].loop_env, optype);
- case O_DUMP:
- case O_GOTO:/* shudder */
- goto_targ = str_get(arg[1].arg_ptr.arg_str);
- if (!*goto_targ)
- goto_targ = Nullch; /* just restart from top */
- if (optype == O_DUMP) {
- do_undump = 1;
- my_unexec();
- }
- longjmp(top_env, 1);
- case O_INDEX:
- tmps = str_get(st[1]);
- if (maxarg < 3)
- anum = 0;
- else {
- anum = (int) str_gnum(st[3]) - arybase;
- if (anum < 0)
- anum = 0;
- else if (anum > st[1]->str_cur)
- anum = st[1]->str_cur;
- }
-#ifndef lint
- if (!(tmps2 = fbminstr((unsigned char*)tmps + anum,
- (unsigned char*)tmps + st[1]->str_cur, st[2])))
-#else
- if (tmps2 = fbminstr(Null(unsigned char*),Null(unsigned char*),Nullstr))
-#endif
- value = (double)(-1 + arybase);
- else
- value = (double)(tmps2 - tmps + arybase);
- goto donumset;
- case O_RINDEX:
- tmps = str_get(st[1]);
- tmps2 = str_get(st[2]);
- if (maxarg < 3)
- anum = st[1]->str_cur;
- else {
- anum = (int) str_gnum(st[3]) - arybase + st[2]->str_cur;
- if (anum < 0)
- anum = 0;
- else if (anum > st[1]->str_cur)
- anum = st[1]->str_cur;
- }
-#ifndef lint
- if (!(tmps2 = rninstr(tmps, tmps + anum,
- tmps2, tmps2 + st[2]->str_cur)))
-#else
- if (tmps2 = rninstr(Nullch,Nullch,Nullch,Nullch))
-#endif
- value = (double)(-1 + arybase);
- else
- value = (double)(tmps2 - tmps + arybase);
- goto donumset;
- case O_TIME:
-#ifndef lint
- value = (double) time(Null(long*));
-#endif
- goto donumset;
- case O_TMS:
- sp = do_tms(str,gimme,arglast);
- goto array_return;
- case O_LOCALTIME:
- if (maxarg < 1)
- (void)time(&when);
- else
- when = (time_t)str_gnum(st[1]);
- sp = do_time(str,localtime(&when),
- gimme,arglast);
- goto array_return;
- case O_GMTIME:
- if (maxarg < 1)
- (void)time(&when);
- else
- when = (time_t)str_gnum(st[1]);
- sp = do_time(str,gmtime(&when),
- gimme,arglast);
- goto array_return;
- case O_TRUNCATE:
- sp = do_truncate(str,arg,
- gimme,arglast);
- goto array_return;
- case O_LSTAT:
- case O_STAT:
- sp = do_stat(str,arg,
- gimme,arglast);
- goto array_return;
- case O_CRYPT:
-#ifdef HAS_CRYPT
- tmps = str_get(st[1]);
-#ifdef FCRYPT
- str_set(str,fcrypt(tmps,str_get(st[2])));
-#else
- str_set(str,crypt(tmps,str_get(st[2])));
-#endif
-#else
- fatal(
- "The crypt() function is unimplemented due to excessive paranoia.");
-#endif
- break;
- case O_ATAN2:
- value = str_gnum(st[1]);
- value = atan2(value,str_gnum(st[2]));
- goto donumset;
- case O_SIN:
- if (maxarg < 1)
- value = str_gnum(stab_val(defstab));
- else
- value = str_gnum(st[1]);
- value = sin(value);
- goto donumset;
- case O_COS:
- if (maxarg < 1)
- value = str_gnum(stab_val(defstab));
- else
- value = str_gnum(st[1]);
- value = cos(value);
- goto donumset;
- case O_RAND:
- if (maxarg < 1)
- value = 1.0;
- else
- value = str_gnum(st[1]);
- if (value == 0.0)
- value = 1.0;
-#if RANDBITS == 31
- value = rand() * value / 2147483648.0;
-#else
-#if RANDBITS == 16
- value = rand() * value / 65536.0;
-#else
-#if RANDBITS == 15
- value = rand() * value / 32768.0;
-#else
- value = rand() * value / (double)(((unsigned long)1) << RANDBITS);
-#endif
-#endif
-#endif
- goto donumset;
- case O_SRAND:
- if (maxarg < 1) {
- (void)time(&when);
- anum = when;
- }
- else
- anum = (int)str_gnum(st[1]);
- (void)srand(anum);
- goto say_yes;
- case O_EXP:
- if (maxarg < 1)
- value = str_gnum(stab_val(defstab));
- else
- value = str_gnum(st[1]);
- value = exp(value);
- goto donumset;
- case O_LOG:
- if (maxarg < 1)
- value = str_gnum(stab_val(defstab));
- else
- value = str_gnum(st[1]);
- if (value <= 0.0)
- fatal("Can't take log of %g\n", value);
- value = log(value);
- goto donumset;
- case O_SQRT:
- if (maxarg < 1)
- value = str_gnum(stab_val(defstab));
- else
- value = str_gnum(st[1]);
- if (value < 0.0)
- fatal("Can't take sqrt of %g\n", value);
- value = sqrt(value);
- goto donumset;
- case O_INT:
- if (maxarg < 1)
- value = str_gnum(stab_val(defstab));
- else
- value = str_gnum(st[1]);
- if (value >= 0.0)
- (void)modf(value,&value);
- else {
- (void)modf(-value,&value);
- value = -value;
- }
- goto donumset;
- case O_ORD:
- if (maxarg < 1)
- tmps = str_get(stab_val(defstab));
- else
- tmps = str_get(st[1]);
-#ifndef I286
- value = (double) (*tmps & 255);
-#else
- anum = (int) *tmps;
- value = (double) (anum & 255);
-#endif
- goto donumset;
- case O_ALARM:
-#ifdef HAS_ALARM
- if (maxarg < 1)
- tmps = str_get(stab_val(defstab));
- else
- tmps = str_get(st[1]);
- if (!tmps)
- tmps = "0";
- anum = alarm((unsigned int)atoi(tmps));
- if (anum < 0)
- goto say_undef;
- value = (double)anum;
- goto donumset;
-#else
- fatal("Unsupported function alarm");
- break;
-#endif
- case O_SLEEP:
- if (maxarg < 1)
- tmps = Nullch;
- else
- tmps = str_get(st[1]);
- (void)time(&when);
- if (!tmps || !*tmps)
- sleep((32767<<16)+32767);
- else
- sleep((unsigned int)atoi(tmps));
-#ifndef lint
- value = (double)when;
- (void)time(&when);
- value = ((double)when) - value;
-#endif
- goto donumset;
- case O_RANGE:
- sp = do_range(gimme,arglast);
- goto array_return;
- case O_F_OR_R:
- if (gimme == G_ARRAY) { /* it's a range */
- /* can we optimize to constant array? */
- if ((arg[1].arg_type & A_MASK) == A_SINGLE &&
- (arg[2].arg_type & A_MASK) == A_SINGLE) {
- st[2] = arg[2].arg_ptr.arg_str;
- sp = do_range(gimme,arglast);
- st = stack->ary_array;
- maxarg = sp - arglast[0];
- str_free(arg[1].arg_ptr.arg_str);
- arg[1].arg_ptr.arg_str = Nullstr;
- str_free(arg[2].arg_ptr.arg_str);
- arg[2].arg_ptr.arg_str = Nullstr;
- arg->arg_type = O_ARRAY;
- arg[1].arg_type = A_STAB|A_DONT;
- arg->arg_len = 1;
- stab = arg[1].arg_ptr.arg_stab = aadd(genstab());
- ary = stab_array(stab);
- afill(ary,maxarg - 1);
- anum = maxarg;
- st += arglast[0]+1;
- while (maxarg-- > 0)
- ary->ary_array[maxarg] = str_smake(st[maxarg]);
- st -= arglast[0]+1;
- goto array_return;
- }
- arg->arg_type = optype = O_RANGE;
- maxarg = arg->arg_len = 2;
- anum = 2;
- arg[anum].arg_flags &= ~AF_ARYOK;
- argflags = arg[anum].arg_flags;
- argtype = arg[anum].arg_type & A_MASK;
- arg[anum].arg_type = argtype;
- argptr = arg[anum].arg_ptr;
- sp = arglast[0];
- st -= sp;
- sp++;
- goto re_eval;
- }
- arg->arg_type = O_FLIP;
- /* FALL THROUGH */
- case O_FLIP:
- if ((arg[1].arg_type & A_MASK) == A_SINGLE ?
- last_in_stab && (int)str_gnum(st[1]) == stab_io(last_in_stab)->lines
- :
- str_true(st[1]) ) {
- arg[2].arg_type &= ~A_DONT;
- arg[1].arg_type |= A_DONT;
- arg->arg_type = optype = O_FLOP;
- if (arg->arg_flags & AF_COMMON) {
- str_numset(str,0.0);
- anum = 2;
- argflags = arg[2].arg_flags;
- argtype = arg[2].arg_type & A_MASK;
- argptr = arg[2].arg_ptr;
- sp = arglast[0];
- st -= sp++;
- goto re_eval;
- }
- else {
- str_numset(str,1.0);
- break;
- }
- }
- str_set(str,"");
- break;
- case O_FLOP:
- str_inc(str);
- if ((arg[2].arg_type & A_MASK) == A_SINGLE ?
- last_in_stab && (int)str_gnum(st[2]) == stab_io(last_in_stab)->lines
- :
- str_true(st[2]) ) {
- arg->arg_type = O_FLIP;
- arg[1].arg_type &= ~A_DONT;
- arg[2].arg_type |= A_DONT;
- str_cat(str,"E0");
- }
- break;
- case O_FORK:
-#ifdef HAS_FORK
- anum = fork();
- if (anum < 0)
- goto say_undef;
- if (!anum) {
- /*SUPPRESS 560*/
- if (tmpstab = stabent("$",allstabs))
- str_numset(STAB_STR(tmpstab),(double)getpid());
- hclear(pidstatus, FALSE); /* no kids, so don't wait for 'em */
- }
- value = (double)anum;
- goto donumset;
-#else
- fatal("Unsupported function fork");
- break;
-#endif
- case O_WAIT:
-#ifdef HAS_WAIT
-#ifndef lint
- anum = wait(&argflags);
- if (anum > 0)
- pidgone(anum,argflags);
- value = (double)anum;
-#endif
- statusvalue = (unsigned short)argflags;
- goto donumset;
-#else
- fatal("Unsupported function wait");
- break;
-#endif
- case O_WAITPID:
-#ifdef HAS_WAIT
-#ifndef lint
- anum = (int)str_gnum(st[1]);
- optype = (int)str_gnum(st[2]);
- anum = wait4pid(anum, &argflags,optype);
- value = (double)anum;
-#endif
- statusvalue = (unsigned short)argflags;
- goto donumset;
-#else
- fatal("Unsupported function wait");
- break;
-#endif
- case O_SYSTEM:
-#ifdef HAS_FORK
-#ifdef TAINT
- if (arglast[2] - arglast[1] == 1) {
- taintenv();
- tainted |= st[2]->str_tainted;
- taintproper("Insecure dependency in system");
- }
-#endif
- while ((anum = vfork()) == -1) {
- if (errno != EAGAIN) {
- value = -1.0;
- goto donumset;
- }
- sleep(5);
- }
- if (anum > 0) {
-#ifndef lint
- ihand = signal(SIGINT, SIG_IGN);
- qhand = signal(SIGQUIT, SIG_IGN);
- argtype = wait4pid(anum, &argflags, 0);
-#else
- ihand = qhand = 0;
-#endif
- (void)signal(SIGINT, ihand);
- (void)signal(SIGQUIT, qhand);
- statusvalue = (unsigned short)argflags;
- if (argtype < 0)
- value = -1.0;
- else {
- value = (double)((unsigned int)argflags & 0xffff);
- }
- do_execfree(); /* free any memory child malloced on vfork */
- goto donumset;
- }
- if ((arg[1].arg_type & A_MASK) == A_STAB)
- value = (double)do_aexec(st[1],arglast);
- else if (arglast[2] - arglast[1] != 1)
- value = (double)do_aexec(Nullstr,arglast);
- else {
- value = (double)do_exec(str_get(str_mortal(st[2])));
- }
- _exit(-1);
-#else /* ! FORK */
- if ((arg[1].arg_type & A_MASK) == A_STAB)
- value = (double)do_aspawn(st[1],arglast);
- else if (arglast[2] - arglast[1] != 1)
- value = (double)do_aspawn(Nullstr,arglast);
- else {
- value = (double)do_spawn(str_get(str_mortal(st[2])));
- }
- goto donumset;
-#endif /* FORK */
- case O_EXEC_OP:
- if ((arg[1].arg_type & A_MASK) == A_STAB)
- value = (double)do_aexec(st[1],arglast);
- else if (arglast[2] - arglast[1] != 1)
- value = (double)do_aexec(Nullstr,arglast);
- else {
-#ifdef TAINT
- taintenv();
- tainted |= st[2]->str_tainted;
- taintproper("Insecure dependency in exec");
-#endif
- value = (double)do_exec(str_get(str_mortal(st[2])));
- }
- goto donumset;
- case O_HEX:
- if (maxarg < 1)
- tmps = str_get(stab_val(defstab));
- else
- tmps = str_get(st[1]);
- value = (double)scanhex(tmps, 99, &argtype);
- goto donumset;
-
- case O_OCT:
- if (maxarg < 1)
- tmps = str_get(stab_val(defstab));
- else
- tmps = str_get(st[1]);
- while (*tmps && (isSPACE(*tmps) || *tmps == '0'))
- tmps++;
- if (*tmps == 'x')
- value = (double)scanhex(++tmps, 99, &argtype);
- else
- value = (double)scanoct(tmps, 99, &argtype);
- goto donumset;
-
-/* These common exits are hidden here in the middle of the switches for the
- benefit of those machines with limited branch addressing. Sigh. */
-
-array_return:
-#ifdef DEBUGGING
- if (debug) {
- dlevel--;
- if (debug & 8) {
- anum = sp - arglast[0];
- switch (anum) {
- case 0:
- deb("%s RETURNS ()\n",opname[optype]);
- break;
- case 1:
- deb("%s RETURNS (\"%s\")\n",opname[optype],
- st[1] ? str_get(st[1]) : "");
- break;
- default:
- tmps = st[1] ? str_get(st[1]) : "";
- deb("%s RETURNS %d ARGS (\"%s\",%s\"%s\")\n",opname[optype],
- anum,tmps,anum==2?"":"...,",
- st[anum] ? str_get(st[anum]) : "");
- break;
- }
- }
- }
-#endif
- return sp;
-
-say_yes:
- str = &str_yes;
- goto normal_return;
-
-say_no:
- str = &str_no;
- goto normal_return;
-
-say_undef:
- str = &str_undef;
- goto normal_return;
-
-say_zero:
- value = 0.0;
- /* FALL THROUGH */
-
-donumset:
- str_numset(str,value);
- STABSET(str);
- st[1] = str;
-#ifdef DEBUGGING
- if (debug) {
- dlevel--;
- if (debug & 8)
- deb("%s RETURNS \"%f\"\n",opname[optype],value);
- }
-#endif
- return arglast[0] + 1;
-#ifdef SMALLSWITCHES
- }
- else
- switch (optype) {
-#endif
- case O_CHOWN:
-#ifdef HAS_CHOWN
- value = (double)apply(optype,arglast);
- goto donumset;
-#else
- fatal("Unsupported function chown");
- break;
-#endif
- case O_KILL:
-#ifdef HAS_KILL
- value = (double)apply(optype,arglast);
- goto donumset;
-#else
- fatal("Unsupported function kill");
- break;
-#endif
- case O_UNLINK:
- case O_CHMOD:
- case O_UTIME:
- value = (double)apply(optype,arglast);
- goto donumset;
- case O_UMASK:
-#ifdef HAS_UMASK
- if (maxarg < 1) {
- anum = umask(0);
- (void)umask(anum);
- }
- else
- anum = umask((int)str_gnum(st[1]));
- value = (double)anum;
-#ifdef TAINT
- taintproper("Insecure dependency in umask");
-#endif
- goto donumset;
-#else
- fatal("Unsupported function umask");
- break;
-#endif
-#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
- case O_MSGGET:
- case O_SHMGET:
- case O_SEMGET:
- if ((anum = do_ipcget(optype, arglast)) == -1)
- goto say_undef;
- value = (double)anum;
- goto donumset;
- case O_MSGCTL:
- case O_SHMCTL:
- case O_SEMCTL:
- anum = do_ipcctl(optype, arglast);
- if (anum == -1)
- goto say_undef;
- if (anum != 0) {
- value = (double)anum;
- goto donumset;
- }
- str_set(str,"0 but true");
- STABSET(str);
- break;
- case O_MSGSND:
- value = (double)(do_msgsnd(arglast) >= 0);
- goto donumset;
- case O_MSGRCV:
- value = (double)(do_msgrcv(arglast) >= 0);
- goto donumset;
- case O_SEMOP:
- value = (double)(do_semop(arglast) >= 0);
- goto donumset;
- case O_SHMREAD:
- case O_SHMWRITE:
- value = (double)(do_shmio(optype, arglast) >= 0);
- goto donumset;
-#else /* not SYSVIPC */
- case O_MSGGET:
- case O_MSGCTL:
- case O_MSGSND:
- case O_MSGRCV:
- case O_SEMGET:
- case O_SEMCTL:
- case O_SEMOP:
- case O_SHMGET:
- case O_SHMCTL:
- case O_SHMREAD:
- case O_SHMWRITE:
- fatal("System V IPC is not implemented on this machine");
-#endif /* not SYSVIPC */
- case O_RENAME:
- tmps = str_get(st[1]);
- tmps2 = str_get(st[2]);
-#ifdef TAINT
- taintproper("Insecure dependency in rename");
-#endif
-#ifdef HAS_RENAME
- value = (double)(rename(tmps,tmps2) >= 0);
-#else
- if (same_dirent(tmps2, tmps)) /* can always rename to same name */
- anum = 1;
- else {
- if (euid || stat(tmps2,&statbuf) < 0 || !S_ISDIR(statbuf.st_mode))
- (void)UNLINK(tmps2);
- if (!(anum = link(tmps,tmps2)))
- anum = UNLINK(tmps);
- }
- value = (double)(anum >= 0);
-#endif
- goto donumset;
- case O_LINK:
-#ifdef HAS_LINK
- tmps = str_get(st[1]);
- tmps2 = str_get(st[2]);
-#ifdef TAINT
- taintproper("Insecure dependency in link");
-#endif
- value = (double)(link(tmps,tmps2) >= 0);
- goto donumset;
-#else
- fatal("Unsupported function link");
- break;
-#endif
- case O_MKDIR:
- tmps = str_get(st[1]);
- anum = (int)str_gnum(st[2]);
-#ifdef TAINT
- taintproper("Insecure dependency in mkdir");
-#endif
-#ifdef HAS_MKDIR
- value = (double)(mkdir(tmps,anum) >= 0);
- goto donumset;
-#else
- (void)strcpy(buf,"mkdir ");
-#endif
-#if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
- one_liner:
- for (tmps2 = buf+6; *tmps; ) {
- *tmps2++ = '\\';
- *tmps2++ = *tmps++;
- }
- (void)strcpy(tmps2," 2>&1");
- rsfp = mypopen(buf,"r");
- if (rsfp) {
- *buf = '\0';
- tmps2 = fgets(buf,sizeof buf,rsfp);
- (void)mypclose(rsfp);
- if (tmps2 != Nullch) {
- for (errno = 1; errno < sys_nerr; errno++) {
- if (instr(buf,sys_errlist[errno])) /* you don't see this */
- goto say_zero;
- }
- errno = 0;
-#ifndef EACCES
-#define EACCES EPERM
-#endif
- if (instr(buf,"cannot make"))
- errno = EEXIST;
- else if (instr(buf,"existing file"))
- errno = EEXIST;
- else if (instr(buf,"ile exists"))
- errno = EEXIST;
- else if (instr(buf,"non-exist"))
- errno = ENOENT;
- else if (instr(buf,"does not exist"))
- errno = ENOENT;
- else if (instr(buf,"not empty"))
- errno = EBUSY;
- else if (instr(buf,"cannot access"))
- errno = EACCES;
- else
- errno = EPERM;
- goto say_zero;
- }
- else { /* some mkdirs return no failure indication */
- tmps = str_get(st[1]);
- anum = (stat(tmps,&statbuf) >= 0);
- if (optype == O_RMDIR)
- anum = !anum;
- if (anum)
- errno = 0;
- else
- errno = EACCES; /* a guess */
- value = (double)anum;
- }
- goto donumset;
- }
- else
- goto say_zero;
-#endif
- case O_RMDIR:
- if (maxarg < 1)
- tmps = str_get(stab_val(defstab));
- else
- tmps = str_get(st[1]);
-#ifdef TAINT
- taintproper("Insecure dependency in rmdir");
-#endif
-#ifdef HAS_RMDIR
- value = (double)(rmdir(tmps) >= 0);
- goto donumset;
-#else
- (void)strcpy(buf,"rmdir ");
- goto one_liner; /* see above in HAS_MKDIR */
-#endif
- case O_GETPPID:
-#ifdef HAS_GETPPID
- value = (double)getppid();
- goto donumset;
-#else
- fatal("Unsupported function getppid");
- break;
-#endif
- case O_GETPGRP:
-#ifdef HAS_GETPGRP
- if (maxarg < 1)
- anum = 0;
- else
- anum = (int)str_gnum(st[1]);
-#ifdef _POSIX_SOURCE
- if (anum != 0)
- fatal("POSIX getpgrp can't take an argument");
- value = (double)getpgrp();
-#else
- value = (double)getpgrp(anum);
-#endif
- goto donumset;
-#else
- fatal("The getpgrp() function is unimplemented on this machine");
- break;
-#endif
- case O_SETPGRP:
-#ifdef HAS_SETPGRP
- argtype = (int)str_gnum(st[1]);
- anum = (int)str_gnum(st[2]);
-#ifdef TAINT
- taintproper("Insecure dependency in setpgrp");
-#endif
- value = (double)(setpgrp(argtype,anum) >= 0);
- goto donumset;
-#else
- fatal("The setpgrp() function is unimplemented on this machine");
- break;
-#endif
- case O_GETPRIORITY:
-#ifdef HAS_GETPRIORITY
- argtype = (int)str_gnum(st[1]);
- anum = (int)str_gnum(st[2]);
- value = (double)getpriority(argtype,anum);
- goto donumset;
-#else
- fatal("The getpriority() function is unimplemented on this machine");
- break;
-#endif
- case O_SETPRIORITY:
-#ifdef HAS_SETPRIORITY
- argtype = (int)str_gnum(st[1]);
- anum = (int)str_gnum(st[2]);
- optype = (int)str_gnum(st[3]);
-#ifdef TAINT
- taintproper("Insecure dependency in setpriority");
-#endif
- value = (double)(setpriority(argtype,anum,optype) >= 0);
- goto donumset;
-#else
- fatal("The setpriority() function is unimplemented on this machine");
- break;
-#endif
- case O_CHROOT:
-#ifdef HAS_CHROOT
- if (maxarg < 1)
- tmps = str_get(stab_val(defstab));
- else
- tmps = str_get(st[1]);
-#ifdef TAINT
- taintproper("Insecure dependency in chroot");
-#endif
- value = (double)(chroot(tmps) >= 0);
- goto donumset;
-#else
- fatal("Unsupported function chroot");
- break;
-#endif
- case O_FCNTL:
- case O_IOCTL:
- if (maxarg <= 0)
- stab = last_in_stab;
- else if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- argtype = U_I(str_gnum(st[2]));
-#ifdef TAINT
- taintproper("Insecure dependency in ioctl");
-#endif
- anum = do_ctl(optype,stab,argtype,st[3]);
- if (anum == -1)
- goto say_undef;
- if (anum != 0) {
- value = (double)anum;
- goto donumset;
- }
- str_set(str,"0 but true");
- STABSET(str);
- break;
- case O_FLOCK:
-#ifdef HAS_FLOCK
- if (maxarg <= 0)
- stab = last_in_stab;
- else if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if (stab && stab_io(stab))
- fp = stab_io(stab)->ifp;
- else
- fp = Nullfp;
- if (fp) {
- argtype = (int)str_gnum(st[2]);
- value = (double)(flock(fileno(fp),argtype) >= 0);
- }
- else
- value = 0;
- goto donumset;
-#else
- fatal("The flock() function is unimplemented on this machine");
- break;
-#endif
- case O_UNSHIFT:
- ary = stab_array(arg[1].arg_ptr.arg_stab);
- if (arglast[2] - arglast[1] != 1)
- do_unshift(ary,arglast);
- else {
- STR *tmpstr = Str_new(52,0); /* must copy the STR */
- str_sset(tmpstr,st[2]);
- aunshift(ary,1);
- (void)astore(ary,0,tmpstr);
- }
- value = (double)(ary->ary_fill + 1);
- goto donumset;
-
- case O_TRY:
- sp = do_try(arg[1].arg_ptr.arg_cmd,
- gimme,arglast);
- goto array_return;
-
- case O_EVALONCE:
- sp = do_eval(st[1], O_EVAL, curcmd->c_stash, TRUE,
- gimme,arglast);
- if (eval_root) {
- str_free(arg[1].arg_ptr.arg_str);
- arg[1].arg_ptr.arg_cmd = eval_root;
- arg[1].arg_type = (A_CMD|A_DONT);
- arg[0].arg_type = O_TRY;
- }
- goto array_return;
-
- case O_REQUIRE:
- case O_DOFILE:
- case O_EVAL:
- if (maxarg < 1)
- tmpstr = stab_val(defstab);
- else
- tmpstr =
- (arg[1].arg_type & A_MASK) != A_NULL ? st[1] : stab_val(defstab);
-#ifdef TAINT
- tainted |= tmpstr->str_tainted;
- taintproper("Insecure dependency in eval");
-#endif
- sp = do_eval(tmpstr, optype, curcmd->c_stash, FALSE,
- gimme,arglast);
- goto array_return;
-
- case O_FTRREAD:
- argtype = 0;
- anum = S_IRUSR;
- goto check_perm;
- case O_FTRWRITE:
- argtype = 0;
- anum = S_IWUSR;
- goto check_perm;
- case O_FTREXEC:
- argtype = 0;
- anum = S_IXUSR;
- goto check_perm;
- case O_FTEREAD:
- argtype = 1;
- anum = S_IRUSR;
- goto check_perm;
- case O_FTEWRITE:
- argtype = 1;
- anum = S_IWUSR;
- goto check_perm;
- case O_FTEEXEC:
- argtype = 1;
- anum = S_IXUSR;
- check_perm:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- if (cando(anum,argtype,&statcache))
- goto say_yes;
- goto say_no;
-
- case O_FTIS:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- goto say_yes;
- case O_FTEOWNED:
- case O_FTROWNED:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- if (statcache.st_uid == (optype == O_FTEOWNED ? euid : uid) )
- goto say_yes;
- goto say_no;
- case O_FTZERO:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- if (!statcache.st_size)
- goto say_yes;
- goto say_no;
- case O_FTSIZE:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- value = (double)statcache.st_size;
- goto donumset;
-
- case O_FTMTIME:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- value = (double)(basetime - statcache.st_mtime) / 86400.0;
- goto donumset;
- case O_FTATIME:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- value = (double)(basetime - statcache.st_atime) / 86400.0;
- goto donumset;
- case O_FTCTIME:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- value = (double)(basetime - statcache.st_ctime) / 86400.0;
- goto donumset;
-
- case O_FTSOCK:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- if (S_ISSOCK(statcache.st_mode))
- goto say_yes;
- goto say_no;
- case O_FTCHR:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- if (S_ISCHR(statcache.st_mode))
- goto say_yes;
- goto say_no;
- case O_FTBLK:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- if (S_ISBLK(statcache.st_mode))
- goto say_yes;
- goto say_no;
- case O_FTFILE:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- if (S_ISREG(statcache.st_mode))
- goto say_yes;
- goto say_no;
- case O_FTDIR:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- if (S_ISDIR(statcache.st_mode))
- goto say_yes;
- goto say_no;
- case O_FTPIPE:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- if (S_ISFIFO(statcache.st_mode))
- goto say_yes;
- goto say_no;
- case O_FTLINK:
- if (mylstat(arg,st[1]) < 0)
- goto say_undef;
- if (S_ISLNK(statcache.st_mode))
- goto say_yes;
- goto say_no;
- case O_SYMLINK:
-#ifdef HAS_SYMLINK
- tmps = str_get(st[1]);
- tmps2 = str_get(st[2]);
-#ifdef TAINT
- taintproper("Insecure dependency in symlink");
-#endif
- value = (double)(symlink(tmps,tmps2) >= 0);
- goto donumset;
-#else
- fatal("Unsupported function symlink");
-#endif
- case O_READLINK:
-#ifdef HAS_SYMLINK
- if (maxarg < 1)
- tmps = str_get(stab_val(defstab));
- else
- tmps = str_get(st[1]);
- anum = readlink(tmps,buf,sizeof buf);
- if (anum < 0)
- goto say_undef;
- str_nset(str,buf,anum);
- break;
-#else
- goto say_undef; /* just pretend it's a normal file */
-#endif
- case O_FTSUID:
-#ifdef S_ISUID
- anum = S_ISUID;
- goto check_xid;
-#else
- goto say_no;
-#endif
- case O_FTSGID:
-#ifdef S_ISGID
- anum = S_ISGID;
- goto check_xid;
-#else
- goto say_no;
-#endif
- case O_FTSVTX:
-#ifdef S_ISVTX
- anum = S_ISVTX;
-#else
- goto say_no;
-#endif
- check_xid:
- if (mystat(arg,st[1]) < 0)
- goto say_undef;
- if (statcache.st_mode & anum)
- goto say_yes;
- goto say_no;
- case O_FTTTY:
- if (arg[1].arg_type & A_DONT) {
- stab = arg[1].arg_ptr.arg_stab;
- tmps = "";
- }
- else
- stab = stabent(tmps = str_get(st[1]),FALSE);
- if (stab && stab_io(stab) && stab_io(stab)->ifp)
- anum = fileno(stab_io(stab)->ifp);
- else if (isDIGIT(*tmps))
- anum = atoi(tmps);
- else
- goto say_undef;
- if (isatty(anum))
- goto say_yes;
- goto say_no;
- case O_FTTEXT:
- case O_FTBINARY:
- str = do_fttext(arg,st[1]);
- break;
-#ifdef HAS_SOCKET
- case O_SOCKET:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
-#ifndef lint
- value = (double)do_socket(stab,arglast);
-#else
- (void)do_socket(stab,arglast);
-#endif
- goto donumset;
- case O_BIND:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
-#ifndef lint
- value = (double)do_bind(stab,arglast);
-#else
- (void)do_bind(stab,arglast);
-#endif
- goto donumset;
- case O_CONNECT:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
-#ifndef lint
- value = (double)do_connect(stab,arglast);
-#else
- (void)do_connect(stab,arglast);
-#endif
- goto donumset;
- case O_LISTEN:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
-#ifndef lint
- value = (double)do_listen(stab,arglast);
-#else
- (void)do_listen(stab,arglast);
-#endif
- goto donumset;
- case O_ACCEPT:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if ((arg[2].arg_type & A_MASK) == A_WORD)
- stab2 = arg[2].arg_ptr.arg_stab;
- else
- stab2 = stabent(str_get(st[2]),TRUE);
- do_accept(str,stab,stab2);
- STABSET(str);
- break;
- case O_GHBYNAME:
- if (maxarg < 1)
- goto say_undef;
- case O_GHBYADDR:
- case O_GHOSTENT:
- sp = do_ghent(optype,
- gimme,arglast);
- goto array_return;
- case O_GNBYNAME:
- if (maxarg < 1)
- goto say_undef;
- case O_GNBYADDR:
- case O_GNETENT:
- sp = do_gnent(optype,
- gimme,arglast);
- goto array_return;
- case O_GPBYNAME:
- if (maxarg < 1)
- goto say_undef;
- case O_GPBYNUMBER:
- case O_GPROTOENT:
- sp = do_gpent(optype,
- gimme,arglast);
- goto array_return;
- case O_GSBYNAME:
- if (maxarg < 1)
- goto say_undef;
- case O_GSBYPORT:
- case O_GSERVENT:
- sp = do_gsent(optype,
- gimme,arglast);
- goto array_return;
- case O_SHOSTENT:
- value = (double) sethostent((int)str_gnum(st[1]));
- goto donumset;
- case O_SNETENT:
- value = (double) setnetent((int)str_gnum(st[1]));
- goto donumset;
- case O_SPROTOENT:
- value = (double) setprotoent((int)str_gnum(st[1]));
- goto donumset;
- case O_SSERVENT:
- value = (double) setservent((int)str_gnum(st[1]));
- goto donumset;
- case O_EHOSTENT:
- value = (double) endhostent();
- goto donumset;
- case O_ENETENT:
- value = (double) endnetent();
- goto donumset;
- case O_EPROTOENT:
- value = (double) endprotoent();
- goto donumset;
- case O_ESERVENT:
- value = (double) endservent();
- goto donumset;
- case O_SOCKPAIR:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if ((arg[2].arg_type & A_MASK) == A_WORD)
- stab2 = arg[2].arg_ptr.arg_stab;
- else
- stab2 = stabent(str_get(st[2]),TRUE);
-#ifndef lint
- value = (double)do_spair(stab,stab2,arglast);
-#else
- (void)do_spair(stab,stab2,arglast);
-#endif
- goto donumset;
- case O_SHUTDOWN:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
-#ifndef lint
- value = (double)do_shutdown(stab,arglast);
-#else
- (void)do_shutdown(stab,arglast);
-#endif
- goto donumset;
- case O_GSOCKOPT:
- case O_SSOCKOPT:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- sp = do_sopt(optype,stab,arglast);
- goto array_return;
- case O_GETSOCKNAME:
- case O_GETPEERNAME:
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if (!stab)
- goto say_undef;
- sp = do_getsockname(optype,stab,arglast);
- goto array_return;
-
-#else /* HAS_SOCKET not defined */
- case O_SOCKET:
- case O_BIND:
- case O_CONNECT:
- case O_LISTEN:
- case O_ACCEPT:
- case O_SOCKPAIR:
- case O_GHBYNAME:
- case O_GHBYADDR:
- case O_GHOSTENT:
- case O_GNBYNAME:
- case O_GNBYADDR:
- case O_GNETENT:
- case O_GPBYNAME:
- case O_GPBYNUMBER:
- case O_GPROTOENT:
- case O_GSBYNAME:
- case O_GSBYPORT:
- case O_GSERVENT:
- case O_SHOSTENT:
- case O_SNETENT:
- case O_SPROTOENT:
- case O_SSERVENT:
- case O_EHOSTENT:
- case O_ENETENT:
- case O_EPROTOENT:
- case O_ESERVENT:
- case O_SHUTDOWN:
- case O_GSOCKOPT:
- case O_SSOCKOPT:
- case O_GETSOCKNAME:
- case O_GETPEERNAME:
- badsock:
- fatal("Unsupported socket function");
-#endif /* HAS_SOCKET */
- case O_SSELECT:
-#ifdef HAS_SELECT
- sp = do_select(gimme,arglast);
- goto array_return;
-#else
- fatal("select not implemented");
-#endif
- case O_FILENO:
- if (maxarg < 1)
- goto say_undef;
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if (!stab || !(stio = stab_io(stab)) || !(fp = stio->ifp))
- goto say_undef;
- value = fileno(fp);
- goto donumset;
- case O_BINMODE:
- if (maxarg < 1)
- goto say_undef;
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if (!stab || !(stio = stab_io(stab)) || !(fp = stio->ifp))
- goto say_undef;
-#ifdef DOSISH
-#ifdef atarist
- if(fflush(fp))
- str_set(str, No);
- else
- {
- fp->_flag |= _IOBIN;
- str_set(str, Yes);
- }
-#else
- str_set(str, (setmode(fileno(fp), O_BINARY) != -1) ? Yes : No);
-#endif
-#else
- str_set(str, Yes);
-#endif
- STABSET(str);
- break;
- case O_VEC:
- sp = do_vec(str == st[1], arg->arg_ptr.arg_str, arglast);
- goto array_return;
- case O_GPWNAM:
- case O_GPWUID:
- case O_GPWENT:
-#ifdef HAS_PASSWD
- sp = do_gpwent(optype,
- gimme,arglast);
- goto array_return;
- case O_SPWENT:
- value = (double) setpwent();
- goto donumset;
- case O_EPWENT:
- value = (double) endpwent();
- goto donumset;
-#else
- case O_EPWENT:
- case O_SPWENT:
- fatal("Unsupported password function");
- break;
-#endif
- case O_GGRNAM:
- case O_GGRGID:
- case O_GGRENT:
-#ifdef HAS_GROUP
- sp = do_ggrent(optype,
- gimme,arglast);
- goto array_return;
- case O_SGRENT:
- value = (double) setgrent();
- goto donumset;
- case O_EGRENT:
- value = (double) endgrent();
- goto donumset;
-#else
- case O_EGRENT:
- case O_SGRENT:
- fatal("Unsupported group function");
- break;
-#endif
- case O_GETLOGIN:
-#ifdef HAS_GETLOGIN
- if (!(tmps = getlogin()))
- goto say_undef;
- str_set(str,tmps);
-#else
- fatal("Unsupported function getlogin");
-#endif
- break;
- case O_OPEN_DIR:
- case O_READDIR:
- case O_TELLDIR:
- case O_SEEKDIR:
- case O_REWINDDIR:
- case O_CLOSEDIR:
- if (maxarg < 1)
- goto say_undef;
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if (!stab)
- goto say_undef;
- sp = do_dirop(optype,stab,gimme,arglast);
- goto array_return;
- case O_SYSCALL:
- value = (double)do_syscall(arglast);
- goto donumset;
- case O_PIPE_OP:
-#ifdef HAS_PIPE
- if ((arg[1].arg_type & A_MASK) == A_WORD)
- stab = arg[1].arg_ptr.arg_stab;
- else
- stab = stabent(str_get(st[1]),TRUE);
- if ((arg[2].arg_type & A_MASK) == A_WORD)
- stab2 = arg[2].arg_ptr.arg_stab;
- else
- stab2 = stabent(str_get(st[2]),TRUE);
- do_pipe(str,stab,stab2);
- STABSET(str);
-#else
- fatal("Unsupported function pipe");
-#endif
- break;
- }
-
- normal_return:
- st[1] = str;
-#ifdef DEBUGGING
- if (debug) {
- dlevel--;
- if (debug & 8)
- deb("%s RETURNS \"%s\"\n",opname[optype],str_get(str));
- }
-#endif
- return arglast[0] + 1;
-}
diff --git a/gnu/usr.bin/perl/perl/form.c b/gnu/usr.bin/perl/perl/form.c
deleted file mode 100644
index cfb7aed..0000000
--- a/gnu/usr.bin/perl/perl/form.c
+++ /dev/null
@@ -1,422 +0,0 @@
-/* $RCSfile: form.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:33 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: form.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:33 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:36 nate
- * PERL!
- *
- * Revision 4.0.1.4 1993/02/05 19:34:32 lwall
- * patch36: formats now ignore literal text for ~~ loop determination
- *
- * Revision 4.0.1.3 92/06/08 13:21:42 lwall
- * patch20: removed implicit int declarations on funcions
- * patch20: form feed for formats is now specifiable via $^L
- * patch20: Perl now distinguishes overlapped copies from non-overlapped
- *
- * Revision 4.0.1.2 91/11/05 17:18:43 lwall
- * patch11: formats didn't fill their fields as well as they could
- * patch11: ^ fields chopped hyphens on line break
- * patch11: # fields could write outside allocated memory
- *
- * Revision 4.0.1.1 91/06/07 11:07:59 lwall
- * patch4: new copyright notice
- * patch4: default top-of-form format is now FILEHANDLE_TOP
- *
- * Revision 4.0 91/03/20 01:19:23 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-/* Forms stuff */
-
-static int countlines();
-
-void
-form_parseargs(fcmd)
-register FCMD *fcmd;
-{
- register int i;
- register ARG *arg;
- register int items;
- STR *str;
- ARG *parselist();
- line_t oldline = curcmd->c_line;
- int oldsave = savestack->ary_fill;
-
- str = fcmd->f_unparsed;
- curcmd->c_line = fcmd->f_line;
- fcmd->f_unparsed = Nullstr;
- (void)savehptr(&curstash);
- curstash = str->str_u.str_hash;
- arg = parselist(str);
- restorelist(oldsave);
-
- items = arg->arg_len - 1; /* ignore $$ on end */
- for (i = 1; i <= items; i++) {
- if (!fcmd || fcmd->f_type == F_NULL)
- fatal("Too many field values");
- dehoist(arg,i);
- fcmd->f_expr = make_op(O_ITEM,1,
- arg[i].arg_ptr.arg_arg,Nullarg,Nullarg);
- if (fcmd->f_flags & FC_CHOP) {
- if ((fcmd->f_expr[1].arg_type & A_MASK) == A_STAB)
- fcmd->f_expr[1].arg_type = A_LVAL;
- else if ((fcmd->f_expr[1].arg_type & A_MASK) == A_EXPR)
- fcmd->f_expr[1].arg_type = A_LEXPR;
- else
- fatal("^ field requires scalar lvalue");
- }
- fcmd = fcmd->f_next;
- }
- if (fcmd && fcmd->f_type)
- fatal("Not enough field values");
- curcmd->c_line = oldline;
- Safefree(arg);
- str_free(str);
-}
-
-int newsize;
-
-#define CHKLEN(allow) \
-newsize = (d - orec->o_str) + (allow); \
-if (newsize >= curlen) { \
- curlen = d - orec->o_str; \
- GROWSTR(&orec->o_str,&orec->o_len,orec->o_len + (allow)); \
- d = orec->o_str + curlen; /* in case it moves */ \
- curlen = orec->o_len - 2; \
-}
-
-void
-format(orec,fcmd,sp)
-register struct outrec *orec;
-register FCMD *fcmd;
-int sp;
-{
- register char *d = orec->o_str;
- register char *s;
- register int curlen = orec->o_len - 2;
- register int size;
- FCMD *nextfcmd;
- FCMD *linebeg = fcmd;
- char tmpchar;
- char *t;
- CMD mycmd;
- STR *str;
- char *chophere;
- int blank = TRUE;
-
- mycmd.c_type = C_NULL;
- orec->o_lines = 0;
- for (; fcmd; fcmd = nextfcmd) {
- nextfcmd = fcmd->f_next;
- CHKLEN(fcmd->f_presize);
- /*SUPPRESS 560*/
- if (s = fcmd->f_pre) {
- while (*s) {
- if (*s == '\n') {
- t = orec->o_str;
- if (blank && (fcmd->f_flags & FC_REPEAT)) {
- while (d > t && (d[-1] != '\n'))
- d--;
- }
- else {
- while (d > t && (d[-1] == ' ' || d[-1] == '\t'))
- d--;
- }
- if (fcmd->f_flags & FC_NOBLANK) {
- if (blank || d == orec->o_str || d[-1] == '\n') {
- orec->o_lines--; /* don't print blank line */
- linebeg = fcmd->f_next;
- break;
- }
- else if (fcmd->f_flags & FC_REPEAT)
- nextfcmd = linebeg;
- else
- linebeg = fcmd->f_next;
- }
- else
- linebeg = fcmd->f_next;
- blank = TRUE;
- }
- *d++ = *s++;
- }
- }
- if (fcmd->f_unparsed)
- form_parseargs(fcmd);
- switch (fcmd->f_type) {
- case F_NULL:
- orec->o_lines++;
- break;
- case F_LEFT:
- (void)eval(fcmd->f_expr,G_SCALAR,sp);
- str = stack->ary_array[sp+1];
- s = str_get(str);
- size = fcmd->f_size;
- CHKLEN(size);
- chophere = Nullch;
- while (size && *s && *s != '\n') {
- if (*s == '\t')
- *s = ' ';
- else if (*s != ' ')
- blank = FALSE;
- size--;
- if (*s && index(chopset,(*d++ = *s++)))
- chophere = s;
- if (*s == '\n' && (fcmd->f_flags & FC_CHOP))
- *s = ' ';
- }
- if (size || !*s)
- chophere = s;
- else if (chophere && chophere < s && *s && index(chopset,*s))
- chophere = s;
- if (fcmd->f_flags & FC_CHOP) {
- if (!chophere)
- chophere = s;
- size += (s - chophere);
- d -= (s - chophere);
- if (fcmd->f_flags & FC_MORE &&
- *chophere && strNE(chophere,"\n")) {
- while (size < 3) {
- d--;
- size++;
- }
- while (d[-1] == ' ' && size < fcmd->f_size) {
- d--;
- size++;
- }
- *d++ = '.';
- *d++ = '.';
- *d++ = '.';
- size -= 3;
- }
- while (*chophere && index(chopset,*chophere)
- && isSPACE(*chophere))
- chophere++;
- str_chop(str,chophere);
- }
- if (fcmd->f_next && fcmd->f_next->f_pre[0] == '\n')
- size = 0; /* no spaces before newline */
- while (size) {
- size--;
- *d++ = ' ';
- }
- break;
- case F_RIGHT:
- (void)eval(fcmd->f_expr,G_SCALAR,sp);
- str = stack->ary_array[sp+1];
- t = s = str_get(str);
- size = fcmd->f_size;
- CHKLEN(size);
- chophere = Nullch;
- while (size && *s && *s != '\n') {
- if (*s == '\t')
- *s = ' ';
- else if (*s != ' ')
- blank = FALSE;
- size--;
- if (*s && index(chopset,*s++))
- chophere = s;
- if (*s == '\n' && (fcmd->f_flags & FC_CHOP))
- *s = ' ';
- }
- if (size || !*s)
- chophere = s;
- else if (chophere && chophere < s && *s && index(chopset,*s))
- chophere = s;
- if (fcmd->f_flags & FC_CHOP) {
- if (!chophere)
- chophere = s;
- size += (s - chophere);
- s = chophere;
- while (*chophere && index(chopset,*chophere)
- && isSPACE(*chophere))
- chophere++;
- }
- tmpchar = *s;
- *s = '\0';
- while (size) {
- size--;
- *d++ = ' ';
- }
- size = s - t;
- Copy(t,d,size,char);
- d += size;
- *s = tmpchar;
- if (fcmd->f_flags & FC_CHOP)
- str_chop(str,chophere);
- break;
- case F_CENTER: {
- int halfsize;
-
- (void)eval(fcmd->f_expr,G_SCALAR,sp);
- str = stack->ary_array[sp+1];
- t = s = str_get(str);
- size = fcmd->f_size;
- CHKLEN(size);
- chophere = Nullch;
- while (size && *s && *s != '\n') {
- if (*s == '\t')
- *s = ' ';
- else if (*s != ' ')
- blank = FALSE;
- size--;
- if (*s && index(chopset,*s++))
- chophere = s;
- if (*s == '\n' && (fcmd->f_flags & FC_CHOP))
- *s = ' ';
- }
- if (size || !*s)
- chophere = s;
- else if (chophere && chophere < s && *s && index(chopset,*s))
- chophere = s;
- if (fcmd->f_flags & FC_CHOP) {
- if (!chophere)
- chophere = s;
- size += (s - chophere);
- s = chophere;
- while (*chophere && index(chopset,*chophere)
- && isSPACE(*chophere))
- chophere++;
- }
- tmpchar = *s;
- *s = '\0';
- halfsize = size / 2;
- while (size > halfsize) {
- size--;
- *d++ = ' ';
- }
- size = s - t;
- Copy(t,d,size,char);
- d += size;
- *s = tmpchar;
- if (fcmd->f_next && fcmd->f_next->f_pre[0] == '\n')
- size = 0; /* no spaces before newline */
- else
- size = halfsize;
- while (size) {
- size--;
- *d++ = ' ';
- }
- if (fcmd->f_flags & FC_CHOP)
- str_chop(str,chophere);
- break;
- }
- case F_LINES:
- (void)eval(fcmd->f_expr,G_SCALAR,sp);
- str = stack->ary_array[sp+1];
- s = str_get(str);
- size = str_len(str);
- CHKLEN(size+1);
- orec->o_lines += countlines(s,size) - 1;
- Copy(s,d,size,char);
- d += size;
- if (size && s[size-1] != '\n') {
- *d++ = '\n';
- orec->o_lines++;
- }
- linebeg = fcmd->f_next;
- break;
- case F_DECIMAL: {
- double value;
-
- (void)eval(fcmd->f_expr,G_SCALAR,sp);
- str = stack->ary_array[sp+1];
- size = fcmd->f_size;
- CHKLEN(size+1);
- /* If the field is marked with ^ and the value is undefined,
- blank it out. */
- if ((fcmd->f_flags & FC_CHOP) && !str->str_pok && !str->str_nok) {
- while (size) {
- size--;
- *d++ = ' ';
- }
- break;
- }
- blank = FALSE;
- value = str_gnum(str);
- if (fcmd->f_flags & FC_DP) {
- sprintf(d, "%#*.*f", size, fcmd->f_decimals, value);
- } else {
- sprintf(d, "%*.0f", size, value);
- }
- d += size;
- break;
- }
- }
- }
- CHKLEN(1);
- *d++ = '\0';
-}
-
-static int
-countlines(s,size)
-register char *s;
-register int size;
-{
- register int count = 0;
-
- while (size--) {
- if (*s++ == '\n')
- count++;
- }
- return count;
-}
-
-void
-do_write(orec,stab,sp)
-struct outrec *orec;
-STAB *stab;
-int sp;
-{
- register STIO *stio = stab_io(stab);
- FILE *ofp = stio->ofp;
-
-#ifdef DEBUGGING
- if (debug & 256)
- fprintf(stderr,"left=%ld, todo=%ld\n",
- (long)stio->lines_left, (long)orec->o_lines);
-#endif
- if (stio->lines_left < orec->o_lines) {
- if (!stio->top_stab) {
- STAB *topstab;
- char tmpbuf[256];
-
- if (!stio->top_name) {
- if (!stio->fmt_name)
- stio->fmt_name = savestr(stab_name(stab));
- sprintf(tmpbuf, "%s_TOP", stio->fmt_name);
- topstab = stabent(tmpbuf,FALSE);
- if (topstab && stab_form(topstab))
- stio->top_name = savestr(tmpbuf);
- else
- stio->top_name = savestr("top");
- }
- topstab = stabent(stio->top_name,FALSE);
- if (!topstab || !stab_form(topstab)) {
- stio->lines_left = 100000000;
- goto forget_top;
- }
- stio->top_stab = topstab;
- }
- if (stio->lines_left >= 0 && stio->page > 0)
- fwrite(formfeed->str_ptr, formfeed->str_cur, 1, ofp);
- stio->lines_left = stio->page_len;
- stio->page++;
- format(&toprec,stab_form(stio->top_stab),sp);
- fputs(toprec.o_str,ofp);
- stio->lines_left -= toprec.o_lines;
- }
- forget_top:
- fputs(orec->o_str,ofp);
- stio->lines_left -= orec->o_lines;
-}
diff --git a/gnu/usr.bin/perl/perl/form.h b/gnu/usr.bin/perl/perl/form.h
deleted file mode 100644
index 3f63289..0000000
--- a/gnu/usr.bin/perl/perl/form.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* $RCSfile: form.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:34 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: form.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:36 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 11:08:20 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:19:37 lwall
- * 4.0 baseline.
- *
- */
-
-#define F_NULL 0
-#define F_LEFT 1
-#define F_RIGHT 2
-#define F_CENTER 3
-#define F_LINES 4
-#define F_DECIMAL 5
-
-struct formcmd {
- struct formcmd *f_next;
- ARG *f_expr;
- STR *f_unparsed;
- line_t f_line;
- char *f_pre;
- short f_presize;
- short f_size;
- short f_decimals;
- char f_type;
- char f_flags;
-};
-
-#define FC_CHOP 1
-#define FC_NOBLANK 2
-#define FC_MORE 4
-#define FC_REPEAT 8
-#define FC_DP 16
-
-#define Nullfcmd Null(FCMD*)
-
-EXT char *chopset INIT(" \n-");
diff --git a/gnu/usr.bin/perl/perl/handy.h b/gnu/usr.bin/perl/perl/handy.h
deleted file mode 100644
index df71984..0000000
--- a/gnu/usr.bin/perl/perl/handy.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/* $RCSfile: handy.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:34 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: handy.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:36 nate
- * PERL!
- *
- * Revision 4.0.1.4 92/06/08 13:23:17 lwall
- * patch20: isascii() may now be supplied by a library routine
- * patch20: Perl now distinguishes overlapped copies from non-overlapped
- *
- * Revision 4.0.1.3 91/11/05 22:54:26 lwall
- * patch11: erratum
- *
- * Revision 4.0.1.2 91/11/05 17:23:38 lwall
- * patch11: prepared for ctype implementations that don't define isascii()
- *
- * Revision 4.0.1.1 91/06/07 11:09:56 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:22:15 lwall
- * 4.0 baseline.
- *
- */
-
-#ifdef NULL
-#undef NULL
-#endif
-#ifndef I286
-# define NULL 0
-#else
-# define NULL 0L
-#endif
-#define Null(type) ((type)NULL)
-#define Nullch Null(char*)
-#define Nullfp Null(FILE*)
-
-#ifdef UTS
-#define bool int
-#else
-#define bool char
-#endif
-
-#ifdef TRUE
-#undef TRUE
-#endif
-#ifdef FALSE
-#undef FALSE
-#endif
-#define TRUE (1)
-#define FALSE (0)
-
-#define Ctl(ch) (ch & 037)
-
-#define strNE(s1,s2) (strcmp(s1,s2))
-#define strEQ(s1,s2) (!strcmp(s1,s2))
-#define strLT(s1,s2) (strcmp(s1,s2) < 0)
-#define strLE(s1,s2) (strcmp(s1,s2) <= 0)
-#define strGT(s1,s2) (strcmp(s1,s2) > 0)
-#define strGE(s1,s2) (strcmp(s1,s2) >= 0)
-#define strnNE(s1,s2,l) (strncmp(s1,s2,l))
-#define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))
-
-#if defined(CTYPE256) || (!defined(isascii) && !defined(HAS_ISASCII))
-#define isALNUM(c) (isalpha(c) || isdigit(c) || c == '_')
-#define isALPHA(c) isalpha(c)
-#define isSPACE(c) isspace(c)
-#define isDIGIT(c) isdigit(c)
-#define isUPPER(c) isupper(c)
-#define isLOWER(c) islower(c)
-#else
-#define isALNUM(c) (isascii(c) && (isalpha(c) || isdigit(c) || c == '_'))
-#define isALPHA(c) (isascii(c) && isalpha(c))
-#define isSPACE(c) (isascii(c) && isspace(c))
-#define isDIGIT(c) (isascii(c) && isdigit(c))
-#define isUPPER(c) (isascii(c) && isupper(c))
-#define isLOWER(c) (isascii(c) && islower(c))
-#endif
-
-/* Line numbers are unsigned, 16 bits. */
-typedef unsigned short line_t;
-#ifdef lint
-#define NOLINE ((line_t)0)
-#else
-#define NOLINE ((line_t) 65535)
-#endif
-
-#ifndef lint
-#ifndef LEAKTEST
-#ifndef safemalloc
-char *safemalloc();
-char *saferealloc();
-void safefree();
-#endif
-#ifndef MSDOS
-#define New(x,v,n,t) (v = (t*)safemalloc((MEM_SIZE)((n) * sizeof(t))))
-#define Newc(x,v,n,t,c) (v = (c*)safemalloc((MEM_SIZE)((n) * sizeof(t))))
-#define Newz(x,v,n,t) (v = (t*)safemalloc((MEM_SIZE)((n) * sizeof(t)))), \
- memzero((char*)(v), (n) * sizeof(t))
-#define Renew(v,n,t) (v = (t*)saferealloc((char*)(v),(MEM_SIZE)((n)*sizeof(t))))
-#define Renewc(v,n,t,c) (v = (c*)saferealloc((char*)(v),(MEM_SIZE)((n)*sizeof(t))))
-#else
-#define New(x,v,n,t) (v = (t*)safemalloc(((unsigned long)(n) * sizeof(t))))
-#define Newc(x,v,n,t,c) (v = (c*)safemalloc(((unsigned long)(n) * sizeof(t))))
-#define Newz(x,v,n,t) (v = (t*)safemalloc(((unsigned long)(n) * sizeof(t)))), \
- memzero((char*)(v), (n) * sizeof(t))
-#define Renew(v,n,t) (v = (t*)saferealloc((char*)(v),((unsigned long)(n)*sizeof(t))))
-#define Renewc(v,n,t,c) (v = (c*)saferealloc((char*)(v),((unsigned long)(n)*sizeof(t))))
-#endif /* MSDOS */
-#define Safefree(d) safefree((char*)d)
-#define Str_new(x,len) str_new(len)
-#else /* LEAKTEST */
-char *safexmalloc();
-char *safexrealloc();
-void safexfree();
-#define New(x,v,n,t) (v = (t*)safexmalloc(x,(MEM_SIZE)((n) * sizeof(t))))
-#define Newc(x,v,n,t,c) (v = (c*)safexmalloc(x,(MEM_SIZE)((n) * sizeof(t))))
-#define Newz(x,v,n,t) (v = (t*)safexmalloc(x,(MEM_SIZE)((n) * sizeof(t)))), \
- memzero((char*)(v), (n) * sizeof(t))
-#define Renew(v,n,t) (v = (t*)safexrealloc((char*)(v),(MEM_SIZE)((n)*sizeof(t))))
-#define Renewc(v,n,t,c) (v = (c*)safexrealloc((char*)(v),(MEM_SIZE)((n)*sizeof(t))))
-#define Safefree(d) safexfree((char*)d)
-#define Str_new(x,len) str_new(x,len)
-#define MAXXCOUNT 1200
-long xcount[MAXXCOUNT];
-long lastxcount[MAXXCOUNT];
-#endif /* LEAKTEST */
-#define Move(s,d,n,t) (void)memmove((char*)(d),(char*)(s), (n) * sizeof(t))
-#define Copy(s,d,n,t) (void)memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
-#define Zero(d,n,t) (void)memzero((char*)(d), (n) * sizeof(t))
-#else /* lint */
-#define New(x,v,n,s) (v = Null(s *))
-#define Newc(x,v,n,s,c) (v = Null(s *))
-#define Newz(x,v,n,s) (v = Null(s *))
-#define Renew(v,n,s) (v = Null(s *))
-#define Move(s,d,n,t)
-#define Copy(s,d,n,t)
-#define Zero(d,n,t)
-#define Safefree(d) d = d
-#endif /* lint */
-
-#ifdef STRUCTCOPY
-#define StructCopy(s,d,t) *((t*)(d)) = *((t*)(s))
-#else
-#define StructCopy(s,d,t) Copy(s,d,1,t)
-#endif
diff --git a/gnu/usr.bin/perl/perl/hash.c b/gnu/usr.bin/perl/perl/hash.c
deleted file mode 100644
index 5d9b594..0000000
--- a/gnu/usr.bin/perl/perl/hash.c
+++ /dev/null
@@ -1,718 +0,0 @@
-/* $RCSfile: hash.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:33 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: hash.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:33 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:37 nate
- * PERL!
- *
- * Revision 4.0.1.3 92/06/08 13:26:29 lwall
- * patch20: removed implicit int declarations on functions
- * patch20: delete could cause %array to give too low a count of buckets filled
- * patch20: hash tables now split only if the memory is available to do so
- *
- * Revision 4.0.1.2 91/11/05 17:24:13 lwall
- * patch11: saberized perl
- *
- * Revision 4.0.1.1 91/06/07 11:10:11 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:22:26 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-static void hsplit();
-
-static char coeff[] = {
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1};
-
-static void hfreeentries();
-
-STR *
-hfetch(tb,key,klen,lval)
-register HASH *tb;
-char *key;
-unsigned int klen;
-int lval;
-{
- register char *s;
- register int i;
- register int hash;
- register HENT *entry;
- register int maxi;
- STR *str;
-#ifdef SOME_DBM
- datum dkey,dcontent;
-#endif
-
- if (!tb)
- return &str_undef;
- if (!tb->tbl_array) {
- if (lval)
- Newz(503,tb->tbl_array, tb->tbl_max + 1, HENT*);
- else
- return &str_undef;
- }
-
- /* The hash function we use on symbols has to be equal to the first
- * character when taken modulo 128, so that str_reset() can be implemented
- * efficiently. We throw in the second character and the last character
- * (times 128) so that long chains of identifiers starting with the
- * same letter don't have to be strEQ'ed within hfetch(), since it
- * compares hash values before trying strEQ().
- */
- if (!tb->tbl_coeffsize)
- hash = *key + 128 * key[1] + 128 * key[klen-1]; /* assuming klen > 0 */
- else { /* use normal coefficients */
- if (klen < tb->tbl_coeffsize)
- maxi = klen;
- else
- maxi = tb->tbl_coeffsize;
- for (s=key, i=0, hash = 0;
- i < maxi; /*SUPPRESS 8*/
- s++, i++, hash *= 5) {
- hash += *s * coeff[i];
- }
- }
-
- entry = tb->tbl_array[hash & tb->tbl_max];
- for (; entry; entry = entry->hent_next) {
- if (entry->hent_hash != hash) /* strings can't be equal */
- continue;
- if (entry->hent_klen != klen)
- continue;
- if (bcmp(entry->hent_key,key,klen)) /* is this it? */
- continue;
- return entry->hent_val;
- }
-#ifdef SOME_DBM
- if (tb->tbl_dbm) {
- dkey.dptr = key;
- dkey.dsize = klen;
-#ifdef HAS_GDBM
- dcontent = gdbm_fetch(tb->tbl_dbm,dkey);
-#else
- dcontent = dbm_fetch(tb->tbl_dbm,dkey);
-#endif
- if (dcontent.dptr) { /* found one */
- str = Str_new(60,dcontent.dsize);
- str_nset(str,dcontent.dptr,dcontent.dsize);
- hstore(tb,key,klen,str,hash); /* cache it */
- return str;
- }
- }
-#endif
- if (lval) { /* gonna assign to this, so it better be there */
- str = Str_new(61,0);
- hstore(tb,key,klen,str,hash);
- return str;
- }
- return &str_undef;
-}
-
-bool
-hstore(tb,key,klen,val,hash)
-register HASH *tb;
-char *key;
-unsigned int klen;
-STR *val;
-register int hash;
-{
- register char *s;
- register int i;
- register HENT *entry;
- register HENT **oentry;
- register int maxi;
-
- if (!tb)
- return FALSE;
-
- if (hash)
- /*SUPPRESS 530*/
- ;
- else if (!tb->tbl_coeffsize)
- hash = *key + 128 * key[1] + 128 * key[klen-1];
- else { /* use normal coefficients */
- if (klen < tb->tbl_coeffsize)
- maxi = klen;
- else
- maxi = tb->tbl_coeffsize;
- for (s=key, i=0, hash = 0;
- i < maxi; /*SUPPRESS 8*/
- s++, i++, hash *= 5) {
- hash += *s * coeff[i];
- }
- }
-
- if (!tb->tbl_array)
- Newz(505,tb->tbl_array, tb->tbl_max + 1, HENT*);
-
- oentry = &(tb->tbl_array[hash & tb->tbl_max]);
- i = 1;
-
- for (entry = *oentry; entry; i=0, entry = entry->hent_next) {
- if (entry->hent_hash != hash) /* strings can't be equal */
- continue;
- if (entry->hent_klen != klen)
- continue;
- if (bcmp(entry->hent_key,key,klen)) /* is this it? */
- continue;
- Safefree(entry->hent_val);
- entry->hent_val = val;
- return TRUE;
- }
- New(501,entry, 1, HENT);
-
- entry->hent_klen = klen;
- entry->hent_key = nsavestr(key,klen);
- entry->hent_val = val;
- entry->hent_hash = hash;
- entry->hent_next = *oentry;
- *oentry = entry;
-
- /* hdbmstore not necessary here because it's called from stabset() */
-
- if (i) { /* initial entry? */
- tb->tbl_fill++;
-#ifdef SOME_DBM
- if (tb->tbl_dbm && tb->tbl_max >= DBM_CACHE_MAX)
- return FALSE;
-#endif
- if (tb->tbl_fill > tb->tbl_dosplit)
- hsplit(tb);
- }
-#ifdef SOME_DBM
- else if (tb->tbl_dbm) { /* is this just a cache for dbm file? */
- void hentdelayfree();
-
- entry = tb->tbl_array[hash & tb->tbl_max];
- oentry = &entry->hent_next;
- entry = *oentry;
- while (entry) { /* trim chain down to 1 entry */
- *oentry = entry->hent_next;
- hentdelayfree(entry); /* no doubt they'll want this next. */
- entry = *oentry;
- }
- }
-#endif
-
- return FALSE;
-}
-
-STR *
-hdelete(tb,key,klen)
-register HASH *tb;
-char *key;
-unsigned int klen;
-{
- register char *s;
- register int i;
- register int hash;
- register HENT *entry;
- register HENT **oentry;
- STR *str;
- int maxi;
-#ifdef SOME_DBM
- datum dkey;
-#endif
-
- if (!tb || !tb->tbl_array)
- return Nullstr;
- if (!tb->tbl_coeffsize)
- hash = *key + 128 * key[1] + 128 * key[klen-1];
- else { /* use normal coefficients */
- if (klen < tb->tbl_coeffsize)
- maxi = klen;
- else
- maxi = tb->tbl_coeffsize;
- for (s=key, i=0, hash = 0;
- i < maxi; /*SUPPRESS 8*/
- s++, i++, hash *= 5) {
- hash += *s * coeff[i];
- }
- }
-
- oentry = &(tb->tbl_array[hash & tb->tbl_max]);
- entry = *oentry;
- i = 1;
- for (; entry; i=0, oentry = &entry->hent_next, entry = *oentry) {
- if (entry->hent_hash != hash) /* strings can't be equal */
- continue;
- if (entry->hent_klen != klen)
- continue;
- if (bcmp(entry->hent_key,key,klen)) /* is this it? */
- continue;
- *oentry = entry->hent_next;
- if (i && !*oentry)
- tb->tbl_fill--;
- str = str_mortal(entry->hent_val);
- hentfree(entry);
-#ifdef SOME_DBM
- do_dbm_delete:
- if (tb->tbl_dbm) {
- dkey.dptr = key;
- dkey.dsize = klen;
-#ifdef HAS_GDBM
- gdbm_delete(tb->tbl_dbm,dkey);
-#else
- dbm_delete(tb->tbl_dbm,dkey);
-#endif
- }
-#endif
- return str;
- }
-#ifdef SOME_DBM
- str = Nullstr;
- goto do_dbm_delete;
-#else
- return Nullstr;
-#endif
-}
-
-static void
-hsplit(tb)
-HASH *tb;
-{
- int oldsize = tb->tbl_max + 1;
- register int newsize = oldsize * 2;
- register int i;
- register HENT **a;
- register HENT **b;
- register HENT *entry;
- register HENT **oentry;
-
- a = tb->tbl_array;
- nomemok = TRUE;
- Renew(a, newsize, HENT*);
- nomemok = FALSE;
- if (!a) {
- tb->tbl_dosplit = tb->tbl_max + 1; /* never split again */
- return;
- }
- Zero(&a[oldsize], oldsize, HENT*); /* zero 2nd half*/
- tb->tbl_max = --newsize;
- tb->tbl_dosplit = tb->tbl_max * FILLPCT / 100;
- tb->tbl_array = a;
-
- for (i=0; i<oldsize; i++,a++) {
- if (!*a) /* non-existent */
- continue;
- b = a+oldsize;
- for (oentry = a, entry = *a; entry; entry = *oentry) {
- if ((entry->hent_hash & newsize) != i) {
- *oentry = entry->hent_next;
- entry->hent_next = *b;
- if (!*b)
- tb->tbl_fill++;
- *b = entry;
- continue;
- }
- else
- oentry = &entry->hent_next;
- }
- if (!*a) /* everything moved */
- tb->tbl_fill--;
- }
-}
-
-HASH *
-hnew(lookat)
-unsigned int lookat;
-{
- register HASH *tb;
-
- Newz(502,tb, 1, HASH);
- if (lookat) {
- tb->tbl_coeffsize = lookat;
- tb->tbl_max = 7; /* it's a normal associative array */
- tb->tbl_dosplit = tb->tbl_max * FILLPCT / 100;
- }
- else {
- tb->tbl_max = 127; /* it's a symbol table */
- tb->tbl_dosplit = 128; /* so never split */
- }
- tb->tbl_fill = 0;
-#ifdef SOME_DBM
- tb->tbl_dbm = 0;
-#endif
- (void)hiterinit(tb); /* so each() will start off right */
- return tb;
-}
-
-void
-hentfree(hent)
-register HENT *hent;
-{
- if (!hent)
- return;
- str_free(hent->hent_val);
- Safefree(hent->hent_key);
- Safefree(hent);
-}
-
-void
-hentdelayfree(hent)
-register HENT *hent;
-{
- if (!hent)
- return;
- str_2mortal(hent->hent_val); /* free between statements */
- Safefree(hent->hent_key);
- Safefree(hent);
-}
-
-void
-hclear(tb,dodbm)
-register HASH *tb;
-int dodbm;
-{
- if (!tb)
- return;
- hfreeentries(tb,dodbm);
- tb->tbl_fill = 0;
-#ifndef lint
- if (tb->tbl_array)
- (void)memzero((char*)tb->tbl_array, (tb->tbl_max + 1) * sizeof(HENT*));
-#endif
-}
-
-static void
-hfreeentries(tb,dodbm)
-register HASH *tb;
-int dodbm;
-{
- register HENT *hent;
- register HENT *ohent = Null(HENT*);
-#ifdef SOME_DBM
- datum dkey;
- datum nextdkey;
-#ifdef HAS_GDBM
- GDBM_FILE old_dbm;
-#else
-#ifdef HAS_NDBM
- DBM *old_dbm;
-#else
- int old_dbm;
-#endif
-#endif
-#endif
-
- if (!tb || !tb->tbl_array)
- return;
-#ifdef SOME_DBM
- if ((old_dbm = tb->tbl_dbm) && dodbm) {
-#ifdef HAS_GDBM
- while (dkey = gdbm_firstkey(tb->tbl_dbm), dkey.dptr) {
-#else
- while (dkey = dbm_firstkey(tb->tbl_dbm), dkey.dptr) {
-#endif
- do {
-#ifdef HAS_GDBM
- nextdkey = gdbm_nextkey(tb->tbl_dbm, dkey);
-#else
-#ifdef HAS_NDBM
-#ifdef _CX_UX
- nextdkey = dbm_nextkey(tb->tbl_dbm, dkey);
-#else
- nextdkey = dbm_nextkey(tb->tbl_dbm);
-#endif
-#else
- nextdkey = nextkey(dkey);
-#endif
-#endif
-#ifdef HAS_GDBM
- gdbm_delete(tb->tbl_dbm,dkey);
-#else
- dbm_delete(tb->tbl_dbm,dkey);
-#endif
- dkey = nextdkey;
- } while (dkey.dptr); /* one way or another, this works */
- }
- }
- tb->tbl_dbm = 0; /* now clear just cache */
-#endif
- (void)hiterinit(tb);
- /*SUPPRESS 560*/
- while (hent = hiternext(tb)) { /* concise but not very efficient */
- hentfree(ohent);
- ohent = hent;
- }
- hentfree(ohent);
-#ifdef SOME_DBM
- tb->tbl_dbm = old_dbm;
-#endif
-}
-
-void
-hfree(tb,dodbm)
-register HASH *tb;
-int dodbm;
-{
- if (!tb)
- return;
- hfreeentries(tb,dodbm);
- Safefree(tb->tbl_array);
- Safefree(tb);
-}
-
-int
-hiterinit(tb)
-register HASH *tb;
-{
- tb->tbl_riter = -1;
- tb->tbl_eiter = Null(HENT*);
- return tb->tbl_fill;
-}
-
-HENT *
-hiternext(tb)
-register HASH *tb;
-{
- register HENT *entry;
-#ifdef SOME_DBM
- datum key;
-#endif
-
- entry = tb->tbl_eiter;
-#ifdef SOME_DBM
- if (tb->tbl_dbm) {
- if (entry) {
-#ifdef HAS_GDBM
- key.dptr = entry->hent_key;
- key.dsize = entry->hent_klen;
- key = gdbm_nextkey(tb->tbl_dbm, key);
-#else
-#ifdef HAS_NDBM
-#ifdef _CX_UX
- key.dptr = entry->hent_key;
- key.dsize = entry->hent_klen;
- key = dbm_nextkey(tb->tbl_dbm, key);
-#else
- key = dbm_nextkey(tb->tbl_dbm);
-#endif /* _CX_UX */
-#else
- key.dptr = entry->hent_key;
- key.dsize = entry->hent_klen;
- key = nextkey(key);
-#endif
-#endif
- }
- else {
- Newz(504,entry, 1, HENT);
- tb->tbl_eiter = entry;
-#ifdef HAS_GDBM
- key = gdbm_firstkey(tb->tbl_dbm);
-#else
- key = dbm_firstkey(tb->tbl_dbm);
-#endif
- }
- entry->hent_key = key.dptr;
- entry->hent_klen = key.dsize;
- if (!key.dptr) {
- if (entry->hent_val)
- str_free(entry->hent_val);
- Safefree(entry);
- tb->tbl_eiter = Null(HENT*);
- return Null(HENT*);
- }
- return entry;
- }
-#endif
- if (!tb->tbl_array)
- Newz(506,tb->tbl_array, tb->tbl_max + 1, HENT*);
- do {
- if (entry)
- entry = entry->hent_next;
- if (!entry) {
- tb->tbl_riter++;
- if (tb->tbl_riter > tb->tbl_max) {
- tb->tbl_riter = -1;
- break;
- }
- entry = tb->tbl_array[tb->tbl_riter];
- }
- } while (!entry);
-
- tb->tbl_eiter = entry;
- return entry;
-}
-
-char *
-hiterkey(entry,retlen)
-register HENT *entry;
-int *retlen;
-{
- *retlen = entry->hent_klen;
- return entry->hent_key;
-}
-
-STR *
-hiterval(tb,entry)
-register HASH *tb;
-register HENT *entry;
-{
-#ifdef SOME_DBM
- datum key, content;
-
- if (tb->tbl_dbm) {
- key.dptr = entry->hent_key;
- key.dsize = entry->hent_klen;
-#ifdef HAS_GDBM
- content = gdbm_fetch(tb->tbl_dbm,key);
-#else
- content = dbm_fetch(tb->tbl_dbm,key);
-#endif
- if (!entry->hent_val)
- entry->hent_val = Str_new(62,0);
- str_nset(entry->hent_val,content.dptr,content.dsize);
- }
-#endif
- return entry->hent_val;
-}
-
-#ifdef SOME_DBM
-
-#ifndef O_CREAT
-# ifdef I_FCNTL
-# include <fcntl.h>
-# endif
-# ifdef I_SYS_FILE
-# include <sys/file.h>
-# endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
-#ifndef O_RDWR
-#define O_RDWR 2
-#endif
-#ifndef O_CREAT
-#define O_CREAT 01000
-#endif
-
-#ifdef HAS_ODBM
-static int dbmrefcnt = 0;
-#endif
-
-bool
-hdbmopen(tb,fname,mode)
-register HASH *tb;
-char *fname;
-int mode;
-{
- if (!tb)
- return FALSE;
-#ifdef HAS_ODBM
- if (tb->tbl_dbm) /* never really closed it */
- return TRUE;
-#endif
- if (tb->tbl_dbm) {
- hdbmclose(tb);
- tb->tbl_dbm = 0;
- }
- hclear(tb, FALSE); /* clear cache */
-#ifdef HAS_GDBM
- if (mode >= 0)
- tb->tbl_dbm = gdbm_open(fname, 0, GDBM_WRCREAT,mode, (void *) NULL);
- if (!tb->tbl_dbm)
- tb->tbl_dbm = gdbm_open(fname, 0, GDBM_WRITER, mode, (void *) NULL);
- if (!tb->tbl_dbm)
- tb->tbl_dbm = gdbm_open(fname, 0, GDBM_READER, mode, (void *) NULL);
-#else
-#ifdef HAS_NDBM
- if (mode >= 0)
- tb->tbl_dbm = dbm_open(fname, O_RDWR|O_CREAT, mode);
- if (!tb->tbl_dbm)
- tb->tbl_dbm = dbm_open(fname, O_RDWR, mode);
- if (!tb->tbl_dbm)
- tb->tbl_dbm = dbm_open(fname, O_RDONLY, mode);
-#else
- if (dbmrefcnt++)
- fatal("Old dbm can only open one database");
- sprintf(buf,"%s.dir",fname);
- if (stat(buf, &statbuf) < 0) {
- if (mode < 0 || close(creat(buf,mode)) < 0)
- return FALSE;
- sprintf(buf,"%s.pag",fname);
- if (close(creat(buf,mode)) < 0)
- return FALSE;
- }
- tb->tbl_dbm = dbminit(fname) >= 0;
-#endif
-#endif
- if (!tb->tbl_array && tb->tbl_dbm != 0)
- Newz(507,tb->tbl_array, tb->tbl_max + 1, HENT*);
- return tb->tbl_dbm != 0;
-}
-
-void
-hdbmclose(tb)
-register HASH *tb;
-{
- if (tb && tb->tbl_dbm) {
-#ifdef HAS_GDBM
- gdbm_close(tb->tbl_dbm);
- tb->tbl_dbm = 0;
-#else
-#ifdef HAS_NDBM
- dbm_close(tb->tbl_dbm);
- tb->tbl_dbm = 0;
-#else
- /* dbmrefcnt--; */ /* doesn't work, rats */
-#endif
-#endif
- }
- else if (dowarn)
- warn("Close on unopened dbm file");
-}
-
-bool
-hdbmstore(tb,key,klen,str)
-register HASH *tb;
-char *key;
-unsigned int klen;
-register STR *str;
-{
- datum dkey, dcontent;
- int error;
-
- if (!tb || !tb->tbl_dbm)
- return FALSE;
- dkey.dptr = key;
- dkey.dsize = klen;
- dcontent.dptr = str_get(str);
- dcontent.dsize = str->str_cur;
-#ifdef HAS_GDBM
- error = gdbm_store(tb->tbl_dbm, dkey, dcontent, GDBM_REPLACE);
-#else
- error = dbm_store(tb->tbl_dbm, dkey, dcontent, DBM_REPLACE);
-#endif
- if (error) {
- if (errno == EPERM)
- fatal("No write permission to dbm file");
- warn("dbm store returned %d, errno %d, key \"%s\"",error,errno,key);
-#ifdef HAS_NDBM
- dbm_clearerr(tb->tbl_dbm);
-#endif
- }
- return !error;
-}
-#endif /* SOME_DBM */
diff --git a/gnu/usr.bin/perl/perl/hash.h b/gnu/usr.bin/perl/perl/hash.h
deleted file mode 100644
index ddf2a11..0000000
--- a/gnu/usr.bin/perl/perl/hash.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* $RCSfile: hash.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:35 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: hash.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:35 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:37 nate
- * PERL!
- *
- * Revision 4.0.1.2 91/11/05 17:24:31 lwall
- * patch11: random cleanup
- *
- * Revision 4.0.1.1 91/06/07 11:10:33 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:22:38 lwall
- * 4.0 baseline.
- *
- */
-
-#define FILLPCT 80 /* don't make greater than 99 */
-#define DBM_CACHE_MAX 63 /* cache 64 entries for dbm file */
- /* (resident array acts as a write-thru cache)*/
-
-#define COEFFSIZE (16 * 8) /* size of coeff array */
-
-typedef struct hentry HENT;
-
-struct hentry {
- HENT *hent_next;
- char *hent_key;
- STR *hent_val;
- int hent_hash;
- int hent_klen;
-};
-
-struct htbl {
- HENT **tbl_array;
- int tbl_max; /* subscript of last element of tbl_array */
- int tbl_dosplit; /* how full to get before splitting */
- int tbl_fill; /* how full tbl_array currently is */
- int tbl_riter; /* current root of iterator */
- HENT *tbl_eiter; /* current entry of iterator */
- SPAT *tbl_spatroot; /* list of spats for this package */
- char *tbl_name; /* name, if a symbol table */
-#ifdef SOME_DBM
-#ifdef HAS_GDBM
- GDBM_FILE tbl_dbm;
-#else
-#ifdef HAS_NDBM
- DBM *tbl_dbm;
-#else
- int tbl_dbm;
-#endif
-#endif
-#endif
- unsigned char tbl_coeffsize; /* is 0 for symbol tables */
-};
-
-STR *hfetch();
-bool hstore();
-STR *hdelete();
-HASH *hnew();
-void hclear();
-void hentfree();
-void hfree();
-int hiterinit();
-HENT *hiternext();
-char *hiterkey();
-STR *hiterval();
-bool hdbmopen();
-void hdbmclose();
-bool hdbmstore();
diff --git a/gnu/usr.bin/perl/perl/patchlevel.h b/gnu/usr.bin/perl/perl/patchlevel.h
deleted file mode 100644
index d248b35..0000000
--- a/gnu/usr.bin/perl/perl/patchlevel.h
+++ /dev/null
@@ -1 +0,0 @@
-#define PATCHLEVEL 36
diff --git a/gnu/usr.bin/perl/perl/perl.1 b/gnu/usr.bin/perl/perl/perl.1
deleted file mode 100644
index a484ddb..0000000
--- a/gnu/usr.bin/perl/perl/perl.1
+++ /dev/null
@@ -1,6022 +0,0 @@
-.rn '' }`
-''' $RCSfile: perl.1,v $$Revision: 1.3 $$Date: 1996/10/05 22:26:23 $
-'''
-''' $Log: perl.1,v $
-''' Revision 1.3 1996/10/05 22:26:23 wosch
-''' delete doubled words, e.g.: "the the" -> "the"
-'''
-''' Revision 1.2 1994/10/27 23:16:52 wollman
-''' Convince Perl to that is is part of the system, as /usr/bin/perl (binary)
-''' and /usr/share/perl (library). The latter was chosen as analogous to other
-''' directories already present in /usr/share, like /usr/share/groff_font and
-''' (particularly) /usr/share/mk.
-'''
-.\" Revision 1.1.1.1 1994/09/10 06:27:36 gclarkii
-.\" Initial import of Perl 4.046 bmaked
-.\"
-.\" Revision 1.1.1.1 1993/08/23 21:29:37 nate
-.\" PERL!
-.\"
-''' Revision 4.0.1.6 92/06/08 15:07:29 lwall
-''' patch20: documented that numbers may contain underline
-''' patch20: clarified that DATA may only be read from main script
-''' patch20: relaxed requirement for semicolon at the end of a block
-''' patch20: added ... as variant on ..
-''' patch20: documented need for 1; at the end of a required file
-''' patch20: extended bracket-style quotes to two-arg operators: s()() and tr()()
-''' patch20: paragraph mode now skips extra newlines automatically
-''' patch20: documented PERLLIB and PERLDB
-''' patch20: documented limit on size of regexp
-'''
-''' Revision 4.0.1.5 91/11/11 16:42:00 lwall
-''' patch19: added little-endian pack/unpack options
-'''
-''' Revision 4.0.1.4 91/11/05 18:11:05 lwall
-''' patch11: added sort {} LIST
-''' patch11: added eval {}
-''' patch11: documented meaning of scalar(%foo)
-''' patch11: sprintf() now supports any length of s field
-'''
-''' Revision 4.0.1.3 91/06/10 01:26:02 lwall
-''' patch10: documented some newer features in addenda
-'''
-''' Revision 4.0.1.2 91/06/07 11:41:23 lwall
-''' patch4: added global modifier for pattern matches
-''' patch4: default top-of-form format is now FILEHANDLE_TOP
-''' patch4: added $^P variable to control calling of perldb routines
-''' patch4: added $^F variable to specify maximum system fd, default 2
-''' patch4: changed old $^P to $^X
-'''
-''' Revision 4.0.1.1 91/04/11 17:50:44 lwall
-''' patch1: fixed some typos
-'''
-''' Revision 4.0 91/03/20 01:38:08 lwall
-''' 4.0 baseline.
-'''
-'''
-.de Sh
-.br
-.ne 5
-.PP
-\fB\\$1\fR
-.PP
-..
-.de Sp
-.if t .sp .5v
-.if n .sp
-..
-.de Ip
-.br
-.ie \\n(.$>=3 .ne \\$3
-.el .ne 3
-.IP "\\$1" \\$2
-..
-'''
-''' Set up \*(-- to give an unbreakable dash;
-''' string Tr holds user defined translation string.
-''' Bell System Logo is used as a dummy character.
-'''
-.tr \(*W-|\(bv\*(Tr
-.ie n \{\
-.ds -- \(*W-
-.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
-.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
-.ds L" ""
-.ds R" ""
-.ds L' '
-.ds R' '
-'br\}
-.el\{\
-.ds -- \(em\|
-.tr \*(Tr
-.ds L" ``
-.ds R" ''
-.ds L' `
-.ds R' '
-'br\}
-.TH PERL 1 "\*(RP"
-.UC
-.SH NAME
-perl \- Practical Extraction and Report Language
-.SH SYNOPSIS
-.B perl
-[options] filename args
-.SH DESCRIPTION
-.I Perl
-is an interpreted language optimized for scanning arbitrary text files,
-extracting information from those text files, and printing reports based
-on that information.
-It's also a good language for many system management tasks.
-The language is intended to be practical (easy to use, efficient, complete)
-rather than beautiful (tiny, elegant, minimal).
-It combines (in the author's opinion, anyway) some of the best features of C,
-\fIsed\fR, \fIawk\fR, and \fIsh\fR,
-so people familiar with those languages should have little difficulty with it.
-(Language historians will also note some vestiges of \fIcsh\fR, Pascal, and
-even BASIC-PLUS.)
-Expression syntax corresponds quite closely to C expression syntax.
-Unlike most Unix utilities,
-.I perl
-does not arbitrarily limit the size of your data\*(--if you've got
-the memory,
-.I perl
-can slurp in your whole file as a single string.
-Recursion is of unlimited depth.
-And the hash tables used by associative arrays grow as necessary to prevent
-degraded performance.
-.I Perl
-uses sophisticated pattern matching techniques to scan large amounts of
-data very quickly.
-Although optimized for scanning text,
-.I perl
-can also deal with binary data, and can make dbm files look like associative
-arrays (where dbm is available).
-Setuid
-.I perl
-scripts are safer than C programs
-through a dataflow tracing mechanism which prevents many stupid security holes.
-If you have a problem that would ordinarily use \fIsed\fR
-or \fIawk\fR or \fIsh\fR, but it
-exceeds their capabilities or must run a little faster,
-and you don't want to write the silly thing in C, then
-.I perl
-may be for you.
-There are also translators to turn your
-.I sed
-and
-.I awk
-scripts into
-.I perl
-scripts.
-OK, enough hype.
-.PP
-Upon startup,
-.I perl
-looks for your script in one of the following places:
-.Ip 1. 4 2
-Specified line by line via
-.B \-e
-switches on the command line.
-.Ip 2. 4 2
-Contained in the file specified by the first filename on the command line.
-(Note that systems supporting the #! notation invoke interpreters this way.)
-.Ip 3. 4 2
-Passed in implicitly via standard input.
-This only works if there are no filename arguments\*(--to pass
-arguments to a
-.I stdin
-script you must explicitly specify a \- for the script name.
-.PP
-After locating your script,
-.I perl
-compiles it to an internal form.
-If the script is syntactically correct, it is executed.
-.Sh "Options"
-Note: on first reading this section may not make much sense to you. It's here
-at the front for easy reference.
-.PP
-A single-character option may be combined with the following option, if any.
-This is particularly useful when invoking a script using the #! construct which
-only allows one argument. Example:
-.nf
-
-.ne 2
- #!/usr/bin/perl \-spi.bak # same as \-s \-p \-i.bak
- .\|.\|.
-
-.fi
-Options include:
-.TP 5
-.BI \-0 digits
-specifies the record separator ($/) as an octal number.
-If there are no digits, the null character is the separator.
-Other switches may precede or follow the digits.
-For example, if you have a version of
-.I find
-which can print filenames terminated by the null character, you can say this:
-.nf
-
- find . \-name '*.bak' \-print0 | perl \-n0e unlink
-
-.fi
-The special value 00 will cause Perl to slurp files in paragraph mode.
-The value 0777 will cause Perl to slurp files whole since there is no
-legal character with that value.
-.TP 5
-.B \-a
-turns on autosplit mode when used with a
-.B \-n
-or
-.BR \-p .
-An implicit split command to the @F array
-is done as the first thing inside the implicit while loop produced by
-the
-.B \-n
-or
-.BR \-p .
-.nf
-
- perl \-ane \'print pop(@F), "\en";\'
-
-is equivalent to
-
- while (<>) {
- @F = split(\' \');
- print pop(@F), "\en";
- }
-
-.fi
-.TP 5
-.B \-c
-causes
-.I perl
-to check the syntax of the script and then exit without executing it.
-.TP 5
-.BI \-d
-runs the script under the perl debugger.
-See the section on Debugging.
-.TP 5
-.BI \-D number
-sets debugging flags.
-To watch how it executes your script, use
-.BR \-D14 .
-(This only works if debugging is compiled into your
-.IR perl .)
-Another nice value is \-D1024, which lists your compiled syntax tree.
-And \-D512 displays compiled regular expressions.
-.TP 5
-.BI \-e " commandline"
-may be used to enter one line of script.
-Multiple
-.B \-e
-commands may be given to build up a multi-line script.
-If
-.B \-e
-is given,
-.I perl
-will not look for a script filename in the argument list.
-.TP 5
-.BI \-i extension
-specifies that files processed by the <> construct are to be edited
-in-place.
-It does this by renaming the input file, opening the output file by the
-same name, and selecting that output file as the default for print statements.
-The extension, if supplied, is added to the name of the
-old file to make a backup copy.
-If no extension is supplied, no backup is made.
-Saying \*(L"perl \-p \-i.bak \-e "s/foo/bar/;" .\|.\|. \*(R" is the same as using
-the script:
-.nf
-
-.ne 2
- #!/usr/bin/perl \-pi.bak
- s/foo/bar/;
-
-which is equivalent to
-
-.ne 14
- #!/usr/bin/perl
- while (<>) {
- if ($ARGV ne $oldargv) {
- rename($ARGV, $ARGV . \'.bak\');
- open(ARGVOUT, ">$ARGV");
- select(ARGVOUT);
- $oldargv = $ARGV;
- }
- s/foo/bar/;
- }
- continue {
- print; # this prints to original filename
- }
- select(STDOUT);
-
-.fi
-except that the
-.B \-i
-form doesn't need to compare $ARGV to $oldargv to know when
-the filename has changed.
-It does, however, use ARGVOUT for the selected filehandle.
-Note that
-.I STDOUT
-is restored as the default output filehandle after the loop.
-.Sp
-You can use eof to locate the end of each input file, in case you want
-to append to each file, or reset line numbering (see example under eof).
-.TP 5
-.BI \-I directory
-may be used in conjunction with
-.B \-P
-to tell the C preprocessor where to look for include files.
-By default /usr/include and /usr/lib/perl are searched.
-.TP 5
-.BI \-l octnum
-enables automatic line-ending processing. It has two effects:
-first, it automatically chops the line terminator when used with
-.B \-n
-or
-.B \-p ,
-and second, it assigns $\e to have the value of
-.I octnum
-so that any print statements will have that line terminator added back on. If
-.I octnum
-is omitted, sets $\e to the current value of $/.
-For instance, to trim lines to 80 columns:
-.nf
-
- perl -lpe \'substr($_, 80) = ""\'
-
-.fi
-Note that the assignment $\e = $/ is done when the switch is processed,
-so the input record separator can be different than the output record
-separator if the
-.B \-l
-switch is followed by a
-.B \-0
-switch:
-.nf
-
- gnufind / -print0 | perl -ln0e 'print "found $_" if -p'
-
-.fi
-This sets $\e to newline and then sets $/ to the null character.
-.TP 5
-.B \-n
-causes
-.I perl
-to assume the following loop around your script, which makes it iterate
-over filename arguments somewhat like \*(L"sed \-n\*(R" or \fIawk\fR:
-.nf
-
-.ne 3
- while (<>) {
- .\|.\|. # your script goes here
- }
-
-.fi
-Note that the lines are not printed by default.
-See
-.B \-p
-to have lines printed.
-Here is an efficient way to delete all files older than a week:
-.nf
-
- find . \-mtime +7 \-print | perl \-nle \'unlink;\'
-
-.fi
-This is faster than using the \-exec switch of find because you don't have to
-start a process on every filename found.
-.TP 5
-.B \-p
-causes
-.I perl
-to assume the following loop around your script, which makes it iterate
-over filename arguments somewhat like \fIsed\fR:
-.nf
-
-.ne 5
- while (<>) {
- .\|.\|. # your script goes here
- } continue {
- print;
- }
-
-.fi
-Note that the lines are printed automatically.
-To suppress printing use the
-.B \-n
-switch.
-A
-.B \-p
-overrides a
-.B \-n
-switch.
-.TP 5
-.B \-P
-causes your script to be run through the C preprocessor before
-compilation by
-.IR perl .
-(Since both comments and cpp directives begin with the # character,
-you should avoid starting comments with any words recognized
-by the C preprocessor such as \*(L"if\*(R", \*(L"else\*(R" or \*(L"define\*(R".)
-.TP 5
-.B \-s
-enables some rudimentary switch parsing for switches on the command line
-after the script name but before any filename arguments (or before a \-\|\-).
-Any switch found there is removed from @ARGV and sets the corresponding variable in the
-.I perl
-script.
-The following script prints \*(L"true\*(R" if and only if the script is
-invoked with a \-xyz switch.
-.nf
-
-.ne 2
- #!/usr/bin/perl \-s
- if ($xyz) { print "true\en"; }
-
-.fi
-.TP 5
-.B \-S
-makes
-.I perl
-use the PATH environment variable to search for the script
-(unless the name of the script starts with a slash).
-Typically this is used to emulate #! startup on machines that don't
-support #!, in the following manner:
-.nf
-
- #!/usr/bin/perl
- eval "exec /usr/bin/perl \-S $0 $*"
- if $running_under_some_shell;
-
-.fi
-The system ignores the first line and feeds the script to /bin/sh,
-which proceeds to try to execute the
-.I perl
-script as a shell script.
-The shell executes the second line as a normal shell command, and thus
-starts up the
-.I perl
-interpreter.
-On some systems $0 doesn't always contain the full pathname,
-so the
-.B \-S
-tells
-.I perl
-to search for the script if necessary.
-After
-.I perl
-locates the script, it parses the lines and ignores them because
-the variable $running_under_some_shell is never true.
-A better construct than $* would be ${1+"$@"}, which handles embedded spaces
-and such in the filenames, but doesn't work if the script is being interpreted
-by csh.
-In order to start up sh rather than csh, some systems may have to replace the
-#! line with a line containing just
-a colon, which will be politely ignored by perl.
-Other systems can't control that, and need a totally devious construct that
-will work under any of csh, sh or perl, such as the following:
-.nf
-
-.ne 3
- eval '(exit $?0)' && eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
- & eval 'exec /usr/bin/perl -S $0 $argv:q'
- if 0;
-
-.fi
-.TP 5
-.B \-u
-causes
-.I perl
-to dump core after compiling your script.
-You can then take this core dump and turn it into an executable file
-by using the undump program (not supplied).
-This speeds startup at the expense of some disk space (which you can
-minimize by stripping the executable).
-(Still, a "hello world" executable comes out to about 200K on my machine.)
-If you are going to run your executable as a set-id program then you
-should probably compile it using taintperl rather than normal perl.
-If you want to execute a portion of your script before dumping, use the
-dump operator instead.
-Note: availability of undump is platform specific and may not be available
-for a specific port of perl.
-.TP 5
-.B \-U
-allows
-.I perl
-to do unsafe operations.
-Currently the only \*(L"unsafe\*(R" operations are the unlinking of directories while
-running as superuser, and running setuid programs with fatal taint checks
-turned into warnings.
-.TP 5
-.B \-v
-prints the version and patchlevel of your
-.I perl
-executable.
-.TP 5
-.B \-w
-prints warnings about identifiers that are mentioned only once, and scalar
-variables that are used before being set.
-Also warns about redefined subroutines, and references to undefined
-filehandles or filehandles opened readonly that you are attempting to
-write on.
-Also warns you if you use == on values that don't look like numbers, and if
-your subroutines recurse more than 100 deep.
-.TP 5
-.BI \-x directory
-tells
-.I perl
-that the script is embedded in a message.
-Leading garbage will be discarded until the first line that starts
-with #! and contains the string "perl".
-Any meaningful switches on that line will be applied (but only one
-group of switches, as with normal #! processing).
-If a directory name is specified, Perl will switch to that directory
-before running the script.
-The
-.B \-x
-switch only controls the disposal of leading garbage.
-The script must be terminated with _\|_END_\|_ if there is trailing garbage
-to be ignored (the script can process any or all of the trailing garbage
-via the DATA filehandle if desired).
-.Sh "Data Types and Objects"
-.PP
-.I Perl
-has three data types: scalars, arrays of scalars, and
-associative arrays of scalars.
-Normal arrays are indexed by number, and associative arrays by string.
-.PP
-The interpretation of operations and values in perl sometimes
-depends on the requirements
-of the context around the operation or value.
-There are three major contexts: string, numeric and array.
-Certain operations return array values
-in contexts wanting an array, and scalar values otherwise.
-(If this is true of an operation it will be mentioned in the documentation
-for that operation.)
-Operations which return scalars don't care whether the context is looking
-for a string or a number, but
-scalar variables and values are interpreted as strings or numbers
-as appropriate to the context.
-A scalar is interpreted as TRUE in the boolean sense if it is not the null
-string or 0.
-Booleans returned by operators are 1 for true and 0 or \'\' (the null
-string) for false.
-.PP
-There are actually two varieties of null string: defined and undefined.
-Undefined null strings are returned when there is no real value for something,
-such as when there was an error, or at end of file, or when you refer
-to an uninitialized variable or element of an array.
-An undefined null string may become defined the first time you access it, but
-prior to that you can use the defined() operator to determine whether the
-value is defined or not.
-.PP
-References to scalar variables always begin with \*(L'$\*(R', even when referring
-to a scalar that is part of an array.
-Thus:
-.nf
-
-.ne 3
- $days \h'|2i'# a simple scalar variable
- $days[28] \h'|2i'# 29th element of array @days
- $days{\'Feb\'}\h'|2i'# one value from an associative array
- $#days \h'|2i'# last index of array @days
-
-but entire arrays or array slices are denoted by \*(L'@\*(R':
-
- @days \h'|2i'# ($days[0], $days[1],\|.\|.\|. $days[n])
- @days[3,4,5]\h'|2i'# same as @days[3.\|.5]
- @days{'a','c'}\h'|2i'# same as ($days{'a'},$days{'c'})
-
-and entire associative arrays are denoted by \*(L'%\*(R':
-
- %days \h'|2i'# (key1, val1, key2, val2 .\|.\|.)
-.fi
-.PP
-Any of these eight constructs may serve as an lvalue,
-that is, may be assigned to.
-(It also turns out that an assignment is itself an lvalue in
-certain contexts\*(--see examples under s, tr and chop.)
-Assignment to a scalar evaluates the righthand side in a scalar context,
-while assignment to an array or array slice evaluates the righthand side
-in an array context.
-.PP
-You may find the length of array @days by evaluating
-\*(L"$#days\*(R", as in
-.IR csh .
-(Actually, it's not the length of the array, it's the subscript of the last element, since there is (ordinarily) a 0th element.)
-Assigning to $#days changes the length of the array.
-Shortening an array by this method does not actually destroy any values.
-Lengthening an array that was previously shortened recovers the values that
-were in those elements.
-You can also gain some measure of efficiency by preextending an array that
-is going to get big.
-(You can also extend an array by assigning to an element that is off the
-end of the array.
-This differs from assigning to $#whatever in that intervening values
-are set to null rather than recovered.)
-You can truncate an array down to nothing by assigning the null list () to
-it.
-The following are exactly equivalent
-.nf
-
- @whatever = ();
- $#whatever = $[ \- 1;
-
-.fi
-.PP
-If you evaluate an array in a scalar context, it returns the length of
-the array.
-The following is always true:
-.nf
-
- scalar(@whatever) == $#whatever \- $[ + 1;
-
-.fi
-If you evaluate an associative array in a scalar context, it returns
-a value which is true if and only if the array contains any elements.
-(If there are any elements, the value returned is a string consisting
-of the number of used buckets and the number of allocated buckets, separated
-by a slash.)
-.PP
-Multi-dimensional arrays are not directly supported, but see the discussion
-of the $; variable later for a means of emulating multiple subscripts with
-an associative array.
-You could also write a subroutine to turn multiple subscripts into a single
-subscript.
-.PP
-Every data type has its own namespace.
-You can, without fear of conflict, use the same name for a scalar variable,
-an array, an associative array, a filehandle, a subroutine name, and/or
-a label.
-Since variable and array references always start with \*(L'$\*(R', \*(L'@\*(R',
-or \*(L'%\*(R', the \*(L"reserved\*(R" words aren't in fact reserved
-with respect to variable names.
-(They ARE reserved with respect to labels and filehandles, however, which
-don't have an initial special character.
-Hint: you could say open(LOG,\'logfile\') rather than open(log,\'logfile\').
-Using uppercase filehandles also improves readability and protects you
-from conflict with future reserved words.)
-Case IS significant\*(--\*(L"FOO\*(R", \*(L"Foo\*(R" and \*(L"foo\*(R" are all
-different names.
-Names which start with a letter may also contain digits and underscores.
-Names which do not start with a letter are limited to one character,
-e.g. \*(L"$%\*(R" or \*(L"$$\*(R".
-(Most of the one character names have a predefined significance to
-.IR perl .
-More later.)
-.PP
-Numeric literals are specified in any of the usual floating point or
-integer formats:
-.nf
-
-.ne 6
- 12345
- 12345.67
- .23E-10
- 0xffff # hex
- 0377 # octal
- 4_294_967_296
-
-.fi
-String literals are delimited by either single or double quotes.
-They work much like shell quotes:
-double-quoted string literals are subject to backslash and variable
-substitution; single-quoted strings are not (except for \e\' and \e\e).
-The usual backslash rules apply for making characters such as newline, tab,
-etc., as well as some more exotic forms:
-.nf
-
- \et tab
- \en newline
- \er return
- \ef form feed
- \eb backspace
- \ea alarm (bell)
- \ee escape
- \e033 octal char
- \ex1b hex char
- \ec[ control char
- \el lowercase next char
- \eu uppercase next char
- \eL lowercase till \eE
- \eU uppercase till \eE
- \eE end case modification
-
-.fi
-You can also embed newlines directly in your strings, i.e. they can end on
-a different line than they begin.
-This is nice, but if you forget your trailing quote, the error will not be
-reported until
-.I perl
-finds another line containing the quote character, which
-may be much further on in the script.
-Variable substitution inside strings is limited to scalar variables, normal
-array values, and array slices.
-(In other words, identifiers beginning with $ or @, followed by an optional
-bracketed expression as a subscript.)
-The following code segment prints out \*(L"The price is $100.\*(R"
-.nf
-
-.ne 2
- $Price = \'$100\';\h'|3.5i'# not interpreted
- print "The price is $Price.\e\|n";\h'|3.5i'# interpreted
-
-.fi
-Note that you can put curly brackets around the identifier to delimit it
-from following alphanumerics.
-Also note that a single quoted string must be separated from a preceding
-word by a space, since single quote is a valid character in an identifier
-(see Packages).
-.PP
-Two special literals are _\|_LINE_\|_ and _\|_FILE_\|_, which represent the current
-line number and filename at that point in your program.
-They may only be used as separate tokens; they will not be interpolated
-into strings.
-In addition, the token _\|_END_\|_ may be used to indicate the logical end of the
-script before the actual end of file.
-Any following text is ignored, but may be read via the DATA filehandle.
-(The DATA filehandle may read data only from the main script, but not from
-any required file or evaluated string.)
-The two control characters ^D and ^Z are synonyms for _\|_END_\|_.
-.PP
-A word that doesn't have any other interpretation in the grammar will be
-treated as if it had single quotes around it.
-For this purpose, a word consists only of alphanumeric characters and underline,
-and must start with an alphabetic character.
-As with filehandles and labels, a bare word that consists entirely of
-lowercase letters risks conflict with future reserved words, and if you
-use the
-.B \-w
-switch, Perl will warn you about any such words.
-.PP
-Array values are interpolated into double-quoted strings by joining all the
-elements of the array with the delimiter specified in the $" variable,
-space by default.
-(Since in versions of perl prior to 3.0 the @ character was not a metacharacter
-in double-quoted strings, the interpolation of @array, $array[EXPR],
-@array[LIST], $array{EXPR}, or @array{LIST} only happens if array is
-referenced elsewhere in the program or is predefined.)
-The following are equivalent:
-.nf
-
-.ne 4
- $temp = join($",@ARGV);
- system "echo $temp";
-
- system "echo @ARGV";
-
-.fi
-Within search patterns (which also undergo double-quotish substitution)
-there is a bad ambiguity: Is /$foo[bar]/ to be
-interpreted as /${foo}[bar]/ (where [bar] is a character class for the
-regular expression) or as /${foo[bar]}/ (where [bar] is the subscript to
-array @foo)?
-If @foo doesn't otherwise exist, then it's obviously a character class.
-If @foo exists, perl takes a good guess about [bar], and is almost always right.
-If it does guess wrong, or if you're just plain paranoid,
-you can force the correct interpretation with curly brackets as above.
-.PP
-A line-oriented form of quoting is based on the shell here-is syntax.
-Following a << you specify a string to terminate the quoted material, and all lines
-following the current line down to the terminating string are the value
-of the item.
-The terminating string may be either an identifier (a word), or some
-quoted text.
-If quoted, the type of quotes you use determines the treatment of the text,
-just as in regular quoting.
-An unquoted identifier works like double quotes.
-There must be no space between the << and the identifier.
-(If you put a space it will be treated as a null identifier, which is
-valid, and matches the first blank line\*(--see Merry Christmas example below.)
-The terminating string must appear by itself (unquoted and with no surrounding
-whitespace) on the terminating line.
-.nf
-
- print <<EOF; # same as above
-The price is $Price.
-EOF
-
- print <<"EOF"; # same as above
-The price is $Price.
-EOF
-
- print << x 10; # null identifier is delimiter
-Merry Christmas!
-
- print <<`EOC`; # execute commands
-echo hi there
-echo lo there
-EOC
-
- print <<foo, <<bar; # you can stack them
-I said foo.
-foo
-I said bar.
-bar
-
-.fi
-Array literals are denoted by separating individual values by commas, and
-enclosing the list in parentheses:
-.nf
-
- (LIST)
-
-.fi
-In a context not requiring an array value, the value of the array literal
-is the value of the final element, as in the C comma operator.
-For example,
-.nf
-
-.ne 4
- @foo = (\'cc\', \'\-E\', $bar);
-
-assigns the entire array value to array foo, but
-
- $foo = (\'cc\', \'\-E\', $bar);
-
-.fi
-assigns the value of variable bar to variable foo.
-Note that the value of an actual array in a scalar context is the length
-of the array; the following assigns to $foo the value 3:
-.nf
-
-.ne 2
- @foo = (\'cc\', \'\-E\', $bar);
- $foo = @foo; # $foo gets 3
-
-.fi
-You may have an optional comma before the closing parenthesis of an
-array literal, so that you can say:
-.nf
-
- @foo = (
- 1,
- 2,
- 3,
- );
-
-.fi
-When a LIST is evaluated, each element of the list is evaluated in
-an array context, and the resulting array value is interpolated into LIST
-just as if each individual element were a member of LIST. Thus arrays
-lose their identity in a LIST\*(--the list
-
- (@foo,@bar,&SomeSub)
-
-contains all the elements of @foo followed by all the elements of @bar,
-followed by all the elements returned by the subroutine named SomeSub.
-.PP
-A list value may also be subscripted like a normal array.
-Examples:
-.nf
-
- $time = (stat($file))[8]; # stat returns array value
- $digit = ('a','b','c','d','e','f')[$digit-10];
- return (pop(@foo),pop(@foo))[0];
-
-.fi
-.PP
-Array lists may be assigned to if and only if each element of the list
-is an lvalue:
-.nf
-
- ($a, $b, $c) = (1, 2, 3);
-
- ($map{\'red\'}, $map{\'blue\'}, $map{\'green\'}) = (0x00f, 0x0f0, 0xf00);
-
-The final element may be an array or an associative array:
-
- ($a, $b, @rest) = split;
- local($a, $b, %rest) = @_;
-
-.fi
-You can actually put an array anywhere in the list, but the first array
-in the list will soak up all the values, and anything after it will get
-a null value.
-This may be useful in a local().
-.PP
-An associative array literal contains pairs of values to be interpreted
-as a key and a value:
-.nf
-
-.ne 2
- # same as map assignment above
- %map = ('red',0x00f,'blue',0x0f0,'green',0xf00);
-
-.fi
-Array assignment in a scalar context returns the number of elements
-produced by the expression on the right side of the assignment:
-.nf
-
- $x = (($foo,$bar) = (3,2,1)); # set $x to 3, not 2
-
-.fi
-.PP
-There are several other pseudo-literals that you should know about.
-If a string is enclosed by backticks (grave accents), it first undergoes
-variable substitution just like a double quoted string.
-It is then interpreted as a command, and the output of that command
-is the value of the pseudo-literal, like in a shell.
-In a scalar context, a single string consisting of all the output is
-returned.
-In an array context, an array of values is returned, one for each line
-of output.
-(You can set $/ to use a different line terminator.)
-The command is executed each time the pseudo-literal is evaluated.
-The status value of the command is returned in $? (see Predefined Names
-for the interpretation of $?).
-Unlike in \f2csh\f1, no translation is done on the return
-data\*(--newlines remain newlines.
-Unlike in any of the shells, single quotes do not hide variable names
-in the command from interpretation.
-To pass a $ through to the shell you need to hide it with a backslash.
-.PP
-Evaluating a filehandle in angle brackets yields the next line
-from that file (newline included, so it's never false until EOF, at
-which time an undefined value is returned).
-Ordinarily you must assign that value to a variable,
-but there is one situation where an automatic assignment happens.
-If (and only if) the input symbol is the only thing inside the conditional of a
-.I while
-loop, the value is
-automatically assigned to the variable \*(L"$_\*(R".
-(This may seem like an odd thing to you, but you'll use the construct
-in almost every
-.I perl
-script you write.)
-Anyway, the following lines are equivalent to each other:
-.nf
-
-.ne 5
- while ($_ = <STDIN>) { print; }
- while (<STDIN>) { print; }
- for (\|;\|<STDIN>;\|) { print; }
- print while $_ = <STDIN>;
- print while <STDIN>;
-
-.fi
-The filehandles
-.IR STDIN ,
-.I STDOUT
-and
-.I STDERR
-are predefined.
-(The filehandles
-.IR stdin ,
-.I stdout
-and
-.I stderr
-will also work except in packages, where they would be interpreted as
-local identifiers rather than global.)
-Additional filehandles may be created with the
-.I open
-function.
-.PP
-If a <FILEHANDLE> is used in a context that is looking for an array, an array
-consisting of all the input lines is returned, one line per array element.
-It's easy to make a LARGE data space this way, so use with care.
-.PP
-The null filehandle <> is special and can be used to emulate the behavior of
-\fIsed\fR and \fIawk\fR.
-Input from <> comes either from standard input, or from each file listed on
-the command line.
-Here's how it works: the first time <> is evaluated, the ARGV array is checked,
-and if it is null, $ARGV[0] is set to \'-\', which when opened gives you standard
-input.
-The ARGV array is then processed as a list of filenames.
-The loop
-.nf
-
-.ne 3
- while (<>) {
- .\|.\|. # code for each line
- }
-
-.ne 10
-is equivalent to the following Perl-like pseudo code:
-
- unshift(@ARGV, \'\-\') \|if \|$#ARGV < $[;
- while ($ARGV = shift) {
- open(ARGV, $ARGV);
- while (<ARGV>) {
- .\|.\|. # code for each line
- }
- }
-
-.fi
-except that it isn't as cumbersome to say, and will actually work.
-It really does shift array ARGV and put the current filename into
-variable ARGV.
-It also uses filehandle ARGV internally\*(--<> is just a synonym for
-<ARGV>, which is magical.
-(The pseudo code above doesn't work because it treats <ARGV> as non-magical.)
-.PP
-You can modify @ARGV before the first <> as long as the array ends up
-containing the list of filenames you really want.
-Line numbers ($.) continue as if the input was one big happy file.
-(But see example under eof for how to reset line numbers on each file.)
-.PP
-.ne 5
-If you want to set @ARGV to your own list of files, go right ahead.
-If you want to pass switches into your script, you can
-put a loop on the front like this:
-.nf
-
-.ne 10
- while ($_ = $ARGV[0], /\|^\-/\|) {
- shift;
- last if /\|^\-\|\-$\|/\|;
- /\|^\-D\|(.*\|)/ \|&& \|($debug = $1);
- /\|^\-v\|/ \|&& \|$verbose++;
- .\|.\|. # other switches
- }
- while (<>) {
- .\|.\|. # code for each line
- }
-
-.fi
-The <> symbol will return FALSE only once.
-If you call it again after this it will assume you are processing another
-@ARGV list, and if you haven't set @ARGV, will input from
-.IR STDIN .
-.PP
-If the string inside the angle brackets is a reference to a scalar variable
-(e.g. <$foo>),
-then that variable contains the name of the filehandle to input from.
-.PP
-If the string inside angle brackets is not a filehandle, it is interpreted
-as a filename pattern to be globbed, and either an array of filenames or the
-next filename in the list is returned, depending on context.
-One level of $ interpretation is done first, but you can't say <$foo>
-because that's an indirect filehandle as explained in the previous
-paragraph.
-You could insert curly brackets to force interpretation as a
-filename glob: <${foo}>.
-Example:
-.nf
-
-.ne 3
- while (<*.c>) {
- chmod 0644, $_;
- }
-
-is equivalent to
-
-.ne 5
- open(foo, "echo *.c | tr \-s \' \et\er\ef\' \'\e\e012\e\e012\e\e012\e\e012\'|");
- while (<foo>) {
- chop;
- chmod 0644, $_;
- }
-
-.fi
-In fact, it's currently implemented that way.
-(Which means it will not work on filenames with spaces in them unless
-you have /bin/csh on your machine.)
-Of course, the shortest way to do the above is:
-.nf
-
- chmod 0644, <*.c>;
-
-.fi
-.Sh "Syntax"
-.PP
-A
-.I perl
-script consists of a sequence of declarations and commands.
-The only things that need to be declared in
-.I perl
-are report formats and subroutines.
-See the sections below for more information on those declarations.
-All uninitialized user-created objects are assumed to
-start with a null or 0 value until they
-are defined by some explicit operation such as assignment.
-The sequence of commands is executed just once, unlike in
-.I sed
-and
-.I awk
-scripts, where the sequence of commands is executed for each input line.
-While this means that you must explicitly loop over the lines of your input file
-(or files), it also means you have much more control over which files and which
-lines you look at.
-(Actually, I'm lying\*(--it is possible to do an implicit loop with either the
-.B \-n
-or
-.B \-p
-switch.)
-.PP
-A declaration can be put anywhere a command can, but has no effect on the
-execution of the primary sequence of commands\*(--declarations all take effect
-at compile time.
-Typically all the declarations are put at the beginning or the end of the script.
-.PP
-.I Perl
-is, for the most part, a free-form language.
-(The only exception to this is format declarations, for fairly obvious reasons.)
-Comments are indicated by the # character, and extend to the end of the line.
-If you attempt to use /* */ C comments, it will be interpreted either as
-division or pattern matching, depending on the context.
-So don't do that.
-.Sh "Compound statements"
-In
-.IR perl ,
-a sequence of commands may be treated as one command by enclosing it
-in curly brackets.
-We will call this a BLOCK.
-.PP
-The following compound commands may be used to control flow:
-.nf
-
-.ne 4
- if (EXPR) BLOCK
- if (EXPR) BLOCK else BLOCK
- if (EXPR) BLOCK elsif (EXPR) BLOCK .\|.\|. else BLOCK
- LABEL while (EXPR) BLOCK
- LABEL while (EXPR) BLOCK continue BLOCK
- LABEL for (EXPR; EXPR; EXPR) BLOCK
- LABEL foreach VAR (ARRAY) BLOCK
- LABEL BLOCK continue BLOCK
-
-.fi
-Note that, unlike C and Pascal, these are defined in terms of BLOCKs, not
-statements.
-This means that the curly brackets are \fIrequired\fR\*(--no dangling statements allowed.
-If you want to write conditionals without curly brackets there are several
-other ways to do it.
-The following all do the same thing:
-.nf
-
-.ne 5
- if (!open(foo)) { die "Can't open $foo: $!"; }
- die "Can't open $foo: $!" unless open(foo);
- open(foo) || die "Can't open $foo: $!"; # foo or bust!
- open(foo) ? \'hi mom\' : die "Can't open $foo: $!";
- # a bit exotic, that last one
-
-.fi
-.PP
-The
-.I if
-statement is straightforward.
-Since BLOCKs are always bounded by curly brackets, there is never any
-ambiguity about which
-.I if
-an
-.I else
-goes with.
-If you use
-.I unless
-in place of
-.IR if ,
-the sense of the test is reversed.
-.PP
-The
-.I while
-statement executes the block as long as the expression is true
-(does not evaluate to the null string or 0).
-The LABEL is optional, and if present, consists of an identifier followed by
-a colon.
-The LABEL identifies the loop for the loop control statements
-.IR next ,
-.IR last ,
-and
-.I redo
-(see below).
-If there is a
-.I continue
-BLOCK, it is always executed just before
-the conditional is about to be evaluated again, similarly to the third part
-of a
-.I for
-loop in C.
-Thus it can be used to increment a loop variable, even when the loop has
-been continued via the
-.I next
-statement (similar to the C \*(L"continue\*(R" statement).
-.PP
-If the word
-.I while
-is replaced by the word
-.IR until ,
-the sense of the test is reversed, but the conditional is still tested before
-the first iteration.
-.PP
-In either the
-.I if
-or the
-.I while
-statement, you may replace \*(L"(EXPR)\*(R" with a BLOCK, and the conditional
-is true if the value of the last command in that block is true.
-.PP
-The
-.I for
-loop works exactly like the corresponding
-.I while
-loop:
-.nf
-
-.ne 12
- for ($i = 1; $i < 10; $i++) {
- .\|.\|.
- }
-
-is the same as
-
- $i = 1;
- while ($i < 10) {
- .\|.\|.
- } continue {
- $i++;
- }
-.fi
-.PP
-The foreach loop iterates over a normal array value and sets the variable
-VAR to be each element of the array in turn.
-The variable is implicitly local to the loop, and regains its former value
-upon exiting the loop.
-The \*(L"foreach\*(R" keyword is actually identical to the \*(L"for\*(R" keyword,
-so you can use \*(L"foreach\*(R" for readability or \*(L"for\*(R" for brevity.
-If VAR is omitted, $_ is set to each value.
-If ARRAY is an actual array (as opposed to an expression returning an array
-value), you can modify each element of the array
-by modifying VAR inside the loop.
-Examples:
-.nf
-
-.ne 5
- for (@ary) { s/foo/bar/; }
-
- foreach $elem (@elements) {
- $elem *= 2;
- }
-
-.ne 3
- for ((10,9,8,7,6,5,4,3,2,1,\'BOOM\')) {
- print $_, "\en"; sleep(1);
- }
-
- for (1..15) { print "Merry Christmas\en"; }
-
-.ne 3
- foreach $item (split(/:[\e\e\en:]*/, $ENV{\'TERMCAP\'})) {
- print "Item: $item\en";
- }
-
-.fi
-.PP
-The BLOCK by itself (labeled or not) is equivalent to a loop that executes
-once.
-Thus you can use any of the loop control statements in it to leave or
-restart the block.
-The
-.I continue
-block is optional.
-This construct is particularly nice for doing case structures.
-.nf
-
-.ne 6
- foo: {
- if (/^abc/) { $abc = 1; last foo; }
- if (/^def/) { $def = 1; last foo; }
- if (/^xyz/) { $xyz = 1; last foo; }
- $nothing = 1;
- }
-
-.fi
-There is no official switch statement in perl, because there
-are already several ways to write the equivalent.
-In addition to the above, you could write
-.nf
-
-.ne 6
- foo: {
- $abc = 1, last foo if /^abc/;
- $def = 1, last foo if /^def/;
- $xyz = 1, last foo if /^xyz/;
- $nothing = 1;
- }
-
-or
-
-.ne 6
- foo: {
- /^abc/ && do { $abc = 1; last foo; };
- /^def/ && do { $def = 1; last foo; };
- /^xyz/ && do { $xyz = 1; last foo; };
- $nothing = 1;
- }
-
-or
-
-.ne 6
- foo: {
- /^abc/ && ($abc = 1, last foo);
- /^def/ && ($def = 1, last foo);
- /^xyz/ && ($xyz = 1, last foo);
- $nothing = 1;
- }
-
-or even
-
-.ne 8
- if (/^abc/)
- { $abc = 1; }
- elsif (/^def/)
- { $def = 1; }
- elsif (/^xyz/)
- { $xyz = 1; }
- else
- {$nothing = 1;}
-
-.fi
-As it happens, these are all optimized internally to a switch structure,
-so perl jumps directly to the desired statement, and you needn't worry
-about perl executing a lot of unnecessary statements when you have a string
-of 50 elsifs, as long as you are testing the same simple scalar variable
-using ==, eq, or pattern matching as above.
-(If you're curious as to whether the optimizer has done this for a particular
-case statement, you can use the \-D1024 switch to list the syntax tree
-before execution.)
-.Sh "Simple statements"
-The only kind of simple statement is an expression evaluated for its side
-effects.
-Every simple statement must be terminated with a semicolon, unless it is the
-final statement in a block, in which case the semicolon is optional.
-(Semicolon is still encouraged there if the block takes up more than one line).
-.PP
-Any simple statement may optionally be followed by a
-single modifier, just before the terminating semicolon.
-The possible modifiers are:
-.nf
-
-.ne 4
- if EXPR
- unless EXPR
- while EXPR
- until EXPR
-
-.fi
-The
-.I if
-and
-.I unless
-modifiers have the expected semantics.
-The
-.I while
-and
-.I until
-modifiers also have the expected semantics (conditional evaluated first),
-except when applied to a do-BLOCK or a do-SUBROUTINE command,
-in which case the block executes once before the conditional is evaluated.
-This is so that you can write loops like:
-.nf
-
-.ne 4
- do {
- $_ = <STDIN>;
- .\|.\|.
- } until $_ \|eq \|".\|\e\|n";
-
-.fi
-(See the
-.I do
-operator below. Note also that the loop control commands described later will
-NOT work in this construct, since modifiers don't take loop labels.
-Sorry.)
-.Sh "Expressions"
-Since
-.I perl
-expressions work almost exactly like C expressions, only the differences
-will be mentioned here.
-.PP
-Here's what
-.I perl
-has that C doesn't:
-.Ip ** 8 2
-The exponentiation operator.
-.Ip **= 8
-The exponentiation assignment operator.
-.Ip (\|) 8 3
-The null list, used to initialize an array to null.
-.Ip . 8
-Concatenation of two strings.
-.Ip .= 8
-The concatenation assignment operator.
-.Ip eq 8
-String equality (== is numeric equality).
-For a mnemonic just think of \*(L"eq\*(R" as a string.
-(If you are used to the
-.I awk
-behavior of using == for either string or numeric equality
-based on the current form of the comparands, beware!
-You must be explicit here.)
-.Ip ne 8
-String inequality (!= is numeric inequality).
-.Ip lt 8
-String less than.
-.Ip gt 8
-String greater than.
-.Ip le 8
-String less than or equal.
-.Ip ge 8
-String greater than or equal.
-.Ip cmp 8
-String comparison, returning -1, 0, or 1.
-.Ip <=> 8
-Numeric comparison, returning -1, 0, or 1.
-.Ip =~ 8 2
-Certain operations search or modify the string \*(L"$_\*(R" by default.
-This operator makes that kind of operation work on some other string.
-The right argument is a search pattern, substitution, or translation.
-The left argument is what is supposed to be searched, substituted, or
-translated instead of the default \*(L"$_\*(R".
-The return value indicates the success of the operation.
-(If the right argument is an expression other than a search pattern,
-substitution, or translation, it is interpreted as a search pattern
-at run time.
-This is less efficient than an explicit search, since the pattern must
-be compiled every time the expression is evaluated.)
-The precedence of this operator is lower than unary minus and autoincrement/decrement, but higher than everything else.
-.Ip !~ 8
-Just like =~ except the return value is negated.
-.Ip x 8
-The repetition operator.
-Returns a string consisting of the left operand repeated the
-number of times specified by the right operand.
-In an array context, if the left operand is a list in parens, it repeats
-the list.
-.nf
-
- print \'\-\' x 80; # print row of dashes
- print \'\-\' x80; # illegal, x80 is identifier
-
- print "\et" x ($tab/8), \' \' x ($tab%8); # tab over
-
- @ones = (1) x 80; # an array of 80 1's
- @ones = (5) x @ones; # set all elements to 5
-
-.fi
-.Ip x= 8
-The repetition assignment operator.
-Only works on scalars.
-.Ip .\|. 8
-The range operator, which is really two different operators depending
-on the context.
-In an array context, returns an array of values counting (by ones)
-from the left value to the right value.
-This is useful for writing \*(L"for (1..10)\*(R" loops and for doing
-slice operations on arrays.
-.Sp
-In a scalar context, .\|. returns a boolean value.
-The operator is bistable, like a flip-flop, and
-emulates the line-range (comma) operator of sed, awk, and various editors.
-Each .\|. operator maintains its own boolean state.
-It is false as long as its left operand is false.
-Once the left operand is true, the range operator stays true
-until the right operand is true,
-AFTER which the range operator becomes false again.
-(It doesn't become false till the next time the range operator is evaluated.
-It can test the right operand and become false on the
-same evaluation it became true (as in awk), but it still returns true once.
-If you don't want it to test the right operand till the next
-evaluation (as in sed), use three dots (.\|.\|.) instead of two.)
-The right operand is not evaluated while the operator is in the \*(L"false\*(R" state,
-and the left operand is not evaluated while the operator is in the \*(L"true\*(R" state.
-The precedence is a little lower than || and &&.
-The value returned is either the null string for false, or a sequence number
-(beginning with 1) for true.
-The sequence number is reset for each range encountered.
-The final sequence number in a range has the string \'E0\' appended to it, which
-doesn't affect its numeric value, but gives you something to search for if you
-want to exclude the endpoint.
-You can exclude the beginning point by waiting for the sequence number to be
-greater than 1.
-If either operand of scalar .\|. is static, that operand is implicitly compared
-to the $. variable, the current line number.
-Examples:
-.nf
-
-.ne 6
-As a scalar operator:
- if (101 .\|. 200) { print; } # print 2nd hundred lines
-
- next line if (1 .\|. /^$/); # skip header lines
-
- s/^/> / if (/^$/ .\|. eof()); # quote body
-
-.ne 4
-As an array operator:
- for (101 .\|. 200) { print; } # print $_ 100 times
-
- @foo = @foo[$[ .\|. $#foo]; # an expensive no-op
- @foo = @foo[$#foo-4 .\|. $#foo]; # slice last 5 items
-
-.fi
-.Ip \-x 8
-A file test.
-This unary operator takes one argument, either a filename or a filehandle,
-and tests the associated file to see if something is true about it.
-If the argument is omitted, tests $_, except for \-t, which tests
-.IR STDIN .
-It returns 1 for true and \'\' for false, or the undefined value if the
-file doesn't exist.
-Precedence is higher than logical and relational operators, but lower than
-arithmetic operators.
-The operator may be any of:
-.nf
- \-r File is readable by effective uid/gid.
- \-w File is writable by effective uid/gid.
- \-x File is executable by effective uid/gid.
- \-o File is owned by effective uid.
- \-R File is readable by real uid/gid.
- \-W File is writable by real uid/gid.
- \-X File is executable by real uid/gid.
- \-O File is owned by real uid.
- \-e File exists.
- \-z File has zero size.
- \-s File has non-zero size (returns size).
- \-f File is a plain file.
- \-d File is a directory.
- \-l File is a symbolic link.
- \-p File is a named pipe (FIFO).
- \-S File is a socket.
- \-b File is a block special file.
- \-c File is a character special file.
- \-u File has setuid bit set.
- \-g File has setgid bit set.
- \-k File has sticky bit set.
- \-t Filehandle is opened to a tty.
- \-T File is a text file.
- \-B File is a binary file (opposite of \-T).
- \-M Age of file in days when script started.
- \-A Same for access time.
- \-C Same for inode change time.
-
-.fi
-The interpretation of the file permission operators \-r, \-R, \-w, \-W, \-x and \-X
-is based solely on the mode of the file and the uids and gids of the user.
-There may be other reasons you can't actually read, write or execute the file.
-Also note that, for the superuser, \-r, \-R, \-w and \-W always return 1, and
-\-x and \-X return 1 if any execute bit is set in the mode.
-Scripts run by the superuser may thus need to do a stat() in order to determine
-the actual mode of the file, or temporarily set the uid to something else.
-.Sp
-Example:
-.nf
-.ne 7
-
- while (<>) {
- chop;
- next unless \-f $_; # ignore specials
- .\|.\|.
- }
-
-.fi
-Note that \-s/a/b/ does not do a negated substitution.
-Saying \-exp($foo) still works as expected, however\*(--only single letters
-following a minus are interpreted as file tests.
-.Sp
-The \-T and \-B switches work as follows.
-The first block or so of the file is examined for odd characters such as
-strange control codes or metacharacters.
-If too many odd characters (>10%) are found, it's a \-B file, otherwise it's a \-T file.
-Also, any file containing null in the first block is considered a binary file.
-If \-T or \-B is used on a filehandle, the current stdio buffer is examined
-rather than the first block.
-Both \-T and \-B return TRUE on a null file, or a file at EOF when testing
-a filehandle.
-.PP
-If any of the file tests (or either stat operator) are given the special
-filehandle consisting of a solitary underline, then the stat structure
-of the previous file test (or stat operator) is used, saving a system
-call.
-(This doesn't work with \-t, and you need to remember that lstat and -l
-will leave values in the stat structure for the symbolic link, not the
-real file.)
-Example:
-.nf
-
- print "Can do.\en" if -r $a || -w _ || -x _;
-
-.ne 9
- stat($filename);
- print "Readable\en" if -r _;
- print "Writable\en" if -w _;
- print "Executable\en" if -x _;
- print "Setuid\en" if -u _;
- print "Setgid\en" if -g _;
- print "Sticky\en" if -k _;
- print "Text\en" if -T _;
- print "Binary\en" if -B _;
-
-.fi
-.PP
-Here is what C has that
-.I perl
-doesn't:
-.Ip "unary &" 12
-Address-of operator.
-.Ip "unary *" 12
-Dereference-address operator.
-.Ip "(TYPE)" 12
-Type casting operator.
-.PP
-Like C,
-.I perl
-does a certain amount of expression evaluation at compile time, whenever
-it determines that all of the arguments to an operator are static and have
-no side effects.
-In particular, string concatenation happens at compile time between literals that don't do variable substitution.
-Backslash interpretation also happens at compile time.
-You can say
-.nf
-
-.ne 2
- \'Now is the time for all\' . "\|\e\|n" .
- \'good men to come to.\'
-
-.fi
-and this all reduces to one string internally.
-.PP
-The autoincrement operator has a little extra built-in magic to it.
-If you increment a variable that is numeric, or that has ever been used in
-a numeric context, you get a normal increment.
-If, however, the variable has only been used in string contexts since it
-was set, and has a value that is not null and matches the
-pattern /^[a\-zA\-Z]*[0\-9]*$/, the increment is done
-as a string, preserving each character within its range, with carry:
-.nf
-
- print ++($foo = \'99\'); # prints \*(L'100\*(R'
- print ++($foo = \'a0\'); # prints \*(L'a1\*(R'
- print ++($foo = \'Az\'); # prints \*(L'Ba\*(R'
- print ++($foo = \'zz\'); # prints \*(L'aaa\*(R'
-
-.fi
-The autodecrement is not magical.
-.PP
-The range operator (in an array context) makes use of the magical
-autoincrement algorithm if the minimum and maximum are strings.
-You can say
-
- @alphabet = (\'A\' .. \'Z\');
-
-to get all the letters of the alphabet, or
-
- $hexdigit = (0 .. 9, \'a\' .. \'f\')[$num & 15];
-
-to get a hexadecimal digit, or
-
- @z2 = (\'01\' .. \'31\'); print @z2[$mday];
-
-to get dates with leading zeros.
-(If the final value specified is not in the sequence that the magical increment
-would produce, the sequence goes until the next value would be longer than
-the final value specified.)
-.PP
-The || and && operators differ from C's in that, rather than returning 0 or 1,
-they return the last value evaluated.
-Thus, a portable way to find out the home directory might be:
-.nf
-
- $home = $ENV{'HOME'} || $ENV{'LOGDIR'} ||
- (getpwuid($<))[7] || die "You're homeless!\en";
-
-.fi
-.PP
-Along with the literals and variables mentioned earlier,
-the operations in the following section can serve as terms in an expression.
-Some of these operations take a LIST as an argument.
-Such a list can consist of any combination of scalar arguments or array values;
-the array values will be included in the list as if each individual element were
-interpolated at that point in the list, forming a longer single-dimensional
-array value.
-Elements of the LIST should be separated by commas.
-If an operation is listed both with and without parentheses around its
-arguments, it means you can either use it as a unary operator or
-as a function call.
-To use it as a function call, the next token on the same line must
-be a left parenthesis.
-(There may be intervening white space.)
-Such a function then has highest precedence, as you would expect from
-a function.
-If any token other than a left parenthesis follows, then it is a
-unary operator, with a precedence depending only on whether it is a LIST
-operator or not.
-LIST operators have lowest precedence.
-All other unary operators have a precedence greater than relational operators
-but less than arithmetic operators.
-See the section on Precedence.
-.PP
-For operators that can be used in either a scalar or array context,
-failure is generally indicated in a scalar context by returning
-the undefined value, and in an array context by returning the null list.
-Remember though that
-THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR.
-Each operator decides which sort of scalar it would be most
-appropriate to return.
-Some operators return the length of the list
-that would have been returned in an array context.
-Some operators return the first value in the list.
-Some operators return the last value in the list.
-Some operators return a count of successful operations.
-In general, they do what you want, unless you want consistency.
-.Ip "/PATTERN/" 8 4
-See m/PATTERN/.
-.Ip "?PATTERN?" 8 4
-This is just like the /pattern/ search, except that it matches only once between
-calls to the
-.I reset
-operator.
-This is a useful optimization when you only want to see the first occurrence of
-something in each file of a set of files, for instance.
-Only ?? patterns local to the current package are reset.
-.Ip "accept(NEWSOCKET,GENERICSOCKET)" 8 2
-Does the same thing that the accept system call does.
-Returns true if it succeeded, false otherwise.
-See example in section on Interprocess Communication.
-.Ip "alarm(SECONDS)" 8 4
-.Ip "alarm SECONDS" 8
-Arranges to have a SIGALRM delivered to this process after the specified number
-of seconds (minus 1, actually) have elapsed. Thus, alarm(15) will cause
-a SIGALRM at some point more than 14 seconds in the future.
-Only one timer may be counting at once. Each call disables the previous
-timer, and an argument of 0 may be supplied to cancel the previous timer
-without starting a new one.
-The returned value is the amount of time remaining on the previous timer.
-.Ip "atan2(Y,X)" 8 2
-Returns the arctangent of Y/X in the range
-.if t \-\(*p to \(*p.
-.if n \-PI to PI.
-.Ip "bind(SOCKET,NAME)" 8 2
-Does the same thing that the bind system call does.
-Returns true if it succeeded, false otherwise.
-NAME should be a packed address of the proper type for the socket.
-See example in section on Interprocess Communication.
-.Ip "binmode(FILEHANDLE)" 8 4
-.Ip "binmode FILEHANDLE" 8 4
-Arranges for the file to be read in \*(L"binary\*(R" mode in operating systems
-that distinguish between binary and text files.
-Files that are not read in binary mode have CR LF sequences translated
-to LF on input and LF translated to CR LF on output.
-Binmode has no effect under Unix.
-If FILEHANDLE is an expression, the value is taken as the name of
-the filehandle.
-.Ip "caller(EXPR)"
-.Ip "caller"
-Returns the context of the current subroutine call:
-.nf
-
- ($package,$filename,$line) = caller;
-
-.fi
-With EXPR, returns some extra information that the debugger uses to print
-a stack trace. The value of EXPR indicates how many call frames to go
-back before the current one.
-.Ip "chdir(EXPR)" 8 2
-.Ip "chdir EXPR" 8 2
-Changes the working directory to EXPR, if possible.
-If EXPR is omitted, changes to home directory.
-Returns 1 upon success, 0 otherwise.
-See example under
-.IR die .
-.Ip "chmod(LIST)" 8 2
-.Ip "chmod LIST" 8 2
-Changes the permissions of a list of files.
-The first element of the list must be the numerical mode.
-Returns the number of files successfully changed.
-.nf
-
-.ne 2
- $cnt = chmod 0755, \'foo\', \'bar\';
- chmod 0755, @executables;
-
-.fi
-.Ip "chop(LIST)" 8 7
-.Ip "chop(VARIABLE)" 8
-.Ip "chop VARIABLE" 8
-.Ip "chop" 8
-Chops off the last character of a string and returns the character chopped.
-It's used primarily to remove the newline from the end of an input record,
-but is much more efficient than s/\en// because it neither scans nor copies
-the string.
-If VARIABLE is omitted, chops $_.
-Example:
-.nf
-
-.ne 5
- while (<>) {
- chop; # avoid \en on last field
- @array = split(/:/);
- .\|.\|.
- }
-
-.fi
-You can actually chop anything that's an lvalue, including an assignment:
-.nf
-
- chop($cwd = \`pwd\`);
- chop($answer = <STDIN>);
-
-.fi
-If you chop a list, each element is chopped.
-Only the value of the last chop is returned.
-.Ip "chown(LIST)" 8 2
-.Ip "chown LIST" 8 2
-Changes the owner (and group) of a list of files.
-The first two elements of the list must be the NUMERICAL uid and gid,
-in that order.
-Returns the number of files successfully changed.
-.nf
-
-.ne 2
- $cnt = chown $uid, $gid, \'foo\', \'bar\';
- chown $uid, $gid, @filenames;
-
-.fi
-.ne 23
-Here's an example that looks up non-numeric uids in the passwd file:
-.nf
-
- print "User: ";
- $user = <STDIN>;
- chop($user);
- print "Files: "
- $pattern = <STDIN>;
- chop($pattern);
-.ie t \{\
- open(pass, \'/etc/passwd\') || die "Can't open passwd: $!\en";
-'br\}
-.el \{\
- open(pass, \'/etc/passwd\')
- || die "Can't open passwd: $!\en";
-'br\}
- while (<pass>) {
- ($login,$pass,$uid,$gid) = split(/:/);
- $uid{$login} = $uid;
- $gid{$login} = $gid;
- }
- @ary = <${pattern}>; # get filenames
- if ($uid{$user} eq \'\') {
- die "$user not in passwd file";
- }
- else {
- chown $uid{$user}, $gid{$user}, @ary;
- }
-
-.fi
-.Ip "chroot(FILENAME)" 8 5
-.Ip "chroot FILENAME" 8
-Does the same as the system call of that name.
-If you don't know what it does, don't worry about it.
-If FILENAME is omitted, does chroot to $_.
-.Ip "close(FILEHANDLE)" 8 5
-.Ip "close FILEHANDLE" 8
-Closes the file or pipe associated with the file handle.
-You don't have to close FILEHANDLE if you are immediately going to
-do another open on it, since open will close it for you.
-(See
-.IR open .)
-However, an explicit close on an input file resets the line counter ($.), while
-the implicit close done by
-.I open
-does not.
-Also, closing a pipe will wait for the process executing on the pipe to complete,
-in case you want to look at the output of the pipe afterwards.
-Closing a pipe explicitly also puts the status value of the command into $?.
-Example:
-.nf
-
-.ne 4
- open(OUTPUT, \'|sort >foo\'); # pipe to sort
- .\|.\|. # print stuff to output
- close OUTPUT; # wait for sort to finish
- open(INPUT, \'foo\'); # get sort's results
-
-.fi
-FILEHANDLE may be an expression whose value gives the real filehandle name.
-.Ip "closedir(DIRHANDLE)" 8 5
-.Ip "closedir DIRHANDLE" 8
-Closes a directory opened by opendir().
-.Ip "connect(SOCKET,NAME)" 8 2
-Does the same thing that the connect system call does.
-Returns true if it succeeded, false otherwise.
-NAME should be a package address of the proper type for the socket.
-See example in section on Interprocess Communication.
-.Ip "cos(EXPR)" 8 6
-.Ip "cos EXPR" 8 6
-Returns the cosine of EXPR (expressed in radians).
-If EXPR is omitted takes cosine of $_.
-.Ip "crypt(PLAINTEXT,SALT)" 8 6
-Encrypts a string exactly like the crypt() function in the C library.
-Useful for checking the password file for lousy passwords.
-Only the guys wearing white hats should do this.
-.Ip "dbmclose(ASSOC_ARRAY)" 8 6
-.Ip "dbmclose ASSOC_ARRAY" 8
-Breaks the binding between a dbm file and an associative array.
-The values remaining in the associative array are meaningless unless
-you happen to want to know what was in the cache for the dbm file.
-This function is only useful if you have ndbm.
-.Ip "dbmopen(ASSOC,DBNAME,MODE)" 8 6
-This binds a dbm or ndbm file to an associative array.
-ASSOC is the name of the associative array.
-(Unlike normal open, the first argument is NOT a filehandle, even though
-it looks like one).
-DBNAME is the name of the database (without the .dir or .pag extension).
-If the database does not exist, it is created with protection specified
-by MODE (as modified by the umask).
-If your system only supports the older dbm functions, you may perform only one
-dbmopen in your program.
-If your system has neither dbm nor ndbm, calling dbmopen produces a fatal
-error.
-.Sp
-Values assigned to the associative array prior to the dbmopen are lost.
-A certain number of values from the dbm file are cached in memory.
-By default this number is 64, but you can increase it by preallocating
-that number of garbage entries in the associative array before the dbmopen.
-You can flush the cache if necessary with the reset command.
-.Sp
-If you don't have write access to the dbm file, you can only read
-associative array variables, not set them.
-If you want to test whether you can write, either use file tests or
-try setting a dummy array entry inside an eval, which will trap the error.
-.Sp
-Note that functions such as keys() and values() may return huge array values
-when used on large dbm files.
-You may prefer to use the each() function to iterate over large dbm files.
-Example:
-.nf
-
-.ne 6
- # print out history file offsets
- dbmopen(HIST,'/usr/lib/news/history',0666);
- while (($key,$val) = each %HIST) {
- print $key, ' = ', unpack('L',$val), "\en";
- }
- dbmclose(HIST);
-
-.fi
-.Ip "defined(EXPR)" 8 6
-.Ip "defined EXPR" 8
-Returns a boolean value saying whether the lvalue EXPR has a real value
-or not.
-Many operations return the undefined value under exceptional conditions,
-such as end of file, uninitialized variable, system error and such.
-This function allows you to distinguish between an undefined null string
-and a defined null string with operations that might return a real null
-string, in particular referencing elements of an array.
-You may also check to see if arrays or subroutines exist.
-Use on predefined variables is not guaranteed to produce intuitive results.
-Examples:
-.nf
-
-.ne 7
- print if defined $switch{'D'};
- print "$val\en" while defined($val = pop(@ary));
- die "Can't readlink $sym: $!"
- unless defined($value = readlink $sym);
- eval '@foo = ()' if defined(@foo);
- die "No XYZ package defined" unless defined %_XYZ;
- sub foo { defined &$bar ? &$bar(@_) : die "No bar"; }
-
-.fi
-See also undef.
-.Ip "delete $ASSOC{KEY}" 8 6
-Deletes the specified value from the specified associative array.
-Returns the deleted value, or the undefined value if nothing was deleted.
-Deleting from $ENV{} modifies the environment.
-Deleting from an array bound to a dbm file deletes the entry from the dbm
-file.
-.Sp
-The following deletes all the values of an associative array:
-.nf
-
-.ne 3
- foreach $key (keys %ARRAY) {
- delete $ARRAY{$key};
- }
-
-.fi
-(But it would be faster to use the
-.I reset
-command.
-Saying undef %ARRAY is faster yet.)
-.Ip "die(LIST)" 8
-.Ip "die LIST" 8
-Outside of an eval, prints the value of LIST to
-.I STDERR
-and exits with the current value of $!
-(errno).
-If $! is 0, exits with the value of ($? >> 8) (\`command\` status).
-If ($? >> 8) is 0, exits with 255.
-Inside an eval, the error message is stuffed into $@ and the eval is terminated
-with the undefined value.
-.Sp
-Equivalent examples:
-.nf
-
-.ne 3
-.ie t \{\
- die "Can't cd to spool: $!\en" unless chdir \'/usr/spool/news\';
-'br\}
-.el \{\
- die "Can't cd to spool: $!\en"
- unless chdir \'/usr/spool/news\';
-'br\}
-
- chdir \'/usr/spool/news\' || die "Can't cd to spool: $!\en"
-
-.fi
-.Sp
-If the value of EXPR does not end in a newline, the current script line
-number and input line number (if any) are also printed, and a newline is
-supplied.
-Hint: sometimes appending \*(L", stopped\*(R" to your message will cause it to make
-better sense when the string \*(L"at foo line 123\*(R" is appended.
-Suppose you are running script \*(L"canasta\*(R".
-.nf
-
-.ne 7
- die "/etc/games is no good";
- die "/etc/games is no good, stopped";
-
-produce, respectively
-
- /etc/games is no good at canasta line 123.
- /etc/games is no good, stopped at canasta line 123.
-
-.fi
-See also
-.IR exit .
-.Ip "do BLOCK" 8 4
-Returns the value of the last command in the sequence of commands indicated
-by BLOCK.
-When modified by a loop modifier, executes the BLOCK once before testing the
-loop condition.
-(On other statements the loop modifiers test the conditional first.)
-.Ip "do SUBROUTINE (LIST)" 8 3
-Executes a SUBROUTINE declared by a
-.I sub
-declaration, and returns the value
-of the last expression evaluated in SUBROUTINE.
-If there is no subroutine by that name, produces a fatal error.
-(You may use the \*(L"defined\*(R" operator to determine if a subroutine
-exists.)
-If you pass arrays as part of LIST you may wish to pass the length
-of the array in front of each array.
-(See the section on subroutines later on.)
-The parentheses are required to avoid confusion with the \*(L"do EXPR\*(R"
-form.
-.Sp
-SUBROUTINE may also be a single scalar variable, in which case
-the name of the subroutine to execute is taken from the variable.
-.Sp
-As an alternate (and preferred) form,
-you may call a subroutine by prefixing the name with
-an ampersand: &foo(@args).
-If you aren't passing any arguments, you don't have to use parentheses.
-If you omit the parentheses, no @_ array is passed to the subroutine.
-The & form is also used to specify subroutines to the defined and undef
-operators:
-.nf
-
- if (defined &$var) { &$var($parm); undef &$var; }
-
-.fi
-.Ip "do EXPR" 8 3
-Uses the value of EXPR as a filename and executes the contents of the file
-as a
-.I perl
-script.
-Its primary use is to include subroutines from a
-.I perl
-subroutine library.
-.nf
-
- do \'stat.pl\';
-
-is just like
-
- eval \`cat stat.pl\`;
-
-.fi
-except that it's more efficient, more concise, keeps track of the current
-filename for error messages, and searches all the
-.B \-I
-libraries if the file
-isn't in the current directory (see also the @INC array in Predefined Names).
-It's the same, however, in that it does reparse the file every time you
-call it, so if you are going to use the file inside a loop you might prefer
-to use \-P and #include, at the expense of a little more startup time.
-(The main problem with #include is that cpp doesn't grok # comments\*(--a
-workaround is to use \*(L";#\*(R" for standalone comments.)
-Note that the following are NOT equivalent:
-.nf
-
-.ne 2
- do $foo; # eval a file
- do $foo(); # call a subroutine
-
-.fi
-Note that inclusion of library routines is better done with
-the \*(L"require\*(R" operator.
-.Ip "dump LABEL" 8 6
-This causes an immediate core dump.
-Primarily this is so that you can use the undump program to turn your
-core dump into an executable binary after having initialized all your
-variables at the beginning of the program.
-When the new binary is executed it will begin by executing a "goto LABEL"
-(with all the restrictions that goto suffers).
-Think of it as a goto with an intervening core dump and reincarnation.
-If LABEL is omitted, restarts the program from the top.
-WARNING: any files opened at the time of the dump will NOT be open any more
-when the program is reincarnated, with possible resulting confusion on the part
-of perl.
-See also \-u.
-.Sp
-Example:
-.nf
-
-.ne 16
- #!/usr/bin/perl
- require 'getopt.pl';
- require 'stat.pl';
- %days = (
- 'Sun',1,
- 'Mon',2,
- 'Tue',3,
- 'Wed',4,
- 'Thu',5,
- 'Fri',6,
- 'Sat',7);
-
- dump QUICKSTART if $ARGV[0] eq '-d';
-
- QUICKSTART:
- do Getopt('f');
-
-.fi
-.Ip "each(ASSOC_ARRAY)" 8 6
-.Ip "each ASSOC_ARRAY" 8
-Returns a 2 element array consisting of the key and value for the next
-value of an associative array, so that you can iterate over it.
-Entries are returned in an apparently random order.
-When the array is entirely read, a null array is returned (which when
-assigned produces a FALSE (0) value).
-The next call to each() after that will start iterating again.
-The iterator can be reset only by reading all the elements from the array.
-You must not modify the array while iterating over it.
-There is a single iterator for each associative array, shared by all
-each(), keys() and values() function calls in the program.
-The following prints out your environment like the printenv program, only
-in a different order:
-.nf
-
-.ne 3
- while (($key,$value) = each %ENV) {
- print "$key=$value\en";
- }
-
-.fi
-See also keys() and values().
-.Ip "eof(FILEHANDLE)" 8 8
-.Ip "eof()" 8
-.Ip "eof" 8
-Returns 1 if the next read on FILEHANDLE will return end of file, or if
-FILEHANDLE is not open.
-FILEHANDLE may be an expression whose value gives the real filehandle name.
-(Note that this function actually reads a character and then ungetc's it,
-so it is not very useful in an interactive context.)
-An eof without an argument returns the eof status for the last file read.
-Empty parentheses () may be used to indicate the pseudo file formed of the
-files listed on the command line, i.e. eof() is reasonable to use inside
-a while (<>) loop to detect the end of only the last file.
-Use eof(ARGV) or eof without the parentheses to test EACH file in a while (<>) loop.
-Examples:
-.nf
-
-.ne 7
- # insert dashes just before last line of last file
- while (<>) {
- if (eof()) {
- print "\-\|\-\|\-\|\-\|\-\|\-\|\-\|\-\|\-\|\-\|\-\|\-\|\-\|\-\en";
- }
- print;
- }
-
-.ne 7
- # reset line numbering on each input file
- while (<>) {
- print "$.\et$_";
- if (eof) { # Not eof().
- close(ARGV);
- }
- }
-
-.fi
-.Ip "eval(EXPR)" 8 6
-.Ip "eval EXPR" 8 6
-.Ip "eval BLOCK" 8 6
-EXPR is parsed and executed as if it were a little
-.I perl
-program.
-It is executed in the context of the current
-.I perl
-program, so that
-any variable settings, subroutine or format definitions remain afterwards.
-The value returned is the value of the last expression evaluated, just
-as with subroutines.
-If there is a syntax error or runtime error, or a die statement is
-executed, an undefined value is returned by
-eval, and $@ is set to the error message.
-If there was no error, $@ is guaranteed to be a null string.
-If EXPR is omitted, evaluates $_.
-The final semicolon, if any, may be omitted from the expression.
-.Sp
-Note that, since eval traps otherwise-fatal errors, it is useful for
-determining whether a particular feature
-(such as dbmopen or symlink) is implemented.
-It is also Perl's exception trapping mechanism, where the die operator is
-used to raise exceptions.
-.Sp
-If the code to be executed doesn't vary, you may use
-the eval-BLOCK form to trap run-time errors without incurring
-the penalty of recompiling each time.
-The error, if any, is still returned in $@.
-Evaluating a single-quoted string (as EXPR) has the same effect, except that
-the eval-EXPR form reports syntax errors at run time via $@, whereas the
-eval-BLOCK form reports syntax errors at compile time. The eval-EXPR form
-is optimized to eval-BLOCK the first time it succeeds. (Since the replacement
-side of a substitution is considered a single-quoted string when you
-use the e modifier, the same optimization occurs there.) Examples:
-.nf
-
-.ne 11
- # make divide-by-zero non-fatal
- eval { $answer = $a / $b; }; warn $@ if $@;
-
- # optimized to same thing after first use
- eval '$answer = $a / $b'; warn $@ if $@;
-
- # a compile-time error
- eval { $answer = };
-
- # a run-time error
- eval '$answer ='; # sets $@
-
-.fi
-.Ip "exec(LIST)" 8 8
-.Ip "exec LIST" 8 6
-If there is more than one argument in LIST, or if LIST is an array with
-more than one value,
-calls execvp() with the arguments in LIST.
-If there is only one scalar argument, the argument is checked for shell metacharacters.
-If there are any, the entire argument is passed to \*(L"/bin/sh \-c\*(R" for parsing.
-If there are none, the argument is split into words and passed directly to
-execvp(), which is more efficient.
-Note: exec (and system) do not flush your output buffer, so you may need to
-set $| to avoid lost output.
-Examples:
-.nf
-
- exec \'/bin/echo\', \'Your arguments are: \', @ARGV;
- exec "sort $outfile | uniq";
-
-.fi
-.Sp
-If you don't really want to execute the first argument, but want to lie
-to the program you are executing about its own name, you can specify
-the program you actually want to run by assigning that to a variable and
-putting the name of the variable in front of the LIST without a comma.
-(This always forces interpretation of the LIST as a multi-valued list, even
-if there is only a single scalar in the list.)
-Example:
-.nf
-
-.ne 2
- $shell = '/bin/csh';
- exec $shell '-sh'; # pretend it's a login shell
-
-.fi
-.Ip "exit(EXPR)" 8 6
-.Ip "exit EXPR" 8
-Evaluates EXPR and exits immediately with that value.
-Example:
-.nf
-
-.ne 2
- $ans = <STDIN>;
- exit 0 \|if \|$ans \|=~ \|/\|^[Xx]\|/\|;
-
-.fi
-See also
-.IR die .
-If EXPR is omitted, exits with 0 status.
-.Ip "exp(EXPR)" 8 3
-.Ip "exp EXPR" 8
-Returns
-.I e
-to the power of EXPR.
-If EXPR is omitted, gives exp($_).
-.Ip "fcntl(FILEHANDLE,FUNCTION,SCALAR)" 8 4
-Implements the fcntl(2) function.
-You'll probably have to say
-.nf
-
- require "fcntl.ph"; # probably /usr/local/lib/perl/fcntl.ph
-
-.fi
-first to get the correct function definitions.
-If fcntl.ph doesn't exist or doesn't have the correct definitions
-you'll have to roll
-your own, based on your C header files such as <sys/fcntl.h>.
-(There is a perl script called h2ph that comes with the perl kit
-which may help you in this.)
-Argument processing and value return works just like ioctl below.
-Note that fcntl will produce a fatal error if used on a machine that doesn't implement
-fcntl(2).
-.Ip "fileno(FILEHANDLE)" 8 4
-.Ip "fileno FILEHANDLE" 8 4
-Returns the file descriptor for a filehandle.
-Useful for constructing bitmaps for select().
-If FILEHANDLE is an expression, the value is taken as the name of
-the filehandle.
-.Ip "flock(FILEHANDLE,OPERATION)" 8 4
-Calls flock(2) on FILEHANDLE.
-See manual page for flock(2) for definition of OPERATION.
-Returns true for success, false on failure.
-Will produce a fatal error if used on a machine that doesn't implement
-flock(2).
-Here's a mailbox appender for BSD systems.
-.nf
-
-.ne 20
- $LOCK_SH = 1;
- $LOCK_EX = 2;
- $LOCK_NB = 4;
- $LOCK_UN = 8;
-
- sub lock {
- flock(MBOX,$LOCK_EX);
- # and, in case someone appended
- # while we were waiting...
- seek(MBOX, 0, 2);
- }
-
- sub unlock {
- flock(MBOX,$LOCK_UN);
- }
-
- open(MBOX, ">>/usr/spool/mail/$ENV{'USER'}")
- || die "Can't open mailbox: $!";
-
- do lock();
- print MBOX $msg,"\en\en";
- do unlock();
-
-.fi
-.Ip "fork" 8 4
-Does a fork() call.
-Returns the child pid to the parent process and 0 to the child process.
-Note: unflushed buffers remain unflushed in both processes, which means
-you may need to set $| to avoid duplicate output.
-.Ip "getc(FILEHANDLE)" 8 4
-.Ip "getc FILEHANDLE" 8
-.Ip "getc" 8
-Returns the next character from the input file attached to FILEHANDLE, or
-a null string at EOF.
-If FILEHANDLE is omitted, reads from STDIN.
-.Ip "getlogin" 8 3
-Returns the current login from /etc/utmp, if any.
-If null, use getpwuid.
-
- $login = getlogin || (getpwuid($<))[0] || "Somebody";
-
-.Ip "getpeername(SOCKET)" 8 3
-Returns the packed sockaddr address of other end of the SOCKET connection.
-.nf
-
-.ne 4
- # An internet sockaddr
- $sockaddr = 'S n a4 x8';
- $hersockaddr = getpeername(S);
-.ie t \{\
- ($family, $port, $heraddr) = unpack($sockaddr,$hersockaddr);
-'br\}
-.el \{\
- ($family, $port, $heraddr) =
- unpack($sockaddr,$hersockaddr);
-'br\}
-
-.fi
-.Ip "getpgrp(PID)" 8 4
-.Ip "getpgrp PID" 8
-Returns the current process group for the specified PID, 0 for the current
-process.
-Will produce a fatal error if used on a machine that doesn't implement
-getpgrp(2).
-If EXPR is omitted, returns process group of current process.
-.Ip "getppid" 8 4
-Returns the process id of the parent process.
-.Ip "getpriority(WHICH,WHO)" 8 4
-Returns the current priority for a process, a process group, or a user.
-(See getpriority(2).)
-Will produce a fatal error if used on a machine that doesn't implement
-getpriority(2).
-.Ip "getpwnam(NAME)" 8
-.Ip "getgrnam(NAME)" 8
-.Ip "gethostbyname(NAME)" 8
-.Ip "getnetbyname(NAME)" 8
-.Ip "getprotobyname(NAME)" 8
-.Ip "getpwuid(UID)" 8
-.Ip "getgrgid(GID)" 8
-.Ip "getservbyname(NAME,PROTO)" 8
-.Ip "gethostbyaddr(ADDR,ADDRTYPE)" 8
-.Ip "getnetbyaddr(ADDR,ADDRTYPE)" 8
-.Ip "getprotobynumber(NUMBER)" 8
-.Ip "getservbyport(PORT,PROTO)" 8
-.Ip "getpwent" 8
-.Ip "getgrent" 8
-.Ip "gethostent" 8
-.Ip "getnetent" 8
-.Ip "getprotoent" 8
-.Ip "getservent" 8
-.Ip "setpwent" 8
-.Ip "setgrent" 8
-.Ip "sethostent(STAYOPEN)" 8
-.Ip "setnetent(STAYOPEN)" 8
-.Ip "setprotoent(STAYOPEN)" 8
-.Ip "setservent(STAYOPEN)" 8
-.Ip "endpwent" 8
-.Ip "endgrent" 8
-.Ip "endhostent" 8
-.Ip "endnetent" 8
-.Ip "endprotoent" 8
-.Ip "endservent" 8
-These routines perform the same functions as their counterparts in the
-system library.
-Within an array context,
-the return values from the various get routines are as follows:
-.nf
-
- ($name,$passwd,$uid,$gid,
- $quota,$comment,$gcos,$dir,$shell) = getpw.\|.\|.
- ($name,$passwd,$gid,$members) = getgr.\|.\|.
- ($name,$aliases,$addrtype,$length,@addrs) = gethost.\|.\|.
- ($name,$aliases,$addrtype,$net) = getnet.\|.\|.
- ($name,$aliases,$proto) = getproto.\|.\|.
- ($name,$aliases,$port,$proto) = getserv.\|.\|.
-
-.fi
-(If the entry doesn't exist you get a null list.)
-.Sp
-Within a scalar context, you get the name, unless the function was a
-lookup by name, in which case you get the other thing, whatever it is.
-(If the entry doesn't exist you get the undefined value.)
-For example:
-.nf
-
- $uid = getpwnam
- $name = getpwuid
- $name = getpwent
- $gid = getgrnam
- $name = getgrgid
- $name = getgrent
- etc.
-
-.fi
-The $members value returned by getgr.\|.\|. is a space separated list
-of the login names of the members of the group.
-.Sp
-For the gethost.\|.\|. functions, if the h_errno variable is supported in C,
-it will be returned to you via $? if the function call fails.
-The @addrs value returned by a successful call is a list of the
-raw addresses returned by the corresponding system library call.
-In the Internet domain, each address is four bytes long and you can unpack
-it by saying something like:
-.nf
-
- ($a,$b,$c,$d) = unpack('C4',$addr[0]);
-
-.fi
-.Ip "getsockname(SOCKET)" 8 3
-Returns the packed sockaddr address of this end of the SOCKET connection.
-.nf
-
-.ne 4
- # An internet sockaddr
- $sockaddr = 'S n a4 x8';
- $mysockaddr = getsockname(S);
-.ie t \{\
- ($family, $port, $myaddr) = unpack($sockaddr,$mysockaddr);
-'br\}
-.el \{\
- ($family, $port, $myaddr) =
- unpack($sockaddr,$mysockaddr);
-'br\}
-
-.fi
-.Ip "getsockopt(SOCKET,LEVEL,OPTNAME)" 8 3
-Returns the socket option requested, or undefined if there is an error.
-.Ip "gmtime(EXPR)" 8 4
-.Ip "gmtime EXPR" 8
-Converts a time as returned by the time function to a 9-element array with
-the time analyzed for the Greenwich timezone.
-Typically used as follows:
-.nf
-
-.ne 3
-.ie t \{\
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
-'br\}
-.el \{\
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
- gmtime(time);
-'br\}
-
-.fi
-All array elements are numeric, and come straight out of a struct tm.
-In particular this means that $mon has the range 0.\|.11 and $wday has the
-range 0.\|.6.
-If EXPR is omitted, does gmtime(time).
-.Ip "goto LABEL" 8 6
-Finds the statement labeled with LABEL and resumes execution there.
-Currently you may only go to statements in the main body of the program
-that are not nested inside a do {} construct.
-This statement is not implemented very efficiently, and is here only to make
-the
-.IR sed -to- perl
-translator easier.
-I may change its semantics at any time, consistent with support for translated
-.I sed
-scripts.
-Use it at your own risk.
-Better yet, don't use it at all.
-.Ip "grep(EXPR,LIST)" 8 4
-Evaluates EXPR for each element of LIST (locally setting $_ to each element)
-and returns the array value consisting of those elements for which the
-expression evaluated to true.
-In a scalar context, returns the number of times the expression was true.
-.nf
-
- @foo = grep(!/^#/, @bar); # weed out comments
-
-.fi
-Note that, since $_ is a reference into the array value, it can be
-used to modify the elements of the array.
-While this is useful and supported, it can cause bizarre results if
-the LIST is not a named array.
-.Ip "hex(EXPR)" 8 4
-.Ip "hex EXPR" 8
-Returns the decimal value of EXPR interpreted as an hex string.
-(To interpret strings that might start with 0 or 0x see oct().)
-If EXPR is omitted, uses $_.
-.Ip "index(STR,SUBSTR,POSITION)" 8 4
-.Ip "index(STR,SUBSTR)" 8 4
-Returns the position of the first occurrence of SUBSTR in STR at or after
-POSITION.
-If POSITION is omitted, starts searching from the beginning of the string.
-The return value is based at 0, or whatever you've
-set the $[ variable to.
-If the substring is not found, returns one less than the base, ordinarily \-1.
-.Ip "int(EXPR)" 8 4
-.Ip "int EXPR" 8
-Returns the integer portion of EXPR.
-If EXPR is omitted, uses $_.
-.Ip "ioctl(FILEHANDLE,FUNCTION,SCALAR)" 8 4
-Implements the ioctl(2) function.
-You'll probably have to say
-.nf
-
- require "ioctl.ph"; # probably /usr/local/lib/perl/ioctl.ph
-
-.fi
-first to get the correct function definitions.
-If ioctl.ph doesn't exist or doesn't have the correct definitions
-you'll have to roll
-your own, based on your C header files such as <sys/ioctl.h>.
-(There is a perl script called h2ph that comes with the perl kit
-which may help you in this.)
-SCALAR will be read and/or written depending on the FUNCTION\*(--a pointer
-to the string value of SCALAR will be passed as the third argument of
-the actual ioctl call.
-(If SCALAR has no string value but does have a numeric value, that value
-will be passed rather than a pointer to the string value.
-To guarantee this to be true, add a 0 to the scalar before using it.)
-The pack() and unpack() functions are useful for manipulating the values
-of structures used by ioctl().
-The following example sets the erase character to DEL.
-.nf
-
-.ne 9
- require 'ioctl.ph';
- $sgttyb_t = "ccccs"; # 4 chars and a short
- if (ioctl(STDIN,$TIOCGETP,$sgttyb)) {
- @ary = unpack($sgttyb_t,$sgttyb);
- $ary[2] = 127;
- $sgttyb = pack($sgttyb_t,@ary);
- ioctl(STDIN,$TIOCSETP,$sgttyb)
- || die "Can't ioctl: $!";
- }
-
-.fi
-The return value of ioctl (and fcntl) is as follows:
-.nf
-
-.ne 4
- if OS returns:\h'|3i'perl returns:
- -1\h'|3i' undefined value
- 0\h'|3i' string "0 but true"
- anything else\h'|3i' that number
-
-.fi
-Thus perl returns true on success and false on failure, yet you can still
-easily determine the actual value returned by the operating system:
-.nf
-
- ($retval = ioctl(...)) || ($retval = -1);
- printf "System returned %d\en", $retval;
-.fi
-.Ip "join(EXPR,LIST)" 8 8
-.Ip "join(EXPR,ARRAY)" 8
-Joins the separate strings of LIST or ARRAY into a single string with fields
-separated by the value of EXPR, and returns the string.
-Example:
-.nf
-
-.ie t \{\
- $_ = join(\|\':\', $login,$passwd,$uid,$gid,$gcos,$home,$shell);
-'br\}
-.el \{\
- $_ = join(\|\':\',
- $login,$passwd,$uid,$gid,$gcos,$home,$shell);
-'br\}
-
-.fi
-See
-.IR split .
-.Ip "keys(ASSOC_ARRAY)" 8 6
-.Ip "keys ASSOC_ARRAY" 8
-Returns a normal array consisting of all the keys of the named associative
-array.
-The keys are returned in an apparently random order, but it is the same order
-as either the values() or each() function produces (given that the associative array
-has not been modified).
-Here is yet another way to print your environment:
-.nf
-
-.ne 5
- @keys = keys %ENV;
- @values = values %ENV;
- while ($#keys >= 0) {
- print pop(@keys), \'=\', pop(@values), "\en";
- }
-
-or how about sorted by key:
-
-.ne 3
- foreach $key (sort(keys %ENV)) {
- print $key, \'=\', $ENV{$key}, "\en";
- }
-
-.fi
-.Ip "kill(LIST)" 8 8
-.Ip "kill LIST" 8 2
-Sends a signal to a list of processes.
-The first element of the list must be the signal to send.
-Returns the number of processes successfully signaled.
-.nf
-
- $cnt = kill 1, $child1, $child2;
- kill 9, @goners;
-
-.fi
-If the signal is negative, kills process groups instead of processes.
-(On System V, a negative \fIprocess\fR number will also kill process groups,
-but that's not portable.)
-You may use a signal name in quotes.
-.Ip "last LABEL" 8 8
-.Ip "last" 8
-The
-.I last
-command is like the
-.I break
-statement in C (as used in loops); it immediately exits the loop in question.
-If the LABEL is omitted, the command refers to the innermost enclosing loop.
-The
-.I continue
-block, if any, is not executed:
-.nf
-
-.ne 4
- line: while (<STDIN>) {
- last line if /\|^$/; # exit when done with header
- .\|.\|.
- }
-
-.fi
-.Ip "length(EXPR)" 8 4
-.Ip "length EXPR" 8
-Returns the length in characters of the value of EXPR.
-If EXPR is omitted, returns length of $_.
-.Ip "link(OLDFILE,NEWFILE)" 8 2
-Creates a new filename linked to the old filename.
-Returns 1 for success, 0 otherwise.
-.Ip "listen(SOCKET,QUEUESIZE)" 8 2
-Does the same thing that the listen system call does.
-Returns true if it succeeded, false otherwise.
-See example in section on Interprocess Communication.
-.Ip "local(LIST)" 8 4
-Declares the listed variables to be local to the enclosing block,
-subroutine, eval or \*(L"do\*(R".
-All the listed elements must be legal lvalues.
-This operator works by saving the current values of those variables in LIST
-on a hidden stack and restoring them upon exiting the block, subroutine or eval.
-This means that called subroutines can also reference the local variable,
-but not the global one.
-The LIST may be assigned to if desired, which allows you to initialize
-your local variables.
-(If no initializer is given for a particular variable, it is created with
-an undefined value.)
-Commonly this is used to name the parameters to a subroutine.
-Examples:
-.nf
-
-.ne 13
- sub RANGEVAL {
- local($min, $max, $thunk) = @_;
- local($result) = \'\';
- local($i);
-
- # Presumably $thunk makes reference to $i
-
- for ($i = $min; $i < $max; $i++) {
- $result .= eval $thunk;
- }
-
- $result;
- }
-
-.ne 6
- if ($sw eq \'-v\') {
- # init local array with global array
- local(@ARGV) = @ARGV;
- unshift(@ARGV,\'echo\');
- system @ARGV;
- }
- # @ARGV restored
-
-.ne 6
- # temporarily add to digits associative array
- if ($base12) {
- # (NOTE: not claiming this is efficient!)
- local(%digits) = (%digits,'t',10,'e',11);
- do parse_num();
- }
-
-.fi
-Note that local() is a run-time command, and so gets executed every time
-through a loop, using up more stack storage each time until it's all
-released at once when the loop is exited.
-.Ip "localtime(EXPR)" 8 4
-.Ip "localtime EXPR" 8
-Converts a time as returned by the time function to a 9-element array with
-the time analyzed for the local timezone.
-Typically used as follows:
-.nf
-
-.ne 3
-.ie t \{\
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
-'br\}
-.el \{\
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
- localtime(time);
-'br\}
-
-.fi
-All array elements are numeric, and come straight out of a struct tm.
-In particular this means that $mon has the range 0.\|.11 and $wday has the
-range 0.\|.6.
-If EXPR is omitted, does localtime(time).
-.Ip "log(EXPR)" 8 4
-.Ip "log EXPR" 8
-Returns logarithm (base
-.IR e )
-of EXPR.
-If EXPR is omitted, returns log of $_.
-.Ip "lstat(FILEHANDLE)" 8 6
-.Ip "lstat FILEHANDLE" 8
-.Ip "lstat(EXPR)" 8
-.Ip "lstat SCALARVARIABLE" 8
-Does the same thing as the stat() function, but stats a symbolic link
-instead of the file the symbolic link points to.
-If symbolic links are unimplemented on your system, a normal stat is done.
-.Ip "m/PATTERN/gio" 8 4
-.Ip "/PATTERN/gio" 8
-Searches a string for a pattern match, and returns true (1) or false (\'\').
-If no string is specified via the =~ or !~ operator,
-the $_ string is searched.
-(The string specified with =~ need not be an lvalue\*(--it may be the result of an expression evaluation, but remember the =~ binds rather tightly.)
-See also the section on regular expressions.
-.Sp
-If / is the delimiter then the initial \*(L'm\*(R' is optional.
-With the \*(L'm\*(R' you can use any pair of non-alphanumeric characters
-as delimiters.
-This is particularly useful for matching Unix path names that contain \*(L'/\*(R'.
-If the final delimiter is followed by the optional letter \*(L'i\*(R', the matching is
-done in a case-insensitive manner.
-PATTERN may contain references to scalar variables, which will be interpolated
-(and the pattern recompiled) every time the pattern search is evaluated.
-(Note that $) and $| may not be interpolated because they look like end-of-string tests.)
-If you want such a pattern to be compiled only once, add an \*(L"o\*(R" after
-the trailing delimiter.
-This avoids expensive run-time recompilations, and
-is useful when the value you are interpolating won't change over the
-life of the script.
-If the PATTERN evaluates to a null string, the most recent successful
-regular expression is used instead.
-.Sp
-If used in a context that requires an array value, a pattern match returns an
-array consisting of the subexpressions matched by the parentheses in the
-pattern,
-i.e. ($1, $2, $3.\|.\|.).
-It does NOT actually set $1, $2, etc. in this case, nor does it set $+, $`, $&
-or $'.
-If the match fails, a null array is returned.
-If the match succeeds, but there were no parentheses, an array value of (1)
-is returned.
-.Sp
-Examples:
-.nf
-
-.ne 4
- open(tty, \'/dev/tty\');
- <tty> \|=~ \|/\|^y\|/i \|&& \|do foo(\|); # do foo if desired
-
- if (/Version: \|*\|([0\-9.]*\|)\|/\|) { $version = $1; }
-
- next if m#^/usr/spool/uucp#;
-
-.ne 5
- # poor man's grep
- $arg = shift;
- while (<>) {
- print if /$arg/o; # compile only once
- }
-
- if (($F1, $F2, $Etc) = ($foo =~ /^(\eS+)\es+(\eS+)\es*(.*)/))
-
-.fi
-This last example splits $foo into the first two words and the remainder
-of the line, and assigns those three fields to $F1, $F2 and $Etc.
-The conditional is true if any variables were assigned, i.e. if the pattern
-matched.
-.Sp
-The \*(L"g\*(R" modifier specifies global pattern matching\*(--that is,
-matching as many times as possible within the string. How it behaves
-depends on the context. In an array context, it returns a list of
-all the substrings matched by all the parentheses in the regular expression.
-If there are no parentheses, it returns a list of all the matched strings,
-as if there were parentheses around the whole pattern. In a scalar context,
-it iterates through the string, returning TRUE each time it matches, and
-FALSE when it eventually runs out of matches. (In other words, it remembers
-where it left off last time and restarts the search at that point.) It
-presumes that you have not modified the string since the last match.
-Modifying the string between matches may result in undefined behavior.
-(You can actually get away with in-place modifications via substr()
-that do not change the length of the entire string. In general, however,
-you should be using s///g for such modifications.) Examples:
-.nf
-
- # array context
- ($one,$five,$fifteen) = (\`uptime\` =~ /(\ed+\e.\ed+)/g);
-
- # scalar context
- $/ = ""; $* = 1;
- while ($paragraph = <>) {
- while ($paragraph =~ /[a-z][\'")]*[.!?]+[\'")]*\es/g) {
- $sentences++;
- }
- }
- print "$sentences\en";
-
-.fi
-.Ip "mkdir(FILENAME,MODE)" 8 3
-Creates the directory specified by FILENAME, with permissions specified by
-MODE (as modified by umask).
-If it succeeds it returns 1, otherwise it returns 0 and sets $! (errno).
-.Ip "msgctl(ID,CMD,ARG)" 8 4
-Calls the System V IPC function msgctl. If CMD is &IPC_STAT, then ARG
-must be a variable which will hold the returned msqid_ds structure.
-Returns like ioctl: the undefined value for error, "0 but true" for
-zero, or the actual return value otherwise.
-.Ip "msgget(KEY,FLAGS)" 8 4
-Calls the System V IPC function msgget. Returns the message queue id,
-or the undefined value if there is an error.
-.Ip "msgsnd(ID,MSG,FLAGS)" 8 4
-Calls the System V IPC function msgsnd to send the message MSG to the
-message queue ID. MSG must begin with the long integer message type,
-which may be created with pack("L", $type). Returns true if
-successful, or false if there is an error.
-.Ip "msgrcv(ID,VAR,SIZE,TYPE,FLAGS)" 8 4
-Calls the System V IPC function msgrcv to receive a message from
-message queue ID into variable VAR with a maximum message size of
-SIZE. Note that if a message is received, the message type will be
-the first thing in VAR, and the maximum length of VAR is SIZE plus the
-size of the message type. Returns true if successful, or false if
-there is an error.
-.Ip "next LABEL" 8 8
-.Ip "next" 8
-The
-.I next
-command is like the
-.I continue
-statement in C; it starts the next iteration of the loop:
-.nf
-
-.ne 4
- line: while (<STDIN>) {
- next line if /\|^#/; # discard comments
- .\|.\|.
- }
-
-.fi
-Note that if there were a
-.I continue
-block on the above, it would get executed even on discarded lines.
-If the LABEL is omitted, the command refers to the innermost enclosing loop.
-.Ip "oct(EXPR)" 8 4
-.Ip "oct EXPR" 8
-Returns the decimal value of EXPR interpreted as an octal string.
-(If EXPR happens to start off with 0x, interprets it as a hex string instead.)
-The following will handle decimal, octal and hex in the standard notation:
-.nf
-
- $val = oct($val) if $val =~ /^0/;
-
-.fi
-If EXPR is omitted, uses $_.
-.Ip "open(FILEHANDLE,EXPR)" 8 8
-.Ip "open(FILEHANDLE)" 8
-.Ip "open FILEHANDLE" 8
-Opens the file whose filename is given by EXPR, and associates it with
-FILEHANDLE.
-If FILEHANDLE is an expression, its value is used as the name of the
-real filehandle wanted.
-If EXPR is omitted, the scalar variable of the same name as the FILEHANDLE
-contains the filename.
-If the filename begins with \*(L"<\*(R" or nothing, the file is opened for
-input.
-If the filename begins with \*(L">\*(R", the file is opened for output.
-If the filename begins with \*(L">>\*(R", the file is opened for appending.
-(You can put a \'+\' in front of the \'>\' or \'<\' to indicate that you
-want both read and write access to the file.)
-If the filename begins with \*(L"|\*(R", the filename is interpreted
-as a command to which output is to be piped, and if the filename ends
-with a \*(L"|\*(R", the filename is interpreted as command which pipes
-input to us.
-(You may not have a command that pipes both in and out.)
-Opening \'\-\' opens
-.I STDIN
-and opening \'>\-\' opens
-.IR STDOUT .
-Open returns non-zero upon success, the undefined value otherwise.
-If the open involved a pipe, the return value happens to be the pid
-of the subprocess.
-Examples:
-.nf
-
-.ne 3
- $article = 100;
- open article || die "Can't find article $article: $!\en";
- while (<article>) {\|.\|.\|.
-
-.ie t \{\
- open(LOG, \'>>/usr/spool/news/twitlog\'\|); # (log is reserved)
-'br\}
-.el \{\
- open(LOG, \'>>/usr/spool/news/twitlog\'\|);
- # (log is reserved)
-'br\}
-
-.ie t \{\
- open(article, "caesar <$article |"\|); # decrypt article
-'br\}
-.el \{\
- open(article, "caesar <$article |"\|);
- # decrypt article
-'br\}
-
-.ie t \{\
- open(extract, "|sort >/tmp/Tmp$$"\|); # $$ is our process#
-'br\}
-.el \{\
- open(extract, "|sort >/tmp/Tmp$$"\|);
- # $$ is our process#
-'br\}
-
-.ne 7
- # process argument list of files along with any includes
-
- foreach $file (@ARGV) {
- do process($file, \'fh00\'); # no pun intended
- }
-
- sub process {
- local($filename, $input) = @_;
- $input++; # this is a string increment
- unless (open($input, $filename)) {
- print STDERR "Can't open $filename: $!\en";
- return;
- }
-.ie t \{\
- while (<$input>) { # note the use of indirection
-'br\}
-.el \{\
- while (<$input>) { # note use of indirection
-'br\}
- if (/^#include "(.*)"/) {
- do process($1, $input);
- next;
- }
- .\|.\|. # whatever
- }
- }
-
-.fi
-You may also, in the Bourne shell tradition, specify an EXPR beginning
-with \*(L">&\*(R", in which case the rest of the string
-is interpreted as the name of a filehandle
-(or file descriptor, if numeric) which is to be duped and opened.
-You may use & after >, >>, <, +>, +>> and +<.
-The mode you specify should match the mode of the original filehandle.
-Here is a script that saves, redirects, and restores
-.I STDOUT
-and
-.IR STDERR :
-.nf
-
-.ne 21
- #!/usr/bin/perl
- open(SAVEOUT, ">&STDOUT");
- open(SAVEERR, ">&STDERR");
-
- open(STDOUT, ">foo.out") || die "Can't redirect stdout";
- open(STDERR, ">&STDOUT") || die "Can't dup stdout";
-
- select(STDERR); $| = 1; # make unbuffered
- select(STDOUT); $| = 1; # make unbuffered
-
- print STDOUT "stdout 1\en"; # this works for
- print STDERR "stderr 1\en"; # subprocesses too
-
- close(STDOUT);
- close(STDERR);
-
- open(STDOUT, ">&SAVEOUT");
- open(STDERR, ">&SAVEERR");
-
- print STDOUT "stdout 2\en";
- print STDERR "stderr 2\en";
-
-.fi
-If you open a pipe on the command \*(L"\-\*(R", i.e. either \*(L"|\-\*(R" or \*(L"\-|\*(R",
-then there is an implicit fork done, and the return value of open
-is the pid of the child within the parent process, and 0 within the child
-process.
-(Use defined($pid) to determine if the open was successful.)
-The filehandle behaves normally for the parent, but i/o to that
-filehandle is piped from/to the
-.IR STDOUT / STDIN
-of the child process.
-In the child process the filehandle isn't opened\*(--i/o happens from/to
-the new
-.I STDOUT
-or
-.IR STDIN .
-Typically this is used like the normal piped open when you want to exercise
-more control over just how the pipe command gets executed, such as when
-you are running setuid, and don't want to have to scan shell commands
-for metacharacters.
-The following pairs are more or less equivalent:
-.nf
-
-.ne 5
- open(FOO, "|tr \'[a\-z]\' \'[A\-Z]\'");
- open(FOO, "|\-") || exec \'tr\', \'[a\-z]\', \'[A\-Z]\';
-
- open(FOO, "cat \-n '$file'|");
- open(FOO, "\-|") || exec \'cat\', \'\-n\', $file;
-
-.fi
-Explicitly closing any piped filehandle causes the parent process to wait for the
-child to finish, and returns the status value in $?.
-Note: on any operation which may do a fork,
-unflushed buffers remain unflushed in both
-processes, which means you may need to set $| to
-avoid duplicate output.
-.Sp
-The filename that is passed to open will have leading and trailing
-whitespace deleted.
-In order to open a file with arbitrary weird characters in it, it's necessary
-to protect any leading and trailing whitespace thusly:
-.nf
-
-.ne 2
- $file =~ s#^(\es)#./$1#;
- open(FOO, "< $file\e0");
-
-.fi
-.Ip "opendir(DIRHANDLE,EXPR)" 8 3
-Opens a directory named EXPR for processing by readdir(), telldir(), seekdir(),
-rewinddir() and closedir().
-Returns true if successful.
-DIRHANDLEs have their own namespace separate from FILEHANDLEs.
-.Ip "ord(EXPR)" 8 4
-.Ip "ord EXPR" 8
-Returns the numeric ascii value of the first character of EXPR.
-If EXPR is omitted, uses $_.
-''' Comments on f & d by gnb@melba.bby.oz.au 22/11/89
-.Ip "pack(TEMPLATE,LIST)" 8 4
-Takes an array or list of values and packs it into a binary structure,
-returning the string containing the structure.
-The TEMPLATE is a sequence of characters that give the order and type
-of values, as follows:
-.nf
-
- A An ascii string, will be space padded.
- a An ascii string, will be null padded.
- c A signed char value.
- C An unsigned char value.
- s A signed short value.
- S An unsigned short value.
- i A signed integer value.
- I An unsigned integer value.
- l A signed long value.
- L An unsigned long value.
- n A short in \*(L"network\*(R" order.
- N A long in \*(L"network\*(R" order.
- f A single-precision float in the native format.
- d A double-precision float in the native format.
- p A pointer to a string.
- v A short in \*(L"VAX\*(R" (little-endian) order.
- V A long in \*(L"VAX\*(R" (little-endian) order.
- x A null byte.
- X Back up a byte.
- @ Null fill to absolute position.
- u A uuencoded string.
- b A bit string (ascending bit order, like vec()).
- B A bit string (descending bit order).
- h A hex string (low nybble first).
- H A hex string (high nybble first).
-
-.fi
-Each letter may optionally be followed by a number which gives a repeat
-count.
-With all types except "a", "A", "b", "B", "h" and "H",
-the pack function will gobble up that many values
-from the LIST.
-A * for the repeat count means to use however many items are left.
-The "a" and "A" types gobble just one value, but pack it as a string of length
-count,
-padding with nulls or spaces as necessary.
-(When unpacking, "A" strips trailing spaces and nulls, but "a" does not.)
-Likewise, the "b" and "B" fields pack a string that many bits long.
-The "h" and "H" fields pack a string that many nybbles long.
-Real numbers (floats and doubles) are in the native machine format
-only; due to the multiplicity of floating formats around, and the lack
-of a standard \*(L"network\*(R" representation, no facility for
-interchange has been made.
-This means that packed floating point data
-written on one machine may not be readable on another - even if both
-use IEEE floating point arithmetic (as the endian-ness of the memory
-representation is not part of the IEEE spec).
-Note that perl uses
-doubles internally for all numeric calculation, and converting from
-double -> float -> double will lose precision (i.e. unpack("f",
-pack("f", $foo)) will not in general equal $foo).
-.br
-Examples:
-.nf
-
- $foo = pack("cccc",65,66,67,68);
- # foo eq "ABCD"
- $foo = pack("c4",65,66,67,68);
- # same thing
-
- $foo = pack("ccxxcc",65,66,67,68);
- # foo eq "AB\e0\e0CD"
-
- $foo = pack("s2",1,2);
- # "\e1\e0\e2\e0" on little-endian
- # "\e0\e1\e0\e2" on big-endian
-
- $foo = pack("a4","abcd","x","y","z");
- # "abcd"
-
- $foo = pack("aaaa","abcd","x","y","z");
- # "axyz"
-
- $foo = pack("a14","abcdefg");
- # "abcdefg\e0\e0\e0\e0\e0\e0\e0"
-
- $foo = pack("i9pl", gmtime);
- # a real struct tm (on my system anyway)
-
- sub bintodec {
- unpack("N", pack("B32", substr("0" x 32 . shift, -32)));
- }
-.fi
-The same template may generally also be used in the unpack function.
-.Ip "pipe(READHANDLE,WRITEHANDLE)" 8 3
-Opens a pair of connected pipes like the corresponding system call.
-Note that if you set up a loop of piped processes, deadlock can occur
-unless you are very careful.
-In addition, note that perl's pipes use stdio buffering, so you may need
-to set $| to flush your WRITEHANDLE after each command, depending on
-the application.
-[Requires version 3.0 patchlevel 9.]
-.Ip "pop(ARRAY)" 8
-.Ip "pop ARRAY" 8 6
-Pops and returns the last value of the array, shortening the array by 1.
-Has the same effect as
-.nf
-
- $tmp = $ARRAY[$#ARRAY\-\|\-];
-
-.fi
-If there are no elements in the array, returns the undefined value.
-.Ip "print(FILEHANDLE LIST)" 8 10
-.Ip "print(LIST)" 8
-.Ip "print FILEHANDLE LIST" 8
-.Ip "print LIST" 8
-.Ip "print" 8
-Prints a string or a comma-separated list of strings.
-Returns non-zero if successful.
-FILEHANDLE may be a scalar variable name, in which case the variable contains
-the name of the filehandle, thus introducing one level of indirection.
-(NOTE: If FILEHANDLE is a variable and the next token is a term, it may be
-misinterpreted as an operator unless you interpose a + or put parens around
-the arguments.)
-If FILEHANDLE is omitted, prints by default to standard output (or to the
-last selected output channel\*(--see select()).
-If LIST is also omitted, prints $_ to
-.IR STDOUT .
-To set the default output channel to something other than
-.I STDOUT
-use the select operation.
-Note that, because print takes a LIST, anything in the LIST is evaluated
-in an array context, and any subroutine that you call will have one or more
-of its expressions evaluated in an array context.
-Also be careful not to follow the print keyword with a left parenthesis
-unless you want the corresponding right parenthesis to terminate the
-arguments to the print\*(--interpose a + or put parens around all the arguments.
-.Ip "printf(FILEHANDLE LIST)" 8 10
-.Ip "printf(LIST)" 8
-.Ip "printf FILEHANDLE LIST" 8
-.Ip "printf LIST" 8
-Equivalent to a \*(L"print FILEHANDLE sprintf(LIST)\*(R".
-.Ip "push(ARRAY,LIST)" 8 7
-Treats ARRAY (@ is optional) as a stack, and pushes the values of LIST
-onto the end of ARRAY.
-The length of ARRAY increases by the length of LIST.
-Has the same effect as
-.nf
-
- for $value (LIST) {
- $ARRAY[++$#ARRAY] = $value;
- }
-
-.fi
-but is more efficient.
-.Ip "q/STRING/" 8 5
-.Ip "qq/STRING/" 8
-.Ip "qx/STRING/" 8
-These are not really functions, but simply syntactic sugar to let you
-avoid putting too many backslashes into quoted strings.
-The q operator is a generalized single quote, and the qq operator a
-generalized double quote.
-The qx operator is a generalized backquote.
-Any non-alphanumeric delimiter can be used in place of /, including newline.
-If the delimiter is an opening bracket or parenthesis, the final delimiter
-will be the corresponding closing bracket or parenthesis.
-(Embedded occurrences of the closing bracket need to be backslashed as usual.)
-Examples:
-.nf
-
-.ne 5
- $foo = q!I said, "You said, \'She said it.\'"!;
- $bar = q(\'This is it.\');
- $today = qx{ date };
- $_ .= qq
-*** The previous line contains the naughty word "$&".\en
- if /(ibm|apple|awk)/; # :-)
-
-.fi
-.Ip "rand(EXPR)" 8 8
-.Ip "rand EXPR" 8
-.Ip "rand" 8
-Returns a random fractional number between 0 and the value of EXPR.
-(EXPR should be positive.)
-If EXPR is omitted, returns a value between 0 and 1.
-See also srand().
-.Ip "read(FILEHANDLE,SCALAR,LENGTH,OFFSET)" 8 5
-.Ip "read(FILEHANDLE,SCALAR,LENGTH)" 8 5
-Attempts to read LENGTH bytes of data into variable SCALAR from the specified
-FILEHANDLE.
-Returns the number of bytes actually read, or undef if there was an error.
-SCALAR will be grown or shrunk to the length actually read.
-An OFFSET may be specified to place the read data at some other place
-than the beginning of the string.
-This call is actually implemented in terms of stdio's fread call. To get
-a true read system call, see sysread.
-.Ip "readdir(DIRHANDLE)" 8 3
-.Ip "readdir DIRHANDLE" 8
-Returns the next directory entry for a directory opened by opendir().
-If used in an array context, returns all the rest of the entries in the
-directory.
-If there are no more entries, returns an undefined value in a scalar context
-or a null list in an array context.
-.Ip "readlink(EXPR)" 8 6
-.Ip "readlink EXPR" 8
-Returns the value of a symbolic link, if symbolic links are implemented.
-If not, gives a fatal error.
-If there is some system error, returns the undefined value and sets $! (errno).
-If EXPR is omitted, uses $_.
-.Ip "recv(SOCKET,SCALAR,LEN,FLAGS)" 8 4
-Receives a message on a socket.
-Attempts to receive LENGTH bytes of data into variable SCALAR from the specified
-SOCKET filehandle.
-Returns the address of the sender, or the undefined value if there's an error.
-SCALAR will be grown or shrunk to the length actually read.
-Takes the same flags as the system call of the same name.
-.Ip "redo LABEL" 8 8
-.Ip "redo" 8
-The
-.I redo
-command restarts the loop block without evaluating the conditional again.
-The
-.I continue
-block, if any, is not executed.
-If the LABEL is omitted, the command refers to the innermost enclosing loop.
-This command is normally used by programs that want to lie to themselves
-about what was just input:
-.nf
-
-.ne 16
- # a simpleminded Pascal comment stripper
- # (warning: assumes no { or } in strings)
- line: while (<STDIN>) {
- while (s|\|({.*}.*\|){.*}|$1 \||) {}
- s|{.*}| \||;
- if (s|{.*| \||) {
- $front = $_;
- while (<STDIN>) {
- if (\|/\|}/\|) { # end of comment?
- s|^|$front{|;
- redo line;
- }
- }
- }
- print;
- }
-
-.fi
-.Ip "rename(OLDNAME,NEWNAME)" 8 2
-Changes the name of a file.
-Returns 1 for success, 0 otherwise.
-Will not work across filesystem boundaries.
-.Ip "require(EXPR)" 8 6
-.Ip "require EXPR" 8
-.Ip "require" 8
-Includes the library file specified by EXPR, or by $_ if EXPR is not supplied.
-Has semantics similar to the following subroutine:
-.nf
-
- sub require {
- local($filename) = @_;
- return 1 if $INC{$filename};
- local($realfilename,$result);
- ITER: {
- foreach $prefix (@INC) {
- $realfilename = "$prefix/$filename";
- if (-f $realfilename) {
- $result = do $realfilename;
- last ITER;
- }
- }
- die "Can't find $filename in \e@INC";
- }
- die $@ if $@;
- die "$filename did not return true value" unless $result;
- $INC{$filename} = $realfilename;
- $result;
- }
-
-.fi
-Note that the file will not be included twice under the same specified name.
-The file must return true as the last statement to indicate successful
-execution of any initialization code, so it's customary to end
-such a file with \*(L"1;\*(R" unless you're sure it'll return true otherwise.
-.Ip "reset(EXPR)" 8 6
-.Ip "reset EXPR" 8
-.Ip "reset" 8
-Generally used in a
-.I continue
-block at the end of a loop to clear variables and reset ?? searches
-so that they work again.
-The expression is interpreted as a list of single characters (hyphens allowed
-for ranges).
-All variables and arrays beginning with one of those letters are reset to
-their pristine state.
-If the expression is omitted, one-match searches (?pattern?) are reset to
-match again.
-Only resets variables or searches in the current package.
-Always returns 1.
-Examples:
-.nf
-
-.ne 3
- reset \'X\'; \h'|2i'# reset all X variables
- reset \'a\-z\';\h'|2i'# reset lower case variables
- reset; \h'|2i'# just reset ?? searches
-
-.fi
-Note: resetting \*(L"A\-Z\*(R" is not recommended since you'll wipe out your ARGV and ENV
-arrays.
-.Sp
-The use of reset on dbm associative arrays does not change the dbm file.
-(It does, however, flush any entries cached by perl, which may be useful if
-you are sharing the dbm file.
-Then again, maybe not.)
-.Ip "return LIST" 8 3
-Returns from a subroutine with the value specified.
-(Note that a subroutine can automatically return
-the value of the last expression evaluated.
-That's the preferred method\*(--use of an explicit
-.I return
-is a bit slower.)
-.Ip "reverse(LIST)" 8 4
-.Ip "reverse LIST" 8
-In an array context, returns an array value consisting of the elements
-of LIST in the opposite order.
-In a scalar context, returns a string value consisting of the bytes of
-the first element of LIST in the opposite order.
-.Ip "rewinddir(DIRHANDLE)" 8 5
-.Ip "rewinddir DIRHANDLE" 8
-Sets the current position to the beginning of the directory for the readdir() routine on DIRHANDLE.
-.Ip "rindex(STR,SUBSTR,POSITION)" 8 6
-.Ip "rindex(STR,SUBSTR)" 8 4
-Works just like index except that it
-returns the position of the LAST occurrence of SUBSTR in STR.
-If POSITION is specified, returns the last occurrence at or before that
-position.
-.Ip "rmdir(FILENAME)" 8 4
-.Ip "rmdir FILENAME" 8
-Deletes the directory specified by FILENAME if it is empty.
-If it succeeds it returns 1, otherwise it returns 0 and sets $! (errno).
-If FILENAME is omitted, uses $_.
-.Ip "s/PATTERN/REPLACEMENT/gieo" 8 3
-Searches a string for a pattern, and if found, replaces that pattern with the
-replacement text and returns the number of substitutions made.
-Otherwise it returns false (0).
-The \*(L"g\*(R" is optional, and if present, indicates that all occurrences
-of the pattern are to be replaced.
-The \*(L"i\*(R" is also optional, and if present, indicates that matching
-is to be done in a case-insensitive manner.
-The \*(L"e\*(R" is likewise optional, and if present, indicates that
-the replacement string is to be evaluated as an expression rather than just
-as a double-quoted string.
-Any non-alphanumeric delimiter may replace the slashes;
-if single quotes are used, no
-interpretation is done on the replacement string (the e modifier overrides
-this, however); if backquotes are used, the replacement string is a command
-to execute whose output will be used as the actual replacement text.
-If the PATTERN is delimited by bracketing quotes, the REPLACEMENT
-has its own pair of quotes, which may or may not be bracketing quotes, e.g.
-s(foo)(bar) or s<foo>/bar/.
-If no string is specified via the =~ or !~ operator,
-the $_ string is searched and modified.
-(The string specified with =~ must be a scalar variable, an array element,
-or an assignment to one of those, i.e. an lvalue.)
-If the pattern contains a $ that looks like a variable rather than an
-end-of-string test, the variable will be interpolated into the pattern at
-run-time.
-If you only want the pattern compiled once the first time the variable is
-interpolated, add an \*(L"o\*(R" at the end.
-If the PATTERN evaluates to a null string, the most recent successful
-regular expression is used instead.
-See also the section on regular expressions.
-Examples:
-.nf
-
- s/\|\e\|bgreen\e\|b/mauve/g; # don't change wintergreen
-
- $path \|=~ \|s|\|/usr/bin|\|/usr/local/bin|;
-
- s/Login: $foo/Login: $bar/; # run-time pattern
-
- ($foo = $bar) =~ s/bar/foo/;
-
- $_ = \'abc123xyz\';
- s/\ed+/$&*2/e; # yields \*(L'abc246xyz\*(R'
- s/\ed+/sprintf("%5d",$&)/e; # yields \*(L'abc 246xyz\*(R'
- s/\ew/$& x 2/eg; # yields \*(L'aabbcc 224466xxyyzz\*(R'
-
- s/\|([^ \|]*\|) *\|([^ \|]*\|)\|/\|$2 $1/; # reverse 1st two fields
-
-.fi
-(Note the use of $ instead of \|\e\| in the last example. See section
-on regular expressions.)
-.Ip "scalar(EXPR)" 8 3
-Forces EXPR to be interpreted in a scalar context and returns the value
-of EXPR.
-.Ip "seek(FILEHANDLE,POSITION,WHENCE)" 8 3
-Randomly positions the file pointer for FILEHANDLE, just like the fseek()
-call of stdio.
-FILEHANDLE may be an expression whose value gives the name of the filehandle.
-Returns 1 upon success, 0 otherwise.
-.Ip "seekdir(DIRHANDLE,POS)" 8 3
-Sets the current position for the readdir() routine on DIRHANDLE.
-POS must be a value returned by telldir().
-Has the same caveats about possible directory compaction as the corresponding
-system library routine.
-.Ip "select(FILEHANDLE)" 8 3
-.Ip "select" 8 3
-Returns the currently selected filehandle.
-Sets the current default filehandle for output, if FILEHANDLE is supplied.
-This has two effects: first, a
-.I write
-or a
-.I print
-without a filehandle will default to this FILEHANDLE.
-Second, references to variables related to output will refer to this output
-channel.
-For example, if you have to set the top of form format for more than
-one output channel, you might do the following:
-.nf
-
-.ne 4
- select(REPORT1);
- $^ = \'report1_top\';
- select(REPORT2);
- $^ = \'report2_top\';
-
-.fi
-FILEHANDLE may be an expression whose value gives the name of the actual filehandle.
-Thus:
-.nf
-
- $oldfh = select(STDERR); $| = 1; select($oldfh);
-
-.fi
-.Ip "select(RBITS,WBITS,EBITS,TIMEOUT)" 8 3
-This calls the select system call with the bitmasks specified, which can
-be constructed using fileno() and vec(), along these lines:
-.nf
-
- $rin = $win = $ein = '';
- vec($rin,fileno(STDIN),1) = 1;
- vec($win,fileno(STDOUT),1) = 1;
- $ein = $rin | $win;
-
-.fi
-If you want to select on many filehandles you might wish to write a subroutine:
-.nf
-
- sub fhbits {
- local(@fhlist) = split(' ',$_[0]);
- local($bits);
- for (@fhlist) {
- vec($bits,fileno($_),1) = 1;
- }
- $bits;
- }
- $rin = &fhbits('STDIN TTY SOCK');
-
-.fi
-The usual idiom is:
-.nf
-
- ($nfound,$timeleft) =
- select($rout=$rin, $wout=$win, $eout=$ein, $timeout);
-
-or to block until something becomes ready:
-
-.ie t \{\
- $nfound = select($rout=$rin, $wout=$win, $eout=$ein, undef);
-'br\}
-.el \{\
- $nfound = select($rout=$rin, $wout=$win,
- $eout=$ein, undef);
-'br\}
-
-.fi
-Any of the bitmasks can also be undef.
-The timeout, if specified, is in seconds, which may be fractional.
-NOTE: not all implementations are capable of returning the $timeleft.
-If not, they always return $timeleft equal to the supplied $timeout.
-.Ip "semctl(ID,SEMNUM,CMD,ARG)" 8 4
-Calls the System V IPC function semctl. If CMD is &IPC_STAT or
-&GETALL, then ARG must be a variable which will hold the returned
-semid_ds structure or semaphore value array. Returns like ioctl: the
-undefined value for error, "0 but true" for zero, or the actual return
-value otherwise.
-.Ip "semget(KEY,NSEMS,SIZE,FLAGS)" 8 4
-Calls the System V IPC function semget. Returns the semaphore id, or
-the undefined value if there is an error.
-.Ip "semop(KEY,OPSTRING)" 8 4
-Calls the System V IPC function semop to perform semaphore operations
-such as signaling and waiting. OPSTRING must be a packed array of
-semop structures. Each semop structure can be generated with
-\&'pack("sss", $semnum, $semop, $semflag)'. The number of semaphore
-operations is implied by the length of OPSTRING. Returns true if
-successful, or false if there is an error. As an example, the
-following code waits on semaphore $semnum of semaphore id $semid:
-.nf
-
- $semop = pack("sss", $semnum, -1, 0);
- die "Semaphore trouble: $!\en" unless semop($semid, $semop);
-
-.fi
-To signal the semaphore, replace "-1" with "1".
-.Ip "send(SOCKET,MSG,FLAGS,TO)" 8 4
-.Ip "send(SOCKET,MSG,FLAGS)" 8
-Sends a message on a socket.
-Takes the same flags as the system call of the same name.
-On unconnected sockets you must specify a destination to send TO.
-Returns the number of characters sent, or the undefined value if
-there is an error.
-.Ip "setpgrp(PID,PGRP)" 8 4
-Sets the current process group for the specified PID, 0 for the current
-process.
-Will produce a fatal error if used on a machine that doesn't implement
-setpgrp(2).
-.Ip "setpriority(WHICH,WHO,PRIORITY)" 8 4
-Sets the current priority for a process, a process group, or a user.
-(See setpriority(2).)
-Will produce a fatal error if used on a machine that doesn't implement
-setpriority(2).
-.Ip "setsockopt(SOCKET,LEVEL,OPTNAME,OPTVAL)" 8 3
-Sets the socket option requested.
-Returns undefined if there is an error.
-OPTVAL may be specified as undef if you don't want to pass an argument.
-.Ip "shift(ARRAY)" 8 6
-.Ip "shift ARRAY" 8
-.Ip "shift" 8
-Shifts the first value of the array off and returns it,
-shortening the array by 1 and moving everything down.
-If there are no elements in the array, returns the undefined value.
-If ARRAY is omitted, shifts the @ARGV array in the main program, and the @_
-array in subroutines.
-(This is determined lexically.)
-See also unshift(), push() and pop().
-Shift() and unshift() do the same thing to the left end of an array that push()
-and pop() do to the right end.
-.Ip "shmctl(ID,CMD,ARG)" 8 4
-Calls the System V IPC function shmctl. If CMD is &IPC_STAT, then ARG
-must be a variable which will hold the returned shmid_ds structure.
-Returns like ioctl: the undefined value for error, "0 but true" for
-zero, or the actual return value otherwise.
-.Ip "shmget(KEY,SIZE,FLAGS)" 8 4
-Calls the System V IPC function shmget. Returns the shared memory
-segment id, or the undefined value if there is an error.
-.Ip "shmread(ID,VAR,POS,SIZE)" 8 4
-.Ip "shmwrite(ID,STRING,POS,SIZE)" 8
-Reads or writes the System V shared memory segment ID starting at
-position POS for size SIZE by attaching to it, copying in/out, and
-detaching from it. When reading, VAR must be a variable which
-will hold the data read. When writing, if STRING is too long,
-only SIZE bytes are used; if STRING is too short, nulls are
-written to fill out SIZE bytes. Return true if successful, or
-false if there is an error.
-.Ip "shutdown(SOCKET,HOW)" 8 3
-Shuts down a socket connection in the manner indicated by HOW, which has
-the same interpretation as in the system call of the same name.
-.Ip "sin(EXPR)" 8 4
-.Ip "sin EXPR" 8
-Returns the sine of EXPR (expressed in radians).
-If EXPR is omitted, returns sine of $_.
-.Ip "sleep(EXPR)" 8 6
-.Ip "sleep EXPR" 8
-.Ip "sleep" 8
-Causes the script to sleep for EXPR seconds, or forever if no EXPR.
-May be interrupted by sending the process a SIGALRM.
-Returns the number of seconds actually slept.
-You probably cannot mix alarm() and sleep() calls, since sleep() is
-often implemented using alarm().
-.Ip "socket(SOCKET,DOMAIN,TYPE,PROTOCOL)" 8 3
-Opens a socket of the specified kind and attaches it to filehandle SOCKET.
-DOMAIN, TYPE and PROTOCOL are specified the same as for the system call
-of the same name.
-You may need to run h2ph on sys/socket.h to get the proper values handy
-in a perl library file.
-Return true if successful.
-See the example in the section on Interprocess Communication.
-.Ip "socketpair(SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL)" 8 3
-Creates an unnamed pair of sockets in the specified domain, of the specified
-type.
-DOMAIN, TYPE and PROTOCOL are specified the same as for the system call
-of the same name.
-If unimplemented, yields a fatal error.
-Return true if successful.
-.Ip "sort(SUBROUTINE LIST)" 8 9
-.Ip "sort(LIST)" 8
-.Ip "sort SUBROUTINE LIST" 8
-.Ip "sort BLOCK LIST" 8
-.Ip "sort LIST" 8
-Sorts the LIST and returns the sorted array value.
-Nonexistent values of arrays are stripped out.
-If SUBROUTINE or BLOCK is omitted, sorts in standard string comparison order.
-If SUBROUTINE is specified, gives the name of a subroutine that returns
-an integer less than, equal to, or greater than 0,
-depending on how the elements of the array are to be ordered.
-(The <=> and cmp operators are extremely useful in such routines.)
-SUBROUTINE may be a scalar variable name, in which case the value provides
-the name of the subroutine to use.
-In place of a SUBROUTINE name, you can provide a BLOCK as an anonymous,
-in-line sort subroutine.
-.Sp
-In the interests of efficiency the normal calling code for subroutines
-is bypassed, with the following effects: the subroutine may not be a recursive
-subroutine, and the two elements to be compared are passed into the subroutine
-not via @_ but as $a and $b (see example below).
-They are passed by reference so don't modify $a and $b.
-.Sp
-Examples:
-.nf
-
-.ne 2
- # sort lexically
- @articles = sort @files;
-
-.ne 2
- # same thing, but with explicit sort routine
- @articles = sort {$a cmp $b} @files;
-
-.ne 2
- # same thing in reversed order
- @articles = sort {$b cmp $a} @files;
-
-.ne 2
- # sort numerically ascending
- @articles = sort {$a <=> $b} @files;
-
-.ne 2
- # sort numerically descending
- @articles = sort {$b <=> $a} @files;
-
-.ne 5
- # sort using explicit subroutine name
- sub byage {
- $age{$a} <=> $age{$b}; # presuming integers
- }
- @sortedclass = sort byage @class;
-
-.ne 9
- sub reverse { $b cmp $a; }
- @harry = (\'dog\',\'cat\',\'x\',\'Cain\',\'Abel\');
- @george = (\'gone\',\'chased\',\'yz\',\'Punished\',\'Axed\');
- print sort @harry;
- # prints AbelCaincatdogx
- print sort reverse @harry;
- # prints xdogcatCainAbel
- print sort @george, \'to\', @harry;
- # prints AbelAxedCainPunishedcatchaseddoggonetoxyz
-
-.fi
-.Ip "splice(ARRAY,OFFSET,LENGTH,LIST)" 8 8
-.Ip "splice(ARRAY,OFFSET,LENGTH)" 8
-.Ip "splice(ARRAY,OFFSET)" 8
-Removes the elements designated by OFFSET and LENGTH from an array, and
-replaces them with the elements of LIST, if any.
-Returns the elements removed from the array.
-The array grows or shrinks as necessary.
-If LENGTH is omitted, removes everything from OFFSET onward.
-The following equivalencies hold (assuming $[ == 0):
-.nf
-
- push(@a,$x,$y)\h'|3.5i'splice(@a,$#a+1,0,$x,$y)
- pop(@a)\h'|3.5i'splice(@a,-1)
- shift(@a)\h'|3.5i'splice(@a,0,1)
- unshift(@a,$x,$y)\h'|3.5i'splice(@a,0,0,$x,$y)
- $a[$x] = $y\h'|3.5i'splice(@a,$x,1,$y);
-
-Example, assuming array lengths are passed before arrays:
-
- sub aeq { # compare two array values
- local(@a) = splice(@_,0,shift);
- local(@b) = splice(@_,0,shift);
- return 0 unless @a == @b; # same len?
- while (@a) {
- return 0 if pop(@a) ne pop(@b);
- }
- return 1;
- }
- if (&aeq($len,@foo[1..$len],0+@bar,@bar)) { ... }
-
-.fi
-.Ip "split(/PATTERN/,EXPR,LIMIT)" 8 8
-.Ip "split(/PATTERN/,EXPR)" 8 8
-.Ip "split(/PATTERN/)" 8
-.Ip "split" 8
-Splits a string into an array of strings, and returns it.
-(If not in an array context, returns the number of fields found and splits
-into the @_ array.
-(In an array context, you can force the split into @_
-by using ?? as the pattern delimiters, but it still returns the array value.))
-If EXPR is omitted, splits the $_ string.
-If PATTERN is also omitted, splits on whitespace (/[\ \et\en]+/).
-Anything matching PATTERN is taken to be a delimiter separating the fields.
-(Note that the delimiter may be longer than one character.)
-If LIMIT is specified, splits into no more than that many fields (though it
-may split into fewer).
-If LIMIT is unspecified, trailing null fields are stripped (which
-potential users of pop() would do well to remember).
-A pattern matching the null string (not to be confused with a null pattern //,
-which is just one member of the set of patterns matching a null string)
-will split the value of EXPR into separate characters at each point it
-matches that way.
-For example:
-.nf
-
- print join(\':\', split(/ */, \'hi there\'));
-
-.fi
-produces the output \*(L'h:i:t:h:e:r:e\*(R'.
-.Sp
-The LIMIT parameter can be used to partially split a line
-.nf
-
- ($login, $passwd, $remainder) = split(\|/\|:\|/\|, $_, 3);
-
-.fi
-(When assigning to a list, if LIMIT is omitted, perl supplies a LIMIT one
-larger than the number of variables in the list, to avoid unnecessary work.
-For the list above LIMIT would have been 4 by default.
-In time critical applications it behooves you not to split into
-more fields than you really need.)
-.Sp
-If the PATTERN contains parentheses, additional array elements are created
-from each matching substring in the delimiter.
-.Sp
- split(/([,-])/,"1-10,20");
-.Sp
-produces the array value
-.Sp
- (1,'-',10,',',20)
-.Sp
-The pattern /PATTERN/ may be replaced with an expression to specify patterns
-that vary at runtime.
-(To do runtime compilation only once, use /$variable/o.)
-As a special case, specifying a space (\'\ \') will split on white space
-just as split with no arguments does, but leading white space does NOT
-produce a null first field.
-Thus, split(\'\ \') can be used to emulate
-.IR awk 's
-default behavior, whereas
-split(/\ /) will give you as many null initial fields as there are
-leading spaces.
-.Sp
-Example:
-.nf
-
-.ne 5
- open(passwd, \'/etc/passwd\');
- while (<passwd>) {
-.ie t \{\
- ($login, $passwd, $uid, $gid, $gcos, $home, $shell) = split(\|/\|:\|/\|);
-'br\}
-.el \{\
- ($login, $passwd, $uid, $gid, $gcos, $home, $shell)
- = split(\|/\|:\|/\|);
-'br\}
- .\|.\|.
- }
-
-.fi
-(Note that $shell above will still have a newline on it. See chop().)
-See also
-.IR join .
-.Ip "sprintf(FORMAT,LIST)" 8 4
-Returns a string formatted by the usual printf conventions.
-The * character is not supported.
-.Ip "sqrt(EXPR)" 8 4
-.Ip "sqrt EXPR" 8
-Return the square root of EXPR.
-If EXPR is omitted, returns square root of $_.
-.Ip "srand(EXPR)" 8 4
-.Ip "srand EXPR" 8
-Sets the random number seed for the
-.I rand
-operator.
-If EXPR is omitted, does srand(time).
-.Ip "stat(FILEHANDLE)" 8 8
-.Ip "stat FILEHANDLE" 8
-.Ip "stat(EXPR)" 8
-.Ip "stat SCALARVARIABLE" 8
-Returns a 13-element array giving the statistics for a file, either the file
-opened via FILEHANDLE, or named by EXPR.
-Returns a null list if the stat fails.
-Typically used as follows:
-.nf
-
-.ne 3
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks)
- = stat($filename);
-
-.fi
-If stat is passed the special filehandle consisting of an underline,
-no stat is done, but the current contents of the stat structure from
-the last stat or filetest are returned.
-Example:
-.nf
-
-.ne 3
- if (-x $file && (($d) = stat(_)) && $d < 0) {
- print "$file is executable NFS file\en";
- }
-
-.fi
-(This only works on machines for which the device number is negative under NFS.)
-.Ip "study(SCALAR)" 8 6
-.Ip "study SCALAR" 8
-.Ip "study"
-Takes extra time to study SCALAR ($_ if unspecified) in anticipation of
-doing many pattern matches on the string before it is next modified.
-This may or may not save time, depending on the nature and number of patterns
-you are searching on, and on the distribution of character frequencies in
-the string to be searched\*(--you probably want to compare runtimes with and
-without it to see which runs faster.
-Those loops which scan for many short constant strings (including the constant
-parts of more complex patterns) will benefit most.
-You may have only one study active at a time\*(--if you study a different
-scalar the first is \*(L"unstudied\*(R".
-(The way study works is this: a linked list of every character in the string
-to be searched is made, so we know, for example, where all the \*(L'k\*(R' characters
-are.
-From each search string, the rarest character is selected, based on some
-static frequency tables constructed from some C programs and English text.
-Only those places that contain this \*(L"rarest\*(R" character are examined.)
-.Sp
-For example, here is a loop which inserts index producing entries before any line
-containing a certain pattern:
-.nf
-
-.ne 8
- while (<>) {
- study;
- print ".IX foo\en" if /\ebfoo\eb/;
- print ".IX bar\en" if /\ebbar\eb/;
- print ".IX blurfl\en" if /\ebblurfl\eb/;
- .\|.\|.
- print;
- }
-
-.fi
-In searching for /\ebfoo\eb/, only those locations in $_ that contain \*(L'f\*(R'
-will be looked at, because \*(L'f\*(R' is rarer than \*(L'o\*(R'.
-In general, this is a big win except in pathological cases.
-The only question is whether it saves you more time than it took to build
-the linked list in the first place.
-.Sp
-Note that if you have to look for strings that you don't know till runtime,
-you can build an entire loop as a string and eval that to avoid recompiling
-all your patterns all the time.
-Together with undefining $/ to input entire files as one record, this can
-be very fast, often faster than specialized programs like fgrep.
-The following scans a list of files (@files)
-for a list of words (@words), and prints out the names of those files that
-contain a match:
-.nf
-
-.ne 12
- $search = \'while (<>) { study;\';
- foreach $word (@words) {
- $search .= "++\e$seen{\e$ARGV} if /\e\eb$word\e\eb/;\en";
- }
- $search .= "}";
- @ARGV = @files;
- undef $/;
- eval $search; # this screams
- $/ = "\en"; # put back to normal input delim
- foreach $file (sort keys(%seen)) {
- print $file, "\en";
- }
-
-.fi
-.Ip "substr(EXPR,OFFSET,LEN)" 8 2
-.Ip "substr(EXPR,OFFSET)" 8 2
-Extracts a substring out of EXPR and returns it.
-First character is at offset 0, or whatever you've set $[ to.
-If OFFSET is negative, starts that far from the end of the string.
-If LEN is omitted, returns everything to the end of the string.
-You can use the substr() function as an lvalue, in which case EXPR must
-be an lvalue.
-If you assign something shorter than LEN, the string will shrink, and
-if you assign something longer than LEN, the string will grow to accommodate it.
-To keep the string the same length you may need to pad or chop your value using
-sprintf().
-.Ip "symlink(OLDFILE,NEWFILE)" 8 2
-Creates a new filename symbolically linked to the old filename.
-Returns 1 for success, 0 otherwise.
-On systems that don't support symbolic links, produces a fatal error at
-run time.
-To check for that, use eval:
-.nf
-
- $symlink_exists = (eval \'symlink("","");\', $@ eq \'\');
-
-.fi
-.Ip "syscall(LIST)" 8 6
-.Ip "syscall LIST" 8
-Calls the system call specified as the first element of the list, passing
-the remaining elements as arguments to the system call.
-If unimplemented, produces a fatal error.
-The arguments are interpreted as follows: if a given argument is numeric,
-the argument is passed as an int.
-If not, the pointer to the string value is passed.
-You are responsible to make sure a string is pre-extended long enough
-to receive any result that might be written into a string.
-If your integer arguments are not literals and have never been interpreted
-in a numeric context, you may need to add 0 to them to force them to look
-like numbers.
-.nf
-
- require 'syscall.ph'; # may need to run h2ph
- syscall(&SYS_write, fileno(STDOUT), "hi there\en", 9);
-
-.fi
-.Ip "sysread(FILEHANDLE,SCALAR,LENGTH,OFFSET)" 8 5
-.Ip "sysread(FILEHANDLE,SCALAR,LENGTH)" 8 5
-Attempts to read LENGTH bytes of data into variable SCALAR from the specified
-FILEHANDLE, using the system call read(2).
-It bypasses stdio, so mixing this with other kinds of reads may cause
-confusion.
-Returns the number of bytes actually read, or undef if there was an error.
-SCALAR will be grown or shrunk to the length actually read.
-An OFFSET may be specified to place the read data at some other place
-than the beginning of the string.
-.Ip "system(LIST)" 8 6
-.Ip "system LIST" 8
-Does exactly the same thing as \*(L"exec LIST\*(R" except that a fork
-is done first, and the parent process waits for the child process to complete.
-Note that argument processing varies depending on the number of arguments.
-The return value is the exit status of the program as returned by the wait()
-call.
-To get the actual exit value divide by 256.
-See also
-.IR exec .
-.Ip "syswrite(FILEHANDLE,SCALAR,LENGTH,OFFSET)" 8 5
-.Ip "syswrite(FILEHANDLE,SCALAR,LENGTH)" 8 5
-Attempts to write LENGTH bytes of data from variable SCALAR to the specified
-FILEHANDLE, using the system call write(2).
-It bypasses stdio, so mixing this with prints may cause
-confusion.
-Returns the number of bytes actually written, or undef if there was an error.
-An OFFSET may be specified to place the read data at some other place
-than the beginning of the string.
-.Ip "tell(FILEHANDLE)" 8 6
-.Ip "tell FILEHANDLE" 8 6
-.Ip "tell" 8
-Returns the current file position for FILEHANDLE.
-FILEHANDLE may be an expression whose value gives the name of the actual
-filehandle.
-If FILEHANDLE is omitted, assumes the file last read.
-.Ip "telldir(DIRHANDLE)" 8 5
-.Ip "telldir DIRHANDLE" 8
-Returns the current position of the readdir() routines on DIRHANDLE.
-Value may be given to seekdir() to access a particular location in
-a directory.
-Has the same caveats about possible directory compaction as the corresponding
-system library routine.
-.Ip "time" 8 4
-Returns the number of non-leap seconds since 00:00:00 UTC, January 1, 1970.
-Suitable for feeding to gmtime() and localtime().
-.Ip "times" 8 4
-Returns a four-element array giving the user and system times, in seconds, for this
-process and the children of this process.
-.Sp
- ($user,$system,$cuser,$csystem) = times;
-.Sp
-.Ip "tr/SEARCHLIST/REPLACEMENTLIST/cds" 8 5
-.Ip "y/SEARCHLIST/REPLACEMENTLIST/cds" 8
-Translates all occurrences of the characters found in the search list with
-the corresponding character in the replacement list.
-It returns the number of characters replaced or deleted.
-If no string is specified via the =~ or !~ operator,
-the $_ string is translated.
-(The string specified with =~ must be a scalar variable, an array element,
-or an assignment to one of those, i.e. an lvalue.)
-For
-.I sed
-devotees,
-.I y
-is provided as a synonym for
-.IR tr .
-If the SEARCHLIST is delimited by bracketing quotes, the REPLACEMENTLIST
-has its own pair of quotes, which may or may not be bracketing quotes, e.g.
-tr[A-Z][a-z] or tr(+-*/)/ABCD/.
-.Sp
-If the c modifier is specified, the SEARCHLIST character set is complemented.
-If the d modifier is specified, any characters specified by SEARCHLIST that
-are not found in REPLACEMENTLIST are deleted.
-(Note that this is slightly more flexible than the behavior of some
-.I tr
-programs, which delete anything they find in the SEARCHLIST, period.)
-If the s modifier is specified, sequences of characters that were translated
-to the same character are squashed down to 1 instance of the character.
-.Sp
-If the d modifier was used, the REPLACEMENTLIST is always interpreted exactly
-as specified.
-Otherwise, if the REPLACEMENTLIST is shorter than the SEARCHLIST,
-the final character is replicated till it is long enough.
-If the REPLACEMENTLIST is null, the SEARCHLIST is replicated.
-This latter is useful for counting characters in a class, or for squashing
-character sequences in a class.
-.Sp
-Examples:
-.nf
-
- $ARGV[1] \|=~ \|y/A\-Z/a\-z/; \h'|3i'# canonicalize to lower case
-
- $cnt = tr/*/*/; \h'|3i'# count the stars in $_
-
- $cnt = tr/0\-9//; \h'|3i'# count the digits in $_
-
- tr/a\-zA\-Z//s; \h'|3i'# bookkeeper \-> bokeper
-
- ($HOST = $host) =~ tr/a\-z/A\-Z/;
-
- y/a\-zA\-Z/ /cs; \h'|3i'# change non-alphas to single space
-
- tr/\e200\-\e377/\e0\-\e177/;\h'|3i'# delete 8th bit
-
-.fi
-.Ip "truncate(FILEHANDLE,LENGTH)" 8 4
-.Ip "truncate(EXPR,LENGTH)" 8
-Truncates the file opened on FILEHANDLE, or named by EXPR, to the specified
-length.
-Produces a fatal error if truncate isn't implemented on your system.
-.Ip "umask(EXPR)" 8 4
-.Ip "umask EXPR" 8
-.Ip "umask" 8
-Sets the umask for the process and returns the old one.
-If EXPR is omitted, merely returns current umask.
-.Ip "undef(EXPR)" 8 6
-.Ip "undef EXPR" 8
-.Ip "undef" 8
-Undefines the value of EXPR, which must be an lvalue.
-Use only on a scalar value, an entire array, or a subroutine name (using &).
-(Undef will probably not do what you expect on most predefined variables or
-dbm array values.)
-Always returns the undefined value.
-You can omit the EXPR, in which case nothing is undefined, but you still
-get an undefined value that you could, for instance, return from a subroutine.
-Examples:
-.nf
-
-.ne 6
- undef $foo;
- undef $bar{'blurfl'};
- undef @ary;
- undef %assoc;
- undef &mysub;
- return (wantarray ? () : undef) if $they_blew_it;
-
-.fi
-.Ip "unlink(LIST)" 8 4
-.Ip "unlink LIST" 8
-Deletes a list of files.
-Returns the number of files successfully deleted.
-.nf
-
-.ne 2
- $cnt = unlink \'a\', \'b\', \'c\';
- unlink @goners;
- unlink <*.bak>;
-
-.fi
-Note: unlink will not delete directories unless you are superuser and the
-.B \-U
-flag is supplied to
-.IR perl .
-Even if these conditions are met, be warned that unlinking a directory
-can inflict damage on your filesystem.
-Use rmdir instead.
-.Ip "unpack(TEMPLATE,EXPR)" 8 4
-Unpack does the reverse of pack: it takes a string representing
-a structure and expands it out into an array value, returning the array
-value.
-(In a scalar context, it merely returns the first value produced.)
-The TEMPLATE has the same format as in the pack function.
-Here's a subroutine that does substring:
-.nf
-
-.ne 4
- sub substr {
- local($what,$where,$howmuch) = @_;
- unpack("x$where a$howmuch", $what);
- }
-
-.ne 3
-and then there's
-
- sub ord { unpack("c",$_[0]); }
-
-.fi
-In addition, you may prefix a field with a %<number> to indicate that
-you want a <number>-bit checksum of the items instead of the items themselves.
-Default is a 16-bit checksum.
-For example, the following computes the same number as the System V sum program:
-.nf
-
-.ne 4
- while (<>) {
- $checksum += unpack("%16C*", $_);
- }
- $checksum %= 65536;
-
-.fi
-.Ip "unshift(ARRAY,LIST)" 8 4
-Does the opposite of a
-.IR shift .
-Or the opposite of a
-.IR push ,
-depending on how you look at it.
-Prepends list to the front of the array, and returns the number of elements
-in the new array.
-.nf
-
- unshift(ARGV, \'\-e\') unless $ARGV[0] =~ /^\-/;
-
-.fi
-.Ip "utime(LIST)" 8 2
-.Ip "utime LIST" 8 2
-Changes the access and modification times on each file of a list of files.
-The first two elements of the list must be the NUMERICAL access and
-modification times, in that order.
-Returns the number of files successfully changed.
-The inode modification time of each file is set to the current time.
-Example of a \*(L"touch\*(R" command:
-.nf
-
-.ne 3
- #!/usr/bin/perl
- $now = time;
- utime $now, $now, @ARGV;
-
-.fi
-.Ip "values(ASSOC_ARRAY)" 8 6
-.Ip "values ASSOC_ARRAY" 8
-Returns a normal array consisting of all the values of the named associative
-array.
-The values are returned in an apparently random order, but it is the same order
-as either the keys() or each() function would produce on the same array.
-See also keys() and each().
-.Ip "vec(EXPR,OFFSET,BITS)" 8 2
-Treats a string as a vector of unsigned integers, and returns the value
-of the bitfield specified.
-May also be assigned to.
-BITS must be a power of two from 1 to 32.
-.Sp
-Vectors created with vec() can also be manipulated with the logical operators
-|, & and ^,
-which will assume a bit vector operation is desired when both operands are
-strings.
-This interpretation is not enabled unless there is at least one vec() in
-your program, to protect older programs.
-.Sp
-To transform a bit vector into a string or array of 0's and 1's, use these:
-.nf
-
- $bits = unpack("b*", $vector);
- @bits = split(//, unpack("b*", $vector));
-
-.fi
-If you know the exact length in bits, it can be used in place of the *.
-.Ip "wait" 8 6
-Waits for a child process to terminate and returns the pid of the deceased
-process, or -1 if there are no child processes.
-The status is returned in $?.
-.Ip "waitpid(PID,FLAGS)" 8 6
-Waits for a particular child process to terminate and returns the pid of the deceased
-process, or -1 if there is no such child process.
-The status is returned in $?.
-If you say
-.nf
-
- require "sys/wait.h";
- .\|.\|.
- waitpid(-1,&WNOHANG);
-
-.fi
-then you can do a non-blocking wait for any process. Non-blocking wait
-is only available on machines supporting either the
-.I waitpid (2)
-or
-.I wait4 (2)
-system calls.
-However, waiting for a particular pid with FLAGS of 0 is implemented
-everywhere. (Perl emulates the system call by remembering the status
-values of processes that have exited but have not been harvested by the
-Perl script yet.)
-.Ip "wantarray" 8 4
-Returns true if the context of the currently executing subroutine
-is looking for an array value.
-Returns false if the context is looking for a scalar.
-.nf
-
- return wantarray ? () : undef;
-
-.fi
-.Ip "warn(LIST)" 8 4
-.Ip "warn LIST" 8
-Produces a message on STDERR just like \*(L"die\*(R", but doesn't exit.
-.Ip "write(FILEHANDLE)" 8 6
-.Ip "write(EXPR)" 8
-.Ip "write" 8
-Writes a formatted record (possibly multi-line) to the specified file,
-using the format associated with that file.
-By default the format for a file is the one having the same name is the
-filehandle, but the format for the current output channel (see
-.IR select )
-may be set explicitly
-by assigning the name of the format to the $~ variable.
-.Sp
-Top of form processing is handled automatically:
-if there is insufficient room on the current page for the formatted
-record, the page is advanced by writing a form feed,
-a special top-of-page format is used
-to format the new page header, and then the record is written.
-By default the top-of-page format is the name of the filehandle with
-\*(L"_TOP\*(R" appended, but it may be dynamicallly set to the
-format of your choice by assigning the name to the $^ variable while
-the filehandle is selected.
-The number of lines remaining on the current page is in variable $-, which
-can be set to 0 to force a new page.
-.Sp
-If FILEHANDLE is unspecified, output goes to the current default output channel,
-which starts out as
-.I STDOUT
-but may be changed by the
-.I select
-operator.
-If the FILEHANDLE is an EXPR, then the expression is evaluated and the
-resulting string is used to look up the name of the FILEHANDLE at run time.
-For more on formats, see the section on formats later on.
-.Sp
-Note that write is NOT the opposite of read.
-.Sh "Precedence"
-.I Perl
-operators have the following associativity and precedence:
-.nf
-
-nonassoc\h'|1i'print printf exec system sort reverse
-\h'1.5i'chmod chown kill unlink utime die return
-left\h'|1i',
-right\h'|1i'= += \-= *= etc.
-right\h'|1i'?:
-nonassoc\h'|1i'.\|.
-left\h'|1i'||
-left\h'|1i'&&
-left\h'|1i'| ^
-left\h'|1i'&
-nonassoc\h'|1i'== != <=> eq ne cmp
-nonassoc\h'|1i'< > <= >= lt gt le ge
-nonassoc\h'|1i'chdir exit eval reset sleep rand umask
-nonassoc\h'|1i'\-r \-w \-x etc.
-left\h'|1i'<< >>
-left\h'|1i'+ \- .
-left\h'|1i'* / % x
-left\h'|1i'=~ !~
-right\h'|1i'! ~ and unary minus
-right\h'|1i'**
-nonassoc\h'|1i'++ \-\|\-
-left\h'|1i'\*(L'(\*(R'
-
-.fi
-As mentioned earlier, if any list operator (print, etc.) or
-any unary operator (chdir, etc.)
-is followed by a left parenthesis as the next token on the same line,
-the operator and arguments within parentheses are taken to
-be of highest precedence, just like a normal function call.
-Examples:
-.nf
-
- chdir $foo || die;\h'|3i'# (chdir $foo) || die
- chdir($foo) || die;\h'|3i'# (chdir $foo) || die
- chdir ($foo) || die;\h'|3i'# (chdir $foo) || die
- chdir +($foo) || die;\h'|3i'# (chdir $foo) || die
-
-but, because * is higher precedence than ||:
-
- chdir $foo * 20;\h'|3i'# chdir ($foo * 20)
- chdir($foo) * 20;\h'|3i'# (chdir $foo) * 20
- chdir ($foo) * 20;\h'|3i'# (chdir $foo) * 20
- chdir +($foo) * 20;\h'|3i'# chdir ($foo * 20)
-
- rand 10 * 20;\h'|3i'# rand (10 * 20)
- rand(10) * 20;\h'|3i'# (rand 10) * 20
- rand (10) * 20;\h'|3i'# (rand 10) * 20
- rand +(10) * 20;\h'|3i'# rand (10 * 20)
-
-.fi
-In the absence of parentheses,
-the precedence of list operators such as print, sort or chmod is
-either very high or very low depending on whether you look at the left
-side of operator or the right side of it.
-For example, in
-.nf
-
- @ary = (1, 3, sort 4, 2);
- print @ary; # prints 1324
-
-.fi
-the commas on the right of the sort are evaluated before the sort, but
-the commas on the left are evaluated after.
-In other words, list operators tend to gobble up all the arguments that
-follow them, and then act like a simple term with regard to the preceding
-expression.
-Note that you have to be careful with parens:
-.nf
-
-.ne 3
- # These evaluate exit before doing the print:
- print($foo, exit); # Obviously not what you want.
- print $foo, exit; # Nor is this.
-
-.ne 4
- # These do the print before evaluating exit:
- (print $foo), exit; # This is what you want.
- print($foo), exit; # Or this.
- print ($foo), exit; # Or even this.
-
-Also note that
-
- print ($foo & 255) + 1, "\en";
-
-.fi
-probably doesn't do what you expect at first glance.
-.Sh "Subroutines"
-A subroutine may be declared as follows:
-.nf
-
- sub NAME BLOCK
-
-.fi
-.PP
-Any arguments passed to the routine come in as array @_,
-that is ($_[0], $_[1], .\|.\|.).
-The array @_ is a local array, but its values are references to the
-actual scalar parameters.
-The return value of the subroutine is the value of the last expression
-evaluated, and can be either an array value or a scalar value.
-Alternately, a return statement may be used to specify the returned value and
-exit the subroutine.
-To create local variables see the
-.I local
-operator.
-.PP
-A subroutine is called using the
-.I do
-operator or the & operator.
-.nf
-
-.ne 12
-Example:
-
- sub MAX {
- local($max) = pop(@_);
- foreach $foo (@_) {
- $max = $foo \|if \|$max < $foo;
- }
- $max;
- }
-
- .\|.\|.
- $bestday = &MAX($mon,$tue,$wed,$thu,$fri);
-
-.ne 21
-Example:
-
- # get a line, combining continuation lines
- # that start with whitespace
- sub get_line {
- $thisline = $lookahead;
- line: while ($lookahead = <STDIN>) {
- if ($lookahead \|=~ \|/\|^[ \^\e\|t]\|/\|) {
- $thisline \|.= \|$lookahead;
- }
- else {
- last line;
- }
- }
- $thisline;
- }
-
- $lookahead = <STDIN>; # get first line
- while ($_ = do get_line(\|)) {
- .\|.\|.
- }
-
-.fi
-.nf
-.ne 6
-Use array assignment to a local list to name your formal arguments:
-
- sub maybeset {
- local($key, $value) = @_;
- $foo{$key} = $value unless $foo{$key};
- }
-
-.fi
-This also has the effect of turning call-by-reference into call-by-value,
-since the assignment copies the values.
-.Sp
-Subroutines may be called recursively.
-If a subroutine is called using the & form, the argument list is optional.
-If omitted, no @_ array is set up for the subroutine; the @_ array at the
-time of the call is visible to subroutine instead.
-.nf
-
- do foo(1,2,3); # pass three arguments
- &foo(1,2,3); # the same
-
- do foo(); # pass a null list
- &foo(); # the same
- &foo; # pass no arguments\*(--more efficient
-
-.fi
-.Sh "Passing By Reference"
-Sometimes you don't want to pass the value of an array to a subroutine but
-rather the name of it, so that the subroutine can modify the global copy
-of it rather than working with a local copy.
-In perl you can refer to all the objects of a particular name by prefixing
-the name with a star: *foo.
-When evaluated, it produces a scalar value that represents all the objects
-of that name, including any filehandle, format or subroutine.
-When assigned to within a local() operation, it causes the name mentioned
-to refer to whatever * value was assigned to it.
-Example:
-.nf
-
- sub doubleary {
- local(*someary) = @_;
- foreach $elem (@someary) {
- $elem *= 2;
- }
- }
- do doubleary(*foo);
- do doubleary(*bar);
-
-.fi
-Assignment to *name is currently recommended only inside a local().
-You can actually assign to *name anywhere, but the previous referent of
-*name may be stranded forever.
-This may or may not bother you.
-.Sp
-Note that scalars are already passed by reference, so you can modify scalar
-arguments without using this mechanism by referring explicitly to the $_[nnn]
-in question.
-You can modify all the elements of an array by passing all the elements
-as scalars, but you have to use the * mechanism to push, pop or change the
-size of an array.
-The * mechanism will probably be more efficient in any case.
-.Sp
-Since a *name value contains unprintable binary data, if it is used as
-an argument in a print, or as a %s argument in a printf or sprintf, it
-then has the value '*name', just so it prints out pretty.
-.Sp
-Even if you don't want to modify an array, this mechanism is useful for
-passing multiple arrays in a single LIST, since normally the LIST mechanism
-will merge all the array values so that you can't extract out the
-individual arrays.
-.Sh "Regular Expressions"
-The patterns used in pattern matching are regular expressions such as
-those supplied in the Version 8 regexp routines.
-(In fact, the routines are derived from Henry Spencer's freely redistributable
-reimplementation of the V8 routines.)
-In addition, \ew matches an alphanumeric character (including \*(L"_\*(R") and \eW a nonalphanumeric.
-Word boundaries may be matched by \eb, and non-boundaries by \eB.
-A whitespace character is matched by \es, non-whitespace by \eS.
-A numeric character is matched by \ed, non-numeric by \eD.
-You may use \ew, \es and \ed within character classes.
-Also, \en, \er, \ef, \et and \eNNN have their normal interpretations.
-Within character classes \eb represents backspace rather than a word boundary.
-Alternatives may be separated by |.
-The bracketing construct \|(\ .\|.\|.\ \|) may also be used, in which case \e<digit>
-matches the digit'th substring.
-(Outside of the pattern, always use $ instead of \e in front of the digit.
-The scope of $<digit> (and $\`, $& and $\')
-extends to the end of the enclosing BLOCK or eval string, or to
-the next pattern match with subexpressions.
-The \e<digit> notation sometimes works outside the current pattern, but should
-not be relied upon.)
-You may have as many parentheses as you wish. If you have more than 9
-substrings, the variables $10, $11, ... refer to the corresponding
-substring. Within the pattern, \e10, \e11,
-etc. refer back to substrings if there have been at least that many left parens
-before the backreference. Otherwise (for backward compatibility) \e10
-is the same as \e010, a backspace,
-and \e11 the same as \e011, a tab.
-And so on.
-(\e1 through \e9 are always backreferences.)
-.PP
-$+ returns whatever the last bracket match matched.
-$& returns the entire matched string.
-($0 used to return the same thing, but not any more.)
-$\` returns everything before the matched string.
-$\' returns everything after the matched string.
-Examples:
-.nf
-
- s/\|^\|([^ \|]*\|) \|*([^ \|]*\|)\|/\|$2 $1\|/; # swap first two words
-
-.ne 5
- if (/\|Time: \|(.\|.\|):\|(.\|.\|):\|(.\|.\|)\|/\|) {
- $hours = $1;
- $minutes = $2;
- $seconds = $3;
- }
-
-.fi
-By default, the ^ character is only guaranteed to match at the beginning
-of the string,
-the $ character only at the end (or before the newline at the end)
-and
-.I perl
-does certain optimizations with the assumption that the string contains
-only one line.
-The behavior of ^ and $ on embedded newlines will be inconsistent.
-You may, however, wish to treat a string as a multi-line buffer, such that
-the ^ will match after any newline within the string, and $ will match
-before any newline.
-At the cost of a little more overhead, you can do this by setting the variable
-$* to 1.
-Setting it back to 0 makes
-.I perl
-revert to its old behavior.
-.PP
-To facilitate multi-line substitutions, the . character never matches a newline
-(even when $* is 0).
-In particular, the following leaves a newline on the $_ string:
-.nf
-
- $_ = <STDIN>;
- s/.*(some_string).*/$1/;
-
-If the newline is unwanted, try one of
-
- s/.*(some_string).*\en/$1/;
- s/.*(some_string)[^\e000]*/$1/;
- s/.*(some_string)(.|\en)*/$1/;
- chop; s/.*(some_string).*/$1/;
- /(some_string)/ && ($_ = $1);
-
-.fi
-Any item of a regular expression may be followed with digits in curly brackets
-of the form {n,m}, where n gives the minimum number of times to match the item
-and m gives the maximum.
-The form {n} is equivalent to {n,n} and matches exactly n times.
-The form {n,} matches n or more times.
-(If a curly bracket occurs in any other context, it is treated as a regular
-character.)
-The * modifier is equivalent to {0,}, the + modifier to {1,} and the ? modifier
-to {0,1}.
-There is no limit to the size of n or m, but large numbers will chew up
-more memory.
-.Sp
-You will note that all backslashed metacharacters in
-.I perl
-are alphanumeric,
-such as \eb, \ew, \en.
-Unlike some other regular expression languages, there are no backslashed
-symbols that aren't alphanumeric.
-So anything that looks like \e\e, \e(, \e), \e<, \e>, \e{, or \e} is always
-interpreted as a literal character, not a metacharacter.
-This makes it simple to quote a string that you want to use for a pattern
-but that you are afraid might contain metacharacters.
-Simply quote all the non-alphanumeric characters:
-.nf
-
- $pattern =~ s/(\eW)/\e\e$1/g;
-
-.fi
-.Sh "Formats"
-Output record formats for use with the
-.I write
-operator may declared as follows:
-.nf
-
-.ne 3
- format NAME =
- FORMLIST
- .
-
-.fi
-If name is omitted, format \*(L"STDOUT\*(R" is defined.
-FORMLIST consists of a sequence of lines, each of which may be of one of three
-types:
-.Ip 1. 4
-A comment.
-.Ip 2. 4
-A \*(L"picture\*(R" line giving the format for one output line.
-.Ip 3. 4
-An argument line supplying values to plug into a picture line.
-.PP
-Picture lines are printed exactly as they look, except for certain fields
-that substitute values into the line.
-Each picture field starts with either @ or ^.
-The @ field (not to be confused with the array marker @) is the normal
-case; ^ fields are used
-to do rudimentary multi-line text block filling.
-The length of the field is supplied by padding out the field
-with multiple <, >, or | characters to specify, respectively, left justification,
-right justification, or centering.
-As an alternate form of right justification,
-you may also use # characters (with an optional .) to specify a numeric field.
-(Use of ^ instead of @ causes the field to be blanked if undefined.)
-If any of the values supplied for these fields contains a newline, only
-the text up to the newline is printed.
-The special field @* can be used for printing multi-line values.
-It should appear by itself on a line.
-.PP
-The values are specified on the following line, in the same order as
-the picture fields.
-The values should be separated by commas.
-.PP
-Picture fields that begin with ^ rather than @ are treated specially.
-The value supplied must be a scalar variable name which contains a text
-string.
-.I Perl
-puts as much text as it can into the field, and then chops off the front
-of the string so that the next time the variable is referenced,
-more of the text can be printed.
-Normally you would use a sequence of fields in a vertical stack to print
-out a block of text.
-If you like, you can end the final field with .\|.\|., which will appear in the
-output if the text was too long to appear in its entirety.
-You can change which characters are legal to break on by changing the
-variable $: to a list of the desired characters.
-.PP
-Since use of ^ fields can produce variable length records if the text to be
-formatted is short, you can suppress blank lines by putting the tilde (~)
-character anywhere in the line.
-(Normally you should put it in the front if possible, for visibility.)
-The tilde will be translated to a space upon output.
-If you put a second tilde contiguous to the first, the line will be repeated
-until all the fields on the line are exhausted.
-(If you use a field of the @ variety, the expression you supply had better
-not give the same value every time forever!)
-.PP
-Examples:
-.nf
-.lg 0
-.cs R 25
-.ft C
-
-.ne 10
-# a report on the /etc/passwd file
-format STDOUT_TOP =
-\& Passwd File
-Name Login Office Uid Gid Home
-------------------------------------------------------------------
-\&.
-format STDOUT =
-@<<<<<<<<<<<<<<<<<< @||||||| @<<<<<<@>>>> @>>>> @<<<<<<<<<<<<<<<<<
-$name, $login, $office,$uid,$gid, $home
-\&.
-
-.ne 29
-# a report from a bug report form
-format STDOUT_TOP =
-\& Bug Reports
-@<<<<<<<<<<<<<<<<<<<<<<< @||| @>>>>>>>>>>>>>>>>>>>>>>>
-$system, $%, $date
-------------------------------------------------------------------
-\&.
-format STDOUT =
-Subject: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-\& $subject
-Index: @<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-\& $index, $description
-Priority: @<<<<<<<<<< Date: @<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-\& $priority, $date, $description
-From: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-\& $from, $description
-Assigned to: @<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-\& $programmer, $description
-\&~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-\& $description
-\&~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-\& $description
-\&~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-\& $description
-\&~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-\& $description
-\&~ ^<<<<<<<<<<<<<<<<<<<<<<<...
-\& $description
-\&.
-
-.ft R
-.cs R
-.lg
-.fi
-It is possible to intermix prints with writes on the same output channel,
-but you'll have to handle $\- (lines left on the page) yourself.
-.PP
-If you are printing lots of fields that are usually blank, you should consider
-using the reset operator between records.
-Not only is it more efficient, but it can prevent the bug of adding another
-field and forgetting to zero it.
-.Sh "Interprocess Communication"
-The IPC facilities of perl are built on the Berkeley socket mechanism.
-If you don't have sockets, you can ignore this section.
-The calls have the same names as the corresponding system calls,
-but the arguments tend to differ, for two reasons.
-First, perl file handles work differently than C file descriptors.
-Second, perl already knows the length of its strings, so you don't need
-to pass that information.
-Here is a sample client (untested):
-.nf
-
- ($them,$port) = @ARGV;
- $port = 2345 unless $port;
- $them = 'localhost' unless $them;
-
- $SIG{'INT'} = 'dokill';
- sub dokill { kill 9,$child if $child; }
-
- require 'sys/socket.ph';
-
- $sockaddr = 'S n a4 x8';
- chop($hostname = `hostname`);
-
- ($name, $aliases, $proto) = getprotobyname('tcp');
- ($name, $aliases, $port) = getservbyname($port, 'tcp')
- unless $port =~ /^\ed+$/;
-.ie t \{\
- ($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname);
-'br\}
-.el \{\
- ($name, $aliases, $type, $len, $thisaddr) =
- gethostbyname($hostname);
-'br\}
- ($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);
-
- $this = pack($sockaddr, &AF_INET, 0, $thisaddr);
- $that = pack($sockaddr, &AF_INET, $port, $thataddr);
-
- socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
- bind(S, $this) || die "bind: $!";
- connect(S, $that) || die "connect: $!";
-
- select(S); $| = 1; select(stdout);
-
- if ($child = fork) {
- while (<>) {
- print S;
- }
- sleep 3;
- do dokill();
- }
- else {
- while (<S>) {
- print;
- }
- }
-
-.fi
-And here's a server:
-.nf
-
- ($port) = @ARGV;
- $port = 2345 unless $port;
-
- require 'sys/socket.ph';
-
- $sockaddr = 'S n a4 x8';
-
- ($name, $aliases, $proto) = getprotobyname('tcp');
- ($name, $aliases, $port) = getservbyname($port, 'tcp')
- unless $port =~ /^\ed+$/;
-
- $this = pack($sockaddr, &AF_INET, $port, "\e0\e0\e0\e0");
-
- select(NS); $| = 1; select(stdout);
-
- socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
- bind(S, $this) || die "bind: $!";
- listen(S, 5) || die "connect: $!";
-
- select(S); $| = 1; select(stdout);
-
- for (;;) {
- print "Listening again\en";
- ($addr = accept(NS,S)) || die $!;
- print "accept ok\en";
-
- ($af,$port,$inetaddr) = unpack($sockaddr,$addr);
- @inetaddr = unpack('C4',$inetaddr);
- print "$af $port @inetaddr\en";
-
- while (<NS>) {
- print;
- print NS;
- }
- }
-
-.fi
-.Sh "Predefined Names"
-The following names have special meaning to
-.IR perl .
-I could have used alphabetic symbols for some of these, but I didn't want
-to take the chance that someone would say reset \*(L"a\-zA\-Z\*(R" and wipe them all
-out.
-You'll just have to suffer along with these silly symbols.
-Most of them have reasonable mnemonics, or analogues in one of the shells.
-.Ip $_ 8
-The default input and pattern-searching space.
-The following pairs are equivalent:
-.nf
-
-.ne 2
- while (<>) {\|.\|.\|. # only equivalent in while!
- while ($_ = <>) {\|.\|.\|.
-
-.ne 2
- /\|^Subject:/
- $_ \|=~ \|/\|^Subject:/
-
-.ne 2
- y/a\-z/A\-Z/
- $_ =~ y/a\-z/A\-Z/
-
-.ne 2
- chop
- chop($_)
-
-.fi
-(Mnemonic: underline is understood in certain operations.)
-.Ip $. 8
-The current input line number of the last filehandle that was read.
-Readonly.
-Remember that only an explicit close on the filehandle resets the line number.
-Since <> never does an explicit close, line numbers increase across ARGV files
-(but see examples under eof).
-(Mnemonic: many programs use . to mean the current line number.)
-.Ip $/ 8
-The input record separator, newline by default.
-Works like
-.IR awk 's
-RS variable, including treating blank lines as delimiters
-if set to the null string.
-You may set it to a multicharacter string to match a multi-character
-delimiter.
-Note that setting it to "\en\en" means something slightly different
-than setting it to "", if the file contains consecutive blank lines.
-Setting it to "" will treat two or more consecutive blank lines as a single
-blank line.
-Setting it to "\en\en" will blindly assume that the next input character
-belongs to the next paragraph, even if it's a newline.
-(Mnemonic: / is used to delimit line boundaries when quoting poetry.)
-.Ip $, 8
-The output field separator for the print operator.
-Ordinarily the print operator simply prints out the comma separated fields
-you specify.
-In order to get behavior more like
-.IR awk ,
-set this variable as you would set
-.IR awk 's
-OFS variable to specify what is printed between fields.
-(Mnemonic: what is printed when there is a , in your print statement.)
-.Ip $"" 8
-This is like $, except that it applies to array values interpolated into
-a double-quoted string (or similar interpreted string).
-Default is a space.
-(Mnemonic: obvious, I think.)
-.Ip $\e 8
-The output record separator for the print operator.
-Ordinarily the print operator simply prints out the comma separated fields
-you specify, with no trailing newline or record separator assumed.
-In order to get behavior more like
-.IR awk ,
-set this variable as you would set
-.IR awk 's
-ORS variable to specify what is printed at the end of the print.
-(Mnemonic: you set $\e instead of adding \en at the end of the print.
-Also, it's just like /, but it's what you get \*(L"back\*(R" from
-.IR perl .)
-.Ip $# 8
-The output format for printed numbers.
-This variable is a half-hearted attempt to emulate
-.IR awk 's
-OFMT variable.
-There are times, however, when
-.I awk
-and
-.I perl
-have differing notions of what
-is in fact numeric.
-Also, the initial value is %.20g rather than %.6g, so you need to set $#
-explicitly to get
-.IR awk 's
-value.
-(Mnemonic: # is the number sign.)
-.Ip $% 8
-The current page number of the currently selected output channel.
-(Mnemonic: % is page number in nroff.)
-.Ip $= 8
-The current page length (printable lines) of the currently selected output
-channel.
-Default is 60.
-(Mnemonic: = has horizontal lines.)
-.Ip $\- 8
-The number of lines left on the page of the currently selected output channel.
-(Mnemonic: lines_on_page \- lines_printed.)
-.Ip $~ 8
-The name of the current report format for the currently selected output
-channel.
-Default is name of the filehandle.
-(Mnemonic: brother to $^.)
-.Ip $^ 8
-The name of the current top-of-page format for the currently selected output
-channel.
-Default is name of the filehandle with \*(L"_TOP\*(R" appended.
-(Mnemonic: points to top of page.)
-.Ip $| 8
-If set to nonzero, forces a flush after every write or print on the currently
-selected output channel.
-Default is 0.
-Note that
-.I STDOUT
-will typically be line buffered if output is to the
-terminal and block buffered otherwise.
-Setting this variable is useful primarily when you are outputting to a pipe,
-such as when you are running a
-.I perl
-script under rsh and want to see the
-output as it's happening.
-(Mnemonic: when you want your pipes to be piping hot.)
-.Ip $$ 8
-The process number of the
-.I perl
-running this script.
-(Mnemonic: same as shells.)
-.Ip $? 8
-The status returned by the last pipe close, backtick (\`\`) command or
-.I system
-operator.
-Note that this is the status word returned by the wait() system
-call, so the exit value of the subprocess is actually ($? >> 8).
-$? & 255 gives which signal, if any, the process died from, and whether
-there was a core dump.
-(Mnemonic: similar to sh and ksh.)
-.Ip $& 8 4
-The string matched by the last successful pattern match
-(not counting any matches hidden
-within a BLOCK or eval enclosed by the current BLOCK).
-(Mnemonic: like & in some editors.)
-.Ip $\` 8 4
-The string preceding whatever was matched by the last successful pattern match
-(not counting any matches hidden within a BLOCK or eval enclosed by the current
-BLOCK).
-(Mnemonic: \` often precedes a quoted string.)
-.Ip $\' 8 4
-The string following whatever was matched by the last successful pattern match
-(not counting any matches hidden within a BLOCK or eval enclosed by the current
-BLOCK).
-(Mnemonic: \' often follows a quoted string.)
-Example:
-.nf
-
-.ne 3
- $_ = \'abcdefghi\';
- /def/;
- print "$\`:$&:$\'\en"; # prints abc:def:ghi
-
-.fi
-.Ip $+ 8 4
-The last bracket matched by the last search pattern.
-This is useful if you don't know which of a set of alternative patterns
-matched.
-For example:
-.nf
-
- /Version: \|(.*\|)|Revision: \|(.*\|)\|/ \|&& \|($rev = $+);
-
-.fi
-(Mnemonic: be positive and forward looking.)
-.Ip $* 8 2
-Set to 1 to do multiline matching within a string, 0 to tell
-.I perl
-that it can assume that strings contain a single line, for the purpose
-of optimizing pattern matches.
-Pattern matches on strings containing multiple newlines can produce confusing
-results when $* is 0.
-Default is 0.
-(Mnemonic: * matches multiple things.)
-Note that this variable only influences the interpretation of ^ and $.
-A literal newline can be searched for even when $* == 0.
-.Ip $0 8
-Contains the name of the file containing the
-.I perl
-script being executed.
-Assigning to $0 modifies the argument area that the ps(1) program sees.
-(Mnemonic: same as sh and ksh.)
-.Ip $<digit> 8
-Contains the subpattern from the corresponding set of parentheses in the last
-pattern matched, not counting patterns matched in nested blocks that have
-been exited already.
-(Mnemonic: like \edigit.)
-.Ip $[ 8 2
-The index of the first element in an array, and of the first character in
-a substring.
-Default is 0, but you could set it to 1 to make
-.I perl
-behave more like
-.I awk
-(or Fortran)
-when subscripting and when evaluating the index() and substr() functions.
-(Mnemonic: [ begins subscripts.)
-.Ip $] 8 2
-The string printed out when you say \*(L"perl -v\*(R".
-It can be used to determine at the beginning of a script whether the perl
-interpreter executing the script is in the right range of versions.
-If used in a numeric context, returns the version + patchlevel / 1000.
-Example:
-.nf
-
-.ne 8
- # see if getc is available
- ($version,$patchlevel) =
- $] =~ /(\ed+\e.\ed+).*\enPatch level: (\ed+)/;
- print STDERR "(No filename completion available.)\en"
- if $version * 1000 + $patchlevel < 2016;
-
-or, used numerically,
-
- warn "No checksumming!\en" if $] < 3.019;
-
-.fi
-(Mnemonic: Is this version of perl in the right bracket?)
-.Ip $; 8 2
-The subscript separator for multi-dimensional array emulation.
-If you refer to an associative array element as
-.nf
- $foo{$a,$b,$c}
-
-it really means
-
- $foo{join($;, $a, $b, $c)}
-
-But don't put
-
- @foo{$a,$b,$c} # a slice\*(--note the @
-
-which means
-
- ($foo{$a},$foo{$b},$foo{$c})
-
-.fi
-Default is "\e034", the same as SUBSEP in
-.IR awk .
-Note that if your keys contain binary data there might not be any safe
-value for $;.
-(Mnemonic: comma (the syntactic subscript separator) is a semi-semicolon.
-Yeah, I know, it's pretty lame, but $, is already taken for something more
-important.)
-.Ip $! 8 2
-If used in a numeric context, yields the current value of errno, with all the
-usual caveats.
-(This means that you shouldn't depend on the value of $! to be anything
-in particular unless you've gotten a specific error return indicating a
-system error.)
-If used in a string context, yields the corresponding system error string.
-You can assign to $! in order to set errno
-if, for instance, you want $! to return the string for error n, or you want
-to set the exit value for the die operator.
-(Mnemonic: What just went bang?)
-.Ip $@ 8 2
-The perl syntax error message from the last eval command.
-If null, the last eval parsed and executed correctly (although the operations
-you invoked may have failed in the normal fashion).
-(Mnemonic: Where was the syntax error \*(L"at\*(R"?)
-.Ip $< 8 2
-The real uid of this process.
-(Mnemonic: it's the uid you came FROM, if you're running setuid.)
-.Ip $> 8 2
-The effective uid of this process.
-Example:
-.nf
-
-.ne 2
- $< = $>; # set real uid to the effective uid
- ($<,$>) = ($>,$<); # swap real and effective uid
-
-.fi
-(Mnemonic: it's the uid you went TO, if you're running setuid.)
-Note: $< and $> can only be swapped on machines supporting setreuid().
-.Ip $( 8 2
-The real gid of this process.
-If you are on a machine that supports membership in multiple groups
-simultaneously, gives a space separated list of groups you are in.
-The first number is the one returned by getgid(), and the subsequent ones
-by getgroups(), one of which may be the same as the first number.
-(Mnemonic: parentheses are used to GROUP things.
-The real gid is the group you LEFT, if you're running setgid.)
-.Ip $) 8 2
-The effective gid of this process.
-If you are on a machine that supports membership in multiple groups
-simultaneously, gives a space separated list of groups you are in.
-The first number is the one returned by getegid(), and the subsequent ones
-by getgroups(), one of which may be the same as the first number.
-(Mnemonic: parentheses are used to GROUP things.
-The effective gid is the group that's RIGHT for you, if you're running setgid.)
-.Sp
-Note: $<, $>, $( and $) can only be set on machines that support the
-corresponding set[re][ug]id() routine.
-$( and $) can only be swapped on machines supporting setregid().
-.Ip $: 8 2
-The current set of characters after which a string may be broken to
-fill continuation fields (starting with ^) in a format.
-Default is "\ \en-", to break on whitespace or hyphens.
-(Mnemonic: a \*(L"colon\*(R" in poetry is a part of a line.)
-.Ip $^D 8 2
-The current value of the debugging flags.
-(Mnemonic: value of
-.B \-D
-switch.)
-.Ip $^F 8 2
-The maximum system file descriptor, ordinarily 2. System file descriptors
-are passed to subprocesses, while higher file descriptors are not.
-During an open, system file descriptors are preserved even if the open
-fails. Ordinary file descriptors are closed before the open is attempted.
-.Ip $^I 8 2
-The current value of the inplace-edit extension.
-Use undef to disable inplace editing.
-(Mnemonic: value of
-.B \-i
-switch.)
-.Ip $^L 8 2
-What formats output to perform a formfeed. Default is \ef.
-.Ip $^P 8 2
-The internal flag that the debugger clears so that it doesn't
-debug itself. You could conceivable disable debugging yourself
-by clearing it.
-.Ip $^T 8 2
-The time at which the script began running, in seconds since the epoch.
-The values returned by the
-.B \-M ,
-.B \-A
-and
-.B \-C
-filetests are based on this value.
-.Ip $^W 8 2
-The current value of the warning switch.
-(Mnemonic: related to the
-.B \-w
-switch.)
-.Ip $^X 8 2
-The name that Perl itself was executed as, from argv[0].
-.Ip $ARGV 8 3
-contains the name of the current file when reading from <>.
-.Ip @ARGV 8 3
-The array ARGV contains the command line arguments intended for the script.
-Note that $#ARGV is the generally number of arguments minus one, since
-$ARGV[0] is the first argument, NOT the command name.
-See $0 for the command name.
-.Ip @INC 8 3
-The array INC contains the list of places to look for
-.I perl
-scripts to be
-evaluated by the \*(L"do EXPR\*(R" command or the \*(L"require\*(R" command.
-It initially consists of the arguments to any
-.B \-I
-command line switches, followed
-by the default
-.I perl
-library, probably \*(L"/usr/share/perl\*(R",
-followed by \*(L".\*(R", to represent the current directory.
-.Ip %INC 8 3
-The associative array INC contains entries for each filename that has
-been included via \*(L"do\*(R" or \*(L"require\*(R".
-The key is the filename you specified, and the value is the location of
-the file actually found.
-The \*(L"require\*(R" command uses this array to determine whether
-a given file has already been included.
-.Ip $ENV{expr} 8 2
-The associative array ENV contains your current environment.
-Setting a value in ENV changes the environment for child processes.
-.Ip $SIG{expr} 8 2
-The associative array SIG is used to set signal handlers for various signals.
-Example:
-.nf
-
-.ne 12
- sub handler { # 1st argument is signal name
- local($sig) = @_;
- print "Caught a SIG$sig\-\|\-shutting down\en";
- close(LOG);
- exit(0);
- }
-
- $SIG{\'INT\'} = \'handler\';
- $SIG{\'QUIT\'} = \'handler\';
- .\|.\|.
- $SIG{\'INT\'} = \'DEFAULT\'; # restore default action
- $SIG{\'QUIT\'} = \'IGNORE\'; # ignore SIGQUIT
-
-.fi
-The SIG array only contains values for the signals actually set within
-the perl script.
-.Sh "Packages"
-Perl provides a mechanism for alternate namespaces to protect packages from
-stomping on each others variables.
-By default, a perl script starts compiling into the package known as \*(L"main\*(R".
-By use of the
-.I package
-declaration, you can switch namespaces.
-The scope of the package declaration is from the declaration itself to the end
-of the enclosing block (the same scope as the local() operator).
-Typically it would be the first declaration in a file to be included by
-the \*(L"require\*(R" operator.
-You can switch into a package in more than one place; it merely influences
-which symbol table is used by the compiler for the rest of that block.
-You can refer to variables and filehandles in other packages by prefixing
-the identifier with the package name and a single quote.
-If the package name is null, the \*(L"main\*(R" package as assumed.
-.PP
-Only identifiers starting with letters are stored in the packages symbol
-table.
-All other symbols are kept in package \*(L"main\*(R".
-In addition, the identifiers STDIN, STDOUT, STDERR, ARGV, ARGVOUT, ENV, INC
-and SIG are forced to be in package \*(L"main\*(R", even when used for
-other purposes than their built-in one.
-Note also that, if you have a package called \*(L"m\*(R", \*(L"s\*(R"
-or \*(L"y\*(R", the you can't use the qualified form of an identifier since it
-will be interpreted instead as a pattern match, a substitution
-or a translation.
-.PP
-Eval'ed strings are compiled in the package in which the eval was compiled
-in.
-(Assignments to $SIG{}, however, assume the signal handler specified is in the
-main package.
-Qualify the signal handler name if you wish to have a signal handler in
-a package.)
-For an example, examine perldb.pl in the perl library.
-It initially switches to the DB package so that the debugger doesn't interfere
-with variables in the script you are trying to debug.
-At various points, however, it temporarily switches back to the main package
-to evaluate various expressions in the context of the main package.
-.PP
-The symbol table for a package happens to be stored in the associative array
-of that name prepended with an underscore.
-The value in each entry of the associative array is
-what you are referring to when you use the *name notation.
-In fact, the following have the same effect (in package main, anyway),
-though the first is more
-efficient because it does the symbol table lookups at compile time:
-.nf
-
-.ne 2
- local(*foo) = *bar;
- local($_main{'foo'}) = $_main{'bar'};
-
-.fi
-You can use this to print out all the variables in a package, for instance.
-Here is dumpvar.pl from the perl library:
-.nf
-.ne 11
- package dumpvar;
-
- sub main'dumpvar {
- \& ($package) = @_;
- \& local(*stab) = eval("*_$package");
- \& while (($key,$val) = each(%stab)) {
- \& {
- \& local(*entry) = $val;
- \& if (defined $entry) {
- \& print "\e$$key = '$entry'\en";
- \& }
-.ne 7
- \& if (defined @entry) {
- \& print "\e@$key = (\en";
- \& foreach $num ($[ .. $#entry) {
- \& print " $num\et'",$entry[$num],"'\en";
- \& }
- \& print ")\en";
- \& }
-.ne 10
- \& if ($key ne "_$package" && defined %entry) {
- \& print "\e%$key = (\en";
- \& foreach $key (sort keys(%entry)) {
- \& print " $key\et'",$entry{$key},"'\en";
- \& }
- \& print ")\en";
- \& }
- \& }
- \& }
- }
-
-.fi
-Note that, even though the subroutine is compiled in package dumpvar, the
-name of the subroutine is qualified so that its name is inserted into package
-\*(L"main\*(R".
-.Sh "Style"
-Each programmer will, of course, have his or her own preferences in regards
-to formatting, but there are some general guidelines that will make your
-programs easier to read.
-.Ip 1. 4 4
-Just because you CAN do something a particular way doesn't mean that
-you SHOULD do it that way.
-.I Perl
-is designed to give you several ways to do anything, so consider picking
-the most readable one.
-For instance
-
- open(FOO,$foo) || die "Can't open $foo: $!";
-
-is better than
-
- die "Can't open $foo: $!" unless open(FOO,$foo);
-
-because the second way hides the main point of the statement in a
-modifier.
-On the other hand
-
- print "Starting analysis\en" if $verbose;
-
-is better than
-
- $verbose && print "Starting analysis\en";
-
-since the main point isn't whether the user typed -v or not.
-.Sp
-Similarly, just because an operator lets you assume default arguments
-doesn't mean that you have to make use of the defaults.
-The defaults are there for lazy systems programmers writing one-shot
-programs.
-If you want your program to be readable, consider supplying the argument.
-.Sp
-Along the same lines, just because you
-.I can
-omit parentheses in many places doesn't mean that you ought to:
-.nf
-
- return print reverse sort num values array;
- return print(reverse(sort num (values(%array))));
-
-.fi
-When in doubt, parenthesize.
-At the very least it will let some poor schmuck bounce on the % key in vi.
-.Sp
-Even if you aren't in doubt, consider the mental welfare of the person who
-has to maintain the code after you, and who will probably put parens in
-the wrong place.
-.Ip 2. 4 4
-Don't go through silly contortions to exit a loop at the top or the
-bottom, when
-.I perl
-provides the "last" operator so you can exit in the middle.
-Just outdent it a little to make it more visible:
-.nf
-
-.ne 7
- line:
- for (;;) {
- statements;
- last line if $foo;
- next line if /^#/;
- statements;
- }
-
-.fi
-.Ip 3. 4 4
-Don't be afraid to use loop labels\*(--they're there to enhance readability as
-well as to allow multi-level loop breaks.
-See last example.
-.Ip 4. 4 4
-For portability, when using features that may not be implemented on every
-machine, test the construct in an eval to see if it fails.
-If you know what version or patchlevel a particular feature was implemented,
-you can test $] to see if it will be there.
-.Ip 5. 4 4
-Choose mnemonic identifiers.
-.Ip 6. 4 4
-Be consistent.
-.Sh "Debugging"
-If you invoke
-.I perl
-with a
-.B \-d
-switch, your script will be run under a debugging monitor.
-It will halt before the first executable statement and ask you for a
-command, such as:
-.Ip "h" 12 4
-Prints out a help message.
-.Ip "T" 12 4
-Stack trace.
-.Ip "s" 12 4
-Single step.
-Executes until it reaches the beginning of another statement.
-.Ip "n" 12 4
-Next.
-Executes over subroutine calls, until it reaches the beginning of the
-next statement.
-.Ip "f" 12 4
-Finish.
-Executes statements until it has finished the current subroutine.
-.Ip "c" 12 4
-Continue.
-Executes until the next breakpoint is reached.
-.Ip "c line" 12 4
-Continue to the specified line.
-Inserts a one-time-only breakpoint at the specified line.
-.Ip "<CR>" 12 4
-Repeat last n or s.
-.Ip "l min+incr" 12 4
-List incr+1 lines starting at min.
-If min is omitted, starts where last listing left off.
-If incr is omitted, previous value of incr is used.
-.Ip "l min-max" 12 4
-List lines in the indicated range.
-.Ip "l line" 12 4
-List just the indicated line.
-.Ip "l" 12 4
-List next window.
-.Ip "-" 12 4
-List previous window.
-.Ip "w line" 12 4
-List window around line.
-.Ip "l subname" 12 4
-List subroutine.
-If it's a long subroutine it just lists the beginning.
-Use \*(L"l\*(R" to list more.
-.Ip "/pattern/" 12 4
-Regular expression search forward for pattern; the final / is optional.
-.Ip "?pattern?" 12 4
-Regular expression search backward for pattern; the final ? is optional.
-.Ip "L" 12 4
-List lines that have breakpoints or actions.
-.Ip "S" 12 4
-Lists the names of all subroutines.
-.Ip "t" 12 4
-Toggle trace mode on or off.
-.Ip "b line condition" 12 4
-Set a breakpoint.
-If line is omitted, sets a breakpoint on the
-line that is about to be executed.
-If a condition is specified, it is evaluated each time the statement is
-reached and a breakpoint is taken only if the condition is true.
-Breakpoints may only be set on lines that begin an executable statement.
-.Ip "b subname condition" 12 4
-Set breakpoint at first executable line of subroutine.
-.Ip "d line" 12 4
-Delete breakpoint.
-If line is omitted, deletes the breakpoint on the
-line that is about to be executed.
-.Ip "D" 12 4
-Delete all breakpoints.
-.Ip "a line command" 12 4
-Set an action for line.
-A multi-line command may be entered by backslashing the newlines.
-.Ip "A" 12 4
-Delete all line actions.
-.Ip "< command" 12 4
-Set an action to happen before every debugger prompt.
-A multi-line command may be entered by backslashing the newlines.
-.Ip "> command" 12 4
-Set an action to happen after the prompt when you've just given a command
-to return to executing the script.
-A multi-line command may be entered by backslashing the newlines.
-.Ip "V package" 12 4
-List all variables in package.
-Default is main package.
-.Ip "! number" 12 4
-Redo a debugging command.
-If number is omitted, redoes the previous command.
-.Ip "! -number" 12 4
-Redo the command that was that many commands ago.
-.Ip "H -number" 12 4
-Display last n commands.
-Only commands longer than one character are listed.
-If number is omitted, lists them all.
-.Ip "q or ^D" 12 4
-Quit.
-.Ip "command" 12 4
-Execute command as a perl statement.
-A missing semicolon will be supplied.
-.Ip "p expr" 12 4
-Same as \*(L"print DB'OUT expr\*(R".
-The DB'OUT filehandle is opened to /dev/tty, regardless of where STDOUT
-may be redirected to.
-.PP
-If you want to modify the debugger, copy perldb.pl from the perl library
-to your current directory and modify it as necessary.
-(You'll also have to put -I. on your command line.)
-You can do some customization by setting up a .perldb file which contains
-initialization code.
-For instance, you could make aliases like these:
-.nf
-
- $DB'alias{'len'} = 's/^len(.*)/p length($1)/';
- $DB'alias{'stop'} = 's/^stop (at|in)/b/';
- $DB'alias{'.'} =
- 's/^\e./p "\e$DB\e'sub(\e$DB\e'line):\et",\e$DB\e'line[\e$DB\e'line]/';
-
-.fi
-.Sh "Setuid Scripts"
-.I Perl
-is designed to make it easy to write secure setuid and setgid scripts.
-Unlike shells, which are based on multiple substitution passes on each line
-of the script,
-.I perl
-uses a more conventional evaluation scheme with fewer hidden \*(L"gotchas\*(R".
-Additionally, since the language has more built-in functionality, it
-has to rely less upon external (and possibly untrustworthy) programs to
-accomplish its purposes.
-.PP
-In an unpatched 4.2 or 4.3bsd kernel, setuid scripts are intrinsically
-insecure, but this kernel feature can be disabled.
-If it is,
-.I perl
-can emulate the setuid and setgid mechanism when it notices the otherwise
-useless setuid/gid bits on perl scripts.
-If the kernel feature isn't disabled,
-.I perl
-will complain loudly that your setuid script is insecure.
-You'll need to either disable the kernel setuid script feature, or put
-a C wrapper around the script.
-.PP
-When perl is executing a setuid script, it takes special precautions to
-prevent you from falling into any obvious traps.
-(In some ways, a perl script is more secure than the corresponding
-C program.)
-Any command line argument, environment variable, or input is marked as
-\*(L"tainted\*(R", and may not be used, directly or indirectly, in any
-command that invokes a subshell, or in any command that modifies files,
-directories or processes.
-Any variable that is set within an expression that has previously referenced
-a tainted value also becomes tainted (even if it is logically impossible
-for the tainted value to influence the variable).
-For example:
-.nf
-
-.ne 5
- $foo = shift; # $foo is tainted
- $bar = $foo,\'bar\'; # $bar is also tainted
- $xxx = <>; # Tainted
- $path = $ENV{\'PATH\'}; # Tainted, but see below
- $abc = \'abc\'; # Not tainted
-
-.ne 4
- system "echo $foo"; # Insecure
- system "/bin/echo", $foo; # Secure (doesn't use sh)
- system "echo $bar"; # Insecure
- system "echo $abc"; # Insecure until PATH set
-
-.ne 5
- $ENV{\'PATH\'} = \'/bin:/usr/bin\';
- $ENV{\'IFS\'} = \'\' if $ENV{\'IFS\'} ne \'\';
-
- $path = $ENV{\'PATH\'}; # Not tainted
- system "echo $abc"; # Is secure now!
-
-.ne 5
- open(FOO,"$foo"); # OK
- open(FOO,">$foo"); # Not OK
-
- open(FOO,"echo $foo|"); # Not OK, but...
- open(FOO,"-|") || exec \'echo\', $foo; # OK
-
- $zzz = `echo $foo`; # Insecure, zzz tainted
-
- unlink $abc,$foo; # Insecure
- umask $foo; # Insecure
-
-.ne 3
- exec "echo $foo"; # Insecure
- exec "echo", $foo; # Secure (doesn't use sh)
- exec "sh", \'-c\', $foo; # Considered secure, alas
-
-.fi
-The taintedness is associated with each scalar value, so some elements
-of an array can be tainted, and others not.
-.PP
-If you try to do something insecure, you will get a fatal error saying
-something like \*(L"Insecure dependency\*(R" or \*(L"Insecure PATH\*(R".
-Note that you can still write an insecure system call or exec,
-but only by explicitly doing something like the last example above.
-You can also bypass the tainting mechanism by referencing
-subpatterns\*(--\c
-.I perl
-presumes that if you reference a substring using $1, $2, etc, you knew
-what you were doing when you wrote the pattern:
-.nf
-
- $ARGV[0] =~ /^\-P(\ew+)$/;
- $printer = $1; # Not tainted
-
-.fi
-This is fairly secure since \ew+ doesn't match shell metacharacters.
-Use of .+ would have been insecure, but
-.I perl
-doesn't check for that, so you must be careful with your patterns.
-This is the ONLY mechanism for untainting user supplied filenames if you
-want to do file operations on them (unless you make $> equal to $<).
-.PP
-It's also possible to get into trouble with other operations that don't care
-whether they use tainted values.
-Make judicious use of the file tests in dealing with any user-supplied
-filenames.
-When possible, do opens and such after setting $> = $<.
-.I Perl
-doesn't prevent you from opening tainted filenames for reading, so be
-careful what you print out.
-The tainting mechanism is intended to prevent stupid mistakes, not to remove
-the need for thought.
-.SH ENVIRONMENT
-.Ip HOME 12 4
-Used if chdir has no argument.
-.Ip LOGDIR 12 4
-Used if chdir has no argument and HOME is not set.
-.Ip PATH 12 4
-Used in executing subprocesses, and in finding the script if \-S
-is used.
-.Ip PERLLIB 12 4
-A colon-separated list of directories in which to look for Perl library
-files before looking in the standard library and the current directory.
-.Ip PERLDB 12 4
-The command used to get the debugger code. If unset, uses
-.br
-
- require 'perldb.pl'
-
-.PP
-Apart from these,
-.I perl
-uses no other environment variables, except to make them available
-to the script being executed, and to child processes.
-However, scripts running setuid would do well to execute the following lines
-before doing anything else, just to keep people honest:
-.nf
-
-.ne 3
- $ENV{\'PATH\'} = \'/bin:/usr/bin\'; # or whatever you need
- $ENV{\'SHELL\'} = \'/bin/sh\' if $ENV{\'SHELL\'} ne \'\';
- $ENV{\'IFS\'} = \'\' if $ENV{\'IFS\'} ne \'\';
-
-.fi
-.SH AUTHOR
-Larry Wall <lwall@netlabs.com>
-.br
-MS-DOS port by Diomidis Spinellis <dds@cc.ic.ac.uk>
-.SH FILES
-/tmp/perl\-eXXXXXX temporary file for
-.B \-e
-commands.
-.SH SEE ALSO
-a2p awk to perl translator
-.br
-s2p sed to perl translator
-.SH DIAGNOSTICS
-Compilation errors will tell you the line number of the error, with an
-indication of the next token or token type that was to be examined.
-(In the case of a script passed to
-.I perl
-via
-.B \-e
-switches, each
-.B \-e
-is counted as one line.)
-.PP
-Setuid scripts have additional constraints that can produce error messages
-such as \*(L"Insecure dependency\*(R".
-See the section on setuid scripts.
-.SH TRAPS
-Accustomed
-.IR awk
-users should take special note of the following:
-.Ip * 4 2
-Semicolons are required after all simple statements in
-.I perl
-(except at the end of a block).
-Newline is not a statement delimiter.
-.Ip * 4 2
-Curly brackets are required on ifs and whiles.
-.Ip * 4 2
-Variables begin with $ or @ in
-.IR perl .
-.Ip * 4 2
-Arrays index from 0 unless you set $[.
-Likewise string positions in substr() and index().
-.Ip * 4 2
-You have to decide whether your array has numeric or string indices.
-.Ip * 4 2
-Associative array values do not spring into existence upon mere reference.
-.Ip * 4 2
-You have to decide whether you want to use string or numeric comparisons.
-.Ip * 4 2
-Reading an input line does not split it for you. You get to split it yourself
-to an array.
-And the
-.I split
-operator has different arguments.
-.Ip * 4 2
-The current input line is normally in $_, not $0.
-It generally does not have the newline stripped.
-($0 is the name of the program executed.)
-.Ip * 4 2
-$<digit> does not refer to fields\*(--it refers to substrings matched by the last
-match pattern.
-.Ip * 4 2
-The
-.I print
-statement does not add field and record separators unless you set
-$, and $\e.
-.Ip * 4 2
-You must open your files before you print to them.
-.Ip * 4 2
-The range operator is \*(L".\|.\*(R", not comma.
-(The comma operator works as in C.)
-.Ip * 4 2
-The match operator is \*(L"=~\*(R", not \*(L"~\*(R".
-(\*(L"~\*(R" is the one's complement operator, as in C.)
-.Ip * 4 2
-The exponentiation operator is \*(L"**\*(R", not \*(L"^\*(R".
-(\*(L"^\*(R" is the XOR operator, as in C.)
-.Ip * 4 2
-The concatenation operator is \*(L".\*(R", not the null string.
-(Using the null string would render \*(L"/pat/ /pat/\*(R" unparsable,
-since the third slash would be interpreted as a division operator\*(--the
-tokener is in fact slightly context sensitive for operators like /, ?, and <.
-And in fact, . itself can be the beginning of a number.)
-.Ip * 4 2
-.IR Next ,
-.I exit
-and
-.I continue
-work differently.
-.Ip * 4 2
-The following variables work differently
-.nf
-
- Awk \h'|2.5i'Perl
- ARGC \h'|2.5i'$#ARGV
- ARGV[0] \h'|2.5i'$0
- FILENAME\h'|2.5i'$ARGV
- FNR \h'|2.5i'$. \- something
- FS \h'|2.5i'(whatever you like)
- NF \h'|2.5i'$#Fld, or some such
- NR \h'|2.5i'$.
- OFMT \h'|2.5i'$#
- OFS \h'|2.5i'$,
- ORS \h'|2.5i'$\e
- RLENGTH \h'|2.5i'length($&)
- RS \h'|2.5i'$/
- RSTART \h'|2.5i'length($\`)
- SUBSEP \h'|2.5i'$;
-
-.fi
-.Ip * 4 2
-When in doubt, run the
-.I awk
-construct through a2p and see what it gives you.
-.PP
-Cerebral C programmers should take note of the following:
-.Ip * 4 2
-Curly brackets are required on ifs and whiles.
-.Ip * 4 2
-You should use \*(L"elsif\*(R" rather than \*(L"else if\*(R"
-.Ip * 4 2
-.I Break
-and
-.I continue
-become
-.I last
-and
-.IR next ,
-respectively.
-.Ip * 4 2
-There's no switch statement.
-.Ip * 4 2
-Variables begin with $ or @ in
-.IR perl .
-.Ip * 4 2
-Printf does not implement *.
-.Ip * 4 2
-Comments begin with #, not /*.
-.Ip * 4 2
-You can't take the address of anything.
-.Ip * 4 2
-ARGV must be capitalized.
-.Ip * 4 2
-The \*(L"system\*(R" calls link, unlink, rename, etc. return nonzero for success, not 0.
-.Ip * 4 2
-Signal handlers deal with signal names, not numbers.
-.PP
-Seasoned
-.I sed
-programmers should take note of the following:
-.Ip * 4 2
-Backreferences in substitutions use $ rather than \e.
-.Ip * 4 2
-The pattern matching metacharacters (, ), and | do not have backslashes in front.
-.Ip * 4 2
-The range operator is .\|. rather than comma.
-.PP
-Sharp shell programmers should take note of the following:
-.Ip * 4 2
-The backtick operator does variable interpretation without regard to the
-presence of single quotes in the command.
-.Ip * 4 2
-The backtick operator does no translation of the return value, unlike csh.
-.Ip * 4 2
-Shells (especially csh) do several levels of substitution on each command line.
-.I Perl
-does substitution only in certain constructs such as double quotes,
-backticks, angle brackets and search patterns.
-.Ip * 4 2
-Shells interpret scripts a little bit at a time.
-.I Perl
-compiles the whole program before executing it.
-.Ip * 4 2
-The arguments are available via @ARGV, not $1, $2, etc.
-.Ip * 4 2
-The environment is not automatically made available as variables.
-.SH ERRATA\0AND\0ADDENDA
-The Perl book,
-.I Programming\0Perl ,
-has the following omissions and goofs.
-.PP
-On page 5, the examples which read
-.nf
-
- eval "/usr/bin/perl
-
-should read
-
- eval "exec /usr/bin/perl
-
-.fi
-.PP
-On page 195, the equivalent to the System V sum program only works for
-very small files. To do larger files, use
-.nf
-
- undef $/;
- $checksum = unpack("%32C*",<>) % 32767;
-
-.fi
-.PP
-The descriptions of alarm and sleep refer to signal SIGALARM. These
-should refer to SIGALRM.
-.PP
-The
-.B \-0
-switch to set the initial value of $/ was added to Perl after the book
-went to press.
-.PP
-The
-.B \-l
-switch now does automatic line ending processing.
-.PP
-The qx// construct is now a synonym for backticks.
-.PP
-$0 may now be assigned to set the argument displayed by
-.I ps (1).
-.PP
-The new @###.## format was omitted accidentally from the description
-on formats.
-.PP
-It wasn't known at press time that s///ee caused multiple evaluations of
-the replacement expression. This is to be construed as a feature.
-.PP
-(LIST) x $count now does array replication.
-.PP
-There is now no limit on the number of parentheses in a regular expression.
-.PP
-In double-quote context, more escapes are supported: \ee, \ea, \ex1b, \ec[,
-\el, \eL, \eu, \eU, \eE. The latter five control up/lower case translation.
-.PP
-The
-.B $/
-variable may now be set to a multi-character delimiter.
-.PP
-There is now a g modifier on ordinary pattern matching that causes it
-to iterate through a string finding multiple matches.
-.PP
-All of the $^X variables are new except for $^T.
-.PP
-The default top-of-form format for FILEHANDLE is now FILEHANDLE_TOP rather
-than top.
-.PP
-The eval {} and sort {} constructs were added in version 4.018.
-.PP
-The v and V (little-endian) template options for pack and unpack were
-added in 4.019.
-.SH BUGS
-.PP
-.I Perl
-is at the mercy of your machine's definitions of various operations
-such as type casting, atof() and sprintf().
-.PP
-If your stdio requires an seek or eof between reads and writes on a particular
-stream, so does
-.IR perl .
-(This doesn't apply to sysread() and syswrite().)
-.PP
-While none of the built-in data types have any arbitrary size limits (apart
-from memory size), there are still a few arbitrary limits:
-a given identifier may not be longer than 255 characters,
-and no component of your PATH may be longer than 255 if you use \-S.
-A regular expression may not compile to more than 32767 bytes internally.
-.PP
-.I Perl
-actually stands for Pathologically Eclectic Rubbish Lister, but don't tell
-anyone I said that.
-.rn }` ''
diff --git a/gnu/usr.bin/perl/perl/perl.c b/gnu/usr.bin/perl/perl/perl.c
deleted file mode 100644
index d41280b..0000000
--- a/gnu/usr.bin/perl/perl/perl.c
+++ /dev/null
@@ -1,1484 +0,0 @@
-char rcsid[] = "$RCSfile: perl.c,v $$Revision: 1.7 $$Date: 1996/06/30 09:47:56 $\nPatch level: ###\n";
-/*
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: perl.c,v $
- * Revision 1.7 1996/06/30 09:47:56 joerg
- * Back out Nate's changes from rev. 1.6; our Perl has not been
- * vulnerable since it used setreuid() as opposed to Posix saved IDs.
- * The change broke setuid scripts.
- *
- * Revision 1.5 1996/06/02 19:59:24 gpalmer
- * Use setreuid instead of seteuid for permissions management
- *
- * Revision 1.4 1995/05/30 05:03:10 rgrimes
- * Remove trailing whitespace.
- *
- * Revision 1.3 1995/05/28 19:21:54 ache
- * Fix $] variable value (version number), close PR 449
- * Submitted by: Bill Fenner <fenner@parc.xerox.com>
- *
- * Revision 1.2 1994/10/27 23:16:54 wollman
- * Convince Perl to that is is part of the system, as /usr/bin/perl (binary)
- * and /usr/share/perl (library). The latter was chosen as analogous to other
- * directories already present in /usr/share, like /usr/share/groff_font and
- * (particularly) /usr/share/mk.
- *
- * Revision 1.1.1.1 1994/09/10 06:27:33 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:37 nate
- * PERL!
- *
- * Revision 4.0.1.8 1993/02/05 19:39:30 lwall
- * patch36: the taintanyway code wasn't tainting anyway
- * patch36: Malformed cmd links core dump apparently fixed
- *
- * Revision 4.0.1.7 92/06/08 14:50:39 lwall
- * patch20: PERLLIB now supports multiple directories
- * patch20: running taintperl explicitly now does checks even if $< == $>
- * patch20: -e 'cmd' no longer fails silently if /tmp runs out of space
- * patch20: perl -P now uses location of sed determined by Configure
- * patch20: form feed for formats is now specifiable via $^L
- * patch20: paragraph mode now skips extra newlines automatically
- * patch20: eval "1 #comment" didn't work
- * patch20: couldn't require . files
- * patch20: semantic compilation errors didn't abort execution
- *
- * Revision 4.0.1.6 91/11/11 16:38:45 lwall
- * patch19: default arg for shift was wrong after first subroutine definition
- * patch19: op/regexp.t failed from missing arg to bcmp()
- *
- * Revision 4.0.1.5 91/11/05 18:03:32 lwall
- * patch11: random cleanup
- * patch11: $0 was being truncated at times
- * patch11: cppstdin now installed outside of source directory
- * patch11: -P didn't allow use of #elif or #undef
- * patch11: prepared for ctype implementations that don't define isascii()
- * patch11: added eval {}
- * patch11: eval confused by string containing null
- *
- * Revision 4.0.1.4 91/06/10 01:23:07 lwall
- * patch10: perl -v printed incorrect copyright notice
- *
- * Revision 4.0.1.3 91/06/07 11:40:18 lwall
- * patch4: changed old $^P to $^X
- *
- * Revision 4.0.1.2 91/06/07 11:26:16 lwall
- * patch4: new copyright notice
- * patch4: added $^P variable to control calling of perldb routines
- * patch4: added $^F variable to specify maximum system fd, default 2
- * patch4: debugger lost track of lines in eval
- *
- * Revision 4.0.1.1 91/04/11 17:49:05 lwall
- * patch1: fixed undefined environ problem
- *
- * Revision 4.0 91/03/20 01:37:44 lwall
- * 4.0 baseline.
- *
- */
-
-/*SUPPRESS 560*/
-
-#include "EXTERN.h"
-#include "perl.h"
-#include "perly.h"
-#include "patchlevel.h"
-
-char *getenv();
-
-#ifdef IAMSUID
-#ifndef DOSUID
-#define DOSUID
-#endif
-#endif
-
-#ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
-#ifdef DOSUID
-#undef DOSUID
-#endif
-#endif
-
-static char* moreswitches();
-static void incpush();
-static char* cddir;
-static bool minus_c;
-static char patchlevel[6];
-static char *nrs = "\n";
-static int nrschar = '\n'; /* final char of rs, or 0777 if none */
-static int nrslen = 1;
-
-main(argc,argv,env)
-register int argc;
-register char **argv;
-register char **env;
-{
- register STR *str;
- register char *s;
- char *scriptname;
- char *getenv();
- bool dosearch = FALSE;
-#ifdef DOSUID
- char *validarg = "";
-#endif
-
-#ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
-#ifdef IAMSUID
-#undef IAMSUID
- fatal("suidperl is no longer needed since the kernel can now execute\n\
-setuid perl scripts securely.\n");
-#endif
-#endif
-
- origargv = argv;
- origargc = argc;
- origenviron = environ;
- uid = (int)getuid();
- euid = (int)geteuid();
- gid = (int)getgid();
- egid = (int)getegid();
- sprintf(patchlevel,"%3.3s%2.2d", "4.0", PATCHLEVEL);
-#ifdef MSDOS
- /*
- * There is no way we can refer to them from Perl so close them to save
- * space. The other alternative would be to provide STDAUX and STDPRN
- * filehandles.
- */
- (void)fclose(stdaux);
- (void)fclose(stdprn);
-#endif
- if (do_undump) {
- origfilename = savestr(argv[0]);
- do_undump = 0;
- loop_ptr = -1; /* start label stack again */
- goto just_doit;
- }
-#ifdef TAINT
-#ifndef DOSUID
- if (uid == euid && gid == egid)
- taintanyway = TRUE; /* running taintperl explicitly */
-#endif
-#endif
- (void)sprintf(index(rcsid,'#'), "%d\n", PATCHLEVEL);
- linestr = Str_new(65,80);
- str_nset(linestr,"",0);
- str = str_make("",0); /* first used for -I flags */
- curstash = defstash = hnew(0);
- curstname = str_make("main",4);
- stab_xhash(stabent("_main",TRUE)) = defstash;
- defstash->tbl_name = "main";
- incstab = hadd(aadd(stabent("INC",TRUE)));
- incstab->str_pok |= SP_MULTI;
- for (argc--,argv++; argc > 0; argc--,argv++) {
- if (argv[0][0] != '-' || !argv[0][1])
- break;
-#ifdef DOSUID
- if (*validarg)
- validarg = " PHOOEY ";
- else
- validarg = argv[0];
-#endif
- s = argv[0]+1;
- reswitch:
- switch (*s) {
- case '0':
- case 'a':
- case 'c':
- case 'd':
- case 'D':
- case 'i':
- case 'l':
- case 'n':
- case 'p':
- case 'u':
- case 'U':
- case 'v':
- case 'w':
- if (s = moreswitches(s))
- goto reswitch;
- break;
-
- case 'e':
-#ifdef TAINT
- if (euid != uid || egid != gid)
- fatal("No -e allowed in setuid scripts");
-#endif
- if (!e_fp) {
- e_tmpname = savestr(TMPPATH);
- (void)mktemp(e_tmpname);
- if (!*e_tmpname)
- fatal("Can't mktemp()");
- e_fp = fopen(e_tmpname,"w");
- if (!e_fp)
- fatal("Cannot open temporary file");
- }
- if (argv[1]) {
- fputs(argv[1],e_fp);
- argc--,argv++;
- }
- (void)putc('\n', e_fp);
- break;
- case 'I':
-#ifdef TAINT
- if (euid != uid || egid != gid)
- fatal("No -I allowed in setuid scripts");
-#endif
- str_cat(str,"-");
- str_cat(str,s);
- str_cat(str," ");
- if (*++s) {
- (void)apush(stab_array(incstab),str_make(s,0));
- }
- else if (argv[1]) {
- (void)apush(stab_array(incstab),str_make(argv[1],0));
- str_cat(str,argv[1]);
- argc--,argv++;
- str_cat(str," ");
- }
- break;
- case 'P':
-#ifdef TAINT
- if (euid != uid || egid != gid)
- fatal("No -P allowed in setuid scripts");
-#endif
- preprocess = TRUE;
- s++;
- goto reswitch;
- case 's':
-#ifdef TAINT
- if (euid != uid || egid != gid)
- fatal("No -s allowed in setuid scripts");
-#endif
- doswitches = TRUE;
- s++;
- goto reswitch;
- case 'S':
-#ifdef TAINT
- if (euid != uid || egid != gid)
- fatal("No -S allowed in setuid scripts");
-#endif
- dosearch = TRUE;
- s++;
- goto reswitch;
- case 'x':
- doextract = TRUE;
- s++;
- if (*s)
- cddir = savestr(s);
- break;
- case '-':
- argc--,argv++;
- goto switch_end;
- case 0:
- break;
- default:
- fatal("Unrecognized switch: -%s",s);
- }
- }
- switch_end:
- scriptname = argv[0];
- if (e_fp) {
- if (fflush(e_fp) || ferror(e_fp) || fclose(e_fp))
- fatal("Can't write to temp file for -e: %s", strerror(errno));
- argc++,argv--;
- scriptname = e_tmpname;
- }
-
-#ifdef DOSISH
-#define PERLLIB_SEP ';'
-#else
-#define PERLLIB_SEP ':'
-#endif
-#ifndef TAINT /* Can't allow arbitrary PERLLIB in setuid script */
- incpush(getenv("PERLLIB"));
-#endif /* TAINT */
-
-#ifndef PRIVLIB
-#define PRIVLIB "/usr/share/perl"
-#endif
- incpush(PRIVLIB);
- (void)apush(stab_array(incstab),str_make(".",1));
-
- str_set(&str_no,No);
- str_set(&str_yes,Yes);
-
- /* open script */
-
- if (scriptname == Nullch)
-#ifdef MSDOS
- {
- if ( isatty(fileno(stdin)) )
- moreswitches("v");
- scriptname = "-";
- }
-#else
- scriptname = "-";
-#endif
- if (dosearch && !index(scriptname, '/') && (s = getenv("PATH"))) {
- char *xfound = Nullch, *xfailed = Nullch;
- int len;
-
- bufend = s + strlen(s);
- while (*s) {
-#ifndef DOSISH
- s = cpytill(tokenbuf,s,bufend,':',&len);
-#else
-#ifdef atarist
- for (len = 0; *s && *s != ',' && *s != ';'; tokenbuf[len++] = *s++);
- tokenbuf[len] = '\0';
-#else
- for (len = 0; *s && *s != ';'; tokenbuf[len++] = *s++);
- tokenbuf[len] = '\0';
-#endif
-#endif
- if (*s)
- s++;
-#ifndef DOSISH
- if (len && tokenbuf[len-1] != '/')
-#else
-#ifdef atarist
- if (len && ((tokenbuf[len-1] != '\\') && (tokenbuf[len-1] != '/')))
-#else
- if (len && tokenbuf[len-1] != '\\')
-#endif
-#endif
- (void)strcat(tokenbuf+len,"/");
- (void)strcat(tokenbuf+len,scriptname);
-#ifdef DEBUGGING
- if (debug & 1)
- fprintf(stderr,"Looking for %s\n",tokenbuf);
-#endif
- if (stat(tokenbuf,&statbuf) < 0) /* not there? */
- continue;
- if (S_ISREG(statbuf.st_mode)
- && cando(S_IRUSR,TRUE,&statbuf) && cando(S_IXUSR,TRUE,&statbuf)) {
- xfound = tokenbuf; /* bingo! */
- break;
- }
- if (!xfailed)
- xfailed = savestr(tokenbuf);
- }
- if (!xfound)
- fatal("Can't execute %s", xfailed ? xfailed : scriptname );
- if (xfailed)
- Safefree(xfailed);
- scriptname = savestr(xfound);
- }
-
- fdpid = anew(Nullstab); /* for remembering popen pids by fd */
- pidstatus = hnew(COEFFSIZE);/* for remembering status of dead pids */
-
- origfilename = savestr(scriptname);
- curcmd->c_filestab = fstab(origfilename);
- if (strEQ(origfilename,"-"))
- scriptname = "";
- if (preprocess) {
- char *cpp = CPPSTDIN;
-
- if (strEQ(cpp,"cppstdin"))
- sprintf(tokenbuf, "%s/%s", SCRIPTDIR, cpp);
- else
- sprintf(tokenbuf, "%s", cpp);
- str_cat(str,"-I");
- str_cat(str,PRIVLIB);
-#ifdef MSDOS
- (void)sprintf(buf, "\
-sed %s -e \"/^[^#]/b\" \
- -e \"/^#[ ]*include[ ]/b\" \
- -e \"/^#[ ]*define[ ]/b\" \
- -e \"/^#[ ]*if[ ]/b\" \
- -e \"/^#[ ]*ifdef[ ]/b\" \
- -e \"/^#[ ]*ifndef[ ]/b\" \
- -e \"/^#[ ]*else/b\" \
- -e \"/^#[ ]*elif[ ]/b\" \
- -e \"/^#[ ]*undef[ ]/b\" \
- -e \"/^#[ ]*endif/b\" \
- -e \"s/^#.*//\" \
- %s | %s -C %s %s",
- (doextract ? "-e \"1,/^#/d\n\"" : ""),
-#else
- (void)sprintf(buf, "\
-%s %s -e '/^[^#]/b' \
- -e '/^#[ ]*include[ ]/b' \
- -e '/^#[ ]*define[ ]/b' \
- -e '/^#[ ]*if[ ]/b' \
- -e '/^#[ ]*ifdef[ ]/b' \
- -e '/^#[ ]*ifndef[ ]/b' \
- -e '/^#[ ]*else/b' \
- -e '/^#[ ]*elif[ ]/b' \
- -e '/^#[ ]*undef[ ]/b' \
- -e '/^#[ ]*endif/b' \
- -e 's/^[ ]*#.*//' \
- %s | %s -C %s %s",
-#ifdef LOC_SED
- LOC_SED,
-#else
- "sed",
-#endif
- (doextract ? "-e '1,/^#/d\n'" : ""),
-#endif
- scriptname, tokenbuf, str_get(str), CPPMINUS);
-#ifdef DEBUGGING
- if (debug & 64) {
- fputs(buf,stderr);
- fputs("\n",stderr);
- }
-#endif
- doextract = FALSE;
-#ifdef IAMSUID /* actually, this is caught earlier */
- if (euid != uid && !euid) { /* if running suidperl */
-#ifdef HAS_SETEUID
- (void)seteuid(uid); /* musn't stay setuid root */
-#else
-#ifdef HAS_SETREUID
- (void)setreuid(-1, uid);
-#else
- setuid(uid);
-#endif
-#endif
- if (geteuid() != uid)
- fatal("Can't do seteuid!\n");
- }
-#endif /* IAMSUID */
- rsfp = mypopen(buf,"r");
- }
- else if (!*scriptname) {
-#ifdef TAINT
- if (euid != uid || egid != gid)
- fatal("Can't take set-id script from stdin");
-#endif
- rsfp = stdin;
- }
- else
- rsfp = fopen(scriptname,"r");
- if ((FILE*)rsfp == Nullfp) {
-#ifdef DOSUID
-#ifndef IAMSUID /* in case script is not readable before setuid */
- if (euid && stat(stab_val(curcmd->c_filestab)->str_ptr,&statbuf) >= 0 &&
- statbuf.st_mode & (S_ISUID|S_ISGID)) {
- (void)sprintf(buf, "%s/sperl%s", BIN, patchlevel);
- execv(buf, origargv); /* try again */
- fatal("Can't do setuid\n");
- }
-#endif
-#endif
- fatal("Can't open perl script \"%s\": %s\n",
- stab_val(curcmd->c_filestab)->str_ptr, strerror(errno));
- }
- str_free(str); /* free -I directories */
- str = Nullstr;
-
- /* do we need to emulate setuid on scripts? */
-
- /* This code is for those BSD systems that have setuid #! scripts disabled
- * in the kernel because of a security problem. Merely defining DOSUID
- * in perl will not fix that problem, but if you have disabled setuid
- * scripts in the kernel, this will attempt to emulate setuid and setgid
- * on scripts that have those now-otherwise-useless bits set. The setuid
- * root version must be called suidperl or sperlN.NNN. If regular perl
- * discovers that it has opened a setuid script, it calls suidperl with
- * the same argv that it had. If suidperl finds that the script it has
- * just opened is NOT setuid root, it sets the effective uid back to the
- * uid. We don't just make perl setuid root because that loses the
- * effective uid we had before invoking perl, if it was different from the
- * uid.
- *
- * DOSUID must be defined in both perl and suidperl, and IAMSUID must
- * be defined in suidperl only. suidperl must be setuid root. The
- * Configure script will set this up for you if you want it.
- *
- * There is also the possibility of have a script which is running
- * set-id due to a C wrapper. We want to do the TAINT checks
- * on these set-id scripts, but don't want to have the overhead of
- * them in normal perl, and can't use suidperl because it will lose
- * the effective uid info, so we have an additional non-setuid root
- * version called taintperl or tperlN.NNN that just does the TAINT checks.
- */
-
-#ifdef DOSUID
- if (fstat(fileno(rsfp),&statbuf) < 0) /* normal stat is insecure */
- fatal("Can't stat script \"%s\"",origfilename);
-#ifdef IAMSUID
- {
- struct statfs stfs;
-
- if (fstatfs(fileno(rsfp),&stfs) < 0)
- fatal("Can't statfs filesystem of script \"%s\"",origfilename);
-
- if (stfs.f_flags & MNT_NOSUID)
- fatal("Permission denied");
- }
-#endif /* IAMSUID */
- if (statbuf.st_mode & (S_ISUID|S_ISGID)) {
- int len;
-
-#ifdef IAMSUID
-#ifndef HAS_SETREUID
- /* On this access check to make sure the directories are readable,
- * there is actually a small window that the user could use to make
- * filename point to an accessible directory. So there is a faint
- * chance that someone could execute a setuid script down in a
- * non-accessible directory. I don't know what to do about that.
- * But I don't think it's too important. The manual lies when
- * it says access() is useful in setuid programs.
- */
- if (access(stab_val(curcmd->c_filestab)->str_ptr,1)) /*double check*/
- fatal("Permission denied");
-#else
- /* If we can swap euid and uid, then we can determine access rights
- * with a simple stat of the file, and then compare device and
- * inode to make sure we did stat() on the same file we opened.
- * Then we just have to make sure he or she can execute it.
- */
- {
- struct stat tmpstatbuf;
-
- if (setreuid(euid,uid) < 0 || getuid() != euid || geteuid() != uid)
- fatal("Can't swap uid and euid"); /* really paranoid */
- if (stat(stab_val(curcmd->c_filestab)->str_ptr,&tmpstatbuf) < 0)
- fatal("Permission denied"); /* testing full pathname here */
- if (tmpstatbuf.st_dev != statbuf.st_dev ||
- tmpstatbuf.st_ino != statbuf.st_ino) {
- (void)fclose(rsfp);
- if (rsfp = mypopen("/bin/mail root","w")) { /* heh, heh */
- fprintf(rsfp,
-"User %d tried to run dev %d ino %d in place of dev %d ino %d!\n\
-(Filename of set-id script was %s, uid %d gid %d.)\n\nSincerely,\nperl\n",
- uid,tmpstatbuf.st_dev, tmpstatbuf.st_ino,
- statbuf.st_dev, statbuf.st_ino,
- stab_val(curcmd->c_filestab)->str_ptr,
- statbuf.st_uid, statbuf.st_gid);
- (void)mypclose(rsfp);
- }
- fatal("Permission denied\n");
- }
- if (setreuid(uid,euid) < 0 || getuid() != uid || geteuid() != euid)
- fatal("Can't reswap uid and euid");
- if (!cando(S_IXUSR,FALSE,&statbuf)) /* can real uid exec? */
- fatal("Permission denied\n");
- }
-#endif /* HAS_SETREUID */
-#endif /* IAMSUID */
-
- if (!S_ISREG(statbuf.st_mode))
- fatal("Permission denied");
- if (statbuf.st_mode & S_IWOTH)
- fatal("Setuid/gid script is writable by world");
- doswitches = FALSE; /* -s is insecure in suid */
- curcmd->c_line++;
- if (fgets(tokenbuf,sizeof tokenbuf, rsfp) == Nullch ||
- strnNE(tokenbuf,"#!",2) ) /* required even on Sys V */
- fatal("No #! line");
- s = tokenbuf+2;
- if (*s == ' ') s++;
- while (!isSPACE(*s)) s++;
- if (strnNE(s-4,"perl",4) && strnNE(s-9,"perl",4)) /* sanity check */
- fatal("Not a perl script");
- while (*s == ' ' || *s == '\t') s++;
- /*
- * #! arg must be what we saw above. They can invoke it by
- * mentioning suidperl explicitly, but they may not add any strange
- * arguments beyond what #! says if they do invoke suidperl that way.
- */
- len = strlen(validarg);
- if (strEQ(validarg," PHOOEY ") ||
- strnNE(s,validarg,len) || !isSPACE(s[len]))
- fatal("Args must match #! line");
-
-#ifndef IAMSUID
- if (euid != uid && (statbuf.st_mode & S_ISUID) &&
- euid == statbuf.st_uid)
- if (!do_undump)
- fatal("YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET!\n\
-FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
-#endif /* IAMSUID */
-
- if (euid) { /* oops, we're not the setuid root perl */
- (void)fclose(rsfp);
-#ifndef IAMSUID
- (void)sprintf(buf, "%s/sperl%s", BIN, patchlevel);
- execv(buf, origargv); /* try again */
-#endif
- fatal("Can't do setuid\n");
- }
-
- if (statbuf.st_mode & S_ISGID && statbuf.st_gid != egid) {
-#ifdef HAS_SETEGID
- (void)setegid(statbuf.st_gid);
-#else
-#ifdef HAS_SETREGID
- (void)setregid((GIDTYPE)gid,statbuf.st_gid);
-#else
- setgid(statbuf.st_gid);
-#endif
-#endif
- if (getegid() != statbuf.st_gid)
- fatal("Can't do setegid!\n");
- }
- if (statbuf.st_mode & S_ISUID) {
- if (statbuf.st_uid != euid)
-#ifdef HAS_SETEUID
- (void)seteuid(statbuf.st_uid); /* all that for this */
-#else
-#ifdef HAS_SETREUID
- (void)setreuid((UIDTYPE)uid,statbuf.st_uid);
-#else
- setuid(statbuf.st_uid);
-#endif
-#endif
- if (geteuid() != statbuf.st_uid)
- fatal("Can't do seteuid!\n");
- }
- else if (uid) { /* oops, mustn't run as root */
-#ifdef HAS_SETEUID
- (void)seteuid((UIDTYPE)uid);
-#else
-#ifdef HAS_SETREUID
- (void)setreuid((UIDTYPE)uid,(UIDTYPE)uid);
-#else
- setuid((UIDTYPE)uid);
-#endif
-#endif
- if (geteuid() != uid)
- fatal("Can't do seteuid!\n");
- }
- uid = (int)getuid();
- euid = (int)geteuid();
- gid = (int)getgid();
- egid = (int)getegid();
- if (!cando(S_IXUSR,TRUE,&statbuf))
- fatal("Permission denied\n"); /* they can't do this */
- }
-#ifdef IAMSUID
- else if (preprocess)
- fatal("-P not allowed for setuid/setgid script\n");
- else
- fatal("Script is not setuid/setgid in suidperl\n");
-#else
-#ifndef TAINT /* we aren't taintperl or suidperl */
- /* script has a wrapper--can't run suidperl or we lose euid */
- else if (euid != uid || egid != gid) {
- (void)fclose(rsfp);
- (void)sprintf(buf, "%s/tperl%s", BIN, patchlevel);
- execv(buf, origargv); /* try again */
- fatal("Can't run setuid script with taint checks");
- }
-#endif /* TAINT */
-#endif /* IAMSUID */
-#else /* !DOSUID */
-#ifndef TAINT /* we aren't taintperl or suidperl */
- if (euid != uid || egid != gid) { /* (suidperl doesn't exist, in fact) */
-#ifndef SETUID_SCRIPTS_ARE_SECURE_NOW
- fstat(fileno(rsfp),&statbuf); /* may be either wrapped or real suid */
- if ((euid != uid && euid == statbuf.st_uid && statbuf.st_mode & S_ISUID)
- ||
- (egid != gid && egid == statbuf.st_gid && statbuf.st_mode & S_ISGID)
- )
- if (!do_undump)
- fatal("YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET!\n\
-FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
-#endif /* SETUID_SCRIPTS_ARE_SECURE_NOW */
- /* not set-id, must be wrapped */
- (void)fclose(rsfp);
- (void)sprintf(buf, "%s/tperl%s", BIN, patchlevel);
- execv(buf, origargv); /* try again */
- fatal("Can't run setuid script with taint checks");
- }
-#endif /* TAINT */
-#endif /* DOSUID */
-
-#if !defined(IAMSUID) && !defined(TAINT)
-
- /* skip forward in input to the real script? */
-
- while (doextract) {
- if ((s = str_gets(linestr, rsfp, 0)) == Nullch)
- fatal("No Perl script found in input\n");
- if (*s == '#' && s[1] == '!' && instr(s,"perl")) {
- ungetc('\n',rsfp); /* to keep line count right */
- doextract = FALSE;
- if (s = instr(s,"perl -")) {
- s += 6;
- /*SUPPRESS 530*/
- while (s = moreswitches(s)) ;
- }
- if (cddir && chdir(cddir) < 0)
- fatal("Can't chdir to %s",cddir);
- }
- }
-#endif /* !defined(IAMSUID) && !defined(TAINT) */
-
- defstab = stabent("_",TRUE);
-
- subname = str_make("main",4);
- if (perldb) {
- debstash = hnew(0);
- stab_xhash(stabent("_DB",TRUE)) = debstash;
- curstash = debstash;
- dbargs = stab_xarray(aadd((tmpstab = stabent("args",TRUE))));
- tmpstab->str_pok |= SP_MULTI;
- dbargs->ary_flags = 0;
- DBstab = stabent("DB",TRUE);
- DBstab->str_pok |= SP_MULTI;
- DBline = stabent("dbline",TRUE);
- DBline->str_pok |= SP_MULTI;
- DBsub = hadd(tmpstab = stabent("sub",TRUE));
- tmpstab->str_pok |= SP_MULTI;
- DBsingle = stab_val((tmpstab = stabent("single",TRUE)));
- tmpstab->str_pok |= SP_MULTI;
- DBtrace = stab_val((tmpstab = stabent("trace",TRUE)));
- tmpstab->str_pok |= SP_MULTI;
- DBsignal = stab_val((tmpstab = stabent("signal",TRUE)));
- tmpstab->str_pok |= SP_MULTI;
- curstash = defstash;
- }
-
- /* init tokener */
-
- bufend = bufptr = str_get(linestr);
-
- savestack = anew(Nullstab); /* for saving non-local values */
- stack = anew(Nullstab); /* for saving non-local values */
- stack->ary_flags = 0; /* not a real array */
- afill(stack,63); afill(stack,-1); /* preextend stack */
- afill(savestack,63); afill(savestack,-1);
-
- /* now parse the script */
-
- error_count = 0;
- if (yyparse() || error_count) {
- if (minus_c)
- fatal("%s had compilation errors.\n", origfilename);
- else {
- fatal("Execution of %s aborted due to compilation errors.\n",
- origfilename);
- }
- }
-
- New(50,loop_stack,128,struct loop);
-#ifdef DEBUGGING
- if (debug) {
- New(51,debname,128,char);
- New(52,debdelim,128,char);
- }
-#endif
- curstash = defstash;
-
- preprocess = FALSE;
- if (e_fp) {
- e_fp = Nullfp;
- (void)UNLINK(e_tmpname);
- }
-
- /* initialize everything that won't change if we undump */
-
- if (sigstab = stabent("SIG",allstabs)) {
- sigstab->str_pok |= SP_MULTI;
- (void)hadd(sigstab);
- }
-
- magicalize("!#?^~=-%.+&*()<>,\\/[|`':\004\t\020\024\027\006");
- userinit(); /* in case linked C routines want magical variables */
-
- amperstab = stabent("&",allstabs);
- leftstab = stabent("`",allstabs);
- rightstab = stabent("'",allstabs);
- sawampersand = (amperstab || leftstab || rightstab);
- if (tmpstab = stabent(":",allstabs))
- str_set(stab_val(tmpstab),chopset);
- if (tmpstab = stabent("\024",allstabs))
- time(&basetime);
-
- /* these aren't necessarily magical */
- if (tmpstab = stabent("\014",allstabs)) {
- str_set(stab_val(tmpstab),"\f");
- formfeed = stab_val(tmpstab);
- }
- if (tmpstab = stabent(";",allstabs))
- str_set(STAB_STR(tmpstab),"\034");
- if (tmpstab = stabent("]",allstabs)) {
- str = STAB_STR(tmpstab);
- str_set(str,rcsid);
- str->str_u.str_nval = atof(patchlevel);
- str->str_nok = 1;
- }
- str_nset(stab_val(stabent("\"", TRUE)), " ", 1);
-
- stdinstab = stabent("STDIN",TRUE);
- stdinstab->str_pok |= SP_MULTI;
- if (!stab_io(stdinstab))
- stab_io(stdinstab) = stio_new();
- stab_io(stdinstab)->ifp = stdin;
- tmpstab = stabent("stdin",TRUE);
- stab_io(tmpstab) = stab_io(stdinstab);
- tmpstab->str_pok |= SP_MULTI;
-
- tmpstab = stabent("STDOUT",TRUE);
- tmpstab->str_pok |= SP_MULTI;
- if (!stab_io(tmpstab))
- stab_io(tmpstab) = stio_new();
- stab_io(tmpstab)->ofp = stab_io(tmpstab)->ifp = stdout;
- defoutstab = tmpstab;
- tmpstab = stabent("stdout",TRUE);
- stab_io(tmpstab) = stab_io(defoutstab);
- tmpstab->str_pok |= SP_MULTI;
-
- curoutstab = stabent("STDERR",TRUE);
- curoutstab->str_pok |= SP_MULTI;
- if (!stab_io(curoutstab))
- stab_io(curoutstab) = stio_new();
- stab_io(curoutstab)->ofp = stab_io(curoutstab)->ifp = stderr;
- tmpstab = stabent("stderr",TRUE);
- stab_io(tmpstab) = stab_io(curoutstab);
- tmpstab->str_pok |= SP_MULTI;
- curoutstab = defoutstab; /* switch back to STDOUT */
-
- statname = Str_new(66,0); /* last filename we did stat on */
-
- /* now that script is parsed, we can modify record separator */
-
- rs = nrs;
- rslen = nrslen;
- rschar = nrschar;
- rspara = (nrslen == 2);
- str_nset(stab_val(stabent("/", TRUE)), rs, rslen);
-
- if (do_undump)
- my_unexec();
-
- just_doit: /* come here if running an undumped a.out */
- argc--,argv++; /* skip name of script */
- if (doswitches) {
- for (; argc > 0 && **argv == '-'; argc--,argv++) {
- if (argv[0][1] == '-') {
- argc--,argv++;
- break;
- }
- if (s = index(argv[0], '=')) {
- *s++ = '\0';
- str_set(stab_val(stabent(argv[0]+1,TRUE)),s);
- }
- else
- str_numset(stab_val(stabent(argv[0]+1,TRUE)),(double)1.0);
- }
- }
-#ifdef TAINT
- tainted = 1;
-#endif
- if (tmpstab = stabent("0",allstabs)) {
- str_set(stab_val(tmpstab),origfilename);
- magicname("0", Nullch, 0);
- }
- if (tmpstab = stabent("\030",allstabs))
- str_set(stab_val(tmpstab),origargv[0]);
- if (argvstab = stabent("ARGV",allstabs)) {
- argvstab->str_pok |= SP_MULTI;
- (void)aadd(argvstab);
- aclear(stab_array(argvstab));
- for (; argc > 0; argc--,argv++) {
- (void)apush(stab_array(argvstab),str_make(argv[0],0));
- }
- }
-#ifdef TAINT
- (void) stabent("ENV",TRUE); /* must test PATH and IFS */
-#endif
- if (envstab = stabent("ENV",allstabs)) {
- envstab->str_pok |= SP_MULTI;
- (void)hadd(envstab);
- hclear(stab_hash(envstab), FALSE);
- if (env != environ)
- environ[0] = Nullch;
- for (; *env; env++) {
- if (!(s = index(*env,'=')))
- continue;
- *s++ = '\0';
- str = str_make(s--,0);
- str_magic(str, envstab, 'E', *env, s - *env);
- (void)hstore(stab_hash(envstab), *env, s - *env, str, 0);
- *s = '=';
- }
- }
-#ifdef TAINT
- tainted = 0;
-#endif
- if (tmpstab = stabent("$",allstabs))
- str_numset(STAB_STR(tmpstab),(double)getpid());
-
- if (dowarn) {
- stab_check('A','Z');
- stab_check('a','z');
- }
-
- if (setjmp(top_env)) /* sets goto_targ on longjump */
- loop_ptr = -1; /* start label stack again */
-
-#ifdef DEBUGGING
- if (debug & 1024)
- dump_all();
- if (debug)
- fprintf(stderr,"\nEXECUTING...\n\n");
-#endif
-
- if (minus_c) {
- fprintf(stderr,"%s syntax OK\n", origfilename);
- exit(0);
- }
-
- /* do it */
-
- (void) cmd_exec(main_root,G_SCALAR,-1);
-
- if (goto_targ)
- fatal("Can't find label \"%s\"--aborting",goto_targ);
- exit(0);
- /* NOTREACHED */
-}
-
-void
-magicalize(list)
-register char *list;
-{
- char sym[2];
-
- sym[1] = '\0';
- while (*sym = *list++)
- magicname(sym, Nullch, 0);
-}
-
-void
-magicname(sym,name,namlen)
-char *sym;
-char *name;
-int namlen;
-{
- register STAB *stab;
-
- if (stab = stabent(sym,allstabs)) {
- stab_flags(stab) = SF_VMAGIC;
- str_magic(stab_val(stab), stab, 0, name, namlen);
- }
-}
-
-static void
-incpush(p)
-char *p;
-{
- char *s;
-
- if (!p)
- return;
-
- /* Break at all separators */
- while (*p) {
- /* First, skip any consecutive separators */
- while ( *p == PERLLIB_SEP ) {
- /* Uncomment the next line for PATH semantics */
- /* (void)apush(stab_array(incstab), str_make(".", 1)); */
- p++;
- }
- if ( (s = index(p, PERLLIB_SEP)) != Nullch ) {
- (void)apush(stab_array(incstab), str_make(p, (int)(s - p)));
- p = s + 1;
- } else {
- (void)apush(stab_array(incstab), str_make(p, 0));
- break;
- }
- }
-}
-
-void
-savelines(array, str)
-ARRAY *array;
-STR *str;
-{
- register char *s = str->str_ptr;
- register char *send = str->str_ptr + str->str_cur;
- register char *t;
- register int line = 1;
-
- while (s && s < send) {
- STR *tmpstr = Str_new(85,0);
-
- t = index(s, '\n');
- if (t)
- t++;
- else
- t = send;
-
- str_nset(tmpstr, s, t - s);
- astore(array, line++, tmpstr);
- s = t;
- }
-}
-
-/* this routine is in perl.c by virtue of being sort of an alternate main() */
-
-int
-do_eval(str,optype,stash,savecmd,gimme,arglast)
-STR *str;
-int optype;
-HASH *stash;
-int savecmd;
-int gimme;
-int *arglast;
-{
- STR **st = stack->ary_array;
- int retval;
- CMD *myroot = Nullcmd;
- ARRAY *ar;
- int i;
- CMD * VOLATILE oldcurcmd = curcmd;
- VOLATILE int oldtmps_base = tmps_base;
- VOLATILE int oldsave = savestack->ary_fill;
- VOLATILE int oldperldb = perldb;
- SPAT * VOLATILE oldspat = curspat;
- SPAT * VOLATILE oldlspat = lastspat;
- static char *last_eval = Nullch;
- static long last_elen = 0;
- static CMD *last_root = Nullcmd;
- VOLATILE int sp = arglast[0];
- char *specfilename;
- char *tmpfilename;
- int parsing = 1;
-
- tmps_base = tmps_max;
- if (curstash != stash) {
- (void)savehptr(&curstash);
- curstash = stash;
- }
- str_set(stab_val(stabent("@",TRUE)),"");
- if (curcmd->c_line == 0) /* don't debug debugger... */
- perldb = FALSE;
- curcmd = &compiling;
- if (optype == O_EVAL) { /* normal eval */
- curcmd->c_filestab = fstab("(eval)");
- curcmd->c_line = 1;
- str_sset(linestr,str);
- str_cat(linestr,";\n;\n"); /* be kind to them */
- if (perldb)
- savelines(stab_xarray(curcmd->c_filestab), linestr);
- }
- else {
- if (last_root && !in_eval) {
- Safefree(last_eval);
- last_eval = Nullch;
- cmd_free(last_root);
- last_root = Nullcmd;
- }
- specfilename = str_get(str);
- str_set(linestr,"");
- if (optype == O_REQUIRE && &str_undef !=
- hfetch(stab_hash(incstab), specfilename, strlen(specfilename), 0)) {
- curcmd = oldcurcmd;
- tmps_base = oldtmps_base;
- st[++sp] = &str_yes;
- perldb = oldperldb;
- return sp;
- }
- tmpfilename = savestr(specfilename);
- if (*tmpfilename == '/' ||
- (*tmpfilename == '.' &&
- (tmpfilename[1] == '/' ||
- (tmpfilename[1] == '.' && tmpfilename[2] == '/'))))
- {
- rsfp = fopen(tmpfilename,"r");
- }
- else {
- ar = stab_array(incstab);
- for (i = 0; i <= ar->ary_fill; i++) {
- (void)sprintf(buf, "%s/%s",
- str_get(afetch(ar,i,TRUE)), specfilename);
- rsfp = fopen(buf,"r");
- if (rsfp) {
- char *s = buf;
-
- if (*s == '.' && s[1] == '/')
- s += 2;
- Safefree(tmpfilename);
- tmpfilename = savestr(s);
- break;
- }
- }
- }
- curcmd->c_filestab = fstab(tmpfilename);
- Safefree(tmpfilename);
- tmpfilename = Nullch;
- if (!rsfp) {
- curcmd = oldcurcmd;
- tmps_base = oldtmps_base;
- if (optype == O_REQUIRE) {
- sprintf(tokenbuf,"Can't locate %s in @INC", specfilename);
- if (instr(tokenbuf,".h "))
- strcat(tokenbuf," (change .h to .ph maybe?)");
- if (instr(tokenbuf,".ph "))
- strcat(tokenbuf," (did you run h2ph?)");
- fatal("%s",tokenbuf);
- }
- if (gimme != G_ARRAY)
- st[++sp] = &str_undef;
- perldb = oldperldb;
- return sp;
- }
- curcmd->c_line = 0;
- }
- in_eval++;
- oldoldbufptr = oldbufptr = bufptr = str_get(linestr);
- bufend = bufptr + linestr->str_cur;
- if (++loop_ptr >= loop_max) {
- loop_max += 128;
- Renew(loop_stack, loop_max, struct loop);
- }
- loop_stack[loop_ptr].loop_label = "_EVAL_";
- loop_stack[loop_ptr].loop_sp = sp;
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Pushing label #%d _EVAL_)\n", loop_ptr);
- }
-#endif
- eval_root = Nullcmd;
- if (setjmp(loop_stack[loop_ptr].loop_env)) {
- retval = 1;
- }
- else {
- error_count = 0;
- if (rsfp) {
- retval = yyparse();
- retval |= error_count;
- }
- else if (last_root && last_elen == bufend - bufptr
- && *bufptr == *last_eval && !bcmp(bufptr,last_eval,last_elen)){
- retval = 0;
- eval_root = last_root; /* no point in reparsing */
- }
- else if (in_eval == 1 && !savecmd) {
- if (last_root) {
- Safefree(last_eval);
- last_eval = Nullch;
- cmd_free(last_root);
- }
- last_root = Nullcmd;
- last_elen = bufend - bufptr;
- last_eval = nsavestr(bufptr, last_elen);
- retval = yyparse();
- retval |= error_count;
- if (!retval)
- last_root = eval_root;
- if (!last_root) {
- Safefree(last_eval);
- last_eval = Nullch;
- }
- }
- else
- retval = yyparse();
- }
- myroot = eval_root; /* in case cmd_exec does another eval! */
-
- if (retval || error_count) {
- st = stack->ary_array;
- sp = arglast[0];
- if (gimme != G_ARRAY)
- st[++sp] = &str_undef;
- if (parsing) {
-#ifndef MANGLEDPARSE
-#ifdef DEBUGGING
- if (debug & 128)
- fprintf(stderr,"Freeing eval_root %lx\n",(long)eval_root);
-#endif
- cmd_free(eval_root);
-#endif
- /*SUPPRESS 29*/ /*SUPPRESS 30*/
- if ((CMD*)eval_root == last_root)
- last_root = Nullcmd;
- eval_root = myroot = Nullcmd;
- }
- if (rsfp) {
- fclose(rsfp);
- rsfp = 0;
- }
- }
- else {
- parsing = 0;
- sp = cmd_exec(eval_root,gimme,sp);
- st = stack->ary_array;
- for (i = arglast[0] + 1; i <= sp; i++)
- st[i] = str_mortal(st[i]);
- /* if we don't save result, free zaps it */
- if (savecmd)
- eval_root = myroot;
- else if (in_eval != 1 && myroot != last_root)
- cmd_free(myroot);
- if (eval_root == myroot)
- eval_root = Nullcmd;
- }
-
- perldb = oldperldb;
- in_eval--;
-#ifdef DEBUGGING
- if (debug & 4) {
- char *tmps = loop_stack[loop_ptr].loop_label;
- deb("(Popping label #%d %s)\n",loop_ptr,
- tmps ? tmps : "" );
- }
-#endif
- loop_ptr--;
- tmps_base = oldtmps_base;
- curspat = oldspat;
- lastspat = oldlspat;
- if (savestack->ary_fill > oldsave) /* let them use local() */
- restorelist(oldsave);
-
- if (optype != O_EVAL) {
- if (retval) {
- if (optype == O_REQUIRE)
- fatal("%s", str_get(stab_val(stabent("@",TRUE))));
- }
- else {
- curcmd = oldcurcmd;
- if (gimme == G_SCALAR ? str_true(st[sp]) : sp > arglast[0]) {
- (void)hstore(stab_hash(incstab), specfilename,
- strlen(specfilename), str_smake(stab_val(curcmd->c_filestab)),
- 0 );
- }
- else if (optype == O_REQUIRE)
- fatal("%s did not return a true value", specfilename);
- }
- }
- curcmd = oldcurcmd;
- return sp;
-}
-
-int
-do_try(cmd,gimme,arglast)
-CMD *cmd;
-int gimme;
-int *arglast;
-{
- STR **st = stack->ary_array;
-
- CMD * VOLATILE oldcurcmd = curcmd;
- VOLATILE int oldtmps_base = tmps_base;
- VOLATILE int oldsave = savestack->ary_fill;
- SPAT * VOLATILE oldspat = curspat;
- SPAT * VOLATILE oldlspat = lastspat;
- VOLATILE int sp = arglast[0];
-
- tmps_base = tmps_max;
- str_set(stab_val(stabent("@",TRUE)),"");
- in_eval++;
- if (++loop_ptr >= loop_max) {
- loop_max += 128;
- Renew(loop_stack, loop_max, struct loop);
- }
- loop_stack[loop_ptr].loop_label = "_EVAL_";
- loop_stack[loop_ptr].loop_sp = sp;
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Pushing label #%d _EVAL_)\n", loop_ptr);
- }
-#endif
- if (setjmp(loop_stack[loop_ptr].loop_env)) {
- st = stack->ary_array;
- sp = arglast[0];
- if (gimme != G_ARRAY)
- st[++sp] = &str_undef;
- }
- else {
- sp = cmd_exec(cmd,gimme,sp);
- st = stack->ary_array;
-/* for (i = arglast[0] + 1; i <= sp; i++)
- st[i] = str_mortal(st[i]); not needed, I think */
- /* if we don't save result, free zaps it */
- }
-
- in_eval--;
-#ifdef DEBUGGING
- if (debug & 4) {
- char *tmps = loop_stack[loop_ptr].loop_label;
- deb("(Popping label #%d %s)\n",loop_ptr,
- tmps ? tmps : "" );
- }
-#endif
- loop_ptr--;
- tmps_base = oldtmps_base;
- curspat = oldspat;
- lastspat = oldlspat;
- curcmd = oldcurcmd;
- if (savestack->ary_fill > oldsave) /* let them use local() */
- restorelist(oldsave);
-
- return sp;
-}
-
-/* This routine handles any switches that can be given during run */
-
-static char *
-moreswitches(s)
-char *s;
-{
- int numlen;
-
- switch (*s) {
- case '0':
- nrschar = scanoct(s, 4, &numlen);
- nrs = nsavestr("\n",1);
- *nrs = nrschar;
- if (nrschar > 0377) {
- nrslen = 0;
- nrs = "";
- }
- else if (!nrschar && numlen >= 2) {
- nrslen = 2;
- nrs = "\n\n";
- nrschar = '\n';
- }
- return s + numlen;
- case 'a':
- minus_a = TRUE;
- s++;
- return s;
- case 'c':
- minus_c = TRUE;
- s++;
- return s;
- case 'd':
-#ifdef TAINT
- if (euid != uid || egid != gid)
- fatal("No -d allowed in setuid scripts");
-#endif
- perldb = TRUE;
- s++;
- return s;
- case 'D':
-#ifdef DEBUGGING
-#ifdef TAINT
- if (euid != uid || egid != gid)
- fatal("No -D allowed in setuid scripts");
-#endif
- debug = atoi(s+1) | 32768;
-#else
- warn("Recompile perl with -DDEBUGGING to use -D switch\n");
-#endif
- /*SUPPRESS 530*/
- for (s++; isDIGIT(*s); s++) ;
- return s;
- case 'i':
- inplace = savestr(s+1);
- /*SUPPRESS 530*/
- for (s = inplace; *s && !isSPACE(*s); s++) ;
- *s = '\0';
- break;
- case 'I':
-#ifdef TAINT
- if (euid != uid || egid != gid)
- fatal("No -I allowed in setuid scripts");
-#endif
- if (*++s) {
- (void)apush(stab_array(incstab),str_make(s,0));
- }
- else
- fatal("No space allowed after -I");
- break;
- case 'l':
- minus_l = TRUE;
- s++;
- if (isDIGIT(*s)) {
- ors = savestr("\n");
- orslen = 1;
- *ors = scanoct(s, 3 + (*s == '0'), &numlen);
- s += numlen;
- }
- else {
- ors = nsavestr(nrs,nrslen);
- orslen = nrslen;
- }
- return s;
- case 'n':
- minus_n = TRUE;
- s++;
- return s;
- case 'p':
- minus_p = TRUE;
- s++;
- return s;
- case 'u':
- do_undump = TRUE;
- s++;
- return s;
- case 'U':
- unsafe = TRUE;
- s++;
- return s;
- case 'v':
- fputs("\nThis is perl, version 4.0\n\n",stdout);
- fputs(rcsid,stdout);
- fputs("\nCopyright (c) 1989, 1990, 1991, Larry Wall\n",stdout);
-#ifdef MSDOS
- fputs("MS-DOS port Copyright (c) 1989, 1990, Diomidis Spinellis\n",
- stdout);
-#ifdef OS2
- fputs("OS/2 port Copyright (c) 1990, 1991, Raymond Chen, Kai Uwe Rommel\n",
- stdout);
-#endif
-#endif
-#ifdef atarist
- fputs("atariST series port, ++jrb bammi@cadence.com\n", stdout);
-#endif
- fputs("\n\
-Perl may be copied only under the terms of either the Artistic License or the\n\
-GNU General Public License, which may be found in the Perl 4.0 source kit.\n",stdout);
-#ifdef MSDOS
- usage(origargv[0]);
-#endif
- exit(0);
- case 'w':
- dowarn = TRUE;
- s++;
- return s;
- case ' ':
- case '\n':
- case '\t':
- break;
- default:
- fatal("Switch meaningless after -x: -%s",s);
- }
- return Nullch;
-}
-
-/* compliments of Tom Christiansen */
-
-/* unexec() can be found in the Gnu emacs distribution */
-
-void
-my_unexec()
-{
-#ifdef UNEXEC
- int status;
- extern int etext;
- static char dumpname[BUFSIZ];
- static char perlpath[256];
-
- sprintf (dumpname, "%s.perldump", origfilename);
- sprintf (perlpath, "%s/perl", BIN);
-
- status = unexec(dumpname, perlpath, &etext, sbrk(0), 0);
- if (status)
- fprintf(stderr, "unexec of %s into %s failed!\n", perlpath, dumpname);
- exit(status);
-#else
-#ifdef DOSISH
- abort(); /* nothing else to do */
-#else /* ! MSDOS */
-# ifndef SIGABRT
-# define SIGABRT SIGILL
-# endif
-# ifndef SIGILL
-# define SIGILL 6 /* blech */
-# endif
- kill(getpid(),SIGABRT); /* for use with undump */
-#endif /* ! MSDOS */
-#endif
-}
-
diff --git a/gnu/usr.bin/perl/perl/perl.h b/gnu/usr.bin/perl/perl/perl.h
deleted file mode 100644
index af5873d..0000000
--- a/gnu/usr.bin/perl/perl/perl.h
+++ /dev/null
@@ -1,1071 +0,0 @@
-/* $RCSfile: perl.h,v $$Revision: 1.2 $$Date: 1995/05/30 05:03:11 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: perl.h,v $
- * Revision 1.2 1995/05/30 05:03:11 rgrimes
- * Remove trailing whitespace.
- *
- * Revision 1.1.1.1 1994/09/10 06:27:35 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:35 nate
- * PERL!
- *
- * Revision 4.0.1.7 1993/02/05 19:40:30 lwall
- * patch36: worked around certain busted compilers that don't init statics right
- *
- * Revision 4.0.1.6 92/06/08 14:55:10 lwall
- * patch20: added Atari ST portability
- * patch20: bcopy() and memcpy() now tested for overlap safety
- * patch20: Perl now distinguishes overlapped copies from non-overlapped
- * patch20: removed implicit int declarations on functions
- *
- * Revision 4.0.1.5 91/11/11 16:41:07 lwall
- * patch19: uts wrongly defines S_ISDIR() et al
- * patch19: too many preprocessors can't expand a macro right in #if
- * patch19: added little-endian pack/unpack options
- *
- * Revision 4.0.1.4 91/11/05 18:06:10 lwall
- * patch11: various portability fixes
- * patch11: added support for dbz
- * patch11: added some support for 64-bit integers
- * patch11: hex() didn't understand leading 0x
- *
- * Revision 4.0.1.3 91/06/10 01:25:10 lwall
- * patch10: certain pattern optimizations were botched
- *
- * Revision 4.0.1.2 91/06/07 11:28:33 lwall
- * patch4: new copyright notice
- * patch4: made some allowances for "semi-standard" C
- * patch4: many, many itty-bitty portability fixes
- *
- * Revision 4.0.1.1 91/04/11 17:49:51 lwall
- * patch1: hopefully straightened out some of the Xenix mess
- *
- * Revision 4.0 91/03/20 01:37:56 lwall
- * 4.0 baseline.
- *
- */
-
-#define VOIDWANT 1
-#include "config.h"
-
-#ifdef MYMALLOC
-# ifdef HIDEMYMALLOC
-# define malloc Mymalloc
-# define realloc Myremalloc
-# define free Myfree
-# endif
-# define safemalloc malloc
-# define saferealloc realloc
-# define safefree free
-#endif
-
-/* work around some libPW problems */
-#define fatal Myfatal
-#ifdef DOINIT
-char Error[1];
-#endif
-
-/* define this once if either system, instead of cluttering up the src */
-#if defined(MSDOS) || defined(atarist)
-#define DOSISH 1
-#endif
-
-#ifdef DOSISH
-/* This stuff now in the MS-DOS config.h file. */
-#else /* !MSDOS */
-
-/*
- * The following symbols are defined if your operating system supports
- * functions by that name. All Unixes I know of support them, thus they
- * are not checked by the configuration script, but are directly defined
- * here.
- */
-#define HAS_ALARM
-#define HAS_CHOWN
-#define HAS_CHROOT
-#define HAS_FORK
-#define HAS_GETLOGIN
-#define HAS_GETPPID
-#define HAS_KILL
-#define HAS_LINK
-#define HAS_PIPE
-#define HAS_WAIT
-#define HAS_UMASK
-/*
- * The following symbols are defined if your operating system supports
- * password and group functions in general. All Unix systems do.
- */
-#define HAS_GROUP
-#define HAS_PASSWD
-
-#endif /* !MSDOS */
-
-#if defined(__STDC__) || defined(_AIX) || defined(__stdc__)
-# define STANDARD_C 1
-#endif
-
-#if defined(HASVOLATILE) || defined(STANDARD_C)
-#define VOLATILE volatile
-#else
-#define VOLATILE
-#endif
-
-#ifdef IAMSUID
-# ifndef TAINT
-# define TAINT
-# endif
-#endif
-
-#ifndef HAS_VFORK
-# define vfork fork
-#endif
-
-#ifdef HAS_GETPGRP2
-# ifndef HAS_GETPGRP
-# define HAS_GETPGRP
-# endif
-# define getpgrp getpgrp2
-#endif
-
-#ifdef HAS_SETPGRP2
-# ifndef HAS_SETPGRP
-# define HAS_SETPGRP
-# endif
-# define setpgrp setpgrp2
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <setjmp.h>
-#ifndef MSDOS
-#ifdef PARAM_NEEDS_TYPES
-#include <sys/types.h>
-#endif
-#include <sys/param.h>
-#endif
-#ifdef STANDARD_C
-/* Use all the "standard" definitions */
-#include <stdlib.h>
-#include <string.h>
-#define MEM_SIZE size_t
-#else
-typedef unsigned int MEM_SIZE;
-#endif /* STANDARD_C */
-
-#if defined(HAS_MEMCMP) && defined(mips) && defined(ultrix)
-#undef HAS_MEMCMP
-#endif
-
-#ifdef HAS_MEMCPY
-# ifndef STANDARD_C
-# ifndef memcpy
- extern char * memcpy();
-# endif
-# endif
-#else
-# ifndef memcpy
-# ifdef HAS_BCOPY
-# define memcpy(d,s,l) bcopy(s,d,l)
-# else
-# define memcpy(d,s,l) my_bcopy(s,d,l)
-# endif
-# endif
-#endif /* HAS_MEMCPY */
-
-#ifdef HAS_MEMSET
-# ifndef STANDARD_C
-# ifndef memset
- extern char *memset();
-# endif
-# endif
-# define memzero(d,l) memset(d,0,l)
-#else
-# ifndef memzero
-# ifdef HAS_BZERO
-# define memzero(d,l) bzero(d,l)
-# else
-# define memzero(d,l) my_bzero(d,l)
-# endif
-# endif
-#endif /* HAS_MEMSET */
-
-#ifdef HAS_MEMCMP
-# ifndef STANDARD_C
-# ifndef memcmp
- extern int memcmp();
-# endif
-# endif
-#else
-# ifndef memcmp
-# define memcmp(s1,s2,l) my_memcmp(s1,s2,l)
-# endif
-#endif /* HAS_MEMCMP */
-
-/* we prefer bcmp slightly for comparisons that don't care about ordering */
-#ifndef HAS_BCMP
-# ifndef bcmp
-# define bcmp(s1,s2,l) memcmp(s1,s2,l)
-# endif
-#endif /* HAS_BCMP */
-
-#ifndef HAS_MEMMOVE
-#if defined(HAS_BCOPY) && defined(SAFE_BCOPY)
-#define memmove(d,s,l) bcopy(s,d,l)
-#else
-#if defined(HAS_MEMCPY) && defined(SAFE_MEMCPY)
-#define memmove(d,s,l) memcpy(d,s,l)
-#else
-#define memmove(d,s,l) my_bcopy(s,d,l)
-#endif
-#endif
-#endif
-
-#ifndef _TYPES_ /* If types.h defines this it's easy. */
-#ifndef major /* Does everyone's types.h define this? */
-#include <sys/types.h>
-#endif
-#endif
-
-#ifdef I_NETINET_IN
-#include <netinet/in.h>
-#endif
-
-#include <sys/stat.h>
-#if defined(uts) || defined(UTekV)
-#undef S_ISDIR
-#undef S_ISCHR
-#undef S_ISBLK
-#undef S_ISREG
-#undef S_ISFIFO
-#undef S_ISLNK
-#define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR)
-#define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR)
-#define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK)
-#define S_ISREG(P) (((P)&S_IFMT)==S_IFREG)
-#define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO)
-#ifdef S_IFLNK
-#define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK)
-#endif
-#endif
-
-#include <sys/mount.h>
-
-#ifdef I_TIME
-# include <time.h>
-#endif
-
-#ifdef I_SYS_TIME
-# ifdef SYSTIMEKERNEL
-# define KERNEL
-# endif
-# include <sys/time.h>
-# ifdef SYSTIMEKERNEL
-# undef KERNEL
-# endif
-#endif
-
-#ifndef MSDOS
-#include <sys/times.h>
-#endif
-
-#if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
-#undef HAS_STRERROR
-#endif
-
-#include <errno.h>
-#ifndef MSDOS
-#ifndef errno
-extern int errno; /* ANSI allows errno to be an lvalue expr */
-#endif
-#endif
-
-#ifndef strerror
-#ifdef HAS_STRERROR
-char *strerror();
-#else
-extern int sys_nerr;
-extern char *sys_errlist[];
-#define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
-#endif
-#endif
-
-#ifdef I_SYSIOCTL
-#ifndef _IOCTL_
-#include <sys/ioctl.h>
-#endif
-#endif
-
-#if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
-#ifdef HAS_SOCKETPAIR
-#undef HAS_SOCKETPAIR
-#endif
-#ifdef HAS_NDBM
-#undef HAS_NDBM
-#endif
-#endif
-
-#ifdef WANT_DBZ
-#include <dbz.h>
-#define SOME_DBM
-#define dbm_fetch(db,dkey) fetch(dkey)
-#define dbm_delete(db,dkey) fatal("dbz doesn't implement delete")
-#define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
-#define dbm_close(db) dbmclose()
-#define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch())
-#define nextkey() (fatal("dbz doesn't implement traversal"),fetch())
-#define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch())
-#ifdef HAS_NDBM
-#undef HAS_NDBM
-#endif
-#ifndef HAS_ODBM
-#define HAS_ODBM
-#endif
-#else
-#ifdef HAS_GDBM
-#ifdef I_GDBM
-#include <gdbm.h>
-#endif
-#define SOME_DBM
-#ifdef HAS_NDBM
-#undef HAS_NDBM
-#endif
-#ifdef HAS_ODBM
-#undef HAS_ODBM
-#endif
-#else
-#ifdef HAS_NDBM
-#include <ndbm.h>
-#define SOME_DBM
-#ifdef HAS_ODBM
-#undef HAS_ODBM
-#endif
-#else
-#ifdef HAS_ODBM
-#ifdef NULL
-#undef NULL /* suppress redefinition message */
-#endif
-#include <dbm.h>
-#ifdef NULL
-#undef NULL
-#endif
-#define NULL 0 /* silly thing is, we don't even use this */
-#define SOME_DBM
-#define dbm_fetch(db,dkey) fetch(dkey)
-#define dbm_delete(db,dkey) delete(dkey)
-#define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
-#define dbm_close(db) dbmclose()
-#define dbm_firstkey(db) firstkey()
-#endif /* HAS_ODBM */
-#endif /* HAS_NDBM */
-#endif /* HAS_GDBM */
-#endif /* WANT_DBZ */
-#ifdef SOME_DBM
-EXT char *dbmkey;
-EXT int dbmlen;
-#endif
-
-#if INTSIZE == 2
-#define htoni htons
-#define ntohi ntohs
-#else
-#define htoni htonl
-#define ntohi ntohl
-#endif
-
-#if defined(I_DIRENT)
-# include <dirent.h>
-# define DIRENT dirent
-#else
-# ifdef I_SYS_NDIR
-# include <sys/ndir.h>
-# define DIRENT direct
-# else
-# ifdef I_SYS_DIR
-# ifdef hp9000s500
-# include <ndir.h> /* may be wrong in the future */
-# else
-# include <sys/dir.h>
-# endif
-# define DIRENT direct
-# endif
-# endif
-#endif
-
-#ifdef FPUTS_BOTCH
-/* work around botch in SunOS 4.0.1 and 4.0.2 */
-# ifndef fputs
-# define fputs(str,fp) fprintf(fp,"%s",str)
-# endif
-#endif
-
-/*
- * The following gobbledygook brought to you on behalf of __STDC__.
- * (I could just use #ifndef __STDC__, but this is more bulletproof
- * in the face of half-implementations.)
- */
-
-#ifndef S_IFMT
-# ifdef _S_IFMT
-# define S_IFMT _S_IFMT
-# else
-# define S_IFMT 0170000
-# endif
-#endif
-
-#ifndef S_ISDIR
-# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
-#endif
-
-#ifndef S_ISCHR
-# define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
-#endif
-
-#ifndef S_ISBLK
-# ifdef S_IFBLK
-# define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
-# else
-# define S_ISBLK(m) (0)
-# endif
-#endif
-
-#ifndef S_ISREG
-# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
-#endif
-
-#ifndef S_ISFIFO
-# ifdef S_IFIFO
-# define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
-# else
-# define S_ISFIFO(m) (0)
-# endif
-#endif
-
-#ifndef S_ISLNK
-# ifdef _S_ISLNK
-# define S_ISLNK(m) _S_ISLNK(m)
-# else
-# ifdef _S_IFLNK
-# define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
-# else
-# ifdef S_IFLNK
-# define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
-# else
-# define S_ISLNK(m) (0)
-# endif
-# endif
-# endif
-#endif
-
-#ifndef S_ISSOCK
-# ifdef _S_ISSOCK
-# define S_ISSOCK(m) _S_ISSOCK(m)
-# else
-# ifdef _S_IFSOCK
-# define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
-# else
-# ifdef S_IFSOCK
-# define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
-# else
-# define S_ISSOCK(m) (0)
-# endif
-# endif
-# endif
-#endif
-
-#ifndef S_IRUSR
-# ifdef S_IREAD
-# define S_IRUSR S_IREAD
-# define S_IWUSR S_IWRITE
-# define S_IXUSR S_IEXEC
-# else
-# define S_IRUSR 0400
-# define S_IWUSR 0200
-# define S_IXUSR 0100
-# endif
-# define S_IRGRP (S_IRUSR>>3)
-# define S_IWGRP (S_IWUSR>>3)
-# define S_IXGRP (S_IXUSR>>3)
-# define S_IROTH (S_IRUSR>>6)
-# define S_IWOTH (S_IWUSR>>6)
-# define S_IXOTH (S_IXUSR>>6)
-#endif
-
-#ifndef S_ISUID
-# define S_ISUID 04000
-#endif
-
-#ifndef S_ISGID
-# define S_ISGID 02000
-#endif
-
-#ifdef f_next
-#undef f_next
-#endif
-
-#if defined(cray) || defined(gould) || defined(i860)
-# define SLOPPYDIVIDE
-#endif
-
-#if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
-# define QUAD
-#endif
-
-#ifdef QUAD
-# ifdef cray
-# define quad int
-# else
-# if defined(convex) || defined (uts)
-# define quad long long
-# else
-# define quad long
-# endif
-# endif
-#endif
-
-typedef MEM_SIZE STRLEN;
-
-typedef struct arg ARG;
-typedef struct cmd CMD;
-typedef struct formcmd FCMD;
-typedef struct scanpat SPAT;
-typedef struct stio STIO;
-typedef struct sub SUBR;
-typedef struct string STR;
-typedef struct atbl ARRAY;
-typedef struct htbl HASH;
-typedef struct regexp REGEXP;
-typedef struct stabptrs STBP;
-typedef struct stab STAB;
-typedef struct callsave CSV;
-
-#include "handy.h"
-#include "regexp.h"
-#include "str.h"
-#include "util.h"
-#include "form.h"
-#include "stab.h"
-#include "spat.h"
-#include "arg.h"
-#include "cmd.h"
-#include "array.h"
-#include "hash.h"
-
-#if defined(iAPX286) || defined(M_I286) || defined(I80286)
-# define I286
-#endif
-
-#ifndef STANDARD_C
-#ifdef CHARSPRINTF
- char *sprintf();
-#else
- int sprintf();
-#endif
-#endif
-
-EXT char *Yes INIT("1");
-EXT char *No INIT("");
-
-/* "gimme" values */
-
-/* Note: cmd.c assumes that it can use && to produce one of these values! */
-#define G_SCALAR 0
-#define G_ARRAY 1
-
-#ifdef CRIPPLED_CC
-int str_true();
-#else /* !CRIPPLED_CC */
-#define str_true(str) (Str = (str), \
- (Str->str_pok ? \
- ((*Str->str_ptr > '0' || \
- Str->str_cur > 1 || \
- (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
- : \
- (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
-#endif /* CRIPPLED_CC */
-
-#ifdef DEBUGGING
-#define str_peek(str) (Str = (str), \
- (Str->str_pok ? \
- Str->str_ptr : \
- (Str->str_nok ? \
- (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
- (char*)tokenbuf) : \
- "" )))
-#endif
-
-#ifdef CRIPPLED_CC
-char *str_get();
-#else
-#ifdef TAINT
-#define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
- (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
-#else
-#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
-#endif /* TAINT */
-#endif /* CRIPPLED_CC */
-
-#ifdef CRIPPLED_CC
-double str_gnum();
-#else /* !CRIPPLED_CC */
-#ifdef TAINT
-#define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
- (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
-#else /* !TAINT */
-#define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
-#endif /* TAINT*/
-#endif /* CRIPPLED_CC */
-EXT STR *Str;
-
-#define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
-
-#ifndef DOSISH
-#define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
-#define Str_Grow str_grow
-#else
-/* extra parentheses intentionally NOT placed around "len"! */
-#define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
- str_grow(str,(unsigned long)len)
-#define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
-#endif /* DOSISH */
-
-#ifndef BYTEORDER
-#define BYTEORDER 0x1234
-#endif
-
-#if defined(htonl) && !defined(HAS_HTONL)
-#define HAS_HTONL
-#endif
-#if defined(htons) && !defined(HAS_HTONS)
-#define HAS_HTONS
-#endif
-#if defined(ntohl) && !defined(HAS_NTOHL)
-#define HAS_NTOHL
-#endif
-#if defined(ntohs) && !defined(HAS_NTOHS)
-#define HAS_NTOHS
-#endif
-#ifndef HAS_HTONL
-#if (BYTEORDER & 0xffff) != 0x4321
-#define HAS_HTONS
-#define HAS_HTONL
-#define HAS_NTOHS
-#define HAS_NTOHL
-#define MYSWAP
-#define htons my_swap
-#define htonl my_htonl
-#define ntohs my_swap
-#define ntohl my_ntohl
-#endif
-#else
-#if (BYTEORDER & 0xffff) == 0x4321
-#undef HAS_HTONS
-#undef HAS_HTONL
-#undef HAS_NTOHS
-#undef HAS_NTOHL
-#endif
-#endif
-
-/*
- * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
- * -DWS
- */
-#if BYTEORDER != 0x1234
-# define HAS_VTOHL
-# define HAS_VTOHS
-# define HAS_HTOVL
-# define HAS_HTOVS
-# if BYTEORDER == 0x4321
-# define vtohl(x) ((((x)&0xFF)<<24) \
- +(((x)>>24)&0xFF) \
- +(((x)&0x0000FF00)<<8) \
- +(((x)&0x00FF0000)>>8) )
-# define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
-# define htovl(x) vtohl(x)
-# define htovs(x) vtohs(x)
-# endif
- /* otherwise default to functions in util.c */
-#endif
-
-#ifdef CASTNEGFLOAT
-#define U_S(what) ((unsigned short)(what))
-#define U_I(what) ((unsigned int)(what))
-#define U_L(what) ((unsigned long)(what))
-#else
-unsigned long castulong();
-#define U_S(what) ((unsigned int)castulong(what))
-#define U_I(what) ((unsigned int)castulong(what))
-#define U_L(what) (castulong(what))
-#endif
-
-CMD *add_label();
-CMD *block_head();
-CMD *append_line();
-CMD *make_acmd();
-CMD *make_ccmd();
-CMD *make_icmd();
-CMD *invert();
-CMD *addcond();
-CMD *addloop();
-CMD *wopt();
-CMD *over();
-
-STAB *stabent();
-STAB *genstab();
-
-ARG *stab2arg();
-ARG *op_new();
-ARG *make_op();
-ARG *make_match();
-ARG *make_split();
-ARG *rcatmaybe();
-ARG *listish();
-ARG *maybelistish();
-ARG *localize();
-ARG *fixeval();
-ARG *jmaybe();
-ARG *l();
-ARG *fixl();
-ARG *mod_match();
-ARG *make_list();
-ARG *cmd_to_arg();
-ARG *addflags();
-ARG *hide_ary();
-ARG *cval_to_arg();
-
-STR *str_new();
-STR *stab_str();
-
-int apply();
-int do_each();
-int do_subr();
-int do_match();
-int do_unpack();
-int eval(); /* this evaluates expressions */
-int do_eval(); /* this evaluates eval operator */
-int do_assign();
-
-SUBR *make_sub();
-
-FCMD *load_format();
-
-char *scanpat();
-char *scansubst();
-char *scantrans();
-char *scanstr();
-char *scanident();
-char *str_append_till();
-char *str_gets();
-char *str_grow();
-
-bool do_open();
-bool do_close();
-bool do_print();
-bool do_aprint();
-bool do_exec();
-bool do_aexec();
-
-int do_subst();
-int cando();
-int ingroup();
-int whichsig();
-int userinit();
-#ifdef CRYPTSCRIPT
-void cryptswitch();
-#endif
-
-void str_replace();
-void str_inc();
-void str_dec();
-void str_free();
-void cmd_free();
-void arg_free();
-void spat_free();
-void regfree();
-void stab_clear();
-void do_chop();
-void do_vop();
-void do_write();
-void do_join();
-void do_sprintf();
-void do_accept();
-void do_pipe();
-void do_vecset();
-void do_unshift();
-void do_execfree();
-void magicalize();
-void magicname();
-void savelist();
-void saveitem();
-void saveint();
-void savelong();
-void savesptr();
-void savehptr();
-void restorelist();
-void repeatcpy();
-void make_form();
-void dehoist();
-void format();
-void my_unexec();
-void fatal();
-void warn();
-#ifdef DEBUGGING
-void dump_all();
-void dump_cmd();
-void dump_arg();
-void dump_flags();
-void dump_stab();
-void dump_spat();
-#endif
-#ifdef MSTATS
-void mstats();
-#endif
-
-HASH *savehash();
-ARRAY *saveary();
-
-EXT char **origargv;
-EXT int origargc;
-EXT char **origenviron;
-extern char **environ;
-
-EXT long subline INIT(0);
-EXT STR *subname INIT(Nullstr);
-EXT int arybase INIT(0);
-
-struct outrec {
- long o_lines;
- char *o_str;
- int o_len;
-};
-
-EXT struct outrec outrec;
-EXT struct outrec toprec;
-
-EXT STAB *stdinstab INIT(Nullstab);
-EXT STAB *last_in_stab INIT(Nullstab);
-EXT STAB *defstab INIT(Nullstab);
-EXT STAB *argvstab INIT(Nullstab);
-EXT STAB *envstab INIT(Nullstab);
-EXT STAB *sigstab INIT(Nullstab);
-EXT STAB *defoutstab INIT(Nullstab);
-EXT STAB *curoutstab INIT(Nullstab);
-EXT STAB *argvoutstab INIT(Nullstab);
-EXT STAB *incstab INIT(Nullstab);
-EXT STAB *leftstab INIT(Nullstab);
-EXT STAB *amperstab INIT(Nullstab);
-EXT STAB *rightstab INIT(Nullstab);
-EXT STAB *DBstab INIT(Nullstab);
-EXT STAB *DBline INIT(Nullstab);
-EXT STAB *DBsub INIT(Nullstab);
-
-EXT HASH *defstash; /* main symbol table */
-EXT HASH *curstash; /* symbol table for current package */
-EXT HASH *debstash; /* symbol table for perldb package */
-
-EXT STR *curstname; /* name of current package */
-
-EXT STR *freestrroot INIT(Nullstr);
-EXT STR *lastretstr INIT(Nullstr);
-EXT STR *DBsingle INIT(Nullstr);
-EXT STR *DBtrace INIT(Nullstr);
-EXT STR *DBsignal INIT(Nullstr);
-EXT STR *formfeed INIT(Nullstr);
-
-EXT int lastspbase;
-EXT int lastsize;
-
-EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
-EXT char *origfilename;
-EXT FILE * VOLATILE rsfp INIT(Nullfp);
-EXT char buf[1024];
-EXT char *bufptr;
-EXT char *oldbufptr;
-EXT char *oldoldbufptr;
-EXT char *bufend;
-
-EXT STR *linestr INIT(Nullstr);
-
-EXT char *rs INIT("\n");
-EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */
-EXT int rslen INIT(1);
-EXT bool rspara INIT(FALSE);
-EXT char *ofs INIT(Nullch);
-EXT int ofslen INIT(0);
-EXT char *ors INIT(Nullch);
-EXT int orslen INIT(0);
-EXT char *ofmt INIT(Nullch);
-EXT char *inplace INIT(Nullch);
-EXT char *nointrp INIT("");
-
-EXT bool preprocess INIT(FALSE);
-EXT bool minus_n INIT(FALSE);
-EXT bool minus_p INIT(FALSE);
-EXT bool minus_l INIT(FALSE);
-EXT bool minus_a INIT(FALSE);
-EXT bool doswitches INIT(FALSE);
-EXT bool dowarn INIT(FALSE);
-EXT bool doextract INIT(FALSE);
-EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
-EXT bool sawampersand INIT(FALSE); /* must save all match strings */
-EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
-EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
-EXT bool sawvec INIT(FALSE);
-EXT bool localizing INIT(FALSE); /* are we processing a local() list? */
-
-#ifndef MAXSYSFD
-# define MAXSYSFD 2
-#endif
-EXT int maxsysfd INIT(MAXSYSFD); /* top fd to pass to subprocesses */
-
-#ifdef CSH
-EXT char *cshname INIT(CSH);
-EXT int cshlen INIT(0);
-#endif /* CSH */
-
-#ifdef TAINT
-EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
-EXT bool taintanyway INIT(FALSE); /* force taint checks when !set?id */
-#endif
-
-EXT bool nomemok INIT(FALSE); /* let malloc context handle nomem */
-
-#ifndef DOSISH
-#define TMPPATH "/tmp/perl-eXXXXXX"
-#else
-#define TMPPATH "plXXXXXX"
-#endif /* MSDOS */
-EXT char *e_tmpname;
-EXT FILE *e_fp INIT(Nullfp);
-
-EXT char tokenbuf[256];
-EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
-EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */
-EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
-EXT int forkprocess; /* so do_open |- can return proc# */
-EXT int do_undump INIT(0); /* -u or dump seen? */
-EXT int error_count INIT(0); /* how many errors so far, max 10 */
-EXT int multi_start INIT(0); /* 1st line of multi-line string */
-EXT int multi_end INIT(0); /* last line of multi-line string */
-EXT int multi_open INIT(0); /* delimiter of said string */
-EXT int multi_close INIT(0); /* delimiter of said string */
-
-FILE *popen();
-/* char *str_get(); */
-STR *interp();
-void free_arg();
-STIO *stio_new();
-void hoistmust();
-void scanconst();
-
-EXT struct stat statbuf;
-EXT struct stat statcache;
-EXT STAB *statstab INIT(Nullstab);
-EXT STR *statname INIT(Nullstr);
-#ifndef MSDOS
-EXT struct tms timesbuf;
-#endif
-EXT int uid;
-EXT int euid;
-EXT int gid;
-EXT int egid;
-UIDTYPE getuid();
-UIDTYPE geteuid();
-GIDTYPE getgid();
-GIDTYPE getegid();
-EXT int unsafe;
-
-#ifdef DEBUGGING
-EXT VOLATILE int debug INIT(0);
-EXT int dlevel INIT(0);
-EXT int dlmax INIT(128);
-EXT char *debname;
-EXT char *debdelim;
-#define YYDEBUG 1
-#endif
-EXT int perldb INIT(0);
-#define YYMAXDEPTH 300
-
-EXT line_t cmdline INIT(NOLINE);
-
-EXT STR str_undef;
-EXT STR str_no;
-EXT STR str_yes;
-
-/* runtime control stuff */
-
-EXT struct loop {
- char *loop_label; /* what the loop was called, if anything */
- int loop_sp; /* stack pointer to copy stuff down to */
- jmp_buf loop_env;
-} *loop_stack;
-
-EXT int loop_ptr INIT(-1);
-EXT int loop_max INIT(128);
-
-EXT jmp_buf top_env;
-
-EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
-
-struct ufuncs {
- int (*uf_val)();
- int (*uf_set)();
- int uf_index;
-};
-
-EXT ARRAY *stack; /* THE STACK */
-
-EXT ARRAY * VOLATILE savestack; /* to save non-local values on */
-
-EXT ARRAY *tosave; /* strings to save on recursive subroutine */
-
-EXT ARRAY *lineary; /* lines of script for debugger */
-EXT ARRAY *dbargs; /* args to call listed by caller function */
-
-EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */
-EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */
-
-EXT int *di; /* for tmp use in debuggers */
-EXT char *dc;
-EXT short *ds;
-
-/* Fix these up for __STDC__ */
-EXT time_t basetime INIT(0);
-char *mktemp();
-#ifndef STANDARD_C
-/* All of these are in stdlib.h or time.h for ANSI C */
-double atof();
-long time();
-struct tm *gmtime(), *localtime();
-char *index(), *rindex();
-char *strcpy(), *strcat();
-#endif /* ! STANDARD_C */
-
-#ifdef EUNICE
-#define UNLINK unlnk
-int unlnk();
-#else
-#define UNLINK unlink
-#endif
-
-#ifndef HAS_SETREUID
-#ifdef HAS_SETRESUID
-#define setreuid(r,e) setresuid(r,e,-1)
-#define HAS_SETREUID
-#endif
-#endif
-#ifndef HAS_SETREGID
-#ifdef HAS_SETRESGID
-#define setregid(r,e) setresgid(r,e,-1)
-#define HAS_SETREGID
-#endif
-#endif
-
-#define SCAN_DEF 0
-#define SCAN_TR 1
-#define SCAN_REPL 2
diff --git a/gnu/usr.bin/perl/perl/perly.c b/gnu/usr.bin/perl/perl/perly.c
deleted file mode 100644
index 9e314cd..0000000
--- a/gnu/usr.bin/perl/perl/perly.c
+++ /dev/null
@@ -1,3063 +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 43 "perly.y"
-#include "INTERN.h"
-#include "perl.h"
-
-/*SUPPRESS 530*/
-/*SUPPRESS 593*/
-/*SUPPRESS 595*/
-
-STAB *scrstab;
-ARG *arg4; /* rarely used arguments to make_op() */
-ARG *arg5;
-
-#line 58 "perly.y"
-typedef union {
- int ival;
- char *cval;
- ARG *arg;
- CMD *cmdval;
- struct compcmd compval;
- STAB *stabval;
- FCMD *formval;
-} YYSTYPE;
-#line 34 "y.tab.c"
-#define WORD 257
-#define LABEL 258
-#define APPEND 259
-#define OPEN 260
-#define SSELECT 261
-#define LOOPEX 262
-#define DOTDOT 263
-#define USING 264
-#define FORMAT 265
-#define DO 266
-#define SHIFT 267
-#define PUSH 268
-#define POP 269
-#define LVALFUN 270
-#define WHILE 271
-#define UNTIL 272
-#define IF 273
-#define UNLESS 274
-#define ELSE 275
-#define ELSIF 276
-#define CONTINUE 277
-#define SPLIT 278
-#define FLIST 279
-#define FOR 280
-#define FILOP 281
-#define FILOP2 282
-#define FILOP3 283
-#define FILOP4 284
-#define FILOP22 285
-#define FILOP25 286
-#define FUNC0 287
-#define FUNC1 288
-#define FUNC2 289
-#define FUNC2x 290
-#define FUNC3 291
-#define FUNC4 292
-#define FUNC5 293
-#define HSHFUN 294
-#define HSHFUN3 295
-#define FLIST2 296
-#define SUB 297
-#define FILETEST 298
-#define LOCAL 299
-#define DELETE 300
-#define RELOP 301
-#define EQOP 302
-#define MULOP 303
-#define ADDOP 304
-#define PACKAGE 305
-#define AMPER 306
-#define FORMLIST 307
-#define REG 308
-#define ARYLEN 309
-#define ARY 310
-#define HSH 311
-#define STAR 312
-#define SUBST 313
-#define PATTERN 314
-#define RSTRING 315
-#define TRANS 316
-#define LISTOP 317
-#define OROR 318
-#define ANDAND 319
-#define UNIOP 320
-#define LS 321
-#define RS 322
-#define MATCH 323
-#define NMATCH 324
-#define UMINUS 325
-#define POW 326
-#define INC 327
-#define DEC 328
-#define YYERRCODE 256
-short yylhs[] = { -1,
- 26, 0, 25, 25, 12, 12, 12, 5, 3, 6,
- 6, 7, 7, 7, 7, 7, 10, 10, 10, 10,
- 10, 10, 9, 9, 9, 9, 8, 8, 8, 8,
- 8, 8, 8, 8, 11, 11, 21, 21, 24, 24,
- 1, 1, 1, 2, 2, 27, 28, 15, 13, 13,
- 16, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 22, 22, 22, 22, 22, 22, 18, 18, 19,
- 19, 20, 20, 4, 4, 23,
-};
-short yylen[] = { 2,
- 0, 2, 3, 2, 0, 2, 5, 4, 0, 0,
- 2, 1, 2, 1, 2, 3, 1, 1, 3, 3,
- 3, 3, 5, 5, 3, 3, 6, 6, 4, 4,
- 7, 6, 10, 2, 0, 1, 0, 1, 0, 1,
- 1, 1, 1, 4, 3, 3, 3, 2, 3, 1,
- 2, 3, 4, 4, 4, 4, 4, 4, 4, 4,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 5, 3, 3, 1, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 1, 4, 3,
- 2, 2, 2, 1, 1, 4, 1, 1, 5, 6,
- 5, 4, 5, 6, 8, 1, 1, 1, 1, 1,
- 5, 5, 4, 4, 2, 5, 5, 4, 4, 2,
- 1, 2, 1, 2, 2, 1, 2, 4, 7, 2,
- 4, 5, 4, 2, 2, 3, 1, 5, 6, 6,
- 7, 9, 6, 2, 4, 2, 4, 1, 1, 6,
- 5, 4, 5, 4, 2, 1, 1, 3, 3, 4,
- 5, 5, 6, 6, 7, 8, 4, 2, 6, 1,
- 1, 1, 2, 2, 3, 3, 3, 1, 1, 1,
- 1, 1, 1, 2, 1, 1,
-};
-short yydefred[] = { 1,
- 0, 10, 0, 40, 0, 0, 0, 12, 41, 11,
- 14, 0, 42, 43, 0, 0, 0, 0, 17, 9,
- 186, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 106, 0, 97,
- 95, 109, 108, 107, 110, 0, 0, 0, 0, 0,
- 0, 0, 15, 0, 0, 0, 13, 0, 0, 0,
- 0, 171, 170, 34, 0, 45, 46, 47, 10, 130,
- 0, 127, 0, 122, 0, 0, 93, 0, 180, 181,
- 0, 146, 0, 0, 144, 155, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 134, 135,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 182, 183, 0, 168, 0, 0, 86,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 124, 0, 0, 0, 84, 85,
- 0, 0, 0, 0, 0, 0, 0, 4, 16, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 82, 83, 44, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 29, 0,
- 30, 0, 25, 0, 26, 0, 0, 0, 36, 0,
- 0, 136, 0, 0, 0, 0, 0, 0, 158, 159,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 185, 0, 0, 6, 0, 3, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 8, 131,
- 0, 0, 0, 0, 128, 113, 0, 118, 0, 147,
- 0, 145, 0, 0, 0, 0, 152, 0, 154, 0,
- 0, 0, 133, 0, 0, 0, 0, 0, 160, 0,
- 0, 0, 0, 0, 167, 0, 0, 89, 0, 0,
- 114, 0, 119, 0, 0, 96, 0, 102, 0, 184,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 132, 0, 0, 111, 116, 0, 27, 28,
- 23, 24, 151, 0, 0, 0, 32, 138, 0, 0,
- 0, 0, 161, 162, 0, 0, 0, 0, 0, 153,
- 0, 0, 112, 117, 99, 103, 101, 0, 0, 0,
- 0, 143, 150, 31, 0, 139, 0, 140, 0, 163,
- 164, 0, 0, 169, 104, 0, 100, 7, 129, 0,
- 141, 0, 165, 0, 0, 0, 0, 166, 105, 33,
- 142,
-};
-short yydgoto[] = { 1,
- 8, 9, 89, 255, 76, 3, 10, 11, 77, 219,
- 220, 168, 79, 80, 292, 294, 81, 198, 102, 137,
- 208, 82, 83, 12, 84, 2, 13, 14,
-};
-short yysindex[] = { 0,
- 0, 0, -193, 0, -54, -229, -212, 0, 0, 0,
- 0, 383, 0, 0, 22, -232, -31, 40, 0, 0,
- 0, -37, -36, -132, 562, -7, 107, -2, 2819, -29,
- -23, -22, -21, 109, 111, -3, -4, 113, 123, 143,
- 170, 172, 173, 174, 175, 186, 187, 188, 189, -34,
- 191, 200, 2896, 202, 11, -228, -60, 0, -32, 0,
- 0, 0, 0, 0, 0, 741, 848, 2819, 2819, 2819,
- 2819, 912, 0, 2819, 2819, -98, 0, 98, -35, 1707,
- -197, 0, 0, 0, -64, 0, 0, 0, 0, 0,
- 3011, 0, 3105, 0, 204, -30, 0, -122, 0, 0,
- -231, 0, -231, -231, 0, 0, 2819, -31, 2819, -31,
- 2819, -31, 2819, -31, 2819, 2819, 205, 1027, 0, 0,
- 1144, 3105, 3105, 3105, 3105, 3105, 206, 1208, 2819, 2819,
- 2819, 2819, 2819, 0, 0, -237, 0, -237, 2819, 0,
- -122, 2819, 131, -62, 216, 220, 2819, 2819, 2819, 2819,
- 2819, 5754, 2819, 221, 0, -122, -197, -197, 0, 0,
- 229, 32, -197, -197, -31, 224, -31, 0, 0, 2819,
- 2819, 2819, 2819, 2819, 2819, 2819, 2819, 1319, 1494, 2819,
- 2819, 2819, 2819, 1605, 1669, 1780, 1955, 2066, 2819, 2819,
- 2130, 0, 0, 0, -113, 281, 1707, 279, 0, 5647,
- 283, 2244, 2362, 284, 289, 293, 221, 294, 0, 65,
- 0, 67, 0, 126, 0, 5528, 32, 2819, 0, 286,
- -39, 0, 305, 279, 303, 303, 328, 329, 0, 0,
- 130, 5658, 5647, 5647, 5647, 5647, 333, 303, 5658, 32,
- 2819, 252, 2436, 2533, 74, -12, 84, -9, 221, 221,
- 221, 2819, 0, 2725, 297, 0, 2819, 0, 221, 221,
- 221, 221, 1707, 474, -122, -187, 2819, -257, 2819, -138,
- 1707, 954, 117, 512, 2819, 238, 2819, 238, 2819, 486,
- 2819, -162, 2819, -162, 51, 51, 2819, 51, 0, 0,
- 2819, 348, 2819, 303, 0, 0, 32, 0, 32, 0,
- 2819, 0, -31, -31, -31, -31, 0, 146, 0, 32,
- 2819, -31, 0, 352, 279, 303, 3105, 3105, 0, 353,
- 153, 279, 303, 303, 0, 279, 355, 0, 100, 2819,
- 0, 32, 0, 32, 276, 0, 277, 0, 3, 0,
- 2819, 154, 1707, 1707, 2819, 1707, 1707, 1707, 1707, 1707,
- 1707, 221, 0, 1707, 303, 0, 0, 32, 0, 0,
- 0, 0, 0, 362, -31, 345, 0, 0, 364, 279,
- 365, 303, 0, 0, 367, 369, 279, 303, 370, 0,
- 287, 114, 0, 0, 0, 0, 0, 14, -31, 1989,
- 372, 0, 0, 0, 1027, 0, 373, 0, 303, 0,
- 0, 374, 279, 0, 0, 292, 0, 0, 0, 381,
- 0, 279, 0, 384, 386, -31, 393, 0, 0, 0,
- 0,
-};
-short yyrindex[] = { 0,
- 0, 0, 70, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 3189, 3385, 0, 3460, 0, 0, 5031, 0,
- 0, 0, 0, 3497, 0, 0, 3539, 0, 0, 0,
- 0, 0, 3576, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 5098, 0, 0, 0, 3661, 0, 3793, 0,
- 0, 0, 0, 0, 0, 5195, 5207, 0, 0, 0,
- 0, 0, 0, 0, 0, 1, 0, 0, -11, 2796,
- 5280, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 3867, 3661, 0, 4782, 0, 0,
- 0, 0, 0, 0, 0, 0, 396, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 385, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 4825, 0, 0, 0, 3909, 3952, 0, 0, 0, 0,
- 5347, 3661, 0, 4158, 0, 4849, 5444, 5501, 0, 0,
- 3994, 0, 5570, 5596, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 452, 2647, 164, 0, 128, 404,
- 0, 0, 0, 0, 0, 0, 23, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 389, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 4200, 4243,
- 4285, 0, 0, 0, 4084, 0, 0, 0, 30, 64,
- 79, 81, 3733, 1030, 4916, 3409, 0, 4534, 0, 4576,
- 3830, 0, 1883, 1422, 0, 5843, 0, 5894, 0, 4957,
- 0, 4666, 0, 4740, 4375, 4449, 0, 4491, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 394, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 3878, 4698, 0, 4858, 4989, 5104, 5370, 5668,
- 5820, 417, 0, 165, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 1582,
- 0, 0, 0, 0, 418, 0, 0, 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, -178, -17, 335, 0, 0, 0, 448,
- 66, 0, 6067, 342, 168, -148, 430, -69, -6, -96,
- 151, 0, 0, 0, -87, 0, 0, 0,
-};
-#define YYTABLESIZE 6408
-short yytable[] = { 87,
- 5, 253, 91, 93, 254, 136, 16, 97, 174, 203,
- 107, 289, 108, 110, 112, 114, 109, 111, 113, 134,
- 209, 105, 211, 201, 213, 99, 215, 17, 145, 18,
- 148, 174, 101, 5, 174, 121, 118, 104, 309, 237,
- 5, 238, 312, 5, 18, 5, 174, 18, 153, 155,
- 144, 223, 224, 225, 226, 227, 228, 174, 150, 5,
- 148, 328, 147, 38, 4, 189, 190, 308, 191, 2,
- 21, 5, 253, 135, 86, 254, 315, 316, 100, 146,
- 336, 38, 85, 338, 321, 322, 323, 324, 21, 326,
- 149, 20, 147, 20, 204, 387, 205, 206, 88, 20,
- 20, 20, 39, 6, 22, 304, 407, 305, 174, 39,
- 174, 7, 39, 176, 39, 178, 179, 174, 356, 19,
- 357, 20, 22, 5, 94, 5, 5, 174, 39, 192,
- 193, 365, 335, 187, 188, 189, 190, 19, 191, 20,
- 178, 179, 337, 174, 4, 355, 103, 256, 115, 258,
- 116, 5, 122, 383, 186, 384, 169, 174, 381, 364,
- 189, 190, 123, 191, 178, 186, 306, 370, 178, 174,
- 319, 178, 406, 174, 377, 378, 165, 166, 167, 392,
- 178, 179, 124, 6, 189, 190, 363, 191, 186, 293,
- 186, 7, 39, 374, 389, 39, 291, 174, 187, 188,
- 189, 190, 15, 191, 179, 51, 391, 179, 51, 125,
- 185, 126, 127, 128, 129, 359, 360, 361, 362, 90,
- 92, 186, 134, 399, 367, 130, 131, 132, 133, 403,
- 138, 170, 171, 172, 173, 170, 171, 172, 173, 139,
- 184, 142, 194, 202, 218, 242, 229, 371, 372, 99,
- 412, 186, 119, 241, 99, 243, 5, 5, 5, 244,
- 5, 5, 5, 257, 174, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 186, 135, 394, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 408, 100, 120, 117, 5, 5, 100, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 143, 252,
- 5, 290, 291, 295, 300, 39, 39, 5, 5, 39,
- 39, 39, 301, 302, 303, 39, 39, 39, 39, 39,
- 39, 39, 39, 39, 311, 313, 293, 39, 39, 39,
- 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
- 39, 39, 39, 39, 39, 39, 98, 39, 39, 39,
- 106, 317, 318, 325, 330, 39, 191, 39, 39, 39,
- 39, 39, 39, 39, 39, 39, 39, 341, 353, 39,
- 186, 314, 368, 373, 141, 380, 39, 39, 420, 320,
- 385, 386, 393, 395, 396, 398, 327, 400, 156, 401,
- 404, 405, 409, 411, 413, 68, 415, 176, 177, 178,
- 179, 416, 72, 195, 418, 75, 419, 74, 186, 186,
- 186, 186, 197, 421, 200, 183, 37, 187, 188, 189,
- 190, 73, 191, 35, 179, 186, 186, 18, 186, 186,
- 186, 186, 37, 186, 186, 186, 216, 48, 35, 78,
- 410, 366, 197, 197, 197, 197, 197, 197, 0, 0,
- 232, 233, 234, 235, 236, 0, 0, 0, 0, 0,
- 239, 0, 369, 0, 39, 0, 0, 0, 375, 376,
- 0, 39, 0, 379, 39, 0, 39, 157, 158, 159,
- 160, 0, 0, 163, 164, 20, 0, 0, 69, 0,
- 39, 186, 0, 0, 0, 263, 264, 265, 266, 268,
- 270, 271, 272, 273, 274, 276, 278, 280, 282, 284,
- 285, 286, 288, 0, 0, 0, 0, 397, 176, 177,
- 178, 179, 0, 0, 402, 0, 0, 0, 0, 186,
- 0, 0, 0, 0, 0, 0, 0, 0, 187, 188,
- 189, 190, 0, 191, 0, 0, 0, 185, 0, 0,
- 414, 0, 0, 0, 39, 0, 0, 39, 0, 417,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 68, 263, 0, 184, 0, 0,
- 0, 72, 0, 0, 75, 185, 74, 0, 343, 0,
- 344, 0, 0, 0, 0, 0, 346, 0, 347, 0,
- 348, 0, 349, 0, 350, 0, 0, 0, 351, 0,
- 0, 0, 0, 0, 354, 184, 0, 0, 19, 21,
- 0, 0, 22, 23, 24, 0, 0, 0, 25, 26,
- 27, 28, 29, 30, 31, 32, 33, 0, 197, 197,
- 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 52, 0,
- 53, 54, 55, 0, 20, 0, 390, 69, 56, 0,
- 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
- 0, 0, 67, 0, 0, 0, 0, 39, 39, 70,
- 71, 39, 39, 39, 0, 0, 0, 39, 39, 39,
- 39, 39, 39, 39, 39, 39, 0, 0, 0, 39,
- 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
- 39, 39, 39, 39, 39, 39, 39, 39, 0, 39,
- 39, 39, 0, 0, 0, 0, 0, 39, 0, 39,
- 39, 39, 39, 39, 39, 39, 39, 39, 39, 0,
- 0, 39, 0, 68, 176, 177, 178, 179, 39, 39,
- 72, 0, 0, 75, 0, 74, 176, 177, 178, 179,
- 0, 182, 183, 0, 187, 188, 189, 190, 0, 191,
- 0, 0, 0, 0, 0, 0, 187, 188, 189, 190,
- 0, 191, 176, 177, 178, 179, 0, 0, 95, 0,
- 0, 22, 23, 24, 0, 0, 0, 25, 26, 27,
- 28, 29, 187, 188, 189, 190, 0, 191, 0, 34,
- 35, 0, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 0, 53,
- 54, 55, 0, 20, 0, 0, 69, 56, 0, 96,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 0,
- 68, 67, 0, 0, 0, 0, 0, 72, 70, 71,
- 75, 0, 74, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 68, 0, 0, 0, 0, 0,
- 0, 72, 161, 0, 75, 0, 74, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 20, 0, 0, 69, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 186, 0, 0, 0, 0, 0, 151, 0, 0,
- 22, 23, 24, 0, 0, 0, 25, 26, 27, 28,
- 29, 345, 0, 0, 180, 0, 181, 0, 34, 35,
- 0, 37, 38, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 52, 69, 53, 54,
- 55, 0, 0, 0, 0, 0, 56, 185, 152, 58,
- 59, 60, 61, 62, 63, 64, 65, 66, 0, 68,
- 67, 0, 0, 0, 0, 0, 72, 70, 71, 75,
- 71, 74, 0, 71, 0, 0, 0, 184, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 71, 71, 0,
- 71, 0, 71, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 21, 0, 0, 22, 23, 24,
- 0, 0, 0, 25, 26, 27, 28, 29, 0, 0,
- 0, 0, 71, 0, 0, 34, 35, 0, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 0, 53, 54, 55, 0, 0,
- 0, 0, 69, 56, 0, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 0, 0, 67, 21, 0,
- 0, 22, 23, 24, 70, 71, 68, 25, 26, 27,
- 28, 29, 0, 72, 222, 0, 75, 0, 74, 34,
- 35, 0, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 0, 53,
- 54, 55, 0, 0, 0, 0, 175, 56, 0, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 0,
- 0, 67, 0, 0, 0, 0, 0, 0, 70, 71,
- 68, 0, 0, 0, 0, 0, 0, 72, 230, 0,
- 75, 0, 74, 0, 176, 177, 178, 179, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 69,
- 0, 182, 183, 0, 187, 188, 189, 190, 0, 191,
- 0, 0, 19, 21, 0, 0, 22, 23, 24, 0,
- 0, 0, 25, 26, 27, 28, 29, 0, 0, 0,
- 71, 71, 71, 71, 34, 35, 0, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 52, 0, 53, 54, 55, 0, 0, 0,
- 0, 0, 56, 69, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 0, 0, 67, 0, 0, 0,
- 0, 68, 0, 70, 71, 0, 71, 71, 72, 0,
- 0, 75, 0, 74, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 267,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 199, 0, 0, 22, 23, 24, 0, 0, 0, 25,
- 26, 27, 28, 29, 0, 0, 0, 0, 0, 0,
- 0, 34, 35, 0, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 0, 53, 54, 55, 69, 0, 0, 0, 0, 56,
- 0, 57, 58, 59, 60, 61, 62, 63, 64, 65,
- 66, 0, 72, 67, 21, 72, 0, 22, 23, 24,
- 70, 71, 0, 25, 26, 27, 28, 29, 0, 72,
- 72, 0, 72, 0, 72, 34, 35, 0, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 0, 53, 54, 55, 0, 0,
- 0, 0, 0, 56, 72, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 0, 68, 67, 0, 0,
- 0, 0, 0, 72, 70, 71, 75, 0, 74, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 269, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 21, 0, 0, 22, 23,
- 24, 0, 0, 0, 25, 26, 27, 28, 29, 0,
- 0, 0, 0, 0, 0, 0, 34, 35, 0, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 0, 53, 54, 55, 69,
- 0, 0, 74, 0, 56, 74, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 0, 68, 67, 74,
- 74, 0, 74, 0, 72, 70, 71, 75, 0, 74,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 275, 0, 0, 0, 0,
- 0, 0, 0, 0, 74, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 72, 0, 0, 0, 0, 0,
- 0, 0, 72, 72, 72, 72, 0, 0, 0, 0,
- 0, 68, 0, 0, 0, 0, 0, 0, 72, 0,
- 0, 75, 0, 74, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 277,
- 69, 0, 0, 0, 0, 0, 0, 0, 0, 72,
- 72, 0, 0, 0, 186, 0, 0, 0, 72, 72,
- 21, 0, 0, 22, 23, 24, 0, 0, 0, 25,
- 26, 27, 28, 29, 0, 0, 0, 180, 0, 181,
- 0, 34, 35, 0, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 0, 53, 54, 55, 69, 0, 0, 0, 0, 56,
- 185, 57, 58, 59, 60, 61, 62, 63, 64, 65,
- 66, 0, 68, 67, 0, 0, 0, 0, 0, 72,
- 70, 71, 75, 0, 74, 0, 0, 0, 0, 0,
- 184, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 279, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 74, 74, 74, 74, 0, 0, 0, 0,
- 0, 21, 0, 0, 22, 23, 24, 0, 0, 0,
- 25, 26, 27, 28, 29, 0, 0, 0, 0, 0,
- 0, 0, 34, 35, 0, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 0, 53, 54, 55, 69, 0, 0, 74, 74,
- 56, 0, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 0, 73, 67, 21, 73, 0, 22, 23,
- 24, 70, 71, 0, 25, 26, 27, 28, 29, 0,
- 73, 73, 0, 73, 0, 73, 34, 35, 0, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 0, 53, 54, 55, 175,
- 0, 0, 0, 0, 56, 73, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 0, 68, 67, 0,
- 0, 0, 0, 0, 72, 70, 71, 75, 0, 74,
- 0, 0, 0, 0, 0, 0, 0, 176, 177, 178,
- 179, 0, 0, 0, 0, 281, 0, 0, 0, 0,
- 0, 0, 0, 0, 182, 183, 186, 187, 188, 189,
- 190, 0, 191, 0, 0, 0, 21, 0, 0, 22,
- 23, 24, 0, 0, 0, 25, 26, 27, 28, 29,
- 0, 181, 0, 0, 0, 0, 0, 34, 35, 0,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 0, 53, 54, 55,
- 69, 0, 185, 0, 0, 56, 0, 57, 58, 59,
- 60, 61, 62, 63, 64, 65, 66, 0, 68, 67,
- 0, 0, 0, 0, 0, 72, 70, 71, 75, 0,
- 74, 0, 184, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 283, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 73, 0, 0, 0, 0,
- 0, 0, 0, 73, 73, 73, 73, 0, 0, 0,
- 0, 0, 68, 0, 0, 0, 0, 0, 0, 72,
- 0, 0, 75, 0, 74, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 287, 69, 0, 0, 0, 0, 0, 0, 0, 0,
- 73, 0, 0, 0, 0, 0, 0, 0, 0, 73,
- 73, 21, 0, 0, 22, 23, 24, 0, 0, 0,
- 25, 26, 27, 28, 29, 0, 0, 0, 0, 0,
- 0, 0, 34, 35, 0, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 175, 53, 54, 55, 69, 0, 0, 0, 0,
- 56, 0, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 0, 0, 67, 0, 68, 0, 0, 0,
- 0, 70, 71, 72, 296, 0, 75, 0, 74, 176,
- 177, 178, 179, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 182, 183, 0, 187,
- 188, 189, 190, 0, 191, 0, 0, 0, 0, 0,
- 0, 0, 21, 0, 0, 22, 23, 24, 0, 0,
- 0, 25, 26, 27, 28, 29, 0, 0, 0, 0,
- 0, 0, 0, 34, 35, 0, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 0, 53, 54, 55, 0, 0, 0, 69,
- 0, 56, 0, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 0, 0, 67, 21, 0, 0, 22,
- 23, 24, 70, 71, 68, 25, 26, 27, 28, 29,
- 0, 72, 298, 0, 75, 0, 74, 34, 35, 0,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 0, 53, 54, 55,
- 0, 0, 0, 0, 0, 56, 0, 57, 58, 59,
- 60, 61, 62, 63, 64, 65, 66, 0, 0, 67,
- 0, 0, 0, 0, 0, 0, 70, 71, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
- 0, 0, 0, 0, 0, 72, 331, 0, 75, 0,
- 74, 0, 0, 0, 0, 0, 0, 69, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 21, 0, 0, 22, 23, 24, 0, 0, 0, 25,
- 26, 27, 28, 29, 0, 0, 0, 0, 0, 0,
- 0, 34, 35, 0, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 0, 53, 54, 55, 0, 0, 0, 0, 0, 56,
- 0, 57, 58, 59, 60, 61, 62, 63, 64, 65,
- 66, 69, 0, 67, 0, 68, 0, 0, 0, 0,
- 70, 71, 72, 333, 0, 75, 0, 74, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 21, 0,
- 0, 22, 23, 24, 0, 0, 0, 25, 26, 27,
- 28, 29, 0, 0, 0, 0, 0, 0, 0, 34,
- 35, 0, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 69, 53,
- 54, 55, 0, 0, 0, 0, 0, 56, 0, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 0,
- 0, 67, 0, 0, 186, 0, 0, 0, 70, 71,
- 178, 0, 21, 0, 0, 22, 23, 24, 0, 0,
- 0, 25, 26, 27, 28, 29, 0, 186, 0, 186,
- 0, 0, 0, 34, 35, 0, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 0, 53, 54, 55, 0, 0, 0, 0,
- 186, 56, 0, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 0, 0, 67, 0, 68, 0, 0,
- 0, 0, 70, 71, 72, 340, 0, 75, 0, 74,
- 186, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
- 0, 0, 22, 23, 24, 0, 0, 0, 25, 26,
- 27, 28, 29, 0, 0, 0, 0, 0, 0, 0,
- 34, 35, 0, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 52, 0,
- 53, 54, 55, 0, 0, 0, 50, 0, 56, 50,
- 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
- 69, 68, 67, 50, 50, 0, 0, 0, 72, 70,
- 71, 75, 0, 74, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 50, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 186,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
- 0, 0, 0, 0, 0, 72, 0, 0, 75, 0,
- 74, 0, 0, 0, 69, 0, 0, 186, 186, 186,
- 186, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 186, 186, 0, 186, 186, 186,
- 186, 0, 186, 186, 186, 0, 0, 0, 0, 0,
- 0, 21, 0, 0, 22, 23, 24, 0, 0, 0,
- 25, 26, 27, 28, 29, 0, 0, 0, 0, 0,
- 0, 0, 34, 35, 0, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 69, 53, 54, 55, 0, 0, 0, 0, 0,
- 56, 0, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 0, 68, 67, 0, 0, 0, 0, 0,
- 72, 70, 71, 75, 0, 74, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 50, 50, 50, 50,
- 0, 0, 0, 0, 0, 21, 0, 0, 22, 23,
- 24, 0, 0, 0, 25, 26, 27, 28, 29, 0,
- 0, 0, 0, 0, 0, 0, 34, 35, 0, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 0, 53, 54, 55, 0,
- 0, 0, 50, 50, 56, 0, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 69, 68, 67, 0,
- 0, 0, 0, 0, 72, 70, 71, 75, 0, 74,
- 0, 0, 140, 0, 0, 22, 23, 24, 0, 0,
- 0, 25, 26, 27, 28, 29, 0, 0, 0, 0,
- 0, 0, 0, 34, 35, 0, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 0, 53, 54, 55, 0, 0, 0, 0,
- 0, 56, 0, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 0, 0, 67, 0, 0, 0, 0,
- 0, 0, 70, 71, 0, 0, 126, 0, 0, 126,
- 69, 0, 126, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 126, 126, 0, 126,
- 0, 126, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 196, 0, 0,
- 22, 23, 24, 0, 0, 0, 25, 26, 27, 28,
- 29, 126, 126, 0, 0, 0, 0, 0, 34, 35,
- 0, 37, 38, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 52, 0, 53, 54,
- 55, 0, 126, 0, 0, 0, 56, 0, 57, 58,
- 59, 60, 61, 62, 63, 64, 65, 66, 0, 0,
- 67, 0, 0, 0, 0, 0, 0, 70, 71, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 199, 0, 0, 22, 23, 24, 0, 0, 0,
- 25, 26, 27, 28, 29, 0, 0, 0, 0, 0,
- 0, 0, 34, 35, 0, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 0, 53, 54, 55, 0, 0, 0, 0, 0,
- 56, 0, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 121, 0, 67, 121, 0, 0, 121, 0,
- 0, 70, 71, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 121, 121, 0, 121, 67, 121, 0, 67,
- 0, 126, 67, 0, 0, 0, 0, 0, 0, 126,
- 126, 126, 126, 0, 0, 0, 67, 67, 0, 67,
- 0, 67, 0, 0, 0, 0, 0, 121, 121, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 126,
- 126, 126, 126, 0, 0, 0, 0, 148, 0, 0,
- 148, 67, 67, 148, 0, 0, 126, 126, 121, 126,
- 126, 126, 126, 0, 126, 126, 126, 148, 148, 0,
- 148, 0, 148, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 67, 0, 149, 0, 0, 149, 0, 0,
- 149, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 148, 148, 149, 149, 0, 149, 0, 149,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 137, 0, 0, 137,
- 0, 0, 137, 148, 0, 0, 0, 0, 0, 149,
- 149, 0, 0, 0, 0, 0, 137, 137, 0, 137,
- 0, 137, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 157, 0, 0, 157, 0, 0, 157,
- 149, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 137, 137, 157, 157, 0, 157, 0, 157, 0,
- 0, 0, 0, 0, 0, 0, 0, 121, 0, 0,
- 0, 0, 0, 0, 0, 121, 121, 121, 121, 0,
- 0, 0, 137, 0, 0, 0, 0, 0, 157, 157,
- 0, 67, 0, 0, 0, 0, 0, 0, 0, 67,
- 67, 67, 67, 0, 0, 121, 121, 121, 121, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 94, 157,
- 0, 94, 121, 121, 94, 121, 121, 121, 121, 0,
- 121, 121, 121, 0, 0, 0, 0, 0, 94, 94,
- 0, 94, 148, 94, 0, 0, 67, 67, 0, 0,
- 148, 148, 148, 148, 0, 67, 67, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 94, 94, 0, 0, 0, 0, 149,
- 148, 148, 148, 148, 0, 0, 0, 149, 149, 149,
- 149, 0, 0, 49, 0, 0, 49, 148, 148, 0,
- 148, 148, 148, 148, 94, 148, 148, 148, 0, 0,
- 49, 49, 0, 0, 0, 0, 0, 149, 149, 149,
- 149, 137, 0, 0, 0, 0, 0, 0, 0, 137,
- 137, 137, 137, 0, 149, 149, 0, 149, 149, 149,
- 149, 0, 149, 149, 149, 49, 0, 0, 0, 0,
- 98, 0, 0, 98, 0, 0, 98, 0, 157, 137,
- 137, 137, 137, 0, 0, 0, 157, 157, 157, 157,
- 98, 98, 0, 98, 0, 98, 137, 137, 0, 137,
- 137, 137, 137, 0, 137, 137, 137, 0, 0, 0,
- 52, 0, 0, 52, 0, 0, 157, 157, 157, 157,
- 0, 0, 0, 0, 0, 98, 98, 52, 52, 0,
- 0, 0, 0, 157, 157, 0, 157, 157, 157, 157,
- 0, 157, 157, 157, 186, 0, 0, 186, 0, 0,
- 186, 0, 0, 0, 0, 0, 98, 0, 54, 0,
- 0, 54, 52, 94, 186, 186, 0, 186, 0, 186,
- 0, 94, 94, 94, 94, 54, 54, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 115, 0, 0, 115,
- 0, 0, 115, 0, 0, 0, 0, 0, 0, 186,
- 186, 94, 94, 94, 94, 0, 115, 115, 0, 115,
- 54, 115, 0, 0, 0, 0, 0, 0, 94, 94,
- 0, 94, 94, 94, 94, 0, 94, 94, 94, 120,
- 186, 0, 120, 0, 0, 120, 0, 0, 0, 0,
- 0, 115, 115, 49, 49, 49, 49, 0, 0, 120,
- 120, 0, 120, 0, 120, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 91, 115, 0, 91, 0, 0, 91, 0, 0,
- 0, 0, 0, 0, 120, 120, 0, 0, 0, 0,
- 0, 91, 91, 0, 91, 98, 91, 0, 0, 49,
- 49, 0, 0, 98, 98, 98, 98, 0, 0, 0,
- 0, 0, 0, 0, 0, 120, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 91, 91, 0, 0,
- 0, 0, 0, 98, 98, 98, 98, 0, 0, 0,
- 52, 52, 52, 52, 0, 0, 0, 0, 0, 0,
- 98, 98, 0, 98, 98, 98, 98, 91, 98, 98,
- 98, 90, 0, 0, 90, 0, 0, 90, 0, 186,
- 0, 0, 0, 0, 0, 0, 0, 186, 186, 186,
- 186, 90, 90, 0, 90, 0, 90, 0, 54, 54,
- 54, 54, 0, 0, 0, 0, 52, 52, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 186, 186, 186,
- 186, 115, 0, 0, 0, 0, 90, 90, 0, 115,
- 115, 115, 115, 0, 186, 186, 0, 186, 186, 186,
- 186, 0, 186, 186, 186, 173, 0, 0, 173, 0,
- 0, 0, 0, 0, 54, 54, 0, 90, 0, 115,
- 115, 115, 115, 0, 120, 173, 173, 0, 173, 0,
- 173, 0, 120, 120, 120, 120, 115, 115, 0, 115,
- 115, 115, 115, 0, 115, 115, 115, 175, 0, 0,
- 175, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 173, 173, 120, 120, 120, 120, 91, 175, 175, 0,
- 175, 0, 175, 0, 91, 91, 91, 91, 0, 120,
- 120, 0, 120, 120, 120, 120, 0, 120, 120, 120,
- 176, 173, 0, 176, 0, 0, 0, 0, 0, 0,
- 0, 0, 175, 175, 91, 91, 91, 91, 0, 0,
- 176, 176, 0, 176, 0, 176, 0, 0, 0, 0,
- 0, 91, 91, 0, 91, 91, 91, 91, 0, 91,
- 91, 91, 177, 175, 0, 177, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 176, 176, 0, 0, 0,
- 0, 0, 177, 177, 0, 177, 90, 177, 0, 0,
- 0, 0, 0, 0, 90, 90, 90, 90, 0, 0,
- 0, 0, 0, 0, 0, 0, 176, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 177, 177, 0,
- 0, 0, 0, 0, 90, 90, 90, 90, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 90, 90, 0, 90, 90, 90, 90, 177, 90,
- 90, 90, 75, 0, 0, 75, 0, 0, 75, 0,
- 173, 0, 0, 0, 0, 0, 0, 0, 173, 173,
- 173, 173, 75, 75, 0, 75, 0, 75, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 173, 173,
- 173, 173, 175, 0, 0, 0, 0, 75, 75, 0,
- 175, 175, 175, 175, 0, 173, 173, 0, 173, 173,
- 173, 173, 0, 173, 173, 173, 76, 0, 0, 76,
- 0, 0, 76, 0, 0, 0, 0, 0, 75, 0,
- 175, 175, 175, 175, 0, 176, 76, 76, 0, 76,
- 0, 76, 0, 176, 176, 176, 176, 175, 175, 0,
- 175, 175, 175, 175, 0, 175, 175, 175, 61, 0,
- 0, 61, 0, 0, 61, 0, 0, 0, 0, 0,
- 0, 76, 76, 176, 176, 176, 176, 177, 61, 61,
- 0, 61, 0, 61, 0, 177, 177, 177, 177, 0,
- 176, 176, 0, 176, 176, 176, 176, 0, 176, 176,
- 176, 62, 76, 0, 62, 0, 0, 62, 0, 0,
- 0, 0, 0, 61, 61, 177, 177, 177, 177, 0,
- 0, 62, 62, 0, 62, 0, 62, 0, 0, 0,
- 0, 0, 177, 177, 0, 177, 177, 177, 177, 0,
- 177, 177, 177, 63, 61, 0, 63, 0, 0, 63,
- 0, 0, 0, 0, 0, 0, 62, 62, 0, 0,
- 0, 0, 0, 63, 63, 0, 63, 75, 63, 0,
- 0, 0, 0, 0, 0, 75, 75, 75, 75, 0,
- 0, 0, 0, 0, 0, 0, 0, 62, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 63, 63,
- 0, 0, 0, 0, 0, 75, 75, 75, 75, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 75, 75, 0, 75, 75, 75, 75, 63,
- 0, 75, 75, 64, 0, 0, 64, 0, 0, 64,
- 0, 76, 0, 0, 0, 0, 0, 0, 0, 76,
- 76, 76, 76, 64, 64, 0, 64, 0, 64, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 55, 0,
- 0, 55, 0, 0, 0, 0, 0, 0, 0, 76,
- 76, 76, 76, 61, 0, 55, 55, 0, 64, 64,
- 0, 61, 61, 61, 61, 0, 76, 76, 0, 76,
- 76, 76, 76, 0, 0, 76, 76, 65, 0, 0,
- 65, 0, 0, 65, 0, 0, 0, 0, 0, 64,
- 55, 61, 61, 61, 61, 0, 62, 65, 65, 0,
- 65, 0, 65, 0, 62, 62, 62, 62, 61, 61,
- 0, 61, 61, 61, 61, 0, 0, 61, 61, 92,
- 0, 0, 92, 0, 0, 92, 0, 0, 0, 0,
- 0, 0, 65, 65, 62, 62, 62, 62, 63, 92,
- 92, 0, 92, 0, 92, 0, 63, 63, 63, 63,
- 0, 62, 62, 0, 62, 62, 0, 0, 0, 0,
- 62, 62, 87, 65, 0, 87, 0, 0, 87, 0,
- 0, 0, 0, 0, 92, 92, 63, 63, 0, 63,
- 0, 0, 87, 87, 0, 87, 125, 87, 0, 125,
- 0, 0, 125, 63, 63, 0, 63, 63, 60, 0,
- 0, 60, 63, 63, 0, 92, 125, 125, 0, 125,
- 0, 125, 0, 0, 0, 60, 60, 87, 87, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 64, 0,
- 0, 0, 0, 0, 0, 0, 64, 64, 64, 64,
- 0, 125, 125, 0, 0, 0, 0, 0, 87, 0,
- 60, 0, 0, 66, 0, 0, 66, 0, 0, 66,
- 0, 0, 0, 0, 0, 0, 64, 64, 55, 55,
- 55, 55, 125, 66, 66, 0, 66, 0, 66, 0,
- 0, 0, 0, 64, 64, 0, 64, 64, 0, 0,
- 0, 0, 64, 64, 68, 0, 0, 68, 0, 0,
- 68, 0, 65, 0, 0, 0, 0, 0, 66, 66,
- 65, 65, 65, 65, 68, 68, 0, 68, 0, 68,
- 0, 0, 0, 0, 55, 55, 0, 0, 0, 59,
- 0, 0, 59, 0, 0, 0, 0, 0, 0, 66,
- 65, 65, 0, 0, 92, 0, 59, 59, 0, 68,
- 68, 0, 92, 92, 92, 92, 0, 65, 65, 0,
- 65, 65, 0, 0, 0, 0, 65, 65, 156, 0,
- 0, 156, 0, 0, 156, 0, 0, 0, 0, 0,
- 68, 59, 92, 92, 0, 0, 0, 87, 156, 156,
- 0, 156, 0, 156, 0, 87, 87, 87, 87, 92,
- 92, 0, 0, 0, 0, 0, 0, 0, 92, 92,
- 0, 125, 0, 0, 0, 0, 0, 0, 0, 125,
- 125, 125, 125, 156, 156, 87, 87, 0, 60, 60,
- 60, 60, 0, 0, 0, 88, 0, 0, 88, 0,
- 0, 88, 87, 87, 58, 0, 0, 58, 0, 125,
- 125, 87, 87, 0, 156, 88, 88, 0, 88, 0,
- 88, 58, 58, 0, 0, 0, 125, 125, 0, 0,
- 0, 0, 0, 0, 0, 125, 125, 0, 66, 0,
- 0, 0, 0, 0, 60, 60, 66, 66, 66, 66,
- 88, 88, 0, 0, 0, 0, 58, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 66, 0, 68,
- 0, 88, 0, 0, 0, 0, 0, 68, 68, 68,
- 68, 0, 172, 66, 66, 172, 0, 0, 172, 0,
- 0, 0, 66, 66, 123, 0, 0, 123, 0, 0,
- 123, 0, 172, 172, 0, 172, 0, 172, 0, 59,
- 59, 59, 59, 0, 123, 123, 0, 123, 0, 123,
- 0, 0, 0, 0, 68, 68, 0, 0, 0, 0,
- 0, 0, 0, 68, 68, 0, 0, 172, 172, 0,
- 0, 0, 0, 156, 0, 0, 0, 0, 0, 123,
- 123, 156, 156, 156, 156, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 59, 59, 77, 172, 0,
- 77, 0, 0, 77, 0, 0, 0, 0, 0, 0,
- 123, 156, 156, 156, 156, 0, 0, 77, 77, 0,
- 77, 0, 77, 0, 0, 0, 0, 0, 156, 156,
- 0, 156, 156, 156, 156, 0, 156, 0, 0, 0,
- 88, 0, 0, 0, 0, 0, 0, 0, 88, 88,
- 88, 88, 77, 77, 58, 58, 58, 58, 0, 0,
- 0, 0, 0, 0, 174, 0, 0, 174, 0, 0,
- 174, 0, 0, 0, 0, 0, 0, 0, 88, 88,
- 88, 88, 0, 77, 174, 174, 0, 174, 0, 174,
- 56, 0, 0, 56, 0, 88, 88, 0, 88, 88,
- 88, 88, 0, 88, 0, 0, 0, 56, 56, 0,
- 58, 58, 0, 0, 0, 0, 0, 0, 0, 174,
- 174, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 172, 0, 0,
- 0, 0, 56, 0, 0, 172, 172, 172, 172, 123,
- 174, 0, 0, 0, 0, 0, 0, 123, 123, 123,
- 123, 80, 0, 0, 80, 0, 0, 80, 0, 0,
- 0, 0, 0, 0, 0, 172, 172, 172, 172, 0,
- 0, 80, 80, 0, 80, 0, 80, 123, 123, 123,
- 123, 0, 172, 172, 0, 172, 172, 172, 172, 0,
- 172, 0, 0, 0, 123, 123, 0, 123, 123, 123,
- 123, 0, 123, 0, 0, 0, 80, 80, 81, 0,
- 0, 81, 77, 0, 81, 0, 0, 0, 0, 0,
- 77, 77, 77, 77, 0, 0, 0, 0, 81, 81,
- 0, 81, 0, 81, 0, 186, 0, 80, 307, 0,
- 0, 293, 0, 0, 0, 0, 0, 0, 0, 0,
- 77, 77, 77, 77, 0, 0, 0, 0, 180, 0,
- 181, 0, 0, 81, 81, 0, 0, 77, 77, 0,
- 77, 77, 77, 77, 0, 77, 0, 78, 0, 174,
- 78, 0, 0, 78, 0, 0, 0, 174, 174, 174,
- 174, 185, 0, 0, 81, 0, 0, 78, 78, 0,
- 78, 0, 78, 79, 0, 0, 79, 0, 0, 79,
- 56, 56, 56, 56, 0, 0, 0, 174, 174, 174,
- 174, 184, 0, 79, 79, 0, 79, 0, 79, 0,
- 0, 0, 78, 78, 174, 174, 0, 174, 174, 174,
- 174, 0, 174, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 186, 0, 0, 0, 79, 79,
- 293, 0, 0, 78, 0, 186, 56, 56, 0, 0,
- 0, 291, 0, 0, 0, 0, 80, 180, 57, 181,
- 0, 57, 0, 0, 80, 80, 80, 80, 180, 79,
- 181, 0, 0, 0, 0, 57, 57, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 185, 0, 0, 0, 80, 80, 80, 80, 0, 0,
- 0, 185, 0, 0, 0, 0, 0, 0, 0, 0,
- 57, 80, 80, 81, 80, 80, 80, 80, 0, 80,
- 184, 81, 81, 81, 81, 0, 0, 0, 0, 0,
- 0, 184, 0, 0, 0, 0, 68, 0, 0, 0,
- 175, 0, 0, 72, 0, 0, 75, 0, 74, 0,
- 0, 81, 81, 81, 81, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 81, 81,
- 0, 81, 81, 81, 81, 0, 81, 0, 176, 177,
- 178, 179, 78, 0, 0, 0, 0, 0, 0, 0,
- 78, 78, 78, 78, 148, 182, 183, 0, 187, 188,
- 189, 190, 0, 191, 0, 0, 0, 0, 79, 0,
- 53, 0, 0, 53, 0, 0, 79, 79, 79, 79,
- 78, 78, 78, 78, 0, 0, 147, 53, 53, 69,
- 0, 0, 0, 70, 0, 0, 70, 78, 78, 0,
- 78, 78, 78, 78, 0, 78, 79, 79, 79, 79,
- 70, 70, 0, 70, 0, 70, 0, 0, 0, 175,
- 0, 0, 53, 79, 79, 0, 79, 79, 79, 79,
- 175, 79, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 69, 70, 70, 69, 57, 57,
- 57, 57, 0, 0, 0, 0, 0, 176, 177, 178,
- 179, 69, 69, 0, 69, 0, 69, 0, 176, 177,
- 178, 179, 0, 0, 182, 183, 70, 187, 188, 189,
- 190, 0, 191, 0, 0, 182, 183, 0, 187, 188,
- 189, 190, 0, 191, 0, 0, 69, 69, 0, 0,
- 0, 0, 0, 0, 57, 57, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 21, 0, 0, 22, 23, 24, 0, 69, 0, 25,
- 26, 27, 28, 29, 0, 0, 0, 0, 0, 0,
- 0, 34, 35, 0, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 0, 53, 54, 55, 0, 0, 0, 0, 0, 56,
- 0, 57, 58, 59, 60, 61, 62, 63, 64, 65,
- 66, 0, 0, 67, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 53, 53, 53, 53, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 70, 0, 0, 0, 0,
- 0, 0, 0, 70, 70, 70, 70, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 154, 0, 0, 0, 0, 0, 162, 0,
- 0, 0, 0, 0, 0, 0, 53, 53, 0, 0,
- 0, 0, 0, 0, 0, 0, 69, 0, 0, 0,
- 70, 70, 0, 0, 69, 69, 69, 69, 0, 70,
- 70, 0, 0, 207, 0, 210, 0, 212, 0, 214,
- 0, 0, 217, 0, 221, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 231, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 240, 0,
- 0, 69, 69, 245, 246, 247, 248, 249, 250, 251,
- 69, 69, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 259, 260, 261, 262,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 297, 299,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 310, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 329, 0, 332,
- 334, 0, 0, 0, 0, 0, 0, 0, 339, 0,
- 0, 0, 0, 342, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 352, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 358, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 207, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 382, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 388,
-};
-short yycheck[] = { 17,
- 0, 41, 40, 40, 44, 40, 61, 25, 44, 40,
- 40, 125, 30, 31, 32, 33, 40, 40, 40, 257,
- 108, 28, 110, 93, 112, 257, 114, 257, 257, 41,
- 91, 44, 40, 33, 44, 40, 40, 40, 217, 136,
- 40, 138, 221, 43, 257, 45, 44, 59, 66, 67,
- 40, 121, 122, 123, 124, 125, 126, 44, 91, 59,
- 91, 240, 123, 41, 258, 323, 324, 216, 326, 0,
- 41, 265, 41, 311, 307, 44, 225, 226, 310, 308,
- 93, 59, 61, 93, 233, 234, 235, 236, 59, 238,
- 123, 123, 123, 123, 101, 93, 103, 104, 59, 123,
- 123, 123, 33, 297, 41, 41, 93, 41, 44, 40,
- 44, 305, 43, 301, 45, 303, 304, 44, 297, 41,
- 299, 41, 59, 123, 257, 125, 126, 44, 59, 327,
- 328, 310, 59, 321, 322, 323, 324, 59, 326, 59,
- 303, 304, 59, 44, 258, 294, 40, 165, 40, 167,
- 40, 265, 40, 332, 38, 334, 59, 44, 59, 308,
- 323, 324, 40, 326, 303, 38, 41, 316, 41, 44,
- 41, 44, 59, 44, 323, 324, 275, 276, 277, 358,
- 303, 304, 40, 297, 323, 324, 41, 326, 61, 44,
- 63, 305, 123, 41, 41, 126, 44, 44, 321, 322,
- 323, 324, 257, 326, 41, 41, 355, 44, 44, 40,
- 94, 40, 40, 40, 40, 303, 304, 305, 306, 257,
- 257, 94, 257, 372, 312, 40, 40, 40, 40, 378,
- 40, 271, 272, 273, 274, 271, 272, 273, 274, 40,
- 124, 40, 307, 40, 40, 308, 41, 317, 318, 257,
- 399, 124, 257, 123, 257, 40, 256, 257, 258, 40,
- 260, 261, 262, 40, 44, 265, 266, 267, 268, 269,
- 270, 271, 272, 273, 274, 38, 311, 365, 278, 279,
- 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
- 290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
- 300, 389, 310, 308, 308, 305, 306, 310, 308, 309,
- 310, 311, 312, 313, 314, 315, 316, 317, 308, 91,
- 320, 41, 44, 41, 41, 256, 257, 327, 328, 260,
- 261, 262, 44, 41, 41, 266, 267, 268, 269, 270,
- 271, 272, 273, 274, 59, 41, 44, 278, 279, 280,
- 281, 282, 283, 284, 285, 286, 287, 288, 289, 290,
- 291, 292, 293, 294, 295, 296, 25, 298, 299, 300,
- 29, 44, 44, 41, 123, 306, 326, 308, 309, 310,
- 311, 312, 313, 314, 315, 316, 317, 91, 41, 320,
- 263, 224, 41, 41, 53, 41, 327, 328, 416, 232,
- 125, 125, 41, 59, 41, 41, 239, 41, 67, 41,
- 41, 125, 41, 41, 41, 33, 125, 301, 302, 303,
- 304, 41, 40, 89, 41, 43, 41, 45, 301, 302,
- 303, 304, 91, 41, 93, 319, 41, 321, 322, 323,
- 324, 59, 326, 59, 41, 318, 319, 59, 321, 322,
- 323, 324, 59, 326, 327, 328, 115, 41, 41, 12,
- 395, 311, 121, 122, 123, 124, 125, 126, -1, -1,
- 129, 130, 131, 132, 133, -1, -1, -1, -1, -1,
- 139, -1, 315, -1, 33, -1, -1, -1, 321, 322,
- -1, 40, -1, 326, 43, -1, 45, 68, 69, 70,
- 71, -1, -1, 74, 75, 123, -1, -1, 126, -1,
- 59, 38, -1, -1, -1, 174, 175, 176, 177, 178,
- 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
- 189, 190, 191, -1, -1, -1, -1, 370, 301, 302,
- 303, 304, -1, -1, 377, -1, -1, -1, -1, 38,
- -1, -1, -1, -1, -1, -1, -1, -1, 321, 322,
- 323, 324, -1, 326, -1, -1, -1, 94, -1, -1,
- 403, -1, -1, -1, 123, -1, -1, 126, -1, 412,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 33, 254, -1, 124, -1, -1,
- -1, 40, -1, -1, 43, 94, 45, -1, 267, -1,
- 269, -1, -1, -1, -1, -1, 275, -1, 277, -1,
- 279, -1, 281, -1, 283, -1, -1, -1, 287, -1,
- -1, -1, -1, -1, 293, 124, -1, -1, 256, 257,
- -1, -1, 260, 261, 262, -1, -1, -1, 266, 267,
- 268, 269, 270, 271, 272, 273, 274, -1, 317, 318,
- 278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
- 288, 289, 290, 291, 292, 293, 294, 295, 296, -1,
- 298, 299, 300, -1, 123, -1, 345, 126, 306, -1,
- 308, 309, 310, 311, 312, 313, 314, 315, 316, 317,
- -1, -1, 320, -1, -1, -1, -1, 256, 257, 327,
- 328, 260, 261, 262, -1, -1, -1, 266, 267, 268,
- 269, 270, 271, 272, 273, 274, -1, -1, -1, 278,
- 279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
- 289, 290, 291, 292, 293, 294, 295, 296, -1, 298,
- 299, 300, -1, -1, -1, -1, -1, 306, -1, 308,
- 309, 310, 311, 312, 313, 314, 315, 316, 317, -1,
- -1, 320, -1, 33, 301, 302, 303, 304, 327, 328,
- 40, -1, -1, 43, -1, 45, 301, 302, 303, 304,
- -1, 318, 319, -1, 321, 322, 323, 324, -1, 326,
- -1, -1, -1, -1, -1, -1, 321, 322, 323, 324,
- -1, 326, 301, 302, 303, 304, -1, -1, 257, -1,
- -1, 260, 261, 262, -1, -1, -1, 266, 267, 268,
- 269, 270, 321, 322, 323, 324, -1, 326, -1, 278,
- 279, -1, 281, 282, 283, 284, 285, 286, 287, 288,
- 289, 290, 291, 292, 293, 294, 295, 296, -1, 298,
- 299, 300, -1, 123, -1, -1, 126, 306, -1, 308,
- 309, 310, 311, 312, 313, 314, 315, 316, 317, -1,
- 33, 320, -1, -1, -1, -1, -1, 40, 327, 328,
- 43, -1, 45, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 33, -1, -1, -1, -1, -1,
- -1, 40, 41, -1, 43, -1, 45, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 123, -1, -1, 126, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 38, -1, -1, -1, -1, -1, 257, -1, -1,
- 260, 261, 262, -1, -1, -1, 266, 267, 268, 269,
- 270, 58, -1, -1, 61, -1, 63, -1, 278, 279,
- -1, 281, 282, 283, 284, 285, 286, 287, 288, 289,
- 290, 291, 292, 293, 294, 295, 296, 126, 298, 299,
- 300, -1, -1, -1, -1, -1, 306, 94, 308, 309,
- 310, 311, 312, 313, 314, 315, 316, 317, -1, 33,
- 320, -1, -1, -1, -1, -1, 40, 327, 328, 43,
- 41, 45, -1, 44, -1, -1, -1, 124, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 58, 59, -1,
- 61, -1, 63, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 257, -1, -1, 260, 261, 262,
- -1, -1, -1, 266, 267, 268, 269, 270, -1, -1,
- -1, -1, 93, -1, -1, 278, 279, -1, 281, 282,
- 283, 284, 285, 286, 287, 288, 289, 290, 291, 292,
- 293, 294, 295, 296, -1, 298, 299, 300, -1, -1,
- -1, -1, 126, 306, -1, 308, 309, 310, 311, 312,
- 313, 314, 315, 316, 317, -1, -1, 320, 257, -1,
- -1, 260, 261, 262, 327, 328, 33, 266, 267, 268,
- 269, 270, -1, 40, 41, -1, 43, -1, 45, 278,
- 279, -1, 281, 282, 283, 284, 285, 286, 287, 288,
- 289, 290, 291, 292, 293, 294, 295, 296, -1, 298,
- 299, 300, -1, -1, -1, -1, 263, 306, -1, 308,
- 309, 310, 311, 312, 313, 314, 315, 316, 317, -1,
- -1, 320, -1, -1, -1, -1, -1, -1, 327, 328,
- 33, -1, -1, -1, -1, -1, -1, 40, 41, -1,
- 43, -1, 45, -1, 301, 302, 303, 304, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 126,
- -1, 318, 319, -1, 321, 322, 323, 324, -1, 326,
- -1, -1, 256, 257, -1, -1, 260, 261, 262, -1,
- -1, -1, 266, 267, 268, 269, 270, -1, -1, -1,
- 271, 272, 273, 274, 278, 279, -1, 281, 282, 283,
- 284, 285, 286, 287, 288, 289, 290, 291, 292, 293,
- 294, 295, 296, -1, 298, 299, 300, -1, -1, -1,
- -1, -1, 306, 126, 308, 309, 310, 311, 312, 313,
- 314, 315, 316, 317, -1, -1, 320, -1, -1, -1,
- -1, 33, -1, 327, 328, -1, 327, 328, 40, -1,
- -1, 43, -1, 45, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 257, -1, -1, 260, 261, 262, -1, -1, -1, 266,
- 267, 268, 269, 270, -1, -1, -1, -1, -1, -1,
- -1, 278, 279, -1, 281, 282, 283, 284, 285, 286,
- 287, 288, 289, 290, 291, 292, 293, 294, 295, 296,
- -1, 298, 299, 300, 126, -1, -1, -1, -1, 306,
- -1, 308, 309, 310, 311, 312, 313, 314, 315, 316,
- 317, -1, 41, 320, 257, 44, -1, 260, 261, 262,
- 327, 328, -1, 266, 267, 268, 269, 270, -1, 58,
- 59, -1, 61, -1, 63, 278, 279, -1, 281, 282,
- 283, 284, 285, 286, 287, 288, 289, 290, 291, 292,
- 293, 294, 295, 296, -1, 298, 299, 300, -1, -1,
- -1, -1, -1, 306, 93, 308, 309, 310, 311, 312,
- 313, 314, 315, 316, 317, -1, 33, 320, -1, -1,
- -1, -1, -1, 40, 327, 328, 43, -1, 45, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 61, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 257, -1, -1, 260, 261,
- 262, -1, -1, -1, 266, 267, 268, 269, 270, -1,
- -1, -1, -1, -1, -1, -1, 278, 279, -1, 281,
- 282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
- 292, 293, 294, 295, 296, -1, 298, 299, 300, 126,
- -1, -1, 41, -1, 306, 44, 308, 309, 310, 311,
- 312, 313, 314, 315, 316, 317, -1, 33, 320, 58,
- 59, -1, 61, -1, 40, 327, 328, 43, -1, 45,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 61, -1, -1, -1, -1,
- -1, -1, -1, -1, 93, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 263, -1, -1, -1, -1, -1,
- -1, -1, 271, 272, 273, 274, -1, -1, -1, -1,
- -1, 33, -1, -1, -1, -1, -1, -1, 40, -1,
- -1, 43, -1, 45, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
- 126, -1, -1, -1, -1, -1, -1, -1, -1, 318,
- 319, -1, -1, -1, 38, -1, -1, -1, 327, 328,
- 257, -1, -1, 260, 261, 262, -1, -1, -1, 266,
- 267, 268, 269, 270, -1, -1, -1, 61, -1, 63,
- -1, 278, 279, -1, 281, 282, 283, 284, 285, 286,
- 287, 288, 289, 290, 291, 292, 293, 294, 295, 296,
- -1, 298, 299, 300, 126, -1, -1, -1, -1, 306,
- 94, 308, 309, 310, 311, 312, 313, 314, 315, 316,
- 317, -1, 33, 320, -1, -1, -1, -1, -1, 40,
- 327, 328, 43, -1, 45, -1, -1, -1, -1, -1,
- 124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 61, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 271, 272, 273, 274, -1, -1, -1, -1,
- -1, 257, -1, -1, 260, 261, 262, -1, -1, -1,
- 266, 267, 268, 269, 270, -1, -1, -1, -1, -1,
- -1, -1, 278, 279, -1, 281, 282, 283, 284, 285,
- 286, 287, 288, 289, 290, 291, 292, 293, 294, 295,
- 296, -1, 298, 299, 300, 126, -1, -1, 327, 328,
- 306, -1, 308, 309, 310, 311, 312, 313, 314, 315,
- 316, 317, -1, 41, 320, 257, 44, -1, 260, 261,
- 262, 327, 328, -1, 266, 267, 268, 269, 270, -1,
- 58, 59, -1, 61, -1, 63, 278, 279, -1, 281,
- 282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
- 292, 293, 294, 295, 296, -1, 298, 299, 300, 263,
- -1, -1, -1, -1, 306, 93, 308, 309, 310, 311,
- 312, 313, 314, 315, 316, 317, -1, 33, 320, -1,
- -1, -1, -1, -1, 40, 327, 328, 43, -1, 45,
- -1, -1, -1, -1, -1, -1, -1, 301, 302, 303,
- 304, -1, -1, -1, -1, 61, -1, -1, -1, -1,
- -1, -1, -1, -1, 318, 319, 38, 321, 322, 323,
- 324, -1, 326, -1, -1, -1, 257, -1, -1, 260,
- 261, 262, -1, -1, -1, 266, 267, 268, 269, 270,
- -1, 63, -1, -1, -1, -1, -1, 278, 279, -1,
- 281, 282, 283, 284, 285, 286, 287, 288, 289, 290,
- 291, 292, 293, 294, 295, 296, -1, 298, 299, 300,
- 126, -1, 94, -1, -1, 306, -1, 308, 309, 310,
- 311, 312, 313, 314, 315, 316, 317, -1, 33, 320,
- -1, -1, -1, -1, -1, 40, 327, 328, 43, -1,
- 45, -1, 124, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 61, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 263, -1, -1, -1, -1,
- -1, -1, -1, 271, 272, 273, 274, -1, -1, -1,
- -1, -1, 33, -1, -1, -1, -1, -1, -1, 40,
- -1, -1, 43, -1, 45, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 61, 126, -1, -1, -1, -1, -1, -1, -1, -1,
- 318, -1, -1, -1, -1, -1, -1, -1, -1, 327,
- 328, 257, -1, -1, 260, 261, 262, -1, -1, -1,
- 266, 267, 268, 269, 270, -1, -1, -1, -1, -1,
- -1, -1, 278, 279, -1, 281, 282, 283, 284, 285,
- 286, 287, 288, 289, 290, 291, 292, 293, 294, 295,
- 296, 263, 298, 299, 300, 126, -1, -1, -1, -1,
- 306, -1, 308, 309, 310, 311, 312, 313, 314, 315,
- 316, 317, -1, -1, 320, -1, 33, -1, -1, -1,
- -1, 327, 328, 40, 41, -1, 43, -1, 45, 301,
- 302, 303, 304, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 318, 319, -1, 321,
- 322, 323, 324, -1, 326, -1, -1, -1, -1, -1,
- -1, -1, 257, -1, -1, 260, 261, 262, -1, -1,
- -1, 266, 267, 268, 269, 270, -1, -1, -1, -1,
- -1, -1, -1, 278, 279, -1, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, -1, 298, 299, 300, -1, -1, -1, 126,
- -1, 306, -1, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, -1, -1, 320, 257, -1, -1, 260,
- 261, 262, 327, 328, 33, 266, 267, 268, 269, 270,
- -1, 40, 41, -1, 43, -1, 45, 278, 279, -1,
- 281, 282, 283, 284, 285, 286, 287, 288, 289, 290,
- 291, 292, 293, 294, 295, 296, -1, 298, 299, 300,
- -1, -1, -1, -1, -1, 306, -1, 308, 309, 310,
- 311, 312, 313, 314, 315, 316, 317, -1, -1, 320,
- -1, -1, -1, -1, -1, -1, 327, 328, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 33, -1,
- -1, -1, -1, -1, -1, 40, 41, -1, 43, -1,
- 45, -1, -1, -1, -1, -1, -1, 126, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 257, -1, -1, 260, 261, 262, -1, -1, -1, 266,
- 267, 268, 269, 270, -1, -1, -1, -1, -1, -1,
- -1, 278, 279, -1, 281, 282, 283, 284, 285, 286,
- 287, 288, 289, 290, 291, 292, 293, 294, 295, 296,
- -1, 298, 299, 300, -1, -1, -1, -1, -1, 306,
- -1, 308, 309, 310, 311, 312, 313, 314, 315, 316,
- 317, 126, -1, 320, -1, 33, -1, -1, -1, -1,
- 327, 328, 40, 41, -1, 43, -1, 45, -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, 257, -1,
- -1, 260, 261, 262, -1, -1, -1, 266, 267, 268,
- 269, 270, -1, -1, -1, -1, -1, -1, -1, 278,
- 279, -1, 281, 282, 283, 284, 285, 286, 287, 288,
- 289, 290, 291, 292, 293, 294, 295, 296, 126, 298,
- 299, 300, -1, -1, -1, -1, -1, 306, -1, 308,
- 309, 310, 311, 312, 313, 314, 315, 316, 317, -1,
- -1, 320, -1, -1, 38, -1, -1, -1, 327, 328,
- 44, -1, 257, -1, -1, 260, 261, 262, -1, -1,
- -1, 266, 267, 268, 269, 270, -1, 61, -1, 63,
- -1, -1, -1, 278, 279, -1, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, -1, 298, 299, 300, -1, -1, -1, -1,
- 94, 306, -1, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, -1, -1, 320, -1, 33, -1, -1,
- -1, -1, 327, 328, 40, 41, -1, 43, -1, 45,
- 124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 257,
- -1, -1, 260, 261, 262, -1, -1, -1, 266, 267,
- 268, 269, 270, -1, -1, -1, -1, -1, -1, -1,
- 278, 279, -1, 281, 282, 283, 284, 285, 286, 287,
- 288, 289, 290, 291, 292, 293, 294, 295, 296, -1,
- 298, 299, 300, -1, -1, -1, 41, -1, 306, 44,
- 308, 309, 310, 311, 312, 313, 314, 315, 316, 317,
- 126, 33, 320, 58, 59, -1, -1, -1, 40, 327,
- 328, 43, -1, 45, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 93, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 263,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 33, -1,
- -1, -1, -1, -1, -1, 40, -1, -1, 43, -1,
- 45, -1, -1, -1, 126, -1, -1, 301, 302, 303,
- 304, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 318, 319, -1, 321, 322, 323,
- 324, -1, 326, 327, 328, -1, -1, -1, -1, -1,
- -1, 257, -1, -1, 260, 261, 262, -1, -1, -1,
- 266, 267, 268, 269, 270, -1, -1, -1, -1, -1,
- -1, -1, 278, 279, -1, 281, 282, 283, 284, 285,
- 286, 287, 288, 289, 290, 291, 292, 293, 294, 295,
- 296, 126, 298, 299, 300, -1, -1, -1, -1, -1,
- 306, -1, 308, 309, 310, 311, 312, 313, 314, 315,
- 316, 317, -1, 33, 320, -1, -1, -1, -1, -1,
- 40, 327, 328, 43, -1, 45, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 271, 272, 273, 274,
- -1, -1, -1, -1, -1, 257, -1, -1, 260, 261,
- 262, -1, -1, -1, 266, 267, 268, 269, 270, -1,
- -1, -1, -1, -1, -1, -1, 278, 279, -1, 281,
- 282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
- 292, 293, 294, 295, 296, -1, 298, 299, 300, -1,
- -1, -1, 327, 328, 306, -1, 308, 309, 310, 311,
- 312, 313, 314, 315, 316, 317, 126, 33, 320, -1,
- -1, -1, -1, -1, 40, 327, 328, 43, -1, 45,
- -1, -1, 257, -1, -1, 260, 261, 262, -1, -1,
- -1, 266, 267, 268, 269, 270, -1, -1, -1, -1,
- -1, -1, -1, 278, 279, -1, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, -1, 298, 299, 300, -1, -1, -1, -1,
- -1, 306, -1, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, -1, -1, 320, -1, -1, -1, -1,
- -1, -1, 327, 328, -1, -1, 38, -1, -1, 41,
- 126, -1, 44, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 58, 59, -1, 61,
- -1, 63, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 257, -1, -1,
- 260, 261, 262, -1, -1, -1, 266, 267, 268, 269,
- 270, 93, 94, -1, -1, -1, -1, -1, 278, 279,
- -1, 281, 282, 283, 284, 285, 286, 287, 288, 289,
- 290, 291, 292, 293, 294, 295, 296, -1, 298, 299,
- 300, -1, 124, -1, -1, -1, 306, -1, 308, 309,
- 310, 311, 312, 313, 314, 315, 316, 317, -1, -1,
- 320, -1, -1, -1, -1, -1, -1, 327, 328, -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, 260, 261, 262, -1, -1, -1,
- 266, 267, 268, 269, 270, -1, -1, -1, -1, -1,
- -1, -1, 278, 279, -1, 281, 282, 283, 284, 285,
- 286, 287, 288, 289, 290, 291, 292, 293, 294, 295,
- 296, -1, 298, 299, 300, -1, -1, -1, -1, -1,
- 306, -1, 308, 309, 310, 311, 312, 313, 314, 315,
- 316, 317, 38, -1, 320, 41, -1, -1, 44, -1,
- -1, 327, 328, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 58, 59, -1, 61, 38, 63, -1, 41,
- -1, 263, 44, -1, -1, -1, -1, -1, -1, 271,
- 272, 273, 274, -1, -1, -1, 58, 59, -1, 61,
- -1, 63, -1, -1, -1, -1, -1, 93, 94, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 301,
- 302, 303, 304, -1, -1, -1, -1, 38, -1, -1,
- 41, 93, 94, 44, -1, -1, 318, 319, 124, 321,
- 322, 323, 324, -1, 326, 327, 328, 58, 59, -1,
- 61, -1, 63, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 124, -1, 38, -1, -1, 41, -1, -1,
- 44, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 93, 94, 58, 59, -1, 61, -1, 63,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 38, -1, -1, 41,
- -1, -1, 44, 124, -1, -1, -1, -1, -1, 93,
- 94, -1, -1, -1, -1, -1, 58, 59, -1, 61,
- -1, 63, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 38, -1, -1, 41, -1, -1, 44,
- 124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 93, 94, 58, 59, -1, 61, -1, 63, -1,
- -1, -1, -1, -1, -1, -1, -1, 263, -1, -1,
- -1, -1, -1, -1, -1, 271, 272, 273, 274, -1,
- -1, -1, 124, -1, -1, -1, -1, -1, 93, 94,
- -1, 263, -1, -1, -1, -1, -1, -1, -1, 271,
- 272, 273, 274, -1, -1, 301, 302, 303, 304, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 38, 124,
- -1, 41, 318, 319, 44, 321, 322, 323, 324, -1,
- 326, 327, 328, -1, -1, -1, -1, -1, 58, 59,
- -1, 61, 263, 63, -1, -1, 318, 319, -1, -1,
- 271, 272, 273, 274, -1, 327, 328, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 93, 94, -1, -1, -1, -1, 263,
- 301, 302, 303, 304, -1, -1, -1, 271, 272, 273,
- 274, -1, -1, 41, -1, -1, 44, 318, 319, -1,
- 321, 322, 323, 324, 124, 326, 327, 328, -1, -1,
- 58, 59, -1, -1, -1, -1, -1, 301, 302, 303,
- 304, 263, -1, -1, -1, -1, -1, -1, -1, 271,
- 272, 273, 274, -1, 318, 319, -1, 321, 322, 323,
- 324, -1, 326, 327, 328, 93, -1, -1, -1, -1,
- 38, -1, -1, 41, -1, -1, 44, -1, 263, 301,
- 302, 303, 304, -1, -1, -1, 271, 272, 273, 274,
- 58, 59, -1, 61, -1, 63, 318, 319, -1, 321,
- 322, 323, 324, -1, 326, 327, 328, -1, -1, -1,
- 41, -1, -1, 44, -1, -1, 301, 302, 303, 304,
- -1, -1, -1, -1, -1, 93, 94, 58, 59, -1,
- -1, -1, -1, 318, 319, -1, 321, 322, 323, 324,
- -1, 326, 327, 328, 38, -1, -1, 41, -1, -1,
- 44, -1, -1, -1, -1, -1, 124, -1, 41, -1,
- -1, 44, 93, 263, 58, 59, -1, 61, -1, 63,
- -1, 271, 272, 273, 274, 58, 59, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 38, -1, -1, 41,
- -1, -1, 44, -1, -1, -1, -1, -1, -1, 93,
- 94, 301, 302, 303, 304, -1, 58, 59, -1, 61,
- 93, 63, -1, -1, -1, -1, -1, -1, 318, 319,
- -1, 321, 322, 323, 324, -1, 326, 327, 328, 38,
- 124, -1, 41, -1, -1, 44, -1, -1, -1, -1,
- -1, 93, 94, 271, 272, 273, 274, -1, -1, 58,
- 59, -1, 61, -1, 63, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 38, 124, -1, 41, -1, -1, 44, -1, -1,
- -1, -1, -1, -1, 93, 94, -1, -1, -1, -1,
- -1, 58, 59, -1, 61, 263, 63, -1, -1, 327,
- 328, -1, -1, 271, 272, 273, 274, -1, -1, -1,
- -1, -1, -1, -1, -1, 124, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 93, 94, -1, -1,
- -1, -1, -1, 301, 302, 303, 304, -1, -1, -1,
- 271, 272, 273, 274, -1, -1, -1, -1, -1, -1,
- 318, 319, -1, 321, 322, 323, 324, 124, 326, 327,
- 328, 38, -1, -1, 41, -1, -1, 44, -1, 263,
- -1, -1, -1, -1, -1, -1, -1, 271, 272, 273,
- 274, 58, 59, -1, 61, -1, 63, -1, 271, 272,
- 273, 274, -1, -1, -1, -1, 327, 328, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 301, 302, 303,
- 304, 263, -1, -1, -1, -1, 93, 94, -1, 271,
- 272, 273, 274, -1, 318, 319, -1, 321, 322, 323,
- 324, -1, 326, 327, 328, 38, -1, -1, 41, -1,
- -1, -1, -1, -1, 327, 328, -1, 124, -1, 301,
- 302, 303, 304, -1, 263, 58, 59, -1, 61, -1,
- 63, -1, 271, 272, 273, 274, 318, 319, -1, 321,
- 322, 323, 324, -1, 326, 327, 328, 38, -1, -1,
- 41, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 93, 94, 301, 302, 303, 304, 263, 58, 59, -1,
- 61, -1, 63, -1, 271, 272, 273, 274, -1, 318,
- 319, -1, 321, 322, 323, 324, -1, 326, 327, 328,
- 38, 124, -1, 41, -1, -1, -1, -1, -1, -1,
- -1, -1, 93, 94, 301, 302, 303, 304, -1, -1,
- 58, 59, -1, 61, -1, 63, -1, -1, -1, -1,
- -1, 318, 319, -1, 321, 322, 323, 324, -1, 326,
- 327, 328, 38, 124, -1, 41, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 93, 94, -1, -1, -1,
- -1, -1, 58, 59, -1, 61, 263, 63, -1, -1,
- -1, -1, -1, -1, 271, 272, 273, 274, -1, -1,
- -1, -1, -1, -1, -1, -1, 124, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 93, 94, -1,
- -1, -1, -1, -1, 301, 302, 303, 304, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 318, 319, -1, 321, 322, 323, 324, 124, 326,
- 327, 328, 38, -1, -1, 41, -1, -1, 44, -1,
- 263, -1, -1, -1, -1, -1, -1, -1, 271, 272,
- 273, 274, 58, 59, -1, 61, -1, 63, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 301, 302,
- 303, 304, 263, -1, -1, -1, -1, 93, 94, -1,
- 271, 272, 273, 274, -1, 318, 319, -1, 321, 322,
- 323, 324, -1, 326, 327, 328, 38, -1, -1, 41,
- -1, -1, 44, -1, -1, -1, -1, -1, 124, -1,
- 301, 302, 303, 304, -1, 263, 58, 59, -1, 61,
- -1, 63, -1, 271, 272, 273, 274, 318, 319, -1,
- 321, 322, 323, 324, -1, 326, 327, 328, 38, -1,
- -1, 41, -1, -1, 44, -1, -1, -1, -1, -1,
- -1, 93, 94, 301, 302, 303, 304, 263, 58, 59,
- -1, 61, -1, 63, -1, 271, 272, 273, 274, -1,
- 318, 319, -1, 321, 322, 323, 324, -1, 326, 327,
- 328, 38, 124, -1, 41, -1, -1, 44, -1, -1,
- -1, -1, -1, 93, 94, 301, 302, 303, 304, -1,
- -1, 58, 59, -1, 61, -1, 63, -1, -1, -1,
- -1, -1, 318, 319, -1, 321, 322, 323, 324, -1,
- 326, 327, 328, 38, 124, -1, 41, -1, -1, 44,
- -1, -1, -1, -1, -1, -1, 93, 94, -1, -1,
- -1, -1, -1, 58, 59, -1, 61, 263, 63, -1,
- -1, -1, -1, -1, -1, 271, 272, 273, 274, -1,
- -1, -1, -1, -1, -1, -1, -1, 124, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 93, 94,
- -1, -1, -1, -1, -1, 301, 302, 303, 304, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 318, 319, -1, 321, 322, 323, 324, 124,
- -1, 327, 328, 38, -1, -1, 41, -1, -1, 44,
- -1, 263, -1, -1, -1, -1, -1, -1, -1, 271,
- 272, 273, 274, 58, 59, -1, 61, -1, 63, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 41, -1,
- -1, 44, -1, -1, -1, -1, -1, -1, -1, 301,
- 302, 303, 304, 263, -1, 58, 59, -1, 93, 94,
- -1, 271, 272, 273, 274, -1, 318, 319, -1, 321,
- 322, 323, 324, -1, -1, 327, 328, 38, -1, -1,
- 41, -1, -1, 44, -1, -1, -1, -1, -1, 124,
- 93, 301, 302, 303, 304, -1, 263, 58, 59, -1,
- 61, -1, 63, -1, 271, 272, 273, 274, 318, 319,
- -1, 321, 322, 323, 324, -1, -1, 327, 328, 38,
- -1, -1, 41, -1, -1, 44, -1, -1, -1, -1,
- -1, -1, 93, 94, 301, 302, 303, 304, 263, 58,
- 59, -1, 61, -1, 63, -1, 271, 272, 273, 274,
- -1, 318, 319, -1, 321, 322, -1, -1, -1, -1,
- 327, 328, 38, 124, -1, 41, -1, -1, 44, -1,
- -1, -1, -1, -1, 93, 94, 301, 302, -1, 304,
- -1, -1, 58, 59, -1, 61, 38, 63, -1, 41,
- -1, -1, 44, 318, 319, -1, 321, 322, 41, -1,
- -1, 44, 327, 328, -1, 124, 58, 59, -1, 61,
- -1, 63, -1, -1, -1, 58, 59, 93, 94, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 263, -1,
- -1, -1, -1, -1, -1, -1, 271, 272, 273, 274,
- -1, 93, 94, -1, -1, -1, -1, -1, 124, -1,
- 93, -1, -1, 38, -1, -1, 41, -1, -1, 44,
- -1, -1, -1, -1, -1, -1, 301, 302, 271, 272,
- 273, 274, 124, 58, 59, -1, 61, -1, 63, -1,
- -1, -1, -1, 318, 319, -1, 321, 322, -1, -1,
- -1, -1, 327, 328, 38, -1, -1, 41, -1, -1,
- 44, -1, 263, -1, -1, -1, -1, -1, 93, 94,
- 271, 272, 273, 274, 58, 59, -1, 61, -1, 63,
- -1, -1, -1, -1, 327, 328, -1, -1, -1, 41,
- -1, -1, 44, -1, -1, -1, -1, -1, -1, 124,
- 301, 302, -1, -1, 263, -1, 58, 59, -1, 93,
- 94, -1, 271, 272, 273, 274, -1, 318, 319, -1,
- 321, 322, -1, -1, -1, -1, 327, 328, 38, -1,
- -1, 41, -1, -1, 44, -1, -1, -1, -1, -1,
- 124, 93, 301, 302, -1, -1, -1, 263, 58, 59,
- -1, 61, -1, 63, -1, 271, 272, 273, 274, 318,
- 319, -1, -1, -1, -1, -1, -1, -1, 327, 328,
- -1, 263, -1, -1, -1, -1, -1, -1, -1, 271,
- 272, 273, 274, 93, 94, 301, 302, -1, 271, 272,
- 273, 274, -1, -1, -1, 38, -1, -1, 41, -1,
- -1, 44, 318, 319, 41, -1, -1, 44, -1, 301,
- 302, 327, 328, -1, 124, 58, 59, -1, 61, -1,
- 63, 58, 59, -1, -1, -1, 318, 319, -1, -1,
- -1, -1, -1, -1, -1, 327, 328, -1, 263, -1,
- -1, -1, -1, -1, 327, 328, 271, 272, 273, 274,
- 93, 94, -1, -1, -1, -1, 93, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 302, -1, 263,
- -1, 124, -1, -1, -1, -1, -1, 271, 272, 273,
- 274, -1, 38, 318, 319, 41, -1, -1, 44, -1,
- -1, -1, 327, 328, 38, -1, -1, 41, -1, -1,
- 44, -1, 58, 59, -1, 61, -1, 63, -1, 271,
- 272, 273, 274, -1, 58, 59, -1, 61, -1, 63,
- -1, -1, -1, -1, 318, 319, -1, -1, -1, -1,
- -1, -1, -1, 327, 328, -1, -1, 93, 94, -1,
- -1, -1, -1, 263, -1, -1, -1, -1, -1, 93,
- 94, 271, 272, 273, 274, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 327, 328, 38, 124, -1,
- 41, -1, -1, 44, -1, -1, -1, -1, -1, -1,
- 124, 301, 302, 303, 304, -1, -1, 58, 59, -1,
- 61, -1, 63, -1, -1, -1, -1, -1, 318, 319,
- -1, 321, 322, 323, 324, -1, 326, -1, -1, -1,
- 263, -1, -1, -1, -1, -1, -1, -1, 271, 272,
- 273, 274, 93, 94, 271, 272, 273, 274, -1, -1,
- -1, -1, -1, -1, 38, -1, -1, 41, -1, -1,
- 44, -1, -1, -1, -1, -1, -1, -1, 301, 302,
- 303, 304, -1, 124, 58, 59, -1, 61, -1, 63,
- 41, -1, -1, 44, -1, 318, 319, -1, 321, 322,
- 323, 324, -1, 326, -1, -1, -1, 58, 59, -1,
- 327, 328, -1, -1, -1, -1, -1, -1, -1, 93,
- 94, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 263, -1, -1,
- -1, -1, 93, -1, -1, 271, 272, 273, 274, 263,
- 124, -1, -1, -1, -1, -1, -1, 271, 272, 273,
- 274, 38, -1, -1, 41, -1, -1, 44, -1, -1,
- -1, -1, -1, -1, -1, 301, 302, 303, 304, -1,
- -1, 58, 59, -1, 61, -1, 63, 301, 302, 303,
- 304, -1, 318, 319, -1, 321, 322, 323, 324, -1,
- 326, -1, -1, -1, 318, 319, -1, 321, 322, 323,
- 324, -1, 326, -1, -1, -1, 93, 94, 38, -1,
- -1, 41, 263, -1, 44, -1, -1, -1, -1, -1,
- 271, 272, 273, 274, -1, -1, -1, -1, 58, 59,
- -1, 61, -1, 63, -1, 38, -1, 124, 41, -1,
- -1, 44, -1, -1, -1, -1, -1, -1, -1, -1,
- 301, 302, 303, 304, -1, -1, -1, -1, 61, -1,
- 63, -1, -1, 93, 94, -1, -1, 318, 319, -1,
- 321, 322, 323, 324, -1, 326, -1, 38, -1, 263,
- 41, -1, -1, 44, -1, -1, -1, 271, 272, 273,
- 274, 94, -1, -1, 124, -1, -1, 58, 59, -1,
- 61, -1, 63, 38, -1, -1, 41, -1, -1, 44,
- 271, 272, 273, 274, -1, -1, -1, 301, 302, 303,
- 304, 124, -1, 58, 59, -1, 61, -1, 63, -1,
- -1, -1, 93, 94, 318, 319, -1, 321, 322, 323,
- 324, -1, 326, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 38, -1, -1, -1, 93, 94,
- 44, -1, -1, 124, -1, 38, 327, 328, -1, -1,
- -1, 44, -1, -1, -1, -1, 263, 61, 41, 63,
- -1, 44, -1, -1, 271, 272, 273, 274, 61, 124,
- 63, -1, -1, -1, -1, 58, 59, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 94, -1, -1, -1, 301, 302, 303, 304, -1, -1,
- -1, 94, -1, -1, -1, -1, -1, -1, -1, -1,
- 93, 318, 319, 263, 321, 322, 323, 324, -1, 326,
- 124, 271, 272, 273, 274, -1, -1, -1, -1, -1,
- -1, 124, -1, -1, -1, -1, 33, -1, -1, -1,
- 263, -1, -1, 40, -1, -1, 43, -1, 45, -1,
- -1, 301, 302, 303, 304, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 318, 319,
- -1, 321, 322, 323, 324, -1, 326, -1, 301, 302,
- 303, 304, 263, -1, -1, -1, -1, -1, -1, -1,
- 271, 272, 273, 274, 91, 318, 319, -1, 321, 322,
- 323, 324, -1, 326, -1, -1, -1, -1, 263, -1,
- 41, -1, -1, 44, -1, -1, 271, 272, 273, 274,
- 301, 302, 303, 304, -1, -1, 123, 58, 59, 126,
- -1, -1, -1, 41, -1, -1, 44, 318, 319, -1,
- 321, 322, 323, 324, -1, 326, 301, 302, 303, 304,
- 58, 59, -1, 61, -1, 63, -1, -1, -1, 263,
- -1, -1, 93, 318, 319, -1, 321, 322, 323, 324,
- 263, 326, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 41, 93, 94, 44, 271, 272,
- 273, 274, -1, -1, -1, -1, -1, 301, 302, 303,
- 304, 58, 59, -1, 61, -1, 63, -1, 301, 302,
- 303, 304, -1, -1, 318, 319, 124, 321, 322, 323,
- 324, -1, 326, -1, -1, 318, 319, -1, 321, 322,
- 323, 324, -1, 326, -1, -1, 93, 94, -1, -1,
- -1, -1, -1, -1, 327, 328, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 257, -1, -1, 260, 261, 262, -1, 124, -1, 266,
- 267, 268, 269, 270, -1, -1, -1, -1, -1, -1,
- -1, 278, 279, -1, 281, 282, 283, 284, 285, 286,
- 287, 288, 289, 290, 291, 292, 293, 294, 295, 296,
- -1, 298, 299, 300, -1, -1, -1, -1, -1, 306,
- -1, 308, 309, 310, 311, 312, 313, 314, 315, 316,
- 317, -1, -1, 320, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 271, 272, 273, 274, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 263, -1, -1, -1, -1,
- -1, -1, -1, 271, 272, 273, 274, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 66, -1, -1, -1, -1, -1, 72, -1,
- -1, -1, -1, -1, -1, -1, 327, 328, -1, -1,
- -1, -1, -1, -1, -1, -1, 263, -1, -1, -1,
- 318, 319, -1, -1, 271, 272, 273, 274, -1, 327,
- 328, -1, -1, 107, -1, 109, -1, 111, -1, 113,
- -1, -1, 116, -1, 118, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 128, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 142, -1,
- -1, 318, 319, 147, 148, 149, 150, 151, 152, 153,
- 327, 328, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 170, 171, 172, 173,
- -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, 202, 203,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 218, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 241, -1, 243,
- 244, -1, -1, -1, -1, -1, -1, -1, 252, -1,
- -1, -1, -1, 257, -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, 291, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 301, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 311, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 330, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 341,
-};
-#define YYFINAL 1
-#ifndef YYDEBUG
-#define YYDEBUG 0
-#endif
-#define YYMAXTOKEN 328
-#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,"WORD","LABEL","APPEND","OPEN",
-"SSELECT","LOOPEX","DOTDOT","USING","FORMAT","DO","SHIFT","PUSH","POP",
-"LVALFUN","WHILE","UNTIL","IF","UNLESS","ELSE","ELSIF","CONTINUE","SPLIT",
-"FLIST","FOR","FILOP","FILOP2","FILOP3","FILOP4","FILOP22","FILOP25","FUNC0",
-"FUNC1","FUNC2","FUNC2x","FUNC3","FUNC4","FUNC5","HSHFUN","HSHFUN3","FLIST2",
-"SUB","FILETEST","LOCAL","DELETE","RELOP","EQOP","MULOP","ADDOP","PACKAGE",
-"AMPER","FORMLIST","REG","ARYLEN","ARY","HSH","STAR","SUBST","PATTERN",
-"RSTRING","TRANS","LISTOP","OROR","ANDAND","UNIOP","LS","RS","MATCH","NMATCH",
-"UMINUS","POW","INC","DEC",
-};
-char *yyrule[] = {
-"$accept : prog",
-"$$1 :",
-"prog : $$1 lineseq",
-"compblock : block CONTINUE block",
-"compblock : block else",
-"else :",
-"else : ELSE block",
-"else : ELSIF '(' expr ')' compblock",
-"block : '{' remember lineseq '}'",
-"remember :",
-"lineseq :",
-"lineseq : lineseq line",
-"line : decl",
-"line : label cond",
-"line : loop",
-"line : label ';'",
-"line : label sideff ';'",
-"sideff : error",
-"sideff : expr",
-"sideff : expr IF expr",
-"sideff : expr UNLESS expr",
-"sideff : expr WHILE expr",
-"sideff : expr UNTIL expr",
-"cond : IF '(' expr ')' compblock",
-"cond : UNLESS '(' expr ')' compblock",
-"cond : IF block compblock",
-"cond : UNLESS block compblock",
-"loop : label WHILE '(' texpr ')' compblock",
-"loop : label UNTIL '(' expr ')' compblock",
-"loop : label WHILE block compblock",
-"loop : label UNTIL block compblock",
-"loop : label FOR REG '(' expr crp compblock",
-"loop : label FOR '(' expr crp compblock",
-"loop : label FOR '(' nexpr ';' texpr ';' nexpr ')' block",
-"loop : label compblock",
-"nexpr :",
-"nexpr : sideff",
-"texpr :",
-"texpr : expr",
-"label :",
-"label : LABEL",
-"decl : format",
-"decl : subrout",
-"decl : package",
-"format : FORMAT WORD '=' FORMLIST",
-"format : FORMAT '=' FORMLIST",
-"subrout : SUB WORD block",
-"package : PACKAGE WORD ';'",
-"cexpr : ',' expr",
-"expr : expr ',' sexpr",
-"expr : sexpr",
-"csexpr : ',' sexpr",
-"sexpr : sexpr '=' sexpr",
-"sexpr : sexpr POW '=' sexpr",
-"sexpr : sexpr MULOP '=' sexpr",
-"sexpr : sexpr ADDOP '=' sexpr",
-"sexpr : sexpr LS '=' sexpr",
-"sexpr : sexpr RS '=' sexpr",
-"sexpr : sexpr '&' '=' sexpr",
-"sexpr : sexpr '^' '=' sexpr",
-"sexpr : sexpr '|' '=' sexpr",
-"sexpr : sexpr POW sexpr",
-"sexpr : sexpr MULOP sexpr",
-"sexpr : sexpr ADDOP sexpr",
-"sexpr : sexpr LS sexpr",
-"sexpr : sexpr RS sexpr",
-"sexpr : sexpr RELOP sexpr",
-"sexpr : sexpr EQOP sexpr",
-"sexpr : sexpr '&' sexpr",
-"sexpr : sexpr '^' sexpr",
-"sexpr : sexpr '|' sexpr",
-"sexpr : sexpr DOTDOT sexpr",
-"sexpr : sexpr ANDAND sexpr",
-"sexpr : sexpr OROR sexpr",
-"sexpr : sexpr '?' sexpr ':' sexpr",
-"sexpr : sexpr MATCH sexpr",
-"sexpr : sexpr NMATCH sexpr",
-"sexpr : term",
-"term : '-' term",
-"term : '+' term",
-"term : '!' term",
-"term : '~' term",
-"term : term INC",
-"term : term DEC",
-"term : INC term",
-"term : DEC term",
-"term : FILETEST WORD",
-"term : FILETEST sexpr",
-"term : FILETEST",
-"term : LOCAL '(' expr crp",
-"term : '(' expr crp",
-"term : '(' ')'",
-"term : DO sexpr",
-"term : DO block",
-"term : REG",
-"term : STAR",
-"term : REG '[' expr ']'",
-"term : HSH",
-"term : ARY",
-"term : REG '{' expr ';' '}'",
-"term : '(' expr crp '[' expr ']'",
-"term : '(' ')' '[' expr ']'",
-"term : ARY '[' expr ']'",
-"term : ARY '{' expr ';' '}'",
-"term : DELETE REG '{' expr ';' '}'",
-"term : DELETE '(' REG '{' expr ';' '}' ')'",
-"term : ARYLEN",
-"term : RSTRING",
-"term : PATTERN",
-"term : SUBST",
-"term : TRANS",
-"term : DO WORD '(' expr crp",
-"term : AMPER WORD '(' expr crp",
-"term : DO WORD '(' ')'",
-"term : AMPER WORD '(' ')'",
-"term : AMPER WORD",
-"term : DO REG '(' expr crp",
-"term : AMPER REG '(' expr crp",
-"term : DO REG '(' ')'",
-"term : AMPER REG '(' ')'",
-"term : AMPER REG",
-"term : LOOPEX",
-"term : LOOPEX WORD",
-"term : UNIOP",
-"term : UNIOP block",
-"term : UNIOP sexpr",
-"term : SSELECT",
-"term : SSELECT WORD",
-"term : SSELECT '(' handle ')'",
-"term : SSELECT '(' sexpr csexpr csexpr csexpr ')'",
-"term : OPEN WORD",
-"term : OPEN '(' WORD ')'",
-"term : OPEN '(' handle cexpr ')'",
-"term : FILOP '(' handle ')'",
-"term : FILOP WORD",
-"term : FILOP REG",
-"term : FILOP '(' ')'",
-"term : FILOP",
-"term : FILOP2 '(' handle cexpr ')'",
-"term : FILOP3 '(' handle csexpr cexpr ')'",
-"term : FILOP22 '(' handle ',' handle ')'",
-"term : FILOP4 '(' handle csexpr csexpr cexpr ')'",
-"term : FILOP25 '(' handle ',' handle csexpr csexpr cexpr ')'",
-"term : PUSH '(' aryword ',' expr crp",
-"term : POP aryword",
-"term : POP '(' aryword ')'",
-"term : SHIFT aryword",
-"term : SHIFT '(' aryword ')'",
-"term : SHIFT",
-"term : SPLIT",
-"term : SPLIT '(' sexpr csexpr csexpr ')'",
-"term : SPLIT '(' sexpr csexpr ')'",
-"term : SPLIT '(' sexpr ')'",
-"term : FLIST2 '(' sexpr cexpr ')'",
-"term : FLIST '(' expr crp",
-"term : LVALFUN sexpr",
-"term : LVALFUN",
-"term : FUNC0",
-"term : FUNC0 '(' ')'",
-"term : FUNC1 '(' ')'",
-"term : FUNC1 '(' expr ')'",
-"term : FUNC2 '(' sexpr cexpr ')'",
-"term : FUNC2x '(' sexpr csexpr ')'",
-"term : FUNC2x '(' sexpr csexpr cexpr ')'",
-"term : FUNC3 '(' sexpr csexpr cexpr ')'",
-"term : FUNC4 '(' sexpr csexpr csexpr cexpr ')'",
-"term : FUNC5 '(' sexpr csexpr csexpr csexpr cexpr ')'",
-"term : HSHFUN '(' hshword ')'",
-"term : HSHFUN hshword",
-"term : HSHFUN3 '(' hshword csexpr cexpr ')'",
-"term : bareword",
-"term : listop",
-"listop : LISTOP",
-"listop : LISTOP expr",
-"listop : LISTOP WORD",
-"listop : LISTOP WORD expr",
-"listop : LISTOP REG expr",
-"listop : LISTOP block expr",
-"handle : WORD",
-"handle : sexpr",
-"aryword : WORD",
-"aryword : ARY",
-"hshword : WORD",
-"hshword : HSH",
-"crp : ',' ')'",
-"crp : ')'",
-"bareword : WORD",
-};
-#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 876 "perly.y"
- /* PROGRAM */
-#line 1820 "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 115 "perly.y"
-{
-#if defined(YYDEBUG) && defined(DEBUGGING)
- yydebug = (debug & 1);
-#endif
- expectterm = 2;
- }
-break;
-case 2:
-#line 122 "perly.y"
-{ if (in_eval)
- eval_root = block_head(yyvsp[0].cmdval);
- else
- main_root = block_head(yyvsp[0].cmdval); }
-break;
-case 3:
-#line 129 "perly.y"
-{ yyval.compval.comp_true = yyvsp[-2].cmdval; yyval.compval.comp_alt = yyvsp[0].cmdval; }
-break;
-case 4:
-#line 131 "perly.y"
-{ yyval.compval.comp_true = yyvsp[-1].cmdval; yyval.compval.comp_alt = yyvsp[0].cmdval; }
-break;
-case 5:
-#line 135 "perly.y"
-{ yyval.cmdval = Nullcmd; }
-break;
-case 6:
-#line 137 "perly.y"
-{ yyval.cmdval = yyvsp[0].cmdval; }
-break;
-case 7:
-#line 139 "perly.y"
-{ cmdline = yyvsp[-4].ival;
- yyval.cmdval = make_ccmd(C_ELSIF,1,yyvsp[-2].arg,yyvsp[0].compval); }
-break;
-case 8:
-#line 144 "perly.y"
-{ yyval.cmdval = block_head(yyvsp[-1].cmdval);
- if (cmdline > (line_t)yyvsp[-3].ival)
- cmdline = yyvsp[-3].ival;
- if (savestack->ary_fill > yyvsp[-2].ival)
- restorelist(yyvsp[-2].ival);
- expectterm = 2; }
-break;
-case 9:
-#line 153 "perly.y"
-{ yyval.ival = savestack->ary_fill; }
-break;
-case 10:
-#line 157 "perly.y"
-{ yyval.cmdval = Nullcmd; }
-break;
-case 11:
-#line 159 "perly.y"
-{ yyval.cmdval = append_line(yyvsp[-1].cmdval,yyvsp[0].cmdval); }
-break;
-case 12:
-#line 163 "perly.y"
-{ yyval.cmdval = Nullcmd; }
-break;
-case 13:
-#line 165 "perly.y"
-{ yyval.cmdval = add_label(yyvsp[-1].cval,yyvsp[0].cmdval); }
-break;
-case 15:
-#line 168 "perly.y"
-{ if (yyvsp[-1].cval != Nullch) {
- yyval.cmdval = add_label(yyvsp[-1].cval, make_acmd(C_EXPR, Nullstab,
- Nullarg, Nullarg) );
- }
- else {
- yyval.cmdval = Nullcmd;
- cmdline = NOLINE;
- }
- expectterm = 2; }
-break;
-case 16:
-#line 178 "perly.y"
-{ yyval.cmdval = add_label(yyvsp[-2].cval,yyvsp[-1].cmdval);
- expectterm = 2; }
-break;
-case 17:
-#line 183 "perly.y"
-{ yyval.cmdval = Nullcmd; }
-break;
-case 18:
-#line 185 "perly.y"
-{ yyval.cmdval = make_acmd(C_EXPR, Nullstab, yyvsp[0].arg, Nullarg); }
-break;
-case 19:
-#line 187 "perly.y"
-{ yyval.cmdval = addcond(
- make_acmd(C_EXPR, Nullstab, Nullarg, yyvsp[-2].arg), yyvsp[0].arg); }
-break;
-case 20:
-#line 190 "perly.y"
-{ yyval.cmdval = addcond(invert(
- make_acmd(C_EXPR, Nullstab, Nullarg, yyvsp[-2].arg)), yyvsp[0].arg); }
-break;
-case 21:
-#line 193 "perly.y"
-{ yyval.cmdval = addloop(
- make_acmd(C_EXPR, Nullstab, Nullarg, yyvsp[-2].arg), yyvsp[0].arg); }
-break;
-case 22:
-#line 196 "perly.y"
-{ yyval.cmdval = addloop(invert(
- make_acmd(C_EXPR, Nullstab, Nullarg, yyvsp[-2].arg)), yyvsp[0].arg); }
-break;
-case 23:
-#line 201 "perly.y"
-{ cmdline = yyvsp[-4].ival;
- yyval.cmdval = make_icmd(C_IF,yyvsp[-2].arg,yyvsp[0].compval); }
-break;
-case 24:
-#line 204 "perly.y"
-{ cmdline = yyvsp[-4].ival;
- yyval.cmdval = invert(make_icmd(C_IF,yyvsp[-2].arg,yyvsp[0].compval)); }
-break;
-case 25:
-#line 207 "perly.y"
-{ cmdline = yyvsp[-2].ival;
- yyval.cmdval = make_icmd(C_IF,cmd_to_arg(yyvsp[-1].cmdval),yyvsp[0].compval); }
-break;
-case 26:
-#line 210 "perly.y"
-{ cmdline = yyvsp[-2].ival;
- yyval.cmdval = invert(make_icmd(C_IF,cmd_to_arg(yyvsp[-1].cmdval),yyvsp[0].compval)); }
-break;
-case 27:
-#line 215 "perly.y"
-{ cmdline = yyvsp[-4].ival;
- yyval.cmdval = wopt(add_label(yyvsp[-5].cval,
- make_ccmd(C_WHILE,1,yyvsp[-2].arg,yyvsp[0].compval) )); }
-break;
-case 28:
-#line 219 "perly.y"
-{ cmdline = yyvsp[-4].ival;
- yyval.cmdval = wopt(add_label(yyvsp[-5].cval,
- invert(make_ccmd(C_WHILE,1,yyvsp[-2].arg,yyvsp[0].compval)) )); }
-break;
-case 29:
-#line 223 "perly.y"
-{ cmdline = yyvsp[-2].ival;
- yyval.cmdval = wopt(add_label(yyvsp[-3].cval,
- make_ccmd(C_WHILE, 1, cmd_to_arg(yyvsp[-1].cmdval),yyvsp[0].compval) )); }
-break;
-case 30:
-#line 227 "perly.y"
-{ cmdline = yyvsp[-2].ival;
- yyval.cmdval = wopt(add_label(yyvsp[-3].cval,
- invert(make_ccmd(C_WHILE,1,cmd_to_arg(yyvsp[-1].cmdval),yyvsp[0].compval)) )); }
-break;
-case 31:
-#line 231 "perly.y"
-{ cmdline = yyvsp[-5].ival;
- /*
- * The following gobbledygook catches EXPRs that
- * aren't explicit array refs and translates
- * foreach VAR (EXPR) {
- * into
- * @ary = EXPR;
- * foreach VAR (@ary) {
- * where @ary is a hidden array made by genstab().
- * (Note that @ary may become a local array if
- * it is determined that it might be called
- * recursively. See cmd_tosave().)
- */
- if (yyvsp[-2].arg->arg_type != O_ARRAY) {
- scrstab = aadd(genstab());
- yyval.cmdval = append_line(
- make_acmd(C_EXPR, Nullstab,
- l(make_op(O_ASSIGN,2,
- listish(make_op(O_ARRAY, 1,
- stab2arg(A_STAB,scrstab),
- Nullarg,Nullarg )),
- listish(make_list(yyvsp[-2].arg)),
- Nullarg)),
- Nullarg),
- wopt(over(yyvsp[-4].stabval,add_label(yyvsp[-6].cval,
- make_ccmd(C_WHILE, 0,
- make_op(O_ARRAY, 1,
- stab2arg(A_STAB,scrstab),
- Nullarg,Nullarg ),
- yyvsp[0].compval)))));
- yyval.cmdval->c_line = yyvsp[-5].ival;
- yyval.cmdval->c_head->c_line = yyvsp[-5].ival;
- }
- else {
- yyval.cmdval = wopt(over(yyvsp[-4].stabval,add_label(yyvsp[-6].cval,
- make_ccmd(C_WHILE,1,yyvsp[-2].arg,yyvsp[0].compval) )));
- }
- }
-break;
-case 32:
-#line 270 "perly.y"
-{ cmdline = yyvsp[-4].ival;
- if (yyvsp[-2].arg->arg_type != O_ARRAY) {
- scrstab = aadd(genstab());
- yyval.cmdval = append_line(
- make_acmd(C_EXPR, Nullstab,
- l(make_op(O_ASSIGN,2,
- listish(make_op(O_ARRAY, 1,
- stab2arg(A_STAB,scrstab),
- Nullarg,Nullarg )),
- listish(make_list(yyvsp[-2].arg)),
- Nullarg)),
- Nullarg),
- wopt(over(defstab,add_label(yyvsp[-5].cval,
- make_ccmd(C_WHILE, 0,
- make_op(O_ARRAY, 1,
- stab2arg(A_STAB,scrstab),
- Nullarg,Nullarg ),
- yyvsp[0].compval)))));
- yyval.cmdval->c_line = yyvsp[-4].ival;
- yyval.cmdval->c_head->c_line = yyvsp[-4].ival;
- }
- else { /* lisp, anyone? */
- yyval.cmdval = wopt(over(defstab,add_label(yyvsp[-5].cval,
- make_ccmd(C_WHILE,1,yyvsp[-2].arg,yyvsp[0].compval) )));
- }
- }
-break;
-case 33:
-#line 298 "perly.y"
-{ yyval.compval.comp_true = yyvsp[0].cmdval;
- yyval.compval.comp_alt = yyvsp[-2].cmdval;
- cmdline = yyvsp[-8].ival;
- yyval.cmdval = append_line(yyvsp[-6].cmdval,wopt(add_label(yyvsp[-9].cval,
- make_ccmd(C_WHILE,1,yyvsp[-4].arg,yyval.compval) ))); }
-break;
-case 34:
-#line 304 "perly.y"
-{ yyval.cmdval = add_label(yyvsp[-1].cval,make_ccmd(C_BLOCK,1,Nullarg,yyvsp[0].compval)); }
-break;
-case 35:
-#line 308 "perly.y"
-{ yyval.cmdval = Nullcmd; }
-break;
-case 37:
-#line 313 "perly.y"
-{ (void)scanstr("1",SCAN_DEF); yyval.arg = yylval.arg; }
-break;
-case 39:
-#line 318 "perly.y"
-{ yyval.cval = Nullch; }
-break;
-case 41:
-#line 323 "perly.y"
-{ yyval.ival = 0; }
-break;
-case 42:
-#line 325 "perly.y"
-{ yyval.ival = 0; }
-break;
-case 43:
-#line 327 "perly.y"
-{ yyval.ival = 0; }
-break;
-case 44:
-#line 331 "perly.y"
-{ if (strEQ(yyvsp[-2].cval,"stdout"))
- make_form(stabent("STDOUT",TRUE),yyvsp[0].formval);
- else if (strEQ(yyvsp[-2].cval,"stderr"))
- make_form(stabent("STDERR",TRUE),yyvsp[0].formval);
- else
- make_form(stabent(yyvsp[-2].cval,TRUE),yyvsp[0].formval);
- Safefree(yyvsp[-2].cval); yyvsp[-2].cval = Nullch; }
-break;
-case 45:
-#line 339 "perly.y"
-{ make_form(stabent("STDOUT",TRUE),yyvsp[0].formval); }
-break;
-case 46:
-#line 343 "perly.y"
-{ make_sub(yyvsp[-1].cval,yyvsp[0].cmdval);
- cmdline = NOLINE;
- if (savestack->ary_fill > yyvsp[-2].ival)
- restorelist(yyvsp[-2].ival); }
-break;
-case 47:
-#line 350 "perly.y"
-{ char tmpbuf[256];
- STAB *tmpstab;
-
- savehptr(&curstash);
- saveitem(curstname);
- str_set(curstname,yyvsp[-1].cval);
- sprintf(tmpbuf,"'_%s",yyvsp[-1].cval);
- tmpstab = stabent(tmpbuf,TRUE);
- if (!stab_xhash(tmpstab))
- stab_xhash(tmpstab) = hnew(0);
- curstash = stab_xhash(tmpstab);
- if (!curstash->tbl_name)
- curstash->tbl_name = savestr(yyvsp[-1].cval);
- curstash->tbl_coeffsize = 0;
- Safefree(yyvsp[-1].cval); yyvsp[-1].cval = Nullch;
- cmdline = NOLINE;
- expectterm = 2;
- }
-break;
-case 48:
-#line 371 "perly.y"
-{ yyval.arg = yyvsp[0].arg; }
-break;
-case 49:
-#line 375 "perly.y"
-{ yyval.arg = make_op(O_COMMA, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 51:
-#line 380 "perly.y"
-{ yyval.arg = yyvsp[0].arg; }
-break;
-case 52:
-#line 384 "perly.y"
-{ yyvsp[-2].arg = listish(yyvsp[-2].arg);
- if (yyvsp[-2].arg->arg_type == O_ASSIGN && yyvsp[-2].arg->arg_len == 1)
- yyvsp[-2].arg->arg_type = O_ITEM; /* a local() */
- if (yyvsp[-2].arg->arg_type == O_LIST)
- yyvsp[0].arg = listish(yyvsp[0].arg);
- yyval.arg = l(make_op(O_ASSIGN, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg)); }
-break;
-case 53:
-#line 391 "perly.y"
-{ yyval.arg = l(make_op(O_POW, 2, yyvsp[-3].arg, yyvsp[0].arg, Nullarg)); }
-break;
-case 54:
-#line 393 "perly.y"
-{ yyval.arg = l(make_op(yyvsp[-2].ival, 2, yyvsp[-3].arg, yyvsp[0].arg, Nullarg)); }
-break;
-case 55:
-#line 395 "perly.y"
-{ yyval.arg = rcatmaybe(l(make_op(yyvsp[-2].ival, 2, yyvsp[-3].arg, yyvsp[0].arg, Nullarg)));}
-break;
-case 56:
-#line 397 "perly.y"
-{ yyval.arg = l(make_op(O_LEFT_SHIFT, 2, yyvsp[-3].arg, yyvsp[0].arg, Nullarg)); }
-break;
-case 57:
-#line 399 "perly.y"
-{ yyval.arg = l(make_op(O_RIGHT_SHIFT, 2, yyvsp[-3].arg, yyvsp[0].arg, Nullarg)); }
-break;
-case 58:
-#line 401 "perly.y"
-{ yyval.arg = l(make_op(O_BIT_AND, 2, yyvsp[-3].arg, yyvsp[0].arg, Nullarg)); }
-break;
-case 59:
-#line 403 "perly.y"
-{ yyval.arg = l(make_op(O_XOR, 2, yyvsp[-3].arg, yyvsp[0].arg, Nullarg)); }
-break;
-case 60:
-#line 405 "perly.y"
-{ yyval.arg = l(make_op(O_BIT_OR, 2, yyvsp[-3].arg, yyvsp[0].arg, Nullarg)); }
-break;
-case 61:
-#line 409 "perly.y"
-{ yyval.arg = make_op(O_POW, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 62:
-#line 411 "perly.y"
-{ if (yyvsp[-1].ival == O_REPEAT)
- yyvsp[-2].arg = listish(yyvsp[-2].arg);
- yyval.arg = make_op(yyvsp[-1].ival, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg);
- if (yyvsp[-1].ival == O_REPEAT) {
- if (yyval.arg[1].arg_type != A_EXPR ||
- yyval.arg[1].arg_ptr.arg_arg->arg_type != O_LIST)
- yyval.arg[1].arg_flags &= ~AF_ARYOK;
- } }
-break;
-case 63:
-#line 420 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 64:
-#line 422 "perly.y"
-{ yyval.arg = make_op(O_LEFT_SHIFT, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 65:
-#line 424 "perly.y"
-{ yyval.arg = make_op(O_RIGHT_SHIFT, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 66:
-#line 426 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 67:
-#line 428 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 68:
-#line 430 "perly.y"
-{ yyval.arg = make_op(O_BIT_AND, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 69:
-#line 432 "perly.y"
-{ yyval.arg = make_op(O_XOR, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 70:
-#line 434 "perly.y"
-{ yyval.arg = make_op(O_BIT_OR, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 71:
-#line 436 "perly.y"
-{ arg4 = Nullarg;
- yyval.arg = make_op(O_F_OR_R, 4, yyvsp[-2].arg, yyvsp[0].arg, Nullarg);
- yyval.arg[0].arg_flags |= yyvsp[-1].ival; }
-break;
-case 72:
-#line 440 "perly.y"
-{ yyval.arg = make_op(O_AND, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 73:
-#line 442 "perly.y"
-{ yyval.arg = make_op(O_OR, 2, yyvsp[-2].arg, yyvsp[0].arg, Nullarg); }
-break;
-case 74:
-#line 444 "perly.y"
-{ yyval.arg = make_op(O_COND_EXPR, 3, yyvsp[-4].arg, yyvsp[-2].arg, yyvsp[0].arg); }
-break;
-case 75:
-#line 446 "perly.y"
-{ yyval.arg = mod_match(O_MATCH, yyvsp[-2].arg, yyvsp[0].arg); }
-break;
-case 76:
-#line 448 "perly.y"
-{ yyval.arg = mod_match(O_NMATCH, yyvsp[-2].arg, yyvsp[0].arg); }
-break;
-case 77:
-#line 450 "perly.y"
-{ yyval.arg = yyvsp[0].arg; }
-break;
-case 78:
-#line 454 "perly.y"
-{ yyval.arg = make_op(O_NEGATE, 1, yyvsp[0].arg, Nullarg, Nullarg); }
-break;
-case 79:
-#line 456 "perly.y"
-{ yyval.arg = yyvsp[0].arg; }
-break;
-case 80:
-#line 458 "perly.y"
-{ yyval.arg = make_op(O_NOT, 1, yyvsp[0].arg, Nullarg, Nullarg); }
-break;
-case 81:
-#line 460 "perly.y"
-{ yyval.arg = make_op(O_COMPLEMENT, 1, yyvsp[0].arg, Nullarg, Nullarg);}
-break;
-case 82:
-#line 462 "perly.y"
-{ yyval.arg = addflags(1, AF_POST|AF_UP,
- l(make_op(O_ITEM,1,yyvsp[-1].arg,Nullarg,Nullarg))); }
-break;
-case 83:
-#line 465 "perly.y"
-{ yyval.arg = addflags(1, AF_POST,
- l(make_op(O_ITEM,1,yyvsp[-1].arg,Nullarg,Nullarg))); }
-break;
-case 84:
-#line 468 "perly.y"
-{ yyval.arg = addflags(1, AF_PRE|AF_UP,
- l(make_op(O_ITEM,1,yyvsp[0].arg,Nullarg,Nullarg))); }
-break;
-case 85:
-#line 471 "perly.y"
-{ yyval.arg = addflags(1, AF_PRE,
- l(make_op(O_ITEM,1,yyvsp[0].arg,Nullarg,Nullarg))); }
-break;
-case 86:
-#line 474 "perly.y"
-{ opargs[yyvsp[-1].ival] = 0; /* force it special */
- yyval.arg = make_op(yyvsp[-1].ival, 1,
- stab2arg(A_STAB,stabent(yyvsp[0].cval,TRUE)),
- Nullarg, Nullarg);
- Safefree(yyvsp[0].cval); yyvsp[0].cval = Nullch;
- }
-break;
-case 87:
-#line 481 "perly.y"
-{ opargs[yyvsp[-1].ival] = 1;
- yyval.arg = make_op(yyvsp[-1].ival, 1, yyvsp[0].arg, Nullarg, Nullarg); }
-break;
-case 88:
-#line 484 "perly.y"
-{ opargs[yyvsp[0].ival] = (yyvsp[0].ival != O_FTTTY);
- yyval.arg = make_op(yyvsp[0].ival, 1,
- stab2arg(A_STAB,
- yyvsp[0].ival == O_FTTTY?stabent("STDIN",TRUE):defstab),
- Nullarg, Nullarg); }
-break;
-case 89:
-#line 490 "perly.y"
-{ yyval.arg = l(localize(make_op(O_ASSIGN, 1,
- localize(listish(make_list(yyvsp[-1].arg))),
- Nullarg,Nullarg))); }
-break;
-case 90:
-#line 494 "perly.y"
-{ yyval.arg = make_list(yyvsp[-1].arg); }
-break;
-case 91:
-#line 496 "perly.y"
-{ yyval.arg = make_list(Nullarg); }
-break;
-case 92:
-#line 498 "perly.y"
-{ yyval.arg = make_op(O_DOFILE,2,yyvsp[0].arg,Nullarg,Nullarg);
- allstabs = TRUE;}
-break;
-case 93:
-#line 501 "perly.y"
-{ yyval.arg = cmd_to_arg(yyvsp[0].cmdval); }
-break;
-case 94:
-#line 503 "perly.y"
-{ yyval.arg = stab2arg(A_STAB,yyvsp[0].stabval); }
-break;
-case 95:
-#line 505 "perly.y"
-{ yyval.arg = stab2arg(A_STAR,yyvsp[0].stabval); }
-break;
-case 96:
-#line 507 "perly.y"
-{ yyval.arg = make_op(O_AELEM, 2,
- stab2arg(A_STAB,aadd(yyvsp[-3].stabval)), yyvsp[-1].arg, Nullarg); }
-break;
-case 97:
-#line 510 "perly.y"
-{ yyval.arg = make_op(O_HASH, 1,
- stab2arg(A_STAB,yyvsp[0].stabval),
- Nullarg, Nullarg); }
-break;
-case 98:
-#line 514 "perly.y"
-{ yyval.arg = make_op(O_ARRAY, 1,
- stab2arg(A_STAB,yyvsp[0].stabval),
- Nullarg, Nullarg); }
-break;
-case 99:
-#line 518 "perly.y"
-{ yyval.arg = make_op(O_HELEM, 2,
- stab2arg(A_STAB,hadd(yyvsp[-4].stabval)),
- jmaybe(yyvsp[-2].arg),
- Nullarg);
- expectterm = FALSE; }
-break;
-case 100:
-#line 524 "perly.y"
-{ yyval.arg = make_op(O_LSLICE, 3,
- Nullarg,
- listish(make_list(yyvsp[-1].arg)),
- listish(make_list(yyvsp[-4].arg))); }
-break;
-case 101:
-#line 529 "perly.y"
-{ yyval.arg = make_op(O_LSLICE, 3,
- Nullarg,
- listish(make_list(yyvsp[-1].arg)),
- Nullarg); }
-break;
-case 102:
-#line 534 "perly.y"
-{ yyval.arg = make_op(O_ASLICE, 2,
- stab2arg(A_STAB,aadd(yyvsp[-3].stabval)),
- listish(make_list(yyvsp[-1].arg)),
- Nullarg); }
-break;
-case 103:
-#line 539 "perly.y"
-{ yyval.arg = make_op(O_HSLICE, 2,
- stab2arg(A_STAB,hadd(yyvsp[-4].stabval)),
- listish(make_list(yyvsp[-2].arg)),
- Nullarg);
- expectterm = FALSE; }
-break;
-case 104:
-#line 545 "perly.y"
-{ yyval.arg = make_op(O_DELETE, 2,
- stab2arg(A_STAB,hadd(yyvsp[-4].stabval)),
- jmaybe(yyvsp[-2].arg),
- Nullarg);
- expectterm = FALSE; }
-break;
-case 105:
-#line 551 "perly.y"
-{ yyval.arg = make_op(O_DELETE, 2,
- stab2arg(A_STAB,hadd(yyvsp[-5].stabval)),
- jmaybe(yyvsp[-3].arg),
- Nullarg);
- expectterm = FALSE; }
-break;
-case 106:
-#line 557 "perly.y"
-{ yyval.arg = stab2arg(A_ARYLEN,yyvsp[0].stabval); }
-break;
-case 107:
-#line 559 "perly.y"
-{ yyval.arg = yyvsp[0].arg; }
-break;
-case 108:
-#line 561 "perly.y"
-{ yyval.arg = yyvsp[0].arg; }
-break;
-case 109:
-#line 563 "perly.y"
-{ yyval.arg = yyvsp[0].arg; }
-break;
-case 110:
-#line 565 "perly.y"
-{ yyval.arg = yyvsp[0].arg; }
-break;
-case 111:
-#line 567 "perly.y"
-{ yyval.arg = make_op((perldb ? O_DBSUBR : O_SUBR), 2,
- stab2arg(A_WORD,stabent(yyvsp[-3].cval,MULTI)),
- make_list(yyvsp[-1].arg),
- Nullarg); Safefree(yyvsp[-3].cval); yyvsp[-3].cval = Nullch;
- yyval.arg->arg_flags |= AF_DEPR; }
-break;
-case 112:
-#line 573 "perly.y"
-{ yyval.arg = make_op((perldb ? O_DBSUBR : O_SUBR), 2,
- stab2arg(A_WORD,stabent(yyvsp[-3].cval,MULTI)),
- make_list(yyvsp[-1].arg),
- Nullarg); Safefree(yyvsp[-3].cval); yyvsp[-3].cval = Nullch; }
-break;
-case 113:
-#line 578 "perly.y"
-{ yyval.arg = make_op((perldb ? O_DBSUBR : O_SUBR), 2,
- stab2arg(A_WORD,stabent(yyvsp[-2].cval,MULTI)),
- make_list(Nullarg),
- Nullarg);
- Safefree(yyvsp[-2].cval); yyvsp[-2].cval = Nullch;
- yyval.arg->arg_flags |= AF_DEPR; }
-break;
-case 114:
-#line 585 "perly.y"
-{ yyval.arg = make_op((perldb ? O_DBSUBR : O_SUBR), 2,
- stab2arg(A_WORD,stabent(yyvsp[-2].cval,MULTI)),
- make_list(Nullarg),
- Nullarg);
- Safefree(yyvsp[-2].cval); yyvsp[-2].cval = Nullch;
- }
-break;
-case 115:
-#line 592 "perly.y"
-{ yyval.arg = make_op((perldb ? O_DBSUBR : O_SUBR), 2,
- stab2arg(A_WORD,stabent(yyvsp[0].cval,MULTI)),
- Nullarg,
- Nullarg);
- Safefree(yyvsp[0].cval); yyvsp[0].cval = Nullch;
- }
-break;
-case 116:
-#line 599 "perly.y"
-{ yyval.arg = make_op((perldb ? O_DBSUBR : O_SUBR), 2,
- stab2arg(A_STAB,yyvsp[-3].stabval),
- make_list(yyvsp[-1].arg),
- Nullarg);
- yyval.arg->arg_flags |= AF_DEPR; }
-break;
-case 117:
-#line 605 "perly.y"
-{ yyval.arg = make_op((perldb ? O_DBSUBR : O_SUBR), 2,
- stab2arg(A_STAB,yyvsp[-3].stabval),
- make_list(yyvsp[-1].arg),
- Nullarg); }
-break;
-case 118:
-#line 610 "perly.y"
-{ yyval.arg = make_op((perldb ? O_DBSUBR : O_SUBR), 2,
- stab2arg(A_STAB,yyvsp[-2].stabval),
- make_list(Nullarg),
- Nullarg);
- yyval.arg->arg_flags |= AF_DEPR; }
-break;
-case 119:
-#line 616 "perly.y"
-{ yyval.arg = make_op((perldb ? O_DBSUBR : O_SUBR), 2,
- stab2arg(A_STAB,yyvsp[-2].stabval),
- make_list(Nullarg),
- Nullarg); }
-break;
-case 120:
-#line 621 "perly.y"
-{ yyval.arg = make_op((perldb ? O_DBSUBR : O_SUBR), 2,
- stab2arg(A_STAB,yyvsp[0].stabval),
- Nullarg,
- Nullarg); }
-break;
-case 121:
-#line 626 "perly.y"
-{ yyval.arg = make_op(yyvsp[0].ival,0,Nullarg,Nullarg,Nullarg); }
-break;
-case 122:
-#line 628 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival,1,cval_to_arg(yyvsp[0].cval),
- Nullarg,Nullarg); }
-break;
-case 123:
-#line 631 "perly.y"
-{ yyval.arg = make_op(yyvsp[0].ival,0,Nullarg,Nullarg,Nullarg); }
-break;
-case 124:
-#line 633 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival,1,cmd_to_arg(yyvsp[0].cmdval),Nullarg,Nullarg); }
-break;
-case 125:
-#line 635 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival,1,yyvsp[0].arg,Nullarg,Nullarg); }
-break;
-case 126:
-#line 637 "perly.y"
-{ yyval.arg = make_op(O_SELECT, 0, Nullarg, Nullarg, Nullarg);}
-break;
-case 127:
-#line 639 "perly.y"
-{ yyval.arg = make_op(O_SELECT, 1,
- stab2arg(A_WORD,stabent(yyvsp[0].cval,TRUE)),
- Nullarg,
- Nullarg);
- Safefree(yyvsp[0].cval); yyvsp[0].cval = Nullch; }
-break;
-case 128:
-#line 645 "perly.y"
-{ yyval.arg = make_op(O_SELECT, 1, yyvsp[-1].arg, Nullarg, Nullarg); }
-break;
-case 129:
-#line 647 "perly.y"
-{ arg4 = yyvsp[-1].arg;
- yyval.arg = make_op(O_SSELECT, 4, yyvsp[-4].arg, yyvsp[-3].arg, yyvsp[-2].arg); }
-break;
-case 130:
-#line 650 "perly.y"
-{ yyval.arg = make_op(O_OPEN, 2,
- stab2arg(A_WORD,stabent(yyvsp[0].cval,TRUE)),
- stab2arg(A_STAB,stabent(yyvsp[0].cval,TRUE)),
- Nullarg);
- Safefree(yyvsp[0].cval); yyvsp[0].cval = Nullch;
- }
-break;
-case 131:
-#line 657 "perly.y"
-{ yyval.arg = make_op(O_OPEN, 2,
- stab2arg(A_WORD,stabent(yyvsp[-1].cval,TRUE)),
- stab2arg(A_STAB,stabent(yyvsp[-1].cval,TRUE)),
- Nullarg);
- Safefree(yyvsp[-1].cval); yyvsp[-1].cval = Nullch;
- }
-break;
-case 132:
-#line 664 "perly.y"
-{ yyval.arg = make_op(O_OPEN, 2,
- yyvsp[-2].arg,
- yyvsp[-1].arg, Nullarg); }
-break;
-case 133:
-#line 668 "perly.y"
-{ yyval.arg = make_op(yyvsp[-3].ival, 1,
- yyvsp[-1].arg,
- Nullarg, Nullarg); }
-break;
-case 134:
-#line 672 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival, 1,
- stab2arg(A_WORD,stabent(yyvsp[0].cval,TRUE)),
- Nullarg, Nullarg);
- Safefree(yyvsp[0].cval); yyvsp[0].cval = Nullch; }
-break;
-case 135:
-#line 677 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival, 1,
- stab2arg(A_STAB,yyvsp[0].stabval),
- Nullarg, Nullarg); }
-break;
-case 136:
-#line 681 "perly.y"
-{ yyval.arg = make_op(yyvsp[-2].ival, 1,
- stab2arg(A_WORD,Nullstab),
- Nullarg, Nullarg); }
-break;
-case 137:
-#line 685 "perly.y"
-{ yyval.arg = make_op(yyvsp[0].ival, 0,
- Nullarg, Nullarg, Nullarg); }
-break;
-case 138:
-#line 688 "perly.y"
-{ yyval.arg = make_op(yyvsp[-4].ival, 2, yyvsp[-2].arg, yyvsp[-1].arg, Nullarg); }
-break;
-case 139:
-#line 690 "perly.y"
-{ yyval.arg = make_op(yyvsp[-5].ival, 3, yyvsp[-3].arg, yyvsp[-2].arg, make_list(yyvsp[-1].arg)); }
-break;
-case 140:
-#line 692 "perly.y"
-{ yyval.arg = make_op(yyvsp[-5].ival, 2, yyvsp[-3].arg, yyvsp[-1].arg, Nullarg); }
-break;
-case 141:
-#line 694 "perly.y"
-{ arg4 = yyvsp[-1].arg; yyval.arg = make_op(yyvsp[-6].ival, 4, yyvsp[-4].arg, yyvsp[-3].arg, yyvsp[-2].arg); }
-break;
-case 142:
-#line 696 "perly.y"
-{ arg4 = yyvsp[-2].arg; arg5 = yyvsp[-1].arg;
- yyval.arg = make_op(yyvsp[-8].ival, 5, yyvsp[-6].arg, yyvsp[-4].arg, yyvsp[-3].arg); }
-break;
-case 143:
-#line 699 "perly.y"
-{ yyval.arg = make_op(yyvsp[-5].ival, 2,
- yyvsp[-3].arg,
- make_list(yyvsp[-1].arg),
- Nullarg); }
-break;
-case 144:
-#line 704 "perly.y"
-{ yyval.arg = make_op(O_POP, 1, yyvsp[0].arg, Nullarg, Nullarg); }
-break;
-case 145:
-#line 706 "perly.y"
-{ yyval.arg = make_op(O_POP, 1, yyvsp[-1].arg, Nullarg, Nullarg); }
-break;
-case 146:
-#line 708 "perly.y"
-{ yyval.arg = make_op(O_SHIFT, 1, yyvsp[0].arg, Nullarg, Nullarg); }
-break;
-case 147:
-#line 710 "perly.y"
-{ yyval.arg = make_op(O_SHIFT, 1, yyvsp[-1].arg, Nullarg, Nullarg); }
-break;
-case 148:
-#line 712 "perly.y"
-{ yyval.arg = make_op(O_SHIFT, 1,
- stab2arg(A_STAB,
- aadd(stabent(subline ? "_" : "ARGV", TRUE))),
- Nullarg, Nullarg); }
-break;
-case 149:
-#line 717 "perly.y"
-{ static char p[]="/\\s+/";
- char *oldend = bufend;
- ARG *oldarg = yylval.arg;
-
- bufend=p+5;
- (void)scanpat(p);
- bufend=oldend;
- yyval.arg = make_split(defstab,yylval.arg,Nullarg);
- yylval.arg = oldarg; }
-break;
-case 150:
-#line 727 "perly.y"
-{ yyval.arg = mod_match(O_MATCH, yyvsp[-2].arg,
- make_split(defstab,yyvsp[-3].arg,yyvsp[-1].arg));}
-break;
-case 151:
-#line 730 "perly.y"
-{ yyval.arg = mod_match(O_MATCH, yyvsp[-1].arg,
- make_split(defstab,yyvsp[-2].arg,Nullarg) ); }
-break;
-case 152:
-#line 733 "perly.y"
-{ yyval.arg = mod_match(O_MATCH,
- stab2arg(A_STAB,defstab),
- make_split(defstab,yyvsp[-1].arg,Nullarg) ); }
-break;
-case 153:
-#line 737 "perly.y"
-{ yyval.arg = make_op(yyvsp[-4].ival, 2,
- yyvsp[-2].arg,
- listish(make_list(yyvsp[-1].arg)),
- Nullarg); }
-break;
-case 154:
-#line 742 "perly.y"
-{ yyval.arg = make_op(yyvsp[-3].ival, 1,
- make_list(yyvsp[-1].arg),
- Nullarg,
- Nullarg); }
-break;
-case 155:
-#line 747 "perly.y"
-{ yyval.arg = l(make_op(yyvsp[-1].ival, 1, fixl(yyvsp[-1].ival,yyvsp[0].arg),
- Nullarg, Nullarg)); }
-break;
-case 156:
-#line 750 "perly.y"
-{ yyval.arg = l(make_op(yyvsp[0].ival, 1,
- stab2arg(A_STAB,defstab),
- Nullarg, Nullarg)); }
-break;
-case 157:
-#line 754 "perly.y"
-{ yyval.arg = make_op(yyvsp[0].ival, 0, Nullarg, Nullarg, Nullarg); }
-break;
-case 158:
-#line 756 "perly.y"
-{ yyval.arg = make_op(yyvsp[-2].ival, 0, Nullarg, Nullarg, Nullarg); }
-break;
-case 159:
-#line 758 "perly.y"
-{ yyval.arg = make_op(yyvsp[-2].ival, 0, Nullarg, Nullarg, Nullarg); }
-break;
-case 160:
-#line 760 "perly.y"
-{ yyval.arg = make_op(yyvsp[-3].ival, 1, yyvsp[-1].arg, Nullarg, Nullarg); }
-break;
-case 161:
-#line 762 "perly.y"
-{ yyval.arg = make_op(yyvsp[-4].ival, 2, yyvsp[-2].arg, yyvsp[-1].arg, Nullarg);
- if (yyvsp[-4].ival == O_INDEX && yyval.arg[2].arg_type == A_SINGLE)
- fbmcompile(yyval.arg[2].arg_ptr.arg_str,0); }
-break;
-case 162:
-#line 766 "perly.y"
-{ yyval.arg = make_op(yyvsp[-4].ival, 2, yyvsp[-2].arg, yyvsp[-1].arg, Nullarg);
- if (yyvsp[-4].ival == O_INDEX && yyval.arg[2].arg_type == A_SINGLE)
- fbmcompile(yyval.arg[2].arg_ptr.arg_str,0); }
-break;
-case 163:
-#line 770 "perly.y"
-{ yyval.arg = make_op(yyvsp[-5].ival, 3, yyvsp[-3].arg, yyvsp[-2].arg, yyvsp[-1].arg);
- if (yyvsp[-5].ival == O_INDEX && yyval.arg[2].arg_type == A_SINGLE)
- fbmcompile(yyval.arg[2].arg_ptr.arg_str,0); }
-break;
-case 164:
-#line 774 "perly.y"
-{ yyval.arg = make_op(yyvsp[-5].ival, 3, yyvsp[-3].arg, yyvsp[-2].arg, yyvsp[-1].arg); }
-break;
-case 165:
-#line 776 "perly.y"
-{ arg4 = yyvsp[-1].arg;
- yyval.arg = make_op(yyvsp[-6].ival, 4, yyvsp[-4].arg, yyvsp[-3].arg, yyvsp[-2].arg); }
-break;
-case 166:
-#line 779 "perly.y"
-{ arg4 = yyvsp[-2].arg; arg5 = yyvsp[-1].arg;
- yyval.arg = make_op(yyvsp[-7].ival, 5, yyvsp[-5].arg, yyvsp[-4].arg, yyvsp[-3].arg); }
-break;
-case 167:
-#line 782 "perly.y"
-{ yyval.arg = make_op(yyvsp[-3].ival, 1,
- yyvsp[-1].arg,
- Nullarg,
- Nullarg); }
-break;
-case 168:
-#line 787 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival, 1,
- yyvsp[0].arg,
- Nullarg,
- Nullarg); }
-break;
-case 169:
-#line 792 "perly.y"
-{ yyval.arg = make_op(yyvsp[-5].ival, 3, yyvsp[-3].arg, yyvsp[-2].arg, yyvsp[-1].arg); }
-break;
-case 172:
-#line 798 "perly.y"
-{ yyval.arg = make_op(yyvsp[0].ival,2,
- stab2arg(A_WORD,Nullstab),
- stab2arg(A_STAB,defstab),
- Nullarg); }
-break;
-case 173:
-#line 803 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival,2,
- stab2arg(A_WORD,Nullstab),
- maybelistish(yyvsp[-1].ival,make_list(yyvsp[0].arg)),
- Nullarg); }
-break;
-case 174:
-#line 808 "perly.y"
-{ yyval.arg = make_op(yyvsp[-1].ival,2,
- stab2arg(A_WORD,stabent(yyvsp[0].cval,TRUE)),
- stab2arg(A_STAB,defstab),
- Nullarg);
- Safefree(yyvsp[0].cval); yyvsp[0].cval = Nullch;
- }
-break;
-case 175:
-#line 815 "perly.y"
-{ yyval.arg = make_op(yyvsp[-2].ival,2,
- stab2arg(A_WORD,stabent(yyvsp[-1].cval,TRUE)),
- maybelistish(yyvsp[-2].ival,make_list(yyvsp[0].arg)),
- Nullarg); Safefree(yyvsp[-1].cval); yyvsp[-1].cval = Nullch; }
-break;
-case 176:
-#line 820 "perly.y"
-{ yyval.arg = make_op(yyvsp[-2].ival,2,
- stab2arg(A_STAB,yyvsp[-1].stabval),
- maybelistish(yyvsp[-2].ival,make_list(yyvsp[0].arg)),
- Nullarg); }
-break;
-case 177:
-#line 825 "perly.y"
-{ yyval.arg = make_op(yyvsp[-2].ival,2,
- cmd_to_arg(yyvsp[-1].cmdval),
- maybelistish(yyvsp[-2].ival,make_list(yyvsp[0].arg)),
- Nullarg); }
-break;
-case 178:
-#line 832 "perly.y"
-{ yyval.arg = stab2arg(A_WORD,stabent(yyvsp[0].cval,TRUE));
- Safefree(yyvsp[0].cval); yyvsp[0].cval = Nullch;}
-break;
-case 180:
-#line 838 "perly.y"
-{ yyval.arg = stab2arg(A_WORD,aadd(stabent(yyvsp[0].cval,TRUE)));
- Safefree(yyvsp[0].cval); yyvsp[0].cval = Nullch; }
-break;
-case 181:
-#line 841 "perly.y"
-{ yyval.arg = stab2arg(A_STAB,yyvsp[0].stabval); }
-break;
-case 182:
-#line 845 "perly.y"
-{ yyval.arg = stab2arg(A_WORD,hadd(stabent(yyvsp[0].cval,TRUE)));
- Safefree(yyvsp[0].cval); yyvsp[0].cval = Nullch; }
-break;
-case 183:
-#line 848 "perly.y"
-{ yyval.arg = stab2arg(A_STAB,yyvsp[0].stabval); }
-break;
-case 184:
-#line 852 "perly.y"
-{ yyval.ival = 1; }
-break;
-case 185:
-#line 854 "perly.y"
-{ yyval.ival = 0; }
-break;
-case 186:
-#line 863 "perly.y"
-{ char *s;
- yyval.arg = op_new(1);
- yyval.arg->arg_type = O_ITEM;
- yyval.arg[1].arg_type = A_SINGLE;
- yyval.arg[1].arg_ptr.arg_str = str_make(yyvsp[0].cval,0);
- for (s = yyvsp[0].cval; *s && isLOWER(*s); s++) ;
- if (dowarn && !*s)
- warn(
- "\"%s\" may clash with future reserved word",
- yyvsp[0].cval );
- Safefree(yyvsp[0].cval); yyvsp[0].cval = Nullch;
- }
-break;
-#line 3008 "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/gnu/usr.bin/perl/perl/perly.h b/gnu/usr.bin/perl/perl/perly.h
deleted file mode 100644
index c6f13d1..0000000
--- a/gnu/usr.bin/perl/perl/perly.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#define WORD 257
-#define LABEL 258
-#define APPEND 259
-#define OPEN 260
-#define SSELECT 261
-#define LOOPEX 262
-#define DOTDOT 263
-#define USING 264
-#define FORMAT 265
-#define DO 266
-#define SHIFT 267
-#define PUSH 268
-#define POP 269
-#define LVALFUN 270
-#define WHILE 271
-#define UNTIL 272
-#define IF 273
-#define UNLESS 274
-#define ELSE 275
-#define ELSIF 276
-#define CONTINUE 277
-#define SPLIT 278
-#define FLIST 279
-#define FOR 280
-#define FILOP 281
-#define FILOP2 282
-#define FILOP3 283
-#define FILOP4 284
-#define FILOP22 285
-#define FILOP25 286
-#define FUNC0 287
-#define FUNC1 288
-#define FUNC2 289
-#define FUNC2x 290
-#define FUNC3 291
-#define FUNC4 292
-#define FUNC5 293
-#define HSHFUN 294
-#define HSHFUN3 295
-#define FLIST2 296
-#define SUB 297
-#define FILETEST 298
-#define LOCAL 299
-#define DELETE 300
-#define RELOP 301
-#define EQOP 302
-#define MULOP 303
-#define ADDOP 304
-#define PACKAGE 305
-#define AMPER 306
-#define FORMLIST 307
-#define REG 308
-#define ARYLEN 309
-#define ARY 310
-#define HSH 311
-#define STAR 312
-#define SUBST 313
-#define PATTERN 314
-#define RSTRING 315
-#define TRANS 316
-#define LISTOP 317
-#define OROR 318
-#define ANDAND 319
-#define UNIOP 320
-#define LS 321
-#define RS 322
-#define MATCH 323
-#define NMATCH 324
-#define UMINUS 325
-#define POW 326
-#define INC 327
-#define DEC 328
-typedef union {
- int ival;
- char *cval;
- ARG *arg;
- CMD *cmdval;
- struct compcmd compval;
- STAB *stabval;
- FCMD *formval;
-} YYSTYPE;
-extern YYSTYPE yylval;
-extern YYSTYPE yylval;
diff --git a/gnu/usr.bin/perl/perl/regcomp.c b/gnu/usr.bin/perl/perl/regcomp.c
deleted file mode 100644
index 0287778..0000000
--- a/gnu/usr.bin/perl/perl/regcomp.c
+++ /dev/null
@@ -1,1481 +0,0 @@
-/* NOTE: this is derived from Henry Spencer's regexp code, and should not
- * confused with the original package (see point 3 below). Thanks, Henry!
- */
-
-/* Additional note: this code is very heavily munged from Henry's version
- * in places. In some spots I've traded clarity for efficiency, so don't
- * blame Henry for some of the lack of readability.
- */
-
-/* $RCSfile: regcomp.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:33 $
- *
- * $Log: regcomp.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:33 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:39 nate
- * PERL!
- *
- * Revision 4.0.1.5 92/06/08 15:23:36 lwall
- * patch20: Perl now distinguishes overlapped copies from non-overlapped
- * patch20: /^stuff/ wrongly assumed an implicit $* == 1
- * patch20: /x{0}/ was wrongly interpreted as /x{0,}/
- * patch20: added \W, \S and \D inside /[...]/
- *
- * Revision 4.0.1.4 91/11/05 22:55:14 lwall
- * patch11: Erratum
- *
- * Revision 4.0.1.3 91/11/05 18:22:28 lwall
- * patch11: minimum match length calculation in regexp is now cumulative
- * patch11: initial .* in pattern had dependency on value of $*
- * patch11: certain patterns made use of garbage pointers from uncleared memory
- * patch11: prepared for ctype implementations that don't define isascii()
- *
- * Revision 4.0.1.2 91/06/07 11:48:24 lwall
- * patch4: new copyright notice
- * patch4: /(x+) \1/ incorrectly optimized to not match "xxx xx"
- * patch4: // wouldn't use previous pattern if it started with a null character
- *
- * Revision 4.0.1.1 91/04/12 09:04:45 lwall
- * patch1: random cleanup in cpp namespace
- *
- * Revision 4.0 91/03/20 01:39:01 lwall
- * 4.0 baseline.
- *
- */
-/*SUPPRESS 112*/
-/*
- * regcomp and regexec -- regsub and regerror are not used in perl
- *
- * Copyright (c) 1986 by University of Toronto.
- * Written by Henry Spencer. Not derived from licensed software.
- *
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to redistribute it freely,
- * subject to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of
- * this software, no matter how awful, even if they arise
- * from defects in it.
- *
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission.
- *
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- *
- *
- **** Alterations to Henry's code are...
- ****
- **** Copyright (c) 1991, Larry Wall
- ****
- **** You may distribute under the terms of either the GNU General Public
- **** License or the Artistic License, as specified in the README file.
-
- *
- * Beware that some of this code is subtly aware of the way operator
- * precedence is structured in regular expressions. Serious changes in
- * regular-expression syntax might require a total rethink.
- */
-#include "EXTERN.h"
-#include "perl.h"
-#include "INTERN.h"
-#include "regcomp.h"
-
-#ifdef MSDOS
-# if defined(BUGGY_MSC6)
- /* MSC 6.00A breaks on op/regexp.t test 85 unless we turn this off */
- # pragma optimize("a",off)
- /* But MSC 6.00A is happy with 'w', for aliases only across function calls*/
- # pragma optimize("w",on )
-# endif /* BUGGY_MSC6 */
-#endif /* MSDOS */
-
-#ifndef STATIC
-#define STATIC static
-#endif
-
-#define ISMULT1(c) ((c) == '*' || (c) == '+' || (c) == '?')
-#define ISMULT2(s) ((*s) == '*' || (*s) == '+' || (*s) == '?' || \
- ((*s) == '{' && regcurly(s)))
-#ifdef atarist
-#define PERL_META "^$.[()|?+*\\"
-#else
-#define META "^$.[()|?+*\\"
-#endif
-
-#ifdef SPSTART
-#undef SPSTART /* dratted cpp namespace... */
-#endif
-/*
- * Flags to be passed up and down.
- */
-#define HASWIDTH 01 /* Known never to match null string. */
-#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
-#define SPSTART 04 /* Starts with * or +. */
-#define WORST 0 /* Worst case. */
-
-/*
- * Global work variables for regcomp().
- */
-static char *regprecomp; /* uncompiled string. */
-static char *regparse; /* Input-scan pointer. */
-static char *regxend; /* End of input for compile */
-static int regnpar; /* () count. */
-static char *regcode; /* Code-emit pointer; &regdummy = don't. */
-static long regsize; /* Code size. */
-static int regfold;
-static int regsawbracket; /* Did we do {d,d} trick? */
-static int regsawback; /* Did we see \1, ...? */
-
-/*
- * Forward declarations for regcomp()'s friends.
- */
-STATIC int regcurly();
-STATIC char *reg();
-STATIC char *regbranch();
-STATIC char *regpiece();
-STATIC char *regatom();
-STATIC char *regclass();
-STATIC char *regnode();
-STATIC char *reganode();
-STATIC void regc();
-STATIC void reginsert();
-STATIC void regtail();
-STATIC void regoptail();
-
-/*
- - regcomp - compile a regular expression into internal code
- *
- * We can't allocate space until we know how big the compiled form will be,
- * but we can't compile it (and thus know how big it is) until we've got a
- * place to put the code. So we cheat: we compile it twice, once with code
- * generation turned off and size counting turned on, and once "for real".
- * This also means that we don't allocate space until we are sure that the
- * thing really will compile successfully, and we never have to move the
- * code and thus invalidate pointers into it. (Note that it has to be in
- * one piece because free() must be able to free it all.) [NB: not true in perl]
- *
- * Beware that the optimization-preparation code in here knows about some
- * of the structure of the compiled regexp. [I'll say.]
- */
-regexp *
-regcomp(exp,xend,fold)
-char *exp;
-char *xend;
-int fold;
-{
- register regexp *r;
- register char *scan;
- register STR *longish;
- STR *longest;
- register int len;
- register char *first;
- int flags;
- int backish;
- int backest;
- int curback;
- int minlen;
- int sawplus = 0;
- int sawopen = 0;
-
- if (exp == NULL)
- fatal("NULL regexp argument");
-
- /* First pass: determine size, legality. */
- regfold = fold;
- regparse = exp;
- regxend = xend;
- regprecomp = nsavestr(exp,xend-exp);
- regsawbracket = 0;
- regsawback = 0;
- regnpar = 1;
- regsize = 0L;
- regcode = &regdummy;
- regc((char)MAGIC);
- if (reg(0, &flags) == NULL) {
- Safefree(regprecomp);
- regprecomp = Nullch;
- return(NULL);
- }
-
- /* Small enough for pointer-storage convention? */
- if (regsize >= 32767L) /* Probably could be 65535L. */
- FAIL("regexp too big");
-
- /* Allocate space. */
- Newc(1001, r, sizeof(regexp) + (unsigned)regsize, char, regexp);
- if (r == NULL)
- FAIL("regexp out of space");
-
- /* Second pass: emit code. */
- if (regsawbracket)
- Copy(regprecomp,exp,xend-exp,char);
- r->prelen = xend-exp;
- r->precomp = regprecomp;
- r->subbeg = r->subbase = NULL;
- regparse = exp;
- regnpar = 1;
- regcode = r->program;
- regc((char)MAGIC);
- if (reg(0, &flags) == NULL)
- return(NULL);
-
- /* Dig out information for optimizations. */
- r->regstart = Nullstr; /* Worst-case defaults. */
- r->reganch = 0;
- r->regmust = Nullstr;
- r->regback = -1;
- r->regstclass = Nullch;
- scan = r->program+1; /* First BRANCH. */
- if (OP(regnext(scan)) == END) {/* Only one top-level choice. */
- scan = NEXTOPER(scan);
-
- first = scan;
- while ((OP(first) == OPEN && (sawopen = 1)) ||
- (OP(first) == BRANCH && OP(regnext(first)) != BRANCH) ||
- (OP(first) == PLUS) ||
- (OP(first) == CURLY && ARG1(first) > 0) ) {
- if (OP(first) == PLUS)
- sawplus = 1;
- else
- first += regarglen[OP(first)];
- first = NEXTOPER(first);
- }
-
- /* Starting-point info. */
- again:
- if (OP(first) == EXACTLY) {
- r->regstart =
- str_make(OPERAND(first)+1,*OPERAND(first));
- if (r->regstart->str_cur > !(sawstudy|fold))
- fbmcompile(r->regstart,fold);
- }
- else if ((exp = index(simple,OP(first))) && exp > simple)
- r->regstclass = first;
- else if (OP(first) == BOUND || OP(first) == NBOUND)
- r->regstclass = first;
- else if (OP(first) == BOL) {
- r->reganch = ROPT_ANCH;
- first = NEXTOPER(first);
- goto again;
- }
- else if ((OP(first) == STAR && OP(NEXTOPER(first)) == ANY) &&
- !(r->reganch & ROPT_ANCH) ) {
- /* turn .* into ^.* with an implied $*=1 */
- r->reganch = ROPT_ANCH | ROPT_IMPLICIT;
- first = NEXTOPER(first);
- goto again;
- }
- if (sawplus && (!sawopen || !regsawback))
- r->reganch |= ROPT_SKIP; /* x+ must match 1st of run */
-
-#ifdef DEBUGGING
- if (debug & 512)
- fprintf(stderr,"first %d next %d offset %d\n",
- OP(first), OP(NEXTOPER(first)), first - scan);
-#endif
- /*
- * If there's something expensive in the r.e., find the
- * longest literal string that must appear and make it the
- * regmust. Resolve ties in favor of later strings, since
- * the regstart check works with the beginning of the r.e.
- * and avoiding duplication strengthens checking. Not a
- * strong reason, but sufficient in the absence of others.
- * [Now we resolve ties in favor of the earlier string if
- * it happens that curback has been invalidated, since the
- * earlier string may buy us something the later one won't.]
- */
- longish = str_make("",0);
- longest = str_make("",0);
- len = 0;
- minlen = 0;
- curback = 0;
- backish = 0;
- backest = 0;
- while (OP(scan) != END) {
- if (OP(scan) == BRANCH) {
- if (OP(regnext(scan)) == BRANCH) {
- curback = -30000;
- while (OP(scan) == BRANCH)
- scan = regnext(scan);
- }
- else /* single branch is ok */
- scan = NEXTOPER(scan);
- }
- if (OP(scan) == EXACTLY) {
- char *t;
-
- first = scan;
- while (OP(t = regnext(scan)) == CLOSE)
- scan = t;
- minlen += *OPERAND(first);
- if (curback - backish == len) {
- str_ncat(longish, OPERAND(first)+1,
- *OPERAND(first));
- len += *OPERAND(first);
- curback += *OPERAND(first);
- first = regnext(scan);
- }
- else if (*OPERAND(first) >= len + (curback >= 0)) {
- len = *OPERAND(first);
- str_nset(longish, OPERAND(first)+1,len);
- backish = curback;
- curback += len;
- first = regnext(scan);
- }
- else
- curback += *OPERAND(first);
- }
- else if (index(varies,OP(scan))) {
- curback = -30000;
- len = 0;
- if (longish->str_cur > longest->str_cur) {
- str_sset(longest,longish);
- backest = backish;
- }
- str_nset(longish,"",0);
- if (OP(scan) == PLUS &&
- index(simple,OP(NEXTOPER(scan))))
- minlen++;
- else if (OP(scan) == CURLY &&
- index(simple,OP(NEXTOPER(scan)+4)))
- minlen += ARG1(scan);
- }
- else if (index(simple,OP(scan))) {
- curback++;
- minlen++;
- len = 0;
- if (longish->str_cur > longest->str_cur) {
- str_sset(longest,longish);
- backest = backish;
- }
- str_nset(longish,"",0);
- }
- scan = regnext(scan);
- }
-
- /* Prefer earlier on tie, unless we can tail match latter */
-
- if (longish->str_cur + (OP(first) == EOL) > longest->str_cur) {
- str_sset(longest,longish);
- backest = backish;
- }
- else
- str_nset(longish,"",0);
- if (longest->str_cur
- &&
- (!r->regstart
- ||
- !fbminstr((unsigned char*) r->regstart->str_ptr,
- (unsigned char *) r->regstart->str_ptr
- + r->regstart->str_cur,
- longest)
- )
- )
- {
- r->regmust = longest;
- if (backest < 0)
- backest = -1;
- r->regback = backest;
- if (longest->str_cur
- > !(sawstudy || fold || OP(first) == EOL) )
- fbmcompile(r->regmust,fold);
- r->regmust->str_u.str_useful = 100;
- if (OP(first) == EOL && longish->str_cur)
- r->regmust->str_pok |= SP_TAIL;
- }
- else {
- str_free(longest);
- longest = Nullstr;
- }
- str_free(longish);
- }
-
- r->do_folding = fold;
- r->nparens = regnpar - 1;
- r->minlen = minlen;
- Newz(1002, r->startp, regnpar, char*);
- Newz(1002, r->endp, regnpar, char*);
-#ifdef DEBUGGING
- if (debug & 512)
- regdump(r);
-#endif
- return(r);
-}
-
-/*
- - reg - regular expression, i.e. main body or parenthesized thing
- *
- * Caller must absorb opening parenthesis.
- *
- * Combining parenthesis handling with the base level of regular expression
- * is a trifle forced, but the need to tie the tails of the branches to what
- * follows makes it hard to avoid.
- */
-static char *
-reg(paren, flagp)
-int paren; /* Parenthesized? */
-int *flagp;
-{
- register char *ret;
- register char *br;
- register char *ender;
- register int parno;
- int flags;
-
- *flagp = HASWIDTH; /* Tentatively. */
-
- /* Make an OPEN node, if parenthesized. */
- if (paren) {
- parno = regnpar;
- regnpar++;
- ret = reganode(OPEN, parno);
- } else
- ret = NULL;
-
- /* Pick up the branches, linking them together. */
- br = regbranch(&flags);
- if (br == NULL)
- return(NULL);
- if (ret != NULL)
- regtail(ret, br); /* OPEN -> first. */
- else
- ret = br;
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- while (*regparse == '|') {
- regparse++;
- br = regbranch(&flags);
- if (br == NULL)
- return(NULL);
- regtail(ret, br); /* BRANCH -> BRANCH. */
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- }
-
- /* Make a closing node, and hook it on the end. */
- if (paren)
- ender = reganode(CLOSE, parno);
- else
- ender = regnode(END);
- regtail(ret, ender);
-
- /* Hook the tails of the branches to the closing node. */
- for (br = ret; br != NULL; br = regnext(br))
- regoptail(br, ender);
-
- /* Check for proper termination. */
- if (paren && *regparse++ != ')') {
- FAIL("unmatched () in regexp");
- } else if (!paren && regparse < regxend) {
- if (*regparse == ')') {
- FAIL("unmatched () in regexp");
- } else
- FAIL("junk on end of regexp"); /* "Can't happen". */
- /* NOTREACHED */
- }
-
- return(ret);
-}
-
-/*
- - regbranch - one alternative of an | operator
- *
- * Implements the concatenation operator.
- */
-static char *
-regbranch(flagp)
-int *flagp;
-{
- register char *ret;
- register char *chain;
- register char *latest;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- ret = regnode(BRANCH);
- chain = NULL;
- while (regparse < regxend && *regparse != '|' && *regparse != ')') {
- latest = regpiece(&flags);
- if (latest == NULL)
- return(NULL);
- *flagp |= flags&HASWIDTH;
- if (chain == NULL) /* First piece. */
- *flagp |= flags&SPSTART;
- else
- regtail(chain, latest);
- chain = latest;
- }
- if (chain == NULL) /* Loop ran zero times. */
- (void) regnode(NOTHING);
-
- return(ret);
-}
-
-/*
- - regpiece - something followed by possible [*+?]
- *
- * Note that the branching code sequences used for ? and the general cases
- * of * and + are somewhat optimized: they use the same NOTHING node as
- * both the endmarker for their branch list and the body of the last branch.
- * It might seem that this node could be dispensed with entirely, but the
- * endmarker role is not redundant.
- */
-static char *
-regpiece(flagp)
-int *flagp;
-{
- register char *ret;
- register char op;
- register char *next;
- int flags;
- char *origparse = regparse;
- int orignpar = regnpar;
- char *max;
- int iter;
- char ch;
-
- ret = regatom(&flags);
- if (ret == NULL)
- return(NULL);
-
- op = *regparse;
-
- /* Here's a total kludge: if after the atom there's a {\d+,?\d*}
- * then we decrement the first number by one and reset our
- * parsing back to the beginning of the same atom. If the first number
- * is down to 0, decrement the second number instead and fake up
- * a ? after it. Given the way this compiler doesn't keep track
- * of offsets on the first pass, this is the only way to replicate
- * a piece of code. Sigh.
- */
- if (op == '{' && regcurly(regparse)) {
- next = regparse + 1;
- max = Nullch;
- while (isDIGIT(*next) || *next == ',') {
- if (*next == ',') {
- if (max)
- break;
- else
- max = next;
- }
- next++;
- }
- if (*next == '}') { /* got one */
- if (!max)
- max = next;
- regparse++;
- iter = atoi(regparse);
- if (flags&SIMPLE) { /* we can do it right after all */
- int tmp;
-
- reginsert(CURLY, ret);
- if (iter > 0)
- *flagp = (WORST|HASWIDTH);
- if (*max == ',')
- max++;
- else
- max = regparse;
- tmp = atoi(max);
- if (!tmp && *max != '0')
- tmp = 32767; /* meaning "infinity" */
- if (tmp && tmp < iter)
- fatal("Can't do {n,m} with n > m");
- if (regcode != &regdummy) {
-#ifdef REGALIGN
- *(unsigned short *)(ret+3) = iter;
- *(unsigned short *)(ret+5) = tmp;
-#else
- ret[3] = iter >> 8; ret[4] = iter & 0377;
- ret[5] = tmp >> 8; ret[6] = tmp & 0377;
-#endif
- }
- regparse = next;
- goto nest_check;
- }
- regsawbracket++; /* remember we clobbered exp */
- if (iter > 0) {
- ch = *max;
- sprintf(regparse,"%.*d", max-regparse, iter - 1);
- *max = ch;
- if (*max == ',' && max[1] != '}') {
- if (atoi(max+1) <= 0)
- fatal("Can't do {n,m} with n > m");
- ch = *next;
- sprintf(max+1,"%.*d", next-(max+1), atoi(max+1) - 1);
- *next = ch;
- }
- if (iter != 1 || *max == ',') {
- regparse = origparse; /* back up input pointer */
- regnpar = orignpar; /* don't make more parens */
- }
- else {
- regparse = next;
- goto nest_check;
- }
- *flagp = flags;
- return ret;
- }
- if (*max == ',') {
- max++;
- iter = atoi(max);
- if (max == next) { /* any number more? */
- regparse = next;
- op = '*'; /* fake up one with a star */
- }
- else if (iter > 0) {
- op = '?'; /* fake up optional atom */
- ch = *next;
- sprintf(max,"%.*d", next-max, iter - 1);
- *next = ch;
- if (iter == 1)
- regparse = next;
- else {
- regparse = origparse - 1; /* offset ++ below */
- regnpar = orignpar;
- }
- }
- else
- fatal("Can't do {n,0}");
- }
- else
- fatal("Can't do {0}");
- }
- }
-
- if (!ISMULT1(op)) {
- *flagp = flags;
- return(ret);
- }
-
- if (!(flags&HASWIDTH) && op != '?')
- FAIL("regexp *+ operand could be empty");
- *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
-
- if (op == '*' && (flags&SIMPLE))
- reginsert(STAR, ret);
- else if (op == '*') {
- /* Emit x* as (x&|), where & means "self". */
- reginsert(BRANCH, ret); /* Either x */
- regoptail(ret, regnode(BACK)); /* and loop */
- regoptail(ret, ret); /* back */
- regtail(ret, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- } else if (op == '+' && (flags&SIMPLE))
- reginsert(PLUS, ret);
- else if (op == '+') {
- /* Emit x+ as x(&|), where & means "self". */
- next = regnode(BRANCH); /* Either */
- regtail(ret, next);
- regtail(regnode(BACK), ret); /* loop back */
- regtail(next, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- } else if (op == '?') {
- /* Emit x? as (x|) */
- reginsert(BRANCH, ret); /* Either x */
- regtail(ret, regnode(BRANCH)); /* or */
- next = regnode(NOTHING); /* null. */
- regtail(ret, next);
- regoptail(ret, next);
- }
- nest_check:
- regparse++;
- if (ISMULT2(regparse))
- FAIL("nested *?+ in regexp");
-
- return(ret);
-}
-
-/*
- - regatom - the lowest level
- *
- * Optimization: gobbles an entire sequence of ordinary characters so that
- * it can turn them into a single node, which is smaller to store and
- * faster to run. Backslashed characters are exceptions, each becoming a
- * separate node; the code is simpler that way and it's not worth fixing.
- *
- * [Yes, it is worth fixing, some scripts can run twice the speed.]
- */
-static char *
-regatom(flagp)
-int *flagp;
-{
- register char *ret;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- switch (*regparse++) {
- case '^':
- ret = regnode(BOL);
- break;
- case '$':
- ret = regnode(EOL);
- break;
- case '.':
- ret = regnode(ANY);
- *flagp |= HASWIDTH|SIMPLE;
- break;
- case '[':
- ret = regclass();
- *flagp |= HASWIDTH|SIMPLE;
- break;
- case '(':
- ret = reg(1, &flags);
- if (ret == NULL)
- return(NULL);
- *flagp |= flags&(HASWIDTH|SPSTART);
- break;
- case '|':
- case ')':
- FAIL("internal urp in regexp"); /* Supposed to be caught earlier. */
- break;
- case '?':
- case '+':
- case '*':
- FAIL("?+* follows nothing in regexp");
- break;
- case '\\':
- switch (*regparse) {
- case 'w':
- ret = regnode(ALNUM);
- *flagp |= HASWIDTH|SIMPLE;
- regparse++;
- break;
- case 'W':
- ret = regnode(NALNUM);
- *flagp |= HASWIDTH|SIMPLE;
- regparse++;
- break;
- case 'b':
- ret = regnode(BOUND);
- *flagp |= SIMPLE;
- regparse++;
- break;
- case 'B':
- ret = regnode(NBOUND);
- *flagp |= SIMPLE;
- regparse++;
- break;
- case 's':
- ret = regnode(SPACE);
- *flagp |= HASWIDTH|SIMPLE;
- regparse++;
- break;
- case 'S':
- ret = regnode(NSPACE);
- *flagp |= HASWIDTH|SIMPLE;
- regparse++;
- break;
- case 'd':
- ret = regnode(DIGIT);
- *flagp |= HASWIDTH|SIMPLE;
- regparse++;
- break;
- case 'D':
- ret = regnode(NDIGIT);
- *flagp |= HASWIDTH|SIMPLE;
- regparse++;
- break;
- case 'n':
- case 'r':
- case 't':
- case 'f':
- case 'e':
- case 'a':
- case 'x':
- case 'c':
- case '0':
- goto defchar;
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- {
- int num = atoi(regparse);
-
- if (num > 9 && num >= regnpar)
- goto defchar;
- else {
- regsawback = 1;
- ret = reganode(REF, num);
- while (isDIGIT(*regparse))
- regparse++;
- *flagp |= SIMPLE;
- }
- }
- break;
- case '\0':
- if (regparse >= regxend)
- FAIL("trailing \\ in regexp");
- /* FALL THROUGH */
- default:
- goto defchar;
- }
- break;
- default: {
- register int len;
- register char ender;
- register char *p;
- char *oldp;
- int numlen;
-
- defchar:
- ret = regnode(EXACTLY);
- regc(0); /* save spot for len */
- for (len=0, p=regparse-1;
- len < 127 && p < regxend;
- len++)
- {
- oldp = p;
- switch (*p) {
- case '^':
- case '$':
- case '.':
- case '[':
- case '(':
- case ')':
- case '|':
- goto loopdone;
- case '\\':
- switch (*++p) {
- case 'w':
- case 'W':
- case 'b':
- case 'B':
- case 's':
- case 'S':
- case 'd':
- case 'D':
- --p;
- goto loopdone;
- case 'n':
- ender = '\n';
- p++;
- break;
- case 'r':
- ender = '\r';
- p++;
- break;
- case 't':
- ender = '\t';
- p++;
- break;
- case 'f':
- ender = '\f';
- p++;
- break;
- case 'e':
- ender = '\033';
- p++;
- break;
- case 'a':
- ender = '\007';
- p++;
- break;
- case 'x':
- ender = scanhex(++p, 2, &numlen);
- p += numlen;
- break;
- case 'c':
- p++;
- ender = *p++;
- if (isLOWER(ender))
- ender = toupper(ender);
- ender ^= 64;
- break;
- case '0': case '1': case '2': case '3':case '4':
- case '5': case '6': case '7': case '8':case '9':
- if (*p == '0' ||
- (isDIGIT(p[1]) && atoi(p) >= regnpar) ) {
- ender = scanoct(p, 3, &numlen);
- p += numlen;
- }
- else {
- --p;
- goto loopdone;
- }
- break;
- case '\0':
- if (p >= regxend)
- FAIL("trailing \\ in regexp");
- /* FALL THROUGH */
- default:
- ender = *p++;
- break;
- }
- break;
- default:
- ender = *p++;
- break;
- }
- if (regfold && isUPPER(ender))
- ender = tolower(ender);
- if (ISMULT2(p)) { /* Back off on ?+*. */
- if (len)
- p = oldp;
- else {
- len++;
- regc(ender);
- }
- break;
- }
- regc(ender);
- }
- loopdone:
- regparse = p;
- if (len <= 0)
- FAIL("internal disaster in regexp");
- *flagp |= HASWIDTH;
- if (len == 1)
- *flagp |= SIMPLE;
- if (regcode != &regdummy)
- *OPERAND(ret) = len;
- regc('\0');
- }
- break;
- }
-
- return(ret);
-}
-
-static void
-regset(bits,def,c)
-char *bits;
-int def;
-register int c;
-{
- if (regcode == &regdummy)
- return;
- c &= 255;
- if (def)
- bits[c >> 3] &= ~(1 << (c & 7));
- else
- bits[c >> 3] |= (1 << (c & 7));
-}
-
-static char *
-regclass()
-{
- register char *bits;
- register int class;
- register int lastclass;
- register int range = 0;
- register char *ret;
- register int def;
- int numlen;
-
- ret = regnode(ANYOF);
- if (*regparse == '^') { /* Complement of range. */
- regparse++;
- def = 0;
- } else {
- def = 255;
- }
- bits = regcode;
- for (class = 0; class < 32; class++)
- regc(def);
- if (*regparse == ']' || *regparse == '-')
- goto skipcond; /* allow 1st char to be ] or - */
- while (regparse < regxend && *regparse != ']') {
- skipcond:
- class = UCHARAT(regparse++);
- if (class == '\\') {
- class = UCHARAT(regparse++);
- switch (class) {
- case 'w':
- for (class = 0; class < 256; class++)
- if (isALNUM(class))
- regset(bits,def,class);
- lastclass = 1234;
- continue;
- case 'W':
- for (class = 0; class < 256; class++)
- if (!isALNUM(class))
- regset(bits,def,class);
- lastclass = 1234;
- continue;
- case 's':
- for (class = 0; class < 256; class++)
- if (isSPACE(class))
- regset(bits,def,class);
- lastclass = 1234;
- continue;
- case 'S':
- for (class = 0; class < 256; class++)
- if (!isSPACE(class))
- regset(bits,def,class);
- lastclass = 1234;
- continue;
- case 'd':
- for (class = '0'; class <= '9'; class++)
- regset(bits,def,class);
- lastclass = 1234;
- continue;
- case 'D':
- for (class = 0; class < '0'; class++)
- regset(bits,def,class);
- for (class = '9' + 1; class < 256; class++)
- regset(bits,def,class);
- lastclass = 1234;
- continue;
- case 'n':
- class = '\n';
- break;
- case 'r':
- class = '\r';
- break;
- case 't':
- class = '\t';
- break;
- case 'f':
- class = '\f';
- break;
- case 'b':
- class = '\b';
- break;
- case 'e':
- class = '\033';
- break;
- case 'a':
- class = '\007';
- break;
- case 'x':
- class = scanhex(regparse, 2, &numlen);
- regparse += numlen;
- break;
- case 'c':
- class = *regparse++;
- if (isLOWER(class))
- class = toupper(class);
- class ^= 64;
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- class = scanoct(--regparse, 3, &numlen);
- regparse += numlen;
- break;
- }
- }
- if (range) {
- if (lastclass > class)
- FAIL("invalid [] range in regexp");
- range = 0;
- }
- else {
- lastclass = class;
- if (*regparse == '-' && regparse+1 < regxend &&
- regparse[1] != ']') {
- regparse++;
- range = 1;
- continue; /* do it next time */
- }
- }
- for ( ; lastclass <= class; lastclass++) {
- regset(bits,def,lastclass);
- if (regfold && isUPPER(lastclass))
- regset(bits,def,tolower(lastclass));
- }
- lastclass = class;
- }
- if (*regparse != ']')
- FAIL("unmatched [] in regexp");
- regparse++;
- return ret;
-}
-
-/*
- - regnode - emit a node
- */
-static char * /* Location. */
-regnode(op)
-char op;
-{
- register char *ret;
- register char *ptr;
-
- ret = regcode;
- if (ret == &regdummy) {
-#ifdef REGALIGN
- if (!(regsize & 1))
- regsize++;
-#endif
- regsize += 3;
- return(ret);
- }
-
-#ifdef REGALIGN
-#ifndef lint
- if (!((long)ret & 1))
- *ret++ = 127;
-#endif
-#endif
- ptr = ret;
- *ptr++ = op;
- *ptr++ = '\0'; /* Null "next" pointer. */
- *ptr++ = '\0';
- regcode = ptr;
-
- return(ret);
-}
-
-/*
- - reganode - emit a node with an argument
- */
-static char * /* Location. */
-reganode(op, arg)
-char op;
-unsigned short arg;
-{
- register char *ret;
- register char *ptr;
-
- ret = regcode;
- if (ret == &regdummy) {
-#ifdef REGALIGN
- if (!(regsize & 1))
- regsize++;
-#endif
- regsize += 5;
- return(ret);
- }
-
-#ifdef REGALIGN
-#ifndef lint
- if (!((long)ret & 1))
- *ret++ = 127;
-#endif
-#endif
- ptr = ret;
- *ptr++ = op;
- *ptr++ = '\0'; /* Null "next" pointer. */
- *ptr++ = '\0';
-#ifdef REGALIGN
- *(unsigned short *)(ret+3) = arg;
-#else
- ret[3] = arg >> 8; ret[4] = arg & 0377;
-#endif
- ptr += 2;
- regcode = ptr;
-
- return(ret);
-}
-
-/*
- - regc - emit (if appropriate) a byte of code
- */
-static void
-regc(b)
-char b;
-{
- if (regcode != &regdummy)
- *regcode++ = b;
- else
- regsize++;
-}
-
-/*
- - reginsert - insert an operator in front of already-emitted operand
- *
- * Means relocating the operand.
- */
-static void
-reginsert(op, opnd)
-char op;
-char *opnd;
-{
- register char *src;
- register char *dst;
- register char *place;
- register offset = (op == CURLY ? 4 : 0);
-
- if (regcode == &regdummy) {
-#ifdef REGALIGN
- regsize += 4 + offset;
-#else
- regsize += 3 + offset;
-#endif
- return;
- }
-
- src = regcode;
-#ifdef REGALIGN
- regcode += 4 + offset;
-#else
- regcode += 3 + offset;
-#endif
- dst = regcode;
- while (src > opnd)
- *--dst = *--src;
-
- place = opnd; /* Op node, where operand used to be. */
- *place++ = op;
- *place++ = '\0';
- *place++ = '\0';
- while (offset-- > 0)
- *place++ = '\0';
-#ifdef REGALIGN
- *place++ = '\177';
-#endif
-}
-
-/*
- - regtail - set the next-pointer at the end of a node chain
- */
-static void
-regtail(p, val)
-char *p;
-char *val;
-{
- register char *scan;
- register char *temp;
- register int offset;
-
- if (p == &regdummy)
- return;
-
- /* Find last node. */
- scan = p;
- for (;;) {
- temp = regnext(scan);
- if (temp == NULL)
- break;
- scan = temp;
- }
-
-#ifdef REGALIGN
- offset = val - scan;
-#ifndef lint
- *(short*)(scan+1) = offset;
-#else
- offset = offset;
-#endif
-#else
- if (OP(scan) == BACK)
- offset = scan - val;
- else
- offset = val - scan;
- *(scan+1) = (offset>>8)&0377;
- *(scan+2) = offset&0377;
-#endif
-}
-
-/*
- - regoptail - regtail on operand of first argument; nop if operandless
- */
-static void
-regoptail(p, val)
-char *p;
-char *val;
-{
- /* "Operandless" and "op != BRANCH" are synonymous in practice. */
- if (p == NULL || p == &regdummy || OP(p) != BRANCH)
- return;
- regtail(NEXTOPER(p), val);
-}
-
-/*
- - regcurly - a little FSA that accepts {\d+,?\d*}
- */
-STATIC int
-regcurly(s)
-register char *s;
-{
- if (*s++ != '{')
- return FALSE;
- if (!isDIGIT(*s))
- return FALSE;
- while (isDIGIT(*s))
- s++;
- if (*s == ',')
- s++;
- while (isDIGIT(*s))
- s++;
- if (*s != '}')
- return FALSE;
- return TRUE;
-}
-
-#ifdef DEBUGGING
-
-/*
- - regdump - dump a regexp onto stderr in vaguely comprehensible form
- */
-void
-regdump(r)
-regexp *r;
-{
- register char *s;
- register char op = EXACTLY; /* Arbitrary non-END op. */
- register char *next;
-
-
- s = r->program + 1;
- while (op != END) { /* While that wasn't END last time... */
-#ifdef REGALIGN
- if (!((long)s & 1))
- s++;
-#endif
- op = OP(s);
- fprintf(stderr,"%2d%s", s-r->program, regprop(s)); /* Where, what. */
- next = regnext(s);
- s += regarglen[op];
- if (next == NULL) /* Next ptr. */
- fprintf(stderr,"(0)");
- else
- fprintf(stderr,"(%d)", (s-r->program)+(next-s));
- s += 3;
- if (op == ANYOF) {
- s += 32;
- }
- if (op == EXACTLY) {
- /* Literal string, where present. */
- s++;
- while (*s != '\0') {
- (void)putchar(*s);
- s++;
- }
- s++;
- }
- (void)putchar('\n');
- }
-
- /* Header fields of interest. */
- if (r->regstart)
- fprintf(stderr,"start `%s' ", r->regstart->str_ptr);
- if (r->regstclass)
- fprintf(stderr,"stclass `%s' ", regprop(r->regstclass));
- if (r->reganch & ROPT_ANCH)
- fprintf(stderr,"anchored ");
- if (r->reganch & ROPT_SKIP)
- fprintf(stderr,"plus ");
- if (r->reganch & ROPT_IMPLICIT)
- fprintf(stderr,"implicit ");
- if (r->regmust != NULL)
- fprintf(stderr,"must have \"%s\" back %d ", r->regmust->str_ptr,
- r->regback);
- fprintf(stderr, "minlen %d ", r->minlen);
- fprintf(stderr,"\n");
-}
-
-/*
- - regprop - printable representation of opcode
- */
-char *
-regprop(op)
-char *op;
-{
- register char *p;
-
- (void) strcpy(buf, ":");
-
- switch (OP(op)) {
- case BOL:
- p = "BOL";
- break;
- case EOL:
- p = "EOL";
- break;
- case ANY:
- p = "ANY";
- break;
- case ANYOF:
- p = "ANYOF";
- break;
- case BRANCH:
- p = "BRANCH";
- break;
- case EXACTLY:
- p = "EXACTLY";
- break;
- case NOTHING:
- p = "NOTHING";
- break;
- case BACK:
- p = "BACK";
- break;
- case END:
- p = "END";
- break;
- case ALNUM:
- p = "ALNUM";
- break;
- case NALNUM:
- p = "NALNUM";
- break;
- case BOUND:
- p = "BOUND";
- break;
- case NBOUND:
- p = "NBOUND";
- break;
- case SPACE:
- p = "SPACE";
- break;
- case NSPACE:
- p = "NSPACE";
- break;
- case DIGIT:
- p = "DIGIT";
- break;
- case NDIGIT:
- p = "NDIGIT";
- break;
- case CURLY:
- (void)sprintf(buf+strlen(buf), "CURLY {%d,%d}",
- ARG1(op),ARG2(op));
- p = NULL;
- break;
- case REF:
- (void)sprintf(buf+strlen(buf), "REF%d", ARG1(op));
- p = NULL;
- break;
- case OPEN:
- (void)sprintf(buf+strlen(buf), "OPEN%d", ARG1(op));
- p = NULL;
- break;
- case CLOSE:
- (void)sprintf(buf+strlen(buf), "CLOSE%d", ARG1(op));
- p = NULL;
- break;
- case STAR:
- p = "STAR";
- break;
- case PLUS:
- p = "PLUS";
- break;
- default:
- FAIL("corrupted regexp opcode");
- }
- if (p != NULL)
- (void) strcat(buf, p);
- return(buf);
-}
-#endif /* DEBUGGING */
-
-void
-regfree(r)
-struct regexp *r;
-{
- if (r->precomp) {
- Safefree(r->precomp);
- r->precomp = Nullch;
- }
- if (r->subbase) {
- Safefree(r->subbase);
- r->subbase = Nullch;
- }
- if (r->regmust) {
- str_free(r->regmust);
- r->regmust = Nullstr;
- }
- if (r->regstart) {
- str_free(r->regstart);
- r->regstart = Nullstr;
- }
- Safefree(r->startp);
- Safefree(r->endp);
- Safefree(r);
-}
diff --git a/gnu/usr.bin/perl/perl/regcomp.h b/gnu/usr.bin/perl/perl/regcomp.h
deleted file mode 100644
index b6b8c18..0000000
--- a/gnu/usr.bin/perl/perl/regcomp.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/* $RCSfile: regcomp.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:35 $
- *
- * $Log: regcomp.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:35 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:39 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 11:49:40 lwall
- * patch4: no change
- *
- * Revision 4.0 91/03/20 01:39:09 lwall
- * 4.0 baseline.
- *
- */
-
-/*
- * The "internal use only" fields in regexp.h are present to pass info from
- * compile to execute that permits the execute phase to run lots faster on
- * simple cases. They are:
- *
- * regstart str that must begin a match; Nullch if none obvious
- * reganch is the match anchored (at beginning-of-line only)?
- * regmust string (pointer into program) that match must include, or NULL
- * [regmust changed to STR* for bminstr()--law]
- * regmlen length of regmust string
- * [regmlen not used currently]
- *
- * Regstart and reganch permit very fast decisions on suitable starting points
- * for a match, cutting down the work a lot. Regmust permits fast rejection
- * of lines that cannot possibly match. The regmust tests are costly enough
- * that regcomp() supplies a regmust only if the r.e. contains something
- * potentially expensive (at present, the only such thing detected is * or +
- * at the start of the r.e., which can involve a lot of backup). Regmlen is
- * supplied because the test in regexec() needs it and regcomp() is computing
- * it anyway.
- * [regmust is now supplied always. The tests that use regmust have a
- * heuristic that disables the test if it usually matches.]
- *
- * [In fact, we now use regmust in many cases to locate where the search
- * starts in the string, so if regback is >= 0, the regmust search is never
- * wasted effort. The regback variable says how many characters back from
- * where regmust matched is the earliest possible start of the match.
- * For instance, /[a-z].foo/ has a regmust of 'foo' and a regback of 2.]
- */
-
-/*
- * Structure for regexp "program". This is essentially a linear encoding
- * of a nondeterministic finite-state machine (aka syntax charts or
- * "railroad normal form" in parsing technology). Each node is an opcode
- * plus a "next" pointer, possibly plus an operand. "Next" pointers of
- * all nodes except BRANCH implement concatenation; a "next" pointer with
- * a BRANCH on both ends of it is connecting two alternatives. (Here we
- * have one of the subtle syntax dependencies: an individual BRANCH (as
- * opposed to a collection of them) is never concatenated with anything
- * because of operator precedence.) The operand of some types of node is
- * a literal string; for others, it is a node leading into a sub-FSM. In
- * particular, the operand of a BRANCH node is the first node of the branch.
- * (NB this is *not* a tree structure: the tail of the branch connects
- * to the thing following the set of BRANCHes.) The opcodes are:
- */
-
-/* definition number opnd? meaning */
-#define END 0 /* no End of program. */
-#define BOL 1 /* no Match "" at beginning of line. */
-#define EOL 2 /* no Match "" at end of line. */
-#define ANY 3 /* no Match any one character. */
-#define ANYOF 4 /* str Match character in (or not in) this class. */
-#define CURLY 5 /* str Match this simple thing {n,m} times. */
-#define BRANCH 6 /* node Match this alternative, or the next... */
-#define BACK 7 /* no Match "", "next" ptr points backward. */
-#define EXACTLY 8 /* str Match this string (preceded by length). */
-#define NOTHING 9 /* no Match empty string. */
-#define STAR 10 /* node Match this (simple) thing 0 or more times. */
-#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
-#define ALNUM 12 /* no Match any alphanumeric character */
-#define NALNUM 13 /* no Match any non-alphanumeric character */
-#define BOUND 14 /* no Match "" at any word boundary */
-#define NBOUND 15 /* no Match "" at any word non-boundary */
-#define SPACE 16 /* no Match any whitespace character */
-#define NSPACE 17 /* no Match any non-whitespace character */
-#define DIGIT 18 /* no Match any numeric character */
-#define NDIGIT 19 /* no Match any non-numeric character */
-#define REF 20 /* num Match some already matched string */
-#define OPEN 21 /* num Mark this point in input as start of #n. */
-#define CLOSE 22 /* num Analogous to OPEN. */
-
-/*
- * Opcode notes:
- *
- * BRANCH The set of branches constituting a single choice are hooked
- * together with their "next" pointers, since precedence prevents
- * anything being concatenated to any individual branch. The
- * "next" pointer of the last BRANCH in a choice points to the
- * thing following the whole choice. This is also where the
- * final "next" pointer of each individual branch points; each
- * branch starts with the operand node of a BRANCH node.
- *
- * BACK Normal "next" pointers all implicitly point forward; BACK
- * exists to make loop structures possible.
- *
- * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
- * BRANCH structures using BACK. Simple cases (one character
- * per match) are implemented with STAR and PLUS for speed
- * and to minimize recursive plunges.
- *
- * OPEN,CLOSE ...are numbered at compile time.
- */
-
-#ifndef DOINIT
-extern char regarglen[];
-#else
-char regarglen[] = {0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2};
-#endif
-
-/* The following have no fixed length. */
-#ifndef DOINIT
-extern char varies[];
-#else
-char varies[] = {BRANCH,BACK,STAR,PLUS,CURLY,REF,0};
-#endif
-
-/* The following always have a length of 1. */
-#ifndef DOINIT
-extern char simple[];
-#else
-char simple[] = {ANY,ANYOF,ALNUM,NALNUM,SPACE,NSPACE,DIGIT,NDIGIT,0};
-#endif
-
-EXT char regdummy;
-
-/*
- * A node is one char of opcode followed by two chars of "next" pointer.
- * "Next" pointers are stored as two 8-bit pieces, high order first. The
- * value is a positive offset from the opcode of the node containing it.
- * An operand, if any, simply follows the node. (Note that much of the
- * code generation knows about this implicit relationship.)
- *
- * Using two bytes for the "next" pointer is vast overkill for most things,
- * but allows patterns to get big without disasters.
- *
- * [If REGALIGN is defined, the "next" pointer is always aligned on an even
- * boundary, and reads the offset directly as a short. Also, there is no
- * special test to reverse the sign of BACK pointers since the offset is
- * stored negative.]
- */
-
-#ifndef gould
-#ifndef cray
-#ifndef eta10
-#define REGALIGN
-#endif
-#endif
-#endif
-
-#define OP(p) (*(p))
-
-#ifndef lint
-#ifdef REGALIGN
-#define NEXT(p) (*(short*)(p+1))
-#define ARG1(p) (*(unsigned short*)(p+3))
-#define ARG2(p) (*(unsigned short*)(p+5))
-#else
-#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
-#define ARG1(p) (((*((p)+3)&0377)<<8) + (*((p)+4)&0377))
-#define ARG2(p) (((*((p)+5)&0377)<<8) + (*((p)+6)&0377))
-#endif
-#else /* lint */
-#define NEXT(p) 0
-#endif /* lint */
-
-#define OPERAND(p) ((p) + 3)
-
-#ifdef REGALIGN
-#define NEXTOPER(p) ((p) + 4)
-#else
-#define NEXTOPER(p) ((p) + 3)
-#endif
-
-#define MAGIC 0234
-
-/*
- * Utility definitions.
- */
-#ifndef lint
-#ifndef CHARBITS
-#define UCHARAT(p) ((int)*(unsigned char *)(p))
-#else
-#define UCHARAT(p) ((int)*(p)&CHARBITS)
-#endif
-#else /* lint */
-#define UCHARAT(p) regdummy
-#endif /* lint */
-
-#define FAIL(m) fatal("/%s/: %s",regprecomp,m)
-
-char *regnext();
-#ifdef DEBUGGING
-void regdump();
-char *regprop();
-#endif
-
diff --git a/gnu/usr.bin/perl/perl/regexec.c b/gnu/usr.bin/perl/perl/regexec.c
deleted file mode 100644
index b835306..0000000
--- a/gnu/usr.bin/perl/perl/regexec.c
+++ /dev/null
@@ -1,913 +0,0 @@
-/* NOTE: this is derived from Henry Spencer's regexp code, and should not
- * confused with the original package (see point 3 below). Thanks, Henry!
- */
-
-/* Additional note: this code is very heavily munged from Henry's version
- * in places. In some spots I've traded clarity for efficiency, so don't
- * blame Henry for some of the lack of readability.
- */
-
-/* $RCSfile: regexec.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:33 $
- *
- * $Log: regexec.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:33 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:39 nate
- * PERL!
- *
- * Revision 4.0.1.4 92/06/08 15:25:50 lwall
- * patch20: pattern modifiers i and g didn't interact right
- * patch20: in some cases $` and $' didn't get set by match
- * patch20: /x{0}/ was wrongly interpreted as /x{0,}/
- *
- * Revision 4.0.1.3 91/11/05 18:23:55 lwall
- * patch11: prepared for ctype implementations that don't define isascii()
- * patch11: initial .* in pattern had dependency on value of $*
- *
- * Revision 4.0.1.2 91/06/07 11:50:33 lwall
- * patch4: new copyright notice
- * patch4: // wouldn't use previous pattern if it started with a null character
- *
- * Revision 4.0.1.1 91/04/12 09:07:39 lwall
- * patch1: regexec only allocated space for 9 subexpresssions
- *
- * Revision 4.0 91/03/20 01:39:16 lwall
- * 4.0 baseline.
- *
- */
-/*SUPPRESS 112*/
-/*
- * regcomp and regexec -- regsub and regerror are not used in perl
- *
- * Copyright (c) 1986 by University of Toronto.
- * Written by Henry Spencer. Not derived from licensed software.
- *
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to redistribute it freely,
- * subject to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of
- * this software, no matter how awful, even if they arise
- * from defects in it.
- *
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission.
- *
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- *
- **** Alterations to Henry's code are...
- ****
- **** Copyright (c) 1991, Larry Wall
- ****
- **** You may distribute under the terms of either the GNU General Public
- **** License or the Artistic License, as specified in the README file.
- *
- * Beware that some of this code is subtly aware of the way operator
- * precedence is structured in regular expressions. Serious changes in
- * regular-expression syntax might require a total rethink.
- */
-#include "EXTERN.h"
-#include "perl.h"
-#include "regcomp.h"
-
-#ifndef STATIC
-#define STATIC static
-#endif
-
-#ifdef DEBUGGING
-int regnarrate = 0;
-#endif
-
-/*
- * regexec and friends
- */
-
-/*
- * Global work variables for regexec().
- */
-static char *regprecomp;
-static char *reginput; /* String-input pointer. */
-static char regprev; /* char before regbol, \n if none */
-static char *regbol; /* Beginning of input, for ^ check. */
-static char *regeol; /* End of input, for $ check. */
-static char **regstartp; /* Pointer to startp array. */
-static char **regendp; /* Ditto for endp. */
-static char *reglastparen; /* Similarly for lastparen. */
-static char *regtill;
-
-static int regmyp_size = 0;
-static char **regmystartp = Null(char**);
-static char **regmyendp = Null(char**);
-
-/*
- * Forwards.
- */
-STATIC int regtry();
-STATIC int regmatch();
-STATIC int regrepeat();
-
-extern int multiline;
-
-/*
- - regexec - match a regexp against a string
- */
-int
-regexec(prog, stringarg, strend, strbeg, minend, screamer, safebase)
-register regexp *prog;
-char *stringarg;
-register char *strend; /* pointer to null at end of string */
-char *strbeg; /* real beginning of string */
-int minend; /* end of match must be at least minend after stringarg */
-STR *screamer;
-int safebase; /* no need to remember string in subbase */
-{
- register char *s;
- register int i;
- register char *c;
- register char *string = stringarg;
- register int tmp;
- int minlen = 0; /* must match at least this many chars */
- int dontbother = 0; /* how many characters not to try at end */
-
- /* Be paranoid... */
- if (prog == NULL || string == NULL) {
- fatal("NULL regexp parameter");
- return(0);
- }
-
- if (string == strbeg) /* is ^ valid at stringarg? */
- regprev = '\n';
- else {
- regprev = stringarg[-1];
- if (!multiline && regprev == '\n')
- regprev = '\0'; /* force ^ to NOT match */
- }
- regprecomp = prog->precomp;
- /* Check validity of program. */
- if (UCHARAT(prog->program) != MAGIC) {
- FAIL("corrupted regexp program");
- }
-
- if (prog->do_folding) {
- i = strend - string;
- New(1101,c,i+1,char);
- Copy(string, c, i+1, char);
- string = c;
- strend = string + i;
- for (s = string; s < strend; s++)
- if (isUPPER(*s))
- *s = tolower(*s);
- }
-
- /* If there is a "must appear" string, look for it. */
- s = string;
- if (prog->regmust != Nullstr &&
- (!(prog->reganch & ROPT_ANCH)
- || (multiline && prog->regback >= 0)) ) {
- if (stringarg == strbeg && screamer) {
- if (screamfirst[prog->regmust->str_rare] >= 0)
- s = screaminstr(screamer,prog->regmust);
- else
- s = Nullch;
- }
-#ifndef lint
- else
- s = fbminstr((unsigned char*)s, (unsigned char*)strend,
- prog->regmust);
-#endif
- if (!s) {
- ++prog->regmust->str_u.str_useful; /* hooray */
- goto phooey; /* not present */
- }
- else if (prog->regback >= 0) {
- s -= prog->regback;
- if (s < string)
- s = string;
- minlen = prog->regback + prog->regmust->str_cur;
- }
- else if (--prog->regmust->str_u.str_useful < 0) { /* boo */
- str_free(prog->regmust);
- prog->regmust = Nullstr; /* disable regmust */
- s = string;
- }
- else {
- s = string;
- minlen = prog->regmust->str_cur;
- }
- }
-
- /* Mark beginning of line for ^ . */
- regbol = string;
-
- /* Mark end of line for $ (and such) */
- regeol = strend;
-
- /* see how far we have to get to not match where we matched before */
- regtill = string+minend;
-
- /* Allocate our backreference arrays */
- if ( regmyp_size < prog->nparens + 1 ) {
- /* Allocate or enlarge the arrays */
- regmyp_size = prog->nparens + 1;
- if ( regmyp_size < 10 ) regmyp_size = 10; /* minimum */
- if ( regmystartp ) {
- /* reallocate larger */
- Renew(regmystartp,regmyp_size,char*);
- Renew(regmyendp, regmyp_size,char*);
- }
- else {
- /* Initial allocation */
- New(1102,regmystartp,regmyp_size,char*);
- New(1102,regmyendp, regmyp_size,char*);
- }
-
- }
-
- /* Simplest case: anchored match need be tried only once. */
- /* [unless multiline is set] */
- if (prog->reganch & ROPT_ANCH) {
- if (regtry(prog, string))
- goto got_it;
- else if (multiline || (prog->reganch & ROPT_IMPLICIT)) {
- if (minlen)
- dontbother = minlen - 1;
- strend -= dontbother;
- /* for multiline we only have to try after newlines */
- if (s > string)
- s--;
- while (s < strend) {
- if (*s++ == '\n') {
- if (s < strend && regtry(prog, s))
- goto got_it;
- }
- }
- }
- goto phooey;
- }
-
- /* Messy cases: unanchored match. */
- if (prog->regstart) {
- if (prog->reganch & ROPT_SKIP) { /* we have /x+whatever/ */
- /* it must be a one character string */
- i = prog->regstart->str_ptr[0];
- while (s < strend) {
- if (*s == i) {
- if (regtry(prog, s))
- goto got_it;
- s++;
- while (s < strend && *s == i)
- s++;
- }
- s++;
- }
- }
- else if (prog->regstart->str_pok == 3) {
- /* We know what string it must start with. */
-#ifndef lint
- while ((s = fbminstr((unsigned char*)s,
- (unsigned char*)strend, prog->regstart)) != NULL)
-#else
- while (s = Nullch)
-#endif
- {
- if (regtry(prog, s))
- goto got_it;
- s++;
- }
- }
- else {
- c = prog->regstart->str_ptr;
- while ((s = ninstr(s, strend,
- c, c + prog->regstart->str_cur )) != NULL) {
- if (regtry(prog, s))
- goto got_it;
- s++;
- }
- }
- goto phooey;
- }
- /*SUPPRESS 560*/
- if (c = prog->regstclass) {
- int doevery = (prog->reganch & ROPT_SKIP) == 0;
-
- if (minlen)
- dontbother = minlen - 1;
- strend -= dontbother; /* don't bother with what can't match */
- tmp = 1;
- /* We know what class it must start with. */
- switch (OP(c)) {
- case ANYOF:
- c = OPERAND(c);
- while (s < strend) {
- i = UCHARAT(s);
- if (!(c[i >> 3] & (1 << (i&7)))) {
- if (tmp && regtry(prog, s))
- goto got_it;
- else
- tmp = doevery;
- }
- else
- tmp = 1;
- s++;
- }
- break;
- case BOUND:
- if (minlen)
- dontbother++,strend--;
- if (s != string) {
- i = s[-1];
- tmp = isALNUM(i);
- }
- else
- tmp = isALNUM(regprev); /* assume not alphanumeric */
- while (s < strend) {
- i = *s;
- if (tmp != isALNUM(i)) {
- tmp = !tmp;
- if (regtry(prog, s))
- goto got_it;
- }
- s++;
- }
- if ((minlen || tmp) && regtry(prog,s))
- goto got_it;
- break;
- case NBOUND:
- if (minlen)
- dontbother++,strend--;
- if (s != string) {
- i = s[-1];
- tmp = isALNUM(i);
- }
- else
- tmp = isALNUM(regprev); /* assume not alphanumeric */
- while (s < strend) {
- i = *s;
- if (tmp != isALNUM(i))
- tmp = !tmp;
- else if (regtry(prog, s))
- goto got_it;
- s++;
- }
- if ((minlen || !tmp) && regtry(prog,s))
- goto got_it;
- break;
- case ALNUM:
- while (s < strend) {
- i = *s;
- if (isALNUM(i)) {
- if (tmp && regtry(prog, s))
- goto got_it;
- else
- tmp = doevery;
- }
- else
- tmp = 1;
- s++;
- }
- break;
- case NALNUM:
- while (s < strend) {
- i = *s;
- if (!isALNUM(i)) {
- if (tmp && regtry(prog, s))
- goto got_it;
- else
- tmp = doevery;
- }
- else
- tmp = 1;
- s++;
- }
- break;
- case SPACE:
- while (s < strend) {
- if (isSPACE(*s)) {
- if (tmp && regtry(prog, s))
- goto got_it;
- else
- tmp = doevery;
- }
- else
- tmp = 1;
- s++;
- }
- break;
- case NSPACE:
- while (s < strend) {
- if (!isSPACE(*s)) {
- if (tmp && regtry(prog, s))
- goto got_it;
- else
- tmp = doevery;
- }
- else
- tmp = 1;
- s++;
- }
- break;
- case DIGIT:
- while (s < strend) {
- if (isDIGIT(*s)) {
- if (tmp && regtry(prog, s))
- goto got_it;
- else
- tmp = doevery;
- }
- else
- tmp = 1;
- s++;
- }
- break;
- case NDIGIT:
- while (s < strend) {
- if (!isDIGIT(*s)) {
- if (tmp && regtry(prog, s))
- goto got_it;
- else
- tmp = doevery;
- }
- else
- tmp = 1;
- s++;
- }
- break;
- }
- }
- else {
- if (minlen)
- dontbother = minlen - 1;
- strend -= dontbother;
- /* We don't know much -- general case. */
- do {
- if (regtry(prog, s))
- goto got_it;
- } while (s++ < strend);
- }
-
- /* Failure. */
- goto phooey;
-
- got_it:
- prog->subbeg = strbeg;
- prog->subend = strend;
- if ((!safebase && (prog->nparens || sawampersand)) || prog->do_folding){
- strend += dontbother; /* uncheat */
- if (safebase) /* no need for $digit later */
- s = strbeg;
- else if (strbeg != prog->subbase) {
- i = strend - string + (stringarg - strbeg);
- s = nsavestr(strbeg,i); /* so $digit will work later */
- if (prog->subbase)
- Safefree(prog->subbase);
- prog->subbeg = prog->subbase = s;
- prog->subend = s+i;
- }
- else {
- i = strend - string + (stringarg - strbeg);
- prog->subbeg = s = prog->subbase;
- prog->subend = s+i;
- }
- s += (stringarg - strbeg);
- for (i = 0; i <= prog->nparens; i++) {
- if (prog->endp[i]) {
- prog->startp[i] = s + (prog->startp[i] - string);
- prog->endp[i] = s + (prog->endp[i] - string);
- }
- }
- if (prog->do_folding)
- Safefree(string);
- }
- return(1);
-
- phooey:
- if (prog->do_folding)
- Safefree(string);
- return(0);
-}
-
-/*
- - regtry - try match at specific point
- */
-static int /* 0 failure, 1 success */
-regtry(prog, string)
-regexp *prog;
-char *string;
-{
- register int i;
- register char **sp;
- register char **ep;
-
- reginput = string;
- regstartp = prog->startp;
- regendp = prog->endp;
- reglastparen = &prog->lastparen;
- prog->lastparen = 0;
-
- sp = prog->startp;
- ep = prog->endp;
- if (prog->nparens) {
- for (i = prog->nparens; i >= 0; i--) {
- *sp++ = NULL;
- *ep++ = NULL;
- }
- }
- if (regmatch(prog->program + 1) && reginput >= regtill) {
- prog->startp[0] = string;
- prog->endp[0] = reginput;
- return(1);
- } else
- return(0);
-}
-
-/*
- - regmatch - main matching routine
- *
- * Conceptually the strategy is simple: check to see whether the current
- * node matches, call self recursively to see whether the rest matches,
- * and then act accordingly. In practice we make some effort to avoid
- * recursion, in particular by going through "ordinary" nodes (that don't
- * need to know whether the rest of the match failed) by a loop instead of
- * by recursion.
- */
-/* [lwall] I've hoisted the register declarations to the outer block in order to
- * maybe save a little bit of pushing and popping on the stack. It also takes
- * advantage of machines that use a register save mask on subroutine entry.
- */
-static int /* 0 failure, 1 success */
-regmatch(prog)
-char *prog;
-{
- register char *scan; /* Current node. */
- char *next; /* Next node. */
- register int nextchar;
- register int n; /* no or next */
- register int ln; /* len or last */
- register char *s; /* operand or save */
- register char *locinput = reginput;
-
- nextchar = *locinput;
- scan = prog;
-#ifdef DEBUGGING
- if (scan != NULL && regnarrate)
- fprintf(stderr, "%s(\n", regprop(scan));
-#endif
- while (scan != NULL) {
-#ifdef DEBUGGING
- if (regnarrate)
- fprintf(stderr, "%s...\n", regprop(scan));
-#endif
-
-#ifdef REGALIGN
- next = scan + NEXT(scan);
- if (next == scan)
- next = NULL;
-#else
- next = regnext(scan);
-#endif
-
- switch (OP(scan)) {
- case BOL:
- if (locinput == regbol ? regprev == '\n' :
- ((nextchar || locinput < regeol) &&
- locinput[-1] == '\n') )
- {
- /* regtill = regbol; */
- break;
- }
- return(0);
- case EOL:
- if ((nextchar || locinput < regeol) && nextchar != '\n')
- return(0);
- if (!multiline && regeol - locinput > 1)
- return 0;
- /* regtill = regbol; */
- break;
- case ANY:
- if ((nextchar == '\0' && locinput >= regeol) ||
- nextchar == '\n')
- return(0);
- nextchar = *++locinput;
- break;
- case EXACTLY:
- s = OPERAND(scan);
- ln = *s++;
- /* Inline the first character, for speed. */
- if (*s != nextchar)
- return(0);
- if (regeol - locinput < ln)
- return 0;
- if (ln > 1 && bcmp(s, locinput, ln) != 0)
- return(0);
- locinput += ln;
- nextchar = *locinput;
- break;
- case ANYOF:
- s = OPERAND(scan);
- if (nextchar < 0)
- nextchar = UCHARAT(locinput);
- if (s[nextchar >> 3] & (1 << (nextchar&7)))
- return(0);
- if (!nextchar && locinput >= regeol)
- return 0;
- nextchar = *++locinput;
- break;
- case ALNUM:
- if (!nextchar)
- return(0);
- if (!isALNUM(nextchar))
- return(0);
- nextchar = *++locinput;
- break;
- case NALNUM:
- if (!nextchar && locinput >= regeol)
- return(0);
- if (isALNUM(nextchar))
- return(0);
- nextchar = *++locinput;
- break;
- case NBOUND:
- case BOUND:
- if (locinput == regbol) /* was last char in word? */
- ln = isALNUM(regprev);
- else
- ln = isALNUM(locinput[-1]);
- n = isALNUM(nextchar); /* is next char in word? */
- if ((ln == n) == (OP(scan) == BOUND))
- return(0);
- break;
- case SPACE:
- if (!nextchar && locinput >= regeol)
- return(0);
- if (!isSPACE(nextchar))
- return(0);
- nextchar = *++locinput;
- break;
- case NSPACE:
- if (!nextchar)
- return(0);
- if (isSPACE(nextchar))
- return(0);
- nextchar = *++locinput;
- break;
- case DIGIT:
- if (!isDIGIT(nextchar))
- return(0);
- nextchar = *++locinput;
- break;
- case NDIGIT:
- if (!nextchar && locinput >= regeol)
- return(0);
- if (isDIGIT(nextchar))
- return(0);
- nextchar = *++locinput;
- break;
- case REF:
- n = ARG1(scan); /* which paren pair */
- s = regmystartp[n];
- if (!s)
- return(0);
- if (!regmyendp[n])
- return(0);
- if (s == regmyendp[n])
- break;
- /* Inline the first character, for speed. */
- if (*s != nextchar)
- return(0);
- ln = regmyendp[n] - s;
- if (locinput + ln > regeol)
- return 0;
- if (ln > 1 && bcmp(s, locinput, ln) != 0)
- return(0);
- locinput += ln;
- nextchar = *locinput;
- break;
-
- case NOTHING:
- break;
- case BACK:
- break;
- case OPEN:
- n = ARG1(scan); /* which paren pair */
- reginput = locinput;
-
- regmystartp[n] = locinput; /* for REF */
- if (regmatch(next)) {
- /*
- * Don't set startp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (regstartp[n] == NULL)
- regstartp[n] = locinput;
- return(1);
- } else
- return(0);
- /* NOTREACHED */
- case CLOSE: {
- n = ARG1(scan); /* which paren pair */
- reginput = locinput;
-
- regmyendp[n] = locinput; /* for REF */
- if (regmatch(next)) {
- /*
- * Don't set endp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (regendp[n] == NULL) {
- regendp[n] = locinput;
- if (n > *reglastparen)
- *reglastparen = n;
- }
- return(1);
- } else
- return(0);
- }
- /*NOTREACHED*/
- case BRANCH: {
- if (OP(next) != BRANCH) /* No choice. */
- next = NEXTOPER(scan); /* Avoid recursion. */
- else {
- do {
- reginput = locinput;
- if (regmatch(NEXTOPER(scan)))
- return(1);
-#ifdef REGALIGN
- /*SUPPRESS 560*/
- if (n = NEXT(scan))
- scan += n;
- else
- scan = NULL;
-#else
- scan = regnext(scan);
-#endif
- } while (scan != NULL && OP(scan) == BRANCH);
- return(0);
- /* NOTREACHED */
- }
- }
- break;
- case CURLY:
- ln = ARG1(scan); /* min to match */
- n = ARG2(scan); /* max to match */
- scan = NEXTOPER(scan) + 4;
- goto repeat;
- case STAR:
- ln = 0;
- n = 32767;
- scan = NEXTOPER(scan);
- goto repeat;
- case PLUS:
- /*
- * Lookahead to avoid useless match attempts
- * when we know what character comes next.
- */
- ln = 1;
- n = 32767;
- scan = NEXTOPER(scan);
- repeat:
- if (OP(next) == EXACTLY)
- nextchar = *(OPERAND(next)+1);
- else
- nextchar = -1000;
- reginput = locinput;
- n = regrepeat(scan, n);
- if (!multiline && OP(next) == EOL && ln < n)
- ln = n; /* why back off? */
- while (n >= ln) {
- /* If it could work, try it. */
- if (nextchar == -1000 || *reginput == nextchar)
- if (regmatch(next))
- return(1);
- /* Couldn't or didn't -- back up. */
- n--;
- reginput = locinput + n;
- }
- return(0);
- case END:
- reginput = locinput; /* put where regtry can find it */
- return(1); /* Success! */
- default:
- printf("%x %d\n",scan,scan[1]);
- FAIL("regexp memory corruption");
- }
-
- scan = next;
- }
-
- /*
- * We get here only if there's trouble -- normally "case END" is
- * the terminating point.
- */
- FAIL("corrupted regexp pointers");
- /*NOTREACHED*/
-#ifdef lint
- return 0;
-#endif
-}
-
-/*
- - regrepeat - repeatedly match something simple, report how many
- */
-/*
- * [This routine now assumes that it will only match on things of length 1.
- * That was true before, but now we assume scan - reginput is the count,
- * rather than incrementing count on every character.]
- */
-static int
-regrepeat(p, max)
-char *p;
-int max;
-{
- register char *scan;
- register char *opnd;
- register int c;
- register char *loceol = regeol;
-
- scan = reginput;
- if (max != 32767 && max < loceol - scan)
- loceol = scan + max;
- opnd = OPERAND(p);
- switch (OP(p)) {
- case ANY:
- while (scan < loceol && *scan != '\n')
- scan++;
- break;
- case EXACTLY: /* length of string is 1 */
- opnd++;
- while (scan < loceol && *opnd == *scan)
- scan++;
- break;
- case ANYOF:
- c = UCHARAT(scan);
- while (scan < loceol && !(opnd[c >> 3] & (1 << (c & 7)))) {
- scan++;
- c = UCHARAT(scan);
- }
- break;
- case ALNUM:
- while (scan < loceol && isALNUM(*scan))
- scan++;
- break;
- case NALNUM:
- while (scan < loceol && !isALNUM(*scan))
- scan++;
- break;
- case SPACE:
- while (scan < loceol && isSPACE(*scan))
- scan++;
- break;
- case NSPACE:
- while (scan < loceol && !isSPACE(*scan))
- scan++;
- break;
- case DIGIT:
- while (scan < loceol && isDIGIT(*scan))
- scan++;
- break;
- case NDIGIT:
- while (scan < loceol && !isDIGIT(*scan))
- scan++;
- break;
- default: /* Oh dear. Called inappropriately. */
- FAIL("internal regexp foulup");
- /* NOTREACHED */
- }
-
- c = scan - reginput;
- reginput = scan;
-
- return(c);
-}
-
-/*
- - regnext - dig the "next" pointer out of a node
- *
- * [Note, when REGALIGN is defined there are two places in regmatch()
- * that bypass this code for speed.]
- */
-char *
-regnext(p)
-register char *p;
-{
- register int offset;
-
- if (p == &regdummy)
- return(NULL);
-
- offset = NEXT(p);
- if (offset == 0)
- return(NULL);
-
-#ifdef REGALIGN
- return(p+offset);
-#else
- if (OP(p) == BACK)
- return(p-offset);
- else
- return(p+offset);
-#endif
-}
diff --git a/gnu/usr.bin/perl/perl/regexp.h b/gnu/usr.bin/perl/perl/regexp.h
deleted file mode 100644
index 634b19b..0000000
--- a/gnu/usr.bin/perl/perl/regexp.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Definitions etc. for regexp(3) routines.
- *
- * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
- * not the System V one.
- */
-
-/* $RCSfile: regexp.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:35 $
- *
- * $Log: regexp.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:35 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:39 nate
- * PERL!
- *
- * Revision 4.0.1.2 91/11/05 18:24:31 lwall
- * patch11: minimum match length calculation in regexp is now cumulative
- * patch11: initial .* in pattern had dependency on value of $*
- *
- * Revision 4.0.1.1 91/06/07 11:51:18 lwall
- * patch4: new copyright notice
- * patch4: // wouldn't use previous pattern if it started with a null character
- * patch4: $` was busted inside s///
- *
- * Revision 4.0 91/03/20 01:39:23 lwall
- * 4.0 baseline.
- *
- */
-
-typedef struct regexp {
- char **startp;
- char **endp;
- STR *regstart; /* Internal use only. */
- char *regstclass;
- STR *regmust; /* Internal use only. */
- int regback; /* Can regmust locate first try? */
- int minlen; /* mininum possible length of $& */
- int prelen; /* length of precomp */
- char *precomp; /* pre-compilation regular expression */
- char *subbase; /* saved string so \digit works forever */
- char *subbeg; /* same, but not responsible for allocation */
- char *subend; /* end of subbase */
- char reganch; /* Internal use only. */
- char do_folding; /* do case-insensitive match? */
- char lastparen; /* last paren matched */
- char nparens; /* number of parentheses */
- char program[1]; /* Unwarranted chumminess with compiler. */
-} regexp;
-
-#define ROPT_ANCH 1
-#define ROPT_SKIP 2
-#define ROPT_IMPLICIT 4
-
-regexp *regcomp();
-int regexec();
diff --git a/gnu/usr.bin/perl/perl/spat.h b/gnu/usr.bin/perl/perl/spat.h
deleted file mode 100644
index 7c392b0..0000000
--- a/gnu/usr.bin/perl/perl/spat.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* $RCSfile: spat.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:35 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: spat.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:35 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:39 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 11:51:59 lwall
- * patch4: new copyright notice
- * patch4: added global modifier for pattern matches
- *
- * Revision 4.0 91/03/20 01:39:36 lwall
- * 4.0 baseline.
- *
- */
-
-struct scanpat {
- SPAT *spat_next; /* list of all scanpats */
- REGEXP *spat_regexp; /* compiled expression */
- ARG *spat_repl; /* replacement string for subst */
- ARG *spat_runtime; /* compile pattern at runtime */
- STR *spat_short; /* for a fast bypass of execute() */
- short spat_flags;
- char spat_slen;
-};
-
-#define SPAT_USED 1 /* spat has been used once already */
-#define SPAT_ONCE 2 /* use pattern only once per reset */
-#define SPAT_SCANFIRST 4 /* initial constant not anchored */
-#define SPAT_ALL 8 /* initial constant is whole pat */
-#define SPAT_SKIPWHITE 16 /* skip leading whitespace for split */
-#define SPAT_FOLD 32 /* case insensitivity */
-#define SPAT_CONST 64 /* subst replacement is constant */
-#define SPAT_KEEP 128 /* keep 1st runtime pattern forever */
-#define SPAT_GLOBAL 256 /* pattern had a g modifier */
-
-EXT SPAT *curspat; /* what to do \ interps from */
-EXT SPAT *lastspat; /* what to use in place of null pattern */
-
-EXT char *hint INIT(Nullch); /* hint from cmd_exec to do_match et al */
-
-#define Nullspat Null(SPAT*)
diff --git a/gnu/usr.bin/perl/perl/stab.c b/gnu/usr.bin/perl/perl/stab.c
deleted file mode 100644
index 6edb599..0000000
--- a/gnu/usr.bin/perl/perl/stab.c
+++ /dev/null
@@ -1,1061 +0,0 @@
-/* $RCSfile: stab.c,v $$Revision: 1.2 $$Date: 1995/05/30 05:03:19 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: stab.c,v $
- * Revision 1.2 1995/05/30 05:03:19 rgrimes
- * Remove trailing whitespace.
- *
- * Revision 1.1.1.1 1994/09/10 06:27:33 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:39 nate
- * PERL!
- *
- * Revision 4.0.1.5 1993/02/05 19:42:47 lwall
- * patch36: length returned wrong value on certain semi-magical variables
- *
- * Revision 4.0.1.4 92/06/08 15:32:19 lwall
- * patch20: fixed confusion between a *var's real name and its effective name
- * patch20: the debugger now warns you on lines that can't set a breakpoint
- * patch20: the debugger made perl forget the last pattern used by //
- * patch20: paragraph mode now skips extra newlines automatically
- * patch20: ($<,$>) = ... didn't work on some architectures
- *
- * Revision 4.0.1.3 91/11/05 18:35:33 lwall
- * patch11: length($x) was sometimes wrong for numeric $x
- * patch11: perl now issues warning if $SIG{'ALARM'} is referenced
- * patch11: *foo = undef coredumped
- * patch11: solitary subroutine references no longer trigger typo warnings
- * patch11: local(*FILEHANDLE) had a memory leak
- *
- * Revision 4.0.1.2 91/06/07 11:55:53 lwall
- * patch4: new copyright notice
- * patch4: added $^P variable to control calling of perldb routines
- * patch4: added $^F variable to specify maximum system fd, default 2
- * patch4: $` was busted inside s///
- * patch4: default top-of-form format is now FILEHANDLE_TOP
- * patch4: length($`), length($&), length($') now optimized to avoid string copy
- * patch4: $^D |= 1024 now does syntax tree dump at run-time
- *
- * Revision 4.0.1.1 91/04/12 09:10:24 lwall
- * patch1: Configure now differentiates getgroups() type from getgid() type
- * patch1: you may now use "die" and "caller" in a signal handler
- *
- * Revision 4.0 91/03/20 01:39:41 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX)
-#include <signal.h>
-#endif
-
-static char *sig_name[] = {
- SIG_NAME,0
-};
-
-#ifdef VOIDSIG
-#define handlertype void
-#else
-#define handlertype int
-#endif
-
-static handlertype sighandler();
-
-static int origalen = 0;
-
-STR *
-stab_str(str)
-STR *str;
-{
- STAB *stab = str->str_u.str_stab;
- register int paren;
- register char *s;
- register int i;
-
- if (str->str_rare)
- return stab_val(stab);
-
- switch (*stab->str_magic->str_ptr) {
- case '\004': /* ^D */
-#ifdef DEBUGGING
- str_numset(stab_val(stab),(double)(debug & 32767));
-#endif
- break;
- case '\006': /* ^F */
- str_numset(stab_val(stab),(double)maxsysfd);
- break;
- case '\t': /* ^I */
- if (inplace)
- str_set(stab_val(stab), inplace);
- else
- str_sset(stab_val(stab),&str_undef);
- break;
- case '\020': /* ^P */
- str_numset(stab_val(stab),(double)perldb);
- break;
- case '\024': /* ^T */
- str_numset(stab_val(stab),(double)basetime);
- break;
- case '\027': /* ^W */
- str_numset(stab_val(stab),(double)dowarn);
- break;
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9': case '&':
- if (curspat) {
- paren = atoi(stab_ename(stab));
- getparen:
- if (curspat->spat_regexp &&
- paren <= curspat->spat_regexp->nparens &&
- (s = curspat->spat_regexp->startp[paren]) ) {
- i = curspat->spat_regexp->endp[paren] - s;
- if (i >= 0)
- str_nset(stab_val(stab),s,i);
- else
- str_sset(stab_val(stab),&str_undef);
- }
- else
- str_sset(stab_val(stab),&str_undef);
- }
- break;
- case '+':
- if (curspat) {
- paren = curspat->spat_regexp->lastparen;
- goto getparen;
- }
- break;
- case '`':
- if (curspat) {
- if (curspat->spat_regexp &&
- (s = curspat->spat_regexp->subbeg) ) {
- i = curspat->spat_regexp->startp[0] - s;
- if (i >= 0)
- str_nset(stab_val(stab),s,i);
- else
- str_nset(stab_val(stab),"",0);
- }
- else
- str_nset(stab_val(stab),"",0);
- }
- break;
- case '\'':
- if (curspat) {
- if (curspat->spat_regexp &&
- (s = curspat->spat_regexp->endp[0]) ) {
- str_nset(stab_val(stab),s, curspat->spat_regexp->subend - s);
- }
- else
- str_nset(stab_val(stab),"",0);
- }
- break;
- case '.':
-#ifndef lint
- if (last_in_stab && stab_io(last_in_stab)) {
- str_numset(stab_val(stab),(double)stab_io(last_in_stab)->lines);
- }
-#endif
- break;
- case '?':
- str_numset(stab_val(stab),(double)statusvalue);
- break;
- case '^':
- s = stab_io(curoutstab)->top_name;
- if (s)
- str_set(stab_val(stab),s);
- else {
- str_set(stab_val(stab),stab_ename(curoutstab));
- str_cat(stab_val(stab),"_TOP");
- }
- break;
- case '~':
- s = stab_io(curoutstab)->fmt_name;
- if (!s)
- s = stab_ename(curoutstab);
- str_set(stab_val(stab),s);
- break;
-#ifndef lint
- case '=':
- str_numset(stab_val(stab),(double)stab_io(curoutstab)->page_len);
- break;
- case '-':
- str_numset(stab_val(stab),(double)stab_io(curoutstab)->lines_left);
- break;
- case '%':
- str_numset(stab_val(stab),(double)stab_io(curoutstab)->page);
- break;
-#endif
- case ':':
- break;
- case '/':
- break;
- case '[':
- str_numset(stab_val(stab),(double)arybase);
- break;
- case '|':
- if (!stab_io(curoutstab))
- stab_io(curoutstab) = stio_new();
- str_numset(stab_val(stab),
- (double)((stab_io(curoutstab)->flags & IOF_FLUSH) != 0) );
- break;
- case ',':
- str_nset(stab_val(stab),ofs,ofslen);
- break;
- case '\\':
- str_nset(stab_val(stab),ors,orslen);
- break;
- case '#':
- str_set(stab_val(stab),ofmt);
- break;
- case '!':
- str_numset(stab_val(stab), (double)errno);
- str_set(stab_val(stab), errno ? strerror(errno) : "");
- stab_val(stab)->str_nok = 1; /* what a wonderful hack! */
- break;
- case '<':
- str_numset(stab_val(stab),(double)uid);
- break;
- case '>':
- str_numset(stab_val(stab),(double)euid);
- break;
- case '(':
- s = buf;
- (void)sprintf(s,"%d",(int)gid);
- goto add_groups;
- case ')':
- s = buf;
- (void)sprintf(s,"%d",(int)egid);
- add_groups:
- while (*s) s++;
-#ifdef HAS_GETGROUPS
-#ifndef NGROUPS
-#define NGROUPS 32
-#endif
- {
- GROUPSTYPE gary[NGROUPS];
-
- i = getgroups(NGROUPS,gary);
- while (--i >= 0) {
- (void)sprintf(s," %ld", (long)gary[i]);
- while (*s) s++;
- }
- }
-#endif
- str_set(stab_val(stab),buf);
- break;
- case '*':
- break;
- case '0':
- break;
- default:
- {
- struct ufuncs *uf = (struct ufuncs *)str->str_ptr;
-
- if (uf && uf->uf_val)
- (*uf->uf_val)(uf->uf_index, stab_val(stab));
- }
- break;
- }
- return stab_val(stab);
-}
-
-STRLEN
-stab_len(str)
-STR *str;
-{
- STAB *stab = str->str_u.str_stab;
- int paren;
- int i;
- char *s;
-
- if (str->str_rare)
- return str_len(stab_val(stab));
-
- switch (*stab->str_magic->str_ptr) {
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9': case '&':
- if (curspat) {
- paren = atoi(stab_ename(stab));
- getparen:
- if (curspat->spat_regexp &&
- paren <= curspat->spat_regexp->nparens &&
- (s = curspat->spat_regexp->startp[paren]) ) {
- i = curspat->spat_regexp->endp[paren] - s;
- if (i >= 0)
- return i;
- else
- return 0;
- }
- else
- return 0;
- }
- break;
- case '+':
- if (curspat) {
- paren = curspat->spat_regexp->lastparen;
- goto getparen;
- }
- break;
- case '`':
- if (curspat) {
- if (curspat->spat_regexp &&
- (s = curspat->spat_regexp->subbeg) ) {
- i = curspat->spat_regexp->startp[0] - s;
- if (i >= 0)
- return i;
- else
- return 0;
- }
- else
- return 0;
- }
- break;
- case '\'':
- if (curspat) {
- if (curspat->spat_regexp &&
- (s = curspat->spat_regexp->endp[0]) ) {
- return (STRLEN) (curspat->spat_regexp->subend - s);
- }
- else
- return 0;
- }
- break;
- case ',':
- return (STRLEN)ofslen;
- case '\\':
- return (STRLEN)orslen;
- }
- return str_len(stab_str(str));
-}
-
-void
-stabset(mstr,str)
-register STR *mstr;
-STR *str;
-{
- STAB *stab;
- register char *s;
- int i;
-
- switch (mstr->str_rare) {
- case 'E':
- my_setenv(mstr->str_ptr,str_get(str));
- /* And you'll never guess what the dog had */
- /* in its mouth... */
-#ifdef TAINT
- if (strEQ(mstr->str_ptr,"PATH")) {
- char *strend = str->str_ptr + str->str_cur;
-
- s = str->str_ptr;
- while (s < strend) {
- s = cpytill(tokenbuf,s,strend,':',&i);
- s++;
- if (*tokenbuf != '/'
- || (stat(tokenbuf,&statbuf) && (statbuf.st_mode & 2)) )
- str->str_tainted = 2;
- }
- }
-#endif
- break;
- case 'S':
- s = str_get(str);
- i = whichsig(mstr->str_ptr); /* ...no, a brick */
- if (!i && (dowarn || strEQ(mstr->str_ptr,"ALARM")))
- warn("No such signal: SIG%s", mstr->str_ptr);
- if (strEQ(s,"IGNORE"))
-#ifndef lint
- (void)signal(i,SIG_IGN);
-#else
- ;
-#endif
- else if (strEQ(s,"DEFAULT") || !*s)
- (void)signal(i,SIG_DFL);
- else {
- (void)signal(i,sighandler);
- if (!index(s,'\'')) {
- sprintf(tokenbuf, "main'%s",s);
- str_set(str,tokenbuf);
- }
- }
- break;
-#ifdef SOME_DBM
- case 'D':
- stab = mstr->str_u.str_stab;
- hdbmstore(stab_hash(stab),mstr->str_ptr,mstr->str_cur,str);
- break;
-#endif
- case 'L':
- {
- CMD *cmd;
-
- stab = mstr->str_u.str_stab;
- i = str_true(str);
- str = afetch(stab_xarray(stab),atoi(mstr->str_ptr), FALSE);
- if (str->str_magic && (cmd = str->str_magic->str_u.str_cmd)) {
- cmd->c_flags &= ~CF_OPTIMIZE;
- cmd->c_flags |= i? CFT_D1 : CFT_D0;
- }
- else
- warn("Can't break at that line\n");
- }
- break;
- case '#':
- stab = mstr->str_u.str_stab;
- afill(stab_array(stab), (int)str_gnum(str) - arybase);
- break;
- case 'X': /* merely a copy of a * string */
- break;
- case '*':
- s = str->str_pok ? str_get(str) : "";
- if (strNE(s,"StB") || str->str_cur != sizeof(STBP)) {
- stab = mstr->str_u.str_stab;
- if (!*s) {
- STBP *stbp;
-
- /*SUPPRESS 701*/
- (void)savenostab(stab); /* schedule a free of this stab */
- if (stab->str_len)
- Safefree(stab->str_ptr);
- Newz(601,stbp, 1, STBP);
- stab->str_ptr = stbp;
- stab->str_len = stab->str_cur = sizeof(STBP);
- stab->str_pok = 1;
- strcpy(stab_magic(stab),"StB");
- stab_val(stab) = Str_new(70,0);
- stab_line(stab) = curcmd->c_line;
- stab_estab(stab) = stab;
- }
- else {
- stab = stabent(s,TRUE);
- if (!stab_xarray(stab))
- aadd(stab);
- if (!stab_xhash(stab))
- hadd(stab);
- if (!stab_io(stab))
- stab_io(stab) = stio_new();
- }
- str_sset(str, (STR*) stab);
- }
- break;
- case 's': {
- struct lstring *lstr = (struct lstring*)str;
- char *tmps;
-
- mstr->str_rare = 0;
- str->str_magic = Nullstr;
- tmps = str_get(str);
- str_insert(mstr,lstr->lstr_offset,lstr->lstr_len,
- tmps,str->str_cur);
- }
- break;
-
- case 'v':
- do_vecset(mstr,str);
- break;
-
- case 0:
- /*SUPPRESS 560*/
- if (!(stab = mstr->str_u.str_stab))
- break;
- switch (*stab->str_magic->str_ptr) {
- case '\004': /* ^D */
-#ifdef DEBUGGING
- debug = (int)(str_gnum(str)) | 32768;
- if (debug & 1024)
- dump_all();
-#endif
- break;
- case '\006': /* ^F */
- maxsysfd = (int)str_gnum(str);
- break;
- case '\t': /* ^I */
- if (inplace)
- Safefree(inplace);
- if (str->str_pok || str->str_nok)
- inplace = savestr(str_get(str));
- else
- inplace = Nullch;
- break;
- case '\020': /* ^P */
- i = (int)str_gnum(str);
- if (i != perldb) {
- static SPAT *oldlastspat;
-
- if (perldb)
- oldlastspat = lastspat;
- else
- lastspat = oldlastspat;
- }
- perldb = i;
- break;
- case '\024': /* ^T */
- basetime = (time_t)str_gnum(str);
- break;
- case '\027': /* ^W */
- dowarn = (bool)str_gnum(str);
- break;
- case '.':
- if (localizing)
- savesptr((STR**)&last_in_stab);
- break;
- case '^':
- Safefree(stab_io(curoutstab)->top_name);
- stab_io(curoutstab)->top_name = s = savestr(str_get(str));
- stab_io(curoutstab)->top_stab = stabent(s,TRUE);
- break;
- case '~':
- Safefree(stab_io(curoutstab)->fmt_name);
- stab_io(curoutstab)->fmt_name = s = savestr(str_get(str));
- stab_io(curoutstab)->fmt_stab = stabent(s,TRUE);
- break;
- case '=':
- stab_io(curoutstab)->page_len = (long)str_gnum(str);
- break;
- case '-':
- stab_io(curoutstab)->lines_left = (long)str_gnum(str);
- if (stab_io(curoutstab)->lines_left < 0L)
- stab_io(curoutstab)->lines_left = 0L;
- break;
- case '%':
- stab_io(curoutstab)->page = (long)str_gnum(str);
- break;
- case '|':
- if (!stab_io(curoutstab))
- stab_io(curoutstab) = stio_new();
- stab_io(curoutstab)->flags &= ~IOF_FLUSH;
- if (str_gnum(str) != 0.0) {
- stab_io(curoutstab)->flags |= IOF_FLUSH;
- }
- break;
- case '*':
- i = (int)str_gnum(str);
- multiline = (i != 0);
- break;
- case '/':
- if (str->str_pok) {
- rs = str_get(str);
- rslen = str->str_cur;
- if (rspara = !rslen) {
- rs = "\n\n";
- rslen = 2;
- }
- rschar = rs[rslen - 1];
- }
- else {
- rschar = 0777; /* fake a non-existent char */
- rslen = 1;
- }
- break;
- case '\\':
- if (ors)
- Safefree(ors);
- ors = savestr(str_get(str));
- orslen = str->str_cur;
- break;
- case ',':
- if (ofs)
- Safefree(ofs);
- ofs = savestr(str_get(str));
- ofslen = str->str_cur;
- break;
- case '#':
- if (ofmt)
- Safefree(ofmt);
- ofmt = savestr(str_get(str));
- break;
- case '[':
- arybase = (int)str_gnum(str);
- break;
- case '?':
- statusvalue = U_S(str_gnum(str));
- break;
- case '!':
- errno = (int)str_gnum(str); /* will anyone ever use this? */
- break;
- case '<':
- uid = (int)str_gnum(str);
- if (delaymagic) {
- delaymagic |= DM_RUID;
- break; /* don't do magic till later */
- }
-#ifdef HAS_SETRUID
- (void)setruid((UIDTYPE)uid);
-#else
-#ifdef HAS_SETREUID
- (void)setreuid((UIDTYPE)uid, (UIDTYPE)-1);
-#else
- if (uid == euid) /* special case $< = $> */
- (void)setuid(uid);
- else
- fatal("setruid() not implemented");
-#endif
-#endif
- uid = (int)getuid();
- break;
- case '>':
- euid = (int)str_gnum(str);
- if (delaymagic) {
- delaymagic |= DM_EUID;
- break; /* don't do magic till later */
- }
-#ifdef HAS_SETEUID
- (void)seteuid((UIDTYPE)euid);
-#else
-#ifdef HAS_SETREUID
- (void)setreuid((UIDTYPE)-1, (UIDTYPE)euid);
-#else
- if (euid == uid) /* special case $> = $< */
- setuid(euid);
- else
- fatal("seteuid() not implemented");
-#endif
-#endif
- euid = (int)geteuid();
- break;
- case '(':
- gid = (int)str_gnum(str);
- if (delaymagic) {
- delaymagic |= DM_RGID;
- break; /* don't do magic till later */
- }
-#ifdef HAS_SETRGID
- (void)setrgid((GIDTYPE)gid);
-#else
-#ifdef HAS_SETREGID
- (void)setregid((GIDTYPE)gid, (GIDTYPE)-1);
-#else
- if (gid == egid) /* special case $( = $) */
- (void)setgid(gid);
- else
- fatal("setrgid() not implemented");
-#endif
-#endif
- gid = (int)getgid();
- break;
- case ')':
- egid = (int)str_gnum(str);
- if (delaymagic) {
- delaymagic |= DM_EGID;
- break; /* don't do magic till later */
- }
-#ifdef HAS_SETEGID
- (void)setegid((GIDTYPE)egid);
-#else
-#ifdef HAS_SETREGID
- (void)setregid((GIDTYPE)-1, (GIDTYPE)egid);
-#else
- if (egid == gid) /* special case $) = $( */
- (void)setgid(egid);
- else
- fatal("setegid() not implemented");
-#endif
-#endif
- egid = (int)getegid();
- break;
- case ':':
- chopset = str_get(str);
- break;
- case '0':
- if (!origalen) {
- s = origargv[0];
- s += strlen(s);
- /* See if all the arguments are contiguous in memory */
- for (i = 1; i < origargc; i++) {
- if (origargv[i] == s + 1)
- s += strlen(++s); /* this one is ok too */
- }
- if (origenviron[0] == s + 1) { /* can grab env area too? */
- my_setenv("NoNeSuCh", Nullch);
- /* force copy of environment */
- for (i = 0; origenviron[i]; i++)
- if (origenviron[i] == s + 1)
- s += strlen(++s);
- }
- origalen = s - origargv[0];
- }
- s = str_get(str);
- i = str->str_cur;
- if (i >= origalen) {
- i = origalen;
- str->str_cur = i;
- str->str_ptr[i] = '\0';
- Copy(s, origargv[0], i, char);
- }
- else {
- Copy(s, origargv[0], i, char);
- s = origargv[0]+i;
- *s++ = '\0';
- while (++i < origalen)
- *s++ = ' ';
- }
- break;
- default:
- {
- struct ufuncs *uf = (struct ufuncs *)str->str_magic->str_ptr;
-
- if (uf && uf->uf_set)
- (*uf->uf_set)(uf->uf_index, str);
- }
- break;
- }
- break;
- }
-}
-
-int
-whichsig(sig)
-char *sig;
-{
- register char **sigv;
-
- for (sigv = sig_name+1; *sigv; sigv++)
- if (strEQ(sig,*sigv))
- return sigv - sig_name;
-#ifdef SIGCLD
- if (strEQ(sig,"CHLD"))
- return SIGCLD;
-#endif
-#ifdef SIGCHLD
- if (strEQ(sig,"CLD"))
- return SIGCHLD;
-#endif
- return 0;
-}
-
-static handlertype
-sighandler(sig)
-int sig;
-{
- STAB *stab;
- STR *str;
- int oldsave = savestack->ary_fill;
- int oldtmps_base = tmps_base;
- register CSV *csv;
- SUBR *sub;
-
-#ifdef OS2 /* or anybody else who requires SIG_ACK */
- signal(sig, SIG_ACK);
-#endif
- stab = stabent(
- str_get(hfetch(stab_hash(sigstab),sig_name[sig],strlen(sig_name[sig]),
- TRUE)), TRUE);
- sub = stab_sub(stab);
- if (!sub && *sig_name[sig] == 'C' && instr(sig_name[sig],"LD")) {
- if (sig_name[sig][1] == 'H')
- stab = stabent(str_get(hfetch(stab_hash(sigstab),"CLD",3,TRUE)),
- TRUE);
- else
- stab = stabent(str_get(hfetch(stab_hash(sigstab),"CHLD",4,TRUE)),
- TRUE);
- sub = stab_sub(stab); /* gag */
- }
- if (!sub) {
- if (dowarn)
- warn("SIG%s handler \"%s\" not defined.\n",
- sig_name[sig], stab_ename(stab) );
- return;
- }
- /*SUPPRESS 701*/
- saveaptr(&stack);
- str = Str_new(15, sizeof(CSV));
- str->str_state = SS_SCSV;
- (void)apush(savestack,str);
- csv = (CSV*)str->str_ptr;
- csv->sub = sub;
- csv->stab = stab;
- csv->curcsv = curcsv;
- csv->curcmd = curcmd;
- csv->depth = sub->depth;
- csv->wantarray = G_SCALAR;
- csv->hasargs = TRUE;
- csv->savearray = stab_xarray(defstab);
- csv->argarray = stab_xarray(defstab) = stack = anew(defstab);
- stack->ary_flags = 0;
- curcsv = csv;
- str = str_mortal(&str_undef);
- str_set(str,sig_name[sig]);
- (void)apush(stab_xarray(defstab),str);
- sub->depth++;
- if (sub->depth >= 2) { /* save temporaries on recursion? */
- if (sub->depth == 100 && dowarn)
- warn("Deep recursion on subroutine \"%s\"",stab_ename(stab));
- savelist(sub->tosave->ary_array,sub->tosave->ary_fill);
- }
-
- tmps_base = tmps_max; /* protect our mortal string */
- (void)cmd_exec(sub->cmd,G_SCALAR,0); /* so do it already */
- tmps_base = oldtmps_base;
-
- restorelist(oldsave); /* put everything back */
-}
-
-STAB *
-aadd(stab)
-register STAB *stab;
-{
- if (!stab_xarray(stab))
- stab_xarray(stab) = anew(stab);
- return stab;
-}
-
-STAB *
-hadd(stab)
-register STAB *stab;
-{
- if (!stab_xhash(stab))
- stab_xhash(stab) = hnew(COEFFSIZE);
- return stab;
-}
-
-STAB *
-fstab(name)
-char *name;
-{
- char tmpbuf[1200];
- STAB *stab;
-
- snprintf(tmpbuf,sizeof(tmpbuf), "'_<%s", name);
- stab = stabent(tmpbuf, TRUE);
- str_set(stab_val(stab), name);
- if (perldb)
- (void)hadd(aadd(stab));
- return stab;
-}
-
-STAB *
-stabent(name,add)
-register char *name;
-int add;
-{
- register STAB *stab;
- register STBP *stbp;
- int len;
- register char *namend;
- HASH *stash;
- char *sawquote = Nullch;
- char *prevquote = Nullch;
- bool global = FALSE;
-
- if (isUPPER(*name)) {
- if (*name > 'I') {
- if (*name == 'S' && (
- strEQ(name, "SIG") ||
- strEQ(name, "STDIN") ||
- strEQ(name, "STDOUT") ||
- strEQ(name, "STDERR") ))
- global = TRUE;
- }
- else if (*name > 'E') {
- if (*name == 'I' && strEQ(name, "INC"))
- global = TRUE;
- }
- else if (*name > 'A') {
- if (*name == 'E' && strEQ(name, "ENV"))
- global = TRUE;
- }
- else if (*name == 'A' && (
- strEQ(name, "ARGV") ||
- strEQ(name, "ARGVOUT") ))
- global = TRUE;
- }
- for (namend = name; *namend; namend++) {
- if (*namend == '\'' && namend[1])
- prevquote = sawquote, sawquote = namend;
- }
- if (sawquote == name && name[1]) {
- stash = defstash;
- sawquote = Nullch;
- name++;
- }
- else if (!isALPHA(*name) || global)
- stash = defstash;
- else if ((CMD*)curcmd == &compiling)
- stash = curstash;
- else
- stash = curcmd->c_stash;
- if (sawquote) {
- char tmpbuf[256];
- char *s, *d;
-
- *sawquote = '\0';
- /*SUPPRESS 560*/
- if (s = prevquote) {
- strncpy(tmpbuf,name,s-name+1);
- d = tmpbuf+(s-name+1);
- *d++ = '_';
- strcpy(d,s+1);
- }
- else {
- *tmpbuf = '_';
- strcpy(tmpbuf+1,name);
- }
- stab = stabent(tmpbuf,TRUE);
- if (!(stash = stab_xhash(stab)))
- stash = stab_xhash(stab) = hnew(0);
- if (!stash->tbl_name)
- stash->tbl_name = savestr(name);
- name = sawquote+1;
- *sawquote = '\'';
- }
- len = namend - name;
- stab = (STAB*)hfetch(stash,name,len,add);
- if (stab == (STAB*)&str_undef)
- return Nullstab;
- if (stab->str_pok) {
- stab->str_pok |= SP_MULTI;
- return stab;
- }
- else {
- if (stab->str_len)
- Safefree(stab->str_ptr);
- Newz(602,stbp, 1, STBP);
- stab->str_ptr = stbp;
- stab->str_len = stab->str_cur = sizeof(STBP);
- stab->str_pok = 1;
- strcpy(stab_magic(stab),"StB");
- stab_val(stab) = Str_new(72,0);
- stab_line(stab) = curcmd->c_line;
- stab_estab(stab) = stab;
- str_magic((STR*)stab, stab, '*', name, len);
- stab_stash(stab) = stash;
- if (isDIGIT(*name) && *name != '0') {
- stab_flags(stab) = SF_VMAGIC;
- str_magic(stab_val(stab), stab, 0, Nullch, 0);
- }
- if (add & 2)
- stab->str_pok |= SP_MULTI;
- return stab;
- }
-}
-
-void
-stab_fullname(str,stab)
-STR *str;
-STAB *stab;
-{
- HASH *tb = stab_stash(stab);
-
- if (!tb)
- return;
- str_set(str,tb->tbl_name);
- str_ncat(str,"'", 1);
- str_scat(str,stab->str_magic);
-}
-
-void
-stab_efullname(str,stab)
-STR *str;
-STAB *stab;
-{
- HASH *tb = stab_estash(stab);
-
- if (!tb)
- return;
- str_set(str,tb->tbl_name);
- str_ncat(str,"'", 1);
- str_scat(str,stab_estab(stab)->str_magic);
-}
-
-STIO *
-stio_new()
-{
- STIO *stio;
-
- Newz(603,stio,1,STIO);
- stio->page_len = 60;
- return stio;
-}
-
-void
-stab_check(min,max)
-int min;
-register int max;
-{
- register HENT *entry;
- register int i;
- register STAB *stab;
-
- for (i = min; i <= max; i++) {
- for (entry = defstash->tbl_array[i]; entry; entry = entry->hent_next) {
- stab = (STAB*)entry->hent_val;
- if (stab->str_pok & SP_MULTI)
- continue;
- curcmd->c_line = stab_line(stab);
- warn("Possible typo: \"%s\"", stab_name(stab));
- }
- }
-}
-
-static int gensym = 0;
-
-STAB *
-genstab()
-{
- (void)sprintf(tokenbuf,"_GEN_%d",gensym++);
- return stabent(tokenbuf,TRUE);
-}
-
-/* hopefully this is only called on local symbol table entries */
-
-void
-stab_clear(stab)
-register STAB *stab;
-{
- STIO *stio;
- SUBR *sub;
-
- if (!stab || !stab->str_ptr)
- return;
- afree(stab_xarray(stab));
- stab_xarray(stab) = Null(ARRAY*);
- (void)hfree(stab_xhash(stab), FALSE);
- stab_xhash(stab) = Null(HASH*);
- str_free(stab_val(stab));
- stab_val(stab) = Nullstr;
- /*SUPPRESS 560*/
- if (stio = stab_io(stab)) {
- do_close(stab,FALSE);
- Safefree(stio->top_name);
- Safefree(stio->fmt_name);
- Safefree(stio);
- }
- /*SUPPRESS 560*/
- if (sub = stab_sub(stab)) {
- afree(sub->tosave);
- cmd_free(sub->cmd);
- }
- Safefree(stab->str_ptr);
- stab->str_ptr = Null(STBP*);
- stab->str_len = 0;
- stab->str_cur = 0;
-}
-
-#if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286))
-#define MICROPORT
-#endif
-
-#ifdef MICROPORT /* Microport 2.4 hack */
-ARRAY *stab_array(stab)
-register STAB *stab;
-{
- if (((STBP*)(stab->str_ptr))->stbp_array)
- return ((STBP*)(stab->str_ptr))->stbp_array;
- else
- return ((STBP*)(aadd(stab)->str_ptr))->stbp_array;
-}
-
-HASH *stab_hash(stab)
-register STAB *stab;
-{
- if (((STBP*)(stab->str_ptr))->stbp_hash)
- return ((STBP*)(stab->str_ptr))->stbp_hash;
- else
- return ((STBP*)(hadd(stab)->str_ptr))->stbp_hash;
-}
-#endif /* Microport 2.4 hack */
diff --git a/gnu/usr.bin/perl/perl/stab.h b/gnu/usr.bin/perl/perl/stab.h
deleted file mode 100644
index 9da5a4a..0000000
--- a/gnu/usr.bin/perl/perl/stab.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/* $RCSfile: stab.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:35 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: stab.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:35 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:39 nate
- * PERL!
- *
- * Revision 4.0.1.3 92/06/08 15:33:44 lwall
- * patch20: fixed confusion between a *var's real name and its effective name
- * patch20: ($<,$>) = ... didn't work on some architectures
- *
- * Revision 4.0.1.2 91/11/05 18:36:15 lwall
- * patch11: length($x) was sometimes wrong for numeric $x
- *
- * Revision 4.0.1.1 91/06/07 11:56:35 lwall
- * patch4: new copyright notice
- * patch4: length($`), length($&), length($') now optimized to avoid string copy
- *
- * Revision 4.0 91/03/20 01:39:49 lwall
- * 4.0 baseline.
- *
- */
-
-struct stabptrs {
- char stbp_magic[4];
- STR *stbp_val; /* scalar value */
- struct stio *stbp_io; /* filehandle value */
- FCMD *stbp_form; /* format value */
- ARRAY *stbp_array; /* array value */
- HASH *stbp_hash; /* associative array value */
- STAB *stbp_stab; /* effective stab, if *glob */
- SUBR *stbp_sub; /* subroutine value */
- int stbp_lastexpr; /* used by nothing_in_common() */
- line_t stbp_line; /* line first declared at (for -w) */
- char stbp_flags;
-};
-
-#if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286))
-#define MICROPORT
-#endif
-
-#define stab_magic(stab) (((STBP*)(stab->str_ptr))->stbp_magic)
-#define stab_val(stab) (((STBP*)(stab->str_ptr))->stbp_val)
-#define stab_io(stab) (((STBP*)(stab->str_ptr))->stbp_io)
-#define stab_form(stab) (((STBP*)(stab->str_ptr))->stbp_form)
-#define stab_xarray(stab) (((STBP*)(stab->str_ptr))->stbp_array)
-#ifdef MICROPORT /* Microport 2.4 hack */
-ARRAY *stab_array();
-#else
-#define stab_array(stab) (((STBP*)(stab->str_ptr))->stbp_array ? \
- ((STBP*)(stab->str_ptr))->stbp_array : \
- ((STBP*)(aadd(stab)->str_ptr))->stbp_array)
-#endif
-#define stab_xhash(stab) (((STBP*)(stab->str_ptr))->stbp_hash)
-#ifdef MICROPORT /* Microport 2.4 hack */
-HASH *stab_hash();
-#else
-#define stab_hash(stab) (((STBP*)(stab->str_ptr))->stbp_hash ? \
- ((STBP*)(stab->str_ptr))->stbp_hash : \
- ((STBP*)(hadd(stab)->str_ptr))->stbp_hash)
-#endif /* Microport 2.4 hack */
-#define stab_sub(stab) (((STBP*)(stab->str_ptr))->stbp_sub)
-#define stab_lastexpr(stab) (((STBP*)(stab->str_ptr))->stbp_lastexpr)
-#define stab_line(stab) (((STBP*)(stab->str_ptr))->stbp_line)
-#define stab_flags(stab) (((STBP*)(stab->str_ptr))->stbp_flags)
-
-#define stab_stab(stab) (stab->str_magic->str_u.str_stab)
-#define stab_estab(stab) (((STBP*)(stab->str_ptr))->stbp_stab)
-
-#define stab_name(stab) (stab->str_magic->str_ptr)
-#define stab_ename(stab) stab_name(stab_estab(stab))
-
-#define stab_stash(stab) (stab->str_magic->str_u.str_stash)
-#define stab_estash(stab) stab_stash(stab_estab(stab))
-
-#define SF_VMAGIC 1 /* call routine to dereference STR val */
-#define SF_MULTI 2 /* seen more than once */
-
-struct stio {
- FILE *ifp; /* ifp and ofp are normally the same */
- FILE *ofp; /* but sockets need separate streams */
-#ifdef HAS_READDIR
- DIR *dirp; /* for opendir, readdir, etc */
-#endif
- long lines; /* $. */
- long page; /* $% */
- long page_len; /* $= */
- long lines_left; /* $- */
- char *top_name; /* $^ */
- STAB *top_stab; /* $^ */
- char *fmt_name; /* $~ */
- STAB *fmt_stab; /* $~ */
- short subprocess; /* -| or |- */
- char type;
- char flags;
-};
-
-#define IOF_ARGV 1 /* this fp iterates over ARGV */
-#define IOF_START 2 /* check for null ARGV and substitute '-' */
-#define IOF_FLUSH 4 /* this fp wants a flush after write op */
-
-struct sub {
- CMD *cmd;
- int (*usersub)();
- int userindex;
- STAB *filestab;
- long depth; /* >= 2 indicates recursive call */
- ARRAY *tosave;
-};
-
-#define Nullstab Null(STAB*)
-
-STRLEN stab_len();
-
-#define STAB_STR(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_str(stab_val(tmpstab)->str_magic) : stab_val(tmpstab))
-#define STAB_LEN(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_len(stab_val(tmpstab)->str_magic) : str_len(stab_val(tmpstab)))
-#define STAB_GET(s) (tmpstab = (s), str_get(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab)))
-#define STAB_GNUM(s) (tmpstab = (s), str_gnum(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab)))
-
-EXT STAB *tmpstab;
-
-EXT STAB *stab_index[128];
-
-EXT unsigned short statusvalue;
-
-EXT int delaymagic INIT(0);
-#define DM_UID 0x003
-#define DM_RUID 0x001
-#define DM_EUID 0x002
-#define DM_GID 0x030
-#define DM_RGID 0x010
-#define DM_EGID 0x020
-#define DM_DELAY 0x100
-
-STAB *aadd();
-STAB *hadd();
-STAB *fstab();
-void stabset();
-void stab_fullname();
-void stab_efullname();
-void stab_check();
diff --git a/gnu/usr.bin/perl/perl/str.c b/gnu/usr.bin/perl/perl/str.c
deleted file mode 100644
index 4d3bb5a..0000000
--- a/gnu/usr.bin/perl/perl/str.c
+++ /dev/null
@@ -1,1605 +0,0 @@
-/* $RCSfile: str.c,v $$Revision: 1.2 $$Date: 1995/05/30 05:03:21 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: str.c,v $
- * Revision 1.2 1995/05/30 05:03:21 rgrimes
- * Remove trailing whitespace.
- *
- * Revision 1.1.1.1 1994/09/10 06:27:33 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:39 nate
- * PERL!
- *
- * Revision 4.0.1.7 1993/02/05 19:43:47 lwall
- * patch36: the non-std stdio input code wasn't null-proof
- *
- * Revision 4.0.1.6 92/06/11 21:14:21 lwall
- * patch34: quotes containing subscripts containing variables didn't parse right
- *
- * Revision 4.0.1.5 92/06/08 15:40:43 lwall
- * patch20: removed implicit int declarations on functions
- * patch20: Perl now distinguishes overlapped copies from non-overlapped
- * patch20: paragraph mode now skips extra newlines automatically
- * patch20: fixed memory leak in doube-quote interpretation
- * patch20: made /\$$foo/ look for literal '$foo'
- * patch20: "$var{$foo'bar}" didn't scan subscript correctly
- * patch20: a splice on non-existent array elements could dump core
- * patch20: running taintperl explicitly now does checks even if $< == $>
- *
- * Revision 4.0.1.4 91/11/05 18:40:51 lwall
- * patch11: $foo .= <BAR> could overrun malloced memory
- * patch11: \$ didn't always make it through double-quoter to regexp routines
- * patch11: prepared for ctype implementations that don't define isascii()
- *
- * Revision 4.0.1.3 91/06/10 01:27:54 lwall
- * patch10: $) and $| incorrectly handled in run-time patterns
- *
- * Revision 4.0.1.2 91/06/07 11:58:13 lwall
- * patch4: new copyright notice
- * patch4: taint check on undefined string could cause core dump
- *
- * Revision 4.0.1.1 91/04/12 09:15:30 lwall
- * patch1: fixed undefined environ problem
- * patch1: substr($ENV{"PATH"},0,0) = "/foo:" didn't modify environment
- * patch1: $foo .= <BAR> could cause core dump for certain lengths of $foo
- *
- * Revision 4.0 91/03/20 01:39:55 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-#include "perly.h"
-
-static void ucase();
-static void lcase();
-
-#ifndef str_get
-char *
-str_get(str)
-STR *str;
-{
-#ifdef TAINT
- tainted |= str->str_tainted;
-#endif
- return str->str_pok ? str->str_ptr : str_2ptr(str);
-}
-#endif
-
-/* dlb ... guess we have a "crippled cc".
- * dlb the following functions are usually macros.
- */
-#ifndef str_true
-int
-str_true(Str)
-STR *Str;
-{
- if (Str->str_pok) {
- if (*Str->str_ptr > '0' ||
- Str->str_cur > 1 ||
- (Str->str_cur && *Str->str_ptr != '0'))
- return 1;
- return 0;
- }
- if (Str->str_nok)
- return (Str->str_u.str_nval != 0.0);
- return 0;
-}
-#endif /* str_true */
-
-#ifndef str_gnum
-double str_gnum(Str)
-STR *Str;
-{
-#ifdef TAINT
- tainted |= Str->str_tainted;
-#endif /* TAINT*/
- if (Str->str_nok)
- return Str->str_u.str_nval;
- return str_2num(Str);
-}
-#endif /* str_gnum */
-/* dlb ... end of crutch */
-
-char *
-str_grow(str,newlen)
-register STR *str;
-#ifndef DOSISH
-register int newlen;
-#else
-unsigned long newlen;
-#endif
-{
- register char *s = str->str_ptr;
-
-#ifdef MSDOS
- if (newlen >= 0x10000) {
- fprintf(stderr, "Allocation too large: %lx\n", newlen);
- exit(1);
- }
-#endif /* MSDOS */
- if (str->str_state == SS_INCR) { /* data before str_ptr? */
- str->str_len += str->str_u.str_useful;
- str->str_ptr -= str->str_u.str_useful;
- str->str_u.str_useful = 0L;
- Move(s, str->str_ptr, str->str_cur+1, char);
- s = str->str_ptr;
- str->str_state = SS_NORM; /* normal again */
- if (newlen > str->str_len)
- newlen += 10 * (newlen - str->str_cur); /* avoid copy each time */
- }
- if (newlen > str->str_len) { /* need more room? */
- if (str->str_len)
- Renew(s,newlen,char);
- else
- New(703,s,newlen,char);
- str->str_ptr = s;
- str->str_len = newlen;
- }
- return s;
-}
-
-void
-str_numset(str,num)
-register STR *str;
-double num;
-{
- if (str->str_pok) {
- str->str_pok = 0; /* invalidate pointer */
- if (str->str_state == SS_INCR)
- Str_Grow(str,0);
- }
- str->str_u.str_nval = num;
- str->str_state = SS_NORM;
- str->str_nok = 1; /* validate number */
-#ifdef TAINT
- str->str_tainted = tainted;
-#endif
-}
-
-char *
-str_2ptr(str)
-register STR *str;
-{
- register char *s;
- int olderrno;
-
- if (!str)
- return "";
- if (str->str_nok) {
- STR_GROW(str, 30);
- s = str->str_ptr;
- olderrno = errno; /* some Xenix systems wipe out errno here */
-#if defined(scs) && defined(ns32000)
- gcvt(str->str_u.str_nval,20,s);
-#else
-#ifdef apollo
- if (str->str_u.str_nval == 0.0)
- (void)strcpy(s,"0");
- else
-#endif /*apollo*/
- (void)sprintf(s,"%.20g",str->str_u.str_nval);
-#endif /*scs*/
- errno = olderrno;
- while (*s) s++;
-#ifdef hcx
- if (s[-1] == '.')
- s--;
-#endif
- }
- else {
- if (str == &str_undef)
- return No;
- if (dowarn)
- warn("Use of uninitialized variable");
- STR_GROW(str, 30);
- s = str->str_ptr;
- }
- *s = '\0';
- str->str_cur = s - str->str_ptr;
- str->str_pok = 1;
-#ifdef DEBUGGING
- if (debug & 32)
- fprintf(stderr,"0x%lx ptr(%s)\n",str,str->str_ptr);
-#endif
- return str->str_ptr;
-}
-
-double
-str_2num(str)
-register STR *str;
-{
- if (!str)
- return 0.0;
- if (str->str_state == SS_INCR)
- Str_Grow(str,0); /* just force copy down */
- str->str_state = SS_NORM;
- if (str->str_len && str->str_pok)
- str->str_u.str_nval = atof(str->str_ptr);
- else {
- if (str == &str_undef)
- return 0.0;
- if (dowarn)
- warn("Use of uninitialized variable");
- str->str_u.str_nval = 0.0;
- }
- str->str_nok = 1;
-#ifdef DEBUGGING
- if (debug & 32)
- fprintf(stderr,"0x%lx num(%g)\n",str,str->str_u.str_nval);
-#endif
- return str->str_u.str_nval;
-}
-
-/* Note: str_sset() should not be called with a source string that needs
- * be reused, since it may destroy the source string if it is marked
- * as temporary.
- */
-
-void
-str_sset(dstr,sstr)
-STR *dstr;
-register STR *sstr;
-{
-#ifdef TAINT
- if (sstr)
- tainted |= sstr->str_tainted;
-#endif
- if (sstr == dstr || dstr == &str_undef)
- return;
- if (!sstr)
- dstr->str_pok = dstr->str_nok = 0;
- else if (sstr->str_pok) {
-
- /*
- * Check to see if we can just swipe the string. If so, it's a
- * possible small lose on short strings, but a big win on long ones.
- * It might even be a win on short strings if dstr->str_ptr
- * has to be allocated and sstr->str_ptr has to be freed.
- */
-
- if (sstr->str_pok & SP_TEMP) { /* slated for free anyway? */
- if (dstr->str_ptr) {
- if (dstr->str_state == SS_INCR)
- dstr->str_ptr -= dstr->str_u.str_useful;
- Safefree(dstr->str_ptr);
- }
- dstr->str_ptr = sstr->str_ptr;
- dstr->str_len = sstr->str_len;
- dstr->str_cur = sstr->str_cur;
- dstr->str_state = sstr->str_state;
- dstr->str_pok = sstr->str_pok & ~SP_TEMP;
-#ifdef TAINT
- dstr->str_tainted = sstr->str_tainted;
-#endif
- sstr->str_ptr = Nullch;
- sstr->str_len = 0;
- sstr->str_pok = 0; /* wipe out any weird flags */
- sstr->str_state = 0; /* so sstr frees uneventfully */
- }
- else { /* have to copy actual string */
- if (dstr->str_ptr) {
- if (dstr->str_state == SS_INCR) {
- Str_Grow(dstr,0);
- }
- }
- str_nset(dstr,sstr->str_ptr,sstr->str_cur);
- }
- /*SUPPRESS 560*/
- if (dstr->str_nok = sstr->str_nok)
- dstr->str_u.str_nval = sstr->str_u.str_nval;
- else {
-#ifdef STRUCTCOPY
- dstr->str_u = sstr->str_u;
-#else
- dstr->str_u.str_nval = sstr->str_u.str_nval;
-#endif
- if (dstr->str_cur == sizeof(STBP)) {
- char *tmps = dstr->str_ptr;
-
- if (*tmps == 'S' && bcmp(tmps,"StB",4) == 0) {
- if (dstr->str_magic && dstr->str_magic->str_rare == 'X') {
- str_free(dstr->str_magic);
- dstr->str_magic = Nullstr;
- }
- if (!dstr->str_magic) {
- dstr->str_magic = str_smake(sstr->str_magic);
- dstr->str_magic->str_rare = 'X';
- }
- }
- }
- }
- }
- else if (sstr->str_nok)
- str_numset(dstr,sstr->str_u.str_nval);
- else {
- if (dstr->str_state == SS_INCR)
- Str_Grow(dstr,0); /* just force copy down */
-
-#ifdef STRUCTCOPY
- dstr->str_u = sstr->str_u;
-#else
- dstr->str_u.str_nval = sstr->str_u.str_nval;
-#endif
- dstr->str_pok = dstr->str_nok = 0;
- }
-}
-
-void
-str_nset(str,ptr,len)
-register STR *str;
-register char *ptr;
-register STRLEN len;
-{
- if (str == &str_undef)
- return;
- STR_GROW(str, len + 1);
- if (ptr)
- Move(ptr,str->str_ptr,len,char);
- str->str_cur = len;
- *(str->str_ptr+str->str_cur) = '\0';
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
-#ifdef TAINT
- str->str_tainted = tainted;
-#endif
-}
-
-void
-str_set(str,ptr)
-register STR *str;
-register char *ptr;
-{
- register STRLEN len;
-
- if (str == &str_undef)
- return;
- if (!ptr)
- ptr = "";
- len = strlen(ptr);
- STR_GROW(str, len + 1);
- Move(ptr,str->str_ptr,len+1,char);
- str->str_cur = len;
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
-#ifdef TAINT
- str->str_tainted = tainted;
-#endif
-}
-
-void
-str_chop(str,ptr) /* like set but assuming ptr is in str */
-register STR *str;
-register char *ptr;
-{
- register STRLEN delta;
-
- if (!ptr || !(str->str_pok))
- return;
- delta = ptr - str->str_ptr;
- str->str_len -= delta;
- str->str_cur -= delta;
- str->str_ptr += delta;
- if (str->str_state == SS_INCR)
- str->str_u.str_useful += delta;
- else {
- str->str_u.str_useful = delta;
- str->str_state = SS_INCR;
- }
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer (and unstudy str) */
-}
-
-void
-str_ncat(str,ptr,len)
-register STR *str;
-register char *ptr;
-register STRLEN len;
-{
- if (str == &str_undef)
- return;
- if (!(str->str_pok))
- (void)str_2ptr(str);
- STR_GROW(str, str->str_cur + len + 1);
- Move(ptr,str->str_ptr+str->str_cur,len,char);
- str->str_cur += len;
- *(str->str_ptr+str->str_cur) = '\0';
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
-#ifdef TAINT
- str->str_tainted |= tainted;
-#endif
-}
-
-void
-str_scat(dstr,sstr)
-STR *dstr;
-register STR *sstr;
-{
- if (!sstr)
- return;
-#ifdef TAINT
- tainted |= sstr->str_tainted;
-#endif
- if (!(sstr->str_pok))
- (void)str_2ptr(sstr);
- if (sstr)
- str_ncat(dstr,sstr->str_ptr,sstr->str_cur);
-}
-
-void
-str_cat(str,ptr)
-register STR *str;
-register char *ptr;
-{
- register STRLEN len;
-
- if (str == &str_undef)
- return;
- if (!ptr)
- return;
- if (!(str->str_pok))
- (void)str_2ptr(str);
- len = strlen(ptr);
- STR_GROW(str, str->str_cur + len + 1);
- Move(ptr,str->str_ptr+str->str_cur,len+1,char);
- str->str_cur += len;
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
-#ifdef TAINT
- str->str_tainted |= tainted;
-#endif
-}
-
-char *
-str_append_till(str,from,fromend,delim,keeplist)
-register STR *str;
-register char *from;
-register char *fromend;
-register int delim;
-char *keeplist;
-{
- register char *to;
- register STRLEN len;
-
- if (str == &str_undef)
- return Nullch;
- if (!from)
- return Nullch;
- len = fromend - from;
- STR_GROW(str, str->str_cur + len + 1);
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
- to = str->str_ptr+str->str_cur;
- for (; from < fromend; from++,to++) {
- if (*from == '\\' && from+1 < fromend && delim != '\\') {
- if (!keeplist) {
- if (from[1] == delim || from[1] == '\\')
- from++;
- else
- *to++ = *from++;
- }
- else if (from[1] && index(keeplist,from[1]))
- *to++ = *from++;
- else
- from++;
- }
- else if (*from == delim)
- break;
- *to = *from;
- }
- *to = '\0';
- str->str_cur = to - str->str_ptr;
- return from;
-}
-
-STR *
-#ifdef LEAKTEST
-str_new(x,len)
-int x;
-#else
-str_new(len)
-#endif
-STRLEN len;
-{
- register STR *str;
-
- if (freestrroot) {
- str = freestrroot;
- freestrroot = str->str_magic;
- str->str_magic = Nullstr;
- str->str_state = SS_NORM;
- }
- else {
- Newz(700+x,str,1,STR);
- }
- if (len)
- STR_GROW(str, len + 1);
- return str;
-}
-
-void
-str_magic(str, stab, how, name, namlen)
-register STR *str;
-STAB *stab;
-int how;
-char *name;
-STRLEN namlen;
-{
- if (str == &str_undef || str->str_magic)
- return;
- str->str_magic = Str_new(75,namlen);
- str = str->str_magic;
- str->str_u.str_stab = stab;
- str->str_rare = how;
- if (name)
- str_nset(str,name,namlen);
-}
-
-void
-str_insert(bigstr,offset,len,little,littlelen)
-STR *bigstr;
-STRLEN offset;
-STRLEN len;
-char *little;
-STRLEN littlelen;
-{
- register char *big;
- register char *mid;
- register char *midend;
- register char *bigend;
- register int i;
-
- if (bigstr == &str_undef)
- return;
- bigstr->str_nok = 0;
- bigstr->str_pok = SP_VALID; /* disable possible screamer */
-
- i = littlelen - len;
- if (i > 0) { /* string might grow */
- STR_GROW(bigstr, bigstr->str_cur + i + 1);
- big = bigstr->str_ptr;
- mid = big + offset + len;
- midend = bigend = big + bigstr->str_cur;
- bigend += i;
- *bigend = '\0';
- while (midend > mid) /* shove everything down */
- *--bigend = *--midend;
- Move(little,big+offset,littlelen,char);
- bigstr->str_cur += i;
- STABSET(bigstr);
- return;
- }
- else if (i == 0) {
- Move(little,bigstr->str_ptr+offset,len,char);
- STABSET(bigstr);
- return;
- }
-
- big = bigstr->str_ptr;
- mid = big + offset;
- midend = mid + len;
- bigend = big + bigstr->str_cur;
-
- if (midend > bigend)
- fatal("panic: str_insert");
-
- if (mid - big > bigend - midend) { /* faster to shorten from end */
- if (littlelen) {
- Move(little, mid, littlelen,char);
- mid += littlelen;
- }
- i = bigend - midend;
- if (i > 0) {
- Move(midend, mid, i,char);
- mid += i;
- }
- *mid = '\0';
- bigstr->str_cur = mid - big;
- }
- /*SUPPRESS 560*/
- else if (i = mid - big) { /* faster from front */
- midend -= littlelen;
- mid = midend;
- str_chop(bigstr,midend-i);
- big += i;
- while (i--)
- *--midend = *--big;
- if (littlelen)
- Move(little, mid, littlelen,char);
- }
- else if (littlelen) {
- midend -= littlelen;
- str_chop(bigstr,midend);
- Move(little,midend,littlelen,char);
- }
- else {
- str_chop(bigstr,midend);
- }
- STABSET(bigstr);
-}
-
-/* make str point to what nstr did */
-
-void
-str_replace(str,nstr)
-register STR *str;
-register STR *nstr;
-{
- if (str == &str_undef)
- return;
- if (str->str_state == SS_INCR)
- Str_Grow(str,0); /* just force copy down */
- if (nstr->str_state == SS_INCR)
- Str_Grow(nstr,0);
- if (str->str_ptr)
- Safefree(str->str_ptr);
- str->str_ptr = nstr->str_ptr;
- str->str_len = nstr->str_len;
- str->str_cur = nstr->str_cur;
- str->str_pok = nstr->str_pok;
- str->str_nok = nstr->str_nok;
-#ifdef STRUCTCOPY
- str->str_u = nstr->str_u;
-#else
- str->str_u.str_nval = nstr->str_u.str_nval;
-#endif
-#ifdef TAINT
- str->str_tainted = nstr->str_tainted;
-#endif
- if (nstr->str_magic)
- str_free(nstr->str_magic);
- Safefree(nstr);
-}
-
-void
-str_free(str)
-register STR *str;
-{
- if (!str || str == &str_undef)
- return;
- if (str->str_state) {
- if (str->str_state == SS_FREE) /* already freed */
- return;
- if (str->str_state == SS_INCR && !(str->str_pok & 2)) {
- str->str_ptr -= str->str_u.str_useful;
- str->str_len += str->str_u.str_useful;
- }
- }
- if (str->str_magic)
- str_free(str->str_magic);
- str->str_magic = freestrroot;
-#ifdef LEAKTEST
- if (str->str_len) {
- Safefree(str->str_ptr);
- str->str_ptr = Nullch;
- }
- if ((str->str_pok & SP_INTRP) && str->str_u.str_args)
- arg_free(str->str_u.str_args);
- Safefree(str);
-#else /* LEAKTEST */
- if (str->str_len) {
- if (str->str_len > 127) { /* next user not likely to want more */
- Safefree(str->str_ptr); /* so give it back to malloc */
- str->str_ptr = Nullch;
- str->str_len = 0;
- }
- else
- str->str_ptr[0] = '\0';
- }
- if ((str->str_pok & SP_INTRP) && str->str_u.str_args)
- arg_free(str->str_u.str_args);
- str->str_cur = 0;
- str->str_nok = 0;
- str->str_pok = 0;
- str->str_state = SS_FREE;
-#ifdef TAINT
- str->str_tainted = 0;
-#endif
- freestrroot = str;
-#endif /* LEAKTEST */
-}
-
-STRLEN
-str_len(str)
-register STR *str;
-{
- if (!str)
- return 0;
- if (!(str->str_pok))
- (void)str_2ptr(str);
- if (str->str_ptr)
- return str->str_cur;
- else
- return 0;
-}
-
-int
-str_eq(str1,str2)
-register STR *str1;
-register STR *str2;
-{
- if (!str1 || str1 == &str_undef)
- return (str2 == Nullstr || str2 == &str_undef || !str2->str_cur);
- if (!str2 || str2 == &str_undef)
- return !str1->str_cur;
-
- if (!str1->str_pok)
- (void)str_2ptr(str1);
- if (!str2->str_pok)
- (void)str_2ptr(str2);
-
- if (str1->str_cur != str2->str_cur)
- return 0;
-
- return !bcmp(str1->str_ptr, str2->str_ptr, str1->str_cur);
-}
-
-int
-str_cmp(str1,str2)
-register STR *str1;
-register STR *str2;
-{
- int retval;
-
- if (!str1 || str1 == &str_undef)
- return (str2 == Nullstr || str2 == &str_undef || !str2->str_cur)?0:-1;
- if (!str2 || str2 == &str_undef)
- return str1->str_cur != 0;
-
- if (!str1->str_pok)
- (void)str_2ptr(str1);
- if (!str2->str_pok)
- (void)str_2ptr(str2);
-
- if (str1->str_cur < str2->str_cur) {
- /*SUPPRESS 560*/
- if (retval = memcmp(str1->str_ptr, str2->str_ptr, str1->str_cur))
- return retval < 0 ? -1 : 1;
- else
- return -1;
- }
- /*SUPPRESS 560*/
- else if (retval = memcmp(str1->str_ptr, str2->str_ptr, str2->str_cur))
- return retval < 0 ? -1 : 1;
- else if (str1->str_cur == str2->str_cur)
- return 0;
- else
- return 1;
-}
-
-char *
-str_gets(str,fp,append)
-register STR *str;
-register FILE *fp;
-int append;
-{
- register char *bp; /* we're going to steal some values */
- register int cnt; /* from the stdio struct and put EVERYTHING */
- register STDCHAR *ptr; /* in the innermost loop into registers */
- register int newline = rschar;/* (assuming >= 6 registers) */
- int i;
- STRLEN bpx;
- int shortbuffered;
-
- if (str == &str_undef)
- return Nullch;
- if (rspara) { /* have to do this both before and after */
- do { /* to make sure file boundaries work right */
- i = getc(fp);
- if (i != '\n') {
- ungetc(i,fp);
- break;
- }
- } while (i != EOF);
- }
-#ifdef STDSTDIO /* Here is some breathtakingly efficient cheating */
- cnt = fp->_cnt; /* get count into register */
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
- if (str->str_len - append <= cnt + 1) { /* make sure we have the room */
- if (cnt > 80 && str->str_len > append) {
- shortbuffered = cnt - str->str_len + append + 1;
- cnt -= shortbuffered;
- }
- else {
- shortbuffered = 0;
- STR_GROW(str, append+cnt+2);/* (remembering cnt can be -1) */
- }
- }
- else
- shortbuffered = 0;
- bp = str->str_ptr + append; /* move these two too to registers */
- ptr = fp->_ptr;
- for (;;) {
- screamer:
- while (--cnt >= 0) { /* this */ /* eat */
- if ((*bp++ = *ptr++) == newline) /* really */ /* dust */
- goto thats_all_folks; /* screams */ /* sed :-) */
- }
-
- if (shortbuffered) { /* oh well, must extend */
- cnt = shortbuffered;
- shortbuffered = 0;
- bpx = bp - str->str_ptr; /* prepare for possible relocation */
- str->str_cur = bpx;
- STR_GROW(str, str->str_len + append + cnt + 2);
- bp = str->str_ptr + bpx; /* reconstitute our pointer */
- continue;
- }
-
- fp->_cnt = cnt; /* deregisterize cnt and ptr */
- fp->_ptr = ptr;
- i = _filbuf(fp); /* get more characters */
- cnt = fp->_cnt;
- ptr = fp->_ptr; /* reregisterize cnt and ptr */
-
- bpx = bp - str->str_ptr; /* prepare for possible relocation */
- str->str_cur = bpx;
- STR_GROW(str, bpx + cnt + 2);
- bp = str->str_ptr + bpx; /* reconstitute our pointer */
-
- if (i == newline) { /* all done for now? */
- *bp++ = i;
- goto thats_all_folks;
- }
- else if (i == EOF) /* all done for ever? */
- goto thats_really_all_folks;
- *bp++ = i; /* now go back to screaming loop */
- }
-
-thats_all_folks:
- if (rslen > 1 && (bp - str->str_ptr < rslen || bcmp(bp - rslen, rs, rslen)))
- goto screamer; /* go back to the fray */
-thats_really_all_folks:
- if (shortbuffered)
- cnt += shortbuffered;
- fp->_cnt = cnt; /* put these back or we're in trouble */
- fp->_ptr = ptr;
- *bp = '\0';
- str->str_cur = bp - str->str_ptr; /* set length */
-
-#else /* !STDSTDIO */ /* The big, slow, and stupid way */
-
- {
- static char buf[8192];
- char * bpe = buf + sizeof(buf) - 3;
-
-screamer:
- bp = buf;
- while ((i = getc(fp)) != EOF && (*bp++ = i) != newline && bp < bpe) ;
-
- if (append)
- str_ncat(str, buf, bp - buf);
- else
- str_nset(str, buf, bp - buf);
- if (i != EOF /* joy */
- &&
- (i != newline
- ||
- (rslen > 1
- &&
- (str->str_cur < rslen
- ||
- bcmp(str->str_ptr + str->str_cur - rslen, rs, rslen)
- )
- )
- )
- )
- {
- append = -1;
- goto screamer;
- }
- }
-
-#endif /* STDSTDIO */
-
- if (rspara) {
- while (i != EOF) {
- i = getc(fp);
- if (i != '\n') {
- ungetc(i,fp);
- break;
- }
- }
- }
- return str->str_cur - append ? str->str_ptr : Nullch;
-}
-
-ARG *
-parselist(str)
-STR *str;
-{
- register CMD *cmd;
- register ARG *arg;
- CMD *oldcurcmd = curcmd;
- int oldperldb = perldb;
- int retval;
-
- perldb = 0;
- str_sset(linestr,str);
- in_eval++;
- oldoldbufptr = oldbufptr = bufptr = str_get(linestr);
- bufend = bufptr + linestr->str_cur;
- if (++loop_ptr >= loop_max) {
- loop_max += 128;
- Renew(loop_stack, loop_max, struct loop);
- }
- loop_stack[loop_ptr].loop_label = "_EVAL_";
- loop_stack[loop_ptr].loop_sp = 0;
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Pushing label #%d _EVAL_)\n", loop_ptr);
- }
-#endif
- if (setjmp(loop_stack[loop_ptr].loop_env)) {
- in_eval--;
- loop_ptr--;
- perldb = oldperldb;
- fatal("%s\n",stab_val(stabent("@",TRUE))->str_ptr);
- }
-#ifdef DEBUGGING
- if (debug & 4) {
- char *tmps = loop_stack[loop_ptr].loop_label;
- deb("(Popping label #%d %s)\n",loop_ptr,
- tmps ? tmps : "" );
- }
-#endif
- loop_ptr--;
- error_count = 0;
- curcmd = &compiling;
- curcmd->c_line = oldcurcmd->c_line;
- retval = yyparse();
- curcmd = oldcurcmd;
- perldb = oldperldb;
- in_eval--;
- if (retval || error_count)
- fatal("Invalid component in string or format");
- cmd = eval_root;
- arg = cmd->c_expr;
- if (cmd->c_type != C_EXPR || cmd->c_next || arg->arg_type != O_LIST)
- fatal("panic: error in parselist %d %x %d", cmd->c_type,
- cmd->c_next, arg ? arg->arg_type : -1);
- cmd->c_expr = Nullarg;
- cmd_free(cmd);
- eval_root = Nullcmd;
- return arg;
-}
-
-void
-intrpcompile(src)
-STR *src;
-{
- register char *s = str_get(src);
- register char *send = s + src->str_cur;
- register STR *str;
- register char *t;
- STR *toparse;
- STRLEN len;
- register int brackets;
- register char *d;
- STAB *stab;
- char *checkpoint;
- int sawcase = 0;
-
- toparse = Str_new(76,0);
- str = Str_new(77,0);
-
- str_nset(str,"",0);
- str_nset(toparse,"",0);
- t = s;
- while (s < send) {
- if (*s == '\\' && s[1] && index("$@[{\\]}lLuUE",s[1])) {
- str_ncat(str, t, s - t);
- ++s;
- if (isALPHA(*s)) {
- str_ncat(str, "$c", 2);
- sawcase = (*s != 'E');
- }
- else {
- if (*nointrp) { /* in a regular expression */
- if (*s == '@') /* always strip \@ */ /*SUPPRESS 530*/
- ;
- else /* don't strip \\, \[, \{ etc. */
- str_ncat(str,s-1,1);
- }
- str_ncat(str, "$b", 2);
- }
- str_ncat(str, s, 1);
- ++s;
- t = s;
- }
- else if (*s == '$' && s+1 < send && *nointrp && index(nointrp,s[1])) {
- str_ncat(str, t, s - t);
- str_ncat(str, "$b", 2);
- str_ncat(str, s, 2);
- s += 2;
- t = s;
- }
- else if ((*s == '@' || *s == '$') && s+1 < send) {
- str_ncat(str,t,s-t);
- t = s;
- if (*s == '$' && s[1] == '#' && (isALPHA(s[2]) || s[2] == '_'))
- s++;
- s = scanident(s,send,tokenbuf,sizeof tokenbuf);
- if (*t == '@' &&
- (!(stab = stabent(tokenbuf,FALSE)) ||
- (*s == '{' ? !stab_xhash(stab) : !stab_xarray(stab)) )) {
- str_ncat(str,"@",1);
- s = ++t;
- continue; /* grandfather @ from old scripts */
- }
- str_ncat(str,"$a",2);
- str_ncat(toparse,",",1);
- if (t[1] != '{' && (*s == '[' || *s == '{' /* }} */ ) &&
- (stab = stabent(tokenbuf,FALSE)) &&
- ((*s == '[') ? (stab_xarray(stab) != 0) : (stab_xhash(stab) != 0)) ) {
- brackets = 0;
- checkpoint = s;
- do {
- switch (*s) {
- case '[':
- brackets++;
- break;
- case '{':
- brackets++;
- break;
- case ']':
- brackets--;
- break;
- case '}':
- brackets--;
- break;
- case '$':
- case '%':
- case '@':
- case '&':
- case '*':
- s = scanident(s,send,tokenbuf,sizeof tokenbuf);
- continue;
- case '\'':
- case '"':
- /*SUPPRESS 68*/
- s = cpytill(tokenbuf,s+1,send,*s,&len);
- if (s >= send)
- fatal("Unterminated string");
- break;
- }
- s++;
- } while (brackets > 0 && s < send);
- if (s > send)
- fatal("Unmatched brackets in string");
- if (*nointrp) { /* we're in a regular expression */
- d = checkpoint;
- if (*d == '{' && s[-1] == '}') { /* maybe {n,m} */
- ++d;
- if (isDIGIT(*d)) { /* matches /^{\d,?\d*}$/ */
- if (*++d == ',')
- ++d;
- while (isDIGIT(*d))
- d++;
- if (d == s - 1)
- s = checkpoint; /* Is {n,m}! Backoff! */
- }
- }
- else if (*d == '[' && s[-1] == ']') { /* char class? */
- int weight = 2; /* let's weigh the evidence */
- char seen[256];
- unsigned char un_char = 0, last_un_char;
-
- Zero(seen,256,char);
- *--s = '\0';
- if (d[1] == '^')
- weight += 150;
- else if (d[1] == '$')
- weight -= 3;
- if (isDIGIT(d[1])) {
- if (d[2]) {
- if (isDIGIT(d[2]) && !d[3])
- weight -= 10;
- }
- else
- weight -= 100;
- }
- for (d++; d < s; d++) {
- last_un_char = un_char;
- un_char = (unsigned char)*d;
- switch (*d) {
- case '&':
- case '$':
- weight -= seen[un_char] * 10;
- if (isALNUM(d[1])) {
- d = scanident(d,s,tokenbuf,sizeof tokenbuf);
- if (stabent(tokenbuf,FALSE))
- weight -= 100;
- else
- weight -= 10;
- }
- else if (*d == '$' && d[1] &&
- index("[#!%*<>()-=",d[1])) {
- if (!d[2] || /*{*/ index("])} =",d[2]))
- weight -= 10;
- else
- weight -= 1;
- }
- break;
- case '\\':
- un_char = 254;
- if (d[1]) {
- if (index("wds",d[1]))
- weight += 100;
- else if (seen['\''] || seen['"'])
- weight += 1;
- else if (index("rnftb",d[1]))
- weight += 40;
- else if (isDIGIT(d[1])) {
- weight += 40;
- while (d[1] && isDIGIT(d[1]))
- d++;
- }
- }
- else
- weight += 100;
- break;
- case '-':
- if (last_un_char < (unsigned char) d[1]
- || d[1] == '\\') {
- if (index("aA01! ",last_un_char))
- weight += 30;
- if (index("zZ79~",d[1]))
- weight += 30;
- }
- else
- weight -= 1;
- default:
- if (isALPHA(*d) && d[1] && isALPHA(d[1])) {
- bufptr = d;
- if (yylex() != WORD)
- weight -= 150;
- d = bufptr;
- }
- if (un_char == last_un_char + 1)
- weight += 5;
- weight -= seen[un_char];
- break;
- }
- seen[un_char]++;
- }
-#ifdef DEBUGGING
- if (debug & 512)
- fprintf(stderr,"[%s] weight %d\n",
- checkpoint+1,weight);
-#endif
- *s++ = ']';
- if (weight >= 0) /* probably a character class */
- s = checkpoint;
- }
- }
- }
- if (*t == '@')
- str_ncat(toparse, "join($\",", 8);
- if (t[1] == '{' && s[-1] == '}') {
- str_ncat(toparse, t, 1);
- str_ncat(toparse, t+2, s - t - 3);
- }
- else
- str_ncat(toparse, t, s - t);
- if (*t == '@')
- str_ncat(toparse, ")", 1);
- t = s;
- }
- else
- s++;
- }
- str_ncat(str,t,s-t);
- if (sawcase)
- str_ncat(str, "$cE", 3);
- if (toparse->str_ptr && *toparse->str_ptr == ',') {
- *toparse->str_ptr = '(';
- str_ncat(toparse,",$$);",5);
- str->str_u.str_args = parselist(toparse);
- str->str_u.str_args->arg_len--; /* ignore $$ reference */
- }
- else
- str->str_u.str_args = Nullarg;
- str_free(toparse);
- str->str_pok |= SP_INTRP;
- str->str_nok = 0;
- str_replace(src,str);
-}
-
-STR *
-interp(str,src,sp)
-register STR *str;
-STR *src;
-int sp;
-{
- register char *s;
- register char *t;
- register char *send;
- register STR **elem;
- int docase = 0;
- int l = 0;
- int u = 0;
- int L = 0;
- int U = 0;
-
- if (str == &str_undef)
- return Nullstr;
- if (!(src->str_pok & SP_INTRP)) {
- int oldsave = savestack->ary_fill;
-
- (void)savehptr(&curstash);
- curstash = curcmd->c_stash; /* so stabent knows right package */
- intrpcompile(src);
- restorelist(oldsave);
- }
- s = src->str_ptr; /* assumed valid since str_pok set */
- t = s;
- send = s + src->str_cur;
-
- if (src->str_u.str_args) {
- (void)eval(src->str_u.str_args,G_ARRAY,sp);
- /* Assuming we have correct # of args */
- elem = stack->ary_array + sp;
- }
-
- str_nset(str,"",0);
- while (s < send) {
- if (*s == '$' && s+1 < send) {
- if (s-t > 0)
- str_ncat(str,t,s-t);
- switch(*++s) {
- default:
- fatal("panic: unknown interp cookie\n");
- break;
- case 'a':
- str_scat(str,*++elem);
- break;
- case 'b':
- str_ncat(str,++s,1);
- break;
- case 'c':
- if (docase && str->str_cur >= docase) {
- char *b = str->str_ptr + --docase;
-
- if (L)
- lcase(b, str->str_ptr + str->str_cur);
- else if (U)
- ucase(b, str->str_ptr + str->str_cur);
-
- if (u) /* note that l & u are independent of L & U */
- ucase(b, b+1);
- else if (l)
- lcase(b, b+1);
- l = u = 0;
- }
- docase = str->str_cur + 1;
- switch (*++s) {
- case 'u':
- u = 1;
- l = 0;
- break;
- case 'U':
- U = 1;
- L = 0;
- break;
- case 'l':
- l = 1;
- u = 0;
- break;
- case 'L':
- L = 1;
- U = 0;
- break;
- case 'E':
- docase = L = U = l = u = 0;
- break;
- }
- break;
- }
- t = ++s;
- }
- else
- s++;
- }
- if (s-t > 0)
- str_ncat(str,t,s-t);
- return str;
-}
-
-static void
-ucase(s,send)
-register char *s;
-register char *send;
-{
- while (s < send) {
- if (isLOWER(*s))
- *s = toupper(*s);
- s++;
- }
-}
-
-static void
-lcase(s,send)
-register char *s;
-register char *send;
-{
- while (s < send) {
- if (isUPPER(*s))
- *s = tolower(*s);
- s++;
- }
-}
-
-void
-str_inc(str)
-register STR *str;
-{
- register char *d;
-
- if (!str || str == &str_undef)
- return;
- if (str->str_nok) {
- str->str_u.str_nval += 1.0;
- str->str_pok = 0;
- return;
- }
- if (!str->str_pok || !*str->str_ptr) {
- str->str_u.str_nval = 1.0;
- str->str_nok = 1;
- str->str_pok = 0;
- return;
- }
- d = str->str_ptr;
- while (isALPHA(*d)) d++;
- while (isDIGIT(*d)) d++;
- if (*d) {
- str_numset(str,atof(str->str_ptr) + 1.0); /* punt */
- return;
- }
- d--;
- while (d >= str->str_ptr) {
- if (isDIGIT(*d)) {
- if (++*d <= '9')
- return;
- *(d--) = '0';
- }
- else {
- ++*d;
- if (isALPHA(*d))
- return;
- *(d--) -= 'z' - 'a' + 1;
- }
- }
- /* oh,oh, the number grew */
- STR_GROW(str, str->str_cur + 2);
- str->str_cur++;
- for (d = str->str_ptr + str->str_cur; d > str->str_ptr; d--)
- *d = d[-1];
- if (isDIGIT(d[1]))
- *d = '1';
- else
- *d = d[1];
-}
-
-void
-str_dec(str)
-register STR *str;
-{
- if (!str || str == &str_undef)
- return;
- if (str->str_nok) {
- str->str_u.str_nval -= 1.0;
- str->str_pok = 0;
- return;
- }
- if (!str->str_pok) {
- str->str_u.str_nval = -1.0;
- str->str_nok = 1;
- return;
- }
- str_numset(str,atof(str->str_ptr) - 1.0);
-}
-
-/* Make a string that will exist for the duration of the expression
- * evaluation. Actually, it may have to last longer than that, but
- * hopefully cmd_exec won't free it until it has been assigned to a
- * permanent location. */
-
-static long tmps_size = -1;
-
-STR *
-str_mortal(oldstr)
-STR *oldstr;
-{
- register STR *str = Str_new(78,0);
-
- str_sset(str,oldstr);
- if (++tmps_max > tmps_size) {
- tmps_size = tmps_max;
- if (!(tmps_size & 127)) {
- if (tmps_size)
- Renew(tmps_list, tmps_size + 128, STR*);
- else
- New(702,tmps_list, 128, STR*);
- }
- }
- tmps_list[tmps_max] = str;
- if (str->str_pok)
- str->str_pok |= SP_TEMP;
- return str;
-}
-
-/* same thing without the copying */
-
-STR *
-str_2mortal(str)
-register STR *str;
-{
- if (!str || str == &str_undef)
- return str;
- if (++tmps_max > tmps_size) {
- tmps_size = tmps_max;
- if (!(tmps_size & 127)) {
- if (tmps_size)
- Renew(tmps_list, tmps_size + 128, STR*);
- else
- New(704,tmps_list, 128, STR*);
- }
- }
- tmps_list[tmps_max] = str;
- if (str->str_pok)
- str->str_pok |= SP_TEMP;
- return str;
-}
-
-STR *
-str_make(s,len)
-char *s;
-STRLEN len;
-{
- register STR *str = Str_new(79,0);
-
- if (!len)
- len = strlen(s);
- str_nset(str,s,len);
- return str;
-}
-
-STR *
-str_nmake(n)
-double n;
-{
- register STR *str = Str_new(80,0);
-
- str_numset(str,n);
- return str;
-}
-
-/* make an exact duplicate of old */
-
-STR *
-str_smake(old)
-register STR *old;
-{
- register STR *new = Str_new(81,0);
-
- if (!old)
- return Nullstr;
- if (old->str_state == SS_FREE) {
- warn("semi-panic: attempt to dup freed string");
- return Nullstr;
- }
- if (old->str_state == SS_INCR && !(old->str_pok & 2))
- Str_Grow(old,0);
- if (new->str_ptr)
- Safefree(new->str_ptr);
- StructCopy(old,new,STR);
- if (old->str_ptr) {
- new->str_ptr = nsavestr(old->str_ptr,old->str_len);
- new->str_pok &= ~SP_TEMP;
- }
- return new;
-}
-
-void
-str_reset(s,stash)
-register char *s;
-HASH *stash;
-{
- register HENT *entry;
- register STAB *stab;
- register STR *str;
- register int i;
- register SPAT *spat;
- register int max;
-
- if (!*s) { /* reset ?? searches */
- for (spat = stash->tbl_spatroot;
- spat != Nullspat;
- spat = spat->spat_next) {
- spat->spat_flags &= ~SPAT_USED;
- }
- return;
- }
-
- /* reset variables */
-
- if (!stash->tbl_array)
- return;
- while (*s) {
- i = *s;
- if (s[1] == '-') {
- s += 2;
- }
- max = *s++;
- for ( ; i <= max; i++) {
- for (entry = stash->tbl_array[i];
- entry;
- entry = entry->hent_next) {
- stab = (STAB*)entry->hent_val;
- str = stab_val(stab);
- str->str_cur = 0;
- str->str_nok = 0;
-#ifdef TAINT
- str->str_tainted = tainted;
-#endif
- if (str->str_ptr != Nullch)
- str->str_ptr[0] = '\0';
- if (stab_xarray(stab)) {
- aclear(stab_xarray(stab));
- }
- if (stab_xhash(stab)) {
- hclear(stab_xhash(stab), FALSE);
- if (stab == envstab)
- environ[0] = Nullch;
- }
- }
- }
- }
-}
-
-#ifdef TAINT
-void
-taintproper(s)
-char *s;
-{
-#ifdef DEBUGGING
- if (debug & 2048)
- fprintf(stderr,"%s %d %d %d\n",s,tainted,uid, euid);
-#endif
- if (tainted && (!euid || euid != uid || egid != gid || taintanyway)) {
- if (!unsafe)
- fatal("%s", s);
- else if (dowarn)
- warn("%s", s);
- }
-}
-
-void
-taintenv()
-{
- register STR *envstr;
-
- envstr = hfetch(stab_hash(envstab),"PATH",4,FALSE);
- if (envstr == &str_undef || envstr->str_tainted) {
- tainted = 1;
- if (envstr->str_tainted == 2)
- taintproper("Insecure directory in PATH");
- else
- taintproper("Insecure PATH");
- }
- envstr = hfetch(stab_hash(envstab),"IFS",3,FALSE);
- if (envstr != &str_undef && envstr->str_tainted) {
- tainted = 1;
- taintproper("Insecure IFS");
- }
-}
-#endif /* TAINT */
diff --git a/gnu/usr.bin/perl/perl/str.h b/gnu/usr.bin/perl/perl/str.h
deleted file mode 100644
index 8e95749..0000000
--- a/gnu/usr.bin/perl/perl/str.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/* $RCSfile: str.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:35 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: str.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:35 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:39 nate
- * PERL!
- *
- * Revision 4.0.1.4 92/06/08 15:41:45 lwall
- * patch20: fixed confusion between a *var's real name and its effective name
- * patch20: removed implicit int declarations on functions
- *
- * Revision 4.0.1.3 91/11/05 18:41:47 lwall
- * patch11: random cleanup
- * patch11: solitary subroutine references no longer trigger typo warnings
- *
- * Revision 4.0.1.2 91/06/07 11:58:33 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0.1.1 91/04/12 09:16:12 lwall
- * patch1: you may now use "die" and "caller" in a signal handler
- *
- * Revision 4.0 91/03/20 01:40:04 lwall
- * 4.0 baseline.
- *
- */
-
-struct string {
- char * str_ptr; /* pointer to malloced string */
- STRLEN str_len; /* allocated size */
- union {
- double str_nval; /* numeric value, if any */
- long str_useful; /* is this search optimization effective? */
- ARG *str_args; /* list of args for interpreted string */
- HASH *str_hash; /* string represents an assoc array (stab?) */
- ARRAY *str_array; /* string represents an array */
- CMD *str_cmd; /* command for this source line */
- struct {
- STAB *stb_stab; /* magic stab for magic "key" string */
- HASH *stb_stash; /* which symbol table this stab is in */
- } stb_u;
- } str_u;
- STRLEN str_cur; /* length of str_ptr as a C string */
- STR *str_magic; /* while free, link to next free str */
- /* while in use, ptr to "key" for magic items */
- unsigned char str_pok; /* state of str_ptr */
- unsigned char str_nok; /* state of str_nval */
- unsigned char str_rare; /* used by search strings */
- unsigned char str_state; /* one of SS_* below */
- /* also used by search strings for backoff */
-#ifdef TAINT
- bool str_tainted; /* 1 if possibly under control of $< */
-#endif
-};
-
-struct stab { /* should be identical, except for str_ptr */
- STBP * str_ptr; /* pointer to malloced string */
- STRLEN str_len; /* allocated size */
- union {
- double str_nval; /* numeric value, if any */
- long str_useful; /* is this search optimization effective? */
- ARG *str_args; /* list of args for interpreted string */
- HASH *str_hash; /* string represents an assoc array (stab?) */
- ARRAY *str_array; /* string represents an array */
- CMD *str_cmd; /* command for this source line */
- struct {
- STAB *stb_stab; /* magic stab for magic "key" string */
- HASH *stb_stash; /* which symbol table this stab is in */
- } stb_u;
- } str_u;
- STRLEN str_cur; /* length of str_ptr as a C string */
- STR *str_magic; /* while free, link to next free str */
- /* while in use, ptr to "key" for magic items */
- unsigned char str_pok; /* state of str_ptr */
- unsigned char str_nok; /* state of str_nval */
- unsigned char str_rare; /* used by search strings */
- unsigned char str_state; /* one of SS_* below */
- /* also used by search strings for backoff */
-#ifdef TAINT
- bool str_tainted; /* 1 if possibly under control of $< */
-#endif
-};
-
-#define str_stab stb_u.stb_stab
-#define str_stash stb_u.stb_stash
-
-/* some extra info tacked to some lvalue strings */
-
-struct lstring {
- struct string lstr;
- STRLEN lstr_offset;
- STRLEN lstr_len;
-};
-
-/* These are the values of str_pok: */
-#define SP_VALID 1 /* str_ptr is valid */
-#define SP_FBM 2 /* string was compiled for fbm search */
-#define SP_STUDIED 4 /* string was studied */
-#define SP_CASEFOLD 8 /* case insensitive fbm search */
-#define SP_INTRP 16 /* string was compiled for interping */
-#define SP_TAIL 32 /* fbm string is tail anchored: /foo$/ */
-#define SP_MULTI 64 /* symbol table entry probably isn't a typo */
-#define SP_TEMP 128 /* string slated to die, so can be plundered */
-
-#define Nullstr Null(STR*)
-
-/* These are the values of str_state: */
-#define SS_NORM 0 /* normal string */
-#define SS_INCR 1 /* normal string, incremented ptr */
-#define SS_SARY 2 /* array on save stack */
-#define SS_SHASH 3 /* associative array on save stack */
-#define SS_SINT 4 /* integer on save stack */
-#define SS_SLONG 5 /* long on save stack */
-#define SS_SSTRP 6 /* STR* on save stack */
-#define SS_SHPTR 7 /* HASH* on save stack */
-#define SS_SNSTAB 8 /* non-stab on save stack */
-#define SS_SCSV 9 /* callsave structure on save stack */
-#define SS_SAPTR 10 /* ARRAY* on save stack */
-#define SS_HASH 253 /* carrying an hash */
-#define SS_ARY 254 /* carrying an array */
-#define SS_FREE 255 /* in free list */
-/* str_state may have any value 0-255 when used to hold fbm pattern, in which */
-/* case it indicates offset to rarest character in screaminstr key */
-
-/* the following macro updates any magic values this str is associated with */
-
-#ifdef TAINT
-#define STABSET(x) \
- (x)->str_tainted |= tainted; \
- if ((x)->str_magic) \
- stabset((x)->str_magic,(x))
-#else
-#define STABSET(x) \
- if ((x)->str_magic) \
- stabset((x)->str_magic,(x))
-#endif
-
-#define STR_SSET(dst,src) if (dst != src) str_sset(dst,src)
-
-EXT STR **tmps_list;
-EXT int tmps_max INIT(-1);
-EXT int tmps_base INIT(-1);
-
-char *str_2ptr();
-double str_2num();
-STR *str_mortal();
-STR *str_2mortal();
-STR *str_make();
-STR *str_nmake();
-STR *str_smake();
-int str_cmp();
-int str_eq();
-void str_magic();
-void str_insert();
-void str_numset();
-void str_sset();
-void str_nset();
-void str_set();
-void str_chop();
-void str_cat();
-void str_scat();
-void str_ncat();
-void str_reset();
-void str_taintproper();
-void str_taintenv();
-STRLEN str_len();
-
-#define MULTI (3)
diff --git a/gnu/usr.bin/perl/perl/t/README b/gnu/usr.bin/perl/perl/t/README
deleted file mode 100644
index 47ab845..0000000
--- a/gnu/usr.bin/perl/perl/t/README
+++ /dev/null
@@ -1,11 +0,0 @@
-This is the perl test library. To run all the tests, just type 'TEST'.
-
-To add new tests, just look at the current tests and do likewise.
-
-If a test fails, run it by itself to see if it prints any informative
-diagnostics. If not, modify the test to print informative diagnostics.
-If you put out extra lines with a '#' character on the front, you don't
-have to worry about removing the extra print statements later since TEST
-ignores lines beginning with '#'.
-
-If you come up with new tests, send them to lwall@netlabs.com.
diff --git a/gnu/usr.bin/perl/perl/t/TEST b/gnu/usr.bin/perl/perl/t/TEST
deleted file mode 100755
index 957a868..0000000
--- a/gnu/usr.bin/perl/perl/t/TEST
+++ /dev/null
@@ -1,102 +0,0 @@
-#!./perl
-
-# $RCSfile: TEST,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:01 $
-
-# This is written in a peculiar style, since we're trying to avoid
-# most of the constructs we'll be testing for.
-
-$| = 1;
-
-if ($ARGV[0] eq '-v') {
- $verbose = 1;
- shift;
-}
-
-chdir 't' if -f 't/TEST';
-
-if ($ARGV[0] eq '') {
- @ARGV = split(/[ \n]/,
- `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`);
-}
-
-open(CONFIG,"../config.sh");
-while (<CONFIG>) {
- if (/sharpbang='(.*)'/) {
- $sharpbang = ($1 eq '#!');
- last;
- }
-}
-$bad = 0;
-while ($test = shift) {
- if ($test =~ /^$/) {
- next;
- }
- $te = $test;
- chop($te);
- print "$te" . '.' x (15 - length($te));
- if ($sharpbang) {
- open(results,"./$test|") || (print "can't run.\n");
- } else {
- open(script,"$test") || die "Can't run $test.\n";
- $_ = <script>;
- close(script);
- if (/#!..perl(.*)/) {
- $switch = $1;
- } else {
- $switch = '';
- }
- open(results,"./perl$switch $test|") || (print "can't run.\n");
- }
- $ok = 0;
- $next = 0;
- while (<results>) {
- if ($verbose) {
- print $_;
- }
- unless (/^#/) {
- if (/^1\.\.([0-9]+)/) {
- $max = $1;
- $totmax += $max;
- $files += 1;
- $next = 1;
- $ok = 1;
- } else {
- $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
- if (/^ok (.*)/ && $1 == $next) {
- $next = $next + 1;
- } else {
- $ok = 0;
- }
- }
- }
- }
- $next = $next - 1;
- if ($ok && $next == $max) {
- print "ok\n";
- } else {
- $next += 1;
- print "FAILED on test $next\n";
- $bad = $bad + 1;
- $_ = $test;
- if (/^base/) {
- die "Failed a basic test--cannot continue.\n";
- }
- }
-}
-
-if ($bad == 0) {
- if ($ok) {
- print "All tests successful.\n";
- } else {
- die "FAILED--no tests were run for some reason.\n";
- }
-} else {
- if ($bad == 1) {
- die "Failed 1 test.\n";
- } else {
- die "Failed $bad tests.\n";
- }
-}
-($user,$sys,$cuser,$csys) = times;
-print sprintf("u=%g s=%g cu=%g cs=%g files=%d tests=%d\n",
- $user,$sys,$cuser,$csys,$files,$totmax);
diff --git a/gnu/usr.bin/perl/perl/t/base/cond.t b/gnu/usr.bin/perl/perl/t/base/cond.t
deleted file mode 100755
index 7d49f4e..0000000
--- a/gnu/usr.bin/perl/perl/t/base/cond.t
+++ /dev/null
@@ -1,19 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/base/cond.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-# make sure conditional operators work
-
-print "1..4\n";
-
-$x = '0';
-
-$x eq $x && (print "ok 1\n");
-$x ne $x && (print "not ok 1\n");
-$x eq $x || (print "not ok 2\n");
-$x ne $x || (print "ok 2\n");
-
-$x == $x && (print "ok 3\n");
-$x != $x && (print "not ok 3\n");
-$x == $x || (print "not ok 4\n");
-$x != $x || (print "ok 4\n");
diff --git a/gnu/usr.bin/perl/perl/t/base/if.t b/gnu/usr.bin/perl/perl/t/base/if.t
deleted file mode 100755
index 2a9b82c..0000000
--- a/gnu/usr.bin/perl/perl/t/base/if.t
+++ /dev/null
@@ -1,11 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/base/if.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-print "1..2\n";
-
-# first test to see if we can run the tests.
-
-$x = 'test';
-if ($x eq $x) { print "ok 1\n"; } else { print "not ok 1\n";}
-if ($x ne $x) { print "not ok 2\n"; } else { print "ok 2\n";}
diff --git a/gnu/usr.bin/perl/perl/t/base/lex.t b/gnu/usr.bin/perl/perl/t/base/lex.t
deleted file mode 100755
index cd6321d..0000000
--- a/gnu/usr.bin/perl/perl/t/base/lex.t
+++ /dev/null
@@ -1,78 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/base/lex.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-print "1..18\n";
-
-$ # this is the register <space>
-= 'x';
-
-print "#1 :$ : eq :x:\n";
-if ($ eq 'x') {print "ok 1\n";} else {print "not ok 1\n";}
-
-$x = $#; # this is the register $#
-
-if ($x eq '') {print "ok 2\n";} else {print "not ok 2\n";}
-
-$x = $#x;
-
-if ($x eq '-1') {print "ok 3\n";} else {print "not ok 3\n";}
-
-$x = '\\'; # ';
-
-if (length($x) == 1) {print "ok 4\n";} else {print "not ok 4\n";}
-
-eval 'while (0) {
- print "foo\n";
-}
-/^/ && (print "ok 5\n");
-';
-
-eval '$foo{1} / 1;';
-if (!$@) {print "ok 6\n";} else {print "not ok 6\n";}
-
-eval '$foo = 123+123.4+123e4+123.4E5+123.4e+5+.12;';
-
-$foo = int($foo * 100 + .5);
-if ($foo eq 2591024652) {print "ok 7\n";} else {print "not ok 7 :$foo:\n";}
-
-print <<'EOF';
-ok 8
-EOF
-
-$foo = 'ok 9';
-print <<EOF;
-$foo
-EOF
-
-eval <<\EOE, print $@;
-print <<'EOF';
-ok 10
-EOF
-
-$foo = 'ok 11';
-print <<EOF;
-$foo
-EOF
-EOE
-
-print <<`EOS` . <<\EOF;
-echo ok 12
-EOS
-ok 13
-EOF
-
-print qq/ok 14\n/;
-print qq(ok 15\n);
-
-print qq
-ok 16\n
-;
-
-print q<ok 17
->;
-
-print <<; # Yow!
-ok 18
-
-# previous line intentionally left blank.
diff --git a/gnu/usr.bin/perl/perl/t/base/pat.t b/gnu/usr.bin/perl/perl/t/base/pat.t
deleted file mode 100755
index 2c8d9a9..0000000
--- a/gnu/usr.bin/perl/perl/t/base/pat.t
+++ /dev/null
@@ -1,11 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/base/pat.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-print "1..2\n";
-
-# first test to see if we can run the tests.
-
-$_ = 'test';
-if (/^test/) { print "ok 1\n"; } else { print "not ok 1\n";}
-if (/^foo/) { print "not ok 2\n"; } else { print "ok 2\n";}
diff --git a/gnu/usr.bin/perl/perl/t/base/term.t b/gnu/usr.bin/perl/perl/t/base/term.t
deleted file mode 100755
index c049c58..0000000
--- a/gnu/usr.bin/perl/perl/t/base/term.t
+++ /dev/null
@@ -1,42 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/base/term.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-print "1..6\n";
-
-# check "" interpretation
-
-$x = "\n";
-if ($x lt ' ') {print "ok 1\n";} else {print "not ok 1\n";}
-
-# check `` processing
-
-$x = `echo hi there`;
-if ($x eq "hi there\n") {print "ok 2\n";} else {print "not ok 2\n";}
-
-# check $#array
-
-$x[0] = 'foo';
-$x[1] = 'foo';
-$tmp = $#x;
-print "#3\t:$tmp: == :1:\n";
-if ($#x == '1') {print "ok 3\n";} else {print "not ok 3\n";}
-
-# check numeric literal
-
-$x = 1;
-if ($x == '1') {print "ok 4\n";} else {print "not ok 4\n";}
-
-# check <> pseudoliteral
-
-open(try, "/dev/null") || (die "Can't open /dev/null.");
-if (<try> eq '') {
- print "ok 5\n";
-}
-else {
- print "not ok 5\n";
- die "/dev/null IS NOT A CHARACTER SPECIAL FILE!!!!\n" unless -c '/dev/null';
-}
-
-open(try, "../Makefile") || (die "Can't open ../Makefile.");
-if (<try> ne '') {print "ok 6\n";} else {print "not ok 6\n";}
diff --git a/gnu/usr.bin/perl/perl/t/cmd/elsif.t b/gnu/usr.bin/perl/perl/t/cmd/elsif.t
deleted file mode 100755
index 0e3457f..0000000
--- a/gnu/usr.bin/perl/perl/t/cmd/elsif.t
+++ /dev/null
@@ -1,25 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/cmd/elsif.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-sub foo {
- if ($_[0] == 1) {
- 1;
- }
- elsif ($_[0] == 2) {
- 2;
- }
- elsif ($_[0] == 3) {
- 3;
- }
- else {
- 4;
- }
-}
-
-print "1..4\n";
-
-if (($x = do foo(1)) == 1) {print "ok 1\n";} else {print "not ok 1 '$x'\n";}
-if (($x = do foo(2)) == 2) {print "ok 2\n";} else {print "not ok 2 '$x'\n";}
-if (($x = do foo(3)) == 3) {print "ok 3\n";} else {print "not ok 3 '$x'\n";}
-if (($x = do foo(4)) == 4) {print "ok 4\n";} else {print "not ok 4 '$x'\n";}
diff --git a/gnu/usr.bin/perl/perl/t/cmd/for.t b/gnu/usr.bin/perl/perl/t/cmd/for.t
deleted file mode 100755
index 4a0c922..0000000
--- a/gnu/usr.bin/perl/perl/t/cmd/for.t
+++ /dev/null
@@ -1,49 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/cmd/for.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-print "1..7\n";
-
-for ($i = 0; $i <= 10; $i++) {
- $x[$i] = $i;
-}
-$y = $x[10];
-print "#1 :$y: eq :10:\n";
-$y = join(' ', @x);
-print "#1 :$y: eq :0 1 2 3 4 5 6 7 8 9 10:\n";
-if (join(' ', @x) eq '0 1 2 3 4 5 6 7 8 9 10') {
- print "ok 1\n";
-} else {
- print "not ok 1\n";
-}
-
-$i = $c = 0;
-for (;;) {
- $c++;
- last if $i++ > 10;
-}
-if ($c == 12) {print "ok 2\n";} else {print "not ok 2\n";}
-
-$foo = 3210;
-@ary = (1,2,3,4,5);
-foreach $foo (@ary) {
- $foo *= 2;
-}
-if (join('',@ary) eq '246810') {print "ok 3\n";} else {print "not ok 3\n";}
-
-for (@ary) {
- s/(.*)/ok $1\n/;
-}
-
-print $ary[1];
-
-# test for internal scratch array generation
-# this also tests that $foo was restored to 3210 after test 3
-for (split(' ','a b c d e')) {
- $foo .= $_;
-}
-if ($foo eq '3210abcde') {print "ok 5\n";} else {print "not ok 5 $foo\n";}
-
-foreach $foo (("ok 6\n","ok 7\n")) {
- print $foo;
-}
diff --git a/gnu/usr.bin/perl/perl/t/cmd/mod.t b/gnu/usr.bin/perl/perl/t/cmd/mod.t
deleted file mode 100755
index eeb44d9..0000000
--- a/gnu/usr.bin/perl/perl/t/cmd/mod.t
+++ /dev/null
@@ -1,33 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/cmd/mod.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-print "1..7\n";
-
-print "ok 1\n" if 1;
-print "not ok 1\n" unless 1;
-
-print "ok 2\n" unless 0;
-print "not ok 2\n" if 0;
-
-1 && (print "not ok 3\n") if 0;
-1 && (print "ok 3\n") if 1;
-0 || (print "not ok 4\n") if 0;
-0 || (print "ok 4\n") if 1;
-
-$x = 0;
-do {$x[$x] = $x;} while ($x++) < 10;
-if (join(' ',@x) eq '0 1 2 3 4 5 6 7 8 9 10') {
- print "ok 5\n";
-} else {
- print "not ok 5\n";
-}
-
-$x = 15;
-$x = 10 while $x < 10;
-if ($x == 15) {print "ok 6\n";} else {print "not ok 6\n";}
-
-open(foo,'TEST') || open(foo,'t/TEST');
-$x = 0;
-$x++ while <foo>;
-print $x > 50 && $x < 1000 ? "ok 7\n" : "not ok 7\n";
diff --git a/gnu/usr.bin/perl/perl/t/cmd/subval.t b/gnu/usr.bin/perl/perl/t/cmd/subval.t
deleted file mode 100755
index f7f411b..0000000
--- a/gnu/usr.bin/perl/perl/t/cmd/subval.t
+++ /dev/null
@@ -1,179 +0,0 @@
-#!./perl
-
-# $RCSfile: subval.t,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:05 $
-
-sub foo1 {
- 'true1';
- if ($_[0]) { 'true2'; }
-}
-
-sub foo2 {
- 'true1';
- if ($_[0]) { return 'true2'; } else { return 'true3'; }
- 'true0';
-}
-
-sub foo3 {
- 'true1';
- unless ($_[0]) { 'true2'; }
-}
-
-sub foo4 {
- 'true1';
- unless ($_[0]) { 'true2'; } else { 'true3'; }
-}
-
-sub foo5 {
- 'true1';
- 'true2' if $_[0];
-}
-
-sub foo6 {
- 'true1';
- 'true2' unless $_[0];
-}
-
-print "1..34\n";
-
-if (do foo1(0) eq '0') {print "ok 1\n";} else {print "not ok 1 $foo\n";}
-if (do foo1(1) eq 'true2') {print "ok 2\n";} else {print "not ok 2\n";}
-if (do foo2(0) eq 'true3') {print "ok 3\n";} else {print "not ok 3\n";}
-if (do foo2(1) eq 'true2') {print "ok 4\n";} else {print "not ok 4\n";}
-
-if (do foo3(0) eq 'true2') {print "ok 5\n";} else {print "not ok 5\n";}
-if (do foo3(1) eq '1') {print "ok 6\n";} else {print "not ok 6\n";}
-if (do foo4(0) eq 'true2') {print "ok 7\n";} else {print "not ok 7\n";}
-if (do foo4(1) eq 'true3') {print "ok 8\n";} else {print "not ok 8\n";}
-
-if (do foo5(0) eq '0') {print "ok 9\n";} else {print "not ok 9\n";}
-if (do foo5(1) eq 'true2') {print "ok 10\n";} else {print "not ok 10\n";}
-if (do foo6(0) eq 'true2') {print "ok 11\n";} else {print "not ok 11\n";}
-if (do foo6(1) eq '1') {print "ok 12\n";} else {print "not ok 12 $x\n";}
-
-# Now test to see that recursion works using a Fibonacci number generator
-
-sub fib {
- local($arg) = @_;
- local($foo);
- $level++;
- if ($arg <= 2) {
- $foo = 1;
- }
- else {
- $foo = do fib($arg-1) + do fib($arg-2);
- }
- $level--;
- $foo;
-}
-
-@good = (0,1,1,2,3,5,8,13,21,34,55,89);
-
-for ($i = 1; $i <= 10; $i++) {
- $foo = $i + 12;
- if (do fib($i) == $good[$i]) {
- print "ok $foo\n";
- }
- else {
- print "not ok $foo\n";
- }
-}
-
-sub ary1 {
- (1,2,3);
-}
-
-print &ary1 eq 3 ? "ok 23\n" : "not ok 23\n";
-
-print join(':',&ary1) eq '1:2:3' ? "ok 24\n" : "not ok 24\n";
-
-sub ary2 {
- do {
- return (1,2,3);
- (3,2,1);
- };
- 0;
-}
-
-print &ary2 eq 3 ? "ok 25\n" : "not ok 25\n";
-
-$x = join(':',&ary2);
-print $x eq '1:2:3' ? "ok 26\n" : "not ok 26 $x\n";
-
-sub somesub {
- local($num,$P,$F,$L) = @_;
- ($p,$f,$l) = caller;
- print "$p:$f:$l" eq "$P:$F:$L" ? "ok $num\n" : "not ok $num $p:$f:$l ne $P:$F:$L\n";
-}
-
-&somesub(27, 'main', __FILE__, __LINE__);
-
-package foo;
-&main'somesub(28, 'foo', __FILE__, __LINE__);
-
-package main;
-$i = 28;
-open(FOO,">Cmd_subval.tmp");
-print FOO "blah blah\n";
-close FOO;
-
-&file_main(*F);
-close F;
-&info_main;
-
-&file_package(*F);
-close F;
-&info_package;
-
-unlink 'Cmd_subval.tmp';
-
-sub file_main {
- local(*F) = @_;
-
- open(F, 'Cmd_subval.tmp') || die "can't open\n";
- $i++;
- eof F ? print "not ok $i\n" : print "ok $i\n";
-}
-
-sub info_main {
- local(*F);
-
- open(F, 'Cmd_subval.tmp') || die "test: can't open\n";
- $i++;
- eof F ? print "not ok $i\n" : print "ok $i\n";
- &iseof(*F);
- close F;
-}
-
-sub iseof {
- local(*UNIQ) = @_;
-
- $i++;
- eof UNIQ ? print "(not ok $i)\n" : print "ok $i\n";
-}
-
-{package foo;
-
- sub main'file_package {
- local(*F) = @_;
-
- open(F, 'Cmd_subval.tmp') || die "can't open\n";
- $main'i++;
- eof F ? print "not ok $main'i\n" : print "ok $main'i\n";
- }
-
- sub main'info_package {
- local(*F);
-
- open(F, 'Cmd_subval.tmp') || die "can't open\n";
- $main'i++;
- eof F ? print "not ok $main'i\n" : print "ok $main'i\n";
- &iseof(*F);
- }
-
- sub iseof {
- local(*UNIQ) = @_;
-
- $main'i++;
- eof UNIQ ? print "not ok $main'i\n" : print "ok $main'i\n";
- }
-}
diff --git a/gnu/usr.bin/perl/perl/t/cmd/switch.t b/gnu/usr.bin/perl/perl/t/cmd/switch.t
deleted file mode 100755
index d0d4c93..0000000
--- a/gnu/usr.bin/perl/perl/t/cmd/switch.t
+++ /dev/null
@@ -1,75 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/cmd/switch.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-print "1..18\n";
-
-sub foo1 {
- $_ = shift(@_);
- $a = 0;
- until ($a++) {
- next if $_ eq 1;
- next if $_ eq 2;
- next if $_ eq 3;
- next if $_ eq 4;
- return 20;
- }
- continue {
- return $_;
- }
-}
-
-print do foo1(0) == 20 ? "ok 1\n" : "not ok 1\n";
-print do foo1(1) == 1 ? "ok 2\n" : "not ok 2\n";
-print do foo1(2) == 2 ? "ok 3\n" : "not ok 3\n";
-print do foo1(3) == 3 ? "ok 4\n" : "not ok 4\n";
-print do foo1(4) == 4 ? "ok 5\n" : "not ok 5\n";
-print do foo1(5) == 20 ? "ok 6\n" : "not ok 6\n";
-
-sub foo2 {
- $_ = shift(@_);
- {
- last if $_ == 1;
- last if $_ == 2;
- last if $_ == 3;
- last if $_ == 4;
- }
- continue {
- return 20;
- }
- return $_;
-}
-
-print do foo2(0) == 20 ? "ok 7\n" : "not ok 1\n";
-print do foo2(1) == 1 ? "ok 8\n" : "not ok 8\n";
-print do foo2(2) == 2 ? "ok 9\n" : "not ok 9\n";
-print do foo2(3) == 3 ? "ok 10\n" : "not ok 10\n";
-print do foo2(4) == 4 ? "ok 11\n" : "not ok 11\n";
-print do foo2(5) == 20 ? "ok 12\n" : "not ok 12\n";
-
-sub foo3 {
- $_ = shift(@_);
- if (/^1/) {
- return 1;
- }
- elsif (/^2/) {
- return 2;
- }
- elsif (/^3/) {
- return 3;
- }
- elsif (/^4/) {
- return 4;
- }
- else {
- return 20;
- }
- return 40;
-}
-
-print do foo3(0) == 20 ? "ok 13\n" : "not ok 13\n";
-print do foo3(1) == 1 ? "ok 14\n" : "not ok 14\n";
-print do foo3(2) == 2 ? "ok 15\n" : "not ok 15\n";
-print do foo3(3) == 3 ? "ok 16\n" : "not ok 16\n";
-print do foo3(4) == 4 ? "ok 17\n" : "not ok 17\n";
-print do foo3(5) == 20 ? "ok 18\n" : "not ok 18\n";
diff --git a/gnu/usr.bin/perl/perl/t/cmd/while.t b/gnu/usr.bin/perl/perl/t/cmd/while.t
deleted file mode 100755
index 006e251..0000000
--- a/gnu/usr.bin/perl/perl/t/cmd/while.t
+++ /dev/null
@@ -1,110 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/cmd/while.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-print "1..10\n";
-
-open (tmp,'>Cmd.while.tmp') || die "Can't create Cmd.while.tmp.";
-print tmp "tvi925\n";
-print tmp "tvi920\n";
-print tmp "vt100\n";
-print tmp "Amiga\n";
-print tmp "paper\n";
-close tmp;
-
-# test "last" command
-
-open(fh,'Cmd.while.tmp') || die "Can't open Cmd.while.tmp.";
-while (<fh>) {
- last if /vt100/;
-}
-if (!eof && /vt100/) {print "ok 1\n";} else {print "not ok 1 $_\n";}
-
-# test "next" command
-
-$bad = '';
-open(fh,'Cmd.while.tmp') || die "Can't open Cmd.while.tmp.";
-while (<fh>) {
- next if /vt100/;
- $bad = 1 if /vt100/;
-}
-if (!eof || /vt100/ || $bad) {print "not ok 2\n";} else {print "ok 2\n";}
-
-# test "redo" command
-
-$bad = '';
-open(fh,'Cmd.while.tmp') || die "Can't open Cmd.while.tmp.";
-while (<fh>) {
- if (s/vt100/VT100/g) {
- s/VT100/Vt100/g;
- redo;
- }
- $bad = 1 if /vt100/;
- $bad = 1 if /VT100/;
-}
-if (!eof || $bad) {print "not ok 3\n";} else {print "ok 3\n";}
-
-# now do the same with a label and a continue block
-
-# test "last" command
-
-$badcont = '';
-open(fh,'Cmd.while.tmp') || die "Can't open Cmd.while.tmp.";
-line: while (<fh>) {
- if (/vt100/) {last line;}
-} continue {
- $badcont = 1 if /vt100/;
-}
-if (!eof && /vt100/) {print "ok 4\n";} else {print "not ok 4\n";}
-if (!$badcont) {print "ok 5\n";} else {print "not ok 5\n";}
-
-# test "next" command
-
-$bad = '';
-$badcont = 1;
-open(fh,'Cmd.while.tmp') || die "Can't open Cmd.while.tmp.";
-entry: while (<fh>) {
- next entry if /vt100/;
- $bad = 1 if /vt100/;
-} continue {
- $badcont = '' if /vt100/;
-}
-if (!eof || /vt100/ || $bad) {print "not ok 6\n";} else {print "ok 6\n";}
-if (!$badcont) {print "ok 7\n";} else {print "not ok 7\n";}
-
-# test "redo" command
-
-$bad = '';
-$badcont = '';
-open(fh,'Cmd.while.tmp') || die "Can't open Cmd.while.tmp.";
-loop: while (<fh>) {
- if (s/vt100/VT100/g) {
- s/VT100/Vt100/g;
- redo loop;
- }
- $bad = 1 if /vt100/;
- $bad = 1 if /VT100/;
-} continue {
- $badcont = 1 if /vt100/;
-}
-if (!eof || $bad) {print "not ok 8\n";} else {print "ok 8\n";}
-if (!$badcont) {print "ok 9\n";} else {print "not ok 9\n";}
-
-`/bin/rm -f Cmd.while.tmp`;
-
-#$x = 0;
-#while (1) {
-# if ($x > 1) {last;}
-# next;
-#} continue {
-# if ($x++ > 10) {last;}
-# next;
-#}
-#
-#if ($x < 10) {print "ok 10\n";} else {print "not ok 10\n";}
-
-$i = 9;
-{
- $i++;
-}
-print "ok $i\n";
diff --git a/gnu/usr.bin/perl/perl/t/comp/cmdopt.t b/gnu/usr.bin/perl/perl/t/comp/cmdopt.t
deleted file mode 100755
index 3c47130..0000000
--- a/gnu/usr.bin/perl/perl/t/comp/cmdopt.t
+++ /dev/null
@@ -1,83 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/comp/cmdopt.t,v 1.1.1.1 1993/08/23 21:30:06 nate Exp $
-
-print "1..40\n";
-
-# test the optimization of constants
-
-if (1) { print "ok 1\n";} else { print "not ok 1\n";}
-unless (0) { print "ok 2\n";} else { print "not ok 2\n";}
-
-if (0) { print "not ok 3\n";} else { print "ok 3\n";}
-unless (1) { print "not ok 4\n";} else { print "ok 4\n";}
-
-unless (!1) { print "ok 5\n";} else { print "not ok 5\n";}
-if (!0) { print "ok 6\n";} else { print "not ok 6\n";}
-
-unless (!0) { print "not ok 7\n";} else { print "ok 7\n";}
-if (!1) { print "not ok 8\n";} else { print "ok 8\n";}
-
-$x = 1;
-if (1 && $x) { print "ok 9\n";} else { print "not ok 9\n";}
-if (0 && $x) { print "not ok 10\n";} else { print "ok 10\n";}
-$x = '';
-if (1 && $x) { print "not ok 11\n";} else { print "ok 11\n";}
-if (0 && $x) { print "not ok 12\n";} else { print "ok 12\n";}
-
-$x = 1;
-if (1 || $x) { print "ok 13\n";} else { print "not ok 13\n";}
-if (0 || $x) { print "ok 14\n";} else { print "not ok 14\n";}
-$x = '';
-if (1 || $x) { print "ok 15\n";} else { print "not ok 15\n";}
-if (0 || $x) { print "not ok 16\n";} else { print "ok 16\n";}
-
-
-# test the optimization of registers
-
-$x = 1;
-if ($x) { print "ok 17\n";} else { print "not ok 17\n";}
-unless ($x) { print "not ok 18\n";} else { print "ok 18\n";}
-
-$x = '';
-if ($x) { print "not ok 19\n";} else { print "ok 19\n";}
-unless ($x) { print "ok 20\n";} else { print "not ok 20\n";}
-
-# test optimization of string operations
-
-$a = 'a';
-if ($a eq 'a') { print "ok 21\n";} else { print "not ok 21\n";}
-if ($a ne 'a') { print "not ok 22\n";} else { print "ok 22\n";}
-
-if ($a =~ /a/) { print "ok 23\n";} else { print "not ok 23\n";}
-if ($a !~ /a/) { print "not ok 24\n";} else { print "ok 24\n";}
-# test interaction of logicals and other operations
-
-$a = 'a';
-$x = 1;
-if ($a eq 'a' && $x) { print "ok 25\n";} else { print "not ok 25\n";}
-if ($a ne 'a' && $x) { print "not ok 26\n";} else { print "ok 26\n";}
-$x = '';
-if ($a eq 'a' && $x) { print "not ok 27\n";} else { print "ok 27\n";}
-if ($a ne 'a' && $x) { print "not ok 28\n";} else { print "ok 28\n";}
-
-$x = 1;
-if ($a eq 'a' || $x) { print "ok 29\n";} else { print "not ok 29\n";}
-if ($a ne 'a' || $x) { print "ok 30\n";} else { print "not ok 30\n";}
-$x = '';
-if ($a eq 'a' || $x) { print "ok 31\n";} else { print "not ok 31\n";}
-if ($a ne 'a' || $x) { print "not ok 32\n";} else { print "ok 32\n";}
-
-$x = 1;
-if ($a =~ /a/ && $x) { print "ok 33\n";} else { print "not ok 33\n";}
-if ($a !~ /a/ && $x) { print "not ok 34\n";} else { print "ok 34\n";}
-$x = '';
-if ($a =~ /a/ && $x) { print "not ok 35\n";} else { print "ok 35\n";}
- if ($a !~ /a/ && $x) { print "not ok 36\n";} else { print "ok 36\n";}
-
-$x = 1;
-if ($a =~ /a/ || $x) { print "ok 37\n";} else { print "not ok 37\n";}
-if ($a !~ /a/ || $x) { print "ok 38\n";} else { print "not ok 38\n";}
-$x = '';
-if ($a =~ /a/ || $x) { print "ok 39\n";} else { print "not ok 39\n";}
-if ($a !~ /a/ || $x) { print "not ok 40\n";} else { print "ok 40\n";}
diff --git a/gnu/usr.bin/perl/perl/t/comp/cpp.t b/gnu/usr.bin/perl/perl/t/comp/cpp.t
deleted file mode 100755
index 8cceb73..0000000
--- a/gnu/usr.bin/perl/perl/t/comp/cpp.t
+++ /dev/null
@@ -1,51 +0,0 @@
-#!./perl -P
-
-# $RCSfile: cpp.t,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:06 $
-
-open(CONFIG,"../config.sh") || die;
-while (<CONFIG>) {
- if (/^cppstdin/) {
- if (/^cppstdin='(.*cppstdin)'/ && ! -e $1) {
- print "1..0\n";
- exit; # Can't test till after install, alas.
- }
- last;
- }
-}
-close CONFIG;
-
-print "1..3\n";
-
-#this is a comment
-#define MESS "ok 1\n"
-print MESS;
-
-#If you capitalize, it's a comment.
-#ifdef MESS
- print "ok 2\n";
-#else
- print "not ok 2\n";
-#endif
-
-open(TRY,">Comp.cpp.tmp") || die "Can't open temp perl file.";
-
-($prog = <<'END') =~ s/X//g;
-X$ok = "not ok 3\n";
-X#include "Comp.cpp.inc"
-X#ifdef OK
-X$ok = OK;
-X#endif
-Xprint $ok;
-END
-print TRY $prog;
-close TRY;
-
-open(TRY,">Comp.cpp.inc") || (die "Can't open temp include file.");
-print TRY '#define OK "ok 3\n"' . "\n";
-close TRY;
-
-$pwd=`pwd`;
-$pwd =~ s/\n//;
-$x = `./perl -P Comp.cpp.tmp`;
-print $x;
-unlink "Comp.cpp.tmp", "Comp.cpp.inc";
diff --git a/gnu/usr.bin/perl/perl/t/comp/decl.t b/gnu/usr.bin/perl/perl/t/comp/decl.t
deleted file mode 100755
index f1c84c2..0000000
--- a/gnu/usr.bin/perl/perl/t/comp/decl.t
+++ /dev/null
@@ -1,49 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/comp/decl.t,v 1.1.1.1 1993/08/23 21:30:07 nate Exp $
-
-# check to see if subroutine declarations work everwhere
-
-sub one {
- print "ok 1\n";
-}
-format one =
-ok 5
-.
-
-print "1..7\n";
-
-do one();
-do two();
-
-sub two {
- print "ok 2\n";
-}
-format two =
-@<<<
-$foo
-.
-
-if ($x eq $x) {
- sub three {
- print "ok 3\n";
- }
- do three();
-}
-
-do four();
-$~ = 'one';
-write;
-$~ = 'two';
-$foo = "ok 6";
-write;
-$~ = 'three';
-write;
-
-format three =
-ok 7
-.
-
-sub four {
- print "ok 4\n";
-}
diff --git a/gnu/usr.bin/perl/perl/t/comp/multiline.t b/gnu/usr.bin/perl/perl/t/comp/multiline.t
deleted file mode 100755
index 78df482..0000000
--- a/gnu/usr.bin/perl/perl/t/comp/multiline.t
+++ /dev/null
@@ -1,40 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/comp/multiline.t,v 1.1.1.1 1993/08/23 21:30:06 nate Exp $
-
-print "1..5\n";
-
-open(try,'>Comp.try') || (die "Can't open temp file.");
-
-$x = 'now is the time
-for all good men
-to come to.
-';
-
-$y = 'now is the time' . "\n" .
-'for all good men' . "\n" .
-'to come to.' . "\n";
-
-if ($x eq $y) {print "ok 1\n";} else {print "not ok 1\n";}
-
-print try $x;
-close try;
-
-open(try,'Comp.try') || (die "Can't reopen temp file.");
-$count = 0;
-$z = '';
-while (<try>) {
- $z .= $_;
- $count = $count + 1;
-}
-
-if ($z eq $y) {print "ok 2\n";} else {print "not ok 2\n";}
-
-if ($count == 3) {print "ok 3\n";} else {print "not ok 3\n";}
-
-$_ = `cat Comp.try`;
-
-if (/.*\n.*\n.*\n$/) {print "ok 4\n";} else {print "not ok 4\n";}
-`/bin/rm -f Comp.try`;
-
-if ($_ eq $y) {print "ok 5\n";} else {print "not ok 5\n";}
diff --git a/gnu/usr.bin/perl/perl/t/comp/package.t b/gnu/usr.bin/perl/perl/t/comp/package.t
deleted file mode 100755
index 5237011..0000000
--- a/gnu/usr.bin/perl/perl/t/comp/package.t
+++ /dev/null
@@ -1,33 +0,0 @@
-#!./perl
-
-print "1..7\n";
-
-$blurfl = 123;
-$foo = 3;
-
-package XYZ;
-
-$bar = 4;
-
-{
- package ABC;
- $blurfl = 5;
- $main'a = $'b;
-}
-
-$ABC'dyick = 6;
-
-$xyz = 2;
-
-$main = join(':', sort(keys _main));
-$XYZ = join(':', sort(keys _XYZ));
-$ABC = join(':', sort(keys _ABC));
-
-print $XYZ eq 'ABC:XYZ:bar:main:xyz' ? "ok 1\n" : "not ok 1 '$XYZ'\n";
-print $ABC eq 'blurfl:dyick' ? "ok 2\n" : "not ok 2\n";
-print $main'blurfl == 123 ? "ok 3\n" : "not ok 3\n";
-package ABC;
-print $blurfl == 5 ? "ok 4\n" : "not ok 4\n";
-eval 'print $blurfl == 5 ? "ok 5\n" : "not ok 5\n";';
-eval 'package main; print $blurfl == 123 ? "ok 6\n" : "not ok 6\n";';
-print $blurfl == 5 ? "ok 7\n" : "not ok 7\n";
diff --git a/gnu/usr.bin/perl/perl/t/comp/script.t b/gnu/usr.bin/perl/perl/t/comp/script.t
deleted file mode 100755
index 9dcf901..0000000
--- a/gnu/usr.bin/perl/perl/t/comp/script.t
+++ /dev/null
@@ -1,23 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/comp/script.t,v 1.1.1.1 1993/08/23 21:30:06 nate Exp $
-
-print "1..3\n";
-
-$x = `./perl -e 'print "ok\n";'`;
-
-if ($x eq "ok\n") {print "ok 1\n";} else {print "not ok 1\n";}
-
-open(try,">Comp.script") || (die "Can't open temp file.");
-print try 'print "ok\n";'; print try "\n";
-close try;
-
-$x = `./perl Comp.script`;
-
-if ($x eq "ok\n") {print "ok 2\n";} else {print "not ok 2\n";}
-
-$x = `./perl <Comp.script`;
-
-if ($x eq "ok\n") {print "ok 3\n";} else {print "not ok 3\n";}
-
-`/bin/rm -f Comp.script`;
diff --git a/gnu/usr.bin/perl/perl/t/comp/term.t b/gnu/usr.bin/perl/perl/t/comp/term.t
deleted file mode 100755
index 70b23fd..0000000
--- a/gnu/usr.bin/perl/perl/t/comp/term.t
+++ /dev/null
@@ -1,35 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/comp/term.t,v 1.1.1.1 1993/08/23 21:30:06 nate Exp $
-
-# tests that aren't important enough for base.term
-
-print "1..14\n";
-
-$x = "\\n";
-print "#1\t:$x: eq " . ':\n:' . "\n";
-if ($x eq '\n') {print "ok 1\n";} else {print "not ok 1\n";}
-
-$x = "#2\t:$x: eq :\\n:\n";
-print $x;
-unless (index($x,'\\\\')>0) {print "ok 2\n";} else {print "not ok 2\n";}
-
-if (length('\\\\') == 2) {print "ok 3\n";} else {print "not ok 3\n";}
-
-$one = 'a';
-
-if (length("\\n") == 2) {print "ok 4\n";} else {print "not ok 4\n";}
-if (length("\\\n") == 2) {print "ok 5\n";} else {print "not ok 5\n";}
-if (length("$one\\n") == 3) {print "ok 6\n";} else {print "not ok 6\n";}
-if (length("$one\\\n") == 3) {print "ok 7\n";} else {print "not ok 7\n";}
-if (length("\\n$one") == 3) {print "ok 8\n";} else {print "not ok 8\n";}
-if (length("\\\n$one") == 3) {print "ok 9\n";} else {print "not ok 9\n";}
-if (length("\\${one}") == 2) {print "ok 10\n";} else {print "not ok 10\n";}
-
-if ("${one}b" eq "ab") { print "ok 11\n";} else {print "not ok 11\n";}
-
-@foo = (1,2,3);
-if ("$foo[1]b" eq "2b") { print "ok 12\n";} else {print "not ok 12\n";}
-if ("@foo[0..1]b" eq "1 2b") { print "ok 13\n";} else {print "not ok 13\n";}
-$" = '::';
-if ("@foo[0..1]b" eq "1::2b") { print "ok 14\n";} else {print "not ok 14\n";}
diff --git a/gnu/usr.bin/perl/perl/t/io/argv.t b/gnu/usr.bin/perl/perl/t/io/argv.t
deleted file mode 100755
index 99c5936..0000000
--- a/gnu/usr.bin/perl/perl/t/io/argv.t
+++ /dev/null
@@ -1,36 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/io/argv.t,v 1.1.1.1 1993/08/23 21:30:06 nate Exp $
-
-print "1..5\n";
-
-open(try, '>Io.argv.tmp') || (die "Can't open temp file.");
-print try "a line\n";
-close try;
-
-$x = `./perl -e 'while (<>) {print \$.,\$_;}' Io.argv.tmp Io.argv.tmp`;
-
-if ($x eq "1a line\n2a line\n") {print "ok 1\n";} else {print "not ok 1\n";}
-
-$x = `echo foo|./perl -e 'while (<>) {print $_;}' Io.argv.tmp -`;
-
-if ($x eq "a line\nfoo\n") {print "ok 2\n";} else {print "not ok 2\n";}
-
-$x = `echo foo|./perl -e 'while (<>) {print $_;}'`;
-
-if ($x eq "foo\n") {print "ok 3\n";} else {print "not ok 3 :$x:\n";}
-
-@ARGV = ('Io.argv.tmp', 'Io.argv.tmp', '/dev/null', 'Io.argv.tmp');
-while (<>) {
- $y .= $. . $_;
- if (eof()) {
- if ($. == 3) {print "ok 4\n";} else {print "not ok 4\n";}
- }
-}
-
-if ($y eq "1a line\n2a line\n3a line\n")
- {print "ok 5\n";}
-else
- {print "not ok 5\n";}
-
-`/bin/rm -f Io.argv.tmp`;
diff --git a/gnu/usr.bin/perl/perl/t/io/dup.t b/gnu/usr.bin/perl/perl/t/io/dup.t
deleted file mode 100755
index 8d11eca..0000000
--- a/gnu/usr.bin/perl/perl/t/io/dup.t
+++ /dev/null
@@ -1,32 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/io/dup.t,v 1.1.1.1 1993/08/23 21:30:06 nate Exp $
-
-print "1..6\n";
-
-print "ok 1\n";
-
-open(dupout,">&STDOUT");
-open(duperr,">&STDERR");
-
-open(STDOUT,">Io.dup") || die "Can't open stdout";
-open(STDERR,">&STDOUT") || die "Can't open stderr";
-
-select(STDERR); $| = 1;
-select(STDOUT); $| = 1;
-
-print STDOUT "ok 2\n";
-print STDERR "ok 3\n";
-system 'echo ok 4';
-system 'echo ok 5 1>&2';
-
-close(STDOUT);
-close(STDERR);
-
-open(STDOUT,">&dupout");
-open(STDERR,">&duperr");
-
-system 'cat Io.dup';
-unlink 'Io.dup';
-
-print STDOUT "ok 6\n";
diff --git a/gnu/usr.bin/perl/perl/t/io/fs.t b/gnu/usr.bin/perl/perl/t/io/fs.t
deleted file mode 100755
index 1d95cdc..0000000
--- a/gnu/usr.bin/perl/perl/t/io/fs.t
+++ /dev/null
@@ -1,85 +0,0 @@
-#!./perl
-
-# $RCSfile: fs.t,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:05 $
-
-print "1..22\n";
-
-$wd = `pwd`;
-chop($wd);
-
-`rm -f tmp 2>/dev/null; mkdir tmp 2>/dev/null`;
-chdir './tmp';
-`/bin/rm -rf a b c x`;
-
-umask(022);
-
-if ((umask(0)&0777) == 022) {print "ok 1\n";} else {print "not ok 1\n";}
-open(fh,'>x') || die "Can't create x";
-close(fh);
-open(fh,'>a') || die "Can't create a";
-close(fh);
-
-if (link('a','b')) {print "ok 2\n";} else {print "not ok 2\n";}
-
-if (link('b','c')) {print "ok 3\n";} else {print "not ok 3\n";}
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('c');
-
-if ($nlink == 3) {print "ok 4\n";} else {print "not ok 4\n";}
-if (($mode & 0777) == 0666) {print "ok 5\n";} else {print "not ok 5\n";}
-
-if ((chmod 0777,'a') == 1) {print "ok 6\n";} else {print "not ok 6\n";}
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('c');
-if (($mode & 0777) == 0777) {print "ok 7\n";} else {print "not ok 7\n";}
-
-if ((chmod 0700,'c','x') == 2) {print "ok 8\n";} else {print "not ok 8\n";}
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('c');
-if (($mode & 0777) == 0700) {print "ok 9\n";} else {print "not ok 9\n";}
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('x');
-if (($mode & 0777) == 0700) {print "ok 10\n";} else {print "not ok 10\n";}
-
-if ((unlink 'b','x') == 2) {print "ok 11\n";} else {print "not ok 11\n";}
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('b');
-if ($ino == 0) {print "ok 12\n";} else {print "not ok 12\n";}
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('x');
-if ($ino == 0) {print "ok 13\n";} else {print "not ok 13\n";}
-
-if (rename('a','b')) {print "ok 14\n";} else {print "not ok 14\n";}
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('a');
-if ($ino == 0) {print "ok 15\n";} else {print "not ok 15\n";}
-$foo = (utime 500000000,500000001,'b');
-if ($foo == 1) {print "ok 16\n";} else {print "not ok 16 $foo\n";}
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('b');
-if ($ino) {print "ok 17\n";} else {print "not ok 17\n";}
-if (($atime == 500000000 && $mtime == 500000001) || $wd =~ m#/afs/#)
- {print "ok 18\n";}
-else
- {print "not ok 18 $atime $mtime\n";}
-
-if ((unlink 'b') == 1) {print "ok 19\n";} else {print "not ok 19\n";}
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('b');
-if ($ino == 0) {print "ok 20\n";} else {print "not ok 20\n";}
-unlink 'c';
-
-chdir $wd || die "Can't cd back to $wd";
-
-unlink 'c';
-if (`ls -l perl 2>/dev/null` =~ /^l.*->/) { # we have symbolic links
- if (symlink("TEST","c")) {print "ok 21\n";} else {print "not ok 21\n";}
- $foo = `grep perl c`;
- if ($foo) {print "ok 22\n";} else {print "not ok 22\n";}
-}
-else {
- print "ok 21\nok 22\n";
-}
diff --git a/gnu/usr.bin/perl/perl/t/io/inplace.t b/gnu/usr.bin/perl/perl/t/io/inplace.t
deleted file mode 100755
index b22afda..0000000
--- a/gnu/usr.bin/perl/perl/t/io/inplace.t
+++ /dev/null
@@ -1,21 +0,0 @@
-#!./perl
-
-$^I = '.bak';
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/io/inplace.t,v 1.1.1.1 1993/08/23 21:30:05 nate Exp $
-
-print "1..2\n";
-
-@ARGV = ('.a','.b','.c');
-`echo foo | tee .a .b .c`;
-while (<>) {
- s/foo/bar/;
-}
-continue {
- print;
-}
-
-if (`cat .a .b .c` eq "bar\nbar\nbar\n") {print "ok 1\n";} else {print "not ok 1\n";}
-if (`cat .a.bak .b.bak .c.bak` eq "foo\nfoo\nfoo\n") {print "ok 2\n";} else {print "not ok 2\n";}
-
-unlink '.a', '.b', '.c', '.a.bak', '.b.bak', '.c.bak';
diff --git a/gnu/usr.bin/perl/perl/t/io/pipe.t b/gnu/usr.bin/perl/perl/t/io/pipe.t
deleted file mode 100755
index 791a9c7..0000000
--- a/gnu/usr.bin/perl/perl/t/io/pipe.t
+++ /dev/null
@@ -1,56 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/io/pipe.t,v 1.1.1.1 1993/08/23 21:30:06 nate Exp $
-
-$| = 1;
-print "1..8\n";
-
-open(PIPE, "|-") || (exec 'tr', '[A-Z]', '[a-z]');
-print PIPE "OK 1\n";
-print PIPE "ok 2\n";
-close PIPE;
-
-if (open(PIPE, "-|")) {
- while(<PIPE>) {
- s/^not //;
- print;
- }
-}
-else {
- print STDOUT "not ok 3\n";
- exec 'echo', 'not ok 4';
-}
-
-pipe(READER,WRITER) || die "Can't open pipe";
-
-if ($pid = fork) {
- close WRITER;
- while(<READER>) {
- s/^not //;
- y/A-Z/a-z/;
- print;
- }
-}
-else {
- die "Couldn't fork" unless defined $pid;
- close READER;
- print WRITER "not ok 5\n";
- open(STDOUT,">&WRITER") || die "Can't dup WRITER to STDOUT";
- close WRITER;
- exec 'echo', 'not ok 6';
-}
-
-
-pipe(READER,WRITER) || die "Can't open pipe";
-close READER;
-
-$SIG{'PIPE'} = 'broken_pipe';
-
-sub broken_pipe {
- print "ok 7\n";
-}
-
-print WRITER "not ok 7\n";
-close WRITER;
-
-print "ok 8\n";
diff --git a/gnu/usr.bin/perl/perl/t/io/print.t b/gnu/usr.bin/perl/perl/t/io/print.t
deleted file mode 100755
index 1185442..0000000
--- a/gnu/usr.bin/perl/perl/t/io/print.t
+++ /dev/null
@@ -1,32 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/io/print.t,v 1.1.1.1 1993/08/23 21:30:06 nate Exp $
-
-print "1..16\n";
-
-$foo = 'STDOUT';
-print $foo "ok 1\n";
-
-print "ok 2\n","ok 3\n","ok 4\n";
-print STDOUT "ok 5\n";
-
-open(foo,">-");
-print foo "ok 6\n";
-
-printf "ok %d\n",7;
-printf("ok %d\n",8);
-
-@a = ("ok %d%c",9,ord("\n"));
-printf @a;
-
-$a[1] = 10;
-printf STDOUT @a;
-
-$, = ' ';
-$\ = "\n";
-
-print "ok","11";
-
-@x = ("ok","12\nok","13\nok");
-@y = ("15\nok","16");
-print @x,"14\nok",@y;
diff --git a/gnu/usr.bin/perl/perl/t/io/tell.t b/gnu/usr.bin/perl/perl/t/io/tell.t
deleted file mode 100755
index 27e69a0..0000000
--- a/gnu/usr.bin/perl/perl/t/io/tell.t
+++ /dev/null
@@ -1,44 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/io/tell.t,v 1.1.1.1 1993/08/23 21:30:06 nate Exp $
-
-print "1..13\n";
-
-$TST = 'tst';
-
-open($TST, '../Makefile') || (die "Can't open ../Makefile");
-
-if (eof(tst)) { print "not ok 1\n"; } else { print "ok 1\n"; }
-
-$firstline = <$TST>;
-$secondpos = tell;
-
-$x = 0;
-while (<tst>) {
- if (eof) {$x++;}
-}
-if ($x == 1) { print "ok 2\n"; } else { print "not ok 2\n"; }
-
-$lastpos = tell;
-
-unless (eof) { print "not ok 3\n"; } else { print "ok 3\n"; }
-
-if (seek($TST,0,0)) { print "ok 4\n"; } else { print "not ok 4\n"; }
-
-if (eof) { print "not ok 5\n"; } else { print "ok 5\n"; }
-
-if ($firstline eq <tst>) { print "ok 6\n"; } else { print "not ok 6\n"; }
-
-if ($secondpos == tell) { print "ok 7\n"; } else { print "not ok 7\n"; }
-
-if (seek(tst,0,1)) { print "ok 8\n"; } else { print "not ok 8\n"; }
-
-if (eof($TST)) { print "not ok 9\n"; } else { print "ok 9\n"; }
-
-if ($secondpos == tell) { print "ok 10\n"; } else { print "not ok 10\n"; }
-
-if (seek(tst,0,2)) { print "ok 11\n"; } else { print "not ok 11\n"; }
-
-if ($lastpos == tell) { print "ok 12\n"; } else { print "not ok 12\n"; }
-
-unless (eof) { print "not ok 13\n"; } else { print "ok 13\n"; }
diff --git a/gnu/usr.bin/perl/perl/t/lib/big.t b/gnu/usr.bin/perl/perl/t/lib/big.t
deleted file mode 100755
index 9b27a5f..0000000
--- a/gnu/usr.bin/perl/perl/t/lib/big.t
+++ /dev/null
@@ -1,280 +0,0 @@
-#!./perl
-require "../../lib/bigint.pl";
-
-$test = 0;
-$| = 1;
-print "1..246\n";
-while (<DATA>) {
- chop;
- if (/^&/) {
- $f = $_;
- } else {
- ++$test;
- @args = split(/:/,$_,99);
- $ans = pop(@args);
- $try = "$f('" . join("','", @args) . "');";
- if (($ans1 = eval($try)) eq $ans) {
- print "ok $test\n";
- } else {
- print "not ok $test\n";
- print "# '$try' expected: '$ans' got: '$ans1'\n";
- }
- }
-}
-__END__
-&bnorm
-abc:NaN
- 1 a:NaN
-1bcd2:NaN
-11111b:NaN
-+1z:NaN
--1z:NaN
-0:+0
-+0:+0
-+00:+0
-+0 0 0:+0
-000000 0000000 00000:+0
--0:+0
--0000:+0
-+1:+1
-+01:+1
-+001:+1
-+00000100000:+100000
-123456789:+123456789
--1:-1
--01:-1
--001:-1
--123456789:-123456789
--00000100000:-100000
-&bneg
-abd:NaN
-+0:+0
-+1:-1
--1:+1
-+123456789:-123456789
--123456789:+123456789
-&babs
-abc:NaN
-+0:+0
-+1:+1
--1:+1
-+123456789:+123456789
--123456789:+123456789
-&bcmp
-abc:abc:
-abc:+0:
-+0:abc:
-+0:+0:0
--1:+0:-1
-+0:-1:1
-+1:+0:1
-+0:+1:-1
--1:+1:-1
-+1:-1:1
--1:-1:0
-+1:+1:0
-+123:+123:0
-+123:+12:1
-+12:+123:-1
--123:-123:0
--123:-12:-1
--12:-123:1
-+123:+124:-1
-+124:+123:1
--123:-124:1
--124:-123:-1
-&badd
-abc:abc:NaN
-abc:+0:NaN
-+0:abc:NaN
-+0:+0:+0
-+1:+0:+1
-+0:+1:+1
-+1:+1:+2
--1:+0:-1
-+0:-1:-1
--1:-1:-2
--1:+1:+0
-+1:-1:+0
-+9:+1:+10
-+99:+1:+100
-+999:+1:+1000
-+9999:+1:+10000
-+99999:+1:+100000
-+999999:+1:+1000000
-+9999999:+1:+10000000
-+99999999:+1:+100000000
-+999999999:+1:+1000000000
-+9999999999:+1:+10000000000
-+99999999999:+1:+100000000000
-+10:-1:+9
-+100:-1:+99
-+1000:-1:+999
-+10000:-1:+9999
-+100000:-1:+99999
-+1000000:-1:+999999
-+10000000:-1:+9999999
-+100000000:-1:+99999999
-+1000000000:-1:+999999999
-+10000000000:-1:+9999999999
-+123456789:+987654321:+1111111110
--123456789:+987654321:+864197532
--123456789:-987654321:-1111111110
-+123456789:-987654321:-864197532
-&bsub
-abc:abc:NaN
-abc:+0:NaN
-+0:abc:NaN
-+0:+0:+0
-+1:+0:+1
-+0:+1:-1
-+1:+1:+0
--1:+0:-1
-+0:-1:+1
--1:-1:+0
--1:+1:-2
-+1:-1:+2
-+9:+1:+8
-+99:+1:+98
-+999:+1:+998
-+9999:+1:+9998
-+99999:+1:+99998
-+999999:+1:+999998
-+9999999:+1:+9999998
-+99999999:+1:+99999998
-+999999999:+1:+999999998
-+9999999999:+1:+9999999998
-+99999999999:+1:+99999999998
-+10:-1:+11
-+100:-1:+101
-+1000:-1:+1001
-+10000:-1:+10001
-+100000:-1:+100001
-+1000000:-1:+1000001
-+10000000:-1:+10000001
-+100000000:-1:+100000001
-+1000000000:-1:+1000000001
-+10000000000:-1:+10000000001
-+123456789:+987654321:-864197532
--123456789:+987654321:-1111111110
--123456789:-987654321:+864197532
-+123456789:-987654321:+1111111110
-&bmul
-abc:abc:NaN
-abc:+0:NaN
-+0:abc:NaN
-+0:+0:+0
-+0:+1:+0
-+1:+0:+0
-+0:-1:+0
--1:+0:+0
-+123456789123456789:+0:+0
-+0:+123456789123456789:+0
--1:-1:+1
--1:+1:-1
-+1:-1:-1
-+1:+1:+1
-+2:+3:+6
--2:+3:-6
-+2:-3:-6
--2:-3:+6
-+111:+111:+12321
-+10101:+10101:+102030201
-+1001001:+1001001:+1002003002001
-+100010001:+100010001:+10002000300020001
-+10000100001:+10000100001:+100002000030000200001
-+11111111111:+9:+99999999999
-+22222222222:+9:+199999999998
-+33333333333:+9:+299999999997
-+44444444444:+9:+399999999996
-+55555555555:+9:+499999999995
-+66666666666:+9:+599999999994
-+77777777777:+9:+699999999993
-+88888888888:+9:+799999999992
-+99999999999:+9:+899999999991
-&bdiv
-abc:abc:NaN
-abc:+1:abc:NaN
-+1:abc:NaN
-+0:+0:NaN
-+0:+1:+0
-+1:+0:NaN
-+0:-1:+0
--1:+0:NaN
-+1:+1:+1
--1:-1:+1
-+1:-1:-1
--1:+1:-1
-+1:+2:+0
-+2:+1:+2
-+1000000000:+9:+111111111
-+2000000000:+9:+222222222
-+3000000000:+9:+333333333
-+4000000000:+9:+444444444
-+5000000000:+9:+555555555
-+6000000000:+9:+666666666
-+7000000000:+9:+777777777
-+8000000000:+9:+888888888
-+9000000000:+9:+1000000000
-+35500000:+113:+314159
-+71000000:+226:+314159
-+106500000:+339:+314159
-+1000000000:+3:+333333333
-+10:+5:+2
-+100:+4:+25
-+1000:+8:+125
-+10000:+16:+625
-+999999999999:+9:+111111111111
-+999999999999:+99:+10101010101
-+999999999999:+999:+1001001001
-+999999999999:+9999:+100010001
-+999999999999999:+99999:+10000100001
-&bmod
-abc:abc:NaN
-abc:+1:abc:NaN
-+1:abc:NaN
-+0:+0:NaN
-+0:+1:+0
-+1:+0:NaN
-+0:-1:+0
--1:+0:NaN
-+1:+1:+0
--1:-1:+0
-+1:-1:+0
--1:+1:+0
-+1:+2:+1
-+2:+1:+0
-+1000000000:+9:+1
-+2000000000:+9:+2
-+3000000000:+9:+3
-+4000000000:+9:+4
-+5000000000:+9:+5
-+6000000000:+9:+6
-+7000000000:+9:+7
-+8000000000:+9:+8
-+9000000000:+9:+0
-+35500000:+113:+33
-+71000000:+226:+66
-+106500000:+339:+99
-+1000000000:+3:+1
-+10:+5:+0
-+100:+4:+0
-+1000:+8:+0
-+10000:+16:+0
-+999999999999:+9:+0
-+999999999999:+99:+0
-+999999999999:+999:+0
-+999999999999:+9999:+0
-+999999999999999:+99999:+0
-&bgcd
-abc:abc:NaN
-abc:+0:NaN
-+0:abc:NaN
-+0:+0:+0
-+0:+1:+1
-+1:+0:+1
-+1:+1:+1
-+2:+3:+1
-+3:+2:+1
-+100:+625:+25
-+4096:+81:+1
diff --git a/gnu/usr.bin/perl/perl/t/op/append.t b/gnu/usr.bin/perl/perl/t/op/append.t
deleted file mode 100755
index 92c6f48..0000000
--- a/gnu/usr.bin/perl/perl/t/op/append.t
+++ /dev/null
@@ -1,21 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/append.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..3\n";
-
-$a = 'ab' . 'c'; # compile time
-$b = 'def';
-
-$c = $a . $b;
-print "#1\t:$c: eq :abcdef:\n";
-if ($c eq 'abcdef') {print "ok 1\n";} else {print "not ok 1\n";}
-
-$c .= 'xyz';
-print "#2\t:$c: eq :abcdefxyz:\n";
-if ($c eq 'abcdefxyz') {print "ok 2\n";} else {print "not ok 2\n";}
-
-$_ = $a;
-$_ .= $b;
-print "#3\t:$_: eq :abcdef:\n";
-if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/array.t b/gnu/usr.bin/perl/perl/t/op/array.t
deleted file mode 100755
index 39e05e3..0000000
--- a/gnu/usr.bin/perl/perl/t/op/array.t
+++ /dev/null
@@ -1,120 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/array.t,v 1.1.1.1 1993/08/23 21:30:02 nate Exp $
-
-print "1..36\n";
-
-@ary = (1,2,3,4,5);
-if (join('',@ary) eq '12345') {print "ok 1\n";} else {print "not ok 1\n";}
-
-$tmp = $ary[$#ary]; --$#ary;
-if ($tmp == 5) {print "ok 2\n";} else {print "not ok 2\n";}
-if ($#ary == 3) {print "ok 3\n";} else {print "not ok 3\n";}
-if (join('',@ary) eq '1234') {print "ok 4\n";} else {print "not ok 4\n";}
-
-$[ = 1;
-@ary = (1,2,3,4,5);
-if (join('',@ary) eq '12345') {print "ok 5\n";} else {print "not ok 5\n";}
-
-$tmp = $ary[$#ary]; --$#ary;
-if ($tmp == 5) {print "ok 6\n";} else {print "not ok 6\n";}
-if ($#ary == 4) {print "ok 7\n";} else {print "not ok 7\n";}
-if (join('',@ary) eq '1234') {print "ok 8\n";} else {print "not ok 8\n";}
-
-if ($ary[5] eq '') {print "ok 9\n";} else {print "not ok 9\n";}
-
-$#ary += 1; # see if we can recover element 5
-if ($#ary == 5) {print "ok 10\n";} else {print "not ok 10\n";}
-if ($ary[5] == 5) {print "ok 11\n";} else {print "not ok 11\n";}
-
-$[ = 0;
-@foo = ();
-$r = join(',', $#foo, @foo);
-if ($r eq "-1") {print "ok 12\n";} else {print "not ok 12 $r\n";}
-$foo[0] = '0';
-$r = join(',', $#foo, @foo);
-if ($r eq "0,0") {print "ok 13\n";} else {print "not ok 13 $r\n";}
-$foo[2] = '2';
-$r = join(',', $#foo, @foo);
-if ($r eq "2,0,,2") {print "ok 14\n";} else {print "not ok 14 $r\n";}
-@bar = ();
-$bar[0] = '0';
-$bar[1] = '1';
-$r = join(',', $#bar, @bar);
-if ($r eq "1,0,1") {print "ok 15\n";} else {print "not ok 15 $r\n";}
-@bar = ();
-$r = join(',', $#bar, @bar);
-if ($r eq "-1") {print "ok 16\n";} else {print "not ok 16 $r\n";}
-$bar[0] = '0';
-$r = join(',', $#bar, @bar);
-if ($r eq "0,0") {print "ok 17\n";} else {print "not ok 17 $r\n";}
-$bar[2] = '2';
-$r = join(',', $#bar, @bar);
-if ($r eq "2,0,,2") {print "ok 18\n";} else {print "not ok 18 $r\n";}
-reset 'b';
-@bar = ();
-$bar[0] = '0';
-$r = join(',', $#bar, @bar);
-if ($r eq "0,0") {print "ok 19\n";} else {print "not ok 19 $r\n";}
-$bar[2] = '2';
-$r = join(',', $#bar, @bar);
-if ($r eq "2,0,,2") {print "ok 20\n";} else {print "not ok 20 $r\n";}
-
-$foo = 'now is the time';
-if (($F1,$F2,$Etc) = ($foo =~ /^(\S+)\s+(\S+)\s*(.*)/)) {
- if ($F1 eq 'now' && $F2 eq 'is' && $Etc eq 'the time') {
- print "ok 21\n";
- }
- else {
- print "not ok 21\n";
- }
-}
-else {
- print "not ok 21\n";
-}
-
-$foo = 'lskjdf';
-if ($cnt = (($F1,$F2,$Etc) = ($foo =~ /^(\S+)\s+(\S+)\s*(.*)/))) {
- print "not ok 22 $cnt $F1:$F2:$Etc\n";
-}
-else {
- print "ok 22\n";
-}
-
-%foo = ('blurfl','dyick','foo','bar','etc.','etc.');
-%bar = %foo;
-print $bar{'foo'} eq 'bar' ? "ok 23\n" : "not ok 23\n";
-%bar = ();
-print $bar{'foo'} eq '' ? "ok 24\n" : "not ok 24\n";
-(%bar,$a,$b) = (%foo,'how','now');
-print $bar{'foo'} eq 'bar' ? "ok 25\n" : "not ok 25\n";
-print $bar{'how'} eq 'now' ? "ok 26\n" : "not ok 26\n";
-@bar{keys %foo} = values %foo;
-print $bar{'foo'} eq 'bar' ? "ok 27\n" : "not ok 27\n";
-print $bar{'how'} eq 'now' ? "ok 28\n" : "not ok 28\n";
-
-@foo = grep(/e/,split(' ','now is the time for all good men to come to'));
-print join(' ',@foo) eq 'the time men come' ? "ok 29\n" : "not ok 29\n";
-
-@foo = grep(!/e/,split(' ','now is the time for all good men to come to'));
-print join(' ',@foo) eq 'now is for all good to to' ? "ok 30\n" : "not ok 30\n";
-
-$foo = join('',('a','b','c','d','e','f')[0..5]);
-print $foo eq 'abcdef' ? "ok 31\n" : "not ok 31\n";
-
-$foo = join('',('a','b','c','d','e','f')[0..1]);
-print $foo eq 'ab' ? "ok 32\n" : "not ok 32\n";
-
-$foo = join('',('a','b','c','d','e','f')[6]);
-print $foo eq '' ? "ok 33\n" : "not ok 33\n";
-
-@foo = ('a','b','c','d','e','f')[0,2,4];
-@bar = ('a','b','c','d','e','f')[1,3,5];
-$foo = join('',(@foo,@bar)[0..5]);
-print $foo eq 'acebdf' ? "ok 34\n" : "not ok 34\n";
-
-$foo = ('a','b','c','d','e','f')[0,2,4];
-print $foo eq 'e' ? "ok 35\n" : "not ok 35\n";
-
-$foo = ('a','b','c','d','e','f')[1];
-print $foo eq 'b' ? "ok 36\n" : "not ok 36\n";
diff --git a/gnu/usr.bin/perl/perl/t/op/auto.t b/gnu/usr.bin/perl/perl/t/op/auto.t
deleted file mode 100755
index 5301f93..0000000
--- a/gnu/usr.bin/perl/perl/t/op/auto.t
+++ /dev/null
@@ -1,48 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/auto.t,v 1.1.1.1 1993/08/23 21:30:01 nate Exp $
-
-print "1..34\n";
-
-$x = 10000;
-if (0 + ++$x - 1 == 10000) { print "ok 1\n";} else {print "not ok 1\n";}
-if (0 + $x-- - 1 == 10000) { print "ok 2\n";} else {print "not ok 2\n";}
-if (1 * $x == 10000) { print "ok 3\n";} else {print "not ok 3\n";}
-if (0 + $x-- - 0 == 10000) { print "ok 4\n";} else {print "not ok 4\n";}
-if (1 + $x == 10000) { print "ok 5\n";} else {print "not ok 5\n";}
-if (1 + $x++ == 10000) { print "ok 6\n";} else {print "not ok 6\n";}
-if (0 + $x == 10000) { print "ok 7\n";} else {print "not ok 7\n";}
-if (0 + --$x + 1 == 10000) { print "ok 8\n";} else {print "not ok 8\n";}
-if (0 + ++$x + 0 == 10000) { print "ok 9\n";} else {print "not ok 9\n";}
-if ($x == 10000) { print "ok 10\n";} else {print "not ok 10\n";}
-
-$x[0] = 10000;
-if (0 + ++$x[0] - 1 == 10000) { print "ok 11\n";} else {print "not ok 11\n";}
-if (0 + $x[0]-- - 1 == 10000) { print "ok 12\n";} else {print "not ok 12\n";}
-if (1 * $x[0] == 10000) { print "ok 13\n";} else {print "not ok 13\n";}
-if (0 + $x[0]-- - 0 == 10000) { print "ok 14\n";} else {print "not ok 14\n";}
-if (1 + $x[0] == 10000) { print "ok 15\n";} else {print "not ok 15\n";}
-if (1 + $x[0]++ == 10000) { print "ok 16\n";} else {print "not ok 16\n";}
-if (0 + $x[0] == 10000) { print "ok 17\n";} else {print "not ok 17\n";}
-if (0 + --$x[0] + 1 == 10000) { print "ok 18\n";} else {print "not ok 18\n";}
-if (0 + ++$x[0] + 0 == 10000) { print "ok 19\n";} else {print "not ok 19\n";}
-if ($x[0] == 10000) { print "ok 20\n";} else {print "not ok 20\n";}
-
-$x{0} = 10000;
-if (0 + ++$x{0} - 1 == 10000) { print "ok 21\n";} else {print "not ok 21\n";}
-if (0 + $x{0}-- - 1 == 10000) { print "ok 22\n";} else {print "not ok 22\n";}
-if (1 * $x{0} == 10000) { print "ok 23\n";} else {print "not ok 23\n";}
-if (0 + $x{0}-- - 0 == 10000) { print "ok 24\n";} else {print "not ok 24\n";}
-if (1 + $x{0} == 10000) { print "ok 25\n";} else {print "not ok 25\n";}
-if (1 + $x{0}++ == 10000) { print "ok 26\n";} else {print "not ok 26\n";}
-if (0 + $x{0} == 10000) { print "ok 27\n";} else {print "not ok 27\n";}
-if (0 + --$x{0} + 1 == 10000) { print "ok 28\n";} else {print "not ok 28\n";}
-if (0 + ++$x{0} + 0 == 10000) { print "ok 29\n";} else {print "not ok 29\n";}
-if ($x{0} == 10000) { print "ok 30\n";} else {print "not ok 30\n";}
-
-# test magical autoincrement
-
-if (++($foo = '99') eq '100') {print "ok 31\n";} else {print "not ok 31\n";}
-if (++($foo = 'a0') eq 'a1') {print "ok 32\n";} else {print "not ok 32\n";}
-if (++($foo = 'Az') eq 'Ba') {print "ok 33\n";} else {print "not ok 33\n";}
-if (++($foo = 'zz') eq 'aaa') {print "ok 34\n";} else {print "not ok 34\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/chop.t b/gnu/usr.bin/perl/perl/t/op/chop.t
deleted file mode 100755
index d691d73..0000000
--- a/gnu/usr.bin/perl/perl/t/op/chop.t
+++ /dev/null
@@ -1,30 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/chop.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..4\n";
-
-# optimized
-
-$_ = 'abc';
-$c = do foo();
-if ($c . $_ eq 'cab') {print "ok 1\n";} else {print "not ok 1 $c$_\n";}
-
-# unoptimized
-
-$_ = 'abc';
-$c = chop($_);
-if ($c . $_ eq 'cab') {print "ok 2\n";} else {print "not ok 2\n";}
-
-sub foo {
- chop;
-}
-
-@foo = ("hi \n","there\n","!\n");
-@bar = @foo;
-chop(@bar);
-print join('',@bar) eq 'hi there!' ? "ok 3\n" : "not ok 3\n";
-
-$foo = "\n";
-chop($foo,@foo);
-print join('',$foo,@foo) eq 'hi there!' ? "ok 4\n" : "not ok 4\n";
diff --git a/gnu/usr.bin/perl/perl/t/op/cond.t b/gnu/usr.bin/perl/perl/t/op/cond.t
deleted file mode 100755
index 054a5ff..0000000
--- a/gnu/usr.bin/perl/perl/t/op/cond.t
+++ /dev/null
@@ -1,12 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/cond.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..4\n";
-
-print 1 ? "ok 1\n" : "not ok 1\n"; # compile time
-print 0 ? "not ok 2\n" : "ok 2\n";
-
-$x = 1;
-print $x ? "ok 3\n" : "not ok 3\n"; # run time
-print !$x ? "not ok 4\n" : "ok 4\n";
diff --git a/gnu/usr.bin/perl/perl/t/op/dbm.t b/gnu/usr.bin/perl/perl/t/op/dbm.t
deleted file mode 100755
index 23d4d98..0000000
--- a/gnu/usr.bin/perl/perl/t/op/dbm.t
+++ /dev/null
@@ -1,106 +0,0 @@
-#!./perl
-
-# $RCSfile: dbm.t,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:02 $
-
-if (!-r '/usr/include/dbm.h' && !-r '/usr/include/ndbm.h'
- && !-r '/usr/include/rpcsvc/dbm.h') {
- print "1..0\n";
- exit;
-}
-
-print "1..12\n";
-
-unlink <Op.dbmx.*>;
-umask(0);
-print (dbmopen(h,'Op.dbmx',0640) ? "ok 1\n" : "not ok 1\n");
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('Op.dbmx.pag');
-print (($mode & 0777) == 0640 ? "ok 2\n" : "not ok 2\n");
-while (($key,$value) = each(h)) {
- $i++;
-}
-print (!$i ? "ok 3\n" : "not ok 3\n");
-
-$h{'goner1'} = 'snork';
-
-$h{'abc'} = 'ABC';
-$h{'def'} = 'DEF';
-$h{'jkl','mno'} = "JKL\034MNO";
-$h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
-$h{'a'} = 'A';
-$h{'b'} = 'B';
-$h{'c'} = 'C';
-$h{'d'} = 'D';
-$h{'e'} = 'E';
-$h{'f'} = 'F';
-$h{'g'} = 'G';
-$h{'h'} = 'H';
-$h{'i'} = 'I';
-
-$h{'goner2'} = 'snork';
-delete $h{'goner2'};
-
-dbmclose(h);
-print (dbmopen(h,'Op.dbmx',0640) ? "ok 4\n" : "not ok 4\n");
-
-$h{'j'} = 'J';
-$h{'k'} = 'K';
-$h{'l'} = 'L';
-$h{'m'} = 'M';
-$h{'n'} = 'N';
-$h{'o'} = 'O';
-$h{'p'} = 'P';
-$h{'q'} = 'Q';
-$h{'r'} = 'R';
-$h{'s'} = 'S';
-$h{'t'} = 'T';
-$h{'u'} = 'U';
-$h{'v'} = 'V';
-$h{'w'} = 'W';
-$h{'x'} = 'X';
-$h{'y'} = 'Y';
-$h{'z'} = 'Z';
-
-$h{'goner3'} = 'snork';
-
-delete $h{'goner1'};
-delete $h{'goner3'};
-
-@keys = keys(%h);
-@values = values(%h);
-
-if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
-
-while (($key,$value) = each(h)) {
- if ($key eq $keys[$i] && $value eq $values[$i] && $key gt $value) {
- $key =~ y/a-z/A-Z/;
- $i++ if $key eq $value;
- }
-}
-
-if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
-
-@keys = ('blurfl', keys(h), 'dyick');
-if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
-
-$h{'foo'} = '';
-$h{''} = 'bar';
-
-# check cache overflow and numeric keys and contents
-$ok = 1;
-for ($i = 1; $i < 200; $i++) { $h{$i + 0} = $i + 0; }
-for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; }
-print ($ok ? "ok 8\n" : "not ok 8\n");
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('Op.dbmx.pag');
-print ($size > 0 ? "ok 9\n" : "not ok 9\n");
-
-@h{0..200} = 200..400;
-@foo = @h{0..200};
-print join(':',200..400) eq join(':',@foo) ? "ok 10\n" : "not ok 10\n";
-
-print ($h{'foo'} eq '' ? "ok 11\n" : "not ok 11\n");
-print ($h{''} eq 'bar' ? "ok 12\n" : "not ok 12\n");
-
-unlink 'Op.dbmx.dir', 'Op.dbmx.pag';
diff --git a/gnu/usr.bin/perl/perl/t/op/delete.t b/gnu/usr.bin/perl/perl/t/op/delete.t
deleted file mode 100755
index e4e1fea..0000000
--- a/gnu/usr.bin/perl/perl/t/op/delete.t
+++ /dev/null
@@ -1,29 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/delete.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-print "1..6\n";
-
-$foo{1} = 'a';
-$foo{2} = 'b';
-$foo{3} = 'c';
-
-$foo = delete $foo{2};
-
-if ($foo eq 'b') {print "ok 1\n";} else {print "not ok 1 $foo\n";}
-if ($foo{2} eq '') {print "ok 2\n";} else {print "not ok 2 $foo{2}\n";}
-if ($foo{1} eq 'a') {print "ok 3\n";} else {print "not ok 3\n";}
-if ($foo{3} eq 'c') {print "ok 4\n";} else {print "not ok 4\n";}
-
-$foo = join('',values(foo));
-if ($foo eq 'ac' || $foo eq 'ca') {print "ok 5\n";} else {print "not ok 5\n";}
-
-foreach $key (keys foo) {
- delete $foo{$key};
-}
-
-$foo{'foo'} = 'x';
-$foo{'bar'} = 'y';
-
-$foo = join('',values(foo));
-if ($foo eq 'xy' || $foo eq 'yx') {print "ok 6\n";} else {print "not ok 6\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/do.t b/gnu/usr.bin/perl/perl/t/op/do.t
deleted file mode 100755
index 370012c..0000000
--- a/gnu/usr.bin/perl/perl/t/op/do.t
+++ /dev/null
@@ -1,44 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/do.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-sub foo1
-{
- print $_[0];
- 'value';
-}
-
-sub foo2
-{
- shift(_);
- print $_[0];
- $x = 'value';
- $x;
-}
-
-print "1..15\n";
-
-$_[0] = "not ok 1\n";
-$result = do foo1("ok 1\n");
-print "#2\t:$result: eq :value:\n";
-if ($result EQ 'value') { print "ok 2\n"; } else { print "not ok 2\n"; }
-if ($_[0] EQ "not ok 1\n") { print "ok 3\n"; } else { print "not ok 3\n"; }
-
-$_[0] = "not ok 4\n";
-$result = do foo2("not ok 4\n","ok 4\n","not ok 4\n");
-print "#5\t:$result: eq :value:\n";
-if ($result EQ 'value') { print "ok 5\n"; } else { print "not ok 5\n"; }
-if ($_[0] EQ "not ok 4\n") { print "ok 6\n"; } else { print "not ok 6\n"; }
-
-$result = do{print "ok 7\n"; 'value';};
-print "#8\t:$result: eq :value:\n";
-if ($result EQ 'value') { print "ok 8\n"; } else { print "not ok 8\n"; }
-
-sub blather {
- print @_;
-}
-
-do blather("ok 9\n","ok 10\n");
-@x = ("ok 11\n", "ok 12\n");
-@y = ("ok 14\n", "ok 15\n");
-do blather(@x,"ok 13\n",@y);
diff --git a/gnu/usr.bin/perl/perl/t/op/each.t b/gnu/usr.bin/perl/perl/t/op/each.t
deleted file mode 100755
index 532d1b0..0000000
--- a/gnu/usr.bin/perl/perl/t/op/each.t
+++ /dev/null
@@ -1,53 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/each.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-print "1..3\n";
-
-$h{'abc'} = 'ABC';
-$h{'def'} = 'DEF';
-$h{'jkl','mno'} = "JKL\034MNO";
-$h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
-$h{'a'} = 'A';
-$h{'b'} = 'B';
-$h{'c'} = 'C';
-$h{'d'} = 'D';
-$h{'e'} = 'E';
-$h{'f'} = 'F';
-$h{'g'} = 'G';
-$h{'h'} = 'H';
-$h{'i'} = 'I';
-$h{'j'} = 'J';
-$h{'k'} = 'K';
-$h{'l'} = 'L';
-$h{'m'} = 'M';
-$h{'n'} = 'N';
-$h{'o'} = 'O';
-$h{'p'} = 'P';
-$h{'q'} = 'Q';
-$h{'r'} = 'R';
-$h{'s'} = 'S';
-$h{'t'} = 'T';
-$h{'u'} = 'U';
-$h{'v'} = 'V';
-$h{'w'} = 'W';
-$h{'x'} = 'X';
-$h{'y'} = 'Y';
-$h{'z'} = 'Z';
-
-@keys = keys %h;
-@values = values %h;
-
-if ($#keys == 29 && $#values == 29) {print "ok 1\n";} else {print "not ok 1\n";}
-
-while (($key,$value) = each(h)) {
- if ($key eq $keys[$i] && $value eq $values[$i] && $key gt $value) {
- $key =~ y/a-z/A-Z/;
- $i++ if $key eq $value;
- }
-}
-
-if ($i == 30) {print "ok 2\n";} else {print "not ok 2\n";}
-
-@keys = ('blurfl', keys(%h), 'dyick');
-if ($#keys == 31) {print "ok 3\n";} else {print "not ok 3\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/eval.t b/gnu/usr.bin/perl/perl/t/op/eval.t
deleted file mode 100755
index b21b44d..0000000
--- a/gnu/usr.bin/perl/perl/t/op/eval.t
+++ /dev/null
@@ -1,57 +0,0 @@
-#!./perl
-
-# $RCSfile: eval.t,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:02 $
-
-print "1..16\n";
-
-eval 'print "ok 1\n";';
-
-if ($@ eq '') {print "ok 2\n";} else {print "not ok 2\n";}
-
-eval "\$foo\n = # this is a comment\n'ok 3';";
-print $foo,"\n";
-
-eval "\$foo\n = # this is a comment\n'ok 4\n';";
-print $foo;
-
-print eval '
-$foo ='; # this tests for a call through yyerror()
-if ($@ =~ /line 2/) {print "ok 5\n";} else {print "not ok 5\n";}
-
-print eval '$foo = /'; # this tests for a call through fatal()
-if ($@ =~ /Search/) {print "ok 6\n";} else {print "not ok 6\n";}
-
-print eval '"ok 7\n";';
-
-# calculate a factorial with recursive evals
-
-$foo = 5;
-$fact = 'if ($foo <= 1) {1;} else {push(@x,$foo--); (eval $fact) * pop(@x);}';
-$ans = eval $fact;
-if ($ans == 120) {print "ok 8\n";} else {print "not ok 8\n";}
-
-$foo = 5;
-$fact = 'local($foo)=$foo; $foo <= 1 ? 1 : $foo-- * (eval $fact);';
-$ans = eval $fact;
-if ($ans == 120) {print "ok 9\n";} else {print "not ok 9 $ans\n";}
-
-open(try,'>Op.eval');
-print try 'print "ok 10\n"; unlink "Op.eval";',"\n";
-close try;
-
-do 'Op.eval'; print $@;
-
-# Test the singlequoted eval optimizer
-
-$i = 11;
-for (1..3) {
- eval 'print "ok ", $i++, "\n"';
-}
-
-eval {
- print "ok 14\n";
- die "ok 16\n";
- 1;
-} || print "ok 15\n$@";
-
-
diff --git a/gnu/usr.bin/perl/perl/t/op/exec.t b/gnu/usr.bin/perl/perl/t/op/exec.t
deleted file mode 100755
index 69909f7..0000000
--- a/gnu/usr.bin/perl/perl/t/op/exec.t
+++ /dev/null
@@ -1,21 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/exec.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-$| = 1; # flush stdout
-print "1..8\n";
-
-print "not ok 1\n" if system "echo ok \\1"; # shell interpreted
-print "not ok 2\n" if system "echo ok 2"; # split and directly called
-print "not ok 3\n" if system "echo", "ok", "3"; # directly called
-
-if (system "true") {print "not ok 4\n";} else {print "ok 4\n";}
-
-if ((system "/bin/sh -c 'exit 1'") != 256) { print "not "; }
-print "ok 5\n";
-
-if ((system "lskdfj") == 255 << 8) {print "ok 6\n";} else {print "not ok 6\n";}
-
-unless (exec "lskdjfalksdjfdjfkls") {print "ok 7\n";} else {print "not ok 7\n";}
-
-exec "echo","ok","8";
diff --git a/gnu/usr.bin/perl/perl/t/op/exp.t b/gnu/usr.bin/perl/perl/t/op/exp.t
deleted file mode 100755
index 2195e54..0000000
--- a/gnu/usr.bin/perl/perl/t/op/exp.t
+++ /dev/null
@@ -1,27 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/exp.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-print "1..6\n";
-
-# compile time evaluation
-
-$s = sqrt(2);
-if (substr($s,0,5) eq '1.414') {print "ok 1\n";} else {print "not ok 1\n";}
-
-$s = exp(1);
-if (substr($s,0,7) eq '2.71828') {print "ok 2\n";} else {print "not ok 2\n";}
-
-if (exp(log(1)) == 1) {print "ok 3\n";} else {print "not ok 3\n";}
-
-# run time evaluation
-
-$x1 = 1;
-$x2 = 2;
-$s = sqrt($x2);
-if (substr($s,0,5) eq '1.414') {print "ok 4\n";} else {print "not ok 4\n";}
-
-$s = exp($x1);
-if (substr($s,0,7) eq '2.71828') {print "ok 5\n";} else {print "not ok 5\n";}
-
-if (exp(log($x1)) == 1) {print "ok 6\n";} else {print "not ok 6\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/flip.t b/gnu/usr.bin/perl/perl/t/op/flip.t
deleted file mode 100755
index 74ba508..0000000
--- a/gnu/usr.bin/perl/perl/t/op/flip.t
+++ /dev/null
@@ -1,26 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/flip.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..8\n";
-
-@a = (1,2,3,4,5,6,7,8,9,10,11,12);
-
-while ($_ = shift(a)) {
- if ($x = /4/../8/) { $z = $x; print "ok ", $x + 0, "\n"; }
- $y .= /1/../2/;
-}
-
-if ($z eq '5E0') {print "ok 6\n";} else {print "not ok 6\n";}
-
-if ($y eq '12E0123E0') {print "ok 7\n";} else {print "not ok 7\n";}
-
-@a = ('a','b','c','d','e','f','g');
-
-open(of,'../Makefile');
-while (<of>) {
- (3 .. 5) && $foo .= $_;
-}
-$x = ($foo =~ y/\n/\n/);
-
-if ($x eq 3) {print "ok 8\n";} else {print "not ok 8 $x:$foo:\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/fork.t b/gnu/usr.bin/perl/perl/t/op/fork.t
deleted file mode 100755
index 10b54a2..0000000
--- a/gnu/usr.bin/perl/perl/t/op/fork.t
+++ /dev/null
@@ -1,16 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/fork.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-$| = 1;
-print "1..2\n";
-
-if ($cid = fork) {
- sleep 2;
- if ($result = (kill 9, $cid)) {print "ok 2\n";} else {print "not ok 2 $result\n";}
-}
-else {
- $| = 1;
- print "ok 1\n";
- sleep 10;
-}
diff --git a/gnu/usr.bin/perl/perl/t/op/glob.t b/gnu/usr.bin/perl/perl/t/op/glob.t
deleted file mode 100755
index 68b0844..0000000
--- a/gnu/usr.bin/perl/perl/t/op/glob.t
+++ /dev/null
@@ -1,22 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/glob.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..4\n";
-
-@ops = <op/*>;
-$list = join(' ',@ops);
-
-chop($otherway = `echo op/*`);
-
-print $list eq $otherway ? "ok 1\n" : "not ok 1\n$list\n$otherway\n";
-
-print $/ eq "\n" ? "ok 2\n" : "not ok 2\n";
-
-while (<jskdfjskdfj* op/* jskdjfjkosvk*>) {
- $not = "not " unless $_ eq shift @ops;
- $not = "not at all " if $/ eq "\0";
-}
-print "${not}ok 3\n";
-
-print $/ eq "\n" ? "ok 4\n" : "not ok 4\n";
diff --git a/gnu/usr.bin/perl/perl/t/op/goto.t b/gnu/usr.bin/perl/perl/t/op/goto.t
deleted file mode 100755
index 44ef343..0000000
--- a/gnu/usr.bin/perl/perl/t/op/goto.t
+++ /dev/null
@@ -1,33 +0,0 @@
-#!./perl
-
-# $RCSfile: goto.t,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:03 $
-
-print "1..3\n";
-
-while (0) {
- $foo = 1;
- label1:
- $foo = 2;
- goto label2;
-} continue {
- $foo = 0;
- goto label4;
- label3:
- $foo = 4;
- goto label4;
-}
-goto label1;
-
-$foo = 3;
-
-label2:
-print "#1\t:$foo: == 2\n";
-if ($foo == 2) {print "ok 1\n";} else {print "not ok 1\n";}
-goto label3;
-
-label4:
-print "#2\t:$foo: == 4\n";
-if ($foo == 4) {print "ok 2\n";} else {print "not ok 2\n";}
-
-$x = `./perl -e 'goto foo;' 2>&1`;
-if ($x =~ /label/) {print "ok 3\n";} else {print "not ok 3\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/groups.t b/gnu/usr.bin/perl/perl/t/op/groups.t
deleted file mode 100755
index e1520cc..0000000
--- a/gnu/usr.bin/perl/perl/t/op/groups.t
+++ /dev/null
@@ -1,47 +0,0 @@
-#!./perl
-
-if (! -x '/usr/ucb/groups') {
- print "1..0\n";
- exit 0;
-}
-
-print "1..2\n";
-
-$pwgid = $( + 0;
-($pwgnam) = getgrgid($pwgid);
-@basegroup{$pwgid,$pwgnam} = (1,1);
-
-$seen{$pwgid}++;
-
-for (split(' ', $()) {
- next if $seen{$_}++;
- ($group) = getgrgid($_);
- if (defined $group) {
- push(@gr, $group);
- }
- else {
- push(@gr, $_);
- }
-}
-
-$gr1 = join(' ', sort @gr);
-
-$gr2 = join(' ', grep(!$basegroup{$_}, sort split(' ',`/usr/ucb/groups`)));
-
-if ($gr1 eq $gr2) {
- print "ok 1\n";
-}
-else {
- print "#gr1 is <$gr1>\n";
- print "#gr2 is <$gr2>\n";
- print "not ok 1\n";
-}
-
-# multiple 0's indicate GROUPSTYPE is currently long but should be short
-
-if ($pwgid == 0 || $seen{0} < 2) {
- print "ok 2\n";
-}
-else {
- print "not ok 2 (groupstype should be type short, not long)\n";
-}
diff --git a/gnu/usr.bin/perl/perl/t/op/index.t b/gnu/usr.bin/perl/perl/t/op/index.t
deleted file mode 100755
index 769314b..0000000
--- a/gnu/usr.bin/perl/perl/t/op/index.t
+++ /dev/null
@@ -1,42 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/index.t,v 1.1.1.1 1993/08/23 21:30:01 nate Exp $
-
-print "1..20\n";
-
-
-$foo = 'Now is the time for all good men to come to the aid of their country.';
-
-$first = substr($foo,0,index($foo,'the'));
-print ($first eq "Now is " ? "ok 1\n" : "not ok 1\n");
-
-$last = substr($foo,rindex($foo,'the'),100);
-print ($last eq "their country." ? "ok 2\n" : "not ok 2\n");
-
-$last = substr($foo,index($foo,'Now'),2);
-print ($last eq "No" ? "ok 3\n" : "not ok 3\n");
-
-$last = substr($foo,rindex($foo,'Now'),2);
-print ($last eq "No" ? "ok 4\n" : "not ok 4\n");
-
-$last = substr($foo,index($foo,'.'),100);
-print ($last eq "." ? "ok 5\n" : "not ok 5\n");
-
-$last = substr($foo,rindex($foo,'.'),100);
-print ($last eq "." ? "ok 6\n" : "not ok 6\n");
-
-print index("ababa","a",-1) == 0 ? "ok 7\n" : "not ok 7\n";
-print index("ababa","a",0) == 0 ? "ok 8\n" : "not ok 8\n";
-print index("ababa","a",1) == 2 ? "ok 9\n" : "not ok 9\n";
-print index("ababa","a",2) == 2 ? "ok 10\n" : "not ok 10\n";
-print index("ababa","a",3) == 4 ? "ok 11\n" : "not ok 11\n";
-print index("ababa","a",4) == 4 ? "ok 12\n" : "not ok 12\n";
-print index("ababa","a",5) == -1 ? "ok 13\n" : "not ok 13\n";
-
-print rindex("ababa","a",-1) == -1 ? "ok 14\n" : "not ok 14\n";
-print rindex("ababa","a",0) == 0 ? "ok 15\n" : "not ok 15\n";
-print rindex("ababa","a",1) == 0 ? "ok 16\n" : "not ok 16\n";
-print rindex("ababa","a",2) == 2 ? "ok 17\n" : "not ok 17\n";
-print rindex("ababa","a",3) == 2 ? "ok 18\n" : "not ok 18\n";
-print rindex("ababa","a",4) == 4 ? "ok 19\n" : "not ok 19\n";
-print rindex("ababa","a",5) == 4 ? "ok 20\n" : "not ok 20\n";
diff --git a/gnu/usr.bin/perl/perl/t/op/int.t b/gnu/usr.bin/perl/perl/t/op/int.t
deleted file mode 100755
index 09434b8..0000000
--- a/gnu/usr.bin/perl/perl/t/op/int.t
+++ /dev/null
@@ -1,17 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/int.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..4\n";
-
-# compile time evaluation
-
-if (int(1.234) == 1) {print "ok 1\n";} else {print "not ok 1\n";}
-
-if (int(-1.234) == -1) {print "ok 2\n";} else {print "not ok 2\n";}
-
-# run time evaluation
-
-$x = 1.234;
-if (int($x) == 1) {print "ok 3\n";} else {print "not ok 3\n";}
-if (int(-$x) == -1) {print "ok 4\n";} else {print "not ok 4\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/join.t b/gnu/usr.bin/perl/perl/t/op/join.t
deleted file mode 100755
index a6678e9..0000000
--- a/gnu/usr.bin/perl/perl/t/op/join.t
+++ /dev/null
@@ -1,12 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/join.t,v 1.1.1.1 1993/08/23 21:30:02 nate Exp $
-
-print "1..3\n";
-
-@x = (1, 2, 3);
-if (join(':',@x) eq '1:2:3') {print "ok 1\n";} else {print "not ok 1\n";}
-
-if (join('',1,2,3) eq '123') {print "ok 2\n";} else {print "not ok 2\n";}
-
-if (join(':',split(/ /,"1 2 3")) eq '1:2:3') {print "ok 3\n";} else {print "not ok 3\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/list.t b/gnu/usr.bin/perl/perl/t/op/list.t
deleted file mode 100755
index 52b2347..0000000
--- a/gnu/usr.bin/perl/perl/t/op/list.t
+++ /dev/null
@@ -1,83 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/list.t,v 1.1.1.1 1993/08/23 21:30:02 nate Exp $
-
-print "1..27\n";
-
-@foo = (1, 2, 3, 4);
-if ($foo[0] == 1 && $foo[3] == 4) {print "ok 1\n";} else {print "not ok 1\n";}
-
-$_ = join(':',@foo);
-if ($_ eq '1:2:3:4') {print "ok 2\n";} else {print "not ok 2\n";}
-
-($a,$b,$c,$d) = (1,2,3,4);
-if ("$a;$b;$c;$d" eq '1;2;3;4') {print "ok 3\n";} else {print "not ok 3\n";}
-
-($c,$b,$a) = split(/ /,"111 222 333");
-if ("$a;$b;$c" eq '333;222;111') {print "ok 4\n";} else {print "not ok 4\n";}
-
-($a,$b,$c) = ($c,$b,$a);
-if ("$a;$b;$c" eq '111;222;333') {print "ok 5\n";} else {print "not ok 5 $a;$b;$c\n";}
-
-($a, $b) = ($b, $a);
-if ("$a;$b;$c" eq '222;111;333') {print "ok 6\n";} else {print "not ok 6\n";}
-
-($a, $b[1], $c{2}, $d) = (1, 2, 3, 4);
-if ($a eq 1) {print "ok 7\n";} else {print "not ok 7\n";}
-if ($b[1] eq 2) {print "ok 8\n";} else {print "not ok 8\n";}
-if ($c{2} eq 3) {print "ok 9\n";} else {print "not ok 9\n";}
-if ($d eq 4) {print "ok 10\n";} else {print "not ok 10\n";}
-
-@foo = (1,2,3,4,5,6,7,8);
-($a, $b, $c, $d) = @foo;
-print "#11 $a;$b;$c;$d eq 1;2;3;4\n";
-if ("$a;$b;$c;$d" eq '1;2;3;4') {print "ok 11\n";} else {print "not ok 11\n";}
-
-@foo = @bar = (1);
-if (join(':',@foo,@bar) eq '1:1') {print "ok 12\n";} else {print "not ok 12\n";}
-
-@foo = ();
-@foo = 1+2+3;
-if (join(':',@foo) eq '6') {print "ok 13\n";} else {print "not ok 13\n";}
-
-for ($x = 0; $x < 3; $x++) {
- ($a, $b, $c) =
- $x == 0?
- ('ok ', 14, "\n"):
- $x == 1?
- ('ok ', 15, "\n"):
- # default
- ('ok ', 16, "\n");
-
- print $a,$b,$c;
-}
-
-@a = ($x == 12345 || (1,2,3));
-if (join('',@a) eq '123') {print "ok 17\n";} else {print "not ok 17\n";}
-
-@a = ($x == $x || (4,5,6));
-if (join('',@a) eq '1') {print "ok 18\n";} else {print "not ok 18\n";}
-
-if (join('',1,2,(3,4,5)) eq '12345'){print "ok 19\n";}else{print "not ok 19\n";}
-if (join('',(1,2,3,4,5)) eq '12345'){print "ok 20\n";}else{print "not ok 20\n";}
-if (join('',(1,2,3,4),5) eq '12345'){print "ok 21\n";}else{print "not ok 21\n";}
-if (join('',1,(2,3,4),5) eq '12345'){print "ok 22\n";}else{print "not ok 22\n";}
-if (join('',1,2,(3,4),5) eq '12345'){print "ok 23\n";}else{print "not ok 23\n";}
-if (join('',1,2,3,(4),5) eq '12345'){print "ok 24\n";}else{print "not ok 24\n";}
-
-for ($x = 0; $x < 3; $x++) {
- ($a, $b, $c) = do {
- if ($x == 0) {
- ('ok ', 25, "\n");
- }
- elsif ($x == 1) {
- ('ok ', 26, "\n");
- }
- else {
- ('ok ', 27, "\n");
- }
- };
-
- print $a,$b,$c;
-}
-
diff --git a/gnu/usr.bin/perl/perl/t/op/local.t b/gnu/usr.bin/perl/perl/t/op/local.t
deleted file mode 100755
index 67396e7..0000000
--- a/gnu/usr.bin/perl/perl/t/op/local.t
+++ /dev/null
@@ -1,45 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/local.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-print "1..20\n";
-
-sub foo {
- local($a, $b) = @_;
- local($c, $d);
- $c = "ok 3\n";
- $d = "ok 4\n";
- { local($a,$c) = ("ok 9\n", "ok 10\n"); ($x, $y) = ($a, $c); }
- print $a, $b;
- $c . $d;
-}
-
-$a = "ok 5\n";
-$b = "ok 6\n";
-$c = "ok 7\n";
-$d = "ok 8\n";
-
-print do foo("ok 1\n","ok 2\n");
-
-print $a,$b,$c,$d,$x,$y;
-
-# same thing, only with arrays and associative arrays
-
-sub foo2 {
- local($a, @b) = @_;
- local(@c, %d);
- @c = "ok 13\n";
- $d{''} = "ok 14\n";
- { local($a,@c) = ("ok 19\n", "ok 20\n"); ($x, $y) = ($a, @c); }
- print $a, @b;
- $c[0] . $d{''};
-}
-
-$a = "ok 15\n";
-@b = "ok 16\n";
-@c = "ok 17\n";
-$d{''} = "ok 18\n";
-
-print do foo2("ok 11\n","ok 12\n");
-
-print $a,@b,@c,%d,$x,$y;
diff --git a/gnu/usr.bin/perl/perl/t/op/magic.t b/gnu/usr.bin/perl/perl/t/op/magic.t
deleted file mode 100755
index 1f47a99..0000000
--- a/gnu/usr.bin/perl/perl/t/op/magic.t
+++ /dev/null
@@ -1,32 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/magic.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-$| = 1; # command buffering
-
-print "1..5\n";
-
-eval '$ENV{"foo"} = "hi there";'; # check that ENV is inited inside eval
-if (`echo \$foo` eq "hi there\n") {print "ok 1\n";} else {print "not ok 1\n";}
-
-unlink 'ajslkdfpqjsjfk';
-$! = 0;
-open(foo,'ajslkdfpqjsjfk');
-if ($! == 2) {print "ok 2\n";} else {print "not ok 2\n";}
-
-# the next tests are embedded inside system simply because sh spits out
-# a newline onto stderr when a child process kills itself with SIGINT.
-
-system './perl',
-'-e', '$| = 1; # command buffering',
-
-'-e', '$SIG{"INT"} = "ok3"; kill 2,$$;',
-'-e', '$SIG{"INT"} = "IGNORE"; kill 2,$$; print "ok 4\n";',
-'-e', '$SIG{"INT"} = "DEFAULT"; kill 2,$$; print "not ok\n";',
-
-'-e', 'sub ok3 { print "ok 3\n" if pop(@_) eq "INT"; }';
-
-@val1 = @ENV{keys(%ENV)}; # can we slice ENV?
-@val2 = values(%ENV);
-
-print join(':',@val1) eq join(':',@val2) ? "ok 5\n" : "not ok 5\n";
diff --git a/gnu/usr.bin/perl/perl/t/op/mkdir.t b/gnu/usr.bin/perl/perl/t/op/mkdir.t
deleted file mode 100755
index 0290ed4..0000000
--- a/gnu/usr.bin/perl/perl/t/op/mkdir.t
+++ /dev/null
@@ -1,15 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/mkdir.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..7\n";
-
-`rm -rf blurfl`;
-
-print (mkdir('blurfl',0777) ? "ok 1\n" : "not ok 1\n");
-print (mkdir('blurfl',0777) ? "not ok 2\n" : "ok 2\n");
-print ($! =~ /exist/ ? "ok 3\n" : "not ok 3\n");
-print (-d 'blurfl' ? "ok 4\n" : "not ok 4\n");
-print (rmdir('blurfl') ? "ok 5\n" : "not ok 5\n");
-print (rmdir('blurfl') ? "not ok 6\n" : "ok 6\n");
-print ($! =~ /such|exist/ ? "ok 7\n" : "not ok 7\n");
diff --git a/gnu/usr.bin/perl/perl/t/op/oct.t b/gnu/usr.bin/perl/perl/t/op/oct.t
deleted file mode 100755
index 9322cf0..0000000
--- a/gnu/usr.bin/perl/perl/t/op/oct.t
+++ /dev/null
@@ -1,9 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/oct.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..3\n";
-
-if (oct('01234') == 01234) {print "ok 1\n";} else {print "not ok 1\n";}
-if (oct('0x1234') == 0x1234) {print "ok 2\n";} else {print "not ok 2\n";}
-if (hex('01234') == 0x1234) {print "ok 3\n";} else {print "not ok 3\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/ord.t b/gnu/usr.bin/perl/perl/t/op/ord.t
deleted file mode 100755
index 9d31988..0000000
--- a/gnu/usr.bin/perl/perl/t/op/ord.t
+++ /dev/null
@@ -1,14 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/ord.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..2\n";
-
-# compile time evaluation
-
-if (ord('A') == 65) {print "ok 1\n";} else {print "not ok 1\n";}
-
-# run time evaluation
-
-$x = 'ABC';
-if (ord($x) == 65) {print "ok 2\n";} else {print "not ok 2\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/pack.t b/gnu/usr.bin/perl/perl/t/op/pack.t
deleted file mode 100755
index 1dfaddf..0000000
--- a/gnu/usr.bin/perl/perl/t/op/pack.t
+++ /dev/null
@@ -1,20 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/pack.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-print "1..3\n";
-
-$format = "c2x5CCxsdila6";
-# Need the expression in here to force ary[5] to be numeric. This avoids
-# test2 failing because ary2 goes str->numeric->str and ary doesn't.
-@ary = (1,-100,127,128,32767,987.654321098 / 100.0,12345,123456,"abcdef");
-$foo = pack($format,@ary);
-@ary2 = unpack($format,$foo);
-
-print ($#ary == $#ary2 ? "ok 1\n" : "not ok 1\n");
-
-$out1=join(':',@ary);
-$out2=join(':',@ary2);
-print ($out1 eq $out2 ? "ok 2\n" : "not ok 2\n");
-
-print ($foo =~ /def/ ? "ok 3\n" : "not ok 3\n");
diff --git a/gnu/usr.bin/perl/perl/t/op/pat.t b/gnu/usr.bin/perl/perl/t/op/pat.t
deleted file mode 100755
index ce9f35c..0000000
--- a/gnu/usr.bin/perl/perl/t/op/pat.t
+++ /dev/null
@@ -1,184 +0,0 @@
-#!./perl
-
-# $RCSfile: pat.t,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:01 $
-
-print "1..51\n";
-
-$x = "abc\ndef\n";
-
-if ($x =~ /^abc/) {print "ok 1\n";} else {print "not ok 1\n";}
-if ($x !~ /^def/) {print "ok 2\n";} else {print "not ok 2\n";}
-
-$* = 1;
-if ($x =~ /^def/) {print "ok 3\n";} else {print "not ok 3\n";}
-$* = 0;
-
-$_ = '123';
-if (/^([0-9][0-9]*)/) {print "ok 4\n";} else {print "not ok 4\n";}
-
-if ($x =~ /^xxx/) {print "not ok 5\n";} else {print "ok 5\n";}
-if ($x !~ /^abc/) {print "not ok 6\n";} else {print "ok 6\n";}
-
-if ($x =~ /def/) {print "ok 7\n";} else {print "not ok 7\n";}
-if ($x !~ /def/) {print "not ok 8\n";} else {print "ok 8\n";}
-
-if ($x !~ /.def/) {print "ok 9\n";} else {print "not ok 9\n";}
-if ($x =~ /.def/) {print "not ok 10\n";} else {print "ok 10\n";}
-
-if ($x =~ /\ndef/) {print "ok 11\n";} else {print "not ok 11\n";}
-if ($x !~ /\ndef/) {print "not ok 12\n";} else {print "ok 12\n";}
-
-$_ = 'aaabbbccc';
-if (/(a*b*)(c*)/ && $1 eq 'aaabbb' && $2 eq 'ccc') {
- print "ok 13\n";
-} else {
- print "not ok 13\n";
-}
-if (/(a+b+c+)/ && $1 eq 'aaabbbccc') {
- print "ok 14\n";
-} else {
- print "not ok 14\n";
-}
-
-if (/a+b?c+/) {print "not ok 15\n";} else {print "ok 15\n";}
-
-$_ = 'aaabccc';
-if (/a+b?c+/) {print "ok 16\n";} else {print "not ok 16\n";}
-if (/a*b+c*/) {print "ok 17\n";} else {print "not ok 17\n";}
-
-$_ = 'aaaccc';
-if (/a*b?c*/) {print "ok 18\n";} else {print "not ok 18\n";}
-if (/a*b+c*/) {print "not ok 19\n";} else {print "ok 19\n";}
-
-$_ = 'abcdef';
-if (/bcd|xyz/) {print "ok 20\n";} else {print "not ok 20\n";}
-if (/xyz|bcd/) {print "ok 21\n";} else {print "not ok 21\n";}
-
-if (m|bc/*d|) {print "ok 22\n";} else {print "not ok 22\n";}
-
-if (/^$_$/) {print "ok 23\n";} else {print "not ok 23\n";}
-
-$* = 1; # test 3 only tested the optimized version--this one is for real
-if ("ab\ncd\n" =~ /^cd/) {print "ok 24\n";} else {print "not ok 24\n";}
-$* = 0;
-
-$XXX{123} = 123;
-$XXX{234} = 234;
-$XXX{345} = 345;
-
-@XXX = ('ok 25','not ok 25', 'ok 26','not ok 26','not ok 27');
-while ($_ = shift(XXX)) {
- ?(.*)? && (print $1,"\n");
- /not/ && reset;
- /not ok 26/ && reset 'X';
-}
-
-while (($key,$val) = each(XXX)) {
- print "not ok 27\n";
- exit;
-}
-
-print "ok 27\n";
-
-'cde' =~ /[^ab]*/;
-'xyz' =~ //;
-if ($& eq 'xyz') {print "ok 28\n";} else {print "not ok 28\n";}
-
-$foo = '[^ab]*';
-'cde' =~ /$foo/;
-'xyz' =~ //;
-if ($& eq 'xyz') {print "ok 29\n";} else {print "not ok 29\n";}
-
-$foo = '[^ab]*';
-'cde' =~ /$foo/;
-'xyz' =~ /$null/;
-if ($& eq 'xyz') {print "ok 30\n";} else {print "not ok 30\n";}
-
-$_ = 'abcdefghi';
-/def/; # optimized up to cmd
-if ("$`:$&:$'" eq 'abc:def:ghi') {print "ok 31\n";} else {print "not ok 31\n";}
-
-/cde/ + 0; # optimized only to spat
-if ("$`:$&:$'" eq 'ab:cde:fghi') {print "ok 32\n";} else {print "not ok 32\n";}
-
-/[d][e][f]/; # not optimized
-if ("$`:$&:$'" eq 'abc:def:ghi') {print "ok 33\n";} else {print "not ok 33\n";}
-
-$_ = 'now is the {time for all} good men to come to.';
-/ {([^}]*)}/;
-if ($1 eq 'time for all') {print "ok 34\n";} else {print "not ok 34 $1\n";}
-
-$_ = 'xxx {3,4} yyy zzz';
-print /( {3,4})/ ? "ok 35\n" : "not ok 35\n";
-print $1 eq ' ' ? "ok 36\n" : "not ok 36\n";
-print /( {4,})/ ? "not ok 37\n" : "ok 37\n";
-print /( {2,3}.)/ ? "ok 38\n" : "not ok 38\n";
-print $1 eq ' y' ? "ok 39\n" : "not ok 39\n";
-print /(y{2,3}.)/ ? "ok 40\n" : "not ok 40\n";
-print $1 eq 'yyy ' ? "ok 41\n" : "not ok 41\n";
-print /x {3,4}/ ? "not ok 42\n" : "ok 42\n";
-print /^xxx {3,4}/ ? "not ok 43\n" : "ok 43\n";
-
-$_ = "now is the time for all good men to come to.";
-@words = /(\w+)/g;
-print join(':',@words) eq "now:is:the:time:for:all:good:men:to:come:to"
- ? "ok 44\n"
- : "not ok 44\n";
-
-@words = ();
-while (/\w+/g) {
- push(@words, $&);
-}
-print join(':',@words) eq "now:is:the:time:for:all:good:men:to:come:to"
- ? "ok 45\n"
- : "not ok 45\n";
-
-@words = ();
-while (/to/g) {
- push(@words, $&);
-}
-print join(':',@words) eq "to:to"
- ? "ok 46\n"
- : "not ok 46 @words\n";
-
-@words = /to/g;
-print join(':',@words) eq "to:to"
- ? "ok 47\n"
- : "not ok 47 @words\n";
-
-$_ = "abcdefghi";
-
-$pat1 = 'def';
-$pat2 = '^def';
-$pat3 = '.def.';
-$pat4 = 'abc';
-$pat5 = '^abc';
-$pat6 = 'abc$';
-$pat7 = 'ghi';
-$pat8 = '\w*ghi';
-$pat9 = 'ghi$';
-
-$t1=$t2=$t3=$t4=$t5=$t6=$t7=$t8=$t9=0;
-
-for $iter (1..5) {
- $t1++ if /$pat1/o;
- $t2++ if /$pat2/o;
- $t3++ if /$pat3/o;
- $t4++ if /$pat4/o;
- $t5++ if /$pat5/o;
- $t6++ if /$pat6/o;
- $t7++ if /$pat7/o;
- $t8++ if /$pat8/o;
- $t9++ if /$pat9/o;
-}
-
-$x = "$t1$t2$t3$t4$t5$t6$t7$t8$t9";
-print $x eq '505550555' ? "ok 48\n" : "not ok 48 $x\n";
-
-$xyz = 'xyz';
-print "abc" =~ /^abc$|$xyz/ ? "ok 49\n" : "not ok 49\n";
-
-# perl 4.009 says "unmatched ()"
-eval '"abc" =~ /a(bc$)|$xyz/; $result = "$&:$1"';
-print $@ eq "" ? "ok 50\n" : "not ok 50\n";
-print $result eq "abc:bc" ? "ok 51\n" : "not ok 51\n";
diff --git a/gnu/usr.bin/perl/perl/t/op/push.t b/gnu/usr.bin/perl/perl/t/op/push.t
deleted file mode 100755
index 3d738ac..0000000
--- a/gnu/usr.bin/perl/perl/t/op/push.t
+++ /dev/null
@@ -1,44 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/push.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-@tests = split(/\n/, <<EOF);
-0 3, 0 1 2, 3 4 5 6 7
-0 0 a b c, , a b c 0 1 2 3 4 5 6 7
-8 0 a b c, , 0 1 2 3 4 5 6 7 a b c
-7 0 6.5, , 0 1 2 3 4 5 6 6.5 7
-1 0 a b c d e f g h i j,, 0 a b c d e f g h i j 1 2 3 4 5 6 7
-0 1 a, 0, a 1 2 3 4 5 6 7
-1 6 x y z, 1 2 3 4 5 6, 0 x y z 7
-0 7 x y z, 0 1 2 3 4 5 6, x y z 7
-1 7 x y z, 1 2 3 4 5 6 7, 0 x y z
-4, 4 5 6 7, 0 1 2 3
--4, 4 5 6 7, 0 1 2 3
-EOF
-
-print "1..", 2 + @tests, "\n";
-die "blech" unless @tests;
-
-@x = (1,2,3);
-push(@x,@x);
-if (join(':',@x) eq '1:2:3:1:2:3') {print "ok 1\n";} else {print "not ok 1\n";}
-push(x,4);
-if (join(':',@x) eq '1:2:3:1:2:3:4') {print "ok 2\n";} else {print "not ok 2\n";}
-
-$test = 3;
-foreach $line (@tests) {
- ($list,$get,$leave) = split(/,\t*/,$line);
- @list = split(' ',$list);
- @get = split(' ',$get);
- @leave = split(' ',$leave);
- @x = (0,1,2,3,4,5,6,7);
- @got = splice(@x,@list);
- if (join(':',@got) eq join(':',@get) &&
- join(':',@x) eq join(':',@leave)) {
- print "ok ",$test++,"\n";
- }
- else {
- print "not ok ",$test++," got: @got == @get left: @x == @leave\n";
- }
-}
-
diff --git a/gnu/usr.bin/perl/perl/t/op/range.t b/gnu/usr.bin/perl/perl/t/op/range.t
deleted file mode 100755
index 6214f95..0000000
--- a/gnu/usr.bin/perl/perl/t/op/range.t
+++ /dev/null
@@ -1,36 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/range.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-print "1..8\n";
-
-print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n";
-
-@foo = (1,2,3,4,5,6,7,8,9);
-@foo[2..4] = ('c','d','e');
-
-print join(':',@foo[$foo[0]..5]) eq '2:c:d:e:6' ? "ok 2\n" : "not ok 2\n";
-
-@bar[2..4] = ('c','d','e');
-print join(':',@bar[1..5]) eq ':c:d:e:' ? "ok 3\n" : "not ok 3\n";
-
-($a,@bcd[0..2],$e) = ('a','b','c','d','e');
-print join(':',$a,@bcd[0..2],$e) eq 'a:b:c:d:e' ? "ok 4\n" : "not ok 4\n";
-
-$x = 0;
-for (1..100) {
- $x += $_;
-}
-print $x == 5050 ? "ok 5\n" : "not ok 5 $x\n";
-
-$x = 0;
-for ((100,2..99,1)) {
- $x += $_;
-}
-print $x == 5050 ? "ok 6\n" : "not ok 6 $x\n";
-
-$x = join('','a'..'z');
-print $x eq 'abcdefghijklmnopqrstuvwxyz' ? "ok 7\n" : "not ok 7 $x\n";
-
-@x = 'A'..'ZZ';
-print @x == 27 * 26 ? "ok 8\n" : "not ok 8\n";
diff --git a/gnu/usr.bin/perl/perl/t/op/re_tests b/gnu/usr.bin/perl/perl/t/op/re_tests
deleted file mode 100644
index ee03d6f..0000000
--- a/gnu/usr.bin/perl/perl/t/op/re_tests
+++ /dev/null
@@ -1,274 +0,0 @@
-abc abc y $& abc
-abc xbc n - -
-abc axc n - -
-abc abx n - -
-abc xabcy y $& abc
-abc ababc y $& abc
-ab*c abc y $& abc
-ab*bc abc y $& abc
-ab*bc abbc y $& abbc
-ab*bc abbbbc y $& abbbbc
-ab{0,}bc abbbbc y $& abbbbc
-ab+bc abbc y $& abbc
-ab+bc abc n - -
-ab+bc abq n - -
-ab{1,}bc abq n - -
-ab+bc abbbbc y $& abbbbc
-ab{1,}bc abbbbc y $& abbbbc
-ab{1,3}bc abbbbc y $& abbbbc
-ab{3,4}bc abbbbc y $& abbbbc
-ab{4,5}bc abbbbc n - -
-ab?bc abbc y $& abbc
-ab?bc abc y $& abc
-ab{0,1}bc abc y $& abc
-ab?bc abbbbc n - -
-ab?c abc y $& abc
-ab{0,1}c abc y $& abc
-^abc$ abc y $& abc
-^abc$ abcc n - -
-^abc abcc y $& abc
-^abc$ aabc n - -
-abc$ aabc y $& abc
-^ abc y $&
-$ abc y $&
-a.c abc y $& abc
-a.c axc y $& axc
-a.*c axyzc y $& axyzc
-a.*c axyzd n - -
-a[bc]d abc n - -
-a[bc]d abd y $& abd
-a[b-d]e abd n - -
-a[b-d]e ace y $& ace
-a[b-d] aac y $& ac
-a[-b] a- y $& a-
-a[b-] a- y $& a-
-a[b-a] - c - -
-a[]b - c - -
-a[ - c - -
-a] a] y $& a]
-a[]]b a]b y $& a]b
-a[^bc]d aed y $& aed
-a[^bc]d abd n - -
-a[^-b]c adc y $& adc
-a[^-b]c a-c n - -
-a[^]b]c a]c n - -
-a[^]b]c adc y $& adc
-ab|cd abc y $& ab
-ab|cd abcd y $& ab
-()ef def y $&-$1 ef-
-()* - c - -
-*a - c - -
-^* - c - -
-$* - c - -
-(*)b - c - -
-$b b n - -
-a\ - c - -
-a\(b a(b y $&-$1 a(b-
-a\(*b ab y $& ab
-a\(*b a((b y $& a((b
-a\\b a\b y $& a\b
-abc) - c - -
-(abc - c - -
-((a)) abc y $&-$1-$2 a-a-a
-(a)b(c) abc y $&-$1-$2 abc-a-c
-a+b+c aabbabc y $& abc
-a{1,}b{1,}c aabbabc y $& abc
-a** - c - -
-a*? - c - -
-(a*)* - c - -
-(a*)+ - c - -
-(a|)* - c - -
-(a*|b)* - c - -
-(a+|b)* ab y $&-$1 ab-b
-(a+|b){0,} ab y $&-$1 ab-b
-(a+|b)+ ab y $&-$1 ab-b
-(a+|b){1,} ab y $&-$1 ab-b
-(a+|b)? ab y $&-$1 a-a
-(a+|b){0,1} ab y $&-$1 a-a
-(^)* - c - -
-(ab|)* - c - -
-)( - c - -
-[^ab]* cde y $& cde
-abc n - -
-a* y $&
-([abc])*d abbbcd y $&-$1 abbbcd-c
-([abc])*bcd abcd y $&-$1 abcd-a
-a|b|c|d|e e y $& e
-(a|b|c|d|e)f ef y $&-$1 ef-e
-((a*|b))* - c - -
-abcd*efg abcdefg y $& abcdefg
-ab* xabyabbbz y $& ab
-ab* xayabbbz y $& a
-(ab|cd)e abcde y $&-$1 cde-cd
-[abhgefdc]ij hij y $& hij
-^(ab|cd)e abcde n x$1y xy
-(abc|)ef abcdef y $&-$1 ef-
-(a|b)c*d abcd y $&-$1 bcd-b
-(ab|ab*)bc abc y $&-$1 abc-a
-a([bc]*)c* abc y $&-$1 abc-bc
-a([bc]*)(c*d) abcd y $&-$1-$2 abcd-bc-d
-a([bc]+)(c*d) abcd y $&-$1-$2 abcd-bc-d
-a([bc]*)(c+d) abcd y $&-$1-$2 abcd-b-cd
-a[bcd]*dcdcde adcdcde y $& adcdcde
-a[bcd]+dcdcde adcdcde n - -
-(ab|a)b*c abc y $&-$1 abc-ab
-((a)(b)c)(d) abcd y $1-$2-$3-$4 abc-a-b-d
-[a-zA-Z_][a-zA-Z0-9_]* alpha y $& alpha
-^a(bc+|b[eh])g|.h$ abh y $&-$1 bh-
-(bc+d$|ef*g.|h?i(j|k)) effgz y $&-$1-$2 effgz-effgz-
-(bc+d$|ef*g.|h?i(j|k)) ij y $&-$1-$2 ij-ij-j
-(bc+d$|ef*g.|h?i(j|k)) effg n - -
-(bc+d$|ef*g.|h?i(j|k)) bcdd n - -
-(bc+d$|ef*g.|h?i(j|k)) reffgz y $&-$1-$2 effgz-effgz-
-((((((((((a)))))))))) a y $10 a
-((((((((((a))))))))))\10 aa y $& aa
-((((((((((a))))))))))\41 aa n - -
-((((((((((a))))))))))\41 a! y $& a!
-(((((((((a))))))))) a y $& a
-multiple words of text uh-uh n - -
-multiple words multiple words, yeah y $& multiple words
-(.*)c(.*) abcde y $&-$1-$2 abcde-ab-de
-\((.*), (.*)\) (a, b) y ($2, $1) (b, a)
-[k] ab n - -
-abcd abcd y $&-\$&-\\$& abcd-$&-\abcd
-a(bc)d abcd y $1-\$1-\\$1 bc-$1-\bc
-a[-]?c ac y $& ac
-(abc)\1 abcabc y $1 abc
-([a-c]*)\1 abcabc y $1 abc
-'abc'i ABC y $& ABC
-'abc'i XBC n - -
-'abc'i AXC n - -
-'abc'i ABX n - -
-'abc'i XABCY y $& ABC
-'abc'i ABABC y $& ABC
-'ab*c'i ABC y $& ABC
-'ab*bc'i ABC y $& ABC
-'ab*bc'i ABBC y $& ABBC
-'ab*bc'i ABBBBC y $& ABBBBC
-'ab{0,}bc'i ABBBBC y $& ABBBBC
-'ab+bc'i ABBC y $& ABBC
-'ab+bc'i ABC n - -
-'ab+bc'i ABQ n - -
-'ab{1,}bc'i ABQ n - -
-'ab+bc'i ABBBBC y $& ABBBBC
-'ab{1,}bc'i ABBBBC y $& ABBBBC
-'ab{1,3}bc'i ABBBBC y $& ABBBBC
-'ab{3,4}bc'i ABBBBC y $& ABBBBC
-'ab{4,5}bc'i ABBBBC n - -
-'ab?bc'i ABBC y $& ABBC
-'ab?bc'i ABC y $& ABC
-'ab{0,1}bc'i ABC y $& ABC
-'ab?bc'i ABBBBC n - -
-'ab?c'i ABC y $& ABC
-'ab{0,1}c'i ABC y $& ABC
-'^abc$'i ABC y $& ABC
-'^abc$'i ABCC n - -
-'^abc'i ABCC y $& ABC
-'^abc$'i AABC n - -
-'abc$'i AABC y $& ABC
-'^'i ABC y $&
-'$'i ABC y $&
-'a.c'i ABC y $& ABC
-'a.c'i AXC y $& AXC
-'a.*c'i AXYZC y $& AXYZC
-'a.*c'i AXYZD n - -
-'a[bc]d'i ABC n - -
-'a[bc]d'i ABD y $& ABD
-'a[b-d]e'i ABD n - -
-'a[b-d]e'i ACE y $& ACE
-'a[b-d]'i AAC y $& AC
-'a[-b]'i A- y $& A-
-'a[b-]'i A- y $& A-
-'a[b-a]'i - c - -
-'a[]b'i - c - -
-'a['i - c - -
-'a]'i A] y $& A]
-'a[]]b'i A]B y $& A]B
-'a[^bc]d'i AED y $& AED
-'a[^bc]d'i ABD n - -
-'a[^-b]c'i ADC y $& ADC
-'a[^-b]c'i A-C n - -
-'a[^]b]c'i A]C n - -
-'a[^]b]c'i ADC y $& ADC
-'ab|cd'i ABC y $& AB
-'ab|cd'i ABCD y $& AB
-'()ef'i DEF y $&-$1 EF-
-'()*'i - c - -
-'*a'i - c - -
-'^*'i - c - -
-'$*'i - c - -
-'(*)b'i - c - -
-'$b'i B n - -
-'a\'i - c - -
-'a\(b'i A(B y $&-$1 A(B-
-'a\(*b'i AB y $& AB
-'a\(*b'i A((B y $& A((B
-'a\\b'i A\B y $& A\B
-'abc)'i - c - -
-'(abc'i - c - -
-'((a))'i ABC y $&-$1-$2 A-A-A
-'(a)b(c)'i ABC y $&-$1-$2 ABC-A-C
-'a+b+c'i AABBABC y $& ABC
-'a{1,}b{1,}c'i AABBABC y $& ABC
-'a**'i - c - -
-'a*?'i - c - -
-'(a*)*'i - c - -
-'(a*)+'i - c - -
-'(a|)*'i - c - -
-'(a*|b)*'i - c - -
-'(a+|b)*'i AB y $&-$1 AB-B
-'(a+|b){0,}'i AB y $&-$1 AB-B
-'(a+|b)+'i AB y $&-$1 AB-B
-'(a+|b){1,}'i AB y $&-$1 AB-B
-'(a+|b)?'i AB y $&-$1 A-A
-'(a+|b){0,1}'i AB y $&-$1 A-A
-'(^)*'i - c - -
-'(ab|)*'i - c - -
-')('i - c - -
-'[^ab]*'i CDE y $& CDE
-'abc'i n - -
-'a*'i y $&
-'([abc])*d'i ABBBCD y $&-$1 ABBBCD-C
-'([abc])*bcd'i ABCD y $&-$1 ABCD-A
-'a|b|c|d|e'i E y $& E
-'(a|b|c|d|e)f'i EF y $&-$1 EF-E
-'((a*|b))*'i - c - -
-'abcd*efg'i ABCDEFG y $& ABCDEFG
-'ab*'i XABYABBBZ y $& AB
-'ab*'i XAYABBBZ y $& A
-'(ab|cd)e'i ABCDE y $&-$1 CDE-CD
-'[abhgefdc]ij'i HIJ y $& HIJ
-'^(ab|cd)e'i ABCDE n x$1y XY
-'(abc|)ef'i ABCDEF y $&-$1 EF-
-'(a|b)c*d'i ABCD y $&-$1 BCD-B
-'(ab|ab*)bc'i ABC y $&-$1 ABC-A
-'a([bc]*)c*'i ABC y $&-$1 ABC-BC
-'a([bc]*)(c*d)'i ABCD y $&-$1-$2 ABCD-BC-D
-'a([bc]+)(c*d)'i ABCD y $&-$1-$2 ABCD-BC-D
-'a([bc]*)(c+d)'i ABCD y $&-$1-$2 ABCD-B-CD
-'a[bcd]*dcdcde'i ADCDCDE y $& ADCDCDE
-'a[bcd]+dcdcde'i ADCDCDE n - -
-'(ab|a)b*c'i ABC y $&-$1 ABC-AB
-'((a)(b)c)(d)'i ABCD y $1-$2-$3-$4 ABC-A-B-D
-'[a-zA-Z_][a-zA-Z0-9_]*'i ALPHA y $& ALPHA
-'^a(bc+|b[eh])g|.h$'i ABH y $&-$1 BH-
-'(bc+d$|ef*g.|h?i(j|k))'i EFFGZ y $&-$1-$2 EFFGZ-EFFGZ-
-'(bc+d$|ef*g.|h?i(j|k))'i IJ y $&-$1-$2 IJ-IJ-J
-'(bc+d$|ef*g.|h?i(j|k))'i EFFG n - -
-'(bc+d$|ef*g.|h?i(j|k))'i BCDD n - -
-'(bc+d$|ef*g.|h?i(j|k))'i REFFGZ y $&-$1-$2 EFFGZ-EFFGZ-
-'((((((((((a))))))))))'i A y $10 A
-'((((((((((a))))))))))\10'i AA y $& AA
-'((((((((((a))))))))))\41'i AA n - -
-'((((((((((a))))))))))\41'i A! y $& A!
-'(((((((((a)))))))))'i A y $& A
-'multiple words of text'i UH-UH n - -
-'multiple words'i MULTIPLE WORDS, YEAH y $& MULTIPLE WORDS
-'(.*)c(.*)'i ABCDE y $&-$1-$2 ABCDE-AB-DE
-'\((.*), (.*)\)'i (A, B) y ($2, $1) (B, A)
-'[k]'i AB n - -
-'abcd'i ABCD y $&-\$&-\\$& ABCD-$&-\ABCD
-'a(bc)d'i ABCD y $1-\$1-\\$1 BC-$1-\BC
-'a[-]?c'i AC y $& AC
-'(abc)\1'i ABCABC y $1 ABC
-'([a-c]*)\1'i ABCABC y $1 ABC
diff --git a/gnu/usr.bin/perl/perl/t/op/read.t b/gnu/usr.bin/perl/perl/t/op/read.t
deleted file mode 100755
index 4151e5c..0000000
--- a/gnu/usr.bin/perl/perl/t/op/read.t
+++ /dev/null
@@ -1,20 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/read.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..4\n";
-
-
-open(FOO,'op/read.t') || open(FOO,'./read.t') || open(FOO,'t/op/read.t') || die "Can't open op.read";
-seek(FOO,4,0);
-$got = read(FOO,$buf,4);
-print "This is got ... $got\n";
-
-print ($got == 4 ? "ok 1\n" : "not ok 1\n");
-print ($buf eq "perl" ? "ok 2\n" : "not ok 2 :$buf:\n");
-
-seek(FOO,20000,0);
-$got = read(FOO,$buf,4);
-
-print ($got == 0 ? "ok 3\n" : "not ok 3\n");
-print ($buf eq "" ? "ok 4\n" : "not ok 4\n");
diff --git a/gnu/usr.bin/perl/perl/t/op/readdir.t b/gnu/usr.bin/perl/perl/t/op/readdir.t
deleted file mode 100755
index 1800699..0000000
--- a/gnu/usr.bin/perl/perl/t/op/readdir.t
+++ /dev/null
@@ -1,20 +0,0 @@
-#!./perl
-
-eval 'opendir(NOSUCH, "no/such/directory");';
-if ($@) { print "1..0\n"; exit; }
-
-print "1..3\n";
-
-if (opendir(OP, "op")) { print "ok 1\n"; } else { print "not ok 1\n"; }
-@D = grep(/^[^\.].*\.t$/, readdir(OP));
-closedir(OP);
-
-if (@D > 20 && @D < 100) { print "ok 2\n"; } else { print "not ok 2\n"; }
-
-@R = sort @D;
-@G = <op/*.t>;
-while (@R && @G && "op/".$R[0] eq $G[0]) {
- shift(@R);
- shift(@G);
-}
-if (@R == 0 && @G == 0) { print "ok 3\n"; } else { print "not ok 3\n"; }
diff --git a/gnu/usr.bin/perl/perl/t/op/regexp.t b/gnu/usr.bin/perl/perl/t/op/regexp.t
deleted file mode 100755
index 58f6666..0000000
--- a/gnu/usr.bin/perl/perl/t/op/regexp.t
+++ /dev/null
@@ -1,35 +0,0 @@
-#!./perl
-
-# $RCSfile: regexp.t,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:03 $
-
-open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
- || die "Can't open re_tests";
-while (<TESTS>) { }
-$numtests = $.;
-close(TESTS);
-
-print "1..$numtests\n";
-open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
- || die "Can't open re_tests";
-$| = 1;
-while (<TESTS>) {
- ($pat, $subject, $result, $repl, $expect) = split(/[\t\n]/,$_);
- $input = join(':',$pat,$subject,$result,$repl,$expect);
- $pat = "'$pat'" unless $pat =~ /^'/;
- eval "\$match = (\$subject =~ m$pat); \$got = \"$repl\";";
- if ($result eq 'c') {
- if ($@ ne '') {print "ok $.\n";} else {print "not ok $.\n";}
- }
- elsif ($result eq 'n') {
- if (!$match) {print "ok $.\n";} else {print "not ok $. $input => $got\n";}
- }
- else {
- if ($match && $got eq $expect) {
- print "ok $.\n";
- }
- else {
- print "not ok $. $input => $got\n";
- }
- }
-}
-close(TESTS);
diff --git a/gnu/usr.bin/perl/perl/t/op/repeat.t b/gnu/usr.bin/perl/perl/t/op/repeat.t
deleted file mode 100755
index 68c61fc..0000000
--- a/gnu/usr.bin/perl/perl/t/op/repeat.t
+++ /dev/null
@@ -1,42 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/repeat.t,v 1.1.1.1 1993/08/23 21:30:02 nate Exp $
-
-print "1..19\n";
-
-# compile time
-
-if ('-' x 5 eq '-----') {print "ok 1\n";} else {print "not ok 1\n";}
-if ('-' x 1 eq '-') {print "ok 2\n";} else {print "not ok 2\n";}
-if ('-' x 0 eq '') {print "ok 3\n";} else {print "not ok 3\n";}
-
-if ('ab' x 3 eq 'ababab') {print "ok 4\n";} else {print "not ok 4\n";}
-
-# run time
-
-$a = '-';
-if ($a x 5 eq '-----') {print "ok 5\n";} else {print "not ok 5\n";}
-if ($a x 1 eq '-') {print "ok 6\n";} else {print "not ok 6\n";}
-if ($a x 0 eq '') {print "ok 7\n";} else {print "not ok 7\n";}
-
-$a = 'ab';
-if ($a x 3 eq 'ababab') {print "ok 8\n";} else {print "not ok 8\n";}
-
-$a = 'xyz';
-$a x= 2;
-if ($a eq 'xyzxyz') {print "ok 9\n";} else {print "not ok 9\n";}
-$a x= 1;
-if ($a eq 'xyzxyz') {print "ok 10\n";} else {print "not ok 10\n";}
-$a x= 0;
-if ($a eq '') {print "ok 11\n";} else {print "not ok 11\n";}
-
-@x = (1,2,3);
-
-print join('', @x x 4) eq '3333' ? "ok 12\n" : "not ok 12\n";
-print join('', (@x) x 4) eq '123123123123' ? "ok 13\n" : "not ok 13\n";
-print join('', (@x,()) x 4) eq '123123123123' ? "ok 14\n" : "not ok 14\n";
-print join('', (@x,1) x 4) eq '1231123112311231' ? "ok 15\n" : "not ok 15\n";
-print join(':', () x 4) eq '' ? "ok 16\n" : "not ok 16\n";
-print join(':', (9) x 4) eq '9:9:9:9' ? "ok 17\n" : "not ok 17\n";
-print join(':', (9,9) x 4) eq '9:9:9:9:9:9:9:9' ? "ok 18\n" : "not ok 18\n";
-print join('', (split(//,"123")) x 2) eq '123123' ? "ok 19\n" : "not ok 19\n";
diff --git a/gnu/usr.bin/perl/perl/t/op/s.t b/gnu/usr.bin/perl/perl/t/op/s.t
deleted file mode 100755
index 5930020..0000000
--- a/gnu/usr.bin/perl/perl/t/op/s.t
+++ /dev/null
@@ -1,179 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/s.t,v 1.1.1.1 1993/08/23 21:30:01 nate Exp $
-
-print "1..51\n";
-
-$x = 'foo';
-$_ = "x";
-s/x/\$x/;
-print "#1\t:$_: eq :\$x:\n";
-if ($_ eq '$x') {print "ok 1\n";} else {print "not ok 1\n";}
-
-$_ = "x";
-s/x/$x/;
-print "#2\t:$_: eq :foo:\n";
-if ($_ eq 'foo') {print "ok 2\n";} else {print "not ok 2\n";}
-
-$_ = "x";
-s/x/\$x $x/;
-print "#3\t:$_: eq :\$x foo:\n";
-if ($_ eq '$x foo') {print "ok 3\n";} else {print "not ok 3\n";}
-
-$b = 'cd';
-($a = 'abcdef') =~ s'(b${b}e)'\n$1';
-print "#4\t:$1: eq :bcde:\n";
-print "#4\t:$a: eq :a\\n\$1f:\n";
-if ($1 eq 'bcde' && $a eq 'a\n$1f') {print "ok 4\n";} else {print "not ok 4\n";}
-
-$a = 'abacada';
-if (($a =~ s/a/x/g) == 4 && $a eq 'xbxcxdx')
- {print "ok 5\n";} else {print "not ok 5\n";}
-
-if (($a =~ s/a/y/g) == 0 && $a eq 'xbxcxdx')
- {print "ok 6\n";} else {print "not ok 6 $a\n";}
-
-if (($a =~ s/b/y/g) == 1 && $a eq 'xyxcxdx')
- {print "ok 7\n";} else {print "not ok 7 $a\n";}
-
-$_ = 'ABACADA';
-if (/a/i && s///gi && $_ eq 'BCD') {print "ok 8\n";} else {print "not ok 8 $_\n";}
-
-$_ = '\\' x 4;
-if (length($_) == 4) {print "ok 9\n";} else {print "not ok 9\n";}
-s/\\/\\\\/g;
-if ($_ eq '\\' x 8) {print "ok 10\n";} else {print "not ok 10 $_\n";}
-
-$_ = '\/' x 4;
-if (length($_) == 8) {print "ok 11\n";} else {print "not ok 11\n";}
-s/\//\/\//g;
-if ($_ eq '\\//' x 4) {print "ok 12\n";} else {print "not ok 12\n";}
-if (length($_) == 12) {print "ok 13\n";} else {print "not ok 13\n";}
-
-$_ = 'aaaXXXXbbb';
-s/^a//;
-print $_ eq 'aaXXXXbbb' ? "ok 14\n" : "not ok 14\n";
-
-$_ = 'aaaXXXXbbb';
-s/a//;
-print $_ eq 'aaXXXXbbb' ? "ok 15\n" : "not ok 15\n";
-
-$_ = 'aaaXXXXbbb';
-s/^a/b/;
-print $_ eq 'baaXXXXbbb' ? "ok 16\n" : "not ok 16\n";
-
-$_ = 'aaaXXXXbbb';
-s/a/b/;
-print $_ eq 'baaXXXXbbb' ? "ok 17\n" : "not ok 17\n";
-
-$_ = 'aaaXXXXbbb';
-s/aa//;
-print $_ eq 'aXXXXbbb' ? "ok 18\n" : "not ok 18\n";
-
-$_ = 'aaaXXXXbbb';
-s/aa/b/;
-print $_ eq 'baXXXXbbb' ? "ok 19\n" : "not ok 19\n";
-
-$_ = 'aaaXXXXbbb';
-s/b$//;
-print $_ eq 'aaaXXXXbb' ? "ok 20\n" : "not ok 20\n";
-
-$_ = 'aaaXXXXbbb';
-s/b//;
-print $_ eq 'aaaXXXXbb' ? "ok 21\n" : "not ok 21\n";
-
-$_ = 'aaaXXXXbbb';
-s/bb//;
-print $_ eq 'aaaXXXXb' ? "ok 22\n" : "not ok 22\n";
-
-$_ = 'aaaXXXXbbb';
-s/aX/y/;
-print $_ eq 'aayXXXbbb' ? "ok 23\n" : "not ok 23\n";
-
-$_ = 'aaaXXXXbbb';
-s/Xb/z/;
-print $_ eq 'aaaXXXzbb' ? "ok 24\n" : "not ok 24\n";
-
-$_ = 'aaaXXXXbbb';
-s/aaX.*Xbb//;
-print $_ eq 'ab' ? "ok 25\n" : "not ok 25\n";
-
-$_ = 'aaaXXXXbbb';
-s/bb/x/;
-print $_ eq 'aaaXXXXxb' ? "ok 26\n" : "not ok 26\n";
-
-# now for some unoptimized versions of the same.
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/^a//;
-print $_ eq 'aaXXXXbbb' ? "ok 27\n" : "not ok 27\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/a//;
-print $_ eq 'aaXXXXbbb' ? "ok 28\n" : "not ok 28\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/^a/b/;
-print $_ eq 'baaXXXXbbb' ? "ok 29\n" : "not ok 29\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/a/b/;
-print $_ eq 'baaXXXXbbb' ? "ok 30\n" : "not ok 30\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/aa//;
-print $_ eq 'aXXXXbbb' ? "ok 31\n" : "not ok 31\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/aa/b/;
-print $_ eq 'baXXXXbbb' ? "ok 32\n" : "not ok 32\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/b$//;
-print $_ eq 'aaaXXXXbb' ? "ok 33\n" : "not ok 33\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/b//;
-print $_ eq 'aaaXXXXbb' ? "ok 34\n" : "not ok 34\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/bb//;
-print $_ eq 'aaaXXXXb' ? "ok 35\n" : "not ok 35\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/aX/y/;
-print $_ eq 'aayXXXbbb' ? "ok 36\n" : "not ok 36\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/Xb/z/;
-print $_ eq 'aaaXXXzbb' ? "ok 37\n" : "not ok 37\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/aaX.*Xbb//;
-print $_ eq 'ab' ? "ok 38\n" : "not ok 38\n";
-
-$_ = 'aaaXXXXbbb';
-$x ne $x || s/bb/x/;
-print $_ eq 'aaaXXXXxb' ? "ok 39\n" : "not ok 39\n";
-
-$_ = 'abc123xyz';
-s/\d+/$&*2/e; # yields 'abc246xyz'
-print $_ eq 'abc246xyz' ? "ok 40\n" : "not ok 40\n";
-s/\d+/sprintf("%5d",$&)/e; # yields 'abc 246xyz'
-print $_ eq 'abc 246xyz' ? "ok 41\n" : "not ok 41\n";
-s/\w/$& x 2/eg; # yields 'aabbcc 224466xxyyzz'
-print $_ eq 'aabbcc 224466xxyyzz' ? "ok 42\n" : "not ok 42\n";
-
-$_ = "aaaaa";
-print y/a/b/ == 5 ? "ok 43\n" : "not ok 43\n";
-print y/a/b/ == 0 ? "ok 44\n" : "not ok 44\n";
-print y/b// == 5 ? "ok 45\n" : "not ok 45\n";
-print y/b/c/s == 5 ? "ok 46\n" : "not ok 46\n";
-print y/c// == 1 ? "ok 47\n" : "not ok 47\n";
-print y/c//d == 1 ? "ok 48\n" : "not ok 48\n";
-print $_ eq "" ? "ok 49\n" : "not ok 49\n";
-
-$_ = "Now is the %#*! time for all good men...";
-print (($x=(y/a-zA-Z //cd)) == 7 ? "ok 50\n" : "not ok 50\n");
-print y/ / /s == 8 ? "ok 51\n" : "not ok 51\n";
-
diff --git a/gnu/usr.bin/perl/perl/t/op/sleep.t b/gnu/usr.bin/perl/perl/t/op/sleep.t
deleted file mode 100755
index 81113712..0000000
--- a/gnu/usr.bin/perl/perl/t/op/sleep.t
+++ /dev/null
@@ -1,8 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/sleep.t,v 1.1.1.1 1993/08/23 21:30:04 nate Exp $
-
-print "1..1\n";
-
-$x = sleep 2;
-if ($x >= 2 && $x <= 10) {print "ok 1\n";} else {print "not ok 1 $x\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/sort.t b/gnu/usr.bin/perl/perl/t/op/sort.t
deleted file mode 100755
index 4692ee4..0000000
--- a/gnu/usr.bin/perl/perl/t/op/sort.t
+++ /dev/null
@@ -1,48 +0,0 @@
-#!./perl
-
-# $RCSfile: sort.t,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:02 $
-
-print "1..10\n";
-
-sub reverse { $a lt $b ? 1 : $a gt $b ? -1 : 0; }
-
-@harry = ('dog','cat','x','Cain','Abel');
-@george = ('gone','chased','yz','Punished','Axed');
-
-$x = join('', sort @harry);
-print ($x eq 'AbelCaincatdogx' ? "ok 1\n" : "not ok 1\n");
-
-$x = join('', sort reverse @harry);
-print ($x eq 'xdogcatCainAbel' ? "ok 2\n" : "not ok 2\n");
-
-$x = join('', sort @george, 'to', @harry);
-print ($x eq 'AbelAxedCainPunishedcatchaseddoggonetoxyz'?"ok 3\n":"not ok 3\n");
-
-@a = ();
-@b = reverse @a;
-print ("@b" eq "" ? "ok 4\n" : "not ok 4 (@b)\n");
-
-@a = (1);
-@b = reverse @a;
-print ("@b" eq "1" ? "ok 5\n" : "not ok 5 (@b)\n");
-
-@a = (1,2);
-@b = reverse @a;
-print ("@b" eq "2 1" ? "ok 6\n" : "not ok 6 (@b)\n");
-
-@a = (1,2,3);
-@b = reverse @a;
-print ("@b" eq "3 2 1" ? "ok 7\n" : "not ok 7 (@b)\n");
-
-@a = (1,2,3,4);
-@b = reverse @a;
-print ("@b" eq "4 3 2 1" ? "ok 8\n" : "not ok 8 (@b)\n");
-
-@a = (10,2,3,4);
-@b = sort {$a <=> $b;} @a;
-print ("@b" eq "2 3 4 10" ? "ok 9\n" : "not ok 9 (@b)\n");
-
-$sub = 'reverse';
-$x = join('', sort $sub @harry);
-print ($x eq 'xdogcatCainAbel' ? "ok 10\n" : "not ok 10\n");
-
diff --git a/gnu/usr.bin/perl/perl/t/op/split.t b/gnu/usr.bin/perl/perl/t/op/split.t
deleted file mode 100755
index 63bf3c7..0000000
--- a/gnu/usr.bin/perl/perl/t/op/split.t
+++ /dev/null
@@ -1,57 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/split.t,v 1.1.1.1 1993/08/23 21:30:02 nate Exp $
-
-print "1..12\n";
-
-$FS = ':';
-
-$_ = 'a:b:c';
-
-($a,$b,$c) = split($FS,$_);
-
-if (join(';',$a,$b,$c) eq 'a;b;c') {print "ok 1\n";} else {print "not ok 1\n";}
-
-@ary = split(/:b:/);
-if (join("$_",@ary) eq 'aa:b:cc') {print "ok 2\n";} else {print "not ok 2\n";}
-
-$_ = "abc\n";
-@xyz = (@ary = split(//));
-if (join(".",@ary) eq "a.b.c.\n") {print "ok 3\n";} else {print "not ok 3\n";}
-
-$_ = "a:b:c::::";
-@ary = split(/:/);
-if (join(".",@ary) eq "a.b.c") {print "ok 4\n";} else {print "not ok 4\n";}
-
-$_ = join(':',split(' '," a b\tc \t d "));
-if ($_ eq 'a:b:c:d') {print "ok 5\n";} else {print "not ok 5 #$_#\n";}
-
-$_ = join(':',split(/ */,"foo bar bie\tdoll"));
-if ($_ eq "f:o:o:b:a:r:b:i:e:\t:d:o:l:l")
- {print "ok 6\n";} else {print "not ok 6\n";}
-
-$_ = join(':', 'foo', split(/ /,'a b c'), 'bar');
-if ($_ eq "foo:a:b::c:bar") {print "ok 7\n";} else {print "not ok 7 $_\n";}
-
-# Can we say how many fields to split to?
-$_ = join(':', split(' ','1 2 3 4 5 6', 3));
-print $_ eq '1:2:3 4 5 6' ? "ok 8\n" : "not ok 8 $_\n";
-
-# Can we do it as a variable?
-$x = 4;
-$_ = join(':', split(' ','1 2 3 4 5 6', $x));
-print $_ eq '1:2:3:4 5 6' ? "ok 9\n" : "not ok 9 $_\n";
-
-# Does the 999 suppress null field chopping?
-$_ = join(':', split(/:/,'1:2:3:4:5:6:::', 999));
-print $_ eq '1:2:3:4:5:6:::' ? "ok 10\n" : "not ok 10 $_\n";
-
-# Does assignment to a list imply split to one more field than that?
-$foo = `./perl -D1024 -e '(\$a,\$b) = split;' 2>&1`;
-print $foo =~ /DEBUGGING/ || $foo =~ /num\(3\)/ ? "ok 11\n" : "not ok 11\n";
-
-# Can we say how many fields to split to when assigning to a list?
-($a,$b) = split(' ','1 2 3 4 5 6', 2);
-$_ = join(':',$a,$b);
-print $_ eq '1:2 3 4 5 6' ? "ok 12\n" : "not ok 12 $_\n";
-
diff --git a/gnu/usr.bin/perl/perl/t/op/sprintf.t b/gnu/usr.bin/perl/perl/t/op/sprintf.t
deleted file mode 100755
index cdb4af5..0000000
--- a/gnu/usr.bin/perl/perl/t/op/sprintf.t
+++ /dev/null
@@ -1,8 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/sprintf.t,v 1.1.1.1 1993/08/23 21:30:01 nate Exp $
-
-print "1..1\n";
-
-$x = sprintf("%3s %-4s%%foo %5d%c%3.1f","hi",123,456,65,3.0999);
-if ($x eq ' hi 123 %foo 456A3.1') {print "ok 1\n";} else {print "not ok 1 '$x'\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/stat.t b/gnu/usr.bin/perl/perl/t/op/stat.t
deleted file mode 100755
index a5db14f..0000000
--- a/gnu/usr.bin/perl/perl/t/op/stat.t
+++ /dev/null
@@ -1,176 +0,0 @@
-#!./perl
-
-# $RCSfile: stat.t,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:01 $
-
-print "1..56\n";
-
-chop($cwd = `pwd`);
-
-$DEV = `ls -l /dev`;
-
-unlink "Op.stat.tmp";
-open(FOO, ">Op.stat.tmp");
-
-$junk = `ls Op.stat.tmp`; # hack to make Apollo update link count
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat(FOO);
-if ($nlink == 1) {print "ok 1\n";} else {print "not ok 1\n";}
-if ($mtime && $mtime == $ctime) {print "ok 2\n";} else {print "not ok 2\n";}
-
-print FOO "Now is the time for all good men to come to.\n";
-close(FOO);
-
-sleep 2;
-
-`rm -f Op.stat.tmp2; ln Op.stat.tmp Op.stat.tmp2; chmod 644 Op.stat.tmp`;
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat('Op.stat.tmp');
-
-if ($nlink == 2) {print "ok 3\n";} else {print "not ok 3\n";}
-if (($mtime && $mtime != $ctime) || $cwd =~ m#/afs/#) {
- print "ok 4\n";
-}
-else {
- print "not ok 4\n";
-}
-print "#4 :$mtime: != :$ctime:\n";
-
-`rm -f Op.stat.tmp`;
-`touch Op.stat.tmp`;
-
-if (-z 'Op.stat.tmp') {print "ok 5\n";} else {print "not ok 5\n";}
-if (! -s 'Op.stat.tmp') {print "ok 6\n";} else {print "not ok 6\n";}
-
-`echo hi >Op.stat.tmp`;
-if (! -z 'Op.stat.tmp') {print "ok 7\n";} else {print "not ok 7\n";}
-if (-s 'Op.stat.tmp') {print "ok 8\n";} else {print "not ok 8\n";}
-
-unlink 'Op.stat.tmp';
-$olduid = $>; # can't test -r if uid == 0
-`echo hi >Op.stat.tmp`;
-chmod 0,'Op.stat.tmp';
-eval '$> = 1;'; # so switch uid (may not be implemented)
-if (!$> || ! -r 'Op.stat.tmp') {print "ok 9\n";} else {print "not ok 9\n";}
-if (!$> || ! -w 'Op.stat.tmp') {print "ok 10\n";} else {print "not ok 10\n";}
-eval '$> = $olduid;'; # switch uid back (may not be implemented)
-print "# olduid=$olduid, newuid=$>\n" unless ($> == $olduid);
-if (! -x 'Op.stat.tmp') {print "ok 11\n";} else {print "not ok 11\n";}
-
-foreach ((12,13,14,15,16,17)) {
- print "ok $_\n"; #deleted tests
-}
-
-chmod 0700,'Op.stat.tmp';
-if (-r 'Op.stat.tmp') {print "ok 18\n";} else {print "not ok 18\n";}
-if (-w 'Op.stat.tmp') {print "ok 19\n";} else {print "not ok 19\n";}
-if (-x 'Op.stat.tmp') {print "ok 20\n";} else {print "not ok 20\n";}
-
-if (-f 'Op.stat.tmp') {print "ok 21\n";} else {print "not ok 21\n";}
-if (! -d 'Op.stat.tmp') {print "ok 22\n";} else {print "not ok 22\n";}
-
-if (-d '.') {print "ok 23\n";} else {print "not ok 23\n";}
-if (! -f '.') {print "ok 24\n";} else {print "not ok 24\n";}
-
-if (`ls -l perl` =~ /^l.*->/) {
- if (-l 'perl') {print "ok 25\n";} else {print "not ok 25\n";}
-}
-else {
- print "ok 25\n";
-}
-
-if (-o 'Op.stat.tmp') {print "ok 26\n";} else {print "not ok 26\n";}
-
-if (-e 'Op.stat.tmp') {print "ok 27\n";} else {print "not ok 27\n";}
-`rm -f Op.stat.tmp Op.stat.tmp2`;
-if (! -e 'Op.stat.tmp') {print "ok 28\n";} else {print "not ok 28\n";}
-
-if ($DEV !~ /\nc.* (\S+)\n/)
- {print "ok 29\n";}
-elsif (-c "/dev/$1")
- {print "ok 29\n";}
-else
- {print "not ok 29\n";}
-if (! -c '.') {print "ok 30\n";} else {print "not ok 30\n";}
-
-if ($DEV !~ /\ns.* (\S+)\n/)
- {print "ok 31\n";}
-elsif (-S "/dev/$1")
- {print "ok 31\n";}
-else
- {print "not ok 31\n";}
-if (! -S '.') {print "ok 32\n";} else {print "not ok 32\n";}
-
-if ($DEV !~ /\nb.* (\S+)\n/)
- {print "ok 33\n";}
-elsif (-b "/dev/$1")
- {print "ok 33\n";}
-else
- {print "not ok 33\n";}
-if (! -b '.') {print "ok 34\n";} else {print "not ok 34\n";}
-
-$cnt = $uid = 0;
-
-die "Can't run op/stat.t test 35 without pwd working" unless $cwd;
-chdir '/usr/bin' || die "Can't cd to /usr/bin";
-while (defined($_ = <*>)) {
- $cnt++;
- $uid++ if -u;
- last if $uid && $uid < $cnt;
-}
-chdir $cwd || die "Can't cd back to $cwd";
-
-# I suppose this is going to fail somewhere...
-if ($uid > 0 && $uid < $cnt) {print "ok 35\n";} else {print "not ok 35\n";}
-
-unless (open(tty,"/dev/tty")) {
- print STDERR "Can't open /dev/tty--run t/TEST outside of make.\n";
-}
-if (-t tty) {print "ok 36\n";} else {print "not ok 36\n";}
-if (-c tty) {print "ok 37\n";} else {print "not ok 37\n";}
-close(tty);
-if (! -t tty) {print "ok 38\n";} else {print "not ok 38\n";}
-open(null,"/dev/null");
-if (! -t null || -e '/xenix') {print "ok 39\n";} else {print "not ok 39\n";}
-close(null);
-if (-t) {print "ok 40\n";} else {print "not ok 40\n";}
-
-# These aren't strictly "stat" calls, but so what?
-
-if (-T 'op/stat.t') {print "ok 41\n";} else {print "not ok 41\n";}
-if (! -B 'op/stat.t') {print "ok 42\n";} else {print "not ok 42\n";}
-
-if (-B './perl') {print "ok 43\n";} else {print "not ok 43\n";}
-if (! -T './perl') {print "ok 44\n";} else {print "not ok 44\n";}
-
-open(FOO,'op/stat.t');
-eval { -T FOO; };
-if ($@ =~ /not implemented/) {
- print "# $@";
- for (45 .. 54) {
- print "ok $_\n";
- }
-}
-else {
- if (-T FOO) {print "ok 45\n";} else {print "not ok 45\n";}
- if (! -B FOO) {print "ok 46\n";} else {print "not ok 46\n";}
- $_ = <FOO>;
- if (/perl/) {print "ok 47\n";} else {print "not ok 47\n";}
- if (-T FOO) {print "ok 48\n";} else {print "not ok 48\n";}
- if (! -B FOO) {print "ok 49\n";} else {print "not ok 49\n";}
- close(FOO);
-
- open(FOO,'op/stat.t');
- $_ = <FOO>;
- if (/perl/) {print "ok 50\n";} else {print "not ok 50\n";}
- if (-T FOO) {print "ok 51\n";} else {print "not ok 51\n";}
- if (! -B FOO) {print "ok 52\n";} else {print "not ok 52\n";}
- seek(FOO,0,0);
- if (-T FOO) {print "ok 53\n";} else {print "not ok 53\n";}
- if (! -B FOO) {print "ok 54\n";} else {print "not ok 54\n";}
-}
-close(FOO);
-
-if (-T '/dev/null') {print "ok 55\n";} else {print "not ok 55\n";}
-if (-B '/dev/null') {print "ok 56\n";} else {print "not ok 56\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/study.t b/gnu/usr.bin/perl/perl/t/op/study.t
deleted file mode 100755
index a0fdc4c..0000000
--- a/gnu/usr.bin/perl/perl/t/op/study.t
+++ /dev/null
@@ -1,69 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/study.t,v 1.1.1.1 1993/08/23 21:30:02 nate Exp $
-
-print "1..24\n";
-
-$x = "abc\ndef\n";
-study($x);
-
-if ($x =~ /^abc/) {print "ok 1\n";} else {print "not ok 1\n";}
-if ($x !~ /^def/) {print "ok 2\n";} else {print "not ok 2\n";}
-
-$* = 1;
-if ($x =~ /^def/) {print "ok 3\n";} else {print "not ok 3\n";}
-$* = 0;
-
-$_ = '123';
-study;
-if (/^([0-9][0-9]*)/) {print "ok 4\n";} else {print "not ok 4\n";}
-
-if ($x =~ /^xxx/) {print "not ok 5\n";} else {print "ok 5\n";}
-if ($x !~ /^abc/) {print "not ok 6\n";} else {print "ok 6\n";}
-
-if ($x =~ /def/) {print "ok 7\n";} else {print "not ok 7\n";}
-if ($x !~ /def/) {print "not ok 8\n";} else {print "ok 8\n";}
-
-study($x);
-if ($x !~ /.def/) {print "ok 9\n";} else {print "not ok 9\n";}
-if ($x =~ /.def/) {print "not ok 10\n";} else {print "ok 10\n";}
-
-if ($x =~ /\ndef/) {print "ok 11\n";} else {print "not ok 11\n";}
-if ($x !~ /\ndef/) {print "not ok 12\n";} else {print "ok 12\n";}
-
-$_ = 'aaabbbccc';
-study;
-if (/(a*b*)(c*)/ && $1 eq 'aaabbb' && $2 eq 'ccc') {
- print "ok 13\n";
-} else {
- print "not ok 13\n";
-}
-if (/(a+b+c+)/ && $1 eq 'aaabbbccc') {
- print "ok 14\n";
-} else {
- print "not ok 14\n";
-}
-
-if (/a+b?c+/) {print "not ok 15\n";} else {print "ok 15\n";}
-
-$_ = 'aaabccc';
-study;
-if (/a+b?c+/) {print "ok 16\n";} else {print "not ok 16\n";}
-if (/a*b+c*/) {print "ok 17\n";} else {print "not ok 17\n";}
-
-$_ = 'aaaccc';
-study;
-if (/a*b?c*/) {print "ok 18\n";} else {print "not ok 18\n";}
-if (/a*b+c*/) {print "not ok 19\n";} else {print "ok 19\n";}
-
-$_ = 'abcdef';
-study;
-if (/bcd|xyz/) {print "ok 20\n";} else {print "not ok 20\n";}
-if (/xyz|bcd/) {print "ok 21\n";} else {print "not ok 21\n";}
-
-if (m|bc/*d|) {print "ok 22\n";} else {print "not ok 22\n";}
-
-if (/^$_$/) {print "ok 23\n";} else {print "not ok 23\n";}
-
-$* = 1; # test 3 only tested the optimized version--this one is for real
-if ("ab\ncd\n" =~ /^cd/) {print "ok 24\n";} else {print "not ok 24\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/substr.t b/gnu/usr.bin/perl/perl/t/op/substr.t
deleted file mode 100755
index 09f312f..0000000
--- a/gnu/usr.bin/perl/perl/t/op/substr.t
+++ /dev/null
@@ -1,47 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/substr.t,v 1.1.1.1 1993/08/23 21:30:01 nate Exp $
-
-print "1..22\n";
-
-$a = 'abcdefxyz';
-
-print (substr($a,0,3) eq 'abc' ? "ok 1\n" : "not ok 1\n");
-print (substr($a,3,3) eq 'def' ? "ok 2\n" : "not ok 2\n");
-print (substr($a,6,999) eq 'xyz' ? "ok 3\n" : "not ok 3\n");
-print (substr($a,999,999) eq '' ? "ok 4\n" : "not ok 4\n");
-print (substr($a,6,-1) eq '' ? "ok 5\n" : "not ok 5\n");
-print (substr($a,-3,1) eq 'x' ? "ok 6\n" : "not ok 6\n");
-
-$[ = 1;
-
-print (substr($a,1,3) eq 'abc' ? "ok 7\n" : "not ok 7\n");
-print (substr($a,4,3) eq 'def' ? "ok 8\n" : "not ok 8\n");
-print (substr($a,7,999) eq 'xyz' ? "ok 9\n" : "not ok 9\n");
-print (substr($a,999,999) eq '' ? "ok 10\n" : "not ok 10\n");
-print (substr($a,7,-1) eq '' ? "ok 11\n" : "not ok 11\n");
-print (substr($a,-3,1) eq 'x' ? "ok 12\n" : "not ok 12\n");
-
-$[ = 0;
-
-substr($a,3,3) = 'XYZ';
-print $a eq 'abcXYZxyz' ? "ok 13\n" : "not ok 13\n";
-substr($a,0,2) = '';
-print $a eq 'cXYZxyz' ? "ok 14\n" : "not ok 14\n";
-y/a/a/;
-substr($a,0,0) = 'ab';
-print $a eq 'abcXYZxyz' ? "ok 15\n" : "not ok 15 $a\n";
-substr($a,0,0) = '12345678';
-print $a eq '12345678abcXYZxyz' ? "ok 16\n" : "not ok 16\n";
-substr($a,-3,3) = 'def';
-print $a eq '12345678abcXYZdef' ? "ok 17\n" : "not ok 17\n";
-substr($a,-3,3) = '<';
-print $a eq '12345678abcXYZ<' ? "ok 18\n" : "not ok 18\n";
-substr($a,-1,1) = '12345678';
-print $a eq '12345678abcXYZ12345678' ? "ok 19\n" : "not ok 19\n";
-
-$a = 'abcdefxyz';
-
-print (substr($a,6) eq 'xyz' ? "ok 20\n" : "not ok 20\n");
-print (substr($a,-3) eq 'xyz' ? "ok 21\n" : "not ok 21\n");
-print (substr($a,999) eq '' ? "ok 22\n" : "not ok 22\n");
diff --git a/gnu/usr.bin/perl/perl/t/op/time.t b/gnu/usr.bin/perl/perl/t/op/time.t
deleted file mode 100755
index f8e5545..0000000
--- a/gnu/usr.bin/perl/perl/t/op/time.t
+++ /dev/null
@@ -1,43 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/time.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-print "1..5\n";
-
-($beguser,$begsys) = times;
-
-$beg = time;
-
-while (($now = time) == $beg) {}
-
-if ($now > $beg && $now - $beg < 10){print "ok 1\n";} else {print "not ok 1\n";}
-
-for ($i = 0; $i < 100000; $i++) {
- ($nowuser, $nowsys) = times;
- $i = 200000 if $nowuser > $beguser && $nowsys > $begsys;
- last if time - $beg > 20;
-}
-
-if ($i >= 200000) {print "ok 2\n";} else {print "not ok 2\n";}
-
-($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
-($xsec,$foo) = localtime($now);
-$localyday = $yday;
-
-if ($sec != $xsec && $mday && $year)
- {print "ok 3\n";}
-else
- {print "not ok 3\n";}
-
-($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($beg);
-($xsec,$foo) = localtime($now);
-
-if ($sec != $xsec && $mday && $year)
- {print "ok 4\n";}
-else
- {print "not ok 4\n";}
-
-if (index(" :0:1:-1:365:366:-365:-366:",':' . ($localyday - $yday) . ':') > 0)
- {print "ok 5\n";}
-else
- {print "not ok 5\n";}
diff --git a/gnu/usr.bin/perl/perl/t/op/undef.t b/gnu/usr.bin/perl/perl/t/op/undef.t
deleted file mode 100755
index b4827db..0000000
--- a/gnu/usr.bin/perl/perl/t/op/undef.t
+++ /dev/null
@@ -1,56 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/undef.t,v 1.1.1.1 1993/08/23 21:30:02 nate Exp $
-
-print "1..21\n";
-
-print defined($a) ? "not ok 1\n" : "ok 1\n";
-
-$a = 1+1;
-print defined($a) ? "ok 2\n" : "not ok 2\n";
-
-undef $a;
-print defined($a) ? "not ok 3\n" : "ok 3\n";
-
-$a = "hi";
-print defined($a) ? "ok 4\n" : "not ok 4\n";
-
-$a = $b;
-print defined($a) ? "not ok 5\n" : "ok 5\n";
-
-@ary = ("1arg");
-$a = pop(@ary);
-print defined($a) ? "ok 6\n" : "not ok 6\n";
-$a = pop(@ary);
-print defined($a) ? "not ok 7\n" : "ok 7\n";
-
-@ary = ("1arg");
-$a = shift(@ary);
-print defined($a) ? "ok 8\n" : "not ok 8\n";
-$a = shift(@ary);
-print defined($a) ? "not ok 9\n" : "ok 9\n";
-
-$ary{'foo'} = 'hi';
-print defined($ary{'foo'}) ? "ok 10\n" : "not ok 10\n";
-print defined($ary{'bar'}) ? "not ok 11\n" : "ok 11\n";
-undef $ary{'foo'};
-print defined($ary{'foo'}) ? "not ok 12\n" : "ok 12\n";
-
-print defined(@ary) ? "ok 13\n" : "not ok 13\n";
-print defined(%ary) ? "ok 14\n" : "not ok 14\n";
-undef @ary;
-print defined(@ary) ? "not ok 15\n" : "ok 15\n";
-undef %ary;
-print defined(%ary) ? "not ok 16\n" : "ok 16\n";
-@ary = (1);
-print defined @ary ? "ok 17\n" : "not ok 17\n";
-%ary = (1,1);
-print defined %ary ? "ok 18\n" : "not ok 18\n";
-
-sub foo { print "ok 19\n"; }
-
-&foo || print "not ok 19\n";
-
-print defined &foo ? "ok 20\n" : "not ok 20\n";
-undef &foo;
-print defined(&foo) ? "not ok 21\n" : "ok 21\n";
diff --git a/gnu/usr.bin/perl/perl/t/op/unshift.t b/gnu/usr.bin/perl/perl/t/op/unshift.t
deleted file mode 100755
index 53d7388..0000000
--- a/gnu/usr.bin/perl/perl/t/op/unshift.t
+++ /dev/null
@@ -1,14 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/unshift.t,v 1.1.1.1 1993/08/23 21:30:02 nate Exp $
-
-print "1..2\n";
-
-@a = (1,2,3);
-$cnt1 = unshift(a,0);
-
-if (join(' ',@a) eq '0 1 2 3') {print "ok 1\n";} else {print "not ok 1\n";}
-$cnt2 = unshift(a,3,2,1);
-if (join(' ',@a) eq '3 2 1 0 1 2 3') {print "ok 2\n";} else {print "not ok 2\n";}
-
-
diff --git a/gnu/usr.bin/perl/perl/t/op/vec.t b/gnu/usr.bin/perl/perl/t/op/vec.t
deleted file mode 100755
index 5134476..0000000
--- a/gnu/usr.bin/perl/perl/t/op/vec.t
+++ /dev/null
@@ -1,24 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/vec.t,v 1.1.1.1 1993/08/23 21:30:03 nate Exp $
-
-print "1..13\n";
-
-print vec($foo,0,1) == 0 ? "ok 1\n" : "not ok 1\n";
-print length($foo) == 0 ? "ok 2\n" : "not ok 2\n";
-vec($foo,0,1) = 1;
-print length($foo) == 1 ? "ok 3\n" : "not ok 3\n";
-print ord($foo) == 1 ? "ok 4\n" : "not ok 4\n";
-print vec($foo,0,1) == 1 ? "ok 5\n" : "not ok 5\n";
-
-print vec($foo,20,1) == 0 ? "ok 6\n" : "not ok 6\n";
-vec($foo,20,1) = 1;
-print vec($foo,20,1) == 1 ? "ok 7\n" : "not ok 7\n";
-print length($foo) == 3 ? "ok 8\n" : "not ok 8\n";
-print vec($foo,1,8) == 0 ? "ok 9\n" : "not ok 9\n";
-vec($foo,1,8) = 0xf1;
-print vec($foo,1,8) == 0xf1 ? "ok 10\n" : "not ok 10\n";
-print ((ord(substr($foo,1,1)) & 255) == 0xf1 ? "ok 11\n" : "not ok 11\n");
-print vec($foo,2,4) == 1 ? "ok 12\n" : "not ok 12\n";
-print vec($foo,3,4) == 15 ? "ok 13\n" : "not ok 13\n";
-
diff --git a/gnu/usr.bin/perl/perl/t/op/write.t b/gnu/usr.bin/perl/perl/t/op/write.t
deleted file mode 100755
index d17f195..0000000
--- a/gnu/usr.bin/perl/perl/t/op/write.t
+++ /dev/null
@@ -1,129 +0,0 @@
-#!./perl
-
-# $Header: /home/cvs/386BSD/ports/lang/perl/t/op/write.t,v 1.1.1.1 1993/08/23 21:30:02 nate Exp $
-
-print "1..3\n";
-
-format OUT =
-the quick brown @<<
-$fox
-jumped
-@*
-$multiline
-^<<<<<<<<<
-$foo
-^<<<<<<<<<
-$foo
-^<<<<<<...
-$foo
-now @<<the@>>>> for all@|||||men to come @<<<<
-'i' . 's', "time\n", $good, 'to'
-.
-
-open(OUT, '>Op.write.tmp') || die "Can't create Op.write.tmp";
-
-$fox = 'foxiness';
-$good = 'good';
-$multiline = "forescore\nand\nseven years\n";
-$foo = 'when in the course of human events it becomes necessary';
-write(OUT);
-close OUT;
-
-$right =
-"the quick brown fox
-jumped
-forescore
-and
-seven years
-when in
-the course
-of huma...
-now is the time for all good men to come to\n";
-
-if (`cat Op.write.tmp` eq $right)
- { print "ok 1\n"; unlink 'Op.write.tmp'; }
-else
- { print "not ok 1\n"; }
-
-format OUT2 =
-the quick brown @<<
-$fox
-jumped
-@*
-$multiline
-^<<<<<<<<< ~~
-$foo
-now @<<the@>>>> for all@|||||men to come @<<<<
-'i' . 's', "time\n", $good, 'to'
-.
-
-open(OUT2, '>Op.write.tmp') || die "Can't create Op.write.tmp";
-
-$fox = 'foxiness';
-$good = 'good';
-$multiline = "forescore\nand\nseven years\n";
-$foo = 'when in the course of human events it becomes necessary';
-write(OUT2);
-close OUT2;
-
-$right =
-"the quick brown fox
-jumped
-forescore
-and
-seven years
-when in
-the course
-of human
-events it
-becomes
-necessary
-now is the time for all good men to come to\n";
-
-if (`cat Op.write.tmp` eq $right)
- { print "ok 2\n"; unlink 'Op.write.tmp'; }
-else
- { print "not ok 2\n"; }
-
-eval <<'EOFORMAT';
-format OUT2 =
-the brown quick @<<
-$fox
-jumped
-@*
-$multiline
-^<<<<<<<<< ~~
-$foo
-now @<<the@>>>> for all@|||||men to come @<<<<
-'i' . 's', "time\n", $good, 'to'
-.
-EOFORMAT
-
-open(OUT2, '>Op.write.tmp') || die "Can't create Op.write.tmp";
-
-$fox = 'foxiness';
-$good = 'good';
-$multiline = "forescore\nand\nseven years\n";
-$foo = 'when in the course of human events it becomes necessary';
-write(OUT2);
-close OUT2;
-
-$right =
-"the brown quick fox
-jumped
-forescore
-and
-seven years
-when in
-the course
-of human
-events it
-becomes
-necessary
-now is the time for all good men to come to\n";
-
-if (`cat Op.write.tmp` eq $right)
- { print "ok 3\n"; unlink 'Op.write.tmp'; }
-else
- { print "not ok 3\n"; }
-
diff --git a/gnu/usr.bin/perl/perl/t/printme b/gnu/usr.bin/perl/perl/t/printme
deleted file mode 100644
index feefccb2..0000000
--- a/gnu/usr.bin/perl/perl/t/printme
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-print "Hello World\n";
-
diff --git a/gnu/usr.bin/perl/perl/tdoio.c b/gnu/usr.bin/perl/perl/tdoio.c
deleted file mode 100644
index cd5d480..0000000
--- a/gnu/usr.bin/perl/perl/tdoio.c
+++ /dev/null
@@ -1,2972 +0,0 @@
-/* $RCSfile: tdoio.c,v $$Revision: 1.2 $$Date: 1995/05/30 05:03:23 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: tdoio.c,v $
- * Revision 1.2 1995/05/30 05:03:23 rgrimes
- * Remove trailing whitespace.
- *
- * Revision 1.1.1.1 1994/09/10 06:27:36 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.2 1994/03/09 22:24:27 ache
- * (cast) added for last argument of semctl
- *
- * Revision 1.1.1.1 1993/08/23 21:29:36 nate
- * PERL!
- *
- * Revision 4.0.1.6 92/06/11 21:08:16 lwall
- * patch34: some systems don't declare h_errno extern in header files
- *
- * Revision 4.0.1.5 92/06/08 13:00:21 lwall
- * patch20: some machines don't define ENOTSOCK in errno.h
- * patch20: new warnings for failed use of stat operators on filenames with \n
- * patch20: wait failed when STDOUT or STDERR reopened to a pipe
- * patch20: end of file latch not reset on reopen of STDIN
- * patch20: seek(HANDLE, 0, 1) went to eof because of ancient Ultrix workaround
- * patch20: fixed memory leak on system() for vfork() machines
- * patch20: get*by* routines now return something useful in a scalar context
- * patch20: h_errno now accessible via $?
- *
- * Revision 4.0.1.4 91/11/05 16:51:43 lwall
- * patch11: prepared for ctype implementations that don't define isascii()
- * patch11: perl mistook some streams for sockets because they return mode 0 too
- * patch11: reopening STDIN, STDOUT and STDERR failed on some machines
- * patch11: certain perl errors should set EBADF so that $! looks better
- * patch11: truncate on a closed filehandle could dump
- * patch11: stats of _ forgot whether prior stat was actually lstat
- * patch11: -T returned true on NFS directory
- *
- * Revision 4.0.1.3 91/06/10 01:21:19 lwall
- * patch10: read didn't work from character special files open for writing
- * patch10: close-on-exec wrongly set on system file descriptors
- *
- * Revision 4.0.1.2 91/06/07 10:53:39 lwall
- * patch4: new copyright notice
- * patch4: system fd's are now treated specially
- * patch4: added $^F variable to specify maximum system fd, default 2
- * patch4: character special files now opened with bidirectional stdio buffers
- * patch4: taintchecks could improperly modify parent in vfork()
- * patch4: many, many itty-bitty portability fixes
- *
- * Revision 4.0.1.1 91/04/11 17:41:06 lwall
- * patch1: hopefully straightened out some of the Xenix mess
- *
- * Revision 4.0 91/03/20 01:07:06 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-#include <unistd.h>
-#include <stdio.h>
-
-#ifdef HAS_SOCKET
-#include <sys/socket.h>
-#include <netdb.h>
-#ifndef ENOTSOCK
-#include <net/errno.h>
-#endif
-#endif
-
-#ifdef HAS_SELECT
-#ifdef I_SYS_SELECT
-#ifndef I_SYS_TIME
-#include <sys/select.h>
-#endif
-#endif
-#endif
-
-#ifdef HOST_NOT_FOUND
-extern int h_errno;
-#endif
-
-#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
-#include <sys/ipc.h>
-#ifdef HAS_MSG
-#include <sys/msg.h>
-#endif
-#ifdef HAS_SEM
-#include <sys/sem.h>
-#endif
-#ifdef HAS_SHM
-#include <sys/shm.h>
-#endif
-#endif
-
-#ifdef I_PWD
-#include <pwd.h>
-#endif
-#ifdef I_GRP
-#include <grp.h>
-#endif
-#ifdef I_UTIME
-#include <utime.h>
-#endif
-#ifdef I_FCNTL
-#include <fcntl.h>
-#endif
-#ifdef I_SYS_FILE
-#include <sys/file.h>
-#endif
-
-int laststatval = -1;
-int laststype = O_STAT;
-
-static char* warn_nl = "Unsuccessful %s on filename containing newline";
-
-bool
-do_open(stab,name,len)
-STAB *stab;
-register char *name;
-int len;
-{
- FILE *fp;
- register STIO *stio = stab_io(stab);
- char *myname = savestr(name);
- int result;
- int fd;
- int writing = 0;
- char mode[3]; /* stdio file mode ("r\0" or "r+\0") */
- FILE *saveifp = Nullfp;
- FILE *saveofp = Nullfp;
- char savetype = ' ';
-
- mode[0] = mode[1] = mode[2] = '\0';
- name = myname;
- forkprocess = 1; /* assume true if no fork */
- while (len && isSPACE(name[len-1]))
- name[--len] = '\0';
- if (!stio)
- stio = stab_io(stab) = stio_new();
- else if (stio->ifp) {
- fd = fileno(stio->ifp);
- if (stio->type == '-')
- result = 0;
- else if (fd <= maxsysfd) {
- saveifp = stio->ifp;
- saveofp = stio->ofp;
- savetype = stio->type;
- result = 0;
- }
- else if (stio->type == '|')
- result = mypclose(stio->ifp);
- else if (stio->ifp != stio->ofp) {
- if (stio->ofp) {
- result = fclose(stio->ofp);
- fclose(stio->ifp); /* clear stdio, fd already closed */
- }
- else
- result = fclose(stio->ifp);
- }
- else
- result = fclose(stio->ifp);
- if (result == EOF && fd > maxsysfd)
- fprintf(stderr,"Warning: unable to close filehandle %s properly.\n",
- stab_ename(stab));
- stio->ofp = stio->ifp = Nullfp;
- }
- if (*name == '+' && len > 1 && name[len-1] != '|') { /* scary */
- mode[1] = *name++;
- mode[2] = '\0';
- --len;
- writing = 1;
- }
- else {
- mode[1] = '\0';
- }
- stio->type = *name;
- if (*name == '|') {
- /*SUPPRESS 530*/
- for (name++; isSPACE(*name); name++) ;
-#ifdef TAINT
- taintenv();
- taintproper("Insecure dependency in piped open");
-#endif
- fp = mypopen(name,"w");
- writing = 1;
- }
- else if (*name == '>') {
-#ifdef TAINT
- taintproper("Insecure dependency in open");
-#endif
- name++;
- if (*name == '>') {
- mode[0] = stio->type = 'a';
- name++;
- }
- else
- mode[0] = 'w';
- writing = 1;
- if (*name == '&') {
- duplicity:
- name++;
- while (isSPACE(*name))
- name++;
- if (isDIGIT(*name))
- fd = atoi(name);
- else {
- stab = stabent(name,FALSE);
- if (!stab || !stab_io(stab)) {
-#ifdef EINVAL
- errno = EINVAL;
-#endif
- goto say_false;
- }
- if (stab_io(stab) && stab_io(stab)->ifp) {
- fd = fileno(stab_io(stab)->ifp);
- if (stab_io(stab)->type == 's')
- stio->type = 's';
- }
- else
- fd = -1;
- }
- if (!(fp = fdopen(fd = dup(fd),mode))) {
- close(fd);
- }
- }
- else {
- while (isSPACE(*name))
- name++;
- if (strEQ(name,"-")) {
- fp = stdout;
- stio->type = '-';
- }
- else {
- fp = fopen(name,mode);
- }
- }
- }
- else {
- if (*name == '<') {
- mode[0] = 'r';
- name++;
- while (isSPACE(*name))
- name++;
- if (*name == '&')
- goto duplicity;
- if (strEQ(name,"-")) {
- fp = stdin;
- stio->type = '-';
- }
- else
- fp = fopen(name,mode);
- }
- else if (name[len-1] == '|') {
-#ifdef TAINT
- taintenv();
- taintproper("Insecure dependency in piped open");
-#endif
- name[--len] = '\0';
- while (len && isSPACE(name[len-1]))
- name[--len] = '\0';
- /*SUPPRESS 530*/
- for (; isSPACE(*name); name++) ;
- fp = mypopen(name,"r");
- stio->type = '|';
- }
- else {
- stio->type = '<';
- /*SUPPRESS 530*/
- for (; isSPACE(*name); name++) ;
- if (strEQ(name,"-")) {
- fp = stdin;
- stio->type = '-';
- }
- else
- fp = fopen(name,"r");
- }
- }
- if (!fp) {
- if (dowarn && stio->type == '<' && index(name, '\n'))
- warn(warn_nl, "open");
- Safefree(myname);
- goto say_false;
- }
- Safefree(myname);
- if (stio->type &&
- stio->type != '|' && stio->type != '-') {
- if (fstat(fileno(fp),&statbuf) < 0) {
- (void)fclose(fp);
- goto say_false;
- }
- if (S_ISSOCK(statbuf.st_mode))
- stio->type = 's'; /* in case a socket was passed in to us */
-#ifdef HAS_SOCKET
- else if (
-#ifdef S_IFMT
- !(statbuf.st_mode & S_IFMT)
-#else
- !statbuf.st_mode
-#endif
- ) {
- int buflen = sizeof tokenbuf;
- if (getsockname(fileno(fp), tokenbuf, &buflen) >= 0
- || errno != ENOTSOCK)
- stio->type = 's'; /* some OS's return 0 on fstat()ed socket */
- /* but some return 0 for streams too, sigh */
- }
-#endif
- }
- if (saveifp) { /* must use old fp? */
- fd = fileno(saveifp);
- if (saveofp) {
- fflush(saveofp); /* emulate fclose() */
- if (saveofp != saveifp) { /* was a socket? */
- fclose(saveofp);
- if (fd > 2)
- Safefree(saveofp);
- }
- }
- if (fd != fileno(fp)) {
- int pid;
- STR *str;
-
- dup2(fileno(fp), fd);
- str = afetch(fdpid,fileno(fp),TRUE);
- pid = str->str_u.str_useful;
- str->str_u.str_useful = 0;
- str = afetch(fdpid,fd,TRUE);
- str->str_u.str_useful = pid;
- fclose(fp);
-
- }
- fp = saveifp;
- clearerr(fp);
- }
-#if defined(HAS_FCNTL) && defined(F_SETFD)
- fd = fileno(fp);
- fcntl(fd,F_SETFD,fd > maxsysfd);
-#endif
- stio->ifp = fp;
- if (writing) {
- if (stio->type == 's'
- || (stio->type == '>' && S_ISCHR(statbuf.st_mode)) ) {
- if (!(stio->ofp = fdopen(fileno(fp),"w"))) {
- fclose(fp);
- stio->ifp = Nullfp;
- goto say_false;
- }
- }
- else
- stio->ofp = fp;
- }
- return TRUE;
-
-say_false:
- stio->ifp = saveifp;
- stio->ofp = saveofp;
- stio->type = savetype;
- return FALSE;
-}
-
-FILE *
-nextargv(stab)
-register STAB *stab;
-{
- register STR *str;
-#ifndef FLEXFILENAMES
- int filedev;
- int fileino;
-#endif
- int fileuid;
- int filegid;
- static int filemode = 0;
- static int lastfd;
- static char *oldname;
-
- if (!argvoutstab)
- argvoutstab = stabent("ARGVOUT",TRUE);
- if (filemode & (S_ISUID|S_ISGID)) {
- fflush(stab_io(argvoutstab)->ifp); /* chmod must follow last write */
-#ifdef HAS_FCHMOD
- (void)fchmod(lastfd,filemode);
-#else
- (void)chmod(oldname,filemode);
-#endif
- }
- filemode = 0;
- while (alen(stab_xarray(stab)) >= 0) {
- str = ashift(stab_xarray(stab));
- str_sset(stab_val(stab),str);
- STABSET(stab_val(stab));
- oldname = str_get(stab_val(stab));
- if (do_open(stab,oldname,stab_val(stab)->str_cur)) {
- if (inplace) {
-#ifdef TAINT
- taintproper("Insecure dependency in inplace open");
-#endif
- if (strEQ(oldname,"-")) {
- str_free(str);
- defoutstab = stabent("STDOUT",TRUE);
- return stab_io(stab)->ifp;
- }
-#ifndef FLEXFILENAMES
- filedev = statbuf.st_dev;
- fileino = statbuf.st_ino;
-#endif
- filemode = statbuf.st_mode;
- fileuid = statbuf.st_uid;
- filegid = statbuf.st_gid;
- if (!S_ISREG(filemode)) {
- warn("Can't do inplace edit: %s is not a regular file",
- oldname );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
- if (*inplace) {
-#ifdef SUFFIX
- add_suffix(str,inplace);
-#else
- str_cat(str,inplace);
-#endif
-#ifndef FLEXFILENAMES
- if (stat(str->str_ptr,&statbuf) >= 0
- && statbuf.st_dev == filedev
- && statbuf.st_ino == fileino ) {
- warn("Can't do inplace edit: %s > 14 characters",
- str->str_ptr );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
-#endif
-#ifdef HAS_RENAME
-#ifndef DOSISH
- if (rename(oldname,str->str_ptr) < 0) {
- warn("Can't rename %s to %s: %s, skipping file",
- oldname, str->str_ptr, strerror(errno) );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
-#else
- do_close(stab,FALSE);
- (void)unlink(str->str_ptr);
- (void)rename(oldname,str->str_ptr);
- do_open(stab,str->str_ptr,stab_val(stab)->str_cur);
-#endif /* MSDOS */
-#else
- (void)UNLINK(str->str_ptr);
- if (link(oldname,str->str_ptr) < 0) {
- warn("Can't rename %s to %s: %s, skipping file",
- oldname, str->str_ptr, strerror(errno) );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
- (void)UNLINK(oldname);
-#endif
- }
- else {
-#ifndef DOSISH
- if (UNLINK(oldname) < 0) {
- warn("Can't rename %s to %s: %s, skipping file",
- oldname, str->str_ptr, strerror(errno) );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
-#else
- fatal("Can't do inplace edit without backup");
-#endif
- }
-
- str_nset(str,">",1);
- str_cat(str,oldname);
- errno = 0; /* in case sprintf set errno */
- if (!do_open(argvoutstab,str->str_ptr,str->str_cur)) {
- warn("Can't do inplace edit on %s: %s",
- oldname, strerror(errno) );
- do_close(stab,FALSE);
- str_free(str);
- continue;
- }
- defoutstab = argvoutstab;
- lastfd = fileno(stab_io(argvoutstab)->ifp);
- (void)fstat(lastfd,&statbuf);
-#ifdef HAS_FCHMOD
- (void)fchmod(lastfd,filemode);
-#else
- (void)chmod(oldname,filemode);
-#endif
- if (fileuid != statbuf.st_uid || filegid != statbuf.st_gid) {
-#ifdef HAS_FCHOWN
- (void)fchown(lastfd,fileuid,filegid);
-#else
-#ifdef HAS_CHOWN
- (void)chown(oldname,fileuid,filegid);
-#endif
-#endif
- }
- }
- str_free(str);
- return stab_io(stab)->ifp;
- }
- else
- fprintf(stderr,"Can't open %s: %s\n",str_get(str), strerror(errno));
- str_free(str);
- }
- if (inplace) {
- (void)do_close(argvoutstab,FALSE);
- defoutstab = stabent("STDOUT",TRUE);
- }
- return Nullfp;
-}
-
-#ifdef HAS_PIPE
-void
-do_pipe(str, rstab, wstab)
-STR *str;
-STAB *rstab;
-STAB *wstab;
-{
- register STIO *rstio;
- register STIO *wstio;
- int fd[2];
-
- if (!rstab)
- goto badexit;
- if (!wstab)
- goto badexit;
-
- rstio = stab_io(rstab);
- wstio = stab_io(wstab);
-
- if (!rstio)
- rstio = stab_io(rstab) = stio_new();
- else if (rstio->ifp)
- do_close(rstab,FALSE);
- if (!wstio)
- wstio = stab_io(wstab) = stio_new();
- else if (wstio->ifp)
- do_close(wstab,FALSE);
-
- if (pipe(fd) < 0)
- goto badexit;
- rstio->ifp = fdopen(fd[0], "r");
- wstio->ofp = fdopen(fd[1], "w");
- wstio->ifp = wstio->ofp;
- rstio->type = '<';
- wstio->type = '>';
- if (!rstio->ifp || !wstio->ofp) {
- if (rstio->ifp) fclose(rstio->ifp);
- else close(fd[0]);
- if (wstio->ofp) fclose(wstio->ofp);
- else close(fd[1]);
- goto badexit;
- }
-
- str_sset(str,&str_yes);
- return;
-
-badexit:
- str_sset(str,&str_undef);
- return;
-}
-#endif
-
-bool
-do_close(stab,explicit)
-STAB *stab;
-bool explicit;
-{
- bool retval = FALSE;
- register STIO *stio;
- int status;
-
- if (!stab)
- stab = argvstab;
- if (!stab) {
- errno = EBADF;
- return FALSE;
- }
- stio = stab_io(stab);
- if (!stio) { /* never opened */
- if (dowarn && explicit)
- warn("Close on unopened file <%s>",stab_ename(stab));
- return FALSE;
- }
- if (stio->ifp) {
- if (stio->type == '|') {
- status = mypclose(stio->ifp);
- retval = (status == 0);
- statusvalue = (unsigned short)status & 0xffff;
- }
- else if (stio->type == '-')
- retval = TRUE;
- else {
- if (stio->ofp && stio->ofp != stio->ifp) { /* a socket */
- retval = (fclose(stio->ofp) != EOF);
- fclose(stio->ifp); /* clear stdio, fd already closed */
- }
- else
- retval = (fclose(stio->ifp) != EOF);
- }
- stio->ofp = stio->ifp = Nullfp;
- }
- if (explicit)
- stio->lines = 0;
- stio->type = ' ';
- return retval;
-}
-
-bool
-do_eof(stab)
-STAB *stab;
-{
- register STIO *stio;
- int ch;
-
- if (!stab) { /* eof() */
- if (argvstab)
- stio = stab_io(argvstab);
- else
- return TRUE;
- }
- else
- stio = stab_io(stab);
-
- if (!stio)
- return TRUE;
-
- while (stio->ifp) {
-
-#ifdef STDSTDIO /* (the code works without this) */
- if (stio->ifp->_cnt > 0) /* cheat a little, since */
- return FALSE; /* this is the most usual case */
-#endif
-
- ch = getc(stio->ifp);
- if (ch != EOF) {
- (void)ungetc(ch, stio->ifp);
- return FALSE;
- }
-#ifdef STDSTDIO
- if (stio->ifp->_cnt < -1)
- stio->ifp->_cnt = -1;
-#endif
- if (!stab) { /* not necessarily a real EOF yet? */
- if (!nextargv(argvstab)) /* get another fp handy */
- return TRUE;
- }
- else
- return TRUE; /* normal fp, definitely end of file */
- }
- return TRUE;
-}
-
-long
-do_tell(stab)
-STAB *stab;
-{
- register STIO *stio;
-
- if (!stab)
- goto phooey;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto phooey;
-
-#ifdef ULTRIX_STDIO_BOTCH
- if (feof(stio->ifp))
- (void)fseek (stio->ifp, 0L, 2); /* ultrix 1.2 workaround */
-#endif
-
- return ftell(stio->ifp);
-
-phooey:
- if (dowarn)
- warn("tell() on unopened file");
- errno = EBADF;
- return -1L;
-}
-
-bool
-do_seek(stab, pos, whence)
-STAB *stab;
-long pos;
-int whence;
-{
- register STIO *stio;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
-#ifdef ULTRIX_STDIO_BOTCH
- if (feof(stio->ifp))
- (void)fseek (stio->ifp, 0L, 2); /* ultrix 1.2 workaround */
-#endif
-
- return fseek(stio->ifp, pos, whence) >= 0;
-
-nuts:
- if (dowarn)
- warn("seek() on unopened file");
- errno = EBADF;
- return FALSE;
-}
-
-int
-do_ctl(optype,stab,func,argstr)
-int optype;
-STAB *stab;
-int func;
-STR *argstr;
-{
- register STIO *stio;
- register char *s;
- int retval;
-
- if (!stab || !argstr || !(stio = stab_io(stab)) || !stio->ifp) {
- errno = EBADF; /* well, sort of... */
- return -1;
- }
-
- if (argstr->str_pok || !argstr->str_nok) {
- if (!argstr->str_pok)
- s = str_get(argstr);
-
-#ifdef IOCPARM_MASK
-#ifndef IOCPARM_LEN
-#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
-#endif
-#endif
-#ifdef IOCPARM_LEN
- retval = IOCPARM_LEN(func); /* on BSDish systes we're safe */
-#else
- retval = 256; /* otherwise guess at what's safe */
-#endif
- if (argstr->str_cur < retval) {
- Str_Grow(argstr,retval+1);
- argstr->str_cur = retval;
- }
-
- s = argstr->str_ptr;
- s[argstr->str_cur] = 17; /* a little sanity check here */
- }
- else {
- retval = (int)str_gnum(argstr);
-#ifdef DOSISH
- s = (char*)(long)retval; /* ouch */
-#else
- s = (char*)retval; /* ouch */
-#endif
- }
-
-#ifndef lint
- if (optype == O_IOCTL)
- retval = ioctl(fileno(stio->ifp), func, s);
- else
-#ifdef DOSISH
- fatal("fcntl is not implemented");
-#else
-#ifdef HAS_FCNTL
- retval = fcntl(fileno(stio->ifp), func, s);
-#else
- fatal("fcntl is not implemented");
-#endif
-#endif
-#else /* lint */
- retval = 0;
-#endif /* lint */
-
- if (argstr->str_pok) {
- if (s[argstr->str_cur] != 17)
- fatal("Return value overflowed string");
- s[argstr->str_cur] = 0; /* put our null back */
- }
- return retval;
-}
-
-int
-do_stat(str,arg,gimme,arglast)
-STR *str;
-register ARG *arg;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0] + 1;
- int max = 13;
-
- if ((arg[1].arg_type & A_MASK) == A_WORD) {
- tmpstab = arg[1].arg_ptr.arg_stab;
- if (tmpstab != defstab) {
- laststype = O_STAT;
- statstab = tmpstab;
- str_set(statname,"");
- if (!stab_io(tmpstab) || !stab_io(tmpstab)->ifp ||
- fstat(fileno(stab_io(tmpstab)->ifp),&statcache) < 0) {
- max = 0;
- laststatval = -1;
- }
- }
- else if (laststatval < 0)
- max = 0;
- }
- else {
- str_set(statname,str_get(ary->ary_array[sp]));
- statstab = Nullstab;
-#ifdef HAS_LSTAT
- laststype = arg->arg_type;
- if (arg->arg_type == O_LSTAT)
- laststatval = lstat(str_get(statname),&statcache);
- else
-#endif
- laststatval = stat(str_get(statname),&statcache);
- if (laststatval < 0) {
- if (dowarn && index(str_get(statname), '\n'))
- warn(warn_nl, "stat");
- max = 0;
- }
- }
-
- if (gimme != G_ARRAY) {
- if (max)
- str_sset(str,&str_yes);
- else
- str_sset(str,&str_undef);
- STABSET(str);
- ary->ary_array[sp] = str;
- return sp;
- }
- sp--;
- if (max) {
-#ifndef lint
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_dev)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_ino)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_mode)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_nlink)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_uid)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_gid)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_rdev)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_size)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_atime)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_mtime)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_ctime)));
-#ifdef STATBLOCKS
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_blksize)));
- (void)astore(ary,++sp,
- str_2mortal(str_nmake((double)statcache.st_blocks)));
-#else
- (void)astore(ary,++sp,
- str_2mortal(str_make("",0)));
- (void)astore(ary,++sp,
- str_2mortal(str_make("",0)));
-#endif
-#else /* lint */
- (void)astore(ary,++sp,str_nmake(0.0));
-#endif /* lint */
- }
- return sp;
-}
-
-#if !defined(HAS_TRUNCATE) && !defined(HAS_CHSIZE) && defined(F_FREESP)
- /* code courtesy of William Kucharski */
-#define HAS_CHSIZE
-
-int chsize(fd, length)
-int fd; /* file descriptor */
-off_t length; /* length to set file to */
-{
- extern long lseek();
- struct flock fl;
- struct stat filebuf;
-
- if (fstat(fd, &filebuf) < 0)
- return -1;
-
- if (filebuf.st_size < length) {
-
- /* extend file length */
-
- if ((lseek(fd, (length - 1), 0)) < 0)
- return -1;
-
- /* write a "0" byte */
-
- if ((write(fd, "", 1)) != 1)
- return -1;
- }
- else {
- /* truncate length */
-
- fl.l_whence = 0;
- fl.l_len = 0;
- fl.l_start = length;
- fl.l_type = F_WRLCK; /* write lock on file space */
-
- /*
- * This relies on the UNDOCUMENTED F_FREESP argument to
- * fcntl(2), which truncates the file so that it ends at the
- * position indicated by fl.l_start.
- *
- * Will minor miracles never cease?
- */
-
- if (fcntl(fd, F_FREESP, &fl) < 0)
- return -1;
-
- }
-
- return 0;
-}
-#endif /* F_FREESP */
-
-int /*SUPPRESS 590*/
-do_truncate(str,arg,gimme,arglast)
-STR *str;
-register ARG *arg;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0] + 1;
- off_t len = (off_t)str_gnum(ary->ary_array[sp+1]);
- int result = 1;
- STAB *tmpstab;
-
-#if defined(HAS_TRUNCATE) || defined(HAS_CHSIZE)
-#ifdef HAS_TRUNCATE
- if ((arg[1].arg_type & A_MASK) == A_WORD) {
- tmpstab = arg[1].arg_ptr.arg_stab;
- if (!stab_io(tmpstab) || !stab_io(tmpstab)->ifp ||
- ftruncate(fileno(stab_io(tmpstab)->ifp), len) < 0)
- result = 0;
- }
- else if (truncate(str_get(ary->ary_array[sp]), len) < 0)
- result = 0;
-#else
- if ((arg[1].arg_type & A_MASK) == A_WORD) {
- tmpstab = arg[1].arg_ptr.arg_stab;
- if (!stab_io(tmpstab) || !stab_io(tmpstab)->ifp ||
- chsize(fileno(stab_io(tmpstab)->ifp), len) < 0)
- result = 0;
- }
- else {
- int tmpfd;
-
- if ((tmpfd = open(str_get(ary->ary_array[sp]), 0)) < 0)
- result = 0;
- else {
- if (chsize(tmpfd, len) < 0)
- result = 0;
- close(tmpfd);
- }
- }
-#endif
-
- if (result)
- str_sset(str,&str_yes);
- else
- str_sset(str,&str_undef);
- STABSET(str);
- ary->ary_array[sp] = str;
- return sp;
-#else
- fatal("truncate not implemented");
-#endif
-}
-
-int
-looks_like_number(str)
-STR *str;
-{
- register char *s;
- register char *send;
-
- if (!str->str_pok)
- return TRUE;
- s = str->str_ptr;
- send = s + str->str_cur;
- while (isSPACE(*s))
- s++;
- if (s >= send)
- return FALSE;
- if (*s == '+' || *s == '-')
- s++;
- while (isDIGIT(*s))
- s++;
- if (s == send)
- return TRUE;
- if (*s == '.')
- s++;
- else if (s == str->str_ptr)
- return FALSE;
- while (isDIGIT(*s))
- s++;
- if (s == send)
- return TRUE;
- if (*s == 'e' || *s == 'E') {
- s++;
- if (*s == '+' || *s == '-')
- s++;
- while (isDIGIT(*s))
- s++;
- }
- while (isSPACE(*s))
- s++;
- if (s >= send)
- return TRUE;
- return FALSE;
-}
-
-bool
-do_print(str,fp)
-register STR *str;
-FILE *fp;
-{
- register char *tmps;
-
- if (!fp) {
- if (dowarn)
- warn("print to unopened file");
- errno = EBADF;
- return FALSE;
- }
- if (!str)
- return TRUE;
- if (ofmt &&
- ((str->str_nok && str->str_u.str_nval != 0.0)
- || (looks_like_number(str) && str_gnum(str) != 0.0) ) ) {
- fprintf(fp, ofmt, str->str_u.str_nval);
- return !ferror(fp);
- }
- else {
- tmps = str_get(str);
- if (*tmps == 'S' && tmps[1] == 't' && tmps[2] == 'B' && tmps[3] == '\0'
- && str->str_cur == sizeof(STBP) && strlen(tmps) < str->str_cur) {
- STR *tmpstr = str_mortal(&str_undef);
- stab_efullname(tmpstr,((STAB*)str));/* a stab value, be nice */
- str = tmpstr;
- tmps = str->str_ptr;
- putc('*',fp);
- }
- if (str->str_cur && (fwrite(tmps,1,str->str_cur,fp) == 0 || ferror(fp)))
- return FALSE;
- }
- return TRUE;
-}
-
-bool
-do_aprint(arg,fp,arglast)
-register ARG *arg;
-register FILE *fp;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int retval;
- register int items = arglast[2] - sp;
-
- if (!fp) {
- if (dowarn)
- warn("print to unopened file");
- errno = EBADF;
- return FALSE;
- }
- st += ++sp;
- if (arg->arg_type == O_PRTF) {
- do_sprintf(arg->arg_ptr.arg_str,items,st);
- retval = do_print(arg->arg_ptr.arg_str,fp);
- }
- else {
- retval = (items <= 0);
- for (; items > 0; items--,st++) {
- if (retval && ofslen) {
- if (fwrite(ofs, 1, ofslen, fp) == 0 || ferror(fp)) {
- retval = FALSE;
- break;
- }
- }
- if (!(retval = do_print(*st, fp)))
- break;
- }
- if (retval && orslen)
- if (fwrite(ors, 1, orslen, fp) == 0 || ferror(fp))
- retval = FALSE;
- }
- return retval;
-}
-
-int
-mystat(arg,str)
-ARG *arg;
-STR *str;
-{
- STIO *stio;
-
- if (arg[1].arg_type & A_DONT) {
- stio = stab_io(arg[1].arg_ptr.arg_stab);
- if (stio && stio->ifp) {
- statstab = arg[1].arg_ptr.arg_stab;
- str_set(statname,"");
- laststype = O_STAT;
- return (laststatval = fstat(fileno(stio->ifp), &statcache));
- }
- else {
- if (arg[1].arg_ptr.arg_stab == defstab)
- return laststatval;
- if (dowarn)
- warn("Stat on unopened file <%s>",
- stab_ename(arg[1].arg_ptr.arg_stab));
- statstab = Nullstab;
- str_set(statname,"");
- return (laststatval = -1);
- }
- }
- else {
- statstab = Nullstab;
- str_set(statname,str_get(str));
- laststype = O_STAT;
- laststatval = stat(str_get(str),&statcache);
- if (laststatval < 0 && dowarn && index(str_get(str), '\n'))
- warn(warn_nl, "stat");
- return laststatval;
- }
-}
-
-int
-mylstat(arg,str)
-ARG *arg;
-STR *str;
-{
- if (arg[1].arg_type & A_DONT) {
- if (arg[1].arg_ptr.arg_stab == defstab) {
- if (laststype != O_LSTAT)
- fatal("The stat preceding -l _ wasn't an lstat");
- return laststatval;
- }
- fatal("You can't use -l on a filehandle");
- }
-
- laststype = O_LSTAT;
- statstab = Nullstab;
- str_set(statname,str_get(str));
-#ifdef HAS_LSTAT
- laststatval = lstat(str_get(str),&statcache);
-#else
- laststatval = stat(str_get(str),&statcache);
-#endif
- if (laststatval < 0 && dowarn && index(str_get(str), '\n'))
- warn(warn_nl, "lstat");
- return laststatval;
-}
-
-STR *
-do_fttext(arg,str)
-register ARG *arg;
-STR *str;
-{
- int i;
- int len;
- int odd = 0;
- STDCHAR tbuf[512];
- register STDCHAR *s;
- register STIO *stio;
-
- if (arg[1].arg_type & A_DONT) {
- if (arg[1].arg_ptr.arg_stab == defstab) {
- if (statstab)
- stio = stab_io(statstab);
- else {
- str = statname;
- goto really_filename;
- }
- }
- else {
- statstab = arg[1].arg_ptr.arg_stab;
- str_set(statname,"");
- stio = stab_io(statstab);
- }
- if (stio && stio->ifp) {
-#if defined(STDSTDIO) || defined(atarist) /* this will work with atariST */
- fstat(fileno(stio->ifp),&statcache);
- if (S_ISDIR(statcache.st_mode)) /* handle NFS glitch */
- return arg->arg_type == O_FTTEXT ? &str_no : &str_yes;
- if (stio->ifp->_cnt <= 0) {
- i = getc(stio->ifp);
- if (i != EOF)
- (void)ungetc(i,stio->ifp);
- }
- if (stio->ifp->_cnt <= 0) /* null file is anything */
- return &str_yes;
- len = stio->ifp->_cnt + (stio->ifp->_ptr - stio->ifp->_base);
- s = stio->ifp->_base;
-#else
-#if (defined(BSD) && (BSD >= 199103))
- s = stio->ifp->_base;
- fstat(fileno(stio->ifp),&statcache);
- if (S_ISDIR(statcache.st_mode)) /* handle NFS glitch */
- return arg->arg_type == O_FTTEXT ? &str_no : &str_yes;
-
- if (stio->ifp->_bf._size <= 0) {
- i = getc(stio->ifp);
- if (i != EOF)
- (void)ungetc(i,stio->ifp);
- }
-
- if (stio->ifp->_bf._size <= 0)
- return &str_yes;
- len = stio->ifp->_bf._size+(stio->ifp->_p - stio->ifp->_bf._base);
- s = stio->ifp->_bf._base;
-#else
- fatal("-T and -B not implemented on filehandles");
-#endif
-#endif
- }
- else {
- if (dowarn)
- warn("Test on unopened file <%s>",
- stab_ename(arg[1].arg_ptr.arg_stab));
- errno = EBADF;
- return &str_undef;
- }
- }
- else {
- statstab = Nullstab;
- str_set(statname,str_get(str));
- really_filename:
- i = open(str_get(str),0);
- if (i < 0) {
- if (dowarn && index(str_get(str), '\n'))
- warn(warn_nl, "open");
- return &str_undef;
- }
- fstat(i,&statcache);
- len = read(i,tbuf,512);
- (void)close(i);
- if (len <= 0) {
- if (S_ISDIR(statcache.st_mode) && arg->arg_type == O_FTTEXT)
- return &str_no; /* special case NFS directories */
- return &str_yes; /* null file is anything */
- }
- s = tbuf;
- }
-
- /* now scan s to look for textiness */
-
- for (i = 0; i < len; i++,s++) {
- if (!*s) { /* null never allowed in text */
- odd += len;
- break;
- }
- else if (*s & 128)
- odd++;
- else if (*s < 32 &&
- *s != '\n' && *s != '\r' && *s != '\b' &&
- *s != '\t' && *s != '\f' && *s != 27)
- odd++;
- }
-
- if ((odd * 10 > len) == (arg->arg_type == O_FTTEXT)) /* allow 10% odd */
- return &str_no;
- else
- return &str_yes;
-}
-
-static char **Argv = Null(char **);
-static char *Cmd = Nullch;
-
-bool
-do_aexec(really,arglast)
-STR *really;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int items = arglast[2] - sp;
- register char **a;
- char *tmps;
-
- if (items) {
- New(401,Argv, items+1, char*);
- a = Argv;
- for (st += ++sp; items > 0; items--,st++) {
- if (*st)
- *a++ = str_get(*st);
- else
- *a++ = "";
- }
- *a = Nullch;
-#ifdef TAINT
- if (*Argv[0] != '/') /* will execvp use PATH? */
- taintenv(); /* testing IFS here is overkill, probably */
-#endif
- if (really && *(tmps = str_get(really)))
- execvp(tmps,Argv);
- else
- execvp(Argv[0],Argv);
- }
- do_execfree();
- return FALSE;
-}
-
-void
-do_execfree()
-{
- if (Argv) {
- Safefree(Argv);
- Argv = Null(char **);
- }
- if (Cmd) {
- Safefree(Cmd);
- Cmd = Nullch;
- }
-}
-
-bool
-do_exec(cmd)
-char *cmd;
-{
- register char **a;
- register char *s;
- char flags[10];
-
- /* save an extra exec if possible */
-
-#ifdef CSH
- if (strnEQ(cmd,cshname,cshlen) && strnEQ(cmd+cshlen," -c",3)) {
- strcpy(flags,"-c");
- s = cmd+cshlen+3;
- if (*s == 'f') {
- s++;
- strcat(flags,"f");
- }
- if (*s == ' ')
- s++;
- if (*s++ == '\'') {
- char *ncmd = s;
-
- while (*s)
- s++;
- if (s[-1] == '\n')
- *--s = '\0';
- if (s[-1] == '\'') {
- *--s = '\0';
- execl(cshname,"csh", flags,ncmd,(char*)0);
- *s = '\'';
- return FALSE;
- }
- }
- }
-#endif /* CSH */
-
- /* see if there are shell metacharacters in it */
-
- /*SUPPRESS 530*/
- for (s = cmd; *s && isALPHA(*s); s++) ; /* catch VAR=val gizmo */
- if (*s == '=')
- goto doshell;
- for (s = cmd; *s; s++) {
- if (*s != ' ' && !isALPHA(*s) && index("$&*(){}[]'\";\\|?<>~`\n",*s)) {
- if (*s == '\n' && !s[1]) {
- *s = '\0';
- break;
- }
- doshell:
- execl("/bin/sh","sh","-c",cmd,(char*)0);
- return FALSE;
- }
- }
- New(402,Argv, (s - cmd) / 2 + 2, char*);
- Cmd = nsavestr(cmd, s-cmd);
- a = Argv;
- for (s = Cmd; *s;) {
- while (*s && isSPACE(*s)) s++;
- if (*s)
- *(a++) = s;
- while (*s && !isSPACE(*s)) s++;
- if (*s)
- *s++ = '\0';
- }
- *a = Nullch;
- if (Argv[0]) {
- execvp(Argv[0],Argv);
- if (errno == ENOEXEC) { /* for system V NIH syndrome */
- do_execfree();
- goto doshell;
- }
- }
- do_execfree();
- return FALSE;
-}
-
-#ifdef HAS_SOCKET
-int
-do_socket(stab, arglast)
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- int domain, type, protocol, fd;
-
- if (!stab) {
- errno = EBADF;
- return FALSE;
- }
-
- stio = stab_io(stab);
- if (!stio)
- stio = stab_io(stab) = stio_new();
- else if (stio->ifp)
- do_close(stab,FALSE);
-
- domain = (int)str_gnum(st[++sp]);
- type = (int)str_gnum(st[++sp]);
- protocol = (int)str_gnum(st[++sp]);
-#ifdef TAINT
- taintproper("Insecure dependency in socket");
-#endif
- fd = socket(domain,type,protocol);
- if (fd < 0)
- return FALSE;
- stio->ifp = fdopen(fd, "r"); /* stdio gets confused about sockets */
- stio->ofp = fdopen(fd, "w");
- stio->type = 's';
- if (!stio->ifp || !stio->ofp) {
- if (stio->ifp) fclose(stio->ifp);
- if (stio->ofp) fclose(stio->ofp);
- if (!stio->ifp && !stio->ofp) close(fd);
- return FALSE;
- }
-
- return TRUE;
-}
-
-int
-do_bind(stab, arglast)
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- char *addr;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- addr = str_get(st[++sp]);
-#ifdef TAINT
- taintproper("Insecure dependency in bind");
-#endif
- return bind(fileno(stio->ifp), addr, st[sp]->str_cur) >= 0;
-
-nuts:
- if (dowarn)
- warn("bind() on closed fd");
- errno = EBADF;
- return FALSE;
-
-}
-
-int
-do_connect(stab, arglast)
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- char *addr;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- addr = str_get(st[++sp]);
-#ifdef TAINT
- taintproper("Insecure dependency in connect");
-#endif
- return connect(fileno(stio->ifp), addr, st[sp]->str_cur) >= 0;
-
-nuts:
- if (dowarn)
- warn("connect() on closed fd");
- errno = EBADF;
- return FALSE;
-
-}
-
-int
-do_listen(stab, arglast)
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- int backlog;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- backlog = (int)str_gnum(st[++sp]);
- return listen(fileno(stio->ifp), backlog) >= 0;
-
-nuts:
- if (dowarn)
- warn("listen() on closed fd");
- errno = EBADF;
- return FALSE;
-}
-
-void
-do_accept(str, nstab, gstab)
-STR *str;
-STAB *nstab;
-STAB *gstab;
-{
- register STIO *nstio;
- register STIO *gstio;
- int len = sizeof buf;
- int fd;
-
- if (!nstab)
- goto badexit;
- if (!gstab)
- goto nuts;
-
- gstio = stab_io(gstab);
- nstio = stab_io(nstab);
-
- if (!gstio || !gstio->ifp)
- goto nuts;
- if (!nstio)
- nstio = stab_io(nstab) = stio_new();
- else if (nstio->ifp)
- do_close(nstab,FALSE);
-
- fd = accept(fileno(gstio->ifp),(struct sockaddr *)buf,&len);
- if (fd < 0)
- goto badexit;
- nstio->ifp = fdopen(fd, "r");
- nstio->ofp = fdopen(fd, "w");
- nstio->type = 's';
- if (!nstio->ifp || !nstio->ofp) {
- if (nstio->ifp) fclose(nstio->ifp);
- if (nstio->ofp) fclose(nstio->ofp);
- if (!nstio->ifp && !nstio->ofp) close(fd);
- goto badexit;
- }
-
- str_nset(str, buf, len);
- return;
-
-nuts:
- if (dowarn)
- warn("accept() on closed fd");
- errno = EBADF;
-badexit:
- str_sset(str,&str_undef);
- return;
-}
-
-int
-do_shutdown(stab, arglast)
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- int how;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- how = (int)str_gnum(st[++sp]);
- return shutdown(fileno(stio->ifp), how) >= 0;
-
-nuts:
- if (dowarn)
- warn("shutdown() on closed fd");
- errno = EBADF;
- return FALSE;
-
-}
-
-int
-do_sopt(optype, stab, arglast)
-int optype;
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- int fd;
- unsigned int lvl;
- unsigned int optname;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- fd = fileno(stio->ifp);
- lvl = (unsigned int)str_gnum(st[sp+1]);
- optname = (unsigned int)str_gnum(st[sp+2]);
- switch (optype) {
- case O_GSOCKOPT:
- st[sp] = str_2mortal(Str_new(22,257));
- st[sp]->str_cur = 256;
- st[sp]->str_pok = 1;
- if (getsockopt(fd, lvl, optname, st[sp]->str_ptr,
- (int*)&st[sp]->str_cur) < 0)
- goto nuts;
- break;
- case O_SSOCKOPT:
- st[sp] = st[sp+3];
- if (setsockopt(fd, lvl, optname, st[sp]->str_ptr, st[sp]->str_cur) < 0)
- goto nuts;
- st[sp] = &str_yes;
- break;
- }
-
- return sp;
-
-nuts:
- if (dowarn)
- warn("[gs]etsockopt() on closed fd");
- st[sp] = &str_undef;
- errno = EBADF;
- return sp;
-
-}
-
-int
-do_getsockname(optype, stab, arglast)
-int optype;
-STAB *stab;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- int fd;
-
- if (!stab)
- goto nuts;
-
- stio = stab_io(stab);
- if (!stio || !stio->ifp)
- goto nuts;
-
- st[sp] = str_2mortal(Str_new(22,257));
- st[sp]->str_cur = 256;
- st[sp]->str_pok = 1;
- fd = fileno(stio->ifp);
- switch (optype) {
- case O_GETSOCKNAME:
- if (getsockname(fd, st[sp]->str_ptr, (int*)&st[sp]->str_cur) < 0)
- goto nuts2;
- break;
- case O_GETPEERNAME:
- if (getpeername(fd, st[sp]->str_ptr, (int*)&st[sp]->str_cur) < 0)
- goto nuts2;
- break;
- }
-
- return sp;
-
-nuts:
- if (dowarn)
- warn("get{sock,peer}name() on closed fd");
- errno = EBADF;
-nuts2:
- st[sp] = &str_undef;
- return sp;
-
-}
-
-int
-do_ghent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register char **elem;
- register STR *str;
- struct hostent *gethostbyname();
- struct hostent *gethostbyaddr();
-#ifdef HAS_GETHOSTENT
- struct hostent *gethostent();
-#endif
- struct hostent *hent;
- unsigned long len;
-
- if (which == O_GHBYNAME) {
- char *name = str_get(ary->ary_array[sp+1]);
-
- hent = gethostbyname(name);
- }
- else if (which == O_GHBYADDR) {
- STR *addrstr = ary->ary_array[sp+1];
- int addrtype = (int)str_gnum(ary->ary_array[sp+2]);
- char *addr = str_get(addrstr);
-
- hent = gethostbyaddr(addr,addrstr->str_cur,addrtype);
- }
- else
-#ifdef HAS_GETHOSTENT
- hent = gethostent();
-#else
- fatal("gethostent not implemented");
-#endif
-
-#ifdef HOST_NOT_FOUND
- if (!hent)
- statusvalue = (unsigned short)h_errno & 0xffff;
-#endif
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (hent) {
- if (which == O_GHBYNAME) {
-#ifdef h_addr
- str_nset(str, *hent->h_addr, hent->h_length);
-#else
- str_nset(str, hent->h_addr, hent->h_length);
-#endif
- }
- else
- str_set(str, hent->h_name);
- }
- return sp;
- }
-
- if (hent) {
-#ifndef lint
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, hent->h_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- for (elem = hent->h_aliases; *elem; elem++) {
- str_cat(str, *elem);
- if (elem[1])
- str_ncat(str," ",1);
- }
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)hent->h_addrtype);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- len = hent->h_length;
- str_numset(str, (double)len);
-#ifdef h_addr
- for (elem = hent->h_addr_list; *elem; elem++) {
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_nset(str, *elem, len);
- }
-#else
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_nset(str, hent->h_addr, len);
-#endif /* h_addr */
-#else /* lint */
- elem = Nullch;
- elem = elem;
- (void)astore(ary, ++sp, str_mortal(&str_no));
-#endif /* lint */
- }
-
- return sp;
-}
-
-int
-do_gnent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register char **elem;
- register STR *str;
- struct netent *getnetbyname();
- struct netent *getnetbyaddr();
- struct netent *getnetent();
- struct netent *nent;
-
- if (which == O_GNBYNAME) {
- char *name = str_get(ary->ary_array[sp+1]);
-
- nent = getnetbyname(name);
- }
- else if (which == O_GNBYADDR) {
- unsigned long addr = U_L(str_gnum(ary->ary_array[sp+1]));
- int addrtype = (int)str_gnum(ary->ary_array[sp+2]);
-
- nent = getnetbyaddr((long)addr,addrtype);
- }
- else
- nent = getnetent();
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (nent) {
- if (which == O_GNBYNAME)
- str_numset(str, (double)nent->n_net);
- else
- str_set(str, nent->n_name);
- }
- return sp;
- }
-
- if (nent) {
-#ifndef lint
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, nent->n_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- for (elem = nent->n_aliases; *elem; elem++) {
- str_cat(str, *elem);
- if (elem[1])
- str_ncat(str," ",1);
- }
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)nent->n_addrtype);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)nent->n_net);
-#else /* lint */
- elem = Nullch;
- elem = elem;
- (void)astore(ary, ++sp, str_mortal(&str_no));
-#endif /* lint */
- }
-
- return sp;
-}
-
-int
-do_gpent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register char **elem;
- register STR *str;
- struct protoent *getprotobyname();
- struct protoent *getprotobynumber();
- struct protoent *getprotoent();
- struct protoent *pent;
-
- if (which == O_GPBYNAME) {
- char *name = str_get(ary->ary_array[sp+1]);
-
- pent = getprotobyname(name);
- }
- else if (which == O_GPBYNUMBER) {
- int proto = (int)str_gnum(ary->ary_array[sp+1]);
-
- pent = getprotobynumber(proto);
- }
- else
- pent = getprotoent();
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (pent) {
- if (which == O_GPBYNAME)
- str_numset(str, (double)pent->p_proto);
- else
- str_set(str, pent->p_name);
- }
- return sp;
- }
-
- if (pent) {
-#ifndef lint
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pent->p_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- for (elem = pent->p_aliases; *elem; elem++) {
- str_cat(str, *elem);
- if (elem[1])
- str_ncat(str," ",1);
- }
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)pent->p_proto);
-#else /* lint */
- elem = Nullch;
- elem = elem;
- (void)astore(ary, ++sp, str_mortal(&str_no));
-#endif /* lint */
- }
-
- return sp;
-}
-
-int
-do_gsent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register char **elem;
- register STR *str;
- struct servent *getservbyname();
- struct servent *getservbynumber();
- struct servent *getservent();
- struct servent *sent;
-
- if (which == O_GSBYNAME) {
- char *name = str_get(ary->ary_array[sp+1]);
- char *proto = str_get(ary->ary_array[sp+2]);
-
- if (proto && !*proto)
- proto = Nullch;
-
- sent = getservbyname(name,proto);
- }
- else if (which == O_GSBYPORT) {
- int port = (int)str_gnum(ary->ary_array[sp+1]);
- char *proto = str_get(ary->ary_array[sp+2]);
-
- sent = getservbyport(port,proto);
- }
- else
- sent = getservent();
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (sent) {
- if (which == O_GSBYNAME) {
-#ifdef HAS_NTOHS
- str_numset(str, (double)ntohs(sent->s_port));
-#else
- str_numset(str, (double)(sent->s_port));
-#endif
- }
- else
- str_set(str, sent->s_name);
- }
- return sp;
- }
-
- if (sent) {
-#ifndef lint
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, sent->s_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- for (elem = sent->s_aliases; *elem; elem++) {
- str_cat(str, *elem);
- if (elem[1])
- str_ncat(str," ",1);
- }
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
-#ifdef HAS_NTOHS
- str_numset(str, (double)ntohs(sent->s_port));
-#else
- str_numset(str, (double)(sent->s_port));
-#endif
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, sent->s_proto);
-#else /* lint */
- elem = Nullch;
- elem = elem;
- (void)astore(ary, ++sp, str_mortal(&str_no));
-#endif /* lint */
- }
-
- return sp;
-}
-
-#endif /* HAS_SOCKET */
-
-#ifdef HAS_SELECT
-int
-do_select(gimme,arglast)
-int gimme;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- register int i;
- register int j;
- register char *s;
- register STR *str;
- double value;
- int maxlen = 0;
- int nfound;
- struct timeval timebuf;
- struct timeval *tbuf = &timebuf;
- int growsize;
-#if BYTEORDER != 0x1234 && BYTEORDER != 0x12345678
- int masksize;
- int offset;
- char *fd_sets[4];
- int k;
-
-#if BYTEORDER & 0xf0000
-#define ORDERBYTE (0x88888888 - BYTEORDER)
-#else
-#define ORDERBYTE (0x4444 - BYTEORDER)
-#endif
-
-#endif
-
- for (i = 1; i <= 3; i++) {
- j = st[sp+i]->str_cur;
- if (maxlen < j)
- maxlen = j;
- }
-
-#if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678
- growsize = maxlen; /* little endians can use vecs directly */
-#else
-#ifdef NFDBITS
-
-#ifndef NBBY
-#define NBBY 8
-#endif
-
- masksize = NFDBITS / NBBY;
-#else
- masksize = sizeof(long); /* documented int, everyone seems to use long */
-#endif
- growsize = maxlen + (masksize - (maxlen % masksize));
- Zero(&fd_sets[0], 4, char*);
-#endif
-
- for (i = 1; i <= 3; i++) {
- str = st[sp+i];
- j = str->str_len;
- if (j < growsize) {
- if (str->str_pok) {
- Str_Grow(str,growsize);
- s = str_get(str) + j;
- while (++j <= growsize) {
- *s++ = '\0';
- }
- }
- else if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_ptr = Nullch;
- }
- }
-#if BYTEORDER != 0x1234 && BYTEORDER != 0x12345678
- s = str->str_ptr;
- if (s) {
- New(403, fd_sets[i], growsize, char);
- for (offset = 0; offset < growsize; offset += masksize) {
- for (j = 0, k=ORDERBYTE; j < masksize; j++, (k >>= 4))
- fd_sets[i][j+offset] = s[(k % masksize) + offset];
- }
- }
-#endif
- }
- str = st[sp+4];
- if (str->str_nok || str->str_pok) {
- value = str_gnum(str);
- if (value < 0.0)
- value = 0.0;
- timebuf.tv_sec = (long)value;
- value -= (double)timebuf.tv_sec;
- timebuf.tv_usec = (long)(value * 1000000.0);
- }
- else
- tbuf = Null(struct timeval*);
-
-#if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678
- nfound = select(
- maxlen * 8,
- st[sp+1]->str_ptr,
- st[sp+2]->str_ptr,
- st[sp+3]->str_ptr,
- tbuf);
-#else
- nfound = select(
- maxlen * 8,
- fd_sets[1],
- fd_sets[2],
- fd_sets[3],
- tbuf);
- for (i = 1; i <= 3; i++) {
- if (fd_sets[i]) {
- str = st[sp+i];
- s = str->str_ptr;
- for (offset = 0; offset < growsize; offset += masksize) {
- for (j = 0, k=ORDERBYTE; j < masksize; j++, (k >>= 4))
- s[(k % masksize) + offset] = fd_sets[i][j+offset];
- }
- Safefree(fd_sets[i]);
- }
- }
-#endif
-
- st[++sp] = str_mortal(&str_no);
- str_numset(st[sp], (double)nfound);
- if (gimme == G_ARRAY && tbuf) {
- value = (double)(timebuf.tv_sec) +
- (double)(timebuf.tv_usec) / 1000000.0;
- st[++sp] = str_mortal(&str_no);
- str_numset(st[sp], value);
- }
- return sp;
-}
-#endif /* SELECT */
-
-#ifdef HAS_SOCKET
-int
-do_spair(stab1, stab2, arglast)
-STAB *stab1;
-STAB *stab2;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[2];
- register STIO *stio1;
- register STIO *stio2;
- int domain, type, protocol, fd[2];
-
- if (!stab1 || !stab2)
- return FALSE;
-
- stio1 = stab_io(stab1);
- stio2 = stab_io(stab2);
- if (!stio1)
- stio1 = stab_io(stab1) = stio_new();
- else if (stio1->ifp)
- do_close(stab1,FALSE);
- if (!stio2)
- stio2 = stab_io(stab2) = stio_new();
- else if (stio2->ifp)
- do_close(stab2,FALSE);
-
- domain = (int)str_gnum(st[++sp]);
- type = (int)str_gnum(st[++sp]);
- protocol = (int)str_gnum(st[++sp]);
-#ifdef TAINT
- taintproper("Insecure dependency in socketpair");
-#endif
-#ifdef HAS_SOCKETPAIR
- if (socketpair(domain,type,protocol,fd) < 0)
- return FALSE;
-#else
- fatal("Socketpair unimplemented");
-#endif
- stio1->ifp = fdopen(fd[0], "r");
- stio1->ofp = fdopen(fd[0], "w");
- stio1->type = 's';
- stio2->ifp = fdopen(fd[1], "r");
- stio2->ofp = fdopen(fd[1], "w");
- stio2->type = 's';
- if (!stio1->ifp || !stio1->ofp || !stio2->ifp || !stio2->ofp) {
- if (stio1->ifp) fclose(stio1->ifp);
- if (stio1->ofp) fclose(stio1->ofp);
- if (!stio1->ifp && !stio1->ofp) close(fd[0]);
- if (stio2->ifp) fclose(stio2->ifp);
- if (stio2->ofp) fclose(stio2->ofp);
- if (!stio2->ifp && !stio2->ofp) close(fd[1]);
- return FALSE;
- }
-
- return TRUE;
-}
-
-#endif /* HAS_SOCKET */
-
-int
-do_gpwent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
-#ifdef I_PWD
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register STR *str;
- struct passwd *getpwnam();
- struct passwd *getpwuid();
- struct passwd *getpwent();
- struct passwd *pwent;
-
- if (which == O_GPWNAM) {
- char *name = str_get(ary->ary_array[sp+1]);
-
- pwent = getpwnam(name);
- }
- else if (which == O_GPWUID) {
- int uid = (int)str_gnum(ary->ary_array[sp+1]);
-
- pwent = getpwuid(uid);
- }
- else
- pwent = getpwent();
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (pwent) {
- if (which == O_GPWNAM)
- str_numset(str, (double)pwent->pw_uid);
- else
- str_set(str, pwent->pw_name);
- }
- return sp;
- }
-
- if (pwent) {
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pwent->pw_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pwent->pw_passwd);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)pwent->pw_uid);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)pwent->pw_gid);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
-#ifdef PWCHANGE
- str_numset(str, (double)pwent->pw_change);
-#else
-#ifdef PWQUOTA
- str_numset(str, (double)pwent->pw_quota);
-#else
-#ifdef PWAGE
- str_set(str, pwent->pw_age);
-#endif
-#endif
-#endif
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
-#ifdef PWCLASS
- str_set(str,pwent->pw_class);
-#else
-#ifdef PWCOMMENT
- str_set(str, pwent->pw_comment);
-#endif
-#endif
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pwent->pw_gecos);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pwent->pw_dir);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, pwent->pw_shell);
-#ifdef PWEXPIRE
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)pwent->pw_expire);
-#endif
- }
-
- return sp;
-#else
- fatal("password routines not implemented");
-#endif
-}
-
-int
-do_ggrent(which,gimme,arglast)
-int which;
-int gimme;
-int *arglast;
-{
-#ifdef I_GRP
- register ARRAY *ary = stack;
- register int sp = arglast[0];
- register char **elem;
- register STR *str;
- struct group *getgrnam();
- struct group *getgrgid();
- struct group *getgrent();
- struct group *grent;
-
- if (which == O_GGRNAM) {
- char *name = str_get(ary->ary_array[sp+1]);
-
- grent = getgrnam(name);
- }
- else if (which == O_GGRGID) {
- int gid = (int)str_gnum(ary->ary_array[sp+1]);
-
- grent = getgrgid(gid);
- }
- else
- grent = getgrent();
-
- if (gimme != G_ARRAY) {
- astore(ary, ++sp, str = str_mortal(&str_undef));
- if (grent) {
- if (which == O_GGRNAM)
- str_numset(str, (double)grent->gr_gid);
- else
- str_set(str, grent->gr_name);
- }
- return sp;
- }
-
- if (grent) {
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, grent->gr_name);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_set(str, grent->gr_passwd);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- str_numset(str, (double)grent->gr_gid);
- (void)astore(ary, ++sp, str = str_mortal(&str_no));
- for (elem = grent->gr_mem; *elem; elem++) {
- str_cat(str, *elem);
- if (elem[1])
- str_ncat(str," ",1);
- }
- }
-
- return sp;
-#else
- fatal("group routines not implemented");
-#endif
-}
-
-int
-do_dirop(optype,stab,gimme,arglast)
-int optype;
-STAB *stab;
-int gimme;
-int *arglast;
-{
-#if defined(DIRENT) && defined(HAS_READDIR)
- register ARRAY *ary = stack;
- register STR **st = ary->ary_array;
- register int sp = arglast[1];
- register STIO *stio;
- long along;
-#ifndef apollo
- struct DIRENT *readdir();
-#endif
- register struct DIRENT *dp;
-
- if (!stab)
- goto nope;
- if (!(stio = stab_io(stab)))
- stio = stab_io(stab) = stio_new();
- if (!stio->dirp && optype != O_OPEN_DIR)
- goto nope;
- st[sp] = &str_yes;
- switch (optype) {
- case O_OPEN_DIR:
- if (stio->dirp)
- closedir(stio->dirp);
- if (!(stio->dirp = opendir(str_get(st[sp+1]))))
- goto nope;
- break;
- case O_READDIR:
- if (gimme == G_ARRAY) {
- --sp;
- /*SUPPRESS 560*/
- while (dp = readdir(stio->dirp)) {
-#ifdef DIRNAMLEN
- (void)astore(ary,++sp,
- str_2mortal(str_make(dp->d_name,dp->d_namlen)));
-#else
- (void)astore(ary,++sp,
- str_2mortal(str_make(dp->d_name,0)));
-#endif
- }
- }
- else {
- if (!(dp = readdir(stio->dirp)))
- goto nope;
- st[sp] = str_mortal(&str_undef);
-#ifdef DIRNAMLEN
- str_nset(st[sp], dp->d_name, dp->d_namlen);
-#else
- str_set(st[sp], dp->d_name);
-#endif
- }
- break;
-#if defined(HAS_TELLDIR) || defined(telldir)
- case O_TELLDIR: {
-#ifndef telldir
- long telldir();
-#endif
- st[sp] = str_mortal(&str_undef);
- str_numset(st[sp], (double)telldir(stio->dirp));
- break;
- }
-#endif
-#if defined(HAS_SEEKDIR) || defined(seekdir)
- case O_SEEKDIR:
- st[sp] = str_mortal(&str_undef);
- along = (long)str_gnum(st[sp+1]);
- (void)seekdir(stio->dirp,along);
- break;
-#endif
-#if defined(HAS_REWINDDIR) || defined(rewinddir)
- case O_REWINDDIR:
- st[sp] = str_mortal(&str_undef);
- (void)rewinddir(stio->dirp);
- break;
-#endif
- case O_CLOSEDIR:
- st[sp] = str_mortal(&str_undef);
- (void)closedir(stio->dirp);
- stio->dirp = 0;
- break;
- default:
- goto phooey;
- }
- return sp;
-
-nope:
- st[sp] = &str_undef;
- if (!errno)
- errno = EBADF;
- return sp;
-
-#endif
-phooey:
- fatal("Unimplemented directory operation");
-}
-
-int
-apply(type,arglast)
-int type;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[1];
- register int items = arglast[2] - sp;
- register int val;
- register int val2;
- register int tot = 0;
- char *s;
-
-#ifdef TAINT
- for (st += ++sp; items--; st++)
- tainted |= (*st)->str_tainted;
- st = stack->ary_array;
- sp = arglast[1];
- items = arglast[2] - sp;
-#endif
- switch (type) {
- case O_CHMOD:
-#ifdef TAINT
- taintproper("Insecure dependency in chmod");
-#endif
- if (--items > 0) {
- tot = items;
- val = (int)str_gnum(st[++sp]);
- while (items--) {
- if (chmod(str_get(st[++sp]),val))
- tot--;
- }
- }
- break;
-#ifdef HAS_CHOWN
- case O_CHOWN:
-#ifdef TAINT
- taintproper("Insecure dependency in chown");
-#endif
- if (items > 2) {
- items -= 2;
- tot = items;
- val = (int)str_gnum(st[++sp]);
- val2 = (int)str_gnum(st[++sp]);
- while (items--) {
- if (chown(str_get(st[++sp]),val,val2))
- tot--;
- }
- }
- break;
-#endif
-#ifdef HAS_KILL
- case O_KILL:
-#ifdef TAINT
- taintproper("Insecure dependency in kill");
-#endif
- if (--items > 0) {
- tot = items;
- s = str_get(st[++sp]);
- if (isUPPER(*s)) {
- if (*s == 'S' && s[1] == 'I' && s[2] == 'G')
- s += 3;
- if (!(val = whichsig(s)))
- fatal("Unrecognized signal name \"%s\"",s);
- }
- else
- val = (int)str_gnum(st[sp]);
- if (val < 0) {
- val = -val;
- while (items--) {
- int proc = (int)str_gnum(st[++sp]);
-#ifdef HAS_KILLPG
- if (killpg(proc,val)) /* BSD */
-#else
- if (kill(-proc,val)) /* SYSV */
-#endif
- tot--;
- }
- }
- else {
- while (items--) {
- if (kill((int)(str_gnum(st[++sp])),val))
- tot--;
- }
- }
- }
- break;
-#endif
- case O_UNLINK:
-#ifdef TAINT
- taintproper("Insecure dependency in unlink");
-#endif
- tot = items;
- while (items--) {
- s = str_get(st[++sp]);
- if (euid || unsafe) {
- if (UNLINK(s))
- tot--;
- }
- else { /* don't let root wipe out directories without -U */
-#ifdef HAS_LSTAT
- if (lstat(s,&statbuf) < 0 || S_ISDIR(statbuf.st_mode))
-#else
- if (stat(s,&statbuf) < 0 || S_ISDIR(statbuf.st_mode))
-#endif
- tot--;
- else {
- if (UNLINK(s))
- tot--;
- }
- }
- }
- break;
- case O_UTIME:
-#ifdef TAINT
- taintproper("Insecure dependency in utime");
-#endif
- if (items > 2) {
-#ifdef I_UTIME
- struct utimbuf utbuf;
-#else
- struct {
- long actime;
- long modtime;
- } utbuf;
-#endif
-
- Zero(&utbuf, sizeof utbuf, char);
- utbuf.actime = (long)str_gnum(st[++sp]); /* time accessed */
- utbuf.modtime = (long)str_gnum(st[++sp]); /* time modified */
- items -= 2;
-#ifndef lint
- tot = items;
- while (items--) {
- if (utime(str_get(st[++sp]),&utbuf))
- tot--;
- }
-#endif
- }
- else
- items = 0;
- break;
- }
- return tot;
-}
-
-/* Do the permissions allow some operation? Assumes statcache already set. */
-
-int
-cando(bit, effective, statbufp)
-int bit;
-int effective;
-register struct stat *statbufp;
-{
-#ifdef DOSISH
- /* [Comments and code from Len Reed]
- * MS-DOS "user" is similar to UNIX's "superuser," but can't write
- * to write-protected files. The execute permission bit is set
- * by the Miscrosoft C library stat() function for the following:
- * .exe files
- * .com files
- * .bat files
- * directories
- * All files and directories are readable.
- * Directories and special files, e.g. "CON", cannot be
- * write-protected.
- * [Comment by Tom Dinger -- a directory can have the write-protect
- * bit set in the file system, but DOS permits changes to
- * the directory anyway. In addition, all bets are off
- * here for networked software, such as Novell and
- * Sun's PC-NFS.]
- */
-
- /* Atari stat() does pretty much the same thing. we set x_bit_set_in_stat
- * too so it will actually look into the files for magic numbers
- */
- return (bit & statbufp->st_mode) ? TRUE : FALSE;
-
-#else /* ! MSDOS */
- if ((effective ? euid : uid) == 0) { /* root is special */
- if (bit == S_IXUSR) {
- if (statbufp->st_mode & 0111 || S_ISDIR(statbufp->st_mode))
- return TRUE;
- }
- else
- return TRUE; /* root reads and writes anything */
- return FALSE;
- }
- if (statbufp->st_uid == (effective ? euid : uid) ) {
- if (statbufp->st_mode & bit)
- return TRUE; /* ok as "user" */
- }
- else if (ingroup((int)statbufp->st_gid,effective)) {
- if (statbufp->st_mode & bit >> 3)
- return TRUE; /* ok as "group" */
- }
- else if (statbufp->st_mode & bit >> 6)
- return TRUE; /* ok as "other" */
- return FALSE;
-#endif /* ! MSDOS */
-}
-
-int
-ingroup(testgid,effective)
-int testgid;
-int effective;
-{
- if (testgid == (effective ? egid : gid))
- return TRUE;
-#ifdef HAS_GETGROUPS
-#ifndef NGROUPS
-#define NGROUPS 32
-#endif
- {
- GROUPSTYPE gary[NGROUPS];
- int anum;
-
- anum = getgroups(NGROUPS,gary);
- while (--anum >= 0)
- if (gary[anum] == testgid)
- return TRUE;
- }
-#endif
- return FALSE;
-}
-
-#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
-
-int
-do_ipcget(optype, arglast)
-int optype;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- key_t key;
- int n, flags;
-
- key = (key_t)str_gnum(st[++sp]);
- n = (optype == O_MSGGET) ? 0 : (int)str_gnum(st[++sp]);
- flags = (int)str_gnum(st[++sp]);
- errno = 0;
- switch (optype)
- {
-#ifdef HAS_MSG
- case O_MSGGET:
- return msgget(key, flags);
-#endif
-#ifdef HAS_SEM
- case O_SEMGET:
- return semget(key, n, flags);
-#endif
-#ifdef HAS_SHM
- case O_SHMGET:
- return shmget(key, n, flags);
-#endif
-#if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM)
- default:
- fatal("%s not implemented", opname[optype]);
-#endif
- }
- return -1; /* should never happen */
-}
-
-int
-do_ipcctl(optype, arglast)
-int optype;
-int *arglast;
-{
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- STR *astr;
- char *a;
- int id, n, cmd, infosize, getinfo, ret;
-
- id = (int)str_gnum(st[++sp]);
- n = (optype == O_SEMCTL) ? (int)str_gnum(st[++sp]) : 0;
- cmd = (int)str_gnum(st[++sp]);
- astr = st[++sp];
-
- infosize = 0;
- getinfo = (cmd == IPC_STAT);
-
- switch (optype)
- {
-#ifdef HAS_MSG
- case O_MSGCTL:
- if (cmd == IPC_STAT || cmd == IPC_SET)
- infosize = sizeof(struct msqid_ds);
- break;
-#endif
-#ifdef HAS_SHM
- case O_SHMCTL:
- if (cmd == IPC_STAT || cmd == IPC_SET)
- infosize = sizeof(struct shmid_ds);
- break;
-#endif
-#ifdef HAS_SEM
- case O_SEMCTL:
- if (cmd == IPC_STAT || cmd == IPC_SET)
- infosize = sizeof(struct semid_ds);
- else if (cmd == GETALL || cmd == SETALL)
- {
- struct semid_ds semds;
- if (semctl(id, 0, IPC_STAT, (union semun)&semds) == -1)
- return -1;
- getinfo = (cmd == GETALL);
- infosize = semds.sem_nsems * sizeof(short);
- /* "short" is technically wrong but much more portable
- than guessing about u_?short(_t)? */
- }
- break;
-#endif
-#if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM)
- default:
- fatal("%s not implemented", opname[optype]);
-#endif
- }
-
- if (infosize)
- {
- if (getinfo)
- {
- STR_GROW(astr, infosize+1);
- a = str_get(astr);
- }
- else
- {
- a = str_get(astr);
- if (astr->str_cur != infosize)
- {
- errno = EINVAL;
- return -1;
- }
- }
- }
- else
- {
- int i = (int)str_gnum(astr);
- a = (char *)i; /* ouch */
- }
- errno = 0;
- switch (optype)
- {
-#ifdef HAS_MSG
- case O_MSGCTL:
- ret = msgctl(id, cmd, (struct msqid_ds *)a);
- break;
-#endif
-#ifdef HAS_SEM
- case O_SEMCTL:
- ret = semctl(id, n, cmd, (union semun)((int)a));
- break;
-#endif
-#ifdef HAS_SHM
- case O_SHMCTL:
- ret = shmctl(id, cmd, (struct shmid_ds *)a);
- break;
-#endif
- }
- if (getinfo && ret >= 0) {
- astr->str_cur = infosize;
- astr->str_ptr[infosize] = '\0';
- }
- return ret;
-}
-
-int
-do_msgsnd(arglast)
-int *arglast;
-{
-#ifdef HAS_MSG
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- STR *mstr;
- char *mbuf;
- int id, msize, flags;
-
- id = (int)str_gnum(st[++sp]);
- mstr = st[++sp];
- flags = (int)str_gnum(st[++sp]);
- mbuf = str_get(mstr);
- if ((msize = mstr->str_cur - sizeof(long)) < 0) {
- errno = EINVAL;
- return -1;
- }
- errno = 0;
- return msgsnd(id, (struct msgbuf *)mbuf, msize, flags);
-#else
- fatal("msgsnd not implemented");
-#endif
-}
-
-int
-do_msgrcv(arglast)
-int *arglast;
-{
-#ifdef HAS_MSG
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- STR *mstr;
- char *mbuf;
- long mtype;
- int id, msize, flags, ret;
-
- id = (int)str_gnum(st[++sp]);
- mstr = st[++sp];
- msize = (int)str_gnum(st[++sp]);
- mtype = (long)str_gnum(st[++sp]);
- flags = (int)str_gnum(st[++sp]);
- mbuf = str_get(mstr);
- if (mstr->str_cur < sizeof(long)+msize+1) {
- STR_GROW(mstr, sizeof(long)+msize+1);
- mbuf = str_get(mstr);
- }
- errno = 0;
- ret = msgrcv(id, (struct msgbuf *)mbuf, msize, mtype, flags);
- if (ret >= 0) {
- mstr->str_cur = sizeof(long)+ret;
- mstr->str_ptr[sizeof(long)+ret] = '\0';
- }
- return ret;
-#else
- fatal("msgrcv not implemented");
-#endif
-}
-
-int
-do_semop(arglast)
-int *arglast;
-{
-#ifdef HAS_SEM
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- STR *opstr;
- char *opbuf;
- int id, opsize;
-
- id = (int)str_gnum(st[++sp]);
- opstr = st[++sp];
- opbuf = str_get(opstr);
- opsize = opstr->str_cur;
- if (opsize < sizeof(struct sembuf)
- || (opsize % sizeof(struct sembuf)) != 0) {
- errno = EINVAL;
- return -1;
- }
- errno = 0;
- return semop(id, (struct sembuf *)opbuf, opsize/sizeof(struct sembuf));
-#else
- fatal("semop not implemented");
-#endif
-}
-
-int
-do_shmio(optype, arglast)
-int optype;
-int *arglast;
-{
-#ifdef HAS_SHM
- register STR **st = stack->ary_array;
- register int sp = arglast[0];
- STR *mstr;
- char *mbuf, *shm;
- int id, mpos, msize;
- struct shmid_ds shmds;
-#ifndef VOIDSHMAT
- extern char *shmat();
-#endif
-
- id = (int)str_gnum(st[++sp]);
- mstr = st[++sp];
- mpos = (int)str_gnum(st[++sp]);
- msize = (int)str_gnum(st[++sp]);
- errno = 0;
- if (shmctl(id, IPC_STAT, &shmds) == -1)
- return -1;
- if (mpos < 0 || msize < 0 || mpos + msize > shmds.shm_segsz) {
- errno = EFAULT; /* can't do as caller requested */
- return -1;
- }
- shm = (char*)shmat(id, (char*)NULL, (optype == O_SHMREAD) ? SHM_RDONLY : 0);
- if (shm == (char *)-1) /* I hate System V IPC, I really do */
- return -1;
- mbuf = str_get(mstr);
- if (optype == O_SHMREAD) {
- if (mstr->str_cur < msize) {
- STR_GROW(mstr, msize+1);
- mbuf = str_get(mstr);
- }
- Copy(shm + mpos, mbuf, msize, char);
- mstr->str_cur = msize;
- mstr->str_ptr[msize] = '\0';
- }
- else {
- int n;
-
- if ((n = mstr->str_cur) > msize)
- n = msize;
- Copy(mbuf, shm + mpos, n, char);
- if (n < msize)
- memzero(shm + mpos + n, msize - n);
- }
- return shmdt(shm);
-#else
- fatal("shm I/O not implemented");
-#endif
-}
-
-#endif /* SYSV IPC */
diff --git a/gnu/usr.bin/perl/perl/toke.c b/gnu/usr.bin/perl/perl/toke.c
deleted file mode 100644
index d654066..0000000
--- a/gnu/usr.bin/perl/perl/toke.c
+++ /dev/null
@@ -1,2785 +0,0 @@
-/* $RCSfile: toke.c,v $$Revision: 1.3 $$Date: 1997/08/08 20:53:59 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: toke.c,v $
- * Revision 1.3 1997/08/08 20:53:59 joerg
- * Fix a buffer overflow condition (that causes a security hole in suidperl).
- *
- * Closes: CERT Advisory CA-97.17 - Vulnerability in suidperl
- * Obtained from: (partly) the fix in CA-97.17
- *
- * Revision 1.2 1995/05/30 05:03:26 rgrimes
- * Remove trailing whitespace.
- *
- * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:40 nate
- * PERL!
- *
- * Revision 4.0.1.9 1993/02/05 19:48:43 lwall
- * patch36: now detects ambiguous use of filetest operators as well as unary
- * patch36: fixed ambiguity on - within tr///
- *
- * Revision 4.0.1.8 92/06/23 12:33:45 lwall
- * patch35: bad interaction between backslash and hyphen in tr///
- *
- * Revision 4.0.1.7 92/06/11 21:16:30 lwall
- * patch34: expectterm incorrectly set to indicate start of program or block
- *
- * Revision 4.0.1.6 92/06/08 16:03:49 lwall
- * patch20: an EXPR may now start with a bareword
- * patch20: print $fh EXPR can now expect term rather than operator in EXPR
- * patch20: added ... as variant on ..
- * patch20: new warning on spurious backslash
- * patch20: new warning on missing $ for foreach variable
- * patch20: "foo"x1024 now legal without space after x
- * patch20: new warning on print accidentally used as function
- * patch20: tr/stuff// wasn't working right
- * patch20: 2. now eats the dot
- * patch20: <@ARGV> now notices @ARGV
- * patch20: tr/// now lets you say \-
- *
- * Revision 4.0.1.5 91/11/11 16:45:51 lwall
- * patch19: default arg for shift was wrong after first subroutine definition
- *
- * Revision 4.0.1.4 91/11/05 19:02:48 lwall
- * patch11: \x and \c were subject to double interpretation in regexps
- * patch11: prepared for ctype implementations that don't define isascii()
- * patch11: nested list operators could miscount parens
- * patch11: once-thru blocks didn't display right in the debugger
- * patch11: sort eval "whatever" didn't work
- * patch11: underscore is now allowed within literal octal and hex numbers
- *
- * Revision 4.0.1.3 91/06/10 01:32:26 lwall
- * patch10: m'$foo' now treats string as single quoted
- * patch10: certain pattern optimizations were botched
- *
- * Revision 4.0.1.2 91/06/07 12:05:56 lwall
- * patch4: new copyright notice
- * patch4: debugger lost track of lines in eval
- * patch4: //o and s///o now optimize themselves fully at runtime
- * patch4: added global modifier for pattern matches
- *
- * Revision 4.0.1.1 91/04/12 09:18:18 lwall
- * patch1: perl -de "print" wouldn't stop at the first statement
- *
- * Revision 4.0 91/03/20 01:42:14 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-#include "perly.h"
-
-static void set_csh();
-
-#ifdef I_FCNTL
-#include <fcntl.h>
-#endif
-#ifdef I_SYS_FILE
-#include <sys/file.h>
-#endif
-
-#ifdef f_next
-#undef f_next
-#endif
-
-/* which backslash sequences to keep in m// or s// */
-
-static char *patleave = "\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}";
-
-char *reparse; /* if non-null, scanident found ${foo[$bar]} */
-
-void checkcomma();
-
-#ifdef CLINE
-#undef CLINE
-#endif
-#define CLINE (cmdline = (curcmd->c_line < cmdline ? curcmd->c_line : cmdline))
-
-#ifdef atarist
-#define PERL_META(c) ((c) | 128)
-#else
-#define META(c) ((c) | 128)
-#endif
-
-#define RETURN(retval) return (bufptr = s,(int)retval)
-#define OPERATOR(retval) return (expectterm = TRUE,bufptr = s,(int)retval)
-#define TERM(retval) return (CLINE, expectterm = FALSE,bufptr = s,(int)retval)
-#define LOOPX(f) return(yylval.ival=f,expectterm = FALSE,bufptr = s,(int)LOOPEX)
-#define FTST(f) return(yylval.ival=f,expectterm = TRUE,bufptr = s,(int)FILETEST)
-#define FUN0(f) return(yylval.ival = f,expectterm = FALSE,bufptr = s,(int)FUNC0)
-#define FUN1(f) return(yylval.ival = f,expectterm = FALSE,bufptr = s,(int)FUNC1)
-#define FUN2(f) return(yylval.ival = f,expectterm = FALSE,bufptr = s,(int)FUNC2)
-#define FUN2x(f) return(yylval.ival = f,expectterm = FALSE,bufptr = s,(int)FUNC2x)
-#define FUN3(f) return(yylval.ival = f,expectterm = FALSE,bufptr = s,(int)FUNC3)
-#define FUN4(f) return(yylval.ival = f,expectterm = FALSE,bufptr = s,(int)FUNC4)
-#define FUN5(f) return(yylval.ival = f,expectterm = FALSE,bufptr = s,(int)FUNC5)
-#define FL(f) return(yylval.ival=f,expectterm = FALSE,bufptr = s,(int)FLIST)
-#define FL2(f) return(yylval.ival=f,expectterm = FALSE,bufptr = s,(int)FLIST2)
-#define HFUN(f) return(yylval.ival=f,expectterm = TRUE,bufptr = s,(int)HSHFUN)
-#define HFUN3(f) return(yylval.ival=f,expectterm = FALSE,bufptr = s,(int)HSHFUN3)
-#define LFUN(f) return(yylval.ival=f,expectterm = TRUE,bufptr = s,(int)LVALFUN)
-#define AOP(f) return(yylval.ival=f,expectterm = TRUE,bufptr = s,(int)ADDOP)
-#define MOP(f) return(yylval.ival=f,expectterm = TRUE,bufptr = s,(int)MULOP)
-#define EOP(f) return(yylval.ival=f,expectterm = TRUE,bufptr = s,(int)EQOP)
-#define ROP(f) return(yylval.ival=f,expectterm = TRUE,bufptr = s,(int)RELOP)
-#define FOP(f) return(yylval.ival=f,expectterm = FALSE,bufptr = s,(int)FILOP)
-#define FOP2(f) return(yylval.ival=f,expectterm = FALSE,bufptr = s,(int)FILOP2)
-#define FOP3(f) return(yylval.ival=f,expectterm = FALSE,bufptr = s,(int)FILOP3)
-#define FOP4(f) return(yylval.ival=f,expectterm = FALSE,bufptr = s,(int)FILOP4)
-#define FOP22(f) return(yylval.ival=f,expectterm = FALSE,bufptr = s,(int)FILOP22)
-#define FOP25(f) return(yylval.ival=f,expectterm = FALSE,bufptr = s,(int)FILOP25)
-
-static char *last_uni;
-
-/* This bit of chicanery makes a unary function followed by
- * a parenthesis into a function with one argument, highest precedence.
- */
-#define UNI(f) return(yylval.ival = f, \
- expectterm = TRUE, \
- bufptr = s, \
- last_uni = oldbufptr, \
- (*s == '(' || (s = skipspace(s), *s == '(') ? (int)FUNC1 : (int)UNIOP) )
-
-/* This does similarly for list operators, merely by pretending that the
- * paren came before the listop rather than after.
- */
-#ifdef atarist
-#define LOP(f) return(CLINE, *s == '(' || (s = skipspace(s), *s == '(') ? \
- (*s = (char) PERL_META('('), bufptr = oldbufptr, '(') : \
- (yylval.ival=f,expectterm = TRUE,bufptr = s,(int)LISTOP))
-#else
-#define LOP(f) return(CLINE, *s == '(' || (s = skipspace(s), *s == '(') ? \
- (*s = (char) META('('), bufptr = oldbufptr, '(') : \
- (yylval.ival=f,expectterm = TRUE,bufptr = s,(int)LISTOP))
-#endif
-/* grandfather return to old style */
-#define OLDLOP(f) return(yylval.ival=f,expectterm = TRUE,bufptr = s,(int)LISTOP)
-
-char *
-skipspace(s)
-register char *s;
-{
- while (s < bufend && isSPACE(*s))
- s++;
- return s;
-}
-
-void
-check_uni() {
- char *s;
- char ch;
-
- if (oldoldbufptr != last_uni)
- return;
- while (isSPACE(*last_uni))
- last_uni++;
- for (s = last_uni; isALNUM(*s) || *s == '-'; s++) ;
- ch = *s;
- *s = '\0';
- warn("Warning: Use of \"%s\" without parens is ambiguous", last_uni);
- *s = ch;
-}
-
-#ifdef CRIPPLED_CC
-
-#undef UNI
-#undef LOP
-#define UNI(f) return uni(f,s)
-#define LOP(f) return lop(f,s)
-
-int
-uni(f,s)
-int f;
-char *s;
-{
- yylval.ival = f;
- expectterm = TRUE;
- bufptr = s;
- last_uni = oldbufptr;
- if (*s == '(')
- return FUNC1;
- s = skipspace(s);
- if (*s == '(')
- return FUNC1;
- else
- return UNIOP;
-}
-
-int
-lop(f,s)
-int f;
-char *s;
-{
- CLINE;
- if (*s != '(')
- s = skipspace(s);
- if (*s == '(') {
-#ifdef atarist
- *s = PERL_META('(');
-#else
- *s = META('(');
-#endif
- bufptr = oldbufptr;
- return '(';
- }
- else {
- yylval.ival=f;
- expectterm = TRUE;
- bufptr = s;
- return LISTOP;
- }
-}
-
-#endif /* CRIPPLED_CC */
-
-int
-yylex()
-{
- register char *s = bufptr;
- register char *d;
- register int tmp;
- static bool in_format = FALSE;
- static bool firstline = TRUE;
- extern int yychar; /* last token */
-
- oldoldbufptr = oldbufptr;
- oldbufptr = s;
-
- retry:
-#ifdef YYDEBUG
- if (debug & 1)
- if (index(s,'\n'))
- fprintf(stderr,"Tokener at %s",s);
- else
- fprintf(stderr,"Tokener at %s\n",s);
-#endif
-#ifdef BADSWITCH
- if (*s & 128) {
- if ((*s & 127) == '(') {
- *s++ = '(';
- oldbufptr = s;
- }
- else if ((*s & 127) == '}') {
- *s++ = '}';
- RETURN('}');
- }
- else
- warn("Unrecognized character \\%03o ignored", *s++ & 255);
- goto retry;
- }
-#endif
- switch (*s) {
- default:
- if ((*s & 127) == '(') {
- *s++ = '(';
- oldbufptr = s;
- }
- else if ((*s & 127) == '}') {
- *s++ = '}';
- RETURN('}');
- }
- else
- warn("Unrecognized character \\%03o ignored", *s++ & 255);
- goto retry;
- case 4:
- case 26:
- goto fake_eof; /* emulate EOF on ^D or ^Z */
- case 0:
- if (!rsfp)
- RETURN(0);
- if (s++ < bufend)
- goto retry; /* ignore stray nulls */
- last_uni = 0;
- if (firstline) {
- firstline = FALSE;
- if (minus_n || minus_p || perldb) {
- str_set(linestr,"");
- if (perldb) {
- char *getenv();
- char *pdb = getenv("PERLDB");
-
- str_cat(linestr, pdb ? pdb : "require 'perldb.pl'");
- str_cat(linestr, ";");
- }
- if (minus_n || minus_p) {
- str_cat(linestr,"line: while (<>) {");
- if (minus_l)
- str_cat(linestr,"chop;");
- if (minus_a)
- str_cat(linestr,"@F=split(' ');");
- }
- oldoldbufptr = oldbufptr = s = str_get(linestr);
- bufend = linestr->str_ptr + linestr->str_cur;
- goto retry;
- }
- }
- if (in_format) {
- bufptr = bufend;
- yylval.formval = load_format();
- in_format = FALSE;
- oldoldbufptr = oldbufptr = s = str_get(linestr) + 1;
- bufend = linestr->str_ptr + linestr->str_cur;
- OPERATOR(FORMLIST);
- }
- curcmd->c_line++;
-#ifdef CRYPTSCRIPT
- cryptswitch();
-#endif /* CRYPTSCRIPT */
- do {
- if ((s = str_gets(linestr, rsfp, 0)) == Nullch) {
- fake_eof:
- if (rsfp) {
- if (preprocess)
- (void)mypclose(rsfp);
- else if ((FILE*)rsfp == stdin)
- clearerr(stdin);
- else
- (void)fclose(rsfp);
- rsfp = Nullfp;
- }
- if (minus_n || minus_p) {
- str_set(linestr,minus_p ? ";}continue{print" : "");
- str_cat(linestr,";}");
- oldoldbufptr = oldbufptr = s = str_get(linestr);
- bufend = linestr->str_ptr + linestr->str_cur;
- minus_n = minus_p = 0;
- goto retry;
- }
- oldoldbufptr = oldbufptr = s = str_get(linestr);
- str_set(linestr,"");
- RETURN(';'); /* not infinite loop because rsfp is NULL now */
- }
- if (doextract && *linestr->str_ptr == '#')
- doextract = FALSE;
- } while (doextract);
- oldoldbufptr = oldbufptr = bufptr = s;
- if (perldb) {
- STR *str = Str_new(85,0);
-
- str_sset(str,linestr);
- astore(stab_xarray(curcmd->c_filestab),(int)curcmd->c_line,str);
- }
-#ifdef DEBUG
- if (firstline) {
- char *showinput();
- s = showinput();
- }
-#endif
- bufend = linestr->str_ptr + linestr->str_cur;
- if (curcmd->c_line == 1) {
- if (*s == '#' && s[1] == '!') {
- if (!in_eval && !instr(s,"perl") && instr(origargv[0],"perl")) {
- char **newargv;
- char *cmd;
-
- s += 2;
- if (*s == ' ')
- s++;
- cmd = s;
- while (s < bufend && !isSPACE(*s))
- s++;
- *s++ = '\0';
- while (s < bufend && isSPACE(*s))
- s++;
- if (s < bufend) {
- Newz(899,newargv,origargc+3,char*);
- newargv[1] = s;
- while (s < bufend && !isSPACE(*s))
- s++;
- *s = '\0';
- Copy(origargv+1, newargv+2, origargc+1, char*);
- }
- else
- newargv = origargv;
- newargv[0] = cmd;
- execv(cmd,newargv);
- fatal("Can't exec %s", cmd);
- }
- }
- else {
- while (s < bufend && isSPACE(*s))
- s++;
- if (*s == ':') /* for csh's that have to exec sh scripts */
- s++;
- }
- }
- goto retry;
- case ' ': case '\t': case '\f': case '\r': case 013:
- s++;
- goto retry;
- case '#':
- if (preprocess && s == str_get(linestr) &&
- s[1] == ' ' && (isDIGIT(s[2]) || strnEQ(s+2,"line ",5)) ) {
- while (*s && !isDIGIT(*s))
- s++;
- curcmd->c_line = atoi(s)-1;
- while (isDIGIT(*s))
- s++;
- d = bufend;
- while (s < d && isSPACE(*s)) s++;
- s[strlen(s)-1] = '\0'; /* wipe out newline */
- if (*s == '"') {
- s++;
- s[strlen(s)-1] = '\0'; /* wipe out trailing quote */
- }
- if (*s)
- curcmd->c_filestab = fstab(s);
- else
- curcmd->c_filestab = fstab(origfilename);
- oldoldbufptr = oldbufptr = s = str_get(linestr);
- }
- /* FALL THROUGH */
- case '\n':
- if (in_eval && !rsfp) {
- d = bufend;
- while (s < d && *s != '\n')
- s++;
- if (s < d)
- s++;
- if (in_format) {
- bufptr = s;
- yylval.formval = load_format();
- in_format = FALSE;
- oldoldbufptr = oldbufptr = s = bufptr + 1;
- TERM(FORMLIST);
- }
- curcmd->c_line++;
- }
- else {
- *s = '\0';
- bufend = s;
- }
- goto retry;
- case '-':
- if (s[1] && isALPHA(s[1]) && !isALPHA(s[2])) {
- s++;
- last_uni = oldbufptr;
- switch (*s++) {
- case 'r': FTST(O_FTEREAD);
- case 'w': FTST(O_FTEWRITE);
- case 'x': FTST(O_FTEEXEC);
- case 'o': FTST(O_FTEOWNED);
- case 'R': FTST(O_FTRREAD);
- case 'W': FTST(O_FTRWRITE);
- case 'X': FTST(O_FTREXEC);
- case 'O': FTST(O_FTROWNED);
- case 'e': FTST(O_FTIS);
- case 'z': FTST(O_FTZERO);
- case 's': FTST(O_FTSIZE);
- case 'f': FTST(O_FTFILE);
- case 'd': FTST(O_FTDIR);
- case 'l': FTST(O_FTLINK);
- case 'p': FTST(O_FTPIPE);
- case 'S': FTST(O_FTSOCK);
- case 'u': FTST(O_FTSUID);
- case 'g': FTST(O_FTSGID);
- case 'k': FTST(O_FTSVTX);
- case 'b': FTST(O_FTBLK);
- case 'c': FTST(O_FTCHR);
- case 't': FTST(O_FTTTY);
- case 'T': FTST(O_FTTEXT);
- case 'B': FTST(O_FTBINARY);
- case 'M': stabent("\024",TRUE); FTST(O_FTMTIME);
- case 'A': stabent("\024",TRUE); FTST(O_FTATIME);
- case 'C': stabent("\024",TRUE); FTST(O_FTCTIME);
- default:
- s -= 2;
- break;
- }
- }
- tmp = *s++;
- if (*s == tmp) {
- s++;
- RETURN(DEC);
- }
- if (expectterm) {
- if (isSPACE(*s) || !isSPACE(*bufptr))
- check_uni();
- OPERATOR('-');
- }
- else
- AOP(O_SUBTRACT);
- case '+':
- tmp = *s++;
- if (*s == tmp) {
- s++;
- RETURN(INC);
- }
- if (expectterm) {
- if (isSPACE(*s) || !isSPACE(*bufptr))
- check_uni();
- OPERATOR('+');
- }
- else
- AOP(O_ADD);
-
- case '*':
- if (expectterm) {
- check_uni();
- s = scanident(s,bufend,tokenbuf,sizeof tokenbuf);
- yylval.stabval = stabent(tokenbuf,TRUE);
- TERM(STAR);
- }
- tmp = *s++;
- if (*s == tmp) {
- s++;
- OPERATOR(POW);
- }
- MOP(O_MULTIPLY);
- case '%':
- if (expectterm) {
- if (!isALPHA(s[1]))
- check_uni();
- s = scanident(s,bufend,tokenbuf,sizeof tokenbuf);
- yylval.stabval = hadd(stabent(tokenbuf,TRUE));
- TERM(HSH);
- }
- s++;
- MOP(O_MODULO);
-
- case '^':
- case '~':
- case '(':
- case ',':
- case ':':
- case '[':
- tmp = *s++;
- OPERATOR(tmp);
- case '{':
- tmp = *s++;
- yylval.ival = curcmd->c_line;
- if (isSPACE(*s) || *s == '#')
- cmdline = NOLINE; /* invalidate current command line number */
- expectterm = 2;
- RETURN(tmp);
- case ';':
- if (curcmd->c_line < cmdline)
- cmdline = curcmd->c_line;
- tmp = *s++;
- OPERATOR(tmp);
- case ')':
- case ']':
- tmp = *s++;
- TERM(tmp);
- case '}':
- *s |= 128;
- RETURN(';');
- case '&':
- s++;
- tmp = *s++;
- if (tmp == '&')
- OPERATOR(ANDAND);
- s--;
- if (expectterm) {
- d = bufend;
- while (s < d && isSPACE(*s))
- s++;
- if (isALPHA(*s) || *s == '_' || *s == '\'')
- *(--s) = '\\'; /* force next ident to WORD */
- else
- check_uni();
- OPERATOR(AMPER);
- }
- OPERATOR('&');
- case '|':
- s++;
- tmp = *s++;
- if (tmp == '|')
- OPERATOR(OROR);
- s--;
- OPERATOR('|');
- case '=':
- s++;
- tmp = *s++;
- if (tmp == '=')
- EOP(O_EQ);
- if (tmp == '~')
- OPERATOR(MATCH);
- s--;
- OPERATOR('=');
- case '!':
- s++;
- tmp = *s++;
- if (tmp == '=')
- EOP(O_NE);
- if (tmp == '~')
- OPERATOR(NMATCH);
- s--;
- OPERATOR('!');
- case '<':
- if (expectterm) {
- if (s[1] != '<' && !index(s,'>'))
- check_uni();
- s = scanstr(s, SCAN_DEF);
- TERM(RSTRING);
- }
- s++;
- tmp = *s++;
- if (tmp == '<')
- OPERATOR(LS);
- if (tmp == '=') {
- tmp = *s++;
- if (tmp == '>')
- EOP(O_NCMP);
- s--;
- ROP(O_LE);
- }
- s--;
- ROP(O_LT);
- case '>':
- s++;
- tmp = *s++;
- if (tmp == '>')
- OPERATOR(RS);
- if (tmp == '=')
- ROP(O_GE);
- s--;
- ROP(O_GT);
-
-#define SNARFWORD \
- d = tokenbuf; \
- while (isALNUM(*s) || *s == '\'') \
- *d++ = *s++; \
- while (d[-1] == '\'') \
- d--,s--; \
- *d = '\0'; \
- d = tokenbuf;
-
- case '$':
- if (s[1] == '#' && (isALPHA(s[2]) || s[2] == '_')) {
- s++;
- s = scanident(s,bufend,tokenbuf,sizeof tokenbuf);
- yylval.stabval = aadd(stabent(tokenbuf,TRUE));
- TERM(ARYLEN);
- }
- d = s;
- s = scanident(s,bufend,tokenbuf,sizeof tokenbuf);
- if (reparse) { /* turn ${foo[bar]} into ($foo[bar]) */
- do_reparse:
- s[-1] = ')';
- s = d;
- s[1] = s[0];
- s[0] = '(';
- goto retry;
- }
- yylval.stabval = stabent(tokenbuf,TRUE);
- expectterm = FALSE;
- if (isSPACE(*s) && oldoldbufptr && oldoldbufptr < bufptr) {
- s++;
- while (isSPACE(*oldoldbufptr))
- oldoldbufptr++;
- if (*oldoldbufptr == 'p' && strnEQ(oldoldbufptr,"print",5)) {
- if (index("&*<%", *s) && isALPHA(s[1]))
- expectterm = TRUE; /* e.g. print $fh &sub */
- else if (*s == '.' && isDIGIT(s[1]))
- expectterm = TRUE; /* e.g. print $fh .3 */
- else if (index("/?-+", *s) && !isSPACE(s[1]))
- expectterm = TRUE; /* e.g. print $fh -1 */
- }
- }
- RETURN(REG);
-
- case '@':
- d = s;
- s = scanident(s,bufend,tokenbuf,sizeof tokenbuf);
- if (reparse)
- goto do_reparse;
- yylval.stabval = aadd(stabent(tokenbuf,TRUE));
- TERM(ARY);
-
- case '/': /* may either be division or pattern */
- case '?': /* may either be conditional or pattern */
- if (expectterm) {
- check_uni();
- s = scanpat(s);
- TERM(PATTERN);
- }
- tmp = *s++;
- if (tmp == '/')
- MOP(O_DIVIDE);
- OPERATOR(tmp);
-
- case '.':
- if (!expectterm || !isDIGIT(s[1])) {
- tmp = *s++;
- if (*s == tmp) {
- s++;
- if (*s == tmp) {
- s++;
- yylval.ival = 0;
- }
- else
- yylval.ival = AF_COMMON;
- OPERATOR(DOTDOT);
- }
- if (expectterm)
- check_uni();
- AOP(O_CONCAT);
- }
- /* FALL THROUGH */
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case '\'': case '"': case '`':
- s = scanstr(s, SCAN_DEF);
- TERM(RSTRING);
-
- case '\\': /* some magic to force next word to be a WORD */
- s++; /* used by do and sub to force a separate namespace */
- if (!isALPHA(*s) && *s != '_' && *s != '\'') {
- warn("Spurious backslash ignored");
- goto retry;
- }
- /* FALL THROUGH */
- case '_':
- SNARFWORD;
- if (d[1] == '_') {
- if (strEQ(d,"__LINE__") || strEQ(d,"__FILE__")) {
- ARG *arg = op_new(1);
-
- yylval.arg = arg;
- arg->arg_type = O_ITEM;
- if (d[2] == 'L')
- (void)sprintf(tokenbuf,"%ld",(long)curcmd->c_line);
- else
- strcpy(tokenbuf, stab_val(curcmd->c_filestab)->str_ptr);
- arg[1].arg_type = A_SINGLE;
- arg[1].arg_ptr.arg_str = str_make(tokenbuf,strlen(tokenbuf));
- TERM(RSTRING);
- }
- else if (strEQ(d,"__END__")) {
- STAB *stab;
- int fd;
-
- /*SUPPRESS 560*/
- if (!in_eval && (stab = stabent("DATA",FALSE))) {
- stab->str_pok |= SP_MULTI;
- if (!stab_io(stab))
- stab_io(stab) = stio_new();
- stab_io(stab)->ifp = rsfp;
-#if defined(HAS_FCNTL) && defined(F_SETFD)
- fd = fileno(rsfp);
- fcntl(fd,F_SETFD,fd >= 3);
-#endif
- if (preprocess)
- stab_io(stab)->type = '|';
- else if ((FILE*)rsfp == stdin)
- stab_io(stab)->type = '-';
- else
- stab_io(stab)->type = '<';
- rsfp = Nullfp;
- }
- goto fake_eof;
- }
- }
- break;
- case 'a': case 'A':
- SNARFWORD;
- if (strEQ(d,"alarm"))
- UNI(O_ALARM);
- if (strEQ(d,"accept"))
- FOP22(O_ACCEPT);
- if (strEQ(d,"atan2"))
- FUN2(O_ATAN2);
- break;
- case 'b': case 'B':
- SNARFWORD;
- if (strEQ(d,"bind"))
- FOP2(O_BIND);
- if (strEQ(d,"binmode"))
- FOP(O_BINMODE);
- break;
- case 'c': case 'C':
- SNARFWORD;
- if (strEQ(d,"chop"))
- LFUN(O_CHOP);
- if (strEQ(d,"continue"))
- OPERATOR(CONTINUE);
- if (strEQ(d,"chdir")) {
- (void)stabent("ENV",TRUE); /* may use HOME */
- UNI(O_CHDIR);
- }
- if (strEQ(d,"close"))
- FOP(O_CLOSE);
- if (strEQ(d,"closedir"))
- FOP(O_CLOSEDIR);
- if (strEQ(d,"cmp"))
- EOP(O_SCMP);
- if (strEQ(d,"caller"))
- UNI(O_CALLER);
- if (strEQ(d,"crypt")) {
-#ifdef FCRYPT
- static int cryptseen = 0;
-
- if (!cryptseen++)
- init_des();
-#endif
- FUN2(O_CRYPT);
- }
- if (strEQ(d,"chmod"))
- LOP(O_CHMOD);
- if (strEQ(d,"chown"))
- LOP(O_CHOWN);
- if (strEQ(d,"connect"))
- FOP2(O_CONNECT);
- if (strEQ(d,"cos"))
- UNI(O_COS);
- if (strEQ(d,"chroot"))
- UNI(O_CHROOT);
- break;
- case 'd': case 'D':
- SNARFWORD;
- if (strEQ(d,"do")) {
- d = bufend;
- while (s < d && isSPACE(*s))
- s++;
- if (isALPHA(*s) || *s == '_')
- *(--s) = '\\'; /* force next ident to WORD */
- OPERATOR(DO);
- }
- if (strEQ(d,"die"))
- LOP(O_DIE);
- if (strEQ(d,"defined"))
- LFUN(O_DEFINED);
- if (strEQ(d,"delete"))
- OPERATOR(DELETE);
- if (strEQ(d,"dbmopen"))
- HFUN3(O_DBMOPEN);
- if (strEQ(d,"dbmclose"))
- HFUN(O_DBMCLOSE);
- if (strEQ(d,"dump"))
- LOOPX(O_DUMP);
- break;
- case 'e': case 'E':
- SNARFWORD;
- if (strEQ(d,"else"))
- OPERATOR(ELSE);
- if (strEQ(d,"elsif")) {
- yylval.ival = curcmd->c_line;
- OPERATOR(ELSIF);
- }
- if (strEQ(d,"eq") || strEQ(d,"EQ"))
- EOP(O_SEQ);
- if (strEQ(d,"exit"))
- UNI(O_EXIT);
- if (strEQ(d,"eval")) {
- allstabs = TRUE; /* must initialize everything since */
- UNI(O_EVAL); /* we don't know what will be used */
- }
- if (strEQ(d,"eof"))
- FOP(O_EOF);
- if (strEQ(d,"exp"))
- UNI(O_EXP);
- if (strEQ(d,"each"))
- HFUN(O_EACH);
- if (strEQ(d,"exec")) {
- set_csh();
- LOP(O_EXEC_OP);
- }
- if (strEQ(d,"endhostent"))
- FUN0(O_EHOSTENT);
- if (strEQ(d,"endnetent"))
- FUN0(O_ENETENT);
- if (strEQ(d,"endservent"))
- FUN0(O_ESERVENT);
- if (strEQ(d,"endprotoent"))
- FUN0(O_EPROTOENT);
- if (strEQ(d,"endpwent"))
- FUN0(O_EPWENT);
- if (strEQ(d,"endgrent"))
- FUN0(O_EGRENT);
- break;
- case 'f': case 'F':
- SNARFWORD;
- if (strEQ(d,"for") || strEQ(d,"foreach")) {
- yylval.ival = curcmd->c_line;
- while (s < bufend && isSPACE(*s))
- s++;
- if (isALPHA(*s))
- fatal("Missing $ on loop variable");
- OPERATOR(FOR);
- }
- if (strEQ(d,"format")) {
- d = bufend;
- while (s < d && isSPACE(*s))
- s++;
- if (isALPHA(*s) || *s == '_')
- *(--s) = '\\'; /* force next ident to WORD */
- in_format = TRUE;
- allstabs = TRUE; /* must initialize everything since */
- OPERATOR(FORMAT); /* we don't know what will be used */
- }
- if (strEQ(d,"fork"))
- FUN0(O_FORK);
- if (strEQ(d,"fcntl"))
- FOP3(O_FCNTL);
- if (strEQ(d,"fileno"))
- FOP(O_FILENO);
- if (strEQ(d,"flock"))
- FOP2(O_FLOCK);
- break;
- case 'g': case 'G':
- SNARFWORD;
- if (strEQ(d,"gt") || strEQ(d,"GT"))
- ROP(O_SGT);
- if (strEQ(d,"ge") || strEQ(d,"GE"))
- ROP(O_SGE);
- if (strEQ(d,"grep"))
- FL2(O_GREP);
- if (strEQ(d,"goto"))
- LOOPX(O_GOTO);
- if (strEQ(d,"gmtime"))
- UNI(O_GMTIME);
- if (strEQ(d,"getc"))
- FOP(O_GETC);
- if (strnEQ(d,"get",3)) {
- d += 3;
- if (*d == 'p') {
- if (strEQ(d,"ppid"))
- FUN0(O_GETPPID);
- if (strEQ(d,"pgrp"))
- UNI(O_GETPGRP);
- if (strEQ(d,"priority"))
- FUN2(O_GETPRIORITY);
- if (strEQ(d,"protobyname"))
- UNI(O_GPBYNAME);
- if (strEQ(d,"protobynumber"))
- FUN1(O_GPBYNUMBER);
- if (strEQ(d,"protoent"))
- FUN0(O_GPROTOENT);
- if (strEQ(d,"pwent"))
- FUN0(O_GPWENT);
- if (strEQ(d,"pwnam"))
- FUN1(O_GPWNAM);
- if (strEQ(d,"pwuid"))
- FUN1(O_GPWUID);
- if (strEQ(d,"peername"))
- FOP(O_GETPEERNAME);
- }
- else if (*d == 'h') {
- if (strEQ(d,"hostbyname"))
- UNI(O_GHBYNAME);
- if (strEQ(d,"hostbyaddr"))
- FUN2(O_GHBYADDR);
- if (strEQ(d,"hostent"))
- FUN0(O_GHOSTENT);
- }
- else if (*d == 'n') {
- if (strEQ(d,"netbyname"))
- UNI(O_GNBYNAME);
- if (strEQ(d,"netbyaddr"))
- FUN2(O_GNBYADDR);
- if (strEQ(d,"netent"))
- FUN0(O_GNETENT);
- }
- else if (*d == 's') {
- if (strEQ(d,"servbyname"))
- FUN2(O_GSBYNAME);
- if (strEQ(d,"servbyport"))
- FUN2(O_GSBYPORT);
- if (strEQ(d,"servent"))
- FUN0(O_GSERVENT);
- if (strEQ(d,"sockname"))
- FOP(O_GETSOCKNAME);
- if (strEQ(d,"sockopt"))
- FOP3(O_GSOCKOPT);
- }
- else if (*d == 'g') {
- if (strEQ(d,"grent"))
- FUN0(O_GGRENT);
- if (strEQ(d,"grnam"))
- FUN1(O_GGRNAM);
- if (strEQ(d,"grgid"))
- FUN1(O_GGRGID);
- }
- else if (*d == 'l') {
- if (strEQ(d,"login"))
- FUN0(O_GETLOGIN);
- }
- d -= 3;
- }
- break;
- case 'h': case 'H':
- SNARFWORD;
- if (strEQ(d,"hex"))
- UNI(O_HEX);
- break;
- case 'i': case 'I':
- SNARFWORD;
- if (strEQ(d,"if")) {
- yylval.ival = curcmd->c_line;
- OPERATOR(IF);
- }
- if (strEQ(d,"index"))
- FUN2x(O_INDEX);
- if (strEQ(d,"int"))
- UNI(O_INT);
- if (strEQ(d,"ioctl"))
- FOP3(O_IOCTL);
- break;
- case 'j': case 'J':
- SNARFWORD;
- if (strEQ(d,"join"))
- FL2(O_JOIN);
- break;
- case 'k': case 'K':
- SNARFWORD;
- if (strEQ(d,"keys"))
- HFUN(O_KEYS);
- if (strEQ(d,"kill"))
- LOP(O_KILL);
- break;
- case 'l': case 'L':
- SNARFWORD;
- if (strEQ(d,"last"))
- LOOPX(O_LAST);
- if (strEQ(d,"local"))
- OPERATOR(LOCAL);
- if (strEQ(d,"length"))
- UNI(O_LENGTH);
- if (strEQ(d,"lt") || strEQ(d,"LT"))
- ROP(O_SLT);
- if (strEQ(d,"le") || strEQ(d,"LE"))
- ROP(O_SLE);
- if (strEQ(d,"localtime"))
- UNI(O_LOCALTIME);
- if (strEQ(d,"log"))
- UNI(O_LOG);
- if (strEQ(d,"link"))
- FUN2(O_LINK);
- if (strEQ(d,"listen"))
- FOP2(O_LISTEN);
- if (strEQ(d,"lstat"))
- FOP(O_LSTAT);
- break;
- case 'm': case 'M':
- if (s[1] == '\'') {
- d = "m";
- s++;
- }
- else {
- SNARFWORD;
- }
- if (strEQ(d,"m")) {
- s = scanpat(s-1);
- if (yylval.arg)
- TERM(PATTERN);
- else
- RETURN(1); /* force error */
- }
- switch (d[1]) {
- case 'k':
- if (strEQ(d,"mkdir"))
- FUN2(O_MKDIR);
- break;
- case 's':
- if (strEQ(d,"msgctl"))
- FUN3(O_MSGCTL);
- if (strEQ(d,"msgget"))
- FUN2(O_MSGGET);
- if (strEQ(d,"msgrcv"))
- FUN5(O_MSGRCV);
- if (strEQ(d,"msgsnd"))
- FUN3(O_MSGSND);
- break;
- }
- break;
- case 'n': case 'N':
- SNARFWORD;
- if (strEQ(d,"next"))
- LOOPX(O_NEXT);
- if (strEQ(d,"ne") || strEQ(d,"NE"))
- EOP(O_SNE);
- break;
- case 'o': case 'O':
- SNARFWORD;
- if (strEQ(d,"open"))
- OPERATOR(OPEN);
- if (strEQ(d,"ord"))
- UNI(O_ORD);
- if (strEQ(d,"oct"))
- UNI(O_OCT);
- if (strEQ(d,"opendir"))
- FOP2(O_OPEN_DIR);
- break;
- case 'p': case 'P':
- SNARFWORD;
- if (strEQ(d,"print")) {
- checkcomma(s,d,"filehandle");
- LOP(O_PRINT);
- }
- if (strEQ(d,"printf")) {
- checkcomma(s,d,"filehandle");
- LOP(O_PRTF);
- }
- if (strEQ(d,"push")) {
- yylval.ival = O_PUSH;
- OPERATOR(PUSH);
- }
- if (strEQ(d,"pop"))
- OPERATOR(POP);
- if (strEQ(d,"pack"))
- FL2(O_PACK);
- if (strEQ(d,"package"))
- OPERATOR(PACKAGE);
- if (strEQ(d,"pipe"))
- FOP22(O_PIPE_OP);
- break;
- case 'q': case 'Q':
- SNARFWORD;
- if (strEQ(d,"q")) {
- s = scanstr(s-1, SCAN_DEF);
- TERM(RSTRING);
- }
- if (strEQ(d,"qq")) {
- s = scanstr(s-2, SCAN_DEF);
- TERM(RSTRING);
- }
- if (strEQ(d,"qx")) {
- s = scanstr(s-2, SCAN_DEF);
- TERM(RSTRING);
- }
- break;
- case 'r': case 'R':
- SNARFWORD;
- if (strEQ(d,"return"))
- OLDLOP(O_RETURN);
- if (strEQ(d,"require")) {
- allstabs = TRUE; /* must initialize everything since */
- UNI(O_REQUIRE); /* we don't know what will be used */
- }
- if (strEQ(d,"reset"))
- UNI(O_RESET);
- if (strEQ(d,"redo"))
- LOOPX(O_REDO);
- if (strEQ(d,"rename"))
- FUN2(O_RENAME);
- if (strEQ(d,"rand"))
- UNI(O_RAND);
- if (strEQ(d,"rmdir"))
- UNI(O_RMDIR);
- if (strEQ(d,"rindex"))
- FUN2x(O_RINDEX);
- if (strEQ(d,"read"))
- FOP3(O_READ);
- if (strEQ(d,"readdir"))
- FOP(O_READDIR);
- if (strEQ(d,"rewinddir"))
- FOP(O_REWINDDIR);
- if (strEQ(d,"recv"))
- FOP4(O_RECV);
- if (strEQ(d,"reverse"))
- LOP(O_REVERSE);
- if (strEQ(d,"readlink"))
- UNI(O_READLINK);
- break;
- case 's': case 'S':
- if (s[1] == '\'') {
- d = "s";
- s++;
- }
- else {
- SNARFWORD;
- }
- if (strEQ(d,"s")) {
- s = scansubst(s);
- if (yylval.arg)
- TERM(SUBST);
- else
- RETURN(1); /* force error */
- }
- switch (d[1]) {
- case 'a':
- case 'b':
- break;
- case 'c':
- if (strEQ(d,"scalar"))
- UNI(O_SCALAR);
- break;
- case 'd':
- break;
- case 'e':
- if (strEQ(d,"select"))
- OPERATOR(SSELECT);
- if (strEQ(d,"seek"))
- FOP3(O_SEEK);
- if (strEQ(d,"semctl"))
- FUN4(O_SEMCTL);
- if (strEQ(d,"semget"))
- FUN3(O_SEMGET);
- if (strEQ(d,"semop"))
- FUN2(O_SEMOP);
- if (strEQ(d,"send"))
- FOP3(O_SEND);
- if (strEQ(d,"setpgrp"))
- FUN2(O_SETPGRP);
- if (strEQ(d,"setpriority"))
- FUN3(O_SETPRIORITY);
- if (strEQ(d,"sethostent"))
- FUN1(O_SHOSTENT);
- if (strEQ(d,"setnetent"))
- FUN1(O_SNETENT);
- if (strEQ(d,"setservent"))
- FUN1(O_SSERVENT);
- if (strEQ(d,"setprotoent"))
- FUN1(O_SPROTOENT);
- if (strEQ(d,"setpwent"))
- FUN0(O_SPWENT);
- if (strEQ(d,"setgrent"))
- FUN0(O_SGRENT);
- if (strEQ(d,"seekdir"))
- FOP2(O_SEEKDIR);
- if (strEQ(d,"setsockopt"))
- FOP4(O_SSOCKOPT);
- break;
- case 'f':
- case 'g':
- break;
- case 'h':
- if (strEQ(d,"shift"))
- TERM(SHIFT);
- if (strEQ(d,"shmctl"))
- FUN3(O_SHMCTL);
- if (strEQ(d,"shmget"))
- FUN3(O_SHMGET);
- if (strEQ(d,"shmread"))
- FUN4(O_SHMREAD);
- if (strEQ(d,"shmwrite"))
- FUN4(O_SHMWRITE);
- if (strEQ(d,"shutdown"))
- FOP2(O_SHUTDOWN);
- break;
- case 'i':
- if (strEQ(d,"sin"))
- UNI(O_SIN);
- break;
- case 'j':
- case 'k':
- break;
- case 'l':
- if (strEQ(d,"sleep"))
- UNI(O_SLEEP);
- break;
- case 'm':
- case 'n':
- break;
- case 'o':
- if (strEQ(d,"socket"))
- FOP4(O_SOCKET);
- if (strEQ(d,"socketpair"))
- FOP25(O_SOCKPAIR);
- if (strEQ(d,"sort")) {
- checkcomma(s,d,"subroutine name");
- d = bufend;
- while (s < d && isSPACE(*s)) s++;
- if (*s == ';' || *s == ')') /* probably a close */
- fatal("sort is now a reserved word");
- if (isALPHA(*s) || *s == '_') {
- /*SUPPRESS 530*/
- for (d = s; isALNUM(*d); d++) ;
- strncpy(tokenbuf,s,d-s);
- tokenbuf[d-s] = '\0';
- if (strNE(tokenbuf,"keys") &&
- strNE(tokenbuf,"values") &&
- strNE(tokenbuf,"split") &&
- strNE(tokenbuf,"grep") &&
- strNE(tokenbuf,"readdir") &&
- strNE(tokenbuf,"unpack") &&
- strNE(tokenbuf,"do") &&
- strNE(tokenbuf,"eval") &&
- (d >= bufend || isSPACE(*d)) )
- *(--s) = '\\'; /* force next ident to WORD */
- }
- LOP(O_SORT);
- }
- break;
- case 'p':
- if (strEQ(d,"split"))
- TERM(SPLIT);
- if (strEQ(d,"sprintf"))
- FL(O_SPRINTF);
- if (strEQ(d,"splice")) {
- yylval.ival = O_SPLICE;
- OPERATOR(PUSH);
- }
- break;
- case 'q':
- if (strEQ(d,"sqrt"))
- UNI(O_SQRT);
- break;
- case 'r':
- if (strEQ(d,"srand"))
- UNI(O_SRAND);
- break;
- case 's':
- break;
- case 't':
- if (strEQ(d,"stat"))
- FOP(O_STAT);
- if (strEQ(d,"study")) {
- sawstudy++;
- LFUN(O_STUDY);
- }
- break;
- case 'u':
- if (strEQ(d,"substr"))
- FUN2x(O_SUBSTR);
- if (strEQ(d,"sub")) {
- yylval.ival = savestack->ary_fill; /* restore stuff on reduce */
- savelong(&subline);
- saveitem(subname);
-
- subline = curcmd->c_line;
- d = bufend;
- while (s < d && isSPACE(*s))
- s++;
- if (isALPHA(*s) || *s == '_' || *s == '\'') {
- str_sset(subname,curstname);
- str_ncat(subname,"'",1);
- for (d = s+1; isALNUM(*d) || *d == '\''; d++)
- /*SUPPRESS 530*/
- ;
- if (d[-1] == '\'')
- d--;
- str_ncat(subname,s,d-s);
- *(--s) = '\\'; /* force next ident to WORD */
- }
- else
- str_set(subname,"?");
- OPERATOR(SUB);
- }
- break;
- case 'v':
- case 'w':
- case 'x':
- break;
- case 'y':
- if (strEQ(d,"system")) {
- set_csh();
- LOP(O_SYSTEM);
- }
- if (strEQ(d,"symlink"))
- FUN2(O_SYMLINK);
- if (strEQ(d,"syscall"))
- LOP(O_SYSCALL);
- if (strEQ(d,"sysread"))
- FOP3(O_SYSREAD);
- if (strEQ(d,"syswrite"))
- FOP3(O_SYSWRITE);
- break;
- case 'z':
- break;
- }
- break;
- case 't': case 'T':
- SNARFWORD;
- if (strEQ(d,"tr")) {
- s = scantrans(s);
- if (yylval.arg)
- TERM(TRANS);
- else
- RETURN(1); /* force error */
- }
- if (strEQ(d,"tell"))
- FOP(O_TELL);
- if (strEQ(d,"telldir"))
- FOP(O_TELLDIR);
- if (strEQ(d,"time"))
- FUN0(O_TIME);
- if (strEQ(d,"times"))
- FUN0(O_TMS);
- if (strEQ(d,"truncate"))
- FOP2(O_TRUNCATE);
- break;
- case 'u': case 'U':
- SNARFWORD;
- if (strEQ(d,"using"))
- OPERATOR(USING);
- if (strEQ(d,"until")) {
- yylval.ival = curcmd->c_line;
- OPERATOR(UNTIL);
- }
- if (strEQ(d,"unless")) {
- yylval.ival = curcmd->c_line;
- OPERATOR(UNLESS);
- }
- if (strEQ(d,"unlink"))
- LOP(O_UNLINK);
- if (strEQ(d,"undef"))
- LFUN(O_UNDEF);
- if (strEQ(d,"unpack"))
- FUN2(O_UNPACK);
- if (strEQ(d,"utime"))
- LOP(O_UTIME);
- if (strEQ(d,"umask"))
- UNI(O_UMASK);
- if (strEQ(d,"unshift")) {
- yylval.ival = O_UNSHIFT;
- OPERATOR(PUSH);
- }
- break;
- case 'v': case 'V':
- SNARFWORD;
- if (strEQ(d,"values"))
- HFUN(O_VALUES);
- if (strEQ(d,"vec")) {
- sawvec = TRUE;
- FUN3(O_VEC);
- }
- break;
- case 'w': case 'W':
- SNARFWORD;
- if (strEQ(d,"while")) {
- yylval.ival = curcmd->c_line;
- OPERATOR(WHILE);
- }
- if (strEQ(d,"warn"))
- LOP(O_WARN);
- if (strEQ(d,"wait"))
- FUN0(O_WAIT);
- if (strEQ(d,"waitpid"))
- FUN2(O_WAITPID);
- if (strEQ(d,"wantarray")) {
- yylval.arg = op_new(1);
- yylval.arg->arg_type = O_ITEM;
- yylval.arg[1].arg_type = A_WANTARRAY;
- TERM(RSTRING);
- }
- if (strEQ(d,"write"))
- FOP(O_WRITE);
- break;
- case 'x': case 'X':
- if (*s == 'x' && isDIGIT(s[1]) && !expectterm) {
- s++;
- MOP(O_REPEAT);
- }
- SNARFWORD;
- if (strEQ(d,"x")) {
- if (!expectterm)
- MOP(O_REPEAT);
- check_uni();
- }
- break;
- case 'y': case 'Y':
- if (s[1] == '\'') {
- d = "y";
- s++;
- }
- else {
- SNARFWORD;
- }
- if (strEQ(d,"y")) {
- s = scantrans(s);
- TERM(TRANS);
- }
- break;
- case 'z': case 'Z':
- SNARFWORD;
- break;
- }
- yylval.cval = savestr(d);
- if (expectterm == 2) { /* special case: start of statement */
- while (isSPACE(*s)) s++;
- if (*s == ':') {
- s++;
- CLINE;
- OPERATOR(LABEL);
- }
- TERM(WORD);
- }
- expectterm = FALSE;
- if (oldoldbufptr && oldoldbufptr < bufptr) {
- while (isSPACE(*oldoldbufptr))
- oldoldbufptr++;
- if (*oldoldbufptr == 'p' && strnEQ(oldoldbufptr,"print",5))
- expectterm = TRUE;
- else if (*oldoldbufptr == 's' && strnEQ(oldoldbufptr,"sort",4))
- expectterm = TRUE;
- }
- return (CLINE, bufptr = s, (int)WORD);
-}
-
-void
-checkcomma(s,name,what)
-register char *s;
-char *name;
-char *what;
-{
- char *w;
-
- if (dowarn && *s == ' ' && s[1] == '(') {
- w = index(s,')');
- if (w)
- for (w++; *w && isSPACE(*w); w++) ;
- if (!w || !*w || !index(";|}", *w)) /* an advisory hack only... */
- warn("%s (...) interpreted as function",name);
- }
- while (s < bufend && isSPACE(*s))
- s++;
- if (*s == '(')
- s++;
- while (s < bufend && isSPACE(*s))
- s++;
- if (isALPHA(*s) || *s == '_') {
- w = s++;
- while (isALNUM(*s))
- s++;
- while (s < bufend && isSPACE(*s))
- s++;
- if (*s == ',') {
- *s = '\0';
- w = instr(
- "tell eof times getlogin wait length shift umask getppid \
- cos exp int log rand sin sqrt ord wantarray",
- w);
- *s = ',';
- if (w)
- return;
- fatal("No comma allowed after %s", what);
- }
- }
-}
-
-char *
-scanident(s,send,dest,destlen)
-register char *s;
-register char *send;
-char *dest;
-STRLEN destlen;
-{
- register char *d;
- register char *e;
- int brackets = 0;
-
- reparse = Nullch;
- s++;
- d = dest;
- e = d + destlen - 3; /* two-character token, ending NUL */
- if (isDIGIT(*s)) {
- while (isDIGIT(*s)) {
- if (d >= e)
- fatal("Identifier too long");
- *d++ = *s++;
- }
- }
- else {
- while (isALNUM(*s) || *s == '\'') {
- if (d >= e)
- fatal("Identifier too long");
- *d++ = *s++;
- }
- }
- while (d > dest+1 && d[-1] == '\'')
- d--,s--;
- *d = '\0';
- d = dest;
- if (!*d) {
- *d = *s++;
- if (*d == '{' /* } */ ) {
- d = dest;
- brackets++;
- while (s < send && brackets) {
- if (!reparse && (d == dest || (*s && isALNUM(*s) ))) {
- *d++ = *s++;
- continue;
- }
- else if (!reparse)
- reparse = s;
- switch (*s++) {
- /* { */
- case '}':
- brackets--;
- if (reparse && reparse == s - 1)
- reparse = Nullch;
- break;
- case '{': /* } */
- brackets++;
- break;
- }
- }
- *d = '\0';
- d = dest;
- }
- else
- d[1] = '\0';
- }
- if (*d == '^' && (isUPPER(*s) || index("[\\]^_?", *s))) {
-#ifdef DEBUGGING
- if (*s == 'D')
- debug |= 32768;
-#endif
- *d = *s++ ^ 64;
- }
- return s;
-}
-
-void
-scanconst(spat,string,len)
-SPAT *spat;
-char *string;
-int len;
-{
- register STR *tmpstr;
- register char *t;
- register char *d;
- register char *e;
- char *origstring = string;
- static char *vert = "|";
-
- if (ninstr(string, string+len, vert, vert+1))
- return;
- if (*string == '^')
- string++, len--;
- tmpstr = Str_new(86,len);
- str_nset(tmpstr,string,len);
- t = str_get(tmpstr);
- e = t + len;
- tmpstr->str_u.str_useful = 100;
- for (d=t; d < e; ) {
- switch (*d) {
- case '{':
- if (isDIGIT(d[1]))
- e = d;
- else
- goto defchar;
- break;
- case '.': case '[': case '$': case '(': case ')': case '|': case '+':
- case '^':
- e = d;
- break;
- case '\\':
- if (d[1] && index("wWbB0123456789sSdDlLuUExc",d[1])) {
- e = d;
- break;
- }
- Move(d+1,d,e-d,char);
- e--;
- switch(*d) {
- case 'n':
- *d = '\n';
- break;
- case 't':
- *d = '\t';
- break;
- case 'f':
- *d = '\f';
- break;
- case 'r':
- *d = '\r';
- break;
- case 'e':
- *d = '\033';
- break;
- case 'a':
- *d = '\007';
- break;
- }
- /* FALL THROUGH */
- default:
- defchar:
- if (d[1] == '*' || (d[1] == '{' && d[2] == '0') || d[1] == '?') {
- e = d;
- break;
- }
- d++;
- }
- }
- if (d == t) {
- str_free(tmpstr);
- return;
- }
- *d = '\0';
- tmpstr->str_cur = d - t;
- if (d == t+len)
- spat->spat_flags |= SPAT_ALL;
- if (*origstring != '^')
- spat->spat_flags |= SPAT_SCANFIRST;
- spat->spat_short = tmpstr;
- spat->spat_slen = d - t;
-}
-
-char *
-scanpat(s)
-register char *s;
-{
- register SPAT *spat;
- register char *d;
- register char *e;
- int len;
- SPAT savespat;
- STR *str = Str_new(93,0);
- char delim;
-
- Newz(801,spat,1,SPAT);
- spat->spat_next = curstash->tbl_spatroot; /* link into spat list */
- curstash->tbl_spatroot = spat;
-
- switch (*s++) {
- case 'm':
- s++;
- break;
- case '/':
- break;
- case '?':
- spat->spat_flags |= SPAT_ONCE;
- break;
- default:
- fatal("panic: scanpat");
- }
- s = str_append_till(str,s,bufend,s[-1],patleave);
- if (s >= bufend) {
- str_free(str);
- yyerror("Search pattern not terminated");
- yylval.arg = Nullarg;
- return s;
- }
- delim = *s++;
- while (*s == 'i' || *s == 'o' || *s == 'g') {
- if (*s == 'i') {
- s++;
- sawi = TRUE;
- spat->spat_flags |= SPAT_FOLD;
- }
- if (*s == 'o') {
- s++;
- spat->spat_flags |= SPAT_KEEP;
- }
- if (*s == 'g') {
- s++;
- spat->spat_flags |= SPAT_GLOBAL;
- }
- }
- len = str->str_cur;
- e = str->str_ptr + len;
- if (delim == '\'')
- d = e;
- else
- d = str->str_ptr;
- for (; d < e; d++) {
- if (*d == '\\')
- d++;
- else if ((*d == '$' && d[1] && d[1] != '|' && d[1] != ')') ||
- (*d == '@')) {
- register ARG *arg;
-
- spat->spat_runtime = arg = op_new(1);
- arg->arg_type = O_ITEM;
- arg[1].arg_type = A_DOUBLE;
- arg[1].arg_ptr.arg_str = str_smake(str);
- d = scanident(d,bufend,buf,sizeof buf);
- (void)stabent(buf,TRUE); /* make sure it's created */
- for (; d < e; d++) {
- if (*d == '\\')
- d++;
- else if (*d == '$' && d[1] && d[1] != '|' && d[1] != ')') {
- d = scanident(d,bufend,buf,sizeof buf);
- (void)stabent(buf,TRUE);
- }
- else if (*d == '@') {
- d = scanident(d,bufend,buf,sizeof buf);
- if (strEQ(buf,"ARGV") || strEQ(buf,"ENV") ||
- strEQ(buf,"SIG") || strEQ(buf,"INC"))
- (void)stabent(buf,TRUE);
- }
- }
- goto got_pat; /* skip compiling for now */
- }
- }
- if (spat->spat_flags & SPAT_FOLD)
- StructCopy(spat, &savespat, SPAT);
- scanconst(spat,str->str_ptr,len);
- if ((spat->spat_flags & SPAT_ALL) && (spat->spat_flags & SPAT_SCANFIRST)) {
- fbmcompile(spat->spat_short, spat->spat_flags & SPAT_FOLD);
- spat->spat_regexp = regcomp(str->str_ptr,str->str_ptr+len,
- spat->spat_flags & SPAT_FOLD);
- /* Note that this regexp can still be used if someone says
- * something like /a/ && s//b/; so we can't delete it.
- */
- }
- else {
- if (spat->spat_flags & SPAT_FOLD)
- StructCopy(&savespat, spat, SPAT);
- if (spat->spat_short)
- fbmcompile(spat->spat_short, spat->spat_flags & SPAT_FOLD);
- spat->spat_regexp = regcomp(str->str_ptr,str->str_ptr+len,
- spat->spat_flags & SPAT_FOLD);
- hoistmust(spat);
- }
- got_pat:
- str_free(str);
- yylval.arg = make_match(O_MATCH,stab2arg(A_STAB,defstab),spat);
- return s;
-}
-
-char *
-scansubst(start)
-char *start;
-{
- register char *s = start;
- register SPAT *spat;
- register char *d;
- register char *e;
- int len;
- STR *str = Str_new(93,0);
- char term = *s;
-
- if (term && (d = index("([{< )]}> )]}>",term)))
- term = d[5];
-
- Newz(802,spat,1,SPAT);
- spat->spat_next = curstash->tbl_spatroot; /* link into spat list */
- curstash->tbl_spatroot = spat;
-
- s = str_append_till(str,s+1,bufend,term,patleave);
- if (s >= bufend) {
- str_free(str);
- yyerror("Substitution pattern not terminated");
- yylval.arg = Nullarg;
- return s;
- }
- len = str->str_cur;
- e = str->str_ptr + len;
- for (d = str->str_ptr; d < e; d++) {
- if (*d == '\\')
- d++;
- else if ((*d == '$' && d[1] && d[1] != '|' && /*(*/ d[1] != ')') ||
- *d == '@' ) {
- register ARG *arg;
-
- spat->spat_runtime = arg = op_new(1);
- arg->arg_type = O_ITEM;
- arg[1].arg_type = A_DOUBLE;
- arg[1].arg_ptr.arg_str = str_smake(str);
- d = scanident(d,e,buf,sizeof buf);
- (void)stabent(buf,TRUE); /* make sure it's created */
- for (; *d; d++) {
- if (*d == '$' && d[1] && d[-1] != '\\' && d[1] != '|') {
- d = scanident(d,e,buf,sizeof buf);
- (void)stabent(buf,TRUE);
- }
- else if (*d == '@' && d[-1] != '\\') {
- d = scanident(d,e,buf,sizeof buf);
- if (strEQ(buf,"ARGV") || strEQ(buf,"ENV") ||
- strEQ(buf,"SIG") || strEQ(buf,"INC"))
- (void)stabent(buf,TRUE);
- }
- }
- goto get_repl; /* skip compiling for now */
- }
- }
- scanconst(spat,str->str_ptr,len);
-get_repl:
- if (term != *start)
- s++;
- s = scanstr(s, SCAN_REPL);
- if (s >= bufend) {
- str_free(str);
- yyerror("Substitution replacement not terminated");
- yylval.arg = Nullarg;
- return s;
- }
- spat->spat_repl = yylval.arg;
- if ((spat->spat_repl[1].arg_type & A_MASK) == A_SINGLE)
- spat->spat_flags |= SPAT_CONST;
- else if ((spat->spat_repl[1].arg_type & A_MASK) == A_DOUBLE) {
- STR *tmpstr;
- register char *t;
-
- spat->spat_flags |= SPAT_CONST;
- tmpstr = spat->spat_repl[1].arg_ptr.arg_str;
- e = tmpstr->str_ptr + tmpstr->str_cur;
- for (t = tmpstr->str_ptr; t < e; t++) {
- if (*t == '$' && t[1] && (index("`'&+0123456789",t[1]) ||
- (t[1] == '{' /*}*/ && isDIGIT(t[2])) ))
- spat->spat_flags &= ~SPAT_CONST;
- }
- }
- while (*s == 'g' || *s == 'i' || *s == 'e' || *s == 'o') {
- int es = 0;
-
- if (*s == 'e') {
- s++;
- es++;
- if ((spat->spat_repl[1].arg_type & A_MASK) == A_DOUBLE)
- spat->spat_repl[1].arg_type = A_SINGLE;
- spat->spat_repl = make_op(
- (!es && spat->spat_repl[1].arg_type == A_SINGLE
- ? O_EVALONCE
- : O_EVAL),
- 2,
- spat->spat_repl,
- Nullarg,
- Nullarg);
- spat->spat_flags &= ~SPAT_CONST;
- }
- if (*s == 'g') {
- s++;
- spat->spat_flags |= SPAT_GLOBAL;
- }
- if (*s == 'i') {
- s++;
- sawi = TRUE;
- spat->spat_flags |= SPAT_FOLD;
- if (!(spat->spat_flags & SPAT_SCANFIRST)) {
- str_free(spat->spat_short); /* anchored opt doesn't do */
- spat->spat_short = Nullstr; /* case insensitive match */
- spat->spat_slen = 0;
- }
- }
- if (*s == 'o') {
- s++;
- spat->spat_flags |= SPAT_KEEP;
- }
- }
- if (spat->spat_short && (spat->spat_flags & SPAT_SCANFIRST))
- fbmcompile(spat->spat_short, spat->spat_flags & SPAT_FOLD);
- if (!spat->spat_runtime) {
- spat->spat_regexp = regcomp(str->str_ptr,str->str_ptr+len,
- spat->spat_flags & SPAT_FOLD);
- hoistmust(spat);
- }
- yylval.arg = make_match(O_SUBST,stab2arg(A_STAB,defstab),spat);
- str_free(str);
- return s;
-}
-
-void
-hoistmust(spat)
-register SPAT *spat;
-{
- if (!spat->spat_short && spat->spat_regexp->regstart &&
- (!spat->spat_regexp->regmust || spat->spat_regexp->reganch & ROPT_ANCH)
- ) {
- if (!(spat->spat_regexp->reganch & ROPT_ANCH))
- spat->spat_flags |= SPAT_SCANFIRST;
- else if (spat->spat_flags & SPAT_FOLD)
- return;
- spat->spat_short = str_smake(spat->spat_regexp->regstart);
- }
- else if (spat->spat_regexp->regmust) {/* is there a better short-circuit? */
- if (spat->spat_short &&
- str_eq(spat->spat_short,spat->spat_regexp->regmust))
- {
- if (spat->spat_flags & SPAT_SCANFIRST) {
- str_free(spat->spat_short);
- spat->spat_short = Nullstr;
- }
- else {
- str_free(spat->spat_regexp->regmust);
- spat->spat_regexp->regmust = Nullstr;
- return;
- }
- }
- if (!spat->spat_short || /* promote the better string */
- ((spat->spat_flags & SPAT_SCANFIRST) &&
- (spat->spat_short->str_cur < spat->spat_regexp->regmust->str_cur) )){
- str_free(spat->spat_short); /* ok if null */
- spat->spat_short = spat->spat_regexp->regmust;
- spat->spat_regexp->regmust = Nullstr;
- spat->spat_flags |= SPAT_SCANFIRST;
- }
- }
-}
-
-char *
-scantrans(start)
-char *start;
-{
- register char *s = start;
- ARG *arg =
- l(make_op(O_TRANS,2,stab2arg(A_STAB,defstab),Nullarg,Nullarg));
- STR *tstr;
- STR *rstr;
- register char *t;
- register char *r;
- register short *tbl;
- register int i;
- register int j;
- int tlen, rlen;
- int squash;
- int delete;
- int complement;
-
- New(803,tbl,256,short);
- arg[2].arg_type = A_NULL;
- arg[2].arg_ptr.arg_cval = (char*) tbl;
-
- s = scanstr(s, SCAN_TR);
- if (s >= bufend) {
- yyerror("Translation pattern not terminated");
- yylval.arg = Nullarg;
- return s;
- }
- tstr = yylval.arg[1].arg_ptr.arg_str;
- yylval.arg[1].arg_ptr.arg_str = Nullstr;
- arg_free(yylval.arg);
- t = tstr->str_ptr;
- tlen = tstr->str_cur;
-
- if (s[-1] == *start)
- s--;
-
- s = scanstr(s, SCAN_TR|SCAN_REPL);
- if (s >= bufend) {
- yyerror("Translation replacement not terminated");
- yylval.arg = Nullarg;
- return s;
- }
- rstr = yylval.arg[1].arg_ptr.arg_str;
- yylval.arg[1].arg_ptr.arg_str = Nullstr;
- arg_free(yylval.arg);
- r = rstr->str_ptr;
- rlen = rstr->str_cur;
-
- complement = delete = squash = 0;
- while (*s == 'c' || *s == 'd' || *s == 's') {
- if (*s == 'c')
- complement = 1;
- else if (*s == 'd')
- delete = 2;
- else
- squash = 1;
- s++;
- }
- arg[2].arg_len = delete|squash;
- yylval.arg = arg;
- if (complement) {
- Zero(tbl, 256, short);
- for (i = 0; i < tlen; i++)
- tbl[t[i] & 0377] = -1;
- for (i = 0, j = 0; i < 256; i++) {
- if (!tbl[i]) {
- if (j >= rlen) {
- if (delete)
- tbl[i] = -2;
- else if (rlen)
- tbl[i] = r[j-1] & 0377;
- else
- tbl[i] = i;
- }
- else
- tbl[i] = r[j++] & 0377;
- }
- }
- }
- else {
- if (!rlen && !delete) {
- r = t; rlen = tlen;
- }
- for (i = 0; i < 256; i++)
- tbl[i] = -1;
- for (i = 0, j = 0; i < tlen; i++,j++) {
- if (j >= rlen) {
- if (delete) {
- if (tbl[t[i] & 0377] == -1)
- tbl[t[i] & 0377] = -2;
- continue;
- }
- --j;
- }
- if (tbl[t[i] & 0377] == -1)
- tbl[t[i] & 0377] = r[j] & 0377;
- }
- }
- str_free(tstr);
- str_free(rstr);
- return s;
-}
-
-char *
-scanstr(start, in_what)
-char *start;
-int in_what;
-{
- register char *s = start;
- register char term;
- register char *d;
- register ARG *arg;
- register char *send;
- register bool makesingle = FALSE;
- register STAB *stab;
- bool alwaysdollar = FALSE;
- bool hereis = FALSE;
- STR *herewas;
- STR *str;
- /* which backslash sequences to keep */
- char *leave = (in_what & SCAN_TR)
- ? "\\$@nrtfbeacx0123456789-"
- : "\\$@nrtfbeacx0123456789[{]}lLuUE";
- int len;
-
- arg = op_new(1);
- yylval.arg = arg;
- arg->arg_type = O_ITEM;
-
- switch (*s) {
- default: /* a substitution replacement */
- arg[1].arg_type = A_DOUBLE;
- makesingle = TRUE; /* maybe disable runtime scanning */
- term = *s;
- if (term == '\'')
- leave = Nullch;
- goto snarf_it;
- case '0':
- {
- unsigned long i;
- int shift;
-
- arg[1].arg_type = A_SINGLE;
- if (s[1] == 'x') {
- shift = 4;
- s += 2;
- }
- else if (s[1] == '.')
- goto decimal;
- else
- shift = 3;
- i = 0;
- for (;;) {
- switch (*s) {
- default:
- goto out;
- case '_':
- s++;
- break;
- case '8': case '9':
- if (shift != 4)
- yyerror("Illegal octal digit");
- /* FALL THROUGH */
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7':
- i <<= shift;
- i += *s++ & 15;
- break;
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- if (shift != 4)
- goto out;
- i <<= 4;
- i += (*s++ & 7) + 9;
- break;
- }
- }
- out:
- str = Str_new(92,0);
- str_numset(str,(double)i);
- if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_ptr = Nullch;
- str->str_len = str->str_cur = 0;
- }
- arg[1].arg_ptr.arg_str = str;
- }
- break;
- case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9': case '.':
- decimal:
- arg[1].arg_type = A_SINGLE;
- d = tokenbuf;
- while (isDIGIT(*s) || *s == '_') {
- if (*s == '_')
- s++;
- else
- *d++ = *s++;
- }
- if (*s == '.' && s[1] != '.') {
- *d++ = *s++;
- while (isDIGIT(*s) || *s == '_') {
- if (*s == '_')
- s++;
- else
- *d++ = *s++;
- }
- }
- if (*s && index("eE",*s) && index("+-0123456789",s[1])) {
- *d++ = *s++;
- if (*s == '+' || *s == '-')
- *d++ = *s++;
- while (isDIGIT(*s))
- *d++ = *s++;
- }
- *d = '\0';
- str = Str_new(92,0);
- str_numset(str,atof(tokenbuf));
- if (str->str_ptr) {
- Safefree(str->str_ptr);
- str->str_ptr = Nullch;
- str->str_len = str->str_cur = 0;
- }
- arg[1].arg_ptr.arg_str = str;
- break;
- case '<':
- if (in_what & (SCAN_REPL|SCAN_TR))
- goto do_double;
- if (*++s == '<') {
- hereis = TRUE;
- d = tokenbuf;
- if (!rsfp)
- *d++ = '\n';
- if (*++s && index("`'\"",*s)) {
- term = *s++;
- s = cpytill(d,s,bufend,term,&len);
- if (s < bufend)
- s++;
- d += len;
- }
- else {
- if (*s == '\\')
- s++, term = '\'';
- else
- term = '"';
- while (isALNUM(*s))
- *d++ = *s++;
- } /* assuming tokenbuf won't clobber */
- *d++ = '\n';
- *d = '\0';
- len = d - tokenbuf;
- d = "\n";
- if (rsfp || !(d=ninstr(s,bufend,d,d+1)))
- herewas = str_make(s,bufend-s);
- else
- s--, herewas = str_make(s,d-s);
- s += herewas->str_cur;
- if (term == '\'')
- goto do_single;
- if (term == '`')
- goto do_back;
- goto do_double;
- }
- d = tokenbuf;
- s = cpytill(d,s,bufend,'>',&len);
- if (s < bufend)
- s++;
- else
- fatal("Unterminated <> operator");
-
- if (*d == '$') d++;
- while (*d && (isALNUM(*d) || *d == '\''))
- d++;
- if (d - tokenbuf != len) {
- s = start;
- term = *s;
- arg[1].arg_type = A_GLOB;
- set_csh();
- alwaysdollar = TRUE; /* treat $) and $| as variables */
- goto snarf_it;
- }
- else {
- d = tokenbuf;
- if (!len)
- (void)strcpy(d,"ARGV");
- if (*d == '$') {
- arg[1].arg_type = A_INDREAD;
- arg[1].arg_ptr.arg_stab = stabent(d+1,TRUE);
- }
- else {
- arg[1].arg_type = A_READ;
- arg[1].arg_ptr.arg_stab = stabent(d,TRUE);
- if (!stab_io(arg[1].arg_ptr.arg_stab))
- stab_io(arg[1].arg_ptr.arg_stab) = stio_new();
- if (strEQ(d,"ARGV")) {
- (void)aadd(arg[1].arg_ptr.arg_stab);
- stab_io(arg[1].arg_ptr.arg_stab)->flags |=
- IOF_ARGV|IOF_START;
- }
- }
- }
- break;
-
- case 'q':
- s++;
- if (*s == 'q') {
- s++;
- goto do_double;
- }
- if (*s == 'x') {
- s++;
- goto do_back;
- }
- /* FALL THROUGH */
- case '\'':
- do_single:
- term = *s;
- arg[1].arg_type = A_SINGLE;
- leave = Nullch;
- goto snarf_it;
-
- case '"':
- do_double:
- term = *s;
- arg[1].arg_type = A_DOUBLE;
- makesingle = TRUE; /* maybe disable runtime scanning */
- alwaysdollar = TRUE; /* treat $) and $| as variables */
- goto snarf_it;
- case '`':
- do_back:
- term = *s;
- arg[1].arg_type = A_BACKTICK;
- set_csh();
- alwaysdollar = TRUE; /* treat $) and $| as variables */
- snarf_it:
- {
- STR *tmpstr;
- STR *tmpstr2 = Nullstr;
- char *tmps;
- char *start;
- bool dorange = FALSE;
-
- CLINE;
- multi_start = curcmd->c_line;
- if (hereis)
- multi_open = multi_close = '<';
- else {
- multi_open = term;
- if (term && (tmps = index("([{< )]}> )]}>",term)))
- term = tmps[5];
- multi_close = term;
- }
- tmpstr = Str_new(87,80);
- if (hereis) {
- term = *tokenbuf;
- if (!rsfp) {
- d = s;
- while (s < bufend &&
- (*s != term || bcmp(s,tokenbuf,len) != 0) ) {
- if (*s++ == '\n')
- curcmd->c_line++;
- }
- if (s >= bufend) {
- curcmd->c_line = multi_start;
- fatal("EOF in string");
- }
- str_nset(tmpstr,d+1,s-d);
- s += len - 1;
- str_ncat(herewas,s,bufend-s);
- str_replace(linestr,herewas);
- oldoldbufptr = oldbufptr = bufptr = s = str_get(linestr);
- bufend = linestr->str_ptr + linestr->str_cur;
- hereis = FALSE;
- }
- else
- str_nset(tmpstr,"",0); /* avoid "uninitialized" warning */
- }
- else
- s = str_append_till(tmpstr,s+1,bufend,term,leave);
- while (s >= bufend) { /* multiple line string? */
- if (!rsfp ||
- !(oldoldbufptr = oldbufptr = s = str_gets(linestr, rsfp, 0))) {
- curcmd->c_line = multi_start;
- fatal("EOF in string");
- }
- curcmd->c_line++;
- if (perldb) {
- STR *str = Str_new(88,0);
-
- str_sset(str,linestr);
- astore(stab_xarray(curcmd->c_filestab),
- (int)curcmd->c_line,str);
- }
- bufend = linestr->str_ptr + linestr->str_cur;
- if (hereis) {
- if (*s == term && bcmp(s,tokenbuf,len) == 0) {
- s = bufend - 1;
- *s = ' ';
- str_scat(linestr,herewas);
- bufend = linestr->str_ptr + linestr->str_cur;
- }
- else {
- s = bufend;
- str_scat(tmpstr,linestr);
- }
- }
- else
- s = str_append_till(tmpstr,s,bufend,term,leave);
- }
- multi_end = curcmd->c_line;
- s++;
- if (tmpstr->str_cur + 5 < tmpstr->str_len) {
- tmpstr->str_len = tmpstr->str_cur + 1;
- Renew(tmpstr->str_ptr, tmpstr->str_len, char);
- }
- if (arg[1].arg_type == A_SINGLE) {
- arg[1].arg_ptr.arg_str = tmpstr;
- break;
- }
- tmps = s;
- s = tmpstr->str_ptr;
- send = s + tmpstr->str_cur;
- while (s < send) { /* see if we can make SINGLE */
- if (*s == '\\' && s[1] && isDIGIT(s[1]) && !isDIGIT(s[2]) &&
- !alwaysdollar && s[1] != '0')
- *s = '$'; /* grandfather \digit in subst */
- if ((*s == '$' || *s == '@') && s+1 < send &&
- (alwaysdollar || (s[1] != ')' && s[1] != '|'))) {
- makesingle = FALSE; /* force interpretation */
- }
- else if (*s == '\\' && s+1 < send) {
- if (index("lLuUE",s[1]))
- makesingle = FALSE;
- s++;
- }
- s++;
- }
- s = d = start = tmpstr->str_ptr; /* assuming shrinkage only */
- while (s < send || dorange) {
- if (in_what & SCAN_TR) {
- if (dorange) {
- int i;
- int max;
- if (!tmpstr2) { /* oops, have to grow */
- tmpstr2 = str_smake(tmpstr);
- s = tmpstr2->str_ptr + (s - tmpstr->str_ptr);
- send = tmpstr2->str_ptr + (send - tmpstr->str_ptr);
- }
- i = d - tmpstr->str_ptr;
- STR_GROW(tmpstr, tmpstr->str_len + 256);
- d = tmpstr->str_ptr + i;
- d -= 2;
- max = d[1] & 0377;
- for (i = (*d & 0377); i <= max; i++)
- *d++ = i;
- start = s;
- dorange = FALSE;
- continue;
- }
- else if (*s == '-' && s+1 < send && s != start) {
- dorange = TRUE;
- s++;
- }
- }
- else {
- if ((*s == '$' && s+1 < send &&
- (alwaysdollar || /*(*/(s[1] != ')' && s[1] != '|')) ) ||
- (*s == '@' && s+1 < send) ) {
- if (s[1] == '#' && (isALPHA(s[2]) || s[2] == '_'))
- *d++ = *s++;
- len = scanident(s,send,tokenbuf,sizeof tokenbuf) - s;
- if (*s == '$' || strEQ(tokenbuf,"ARGV")
- || strEQ(tokenbuf,"ENV")
- || strEQ(tokenbuf,"SIG")
- || strEQ(tokenbuf,"INC") )
- (void)stabent(tokenbuf,TRUE); /* add symbol */
- while (len--)
- *d++ = *s++;
- continue;
- }
- }
- if (*s == '\\' && s+1 < send) {
- s++;
- switch (*s) {
- case '-':
- if (in_what & SCAN_TR) {
- *d++ = *s++;
- continue;
- }
- /* FALL THROUGH */
- default:
- if (!makesingle && (!leave || (*s && index(leave,*s))))
- *d++ = '\\';
- *d++ = *s++;
- continue;
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- *d++ = scanoct(s, 3, &len);
- s += len;
- continue;
- case 'x':
- *d++ = scanhex(++s, 2, &len);
- s += len;
- continue;
- case 'c':
- s++;
- *d = *s++;
- if (isLOWER(*d))
- *d = toupper(*d);
- *d++ ^= 64;
- continue;
- case 'b':
- *d++ = '\b';
- break;
- case 'n':
- *d++ = '\n';
- break;
- case 'r':
- *d++ = '\r';
- break;
- case 'f':
- *d++ = '\f';
- break;
- case 't':
- *d++ = '\t';
- break;
- case 'e':
- *d++ = '\033';
- break;
- case 'a':
- *d++ = '\007';
- break;
- }
- s++;
- continue;
- }
- *d++ = *s++;
- }
- *d = '\0';
-
- if (arg[1].arg_type == A_DOUBLE && makesingle)
- arg[1].arg_type = A_SINGLE; /* now we can optimize on it */
-
- tmpstr->str_cur = d - tmpstr->str_ptr;
- if (arg[1].arg_type == A_GLOB) {
- arg[1].arg_ptr.arg_stab = stab = genstab();
- stab_io(stab) = stio_new();
- str_sset(stab_val(stab), tmpstr);
- }
- else
- arg[1].arg_ptr.arg_str = tmpstr;
- s = tmps;
- if (tmpstr2)
- str_free(tmpstr2);
- break;
- }
- }
- if (hereis)
- str_free(herewas);
- return s;
-}
-
-FCMD *
-load_format()
-{
- FCMD froot;
- FCMD *flinebeg;
- char *eol;
- register FCMD *fprev = &froot;
- register FCMD *fcmd;
- register char *s;
- register char *t;
- register STR *str;
- bool noblank;
- bool repeater;
-
- Zero(&froot, 1, FCMD);
- s = bufptr;
- while (s < bufend || (rsfp && (s = str_gets(linestr,rsfp, 0)) != Nullch)) {
- curcmd->c_line++;
- if (in_eval && !rsfp) {
- eol = index(s,'\n');
- if (!eol++)
- eol = bufend;
- }
- else
- eol = bufend = linestr->str_ptr + linestr->str_cur;
- if (perldb) {
- STR *tmpstr = Str_new(89,0);
-
- str_nset(tmpstr, s, eol-s);
- astore(stab_xarray(curcmd->c_filestab), (int)curcmd->c_line,tmpstr);
- }
- if (*s == '.') {
- /*SUPPRESS 530*/
- for (t = s+1; *t == ' ' || *t == '\t'; t++) ;
- if (*t == '\n') {
- bufptr = s;
- return froot.f_next;
- }
- }
- if (*s == '#') {
- s = eol;
- continue;
- }
- flinebeg = Nullfcmd;
- noblank = FALSE;
- repeater = FALSE;
- while (s < eol) {
- Newz(804,fcmd,1,FCMD);
- fprev->f_next = fcmd;
- fprev = fcmd;
- for (t=s; t < eol && *t != '@' && *t != '^'; t++) {
- if (*t == '~') {
- noblank = TRUE;
- *t = ' ';
- if (t[1] == '~') {
- repeater = TRUE;
- t[1] = ' ';
- }
- }
- }
- fcmd->f_pre = nsavestr(s, t-s);
- fcmd->f_presize = t-s;
- s = t;
- if (s >= eol) {
- if (noblank)
- fcmd->f_flags |= FC_NOBLANK;
- if (repeater)
- fcmd->f_flags |= FC_REPEAT;
- break;
- }
- if (!flinebeg)
- flinebeg = fcmd; /* start values here */
- if (*s++ == '^')
- fcmd->f_flags |= FC_CHOP; /* for doing text filling */
- switch (*s) {
- case '*':
- fcmd->f_type = F_LINES;
- *s = '\0';
- break;
- case '<':
- fcmd->f_type = F_LEFT;
- while (*s == '<')
- s++;
- break;
- case '>':
- fcmd->f_type = F_RIGHT;
- while (*s == '>')
- s++;
- break;
- case '|':
- fcmd->f_type = F_CENTER;
- while (*s == '|')
- s++;
- break;
- case '#':
- case '.':
- /* Catch the special case @... and handle it as a string
- field. */
- if (*s == '.' && s[1] == '.') {
- goto default_format;
- }
- fcmd->f_type = F_DECIMAL;
- {
- char *p;
-
- /* Read a format in the form @####.####, where either group
- of ### may be empty, or the final .### may be missing. */
- while (*s == '#')
- s++;
- if (*s == '.') {
- s++;
- p = s;
- while (*s == '#')
- s++;
- fcmd->f_decimals = s-p;
- fcmd->f_flags |= FC_DP;
- } else {
- fcmd->f_decimals = 0;
- }
- }
- break;
- default:
- default_format:
- fcmd->f_type = F_LEFT;
- break;
- }
- if (fcmd->f_flags & FC_CHOP && *s == '.') {
- fcmd->f_flags |= FC_MORE;
- while (*s == '.')
- s++;
- }
- fcmd->f_size = s-t;
- }
- if (flinebeg) {
- again:
- if (s >= bufend &&
- (!rsfp || (s = str_gets(linestr, rsfp, 0)) == Nullch) )
- goto badform;
- curcmd->c_line++;
- if (in_eval && !rsfp) {
- eol = index(s,'\n');
- if (!eol++)
- eol = bufend;
- }
- else
- eol = bufend = linestr->str_ptr + linestr->str_cur;
- if (perldb) {
- STR *tmpstr = Str_new(90,0);
-
- str_nset(tmpstr, s, eol-s);
- astore(stab_xarray(curcmd->c_filestab),
- (int)curcmd->c_line,tmpstr);
- }
- if (strnEQ(s,".\n",2)) {
- bufptr = s;
- yyerror("Missing values line");
- return froot.f_next;
- }
- if (*s == '#') {
- s = eol;
- goto again;
- }
- str = flinebeg->f_unparsed = Str_new(91,eol - s);
- str->str_u.str_hash = curstash;
- str_nset(str,"(",1);
- flinebeg->f_line = curcmd->c_line;
- eol[-1] = '\0';
- if (!flinebeg->f_next->f_type || index(s, ',')) {
- eol[-1] = '\n';
- str_ncat(str, s, eol - s - 1);
- str_ncat(str,",$$);",5);
- s = eol;
- }
- else {
- eol[-1] = '\n';
- while (s < eol && isSPACE(*s))
- s++;
- t = s;
- while (s < eol) {
- switch (*s) {
- case ' ': case '\t': case '\n': case ';':
- str_ncat(str, t, s - t);
- str_ncat(str, "," ,1);
- while (s < eol && (isSPACE(*s) || *s == ';'))
- s++;
- t = s;
- break;
- case '$':
- str_ncat(str, t, s - t);
- t = s;
- s = scanident(s,eol,tokenbuf,sizeof tokenbuf);
- str_ncat(str, t, s - t);
- t = s;
- if (s < eol && *s && index("$'\"",*s))
- str_ncat(str, ",", 1);
- break;
- case '"': case '\'':
- str_ncat(str, t, s - t);
- t = s;
- s++;
- while (s < eol && (*s != *t || s[-1] == '\\'))
- s++;
- if (s < eol)
- s++;
- str_ncat(str, t, s - t);
- t = s;
- if (s < eol && *s && index("$'\"",*s))
- str_ncat(str, ",", 1);
- break;
- default:
- yyerror("Please use commas to separate fields");
- }
- }
- str_ncat(str,"$$);",4);
- }
- }
- }
- badform:
- bufptr = str_get(linestr);
- yyerror("Format not terminated");
- return froot.f_next;
-}
-
-static void
-set_csh()
-{
-#ifdef CSH
- if (!cshlen)
- cshlen = strlen(cshname);
-#endif
-}
diff --git a/gnu/usr.bin/perl/perl/usersub.c b/gnu/usr.bin/perl/perl/usersub.c
deleted file mode 100644
index 8c7cb65..0000000
--- a/gnu/usr.bin/perl/perl/usersub.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/* $RCSfile: usersub.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:34 $
- *
- * This file contains stubs for routines that the user may define to
- * set up glue routines for C libraries or to decrypt encrypted scripts
- * for execution.
- *
- * $Log: usersub.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:40 nate
- * PERL!
- *
- * Revision 4.0.1.2 92/06/08 16:04:24 lwall
- * patch20: removed implicit int declarations on functions
- *
- * Revision 4.0.1.1 91/11/11 16:47:17 lwall
- * patch19: deleted some unused functions from usersub.c
- *
- * Revision 4.0 91/03/20 01:55:56 lwall
- * 4.0 baseline.
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-int
-userinit()
-{
- return 0;
-}
-
-/*
- * The following is supplied by John Macdonald as a means of decrypting
- * and executing (presumably proprietary) scripts that have been encrypted
- * by a (presumably secret) method. The idea is that you supply your own
- * routine in place of cryptfilter (which is purposefully a very weak
- * encryption). If an encrypted script is detected, a process is forked
- * off to run the cryptfilter routine as input to perl.
- */
-
-#ifdef CRYPTSCRIPT
-
-#include <signal.h>
-#ifdef I_VFORK
-#include <vfork.h>
-#endif
-
-#ifdef CRYPTLOCAL
-
-#include "cryptlocal.h"
-
-#else /* ndef CRYPTLOCAL */
-
-#define CRYPT_MAGIC_1 0xfb
-#define CRYPT_MAGIC_2 0xf1
-
-void
-cryptfilter( fil )
-FILE * fil;
-{
- int ch;
-
- while( (ch = getc( fil )) != EOF ) {
- putchar( (ch ^ 0x80) );
- }
-}
-
-#endif /* CRYPTLOCAL */
-
-#ifndef MSDOS
-static FILE *lastpipefile;
-static int pipepid;
-
-#ifdef VOIDSIG
-# define VOID void
-#else
-# define VOID int
-#endif
-
-FILE *
-mypfiopen(fil,func) /* open a pipe to function call for input */
-FILE *fil;
-VOID (*func)();
-{
- int p[2];
- STR *str;
-
- if (pipe(p) < 0) {
- fclose( fil );
- fatal("Can't get pipe for decrypt");
- }
-
- /* make sure that the child doesn't get anything extra */
- fflush(stdout);
- fflush(stderr);
-
- while ((pipepid = fork()) < 0) {
- if (errno != EAGAIN) {
- close(p[0]);
- close(p[1]);
- fclose( fil );
- fatal("Can't fork for decrypt");
- }
- sleep(5);
- }
- if (pipepid == 0) {
- close(p[0]);
- if (p[1] != 1) {
- dup2(p[1], 1);
- close(p[1]);
- }
- (*func)(fil);
- fflush(stdout);
- fflush(stderr);
- _exit(0);
- }
- close(p[1]);
- close(fileno(fil));
- fclose(fil);
- str = afetch(fdpid,p[0],TRUE);
- str->str_u.str_useful = pipepid;
- return fdopen(p[0], "r");
-}
-
-void
-cryptswitch()
-{
- int ch;
-#ifdef STDSTDIO
- /* cheat on stdio if possible */
- if (rsfp->_cnt > 0 && (*rsfp->_ptr & 0xff) != CRYPT_MAGIC_1)
- return;
-#endif
- ch = getc(rsfp);
- if (ch == CRYPT_MAGIC_1) {
- if (getc(rsfp) == CRYPT_MAGIC_2) {
- if( perldb ) fatal("can't debug an encrypted script");
- rsfp = mypfiopen( rsfp, cryptfilter );
- preprocess = 1; /* force call to pclose when done */
- }
- else
- fatal( "bad encryption format" );
- }
- else
- ungetc(ch,rsfp);
-}
-#endif /* !MSDOS */
-
-#endif /* CRYPTSCRIPT */
diff --git a/gnu/usr.bin/perl/perl/util.c b/gnu/usr.bin/perl/perl/util.c
deleted file mode 100644
index ded365a..0000000
--- a/gnu/usr.bin/perl/perl/util.c
+++ /dev/null
@@ -1,1790 +0,0 @@
-/* $RCSfile: util.c,v $$Revision: 1.2 $$Date: 1995/05/30 05:03:28 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: util.c,v $
- * Revision 1.2 1995/05/30 05:03:28 rgrimes
- * Remove trailing whitespace.
- *
- * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:40 nate
- * PERL!
- *
- * Revision 4.0.1.6 92/06/11 21:18:47 lwall
- * patch34: boneheaded typo in my_bcopy()
- *
- * Revision 4.0.1.5 92/06/08 16:08:37 lwall
- * patch20: removed implicit int declarations on functions
- * patch20: Perl now distinguishes overlapped copies from non-overlapped
- * patch20: fixed confusion between a *var's real name and its effective name
- * patch20: bcopy() and memcpy() now tested for overlap safety
- * patch20: added Atari ST portability
- *
- * Revision 4.0.1.4 91/11/11 16:48:54 lwall
- * patch19: study was busted by 4.018
- * patch19: added little-endian pack/unpack options
- *
- * Revision 4.0.1.3 91/11/05 19:18:26 lwall
- * patch11: safe malloc code now integrated into Perl's malloc when possible
- * patch11: index("little", "longer string") could visit faraway places
- * patch11: warn '-' x 10000 dumped core
- * patch11: forked exec on non-existent program now issues a warning
- *
- * Revision 4.0.1.2 91/06/07 12:10:42 lwall
- * patch4: new copyright notice
- * patch4: made some allowances for "semi-standard" C
- * patch4: index() could blow up searching for null string
- * patch4: taintchecks could improperly modify parent in vfork()
- * patch4: exec would close files even if you cleared close-on-exec flag
- *
- * Revision 4.0.1.1 91/04/12 09:19:25 lwall
- * patch1: random cleanup in cpp namespace
- *
- * Revision 4.0 91/03/20 01:56:39 lwall
- * 4.0 baseline.
- *
- */
-/*SUPPRESS 112*/
-
-#include "EXTERN.h"
-#include "perl.h"
-
-#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX)
-#include <signal.h>
-#endif
-
-#ifdef I_VFORK
-# include <vfork.h>
-#endif
-
-#ifdef I_VARARGS
-# include <varargs.h>
-#endif
-
-#ifdef I_FCNTL
-# include <fcntl.h>
-#endif
-#ifdef I_SYS_FILE
-# include <sys/file.h>
-#endif
-
-#define FLUSH
-
-#ifndef safemalloc
-
-static char nomem[] = "Out of memory!\n";
-
-/* paranoid version of malloc */
-
-#ifdef DEBUGGING
-static int an = 0;
-#endif
-
-/* NOTE: Do not call the next three routines directly. Use the macros
- * in handy.h, so that we can easily redefine everything to do tracking of
- * allocated hunks back to the original New to track down any memory leaks.
- */
-
-char *
-safemalloc(size)
-#ifdef MSDOS
-unsigned long size;
-#else
-MEM_SIZE size;
-#endif /* MSDOS */
-{
- char *ptr;
-#ifndef STANDARD_C
- char *malloc();
-#endif /* ! STANDARD_C */
-
-#ifdef MSDOS
- if (size > 0xffff) {
- fprintf(stderr, "Allocation too large: %lx\n", size) FLUSH;
- exit(1);
- }
-#endif /* MSDOS */
-#ifdef DEBUGGING
- if ((long)size < 0)
- fatal("panic: malloc");
-#endif
- ptr = malloc(size?size:1); /* malloc(0) is NASTY on our system */
-#ifdef DEBUGGING
-# if !(defined(I286) || defined(atarist))
- if (debug & 128)
- fprintf(stderr,"0x%x: (%05d) malloc %ld bytes\n",ptr,an++,(long)size);
-# else
- if (debug & 128)
- fprintf(stderr,"0x%lx: (%05d) malloc %ld bytes\n",ptr,an++,(long)size);
-# endif
-#endif
- if (ptr != Nullch)
- return ptr;
- else if (nomemok)
- return Nullch;
- else {
- fputs(nomem,stderr) FLUSH;
- exit(1);
- }
- /*NOTREACHED*/
-#ifdef lint
- return ptr;
-#endif
-}
-
-/* paranoid version of realloc */
-
-char *
-saferealloc(where,size)
-char *where;
-#ifndef MSDOS
-MEM_SIZE size;
-#else
-unsigned long size;
-#endif /* MSDOS */
-{
- char *ptr;
-#ifndef STANDARD_C
- char *realloc();
-#endif /* ! STANDARD_C */
-
-#ifdef MSDOS
- if (size > 0xffff) {
- fprintf(stderr, "Reallocation too large: %lx\n", size) FLUSH;
- exit(1);
- }
-#endif /* MSDOS */
- if (!where)
- fatal("Null realloc");
-#ifdef DEBUGGING
- if ((long)size < 0)
- fatal("panic: realloc");
-#endif
- ptr = realloc(where,size?size:1); /* realloc(0) is NASTY on our system */
-#ifdef DEBUGGING
-# if !(defined(I286) || defined(atarist))
- if (debug & 128) {
- fprintf(stderr,"0x%x: (%05d) rfree\n",where,an++);
- fprintf(stderr,"0x%x: (%05d) realloc %ld bytes\n",ptr,an++,(long)size);
- }
-# else
- if (debug & 128) {
- fprintf(stderr,"0x%lx: (%05d) rfree\n",where,an++);
- fprintf(stderr,"0x%lx: (%05d) realloc %ld bytes\n",ptr,an++,(long)size);
- }
-# endif
-#endif
- if (ptr != Nullch)
- return ptr;
- else if (nomemok)
- return Nullch;
- else {
- fputs(nomem,stderr) FLUSH;
- exit(1);
- }
- /*NOTREACHED*/
-#ifdef lint
- return ptr;
-#endif
-}
-
-/* safe version of free */
-
-void
-safefree(where)
-char *where;
-{
-#ifdef DEBUGGING
-# if !(defined(I286) || defined(atarist))
- if (debug & 128)
- fprintf(stderr,"0x%x: (%05d) free\n",where,an++);
-# else
- if (debug & 128)
- fprintf(stderr,"0x%lx: (%05d) free\n",where,an++);
-# endif
-#endif
- if (where) {
- /*SUPPRESS 701*/
- free(where);
- }
-}
-
-#endif /* !safemalloc */
-
-#ifdef LEAKTEST
-
-#define ALIGN sizeof(long)
-
-char *
-safexmalloc(x,size)
-int x;
-MEM_SIZE size;
-{
- register char *where;
-
- where = safemalloc(size + ALIGN);
- xcount[x]++;
- where[0] = x % 100;
- where[1] = x / 100;
- return where + ALIGN;
-}
-
-char *
-safexrealloc(where,size)
-char *where;
-MEM_SIZE size;
-{
- return saferealloc(where - ALIGN, size + ALIGN) + ALIGN;
-}
-
-void
-safexfree(where)
-char *where;
-{
- int x;
-
- if (!where)
- return;
- where -= ALIGN;
- x = where[0] + 100 * where[1];
- xcount[x]--;
- safefree(where);
-}
-
-static void
-xstat()
-{
- register int i;
-
- for (i = 0; i < MAXXCOUNT; i++) {
- if (xcount[i] > lastxcount[i]) {
- fprintf(stderr,"%2d %2d\t%ld\n", i / 100, i % 100, xcount[i]);
- lastxcount[i] = xcount[i];
- }
- }
-}
-
-#endif /* LEAKTEST */
-
-/* copy a string up to some (non-backslashed) delimiter, if any */
-
-char *
-cpytill(to,from,fromend,delim,retlen)
-register char *to;
-register char *from;
-register char *fromend;
-register int delim;
-int *retlen;
-{
- char *origto = to;
-
- for (; from < fromend; from++,to++) {
- if (*from == '\\') {
- if (from[1] == delim)
- from++;
- else if (from[1] == '\\')
- *to++ = *from++;
- }
- else if (*from == delim)
- break;
- *to = *from;
- }
- *to = '\0';
- *retlen = to - origto;
- return from;
-}
-
-/* return ptr to little string in big string, NULL if not found */
-/* This routine was donated by Corey Satten. */
-
-char *
-instr(big, little)
-register char *big;
-register char *little;
-{
- register char *s, *x;
- register int first;
-
- if (!little)
- return big;
- first = *little++;
- if (!first)
- return big;
- while (*big) {
- if (*big++ != first)
- continue;
- for (x=big,s=little; *s; /**/ ) {
- if (!*x)
- return Nullch;
- if (*s++ != *x++) {
- s--;
- break;
- }
- }
- if (!*s)
- return big-1;
- }
- return Nullch;
-}
-
-/* same as instr but allow embedded nulls */
-
-char *
-ninstr(big, bigend, little, lend)
-register char *big;
-register char *bigend;
-char *little;
-char *lend;
-{
- register char *s, *x;
- register int first = *little;
- register char *littleend = lend;
-
- if (!first && little > littleend)
- return big;
- if (bigend - big < littleend - little)
- return Nullch;
- bigend -= littleend - little++;
- while (big <= bigend) {
- if (*big++ != first)
- continue;
- for (x=big,s=little; s < littleend; /**/ ) {
- if (*s++ != *x++) {
- s--;
- break;
- }
- }
- if (s >= littleend)
- return big-1;
- }
- return Nullch;
-}
-
-/* reverse of the above--find last substring */
-
-char *
-rninstr(big, bigend, little, lend)
-register char *big;
-char *bigend;
-char *little;
-char *lend;
-{
- register char *bigbeg;
- register char *s, *x;
- register int first = *little;
- register char *littleend = lend;
-
- if (!first && little > littleend)
- return bigend;
- bigbeg = big;
- big = bigend - (littleend - little++);
- while (big >= bigbeg) {
- if (*big-- != first)
- continue;
- for (x=big+2,s=little; s < littleend; /**/ ) {
- if (*s++ != *x++) {
- s--;
- break;
- }
- }
- if (s >= littleend)
- return big+1;
- }
- return Nullch;
-}
-
-unsigned char fold[] = {
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 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, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
- 'x', 'y', 'z', 91, 92, 93, 94, 95,
- 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
- 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
- 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
- 128, 129, 130, 131, 132, 133, 134, 135,
- 136, 137, 138, 139, 140, 141, 142, 143,
- 144, 145, 146, 147, 148, 149, 150, 151,
- 152, 153, 154, 155, 156, 157, 158, 159,
- 160, 161, 162, 163, 164, 165, 166, 167,
- 168, 169, 170, 171, 172, 173, 174, 175,
- 176, 177, 178, 179, 180, 181, 182, 183,
- 184, 185, 186, 187, 188, 189, 190, 191,
- 192, 193, 194, 195, 196, 197, 198, 199,
- 200, 201, 202, 203, 204, 205, 206, 207,
- 208, 209, 210, 211, 212, 213, 214, 215,
- 216, 217, 218, 219, 220, 221, 222, 223,
- 224, 225, 226, 227, 228, 229, 230, 231,
- 232, 233, 234, 235, 236, 237, 238, 239,
- 240, 241, 242, 243, 244, 245, 246, 247,
- 248, 249, 250, 251, 252, 253, 254, 255
-};
-
-static unsigned char freq[] = {
- 1, 2, 84, 151, 154, 155, 156, 157,
- 165, 246, 250, 3, 158, 7, 18, 29,
- 40, 51, 62, 73, 85, 96, 107, 118,
- 129, 140, 147, 148, 149, 150, 152, 153,
- 255, 182, 224, 205, 174, 176, 180, 217,
- 233, 232, 236, 187, 235, 228, 234, 226,
- 222, 219, 211, 195, 188, 193, 185, 184,
- 191, 183, 201, 229, 181, 220, 194, 162,
- 163, 208, 186, 202, 200, 218, 198, 179,
- 178, 214, 166, 170, 207, 199, 209, 206,
- 204, 160, 212, 216, 215, 192, 175, 173,
- 243, 172, 161, 190, 203, 189, 164, 230,
- 167, 248, 227, 244, 242, 255, 241, 231,
- 240, 253, 169, 210, 245, 237, 249, 247,
- 239, 168, 252, 251, 254, 238, 223, 221,
- 213, 225, 177, 197, 171, 196, 159, 4,
- 5, 6, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 19, 20, 21, 22,
- 23, 24, 25, 26, 27, 28, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 63, 64, 65, 66,
- 67, 68, 69, 70, 71, 72, 74, 75,
- 76, 77, 78, 79, 80, 81, 82, 83,
- 86, 87, 88, 89, 90, 91, 92, 93,
- 94, 95, 97, 98, 99, 100, 101, 102,
- 103, 104, 105, 106, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 119, 120,
- 121, 122, 123, 124, 125, 126, 127, 128,
- 130, 131, 132, 133, 134, 135, 136, 137,
- 138, 139, 141, 142, 143, 144, 145, 146
-};
-
-void
-fbmcompile(str, iflag)
-STR *str;
-int iflag;
-{
- register unsigned char *s;
- register unsigned char *table;
- register unsigned int i;
- register unsigned int len = str->str_cur;
- int rarest = 0;
- unsigned int frequency = 256;
-
- Str_Grow(str,len+258);
-#ifndef lint
- table = (unsigned char*)(str->str_ptr + len + 1);
-#else
- table = Null(unsigned char*);
-#endif
- s = table - 2;
- for (i = 0; i < 256; i++) {
- table[i] = len;
- }
- i = 0;
-#ifndef lint
- while (s >= (unsigned char*)(str->str_ptr))
-#endif
- {
- if (table[*s] == len) {
-#ifndef pdp11
- if (iflag)
- table[*s] = table[fold[*s]] = i;
-#else
- if (iflag) {
- int j;
- j = fold[*s];
- table[j] = i;
- table[*s] = i;
- }
-#endif /* pdp11 */
- else
- table[*s] = i;
- }
- s--,i++;
- }
- str->str_pok |= SP_FBM; /* deep magic */
-
-#ifndef lint
- s = (unsigned char*)(str->str_ptr); /* deeper magic */
-#else
- s = Null(unsigned char*);
-#endif
- if (iflag) {
- register unsigned int tmp, foldtmp;
- str->str_pok |= SP_CASEFOLD;
- for (i = 0; i < len; i++) {
- tmp=freq[s[i]];
- foldtmp=freq[fold[s[i]]];
- if (tmp < frequency && foldtmp < frequency) {
- rarest = i;
- /* choose most frequent among the two */
- frequency = (tmp > foldtmp) ? tmp : foldtmp;
- }
- }
- }
- else {
- for (i = 0; i < len; i++) {
- if (freq[s[i]] < frequency) {
- rarest = i;
- frequency = freq[s[i]];
- }
- }
- }
- str->str_rare = s[rarest];
- str->str_state = rarest;
-#ifdef DEBUGGING
- if (debug & 512)
- fprintf(stderr,"rarest char %c at %d\n",str->str_rare, str->str_state);
-#endif
-}
-
-char *
-fbminstr(big, bigend, littlestr)
-unsigned char *big;
-register unsigned char *bigend;
-STR *littlestr;
-{
- register unsigned char *s;
- register int tmp;
- register int littlelen;
- register unsigned char *little;
- register unsigned char *table;
- register unsigned char *olds;
- register unsigned char *oldlittle;
-
-#ifndef lint
- if (!(littlestr->str_pok & SP_FBM)) {
- if (!littlestr->str_ptr)
- return (char*)big;
- return ninstr((char*)big,(char*)bigend,
- littlestr->str_ptr, littlestr->str_ptr + littlestr->str_cur);
- }
-#endif
-
- littlelen = littlestr->str_cur;
-#ifndef lint
- if (littlestr->str_pok & SP_TAIL && !multiline) { /* tail anchored? */
- if (littlelen > bigend - big)
- return Nullch;
- little = (unsigned char*)littlestr->str_ptr;
- if (littlestr->str_pok & SP_CASEFOLD) { /* oops, fake it */
- big = bigend - littlelen; /* just start near end */
- if (bigend[-1] == '\n' && little[littlelen-1] != '\n')
- big--;
- }
- else {
- s = bigend - littlelen;
- if (*s == *little && bcmp(s,little,littlelen)==0)
- return (char*)s; /* how sweet it is */
- else if (bigend[-1] == '\n' && little[littlelen-1] != '\n'
- && s > big) {
- s--;
- if (*s == *little && bcmp(s,little,littlelen)==0)
- return (char*)s;
- }
- return Nullch;
- }
- }
- table = (unsigned char*)(littlestr->str_ptr + littlelen + 1);
-#else
- table = Null(unsigned char*);
-#endif
- if (--littlelen >= bigend - big)
- return Nullch;
- s = big + littlelen;
- oldlittle = little = table - 2;
- if (littlestr->str_pok & SP_CASEFOLD) { /* case insensitive? */
- if (s < bigend) {
- top1:
- /*SUPPRESS 560*/
- if (tmp = table[*s]) {
-#ifdef POINTERRIGOR
- if (bigend - s > tmp) {
- s += tmp;
- goto top1;
- }
-#else
- if ((s += tmp) < bigend)
- goto top1;
-#endif
- return Nullch;
- }
- else {
- tmp = littlelen; /* less expensive than calling strncmp() */
- olds = s;
- while (tmp--) {
- if (*--s == *--little || fold[*s] == *little)
- continue;
- s = olds + 1; /* here we pay the price for failure */
- little = oldlittle;
- if (s < bigend) /* fake up continue to outer loop */
- goto top1;
- return Nullch;
- }
-#ifndef lint
- return (char *)s;
-#endif
- }
- }
- }
- else {
- if (s < bigend) {
- top2:
- /*SUPPRESS 560*/
- if (tmp = table[*s]) {
-#ifdef POINTERRIGOR
- if (bigend - s > tmp) {
- s += tmp;
- goto top2;
- }
-#else
- if ((s += tmp) < bigend)
- goto top2;
-#endif
- return Nullch;
- }
- else {
- tmp = littlelen; /* less expensive than calling strncmp() */
- olds = s;
- while (tmp--) {
- if (*--s == *--little)
- continue;
- s = olds + 1; /* here we pay the price for failure */
- little = oldlittle;
- if (s < bigend) /* fake up continue to outer loop */
- goto top2;
- return Nullch;
- }
-#ifndef lint
- return (char *)s;
-#endif
- }
- }
- }
- return Nullch;
-}
-
-char *
-screaminstr(bigstr, littlestr)
-STR *bigstr;
-STR *littlestr;
-{
- register unsigned char *s, *x;
- register unsigned char *big;
- register int pos;
- register int previous;
- register int first;
- register unsigned char *little;
- register unsigned char *bigend;
- register unsigned char *littleend;
-
- if ((pos = screamfirst[littlestr->str_rare]) < 0)
- return Nullch;
-#ifndef lint
- little = (unsigned char *)(littlestr->str_ptr);
-#else
- little = Null(unsigned char *);
-#endif
- littleend = little + littlestr->str_cur;
- first = *little++;
- previous = littlestr->str_state;
-#ifndef lint
- big = (unsigned char *)(bigstr->str_ptr);
-#else
- big = Null(unsigned char*);
-#endif
- bigend = big + bigstr->str_cur;
- while (pos < previous) {
-#ifndef lint
- if (!(pos += screamnext[pos]))
-#endif
- return Nullch;
- }
-#ifdef POINTERRIGOR
- if (littlestr->str_pok & SP_CASEFOLD) { /* case insignificant? */
- do {
- if (big[pos-previous] != first && big[pos-previous] != fold[first])
- continue;
- for (x=big+pos+1-previous,s=little; s < littleend; /**/ ) {
- if (x >= bigend)
- return Nullch;
- if (*s++ != *x++ && fold[*(s-1)] != *(x-1)) {
- s--;
- break;
- }
- }
- if (s == littleend)
-#ifndef lint
- return (char *)(big+pos-previous);
-#else
- return Nullch;
-#endif
- } while (
-#ifndef lint
- pos += screamnext[pos] /* does this goof up anywhere? */
-#else
- pos += screamnext[0]
-#endif
- );
- }
- else {
- do {
- if (big[pos-previous] != first)
- continue;
- for (x=big+pos+1-previous,s=little; s < littleend; /**/ ) {
- if (x >= bigend)
- return Nullch;
- if (*s++ != *x++) {
- s--;
- break;
- }
- }
- if (s == littleend)
-#ifndef lint
- return (char *)(big+pos-previous);
-#else
- return Nullch;
-#endif
- } while (
-#ifndef lint
- pos += screamnext[pos]
-#else
- pos += screamnext[0]
-#endif
- );
- }
-#else /* !POINTERRIGOR */
- big -= previous;
- if (littlestr->str_pok & SP_CASEFOLD) { /* case insignificant? */
- do {
- if (big[pos] != first && big[pos] != fold[first])
- continue;
- for (x=big+pos+1,s=little; s < littleend; /**/ ) {
- if (x >= bigend)
- return Nullch;
- if (*s++ != *x++ && fold[*(s-1)] != *(x-1)) {
- s--;
- break;
- }
- }
- if (s == littleend)
-#ifndef lint
- return (char *)(big+pos);
-#else
- return Nullch;
-#endif
- } while (
-#ifndef lint
- pos += screamnext[pos] /* does this goof up anywhere? */
-#else
- pos += screamnext[0]
-#endif
- );
- }
- else {
- do {
- if (big[pos] != first)
- continue;
- for (x=big+pos+1,s=little; s < littleend; /**/ ) {
- if (x >= bigend)
- return Nullch;
- if (*s++ != *x++) {
- s--;
- break;
- }
- }
- if (s == littleend)
-#ifndef lint
- return (char *)(big+pos);
-#else
- return Nullch;
-#endif
- } while (
-#ifndef lint
- pos += screamnext[pos]
-#else
- pos += screamnext[0]
-#endif
- );
- }
-#endif /* POINTERRIGOR */
- return Nullch;
-}
-
-/* copy a string to a safe spot */
-
-char *
-savestr(str)
-char *str;
-{
- register char *newaddr;
-
- New(902,newaddr,strlen(str)+1,char);
- (void)strcpy(newaddr,str);
- return newaddr;
-}
-
-/* same thing but with a known length */
-
-char *
-nsavestr(str, len)
-char *str;
-register int len;
-{
- register char *newaddr;
-
- New(903,newaddr,len+1,char);
- Copy(str,newaddr,len,char); /* might not be null terminated */
- newaddr[len] = '\0'; /* is now */
- return newaddr;
-}
-
-/* grow a static string to at least a certain length */
-
-void
-growstr(strptr,curlen,newlen)
-char **strptr;
-int *curlen;
-int newlen;
-{
- if (newlen > *curlen) { /* need more room? */
- if (*curlen)
- Renew(*strptr,newlen,char);
- else
- New(905,*strptr,newlen,char);
- *curlen = newlen;
- }
-}
-
-#ifndef I_VARARGS
-/*VARARGS1*/
-char *
-mess(pat,a1,a2,a3,a4)
-char *pat;
-long a1, a2, a3, a4;
-{
- char *s;
- int usermess = strEQ(pat,"%s");
- STR *tmpstr;
-
- s = buf;
- if (usermess) {
- tmpstr = str_mortal(&str_undef);
- str_set(tmpstr, (char*)a1);
- *s++ = tmpstr->str_ptr[tmpstr->str_cur-1];
- }
- else {
- (void)sprintf(s,pat,a1,a2,a3,a4);
- s += strlen(s);
- }
-
- if (s[-1] != '\n') {
- if (curcmd->c_line) {
- (void)sprintf(s," at %s line %ld",
- stab_val(curcmd->c_filestab)->str_ptr, (long)curcmd->c_line);
- s += strlen(s);
- }
- if (last_in_stab &&
- stab_io(last_in_stab) &&
- stab_io(last_in_stab)->lines ) {
- (void)sprintf(s,", <%s> line %ld",
- last_in_stab == argvstab ? "" : stab_ename(last_in_stab),
- (long)stab_io(last_in_stab)->lines);
- s += strlen(s);
- }
- (void)strcpy(s,".\n");
- if (usermess)
- str_cat(tmpstr,buf+1);
- }
- if (usermess)
- return tmpstr->str_ptr;
- else
- return buf;
-}
-
-/*VARARGS1*/
-void fatal(pat,a1,a2,a3,a4)
-char *pat;
-long a1, a2, a3, a4;
-{
- extern FILE *e_fp;
- extern char *e_tmpname;
- char *tmps;
- char *message;
-
- message = mess(pat,a1,a2,a3,a4);
- if (in_eval) {
- str_set(stab_val(stabent("@",TRUE)),message);
- tmps = "_EVAL_";
- while (loop_ptr >= 0 && (!loop_stack[loop_ptr].loop_label ||
- strNE(tmps,loop_stack[loop_ptr].loop_label) )) {
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Skipping label #%d %s)\n",loop_ptr,
- loop_stack[loop_ptr].loop_label);
- }
-#endif
- loop_ptr--;
- }
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Found label #%d %s)\n",loop_ptr,
- loop_stack[loop_ptr].loop_label);
- }
-#endif
- if (loop_ptr < 0) {
- in_eval = 0;
- fatal("Bad label: %s", tmps);
- }
- longjmp(loop_stack[loop_ptr].loop_env, 1);
- }
- fputs(message,stderr);
- (void)fflush(stderr);
- if (e_fp)
- (void)UNLINK(e_tmpname);
- statusvalue >>= 8;
- exit((int)((errno&255)?errno:((statusvalue&255)?statusvalue:255)));
-}
-
-/*VARARGS1*/
-void warn(pat,a1,a2,a3,a4)
-char *pat;
-long a1, a2, a3, a4;
-{
- char *message;
-
- message = mess(pat,a1,a2,a3,a4);
- fputs(message,stderr);
-#ifdef LEAKTEST
-#ifdef DEBUGGING
- if (debug & 4096)
- xstat();
-#endif
-#endif
- (void)fflush(stderr);
-}
-#else
-/*VARARGS0*/
-char *
-mess(args)
-va_list args;
-{
- char *pat;
- char *s;
- STR *tmpstr;
- int usermess;
- size_t l;
-#ifndef HAS_VPRINTF
-#ifdef CHARVSPRINTF
- char *vsprintf();
-#else
- int vsprintf();
-#endif
-#endif
-
-#ifdef lint
- pat = Nullch;
-#else
- pat = va_arg(args, char *);
-#endif
- s = buf;
- usermess = strEQ(pat, "%s");
- if (usermess) {
- tmpstr = str_mortal(&str_undef);
- str_set(tmpstr, va_arg(args, char *));
- *s++ = tmpstr->str_ptr[tmpstr->str_cur-1];
- }
- else {
- (void) vsnprintf(s,sizeof buf - (s - buf),pat,args);
- s += strlen(s);
- }
-
- if (s[-1] != '\n') {
- if (curcmd->c_line) {
- l = s - buf >= sizeof buf - 1? 1: sizeof buf - (s - buf);
- (void)snprintf(s,l," at %s line %ld",
- stab_val(curcmd->c_filestab)->str_ptr, (long)curcmd->c_line);
- s += strlen(s);
- }
- if (last_in_stab &&
- stab_io(last_in_stab) &&
- stab_io(last_in_stab)->lines ) {
- l = s - buf >= sizeof buf - 1? 1: sizeof buf - (s - buf);
- (void)snprintf(s,l,", <%s> line %ld",
- last_in_stab == argvstab ? "" : last_in_stab->str_magic->str_ptr,
- (long)stab_io(last_in_stab)->lines);
- s += strlen(s);
- }
- if (s - buf > sizeof buf - 3)
- (void)strcpy(s,".\n");
- if (usermess)
- str_cat(tmpstr,buf+1);
- }
-
- if (usermess)
- return tmpstr->str_ptr;
- else
- return buf;
-}
-
-/*VARARGS0*/
-void fatal(va_alist)
-va_dcl
-{
- va_list args;
- extern FILE *e_fp;
- extern char *e_tmpname;
- char *tmps;
- char *message;
-
-#ifndef lint
- va_start(args);
-#else
- args = 0;
-#endif
- message = mess(args);
- va_end(args);
- if (in_eval) {
- str_set(stab_val(stabent("@",TRUE)),message);
- tmps = "_EVAL_";
- while (loop_ptr >= 0 && (!loop_stack[loop_ptr].loop_label ||
- strNE(tmps,loop_stack[loop_ptr].loop_label) )) {
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Skipping label #%d %s)\n",loop_ptr,
- loop_stack[loop_ptr].loop_label);
- }
-#endif
- loop_ptr--;
- }
-#ifdef DEBUGGING
- if (debug & 4) {
- deb("(Found label #%d %s)\n",loop_ptr,
- loop_stack[loop_ptr].loop_label);
- }
-#endif
- if (loop_ptr < 0) {
- in_eval = 0;
- fatal("Bad label: %s", tmps);
- }
- longjmp(loop_stack[loop_ptr].loop_env, 1);
- }
- fputs(message,stderr);
- (void)fflush(stderr);
- if (e_fp)
- (void)UNLINK(e_tmpname);
- statusvalue >>= 8;
- exit((int)((errno&255)?errno:((statusvalue&255)?statusvalue:255)));
-}
-
-/*VARARGS0*/
-void warn(va_alist)
-va_dcl
-{
- va_list args;
- char *message;
-
-#ifndef lint
- va_start(args);
-#else
- args = 0;
-#endif
- message = mess(args);
- va_end(args);
-
- fputs(message,stderr);
-#ifdef LEAKTEST
-#ifdef DEBUGGING
- if (debug & 4096)
- xstat();
-#endif
-#endif
- (void)fflush(stderr);
-}
-#endif
-
-void
-my_setenv(nam,val)
-char *nam, *val;
-{
- register int i=envix(nam); /* where does it go? */
-
- if (environ == origenviron) { /* need we copy environment? */
- int j;
- int max;
- char **tmpenv;
-
- /*SUPPRESS 530*/
- for (max = i; environ[max]; max++) ;
- New(901,tmpenv, max+2, char*);
- for (j=0; j<max; j++) /* copy environment */
- tmpenv[j] = savestr(environ[j]);
- tmpenv[max] = Nullch;
- environ = tmpenv; /* tell exec where it is now */
- }
- if (!val) {
- while (environ[i]) {
- environ[i] = environ[i+1];
- i++;
- }
- return;
- }
- if (!environ[i]) { /* does not exist yet */
- Renew(environ, i+2, char*); /* just expand it a bit */
- environ[i+1] = Nullch; /* make sure it's null terminated */
- }
- else
- Safefree(environ[i]);
- New(904, environ[i], strlen(nam) + strlen(val) + 2, char);
-#ifndef MSDOS
- (void)sprintf(environ[i],"%s=%s",nam,val);/* all that work just for this */
-#else
- /* MS-DOS requires environment variable names to be in uppercase */
- /* [Tom Dinger, 27 August 1990: Well, it doesn't _require_ it, but
- * some utilities and applications may break because they only look
- * for upper case strings. (Fixed strupr() bug here.)]
- */
- strcpy(environ[i],nam); strupr(environ[i]);
- (void)sprintf(environ[i] + strlen(nam),"=%s",val);
-#endif /* MSDOS */
-}
-
-int
-envix(nam)
-char *nam;
-{
- register int i, len = strlen(nam);
-
- for (i = 0; environ[i]; i++) {
- if (strnEQ(environ[i],nam,len) && environ[i][len] == '=')
- break; /* strnEQ must come first to avoid */
- } /* potential SEGV's */
- return i;
-}
-
-#ifdef EUNICE
-int
-unlnk(f) /* unlink all versions of a file */
-char *f;
-{
- int i;
-
- for (i = 0; unlink(f) >= 0; i++) ;
- return i ? 0 : -1;
-}
-#endif
-
-#if !defined(HAS_BCOPY) || !defined(SAFE_BCOPY)
-char *
-my_bcopy(from,to,len)
-register char *from;
-register char *to;
-register int len;
-{
- char *retval = to;
-
- if (from - to >= 0) {
- while (len--)
- *to++ = *from++;
- }
- else {
- to += len;
- from += len;
- while (len--)
- *(--to) = *(--from);
- }
- return retval;
-}
-#endif
-
-#if !defined(HAS_BZERO) && !defined(HAS_MEMSET)
-char *
-my_bzero(loc,len)
-register char *loc;
-register int len;
-{
- char *retval = loc;
-
- while (len--)
- *loc++ = 0;
- return retval;
-}
-#endif
-
-#ifndef HAS_MEMCMP
-int
-my_memcmp(s1,s2,len)
-register unsigned char *s1;
-register unsigned char *s2;
-register int len;
-{
- register int tmp;
-
- while (len--) {
- if (tmp = *s1++ - *s2++)
- return tmp;
- }
- return 0;
-}
-#endif /* HAS_MEMCMP */
-
-#ifdef I_VARARGS
-#ifndef HAS_VPRINTF
-
-#ifdef CHARVSPRINTF
-char *
-#else
-int
-#endif
-vsprintf(dest, pat, args)
-char *dest, *pat, *args;
-{
- FILE fakebuf;
-
- fakebuf._ptr = dest;
- fakebuf._cnt = 32767;
-#ifndef _IOSTRG
-#define _IOSTRG 0
-#endif
- fakebuf._flag = _IOWRT|_IOSTRG;
- _doprnt(pat, args, &fakebuf); /* what a kludge */
- (void)putc('\0', &fakebuf);
-#ifdef CHARVSPRINTF
- return(dest);
-#else
- return 0; /* perl doesn't use return value */
-#endif
-}
-
-#ifdef DEBUGGING
-int
-vfprintf(fd, pat, args)
-FILE *fd;
-char *pat, *args;
-{
- _doprnt(pat, args, fd);
- return 0; /* wrong, but perl doesn't use the return value */
-}
-#endif
-#endif /* HAS_VPRINTF */
-#endif /* I_VARARGS */
-
-/*
- * I think my_swap(), htonl() and ntohl() have never been used.
- * perl.h contains last-chance references to my_swap(), my_htonl()
- * and my_ntohl(). I presume these are the intended functions;
- * but htonl() and ntohl() have the wrong names. There are no
- * functions my_htonl() and my_ntohl() defined anywhere.
- * -DWS
- */
-#ifdef MYSWAP
-#if BYTEORDER != 0x4321
-short
-my_swap(s)
-short s;
-{
-#if (BYTEORDER & 1) == 0
- short result;
-
- result = ((s & 255) << 8) + ((s >> 8) & 255);
- return result;
-#else
- return s;
-#endif
-}
-
-long
-htonl(l)
-register long l;
-{
- union {
- long result;
- char c[sizeof(long)];
- } u;
-
-#if BYTEORDER == 0x1234
- u.c[0] = (l >> 24) & 255;
- u.c[1] = (l >> 16) & 255;
- u.c[2] = (l >> 8) & 255;
- u.c[3] = l & 255;
- return u.result;
-#else
-#if ((BYTEORDER - 0x1111) & 0x444) || !(BYTEORDER & 0xf)
- fatal("Unknown BYTEORDER\n");
-#else
- register int o;
- register int s;
-
- for (o = BYTEORDER - 0x1111, s = 0; s < (sizeof(long)*8); o >>= 4, s += 8) {
- u.c[o & 0xf] = (l >> s) & 255;
- }
- return u.result;
-#endif
-#endif
-}
-
-long
-ntohl(l)
-register long l;
-{
- union {
- long l;
- char c[sizeof(long)];
- } u;
-
-#if BYTEORDER == 0x1234
- u.c[0] = (l >> 24) & 255;
- u.c[1] = (l >> 16) & 255;
- u.c[2] = (l >> 8) & 255;
- u.c[3] = l & 255;
- return u.l;
-#else
-#if ((BYTEORDER - 0x1111) & 0x444) || !(BYTEORDER & 0xf)
- fatal("Unknown BYTEORDER\n");
-#else
- register int o;
- register int s;
-
- u.l = l;
- l = 0;
- for (o = BYTEORDER - 0x1111, s = 0; s < (sizeof(long)*8); o >>= 4, s += 8) {
- l |= (u.c[o & 0xf] & 255) << s;
- }
- return l;
-#endif
-#endif
-}
-
-#endif /* BYTEORDER != 0x4321 */
-#endif /* MYSWAP */
-
-/*
- * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
- * If these functions are defined,
- * the BYTEORDER is neither 0x1234 nor 0x4321.
- * However, this is not assumed.
- * -DWS
- */
-
-#define HTOV(name,type) \
- type \
- name (n) \
- register type n; \
- { \
- union { \
- type value; \
- char c[sizeof(type)]; \
- } u; \
- register int i; \
- register int s; \
- for (i = 0, s = 0; i < sizeof(u.c); i++, s += 8) { \
- u.c[i] = (n >> s) & 0xFF; \
- } \
- return u.value; \
- }
-
-#define VTOH(name,type) \
- type \
- name (n) \
- register type n; \
- { \
- union { \
- type value; \
- char c[sizeof(type)]; \
- } u; \
- register int i; \
- register int s; \
- u.value = n; \
- n = 0; \
- for (i = 0, s = 0; i < sizeof(u.c); i++, s += 8) { \
- n += (u.c[i] & 0xFF) << s; \
- } \
- return n; \
- }
-
-#if defined(HAS_HTOVS) && !defined(htovs)
-HTOV(htovs,short)
-#endif
-#if defined(HAS_HTOVL) && !defined(htovl)
-HTOV(htovl,long)
-#endif
-#if defined(HAS_VTOHS) && !defined(vtohs)
-VTOH(vtohs,short)
-#endif
-#if defined(HAS_VTOHL) && !defined(vtohl)
-VTOH(vtohl,long)
-#endif
-
-#ifndef DOSISH
-FILE *
-mypopen(cmd,mode)
-char *cmd;
-char *mode;
-{
- int p[2];
- register int this, that;
- register int pid;
- STR *str;
- int doexec = strNE(cmd,"-");
-
- if (pipe(p) < 0)
- return Nullfp;
- this = (*mode == 'w');
- that = !this;
-#ifdef TAINT
- if (doexec) {
- taintenv();
- taintproper("Insecure dependency in exec");
- }
-#endif
- while ((pid = (doexec?vfork():fork())) < 0) {
- if (errno != EAGAIN) {
- close(p[this]);
- if (!doexec)
- fatal("Can't fork");
- return Nullfp;
- }
- sleep(5);
- }
- if (pid == 0) {
-#define THIS that
-#define THAT this
- close(p[THAT]);
- if (p[THIS] != (*mode == 'r')) {
- dup2(p[THIS], *mode == 'r');
- close(p[THIS]);
- }
- if (doexec) {
-#if !defined(HAS_FCNTL) || !defined(F_SETFD)
- int fd;
-
-#ifndef NOFILE
-#define NOFILE 20
-#endif
- for (fd = maxsysfd + 1; fd < NOFILE; fd++)
- close(fd);
-#endif
- do_exec(cmd); /* may or may not use the shell */
- warn("Can't exec \"%s\": %s", cmd, strerror(errno));
- _exit(1);
- }
- /*SUPPRESS 560*/
- if (tmpstab = stabent("$",allstabs))
- str_numset(STAB_STR(tmpstab),(double)getpid());
- forkprocess = 0;
- hclear(pidstatus, FALSE); /* we have no children */
- return Nullfp;
-#undef THIS
-#undef THAT
- }
- do_execfree(); /* free any memory malloced by child on vfork */
- close(p[that]);
- if (p[that] < p[this]) {
- dup2(p[this], p[that]);
- close(p[this]);
- p[this] = p[that];
- }
- str = afetch(fdpid,p[this],TRUE);
- str->str_u.str_useful = pid;
- forkprocess = pid;
- return fdopen(p[this], mode);
-}
-#else
-#ifdef atarist
-FILE *popen();
-FILE *
-mypopen(cmd,mode)
-char *cmd;
-char *mode;
-{
- return popen(cmd, mode);
-}
-#endif
-
-#endif /* !DOSISH */
-
-#ifdef NOTDEF
-dumpfds(s)
-char *s;
-{
- int fd;
- struct stat tmpstatbuf;
-
- fprintf(stderr,"%s", s);
- for (fd = 0; fd < 32; fd++) {
- if (fstat(fd,&tmpstatbuf) >= 0)
- fprintf(stderr," %d",fd);
- }
- fprintf(stderr,"\n");
-}
-#endif
-
-#ifndef HAS_DUP2
-dup2(oldfd,newfd)
-int oldfd;
-int newfd;
-{
-#if defined(HAS_FCNTL) && defined(F_DUPFD)
- close(newfd);
- fcntl(oldfd, F_DUPFD, newfd);
-#else
- int fdtmp[256];
- int fdx = 0;
- int fd;
-
- if (oldfd == newfd)
- return 0;
- close(newfd);
- while ((fd = dup(oldfd)) != newfd) /* good enough for low fd's */
- fdtmp[fdx++] = fd;
- while (fdx > 0)
- close(fdtmp[--fdx]);
-#endif
-}
-#endif
-
-#ifndef DOSISH
-int
-mypclose(ptr)
-FILE *ptr;
-{
-#ifdef VOIDSIG
- void (*hstat)(), (*istat)(), (*qstat)();
-#else
- int (*hstat)(), (*istat)(), (*qstat)();
-#endif
- int status;
- STR *str;
- int pid;
-
- str = afetch(fdpid,fileno(ptr),TRUE);
- pid = (int)str->str_u.str_useful;
- astore(fdpid,fileno(ptr),Nullstr);
- fclose(ptr);
-#ifdef UTS
- if(kill(pid, 0) < 0) { return(pid); } /* HOM 12/23/91 */
-#endif
- hstat = signal(SIGHUP, SIG_IGN);
- istat = signal(SIGINT, SIG_IGN);
- qstat = signal(SIGQUIT, SIG_IGN);
- pid = wait4pid(pid, &status, 0);
- signal(SIGHUP, hstat);
- signal(SIGINT, istat);
- signal(SIGQUIT, qstat);
- return(pid < 0 ? pid : status);
-}
-
-int
-wait4pid(pid,statusp,flags)
-int pid;
-int *statusp;
-int flags;
-{
-#if !defined(HAS_WAIT4) && !defined(HAS_WAITPID)
- int result;
- STR *str;
- char spid[16];
-#endif
-
- if (!pid)
- return -1;
-#ifdef HAS_WAIT4
- return wait4((pid==-1)?0:pid,statusp,flags,Null(struct rusage *));
-#else
-#ifdef HAS_WAITPID
- return waitpid(pid,statusp,flags);
-#else
- if (pid > 0) {
- sprintf(spid, "%d", pid);
- str = hfetch(pidstatus,spid,strlen(spid),FALSE);
- if (str != &str_undef) {
- *statusp = (int)str->str_u.str_useful;
- hdelete(pidstatus,spid,strlen(spid));
- return pid;
- }
- }
- else {
- HENT *entry;
-
- hiterinit(pidstatus);
- if (entry = hiternext(pidstatus)) {
- pid = atoi(hiterkey(entry,statusp));
- str = hiterval(pidstatus,entry);
- *statusp = (int)str->str_u.str_useful;
- sprintf(spid, "%d", pid);
- hdelete(pidstatus,spid,strlen(spid));
- return pid;
- }
- }
- if (flags)
- fatal("Can't do waitpid with flags");
- else {
- while ((result = wait(statusp)) != pid && pid > 0 && result >= 0)
- pidgone(result,*statusp);
- if (result < 0)
- *statusp = -1;
- }
- return result;
-#endif
-#endif
-}
-#endif /* !DOSISH */
-
-void
-/*SUPPRESS 590*/
-pidgone(pid,status)
-int pid;
-int status;
-{
-#if defined(HAS_WAIT4) || defined(HAS_WAITPID)
-#else
- register STR *str;
- char spid[16];
-
- sprintf(spid, "%d", pid);
- str = hfetch(pidstatus,spid,strlen(spid),TRUE);
- str->str_u.str_useful = status;
-#endif
- return;
-}
-
-#ifdef atarist
-int pclose();
-int
-mypclose(ptr)
-FILE *ptr;
-{
- return pclose(ptr);
-}
-#endif
-
-void
-repeatcpy(to,from,len,count)
-register char *to;
-register char *from;
-int len;
-register int count;
-{
- register int todo;
- register char *frombase = from;
-
- if (len == 1) {
- todo = *from;
- while (count-- > 0)
- *to++ = todo;
- return;
- }
- while (count-- > 0) {
- for (todo = len; todo > 0; todo--) {
- *to++ = *from++;
- }
- from = frombase;
- }
-}
-
-#ifndef CASTNEGFLOAT
-unsigned long
-castulong(f)
-double f;
-{
- long along;
-
-#if CASTFLAGS & 2
-# define BIGDOUBLE 2147483648.0
- if (f >= BIGDOUBLE)
- return (unsigned long)(f-(long)(f/BIGDOUBLE)*BIGDOUBLE)|0x80000000;
-#endif
- if (f >= 0.0)
- return (unsigned long)f;
- along = (long)f;
- return (unsigned long)along;
-}
-#endif
-
-#ifndef HAS_RENAME
-int
-same_dirent(a,b)
-char *a;
-char *b;
-{
- char *fa = rindex(a,'/');
- char *fb = rindex(b,'/');
- struct stat tmpstatbuf1;
- struct stat tmpstatbuf2;
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
-#endif
- char tmpbuf[MAXPATHLEN+1];
-
- if (fa)
- fa++;
- else
- fa = a;
- if (fb)
- fb++;
- else
- fb = b;
- if (strNE(a,b))
- return FALSE;
- if (fa == a)
- strcpy(tmpbuf,".");
- else
- strncpy(tmpbuf, a, fa - a);
- if (stat(tmpbuf, &tmpstatbuf1) < 0)
- return FALSE;
- if (fb == b)
- strcpy(tmpbuf,".");
- else
- strncpy(tmpbuf, b, fb - b);
- if (stat(tmpbuf, &tmpstatbuf2) < 0)
- return FALSE;
- return tmpstatbuf1.st_dev == tmpstatbuf2.st_dev &&
- tmpstatbuf1.st_ino == tmpstatbuf2.st_ino;
-}
-#endif /* !HAS_RENAME */
-
-unsigned long
-scanoct(start, len, retlen)
-char *start;
-int len;
-int *retlen;
-{
- register char *s = start;
- register unsigned long retval = 0;
-
- while (len-- && *s >= '0' && *s <= '7') {
- retval <<= 3;
- retval |= *s++ - '0';
- }
- *retlen = s - start;
- return retval;
-}
-
-unsigned long
-scanhex(start, len, retlen)
-char *start;
-int len;
-int *retlen;
-{
- register char *s = start;
- register unsigned long retval = 0;
- char *tmp;
-
- while (len-- && *s && (tmp = index(hexdigit, *s))) {
- retval <<= 4;
- retval |= (tmp - hexdigit) & 15;
- s++;
- }
- *retlen = s - start;
- return retval;
-}
diff --git a/gnu/usr.bin/perl/perl/util.h b/gnu/usr.bin/perl/perl/util.h
deleted file mode 100644
index 003e4438..0000000
--- a/gnu/usr.bin/perl/perl/util.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* $RCSfile: util.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:35 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: util.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:35 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:29:40 nate
- * PERL!
- *
- * Revision 4.0.1.4 92/06/11 21:19:36 lwall
- * patch34: pidgone() wasn't declared right
- *
- * Revision 4.0.1.3 92/06/08 16:09:20 lwall
- * patch20: bcopy() and memcpy() now tested for overlap safety
- *
- * Revision 4.0.1.2 91/11/05 19:18:40 lwall
- * patch11: safe malloc code now integrated into Perl's malloc when possible
- *
- * Revision 4.0.1.1 91/06/07 12:11:00 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:56:48 lwall
- * 4.0 baseline.
- *
- */
-
-EXT int *screamfirst INIT(Null(int*));
-EXT int *screamnext INIT(Null(int*));
-
-#ifndef safemalloc
-char *safemalloc();
-char *saferealloc();
-#endif
-char *cpytill();
-char *instr();
-char *fbminstr();
-char *screaminstr();
-void fbmcompile();
-char *savestr();
-void my_setenv();
-int envix();
-void growstr();
-char *ninstr();
-char *rninstr();
-char *nsavestr();
-FILE *mypopen();
-int mypclose();
-#if !defined(HAS_BCOPY) || !defined(SAFE_BCOPY)
-char *my_bcopy();
-#endif
-#if !defined(HAS_BZERO) && !defined(HAS_MEMSET)
-char *my_bzero();
-#endif
-#ifndef HAS_MEMCMP
-int my_memcmp();
-#endif
-unsigned long scanoct();
-unsigned long scanhex();
-void pidgone();
diff --git a/gnu/usr.bin/perl/sperl/Makefile b/gnu/usr.bin/perl/sperl/Makefile
deleted file mode 100644
index 6201f44..0000000
--- a/gnu/usr.bin/perl/sperl/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-#
-
-PROG= suidperl
-LINKS= ${BINDIR}/suidperl ${BINDIR}/sperl4.036
-
-SRCS+= array.c cmd.c cons.c consarg.c
-SRCS+= doarg.c doio.c dolist.c dump.c
-SRCS+= eval.c form.c hash.c
-SRCS+= perl.c perly.c regcomp.c regexec.c
-SRCS+= stab.c str.c toke.c util.c
-SRCS+= usersub.c
-.PATH: ${.CURDIR}/../perl
-
-
-CFLAGS+= -I${.CURDIR}/../perl -DIAMSUID -DTAINT
-LDADD= -lm
-DPADD= ${LIBM}
-
-LDADD+= -lcrypt
-DPADD+= ${LIBCRYPT}
-
-MAN1=
-MLINKS+= perl.1 suidperl.1
-
-BINOWN= root
-BINMODE=4111
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/perl/tperl/Makefile b/gnu/usr.bin/perl/tperl/Makefile
deleted file mode 100644
index 0a4f47d..0000000
--- a/gnu/usr.bin/perl/tperl/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-#
-
-PROG= tperl
-LINKS= ${BINDIR}/tperl ${BINDIR}/tperl4.036
-
-SRCS+= array.c cmd.c cons.c consarg.c
-SRCS+= doarg.c doio.c dolist.c dump.c
-SRCS+= eval.c form.c hash.c
-SRCS+= perl.c perly.c regcomp.c regexec.c
-SRCS+= stab.c str.c toke.c util.c
-SRCS+= usersub.c
-.PATH: ${.CURDIR}/../perl
-
-
-CFLAGS+= -I${.CURDIR}/../perl -DTAINT
-LDADD+= -lm
-DPADD= ${LIBM}
-
-LDADD+= -lcrypt
-DPADD+= ${LIBCRYPT}
-
-MAN1=
-MLINKS+= perl.1 tperl.1
-MLINKS+= perl.1 taintperl.1
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/perl/usub/Makefile b/gnu/usr.bin/perl/usub/Makefile
deleted file mode 100644
index a6c7259..0000000
--- a/gnu/usr.bin/perl/usub/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-PROG= curseperl
-
-# From perl
-SRCS+= array.c cmd.c cons.c consarg.c doarg.c doio.c dolist.c dump.c
-SRCS+= eval.c form.c hash.c perl.c perly.c regcomp.c regexec.c
-SRCS+= stab.c str.c toke.c util.c
-
-# Local to us.
-SRCS+= usersub.c curses.c
-
-CFLAGS+= -DDEBUGGING -I${.CURDIR}/../perl
-LDADD+= -lncurses -lmytinfo -lcrypt -lm
-DPADD+= ${LIBNCURSES} ${LIBMYTINFO} ${LIBCRYPT} ${LIBM}
-CLEANFILES+= curses.c
-VPATH+= ${.CURDIR}/../perl
-NOMAN= yes
-
-# If perl exists in none of these places, something is horribly wrong.
-.if exists(${.OBJDIR}/../perl/perl)
-PERL=${.OBJDIR}/../perl/perl
-.endif
-.if !defined(PERL) && exists(${.CURDIR}/../perl/perl)
-PERL=${.CURDIR}/../perl/perl
-.else
-PERL= /usr/bin/perl
-.endif
-
-curses.c: curses.mus
- ${PERL} ${.CURDIR}/mus ${.CURDIR}/curses.mus > curses.c
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/perl/usub/README b/gnu/usr.bin/perl/usub/README
deleted file mode 100644
index 4e14596..0000000
--- a/gnu/usr.bin/perl/usub/README
+++ /dev/null
@@ -1,117 +0,0 @@
-[ Note: This directory was actually brought in to be able to use curseperl,
- but it's also a useful reference for general extension ]
-
-This directory contains an example of how you might link in C subroutines
-with perl to make your own special copy of perl. In the perl distribution
-directory, there will be (after make is run) a file called uperl.o, which
-is all of perl except for a single undefined subroutine, named userinit().
-See usersub.c.
-
-The sole purpose of the userinit() routine is to call the initialization
-routines for any modules that you want to link in. In this example, we just
-call init_curses(), which sets up to link in the System V curses routines.
-You'll find this in the file curses.c, which is the processed output of
-curses.mus. (To get BSD curses, replace curses.mus with bsdcurses.mus.)
-
-The magicname() routine adds variable names into the symbol table. Along
-with the name of the variable as Perl knows it, we pass a structure containing
-an index identifying the variable, and the names of two C functions that
-know how to set or evaluate a variable given the index of the variable.
-Our example uses a macro to handle this conveniently.
-
-The init routine calls make_usub() to add user-defined subroutine names
-into the symbol table. The arguments are
-
- make_usub(subname, subindex, subfunc, filename);
- char *subname;
- int subindex;
- int subfunc();
- char *filename;
-
-The subname is the name that will be used in the Perl program. The subindex
-will be passed to subfunc() when it is called to tell it which C function
-is desired. subfunc() is a glue routine that translates the arguments
-from Perl internal stack form to the form required by the routine in
-question, calls the desired C function, and then translates any return
-value back into the stack format. The glue routine used by curses just
-has a large switch statement, each branch of which does the processing
-for a particular C function. The subindex could, however, be used to look
-up a function in a dynamically linked library. No example of this is
-provided.
-
-As a help in producing the glue routine, a preprocessor called "mus" lets
-you specify argument and return value types in a tabular format. An entry
-such as:
-
- CASE int waddstr
- I WINDOW* win
- I char* str
- END
-
-indicates that waddstr takes two input arguments, the first of which is a
-pointer to a window, and the second of which is an ordinary C string. It
-also indicates that an integer is returned. The mus program turns this into:
-
- case US_waddstr:
- if (items != 2)
- fatal("Usage: &waddstr($win, $str)");
- else {
- int retval;
- WINDOW* win = *(WINDOW**) str_get(st[1]);
- char* str = (char*) str_get(st[2]);
-
- retval = waddstr(win, str);
- str_numset(st[0], (double) retval);
- }
- return sp;
-
-It's also possible to have output parameters, indicated by O, and input/ouput
-parameters indicated by IO.
-
-The mus program isn't perfect. You'll note that curses.mus has some
-cases which are hand coded. They'll be passed straight through unmodified.
-You can produce similar cases by analogy to what's in curses.c, as well
-as similar routines in the doarg.c, dolist.c and doio.c routines of Perl.
-The mus program is only intended to get you about 90% there. It's not clear,
-for instance, how a given structure should be passed to Perl. But that
-shouldn't bother you--if you've gotten this far, it's already obvious
-that you are totally mad.
-
-Here's an example of how to return an array value:
-
- case US_appl_errlist:
- if (!wantarray) {
- str_numset(st[0], (double) appl_nerr);
- return sp;
- }
- astore(stack, sp + appl_nerr, Nullstr); /* extend stack */
- st = stack->ary_array + sp; /* possibly realloced */
- for (i = 0; i < appl_nerr; i++) {
- tmps = appl_errlist[i];
- st[i] = str_2mortal(str_make(tmps,strlen(tmps)));
- }
- return sp + appl_nerr - 1;
-
-
-In addition, there is a program, man2mus, that will scan a man page for
-function prototypes and attempt to construct a mus CASE entry for you. It has
-to guess about input/output parameters, so you'll have to tidy up after it.
-But it can save you a lot of time if the man pages for a library are
-reasonably well formed.
-
-If you happen to have curses on your machine, you might try compiling
-a copy of curseperl. The "pager" program in this directory is a rudimentary
-start on writing a pager--don't believe the help message, which is stolen
-from the less program.
-
-User-defined subroutines may not currently be called as a signal handler,
-though a signal handler may itself call a user-defined subroutine.
-
-There are now glue routines to call back from C into Perl. In usersub.c
-in this directory, you'll find callback() and callv(). The callback()
-routine presumes that any arguments to pass to the Perl subroutine
-have already been pushed onto the Perl stack. The callv() routine
-is a wrapper that pushes an argv-style array of strings onto the
-stack for you, and then calls callback(). Be sure to recheck your
-stack pointer after returning from these routine, since the Perl code
-may have reallocated it.
diff --git a/gnu/usr.bin/perl/usub/curses.mus b/gnu/usr.bin/perl/usub/curses.mus
deleted file mode 100644
index 03269c3..0000000
--- a/gnu/usr.bin/perl/usub/curses.mus
+++ /dev/null
@@ -1,813 +0,0 @@
-/* $RCSfile: curses.mus,v $$Revision: 1.1 $$Date: 1995/03/24 04:33:49 $
- *
- * $Log: curses.mus,v $
-# Revision 1.1 1995/03/24 04:33:49 jkh
-# Bring back perl/usub as usub/, this time containing an updated curseperl
-# which is also installed by default (the reason for which should also be
-# plain shortly).
-#
- * Revision 4.0.1.2 92/06/08 16:06:12 lwall
- * patch20: function key support added to curses.mus
- *
- * Revision 4.0.1.1 91/11/05 19:06:19 lwall
- * patch11: usub/curses.mus now supports SysV curses
- *
- * Revision 4.0 91/03/20 01:56:13 lwall
- * 4.0 baseline.
- *
- * Revision 3.0.1.1 90/08/09 04:05:21 lwall
- * patch19: Initial revision
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-char *savestr();
-static char *getcap();
-
-#undef bool
-#include <ncurses.h>
-
-#ifndef A_UNDERLINE
-#define NOSETATTR
-#define A_STANDOUT 0x0200
-#define A_UNDERLINE 0x0100
-#define A_REVERSE 0x0200
-#define A_BLINK 0x0400
-#define A_BOLD 0x0800
-#define A_ALTCHARSET 0x1000
-#define A_NORMAL 0
-#endif
-
-#ifdef USG
-static char *tcbuf = NULL;
-#endif
-
-#ifdef NOSETATTR
-static unsigned curattr = NORMAL;
-#endif
-
-enum uservars {
- UV_curscr,
- UV_stdscr,
- UV_LINES,
- UV_COLS,
- UV_ERR,
- UV_OK,
- UV_A_STANDOUT,
- UV_A_UNDERLINE,
- UV_A_REVERSE,
- UV_A_BLINK,
- UV_A_DIM,
- UV_A_BOLD,
- UV_A_NORMAL,
-};
-
-enum usersubs {
- US_addch,
- US_waddch,
- US_addstr,
- US_waddstr,
- US_box,
- US_clear,
- US_wclear,
- US_clearok,
- US_clrtobot,
- US_wclrtobot,
- US_clrtoeol,
- US_wclrtoeol,
- US_delch,
- US_wdelch,
- US_deleteln,
- US_wdeleteln,
- US_erase,
- US_werase,
- US_idlok,
- US_insch,
- US_winsch,
- US_insertln,
- US_winsertln,
- US_move,
- US_wmove,
- US_overlay,
- US_overwrite,
- US_refresh,
- US_wrefresh,
- US_standout,
- US_wstandout,
- US_standend,
- US_wstandend,
- US_cbreak,
- US_nocbreak,
- US_echo,
- US_noecho,
- US_getch,
- US_wgetch,
- US_getstr,
- US_wgetstr,
- US_raw,
- US_noraw,
- US_baudrate,
- US_delwin,
- US_endwin,
- US_erasechar,
- US_getyx,
- US_inch,
- US_winch,
- US_initscr,
- US_killchar,
- US_leaveok,
- US_longname,
- US_mvwin,
- US_newwin,
- US_nl,
- US_nonl,
- US_scrollok,
- US_subwin,
- US_touchline,
- US_touchwin,
- US_unctrl,
-#ifndef __FreeBSD__
- US_gettmode,
-#endif
- US_mvcur,
- US_scroll,
- US_savetty,
- US_resetty,
- US_attroff,
- US_wattroff,
- US_attron,
- US_wattron,
- US_attrset,
- US_wattrset,
-#ifdef CURSEFMT
- US_printw, /* remove */
- US_wprintw, /* remove */
- US_scanw, /* delete */
- US_wscanw, /* delete */
-#endif
- US_getcap,
- US_mysub,
- US_testcallback,
-};
-
-static int usersub();
-static int userset();
-static int userval();
-
-int
-init_curses()
-{
- struct ufuncs uf;
- char *filename = "curses.c";
-
- uf.uf_set = userset;
- uf.uf_val = userval;
-
-#define MAGICVAR(name, ix) uf.uf_index = ix, magicname(name, &uf, sizeof uf)
-
- MAGICVAR("curscr", UV_curscr);
- MAGICVAR("stdscr", UV_stdscr);
- MAGICVAR("LINES", UV_LINES);
- MAGICVAR("COLS", UV_COLS);
- MAGICVAR("ERR", UV_ERR);
- MAGICVAR("OK", UV_OK);
- MAGICVAR("A_STANDOUT", UV_A_STANDOUT);
- MAGICVAR("A_UNDERLINE", UV_A_UNDERLINE);
- MAGICVAR("A_REVERSE", UV_A_REVERSE);
- MAGICVAR("A_BLINK", UV_A_BLINK);
- MAGICVAR("A_DIM", UV_A_DIM);
- MAGICVAR("A_BOLD", UV_A_BOLD);
- MAGICVAR("A_NORMAL", UV_A_NORMAL);
-
- make_usub("addch", US_addch, usersub, filename);
- make_usub("waddch", US_waddch, usersub, filename);
- make_usub("addstr", US_addstr, usersub, filename);
- make_usub("waddstr", US_waddstr, usersub, filename);
- make_usub("box", US_box, usersub, filename);
- make_usub("clear", US_clear, usersub, filename);
- make_usub("wclear", US_wclear, usersub, filename);
- make_usub("clearok", US_clearok, usersub, filename);
- make_usub("clrtobot", US_clrtobot, usersub, filename);
- make_usub("wclrtobot", US_wclrtobot, usersub, filename);
- make_usub("clrtoeol", US_clrtoeol, usersub, filename);
- make_usub("wclrtoeol", US_wclrtoeol, usersub, filename);
- make_usub("delch", US_delch, usersub, filename);
- make_usub("wdelch", US_wdelch, usersub, filename);
- make_usub("deleteln", US_deleteln, usersub, filename);
- make_usub("wdeleteln", US_wdeleteln, usersub, filename);
- make_usub("erase", US_erase, usersub, filename);
- make_usub("werase", US_werase, usersub, filename);
- make_usub("idlok", US_idlok, usersub, filename);
- make_usub("insch", US_insch, usersub, filename);
- make_usub("winsch", US_winsch, usersub, filename);
- make_usub("insertln", US_insertln, usersub, filename);
- make_usub("winsertln", US_winsertln, usersub, filename);
- make_usub("move", US_move, usersub, filename);
- make_usub("wmove", US_wmove, usersub, filename);
- make_usub("overlay", US_overlay, usersub, filename);
- make_usub("overwrite", US_overwrite, usersub, filename);
- make_usub("refresh", US_refresh, usersub, filename);
- make_usub("wrefresh", US_wrefresh, usersub, filename);
- make_usub("standout", US_standout, usersub, filename);
- make_usub("wstandout", US_wstandout, usersub, filename);
- make_usub("standend", US_standend, usersub, filename);
- make_usub("wstandend", US_wstandend, usersub, filename);
- make_usub("cbreak", US_cbreak, usersub, filename);
- make_usub("nocbreak", US_nocbreak, usersub, filename);
- make_usub("echo", US_echo, usersub, filename);
- make_usub("noecho", US_noecho, usersub, filename);
- make_usub("getch", US_getch, usersub, filename);
- make_usub("wgetch", US_wgetch, usersub, filename);
- make_usub("getstr", US_getstr, usersub, filename);
- make_usub("wgetstr", US_wgetstr, usersub, filename);
- make_usub("raw", US_raw, usersub, filename);
- make_usub("noraw", US_noraw, usersub, filename);
- make_usub("baudrate", US_baudrate, usersub, filename);
- make_usub("delwin", US_delwin, usersub, filename);
- make_usub("endwin", US_endwin, usersub, filename);
- make_usub("erasechar", US_erasechar, usersub, filename);
- make_usub("getyx", US_getyx, usersub, filename);
- make_usub("inch", US_inch, usersub, filename);
- make_usub("winch", US_winch, usersub, filename);
- make_usub("initscr", US_initscr, usersub, filename);
- make_usub("killchar", US_killchar, usersub, filename);
- make_usub("leaveok", US_leaveok, usersub, filename);
- make_usub("longname", US_longname, usersub, filename);
- make_usub("mvwin", US_mvwin, usersub, filename);
- make_usub("newwin", US_newwin, usersub, filename);
- make_usub("nl", US_nl, usersub, filename);
- make_usub("nonl", US_nonl, usersub, filename);
- make_usub("scrollok", US_scrollok, usersub, filename);
- make_usub("subwin", US_subwin, usersub, filename);
- make_usub("touchline", US_touchline, usersub, filename);
- make_usub("touchwin", US_touchwin, usersub, filename);
- make_usub("unctrl", US_unctrl, usersub, filename);
-#ifndef __FreeBSD__
- make_usub("gettmode", US_gettmode, usersub, filename);
-#endif
- make_usub("mvcur", US_mvcur, usersub, filename);
- make_usub("scroll", US_scroll, usersub, filename);
- make_usub("savetty", US_savetty, usersub, filename);
- make_usub("resetty", US_resetty, usersub, filename);
- make_usub("getcap", US_getcap, usersub, filename);
- make_usub("attroff", US_attroff, usersub, filename);
- make_usub("wattroff", US_wattroff, usersub, filename);
- make_usub("attron", US_attron, usersub, filename);
- make_usub("wattron", US_wattron, usersub, filename);
- make_usub("attrset", US_attrset, usersub, filename);
- make_usub("wattrset", US_wattrset, usersub, filename);
-#ifdef CURSEFMT
- make_usub("printw", US_printw, usersub, filename);
- make_usub("wprintw", US_wprintw, usersub, filename);
- make_usub("scanw", US_scanw, usersub, filename);
- make_usub("wscanw", US_wscanw, usersub, filename);
-#endif
- make_usub("testcallback", US_testcallback,usersub, filename);
- };
-
-#ifdef NOSETATTR
-#define attron(attr) wattron(stdscr, attr)
-#define attroff(attr) wattroff(stdscr, attr)
-#define attset(attr) wattset(stdscr, attr)
-
-int
-wattron(win, attr)
-WINDOW *win;
-chtype attr;
-{
- curattr |= attr;
- if (curattr & A_STANDOUT) {
- return(wstandout(win));
- } else {
- return(wstandend(win));
- }
-}
-
-int
-wattroff(win, attr)
-WINDOW *win;
-chtype attr;
-{
- curattr &= (~attr);
- if (curattr & A_STANDOUT) {
- return(wstandout(win));
- } else {
- return(wstandend(win));
- }
-}
-
-int
-wattrset(win, attr)
-WINDOW *win;
-chtype attr;
-{
- curattr = attr;
- if (curattr & A_STANDOUT) {
- return(wstandout(win));
- } else {
- return(wstandend(win));
- }
-}
-
-#endif
-
-static int
-usersub(ix, sp, items)
-int ix;
-register int sp;
-register int items;
-{
- STR **st = stack->ary_array + sp;
- register int i;
- register char *tmps;
- register STR *Str; /* used in str_get and str_gnum macros */
-
- switch (ix) {
-CASE int addch
-I char ch
-END
-
-CASE int waddch
-I WINDOW* win
-I char ch
-END
-
-CASE int addstr
-I char* str
-END
-
-CASE int waddstr
-I WINDOW* win
-I char* str
-END
-
-CASE int box
-I WINDOW* win
-I char vert
-I char hor
-END
-
-CASE int clear
-END
-
-CASE int wclear
-I WINDOW* win
-END
-
-CASE int clearok
-I WINDOW* win
-I bool boolf
-END
-
-CASE int clrtobot
-END
-
-CASE int wclrtobot
-I WINDOW* win
-END
-
-CASE int clrtoeol
-END
-
-CASE int wclrtoeol
-I WINDOW* win
-END
-
-CASE int delch
-END
-
-CASE int wdelch
-I WINDOW* win
-END
-
-CASE int deleteln
-END
-
-CASE int wdeleteln
-I WINDOW* win
-END
-
-CASE int erase
-END
-
-CASE int werase
-I WINDOW* win
-END
-
-CASE int idlok
-I WINDOW* win
-I bool boolf
-END
-
-CASE int insch
-I char c
-END
-
-CASE int winsch
-I WINDOW* win
-I char c
-END
-
-CASE int insertln
-END
-
-CASE int winsertln
-I WINDOW* win
-END
-
-CASE int move
-I int y
-I int x
-END
-
-CASE int wmove
-I WINDOW* win
-I int y
-I int x
-END
-
-CASE int overlay
-I WINDOW* win1
-I WINDOW* win2
-END
-
-CASE int overwrite
-I WINDOW* win1
-I WINDOW* win2
-END
-
-CASE int refresh
-END
-
-CASE int wrefresh
-I WINDOW* win
-END
-
-CASE int standout
-END
-
-CASE int wstandout
-I WINDOW* win
-END
-
-CASE int standend
-END
-
-CASE int wstandend
-I WINDOW* win
-END
-
-CASE int cbreak
-END
-
-CASE int nocbreak
-END
-
-CASE int echo
-END
-
-CASE int noecho
-END
-
- case US_getch:
- if (items != 0)
- fatal("Usage: &getch()");
- else {
- int retval;
- char retch;
-
- retval = getch();
- if (retval == EOF)
- st[0] = &str_undef;
- else {
- retch = retval;
- if (retval > 0377)
- str_numset(st[0], (double) retval);
- else
- str_nset(st[0], &retch, 1);
- }
- }
- return sp;
-
- case US_wgetch:
- if (items != 1)
- fatal("Usage: &wgetch($win)");
- else {
- int retval;
- char retch;
- WINDOW* win = *(WINDOW**) str_get(st[1]);
-
- retval = wgetch(win);
- if (retval == EOF)
- st[0] = &str_undef;
- else {
- retch = retval;
- if (retval > 0377)
- str_numset(st[0], (double) retval);
- else
- str_nset(st[0], &retch, 1);
- }
- }
- return sp;
-
-CASE int getstr
-O char* str
-END
-
-CASE int wgetstr
-I WINDOW* win
-O char* str
-END
-
-CASE int raw
-END
-
-CASE int noraw
-END
-
-CASE int baudrate
-END
-
-CASE int delwin
-I WINDOW* win
-END
-
-CASE int endwin
-END
-
-CASE int erasechar
-END
-
- case US_getyx:
- if (items != 3)
- fatal("Usage: &getyx($win, $y, $x)");
- else {
- int retval;
- STR* str = str_new(0);
- WINDOW* win = *(WINDOW**) str_get(st[1]);
- int y;
- int x;
-
- do_sprintf(str, items - 1, st + 1);
- retval = getyx(win, y, x);
- str_numset(st[2], (double)y);
- str_numset(st[3], (double)x);
- str_numset(st[0], (double) retval);
- str_free(str);
- }
- return sp;
-
-CASE int inch
-END
-
-CASE int winch
-I WINDOW* win
-END
-
-CASE WINDOW* initscr
-END
-
-CASE int killchar
-END
-
-CASE int leaveok
-I WINDOW* win
-I bool boolf
-END
-
-#ifdef BSD
-CASE char* longname
-END
-#else
-CASE char* longname
-I char* termbug
-I char* name
-END
-#endif
-
-CASE int mvwin
-I WINDOW* win
-I int y
-I int x
-END
-
-CASE WINDOW* newwin
-I int lines
-I int cols
-I int begin_y
-I int begin_x
-END
-
-CASE int nl
-END
-
-CASE int nonl
-END
-
-CASE int scrollok
-I WINDOW* win
-I bool boolf
-END
-
-CASE WINDOW* subwin
-I WINDOW* win
-I int lines
-I int cols
-I int begin_y
-I int begin_x
-END
-
-CASE int touchline
-I WINDOW* win
-I int y
-I int startx
-END
-
-CASE int touchwin
-I WINDOW* win
-END
-
-CASE char* unctrl
-I char ch
-END
-
-#ifndef __FreeBSD__
-CASE int gettmode
-END
-#endif
-
-CASE int mvcur
-I int lasty
-I int lastx
-I int newy
-I int newx
-END
-
-CASE int scroll
-I WINDOW* win
-END
-
-CASE int savetty
-END
-
-CASE void resetty
-END
-
-CASE int attroff
-I chtype str
-END
-
-CASE int wattroff
-I WINDOW* win
-I chtype str
-END
-
-CASE int wattron
-I WINDOW* win
-I chtype str
-END
-
-CASE int attron
-I chtype str
-END
-
-CASE int attrset
-I chtype str
-END
-
-CASE int wattrset
-I WINDOW* win
-I chtype str
-END
-
-#ifdef CURSEFMT
- case US_printw:
- if (items < 1)
- fatal("Usage: &printw($fmt, $arg1, $arg2, ... )");
- else {
- int retval;
- STR* str = str_new(0);
-
- do_sprintf(str, items - 1, st + 1);
- retval = addstr(str->str_ptr);
- str_numset(st[0], (double) retval);
- str_free(str);
- }
- return sp;
-
- case US_wprintw:
- if (items < 2)
- fatal("Usage: &wprintw($win, $fmt, $arg1, $arg2, ... )");
- else {
- int retval;
- STR* str = str_new(0);
- WINDOW* win = *(WINDOW**) str_get(st[1]);
-
- do_sprintf(str, items - 1, st + 1);
- retval = waddstr(win, str->str_ptr);
- str_numset(st[0], (double) retval);
- str_free(str);
- }
- return sp;
-
-#endif
-CASE char* getcap
-I char* str
-END
- default:
- fatal("Unimplemented user-defined subroutine");
- }
- return sp;
-}
-
-static char
-*getcap(cap)
-register char *cap;
-{
- static char *tcbuf = NULL;
- static char nocaperr[] = "Cannot read termcap entry.";
- extern char *tgetstr();
- char *cp, *tp;
- static char capstr[256];
-
- cp = capstr;
- if (tcbuf == NULL) {
- if ((tcbuf = malloc(1024)) == NULL) {
- fatal(nocaperr);
- }
- tp = getenv("TERM");
- if (!tp)
- tp = "tty";
- if (tgetent(tcbuf, tp) == -1) {
- fatal(nocaperr);
- }
- }
- return (tgetstr(cap, &cp));
-}
-
-static int
-userval(ix, str)
-int ix;
-STR *str;
-{
- switch (ix) {
- case UV_COLS:
- str_numset(str, (double)COLS);
- break;
- case UV_ERR:
- str_numset(str, (double)ERR);
- break;
- case UV_LINES:
- str_numset(str, (double)LINES);
- break;
- case UV_OK:
- str_numset(str, (double)OK);
- break;
- case UV_curscr:
- str_nset(str, &curscr, sizeof(WINDOW*));
- break;
- case UV_stdscr:
- str_nset(str, &stdscr, sizeof(WINDOW*));
- break;
- case UV_A_STANDOUT:
- str_numset(str, (double)A_STANDOUT);
- break;
- case UV_A_UNDERLINE:
- str_numset(str, (double)A_UNDERLINE);
- break;
- case UV_A_REVERSE:
- str_numset(str, (double)A_REVERSE);
- break;
- case UV_A_BLINK:
- str_numset(str, (double)A_BLINK);
- break;
- case UV_A_DIM:
- str_numset(str, (double)A_DIM);
- break;
- case UV_A_BOLD:
- str_numset(str, (double)A_BOLD);
- break;
- case UV_A_NORMAL:
- str_numset(str, (double)A_NORMAL);
- break;
- }
- return 0;
-}
-
-static int
-userset(ix, str)
-int ix;
-STR *str;
-{
- switch (ix) {
- case UV_COLS:
- COLS = (int)str_gnum(str);
- break;
- case UV_LINES:
- LINES = (int)str_gnum(str);
- break;
- }
- return 0;
-}
diff --git a/gnu/usr.bin/perl/usub/man2mus b/gnu/usr.bin/perl/usub/man2mus
deleted file mode 100755
index a304678..0000000
--- a/gnu/usr.bin/perl/usub/man2mus
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/perl
-while (<>) {
- if (/^\.SH SYNOPSIS/) {
- $spec = '';
- for ($_ = <>; $_ && !/^\.SH/; $_ = <>) {
- s/^\.[IRB][IRB]\s*//;
- s/^\.[IRB]\s+//;
- next if /^\./;
- s/\\f\w//g;
- s/\\&//g;
- s/^\s+//;
- next if /^$/;
- next if /^#/;
- $spec .= $_;
- }
- $_ = $spec;
- 0 while s/\(([^),;]*)\s*,\s*([^);]*)\)/($1|$2)/g;
- s/\(\*([^,;]*)\)\(\)/(*)()$1/g;
- s/(\w+)\[\]/*$1/g;
-
- s/\n/ /g;
- s/\s+/ /g;
- s/(\w+) \(([^*])/$1($2/g;
- s/^ //;
- s/ ?; ?/\n/g;
- s/\) /)\n/g;
- s/ \* / \*/g;
- s/\* / \*/g;
-
- $* = 1;
- 0 while s/^((struct )?\w+ )([^\n,]*), ?(.*)/$1$3\n$1$4/g;
- $* = 0;
- s/\|/,/g;
-
- @cases = ();
- for (reverse split(/\n/,$_)) {
- if (/\)$/) {
- ($type,$name,$args) = split(/(\w+)\(/);
- $type =~ s/ $//;
- if ($type =~ /^(\w+) =/) {
- $type = $type{$1} if $type{$1};
- }
- $type = 'int' if $type eq '';
- @args = grep(/./, split(/[,)]/,$args));
- $case = "CASE $type $name\n";
- foreach $arg (@args) {
- $type = $type{$arg} || "int";
- $type =~ s/ //g;
- $type .= "\t" if length($type) < 8;
- if ($type =~ /\*/) {
- $case .= "IO $type $arg\n";
- }
- else {
- $case .= "I $type $arg\n";
- }
- }
- $case .= "END\n\n";
- unshift(@cases, $case);
- }
- else {
- $type{$name} = $type if ($type,$name) = /(.*\W)(\w+)$/;
- }
- }
- print @cases;
- }
-}
diff --git a/gnu/usr.bin/perl/usub/mus b/gnu/usr.bin/perl/usub/mus
deleted file mode 100755
index b1675fd..0000000
--- a/gnu/usr.bin/perl/usub/mus
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/usr/bin/perl
-
-while (<>) {
- if (s/^CASE\s+//) {
- @fields = split;
- $funcname = pop(@fields);
- $rettype = "@fields";
- @modes = ();
- @types = ();
- @names = ();
- @outies = ();
- @callnames = ();
- $pre = "\n";
- $post = '';
-
- while (<>) {
- last unless /^[IO]+\s/;
- @fields = split(' ');
- push(@modes, shift(@fields));
- push(@names, pop(@fields));
- push(@types, "@fields");
- }
- while (s/^<\s//) {
- $pre .= "\t $_";
- $_ = <>;
- }
- while (s/^>\s//) {
- $post .= "\t $_";
- $_ = <>;
- }
- $items = @names;
- $namelist = '$' . join(', $', @names);
- $namelist = '' if $namelist eq '$';
- print <<EOF;
- case US_$funcname:
- if (items != $items)
- fatal("Usage: &$funcname($namelist)");
- else {
-EOF
- if ($rettype eq 'void') {
- print <<EOF;
- int retval = 1;
-EOF
- }
- else {
- print <<EOF;
- $rettype retval;
-EOF
- }
- foreach $i (1..@names) {
- $mode = $modes[$i-1];
- $type = $types[$i-1];
- $name = $names[$i-1];
- if ($type =~ /^[A-Z]+\*$/) {
- $cast = "*($type*)";
- }
- else {
- $cast = "($type)";
- }
- $what = ($type =~ /^(struct\s+\w+|char|[A-Z]+)\s*\*$/ ? "get" : "gnum");
- $type .= "\t" if length($type) < 4;
- $cast .= "\t" if length($cast) < 8;
- $x = "\t" x (length($name) < 6);
- if ($mode =~ /O/) {
- if ($what eq 'gnum') {
- push(@outies, "\t str_numset(st[$i], (double) $name);\n");
- push(@callnames, "&$name");
- }
- else {
- push(@outies, "\t str_set(st[$i], (char*) $name);\n");
- push(@callnames, "$name");
- }
- }
- else {
- push(@callnames, $name);
- }
- if ($mode =~ /I/) {
- print <<EOF;
- $type $name =$x $cast str_$what(st[$i]);
-EOF
- }
- elsif ($type =~ /char/) {
- print <<EOF;
- char ${name}[133];
-EOF
- }
- else {
- print <<EOF;
- $type $name;
-EOF
- }
- }
- $callnames = join(', ', @callnames);
- $outies = join("\n",@outies);
- if ($rettype eq 'void') {
- print <<EOF;
-$pre (void)$funcname($callnames);
-EOF
- }
- else {
- print <<EOF;
-$pre retval = $funcname($callnames);
-EOF
- }
- if ($rettype =~ /^(struct\s+\w+|char)\s*\*$/) {
- print <<EOF;
- str_set(st[0], (char*) retval);
-EOF
- }
- elsif ($rettype =~ /^[A-Z]+\s*\*$/) {
- print <<EOF;
- str_nset(st[0], (char*) &retval, sizeof retval);
-EOF
- }
- else {
- print <<EOF;
- str_numset(st[0], (double) retval);
-EOF
- }
- print $outies if $outies;
- print $post if $post;
- if (/^END/) {
- print "\t}\n\treturn sp;\n";
- }
- else {
- redo;
- }
- }
- elsif (/^END/) {
- print "\t}\n\treturn sp;\n";
- }
- else {
- print;
- }
-}
diff --git a/gnu/usr.bin/perl/usub/pager b/gnu/usr.bin/perl/usub/pager
deleted file mode 100755
index d55ace2..0000000
--- a/gnu/usr.bin/perl/usub/pager
+++ /dev/null
@@ -1,190 +0,0 @@
-#!/usr/bin/curseperl
-
-eval <<'EndOfMain'; $evaloffset = __LINE__;
-
- $SIG{'INT'} = 'endit';
- $| = 1; # command buffering on stdout
- &initterm;
- &inithelp;
- &slurpfile && &pagearray;
-
-EndOfMain
-
-&endit;
-
-################################################################################
-
-sub initterm {
-
- &initscr; &cbreak; &noecho; &scrollok($stdscr, 1);
- &defbell unless defined &bell;
-
- $lines = $LINES; $lines1 = $lines - 1; $lines2 = $lines - 2;
- $cols = $COLS; $cols1 = $cols - 1; $cols2 = $cols - 2;;
-
-# $dl = &getcap('dl');
-# $al = &getcap('al');
-# $ho = &getcap('ho');
-# $ce = &getcap('ce');
-}
-
-sub slurpfile {
- while (<>) {
- s/^(\t+)/' ' x length($1)/e;
- &expand($_) if /\t/;
- if (length($_) < $cols) {
- push(@lines, $_);
- }
- else {
- while ($_ && $_ ne "\n") {
- push(@lines, substr($_,0,$cols));
- substr($_,0,$cols) = '';
- }
- }
- }
- 1;
-}
-
-sub drawscreen {
- &move(0,0);
- for ($line .. $line + $lines2) {
- &addstr($lines[$_]);
- }
- &clrtobot;
- &percent;
- &refresh;
-}
-
-sub expand {
- while (($off = index($_[0],"\t")) >= 0) {
- substr($_[0], $off, 1) = ' ' x (8 - $off % 8);
- }
-}
-
-sub pagearray {
- $line = 0;
-
- $| = 1;
-
- for (&drawscreen;;&drawscreen) {
-
- $ch = &getch;
- $ch = 'j' if $ch eq "\n";
-
- if ($ch eq ' ') {
- last if $percent >= 100;
- &move(0,0);
- $line += $lines1;
- }
- elsif ($ch eq 'b') {
- $line -= $lines1;
- &move(0,0);
- $line = 0 if $line < 0;
- }
- elsif ($ch eq 'j') {
- next if $percent >= 100;
- $line += 1;
-# if ($dl && $ho) {
-# print $ho, $dl;
-# &mvcur(0,0,$lines2,0);
-# print $ce,$lines[$line+$lines2],$ce;
-# &wmove($curscr,0,0);
-# &wdeleteln($curscr);
-# &wmove($curscr,$lines2,0);
-# &waddstr($curscr,$lines[$line+$lines2]);
-# }
- &wmove($stdscr,0,0);
- &wdeleteln($stdscr);
- &wmove($stdscr,$lines2,0);
- &waddstr($stdscr,$lines[$line+$lines2]);
- &percent;
- &refresh;
- redo;
- }
- elsif ($ch eq 'k') {
- next if $line <= 0;
- $line -= 1;
-# if ($al && $ho && $ce) {
-# print $ho, $al, $ce, $lines[$line];
-# &wmove($curscr,0,0);
-# &winsertln($curscr);
-# &waddstr($curscr,$lines[$line]);
-# }
- &wmove($stdscr,0,0);
- &winsertln($stdscr);
- &waddstr($stdscr,$lines[$line]);
- &percent;
- &refresh;
- redo;
- }
- elsif ($ch eq "\f") {
- &clear;
- }
- elsif ($ch eq 'q') {
- last;
- }
- elsif ($ch eq 'h') {
- &clear;
- &help;
- &clear;
- }
- else {
- &bell;
- }
- }
-}
-
-sub defbell {
- eval q#
- sub bell {
- print "\007";
- }
- #;
-}
-
-sub help {
- local(*lines) = *helplines;
- local($line);
- &pagearray;
-}
-
-sub inithelp {
- @helplines = split(/\n/,<<'EOT');
-
- h Display this help.
- q Exit.
-
- SPACE Forward screen.
- b Backward screen.
- j, CR Forward 1 line.
- k Backward 1 line.
- FF Repaint screen.
-EOT
- for (@helplines) {
- s/$/\n/;
- }
-}
-
-sub percent {
- &standout;
- $percent = int(($line + $lines1) * 100 / @lines);
- &move($lines1,0);
- &addstr("($percent%)");
- &standend;
- &clrtoeol;
-}
-
-sub endit {
- &move($lines1,0);
- &clrtoeol;
- &refresh;
- &endwin;
-
- if ($@) {
- print ""; # force flush of stdout
- $@ =~ s/\(eval\)/$0/ && $@ =~ s/line (\d+)/'line ' . ($1 + $evaloffset)/e;
- die $@;
- }
-
- exit;
-}
diff --git a/gnu/usr.bin/perl/usub/usersub.c b/gnu/usr.bin/perl/usub/usersub.c
deleted file mode 100644
index 26fbcbc..0000000
--- a/gnu/usr.bin/perl/usub/usersub.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* $RCSfile: usersub.c,v $$Revision: 1.1 $$Date: 1995/03/24 04:33:54 $
- *
- * $Log: usersub.c,v $
- * Revision 1.1 1995/03/24 04:33:54 jkh
- * Bring back perl/usub as usub/, this time containing an updated curseperl
- * which is also installed by default (the reason for which should also be
- * plain shortly).
- *
- * Revision 4.0.1.1 91/11/05 19:07:24 lwall
- * patch11: there are now subroutines for calling back from C into Perl
- *
- * Revision 4.0 91/03/20 01:56:34 lwall
- * 4.0 baseline.
- *
- * Revision 3.0.1.1 90/08/09 04:06:10 lwall
- * patch19: Initial revision
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-
-int
-userinit()
-{
- init_curses();
-}
-
-/* Be sure to refetch the stack pointer after calling these routines. */
-
-int
-callback(subname, sp, gimme, hasargs, numargs)
-char *subname;
-int sp; /* stack pointer after args are pushed */
-int gimme; /* called in array or scalar context */
-int hasargs; /* whether to create a @_ array for routine */
-int numargs; /* how many args are pushed on the stack */
-{
- static ARG myarg[3]; /* fake syntax tree node */
- int arglast[3];
-
- arglast[2] = sp;
- sp -= numargs;
- arglast[1] = sp--;
- arglast[0] = sp;
-
- if (!myarg[0].arg_ptr.arg_str)
- myarg[0].arg_ptr.arg_str = str_make("",0);
-
- myarg[1].arg_type = A_WORD;
- myarg[1].arg_ptr.arg_stab = stabent(subname, FALSE);
-
- myarg[2].arg_type = hasargs ? A_EXPR : A_NULL;
-
- return do_subr(myarg, gimme, arglast);
-}
-
-int
-callv(subname, sp, gimme, argv)
-char *subname;
-register int sp; /* current stack pointer */
-int gimme; /* called in array or scalar context */
-register char **argv; /* null terminated arg list, NULL for no arglist */
-{
- register int items = 0;
- int hasargs = (argv != 0);
-
- astore(stack, ++sp, Nullstr); /* reserve spot for 1st return arg */
- if (hasargs) {
- while (*argv) {
- astore(stack, ++sp, str_2mortal(str_make(*argv,0)));
- items++;
- argv++;
- }
- }
- return callback(subname, sp, gimme, hasargs, items);
-}
diff --git a/gnu/usr.bin/perl/x2p/EXTERN.h b/gnu/usr.bin/perl/x2p/EXTERN.h
deleted file mode 100644
index b0bb6d0..0000000
--- a/gnu/usr.bin/perl/x2p/EXTERN.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* $RCSfile: EXTERN.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:54 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: EXTERN.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:54 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:11 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 12:11:15 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:56:53 lwall
- * 4.0 baseline.
- *
- */
-
-#undef EXT
-#define EXT extern
-
-#undef INIT
-#define INIT(x)
-
-#undef DOINIT
diff --git a/gnu/usr.bin/perl/x2p/INTERN.h b/gnu/usr.bin/perl/x2p/INTERN.h
deleted file mode 100644
index d8a8a3e..0000000
--- a/gnu/usr.bin/perl/x2p/INTERN.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* $RCSfile: INTERN.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:54 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: INTERN.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:54 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:11 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 12:11:20 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:56:58 lwall
- * 4.0 baseline.
- *
- */
-
-#undef EXT
-#define EXT
-
-#undef INIT
-#define INIT(x) = x
-
-#define DOINIT
diff --git a/gnu/usr.bin/perl/x2p/Makefile b/gnu/usr.bin/perl/x2p/Makefile
deleted file mode 100644
index a355d9a..0000000
--- a/gnu/usr.bin/perl/x2p/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-
-PROG= a2p
-
-SRCS+= a2p.c hash.c str.c walk.c util.c
-CFLAGS+= -I${.CURDIR}/../perl
-CLEANFILES+= y.tab.h a2p.c
-
-LDADD= -lm
-DPADD= ${LIBM}
-
-MAN1+= a2p.1 s2p.1 h2ph.1
-
-beforeinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 555 ${.CURDIR}/s2p \
- ${DESTDIR}${BINDIR}
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 555 ${.CURDIR}/h2ph \
- ${DESTDIR}${BINDIR}
-
-afterinstall:
- (DESTDIR=${DESTDIR}; cd ${DESTDIR}/usr/include; ${BINDIR}/h2ph * sys/*)
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/perl/x2p/a2p.1 b/gnu/usr.bin/perl/x2p/a2p.1
deleted file mode 100644
index 58d8c07..0000000
--- a/gnu/usr.bin/perl/x2p/a2p.1
+++ /dev/null
@@ -1,199 +0,0 @@
-.rn '' }`
-''' $Header: /home/cvs/386BSD/ports/lang/perl/x2p/a2p.man,v 1.1.1.1 1993/08/23 21:30:10 nate Exp $
-'''
-''' $Log: a2p.man,v $
-.\" Revision 1.1.1.1 1993/08/23 21:30:10 nate
-.\" PERL!
-.\"
-''' Revision 4.0 91/03/20 01:57:11 lwall
-''' 4.0 baseline.
-'''
-''' Revision 3.0 89/10/18 15:34:22 lwall
-''' 3.0 baseline
-'''
-''' Revision 2.0.1.1 88/07/11 23:16:25 root
-''' patch2: changes related to 1985 awk
-'''
-''' Revision 2.0 88/06/05 00:15:36 root
-''' Baseline version 2.0.
-'''
-'''
-.de Sh
-.br
-.ne 5
-.PP
-\fB\\$1\fR
-.PP
-..
-.de Sp
-.if t .sp .5v
-.if n .sp
-..
-.de Ip
-.br
-.ie \\n.$>=3 .ne \\$3
-.el .ne 3
-.IP "\\$1" \\$2
-..
-'''
-''' Set up \*(-- to give an unbreakable dash;
-''' string Tr holds user defined translation string.
-''' Bell System Logo is used as a dummy character.
-'''
-.tr \(*W-|\(bv\*(Tr
-.ie n \{\
-.ds -- \(*W-
-.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
-.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
-.ds L" ""
-.ds R" ""
-.ds L' '
-.ds R' '
-'br\}
-.el\{\
-.ds -- \(em\|
-.tr \*(Tr
-.ds L" ``
-.ds R" ''
-.ds L' `
-.ds R' '
-'br\}
-.TH A2P 1 LOCAL
-.SH NAME
-a2p - Awk to Perl translator
-.SH SYNOPSIS
-.B a2p [options] filename
-.SH DESCRIPTION
-.I A2p
-takes an awk script specified on the command line (or from standard input)
-and produces a comparable
-.I perl
-script on the standard output.
-.Sh "Options"
-Options include:
-.TP 5
-.B \-D<number>
-sets debugging flags.
-.TP 5
-.B \-F<character>
-tells a2p that this awk script is always invoked with this -F switch.
-.TP 5
-.B \-n<fieldlist>
-specifies the names of the input fields if input does not have to be split into
-an array.
-If you were translating an awk script that processes the password file, you
-might say:
-.sp
- a2p -7 -nlogin.password.uid.gid.gcos.shell.home
-.sp
-Any delimiter can be used to separate the field names.
-.TP 5
-.B \-<number>
-causes a2p to assume that input will always have that many fields.
-.Sh "Considerations"
-A2p cannot do as good a job translating as a human would, but it usually
-does pretty well.
-There are some areas where you may want to examine the perl script produced
-and tweak it some.
-Here are some of them, in no particular order.
-.PP
-There is an awk idiom of putting int() around a string expression to force
-numeric interpretation, even though the argument is always integer anyway.
-This is generally unneeded in perl, but a2p can't tell if the argument
-is always going to be integer, so it leaves it in.
-You may wish to remove it.
-.PP
-Perl differentiates numeric comparison from string comparison.
-Awk has one operator for both that decides at run time which comparison
-to do.
-A2p does not try to do a complete job of awk emulation at this point.
-Instead it guesses which one you want.
-It's almost always right, but it can be spoofed.
-All such guesses are marked with the comment \*(L"#???\*(R".
-You should go through and check them.
-You might want to run at least once with the \-w switch to perl, which
-will warn you if you use == where you should have used eq.
-.PP
-Perl does not attempt to emulate the behavior of awk in which nonexistent
-array elements spring into existence simply by being referenced.
-If somehow you are relying on this mechanism to create null entries for
-a subsequent for...in, they won't be there in perl.
-.PP
-If a2p makes a split line that assigns to a list of variables that looks
-like (Fld1, Fld2, Fld3...) you may want
-to rerun a2p using the \-n option mentioned above.
-This will let you name the fields throughout the script.
-If it splits to an array instead, the script is probably referring to the number
-of fields somewhere.
-.PP
-The exit statement in awk doesn't necessarily exit; it goes to the END
-block if there is one.
-Awk scripts that do contortions within the END block to bypass the block under
-such circumstances can be simplified by removing the conditional
-in the END block and just exiting directly from the perl script.
-.PP
-Perl has two kinds of array, numerically-indexed and associative.
-Awk arrays are usually translated to associative arrays, but if you happen
-to know that the index is always going to be numeric you could change
-the {...} to [...].
-Iteration over an associative array is done using the keys() function, but
-iteration over a numeric array is NOT.
-You might need to modify any loop that is iterating over the array in question.
-.PP
-Awk starts by assuming OFMT has the value %.6g.
-Perl starts by assuming its equivalent, $#, to have the value %.20g.
-You'll want to set $# explicitly if you use the default value of OFMT.
-.PP
-Near the top of the line loop will be the split operation that is implicit in
-the awk script.
-There are times when you can move this down past some conditionals that
-test the entire record so that the split is not done as often.
-.PP
-For aesthetic reasons you may wish to change the array base $[ from 1 back
-to perl's default of 0, but remember to change all array subscripts AND
-all substr() and index() operations to match.
-.PP
-Cute comments that say "# Here is a workaround because awk is dumb" are passed
-through unmodified.
-.PP
-Awk scripts are often embedded in a shell script that pipes stuff into and
-out of awk.
-Often the shell script wrapper can be incorporated into the perl script, since
-perl can start up pipes into and out of itself, and can do other things that
-awk can't do by itself.
-.PP
-Scripts that refer to the special variables RSTART and RLENGTH can often
-be simplified by referring to the variables $`, $& and $', as long as they
-are within the scope of the pattern match that sets them.
-.PP
-The produced perl script may have subroutines defined to deal with awk's
-semantics regarding getline and print.
-Since a2p usually picks correctness over efficiency.
-it is almost always possible to rewrite such code to be more efficient by
-discarding the semantic sugar.
-.PP
-For efficiency, you may wish to remove the keyword from any return statement
-that is the last statement executed in a subroutine.
-A2p catches the most common case, but doesn't analyze embedded blocks for
-subtler cases.
-.PP
-ARGV[0] translates to $ARGV0, but ARGV[n] translates to $ARGV[$n].
-A loop that tries to iterate over ARGV[0] won't find it.
-.SH ENVIRONMENT
-A2p uses no environment variables.
-.SH AUTHOR
-Larry Wall <lwall@jpl-devvax.Jpl.Nasa.Gov>
-.SH FILES
-.SH SEE ALSO
-perl The perl compiler/interpreter
-.br
-s2p sed to perl translator
-.SH DIAGNOSTICS
-.SH BUGS
-It would be possible to emulate awk's behavior in selecting string versus
-numeric operations at run time by inspection of the operands, but it would
-be gross and inefficient.
-Besides, a2p almost always guesses right.
-.PP
-Storage for the awk syntax tree is currently static, and can run out.
-.rn }` ''
diff --git a/gnu/usr.bin/perl/x2p/a2p.h b/gnu/usr.bin/perl/x2p/a2p.h
deleted file mode 100644
index cc59fb7..0000000
--- a/gnu/usr.bin/perl/x2p/a2p.h
+++ /dev/null
@@ -1,344 +0,0 @@
-/* $RCSfile: a2p.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:53 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: a2p.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:53 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:09 nate
- * PERL!
- *
- * Revision 4.0.1.2 92/06/08 16:12:23 lwall
- * patch20: hash tables now split only if the memory is available to do so
- *
- * Revision 4.0.1.1 91/06/07 12:12:27 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:57:07 lwall
- * 4.0 baseline.
- *
- */
-
-#define VOIDUSED 1
-#include "config.h"
-
-#ifndef HAS_BCOPY
-# define bcopy(s1,s2,l) memcpy(s2,s1,l)
-#endif
-#ifndef HAS_BZERO
-# define bzero(s,l) memset(s,0,l)
-#endif
-
-#include "handy.h"
-#define Nullop 0
-
-#define OPROG 1
-#define OJUNK 2
-#define OHUNKS 3
-#define ORANGE 4
-#define OPAT 5
-#define OHUNK 6
-#define OPPAREN 7
-#define OPANDAND 8
-#define OPOROR 9
-#define OPNOT 10
-#define OCPAREN 11
-#define OCANDAND 12
-#define OCOROR 13
-#define OCNOT 14
-#define ORELOP 15
-#define ORPAREN 16
-#define OMATCHOP 17
-#define OMPAREN 18
-#define OCONCAT 19
-#define OASSIGN 20
-#define OADD 21
-#define OSUBTRACT 22
-#define OMULT 23
-#define ODIV 24
-#define OMOD 25
-#define OPOSTINCR 26
-#define OPOSTDECR 27
-#define OPREINCR 28
-#define OPREDECR 29
-#define OUMINUS 30
-#define OUPLUS 31
-#define OPAREN 32
-#define OGETLINE 33
-#define OSPRINTF 34
-#define OSUBSTR 35
-#define OSTRING 36
-#define OSPLIT 37
-#define OSNEWLINE 38
-#define OINDEX 39
-#define ONUM 40
-#define OSTR 41
-#define OVAR 42
-#define OFLD 43
-#define ONEWLINE 44
-#define OCOMMENT 45
-#define OCOMMA 46
-#define OSEMICOLON 47
-#define OSCOMMENT 48
-#define OSTATES 49
-#define OSTATE 50
-#define OPRINT 51
-#define OPRINTF 52
-#define OBREAK 53
-#define ONEXT 54
-#define OEXIT 55
-#define OCONTINUE 56
-#define OREDIR 57
-#define OIF 58
-#define OWHILE 59
-#define OFOR 60
-#define OFORIN 61
-#define OVFLD 62
-#define OBLOCK 63
-#define OREGEX 64
-#define OLENGTH 65
-#define OLOG 66
-#define OEXP 67
-#define OSQRT 68
-#define OINT 69
-#define ODO 70
-#define OPOW 71
-#define OSUB 72
-#define OGSUB 73
-#define OMATCH 74
-#define OUSERFUN 75
-#define OUSERDEF 76
-#define OCLOSE 77
-#define OATAN2 78
-#define OSIN 79
-#define OCOS 80
-#define ORAND 81
-#define OSRAND 82
-#define ODELETE 83
-#define OSYSTEM 84
-#define OCOND 85
-#define ORETURN 86
-#define ODEFINED 87
-#define OSTAR 88
-
-#ifdef DOINIT
-char *opname[] = {
- "0",
- "PROG",
- "JUNK",
- "HUNKS",
- "RANGE",
- "PAT",
- "HUNK",
- "PPAREN",
- "PANDAND",
- "POROR",
- "PNOT",
- "CPAREN",
- "CANDAND",
- "COROR",
- "CNOT",
- "RELOP",
- "RPAREN",
- "MATCHOP",
- "MPAREN",
- "CONCAT",
- "ASSIGN",
- "ADD",
- "SUBTRACT",
- "MULT",
- "DIV",
- "MOD",
- "POSTINCR",
- "POSTDECR",
- "PREINCR",
- "PREDECR",
- "UMINUS",
- "UPLUS",
- "PAREN",
- "GETLINE",
- "SPRINTF",
- "SUBSTR",
- "STRING",
- "SPLIT",
- "SNEWLINE",
- "INDEX",
- "NUM",
- "STR",
- "VAR",
- "FLD",
- "NEWLINE",
- "COMMENT",
- "COMMA",
- "SEMICOLON",
- "SCOMMENT",
- "STATES",
- "STATE",
- "PRINT",
- "PRINTF",
- "BREAK",
- "NEXT",
- "EXIT",
- "CONTINUE",
- "REDIR",
- "IF",
- "WHILE",
- "FOR",
- "FORIN",
- "VFLD",
- "BLOCK",
- "REGEX",
- "LENGTH",
- "LOG",
- "EXP",
- "SQRT",
- "INT",
- "DO",
- "POW",
- "SUB",
- "GSUB",
- "MATCH",
- "USERFUN",
- "USERDEF",
- "CLOSE",
- "ATAN2",
- "SIN",
- "COS",
- "RAND",
- "SRAND",
- "DELETE",
- "SYSTEM",
- "COND",
- "RETURN",
- "DEFINED",
- "STAR",
- "89"
-};
-#else
-extern char *opname[];
-#endif
-
-EXT int mop INIT(1);
-
-union u_ops {
- int ival;
- char *cval;
-};
-#if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
-#define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
-#else
-#define OPSMAX 50000
-#endif /* 80286 hack */
-union u_ops ops[OPSMAX];
-
-#include <stdio.h>
-#include <ctype.h>
-
-typedef struct string STR;
-typedef struct htbl HASH;
-
-#include "str.h"
-#include "hash.h"
-
-/* A string is TRUE if not "" or "0". */
-#define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
-EXT char *Yes INIT("1");
-EXT char *No INIT("");
-
-#define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
-
-#define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
-#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
-#define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
-EXT STR *Str;
-
-#define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
-
-STR *str_new();
-
-char *scanpat();
-char *scannum();
-
-void str_free();
-
-EXT int line INIT(0);
-
-EXT FILE *rsfp;
-EXT char buf[2048];
-EXT char *bufptr INIT(buf);
-
-EXT STR *linestr INIT(Nullstr);
-
-EXT char tokenbuf[2048];
-EXT int expectterm INIT(TRUE);
-
-#ifdef DEBUGGING
-EXT int debug INIT(0);
-EXT int dlevel INIT(0);
-#define YYDEBUG 1
-extern int yydebug;
-#endif
-
-EXT STR *freestrroot INIT(Nullstr);
-
-EXT STR str_no;
-EXT STR str_yes;
-
-EXT bool do_split INIT(FALSE);
-EXT bool split_to_array INIT(FALSE);
-EXT bool set_array_base INIT(FALSE);
-EXT bool saw_RS INIT(FALSE);
-EXT bool saw_OFS INIT(FALSE);
-EXT bool saw_ORS INIT(FALSE);
-EXT bool saw_line_op INIT(FALSE);
-EXT bool in_begin INIT(TRUE);
-EXT bool do_opens INIT(FALSE);
-EXT bool do_fancy_opens INIT(FALSE);
-EXT bool lval_field INIT(FALSE);
-EXT bool do_chop INIT(FALSE);
-EXT bool need_entire INIT(FALSE);
-EXT bool absmaxfld INIT(FALSE);
-EXT bool saw_altinput INIT(FALSE);
-
-EXT bool nomemok INIT(FALSE);
-
-EXT char const_FS INIT(0);
-EXT char *namelist INIT(Nullch);
-EXT char fswitch INIT(0);
-
-EXT int saw_FS INIT(0);
-EXT int maxfld INIT(0);
-EXT int arymax INIT(0);
-char *nameary[100];
-
-EXT STR *opens;
-
-EXT HASH *symtab;
-EXT HASH *curarghash;
-
-#define P_MIN 0
-#define P_LISTOP 5
-#define P_COMMA 10
-#define P_ASSIGN 15
-#define P_COND 20
-#define P_DOTDOT 25
-#define P_OROR 30
-#define P_ANDAND 35
-#define P_OR 40
-#define P_AND 45
-#define P_EQ 50
-#define P_REL 55
-#define P_UNI 60
-#define P_FILETEST 65
-#define P_SHIFT 70
-#define P_ADD 75
-#define P_MUL 80
-#define P_MATCH 85
-#define P_UNARY 90
-#define P_POW 95
-#define P_AUTO 100
-#define P_MAX 999
diff --git a/gnu/usr.bin/perl/x2p/a2p.y b/gnu/usr.bin/perl/x2p/a2p.y
deleted file mode 100644
index bc86632..0000000
--- a/gnu/usr.bin/perl/x2p/a2p.y
+++ /dev/null
@@ -1,406 +0,0 @@
-%{
-/* $RCSfile: a2p.y,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:09 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: a2p.y,v $
- * Revision 1.1.1.1 1993/08/23 21:30:09 nate
- * PERL!
- *
- * Revision 4.0.1.2 92/06/08 16:13:03 lwall
- * patch20: in a2p, getline should allow variable to be array element
- *
- * Revision 4.0.1.1 91/06/07 12:12:41 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:57:21 lwall
- * 4.0 baseline.
- *
- */
-
-#include "INTERN.h"
-#include "a2p.h"
-
-int root;
-int begins = Nullop;
-int ends = Nullop;
-
-%}
-%token BEGIN END
-%token REGEX
-%token SEMINEW NEWLINE COMMENT
-%token FUN1 FUNN GRGR
-%token PRINT PRINTF SPRINTF SPLIT
-%token IF ELSE WHILE FOR IN
-%token EXIT NEXT BREAK CONTINUE RET
-%token GETLINE DO SUB GSUB MATCH
-%token FUNCTION USERFUN DELETE
-
-%right ASGNOP
-%right '?' ':'
-%left OROR
-%left ANDAND
-%left IN
-%left NUMBER VAR SUBSTR INDEX
-%left MATCHOP
-%left RELOP '<' '>'
-%left OR
-%left STRING
-%left '+' '-'
-%left '*' '/' '%'
-%right UMINUS
-%left NOT
-%right '^'
-%left INCR DECR
-%left FIELD VFIELD
-
-%%
-
-program : junk hunks
- { root = oper4(OPROG,$1,begins,$2,ends); }
- ;
-
-begin : BEGIN '{' maybe states '}' junk
- { begins = oper4(OJUNK,begins,$3,$4,$6); in_begin = FALSE;
- $$ = Nullop; }
- ;
-
-end : END '{' maybe states '}'
- { ends = oper3(OJUNK,ends,$3,$4); $$ = Nullop; }
- | end NEWLINE
- { $$ = $1; }
- ;
-
-hunks : hunks hunk junk
- { $$ = oper3(OHUNKS,$1,$2,$3); }
- | /* NULL */
- { $$ = Nullop; }
- ;
-
-hunk : patpat
- { $$ = oper1(OHUNK,$1); need_entire = TRUE; }
- | patpat '{' maybe states '}'
- { $$ = oper2(OHUNK,$1,oper2(OJUNK,$3,$4)); }
- | FUNCTION USERFUN '(' arg_list ')' maybe '{' maybe states '}'
- { fixfargs($2,$4,0); $$ = oper5(OUSERDEF,$2,$4,$6,$8,$9); }
- | '{' maybe states '}'
- { $$ = oper2(OHUNK,Nullop,oper2(OJUNK,$2,$3)); }
- | begin
- | end
- ;
-
-arg_list: expr_list
- { $$ = rememberargs($$); }
- ;
-
-patpat : cond
- { $$ = oper1(OPAT,$1); }
- | cond ',' cond
- { $$ = oper2(ORANGE,$1,$3); }
- ;
-
-cond : expr
- | match
- | rel
- | compound_cond
- ;
-
-compound_cond
- : '(' compound_cond ')'
- { $$ = oper1(OCPAREN,$2); }
- | cond ANDAND maybe cond
- { $$ = oper3(OCANDAND,$1,$3,$4); }
- | cond OROR maybe cond
- { $$ = oper3(OCOROR,$1,$3,$4); }
- | NOT cond
- { $$ = oper1(OCNOT,$2); }
- ;
-
-rel : expr RELOP expr
- { $$ = oper3(ORELOP,$2,$1,$3); }
- | expr '>' expr
- { $$ = oper3(ORELOP,string(">",1),$1,$3); }
- | expr '<' expr
- { $$ = oper3(ORELOP,string("<",1),$1,$3); }
- | '(' rel ')'
- { $$ = oper1(ORPAREN,$2); }
- ;
-
-match : expr MATCHOP expr
- { $$ = oper3(OMATCHOP,$2,$1,$3); }
- | expr MATCHOP REGEX
- { $$ = oper3(OMATCHOP,$2,$1,oper1(OREGEX,$3)); }
- | REGEX %prec MATCHOP
- { $$ = oper1(OREGEX,$1); }
- | '(' match ')'
- { $$ = oper1(OMPAREN,$2); }
- ;
-
-expr : term
- { $$ = $1; }
- | expr term
- { $$ = oper2(OCONCAT,$1,$2); }
- | variable ASGNOP cond
- { $$ = oper3(OASSIGN,$2,$1,$3);
- if ((ops[$1].ival & 255) == OFLD)
- lval_field = TRUE;
- if ((ops[$1].ival & 255) == OVFLD)
- lval_field = TRUE;
- }
- ;
-
-term : variable
- { $$ = $1; }
- | NUMBER
- { $$ = oper1(ONUM,$1); }
- | STRING
- { $$ = oper1(OSTR,$1); }
- | term '+' term
- { $$ = oper2(OADD,$1,$3); }
- | term '-' term
- { $$ = oper2(OSUBTRACT,$1,$3); }
- | term '*' term
- { $$ = oper2(OMULT,$1,$3); }
- | term '/' term
- { $$ = oper2(ODIV,$1,$3); }
- | term '%' term
- { $$ = oper2(OMOD,$1,$3); }
- | term '^' term
- { $$ = oper2(OPOW,$1,$3); }
- | term IN VAR
- { $$ = oper2(ODEFINED,aryrefarg($3),$1); }
- | term '?' term ':' term
- { $$ = oper3(OCOND,$1,$3,$5); }
- | variable INCR
- { $$ = oper1(OPOSTINCR,$1); }
- | variable DECR
- { $$ = oper1(OPOSTDECR,$1); }
- | INCR variable
- { $$ = oper1(OPREINCR,$2); }
- | DECR variable
- { $$ = oper1(OPREDECR,$2); }
- | '-' term %prec UMINUS
- { $$ = oper1(OUMINUS,$2); }
- | '+' term %prec UMINUS
- { $$ = oper1(OUPLUS,$2); }
- | '(' cond ')'
- { $$ = oper1(OPAREN,$2); }
- | GETLINE
- { $$ = oper0(OGETLINE); }
- | GETLINE variable
- { $$ = oper1(OGETLINE,$2); }
- | GETLINE '<' expr
- { $$ = oper3(OGETLINE,Nullop,string("<",1),$3);
- if (ops[$3].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; }
- | GETLINE variable '<' expr
- { $$ = oper3(OGETLINE,$2,string("<",1),$4);
- if (ops[$4].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; }
- | term 'p' GETLINE
- { $$ = oper3(OGETLINE,Nullop,string("|",1),$1);
- if (ops[$1].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; }
- | term 'p' GETLINE variable
- { $$ = oper3(OGETLINE,$4,string("|",1),$1);
- if (ops[$1].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; }
- | FUN1
- { $$ = oper0($1); need_entire = do_chop = TRUE; }
- | FUN1 '(' ')'
- { $$ = oper1($1,Nullop); need_entire = do_chop = TRUE; }
- | FUN1 '(' expr ')'
- { $$ = oper1($1,$3); }
- | FUNN '(' expr_list ')'
- { $$ = oper1($1,$3); }
- | USERFUN '(' expr_list ')'
- { $$ = oper2(OUSERFUN,$1,$3); }
- | SPRINTF expr_list
- { $$ = oper1(OSPRINTF,$2); }
- | SUBSTR '(' expr ',' expr ',' expr ')'
- { $$ = oper3(OSUBSTR,$3,$5,$7); }
- | SUBSTR '(' expr ',' expr ')'
- { $$ = oper2(OSUBSTR,$3,$5); }
- | SPLIT '(' expr ',' VAR ',' expr ')'
- { $$ = oper3(OSPLIT,$3,aryrefarg(numary($5)),$7); }
- | SPLIT '(' expr ',' VAR ',' REGEX ')'
- { $$ = oper3(OSPLIT,$3,aryrefarg(numary($5)),oper1(OREGEX,$7));}
- | SPLIT '(' expr ',' VAR ')'
- { $$ = oper2(OSPLIT,$3,aryrefarg(numary($5))); }
- | INDEX '(' expr ',' expr ')'
- { $$ = oper2(OINDEX,$3,$5); }
- | MATCH '(' expr ',' REGEX ')'
- { $$ = oper2(OMATCH,$3,oper1(OREGEX,$5)); }
- | MATCH '(' expr ',' expr ')'
- { $$ = oper2(OMATCH,$3,$5); }
- | SUB '(' expr ',' expr ')'
- { $$ = oper2(OSUB,$3,$5); }
- | SUB '(' REGEX ',' expr ')'
- { $$ = oper2(OSUB,oper1(OREGEX,$3),$5); }
- | GSUB '(' expr ',' expr ')'
- { $$ = oper2(OGSUB,$3,$5); }
- | GSUB '(' REGEX ',' expr ')'
- { $$ = oper2(OGSUB,oper1(OREGEX,$3),$5); }
- | SUB '(' expr ',' expr ',' expr ')'
- { $$ = oper3(OSUB,$3,$5,$7); }
- | SUB '(' REGEX ',' expr ',' expr ')'
- { $$ = oper3(OSUB,oper1(OREGEX,$3),$5,$7); }
- | GSUB '(' expr ',' expr ',' expr ')'
- { $$ = oper3(OGSUB,$3,$5,$7); }
- | GSUB '(' REGEX ',' expr ',' expr ')'
- { $$ = oper3(OGSUB,oper1(OREGEX,$3),$5,$7); }
- ;
-
-variable: VAR
- { $$ = oper1(OVAR,$1); }
- | VAR '[' expr_list ']'
- { $$ = oper2(OVAR,aryrefarg($1),$3); }
- | FIELD
- { $$ = oper1(OFLD,$1); }
- | VFIELD term
- { $$ = oper1(OVFLD,$2); }
- ;
-
-expr_list
- : expr
- | clist
- | /* NULL */
- { $$ = Nullop; }
- ;
-
-clist : expr ',' maybe expr
- { $$ = oper3(OCOMMA,$1,$3,$4); }
- | clist ',' maybe expr
- { $$ = oper3(OCOMMA,$1,$3,$4); }
- | '(' clist ')' /* these parens are invisible */
- { $$ = $2; }
- ;
-
-junk : junk hunksep
- { $$ = oper2(OJUNK,$1,$2); }
- | /* NULL */
- { $$ = Nullop; }
- ;
-
-hunksep : ';'
- { $$ = oper2(OJUNK,oper0(OSEMICOLON),oper0(ONEWLINE)); }
- | SEMINEW
- { $$ = oper2(OJUNK,oper0(OSEMICOLON),oper0(ONEWLINE)); }
- | NEWLINE
- { $$ = oper0(ONEWLINE); }
- | COMMENT
- { $$ = oper1(OCOMMENT,$1); }
- ;
-
-maybe : maybe nlstuff
- { $$ = oper2(OJUNK,$1,$2); }
- | /* NULL */
- { $$ = Nullop; }
- ;
-
-nlstuff : NEWLINE
- { $$ = oper0(ONEWLINE); }
- | COMMENT
- { $$ = oper1(OCOMMENT,$1); }
- ;
-
-separator
- : ';' maybe
- { $$ = oper2(OJUNK,oper0(OSEMICOLON),$2); }
- | SEMINEW maybe
- { $$ = oper2(OJUNK,oper0(OSNEWLINE),$2); }
- | NEWLINE maybe
- { $$ = oper2(OJUNK,oper0(OSNEWLINE),$2); }
- | COMMENT maybe
- { $$ = oper2(OJUNK,oper1(OSCOMMENT,$1),$2); }
- ;
-
-states : states statement
- { $$ = oper2(OSTATES,$1,$2); }
- | /* NULL */
- { $$ = Nullop; }
- ;
-
-statement
- : simple separator maybe
- { $$ = oper2(OJUNK,oper2(OSTATE,$1,$2),$3); }
- | ';' maybe
- { $$ = oper2(OSTATE,Nullop,oper2(OJUNK,oper0(OSEMICOLON),$2)); }
- | SEMINEW maybe
- { $$ = oper2(OSTATE,Nullop,oper2(OJUNK,oper0(OSNEWLINE),$2)); }
- | compound
- ;
-
-simpnull: simple
- | /* NULL */
- { $$ = Nullop; }
- ;
-
-simple
- : expr
- | PRINT expr_list redir expr
- { $$ = oper3(OPRINT,$2,$3,$4);
- do_opens = TRUE;
- saw_ORS = saw_OFS = TRUE;
- if (!$2) need_entire = TRUE;
- if (ops[$4].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; }
- | PRINT expr_list
- { $$ = oper1(OPRINT,$2);
- if (!$2) need_entire = TRUE;
- saw_ORS = saw_OFS = TRUE;
- }
- | PRINTF expr_list redir expr
- { $$ = oper3(OPRINTF,$2,$3,$4);
- do_opens = TRUE;
- if (!$2) need_entire = TRUE;
- if (ops[$4].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; }
- | PRINTF expr_list
- { $$ = oper1(OPRINTF,$2);
- if (!$2) need_entire = TRUE;
- }
- | BREAK
- { $$ = oper0(OBREAK); }
- | NEXT
- { $$ = oper0(ONEXT); }
- | EXIT
- { $$ = oper0(OEXIT); }
- | EXIT expr
- { $$ = oper1(OEXIT,$2); }
- | CONTINUE
- { $$ = oper0(OCONTINUE); }
- | RET
- { $$ = oper0(ORETURN); }
- | RET expr
- { $$ = oper1(ORETURN,$2); }
- | DELETE VAR '[' expr ']'
- { $$ = oper2(ODELETE,aryrefarg($2),$4); }
- ;
-
-redir : '>' %prec FIELD
- { $$ = oper1(OREDIR,string(">",1)); }
- | GRGR
- { $$ = oper1(OREDIR,string(">>",2)); }
- | '|'
- { $$ = oper1(OREDIR,string("|",1)); }
- ;
-
-compound
- : IF '(' cond ')' maybe statement
- { $$ = oper2(OIF,$3,bl($6,$5)); }
- | IF '(' cond ')' maybe statement ELSE maybe statement
- { $$ = oper3(OIF,$3,bl($6,$5),bl($9,$8)); }
- | WHILE '(' cond ')' maybe statement
- { $$ = oper2(OWHILE,$3,bl($6,$5)); }
- | DO maybe statement WHILE '(' cond ')'
- { $$ = oper2(ODO,bl($3,$2),$6); }
- | FOR '(' simpnull ';' cond ';' simpnull ')' maybe statement
- { $$ = oper4(OFOR,$3,$5,$7,bl($10,$9)); }
- | FOR '(' simpnull ';' ';' simpnull ')' maybe statement
- { $$ = oper4(OFOR,$3,string("",0),$6,bl($9,$8)); }
- | FOR '(' expr ')' maybe statement
- { $$ = oper2(OFORIN,$3,bl($6,$5)); }
- | '{' maybe states '}' maybe
- { $$ = oper3(OBLOCK,oper2(OJUNK,$2,$3),Nullop,$5); }
- ;
-
-%%
-#include "a2py.c"
diff --git a/gnu/usr.bin/perl/x2p/a2py.c b/gnu/usr.bin/perl/x2p/a2py.c
deleted file mode 100644
index fcc196b..0000000
--- a/gnu/usr.bin/perl/x2p/a2py.c
+++ /dev/null
@@ -1,1304 +0,0 @@
-/* $RCSfile: a2py.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:53 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: a2py.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:53 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:10 nate
- * PERL!
- *
- * Revision 4.0.1.2 92/06/08 16:15:16 lwall
- * patch20: in a2p, now warns about spurious backslashes
- * patch20: in a2p, now allows [ to be backslashed in pattern
- * patch20: in a2p, now allows numbers of the form 2.
- *
- * Revision 4.0.1.1 91/06/07 12:12:59 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:57:26 lwall
- * 4.0 baseline.
- *
- */
-
-#ifdef OS2
-#include "../patchlevel.h"
-#endif
-#include "util.h"
-char *index();
-
-char *filename;
-char *myname;
-
-int checkers = 0;
-STR *walk();
-
-#ifdef OS2
-usage()
-{
- printf("\nThis is the AWK to PERL translator, version 4.0, patchlevel %d\n", PATCHLEVEL);
- printf("\nUsage: %s [-D<number>] [-F<char>] [-n<fieldlist>] [-<number>] filename\n", myname);
- printf("\n -D<number> sets debugging flags."
- "\n -F<character> the awk script to translate is always invoked with"
- "\n this -F switch."
- "\n -n<fieldlist> specifies the names of the input fields if input does"
- "\n not have to be split into an array."
- "\n -<number> causes a2p to assume that input will always have that"
- "\n many fields.\n");
- exit(1);
-}
-#endif
-main(argc,argv,env)
-register int argc;
-register char **argv;
-register char **env;
-{
- register STR *str;
- register char *s;
- int i;
- STR *tmpstr;
-
- myname = argv[0];
- linestr = str_new(80);
- str = str_new(0); /* first used for -I flags */
- for (argc--,argv++; argc; argc--,argv++) {
- if (argv[0][0] != '-' || !argv[0][1])
- break;
- reswitch:
- switch (argv[0][1]) {
-#ifdef DEBUGGING
- case 'D':
- debug = atoi(argv[0]+2);
-#ifdef YYDEBUG
- yydebug = (debug & 1);
-#endif
- break;
-#endif
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- maxfld = atoi(argv[0]+1);
- absmaxfld = TRUE;
- break;
- case 'F':
- fswitch = argv[0][2];
- break;
- case 'n':
- namelist = savestr(argv[0]+2);
- break;
- case '-':
- argc--,argv++;
- goto switch_end;
- case 0:
- break;
- default:
- fatal("Unrecognized switch: %s\n",argv[0]);
-#ifdef OS2
- usage();
-#endif
- }
- }
- switch_end:
-
- /* open script */
-
- if (argv[0] == Nullch) {
-#ifdef OS2
- if ( isatty(fileno(stdin)) )
- usage();
-#endif
- argv[0] = "-";
- }
- filename = savestr(argv[0]);
-
- filename = savestr(argv[0]);
- if (strEQ(filename,"-"))
- argv[0] = "";
- if (!*argv[0])
- rsfp = stdin;
- else
- rsfp = fopen(argv[0],"r");
- if (rsfp == Nullfp)
- fatal("Awk script \"%s\" doesn't seem to exist.\n",filename);
-
- /* init tokener */
-
- bufptr = str_get(linestr);
- symtab = hnew();
- curarghash = hnew();
-
- /* now parse the report spec */
-
- if (yyparse())
- fatal("Translation aborted due to syntax errors.\n");
-
-#ifdef DEBUGGING
- if (debug & 2) {
- int type, len;
-
- for (i=1; i<mop;) {
- type = ops[i].ival;
- len = type >> 8;
- type &= 255;
- printf("%d\t%d\t%d\t%-10s",i++,type,len,opname[type]);
- if (type == OSTRING)
- printf("\t\"%s\"\n",ops[i].cval),i++;
- else {
- while (len--) {
- printf("\t%d",ops[i].ival),i++;
- }
- putchar('\n');
- }
- }
- }
- if (debug & 8)
- dump(root);
-#endif
-
- /* first pass to look for numeric variables */
-
- prewalk(0,0,root,&i);
-
- /* second pass to produce new program */
-
- tmpstr = walk(0,0,root,&i,P_MIN);
- str = str_make("#!");
- str_cat(str, BIN);
- str_cat(str, "/perl\neval \"exec ");
- str_cat(str, BIN);
- str_cat(str, "/perl -S $0 $*\"\n\
- if $running_under_some_shell;\n\
- # this emulates #! processing on NIH machines.\n\
- # (remove #! line above if indigestible)\n\n");
- str_cat(str,
- "eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;\n");
- str_cat(str,
- " # process any FOO=bar switches\n\n");
- if (do_opens && opens) {
- str_scat(str,opens);
- str_free(opens);
- str_cat(str,"\n");
- }
- str_scat(str,tmpstr);
- str_free(tmpstr);
-#ifdef DEBUGGING
- if (!(debug & 16))
-#endif
- fixup(str);
- putlines(str);
- if (checkers) {
- fprintf(stderr,
- "Please check my work on the %d line%s I've marked with \"#???\".\n",
- checkers, checkers == 1 ? "" : "s" );
- fprintf(stderr,
- "The operation I've selected may be wrong for the operand types.\n");
- }
- exit(0);
-}
-
-#define RETURN(retval) return (bufptr = s,retval)
-#define XTERM(retval) return (expectterm = TRUE,bufptr = s,retval)
-#define XOP(retval) return (expectterm = FALSE,bufptr = s,retval)
-#define ID(x) return (yylval=string(x,0),expectterm = FALSE,bufptr = s,idtype)
-
-int idtype;
-
-yylex()
-{
- register char *s = bufptr;
- register char *d;
- register int tmp;
-
- retry:
-#ifdef YYDEBUG
- if (yydebug)
- if (index(s,'\n'))
- fprintf(stderr,"Tokener at %s",s);
- else
- fprintf(stderr,"Tokener at %s\n",s);
-#endif
- switch (*s) {
- default:
- fprintf(stderr,
- "Unrecognized character %c in file %s line %d--ignoring.\n",
- *s++,filename,line);
- goto retry;
- case '\\':
- s++;
- if (*s && *s != '\n') {
- yyerror("Ignoring spurious backslash");
- goto retry;
- }
- /*FALLSTHROUGH*/
- case 0:
- s = str_get(linestr);
- *s = '\0';
- if (!rsfp)
- RETURN(0);
- line++;
- if ((s = str_gets(linestr, rsfp)) == Nullch) {
- if (rsfp != stdin)
- fclose(rsfp);
- rsfp = Nullfp;
- s = str_get(linestr);
- RETURN(0);
- }
- goto retry;
- case ' ': case '\t':
- s++;
- goto retry;
- case '\n':
- *s = '\0';
- XTERM(NEWLINE);
- case '#':
- yylval = string(s,0);
- *s = '\0';
- XTERM(COMMENT);
- case ';':
- tmp = *s++;
- if (*s == '\n') {
- s++;
- XTERM(SEMINEW);
- }
- XTERM(tmp);
- case '(':
- tmp = *s++;
- XTERM(tmp);
- case '{':
- case '[':
- case ')':
- case ']':
- case '?':
- case ':':
- tmp = *s++;
- XOP(tmp);
- case 127:
- s++;
- XTERM('}');
- case '}':
- for (d = s + 1; isspace(*d); d++) ;
- if (!*d)
- s = d - 1;
- *s = 127;
- XTERM(';');
- case ',':
- tmp = *s++;
- XTERM(tmp);
- case '~':
- s++;
- yylval = string("~",1);
- XTERM(MATCHOP);
- case '+':
- case '-':
- if (s[1] == *s) {
- s++;
- if (*s++ == '+')
- XTERM(INCR);
- else
- XTERM(DECR);
- }
- /* FALL THROUGH */
- case '*':
- case '%':
- case '^':
- tmp = *s++;
- if (*s == '=') {
- if (tmp == '^')
- yylval = string("**=",3);
- else
- yylval = string(s-1,2);
- s++;
- XTERM(ASGNOP);
- }
- XTERM(tmp);
- case '&':
- s++;
- tmp = *s++;
- if (tmp == '&')
- XTERM(ANDAND);
- s--;
- XTERM('&');
- case '|':
- s++;
- tmp = *s++;
- if (tmp == '|')
- XTERM(OROR);
- s--;
- while (*s == ' ' || *s == '\t')
- s++;
- if (strnEQ(s,"getline",7))
- XTERM('p');
- else
- XTERM('|');
- case '=':
- s++;
- tmp = *s++;
- if (tmp == '=') {
- yylval = string("==",2);
- XTERM(RELOP);
- }
- s--;
- yylval = string("=",1);
- XTERM(ASGNOP);
- case '!':
- s++;
- tmp = *s++;
- if (tmp == '=') {
- yylval = string("!=",2);
- XTERM(RELOP);
- }
- if (tmp == '~') {
- yylval = string("!~",2);
- XTERM(MATCHOP);
- }
- s--;
- XTERM(NOT);
- case '<':
- s++;
- tmp = *s++;
- if (tmp == '=') {
- yylval = string("<=",2);
- XTERM(RELOP);
- }
- s--;
- XTERM('<');
- case '>':
- s++;
- tmp = *s++;
- if (tmp == '>') {
- yylval = string(">>",2);
- XTERM(GRGR);
- }
- if (tmp == '=') {
- yylval = string(">=",2);
- XTERM(RELOP);
- }
- s--;
- XTERM('>');
-
-#define SNARFWORD \
- d = tokenbuf; \
- while (isalpha(*s) || isdigit(*s) || *s == '_') \
- *d++ = *s++; \
- *d = '\0'; \
- d = tokenbuf; \
- if (*s == '(') \
- idtype = USERFUN; \
- else \
- idtype = VAR;
-
- case '$':
- s++;
- if (*s == '0') {
- s++;
- do_chop = TRUE;
- need_entire = TRUE;
- idtype = VAR;
- ID("0");
- }
- do_split = TRUE;
- if (isdigit(*s)) {
- for (d = s; isdigit(*s); s++) ;
- yylval = string(d,s-d);
- tmp = atoi(d);
- if (tmp > maxfld)
- maxfld = tmp;
- XOP(FIELD);
- }
- split_to_array = set_array_base = TRUE;
- XOP(VFIELD);
-
- case '/': /* may either be division or pattern */
- if (expectterm) {
- s = scanpat(s);
- XTERM(REGEX);
- }
- tmp = *s++;
- if (*s == '=') {
- yylval = string("/=",2);
- s++;
- XTERM(ASGNOP);
- }
- XTERM(tmp);
-
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9': case '.':
- s = scannum(s);
- XOP(NUMBER);
- case '"':
- s++;
- s = cpy2(tokenbuf,s,s[-1]);
- if (!*s)
- fatal("String not terminated:\n%s",str_get(linestr));
- s++;
- yylval = string(tokenbuf,0);
- XOP(STRING);
-
- case 'a': case 'A':
- SNARFWORD;
- if (strEQ(d,"ARGC"))
- set_array_base = TRUE;
- if (strEQ(d,"ARGV")) {
- yylval=numary(string("ARGV",0));
- XOP(VAR);
- }
- if (strEQ(d,"atan2")) {
- yylval = OATAN2;
- XTERM(FUNN);
- }
- ID(d);
- case 'b': case 'B':
- SNARFWORD;
- if (strEQ(d,"break"))
- XTERM(BREAK);
- if (strEQ(d,"BEGIN"))
- XTERM(BEGIN);
- ID(d);
- case 'c': case 'C':
- SNARFWORD;
- if (strEQ(d,"continue"))
- XTERM(CONTINUE);
- if (strEQ(d,"cos")) {
- yylval = OCOS;
- XTERM(FUN1);
- }
- if (strEQ(d,"close")) {
- do_fancy_opens = 1;
- yylval = OCLOSE;
- XTERM(FUN1);
- }
- if (strEQ(d,"chdir"))
- *d = toupper(*d);
- else if (strEQ(d,"crypt"))
- *d = toupper(*d);
- else if (strEQ(d,"chop"))
- *d = toupper(*d);
- else if (strEQ(d,"chmod"))
- *d = toupper(*d);
- else if (strEQ(d,"chown"))
- *d = toupper(*d);
- ID(d);
- case 'd': case 'D':
- SNARFWORD;
- if (strEQ(d,"do"))
- XTERM(DO);
- if (strEQ(d,"delete"))
- XTERM(DELETE);
- if (strEQ(d,"die"))
- *d = toupper(*d);
- ID(d);
- case 'e': case 'E':
- SNARFWORD;
- if (strEQ(d,"END"))
- XTERM(END);
- if (strEQ(d,"else"))
- XTERM(ELSE);
- if (strEQ(d,"exit")) {
- saw_line_op = TRUE;
- XTERM(EXIT);
- }
- if (strEQ(d,"exp")) {
- yylval = OEXP;
- XTERM(FUN1);
- }
- if (strEQ(d,"elsif"))
- *d = toupper(*d);
- else if (strEQ(d,"eq"))
- *d = toupper(*d);
- else if (strEQ(d,"eval"))
- *d = toupper(*d);
- else if (strEQ(d,"eof"))
- *d = toupper(*d);
- else if (strEQ(d,"each"))
- *d = toupper(*d);
- else if (strEQ(d,"exec"))
- *d = toupper(*d);
- ID(d);
- case 'f': case 'F':
- SNARFWORD;
- if (strEQ(d,"FS")) {
- saw_FS++;
- if (saw_FS == 1 && in_begin) {
- for (d = s; *d && isspace(*d); d++) ;
- if (*d == '=') {
- for (d++; *d && isspace(*d); d++) ;
- if (*d == '"' && d[2] == '"')
- const_FS = d[1];
- }
- }
- ID(tokenbuf);
- }
- if (strEQ(d,"for"))
- XTERM(FOR);
- else if (strEQ(d,"function"))
- XTERM(FUNCTION);
- if (strEQ(d,"FILENAME"))
- d = "ARGV";
- if (strEQ(d,"foreach"))
- *d = toupper(*d);
- else if (strEQ(d,"format"))
- *d = toupper(*d);
- else if (strEQ(d,"fork"))
- *d = toupper(*d);
- else if (strEQ(d,"fh"))
- *d = toupper(*d);
- ID(d);
- case 'g': case 'G':
- SNARFWORD;
- if (strEQ(d,"getline"))
- XTERM(GETLINE);
- if (strEQ(d,"gsub"))
- XTERM(GSUB);
- if (strEQ(d,"ge"))
- *d = toupper(*d);
- else if (strEQ(d,"gt"))
- *d = toupper(*d);
- else if (strEQ(d,"goto"))
- *d = toupper(*d);
- else if (strEQ(d,"gmtime"))
- *d = toupper(*d);
- ID(d);
- case 'h': case 'H':
- SNARFWORD;
- if (strEQ(d,"hex"))
- *d = toupper(*d);
- ID(d);
- case 'i': case 'I':
- SNARFWORD;
- if (strEQ(d,"if"))
- XTERM(IF);
- if (strEQ(d,"in"))
- XTERM(IN);
- if (strEQ(d,"index")) {
- set_array_base = TRUE;
- XTERM(INDEX);
- }
- if (strEQ(d,"int")) {
- yylval = OINT;
- XTERM(FUN1);
- }
- ID(d);
- case 'j': case 'J':
- SNARFWORD;
- if (strEQ(d,"join"))
- *d = toupper(*d);
- ID(d);
- case 'k': case 'K':
- SNARFWORD;
- if (strEQ(d,"keys"))
- *d = toupper(*d);
- else if (strEQ(d,"kill"))
- *d = toupper(*d);
- ID(d);
- case 'l': case 'L':
- SNARFWORD;
- if (strEQ(d,"length")) {
- yylval = OLENGTH;
- XTERM(FUN1);
- }
- if (strEQ(d,"log")) {
- yylval = OLOG;
- XTERM(FUN1);
- }
- if (strEQ(d,"last"))
- *d = toupper(*d);
- else if (strEQ(d,"local"))
- *d = toupper(*d);
- else if (strEQ(d,"lt"))
- *d = toupper(*d);
- else if (strEQ(d,"le"))
- *d = toupper(*d);
- else if (strEQ(d,"locatime"))
- *d = toupper(*d);
- else if (strEQ(d,"link"))
- *d = toupper(*d);
- ID(d);
- case 'm': case 'M':
- SNARFWORD;
- if (strEQ(d,"match")) {
- set_array_base = TRUE;
- XTERM(MATCH);
- }
- if (strEQ(d,"m"))
- *d = toupper(*d);
- ID(d);
- case 'n': case 'N':
- SNARFWORD;
- if (strEQ(d,"NF"))
- do_chop = do_split = split_to_array = set_array_base = TRUE;
- if (strEQ(d,"next")) {
- saw_line_op = TRUE;
- XTERM(NEXT);
- }
- if (strEQ(d,"ne"))
- *d = toupper(*d);
- ID(d);
- case 'o': case 'O':
- SNARFWORD;
- if (strEQ(d,"ORS")) {
- saw_ORS = TRUE;
- d = "\\";
- }
- if (strEQ(d,"OFS")) {
- saw_OFS = TRUE;
- d = ",";
- }
- if (strEQ(d,"OFMT")) {
- d = "#";
- }
- if (strEQ(d,"open"))
- *d = toupper(*d);
- else if (strEQ(d,"ord"))
- *d = toupper(*d);
- else if (strEQ(d,"oct"))
- *d = toupper(*d);
- ID(d);
- case 'p': case 'P':
- SNARFWORD;
- if (strEQ(d,"print")) {
- XTERM(PRINT);
- }
- if (strEQ(d,"printf")) {
- XTERM(PRINTF);
- }
- if (strEQ(d,"push"))
- *d = toupper(*d);
- else if (strEQ(d,"pop"))
- *d = toupper(*d);
- ID(d);
- case 'q': case 'Q':
- SNARFWORD;
- ID(d);
- case 'r': case 'R':
- SNARFWORD;
- if (strEQ(d,"RS")) {
- d = "/";
- saw_RS = TRUE;
- }
- if (strEQ(d,"rand")) {
- yylval = ORAND;
- XTERM(FUN1);
- }
- if (strEQ(d,"return"))
- XTERM(RET);
- if (strEQ(d,"reset"))
- *d = toupper(*d);
- else if (strEQ(d,"redo"))
- *d = toupper(*d);
- else if (strEQ(d,"rename"))
- *d = toupper(*d);
- ID(d);
- case 's': case 'S':
- SNARFWORD;
- if (strEQ(d,"split")) {
- set_array_base = TRUE;
- XOP(SPLIT);
- }
- if (strEQ(d,"substr")) {
- set_array_base = TRUE;
- XTERM(SUBSTR);
- }
- if (strEQ(d,"sub"))
- XTERM(SUB);
- if (strEQ(d,"sprintf"))
- XTERM(SPRINTF);
- if (strEQ(d,"sqrt")) {
- yylval = OSQRT;
- XTERM(FUN1);
- }
- if (strEQ(d,"SUBSEP")) {
- d = ";";
- }
- if (strEQ(d,"sin")) {
- yylval = OSIN;
- XTERM(FUN1);
- }
- if (strEQ(d,"srand")) {
- yylval = OSRAND;
- XTERM(FUN1);
- }
- if (strEQ(d,"system")) {
- yylval = OSYSTEM;
- XTERM(FUN1);
- }
- if (strEQ(d,"s"))
- *d = toupper(*d);
- else if (strEQ(d,"shift"))
- *d = toupper(*d);
- else if (strEQ(d,"select"))
- *d = toupper(*d);
- else if (strEQ(d,"seek"))
- *d = toupper(*d);
- else if (strEQ(d,"stat"))
- *d = toupper(*d);
- else if (strEQ(d,"study"))
- *d = toupper(*d);
- else if (strEQ(d,"sleep"))
- *d = toupper(*d);
- else if (strEQ(d,"symlink"))
- *d = toupper(*d);
- else if (strEQ(d,"sort"))
- *d = toupper(*d);
- ID(d);
- case 't': case 'T':
- SNARFWORD;
- if (strEQ(d,"tr"))
- *d = toupper(*d);
- else if (strEQ(d,"tell"))
- *d = toupper(*d);
- else if (strEQ(d,"time"))
- *d = toupper(*d);
- else if (strEQ(d,"times"))
- *d = toupper(*d);
- ID(d);
- case 'u': case 'U':
- SNARFWORD;
- if (strEQ(d,"until"))
- *d = toupper(*d);
- else if (strEQ(d,"unless"))
- *d = toupper(*d);
- else if (strEQ(d,"umask"))
- *d = toupper(*d);
- else if (strEQ(d,"unshift"))
- *d = toupper(*d);
- else if (strEQ(d,"unlink"))
- *d = toupper(*d);
- else if (strEQ(d,"utime"))
- *d = toupper(*d);
- ID(d);
- case 'v': case 'V':
- SNARFWORD;
- if (strEQ(d,"values"))
- *d = toupper(*d);
- ID(d);
- case 'w': case 'W':
- SNARFWORD;
- if (strEQ(d,"while"))
- XTERM(WHILE);
- if (strEQ(d,"write"))
- *d = toupper(*d);
- else if (strEQ(d,"wait"))
- *d = toupper(*d);
- ID(d);
- case 'x': case 'X':
- SNARFWORD;
- if (strEQ(d,"x"))
- *d = toupper(*d);
- ID(d);
- case 'y': case 'Y':
- SNARFWORD;
- if (strEQ(d,"y"))
- *d = toupper(*d);
- ID(d);
- case 'z': case 'Z':
- SNARFWORD;
- ID(d);
- }
-}
-
-char *
-scanpat(s)
-register char *s;
-{
- register char *d;
-
- switch (*s++) {
- case '/':
- break;
- default:
- fatal("Search pattern not found:\n%s",str_get(linestr));
- }
-
- d = tokenbuf;
- for (; *s; s++,d++) {
- if (*s == '\\') {
- if (s[1] == '/')
- *d++ = *s++;
- else if (s[1] == '\\')
- *d++ = *s++;
- else if (s[1] == '[')
- *d++ = *s++;
- }
- else if (*s == '[') {
- *d++ = *s++;
- do {
- if (*s == '\\' && s[1])
- *d++ = *s++;
- if (*s == '/' || (*s == '-' && s[1] == ']'))
- *d++ = '\\';
- *d++ = *s++;
- } while (*s && *s != ']');
- }
- else if (*s == '/')
- break;
- *d = *s;
- }
- *d = '\0';
-
- if (!*s)
- fatal("Search pattern not terminated:\n%s",str_get(linestr));
- s++;
- yylval = string(tokenbuf,0);
- return s;
-}
-
-yyerror(s)
-char *s;
-{
- fprintf(stderr,"%s in file %s at line %d\n",
- s,filename,line);
-}
-
-char *
-scannum(s)
-register char *s;
-{
- register char *d;
-
- switch (*s) {
- case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9': case '0' : case '.':
- d = tokenbuf;
- while (isdigit(*s)) {
- *d++ = *s++;
- }
- if (*s == '.') {
- if (isdigit(s[1])) {
- *d++ = *s++;
- while (isdigit(*s)) {
- *d++ = *s++;
- }
- }
- else
- s++;
- }
- if (index("eE",*s) && index("+-0123456789",s[1])) {
- *d++ = *s++;
- if (*s == '+' || *s == '-')
- *d++ = *s++;
- while (isdigit(*s))
- *d++ = *s++;
- }
- *d = '\0';
- yylval = string(tokenbuf,0);
- break;
- }
- return s;
-}
-
-string(ptr,len)
-char *ptr;
-{
- int retval = mop;
-
- ops[mop++].ival = OSTRING + (1<<8);
- if (!len)
- len = strlen(ptr);
- ops[mop].cval = safemalloc(len+1);
- strncpy(ops[mop].cval,ptr,len);
- ops[mop++].cval[len] = '\0';
- if (mop >= OPSMAX)
- fatal("Recompile a2p with larger OPSMAX\n");
- return retval;
-}
-
-oper0(type)
-int type;
-{
- int retval = mop;
-
- if (type > 255)
- fatal("type > 255 (%d)\n",type);
- ops[mop++].ival = type;
- if (mop >= OPSMAX)
- fatal("Recompile a2p with larger OPSMAX\n");
- return retval;
-}
-
-oper1(type,arg1)
-int type;
-int arg1;
-{
- int retval = mop;
-
- if (type > 255)
- fatal("type > 255 (%d)\n",type);
- ops[mop++].ival = type + (1<<8);
- ops[mop++].ival = arg1;
- if (mop >= OPSMAX)
- fatal("Recompile a2p with larger OPSMAX\n");
- return retval;
-}
-
-oper2(type,arg1,arg2)
-int type;
-int arg1;
-int arg2;
-{
- int retval = mop;
-
- if (type > 255)
- fatal("type > 255 (%d)\n",type);
- ops[mop++].ival = type + (2<<8);
- ops[mop++].ival = arg1;
- ops[mop++].ival = arg2;
- if (mop >= OPSMAX)
- fatal("Recompile a2p with larger OPSMAX\n");
- return retval;
-}
-
-oper3(type,arg1,arg2,arg3)
-int type;
-int arg1;
-int arg2;
-int arg3;
-{
- int retval = mop;
-
- if (type > 255)
- fatal("type > 255 (%d)\n",type);
- ops[mop++].ival = type + (3<<8);
- ops[mop++].ival = arg1;
- ops[mop++].ival = arg2;
- ops[mop++].ival = arg3;
- if (mop >= OPSMAX)
- fatal("Recompile a2p with larger OPSMAX\n");
- return retval;
-}
-
-oper4(type,arg1,arg2,arg3,arg4)
-int type;
-int arg1;
-int arg2;
-int arg3;
-int arg4;
-{
- int retval = mop;
-
- if (type > 255)
- fatal("type > 255 (%d)\n",type);
- ops[mop++].ival = type + (4<<8);
- ops[mop++].ival = arg1;
- ops[mop++].ival = arg2;
- ops[mop++].ival = arg3;
- ops[mop++].ival = arg4;
- if (mop >= OPSMAX)
- fatal("Recompile a2p with larger OPSMAX\n");
- return retval;
-}
-
-oper5(type,arg1,arg2,arg3,arg4,arg5)
-int type;
-int arg1;
-int arg2;
-int arg3;
-int arg4;
-int arg5;
-{
- int retval = mop;
-
- if (type > 255)
- fatal("type > 255 (%d)\n",type);
- ops[mop++].ival = type + (5<<8);
- ops[mop++].ival = arg1;
- ops[mop++].ival = arg2;
- ops[mop++].ival = arg3;
- ops[mop++].ival = arg4;
- ops[mop++].ival = arg5;
- if (mop >= OPSMAX)
- fatal("Recompile a2p with larger OPSMAX\n");
- return retval;
-}
-
-int depth = 0;
-
-dump(branch)
-int branch;
-{
- register int type;
- register int len;
- register int i;
-
- type = ops[branch].ival;
- len = type >> 8;
- type &= 255;
- for (i=depth; i; i--)
- printf(" ");
- if (type == OSTRING) {
- printf("%-5d\"%s\"\n",branch,ops[branch+1].cval);
- }
- else {
- printf("(%-5d%s %d\n",branch,opname[type],len);
- depth++;
- for (i=1; i<=len; i++)
- dump(ops[branch+i].ival);
- depth--;
- for (i=depth; i; i--)
- printf(" ");
- printf(")\n");
- }
-}
-
-bl(arg,maybe)
-int arg;
-int maybe;
-{
- if (!arg)
- return 0;
- else if ((ops[arg].ival & 255) != OBLOCK)
- return oper2(OBLOCK,arg,maybe);
- else if ((ops[arg].ival >> 8) < 2)
- return oper2(OBLOCK,ops[arg+1].ival,maybe);
- else
- return arg;
-}
-
-fixup(str)
-STR *str;
-{
- register char *s;
- register char *t;
-
- for (s = str->str_ptr; *s; s++) {
- if (*s == ';' && s[1] == ' ' && s[2] == '\n') {
- strcpy(s+1,s+2);
- s++;
- }
- else if (*s == '\n') {
- for (t = s+1; isspace(*t & 127); t++) ;
- t--;
- while (isspace(*t & 127) && *t != '\n') t--;
- if (*t == '\n' && t-s > 1) {
- if (s[-1] == '{')
- s--;
- strcpy(s+1,t);
- }
- s++;
- }
- }
-}
-
-putlines(str)
-STR *str;
-{
- register char *d, *s, *t, *e;
- register int pos, newpos;
-
- d = tokenbuf;
- pos = 0;
- for (s = str->str_ptr; *s; s++) {
- *d++ = *s;
- pos++;
- if (*s == '\n') {
- *d = '\0';
- d = tokenbuf;
- pos = 0;
- putone();
- }
- else if (*s == '\t')
- pos += 7;
- if (pos > 78) { /* split a long line? */
- *d-- = '\0';
- newpos = 0;
- for (t = tokenbuf; isspace(*t & 127); t++) {
- if (*t == '\t')
- newpos += 8;
- else
- newpos += 1;
- }
- e = d;
- while (d > tokenbuf && (*d != ' ' || d[-1] != ';'))
- d--;
- if (d < t+10) {
- d = e;
- while (d > tokenbuf &&
- (*d != ' ' || d[-1] != '|' || d[-2] != '|') )
- d--;
- }
- if (d < t+10) {
- d = e;
- while (d > tokenbuf &&
- (*d != ' ' || d[-1] != '&' || d[-2] != '&') )
- d--;
- }
- if (d < t+10) {
- d = e;
- while (d > tokenbuf && (*d != ' ' || d[-1] != ','))
- d--;
- }
- if (d < t+10) {
- d = e;
- while (d > tokenbuf && *d != ' ')
- d--;
- }
- if (d > t+3) {
- char save[2048];
- strcpy(save, d);
- *d = '\n';
- d[1] = '\0';
- putone();
- putchar('\n');
- if (d[-1] != ';' && !(newpos % 4)) {
- *t++ = ' ';
- *t++ = ' ';
- newpos += 2;
- }
- strcpy(t,save+1);
- newpos += strlen(t);
- d = t + strlen(t);
- pos = newpos;
- }
- else
- d = e + 1;
- }
- }
-}
-
-putone()
-{
- register char *t;
-
- for (t = tokenbuf; *t; t++) {
- *t &= 127;
- if (*t == 127) {
- *t = ' ';
- strcpy(t+strlen(t)-1, "\t#???\n");
- checkers++;
- }
- }
- t = tokenbuf;
- if (*t == '#') {
- if (strnEQ(t,"#!/bin/awk",10) || strnEQ(t,"#! /bin/awk",11))
- return;
- if (strnEQ(t,"#!/usr/bin/awk",14) || strnEQ(t,"#! /usr/bin/awk",15))
- return;
- }
- fputs(tokenbuf,stdout);
-}
-
-numary(arg)
-int arg;
-{
- STR *key;
- int dummy;
-
- key = walk(0,0,arg,&dummy,P_MIN);
- str_cat(key,"[]");
- hstore(symtab,key->str_ptr,str_make("1"));
- str_free(key);
- set_array_base = TRUE;
- return arg;
-}
-
-rememberargs(arg)
-int arg;
-{
- int type;
- STR *str;
-
- if (!arg)
- return arg;
- type = ops[arg].ival & 255;
- if (type == OCOMMA) {
- rememberargs(ops[arg+1].ival);
- rememberargs(ops[arg+3].ival);
- }
- else if (type == OVAR) {
- str = str_new(0);
- hstore(curarghash,ops[ops[arg+1].ival+1].cval,str);
- }
- else
- fatal("panic: unknown argument type %d, line %d\n",type,line);
- return arg;
-}
-
-aryrefarg(arg)
-int arg;
-{
- int type = ops[arg].ival & 255;
- STR *str;
-
- if (type != OSTRING)
- fatal("panic: aryrefarg %d, line %d\n",type,line);
- str = hfetch(curarghash,ops[arg+1].cval);
- if (str)
- str_set(str,"*");
- return arg;
-}
-
-fixfargs(name,arg,prevargs)
-int name;
-int arg;
-int prevargs;
-{
- int type;
- STR *str;
- int numargs;
-
- if (!arg)
- return prevargs;
- type = ops[arg].ival & 255;
- if (type == OCOMMA) {
- numargs = fixfargs(name,ops[arg+1].ival,prevargs);
- numargs = fixfargs(name,ops[arg+3].ival,numargs);
- }
- else if (type == OVAR) {
- str = hfetch(curarghash,ops[ops[arg+1].ival+1].cval);
- if (strEQ(str_get(str),"*")) {
- char tmpbuf[128];
-
- str_set(str,""); /* in case another routine has this */
- ops[arg].ival &= ~255;
- ops[arg].ival |= OSTAR;
- sprintf(tmpbuf,"%s:%d",ops[name+1].cval,prevargs);
- fprintf(stderr,"Adding %s\n",tmpbuf);
- str = str_new(0);
- str_set(str,"*");
- hstore(curarghash,tmpbuf,str);
- }
- numargs = prevargs + 1;
- }
- else
- fatal("panic: unknown argument type %d, arg %d, line %d\n",
- type,prevargs+1,line);
- return numargs;
-}
-
-fixrargs(name,arg,prevargs)
-char *name;
-int arg;
-int prevargs;
-{
- int type;
- STR *str;
- int numargs;
-
- if (!arg)
- return prevargs;
- type = ops[arg].ival & 255;
- if (type == OCOMMA) {
- numargs = fixrargs(name,ops[arg+1].ival,prevargs);
- numargs = fixrargs(name,ops[arg+3].ival,numargs);
- }
- else {
- char tmpbuf[128];
-
- sprintf(tmpbuf,"%s:%d",name,prevargs);
- str = hfetch(curarghash,tmpbuf);
- if (str && strEQ(str->str_ptr,"*")) {
- if (type == OVAR || type == OSTAR) {
- ops[arg].ival &= ~255;
- ops[arg].ival |= OSTAR;
- }
- else
- fatal("Can't pass expression by reference as arg %d of %s\n",
- prevargs+1, name);
- }
- numargs = prevargs + 1;
- }
- return numargs;
-}
-
diff --git a/gnu/usr.bin/perl/x2p/find2perl b/gnu/usr.bin/perl/x2p/find2perl
deleted file mode 100755
index fd74c3f..0000000
--- a/gnu/usr.bin/perl/x2p/find2perl
+++ /dev/null
@@ -1,568 +0,0 @@
-#!/usr/bin/perl
-
-eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
- if $running_under_some_shell;
-
-$bin = "/usr/bin";
-
-
-while ($ARGV[0] =~ /^[^-!(]/) {
- push(@roots, shift);
-}
-@roots = ('.') unless @roots;
-for (@roots) { $_ = &quote($_); }
-$roots = join(',', @roots);
-
-$indent = 1;
-
-while (@ARGV) {
- $_ = shift;
- s/^-// || /^[()!]/ || die "Unrecognized switch: $_\n";
- if ($_ eq '(') {
- $out .= &tab . "(\n";
- $indent++;
- next;
- }
- elsif ($_ eq ')') {
- $indent--;
- $out .= &tab . ")";
- }
- elsif ($_ eq '!') {
- $out .= &tab . "!";
- next;
- }
- elsif ($_ eq 'name') {
- $out .= &tab;
- $pat = &fileglob_to_re(shift);
- $out .= '/' . $pat . "/";
- }
- elsif ($_ eq 'perm') {
- $onum = shift;
- die "Malformed -perm argument: $onum\n" unless $onum =~ /^-?[0-7]+$/;
- if ($onum =~ s/^-//) {
- $onum = '0' . sprintf("%o", oct($onum) & 017777); # s/b 07777 ?
- $out .= &tab . "((\$mode & $onum) == $onum)";
- }
- else {
- $onum = '0' . $onum unless $onum =~ /^0/;
- $out .= &tab . "((\$mode & 0777) == $onum)";
- }
- }
- elsif ($_ eq 'type') {
- ($filetest = shift) =~ tr/s/S/;
- $out .= &tab . "-$filetest _";
- }
- elsif ($_ eq 'print') {
- $out .= &tab . 'print("$name\n")';
- }
- elsif ($_ eq 'print0') {
- $out .= &tab . 'print("$name\0")';
- }
- elsif ($_ eq 'fstype') {
- $out .= &tab;
- $type = shift;
- if ($type eq 'nfs')
- { $out .= '$dev < 0'; }
- else
- { $out .= '$dev >= 0'; }
- }
- elsif ($_ eq 'user') {
- $uname = shift;
- $out .= &tab . "\$uid == \$uid{'$uname'}";
- $inituser++;
- }
- elsif ($_ eq 'group') {
- $gname = shift;
- $out .= &tab . "\$gid == \$gid{'$gname'}";
- $initgroup++;
- }
- elsif ($_ eq 'nouser') {
- $out .= &tab . '!defined $uid{$uid}';
- $inituser++;
- }
- elsif ($_ eq 'nogroup') {
- $out .= &tab . '!defined $gid{$gid}';
- $initgroup++;
- }
- elsif ($_ eq 'links') {
- $out .= &tab . '$nlink ' . &n(shift);
- }
- elsif ($_ eq 'inum') {
- $out .= &tab . '$ino ' . &n(shift);
- }
- elsif ($_ eq 'size') {
- $out .= &tab . 'int((-s _ + 511) / 512) ' . &n(shift);
- }
- elsif ($_ eq 'atime') {
- $out .= &tab . 'int(-A _) ' . &n(shift);
- }
- elsif ($_ eq 'mtime') {
- $out .= &tab . 'int(-M _) ' . &n(shift);
- }
- elsif ($_ eq 'ctime') {
- $out .= &tab . 'int(-C _) ' . &n(shift);
- }
- elsif ($_ eq 'exec') {
- for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { }
- shift;
- $_ = "@cmd";
- if (m#^(/bin/)?rm -f {}$#) {
- if (!@ARGV) {
- $out .= &tab . 'unlink($_)';
- }
- else {
- $out .= &tab . '(unlink($_) || 1)';
- }
- }
- elsif (m#^(/bin/)?rm {}$#) {
- $out .= &tab . '(unlink($_) || warn "$name: $!\n")';
- }
- else {
- for (@cmd) { s/'/\\'/g; }
- $" = "','";
- $out .= &tab . "&exec(0, '@cmd')";
- $" = ' ';
- $initexec++;
- }
- }
- elsif ($_ eq 'ok') {
- for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { }
- shift;
- for (@cmd) { s/'/\\'/g; }
- $" = "','";
- $out .= &tab . "&exec(1, '@cmd')";
- $" = ' ';
- $initexec++;
- }
- elsif ($_ eq 'prune') {
- $out .= &tab . '($prune = 1)';
- }
- elsif ($_ eq 'xdev') {
- $out .= &tab . '(($prune |= ($dev != $topdev)),1)';
- }
- elsif ($_ eq 'newer') {
- $out .= &tab;
- $file = shift;
- $newername = 'AGE_OF' . $file;
- $newername =~ s/[^\w]/_/g;
- $newername = '$' . $newername;
- $out .= "-M _ < $newername";
- $initnewer .= "$newername = -M " . &quote($file) . ";\n";
- }
- elsif ($_ eq 'eval') {
- $prog = &quote(shift);
- $out .= &tab . "eval $prog";
- }
- elsif ($_ eq 'depth') {
- $depth++;
- next;
- }
- elsif ($_ eq 'ls') {
- $out .= &tab . "&ls";
- $initls++;
- }
- elsif ($_ eq 'tar') {
- $out .= &tab;
- die "-tar must have a filename argument\n" unless @ARGV;
- $file = shift;
- $fh = 'FH' . $file;
- $fh =~ s/[^\w]/_/g;
- $out .= "&tar($fh)";
- $file = '>' . $file;
- $initfile .= "open($fh, " . &quote($file) .
- qq{) || die "Can't open $fh: \$!\\n";\n};
- $inittar++;
- $flushall = "\n&tflushall;\n";
- }
- elsif (/^n?cpio$/) {
- $depth++;
- $out .= &tab;
- die "-$_ must have a filename argument\n" unless @ARGV;
- $file = shift;
- $fh = 'FH' . $file;
- $fh =~ s/[^\w]/_/g;
- $out .= "&cpio('" . substr($_,0,1) . "', $fh)";
- $file = '>' . $file;
- $initfile .= "open($fh, " . &quote($file) .
- qq{) || die "Can't open $fh: \$!\\n";\n};
- $initcpio++;
- $flushall = "\n&flushall;\n";
- }
- else {
- die "Unrecognized switch: -$_\n";
- }
- if (@ARGV) {
- if ($ARGV[0] eq '-o') {
- { local($statdone) = 1; $out .= "\n" . &tab . "||\n"; }
- $statdone = 0 if $indent == 1 && $delayedstat;
- $saw_or++;
- shift;
- }
- else {
- $out .= " &&" unless $ARGV[0] eq ')';
- $out .= "\n";
- shift if $ARGV[0] eq '-a';
- }
- }
-}
-
-print <<"END";
-#!$bin/perl
-
-eval 'exec $bin/perl -S \$0 \${1+"\$@"}'
- if \$running_under_some_shell;
-
-END
-
-if ($initls) {
- print <<'END';
-@rwx = ('---','--x','-w-','-wx','r--','r-x','rw-','rwx');
-@moname = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
-
-END
-}
-
-if ($inituser || $initls) {
- print 'while (($name, $pw, $uid) = getpwent) {', "\n";
- print ' $uid{$name} = $uid{$uid} = $uid;', "\n" if $inituser;
- print ' $user{$uid} = $name unless $user{$uid};', "\n" if $initls;
- print "}\n\n";
-}
-
-if ($initgroup || $initls) {
- print 'while (($name, $pw, $gid) = getgrent) {', "\n";
- print ' $gid{$name} = $gid{$gid} = $gid;', "\n" if $initgroup;
- print ' $group{$gid} = $name unless $group{$gid};', "\n" if $initls;
- print "}\n\n";
-}
-
-print $initnewer, "\n" if $initnewer;
-
-print $initfile, "\n" if $initfile;
-
-$find = $depth ? "finddepth" : "find";
-print <<"END";
-require "$find.pl";
-
-# Traverse desired filesystems
-
-&$find($roots);
-$flushall
-exit;
-
-sub wanted {
-$out;
-}
-
-END
-
-if ($initexec) {
- print <<'END';
-sub exec {
- local($ok, @cmd) = @_;
- foreach $word (@cmd) {
- $word =~ s#{}#$name#g;
- }
- if ($ok) {
- local($old) = select(STDOUT);
- $| = 1;
- print "@cmd";
- select($old);
- return 0 unless <STDIN> =~ /^y/;
- }
- chdir $cwd; # sigh
- system @cmd;
- chdir $dir;
- return !$?;
-}
-
-END
-}
-
-if ($initls) {
- print <<'END';
-sub ls {
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizemm,
- $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_);
-
- $pname = $name;
-
- if (defined $blocks) {
- $blocks = int(($blocks + 1) / 2);
- }
- else {
- $blocks = int(($size + 1023) / 1024);
- }
-
- if (-f _) { $perms = '-'; }
- elsif (-d _) { $perms = 'd'; }
- elsif (-c _) { $perms = 'c'; $sizemm = &sizemm; }
- elsif (-b _) { $perms = 'b'; $sizemm = &sizemm; }
- elsif (-p _) { $perms = 'p'; }
- elsif (-S _) { $perms = 's'; }
- else { $perms = 'l'; $pname .= ' -> ' . readlink($_); }
-
- $tmpmode = $mode;
- $tmp = $rwx[$tmpmode & 7];
- $tmpmode >>= 3;
- $tmp = $rwx[$tmpmode & 7] . $tmp;
- $tmpmode >>= 3;
- $tmp = $rwx[$tmpmode & 7] . $tmp;
- substr($tmp,2,1) =~ tr/-x/Ss/ if -u _;
- substr($tmp,5,1) =~ tr/-x/Ss/ if -g _;
- substr($tmp,8,1) =~ tr/-x/Tt/ if -k _;
- $perms .= $tmp;
-
- $user = $user{$uid} || $uid;
- $group = $group{$gid} || $gid;
-
- ($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime);
- $moname = $moname[$mon];
- if (-M _ > 365.25 / 2) {
- $timeyear = '19' . $year;
- }
- else {
- $timeyear = sprintf("%02d:%02d", $hour, $min);
- }
-
- printf "%5lu %4ld %-10s %2d %-8s %-8s %8s %s %2d %5s %s\n",
- $ino,
- $blocks,
- $perms,
- $nlink,
- $user,
- $group,
- $sizemm,
- $moname,
- $mday,
- $timeyear,
- $pname;
- 1;
-}
-
-sub sizemm {
- sprintf("%3d, %3d", ($rdev >> 8) & 255, $rdev & 255);
-}
-
-END
-}
-
-if ($initcpio) {
-print <<'END';
-sub cpio {
- local($nc,$fh) = @_;
- local($text);
-
- if ($name eq 'TRAILER!!!') {
- $text = '';
- $size = 0;
- }
- else {
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_);
- if (-f _) {
- open(IN, "./$_\0") || do {
- warn "Couldn't open $name: $!\n";
- return;
- };
- }
- else {
- $text = readlink($_);
- $size = 0 unless defined $text;
- }
- }
-
- ($nm = $name) =~ s#^\./##;
- $nc{$fh} = $nc;
- if ($nc eq 'n') {
- $cpout{$fh} .=
- sprintf("%06o%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo%s\0",
- 070707,
- $dev & 0777777,
- $ino & 0777777,
- $mode & 0777777,
- $uid & 0777777,
- $gid & 0777777,
- $nlink & 0777777,
- $rdev & 0177777,
- $mtime,
- length($nm)+1,
- $size,
- $nm);
- }
- else {
- $cpout{$fh} .= "\0" if length($cpout{$fh}) & 1;
- $cpout{$fh} .= pack("SSSSSSSSLSLa*",
- 070707, $dev, $ino, $mode, $uid, $gid, $nlink, $rdev, $mtime,
- length($nm)+1, $size, $nm . (length($nm) & 1 ? "\0" : "\0\0"));
- }
- if ($text ne '') {
- $cpout{$fh} .= $text;
- }
- elsif ($size) {
- &flush($fh) while ($l = length($cpout{$fh})) >= 5120;
- while (sysread(IN, $cpout{$fh}, 5120 - $l, $l)) {
- &flush($fh);
- $l = length($cpout{$fh});
- }
- }
- close IN;
-}
-
-sub flush {
- local($fh) = @_;
-
- while (length($cpout{$fh}) >= 5120) {
- syswrite($fh,$cpout{$fh},5120);
- ++$blocks{$fh};
- substr($cpout{$fh}, 0, 5120) = '';
- }
-}
-
-sub flushall {
- $name = 'TRAILER!!!';
- foreach $fh (keys %cpout) {
- &cpio($nc{$fh},$fh);
- $cpout{$fh} .= "0" x (5120 - length($cpout{$fh}));
- &flush($fh);
- print $blocks{$fh} * 10, " blocks\n";
- }
-}
-
-END
-}
-
-if ($inittar) {
-print <<'END';
-sub tar {
- local($fh) = @_;
- local($linkname,$header,$l,$slop);
- local($linkflag) = "\0";
-
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_);
- $nm = $name;
- if ($nlink > 1) {
- if ($linkname = $linkseen{$fh,$dev,$ino}) {
- $linkflag = 1;
- }
- else {
- $linkseen{$fh,$dev,$ino} = $nm;
- }
- }
- if (-f _) {
- open(IN, "./$_\0") || do {
- warn "Couldn't open $name: $!\n";
- return;
- };
- $size = 0 if $linkflag ne "\0";
- }
- else {
- $linkname = readlink($_);
- $linkflag = 2 if defined $linkname;
- $nm .= '/' if -d _;
- $size = 0;
- }
-
- $header = pack("a100a8a8a8a12a12a8a1a100",
- $nm,
- sprintf("%6o ", $mode & 0777),
- sprintf("%6o ", $uid & 0777777),
- sprintf("%6o ", $gid & 0777777),
- sprintf("%11o ", $size),
- sprintf("%11o ", $mtime),
- " ",
- $linkflag,
- $linkname);
- $l = length($header) % 512;
- substr($header, 148, 6) = sprintf("%6o", unpack("%16C*", $header));
- substr($header, 154, 1) = "\0"; # blech
- $tarout{$fh} .= $header;
- $tarout{$fh} .= "\0" x (512 - $l) if $l;
- if ($size) {
- &tflush($fh) while ($l = length($tarout{$fh})) >= 10240;
- while (sysread(IN, $tarout{$fh}, 10240 - $l, $l)) {
- $slop = length($tarout{$fh}) % 512;
- $tarout{$fh} .= "\0" x (512 - $slop) if $slop;
- &tflush($fh);
- $l = length($tarout{$fh});
- }
- }
- close IN;
-}
-
-sub tflush {
- local($fh) = @_;
-
- while (length($tarout{$fh}) >= 10240) {
- syswrite($fh,$tarout{$fh},10240);
- ++$blocks{$fh};
- substr($tarout{$fh}, 0, 10240) = '';
- }
-}
-
-sub tflushall {
- local($len);
-
- foreach $fh (keys %tarout) {
- $len = 10240 - length($tarout{$fh});
- $len += 10240 if $len < 1024;
- $tarout{$fh} .= "\0" x $len;
- &tflush($fh);
- }
-}
-
-END
-}
-
-exit;
-
-############################################################################
-
-sub tab {
- local($tabstring);
-
- $tabstring = "\t" x ($indent / 2) . ' ' x ($indent % 2 * 4);
- if (!$statdone) {
- if ($_ =~ /^(name|print|prune|exec|ok|\(|\))/) {
- $delayedstat++;
- }
- else {
- if ($saw_or) {
- $tabstring .= <<'ENDOFSTAT' . $tabstring;
-($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
-ENDOFSTAT
- }
- else {
- $tabstring .= <<'ENDOFSTAT' . $tabstring;
-(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
-ENDOFSTAT
- }
- $statdone = 1;
- }
- }
- $tabstring =~ s/^\s+/ / if $out =~ /!$/;
- $tabstring;
-}
-
-sub fileglob_to_re {
- local($tmp) = @_;
-
- $tmp =~ s/([.^\$()])/\\$1/g;
- $tmp =~ s/([?*])/.$1/g;
- "^$tmp$";
-}
-
-sub n {
- local($n) = @_;
-
- $n =~ s/^-/< / || $n =~ s/^\+/> / || $n =~ s/^/== /;
- $n =~ s/ 0*(\d)/ $1/;
- $n;
-}
-
-sub quote {
- local($string) = @_;
- $string =~ s/'/\\'/;
- "'$string'";
-}
diff --git a/gnu/usr.bin/perl/x2p/h2ph b/gnu/usr.bin/perl/x2p/h2ph
deleted file mode 100755
index 143791f..0000000
--- a/gnu/usr.bin/perl/x2p/h2ph
+++ /dev/null
@@ -1,262 +0,0 @@
-#!/usr/bin/perl
-'di';
-'ig00';
-
-$destdir = $ENV{'DESTDIR'};
-$perlincl = $destdir . '/usr/share/perl';
-
-chdir $destdir . '/usr/include' || die "Can't cd $destdir/usr/include";
-
-@isatype = split(' ',<<END);
- char uchar u_char
- short ushort u_short
- int uint u_int
- long ulong u_long
- FILE
-END
-
-@isatype{@isatype} = (1) x @isatype;
-
-@ARGV = ('-') unless @ARGV;
-
-foreach $file (@ARGV) {
- if ($file eq '-') {
- open(IN, "-");
- open(OUT, ">-");
- }
- else {
- ($outfile = $file) =~ s/\.h$/.ph/ || next;
- print "$file -> $outfile\n";
- if ($file =~ m|^(.*)/|) {
- $dir = $1;
- if (!-d "$perlincl/$dir") {
- mkdir("$perlincl/$dir",0777);
- }
- }
- open(IN,"$file") || ((warn "Can't open $file: $!\n"),next);
- open(OUT,">$perlincl/$outfile") || die "Can't create $outfile: $!\n";
- }
- while (<IN>) {
- chop;
- while (/\\$/) {
- chop;
- $_ .= <IN>;
- chop;
- }
- if (s:/\*:\200:g) {
- s:\*/:\201:g;
- s/\200[^\201]*\201//g; # delete single line comments
- if (s/\200.*//) { # begin multi-line comment?
- $_ .= '/*';
- $_ .= <IN>;
- redo;
- }
- }
- if (s/^#\s*//) {
- if (s/^define\s+(\w+)//) {
- $name = $1;
- $new = '';
- s/\s+$//;
- if (s/^\(([\w,\s]*)\)//) {
- $args = $1;
- if ($args ne '') {
- foreach $arg (split(/,\s*/,$args)) {
- $arg =~ s/^\s*([^\s].*[^\s])\s*$/$1/;
- $curargs{$arg} = 1;
- }
- $args =~ s/\b(\w)/\$$1/g;
- $args = "local($args) = \@_;\n$t ";
- }
- s/^\s+//;
- do expr(0);
- $new =~ s/(["\\])/\\$1/g;
- if ($t ne '') {
- $new =~ s/(['\\])/\\$1/g;
- print OUT $t,
- "eval 'sub $name {\n$t ${args}eval \"$new\";\n$t}';\n";
- }
- else {
- print OUT "sub $name {\n ${args}eval \"$new\";\n}\n";
- }
- %curargs = ();
- }
- else {
- s/^\s+//;
- do expr(0);
- $new = 1 if $new eq '';
- if ($t ne '') {
- $new =~ s/(['\\])/\\$1/g;
- print OUT $t,"eval 'sub $name {",$new,";}';\n";
- }
- else {
- print OUT $t,"sub $name {",$new,";}\n";
- }
- }
- }
- elsif (/^include\s+<(.*)>/) {
- ($incl = $1) =~ s/\.h$/.ph/;
- print OUT $t,"require '$incl';\n";
- }
- elsif (/^ifdef\s+(\w+)/) {
- print OUT $t,"if (defined &$1) {\n";
- $tab += 4;
- $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
- }
- elsif (/^ifndef\s+(\w+)/) {
- print OUT $t,"if (!defined &$1) {\n";
- $tab += 4;
- $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
- }
- elsif (s/^if\s+//) {
- $new = '';
- do expr(1);
- print OUT $t,"if ( $new) {\n";
- $tab += 4;
- $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
- }
- elsif (s/^elif\s+//) {
- $new = '';
- do expr(1);
- $tab -= 4;
- $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
- print OUT $t,"}\n${t}elsif ($new) {\n";
- $tab += 4;
- $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
- }
- elsif (/^else/) {
- $tab -= 4;
- $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
- print OUT $t,"}\n${t}else {\n";
- $tab += 4;
- $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
- }
- elsif (/^endif/) {
- $tab -= 4;
- $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
- print OUT $t,"}\n";
- }
- }
- }
- print OUT "1;\n";
-}
-
-sub expr {
-$hd=0;
- while ($_ ne '') {
- s/^(\s+)// && do {$new .= ' '; next;};
- s/^(0x[0-9a-fA-F]+)// && do {$new .= $1; next;};
- s/^(\d+)// && do {$new .= $1; next;};
- s/^("(\\"|[^"])*")// && do {$new .= $1; next;};
- s/^'((\\"|[^"])*)'// && do {
- if ($curargs{$1}) {
- $new .= "ord('\$$1')";
- }
- else {
- $new .= "ord('$1')";
- }
- next;
- };
- s/^sizeof\s*\(([^)]+)\)/{$1}/ && do {
- $new .= '$sizeof';
- next;
- };
- s/^([_a-zA-Z]\w*)// && do {
- $id = $1;
- if ($id eq 'struct') {
- s/^\s+(\w+)//;
- $id .= ' ' . $1;
- $isatype{$id} = 1;
- }
- elsif ($id eq 'unsigned') {
- s/^\s+(\w+)//;
- $id .= ' ' . $1;
- $isatype{$id} = 1;
- }
- if ($curargs{$id}) {
- $new .= '$' . $id;
- }
- elsif ($id eq 'defined') {
- $new .= 'defined';
- $hd=1;
- }
- elsif (/^\(/) {
- s/^\((\w),/("$1",/ if $id =~ /^_IO[WR]*$/i; # cheat
- $new .= " &$id";
- }
- elsif ($isatype{$id}) {
- if ($new =~ /{\s*$/) {
- $new .= "'$id'";
- $hd=0;
- }
- elsif ($new =~ /\(\s*$/ && /^[\s*]*\)/) {
- $new =~ s/\(\s*$//;
- s/^[\s*]*\)//;
- }
- else {
- $new .= $id;
- }
- }
- else {
- if ($hd == 0) {
- $new .= 'defined &' . $id . ' && &' . $id;
- } else {
- $new .= ' &' . $id;
- }
- $hd=0;
- }
- next;
- };
- s/^(.)// && do {$new .= $1; next;};
- }
-}
-##############################################################################
-
- # These next few lines are legal in both Perl and nroff.
-
-.00; # finish .ig
-
-'di \" finish diversion--previous line must be blank
-.nr nl 0-1 \" fake up transition to first page again
-.nr % 0 \" start at page 1
-'; __END__ ############# From here on it's a standard manual page ############
-.TH H2PH 1 "August 8, 1990"
-.AT 3
-.SH NAME
-h2ph \- convert .h C header files to .ph Perl header files
-.SH SYNOPSIS
-.B h2ph [headerfiles]
-.SH DESCRIPTION
-.I h2ph
-converts any C header files specified to the corresponding Perl header file
-format.
-It is most easily run while in /usr/include:
-.nf
-
- cd /usr/include; h2ph * sys/*
-
-.fi
-If run with no arguments, filters standard input to standard output.
-.SH ENVIRONMENT
-No environment variables are used.
-.SH FILES
-/usr/include/*.h
-.br
-/usr/include/sys/*.h
-.br
-etc.
-.SH AUTHOR
-Larry Wall
-.SH "SEE ALSO"
-perl(1)
-.SH DIAGNOSTICS
-The usual warnings if it can't read or write the files involved.
-.SH BUGS
-Doesn't construct the %sizeof array for you.
-.PP
-It doesn't handle all C constructs, but it does attempt to isolate
-definitions inside evals so that you can get at the definitions
-that it can translate.
-.PP
-It's only intended as a rough tool.
-You may need to dicker with the files produced.
-.ex
diff --git a/gnu/usr.bin/perl/x2p/h2ph.1 b/gnu/usr.bin/perl/x2p/h2ph.1
deleted file mode 100755
index 3ac76f4..0000000
--- a/gnu/usr.bin/perl/x2p/h2ph.1
+++ /dev/null
@@ -1,41 +0,0 @@
-.TH H2PH 1 "August 8, 1990"
-.AT 3
-.SH NAME
-h2ph \- convert .h C header files to .ph Perl header files
-.SH SYNOPSIS
-.B h2ph [headerfiles]
-.SH DESCRIPTION
-.I h2ph
-converts any C header files specified to the corresponding Perl header file
-format.
-It is most easily run while in /usr/include:
-.nf
-
- cd /usr/include; h2ph * sys/*
-
-.fi
-If run with no arguments, filters standard input to standard output.
-.SH ENVIRONMENT
-No environment variables are used.
-.SH FILES
-/usr/include/*.h
-.br
-/usr/include/sys/*.h
-.br
-etc.
-.SH AUTHOR
-Larry Wall
-.SH "SEE ALSO"
-perl(1)
-.SH DIAGNOSTICS
-The usual warnings if it can't read or write the files involved.
-.SH BUGS
-Doesn't construct the %sizeof array for you.
-.PP
-It doesn't handle all C constructs, but it does attempt to isolate
-definitions inside evals so that you can get at the definitions
-that it can translate.
-.PP
-It's only intended as a rough tool.
-You may need to dicker with the files produced.
-.ex
diff --git a/gnu/usr.bin/perl/x2p/handy.h b/gnu/usr.bin/perl/x2p/handy.h
deleted file mode 100644
index 1db94d4..0000000
--- a/gnu/usr.bin/perl/x2p/handy.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* $RCSfile: handy.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:54 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: handy.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:54 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:10 nate
- * PERL!
- *
- * Revision 4.0.1.2 91/06/07 12:15:43 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0.1.1 91/04/12 09:29:08 lwall
- * patch1: random cleanup in cpp namespace
- *
- * Revision 4.0 91/03/20 01:57:45 lwall
- * 4.0 baseline.
- *
- */
-
-#define Null(type) ((type)0)
-#define Nullch Null(char*)
-#define Nullfp Null(FILE*)
-
-#define bool char
-#ifdef TRUE
-#undef TRUE
-#endif
-#ifdef FALSE
-#undef FALSE
-#endif
-#define TRUE (1)
-#define FALSE (0)
-
-#define Ctl(ch) (ch & 037)
-
-#define strNE(s1,s2) (strcmp(s1,s2))
-#define strEQ(s1,s2) (!strcmp(s1,s2))
-#define strLT(s1,s2) (strcmp(s1,s2) < 0)
-#define strLE(s1,s2) (strcmp(s1,s2) <= 0)
-#define strGT(s1,s2) (strcmp(s1,s2) > 0)
-#define strGE(s1,s2) (strcmp(s1,s2) >= 0)
-#define strnNE(s1,s2,l) (strncmp(s1,s2,l))
-#define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))
diff --git a/gnu/usr.bin/perl/x2p/hash.c b/gnu/usr.bin/perl/x2p/hash.c
deleted file mode 100644
index d1ae8ac..0000000
--- a/gnu/usr.bin/perl/x2p/hash.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/* $RCSfile: hash.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:54 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: hash.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:54 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:10 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 12:15:55 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:57:49 lwall
- * 4.0 baseline.
- *
- */
-
-#include <stdio.h>
-#include "EXTERN.h"
-#include "handy.h"
-#include "util.h"
-#include "a2p.h"
-
-STR *
-hfetch(tb,key)
-register HASH *tb;
-char *key;
-{
- register char *s;
- register int i;
- register int hash;
- register HENT *entry;
-
- if (!tb)
- return Nullstr;
- for (s=key, i=0, hash = 0;
- /* while */ *s;
- s++, i++, hash *= 5) {
- hash += *s * coeff[i];
- }
- entry = tb->tbl_array[hash & tb->tbl_max];
- for (; entry; entry = entry->hent_next) {
- if (entry->hent_hash != hash) /* strings can't be equal */
- continue;
- if (strNE(entry->hent_key,key)) /* is this it? */
- continue;
- return entry->hent_val;
- }
- return Nullstr;
-}
-
-bool
-hstore(tb,key,val)
-register HASH *tb;
-char *key;
-STR *val;
-{
- register char *s;
- register int i;
- register int hash;
- register HENT *entry;
- register HENT **oentry;
-
- if (!tb)
- return FALSE;
- for (s=key, i=0, hash = 0;
- /* while */ *s;
- s++, i++, hash *= 5) {
- hash += *s * coeff[i];
- }
-
- oentry = &(tb->tbl_array[hash & tb->tbl_max]);
- i = 1;
-
- for (entry = *oentry; entry; i=0, entry = entry->hent_next) {
- if (entry->hent_hash != hash) /* strings can't be equal */
- continue;
- if (strNE(entry->hent_key,key)) /* is this it? */
- continue;
- /*NOSTRICT*/
- safefree((char*)entry->hent_val);
- entry->hent_val = val;
- return TRUE;
- }
- /*NOSTRICT*/
- entry = (HENT*) safemalloc(sizeof(HENT));
-
- entry->hent_key = savestr(key);
- entry->hent_val = val;
- entry->hent_hash = hash;
- entry->hent_next = *oentry;
- *oentry = entry;
-
- if (i) { /* initial entry? */
- tb->tbl_fill++;
- if ((tb->tbl_fill * 100 / (tb->tbl_max + 1)) > FILLPCT)
- hsplit(tb);
- }
-
- return FALSE;
-}
-
-#ifdef NOTUSED
-bool
-hdelete(tb,key)
-register HASH *tb;
-char *key;
-{
- register char *s;
- register int i;
- register int hash;
- register HENT *entry;
- register HENT **oentry;
-
- if (!tb)
- return FALSE;
- for (s=key, i=0, hash = 0;
- /* while */ *s;
- s++, i++, hash *= 5) {
- hash += *s * coeff[i];
- }
-
- oentry = &(tb->tbl_array[hash & tb->tbl_max]);
- entry = *oentry;
- i = 1;
- for (; entry; i=0, oentry = &entry->hent_next, entry = entry->hent_next) {
- if (entry->hent_hash != hash) /* strings can't be equal */
- continue;
- if (strNE(entry->hent_key,key)) /* is this it? */
- continue;
- safefree((char*)entry->hent_val);
- safefree(entry->hent_key);
- *oentry = entry->hent_next;
- safefree((char*)entry);
- if (i)
- tb->tbl_fill--;
- return TRUE;
- }
- return FALSE;
-}
-#endif
-
-hsplit(tb)
-HASH *tb;
-{
- int oldsize = tb->tbl_max + 1;
- register int newsize = oldsize * 2;
- register int i;
- register HENT **a;
- register HENT **b;
- register HENT *entry;
- register HENT **oentry;
-
- a = (HENT**) saferealloc((char*)tb->tbl_array, newsize * sizeof(HENT*));
- bzero((char*)&a[oldsize], oldsize * sizeof(HENT*)); /* zero second half */
- tb->tbl_max = --newsize;
- tb->tbl_array = a;
-
- for (i=0; i<oldsize; i++,a++) {
- if (!*a) /* non-existent */
- continue;
- b = a+oldsize;
- for (oentry = a, entry = *a; entry; entry = *oentry) {
- if ((entry->hent_hash & newsize) != i) {
- *oentry = entry->hent_next;
- entry->hent_next = *b;
- if (!*b)
- tb->tbl_fill++;
- *b = entry;
- continue;
- }
- else
- oentry = &entry->hent_next;
- }
- if (!*a) /* everything moved */
- tb->tbl_fill--;
- }
-}
-
-HASH *
-hnew()
-{
- register HASH *tb = (HASH*)safemalloc(sizeof(HASH));
-
- tb->tbl_array = (HENT**) safemalloc(8 * sizeof(HENT*));
- tb->tbl_fill = 0;
- tb->tbl_max = 7;
- hiterinit(tb); /* so each() will start off right */
- bzero((char*)tb->tbl_array, 8 * sizeof(HENT*));
- return tb;
-}
-
-#ifdef NOTUSED
-hshow(tb)
-register HASH *tb;
-{
- fprintf(stderr,"%5d %4d (%2d%%)\n",
- tb->tbl_max+1,
- tb->tbl_fill,
- tb->tbl_fill * 100 / (tb->tbl_max+1));
-}
-#endif
-
-hiterinit(tb)
-register HASH *tb;
-{
- tb->tbl_riter = -1;
- tb->tbl_eiter = Null(HENT*);
- return tb->tbl_fill;
-}
-
-HENT *
-hiternext(tb)
-register HASH *tb;
-{
- register HENT *entry;
-
- entry = tb->tbl_eiter;
- do {
- if (entry)
- entry = entry->hent_next;
- if (!entry) {
- tb->tbl_riter++;
- if (tb->tbl_riter > tb->tbl_max) {
- tb->tbl_riter = -1;
- break;
- }
- entry = tb->tbl_array[tb->tbl_riter];
- }
- } while (!entry);
-
- tb->tbl_eiter = entry;
- return entry;
-}
-
-char *
-hiterkey(entry)
-register HENT *entry;
-{
- return entry->hent_key;
-}
-
-STR *
-hiterval(entry)
-register HENT *entry;
-{
- return entry->hent_val;
-}
diff --git a/gnu/usr.bin/perl/x2p/hash.h b/gnu/usr.bin/perl/x2p/hash.h
deleted file mode 100644
index 452321c..0000000
--- a/gnu/usr.bin/perl/x2p/hash.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* $RCSfile: hash.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:54 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: hash.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:54 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:10 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 12:16:04 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:57:53 lwall
- * 4.0 baseline.
- *
- */
-
-#define FILLPCT 60 /* don't make greater than 99 */
-
-#ifdef DOINIT
-char coeff[] = {
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
- 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1};
-#else
-extern char coeff[];
-#endif
-
-typedef struct hentry HENT;
-
-struct hentry {
- HENT *hent_next;
- char *hent_key;
- STR *hent_val;
- int hent_hash;
-};
-
-struct htbl {
- HENT **tbl_array;
- int tbl_max;
- int tbl_fill;
- int tbl_riter; /* current root of iterator */
- HENT *tbl_eiter; /* current entry of iterator */
-};
-
-STR *hfetch();
-bool hstore();
-bool hdelete();
-HASH *hnew();
-int hiterinit();
-HENT *hiternext();
-char *hiterkey();
-STR *hiterval();
diff --git a/gnu/usr.bin/perl/x2p/s2p b/gnu/usr.bin/perl/x2p/s2p
deleted file mode 100755
index c110e5e..0000000
--- a/gnu/usr.bin/perl/x2p/s2p
+++ /dev/null
@@ -1,769 +0,0 @@
-#!/usr/bin/perl
-
-eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
- if $running_under_some_shell;
-
-$bin = '/usr/bin';
-
-# $RCSfile: s2p,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:54 $
-#
-# $Log: s2p,v $
-# Revision 1.1.1.1 1994/09/10 06:27:54 gclarkii
-# Initial import of Perl 4.046 bmaked
-#
-# Revision 1.2 1994/03/05 01:28:48 ache
-# 1) Perl uses scrambler crypt() version from libc instead of proper one
-# from -lcrypt (if exist)
-# 2) We have now all sem/shm/msg stuff, add it to perl too
-#
-# Revision 1.1.1.1 1993/08/23 21:30:10 nate
-# PERL!
-#
-# Revision 4.0.1.2 92/06/08 17:26:31 lwall
-# patch20: s2p didn't output portable startup code
-# patch20: added ... as variant on ..
-# patch20: s2p didn't translate s/pat/\&/ or s/pat/\$/ or s/pat/\\1/ right
-#
-# Revision 4.0.1.1 91/06/07 12:19:18 lwall
-# patch4: s2p now handles embedded newlines better and optimizes common idioms
-#
-# Revision 4.0 91/03/20 01:57:59 lwall
-# 4.0 baseline.
-#
-#
-
-$indent = 4;
-$shiftwidth = 4;
-$l = '{'; $r = '}';
-
-while ($ARGV[0] =~ /^-/) {
- $_ = shift;
- last if /^--/;
- if (/^-D/) {
- $debug++;
- open(BODY,'>-');
- next;
- }
- if (/^-n/) {
- $assumen++;
- next;
- }
- if (/^-p/) {
- $assumep++;
- next;
- }
- die "I don't recognize this switch: $_\n";
-}
-
-unless ($debug) {
- open(BODY,">/tmp/sperl$$") ||
- &Die("Can't open temp file: $!\n");
-}
-
-if (!$assumen && !$assumep) {
- print BODY &q(<<'EOT');
-: while ($ARGV[0] =~ /^-/) {
-: $_ = shift;
-: last if /^--/;
-: if (/^-n/) {
-: $nflag++;
-: next;
-: }
-: die "I don't recognize this switch: $_\\n";
-: }
-:
-EOT
-}
-
-print BODY &q(<<'EOT');
-: #ifdef PRINTIT
-: #ifdef ASSUMEP
-: $printit++;
-: #else
-: $printit++ unless $nflag;
-: #endif
-: #endif
-: <><>
-: $\ = "\n"; # automatically add newline on print
-: <><>
-: #ifdef TOPLABEL
-: LINE:
-: while (chop($_ = <>)) {
-: #else
-: LINE:
-: while (<>) {
-: chop;
-: #endif
-EOT
-
-LINE:
-while (<>) {
-
- # Wipe out surrounding whitespace.
-
- s/[ \t]*(.*)\n$/$1/;
-
- # Perhaps it's a label/comment.
-
- if (/^:/) {
- s/^:[ \t]*//;
- $label = &make_label($_);
- if ($. == 1) {
- $toplabel = $label;
- if (/^(top|(re)?start|redo|begin(ning)|again|input)$/i) {
- $_ = <>;
- redo LINE; # Never referenced, so delete it if not a comment.
- }
- }
- $_ = "$label:";
- if ($lastlinewaslabel++) {
- $indent += 4;
- print BODY &tab, ";\n";
- $indent -= 4;
- }
- if ($indent >= 2) {
- $indent -= 2;
- $indmod = 2;
- }
- next;
- } else {
- $lastlinewaslabel = '';
- }
-
- # Look for one or two address clauses
-
- $addr1 = '';
- $addr2 = '';
- if (s/^([0-9]+)//) {
- $addr1 = "$1";
- $addr1 = "\$. == $addr1" unless /^,/;
- }
- elsif (s/^\$//) {
- $addr1 = 'eof()';
- }
- elsif (s|^/||) {
- $addr1 = &fetchpat('/');
- }
- if (s/^,//) {
- if (s/^([0-9]+)//) {
- $addr2 = "$1";
- } elsif (s/^\$//) {
- $addr2 = "eof()";
- } elsif (s|^/||) {
- $addr2 = &fetchpat('/');
- } else {
- &Die("Invalid second address at line $.\n");
- }
- if ($addr2 =~ /^\d+$/) {
- $addr1 .= "..$addr2";
- }
- else {
- $addr1 .= "...$addr2";
- }
- }
-
- # Now we check for metacommands {, }, and ! and worry
- # about indentation.
-
- s/^[ \t]+//;
- # a { to keep vi happy
- if ($_ eq '}') {
- $indent -= 4;
- next;
- }
- if (s/^!//) {
- $if = 'unless';
- $else = "$r else $l\n";
- } else {
- $if = 'if';
- $else = '';
- }
- if (s/^{//) { # a } to keep vi happy
- $indmod = 4;
- $redo = $_;
- $_ = '';
- $rmaybe = '';
- } else {
- $rmaybe = "\n$r";
- if ($addr2 || $addr1) {
- $space = ' ' x $shiftwidth;
- } else {
- $space = '';
- }
- $_ = &transmogrify();
- }
-
- # See if we can optimize to modifier form.
-
- if ($addr1) {
- if ($_ !~ /[\n{}]/ && $rmaybe && !$change &&
- $_ !~ / if / && $_ !~ / unless /) {
- s/;$/ $if $addr1;/;
- $_ = substr($_,$shiftwidth,1000);
- } else {
- $_ = "$if ($addr1) $l\n$change$_$rmaybe";
- }
- $change = '';
- next LINE;
- }
-} continue {
- @lines = split(/\n/,$_);
- for (@lines) {
- unless (s/^ *<<--//) {
- print BODY &tab;
- }
- print BODY $_, "\n";
- }
- $indent += $indmod;
- $indmod = 0;
- if ($redo) {
- $_ = $redo;
- $redo = '';
- redo LINE;
- }
-}
-if ($lastlinewaslabel++) {
- $indent += 4;
- print BODY &tab, ";\n";
- $indent -= 4;
-}
-
-if ($appendseen || $tseen || !$assumen) {
- $printit++ if $dseen || (!$assumen && !$assumep);
- print BODY &q(<<'EOT');
-: #ifdef SAWNEXT
-: }
-: continue {
-: #endif
-: #ifdef PRINTIT
-: #ifdef DSEEN
-: #ifdef ASSUMEP
-: print if $printit++;
-: #else
-: if ($printit)
-: { print; }
-: else
-: { $printit++ unless $nflag; }
-: #endif
-: #else
-: print if $printit;
-: #endif
-: #else
-: print;
-: #endif
-: #ifdef TSEEN
-: $tflag = 0;
-: #endif
-: #ifdef APPENDSEEN
-: if ($atext) { chop $atext; print $atext; $atext = ''; }
-: #endif
-EOT
-
-print BODY &q(<<'EOT');
-: }
-EOT
-}
-
-close BODY;
-
-unless ($debug) {
- open(HEAD,">/tmp/sperl2$$.c")
- || &Die("Can't open temp file 2: $!\n");
- print HEAD "#define PRINTIT\n" if $printit;
- print HEAD "#define APPENDSEEN\n" if $appendseen;
- print HEAD "#define TSEEN\n" if $tseen;
- print HEAD "#define DSEEN\n" if $dseen;
- print HEAD "#define ASSUMEN\n" if $assumen;
- print HEAD "#define ASSUMEP\n" if $assumep;
- print HEAD "#define TOPLABEL\n" if $toplabel;
- print HEAD "#define SAWNEXT\n" if $sawnext;
- if ($opens) {print HEAD "$opens\n";}
- open(BODY,"/tmp/sperl$$")
- || &Die("Can't reopen temp file: $!\n");
- while (<BODY>) {
- print HEAD $_;
- }
- close HEAD;
-
- print &q(<<"EOT");
-: #!$bin/perl
-: eval 'exec $bin/perl -S \$0 \${1+"\$@"}'
-: if \$running_under_some_shell;
-:
-EOT
- open(BODY,"cc -E /tmp/sperl2$$.c |") ||
- &Die("Can't reopen temp file: $!\n");
- while (<BODY>) {
- /^# [0-9]/ && next;
- /^[ \t]*$/ && next;
- s/^<><>//;
- print;
- }
-}
-
-&Cleanup;
-exit;
-
-sub Cleanup {
- chdir "/tmp";
- unlink "sperl$$", "sperl2$$", "sperl2$$.c";
-}
-sub Die {
- &Cleanup;
- die $_[0];
-}
-sub tab {
- "\t" x ($indent / 8) . ' ' x ($indent % 8);
-}
-sub make_filehandle {
- local($_) = $_[0];
- local($fname) = $_;
- if (!$seen{$fname}) {
- $_ = "FH_" . $_ if /^\d/;
- s/[^a-zA-Z0-9]/_/g;
- s/^_*//;
- $_ = "\U$_";
- if ($fhseen{$_}) {
- for ($tmp = "a"; $fhseen{"$_$tmp"}; $a++) {}
- $_ .= $tmp;
- }
- $fhseen{$_} = 1;
- $opens .= &q(<<"EOT");
-: open($_, '>$fname') || die "Can't create $fname: \$!";
-EOT
- $seen{$fname} = $_;
- }
- $seen{$fname};
-}
-
-sub make_label {
- local($label) = @_;
- $label =~ s/[^a-zA-Z0-9]/_/g;
- if ($label =~ /^[0-9_]/) { $label = 'L' . $label; }
- $label = substr($label,0,8);
-
- # Could be a reserved word, so capitalize it.
- substr($label,0,1) =~ y/a-z/A-Z/
- if $label =~ /^[a-z]/;
-
- $label;
-}
-
-sub transmogrify {
- { # case
- if (/^d/) {
- $dseen++;
- chop($_ = &q(<<'EOT'));
-: <<--#ifdef PRINTIT
-: $printit = 0;
-: <<--#endif
-: next LINE;
-EOT
- $sawnext++;
- next;
- }
-
- if (/^n/) {
- chop($_ = &q(<<'EOT'));
-: <<--#ifdef PRINTIT
-: <<--#ifdef DSEEN
-: <<--#ifdef ASSUMEP
-: print if $printit++;
-: <<--#else
-: if ($printit)
-: { print; }
-: else
-: { $printit++ unless $nflag; }
-: <<--#endif
-: <<--#else
-: print if $printit;
-: <<--#endif
-: <<--#else
-: print;
-: <<--#endif
-: <<--#ifdef APPENDSEEN
-: if ($atext) {chop $atext; print $atext; $atext = '';}
-: <<--#endif
-: $_ = <>;
-: chop;
-: <<--#ifdef TSEEN
-: $tflag = 0;
-: <<--#endif
-EOT
- next;
- }
-
- if (/^a/) {
- $appendseen++;
- $command = $space . "\$atext .= <<'End_Of_Text';\n<<--";
- $lastline = 0;
- while (<>) {
- s/^[ \t]*//;
- s/^[\\]//;
- unless (s|\\$||) { $lastline = 1;}
- s/^([ \t]*\n)/<><>$1/;
- $command .= $_;
- $command .= '<<--';
- last if $lastline;
- }
- $_ = $command . "End_Of_Text";
- last;
- }
-
- if (/^[ic]/) {
- if (/^c/) { $change = 1; }
- $addr1 = 1 if $addr1 eq '';
- $addr1 = '$iter = (' . $addr1 . ')';
- $command = $space .
- " if (\$iter == 1) { print <<'End_Of_Text'; }\n<<--";
- $lastline = 0;
- while (<>) {
- s/^[ \t]*//;
- s/^[\\]//;
- unless (s/\\$//) { $lastline = 1;}
- s/'/\\'/g;
- s/^([ \t]*\n)/<><>$1/;
- $command .= $_;
- $command .= '<<--';
- last if $lastline;
- }
- $_ = $command . "End_Of_Text";
- if ($change) {
- $dseen++;
- $change = "$_\n";
- chop($_ = &q(<<"EOT"));
-: <<--#ifdef PRINTIT
-: $space\$printit = 0;
-: <<--#endif
-: ${space}next LINE;
-EOT
- $sawnext++;
- }
- last;
- }
-
- if (/^s/) {
- $delim = substr($_,1,1);
- $len = length($_);
- $repl = $end = 0;
- $inbracket = 0;
- for ($i = 2; $i < $len; $i++) {
- $c = substr($_,$i,1);
- if ($c eq $delim) {
- if ($inbracket) {
- substr($_, $i, 0) = '\\';
- $i++;
- $len++;
- }
- else {
- if ($repl) {
- $end = $i;
- last;
- } else {
- $repl = $i;
- }
- }
- }
- elsif ($c eq '\\') {
- $i++;
- if ($i >= $len) {
- $_ .= 'n';
- $_ .= <>;
- $len = length($_);
- $_ = substr($_,0,--$len);
- }
- elsif (substr($_,$i,1) =~ /^[n]$/) {
- ;
- }
- elsif (!$repl &&
- substr($_,$i,1) =~ /^[(){}\w]$/) {
- $i--;
- $len--;
- substr($_, $i, 1) = '';
- }
- elsif (!$repl &&
- substr($_,$i,1) =~ /^[<>]$/) {
- substr($_,$i,1) = 'b';
- }
- elsif ($repl && substr($_,$i,1) =~ /^\d$/) {
- substr($_,$i-1,1) = '$';
- }
- }
- elsif ($c eq '&' && $repl) {
- substr($_, $i, 0) = '$';
- $i++;
- $len++;
- }
- elsif ($c eq '$' && $repl) {
- substr($_, $i, 0) = '\\';
- $i++;
- $len++;
- }
- elsif ($c eq '[' && !$repl) {
- $i++ if substr($_,$i,1) eq '^';
- $i++ if substr($_,$i,1) eq ']';
- $inbracket = 1;
- }
- elsif ($c eq ']') {
- $inbracket = 0;
- }
- elsif ($c eq "\t") {
- substr($_, $i, 1) = '\\t';
- $i++;
- $len++;
- }
- elsif (!$repl && index("()+",$c) >= 0) {
- substr($_, $i, 0) = '\\';
- $i++;
- $len++;
- }
- }
- &Die("Malformed substitution at line $.\n")
- unless $end;
- $pat = substr($_, 0, $repl + 1);
- $repl = substr($_, $repl+1, $end-$repl-1);
- $end = substr($_, $end + 1, 1000);
- &simplify($pat);
- $dol = '$';
- $subst = "$pat$repl$delim";
- $cmd = '';
- while ($end) {
- if ($end =~ s/^g//) {
- $subst .= 'g';
- next;
- }
- if ($end =~ s/^p//) {
- $cmd .= ' && (print)';
- next;
- }
- if ($end =~ s/^w[ \t]*//) {
- $fh = &make_filehandle($end);
- $cmd .= " && (print $fh \$_)";
- $end = '';
- next;
- }
- &Die("Unrecognized substitution command".
- "($end) at line $.\n");
- }
- chop ($_ = &q(<<"EOT"));
-: <<--#ifdef TSEEN
-: $subst && \$tflag++$cmd;
-: <<--#else
-: $subst$cmd;
-: <<--#endif
-EOT
- next;
- }
-
- if (/^p/) {
- $_ = 'print;';
- next;
- }
-
- if (/^w/) {
- s/^w[ \t]*//;
- $fh = &make_filehandle($_);
- $_ = "print $fh \$_;";
- next;
- }
-
- if (/^r/) {
- $appendseen++;
- s/^r[ \t]*//;
- $file = $_;
- $_ = "\$atext .= `cat $file 2>/dev/null`;";
- next;
- }
-
- if (/^P/) {
- $_ = 'print $1 if /^(.*)/;';
- next;
- }
-
- if (/^D/) {
- chop($_ = &q(<<'EOT'));
-: s/^.*\n?//;
-: redo LINE if $_;
-: next LINE;
-EOT
- $sawnext++;
- next;
- }
-
- if (/^N/) {
- chop($_ = &q(<<'EOT'));
-: $_ .= "\n";
-: $len1 = length;
-: $_ .= <>;
-: chop if $len1 < length;
-: <<--#ifdef TSEEN
-: $tflag = 0;
-: <<--#endif
-EOT
- next;
- }
-
- if (/^h/) {
- $_ = '$hold = $_;';
- next;
- }
-
- if (/^H/) {
- $_ = '$hold .= "\n"; $hold .= $_;';
- next;
- }
-
- if (/^g/) {
- $_ = '$_ = $hold;';
- next;
- }
-
- if (/^G/) {
- $_ = '$_ .= "\n"; $_ .= $hold;';
- next;
- }
-
- if (/^x/) {
- $_ = '($_, $hold) = ($hold, $_);';
- next;
- }
-
- if (/^b$/) {
- $_ = 'next LINE;';
- $sawnext++;
- next;
- }
-
- if (/^b/) {
- s/^b[ \t]*//;
- $lab = &make_label($_);
- if ($lab eq $toplabel) {
- $_ = 'redo LINE;';
- } else {
- $_ = "goto $lab;";
- }
- next;
- }
-
- if (/^t$/) {
- $_ = 'next LINE if $tflag;';
- $sawnext++;
- $tseen++;
- next;
- }
-
- if (/^t/) {
- s/^t[ \t]*//;
- $lab = &make_label($_);
- $_ = q/if ($tflag) {$tflag = 0; /;
- if ($lab eq $toplabel) {
- $_ .= 'redo LINE;}';
- } else {
- $_ .= "goto $lab;}";
- }
- $tseen++;
- next;
- }
-
- if (/^y/) {
- s/abcdefghijklmnopqrstuvwxyz/a-z/g;
- s/ABCDEFGHIJKLMNOPQRSTUVWXYZ/A-Z/g;
- s/abcdef/a-f/g;
- s/ABCDEF/A-F/g;
- s/0123456789/0-9/g;
- s/01234567/0-7/g;
- $_ .= ';';
- }
-
- if (/^=/) {
- $_ = 'print $.;';
- next;
- }
-
- if (/^q/) {
- chop($_ = &q(<<'EOT'));
-: close(ARGV);
-: @ARGV = ();
-: next LINE;
-EOT
- $sawnext++;
- next;
- }
- } continue {
- if ($space) {
- s/^/$space/;
- s/(\n)(.)/$1$space$2/g;
- }
- last;
- }
- $_;
-}
-
-sub fetchpat {
- local($outer) = @_;
- local($addr) = $outer;
- local($inbracket);
- local($prefix,$delim,$ch);
-
- # Process pattern one potential delimiter at a time.
-
- DELIM: while (s#^([^\]+(|)[\\/]*)([]+(|)[\\/])##) {
- $prefix = $1;
- $delim = $2;
- if ($delim eq '\\') {
- s/(.)//;
- $ch = $1;
- $delim = '' if $ch =~ /^[(){}A-Za-mo-z]$/;
- $ch = 'b' if $ch =~ /^[<>]$/;
- $delim .= $ch;
- }
- elsif ($delim eq '[') {
- $inbracket = 1;
- s/^\^// && ($delim .= '^');
- s/^]// && ($delim .= ']');
- }
- elsif ($delim eq ']') {
- $inbracket = 0;
- }
- elsif ($inbracket || $delim ne $outer) {
- $delim = '\\' . $delim;
- }
- $addr .= $prefix;
- $addr .= $delim;
- if ($delim eq $outer && !$inbracket) {
- last DELIM;
- }
- }
- $addr =~ s/\t/\\t/g;
- &simplify($addr);
- $addr;
-}
-
-sub q {
- local($string) = @_;
- local($*) = 1;
- $string =~ s/^:\t?//g;
- $string;
-}
-
-sub simplify {
- $_[0] =~ s/_a-za-z0-9/\\w/ig;
- $_[0] =~ s/a-z_a-z0-9/\\w/ig;
- $_[0] =~ s/a-za-z_0-9/\\w/ig;
- $_[0] =~ s/a-za-z0-9_/\\w/ig;
- $_[0] =~ s/_0-9a-za-z/\\w/ig;
- $_[0] =~ s/0-9_a-za-z/\\w/ig;
- $_[0] =~ s/0-9a-z_a-z/\\w/ig;
- $_[0] =~ s/0-9a-za-z_/\\w/ig;
- $_[0] =~ s/\[\\w\]/\\w/g;
- $_[0] =~ s/\[^\\w\]/\\W/g;
- $_[0] =~ s/\[0-9\]/\\d/g;
- $_[0] =~ s/\[^0-9\]/\\D/g;
- $_[0] =~ s/\\d\\d\*/\\d+/g;
- $_[0] =~ s/\\D\\D\*/\\D+/g;
- $_[0] =~ s/\\w\\w\*/\\w+/g;
- $_[0] =~ s/\\t\\t\*/\\t+/g;
- $_[0] =~ s/(\[.[^]]*\])\1\*/$1+/g;
- $_[0] =~ s/([\w\s!@#%^&-=,:;'"])\1\*/$1+/g;
-}
-
diff --git a/gnu/usr.bin/perl/x2p/s2p.1 b/gnu/usr.bin/perl/x2p/s2p.1
deleted file mode 100644
index ab74717..0000000
--- a/gnu/usr.bin/perl/x2p/s2p.1
+++ /dev/null
@@ -1,108 +0,0 @@
-.rn '' }`
-''' $RCSfile: s2p.man,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:10 $
-'''
-''' $Log: s2p.man,v $
-.\" Revision 1.1.1.1 1993/08/23 21:30:10 nate
-.\" PERL!
-.\"
-''' Revision 4.0.1.1 91/06/07 12:19:57 lwall
-''' patch4: s2p now handles embedded newlines better and optimizes common idioms
-'''
-''' Revision 4.0 91/03/20 01:58:07 lwall
-''' 4.0 baseline.
-'''
-''' Revision 3.0 89/10/18 15:35:09 lwall
-''' 3.0 baseline
-'''
-''' Revision 2.0 88/06/05 00:15:59 root
-''' Baseline version 2.0.
-'''
-'''
-.de Sh
-.br
-.ne 5
-.PP
-\fB\\$1\fR
-.PP
-..
-.de Sp
-.if t .sp .5v
-.if n .sp
-..
-.de Ip
-.br
-.ie \\n.$>=3 .ne \\$3
-.el .ne 3
-.IP "\\$1" \\$2
-..
-'''
-''' Set up \*(-- to give an unbreakable dash;
-''' string Tr holds user defined translation string.
-''' Bell System Logo is used as a dummy character.
-'''
-.tr \(*W-|\(bv\*(Tr
-.ie n \{\
-.ds -- \(*W-
-.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
-.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
-.ds L" ""
-.ds R" ""
-.ds L' '
-.ds R' '
-'br\}
-.el\{\
-.ds -- \(em\|
-.tr \*(Tr
-.ds L" ``
-.ds R" ''
-.ds L' `
-.ds R' '
-'br\}
-.TH S2P 1 NEW
-.SH NAME
-s2p - Sed to Perl translator
-.SH SYNOPSIS
-.B s2p [options] filename
-.SH DESCRIPTION
-.I S2p
-takes a sed script specified on the command line (or from standard input)
-and produces a comparable
-.I perl
-script on the standard output.
-.Sh "Options"
-Options include:
-.TP 5
-.B \-D<number>
-sets debugging flags.
-.TP 5
-.B \-n
-specifies that this sed script was always invoked with a sed -n.
-Otherwise a switch parser is prepended to the front of the script.
-.TP 5
-.B \-p
-specifies that this sed script was never invoked with a sed -n.
-Otherwise a switch parser is prepended to the front of the script.
-.Sh "Considerations"
-The perl script produced looks very sed-ish, and there may very well be
-better ways to express what you want to do in perl.
-For instance, s2p does not make any use of the split operator, but you might
-want to.
-.PP
-The perl script you end up with may be either faster or slower than the original
-sed script.
-If you're only interested in speed you'll just have to try it both ways.
-Of course, if you want to do something sed doesn't do, you have no choice.
-It's often possible to speed up the perl script by various methods, such
-as deleting all references to $\e and chop.
-.SH ENVIRONMENT
-S2p uses no environment variables.
-.SH AUTHOR
-Larry Wall <lwall@jpl-devvax.Jpl.Nasa.Gov>
-.SH FILES
-.SH SEE ALSO
-perl The perl compiler/interpreter
-.br
-a2p awk to perl translator
-.SH DIAGNOSTICS
-.SH BUGS
-.rn }` ''
diff --git a/gnu/usr.bin/perl/x2p/str.c b/gnu/usr.bin/perl/x2p/str.c
deleted file mode 100644
index 4e078a6..0000000
--- a/gnu/usr.bin/perl/x2p/str.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/* $RCSfile: str.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:54 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: str.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:54 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:09 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 12:20:08 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:58:15 lwall
- * 4.0 baseline.
- *
- */
-
-#include "handy.h"
-#include "EXTERN.h"
-#include "util.h"
-#include "a2p.h"
-
-str_numset(str,num)
-register STR *str;
-double num;
-{
- str->str_nval = num;
- str->str_pok = 0; /* invalidate pointer */
- str->str_nok = 1; /* validate number */
-}
-
-char *
-str_2ptr(str)
-register STR *str;
-{
- register char *s;
-
- if (!str)
- return "";
- GROWSTR(&(str->str_ptr), &(str->str_len), 24);
- s = str->str_ptr;
- if (str->str_nok) {
- sprintf(s,"%.20g",str->str_nval);
- while (*s) s++;
- }
- *s = '\0';
- str->str_cur = s - str->str_ptr;
- str->str_pok = 1;
-#ifdef DEBUGGING
- if (debug & 32)
- fprintf(stderr,"0x%lx ptr(%s)\n",str,str->str_ptr);
-#endif
- return str->str_ptr;
-}
-
-double
-str_2num(str)
-register STR *str;
-{
- if (!str)
- return 0.0;
- if (str->str_len && str->str_pok)
- str->str_nval = atof(str->str_ptr);
- else
- str->str_nval = 0.0;
- str->str_nok = 1;
-#ifdef DEBUGGING
- if (debug & 32)
- fprintf(stderr,"0x%lx num(%g)\n",str,str->str_nval);
-#endif
- return str->str_nval;
-}
-
-str_sset(dstr,sstr)
-STR *dstr;
-register STR *sstr;
-{
- if (!sstr)
- str_nset(dstr,No,0);
- else if (sstr->str_nok)
- str_numset(dstr,sstr->str_nval);
- else if (sstr->str_pok)
- str_nset(dstr,sstr->str_ptr,sstr->str_cur);
- else
- str_nset(dstr,"",0);
-}
-
-str_nset(str,ptr,len)
-register STR *str;
-register char *ptr;
-register int len;
-{
- GROWSTR(&(str->str_ptr), &(str->str_len), len + 1);
- bcopy(ptr,str->str_ptr,len);
- str->str_cur = len;
- *(str->str_ptr+str->str_cur) = '\0';
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
-}
-
-str_set(str,ptr)
-register STR *str;
-register char *ptr;
-{
- register int len;
-
- if (!ptr)
- ptr = "";
- len = strlen(ptr);
- GROWSTR(&(str->str_ptr), &(str->str_len), len + 1);
- bcopy(ptr,str->str_ptr,len+1);
- str->str_cur = len;
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
-}
-
-str_chop(str,ptr) /* like set but assuming ptr is in str */
-register STR *str;
-register char *ptr;
-{
- if (!(str->str_pok))
- str_2ptr(str);
- str->str_cur -= (ptr - str->str_ptr);
- bcopy(ptr,str->str_ptr, str->str_cur + 1);
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
-}
-
-str_ncat(str,ptr,len)
-register STR *str;
-register char *ptr;
-register int len;
-{
- if (!(str->str_pok))
- str_2ptr(str);
- GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + len + 1);
- bcopy(ptr,str->str_ptr+str->str_cur,len);
- str->str_cur += len;
- *(str->str_ptr+str->str_cur) = '\0';
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
-}
-
-str_scat(dstr,sstr)
-STR *dstr;
-register STR *sstr;
-{
- if (!(sstr->str_pok))
- str_2ptr(sstr);
- if (sstr)
- str_ncat(dstr,sstr->str_ptr,sstr->str_cur);
-}
-
-str_cat(str,ptr)
-register STR *str;
-register char *ptr;
-{
- register int len;
-
- if (!ptr)
- return;
- if (!(str->str_pok))
- str_2ptr(str);
- len = strlen(ptr);
- GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + len + 1);
- bcopy(ptr,str->str_ptr+str->str_cur,len+1);
- str->str_cur += len;
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
-}
-
-char *
-str_append_till(str,from,delim,keeplist)
-register STR *str;
-register char *from;
-register int delim;
-char *keeplist;
-{
- register char *to;
- register int len;
-
- if (!from)
- return Nullch;
- len = strlen(from);
- GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + len + 1);
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
- to = str->str_ptr+str->str_cur;
- for (; *from; from++,to++) {
- if (*from == '\\' && from[1] && delim != '\\') {
- if (!keeplist) {
- if (from[1] == delim || from[1] == '\\')
- from++;
- else
- *to++ = *from++;
- }
- else if (index(keeplist,from[1]))
- *to++ = *from++;
- else
- from++;
- }
- else if (*from == delim)
- break;
- *to = *from;
- }
- *to = '\0';
- str->str_cur = to - str->str_ptr;
- return from;
-}
-
-STR *
-str_new(len)
-int len;
-{
- register STR *str;
-
- if (freestrroot) {
- str = freestrroot;
- freestrroot = str->str_link.str_next;
- }
- else {
- str = (STR *) safemalloc(sizeof(STR));
- bzero((char*)str,sizeof(STR));
- }
- if (len)
- GROWSTR(&(str->str_ptr), &(str->str_len), len + 1);
- return str;
-}
-
-void
-str_grow(str,len)
-register STR *str;
-int len;
-{
- if (len && str)
- GROWSTR(&(str->str_ptr), &(str->str_len), len + 1);
-}
-
-/* make str point to what nstr did */
-
-void
-str_replace(str,nstr)
-register STR *str;
-register STR *nstr;
-{
- safefree(str->str_ptr);
- str->str_ptr = nstr->str_ptr;
- str->str_len = nstr->str_len;
- str->str_cur = nstr->str_cur;
- str->str_pok = nstr->str_pok;
- if (str->str_nok = nstr->str_nok)
- str->str_nval = nstr->str_nval;
- safefree((char*)nstr);
-}
-
-void
-str_free(str)
-register STR *str;
-{
- if (!str)
- return;
- if (str->str_len)
- str->str_ptr[0] = '\0';
- str->str_cur = 0;
- str->str_nok = 0;
- str->str_pok = 0;
- str->str_link.str_next = freestrroot;
- freestrroot = str;
-}
-
-str_len(str)
-register STR *str;
-{
- if (!str)
- return 0;
- if (!(str->str_pok))
- str_2ptr(str);
- if (str->str_len)
- return str->str_cur;
- else
- return 0;
-}
-
-char *
-str_gets(str,fp)
-register STR *str;
-register FILE *fp;
-{
-#ifdef STDSTDIO /* Here is some breathtakingly efficient cheating */
-
- register char *bp; /* we're going to steal some values */
- register int cnt; /* from the stdio struct and put EVERYTHING */
- register STDCHAR *ptr; /* in the innermost loop into registers */
- register char newline = '\n'; /* (assuming at least 6 registers) */
- int i;
- int bpx;
-
- cnt = fp->_cnt; /* get count into register */
- str->str_nok = 0; /* invalidate number */
- str->str_pok = 1; /* validate pointer */
- if (str->str_len <= cnt) /* make sure we have the room */
- GROWSTR(&(str->str_ptr), &(str->str_len), cnt+1);
- bp = str->str_ptr; /* move these two too to registers */
- ptr = fp->_ptr;
- for (;;) {
- while (--cnt >= 0) {
- if ((*bp++ = *ptr++) == newline)
- if (bp <= str->str_ptr || bp[-2] != '\\')
- goto thats_all_folks;
- else {
- line++;
- bp -= 2;
- }
- }
-
- fp->_cnt = cnt; /* deregisterize cnt and ptr */
- fp->_ptr = ptr;
- i = _filbuf(fp); /* get more characters */
- cnt = fp->_cnt;
- ptr = fp->_ptr; /* reregisterize cnt and ptr */
-
- bpx = bp - str->str_ptr; /* prepare for possible relocation */
- GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + cnt + 1);
- bp = str->str_ptr + bpx; /* reconstitute our pointer */
-
- if (i == newline) { /* all done for now? */
- *bp++ = i;
- goto thats_all_folks;
- }
- else if (i == EOF) /* all done for ever? */
- goto thats_all_folks;
- *bp++ = i; /* now go back to screaming loop */
- }
-
-thats_all_folks:
- fp->_cnt = cnt; /* put these back or we're in trouble */
- fp->_ptr = ptr;
- *bp = '\0';
- str->str_cur = bp - str->str_ptr; /* set length */
-
-#else /* !STDSTDIO */ /* The big, slow, and stupid way */
-
- static char buf[4192];
-
- if (fgets(buf, sizeof buf, fp) != Nullch)
- str_set(str, buf);
- else
- str_set(str, No);
-
-#endif /* STDSTDIO */
-
- return str->str_cur ? str->str_ptr : Nullch;
-}
-
-void
-str_inc(str)
-register STR *str;
-{
- register char *d;
-
- if (!str)
- return;
- if (str->str_nok) {
- str->str_nval += 1.0;
- str->str_pok = 0;
- return;
- }
- if (!str->str_pok) {
- str->str_nval = 1.0;
- str->str_nok = 1;
- return;
- }
- for (d = str->str_ptr; *d && *d != '.'; d++) ;
- d--;
- if (!isdigit(*str->str_ptr) || !isdigit(*d) ) {
- str_numset(str,atof(str->str_ptr) + 1.0); /* punt */
- return;
- }
- while (d >= str->str_ptr) {
- if (++*d <= '9')
- return;
- *(d--) = '0';
- }
- /* oh,oh, the number grew */
- GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + 2);
- str->str_cur++;
- for (d = str->str_ptr + str->str_cur; d > str->str_ptr; d--)
- *d = d[-1];
- *d = '1';
-}
-
-void
-str_dec(str)
-register STR *str;
-{
- register char *d;
-
- if (!str)
- return;
- if (str->str_nok) {
- str->str_nval -= 1.0;
- str->str_pok = 0;
- return;
- }
- if (!str->str_pok) {
- str->str_nval = -1.0;
- str->str_nok = 1;
- return;
- }
- for (d = str->str_ptr; *d && *d != '.'; d++) ;
- d--;
- if (!isdigit(*str->str_ptr) || !isdigit(*d) || (*d == '0' && d == str->str_ptr)) {
- str_numset(str,atof(str->str_ptr) - 1.0); /* punt */
- return;
- }
- while (d >= str->str_ptr) {
- if (--*d >= '0')
- return;
- *(d--) = '9';
- }
-}
-
-/* make a string that will exist for the duration of the expression eval */
-
-STR *
-str_mortal(oldstr)
-STR *oldstr;
-{
- register STR *str = str_new(0);
- static long tmps_size = -1;
-
- str_sset(str,oldstr);
- if (++tmps_max > tmps_size) {
- tmps_size = tmps_max;
- if (!(tmps_size & 127)) {
- if (tmps_size)
- tmps_list = (STR**)saferealloc((char*)tmps_list,
- (tmps_size + 128) * sizeof(STR*) );
- else
- tmps_list = (STR**)safemalloc(128 * sizeof(char*));
- }
- }
- tmps_list[tmps_max] = str;
- return str;
-}
-
-STR *
-str_make(s)
-char *s;
-{
- register STR *str = str_new(0);
-
- str_set(str,s);
- return str;
-}
-
-STR *
-str_nmake(n)
-double n;
-{
- register STR *str = str_new(0);
-
- str_numset(str,n);
- return str;
-}
diff --git a/gnu/usr.bin/perl/x2p/str.h b/gnu/usr.bin/perl/x2p/str.h
deleted file mode 100644
index 642e18e..0000000
--- a/gnu/usr.bin/perl/x2p/str.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* $RCSfile: str.h,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:55 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: str.h,v $
- * Revision 1.1.1.1 1994/09/10 06:27:55 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:10 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 12:20:22 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:58:21 lwall
- * 4.0 baseline.
- *
- */
-
-struct string {
- char * str_ptr; /* pointer to malloced string */
- double str_nval; /* numeric value, if any */
- int str_len; /* allocated size */
- int str_cur; /* length of str_ptr as a C string */
- union {
- STR *str_next; /* while free, link to next free str */
- } str_link;
- char str_pok; /* state of str_ptr */
- char str_nok; /* state of str_nval */
-};
-
-#define Nullstr Null(STR*)
-
-/* the following macro updates any magic values this str is associated with */
-
-#define STABSET(x) (x->str_link.str_magic && stabset(x->str_link.str_magic,x))
-
-EXT STR **tmps_list;
-EXT long tmps_max INIT(-1);
-
-char *str_2ptr();
-double str_2num();
-STR *str_mortal();
-STR *str_make();
-STR *str_nmake();
-char *str_gets();
diff --git a/gnu/usr.bin/perl/x2p/util.c b/gnu/usr.bin/perl/x2p/util.c
deleted file mode 100644
index 70a6cd7..0000000
--- a/gnu/usr.bin/perl/x2p/util.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/* $RCSfile: util.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:55 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: util.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:55 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:10 nate
- * PERL!
- *
- * Revision 4.0.1.1 91/06/07 12:20:35 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:58:25 lwall
- * 4.0 baseline.
- *
- */
-
-#include <stdio.h>
-
-#include "handy.h"
-#include "EXTERN.h"
-#include "a2p.h"
-#include "INTERN.h"
-#include "util.h"
-
-#define FLUSH
-#define MEM_SIZE unsigned int
-
-static char nomem[] = "Out of memory!\n";
-
-/* paranoid version of malloc */
-
-static int an = 0;
-
-char *
-safemalloc(size)
-MEM_SIZE size;
-{
- char *ptr;
- char *malloc();
-
- ptr = malloc(size?size:1); /* malloc(0) is NASTY on our system */
-#ifdef DEBUGGING
- if (debug & 128)
- fprintf(stderr,"0x%x: (%05d) malloc %d bytes\n",ptr,an++,size);
-#endif
- if (ptr != Nullch)
- return ptr;
- else {
- fputs(nomem,stdout) FLUSH;
- exit(1);
- }
- /*NOTREACHED*/
-}
-
-/* paranoid version of realloc */
-
-char *
-saferealloc(where,size)
-char *where;
-MEM_SIZE size;
-{
- char *ptr;
- char *realloc();
-
- ptr = realloc(where,size?size:1); /* realloc(0) is NASTY on our system */
-#ifdef DEBUGGING
- if (debug & 128) {
- fprintf(stderr,"0x%x: (%05d) rfree\n",where,an++);
- fprintf(stderr,"0x%x: (%05d) realloc %d bytes\n",ptr,an++,size);
- }
-#endif
- if (ptr != Nullch)
- return ptr;
- else {
- fputs(nomem,stdout) FLUSH;
- exit(1);
- }
- /*NOTREACHED*/
-}
-
-/* safe version of free */
-
-safefree(where)
-char *where;
-{
-#ifdef DEBUGGING
- if (debug & 128)
- fprintf(stderr,"0x%x: (%05d) free\n",where,an++);
-#endif
- free(where);
-}
-
-/* safe version of string copy */
-
-char *
-safecpy(to,from,len)
-char *to;
-register char *from;
-register int len;
-{
- register char *dest = to;
-
- if (from != Nullch)
- for (len--; len && (*dest++ = *from++); len--) ;
- *dest = '\0';
- return to;
-}
-
-/* copy a string up to some (non-backslashed) delimiter, if any */
-
-char *
-cpytill(to,from,delim)
-register char *to, *from;
-register int delim;
-{
- for (; *from; from++,to++) {
- if (*from == '\\') {
- if (from[1] == delim)
- from++;
- else if (from[1] == '\\')
- *to++ = *from++;
- }
- else if (*from == delim)
- break;
- *to = *from;
- }
- *to = '\0';
- return from;
-}
-
-
-char *
-cpy2(to,from,delim)
-register char *to, *from;
-register int delim;
-{
- for (; *from; from++,to++) {
- if (*from == '\\')
- *to++ = *from++;
- else if (*from == '$')
- *to++ = '\\';
- else if (*from == delim)
- break;
- *to = *from;
- }
- *to = '\0';
- return from;
-}
-
-/* return ptr to little string in big string, NULL if not found */
-
-char *
-instr(big, little)
-char *big, *little;
-
-{
- register char *t, *s, *x;
-
- for (t = big; *t; t++) {
- for (x=t,s=little; *s; x++,s++) {
- if (!*x)
- return Nullch;
- if (*s != *x)
- break;
- }
- if (!*s)
- return t;
- }
- return Nullch;
-}
-
-/* copy a string to a safe spot */
-
-char *
-savestr(str)
-char *str;
-{
- register char *newaddr = safemalloc((MEM_SIZE)(strlen(str)+1));
-
- (void)strcpy(newaddr,str);
- return newaddr;
-}
-
-/* grow a static string to at least a certain length */
-
-void
-growstr(strptr,curlen,newlen)
-char **strptr;
-int *curlen;
-int newlen;
-{
- if (newlen > *curlen) { /* need more room? */
- if (*curlen)
- *strptr = saferealloc(*strptr,(MEM_SIZE)newlen);
- else
- *strptr = safemalloc((MEM_SIZE)newlen);
- *curlen = newlen;
- }
-}
-
-/*VARARGS1*/
-fatal(pat,a1,a2,a3,a4)
-char *pat;
-{
- fprintf(stderr,pat,a1,a2,a3,a4);
- exit(1);
-}
-
-/*VARARGS1*/
-warn(pat,a1,a2,a3,a4)
-char *pat;
-{
- fprintf(stderr,pat,a1,a2,a3,a4);
-}
-
-static bool firstsetenv = TRUE;
-extern char **environ;
-
-void
-setenv(nam,val)
-char *nam, *val;
-{
- register int i=envix(nam); /* where does it go? */
-
- if (!environ[i]) { /* does not exist yet */
- if (firstsetenv) { /* need we copy environment? */
- int j;
-#ifndef lint
- char **tmpenv = (char**) /* point our wand at memory */
- safemalloc((i+2) * sizeof(char*));
-#else
- char **tmpenv = Null(char **);
-#endif /* lint */
-
- firstsetenv = FALSE;
- for (j=0; j<i; j++) /* copy environment */
- tmpenv[j] = environ[j];
- environ = tmpenv; /* tell exec where it is now */
- }
-#ifndef lint
- else
- environ = (char**) saferealloc((char*) environ,
- (i+2) * sizeof(char*));
- /* just expand it a bit */
-#endif /* lint */
- environ[i+1] = Nullch; /* make sure it's null terminated */
- }
- environ[i] = safemalloc(strlen(nam) + strlen(val) + 2);
- /* this may or may not be in */
- /* the old environ structure */
- sprintf(environ[i],"%s=%s",nam,val);/* all that work just for this */
-}
-
-int
-envix(nam)
-char *nam;
-{
- register int i, len = strlen(nam);
-
- for (i = 0; environ[i]; i++) {
- if (strnEQ(environ[i],nam,len) && environ[i][len] == '=')
- break; /* strnEQ must come first to avoid */
- } /* potential SEGV's */
- return i;
-}
diff --git a/gnu/usr.bin/perl/x2p/util.h b/gnu/usr.bin/perl/x2p/util.h
deleted file mode 100644
index 17a689a..0000000
--- a/gnu/usr.bin/perl/x2p/util.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* $RCSfile: util.h,v $$Revision: 1.2 $$Date: 1995/05/30 05:03:46 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: util.h,v $
- * Revision 1.2 1995/05/30 05:03:46 rgrimes
- * Remove trailing whitespace.
- *
- * Revision 1.1.1.1 1994/09/10 06:27:55 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:10 nate
- * PERL!
- *
- * Revision 4.0.1.2 91/11/05 19:21:20 lwall
- * patch11: various portability fixes
- *
- * Revision 4.0.1.1 91/06/07 12:20:43 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:58:29 lwall
- * 4.0 baseline.
- *
- */
-
-/* is the string for makedir a directory name or a filename? */
-
-#define fatal Myfatal
-
-#define MD_DIR 0
-#define MD_FILE 1
-
-void util_init();
-int doshell();
-char *safemalloc();
-char *saferealloc();
-char *safecpy();
-char *safecat();
-char *cpytill();
-char *cpy2();
-char *instr();
-#ifdef SETUIDGID
- int eaccess();
-#endif
-char *getwd();
-void cat();
-void prexit();
-char *get_a_line();
-char *savestr();
-int makedir();
-int envix();
-void notincl();
-char *getval();
-void growstr();
-void setdef();
diff --git a/gnu/usr.bin/perl/x2p/walk.c b/gnu/usr.bin/perl/x2p/walk.c
deleted file mode 100644
index c7e5e44..0000000
--- a/gnu/usr.bin/perl/x2p/walk.c
+++ /dev/null
@@ -1,2089 +0,0 @@
-/* $RCSfile: walk.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:55 $
- *
- * Copyright (c) 1991, Larry Wall
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: walk.c,v $
- * Revision 1.1.1.1 1994/09/10 06:27:55 gclarkii
- * Initial import of Perl 4.046 bmaked
- *
- * Revision 1.1.1.1 1993/08/23 21:30:11 nate
- * PERL!
- *
- * Revision 4.0.1.3 92/06/08 17:33:46 lwall
- * patch20: in a2p, simplified the filehandle model
- * patch20: in a2p, made RS="" translate to $/ = "\n\n"
- * patch20: in a2p, do {...} while ... was missing some reconstruction code
- * patch20: in a2p, getline should allow variable to be array element
- *
- * Revision 4.0.1.2 91/11/05 19:25:09 lwall
- * patch11: in a2p, split on whitespace produced extra null field
- *
- * Revision 4.0.1.1 91/06/07 12:22:04 lwall
- * patch4: new copyright notice
- * patch4: a2p didn't correctly implement -n switch
- *
- * Revision 4.0 91/03/20 01:58:36 lwall
- * 4.0 baseline.
- *
- */
-
-#include "handy.h"
-#include "EXTERN.h"
-#include "util.h"
-#include "a2p.h"
-
-bool exitval = FALSE;
-bool realexit = FALSE;
-bool saw_getline = FALSE;
-bool subretnum = FALSE;
-bool saw_FNR = FALSE;
-bool saw_argv0 = FALSE;
-bool saw_fh = FALSE;
-int maxtmp = 0;
-char *lparen;
-char *rparen;
-char *limit;
-STR *subs;
-STR *curargs = Nullstr;
-
-STR *
-walk(useval,level,node,numericptr,minprec)
-int useval;
-int level;
-register int node;
-int *numericptr;
-int minprec; /* minimum precedence without parens */
-{
- register int len;
- register STR *str;
- register int type;
- register int i;
- register STR *tmpstr;
- STR *tmp2str;
- STR *tmp3str;
- char *t;
- char *d, *s;
- int numarg;
- int numeric = FALSE;
- STR *fstr;
- int prec = P_MAX; /* assume no parens needed */
- char *index();
-
- if (!node) {
- *numericptr = 0;
- return str_make("");
- }
- type = ops[node].ival;
- len = type >> 8;
- type &= 255;
- switch (type) {
- case OPROG:
- arymax = 0;
- if (namelist) {
- while (isalpha(*namelist)) {
- for (d = tokenbuf,s=namelist;
- isalpha(*s) || isdigit(*s) || *s == '_';
- *d++ = *s++) ;
- *d = '\0';
- while (*s && !isalpha(*s)) s++;
- namelist = s;
- nameary[++arymax] = savestr(tokenbuf);
- }
- }
- if (maxfld < arymax)
- maxfld = arymax;
- opens = str_new(0);
- subs = str_new(0);
- str = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- if (do_split && need_entire && !absmaxfld)
- split_to_array = TRUE;
- if (do_split && split_to_array)
- set_array_base = TRUE;
- if (set_array_base) {
- str_cat(str,"$[ = 1;\t\t\t# set array base to 1\n");
- }
- if (fswitch && !const_FS)
- const_FS = fswitch;
- if (saw_FS > 1 || saw_RS)
- const_FS = 0;
- if (saw_ORS && need_entire)
- do_chop = TRUE;
- if (fswitch) {
- str_cat(str,"$FS = '");
- if (index("*+?.[]()|^$\\",fswitch))
- str_cat(str,"\\");
- sprintf(tokenbuf,"%c",fswitch);
- str_cat(str,tokenbuf);
- str_cat(str,"';\t\t# field separator from -F switch\n");
- }
- else if (saw_FS && !const_FS) {
- str_cat(str,"$FS = ' ';\t\t# set field separator\n");
- }
- if (saw_OFS) {
- str_cat(str,"$, = ' ';\t\t# set output field separator\n");
- }
- if (saw_ORS) {
- str_cat(str,"$\\ = \"\\n\";\t\t# set output record separator\n");
- }
- if (saw_argv0) {
- str_cat(str,"$ARGV0 = $0;\t\t# remember what we ran as\n");
- }
- if (str->str_cur > 20)
- str_cat(str,"\n");
- if (ops[node+2].ival) {
- str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,"\n\n");
- }
- fstr = walk(0,level+1,ops[node+3].ival,&numarg,P_MIN);
- if (*fstr->str_ptr) {
- if (saw_line_op)
- str_cat(str,"line: ");
- str_cat(str,"while (<>) {\n");
- tab(str,++level);
- if (saw_FS && !const_FS)
- do_chop = TRUE;
- if (do_chop) {
- str_cat(str,"chop;\t# strip record separator\n");
- tab(str,level);
- }
- if (do_split)
- emit_split(str,level);
- str_scat(str,fstr);
- str_free(fstr);
- fixtab(str,--level);
- str_cat(str,"}\n");
- if (saw_FNR)
- str_cat(str,"continue {\n $FNRbase = $. if eof;\n}\n");
- }
- else
- str_cat(str,"while (<>) { } # (no line actions)\n");
- if (ops[node+4].ival) {
- realexit = TRUE;
- str_cat(str,"\n");
- tab(str,level);
- str_scat(str,fstr=walk(0,level,ops[node+4].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,"\n");
- }
- if (exitval)
- str_cat(str,"exit $ExitValue;\n");
- if (subs->str_ptr) {
- str_cat(str,"\n");
- str_scat(str,subs);
- }
- if (saw_getline) {
- for (len = 0; len < 4; len++) {
- if (saw_getline & (1 << len)) {
- sprintf(tokenbuf,"\nsub Getline%d {\n",len);
- str_cat(str, tokenbuf);
- if (len & 2) {
- if (do_fancy_opens)
- str_cat(str," &Pick('',@_);\n");
- else
- str_cat(str," ($fh) = @_;\n");
- }
- else {
- if (saw_FNR)
- str_cat(str," $FNRbase = $. if eof;\n");
- }
- if (len & 1)
- str_cat(str," local($_);\n");
- if (len & 2)
- str_cat(str,
- " if ($getline_ok = (($_ = <$fh>) ne ''))");
- else
- str_cat(str,
- " if ($getline_ok = (($_ = <>) ne ''))");
- str_cat(str, " {\n");
- level += 2;
- tab(str,level);
- i = 0;
- if (do_chop) {
- i++;
- str_cat(str,"chop;\t# strip record separator\n");
- tab(str,level);
- }
- if (do_split && !(len & 1)) {
- i++;
- emit_split(str,level);
- }
- if (!i)
- str_cat(str,";\n");
- fixtab(str,--level);
- str_cat(str,"}\n $_;\n}\n");
- --level;
- }
- }
- }
- if (do_fancy_opens) {
- str_cat(str,"\n\
-sub Pick {\n\
- local($mode,$name,$pipe) = @_;\n\
- $fh = $name;\n\
- open($name,$mode.$name.$pipe) unless $opened{$name}++;\n\
-}\n\
-");
- }
- break;
- case OHUNKS:
- str = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- if (len == 3) {
- str_scat(str,fstr=walk(0,level,ops[node+3].ival,&numarg,P_MIN));
- str_free(fstr);
- }
- else {
- }
- break;
- case ORANGE:
- prec = P_DOTDOT;
- str = walk(1,level,ops[node+1].ival,&numarg,prec+1);
- str_cat(str," .. ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- break;
- case OPAT:
- goto def;
- case OREGEX:
- str = str_new(0);
- str_set(str,"/");
- tmpstr=walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- /* translate \nnn to [\nnn] */
- for (s = tmpstr->str_ptr, d = tokenbuf; *s; s++, d++) {
- if (*s == '\\' && isdigit(s[1]) && isdigit(s[2]) && isdigit(s[3])){
- *d++ = '[';
- *d++ = *s++;
- *d++ = *s++;
- *d++ = *s++;
- *d++ = *s;
- *d = ']';
- }
- else
- *d = *s;
- }
- *d = '\0';
- for (d=tokenbuf; *d; d++)
- *d += 128;
- str_cat(str,tokenbuf);
- str_free(tmpstr);
- str_cat(str,"/");
- break;
- case OHUNK:
- if (len == 1) {
- str = str_new(0);
- str = walk(0,level,oper1(OPRINT,0),&numarg,P_MIN);
- str_cat(str," if ");
- str_scat(str,fstr=walk(0,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,";");
- }
- else {
- tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- if (*tmpstr->str_ptr) {
- str = str_new(0);
- str_set(str,"if (");
- str_scat(str,tmpstr);
- str_cat(str,") {\n");
- tab(str,++level);
- str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- fixtab(str,--level);
- str_cat(str,"}\n");
- tab(str,level);
- }
- else {
- str = walk(0,level,ops[node+2].ival,&numarg,P_MIN);
- }
- }
- break;
- case OPPAREN:
- str = str_new(0);
- str_set(str,"(");
- str_scat(str,fstr=walk(useval != 0,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,")");
- break;
- case OPANDAND:
- prec = P_ANDAND;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- str_cat(str," && ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1));
- str_free(fstr);
- break;
- case OPOROR:
- prec = P_OROR;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- str_cat(str," || ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1));
- str_free(fstr);
- break;
- case OPNOT:
- prec = P_UNARY;
- str = str_new(0);
- str_set(str,"!");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,prec));
- str_free(fstr);
- break;
- case OCOND:
- prec = P_COND;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- str_cat(str," ? ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- str_cat(str," : ");
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1));
- str_free(fstr);
- break;
- case OCPAREN:
- str = str_new(0);
- str_set(str,"(");
- str_scat(str,fstr=walk(useval != 0,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- numeric |= numarg;
- str_cat(str,")");
- break;
- case OCANDAND:
- prec = P_ANDAND;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- numeric = 1;
- str_cat(str," && ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1));
- str_free(fstr);
- break;
- case OCOROR:
- prec = P_OROR;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- numeric = 1;
- str_cat(str," || ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1));
- str_free(fstr);
- break;
- case OCNOT:
- prec = P_UNARY;
- str = str_new(0);
- str_set(str,"!");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,prec));
- str_free(fstr);
- numeric = 1;
- break;
- case ORELOP:
- prec = P_REL;
- str = walk(1,level,ops[node+2].ival,&numarg,prec+1);
- numeric |= numarg;
- tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- tmp2str = walk(1,level,ops[node+3].ival,&numarg,prec+1);
- numeric |= numarg;
- if (!numeric ||
- (!numarg && (*tmp2str->str_ptr == '"' || *tmp2str->str_ptr == '\''))) {
- t = tmpstr->str_ptr;
- if (strEQ(t,"=="))
- str_set(tmpstr,"eq");
- else if (strEQ(t,"!="))
- str_set(tmpstr,"ne");
- else if (strEQ(t,"<"))
- str_set(tmpstr,"lt");
- else if (strEQ(t,"<="))
- str_set(tmpstr,"le");
- else if (strEQ(t,">"))
- str_set(tmpstr,"gt");
- else if (strEQ(t,">="))
- str_set(tmpstr,"ge");
- if (!index(tmpstr->str_ptr,'\'') && !index(tmpstr->str_ptr,'"') &&
- !index(tmp2str->str_ptr,'\'') && !index(tmp2str->str_ptr,'"') )
- numeric |= 2;
- }
- if (numeric & 2) {
- if (numeric & 1) /* numeric is very good guess */
- str_cat(str," ");
- else
- str_cat(str,"\377");
- numeric = 1;
- }
- else
- str_cat(str," ");
- str_scat(str,tmpstr);
- str_free(tmpstr);
- str_cat(str," ");
- str_scat(str,tmp2str);
- str_free(tmp2str);
- numeric = 1;
- break;
- case ORPAREN:
- str = str_new(0);
- str_set(str,"(");
- str_scat(str,fstr=walk(useval != 0,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- numeric |= numarg;
- str_cat(str,")");
- break;
- case OMATCHOP:
- prec = P_MATCH;
- str = walk(1,level,ops[node+2].ival,&numarg,prec+1);
- str_cat(str," ");
- tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- if (strEQ(tmpstr->str_ptr,"~"))
- str_cat(str,"=~");
- else {
- str_scat(str,tmpstr);
- str_free(tmpstr);
- }
- str_cat(str," ");
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1));
- str_free(fstr);
- numeric = 1;
- break;
- case OMPAREN:
- str = str_new(0);
- str_set(str,"(");
- str_scat(str,
- fstr=walk(useval != 0,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- numeric |= numarg;
- str_cat(str,")");
- break;
- case OCONCAT:
- prec = P_ADD;
- type = ops[ops[node+1].ival].ival & 255;
- str = walk(1,level,ops[node+1].ival,&numarg,prec+(type != OCONCAT));
- str_cat(str," . ");
- type = ops[ops[node+2].ival].ival & 255;
- str_scat(str,
- fstr=walk(1,level,ops[node+2].ival,&numarg,prec+(type != OCONCAT)));
- str_free(fstr);
- break;
- case OASSIGN:
- prec = P_ASSIGN;
- str = walk(0,level,ops[node+2].ival,&numarg,prec+1);
- str_cat(str," ");
- tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- str_scat(str,tmpstr);
- if (str_len(tmpstr) > 1)
- numeric = 1;
- str_free(tmpstr);
- str_cat(str," ");
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec));
- str_free(fstr);
- numeric |= numarg;
- if (strEQ(str->str_ptr,"$/ = ''"))
- str_set(str, "$/ = \"\\n\\n\"");
- break;
- case OADD:
- prec = P_ADD;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- str_cat(str," + ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- numeric = 1;
- break;
- case OSUBTRACT:
- prec = P_ADD;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- str_cat(str," - ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- numeric = 1;
- break;
- case OMULT:
- prec = P_MUL;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- str_cat(str," * ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- numeric = 1;
- break;
- case ODIV:
- prec = P_MUL;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- str_cat(str," / ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- numeric = 1;
- break;
- case OPOW:
- prec = P_POW;
- str = walk(1,level,ops[node+1].ival,&numarg,prec+1);
- str_cat(str," ** ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec));
- str_free(fstr);
- numeric = 1;
- break;
- case OMOD:
- prec = P_MUL;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- str_cat(str," % ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1));
- str_free(fstr);
- numeric = 1;
- break;
- case OPOSTINCR:
- prec = P_AUTO;
- str = walk(1,level,ops[node+1].ival,&numarg,prec+1);
- str_cat(str,"++");
- numeric = 1;
- break;
- case OPOSTDECR:
- prec = P_AUTO;
- str = walk(1,level,ops[node+1].ival,&numarg,prec+1);
- str_cat(str,"--");
- numeric = 1;
- break;
- case OPREINCR:
- prec = P_AUTO;
- str = str_new(0);
- str_set(str,"++");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,prec+1));
- str_free(fstr);
- numeric = 1;
- break;
- case OPREDECR:
- prec = P_AUTO;
- str = str_new(0);
- str_set(str,"--");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,prec+1));
- str_free(fstr);
- numeric = 1;
- break;
- case OUMINUS:
- prec = P_UNARY;
- str = str_new(0);
- str_set(str,"-");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,prec));
- str_free(fstr);
- numeric = 1;
- break;
- case OUPLUS:
- numeric = 1;
- goto def;
- case OPAREN:
- str = str_new(0);
- str_set(str,"(");
- str_scat(str,
- fstr=walk(useval != 0,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,")");
- numeric |= numarg;
- break;
- case OGETLINE:
- str = str_new(0);
- if (useval)
- str_cat(str,"(");
- if (len > 0) {
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- if (!*fstr->str_ptr) {
- str_cat(str,"$_");
- len = 2; /* a legal fiction */
- }
- str_free(fstr);
- }
- else
- str_cat(str,"$_");
- if (len > 1) {
- tmpstr=walk(1,level,ops[node+3].ival,&numarg,P_MIN);
- fstr=walk(1,level,ops[node+2].ival,&numarg,P_MIN);
- if (!do_fancy_opens) {
- t = tmpstr->str_ptr;
- if (*t == '"' || *t == '\'')
- t = cpytill(tokenbuf,t+1,*t);
- else
- fatal("Internal error: OGETLINE %s", t);
- d = savestr(t);
- s = savestr(tokenbuf);
- for (t = tokenbuf; *t; t++) {
- *t &= 127;
- if (islower(*t))
- *t = toupper(*t);
- if (!isalpha(*t) && !isdigit(*t))
- *t = '_';
- }
- if (!index(tokenbuf,'_'))
- strcpy(t,"_FH");
- tmp3str = hfetch(symtab,tokenbuf);
- if (!tmp3str) {
- do_opens = TRUE;
- str_cat(opens,"open(");
- str_cat(opens,tokenbuf);
- str_cat(opens,", ");
- d[1] = '\0';
- str_cat(opens,d);
- str_cat(opens,tmpstr->str_ptr+1);
- opens->str_cur--;
- if (*fstr->str_ptr == '|')
- str_cat(opens,"|");
- str_cat(opens,d);
- if (*fstr->str_ptr == '|')
- str_cat(opens,") || die 'Cannot pipe from \"");
- else
- str_cat(opens,") || die 'Cannot open file \"");
- if (*d == '"')
- str_cat(opens,"'.\"");
- str_cat(opens,s);
- if (*d == '"')
- str_cat(opens,"\".'");
- str_cat(opens,"\".';\n");
- hstore(symtab,tokenbuf,str_make("x"));
- }
- safefree(s);
- safefree(d);
- str_set(tmpstr,"'");
- str_cat(tmpstr,tokenbuf);
- str_cat(tmpstr,"'");
- }
- if (*fstr->str_ptr == '|')
- str_cat(tmpstr,", '|'");
- str_free(fstr);
- }
- else
- tmpstr = str_make("");
- sprintf(tokenbuf," = &Getline%d(%s)",len,tmpstr->str_ptr);
- str_cat(str,tokenbuf);
- str_free(tmpstr);
- if (useval)
- str_cat(str,",$getline_ok)");
- saw_getline |= 1 << len;
- break;
- case OSPRINTF:
- str = str_new(0);
- str_set(str,"sprintf(");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,")");
- break;
- case OSUBSTR:
- str = str_new(0);
- str_set(str,"substr(");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_COMMA+1));
- str_free(fstr);
- str_cat(str,", ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_COMMA+1));
- str_free(fstr);
- str_cat(str,", ");
- if (len == 3) {
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,P_COMMA+1));
- str_free(fstr);
- }
- else
- str_cat(str,"999999");
- str_cat(str,")");
- break;
- case OSTRING:
- str = str_new(0);
- str_set(str,ops[node+1].cval);
- break;
- case OSPLIT:
- str = str_new(0);
- limit = ", 9999)";
- numeric = 1;
- tmpstr = walk(1,level,ops[node+2].ival,&numarg,P_MIN);
- if (useval)
- str_set(str,"(@");
- else
- str_set(str,"@");
- str_scat(str,tmpstr);
- str_cat(str," = split(");
- if (len == 3) {
- fstr = walk(1,level,ops[node+3].ival,&numarg,P_COMMA+1);
- if (str_len(fstr) == 3 && *fstr->str_ptr == '\'') {
- i = fstr->str_ptr[1] & 127;
- if (index("*+?.[]()|^$\\",i))
- sprintf(tokenbuf,"/\\%c/",i);
- else if (i == ' ')
- sprintf(tokenbuf,"' '");
- else
- sprintf(tokenbuf,"/%c/",i);
- str_cat(str,tokenbuf);
- }
- else
- str_scat(str,fstr);
- str_free(fstr);
- }
- else if (const_FS) {
- sprintf(tokenbuf,"/[%c\\n]/",const_FS);
- str_cat(str,tokenbuf);
- }
- else if (saw_FS)
- str_cat(str,"$FS");
- else {
- str_cat(str,"' '");
- limit = ")";
- }
- str_cat(str,", ");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_COMMA+1));
- str_free(fstr);
- str_cat(str,limit);
- if (useval) {
- str_cat(str,")");
- }
- str_free(tmpstr);
- break;
- case OINDEX:
- str = str_new(0);
- str_set(str,"index(");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_COMMA+1));
- str_free(fstr);
- str_cat(str,", ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_COMMA+1));
- str_free(fstr);
- str_cat(str,")");
- numeric = 1;
- break;
- case OMATCH:
- str = str_new(0);
- prec = P_ANDAND;
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MATCH+1));
- str_free(fstr);
- str_cat(str," =~ ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_MATCH+1));
- str_free(fstr);
- str_cat(str," && ($RLENGTH = length($&), $RSTART = length($`)+1)");
- numeric = 1;
- break;
- case OUSERDEF:
- str = str_new(0);
- subretnum = FALSE;
- fstr=walk(1,level-1,ops[node+2].ival,&numarg,P_MIN);
- curargs = str_new(0);
- str_sset(curargs,fstr);
- str_cat(curargs,",");
- tmp2str=walk(1,level,ops[node+5].ival,&numarg,P_MIN);
- str_free(curargs);
- curargs = Nullstr;
- level--;
- subretnum |= numarg;
- s = Nullch;
- t = tmp2str->str_ptr;
- while (t = instr(t,"return "))
- s = t++;
- if (s) {
- i = 0;
- for (t = s+7; *t; t++) {
- if (*t == ';' || *t == '}')
- i++;
- }
- if (i == 1) {
- strcpy(s,s+7);
- tmp2str->str_cur -= 7;
- }
- }
- str_set(str,"\n");
- tab(str,level);
- str_cat(str,"sub ");
- str_scat(str,tmpstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- str_cat(str," {\n");
- tab(str,++level);
- if (fstr->str_cur) {
- str_cat(str,"local(");
- str_scat(str,fstr);
- str_cat(str,") = @_;");
- }
- str_free(fstr);
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,P_MIN));
- str_free(fstr);
- fixtab(str,level);
- str_scat(str,fstr=walk(1,level,ops[node+4].ival,&numarg,P_MIN));
- str_free(fstr);
- fixtab(str,level);
- str_scat(str,tmp2str);
- str_free(tmp2str);
- fixtab(str,--level);
- str_cat(str,"}\n");
- tab(str,level);
- str_scat(subs,str);
- str_set(str,"");
- str_cat(tmpstr,"(");
- tmp2str = str_new(0);
- if (subretnum)
- str_set(tmp2str,"1");
- hstore(symtab,tmpstr->str_ptr,tmp2str);
- str_free(tmpstr);
- level++;
- break;
- case ORETURN:
- str = str_new(0);
- if (len > 0) {
- str_cat(str,"return ");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_UNI+1));
- str_free(fstr);
- if (numarg)
- subretnum = TRUE;
- }
- else
- str_cat(str,"return");
- break;
- case OUSERFUN:
- str = str_new(0);
- str_set(str,"&");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,"(");
- tmpstr = hfetch(symtab,str->str_ptr+3);
- if (tmpstr && tmpstr->str_ptr)
- numeric |= atoi(tmpstr->str_ptr);
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,")");
- break;
- case OGSUB:
- case OSUB:
- if (type == OGSUB)
- s = "g";
- else
- s = "";
- str = str_new(0);
- tmpstr = str_new(0);
- i = 0;
- if (len == 3) {
- tmpstr = walk(1,level,ops[node+3].ival,&numarg,P_MATCH+1);
- if (strNE(tmpstr->str_ptr,"$_")) {
- str_cat(tmpstr, " =~ s");
- i++;
- }
- else
- str_set(tmpstr, "s");
- }
- else
- str_set(tmpstr, "s");
- type = ops[ops[node+2].ival].ival;
- len = type >> 8;
- type &= 255;
- tmp3str = str_new(0);
- if (type == OSTR) {
- tmp2str=walk(1,level,ops[ops[node+2].ival+1].ival,&numarg,P_MIN);
- for (t = tmp2str->str_ptr, d=tokenbuf; *t; d++,t++) {
- if (*t == '&')
- *d++ = '$' + 128;
- else if (*t == '$')
- *d++ = '\\' + 128;
- *d = *t + 128;
- }
- *d = '\0';
- str_set(tmp2str,tokenbuf);
- }
- else {
- tmp2str=walk(1,level,ops[node+2].ival,&numarg,P_MIN);
- str_set(tmp3str,"($s_ = '\"'.(");
- str_scat(tmp3str,tmp2str);
- str_cat(tmp3str,").'\"') =~ s/&/\\$&/g, ");
- str_set(tmp2str,"eval $s_");
- s = (*s == 'g' ? "ge" : "e");
- i++;
- }
- type = ops[ops[node+1].ival].ival;
- len = type >> 8;
- type &= 255;
- fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN);
- if (type == OREGEX) {
- if (useval && i)
- str_cat(str,"(");
- str_scat(str,tmp3str);
- str_scat(str,tmpstr);
- str_scat(str,fstr);
- str_scat(str,tmp2str);
- str_cat(str,"/");
- str_cat(str,s);
- }
- else if ((type == OFLD && !split_to_array) || (type == OVAR && len == 1)) {
- if (useval && i)
- str_cat(str,"(");
- str_scat(str,tmp3str);
- str_scat(str,tmpstr);
- str_cat(str,"/");
- str_scat(str,fstr);
- str_cat(str,"/");
- str_scat(str,tmp2str);
- str_cat(str,"/");
- str_cat(str,s);
- }
- else {
- i++;
- if (useval)
- str_cat(str,"(");
- str_cat(str,"$s = ");
- str_scat(str,fstr);
- str_cat(str,", ");
- str_scat(str,tmp3str);
- str_scat(str,tmpstr);
- str_cat(str,"/$s/");
- str_scat(str,tmp2str);
- str_cat(str,"/");
- str_cat(str,s);
- }
- if (useval && i)
- str_cat(str,")");
- str_free(fstr);
- str_free(tmpstr);
- str_free(tmp2str);
- str_free(tmp3str);
- numeric = 1;
- break;
- case ONUM:
- str = walk(1,level,ops[node+1].ival,&numarg,P_MIN);
- numeric = 1;
- break;
- case OSTR:
- tmpstr = walk(1,level,ops[node+1].ival,&numarg,P_MIN);
- s = "'";
- for (t = tmpstr->str_ptr, d=tokenbuf; *t; d++,t++) {
- if (*t == '\'')
- s = "\"";
- else if (*t == '\\') {
- s = "\"";
- *d++ = *t++ + 128;
- switch (*t) {
- case '\\': case '"': case 'n': case 't': case '$':
- break;
- default: /* hide this from perl */
- *d++ = '\\' + 128;
- }
- }
- *d = *t + 128;
- }
- *d = '\0';
- str = str_new(0);
- str_set(str,s);
- str_cat(str,tokenbuf);
- str_free(tmpstr);
- str_cat(str,s);
- break;
- case ODEFINED:
- prec = P_UNI;
- str = str_new(0);
- str_set(str,"defined $");
- goto addvar;
- case ODELETE:
- str = str_new(0);
- str_set(str,"delete $");
- goto addvar;
- case OSTAR:
- str = str_new(0);
- str_set(str,"*");
- goto addvar;
- case OVAR:
- str = str_new(0);
- str_set(str,"$");
- addvar:
- str_scat(str,tmpstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- if (len == 1) {
- tmp2str = hfetch(symtab,tmpstr->str_ptr);
- if (tmp2str && atoi(tmp2str->str_ptr))
- numeric = 2;
- if (strEQ(str->str_ptr,"$FNR")) {
- numeric = 1;
- saw_FNR++;
- str_set(str,"($.-$FNRbase)");
- }
- else if (strEQ(str->str_ptr,"$NR")) {
- numeric = 1;
- str_set(str,"$.");
- }
- else if (strEQ(str->str_ptr,"$NF")) {
- numeric = 1;
- str_set(str,"$#Fld");
- }
- else if (strEQ(str->str_ptr,"$0"))
- str_set(str,"$_");
- else if (strEQ(str->str_ptr,"$ARGC"))
- str_set(str,"($#ARGV+1)");
- }
- else {
-#ifdef NOTDEF
- if (curargs) {
- sprintf(tokenbuf,"$%s,",tmpstr->str_ptr);
- ??? if (instr(curargs->str_ptr,tokenbuf))
- str_cat(str,"\377"); /* can't translate yet */
- }
-#endif
- str_cat(tmpstr,"[]");
- tmp2str = hfetch(symtab,tmpstr->str_ptr);
- if (tmp2str && atoi(tmp2str->str_ptr))
- str_cat(str,"[");
- else
- str_cat(str,"{");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- if (strEQ(str->str_ptr,"$ARGV[0")) {
- str_set(str,"$ARGV0");
- saw_argv0++;
- }
- else {
- if (tmp2str && atoi(tmp2str->str_ptr))
- strcpy(tokenbuf,"]");
- else
- strcpy(tokenbuf,"}");
- *tokenbuf += 128;
- str_cat(str,tokenbuf);
- }
- }
- str_free(tmpstr);
- break;
- case OFLD:
- str = str_new(0);
- if (split_to_array) {
- str_set(str,"$Fld");
- str_cat(str,"[");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,"]");
- }
- else {
- i = atoi(walk(1,level,ops[node+1].ival,&numarg,P_MIN)->str_ptr);
- if (i <= arymax)
- sprintf(tokenbuf,"$%s",nameary[i]);
- else
- sprintf(tokenbuf,"$Fld%d",i);
- str_set(str,tokenbuf);
- }
- break;
- case OVFLD:
- str = str_new(0);
- str_set(str,"$Fld[");
- i = ops[node+1].ival;
- if ((ops[i].ival & 255) == OPAREN)
- i = ops[i+1].ival;
- tmpstr=walk(1,level,i,&numarg,P_MIN);
- str_scat(str,tmpstr);
- str_free(tmpstr);
- str_cat(str,"]");
- break;
- case OJUNK:
- goto def;
- case OSNEWLINE:
- str = str_new(2);
- str_set(str,";\n");
- tab(str,level);
- break;
- case ONEWLINE:
- str = str_new(1);
- str_set(str,"\n");
- tab(str,level);
- break;
- case OSCOMMENT:
- str = str_new(0);
- str_set(str,";");
- tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- for (s = tmpstr->str_ptr; *s && *s != '\n'; s++)
- *s += 128;
- str_scat(str,tmpstr);
- str_free(tmpstr);
- tab(str,level);
- break;
- case OCOMMENT:
- str = str_new(0);
- tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- for (s = tmpstr->str_ptr; *s && *s != '\n'; s++)
- *s += 128;
- str_scat(str,tmpstr);
- str_free(tmpstr);
- tab(str,level);
- break;
- case OCOMMA:
- prec = P_COMMA;
- str = walk(1,level,ops[node+1].ival,&numarg,prec);
- str_cat(str,", ");
- str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1));
- str_free(fstr);
- break;
- case OSEMICOLON:
- str = str_new(1);
- str_set(str,";\n");
- tab(str,level);
- break;
- case OSTATES:
- str = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- break;
- case OSTATE:
- str = str_new(0);
- if (len >= 1) {
- str_scat(str,fstr=walk(0,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- if (len >= 2) {
- tmpstr = walk(0,level,ops[node+2].ival,&numarg,P_MIN);
- if (*tmpstr->str_ptr == ';') {
- addsemi(str);
- str_cat(str,tmpstr->str_ptr+1);
- }
- str_free(tmpstr);
- }
- }
- break;
- case OCLOSE:
- str = str_make("close(");
- tmpstr = walk(1,level,ops[node+1].ival,&numarg,P_MIN);
- if (!do_fancy_opens) {
- t = tmpstr->str_ptr;
- if (*t == '"' || *t == '\'')
- t = cpytill(tokenbuf,t+1,*t);
- else
- fatal("Internal error: OCLOSE %s",t);
- s = savestr(tokenbuf);
- for (t = tokenbuf; *t; t++) {
- *t &= 127;
- if (islower(*t))
- *t = toupper(*t);
- if (!isalpha(*t) && !isdigit(*t))
- *t = '_';
- }
- if (!index(tokenbuf,'_'))
- strcpy(t,"_FH");
- str_free(tmpstr);
- safefree(s);
- str_set(str,"close ");
- str_cat(str,tokenbuf);
- }
- else {
- sprintf(tokenbuf,"delete $opened{%s} && close(%s)",
- tmpstr->str_ptr, tmpstr->str_ptr);
- str_free(tmpstr);
- str_set(str,tokenbuf);
- }
- break;
- case OPRINTF:
- case OPRINT:
- lparen = ""; /* set to parens if necessary */
- rparen = "";
- str = str_new(0);
- if (len == 3) { /* output redirection */
- tmpstr = walk(1,level,ops[node+3].ival,&numarg,P_MIN);
- tmp2str = walk(1,level,ops[node+2].ival,&numarg,P_MIN);
- if (!do_fancy_opens) {
- t = tmpstr->str_ptr;
- if (*t == '"' || *t == '\'')
- t = cpytill(tokenbuf,t+1,*t);
- else
- fatal("Internal error: OPRINT");
- d = savestr(t);
- s = savestr(tokenbuf);
- for (t = tokenbuf; *t; t++) {
- *t &= 127;
- if (islower(*t))
- *t = toupper(*t);
- if (!isalpha(*t) && !isdigit(*t))
- *t = '_';
- }
- if (!index(tokenbuf,'_'))
- strcpy(t,"_FH");
- tmp3str = hfetch(symtab,tokenbuf);
- if (!tmp3str) {
- str_cat(opens,"open(");
- str_cat(opens,tokenbuf);
- str_cat(opens,", ");
- d[1] = '\0';
- str_cat(opens,d);
- str_scat(opens,tmp2str);
- str_cat(opens,tmpstr->str_ptr+1);
- if (*tmp2str->str_ptr == '|')
- str_cat(opens,") || die 'Cannot pipe to \"");
- else
- str_cat(opens,") || die 'Cannot create file \"");
- if (*d == '"')
- str_cat(opens,"'.\"");
- str_cat(opens,s);
- if (*d == '"')
- str_cat(opens,"\".'");
- str_cat(opens,"\".';\n");
- hstore(symtab,tokenbuf,str_make("x"));
- }
- str_free(tmpstr);
- str_free(tmp2str);
- safefree(s);
- safefree(d);
- }
- else {
- sprintf(tokenbuf,"&Pick('%s', %s) &&\n",
- tmp2str->str_ptr, tmpstr->str_ptr);
- str_cat(str,tokenbuf);
- tab(str,level+1);
- strcpy(tokenbuf,"$fh");
- str_free(tmpstr);
- str_free(tmp2str);
- lparen = "(";
- rparen = ")";
- }
- }
- else
- strcpy(tokenbuf,"");
- str_cat(str,lparen); /* may be null */
- if (type == OPRINTF)
- str_cat(str,"printf");
- else
- str_cat(str,"print");
- saw_fh = 0;
- if (len == 3 || do_fancy_opens) {
- if (*tokenbuf) {
- str_cat(str," ");
- saw_fh = 1;
- }
- str_cat(str,tokenbuf);
- }
- tmpstr = walk(1+(type==OPRINT),level,ops[node+1].ival,&numarg,P_MIN);
- if (!*tmpstr->str_ptr && lval_field) {
- t = saw_OFS ? "$," : "' '";
- if (split_to_array) {
- sprintf(tokenbuf,"join(%s,@Fld)",t);
- str_cat(tmpstr,tokenbuf);
- }
- else {
- for (i = 1; i < maxfld; i++) {
- if (i <= arymax)
- sprintf(tokenbuf,"$%s, ",nameary[i]);
- else
- sprintf(tokenbuf,"$Fld%d, ",i);
- str_cat(tmpstr,tokenbuf);
- }
- if (maxfld <= arymax)
- sprintf(tokenbuf,"$%s",nameary[maxfld]);
- else
- sprintf(tokenbuf,"$Fld%d",maxfld);
- str_cat(tmpstr,tokenbuf);
- }
- }
- if (*tmpstr->str_ptr) {
- str_cat(str," ");
- if (!saw_fh && *tmpstr->str_ptr == '(') {
- str_cat(str,"(");
- str_scat(str,tmpstr);
- str_cat(str,")");
- }
- else
- str_scat(str,tmpstr);
- }
- else {
- str_cat(str," $_");
- }
- str_cat(str,rparen); /* may be null */
- str_free(tmpstr);
- break;
- case ORAND:
- str = str_make("rand(1)");
- break;
- case OSRAND:
- str = str_make("srand(");
- goto maybe0;
- case OATAN2:
- str = str_make("atan2(");
- goto maybe0;
- case OSIN:
- str = str_make("sin(");
- goto maybe0;
- case OCOS:
- str = str_make("cos(");
- goto maybe0;
- case OSYSTEM:
- str = str_make("system(");
- goto maybe0;
- case OLENGTH:
- str = str_make("length(");
- goto maybe0;
- case OLOG:
- str = str_make("log(");
- goto maybe0;
- case OEXP:
- str = str_make("exp(");
- goto maybe0;
- case OSQRT:
- str = str_make("sqrt(");
- goto maybe0;
- case OINT:
- str = str_make("int(");
- maybe0:
- numeric = 1;
- if (len > 0)
- tmpstr = walk(1,level,ops[node+1].ival,&numarg,P_MIN);
- else
- tmpstr = str_new(0);;
- if (!tmpstr->str_ptr || !*tmpstr->str_ptr) {
- if (lval_field) {
- t = saw_OFS ? "$," : "' '";
- if (split_to_array) {
- sprintf(tokenbuf,"join(%s,@Fld)",t);
- str_cat(tmpstr,tokenbuf);
- }
- else {
- sprintf(tokenbuf,"join(%s, ",t);
- str_cat(tmpstr,tokenbuf);
- for (i = 1; i < maxfld; i++) {
- if (i <= arymax)
- sprintf(tokenbuf,"$%s,",nameary[i]);
- else
- sprintf(tokenbuf,"$Fld%d,",i);
- str_cat(tmpstr,tokenbuf);
- }
- if (maxfld <= arymax)
- sprintf(tokenbuf,"$%s)",nameary[maxfld]);
- else
- sprintf(tokenbuf,"$Fld%d)",maxfld);
- str_cat(tmpstr,tokenbuf);
- }
- }
- else
- str_cat(tmpstr,"$_");
- }
- if (strEQ(tmpstr->str_ptr,"$_")) {
- if (type == OLENGTH && !do_chop) {
- str = str_make("(length(");
- str_cat(tmpstr,") - 1");
- }
- }
- str_scat(str,tmpstr);
- str_free(tmpstr);
- str_cat(str,")");
- break;
- case OBREAK:
- str = str_new(0);
- str_set(str,"last");
- break;
- case ONEXT:
- str = str_new(0);
- str_set(str,"next line");
- break;
- case OEXIT:
- str = str_new(0);
- if (realexit) {
- prec = P_UNI;
- str_set(str,"exit");
- if (len == 1) {
- str_cat(str," ");
- exitval = TRUE;
- str_scat(str,
- fstr=walk(1,level,ops[node+1].ival,&numarg,prec+1));
- str_free(fstr);
- }
- }
- else {
- if (len == 1) {
- str_set(str,"$ExitValue = ");
- exitval = TRUE;
- str_scat(str,
- fstr=walk(1,level,ops[node+1].ival,&numarg,P_ASSIGN));
- str_free(fstr);
- str_cat(str,"; ");
- }
- str_cat(str,"last line");
- }
- break;
- case OCONTINUE:
- str = str_new(0);
- str_set(str,"next");
- break;
- case OREDIR:
- goto def;
- case OIF:
- str = str_new(0);
- str_set(str,"if (");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,") ");
- str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- if (len == 3) {
- i = ops[node+3].ival;
- if (i) {
- if ((ops[i].ival & 255) == OBLOCK) {
- i = ops[i+1].ival;
- if (i) {
- if ((ops[i].ival & 255) != OIF)
- i = 0;
- }
- }
- else
- i = 0;
- }
- if (i) {
- str_cat(str,"els");
- str_scat(str,fstr=walk(0,level,i,&numarg,P_MIN));
- str_free(fstr);
- }
- else {
- str_cat(str,"else ");
- str_scat(str,fstr=walk(0,level,ops[node+3].ival,&numarg,P_MIN));
- str_free(fstr);
- }
- }
- break;
- case OWHILE:
- str = str_new(0);
- str_set(str,"while (");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,") ");
- str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- break;
- case ODO:
- str = str_new(0);
- str_set(str,"do ");
- str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- if (str->str_ptr[str->str_cur - 1] == '\n')
- --str->str_cur;;
- str_cat(str," while (");
- str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,");");
- break;
- case OFOR:
- str = str_new(0);
- str_set(str,"for (");
- str_scat(str,tmpstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- i = numarg;
- if (i) {
- t = s = tmpstr->str_ptr;
- while (isalpha(*t) || isdigit(*t) || *t == '$' || *t == '_')
- t++;
- i = t - s;
- if (i < 2)
- i = 0;
- }
- str_cat(str,"; ");
- fstr=walk(1,level,ops[node+2].ival,&numarg,P_MIN);
- if (i && (t = index(fstr->str_ptr,0377))) {
- if (strnEQ(fstr->str_ptr,s,i))
- *t = ' ';
- }
- str_scat(str,fstr);
- str_free(fstr);
- str_free(tmpstr);
- str_cat(str,"; ");
- str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,P_MIN));
- str_free(fstr);
- str_cat(str,") ");
- str_scat(str,fstr=walk(0,level,ops[node+4].ival,&numarg,P_MIN));
- str_free(fstr);
- break;
- case OFORIN:
- tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- d = index(tmpstr->str_ptr,'$');
- if (!d)
- fatal("Illegal for loop: %s",tmpstr->str_ptr);
- s = index(d,'{');
- if (!s)
- s = index(d,'[');
- if (!s)
- fatal("Illegal for loop: %s",d);
- *s++ = '\0';
- for (t = s; i = *t; t++) {
- i &= 127;
- if (i == '}' || i == ']')
- break;
- }
- if (*t)
- *t = '\0';
- str = str_new(0);
- str_set(str,d+1);
- str_cat(str,"[]");
- tmp2str = hfetch(symtab,str->str_ptr);
- if (tmp2str && atoi(tmp2str->str_ptr)) {
- sprintf(tokenbuf,
- "foreach %s ($[ .. $#%s) ",
- s,
- d+1);
- }
- else {
- sprintf(tokenbuf,
- "foreach %s (keys %%%s) ",
- s,
- d+1);
- }
- str_set(str,tokenbuf);
- str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- str_free(tmpstr);
- break;
- case OBLOCK:
- str = str_new(0);
- str_set(str,"{");
- if (len >= 2 && ops[node+2].ival) {
- str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN));
- str_free(fstr);
- }
- fixtab(str,++level);
- str_scat(str,fstr=walk(0,level,ops[node+1].ival,&numarg,P_MIN));
- str_free(fstr);
- addsemi(str);
- fixtab(str,--level);
- str_cat(str,"}\n");
- tab(str,level);
- if (len >= 3) {
- str_scat(str,fstr=walk(0,level,ops[node+3].ival,&numarg,P_MIN));
- str_free(fstr);
- }
- break;
- default:
- def:
- if (len) {
- if (len > 5)
- fatal("Garbage length in walk");
- str = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- for (i = 2; i<= len; i++) {
- str_scat(str,fstr=walk(0,level,ops[node+i].ival,&numarg,P_MIN));
- str_free(fstr);
- }
- }
- else {
- str = Nullstr;
- }
- break;
- }
- if (!str)
- str = str_new(0);
-
- if (useval && prec < minprec) { /* need parens? */
- fstr = str_new(str->str_cur+2);
- str_nset(fstr,"(",1);
- str_scat(fstr,str);
- str_ncat(fstr,")",1);
- str_free(str);
- str = fstr;
- }
-
- *numericptr = numeric;
-#ifdef DEBUGGING
- if (debug & 4) {
- printf("%3d %5d %15s %d %4d ",level,node,opname[type],len,str->str_cur);
- for (t = str->str_ptr; *t && t - str->str_ptr < 40; t++)
- if (*t == '\n')
- printf("\\n");
- else if (*t == '\t')
- printf("\\t");
- else
- putchar(*t);
- putchar('\n');
- }
-#endif
- return str;
-}
-
-tab(str,lvl)
-register STR *str;
-register int lvl;
-{
- while (lvl > 1) {
- str_cat(str,"\t");
- lvl -= 2;
- }
- if (lvl)
- str_cat(str," ");
-}
-
-fixtab(str,lvl)
-register STR *str;
-register int lvl;
-{
- register char *s;
-
- /* strip trailing white space */
-
- s = str->str_ptr+str->str_cur - 1;
- while (s >= str->str_ptr && (*s == ' ' || *s == '\t' || *s == '\n'))
- s--;
- s[1] = '\0';
- str->str_cur = s + 1 - str->str_ptr;
- if (s >= str->str_ptr && *s != '\n')
- str_cat(str,"\n");
-
- tab(str,lvl);
-}
-
-addsemi(str)
-register STR *str;
-{
- register char *s;
-
- s = str->str_ptr+str->str_cur - 1;
- while (s >= str->str_ptr && (*s == ' ' || *s == '\t' || *s == '\n'))
- s--;
- if (s >= str->str_ptr && *s != ';' && *s != '}')
- str_cat(str,";");
-}
-
-emit_split(str,level)
-register STR *str;
-int level;
-{
- register int i;
-
- if (split_to_array)
- str_cat(str,"@Fld");
- else {
- str_cat(str,"(");
- for (i = 1; i < maxfld; i++) {
- if (i <= arymax)
- sprintf(tokenbuf,"$%s,",nameary[i]);
- else
- sprintf(tokenbuf,"$Fld%d,",i);
- str_cat(str,tokenbuf);
- }
- if (maxfld <= arymax)
- sprintf(tokenbuf,"$%s)",nameary[maxfld]);
- else
- sprintf(tokenbuf,"$Fld%d)",maxfld);
- str_cat(str,tokenbuf);
- }
- if (const_FS) {
- sprintf(tokenbuf," = split(/[%c\\n]/, $_, 9999);\n",const_FS);
- str_cat(str,tokenbuf);
- }
- else if (saw_FS)
- str_cat(str," = split($FS, $_, 9999);\n");
- else
- str_cat(str," = split(' ', $_, 9999);\n");
- tab(str,level);
-}
-
-prewalk(numit,level,node,numericptr)
-int numit;
-int level;
-register int node;
-int *numericptr;
-{
- register int len;
- register int type;
- register int i;
- char *t;
- char *d, *s;
- int numarg;
- int numeric = FALSE;
- STR *tmpstr;
- STR *tmp2str;
-
- if (!node) {
- *numericptr = 0;
- return 0;
- }
- type = ops[node].ival;
- len = type >> 8;
- type &= 255;
- switch (type) {
- case OPROG:
- prewalk(0,level,ops[node+1].ival,&numarg);
- if (ops[node+2].ival) {
- prewalk(0,level,ops[node+2].ival,&numarg);
- }
- ++level;
- prewalk(0,level,ops[node+3].ival,&numarg);
- --level;
- if (ops[node+3].ival) {
- prewalk(0,level,ops[node+4].ival,&numarg);
- }
- break;
- case OHUNKS:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- if (len == 3) {
- prewalk(0,level,ops[node+3].ival,&numarg);
- }
- break;
- case ORANGE:
- prewalk(1,level,ops[node+1].ival,&numarg);
- prewalk(1,level,ops[node+2].ival,&numarg);
- break;
- case OPAT:
- goto def;
- case OREGEX:
- prewalk(0,level,ops[node+1].ival,&numarg);
- break;
- case OHUNK:
- if (len == 1) {
- prewalk(0,level,ops[node+1].ival,&numarg);
- }
- else {
- i = prewalk(0,level,ops[node+1].ival,&numarg);
- if (i) {
- ++level;
- prewalk(0,level,ops[node+2].ival,&numarg);
- --level;
- }
- else {
- prewalk(0,level,ops[node+2].ival,&numarg);
- }
- }
- break;
- case OPPAREN:
- prewalk(0,level,ops[node+1].ival,&numarg);
- break;
- case OPANDAND:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- break;
- case OPOROR:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- break;
- case OPNOT:
- prewalk(0,level,ops[node+1].ival,&numarg);
- break;
- case OCPAREN:
- prewalk(0,level,ops[node+1].ival,&numarg);
- numeric |= numarg;
- break;
- case OCANDAND:
- prewalk(0,level,ops[node+1].ival,&numarg);
- numeric = 1;
- prewalk(0,level,ops[node+2].ival,&numarg);
- break;
- case OCOROR:
- prewalk(0,level,ops[node+1].ival,&numarg);
- numeric = 1;
- prewalk(0,level,ops[node+2].ival,&numarg);
- break;
- case OCNOT:
- prewalk(0,level,ops[node+1].ival,&numarg);
- numeric = 1;
- break;
- case ORELOP:
- prewalk(0,level,ops[node+2].ival,&numarg);
- numeric |= numarg;
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+3].ival,&numarg);
- numeric |= numarg;
- numeric = 1;
- break;
- case ORPAREN:
- prewalk(0,level,ops[node+1].ival,&numarg);
- numeric |= numarg;
- break;
- case OMATCHOP:
- prewalk(0,level,ops[node+2].ival,&numarg);
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+3].ival,&numarg);
- numeric = 1;
- break;
- case OMPAREN:
- prewalk(0,level,ops[node+1].ival,&numarg);
- numeric |= numarg;
- break;
- case OCONCAT:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- break;
- case OASSIGN:
- prewalk(0,level,ops[node+2].ival,&numarg);
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+3].ival,&numarg);
- if (numarg || strlen(ops[ops[node+1].ival+1].cval) > 1) {
- numericize(ops[node+2].ival);
- if (!numarg)
- numericize(ops[node+3].ival);
- }
- numeric |= numarg;
- break;
- case OADD:
- prewalk(1,level,ops[node+1].ival,&numarg);
- prewalk(1,level,ops[node+2].ival,&numarg);
- numeric = 1;
- break;
- case OSUBTRACT:
- prewalk(1,level,ops[node+1].ival,&numarg);
- prewalk(1,level,ops[node+2].ival,&numarg);
- numeric = 1;
- break;
- case OMULT:
- prewalk(1,level,ops[node+1].ival,&numarg);
- prewalk(1,level,ops[node+2].ival,&numarg);
- numeric = 1;
- break;
- case ODIV:
- prewalk(1,level,ops[node+1].ival,&numarg);
- prewalk(1,level,ops[node+2].ival,&numarg);
- numeric = 1;
- break;
- case OPOW:
- prewalk(1,level,ops[node+1].ival,&numarg);
- prewalk(1,level,ops[node+2].ival,&numarg);
- numeric = 1;
- break;
- case OMOD:
- prewalk(1,level,ops[node+1].ival,&numarg);
- prewalk(1,level,ops[node+2].ival,&numarg);
- numeric = 1;
- break;
- case OPOSTINCR:
- prewalk(1,level,ops[node+1].ival,&numarg);
- numeric = 1;
- break;
- case OPOSTDECR:
- prewalk(1,level,ops[node+1].ival,&numarg);
- numeric = 1;
- break;
- case OPREINCR:
- prewalk(1,level,ops[node+1].ival,&numarg);
- numeric = 1;
- break;
- case OPREDECR:
- prewalk(1,level,ops[node+1].ival,&numarg);
- numeric = 1;
- break;
- case OUMINUS:
- prewalk(1,level,ops[node+1].ival,&numarg);
- numeric = 1;
- break;
- case OUPLUS:
- prewalk(1,level,ops[node+1].ival,&numarg);
- numeric = 1;
- break;
- case OPAREN:
- prewalk(0,level,ops[node+1].ival,&numarg);
- numeric |= numarg;
- break;
- case OGETLINE:
- break;
- case OSPRINTF:
- prewalk(0,level,ops[node+1].ival,&numarg);
- break;
- case OSUBSTR:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(1,level,ops[node+2].ival,&numarg);
- if (len == 3) {
- prewalk(1,level,ops[node+3].ival,&numarg);
- }
- break;
- case OSTRING:
- break;
- case OSPLIT:
- numeric = 1;
- prewalk(0,level,ops[node+2].ival,&numarg);
- if (len == 3)
- prewalk(0,level,ops[node+3].ival,&numarg);
- prewalk(0,level,ops[node+1].ival,&numarg);
- break;
- case OINDEX:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- numeric = 1;
- break;
- case OMATCH:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- numeric = 1;
- break;
- case OUSERDEF:
- subretnum = FALSE;
- --level;
- tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
- ++level;
- prewalk(0,level,ops[node+2].ival,&numarg);
- prewalk(0,level,ops[node+4].ival,&numarg);
- prewalk(0,level,ops[node+5].ival,&numarg);
- --level;
- str_cat(tmpstr,"(");
- tmp2str = str_new(0);
- if (subretnum || numarg)
- str_set(tmp2str,"1");
- hstore(symtab,tmpstr->str_ptr,tmp2str);
- str_free(tmpstr);
- level++;
- break;
- case ORETURN:
- if (len > 0) {
- prewalk(0,level,ops[node+1].ival,&numarg);
- if (numarg)
- subretnum = TRUE;
- }
- break;
- case OUSERFUN:
- tmp2str = str_new(0);
- str_scat(tmp2str,tmpstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN));
- fixrargs(tmpstr->str_ptr,ops[node+2].ival,0);
- str_free(tmpstr);
- str_cat(tmp2str,"(");
- tmpstr = hfetch(symtab,tmp2str->str_ptr);
- if (tmpstr && tmpstr->str_ptr)
- numeric |= atoi(tmpstr->str_ptr);
- prewalk(0,level,ops[node+2].ival,&numarg);
- str_free(tmp2str);
- break;
- case OGSUB:
- case OSUB:
- if (len >= 3)
- prewalk(0,level,ops[node+3].ival,&numarg);
- prewalk(0,level,ops[ops[node+2].ival+1].ival,&numarg);
- prewalk(0,level,ops[node+1].ival,&numarg);
- numeric = 1;
- break;
- case ONUM:
- prewalk(0,level,ops[node+1].ival,&numarg);
- numeric = 1;
- break;
- case OSTR:
- prewalk(0,level,ops[node+1].ival,&numarg);
- break;
- case ODEFINED:
- case ODELETE:
- case OSTAR:
- case OVAR:
- prewalk(0,level,ops[node+1].ival,&numarg);
- if (len == 1) {
- if (numit)
- numericize(node);
- }
- else {
- prewalk(0,level,ops[node+2].ival,&numarg);
- }
- break;
- case OFLD:
- prewalk(0,level,ops[node+1].ival,&numarg);
- break;
- case OVFLD:
- i = ops[node+1].ival;
- prewalk(0,level,i,&numarg);
- break;
- case OJUNK:
- goto def;
- case OSNEWLINE:
- break;
- case ONEWLINE:
- break;
- case OSCOMMENT:
- break;
- case OCOMMENT:
- break;
- case OCOMMA:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- prewalk(0,level,ops[node+3].ival,&numarg);
- break;
- case OSEMICOLON:
- break;
- case OSTATES:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- break;
- case OSTATE:
- if (len >= 1) {
- prewalk(0,level,ops[node+1].ival,&numarg);
- if (len >= 2) {
- prewalk(0,level,ops[node+2].ival,&numarg);
- }
- }
- break;
- case OCLOSE:
- prewalk(0,level,ops[node+1].ival,&numarg);
- break;
- case OPRINTF:
- case OPRINT:
- if (len == 3) { /* output redirection */
- prewalk(0,level,ops[node+3].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- }
- prewalk(0+(type==OPRINT),level,ops[node+1].ival,&numarg);
- break;
- case ORAND:
- break;
- case OSRAND:
- goto maybe0;
- case OATAN2:
- goto maybe0;
- case OSIN:
- goto maybe0;
- case OCOS:
- goto maybe0;
- case OSYSTEM:
- goto maybe0;
- case OLENGTH:
- goto maybe0;
- case OLOG:
- goto maybe0;
- case OEXP:
- goto maybe0;
- case OSQRT:
- goto maybe0;
- case OINT:
- maybe0:
- numeric = 1;
- if (len > 0)
- prewalk(type != OLENGTH && type != OSYSTEM,
- level,ops[node+1].ival,&numarg);
- break;
- case OBREAK:
- break;
- case ONEXT:
- break;
- case OEXIT:
- if (len == 1) {
- prewalk(1,level,ops[node+1].ival,&numarg);
- }
- break;
- case OCONTINUE:
- break;
- case OREDIR:
- goto def;
- case OIF:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- if (len == 3) {
- prewalk(0,level,ops[node+3].ival,&numarg);
- }
- break;
- case OWHILE:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- break;
- case OFOR:
- prewalk(0,level,ops[node+1].ival,&numarg);
- prewalk(0,level,ops[node+2].ival,&numarg);
- prewalk(0,level,ops[node+3].ival,&numarg);
- prewalk(0,level,ops[node+4].ival,&numarg);
- break;
- case OFORIN:
- prewalk(0,level,ops[node+2].ival,&numarg);
- prewalk(0,level,ops[node+1].ival,&numarg);
- break;
- case OBLOCK:
- if (len == 2) {
- prewalk(0,level,ops[node+2].ival,&numarg);
- }
- ++level;
- prewalk(0,level,ops[node+1].ival,&numarg);
- --level;
- break;
- default:
- def:
- if (len) {
- if (len > 5)
- fatal("Garbage length in prewalk");
- prewalk(0,level,ops[node+1].ival,&numarg);
- for (i = 2; i<= len; i++) {
- prewalk(0,level,ops[node+i].ival,&numarg);
- }
- }
- break;
- }
- *numericptr = numeric;
- return 1;
-}
-
-numericize(node)
-register int node;
-{
- register int len;
- register int type;
- register int i;
- STR *tmpstr;
- STR *tmp2str;
- int numarg;
-
- type = ops[node].ival;
- len = type >> 8;
- type &= 255;
- if (type == OVAR && len == 1) {
- tmpstr=walk(0,0,ops[node+1].ival,&numarg,P_MIN);
- tmp2str = str_make("1");
- hstore(symtab,tmpstr->str_ptr,tmp2str);
- }
-}
diff --git a/gnu/usr.bin/ptx/COPYING b/gnu/usr.bin/ptx/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/ptx/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/ptx/ChangeLog b/gnu/usr.bin/ptx/ChangeLog
deleted file mode 100644
index fffb47f..0000000
--- a/gnu/usr.bin/ptx/ChangeLog
+++ /dev/null
@@ -1,546 +0,0 @@
-Fri Nov 5 23:10:07 1993 Francois Pinard (pinard@icule)
-
- * Version 0.3
-
- * check-out: New name for check_out.
- * Makefile.in: Change check_out for check-out everywhere.
- Reported by Jim Meyering <meyering@comco.com>.
-
- * Makefile.in (realclean): Do not remove .stamp-h.in and
- config.h.in. One should not need Autoconf installed.
- Reported by Nelson Beebe <beebe@math.utah.edu>.
-
- * ptx.c: Add missing definition of isxdigit.
- Reported by Nelson Beebe <beebe@math.utah.edu>.
-
- * ptx.c: Define S_ISREG if not defined, then use it.
- Reported by Karl Berry <karl@cs.umb.edu>.
-
-Wed Nov 3 15:53:00 1993 Francois Pinard (pinard@icule)
-
- * mkinstalldirs: New, from elsewhere.
- * Makefile.in: Use it.
-
-Mon Nov 1 00:48:34 1993 Francois Pinard (pinard@lagrande.IRO.UMontreal.CA)
-
- * Makefile.in (clean): Delete ptx, not the obsolete $(PROGS).
-
-Sun Oct 31 15:04:57 1993 Francois Pinard (pinard@raptor.IRO.UMontreal.CA)
-
- * ptx.c (alloc_and_compile_regex): Zero out the whole allocated
- pattern, not just a few fields.
-
- * ptx.c (alloc_and_compile_regex): Clarify error message.
-
-Thu Oct 28 08:29:29 1993 Francois Pinard (pinard@compy.IRO.UMontreal.CA)
-
- * ptx.c (print_copyright): Deleted. Rather use a "copyright"
- variable, print to standard output instead of standard error.
-
- * ptx.c: Use error instead of fprintf (stderr, ...).
-
- * ptx.c: Rename fold_lower_to_upper to ignore_case.
-
-Wed Oct 27 18:41:52 1993 Francois Pinard (pinard@lagrande.IRO.UMontreal.CA)
-
- * ptx.c: Add option -M for using another macro name than "xx".
- Reported by Thorsten Ohl <ohl@physics.harvard.edu>.
-
- * examples/ignore/: New files.
- * eign: Linked to examples/ignore/eign.
- * Makefile.in: Install and uninstall $(datadir)/eign.
- * configure.in: Remove testing of a default ignore file.
- Reported by Nelson Beebe <beebe@math.utah.edu>.
-
- * ptx.c (main): Add --help and --version processing.
- (print_version): Deleted.
-
- * ptx.c: Use -traditional instead of --no-gnu-extensions,
- --ignore-case instead of --fold-letter-case, --format=<format>
- instead of --tex-output and --roff-output.
- * argmatch.c: New file. Taken from fileutils/lib.
- Reported by Karl Berry <karl@cs.umb.edu>.
-
-Tue Oct 26 08:39:14 1993 Francois Pinard (pinard@icule)
-
- * ptx.c (usage): New name for usage_and_exit. Accept an exit
- status parameter. If zero, print full help on stdout. If
- non-zero, print a one-line helper on stderr.
-
- * ptx.c: Remove sizeof_occurs and OCCURS_ALIGNMENT complexity.
- The memory savings did not justify the portability headaches.
-
- * ptx.c (copy_unescaped_string): New function.
- (main): Use it with options -F, -S and -W.
- Reported by Dave Cottingham <dc@haiti.gsfc.nasa.gov>.
-
- * ptx.c (fix_output_parameters): Force edit of '\f', because some
- systems does not consider it to be whitespace.
- Reported by Stephane Berube <berube@iro.umontreal.ca>.
-
- * ptx.c (fix_output_parameters): For roff output, do not disallow
- characters with 8th bit set.
- Reported by James Clark <jjc@jclark.com>.
-
- * Makefile.in (dist): Include examples/ in distribution.
-
-Mon Oct 25 15:46:16 1993 Francois Pinard (pinard@icule)
-
- * ptx.c: Change --display-width to --width, for consistency with
- other GNU programs.
-
- * examples/ajay/: New files.
- Reported by Ajay Shah <ajayshah@cmie.ernet.in>.
- Reported by Rakesh Chauhan <rk@cmie.ernet.in>.
-
- * examples/luke/: New files.
- Reported by Luke Kendall <luke@research.canon.oz.au>.
-
- * examples/latex/: New files.
-
- * ptx.c (find_occurs_in_text): Assign 0 to refererence_length so
- GNU C will not warn anymore against its unitialized use.
- Reported by Loic Dachary <L.Dachary@cs.ucl.ac.uk>.
-
- * lib/: Move routines in main directory first, then destroy.
- * Makefile.in: Merge lib/Makefile.in, clean up.
- * configure.in: Do not create lib/Makefile.in.
-
- * acconfig.h: New file.
- * .stamp-h.in: Used for timestamping autoheader.
- * Makefile.in: Use acconfig.h and .stamp-h.in. Force
- autoheader whenever acconfig.h is modified.
-
-Wed Jun 9 15:01:28 1993 Francois Pinard (pinard@icule)
-
- * Makefile.in (dist): Replace "echo `pwd`" by a mere "pwd".
- Create a gzip file.
-
-Sat May 22 20:18:31 1993 Francois Pinard (pinard@icule)
-
- * Makefile.in: Replace $(PROGS) by ptx.
-
- * diacrit.h: Change `c' to `chr', better protect it.
-
- * lib/COPYING.LIB: Deleted.
- * lib/Makefile.in: Adjust accordingly.
-
-Sat Feb 6 15:03:13 1993 Francois Pinard (pinard@icule)
-
- * Makefile.in, lib/Makefile.in: In dist goals, ensure 777 mode for
- directories, so older tar's will restore file modes properly.
-
-Sun Jan 17 15:42:35 1993 Francois Pinard (pinard@icule)
-
- * Makefile.in, lib/Makefile.in: Put $(CFLAGS) after $(CPPFLAGS),
- so the installer can override automatically configured choices.
- Reported by Karl Berry <karl@cs.umb.edu>.
-
-Tue Jan 12 09:21:22 1993 Francois Pinard (pinard at icule)
-
- * configure.in: Check for setchrclass().
- * diacrit.[hc]: New file, extracted from my own ctype.[hc].
- * ctype.[hc]: Deleted.
- * Makefile.in: Distribute diacrit.[hc], but not ctype.[hc].
- * ptx.c: Include "diacrit.h" rather than "ctype.h".
- Include <ctype.h> for ANSI C, or else, use our own definitions.
- (initialize_regex): Use ctype.h macros for making the folding
- table and for making the \w+ fastmap. Previously, was reusing the
- regex syntax table or looking at character bit structure.
- (main): Execute setchrclass (NULL) if available and ANSI C.
-
- * Spelling fixes in various files.
- Reported by Jim Meyering <meyering@cs.utexas.edu>.
-
-Thu Jan 7 20:19:25 1993 Francois Pinard (pinard at icule)
-
- * Makefile.in: Using autoheader, derive config.h.in from
- configure.in. Distribute config.h.in.
- Use config.status for reconstructing config.h from config.h.in.
- Have all $(OBJECTS) depend upon config.h.
- Always use -I. calling the C compiler, for config.h to be found.
- Remove config.h in distclean-local.
- * lib/Makefile.in: Always use -I.. calling the C compiler, for
- config.h to be found. Also use $(DEFS).
- Have all $(OBJECTS) depend upon ../config.h.
- * configure.in: Create config.h from config.h.in.
- * ptx.c, ctype.c: Conditionnaly include config.h.
-
-Fri Jan 1 19:52:49 1993 Francois Pinard (pinard at icule)
-
- * Makefile.in, lib/Makefile.in: Reinstate $(CPPFLAGS), use it.
- Richard wants it there. Remove $(ALLFLAGS) and reequilibrate.
-
-Sun Dec 27 05:57:55 1992 Francois Pinard (pinard at icule)
-
- * ptx.c (find_occurs_in_text): Introduce word_start and word_end
- variables, and use them instead of the word_regs structure. This
- takes care of the fact newer regex.h does not allocate the arrays
- any more, and these were used even when regexps were not compiled.
-
- * Makefile, lib/Makefile.in: Define CHAR_SET_SIZE for SYNTAX_TABLE
- to work correctly.
-
- * configure.in: Replace AC_USG by AC_HAVE_HEADERS(string.h).
- Cleanup and reorganize a little.
-
- * ptx.c: Renamed from gptx.c. Add -G (--no-gnu-extensions)
- and clarify some long option names by making them more
- explicit. Remove all PTX_COMPATIBILITY conditionals.
- Introduce gnu_extensions variable initialized to 1. Let -G
- give it the value 0, but still allow and process GNU specific
- options and long option names. The Ignore file is now the same
- whatever the value of gnu_extensions.
- * ptx.texinfo: Renamed from gptx.texinfo, adjusted.
- * Makefile.in, configure.in: Adjusted accordingly. Now
- installs only one program under the name $(binprefix)ptx.
-
- * gptx.c (perror_and_exit): Deleted. Use error() directly.
-
- * gptx.c: Remove unneeded prototypes for system library routines.
-
- * gptx.c (compare_words, compare_occurs): #define first and second
- instead of using an intermediate variable.
-
- * configure.in: Use AC_CONST.
- * gptx.h: Do not define const.
- * Define volatile dependent on __GNUC__, not __STDC__, and define
- it to __volatile__.
-
- * gptx.h, version.c: Deleted, integrated into gptx.c.
- * Remove src/ and doc/ subdirectories, merging them in main.
- * Move lib/bumpalloc.h, lib/ctype.[ch] in main directory.
- * Integrate all ChangeLogs in main ChangeLog.
- * Integrate all Makefiles in main Makefile and lib/Makefile,
- rewriting them all along the way.
-
-Fri Nov 13 00:10:31 1992 Francois Pinard (pinard at icule)
-
- * Makefile.in (dist): chmod a+r before making the tar file.
-
-Tue Oct 6 12:47:00 1992 Francois Pinard (pinard at icule)
-
- * {,doc/,lib/,src/}Makefile.in: Use exec_prefix. Add `uninstall'.
-
-Wed Aug 19 16:02:09 1992 Francois Pinard (pinard at icule)
-
- * ansi2knr.c: New file, from Ghostscript distribution.
- * gptx.c: Get rid of many __STDC__ tests.
- * version.c: Idem.
-
-Fri Aug 14 22:53:05 1992 Francois Pinard (pinard at icule)
-
- * gptx.c: Use HAVE_MCHECK instead of MCHECK_MISSING.
- * configure.in: Use AC_HAVE_FUNCS instead of AC_MISSING_FUNCS.
-
- * configure.in: Autoconfigure for mcheck and strerror.
- Reported by Bernd Nordhausen <bernd@iss.nus.sg>.
-
-Thu Jun 18 09:15:12 1992 Francois Pinard (pinard at icule)
-
- * configure.in, all Makefile's: Adapt to Autoconf 0.118.
-
-Sun Feb 2 16:23:47 1992 Francois Pinard (pinard at icule)
-
- * gptx.c (main): Returns int.
-
-Tue Dec 10 09:53:21 1991 Francois Pinard (pinard at icule)
-
- * gptx.c (usage_and_exit): Print --OPTION instead of +OPTION.
-
-Wed Dec 4 10:31:06 1991 Francois Pinard (pinard at icule)
-
- * gptx.c (compare_occurs, compare_words): Change parameters to
- (void *) to comply with qsort ANSI declaration, and cast the true
- type inside the function, each time a parameter is used.
- Reported by Byron Rakitzis <byron@archone.tamu.edu>.
-
-Mon Dec 2 10:41:43 1991 Francois Pinard (pinard at icule)
-
- * gptx.c: Removed comma at end of enum.
-
- * version.c: Add a few missing `const's.
-
- * gptx.c: Add prototypes for close, fstat, open, perror and read
- if __STDC__.
-
- * gptx.c: Remove useless alloca declaration.
-
-Sat Nov 9 20:03:37 1991 Francois Pinard (pinard at icule)
-
- * configure.in, all/Makefile.in: Directory reorganization,
- including separate src and doc, in plus of lib. Ensure all
- Makefile's can be used independently.
-
-Thu Nov 7 11:20:38 1991 Francois Pinard (pinard at icule)
-
- * gptx.texinfo: Renamed from gptx.texi. Now `TeX'able.
- * Makefile.in: Ensure distributing texinfo.tex.
- Reported by Karl Berry <karl@cs.umb.edu>.
-
- * configure.in: Take care of POSIXish ISC.
- Reported by Karl Berry <karl@cs.umb.edu>.
-
-Tue Nov 5 09:42:58 1991 Francois Pinard (pinard at icule)
-
- * configure.in, Makefile.in: Do not absolutize $(srcdir), because
- this could create problems with automounters.
-
- * configure.in, Makefile.in: Remove IF_* devices, they were
- solving a problem caused only by non timestamping shars, and
- gptx is now distributed in tar format.
-
-Mon Oct 28 14:39:36 1991 Francois Pinard (pinard at icule)
-
- * configure.in: New file.
- * configure: Automatically generated from file configure.in
- and David MacKenzie's autoconf.
-
-Sat Oct 19 20:06:28 1991 Francois Pinard (pinard at icule)
-
- * configure: Use ANSI header files if present, even with non ANSI
- compilers.
- Reported by David MacKenzie <djm@eng.umd.edu>.
-
-Tue Oct 15 08:43:13 1991 Francois Pinard (pinard at icule)
-
- * Makefile.in: Install gptx and ptx separately. On DEC Ultrix
- 4.1, install cannot install more than one file at a time.
- Reported by Simon Leinen <simon@liasun1.epfl.ch>.
-
-Fri Oct 11 15:19:42 1991 Francois Pinard (pinard at icule)
-
- * Makefile.in: `realclean' did not work, because lib/Makefile was
- disappearing at `distclean' time. I tried separate doc and src
- directories, but this is not worth the heaviness. Split some
- goals instead, using _doc, _lib and _src suffixes.
-
-Fri Oct 10 18:04:21 1991 Francois Pinard (pinard at icule)
-
- * Version 0.2
-
-Wed Oct 9 16:13:42 1991 Francois Pinard (pinard at icule)
-
- * configure, Makefile.in: New files.
- * Makefile, GNUmakefile, Depends: Deleted.
-
- * gptx.c: Change -A output from `FILE(NN):' to `FILE:NN:'.
-
- * gptx.c, gptx.h, version.c: Reinstate __STDC__ tests.
-
-Tue Jun 25 11:35:32 1991 Francois Pinard (pinard at icule)
-
- * gptx.c: Something is wrong in -r reference allocation, I suspect
- casting does not do what I expect. I relax the constraints so to
- make it work for now. To be revisited.
-
- * gptx.c: Call initialize_regex sooner, to ensure folded_chars is
- properly initialized when -f and -i are simultaneously used.
-
- * gptx.c: Remove -p option and rather compile two separate
- programs, one by defining PTX_COMPATIBILITY, to conform a GNU
- standard asking to not depend on the program installed name. This
- also removes the -p option, so loosing the debatable advantage of
- dynamically reverting to ptx compatibility mode.
-
- * gptx.h: Cleanup. Don't duplicate stdlib.h.
-
-Wed Dec 5 18:00:23 1990 Francois Pinard (pinard at icule)
-
- * gptx.c (usage_and_exit): Change -C explanation.
-
-Sun Oct 28 16:11:36 1990 Francois Pinard (pinard at icule)
-
- * gptx.h: Remove the PROTO macros and usage.
- * gptx.c: Remove all the #ifdef __STDC__ noise.
- * version.c: Remove all the #ifdef __STDC__ noise.
-
-Wed Jul 25 12:20:45 1990 Francois Pinard (pinard at icule)
-
- * ctype.[ch]: Linked from my library.
-
-Wed Jul 11 10:53:13 1990 Francois Pinard (pinard at icule)
-
- * bumpalloc.h: Linked from my library.
-
-Sun Aug 5 13:17:25 1990 Francois Pinard (pinard at icule)
-
- * Version 0.1
-
- * gptx.c: Implement IGNORE and PIGNORE defines.
-
- * gptx.c: Implement special character protection for roff and TeX
- output, through the edited_flag array.
-
-Fri Aug 3 12:47:35 1990 Francois Pinard (pinard at icule)
-
- * gptx.c: Implement new -R option for automatic referencing, with
- the possibility of multiple input files in normal mode. Now,
- option -r implies ptx compatibility mode default for -S; exclude
- reference from context whenever easy to do, and allow coselection
- of both -r and -R.
-
-Wed Aug 1 12:00:07 1990 Francois Pinard (pinard at icule)
-
- * gptx.[hc]: Define and use OCCURS_ALIGNMENT, to avoid those
- `Bus error's on Sparcs.
-
-Fri Jul 27 12:04:40 1990 Francois Pinard (pinard at icule)
-
- * gptx.c (initialize_regex): Use only isalpha and "ctype.h" to
- initialize Sword syntax, getting rid of any other explicit ISO
- 8859-1 references. This will make the MS-DOS port easier,
- character set wise.
-
- * gptx.c (swallow_file_in_memory): Revised along the lines of
- io.c from GNU diff 1.14, so it could handle stin and fifos,
- and work faster.
-
- * gptx.c (perror_and_exit): New function, use it where convenient.
-
-Thu Jul 26 13:28:13 1990 Francois Pinard (pinard at icule)
-
- * gptx.c (swallow_input_text): Remove white space compression even
- if not in ptx compatibility mode. This being out of the way, use
- swallow_file_in_memory instead of inputting characters one by one.
-
-Wed Jul 25 12:20:45 1990 Francois Pinard (pinard at icule)
-
- * gptx.c (find_occurs_in_text): Include the sentence separator as
- part of the right context, except for separator's suffix white
- space. Formerly, it was excluded from all contexts.
-
- * gptx.h: Check STDLIB_PROTO_ALREADY to conditionalize prototype
- declarations for standard C library routines; check __GNUC__
- before using `volatile' on function prototypes.
-
- * gptx.c: (find_occurs_in_text): Maintain the maximum length of
- all words read.
- (define_all_fields): Optimize scanning longish left contexts by
- sometimes doing a backward jump from the keyword instead of always
- scanning forward from the left context boundary.
-
-Sun Jul 22 09:18:21 1990 Francois Pinard (pinard at icule)
-
- * gptx (alloc_and_compile_regex): Realloc out all extra allocated
- space.
-
-Mon Jul 16 09:07:25 1990 Francois Pinard (pinard at icule)
-
- * gptx.c: In OCCURS structure, modify left, right and reference
- pointers and make them displacements, to save some space. Define
- DELTA typedef, use it, make all other necessary changes.
-
- * gptx.c: Work on portability. Define const and volatile to
- nothing if not __STDC__. On BSD, define str[r]chr to be [r]index.
- Avoid writings specific to GNU C.
-
-Sun Jul 15 17:28:39 1990 Francois Pinard (pinard at icule)
-
- * gptx.c: Add a word_fastmap array and use it if -W has not been
- specified, instead of using default regexps. Finish implementing
- the Break files.
-
-Sat Jul 14 10:54:21 1990 Francois Pinard (pinard at icule)
-
- * gptx.[ch], version.c: Use prototypes in all header
- functions. Add some missing const declarations.
-
-Fri Jul 13 10:16:34 1990 Francois Pinard (pinard at icule)
-
- * gptx.c: Enforce ptx compatibility mode by disallowing normal
- mode extensions. Disallow -p if extensions are used.
-
- * gptx.c: Finish implementation of Ignore and Only files.
-
-Wed Jul 11 10:53:13 1990 Francois Pinard (pinard at icule)
-
- * gptx.c: Revise WORD typedef and use it in OCCURS typedef;
- adjust all usages. Add BLOCK and WORD_ARRAY typedefs, revise in
- various place to make better usage of these. Use BUMP_ALLOC.
-
-Tue Jul 10 09:02:26 1990 Francois Pinard (pinard at icule)
-
- * gptx.c: Add -L option, `latin1_charset' variable and support.
-
- * gptx.c: Remove old generate_roff and generate_tex variables,
- replace with output_format which is of enum type.
-
-Mon Jul 9 10:40:41 1990 Francois Pinard (pinard at icule)
-
- * gptx.c (compare_words): Check word_regex.translate and do not
- use the translation table if not computed. Also protect against
- possible 8-bit problems.
-
- * gptx.c (alloc_and_compile_regex): New function.
-
-Sun Jul 8 17:52:14 1990 Francois Pinard (pinard at icule)
-
- * gptx.c: Make a more systematic use of SKIP_* macros, to get rid
- of explicit ' ' references when possible.
-
- * gptx.c: Replace `head' field by `left' in the OCCURS structure,
- delay the `before' computation from find_occurs_in_text to
- define_all_fields, and make all necessary adjustments. Also
- add a `right' field in the OCCURS structure, use it to get rid of
- explicit '\n' references when possible.
-
- * gptx.c (initialize_regex): New function. Compute the syntax
- table for regex. Get rid of previous break_chars_init variable
- and break_chars array, use word_regex and word_regex_string
- instead.
-
- * gptx.c: Use re_search to find words and re_match to skip over
- them. Add -W option and support. Use re_search to find end of
- lines or end of sentences, add -S option and support.
-
-Sat Jul 7 08:50:40 1990 Francois Pinard (pinard at icule)
-
- * gptx.c: Change PRINT_SPACES and PRINT_FIELD macros to
- print_spaces and print_field routines, respectively.
-
-Fri Jul 6 09:44:39 1990 Francois Pinard (pinard at icule)
-
- * gptx.c (generate_output): Split into define_all_fields,
- generate_all_output, output_one_roff_line, output_one_tex_line,
- and output_one_tty_line.
-
- * gptx.c: Move the inline code to reallocate the text buffer into
- reallocate_text_buffer. Correct a small bug in this area.
-
- * gptx.c: Modify -F to accept a STRING argument, modify output
- routines to handle truncation marks having more than one
- character.
-
-Thu Jul 5 11:08:59 1990 Francois Pinard (pinard at icule)
-
- * gptx.c: Add -F option and logic.
-
- * gptx.c: Select ptx compatibility mode if program is
- installed under the name `ptx'. Install both gptx and ptx.
-
-Thu Jun 7 17:21:25 1990 Francois Pinard (pinard at icule)
-
- * gptx.c: Make each OCCURS a variable size thing, depending on
- various options; mark occurs_found table size with an integer
- counter instead of an end pointer.
-
-Sat Apr 14 20:01:09 1990 Francois Pinard (pinard at icule)
-
- * Version 0.0
-
- * gptx.c: Removed limitations on table sizes: it should now go
- until an `Out of memory' error. Use xmalloc. Rename some
- variables.
-
- * version.c, gptx.c (usage_and_exit): Add -C option to print
- Copyright.
-
-Mon Mar 12 17:59:42 1990 Francois Pinard (pinard at icule)
-
- * ChangeLog initialisation. Previous experiments towards gptx
- were done at the defunct site ora.odyssee.qc.ca, which was a
- Sun-3/160 running SunOS 3.0. The files have been stocked for
- a long time to kovic.iro archives, then imported to icule.
-
- * gptx.c: GCC linted.
diff --git a/gnu/usr.bin/ptx/Makefile b/gnu/usr.bin/ptx/Makefile
deleted file mode 100644
index b06f5b4..0000000
--- a/gnu/usr.bin/ptx/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-PROG= ptx
-SRCS= argmatch.c diacrit.c error.c getopt.c getopt1.c ptx.c xmalloc.c
-
-LDADD+= -lgnuregex
-DPADD+= ${LIBGNUREGEX}
-CFLAGS+= -DHAVE_CONFIG_H -DDEFAULT_IGNORE_FILE=\"/usr/share/dict/eign\"
-
-NOMAN=
-
-SUBDIR+= doc
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/ptx/NEWS b/gnu/usr.bin/ptx/NEWS
deleted file mode 100644
index 6f97bf9..0000000
--- a/gnu/usr.bin/ptx/NEWS
+++ /dev/null
@@ -1,53 +0,0 @@
-GNU permuted indexer NEWS - User visible changes.
-Copyright (C) 1990, 1991, 1993 Free Software Foundation, Inc.
-Francois Pinard <pinard@iro.umontreal.ca>, 1992.
-
-Version 0.3 - 1993-10-??, by Franc,ois Pinard
-
-* GNU ptx installs as a single program, -G option dynamically reverts
-to the System V compatible behaviour, yet being liberal with options.
-
-* It should install more easily on more systems, source code is
-unprotoized on the fly for older C compilers.
-
-* A default ignore file is installed along with GNU ptx, ptx uses it.
-
-* Options -F, -S and -W interpret most \-escapes themselves.
-
-* Option -M can be use to change "xx" to another macro name.
-
-* CHRCLASS environment variable is obeyed for systems supporting it.
-
-* Long option names have been cleaned up a little.
-
-* Some examples are given in the example/ directory structure.
-
-
-Version 0.2 - 1991-10-10, by Franc,ois Pinard
-
-* Reference format (with -A) has been modified slightly to better
-comply with GNU standards for line reporting.
-
-* Option -p removed, rather compile two separate programs, one with
-GNU extensions, the other being strict on System V compatibility.
-
-
-Version 0.1 - 1990-08-05, by Franc,ois Pinard
-
-* Add many options: -L for Latin1, -R for automatic referencing, -W
-for regular expressions describing words, -S for regular expressions
-describing end of lines or sentences. Let -F specify the truncation
-strings.
-
-* Implementing Ignore files and Only files.
-
-* Option -p dynamically enforces strict System V compatibility.
-
-* Correct a few bugs and portability problems, have faster input,
-faster processing, and use less memory.
-
-
-Version 0.0 - 1990-04-14, by Franc,ois Pinard
-
-* Initial release.
-
diff --git a/gnu/usr.bin/ptx/README b/gnu/usr.bin/ptx/README
deleted file mode 100644
index 240b7ee..0000000
--- a/gnu/usr.bin/ptx/README
+++ /dev/null
@@ -1,23 +0,0 @@
-This is an beta release of GNU ptx, a permuted index generator. GNU
-ptx can handle multiple input files at once, produce TeX compatible
-output, or a readable KWIC (keywords in their context) without the
-need of nroff. This version does not handle huge input files, that
-is, those which do not fit in memory all at once.
-
-The command syntax is not the same as UNIX ptx: all given files are
-input files, the results are produced on standard output by default.
-GNU ptx manual is provided in Texinfo format. Calling `ptx --help'
-prints an option summary. Please note that an overall renaming of all
-options is foreseeable: GNU ptx specifications are not frozen yet.
-
-See the file COPYING for copying conditions.
-
-See the file THANKS for a list of contributors.
-
-See the file NEWS for a list of major changes in the current release.
-
-See the file INSTALL for compilation and installation instructions.
-
-Mail suggestions and bug reports (including documentation errors) for
-these programs to bug-gnu-utils@prep.ai.mit.edu.
-
diff --git a/gnu/usr.bin/ptx/THANKS b/gnu/usr.bin/ptx/THANKS
deleted file mode 100644
index e6a45cf..0000000
--- a/gnu/usr.bin/ptx/THANKS
+++ /dev/null
@@ -1,23 +0,0 @@
-GNU permuted indexer has originally been written by François Pinard.
-Other people contributed to the GNU permuted index by reporting
-problems, suggesting various improvements or submitting actual code.
-Here is a list of these people. Help me keep it complete and exempt
-of errors.
-
-Ajay Shah ajayshah@cmie.ernet.in
-Bernd Nordhausen bernd@iss.nus.sg
-Byron Rakitzis byron@archone.tamu.edu
-Dave Cottingham dc@haiti.gsfc.nasa.gov
-David J. MacKenzie djm@eng.umd.edu
-Francois Pinard pinard@iro.umontreal.ca
-Janne Himanka shem@syy.oulu.fi
-James Clark jjc@jclark.com
-Jim Meyering meyering@comco.com
-Karl Berry karl@cs.umb.edu
-Loic Dachary L.Dachary@cs.ucl.ac.uk
-Luke Kendall luke@research.canon.oz.au
-Nelson Beebe beebe@math.utah.edu
-Rakesh Chauhan rk@cmie.ernet.in
-Simon Leinen simon@liasun1.epfl.ch
-Stephane Berube berube@iro.umontreal.ca
-Thorsten Ohl ohl@physics.harvard.edu
diff --git a/gnu/usr.bin/ptx/TODO b/gnu/usr.bin/ptx/TODO
deleted file mode 100644
index 6714313..0000000
--- a/gnu/usr.bin/ptx/TODO
+++ /dev/null
@@ -1,94 +0,0 @@
-TODO file for GNU ptx - last revised 05 November 1993.
-Copyright (C) 1992, 1993 Free Software Foundation, Inc.
-Francois Pinard <pinard@iro.umontreal.ca>, 1992.
-
-The following are more or less in decreasing order of priority.
-
-* Use rx instead of regex.
-
-* Correct the infinite loop using -S '$' or -S '^'.
-
-* Use mmap for swallowing files (maybe wrong when memory edited).
-
-* Understand and mimic `-t' option, if I can.
-
-* Sort keywords intelligently for Latin-1 code. See how to interface
-this character set with various output formats. Also, introduce
-options to inverse-sort and possibly to reverse-sort.
-
-* Improve speed for Ignore and Only tables. Consider hashing instead
-of sorting. Consider playing with obstacks to digest them.
-
-* Provide better handling of format effectors obtained from input, and
-also attempt white space compression on output which would still
-maximize full output width usage.
-
-* See how TeX mode could be made more useful, and if a texinfo mode
-would mean something to someone.
-
-* Provide multiple language support
-
-Most of the boosting work should go along the line of fast recognition
-of multiple and complex boundaries, which define various `languages'.
-Each such language has its own rules for words, sentences, paragraphs,
-and reporting requests. This is less difficult than I first thought:
-
- . Recognize language modifiers with each option. At least -b, -i, -o,
--W, -S, and also new language switcher options, will have such
-modifiers. Modifiers on language switchers will allow or disallow
-language transitions.
-
- . Complete the transformation of underlying variables into arrays in
-the code.
-
- . Implement a heap of positions in the input file. There is one entry
-in the heap for each compiled regexp; it is initialized by a re_search
-after each regexp compile. Regexps reschedule themselves in the heap
-when their position passes while scanning input. In this way, looking
-simultaneously for a lot of regexps should not be too inefficient,
-once the scanning starts. If this works ok, maybe consider accepting
-regexps in Only and Ignore tables.
-
- . Merge with language processing boundary processing options, really
-integrating -S processing as a special case. Maybe, implement several
-level of boundaries. See how to implement a stack of languages, for
-handling quotations. See if more sophisticated references could be
-handled as another special case of a language.
-
-* Tackle other aspects, in a more long term view
-
- . Add options for statistics, frequency lists, referencing, and all
-other prescreening tools and subsidiary tasks of concordance
-production.
-
- . Develop an interactive mode. Even better, construct a GNU emacs
-interface. I'm looking at Gene Myers <gene@cs.arizona.edu> suffix
-arrays as a possible implementation along those ideas.
-
- . Implement hooks so word classification and tagging should be merged
-in. See how to effectively hook in lemmatisation or other
-morphological features. It is far from being clear by now how to
-interface this correctly, so some experimentation is mandatory.
-
- . Profile and speed up the whole thing.
-
- . Make it work on small address space machines. Consider three levels
-of hugeness for files, and three corresponding algorithms to make
-optimal use of memory. The first case is when all the input files and
-all the word references fit in memory: this is the case currently
-implemented. The second case is when the files cannot fit all together
-in memory, but the word references do. The third case is when even
-the word references cannot fit in memory.
-
- . There also are subsidiary developments for in-core incremental sort
-routines as well as for external sort packages. The need for more
-flexible sort packages comes partly from the fact that linguists use
-kinds of keys which compare in unusual and more sophisticated ways.
-GNU `sort' and `ptx' could evolve together.
-
-
-Local Variables:
-mode: outline
-outline-regexp: " *[-+*.] \\| "
-eval: (hide-body)
-End:
diff --git a/gnu/usr.bin/ptx/alloca.c b/gnu/usr.bin/ptx/alloca.c
deleted file mode 100644
index bd4932a..0000000
--- a/gnu/usr.bin/ptx/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 <jot@cray.com> 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 <config.h>
-#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 <stdio.h>
-#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/gnu/usr.bin/ptx/argmatch.c b/gnu/usr.bin/ptx/argmatch.c
deleted file mode 100644
index 17e088b..0000000
--- a/gnu/usr.bin/ptx/argmatch.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* argmatch.c -- find a match for a string in an array
- Copyright (C) 1990 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Written by David MacKenzie <djm@ai.mit.edu> */
-
-#ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
- using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
- (which it would do because it found this file in $srcdir). */
-#include <config.h>
-#else
-#include "config.h"
-#endif
-#endif
-
-#include <stdio.h>
-#ifdef STDC_HEADERS
-#include <string.h>
-#endif
-
-extern char *program_name;
-
-/* If ARG is an unambiguous match for an element of the
- null-terminated array OPTLIST, return the index in OPTLIST
- of the matched element, else -1 if it does not match any element
- or -2 if it is ambiguous (is a prefix of more than one element). */
-
-int
-argmatch (arg, optlist)
- char *arg;
- char **optlist;
-{
- int i; /* Temporary index in OPTLIST. */
- int arglen; /* Length of ARG. */
- int matchind = -1; /* Index of first nonexact match. */
- int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */
-
- arglen = strlen (arg);
-
- /* Test all elements for either exact match or abbreviated matches. */
- for (i = 0; optlist[i]; i++)
- {
- if (!strncmp (optlist[i], arg, arglen))
- {
- if (strlen (optlist[i]) == arglen)
- /* Exact match found. */
- return i;
- else if (matchind == -1)
- /* First nonexact match found. */
- matchind = i;
- else
- /* Second nonexact match found. */
- ambiguous = 1;
- }
- }
- if (ambiguous)
- return -2;
- else
- return matchind;
-}
-
-/* Error reporting for argmatch.
- KIND is a description of the type of entity that was being matched.
- VALUE is the invalid value that was given.
- PROBLEM is the return value from argmatch. */
-
-void
-invalid_arg (kind, value, problem)
- char *kind;
- char *value;
- int problem;
-{
- fprintf (stderr, "%s: ", program_name);
- if (problem == -1)
- fprintf (stderr, "invalid");
- else /* Assume -2. */
- fprintf (stderr, "ambiguous");
- fprintf (stderr, " %s `%s'\n", kind, value);
-}
diff --git a/gnu/usr.bin/ptx/bumpalloc.h b/gnu/usr.bin/ptx/bumpalloc.h
deleted file mode 100644
index 6fe8952..0000000
--- a/gnu/usr.bin/ptx/bumpalloc.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* BUMP_ALLOC macro - increase table allocation by one element.
- Copyright (C) 1990, 1991, 1993 Free Software Foundation, Inc.
- Francois Pinard <pinard@iro.umontreal.ca>, 1990.
-
- 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. */
-
-/*-------------------------------------------------------------------------.
-| Bump the allocation of the array pointed to by TABLE whenever required. |
-| The table already has already COUNT elements in it, this macro ensure it |
-| has enough space to accommodate at least one more element. Space is |
-| allocated (2 ^ EXPONENT) elements at a time. Each element of the array |
-| is of type TYPE. |
-`-------------------------------------------------------------------------*/
-
-/* Routines `xmalloc' and `xrealloc' are called to do the actual memory
- management. This implies that the program will abort with an `Virtual
- Memory exhausted!' error if any problem arise.
-
- To work correctly, at least EXPONENT and TYPE should always be the
- same for all uses of this macro for any given TABLE. A secure way to
- achieve this is to never use this macro directly, but use it to define
- other macros, which would then be TABLE-specific.
-
- The first time through, COUNT is usually zero. Note that COUNT is not
- updated by this macro, but it should be update elsewhere, later. This
- is convenient, because it allows TABLE[COUNT] to refer to the new
- element at the end. Once its construction is completed, COUNT++ will
- record it in the table. Calling this macro several times in a row
- without updating COUNT is a bad thing to do. */
-
-#define BUMP_ALLOC(Table, Count, Exponent, Type) \
- BUMP_ALLOC_WITH_SIZE ((Table), (Count), (Exponent), Type, sizeof (Type))
-
-/* In cases `sizeof TYPE' would not always yield the correct value for
- the size of each element entry, this macro accepts a supplementary
- SIZE argument. The EXPONENT, TYPE and SIZE parameters should still
- have the same value for all macro calls related to a specific TABLE. */
-
-#define BUMP_ALLOC_WITH_SIZE(Table, Count, Exponent, Type, Size) \
- if (((Count) & (~(~0 << (Exponent)))) == 0) \
- if ((Count) == 0) \
- (Table) = (Type *) xmalloc ((1 << (Exponent)) * (Size)); \
- else \
- (Table) = (Type *) \
- xrealloc ((Table), ((Count) + (1 << (Exponent))) * (Size)); \
- else
diff --git a/gnu/usr.bin/ptx/check-out b/gnu/usr.bin/ptx/check-out
deleted file mode 100644
index 4d13c48..0000000
--- a/gnu/usr.bin/ptx/check-out
+++ /dev/null
@@ -1,65 +0,0 @@
-:30: /ranslate to certain respons ibilities for you if you distr/
-:183: c/ These actions are proh ibited by law if you do not ac
-:278: AS BEEN ADVISED OF THE POSS IBILITY OF SUCH DAMAGES. /Y H
-:232: /his License may add an expl icit geographical distribution/
-:267: /COST OF ALL NECESSARY SERV ICING, REPAIR OR CORRECTION.
-:216: /ht claims or to contest val idity of any such claims; this/
-:45: e/ If the software is mod ified by someone else and pass
-:57: pying, distribution and mod ification follow. /for co
-:60: /PYING, DISTRIBUTION AND MOD IFICATION 0. This License a/
-:68: /either verbatim or with mod ifications and/or translated i/
-:70: limitation in the term "mod ification".) /ithout
-:72: /pying, distribution and mod ification are not covered by t/
-:92: /opy and distribute such mod ifications or work under the t/
-:95: /a) You must cause the mod ified files to carry prominent/
-:103: ommands in/ c) If the mod ified program normally reads c
-:114: quirements apply to the mod ified work as a whole. /se re
-:115: are not derived/ If ident ifiable sections of that work
-:156: of the work for making mod ifications to it. /ed form
-:243: Lice/ If the Program spec ifies a version number of this
-:46: /hat they have is not the or iginal, so that any problems i/
-:47: /will not reflect on the or iginal authors' reputations.
-:191: /eives a license from the or iginal licensor to copy, distr/
-:231: /yrighted interfaces, the or iginal copyright holder who pl/
-:265: /ED WARRANTIES OF MERCHANTAB ILITY AND FITNESS FOR A PARTIC/
-:274: /NG OUT OF THE USE OR INAB ILITY TO USE THE PROGRAM (INCL/
-:303: /warranty of MERCHANTAB ILITY or FITNESS FOR A PARTICU/
-:69: /ation is included without l imitation in the term "modific/
-:198: /for any other reason (not l imited to patent issues), cond/
-:232: /geographical distribution l imitation excluding those coun/
-:235: /License incorporates the l imitation as if written in the/
-:239: Such new versions will be s imilar in spirit to the presen/
-:264: /PLIED, INCLUDING, BUT NOT L IMITED TO, THE IMPLIED WARRANT/
-:274: /ROGRAM (INCLUDING BUT NOT L IMITED TO LOSS OF DATA OR DATA/
-:67: /hat is to say, a work conta ining the Program or a portion/
-:158: /ny associated interface def inition files, plus the script/
-:34: /fee, you must give the rec ipients all the rights that yo/
-:46: /passed on, we want its rec ipients to know that what they/
-:84: /nty; and give any other rec ipients of the Program a copy/
-:190: /ed on the Program), the rec ipient automatically receives/
-:193: /her restrictions on the rec ipients' exercise of the right/
-:239: /sions will be similar in sp irit to the present version, b/
-:254: o goals of prese/ Our dec ision will be guided by the tw
-:273: /OR CONSEQUENTIAL DAMAGES AR ISING OUT OF THE USE OR INAB/
-:315: /teractive mode: Gnomov ision version 69, Copyright (C/
-:316: /y name of author Gnomov ision comes with ABSOLUTELY NO/
-:330: /st in the program `Gnomov ision' (which makes passes at/
-:30: /late to certain responsibil ities for you if you distribut/
-:56: The precise terms and cond itions for copying, distributi/
-:60: /C LICENSE TERMS AND COND ITIONS FOR COPYING, DISTRIBUTI/
-:93: /also meet all of these cond itions: a) You must cause/
-:109: /rogram under these cond itions, and telling the user h/
-:129: ther work not bas/ In add ition, mere aggregation of ano
-:186: /and all its terms and cond itions for copying, distributi/
-:192: ect to these terms and cond itions. /am subj
-:199: /ted to patent issues), cond itions are imposed on you (whe/
-:200: /e) that contradict the cond itions of this License, they d/
-:201: ot excuse you from the cond itions of this License. /do n
-:244: /ollowing the terms and cond itions either of that version/
-:251: /ams whose distribution cond itions are different, write to/
-:262: /WHEN OTHERWISE STATED IN WR ITING THE COPYRIGHT HOLDERS AN/
-:270: /ABLE LAW OR AGREED TO IN WR ITING WILL ANY COPYRIGHT HOLDE/
-:280: ly/ END OF TERMS AND COND ITIONS Appendix: How to App
-:318: /e it under certain cond itions; type `show c' for deta/
-:52: /of a free program will ind ividually obtain patent licens/
-:72: stribution and mod/ Act ivities other than copying, di
diff --git a/gnu/usr.bin/ptx/config.h b/gnu/usr.bin/ptx/config.h
deleted file mode 100644
index 93e7ed1..0000000
--- a/gnu/usr.bin/ptx/config.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if using alloca.c. */
-/* #undef C_ALLOCA */
-
-/* Define if type char is unsigned and you are not using gcc. */
-/* #undef __CHAR_UNSIGNED__ */
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
- This function is required for alloca.c support on those systems. */
-/* #undef CRAY_STACKSEG_END */
-
-/* Define if you have alloca.h and it should be used (not Ultrix). */
-/* #undef HAVE_ALLOCA_H */
-
-/* Define if you don't have vprintf but do have _doprnt. */
-/* #undef HAVE_DOPRNT */
-
-/* Define if you have the vprintf function. */
-#define HAVE_VPRINTF 1
-
-/* Define if you need to in order for stat and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* If using the C implementation of alloca, define 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
- */
-/* #undef STACK_DIRECTION */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* In regex, request the capability of modifying the letter syntax. */
-#define SYNTAX_TABLE 1
-
-/* In regex, use 8 bits per character. */
-#define CHAR_SET_SIZE 256
-
-/* Define if you have mcheck. */
-/* #undef HAVE_MCHECK */
-
-/* Define if you have setchrclass. */
-/* #undef HAVE_SETCHRCLASS */
-
-/* Define if you have strerror. */
-#define HAVE_STRERROR 1
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
diff --git a/gnu/usr.bin/ptx/diacrit.c b/gnu/usr.bin/ptx/diacrit.c
deleted file mode 100644
index 29e319b..0000000
--- a/gnu/usr.bin/ptx/diacrit.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/* Diacritics processing for a few character codes.
- Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
- Francois Pinard <pinard@iro.umontreal.ca>, 1988.
-
- All this file is a temporary hack, waiting for locales in GNU.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "diacrit.h"
-
-/* ISO 8859-1 Latin-1 code is used as the underlying character set. If
- MSDOS is defined, IBM-PC's character set code is used instead. */
-
-/*--------------------------------------------------------------------.
-| For each alphabetic character, returns what it would be without its |
-| possible diacritic symbol. |
-`--------------------------------------------------------------------*/
-
-const char diacrit_base[256] =
-{
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 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', 'D', 'E', 'F', 'G',
- 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
- 'X', 'Y', 'Z', 0, 0, 0, 0, 0,
- 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
- 'x', 'y', 'z', 0, 0, 0, 0, 0,
-
-#ifdef MSDOS
-
- 'C', 'u', 'e', 'a', 'a', 'a', 'a', 'c',
- 'e', 'e', 'e', 'i', 'i', 'i', 'A', 'A',
- 'E', 'e', 'E', 'o', 'o', 'o', 'u', 'u',
- 'y', 'O', 'U', 0, 0, 0, 0, 0,
- 'a', 'i', 'o', 'u', 'n', '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,
-
-#else /* not MSDOS */
-
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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', 'A', 'A', 'A', 'A', 'A', 'A', 'C',
- 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I',
- 0, 'N', 'O', 'O', 'O', 'O', 'O', 0,
- 'O', 'U', 'U', 'U', 'U', 'Y', 0, 0,
- 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c',
- 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i',
- 0, 'n', 'o', 'o', 'o', 'o', 'o', 0,
- 'o', 'u', 'u', 'u', 'u', 'y', 0, 'y',
-
-#endif /* not MSDOS */
-};
-
-/*------------------------------------------------------------------------.
-| For each alphabetic character, returns a code of what its diacritic is, |
-| according to the following codes: 1 (eE) over aA for latin diphtongs; 2 |
-| (') acute accent; 3 (`) grave accent; 4 (^) circumflex accent; 5 (") |
-| umlaut or diaraesis; 6 (~) tilda; 7 (,) cedilla; 8 (o) covering degree |
-| symbol; 9 (|) slashed character. |
-`------------------------------------------------------------------------*/
-
-const char diacrit_diac[256] =
-{
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 4, 0,
- 3, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 6, 0,
-
-#ifdef MSDOS
-
- 7, 5, 2, 4, 5, 3, 8, 7,
- 4, 5, 3, 5, 4, 3, 5, 8,
- 2, 1, 1, 4, 5, 3, 4, 3,
- 5, 5, 5, 0, 0, 0, 0, 0,
- 2, 2, 2, 2, 6, 6, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-
-#else /* not MSDOS */
-
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 3, 2, 4, 6, 5, 8, 1, 7,
- 3, 2, 4, 5, 3, 2, 4, 5,
- 0, 6, 3, 2, 4, 6, 5, 0,
- 9, 3, 2, 4, 5, 2, 0, 0,
- 3, 2, 4, 6, 5, 8, 1, 7,
- 3, 2, 4, 5, 3, 2, 4, 5,
- 0, 6, 3, 2, 4, 6, 5, 0,
- 9, 3, 2, 4, 5, 2, 0, 0,
-
-#endif /* not MSDOS */
-};
diff --git a/gnu/usr.bin/ptx/diacrit.h b/gnu/usr.bin/ptx/diacrit.h
deleted file mode 100644
index c880a45..0000000
--- a/gnu/usr.bin/ptx/diacrit.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Diacritics processing for a few character codes.
- Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
- Francois Pinard <pinard@iro.umontreal.ca>, 1988.
-
- All this file is a temporary hack, waiting for locales in GNU.
-*/
-
-extern const char diacrit_base[]; /* characters without diacritics */
-extern const char diacrit_diac[]; /* diacritic code for each character */
-
-/* Returns CHR without its diacritic. CHR is known to be alphabetic. */
-#define tobase(chr) (diacrit_base[(unsigned char) (chr)])
-
-/* Returns a diacritic code for CHR. CHR is known to be alphabetic. */
-#define todiac(chr) (diacrit_diac[(unsigned char) (chr)])
-
diff --git a/gnu/usr.bin/ptx/doc/Makefile b/gnu/usr.bin/ptx/doc/Makefile
deleted file mode 100644
index 740db51..0000000
--- a/gnu/usr.bin/ptx/doc/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-INFO = ptx
-INFOSECTION= "Documentation tools"
-INFOENTRY_ptx= "* PTX: (ptx). GNU permuted index generator."
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/ptx/doc/ptx.texinfo b/gnu/usr.bin/ptx/doc/ptx.texinfo
deleted file mode 100644
index e690c55..0000000
--- a/gnu/usr.bin/ptx/doc/ptx.texinfo
+++ /dev/null
@@ -1,554 +0,0 @@
-\input texinfo @c -*-texinfo-*-
-@c %**start of header
-@setfilename ptx.info
-@settitle GNU @code{ptx} reference manual
-@finalout
-@c %**end of header
-
-@ifinfo
-This file documents the @code{ptx} command, which has the purpose of
-generated permuted indices for group of files.
-
-Copyright (C) 1990, 1991, 1993 by the Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-@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
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the entire
-resulting derived work is distributed under the terms of a permission
-notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions,
-except that this permission notice may be stated in a translation approved
-by the Foundation.
-@end ifinfo
-
-@titlepage
-@title ptx
-@subtitle The GNU permuted indexer
-@subtitle Edition 0.3, for ptx version 0.3
-@subtitle November 1993
-@author by Francois Pinard
-
-@page
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1990, 1991, 1993 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the entire
-resulting derived work is distributed under the terms of a permission
-notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions,
-except that this permission notice may be stated in a translation approved
-by the Foundation.
-@end titlepage
-
-@node Top, Invoking ptx, (dir), (dir)
-@chapter Introduction
-
-This is the 0.3 beta release of @code{ptx}, the GNU version of a
-permuted index generator. This software has the main goal of providing
-a replacement for the traditional @code{ptx} as found on System V
-machines, able to handle small files quickly, while providing a platform
-for more development.
-
-This version reimplements and extends traditional @code{ptx}. Among
-other things, it can produce a readable @dfn{KWIC} (keywords in their
-context) without the need of @code{nroff}, there is also an option to
-produce @TeX{} compatible output. This version does not handle huge
-input files, that is, those files which do not fit in memory all at
-once.
-
-@emph{Please note} that an overall renaming of all options is
-foreseeable. In fact, GNU ptx specifications are not frozen yet.
-
-@menu
-* Invoking ptx:: How to use this program
-* Compatibility:: The GNU extensions to @code{ptx}
-
- --- The Detailed Node Listing ---
-
-How to use this program
-
-* General options:: Options which affect general program behaviour.
-* Charset selection:: Underlying character set considerations.
-* Input processing:: Input fields, contexts, and keyword selection.
-* Output formatting:: Types of output format, and sizing the fields.
-@end menu
-
-@node Invoking ptx, Compatibility, Top, Top
-@chapter How to use this program
-
-This tool reads a text file and essentially produces a permuted index, with
-each keyword in its context. The calling sketch is one of:
-
-@example
-ptx [@var{option} @dots{}] [@var{file} @dots{}]
-@end example
-
-or:
-
-@example
-ptx -G [@var{option} @dots{}] [@var{input} [@var{output}]]
-@end example
-
-The @samp{-G} (or its equivalent: @samp{--traditional}) option disables
-all GNU extensions and revert to traditional mode, thus introducing some
-limitations, and changes several of the program's default option values.
-When @samp{-G} is not specified, GNU extensions are always enabled. GNU
-extensions to @code{ptx} are documented wherever appropriate in this
-document. See @xref{Compatibility} for an explicit list of them.
-
-Individual options are explained later in this document.
-
-When GNU extensions are enabled, there may be zero, one or several
-@var{file} after the options. If there is no @var{file}, the program
-reads the standard input. If there is one or several @var{file}, they
-give the name of input files which are all read in turn, as if all the
-input files were concatenated. However, there is a full contextual
-break between each file and, when automatic referencing is requested,
-file names and line numbers refer to individual text input files. In
-all cases, the program produces the permuted index onto the standard
-output.
-
-When GNU extensions are @emph{not} enabled, that is, when the program
-operates in traditional mode, there may be zero, one or two parameters
-besides the options. If there is no parameters, the program reads the
-standard input and produces the permuted index onto the standard output.
-If there is only one parameter, it names the text @var{input} to be read
-instead of the standard input. If two parameters are given, they give
-respectively the name of the @var{input} file to read and the name of
-the @var{output} file to produce. @emph{Be very careful} to note that,
-in this case, the contents of file given by the second parameter is
-destroyed. This behaviour is dictated only by System V @code{ptx}
-compatibility, because GNU Standards discourage output parameters not
-introduced by an option.
-
-Note that for @emph{any} file named as the value of an option or as an
-input text file, a single dash @kbd{-} may be used, in which case
-standard input is assumed. However, it would not make sense to use this
-convention more than once per program invocation.
-
-@menu
-* General options:: Options which affect general program behaviour.
-* Charset selection:: Underlying character set considerations.
-* Input processing:: Input fields, contexts, and keyword selection.
-* Output formatting:: Types of output format, and sizing the fields.
-@end menu
-
-@node General options, Charset selection, Invoking ptx, Invoking ptx
-@section General options
-
-@table @code
-
-@item -C
-@itemx --copyright
-Prints a short note about the Copyright and copying conditions, then
-exit without further processing.
-
-@item -G
-@itemx --traditional
-As already explained, this option disables all GNU extensions to
-@code{ptx} and switch to traditional mode.
-
-@item --help
-Prints a short help on standard output, then exit without further
-processing.
-
-@item --version
-Prints the program verison on standard output, then exit without further
-processing.
-
-@end table
-
-@node Charset selection, Input processing, General options, Invoking ptx
-@section Charset selection
-
-As it is setup now, the program assumes that the input file is coded
-using 8-bit ISO 8859-1 code, also known as Latin-1 character set,
-@emph{unless} if it is compiled for MS-DOS, in which case it uses the
-character set of the IBM-PC. (GNU @code{ptx} is not known to work on
-smaller MS-DOS machines anymore.) Compared to 7-bit ASCII, the set of
-characters which are letters is then different, this fact alters the
-behaviour of regular expression matching. Thus, the default regular
-expression for a keyword allows foreign or diacriticized letters.
-Keyword sorting, however, is still crude; it obeys the underlying
-character set ordering quite blindly.
-
-@table @code
-
-@item -f
-@itemx --ignore-case
-Fold lower case letters to upper case for sorting.
-
-@end table
-
-@node Input processing, Output formatting, Charset selection, Invoking ptx
-@section Word selection
-
-@table @code
-
-@item -b @var{file}
-@item --break-file=@var{file}
-
-This option is an alternative way to option @code{-W} for describing
-which characters make up words. This option introduces the name of a
-file which contains a list of characters which can@emph{not} be part of
-one word, this file is called the @dfn{Break file}. Any character which
-is not part of the Break file is a word constituent. If both options
-@code{-b} and @code{-W} are specified, then @code{-W} has precedence and
-@code{-b} is ignored.
-
-When GNU extensions are enabled, the only way to avoid newline as a
-break character is to write all the break characters in the file with no
-newline at all, not even at the end of the file. When GNU extensions
-are disabled, spaces, tabs and newlines are always considered as break
-characters even if not included in the Break file.
-
-@item -i @var{file}
-@itemx --ignore-file=@var{file}
-
-The file associated with this option contains a list of words which will
-never be taken as keywords in concordance output. It is called the
-@dfn{Ignore file}. The file contains exactly one word in each line; the
-end of line separation of words is not subject to the value of the
-@code{-S} option.
-
-There is a default Ignore file used by @code{ptx} when this option is
-not specified, usually found in @file{/usr/local/lib/eign} if this has
-not been changed at installation time. If you want to deactivate the
-default Ignore file, specify @code{/dev/null} instead.
-
-@item -o @var{file}
-@itemx --only-file=@var{file}
-
-The file associated with this option contains a list of words which will
-be retained in concordance output, any word not mentioned in this file
-is ignored. The file is called the @dfn{Only file}. The file contains
-exactly one word in each line; the end of line separation of words is
-not subject to the value of the @code{-S} option.
-
-There is no default for the Only file. In the case there are both an
-Only file and an Ignore file, a word will be subject to be a keyword
-only if it is given in the Only file and not given in the Ignore file.
-
-@item -r
-@itemx --references
-
-On each input line, the leading sequence of non white characters will be
-taken to be a reference that has the purpose of identifying this input
-line on the produced permuted index. See @xref{Output formatting} for
-more information about reference production. Using this option change
-the default value for option @code{-S}.
-
-Using this option, the program does not try very hard to remove
-references from contexts in output, but it succeeds in doing so
-@emph{when} the context ends exactly at the newline. If option
-@code{-r} is used with @code{-S} default value, or when GNU extensions
-are disabled, this condition is always met and references are completely
-excluded from the output contexts.
-
-@item -S @var{regexp}
-@itemx --sentence-regexp=@var{regexp}
-
-This option selects which regular expression will describe the end of a
-line or the end of a sentence. In fact, there is other distinction
-between end of lines or end of sentences than the effect of this regular
-expression, and input line boundaries have no special significance
-outside this option. By default, when GNU extensions are enabled and if
-@code{-r} option is not used, end of sentences are used. In this
-case, the precise @var{regex} is imported from GNU emacs:
-
-@example
-[.?!][]\"')@}]*\\($\\|\t\\| \\)[ \t\n]*
-@end example
-
-Whenever GNU extensions are disabled or if @code{-r} option is used, end
-of lines are used; in this case, the default @var{regexp} is just:
-
-@example
-\n
-@end example
-
-Using an empty REGEXP is equivalent to completely disabling end of line or end
-of sentence recognition. In this case, the whole file is considered to
-be a single big line or sentence. The user might want to disallow all
-truncation flag generation as well, through option @code{-F ""}.
-@xref{Regexps, , Syntax of Regular Expressions, emacs, The GNU Emacs
-Manual}.
-
-When the keywords happen to be near the beginning of the input line or
-sentence, this often creates an unused area at the beginning of the
-output context line; when the keywords happen to be near the end of the
-input line or sentence, this often creates an unused area at the end of
-the output context line. The program tries to fill those unused areas
-by wrapping around context in them; the tail of the input line or
-sentence is used to fill the unused area on the left of the output line;
-the head of the input line or sentence is used to fill the unused area
-on the right of the output line.
-
-As a matter of convenience to the user, many usual backslashed escape
-sequences, as found in the C language, are recognized and converted to
-the corresponding characters by @code{ptx} itself.
-
-@item -W @var{regexp}
-@itemx --word-regexp=@var{regexp}
-
-This option selects which regular expression will describe each keyword.
-By default, if GNU extensions are enabled, a word is a sequence of
-letters; the @var{regexp} used is @code{\w+}. When GNU extensions are
-disabled, a word is by default anything which ends with a space, a tab
-or a newline; the @var{regexp} used is @code{[^ \t\n]+}.
-
-An empty REGEXP is equivalent to not using this option, letting the
-default dive in. @xref{Regexps, , Syntax of Regular Expressions, emacs,
-The GNU Emacs Manual}.
-
-As a matter of convenience to the user, many usual backslashed escape
-sequences, as found in the C language, are recognized and converted to
-the corresponding characters by @code{ptx} itself.
-
-@end table
-
-@node Output formatting, , Input processing, Invoking ptx
-@section Output formatting
-
-Output format is mainly controlled by @code{-O} and @code{-T} options,
-described in the table below. When neither @code{-O} nor @code{-T} is
-selected, and if GNU extensions are enabled, the program choose an
-output format suited for a dumb terminal. Each keyword occurrence is
-output to the center of one line, surrounded by its left and right
-contexts. Each field is properly justified, so the concordance output
-could readily be observed. As a special feature, if automatic
-references are selected by option @code{-A} and are output before the
-left context, that is, if option @code{-R} is @emph{not} selected, then
-a colon is added after the reference; this nicely interfaces with GNU
-Emacs @code{next-error} processing. In this default output format, each
-white space character, like newline and tab, is merely changed to
-exactly one space, with no special attempt to compress consecutive
-spaces. This might change in the future. Except for those white space
-characters, every other character of the underlying set of 256
-characters is transmitted verbatim.
-
-Output format is further controlled by the following options.
-
-@table @code
-
-@item -g @var{number}
-@itemx --gap-size=@var{number}
-
-Select the size of the minimum white gap between the fields on the output
-line.
-
-@item -w @var{number}
-@itemx --width=@var{number}
-
-Select the output maximum width of each final line. If references are
-used, they are included or excluded from the output maximum width
-depending on the value of option @code{-R}. If this option is not
-selected, that is, when references are output before the left context,
-the output maximum width takes into account the maximum length of all
-references. If this options is selected, that is, when references are
-output after the right context, the output maximum width does not take
-into account the space taken by references, nor the gap that precedes
-them.
-
-@item -A
-@itemx --auto-reference
-
-Select automatic references. Each input line will have an automatic
-reference made up of the file name and the line ordinal, with a single
-colon between them. However, the file name will be empty when standard
-input is being read. If both @code{-A} and @code{-r} are selected, then
-the input reference is still read and skipped, but the automatic
-reference is used at output time, overriding the input reference.
-
-@item -R
-@itemx --right-side-refs
-
-In default output format, when option @code{-R} is not used, any
-reference produced by the effect of options @code{-r} or @code{-A} are
-given to the far right of output lines, after the right context. In
-default output format, when option @code{-R} is specified, references
-are rather given to the beginning of each output line, before the left
-context. For any other output format, option @code{-R} is almost
-ignored, except for the fact that the width of references is @emph{not}
-taken into account in total output width given by @code{-w} whenever
-@code{-R} is selected.
-
-This option is automatically selected whenever GNU extensions are
-disabled.
-
-@item -F @var{string}
-@itemx --flac-truncation=@var{string}
-
-This option will request that any truncation in the output be reported
-using the string @var{string}. Most output fields theoretically extend
-towards the beginning or the end of the current line, or current
-sentence, as selected with option @code{-S}. But there is a maximum
-allowed output line width, changeable through option @code{-w}, which is
-further divided into space for various output fields. When a field has
-to be truncated because cannot extend until the beginning or the end of
-the current line to fit in the, then a truncation occurs. By default,
-the string used is a single slash, as in @code{-F /}.
-
-@var{string} may have more than one character, as in @code{-F ...}.
-Also, in the particular case @var{string} is empty (@code{-F ""}),
-truncation flagging is disabled, and no truncation marks are appended in
-this case.
-
-As a matter of convenience to the user, many usual backslashed escape
-sequences, as found in the C language, are recognized and converted to
-the corresponding characters by @code{ptx} itself.
-
-@item -M @var{string}
-@itemx --macro-name=@var{string}
-
-Select another @var{string} to be used instead of @samp{xx}, while
-generating output suitable for @code{nroff}, @code{troff} or @TeX{}.
-
-@item -O
-@itemx --format=roff
-
-Choose an output format suitable for @code{nroff} or @code{troff}
-processing. Each output line will look like:
-
-@example
-.xx "@var{tail}" "@var{before}" "@var{keyword_and_after}" "@var{head}" "@var{ref}"
-@end example
-
-so it will be possible to write an @samp{.xx} roff macro to take care of
-the output typesetting. This is the default output format when GNU
-extensions are disabled. Option @samp{-M} might be used to change
-@samp{xx} to another macro name.
-
-In this output format, each non-graphical character, like newline and
-tab, is merely changed to exactly one space, with no special attempt to
-compress consecutive spaces. Each quote character: @kbd{"} is doubled
-so it will be correctly processed by @code{nroff} or @code{troff}.
-
-@item -T
-@itemx --format=tex
-
-Choose an output format suitable for @TeX{} processing. Each output
-line will look like:
-
-@example
-\xx @{@var{tail}@}@{@var{before}@}@{@var{keyword}@}@{@var{after}@}@{@var{head}@}@{@var{ref}@}
-@end example
-
-@noindent
-so it will be possible to write write a @code{\xx} definition to take
-care of the output typesetting. Note that when references are not being
-produced, that is, neither option @code{-A} nor option @code{-r} is
-selected, the last parameter of each @code{\xx} call is inhibited.
-Option @samp{-M} might be used to change @samp{xx} to another macro
-name.
-
-In this output format, some special characters, like @kbd{$}, @kbd{%},
-@kbd{&}, @kbd{#} and @kbd{_} are automatically protected with a
-backslash. Curly brackets @kbd{@{}, @kbd{@}} are also protected with a
-backslash, but also enclosed in a pair of dollar signs to force
-mathematical mode. The backslash itself produces the sequence
-@code{\backslash@{@}}. Circumflex and tilde diacritics produce the
-sequence @code{^\@{ @}} and @code{~\@{ @}} respectively. Other
-diacriticized characters of the underlying character set produce an
-appropriate @TeX{} sequence as far as possible. The other non-graphical
-characters, like newline and tab, and all others characters which are
-not part of ASCII, are merely changed to exactly one space, with no
-special attempt to compress consecutive spaces. Let me know how to
-improve this special character processing for @TeX{}.
-
-@end table
-
-@node Compatibility, , Invoking ptx, Top
-@chapter The GNU extensions to @code{ptx}
-
-This version of @code{ptx} contains a few features which do not exist in
-System V @code{ptx}. These extra features are suppressed by using the
-@samp{-G} command line option, unless overridden by other command line
-options. Some GNU extensions cannot be recovered by overriding, so the
-simple rule is to avoid @samp{-G} if you care about GNU extensions.
-Here are the differences between this program and System V @code{ptx}.
-
-@itemize @bullet
-
-@item
-This program can read many input files at once, it always writes the
-resulting concordance on standard output. On the other end, System V
-@code{ptx} reads only one file and produce the result on standard output
-or, if a second @var{file} parameter is given on the command, to that
-@var{file}.
-
-Having output parameters not introduced by options is a quite dangerous
-practice which GNU avoids as far as possible. So, for using @code{ptx}
-portably between GNU and System V, you should pay attention to always
-use it with a single input file, and always expect the result on
-standard output. You might also want to automatically configure in a
-@samp{-G} option to @code{ptx} calls in products using @code{ptx}, if
-the configurator finds that the installed @code{ptx} accepts @samp{-G}.
-
-@item
-The only options available in System V @code{ptx} are options @samp{-b},
-@samp{-f}, @samp{-g}, @samp{-i}, @samp{-o}, @samp{-r}, @samp{-t} and
-@samp{-w}. All other options are GNU extensions and are not repeated in
-this enumeration. Moreover, some options have a slightly different
-meaning when GNU extensions are enabled, as explained below.
-
-@item
-By default, concordance output is not formatted for @code{troff} or
-@code{nroff}. It is rather formatted for a dumb terminal. @code{troff}
-or @code{nroff} output may still be selected through option @code{-O}.
-
-@item
-Unless @code{-R} option is used, the maximum reference width is
-subtracted from the total output line width. With GNU extensions
-disabled, width of references is not taken into account in the output
-line width computations.
-
-@item
-All 256 characters, even @kbd{NUL}s, are always read and processed from
-input file with no adverse effect, even if GNU extensions are disabled.
-However, System V @code{ptx} does not accept 8-bit characters, a few
-control characters are rejected, and the tilda @kbd{~} is condemned.
-
-@item
-Input line length is only limited by available memory, even if GNU
-extensions are disabled. However, System V @code{ptx} processes only
-the first 200 characters in each line.
-
-@item
-The break (non-word) characters default to be every character except all
-letters of the underlying character set, diacriticized or not. When GNU
-extensions are disabled, the break characters default to space, tab and
-newline only.
-
-@item
-The program makes better use of output line width. If GNU extensions
-are disabled, the program rather tries to imitate System V @code{ptx},
-but still, there are some slight disposition glitches this program does
-not completely reproduce.
-
-@item
-The user can specify both an Ignore file and an Only file. This is not
-allowed with System V @code{ptx}.
-
-@end itemize
-
-@bye
diff --git a/gnu/usr.bin/ptx/error.c b/gnu/usr.bin/ptx/error.c
deleted file mode 100644
index 41d66fb..0000000
--- a/gnu/usr.bin/ptx/error.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* error.c -- error handler for noninteractive utilities
- Copyright (C) 1990, 1991, 1992, 1993 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. */
-
-/* Written by David MacKenzie. */
-
-#ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
- using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
- (which it would do because it found this file in $srcdir). */
-#include <config.h>
-#else
-#include "config.h"
-#endif
-#endif
-
-#include <stdio.h>
-
-#ifdef HAVE_VPRINTF
-
-#if __STDC__
-#include <stdarg.h>
-#define VA_START(args, lastarg) va_start(args, lastarg)
-#else /* !__STDC__ */
-#include <varargs.h>
-#define VA_START(args, lastarg) va_start(args)
-#endif /* !__STDC__ */
-
-#else /* !HAVE_VPRINTF */
-
-#ifdef HAVE_DOPRNT
-#define va_alist args
-#define va_dcl int args;
-#else /* !HAVE_DOPRNT */
-#define va_alist a1, a2, a3, a4, a5, a6, a7, a8
-#define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
-#endif /* !HAVE_DOPRNT */
-
-#endif /* !HAVE_VPRINTF */
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#include <string.h>
-#else /* !STDC_HEADERS */
-void exit ();
-#endif /* !STDC_HEADERS */
-
-extern char *program_name;
-
-#ifndef HAVE_STRERROR
-static char *
-private_strerror (errnum)
- int errnum;
-{
- extern char *sys_errlist[];
- extern int sys_nerr;
-
- if (errnum > 0 && errnum <= sys_nerr)
- return sys_errlist[errnum];
- return "Unknown system error";
-}
-#define strerror private_strerror
-#endif /* !HAVE_STRERROR */
-
-/* Print the program name and error message MESSAGE, which is a printf-style
- format string with optional args.
- If ERRNUM is nonzero, print its corresponding system error message.
- Exit with status STATUS if it is nonzero. */
-/* VARARGS */
-void
-#if defined (HAVE_VPRINTF) && __STDC__
-error (int status, int errnum, char *message, ...)
-#else /* !HAVE_VPRINTF or !__STDC__ */
-error (status, errnum, message, va_alist)
- int status;
- int errnum;
- char *message;
- va_dcl
-#endif /* !HAVE_VPRINTF or !__STDC__ */
-{
-#ifdef HAVE_VPRINTF
- va_list args;
-#endif /* HAVE_VPRINTF */
-
- fprintf (stderr, "%s: ", program_name);
-#ifdef HAVE_VPRINTF
- VA_START (args, message);
- vfprintf (stderr, message, args);
- va_end (args);
-#else /* !HAVE_VPRINTF */
-#ifdef HAVE_DOPRNT
- _doprnt (message, &args, stderr);
-#else /* !HAVE_DOPRNT */
- fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif /* !HAVE_DOPRNT */
-#endif /* !HAVE_VPRINTF */
- if (errnum)
- fprintf (stderr, ": %s", strerror (errnum));
- putc ('\n', stderr);
- fflush (stderr);
- if (status)
- exit (status);
-}
diff --git a/gnu/usr.bin/ptx/examples/README b/gnu/usr.bin/ptx/examples/README
deleted file mode 100644
index 038034f..0000000
--- a/gnu/usr.bin/ptx/examples/README
+++ /dev/null
@@ -1,21 +0,0 @@
-Various examples of GNU ptx usages.
-Francois Pinard <pinard@iro.umontreal.ca>, 1993.
-
-This directory contains a few examples contributed by GNU ptx users.
-Feel free to look at them for tricks or ideas. When an example
-requires many files, a subdirectory is used to hold them together.
-I have not necessarily tested these examples recently, if at all.
-
-If you have examples you would like to share, please submit them to
-me. You may also submit corrections to the examples given in this
-directory, however, please write to the authors first, since they most
-probably will like to have their say about their own contribution.
-
-* include.pl: A Perl script studying system include files.
-
-* luke/: A shell script permuting indices for man pages. It contains
-two examples of an .xx definition for *roff, one simple, one complex.
-
-* latex/: A simple example of \xx definition for latex.
-
-* ajay/: A more complex application of latex with ptx.
diff --git a/gnu/usr.bin/ptx/examples/ajay/Makefile b/gnu/usr.bin/ptx/examples/ajay/Makefile
deleted file mode 100644
index bff099c..0000000
--- a/gnu/usr.bin/ptx/examples/ajay/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-JUNKFILES = tip-index.ps tip-index.dvi tip-index.tex tip-index.log \
- tip-index.aux
-
-tip-index.ps : tip-index.dvi
- dvips tip-index.dvi
-
-tip-index.dvi : tip-index.tex
- latex tip-index.tex
-
-tip-index.tex : tip.texified header.tex footer.tex
- cat header.tex tip.texified footer.tex > tip-index.tex
-
-tip.texified : tip.eign tip.forgptx Makefile
- gptx -f -r -i ./tip.eign -T < tip.forgptx | x.pl > tip.texified
-
-tip.eign : /usr/lib/eign exclude-words
- cat /usr/lib/eign exclude-words > tip.eign
-
-screenlist : tip.texified
- cat tip.texified \
- | gawk -F\{ '{count[$$4]++} \
- END {for (s in count) printf("%d %20s\n", count[s], s)}' \
- | tr -d '}' \
- | sort -n > screenlist
- @echo "Check (say) the last 100 lines of ./screenlist".
-
-clean :
- rm -f tip.eign tip.texified $(JUNKFILES) screenlist
diff --git a/gnu/usr.bin/ptx/examples/ajay/README b/gnu/usr.bin/ptx/examples/ajay/README
deleted file mode 100644
index 7b55ca2..0000000
--- a/gnu/usr.bin/ptx/examples/ajay/README
+++ /dev/null
@@ -1,41 +0,0 @@
-To: pinard@iro.umontreal.ca
-Subject: Re: Gptx suggestions and help request
-Date: Tue, 28 Sep 93 11:30:04 +0500
-From: ajayshah@cmie.ernet.in
-
-[...] My plaintext input looks like: "pagenum multiword-phrase" where
-the multiword phrase is atmost five words. So [...], I'm doing two
-columns in small type.
-
-I got one of the programmers here to write me a tex macro for my
-problem. When it goes into production I'll mail you a few files: a
-sample input, the gptx command, the output, and the tex macro. If you
-find these interesting you can ship them with future gptx releases.
-
-Thanks a lot for gptx. If you have a mailing list of loyal users,
-you can add us to it :-)
-
-
-To: pinard@iro.umontreal.ca
-Cc: rk@cmie.ernet.in
-Subject: All glue code I used with gptx
-Date: Tue, 05 Oct 93 15:23:44 +0500
-From: ajayshah@zigma.cmie.ernet.in
-
-That is a full set of a files for an example of "production use". You
-are welcome to post them, or use them as a sample supplied with the
-gptx distribution, etc., with absolutely no restrictions on what
-anyone does with this. In case you do so, please acknowledge the
-contribution of Rakesh Chauhan, rk@cmie.ernet.in, who is the author of
-x.pl and header.tex. [...]
-
-As you can tell, I used it for a 100% realworld problem, and it
-worked. Thanks a million. If you'd like, I can send you a hardcopy
-of the full finished document (just send me your mailing address). If
-you would like to mention the name of this document when you use
-these files as a demo, it is
-
- Trends in Industrial Production
- September 1993
- Centre for Monitoring Indian Economy, Bombay, India.
-
diff --git a/gnu/usr.bin/ptx/examples/ajay/footer.tex b/gnu/usr.bin/ptx/examples/ajay/footer.tex
deleted file mode 100644
index 6b47932..0000000
--- a/gnu/usr.bin/ptx/examples/ajay/footer.tex
+++ /dev/null
@@ -1 +0,0 @@
-\end{document}
diff --git a/gnu/usr.bin/ptx/examples/ajay/header.tex b/gnu/usr.bin/ptx/examples/ajay/header.tex
deleted file mode 100644
index 04a9c64..0000000
--- a/gnu/usr.bin/ptx/examples/ajay/header.tex
+++ /dev/null
@@ -1,21 +0,0 @@
-\documentstyle [twocolumn,a4]{article}
-
-\pagestyle{empty}
-
-\textwidth 6.8in
-\oddsidemargin -.8in
-\evensidemargin -.8in
-\textheight 10in
-\topmargin -1in
-% \columnseprule 1pt
-
-\begin{document}
-
-\def\xx #1#2#3#4#5#6{\hbox to \hsize{%
-\hbox to 1.4in{\hfill #2}\hskip .05in%
-\hbox to .8in{\it #3\hfil}\hskip .05in%
-\hbox to 1.4in{#4\hfil}\hskip .05in%
-\hbox{\hfil #6}\hfil}%
-}
-
-\scriptsize
diff --git a/gnu/usr.bin/ptx/examples/ajay/tip.forgptx b/gnu/usr.bin/ptx/examples/ajay/tip.forgptx
deleted file mode 100644
index ecf6e0e..0000000
--- a/gnu/usr.bin/ptx/examples/ajay/tip.forgptx
+++ /dev/null
@@ -1,10 +0,0 @@
-1 Zinc concentrate
-1 Coal
-1 Ball clay
-1 Non-coking coal
-1 Calcareous sand
-1 Natural Gas
-1 Chalk
-1 Bauxite
-1 Clay (others)
-1 Copper ore
diff --git a/gnu/usr.bin/ptx/examples/ajay/x.pl b/gnu/usr.bin/ptx/examples/ajay/x.pl
deleted file mode 100644
index e0615ba..0000000
--- a/gnu/usr.bin/ptx/examples/ajay/x.pl
+++ /dev/null
@@ -1,22 +0,0 @@
-#! /usr/local/bin/perl
-
-while ($l = <>)
-{
-chop $l;
-
-$l =~ s/\\xx //;
-$l =~ s/}{/|/g;
-$l =~ s/{//g;
-$l =~ s/}//g;
-@x = split(/\|/, $l);
-
-printf ("\\xx ");
-for ($i = 0; $i <= $#x; $i++)
- {
- $v = substr($x[$i], 0, 17);
- $v =~ s/\\$//;
- printf("{%s}", $v);
- }
-printf ("\n");
-
-}
diff --git a/gnu/usr.bin/ptx/examples/ignore/README b/gnu/usr.bin/ptx/examples/ignore/README
deleted file mode 100644
index 33ee19e..0000000
--- a/gnu/usr.bin/ptx/examples/ignore/README
+++ /dev/null
@@ -1,65 +0,0 @@
-From beebe@math.utah.edu Wed Oct 27 19:37:22 1993
-Date: Tue, 26 Oct 93 15:43:19 MDT
-From: "Nelson H. F. Beebe" <beebe@math.utah.edu>
-To: pinard@iro.umontreal.ca
-Subject: Re: Another short comment on gptx 0.2
-
-/usr/lib/eign: DECstation 5000, ULTRIX 4.3
- HP 9000/735, HP-UX 9.0
- IBM RS/6000, AIX 2.3
- IBM 3090, AIX MP370 2.1
- Stardent 1520, OS 2.2
- Sun SPARCstation, SunOS 4.x
-
-No eign anywhere on: HP 375, BSD 4.3 (ptx.c is in /usr/src/usr.bin,
- and the source code refers to /usr/lib/eign,
- but I could not find it in the source tree)
- NeXT, Mach 3.0 (though documented in man pages)
- Sun SPARCstation, Solaris 2.x
- SGI Indigo, IRIX 4.0.x
-
-The contents of the eign files that I found on the above machines were
-almost identical. With the exception of the Stardent and the IBM
-3090, there were only two such files, one with 150 words, and the
-other with 133, with only a few differences between them (some words
-in the 133-word file were not in the 150-word file). I found the
-133-word variant in groff-1.06/src/indxbib. I used archie to search
-for eign, and it found 7 sites, all with the groff versions.
-
-The Stardent and IBM 3090 eign files have the same contents as the
-150-word version, but have a multiline copyright comment at the
-beginning. None of the others contains a copyright.
-
-I recently had occasion to build a similar list of words for bibindex,
-which indexes a BibTeX .bib file, and for which omission of common
-words, like articles and prepositions, helps to reduce the size of the
-index. I didn't use eign to build that list, but instead, went
-through the word lists from 3.8MB of .bib files in the tuglib
-collection on ftp.math.utah.edu:pub/tex/bib, and collected words to be
-ignored. That list includes words from several languages. I'll leave
-it up to you to decide whether you wish to merge them or not; I
-suspect it may be a better design choice to keep a separate eign file
-for each language, although in my own application of ptx-ing
-bibliographies, the titles do occur in multiple languages, so a
-mixed-language eign is appropriate. Since there are standard ISO
-2-letter abbreviations for every country, perhaps one could have
-eign.xy for country xy (of course, only approximately is country ==
-language). The exact list of words in eign is not so critical; its
-only purpose is to reduce the size of the output by not indexing words
-that occur very frequently and have little content in themselves.
-
-I'm enclosing a shar bundle at the end of this message with the merger
-of the multiple eign versions (duplicates eliminated, and the list
-sorted into 179 unique words), followed by the bibindex list.
-
-
-
-========================================================================
-Nelson H. F. Beebe Tel: +1 801 581 5254
-Center for Scientific Computing FAX: +1 801 581 4148
-Department of Mathematics, 105 JWB Internet: beebe@math.utah.edu
-University of Utah
-Salt Lake City, UT 84112, USA
-========================================================================
-
-
diff --git a/gnu/usr.bin/ptx/examples/ignore/bix b/gnu/usr.bin/ptx/examples/ignore/bix
deleted file mode 100644
index b9a8ba6..0000000
--- a/gnu/usr.bin/ptx/examples/ignore/bix
+++ /dev/null
@@ -1,109 +0,0 @@
-ab
-aber
-als
-an
-and
-are
-as
-auf
-aus
-az
-bei
-bir
-but
-da
-das
-dat
-de
-dei
-dem
-den
-der
-des
-det
-di
-die
-dos
-een
-eene
-egy
-ei
-ein
-eine
-einen
-einer
-eines
-eit
-el
-en
-er
-es
-et
-ett
-eyn
-eyne
-for
-from
-fuer
-fur
-gl
-gli
-ha
-haben
-had
-hai
-has
-hat
-have
-he
-heis
-hen
-hena
-henas
-het
-hin
-hinar
-hinir
-hinn
-hith
-ho
-hoi
-il
-in
-ist
-ka
-ke
-la
-las
-le
-les
-lo
-los
-mia
-mit
-na
-nji
-not
-oder
-of
-on
-or
-os
-others
-sie
-sind
-so
-ta
-the
-to
-um
-uma
-un
-una
-und
-une
-uno
-unter
-von
-with
-yr
diff --git a/gnu/usr.bin/ptx/examples/ignore/eign b/gnu/usr.bin/ptx/examples/ignore/eign
deleted file mode 100644
index 0401245..0000000
--- a/gnu/usr.bin/ptx/examples/ignore/eign
+++ /dev/null
@@ -1,163 +0,0 @@
-a
-about
-after
-against
-all
-also
-an
-and
-another
-any
-are
-as
-at
-back
-be
-because
-been
-before
-being
-between
-both
-but
-by
-came
-can
-come
-could
-current
-day
-did
-do
-down
-each
-end
-even
-first
-for
-from
-get
-go
-good
-great
-had
-has
-have
-he
-her
-here
-him
-his
-how
-i
-if
-in
-into
-is
-it
-its
-just
-know
-last
-life
-like
-little
-long
-made
-make
-man
-many
-may
-me
-men
-might
-more
-most
-mr
-much
-must
-my
-name
-never
-new
-no
-not
-now
-of
-off
-old
-on
-one
-only
-or
-other
-our
-out
-over
-own
-part
-people
-point
-right
-said
-same
-say
-see
-she
-should
-since
-so
-some
-start
-state
-still
-such
-take
-than
-that
-the
-their
-them
-then
-there
-these
-they
-this
-those
-three
-through
-time
-to
-too
-true
-try
-two
-under
-up
-us
-use
-used
-value
-very
-was
-way
-we
-well
-were
-what
-when
-where
-which
-while
-who
-why
-will
-with
-without
-work
-world
-would
-year
-years
-you
-your
diff --git a/gnu/usr.bin/ptx/examples/include.pl b/gnu/usr.bin/ptx/examples/include.pl
deleted file mode 100755
index cb3c0ff..0000000
--- a/gnu/usr.bin/ptx/examples/include.pl
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/perl -- # -*-Perl-*-
-eval "exec /usr/bin/perl -S $0 $*"
- if $running_under_some_shell;
-
-# Construct a permuted index for all system include files.
-# Copyright (C) 1991 Free Software Foundation, Inc.
-# Francois Pinard <pinard@iro.umontreal.ca>, June 1991.
-
-# NOTE: about removing asm statements?
-# NOTE: about removing strings?
-# NOTE: about ignoring 0xHEXDIGITS, unchar/ushort/etc.
-
-# Construct a sorted list of system include files.
-
-opendir (DIR, "/usr/include");
-@includes = sort grep (-f "/usr/include/$_", readdir (DIR));
-opendir (DIR, "/usr/include/sys");
-foreach (sort grep (-f "/usr/include/sys/$_", readdir (DIR))) {
- push (@includes, "sys/$_");
-}
-closedir (DIR);
-
-# Launch the permuted indexer, with a list of ignore words.
-
-$ignore = "/tmp/incptx.$$";
-open (IGNORE, "> $ignore");
-print IGNORE join ("\n", split (' ', <<IGNORE)), "\n";
-asm at at386 break bss case ch char continue copyright corporation
-default define defined do double dst else endif enum extern file flag
-float for goto i286 i386 ident if ifdef ifndef int interactive len
-lint long m32 mpat num pdp11 printf ptr register return sco5 short siz
-sizeof src static str struct sun switch sys systems type typedef u370
-u3b u3b15 u3b2 u3b5 undef union unsigned vax void while win
-IGNORE
-close IGNORE;
-exit 0;
-
-open (OUTPUT, "| ptx -r -f -W '[a-zA-Z_][a-zA-Z_0-9]+' -F ... -i $ignore")
- || die "ptx did not start\n";
-select (OUTPUT);
-
-# Reformat all files, removing C comments and adding a reference field.
-
-foreach $include (@includes)
-{
- warn "Reading /usr/include/$include\n";
- open (INPUT, "/usr/include/$include");
- while (<INPUT>)
- {
-
- # Get rid of comments.
-
- $comment = $next_comment;
- if ($comment)
- {
- $next_comment = !s,^.*\*/,,;
- }
- else
- {
- s,/\*.*\*/,,g;
- $next_comment = s,/\*.*,,;
- }
- next if $comment && $next_comment;
-
- # Remove extraneous white space.
-
- s/[ \t]+/ /g;
- s/ $//;
- next if /^$/;
-
- # Print the line with its reference.
-
- print "$include($.): ", $_;
- }
-}
-
-warn "All read, now ptx' game!\n";
-close OUTPUT || die "ptx failed...\n";
-unlink $ignore;
diff --git a/gnu/usr.bin/ptx/examples/latex/Makefile b/gnu/usr.bin/ptx/examples/latex/Makefile
deleted file mode 100644
index 5f930b2..0000000
--- a/gnu/usr.bin/ptx/examples/latex/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# Example of using ptx with latex.
-# Copyright (C) 1993 Free Software Foundation, Inc.
-# Francois Pinard <pinard@iro.umontreal.ca>, 1993.
-
-PTX = ../ptx
-PTX_OPTIONS = -AfTWi.i
-
-try: latex.dvi
- xdvi latex
-
-latex.dvi: latex.tex table.tex
- latex latex
-
-table.tex: Makefile ../COPYING
- $(PTX) $(PTX_OPTIONS) ../COPYING | sed 's/ //' > table.tex
diff --git a/gnu/usr.bin/ptx/examples/latex/README b/gnu/usr.bin/ptx/examples/latex/README
deleted file mode 100644
index fc5098a..0000000
--- a/gnu/usr.bin/ptx/examples/latex/README
+++ /dev/null
@@ -1,10 +0,0 @@
-Date: Sun, 26 Sep 93 19:07:10 EDT
-From: Francois Pinard <pinard@iro.umontreal.ca>
-To: ajayshah@cmie.ernet.in
-Subject: Re: Gptx suggestions and help request
-
- In fact, if you could send me such a macro right now I would be
- thrilled :-)
-
-Ok, I worked out this example for you. Even if a little rude, you can
-still start from it for your own need. [...]
diff --git a/gnu/usr.bin/ptx/examples/latex/latex.tex b/gnu/usr.bin/ptx/examples/latex/latex.tex
deleted file mode 100644
index 1f0a2f1..0000000
--- a/gnu/usr.bin/ptx/examples/latex/latex.tex
+++ /dev/null
@@ -1,11 +0,0 @@
-\documentstyle[11pt]{article}
-\begin{document}
-
-\def\xx#1#2#3#4#5#6{\hbox{
- \hbox to2.5in{\hfil#5#2}
- \hbox to3.0in{{\sl #3}\,#4#1\hfil}
- \hbox to1.5in{\tiny#6\hfil}
-}}
-\input table
-
-\end{document}
diff --git a/gnu/usr.bin/ptx/examples/latex/table.tex b/gnu/usr.bin/ptx/examples/latex/table.tex
deleted file mode 100644
index b68ea38..0000000
--- a/gnu/usr.bin/ptx/examples/latex/table.tex
+++ /dev/null
@@ -1,65 +0,0 @@
-\xx {}{ate to certain respons}{ibi}{lities for you if you}{}{../COPYING:30}
-\xx {}{These actions are proh}{ibi}{ted by law if you do n}{}{../COPYING:183}
-\xx {}{EN ADVISED OF THE POSS}{IBI}{LITY OF SUCH DAMAGES.}{}{../COPYING:278}
-\xx {}{icense may add an expl}{ici}{t geographical distrib}{}{../COPYING:232}
-\xx {}{OF ALL NECESSARY SERV}{ICI}{NG, REPAIR OR CORRECTI}{}{../COPYING:267}
-\xx {}{aims or to contest val}{idi}{ty of any such claims;}{}{../COPYING:216}
-\xx {}{If the software is mod}{ifi}{ed by someone else and}{}{../COPYING:45}
-\xx {}{, distribution and mod}{ifi}{cation follow.}{pying}{../COPYING:57}
-\xx {}{, DISTRIBUTION AND MOD}{IFI}{CATION 0. This Lice}{}{../COPYING:60}
-\xx {}{r verbatim or with mod}{ifi}{cations and/or transla}{}{../COPYING:68}
-\xx {}{ation in the term "mod}{ifi}{cation".)}{t limit}{../COPYING:70}
-\xx {}{, distribution and mod}{ifi}{cation are not covered}{}{../COPYING:72}
-\xx {}{nd distribute such mod}{ifi}{cations or work under}{}{../COPYING:92}
-\xx {}{You must cause the mod}{ifi}{ed files to carry prom}{}{../COPYING:95}
-\xx {ads c}{c) If the mod}{ifi}{ed program normally re}{}{../COPYING:103}
-\xx {}{ments apply to the mod}{ifi}{ed work as a whole.}{}{../COPYING:114}
-\xx {work are n}{If ident}{ifi}{able sections of that}{}{../COPYING:115}
-\xx {}{he work for making mod}{ifi}{cations to it.}{of t}{../COPYING:156}
-\xx {}{If the Program spec}{ifi}{es a version number of}{}{../COPYING:243}
-\xx {}{hey have is not the or}{igi}{nal, so that any probl}{}{../COPYING:46}
-\xx {}{not reflect on the or}{igi}{nal authors' reputatio}{}{../COPYING:47}
-\xx {}{a license from the or}{igi}{nal licensor to copy,}{}{../COPYING:191}
-\xx {}{ted interfaces, the or}{igi}{nal copyright holder w}{}{../COPYING:231}
-\xx {}{RRANTIES OF MERCHANTAB}{ILI}{TY AND FITNESS FOR A P}{}{../COPYING:265}
-\xx {}{OUT OF THE USE OR INAB}{ILI}{TY TO USE THE PROGRAM}{}{../COPYING:274}
-\xx {}{anty of MERCHANTAB}{ILI}{TY or FITNESS FOR A PA}{}{../COPYING:303}
-\xx {}{is included without l}{imi}{tation in the term "mo}{}{../COPYING:69}
-\xx {}{ny other reason (not l}{imi}{ted to patent issues),}{}{../COPYING:198}
-\xx {}{aphical distribution l}{imi}{tation excluding those}{}{../COPYING:232}
-\xx {}{nse incorporates the l}{imi}{tation as if written i}{}{../COPYING:235}
-\xx {}{new versions will be s}{imi}{lar in spirit to the p}{}{../COPYING:239}
-\xx {}{, INCLUDING, BUT NOT L}{IMI}{TED TO, THE IMPLIED WA}{}{../COPYING:264}
-\xx {}{M (INCLUDING BUT NOT L}{IMI}{TED TO LOSS OF DATA OR}{}{../COPYING:274}
-\xx {}{s to say, a work conta}{ini}{ng the Program or a po}{}{../COPYING:67}
-\xx {}{sociated interface def}{ini}{tion files, plus the s}{}{../COPYING:158}
-\xx {}{you must give the rec}{ipi}{ents all the rights th}{}{../COPYING:34}
-\xx {}{ed on, we want its rec}{ipi}{ents to know that what}{}{../COPYING:46}
-\xx {}{and give any other rec}{ipi}{ents of the Program a}{}{../COPYING:84}
-\xx {}{the Program), the rec}{ipi}{ent automatically rece}{}{../COPYING:190}
-\xx {}{estrictions on the rec}{ipi}{ents' exercise of the}{}{../COPYING:193}
-\xx {}{will be similar in sp}{iri}{t to the present versi}{}{../COPYING:239}
-\xx {he two goal}{Our dec}{isi}{on will be guided by t}{}{../COPYING:254}
-\xx {}{NSEQUENTIAL DAMAGES AR}{ISI}{NG OUT OF THE USE OR I}{}{../COPYING:273}
-\xx {}{tive mode: Gnomov}{isi}{on version 69, Copyrig}{}{../COPYING:315}
-\xx {}{e of author Gnomov}{isi}{on comes with ABSOLUTE}{}{../COPYING:316}
-\xx {}{the program `Gnomov}{isi}{on' (which makes passe}{}{../COPYING:330}
-\xx {}{to certain responsibil}{iti}{es for you if you dist}{}{../COPYING:30}
-\xx {}{precise terms and cond}{iti}{ons for copying, distr}{}{../COPYING:56}
-\xx {}{ENSE TERMS AND COND}{ITI}{ONS FOR COPYING, DISTR}{}{../COPYING:60}
-\xx {}{meet all of these cond}{iti}{ons: a) You must}{}{../COPYING:93}
-\xx {}{m under these cond}{iti}{ons, and telling the u}{}{../COPYING:109}
-\xx {f another wo}{In add}{iti}{on, mere aggregation o}{}{../COPYING:129}
-\xx {}{all its terms and cond}{iti}{ons for copying, distr}{}{../COPYING:186}
-\xx {}{o these terms and cond}{iti}{ons.}{bject t}{../COPYING:192}
-\xx {}{o patent issues), cond}{iti}{ons are imposed on you}{}{../COPYING:199}
-\xx {}{at contradict the cond}{iti}{ons of this License, t}{}{../COPYING:200}
-\xx {}{cuse you from the cond}{iti}{ons of this License.}{}{../COPYING:201}
-\xx {}{ing the terms and cond}{iti}{ons either of that ver}{}{../COPYING:244}
-\xx {}{hose distribution cond}{iti}{ons are different, wri}{}{../COPYING:251}
-\xx {}{OTHERWISE STATED IN WR}{ITI}{NG THE COPYRIGHT HOLDE}{}{../COPYING:262}
-\xx {}{LAW OR AGREED TO IN WR}{ITI}{NG WILL ANY COPYRIGHT}{}{../COPYING:270}
-\xx {}{END OF TERMS AND COND}{ITI}{ONS Appendix: How t}{}{../COPYING:280}
-\xx {}{under certain cond}{iti}{ons; type `show c' for}{}{../COPYING:318}
-\xx {}{free program will ind}{ivi}{dually obtain patent l}{}{../COPYING:52}
-\xx {g, distribution}{Act}{ivi}{ties other than copyin}{}{../COPYING:72}
diff --git a/gnu/usr.bin/ptx/examples/luke/README b/gnu/usr.bin/ptx/examples/luke/README
deleted file mode 100644
index 6291861..0000000
--- a/gnu/usr.bin/ptx/examples/luke/README
+++ /dev/null
@@ -1,2 +0,0 @@
-From: Luke Kendall <luke@research.canon.oz.au>
-Date: Wed, 16 Oct 91 12:26:39 EST
diff --git a/gnu/usr.bin/ptx/examples/luke/xxroff.sh b/gnu/usr.bin/ptx/examples/luke/xxroff.sh
deleted file mode 100644
index 55ef908..0000000
--- a/gnu/usr.bin/ptx/examples/luke/xxroff.sh
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/bin/sh
-#
-# Author: Luke Kendall
-#
-MYNAME=`basename $0`
-usage="usage: $MYNAME [man-directory]
- (generates permuted index of -man files in directory)"
-md=/usr/man
-#
-if [ $# = 0 ]
-then
- echo "$MYNAME: no man directory specified: assuming $md"
-elif [ $# != 1 ]
-then
- echo "$usage"
- exit 1
-elif [ -d $1 ]
-then
- md="$1"
-else
- echo "$usage"
- exit 1
-fi
-echo "Permuted index of $md:"
-out=ptx.tr
-# ------ clumsy permuted index macros (replaced by stuff below) ------------
-cat <<'EOF' > $out
-.pn 1
-.de xx
-\\$1 \\$2 \\fB\\$3\\fR \\$4 \\s-1\\$5\\s0
-..
-.pl 10i
-.de NP
-.ev 1
-.ft 1
-.ps 10
-.sp 0.75c
-.tl '\s-2\\fIpermuted index\\fP\s0'\- \\n% \-'\s-2\\fIpermuted index\\fP\s0'
-.pn +1
-.bp
-.ev
-..
-.wh 9i NP
-.nf
-.na
-.ta 6.5i-1.1iR 6.5iR 6.51iR 6.52R
-.ll 6.0i
-.po 0i
-.sp 0.25i
-'\"
-EOF
-# ------ ------- ------- ------- ------- -------
-# ------ alternate permuted index macros (from net) ------------
-cat <<'EOF' > $out
-.pl 10i
-.de NP
-.ev 1
-.ft 1
-.ps 10
-.sp 0.75c
-.tl '\s-2\\fIpermuted index\\fP\s0'\- \\n% \-'\s-2\\fIpermuted index\\fP\s0'
-.pn +1
-.bp
-.ev
-..
-.wh 9i NP
-.po 0.5i
-.sp 0.25i
-.tr ~ \" tildes will translate to blanks
-'\".ll 80 \" line length of output
-.ll 6.0i \" line length of output
-.nf \" must be in no-fill mode
-.nr )r \n(.lu-10n \" set position of reference in line (10 less than length)
-.nr )k \n()ru/2u \" set position of keyword (approx. centered)
-.ds s2 ~~~ \" this is the center gap -- 3 spaces
-.de xx \"definition of xx macro
-.ds s1\" \" initialise to null string
-.if \w@\\$2@ .ds s1 ~\" \"set to single blank if there is second arg
-.ds s3\" \" initialise to null string
-.if \w@\\$4@ .ds s3 ~\" \"set to single blank if there is second arg
-.ds s4 ~\" \" set to single blank
-.ds s5 ~\" \" set to single blank
-.ds y \\*(s4\a\\*(s5\" \" blank, leader, blank
-.ta \\n()ru-\w@\\*(s5@u \" set tab just to left of ref
-\h@\\n()ku-\w@\\$1\\*(s1\\$2\\*(s2@u@\\$1\\*(s1\\$2\\*(s2\\$3\\*(s3\\$4\\*y\\$5
-..
- ~
-EOF
-# ------ ------- ------- ------- ------- -------
-find $md -type f -name "*.[1-8nl]*" -print |
-while read f
-do
- man=`basename $f`
- man=`expr "$man" : "\(.*\)\.[^\.]*"`
-echo $man:
- #
- # Use 1st non-"." and non-"'" started line as input to ptx (this
- # should be the synopsis after the `.SH NAME');
- # strip any "\-" from it (a silly sort key for ptx to avoid);
- # insert a leading man page name for the -r option to find
- #
- sed -n '/^[^.]/s/\\-//g;/^[^.]/p;/^[^.]/q' $f | sed "s/^/($man) /"
-done | ptx -t -f -r >> $out
-#
-# Turn the troff'able permuted index file into PostScript
-#
-psroff -t -rL10i $out > ptx.ps
-echo "$out and ptx.ps produced from man directory $md."
diff --git a/gnu/usr.bin/ptx/getopt.c b/gnu/usr.bin/ptx/getopt.c
deleted file mode 100644
index 7a4673b..0000000
--- a/gnu/usr.bin/ptx/getopt.c
+++ /dev/null
@@ -1,757 +0,0 @@
-/* Getopt for GNU.
- NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
- before changing it!
-
- Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
- 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef HAVE_CONFIG_H
-#if defined (emacs) || defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
- using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
- (which it would do because it found this file in $srcdir). */
-#include <config.h>
-#else
-#include "config.h"
-#endif
-#endif
-
-#ifndef __STDC__
-/* This is a separate conditional since some stdc systems
- reject `defined (const)'. */
-#ifndef const
-#define const
-#endif
-#endif
-
-/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
-#ifndef _NO_PROTO
-#define _NO_PROTO
-#endif
-
-#include <stdio.h>
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-/* Don't include stdlib.h for non-GNU C libraries because some of them
- contain conflicting prototypes for getopt. */
-#include <stdlib.h>
-#endif /* GNU C library. */
-
-/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
- long-named option. Because this is not POSIX.2 compliant, it is
- being phased out. */
-/* #define GETOPT_COMPAT */
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- to intersperse the options with the other arguments.
-
- As `getopt' works, it permutes the elements of ARGV so that,
- when it is done, all the options precede everything else. Thus
- all application programs are extended to handle flexible argument order.
-
- Setting the environment variable POSIXLY_CORRECT disables permutation.
- Then the behavior is completely standard.
-
- GNU application programs can use a third alternative mode in which
- they can distinguish the relative order of options and other arguments. */
-
-#include "getopt.h"
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-char *optarg = 0;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-/* XXX 1003.2 says this must be 1 before any call. */
-int optind = 0;
-
-/* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
-static char *nextchar;
-
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-int optopt = '?';
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
- If the caller did not specify anything,
- the default is REQUIRE_ORDER if the environment variable
- POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
- REQUIRE_ORDER means don't recognize them as options;
- stop option processing when the first non-option is seen.
- This is what Unix does.
- This mode of operation is selected by either setting the environment
- variable POSIXLY_CORRECT, or using `+' as the first character
- of the list of option characters.
-
- PERMUTE is the default. We permute the contents of ARGV as we scan,
- so that eventually all the non-options are at the end. This allows options
- to be given in any order, even with programs that were not written to
- expect this.
-
- RETURN_IN_ORDER is an option available to programs that were written
- to expect options and other ARGV-elements in any order and that care about
- the ordering of the two. We describe each non-option ARGV-element
- as if it were the argument of an option with character code 1.
- Using `-' as the first character of the list of option characters
- selects this mode of operation.
-
- The special argument `--' forces an end of option-scanning regardless
- of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return EOF with `optind' != ARGC. */
-
-static enum
-{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-#ifdef __GNU_LIBRARY__
-/* We want to avoid inclusion of string.h with non-GNU libraries
- because there are many ways it can cause trouble.
- On some systems, it contains special magic macros that don't work
- in GCC. */
-#include <string.h>
-#define my_index strchr
-#else
-
-/* Avoid depending on library functions or files
- whose names are inconsistent. */
-
-char *getenv ();
-
-static char *
-my_index (str, chr)
- const char *str;
- int chr;
-{
- while (*str)
- {
- if (*str == chr)
- return (char *) str;
- str++;
- }
- return 0;
-}
-
-/* If using GCC, we can safely declare strlen this way.
- If not using GCC, it is ok not to declare it.
- (Supposedly there are some machines where it might get a warning,
- but changing this conditional to __STDC__ is too risky.) */
-#ifdef __GNUC__
-#ifdef IN_GCC
-#include "gstddef.h"
-#else
-#include <stddef.h>
-#endif
-extern size_t strlen (const char *);
-#endif
-
-#endif /* GNU C library. */
-
-/* Handle permutation of arguments. */
-
-/* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
-static int first_nonopt;
-static int last_nonopt;
-
-/* Exchange two adjacent subsequences of ARGV.
- One subsequence is elements [first_nonopt,last_nonopt)
- which contains all the non-options that have been skipped so far.
- The other is elements [last_nonopt,optind), which contains all
- the options processed since those non-options were skipped.
-
- `first_nonopt' and `last_nonopt' are relocated so that they describe
- the new indices of the non-options in ARGV after they are moved. */
-
-static void
-exchange (argv)
- char **argv;
-{
- int bottom = first_nonopt;
- int middle = last_nonopt;
- int top = optind;
- char *tem;
-
- /* Exchange the shorter segment with the far end of the longer segment.
- That puts the shorter segment into the right place.
- It leaves the longer segment in the right place overall,
- but it consists of two parts that need to be swapped next. */
-
- while (top > middle && middle > bottom)
- {
- if (top - middle > middle - bottom)
- {
- /* Bottom segment is the short one. */
- int len = middle - bottom;
- register int i;
-
- /* Swap it with the top part of the top segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[top - (middle - bottom) + i];
- argv[top - (middle - bottom) + i] = tem;
- }
- /* Exclude the moved bottom segment from further swapping. */
- top -= len;
- }
- else
- {
- /* Top segment is the short one. */
- int len = top - middle;
- register int i;
-
- /* Swap it with the bottom part of the bottom segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[middle + i];
- argv[middle + i] = tem;
- }
- /* Exclude the moved top segment from further swapping. */
- bottom += len;
- }
- }
-
- /* Update records for the slots the non-options now occupy. */
-
- first_nonopt += (optind - last_nonopt);
- last_nonopt = optind;
-}
-
-/* Scan elements of ARGV (whose length is ARGC) for option characters
- given in OPTSTRING.
-
- If an element of ARGV starts with '-', and is not exactly "-" or "--",
- then it is an option element. The characters of this element
- (aside from the initial '-') are option characters. If `getopt'
- is called repeatedly, it returns successively each of the option characters
- from each of the option elements.
-
- If `getopt' finds another option character, it returns that character,
- updating `optind' and `nextchar' so that the next call to `getopt' can
- resume the scan with the following option character or ARGV-element.
-
- If there are no more option characters, `getopt' returns `EOF'.
- Then `optind' is the index in ARGV of the first ARGV-element
- that is not an option. (The ARGV-elements have been permuted
- so that those that are not options now come last.)
-
- OPTSTRING is a string containing the legitimate option characters.
- If an option character is seen that is not listed in OPTSTRING,
- return '?' after printing an error message. If you set `opterr' to
- zero, the error message is suppressed but we still return '?'.
-
- If a char in OPTSTRING is followed by a colon, that means it wants an arg,
- so the following text in the same ARGV-element, or the text of the following
- ARGV-element, is returned in `optarg'. Two colons mean an option that
- wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `optarg', otherwise `optarg' is set to zero.
-
- If OPTSTRING starts with `-' or `+', it requests different methods of
- handling the non-option ARGV-elements.
- See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
-
- Long-named options begin with `--' instead of `-'.
- Their names may be abbreviated as long as the abbreviation is unique
- or is an exact match for some defined option. If they have an
- argument, it follows the option name in the same ARGV-element, separated
- from the option name by a `=', or else the in next ARGV-element.
- When `getopt' finds a long-named option, it returns 0 if that option's
- `flag' field is nonzero, the value of the option's `val' field
- if the `flag' field is zero.
-
- The elements of ARGV aren't really const, because we permute them.
- But we pretend they're const in the prototype to be compatible
- with other systems.
-
- LONGOPTS is a vector of `struct option' terminated by an
- element containing a name which is zero.
-
- LONGIND returns the index in LONGOPT of the long-named option found.
- It is only valid when a long-named option has been found by the most
- recent call.
-
- If LONG_ONLY is nonzero, '-' as well as '--' can introduce
- long-named options. */
-
-int
-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
- int argc;
- char *const *argv;
- const char *optstring;
- const struct option *longopts;
- int *longind;
- int long_only;
-{
- int option_index;
-
- optarg = 0;
-
- /* Initialize the internal data when the first call is made.
- Start processing options with ARGV-element 1 (since ARGV-element 0
- is the program name); the sequence of previously skipped
- non-option ARGV-elements is empty. */
-
- if (optind == 0)
- {
- first_nonopt = last_nonopt = optind = 1;
-
- nextchar = NULL;
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-')
- {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- }
- else if (optstring[0] == '+')
- {
- ordering = REQUIRE_ORDER;
- ++optstring;
- }
- else if (getenv ("POSIXLY_CORRECT") != NULL)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
- }
-
- if (nextchar == NULL || *nextchar == '\0')
- {
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Now skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < argc
- && (argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- optind++;
- last_nonopt = optind;
- }
-
- /* Special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp (argv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return EOF;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- {
- if (ordering == REQUIRE_ORDER)
- return EOF;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- Start decoding its characters. */
-
- nextchar = (argv[optind] + 1
- + (longopts != NULL && argv[optind][1] == '-'));
- }
-
- if (longopts != NULL
- && ((argv[optind][0] == '-'
- && (argv[optind][1] == '-' || long_only))
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- ))
- {
- const struct option *p;
- char *s = nextchar;
- int exact = 0;
- int ambig = 0;
- const struct option *pfound = NULL;
- int indfound;
-
- while (*s && *s != '=')
- s++;
-
- /* Test all options for either exact match or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name;
- p++, option_index++)
- if (!strncmp (p->name, nextchar, s - nextchar))
- {
- if (s - nextchar == strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' is ambiguous\n",
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- return '?';
- }
-
- if (pfound != NULL)
- {
- option_index = indfound;
- optind++;
- if (*s)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = s + 1;
- else
- {
- if (opterr)
- {
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- "%s: option `--%s' doesn't allow an argument\n",
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- "%s: option `%c%s' doesn't allow an argument\n",
- argv[0], argv[optind - 1][0], pfound->name);
- }
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' requires an argument\n",
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- /* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- || my_index (optstring, *nextchar) == NULL)
- {
- if (opterr)
- {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf (stderr, "%s: unrecognized option `--%s'\n",
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf (stderr, "%s: unrecognized option `%c%s'\n",
- argv[0], argv[optind][0], nextchar);
- }
- nextchar = (char *) "";
- optind++;
- return '?';
- }
- }
-
- /* Look at and handle the next option-character. */
-
- {
- char c = *nextchar++;
- char *temp = my_index (optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == '\0')
- ++optind;
-
- if (temp == NULL || c == ':')
- {
- if (opterr)
- {
-#if 0
- if (c < 040 || c >= 0177)
- fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
- argv[0], c);
- else
- fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
-#else
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
-#endif
- }
- optopt = c;
- return '?';
- }
- if (temp[1] == ':')
- {
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = 0;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
-#if 0
- fprintf (stderr, "%s: option `-%c' requires an argument\n",
- argv[0], c);
-#else
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, "%s: option requires an argument -- %c\n",
- argv[0], c);
-#endif
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
- }
- return c;
- }
-}
-
-int
-getopt (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
-{
- return _getopt_internal (argc, argv, optstring,
- (const struct option *) 0,
- (int *) 0,
- 0);
-}
-
-#endif /* _LIBC or not __GNU_LIBRARY__. */
-
-#ifdef TEST
-
-/* Compile with -DTEST to make an executable for use in testing
- the above definition of `getopt'. */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
-
- c = getopt (argc, argv, "abc:d:0123456789");
- if (c == EOF)
- break;
-
- switch (c)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/usr.bin/ptx/getopt.h b/gnu/usr.bin/ptx/getopt.h
deleted file mode 100644
index 45541f5..0000000
--- a/gnu/usr.bin/ptx/getopt.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Declarations for getopt.
- Copyright (C) 1989, 1990, 1991, 1992, 1993 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef _GETOPT_H
-#define _GETOPT_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
-extern int opterr;
-
-/* Set to an option character which was unrecognized. */
-
-extern int optopt;
-
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
-struct option
-{
-#if __STDC__
- const char *name;
-#else
- char *name;
-#endif
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'. */
-
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
-
-#if __STDC__
-#if defined(__GNU_LIBRARY__)
-/* Many other libraries have conflicting prototypes for getopt, with
- differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
-extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* not __GNU_LIBRARY__ */
-extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-extern int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
-
-/* Internal only. Users should not call this directly. */
-extern int _getopt_internal (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
-#else /* not __STDC__ */
-extern int getopt ();
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-#endif /* not __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GETOPT_H */
diff --git a/gnu/usr.bin/ptx/getopt1.c b/gnu/usr.bin/ptx/getopt1.c
deleted file mode 100644
index f784b57..0000000
--- a/gnu/usr.bin/ptx/getopt1.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/* getopt_long and getopt_long_only entry points for GNU getopt.
- Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
- 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef HAVE_CONFIG_H
-#if defined (emacs) || defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
- using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
- (which it would do because it found this file in $srcdir). */
-#include <config.h>
-#else
-#include "config.h"
-#endif
-#endif
-
-#include "getopt.h"
-
-#ifndef __STDC__
-/* This is a separate conditional since some stdc systems
- reject `defined (const)'. */
-#ifndef const
-#define const
-#endif
-#endif
-
-#include <stdio.h>
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-#include <stdlib.h>
-#else
-char *getenv ();
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-int
-getopt_long (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
-}
-
-/* Like getopt_long, but '-' as well as '--' can indicate a long option.
- If an option that starts with '-' (not '--') doesn't match a long option,
- but does match a short option, it is parsed as a short option
- instead. */
-
-int
-getopt_long_only (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
-}
-
-
-#endif /* _LIBC or not __GNU_LIBRARY__. */
-
-#ifdef TEST
-
-#include <stdio.h>
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
- int option_index = 0;
- static struct option long_options[] =
- {
- {"add", 1, 0, 0},
- {"append", 0, 0, 0},
- {"delete", 1, 0, 0},
- {"verbose", 0, 0, 0},
- {"create", 0, 0, 0},
- {"file", 1, 0, 0},
- {0, 0, 0, 0}
- };
-
- c = getopt_long (argc, argv, "abc:d:0123456789",
- long_options, &option_index);
- if (c == EOF)
- break;
-
- switch (c)
- {
- case 0:
- printf ("option %s", long_options[option_index].name);
- if (optarg)
- printf (" with arg %s", optarg);
- printf ("\n");
- break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case 'd':
- printf ("option d with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/usr.bin/ptx/mkinstalldirs b/gnu/usr.bin/ptx/mkinstalldirs
deleted file mode 100755
index 0e29377..0000000
--- a/gnu/usr.bin/ptx/mkinstalldirs
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-# Make directory hierarchy.
-# Written by Noah Friedman <friedman@prep.ai.mit.edu>
-# 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/gnu/usr.bin/ptx/ptx.c b/gnu/usr.bin/ptx/ptx.c
deleted file mode 100644
index 8c1b8d2..0000000
--- a/gnu/usr.bin/ptx/ptx.c
+++ /dev/null
@@ -1,2237 +0,0 @@
-/* Permuted index for GNU, with keywords in their context.
- Copyright (C) 1990, 1991, 1993 Free Software Foundation, Inc.
- Francois Pinard <pinard@iro.umontreal.ca>, 1988.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-const char *version_string = "GNU ptx version 0.3";
-
-char *const copyright = "\
-This program is free software; you can redistribute it and/or modify\n\
-it under the terms of the GNU General Public License as published by\n\
-the Free Software Foundation; either version 2, or (at your option)\n\
-any later version.\n\
-\n\
-This program is distributed in the hope that it will be useful,\n\
-but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
-GNU General Public License for more details.\n\
-\n\
-You should have received a copy of the GNU General Public License\n\
-along with this program; if not, write to the Free Software\n\
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n";
-
-/* Reallocation step when swallowing non regular files. The value is not
- the actual reallocation step, but its base two logarithm. */
-#define SWALLOW_REALLOC_LOG 12
-
-/* Imported from "regex.c". */
-#define Sword 1
-
-#ifdef STDC_HEADERS
-
-#include <stdlib.h>
-#include <ctype.h>
-
-#else /* not STDC_HEADERS */
-
-/* These definitions work, for all 256 characters. */
-#define isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
-#define isxdigit(c) \
- (((unsigned char) (c) >= 'a' && (unsigned char) (c) <= 'f') \
- || ((unsigned char) (c) >= 'A' && (unsigned char) (c) <= 'F') \
- || ((unsigned char) (c) >= '0' && (unsigned char) (c) <= '9'))
-#define islower(c) ((unsigned char) (c) >= 'a' && (unsigned char) (c) <= 'z')
-#define isupper(c) ((unsigned char) (c) >= 'A' && (unsigned char) (c) <= 'Z')
-#define isalpha(c) (islower (c) || isupper (c))
-#define toupper(c) (islower (c) ? (c) - 'a' + 'A' : (c))
-
-#endif /* not STDC_HEADERS */
-
-#if !defined (isascii) || defined (STDC_HEADERS)
-#undef isascii
-#define isascii(c) 1
-#endif
-
-#define ISXDIGIT(c) (isascii (c) && isxdigit (c))
-#define ISODIGIT(c) ((c) >= '0' && (c) <= '7')
-#define HEXTOBIN(c) ((c)>='a'&&(c)<='f' ? (c)-'a'+10 : (c)>='A'&&(c)<='F' ? (c)-'A'+10 : (c)-'0')
-#define OCTTOBIN(c) ((c) - '0')
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#if !defined(S_ISREG) && defined(S_IFREG)
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else /* not HAVE_STRING_H */
-#include <strings.h>
-#define strchr index
-#define strrchr rindex
-#endif /* not HAVE_STRING_H */
-
-#include "getopt.h"
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
-#include "bumpalloc.h"
-#include "diacrit.h"
-#include "gnuregex.h"
-
-#ifndef __STDC__
-void *xmalloc ();
-void *xrealloc ();
-#else
-void *xmalloc (int);
-void *xrealloc (void *, int);
-#endif
-
-
-/* Global definitions. */
-
-const char *program_name; /* name of this program */
-static int show_help = 0; /* display usage information and exit */
-static int show_version = 0; /* print the version and exit */
-
-/* Program options. */
-
-enum Format
-{
- DUMB_FORMAT, /* output for a dumb terminal */
- ROFF_FORMAT, /* output for `troff' or `nroff' */
- TEX_FORMAT, /* output for `TeX' or `LaTeX' */
- UNKNOWN_FORMAT /* output format still unknown */
-};
-
-int gnu_extensions = 1; /* trigger all GNU extensions */
-int auto_reference = 0; /* references are `file_name:line_number:' */
-int input_reference = 0; /* references at beginning of input lines */
-int right_reference = 0; /* output references after right context */
-int line_width = 72; /* output line width in characters */
-int gap_size = 3; /* number of spaces between output fields */
-const char *truncation_string = "/";
- /* string used to mark line truncations */
-const char *macro_name = "xx"; /* macro name for roff or TeX output */
-enum Format output_format = UNKNOWN_FORMAT;
- /* output format */
-
-int ignore_case = 0; /* fold lower to upper case for sorting */
-const char *context_regex_string = NULL;
- /* raw regex for end of context */
-const char *word_regex_string = NULL;
- /* raw regex for a keyword */
-const char *break_file = NULL; /* name of the `Break characters' file */
-const char *only_file = NULL; /* name of the `Only words' file */
-const char *ignore_file = NULL; /* name of the `Ignore words' file */
-
-/* A BLOCK delimit a region in memory of arbitrary size, like the copy of a
- whole file. A WORD is something smaller, its length should fit in a
- short integer. A WORD_TABLE may contain several WORDs. */
-
-typedef struct
- {
- char *start; /* pointer to beginning of region */
- char *end; /* pointer to end + 1 of region */
- }
-BLOCK;
-
-typedef struct
- {
- char *start; /* pointer to beginning of region */
- short size; /* length of the region */
- }
-WORD;
-
-typedef struct
- {
- WORD *start; /* array of WORDs */
- size_t length; /* number of entries */
- }
-WORD_TABLE;
-
-/* Pattern description tables. */
-
-/* For each character, provide its folded equivalent. */
-unsigned char folded_chars[CHAR_SET_SIZE];
-
-/* For each character, indicate if it is part of a word. */
-char syntax_table[CHAR_SET_SIZE];
-char *re_syntax_table = syntax_table;
-
-/* Compiled regex for end of context. */
-struct re_pattern_buffer *context_regex;
-
-/* End of context pattern register indices. */
-struct re_registers context_regs;
-
-/* Compiled regex for a keyword. */
-struct re_pattern_buffer *word_regex;
-
-/* Keyword pattern register indices. */
-struct re_registers word_regs;
-
-/* A word characters fastmap is used only when no word regexp has been
- provided. A word is then made up of a sequence of one or more characters
- allowed by the fastmap. Contains !0 if character allowed in word. Not
- only this is faster in most cases, but it simplifies the implementation
- of the Break files. */
-char word_fastmap[CHAR_SET_SIZE];
-
-/* Maximum length of any word read. */
-int maximum_word_length;
-
-/* Maximum width of any reference used. */
-int reference_max_width;
-
-
-/* Ignore and Only word tables. */
-
-WORD_TABLE ignore_table; /* table of words to ignore */
-WORD_TABLE only_table; /* table of words to select */
-
-#define ALLOC_NEW_WORD(table) \
- BUMP_ALLOC ((table)->start, (table)->length, 8, WORD)
-
-/* Source text table, and scanning macros. */
-
-int number_input_files; /* number of text input files */
-int total_line_count; /* total number of lines seen so far */
-const char **input_file_name; /* array of text input file names */
-int *file_line_count; /* array of `total_line_count' values at end */
-
-BLOCK text_buffer; /* file to study */
-char *text_buffer_maxend; /* allocated end of text_buffer */
-
-/* SKIP_NON_WHITE used only for getting or skipping the reference. */
-
-#define SKIP_NON_WHITE(cursor, limit) \
- while (cursor < limit && !isspace(*cursor)) \
- cursor++
-
-#define SKIP_WHITE(cursor, limit) \
- while (cursor < limit && isspace(*cursor)) \
- cursor++
-
-#define SKIP_WHITE_BACKWARDS(cursor, start) \
- while (cursor > start && isspace(cursor[-1])) \
- cursor--
-
-#define SKIP_SOMETHING(cursor, limit) \
- do \
- if (word_regex_string) \
- { \
- int count; \
- count = re_match (word_regex, cursor, limit - cursor, 0, NULL); \
- cursor += count <= 0 ? 1 : count; \
- } \
- else if (word_fastmap[(unsigned char) *cursor]) \
- while (cursor < limit && word_fastmap[(unsigned char) *cursor]) \
- cursor++; \
- else \
- cursor++; \
- while (0)
-
-/* Occurrences table.
-
- The `keyword' pointer provides the central word, which is surrounded
- by a left context and a right context. The `keyword' and `length'
- field allow full 8-bit characters keys, even including NULs. At other
- places in this program, the name `keyafter' refers to the keyword
- followed by its right context.
-
- The left context does not extend, towards the beginning of the file,
- further than a distance given by the `left' value. This value is
- relative to the keyword beginning, it is usually negative. This
- insures that, except for white space, we will never have to backward
- scan the source text, when it is time to generate the final output
- lines.
-
- The right context, indirectly attainable through the keyword end, does
- not extend, towards the end of the file, further than a distance given
- by the `right' value. This value is relative to the keyword
- beginning, it is usually positive.
-
- When automatic references are used, the `reference' value is the
- overall line number in all input files read so far, in this case, it
- is of type (int). When input references are used, the `reference'
- value indicates the distance between the keyword beginning and the
- start of the reference field, it is of type (DELTA) and usually
- negative. */
-
-typedef short DELTA; /* to hold displacement within one context */
-
-typedef struct
- {
- WORD key; /* description of the keyword */
- DELTA left; /* distance to left context start */
- DELTA right; /* distance to right context end */
- int reference; /* reference descriptor */
- }
-OCCURS;
-
-/* The various OCCURS tables are indexed by the language. But the time
- being, there is no such multiple language support. */
-
-OCCURS *occurs_table[1]; /* all words retained from the read text */
-size_t number_of_occurs[1]; /* number of used slots in occurs_table */
-
-#define ALLOC_NEW_OCCURS(language) \
- BUMP_ALLOC (occurs_table[language], number_of_occurs[language], 9, OCCURS)
-
-
-/* Communication among output routines. */
-
-/* Indicate if special output processing is requested for each character. */
-char edited_flag[CHAR_SET_SIZE];
-
-int half_line_width; /* half of line width, reference excluded */
-int before_max_width; /* maximum width of before field */
-int keyafter_max_width; /* maximum width of keyword-and-after field */
-int truncation_string_length; /* length of string used to flag truncation */
-
-/* When context is limited by lines, wraparound may happen on final output:
- the `head' pointer gives access to some supplementary left context which
- will be seen at the end of the output line, the `tail' pointer gives
- access to some supplementary right context which will be seen at the
- beginning of the output line. */
-
-BLOCK tail; /* tail field */
-int tail_truncation; /* flag truncation after the tail field */
-
-BLOCK before; /* before field */
-int before_truncation; /* flag truncation before the before field */
-
-BLOCK keyafter; /* keyword-and-after field */
-int keyafter_truncation; /* flag truncation after the keyafter field */
-
-BLOCK head; /* head field */
-int head_truncation; /* flag truncation before the head field */
-
-BLOCK reference; /* reference field for input reference mode */
-
-
-/* Miscellaneous routines. */
-
-/*------------------------------------------------------.
-| Duplicate string STRING, while evaluating \-escapes. |
-`------------------------------------------------------*/
-
-/* Loosely adapted from GNU shellutils printf.c code. */
-
-char *
-copy_unescaped_string (const char *string)
-{
- char *result; /* allocated result */
- char *cursor; /* cursor in result */
- int value; /* value of \nnn escape */
- int length; /* length of \nnn escape */
-
- result = xmalloc (strlen (string) + 1);
- cursor = result;
-
- while (*string)
- if (*string == '\\')
- {
- string++;
- switch (*string)
- {
- case 'x': /* \xhhh escape, 3 chars maximum */
- value = 0;
- for (length = 0, string++;
- length < 3 && ISXDIGIT (*string);
- length++, string++)
- value = value * 16 + HEXTOBIN (*string);
- if (length == 0)
- {
- *cursor++ = '\\';
- *cursor++ = 'x';
- }
- else
- *cursor++ = value;
- break;
-
- case '0': /* \0ooo escape, 3 chars maximum */
- value = 0;
- for (length = 0, string++;
- length < 3 && ISODIGIT (*string);
- length++, string++)
- value = value * 8 + OCTTOBIN (*string);
- *cursor++ = value;
- break;
-
- case 'a': /* alert */
-#if __STDC__
- *cursor++ = '\a';
-#else
- *cursor++ = 7;
-#endif
- string++;
- break;
-
- case 'b': /* backspace */
- *cursor++ = '\b';
- string++;
- break;
-
- case 'c': /* cancel the rest of the output */
- while (*string)
- string++;
- break;
-
- case 'f': /* form feed */
- *cursor++ = '\f';
- string++;
- break;
-
- case 'n': /* new line */
- *cursor++ = '\n';
- string++;
- break;
-
- case 'r': /* carriage return */
- *cursor++ = '\r';
- string++;
- break;
-
- case 't': /* horizontal tab */
- *cursor++ = '\t';
- string++;
- break;
-
- case 'v': /* vertical tab */
-#if __STDC__
- *cursor++ = '\v';
-#else
- *cursor++ = 11;
-#endif
- string++;
- break;
-
- default:
- *cursor++ = '\\';
- *cursor++ = *string++;
- break;
- }
- }
- else
- *cursor++ = *string++;
-
- *cursor = '\0';
- return result;
-}
-
-/*-------------------------------------------------------------------.
-| Compile the regex represented by STRING, diagnose and abort if any |
-| error. Returns the compiled regex structure. |
-`-------------------------------------------------------------------*/
-
-struct re_pattern_buffer *
-alloc_and_compile_regex (const char *string)
-{
- struct re_pattern_buffer *pattern; /* newly allocated structure */
- const char *message; /* error message returned by regex.c */
-
- pattern = (struct re_pattern_buffer *)
- xmalloc (sizeof (struct re_pattern_buffer));
- memset (pattern, 0, sizeof (struct re_pattern_buffer));
-
- pattern->buffer = NULL;
- pattern->allocated = 0;
- pattern->translate = ignore_case ? (char *) folded_chars : NULL;
- pattern->fastmap = (char *) xmalloc (CHAR_SET_SIZE);
-
- message = re_compile_pattern (string, strlen (string), pattern);
- if (message)
- error (1, 0, "%s (for regexp `%s')", message, string);
-
- /* The fastmap should be compiled before `re_match'. The following
- call is not mandatory, because `re_search' is always called sooner,
- and it compiles the fastmap if this has not been done yet. */
-
- re_compile_fastmap (pattern);
-
- /* Do not waste extra allocated space. */
-
- if (pattern->allocated > pattern->used)
- {
- pattern->buffer
- = (unsigned char *) xrealloc (pattern->buffer, pattern->used);
- pattern->allocated = pattern->used;
- }
-
- return pattern;
-}
-
-/*------------------------------------------------------------------------.
-| This will initialize various tables for pattern match and compiles some |
-| regexps. |
-`------------------------------------------------------------------------*/
-
-void
-initialize_regex (void)
-{
- int character; /* character value */
-
- /* Initialize the regex syntax table. */
-
- for (character = 0; character < CHAR_SET_SIZE; character++)
- syntax_table[character] = isalpha (character) ? Sword : 0;
-
- /* Initialize the case folding table. */
-
- if (ignore_case)
- for (character = 0; character < CHAR_SET_SIZE; character++)
- folded_chars[character] = toupper (character);
-
- /* Unless the user already provided a description of the end of line or
- end of sentence sequence, select an end of line sequence to compile.
- If the user provided an empty definition, thus disabling end of line
- or sentence feature, make it NULL to speed up tests. If GNU
- extensions are enabled, use end of sentence like in GNU emacs. If
- disabled, use end of lines. */
-
- if (context_regex_string)
- {
- if (!*context_regex_string)
- context_regex_string = NULL;
- }
- else if (gnu_extensions && !input_reference)
- context_regex_string = "[.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]*";
- else
- context_regex_string = "\n";
-
- if (context_regex_string)
- context_regex = alloc_and_compile_regex (context_regex_string);
-
- /* If the user has already provided a non-empty regexp to describe
- words, compile it. Else, unless this has already been done through
- a user provided Break character file, construct a fastmap of
- characters that may appear in a word. If GNU extensions enabled,
- include only letters of the underlying character set. If disabled,
- include almost everything, even punctuations; stop only on white
- space. */
-
- if (word_regex_string && *word_regex_string)
- word_regex = alloc_and_compile_regex (word_regex_string);
- else if (!break_file)
- if (gnu_extensions)
- {
-
- /* Simulate \w+. */
-
- for (character = 0; character < CHAR_SET_SIZE; character++)
- word_fastmap[character] = isalpha (character);
- }
- else
- {
-
- /* Simulate [^ \t\n]+. */
-
- memset (word_fastmap, 1, CHAR_SET_SIZE);
- word_fastmap[' '] = 0;
- word_fastmap['\t'] = 0;
- word_fastmap['\n'] = 0;
- }
-}
-
-/*------------------------------------------------------------------------.
-| This routine will attempt to swallow a whole file name FILE_NAME into a |
-| contiguous region of memory and return a description of it into BLOCK. |
-| Standard input is assumed whenever FILE_NAME is NULL, empty or "-". |
-| |
-| Previously, in some cases, white space compression was attempted while |
-| inputting text. This was defeating some regexps like default end of |
-| sentence, which checks for two consecutive spaces. If white space |
-| compression is ever reinstated, it should be in output routines. |
-`------------------------------------------------------------------------*/
-
-void
-swallow_file_in_memory (const char *file_name, BLOCK *block)
-{
- int file_handle; /* file descriptor number */
- struct stat stat_block; /* stat block for file */
- int allocated_length; /* allocated length of memory buffer */
- int used_length; /* used length in memory buffer */
- int read_length; /* number of character gotten on last read */
-
- /* As special cases, a file name which is NULL or "-" indicates standard
- input, which is already opened. In all other cases, open the file from
- its name. */
-
- if (!file_name || !*file_name || strcmp (file_name, "-") == 0)
- file_handle = fileno (stdin);
- else
- if ((file_handle = open (file_name, O_RDONLY)) < 0)
- error (1, errno, file_name);
-
- /* If the file is a plain, regular file, allocate the memory buffer all at
- once and swallow the file in one blow. In other cases, read the file
- repeatedly in smaller chunks until we have it all, reallocating memory
- once in a while, as we go. */
-
- if (fstat (file_handle, &stat_block) < 0)
- error (1, errno, file_name);
-
- if (S_ISREG (stat_block.st_mode))
- {
- block->start = (char *) xmalloc ((int) stat_block.st_size);
-
- if (read (file_handle, block->start, (int) stat_block.st_size)
- != stat_block.st_size)
- error (1, errno, file_name);
-
- block->end = block->start + stat_block.st_size;
- }
- else
- {
- block->start = (char *) xmalloc (1 << SWALLOW_REALLOC_LOG);
- used_length = 0;
- allocated_length = (1 << SWALLOW_REALLOC_LOG);
-
- while ((read_length = read (file_handle,
- block->start + used_length,
- allocated_length - used_length)) > 0)
- {
- used_length += read_length;
- if (used_length == allocated_length)
- {
- allocated_length += (1 << SWALLOW_REALLOC_LOG);
- block->start
- = (char *) xrealloc (block->start, allocated_length);
- }
- }
-
- if (read_length < 0)
- error (1, errno, file_name);
-
- block->end = block->start + used_length;
- }
-
- /* Close the file, but only if it was not the standard input. */
-
- if (file_handle != fileno (stdin))
- close (file_handle);
-}
-
-/* Sort and search routines. */
-
-/*--------------------------------------------------------------------------.
-| Compare two words, FIRST and SECOND, and return 0 if they are identical. |
-| Return less than 0 if the first word goes before the second; return |
-| greater than 0 if the first word goes after the second. |
-| |
-| If a word is indeed a prefix of the other, the shorter should go first. |
-`--------------------------------------------------------------------------*/
-
-int
-compare_words (const void *void_first, const void *void_second)
-{
-#define first ((WORD *) void_first)
-#define second ((WORD *) void_second)
- int length; /* minimum of two lengths */
- int counter; /* cursor in words */
- int value; /* value of comparison */
-
- length = first->size < second->size ? first->size : second->size;
-
- if (ignore_case)
- {
- for (counter = 0; counter < length; counter++)
- {
- value = (folded_chars [(unsigned char) (first->start[counter])]
- - folded_chars [(unsigned char) (second->start[counter])]);
- if (value != 0)
- return value;
- }
- }
- else
- {
- for (counter = 0; counter < length; counter++)
- {
- value = ((unsigned char) first->start[counter]
- - (unsigned char) second->start[counter]);
- if (value != 0)
- return value;
- }
- }
-
- return first->size - second->size;
-#undef first
-#undef second
-}
-
-/*-----------------------------------------------------------------------.
-| Decides which of two OCCURS, FIRST or SECOND, should lexicographically |
-| go first. In case of a tie, preserve the original order through a |
-| pointer comparison. |
-`-----------------------------------------------------------------------*/
-
-int
-compare_occurs (const void *void_first, const void *void_second)
-{
-#define first ((OCCURS *) void_first)
-#define second ((OCCURS *) void_second)
- int value;
-
- value = compare_words (&first->key, &second->key);
- return value == 0 ? first->key.start - second->key.start : value;
-#undef first
-#undef second
-}
-
-/*------------------------------------------------------------.
-| Return !0 if WORD appears in TABLE. Uses a binary search. |
-`------------------------------------------------------------*/
-
-int
-search_table (WORD *word, WORD_TABLE *table)
-{
- int lowest; /* current lowest possible index */
- int highest; /* current highest possible index */
- int middle; /* current middle index */
- int value; /* value from last comparison */
-
- lowest = 0;
- highest = table->length - 1;
- while (lowest <= highest)
- {
- middle = (lowest + highest) / 2;
- value = compare_words (word, table->start + middle);
- if (value < 0)
- highest = middle - 1;
- else if (value > 0)
- lowest = middle + 1;
- else
- return 1;
- }
- return 0;
-}
-
-/*---------------------------------------------------------------------.
-| Sort the whole occurs table in memory. Presumably, `qsort' does not |
-| take intermediate copies or table elements, so the sort will be |
-| stabilized throughout the comparison routine. |
-`---------------------------------------------------------------------*/
-
-void
-sort_found_occurs (void)
-{
-
- /* Only one language for the time being. */
-
- qsort (occurs_table[0], number_of_occurs[0], sizeof (OCCURS),
- compare_occurs);
-}
-
-/* Parameter files reading routines. */
-
-/*----------------------------------------------------------------------.
-| Read a file named FILE_NAME, containing a set of break characters. |
-| Build a content to the array word_fastmap in which all characters are |
-| allowed except those found in the file. Characters may be repeated. |
-`----------------------------------------------------------------------*/
-
-void
-digest_break_file (const char *file_name)
-{
- BLOCK file_contents; /* to receive a copy of the file */
- char *cursor; /* cursor in file copy */
-
- swallow_file_in_memory (file_name, &file_contents);
-
- /* Make the fastmap and record the file contents in it. */
-
- memset (word_fastmap, 1, CHAR_SET_SIZE);
- for (cursor = file_contents.start; cursor < file_contents.end; cursor++)
- word_fastmap[(unsigned char) *cursor] = 0;
-
- if (!gnu_extensions)
- {
-
- /* If GNU extensions are enabled, the only way to avoid newline as
- a break character is to write all the break characters in the
- file with no newline at all, not even at the end of the file.
- If disabled, spaces, tabs and newlines are always considered as
- break characters even if not included in the break file. */
-
- word_fastmap[' '] = 0;
- word_fastmap['\t'] = 0;
- word_fastmap['\n'] = 0;
- }
-
- /* Return the space of the file, which is no more required. */
-
- free (file_contents.start);
-}
-
-/*-----------------------------------------------------------------------.
-| Read a file named FILE_NAME, containing one word per line, then |
-| construct in TABLE a table of WORD descriptors for them. The routine |
-| swallows the whole file in memory; this is at the expense of space |
-| needed for newlines, which are useless; however, the reading is fast. |
-`-----------------------------------------------------------------------*/
-
-void
-digest_word_file (const char *file_name, WORD_TABLE *table)
-{
- BLOCK file_contents; /* to receive a copy of the file */
- char *cursor; /* cursor in file copy */
- char *word_start; /* start of the current word */
-
- swallow_file_in_memory (file_name, &file_contents);
-
- table->start = NULL;
- table->length = 0;
-
- /* Read the whole file. */
-
- cursor = file_contents.start;
- while (cursor < file_contents.end)
- {
-
- /* Read one line, and save the word in contains. */
-
- word_start = cursor;
- while (cursor < file_contents.end && *cursor != '\n')
- cursor++;
-
- /* Record the word in table if it is not empty. */
-
- if (cursor > word_start)
- {
- ALLOC_NEW_WORD (table);
- table->start[table->length].start = word_start;
- table->start[table->length].size = cursor - word_start;
- table->length++;
- }
-
- /* This test allows for an incomplete line at end of file. */
-
- if (cursor < file_contents.end)
- cursor++;
- }
-
- /* Finally, sort all the words read. */
-
- qsort (table->start, table->length, (size_t) sizeof (WORD), compare_words);
-}
-
-
-/* Keyword recognition and selection. */
-
-/*----------------------------------------------------------------------.
-| For each keyword in the source text, constructs an OCCURS structure. |
-`----------------------------------------------------------------------*/
-
-void
-find_occurs_in_text (void)
-{
- char *cursor; /* for scanning the source text */
- char *scan; /* for scanning the source text also */
- char *line_start; /* start of the current input line */
- char *line_scan; /* newlines scanned until this point */
- int reference_length; /* length of reference in input mode */
- WORD possible_key; /* possible key, to ease searches */
- OCCURS *occurs_cursor; /* current OCCURS under construction */
-
- char *context_start; /* start of left context */
- char *context_end; /* end of right context */
- char *word_start; /* start of word */
- char *word_end; /* end of word */
- char *next_context_start; /* next start of left context */
-
- /* reference_length is always used within `if (input_reference)'.
- However, GNU C diagnoses that it may be used uninitialized. The
- following assignment is merely to shut it up. */
-
- reference_length = 0;
-
- /* Tracking where lines start is helpful for reference processing. In
- auto reference mode, this allows counting lines. In input reference
- mode, this permits finding the beginning of the references.
-
- The first line begins with the file, skip immediately this very first
- reference in input reference mode, to help further rejection any word
- found inside it. Also, unconditionally assigning these variable has
- the happy effect of shutting up lint. */
-
- line_start = text_buffer.start;
- line_scan = line_start;
- if (input_reference)
- {
- SKIP_NON_WHITE (line_scan, text_buffer.end);
- reference_length = line_scan - line_start;
- SKIP_WHITE (line_scan, text_buffer.end);
- }
-
- /* Process the whole buffer, one line or one sentence at a time. */
-
- for (cursor = text_buffer.start;
- cursor < text_buffer.end;
- cursor = next_context_start)
- {
-
- /* `context_start' gets initialized before the processing of each
- line, or once for the whole buffer if no end of line or sentence
- sequence separator. */
-
- context_start = cursor;
-
- /* If a end of line or end of sentence sequence is defined and
- non-empty, `next_context_start' will be recomputed to be the end of
- each line or sentence, before each one is processed. If no such
- sequence, then `next_context_start' is set at the end of the whole
- buffer, which is then considered to be a single line or sentence.
- This test also accounts for the case of an incomplete line or
- sentence at the end of the buffer. */
-
- if (context_regex_string
- && (re_search (context_regex, cursor, text_buffer.end - cursor,
- 0, text_buffer.end - cursor, &context_regs)
- >= 0))
- next_context_start = cursor + context_regs.end[0];
-
- else
- next_context_start = text_buffer.end;
-
- /* Include the separator into the right context, but not any suffix
- white space in this separator; this insures it will be seen in
- output and will not take more space than necessary. */
-
- context_end = next_context_start;
- SKIP_WHITE_BACKWARDS (context_end, context_start);
-
- /* Read and process a single input line or sentence, one word at a
- time. */
-
- while (1)
- {
- if (word_regex)
-
- /* If a word regexp has been compiled, use it to skip at the
- beginning of the next word. If there is no such word, exit
- the loop. */
-
- {
- if (re_search (word_regex, cursor, context_end - cursor,
- 0, context_end - cursor, &word_regs)
- < 0)
- break;
- word_start = cursor + word_regs.start[0];
- word_end = cursor + word_regs.end[0];
- }
- else
-
- /* Avoid re_search and use the fastmap to skip to the
- beginning of the next word. If there is no more word in
- the buffer, exit the loop. */
-
- {
- scan = cursor;
- while (scan < context_end
- && !word_fastmap[(unsigned char) *scan])
- scan++;
-
- if (scan == context_end)
- break;
-
- word_start = scan;
-
- while (scan < context_end
- && word_fastmap[(unsigned char) *scan])
- scan++;
-
- word_end = scan;
- }
-
- /* Skip right to the beginning of the found word. */
-
- cursor = word_start;
-
- /* Skip any zero length word. Just advance a single position,
- then go fetch the next word. */
-
- if (word_end == word_start)
- {
- cursor++;
- continue;
- }
-
- /* This is a genuine, non empty word, so save it as a possible
- key. Then skip over it. Also, maintain the maximum length of
- all words read so far. It is mandatory to take the maximum
- length of all words in the file, without considering if they
- are actually kept or rejected, because backward jumps at output
- generation time may fall in *any* word. */
-
- possible_key.start = cursor;
- possible_key.size = word_end - word_start;
- cursor += possible_key.size;
-
- if (possible_key.size > maximum_word_length)
- maximum_word_length = possible_key.size;
-
- /* In input reference mode, update `line_start' from its previous
- value. Count the lines just in case auto reference mode is
- also selected. If it happens that the word just matched is
- indeed part of a reference; just ignore it. */
-
- if (input_reference)
- {
- while (line_scan < possible_key.start)
- if (*line_scan == '\n')
- {
- total_line_count++;
- line_scan++;
- line_start = line_scan;
- SKIP_NON_WHITE (line_scan, text_buffer.end);
- reference_length = line_scan - line_start;
- }
- else
- line_scan++;
- if (line_scan > possible_key.start)
- continue;
- }
-
- /* Ignore the word if an `Ignore words' table exists and if it is
- part of it. Also ignore the word if an `Only words' table and
- if it is *not* part of it.
-
- It is allowed that both tables be used at once, even if this
- may look strange for now. Just ignore a word that would appear
- in both. If regexps are eventually implemented for these
- tables, the Ignore table could then reject words that would
- have been previously accepted by the Only table. */
-
- if (ignore_file && search_table (&possible_key, &ignore_table))
- continue;
- if (only_file && !search_table (&possible_key, &only_table))
- continue;
-
- /* A non-empty word has been found. First of all, insure
- proper allocation of the next OCCURS, and make a pointer to
- where it will be constructed. */
-
- ALLOC_NEW_OCCURS (0);
- occurs_cursor = occurs_table[0] + number_of_occurs[0];
-
- /* Define the refence field, if any. */
-
- if (auto_reference)
- {
-
- /* While auto referencing, update `line_start' from its
- previous value, counting lines as we go. If input
- referencing at the same time, `line_start' has been
- advanced earlier, and the following loop is never really
- executed. */
-
- while (line_scan < possible_key.start)
- if (*line_scan == '\n')
- {
- total_line_count++;
- line_scan++;
- line_start = line_scan;
- SKIP_NON_WHITE (line_scan, text_buffer.end);
- }
- else
- line_scan++;
-
- occurs_cursor->reference = total_line_count;
- }
- else if (input_reference)
- {
-
- /* If only input referencing, `line_start' has been computed
- earlier to detect the case the word matched would be part
- of the reference. The reference position is simply the
- value of `line_start'. */
-
- occurs_cursor->reference
- = (DELTA) (line_start - possible_key.start);
- if (reference_length > reference_max_width)
- reference_max_width = reference_length;
- }
-
- /* Exclude the reference from the context in simple cases. */
-
- if (input_reference && line_start == context_start)
- {
- SKIP_NON_WHITE (context_start, context_end);
- SKIP_WHITE (context_start, context_end);
- }
-
- /* Completes the OCCURS structure. */
-
- occurs_cursor->key = possible_key;
- occurs_cursor->left = context_start - possible_key.start;
- occurs_cursor->right = context_end - possible_key.start;
-
- number_of_occurs[0]++;
- }
- }
-}
-
-/* Formatting and actual output - service routines. */
-
-/*-----------------------------------------.
-| Prints some NUMBER of spaces on stdout. |
-`-----------------------------------------*/
-
-void
-print_spaces (int number)
-{
- int counter;
-
- for (counter = number; counter > 0; counter--)
- putchar (' ');
-}
-
-/*-------------------------------------.
-| Prints the field provided by FIELD. |
-`-------------------------------------*/
-
-void
-print_field (BLOCK field)
-{
- char *cursor; /* Cursor in field to print */
- int character; /* Current character */
- int base; /* Base character, without diacritic */
- int diacritic; /* Diacritic code for the character */
-
- /* Whitespace is not really compressed. Instead, each white space
- character (tab, vt, ht etc.) is printed as one single space. */
-
- for (cursor = field.start; cursor < field.end; cursor++)
- {
- character = (unsigned char) *cursor;
- if (edited_flag[character])
- {
-
- /* First check if this is a diacriticized character.
-
- This works only for TeX. I do not know how diacriticized
- letters work with `roff'. Please someone explain it to me! */
-
- diacritic = todiac (character);
- if (diacritic != 0 && output_format == TEX_FORMAT)
- {
- base = tobase (character);
- switch (diacritic)
- {
-
- case 1: /* Latin diphthongs */
- switch (base)
- {
- case 'o':
- printf ("\\oe{}");
- break;
-
- case 'O':
- printf ("\\OE{}");
- break;
-
- case 'a':
- printf ("\\ae{}");
- break;
-
- case 'A':
- printf ("\\AE{}");
- break;
-
- default:
- putchar (' ');
- }
- break;
-
- case 2: /* Acute accent */
- printf ("\\'%s%c", (base == 'i' ? "\\" : ""), base);
- break;
-
- case 3: /* Grave accent */
- printf ("\\`%s%c", (base == 'i' ? "\\" : ""), base);
- break;
-
- case 4: /* Circumflex accent */
- printf ("\\^%s%c", (base == 'i' ? "\\" : ""), base);
- break;
-
- case 5: /* Diaeresis */
- printf ("\\\"%s%c", (base == 'i' ? "\\" : ""), base);
- break;
-
- case 6: /* Tilde accent */
- printf ("\\~%s%c", (base == 'i' ? "\\" : ""), base);
- break;
-
- case 7: /* Cedilla */
- printf ("\\c{%c}", base);
- break;
-
- case 8: /* Small circle beneath */
- switch (base)
- {
- case 'a':
- printf ("\\aa{}");
- break;
-
- case 'A':
- printf ("\\AA{}");
- break;
-
- default:
- putchar (' ');
- }
- break;
-
- case 9: /* Strike through */
- switch (base)
- {
- case 'o':
- printf ("\\o{}");
- break;
-
- case 'O':
- printf ("\\O{}");
- break;
-
- default:
- putchar (' ');
- }
- break;
- }
- }
- else
-
- /* This is not a diacritic character, so handle cases which are
- really specific to `roff' or TeX. All white space processing
- is done as the default case of this switch. */
-
- switch (character)
- {
- case '"':
- /* In roff output format, double any quote. */
- putchar ('"');
- putchar ('"');
- break;
-
- case '$':
- case '%':
- case '&':
- case '#':
- case '_':
- /* In TeX output format, precede these with a backslash. */
- putchar ('\\');
- putchar (character);
- break;
-
- case '{':
- case '}':
- /* In TeX output format, precede these with a backslash and
- force mathematical mode. */
- printf ("$\\%c$", character);
- break;
-
- case '\\':
- /* In TeX output mode, request production of a backslash. */
- printf ("\\backslash{}");
- break;
-
- default:
- /* Any other flagged character produces a single space. */
- putchar (' ');
- }
- }
- else
- putchar (*cursor);
- }
-}
-
-
-/* Formatting and actual output - planning routines. */
-
-/*--------------------------------------------------------------------.
-| From information collected from command line options and input file |
-| readings, compute and fix some output parameter values. |
-`--------------------------------------------------------------------*/
-
-void
-fix_output_parameters (void)
-{
- int file_index; /* index in text input file arrays */
- int line_ordinal; /* line ordinal value for reference */
- char ordinal_string[12]; /* edited line ordinal for reference */
- int reference_width; /* width for the whole reference */
- int character; /* character ordinal */
- const char *cursor; /* cursor in some constant strings */
-
- /* In auto reference mode, the maximum width of this field is
- precomputed and subtracted from the overall line width. Add one for
- the column which separate the file name from the line number. */
-
- if (auto_reference)
- {
- reference_max_width = 0;
- for (file_index = 0; file_index < number_input_files; file_index++)
- {
- line_ordinal = file_line_count[file_index] + 1;
- if (file_index > 0)
- line_ordinal -= file_line_count[file_index - 1];
- sprintf (ordinal_string, "%d", line_ordinal);
- reference_width = strlen (ordinal_string);
- if (input_file_name[file_index])
- reference_width += strlen (input_file_name[file_index]);
- if (reference_width > reference_max_width)
- reference_max_width = reference_width;
- }
- reference_max_width++;
- reference.start = (char *) xmalloc (reference_max_width + 1);
- }
-
- /* If the reference appears to the left of the output line, reserve some
- space for it right away, including one gap size. */
-
- if ((auto_reference || input_reference) && !right_reference)
- line_width -= reference_max_width + gap_size;
-
- /* The output lines, minimally, will contain from left to right a left
- context, a gap, and a keyword followed by the right context with no
- special intervening gap. Half of the line width is dedicated to the
- left context and the gap, the other half is dedicated to the keyword
- and the right context; these values are computed once and for all here.
- There also are tail and head wrap around fields, used when the keyword
- is near the beginning or the end of the line, or when some long word
- cannot fit in, but leave place from wrapped around shorter words. The
- maximum width of these fields are recomputed separately for each line,
- on a case by case basis. It is worth noting that it cannot happen that
- both the tail and head fields are used at once. */
-
- half_line_width = line_width / 2;
- before_max_width = half_line_width - gap_size;
- keyafter_max_width = half_line_width;
-
- /* If truncation_string is the empty string, make it NULL to speed up
- tests. In this case, truncation_string_length will never get used, so
- there is no need to set it. */
-
- if (truncation_string && *truncation_string)
- truncation_string_length = strlen (truncation_string);
- else
- truncation_string = NULL;
-
- if (gnu_extensions)
- {
-
- /* When flagging truncation at the left of the keyword, the
- truncation mark goes at the beginning of the before field,
- unless there is a head field, in which case the mark goes at the
- left of the head field. When flagging truncation at the right
- of the keyword, the mark goes at the end of the keyafter field,
- unless there is a tail field, in which case the mark goes at the
- end of the tail field. Only eight combination cases could arise
- for truncation marks:
-
- . None.
- . One beginning the before field.
- . One beginning the head field.
- . One ending the keyafter field.
- . One ending the tail field.
- . One beginning the before field, another ending the keyafter field.
- . One ending the tail field, another beginning the before field.
- . One ending the keyafter field, another beginning the head field.
-
- So, there is at most two truncation marks, which could appear both
- on the left side of the center of the output line, both on the
- right side, or one on either side. */
-
- before_max_width -= 2 * truncation_string_length;
- keyafter_max_width -= 2 * truncation_string_length;
- }
- else
- {
-
- /* I never figured out exactly how UNIX' ptx plans the output width
- of its various fields. If GNU extensions are disabled, do not
- try computing the field widths correctly; instead, use the
- following formula, which does not completely imitate UNIX' ptx,
- but almost. */
-
- keyafter_max_width -= 2 * truncation_string_length + 1;
- }
-
- /* Compute which characters need special output processing. Initialize
- by flagging any white space character. Some systems do not consider
- form feed as a space character, but we do. */
-
- for (character = 0; character < CHAR_SET_SIZE; character++)
- edited_flag[character] = isspace (character);
- edited_flag['\f'] = 1;
-
- /* Complete the special character flagging according to selected output
- format. */
-
- switch (output_format)
- {
- case UNKNOWN_FORMAT:
- /* Should never happen. */
-
- case DUMB_FORMAT:
- break;
-
- case ROFF_FORMAT:
-
- /* `Quote' characters should be doubled. */
-
- edited_flag['"'] = 1;
- break;
-
- case TEX_FORMAT:
-
- /* Various characters need special processing. */
-
- for (cursor = "$%&#_{}\\"; *cursor; cursor++)
- edited_flag[*cursor] = 1;
-
- /* Any character with 8th bit set will print to a single space, unless
- it is diacriticized. */
-
- for (character = 0200; character < CHAR_SET_SIZE; character++)
- edited_flag[character] = todiac (character) != 0;
- break;
- }
-}
-
-/*------------------------------------------------------------------.
-| Compute the position and length of all the output fields, given a |
-| pointer to some OCCURS. |
-`------------------------------------------------------------------*/
-
-void
-define_all_fields (OCCURS *occurs)
-{
- int tail_max_width; /* allowable width of tail field */
- int head_max_width; /* allowable width of head field */
- char *cursor; /* running cursor in source text */
- char *left_context_start; /* start of left context */
- char *right_context_end; /* end of right context */
- char *left_field_start; /* conservative start for `head'/`before' */
- int file_index; /* index in text input file arrays */
- const char *file_name; /* file name for reference */
- int line_ordinal; /* line ordinal for reference */
-
- /* Define `keyafter', start of left context and end of right context.
- `keyafter' starts at the saved position for keyword and extend to the
- right from the end of the keyword, eating separators or full words, but
- not beyond maximum allowed width for `keyafter' field or limit for the
- right context. Suffix spaces will be removed afterwards. */
-
- keyafter.start = occurs->key.start;
- keyafter.end = keyafter.start + occurs->key.size;
- left_context_start = keyafter.start + occurs->left;
- right_context_end = keyafter.start + occurs->right;
-
- cursor = keyafter.end;
- while (cursor < right_context_end
- && cursor <= keyafter.start + keyafter_max_width)
- {
- keyafter.end = cursor;
- SKIP_SOMETHING (cursor, right_context_end);
- }
- if (cursor <= keyafter.start + keyafter_max_width)
- keyafter.end = cursor;
-
- keyafter_truncation = truncation_string && keyafter.end < right_context_end;
-
- SKIP_WHITE_BACKWARDS (keyafter.end, keyafter.start);
-
- /* When the left context is wide, it might take some time to catch up from
- the left context boundary to the beginning of the `head' or `before'
- fields. So, in this case, to speed the catchup, we jump back from the
- keyword, using some secure distance, possibly falling in the middle of
- a word. A secure backward jump would be at least half the maximum
- width of a line, plus the size of the longest word met in the whole
- input. We conclude this backward jump by a skip forward of at least
- one word. In this manner, we should not inadvertently accept only part
- of a word. From the reached point, when it will be time to fix the
- beginning of `head' or `before' fields, we will skip forward words or
- delimiters until we get sufficiently near. */
-
- if (-occurs->left > half_line_width + maximum_word_length)
- {
- left_field_start
- = keyafter.start - (half_line_width + maximum_word_length);
- SKIP_SOMETHING (left_field_start, keyafter.start);
- }
- else
- left_field_start = keyafter.start + occurs->left;
-
- /* `before' certainly ends at the keyword, but not including separating
- spaces. It starts after than the saved value for the left context, by
- advancing it until it falls inside the maximum allowed width for the
- before field. There will be no prefix spaces either. `before' only
- advances by skipping single separators or whole words. */
-
- before.start = left_field_start;
- before.end = keyafter.start;
- SKIP_WHITE_BACKWARDS (before.end, before.start);
-
- while (before.start + before_max_width < before.end)
- SKIP_SOMETHING (before.start, before.end);
-
- if (truncation_string)
- {
- cursor = before.start;
- SKIP_WHITE_BACKWARDS (cursor, text_buffer.start);
- before_truncation = cursor > left_context_start;
- }
- else
- before_truncation = 0;
-
- SKIP_WHITE (before.start, text_buffer.end);
-
- /* The tail could not take more columns than what has been left in the
- left context field, and a gap is mandatory. It starts after the
- right context, and does not contain prefixed spaces. It ends at
- the end of line, the end of buffer or when the tail field is full,
- whichever comes first. It cannot contain only part of a word, and
- has no suffixed spaces. */
-
- tail_max_width
- = before_max_width - (before.end - before.start) - gap_size;
-
- if (tail_max_width > 0)
- {
- tail.start = keyafter.end;
- SKIP_WHITE (tail.start, text_buffer.end);
-
- tail.end = tail.start;
- cursor = tail.end;
- while (cursor < right_context_end
- && cursor < tail.start + tail_max_width)
- {
- tail.end = cursor;
- SKIP_SOMETHING (cursor, right_context_end);
- }
-
- if (cursor < tail.start + tail_max_width)
- tail.end = cursor;
-
- if (tail.end > tail.start)
- {
- keyafter_truncation = 0;
- tail_truncation = truncation_string && tail.end < right_context_end;
- }
- else
- tail_truncation = 0;
-
- SKIP_WHITE_BACKWARDS (tail.end, tail.start);
- }
- else
- {
-
- /* No place left for a tail field. */
-
- tail.start = NULL;
- tail.end = NULL;
- tail_truncation = 0;
- }
-
- /* `head' could not take more columns than what has been left in the right
- context field, and a gap is mandatory. It ends before the left
- context, and does not contain suffixed spaces. Its pointer is advanced
- until the head field has shrunk to its allowed width. It cannot
- contain only part of a word, and has no suffixed spaces. */
-
- head_max_width
- = keyafter_max_width - (keyafter.end - keyafter.start) - gap_size;
-
- if (head_max_width > 0)
- {
- head.end = before.start;
- SKIP_WHITE_BACKWARDS (head.end, text_buffer.start);
-
- head.start = left_field_start;
- while (head.start + head_max_width < head.end)
- SKIP_SOMETHING (head.start, head.end);
-
- if (head.end > head.start)
- {
- before_truncation = 0;
- head_truncation = (truncation_string
- && head.start > left_context_start);
- }
- else
- head_truncation = 0;
-
- SKIP_WHITE (head.start, head.end);
- }
- else
- {
-
- /* No place left for a head field. */
-
- head.start = NULL;
- head.end = NULL;
- head_truncation = 0;
- }
-
- if (auto_reference)
- {
-
- /* Construct the reference text in preallocated space from the file
- name and the line number. Find out in which file the reference
- occurred. Standard input yields an empty file name. Insure line
- numbers are one based, even if they are computed zero based. */
-
- file_index = 0;
- while (file_line_count[file_index] < occurs->reference)
- file_index++;
-
- file_name = input_file_name[file_index];
- if (!file_name)
- file_name = "";
-
- line_ordinal = occurs->reference + 1;
- if (file_index > 0)
- line_ordinal -= file_line_count[file_index - 1];
-
- sprintf (reference.start, "%s:%d", file_name, line_ordinal);
- reference.end = reference.start + strlen (reference.start);
- }
- else if (input_reference)
- {
-
- /* Reference starts at saved position for reference and extends right
- until some white space is met. */
-
- reference.start = keyafter.start + (DELTA) occurs->reference;
- reference.end = reference.start;
- SKIP_NON_WHITE (reference.end, right_context_end);
- }
-}
-
-
-/* Formatting and actual output - control routines. */
-
-/*----------------------------------------------------------------------.
-| Output the current output fields as one line for `troff' or `nroff'. |
-`----------------------------------------------------------------------*/
-
-void
-output_one_roff_line (void)
-{
- /* Output the `tail' field. */
-
- printf (".%s \"", macro_name);
- print_field (tail);
- if (tail_truncation)
- printf ("%s", truncation_string);
- putchar ('"');
-
- /* Output the `before' field. */
-
- printf (" \"");
- if (before_truncation)
- printf ("%s", truncation_string);
- print_field (before);
- putchar ('"');
-
- /* Output the `keyafter' field. */
-
- printf (" \"");
- print_field (keyafter);
- if (keyafter_truncation)
- printf ("%s", truncation_string);
- putchar ('"');
-
- /* Output the `head' field. */
-
- printf (" \"");
- if (head_truncation)
- printf ("%s", truncation_string);
- print_field (head);
- putchar ('"');
-
- /* Conditionally output the `reference' field. */
-
- if (auto_reference || input_reference)
- {
- printf (" \"");
- print_field (reference);
- putchar ('"');
- }
-
- putchar ('\n');
-}
-
-/*---------------------------------------------------------.
-| Output the current output fields as one line for `TeX'. |
-`---------------------------------------------------------*/
-
-void
-output_one_tex_line (void)
-{
- BLOCK key; /* key field, isolated */
- BLOCK after; /* after field, isolated */
- char *cursor; /* running cursor in source text */
-
- printf ("\\%s ", macro_name);
- printf ("{");
- print_field (tail);
- printf ("}{");
- print_field (before);
- printf ("}{");
- key.start = keyafter.start;
- after.end = keyafter.end;
- cursor = keyafter.start;
- SKIP_SOMETHING (cursor, keyafter.end);
- key.end = cursor;
- after.start = cursor;
- print_field (key);
- printf ("}{");
- print_field (after);
- printf ("}{");
- print_field (head);
- printf ("}");
- if (auto_reference || input_reference)
- {
- printf ("{");
- print_field (reference);
- printf ("}");
- }
- printf ("\n");
-}
-
-/*-------------------------------------------------------------------.
-| Output the current output fields as one line for a dumb terminal. |
-`-------------------------------------------------------------------*/
-
-void
-output_one_dumb_line (void)
-{
- if (!right_reference)
- if (auto_reference)
- {
-
- /* Output the `reference' field, in such a way that GNU emacs
- next-error will handle it. The ending colon is taken from the
- gap which follows. */
-
- print_field (reference);
- putchar (':');
- print_spaces (reference_max_width
- + gap_size
- - (reference.end - reference.start)
- - 1);
- }
- else
- {
-
- /* Output the `reference' field and its following gap. */
-
- print_field (reference);
- print_spaces (reference_max_width
- + gap_size
- - (reference.end - reference.start));
- }
-
- if (tail.start < tail.end)
- {
- /* Output the `tail' field. */
-
- print_field (tail);
- if (tail_truncation)
- printf ("%s", truncation_string);
-
- print_spaces (half_line_width - gap_size
- - (before.end - before.start)
- - (before_truncation ? truncation_string_length : 0)
- - (tail.end - tail.start)
- - (tail_truncation ? truncation_string_length : 0));
- }
- else
- print_spaces (half_line_width - gap_size
- - (before.end - before.start)
- - (before_truncation ? truncation_string_length : 0));
-
- /* Output the `before' field. */
-
- if (before_truncation)
- printf ("%s", truncation_string);
- print_field (before);
-
- print_spaces (gap_size);
-
- /* Output the `keyafter' field. */
-
- print_field (keyafter);
- if (keyafter_truncation)
- printf ("%s", truncation_string);
-
- if (head.start < head.end)
- {
- /* Output the `head' field. */
-
- print_spaces (half_line_width
- - (keyafter.end - keyafter.start)
- - (keyafter_truncation ? truncation_string_length : 0)
- - (head.end - head.start)
- - (head_truncation ? truncation_string_length : 0));
- if (head_truncation)
- printf ("%s", truncation_string);
- print_field (head);
- }
- else
-
- if ((auto_reference || input_reference) && right_reference)
- print_spaces (half_line_width
- - (keyafter.end - keyafter.start)
- - (keyafter_truncation ? truncation_string_length : 0));
-
- if ((auto_reference || input_reference) && right_reference)
- {
- /* Output the `reference' field. */
-
- print_spaces (gap_size);
- print_field (reference);
- }
-
- printf ("\n");
-}
-
-/*------------------------------------------------------------------------.
-| Scan the whole occurs table and, for each entry, output one line in the |
-| appropriate format. |
-`------------------------------------------------------------------------*/
-
-void
-generate_all_output (void)
-{
- int occurs_index; /* index of keyword entry being processed */
- OCCURS *occurs_cursor; /* current keyword entry being processed */
-
-
- /* The following assignments are useful to provide default values in case
- line contexts or references are not used, in which case these variables
- would never be computed. */
-
- tail.start = NULL;
- tail.end = NULL;
- tail_truncation = 0;
-
- head.start = NULL;
- head.end = NULL;
- head_truncation = 0;
-
-
- /* Loop over all keyword occurrences. */
-
- occurs_cursor = occurs_table[0];
-
- for (occurs_index = 0; occurs_index < number_of_occurs[0]; occurs_index++)
- {
- /* Compute the exact size of every field and whenever truncation flags
- are present or not. */
-
- define_all_fields (occurs_cursor);
-
- /* Produce one output line according to selected format. */
-
- switch (output_format)
- {
- case UNKNOWN_FORMAT:
- /* Should never happen. */
-
- case DUMB_FORMAT:
- output_one_dumb_line ();
- break;
-
- case ROFF_FORMAT:
- output_one_roff_line ();
- break;
-
- case TEX_FORMAT:
- output_one_tex_line ();
- break;
- }
-
- /* Advance the cursor into the occurs table. */
-
- occurs_cursor++;
- }
-}
-
-/* Option decoding and main program. */
-
-/*------------------------------------------------------.
-| Print program identification and options, then exit. |
-`------------------------------------------------------*/
-
-void
-usage (int status)
-{
- if (status != 0)
- fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
- else
- {
- printf ("\
-Usage: %s [OPTION]... [INPUT]... (without -G)\n\
- or: %s -G [OPTION]... [INPUT [OUTPUT]]\n", program_name, program_name);
- printf ("\
-\n\
- -A, --auto-reference output automatically generated references\n\
- -C, --copyright display Copyright and copying conditions\n\
- -G, --traditional behave more like System V `ptx'\n\
- -F, --flag-truncation=STRING use STRING for flagging line truncations\n\
- -M, --macro-name=STRING macro name to use instead of `xx'\n\
- -O, --format=roff generate output as roff directives\n\
- -R, --right-side-refs put references at right, not counted in -w\n\
- -S, --sentence-regexp=REGEXP for end of lines or end of sentences\n\
- -T, --format=tex generate output as TeX directives\n\
- -W, --word-regexp=REGEXP use REGEXP to match each keyword\n\
- -b, --break-file=FILE word break characters in this FILE\n\
- -f, --ignore-case fold lower case to upper case for sorting\n\
- -g, --gap-size=NUMBER gap size in columns between output fields\n\
- -i, --ignore-file=FILE read ignore word list from FILE\n\
- -o, --only-file=FILE read only word list from this FILE\n\
- -r, --references first field of each line is a reference\n\
- -t, --typeset-mode - not implemented -\n\
- -w, --width=NUMBER output width in columns, reference excluded\n\
- --help display this help and exit\n\
- --version output version information and exit\n\
-\n\
-With no FILE or if FILE is -, read Standard Input. `-F /' by default.\n");
- }
- exit (status);
-}
-
-/*----------------------------------------------------------------------.
-| Main program. Decode ARGC arguments passed through the ARGV array of |
-| strings, then launch execution. |
-`----------------------------------------------------------------------*/
-
-/* Long options equivalences. */
-const struct option long_options[] =
-{
- {"auto-reference", no_argument, NULL, 'A'},
- {"break-file", required_argument, NULL, 'b'},
- {"copyright", no_argument, NULL, 'C'},
- {"flag-truncation", required_argument, NULL, 'F'},
- {"ignore-case", no_argument, NULL, 'f'},
- {"gap-size", required_argument, NULL, 'g'},
- {"help", no_argument, &show_help, 1},
- {"ignore-file", required_argument, NULL, 'i'},
- {"macro-name", required_argument, NULL, 'M'},
- {"only-file", required_argument, NULL, 'o'},
- {"references", no_argument, NULL, 'r'},
- {"right-side-refs", no_argument, NULL, 'R'},
- {"format", required_argument, NULL, 10},
- {"sentence-regexp", required_argument, NULL, 'S'},
- {"traditional", no_argument, NULL, 'G'},
- {"typeset-mode", no_argument, NULL, 't'},
- {"version", no_argument, &show_version, 1},
- {"width", required_argument, NULL, 'w'},
- {"word-regexp", required_argument, NULL, 'W'},
- {0, 0, 0, 0},
-};
-
-static char const* const format_args[] =
-{
- "roff", "tex", 0
-};
-
-int
-main (int argc, char *const argv[])
-{
- int optchar; /* argument character */
- extern int optind; /* index of argument */
- extern char *optarg; /* value or argument */
- int file_index; /* index in text input file arrays */
-
-#ifdef HAVE_MCHECK
- /* Use GNU malloc checking. It has proven to be useful! */
- mcheck ();
-#endif /* HAVE_MCHECK */
-
-#ifdef STDC_HEADERS
-#ifdef HAVE_SETCHRCLASS
- setchrclass (NULL);
-#endif
-#endif
-
- /* Decode program options. */
-
- program_name = argv[0];
-
- while ((optchar = getopt_long (argc, argv, "ACF:GM:ORS:TW:b:i:fg:o:trw:",
- long_options, NULL)),
- optchar != EOF)
- {
- switch (optchar)
- {
- default:
- usage (1);
-
- case 0:
- break;
-
- case 'C':
- printf ("%s", copyright);
- exit (0);
-
- case 'G':
- gnu_extensions = 0;
- break;
-
- case 'b':
- break_file = optarg;
- break;
-
- case 'f':
- ignore_case = 1;
- break;
-
- case 'g':
- gap_size = atoi (optarg);
- break;
-
- case 'i':
- ignore_file = optarg;
- break;
-
- case 'o':
- only_file = optarg;
- break;
-
- case 'r':
- input_reference = 1;
- break;
-
- case 't':
- /* A decouvrir... */
- break;
-
- case 'w':
- line_width = atoi (optarg);
- break;
-
- case 'A':
- auto_reference = 1;
- break;
-
- case 'F':
- truncation_string = copy_unescaped_string (optarg);
- break;
-
- case 'M':
- macro_name = optarg;
- break;
-
- case 'O':
- output_format = ROFF_FORMAT;
- break;
-
- case 'R':
- right_reference = 1;
- break;
-
- case 'S':
- context_regex_string = copy_unescaped_string (optarg);
- break;
-
- case 'T':
- output_format = TEX_FORMAT;
- break;
-
- case 'W':
- word_regex_string = copy_unescaped_string (optarg);
- break;
-
- case 10:
- switch (argmatch (optarg, format_args))
- {
- default:
- usage (1);
-
- case 0:
- output_format = ROFF_FORMAT;
- break;
-
- case 1:
- output_format = TEX_FORMAT;
- break;
- }
- }
- }
-
- /* Process trivial options. */
-
- if (show_help)
- usage (0);
-
- if (show_version)
- {
- printf ("%s\n", version_string);
- exit (0);
- }
-
- /* Change the default Ignore file if one is defined. */
-
-#ifdef DEFAULT_IGNORE_FILE
- if (!ignore_file)
- ignore_file = DEFAULT_IGNORE_FILE;
-#endif
-
- /* Process remaining arguments. If GNU extensions are enabled, process
- all arguments as input parameters. If disabled, accept at most two
- arguments, the second of which is an output parameter. */
-
- if (optind == argc)
- {
-
- /* No more argument simply means: read standard input. */
-
- input_file_name = (const char **) xmalloc (sizeof (const char *));
- file_line_count = (int *) xmalloc (sizeof (int));
- number_input_files = 1;
- input_file_name[0] = NULL;
- }
- else if (gnu_extensions)
- {
- number_input_files = argc - optind;
- input_file_name
- = (const char **) xmalloc (number_input_files * sizeof (const char *));
- file_line_count
- = (int *) xmalloc (number_input_files * sizeof (int));
-
- for (file_index = 0; file_index < number_input_files; file_index++)
- {
- input_file_name[file_index] = argv[optind];
- if (!*argv[optind] || strcmp (argv[optind], "-") == 0)
- input_file_name[0] = NULL;
- else
- input_file_name[0] = argv[optind];
- optind++;
- }
- }
- else
- {
-
- /* There is one necessary input file. */
-
- number_input_files = 1;
- input_file_name = (const char **) xmalloc (sizeof (const char *));
- file_line_count = (int *) xmalloc (sizeof (int));
- if (!*argv[optind] || strcmp (argv[optind], "-") == 0)
- input_file_name[0] = NULL;
- else
- input_file_name[0] = argv[optind];
- optind++;
-
- /* Redirect standard output, only if requested. */
-
- if (optind < argc)
- {
- fclose (stdout);
- if (fopen (argv[optind], "w") == NULL)
- error (1, errno, argv[optind]);
- optind++;
- }
-
- /* Diagnose any other argument as an error. */
-
- if (optind < argc)
- usage (1);
- }
-
- /* If the output format has not been explicitly selected, choose dumb
- terminal format if GNU extensions are enabled, else `roff' format. */
-
- if (output_format == UNKNOWN_FORMAT)
- output_format = gnu_extensions ? DUMB_FORMAT : ROFF_FORMAT;
-
- /* Initialize the main tables. */
-
- initialize_regex ();
-
- /* Read `Break character' file, if any. */
-
- if (break_file)
- digest_break_file (break_file);
-
- /* Read `Ignore words' file and `Only words' files, if any. If any of
- these files is empty, reset the name of the file to NULL, to avoid
- unnecessary calls to search_table. */
-
- if (ignore_file)
- {
- digest_word_file (ignore_file, &ignore_table);
- if (ignore_table.length == 0)
- ignore_file = NULL;
- }
-
- if (only_file)
- {
- digest_word_file (only_file, &only_table);
- if (only_table.length == 0)
- only_file = NULL;
- }
-
- /* Prepare to study all the input files. */
-
- number_of_occurs[0] = 0;
- total_line_count = 0;
- maximum_word_length = 0;
- reference_max_width = 0;
-
- for (file_index = 0; file_index < number_input_files; file_index++)
- {
-
- /* Read the file in core, than study it. */
-
- swallow_file_in_memory (input_file_name[file_index], &text_buffer);
- find_occurs_in_text ();
-
- /* Maintain for each file how many lines has been read so far when its
- end is reached. Incrementing the count first is a simple kludge to
- handle a possible incomplete line at end of file. */
-
- total_line_count++;
- file_line_count[file_index] = total_line_count;
- }
-
- /* Do the output process phase. */
-
- sort_found_occurs ();
- fix_output_parameters ();
- generate_all_output ();
-
- /* All done. */
-
- exit (0);
-}
diff --git a/gnu/usr.bin/ptx/xmalloc.c b/gnu/usr.bin/ptx/xmalloc.c
deleted file mode 100644
index 58a81b5..0000000
--- a/gnu/usr.bin/ptx/xmalloc.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/* xmalloc.c -- malloc with out of memory checking
- Copyright (C) 1990, 1991, 1993 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
- using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
- (which it would do because it found this file in $srcdir). */
-#include <config.h>
-#else
-#include "config.h"
-#endif
-#endif
-
-#if __STDC__
-#define VOID void
-#else
-#define VOID char
-#endif
-
-#include <sys/types.h>
-
-#if STDC_HEADERS
-#include <stdlib.h>
-#else
-VOID *malloc ();
-VOID *realloc ();
-void free ();
-#endif
-
-#if __STDC__ && defined (HAVE_VPRINTF)
-void error (int, int, char const *, ...);
-#else
-void error ();
-#endif
-
-/* Allocate N bytes of memory dynamically, with error checking. */
-
-VOID *
-xmalloc (n)
- size_t n;
-{
- VOID *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. */
-
-VOID *
-xrealloc (p, n)
- VOID *p;
- size_t 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/gnu/usr.bin/rcs/CREDITS b/gnu/usr.bin/rcs/CREDITS
deleted file mode 100644
index e0fb955..0000000
--- a/gnu/usr.bin/rcs/CREDITS
+++ /dev/null
@@ -1,24 +0,0 @@
-RCS was designed and built by Walter F. Tichy of Purdue University.
-RCS version 3 was released in 1983.
-
-Adam Hammer, Thomas Narten, and Daniel Trinkle of Purdue supported RCS through
-version 4.3, released in 1990. Guy Harris of Sun contributed many porting
-fixes. Paul Eggert of System Development Corporation contributed bug fixes
-and tuneups. Jay Lepreau contributed 4.3BSD support.
-
-Paul Eggert of Twin Sun wrote the changes for RCS versions 5.5 and 5.6 (1991).
-Rich Braun of Kronos and Andy Glew of Intel contributed ideas for new options.
-Bill Hahn of Stratus contributed ideas for setuid support.
-Ideas for piece tables came from Joe Berkovitz of Stratus and Walter F. Tichy.
-Matt Cross of Stratus contributed test case ideas.
-Adam Hammer of Purdue QAed.
-
-Paul Eggert wrote most of the changes for this version of RCS,
-currently in beta test. K. Richard Pixley of Cygnus Support
-contributed several bug fixes. Robert Lupton of Princeton
-and Daniel Trinkle contributed ideas for $Name expansion.
-Brendan Kehoe of Cygnus Support suggested rlog's -N option.
-Paul D. Smith of Data General suggested improvements in option
-and error processing. Adam Hammer of Purdue QAed.
-
-$Id$
diff --git a/gnu/usr.bin/rcs/Makefile b/gnu/usr.bin/rcs/Makefile
deleted file mode 100644
index 4a9fd08..0000000
--- a/gnu/usr.bin/rcs/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-SUBDIR= lib ci co ident merge rcs rcsclean rcsdiff rcsmerge rlog rcsfreeze
-
-.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/rcs/Makefile.inc b/gnu/usr.bin/rcs/Makefile.inc
deleted file mode 100644
index 22d60d7..0000000
--- a/gnu/usr.bin/rcs/Makefile.inc
+++ /dev/null
@@ -1,7 +0,0 @@
-# Location of librcs
-
-.if exists(${.OBJDIR}/../lib)
-LIBRCS= ${.OBJDIR}/../lib/librcs.a
-.else
-LIBRCS= ${.CURDIR}/../lib/librcs.a
-.endif
diff --git a/gnu/usr.bin/rcs/NEWS b/gnu/usr.bin/rcs/NEWS
deleted file mode 100644
index cda484e..0000000
--- a/gnu/usr.bin/rcs/NEWS
+++ /dev/null
@@ -1,548 +0,0 @@
-Recent changes to RCS (and possible future changes)
-
- $Id$
-
- Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
- This file is part of RCS.
-
- RCS 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.
-
- RCS 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 RCS; see the file COPYING.
- If not, write to the Free Software Foundation,
- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-
-Here is a brief summary of user-visible changes since 5.6.
-
- New options:
- `-kb' supports binary files.
- `-T' preserves the modification time of RCS files.
- `-V' prints the version number.
- `-zLT' causes RCS to use local time in working files and logs.
- `rcsclean -n' outputs what rcsclean would do, without actually doing it.
- `rlog -N' omits symbolic names.
- There is a new keyword `Name'.
- Inserted log lines now have the same prefix as the preceding `$Log' line.
-
-Most changes for RCS version 5.7 are to fix bugs and improve portability.
-RCS now conforms to GNU configuration standards and to Posix 1003.1b-1993.
-
-
-Features new to RCS version 5.7, and possibly incompatible
-in minor ways with previous practice, include:
-
- Inserted log lines now have the same prefix as the preceding `$Log' line.
- E.g. if a $Log line starts with `// $Log', log lines are prefixed with `// '.
- RCS still records the (now obsolescent) comment leader inside RCS files,
- but it ignores the comment leader unless it is emulating older RCS versions.
- If you plan to access a file with both old and new versions of RCS,
- make sure its comment leader matches its `$Log' line prefix.
- For backwards compatibility with older versions of RCS,
- if the log prefix is `/*' or `(*' surrounded by optional white space,
- inserted log lines contain ` *' instead of `/*' or `(*';
- however, this usage is obsolescent and should not be relied on.
-
- $Log string `Revision' times now use the same format as other times.
-
- Log lines are now inserted even if -kk is specified; this simplifies merging.
-
- ci's -rR option (with a nonempty R) now just specifies a revision number R.
- In some beta versions, it also reestablished the default behavior of
- releasing a lock and removing the working file.
- Now, only the bare -r option does this.
-
- With an empty extension, any appearance of a directory named `RCS'
- in a pathname identifies the pathname as being that of an RCS file.
- For example, `a/RCS/b/c' is now an RCS file with an empty extension.
- Formerly, `RCS' had to be the last directory in the pathname.
-
- rlog's -d option by default now uses exclusive time ranges.
- E.g. `rlog -d"<T"' now excludes revisions whose times equal T exactly.
- Use `rlog -d"<=T"' to get the old behavior.
-
- merge now takes up to three -L options, one for each input file.
- Formerly, it took at most two -L options, for the 1st and 3rd input files.
-
- `rcs' now requires at least one option; this is for future expansion.
-
-Other features new to RCS version 5.7 include:
-
- merge and rcsmerge now pass -A, -E, and -e options to the subsidiary diff3.
-
- rcs -kb acts like rcs -ko, except it uses binary I/O on working files.
- This makes no difference under Posix or Unix, but it does matter elsewhere.
- With -kb in effect, rcsmerge refuses to merge;
- this avoids common problems with CVS merging.
-
- The following is for future use by GNU Emacs 19's version control package:
-
- rcs's new -M option causes it to not send mail when you break somebody
- else's lock. This is not meant for casual use; see rcs(1).
-
- ci's new -i option causes an error if the RCS file already exists.
- Similarly, -j causes an error if the RCS file does not already exist.
-
- The new keyword `Name' is supported; its value is the name, if any,
- used to check out the revision. E.g. `co -rN foo' causes foo's
- $Name...$ keyword strings to end in `: N $'.
-
- The new -zZONE option causes RCS to output dates and times using ISO 8601
- format with ZONE as the time zone, and to use ZONE as the default time
- zone for input. Its most common use is the -zLT option, which causes RCS
- to use local time externally. You can also specify foreign time zones;
- e.g. -z+05:30 causes RCS to use India time (5 hours 30 minutes east of UTC).
- This option does not affect RCS files themselves, which always use UTC;
- it affects only output (e.g. rlog output, keyword expansion, diff -c times)
- and interpretation of options (e.g. the -d option of ci, co, and rlog).
- Bare -z restores the default behavior of UTC with no time zone indication,
- and the traditional RCS date separator `/' instead of the ISO 8601 `-'.
- RCSINIT may contain a -z option. ci -k parses UTC offsets.
-
- The new -T option of ci, co, rcs, and rcsclean preserves the modification
- time of the RCS file unless a revision is added or removed.
- ci -T sets the RCS file's modification time to the new revision's time
- if the former precedes the latter and there is a new revision;
- otherwise, it preserves the RCS file's modification time.
- Use this option with care, as it can confuse `make'; see ci(1).
-
- The new -N option of rlog omits symbolic names from the output.
-
- A revision number that starts with `.' is considered to be relative to
- the default branch (normally the trunk). A branch number followed by `.'
- stands for the last revision on that branch.
-
- If someone else already holds the lock, rcs -l now asks whether you want
- to break it, instead of immediately reporting an error.
-
- ci now always unlocks a revision like 3.5 if you check in a revision
- like 3.5.2.1 that is the first of a new branch of that revision.
- Formerly it was inconsistent.
-
- File names may now contain tab, newline, space, and '$'.
- They are represented in keyword strings with \t, \n, \040, and \044.
- \ in a file name is now represented by \\ in a keyword string.
-
- Identifiers may now start with a digit and (unless they are symbolic names)
- may contain `.'. This permits author names like `john.doe' and `4tran'.
-
- A bare -V option now prints the current version number.
-
- rcsdiff outputs more readable context diff headers if diff -L works.
-
- rcsdiff -rN -rN now suppresses needless checkout and comparison
- of identical revisions.
-
- Error messages now contain the names of files to which they apply.
-
- Mach style memory mapping is now supported.
-
- The installation procedure now conforms to the GNU coding standards.
-
- When properly configured, RCS now strictly conforms to Posix 1003.1b-1993.
-
-
-Features new to RCS version 5.6 include:
-
- Security holes have been plugged; setgid use is no longer supported.
-
- co can retrieve old revisions much more efficiently.
- To generate the Nth youngest revision on the trunk,
- the old method used up to N passes through copies of the working file;
- the new method uses a piece table to generate the working file in one pass.
-
- When ci finds no changes in the working file,
- it automatically reverts to the previous revision unless -f is given.
-
- RCS follows symbolic links to RCS files instead of breaking them,
- and warns when it breaks hard links to RCS files.
-
- `$' stands for the revision number taken from working file keyword strings.
- E.g. if F contains an Id keyword string,
- `rcsdiff -r$ F' compares F to its checked-in revision, and
- `rcs -nL:$ F' gives the symbolic name L to F's revision.
-
- co and ci's new -M option sets the modification time
- of the working file to be that of the revision.
- Without -M, ci now tries to avoid changing the working file's
- modification time if its contents are unchanged.
-
- rcs's new -m option changes the log message of an old revision.
-
- RCS is portable to hosts that do not permit `,' in filenames.
- (`,' is not part of the Posix portable filename character set.)
- A new -x option specifies extensions other than `,v' for RCS files.
- The Unix default is `-x,v/', so that the working file `w' corresponds
- to the first file in the list `RCS/w,v', `w,v', `RCS/w' that works.
- The non-Unix default is `-x', so that only `RCS/w' is tried.
- Eventually, the Unix default should change to `-x/,v'
- to encourage interoperability among all Posix hosts.
-
- A new RCSINIT environment variable specifies defaults for options like -x.
-
- The separator for revision ranges has been changed from `-' to `:', because
- the range `A-B' is ambiguous if `A', `B' and `A-B' are all symbolic names.
- E.g. the old `rlog -r1.5-1.7' is now `rlog -r1.5:1.7'; ditto for `rcs -o'.
- For a while RCS will still support (but warn about) the old `-' separator.
-
- RCS manipulates its lock files using a method that is more reliable under NFS.
-
-
-Features new to RCS version 5 include:
-
- RCS can check in arbitrary files, not just text files, if diff -a works.
- RCS can merge lines containing just a single `.' if diff3 -m works.
- GNU diff supports the -a and -m options.
-
- RCS can now be used as a setuid program.
- See ci(1) for how users can employ setuid copies of ci, co, and rcsclean.
- Setuid privileges yield extra security if the effective user owns RCS files
- and directories, and if only the effective user can write RCS directories.
- RCS uses the real user for all accesses other than writing RCS directories.
- As described in ci(1), there are three levels of setuid support.
-
- 1. Setuid works fully if the seteuid() system call lets any
- process switch back and forth between real and effective users,
- as specified in Posix 1003.1a Draft 5.
-
- 2. On hosts with saved setuids (a Posix 1003.1-1990 option) and without
- a modern seteuid(), setuid works unless the real or effective user is root.
-
- 3. On hosts that lack both modern seteuid() and saved setuids,
- setuid does not work, and RCS uses the effective user for all accesses;
- formerly it was inconsistent.
-
- New options to co, rcsdiff, and rcsmerge give more flexibility to keyword
- substitution.
-
- -kkv substitutes the default `$Keyword: value $' for keyword strings.
- However, a locker's name is inserted only as a file is being locked,
- i.e. by `ci -l' and `co -l'. This is normally the default.
-
- -kkvl acts like -kkv, except that a locker's name is always inserted
- if the given revision is currently locked. This was the default in
- version 4. It is now the default only with when using rcsdiff to
- compare a revision to a working file whose mode is that of a file
- checked out for changes.
-
- -kk substitutes just `$Keyword$', which helps to ignore keyword values
- when comparing revisions.
-
- -ko retrieves the old revision's keyword string, thus bypassing keyword
- substitution.
-
- -kv retrieves just `value'. This can ease the use of keyword values, but
- it is dangerous because it causes RCS to lose track of where the keywords
- are, so for safety the owner write permission of the working file is
- turned off when -kv is used; to edit the file later, check it out again
- without -kv.
-
- rcs -ko sets the default keyword substitution to be in the style of co -ko,
- and similarly for the other -k options. This can be useful with file
- formats that cannot tolerate changing the lengths of keyword strings.
- However it also renders a RCS file readable only by RCS version 5 or later.
- Use rcs -kkv to restore the usual default substitution.
-
- RCS can now be used by development groups that span time zone boundaries.
- All times are now displayed in UTC, and UTC is the default time zone.
- To use local time with co -d, append ` LT' to the time.
- When interchanging RCS files with sites running older versions of RCS,
- time stamp discrepancies may prevent checkins; to work around this,
- use `ci -d' with a time slightly in the future.
-
- Dates are now displayed using four-digit years, not two-digit years.
- Years given in -d options must now have four digits.
- This change is required for RCS to continue to work after 1999/12/31.
- The form of dates in version 5 RCS files will not change until 2000/01/01,
- so in the meantime RCS files can still be interchanged with sites
- running older versions of RCS. To make room for the longer dates,
- rlog now outputs `lines: +A -D' instead of `lines added/del: A/D'.
-
- To help prevent diff programs that are broken or have run out of memory
- from trashing an RCS file, ci now checks diff output more carefully.
-
- ci -k now handles the Log keyword, so that checking in a file
- with -k does not normally alter the file's contents.
-
- RCS no longer outputs white space at the ends of lines
- unless the original working file had it.
- For consistency with other keywords,
- a space, not a tab, is now output after `$Log:'.
- Rlog now puts lockers and symbolic names on separate lines in the output
- to avoid generating lines that are too long.
- A similar fix has been made to lists in the RCS files themselves.
-
- RCS no longer outputs the string `Locker: ' when expanding Header or Id
- keywords. This saves space and reverts back to version 3 behavior.
-
- The default branch is not put into the RCS file unless it is nonempty.
- Therefore, files generated by RCS version 5 can be read by RCS version 3
- unless they use the default branch feature introduced in version 4.
- This fixes a compatibility problem introduced by version 4.
-
- RCS can now emulate older versions of RCS; see `co -V'.
- This may be useful to overcome compatibility problems
- due to the above changes.
-
- Programs like Emacs can now interact with RCS commands via a pipe:
- the new -I option causes ci, co, and rcs to run interactively,
- even if standard input is not a terminal.
- These commands now accept multiple inputs from stdin separated by `.' lines.
-
- ci now silently ignores the -t option if the RCS file already exists.
- This simplifies some shell scripts and improves security in setuid sites.
-
- Descriptive text may be given directly in an argument of the form -t-string.
-
- The character set for symbolic names has been upgraded
- from Ascii to ISO 8859.
-
- rcsdiff now passes through all options used by GNU diff;
- this is a longer list than 4.3BSD diff.
-
- merge's new -L option gives tags for merge's overlap report lines.
- This ability used to be present in a different, undocumented form;
- the new form is chosen for compatibility with GNU diff3's -L option.
-
- rcsmerge and merge now have a -q option, just like their siblings do.
-
- rcsclean's new -n option outputs what rcsclean would do,
- without actually doing it.
-
- RCS now attempts to ignore parts of an RCS file that look like they come
- from a future version of RCS.
-
- When properly configured, RCS now strictly conforms with Posix 1003.1-1990.
- RCS can still be compiled in non-Posix traditional Unix environments,
- and can use common BSD and USG extensions to Posix.
- RCS is a conforming Standard C program, and also compiles under traditional C.
-
- Arbitrary limits on internal table sizes have been removed.
- The only limit now is the amount of memory available via malloc().
-
- File temporaries, lock files, signals, and system call return codes
- are now handled more cleanly, portably, and quickly.
- Some race conditions have been removed.
-
- A new compile-time option RCSPREFIX lets administrators avoid absolute path
- names for subsidiary programs, trading speed for flexibility.
-
- The configuration procedure is now more automatic.
-
- Snooping has been removed.
-
-
-Version 4 was the first version distributed by FSF.
-Beside bug fixes, features new to RCS version 4 include:
-
- The notion of default branch has been added; see rcs -b.
-
-
-Version 3 was included in the 4.3BSD distribution.
-
-
-Here are some possible future changes for RCS:
-
- Bring back sccstorcs.
-
- Add an option to `rcsmerge' so that it can use an arbitrary program
- to do the 3-way merge, instead of the default `merge'.
- Likewise for `rcsdiff' and `diff'. It should be possible to pass
- arbitrary options to these programs, and to the subsidiary `co's.
-
- Add format options for finer control over the output of ident and rlog.
- E.g. there should be an easy way for rlog to output lines like
- `src/main.c 2.4 wft', one for each locked revision.
- rlog options should have three orthogonal types: selecting files,
- selecting revisions, and selecting rlog format.
-
- Add format options for finer control over the output of keyword strings.
- E.g. there should be some way to prepend @(#), and there should be some
- way to change $ to some other character to disable further substitution.
- These options should make the resulting files uneditable, like -kv.
-
- Add long options, e.g. `--version'. Unfortunately RCS's option syntax
- is incompatible with getopt. Perhaps the best way is to overload `rcs', e.g.
- `rcs diff --keyword-substitution=old file' instead of `rcsdiff -ko file'.
-
- Add a way to put only the interesting part of the path into the $Header
- keyword expansion.
-
- rlog -rM:N should work even if M and N have different numbers of fields,
- so long as M is an ancestor of N or vice versa.
-
- rcs should evaluate options in order; this allows rcs -oS -nS.
-
- rcs should be able to fix minor mistakes in checkin dates and authors.
-
- Be able to redo your most recent checkin with minor changes.
-
- co -u shouldn't complain about a writable working file if it won't change
- its contents.
-
- Configure the Makefile automatically, as well as conf.h.
-
- Add a new option to rcs that behaves like -o, but that doesn't lose the
- nonempty log messages, but instead merges them with the next revision
- if it exists, perhaps with a 1-line header containing author, date, etc.
-
- Add a `-' option to take the list of pathnames from standard input.
- Perhaps the pathnames should be null-terminated, not newline-terminated,
- so that pathnames that contain newlines are handled properly.
-
- Permit multiple option-pathname pairs, e.g. co -r1.4 a -r1.5 b.
-
- Add options to allow arbitrary combinations of working file names
- with RCS file names -- they shouldn't have to match.
-
- Add an option to break a symbolic link to an RCS file,
- instead of breaking the hard link that it points to.
-
- Add ways to specify the earliest revision, the most recent revision,
- the earliest or latest revision on a particular branch, and
- the parent or child of some other revision.
-
- If a user has multiple locks, perhaps ci should fall back on ci -k's
- method to figure out which revision to use.
-
- Symbolic names need not refer to existing branches and revisions.
- rcs(1)'s BUGS section says this is a bug. Is it? If so, it should be fixed.
-
- Add an option to rcs -o so that old log messages are not deleted if
- the next undeleted revision exists, but are merely appended to the log
- message of that revision.
-
- ci -k should be able to get keyword values from the first `$Log' entry.
-
- Add an option to rcsclean to clean directories recursively.
-
- Write an rcsck program that repairs corrupted RCS files,
- much as fsck repairs corrupted file systems.
- For example, it should remove stale lock files.
-
- Clean up the source code with a consistent indenting style.
-
- Update the date parser to use the more modern getdate.y by Bellovin,
- Salz, and Berets, or the even more modern getdate by Moraes. None of
- these getdate implementations are as robust as RCS's old warhorse in
- avoiding problems like arithmetic overflow, so they'll have to be
- fixed first.
-
- Break up the code into a library so that it's easier to write new programs
- that manipulate RCS files, and so that useless code is removed from the
- existing programs. For example, the rcs command contains unnecessary
- keyword substitution baggage, and the merge command can be greatly pruned.
-
- Make it easier to use your favorite text editor to edit log messages,
- etc. instead of having to type them in irretrievably at the terminal.
-
- Let the user specify a search path for default branches,
- e.g. to use L as the default branch if it works, and M otherwise.
- Let the user require that at least one entry in the default branch path works.
- Let the user say that later entries in the default branch path are read only,
- i.e. one cannot check in changes to them.
- This should be an option settable by RCSINIT.
-
- Add a way for a user to see which revisions affected which lines.
-
- Have `rlog -nN F' print just the revision number that N translates to.
- E.g. `rlog -nB. F' would print the highest revision on the branch B.
- Use this to add an option -bB to rcsbranch, to freeze the named branch.
- This should interact well with default branches.
-
- Add a co option that prints the revision number before each line,
- as SCCS's `get -m' does.
-
-The following projects require a change to RCS file format.
-
- Allow keyword expansion to be changed on a per-revision basis,
- not on a per-file basis as now. This would allow -ko to be used
- on imported revisions, with the default -kkv otherwise.
-
- When two or more branches are merged, record all the ancestors
- of the new revision. The hard part of this is keeping track of all
- the ancestors of a working file while it's checked out.
-
- Add loose locking, which is like non-strict but applies to all users,
- not just the owner of the RCS file.
-
- Be able to store RCS files in compressed format.
- Don't bother to use a .Z extension that would exceed file name length limits;
- just look at the magic number.
-
- Add locker commentary, e.g. `co -l -m"checkout to fix merge bug" foo'
- to tell others why you checked out `foo'.
- Also record the time when the revision was locked,
- and perhaps the working pathname (if applicable).
-
- Let the user mark an RCS revision as deleted; checking out such a revision
- would result in no working file. Similarly, using `co -d' with a date either
- before the initial revision or after the file was marked deleted should
- remove the working file. For extra credit, extend the notion of `deleted' to
- include `renamed'. RCS should support arbitrary combinations of renaming and
- deletion, e.g. renaming A to B and B to A, checking in new revisions to both
- files, and then renaming them back.
-
- Be able to check in an entire directory structure into a single RCS file.
-
- Use a better scheme for locking revisions; the current scheme requires
- changing the RCS file just to lock or unlock a revision.
- The new scheme should coexist as well as possible with older versions of RCS,
- and should avoid the rare NFS bugs mentioned in rcsedit.c.
- E.g. if there's a reliable lockd running, RCS should use it
- instead of relying on NFS.
-
- Add rcs options for changing keyword names, e.g. XConsortium instead of Id.
-
- Add a `$Description' keyword; but this may be tricky, since descriptions can
- contain newlines and $s.
-
- Add a `$Copyright' keyword that expands to a copyright notice.
-
- Add frozen branches a la SCCS. In general, be able to emulate all of
- SCCS, so that an SCCS-to-RCS program can be practical. For example,
- there should be an equivalent to the SCCS prt command.
-
- Add support for distributed RCS, where widely separated
- users cannot easily access each others' RCS files,
- and must periodically distribute and reconcile new revisions.
-
- Be able to create empty branches.
-
- Be able to store just deltas from a read-only principal copy,
- e.g. from source on CD-ROM.
-
- Improve RCS's method for storing binary files.
- Although it is more efficient than SCCS's,
- the diff algorithm is still line oriented,
- and often generates long output for minor changes to an executable file.
-
- From the user's point of view, it would be best if
- RCS detected and handled binary files without human intervention,
- switching expansion methods as needed from revision to revision.
-
- Allow RCS to determine automagically whether -ko or -kb should be the default
- by inspecting the file's contents or name. The magic should be optional
- and user-programmable.
-
- Extend the grammar of RCS files so that keywords need not be in a fixed order.
-
- Internationalize messages; unfortunately, there's no common standard yet.
- This requires a change in RCS file format because of the
- `empty log message' and `checked in with -k' hacks inside RCS files.
-
- Add documentation in texinfo format.
diff --git a/gnu/usr.bin/rcs/REFS b/gnu/usr.bin/rcs/REFS
deleted file mode 100644
index 8f326f9..0000000
--- a/gnu/usr.bin/rcs/REFS
+++ /dev/null
@@ -1,90 +0,0 @@
-Here are references to RCS and related free software and documentation.
-Some of this information changes often; see the Frequently Asked Questions
-for more up-to-date references.
-
- $Id$
-
-
-Frequently Asked Questions (FAQs)
-
-<http://www.qucis.queensu.ca/Software-Engineering/>
-<ftp://rtfm.mit.edu//pub/usenet-by-hierarchy/comp/software-eng/>
- for software engineering; e.g. see
- <http://www.qucis.queensu.ca/Software-Engineering/blurb/rcs>.
-
-<http://www.iac.honeywell.com/Pub/Tech/CM/CMFAQ.html>
-<ftp://rtfm.mit.edu//pub/usenet-by-hierarchy/comp/software/config-mgmt/>
- for configuration management
-
-<http://www.winternet.com/~zoo/cvs/FAQ.txt>
-<ftp://ftp.odi.com/pub/users/dgg/FAQ.gz>
- for CVS (see below)
-
-
-RCS and related GNU project software
-
-<ftp://ftp.cs.purdue.edu/pub/RCS/>
- The RCS project distribution directory also contains beta versions,
- ports, and prebuilt documentation.
-
-<ftp://prep.ai.mit.edu/pub/gnu/>
- The GNU project distribution directory contains:
- diffutils-N-tar.gz
- the latest diffutils release; recommended for RCS
- emacs-N-tar.gz
- The latest Emacs release contains VC, a version-control package
- that makes RCS easier to use.
- make-N-tar.gz
- GNU Make, which can automatically build from RCS files.
- rcs-N-tar.gz
- the latest RCS release
- cvs-N-tar.gz
- the latest official CVS release (see below)
-
-<ftp://ftp.leo.org/pub/comp/os/os2/gnu/devtools/> DOS, OS/2 ports
-<ftp://ftp.cc.utexas.edu/microlib/nt/gnu/> NT port
-
-
-CVS
-
-CVS, the Concurrent Versions System, keeps tracks of source changes
-made by groups of developers working on the same files concurrently,
-allowing them to resync as needed.
-
-<http://www.winternet.com/~zoo/cvs/>
-<http://www.loria.fr/~molli/cvs-index.html>
- These pages have useful information about CVS.
-
-<ftp://prep.ai.mit.edu/pub/gnu/cvs-1.3.tar.gz>
- CVS 1.3 is the latest released version.
-
-<ftp://ftp.delos.com/pub/cvs/alpha/cvs-1.4A2.tar.gz>
- CVS 1.4 is in alpha test, but it is recommended if you are installing CVS
- for the first time, or on a recent operating system.
-
-<ftp://ftp-os2.cdrom.com/pub/os2/unix/> DOS, OS/2 ports
-<ftp://ftp.cc.utexas.edu/microlib/nt/gnu/> NT port
-
-<ftp://ftp.cyclic.com/pub/cvs/>
- Cyclic CVS adds network transparency to CVS; it supports efficient,
- reliable, and authenticated repository access via TCP/IP.
-
-
-Other software that uses RCS
-
-<ftp://ftp.nau.edu/pub/Aegis/>
- Aegis manages revisions, baselines, mandatory reviews, and mandatory testing.
-
-<ftp://ftp.vix.com/pub/patches/csu/>
- BCS, the Baseline Configuration System,
- manages revisions, baselines, and staging areas.
-
-<ftp://riftp.osf.org/pub/ode/>
- ODE, the Open Software Foundation Development Environment,
- manages revisions, builds, and sandboxes.
- OSF uses it for their own development.
-
-<ftp://bellcore.com/pub/Odin/>
- Odin, a `make' replacement, can build directly from arbitrary revisions
- without requiring checkouts of working copies. It also handles
- parallel builds on multiple remote hosts and of multiple variants.
diff --git a/gnu/usr.bin/rcs/ci/Makefile b/gnu/usr.bin/rcs/ci/Makefile
deleted file mode 100644
index 2fbb74f..0000000
--- a/gnu/usr.bin/rcs/ci/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG= ci
-SRCS= ci.c
-CFLAGS+= -I${.CURDIR}/../lib
-LDADD= ${LIBRCS}
-DPADD= ${LIBRCS}
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/rcs/ci/ci.1 b/gnu/usr.bin/rcs/ci/ci.1
deleted file mode 100644
index 64e90ef..0000000
--- a/gnu/usr.bin/rcs/ci/ci.1
+++ /dev/null
@@ -1,898 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id$
-.ds i \&\s-1ISO\s0
-.ds r \&\s-1RCS\s0
-.ds u \&\s-1UTC\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.TH CI 1 \*(Dt GNU
-.SH NAME
-ci \- check in RCS revisions
-.SH SYNOPSIS
-.B ci
-.RI [ options ] " file " .\|.\|.
-.SH DESCRIPTION
-.B ci
-stores new revisions into \*r files.
-Each pathname matching an \*r suffix
-is taken to be an \*r file.
-All others
-are assumed to be working files containing new revisions.
-.B ci
-deposits the contents of each working file
-into the corresponding \*r file.
-If only a working file is given,
-.B ci
-tries to find the corresponding \*r file in an \*r subdirectory
-and then in the working file's directory.
-For more details, see
-.SM "FILE NAMING"
-below.
-.PP
-For
-.B ci
-to work, the caller's login must be on the access list,
-except if the access list is empty or the caller is the superuser or the
-owner of the file.
-To append a new revision to an existing branch, the tip revision on
-that branch must be locked by the caller. Otherwise, only a
-new branch can be created. This restriction is not enforced
-for the owner of the file if non-strict locking is used
-(see
-.BR rcs (1)).
-A lock held by someone else can be broken with the
-.B rcs
-command.
-.PP
-Unless the
-.B \-f
-option is given,
-.B ci
-checks whether the revision to be deposited differs from the preceding one.
-If not, instead of creating a new revision
-.B ci
-reverts to the preceding one.
-To revert, ordinary
-.B ci
-removes the working file and any lock;
-.B "ci\ \-l"
-keeps and
-.B "ci\ \-u"
-removes any lock, and then they both generate a new working file much as if
-.B "co\ \-l"
-or
-.B "co\ \-u"
-had been applied to the preceding revision.
-When reverting, any
-.B \-n
-and
-.B \-s
-options apply to the preceding revision.
-.PP
-For each revision deposited,
-.B ci
-prompts for a log message.
-The log message should summarize the change and must be terminated by
-end-of-file or by a line containing
-.BR \&. "\ by"
-itself.
-If several files are checked in
-.B ci
-asks whether to reuse the
-previous log message.
-If the standard input is not a terminal,
-.B ci
-suppresses the prompt
-and uses the same log message for all files.
-See also
-.BR \-m .
-.PP
-If the \*r file does not exist,
-.B ci
-creates it and
-deposits the contents of the working file as the initial revision
-(default number:
-.BR 1.1 ).
-The access list is initialized to empty.
-Instead of the log message,
-.B ci
-requests descriptive text (see
-.B \-t
-below).
-.PP
-The number
-.I rev
-of the deposited revision can be given by any of the options
-.BR \-f ,
-.BR \-i ,
-.BR \-I ,
-.BR \-j ,
-.BR \-k ,
-.BR \-l ,
-.BR \-M ,
-.BR \-q ,
-.BR \-r ,
-or
-.BR \-u .
-.I rev
-can be symbolic, numeric, or mixed.
-Symbolic names in
-.I rev
-must already be defined;
-see the
-.B \-n
-and
-.B \-N
-options for assigning names during checkin.
-If
-.I rev
-is
-.BR $ ,
-.B ci
-determines the revision number from keyword values in the working file.
-.PP
-If
-.I rev
-begins with a period,
-then the default branch (normally the trunk) is prepended to it.
-If
-.I rev
-is a branch number followed by a period,
-then the latest revision on that branch is used.
-.PP
-If
-.I rev
-is a revision number, it must be higher than the latest
-one on the branch to which
-.I rev
-belongs, or must start a new branch.
-.PP
-If
-.I rev
-is a branch rather than a revision number,
-the new revision is appended to that branch. The level number is obtained
-by incrementing the tip revision number of that branch.
-If
-.I rev
-indicates a non-existing branch,
-that branch is created with the initial revision numbered
-.IB rev .1\f1.\fP
-.br
-.ne 8
-.PP
-If
-.I rev
-is omitted,
-.B ci
-tries to derive the new revision number from
-the caller's last lock. If the caller has locked the tip revision of a branch,
-the new revision is appended to that branch.
-The new revision number is obtained
-by incrementing the tip revision number.
-If the caller locked a non-tip revision, a new branch is started at
-that revision by incrementing the highest branch number at that revision.
-The default initial branch and level numbers are
-.BR 1 .
-.PP
-If
-.I rev
-is omitted and the caller has no lock, but owns
-the file and locking
-is not set to
-.IR strict ,
-then the revision is appended to the
-default branch (normally the trunk; see the
-.B \-b
-option of
-.BR rcs (1)).
-.PP
-Exception: On the trunk, revisions can be appended to the end, but
-not inserted.
-.SH OPTIONS
-.TP
-.BI \-r rev
-Check in revision
-.IR rev .
-.TP
-.BR \-r
-The bare
-.B \-r
-option (without any revision) has an unusual meaning in
-.BR ci .
-With other \*r commands, a bare
-.B \-r
-option specifies the most recent revision on the default branch,
-but with
-.BR ci ,
-a bare
-.B \-r
-option reestablishes the default behavior of releasing a lock and
-removing the working file, and is used to override any default
-.B \-l
-or
-.B \-u
-options established by shell aliases or scripts.
-.TP
-.BR \-l [\f2rev\fP]
-works like
-.BR \-r ,
-except it performs an additional
-.B "co\ \-l"
-for the
-deposited revision. Thus, the deposited revision is immediately
-checked out again and locked.
-This is useful for saving a revision although one wants to continue
-editing it after the checkin.
-.TP
-.BR \-u [\f2rev\fP]
-works like
-.BR \-l ,
-except that the deposited revision is not locked.
-This lets one read the working file
-immediately after checkin.
-.RS
-.PP
-The
-.BR \-l ,
-bare
-.BR \-r ,
-and
-.B \-u
-options are mutually exclusive and silently override each other.
-For example,
-.B "ci\ \-u\ \-r"
-is equivalent to
-.B "ci\ \-r"
-because bare
-.B \-r
-overrides
-.BR \-u .
-.RE
-.TP
-.BR \-f [\f2rev\fP]
-forces a deposit; the new revision is deposited even it is not different
-from the preceding one.
-.TP
-.BR \-k [\f2rev\fP]
-searches the working file for keyword values to determine its revision number,
-creation date, state, and author (see
-.BR co (1)),
-and assigns these
-values to the deposited revision, rather than computing them locally.
-It also generates a default login message noting the login of the caller
-and the actual checkin date.
-This option is useful for software distribution. A revision that is sent to
-several sites should be checked in with the
-.B \-k
-option at these sites to
-preserve the original number, date, author, and state.
-The extracted keyword values and the default log message can be overridden
-with the options
-.BR \-d ,
-.BR \-m ,
-.BR \-s ,
-.BR \-w ,
-and any option that carries a revision number.
-.TP
-.BR \-q [\f2rev\fP]
-quiet mode; diagnostic output is not printed.
-A revision that is not different from the preceding one is not deposited,
-unless
-.B \-f
-is given.
-.TP
-.BR \-i [\f2rev\fP]
-initial checkin; report an error if the \*r file already exists.
-This avoids race conditions in certain applications.
-.TP
-.BR \-j [\f2rev\fP]
-just checkin and do not initialize;
-report an error if the \*r file does not already exist.
-.TP
-.BR \-I [\f2rev\fP]
-interactive mode;
-the user is prompted and questioned
-even if the standard input is not a terminal.
-.TP
-.BR \-d "[\f2date\fP]"
-uses
-.I date
-for the checkin date and time.
-The
-.I date
-is specified in free format as explained in
-.BR co (1).
-This is useful for lying about the checkin date, and for
-.B \-k
-if no date is available.
-If
-.I date
-is empty, the working file's time of last modification is used.
-.TP
-.BR \-M [\f2rev\fP]
-Set the modification time on any new working file
-to be the date of the retrieved revision.
-For example,
-.BI "ci\ \-d\ \-M\ \-u" "\ f"
-does not alter
-.IR f 's
-modification time, even if
-.IR f 's
-contents change due to keyword substitution.
-Use this option with care; it can confuse
-.BR make (1).
-.TP
-.BI \-m "msg"
-uses the string
-.I msg
-as the log message for all revisions checked in.
-By convention, log messages that start with
-.B #
-are comments and are ignored by programs like GNU Emacs's
-.B vc
-package.
-Also, log messages that start with
-.BI { clumpname }
-(followed by white space) are meant to be clumped together if possible,
-even if they are associated with different files; the
-.BI { clumpname }
-label is used only for clumping,
-and is not considered to be part of the log message itself.
-.TP
-.BI \-n "name"
-assigns the symbolic name
-.I name
-to the number of the checked-in revision.
-.B ci
-prints an error message if
-.I name
-is already assigned to another
-number.
-.TP
-.BI \-N "name"
-same as
-.BR \-n ,
-except that it overrides a previous assignment of
-.IR name .
-.TP
-.BI \-s "state"
-sets the state of the checked-in revision to the identifier
-.IR state .
-The default state is
-.BR Exp .
-.TP
-.BI \-t file
-writes descriptive text from the contents of the named
-.I file
-into the \*r file,
-deleting the existing text.
-The
-.I file
-cannot begin with
-.BR \- .
-.TP
-.BI \-t\- string
-Write descriptive text from the
-.I string
-into the \*r file, deleting the existing text.
-.RS
-.PP
-The
-.B \-t
-option, in both its forms, has effect only during an initial checkin;
-it is silently ignored otherwise.
-.PP
-During the initial checkin, if
-.B \-t
-is not given,
-.B ci
-obtains the text from standard input,
-terminated by end-of-file or by a line containing
-.BR \&. "\ by"
-itself.
-The user is prompted for the text if interaction is possible; see
-.BR \-I .
-.PP
-For backward compatibility with older versions of \*r, a bare
-.B \-t
-option is ignored.
-.RE
-.TP
-.B \-T
-Set the \*r file's modification time to the new revision's time
-if the former precedes the latter and there is a new revision;
-preserve the \*r file's modification time otherwise.
-If you have locked a revision,
-.B ci
-usually updates the \*r file's modification time to the current time,
-because the lock is stored in the \*r file
-and removing the lock requires changing the \*r file.
-This can create an \*r file newer than the working file in one of two ways:
-first,
-.B "ci\ \-M"
-can create a working file with a date before the current time;
-second, when reverting to the previous revision
-the \*r file can change while the working file remains unchanged.
-These two cases can cause excessive recompilation caused by a
-.BR make (1)
-dependency of the working file on the \*r file.
-The
-.B \-T
-option inhibits this recompilation by lying about the \*r file's date.
-Use this option with care; it can suppress recompilation even when
-a checkin of one working file should affect
-another working file associated with the same \*r file.
-For example, suppose the \*r file's time is 01:00,
-the (changed) working file's time is 02:00,
-some other copy of the working file has a time of 03:00,
-and the current time is 04:00.
-Then
-.B "ci\ \-d\ \-T"
-sets the \*r file's time to 02:00 instead of the usual 04:00;
-this causes
-.BR make (1)
-to think (incorrectly) that the other copy is newer than the \*r file.
-.TP
-.BI \-w "login"
-uses
-.I login
-for the author field of the deposited revision.
-Useful for lying about the author, and for
-.B \-k
-if no author is available.
-.TP
-.BI \-V
-Print \*r's version number.
-.TP
-.BI \-V n
-Emulate \*r version
-.IR n .
-See
-.BR co (1)
-for details.
-.TP
-.BI \-x "suffixes"
-specifies the suffixes for \*r files.
-A nonempty suffix matches any pathname ending in the suffix.
-An empty suffix matches any pathname of the form
-.BI RCS/ path
-or
-.IB path1 /RCS/ path2.
-The
-.B \-x
-option can specify a list of suffixes
-separated by
-.BR / .
-For example,
-.B \-x,v/
-specifies two suffixes:
-.B ,v
-and the empty suffix.
-If two or more suffixes are specified,
-they are tried in order when looking for an \*r file;
-the first one that works is used for that file.
-If no \*r file is found but an \*r file can be created,
-the suffixes are tried in order
-to determine the new \*r file's name.
-The default for
-.IR suffixes
-is installation-dependent; normally it is
-.B ,v/
-for hosts like Unix that permit commas in filenames,
-and is empty (i.e. just the empty suffix) for other hosts.
-.TP
-.BI \-z zone
-specifies the date output format in keyword substitution,
-and specifies the default time zone for
-.I date
-in the
-.BI \-d date
-option.
-The
-.I zone
-should be empty, a numeric \*u offset, or the special string
-.B LT
-for local time.
-The default is an empty
-.IR zone ,
-which uses the traditional \*r format of \*u without any time zone indication
-and with slashes separating the parts of the date;
-otherwise, times are output in \*i 8601 format with time zone indication.
-For example, if local time is January 11, 1990, 8pm Pacific Standard Time,
-eight hours west of \*u,
-then the time is output as follows:
-.RS
-.LP
-.RS
-.nf
-.ta \w'\f3\-z+05:30\fP 'u +\w'\f31990-01-11 09:30:00+05:30\fP 'u
-.ne 4
-\f2option\fP \f2time output\fP
-\f3\-z\fP \f31990/01/12 04:00:00\fP \f2(default)\fP
-\f3\-zLT\fP \f31990-01-11 20:00:00\-08\fP
-\f3\-z+05:30\fP \f31990-01-12 09:30:00+05:30\fP
-.ta 4n +4n +4n +4n
-.fi
-.RE
-.LP
-The
-.B \-z
-option does not affect dates stored in \*r files,
-which are always \*u.
-.SH "FILE NAMING"
-Pairs of \*r files and working files can be specified in three ways
-(see also the
-example section).
-.PP
-1) Both the \*r file and the working file are given. The \*r pathname is of
-the form
-.IB path1 / workfileX
-and the working pathname is of the form
-.IB path2 / workfile
-where
-.IB path1 /
-and
-.IB path2 /
-are (possibly different or empty) paths,
-.I workfile
-is a filename, and
-.I X
-is an \*r suffix.
-If
-.I X
-is empty,
-.IB path1 /
-must start with
-.B RCS/
-or must contain
-.BR /RCS/ .
-.PP
-2) Only the \*r file is given. Then the working file is created in the current
-directory and its name is derived from the name of the \*r file
-by removing
-.IB path1 /
-and the suffix
-.IR X .
-.PP
-3) Only the working file is given.
-Then
-.B ci
-considers each \*r suffix
-.I X
-in turn, looking for an \*r file of the form
-.IB path2 /RCS/ workfileX
-or (if the former is not found and
-.I X
-is nonempty)
-.IB path2 / workfileX.
-.PP
-If the \*r file is specified without a path in 1) and 2),
-.B ci
-looks for the \*r file first in the directory
-.B ./RCS
-and then in the current
-directory.
-.PP
-.B ci
-reports an error if an attempt to open an \*r file fails for an unusual reason,
-even if the \*r file's pathname is just one of several possibilities.
-For example, to suppress use of \*r commands in a directory
-.IR d ,
-create a regular file named
-.IB d /RCS
-so that casual attempts to use \*r commands in
-.I d
-fail because
-.IB d /RCS
-is not a directory.
-.SH EXAMPLES
-Suppose
-.B ,v
-is an \*r suffix and the current directory contains a subdirectory
-.B RCS
-with an \*r file
-.BR io.c,v .
-Then each of the following commands check in a copy of
-.B io.c
-into
-.B RCS/io.c,v
-as the latest revision, removing
-.BR io.c .
-.LP
-.RS
-.nf
-.ft 3
-ci io.c; ci RCS/io.c,v; ci io.c,v;
-ci io.c RCS/io.c,v; ci io.c io.c,v;
-ci RCS/io.c,v io.c; ci io.c,v io.c;
-.ft
-.fi
-.RE
-.PP
-Suppose instead that the empty suffix
-is an \*r suffix and the current directory contains a subdirectory
-.B RCS
-with an \*r file
-.BR io.c .
-The each of the following commands checks in a new revision.
-.LP
-.RS
-.nf
-.ft 3
-ci io.c; ci RCS/io.c;
-ci io.c RCS/io.c;
-ci RCS/io.c io.c;
-.ft
-.fi
-.RE
-.SH "FILE MODES"
-An \*r file created by
-.B ci
-inherits the read and execute permissions
-from the working file. If the \*r file exists already,
-.B ci
-preserves its read and execute permissions.
-.B ci
-always turns off all write permissions of \*r files.
-.SH FILES
-Temporary files are created in the directory containing
-the working file, and also in the temporary directory (see
-.B \s-1TMPDIR\s0
-under
-.BR \s-1ENVIRONMENT\s0 ).
-A semaphore file or files are created in the directory containing the \*r file.
-With a nonempty suffix, the semaphore names begin with
-the first character of the suffix; therefore, do not specify an suffix
-whose first character could be that of a working filename.
-With an empty suffix, the semaphore names end with
-.B _
-so working filenames should not end in
-.BR _ .
-.PP
-.B ci
-never changes an \*r or working file.
-Normally,
-.B ci
-unlinks the file and creates a new one;
-but instead of breaking a chain of one or more symbolic links to an \*r file,
-it unlinks the destination file instead.
-Therefore,
-.B ci
-breaks any hard or symbolic links to any working file it changes;
-and hard links to \*r files are ineffective,
-but symbolic links to \*r files are preserved.
-.PP
-The effective user must be able to
-search and write the directory containing the \*r file.
-Normally, the real user must be able to
-read the \*r and working files
-and to search and write the directory containing the working file;
-however, some older hosts
-cannot easily switch between real and effective users,
-so on these hosts the effective user is used for all accesses.
-The effective user is the same as the real user
-unless your copies of
-.B ci
-and
-.B co
-have setuid privileges.
-As described in the next section,
-these privileges yield extra security if
-the effective user owns all \*r files and directories,
-and if only the effective user can write \*r directories.
-.PP
-Users can control access to \*r files by setting the permissions
-of the directory containing the files; only users with write access
-to the directory can use \*r commands to change its \*r files.
-For example, in hosts that allow a user to belong to several groups,
-one can make a group's \*r directories writable to that group only.
-This approach suffices for informal projects,
-but it means that any group member can arbitrarily change the group's \*r files,
-and can even remove them entirely.
-Hence more formal projects sometimes distinguish between an \*r administrator,
-who can change the \*r files at will, and other project members,
-who can check in new revisions but cannot otherwise change the \*r files.
-.SH "SETUID USE"
-To prevent anybody but their \*r administrator from deleting revisions,
-a set of users can employ setuid privileges as follows.
-.nr n \w'\(bu'+2n-1/1n
-.ds n \nn
-.if \n(.g .if r an-tag-sep .ds n \w'\(bu'u+\n[an-tag-sep]u
-.IP \(bu \*n
-Check that the host supports \*r setuid use.
-Consult a trustworthy expert if there are any doubts.
-It is best if the
-.B seteuid
-system call works as described in Posix 1003.1a Draft 5,
-because \*r can switch back and forth easily
-between real and effective users, even if the real user is
-.BR root .
-If not, the second best is if the
-.B setuid
-system call supports saved setuid
-(the {\s-1_POSIX_SAVED_IDS\s0} behavior of Posix 1003.1-1990);
-this fails only if the real or effective user is
-.BR root .
-If \*r detects any failure in setuid, it quits immediately.
-.IP \(bu \nn
-Choose a user
-.I A
-to serve as \*r administrator for the set of users.
-Only
-.I A
-can invoke the
-.B rcs
-command on the users' \*r files.
-.I A
-should not be
-.B root
-or any other user with special powers.
-Mutually suspicious sets of users should use different administrators.
-.IP \(bu \nn
-Choose a pathname
-.I B
-to be a directory of files to be executed by the users.
-.IP \(bu \nn
-Have
-.I A
-set up
-.I B
-to contain copies of
-.B ci
-and
-.B co
-that are setuid to
-.I A
-by copying the commands from their standard installation directory
-.I D
-as follows:
-.LP
-.RS
-.nf
-.ne 3
-\f3mkdir\fP \f2B\fP
-\f3cp\fP \f2D\fP\^\f3/c[io]\fP \f2B\fP
-\f3chmod go\-w,u+s\fP \f2B\fP\f3/c[io]\fP
-.fi
-.RE
-.IP \(bu \nn
-Have each user prepend
-.I B
-to their path as follows:
-.LP
-.RS
-.nf
-.ne 2
-\f3PATH=\fP\f2B\fP\f3:$PATH; export PATH\fP # ordinary shell
-\f3set path=(\fP\f2B\fP \f3$path)\fP # C shell
-.fi
-.RE
-.IP \(bu \nn
-Have
-.I A
-create each \*r directory
-.I R
-with write access only to
-.I A
-as follows:
-.LP
-.RS
-.nf
-.ne 2
-\f3mkdir\fP \f2R\fP
-\f3chmod go\-w\fP \f2R\fP
-.fi
-.RE
-.IP \(bu \nn
-If you want to let only certain users read the \*r files,
-put the users into a group
-.IR G ,
-and have
-.I A
-further protect the \*r directory as follows:
-.LP
-.RS
-.nf
-.ne 2
-\f3chgrp\fP \f2G R\fP
-\f3chmod g\-w,o\-rwx\fP \f2R\fP
-.fi
-.RE
-.IP \(bu \nn
-Have
-.I A
-copy old \*r files (if any) into
-.IR R ,
-to ensure that
-.I A
-owns them.
-.IP \(bu \nn
-An \*r file's access list limits who can check in and lock revisions.
-The default access list is empty,
-which grants checkin access to anyone who can read the \*r file.
-If you want limit checkin access,
-have
-.I A
-invoke
-.B "rcs\ \-a"
-on the file; see
-.BR rcs (1).
-In particular,
-.BI "rcs\ \-e\ \-a" A
-limits access to just
-.IR A .
-.IP \(bu \nn
-Have
-.I A
-initialize any new \*r files with
-.B "rcs\ \-i"
-before initial checkin, adding the
-.B \-a
-option if you want to limit checkin access.
-.IP \(bu \nn
-Give setuid privileges only to
-.BR ci ,
-.BR co ,
-and
-.BR rcsclean ;
-do not give them to
-.B rcs
-or to any other command.
-.IP \(bu \nn
-Do not use other setuid commands to invoke \*r commands;
-setuid is trickier than you think!
-.SH ENVIRONMENT
-.TP
-.B \s-1RCSINIT\s0
-options prepended to the argument list, separated by spaces.
-A backslash escapes spaces within an option.
-The
-.B \s-1RCSINIT\s0
-options are prepended to the argument lists of most \*r commands.
-Useful
-.B \s-1RCSINIT\s0
-options include
-.BR \-q ,
-.BR \-V ,
-.BR \-x ,
-and
-.BR \-z .
-.TP
-.B \s-1TMPDIR\s0
-Name of the temporary directory.
-If not set, the environment variables
-.B \s-1TMP\s0
-and
-.B \s-1TEMP\s0
-are inspected instead and the first value found is taken;
-if none of them are set,
-a host-dependent default is used, typically
-.BR /tmp .
-.SH DIAGNOSTICS
-For each revision,
-.B ci
-prints the \*r file, the working file, and the number
-of both the deposited and the preceding revision.
-The exit status is zero if and only if all operations were successful.
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert.
-.SH "SEE ALSO"
-co(1),
-ident(1), make(1), rcs(1), rcsclean(1), rcsdiff(1),
-rcsintro(1), rcsmerge(1), rlog(1), setuid(2), rcsfile(5)
-.br
-Walter F. Tichy,
-\*r\*-A System for Version Control,
-.I "Software\*-Practice & Experience"
-.BR 15 ,
-7 (July 1985), 637-654.
-.br
diff --git a/gnu/usr.bin/rcs/ci/ci.c b/gnu/usr.bin/rcs/ci/ci.c
deleted file mode 100644
index b5cf156..0000000
--- a/gnu/usr.bin/rcs/ci/ci.c
+++ /dev/null
@@ -1,1318 +0,0 @@
-/* Check in revisions of RCS files from working files. */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.30 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.29 1995/06/01 16:23:43 eggert
- * (main): Add -kb.
- * Use `cmpdate', not `cmpnum', to compare dates.
- * This is for MKS RCS's incompatible 20th-century date format.
- * Don't worry about errno after ftruncate fails.
- * Fix input file rewinding bug when large_memory && !maps_memory
- * and checking in a branch tip.
- *
- * (fixwork): Fall back on chmod if fchmod fails, since it might be ENOSYS.
- *
- * Revision 5.28 1994/03/20 04:52:58 eggert
- * Do not generate a corrupted RCS file if the user modifies the working file
- * while `ci' is running.
- * Do not remove the lock when `ci -l' reverts.
- * Move buffer-flushes out of critical sections, since they aren't critical.
- * Use ORCSerror to clean up after a fatal error.
- * Specify subprocess input via file descriptor, not file name.
- *
- * Revision 5.27 1993/11/09 17:40:15 eggert
- * -V now prints version on stdout and exits. Don't print usage twice.
- *
- * Revision 5.26 1993/11/03 17:42:27 eggert
- * Add -z. Don't subtract from RCS file timestamp even if -T.
- * Scan for and use Name keyword if -k.
- * Don't discard ignored phrases. Improve quality of diagnostics.
- *
- * Revision 5.25 1992/07/28 16:12:44 eggert
- * Add -i, -j, -V. Check that working and RCS files are distinct.
- *
- * Revision 5.24 1992/02/17 23:02:06 eggert
- * `-rREV' now just specifies a revision REV; only bare `-r' reverts to default.
- * Add -T.
- *
- * Revision 5.23 1992/01/27 16:42:51 eggert
- * Always unlock branchpoint if caller has a lock.
- * Add support for bad_chmod_close, bad_creat0. lint -> RCS_lint
- *
- * Revision 5.22 1992/01/06 02:42:34 eggert
- * Invoke utime() before chmod() to keep some buggy systems happy.
- *
- * Revision 5.21 1991/11/20 17:58:07 eggert
- * Don't read the delta tree from a nonexistent RCS file.
- *
- * Revision 5.20 1991/10/07 17:32:46 eggert
- * Fix log bugs. Remove lint.
- *
- * Revision 5.19 1991/09/26 23:10:30 eggert
- * Plug file descriptor leak.
- *
- * Revision 5.18 1991/09/18 07:29:10 eggert
- * Work around a common ftruncate() bug.
- *
- * Revision 5.17 1991/09/10 22:15:46 eggert
- * Fix test for redirected stdin.
- *
- * Revision 5.16 1991/08/19 23:17:54 eggert
- * When there are no changes, revert to previous revision instead of aborting.
- * Add piece tables, -M, -r$. Tune.
- *
- * Revision 5.15 1991/04/21 11:58:14 eggert
- * Ensure that working file is newer than RCS file after ci -[lu].
- * Add -x, RCSINIT, MS-DOS support.
- *
- * Revision 5.14 1991/02/28 19:18:47 eggert
- * Don't let a setuid ci create a new RCS file; rcs -i -a must be run first.
- * Fix ci -ko -l mode bug. Open work file at most once.
- *
- * Revision 5.13 1991/02/25 07:12:33 eggert
- * getdate -> getcurdate (SVR4 name clash)
- *
- * Revision 5.12 1990/12/31 01:00:12 eggert
- * Don't use uninitialized storage when handling -{N,n}.
- *
- * Revision 5.11 1990/12/04 05:18:36 eggert
- * Use -I for prompts and -q for diagnostics.
- *
- * Revision 5.10 1990/11/05 20:30:10 eggert
- * Don't remove working file when aborting due to no changes.
- *
- * Revision 5.9 1990/11/01 05:03:23 eggert
- * Add -I and new -t behavior. Permit arbitrary data in logs.
- *
- * Revision 5.8 1990/10/04 06:30:09 eggert
- * Accumulate exit status across files.
- *
- * Revision 5.7 1990/09/25 20:11:46 hammer
- * fixed another small typo
- *
- * Revision 5.6 1990/09/24 21:48:50 hammer
- * added cleanups from Paul Eggert.
- *
- * Revision 5.5 1990/09/21 06:16:38 hammer
- * made it handle multiple -{N,n}'s. Also, made it treat re-directed stdin
- * the same as the terminal
- *
- * Revision 5.4 1990/09/20 02:38:51 eggert
- * ci -k now checks dates more thoroughly.
- *
- * Revision 5.3 1990/09/11 02:41:07 eggert
- * Fix revision bug with `ci -k file1 file2'.
- *
- * Revision 5.2 1990/09/04 08:02:10 eggert
- * Permit adjacent revisions with identical time stamps (possible on fast hosts).
- * Improve incomplete line handling. Standardize yes-or-no procedure.
- *
- * Revision 5.1 1990/08/29 07:13:44 eggert
- * Expand locker value like co. Clean old log messages too.
- *
- * Revision 5.0 1990/08/22 08:10:00 eggert
- * Don't require a final newline.
- * Make lock and temp files faster and safer.
- * Remove compile-time limits; use malloc instead.
- * Permit dates past 1999/12/31. Switch to GMT.
- * Add setuid support. Don't pass +args to diff. Check diff's output.
- * Ansify and Posixate. Add -k, -V. Remove snooping. Tune.
- * Check diff's output.
- *
- * Revision 4.9 89/05/01 15:10:54 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.8 88/11/08 13:38:23 narten
- * changes from root@seismo.CSS.GOV (Super User)
- * -d with no arguments uses the mod time of the file it is checking in
- *
- * Revision 4.7 88/08/09 19:12:07 eggert
- * Make sure workfile is a regular file; use its mode if RCSfile doesn't have one.
- * Use execv(), not system(); allow cc -R; remove lint.
- * isatty(fileno(stdin)) -> ttystdin()
- *
- * Revision 4.6 87/12/18 11:34:41 narten
- * lint cleanups (from Guy Harris)
- *
- * Revision 4.5 87/10/18 10:18:48 narten
- * Updating version numbers. Changes relative to revision 1.1 are actually
- * relative to 4.3
- *
- * Revision 1.3 87/09/24 13:57:19 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:21:33 jenkins
- * Port to suns
- *
- * Revision 4.3 83/12/15 12:28:54 wft
- * ci -u and ci -l now set mode of working file properly.
- *
- * Revision 4.2 83/12/05 13:40:54 wft
- * Merged with 3.9.1.1: added calls to clearerr(stdin).
- * made rewriteflag external.
- *
- * Revision 4.1 83/05/10 17:03:06 wft
- * Added option -d and -w, and updated assingment of date, etc. to new delta.
- * Added handling of default branches.
- * Option -k generates std. log message; fixed undef. pointer in reading of log.
- * Replaced getlock() with findlock(), link--unlink with rename(),
- * getpwuid() with getcaller().
- * Moved all revision number generation to new routine addelta().
- * Removed calls to stat(); now done by pairfilenames().
- * Changed most calls to catchints() with restoreints().
- * Directed all interactive messages to stderr.
- *
- * Revision 3.9.1.1 83/10/19 04:21:03 lepreau
- * Added clearerr(stdin) to getlogmsg() for re-reading stdin.
- *
- * Revision 3.9 83/02/15 15:25:44 wft
- * 4.2 prerelease
- *
- * Revision 3.9 83/02/15 15:25:44 wft
- * Added call to fastcopy() to copy remainder of RCS file.
- *
- * Revision 3.8 83/01/14 15:34:05 wft
- * Added ignoring of interrupts while new RCS file is renamed;
- * Avoids deletion of RCS files by interrupts.
- *
- * Revision 3.7 82/12/10 16:09:20 wft
- * Corrected checking of return code from diff.
- *
- * Revision 3.6 82/12/08 21:34:49 wft
- * Using DATEFORM to prepare date of checked-in revision;
- * Fixed return from addbranch().
- *
- * Revision 3.5 82/12/04 18:32:42 wft
- * Replaced getdelta() with gettree(), SNOOPDIR with SNOOPFILE. Updated
- * field lockedby in removelock(), moved getlogmsg() before calling diff.
- *
- * Revision 3.4 82/12/02 13:27:13 wft
- * added option -k.
- *
- * Revision 3.3 82/11/28 20:53:31 wft
- * Added mustcheckin() to check for redundant checkins.
- * Added xpandfile() to do keyword expansion for -u and -l;
- * -m appends linefeed to log message if necessary.
- * getlogmsg() suppresses prompt if stdin is not a terminal.
- * Replaced keeplock with lockflag, fclose() with ffclose(),
- * %02d with %.2d, getlogin() with getpwuid().
- *
- * Revision 3.2 82/10/18 20:57:23 wft
- * An RCS file inherits its mode during the first ci from the working file,
- * otherwise it stays the same, except that write permission is removed.
- * Fixed ci -l, added ci -u (both do an implicit co after the ci).
- * Fixed call to getlogin(), added call to getfullRCSname(), added check
- * for write error.
- * Changed conflicting identifiers.
- *
- * Revision 3.1 82/10/13 16:04:59 wft
- * fixed type of variables receiving from getc() (char -> int).
- * added include file dbm.h for getting BYTESIZ. This is used
- * to check the return code from diff portably.
- */
-
-#include "rcsbase.h"
-
-struct Symrev {
- char const *ssymbol;
- int override;
- struct Symrev * nextsym;
-};
-
-static char const *getcurdate P((void));
-static int addbranch P((struct hshentry*,struct buf*,int));
-static int addelta P((void));
-static int addsyms P((char const*));
-static int fixwork P((mode_t,time_t));
-static int removelock P((struct hshentry*));
-static int xpandfile P((RILE*,struct hshentry const*,char const**,int));
-static struct cbuf getlogmsg P((void));
-static void cleanup P((void));
-static void incnum P((char const*,struct buf*));
-static void addassoclst P((int,char const*));
-
-static FILE *exfile;
-static RILE *workptr; /* working file pointer */
-static struct buf newdelnum; /* new revision number */
-static struct cbuf msg;
-static int exitstatus;
-static int forceciflag; /* forces check in */
-static int keepflag, keepworkingfile, rcsinitflag;
-static struct hshentries *gendeltas; /* deltas to be generated */
-static struct hshentry *targetdelta; /* old delta to be generated */
-static struct hshentry newdelta; /* new delta to be inserted */
-static struct stat workstat;
-static struct Symrev *assoclst, **nextassoc;
-
-mainProg(ciId, "ci", "$Id$")
-{
- static char const cmdusage[] =
- "\nci usage: ci -{fIklMqru}[rev] -d[date] -mmsg -{nN}name -sstate -ttext -T -Vn -wwho -xsuff -zzone file ...";
- static char const default_state[] = DEFAULTSTATE;
-
- char altdate[datesize];
- char olddate[datesize];
- char newdatebuf[datesize + zonelenmax];
- char targetdatebuf[datesize + zonelenmax];
- char *a, **newargv, *textfile;
- char const *author, *krev, *rev, *state;
- char const *diffname, *expname;
- char const *newworkname;
- int initflag, mustread;
- int lockflag, lockthis, mtimeflag, removedlock, Ttimeflag;
- int r;
- int changedRCS, changework, dolog, newhead;
- int usestatdate; /* Use mod time of file for -d. */
- mode_t newworkmode; /* mode for working file */
- time_t mtime, wtime;
- struct hshentry *workdelta;
-
- setrid();
-
- author = rev = state = textfile = 0;
- initflag = lockflag = mustread = false;
- mtimeflag = false;
- Ttimeflag = false;
- altdate[0]= '\0'; /* empty alternate date for -d */
- usestatdate=false;
- suffixes = X_DEFAULT;
- nextassoc = &assoclst;
-
- argc = getRCSINIT(argc, argv, &newargv);
- argv = newargv;
- while (a = *++argv, 0<--argc && *a++=='-') {
- switch (*a++) {
-
- case 'r':
- if (*a)
- goto revno;
- keepworkingfile = lockflag = false;
- break;
-
- case 'l':
- keepworkingfile = lockflag = true;
- revno:
- if (*a) {
- if (rev) warn("redefinition of revision number");
- rev = a;
- }
- break;
-
- case 'u':
- keepworkingfile=true; lockflag=false;
- goto revno;
-
- case 'i':
- initflag = true;
- goto revno;
-
- case 'j':
- mustread = true;
- goto revno;
-
- case 'I':
- interactiveflag = true;
- goto revno;
-
- case 'q':
- quietflag=true;
- goto revno;
-
- case 'f':
- forceciflag=true;
- goto revno;
-
- case 'k':
- keepflag=true;
- goto revno;
-
- case 'm':
- if (msg.size) redefined('m');
- msg = cleanlogmsg(a, strlen(a));
- if (!msg.size)
- error("missing message for -m option");
- break;
-
- case 'n':
- if (!*a) {
- error("missing symbolic name after -n");
- break;
- }
- checkssym(a);
- addassoclst(false, a);
- break;
-
- case 'N':
- if (!*a) {
- error("missing symbolic name after -N");
- break;
- }
- checkssym(a);
- addassoclst(true, a);
- break;
-
- case 's':
- if (*a) {
- if (state) redefined('s');
- checksid(a);
- state = a;
- } else
- error("missing state for -s option");
- break;
-
- case 't':
- if (*a) {
- if (textfile) redefined('t');
- textfile = a;
- }
- break;
-
- case 'd':
- if (altdate[0] || usestatdate)
- redefined('d');
- altdate[0] = '\0';
- if (!(usestatdate = !*a))
- str2date(a, altdate);
- break;
-
- case 'M':
- mtimeflag = true;
- goto revno;
-
- case 'w':
- if (*a) {
- if (author) redefined('w');
- checksid(a);
- author = a;
- } else
- error("missing author for -w option");
- break;
-
- case 'x':
- suffixes = a;
- break;
-
- case 'V':
- setRCSversion(*argv);
- break;
-
- case 'z':
- zone_set(a);
- break;
-
- case 'T':
- if (!*a) {
- Ttimeflag = true;
- break;
- }
- /* fall into */
- default:
- error("unknown option: %s%s", *argv, cmdusage);
- };
- } /* end processing of options */
-
- /* Handle all pathnames. */
- if (nerror) cleanup();
- else if (argc < 1) faterror("no input file%s", cmdusage);
- else for (; 0 < argc; cleanup(), ++argv, --argc) {
- targetdelta = 0;
- ffree();
-
- switch (pairnames(argc, argv, rcswriteopen, mustread, false)) {
-
- case -1: /* New RCS file */
-# if has_setuid && has_getuid
- if (euid() != ruid()) {
- workerror("setuid initial checkin prohibited; use `rcs -i -a' first");
- continue;
- }
-# endif
- rcsinitflag = true;
- break;
-
- case 0: /* Error */
- continue;
-
- case 1: /* Normal checkin with prev . RCS file */
- if (initflag) {
- rcserror("already exists");
- continue;
- }
- rcsinitflag = !Head;
- }
-
- /*
- * RCSname contains the name of the RCS file, and
- * workname contains the name of the working file.
- * If the RCS file exists, finptr contains the file descriptor for the
- * RCS file, and RCSstat is set. The admin node is initialized.
- */
-
- diagnose("%s <-- %s\n", RCSname, workname);
-
- if (!(workptr = Iopen(workname, FOPEN_R_WORK, &workstat))) {
- eerror(workname);
- continue;
- }
-
- if (finptr) {
- if (same_file(RCSstat, workstat, 0)) {
- rcserror("RCS file is the same as working file %s.",
- workname
- );
- continue;
- }
- if (!checkaccesslist())
- continue;
- }
-
- krev = rev;
- if (keepflag) {
- /* get keyword values from working file */
- if (!getoldkeys(workptr)) continue;
- if (!rev && !*(krev = prevrev.string)) {
- workerror("can't find a revision number");
- continue;
- }
- if (!*prevdate.string && *altdate=='\0' && usestatdate==false)
- workwarn("can't find a date");
- if (!*prevauthor.string && !author)
- workwarn("can't find an author");
- if (!*prevstate.string && !state)
- workwarn("can't find a state");
- } /* end processing keepflag */
-
- /* Read the delta tree. */
- if (finptr)
- gettree();
-
- /* expand symbolic revision number */
- if (!fexpandsym(krev, &newdelnum, workptr))
- continue;
-
- /* splice new delta into tree */
- if ((removedlock = addelta()) < 0)
- continue;
-
- newdelta.num = newdelnum.string;
- newdelta.branches = 0;
- newdelta.lockedby = 0; /* This might be changed by addlock(). */
- newdelta.selector = true;
- newdelta.name = 0;
- clear_buf(&newdelta.ig);
- clear_buf(&newdelta.igtext);
- /* set author */
- if (author)
- newdelta.author=author; /* set author given by -w */
- else if (keepflag && *prevauthor.string)
- newdelta.author=prevauthor.string; /* preserve old author if possible*/
- else newdelta.author=getcaller();/* otherwise use caller's id */
- newdelta.state = default_state;
- if (state)
- newdelta.state=state; /* set state given by -s */
- else if (keepflag && *prevstate.string)
- newdelta.state=prevstate.string; /* preserve old state if possible */
- if (usestatdate) {
- time2date(workstat.st_mtime, altdate);
- }
- if (*altdate!='\0')
- newdelta.date=altdate; /* set date given by -d */
- else if (keepflag && *prevdate.string) {
- /* Preserve old date if possible. */
- str2date(prevdate.string, olddate);
- newdelta.date = olddate;
- } else
- newdelta.date = getcurdate(); /* use current date */
- /* now check validity of date -- needed because of -d and -k */
- if (targetdelta &&
- cmpdate(newdelta.date,targetdelta->date) < 0) {
- rcserror("Date %s precedes %s in revision %s.",
- date2str(newdelta.date, newdatebuf),
- date2str(targetdelta->date, targetdatebuf),
- targetdelta->num
- );
- continue;
- }
-
-
- if (lockflag && addlock(&newdelta, true) < 0) continue;
-
- if (keepflag && *prevname.string)
- if (addsymbol(newdelta.num, prevname.string, false) < 0)
- continue;
- if (!addsyms(newdelta.num))
- continue;
-
-
- putadmin();
- puttree(Head,frewrite);
- putdesc(false,textfile);
-
- changework = Expand < MIN_UNCHANGED_EXPAND;
- dolog = true;
- lockthis = lockflag;
- workdelta = &newdelta;
-
- /* build rest of file */
- if (rcsinitflag) {
- diagnose("initial revision: %s\n", newdelta.num);
- /* get logmessage */
- newdelta.log=getlogmsg();
- putdftext(&newdelta, workptr, frewrite, false);
- RCSstat.st_mode = workstat.st_mode;
- RCSstat.st_nlink = 0;
- changedRCS = true;
- } else {
- diffname = maketemp(0);
- newhead = Head == &newdelta;
- if (!newhead)
- foutptr = frewrite;
- expname = buildrevision(
- gendeltas, targetdelta, (FILE*)0, false
- );
- if (
- !forceciflag &&
- strcmp(newdelta.state, targetdelta->state) == 0 &&
- (changework = rcsfcmp(
- workptr, &workstat, expname, targetdelta
- )) <= 0
- ) {
- diagnose("file is unchanged; reverting to previous revision %s\n",
- targetdelta->num
- );
- if (removedlock < lockflag) {
- diagnose("previous revision was not locked; ignoring -l option\n");
- lockthis = 0;
- }
- dolog = false;
- if (! (changedRCS = lockflag<removedlock || assoclst))
- workdelta = targetdelta;
- else {
- /*
- * We have started to build the wrong new RCS file.
- * Start over from the beginning.
- */
- long hwm = ftell(frewrite);
- int bad_truncate;
- Orewind(frewrite);
-
- /*
- * Work around a common ftruncate() bug:
- * NFS won't let you truncate a file that you
- * currently lack permissions for, even if you
- * had permissions when you opened it.
- * Also, Posix 1003.1b-1993 sec 5.6.7.2 p 128 l 1022
- * says ftruncate might fail because it's not supported.
- */
-# if !has_ftruncate
-# undef ftruncate
-# define ftruncate(fd,length) (-1)
-# endif
- bad_truncate = ftruncate(fileno(frewrite), (off_t)0);
-
- Irewind(finptr);
- Lexinit();
- getadmin();
- gettree();
- if (!(workdelta = genrevs(
- targetdelta->num, (char*)0, (char*)0, (char*)0,
- &gendeltas
- )))
- continue;
- workdelta->log = targetdelta->log;
- if (newdelta.state != default_state)
- workdelta->state = newdelta.state;
- if (lockthis<removedlock && removelock(workdelta)<0)
- continue;
- if (!addsyms(workdelta->num))
- continue;
- if (dorewrite(true, true) != 0)
- continue;
- fastcopy(finptr, frewrite);
- if (bad_truncate)
- while (ftell(frewrite) < hwm)
- /* White out any earlier mistake with '\n's. */
- /* This is unlikely. */
- afputc('\n', frewrite);
- }
- } else {
- int wfd = Ifileno(workptr);
- struct stat checkworkstat;
- char const *diffv[6 + !!OPEN_O_BINARY], **diffp;
-# if large_memory && !maps_memory
- FILE *wfile = workptr->stream;
- long wfile_off;
-# endif
-# if !has_fflush_input && !(large_memory && maps_memory)
- off_t wfd_off;
-# endif
-
- diagnose("new revision: %s; previous revision: %s\n",
- newdelta.num, targetdelta->num
- );
- newdelta.log = getlogmsg();
-# if !large_memory
- Irewind(workptr);
-# if has_fflush_input
- if (fflush(workptr) != 0)
- Ierror();
-# endif
-# else
-# if !maps_memory
- if (
- (wfile_off = ftell(wfile)) == -1
- || fseek(wfile, 0L, SEEK_SET) != 0
-# if has_fflush_input
- || fflush(wfile) != 0
-# endif
- )
- Ierror();
-# endif
-# endif
-# if !has_fflush_input && !(large_memory && maps_memory)
- wfd_off = lseek(wfd, (off_t)0, SEEK_CUR);
- if (wfd_off == -1
- || (wfd_off != 0
- && lseek(wfd, (off_t)0, SEEK_SET) != 0))
- Ierror();
-# endif
- diffp = diffv;
- *++diffp = DIFF;
- *++diffp = DIFFFLAGS;
-# if OPEN_O_BINARY
- if (Expand == BINARY_EXPAND)
- *++diffp = "--binary";
-# endif
- *++diffp = newhead ? "-" : expname;
- *++diffp = newhead ? expname : "-";
- *++diffp = 0;
- switch (runv(wfd, diffname, diffv)) {
- case DIFF_FAILURE: case DIFF_SUCCESS: break;
- default: rcsfaterror("diff failed");
- }
-# if !has_fflush_input && !(large_memory && maps_memory)
- if (lseek(wfd, wfd_off, SEEK_CUR) == -1)
- Ierror();
-# endif
-# if large_memory && !maps_memory
- if (fseek(wfile, wfile_off, SEEK_SET) != 0)
- Ierror();
-# endif
- if (newhead) {
- Irewind(workptr);
- putdftext(&newdelta, workptr, frewrite, false);
- if (!putdtext(targetdelta,diffname,frewrite,true)) continue;
- } else
- if (!putdtext(&newdelta,diffname,frewrite,true)) continue;
-
- /*
- * Check whether the working file changed during checkin,
- * to avoid producing an inconsistent RCS file.
- */
- if (
- fstat(wfd, &checkworkstat) != 0
- || workstat.st_mtime != checkworkstat.st_mtime
- || workstat.st_size != checkworkstat.st_size
- ) {
- workerror("file changed during checkin");
- continue;
- }
-
- changedRCS = true;
- }
- }
-
- /* Deduce time_t of new revision if it is needed later. */
- wtime = (time_t)-1;
- if (mtimeflag | Ttimeflag)
- wtime = date2time(workdelta->date);
-
- if (donerewrite(changedRCS,
- !Ttimeflag ? (time_t)-1
- : finptr && wtime < RCSstat.st_mtime ? RCSstat.st_mtime
- : wtime
- ) != 0)
- continue;
-
- if (!keepworkingfile) {
- Izclose(&workptr);
- r = un_link(workname); /* Get rid of old file */
- } else {
- newworkmode = WORKMODE(RCSstat.st_mode,
- ! (Expand==VAL_EXPAND || lockthis < StrictLocks)
- );
- mtime = mtimeflag ? wtime : (time_t)-1;
-
- /* Expand if it might change or if we can't fix mode, time. */
- if (changework || (r=fixwork(newworkmode,mtime)) != 0) {
- Irewind(workptr);
- /* Expand keywords in file. */
- locker_expansion = lockthis;
- workdelta->name =
- namedrev(
- assoclst ? assoclst->ssymbol
- : keepflag && *prevname.string ? prevname.string
- : rev,
- workdelta
- );
- switch (xpandfile(
- workptr, workdelta, &newworkname, dolog
- )) {
- default:
- continue;
-
- case 0:
- /*
- * No expansion occurred; try to reuse working file
- * unless we already tried and failed.
- */
- if (changework)
- if ((r=fixwork(newworkmode,mtime)) == 0)
- break;
- /* fall into */
- case 1:
- Izclose(&workptr);
- aflush(exfile);
- ignoreints();
- r = chnamemod(&exfile, newworkname,
- workname, 1, newworkmode, mtime
- );
- keepdirtemp(newworkname);
- restoreints();
- }
- }
- }
- if (r != 0) {
- eerror(workname);
- continue;
- }
- diagnose("done\n");
-
- }
-
- tempunlink();
- exitmain(exitstatus);
-} /* end of main (ci) */
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = EXIT_FAILURE;
- Izclose(&finptr);
- Izclose(&workptr);
- Ozclose(&exfile);
- Ozclose(&fcopy);
- ORCSclose();
- dirtempunlink();
-}
-
-#if RCS_lint
-# define exiterr ciExit
-#endif
- void
-exiterr()
-{
- ORCSerror();
- dirtempunlink();
- tempunlink();
- _exit(EXIT_FAILURE);
-}
-
-/*****************************************************************/
-/* the rest are auxiliary routines */
-
-
- static int
-addelta()
-/* Function: Appends a delta to the delta tree, whose number is
- * given by newdelnum. Updates Head, newdelnum, newdelnumlength,
- * and the links in newdelta.
- * Return -1 on error, 1 if a lock is removed, 0 otherwise.
- */
-{
- register char *tp;
- register int i;
- int removedlock;
- int newdnumlength; /* actual length of new rev. num. */
-
- newdnumlength = countnumflds(newdelnum.string);
-
- if (rcsinitflag) {
- /* this covers non-existing RCS file and a file initialized with rcs -i */
- if (newdnumlength==0 && Dbranch) {
- bufscpy(&newdelnum, Dbranch);
- newdnumlength = countnumflds(Dbranch);
- }
- if (newdnumlength==0) bufscpy(&newdelnum, "1.1");
- else if (newdnumlength==1) bufscat(&newdelnum, ".1");
- else if (newdnumlength>2) {
- rcserror("Branch point doesn't exist for revision %s.",
- newdelnum.string
- );
- return -1;
- } /* newdnumlength == 2 is OK; */
- Head = &newdelta;
- newdelta.next = 0;
- return 0;
- }
- if (newdnumlength==0) {
- /* derive new revision number from locks */
- switch (findlock(true, &targetdelta)) {
-
- default:
- /* found two or more old locks */
- return -1;
-
- case 1:
- /* found an old lock */
- /* check whether locked revision exists */
- if (!genrevs(targetdelta->num,(char*)0,(char*)0,(char*)0,&gendeltas))
- return -1;
- if (targetdelta==Head) {
- /* make new head */
- newdelta.next=Head;
- Head= &newdelta;
- } else if (!targetdelta->next && countnumflds(targetdelta->num)>2) {
- /* new tip revision on side branch */
- targetdelta->next= &newdelta;
- newdelta.next = 0;
- } else {
- /* middle revision; start a new branch */
- bufscpy(&newdelnum, "");
- return addbranch(targetdelta, &newdelnum, 1);
- }
- incnum(targetdelta->num, &newdelnum);
- return 1; /* successful use of existing lock */
-
- case 0:
- /* no existing lock; try Dbranch */
- /* update newdelnum */
- if (StrictLocks || !myself(RCSstat.st_uid)) {
- rcserror("no lock set by %s", getcaller());
- return -1;
- }
- if (Dbranch) {
- bufscpy(&newdelnum, Dbranch);
- } else {
- incnum(Head->num, &newdelnum);
- }
- newdnumlength = countnumflds(newdelnum.string);
- /* now fall into next statement */
- }
- }
- if (newdnumlength<=2) {
- /* add new head per given number */
- if(newdnumlength==1) {
- /* make a two-field number out of it*/
- if (cmpnumfld(newdelnum.string,Head->num,1)==0)
- incnum(Head->num, &newdelnum);
- else
- bufscat(&newdelnum, ".1");
- }
- if (cmpnum(newdelnum.string,Head->num) <= 0) {
- rcserror("revision %s too low; must be higher than %s",
- newdelnum.string, Head->num
- );
- return -1;
- }
- targetdelta = Head;
- if (0 <= (removedlock = removelock(Head))) {
- if (!genrevs(Head->num,(char*)0,(char*)0,(char*)0,&gendeltas))
- return -1;
- newdelta.next = Head;
- Head = &newdelta;
- }
- return removedlock;
- } else {
- /* put new revision on side branch */
- /*first, get branch point */
- tp = newdelnum.string;
- for (i = newdnumlength - ((newdnumlength&1) ^ 1); --i; )
- while (*tp++ != '.')
- continue;
- *--tp = 0; /* Kill final dot to get old delta temporarily. */
- if (!(targetdelta=genrevs(newdelnum.string,(char*)0,(char*)0,(char*)0,&gendeltas)))
- return -1;
- if (cmpnum(targetdelta->num, newdelnum.string) != 0) {
- rcserror("can't find branch point %s", newdelnum.string);
- return -1;
- }
- *tp = '.'; /* Restore final dot. */
- return addbranch(targetdelta, &newdelnum, 0);
- }
-}
-
-
-
- static int
-addbranch(branchpoint, num, removedlock)
- struct hshentry *branchpoint;
- struct buf *num;
- int removedlock;
-/* adds a new branch and branch delta at branchpoint.
- * If num is the null string, appends the new branch, incrementing
- * the highest branch number (initially 1), and setting the level number to 1.
- * the new delta and branchhead are in globals newdelta and newbranch, resp.
- * the new number is placed into num.
- * Return -1 on error, 1 if a lock is removed, 0 otherwise.
- * If REMOVEDLOCK is 1, a lock was already removed.
- */
-{
- struct branchhead *bhead, **btrail;
- struct buf branchnum;
- int result;
- int field, numlength;
- static struct branchhead newbranch; /* new branch to be inserted */
-
- numlength = countnumflds(num->string);
-
- if (!branchpoint->branches) {
- /* start first branch */
- branchpoint->branches = &newbranch;
- if (numlength==0) {
- bufscpy(num, branchpoint->num);
- bufscat(num, ".1.1");
- } else if (numlength&1)
- bufscat(num, ".1");
- newbranch.nextbranch = 0;
-
- } else if (numlength==0) {
- /* append new branch to the end */
- bhead=branchpoint->branches;
- while (bhead->nextbranch) bhead=bhead->nextbranch;
- bhead->nextbranch = &newbranch;
- bufautobegin(&branchnum);
- getbranchno(bhead->hsh->num, &branchnum);
- incnum(branchnum.string, num);
- bufautoend(&branchnum);
- bufscat(num, ".1");
- newbranch.nextbranch = 0;
- } else {
- /* place the branch properly */
- field = numlength - ((numlength&1) ^ 1);
- /* field of branch number */
- btrail = &branchpoint->branches;
- while (0 < (result=cmpnumfld(num->string,(*btrail)->hsh->num,field))) {
- btrail = &(*btrail)->nextbranch;
- if (!*btrail) {
- result = -1;
- break;
- }
- }
- if (result < 0) {
- /* insert/append new branchhead */
- newbranch.nextbranch = *btrail;
- *btrail = &newbranch;
- if (numlength&1) bufscat(num, ".1");
- } else {
- /* branch exists; append to end */
- bufautobegin(&branchnum);
- getbranchno(num->string, &branchnum);
- targetdelta = genrevs(
- branchnum.string, (char*)0, (char*)0, (char*)0,
- &gendeltas
- );
- bufautoend(&branchnum);
- if (!targetdelta)
- return -1;
- if (cmpnum(num->string,targetdelta->num) <= 0) {
- rcserror("revision %s too low; must be higher than %s",
- num->string, targetdelta->num
- );
- return -1;
- }
- if (!removedlock
- && 0 <= (removedlock = removelock(targetdelta))
- ) {
- if (numlength&1)
- incnum(targetdelta->num,num);
- targetdelta->next = &newdelta;
- newdelta.next = 0;
- }
- return removedlock;
- /* Don't do anything to newbranch. */
- }
- }
- newbranch.hsh = &newdelta;
- newdelta.next = 0;
- if (branchpoint->lockedby)
- if (strcmp(branchpoint->lockedby, getcaller()) == 0)
- return removelock(branchpoint); /* This returns 1. */
- return removedlock;
-}
-
- static int
-addsyms(num)
- char const *num;
-{
- register struct Symrev *p;
-
- for (p = assoclst; p; p = p->nextsym)
- if (addsymbol(num, p->ssymbol, p->override) < 0)
- return false;
- return true;
-}
-
-
- static void
-incnum(onum,nnum)
- char const *onum;
- struct buf *nnum;
-/* Increment the last field of revision number onum by one and
- * place the result into nnum.
- */
-{
- register char *tp, *np;
- register size_t l;
-
- l = strlen(onum);
- bufalloc(nnum, l+2);
- np = tp = nnum->string;
- VOID strcpy(np, onum);
- for (tp = np + l; np != tp; )
- if (isdigit(*--tp)) {
- if (*tp != '9') {
- ++*tp;
- return;
- }
- *tp = '0';
- } else {
- tp++;
- break;
- }
- /* We changed 999 to 000; now change it to 1000. */
- *tp = '1';
- tp = np + l;
- *tp++ = '0';
- *tp = 0;
-}
-
-
-
- static int
-removelock(delta)
-struct hshentry * delta;
-/* function: Finds the lock held by caller on delta,
- * removes it, and returns nonzero if successful.
- * Print an error message and return -1 if there is no such lock.
- * An exception is if !StrictLocks, and caller is the owner of
- * the RCS file. If caller does not have a lock in this case,
- * return 0; return 1 if a lock is actually removed.
- */
-{
- register struct rcslock *next, **trail;
- char const *num;
-
- num=delta->num;
- for (trail = &Locks; (next = *trail); trail = &next->nextlock)
- if (next->delta == delta)
- if (strcmp(getcaller(), next->login) == 0) {
- /* We found a lock on delta by caller; delete it. */
- *trail = next->nextlock;
- delta->lockedby = 0;
- return 1;
- } else {
- rcserror("revision %s locked by %s", num, next->login);
- return -1;
- }
- if (!StrictLocks && myself(RCSstat.st_uid))
- return 0;
- rcserror("no lock set by %s for revision %s", getcaller(), num);
- return -1;
-}
-
-
-
- static char const *
-getcurdate()
-/* Return a pointer to the current date. */
-{
- static char buffer[datesize]; /* date buffer */
-
- if (!buffer[0])
- time2date(now(), buffer);
- return buffer;
-}
-
- static int
-#if has_prototypes
-fixwork(mode_t newworkmode, time_t mtime)
- /* The `#if has_prototypes' is needed because mode_t might promote to int. */
-#else
- fixwork(newworkmode, mtime)
- mode_t newworkmode;
- time_t mtime;
-#endif
-{
- return
- 1 < workstat.st_nlink
- || (newworkmode&S_IWUSR && !myself(workstat.st_uid))
- || setmtime(workname, mtime) != 0
- ? -1
- : workstat.st_mode == newworkmode ? 0
-#if has_fchmod
- : fchmod(Ifileno(workptr), newworkmode) == 0 ? 0
-#endif
-#if bad_chmod_close
- : -1
-#else
- : chmod(workname, newworkmode)
-#endif
- ;
-}
-
- static int
-xpandfile(unexfile, delta, exname, dolog)
- RILE *unexfile;
- struct hshentry const *delta;
- char const **exname;
- int dolog;
-/*
- * Read unexfile and copy it to a
- * file, performing keyword substitution with data from delta.
- * Return -1 if unsuccessful, 1 if expansion occurred, 0 otherwise.
- * If successful, stores the stream descriptor into *EXFILEP
- * and its name into *EXNAME.
- */
-{
- char const *targetname;
- int e, r;
-
- targetname = makedirtemp(1);
- if (!(exfile = fopenSafer(targetname, FOPEN_W_WORK))) {
- eerror(targetname);
- workerror("can't build working file");
- return -1;
- }
- r = 0;
- if (MIN_UNEXPAND <= Expand)
- fastcopy(unexfile,exfile);
- else {
- for (;;) {
- e = expandline(
- unexfile, exfile, delta, false, (FILE*)0, dolog
- );
- if (e < 0)
- break;
- r |= e;
- if (e <= 1)
- break;
- }
- }
- *exname = targetname;
- return r & 1;
-}
-
-
-
-
-/* --------------------- G E T L O G M S G --------------------------------*/
-
-
- static struct cbuf
-getlogmsg()
-/* Obtain and yield a log message.
- * If a log message is given with -m, yield that message.
- * If this is the initial revision, yield a standard log message.
- * Otherwise, reads a character string from the terminal.
- * Stops after reading EOF or a single '.' on a
- * line. getlogmsg prompts the first time it is called for the
- * log message; during all later calls it asks whether the previous
- * log message can be reused.
- */
-{
- static char const
- emptych[] = EMPTYLOG,
- initialch[] = "Initial revision";
- static struct cbuf const
- emptylog = { emptych, sizeof(emptych)-sizeof(char) },
- initiallog = { initialch, sizeof(initialch)-sizeof(char) };
- static struct buf logbuf;
- static struct cbuf logmsg;
-
- register char *tp;
- register size_t i;
- char const *caller;
-
- if (msg.size) return msg;
-
- if (keepflag) {
- /* generate std. log message */
- caller = getcaller();
- i = sizeof(ciklog)+strlen(caller)+3;
- bufalloc(&logbuf, i + datesize + zonelenmax);
- tp = logbuf.string;
- VOID sprintf(tp, "%s%s at ", ciklog, caller);
- VOID date2str(getcurdate(), tp+i);
- logmsg.string = tp;
- logmsg.size = strlen(tp);
- return logmsg;
- }
-
- if (!targetdelta && (
- cmpnum(newdelnum.string,"1.1")==0 ||
- cmpnum(newdelnum.string,"1.0")==0
- ))
- return initiallog;
-
- if (logmsg.size) {
- /*previous log available*/
- if (yesorno(true, "reuse log message of previous file? [yn](y): "))
- return logmsg;
- }
-
- /* now read string from stdin */
- logmsg = getsstdin("m", "log message", "", &logbuf);
-
- /* now check whether the log message is not empty */
- if (logmsg.size)
- return logmsg;
- return emptylog;
-}
-
-/* Make a linked list of Symbolic names */
-
- static void
-addassoclst(flag, sp)
- int flag;
- char const *sp;
-{
- struct Symrev *pt;
-
- pt = talloc(struct Symrev);
- pt->ssymbol = sp;
- pt->override = flag;
- pt->nextsym = 0;
- *nextassoc = pt;
- nextassoc = &pt->nextsym;
-}
diff --git a/gnu/usr.bin/rcs/co/Makefile b/gnu/usr.bin/rcs/co/Makefile
deleted file mode 100644
index 0c73865..0000000
--- a/gnu/usr.bin/rcs/co/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG= co
-SRCS= co.c
-CFLAGS+= -I${.CURDIR}/../lib
-LDADD= ${LIBRCS}
-DPADD= ${LIBRCS}
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/rcs/co/co.1 b/gnu/usr.bin/rcs/co/co.1
deleted file mode 100644
index 5bc62a4..0000000
--- a/gnu/usr.bin/rcs/co/co.1
+++ /dev/null
@@ -1,736 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id$
-.ds i \&\s-1ISO\s0
-.ds r \&\s-1RCS\s0
-.ds u \&\s-1UTC\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.TH CO 1 \*(Dt GNU
-.SH NAME
-co \- check out RCS revisions
-.SH SYNOPSIS
-.B co
-.RI [ options ] " file " .\|.\|.
-.SH DESCRIPTION
-.B co
-retrieves a revision from each \*r file and stores it into
-the corresponding working file.
-.PP
-Pathnames matching an \*r suffix denote \*r files;
-all others denote working files.
-Names are paired as explained in
-.BR ci (1).
-.PP
-Revisions of an \*r file can be checked out locked or unlocked. Locking a
-revision prevents overlapping updates. A revision checked out for reading or
-processing (e.g., compiling) need not be locked. A revision checked out
-for editing and later checkin must normally be locked. Checkout with locking
-fails if the revision to be checked out is currently locked by another user.
-(A lock can be broken with
-.BR rcs "(1).)\ \&"
-Checkout with locking also requires the caller to be on the access list of
-the \*r file, unless he is the owner of the
-file or the superuser, or the access list is empty.
-Checkout without locking is not subject to accesslist restrictions, and is
-not affected by the presence of locks.
-.PP
-A revision is selected by options for revision or branch number,
-checkin date/time, author, or state.
-When the selection options
-are applied in combination,
-.B co
-retrieves the latest revision
-that satisfies all of them.
-If none of the selection options
-is specified,
-.B co
-retrieves the latest revision
-on the default branch (normally the trunk, see the
-.B \-b
-option of
-.BR rcs (1)).
-A revision or branch number can be attached
-to any of the options
-.BR \-f ,
-.BR \-I ,
-.BR \-l ,
-.BR \-M ,
-.BR \-p ,
-.BR \-q ,
-.BR \-r ,
-or
-.BR \-u .
-The options
-.B \-d
-(date),
-.B \-s
-(state), and
-.B \-w
-(author)
-retrieve from a single branch, the
-.I selected
-branch,
-which is either specified by one of
-.BR \-f ,
-\&.\|.\|.,
-.BR \-u ,
-or the default branch.
-.PP
-A
-.B co
-command applied to an \*r
-file with no revisions creates a zero-length working file.
-.B co
-always performs keyword substitution (see below).
-.SH OPTIONS
-.TP
-.BR \-r [\f2rev\fP]
-retrieves the latest revision whose number is less than or equal to
-.IR rev .
-If
-.I rev
-indicates a branch rather than a revision,
-the latest revision on that branch is retrieved.
-If
-.I rev
-is omitted, the latest revision on the default branch
-(see the
-.B \-b
-option of
-.BR rcs (1))
-is retrieved.
-If
-.I rev
-is
-.BR $ ,
-.B co
-determines the revision number from keyword values in the working file.
-Otherwise, a revision is composed of one or more numeric or symbolic fields
-separated by periods.
-If
-.I rev
-begins with a period,
-then the default branch (normally the trunk) is prepended to it.
-If
-.I rev
-is a branch number followed by a period,
-then the latest revision on that branch is used.
-The numeric equivalent of a symbolic field
-is specified with the
-.B \-n
-option of the commands
-.BR ci (1)
-and
-.BR rcs (1).
-.TP
-.BR \-l [\f2rev\fP]
-same as
-.BR \-r ,
-except that it also locks the retrieved revision for
-the caller.
-.TP
-.BR \-u [\f2rev\fP]
-same as
-.BR \-r ,
-except that it unlocks the retrieved revision if it was
-locked by the caller. If
-.I rev
-is omitted,
-.B \-u
-retrieves the revision locked by the caller, if there is one; otherwise,
-it retrieves the latest revision on the default branch.
-.TP
-.BR \-f [\f2rev\fP]
-forces the overwriting of the working file;
-useful in connection with
-.BR \-q .
-See also
-.SM "FILE MODES"
-below.
-.TP
-.B \-kkv
-Generate keyword strings using the default form, e.g.\&
-.B "$\&Revision: \*(Rv $"
-for the
-.B Revision
-keyword.
-A locker's name is inserted in the value of the
-.BR Header ,
-.BR Id ,
-and
-.B Locker
-keyword strings
-only as a file is being locked,
-i.e. by
-.B "ci\ \-l"
-and
-.BR "co\ \-l".
-This is the default.
-.TP
-.B \-kkvl
-Like
-.BR \-kkv ,
-except that a locker's name is always inserted
-if the given revision is currently locked.
-.TP
-.B \-kk
-Generate only keyword names in keyword strings; omit their values.
-See
-.SM "KEYWORD SUBSTITUTION"
-below.
-For example, for the
-.B Revision
-keyword, generate the string
-.B $\&Revision$
-instead of
-.BR "$\&Revision: \*(Rv $" .
-This option is useful to ignore differences due to keyword substitution
-when comparing different revisions of a file.
-Log messages are inserted after
-.B $\&Log$
-keywords even if
-.B \-kk
-is specified,
-since this tends to be more useful when merging changes.
-.TP
-.B \-ko
-Generate the old keyword string,
-present in the working file just before it was checked in.
-For example, for the
-.B Revision
-keyword, generate the string
-.B "$\&Revision: 1.1 $"
-instead of
-.B "$\&Revision: \*(Rv $"
-if that is how the string appeared when the file was checked in.
-This can be useful for file formats
-that cannot tolerate any changes to substrings
-that happen to take the form of keyword strings.
-.TP
-.B \-kb
-Generate a binary image of the old keyword string.
-This acts like
-.BR \-ko ,
-except it performs all working file input and output in binary mode.
-This makes little difference on Posix and Unix hosts,
-but on DOS-like hosts one should use
-.B "rcs\ \-i\ \-kb"
-to initialize an \*r file intended to be used for binary files.
-Also, on all hosts,
-.BR rcsmerge (1)
-normally refuses to merge files when
-.B \-kb
-is in effect.
-.TP
-.B \-kv
-Generate only keyword values for keyword strings.
-For example, for the
-.B Revision
-keyword, generate the string
-.B \*(Rv
-instead of
-.BR "$\&Revision: \*(Rv $" .
-This can help generate files in programming languages where it is hard to
-strip keyword delimiters like
-.B "$\&Revision:\ $"
-from a string.
-However, further keyword substitution cannot be performed once the
-keyword names are removed, so this option should be used with care.
-Because of this danger of losing keywords,
-this option cannot be combined with
-.BR \-l ,
-and the owner write permission of the working file is turned off;
-to edit the file later, check it out again without
-.BR \-kv .
-.TP
-.BR \-p [\f2rev\fP]
-prints the retrieved revision on the standard output rather than storing it
-in the working file.
-This option is useful when
-.B co
-is part of a pipe.
-.TP
-.BR \-q [\f2rev\fP]
-quiet mode; diagnostics are not printed.
-.TP
-.BR \-I [\f2rev\fP]
-interactive mode;
-the user is prompted and questioned
-even if the standard input is not a terminal.
-.TP
-.BI \-d date
-retrieves the latest revision on the selected branch whose checkin date/time is
-less than or equal to
-.IR date .
-The date and time can be given in free format.
-The time zone
-.B LT
-stands for local time;
-other common time zone names are understood.
-For example, the following
-.IR date s
-are equivalent
-if local time is January 11, 1990, 8pm Pacific Standard Time,
-eight hours west of Coordinated Universal Time (\*u):
-.RS
-.LP
-.RS
-.nf
-.ta \w'\f3Thu, 11 Jan 1990 20:00:00 \-0800\fP 'u
-.ne 10
-\f38:00 pm lt\fP
-\f34:00 AM, Jan. 12, 1990\fP default is \*u
-\f31990-01-12 04:00:00+00\fP \*i 8601 (\*u)
-\f31990-01-11 20:00:00\-08\fP \*i 8601 (local time)
-\f31990/01/12 04:00:00\fP traditional \*r format
-\f3Thu Jan 11 20:00:00 1990 LT\fP output of \f3ctime\fP(3) + \f3LT\fP
-\f3Thu Jan 11 20:00:00 PST 1990\fP output of \f3date\fP(1)
-\f3Fri Jan 12 04:00:00 GMT 1990\fP
-\f3Thu, 11 Jan 1990 20:00:00 \-0800\fP Internet RFC 822
-\f312-January-1990, 04:00 WET\fP
-.ta 4n +4n +4n +4n
-.fi
-.RE
-.LP
-Most fields in the date and time can be defaulted.
-The default time zone is normally \*u, but this can be overridden by the
-.B \-z
-option.
-The other defaults are determined in the order year, month, day,
-hour, minute, and second (most to least significant). At least one of these
-fields must be provided. For omitted fields that are of higher significance
-than the highest provided field, the time zone's current values are assumed.
-For all other omitted fields,
-the lowest possible values are assumed.
-For example, without
-.BR \-z ,
-the date
-.B "20, 10:30"
-defaults to
-10:30:00 \*u of the 20th of the \*u time zone's current month and year.
-The date/time must be quoted if it contains spaces.
-.RE
-.TP
-.BR \-M [\f2rev\fP]
-Set the modification time on the new working file
-to be the date of the retrieved revision.
-Use this option with care; it can confuse
-.BR make (1).
-.TP
-.BI \-s state
-retrieves the latest revision on the selected branch whose state is set to
-.IR state .
-.TP
-.B \-T
-Preserve the modification time on the \*r file
-even if the \*r file changes because a lock is added or removed.
-This option can suppress extensive recompilation caused by a
-.BR make (1)
-dependency of some other copy of the working file on the \*r file.
-Use this option with care; it can suppress recompilation even when it is needed,
-i.e. when the change of lock
-would mean a change to keyword strings in the other working file.
-.TP
-.BR \-w [\f2login\fP]
-retrieves the latest revision on the selected branch which was checked in
-by the user with login name
-.IR login .
-If the argument
-.I login
-is
-omitted, the caller's login is assumed.
-.TP
-.BI \-j joinlist
-generates a new revision which is the join of the revisions on
-.IR joinlist .
-This option is largely obsoleted by
-.BR rcsmerge (1)
-but is retained for backwards compatibility.
-.RS
-.PP
-The
-.I joinlist
-is a comma-separated list of pairs of the form
-.IB rev2 : rev3,
-where
-.I rev2
-and
-.I rev3
-are (symbolic or numeric)
-revision numbers.
-For the initial such pair,
-.I rev1
-denotes the revision selected
-by the above options
-.BR \-f ,
-\&.\|.\|.,
-.BR \-w .
-For all other pairs,
-.I rev1
-denotes the revision generated by the previous pair.
-(Thus, the output
-of one join becomes the input to the next.)
-.PP
-For each pair,
-.B co
-joins revisions
-.I rev1
-and
-.I rev3
-with respect to
-.IR rev2 .
-This means that all changes that transform
-.I rev2
-into
-.I rev1
-are applied to a copy of
-.IR rev3 .
-This is particularly useful if
-.I rev1
-and
-.I rev3
-are the ends of two branches that have
-.I rev2
-as a common ancestor. If
-.IR rev1 < rev2 < rev3
-on the same branch,
-joining generates a new revision which is like
-.I rev3,
-but with all changes that lead from
-.I rev1
-to
-.I rev2
-undone.
-If changes from
-.I rev2
-to
-.I rev1
-overlap with changes from
-.I rev2
-to
-.I rev3,
-.B co
-reports overlaps as described in
-.BR merge (1).
-.PP
-For the initial pair,
-.I rev2
-can be omitted. The default is the common
-ancestor.
-If any of the arguments indicate branches, the latest revisions
-on those branches are assumed.
-The options
-.B \-l
-and
-.B \-u
-lock or unlock
-.IR rev1 .
-.RE
-.TP
-.BI \-V
-Print \*r's version number.
-.TP
-.BI \-V n
-Emulate \*r version
-.I n,
-where
-.I n
-can be
-.BR 3 ,
-.BR 4 ,
-or
-.BR 5 .
-This can be useful when interchanging \*r files with others who are
-running older versions of \*r.
-To see which version of \*r your correspondents are running, have them invoke
-.BR "rcs \-V" ;
-this works with newer versions of \*r.
-If it doesn't work, have them invoke
-.B rlog
-on an \*r file;
-if none of the first few lines of output contain the string
-.B branch:
-it is version 3;
-if the dates' years have just two digits, it is version 4;
-otherwise, it is version 5.
-An \*r file generated while emulating version 3 loses its default branch.
-An \*r revision generated while emulating version 4 or earlier has
-a time stamp that is off by up to 13 hours.
-A revision extracted while emulating version 4 or earlier contains
-abbreviated dates of the form
-.IB yy / mm / dd
-and can also contain different white space and line prefixes
-in the substitution for
-.BR $\&Log$ .
-.TP
-.BI \-x "suffixes"
-Use
-.I suffixes
-to characterize \*r files.
-See
-.BR ci (1)
-for details.
-.TP
-.BI \-z zone
-specifies the date output format in keyword substitution,
-and specifies the default time zone for
-.I date
-in the
-.BI \-d date
-option.
-The
-.I zone
-should be empty, a numeric \*u offset, or the special string
-.B LT
-for local time.
-The default is an empty
-.IR zone ,
-which uses the traditional \*r format of \*u without any time zone indication
-and with slashes separating the parts of the date;
-otherwise, times are output in \*i 8601 format with time zone indication.
-For example, if local time is January 11, 1990, 8pm Pacific Standard Time,
-eight hours west of \*u,
-then the time is output as follows:
-.RS
-.LP
-.RS
-.nf
-.ta \w'\f3\-z+05:30\fP 'u +\w'\f31990-01-11 09:30:00+05:30\fP 'u
-.ne 4
-\f2option\fP \f2time output\fP
-\f3\-z\fP \f31990/01/12 04:00:00\fP \f2(default)\fP
-\f3\-zLT\fP \f31990-01-11 20:00:00\-08\fP
-\f3\-z+05:30\fP \f31990-01-12 09:30:00+05:30\fP
-.ta 4n +4n +4n +4n
-.fi
-.RE
-.LP
-The
-.B \-z
-option does not affect dates stored in \*r files,
-which are always \*u.
-.RE
-.SH "KEYWORD SUBSTITUTION"
-Strings of the form
-.BI $ keyword $
-and
-.BI $ keyword : .\|.\|. $
-embedded in
-the text are replaced
-with strings of the form
-.BI $ keyword : value $
-where
-.I keyword
-and
-.I value
-are pairs listed below.
-Keywords can be embedded in literal strings
-or comments to identify a revision.
-.PP
-Initially, the user enters strings of the form
-.BI $ keyword $ .
-On checkout,
-.B co
-replaces these strings with strings of the form
-.BI $ keyword : value $ .
-If a revision containing strings of the latter form
-is checked back in, the value fields will be replaced during the next
-checkout.
-Thus, the keyword values are automatically updated on checkout.
-This automatic substitution can be modified by the
-.B \-k
-options.
-.PP
-Keywords and their corresponding values:
-.TP
-.B $\&Author$
-The login name of the user who checked in the revision.
-.TP
-.B $\&Date$
-The date and time the revision was checked in.
-With
-.BI \-z zone
-a numeric time zone offset is appended; otherwise, the date is \*u.
-.TP
-.B $\&Header$
-A standard header containing the full pathname of the \*r file, the
-revision number, the date and time, the author, the state,
-and the locker (if locked).
-With
-.BI \-z zone
-a numeric time zone offset is appended to the date; otherwise, the date is \*u.
-.TP
-.B $\&Id$
-Same as
-.BR $\&Header$ ,
-except that the \*r filename is without a path.
-.TP
-.B $\&Locker$
-The login name of the user who locked the revision (empty if not locked).
-.TP
-.B $\&Log$
-The log message supplied during checkin, preceded by a header
-containing the \*r filename, the revision number, the author, and the date
-and time.
-With
-.BI \-z zone
-a numeric time zone offset is appended; otherwise, the date is \*u.
-Existing log messages are
-.I not
-replaced.
-Instead, the new log message is inserted after
-.BR $\&Log: .\|.\|. $ .
-This is useful for
-accumulating a complete change log in a source file.
-.RS
-.LP
-Each inserted line is prefixed by the string that prefixes the
-.B $\&Log$
-line. For example, if the
-.B $\&Log$
-line is
-.RB \*(lq "//\ $\&Log: tan.cc\ $" \*(rq,
-\*r prefixes each line of the log with
-.RB \*(lq "//\ " \*(rq.
-This is useful for languages with comments that go to the end of the line.
-The convention for other languages is to use a
-.RB \*(lq " \(** " \(rq
-prefix inside a multiline comment.
-For example, the initial log comment of a C program
-conventionally is of the following form:
-.RS
-.LP
-.nf
-.ft 3
-.ne 3
-/\(**
-.in +\w'/'u
-\(** $\&Log$
-\(**/
-.in
-.ft
-.fi
-.RE
-.LP
-For backwards compatibility with older versions of \*r, if the log prefix is
-.B /\(**
-or
-.B (\(**
-surrounded by optional white space, inserted log lines contain a space
-instead of
-.B /
-or
-.BR ( ;
-however, this usage is obsolescent and should not be relied on.
-.RE
-.TP
-.B $\&Name$
-The symbolic name used to check out the revision, if any.
-For example,
-.B "co\ \-rJoe"
-generates
-.BR "$\&Name:\ Joe\ $" .
-Plain
-.B co
-generates just
-.BR "$\&Name:\ \ $" .
-.TP
-.B $\&RCSfile$
-The name of the \*r file without a path.
-.TP
-.B $\&Revision$
-The revision number assigned to the revision.
-.TP
-.B $\&Source$
-The full pathname of the \*r file.
-.TP
-.B $\&State$
-The state assigned to the revision with the
-.B \-s
-option of
-.BR rcs (1)
-or
-.BR ci (1).
-.PP
-The following characters in keyword values are represented by escape sequences
-to keep keyword strings well-formed.
-.LP
-.RS
-.nf
-.ne 6
-.ta \w'newline 'u
-\f2char escape sequence\fP
-tab \f3\et\fP
-newline \f3\en\fP
-space \f3\e040
-$ \e044
-\e \e\e\fP
-.fi
-.RE
-.SH "FILE MODES"
-The working file inherits the read and execute permissions from the \*r
-file. In addition, the owner write permission is turned on, unless
-.B \-kv
-is set or the file
-is checked out unlocked and locking is set to strict (see
-.BR rcs (1)).
-.PP
-If a file with the name of the working file exists already and has write
-permission,
-.B co
-aborts the checkout,
-asking beforehand if possible.
-If the existing working file is
-not writable or
-.B \-f
-is given, the working file is deleted without asking.
-.SH FILES
-.B co
-accesses files much as
-.BR ci (1)
-does, except that it does not need to read the working file
-unless a revision number of
-.B $
-is specified.
-.SH ENVIRONMENT
-.TP
-.B \s-1RCSINIT\s0
-options prepended to the argument list, separated by spaces.
-See
-.BR ci (1)
-for details.
-.SH DIAGNOSTICS
-The \*r pathname, the working pathname,
-and the revision number retrieved are
-written to the diagnostic output.
-The exit status is zero if and only if all operations were successful.
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert.
-.SH "SEE ALSO"
-rcsintro(1), ci(1), ctime(3), date(1), ident(1), make(1),
-rcs(1), rcsclean(1), rcsdiff(1), rcsmerge(1), rlog(1),
-rcsfile(5)
-.br
-Walter F. Tichy,
-\*r\*-A System for Version Control,
-.I "Software\*-Practice & Experience"
-.BR 15 ,
-7 (July 1985), 637-654.
-.SH LIMITS
-Links to the \*r and working files are not preserved.
-.PP
-There is no way to selectively suppress the expansion of keywords, except
-by writing them differently. In nroff and troff, this is done by embedding the
-null-character
-.B \e&
-into the keyword.
-.br
diff --git a/gnu/usr.bin/rcs/co/co.c b/gnu/usr.bin/rcs/co/co.c
deleted file mode 100644
index 4165df2..0000000
--- a/gnu/usr.bin/rcs/co/co.c
+++ /dev/null
@@ -1,826 +0,0 @@
-/* Check out working files from revisions of RCS files. */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.18 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.17 1995/06/01 16:23:43 eggert
- * (main, preparejoin): Pass argument instead of using `join' static variable.
- * (main): Add -kb.
- *
- * Revision 5.16 1994/03/17 14:05:48 eggert
- * Move buffer-flushes out of critical sections, since they aren't critical.
- * Use ORCSerror to clean up after a fatal error. Remove lint.
- * Specify subprocess input via file descriptor, not file name.
- *
- * Revision 5.15 1993/11/09 17:40:15 eggert
- * -V now prints version on stdout and exits. Don't print usage twice.
- *
- * Revision 5.14 1993/11/03 17:42:27 eggert
- * Add -z. Generate a value for the Name keyword.
- * Don't arbitrarily limit the number of joins.
- * Improve quality of diagnostics.
- *
- * Revision 5.13 1992/07/28 16:12:44 eggert
- * Add -V. Check that working and RCS files are distinct.
- *
- * Revision 5.12 1992/02/17 23:02:08 eggert
- * Add -T.
- *
- * Revision 5.11 1992/01/24 18:44:19 eggert
- * Add support for bad_creat0. lint -> RCS_lint
- *
- * Revision 5.10 1992/01/06 02:42:34 eggert
- * Update usage string.
- *
- * Revision 5.9 1991/10/07 17:32:46 eggert
- * -k affects just working file, not RCS file.
- *
- * Revision 5.8 1991/08/19 03:13:55 eggert
- * Warn before removing somebody else's file.
- * Add -M. Fix co -j bugs. Tune.
- *
- * Revision 5.7 1991/04/21 11:58:15 eggert
- * Ensure that working file is newer than RCS file after co -[lu].
- * Add -x, RCSINIT, MS-DOS support.
- *
- * Revision 5.6 1990/12/04 05:18:38 eggert
- * Don't checkaccesslist() unless necessary.
- * Use -I for prompts and -q for diagnostics.
- *
- * Revision 5.5 1990/11/01 05:03:26 eggert
- * Fix -j. Add -I.
- *
- * Revision 5.4 1990/10/04 06:30:11 eggert
- * Accumulate exit status across files.
- *
- * Revision 5.3 1990/09/11 02:41:09 eggert
- * co -kv yields a readonly working file.
- *
- * Revision 5.2 1990/09/04 08:02:13 eggert
- * Standardize yes-or-no procedure.
- *
- * Revision 5.0 1990/08/22 08:10:02 eggert
- * Permit multiple locks by same user. Add setuid support.
- * Remove compile-time limits; use malloc instead.
- * Permit dates past 1999/12/31. Switch to GMT.
- * Make lock and temp files faster and safer.
- * Ansify and Posixate. Add -k, -V. Remove snooping. Tune.
- *
- * Revision 4.7 89/05/01 15:11:41 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.6 88/08/09 19:12:15 eggert
- * Fix "co -d" core dump; rawdate wasn't always initialized.
- * Use execv(), not system(); fix putchar('\0') and diagnose() botches; remove lint
- *
- * Revision 4.5 87/12/18 11:35:40 narten
- * lint cleanups (from Guy Harris)
- *
- * Revision 4.4 87/10/18 10:20:53 narten
- * Updating version numbers changes relative to 1.1, are actually
- * relative to 4.2
- *
- * Revision 1.3 87/09/24 13:58:30 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:21:38 jenkins
- * Port to suns
- *
- * Revision 4.2 83/12/05 13:39:48 wft
- * made rewriteflag external.
- *
- * Revision 4.1 83/05/10 16:52:55 wft
- * Added option -u and -f.
- * Added handling of default branch.
- * Replaced getpwuid() with getcaller().
- * Removed calls to stat(); now done by pairfilenames().
- * Changed and renamed rmoldfile() to rmworkfile().
- * Replaced catchints() calls with restoreints(), unlink()--link() with rename();
- *
- * Revision 3.7 83/02/15 15:27:07 wft
- * Added call to fastcopy() to copy remainder of RCS file.
- *
- * Revision 3.6 83/01/15 14:37:50 wft
- * Added ignoring of interrupts while RCS file is renamed; this avoids
- * deletion of RCS files during the unlink/link window.
- *
- * Revision 3.5 82/12/08 21:40:11 wft
- * changed processing of -d to use DATEFORM; removed actual from
- * call to preparejoin; re-fixed printing of done at the end.
- *
- * Revision 3.4 82/12/04 18:40:00 wft
- * Replaced getdelta() with gettree(), SNOOPDIR with SNOOPFILE.
- * Fixed printing of "done".
- *
- * Revision 3.3 82/11/28 22:23:11 wft
- * Replaced getlogin() with getpwuid(), flcose() with ffclose(),
- * %02d with %.2d, mode generation for working file with WORKMODE.
- * Fixed nil printing. Fixed -j combined with -l and -p, and exit
- * for non-existing revisions in preparejoin().
- *
- * Revision 3.2 82/10/18 20:47:21 wft
- * Mode of working file is now maintained even for co -l, but write permission
- * is removed.
- * The working file inherits its mode from the RCS file, plus write permission
- * for the owner. The write permission is not given if locking is strict and
- * co does not lock.
- * An existing working file without write permission is deleted automatically.
- * Otherwise, co asks (empty answer: abort co).
- * Call to getfullRCSname() added, check for write error added, call
- * for getlogin() fixed.
- *
- * Revision 3.1 82/10/13 16:01:30 wft
- * fixed type of variables receiving from getc() (char -> int).
- * removed unused variables.
- */
-
-
-
-
-#include "rcsbase.h"
-
-static char *addjoin P((char*));
-static char const *getancestor P((char const*,char const*));
-static int buildjoin P((char const*));
-static int preparejoin P((char*));
-static int rmlock P((struct hshentry const*));
-static int rmworkfile P((void));
-static void cleanup P((void));
-
-static char const quietarg[] = "-q";
-
-static char const *expandarg, *suffixarg, *versionarg, *zonearg;
-static char const **joinlist; /* revisions to be joined */
-static int joinlength;
-static FILE *neworkptr;
-static int exitstatus;
-static int forceflag;
-static int lastjoin; /* index of last element in joinlist */
-static int lockflag; /* -1 -> unlock, 0 -> do nothing, 1 -> lock */
-static int mtimeflag;
-static struct hshentries *gendeltas; /* deltas to be generated */
-static struct hshentry *targetdelta; /* final delta to be generated */
-static struct stat workstat;
-
-mainProg(coId, "co", "$Id: co.c,v 1.8 1997/02/22 15:47:21 peter Exp $")
-{
- static char const cmdusage[] =
- "\nco usage: co -{fIlMpqru}[rev] -ddate -jjoins -ksubst -sstate -T -w[who] -Vn -xsuff -zzone file ...";
-
- char *a, *joinflag, **newargv;
- char const *author, *date, *rev, *state;
- char const *joinname, *newdate, *neworkname;
- int changelock; /* 1 if a lock has been changed, -1 if error */
- int expmode, r, tostdout, workstatstat;
- int Ttimeflag;
- struct buf numericrev; /* expanded revision number */
- char finaldate[datesize];
-# if OPEN_O_BINARY
- int stdout_mode = 0;
-# endif
-
- setrid();
- author = date = rev = state = 0;
- joinflag = 0;
- bufautobegin(&numericrev);
- expmode = -1;
- suffixes = X_DEFAULT;
- tostdout = false;
- Ttimeflag = false;
-
- argc = getRCSINIT(argc, argv, &newargv);
- argv = newargv;
- while (a = *++argv, 0<--argc && *a++=='-') {
- switch (*a++) {
-
- case 'r':
- revno:
- if (*a) {
- if (rev) warn("redefinition of revision number");
- rev = a;
- }
- break;
-
- case 'f':
- forceflag=true;
- goto revno;
-
- case 'l':
- if (lockflag < 0) {
- warn("-u overridden by -l.");
- }
- lockflag = 1;
- goto revno;
-
- case 'u':
- if (0 < lockflag) {
- warn("-l overridden by -u.");
- }
- lockflag = -1;
- goto revno;
-
- case 'p':
- tostdout = true;
- goto revno;
-
- case 'I':
- interactiveflag = true;
- goto revno;
-
- case 'q':
- quietflag=true;
- goto revno;
-
- case 'd':
- if (date)
- redefined('d');
- str2date(a, finaldate);
- date=finaldate;
- break;
-
- case 'j':
- if (*a) {
- if (joinflag) redefined('j');
- joinflag = a;
- }
- break;
-
- case 'M':
- mtimeflag = true;
- goto revno;
-
- case 's':
- if (*a) {
- if (state) redefined('s');
- state = a;
- }
- break;
-
- case 'T':
- if (*a)
- goto unknown;
- Ttimeflag = true;
- break;
-
- case 'w':
- if (author) redefined('w');
- if (*a)
- author = a;
- else
- author = getcaller();
- break;
-
- case 'x':
- suffixarg = *argv;
- suffixes = a;
- break;
-
- case 'V':
- versionarg = *argv;
- setRCSversion(versionarg);
- break;
-
- case 'z':
- zonearg = *argv;
- zone_set(a);
- break;
-
- case 'k': /* set keyword expand mode */
- expandarg = *argv;
- if (0 <= expmode) redefined('k');
- if (0 <= (expmode = str2expmode(a)))
- break;
- /* fall into */
- default:
- unknown:
- error("unknown option: %s%s", *argv, cmdusage);
-
- };
- } /* end of option processing */
-
- /* Now handle all pathnames. */
- if (nerror) cleanup();
- else if (argc < 1) faterror("no input file%s", cmdusage);
- else for (; 0 < argc; cleanup(), ++argv, --argc) {
- ffree();
-
- if (pairnames(argc, argv, lockflag?rcswriteopen:rcsreadopen, true, false) <= 0)
- continue;
-
- /*
- * RCSname contains the name of the RCS file, and finptr
- * points at it. workname contains the name of the working file.
- * Also, RCSstat has been set.
- */
- diagnose("%s --> %s\n", RCSname, tostdout?"standard output":workname);
-
- workstatstat = -1;
- if (tostdout) {
-# if OPEN_O_BINARY
- int newmode = Expand==BINARY_EXPAND ? OPEN_O_BINARY : 0;
- if (stdout_mode != newmode) {
- stdout_mode = newmode;
- oflush();
- VOID setmode(STDOUT_FILENO, newmode);
- }
-# endif
- neworkname = 0;
- neworkptr = workstdout = stdout;
- } else {
- workstatstat = stat(workname, &workstat);
- if (workstatstat == 0 && same_file(RCSstat, workstat, 0)) {
- rcserror("RCS file is the same as working file %s.",
- workname
- );
- continue;
- }
- neworkname = makedirtemp(1);
- if (!(neworkptr = fopenSafer(neworkname, FOPEN_W_WORK))) {
- if (errno == EACCES)
- workerror("permission denied on parent directory");
- else
- eerror(neworkname);
- continue;
- }
- }
-
- gettree(); /* reads in the delta tree */
-
- if (!Head) {
- /* no revisions; create empty file */
- diagnose("no revisions present; generating empty revision 0.0\n");
- if (lockflag)
- warn(
- "no revisions, so nothing can be %slocked",
- lockflag < 0 ? "un" : ""
- );
- Ozclose(&fcopy);
- if (workstatstat == 0)
- if (!rmworkfile()) continue;
- changelock = 0;
- newdate = 0;
- } else {
- int locks = lockflag ? findlock(false, &targetdelta) : 0;
- if (rev) {
- /* expand symbolic revision number */
- if (!expandsym(rev, &numericrev))
- continue;
- } else {
- switch (locks) {
- default:
- continue;
- case 0:
- bufscpy(&numericrev, Dbranch?Dbranch:"");
- break;
- case 1:
- bufscpy(&numericrev, targetdelta->num);
- break;
- }
- }
- /* get numbers of deltas to be generated */
- if (!(targetdelta=genrevs(numericrev.string,date,author,state,&gendeltas)))
- continue;
- /* check reservations */
- changelock =
- lockflag < 0 ?
- rmlock(targetdelta)
- : lockflag == 0 ?
- 0
- :
- addlock(targetdelta, true);
-
- if (
- changelock < 0
- || (changelock && !checkaccesslist())
- || dorewrite(lockflag, changelock) != 0
- )
- continue;
-
- if (0 <= expmode)
- Expand = expmode;
- if (0 < lockflag && Expand == VAL_EXPAND) {
- rcserror("cannot combine -kv and -l");
- continue;
- }
-
- if (joinflag && !preparejoin(joinflag))
- continue;
-
- diagnose("revision %s%s\n",targetdelta->num,
- 0<lockflag ? " (locked)" :
- lockflag<0 ? " (unlocked)" : "");
-
- /* Prepare to remove old working file if necessary. */
- if (workstatstat == 0)
- if (!rmworkfile()) continue;
-
- /* skip description */
- getdesc(false); /* don't echo*/
-
- locker_expansion = 0 < lockflag;
- targetdelta->name = namedrev(rev, targetdelta);
- joinname = buildrevision(
- gendeltas, targetdelta,
- joinflag&&tostdout ? (FILE*)0 : neworkptr,
- Expand < MIN_UNEXPAND
- );
-# if !large_memory
- if (fcopy == neworkptr)
- fcopy = 0; /* Don't close it twice. */
-# endif
- if_advise_access(changelock && gendeltas->first!=targetdelta,
- finptr, MADV_SEQUENTIAL
- );
-
- if (donerewrite(changelock,
- Ttimeflag ? RCSstat.st_mtime : (time_t)-1
- ) != 0)
- continue;
-
- if (changelock) {
- locks += lockflag;
- if (1 < locks)
- rcswarn("You now have %d locks.", locks);
- }
-
- newdate = targetdelta->date;
- if (joinflag) {
- newdate = 0;
- if (!joinname) {
- aflush(neworkptr);
- joinname = neworkname;
- }
- if (Expand == BINARY_EXPAND)
- workerror("merging binary files");
- if (!buildjoin(joinname))
- continue;
- }
- }
- if (!tostdout) {
- mode_t m = WORKMODE(RCSstat.st_mode,
- ! (Expand==VAL_EXPAND || (lockflag<=0 && StrictLocks))
- );
- time_t t = mtimeflag&&newdate ? date2time(newdate) : (time_t)-1;
- aflush(neworkptr);
- ignoreints();
- r = chnamemod(&neworkptr, neworkname, workname, 1, m, t);
- keepdirtemp(neworkname);
- restoreints();
- if (r != 0) {
- eerror(workname);
- error("see %s", neworkname);
- continue;
- }
- diagnose("done\n");
- }
- }
-
- tempunlink();
- Ofclose(workstdout);
- exitmain(exitstatus);
-
-} /* end of main (co) */
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = EXIT_FAILURE;
- Izclose(&finptr);
- ORCSclose();
-# if !large_memory
- if (fcopy!=workstdout) Ozclose(&fcopy);
-# endif
- if (neworkptr!=workstdout) Ozclose(&neworkptr);
- dirtempunlink();
-}
-
-#if RCS_lint
-# define exiterr coExit
-#endif
- void
-exiterr()
-{
- ORCSerror();
- dirtempunlink();
- tempunlink();
- _exit(EXIT_FAILURE);
-}
-
-
-/*****************************************************************
- * The following routines are auxiliary routines
- *****************************************************************/
-
- static int
-rmworkfile()
-/*
- * Prepare to remove workname, if it exists, and if
- * it is read-only.
- * Otherwise (file writable):
- * if !quietmode asks the user whether to really delete it (default: fail);
- * otherwise failure.
- * Returns true if permission is gotten.
- */
-{
- if (workstat.st_mode&(S_IWUSR|S_IWGRP|S_IWOTH) && !forceflag) {
- /* File is writable */
- if (!yesorno(false, "writable %s exists%s; remove it? [ny](n): ",
- workname,
- myself(workstat.st_uid) ? "" : ", and you do not own it"
- )) {
- error(!quietflag && ttystdin()
- ? "checkout aborted"
- : "writable %s exists; checkout aborted", workname);
- return false;
- }
- }
- /* Actual unlink is done later by caller. */
- return true;
-}
-
-
- static int
-rmlock(delta)
- struct hshentry const *delta;
-/* Function: removes the lock held by caller on delta.
- * Returns -1 if someone else holds the lock,
- * 0 if there is no lock on delta,
- * and 1 if a lock was found and removed.
- */
-{ register struct rcslock * next, * trail;
- char const *num;
- struct rcslock dummy;
- int whomatch, nummatch;
-
- num=delta->num;
- dummy.nextlock=next=Locks;
- trail = &dummy;
- while (next) {
- whomatch = strcmp(getcaller(), next->login);
- nummatch=strcmp(num,next->delta->num);
- if ((whomatch==0) && (nummatch==0)) break;
- /*found a lock on delta by caller*/
- if ((whomatch!=0)&&(nummatch==0)) {
- rcserror("revision %s locked by %s; use co -r or rcs -u",
- num, next->login
- );
- return -1;
- }
- trail=next;
- next=next->nextlock;
- }
- if (next) {
- /*found one; delete it */
- trail->nextlock=next->nextlock;
- Locks=dummy.nextlock;
- next->delta->lockedby = 0;
- return 1; /*success*/
- } else return 0; /*no lock on delta*/
-}
-
-
-
-
-/*****************************************************************
- * The rest of the routines are for handling joins
- *****************************************************************/
-
-
- static char *
-addjoin(joinrev)
- char *joinrev;
-/* Add joinrev's number to joinlist, yielding address of char past joinrev,
- * or 0 if no such revision exists.
- */
-{
- register char *j;
- register struct hshentry *d;
- char terminator;
- struct buf numrev;
- struct hshentries *joindeltas;
-
- j = joinrev;
- for (;;) {
- switch (*j++) {
- default:
- continue;
- case 0:
- case ' ': case '\t': case '\n':
- case ':': case ',': case ';':
- break;
- }
- break;
- }
- terminator = *--j;
- *j = 0;
- bufautobegin(&numrev);
- d = 0;
- if (expandsym(joinrev, &numrev))
- d = genrevs(numrev.string,(char*)0,(char*)0,(char*)0,&joindeltas);
- bufautoend(&numrev);
- *j = terminator;
- if (d) {
- joinlist[++lastjoin] = d->num;
- return j;
- }
- return 0;
-}
-
- static int
-preparejoin(j)
- register char *j;
-/* Parse join list J and place pointers to the
- * revision numbers into joinlist.
- */
-{
- lastjoin= -1;
- for (;;) {
- while ((*j==' ')||(*j=='\t')||(*j==',')) j++;
- if (*j=='\0') break;
- if (lastjoin>=joinlength-2) {
- joinlist =
- (joinlength *= 2) == 0
- ? tnalloc(char const *, joinlength = 16)
- : trealloc(char const *, joinlist, joinlength);
- }
- if (!(j = addjoin(j))) return false;
- while ((*j==' ') || (*j=='\t')) j++;
- if (*j == ':') {
- j++;
- while((*j==' ') || (*j=='\t')) j++;
- if (*j!='\0') {
- if (!(j = addjoin(j))) return false;
- } else {
- rcsfaterror("join pair incomplete");
- }
- } else {
- if (lastjoin==0) { /* first pair */
- /* common ancestor missing */
- joinlist[1]=joinlist[0];
- lastjoin=1;
- /*derive common ancestor*/
- if (!(joinlist[0] = getancestor(targetdelta->num,joinlist[1])))
- return false;
- } else {
- rcsfaterror("join pair incomplete");
- }
- }
- }
- if (lastjoin < 1)
- rcsfaterror("empty join");
- return true;
-}
-
-
-
- static char const *
-getancestor(r1, r2)
- char const *r1, *r2;
-/* Yield the common ancestor of r1 and r2 if successful, 0 otherwise.
- * Work reliably only if r1 and r2 are not branch numbers.
- */
-{
- static struct buf t1, t2;
-
- int l1, l2, l3;
- char const *r;
-
- l1 = countnumflds(r1);
- l2 = countnumflds(r2);
- if ((2<l1 || 2<l2) && cmpnum(r1,r2)!=0) {
- /* not on main trunk or identical */
- l3 = 0;
- while (cmpnumfld(r1, r2, l3+1)==0 && cmpnumfld(r1, r2, l3+2)==0)
- l3 += 2;
- /* This will terminate since r1 and r2 are not the same; see above. */
- if (l3==0) {
- /* no common prefix; common ancestor on main trunk */
- VOID partialno(&t1, r1, l1>2 ? 2 : l1);
- VOID partialno(&t2, r2, l2>2 ? 2 : l2);
- r = cmpnum(t1.string,t2.string)<0 ? t1.string : t2.string;
- if (cmpnum(r,r1)!=0 && cmpnum(r,r2)!=0)
- return r;
- } else if (cmpnumfld(r1, r2, l3+1)!=0)
- return partialno(&t1,r1,l3);
- }
- rcserror("common ancestor of %s and %s undefined", r1, r2);
- return 0;
-}
-
-
-
- static int
-buildjoin(initialfile)
- char const *initialfile;
-/* Function: merge pairs of elements in joinlist into initialfile
- * If workstdout is set, copy result to stdout.
- * All unlinking of initialfile, rev2, and rev3 should be done by tempunlink().
- */
-{
- struct buf commarg;
- struct buf subs;
- char const *rev2, *rev3;
- int i;
- char const *cov[10], *mergev[11];
- char const **p;
-
- bufautobegin(&commarg);
- bufautobegin(&subs);
- rev2 = maketemp(0);
- rev3 = maketemp(3); /* buildrevision() may use 1 and 2 */
-
- cov[1] = CO;
- /* cov[2] setup below */
- p = &cov[3];
- if (expandarg) *p++ = expandarg;
- if (suffixarg) *p++ = suffixarg;
- if (versionarg) *p++ = versionarg;
- if (zonearg) *p++ = zonearg;
- *p++ = quietarg;
- *p++ = RCSname;
- *p = 0;
-
- mergev[1] = MERGE;
- mergev[2] = mergev[4] = "-L";
- /* rest of mergev setup below */
-
- i=0;
- while (i<lastjoin) {
- /*prepare marker for merge*/
- if (i==0)
- bufscpy(&subs, targetdelta->num);
- else {
- bufscat(&subs, ",");
- bufscat(&subs, joinlist[i-2]);
- bufscat(&subs, ":");
- bufscat(&subs, joinlist[i-1]);
- }
- diagnose("revision %s\n",joinlist[i]);
- bufscpy(&commarg, "-p");
- bufscat(&commarg, joinlist[i]);
- cov[2] = commarg.string;
- if (runv(-1, rev2, cov))
- goto badmerge;
- diagnose("revision %s\n",joinlist[i+1]);
- bufscpy(&commarg, "-p");
- bufscat(&commarg, joinlist[i+1]);
- cov[2] = commarg.string;
- if (runv(-1, rev3, cov))
- goto badmerge;
- diagnose("merging...\n");
- mergev[3] = subs.string;
- mergev[5] = joinlist[i+1];
- p = &mergev[6];
- if (quietflag) *p++ = quietarg;
- if (lastjoin<=i+2 && workstdout) *p++ = "-p";
- *p++ = initialfile;
- *p++ = rev2;
- *p++ = rev3;
- *p = 0;
- switch (runv(-1, (char*)0, mergev)) {
- case DIFF_FAILURE: case DIFF_SUCCESS:
- break;
- default:
- goto badmerge;
- }
- i=i+2;
- }
- bufautoend(&commarg);
- bufautoend(&subs);
- return true;
-
- badmerge:
- nerror++;
- bufautoend(&commarg);
- bufautoend(&subs);
- return false;
-}
diff --git a/gnu/usr.bin/rcs/doc/rcs.ms b/gnu/usr.bin/rcs/doc/rcs.ms
deleted file mode 100644
index e89ae70..0000000
--- a/gnu/usr.bin/rcs/doc/rcs.ms
+++ /dev/null
@@ -1,1518 +0,0 @@
-.\" Format this file with:
-.\" pic file | tbl | troff -ms
-.\"
-.\" \*s stands for $, and avoids problems when this file is checked in.
-.ds s $
-.de D(
-.DS
-.nr VS 12p
-.vs 12p
-.I
-..
-.de D)
-.DE
-.nr VS 18p
-.vs 18p
-.R
-..
-.de Id
-.ND \\$4
-..
-.Id $Id$
-.RP
-.TL
-RCS\*-A System for Version Control
-.sp
-.AU
-Walter F. Tichy
-.AI
-Department of Computer Sciences
-Purdue University
-West Lafayette, Indiana 47907
-.sp
-.AB
-An important problem in program development and maintenance is version control,
-i.e., the task of keeping a software system consisting of many versions and
-configurations well organized.
-The Revision Control System (RCS)
-is a software tool that assists with that task.
-RCS manages revisions of text documents, in particular source programs,
-documentation, and test data.
-It automates the storing, retrieval, logging and identification of revisions,
-and it provides selection mechanisms for composing configurations.
-This paper introduces basic version control concepts and
-discusses the practice of version control
-using RCS.
-For conserving space, RCS stores deltas, i.e., differences between
-successive revisions. Several delta storage methods are discussed.
-Usage statistics show that RCS's delta storage method is
-space and time efficient.
-The paper concludes with a detailed survey of version control tools.
-.sp
-\fBKeywords\fR: configuration management, history management,
-version control, revisions, deltas.
-.AE
-.FS
-An earlier version of this paper was published in
-.I "Software\*-Practice & Experience"
-.B 15 ,
-7 (July 1985), 637-654.
-.FE
-.nr VS 18p
-.LP
-.NH
-Introduction
-.PP
-Version control is the task of keeping software
-systems consisting of many versions and configurations well organized.
-The Revision Control System (RCS) is a set of UNIX
-commands that assist with that task.
-.PP
-RCS' primary function is to manage \fIrevision groups\fR.
-A revision group is a set of text documents, called \fIrevisions\fR,
-that evolved from each other. A new revision is
-created by manually editing an existing one.
-RCS organizes the revisions into an ancestral tree. The initial revision
-is the root of the tree, and the tree edges indicate
-from which revision a given one evolved.
-Besides managing individual revision groups, RCS provides
-flexible selection functions for composing configurations.
-RCS may be combined with MAKE\u1\d,
-resulting in a powerful package for version control.
-.PP
-RCS also offers facilities for
-merging updates with customer modifications,
-for distributed software development, and
-for automatic identification.
-Identification is the `stamping'
-of revisions and configurations with unique markers.
-These markers are akin to serial numbers,
-telling software maintainers unambiguously which configuration
-is before them.
-.PP
-RCS is designed for both production and experimental
-environments.
-In production environments,
-access controls detect update conflicts and prevent overlapping changes.
-In experimental environments, where strong controls are
-counterproductive, it is possible to loosen the controls.
-.PP
-Although RCS was originally intended for programs, it is useful for any
-text that is revised frequently and whose previous revisions must be
-preserved. RCS has been applied successfully to store the source
-text for drawings, VLSI layouts, documentation, specifications,
-test data, form letters and articles.
-.PP
-This paper discusses the practice of
-version control using RCS.
-It also introduces basic version control concepts,
-useful for clarifying current practice and designing similar systems.
-Revision groups of individual components are treated in the next three sections,
-and the extensions to configurations follow.
-Because of its size, a survey of version control tools
-appears at the end of the paper.
-.NH
-Getting started with RCS
-.PP
-Suppose a text file \fIf.c\fR is to be placed under control of RCS.
-Invoking the check-in command
-.D(
-ci f.c
-.D)
-creates a new revision group with the contents of
-\fIf.c\fR as the initial
-revision (numbered 1.1)
-and stores the group into the file \fIf.c,v\fR.
-Unless told otherwise, the command deletes \fIf.c\fR.
-It also asks for a description of the group.
-The description should state the common purpose of all revisions in the group,
-and becomes part of the group's documentation.
-All later check-in commands will ask for a log entry,
-which should summarize the changes made.
-(The first revision is assigned a default log message,
-which just records the fact that it is the initial revision.)
-.PP
-Files ending in \fI,v\fR
-are called \fIRCS files\fR (\fIv\fR stands for \fIv\fRersions);
-the others are called working files.
-To get back the working file \fIf.c\fR in the previous example,
-execute the check-out command:
-.D(
-co f.c
-.D)
-.R
-This command extracts the latest revision from
-the revision group \fIf.c,v\fR and writes
-it into \fIf.c\fR.
-The file \fIf.c\fR can now be edited and, when finished,
-checked back in with \fIci\fR:
-.D(
-ci f.c
-.D)
-\fICi\fR assigns number 1.2 to
-the new revision.
-If \fIci\fR complains with the message
-.D(
-ci error: no lock set by <login>
-.D)
-then the system administrator has decided to configure RCS for a
-production environment by enabling the `strict locking feature'.
-If this feature is enabled, all RCS files are initialized
-such that check-in operations require a lock on the previous revision
-(the one from which the current one evolved).
-Locking prevents overlapping modifications if several people work on the same file.
-If locking is required, the revision should
-have been locked during the check-out by using
-the option \fI\-l\fR:
-.D(
-co \-l f.c
-.D)
-Of course it is too late now for the check-out with locking, because
-\fIf.c\fR has already been changed; checking out the file again
-would overwrite the modifications.
-(To prevent accidental overwrites, \fIco\fR senses the presence
-of a working file and asks whether the user really intended to overwrite it.
-The overwriting check-out is sometimes useful for
-backing up to the previous revision.)
-To be able to proceed with the check-in in the present case, first execute
-.D(
-rcs \-l f.c
-.D)
-This command retroactively locks the latest revision, unless someone
-else locked it in the meantime. In this case, the two programmers
-involved have to negotiate whose
-modifications should take precedence.
-.PP
-If an RCS file is private, i.e., if only the owner of the file is expected
-to deposit revisions into it, the strict locking feature is unnecessary and
-may be disabled.
-If strict locking is disabled,
-the owner of the RCS file need not have a lock for check-in.
-For safety reasons, all others
-still do. Turning strict locking off and on is done with the commands:
-.D(
-rcs \-U f.c \fRand\fP rcs \-L f.c
-.D)
-These commands enable or disable the strict locking feature for each RCS file
-individually.
-The system administrator only decides whether strict locking is
-enabled initially.
-.PP
-To reduce the clutter in a working directory, all RCS files can be moved
-to a subdirectory with the name \fIRCS\fR.
-RCS commands look first into that directory for RCS files.
-All the commands presented above work
-with the \fIRCS\fR subdirectory without change.\(dg
-.FS \(dg
-Pairs of RCS and working files can actually be specified in 3 ways:
-a) both are given, b) only the working file is given, c) only the
-RCS file is given.
-If a pair is given, both files may have arbitrary path prefixes;
-RCS commands pair them up intelligently.
-.FE
-.PP
-It may be undesirable that \fIci\fR deletes the working file.
-For instance, sometimes one would like to save the current revision,
-but continue editing.
-Invoking
-.D(
-ci \-l f.c
-.D)
-checks in \fIf.c\fR as usual, but performs an additional
-check-out with locking afterwards. Thus, the working file does
-not disappear after the check-in.
-Similarly, the option
-\fI\-u\fR does a check-in followed by a check-out without
-locking. This option is useful if the file is needed for compilation after the check-in.
-Both options update the identification markers in the working file
-(see below).
-.PP
-Besides the operations \fIci\fR and \fIco\fR, RCS provides the following
-commands:
-.sp 0
-.nr VS 12p
-.vs 12p
-.TS
-tab(%);
-li l.
-ident%extract identification markers
-rcs%change RCS file attributes
-rcsclean%remove unchanged working files (optional)
-rcsdiff%compare revisions
-rcsfreeze%record a configuration (optional)
-rcsmerge%merge revisions
-rlog%read log messages and other information in RCS files
-.TE
-A synopsis of these commands appears in the Appendix.
-.NH 2
-Automatic Identification
-.PP
-RCS can stamp source and object code with special identification strings,
-similar to product and serial numbers.
-To obtain such identification, place the marker
-.D(
-\*sId\*s
-.D)
-into the text of a revision, for instance inside a comment.
-The check-out operation will replace this marker with a string of the form
-.D(
-\*sId: filename revisionnumber date time author state locker \*s
-.D)
-This string need never be touched, because \fIco\fR keeps it
-up to date automatically.
-To propagate the marker into object code, simply put
-it into a literal character string. In C, this is done as follows:
-.D(
-static char rcsid[] = \&"\*sId\*s\&";
-.D)
-The command \fIident\fR extracts such markers from any file, in particular from
-object code.
-\fIIdent\fR helps to find out
-which revisions of which modules were used in a given program.
-It returns a complete and unambiguous component list,
-from which a copy of the program can be reconstructed.
-This facility is invaluable for program maintenance.
-.PP
-There are several additional identification markers, one for each component
-of \*sId\*s.
-The marker
-.D(
-\*sLog\*s
-.D)
-has a similar function. It accumulates
-the log messages that are requested during check-in.
-Thus, one can maintain the complete history of a revision directly inside it,
-by enclosing it in a comment.
-Figure 1 is an edited version of a log contained in revision 4.1 of
-the file \fIci.c\fR. The log appears at the beginning of the file,
-and makes it easy to determine what the recent modifications were.
-.sp
-.nr VS 12p
-.vs 12p
-.ne 18
-.nf
-.in +0.5i
-/*
-.in +\w'/'u
-* \*sLog: ci.c,v \*s
-* Revision 4.1 1983/05/10 17:03:06 wft
-* Added option \-d and \-w, and updated assignment of date, etc. to new delta.
-* Added handling of default branches.
-*
-* Revision 3.9 1983/02/15 15:25:44 wft
-* Added call to fastcopy() to copy remainder of RCS file.
-*
-* Revision 3.8 1983/01/14 15:34:05 wft
-* Added ignoring of interrupts while new RCS file is renamed;
-* avoids deletion of RCS files by interrupts.
-*
-* Revision 3.7 1982/12/10 16:09:20 wft
-* Corrected checking of return code from diff.
-* An RCS file now inherits its mode during the first ci from the working file,
-* except that write permission is removed.
-*/
-.in 0
-.ce 1
-Figure 1. Log entries produced by the marker \*sLog\*s.
-.fi
-.nr VS 18p
-.vs 18p
-.sp 0
-.LP
-Since revisions are stored in the form of differences,
-each log message is
-physically stored once,
-independent of the number of revisions present.
-Thus, the \*sLog\*s marker incurs negligible space overhead.
-.NH
-The RCS Revision Tree
-.PP
-RCS arranges revisions in an ancestral tree.
-The \fIci\fR command builds this tree; the auxiliary command \fIrcs\fR
-prunes it.
-The tree has a root revision, normally numbered 1.1, and successive revisions
-are numbered 1.2, 1.3, etc. The first field of a revision number
-is called the \fIrelease number\fR and the second one
-the \fIlevel number\fR. Unless given explicitly,
-the \fIci\fR command assigns a new revision number
-by incrementing the level number of the previous revision.
-The release number must be incremented explicitly, using the
-\fI\-r\fR option of \fIci\fR.
-Assuming there are revisions 1.1, 1.2, and 1.3 in the RCS file f.c,v, the command
-.D(
-ci \-r2.1 f.c \fRor\fP ci \-r2 f.c
-.D)
-assigns the number 2.1 to the new revision.
-Later check-ins without the \fI\-r\fR option will assign the numbers 2.2, 2.3,
-and so on.
-The release number should be incremented only at major transition points
-in the development, for instance when a new release of a software product has
-been completed.
-.NH 2
-When are branches needed?
-.PP
-A young revision tree is slender:
-It consists of only one branch, called the trunk.
-As the tree ages, side branches may form.
-Branches are needed in the following 4 situations.
-.IP "\fITemporary fixes\fR"
-.sp 0
-Suppose a tree has 5 revisions grouped in 2 releases,
-as illustrated in Figure 2.
-Revision 1.3, the last one of release 1, is in operation at customer sites,
-while release 2 is in active development.
-.ne 4
-.PS 4i
-.ps -2
-box "1.1"
-arrow
-box "1.2"
-arrow
-box "1.3"
-arrow
-box "2.1"
-arrow
-box "2.2"
-arrow dashed
-.ps +2
-.PE
-.ce 1
-Figure 2. A slender revision tree.
-.sp 0
-Now imagine a customer requesting a fix of
-a problem in revision 1.3, although actual development has moved on
-to release 2. RCS does not permit an extra
-revision to be spliced in between 1.3 and 2.1, since that would not reflect
-the actual development history. Instead, create a branch
-at revision 1.3, and check in the fix on that branch.
-The first branch starting at 1.3 has number 1.3.1, and
-the revisions on that branch are numbered 1.3.1.1, 1.3.1.2, etc.
-The double numbering is needed to allow for another
-branch at 1.3, say 1.3.2.
-Revisions on the second branch would be numbered
-1.3.2.1, 1.3.2.2, and so on.
-The following steps create
-branch 1.3.1 and add revision 1.3.1.1:
-.sp 0
-.I
-.nr VS 12p
-.vs 12p
-.TS
-tab(%);
-l l l.
- %co \-r1.3 f.c% \*- check out revision 1.3
- %edit f.c% \*- change it
- %ci \-r1.3.1 f.c% \*- check it in on branch 1.3.1
-.TE
-.nr VS 18p
-.vs 18p
-.R
-This sequence of commands transforms the tree of Figure 2 into
-the one in Figure 3.
-Note that it may be necessary to incorporate the differences
-between 1.3 and 1.3.1.1
-into a revision at level 2. The operation \fIrcsmerge\fR automates this
-process (see the Appendix).
-.ne 7
-.PS 4i
-.ps -2
- box "1.1"
- arrow
- box "1.2"
- arrow
-R13: box "1.3"
- arrow
-R21: box "2.1"
- arrow
-R22: box "2.2"
- arrow dashed
- line invis down from R21.s
-RB1: box "1.3.1.1"
- arrow dashed right from RB1.e
- arrow from R13.s to RB1.w
-.ps +2
-.PE
-.ce 1
-Figure 3. A revision tree with one side branch
-.sp
-.IP "\fIDistributed development and customer modifications\fR"
-.sp 0
-Assume a situation as in Figure 2, where revision 1.3 is in operation
-at several customer sites,
-while release 2 is in development.
-Customer sites should use RCS to store the distributed software.
-However, customer modifications should not be placed on the same branch
-as the distributed source; instead, they should be placed on a side branch.
-When the next software distribution arrives,
-it should be appended to the trunk of
-the customer's RCS file, and the customer
-can then merge the local modifications back into the new release.
-In the above example, a
-customer's RCS file would contain the following tree, assuming
-that the customer has received revision 1.3, added his local modifications
-as revision 1.3.1.1, then received revision 2.4, and merged
-2.4 and 1.3.1.1, resulting in 2.4.1.1.
-.ne 7
-.PS 4i
-.ps -2
-R13: box "1.3"
- line invis
-R21: box invis
- line invis
-R22: box invis
- line invis
-R24: box "2.4"
- line invis
-R25: box invis
- line invis
- arrow from R13.e to R24.w
- line invis down from R21.s
-RB1: box "1.3.1.1"
- arrow from R13.s to RB1.w
- right
- line invis down from R25.s
-RB2: box "2.4.1.1"
- arrow from R24.s to RB2.w
-.ps +2
-.PE
-.ce 1
-Figure 4. A customer's revision tree with local modifications.
-.sp 1
-This approach is actually practiced in the CSNET project,
-where several universities and a company cooperate
-in developing a national computer network.
-.IP "\fIParallel development\fR"
-.sp 0
-Sometimes it is desirable to explore an alternate design or
-a different implementation technique in parallel with the
-main line development. Such development
-should be carried out on a side branch.
-The experimental changes may later be moved into the main line, or abandoned.
-.IP "\fIConflicting updates\fR"
-.sp 0
-A common occurrence is that one programmer
-has checked out a revision, but cannot complete the assignment
-for some reason. In the meantime, another person
-must perform another modification
-immediately. In that case, the second person should check-out the same revision,
-modify it, and check it in on a side branch, for later merging.
-.PP
-Every node in a revision tree consists of the following attributes:
-a revision number, a check-in date and time, the author's identification,
-a log entry, a state and the actual text. All these attributes
-are determined at the time the revision is checked in.
-The state attribute indicates the status of a revision.
-It is set automatically to `experimental' during check-in.
-A revision can later be promoted to a higher status, for example
-`stable' or `released'. The set of states is user-defined.
-.NH 2
-Revisions are represented as deltas
-.PP
-For conserving space, RCS stores revisions in the form
-of deltas, i.e., as differences between revisions.
-The user interface completely hides this fact.
-.PP
-A delta is a sequence of edit commands that transforms one string
-into another. The deltas employed by RCS are line-based, which means
-that the only edit commands allowed are insertion and deletion of lines.
-If a single character in a line is changed, the
-edit scripts consider the entire line changed.
-The program \fIdiff\fR\u2\d
-produces a small, line-based delta between pairs of text files.
-A character-based edit script would take much longer to compute,
-and would not be significantly shorter.
-.PP
-Using deltas is a classical space-time tradeoff: deltas reduce the
-space consumed, but increase access time.
-However, a version control tool should impose as little delay
-as possible on programmers.
-Excessive delays discourage the use of version controls,
-or induce programmers to take shortcuts that compromise system integrity.
-To gain reasonably fast access time for both editing and compiling,
-RCS arranges deltas in the following way.
-The most recent revision on the trunk is stored intact.
-All other revisions on the trunk are stored as reverse deltas.
-A reverse delta describes how to go backward in the development history:
-it produces the desired revision if applied to the successor of that revision.
-This implementation has the advantage
-that extraction of the latest revision is a simple and fast copy
-operation.
-Adding a new revision to the trunk is also fast: \fIci\fR simply
-adds the new revision intact, replaces the previous
-revision with a reverse delta, and keeps the rest of the old deltas.
-Thus, \fIci\fR requires the computation
-of only one new delta.
-.PP
-Branches need special treatment. The naive solution would be to
-store complete copies for the tips of all branches.
-Clearly, this approach would cost too much space. Instead,
-RCS uses \fIforward\fR deltas for branches. Regenerating a revision
-on a side branch proceeds as follows. First, extract the latest revision
-on the trunk; secondly, apply reverse deltas until the fork revision for
-the branch is obtained; thirdly, apply forward deltas until the desired
-branch revision is reached. Figure 5 illustrates a tree with
-one side branch. Triangles pointing to the left and right represent
-reverse and forward deltas, respectively.
-.ne 8
-.PS 4i
-.ps -2
-define BD X [line invis $1 right .5;
-line up .3 then left .5 down .3 then right .5 down .3 then up .3] X
-
-define FD X [line invis $1 right .5;
-line left .5 down .3 then up .6 then right .5 down .3;] X
-
-right
-D11: BD(" 1.1")
- arrow right from D11.e
-D12: BD(" 1.2")
- arrow right from D12.e
-D13: BD(" 1.3")
- arrow right from D13.e
-D21: BD(" 2.1")
- arrow right from D21.e
-D22: box "2.2"
- line invis down from D21.s
-F1: FD("1.3.1.1 ")
- arrow from D13.se to F1.w
- arrow from F1.e right
- right
-F2: FD("1.3.1.2 ")
-.ps +2
-.PE
-.ce 1
-Figure 5. A revision tree with reverse and forward deltas.
-.sp 0
-.PP
-Although implementing fast check-out for the latest trunk revision,
-this arrangement has the disadvantage that generation of other revisions
-takes time proportional to the number of deltas applied. For example,
-regenerating the branch tip in Figure 5 requires application of five
-deltas (including the initial one). Since usage statistics show that
-the latest trunk revision is the one that is retrieved in 95 per cent
-of all cases (see the section on usage statistics), biasing check-out time
-in favor of that revision results in significant savings.
-However, careful implementation of the delta application process is
-necessary to provide low retrieval overhead for other revisions, in
-particular for branch tips.
-.PP
-There are several techniques for delta application.
-The naive one is to pass each delta to a general-purpose text editor.
-A prototype of RCS invoked the UNIX editor \fIed\fR both
-for applying deltas and for expanding the identification markers.
-Although easy to implement, performance was poor, owing to the
-high start-up costs and excess generality of \fIed\fR. An intermediate
-version of RCS used a special-purpose, stream-oriented editor.
-This technique reduced the cost of applying a delta to the cost of
-checking out the latest trunk revision. The reason for this behavior
-is that each delta application involves a complete pass over
-the preceding revision.
-.PP
-However, there is a much better algorithm. Note that the deltas are
-line oriented and that most of the work of a stream editor involves
-copying unchanged lines from one revision to the next. A faster
-algorithm avoids unnecessary copying of character strings by using
-a \fIpiece table\fR.
-A piece table is a one-dimensional array, specifying how a given
-revision is `pieced together' from lines in the RCS file.
-Suppose piece table \fIPT\dr\u\fR represents revision \fIr\fR.
-Then \fIPT\dr\u[i]\fR contains the starting position of line \fIi\fR
-of revision \fIr\fR.
-Application of the next delta transforms piece table \fIPT\dr\u\fR
-into \fIPT\dr+1\u\fR. For instance, a delete command removes a
-series of entries from the piece table. An insertion command inserts
-new entries, moving the entries following the insertion point further down the
-array. The inserted entries point to the text lines in the delta.
-Thus, no I/O is involved except for reading the delta itself. When all
-deltas have been applied to the piece table, a sequential pass
-through the table looks up each line in the RCS file and copies it to
-the output file, updating identification markers at the same time.
-Of course, the RCS file must permit random access, since the copied
-lines are scattered throughout that file. Figure 6 illustrates an
-RCS file with two revisions and the corresponding piece tables.
-.ne 13
-.sp 6
-.ce 1
-\fIFigure 6 is not available.\fP
-.sp 5
-.ce 1
-Figure 6. An RCS file and its piece tables
-.sp 0
-.PP
-The piece table approach has the property that the time for applying a single
-delta is roughly determined by the size of the delta, and not by the
-size of the revision. For example, if a delta is
-10 per cent of the size of a revision, then applying it takes only
-10 per cent of the time to generate the latest trunk revision. (The stream
-editor would take 100 per cent.)
-.PP
-There is an important alternative for representing deltas that affects
-performance. SCCS\u3\d,
-a precursor of RCS, uses \fIinterleaved\fR deltas.
-A file containing interleaved deltas is partitioned into blocks of lines.
-Each block has a header that specifies to which revision(s) the block
-belongs. The blocks are sorted out in such a way that a single
-pass over the file can pick up all the lines belonging to a given
-revision. Thus, the regeneration time for all revisions is the same:
-all headers must be inspected, and the associated blocks either copied
-or skipped. As the number of revisions increases, the cost of retrieving
-any revision is much higher than the cost of checking out the
-latest trunk revision with reverse deltas. A detailed comparison
-of SCCS's interleaved deltas and RCS's reverse deltas can be found
-in Reference 4.
-This reference considers the version of RCS with the
-stream editor only. The piece table method improves performance
-further, so that RCS is always faster than SCCS, except if 10
-or more deltas are applied.
-.PP
-Additional speed-up for both delta methods can be obtained by caching
-the most recently generated revision, as has been implemented in DSEE.\u5\d
-With caching, access time to frequently used revisions can approach normal file
-access time, at the cost of some additional space.
-.NH
-Locking: A Controversial Issue
-.PP
-The locking mechanism for RCS was difficult to design.
-The problem and its solution are first presented in their `pure' form,
-followed by a discussion of the complications
-caused by `real-world' considerations.
-.PP
-RCS must prevent two or more persons from depositing competing changes of the
-same revision.
-Suppose two programmers check out revision 2.4 and
-modify it. Programmer A checks in a revision before programmer B\&.
-Unfortunately, programmer B has not seen A's
-changes, so the effect is that A's changes are covered up by B's deposit.
-A's changes are not lost since all revisions
-are saved, but they are confined to a single revision.\(dd
-.FS \(dd
-Note that this problem is entirely different from the atomicity problem.
-Atomicity means that
-concurrent update operations on the same RCS file cannot be permitted,
-because that may result in inconsistent data.
-Atomic updates are essential (and implemented in RCS),
-but do not solve the conflict discussed here.
-.FE
-.PP
-This conflict is prevented in RCS by locking.
-Whenever someone intends to edit a revision (as opposed
-to reading or compiling it), the revision should be checked out
-and locked,
-using the \fI\-l\fR option on \fIco\fR. On subsequent check-in,
-\fIci\fR tests the lock and then removes it.
-At most one programmer at a time may
-lock a particular revision, and only this programmer may check in
-the succeeding revision.
-Thus, while a revision is locked, it is the exclusive responsibility
-of the locker.
-.PP
-An important maxim for software tools like RCS is that they must
-not stand in the way of making progress with a project.
-This consideration leads to several weakenings of the locking mechanism.
-First of all, even if a revision is locked, it can
-still be checked out. This is necessary if other people
-wish to compile or inspect the locked revision
-while the next one is in preparation. The only operations they
-cannot do are to lock the revision or to check in the succeeding one. Secondly,
-check-in operations on other branches in the RCS file are still possible; the
-locking of one revision does not affect any other revision.
-Thirdly, revisions are occasionally locked for a long period of time
-because a programmer is absent or otherwise unable to complete
-the assignment. If another programmer has to make a pressing change,
-there are the following three alternatives for making progress:
-a) find out who is holding the lock and ask that person to release it;
-b) check out the locked revision, modify it, check it
-in on a branch, and merge the changes later;
-c) break the lock. Breaking a lock leaves a highly visible
-trace, namely an electronic mail message that is sent automatically to the
-holder of the lock, recording the breaker and a commentary requested from him.
-Thus, breaking locks is tolerated under certain circumstances,
-but will not go unnoticed.
-Experience has shown that the automatic mail message attaches a high enough
-stigma to lock breaking,
-such that programmers break locks only in real emergencies,
-or when a co-worker resigns and leaves locked revisions behind.
-.PP
-If an RCS file is private, i.e., when a programmer owns an RCS file
-and does not expect anyone else to perform check-in operations,
-locking is an unnecessary nuisance.
-In this case,
-the `strict locking feature' discussed earlier may be disabled,
-provided that file protection
-is set such that only the owner may write the RCS file.
-This has the effect that only the owner can check-in revisions,
-and that no lock is needed for doing so.
-.PP
-As added protection,
-each RCS file contains an access list that specifies the users
-who may execute update operations. If an access list is empty,
-only normal UNIX file protection applies. Thus, the access list is
-useful for restricting the set of people who would otherwise have update
-permission. Just as with locking, the access list
-has no effect on read-only operations such as \fIco\fR. This approach
-is consistent with the UNIX philosophy of openness, which contributes
-to a productive software development environment.
-.NH
-Configuration Management
-.PP
-The preceding sections described how RCS deals with revisions of individual
-components; this section discusses how to handle configurations.
-A configuration is a set of revisions, where each revision comes
-from a different revision group, and the revisions are selected
-according to a certain criterion.
-For example,
-in order to build a functioning compiler, the `right'
-revisions from the scanner, the parser, the optimizer
-and the code generator must be combined.
-RCS, in conjunction with MAKE,
-provides a number of facilities to effect a smooth selection.
-.NH 2
-RCS Selection Functions
-.PP
-.IP "\fIDefault selection\fR"
-.sp 0
-During development, the usual selection criterion is to choose
-the latest revision of all components. The \fIco\fR command
-makes this selection by default. For example, the command
-.D(
-co *,v
-.D)
-retrieves the latest revision on the default branch of each RCS file
-in the current directory.
-The default branch is usually the trunk, but may be
-set to be a side branch.
-Side branches as defaults are needed in distributed software development,
-as discussed in the section on the RCS revision tree.
-.sp
-.IP "\fIRelease based selection\fR"
-.sp 0
-Specifying a release or branch number selects the latest revision in
-that release or branch.
-For instance,
-.D(
-co \-r2 *,v
-.D)
-retrieves the latest revision with release number 2 from each RCS file.
-This selection is convenient if a release has been completed and
-development has moved on to the next release.
-.sp
-.IP "\fIState and author based selection\fR"
-.sp 0
-If the highest level number within a given release number
-is not the desired one,
-the state attribute can help. For example,
-.D(
-co \-r2 \-sReleased *,v
-.D)
-retrieves the latest revision with release number 2 whose state attribute
-is `Released'.
-Of course, the state attribute has to be set appropriately, using the
-\fIci\fR or \fIrcs\fR commands.
-Another alternative is to select a revision by its author,
-using the \fI\-w\fR option.
-.sp
-.IP "\fIDate based selection\fR"
-.sp 0
-Revisions may also be selected by date.
-Suppose a release of an entire system was
-completed and current on March 4, at 1:00 p.m. local time. Then the command
-.D(
-co \-d'March 4, 1:00 pm LT' *,v
-.D)
-checks out all the components of that release, independent of the numbering.
-The \fI\-d\fR option specifies a `cutoff date', i.e.,
-the revision selected has a check-in date that
-is closest to, but not after the date given.
-.IP "\fIName based selection\fR"
-.sp 0
-The most powerful selection function is based on assigning symbolic
-names to revisions and branches.
-In large systems, a single release number or date is not sufficient
-to collect the appropriate revisions from all groups.
-For example, suppose one wishes to combine release 2
-of one subsystem and release 15 of another.
-Most likely, the creation dates of those releases differ also.
-Thus, a single revision number or date passed to the \fIco\fR command
-will not suffice to select the right revisions.
-Symbolic revision numbers solve this problem.
-Each RCS file may contain a set of symbolic names that are mapped
-to numeric revision numbers. For example, assume
-the symbol \fIV3\fR is bound to release number 2 in file \fIs,v\fR, and to
-revision number 15.9 in \fIt,v\fR.
-Then the single command
-.D(
-co \-rV3 s,v t,v
-.D)
-retrieves the latest revision of release 2 from \fIs,v\fR,
-and revision 15.9 from \fIt,v\fR.
-In a large system with many modules, checking out all
-revisions with one command greatly simplifies configuration management.
-.PP
-Judicious use of symbolic revision numbers helps with organizing
-large configurations.
-A special command, \fIrcsfreeze\fR,
-assigns a symbolic revision number to a selected revision
-in every RCS file.
-\fIRcsfreeze\fR effectively freezes a configuration.
-The assigned symbolic revision number selects all components
-of the configuration.
-If necessary, symbolic numbers
-may even be intermixed with numeric ones. Thus, \fIV3.5\fR in the
-above example
-would select revision 2.5 in \fIs,v\fR and branch 15.9.5 in \fIt,v\fR.
-.PP
-The options \fI\-r\fR, \fI\-s\fR, \fI\-w\fR and \fI\-d\fR
-may be combined. If a branch is given, the latest revision
-on that branch satisfying all conditions is retrieved;
-otherwise, the default branch is used.
-.NH 2
-Combining MAKE and RCS
-.PP
-MAKE\u1\d
-is a program that processes configurations.
-It is driven by configuration specifications
-recorded in a special file, called a `Makefile'.
-MAKE avoids redundant processing steps
-by comparing creation dates of source and processed objects.
-For example, when instructed to compile all
-modules of a given system, it only recompiles
-those source modules that were changed
-since they were processed last.
-.PP
-MAKE has been extended with an auto-checkout feature for RCS.*
-.FS *
-This auto-checkout extension is available only in some versions of MAKE,
-e.g. GNU MAKE.
-.FE
-When a certain file to be processed is not present,
-MAKE attempts a check-out operation.
-If successful, MAKE performs the required processing, and then deletes
-the checked out file to conserve space.
-The selection parameters discussed above can be passed to MAKE
-either as parameters, or directly embedded in the Makefile.
-MAKE has also been extended to search the subdirectory named \fIRCS\fR
-for needed files, rather than just the current working directory.
-However, if a working file is present, MAKE totally ignores the corresponding
-RCS file and uses the working file.
-(In newer versions of MAKE distributed by AT&T and others,
-auto-checkout can be
-achieved with the rule DEFAULT, instead of a special extension of MAKE.
-However, a file checked out by the rule DEFAULT
-will not be deleted after processing. \fIRcsclean\fR can be
-used for that purpose.)
-.PP
-With auto-checkout, RCS/MAKE can effect a selection rule
-especially tuned for multi-person software development and maintenance.
-In these situations,
-programmers should obtain configurations that consist of
-the revisions they have personally checked out plus the latest
-checked in revision of all other revision groups.
-This schema can be set up as follows.
-.PP
-Each programmer chooses a working directory
-and places into it a symbolic link, named \fIRCS\fR,
-to the directory containing the relevant RCS files.
-The symbolic link makes sure that \fIco\fR and \fIci\fR
-operations need only specify the working files, and that
-the Makefile need not be changed.
-The programmer then checks out the needed files and modifies them.
-If MAKE is invoked,
-it composes configurations by selecting those
-revisions that are checked out, and the rest from the
-subdirectory \fIRCS\fR.
-The latter selection may be controlled by a symbolic
-revision number or any of the other selection criteria.
-If there are several programmers editing in separate working directories,
-they are insulated from each other's changes until checking in their
-modifications.
-.PP
-Similarly, a maintainer can recreate an older configuration
-by starting to work in an empty working directory.
-During the initial MAKE invocation, all revisions are selected from RCS files.
-As the maintainer checks out files and modifies them,
-a new configuration is gradually built up.
-Every time MAKE is invoked, it substitutes the modified revisions
-into the configuration being manipulated.
-.PP
-A final application of RCS is to use it for storing Makefiles.
-Revision groups of Makefiles represent
-multiple versions of configurations.
-Whenever a configuration is baselined or distributed,
-the best approach is to unambiguously fix
-the configuration with a symbolic revision number by calling
-\fIrcsfreeze\fR,
-to embed that symbol into the Makefile, and to
-check in the Makefile (using the same symbolic revision number).
-With this approach, old configurations
-can be regenerated easily and reliably.
-.NH
-Usage Statistics
-.PP
-The following usage statistics were collected on two DEC VAX-11/780
-computers of the Purdue Computer Science Department. Both machines
-are mainly used for research purposes. Thus, the data
-reflect an environment in which the majority of projects
-involve prototyping and advanced software development,
-but relatively little long-term maintenance.
-.PP
-For the first experiment,
-the \fIci\fR and \fIco\fR operations were instrumented
-to log the number of backward and forward deltas applied.
-The data were collected during a 13 month period
-from Dec. 1982 to Dec. 1983.
-Table I summarizes the results.
-.sp 0
-.nr VS 12p
-.vs 12p
-.TS
-center,box,tab(#);
-c|c|c|c|c s|c s
-c|c|c|c|c s|c s
-l|n|n|n|n n|n n.
-Operation#Total#Total deltas#Mean deltas#Operations#Branch
- #operations #applied#applied#with >1 delta#operations
-_
-co # 7867# 9320#1.18#509#(6%)#203#(3%)
-ci # 3468# 2207#0.64# 85#(2%)# 75#(2%)
-ci & co#11335#11527#1.02#594#(5%)#278#(2%)
-.TE
-.ce 1
-Table I. Statistics for \fIco\fR and \fIci\fR operations.
-.nr VS 18p
-.vs 18p
-.PP
-The first two lines show statistics for check-out and check-in;
-the third line shows the combination.
-Recall that \fIci\fR performs an implicit check-out to obtain
-a revision for computing the delta.
-In all measures presented, the most recent revision (stored intact)
-counts as one delta. The number of deltas applied represents
-the number of passes necessary, where the first `pass' is a copying step.
-.PP
-Note that the check-out operation is executed more than
-twice as frequently as the check-in operation.
-The fourth column gives the mean number of deltas
-applied in all three cases.
-For \fIci\fR, the mean number of deltas applied is less
-than one.
-The reasons are that the initial check-in requires no delta at all, and that
-the only time \fIci\fR requires more than one delta is for branches.
-Column 5 shows the actual number of operations that applied more than one
-delta.
-The last column indicates that branches were not used often.
-.PP
-The last three columns demonstrate that the most recent trunk revision
-is by far the most frequently accessed.
-For RCS, check-out of
-this revision is a simple copy operation, which is the absolute minimum
-given the copy-semantics of \fIco\fR.
-Access to older revisions and branches
-is more common in non-academic environments,
-yet even if access to older deltas were an order
-of magnitude more frequent,
-the combined average number of deltas applied would still be below 1.2.
-Since RCS is faster than SCCS until up to 10 delta applications,
-reverse deltas are clearly the method of choice.
-.PP
-The second experiment, conducted in March of 1984,
-involved surveying the existing RCS files
-on our two machines. The goal was to determine the mean number of
-revisions per RCS file, as well as the space consumed by them.
-Table II shows the results. (Tables I and II were produced at different
-times and are unrelated.)
-.sp 0
-.nr VS 12p
-.vs 12p
-.TS
-center,box,tab(#);
-c | c | c | c | c | c | c
-c | c | c | c | c | c | c
-l | n | n | n | n | n | n.
- #Total RCS#Total#Mean#Mean size of#Mean size of#Overhead
- #files#revisions#revisions#RCS files#revisions
-_
-All files #8033#11133#1.39#6156#5585#1.10
-Files with#1477# 4578#3.10#8074#6041#1.34
-\(>= 2 deltas
-.TE
-.ce 1
-Table II. Statistics for RCS files.
-.nr VS 18p
-.vs 18p
-.PP
-The mean number of revisions per RCS file is 1.39.
-Columns 5 and 6 show the mean sizes (in bytes) of an RCS file
-and of the latest revision of each RCS file, respectively.
-The `overhead' column contains the ratio of the mean sizes.
-Assuming that all revisions in an RCS file are approximately the same size,
-this ratio gives a measure of the space consumed by the extra revisions.
-.PP
-In our sample, over 80 per cent of the RCS files contained only a single revision.
-The reason is that our
-systems programmers routinely check in all source files
-on the distribution tapes, even though they may never touch them again.
-To get a better indication of how much space savings are possible
-with deltas, all measures with those files
-that contained 2 or more revisions were recomputed. Only for those files
-is RCS necessary.
-As shown in the second line, the average number of revisions for those files is
-3.10, with an overhead of 1.34. This means that the extra 2.10 deltas
-require 34 per cent extra space, or
-16 per cent per extra revision.
-Rochkind\u3\d
-measured the space consumed by SCCS, and
-reported an average of 5 revisions per group
-and an overhead of 1.37 (or about 9 per cent per extra revision).
-In a later paper, Glasser\u6\d
-observed an average of 7 revisions per group in a single, large project,
-but provided no overhead figure.
-In his paper on DSEE\u5\d,
-Leblang reported that delta storage combined with blank compression
-results in an overhead of a mere 1\-2 per cent per revision.
-Since leading blanks accounted for about 20 per cent of the surveyed Pascal
-programs, a revision group with 5\-10 members was smaller
-than a single cleartext copy.
-.PP
-The above observations demonstrate clearly that the space needed
-for extra revisions is small. With delta storage, the luxury of
-keeping multiple revisions online is certainly affordable.
-In fact, introducing a system with delta storage may reduce
-storage requirements, because programmers often save back-up copies
-anyway. Since back-up copies are stored much more efficiently with deltas,
-introducing a system such as RCS may
-actually free a considerable amount of space.
-.NH
-Survey of Version Control Tools
-.PP
-The need to keep back-up copies of software arose when
-programs and data were no longer stored on paper media, but were entered
-from terminals and stored on disk.
-Back-up copies are desirable for reliability, and many modern editors
-automatically save a back-up copy for every file touched.
-This strategy
-is valuable for short-term back-ups, but not suitable for long-term
-version control, since an existing back-up copy is overwritten whenever the
-corresponding file is edited.
-.PP
-Tape archives are suitable for long-term, offline storage.
-If all changed files are dumped on a back-up tape once per day, old revisions
-remain accessible. However, tape archives are unsatisfactory
-for version control in several ways. First, backing up the file
-system every 24 hours does not capture intermediate revisions.
-Secondly, the old revisions are not online,
-and accessing them is tedious and time-consuming.
-In particular, it is impractical to
-compare several old revisions of a group,
-because that may require mounting and searching several tapes.
-Tape archives are important fail-safe tools in the
-event of catastrophic disk failures or accidental deletions,
-but they are ill-suited for version control.
-Conversely, version control tools do not obviate the
-need for tape archives.
-.PP
-A natural technique for keeping several old revisions online is
-to never delete a file.
-Editing a file
-simply creates a new file with the same
-name, but with a different sequence number.
-This technique, available as an option in DEC's VMS operating system,
-turns out to be inadequate for version control.
-First, it is prohibitively expensive in terms of storage costs,
-especially since no data compression techniques are employed.
-Secondly, indiscriminately storing every change produces too many
-revisions, and programmers have difficulties distinguishing them.
-The proliferation of revisions forces programmers to spend much time on
-finding and deleting useless files.
-Thirdly, most of the support functions like locking, logging,
-revision selection,
-and identification described in this paper are not available.
-.PP
-An alternative approach is to separate editing from revision control.
-The user may repeatedly edit a given revision,
-until freezing it with an explicit command.
-Once a revision is frozen, it is stored permanently and can no longer be modified.
-(In RCS, freezing a revisions is done with \fIci\fR.)
-Editing a frozen revision implicitly creates a new one, which
-can again be changed repeatedly until it is frozen itself.
-This approach saves exactly those revisions that the user
-considers important, and keeps the number of revisions manageable.
-IBM's CLEAR/CASTER\u7\d,
-AT&T's SCCS\u3\d,
-CMU's SDC\u8\d
-and DEC's CMS\u9\d,
-are examples of version control systems using this approach.
-CLEAR/CASTER maintains a data base of programs, specifications,
-documentation and messages, using deltas.
-Its goal is to provide control over the development process from a
-management viewpoint.
-SCCS stores multiple revisions of source text in an ancestral tree,
-records a log entry for each revision,
-provides access control, and has facilities
-for uniquely identifying each revision.
-An efficient delta technique
-reduces the space consumed by each revision group.
-SDC is much simpler than SCCS because it stores not more than
-two revisions. However, it maintains a complete log for all old
-revisions, some of which may be on back-up tape.
-CMS, like SCCS, manages tree-structured revision groups,
-but offers no identification mechanism.
-.PP
-Tools for dealing with configurations are still in a state of flux.
-SCCS, SDC and CMS can be combined with MAKE or MAKE-like programs.
-Since flexible selection rules are missing from all these tools,
-it is sometimes difficult
-to specify precisely which revision of each group
-should be passed to MAKE for building a desired configuration.
-The Xerox Cedar system\u10\d
-provides a `System Modeller' that can rebuild
-a configuration from an arbitrary set of module revisions.
-The revisions of a module are only distinguished by creation time,
-and there is no tool for managing groups.
-Since the selection rules are primitive,
-the System Modeller appears to be somewhat tedious to use.
-Apollo's DSEE\u5\d
-is a sophisticated software engineering environment.
-It manages revision groups in a way similar to SCCS and CMS. Configurations
-are built using `configuration threads'.
-A configuration thread states which revision of each group
-named in a configuration should be chosen.
-A configuration thread may contain dynamic specifiers
-(e.g., `choose the revisions I am currently working on,
-and the most recent revisions otherwise'), which are bound
-automatically at build time.
-It also provides a notification mechanism for alerting
-maintainers about the need to rebuild a system after a change.
-.PP
-RCS is based on a general model for describing
-multi-version/multi-configuration systems\u11\d.
-The model describes systems using AND/OR graphs, where AND nodes represent
-configurations, and OR nodes represent version groups.
-The model gives rise to a suit of selection rules for
-composing configurations, almost all of which are implemented in RCS.
-The revisions selected by RCS are passed to MAKE for configuration building.
-Revision group management is modelled after SCCS.
-RCS retains SCCS's best features,
-but offers a significantly simpler user interface,
-flexible selection rules, adequate integration with MAKE
-and improved identification.
-A detailed comparison of RCS and SCCS appears in Reference 4.
-.PP
-An important component of all revision control systems
-is a program for computing deltas.
-SCCS and RCS use the program \fIdiff\fR\u2\d,
-which first computes the longest common substring of two
-revisions, and then produces the delta from that substring.
-The delta is simply an edit script consisting of deletion and
-insertion commands that generate one revision from the other.
-.PP
-A delta based on a longest common substring is not necessarily minimal,
-because it does not take advantage of crossing block moves.
-Crossing block moves arise if two or more blocks of lines
-(e.g., procedures)
-appear in a different order in two revisions.
-An edit script derived from a longest common substring
-first deletes the shorter of the two blocks, and then reinserts it.
-Heckel\u12\d
-proposed an algorithm for detecting block moves, but
-since the algorithm is based on heuristics,
-there are conditions
-under which the generated delta is far from minimal.
-DSEE uses this algorithm combined with blank compression,
-apparently with satisfactory overall results.
-A new algorithm that is guaranteed to produce a minimal delta based on
-block moves appears in Reference 13.
-A future release of RCS will use this algorithm.
-.PP
-\fIAcknowledgements\fR:
-Many people have helped make RCS a success by contributed criticisms, suggestions,
-corrections, and even whole new commands (including manual pages).
-The list of people is too long to be
-reproduced here, but my sincere thanks for their help and
-goodwill goes to all of them.
-.sp
-.nr VS 12p
-.vs 12p
-.SH
-Appendix: Synopsis of RCS Operations
-.LP
-.IP "\fIci\fP \fB\- check in revisions\fP"
-.sp 0
-\fICi\fR stores the contents of a working file into the
-corresponding RCS file as a new revision.
-If the RCS file doesn't exist, \fIci\fR creates it.
-\fICi\fR removes the working file, unless one of the options
-\fI\-u\fR or \fI\-l\fR is present.
-For each check-in, \fIci\fR asks for a commentary
-describing the changes relative to the previous revision.
-.sp 1
-\fICi\fR assigns the revision number given by the \fI\-r\fR option;
-if that option is missing, it derives the number from the
-lock held by the user; if there is no lock and locking is not strict,
-\fIci\fR increments the number of the latest revision on the trunk.
-A side branch can only be started by explicitly specifying its
-number with the \fI\-r\fR option during check-in.
-.sp 1
-\fICi\fR also determines
-whether the revision to be checked in is different from the
-previous one, and asks whether to proceed if not.
-This facility simplifies check-in operations for large systems,
-because one need not remember which files were changed.
-.sp 1
-The option \fI\-k\fR searches the checked in file for identification
-markers containing
-the attributes
-revision number, check-in date, author and state, and assigns these
-to the new revision rather than computing them. This option is
-useful for software distribution: Recipients of distributed software
-using RCS should check in updates with the \fI\-k\fR option.
-This convention guarantees that revision numbers, check-in dates,
-etc., are the same at all sites.
-.IP "\fIco\fP \fB\- check out revisions\fP"
-.sp 0
-\fICo\fR retrieves revisions according to revision number,
-date, author and state attributes. It either places the revision
-into the working file, or prints it on the standard output.
-\fICo\fR always expands the identification markers.
-.IP "\fIident\fP \fB\- extract identification markers\fP"
-.sp 0
-\fIIdent\fR extracts the identification markers expanded by \fIco\fR
-from any file and prints them.
-.IP "\fIrcs\fP \fB\- change RCS file attributes\fP"
-.sp 0
-\fIRcs\fR is an administrative operation that changes access lists,
-locks, unlocks, breaks locks, toggles the strict-locking feature,
-sets state attributes and symbolic revision numbers, changes the
-description, and deletes revisions. A revision can
-only be deleted if it is not the fork of a side branch.
-.br
-.ne 10
-.IP "\fIrcsclean\fP \fB\- clean working directory\fP"
-.sp 0
-\fIRcsclean\fR removes working files that were checked out but never changed.*
-.FS *
-The \fIrcsclean\fP and \fIrcsfreeze\fP commands
-are optional and are not always installed.
-.FE
-.IP "\fIrcsdiff\fP \fB\- compare revisions\fP"
-.sp 0
-\fIRcsdiff\fR compares two revisions and prints their
-difference, using the UNIX tool \fIdiff\fR.
-One of the revisions compared may be checked out.
-This command is useful for finding out about changes.
-.IP "\fIrcsfreeze\fP \fB\- freeze a configuration\fP"
-.sp 0
-\fIRcsfreeze\fR assigns the same symbolic revision number
-to a given revision in all RCS files.
-This command is useful for accurately recording a configuration.*
-.IP "\fIrcsmerge\fP \fB\- merge revisions\fP"
-.sp 0
-\fIRcsmerge\fR merges two revisions, \fIrev1\fR and \fIrev2\fR,
-with respect to a common ancestor.
-A 3-way file comparison determines the segments of lines that
-are (a) the same in all three revisions, or (b) the same in 2 revisions,
-or (c) different in all three. For all segments of type (b) where
-\fIrev1\fR is the differing revision,
-the segment in \fIrev1\fR replaces the corresponding segment of \fIrev2\fR.
-Type (c) indicates an overlapping change, is flagged as an error, and requires user
-intervention to select the correct alternative.
-.IP "\fIrlog\fP \fB\- read log messages\fP"
-.sp 0
-\fIRlog\fR prints the log messages and other information in an RCS file.
-.bp
-.LP
-.nr VS 12p
-.vs 12p
-.]<
-.ds [F 1
-.]-
-.ds [K FELD02
-.ds [K MakeArticle
-.ds [A Feldman, Stuart I.
-.ds [D March 1979
-.ds [T Make\*-A Program for Maintaining Computer Programs
-.ds [J Software\*-Practice & Experience
-.ds [V 9
-.ds [N 3
-.ds [P 255-265
-.nr [P 1
-.nr [T 0
-.nr [A 1
-.nr [O 0
-.][ 1 journal-article
-.ds [F 2
-.]-
-.ds [K HUNT01
-.ds [T An Algorithm for Differential File Comparison
-.ds [A Hunt, James W.
-.as [A " and McIlroy, M. D.
-.ds [I Computing Science Technical Report, Bell Laboratories
-.ds [R 41
-.ds [D June 1976
-.nr [T 0
-.nr [A 1
-.nr [O 0
-.][ 4 tech-report
-.ds [F 3
-.]-
-.ds [K SCCS
-.ds [A Rochkind, Marc J.
-.ds [D Dec. 1975
-.ds [T The Source Code Control System
-.ds [J IEEE Transactions on Software Engineering
-.ds [V SE-1
-.ds [N 4
-.ds [P 364-370
-.nr [P 1
-.nr [T 0
-.nr [A 1
-.nr [O 0
-.][ 1 journal-article
-.ds [F 4
-.]-
-.ds [K TICH08
-.ds [T Design, Implementation, and Evaluation of a Revision Control System
-.ds [A Tichy, Walter F.
-.ds [B Proceedings of the 6th International Conference on Software Engineering
-.ds [I ACM, IEEE, IPS, NBS
-.ds [D September 1982
-.ds [P 58-67
-.nr [P 1
-.nr [T 0
-.nr [A 1
-.nr [O 0
-.][ 3 article-in-book
-.ds [F 5
-.]-
-.ds [K LEBL01
-.ds [A Leblang, David B.
-.as [A " and Chase, Robert P.
-.ds [T Computer-Aided Software Engineering in a Distributed Workstation Environment
-.ds [O Proceedings of the ACM SIGSOFT/SIGPLAN Software Engineering Symposium
-.as [O " on Practical Software Development Environments.
-.ds [J SIGPLAN Notices
-.ds [V 19
-.ds [N 5
-.ds [D May 1984
-.ds [P 104-112
-.nr [P 1
-.nr [T 0
-.nr [A 1
-.nr [O 0
-.][ 1 journal-article
-.ds [F 1
-.ds [F 3
-.ds [F 6
-.]-
-.ds [K SCCSEval
-.ds [A Glasser, Alan L.
-.ds [D Nov. 1978
-.ds [T The Evolution of a Source Code Control System
-.ds [J Software Engineering Notes
-.ds [V 3
-.ds [N 5
-.ds [P 122-125
-.nr [P 1
-.ds [O Proceedings of the Software Quality and Assurance Workshop.
-.nr [T 0
-.nr [A 1
-.nr [O 1
-.][ 1 journal-article
-.ds [F 5
-.ds [F 7
-.]-
-.ds [K IBMClearCaster
-.ds [A Brown, H.B.
-.ds [D 1970
-.ds [T The Clear/Caster System
-.ds [J Nato Conference on Software Engineering, Rome
-.nr [T 0
-.nr [A 1
-.nr [O 0
-.][ 1 journal-article
-.ds [F 3
-.ds [F 8
-.]-
-.ds [K HabermannSDC
-.ds [A Habermann, A. Nico
-.ds [D Jan. 1979
-.ds [T A Software Development Control System
-.ds [I Technical Report, Carnegie-Mellon University, Department of Computer Science
-.nr [T 0
-.nr [A 0
-.nr [O 0
-.][ 2 book
-.ds [F 9
-.]-
-.ds [K CMS
-.ds [A DEC
-.ds [T Code Management System
-.ds [I Digital Equipment Corporation
-.ds [O Document No.\ EA-23134-82
-.ds [D 1982
-.nr [T 0
-.nr [A 0
-.nr [O 0
-.][ 2 book
-.ds [F 10
-.]-
-.ds [K LAMP01
-.ds [A Lampson, Butler W.
-.as [A " and Schmidt, Eric E.
-.ds [T Practical Use of a Polymorphic Applicative Language
-.ds [B Proceedings of the 10th Symposium on Principles of Programming Languages
-.ds [I ACM
-.ds [P 237-255
-.nr [P 1
-.ds [D January 1983
-.nr [T 0
-.nr [A 1
-.nr [O 0
-.][ 3 article-in-book
-.ds [F 5
-.ds [F 11
-.]-
-.ds [K TICH07
-.ds [T A Data Model for Programming Support Environments and its Application
-.ds [A Tichy, Walter F.
-.ds [B Automated Tools for Information System Design and Development
-.ds [E Hans-Jochen Schneider and Anthony I. Wasserman
-.ds [C Amsterdam
-.ds [I North-Holland Publishing Company
-.ds [D 1982
-.nr [T 0
-.nr [A 1
-.nr [O 0
-.][ 3 article-in-book
-.ds [F 4
-.ds [F 2
-.ds [F 12
-.]-
-.ds [K HECK01
-.ds [T A Technique for Isolating Differences Between Files
-.ds [A Heckel, Paul
-.ds [J Communications of the ACM
-.ds [D April 1978
-.ds [V 21
-.ds [N 4
-.ds [P 264-268
-.nr [P 1
-.nr [T 0
-.nr [A 0
-.nr [O 0
-.][ 1 journal-article
-.ds [F 13
-.]-
-.ds [K TICH11
-.ds [T The String-to-String Correction Problem with Block Moves
-.ds [A Tichy, Walter F.
-.ds [D Nov. 1984
-.ds [J ACM Transactions on Computer Systems
-.ds [V 2
-.ds [N 4
-.ds [P 309-321
-.nr [P 1
-.nr [T 0
-.nr [A 1
-.nr [O 0
-.][ 1 journal-article
-.]>
diff --git a/gnu/usr.bin/rcs/doc/rcs_func.ms b/gnu/usr.bin/rcs/doc/rcs_func.ms
deleted file mode 100644
index 9818086..0000000
--- a/gnu/usr.bin/rcs/doc/rcs_func.ms
+++ /dev/null
@@ -1,95 +0,0 @@
-.SH
-Functions of RCS (Revision Control System)
-.PP
-RCS manages software libraries. It greatly increases programmer productivity
-by providing the following functions.
-.IP 1.
-RCS stores and retrieves multiple revisions of program and other text.
-Thus, one can maintain one or more releases while developing the next
-release, with a minimum of space overhead. Changes no longer destroy the
-original -- previous revisions remain accessible.
-.RS
-.IP a.
-Maintains each module as a tree of revisions.
-.IP b.
-Project libraries can
-be organized centrally, decentralized, or any way you like.
-.IP c.
-RCS works for any type of text: programs, documentation, memos, papers,
-graphics, VLSI layouts, form letters, etc.
-.RE
-.IP 2.
-RCS maintains a complete history of changes.
-Thus, one can find out what happened to a module easily
-and quickly, without having to compare source listings or
-having to track down colleagues.
-.RS
-.IP a.
-RCS performs automatic record keeping.
-.IP b.
-RCS logs all changes automatically.
-.IP c.
-RCS guarantees project continuity.
-.RE
-.IP 3.
-RCS manages multiple lines of development.
-.IP 4.
-RCS can merge multiple lines of development.
-Thus, when several parallel lines of development must be consolidated
-into one line, the merging of changes is automatic.
-.IP 5.
-RCS flags coding conflicts.
-If two or more lines of development modify the same section of code,
-RCS can alert programmers about overlapping changes.
-.IP 6.
-RCS resolves access conflicts.
-When two or more programmers wish to modify the same revision,
-RCS alerts the programmers and makes sure that one modification won't wipe
-out the other one.
-.IP 7.
-RCS provides high-level retrieval functions.
-Revisions can be retrieved according to ranges of revision numbers,
-symbolic names, dates, authors, and states.
-.IP 8.
-RCS provides release and configuration control.
-Revisions can be marked as released, stable, experimental, etc.
-Configurations of modules can be described simply and directly.
-.IP 9.
-RCS performs automatic identification of modules with name, revision
-number, creation time, author, etc.
-Thus, it is always possible to determine which revisions of which
-modules make up a given configuration.
-.IP 10.
-Provides high-level management visibility.
-Thus, it is easy to track the status of a software project.
-.RS
-.IP a.
-RCS provides a complete change history.
-.IP b.
-RCS records who did what when to which revision of which module.
-.RE
-.IP 11.
-RCS is fully compatible with existing software development tools.
-RCS is unobtrusive -- its interface to the file system is such that
-all your existing software tools can be used as before.
-.IP 12.
-RCS' basic user interface is extremely simple. The novice need to learn
-only two commands. Its more sophisticated features have been
-tuned towards advanced software development environments and the
-experienced software professional.
-.IP 13.
-RCS simplifies software distribution if customers
-maintain sources with RCS also. This technique assures proper
-identification of versions and configurations, and tracking of customer
-modifications. Customer modifications can be merged into distributed
-versions locally or by the development group.
-.IP 14.
-RCS needs little extra space for the revisions (only the differences).
-If intermediate revisions are deleted, the corresponding
-differences are compressed into the shortest possible form.
-.IP 15.
-RCS is implemented with reverse deltas. This means that
-the latest revision, which is the one that is accessed most often,
-is stored intact. All others are regenerated from the latest one
-by applying reverse deltas (backward differences). This
-results in fast access time for the revision needed most often.
diff --git a/gnu/usr.bin/rcs/ident/Makefile b/gnu/usr.bin/rcs/ident/Makefile
deleted file mode 100644
index f28f8d3..0000000
--- a/gnu/usr.bin/rcs/ident/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG= ident
-SRCS= ident.c
-CFLAGS+= -I${.CURDIR}/../lib
-LDADD= ${LIBRCS}
-DPADD= ${LIBRCS}
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/rcs/ident/ident.1 b/gnu/usr.bin/rcs/ident/ident.1
deleted file mode 100644
index 004db3a..0000000
--- a/gnu/usr.bin/rcs/ident/ident.1
+++ /dev/null
@@ -1,182 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-.ds iD \\$3 \\$4 \\$5 \\$6 \\$7
-..
-.Id $Id$
-.ds r \&\s-1RCS\s0
-.ds u \&\s-1UTC\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.TH IDENT 1 \*(Dt GNU
-.SH NAME
-ident \- identify RCS keyword strings in files
-.SH SYNOPSIS
-.B ident
-[
-.B \-q
-] [
-.B \-V
-] [
-.I file
-\&.\|.\|. ]
-.SH DESCRIPTION
-.B ident
-searches for all instances of the pattern
-.BI $ keyword : "\ text\ " $
-in the named files or, if no files are named, the standard input.
-.PP
-These patterns are normally inserted automatically by the \*r command
-.BR co (1),
-but can also be inserted manually.
-The option
-.B \-q
-suppresses
-the warning given if there are no patterns in a file.
-The option
-.B \-V
-prints
-.BR ident 's
-version number.
-.PP
-.B ident
-works on text files as well as object files and dumps.
-For example, if the C program in
-.B f.c
-contains
-.IP
-.ft 3
-#include <stdio.h>
-.br
-static char const rcsid[] =
-.br
- \&"$\&Id: f.c,v \*(iD $\&";
-.br
-int main() { return printf(\&"%s\en\&", rcsid) == EOF; }
-.ft P
-.LP
-and
-.B f.c
-is compiled into
-.BR f.o ,
-then the command
-.IP
-.B "ident f.c f.o"
-.LP
-will output
-.nf
-.IP
-.ft 3
-f.c:
- $\&Id: f.c,v \*(iD $
-f.o:
- $\&Id: f.c,v \*(iD $
-.ft
-.fi
-.PP
-If a C program defines a string like
-.B rcsid
-above but does not use it,
-.BR lint (1)
-may complain, and some C compilers will optimize away the string.
-The most reliable solution is to have the program use the
-.B rcsid
-string, as shown in the example above.
-.PP
-.B ident
-finds all instances of the
-.BI $ keyword : "\ text\ " $
-pattern, even if
-.I keyword
-is not actually an \*r-supported keyword.
-This gives you information about nonstandard keywords like
-.BR $\&XConsortium$ .
-.SH KEYWORDS
-Here is the list of keywords currently maintained by
-.BR co (1).
-All times are given in Coordinated Universal Time (\*u,
-sometimes called \&\s-1GMT\s0) by default, but if the files
-were checked out with
-.BR co 's
-.BI \-z zone
-option, times are given with a numeric time zone indication appended.
-.TP
-.B $\&Author$
-The login name of the user who checked in the revision.
-.TP
-.B $\&Date$
-The date and time the revision was checked in.
-.TP
-.B $\&Header$
-A standard header containing the full pathname of the \*r file, the
-revision number, the date and time, the author, the state,
-and the locker (if locked).
-.TP
-.B $\&Id$
-Same as
-.BR $\&Header$ ,
-except that the \*r filename is without a path.
-.TP
-.B $\&Locker$
-The login name of the user who locked the revision (empty if not locked).
-.TP
-.B $\&Log$
-The log message supplied during checkin.
-For
-.BR ident 's
-purposes, this is equivalent to
-.BR $\&RCSfile$ .
-.TP
-.B $\&Name$
-The symbolic name used to check out the revision, if any.
-.TP
-.B $\&RCSfile$
-The name of the \*r file without a path.
-.TP
-.B $\&Revision$
-The revision number assigned to the revision.
-.TP
-.B $\&Source$
-The full pathname of the \*r file.
-.TP
-.B $\&State$
-The state assigned to the revision with the
-.B \-s
-option of
-.BR rcs (1)
-or
-.BR ci (1).
-.PP
-.BR co (1)
-represents the following characters in keyword values by escape sequences
-to keep keyword strings well-formed.
-.LP
-.RS
-.nf
-.ne 6
-.ta \w'newline 'u
-\f2char escape sequence\fP
-tab \f3\et\fP
-newline \f3\en\fP
-space \f3\e040
-$ \e044
-\e \e\e\fP
-.fi
-.RE
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1992, 1993 Paul Eggert.
-.SH "SEE ALSO"
-ci(1), co(1), rcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1), rlog(1),
-rcsfile(5)
-.br
-Walter F. Tichy,
-\*r\*-A System for Version Control,
-.I "Software\*-Practice & Experience"
-.BR 15 ,
-7 (July 1985), 637-654.
diff --git a/gnu/usr.bin/rcs/ident/ident.c b/gnu/usr.bin/rcs/ident/ident.c
deleted file mode 100644
index 2f1bbd4..0000000
--- a/gnu/usr.bin/rcs/ident/ident.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/* Identify RCS keyword strings in files. */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.9 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.8 1995/06/01 16:23:43 eggert
- * (exiterr, reportError): New functions, needed for DOS and OS/2 ports.
- * (scanfile): Use them.
- *
- * Revision 5.7 1994/03/20 04:52:58 eggert
- * Remove `exiting' from identExit.
- *
- * Revision 5.6 1993/11/09 17:40:15 eggert
- * Add -V.
- *
- * Revision 5.5 1993/11/03 17:42:27 eggert
- * Test for char == EOF, not char < 0.
- *
- * Revision 5.4 1992/01/24 18:44:19 eggert
- * lint -> RCS_lint
- *
- * Revision 5.3 1991/09/10 22:15:46 eggert
- * Open files with FOPEN_R, not FOPEN_R_WORK,
- * because they might be executables, not working files.
- *
- * Revision 5.2 1991/08/19 03:13:55 eggert
- * Report read errors immediately.
- *
- * Revision 5.1 1991/02/25 07:12:37 eggert
- * Don't report empty keywords. Check for I/O errors.
- *
- * Revision 5.0 1990/08/22 08:12:37 eggert
- * Don't limit output to known keywords.
- * Remove arbitrary limits and lint. Ansify and Posixate.
- *
- * Revision 4.5 89/05/01 15:11:54 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.4 87/10/23 17:09:57 narten
- * added exit(0) so exit return code would be non random
- *
- * Revision 4.3 87/10/18 10:23:55 narten
- * Updating version numbers. Changes relative to 1.1 are actually relative
- * to 4.1
- *
- * Revision 1.3 87/07/09 09:20:52 trinkle
- * Added check to make sure there is at least one arg before comparing argv[1]
- * with "-q". This necessary on machines that don't allow dereferncing null
- * pointers (i.e. Suns).
- *
- * Revision 1.2 87/03/27 14:21:47 jenkins
- * Port to suns
- *
- * Revision 4.1 83/05/10 16:31:02 wft
- * Added option -q and input from reading stdin.
- * Marker matching is now done with trymatch() (independent of keywords).
- *
- * Revision 3.4 83/02/18 17:37:49 wft
- * removed printing of new line after last file.
- *
- * Revision 3.3 82/12/04 12:48:55 wft
- * Added LOCKER.
- *
- * Revision 3.2 82/11/28 18:24:17 wft
- * removed Suffix; added ungetc to avoid skipping over trailing KDELIM.
- *
- * Revision 3.1 82/10/13 15:58:51 wft
- * fixed type of variables receiving from getc() (char-->int).
-*/
-
-#include "rcsbase.h"
-
-static int match P((FILE*));
-static int scanfile P((FILE*,char const*,int));
-static void reportError P((char const*));
-
-mainProg(identId, "ident", "$Id$")
-/* Ident searches the named files for all occurrences
- * of the pattern $@: text $ where @ is a keyword.
- */
-
-{
- FILE *fp;
- int quiet = 0;
- int status = EXIT_SUCCESS;
- char const *a;
-
- while ((a = *++argv) && *a=='-')
- while (*++a)
- switch (*a) {
- case 'q':
- quiet = 1;
- break;
-
- case 'V':
- VOID printf("RCS version %s\n", RCS_version_string);
- quiet = -1;
- break;
-
- default:
- VOID fprintf(stderr,
- "ident: usage: ident -{qV} [file...]\n"
- );
- exitmain(EXIT_FAILURE);
- break;
- }
-
- if (0 <= quiet)
- if (!a)
- VOID scanfile(stdin, (char*)0, quiet);
- else
- do {
- if (!(fp = fopen(a, FOPEN_RB))) {
- reportError(a);
- status = EXIT_FAILURE;
- } else if (
- scanfile(fp, a, quiet) != 0
- || (argv[1] && putchar('\n') == EOF)
- )
- break;
- } while ((a = *++argv));
-
- if (ferror(stdout) || fclose(stdout)!=0) {
- reportError("standard output");
- status = EXIT_FAILURE;
- }
- exitmain(status);
-}
-
-#if RCS_lint
-# define exiterr identExit
-#endif
- void
-exiterr()
-{
- _exit(EXIT_FAILURE);
-}
-
- static void
-reportError(s)
- char const *s;
-{
- int e = errno;
- VOID fprintf(stderr, "%s error: ", cmdid);
- errno = e;
- perror(s);
-}
-
-
- static int
-scanfile(file, name, quiet)
- register FILE *file;
- char const *name;
- int quiet;
-/* Function: scan an open file with descriptor file for keywords.
- * Return -1 if there's a write error; exit immediately on a read error.
- */
-{
- register int c;
-
- if (name) {
- VOID printf("%s:\n", name);
- if (ferror(stdout))
- return -1;
- } else
- name = "standard input";
- c = 0;
- while (c != EOF || ! (feof(file)|ferror(file))) {
- if (c == KDELIM) {
- if ((c = match(file)))
- continue;
- if (ferror(stdout))
- return -1;
- quiet = true;
- }
- c = getc(file);
- }
- if (ferror(file) || fclose(file) != 0) {
- reportError(name);
- /*
- * The following is equivalent to exit(EXIT_FAILURE), but we invoke
- * exiterr to keep lint happy. The DOS and OS/2 ports need exiterr.
- */
- VOID fflush(stderr);
- VOID fflush(stdout);
- exiterr();
- }
- if (!quiet)
- VOID fprintf(stderr, "%s warning: no id keywords in %s\n", cmdid, name);
- return 0;
-}
-
-
-
- static int
-match(fp) /* group substring between two KDELIM's; then do pattern match */
- register FILE *fp;
-{
- char line[BUFSIZ];
- register int c;
- register char * tp;
-
- tp = line;
- while ((c = getc(fp)) != VDELIM) {
- if (c == EOF && feof(fp) | ferror(fp))
- return c;
- switch (ctab[c]) {
- case LETTER: case Letter:
- *tp++ = c;
- if (tp < line+sizeof(line)-4)
- break;
- /* fall into */
- default:
- return c ? c : '\n'/* anything but 0 or KDELIM or EOF */;
- }
- }
- if (tp == line)
- return c;
- *tp++ = c;
- if ((c = getc(fp)) != ' ')
- return c ? c : '\n';
- *tp++ = c;
- while( (c = getc(fp)) != KDELIM ) {
- if (c == EOF && feof(fp) | ferror(fp))
- return c;
- switch (ctab[c]) {
- default:
- *tp++ = c;
- if (tp < line+sizeof(line)-2)
- break;
- /* fall into */
- case NEWLN: case UNKN:
- return c ? c : '\n';
- }
- }
- if (tp[-1] != ' ')
- return c;
- *tp++ = c; /*append trailing KDELIM*/
- *tp = '\0';
- VOID printf(" %c%s\n", KDELIM, line);
- return 0;
-}
diff --git a/gnu/usr.bin/rcs/lib/Makefile b/gnu/usr.bin/rcs/lib/Makefile
deleted file mode 100644
index d379232..0000000
--- a/gnu/usr.bin/rcs/lib/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# Define FSYNC_ALL to get slower but safer writes in case of crashes in
-# the middle of CVS/RCS changes
-#CFLAGS += -DFSYNC_ALL
-
-LIB = rcs
-SRCS = maketime.c partime.c rcsedit.c rcsfcmp.c rcsfnms.c rcsgen.c \
- rcskeep.c rcskeys.c rcslex.c rcsmap.c rcsrev.c rcssyn.c rcstime.c \
- rcsutil.c merger.c version.c
-
-NOPROFILE= noprofile
-INTERNALLIB= true
-INTERNALSTATICLIB= true
-
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/rcs/lib/conf.h b/gnu/usr.bin/rcs/lib/conf.h
deleted file mode 100644
index 907c9f8..0000000
--- a/gnu/usr.bin/rcs/lib/conf.h
+++ /dev/null
@@ -1,399 +0,0 @@
-/* RCS compile-time configuration */
-
- /* $Id$ */
-
-/*
- * This file is generated automatically.
- * If you edit it by hand your changes may be lost.
- * Instead, please try to fix conf.sh,
- * and send your fixes to rcs-bugs@cs.purdue.edu.
- */
-
-#define exitmain(n) return n /* how to exit from main() */
-/* #define _POSIX_C_SOURCE 2147483647L */ /* if strict C + Posix 1003.1b-1993 or later */
-/* #define _POSIX_SOURCE */ /* if strict C + Posix 1003.1-1990 */
-
-#include <errno.h>
-#include <stdio.h>
-#include <time.h>
-
-/* Comment out #include lines below that do not work. */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <limits.h>
-/* #include <mach/mach.h> */
-/* #include <net/errno.h> */
-#include <pwd.h>
-/* #include <siginfo.h> */
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-/* #include <ucontext.h> */
-#include <unistd.h>
-#include <utime.h>
-/* #include <vfork.h> */
-
-/* Define boolean symbols to be 0 (false, the default), or 1 (true). */
-#define has_sys_param_h 1 /* Does #include <sys/param.h> work? */
-/* extern int errno; */ /* Uncomment if <errno.h> doesn't declare errno. */
-#define has_readlink 1 /* Does readlink() work? */
-#define readlink_isreg_errno EINVAL /* errno after readlink on regular file */
-
-#if has_readlink && !defined(MAXSYMLINKS)
-# if has_sys_param_h
-# include <sys/param.h>
-# endif
-# ifndef MAXSYMLINKS
-# define MAXSYMLINKS 20 /* BSD; not standard yet */
-# endif
-#endif
-
-/* Comment out the typedefs below if the types are already declared. */
-/* Fix any uncommented typedefs that are wrong. */
-/* typedef int mode_t; */
-/* typedef long off_t; */
-/* typedef int pid_t; */
-/* typedef int sig_atomic_t; */
-/* typedef unsigned size_t; */
-/* typedef int ssize_t; */
-/* typedef long time_t; */
-/* typedef int uid_t; */
-
-/* Comment out the keyword definitions below if the keywords work. */
-/* #define const */
-/* #define volatile */
-
-/* Define boolean symbols to be 0 (false, the default), or 1 (true). */
-#define has_prototypes 1 /* Do function prototypes work? */
-#define has_stdarg 1 /* Does <stdarg.h> work? */
-/* #define has_varargs ? */ /* Does <varargs.h> work? */
-#define va_start_args 2 /* How many args does va_start() take? */
-
-#if O_BINARY
- /* Text and binary i/o behave differently. */
- /* This is incompatible with Posix and Unix. */
-# define FOPEN_RB "rb"
-# define FOPEN_R_WORK (Expand==BINARY_EXPAND ? "r" : "rb")
-# define FOPEN_WB "wb"
-# define FOPEN_W_WORK (Expand==BINARY_EXPAND ? "w" : "wb")
-# define FOPEN_WPLUS_WORK (Expand==BINARY_EXPAND ? "w+" : "w+b")
-# define OPEN_O_BINARY O_BINARY
-#else
- /*
- * Text and binary i/o behave the same.
- * Omit "b", since some nonstandard hosts reject it.
- */
-# define FOPEN_RB "r"
-# define FOPEN_R_WORK "r"
-# define FOPEN_WB "w"
-# define FOPEN_W_WORK "w"
-# define FOPEN_WPLUS_WORK "w+"
-# define OPEN_O_BINARY 0
-#endif
-
-/* This may need changing on non-Unix systems (notably DOS). */
-#define OPEN_CREAT_READONLY (S_IRUSR|S_IRGRP|S_IROTH) /* lock file mode */
-#define OPEN_O_LOCK 0 /* extra open flags for creating lock file */
-#define OPEN_O_WRONLY O_WRONLY /* main open flag for creating a lock file */
-
-/* Define or comment out the following symbols as needed. */
-#if has_prototypes
-# define P(params) params
-#else
-# define P(params) ()
-#endif
-#if has_stdarg
-# include <stdarg.h>
-#else
-# if has_varargs
-# include <varargs.h>
-# else
- typedef char *va_list;
-# define va_dcl int va_alist;
-# define va_start(ap) ((ap) = (va_list)&va_alist)
-# define va_arg(ap,t) (((t*) ((ap)+=sizeof(t))) [-1])
-# define va_end(ap)
-# endif
-#endif
-#if va_start_args == 2
-# define vararg_start va_start
-#else
-# define vararg_start(ap,p) va_start(ap)
-#endif
-#define bad_chmod_close 0 /* Can chmod() close file descriptors? */
-#define bad_creat0 0 /* Do writes fail after creat(f,0)? */
-#define bad_fopen_wplus 0 /* Does fopen(f,"w+") fail to truncate f? */
-#define getlogin_is_secure 0 /* Is getlogin() secure? Usually it's not. */
-#define has_attribute_noreturn 1 /* Does __attribute__((noreturn)) work? */
-#if has_attribute_noreturn
-# define exiting __attribute__((noreturn))
-#else
-# define exiting
-#endif
-#define has_dirent 1 /* Do opendir(), readdir(), closedir() work? */
-#define void_closedir 0 /* Does closedir() yield void? */
-#define has_fchmod 1 /* Does fchmod() work? */
-#define has_fflush_input 0 /* Does fflush() work on input files? */
-#define has_fputs 1 /* Does fputs() work? */
-#define has_ftruncate 1 /* Does ftruncate() work? */
-#define has_getuid 1 /* Does getuid() work? */
-#define has_getpwuid 1 /* Does getpwuid() work? */
-#define has_memcmp 1 /* Does memcmp() work? */
-#define has_memcpy 1 /* Does memcpy() work? */
-#define has_memmove 1 /* Does memmove() work? */
-#define has_map_fd 0 /* Does map_fd() work? */
-#define has_mmap 1 /* Does mmap() work on regular files? */
-#define has_madvise 0 /* Does madvise() work? */
-#define mmap_signal SIGBUS /* signal received if you reference nonexistent part of mmapped file */
-#define has_rename 1 /* Does rename() work? */
-#define bad_a_rename 0 /* Does rename(A,B) fail if A is unwritable? */
-#define bad_b_rename 0 /* Does rename(A,B) fail if B is unwritable? */
-#define bad_NFS_rename 0 /* Can rename(A,B) falsely report success? */
-/* typedef int void; */ /* Some ancient compilers need this. */
-#define VOID (void) /* 'VOID e;' discards the value of an expression 'e'. */
-#define has_seteuid 1 /* Does seteuid() work? See ../INSTALL.RCS. */
-#define has_setreuid 0 /* Does setreuid() work? See ../INSTALL.RCS. */
-#define has_setuid 1 /* Does setuid() exist? */
-#define has_sigaction 1 /* Does struct sigaction work? */
-#define has_sa_sigaction 0 /* Does struct sigaction have sa_sigaction? */
-#define has_signal 1 /* Does signal() work? */
-#define signal_type void /* type returned by signal handlers */
-#define sig_zaps_handler 0 /* Must a signal handler reinvoke signal()? */
-/* #define has_sigblock ? */ /* Does sigblock() work? */
-/* #define sigmask(s) (1 << ((s)-1)) */ /* Yield mask for signal number. */
-typedef size_t fread_type; /* type returned by fread() and fwrite() */
-typedef size_t freadarg_type; /* type of their size arguments */
-typedef void *malloc_type; /* type returned by malloc() */
-#define has_getcwd 1 /* Does getcwd() work? */
-/* #define has_getwd ? */ /* Does getwd() work? */
-#define needs_getabsname 0 /* Must we define getabsname? */
-#define has_mktemp 1 /* Does mktemp() work? */
-#define has_NFS 1 /* Might NFS be used? */
-#define has_psiginfo 0 /* Does psiginfo() work? */
-#define has_psignal 1 /* Does psignal() work? */
-/* #define has_si_errno ? */ /* Does siginfo_t have si_errno? */
-/* #define has_sys_siglist ? */ /* Does sys_siglist[] work? */
-/* #define strchr index */ /* Use old-fashioned name for strchr()? */
-/* #define strrchr rindex */ /* Use old-fashioned name for strrchr()? */
-#define bad_unlink 0 /* Does unlink() fail on unwritable files? */
-#define has_vfork 1 /* Does vfork() work? */
-#define has_fork 1 /* Does fork() work? */
-#define has_spawn 0 /* Does spawn*() work? */
-#define has_waitpid 1 /* Does waitpid() work? */
-#define bad_wait_if_SIGCHLD_ignored 0 /* Does ignoring SIGCHLD break wait()? */
-#define RCS_SHELL "/bin/sh" /* shell to run RCS subprograms */
-#define has_printf_dot 1 /* Does "%.2d" print leading 0? */
-#define has_vfprintf 1 /* Does vfprintf() work? */
-#define has_attribute_format_printf 1 /* Does __attribute__((format(printf,N,N+1))) work? */
-#if has_attribute_format_printf
-# define printf_string(m, n) __attribute__((format(printf, m, n)))
-#else
-# define printf_string(m, n)
-#endif
-#if has_attribute_format_printf && has_attribute_noreturn
- /* Work around a bug in GCC 2.5.x. */
-# define printf_string_exiting(m, n) __attribute__((format(printf, m, n), noreturn))
-#else
-# define printf_string_exiting(m, n) printf_string(m, n) exiting
-#endif
-/* #define has__doprintf ? */ /* Does _doprintf() work? */
-/* #define has__doprnt ? */ /* Does _doprnt() work? */
-/* #undef EXIT_FAILURE */ /* Uncomment this if EXIT_FAILURE is broken. */
-#define large_memory 1 /* Can main memory hold entire RCS files? */
-#ifndef LONG_MAX
-#define LONG_MAX 2147483647L /* long maximum */
-#endif
-/* Do struct stat s and t describe the same file? Answer d if unknown. */
-#define same_file(s,t,d) ((s).st_ino==(t).st_ino && (s).st_dev==(t).st_dev)
-#define has_utimbuf 1 /* Does struct utimbuf work? */
-#define CO "/usr/bin/co" /* name of 'co' program */
-#define COMPAT2 0 /* Are version 2 files supported? */
-#define DIFF "/usr/bin/diff" /* name of 'diff' program */
-#define DIFF3 "/usr/bin/diff3" /* name of 'diff3' program */
-#define DIFF3_BIN 1 /* Is diff3 user-visible (not the /usr/lib auxiliary)? */
-#define DIFFFLAGS "-an" /* Make diff output suitable for RCS. */
-#define DIFF_L 1 /* Does diff -L work? */
-#define DIFF_SUCCESS 0 /* DIFF status if no differences are found */
-#define DIFF_FAILURE 1 /* DIFF status if differences are found */
-#define DIFF_TROUBLE 2 /* DIFF status if trouble */
-#define ED "/bin/ed" /* name of 'ed' program (used only if !DIFF3_BIN) */
-#define MERGE "/usr/bin/merge" /* name of 'merge' program */
-#define TMPDIR "/tmp" /* default directory for temporary files */
-#define SLASH '/' /* principal filename separator */
-#define SLASHes '/' /* `case SLASHes:' labels all filename separators */
-#define isSLASH(c) ((c) == SLASH) /* Is arg a filename separator? */
-#define ROOTPATH(p) isSLASH((p)[0]) /* Is p an absolute pathname? */
-#define X_DEFAULT ",v/" /* default value for -x option */
-#define SLASHSLASH_is_SLASH 1 /* Are // and / the same directory? */
-#define ALL_ABSOLUTE 1 /* Do all subprograms satisfy ROOTPATH? */
-#define DIFF_ABSOLUTE 1 /* Is ROOTPATH(DIFF) true? */
-#define SENDMAIL "/usr/sbin/sendmail" /* how to send mail */
-#define TZ_must_be_set 0 /* Must TZ be set for gmtime() to work? */
-
-
-
-/* Adjust the following declarations as needed. */
-
-
-/* The rest is for the benefit of non-standard, traditional hosts. */
-/* Don't bother to declare functions that in traditional hosts do not appear, */
-/* or are declared in .h files, or return int or void. */
-
-
-/* traditional BSD */
-
-#if has_sys_siglist && !defined(sys_siglist)
- extern char const * const sys_siglist[];
-#endif
-
-
-/* Posix (ISO/IEC 9945-1: 1990 / IEEE Std 1003.1-1990) */
-
-/* <fcntl.h> */
-#ifdef O_CREAT
-# define open_can_creat 1
-#else
-# define open_can_creat 0
-# define O_RDONLY 0
-# define O_WRONLY 1
-# define O_RDWR 2
-# define O_CREAT 01000
-# define O_TRUNC 02000
-#endif
-#ifndef O_EXCL
-#define O_EXCL 0
-#endif
-
-/* <sys/stat.h> */
-#ifndef S_IRUSR
-# ifdef S_IREAD
-# define S_IRUSR S_IREAD
-# else
-# define S_IRUSR 0400
-# endif
-# ifdef S_IWRITE
-# define S_IWUSR S_IWRITE
-# else
-# define S_IWUSR (S_IRUSR/2)
-# endif
-#endif
-#ifndef S_IRGRP
-# if has_getuid
-# define S_IRGRP (S_IRUSR / 0010)
-# define S_IWGRP (S_IWUSR / 0010)
-# define S_IROTH (S_IRUSR / 0100)
-# define S_IWOTH (S_IWUSR / 0100)
-# else
- /* single user OS -- not Posix or Unix */
-# define S_IRGRP 0
-# define S_IWGRP 0
-# define S_IROTH 0
-# define S_IWOTH 0
-# endif
-#endif
-#ifndef S_ISREG
-#define S_ISREG(n) (((n) & S_IFMT) == S_IFREG)
-#endif
-
-/* <sys/wait.h> */
-#ifndef WEXITSTATUS
-#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
-#undef WIFEXITED /* Avoid 4.3BSD incompatibility with Posix. */
-#endif
-#ifndef WIFEXITED
-#define WIFEXITED(stat_val) (((stat_val) & 0377) == 0)
-#endif
-#ifndef WTERMSIG
-#define WTERMSIG(stat_val) ((stat_val) & 0177)
-#undef WIFSIGNALED /* Avoid 4.3BSD incompatibility with Posix. */
-#endif
-#ifndef WIFSIGNALED
-#define WIFSIGNALED(stat_val) ((unsigned)(stat_val) - 1 < 0377)
-#endif
-
-/* <unistd.h> */
-char *getlogin P((void));
-#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-# define STDOUT_FILENO 1
-# define STDERR_FILENO 2
-#endif
-#if has_fork && !has_vfork
-# undef vfork
-# define vfork fork
-#endif
-#if has_getcwd || !has_getwd
- char *getcwd P((char*,size_t));
-#else
- char *getwd P((char*));
-#endif
-#if has_setuid && !has_seteuid
-# undef seteuid
-# define seteuid setuid
-#endif
-#if has_spawn
-# if ALL_ABSOLUTE
-# define spawn_RCS spawnv
-# else
-# define spawn_RCS spawnvp
-# endif
-#else
-# if ALL_ABSOLUTE
-# define exec_RCS execv
-# else
-# define exec_RCS execvp
-# endif
-#endif
-
-/* utime.h */
-#if !has_utimbuf
- struct utimbuf { time_t actime, modtime; };
-#endif
-
-
-/* Standard C library */
-
-/* <stdio.h> */
-#ifndef L_tmpnam
-#define L_tmpnam 32 /* power of 2 > sizeof("/usr/tmp/xxxxxxxxxxxxxxx") */
-#endif
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-#ifndef SEEK_CUR
-#define SEEK_CUR 1
-#endif
-#if has_mktemp
- char *mktemp P((char*)); /* traditional */
-#else
- char *tmpnam P((char*));
-#endif
-
-/* <stdlib.h> */
-char *getenv P((char const*));
-void _exit P((int)) exiting;
-void exit P((int)) exiting;
-malloc_type malloc P((size_t));
-malloc_type realloc P((malloc_type,size_t));
-#ifndef EXIT_FAILURE
-#define EXIT_FAILURE 1
-#endif
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS 0
-#endif
-
-/* <string.h> */
-char *strcpy P((char*,char const*));
-char *strchr P((char const*,int));
-char *strrchr P((char const*,int));
-void *memcpy P((void*,void const*,size_t));
-#if has_memmove
- void *memmove P((void*,void const*,size_t));
-#endif
-
-/* <time.h> */
-time_t time P((time_t*));
diff --git a/gnu/usr.bin/rcs/lib/maketime.c b/gnu/usr.bin/rcs/lib/maketime.c
deleted file mode 100644
index 697929d..0000000
--- a/gnu/usr.bin/rcs/lib/maketime.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/* Convert struct partime into time_t. */
-
-/* Copyright 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#if has_conf_h
-# include "conf.h"
-#else
-# ifdef __STDC__
-# define P(x) x
-# else
-# define const
-# define P(x) ()
-# endif
-# include <stdlib.h>
-# include <time.h>
-#endif
-
-#include "partime.h"
-#include "maketime.h"
-
-char const maketId[]
- = "$Id$";
-
-static int isleap P((int));
-static int month_days P((struct tm const*));
-static time_t maketime P((struct partime const*,time_t));
-
-/*
-* For maximum portability, use only localtime and gmtime.
-* Make no assumptions about the time_t epoch or the range of time_t values.
-* Avoid mktime because it's not universal and because there's no easy,
-* portable way for mktime to yield the inverse of gmtime.
-*/
-
-#define TM_YEAR_ORIGIN 1900
-
- static int
-isleap(y)
- int y;
-{
- return (y&3) == 0 && (y%100 != 0 || y%400 == 0);
-}
-
-static int const month_yday[] = {
- /* days in year before start of months 0-12 */
- 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
-};
-
-/* Yield the number of days in TM's month. */
- static int
-month_days(tm)
- struct tm const *tm;
-{
- int m = tm->tm_mon;
- return month_yday[m+1] - month_yday[m]
- + (m==1 && isleap(tm->tm_year + TM_YEAR_ORIGIN));
-}
-
-/*
-* Convert UNIXTIME to struct tm form.
-* Use gmtime if available and if !LOCALZONE, localtime otherwise.
-*/
- struct tm *
-time2tm(unixtime, localzone)
- time_t unixtime;
- int localzone;
-{
- struct tm *tm;
-# if TZ_must_be_set
- static char const *TZ;
- if (!TZ && !(TZ = getenv("TZ")))
- faterror("The TZ environment variable is not set; please set it to your timezone");
-# endif
- if (localzone || !(tm = gmtime(&unixtime)))
- tm = localtime(&unixtime);
- return tm;
-}
-
-/* Yield A - B, measured in seconds. */
- time_t
-difftm(a, b)
- struct tm const *a, *b;
-{
- int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
- int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
- int difference_in_day_of_year = a->tm_yday - b->tm_yday;
- int intervening_leap_days = (
- ((ay >> 2) - (by >> 2))
- - (ay/100 - by/100)
- + ((ay/100 >> 2) - (by/100 >> 2))
- );
- time_t difference_in_years = ay - by;
- time_t difference_in_days = (
- difference_in_years*365
- + (intervening_leap_days + difference_in_day_of_year)
- );
- return
- (
- (
- 24*difference_in_days
- + (a->tm_hour - b->tm_hour)
- )*60 + (a->tm_min - b->tm_min)
- )*60 + (a->tm_sec - b->tm_sec);
-}
-
-/*
-* Adjust time T by adding SECONDS. SECONDS must be at most 24 hours' worth.
-* Adjust only T's year, mon, mday, hour, min and sec members;
-* plus adjust wday if it is defined.
-*/
- void
-adjzone(t, seconds)
- register struct tm *t;
- long seconds;
-{
- /*
- * This code can be off by a second if SECONDS is not a multiple of 60,
- * if T is local time, and if a leap second happens during this minute.
- * But this bug has never occurred, and most likely will not ever occur.
- * Liberia, the last country for which SECONDS % 60 was nonzero,
- * switched to UTC in May 1972; the first leap second was in June 1972.
- */
- int leap_second = t->tm_sec == 60;
- long sec = seconds + (t->tm_sec - leap_second);
- if (sec < 0) {
- if ((t->tm_min -= (59-sec)/60) < 0) {
- if ((t->tm_hour -= (59-t->tm_min)/60) < 0) {
- t->tm_hour += 24;
- if (TM_DEFINED(t->tm_wday) && --t->tm_wday < 0)
- t->tm_wday = 6;
- if (--t->tm_mday <= 0) {
- if (--t->tm_mon < 0) {
- --t->tm_year;
- t->tm_mon = 11;
- }
- t->tm_mday = month_days(t);
- }
- }
- t->tm_min += 24 * 60;
- }
- sec += 24L * 60 * 60;
- } else
- if (60 <= (t->tm_min += sec/60))
- if (24 <= (t->tm_hour += t->tm_min/60)) {
- t->tm_hour -= 24;
- if (TM_DEFINED(t->tm_wday) && ++t->tm_wday == 7)
- t->tm_wday = 0;
- if (month_days(t) < ++t->tm_mday) {
- if (11 < ++t->tm_mon) {
- ++t->tm_year;
- t->tm_mon = 0;
- }
- t->tm_mday = 1;
- }
- }
- t->tm_min %= 60;
- t->tm_sec = (int) (sec%60) + leap_second;
-}
-
-/*
-* Convert TM to time_t, using localtime if LOCALZONE and gmtime otherwise.
-* Use only TM's year, mon, mday, hour, min, and sec members.
-* Ignore TM's old tm_yday and tm_wday, but fill in their correct values.
-* Yield -1 on failure (e.g. a member out of range).
-* Posix 1003.1-1990 doesn't allow leap seconds, but some implementations
-* have them anyway, so allow them if localtime/gmtime does.
-*/
- time_t
-tm2time(tm, localzone)
- struct tm *tm;
- int localzone;
-{
- /* Cache the most recent t,tm pairs; 1 for gmtime, 1 for localtime. */
- static time_t t_cache[2];
- static struct tm tm_cache[2];
-
- time_t d, gt;
- struct tm const *gtm;
- /*
- * The maximum number of iterations should be enough to handle any
- * combinations of leap seconds, time zone rule changes, and solar time.
- * 4 is probably enough; we use a bigger number just to be safe.
- */
- int remaining_tries = 8;
-
- /* Avoid subscript errors. */
- if (12 <= (unsigned)tm->tm_mon)
- return -1;
-
- tm->tm_yday = month_yday[tm->tm_mon] + tm->tm_mday
- - (tm->tm_mon<2 || ! isleap(tm->tm_year + TM_YEAR_ORIGIN));
-
- /* Make a first guess. */
- gt = t_cache[localzone];
- gtm = gt ? &tm_cache[localzone] : time2tm(gt,localzone);
-
- /* Repeatedly use the error from the guess to improve the guess. */
- while ((d = difftm(tm, gtm)) != 0) {
- if (--remaining_tries == 0)
- return -1;
- gt += d;
- gtm = time2tm(gt,localzone);
- }
- t_cache[localzone] = gt;
- tm_cache[localzone] = *gtm;
-
- /*
- * Check that the guess actually matches;
- * overflow can cause difftm to yield 0 even on differing times,
- * or tm may have members out of range (e.g. bad leap seconds).
- */
- if ( (tm->tm_year ^ gtm->tm_year)
- | (tm->tm_mon ^ gtm->tm_mon)
- | (tm->tm_mday ^ gtm->tm_mday)
- | (tm->tm_hour ^ gtm->tm_hour)
- | (tm->tm_min ^ gtm->tm_min)
- | (tm->tm_sec ^ gtm->tm_sec))
- return -1;
-
- tm->tm_wday = gtm->tm_wday;
- return gt;
-}
-
-/*
-* Check *PT and convert it to time_t.
-* If it is incompletely specified, use DEFAULT_TIME to fill it out.
-* Use localtime if PT->zone is the special value TM_LOCAL_ZONE.
-* Yield -1 on failure.
-* ISO 8601 day-of-year and week numbers are not yet supported.
-*/
- static time_t
-maketime(pt, default_time)
- struct partime const *pt;
- time_t default_time;
-{
- int localzone, wday;
- struct tm tm;
- struct tm *tm0 = 0;
- time_t r;
-
- tm0 = 0; /* Keep gcc -Wall happy. */
- localzone = pt->zone==TM_LOCAL_ZONE;
-
- tm = pt->tm;
-
- if (TM_DEFINED(pt->ymodulus) || !TM_DEFINED(tm.tm_year)) {
- /* Get tm corresponding to current time. */
- tm0 = time2tm(default_time, localzone);
- if (!localzone)
- adjzone(tm0, pt->zone);
- }
-
- if (TM_DEFINED(pt->ymodulus))
- tm.tm_year +=
- (tm0->tm_year + TM_YEAR_ORIGIN)/pt->ymodulus * pt->ymodulus;
- else if (!TM_DEFINED(tm.tm_year)) {
- /* Set default year, month, day from current time. */
- tm.tm_year = tm0->tm_year + TM_YEAR_ORIGIN;
- if (!TM_DEFINED(tm.tm_mon)) {
- tm.tm_mon = tm0->tm_mon;
- if (!TM_DEFINED(tm.tm_mday))
- tm.tm_mday = tm0->tm_mday;
- }
- }
-
- /* Convert from partime year (Gregorian) to Posix year. */
- tm.tm_year -= TM_YEAR_ORIGIN;
-
- /* Set remaining default fields to be their minimum values. */
- if (!TM_DEFINED(tm.tm_mon)) tm.tm_mon = 0;
- if (!TM_DEFINED(tm.tm_mday)) tm.tm_mday = 1;
- if (!TM_DEFINED(tm.tm_hour)) tm.tm_hour = 0;
- if (!TM_DEFINED(tm.tm_min)) tm.tm_min = 0;
- if (!TM_DEFINED(tm.tm_sec)) tm.tm_sec = 0;
-
- if (!localzone)
- adjzone(&tm, -pt->zone);
- wday = tm.tm_wday;
-
- /* Convert and fill in the rest of the tm. */
- r = tm2time(&tm, localzone);
-
- /* Check weekday. */
- if (r != -1 && TM_DEFINED(wday) && wday != tm.tm_wday)
- return -1;
-
- return r;
-}
-
-/* Parse a free-format date in SOURCE, yielding a Unix format time. */
- time_t
-str2time(source, default_time, default_zone)
- char const *source;
- time_t default_time;
- long default_zone;
-{
- struct partime pt;
-
- if (*partime(source, &pt))
- return -1;
- if (pt.zone == TM_UNDEFINED_ZONE)
- pt.zone = default_zone;
- return maketime(&pt, default_time);
-}
-
-#if TEST
-#include <stdio.h>
- int
-main(argc, argv) int argc; char **argv;
-{
- time_t default_time = time((time_t *)0);
- long default_zone = argv[1] ? atol(argv[1]) : 0;
- char buf[1000];
- while (fgets(buf, 1000, stdin)) {
- time_t t = str2time(buf, default_time, default_zone);
- printf("%s", asctime(gmtime(&t)));
- }
- return 0;
-}
-#endif
diff --git a/gnu/usr.bin/rcs/lib/maketime.h b/gnu/usr.bin/rcs/lib/maketime.h
deleted file mode 100644
index fbe1256..0000000
--- a/gnu/usr.bin/rcs/lib/maketime.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Yield time_t from struct partime yielded by partime. */
-
-/* Copyright 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#if defined(__STDC__) || has_prototypes
-# define __MAKETIME_P(x) x
-#else
-# define __MAKETIME_P(x) ()
-#endif
-
-struct tm *time2tm __MAKETIME_P((time_t,int));
-time_t difftm __MAKETIME_P((struct tm const *, struct tm const *));
-time_t str2time __MAKETIME_P((char const *, time_t, long));
-time_t tm2time __MAKETIME_P((struct tm *, int));
-void adjzone __MAKETIME_P((struct tm *, long));
diff --git a/gnu/usr.bin/rcs/lib/merger.c b/gnu/usr.bin/rcs/lib/merger.c
deleted file mode 100644
index abd7c9b..0000000
--- a/gnu/usr.bin/rcs/lib/merger.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/* three-way file merge internals */
-
-/* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#include "rcsbase.h"
-
-libId(mergerId, "$Id$")
-
- static char const *normalize_arg P((char const*,char**));
- static char const *
-normalize_arg(s, b)
- char const *s;
- char **b;
-/*
- * If S looks like an option, prepend ./ to it. Yield the result.
- * Set *B to the address of any storage that was allocated.
- */
-{
- char *t;
- if (*s == '-') {
- *b = t = testalloc(strlen(s) + 3);
- VOID sprintf(t, ".%c%s", SLASH, s);
- return t;
- } else {
- *b = 0;
- return s;
- }
-}
-
- int
-merge(tostdout, edarg, label, argv)
- int tostdout;
- char const *edarg;
- char const *const label[3];
- char const *const argv[3];
-/*
- * Do `merge [-p] EDARG -L l0 -L l1 -L l2 a0 a1 a2',
- * where TOSTDOUT specifies whether -p is present,
- * EDARG gives the editing type (e.g. "-A", or null for the default),
- * LABEL gives l0, l1 and l2, and ARGV gives a0, a1 and a2.
- * Yield DIFF_SUCCESS or DIFF_FAILURE.
- */
-{
- register int i;
- FILE *f;
- RILE *rt;
- char const *a[3], *t;
- char *b[3];
- int s;
-#if !DIFF3_BIN
- char const *d[2];
-#endif
-
- for (i=3; 0<=--i; )
- a[i] = normalize_arg(argv[i], &b[i]);
-
- if (!edarg)
- edarg = "-E";
-
-#if DIFF3_BIN
- t = 0;
- if (!tostdout)
- t = maketemp(0);
- s = run(
- -1, t,
- DIFF3, edarg, "-am",
- "-L", label[0],
- "-L", label[1],
- "-L", label[2],
- a[0], a[1], a[2], (char*)0
- );
- switch (s) {
- case DIFF_SUCCESS:
- break;
- case DIFF_FAILURE:
- warn("conflicts during merge");
- break;
- default:
- exiterr();
- }
- if (t) {
- if (!(f = fopenSafer(argv[0], "w")))
- efaterror(argv[0]);
- if (!(rt = Iopen(t, "r", (struct stat*)0)))
- efaterror(t);
- fastcopy(rt, f);
- Ifclose(rt);
- Ofclose(f);
- }
-#else
- for (i=0; i<2; i++)
- switch (run(
- -1, d[i]=maketemp(i),
- DIFF, a[i], a[2], (char*)0
- )) {
- case DIFF_FAILURE: case DIFF_SUCCESS: break;
- default: faterror("diff failed");
- }
- t = maketemp(2);
- s = run(
- -1, t,
- DIFF3, edarg, d[0], d[1], a[0], a[1], a[2],
- label[0], label[2], (char*)0
- );
- if (s != DIFF_SUCCESS) {
- s = DIFF_FAILURE;
- warn("overlaps or other problems during merge");
- }
- if (!(f = fopenSafer(t, "a+")))
- efaterror(t);
- aputs(tostdout ? "1,$p\n" : "w\n", f);
- Orewind(f);
- aflush(f);
- if (run(fileno(f), (char*)0, ED, "-", a[0], (char*)0))
- exiterr();
- Ofclose(f);
-#endif
-
- tempunlink();
- for (i=3; 0<=--i; )
- if (b[i])
- tfree(b[i]);
- return s;
-}
diff --git a/gnu/usr.bin/rcs/lib/partime.c b/gnu/usr.bin/rcs/lib/partime.c
deleted file mode 100644
index cb27bce..0000000
--- a/gnu/usr.bin/rcs/lib/partime.c
+++ /dev/null
@@ -1,701 +0,0 @@
-/* Parse a string, yielding a struct partime that describes it. */
-
-/* Copyright 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#if has_conf_h
-# include "conf.h"
-#else
-# ifdef __STDC__
-# define P(x) x
-# else
-# define const
-# define P(x) ()
-# endif
-# include <limits.h>
-# include <time.h>
-#endif
-
-#include <ctype.h>
-#undef isdigit
-#define isdigit(c) (((unsigned)(c)-'0') <= 9) /* faster than stock */
-
-#include "partime.h"
-
-char const partimeId[]
- = "$Id$";
-
-
-/* Lookup tables for names of months, weekdays, time zones. */
-
-#define NAME_LENGTH_MAXIMUM 4
-
-struct name_val {
- char name[NAME_LENGTH_MAXIMUM];
- int val;
-};
-
-
-static char const *parse_decimal P((char const*,int,int,int,int,int*,int*));
-static char const *parse_fixed P((char const*,int,int*));
-static char const *parse_pattern_letter P((char const*,int,struct partime*));
-static char const *parse_prefix P((char const*,struct partime*,int*));
-static char const *parse_ranged P((char const*,int,int,int,int*));
-static int lookup P((char const*,struct name_val const[]));
-static int merge_partime P((struct partime*, struct partime const*));
-static void undefine P((struct partime*));
-
-
-static struct name_val const month_names[] = {
- {"jan",0}, {"feb",1}, {"mar",2}, {"apr",3}, {"may",4}, {"jun",5},
- {"jul",6}, {"aug",7}, {"sep",8}, {"oct",9}, {"nov",10}, {"dec",11},
- {"", TM_UNDEFINED}
-};
-
-static struct name_val const weekday_names[] = {
- {"sun",0}, {"mon",1}, {"tue",2}, {"wed",3}, {"thu",4}, {"fri",5}, {"sat",6},
- {"", TM_UNDEFINED}
-};
-
-#define hr60nonnegative(t) ((t)/100 * 60 + (t)%100)
-#define hr60(t) ((t)<0 ? -hr60nonnegative(-(t)) : hr60nonnegative(t))
-#define zs(t,s) {s, hr60(t)}
-#define zd(t,s,d) zs(t, s), zs((t)+100, d)
-
-static struct name_val const zone_names[] = {
- zs(-1000, "hst"), /* Hawaii */
- zd(-1000,"hast","hadt"),/* Hawaii-Aleutian */
- zd(- 900,"akst","akdt"),/* Alaska */
- zd(- 800, "pst", "pdt"),/* Pacific */
- zd(- 700, "mst", "mdt"),/* Mountain */
- zd(- 600, "cst", "cdt"),/* Central */
- zd(- 500, "est", "edt"),/* Eastern */
- zd(- 400, "ast", "adt"),/* Atlantic */
- zd(- 330, "nst", "ndt"),/* Newfoundland */
- zs( 000, "utc"), /* Coordinated Universal */
- zs( 000, "cut"), /* " */
- zs( 000, "ut"), /* Universal */
- zs( 000, "z"), /* Zulu (required by ISO 8601) */
- zd( 000, "gmt", "bst"),/* Greenwich Mean, British Summer */
- zs( 000, "wet"), /* Western Europe */
- zs( 100, "met"), /* Middle Europe */
- zs( 100, "cet"), /* Central Europe */
- zs( 200, "eet"), /* Eastern Europe */
- zs( 530, "ist"), /* India */
- zd( 900, "jst", "jdt"),/* Japan */
- zd( 900, "kst", "kdt"),/* Korea */
- zd( 1200,"nzst","nzdt"),/* New Zealand */
- { "lt", 1 },
-#if 0
- /* The following names are duplicates or are not well attested. */
- zs(-1100, "sst"), /* Samoa */
- zs(-1000, "tht"), /* Tahiti */
- zs(- 930, "mqt"), /* Marquesas */
- zs(- 900, "gbt"), /* Gambier */
- zd(- 900, "yst", "ydt"),/* Yukon - name is no longer used */
- zs(- 830, "pit"), /* Pitcairn */
- zd(- 500, "cst", "cdt"),/* Cuba */
- zd(- 500, "ast", "adt"),/* Acre */
- zd(- 400, "wst", "wdt"),/* Western Brazil */
- zd(- 400, "ast", "adt"),/* Andes */
- zd(- 400, "cst", "cdt"),/* Chile */
- zs(- 300, "wgt"), /* Western Greenland */
- zd(- 300, "est", "edt"),/* Eastern South America */
- zs(- 300, "mgt"), /* Middle Greenland */
- zd(- 200, "fst", "fdt"),/* Fernando de Noronha */
- zs(- 100, "egt"), /* Eastern Greenland */
- zs(- 100, "aat"), /* Atlantic Africa */
- zs(- 100, "act"), /* Azores and Canaries */
- zs( 000, "wat"), /* West Africa */
- zs( 100, "cat"), /* Central Africa */
- zd( 100, "mez","mesz"),/* Mittel-Europaeische Zeit */
- zs( 200, "sat"), /* South Africa */
- zd( 200, "ist", "idt"),/* Israel */
- zs( 300, "eat"), /* East Africa */
- zd( 300, "ast", "adt"),/* Arabia */
- zd( 300, "msk", "msd"),/* Moscow */
- zd( 330, "ist", "idt"),/* Iran */
- zs( 400, "gst"), /* Gulf */
- zs( 400, "smt"), /* Seychelles & Mascarene */
- zd( 400, "esk", "esd"),/* Yekaterinburg */
- zd( 400, "bsk", "bsd"),/* Baku */
- zs( 430, "aft"), /* Afghanistan */
- zd( 500, "osk", "osd"),/* Omsk */
- zs( 500, "pkt"), /* Pakistan */
- zd( 500, "tsk", "tsd"),/* Tashkent */
- zs( 545, "npt"), /* Nepal */
- zs( 600, "bgt"), /* Bangladesh */
- zd( 600, "nsk", "nsd"),/* Novosibirsk */
- zs( 630, "bmt"), /* Burma */
- zs( 630, "cct"), /* Cocos */
- zs( 700, "ict"), /* Indochina */
- zs( 700, "jvt"), /* Java */
- zd( 700, "isk", "isd"),/* Irkutsk */
- zs( 800, "hkt"), /* Hong Kong */
- zs( 800, "pst"), /* Philippines */
- zs( 800, "sgt"), /* Singapore */
- zd( 800, "cst", "cdt"),/* China */
- zd( 800, "ust", "udt"),/* Ulan Bator */
- zd( 800, "wst", "wst"),/* Western Australia */
- zd( 800, "ysk", "ysd"),/* Yakutsk */
- zs( 900, "blt"), /* Belau */
- zs( 900, "mlt"), /* Moluccas */
- zd( 900, "vsk", "vsd"),/* Vladivostok */
- zd( 930, "cst", "cst"),/* Central Australia */
- zs( 1000, "gst"), /* Guam */
- zd( 1000, "gsk", "gsd"),/* Magadan */
- zd( 1000, "est", "est"),/* Eastern Australia */
- zd( 1100,"lhst","lhst"),/* Lord Howe */
- zd( 1100, "psk", "psd"),/* Petropavlovsk-Kamchatski */
- zs( 1100,"ncst"), /* New Caledonia */
- zs( 1130,"nrft"), /* Norfolk */
- zd( 1200, "ask", "asd"),/* Anadyr */
- zs( 1245,"nz-chat"), /* Chatham */
- zs( 1300, "tgt"), /* Tongatapu */
-#endif
- {"", -1}
-};
-
- static int
-lookup (s, table)
- char const *s;
- struct name_val const table[];
-/* Look for a prefix of S in TABLE, returning val for first matching entry. */
-{
- int j;
- char buf[NAME_LENGTH_MAXIMUM];
-
- for (j = 0; j < NAME_LENGTH_MAXIMUM; j++) {
- unsigned char c = *s++;
- buf[j] = isupper (c) ? tolower (c) : c;
- if (!isalpha (c))
- break;
- }
- for (; table[0].name[0]; table++)
- for (j = 0; buf[j] == table[0].name[j]; )
- if (++j == NAME_LENGTH_MAXIMUM || !table[0].name[j])
- goto done;
- done:
- return table[0].val;
-}
-
-
- static void
-undefine (t) struct partime *t;
-/* Set *T to ``undefined'' values. */
-{
- t->tm.tm_sec = t->tm.tm_min = t->tm.tm_hour = t->tm.tm_mday = t->tm.tm_mon
- = t->tm.tm_year = t->tm.tm_wday = t->tm.tm_yday
- = t->ymodulus = t->yweek
- = TM_UNDEFINED;
- t->zone = TM_UNDEFINED_ZONE;
-}
-
-/*
-* Array of patterns to look for in a date string.
-* Order is important: we look for the first matching pattern
-* whose values do not contradict values that we already know about.
-* See `parse_pattern_letter' below for the meaning of the pattern codes.
-*/
-static char const * const patterns[] = {
- /*
- * These traditional patterns must come first,
- * to prevent an ISO 8601 format from misinterpreting their prefixes.
- */
- "E_n_y", "x", /* RFC 822 */
- "E_n", "n_E", "n", "t:m:s_A", "t:m_A", "t_A", /* traditional */
- "y/N/D$", /* traditional RCS */
-
- /* ISO 8601:1988 formats, generalized a bit. */
- "y-N-D$", "4ND$", "Y-N$",
- "RND$", "-R=N$", "-R$", "--N=D$", "N=DT",
- "--N$", "---D$", "DT",
- "Y-d$", "4d$", "R=d$", "-d$", "dT",
- "y-W-X", "yWX", "y=W",
- "-r-W-X", "r-W-XT", "-rWX", "rWXT", "-W=X", "W=XT", "-W",
- "-w-X", "w-XT", "---X$", "XT", "4$",
- "T",
- "h:m:s$", "hms$", "h:m$", "hm$", "h$", "-m:s$", "-ms$", "-m$", "--s$",
- "Y", "Z",
-
- 0
-};
-
- static char const *
-parse_prefix (str, t, pi) char const *str; struct partime *t; int *pi;
-/*
-* Parse an initial prefix of STR, setting *T accordingly.
-* Return the first character after the prefix, or 0 if it couldn't be parsed.
-* Start with pattern *PI; if success, set *PI to the next pattern to try.
-* Set *PI to -1 if we know there are no more patterns to try;
-* if *PI is initially negative, give up immediately.
-*/
-{
- int i = *pi;
- char const *pat;
- unsigned char c;
-
- if (i < 0)
- return 0;
-
- /* Remove initial noise. */
- while (!isalnum (c = *str) && c != '-' && c != '+') {
- if (!c) {
- undefine (t);
- *pi = -1;
- return str;
- }
- str++;
- }
-
- /* Try a pattern until one succeeds. */
- while ((pat = patterns[i++]) != 0) {
- char const *s = str;
- undefine (t);
- do {
- if (!(c = *pat++)) {
- *pi = i;
- return s;
- }
- } while ((s = parse_pattern_letter (s, c, t)) != 0);
- }
-
- return 0;
-}
-
- static char const *
-parse_fixed (s, digits, res) char const *s; int digits, *res;
-/*
-* Parse an initial prefix of S of length DIGITS; it must be a number.
-* Store the parsed number into *RES.
-* Return the first character after the prefix, or 0 if it couldn't be parsed.
-*/
-{
- int n = 0;
- char const *lim = s + digits;
- while (s < lim) {
- unsigned d = *s++ - '0';
- if (9 < d)
- return 0;
- n = 10*n + d;
- }
- *res = n;
- return s;
-}
-
- static char const *
-parse_ranged (s, digits, lo, hi, res) char const *s; int digits, lo, hi, *res;
-/*
-* Parse an initial prefix of S of length DIGITS;
-* it must be a number in the range LO through HI.
-* Store the parsed number into *RES.
-* Return the first character after the prefix, or 0 if it couldn't be parsed.
-*/
-{
- s = parse_fixed (s, digits, res);
- return s && lo<=*res && *res<=hi ? s : 0;
-}
-
- static char const *
-parse_decimal (s, digits, lo, hi, resolution, res, fres)
- char const *s;
- int digits, lo, hi, resolution, *res, *fres;
-/*
-* Parse an initial prefix of S of length DIGITS;
-* it must be a number in the range LO through HI
-* and it may be followed by a fraction that is to be computed using RESOLUTION.
-* Store the parsed number into *RES; store the fraction times RESOLUTION,
-* rounded to the nearest integer, into *FRES.
-* Return the first character after the prefix, or 0 if it couldn't be parsed.
-*/
-{
- s = parse_fixed (s, digits, res);
- if (s && lo<=*res && *res<=hi) {
- int f = 0;
- if ((s[0]==',' || s[0]=='.') && isdigit ((unsigned char) s[1])) {
- char const *s1 = ++s;
- int num10 = 0, denom10 = 10, product;
- while (isdigit ((unsigned char) *++s))
- denom10 *= 10;
- s = parse_fixed (s1, s - s1, &num10);
- product = num10*resolution;
- f = (product + (denom10>>1)) / denom10;
- f -= f & (product%denom10 == denom10>>1); /* round to even */
- if (f < 0 || product/resolution != num10)
- return 0; /* overflow */
- }
- *fres = f;
- return s;
- }
- return 0;
-}
-
- char *
-parzone (s, zone) char const *s; long *zone;
-/*
-* Parse an initial prefix of S; it must denote a time zone.
-* Set *ZONE to the number of seconds east of GMT,
-* or to TM_LOCAL_ZONE if it is the local time zone.
-* Return the first character after the prefix, or 0 if it couldn't be parsed.
-*/
-{
- char sign;
- int hh, mm, ss;
- int minutesEastOfUTC;
- long offset, z;
-
- /*
- * The formats are LT, n, n DST, nDST, no, o
- * where n is a time zone name
- * and o is a time zone offset of the form [-+]hh[:mm[:ss]].
- */
- switch (*s) {
- case '-': case '+':
- z = 0;
- break;
-
- default:
- minutesEastOfUTC = lookup (s, zone_names);
- if (minutesEastOfUTC == -1)
- return 0;
-
- /* Don't bother to check rest of spelling. */
- while (isalpha ((unsigned char) *s))
- s++;
-
- /* Don't modify LT. */
- if (minutesEastOfUTC == 1) {
- *zone = TM_LOCAL_ZONE;
- return (char *) s;
- }
-
- z = minutesEastOfUTC * 60L;
-
- /* Look for trailing " DST". */
- if (
- (s[-1]=='T' || s[-1]=='t') &&
- (s[-2]=='S' || s[-2]=='s') &&
- (s[-3]=='D' || s[-3]=='t')
- )
- goto trailing_dst;
- while (isspace ((unsigned char) *s))
- s++;
- if (
- (s[0]=='D' || s[0]=='d') &&
- (s[1]=='S' || s[1]=='s') &&
- (s[2]=='T' || s[2]=='t')
- ) {
- s += 3;
- trailing_dst:
- *zone = z + 60*60;
- return (char *) s;
- }
-
- switch (*s) {
- case '-': case '+': break;
- default: return (char *) s;
- }
- }
- sign = *s++;
-
- if (!(s = parse_ranged (s, 2, 0, 23, &hh)))
- return 0;
- mm = ss = 0;
- if (*s == ':')
- s++;
- if (isdigit ((unsigned char) *s)) {
- if (!(s = parse_ranged (s, 2, 0, 59, &mm)))
- return 0;
- if (*s==':' && s[-3]==':' && isdigit ((unsigned char) s[1])) {
- if (!(s = parse_ranged (s + 1, 2, 0, 59, &ss)))
- return 0;
- }
- }
- if (isdigit ((unsigned char) *s))
- return 0;
- offset = (hh*60 + mm)*60L + ss;
- *zone = z + (sign=='-' ? -offset : offset);
- /*
- * ?? Are fractions allowed here?
- * If so, they're not implemented.
- */
- return (char *) s;
-}
-
- static char const *
-parse_pattern_letter (s, c, t) char const *s; int c; struct partime *t;
-/*
-* Parse an initial prefix of S, matching the pattern whose code is C.
-* Set *T accordingly.
-* Return the first character after the prefix, or 0 if it couldn't be parsed.
-*/
-{
- switch (c) {
- case '$': /* The next character must be a non-digit. */
- if (isdigit ((unsigned char) *s))
- return 0;
- break;
-
- case '-': case '/': case ':':
- /* These characters stand for themselves. */
- if (*s++ != c)
- return 0;
- break;
-
- case '4': /* 4-digit year */
- s = parse_fixed (s, 4, &t->tm.tm_year);
- break;
-
- case '=': /* optional '-' */
- s += *s == '-';
- break;
-
- case 'A': /* AM or PM */
- /*
- * This matches the regular expression [AaPp][Mm]?.
- * It must not be followed by a letter or digit;
- * otherwise it would match prefixes of strings like "PST".
- */
- switch (*s++) {
- case 'A': case 'a':
- if (t->tm.tm_hour == 12)
- t->tm.tm_hour = 0;
- break;
-
- case 'P': case 'p':
- if (t->tm.tm_hour != 12)
- t->tm.tm_hour += 12;
- break;
-
- default: return 0;
- }
- switch (*s) {
- case 'M': case 'm': s++; break;
- }
- if (isalnum (*s))
- return 0;
- break;
-
- case 'D': /* day of month [01-31] */
- s = parse_ranged (s, 2, 1, 31, &t->tm.tm_mday);
- break;
-
- case 'd': /* day of year [001-366] */
- s = parse_ranged (s, 3, 1, 366, &t->tm.tm_yday);
- t->tm.tm_yday--;
- break;
-
- case 'E': /* extended day of month [1-9, 01-31] */
- s = parse_ranged (s, (
- isdigit ((unsigned char) s[0]) &&
- isdigit ((unsigned char) s[1])
- ) + 1, 1, 31, &t->tm.tm_mday);
- break;
-
- case 'h': /* hour [00-23 followed by optional fraction] */
- {
- int frac;
- s = parse_decimal (s, 2, 0, 23, 60*60, &t->tm.tm_hour, &frac);
- t->tm.tm_min = frac / 60;
- t->tm.tm_sec = frac % 60;
- }
- break;
-
- case 'm': /* minute [00-59 followed by optional fraction] */
- s = parse_decimal (s, 2, 0, 59, 60, &t->tm.tm_min, &t->tm.tm_sec);
- break;
-
- case 'n': /* month name [e.g. "Jan"] */
- if (!TM_DEFINED (t->tm.tm_mon = lookup (s, month_names)))
- return 0;
- /* Don't bother to check rest of spelling. */
- while (isalpha ((unsigned char) *s))
- s++;
- break;
-
- case 'N': /* month [01-12] */
- s = parse_ranged (s, 2, 1, 12, &t->tm.tm_mon);
- t->tm.tm_mon--;
- break;
-
- case 'r': /* year % 10 (remainder in origin-0 decade) [0-9] */
- s = parse_fixed (s, 1, &t->tm.tm_year);
- t->ymodulus = 10;
- break;
-
- case_R:
- case 'R': /* year % 100 (remainder in origin-0 century) [00-99] */
- s = parse_fixed (s, 2, &t->tm.tm_year);
- t->ymodulus = 100;
- break;
-
- case 's': /* second [00-60 followed by optional fraction] */
- {
- int frac;
- s = parse_decimal (s, 2, 0, 60, 1, &t->tm.tm_sec, &frac);
- t->tm.tm_sec += frac;
- }
- break;
-
- case 'T': /* 'T' or 't' */
- switch (*s++) {
- case 'T': case 't': break;
- default: return 0;
- }
- break;
-
- case 't': /* traditional hour [1-9 or 01-12] */
- s = parse_ranged (s, (
- isdigit ((unsigned char) s[0]) && isdigit ((unsigned char) s[1])
- ) + 1, 1, 12, &t->tm.tm_hour);
- break;
-
- case 'w': /* 'W' or 'w' only (stands for current week) */
- switch (*s++) {
- case 'W': case 'w': break;
- default: return 0;
- }
- break;
-
- case 'W': /* 'W' or 'w', followed by a week of year [00-53] */
- switch (*s++) {
- case 'W': case 'w': break;
- default: return 0;
- }
- s = parse_ranged (s, 2, 0, 53, &t->yweek);
- break;
-
- case 'X': /* weekday (1=Mon ... 7=Sun) [1-7] */
- s = parse_ranged (s, 1, 1, 7, &t->tm.tm_wday);
- t->tm.tm_wday--;
- break;
-
- case 'x': /* weekday name [e.g. "Sun"] */
- if (!TM_DEFINED (t->tm.tm_wday = lookup (s, weekday_names)))
- return 0;
- /* Don't bother to check rest of spelling. */
- while (isalpha ((unsigned char) *s))
- s++;
- break;
-
- case 'y': /* either R or Y */
- if (
- isdigit ((unsigned char) s[0]) &&
- isdigit ((unsigned char) s[1]) &&
- !isdigit ((unsigned char) s[2])
- )
- goto case_R;
- /* fall into */
- case 'Y': /* year in full [4 or more digits] */
- {
- int len = 0;
- while (isdigit ((unsigned char) s[len]))
- len++;
- if (len < 4)
- return 0;
- s = parse_fixed (s, len, &t->tm.tm_year);
- }
- break;
-
- case 'Z': /* time zone */
- s = parzone (s, &t->zone);
- break;
-
- case '_': /* possibly empty sequence of non-alphanumerics */
- while (!isalnum (*s) && *s)
- s++;
- break;
-
- default: /* bad pattern */
- return 0;
- }
- return s;
-}
-
- static int
-merge_partime (t, u) struct partime *t; struct partime const *u;
-/*
-* If there is no conflict, merge into *T the additional information in *U
-* and return 0. Otherwise do nothing and return -1.
-*/
-{
-# define conflict(a,b) ((a) != (b) && TM_DEFINED (a) && TM_DEFINED (b))
- if (
- conflict (t->tm.tm_sec, u->tm.tm_sec) ||
- conflict (t->tm.tm_min, u->tm.tm_min) ||
- conflict (t->tm.tm_hour, u->tm.tm_hour) ||
- conflict (t->tm.tm_mday, u->tm.tm_mday) ||
- conflict (t->tm.tm_mon, u->tm.tm_mon) ||
- conflict (t->tm.tm_year, u->tm.tm_year) ||
- conflict (t->tm.tm_wday, u->tm.tm_yday) ||
- conflict (t->ymodulus, u->ymodulus) ||
- conflict (t->yweek, u->yweek) ||
- (
- t->zone != u->zone &&
- t->zone != TM_UNDEFINED_ZONE &&
- u->zone != TM_UNDEFINED_ZONE
- )
- )
- return -1;
-# undef conflict
-# define merge_(a,b) if (TM_DEFINED (b)) (a) = (b);
- merge_ (t->tm.tm_sec, u->tm.tm_sec)
- merge_ (t->tm.tm_min, u->tm.tm_min)
- merge_ (t->tm.tm_hour, u->tm.tm_hour)
- merge_ (t->tm.tm_mday, u->tm.tm_mday)
- merge_ (t->tm.tm_mon, u->tm.tm_mon)
- merge_ (t->tm.tm_year, u->tm.tm_year)
- merge_ (t->tm.tm_wday, u->tm.tm_yday)
- merge_ (t->ymodulus, u->ymodulus)
- merge_ (t->yweek, u->yweek)
-# undef merge_
- if (u->zone != TM_UNDEFINED_ZONE) t->zone = u->zone;
- return 0;
-}
-
- char *
-partime (s, t) char const *s; struct partime *t;
-/*
-* Parse a date/time prefix of S, putting the parsed result into *T.
-* Return the first character after the prefix.
-* The prefix may contain no useful information;
-* in that case, *T will contain only undefined values.
-*/
-{
- struct partime p;
-
- undefine (t);
- while (*s) {
- int i = 0;
- char const *s1;
- do {
- if (!(s1 = parse_prefix (s, &p, &i)))
- return (char *) s;
- } while (merge_partime (t, &p) != 0);
- s = s1;
- }
- return (char *) s;
-}
diff --git a/gnu/usr.bin/rcs/lib/partime.h b/gnu/usr.bin/rcs/lib/partime.h
deleted file mode 100644
index 5d3983f..0000000
--- a/gnu/usr.bin/rcs/lib/partime.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Parse a string, yielding a struct partime that describes it. */
-
-/* Copyright 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#define TM_UNDEFINED (-1)
-#define TM_DEFINED(x) (0 <= (x))
-
-#define TM_UNDEFINED_ZONE ((long) -24 * 60 * 60)
-#define TM_LOCAL_ZONE (TM_UNDEFINED_ZONE - 1)
-
-struct partime {
- /*
- * This structure describes the parsed time.
- * Only the following tm_* values in it are used:
- * sec, min, hour, mday, mon, year, wday, yday.
- * If TM_UNDEFINED(value), the parser never found the value.
- * The tm_year field is the actual year, not the year - 1900;
- * but see ymodulus below.
- */
- struct tm tm;
-
- /*
- * If !TM_UNDEFINED(ymodulus),
- * then tm.tm_year is actually modulo ymodulus.
- */
- int ymodulus;
-
- /*
- * Week of year, ISO 8601 style.
- * If TM_UNDEFINED(yweek), the parser never found yweek.
- * Weeks start on Mondays.
- * Week 1 includes Jan 4.
- */
- int yweek;
-
- /* Seconds east of UTC; or TM_LOCAL_ZONE or TM_UNDEFINED_ZONE. */
- long zone;
-};
-
-#if defined(__STDC__) || has_prototypes
-# define __PARTIME_P(x) x
-#else
-# define __PARTIME_P(x) ()
-#endif
-
-char *partime __PARTIME_P((char const *, struct partime *));
-char *parzone __PARTIME_P((char const *, long *));
diff --git a/gnu/usr.bin/rcs/lib/rcsbase.h b/gnu/usr.bin/rcs/lib/rcsbase.h
deleted file mode 100644
index 918f1b9..0000000
--- a/gnu/usr.bin/rcs/lib/rcsbase.h
+++ /dev/null
@@ -1,762 +0,0 @@
-/* RCS common definitions and data structures */
-
-#define RCSBASE "$Id: rcsbase.h,v 1.8 1997/02/22 15:47:33 peter Exp $"
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.20 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.19 1995/06/01 16:23:43 eggert
- * (SIZEABLE_PATH): Don't depend on PATH_MAX: it's not worth configuring.
- * (Ioffset_type,BINARY_EXPAND,MIN_UNEXPAND,MIN_UNCHANGED_EXPAND): New macros.
- * (maps_memory): New macro; replaces many instances of `has_mmap'.
- * (cacheptr): Renamed from cachetell.
- * (struct RILE): New alternate name for RILE; the type is now recursive.
- * (deallocate): New member for RILE, used for generic buffer deallocation.
- * (cacheunget_): No longer take a failure arg; just call Ierror on failure.
- * (struct rcslock): Renamed from struct lock, to avoid collisions with
- * system headers on some hosts. All users changed.
- * (basefilename): Renamed from basename, likewise.
- * (dirtpname): Remove; no longer external.
- * (dirlen, dateform): Remove; no longer used.
- * (cmpdate, fopenSafer, fdSafer, readAccessFilenameBuffer): New functions.
- * (zonelenmax): Increase to 9 for full ISO 8601 format.
- * (catchmmapints): Depend on has_NFS.
- *
- * Revision 5.18 1994/03/17 14:05:48 eggert
- * Add primitives for reading backwards from a RILE;
- * this is needed to go back and find the $Log prefix.
- * Specify subprocess input via file descriptor, not file name. Remove lint.
- *
- * Revision 5.17 1993/11/09 17:40:15 eggert
- * Move RCS-specific time handling into rcstime.c.
- * printf_string now takes two arguments, alas.
- *
- * Revision 5.16 1993/11/03 17:42:27 eggert
- * Don't arbitrarily limit the number of joins. Remove `nil'.
- * Add Name keyword. Don't discard ignored phrases.
- * Add support for merge -A vs -E, and allow up to three labels.
- * Improve quality of diagnostics and prototypes.
- *
- * Revision 5.15 1992/07/28 16:12:44 eggert
- * Statement macro names now end in _.
- *
- * Revision 5.14 1992/02/17 23:02:22 eggert
- * Add -T support. Work around NFS mmap SIGBUS problem.
- *
- * Revision 5.13 1992/01/24 18:44:19 eggert
- * Add support for bad_creat0. lint -> RCS_lint
- *
- * Revision 5.12 1992/01/06 02:42:34 eggert
- * while (E) ; -> while (E) continue;
- *
- * Revision 5.11 1991/10/07 17:32:46 eggert
- * Support piece tables even if !has_mmap.
- *
- * Revision 5.10 1991/09/24 00:28:39 eggert
- * Remove unexported functions.
- *
- * Revision 5.9 1991/08/19 03:13:55 eggert
- * Add piece tables and other tuneups, and NFS workarounds.
- *
- * Revision 5.8 1991/04/21 11:58:20 eggert
- * Add -x, RCSINIT, MS-DOS support.
- *
- * Revision 5.7 1991/02/28 19:18:50 eggert
- * Try setuid() if seteuid() doesn't work.
- *
- * Revision 5.6 1991/02/26 17:48:37 eggert
- * Support new link behavior. Move ANSI C / Posix declarations into conf.sh.
- *
- * Revision 5.5 1990/12/04 05:18:43 eggert
- * Use -I for prompts and -q for diagnostics.
- *
- * Revision 5.4 1990/11/01 05:03:35 eggert
- * Don't assume that builtins are functions; they may be macros.
- * Permit arbitrary data in logs.
- *
- * Revision 5.3 1990/09/26 23:36:58 eggert
- * Port wait() to non-Posix ANSI C hosts.
- *
- * Revision 5.2 1990/09/04 08:02:20 eggert
- * Don't redefine NAME_MAX, PATH_MAX.
- * Improve incomplete line handling. Standardize yes-or-no procedure.
- *
- * Revision 5.1 1990/08/29 07:13:53 eggert
- * Add -kkvl. Fix type typos exposed by porting. Clean old log messages too.
- *
- * Revision 5.0 1990/08/22 08:12:44 eggert
- * Adjust ANSI C / Posix support. Add -k, -V, setuid. Don't call access().
- * Remove compile-time limits; use malloc instead.
- * Ansify and Posixate. Add support for ISO 8859.
- * Remove snoop and v2 support.
- *
- * Revision 4.9 89/05/01 15:17:14 narten
- * botched previous USG fix
- *
- * Revision 4.8 89/05/01 14:53:05 narten
- * changed #include <strings.h> -> string.h for USG systems.
- *
- * Revision 4.7 88/11/08 15:58:45 narten
- * removed defs for functions loaded from libraries
- *
- * Revision 4.6 88/08/09 19:12:36 eggert
- * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
- *
- * Revision 4.5 87/12/18 17:06:41 narten
- * made removed BSD ifdef, now uses V4_2BSD
- *
- * Revision 4.4 87/10/18 10:29:49 narten
- * Updating version numbers
- * Changes relative to 1.1 are actually relative to 4.2
- *
- * Revision 1.3 87/09/24 14:02:25 narten
- * changes for lint
- *
- * Revision 1.2 87/03/27 14:22:02 jenkins
- * Port to suns
- *
- * Revision 4.2 83/12/20 16:04:20 wft
- * merged 3.6.1.1 and 4.1 (SMALLOG, logsize).
- * moved setting of STRICT_LOCKING to Makefile.
- * changed DOLLAR to UNKN (conflict with KDELIM).
- *
- * Revision 4.1 83/05/04 09:12:41 wft
- * Added markers Id and RCSfile.
- * Added Dbranch for default branches.
- *
- * Revision 3.6.1.1 83/12/02 21:56:22 wft
- * Increased logsize, added macro SMALLOG.
- *
- * Revision 3.6 83/01/15 16:43:28 wft
- * 4.2 prerelease
- *
- * Revision 3.6 83/01/15 16:43:28 wft
- * Replaced dbm.h with BYTESIZ, fixed definition of rindex().
- * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD.
- * Added macro DELNUMFORM to have uniform format for printing delta text nodes.
- * Added macro DELETE to mark deleted deltas.
- *
- * Revision 3.5 82/12/10 12:16:56 wft
- * Added two forms of DATEFORM, one using %02d, the other %.2d.
- *
- * Revision 3.4 82/12/04 20:01:25 wft
- * added LOCKER, Locker, and USG (redefinition of rindex).
- *
- * Revision 3.3 82/12/03 12:22:04 wft
- * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3,
- * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength
- * using NCPPN. Changed putc() to abort on write error.
- *
- * Revision 3.2 82/10/18 15:03:52 wft
- * added macro STRICT_LOCKING, removed RCSUMASK.
- * renamed JOINFILE[1,2] to JOINFIL[1,2].
- *
- * Revision 3.1 82/10/11 19:41:17 wft
- * removed NBPW, NBPC, NCPW.
- * added typdef int void to aid compiling
- */
-
-
-#include "conf.h"
-
-
-#define EXIT_TROUBLE DIFF_TROUBLE
-
-#ifdef _POSIX_PATH_MAX
-# define SIZEABLE_PATH _POSIX_PATH_MAX
-#else
-# define SIZEABLE_PATH 255 /* size of a large path; not a hard limit */
-#endif
-
-/* for traditional C hosts with unusual size arguments */
-#define Fread(p,s,n,f) fread(p, (freadarg_type)(s), (freadarg_type)(n), f)
-#define Fwrite(p,s,n,f) fwrite(p, (freadarg_type)(s), (freadarg_type)(n), f)
-
-
-/*
- * Parameters
- */
-
-/* backwards compatibility with old versions of RCS */
-#define VERSION_min 3 /* old output RCS format supported */
-#define VERSION_max 5 /* newest output RCS format supported */
-#ifndef VERSION_DEFAULT /* default RCS output format */
-# define VERSION_DEFAULT VERSION_max
-#endif
-#define VERSION(n) ((n) - VERSION_DEFAULT) /* internally, 0 is the default */
-
-#ifndef STRICT_LOCKING
-#define STRICT_LOCKING 1
-#endif
- /* 0 sets the default locking to non-strict; */
- /* used in experimental environments. */
- /* 1 sets the default locking to strict; */
- /* used in production environments. */
-
-#define yearlength 16 /* (good through AD 9,999,999,999,999,999) */
-#define datesize (yearlength+16) /* size of output of time2date */
-#define RCSTMPPREFIX '_' /* prefix for temp files in working dir */
-#define KDELIM '$' /* delimiter for keywords */
-#define VDELIM ':' /* separates keywords from values */
-#define DEFAULTSTATE "Exp" /* default state of revisions */
-
-
-
-#define true 1
-#define false 0
-
-
-/*
- * RILE - readonly file
- * declarecache; - declares local cache for RILE variable(s)
- * setupcache - sets up the local RILE cache, but does not initialize it
- * cache, uncache - caches and uncaches the local RILE;
- * (uncache,cache) is needed around functions that advance the RILE pointer
- * Igeteof_(f,c,s) - get a char c from f, executing statement s at EOF
- * cachegeteof_(c,s) - Igeteof_ applied to the local RILE
- * Iget_(f,c) - like Igeteof_, except EOF is an error
- * cacheget_(c) - Iget_ applied to the local RILE
- * cacheunget_(f,c,s) - read c backwards from cached f, executing s at BOF
- * Ifileno, Ioffset_type, Irewind, Itell - analogs to stdio routines
- *
- * By conventions, macros whose names end in _ are statements, not expressions.
- * Following such macros with `; else' results in a syntax error.
- */
-
-#define maps_memory (has_map_fd || has_mmap)
-
-#if large_memory
- typedef unsigned char const *Iptr_type;
- typedef struct RILE {
- Iptr_type ptr, lim;
- unsigned char *base; /* not Iptr_type for lint's sake */
- unsigned char *readlim;
- int fd;
-# if maps_memory
- void (*deallocate) P((struct RILE *));
-# else
- FILE *stream;
-# endif
- } RILE;
-# if maps_memory
-# define declarecache register Iptr_type ptr, lim
-# define setupcache(f) (lim = (f)->lim)
-# define Igeteof_(f,c,s) if ((f)->ptr==(f)->lim) s else (c)= *(f)->ptr++;
-# define cachegeteof_(c,s) if (ptr==lim) s else (c)= *ptr++;
-# else
- int Igetmore P((RILE*));
-# define declarecache register Iptr_type ptr; register RILE *rRILE
-# define setupcache(f) (rRILE = (f))
-# define Igeteof_(f,c,s) if ((f)->ptr==(f)->readlim && !Igetmore(f)) s else (c)= *(f)->ptr++;
-# define cachegeteof_(c,s) if (ptr==rRILE->readlim && !Igetmore(rRILE)) s else (c)= *ptr++;
-# endif
-# define uncache(f) ((f)->ptr = ptr)
-# define cache(f) (ptr = (f)->ptr)
-# define Iget_(f,c) Igeteof_(f,c,Ieof();)
-# define cacheget_(c) cachegeteof_(c,Ieof();)
-# define cacheunget_(f,c) (c)=(--ptr)[-1];
-# define Ioffset_type size_t
-# define Itell(f) ((f)->ptr - (f)->base)
-# define Irewind(f) ((f)->ptr = (f)->base)
-# define cacheptr() ptr
-# define Ifileno(f) ((f)->fd)
-#else
-# define RILE FILE
-# define declarecache register FILE *ptr
-# define setupcache(f) (ptr = (f))
-# define uncache(f)
-# define cache(f)
-# define Igeteof_(f,c,s) {if(((c)=getc(f))==EOF){testIerror(f);if(feof(f))s}}
-# define cachegeteof_(c,s) Igeteof_(ptr,c,s)
-# define Iget_(f,c) { if (((c)=getc(f))==EOF) testIeof(f); }
-# define cacheget_(c) Iget_(ptr,c)
-# define cacheunget_(f,c) if(fseek(ptr,-2L,SEEK_CUR))Ierror();else cacheget_(c)
-# define Ioffset_type long
-# define Itell(f) ftell(f)
-# define Ifileno(f) fileno(f)
-#endif
-
-/* Print a char, but abort on write error. */
-#define aputc_(c,o) { if (putc(c,o)==EOF) testOerror(o); }
-
-/* Get a character from an RCS file, perhaps copying to a new RCS file. */
-#define GETCeof_(o,c,s) { cachegeteof_(c,s) if (o) aputc_(c,o) }
-#define GETC_(o,c) { cacheget_(c) if (o) aputc_(c,o) }
-
-
-#define WORKMODE(RCSmode, writable) (((RCSmode)&(mode_t)~(S_IWUSR|S_IWGRP|S_IWOTH)) | ((writable)?S_IWUSR:0))
-/* computes mode of working file: same as RCSmode, but write permission */
-/* determined by writable */
-
-
-/* character classes and token codes */
-enum tokens {
-/* classes */ DELIM, DIGIT, IDCHAR, NEWLN, LETTER, Letter,
- PERIOD, SBEGIN, SPACE, UNKN,
-/* tokens */ COLON, ID, NUM, SEMI, STRING
-};
-
-#define SDELIM '@' /* the actual character is needed for string handling*/
-/* SDELIM must be consistent with ctab[], so that ctab[SDELIM]==SBEGIN.
- * there should be no overlap among SDELIM, KDELIM, and VDELIM
- */
-
-#define isdigit(c) (((unsigned)(c)-'0') <= 9) /* faster than ctab[c]==DIGIT */
-
-
-
-
-
-/***************************************
- * Data structures for the symbol table
- ***************************************/
-
-/* Buffer of arbitrary data */
-struct buf {
- char *string;
- size_t size;
-};
-struct cbuf {
- char const *string;
- size_t size;
-};
-
-/* Hash table entry */
-struct hshentry {
- char const * num; /* pointer to revision number (ASCIZ) */
- char const * date; /* pointer to date of checkin */
- char const * author; /* login of person checking in */
- char const * lockedby; /* who locks the revision */
- char const * state; /* state of revision (Exp by default) */
- char const * name; /* name (if any) by which retrieved */
- struct cbuf log; /* log message requested at checkin */
- struct branchhead * branches; /* list of first revisions on branches*/
- struct cbuf ig; /* ignored phrases in admin part */
- struct cbuf igtext; /* ignored phrases in deltatext part */
- struct hshentry * next; /* next revision on same branch */
- struct hshentry * nexthsh; /* next revision with same hash value */
- long insertlns;/* lines inserted (computed by rlog) */
- long deletelns;/* lines deleted (computed by rlog) */
- char selector; /* true if selected, false if deleted */
-};
-
-/* list of hash entries */
-struct hshentries {
- struct hshentries *rest;
- struct hshentry *first;
-};
-
-/* list element for branch lists */
-struct branchhead {
- struct hshentry * hsh;
- struct branchhead * nextbranch;
-};
-
-/* accesslist element */
-struct access {
- char const * login;
- struct access * nextaccess;
-};
-
-/* list element for locks */
-struct rcslock {
- char const * login;
- struct hshentry * delta;
- struct rcslock * nextlock;
-};
-
-/* list element for symbolic names */
-struct assoc {
- char const * symbol;
- char const * num;
- struct assoc * nextassoc;
-};
-
-
-#define mainArgs (argc,argv) int argc; char **argv;
-
-#if RCS_lint
-# define libId(name,rcsid)
-# define mainProg(name,cmd,rcsid) int name mainArgs
-#else
-# define libId(name,rcsid) char const name[] = rcsid;
-# define mainProg(n,c,i) char const Copyright[] = "Copyright 1982,1988,1989 Walter F. Tichy, Purdue CS\nCopyright 1990,1991,1992,1993,1994,1995 Paul Eggert", baseid[] = RCSBASE, cmdid[] = c; libId(n,i) int main P((int,char**)); int main mainArgs
-#endif
-
-/*
- * Markers for keyword expansion (used in co and ident)
- * Every byte must have class LETTER or Letter.
- */
-#define AUTHOR "Author"
-#define DATE "Date"
-#define HEADER "Header"
-#define IDH "Id"
-#define LOCKER "Locker"
-#define LOG "Log"
-#define NAME "Name"
-#define RCSFILE "RCSfile"
-#define REVISION "Revision"
-#define SOURCE "Source"
-#define STATE "State"
-#define CVSHEADER "CVSHeader"
-#define keylength 9 /* max length of any of the above keywords */
-
-enum markers { Nomatch, Author, Date, Header, Id,
- Locker, Log, Name, RCSfile, Revision, Source, State, CVSHeader,
- LocalId };
- /* This must be in the same order as rcskeys.c's Keyword[] array. */
-
-#define DELNUMFORM "\n\n%s\n%s\n"
-/* used by putdtext and scanlogtext */
-
-#define EMPTYLOG "*** empty log message ***" /* used by ci and rlog */
-
-/* main program */
-extern char const cmdid[];
-void exiterr P((void)) exiting;
-
-/* merge */
-int merge P((int,char const*,char const*const[3],char const*const[3]));
-
-/* rcsedit */
-#define ciklogsize 23 /* sizeof("checked in with -k by ") */
-extern FILE *fcopy;
-extern char const *resultname;
-extern char const ciklog[ciklogsize];
-extern int locker_expansion;
-RILE *rcswriteopen P((struct buf*,struct stat*,int));
-char const *makedirtemp P((int));
-char const *getcaller P((void));
-int addlock P((struct hshentry*,int));
-int addsymbol P((char const*,char const*,int));
-int checkaccesslist P((void));
-int chnamemod P((FILE**,char const*,char const*,int,mode_t,time_t));
-int donerewrite P((int,time_t));
-int dorewrite P((int,int));
-int expandline P((RILE*,FILE*,struct hshentry const*,int,FILE*,int));
-int findlock P((int,struct hshentry**));
-int setmtime P((char const*,time_t));
-void ORCSclose P((void));
-void ORCSerror P((void));
-void copystring P((void));
-void dirtempunlink P((void));
-void enterstring P((void));
-void finishedit P((struct hshentry const*,FILE*,int));
-void keepdirtemp P((char const*));
-void openfcopy P((FILE*));
-void snapshotedit P((FILE*));
-void xpandstring P((struct hshentry const*));
-#if has_NFS || bad_unlink
- int un_link P((char const*));
-#else
-# define un_link(s) unlink(s)
-#endif
-#if large_memory
- void edit_string P((void));
-# define editstring(delta) edit_string()
-#else
- void editstring P((struct hshentry const*));
-#endif
-
-/* rcsfcmp */
-int rcsfcmp P((RILE*,struct stat const*,char const*,struct hshentry const*));
-
-/* rcsfnms */
-#define bufautobegin(b) clear_buf(b)
-#define clear_buf(b) (VOID ((b)->string = 0, (b)->size = 0))
-extern FILE *workstdout;
-extern char *workname;
-extern char const *RCSname;
-extern char const *suffixes;
-extern int fdlock;
-extern struct stat RCSstat;
-RILE *rcsreadopen P((struct buf*,struct stat*,int));
-char *bufenlarge P((struct buf*,char const**));
-char const *basefilename P((char const*));
-char const *getfullRCSname P((void));
-char const *getfullCVSname P((void));
-char const *maketemp P((int));
-char const *rcssuffix P((char const*));
-int pairnames P((int,char**,RILE*(*)P((struct buf*,struct stat*,int)),int,int));
-struct cbuf bufremember P((struct buf*,size_t));
-void bufalloc P((struct buf*,size_t));
-void bufautoend P((struct buf*));
-void bufrealloc P((struct buf*,size_t));
-void bufscat P((struct buf*,char const*));
-void bufscpy P((struct buf*,char const*));
-void tempunlink P((void));
-
-/* rcsgen */
-extern int interactiveflag;
-extern struct buf curlogbuf;
-char const *buildrevision P((struct hshentries const*,struct hshentry*,FILE*,int));
-int getcstdin P((void));
-int putdtext P((struct hshentry const*,char const*,FILE*,int));
-int ttystdin P((void));
-int yesorno P((int,char const*,...)) printf_string(2,3);
-struct cbuf cleanlogmsg P((char*,size_t));
-struct cbuf getsstdin P((char const*,char const*,char const*,struct buf*));
-void putdesc P((int,char*));
-void putdftext P((struct hshentry const*,RILE*,FILE*,int));
-
-/* rcskeep */
-extern int prevkeys;
-extern struct buf prevauthor, prevdate, prevname, prevrev, prevstate;
-int getoldkeys P((RILE*));
-
-/* rcskeys */
-extern char const *Keyword[];
-extern enum markers LocalIdMode;
-enum markers trymatch P((char const*));
-void setRCSLocalId(char const *);
-void setIncExc(char const *);
-
-/* rcslex */
-extern FILE *foutptr;
-extern FILE *frewrite;
-extern RILE *finptr;
-extern char const *NextString;
-extern enum tokens nexttok;
-extern int hshenter;
-extern int nerror;
-extern int nextc;
-extern int quietflag;
-extern long rcsline;
-char const *getid P((void));
-void efaterror P((char const*)) exiting;
-void enfaterror P((int,char const*)) exiting;
-void fatcleanup P((int)) exiting;
-void faterror P((char const*,...)) printf_string_exiting(1,2);
-void fatserror P((char const*,...)) printf_string_exiting(1,2);
-void rcsfaterror P((char const*,...)) printf_string_exiting(1,2);
-void Ieof P((void)) exiting;
-void Ierror P((void)) exiting;
-void Oerror P((void)) exiting;
-char *checkid P((char*,int));
-char *checksym P((char*,int));
-int eoflex P((void));
-int getkeyopt P((char const*));
-int getlex P((enum tokens));
-struct cbuf getphrases P((char const*));
-struct cbuf savestring P((struct buf*));
-struct hshentry *getnum P((void));
-void Ifclose P((RILE*));
-void Izclose P((RILE**));
-void Lexinit P((void));
-void Ofclose P((FILE*));
-void Orewind P((FILE*));
-void Ozclose P((FILE**));
-void aflush P((FILE*));
-void afputc P((int,FILE*));
-void aprintf P((FILE*,char const*,...)) printf_string(2,3);
-void aputs P((char const*,FILE*));
-void checksid P((char*));
-void checkssym P((char*));
-void diagnose P((char const*,...)) printf_string(1,2);
-void eerror P((char const*));
-void eflush P((void));
-void enerror P((int,char const*));
-void error P((char const*,...)) printf_string(1,2);
-void fvfprintf P((FILE*,char const*,va_list));
-void getkey P((char const*));
-void getkeystring P((char const*));
-void nextlex P((void));
-void oflush P((void));
-void printstring P((void));
-void readstring P((void));
-void redefined P((int));
-void rcserror P((char const*,...)) printf_string(1,2);
-void rcswarn P((char const*,...)) printf_string(1,2);
-void testIerror P((FILE*));
-void testOerror P((FILE*));
-void warn P((char const*,...)) printf_string(1,2);
-void warnignore P((void));
-void workerror P((char const*,...)) printf_string(1,2);
-void workwarn P((char const*,...)) printf_string(1,2);
-#if has_madvise && has_mmap && large_memory
- void advise_access P((RILE*,int));
-# define if_advise_access(p,f,advice) if (p) advise_access(f,advice)
-#else
-# define advise_access(f,advice)
-# define if_advise_access(p,f,advice)
-#endif
-#if large_memory && maps_memory
- RILE *I_open P((char const*,struct stat*));
-# define Iopen(f,m,s) I_open(f,s)
-#else
- RILE *Iopen P((char const*,char const*,struct stat*));
-#endif
-#if !large_memory
- void testIeof P((FILE*));
- void Irewind P((RILE*));
-#endif
-
-/* rcsmap */
-extern enum tokens const ctab[];
-
-/* rcsrev */
-char *partialno P((struct buf*,char const*,int));
-char const *namedrev P((char const*,struct hshentry*));
-char const *tiprev P((void));
-int cmpdate P((char const*,char const*));
-int cmpnum P((char const*,char const*));
-int cmpnumfld P((char const*,char const*,int));
-int compartial P((char const*,char const*,int));
-int expandsym P((char const*,struct buf*));
-int fexpandsym P((char const*,struct buf*,RILE*));
-struct hshentry *genrevs P((char const*,char const*,char const*,char const*,struct hshentries**));
-int countnumflds P((char const*));
-void getbranchno P((char const*,struct buf*));
-
-/* rcssyn */
-/* These expand modes must agree with Expand_names[] in rcssyn.c. */
-#define KEYVAL_EXPAND 0 /* -kkv `$Keyword: value $' */
-#define KEYVALLOCK_EXPAND 1 /* -kkvl `$Keyword: value locker $' */
-#define KEY_EXPAND 2 /* -kk `$Keyword$' */
-#define VAL_EXPAND 3 /* -kv `value' */
-#define OLD_EXPAND 4 /* -ko use old string, omitting expansion */
-#define BINARY_EXPAND 5 /* -kb like -ko, but use binary mode I/O */
-#define MIN_UNEXPAND OLD_EXPAND /* min value for no logical expansion */
-#define MIN_UNCHANGED_EXPAND (OPEN_O_BINARY ? BINARY_EXPAND : OLD_EXPAND)
- /* min value guaranteed to yield an identical file */
-struct diffcmd {
- long
- line1, /* number of first line */
- nlines, /* number of lines affected */
- adprev, /* previous 'a' line1+1 or 'd' line1 */
- dafter; /* sum of previous 'd' line1 and previous 'd' nlines */
-};
-extern char const * Dbranch;
-extern struct access * AccessList;
-extern struct assoc * Symbols;
-extern struct cbuf Comment;
-extern struct cbuf Ignored;
-extern struct rcslock *Locks;
-extern struct hshentry * Head;
-extern int Expand;
-extern int StrictLocks;
-extern int TotalDeltas;
-extern char const *const expand_names[];
-extern char const
- Kaccess[], Kauthor[], Kbranch[], Kcomment[],
- Kdate[], Kdesc[], Kexpand[], Khead[], Klocks[], Klog[],
- Knext[], Kstate[], Kstrict[], Ksymbols[], Ktext[];
-void unexpected_EOF P((void)) exiting;
-int getdiffcmd P((RILE*,int,FILE*,struct diffcmd*));
-int str2expmode P((char const*));
-void getadmin P((void));
-void getdesc P((int));
-void gettree P((void));
-void ignorephrases P((char const*));
-void initdiffcmd P((struct diffcmd*));
-void putadmin P((void));
-void putstring P((FILE*,int,struct cbuf,int));
-void puttree P((struct hshentry const*,FILE*));
-
-/* rcstime */
-#define zonelenmax 9 /* maxiumum length of time zone string, e.g. "+12:34:56" */
-char const *date2str P((char const[datesize],char[datesize + zonelenmax]));
-time_t date2time P((char const[datesize]));
-void str2date P((char const*,char[datesize]));
-void time2date P((time_t,char[datesize]));
-void zone_set P((char const*));
-
-/* rcsutil */
-extern int RCSversion;
-FILE *fopenSafer P((char const*,char const*));
-char *cgetenv P((char const*));
-char *fstr_save P((char const*));
-char *str_save P((char const*));
-char const *getusername P((int));
-int fdSafer P((int));
-int getRCSINIT P((int,char**,char***));
-int run P((int,char const*,...));
-int runv P((int,char const*,char const**));
-malloc_type fremember P((malloc_type));
-malloc_type ftestalloc P((size_t));
-malloc_type testalloc P((size_t));
-malloc_type testrealloc P((malloc_type,size_t));
-#define ftalloc(T) ftnalloc(T,1)
-#define talloc(T) tnalloc(T,1)
-#if RCS_lint
- extern malloc_type lintalloc;
-# define ftnalloc(T,n) (lintalloc = ftestalloc(sizeof(T)*(n)), (T*)0)
-# define tnalloc(T,n) (lintalloc = testalloc(sizeof(T)*(n)), (T*)0)
-# define trealloc(T,p,n) (lintalloc = testrealloc((malloc_type)0, sizeof(T)*(n)), p)
-# define tfree(p)
-#else
-# define ftnalloc(T,n) ((T*) ftestalloc(sizeof(T)*(n)))
-# define tnalloc(T,n) ((T*) testalloc(sizeof(T)*(n)))
-# define trealloc(T,p,n) ((T*) testrealloc((malloc_type)(p), sizeof(T)*(n)))
-# define tfree(p) free((malloc_type)(p))
-#endif
-time_t now P((void));
-void awrite P((char const*,size_t,FILE*));
-void fastcopy P((RILE*,FILE*));
-void ffree P((void));
-void ffree1 P((char const*));
-void setRCSversion P((char const*));
-#if has_signal
- void catchints P((void));
- void ignoreints P((void));
- void restoreints P((void));
-#else
-# define catchints()
-# define ignoreints()
-# define restoreints()
-#endif
-#if has_mmap && large_memory
-# if has_NFS && mmap_signal
- void catchmmapints P((void));
- void readAccessFilenameBuffer P((char const*,unsigned char const*));
-# else
-# define catchmmapints()
-# endif
-#endif
-#if has_getuid
- uid_t ruid P((void));
-# define myself(u) ((u) == ruid())
-#else
-# define myself(u) true
-#endif
-#if has_setuid
- uid_t euid P((void));
- void nosetid P((void));
- void seteid P((void));
- void setrid P((void));
-#else
-# define nosetid()
-# define seteid()
-# define setrid()
-#endif
-
-/* version */
-extern char const RCS_version_string[];
diff --git a/gnu/usr.bin/rcs/lib/rcsedit.c b/gnu/usr.bin/rcs/lib/rcsedit.c
deleted file mode 100644
index e3f714b..0000000
--- a/gnu/usr.bin/rcs/lib/rcsedit.c
+++ /dev/null
@@ -1,1952 +0,0 @@
-/* RCS stream editor */
-
-/******************************************************************************
- * edits the input file according to a
- * script from stdin, generated by diff -n
- * performs keyword expansion
- ******************************************************************************
- */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.19 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.18 1995/06/01 16:23:43 eggert
- * (dirtpname): No longer external.
- * (do_link): Simplify logic.
- * (finisheditline, finishedit): Replace Iseek/Itell with what they stand for.
- * (fopen_update_truncate): Replace `#if' with `if'.
- * (keyreplace, makedirtemp): dirlen(x) -> basefilename(x)-x.
- *
- * (edit_string): Fix bug: if !large_memory, a bogus trailing `@' was output
- * at the end of incomplete lines.
- *
- * (keyreplace): Do not assume that seeking backwards
- * at the start of a file will fail; on some systems it succeeds.
- * Convert C- and Pascal-style comment starts to ` *' in comment leader.
- *
- * (rcswriteopen): Use fdSafer to get safer file descriptor.
- * Open RCS file with FOPEN_RB.
- *
- * (chnamemod): Work around bad_NFS_rename bug; don't ignore un_link result.
- * Fall back on chmod if fchmod fails, since it might be ENOSYS.
- *
- * (aflush): Move to rcslex.c.
- *
- * Revision 5.17 1994/03/20 04:52:58 eggert
- * Normally calculate the $Log prefix from context, not from RCS file.
- * Move setmtime here from rcsutil.c. Add ORCSerror. Remove lint.
- *
- * Revision 5.16 1993/11/03 17:42:27 eggert
- * Add -z. Add Name keyword. If bad_unlink, ignore errno when unlink fails.
- * Escape white space, $, and \ in keyword string file names.
- * Don't output 2 spaces between date and time after Log.
- *
- * Revision 5.15 1992/07/28 16:12:44 eggert
- * Some hosts have readlink but not ELOOP. Avoid `unsigned'.
- * Preserve dates more systematically. Statement macro names now end in _.
- *
- * Revision 5.14 1992/02/17 23:02:24 eggert
- * Add -T support.
- *
- * Revision 5.13 1992/01/24 18:44:19 eggert
- * Add support for bad_chmod_close, bad_creat0.
- *
- * Revision 5.12 1992/01/06 02:42:34 eggert
- * Add setmode parameter to chnamemod. addsymbol now reports changes.
- * while (E) ; -> while (E) continue;
- *
- * Revision 5.11 1991/11/03 01:11:44 eggert
- * Move the warning about link breaking to where they're actually being broken.
- *
- * Revision 5.10 1991/10/07 17:32:46 eggert
- * Support piece tables even if !has_mmap. Fix rare NFS bugs.
- *
- * Revision 5.9 1991/09/17 19:07:40 eggert
- * SGI readlink() yields ENXIO, not EINVAL, for nonlinks.
- *
- * Revision 5.8 1991/08/19 03:13:55 eggert
- * Add piece tables, NFS bug workarounds. Catch odd filenames. Tune.
- *
- * Revision 5.7 1991/04/21 11:58:21 eggert
- * Fix errno bugs. Add -x, RCSINIT, MS-DOS support.
- *
- * Revision 5.6 1991/02/25 07:12:40 eggert
- * Fix setuid bug. Support new link behavior. Work around broken "w+" fopen.
- *
- * Revision 5.5 1990/12/30 05:07:35 eggert
- * Fix report of busy RCS files when !defined(O_CREAT) | !defined(O_EXCL).
- *
- * Revision 5.4 1990/11/01 05:03:40 eggert
- * Permit arbitrary data in comment leaders.
- *
- * Revision 5.3 1990/09/11 02:41:13 eggert
- * Tune expandline().
- *
- * Revision 5.2 1990/09/04 08:02:21 eggert
- * Count RCS lines better. Improve incomplete line handling.
- *
- * Revision 5.1 1990/08/29 07:13:56 eggert
- * Add -kkvl.
- * Fix bug when getting revisions to files ending in incomplete lines.
- * Fix bug in comment leader expansion.
- *
- * Revision 5.0 1990/08/22 08:12:47 eggert
- * Don't require final newline.
- * Don't append "checked in with -k by " to logs,
- * so that checking in a program with -k doesn't change it.
- * Don't generate trailing white space for empty comment leader.
- * Remove compile-time limits; use malloc instead. Add -k, -V.
- * Permit dates past 1999/12/31. Make lock and temp files faster and safer.
- * Ansify and Posixate. Check diff's output.
- *
- * Revision 4.8 89/05/01 15:12:35 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.7 88/11/08 13:54:14 narten
- * misplaced semicolon caused infinite loop
- *
- * Revision 4.6 88/08/09 19:12:45 eggert
- * Shrink stdio code size; allow cc -R.
- *
- * Revision 4.5 87/12/18 11:38:46 narten
- * Changes from the 43. version. Don't know the significance of the
- * first change involving "rewind". Also, additional "lint" cleanup.
- * (Guy Harris)
- *
- * Revision 4.4 87/10/18 10:32:21 narten
- * Updating version numbers. Changes relative to version 1.1 actually
- * relative to 4.1
- *
- * Revision 1.4 87/09/24 13:59:29 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.3 87/09/15 16:39:39 shepler
- * added an initializatin of the variables editline and linecorr
- * this will be done each time a file is processed.
- * (there was an obscure bug where if co was used to retrieve multiple files
- * it would dump)
- * fix attributed to Roy Morris @FileNet Corp ...!felix!roy
- *
- * Revision 1.2 87/03/27 14:22:17 jenkins
- * Port to suns
- *
- * Revision 4.1 83/05/12 13:10:30 wft
- * Added new markers Id and RCSfile; added locker to Header and Id.
- * Overhauled expandline completely() (problem with $01234567890123456789@).
- * Moved trymatch() and marker table to rcskeys.c.
- *
- * Revision 3.7 83/05/12 13:04:39 wft
- * Added retry to expandline to resume after failed match which ended in $.
- * Fixed truncation problem for $19chars followed by@@.
- * Log no longer expands full path of RCS file.
- *
- * Revision 3.6 83/05/11 16:06:30 wft
- * added retry to expandline to resume after failed match which ended in $.
- * Fixed truncation problem for $19chars followed by@@.
- *
- * Revision 3.5 82/12/04 13:20:56 wft
- * Added expansion of keyword Locker.
- *
- * Revision 3.4 82/12/03 12:26:54 wft
- * Added line number correction in case editing does not start at the
- * beginning of the file.
- * Changed keyword expansion to always print a space before closing KDELIM;
- * Expansion for Header shortened.
- *
- * Revision 3.3 82/11/14 14:49:30 wft
- * removed Suffix from keyword expansion. Replaced fclose with ffclose.
- * keyreplace() gets log message from delta, not from curlogmsg.
- * fixed expression overflow in while(c=putc(GETC....
- * checked nil printing.
- *
- * Revision 3.2 82/10/18 21:13:39 wft
- * I added checks for write errors during the co process, and renamed
- * expandstring() to xpandstring().
- *
- * Revision 3.1 82/10/13 15:52:55 wft
- * changed type of result of getc() from char to int.
- * made keyword expansion loop in expandline() portable to machines
- * without sign-extension.
- */
-
-
-#include "rcsbase.h"
-
-libId(editId, "$Id: rcsedit.c,v 1.8 1997/02/22 15:47:35 peter Exp $")
-
-static void editEndsPrematurely P((void)) exiting;
-static void editLineNumberOverflow P((void)) exiting;
-static void escape_string P((FILE*,char const*));
-static void keyreplace P((enum markers,struct hshentry const*,int,RILE*,FILE*,int));
-
-FILE *fcopy; /* result file descriptor */
-char const *resultname; /* result pathname */
-int locker_expansion; /* should the locker name be appended to Id val? */
-#if !large_memory
- static RILE *fedit; /* edit file descriptor */
- static char const *editname; /* edit pathname */
-#endif
-static long editline; /* edit line counter; #lines before cursor */
-static long linecorr; /* #adds - #deletes in each edit run. */
- /*used to correct editline in case file is not rewound after */
- /* applying one delta */
-
-/* indexes into dirtpname */
-#define lockdirtp_index 0
-#define newRCSdirtp_index bad_creat0
-#define newworkdirtp_index (newRCSdirtp_index+1)
-#define DIRTEMPNAMES (newworkdirtp_index + 1)
-
-enum maker {notmade, real, effective};
-static struct buf dirtpname[DIRTEMPNAMES]; /* unlink these when done */
-static enum maker volatile dirtpmaker[DIRTEMPNAMES]; /* if these are set */
-#define lockname (dirtpname[lockdirtp_index].string)
-#define newRCSname (dirtpname[newRCSdirtp_index].string)
-
-
-#if has_NFS || bad_unlink
- int
-un_link(s)
- char const *s;
-/*
- * Remove S, even if it is unwritable.
- * Ignore unlink() ENOENT failures; NFS generates bogus ones.
- */
-{
-# if bad_unlink
- if (unlink(s) == 0)
- return 0;
- else {
- int e = errno;
- /*
- * Forge ahead even if errno == ENOENT; some completely
- * brain-damaged hosts (e.g. PCTCP 2.2) yield ENOENT
- * even for existing unwritable files.
- */
- if (chmod(s, S_IWUSR) != 0) {
- errno = e;
- return -1;
- }
- }
-# endif
-# if has_NFS
- return unlink(s)==0 || errno==ENOENT ? 0 : -1;
-# else
- return unlink(s);
-# endif
-}
-#endif
-
-#if !has_rename
-# if !has_NFS
-# define do_link(s,t) link(s,t)
-# else
- static int do_link P((char const*,char const*));
- static int
-do_link(s, t)
- char const *s, *t;
-/* Link S to T, ignoring bogus EEXIST problems due to NFS failures. */
-{
- int r = link(s, t);
-
- if (r != 0 && errno == EEXIST) {
- struct stat sb, tb;
- if (
- stat(s, &sb) == 0 &&
- stat(t, &tb) == 0 &&
- same_file(sb, tb, 0)
- )
- r = 0;
- errno = EEXIST;
- }
- return r;
-}
-# endif
-#endif
-
-
- static void
-editEndsPrematurely()
-{
- fatserror("edit script ends prematurely");
-}
-
- static void
-editLineNumberOverflow()
-{
- fatserror("edit script refers to line past end of file");
-}
-
-
-#if large_memory
-
-#if has_memmove
-# define movelines(s1, s2, n) VOID memmove(s1, s2, (n)*sizeof(Iptr_type))
-#else
- static void movelines P((Iptr_type*,Iptr_type const*,long));
- static void
-movelines(s1, s2, n)
- register Iptr_type *s1;
- register Iptr_type const *s2;
- register long n;
-{
- if (s1 < s2)
- do {
- *s1++ = *s2++;
- } while (--n);
- else {
- s1 += n;
- s2 += n;
- do {
- *--s1 = *--s2;
- } while (--n);
- }
-}
-#endif
-
-static void deletelines P((long,long));
-static void finisheditline P((RILE*,FILE*,Iptr_type,struct hshentry const*));
-static void insertline P((long,Iptr_type));
-static void snapshotline P((FILE*,Iptr_type));
-
-/*
- * `line' contains pointers to the lines in the currently `edited' file.
- * It is a 0-origin array that represents linelim-gapsize lines.
- * line[0 .. gap-1] and line[gap+gapsize .. linelim-1] hold pointers to lines.
- * line[gap .. gap+gapsize-1] contains garbage.
- *
- * Any @s in lines are duplicated.
- * Lines are terminated by \n, or (for a last partial line only) by single @.
- */
-static Iptr_type *line;
-static size_t gap, gapsize, linelim;
-
- static void
-insertline(n, l)
- long n;
- Iptr_type l;
-/* Before line N, insert line L. N is 0-origin. */
-{
- if (linelim-gapsize < n)
- editLineNumberOverflow();
- if (!gapsize)
- line =
- !linelim ?
- tnalloc(Iptr_type, linelim = gapsize = 1024)
- : (
- gap = gapsize = linelim,
- trealloc(Iptr_type, line, linelim <<= 1)
- );
- if (n < gap)
- movelines(line+n+gapsize, line+n, gap-n);
- else if (gap < n)
- movelines(line+gap, line+gap+gapsize, n-gap);
-
- line[n] = l;
- gap = n + 1;
- gapsize--;
-}
-
- static void
-deletelines(n, nlines)
- long n, nlines;
-/* Delete lines N through N+NLINES-1. N is 0-origin. */
-{
- long l = n + nlines;
- if (linelim-gapsize < l || l < n)
- editLineNumberOverflow();
- if (l < gap)
- movelines(line+l+gapsize, line+l, gap-l);
- else if (gap < n)
- movelines(line+gap, line+gap+gapsize, n-gap);
-
- gap = n;
- gapsize += nlines;
-}
-
- static void
-snapshotline(f, l)
- register FILE *f;
- register Iptr_type l;
-{
- register int c;
- do {
- if ((c = *l++) == SDELIM && *l++ != SDELIM)
- return;
- aputc_(c, f)
- } while (c != '\n');
-}
-
- void
-snapshotedit(f)
- FILE *f;
-/* Copy the current state of the edits to F. */
-{
- register Iptr_type *p, *lim, *l=line;
- for (p=l, lim=l+gap; p<lim; )
- snapshotline(f, *p++);
- for (p+=gapsize, lim=l+linelim; p<lim; )
- snapshotline(f, *p++);
-}
-
- static void
-finisheditline(fin, fout, l, delta)
- RILE *fin;
- FILE *fout;
- Iptr_type l;
- struct hshentry const *delta;
-{
- fin->ptr = l;
- if (expandline(fin, fout, delta, true, (FILE*)0, true) < 0)
- faterror("finisheditline internal error");
-}
-
- void
-finishedit(delta, outfile, done)
- struct hshentry const *delta;
- FILE *outfile;
- int done;
-/*
- * Doing expansion if DELTA is set, output the state of the edits to OUTFILE.
- * But do nothing unless DONE is set (which means we are on the last pass).
- */
-{
- if (done) {
- openfcopy(outfile);
- outfile = fcopy;
- if (!delta)
- snapshotedit(outfile);
- else {
- register Iptr_type *p, *lim, *l = line;
- register RILE *fin = finptr;
- Iptr_type here = fin->ptr;
- for (p=l, lim=l+gap; p<lim; )
- finisheditline(fin, outfile, *p++, delta);
- for (p+=gapsize, lim=l+linelim; p<lim; )
- finisheditline(fin, outfile, *p++, delta);
- fin->ptr = here;
- }
- }
-}
-
-/* Open a temporary NAME for output, truncating any previous contents. */
-# define fopen_update_truncate(name) fopenSafer(name, FOPEN_W_WORK)
-#else /* !large_memory */
- static FILE * fopen_update_truncate P((char const*));
- static FILE *
-fopen_update_truncate(name)
- char const *name;
-{
- if (bad_fopen_wplus && un_link(name) != 0)
- efaterror(name);
- return fopenSafer(name, FOPEN_WPLUS_WORK);
-}
-#endif
-
-
- void
-openfcopy(f)
- FILE *f;
-{
- if (!(fcopy = f)) {
- if (!resultname)
- resultname = maketemp(2);
- if (!(fcopy = fopen_update_truncate(resultname)))
- efaterror(resultname);
- }
-}
-
-
-#if !large_memory
-
- static void swapeditfiles P((FILE*));
- static void
-swapeditfiles(outfile)
- FILE *outfile;
-/* Function: swaps resultname and editname, assigns fedit=fcopy,
- * and rewinds fedit for reading. Set fcopy to outfile if nonnull;
- * otherwise, set fcopy to be resultname opened for reading and writing.
- */
-{
- char const *tmpptr;
-
- editline = 0; linecorr = 0;
- Orewind(fcopy);
- fedit = fcopy;
- tmpptr=editname; editname=resultname; resultname=tmpptr;
- openfcopy(outfile);
-}
-
- void
-snapshotedit(f)
- FILE *f;
-/* Copy the current state of the edits to F. */
-{
- finishedit((struct hshentry *)0, (FILE*)0, false);
- fastcopy(fedit, f);
- Irewind(fedit);
-}
-
- void
-finishedit(delta, outfile, done)
- struct hshentry const *delta;
- FILE *outfile;
- int done;
-/* copy the rest of the edit file and close it (if it exists).
- * if delta, perform keyword substitution at the same time.
- * If DONE is set, we are finishing the last pass.
- */
-{
- register RILE *fe;
- register FILE *fc;
-
- fe = fedit;
- if (fe) {
- fc = fcopy;
- if (delta) {
- while (1 < expandline(fe,fc,delta,false,(FILE*)0,true))
- ;
- } else {
- fastcopy(fe,fc);
- }
- Ifclose(fe);
- }
- if (!done)
- swapeditfiles(outfile);
-}
-#endif
-
-
-
-#if large_memory
-# define copylines(upto,delta) (editline = (upto))
-#else
- static void copylines P((long,struct hshentry const*));
- static void
-copylines(upto, delta)
- register long upto;
- struct hshentry const *delta;
-/*
- * Copy input lines editline+1..upto from fedit to fcopy.
- * If delta, keyword expansion is done simultaneously.
- * editline is updated. Rewinds a file only if necessary.
- */
-{
- register int c;
- declarecache;
- register FILE *fc;
- register RILE *fe;
-
- if (upto < editline) {
- /* swap files */
- finishedit((struct hshentry *)0, (FILE*)0, false);
- /* assumes edit only during last pass, from the beginning*/
- }
- fe = fedit;
- fc = fcopy;
- if (editline < upto)
- if (delta)
- do {
- if (expandline(fe,fc,delta,false,(FILE*)0,true) <= 1)
- editLineNumberOverflow();
- } while (++editline < upto);
- else {
- setupcache(fe); cache(fe);
- do {
- do {
- cachegeteof_(c, editLineNumberOverflow();)
- aputc_(c, fc)
- } while (c != '\n');
- } while (++editline < upto);
- uncache(fe);
- }
-}
-#endif
-
-
-
- void
-xpandstring(delta)
- struct hshentry const *delta;
-/* Function: Reads a string terminated by SDELIM from finptr and writes it
- * to fcopy. Double SDELIM is replaced with single SDELIM.
- * Keyword expansion is performed with data from delta.
- * If foutptr is nonnull, the string is also copied unchanged to foutptr.
- */
-{
- while (1 < expandline(finptr,fcopy,delta,true,foutptr,true))
- continue;
-}
-
-
- void
-copystring()
-/* Function: copies a string terminated with a single SDELIM from finptr to
- * fcopy, replacing all double SDELIM with a single SDELIM.
- * If foutptr is nonnull, the string also copied unchanged to foutptr.
- * editline is incremented by the number of lines copied.
- * Assumption: next character read is first string character.
- */
-{ register c;
- declarecache;
- register FILE *frew, *fcop;
- register int amidline;
- register RILE *fin;
-
- fin = finptr;
- setupcache(fin); cache(fin);
- frew = foutptr;
- fcop = fcopy;
- amidline = false;
- for (;;) {
- GETC_(frew,c)
- switch (c) {
- case '\n':
- ++editline;
- ++rcsline;
- amidline = false;
- break;
- case SDELIM:
- GETC_(frew,c)
- if (c != SDELIM) {
- /* end of string */
- nextc = c;
- editline += amidline;
- uncache(fin);
- return;
- }
- /* fall into */
- default:
- amidline = true;
- break;
- }
- aputc_(c,fcop)
- }
-}
-
-
- void
-enterstring()
-/* Like copystring, except the string is put into the edit data structure. */
-{
-#if !large_memory
- editname = 0;
- fedit = 0;
- editline = linecorr = 0;
- resultname = maketemp(1);
- if (!(fcopy = fopen_update_truncate(resultname)))
- efaterror(resultname);
- copystring();
-#else
- register int c;
- declarecache;
- register FILE *frew;
- register long e, oe;
- register int amidline, oamidline;
- register Iptr_type optr;
- register RILE *fin;
-
- e = 0;
- gap = 0;
- gapsize = linelim;
- fin = finptr;
- setupcache(fin); cache(fin);
- advise_access(fin, MADV_NORMAL);
- frew = foutptr;
- amidline = false;
- for (;;) {
- optr = cacheptr();
- GETC_(frew,c)
- oamidline = amidline;
- oe = e;
- switch (c) {
- case '\n':
- ++e;
- ++rcsline;
- amidline = false;
- break;
- case SDELIM:
- GETC_(frew,c)
- if (c != SDELIM) {
- /* end of string */
- nextc = c;
- editline = e + amidline;
- linecorr = 0;
- uncache(fin);
- return;
- }
- /* fall into */
- default:
- amidline = true;
- break;
- }
- if (!oamidline)
- insertline(oe, optr);
- }
-#endif
-}
-
-
-
-
- void
-#if large_memory
-edit_string()
-#else
- editstring(delta)
- struct hshentry const *delta;
-#endif
-/*
- * Read an edit script from finptr and applies it to the edit file.
-#if !large_memory
- * The result is written to fcopy.
- * If delta, keyword expansion is performed simultaneously.
- * If running out of lines in fedit, fedit and fcopy are swapped.
- * editname is the name of the file that goes with fedit.
-#endif
- * If foutptr is set, the edit script is also copied verbatim to foutptr.
- * Assumes that all these files are open.
- * resultname is the name of the file that goes with fcopy.
- * Assumes the next input character from finptr is the first character of
- * the edit script. Resets nextc on exit.
- */
-{
- int ed; /* editor command */
- register int c;
- declarecache;
- register FILE *frew;
-# if !large_memory
- register FILE *f;
- long line_lim = LONG_MAX;
- register RILE *fe;
-# endif
- register long i;
- register RILE *fin;
-# if large_memory
- register long j;
-# endif
- struct diffcmd dc;
-
- editline += linecorr; linecorr=0; /*correct line number*/
- frew = foutptr;
- fin = finptr;
- setupcache(fin);
- initdiffcmd(&dc);
- while (0 <= (ed = getdiffcmd(fin,true,frew,&dc)))
-#if !large_memory
- if (line_lim <= dc.line1)
- editLineNumberOverflow();
- else
-#endif
- if (!ed) {
- copylines(dc.line1-1, delta);
- /* skip over unwanted lines */
- i = dc.nlines;
- linecorr -= i;
- editline += i;
-# if large_memory
- deletelines(editline+linecorr, i);
-# else
- fe = fedit;
- do {
- /*skip next line*/
- do {
- Igeteof_(fe, c, { if (i!=1) editLineNumberOverflow(); line_lim = dc.dafter; break; } )
- } while (c != '\n');
- } while (--i);
-# endif
- } else {
- /* Copy lines without deleting any. */
- copylines(dc.line1, delta);
- i = dc.nlines;
-# if large_memory
- j = editline+linecorr;
-# endif
- linecorr += i;
-#if !large_memory
- f = fcopy;
- if (delta)
- do {
- switch (expandline(fin,f,delta,true,frew,true)){
- case 0: case 1:
- if (i==1)
- return;
- /* fall into */
- case -1:
- editEndsPrematurely();
- }
- } while (--i);
- else
-#endif
- {
- cache(fin);
- do {
-# if large_memory
- insertline(j++, cacheptr());
-# endif
- for (;;) {
- GETC_(frew, c)
- if (c==SDELIM) {
- GETC_(frew, c)
- if (c!=SDELIM) {
- if (--i)
- editEndsPrematurely();
- nextc = c;
- uncache(fin);
- return;
- }
- }
-# if !large_memory
- aputc_(c, f)
-# endif
- if (c == '\n')
- break;
- }
- ++rcsline;
- } while (--i);
- uncache(fin);
- }
- }
-}
-
-
-
-/* The rest is for keyword expansion */
-
-
-
- int
-expandline(infile, outfile, delta, delimstuffed, frewfile, dolog)
- RILE *infile;
- FILE *outfile, *frewfile;
- struct hshentry const *delta;
- int delimstuffed, dolog;
-/*
- * Read a line from INFILE and write it to OUTFILE.
- * Do keyword expansion with data from DELTA.
- * If DELIMSTUFFED is true, double SDELIM is replaced with single SDELIM.
- * If FREWFILE is set, copy the line unchanged to FREWFILE.
- * DELIMSTUFFED must be true if FREWFILE is set.
- * Append revision history to log only if DOLOG is set.
- * Yields -1 if no data is copied, 0 if an incomplete line is copied,
- * 2 if a complete line is copied; adds 1 to yield if expansion occurred.
- */
-{
- register c;
- declarecache;
- register FILE *out, *frew;
- register char * tp;
- register int e, ds, r;
- char const *tlim;
- static struct buf keyval;
- enum markers matchresult;
-
- setupcache(infile); cache(infile);
- out = outfile;
- frew = frewfile;
- ds = delimstuffed;
- bufalloc(&keyval, keylength+3);
- e = 0;
- r = -1;
-
- for (;;) {
- if (ds)
- GETC_(frew, c)
- else
- cachegeteof_(c, goto uncache_exit;)
- for (;;) {
- switch (c) {
- case SDELIM:
- if (ds) {
- GETC_(frew, c)
- if (c != SDELIM) {
- /* end of string */
- nextc=c;
- goto uncache_exit;
- }
- }
- /* fall into */
- default:
- aputc_(c,out)
- r = 0;
- break;
-
- case '\n':
- rcsline += ds;
- aputc_(c,out)
- r = 2;
- goto uncache_exit;
-
- case KDELIM:
- r = 0;
- /* check for keyword */
- /* first, copy a long enough string into keystring */
- tp = keyval.string;
- *tp++ = KDELIM;
- for (;;) {
- if (ds)
- GETC_(frew, c)
- else
- cachegeteof_(c, goto keystring_eof;)
- if (tp <= &keyval.string[keylength])
- switch (ctab[c]) {
- case LETTER: case Letter:
- *tp++ = c;
- continue;
- default:
- break;
- }
- break;
- }
- *tp++ = c; *tp = '\0';
- matchresult = trymatch(keyval.string+1);
- if (matchresult==Nomatch) {
- tp[-1] = 0;
- aputs(keyval.string, out);
- continue; /* last c handled properly */
- }
-
- /* Now we have a keyword terminated with a K/VDELIM */
- if (c==VDELIM) {
- /* try to find closing KDELIM, and replace value */
- tlim = keyval.string + keyval.size;
- for (;;) {
- if (ds)
- GETC_(frew, c)
- else
- cachegeteof_(c, goto keystring_eof;)
- if (c=='\n' || c==KDELIM)
- break;
- *tp++ =c;
- if (tlim <= tp)
- tp = bufenlarge(&keyval, &tlim);
- if (c==SDELIM && ds) { /*skip next SDELIM */
- GETC_(frew, c)
- if (c != SDELIM) {
- /* end of string before closing KDELIM or newline */
- nextc = c;
- goto keystring_eof;
- }
- }
- }
- if (c!=KDELIM) {
- /* couldn't find closing KDELIM -- give up */
- *tp = 0;
- aputs(keyval.string, out);
- continue; /* last c handled properly */
- }
- }
- /* now put out the new keyword value */
- uncache(infile);
- keyreplace(matchresult, delta, ds, infile, out, dolog);
- cache(infile);
- e = 1;
- break;
- }
- break;
- }
- }
-
- keystring_eof:
- *tp = 0;
- aputs(keyval.string, out);
- uncache_exit:
- uncache(infile);
- return r + e;
-}
-
-
- static void
-escape_string(out, s)
- register FILE *out;
- register char const *s;
-/* Output to OUT the string S, escaping chars that would break `ci -k'. */
-{
- register char c;
- for (;;)
- switch ((c = *s++)) {
- case 0: return;
- case '\t': aputs("\\t", out); break;
- case '\n': aputs("\\n", out); break;
- case ' ': aputs("\\040", out); break;
- case KDELIM: aputs("\\044", out); break;
- case '\\': if (VERSION(5)<=RCSversion) {aputs("\\\\", out); break;}
- /* fall into */
- default: aputc_(c, out) break;
- }
-}
-
-char const ciklog[ciklogsize] = "checked in with -k by ";
-
- static void
-keyreplace(marker, delta, delimstuffed, infile, out, dolog)
- enum markers marker;
- register struct hshentry const *delta;
- int delimstuffed;
- RILE *infile;
- register FILE *out;
- int dolog;
-/* function: outputs the keyword value(s) corresponding to marker.
- * Attributes are derived from delta.
- */
-{
- register char const *sp, *cp, *date;
- register int c;
- register size_t cs, cw, ls;
- char const *sp1;
- char datebuf[datesize + zonelenmax];
- int RCSv;
- int exp;
-
- sp = Keyword[(int)marker];
- exp = Expand;
- date = delta->date;
- RCSv = RCSversion;
-
- if (exp != VAL_EXPAND)
- aprintf(out, "%c%s", KDELIM, sp);
- if (exp != KEY_EXPAND) {
-
- if (exp != VAL_EXPAND)
- aprintf(out, "%c%c", VDELIM,
- marker==Log && RCSv<VERSION(5) ? '\t' : ' '
- );
-
- switch (marker) {
- case Author:
- aputs(delta->author, out);
- break;
- case Date:
- aputs(date2str(date,datebuf), out);
- break;
- case Id:
- case LocalId:
- case Header:
- if (marker == Id || RCSv < VERSION(4) ||
- (marker == LocalId && LocalIdMode == Id))
- escape_string(out, basefilename(RCSname));
- else if (marker == CVSHeader ||
- (marker == LocalId && LocalIdMode == CVSHeader))
- escape_string(out, getfullCVSname());
- else
- escape_string(out, getfullRCSname());
- aprintf(out, " %s %s %s %s",
- delta->num,
- date2str(date, datebuf),
- delta->author,
- RCSv==VERSION(3) && delta->lockedby ? "Locked"
- : delta->state
- );
- if (delta->lockedby)
- if (VERSION(5) <= RCSv) {
- if (locker_expansion || exp==KEYVALLOCK_EXPAND)
- aprintf(out, " %s", delta->lockedby);
- } else if (RCSv == VERSION(4))
- aprintf(out, " Locker: %s", delta->lockedby);
- break;
- case Locker:
- if (delta->lockedby)
- if (
- locker_expansion
- || exp == KEYVALLOCK_EXPAND
- || RCSv <= VERSION(4)
- )
- aputs(delta->lockedby, out);
- break;
- case Log:
- case RCSfile:
- escape_string(out, basefilename(RCSname));
- break;
- case Name:
- if (delta->name)
- aputs(delta->name, out);
- break;
- case Revision:
- aputs(delta->num, out);
- break;
- case Source:
- escape_string(out, getfullRCSname());
- break;
- case State:
- aputs(delta->state, out);
- break;
- default:
- break;
- }
- if (exp != VAL_EXPAND)
- afputc(' ', out);
- }
- if (exp != VAL_EXPAND)
- afputc(KDELIM, out);
-
- if (marker == Log && dolog) {
- struct buf leader;
-
- sp = delta->log.string;
- ls = delta->log.size;
- if (sizeof(ciklog)-1<=ls && !memcmp(sp,ciklog,sizeof(ciklog)-1))
- return;
- bufautobegin(&leader);
- if (RCSversion < VERSION(5)) {
- cp = Comment.string;
- cs = Comment.size;
- } else {
- int kdelim_found = 0;
- Ioffset_type chars_read = Itell(infile);
- declarecache;
- setupcache(infile); cache(infile);
-
- c = 0; /* Pacify `gcc -Wall'. */
-
- /*
- * Back up to the start of the current input line,
- * setting CS to the number of characters before `$Log'.
- */
- cs = 0;
- for (;;) {
- if (!--chars_read)
- goto done_backing_up;
- cacheunget_(infile, c)
- if (c == '\n')
- break;
- if (c == SDELIM && delimstuffed) {
- if (!--chars_read)
- break;
- cacheunget_(infile, c)
- if (c != SDELIM) {
- cacheget_(c)
- break;
- }
- }
- cs += kdelim_found;
- kdelim_found |= c==KDELIM;
- }
- cacheget_(c)
- done_backing_up:;
-
- /* Copy characters before `$Log' into LEADER. */
- bufalloc(&leader, cs);
- cp = leader.string;
- for (cw = 0; cw < cs; cw++) {
- leader.string[cw] = c;
- if (c == SDELIM && delimstuffed)
- cacheget_(c)
- cacheget_(c)
- }
-
- /* Convert traditional C or Pascal leader to ` *'. */
- for (cw = 0; cw < cs; cw++)
- if (ctab[(unsigned char) cp[cw]] != SPACE)
- break;
- if (
- cw+1 < cs
- && cp[cw+1] == '*'
- && (cp[cw] == '/' || cp[cw] == '(')
- ) {
- size_t i = cw+1;
- for (;;)
- if (++i == cs) {
- warn(
- "`%c* $Log' is obsolescent; use ` * $Log'.",
- cp[cw]
- );
- leader.string[cw] = ' ';
- break;
- } else if (ctab[(unsigned char) cp[i]] != SPACE)
- break;
- }
-
- /* Skip `$Log ... $' string. */
- do {
- cacheget_(c)
- } while (c != KDELIM);
- uncache(infile);
- }
- afputc('\n', out);
- awrite(cp, cs, out);
- sp1 = date2str(date, datebuf);
- if (VERSION(5) <= RCSv) {
- aprintf(out, "Revision %s %s %s",
- delta->num, sp1, delta->author
- );
- } else {
- /* oddity: 2 spaces between date and time, not 1 as usual */
- sp1 = strchr(sp1, ' ');
- aprintf(out, "Revision %s %.*s %s %s",
- delta->num, (int)(sp1-datebuf), datebuf, sp1,
- delta->author
- );
- }
- /* Do not include state: it may change and is not updated. */
- cw = cs;
- if (VERSION(5) <= RCSv)
- for (; cw && (cp[cw-1]==' ' || cp[cw-1]=='\t'); --cw)
- continue;
- for (;;) {
- afputc('\n', out);
- awrite(cp, cw, out);
- if (!ls)
- break;
- --ls;
- c = *sp++;
- if (c != '\n') {
- awrite(cp+cw, cs-cw, out);
- do {
- afputc(c,out);
- if (!ls)
- break;
- --ls;
- c = *sp++;
- } while (c != '\n');
- }
- }
- bufautoend(&leader);
- }
-}
-
-#if has_readlink
- static int resolve_symlink P((struct buf*));
- static int
-resolve_symlink(L)
- struct buf *L;
-/*
- * If L is a symbolic link, resolve it to the name that it points to.
- * If unsuccessful, set errno and yield -1.
- * If it points to an existing file, yield 1.
- * Otherwise, set errno=ENOENT and yield 0.
- */
-{
- char *b, a[SIZEABLE_PATH];
- int e;
- size_t s;
- ssize_t r;
- struct buf bigbuf;
- int linkcount = MAXSYMLINKS;
-
- b = a;
- s = sizeof(a);
- bufautobegin(&bigbuf);
- while ((r = readlink(L->string,b,s)) != -1)
- if (r == s) {
- bufalloc(&bigbuf, s<<1);
- b = bigbuf.string;
- s = bigbuf.size;
- } else if (!linkcount--) {
-# ifndef ELOOP
- /*
- * Some pedantic Posix 1003.1-1990 hosts have readlink
- * but not ELOOP. Approximate ELOOP with EMLINK.
- */
-# define ELOOP EMLINK
-# endif
- errno = ELOOP;
- return -1;
- } else {
- /* Splice symbolic link into L. */
- b[r] = '\0';
- L->string[
- ROOTPATH(b) ? 0 : basefilename(L->string) - L->string
- ] = '\0';
- bufscat(L, b);
- }
- e = errno;
- bufautoend(&bigbuf);
- errno = e;
- switch (e) {
- case readlink_isreg_errno: return 1;
- case ENOENT: return 0;
- default: return -1;
- }
-}
-#endif
-
- RILE *
-rcswriteopen(RCSbuf, status, mustread)
- struct buf *RCSbuf;
- struct stat *status;
- int mustread;
-/*
- * Create the lock file corresponding to RCSBUF.
- * Then try to open RCSBUF for reading and yield its RILE* descriptor.
- * Put its status into *STATUS too.
- * MUSTREAD is true if the file must already exist, too.
- * If all goes well, discard any previously acquired locks,
- * and set fdlock to the file descriptor of the RCS lockfile.
- */
-{
- register char *tp;
- register char const *sp, *RCSpath, *x;
- RILE *f;
- size_t l;
- int e, exists, fdesc, fdescSafer, r, waslocked;
- struct buf *dirt;
- struct stat statbuf;
-
- waslocked = 0 <= fdlock;
- exists =
-# if has_readlink
- resolve_symlink(RCSbuf);
-# else
- stat(RCSbuf->string, &statbuf) == 0 ? 1
- : errno==ENOENT ? 0 : -1;
-# endif
- if (exists < (mustread|waslocked))
- /*
- * There's an unusual problem with the RCS file;
- * or the RCS file doesn't exist,
- * and we must read or we already have a lock elsewhere.
- */
- return 0;
-
- RCSpath = RCSbuf->string;
- sp = basefilename(RCSpath);
- l = sp - RCSpath;
- dirt = &dirtpname[waslocked];
- bufscpy(dirt, RCSpath);
- tp = dirt->string + l;
- x = rcssuffix(RCSpath);
-# if has_readlink
- if (!x) {
- error("symbolic link to non RCS file `%s'", RCSpath);
- errno = EINVAL;
- return 0;
- }
-# endif
- if (*sp == *x) {
- error("RCS pathname `%s' incompatible with suffix `%s'", sp, x);
- errno = EINVAL;
- return 0;
- }
- /* Create a lock filename that is a function of the RCS filename. */
- if (*x) {
- /*
- * The suffix is nonempty.
- * The lock filename is the first char of of the suffix,
- * followed by the RCS filename with last char removed. E.g.:
- * foo,v RCS filename with suffix ,v
- * ,foo, lock filename
- */
- *tp++ = *x;
- while (*sp)
- *tp++ = *sp++;
- *--tp = 0;
- } else {
- /*
- * The suffix is empty.
- * The lock filename is the RCS filename
- * with last char replaced by '_'.
- */
- while ((*tp++ = *sp++))
- continue;
- tp -= 2;
- if (*tp == '_') {
- error("RCS pathname `%s' ends with `%c'", RCSpath, *tp);
- errno = EINVAL;
- return 0;
- }
- *tp = '_';
- }
-
- sp = dirt->string;
-
- f = 0;
-
- /*
- * good news:
- * open(f, O_CREAT|O_EXCL|O_TRUNC|..., OPEN_CREAT_READONLY)
- * is atomic according to Posix 1003.1-1990.
- * bad news:
- * NFS ignores O_EXCL and doesn't comply with Posix 1003.1-1990.
- * good news:
- * (O_TRUNC,OPEN_CREAT_READONLY) normally guarantees atomicity
- * even with NFS.
- * bad news:
- * If you're root, (O_TRUNC,OPEN_CREAT_READONLY) doesn't
- * guarantee atomicity.
- * good news:
- * Root-over-the-wire NFS access is rare for security reasons.
- * This bug has never been reported in practice with RCS.
- * So we don't worry about this bug.
- *
- * An even rarer NFS bug can occur when clients retry requests.
- * This can happen in the usual case of NFS over UDP.
- * Suppose client A releases a lock by renaming ",f," to "f,v" at
- * about the same time that client B obtains a lock by creating ",f,",
- * and suppose A's first rename request is delayed, so A reissues it.
- * The sequence of events might be:
- * A sends rename(",f,", "f,v")
- * B sends create(",f,")
- * A sends retry of rename(",f,", "f,v")
- * server receives, does, and acknowledges A's first rename()
- * A receives acknowledgment, and its RCS program exits
- * server receives, does, and acknowledges B's create()
- * server receives, does, and acknowledges A's retry of rename()
- * This not only wrongly deletes B's lock, it removes the RCS file!
- * Most NFS implementations have idempotency caches that usually prevent
- * this scenario, but such caches are finite and can be overrun.
- * This problem afflicts not only RCS, which uses open() and rename()
- * to get and release locks; it also afflicts the traditional
- * Unix method of using link() and unlink() to get and release locks,
- * and the less traditional method of using mkdir() and rmdir().
- * There is no easy workaround.
- * Any new method based on lockf() seemingly would be incompatible with
- * the old methods; besides, lockf() is notoriously buggy under NFS.
- * Since this problem afflicts scads of Unix programs, but is so rare
- * that nobody seems to be worried about it, we won't worry either.
- */
-# if !open_can_creat
-# define create(f) creat(f, OPEN_CREAT_READONLY)
-# else
-# define create(f) open(f, OPEN_O_BINARY|OPEN_O_LOCK|OPEN_O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, OPEN_CREAT_READONLY)
-# endif
-
- catchints();
- ignoreints();
-
- /*
- * Create a lock file for an RCS file. This should be atomic, i.e.
- * if two processes try it simultaneously, at most one should succeed.
- */
- seteid();
- fdesc = create(sp);
- fdescSafer = fdSafer(fdesc); /* Do it now; setrid might use stderr. */
- e = errno;
- setrid();
-
- if (0 <= fdesc)
- dirtpmaker[0] = effective;
-
- if (fdescSafer < 0) {
- if (e == EACCES && stat(sp,&statbuf) == 0)
- /* The RCS file is busy. */
- e = EEXIST;
- } else {
- e = ENOENT;
- if (exists) {
- f = Iopen(RCSpath, FOPEN_RB, status);
- e = errno;
- if (f && waslocked) {
- /* Discard the previous lock in favor of this one. */
- ORCSclose();
- seteid();
- r = un_link(lockname);
- e = errno;
- setrid();
- if (r != 0)
- enfaterror(e, lockname);
- bufscpy(&dirtpname[lockdirtp_index], sp);
- }
- }
- fdlock = fdescSafer;
- }
-
- restoreints();
-
- errno = e;
- return f;
-}
-
- void
-keepdirtemp(name)
- char const *name;
-/* Do not unlink name, either because it's not there any more,
- * or because it has already been unlinked.
- */
-{
- register int i;
- for (i=DIRTEMPNAMES; 0<=--i; )
- if (dirtpname[i].string == name) {
- dirtpmaker[i] = notmade;
- return;
- }
- faterror("keepdirtemp");
-}
-
- char const *
-makedirtemp(isworkfile)
- int isworkfile;
-/*
- * Create a unique pathname and store it into dirtpname.
- * Because of storage in tpnames, dirtempunlink() can unlink the file later.
- * Return a pointer to the pathname created.
- * If ISWORKFILE is 1, put it into the working file's directory;
- * if 0, put the unique file in RCSfile's directory.
- */
-{
- register char *tp, *np;
- register size_t dl;
- register struct buf *bn;
- register char const *name = isworkfile ? workname : RCSname;
-
- dl = basefilename(name) - name;
- bn = &dirtpname[newRCSdirtp_index + isworkfile];
- bufalloc(bn,
-# if has_mktemp
- dl + 9
-# else
- strlen(name) + 3
-# endif
- );
- bufscpy(bn, name);
- np = tp = bn->string;
- tp += dl;
- *tp++ = '_';
- *tp++ = '0'+isworkfile;
- catchints();
-# if has_mktemp
- VOID strcpy(tp, "XXXXXX");
- if (!mktemp(np) || !*np)
- faterror("can't make temporary pathname `%.*s_%cXXXXXX'",
- (int)dl, name, '0'+isworkfile
- );
-# else
- /*
- * Posix 1003.1-1990 has no reliable way
- * to create a unique file in a named directory.
- * We fudge here. If the filename is abcde,
- * the temp filename is _Ncde where N is a digit.
- */
- name += dl;
- if (*name) name++;
- if (*name) name++;
- VOID strcpy(tp, name);
-# endif
- dirtpmaker[newRCSdirtp_index + isworkfile] = real;
- return np;
-}
-
- void
-dirtempunlink()
-/* Clean up makedirtemp() files. May be invoked by signal handler. */
-{
- register int i;
- enum maker m;
-
- for (i = DIRTEMPNAMES; 0 <= --i; )
- if ((m = dirtpmaker[i]) != notmade) {
- if (m == effective)
- seteid();
- VOID un_link(dirtpname[i].string);
- if (m == effective)
- setrid();
- dirtpmaker[i] = notmade;
- }
-}
-
-
- int
-#if has_prototypes
-chnamemod(
- FILE **fromp, char const *from, char const *to,
- int set_mode, mode_t mode, time_t mtime
-)
- /* The `#if has_prototypes' is needed because mode_t might promote to int. */
-#else
- chnamemod(fromp, from, to, set_mode, mode, mtime)
- FILE **fromp; char const *from,*to;
- int set_mode; mode_t mode; time_t mtime;
-#endif
-/*
- * Rename a file (with stream pointer *FROMP) from FROM to TO.
- * FROM already exists.
- * If 0 < SET_MODE, change the mode to MODE, before renaming if possible.
- * If MTIME is not -1, change its mtime to MTIME before renaming.
- * Close and clear *FROMP before renaming it.
- * Unlink TO if it already exists.
- * Return -1 on error (setting errno), 0 otherwise.
- */
-{
- mode_t mode_while_renaming = mode;
- int fchmod_set_mode = 0;
-
-# if bad_a_rename || bad_NFS_rename
- struct stat st;
- if (bad_NFS_rename || (bad_a_rename && set_mode <= 0)) {
- if (fstat(fileno(*fromp), &st) != 0)
- return -1;
- if (bad_a_rename && set_mode <= 0)
- mode = st.st_mode;
- }
-# endif
-
-# if bad_a_rename
- /*
- * There's a short window of inconsistency
- * during which the lock file is writable.
- */
- mode_while_renaming = mode|S_IWUSR;
- if (mode != mode_while_renaming)
- set_mode = 1;
-# endif
-
-# if has_fchmod
- if (0<set_mode && fchmod(fileno(*fromp),mode_while_renaming) == 0)
- fchmod_set_mode = set_mode;
-# endif
- /* If bad_chmod_close, we must close before chmod. */
- Ozclose(fromp);
- if (fchmod_set_mode<set_mode && chmod(from, mode_while_renaming) != 0)
- return -1;
-
- if (setmtime(from, mtime) != 0)
- return -1;
-
-# if !has_rename || bad_b_rename
- /*
- * There's a short window of inconsistency
- * during which TO does not exist.
- */
- if (un_link(to) != 0 && errno != ENOENT)
- return -1;
-# endif
-
-# if has_rename
- if (rename(from,to) != 0 && !(has_NFS && errno==ENOENT))
- return -1;
-# else
- if (do_link(from,to) != 0 || un_link(from) != 0)
- return -1;
-# endif
-
-# if bad_NFS_rename
- {
- /*
- * Check whether the rename falsely reported success.
- * A race condition can occur between the rename and the stat.
- */
- struct stat tostat;
- if (stat(to, &tostat) != 0)
- return -1;
- if (! same_file(st, tostat, 0)) {
- errno = EIO;
- return -1;
- }
- }
-# endif
-
-# if bad_a_rename
- if (0 < set_mode && chmod(to, mode) != 0)
- return -1;
-# endif
-
- return 0;
-}
-
- int
-setmtime(file, mtime)
- char const *file;
- time_t mtime;
-/* Set FILE's last modified time to MTIME, but do nothing if MTIME is -1. */
-{
- static struct utimbuf amtime; /* static so unused fields are zero */
- if (mtime == -1)
- return 0;
- amtime.actime = now();
- amtime.modtime = mtime;
- return utime(file, &amtime);
-}
-
-
-
- int
-findlock(delete, target)
- int delete;
- struct hshentry **target;
-/*
- * Find the first lock held by caller and return a pointer
- * to the locked delta; also removes the lock if DELETE.
- * If one lock, put it into *TARGET.
- * Return 0 for no locks, 1 for one, 2 for two or more.
- */
-{
- register struct rcslock *next, **trail, **found;
-
- found = 0;
- for (trail = &Locks; (next = *trail); trail = &next->nextlock)
- if (strcmp(getcaller(), next->login) == 0) {
- if (found) {
- rcserror("multiple revisions locked by %s; please specify one", getcaller());
- return 2;
- }
- found = trail;
- }
- if (!found)
- return 0;
- next = *found;
- *target = next->delta;
- if (delete) {
- next->delta->lockedby = 0;
- *found = next->nextlock;
- }
- return 1;
-}
-
- int
-addlock(delta, verbose)
- struct hshentry * delta;
- int verbose;
-/*
- * Add a lock held by caller to DELTA and yield 1 if successful.
- * Print an error message if verbose and yield -1 if no lock is added because
- * DELTA is locked by somebody other than caller.
- * Return 0 if the caller already holds the lock.
- */
-{
- register struct rcslock *next;
-
- for (next = Locks; next; next = next->nextlock)
- if (cmpnum(delta->num, next->delta->num) == 0)
- if (strcmp(getcaller(), next->login) == 0)
- return 0;
- else {
- if (verbose)
- rcserror("Revision %s is already locked by %s.",
- delta->num, next->login
- );
- return -1;
- }
- next = ftalloc(struct rcslock);
- delta->lockedby = next->login = getcaller();
- next->delta = delta;
- next->nextlock = Locks;
- Locks = next;
- return 1;
-}
-
-
- int
-addsymbol(num, name, rebind)
- char const *num, *name;
- int rebind;
-/*
- * Associate with revision NUM the new symbolic NAME.
- * If NAME already exists and REBIND is set, associate NAME with NUM;
- * otherwise, print an error message and return false;
- * Return -1 if unsuccessful, 0 if no change, 1 if change.
- */
-{
- register struct assoc *next;
-
- for (next = Symbols; next; next = next->nextassoc)
- if (strcmp(name, next->symbol) == 0)
- if (strcmp(next->num,num) == 0)
- return 0;
- else if (rebind) {
- next->num = num;
- return 1;
- } else {
- rcserror("symbolic name %s already bound to %s",
- name, next->num
- );
- return -1;
- }
- next = ftalloc(struct assoc);
- next->symbol = name;
- next->num = num;
- next->nextassoc = Symbols;
- Symbols = next;
- return 1;
-}
-
-
-
- char const *
-getcaller()
-/* Get the caller's login name. */
-{
-# if has_setuid
- return getusername(euid()!=ruid());
-# else
- return getusername(false);
-# endif
-}
-
-
- int
-checkaccesslist()
-/*
- * Return true if caller is the superuser, the owner of the
- * file, the access list is empty, or caller is on the access list.
- * Otherwise, print an error message and return false.
- */
-{
- register struct access const *next;
-
- if (!AccessList || myself(RCSstat.st_uid) || strcmp(getcaller(),"root")==0)
- return true;
-
- next = AccessList;
- do {
- if (strcmp(getcaller(), next->login) == 0)
- return true;
- } while ((next = next->nextaccess));
-
- rcserror("user %s not on the access list", getcaller());
- return false;
-}
-
-
- int
-dorewrite(lockflag, changed)
- int lockflag, changed;
-/*
- * Do nothing if LOCKFLAG is zero.
- * Prepare to rewrite an RCS file if CHANGED is positive.
- * Stop rewriting if CHANGED is zero, because there won't be any changes.
- * Fail if CHANGED is negative.
- * Return 0 on success, -1 on failure.
- */
-{
- int r = 0, e;
-
- if (lockflag)
- if (changed) {
- if (changed < 0)
- return -1;
- putadmin();
- puttree(Head, frewrite);
- aprintf(frewrite, "\n\n%s%c", Kdesc, nextc);
- foutptr = frewrite;
- } else {
-# if bad_creat0
- int nr = !!frewrite, ne = 0;
-# endif
- ORCSclose();
- seteid();
- ignoreints();
-# if bad_creat0
- if (nr) {
- nr = un_link(newRCSname);
- ne = errno;
- keepdirtemp(newRCSname);
- }
-# endif
- r = un_link(lockname);
- e = errno;
- keepdirtemp(lockname);
- restoreints();
- setrid();
- if (r != 0)
- enerror(e, lockname);
-# if bad_creat0
- if (nr != 0) {
- enerror(ne, newRCSname);
- r = -1;
- }
-# endif
- }
- return r;
-}
-
- int
-donerewrite(changed, newRCStime)
- int changed;
- time_t newRCStime;
-/*
- * Finish rewriting an RCS file if CHANGED is nonzero.
- * Set its mode if CHANGED is positive.
- * Set its modification time to NEWRCSTIME unless it is -1.
- * Return 0 on success, -1 on failure.
- */
-{
- int r = 0, e = 0;
-# if bad_creat0
- int lr, le;
-# endif
-
- if (changed && !nerror) {
- if (finptr) {
- fastcopy(finptr, frewrite);
- Izclose(&finptr);
- }
- if (1 < RCSstat.st_nlink)
- rcswarn("breaking hard link");
- aflush(frewrite);
- seteid();
- ignoreints();
- r = chnamemod(
- &frewrite, newRCSname, RCSname, changed,
- RCSstat.st_mode & (mode_t)~(S_IWUSR|S_IWGRP|S_IWOTH),
- newRCStime
- );
- e = errno;
- keepdirtemp(newRCSname);
-# if bad_creat0
- lr = un_link(lockname);
- le = errno;
- keepdirtemp(lockname);
-# endif
- restoreints();
- setrid();
- if (r != 0) {
- enerror(e, RCSname);
- error("saved in %s", newRCSname);
- }
-# if bad_creat0
- if (lr != 0) {
- enerror(le, lockname);
- r = -1;
- }
-# endif
- }
- return r;
-}
-
- void
-ORCSclose()
-{
- if (0 <= fdlock) {
- if (close(fdlock) != 0)
- efaterror(lockname);
- fdlock = -1;
- }
- Ozclose(&frewrite);
-}
-
- void
-ORCSerror()
-/*
-* Like ORCSclose, except we are cleaning up after an interrupt or fatal error.
-* Do not report errors, since this may loop. This is needed only because
-* some brain-damaged hosts (e.g. OS/2) cannot unlink files that are open, and
-* some nearly-Posix hosts (e.g. NFS) work better if the files are closed first.
-* This isn't a completely reliable away to work around brain-damaged hosts,
-* because of the gap between actual file opening and setting frewrite etc.,
-* but it's better than nothing.
-*/
-{
- if (0 <= fdlock)
- VOID close(fdlock);
- if (frewrite)
- /* Avoid fclose, since stdio may not be reentrant. */
- VOID close(fileno(frewrite));
-}
diff --git a/gnu/usr.bin/rcs/lib/rcsfcmp.c b/gnu/usr.bin/rcs/lib/rcsfcmp.c
deleted file mode 100644
index 588756f..0000000
--- a/gnu/usr.bin/rcs/lib/rcsfcmp.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/* Compare working files, ignoring RCS keyword strings. */
-
-/*****************************************************************************
- * rcsfcmp()
- * Testprogram: define FCMPTEST
- *****************************************************************************
- */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-
-
-/*
- * Revision 5.14 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.13 1995/06/01 16:23:43 eggert
- * (rcsfcmp): Add -kb support.
- *
- * Revision 5.12 1994/03/17 14:05:48 eggert
- * Normally calculate the $Log prefix from context, not from RCS file.
- * Calculate line numbers correctly even if the $Log prefix contains newlines.
- * Remove lint.
- *
- * Revision 5.11 1993/11/03 17:42:27 eggert
- * Fix yet another off-by-one error when comparing Log string expansions.
- *
- * Revision 5.10 1992/07/28 16:12:44 eggert
- * Statement macro names now end in _.
- *
- * Revision 5.9 1991/10/07 17:32:46 eggert
- * Count log lines correctly.
- *
- * Revision 5.8 1991/08/19 03:13:55 eggert
- * Tune.
- *
- * Revision 5.7 1991/04/21 11:58:22 eggert
- * Fix errno bug. Add MS-DOS support.
- *
- * Revision 5.6 1991/02/28 19:18:47 eggert
- * Open work file at most once.
- *
- * Revision 5.5 1990/11/27 09:26:05 eggert
- * Fix comment leader bug.
- *
- * Revision 5.4 1990/11/01 05:03:42 eggert
- * Permit arbitrary data in logs and comment leaders.
- *
- * Revision 5.3 1990/09/11 02:41:15 eggert
- * Don't ignore differences inside keyword strings if -ko is set.
- *
- * Revision 5.1 1990/08/29 07:13:58 eggert
- * Clean old log messages too.
- *
- * Revision 5.0 1990/08/22 08:12:49 eggert
- * Don't append "checked in with -k by " log to logs,
- * so that checking in a program with -k doesn't change it.
- * Ansify and Posixate. Remove lint.
- *
- * Revision 4.5 89/05/01 15:12:42 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.4 88/08/09 19:12:50 eggert
- * Shrink stdio code size.
- *
- * Revision 4.3 87/12/18 11:40:02 narten
- * lint cleanups (Guy Harris)
- *
- * Revision 4.2 87/10/18 10:33:06 narten
- * updting version number. Changes relative to 1.1 actually relative to
- * 4.1
- *
- * Revision 1.2 87/03/27 14:22:19 jenkins
- * Port to suns
- *
- * Revision 4.1 83/05/10 16:24:04 wft
- * Marker matching now uses trymatch(). Marker pattern is now
- * checked precisely.
- *
- * Revision 3.1 82/12/04 13:21:40 wft
- * Initial revision.
- *
- */
-
-/*
-#define FCMPTEST
-*/
-/* Testprogram; prints out whether two files are identical,
- * except for keywords
- */
-
-#include "rcsbase.h"
-
-libId(fcmpId, "$Id$")
-
- static int discardkeyval P((int,RILE*));
- static int
-discardkeyval(c, f)
- register int c;
- register RILE *f;
-{
- for (;;)
- switch (c) {
- case KDELIM:
- case '\n':
- return c;
- default:
- Igeteof_(f, c, return EOF;)
- break;
- }
-}
-
- int
-rcsfcmp(xfp, xstatp, uname, delta)
- register RILE *xfp;
- struct stat const *xstatp;
- char const *uname;
- struct hshentry const *delta;
-/* Compare the files xfp and uname. Return zero
- * if xfp has the same contents as uname and neither has keywords,
- * otherwise -1 if they are the same ignoring keyword values,
- * and 1 if they differ even ignoring
- * keyword values. For the LOG-keyword, rcsfcmp skips the log message
- * given by the parameter delta in xfp. Thus, rcsfcmp returns nonpositive
- * if xfp contains the same as uname, with the keywords expanded.
- * Implementation: character-by-character comparison until $ is found.
- * If a $ is found, read in the marker keywords; if they are real keywords
- * and identical, read in keyword value. If value is terminated properly,
- * disregard it and optionally skip log message; otherwise, compare value.
- */
-{
- register int xc, uc;
- char xkeyword[keylength+2];
- int eqkeyvals;
- register RILE *ufp;
- register int xeof, ueof;
- register char * tp;
- register char const *sp;
- register size_t leaderlen;
- int result;
- enum markers match1;
- struct stat ustat;
-
- if (!(ufp = Iopen(uname, FOPEN_R_WORK, &ustat))) {
- efaterror(uname);
- }
- xeof = ueof = false;
- if (MIN_UNEXPAND <= Expand) {
- if (!(result = xstatp->st_size!=ustat.st_size)) {
-# if large_memory && maps_memory
- result = !!memcmp(xfp->base,ufp->base,(size_t)xstatp->st_size);
-# else
- for (;;) {
- /* get the next characters */
- Igeteof_(xfp, xc, xeof=true;)
- Igeteof_(ufp, uc, ueof=true;)
- if (xeof | ueof)
- goto eof;
- if (xc != uc)
- goto return1;
- }
-# endif
- }
- } else {
- xc = 0;
- uc = 0; /* Keep lint happy. */
- leaderlen = 0;
- result = 0;
-
- for (;;) {
- if (xc != KDELIM) {
- /* get the next characters */
- Igeteof_(xfp, xc, xeof=true;)
- Igeteof_(ufp, uc, ueof=true;)
- if (xeof | ueof)
- goto eof;
- } else {
- /* try to get both keywords */
- tp = xkeyword;
- for (;;) {
- Igeteof_(xfp, xc, xeof=true;)
- Igeteof_(ufp, uc, ueof=true;)
- if (xeof | ueof)
- goto eof;
- if (xc != uc)
- break;
- switch (xc) {
- default:
- if (xkeyword+keylength <= tp)
- break;
- *tp++ = xc;
- continue;
- case '\n': case KDELIM: case VDELIM:
- break;
- }
- break;
- }
- if (
- (xc==KDELIM || xc==VDELIM) && (uc==KDELIM || uc==VDELIM) &&
- (*tp = xc, (match1 = trymatch(xkeyword)) != Nomatch)
- ) {
-#ifdef FCMPTEST
- VOID printf("found common keyword %s\n",xkeyword);
-#endif
- result = -1;
- for (;;) {
- if (xc != uc) {
- xc = discardkeyval(xc, xfp);
- uc = discardkeyval(uc, ufp);
- if ((xeof = xc==EOF) | (ueof = uc==EOF))
- goto eof;
- eqkeyvals = false;
- break;
- }
- switch (xc) {
- default:
- Igeteof_(xfp, xc, xeof=true;)
- Igeteof_(ufp, uc, ueof=true;)
- if (xeof | ueof)
- goto eof;
- continue;
-
- case '\n': case KDELIM:
- eqkeyvals = true;
- break;
- }
- break;
- }
- if (xc != uc)
- goto return1;
- if (xc==KDELIM) {
- /* Skip closing KDELIM. */
- Igeteof_(xfp, xc, xeof=true;)
- Igeteof_(ufp, uc, ueof=true;)
- if (xeof | ueof)
- goto eof;
- /* if the keyword is LOG, also skip the log message in xfp*/
- if (match1==Log) {
- /* first, compute the number of line feeds in log msg */
- int lncnt;
- size_t ls, ccnt;
- sp = delta->log.string;
- ls = delta->log.size;
- if (ls<sizeof(ciklog)-1 || memcmp(sp,ciklog,sizeof(ciklog)-1)) {
- /*
- * This log message was inserted. Skip its header.
- * The number of newlines to skip is
- * 1 + (C+1)*(1+L+1), where C is the number of newlines
- * in the comment leader, and L is the number of
- * newlines in the log string.
- */
- int c1 = 1;
- for (ccnt=Comment.size; ccnt--; )
- c1 += Comment.string[ccnt] == '\n';
- lncnt = 2*c1 + 1;
- while (ls--) if (*sp++=='\n') lncnt += c1;
- for (;;) {
- if (xc=='\n')
- if(--lncnt==0) break;
- Igeteof_(xfp, xc, goto returnresult;)
- }
- /* skip last comment leader */
- /* Can't just skip another line here, because there may be */
- /* additional characters on the line (after the Log....$) */
- ccnt = RCSversion<VERSION(5) ? Comment.size : leaderlen;
- do {
- Igeteof_(xfp, xc, goto returnresult;)
- /*
- * Read to the end of the comment leader or '\n',
- * whatever comes first, because the leader's
- * trailing white space was probably stripped.
- */
- } while (ccnt-- && (xc!='\n' || --c1));
- }
- }
- } else {
- /* both end in the same character, but not a KDELIM */
- /* must compare string values.*/
-#ifdef FCMPTEST
- VOID printf("non-terminated keywords %s, potentially different values\n",xkeyword);
-#endif
- if (!eqkeyvals)
- goto return1;
- }
- }
- }
- if (xc != uc)
- goto return1;
- if (xc == '\n')
- leaderlen = 0;
- else
- leaderlen++;
- }
- }
-
- eof:
- if (xeof==ueof)
- goto returnresult;
- return1:
- result = 1;
- returnresult:
- Ifclose(ufp);
- return result;
-}
-
-
-
-#ifdef FCMPTEST
-
-char const cmdid[] = "rcsfcmp";
-
-main(argc, argv)
-int argc; char *argv[];
-/* first argument: comment leader; 2nd: log message, 3rd: expanded file,
- * 4th: unexpanded file
- */
-{ struct hshentry delta;
-
- Comment.string = argv[1];
- Comment.size = strlen(argv[1]);
- delta.log.string = argv[2];
- delta.log.size = strlen(argv[2]);
- if (rcsfcmp(Iopen(argv[3], FOPEN_R_WORK, (struct stat*)0), argv[4], &delta))
- VOID printf("files are the same\n");
- else VOID printf("files are different\n");
-}
-#endif
diff --git a/gnu/usr.bin/rcs/lib/rcsfnms.c b/gnu/usr.bin/rcs/lib/rcsfnms.c
deleted file mode 100644
index 2de1c13..0000000
--- a/gnu/usr.bin/rcs/lib/rcsfnms.c
+++ /dev/null
@@ -1,1127 +0,0 @@
-/* RCS filename and pathname handling */
-
-/****************************************************************************
- * creation and deletion of /tmp temporaries
- * pairing of RCS pathnames and working pathnames.
- * Testprogram: define PAIRTEST
- ****************************************************************************
- */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-
-/*
- * Revision 5.16 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.15 1995/06/01 16:23:43 eggert
- * (basefilename): Renamed from basename to avoid collisions.
- * (dirlen): Remove (for similar reasons).
- * (rcsreadopen): Open with FOPEN_RB.
- * (SLASHSLASH_is_SLASH): Default is 0.
- * (getcwd): Work around bad_wait_if_SIGCHLD_ignored bug.
- *
- * Revision 5.14 1994/03/17 14:05:48 eggert
- * Strip trailing SLASHes from TMPDIR; some systems need this. Remove lint.
- *
- * Revision 5.13 1993/11/03 17:42:27 eggert
- * Determine whether a file name is too long indirectly,
- * by examining inode numbers, instead of trying to use operating system
- * primitives like pathconf, which are not trustworthy in general.
- * File names may now hold white space or $.
- * Do not flatten ../X in pathnames; that may yield wrong answer for symlinks.
- * Add getabsname hook. Improve quality of diagnostics.
- *
- * Revision 5.12 1992/07/28 16:12:44 eggert
- * Add .sty. .pl now implies Perl, not Prolog. Fix fdlock initialization bug.
- * Check that $PWD is really ".". Be consistent about pathnames vs filenames.
- *
- * Revision 5.11 1992/02/17 23:02:25 eggert
- * `a/RCS/b/c' is now an RCS file with an empty extension, not just `a/b/RCS/c'.
- *
- * Revision 5.10 1992/01/24 18:44:19 eggert
- * Fix bug: Expand and Ignored weren't reinitialized.
- * Avoid `char const c=ch;' compiler bug.
- * Add support for bad_creat0.
- *
- * Revision 5.9 1992/01/06 02:42:34 eggert
- * Shorten long (>31 chars) name.
- * while (E) ; -> while (E) continue;
- *
- * Revision 5.8 1991/09/24 00:28:40 eggert
- * Don't export bindex().
- *
- * Revision 5.7 1991/08/19 03:13:55 eggert
- * Fix messages when rcswriteopen fails.
- * Look in $TMP and $TEMP if $TMPDIR isn't set. Tune.
- *
- * Revision 5.6 1991/04/21 11:58:23 eggert
- * Fix errno bugs. Add -x, RCSINIT, MS-DOS support.
- *
- * Revision 5.5 1991/02/26 17:48:38 eggert
- * Fix setuid bug. Support new link behavior.
- * Define more portable getcwd().
- *
- * Revision 5.4 1990/11/01 05:03:43 eggert
- * Permit arbitrary data in comment leaders.
- *
- * Revision 5.3 1990/09/14 22:56:16 hammer
- * added more filename extensions and their comment leaders
- *
- * Revision 5.2 1990/09/04 08:02:23 eggert
- * Fix typo when !RCSSEP.
- *
- * Revision 5.1 1990/08/29 07:13:59 eggert
- * Work around buggy compilers with defective argument promotion.
- *
- * Revision 5.0 1990/08/22 08:12:50 eggert
- * Ignore signals when manipulating the semaphore file.
- * Modernize list of filename extensions.
- * Permit paths of arbitrary length. Beware filenames beginning with "-".
- * Remove compile-time limits; use malloc instead.
- * Permit dates past 1999/12/31. Make lock and temp files faster and safer.
- * Ansify and Posixate.
- * Don't use access(). Fix test for non-regular files. Tune.
- *
- * Revision 4.8 89/05/01 15:09:41 narten
- * changed getwd to not stat empty directories.
- *
- * Revision 4.7 88/08/09 19:12:53 eggert
- * Fix troff macro comment leader bug; add Prolog; allow cc -R; remove lint.
- *
- * Revision 4.6 87/12/18 11:40:23 narten
- * additional file types added from 4.3 BSD version, and SPARC assembler
- * comment character added. Also, more lint cleanups. (Guy Harris)
- *
- * Revision 4.5 87/10/18 10:34:16 narten
- * Updating version numbers. Changes relative to 1.1 actually relative
- * to verion 4.3
- *
- * Revision 1.3 87/03/27 14:22:21 jenkins
- * Port to suns
- *
- * Revision 1.2 85/06/26 07:34:28 svb
- * Comment leader '% ' for '*.tex' files added.
- *
- * Revision 4.3 83/12/15 12:26:48 wft
- * Added check for KDELIM in filenames to pairfilenames().
- *
- * Revision 4.2 83/12/02 22:47:45 wft
- * Added csh, red, and sl filename suffixes.
- *
- * Revision 4.1 83/05/11 16:23:39 wft
- * Added initialization of Dbranch to InitAdmin(). Canged pairfilenames():
- * 1. added copying of path from workfile to RCS file, if RCS file is omitted;
- * 2. added getting the file status of RCS and working files;
- * 3. added ignoring of directories.
- *
- * Revision 3.7 83/05/11 15:01:58 wft
- * Added comtable[] which pairs filename suffixes with comment leaders;
- * updated InitAdmin() accordingly.
- *
- * Revision 3.6 83/04/05 14:47:36 wft
- * fixed Suffix in InitAdmin().
- *
- * Revision 3.5 83/01/17 18:01:04 wft
- * Added getwd() and rename(); these can be removed by defining
- * V4_2BSD, since they are not needed in 4.2 bsd.
- * Changed sys/param.h to sys/types.h.
- *
- * Revision 3.4 82/12/08 21:55:20 wft
- * removed unused variable.
- *
- * Revision 3.3 82/11/28 20:31:37 wft
- * Changed mktempfile() to store the generated filenames.
- * Changed getfullRCSname() to store the file and pathname, and to
- * delete leading "../" and "./".
- *
- * Revision 3.2 82/11/12 14:29:40 wft
- * changed pairfilenames() to handle file.sfx,v; also deleted checkpathnosfx(),
- * checksuffix(), checkfullpath(). Semaphore name generation updated.
- * mktempfile() now checks for nil path; freefilename initialized properly.
- * Added Suffix .h to InitAdmin. Added testprogram PAIRTEST.
- * Moved rmsema, trysema, trydiraccess, getfullRCSname from rcsutil.c to here.
- *
- * Revision 3.1 82/10/18 14:51:28 wft
- * InitAdmin() now initializes StrictLocks=STRICT_LOCKING (def. in rcsbase.h).
- * renamed checkpath() to checkfullpath().
- */
-
-
-#include "rcsbase.h"
-
-libId(fnmsId, "$Id: rcsfnms.c,v 1.8 1997/08/19 11:17:37 peter Exp $")
-
-static char const *bindex P((char const*,int));
-static int fin2open P((char const*, size_t, char const*, size_t, char const*, size_t, RILE*(*)P((struct buf*,struct stat*,int)), int));
-static int finopen P((RILE*(*)P((struct buf*,struct stat*,int)), int));
-static int suffix_matches P((char const*,char const*));
-static size_t dir_useful_len P((char const*));
-static size_t suffixlen P((char const*));
-static void InitAdmin P((void));
-
-char const *RCSname;
-char *workname;
-int fdlock;
-FILE *workstdout;
-struct stat RCSstat;
-char const *suffixes;
-
-static char const rcsdir[] = "RCS";
-#define rcslen (sizeof(rcsdir)-1)
-
-static struct buf RCSbuf, RCSb;
-static int RCSerrno;
-
-
-/* Temp names to be unlinked when done, if they are not 0. */
-#define TEMPNAMES 5 /* must be at least DIRTEMPNAMES (see rcsedit.c) */
-static char *volatile tpnames[TEMPNAMES];
-
-
-struct compair {
- char const *suffix, *comlead;
-};
-
-/*
-* This table is present only for backwards compatibility.
-* Normally we ignore this table, and use the prefix of the `$Log' line instead.
-*/
-static struct compair const comtable[] = {
- { "a" , "-- " }, /* Ada */
- { "ada" , "-- " },
- { "adb" , "-- " },
- { "ads" , "-- " },
- { "asm" , ";; " }, /* assembler (MS-DOS) */
- { "bat" , ":: " }, /* batch (MS-DOS) */
- { "body", "-- " }, /* Ada */
- { "c" , " * " }, /* C */
- { "c++" , "// " }, /* C++ in all its infinite guises */
- { "cc" , "// " },
- { "cpp" , "// " },
- { "cxx" , "// " },
- { "cl" , ";;; "}, /* Common Lisp */
- { "cmd" , ":: " }, /* command (OS/2) */
- { "cmf" , "c " }, /* CM Fortran */
- { "cs" , " * " }, /* C* */
- { "el" , "; " }, /* Emacs Lisp */
- { "f" , "c " }, /* Fortran */
- { "for" , "c " },
- { "h" , " * " }, /* C-header */
- { "hpp" , "// " }, /* C++ header */
- { "hxx" , "// " },
- { "l" , " * " }, /* lex (NOTE: franzlisp disagrees) */
- { "lisp", ";;; "}, /* Lucid Lisp */
- { "lsp" , ";; " }, /* Microsoft Lisp */
- { "m" , "// " }, /* Objective C */
- { "mac" , ";; " }, /* macro (DEC-10, MS-DOS, PDP-11, VMS, etc) */
- { "me" , ".\\\" "}, /* troff -me */
- { "ml" , "; " }, /* mocklisp */
- { "mm" , ".\\\" "}, /* troff -mm */
- { "ms" , ".\\\" "}, /* troff -ms */
- { "p" , " * " }, /* Pascal */
- { "pas" , " * " },
- { "ps" , "% " }, /* PostScript */
- { "spec", "-- " }, /* Ada */
- { "sty" , "% " }, /* LaTeX style */
- { "tex" , "% " }, /* TeX */
- { "y" , " * " }, /* yacc */
- { 0 , "# " } /* default for unknown suffix; must be last */
-};
-
-#if has_mktemp
- static char const *tmp P((void));
- static char const *
-tmp()
-/* Yield the name of the tmp directory. */
-{
- static char const *s;
- if (!s
- && !(s = cgetenv("TMPDIR")) /* Unix tradition */
- && !(s = cgetenv("TMP")) /* DOS tradition */
- && !(s = cgetenv("TEMP")) /* another DOS tradition */
- )
- s = TMPDIR;
- return s;
-}
-#endif
-
- char const *
-maketemp(n)
- int n;
-/* Create a unique pathname using n and the process id and store it
- * into the nth slot in tpnames.
- * Because of storage in tpnames, tempunlink() can unlink the file later.
- * Return a pointer to the pathname created.
- */
-{
- char *p;
- char const *t = tpnames[n];
-
- if (t)
- return t;
-
- catchints();
- {
-# if has_mktemp
- char const *tp = tmp();
- size_t tplen = dir_useful_len(tp);
- p = testalloc(tplen + 10);
- VOID sprintf(p, "%.*s%cT%cXXXXXX", (int)tplen, tp, SLASH, '0'+n);
- if (!mktemp(p) || !*p)
- faterror("can't make temporary pathname `%.*s%cT%cXXXXXX'",
- (int)tplen, tp, SLASH, '0'+n
- );
-# else
- static char tpnamebuf[TEMPNAMES][L_tmpnam];
- p = tpnamebuf[n];
- if (!tmpnam(p) || !*p)
-# ifdef P_tmpdir
- faterror("can't make temporary pathname `%s...'",P_tmpdir);
-# else
- faterror("can't make temporary pathname");
-# endif
-# endif
- }
-
- tpnames[n] = p;
- return p;
-}
-
- void
-tempunlink()
-/* Clean up maketemp() files. May be invoked by signal handler.
- */
-{
- register int i;
- register char *p;
-
- for (i = TEMPNAMES; 0 <= --i; )
- if ((p = tpnames[i])) {
- VOID unlink(p);
- /*
- * We would tfree(p) here,
- * but this might dump core if we're handing a signal.
- * We're about to exit anyway, so we won't bother.
- */
- tpnames[i] = 0;
- }
-}
-
-
- static char const *
-bindex(sp, c)
- register char const *sp;
- register int c;
-/* Function: Finds the last occurrence of character c in string sp
- * and returns a pointer to the character just beyond it. If the
- * character doesn't occur in the string, sp is returned.
- */
-{
- register char const *r;
- r = sp;
- while (*sp) {
- if (*sp++ == c) r=sp;
- }
- return r;
-}
-
-
-
- static int
-suffix_matches(suffix, pattern)
- register char const *suffix, *pattern;
-{
- register int c;
- if (!pattern)
- return true;
- for (;;)
- switch (*suffix++ - (c = *pattern++)) {
- case 0:
- if (!c)
- return true;
- break;
-
- case 'A'-'a':
- if (ctab[c] == Letter)
- break;
- /* fall into */
- default:
- return false;
- }
-}
-
-
- static void
-InitAdmin()
-/* function: initializes an admin node */
-{
- register char const *Suffix;
- register int i;
-
- Head=0; Dbranch=0; AccessList=0; Symbols=0; Locks=0;
- StrictLocks=STRICT_LOCKING;
-
- /* guess the comment leader from the suffix*/
- Suffix = bindex(workname, '.');
- if (Suffix==workname) Suffix= ""; /* empty suffix; will get default*/
- for (i=0; !suffix_matches(Suffix,comtable[i].suffix); i++)
- continue;
- Comment.string = comtable[i].comlead;
- Comment.size = strlen(comtable[i].comlead);
- Expand = KEYVAL_EXPAND;
- clear_buf(&Ignored);
- Lexinit(); /* note: if !finptr, reads nothing; only initializes */
-}
-
-
-
- void
-bufalloc(b, size)
- register struct buf *b;
- size_t size;
-/* Ensure *B is a name buffer of at least SIZE bytes.
- * *B's old contents can be freed; *B's new contents are undefined.
- */
-{
- if (b->size < size) {
- if (b->size)
- tfree(b->string);
- else
- b->size = sizeof(malloc_type);
- while (b->size < size)
- b->size <<= 1;
- b->string = tnalloc(char, b->size);
- }
-}
-
- void
-bufrealloc(b, size)
- register struct buf *b;
- size_t size;
-/* like bufalloc, except *B's old contents, if any, are preserved */
-{
- if (b->size < size) {
- if (!b->size)
- bufalloc(b, size);
- else {
- while ((b->size <<= 1) < size)
- continue;
- b->string = trealloc(char, b->string, b->size);
- }
- }
-}
-
- void
-bufautoend(b)
- struct buf *b;
-/* Free an auto buffer at block exit. */
-{
- if (b->size)
- tfree(b->string);
-}
-
- struct cbuf
-bufremember(b, s)
- struct buf *b;
- size_t s;
-/*
- * Free the buffer B with used size S.
- * Yield a cbuf with identical contents.
- * The cbuf will be reclaimed when this input file is finished.
- */
-{
- struct cbuf cb;
-
- if ((cb.size = s))
- cb.string = fremember(trealloc(char, b->string, s));
- else {
- bufautoend(b); /* not really auto */
- cb.string = "";
- }
- return cb;
-}
-
- char *
-bufenlarge(b, alim)
- register struct buf *b;
- char const **alim;
-/* Make *B larger. Set *ALIM to its new limit, and yield the relocated value
- * of its old limit.
- */
-{
- size_t s = b->size;
- bufrealloc(b, s + 1);
- *alim = b->string + b->size;
- return b->string + s;
-}
-
- void
-bufscat(b, s)
- struct buf *b;
- char const *s;
-/* Concatenate S to B's end. */
-{
- size_t blen = b->string ? strlen(b->string) : 0;
- bufrealloc(b, blen+strlen(s)+1);
- VOID strcpy(b->string+blen, s);
-}
-
- void
-bufscpy(b, s)
- struct buf *b;
- char const *s;
-/* Copy S into B. */
-{
- bufalloc(b, strlen(s)+1);
- VOID strcpy(b->string, s);
-}
-
-
- char const *
-basefilename(p)
- char const *p;
-/* Yield the address of the base filename of the pathname P. */
-{
- register char const *b = p, *q = p;
- for (;;)
- switch (*q++) {
- case SLASHes: b = q; break;
- case 0: return b;
- }
-}
-
-
- static size_t
-suffixlen(x)
- char const *x;
-/* Yield the length of X, an RCS pathname suffix. */
-{
- register char const *p;
-
- p = x;
- for (;;)
- switch (*p) {
- case 0: case SLASHes:
- return p - x;
-
- default:
- ++p;
- continue;
- }
-}
-
- char const *
-rcssuffix(name)
- char const *name;
-/* Yield the suffix of NAME if it is an RCS pathname, 0 otherwise. */
-{
- char const *x, *p, *nz;
- size_t nl, xl;
-
- nl = strlen(name);
- nz = name + nl;
- x = suffixes;
- do {
- if ((xl = suffixlen(x))) {
- if (xl <= nl && memcmp(p = nz-xl, x, xl) == 0)
- return p;
- } else
- for (p = name; p < nz - rcslen; p++)
- if (
- isSLASH(p[rcslen])
- && (p==name || isSLASH(p[-1]))
- && memcmp(p, rcsdir, rcslen) == 0
- )
- return nz;
- x += xl;
- } while (*x++);
- return 0;
-}
-
- /*ARGSUSED*/ RILE *
-rcsreadopen(RCSpath, status, mustread)
- struct buf *RCSpath;
- struct stat *status;
- int mustread;
-/* Open RCSPATH for reading and yield its FILE* descriptor.
- * If successful, set *STATUS to its status.
- * Pass this routine to pairnames() for read-only access to the file. */
-{
- return Iopen(RCSpath->string, FOPEN_RB, status);
-}
-
- static int
-finopen(rcsopen, mustread)
- RILE *(*rcsopen)P((struct buf*,struct stat*,int));
- int mustread;
-/*
- * Use RCSOPEN to open an RCS file; MUSTREAD is set if the file must be read.
- * Set finptr to the result and yield true if successful.
- * RCSb holds the file's name.
- * Set RCSbuf to the best RCS name found so far, and RCSerrno to its errno.
- * Yield true if successful or if an unusual failure.
- */
-{
- int interesting, preferold;
-
- /*
- * We prefer an old name to that of a nonexisting new RCS file,
- * unless we tried locking the old name and failed.
- */
- preferold = RCSbuf.string[0] && (mustread||0<=fdlock);
-
- finptr = (*rcsopen)(&RCSb, &RCSstat, mustread);
- interesting = finptr || errno!=ENOENT;
- if (interesting || !preferold) {
- /* Use the new name. */
- RCSerrno = errno;
- bufscpy(&RCSbuf, RCSb.string);
- }
- return interesting;
-}
-
- static int
-fin2open(d, dlen, base, baselen, x, xlen, rcsopen, mustread)
- char const *d, *base, *x;
- size_t dlen, baselen, xlen;
- RILE *(*rcsopen)P((struct buf*,struct stat*,int));
- int mustread;
-/*
- * D is a directory name with length DLEN (including trailing slash).
- * BASE is a filename with length BASELEN.
- * X is an RCS pathname suffix with length XLEN.
- * Use RCSOPEN to open an RCS file; MUSTREAD is set if the file must be read.
- * Yield true if successful.
- * Try dRCS/basex first; if that fails and x is nonempty, try dbasex.
- * Put these potential names in RCSb.
- * Set RCSbuf to the best RCS name found so far, and RCSerrno to its errno.
- * Yield true if successful or if an unusual failure.
- */
-{
- register char *p;
-
- bufalloc(&RCSb, dlen + rcslen + 1 + baselen + xlen + 1);
-
- /* Try dRCS/basex. */
- VOID memcpy(p = RCSb.string, d, dlen);
- VOID memcpy(p += dlen, rcsdir, rcslen);
- p += rcslen;
- *p++ = SLASH;
- VOID memcpy(p, base, baselen);
- VOID memcpy(p += baselen, x, xlen);
- p[xlen] = 0;
- if (xlen) {
- if (finopen(rcsopen, mustread))
- return true;
-
- /* Try dbasex. */
- /* Start from scratch, because finopen() may have changed RCSb. */
- VOID memcpy(p = RCSb.string, d, dlen);
- VOID memcpy(p += dlen, base, baselen);
- VOID memcpy(p += baselen, x, xlen);
- p[xlen] = 0;
- }
- return finopen(rcsopen, mustread);
-}
-
- int
-pairnames(argc, argv, rcsopen, mustread, quiet)
- int argc;
- char **argv;
- RILE *(*rcsopen)P((struct buf*,struct stat*,int));
- int mustread, quiet;
-/*
- * Pair the pathnames pointed to by argv; argc indicates
- * how many there are.
- * Place a pointer to the RCS pathname into RCSname,
- * and a pointer to the pathname of the working file into workname.
- * If both are given, and workstdout
- * is set, a warning is printed.
- *
- * If the RCS file exists, places its status into RCSstat.
- *
- * If the RCS file exists, it is RCSOPENed for reading, the file pointer
- * is placed into finptr, and the admin-node is read in; returns 1.
- * If the RCS file does not exist and MUSTREAD,
- * print an error unless QUIET and return 0.
- * Otherwise, initialize the admin node and return -1.
- *
- * 0 is returned on all errors, e.g. files that are not regular files.
- */
-{
- static struct buf tempbuf;
-
- register char *p, *arg, *RCS1;
- char const *base, *RCSbase, *x;
- int paired;
- size_t arglen, dlen, baselen, xlen;
-
- fdlock = -1;
-
- if (!(arg = *argv)) return 0; /* already paired pathname */
- if (*arg == '-') {
- error("%s option is ignored after pathnames", arg);
- return 0;
- }
-
- base = basefilename(arg);
- paired = false;
-
- /* first check suffix to see whether it is an RCS file or not */
- if ((x = rcssuffix(arg)))
- {
- /* RCS pathname given */
- RCS1 = arg;
- RCSbase = base;
- baselen = x - base;
- if (
- 1 < argc &&
- !rcssuffix(workname = p = argv[1]) &&
- baselen <= (arglen = strlen(p)) &&
- ((p+=arglen-baselen) == workname || isSLASH(p[-1])) &&
- memcmp(base, p, baselen) == 0
- ) {
- argv[1] = 0;
- paired = true;
- } else {
- bufscpy(&tempbuf, base);
- workname = p = tempbuf.string;
- p[baselen] = 0;
- }
- } else {
- /* working file given; now try to find RCS file */
- workname = arg;
- baselen = strlen(base);
- /* Derive RCS pathname. */
- if (
- 1 < argc &&
- (x = rcssuffix(RCS1 = argv[1])) &&
- baselen <= x - RCS1 &&
- ((RCSbase=x-baselen)==RCS1 || isSLASH(RCSbase[-1])) &&
- memcmp(base, RCSbase, baselen) == 0
- ) {
- argv[1] = 0;
- paired = true;
- } else
- RCSbase = RCS1 = 0;
- }
- /* Now we have a (tentative) RCS pathname in RCS1 and workname. */
- /* Second, try to find the right RCS file */
- if (RCSbase!=RCS1) {
- /* a path for RCSfile is given; single RCS file to look for */
- bufscpy(&RCSbuf, RCS1);
- finptr = (*rcsopen)(&RCSbuf, &RCSstat, mustread);
- RCSerrno = errno;
- } else {
- bufscpy(&RCSbuf, "");
- if (RCS1)
- /* RCS filename was given without path. */
- VOID fin2open(arg, (size_t)0, RCSbase, baselen,
- x, strlen(x), rcsopen, mustread
- );
- else {
- /* No RCS pathname was given. */
- /* Try each suffix in turn. */
- dlen = base-arg;
- x = suffixes;
- while (! fin2open(arg, dlen, base, baselen,
- x, xlen=suffixlen(x), rcsopen, mustread
- )) {
- x += xlen;
- if (!*x++)
- break;
- }
- }
- }
- RCSname = p = RCSbuf.string;
- if (finptr) {
- if (!S_ISREG(RCSstat.st_mode)) {
- error("%s isn't a regular file -- ignored", p);
- return 0;
- }
- Lexinit(); getadmin();
- } else {
- if (RCSerrno!=ENOENT || mustread || fdlock<0) {
- if (RCSerrno == EEXIST)
- error("RCS file %s is in use", p);
- else if (!quiet || RCSerrno!=ENOENT)
- enerror(RCSerrno, p);
- return 0;
- }
- InitAdmin();
- };
-
- if (paired && workstdout)
- workwarn("Working file ignored due to -p option");
-
- prevkeys = false;
- return finptr ? 1 : -1;
-}
-
-
- char const *
-getfullRCSname()
-/*
- * Return a pointer to the full pathname of the RCS file.
- * Remove leading `./'.
- */
-{
- if (ROOTPATH(RCSname)) {
- return RCSname;
- } else {
- static struct buf rcsbuf;
-# if needs_getabsname
- bufalloc(&rcsbuf, SIZEABLE_PATH + 1);
- while (getabsname(RCSname, rcsbuf.string, rcsbuf.size) != 0)
- if (errno == ERANGE)
- bufalloc(&rcsbuf, rcsbuf.size<<1);
- else
- efaterror("getabsname");
-# else
- static char const *wdptr;
- static struct buf wdbuf;
- static size_t wdlen;
-
- register char const *r;
- register size_t dlen;
- register char *d;
- register char const *wd;
-
- if (!(wd = wdptr)) {
- /* Get working directory for the first time. */
- char *PWD = cgetenv("PWD");
- struct stat PWDstat, dotstat;
- if (! (
- (d = PWD) &&
- ROOTPATH(PWD) &&
- stat(PWD, &PWDstat) == 0 &&
- stat(".", &dotstat) == 0 &&
- same_file(PWDstat, dotstat, 1)
- )) {
- bufalloc(&wdbuf, SIZEABLE_PATH + 1);
-# if has_getcwd || !has_getwd
- while (!(d = getcwd(wdbuf.string, wdbuf.size)))
- if (errno == ERANGE)
- bufalloc(&wdbuf, wdbuf.size<<1);
- else if ((d = PWD))
- break;
- else
- efaterror("getcwd");
-# else
- d = getwd(wdbuf.string);
- if (!d && !(d = PWD))
- efaterror("getwd");
-# endif
- }
- wdlen = dir_useful_len(d);
- d[wdlen] = 0;
- wdptr = wd = d;
- }
- /*
- * Remove leading `./'s from RCSname.
- * Do not try to handle `../', since removing it may yield
- * the wrong answer in the presence of symbolic links.
- */
- for (r = RCSname; r[0]=='.' && isSLASH(r[1]); r += 2)
- /* `.////' is equivalent to `./'. */
- while (isSLASH(r[2]))
- r++;
- /* Build full pathname. */
- dlen = wdlen;
- bufalloc(&rcsbuf, dlen + strlen(r) + 2);
- d = rcsbuf.string;
- VOID memcpy(d, wd, dlen);
- d += dlen;
- *d++ = SLASH;
- VOID strcpy(d, r);
-# endif
- return rcsbuf.string;
- }
-}
-
-/* Derived from code from the XFree86 project */
- char const *
-getfullCVSname()
-/* Function: returns a pointer to the path name of the RCS file with the
- * CVSROOT part stripped off, and with 'Attic/' stripped off (if present).
- */
-{
-
-#define ATTICDIR "/Attic"
-
- char const *namebuf = getfullRCSname();
- char *cvsroot = cgetenv("CVSROOT");
- int cvsrootlen;
- char *c = NULL;
- int alen = strlen(ATTICDIR);
-
- if ((c = strrchr(namebuf, '/')) != NULL) {
- if (namebuf - c >= alen) {
- if (!strncmp(c - alen, ATTICDIR, alen)) {
- while(*c != '\0') {
- *(c - alen) = *c;
- c++;
- }
- *(c - alen) = '\0';
- }
- }
- }
-
- if (!cvsroot)
- return(namebuf);
- else
- {
- cvsrootlen = strlen(cvsroot);
- if (!strncmp(namebuf, cvsroot, cvsrootlen) &&
- namebuf[cvsrootlen] == '/')
- return(namebuf + cvsrootlen + 1);
- else
- return(namebuf);
- }
-}
-
- static size_t
-dir_useful_len(d)
- char const *d;
-/*
-* D names a directory; yield the number of characters of D's useful part.
-* To create a file in D, append a SLASH and a file name to D's useful part.
-* Ignore trailing slashes if possible; not only are they ugly,
-* but some non-Posix systems misbehave unless the slashes are omitted.
-*/
-{
-# ifndef SLASHSLASH_is_SLASH
-# define SLASHSLASH_is_SLASH 0
-# endif
- size_t dlen = strlen(d);
- if (!SLASHSLASH_is_SLASH && dlen==2 && isSLASH(d[0]) && isSLASH(d[1]))
- --dlen;
- else
- while (dlen && isSLASH(d[dlen-1]))
- --dlen;
- return dlen;
-}
-
-#ifndef isSLASH
- int
-isSLASH(c)
- int c;
-{
- switch (c) {
- case SLASHes:
- return true;
- default:
- return false;
- }
-}
-#endif
-
-
-#if !has_getcwd && !has_getwd
-
- char *
-getcwd(path, size)
- char *path;
- size_t size;
-{
- static char const usrbinpwd[] = "/usr/bin/pwd";
-# define binpwd (usrbinpwd+4)
-
- register FILE *fp;
- register int c;
- register char *p, *lim;
- int closeerrno, closeerror, e, fd[2], readerror, toolong, wstatus;
- pid_t child;
-
- if (!size) {
- errno = EINVAL;
- return 0;
- }
- if (pipe(fd) != 0)
- return 0;
-# if bad_wait_if_SIGCHLD_ignored
-# ifndef SIGCHLD
-# define SIGCHLD SIGCLD
-# endif
- VOID signal(SIGCHLD, SIG_DFL);
-# endif
- if (!(child = vfork())) {
- if (
- close(fd[0]) == 0 &&
- (fd[1] == STDOUT_FILENO ||
-# ifdef F_DUPFD
- (VOID close(STDOUT_FILENO),
- fcntl(fd[1], F_DUPFD, STDOUT_FILENO))
-# else
- dup2(fd[1], STDOUT_FILENO)
-# endif
- == STDOUT_FILENO &&
- close(fd[1]) == 0
- )
- ) {
- VOID close(STDERR_FILENO);
- VOID execl(binpwd, binpwd, (char *)0);
- VOID execl(usrbinpwd, usrbinpwd, (char *)0);
- }
- _exit(EXIT_FAILURE);
- }
- e = errno;
- closeerror = close(fd[1]);
- closeerrno = errno;
- fp = 0;
- readerror = toolong = wstatus = 0;
- p = path;
- if (0 <= child) {
- fp = fdopen(fd[0], "r");
- e = errno;
- if (fp) {
- lim = p + size;
- for (p = path; ; *p++ = c) {
- if ((c=getc(fp)) < 0) {
- if (feof(fp))
- break;
- if (ferror(fp)) {
- readerror = 1;
- e = errno;
- break;
- }
- }
- if (p == lim) {
- toolong = 1;
- break;
- }
- }
- }
-# if has_waitpid
- if (waitpid(child, &wstatus, 0) < 0)
- wstatus = 1;
-# else
- {
- pid_t w;
- do {
- if ((w = wait(&wstatus)) < 0) {
- wstatus = 1;
- break;
- }
- } while (w != child);
- }
-# endif
- }
- if (!fp) {
- VOID close(fd[0]);
- errno = e;
- return 0;
- }
- if (fclose(fp) != 0)
- return 0;
- if (readerror) {
- errno = e;
- return 0;
- }
- if (closeerror) {
- errno = closeerrno;
- return 0;
- }
- if (toolong) {
- errno = ERANGE;
- return 0;
- }
- if (wstatus || p == path || *--p != '\n') {
- errno = EACCES;
- return 0;
- }
- *p = '\0';
- return path;
-}
-#endif
-
-
-#ifdef PAIRTEST
-/* test program for pairnames() and getfullRCSname() */
-
-char const cmdid[] = "pair";
-
-main(argc, argv)
-int argc; char *argv[];
-{
- int result;
- int initflag;
- quietflag = initflag = false;
-
- while(--argc, ++argv, argc>=1 && ((*argv)[0] == '-')) {
- switch ((*argv)[1]) {
-
- case 'p': workstdout = stdout;
- break;
- case 'i': initflag=true;
- break;
- case 'q': quietflag=true;
- break;
- default: error("unknown option: %s", *argv);
- break;
- }
- }
-
- do {
- RCSname = workname = 0;
- result = pairnames(argc,argv,rcsreadopen,!initflag,quietflag);
- if (result!=0) {
- diagnose("RCS pathname: %s; working pathname: %s\nFull RCS pathname: %s\n",
- RCSname, workname, getfullRCSname()
- );
- }
- switch (result) {
- case 0: continue; /* already paired file */
-
- case 1: if (initflag) {
- rcserror("already exists");
- } else {
- diagnose("RCS file %s exists\n", RCSname);
- }
- Ifclose(finptr);
- break;
-
- case -1:diagnose("RCS file doesn't exist\n");
- break;
- }
-
- } while (++argv, --argc>=1);
-
-}
-
- void
-exiterr()
-{
- dirtempunlink();
- tempunlink();
- _exit(EXIT_FAILURE);
-}
-#endif
diff --git a/gnu/usr.bin/rcs/lib/rcsgen.c b/gnu/usr.bin/rcs/lib/rcsgen.c
deleted file mode 100644
index 4301de7..0000000
--- a/gnu/usr.bin/rcs/lib/rcsgen.c
+++ /dev/null
@@ -1,681 +0,0 @@
-/* Generate RCS revisions. */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.16 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.15 1995/06/01 16:23:43 eggert
- * (putadmin): Open RCS file with FOPEN_WB.
- *
- * Revision 5.14 1994/03/17 14:05:48 eggert
- * Work around SVR4 stdio performance bug.
- * Flush stderr after prompt. Remove lint.
- *
- * Revision 5.13 1993/11/03 17:42:27 eggert
- * Don't discard ignored phrases. Improve quality of diagnostics.
- *
- * Revision 5.12 1992/07/28 16:12:44 eggert
- * Statement macro names now end in _.
- * Be consistent about pathnames vs filenames.
- *
- * Revision 5.11 1992/01/24 18:44:19 eggert
- * Move put routines here from rcssyn.c.
- * Add support for bad_creat0.
- *
- * Revision 5.10 1991/10/07 17:32:46 eggert
- * Fix log bugs, e.g. ci -t/dev/null when has_mmap.
- *
- * Revision 5.9 1991/09/10 22:15:46 eggert
- * Fix test for redirected stdin.
- *
- * Revision 5.8 1991/08/19 03:13:55 eggert
- * Add piece tables. Tune.
- *
- * Revision 5.7 1991/04/21 11:58:24 eggert
- * Add MS-DOS support.
- *
- * Revision 5.6 1990/12/27 19:54:26 eggert
- * Fix bug: rcs -t inserted \n, making RCS file grow.
- *
- * Revision 5.5 1990/12/04 05:18:45 eggert
- * Use -I for prompts and -q for diagnostics.
- *
- * Revision 5.4 1990/11/01 05:03:47 eggert
- * Add -I and new -t behavior. Permit arbitrary data in logs.
- *
- * Revision 5.3 1990/09/21 06:12:43 hammer
- * made putdesc() treat stdin the same whether or not it was from a terminal
- * by making it recognize that a single '.' was then end of the
- * description always
- *
- * Revision 5.2 1990/09/04 08:02:25 eggert
- * Fix `co -p1.1 -ko' bug. Standardize yes-or-no procedure.
- *
- * Revision 5.1 1990/08/29 07:14:01 eggert
- * Clean old log messages too.
- *
- * Revision 5.0 1990/08/22 08:12:52 eggert
- * Remove compile-time limits; use malloc instead.
- * Ansify and Posixate.
- *
- * Revision 4.7 89/05/01 15:12:49 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.6 88/08/28 14:59:10 eggert
- * Shrink stdio code size; allow cc -R; remove lint; isatty() -> ttystdin()
- *
- * Revision 4.5 87/12/18 11:43:25 narten
- * additional lint cleanups, and a bug fix from the 4.3BSD version that
- * keeps "ci" from sticking a '\377' into the description if you run it
- * with a zero-length file as the description. (Guy Harris)
- *
- * Revision 4.4 87/10/18 10:35:10 narten
- * Updating version numbers. Changes relative to 1.1 actually relative to
- * 4.2
- *
- * Revision 1.3 87/09/24 13:59:51 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:27 jenkins
- * Port to suns
- *
- * Revision 4.2 83/12/02 23:01:39 wft
- * merged 4.1 and 3.3.1.1 (clearerr(stdin)).
- *
- * Revision 4.1 83/05/10 16:03:33 wft
- * Changed putamin() to abort if trying to reread redirected stdin.
- * Fixed getdesc() to output a prompt on initial newline.
- *
- * Revision 3.3.1.1 83/10/19 04:21:51 lepreau
- * Added clearerr(stdin) for re-reading description from stdin.
- *
- * Revision 3.3 82/11/28 21:36:49 wft
- * 4.2 prerelease
- *
- * Revision 3.3 82/11/28 21:36:49 wft
- * Replaced ferror() followed by fclose() with ffclose().
- * Putdesc() now suppresses the prompts if stdin
- * is not a terminal. A pointer to the current log message is now
- * inserted into the corresponding delta, rather than leaving it in a
- * global variable.
- *
- * Revision 3.2 82/10/18 21:11:26 wft
- * I added checks for write errors during editing, and improved
- * the prompt on putdesc().
- *
- * Revision 3.1 82/10/13 15:55:09 wft
- * corrected type of variables assigned to by getc (char --> int)
- */
-
-
-
-
-#include "rcsbase.h"
-
-libId(genId, "$Id$")
-
-int interactiveflag; /* Should we act as if stdin is a tty? */
-struct buf curlogbuf; /* buffer for current log message */
-
-enum stringwork { enter, copy, edit, expand, edit_expand };
-
-static void putdelta P((struct hshentry const*,FILE*));
-static void scandeltatext P((struct hshentry*,enum stringwork,int));
-
-
-
-
- char const *
-buildrevision(deltas, target, outfile, expandflag)
- struct hshentries const *deltas;
- struct hshentry *target;
- FILE *outfile;
- int expandflag;
-/* Function: Generates the revision given by target
- * by retrieving all deltas given by parameter deltas and combining them.
- * If outfile is set, the revision is output to it,
- * otherwise written into a temporary file.
- * Temporary files are allocated by maketemp().
- * if expandflag is set, keyword expansion is performed.
- * Return 0 if outfile is set, the name of the temporary file otherwise.
- *
- * Algorithm: Copy initial revision unchanged. Then edit all revisions but
- * the last one into it, alternating input and output files (resultname and
- * editname). The last revision is then edited in, performing simultaneous
- * keyword substitution (this saves one extra pass).
- * All this simplifies if only one revision needs to be generated,
- * or no keyword expansion is necessary, or if output goes to stdout.
- */
-{
- if (deltas->first == target) {
- /* only latest revision to generate */
- openfcopy(outfile);
- scandeltatext(target, expandflag?expand:copy, true);
- if (outfile)
- return 0;
- else {
- Ozclose(&fcopy);
- return resultname;
- }
- } else {
- /* several revisions to generate */
- /* Get initial revision without keyword expansion. */
- scandeltatext(deltas->first, enter, false);
- while ((deltas=deltas->rest)->rest) {
- /* do all deltas except last one */
- scandeltatext(deltas->first, edit, false);
- }
- if (expandflag || outfile) {
- /* first, get to beginning of file*/
- finishedit((struct hshentry*)0, outfile, false);
- }
- scandeltatext(target, expandflag?edit_expand:edit, true);
- finishedit(
- expandflag ? target : (struct hshentry*)0,
- outfile, true
- );
- if (outfile)
- return 0;
- Ozclose(&fcopy);
- return resultname;
- }
-}
-
-
-
- static void
-scandeltatext(delta, func, needlog)
- struct hshentry *delta;
- enum stringwork func;
- int needlog;
-/* Function: Scans delta text nodes up to and including the one given
- * by delta. For the one given by delta, the log message is saved into
- * delta->log if needlog is set; func specifies how to handle the text.
- * Similarly, if needlog, delta->igtext is set to the ignored phrases.
- * Assumes the initial lexeme must be read in first.
- * Does not advance nexttok after it is finished.
- */
-{
- struct hshentry const *nextdelta;
- struct cbuf cb;
-
- for (;;) {
- if (eoflex())
- fatserror("can't find delta for revision %s", delta->num);
- nextlex();
- if (!(nextdelta=getnum())) {
- fatserror("delta number corrupted");
- }
- getkeystring(Klog);
- if (needlog && delta==nextdelta) {
- cb = savestring(&curlogbuf);
- delta->log = cleanlogmsg(curlogbuf.string, cb.size);
- nextlex();
- delta->igtext = getphrases(Ktext);
- } else {readstring();
- ignorephrases(Ktext);
- }
- getkeystring(Ktext);
-
- if (delta==nextdelta)
- break;
- readstring(); /* skip over it */
-
- }
- switch (func) {
- case enter: enterstring(); break;
- case copy: copystring(); break;
- case expand: xpandstring(delta); break;
- case edit: editstring((struct hshentry *)0); break;
- case edit_expand: editstring(delta); break;
- }
-}
-
- struct cbuf
-cleanlogmsg(m, s)
- char *m;
- size_t s;
-{
- register char *t = m;
- register char const *f = t;
- struct cbuf r;
- while (s) {
- --s;
- if ((*t++ = *f++) == '\n')
- while (m < --t)
- if (t[-1]!=' ' && t[-1]!='\t') {
- *t++ = '\n';
- break;
- }
- }
- while (m < t && (t[-1]==' ' || t[-1]=='\t' || t[-1]=='\n'))
- --t;
- r.string = m;
- r.size = t - m;
- return r;
-}
-
-
-int ttystdin()
-{
- static int initialized;
- if (!initialized) {
- if (!interactiveflag)
- interactiveflag = isatty(STDIN_FILENO);
- initialized = true;
- }
- return interactiveflag;
-}
-
- int
-getcstdin()
-{
- register FILE *in;
- register int c;
-
- in = stdin;
- if (feof(in) && ttystdin())
- clearerr(in);
- c = getc(in);
- if (c == EOF) {
- testIerror(in);
- if (feof(in) && ttystdin())
- afputc('\n',stderr);
- }
- return c;
-}
-
-#if has_prototypes
- int
-yesorno(int default_answer, char const *question, ...)
-#else
- /*VARARGS2*/ int
- yesorno(default_answer, question, va_alist)
- int default_answer; char const *question; va_dcl
-#endif
-{
- va_list args;
- register int c, r;
- if (!quietflag && ttystdin()) {
- oflush();
- vararg_start(args, question);
- fvfprintf(stderr, question, args);
- va_end(args);
- eflush();
- r = c = getcstdin();
- while (c!='\n' && !feof(stdin))
- c = getcstdin();
- if (r=='y' || r=='Y')
- return true;
- if (r=='n' || r=='N')
- return false;
- }
- return default_answer;
-}
-
-
- void
-putdesc(textflag, textfile)
- int textflag;
- char *textfile;
-/* Function: puts the descriptive text into file frewrite.
- * if finptr && !textflag, the text is copied from the old description.
- * Otherwise, if textfile, the text is read from that
- * file, or from stdin, if !textfile.
- * A textfile with a leading '-' is treated as a string, not a pathname.
- * If finptr, the old descriptive text is discarded.
- * Always clears foutptr.
- */
-{
- static struct buf desc;
- static struct cbuf desclean;
-
- register FILE *txt;
- register int c;
- register FILE * frew;
- register char *p;
- register size_t s;
- char const *plim;
-
- frew = frewrite;
- if (finptr && !textflag) {
- /* copy old description */
- aprintf(frew, "\n\n%s%c", Kdesc, nextc);
- foutptr = frewrite;
- getdesc(false);
- foutptr = 0;
- } else {
- foutptr = 0;
- /* get new description */
- if (finptr) {
- /*skip old description*/
- getdesc(false);
- }
- aprintf(frew,"\n\n%s\n%c",Kdesc,SDELIM);
- if (!textfile)
- desclean = getsstdin(
- "t-", "description",
- "NOTE: This is NOT the log message!\n", &desc
- );
- else if (!desclean.string) {
- if (*textfile == '-') {
- p = textfile + 1;
- s = strlen(p);
- } else {
- if (!(txt = fopenSafer(textfile, "r")))
- efaterror(textfile);
- bufalloc(&desc, 1);
- p = desc.string;
- plim = p + desc.size;
- for (;;) {
- if ((c=getc(txt)) == EOF) {
- testIerror(txt);
- if (feof(txt))
- break;
- }
- if (plim <= p)
- p = bufenlarge(&desc, &plim);
- *p++ = c;
- }
- if (fclose(txt) != 0)
- Ierror();
- s = p - desc.string;
- p = desc.string;
- }
- desclean = cleanlogmsg(p, s);
- }
- putstring(frew, false, desclean, true);
- aputc_('\n', frew)
- }
-}
-
- struct cbuf
-getsstdin(option, name, note, buf)
- char const *option, *name, *note;
- struct buf *buf;
-{
- register int c;
- register char *p;
- register size_t i;
- register int tty = ttystdin();
-
- if (tty) {
- aprintf(stderr,
- "enter %s, terminated with single '.' or end of file:\n%s>> ",
- name, note
- );
- eflush();
- } else if (feof(stdin))
- rcsfaterror("can't reread redirected stdin for %s; use -%s<%s>",
- name, option, name
- );
-
- for (
- i = 0, p = 0;
- c = getcstdin(), !feof(stdin);
- bufrealloc(buf, i+1), p = buf->string, p[i++] = c
- )
- if (c == '\n')
- if (i && p[i-1]=='.' && (i==1 || p[i-2]=='\n')) {
- /* Remove trailing '.'. */
- --i;
- break;
- } else if (tty) {
- aputs(">> ", stderr);
- eflush();
- }
- return cleanlogmsg(p, i);
-}
-
-
- void
-putadmin()
-/* Output the admin node. */
-{
- register FILE *fout;
- struct assoc const *curassoc;
- struct rcslock const *curlock;
- struct access const *curaccess;
-
- if (!(fout = frewrite)) {
-# if bad_creat0
- ORCSclose();
- fout = fopenSafer(makedirtemp(0), FOPEN_WB);
-# else
- int fo = fdlock;
- fdlock = -1;
- fout = fdopen(fo, FOPEN_WB);
-# endif
-
- if (!(frewrite = fout))
- efaterror(RCSname);
- }
-
- /*
- * Output the first character with putc, not printf.
- * Otherwise, an SVR4 stdio bug buffers output inefficiently.
- */
- aputc_(*Khead, fout)
- aprintf(fout, "%s\t%s;\n", Khead + 1, Head?Head->num:"");
- if (Dbranch && VERSION(4)<=RCSversion)
- aprintf(fout, "%s\t%s;\n", Kbranch, Dbranch);
-
- aputs(Kaccess, fout);
- curaccess = AccessList;
- while (curaccess) {
- aprintf(fout, "\n\t%s", curaccess->login);
- curaccess = curaccess->nextaccess;
- }
- aprintf(fout, ";\n%s", Ksymbols);
- curassoc = Symbols;
- while (curassoc) {
- aprintf(fout, "\n\t%s:%s", curassoc->symbol, curassoc->num);
- curassoc = curassoc->nextassoc;
- }
- aprintf(fout, ";\n%s", Klocks);
- curlock = Locks;
- while (curlock) {
- aprintf(fout, "\n\t%s:%s", curlock->login, curlock->delta->num);
- curlock = curlock->nextlock;
- }
- if (StrictLocks) aprintf(fout, "; %s", Kstrict);
- aprintf(fout, ";\n");
- if (Comment.size) {
- aprintf(fout, "%s\t", Kcomment);
- putstring(fout, true, Comment, false);
- aprintf(fout, ";\n");
- }
- if (Expand != KEYVAL_EXPAND)
- aprintf(fout, "%s\t%c%s%c;\n",
- Kexpand, SDELIM, expand_names[Expand], SDELIM
- );
- awrite(Ignored.string, Ignored.size, fout);
- aputc_('\n', fout)
-}
-
-
- static void
-putdelta(node, fout)
- register struct hshentry const *node;
- register FILE * fout;
-/* Output the delta NODE to FOUT. */
-{
- struct branchhead const *nextbranch;
-
- if (!node) return;
-
- aprintf(fout, "\n%s\n%s\t%s;\t%s %s;\t%s %s;\nbranches",
- node->num,
- Kdate, node->date,
- Kauthor, node->author,
- Kstate, node->state?node->state:""
- );
- nextbranch = node->branches;
- while (nextbranch) {
- aprintf(fout, "\n\t%s", nextbranch->hsh->num);
- nextbranch = nextbranch->nextbranch;
- }
-
- aprintf(fout, ";\n%s\t%s;\n", Knext, node->next?node->next->num:"");
- awrite(node->ig.string, node->ig.size, fout);
-}
-
-
- void
-puttree(root, fout)
- struct hshentry const *root;
- register FILE *fout;
-/* Output the delta tree with base ROOT in preorder to FOUT. */
-{
- struct branchhead const *nextbranch;
-
- if (!root) return;
-
- if (root->selector)
- putdelta(root, fout);
-
- puttree(root->next, fout);
-
- nextbranch = root->branches;
- while (nextbranch) {
- puttree(nextbranch->hsh, fout);
- nextbranch = nextbranch->nextbranch;
- }
-}
-
-
- int
-putdtext(delta, srcname, fout, diffmt)
- struct hshentry const *delta;
- char const *srcname;
- FILE *fout;
- int diffmt;
-/*
- * Output a deltatext node with delta number DELTA->num, log message DELTA->log,
- * ignored phrases DELTA->igtext and text SRCNAME to FOUT.
- * Double up all SDELIMs in both the log and the text.
- * Make sure the log message ends in \n.
- * Return false on error.
- * If DIFFMT, also check that the text is valid diff -n output.
- */
-{
- RILE *fin;
- if (!(fin = Iopen(srcname, "r", (struct stat*)0))) {
- eerror(srcname);
- return false;
- }
- putdftext(delta, fin, fout, diffmt);
- Ifclose(fin);
- return true;
-}
-
- void
-putstring(out, delim, s, log)
- register FILE *out;
- struct cbuf s;
- int delim, log;
-/*
- * Output to OUT one SDELIM if DELIM, then the string S with SDELIMs doubled.
- * If LOG is set then S is a log string; append a newline if S is nonempty.
- */
-{
- register char const *sp;
- register size_t ss;
-
- if (delim)
- aputc_(SDELIM, out)
- sp = s.string;
- for (ss = s.size; ss; --ss) {
- if (*sp == SDELIM)
- aputc_(SDELIM, out)
- aputc_(*sp++, out)
- }
- if (s.size && log)
- aputc_('\n', out)
- aputc_(SDELIM, out)
-}
-
- void
-putdftext(delta, finfile, foutfile, diffmt)
- struct hshentry const *delta;
- RILE *finfile;
- FILE *foutfile;
- int diffmt;
-/* like putdtext(), except the source file is already open */
-{
- declarecache;
- register FILE *fout;
- register int c;
- register RILE *fin;
- int ed;
- struct diffcmd dc;
-
- fout = foutfile;
- aprintf(fout, DELNUMFORM, delta->num, Klog);
-
- /* put log */
- putstring(fout, true, delta->log, true);
- aputc_('\n', fout)
-
- /* put ignored phrases */
- awrite(delta->igtext.string, delta->igtext.size, fout);
-
- /* put text */
- aprintf(fout, "%s\n%c", Ktext, SDELIM);
-
- fin = finfile;
- setupcache(fin);
- if (!diffmt) {
- /* Copy the file */
- cache(fin);
- for (;;) {
- cachegeteof_(c, break;)
- if (c==SDELIM) aputc_(SDELIM, fout) /*double up SDELIM*/
- aputc_(c, fout)
- }
- } else {
- initdiffcmd(&dc);
- while (0 <= (ed = getdiffcmd(fin, false, fout, &dc)))
- if (ed) {
- cache(fin);
- while (dc.nlines--)
- do {
- cachegeteof_(c, { if (!dc.nlines) goto OK_EOF; unexpected_EOF(); })
- if (c == SDELIM)
- aputc_(SDELIM, fout)
- aputc_(c, fout)
- } while (c != '\n');
- uncache(fin);
- }
- }
- OK_EOF:
- aprintf(fout, "%c\n", SDELIM);
-}
diff --git a/gnu/usr.bin/rcs/lib/rcskeep.c b/gnu/usr.bin/rcs/lib/rcskeep.c
deleted file mode 100644
index ebc369e..0000000
--- a/gnu/usr.bin/rcs/lib/rcskeep.c
+++ /dev/null
@@ -1,452 +0,0 @@
-/* Extract RCS keyword string values from working files. */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.10 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.9 1995/06/01 16:23:43 eggert
- * (getoldkeys): Don't panic if a Name: is empty.
- *
- * Revision 5.8 1994/03/17 14:05:48 eggert
- * Remove lint.
- *
- * Revision 5.7 1993/11/09 17:40:15 eggert
- * Use simpler timezone parsing strategy now that we're using ISO 8601 format.
- *
- * Revision 5.6 1993/11/03 17:42:27 eggert
- * Scan for Name keyword. Improve quality of diagnostics.
- *
- * Revision 5.5 1992/07/28 16:12:44 eggert
- * Statement macro names now end in _.
- *
- * Revision 5.4 1991/08/19 03:13:55 eggert
- * Tune.
- *
- * Revision 5.3 1991/04/21 11:58:25 eggert
- * Shorten names to keep them distinct on shortname hosts.
- *
- * Revision 5.2 1990/10/04 06:30:20 eggert
- * Parse time zone offsets; future RCS versions may output them.
- *
- * Revision 5.1 1990/09/20 02:38:56 eggert
- * ci -k now checks dates more thoroughly.
- *
- * Revision 5.0 1990/08/22 08:12:53 eggert
- * Retrieve old log message if there is one.
- * Don't require final newline.
- * Remove compile-time limits; use malloc instead. Tune.
- * Permit dates past 1999/12/31. Ansify and Posixate.
- *
- * Revision 4.6 89/05/01 15:12:56 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.5 88/08/09 19:13:03 eggert
- * Remove lint and speed up by making FILE *fp local, not global.
- *
- * Revision 4.4 87/12/18 11:44:21 narten
- * more lint cleanups (Guy Harris)
- *
- * Revision 4.3 87/10/18 10:35:50 narten
- * Updating version numbers. Changes relative to 1.1 actually relative
- * to 4.1
- *
- * Revision 1.3 87/09/24 14:00:00 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:29 jenkins
- * Port to suns
- *
- * Revision 4.1 83/05/10 16:26:44 wft
- * Added new markers Id and RCSfile; extraction added.
- * Marker matching with trymatch().
- *
- * Revision 3.2 82/12/24 12:08:26 wft
- * added missing #endif.
- *
- * Revision 3.1 82/12/04 13:22:41 wft
- * Initial revision.
- *
- */
-
-#include "rcsbase.h"
-
-libId(keepId, "$Id: rcskeep.c,v 1.6 1997/02/22 15:47:38 peter Exp $")
-
-static int badly_terminated P((void));
-static int checknum P((char const*));
-static int get0val P((int,RILE*,struct buf*,int));
-static int getval P((RILE*,struct buf*,int));
-static int keepdate P((RILE*));
-static int keepid P((int,RILE*,struct buf*));
-static int keeprev P((RILE*));
-
-int prevkeys;
-struct buf prevauthor, prevdate, prevname, prevrev, prevstate;
-
- int
-getoldkeys(fp)
- register RILE *fp;
-/* Function: Tries to read keyword values for author, date,
- * revision number, and state out of the file fp.
- * If fp is null, workname is opened and closed instead of using fp.
- * The results are placed into
- * prevauthor, prevdate, prevname, prevrev, prevstate.
- * Aborts immediately if it finds an error and returns false.
- * If it returns true, it doesn't mean that any of the
- * values were found; instead, check to see whether the corresponding arrays
- * contain the empty string.
- */
-{
- register int c;
- char keyword[keylength+1];
- register char * tp;
- int needs_closing;
- int prevname_found;
-
- if (prevkeys)
- return true;
-
- needs_closing = false;
- if (!fp) {
- if (!(fp = Iopen(workname, FOPEN_R_WORK, (struct stat*)0))) {
- eerror(workname);
- return false;
- }
- needs_closing = true;
- }
-
- /* initialize to empty */
- bufscpy(&prevauthor, "");
- bufscpy(&prevdate, "");
- bufscpy(&prevname, ""); prevname_found = 0;
- bufscpy(&prevrev, "");
- bufscpy(&prevstate, "");
-
- c = '\0'; /* anything but KDELIM */
- for (;;) {
- if ( c==KDELIM) {
- do {
- /* try to get keyword */
- tp = keyword;
- for (;;) {
- Igeteof_(fp, c, goto ok;)
- switch (c) {
- default:
- if (keyword+keylength <= tp)
- break;
- *tp++ = c;
- continue;
-
- case '\n': case KDELIM: case VDELIM:
- break;
- }
- break;
- }
- } while (c==KDELIM);
- if (c!=VDELIM) continue;
- *tp = c;
- Igeteof_(fp, c, break;)
- switch (c) {
- case ' ': case '\t': break;
- default: continue;
- }
-
- switch (trymatch(keyword)) {
- case Author:
- if (!keepid(0, fp, &prevauthor))
- return false;
- c = 0;
- break;
- case Date:
- if (!(c = keepdate(fp)))
- return false;
- break;
- case Header:
- case Id:
- case LocalId:
- if (!(
- getval(fp, (struct buf*)0, false) &&
- keeprev(fp) &&
- (c = keepdate(fp)) &&
- keepid(c, fp, &prevauthor) &&
- keepid(0, fp, &prevstate)
- ))
- return false;
- /* Skip either ``who'' (new form) or ``Locker: who'' (old). */
- if (getval(fp, (struct buf*)0, true) &&
- getval(fp, (struct buf*)0, true))
- c = 0;
- else if (nerror)
- return false;
- else
- c = KDELIM;
- break;
- case Locker:
- (void) getval(fp, (struct buf*)0, false);
- c = 0;
- break;
- case Log:
- case RCSfile:
- case Source:
- if (!getval(fp, (struct buf*)0, false))
- return false;
- c = 0;
- break;
- case Name:
- if (getval(fp, &prevname, false)) {
- if (*prevname.string)
- checkssym(prevname.string);
- prevname_found = 1;
- }
- c = 0;
- break;
- case Revision:
- if (!keeprev(fp))
- return false;
- c = 0;
- break;
- case State:
- if (!keepid(0, fp, &prevstate))
- return false;
- c = 0;
- break;
- default:
- continue;
- }
- if (!c)
- Igeteof_(fp, c, c=0;)
- if (c != KDELIM) {
- workerror("closing %c missing on keyword", KDELIM);
- return false;
- }
- if (prevname_found &&
- *prevauthor.string && *prevdate.string &&
- *prevrev.string && *prevstate.string
- )
- break;
- }
- Igeteof_(fp, c, break;)
- }
-
- ok:
- if (needs_closing)
- Ifclose(fp);
- else
- Irewind(fp);
- prevkeys = true;
- return true;
-}
-
- static int
-badly_terminated()
-{
- workerror("badly terminated keyword value");
- return false;
-}
-
- static int
-getval(fp, target, optional)
- register RILE *fp;
- struct buf *target;
- int optional;
-/* Reads a keyword value from FP into TARGET.
- * Returns true if one is found, false otherwise.
- * Does not modify target if it is 0.
- * Do not report an error if OPTIONAL is set and KDELIM is found instead.
- */
-{
- int c;
- Igeteof_(fp, c, return badly_terminated();)
- return get0val(c, fp, target, optional);
-}
-
- static int
-get0val(c, fp, target, optional)
- register int c;
- register RILE *fp;
- struct buf *target;
- int optional;
-/* Reads a keyword value from C+FP into TARGET, perhaps OPTIONALly.
- * Same as getval, except C is the lookahead character.
- */
-{ register char * tp;
- char const *tlim;
- register int got1;
-
- if (target) {
- bufalloc(target, 1);
- tp = target->string;
- tlim = tp + target->size;
- } else
- tlim = tp = 0;
- got1 = false;
- for (;;) {
- switch (c) {
- default:
- got1 = true;
- if (tp) {
- *tp++ = c;
- if (tlim <= tp)
- tp = bufenlarge(target, &tlim);
- }
- break;
-
- case ' ':
- case '\t':
- if (tp) {
- *tp = 0;
-# ifdef KEEPTEST
- VOID printf("getval: %s\n", target);
-# endif
- }
- return got1;
-
- case KDELIM:
- if (!got1 && optional)
- return false;
- /* fall into */
- case '\n':
- case 0:
- return badly_terminated();
- }
- Igeteof_(fp, c, return badly_terminated();)
- }
-}
-
-
- static int
-keepdate(fp)
- RILE *fp;
-/* Function: reads a date prevdate; checks format
- * Return 0 on error, lookahead character otherwise.
- */
-{
- struct buf prevday, prevtime;
- register int c;
-
- c = 0;
- bufautobegin(&prevday);
- if (getval(fp,&prevday,false)) {
- bufautobegin(&prevtime);
- if (getval(fp,&prevtime,false)) {
- Igeteof_(fp, c, c=0;)
- if (c) {
- register char const *d = prevday.string, *t = prevtime.string;
- bufalloc(&prevdate, strlen(d) + strlen(t) + 9);
- VOID sprintf(prevdate.string, "%s%s %s%s",
- /* Parse dates put out by old versions of RCS. */
- isdigit(d[0]) && isdigit(d[1]) && !isdigit(d[2])
- ? "19" : "",
- d, t,
- strchr(t,'-') || strchr(t,'+') ? "" : "+0000"
- );
- }
- }
- bufautoend(&prevtime);
- }
- bufautoend(&prevday);
- return c;
-}
-
- static int
-keepid(c, fp, b)
- int c;
- RILE *fp;
- struct buf *b;
-/* Get previous identifier from C+FP into B. */
-{
- if (!c)
- Igeteof_(fp, c, return false;)
- if (!get0val(c, fp, b, false))
- return false;
- checksid(b->string);
- return !nerror;
-}
-
- static int
-keeprev(fp)
- RILE *fp;
-/* Get previous revision from FP into prevrev. */
-{
- return getval(fp,&prevrev,false) && checknum(prevrev.string);
-}
-
-
- static int
-checknum(s)
- char const *s;
-{
- register char const *sp;
- register int dotcount = 0;
- for (sp=s; ; sp++) {
- switch (*sp) {
- case 0:
- if (dotcount & 1)
- return true;
- else
- break;
-
- case '.':
- dotcount++;
- continue;
-
- default:
- if (isdigit(*sp))
- continue;
- break;
- }
- break;
- }
- workerror("%s is not a revision number", s);
- return false;
-}
-
-
-
-#ifdef KEEPTEST
-
-/* Print the keyword values found. */
-
-char const cmdid[] ="keeptest";
-
- int
-main(argc, argv)
-int argc; char *argv[];
-{
- while (*(++argv)) {
- workname = *argv;
- getoldkeys((RILE*)0);
- VOID printf("%s: revision: %s, date: %s, author: %s, name: %s, state: %s\n",
- *argv, prevrev.string, prevdate.string, prevauthor.string, prevname.string, prevstate.string);
- }
- exitmain(EXIT_SUCCESS);
-}
-#endif
diff --git a/gnu/usr.bin/rcs/lib/rcskeys.c b/gnu/usr.bin/rcs/lib/rcskeys.c
deleted file mode 100644
index 6d0afb3..0000000
--- a/gnu/usr.bin/rcs/lib/rcskeys.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/* RCS keyword table and match operation */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.4 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.3 1993/11/03 17:42:27 eggert
- * Add Name keyword.
- *
- * Revision 5.2 1991/08/19 03:13:55 eggert
- * Say `T const' instead of `const T'; it's less confusing for pointer types.
- * (This change was made in other source files too.)
- *
- * Revision 5.1 1991/04/21 11:58:25 eggert
- * Don't put , just before } in initializer.
- *
- * Revision 5.0 1990/08/22 08:12:54 eggert
- * Add -k. Ansify and Posixate.
- *
- * Revision 4.3 89/05/01 15:13:02 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.2 87/10/18 10:36:33 narten
- * Updating version numbers. Changes relative to 1.1 actuallyt
- * relative to 4.1
- *
- * Revision 1.2 87/09/24 14:00:10 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 4.1 83/05/04 10:06:53 wft
- * Initial revision.
- *
- */
-
-
-#include "rcsbase.h"
-
-libId(keysId, "$Id: rcskeys.c,v 1.10 1997/02/22 15:47:38 peter Exp $")
-
-
-char const *Keyword[] = {
- /* This must be in the same order as rcsbase.h's enum markers type. */
- 0,
- AUTHOR, DATE, HEADER, IDH,
- LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE, CVSHEADER,
- NULL
-};
-
-/* Expand all keywords by default */
-static int ExpandKeyword[] = {
- false,
- true, true, true, true,
- true, true, true, true, true, true, true, true,
- true
-};
-enum markers LocalIdMode = Id;
-
- enum markers
-trymatch(string)
- char const *string;
-/* function: Checks whether string starts with a keyword followed
- * by a KDELIM or a VDELIM.
- * If successful, returns the appropriate marker, otherwise Nomatch.
- */
-{
- register int j;
- register char const *p, *s;
- for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) {
- if (!ExpandKeyword[j])
- continue;
- /* try next keyword */
- p = Keyword[j];
- if (p == NULL)
- continue;
- s = string;
- while (*p++ == *s++) {
- if (!*p)
- switch (*s) {
- case KDELIM:
- case VDELIM:
- return (enum markers)j;
- default:
- return Nomatch;
- }
- }
- }
- return(Nomatch);
-}
-
- void
-setIncExc(arg)
- char const *arg;
-/* Sets up the ExpandKeyword table according to command-line flags */
-{
- char *key;
- char *copy, *next;
- int include = 0, j;
-
- copy = strdup(arg);
- next = copy;
- switch (*next++) {
- case 'e':
- include = false;
- break;
- case 'i':
- include = true;
- break;
- default:
- free(copy);
- return;
- }
- if (include)
- for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); )
- ExpandKeyword[j] = false;
- key = strtok(next, ",");
- while (key) {
- for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) {
- if (Keyword[j] == NULL)
- continue;
- if (!strcmp(key, Keyword[j]))
- ExpandKeyword[j] = include;
- }
- key = strtok(NULL, ",");
- }
- free(copy);
- return;
-}
-
- void
-setRCSLocalId(string)
- char const *string;
-/* function: sets local RCS id and RCSLOCALID envariable */
-{
- static char local_id[keylength+1];
- char *copy, *next, *key;
- int j;
-
- copy = strdup(string);
- next = copy;
- key = strtok(next, "=");
- if (strlen(key) > keylength)
- error("LocalId is too long");
- VOID strcpy(local_id, key);
- Keyword[LocalId] = local_id;
-
- /* options? */
- while (key = strtok(NULL, ",")) {
- if (!strcmp(key, Keyword[Id]))
- LocalIdMode=Id;
- else if (!strcmp(key, Keyword[Header]))
- LocalIdMode=Header;
- else if (!strcmp(key, Keyword[CVSHeader]))
- LocalIdMode=CVSHeader;
- else
- error("Unknown LocalId mode");
- }
- free(copy);
-}
diff --git a/gnu/usr.bin/rcs/lib/rcslex.c b/gnu/usr.bin/rcs/lib/rcslex.c
deleted file mode 100644
index 95c96c2..0000000
--- a/gnu/usr.bin/rcs/lib/rcslex.c
+++ /dev/null
@@ -1,1568 +0,0 @@
-/* lexical analysis of RCS files */
-
-/******************************************************************************
- * Lexical Analysis.
- * hashtable, Lexinit, nextlex, getlex, getkey,
- * getid, getnum, readstring, printstring, savestring,
- * checkid, fatserror, error, faterror, warn, diagnose
- * Testprogram: define LEXDB
- ******************************************************************************
- */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-/*
- * Revision 5.19 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.18 1995/06/01 16:23:43 eggert
- * (map_fd_deallocate,mmap_deallocate,read_deallocate,nothing_to_deallocate):
- * New functions.
- * (Iclose): If large_memory and maps_memory, use them to deallocate mapping.
- * (fd2RILE): Use map_fd if available.
- * If one mapping method fails, try the next instead of giving up;
- * if they all fail, fall back on ordinary read.
- * Work around bug: root mmap over NFS succeeds, but accessing dumps core.
- * Use MAP_FAILED macro for mmap failure, and `char *' instead of caddr_t.
- * (advise_access): Use madvise only if this instance used mmap.
- * (Iopen): Use fdSafer to get safer file descriptor.
- * (aflush): Moved here from rcsedit.c.
- *
- * Revision 5.17 1994/03/20 04:52:58 eggert
- * Don't worry if madvise fails. Add Orewind. Remove lint.
- *
- * Revision 5.16 1993/11/09 17:55:29 eggert
- * Fix `label: }' typo.
- *
- * Revision 5.15 1993/11/03 17:42:27 eggert
- * Improve quality of diagnostics by putting file names in them more often.
- * Don't discard ignored phrases.
- *
- * Revision 5.14 1992/07/28 16:12:44 eggert
- * Identifiers may now start with a digit and (unless they are symbolic names)
- * may contain `.'. Avoid `unsigned'. Statement macro names now end in _.
- *
- * Revision 5.13 1992/02/17 23:02:27 eggert
- * Work around NFS mmap SIGBUS problem.
- *
- * Revision 5.12 1992/01/06 02:42:34 eggert
- * Use OPEN_O_BINARY if mode contains 'b'.
- *
- * Revision 5.11 1991/11/03 03:30:44 eggert
- * Fix porting bug to ancient hosts lacking vfprintf.
- *
- * Revision 5.10 1991/10/07 17:32:46 eggert
- * Support piece tables even if !has_mmap.
- *
- * Revision 5.9 1991/09/24 00:28:42 eggert
- * Don't export errsay().
- *
- * Revision 5.8 1991/08/19 03:13:55 eggert
- * Add eoflex(), mmap support. Tune.
- *
- * Revision 5.7 1991/04/21 11:58:26 eggert
- * Add MS-DOS support.
- *
- * Revision 5.6 1991/02/25 07:12:42 eggert
- * Work around fputs bug. strsave -> str_save (DG/UX name clash)
- *
- * Revision 5.5 1990/12/04 05:18:47 eggert
- * Use -I for prompts and -q for diagnostics.
- *
- * Revision 5.4 1990/11/19 20:05:28 hammer
- * no longer gives warning about unknown keywords if -q is specified
- *
- * Revision 5.3 1990/11/01 05:03:48 eggert
- * When ignoring unknown phrases, copy them to the output RCS file.
- *
- * Revision 5.2 1990/09/04 08:02:27 eggert
- * Count RCS lines better.
- *
- * Revision 5.1 1990/08/29 07:14:03 eggert
- * Work around buggy compilers with defective argument promotion.
- *
- * Revision 5.0 1990/08/22 08:12:55 eggert
- * Remove compile-time limits; use malloc instead.
- * Report errno-related errors with perror().
- * Ansify and Posixate. Add support for ISO 8859.
- * Use better hash function.
- *
- * Revision 4.6 89/05/01 15:13:07 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.5 88/08/28 15:01:12 eggert
- * Don't loop when writing error messages to a full filesystem.
- * Flush stderr/stdout when mixing output.
- * Yield exit status compatible with diff(1).
- * Shrink stdio code size; allow cc -R; remove lint.
- *
- * Revision 4.4 87/12/18 11:44:47 narten
- * fixed to use "varargs" in "fprintf"; this is required if it is to
- * work on a SPARC machine such as a Sun-4
- *
- * Revision 4.3 87/10/18 10:37:18 narten
- * Updating version numbers. Changes relative to 1.1 actually relative
- * to version 4.1
- *
- * Revision 1.3 87/09/24 14:00:17 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:33 jenkins
- * Port to suns
- *
- * Revision 4.1 83/03/25 18:12:51 wft
- * Only changed $Header to $Id.
- *
- * Revision 3.3 82/12/10 16:22:37 wft
- * Improved error messages, changed exit status on error to 1.
- *
- * Revision 3.2 82/11/28 21:27:10 wft
- * Renamed ctab to map and included EOFILE; ctab is now a macro in rcsbase.h.
- * Added fflsbuf(), fputs(), and fprintf(), which abort the RCS operations
- * properly in case there is an IO-error (e.g., file system full).
- *
- * Revision 3.1 82/10/11 19:43:56 wft
- * removed unused label out:;
- * made sure all calls to getc() return into an integer, not a char.
- */
-
-
-/*
-#define LEXDB
-*/
-/* version LEXDB is for testing the lexical analyzer. The testprogram
- * reads a stream of lexemes, enters the revision numbers into the
- * hashtable, and prints the recognized tokens. Keywords are recognized
- * as identifiers.
- */
-
-
-
-#include "rcsbase.h"
-
-libId(lexId, "$Id$")
-
-static char *checkidentifier P((char*,int,int));
-static void errsay P((char const*));
-static void fatsay P((char const*));
-static void lookup P((char const*));
-static void startsay P((const char*,const char*));
-static void warnsay P((char const*));
-
-static struct hshentry *nexthsh; /*pointer to next hash entry, set by lookup*/
-
-enum tokens nexttok; /*next token, set by nextlex */
-
-int hshenter; /*if true, next suitable lexeme will be entered */
- /*into the symbol table. Handle with care. */
-int nextc; /*next input character, initialized by Lexinit */
-
-long rcsline; /*current line-number of input */
-int nerror; /*counter for errors */
-int quietflag; /*indicates quiet mode */
-RILE * finptr; /*input file descriptor */
-
-FILE * frewrite; /*file descriptor for echoing input */
-
-FILE * foutptr; /* copy of frewrite, but 0 to suppress echo */
-
-static struct buf tokbuf; /* token buffer */
-
-char const * NextString; /* next token */
-
-/*
- * Our hash algorithm is h[0] = 0, h[i+1] = 4*h[i] + c,
- * so hshsize should be odd.
- * See B J McKenzie, R Harries & T Bell, Selecting a hashing algorithm,
- * Software--practice & experience 20, 2 (Feb 1990), 209-224.
- */
-#ifndef hshsize
-# define hshsize 511
-#endif
-
-static struct hshentry *hshtab[hshsize]; /*hashtable */
-
-static int ignored_phrases; /* have we ignored phrases in this RCS file? */
-
- void
-warnignore()
-{
- if (!ignored_phrases) {
- ignored_phrases = true;
- rcswarn("Unknown phrases like `%s ...;' are present.", NextString);
- }
-}
-
-
-
- static void
-lookup(str)
- char const *str;
-/* Function: Looks up the character string pointed to by str in the
- * hashtable. If the string is not present, a new entry for it is created.
- * In any case, the address of the corresponding hashtable entry is placed
- * into nexthsh.
- */
-{
- register unsigned ihash; /* index into hashtable */
- register char const *sp;
- register struct hshentry *n, **p;
-
- /* calculate hash code */
- sp = str;
- ihash = 0;
- while (*sp)
- ihash = (ihash<<2) + *sp++;
- ihash %= hshsize;
-
- for (p = &hshtab[ihash]; ; p = &n->nexthsh)
- if (!(n = *p)) {
- /* empty slot found */
- *p = n = ftalloc(struct hshentry);
- n->num = fstr_save(str);
- n->nexthsh = 0;
-# ifdef LEXDB
- VOID printf("\nEntered: %s at %u ", str, ihash);
-# endif
- break;
- } else if (strcmp(str, n->num) == 0)
- /* match found */
- break;
- nexthsh = n;
- NextString = n->num;
-}
-
-
-
-
-
-
- void
-Lexinit()
-/* Function: Initialization of lexical analyzer:
- * initializes the hashtable,
- * initializes nextc, nexttok if finptr != 0
- */
-{ register int c;
-
- for (c = hshsize; 0 <= --c; ) {
- hshtab[c] = 0;
- }
-
- nerror = 0;
- if (finptr) {
- foutptr = 0;
- hshenter = true;
- ignored_phrases = false;
- rcsline = 1;
- bufrealloc(&tokbuf, 2);
- Iget_(finptr, nextc)
- nextlex(); /*initial token*/
- }
-}
-
-
-
-
-
-
-
- void
-nextlex()
-
-/* Function: Reads the next token and sets nexttok to the next token code.
- * Only if hshenter is set, a revision number is entered into the
- * hashtable and a pointer to it is placed into nexthsh.
- * This is useful for avoiding that dates are placed into the hashtable.
- * For ID's and NUM's, NextString is set to the character string.
- * Assumption: nextc contains the next character.
- */
-{ register c;
- declarecache;
- register FILE *frew;
- register char * sp;
- char const *limit;
- register enum tokens d;
- register RILE *fin;
-
- fin=finptr; frew=foutptr;
- setupcache(fin); cache(fin);
- c = nextc;
-
- for (;;) { switch ((d = ctab[c])) {
-
- default:
- fatserror("unknown character `%c'", c);
- /*NOTREACHED*/
-
- case NEWLN:
- ++rcsline;
-# ifdef LEXDB
- afputc('\n',stdout);
-# endif
- /* Note: falls into next case */
-
- case SPACE:
- GETC_(frew, c)
- continue;
-
- case IDCHAR:
- case LETTER:
- case Letter:
- d = ID;
- /* fall into */
- case DIGIT:
- case PERIOD:
- sp = tokbuf.string;
- limit = sp + tokbuf.size;
- *sp++ = c;
- for (;;) {
- GETC_(frew, c)
- switch (ctab[c]) {
- case IDCHAR:
- case LETTER:
- case Letter:
- d = ID;
- /* fall into */
- case DIGIT:
- case PERIOD:
- *sp++ = c;
- if (limit <= sp)
- sp = bufenlarge(&tokbuf, &limit);
- continue;
-
- default:
- break;
- }
- break;
- }
- *sp = 0;
- if (d == DIGIT || d == PERIOD) {
- d = NUM;
- if (hshenter) {
- lookup(tokbuf.string);
- break;
- }
- }
- NextString = fstr_save(tokbuf.string);
- break;
-
- case SBEGIN: /* long string */
- d = STRING;
- /* note: only the initial SBEGIN has been read*/
- /* read the string, and reset nextc afterwards*/
- break;
-
- case COLON:
- case SEMI:
- GETC_(frew, c)
- break;
- } break; }
- nextc = c;
- nexttok = d;
- uncache(fin);
-}
-
- int
-eoflex()
-/*
- * Yield true if we look ahead to the end of the input, false otherwise.
- * nextc becomes undefined at end of file.
- */
-{
- register int c;
- declarecache;
- register FILE *fout;
- register RILE *fin;
-
- c = nextc;
- fin = finptr;
- fout = foutptr;
- setupcache(fin); cache(fin);
-
- for (;;) {
- switch (ctab[c]) {
- default:
- nextc = c;
- uncache(fin);
- return false;
-
- case NEWLN:
- ++rcsline;
- /* fall into */
- case SPACE:
- cachegeteof_(c, {uncache(fin);return true;})
- break;
- }
- if (fout)
- aputc_(c, fout)
- }
-}
-
-
-int getlex(token)
-enum tokens token;
-/* Function: Checks if nexttok is the same as token. If so,
- * advances the input by calling nextlex and returns true.
- * otherwise returns false.
- * Doesn't work for strings and keywords; loses the character string for ids.
- */
-{
- if (nexttok==token) {
- nextlex();
- return(true);
- } else return(false);
-}
-
- int
-getkeyopt(key)
- char const *key;
-/* Function: If the current token is a keyword identical to key,
- * advances the input by calling nextlex and returns true;
- * otherwise returns false.
- */
-{
- if (nexttok==ID && strcmp(key,NextString) == 0) {
- /* match found */
- ffree1(NextString);
- nextlex();
- return(true);
- }
- return(false);
-}
-
- void
-getkey(key)
- char const *key;
-/* Check that the current input token is a keyword identical to key,
- * and advance the input by calling nextlex.
- */
-{
- if (!getkeyopt(key))
- fatserror("missing '%s' keyword", key);
-}
-
- void
-getkeystring(key)
- char const *key;
-/* Check that the current input token is a keyword identical to key,
- * and advance the input by calling nextlex; then look ahead for a string.
- */
-{
- getkey(key);
- if (nexttok != STRING)
- fatserror("missing string after '%s' keyword", key);
-}
-
-
- char const *
-getid()
-/* Function: Checks if nexttok is an identifier. If so,
- * advances the input by calling nextlex and returns a pointer
- * to the identifier; otherwise returns 0.
- * Treats keywords as identifiers.
- */
-{
- register char const *name;
- if (nexttok==ID) {
- name = NextString;
- nextlex();
- return name;
- } else
- return 0;
-}
-
-
-struct hshentry * getnum()
-/* Function: Checks if nexttok is a number. If so,
- * advances the input by calling nextlex and returns a pointer
- * to the hashtable entry. Otherwise returns 0.
- * Doesn't work if hshenter is false.
- */
-{
- register struct hshentry * num;
- if (nexttok==NUM) {
- num=nexthsh;
- nextlex();
- return num;
- } else
- return 0;
-}
-
- struct cbuf
-getphrases(key)
- char const *key;
-/*
-* Get a series of phrases that do not start with KEY. Yield resulting buffer.
-* Stop when the next phrase starts with a token that is not an identifier,
-* or is KEY. Copy input to foutptr if it is set. Unlike ignorephrases(),
-* this routine assumes nextlex() has already been invoked before we start.
-*/
-{
- declarecache;
- register int c;
- register char const *kn;
- struct cbuf r;
- register RILE *fin;
- register FILE *frew;
-# if large_memory
-# define savech_(c) ;
-# else
- register char *p;
- char const *limit;
- struct buf b;
-# define savech_(c) {if (limit<=p)p=bufenlarge(&b,&limit); *p++ =(c);}
-# endif
-
- if (nexttok!=ID || strcmp(NextString,key) == 0)
- clear_buf(&r);
- else {
- warnignore();
- fin = finptr;
- frew = foutptr;
- setupcache(fin); cache(fin);
-# if large_memory
- r.string = (char const*)cacheptr() - strlen(NextString) - 1;
-# else
- bufautobegin(&b);
- bufscpy(&b, NextString);
- p = b.string + strlen(b.string);
- limit = b.string + b.size;
-# endif
- ffree1(NextString);
- c = nextc;
- for (;;) {
- for (;;) {
- savech_(c)
- switch (ctab[c]) {
- default:
- fatserror("unknown character `%c'", c);
- /*NOTREACHED*/
- case NEWLN:
- ++rcsline;
- /* fall into */
- case COLON: case DIGIT: case LETTER: case Letter:
- case PERIOD: case SPACE:
- GETC_(frew, c)
- continue;
- case SBEGIN: /* long string */
- for (;;) {
- for (;;) {
- GETC_(frew, c)
- savech_(c)
- switch (c) {
- case '\n':
- ++rcsline;
- /* fall into */
- default:
- continue;
-
- case SDELIM:
- break;
- }
- break;
- }
- GETC_(frew, c)
- if (c != SDELIM)
- break;
- savech_(c)
- }
- continue;
- case SEMI:
- cacheget_(c)
- if (ctab[c] == NEWLN) {
- if (frew)
- aputc_(c, frew)
- ++rcsline;
- savech_(c)
- cacheget_(c)
- }
-# if large_memory
- r.size = (char const*)cacheptr() - 1 - r.string;
-# endif
- for (;;) {
- switch (ctab[c]) {
- case NEWLN:
- ++rcsline;
- /* fall into */
- case SPACE:
- cacheget_(c)
- continue;
-
- default: break;
- }
- break;
- }
- if (frew)
- aputc_(c, frew)
- break;
- }
- break;
- }
- if (ctab[c] == Letter) {
- for (kn = key; c && *kn==c; kn++)
- GETC_(frew, c)
- if (!*kn)
- switch (ctab[c]) {
- case DIGIT: case LETTER: case Letter:
- case IDCHAR: case PERIOD:
- break;
- default:
- nextc = c;
- NextString = fstr_save(key);
- nexttok = ID;
- uncache(fin);
- goto returnit;
- }
-# if !large_memory
- {
- register char const *ki;
- for (ki=key; ki<kn; )
- savech_(*ki++)
- }
-# endif
- } else {
- nextc = c;
- uncache(fin);
- nextlex();
- break;
- }
- }
- returnit:;
-# if !large_memory
- return bufremember(&b, (size_t)(p - b.string));
-# endif
- }
- return r;
-}
-
-
- void
-readstring()
-/* skip over characters until terminating single SDELIM */
-/* If foutptr is set, copy every character read to foutptr. */
-/* Does not advance nextlex at the end. */
-{ register c;
- declarecache;
- register FILE *frew;
- register RILE *fin;
- fin=finptr; frew=foutptr;
- setupcache(fin); cache(fin);
- for (;;) {
- GETC_(frew, c)
- switch (c) {
- case '\n':
- ++rcsline;
- break;
-
- case SDELIM:
- GETC_(frew, c)
- if (c != SDELIM) {
- /* end of string */
- nextc = c;
- uncache(fin);
- return;
- }
- break;
- }
- }
-}
-
-
- void
-printstring()
-/* Function: copy a string to stdout, until terminated with a single SDELIM.
- * Does not advance nextlex at the end.
- */
-{
- register c;
- declarecache;
- register FILE *fout;
- register RILE *fin;
- fin=finptr;
- fout = stdout;
- setupcache(fin); cache(fin);
- for (;;) {
- cacheget_(c)
- switch (c) {
- case '\n':
- ++rcsline;
- break;
- case SDELIM:
- cacheget_(c)
- if (c != SDELIM) {
- nextc=c;
- uncache(fin);
- return;
- }
- break;
- }
- aputc_(c,fout)
- }
-}
-
-
-
- struct cbuf
-savestring(target)
- struct buf *target;
-/* Copies a string terminated with SDELIM from file finptr to buffer target.
- * Double SDELIM is replaced with SDELIM.
- * If foutptr is set, the string is also copied unchanged to foutptr.
- * Does not advance nextlex at the end.
- * Yield a copy of *TARGET, except with exact length.
- */
-{
- register c;
- declarecache;
- register FILE *frew;
- register char *tp;
- register RILE *fin;
- char const *limit;
- struct cbuf r;
-
- fin=finptr; frew=foutptr;
- setupcache(fin); cache(fin);
- tp = target->string; limit = tp + target->size;
- for (;;) {
- GETC_(frew, c)
- switch (c) {
- case '\n':
- ++rcsline;
- break;
- case SDELIM:
- GETC_(frew, c)
- if (c != SDELIM) {
- /* end of string */
- nextc=c;
- r.string = target->string;
- r.size = tp - r.string;
- uncache(fin);
- return r;
- }
- break;
- }
- if (tp == limit)
- tp = bufenlarge(target, &limit);
- *tp++ = c;
- }
-}
-
-
- static char *
-checkidentifier(id, delimiter, dotok)
- register char *id;
- int delimiter;
- register int dotok;
-/* Function: check whether the string starting at id is an */
-/* identifier and return a pointer to the delimiter*/
-/* after the identifier. White space, delim and 0 */
-/* are legal delimiters. Aborts the program if not*/
-/* a legal identifier. Useful for checking commands*/
-/* If !delim, the only delimiter is 0. */
-/* Allow '.' in identifier only if DOTOK is set. */
-{
- register char *temp;
- register char c;
- register char delim = delimiter;
- int isid = false;
-
- temp = id;
- for (;; id++) {
- switch (ctab[(unsigned char)(c = *id)]) {
- case IDCHAR:
- case LETTER:
- case Letter:
- isid = true;
- continue;
-
- case DIGIT:
- continue;
-
- case PERIOD:
- if (dotok)
- continue;
- break;
-
- default:
- break;
- }
- break;
- }
- if ( ! isid
- || (c && (!delim || (c!=delim && c!=' ' && c!='\t' && c!='\n')))
- ) {
- /* append \0 to end of id before error message */
- while ((c = *id) && c!=' ' && c!='\t' && c!='\n' && c!=delim)
- id++;
- *id = '\0';
- faterror("invalid %s `%s'",
- dotok ? "identifier" : "symbol", temp
- );
- }
- return id;
-}
-
- char *
-checkid(id, delimiter)
- char *id;
- int delimiter;
-{
- return checkidentifier(id, delimiter, true);
-}
-
- char *
-checksym(sym, delimiter)
- char *sym;
- int delimiter;
-{
- return checkidentifier(sym, delimiter, false);
-}
-
- void
-checksid(id)
- char *id;
-/* Check whether the string ID is an identifier. */
-{
- VOID checkid(id, 0);
-}
-
- void
-checkssym(sym)
- char *sym;
-{
- VOID checksym(sym, 0);
-}
-
-
-#if !large_memory
-# define Iclose(f) fclose(f)
-#else
-# if !maps_memory
- static int Iclose P((RILE *));
- static int
- Iclose(f)
- register RILE *f;
- {
- tfree(f->base);
- f->base = 0;
- return fclose(f->stream);
- }
-# else
- static int Iclose P((RILE *));
- static int
- Iclose(f)
- register RILE *f;
- {
- (* f->deallocate) (f);
- f->base = 0;
- return close(f->fd);
- }
-
-# if has_map_fd
- static void map_fd_deallocate P((RILE *));
- static void
- map_fd_deallocate(f)
- register RILE *f;
- {
- if (vm_deallocate(
- task_self(),
- (vm_address_t) f->base,
- (vm_size_t) (f->lim - f->base)
- ) != KERN_SUCCESS)
- efaterror("vm_deallocate");
- }
-# endif
-# if has_mmap
- static void mmap_deallocate P((RILE *));
- static void
- mmap_deallocate(f)
- register RILE *f;
- {
- if (munmap((char *) f->base, (size_t) (f->lim - f->base)) != 0)
- efaterror("munmap");
- }
-# endif
- static void read_deallocate P((RILE *));
- static void
- read_deallocate(f)
- RILE *f;
- {
- tfree(f->base);
- }
-
- static void nothing_to_deallocate P((RILE *));
- static void
- nothing_to_deallocate(f)
- RILE *f;
- {
- }
-# endif
-#endif
-
-
-#if large_memory && maps_memory
- static RILE *fd2_RILE P((int,char const*,struct stat*));
- static RILE *
-fd2_RILE(fd, name, status)
-#else
- static RILE *fd2RILE P((int,char const*,char const*,struct stat*));
- static RILE *
-fd2RILE(fd, name, type, status)
- char const *type;
-#endif
- int fd;
- char const *name;
- register struct stat *status;
-{
- struct stat st;
-
- if (!status)
- status = &st;
- if (fstat(fd, status) != 0)
- efaterror(name);
- if (!S_ISREG(status->st_mode)) {
- error("`%s' is not a regular file", name);
- VOID close(fd);
- errno = EINVAL;
- return 0;
- } else {
-
-# if !(large_memory && maps_memory)
- FILE *stream;
- if (!(stream = fdopen(fd, type)))
- efaterror(name);
-# endif
-
-# if !large_memory
- return stream;
-# else
-# define RILES 3
- {
- static RILE rilebuf[RILES];
-
- register RILE *f;
- size_t s = status->st_size;
-
- if (s != status->st_size)
- faterror("%s: too large", name);
- for (f = rilebuf; f->base; f++)
- if (f == rilebuf+RILES)
- faterror("too many RILEs");
-# if maps_memory
- f->deallocate = nothing_to_deallocate;
-# endif
- if (!s) {
- static unsigned char nothing;
- f->base = &nothing; /* Any nonzero address will do. */
- } else {
- f->base = 0;
-# if has_map_fd
- map_fd(
- fd, (vm_offset_t)0, (vm_address_t*) &f->base,
- TRUE, (vm_size_t)s
- );
- f->deallocate = map_fd_deallocate;
-# endif
-# if has_mmap
- if (!f->base) {
- catchmmapints();
- f->base = (unsigned char *) mmap(
- (char *)0, s, PROT_READ, MAP_SHARED,
- fd, (off_t)0
- );
-# ifndef MAP_FAILED
-# define MAP_FAILED (-1)
-# endif
- if (f->base == (unsigned char *) MAP_FAILED)
- f->base = 0;
- else {
-# if has_NFS && mmap_signal
- /*
- * On many hosts, the superuser
- * can mmap an NFS file it can't read.
- * So access the first page now, and print
- * a nice message if a bus error occurs.
- */
- readAccessFilenameBuffer(name, f->base);
-# endif
- }
- f->deallocate = mmap_deallocate;
- }
-# endif
- if (!f->base) {
- f->base = tnalloc(unsigned char, s);
-# if maps_memory
- {
- /*
- * We can't map the file into memory for some reason.
- * Read it into main memory all at once; this is
- * the simplest substitute for memory mapping.
- */
- char *bufptr = (char *) f->base;
- size_t bufsiz = s;
- do {
- ssize_t r = read(fd, bufptr, bufsiz);
- switch (r) {
- case -1:
- efaterror(name);
-
- case 0:
- /* The file must have shrunk! */
- status->st_size = s -= bufsiz;
- bufsiz = 0;
- break;
-
- default:
- bufptr += r;
- bufsiz -= r;
- break;
- }
- } while (bufsiz);
- if (lseek(fd, (off_t)0, SEEK_SET) == -1)
- efaterror(name);
- f->deallocate = read_deallocate;
- }
-# endif
- }
- }
- f->ptr = f->base;
- f->lim = f->base + s;
- f->fd = fd;
-# if !maps_memory
- f->readlim = f->base;
- f->stream = stream;
-# endif
- if_advise_access(s, f, MADV_SEQUENTIAL);
- return f;
- }
-# endif
- }
-}
-
-#if !maps_memory && large_memory
- int
-Igetmore(f)
- register RILE *f;
-{
- register fread_type r;
- register size_t s = f->lim - f->readlim;
-
- if (BUFSIZ < s)
- s = BUFSIZ;
- if (!(r = Fread(f->readlim, sizeof(*f->readlim), s, f->stream))) {
- testIerror(f->stream);
- f->lim = f->readlim; /* The file might have shrunk! */
- return 0;
- }
- f->readlim += r;
- return 1;
-}
-#endif
-
-#if has_madvise && has_mmap && large_memory
- void
-advise_access(f, advice)
- register RILE *f;
- int advice;
-{
- if (f->deallocate == mmap_deallocate)
- VOID madvise((char *)f->base, (size_t)(f->lim - f->base), advice);
- /* Don't worry if madvise fails; it's only advisory. */
-}
-#endif
-
- RILE *
-#if large_memory && maps_memory
-I_open(name, status)
-#else
-Iopen(name, type, status)
- char const *type;
-#endif
- char const *name;
- struct stat *status;
-/* Open NAME for reading, yield its descriptor, and set *STATUS. */
-{
- int fd = fdSafer(open(name, O_RDONLY
-# if OPEN_O_BINARY
- | (strchr(type,'b') ? OPEN_O_BINARY : 0)
-# endif
- ));
-
- if (fd < 0)
- return 0;
-# if large_memory && maps_memory
- return fd2_RILE(fd, name, status);
-# else
- return fd2RILE(fd, name, type, status);
-# endif
-}
-
-
-static int Oerrloop;
-
- void
-Oerror()
-{
- if (Oerrloop)
- exiterr();
- Oerrloop = true;
- efaterror("output error");
-}
-
-void Ieof() { fatserror("unexpected end of file"); }
-void Ierror() { efaterror("input error"); }
-void testIerror(f) FILE *f; { if (ferror(f)) Ierror(); }
-void testOerror(o) FILE *o; { if (ferror(o)) Oerror(); }
-
-void Ifclose(f) RILE *f; { if (f && Iclose(f)!=0) Ierror(); }
-void Ofclose(f) FILE *f; { if (f && fclose(f)!=0) Oerror(); }
-void Izclose(p) RILE **p; { Ifclose(*p); *p = 0; }
-void Ozclose(p) FILE **p; { Ofclose(*p); *p = 0; }
-
-#if !large_memory
- void
-testIeof(f)
- FILE *f;
-{
- testIerror(f);
- if (feof(f))
- Ieof();
-}
-void Irewind(f) FILE *f; { if (fseek(f,0L,SEEK_SET) != 0) Ierror(); }
-#endif
-
-void Orewind(f) FILE *f; { if (fseek(f,0L,SEEK_SET) != 0) Oerror(); }
-
-void aflush(f) FILE *f; { if (fflush(f) != 0) Oerror(); }
-void eflush() { if (fflush(stderr)!=0 && !Oerrloop) Oerror(); }
-void oflush()
-{
- if (fflush(workstdout ? workstdout : stdout) != 0 && !Oerrloop)
- Oerror();
-}
-
- void
-fatcleanup(already_newline)
- int already_newline;
-{
- VOID fprintf(stderr, already_newline+"\n%s aborted\n", cmdid);
- exiterr();
-}
-
- static void
-startsay(s, t)
- const char *s, *t;
-{
- oflush();
- if (s)
- aprintf(stderr, "%s: %s: %s", cmdid, s, t);
- else
- aprintf(stderr, "%s: %s", cmdid, t);
-}
-
- static void
-fatsay(s)
- char const *s;
-{
- startsay(s, "");
-}
-
- static void
-errsay(s)
- char const *s;
-{
- fatsay(s);
- nerror++;
-}
-
- static void
-warnsay(s)
- char const *s;
-{
- startsay(s, "warning: ");
-}
-
-void eerror(s) char const *s; { enerror(errno,s); }
-
- void
-enerror(e,s)
- int e;
- char const *s;
-{
- errsay((char const*)0);
- errno = e;
- perror(s);
- eflush();
-}
-
-void efaterror(s) char const *s; { enfaterror(errno,s); }
-
- void
-enfaterror(e,s)
- int e;
- char const *s;
-{
- fatsay((char const*)0);
- errno = e;
- perror(s);
- fatcleanup(true);
-}
-
-#if has_prototypes
- void
-error(char const *format,...)
-#else
- /*VARARGS1*/ void error(format, va_alist) char const *format; va_dcl
-#endif
-/* non-fatal error */
-{
- va_list args;
- errsay((char const*)0);
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- afputc('\n',stderr);
- eflush();
-}
-
-#if has_prototypes
- void
-rcserror(char const *format,...)
-#else
- /*VARARGS1*/ void rcserror(format, va_alist) char const *format; va_dcl
-#endif
-/* non-fatal RCS file error */
-{
- va_list args;
- errsay(RCSname);
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- afputc('\n',stderr);
- eflush();
-}
-
-#if has_prototypes
- void
-workerror(char const *format,...)
-#else
- /*VARARGS1*/ void workerror(format, va_alist) char const *format; va_dcl
-#endif
-/* non-fatal working file error */
-{
- va_list args;
- errsay(workname);
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- afputc('\n',stderr);
- eflush();
-}
-
-#if has_prototypes
- void
-fatserror(char const *format,...)
-#else
- /*VARARGS1*/ void
- fatserror(format, va_alist) char const *format; va_dcl
-#endif
-/* fatal RCS file syntax error */
-{
- va_list args;
- oflush();
- VOID fprintf(stderr, "%s: %s:%ld: ", cmdid, RCSname, rcsline);
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- fatcleanup(false);
-}
-
-#if has_prototypes
- void
-faterror(char const *format,...)
-#else
- /*VARARGS1*/ void faterror(format, va_alist)
- char const *format; va_dcl
-#endif
-/* fatal error, terminates program after cleanup */
-{
- va_list args;
- fatsay((char const*)0);
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- fatcleanup(false);
-}
-
-#if has_prototypes
- void
-rcsfaterror(char const *format,...)
-#else
- /*VARARGS1*/ void rcsfaterror(format, va_alist)
- char const *format; va_dcl
-#endif
-/* fatal RCS file error, terminates program after cleanup */
-{
- va_list args;
- fatsay(RCSname);
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- fatcleanup(false);
-}
-
-#if has_prototypes
- void
-warn(char const *format,...)
-#else
- /*VARARGS1*/ void warn(format, va_alist) char const *format; va_dcl
-#endif
-/* warning */
-{
- va_list args;
- if (!quietflag) {
- warnsay((char *)0);
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- afputc('\n', stderr);
- eflush();
- }
-}
-
-#if has_prototypes
- void
-rcswarn(char const *format,...)
-#else
- /*VARARGS1*/ void rcswarn(format, va_alist) char const *format; va_dcl
-#endif
-/* RCS file warning */
-{
- va_list args;
- if (!quietflag) {
- warnsay(RCSname);
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- afputc('\n', stderr);
- eflush();
- }
-}
-
-#if has_prototypes
- void
-workwarn(char const *format,...)
-#else
- /*VARARGS1*/ void workwarn(format, va_alist) char const *format; va_dcl
-#endif
-/* working file warning */
-{
- va_list args;
- if (!quietflag) {
- warnsay(workname);
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- afputc('\n', stderr);
- eflush();
- }
-}
-
- void
-redefined(c)
- int c;
-{
- warn("redefinition of -%c option", c);
-}
-
-#if has_prototypes
- void
-diagnose(char const *format,...)
-#else
- /*VARARGS1*/ void diagnose(format, va_alist) char const *format; va_dcl
-#endif
-/* prints a diagnostic message */
-/* Unlike the other routines, it does not append a newline. */
-/* This lets some callers suppress the newline, and is faster */
-/* in implementations that flush stderr just at the end of each printf. */
-{
- va_list args;
- if (!quietflag) {
- oflush();
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- eflush();
- }
-}
-
-
-
- void
-afputc(c, f)
-/* afputc(c,f); acts like aputc_(c,f) but is smaller and slower. */
- int c;
- register FILE *f;
-{
- aputc_(c,f)
-}
-
-
- void
-aputs(s, iop)
- char const *s;
- FILE *iop;
-/* Function: Put string s on file iop, abort on error.
- */
-{
-#if has_fputs
- if (fputs(s, iop) < 0)
- Oerror();
-#else
- awrite(s, strlen(s), iop);
-#endif
-}
-
-
-
- void
-#if has_prototypes
-fvfprintf(FILE *stream, char const *format, va_list args)
-#else
- fvfprintf(stream,format,args) FILE *stream; char *format; va_list args;
-#endif
-/* like vfprintf, except abort program on error */
-{
-#if has_vfprintf
- if (vfprintf(stream, format, args) < 0)
- Oerror();
-#else
-# if has__doprintf
- _doprintf(stream, format, args);
-# else
-# if has__doprnt
- _doprnt(format, args, stream);
-# else
- int *a = (int *)args;
- VOID fprintf(stream, format,
- a[0], a[1], a[2], a[3], a[4],
- a[5], a[6], a[7], a[8], a[9]
- );
-# endif
-# endif
- if (ferror(stream))
- Oerror();
-#endif
-}
-
-#if has_prototypes
- void
-aprintf(FILE *iop, char const *fmt, ...)
-#else
- /*VARARGS2*/ void
-aprintf(iop, fmt, va_alist)
-FILE *iop;
-char const *fmt;
-va_dcl
-#endif
-/* Function: formatted output. Same as fprintf in stdio,
- * but aborts program on error
- */
-{
- va_list ap;
- vararg_start(ap, fmt);
- fvfprintf(iop, fmt, ap);
- va_end(ap);
-}
-
-
-
-#ifdef LEXDB
-/* test program reading a stream of lexemes and printing the tokens.
- */
-
-
-
- int
-main(argc,argv)
-int argc; char * argv[];
-{
- cmdid="lextest";
- if (argc<2) {
- aputs("No input file\n",stderr);
- exitmain(EXIT_FAILURE);
- }
- if (!(finptr=Iopen(argv[1], FOPEN_R, (struct stat*)0))) {
- faterror("can't open input file %s",argv[1]);
- }
- Lexinit();
- while (!eoflex()) {
- switch (nexttok) {
-
- case ID:
- VOID printf("ID: %s",NextString);
- break;
-
- case NUM:
- if (hshenter)
- VOID printf("NUM: %s, index: %d",nexthsh->num, nexthsh-hshtab);
- else
- VOID printf("NUM, unentered: %s",NextString);
- hshenter = !hshenter; /*alternate between dates and numbers*/
- break;
-
- case COLON:
- VOID printf("COLON"); break;
-
- case SEMI:
- VOID printf("SEMI"); break;
-
- case STRING:
- readstring();
- VOID printf("STRING"); break;
-
- case UNKN:
- VOID printf("UNKN"); break;
-
- default:
- VOID printf("DEFAULT"); break;
- }
- VOID printf(" | ");
- nextlex();
- }
- exitmain(EXIT_SUCCESS);
-}
-
-void exiterr() { _exit(EXIT_FAILURE); }
-
-
-#endif
diff --git a/gnu/usr.bin/rcs/lib/rcsmap.c b/gnu/usr.bin/rcs/lib/rcsmap.c
deleted file mode 100644
index 0d6d64d..0000000
--- a/gnu/usr.bin/rcs/lib/rcsmap.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* RCS map of character types */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1995 by Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#include "rcsbase.h"
-
-libId(mapId, "$Id$")
-
-/* map of character types */
-/* ISO 8859/1 (Latin-1) */
-enum tokens const ctab[] = {
- UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
- SPACE, SPACE, NEWLN, SPACE, SPACE, SPACE, UNKN, UNKN,
- UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
- UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
- SPACE, IDCHAR, IDCHAR, IDCHAR, DELIM, IDCHAR, IDCHAR, IDCHAR,
- IDCHAR, IDCHAR, IDCHAR, IDCHAR, DELIM, IDCHAR, PERIOD, IDCHAR,
- DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT,
- DIGIT, DIGIT, COLON, SEMI, IDCHAR, IDCHAR, IDCHAR, IDCHAR,
- SBEGIN, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- LETTER, LETTER, LETTER, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR,
- IDCHAR, Letter, Letter, Letter, Letter, Letter, Letter, Letter,
- Letter, Letter, Letter, Letter, Letter, Letter, Letter, Letter,
- Letter, Letter, Letter, Letter, Letter, Letter, Letter, Letter,
- Letter, Letter, Letter, IDCHAR, IDCHAR, IDCHAR, IDCHAR, UNKN,
- UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
- UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
- UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
- UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
- IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR,
- IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR,
- IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR,
- IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR,
- LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, IDCHAR,
- LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, Letter,
- Letter, Letter, Letter, Letter, Letter, Letter, Letter, Letter,
- Letter, Letter, Letter, Letter, Letter, Letter, Letter, Letter,
- Letter, Letter, Letter, Letter, Letter, Letter, Letter, IDCHAR,
- Letter, Letter, Letter, Letter, Letter, Letter, Letter, Letter
-};
diff --git a/gnu/usr.bin/rcs/lib/rcsrev.c b/gnu/usr.bin/rcs/lib/rcsrev.c
deleted file mode 100644
index 8881648..0000000
--- a/gnu/usr.bin/rcs/lib/rcsrev.c
+++ /dev/null
@@ -1,911 +0,0 @@
-/* Handle RCS revision numbers. */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.10 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.9 1995/06/01 16:23:43 eggert
- * (cmpdate, normalizeyear): New functions work around MKS RCS incompatibility.
- * (cmpnum, compartial): s[d] -> *(s+d) to work around Cray compiler bug.
- * (genrevs, genbranch): cmpnum -> cmpdate
- *
- * Revision 5.8 1994/03/17 14:05:48 eggert
- * Remove lint.
- *
- * Revision 5.7 1993/11/09 17:40:15 eggert
- * Fix format string typos.
- *
- * Revision 5.6 1993/11/03 17:42:27 eggert
- * Revision number `.N' now stands for `D.N', where D is the default branch.
- * Add -z. Improve quality of diagnostics. Add `namedrev' for Name support.
- *
- * Revision 5.5 1992/07/28 16:12:44 eggert
- * Identifiers may now start with a digit. Avoid `unsigned'.
- *
- * Revision 5.4 1992/01/06 02:42:34 eggert
- * while (E) ; -> while (E) continue;
- *
- * Revision 5.3 1991/08/19 03:13:55 eggert
- * Add `-r$', `-rB.'. Remove botches like `<now>' from messages. Tune.
- *
- * Revision 5.2 1991/04/21 11:58:28 eggert
- * Add tiprev().
- *
- * Revision 5.1 1991/02/25 07:12:43 eggert
- * Avoid overflow when comparing revision numbers.
- *
- * Revision 5.0 1990/08/22 08:13:43 eggert
- * Remove compile-time limits; use malloc instead.
- * Ansify and Posixate. Tune.
- * Remove possibility of an internal error. Remove lint.
- *
- * Revision 4.5 89/05/01 15:13:22 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.4 87/12/18 11:45:22 narten
- * more lint cleanups. Also, the NOTREACHED comment is no longer necessary,
- * since there's now a return value there with a value. (Guy Harris)
- *
- * Revision 4.3 87/10/18 10:38:42 narten
- * Updating version numbers. Changes relative to version 1.1 actually
- * relative to 4.1
- *
- * Revision 1.3 87/09/24 14:00:37 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:37 jenkins
- * Port to suns
- *
- * Revision 4.1 83/03/25 21:10:45 wft
- * Only changed $Header to $Id.
- *
- * Revision 3.4 82/12/04 13:24:08 wft
- * Replaced getdelta() with gettree().
- *
- * Revision 3.3 82/11/28 21:33:15 wft
- * fixed compartial() and compnum() for nil-parameters; fixed nils
- * in error messages. Testprogram output shortenend.
- *
- * Revision 3.2 82/10/18 21:19:47 wft
- * renamed compnum->cmpnum, compnumfld->cmpnumfld,
- * numericrevno->numricrevno.
- *
- * Revision 3.1 82/10/11 19:46:09 wft
- * changed expandsym() to check for source==nil; returns zero length string
- * in that case.
- */
-
-#include "rcsbase.h"
-
-libId(revId, "$Id$")
-
-static char const *branchtip P((char const*));
-static char const *lookupsym P((char const*));
-static char const *normalizeyear P((char const*,char[5]));
-static struct hshentry *genbranch P((struct hshentry const*,char const*,int,char const*,char const*,char const*,struct hshentries**));
-static void absent P((char const*,int));
-static void cantfindbranch P((char const*,char const[datesize],char const*,char const*));
-static void store1 P((struct hshentries***,struct hshentry*));
-
-
-
- int
-countnumflds(s)
- char const *s;
-/* Given a pointer s to a dotted number (date or revision number),
- * countnumflds returns the number of digitfields in s.
- */
-{
- register char const *sp;
- register int count;
- if (!(sp=s) || !*sp)
- return 0;
- count = 1;
- do {
- if (*sp++ == '.') count++;
- } while (*sp);
- return(count);
-}
-
- void
-getbranchno(revno,branchno)
- char const *revno;
- struct buf *branchno;
-/* Given a revision number revno, getbranchno copies the number of the branch
- * on which revno is into branchno. If revno itself is a branch number,
- * it is copied unchanged.
- */
-{
- register int numflds;
- register char *tp;
-
- bufscpy(branchno, revno);
- numflds=countnumflds(revno);
- if (!(numflds & 1)) {
- tp = branchno->string;
- while (--numflds)
- while (*tp++ != '.')
- continue;
- *(tp-1)='\0';
- }
-}
-
-
-
-int cmpnum(num1, num2)
- char const *num1, *num2;
-/* compares the two dotted numbers num1 and num2 lexicographically
- * by field. Individual fields are compared numerically.
- * returns <0, 0, >0 if num1<num2, num1==num2, and num1>num2, resp.
- * omitted fields are assumed to be higher than the existing ones.
-*/
-{
- register char const *s1, *s2;
- register size_t d1, d2;
- register int r;
-
- s1 = num1 ? num1 : "";
- s2 = num2 ? num2 : "";
-
- for (;;) {
- /* Give precedence to shorter one. */
- if (!*s1)
- return (unsigned char)*s2;
- if (!*s2)
- return -1;
-
- /* Strip leading zeros, then find number of digits. */
- while (*s1=='0') ++s1;
- while (*s2=='0') ++s2;
- for (d1=0; isdigit(*(s1+d1)); d1++) continue;
- for (d2=0; isdigit(*(s2+d2)); d2++) continue;
-
- /* Do not convert to integer; it might overflow! */
- if (d1 != d2)
- return d1<d2 ? -1 : 1;
- if ((r = memcmp(s1, s2, d1)))
- return r;
- s1 += d1;
- s2 += d1;
-
- /* skip '.' */
- if (*s1) s1++;
- if (*s2) s2++;
- }
-}
-
-
-
-int cmpnumfld(num1, num2, fld)
- char const *num1, *num2;
- int fld;
-/* Compare the two dotted numbers at field fld.
- * num1 and num2 must have at least fld fields.
- * fld must be positive.
-*/
-{
- register char const *s1, *s2;
- register size_t d1, d2;
-
- s1 = num1;
- s2 = num2;
- /* skip fld-1 fields */
- while (--fld) {
- while (*s1++ != '.')
- continue;
- while (*s2++ != '.')
- continue;
- }
- /* Now s1 and s2 point to the beginning of the respective fields */
- while (*s1=='0') ++s1; for (d1=0; isdigit(*(s1+d1)); d1++) continue;
- while (*s2=='0') ++s2; for (d2=0; isdigit(*(s2+d2)); d2++) continue;
-
- return d1<d2 ? -1 : d1==d2 ? memcmp(s1,s2,d1) : 1;
-}
-
-
- int
-cmpdate(d1, d2)
- char const *d1, *d2;
-/*
-* Compare the two dates. This is just like cmpnum,
-* except that for compatibility with old versions of RCS,
-* 1900 is added to dates with two-digit years.
-*/
-{
- char year1[5], year2[5];
- int r = cmpnumfld(normalizeyear(d1,year1), normalizeyear(d2,year2), 1);
-
- if (r)
- return r;
- else {
- while (isdigit(*d1)) d1++; d1 += *d1=='.';
- while (isdigit(*d2)) d2++; d2 += *d2=='.';
- return cmpnum(d1, d2);
- }
-}
-
- static char const *
-normalizeyear(date, year)
- char const *date;
- char year[5];
-{
- if (isdigit(date[0]) && isdigit(date[1]) && !isdigit(date[2])) {
- year[0] = '1';
- year[1] = '9';
- year[2] = date[0];
- year[3] = date[1];
- year[4] = 0;
- return year;
- } else
- return date;
-}
-
-
- static void
-cantfindbranch(revno, date, author, state)
- char const *revno, date[datesize], *author, *state;
-{
- char datebuf[datesize + zonelenmax];
-
- rcserror("No revision on branch %s has%s%s%s%s%s%s.",
- revno,
- date ? " a date before " : "",
- date ? date2str(date,datebuf) : "",
- author ? " and author "+(date?0:4) : "",
- author ? author : "",
- state ? " and state "+(date||author?0:4) : "",
- state ? state : ""
- );
-}
-
- static void
-absent(revno, field)
- char const *revno;
- int field;
-{
- struct buf t;
- bufautobegin(&t);
- rcserror("%s %s absent", field&1?"revision":"branch",
- partialno(&t,revno,field)
- );
- bufautoend(&t);
-}
-
-
- int
-compartial(num1, num2, length)
- char const *num1, *num2;
- int length;
-
-/* compare the first "length" fields of two dot numbers;
- the omitted field is considered to be larger than any number */
-/* restriction: at least one number has length or more fields */
-
-{
- register char const *s1, *s2;
- register size_t d1, d2;
- register int r;
-
- s1 = num1; s2 = num2;
- if (!s1) return 1;
- if (!s2) return -1;
-
- for (;;) {
- if (!*s1) return 1;
- if (!*s2) return -1;
-
- while (*s1=='0') ++s1; for (d1=0; isdigit(*(s1+d1)); d1++) continue;
- while (*s2=='0') ++s2; for (d2=0; isdigit(*(s2+d2)); d2++) continue;
-
- if (d1 != d2)
- return d1<d2 ? -1 : 1;
- if ((r = memcmp(s1, s2, d1)))
- return r;
- if (!--length)
- return 0;
-
- s1 += d1;
- s2 += d1;
-
- if (*s1 == '.') s1++;
- if (*s2 == '.') s2++;
- }
-}
-
-
-char * partialno(rev1,rev2,length)
- struct buf *rev1;
- char const *rev2;
- register int length;
-/* Function: Copies length fields of revision number rev2 into rev1.
- * Return rev1's string.
- */
-{
- register char *r1;
-
- bufscpy(rev1, rev2);
- r1 = rev1->string;
- while (length) {
- while (*r1!='.' && *r1)
- ++r1;
- ++r1;
- length--;
- }
- /* eliminate last '.'*/
- *(r1-1)='\0';
- return rev1->string;
-}
-
-
-
-
- static void
-store1(store, next)
- struct hshentries ***store;
- struct hshentry *next;
-/*
- * Allocate a new list node that addresses NEXT.
- * Append it to the list that **STORE is the end pointer of.
- */
-{
- register struct hshentries *p;
-
- p = ftalloc(struct hshentries);
- p->first = next;
- **store = p;
- *store = &p->rest;
-}
-
-struct hshentry * genrevs(revno,date,author,state,store)
- char const *revno, *date, *author, *state;
- struct hshentries **store;
-/* Function: finds the deltas needed for reconstructing the
- * revision given by revno, date, author, and state, and stores pointers
- * to these deltas into a list whose starting address is given by store.
- * The last delta (target delta) is returned.
- * If the proper delta could not be found, 0 is returned.
- */
-{
- int length;
- register struct hshentry * next;
- int result;
- char const *branchnum;
- struct buf t;
- char datebuf[datesize + zonelenmax];
-
- bufautobegin(&t);
-
- if (!(next = Head)) {
- rcserror("RCS file empty");
- goto norev;
- }
-
- length = countnumflds(revno);
-
- if (length >= 1) {
- /* at least one field; find branch exactly */
- while ((result=cmpnumfld(revno,next->num,1)) < 0) {
- store1(&store, next);
- next = next->next;
- if (!next) {
- rcserror("branch number %s too low", partialno(&t,revno,1));
- goto norev;
- }
- }
-
- if (result>0) {
- absent(revno, 1);
- goto norev;
- }
- }
- if (length<=1){
- /* pick latest one on given branch */
- branchnum = next->num; /* works even for empty revno*/
- while (next &&
- cmpnumfld(branchnum,next->num,1) == 0 &&
- (
- (date && cmpdate(date,next->date) < 0) ||
- (author && strcmp(author,next->author) != 0) ||
- (state && strcmp(state,next->state) != 0)
- )
- )
- {
- store1(&store, next);
- next=next->next;
- }
- if (!next ||
- (cmpnumfld(branchnum,next->num,1)!=0))/*overshot*/ {
- cantfindbranch(
- length ? revno : partialno(&t,branchnum,1),
- date, author, state
- );
- goto norev;
- } else {
- store1(&store, next);
- }
- *store = 0;
- return next;
- }
-
- /* length >=2 */
- /* find revision; may go low if length==2*/
- while ((result=cmpnumfld(revno,next->num,2)) < 0 &&
- (cmpnumfld(revno,next->num,1)==0) ) {
- store1(&store, next);
- next = next->next;
- if (!next)
- break;
- }
-
- if (!next || cmpnumfld(revno,next->num,1) != 0) {
- rcserror("revision number %s too low", partialno(&t,revno,2));
- goto norev;
- }
- if ((length>2) && (result!=0)) {
- absent(revno, 2);
- goto norev;
- }
-
- /* print last one */
- store1(&store, next);
-
- if (length>2)
- return genbranch(next,revno,length,date,author,state,store);
- else { /* length == 2*/
- if (date && cmpdate(date,next->date)<0) {
- rcserror("Revision %s has date %s.",
- next->num,
- date2str(next->date, datebuf)
- );
- return 0;
- }
- if (author && strcmp(author,next->author)!=0) {
- rcserror("Revision %s has author %s.",
- next->num, next->author
- );
- return 0;
- }
- if (state && strcmp(state,next->state)!=0) {
- rcserror("Revision %s has state %s.",
- next->num,
- next->state ? next->state : "<empty>"
- );
- return 0;
- }
- *store = 0;
- return next;
- }
-
- norev:
- bufautoend(&t);
- return 0;
-}
-
-
-
-
- static struct hshentry *
-genbranch(bpoint, revno, length, date, author, state, store)
- struct hshentry const *bpoint;
- char const *revno;
- int length;
- char const *date, *author, *state;
- struct hshentries **store;
-/* Function: given a branchpoint, a revision number, date, author, and state,
- * genbranch finds the deltas necessary to reconstruct the given revision
- * from the branch point on.
- * Pointers to the found deltas are stored in a list beginning with store.
- * revno must be on a side branch.
- * Return 0 on error.
- */
-{
- int field;
- register struct hshentry * next, * trail;
- register struct branchhead const *bhead;
- int result;
- struct buf t;
- char datebuf[datesize + zonelenmax];
-
- field = 3;
- bhead = bpoint->branches;
-
- do {
- if (!bhead) {
- bufautobegin(&t);
- rcserror("no side branches present for %s",
- partialno(&t,revno,field-1)
- );
- bufautoend(&t);
- return 0;
- }
-
- /*find branch head*/
- /*branches are arranged in increasing order*/
- while (0 < (result=cmpnumfld(revno,bhead->hsh->num,field))) {
- bhead = bhead->nextbranch;
- if (!bhead) {
- bufautobegin(&t);
- rcserror("branch number %s too high",
- partialno(&t,revno,field)
- );
- bufautoend(&t);
- return 0;
- }
- }
-
- if (result<0) {
- absent(revno, field);
- return 0;
- }
-
- next = bhead->hsh;
- if (length==field) {
- /* pick latest one on that branch */
- trail = 0;
- do { if ((!date || cmpdate(date,next->date)>=0) &&
- (!author || strcmp(author,next->author)==0) &&
- (!state || strcmp(state,next->state)==0)
- ) trail = next;
- next=next->next;
- } while (next);
-
- if (!trail) {
- cantfindbranch(revno, date, author, state);
- return 0;
- } else { /* print up to last one suitable */
- next = bhead->hsh;
- while (next!=trail) {
- store1(&store, next);
- next=next->next;
- }
- store1(&store, next);
- }
- *store = 0;
- return next;
- }
-
- /* length > field */
- /* find revision */
- /* check low */
- if (cmpnumfld(revno,next->num,field+1)<0) {
- bufautobegin(&t);
- rcserror("revision number %s too low",
- partialno(&t,revno,field+1)
- );
- bufautoend(&t);
- return 0;
- }
- do {
- store1(&store, next);
- trail = next;
- next = next->next;
- } while (next && cmpnumfld(revno,next->num,field+1)>=0);
-
- if ((length>field+1) && /*need exact hit */
- (cmpnumfld(revno,trail->num,field+1) !=0)){
- absent(revno, field+1);
- return 0;
- }
- if (length == field+1) {
- if (date && cmpdate(date,trail->date)<0) {
- rcserror("Revision %s has date %s.",
- trail->num,
- date2str(trail->date, datebuf)
- );
- return 0;
- }
- if (author && strcmp(author,trail->author)!=0) {
- rcserror("Revision %s has author %s.",
- trail->num, trail->author
- );
- return 0;
- }
- if (state && strcmp(state,trail->state)!=0) {
- rcserror("Revision %s has state %s.",
- trail->num,
- trail->state ? trail->state : "<empty>"
- );
- return 0;
- }
- }
- bhead = trail->branches;
-
- } while ((field+=2) <= length);
- *store = 0;
- return trail;
-}
-
-
- static char const *
-lookupsym(id)
- char const *id;
-/* Function: looks up id in the list of symbolic names starting
- * with pointer SYMBOLS, and returns a pointer to the corresponding
- * revision number. Return 0 if not present.
- */
-{
- register struct assoc const *next;
- for (next = Symbols; next; next = next->nextassoc)
- if (strcmp(id, next->symbol)==0)
- return next->num;
- return 0;
-}
-
-int expandsym(source, target)
- char const *source;
- struct buf *target;
-/* Function: Source points to a revision number. Expandsym copies
- * the number to target, but replaces all symbolic fields in the
- * source number with their numeric values.
- * Expand a branch followed by `.' to the latest revision on that branch.
- * Ignore `.' after a revision. Remove leading zeros.
- * returns false on error;
- */
-{
- return fexpandsym(source, target, (RILE*)0);
-}
-
- int
-fexpandsym(source, target, fp)
- char const *source;
- struct buf *target;
- RILE *fp;
-/* Same as expandsym, except if FP is nonzero, it is used to expand KDELIM. */
-{
- register char const *sp, *bp;
- register char *tp;
- char const *tlim;
- int dots;
-
- sp = source;
- bufalloc(target, 1);
- tp = target->string;
- if (!sp || !*sp) { /* Accept 0 pointer as a legal value. */
- *tp='\0';
- return true;
- }
- if (sp[0] == KDELIM && !sp[1]) {
- if (!getoldkeys(fp))
- return false;
- if (!*prevrev.string) {
- workerror("working file lacks revision number");
- return false;
- }
- bufscpy(target, prevrev.string);
- return true;
- }
- tlim = tp + target->size;
- dots = 0;
-
- for (;;) {
- register char *p = tp;
- size_t s = tp - target->string;
- int id = false;
- for (;;) {
- switch (ctab[(unsigned char)*sp]) {
- case IDCHAR:
- case LETTER:
- case Letter:
- id = true;
- /* fall into */
- case DIGIT:
- if (tlim <= p)
- p = bufenlarge(target, &tlim);
- *p++ = *sp++;
- continue;
-
- default:
- break;
- }
- break;
- }
- if (tlim <= p)
- p = bufenlarge(target, &tlim);
- *p = 0;
- tp = target->string + s;
-
- if (id) {
- bp = lookupsym(tp);
- if (!bp) {
- rcserror("Symbolic name `%s' is undefined.",tp);
- return false;
- }
- } else {
- /* skip leading zeros */
- for (bp = tp; *bp=='0' && isdigit(bp[1]); bp++)
- continue;
-
- if (!*bp)
- if (s || *sp!='.')
- break;
- else {
- /* Insert default branch before initial `.'. */
- char const *b;
- if (Dbranch)
- b = Dbranch;
- else if (Head)
- b = Head->num;
- else
- break;
- getbranchno(b, target);
- bp = tp = target->string;
- tlim = tp + target->size;
- }
- }
-
- while ((*tp++ = *bp++))
- if (tlim <= tp)
- tp = bufenlarge(target, &tlim);
-
- switch (*sp++) {
- case '\0':
- return true;
-
- case '.':
- if (!*sp) {
- if (dots & 1)
- break;
- if (!(bp = branchtip(target->string)))
- return false;
- bufscpy(target, bp);
- return true;
- }
- ++dots;
- tp[-1] = '.';
- continue;
- }
- break;
- }
-
- rcserror("improper revision number: %s", source);
- return false;
-}
-
- char const *
-namedrev(name, delta)
- char const *name;
- struct hshentry *delta;
-/* Yield NAME if it names DELTA, 0 otherwise. */
-{
- if (name) {
- char const *id = 0, *p, *val;
- for (p = name; ; p++)
- switch (ctab[(unsigned char)*p]) {
- case IDCHAR:
- case LETTER:
- case Letter:
- id = name;
- break;
-
- case DIGIT:
- break;
-
- case UNKN:
- if (!*p && id &&
- (val = lookupsym(id)) &&
- strcmp(val, delta->num) == 0
- )
- return id;
- /* fall into */
- default:
- return 0;
- }
- }
- return 0;
-}
-
- static char const *
-branchtip(branch)
- char const *branch;
-{
- struct hshentry *h;
- struct hshentries *hs;
-
- h = genrevs(branch, (char*)0, (char*)0, (char*)0, &hs);
- return h ? h->num : (char const*)0;
-}
-
- char const *
-tiprev()
-{
- return Dbranch ? branchtip(Dbranch) : Head ? Head->num : (char const*)0;
-}
-
-
-
-#ifdef REVTEST
-
-/*
-* Test the routines that generate a sequence of delta numbers
-* needed to regenerate a given delta.
-*/
-
-char const cmdid[] = "revtest";
-
- int
-main(argc,argv)
-int argc; char * argv[];
-{
- static struct buf numricrevno;
- char symrevno[100]; /* used for input of revision numbers */
- char author[20];
- char state[20];
- char date[20];
- struct hshentries *gendeltas;
- struct hshentry * target;
- int i;
-
- if (argc<2) {
- aputs("No input file\n",stderr);
- exitmain(EXIT_FAILURE);
- }
- if (!(finptr=Iopen(argv[1], FOPEN_R, (struct stat*)0))) {
- faterror("can't open input file %s", argv[1]);
- }
- Lexinit();
- getadmin();
-
- gettree();
-
- getdesc(false);
-
- do {
- /* all output goes to stderr, to have diagnostics and */
- /* errors in sequence. */
- aputs("\nEnter revision number or <return> or '.': ",stderr);
- if (!fgets(symrevno, 100, stdin)) break;
- if (*symrevno == '.') break;
- aprintf(stderr,"%s;\n",symrevno);
- expandsym(symrevno,&numricrevno);
- aprintf(stderr,"expanded number: %s; ",numricrevno.string);
- aprintf(stderr,"Date: ");
- fgets(date, 20, stdin); aprintf(stderr,"%s; ",date);
- aprintf(stderr,"Author: ");
- fgets(author, 20, stdin); aprintf(stderr,"%s; ",author);
- aprintf(stderr,"State: ");
- fgets(state, 20, stdin); aprintf(stderr, "%s;\n", state);
- target = genrevs(numricrevno.string, *date?date:(char *)0, *author?author:(char *)0,
- *state?state:(char*)0, &gendeltas);
- if (target) {
- while (gendeltas) {
- aprintf(stderr,"%s\n",gendeltas->first->num);
- gendeltas = gendeltas->next;
- }
- }
- } while (true);
- aprintf(stderr,"done\n");
- exitmain(EXIT_SUCCESS);
-}
-
-void exiterr() { _exit(EXIT_FAILURE); }
-
-#endif
diff --git a/gnu/usr.bin/rcs/lib/rcssyn.c b/gnu/usr.bin/rcs/lib/rcssyn.c
deleted file mode 100644
index e6ccb25..0000000
--- a/gnu/usr.bin/rcs/lib/rcssyn.c
+++ /dev/null
@@ -1,681 +0,0 @@
-/* RCS file syntactic analysis */
-
-/******************************************************************************
- * Syntax Analysis.
- * Keyword table
- * Testprogram: define SYNTEST
- * Compatibility with Release 2: define COMPAT2=1
- ******************************************************************************
- */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.15 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.14 1995/06/01 16:23:43 eggert
- * (expand_names): Add "b" for -kb.
- * (getdelta): Don't strip leading "19" from MKS RCS dates; see cmpdate.
- *
- * Revision 5.13 1994/03/20 04:52:58 eggert
- * Remove lint.
- *
- * Revision 5.12 1993/11/03 17:42:27 eggert
- * Parse MKS RCS dates; ignore \r in diff control lines.
- * Don't discard ignored phrases. Improve quality of diagnostics.
- *
- * Revision 5.11 1992/07/28 16:12:44 eggert
- * Avoid `unsigned'. Statement macro names now end in _.
- *
- * Revision 5.10 1992/01/24 18:44:19 eggert
- * Move put routines to rcsgen.c.
- *
- * Revision 5.9 1992/01/06 02:42:34 eggert
- * ULONG_MAX/10 -> ULONG_MAX_OVER_10
- * while (E) ; -> while (E) continue;
- *
- * Revision 5.8 1991/08/19 03:13:55 eggert
- * Tune.
- *
- * Revision 5.7 1991/04/21 11:58:29 eggert
- * Disambiguate names on shortname hosts.
- * Fix errno bug. Add MS-DOS support.
- *
- * Revision 5.6 1991/02/28 19:18:51 eggert
- * Fix null termination bug in reporting keyword expansion.
- *
- * Revision 5.5 1991/02/25 07:12:44 eggert
- * Check diff output more carefully; avoid overflow.
- *
- * Revision 5.4 1990/11/01 05:28:48 eggert
- * When ignoring unknown phrases, copy them to the output RCS file.
- * Permit arbitrary data in logs and comment leaders.
- * Don't check for nontext on initial checkin.
- *
- * Revision 5.3 1990/09/20 07:58:32 eggert
- * Remove the test for non-text bytes; it caused more pain than it cured.
- *
- * Revision 5.2 1990/09/04 08:02:30 eggert
- * Parse RCS files with no revisions.
- * Don't strip leading white space from diff commands. Count RCS lines better.
- *
- * Revision 5.1 1990/08/29 07:14:06 eggert
- * Add -kkvl. Clean old log messages too.
- *
- * Revision 5.0 1990/08/22 08:13:44 eggert
- * Try to parse future RCS formats without barfing.
- * Add -k. Don't require final newline.
- * Remove compile-time limits; use malloc instead.
- * Don't output branch keyword if there's no default branch,
- * because RCS version 3 doesn't understand it.
- * Tune. Remove lint.
- * Add support for ISO 8859. Ansify and Posixate.
- * Check that a newly checked-in file is acceptable as input to 'diff'.
- * Check diff's output.
- *
- * Revision 4.6 89/05/01 15:13:32 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.5 88/08/09 19:13:21 eggert
- * Allow cc -R; remove lint.
- *
- * Revision 4.4 87/12/18 11:46:16 narten
- * more lint cleanups (Guy Harris)
- *
- * Revision 4.3 87/10/18 10:39:36 narten
- * Updating version numbers. Changes relative to 1.1 actually relative to
- * 4.1
- *
- * Revision 1.3 87/09/24 14:00:49 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:40 jenkins
- * Port to suns
- *
- * Revision 4.1 83/03/28 11:38:49 wft
- * Added parsing and printing of default branch.
- *
- * Revision 3.6 83/01/15 17:46:50 wft
- * Changed readdelta() to initialize selector and log-pointer.
- * Changed puttree to check for selector==DELETE; putdtext() uses DELNUMFORM.
- *
- * Revision 3.5 82/12/08 21:58:58 wft
- * renamed Commentleader to Commleader.
- *
- * Revision 3.4 82/12/04 13:24:40 wft
- * Added routine gettree(), which updates keeplock after reading the
- * delta tree.
- *
- * Revision 3.3 82/11/28 21:30:11 wft
- * Reading and printing of Suffix removed; version COMPAT2 skips the
- * Suffix for files of release 2 format. Fixed problems with printing nil.
- *
- * Revision 3.2 82/10/18 21:18:25 wft
- * renamed putdeltatext to putdtext.
- *
- * Revision 3.1 82/10/11 19:45:11 wft
- * made sure getc() returns into an integer.
- */
-
-
-
-/* version COMPAT2 reads files of the format of release 2 and 3, but
- * generates files of release 3 format. Need not be defined if no
- * old RCS files generated with release 2 exist.
- */
-
-#include "rcsbase.h"
-
-libId(synId, "$Id$")
-
-static char const *getkeyval P((char const*,enum tokens,int));
-static int getdelta P((void));
-static int strn2expmode P((char const*,size_t));
-static struct hshentry *getdnum P((void));
-static void badDiffOutput P((char const*)) exiting;
-static void diffLineNumberTooLarge P((char const*)) exiting;
-static void getsemi P((char const*));
-
-/* keyword table */
-
-char const
- Kaccess[] = "access",
- Kauthor[] = "author",
- Kbranch[] = "branch",
- Kcomment[] = "comment",
- Kdate[] = "date",
- Kdesc[] = "desc",
- Kexpand[] = "expand",
- Khead[] = "head",
- Klocks[] = "locks",
- Klog[] = "log",
- Knext[] = "next",
- Kstate[] = "state",
- Kstrict[] = "strict",
- Ksymbols[] = "symbols",
- Ktext[] = "text";
-
-static char const
-#if COMPAT2
- Ksuffix[] = "suffix",
-#endif
- K_branches[]= "branches";
-
-static struct buf Commleader;
-struct cbuf Comment;
-struct cbuf Ignored;
-struct access * AccessList;
-struct assoc * Symbols;
-struct rcslock *Locks;
-int Expand;
-int StrictLocks;
-struct hshentry * Head;
-char const * Dbranch;
-int TotalDeltas;
-
-
- static void
-getsemi(key)
- char const *key;
-/* Get a semicolon to finish off a phrase started by KEY. */
-{
- if (!getlex(SEMI))
- fatserror("missing ';' after '%s'", key);
-}
-
- static struct hshentry *
-getdnum()
-/* Get a delta number. */
-{
- register struct hshentry *delta = getnum();
- if (delta && countnumflds(delta->num)&1)
- fatserror("%s isn't a delta number", delta->num);
- return delta;
-}
-
-
- void
-getadmin()
-/* Read an <admin> and initialize the appropriate global variables. */
-{
- register char const *id;
- struct access * newaccess;
- struct assoc * newassoc;
- struct rcslock *newlock;
- struct hshentry * delta;
- struct access **LastAccess;
- struct assoc **LastSymbol;
- struct rcslock **LastLock;
- struct buf b;
- struct cbuf cb;
-
- TotalDeltas=0;
-
- getkey(Khead);
- Head = getdnum();
- getsemi(Khead);
-
- Dbranch = 0;
- if (getkeyopt(Kbranch)) {
- if ((delta = getnum()))
- Dbranch = delta->num;
- getsemi(Kbranch);
- }
-
-
-#if COMPAT2
- /* read suffix. Only in release 2 format */
- if (getkeyopt(Ksuffix)) {
- if (nexttok==STRING) {
- readstring(); nextlex(); /* Throw away the suffix. */
- } else if (nexttok==ID) {
- nextlex();
- }
- getsemi(Ksuffix);
- }
-#endif
-
- getkey(Kaccess);
- LastAccess = &AccessList;
- while ((id = getid())) {
- newaccess = ftalloc(struct access);
- newaccess->login = id;
- *LastAccess = newaccess;
- LastAccess = &newaccess->nextaccess;
- }
- *LastAccess = 0;
- getsemi(Kaccess);
-
- getkey(Ksymbols);
- LastSymbol = &Symbols;
- while ((id = getid())) {
- if (!getlex(COLON))
- fatserror("missing ':' in symbolic name definition");
- if (!(delta=getnum())) {
- fatserror("missing number in symbolic name definition");
- } else { /*add new pair to association list*/
- newassoc = ftalloc(struct assoc);
- newassoc->symbol=id;
- newassoc->num = delta->num;
- *LastSymbol = newassoc;
- LastSymbol = &newassoc->nextassoc;
- }
- }
- *LastSymbol = 0;
- getsemi(Ksymbols);
-
- getkey(Klocks);
- LastLock = &Locks;
- while ((id = getid())) {
- if (!getlex(COLON))
- fatserror("missing ':' in lock");
- if (!(delta=getdnum())) {
- fatserror("missing number in lock");
- } else { /*add new pair to lock list*/
- newlock = ftalloc(struct rcslock);
- newlock->login=id;
- newlock->delta=delta;
- *LastLock = newlock;
- LastLock = &newlock->nextlock;
- }
- }
- *LastLock = 0;
- getsemi(Klocks);
-
- if ((StrictLocks = getkeyopt(Kstrict)))
- getsemi(Kstrict);
-
- clear_buf(&Comment);
- if (getkeyopt(Kcomment)) {
- if (nexttok==STRING) {
- Comment = savestring(&Commleader);
- nextlex();
- }
- getsemi(Kcomment);
- }
-
- Expand = KEYVAL_EXPAND;
- if (getkeyopt(Kexpand)) {
- if (nexttok==STRING) {
- bufautobegin(&b);
- cb = savestring(&b);
- if ((Expand = strn2expmode(cb.string,cb.size)) < 0)
- fatserror("unknown expand mode %.*s",
- (int)cb.size, cb.string
- );
- bufautoend(&b);
- nextlex();
- }
- getsemi(Kexpand);
- }
- Ignored = getphrases(Kdesc);
-}
-
-char const *const expand_names[] = {
- /* These must agree with *_EXPAND in rcsbase.h. */
- "kv", "kvl", "k", "v", "o", "b",
- 0
-};
-
- int
-str2expmode(s)
- char const *s;
-/* Yield expand mode corresponding to S, or -1 if bad. */
-{
- return strn2expmode(s, strlen(s));
-}
-
- static int
-strn2expmode(s, n)
- char const *s;
- size_t n;
-{
- char const *const *p;
-
- for (p = expand_names; *p; ++p)
- if (memcmp(*p,s,n) == 0 && !(*p)[n])
- return p - expand_names;
- return -1;
-}
-
-
- void
-ignorephrases(key)
- const char *key;
-/*
-* Ignore a series of phrases that do not start with KEY.
-* Stop when the next phrase starts with a token that is not an identifier,
-* or is KEY.
-*/
-{
- for (;;) {
- nextlex();
- if (nexttok != ID || strcmp(NextString,key) == 0)
- break;
- warnignore();
- hshenter=false;
- for (;; nextlex()) {
- switch (nexttok) {
- case SEMI: hshenter=true; break;
- case ID:
- case NUM: ffree1(NextString); continue;
- case STRING: readstring(); continue;
- default: continue;
- }
- break;
- }
- }
-}
-
-
- static int
-getdelta()
-/* Function: reads a delta block.
- * returns false if the current block does not start with a number.
- */
-{
- register struct hshentry * Delta, * num;
- struct branchhead **LastBranch, *NewBranch;
-
- if (!(Delta = getdnum()))
- return false;
-
- hshenter = false; /*Don't enter dates into hashtable*/
- Delta->date = getkeyval(Kdate, NUM, false);
- hshenter=true; /*reset hshenter for revision numbers.*/
-
- Delta->author = getkeyval(Kauthor, ID, false);
-
- Delta->state = getkeyval(Kstate, ID, true);
-
- getkey(K_branches);
- LastBranch = &Delta->branches;
- while ((num = getdnum())) {
- NewBranch = ftalloc(struct branchhead);
- NewBranch->hsh = num;
- *LastBranch = NewBranch;
- LastBranch = &NewBranch->nextbranch;
- }
- *LastBranch = 0;
- getsemi(K_branches);
-
- getkey(Knext);
- Delta->next = num = getdnum();
- getsemi(Knext);
- Delta->lockedby = 0;
- Delta->log.string = 0;
- Delta->selector = true;
- Delta->ig = getphrases(Kdesc);
- TotalDeltas++;
- return (true);
-}
-
-
- void
-gettree()
-/* Function: Reads in the delta tree with getdelta(), then
- * updates the lockedby fields.
- */
-{
- struct rcslock const *currlock;
-
- while (getdelta())
- continue;
- currlock=Locks;
- while (currlock) {
- currlock->delta->lockedby = currlock->login;
- currlock = currlock->nextlock;
- }
-}
-
-
- void
-getdesc(prdesc)
-int prdesc;
-/* Function: read in descriptive text
- * nexttok is not advanced afterwards.
- * If prdesc is set, the text is printed to stdout.
- */
-{
-
- getkeystring(Kdesc);
- if (prdesc)
- printstring(); /*echo string*/
- else readstring(); /*skip string*/
-}
-
-
-
-
-
-
- static char const *
-getkeyval(keyword, token, optional)
- char const *keyword;
- enum tokens token;
- int optional;
-/* reads a pair of the form
- * <keyword> <token> ;
- * where token is one of <id> or <num>. optional indicates whether
- * <token> is optional. A pointer to
- * the actual character string of <id> or <num> is returned.
- */
-{
- register char const *val = 0;
-
- getkey(keyword);
- if (nexttok==token) {
- val = NextString;
- nextlex();
- } else {
- if (!optional)
- fatserror("missing %s", keyword);
- }
- getsemi(keyword);
- return(val);
-}
-
-
- void
-unexpected_EOF()
-{
- rcsfaterror("unexpected EOF in diff output");
-}
-
- void
-initdiffcmd(dc)
- register struct diffcmd *dc;
-/* Initialize *dc suitably for getdiffcmd(). */
-{
- dc->adprev = 0;
- dc->dafter = 0;
-}
-
- static void
-badDiffOutput(buf)
- char const *buf;
-{
- rcsfaterror("bad diff output line: %s", buf);
-}
-
- static void
-diffLineNumberTooLarge(buf)
- char const *buf;
-{
- rcsfaterror("diff line number too large: %s", buf);
-}
-
- int
-getdiffcmd(finfile, delimiter, foutfile, dc)
- RILE *finfile;
- FILE *foutfile;
- int delimiter;
- struct diffcmd *dc;
-/* Get a editing command output by 'diff -n' from fin.
- * The input is delimited by SDELIM if delimiter is set, EOF otherwise.
- * Copy a clean version of the command to fout (if nonnull).
- * Yield 0 for 'd', 1 for 'a', and -1 for EOF.
- * Store the command's line number and length into dc->line1 and dc->nlines.
- * Keep dc->adprev and dc->dafter up to date.
- */
-{
- register int c;
- declarecache;
- register FILE *fout;
- register char *p;
- register RILE *fin;
- long line1, nlines, t;
- char buf[BUFSIZ];
-
- fin = finfile;
- fout = foutfile;
- setupcache(fin); cache(fin);
- cachegeteof_(c, { if (delimiter) unexpected_EOF(); return -1; } )
- if (delimiter) {
- if (c==SDELIM) {
- cacheget_(c)
- if (c==SDELIM) {
- buf[0] = c;
- buf[1] = 0;
- badDiffOutput(buf);
- }
- uncache(fin);
- nextc = c;
- if (fout)
- aprintf(fout, "%c%c", SDELIM, c);
- return -1;
- }
- }
- p = buf;
- do {
- if (buf+BUFSIZ-2 <= p) {
- rcsfaterror("diff output command line too long");
- }
- *p++ = c;
- cachegeteof_(c, unexpected_EOF();)
- } while (c != '\n');
- uncache(fin);
- if (delimiter)
- ++rcsline;
- *p = '\0';
- for (p = buf+1; (c = *p++) == ' '; )
- continue;
- line1 = 0;
- while (isdigit(c)) {
- if (
- LONG_MAX/10 < line1 ||
- (t = line1 * 10, (line1 = t + (c - '0')) < t)
- )
- diffLineNumberTooLarge(buf);
- c = *p++;
- }
- while (c == ' ')
- c = *p++;
- nlines = 0;
- while (isdigit(c)) {
- if (
- LONG_MAX/10 < nlines ||
- (t = nlines * 10, (nlines = t + (c - '0')) < t)
- )
- diffLineNumberTooLarge(buf);
- c = *p++;
- }
- if (c == '\r')
- c = *p++;
- if (c || !nlines) {
- badDiffOutput(buf);
- }
- if (line1+nlines < line1)
- diffLineNumberTooLarge(buf);
- switch (buf[0]) {
- case 'a':
- if (line1 < dc->adprev) {
- rcsfaterror("backward insertion in diff output: %s", buf);
- }
- dc->adprev = line1 + 1;
- break;
- case 'd':
- if (line1 < dc->adprev || line1 < dc->dafter) {
- rcsfaterror("backward deletion in diff output: %s", buf);
- }
- dc->adprev = line1;
- dc->dafter = line1 + nlines;
- break;
- default:
- badDiffOutput(buf);
- }
- if (fout) {
- aprintf(fout, "%s\n", buf);
- }
- dc->line1 = line1;
- dc->nlines = nlines;
- return buf[0] == 'a';
-}
-
-
-
-#ifdef SYNTEST
-
-/* Input an RCS file and print its internal data structures. */
-
-char const cmdid[] = "syntest";
-
- int
-main(argc,argv)
-int argc; char * argv[];
-{
-
- if (argc<2) {
- aputs("No input file\n",stderr);
- exitmain(EXIT_FAILURE);
- }
- if (!(finptr = Iopen(argv[1], FOPEN_R, (struct stat*)0))) {
- faterror("can't open input file %s", argv[1]);
- }
- Lexinit();
- getadmin();
- fdlock = STDOUT_FILENO;
- putadmin();
-
- gettree();
-
- getdesc(true);
-
- nextlex();
-
- if (!eoflex()) {
- fatserror("expecting EOF");
- }
- exitmain(EXIT_SUCCESS);
-}
-
-void exiterr() { _exit(EXIT_FAILURE); }
-
-#endif
diff --git a/gnu/usr.bin/rcs/lib/rcstime.c b/gnu/usr.bin/rcs/lib/rcstime.c
deleted file mode 100644
index 70a013b..0000000
--- a/gnu/usr.bin/rcs/lib/rcstime.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/* Convert between RCS time format and Posix and/or C formats. */
-
-/* Copyright 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#include "rcsbase.h"
-#include "partime.h"
-#include "maketime.h"
-
-libId(rcstimeId, "$Id$")
-
-static long zone_offset; /* seconds east of UTC, or TM_LOCAL_ZONE */
-static int use_zone_offset; /* if zero, use UTC without zone indication */
-
-/*
-* Convert Unix time to RCS format.
-* For compatibility with older versions of RCS,
-* dates from 1900 through 1999 are stored without the leading "19".
-*/
- void
-time2date(unixtime,date)
- time_t unixtime;
- char date[datesize];
-{
- register struct tm const *tm = time2tm(unixtime, RCSversion<VERSION(5));
- VOID sprintf(date,
-# if has_printf_dot
- "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d",
-# else
- "%02d.%02d.%02d.%02d.%02d.%02d",
-# endif
- tm->tm_year + ((unsigned)tm->tm_year < 100 ? 0 : 1900),
- tm->tm_mon+1, tm->tm_mday,
- tm->tm_hour, tm->tm_min, tm->tm_sec
- );
-}
-
-/* Like str2time, except die if an error was found. */
-static time_t str2time_checked P((char const*,time_t,long));
- static time_t
-str2time_checked(source, default_time, default_zone)
- char const *source;
- time_t default_time;
- long default_zone;
-{
- time_t t = str2time(source, default_time, default_zone);
- if (t == -1)
- faterror("unknown date/time: %s", source);
- return t;
-}
-
-/*
-* Parse a free-format date in SOURCE, convert it
-* into RCS internal format, and store the result into TARGET.
-*/
- void
-str2date(source, target)
- char const *source;
- char target[datesize];
-{
- time2date(
- str2time_checked(source, now(),
- use_zone_offset ? zone_offset
- : RCSversion<VERSION(5) ? TM_LOCAL_ZONE
- : 0
- ),
- target
- );
-}
-
-/* Convert an RCS internal format date to time_t. */
- time_t
-date2time(source)
- char const source[datesize];
-{
- char s[datesize + zonelenmax];
- return str2time_checked(date2str(source, s), (time_t)0, 0);
-}
-
-
-/* Set the time zone for date2str output. */
- void
-zone_set(s)
- char const *s;
-{
- if ((use_zone_offset = *s)) {
- long zone;
- char const *zonetail = parzone(s, &zone);
- if (!zonetail || *zonetail)
- error("%s: not a known time zone", s);
- else
- zone_offset = zone;
- }
-}
-
-
-/*
-* Format a user-readable form of the RCS format DATE into the buffer DATEBUF.
-* Yield DATEBUF.
-*/
- char const *
-date2str(date, datebuf)
- char const date[datesize];
- char datebuf[datesize + zonelenmax];
-{
- register char const *p = date;
-
- while (*p++ != '.')
- continue;
- if (!use_zone_offset)
- VOID sprintf(datebuf,
- "19%.*s/%.2s/%.2s %.2s:%.2s:%s"
- + (date[2]=='.' && VERSION(5)<=RCSversion ? 0 : 2),
- (int)(p-date-1), date,
- p, p+3, p+6, p+9, p+12
- );
- else {
- struct tm t;
- struct tm const *z;
- int non_hour;
- long zone;
- char c;
-
- t.tm_year = atoi(date) - (date[2]=='.' ? 0 : 1900);
- t.tm_mon = atoi(p) - 1;
- t.tm_mday = atoi(p+3);
- t.tm_hour = atoi(p+6);
- t.tm_min = atoi(p+9);
- t.tm_sec = atoi(p+12);
- t.tm_wday = -1;
- zone = zone_offset;
- if (zone == TM_LOCAL_ZONE) {
- time_t u = tm2time(&t, 0), d;
- z = localtime(&u);
- d = difftm(z, &t);
- zone = (time_t)-1 < 0 || d < -d ? d : -(long)-d;
- } else {
- adjzone(&t, zone);
- z = &t;
- }
- c = '+';
- if (zone < 0) {
- zone = -zone;
- c = '-';
- }
- VOID sprintf(datebuf,
-# if has_printf_dot
- "%.2d-%.2d-%.2d %.2d:%.2d:%.2d%c%.2d",
-# else
- "%02d-%02d-%02d %02d:%02d:%02d%c%02d",
-# endif
- z->tm_year + 1900,
- z->tm_mon + 1, z->tm_mday, z->tm_hour, z->tm_min, z->tm_sec,
- c, (int) (zone / (60*60))
- );
- if ((non_hour = zone % (60*60))) {
-# if has_printf_dot
- static char const fmt[] = ":%.2d";
-# else
- static char const fmt[] = ":%02d";
-# endif
- VOID sprintf(datebuf + strlen(datebuf), fmt, non_hour / 60);
- if ((non_hour %= 60))
- VOID sprintf(datebuf + strlen(datebuf), fmt, non_hour);
- }
- }
- return datebuf;
-}
diff --git a/gnu/usr.bin/rcs/lib/rcsutil.c b/gnu/usr.bin/rcs/lib/rcsutil.c
deleted file mode 100644
index 3b2a46f..0000000
--- a/gnu/usr.bin/rcs/lib/rcsutil.c
+++ /dev/null
@@ -1,1398 +0,0 @@
-/* RCS utility functions */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-
-/*
- * Revision 5.20 1995/06/16 06:19:24 eggert
- * (catchsig): Remove `return'.
- * Update FSF address.
- *
- * Revision 5.19 1995/06/02 18:19:00 eggert
- * (catchsigaction): New name for `catchsig', for sa_sigaction signature.
- * Use nRCS even if !has_psiginfo, to remove unused variable warning.
- * (setup_catchsig): Use sa_sigaction only if has_sa_sigaction.
- * Use ENOTSUP only if defined.
- *
- * Revision 5.18 1995/06/01 16:23:43 eggert
- * (catchsig, restoreints, setup_catchsig): Use SA_SIGINFO, not has_psiginfo,
- * to determine whether to use SA_SIGINFO feature,
- * but also check at runtime whether the feature works.
- * (catchsig): If an mmap_signal occurs, report the affected file name.
- * (unsupported_SA_SIGINFO, accessName): New variables.
- * (setup_catchsig): If using SA_SIGINFO, use sa_sigaction, not sa_handler.
- * If SA_SIGINFO fails, fall back on sa_handler method.
- *
- * (readAccessFilenameBuffer, dupSafer, fdSafer, fopenSafer): New functions.
- * (concatenate): Remove.
- *
- * (runv): Work around bad_wait_if_SIGCHLD_ignored bug.
- * Remove reference to OPEN_O_WORK.
- *
- * Revision 5.17 1994/03/20 04:52:58 eggert
- * Specify subprocess input via file descriptor, not file name.
- * Avoid messing with I/O buffers in the child process.
- * Define dup in terms of F_DUPFD if it exists.
- * Move setmtime to rcsedit.c. Remove lint.
- *
- * Revision 5.16 1993/11/09 17:40:15 eggert
- * -V now prints version on stdout and exits.
- *
- * Revision 5.15 1993/11/03 17:42:27 eggert
- * Use psiginfo and setreuid if available. Move date2str to maketime.c.
- *
- * Revision 5.14 1992/07/28 16:12:44 eggert
- * Add -V. has_sigaction overrides sig_zaps_handler. Fix -M bug.
- * Add mmap_signal, which minimizes signal handling for non-mmap hosts.
- *
- * Revision 5.13 1992/02/17 23:02:28 eggert
- * Work around NFS mmap SIGBUS problem. Add -T support.
- *
- * Revision 5.12 1992/01/24 18:44:19 eggert
- * Work around NFS mmap bug that leads to SIGBUS core dumps. lint -> RCS_lint
- *
- * Revision 5.11 1992/01/06 02:42:34 eggert
- * O_BINARY -> OPEN_O_WORK
- * while (E) ; -> while (E) continue;
- *
- * Revision 5.10 1991/10/07 17:32:46 eggert
- * Support piece tables even if !has_mmap.
- *
- * Revision 5.9 1991/08/19 03:13:55 eggert
- * Add spawn() support. Explicate assumptions about getting invoker's name.
- * Standardize user-visible dates. Tune.
- *
- * Revision 5.8 1991/04/21 11:58:30 eggert
- * Plug setuid security hole.
- *
- * Revision 5.6 1991/02/26 17:48:39 eggert
- * Fix setuid bug. Use fread, fwrite more portably.
- * Support waitpid. Don't assume -1 is acceptable to W* macros.
- * strsave -> str_save (DG/UX name clash)
- *
- * Revision 5.5 1990/12/04 05:18:49 eggert
- * Don't output a blank line after a signal diagnostic.
- * Use -I for prompts and -q for diagnostics.
- *
- * Revision 5.4 1990/11/01 05:03:53 eggert
- * Remove unneeded setid check. Add awrite(), fremember().
- *
- * Revision 5.3 1990/10/06 00:16:45 eggert
- * Don't fread F if feof(F).
- *
- * Revision 5.2 1990/09/04 08:02:31 eggert
- * Store fread()'s result in an fread_type object.
- *
- * Revision 5.1 1990/08/29 07:14:07 eggert
- * Declare getpwuid() more carefully.
- *
- * Revision 5.0 1990/08/22 08:13:46 eggert
- * Add setuid support. Permit multiple locks per user.
- * Remove compile-time limits; use malloc instead.
- * Switch to GMT. Permit dates past 1999/12/31.
- * Add -V. Remove snooping. Ansify and Posixate.
- * Tune. Some USG hosts define NSIG but not sys_siglist.
- * Don't run /bin/sh if it's hopeless.
- * Don't leave garbage behind if the output is an empty pipe.
- * Clean up after SIGXCPU or SIGXFSZ. Print name of signal that caused cleanup.
- *
- * Revision 4.6 89/05/01 15:13:40 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.5 88/11/08 16:01:02 narten
- * corrected use of varargs routines
- *
- * Revision 4.4 88/08/09 19:13:24 eggert
- * Check for memory exhaustion.
- * Permit signal handlers to yield either 'void' or 'int'; fix oldSIGINT botch.
- * Use execv(), not system(); yield exit status like diff(1)'s.
- *
- * Revision 4.3 87/10/18 10:40:22 narten
- * Updating version numbers. Changes relative to 1.1 actually
- * relative to 4.1
- *
- * Revision 1.3 87/09/24 14:01:01 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:43 jenkins
- * Port to suns
- *
- * Revision 4.1 83/05/10 15:53:13 wft
- * Added getcaller() and findlock().
- * Changed catchints() to check SIGINT for SIG_IGN before setting up the signal
- * (needed for background jobs in older shells). Added restoreints().
- * Removed printing of full RCS path from logcommand().
- *
- * Revision 3.8 83/02/15 15:41:49 wft
- * Added routine fastcopy() to copy remainder of a file in blocks.
- *
- * Revision 3.7 82/12/24 15:25:19 wft
- * added catchints(), ignoreints() for catching and ingnoring interrupts;
- * fixed catchsig().
- *
- * Revision 3.6 82/12/08 21:52:05 wft
- * Using DATEFORM to format dates.
- *
- * Revision 3.5 82/12/04 18:20:49 wft
- * Replaced SNOOPDIR with SNOOPFILE; changed addlock() to update
- * lockedby-field.
- *
- * Revision 3.4 82/12/03 17:17:43 wft
- * Added check to addlock() ensuring only one lock per person.
- * Addlock also returns a pointer to the lock created. Deleted fancydate().
- *
- * Revision 3.3 82/11/27 12:24:37 wft
- * moved rmsema(), trysema(), trydiraccess(), getfullRCSname() to rcsfnms.c.
- * Introduced macro SNOOP so that snoop can be placed in directory other than
- * TARGETDIR. Changed %02d to %.2d for compatibility reasons.
- *
- * Revision 3.2 82/10/18 21:15:11 wft
- * added function getfullRCSname().
- *
- * Revision 3.1 82/10/13 16:17:37 wft
- * Cleanup message is now suppressed in quiet mode.
- */
-
-
-
-
-#include "rcsbase.h"
-
-libId(utilId, "$Id: rcsutil.c,v 1.6 1997/02/22 15:47:43 peter Exp $")
-
-#if !has_memcmp
- int
-memcmp(s1, s2, n)
- void const *s1, *s2;
- size_t n;
-{
- register unsigned char const
- *p1 = (unsigned char const*)s1,
- *p2 = (unsigned char const*)s2;
- register size_t i = n;
- register int r = 0;
- while (i-- && !(r = (*p1++ - *p2++)))
- ;
- return r;
-}
-#endif
-
-#if !has_memcpy
- void *
-memcpy(s1, s2, n)
- void *s1;
- void const *s2;
- size_t n;
-{
- register char *p1 = (char*)s1;
- register char const *p2 = (char const*)s2;
- while (n--)
- *p1++ = *p2++;
- return s1;
-}
-#endif
-
-#if RCS_lint
- malloc_type lintalloc;
-#endif
-
-/*
- * list of blocks allocated with ftestalloc()
- * These blocks can be freed by ffree when we're done with the current file.
- * We could put the free block inside struct alloclist, rather than a pointer
- * to the free block, but that would be less portable.
- */
-struct alloclist {
- malloc_type alloc;
- struct alloclist *nextalloc;
-};
-static struct alloclist *alloced;
-
-
- static malloc_type okalloc P((malloc_type));
- static malloc_type
-okalloc(p)
- malloc_type p;
-{
- if (!p)
- faterror("out of memory");
- return p;
-}
-
- malloc_type
-testalloc(size)
- size_t size;
-/* Allocate a block, testing that the allocation succeeded. */
-{
- return okalloc(malloc(size));
-}
-
- malloc_type
-testrealloc(ptr, size)
- malloc_type ptr;
- size_t size;
-/* Reallocate a block, testing that the allocation succeeded. */
-{
- return okalloc(realloc(ptr, size));
-}
-
- malloc_type
-fremember(ptr)
- malloc_type ptr;
-/* Remember PTR in 'alloced' so that it can be freed later. Yield PTR. */
-{
- register struct alloclist *q = talloc(struct alloclist);
- q->nextalloc = alloced;
- alloced = q;
- return q->alloc = ptr;
-}
-
- malloc_type
-ftestalloc(size)
- size_t size;
-/* Allocate a block, putting it in 'alloced' so it can be freed later. */
-{
- return fremember(testalloc(size));
-}
-
- void
-ffree()
-/* Free all blocks allocated with ftestalloc(). */
-{
- register struct alloclist *p, *q;
- for (p = alloced; p; p = q) {
- q = p->nextalloc;
- tfree(p->alloc);
- tfree(p);
- }
- alloced = 0;
-}
-
- void
-ffree1(f)
- register char const *f;
-/* Free the block f, which was allocated by ftestalloc. */
-{
- register struct alloclist *p, **a = &alloced;
-
- while ((p = *a)->alloc != f)
- a = &p->nextalloc;
- *a = p->nextalloc;
- tfree(p->alloc);
- tfree(p);
-}
-
- char *
-str_save(s)
- char const *s;
-/* Save s in permanently allocated storage. */
-{
- return strcpy(tnalloc(char, strlen(s)+1), s);
-}
-
- char *
-fstr_save(s)
- char const *s;
-/* Save s in storage that will be deallocated when we're done with this file. */
-{
- return strcpy(ftnalloc(char, strlen(s)+1), s);
-}
-
- char *
-cgetenv(name)
- char const *name;
-/* Like getenv(), but yield a copy; getenv() can overwrite old results. */
-{
- register char *p;
-
- return (p=getenv(name)) ? str_save(p) : p;
-}
-
- char const *
-getusername(suspicious)
- int suspicious;
-/* Get the caller's login name. Trust only getwpuid if SUSPICIOUS. */
-{
- static char *name;
-
- if (!name) {
- if (
- /* Prefer getenv() unless suspicious; it's much faster. */
-# if getlogin_is_secure
- (suspicious
- || (
- !(name = cgetenv("LOGNAME"))
- && !(name = cgetenv("USER"))
- ))
- && !(name = getlogin())
-# else
- suspicious
- || (
- !(name = cgetenv("LOGNAME"))
- && !(name = cgetenv("USER"))
- && !(name = getlogin())
- )
-# endif
- ) {
-#if has_getuid && has_getpwuid
- struct passwd const *pw = getpwuid(ruid());
- if (!pw)
- faterror("no password entry for userid %lu",
- (unsigned long)ruid()
- );
- name = pw->pw_name;
-#else
-#if has_setuid
- faterror("setuid not supported");
-#else
- faterror("Who are you? Please setenv LOGNAME.");
-#endif
-#endif
- }
- checksid(name);
- }
- return name;
-}
-
-
-
-
-#if has_signal
-
-/*
- * Signal handling
- *
- * Standard C places too many restrictions on signal handlers.
- * We obey as many of them as we can.
- * Posix places fewer restrictions, and we are Posix-compatible here.
- */
-
-static sig_atomic_t volatile heldsignal, holdlevel;
-#ifdef SA_SIGINFO
- static int unsupported_SA_SIGINFO;
- static siginfo_t bufsiginfo;
- static siginfo_t *volatile heldsiginfo;
-#endif
-
-
-#if has_NFS && has_mmap && large_memory && mmap_signal
- static char const *accessName;
-
- void
- readAccessFilenameBuffer(filename, p)
- char const *filename;
- unsigned char const *p;
- {
- unsigned char volatile t;
- accessName = filename;
- t = *p;
- accessName = 0;
- }
-#else
-# define accessName ((char const *) 0)
-#endif
-
-
-#if !has_psignal
-
-# define psignal my_psignal
- static void my_psignal P((int,char const*));
- static void
-my_psignal(sig, s)
- int sig;
- char const *s;
-{
- char const *sname = "Unknown signal";
-# if has_sys_siglist && defined(NSIG)
- if ((unsigned)sig < NSIG)
- sname = sys_siglist[sig];
-# else
- switch (sig) {
-# ifdef SIGHUP
- case SIGHUP: sname = "Hangup"; break;
-# endif
-# ifdef SIGINT
- case SIGINT: sname = "Interrupt"; break;
-# endif
-# ifdef SIGPIPE
- case SIGPIPE: sname = "Broken pipe"; break;
-# endif
-# ifdef SIGQUIT
- case SIGQUIT: sname = "Quit"; break;
-# endif
-# ifdef SIGTERM
- case SIGTERM: sname = "Terminated"; break;
-# endif
-# ifdef SIGXCPU
- case SIGXCPU: sname = "Cputime limit exceeded"; break;
-# endif
-# ifdef SIGXFSZ
- case SIGXFSZ: sname = "Filesize limit exceeded"; break;
-# endif
-# if has_mmap && large_memory
-# if defined(SIGBUS) && mmap_signal==SIGBUS
- case SIGBUS: sname = "Bus error"; break;
-# endif
-# if defined(SIGSEGV) && mmap_signal==SIGSEGV
- case SIGSEGV: sname = "Segmentation fault"; break;
-# endif
-# endif
- }
-# endif
-
- /* Avoid calling sprintf etc., in case they're not reentrant. */
- {
- char const *p;
- char buf[BUFSIZ], *b = buf;
- for (p = s; *p; *b++ = *p++)
- continue;
- *b++ = ':';
- *b++ = ' ';
- for (p = sname; *p; *b++ = *p++)
- continue;
- *b++ = '\n';
- VOID write(STDERR_FILENO, buf, b - buf);
- }
-}
-#endif
-
-static signal_type catchsig P((int));
-#ifdef SA_SIGINFO
- static signal_type catchsigaction P((int,siginfo_t*,void*));
-#endif
-
- static signal_type
-catchsig(s)
- int s;
-#ifdef SA_SIGINFO
-{
- catchsigaction(s, (siginfo_t *)0, (void *)0);
-}
- static signal_type
-catchsigaction(s, i, c)
- int s;
- siginfo_t *i;
- void *c;
-#endif
-{
-# if sig_zaps_handler
- /* If a signal arrives before we reset the handler, we lose. */
- VOID signal(s, SIG_IGN);
-# endif
-
-# ifdef SA_SIGINFO
- if (!unsupported_SA_SIGINFO)
- i = 0;
-# endif
-
- if (holdlevel) {
- heldsignal = s;
-# ifdef SA_SIGINFO
- if (i) {
- bufsiginfo = *i;
- heldsiginfo = &bufsiginfo;
- }
-# endif
- return;
- }
-
- ignoreints();
- setrid();
- if (!quietflag) {
- /* Avoid calling sprintf etc., in case they're not reentrant. */
- char const *p;
- char buf[BUFSIZ], *b = buf;
-
- if ( ! (
-# if has_mmap && large_memory && mmap_signal
- /* Check whether this signal was planned. */
- s == mmap_signal && accessName
-# else
- 0
-# endif
- )) {
- char const *nRCS = "\nRCS";
-# if defined(SA_SIGINFO) && has_si_errno && has_mmap && large_memory && mmap_signal
- if (s == mmap_signal && i && i->si_errno) {
- errno = i->si_errno;
- perror(nRCS++);
- }
-# endif
-# if defined(SA_SIGINFO) && has_psiginfo
- if (i)
- psiginfo(i, nRCS);
- else
- psignal(s, nRCS);
-# else
- psignal(s, nRCS);
-# endif
- }
-
- for (p = "RCS: "; *p; *b++ = *p++)
- continue;
-# if has_mmap && large_memory && mmap_signal
- if (s == mmap_signal) {
- p = accessName;
- if (!p)
- p = "Was a file changed by some other process? ";
- else {
- char const *p1;
- for (p1 = p; *p1; p1++)
- continue;
- VOID write(STDERR_FILENO, buf, b - buf);
- VOID write(STDERR_FILENO, p, p1 - p);
- b = buf;
- p = ": Permission denied. ";
- }
- while (*p)
- *b++ = *p++;
- }
-# endif
- for (p = "Cleaning up.\n"; *p; *b++ = *p++)
- continue;
- VOID write(STDERR_FILENO, buf, b - buf);
- }
- exiterr();
-}
-
- void
-ignoreints()
-{
- ++holdlevel;
-}
-
- void
-restoreints()
-{
- if (!--holdlevel && heldsignal)
-# ifdef SA_SIGINFO
- VOID catchsigaction(heldsignal, heldsiginfo, (void *)0);
-# else
- VOID catchsig(heldsignal);
-# endif
-}
-
-
-static void setup_catchsig P((int const*,int));
-
-#if has_sigaction
-
- static void check_sig P((int));
- static void
- check_sig(r)
- int r;
- {
- if (r != 0)
- efaterror("signal handling");
- }
-
- static void
- setup_catchsig(sig, sigs)
- int const *sig;
- int sigs;
- {
- register int i, j;
- struct sigaction act;
-
- for (i=sigs; 0<=--i; ) {
- check_sig(sigaction(sig[i], (struct sigaction*)0, &act));
- if (act.sa_handler != SIG_IGN) {
- act.sa_handler = catchsig;
-# ifdef SA_SIGINFO
- if (!unsupported_SA_SIGINFO) {
-# if has_sa_sigaction
- act.sa_sigaction = catchsigaction;
-# else
- act.sa_handler = catchsigaction;
-# endif
- act.sa_flags |= SA_SIGINFO;
- }
-# endif
- for (j=sigs; 0<=--j; )
- check_sig(sigaddset(&act.sa_mask, sig[j]));
- if (sigaction(sig[i], &act, (struct sigaction*)0) != 0) {
-# if defined(SA_SIGINFO) && defined(ENOTSUP)
- if (errno == ENOTSUP && !unsupported_SA_SIGINFO) {
- /* Turn off use of SA_SIGINFO and try again. */
- unsupported_SA_SIGINFO = 1;
- i++;
- continue;
- }
-# endif
- check_sig(-1);
- }
- }
- }
- }
-
-#else
-#if has_sigblock
-
- static void
- setup_catchsig(sig, sigs)
- int const *sig;
- int sigs;
- {
- register int i;
- int mask;
-
- mask = 0;
- for (i=sigs; 0<=--i; )
- mask |= sigmask(sig[i]);
- mask = sigblock(mask);
- for (i=sigs; 0<=--i; )
- if (
- signal(sig[i], catchsig) == SIG_IGN &&
- signal(sig[i], SIG_IGN) != catchsig
- )
- faterror("signal catcher failure");
- VOID sigsetmask(mask);
- }
-
-#else
-
- static void
- setup_catchsig(sig, sigs)
- int const *sig;
- int sigs;
- {
- register i;
-
- for (i=sigs; 0<=--i; )
- if (
- signal(sig[i], SIG_IGN) != SIG_IGN &&
- signal(sig[i], catchsig) != SIG_IGN
- )
- faterror("signal catcher failure");
- }
-
-#endif
-#endif
-
-
-static int const regsigs[] = {
-# ifdef SIGHUP
- SIGHUP,
-# endif
-# ifdef SIGINT
- SIGINT,
-# endif
-# ifdef SIGPIPE
- SIGPIPE,
-# endif
-# ifdef SIGQUIT
- SIGQUIT,
-# endif
-# ifdef SIGTERM
- SIGTERM,
-# endif
-# ifdef SIGXCPU
- SIGXCPU,
-# endif
-# ifdef SIGXFSZ
- SIGXFSZ,
-# endif
-};
-
- void
-catchints()
-{
- static int catching_ints;
- if (!catching_ints) {
- catching_ints = true;
- setup_catchsig(regsigs, (int) (sizeof(regsigs)/sizeof(*regsigs)));
- }
-}
-
-#if has_mmap && large_memory && mmap_signal
-
- /*
- * If you mmap an NFS file, and someone on another client removes the last
- * link to that file, and you later reference an uncached part of that file,
- * you'll get a SIGBUS or SIGSEGV (depending on the operating system).
- * Catch the signal and report the problem to the user.
- * Unfortunately, there's no portable way to differentiate between this
- * problem and actual bugs in the program.
- * This NFS problem is rare, thank goodness.
- *
- * This can also occur if someone truncates the file, even without NFS.
- */
-
- static int const mmapsigs[] = { mmap_signal };
-
- void
- catchmmapints()
- {
- static int catching_mmap_ints;
- if (!catching_mmap_ints) {
- catching_mmap_ints = true;
- setup_catchsig(mmapsigs, (int)(sizeof(mmapsigs)/sizeof(*mmapsigs)));
- }
- }
-#endif
-
-#endif /* has_signal */
-
-
- void
-fastcopy(inf,outf)
- register RILE *inf;
- FILE *outf;
-/* Function: copies the remainder of file inf to outf.
- */
-{
-#if large_memory
-# if maps_memory
- awrite((char const*)inf->ptr, (size_t)(inf->lim - inf->ptr), outf);
- inf->ptr = inf->lim;
-# else
- for (;;) {
- awrite((char const*)inf->ptr, (size_t)(inf->readlim - inf->ptr), outf);
- inf->ptr = inf->readlim;
- if (inf->ptr == inf->lim)
- break;
- VOID Igetmore(inf);
- }
-# endif
-#else
- char buf[BUFSIZ*8];
- register fread_type rcount;
-
- /*now read the rest of the file in blocks*/
- while (!feof(inf)) {
- if (!(rcount = Fread(buf,sizeof(*buf),sizeof(buf),inf))) {
- testIerror(inf);
- return;
- }
- awrite(buf, (size_t)rcount, outf);
- }
-#endif
-}
-
-#ifndef SSIZE_MAX
- /* This does not work in #ifs, but it's good enough for us. */
- /* Underestimating SSIZE_MAX may slow us down, but it won't break us. */
-# define SSIZE_MAX ((unsigned)-1 >> 1)
-#endif
-
- void
-awrite(buf, chars, f)
- char const *buf;
- size_t chars;
- FILE *f;
-{
- /* Posix 1003.1-1990 ssize_t hack */
- while (SSIZE_MAX < chars) {
- if (Fwrite(buf, sizeof(*buf), SSIZE_MAX, f) != SSIZE_MAX)
- Oerror();
- buf += SSIZE_MAX;
- chars -= SSIZE_MAX;
- }
-
- if (Fwrite(buf, sizeof(*buf), chars, f) != chars)
- Oerror();
-}
-
-/* dup a file descriptor; the result must not be stdin, stdout, or stderr. */
- static int dupSafer P((int));
- static int
-dupSafer(fd)
- int fd;
-{
-# ifdef F_DUPFD
- return fcntl(fd, F_DUPFD, STDERR_FILENO + 1);
-# else
- int e, f, i, used = 0;
- while (STDIN_FILENO <= (f = dup(fd)) && f <= STDERR_FILENO)
- used |= 1<<f;
- e = errno;
- for (i = STDIN_FILENO; i <= STDERR_FILENO; i++)
- if (used & (1<<i))
- VOID close(i);
- errno = e;
- return f;
-# endif
-}
-
-/* Renumber a file descriptor so that it's not stdin, stdout, or stderr. */
- int
-fdSafer(fd)
- int fd;
-{
- if (STDIN_FILENO <= fd && fd <= STDERR_FILENO) {
- int f = dupSafer(fd);
- int e = errno;
- VOID close(fd);
- errno = e;
- fd = f;
- }
- return fd;
-}
-
-/* Like fopen, except the result is never stdin, stdout, or stderr. */
- FILE *
-fopenSafer(filename, type)
- char const *filename;
- char const *type;
-{
- FILE *stream = fopen(filename, type);
- if (stream) {
- int fd = fileno(stream);
- if (STDIN_FILENO <= fd && fd <= STDERR_FILENO) {
- int f = dupSafer(fd);
- if (f < 0) {
- int e = errno;
- VOID fclose(stream);
- errno = e;
- return 0;
- }
- if (fclose(stream) != 0) {
- int e = errno;
- VOID close(f);
- errno = e;
- return 0;
- }
- stream = fdopen(f, type);
- }
- }
- return stream;
-}
-
-
-#ifdef F_DUPFD
-# undef dup
-# define dup(fd) fcntl(fd, F_DUPFD, 0)
-#endif
-
-
-#if has_fork || has_spawn
-
- static int movefd P((int,int));
- static int
-movefd(old, new)
- int old, new;
-{
- if (old < 0 || old == new)
- return old;
-# ifdef F_DUPFD
- new = fcntl(old, F_DUPFD, new);
-# else
- new = dup2(old, new);
-# endif
- return close(old)==0 ? new : -1;
-}
-
- static int fdreopen P((int,char const*,int));
- static int
-fdreopen(fd, file, flags)
- int fd;
- char const *file;
- int flags;
-{
- int newfd;
- VOID close(fd);
- newfd =
-#if !open_can_creat
- flags&O_CREAT ? creat(file, S_IRUSR|S_IWUSR) :
-#endif
- open(file, flags, S_IRUSR|S_IWUSR);
- return movefd(newfd, fd);
-}
-
-#if has_spawn
- static void redirect P((int,int));
- static void
-redirect(old, new)
- int old, new;
-/*
-* Move file descriptor OLD to NEW.
-* If OLD is -1, do nothing.
-* If OLD is -2, just close NEW.
-*/
-{
- if ((old != -1 && close(new) != 0) || (0 <= old && movefd(old,new) < 0))
- efaterror("spawn I/O redirection");
-}
-#endif
-
-
-#else /* !has_fork && !has_spawn */
-
- static void bufargcat P((struct buf*,int,char const*));
- static void
-bufargcat(b, c, s)
- register struct buf *b;
- int c;
- register char const *s;
-/* Append to B a copy of C, plus a quoted copy of S. */
-{
- register char *p;
- register char const *t;
- size_t bl, sl;
-
- for (t=s, sl=0; *t; )
- sl += 3*(*t++=='\'') + 1;
- bl = strlen(b->string);
- bufrealloc(b, bl + sl + 4);
- p = b->string + bl;
- *p++ = c;
- *p++ = '\'';
- while (*s) {
- if (*s == '\'') {
- *p++ = '\'';
- *p++ = '\\';
- *p++ = '\'';
- }
- *p++ = *s++;
- }
- *p++ = '\'';
- *p = 0;
-}
-
-#endif
-
-#if !has_spawn && has_fork
-/*
-* Output the string S to stderr, without touching any I/O buffers.
-* This is useful if you are a child process, whose buffers are usually wrong.
-* Exit immediately if the write does not completely succeed.
-*/
-static void write_stderr P((char const *));
- static void
-write_stderr(s)
- char const *s;
-{
- size_t slen = strlen(s);
- if (write(STDERR_FILENO, s, slen) != slen)
- _exit(EXIT_TROUBLE);
-}
-#endif
-
-/*
-* Run a command.
-* infd, if not -1, is the input file descriptor.
-* outname, if nonzero, is the name of the output file.
-* args[1..] form the command to be run; args[0] might be modified.
-*/
- int
-runv(infd, outname, args)
- int infd;
- char const *outname, **args;
-{
- int wstatus;
-
-#if bad_wait_if_SIGCHLD_ignored
- static int fixed_SIGCHLD;
- if (!fixed_SIGCHLD) {
- fixed_SIGCHLD = true;
-# ifndef SIGCHLD
-# define SIGCHLD SIGCLD
-# endif
- VOID signal(SIGCHLD, SIG_DFL);
- }
-#endif
-
- oflush();
- eflush();
- {
-#if has_spawn
- int in, out;
- char const *file;
-
- in = -1;
- if (infd != -1 && infd != STDIN_FILENO) {
- if ((in = dup(STDIN_FILENO)) < 0) {
- if (errno != EBADF)
- efaterror("spawn input setup");
- in = -2;
- } else {
-# ifdef F_DUPFD
- if (close(STDIN_FILENO) != 0)
- efaterror("spawn input close");
-# endif
- }
- if (
-# ifdef F_DUPFD
- fcntl(infd, F_DUPFD, STDIN_FILENO) != STDIN_FILENO
-# else
- dup2(infd, STDIN_FILENO) != STDIN_FILENO
-# endif
- )
- efaterror("spawn input redirection");
- }
-
- out = -1;
- if (outname) {
- if ((out = dup(STDOUT_FILENO)) < 0) {
- if (errno != EBADF)
- efaterror("spawn output setup");
- out = -2;
- }
- if (fdreopen(
- STDOUT_FILENO, outname,
- O_CREAT | O_TRUNC | O_WRONLY
- ) < 0)
- efaterror(outname);
- }
-
- wstatus = spawn_RCS(0, args[1], (char**)(args + 1));
-# ifdef RCS_SHELL
- if (wstatus == -1 && errno == ENOEXEC) {
- args[0] = RCS_SHELL;
- wstatus = spawnv(0, args[0], (char**)args);
- }
-# endif
- redirect(in, STDIN_FILENO);
- redirect(out, STDOUT_FILENO);
-#else
-#if has_fork
- pid_t pid;
- if (!(pid = vfork())) {
- char const *notfound;
- if (infd != -1 && infd != STDIN_FILENO && (
-# ifdef F_DUPFD
- (VOID close(STDIN_FILENO),
- fcntl(infd, F_DUPFD, STDIN_FILENO) != STDIN_FILENO)
-# else
- dup2(infd, STDIN_FILENO) != STDIN_FILENO
-# endif
- )) {
- /* Avoid perror since it may misuse buffers. */
- write_stderr(args[1]);
- write_stderr(": I/O redirection failed\n");
- _exit(EXIT_TROUBLE);
- }
-
- if (outname)
- if (fdreopen(
- STDOUT_FILENO, outname,
- O_CREAT | O_TRUNC | O_WRONLY
- ) < 0) {
- /* Avoid perror since it may misuse buffers. */
- write_stderr(args[1]);
- write_stderr(": ");
- write_stderr(outname);
- write_stderr(": cannot create\n");
- _exit(EXIT_TROUBLE);
- }
- VOID exec_RCS(args[1], (char**)(args + 1));
- notfound = args[1];
-# ifdef RCS_SHELL
- if (errno == ENOEXEC) {
- args[0] = notfound = RCS_SHELL;
- VOID execv(args[0], (char**)args);
- }
-# endif
-
- /* Avoid perror since it may misuse buffers. */
- write_stderr(notfound);
- write_stderr(": not found\n");
- _exit(EXIT_TROUBLE);
- }
- if (pid < 0)
- efaterror("fork");
-# if has_waitpid
- if (waitpid(pid, &wstatus, 0) < 0)
- efaterror("waitpid");
-# else
- {
- pid_t w;
- do {
- if ((w = wait(&wstatus)) < 0)
- efaterror("wait");
- } while (w != pid);
- }
-# endif
-#else
- static struct buf b;
- char const *p;
-
- /* Use system(). On many hosts system() discards signals. Yuck! */
- p = args + 1;
- bufscpy(&b, *p);
- while (*++p)
- bufargcat(&b, ' ', *p);
- if (infd != -1 && infd != STDIN_FILENO) {
- char redirection[32];
- VOID sprintf(redirection, "<&%d", infd);
- bufscat(&b, redirection);
- }
- if (outname)
- bufargcat(&b, '>', outname);
- wstatus = system(b.string);
-#endif
-#endif
- }
- if (!WIFEXITED(wstatus)) {
- if (WIFSIGNALED(wstatus)) {
- psignal(WTERMSIG(wstatus), args[1]);
- fatcleanup(1);
- }
- faterror("%s failed for unknown reason", args[1]);
- }
- return WEXITSTATUS(wstatus);
-}
-
-#define CARGSMAX 20
-/*
-* Run a command.
-* infd, if not -1, is the input file descriptor.
-* outname, if nonzero, is the name of the output file.
-* The remaining arguments specify the command and its arguments.
-*/
- int
-#if has_prototypes
-run(int infd, char const *outname, ...)
-#else
- /*VARARGS2*/
-run(infd, outname, va_alist)
- int infd;
- char const *outname;
- va_dcl
-#endif
-{
- va_list ap;
- char const *rgargs[CARGSMAX];
- register int i;
- vararg_start(ap, outname);
- for (i = 1; (rgargs[i++] = va_arg(ap, char const*)); )
- if (CARGSMAX <= i)
- faterror("too many command arguments");
- va_end(ap);
- return runv(infd, outname, rgargs);
-}
-
-
-int RCSversion;
-
- void
-setRCSversion(str)
- char const *str;
-{
- static int oldversion;
-
- register char const *s = str + 2;
-
- if (*s) {
- int v = VERSION_DEFAULT;
-
- if (oldversion)
- redefined('V');
- oldversion = true;
- v = 0;
- while (isdigit(*s))
- v = 10*v + *s++ - '0';
- if (*s)
- error("%s isn't a number", str);
- else if (v < VERSION_min || VERSION_max < v)
- error("%s out of range %d..%d",
- str, VERSION_min, VERSION_max
- );
-
- RCSversion = VERSION(v);
- } else {
- printf("RCS version %s\n", RCS_version_string);
- exit(0);
- }
-}
-
- int
-getRCSINIT(argc, argv, newargv)
- int argc;
- char **argv, ***newargv;
-{
- register char *p, *q, **pp;
- char const *ev;
- size_t n;
-
- if ((ev = cgetenv("RCSLOCALID")))
- setRCSLocalId(ev);
-
- if ((ev = cgetenv("RCSINCEXC")))
- setIncExc(ev);
-
- if (!(q = cgetenv("RCSINIT")))
- *newargv = argv;
- else {
- n = argc + 2;
- /*
- * Count spaces in RCSINIT to allocate a new arg vector.
- * This is an upper bound, but it's OK even if too large.
- */
- for (p = q; ; ) {
- switch (*p++) {
- default:
- continue;
-
- case ' ':
- case '\b': case '\f': case '\n':
- case '\r': case '\t': case '\v':
- n++;
- continue;
-
- case '\0':
- break;
- }
- break;
- }
- *newargv = pp = tnalloc(char*, n);
- *pp++ = *argv++; /* copy program name */
- for (p = q; ; ) {
- for (;;) {
- switch (*q) {
- case '\0':
- goto copyrest;
-
- case ' ':
- case '\b': case '\f': case '\n':
- case '\r': case '\t': case '\v':
- q++;
- continue;
- }
- break;
- }
- *pp++ = p;
- ++argc;
- for (;;) {
- switch ((*p++ = *q++)) {
- case '\0':
- goto copyrest;
-
- case '\\':
- if (!*q)
- goto copyrest;
- p[-1] = *q++;
- continue;
-
- default:
- continue;
-
- case ' ':
- case '\b': case '\f': case '\n':
- case '\r': case '\t': case '\v':
- break;
- }
- break;
- }
- p[-1] = '\0';
- }
- copyrest:
- while ((*pp++ = *argv++))
- continue;
- }
- return argc;
-}
-
-
-#define cacheid(E) static uid_t i; static int s; if (!s){ s=1; i=(E); } return i
-
-#if has_getuid
- uid_t ruid() { cacheid(getuid()); }
-#endif
-#if has_setuid
- uid_t euid() { cacheid(geteuid()); }
-#endif
-
-
-#if has_setuid
-
-/*
- * Setuid execution really works only with Posix 1003.1a Draft 5 seteuid(),
- * because it lets us switch back and forth between arbitrary users.
- * If seteuid() doesn't work, we fall back on setuid(),
- * which works if saved setuid is supported,
- * unless the real or effective user is root.
- * This area is such a mess that we always check switches at runtime.
- */
-
- static void
-#if has_prototypes
-set_uid_to(uid_t u)
-#else
- set_uid_to(u) uid_t u;
-#endif
-/* Become user u. */
-{
- static int looping;
-
- if (euid() == ruid())
- return;
-#if (has_fork||has_spawn) && DIFF_ABSOLUTE
-# if has_setreuid
- if (setreuid(u==euid() ? ruid() : euid(), u) != 0)
- efaterror("setuid");
-# else
- if (seteuid(u) != 0)
- efaterror("setuid");
-# endif
-#endif
- if (geteuid() != u) {
- if (looping)
- return;
- looping = true;
- faterror("root setuid not supported" + (u?5:0));
- }
-}
-
-static int stick_with_euid;
-
- void
-/* Ignore all calls to seteid() and setrid(). */
-nosetid()
-{
- stick_with_euid = true;
-}
-
- void
-seteid()
-/* Become effective user. */
-{
- if (!stick_with_euid)
- set_uid_to(euid());
-}
-
- void
-setrid()
-/* Become real user. */
-{
- if (!stick_with_euid)
- set_uid_to(ruid());
-}
-#endif
-
- time_t
-now()
-{
- static time_t t;
- if (!t && time(&t) == -1)
- efaterror("time");
- return t;
-}
diff --git a/gnu/usr.bin/rcs/lib/version.c b/gnu/usr.bin/rcs/lib/version.c
deleted file mode 100644
index 81f5585..0000000
--- a/gnu/usr.bin/rcs/lib/version.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "rcsbase.h"
-char const RCS_version_string[] = "5.7";
diff --git a/gnu/usr.bin/rcs/merge/Makefile b/gnu/usr.bin/rcs/merge/Makefile
deleted file mode 100644
index 9022bc4..0000000
--- a/gnu/usr.bin/rcs/merge/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG= merge
-SRCS= merge.c
-CFLAGS+= -I${.CURDIR}/../lib
-LDADD= ${LIBRCS}
-DPADD= ${LIBRCS}
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/rcs/merge/merge.1 b/gnu/usr.bin/rcs/merge/merge.1
deleted file mode 100644
index 73ae65c..0000000
--- a/gnu/usr.bin/rcs/merge/merge.1
+++ /dev/null
@@ -1,137 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: merge.1,v 1.4 1997/02/22 15:47:50 peter Exp $
-.ds r \&\s-1RCS\s0
-.TH MERGE 1 \*(Dt GNU
-.SH NAME
-merge \- three-way file merge
-.SH SYNOPSIS
-.B merge
-[
-.I "options"
-]
-.I "file1 file2 file3"
-.SH DESCRIPTION
-.B merge
-incorporates all changes that lead from
-.I file2
-to
-.I file3
-into
-.IR file1 .
-The result ordinarily goes into
-.IR file1 .
-.B merge
-is useful for combining separate changes to an original. Suppose
-.I file2
-is the original, and both
-.I file1
-and
-.I file3
-are modifications of
-.IR file2 .
-Then
-.B merge
-combines both changes.
-.PP
-A conflict occurs if both
-.I file1
-and
-.I file3
-have changes in a common segment of lines.
-If a conflict is found,
-.B merge
-normally outputs a warning and brackets the conflict with
-.B <<<<<<<
-and
-.B >>>>>>>
-lines.
-A typical conflict will look like this:
-.LP
-.RS
-.nf
-.BI <<<<<<< " file A"
-.I "lines in file A"
-.B "======="
-.I "lines in file B"
-.BI >>>>>>> " file B"
-.RE
-.fi
-.LP
-If there are conflicts, the user should edit the result and delete one of the
-alternatives.
-.SH OPTIONS
-.TP
-.B \-A
-Output conflicts using the
-.B \-A
-style of
-.BR diff3 (1),
-if supported by
-.BR diff3 .
-This merges all changes leading from
-.I file2
-to
-.I file3
-into
-.IR file1 ,
-and generates the most verbose output.
-.TP
-\f3\-E\fP, \f3\-e\fP
-These options specify conflict styles that generate less information
-than
-.BR \-A .
-See
-.BR diff3 (1)
-for details.
-The default is
-.BR \-E .
-With
-.BR \-e ,
-.B merge
-does not warn about conflicts.
-.TP
-.BI \-L " label"
-This option may be given up to three times, and specifies labels
-to be used in place of the corresponding file names in conflict reports.
-That is,
-.B "merge\ \-L\ x\ \-L\ y\ \-L\ z\ a\ b\ c"
-generates output that looks like it came from files
-.BR x ,
-.B y
-and
-.B z
-instead of from files
-.BR a ,
-.B b
-and
-.BR c .
-.TP
-.BI \-p
-Send results to standard output instead of overwriting
-.IR file1 .
-.TP
-.BI \-q
-Quiet; do not warn about conflicts.
-.TP
-.BI \-V
-Print \*r's version number.
-.SH DIAGNOSTICS
-Exit status is 0 for no conflicts, 1 for some conflicts, 2 for trouble.
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert.
-.SH SEE ALSO
-diff3(1), diff(1), rcsmerge(1), co(1).
-.SH BUGS
-It normally does not make sense to merge binary files as if they were text, but
-.B merge
-tries to do it anyway.
-.br
diff --git a/gnu/usr.bin/rcs/merge/merge.c b/gnu/usr.bin/rcs/merge/merge.c
deleted file mode 100644
index fabd622..0000000
--- a/gnu/usr.bin/rcs/merge/merge.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* merge - three-way file merge */
-
-/* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#include "rcsbase.h"
-
-static void badoption P((char const*));
-
-static char const usage[] =
- "\nmerge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2 file3";
-
- static void
-badoption(a)
- char const *a;
-{
- error("unknown option: %s%s", a, usage);
-}
-
-
-mainProg(mergeId, "merge", "$Id$")
-{
- register char const *a;
- char const *arg[3], *label[3], *edarg = 0;
- int labels, tostdout;
-
- labels = 0;
- tostdout = false;
-
- for (; (a = *++argv) && *a++ == '-'; --argc) {
- switch (*a++) {
- case 'A': case 'E': case 'e':
- if (edarg && edarg[1] != (*argv)[1])
- error("%s and %s are incompatible",
- edarg, *argv
- );
- edarg = *argv;
- break;
-
- case 'p': tostdout = true; break;
- case 'q': quietflag = true; break;
-
- case 'L':
- if (3 <= labels)
- faterror("too many -L options");
- if (!(label[labels++] = *++argv))
- faterror("-L needs following argument");
- --argc;
- break;
-
- case 'V':
- printf("RCS version %s\n", RCS_version_string);
- exitmain(0);
-
- default:
- badoption(a - 2);
- continue;
- }
- if (*a)
- badoption(a - 2);
- }
-
- if (argc != 4)
- faterror("%s arguments%s",
- argc<4 ? "not enough" : "too many", usage
- );
-
- /* This copy keeps us `const'-clean. */
- arg[0] = argv[0];
- arg[1] = argv[1];
- arg[2] = argv[2];
-
- for (; labels < 3; labels++)
- label[labels] = arg[labels];
-
- if (nerror)
- exiterr();
- exitmain(merge(tostdout, edarg, label, arg));
-}
-
-
-#if RCS_lint
-# define exiterr mergeExit
-#endif
- void
-exiterr()
-{
- tempunlink();
- _exit(DIFF_TROUBLE);
-}
diff --git a/gnu/usr.bin/rcs/rcs/Makefile b/gnu/usr.bin/rcs/rcs/Makefile
deleted file mode 100644
index 344ab6e..0000000
--- a/gnu/usr.bin/rcs/rcs/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-PROG= rcs
-SRCS= rcs.c
-CFLAGS+= -I${.CURDIR}/../lib
-LDADD= ${LIBRCS}
-DPADD= ${LIBRCS}
-
-MAN1= rcs.1 rcsintro.1
-MAN5= rcsfile.5
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/rcs/rcs/rcs.1 b/gnu/usr.bin/rcs/rcs/rcs.1
deleted file mode 100644
index 97dec20..0000000
--- a/gnu/usr.bin/rcs/rcs/rcs.1
+++ /dev/null
@@ -1,454 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id$
-.ds r \&\s-1RCS\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.if !\n(.g \{\
-. if !\w|\*(lq| \{\
-. ds lq ``
-. if \w'\(lq' .ds lq "\(lq
-. \}
-. if !\w|\*(rq| \{\
-. ds rq ''
-. if \w'\(rq' .ds rq "\(rq
-. \}
-.\}
-.TH RCS 1 \*(Dt GNU
-.SH NAME
-rcs \- change RCS file attributes
-.SH SYNOPSIS
-.B rcs
-.IR "options file " .\|.\|.
-.SH DESCRIPTION
-.B rcs
-creates new \*r files or changes attributes of existing ones.
-An \*r file contains multiple revisions of text,
-an access list, a change log,
-descriptive text,
-and some control attributes.
-For
-.B rcs
-to work, the caller's login name must be on the access list,
-except if the access list is empty, the caller is the owner of the file
-or the superuser, or
-the
-.B \-i
-option is present.
-.PP
-Pathnames matching an \*r suffix denote \*r files;
-all others denote working files.
-Names are paired as explained in
-.BR ci (1).
-Revision numbers use the syntax described in
-.BR ci (1).
-.SH OPTIONS
-.TP
-.B \-i
-Create and initialize a new \*r file, but do not deposit any revision.
-If the \*r file has no path prefix, try to place it
-first into the subdirectory
-.BR ./RCS ,
-and then into the current directory.
-If the \*r file
-already exists, print an error message.
-.TP
-.BI \-a "logins"
-Append the login names appearing in the comma-separated list
-.I logins
-to the access list of the \*r file.
-.TP
-.BI \-A "oldfile"
-Append the access list of
-.I oldfile
-to the access list of the \*r file.
-.TP
-.BR \-e [\f2logins\fP]
-Erase the login names appearing in the comma-separated list
-.I logins
-from the access list of the \*r file.
-If
-.I logins
-is omitted, erase the entire access list.
-.TP
-.BR \-b [\f2rev\fP]
-Set the default branch to
-.IR rev .
-If
-.I rev
-is omitted, the default
-branch is reset to the (dynamically) highest branch on the trunk.
-.TP
-.BI \-c string
-Set the comment leader to
-.IR string .
-An initial
-.BR ci ,
-or an
-.B "rcs\ \-i"
-without
-.BR \-c ,
-guesses the comment leader from the suffix of the working filename.
-.RS
-.PP
-This option is obsolescent, since \*r normally uses the preceding
-.B $\&Log$
-line's prefix when inserting log lines during checkout (see
-.BR co (1)).
-However, older versions of \*r use the comment leader instead of the
-.B $\&Log$
-line's prefix, so
-if you plan to access a file with both old and new versions of \*r,
-make sure its comment leader matches its
-.B $\&Log$
-line prefix.
-.RE
-.TP
-.BI \-k subst
-Set the default keyword substitution to
-.IR subst .
-The effect of keyword substitution is described in
-.BR co (1).
-Giving an explicit
-.B \-k
-option to
-.BR co ,
-.BR rcsdiff ,
-and
-.B rcsmerge
-overrides this default.
-Beware
-.BR "rcs\ \-kv",
-because
-.B \-kv
-is incompatible with
-.BR "co\ \-l".
-Use
-.B "rcs\ \-kkv"
-to restore the normal default keyword substitution.
-.TP
-.BR \-l [\f2rev\fP]
-Lock the revision with number
-.IR rev .
-If a branch is given, lock the latest revision on that branch.
-If
-.I rev
-is omitted, lock the latest revision on the default branch.
-Locking prevents overlapping changes.
-If someone else already holds the lock, the lock is broken as with
-.B "rcs\ \-u"
-(see below).
-.TP
-.BR \-u [\f2rev\fP]
-Unlock the revision with number
-.IR rev .
-If a branch is given, unlock the latest revision on that branch.
-If
-.I rev
-is omitted, remove the latest lock held by the caller.
-Normally, only the locker of a revision can unlock it.
-Somebody else unlocking a revision breaks the lock.
-This causes a mail message to be sent to the original locker.
-The message contains a commentary solicited from the breaker.
-The commentary is terminated by end-of-file or by a line containing
-.BR \&. "\ by"
-itself.
-.TP
-.B \-L
-Set locking to
-.IR strict .
-Strict locking means that the owner
-of an \*r file is not exempt from locking for checkin.
-This option should be used for files that are shared.
-.TP
-.B \-U
-Set locking to non-strict. Non-strict locking means that the owner of
-a file need not lock a revision for checkin.
-This option should
-.I not
-be used for files that are shared.
-Whether default locking is strict is determined by your system administrator,
-but it is normally strict.
-.TP
-\f3\-m\fP\f2rev\fP\f3:\fP\f2msg\fP
-Replace revision
-.IR rev 's
-log message with
-.IR msg .
-.TP
-.B \-M
-Do not send mail when breaking somebody else's lock.
-This option is not meant for casual use;
-it is meant for programs that warn users by other means, and invoke
-.B "rcs\ \-u"
-only as a low-level lock-breaking operation.
-.TP
-\f3\-n\fP\f2name\fP[\f3:\fP[\f2rev\fP]]
-Associate the symbolic name
-.I name
-with the branch or
-revision
-.IR rev .
-Delete the symbolic name if both
-.B :
-and
-.I rev
-are omitted; otherwise, print an error message if
-.I name
-is already associated with
-another number.
-If
-.I rev
-is symbolic, it is expanded before association.
-A
-.I rev
-consisting of a branch number followed by a
-.B .\&
-stands for the current latest revision in the branch.
-A
-.B :
-with an empty
-.I rev
-stands for the current latest revision on the default branch,
-normally the trunk.
-For example,
-.BI "rcs\ \-n" name ":\ RCS/*"
-associates
-.I name
-with the current latest revision of all the named \*r files;
-this contrasts with
-.BI "rcs\ \-n" name ":$\ RCS/*"
-which associates
-.I name
-with the revision numbers extracted from keyword strings
-in the corresponding working files.
-.TP
-\f3\-N\fP\f2name\fP[\f3:\fP[\f2rev\fP]]
-Act like
-.BR \-n ,
-except override any previous assignment of
-.IR name .
-.TP
-.BI \-o range
-deletes (\*(lqoutdates\*(rq) the revisions given by
-.IR range .
-A range consisting of a single revision number means that revision.
-A range consisting of a branch number means the latest revision on that
-branch.
-A range of the form
-.IB rev1 : rev2
-means
-revisions
-.I rev1
-to
-.I rev2
-on the same branch,
-.BI : rev
-means from the beginning of the branch containing
-.I rev
-up to and including
-.IR rev ,
-and
-.IB rev :
-means
-from revision
-.I rev
-to the end of the branch containing
-.IR rev .
-None of the outdated revisions can have branches or locks.
-.TP
-.B \-q
-Run quietly; do not print diagnostics.
-.TP
-.B \-I
-Run interactively, even if the standard input is not a terminal.
-.TP
-.B \-s\f2state\fP\f1[\fP:\f2rev\fP\f1]\fP
-Set the state attribute of the revision
-.I rev
-to
-.IR state .
-If
-.I rev
-is a branch number, assume the latest revision on that branch.
-If
-.I rev
-is omitted, assume the latest revision on the default branch.
-Any identifier is acceptable for
-.IR state .
-A useful set of states
-is
-.B Exp
-(for experimental),
-.B Stab
-(for stable), and
-.B Rel
-(for
-released).
-By default,
-.BR ci (1)
-sets the state of a revision to
-.BR Exp .
-.TP
-.BR \-t [\f2file\fP]
-Write descriptive text from the contents of the named
-.I file
-into the \*r file, deleting the existing text.
-The
-.IR file
-pathname cannot begin with
-.BR \- .
-If
-.I file
-is omitted, obtain the text from standard input,
-terminated by end-of-file or by a line containing
-.BR \&. "\ by"
-itself.
-Prompt for the text if interaction is possible; see
-.BR \-I .
-With
-.BR \-i ,
-descriptive text is obtained
-even if
-.B \-t
-is not given.
-.TP
-.BI \-t\- string
-Write descriptive text from the
-.I string
-into the \*r file, deleting the existing text.
-.TP
-.B \-T
-Preserve the modification time on the \*r file
-unless a revision is removed.
-This option can suppress extensive recompilation caused by a
-.BR make (1)
-dependency of some copy of the working file on the \*r file.
-Use this option with care; it can suppress recompilation even when it is needed,
-i.e. when a change to the \*r file
-would mean a change to keyword strings in the working file.
-.TP
-.BI \-V
-Print \*r's version number.
-.TP
-.BI \-V n
-Emulate \*r version
-.IR n .
-See
-.BR co (1)
-for details.
-.TP
-.BI \-x "suffixes"
-Use
-.I suffixes
-to characterize \*r files.
-See
-.BR ci (1)
-for details.
-.TP
-.BI \-z zone
-Use
-.I zone
-as the default time zone.
-This option has no effect;
-it is present for compatibility with other \*r commands.
-.PP
-At least one explicit option must be given,
-to ensure compatibility with future planned extensions
-to the
-.B rcs
-command.
-.SH COMPATIBILITY
-The
-.BI \-b rev
-option generates an \*r file that cannot be parsed by \*r version 3 or earlier.
-.PP
-The
-.BI \-k subst
-options (except
-.BR \-kkv )
-generate an \*r file that cannot be parsed by \*r version 4 or earlier.
-.PP
-Use
-.BI "rcs \-V" n
-to make an \*r file acceptable to \*r version
-.I n
-by discarding information that would confuse version
-.IR n .
-.PP
-\*r version 5.5 and earlier does not support the
-.B \-x
-option, and requires a
-.B ,v
-suffix on an \*r pathname.
-.SH FILES
-.B rcs
-accesses files much as
-.BR ci (1)
-does,
-except that it uses the effective user for all accesses,
-it does not write the working file or its directory,
-and it does not even read the working file unless a revision number of
-.B $
-is specified.
-.SH ENVIRONMENT
-.TP
-.B \s-1RCSINIT\s0
-options prepended to the argument list, separated by spaces.
-See
-.BR ci (1)
-for details.
-.SH DIAGNOSTICS
-The \*r pathname and the revisions outdated are written to
-the diagnostic output.
-The exit status is zero if and only if all operations were successful.
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert.
-.SH "SEE ALSO"
-rcsintro(1), co(1), ci(1), ident(1), rcsclean(1), rcsdiff(1),
-rcsmerge(1), rlog(1), rcsfile(5)
-.br
-Walter F. Tichy,
-\*r\*-A System for Version Control,
-.I "Software\*-Practice & Experience"
-.BR 15 ,
-7 (July 1985), 637-654.
-.SH BUGS
-A catastrophe (e.g. a system crash) can cause \*r to leave behind
-a semaphore file that causes later invocations of \*r to claim
-that the \*r file is in use.
-To fix this, remove the semaphore file.
-A semaphore file's name typically begins with
-.B ,
-or ends with
-.BR _ .
-.PP
-The separator for revision ranges in the
-.B \-o
-option used to be
-.B \-
-instead of
-.BR : ,
-but this leads to confusion when symbolic names contain
-.BR \- .
-For backwards compatibility
-.B "rcs \-o"
-still supports the old
-.B \-
-separator, but it warns about this obsolete use.
-.PP
-Symbolic names need not refer to existing revisions or branches.
-For example, the
-.B \-o
-option does not remove symbolic names for the outdated revisions; you must use
-.B \-n
-to remove the names.
-.br
diff --git a/gnu/usr.bin/rcs/rcs/rcs.c b/gnu/usr.bin/rcs/rcs/rcs.c
deleted file mode 100644
index b46bdf4..0000000
--- a/gnu/usr.bin/rcs/rcs/rcs.c
+++ /dev/null
@@ -1,1629 +0,0 @@
-/* Change RCS file attributes. */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.21 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.20 1995/06/01 16:23:43 eggert
- * (main): Warn if no options were given. Punctuate messages properly.
- *
- * (sendmail): Rewind mailmess before flushing it.
- * Output another warning if mail should work but fails.
- *
- * (buildeltatext): Pass "--binary" if -kb and if --binary makes a difference.
- *
- * Revision 5.19 1994/03/17 14:05:48 eggert
- * Use ORCSerror to clean up after a fatal error. Remove lint.
- * Specify subprocess input via file descriptor, not file name. Remove lint.
- * Flush stderr after prompt.
- *
- * Revision 5.18 1993/11/09 17:40:15 eggert
- * -V now prints version on stdout and exits. Don't print usage twice.
- *
- * Revision 5.17 1993/11/03 17:42:27 eggert
- * Add -z. Don't lose track of -m or -t when there are no other changes.
- * Don't discard ignored phrases. Improve quality of diagnostics.
- *
- * Revision 5.16 1992/07/28 16:12:44 eggert
- * rcs -l now asks whether you want to break the lock.
- * Add -V. Set RCS file's mode and time at right moment.
- *
- * Revision 5.15 1992/02/17 23:02:20 eggert
- * Add -T.
- *
- * Revision 5.14 1992/01/27 16:42:53 eggert
- * Add -M. Avoid invoking umask(); it's one less thing to configure.
- * Add support for bad_creat0. lint -> RCS_lint
- *
- * Revision 5.13 1992/01/06 02:42:34 eggert
- * Avoid changing RCS file in common cases where no change can occur.
- *
- * Revision 5.12 1991/11/20 17:58:08 eggert
- * Don't read the delta tree from a nonexistent RCS file.
- *
- * Revision 5.11 1991/10/07 17:32:46 eggert
- * Remove lint.
- *
- * Revision 5.10 1991/08/19 23:17:54 eggert
- * Add -m, -r$, piece tables. Revision separator is `:', not `-'. Tune.
- *
- * Revision 5.9 1991/04/21 11:58:18 eggert
- * Add -x, RCSINIT, MS-DOS support.
- *
- * Revision 5.8 1991/02/25 07:12:38 eggert
- * strsave -> str_save (DG/UX name clash)
- * 0444 -> S_IRUSR|S_IRGRP|S_IROTH for portability
- *
- * Revision 5.7 1990/12/18 17:19:21 eggert
- * Fix bug with multiple -n and -N options.
- *
- * Revision 5.6 1990/12/04 05:18:40 eggert
- * Use -I for prompts and -q for diagnostics.
- *
- * Revision 5.5 1990/11/11 00:06:35 eggert
- * Fix `rcs -e' core dump.
- *
- * Revision 5.4 1990/11/01 05:03:33 eggert
- * Add -I and new -t behavior. Permit arbitrary data in logs.
- *
- * Revision 5.3 1990/10/04 06:30:16 eggert
- * Accumulate exit status across files.
- *
- * Revision 5.2 1990/09/04 08:02:17 eggert
- * Standardize yes-or-no procedure.
- *
- * Revision 5.1 1990/08/29 07:13:51 eggert
- * Remove unused setuid support. Clean old log messages too.
- *
- * Revision 5.0 1990/08/22 08:12:42 eggert
- * Don't lose names when applying -a option to multiple files.
- * Remove compile-time limits; use malloc instead. Add setuid support.
- * Permit dates past 1999/12/31. Make lock and temp files faster and safer.
- * Ansify and Posixate. Add -V. Fix umask bug. Make linting easier. Tune.
- * Yield proper exit status. Check diff's output.
- *
- * Revision 4.11 89/05/01 15:12:06 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.10 88/11/08 16:01:54 narten
- * didn't install previous patch correctly
- *
- * Revision 4.9 88/11/08 13:56:01 narten
- * removed include <sysexits.h> (not needed)
- * minor fix for -A option
- *
- * Revision 4.8 88/08/09 19:12:27 eggert
- * Don't access freed storage.
- * Use execv(), not system(); yield proper exit status; remove lint.
- *
- * Revision 4.7 87/12/18 11:37:17 narten
- * lint cleanups (Guy Harris)
- *
- * Revision 4.6 87/10/18 10:28:48 narten
- * Updating verison numbers. Changes relative to 1.1 are actually
- * relative to 4.3
- *
- * Revision 1.4 87/09/24 13:58:52 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.3 87/03/27 14:21:55 jenkins
- * Port to suns
- *
- * Revision 1.2 85/12/17 13:59:09 albitz
- * Changed setstate to rcs_setstate because of conflict with random.o.
- *
- * Revision 4.3 83/12/15 12:27:33 wft
- * rcs -u now breaks most recent lock if it can't find a lock by the caller.
- *
- * Revision 4.2 83/12/05 10:18:20 wft
- * Added conditional compilation for sending mail.
- * Alternatives: V4_2BSD, V6, USG, and other.
- *
- * Revision 4.1 83/05/10 16:43:02 wft
- * Simplified breaklock(); added calls to findlock() and getcaller().
- * Added option -b (default branch). Updated -s and -w for -b.
- * Removed calls to stat(); now done by pairfilenames().
- * Replaced most catchints() calls with restoreints().
- * Removed check for exit status of delivermail().
- * Directed all interactive output to stderr.
- *
- * Revision 3.9.1.1 83/12/02 22:08:51 wft
- * Added conditional compilation for 4.2 sendmail and 4.1 delivermail.
- *
- * Revision 3.9 83/02/15 15:38:39 wft
- * Added call to fastcopy() to copy remainder of RCS file.
- *
- * Revision 3.8 83/01/18 17:37:51 wft
- * Changed sendmail(): now uses delivermail, and asks whether to break the lock.
- *
- * Revision 3.7 83/01/15 18:04:25 wft
- * Removed putree(); replaced with puttree() in rcssyn.c.
- * Combined putdellog() and scanlogtext(); deleted putdellog().
- * Cleaned up diagnostics and error messages. Fixed problem with
- * mutilated files in case of deletions in 2 files in a single command.
- * Changed marking of selector from 'D' to DELETE.
- *
- * Revision 3.6 83/01/14 15:37:31 wft
- * Added ignoring of interrupts while new RCS file is renamed;
- * Avoids deletion of RCS files by interrupts.
- *
- * Revision 3.5 82/12/10 21:11:39 wft
- * Removed unused variables, fixed checking of return code from diff,
- * introduced variant COMPAT2 for skipping Suffix on -A files.
- *
- * Revision 3.4 82/12/04 13:18:20 wft
- * Replaced getdelta() with gettree(), changed breaklock to update
- * field lockedby, added some diagnostics.
- *
- * Revision 3.3 82/12/03 17:08:04 wft
- * Replaced getlogin() with getpwuid(), flcose() with ffclose(),
- * /usr/ucb/Mail with macro MAIL. Removed handling of Suffix (-x).
- * fixed -u for missing revno. Disambiguated structure members.
- *
- * Revision 3.2 82/10/18 21:05:07 wft
- * rcs -i now generates a file mode given by the umask minus write permission;
- * otherwise, rcs keeps the mode, but removes write permission.
- * I added a check for write error, fixed call to getlogin(), replaced
- * curdir() with getfullRCSname(), cleaned up handling -U/L, and changed
- * conflicting, long identifiers.
- *
- * Revision 3.1 82/10/13 16:11:07 wft
- * fixed type of variables receiving from getc() (char -> int).
- */
-
-
-#include "rcsbase.h"
-
-struct Lockrev {
- char const *revno;
- struct Lockrev * nextrev;
-};
-
-struct Symrev {
- char const *revno;
- char const *ssymbol;
- int override;
- struct Symrev * nextsym;
-};
-
-struct Message {
- char const *revno;
- struct cbuf message;
- struct Message *nextmessage;
-};
-
-struct Status {
- char const *revno;
- char const *status;
- struct Status * nextstatus;
-};
-
-enum changeaccess {append, erase};
-struct chaccess {
- char const *login;
- enum changeaccess command;
- struct chaccess *nextchaccess;
-};
-
-struct delrevpair {
- char const *strt;
- char const *end;
- int code;
-};
-
-static int branchpoint P((struct hshentry*,struct hshentry*));
-static int breaklock P((struct hshentry const*));
-static int buildeltatext P((struct hshentries const*));
-static int doaccess P((void));
-static int doassoc P((void));
-static int dolocks P((void));
-static int domessages P((void));
-static int rcs_setstate P((char const*,char const*));
-static int removerevs P((void));
-static int sendmail P((char const*,char const*));
-static int setlock P((char const*));
-static struct Lockrev **rmnewlocklst P((char const*));
-static struct hshentry *searchcutpt P((char const*,int,struct hshentries*));
-static void buildtree P((void));
-static void cleanup P((void));
-static void getaccessor P((char*,enum changeaccess));
-static void getassoclst P((int,char*));
-static void getchaccess P((char const*,enum changeaccess));
-static void getdelrev P((char*));
-static void getmessage P((char*));
-static void getstates P((char*));
-static void scanlogtext P((struct hshentry*,int));
-
-static struct buf numrev;
-static char const *headstate;
-static int chgheadstate, exitstatus, lockhead, unlockcaller;
-static int suppress_mail;
-static struct Lockrev *newlocklst, *rmvlocklst;
-static struct Message *messagelst, **nextmessage;
-static struct Status *statelst, **nextstate;
-static struct Symrev *assoclst, **nextassoc;
-static struct chaccess *chaccess, **nextchaccess;
-static struct delrevpair delrev;
-static struct hshentry *cuthead, *cuttail, *delstrt;
-static struct hshentries *gendeltas;
-
-mainProg(rcsId, "rcs", "$Id$")
-{
- static char const cmdusage[] =
- "\nrcs usage: rcs -{ae}logins -Afile -{blu}[rev] -cstring -{iILqTU} -ksubst -mrev:msg -{nN}name[:[rev]] -orange -sstate[:rev] -t[text] -Vn -xsuff -zzone file ...";
-
- char *a, **newargv, *textfile;
- char const *branchsym, *commsyml;
- int branchflag, changed, expmode, initflag;
- int strictlock, strict_selected, textflag;
- int keepRCStime, Ttimeflag;
- size_t commsymlen;
- struct buf branchnum;
- struct Lockrev *lockpt;
- struct Lockrev **curlock, **rmvlock;
- struct Status * curstate;
-
- nosetid();
-
- nextassoc = &assoclst;
- nextchaccess = &chaccess;
- nextmessage = &messagelst;
- nextstate = &statelst;
- branchsym = commsyml = textfile = 0;
- branchflag = strictlock = false;
- bufautobegin(&branchnum);
- commsymlen = 0;
- curlock = &newlocklst;
- rmvlock = &rmvlocklst;
- expmode = -1;
- suffixes = X_DEFAULT;
- initflag= textflag = false;
- strict_selected = 0;
- Ttimeflag = false;
-
- /* preprocessing command options */
- if (1 < argc && argv[1][0] != '-')
- warn("No options were given; this usage is obsolescent.");
-
- argc = getRCSINIT(argc, argv, &newargv);
- argv = newargv;
- while (a = *++argv, 0<--argc && *a++=='-') {
- switch (*a++) {
-
- case 'i': /* initial version */
- initflag = true;
- break;
-
- case 'b': /* change default branch */
- if (branchflag) redefined('b');
- branchflag= true;
- branchsym = a;
- break;
-
- case 'c': /* change comment symbol */
- if (commsyml) redefined('c');
- commsyml = a;
- commsymlen = strlen(a);
- break;
-
- case 'a': /* add new accessor */
- getaccessor(*argv+1, append);
- break;
-
- case 'A': /* append access list according to accessfile */
- if (!*a) {
- error("missing pathname after -A");
- break;
- }
- *argv = a;
- if (0 < pairnames(1,argv,rcsreadopen,true,false)) {
- while (AccessList) {
- getchaccess(str_save(AccessList->login),append);
- AccessList = AccessList->nextaccess;
- }
- Izclose(&finptr);
- }
- break;
-
- case 'e': /* remove accessors */
- getaccessor(*argv+1, erase);
- break;
-
- case 'l': /* lock a revision if it is unlocked */
- if (!*a) {
- /* Lock head or default branch. */
- lockhead = true;
- break;
- }
- *curlock = lockpt = talloc(struct Lockrev);
- lockpt->revno = a;
- lockpt->nextrev = 0;
- curlock = &lockpt->nextrev;
- break;
-
- case 'u': /* release lock of a locked revision */
- if (!*a) {
- unlockcaller=true;
- break;
- }
- *rmvlock = lockpt = talloc(struct Lockrev);
- lockpt->revno = a;
- lockpt->nextrev = 0;
- rmvlock = &lockpt->nextrev;
- curlock = rmnewlocklst(lockpt->revno);
- break;
-
- case 'L': /* set strict locking */
- if (strict_selected) {
- if (!strictlock) /* Already selected -U? */
- warn("-U overridden by -L");
- }
- strictlock = true;
- strict_selected = true;
- break;
-
- case 'U': /* release strict locking */
- if (strict_selected) {
- if (strictlock) /* Already selected -L? */
- warn("-L overridden by -U");
- }
- strict_selected = true;
- break;
-
- case 'n': /* add new association: error, if name exists */
- if (!*a) {
- error("missing symbolic name after -n");
- break;
- }
- getassoclst(false, (*argv)+1);
- break;
-
- case 'N': /* add or change association */
- if (!*a) {
- error("missing symbolic name after -N");
- break;
- }
- getassoclst(true, (*argv)+1);
- break;
-
- case 'm': /* change log message */
- getmessage(a);
- break;
-
- case 'M': /* do not send mail */
- suppress_mail = true;
- break;
-
- case 'o': /* delete revisions */
- if (delrev.strt) redefined('o');
- if (!*a) {
- error("missing revision range after -o");
- break;
- }
- getdelrev( (*argv)+1 );
- break;
-
- case 's': /* change state attribute of a revision */
- if (!*a) {
- error("state missing after -s");
- break;
- }
- getstates( (*argv)+1);
- break;
-
- case 't': /* change descriptive text */
- textflag=true;
- if (*a) {
- if (textfile) redefined('t');
- textfile = a;
- }
- break;
-
- case 'T': /* do not update last-mod time for minor changes */
- if (*a)
- goto unknown;
- Ttimeflag = true;
- break;
-
- case 'I':
- interactiveflag = true;
- break;
-
- case 'q':
- quietflag = true;
- break;
-
- case 'x':
- suffixes = a;
- break;
-
- case 'V':
- setRCSversion(*argv);
- break;
-
- case 'z':
- zone_set(a);
- break;
-
- case 'k': /* set keyword expand mode */
- if (0 <= expmode) redefined('k');
- if (0 <= (expmode = str2expmode(a)))
- break;
- /* fall into */
- default:
- unknown:
- error("unknown option: %s%s", *argv, cmdusage);
- };
- } /* end processing of options */
-
- /* Now handle all pathnames. */
- if (nerror) cleanup();
- else if (argc < 1) faterror("no input file%s", cmdusage);
- else for (; 0 < argc; cleanup(), ++argv, --argc) {
-
- ffree();
-
- if ( initflag ) {
- switch (pairnames(argc, argv, rcswriteopen, false, false)) {
- case -1: break; /* not exist; ok */
- case 0: continue; /* error */
- case 1: rcserror("already exists");
- continue;
- }
- }
- else {
- switch (pairnames(argc, argv, rcswriteopen, true, false)) {
- case -1: continue; /* not exist */
- case 0: continue; /* errors */
- case 1: break; /* file exists; ok*/
- }
- }
-
-
- /*
- * RCSname contains the name of the RCS file, and
- * workname contains the name of the working file.
- * if !initflag, finptr contains the file descriptor for the
- * RCS file. The admin node is initialized.
- */
-
- diagnose("RCS file: %s\n", RCSname);
-
- changed = initflag | textflag;
- keepRCStime = Ttimeflag;
- if (!initflag) {
- if (!checkaccesslist()) continue;
- gettree(); /* Read the delta tree. */
- }
-
- /* update admin. node */
- if (strict_selected) {
- changed |= StrictLocks ^ strictlock;
- StrictLocks = strictlock;
- }
- if (
- commsyml &&
- (
- commsymlen != Comment.size ||
- memcmp(commsyml, Comment.string, commsymlen) != 0
- )
- ) {
- Comment.string = commsyml;
- Comment.size = strlen(commsyml);
- changed = true;
- }
- if (0 <= expmode && Expand != expmode) {
- Expand = expmode;
- changed = true;
- }
-
- /* update default branch */
- if (branchflag && expandsym(branchsym, &branchnum)) {
- if (countnumflds(branchnum.string)) {
- if (cmpnum(Dbranch, branchnum.string) != 0) {
- Dbranch = branchnum.string;
- changed = true;
- }
- } else
- if (Dbranch) {
- Dbranch = 0;
- changed = true;
- }
- }
-
- changed |= doaccess(); /* Update access list. */
-
- changed |= doassoc(); /* Update association list. */
-
- changed |= dolocks(); /* Update locks. */
-
- changed |= domessages(); /* Update log messages. */
-
- /* update state attribution */
- if (chgheadstate) {
- /* change state of default branch or head */
- if (!Dbranch) {
- if (!Head)
- rcswarn("can't change states in an empty tree");
- else if (strcmp(Head->state, headstate) != 0) {
- Head->state = headstate;
- changed = true;
- }
- } else
- changed |= rcs_setstate(Dbranch,headstate);
- }
- for (curstate = statelst; curstate; curstate = curstate->nextstatus)
- changed |= rcs_setstate(curstate->revno,curstate->status);
-
- cuthead = cuttail = 0;
- if (delrev.strt && removerevs()) {
- /* rebuild delta tree if some deltas are deleted */
- if ( cuttail )
- VOID genrevs(
- cuttail->num, (char *)0, (char *)0, (char *)0,
- &gendeltas
- );
- buildtree();
- changed = true;
- keepRCStime = false;
- }
-
- if (nerror)
- continue;
-
- putadmin();
- if ( Head )
- puttree(Head, frewrite);
- putdesc(textflag,textfile);
-
- if ( Head) {
- if (delrev.strt || messagelst) {
- if (!cuttail || buildeltatext(gendeltas)) {
- advise_access(finptr, MADV_SEQUENTIAL);
- scanlogtext((struct hshentry *)0, false);
- /* copy rest of delta text nodes that are not deleted */
- changed = true;
- }
- }
- }
-
- if (initflag) {
- /* Adjust things for donerewrite's sake. */
- if (stat(workname, &RCSstat) != 0) {
-# if bad_creat0
- mode_t m = umask(0);
- (void) umask(m);
- RCSstat.st_mode = (S_IRUSR|S_IRGRP|S_IROTH) & ~m;
-# else
- changed = -1;
-# endif
- }
- RCSstat.st_nlink = 0;
- keepRCStime = false;
- }
- if (donerewrite(changed,
- keepRCStime ? RCSstat.st_mtime : (time_t)-1
- ) != 0)
- break;
-
- diagnose("done\n");
- }
-
- tempunlink();
- exitmain(exitstatus);
-} /* end of main (rcs) */
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = EXIT_FAILURE;
- Izclose(&finptr);
- Ozclose(&fcopy);
- ORCSclose();
- dirtempunlink();
-}
-
- void
-exiterr()
-{
- ORCSerror();
- dirtempunlink();
- tempunlink();
- _exit(EXIT_FAILURE);
-}
-
-
- static void
-getassoclst(flag, sp)
-int flag;
-char * sp;
-/* Function: associate a symbolic name to a revision or branch, */
-/* and store in assoclst */
-
-{
- struct Symrev * pt;
- char const *temp;
- int c;
-
- while ((c = *++sp) == ' ' || c == '\t' || c =='\n')
- continue;
- temp = sp;
- sp = checksym(sp, ':'); /* check for invalid symbolic name */
- c = *sp; *sp = '\0';
- while( c == ' ' || c == '\t' || c == '\n') c = *++sp;
-
- if ( c != ':' && c != '\0') {
- error("invalid string %s after option -n or -N",sp);
- return;
- }
-
- pt = talloc(struct Symrev);
- pt->ssymbol = temp;
- pt->override = flag;
- if (c == '\0') /* delete symbol */
- pt->revno = 0;
- else {
- while ((c = *++sp) == ' ' || c == '\n' || c == '\t')
- continue;
- pt->revno = sp;
- }
- pt->nextsym = 0;
- *nextassoc = pt;
- nextassoc = &pt->nextsym;
-}
-
-
- static void
-getchaccess(login, command)
- char const *login;
- enum changeaccess command;
-{
- register struct chaccess *pt;
-
- pt = talloc(struct chaccess);
- pt->login = login;
- pt->command = command;
- pt->nextchaccess = 0;
- *nextchaccess = pt;
- nextchaccess = &pt->nextchaccess;
-}
-
-
-
- static void
-getaccessor(opt, command)
- char *opt;
- enum changeaccess command;
-/* Function: get the accessor list of options -e and -a, */
-/* and store in chaccess */
-
-
-{
- register c;
- register char *sp;
-
- sp = opt;
- while ((c = *++sp) == ' ' || c == '\n' || c == '\t' || c == ',')
- continue;
- if ( c == '\0') {
- if (command == erase && sp-opt == 1) {
- getchaccess((char*)0, command);
- return;
- }
- error("missing login name after option -a or -e");
- return;
- }
-
- while( c != '\0') {
- getchaccess(sp, command);
- sp = checkid(sp,',');
- c = *sp; *sp = '\0';
- while( c == ' ' || c == '\n' || c == '\t'|| c == ',')c =(*++sp);
- }
-}
-
-
- static void
-getmessage(option)
- char *option;
-{
- struct Message *pt;
- struct cbuf cb;
- char *m;
-
- if (!(m = strchr(option, ':'))) {
- error("-m option lacks revision number");
- return;
- }
- *m++ = 0;
- cb = cleanlogmsg(m, strlen(m));
- if (!cb.size) {
- error("-m option lacks log message");
- return;
- }
- pt = talloc(struct Message);
- pt->revno = option;
- pt->message = cb;
- pt->nextmessage = 0;
- *nextmessage = pt;
- nextmessage = &pt->nextmessage;
-}
-
-
- static void
-getstates(sp)
-char *sp;
-/* Function: get one state attribute and the corresponding */
-/* revision and store in statelst */
-
-{
- char const *temp;
- struct Status *pt;
- register c;
-
- while ((c = *++sp) ==' ' || c == '\t' || c == '\n')
- continue;
- temp = sp;
- sp = checkid(sp,':'); /* check for invalid state attribute */
- c = *sp; *sp = '\0';
- while( c == ' ' || c == '\t' || c == '\n' ) c = *++sp;
-
- if ( c == '\0' ) { /* change state of def. branch or Head */
- chgheadstate = true;
- headstate = temp;
- return;
- }
- else if ( c != ':' ) {
- error("missing ':' after state in option -s");
- return;
- }
-
- while ((c = *++sp) == ' ' || c == '\t' || c == '\n')
- continue;
- pt = talloc(struct Status);
- pt->status = temp;
- pt->revno = sp;
- pt->nextstatus = 0;
- *nextstate = pt;
- nextstate = &pt->nextstatus;
-}
-
-
-
- static void
-getdelrev(sp)
-char *sp;
-/* Function: get revision range or branch to be deleted, */
-/* and place in delrev */
-{
- int c;
- struct delrevpair *pt;
- int separator;
-
- pt = &delrev;
- while ((c = (*++sp)) == ' ' || c == '\n' || c == '\t')
- continue;
-
- /* Support old ambiguous '-' syntax; this will go away. */
- if (strchr(sp,':'))
- separator = ':';
- else {
- if (strchr(sp,'-') && VERSION(5) <= RCSversion)
- warn("`-' is obsolete in `-o%s'; use `:' instead", sp);
- separator = '-';
- }
-
- if (c == separator) { /* -o:rev */
- while ((c = (*++sp)) == ' ' || c == '\n' || c == '\t')
- continue;
- pt->strt = sp; pt->code = 1;
- while( c != ' ' && c != '\n' && c != '\t' && c != '\0') c =(*++sp);
- *sp = '\0';
- pt->end = 0;
- return;
- }
- else {
- pt->strt = sp;
- while( c != ' ' && c != '\n' && c != '\t' && c != '\0'
- && c != separator ) c = *++sp;
- *sp = '\0';
- while( c == ' ' || c == '\n' || c == '\t' ) c = *++sp;
- if ( c == '\0' ) { /* -o rev or branch */
- pt->code = 0;
- pt->end = 0;
- return;
- }
- if (c != separator) {
- error("invalid range %s %s after -o", pt->strt, sp);
- }
- while ((c = *++sp) == ' ' || c == '\n' || c == '\t')
- continue;
- if (!c) { /* -orev: */
- pt->code = 2;
- pt->end = 0;
- return;
- }
- }
- /* -orev1:rev2 */
- pt->end = sp; pt->code = 3;
- while( c!= ' ' && c != '\n' && c != '\t' && c != '\0') c = *++sp;
- *sp = '\0';
-}
-
-
-
-
- static void
-scanlogtext(delta,edit)
- struct hshentry *delta;
- int edit;
-/* Function: Scans delta text nodes up to and including the one given
- * by delta, or up to last one present, if !delta.
- * For the one given by delta (if delta), the log message is saved into
- * delta->log if delta==cuttail; the text is edited if EDIT is set, else copied.
- * Assumes the initial lexeme must be read in first.
- * Does not advance nexttok after it is finished, except if !delta.
- */
-{
- struct hshentry const *nextdelta;
- struct cbuf cb;
-
- for (;;) {
- foutptr = 0;
- if (eoflex()) {
- if(delta)
- rcsfaterror("can't find delta for revision %s",
- delta->num
- );
- return; /* no more delta text nodes */
- }
- nextlex();
- if (!(nextdelta=getnum()))
- fatserror("delta number corrupted");
- if (nextdelta->selector) {
- foutptr = frewrite;
- aprintf(frewrite,DELNUMFORM,nextdelta->num,Klog);
- }
- getkeystring(Klog);
- if (nextdelta == cuttail) {
- cb = savestring(&curlogbuf);
- if (!delta->log.string)
- delta->log = cleanlogmsg(curlogbuf.string, cb.size);
- nextlex();
- delta->igtext = getphrases(Ktext);
- } else {
- if (nextdelta->log.string && nextdelta->selector) {
- foutptr = 0;
- readstring();
- foutptr = frewrite;
- putstring(foutptr, false, nextdelta->log, true);
- afputc(nextc, foutptr);
- } else
- readstring();
- ignorephrases(Ktext);
- }
- getkeystring(Ktext);
-
- if (delta==nextdelta)
- break;
- readstring(); /* skip over it */
-
- }
- /* got the one we're looking for */
- if (edit)
- editstring((struct hshentry*)0);
- else
- enterstring();
-}
-
-
-
- static struct Lockrev **
-rmnewlocklst(which)
- char const *which;
-/* Remove lock to revision WHICH from newlocklst. */
-{
- struct Lockrev *pt, **pre;
-
- pre = &newlocklst;
- while ((pt = *pre))
- if (strcmp(pt->revno, which) != 0)
- pre = &pt->nextrev;
- else {
- *pre = pt->nextrev;
- tfree(pt);
- }
- return pre;
-}
-
-
-
- static int
-doaccess()
-{
- register struct chaccess *ch;
- register struct access **p, *t;
- register int changed = false;
-
- for (ch = chaccess; ch; ch = ch->nextchaccess) {
- switch (ch->command) {
- case erase:
- if (!ch->login) {
- if (AccessList) {
- AccessList = 0;
- changed = true;
- }
- } else
- for (p = &AccessList; (t = *p); p = &t->nextaccess)
- if (strcmp(ch->login, t->login) == 0) {
- *p = t->nextaccess;
- changed = true;
- break;
- }
- break;
- case append:
- for (p = &AccessList; ; p = &t->nextaccess)
- if (!(t = *p)) {
- *p = t = ftalloc(struct access);
- t->login = ch->login;
- t->nextaccess = 0;
- changed = true;
- break;
- } else if (strcmp(ch->login, t->login) == 0)
- break;
- break;
- }
- }
- return changed;
-}
-
-
- static int
-sendmail(Delta, who)
- char const *Delta, *who;
-/* Function: mail to who, informing him that his lock on delta was
- * broken by caller. Ask first whether to go ahead. Return false on
- * error or if user decides not to break the lock.
- */
-{
-#ifdef SENDMAIL
- char const *messagefile;
- int old1, old2, c, status;
- FILE * mailmess;
-#endif
-
-
- aprintf(stderr, "Revision %s is already locked by %s.\n", Delta, who);
- if (suppress_mail)
- return true;
- if (!yesorno(false, "Do you want to break the lock? [ny](n): "))
- return false;
-
- /* go ahead with breaking */
-#ifdef SENDMAIL
- messagefile = maketemp(0);
- if (!(mailmess = fopenSafer(messagefile, "w+"))) {
- efaterror(messagefile);
- }
-
- aprintf(mailmess, "Subject: Broken lock on %s\n\nYour lock on revision %s of file %s\nhas been broken by %s for the following reason:\n",
- basefilename(RCSname), Delta, getfullRCSname(), getcaller()
- );
- aputs("State the reason for breaking the lock:\n(terminate with single '.' or end of file)\n>> ", stderr);
- eflush();
-
- old1 = '\n'; old2 = ' ';
- for (; ;) {
- c = getcstdin();
- if (feof(stdin)) {
- aprintf(mailmess, "%c\n", old1);
- break;
- }
- else if ( c == '\n' && old1 == '.' && old2 == '\n')
- break;
- else {
- afputc(old1, mailmess);
- old2 = old1; old1 = c;
- if (c == '\n') {
- aputs(">> ", stderr);
- eflush();
- }
- }
- }
- Orewind(mailmess);
- aflush(mailmess);
- status = run(fileno(mailmess), (char*)0, SENDMAIL, who, (char*)0);
- Ozclose(&mailmess);
- if (status == 0)
- return true;
- warn("Mail failed.");
-#endif
- warn("Mail notification of broken locks is not available.");
- warn("Please tell `%s' why you broke the lock.", who);
- return(true);
-}
-
-
-
- static int
-breaklock(delta)
- struct hshentry const *delta;
-/* function: Finds the lock held by caller on delta,
- * and removes it.
- * Sends mail if a lock different from the caller's is broken.
- * Prints an error message if there is no such lock or error.
- */
-{
- register struct rcslock *next, **trail;
- char const *num;
-
- num=delta->num;
- for (trail = &Locks; (next = *trail); trail = &next->nextlock)
- if (strcmp(num, next->delta->num) == 0) {
- if (
- strcmp(getcaller(),next->login) != 0
- && !sendmail(num, next->login)
- ) {
- rcserror("revision %s still locked by %s",
- num, next->login
- );
- return false;
- }
- diagnose("%s unlocked\n", next->delta->num);
- *trail = next->nextlock;
- next->delta->lockedby = 0;
- return true;
- }
- rcserror("no lock set on revision %s", num);
- return false;
-}
-
-
-
- static struct hshentry *
-searchcutpt(object, length, store)
- char const *object;
- int length;
- struct hshentries *store;
-/* Function: Search store and return entry with number being object. */
-/* cuttail = 0, if the entry is Head; otherwise, cuttail */
-/* is the entry point to the one with number being object */
-
-{
- cuthead = 0;
- while (compartial(store->first->num, object, length)) {
- cuthead = store->first;
- store = store->rest;
- }
- return store->first;
-}
-
-
-
- static int
-branchpoint(strt, tail)
-struct hshentry *strt, *tail;
-/* Function: check whether the deltas between strt and tail */
-/* are locked or branch point, return 1 if any is */
-/* locked or branch point; otherwise, return 0 and */
-/* mark deleted */
-
-{
- struct hshentry *pt;
- struct rcslock const *lockpt;
-
- for (pt = strt; pt != tail; pt = pt->next) {
- if ( pt->branches ){ /* a branch point */
- rcserror("can't remove branch point %s", pt->num);
- return true;
- }
- for (lockpt = Locks; lockpt; lockpt = lockpt->nextlock)
- if (lockpt->delta == pt) {
- rcserror("can't remove locked revision %s", pt->num);
- return true;
- }
- pt->selector = false;
- diagnose("deleting revision %s\n",pt->num);
- }
- return false;
-}
-
-
-
- static int
-removerevs()
-/* Function: get the revision range to be removed, and place the */
-/* first revision removed in delstrt, the revision before */
-/* delstrt in cuthead (0, if delstrt is head), and the */
-/* revision after the last removed revision in cuttail (0 */
-/* if the last is a leaf */
-
-{
- struct hshentry *target, *target2, *temp;
- int length;
- int cmp;
-
- if (!expandsym(delrev.strt, &numrev)) return 0;
- target = genrevs(numrev.string,(char*)0,(char*)0,(char*)0,&gendeltas);
- if ( ! target ) return 0;
- cmp = cmpnum(target->num, numrev.string);
- length = countnumflds(numrev.string);
-
- if (delrev.code == 0) { /* -o rev or -o branch */
- if (length & 1)
- temp=searchcutpt(target->num,length+1,gendeltas);
- else if (cmp) {
- rcserror("Revision %s doesn't exist.", numrev.string);
- return 0;
- }
- else
- temp = searchcutpt(numrev.string, length, gendeltas);
- cuttail = target->next;
- if ( branchpoint(temp, cuttail) ) {
- cuttail = 0;
- return 0;
- }
- delstrt = temp; /* first revision to be removed */
- return 1;
- }
-
- if (length & 1) { /* invalid branch after -o */
- rcserror("invalid branch range %s after -o", numrev.string);
- return 0;
- }
-
- if (delrev.code == 1) { /* -o -rev */
- if ( length > 2 ) {
- temp = searchcutpt( target->num, length-1, gendeltas);
- cuttail = target->next;
- }
- else {
- temp = searchcutpt(target->num, length, gendeltas);
- cuttail = target;
- while( cuttail && ! cmpnumfld(target->num,cuttail->num,1) )
- cuttail = cuttail->next;
- }
- if ( branchpoint(temp, cuttail) ){
- cuttail = 0;
- return 0;
- }
- delstrt = temp;
- return 1;
- }
-
- if (delrev.code == 2) { /* -o rev- */
- if ( length == 2 ) {
- temp = searchcutpt(target->num, 1,gendeltas);
- if (cmp)
- cuttail = target;
- else
- cuttail = target->next;
- }
- else {
- if (cmp) {
- cuthead = target;
- if ( !(temp = target->next) ) return 0;
- }
- else
- temp = searchcutpt(target->num, length, gendeltas);
- getbranchno(temp->num, &numrev); /* get branch number */
- VOID genrevs(numrev.string, (char*)0, (char*)0, (char*)0, &gendeltas);
- }
- if ( branchpoint( temp, cuttail ) ) {
- cuttail = 0;
- return 0;
- }
- delstrt = temp;
- return 1;
- }
-
- /* -o rev1-rev2 */
- if (!expandsym(delrev.end, &numrev)) return 0;
- if (
- length != countnumflds(numrev.string)
- || (length>2 && compartial(numrev.string, target->num, length-1))
- ) {
- rcserror("invalid revision range %s-%s",
- target->num, numrev.string
- );
- return 0;
- }
-
- target2 = genrevs(numrev.string,(char*)0,(char*)0,(char*)0,&gendeltas);
- if ( ! target2 ) return 0;
-
- if ( length > 2) { /* delete revisions on branches */
- if ( cmpnum(target->num, target2->num) > 0) {
- cmp = cmpnum(target2->num, numrev.string);
- temp = target;
- target = target2;
- target2 = temp;
- }
- if (cmp) {
- if ( ! cmpnum(target->num, target2->num) ) {
- rcserror("Revisions %s-%s don't exist.",
- delrev.strt, delrev.end
- );
- return 0;
- }
- cuthead = target;
- temp = target->next;
- }
- else
- temp = searchcutpt(target->num, length, gendeltas);
- cuttail = target2->next;
- }
- else { /* delete revisions on trunk */
- if ( cmpnum( target->num, target2->num) < 0 ) {
- temp = target;
- target = target2;
- target2 = temp;
- }
- else
- cmp = cmpnum(target2->num, numrev.string);
- if (cmp) {
- if ( ! cmpnum(target->num, target2->num) ) {
- rcserror("Revisions %s-%s don't exist.",
- delrev.strt, delrev.end
- );
- return 0;
- }
- cuttail = target2;
- }
- else
- cuttail = target2->next;
- temp = searchcutpt(target->num, length, gendeltas);
- }
- if ( branchpoint(temp, cuttail) ) {
- cuttail = 0;
- return 0;
- }
- delstrt = temp;
- return 1;
-}
-
-
-
- static int
-doassoc()
-/* Add or delete (if !revno) association that is stored in assoclst. */
-{
- char const *p;
- int changed = false;
- struct Symrev const *curassoc;
- struct assoc **pre, *pt;
-
- /* add new associations */
- for (curassoc = assoclst; curassoc; curassoc = curassoc->nextsym) {
- char const *ssymbol = curassoc->ssymbol;
-
- if (!curassoc->revno) { /* delete symbol */
- for (pre = &Symbols; ; pre = &pt->nextassoc)
- if (!(pt = *pre)) {
- rcswarn("can't delete nonexisting symbol %s", ssymbol);
- break;
- } else if (strcmp(pt->symbol, ssymbol) == 0) {
- *pre = pt->nextassoc;
- changed = true;
- break;
- }
- }
- else {
- if (curassoc->revno[0]) {
- p = 0;
- if (expandsym(curassoc->revno, &numrev))
- p = fstr_save(numrev.string);
- } else if (!(p = tiprev()))
- rcserror("no latest revision to associate with symbol %s",
- ssymbol
- );
- if (p)
- changed |= addsymbol(p, ssymbol, curassoc->override);
- }
- }
- return changed;
-}
-
-
-
- static int
-dolocks()
-/* Function: remove lock for caller or first lock if unlockcaller is set;
- * remove locks which are stored in rmvlocklst,
- * add new locks which are stored in newlocklst,
- * add lock for Dbranch or Head if lockhead is set.
- */
-{
- struct Lockrev const *lockpt;
- struct hshentry *target;
- int changed = false;
-
- if (unlockcaller) { /* find lock for caller */
- if ( Head ) {
- if (Locks) {
- switch (findlock(true, &target)) {
- case 0:
- /* remove most recent lock */
- changed |= breaklock(Locks->delta);
- break;
- case 1:
- diagnose("%s unlocked\n",target->num);
- changed = true;
- break;
- }
- } else {
- rcswarn("No locks are set.");
- }
- } else {
- rcswarn("can't unlock an empty tree");
- }
- }
-
- /* remove locks which are stored in rmvlocklst */
- for (lockpt = rmvlocklst; lockpt; lockpt = lockpt->nextrev)
- if (expandsym(lockpt->revno, &numrev)) {
- target = genrevs(numrev.string, (char *)0, (char *)0, (char *)0, &gendeltas);
- if ( target )
- if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string))
- rcserror("can't unlock nonexisting revision %s",
- lockpt->revno
- );
- else
- changed |= breaklock(target);
- /* breaklock does its own diagnose */
- }
-
- /* add new locks which stored in newlocklst */
- for (lockpt = newlocklst; lockpt; lockpt = lockpt->nextrev)
- changed |= setlock(lockpt->revno);
-
- if (lockhead) /* lock default branch or head */
- if (Dbranch)
- changed |= setlock(Dbranch);
- else if (Head)
- changed |= setlock(Head->num);
- else
- rcswarn("can't lock an empty tree");
- return changed;
-}
-
-
-
- static int
-setlock(rev)
- char const *rev;
-/* Function: Given a revision or branch number, finds the corresponding
- * delta and locks it for caller.
- */
-{
- struct hshentry *target;
- int r;
-
- if (expandsym(rev, &numrev)) {
- target = genrevs(numrev.string, (char*)0, (char*)0,
- (char*)0, &gendeltas);
- if ( target )
- if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string))
- rcserror("can't lock nonexisting revision %s",
- numrev.string
- );
- else {
- if ((r = addlock(target, false)) < 0 && breaklock(target))
- r = addlock(target, true);
- if (0 <= r) {
- if (r)
- diagnose("%s locked\n", target->num);
- return r;
- }
- }
- }
- return 0;
-}
-
-
- static int
-domessages()
-{
- struct hshentry *target;
- struct Message *p;
- int changed = false;
-
- for (p = messagelst; p; p = p->nextmessage)
- if (
- expandsym(p->revno, &numrev) &&
- (target = genrevs(
- numrev.string, (char*)0, (char*)0, (char*)0, &gendeltas
- ))
- ) {
- /*
- * We can't check the old log -- it's much later in the file.
- * We pessimistically assume that it changed.
- */
- target->log = p->message;
- changed = true;
- }
- return changed;
-}
-
-
- static int
-rcs_setstate(rev,status)
- char const *rev, *status;
-/* Function: Given a revision or branch number, finds the corresponding delta
- * and sets its state to status.
- */
-{
- struct hshentry *target;
-
- if (expandsym(rev, &numrev)) {
- target = genrevs(numrev.string, (char*)0, (char*)0,
- (char*)0, &gendeltas);
- if ( target )
- if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string))
- rcserror("can't set state of nonexisting revision %s",
- numrev.string
- );
- else if (strcmp(target->state, status) != 0) {
- target->state = status;
- return true;
- }
- }
- return false;
-}
-
-
-
-
-
- static int
-buildeltatext(deltas)
- struct hshentries const *deltas;
-/* Function: put the delta text on frewrite and make necessary */
-/* change to delta text */
-{
- register FILE *fcut; /* temporary file to rebuild delta tree */
- char const *cutname;
-
- fcut = 0;
- cuttail->selector = false;
- scanlogtext(deltas->first, false);
- if ( cuthead ) {
- cutname = maketemp(3);
- if (!(fcut = fopenSafer(cutname, FOPEN_WPLUS_WORK))) {
- efaterror(cutname);
- }
-
- while (deltas->first != cuthead) {
- deltas = deltas->rest;
- scanlogtext(deltas->first, true);
- }
-
- snapshotedit(fcut);
- Orewind(fcut);
- aflush(fcut);
- }
-
- while (deltas->first != cuttail)
- scanlogtext((deltas = deltas->rest)->first, true);
- finishedit((struct hshentry*)0, (FILE*)0, true);
- Ozclose(&fcopy);
-
- if (fcut) {
- char const *diffname = maketemp(0);
- char const *diffv[6 + !!OPEN_O_BINARY];
- char const **diffp = diffv;
- *++diffp = DIFF;
- *++diffp = DIFFFLAGS;
-# if OPEN_O_BINARY
- if (Expand == BINARY_EXPAND)
- *++diffp == "--binary";
-# endif
- *++diffp = "-";
- *++diffp = resultname;
- *++diffp = 0;
- switch (runv(fileno(fcut), diffname, diffv)) {
- case DIFF_FAILURE: case DIFF_SUCCESS: break;
- default: rcsfaterror("diff failed");
- }
- Ofclose(fcut);
- return putdtext(cuttail,diffname,frewrite,true);
- } else
- return putdtext(cuttail,resultname,frewrite,false);
-}
-
-
-
- static void
-buildtree()
-/* Function: actually removes revisions whose selector field */
-/* is false, and rebuilds the linkage of deltas. */
-/* asks for reconfirmation if deleting last revision*/
-{
- struct hshentry * Delta;
- struct branchhead *pt, *pre;
-
- if ( cuthead )
- if ( cuthead->next == delstrt )
- cuthead->next = cuttail;
- else {
- pre = pt = cuthead->branches;
- while( pt && pt->hsh != delstrt ) {
- pre = pt;
- pt = pt->nextbranch;
- }
- if ( cuttail )
- pt->hsh = cuttail;
- else if ( pt == pre )
- cuthead->branches = pt->nextbranch;
- else
- pre->nextbranch = pt->nextbranch;
- }
- else {
- if (!cuttail && !quietflag) {
- if (!yesorno(false, "Do you really want to delete all revisions? [ny](n): ")) {
- rcserror("No revision deleted");
- Delta = delstrt;
- while( Delta) {
- Delta->selector = true;
- Delta = Delta->next;
- }
- return;
- }
- }
- Head = cuttail;
- }
- return;
-}
-
-#if RCS_lint
-/* This lets us lint everything all at once. */
-
-char const cmdid[] = "";
-
-#define go(p,e) {int p P((int,char**)); void e P((void)); if(*argv)return p(argc,argv);if(*argv[1])e();}
-
- int
-main(argc, argv)
- int argc;
- char **argv;
-{
- go(ciId, ciExit);
- go(coId, coExit);
- go(identId, identExit);
- go(mergeId, mergeExit);
- go(rcsId, exiterr);
- go(rcscleanId, rcscleanExit);
- go(rcsdiffId, rdiffExit);
- go(rcsmergeId, rmergeExit);
- go(rlogId, rlogExit);
- return 0;
-}
-#endif
diff --git a/gnu/usr.bin/rcs/rcs/rcsfile.5 b/gnu/usr.bin/rcs/rcs/rcsfile.5
deleted file mode 100644
index f3be6c5..0000000
--- a/gnu/usr.bin/rcs/rcs/rcsfile.5
+++ /dev/null
@@ -1,426 +0,0 @@
-.lf 1 ./rcsfile.5in
-.\" Set p to 1 if your formatter can handle pic output.
-.if t .nr p 1
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id$
-.ds r \s-1RCS\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.TH RCSFILE 5 \*(Dt GNU
-.SH NAME
-rcsfile \- format of RCS file
-.SH DESCRIPTION
-An \*r file's
-contents are described by the grammar
-below.
-.PP
-The text is free format: space, backspace, tab, newline, vertical
-tab, form feed, and carriage return (collectively,
-.IR "white space")
-have no significance except in strings.
-However, white space cannot appear within an id, num, or sym,
-and an \*r file must end with a newline.
-.PP
-Strings are enclosed by
-.BR @ .
-If a string contains a
-.BR @ ,
-it must be doubled;
-otherwise, strings can contain arbitrary binary data.
-.PP
-The meta syntax uses the following conventions: `|' (bar) separates
-alternatives; `{' and `}' enclose optional phrases; `{' and `}*' enclose
-phrases that can be repeated zero or more times;
-`{' and '}+' enclose phrases that must appear at least once and can be
-repeated;
-Terminal symbols are in
-.BR boldface ;
-nonterminal symbols are in
-.IR italics .
-.LP
-.nr w \w'\f3deltatext\fP '
-.nr y \w'\f3newphrase\fP '
-.if \nw<\ny .nr w \ny
-.nr x \w'\f3branches\fP'
-.nr y \w'{ \f3comment\fP'
-.if \nx<\ny .nr x \ny
-.nr y \w'\f3{ branch\fP'
-.if \nx<\ny .nr x \ny
-.ta \nwu +\w'::= 'u +\nxu+\w' 'u
-.fc #
-.nf
-\f2rcstext\fP ::= \f2admin\fP {\f2delta\fP}* \f2desc\fP {\f2deltatext\fP}*
-.LP
-\f2admin\fP ::= \f3head\fP {\f2num\fP}\f3;\fP
- { \f3branch\fP {\f2num\fP}\f3;\fP }
- \f3access\fP {\f2id\fP}*\f3;\fP
- \f3symbols\fP {\f2sym\fP \f3:\fP \f2num\fP}*\f3;\fP
- \f3locks\fP {\f2id\fP \f3:\fP \f2num\fP}*\f3;\fP {\f3strict ;\fP}
- { \f3comment\fP {\f2string\fP}\f3;\fP }
- { \f3expand\fP {\f2string\fP}\f3;\fP }
- { \f2newphrase\fP }*
-.LP
-\f2delta\fP ::= \f2num\fP
- \f3date\fP \f2num\fP\f3;\fP
- \f3author\fP \f2id\fP\f3;\fP
- \f3state\fP {\f2id\fP}\f3;\fP
- \f3branches\fP {\f2num\fP}*\f3;\fP
- \f3next\fP {\f2num\fP}\f3;\fP
- { \f2newphrase\fP }*
-.LP
-\f2desc\fP ::= \f3desc\fP \f2string\fP
-.LP
-\f2deltatext\fP ::= \f2num\fP
- \f3log\fP \f2string\fP
- { \f2newphrase\fP }*
- \f3text\fP \f2string\fP
-.LP
-\f2num\fP ::= {\f2digit\fP | \f3.\fP}+
-.LP
-\f2digit\fP ::= \f30\fP | \f31\fP | \f32\fP | \f33\fP | \f34\fP | \f35\fP | \f36\fP | \f37\fP | \f38\fP | \f39\fP
-.LP
-\f2id\fP ::= {\f2num\fP} \f2idchar\fP {\f2idchar\fP | \f2num\fP}*
-.LP
-\f2sym\fP ::= {\f2digit\fP}* \f2idchar\fP {\f2idchar\fP | \f2digit\fP}*
-.LP
-\f2idchar\fP ::= any visible graphic character except \f2special\fP
-.LP
-\f2special\fP ::= \f3$\fP | \f3,\fP | \f3.\fP | \f3:\fP | \f3;\fP | \f3@\fP
-.LP
-\f2string\fP ::= \f3@\fP{any character, with \f3@\fP doubled}*\f3@\fP
-.LP
-\f2newphrase\fP ::= \f2id\fP \f2word\fP* \f3;\fP
-.LP
-\f2word\fP ::= \f2id\fP | \f2num\fP | \f2string\fP | \f3:\fP
-.fi
-.PP
-Identifiers are case sensitive. Keywords are in lower case only.
-The sets of keywords and identifiers can overlap.
-In most environments \*r uses the \s-1ISO\s0 8859/1 encoding:
-visible graphic characters are codes 041\-176 and 240\-377,
-and white space characters are codes 010\-015 and 040.
-.PP
-Dates, which appear after the
-.B date
-keyword, are of the form
-\f2Y\fP\f3.\fP\f2mm\fP\f3.\fP\f2dd\fP\f3.\fP\f2hh\fP\f3.\fP\f2mm\fP\f3.\fP\f2ss\fP,
-where
-.I Y
-is the year,
-.I mm
-the month (01\-12),
-.I dd
-the day (01\-31),
-.I hh
-the hour (00\-23),
-.I mm
-the minute (00\-59),
-and
-.I ss
-the second (00\-60).
-.I Y
-contains just the last two digits of the year
-for years from 1900 through 1999,
-and all the digits of years thereafter.
-Dates use the Gregorian calendar; times use UTC.
-.PP
-The
-.I newphrase
-productions in the grammar are reserved for future extensions
-to the format of \*r files.
-No
-.I newphrase
-will begin with any keyword already in use.
-.PP
-The
-.I delta
-nodes form a tree. All nodes whose numbers
-consist of a single pair
-(e.g., 2.3, 2.1, 1.3, etc.)
-are on the trunk, and are linked through the
-.B next
-field in order of decreasing numbers.
-The
-.B head
-field in the
-.I admin
-node points to the head of that sequence (i.e., contains
-the highest pair).
-The
-.B branch
-node in the admin node indicates the default
-branch (or revision) for most \*r operations.
-If empty, the default
-branch is the highest branch on the trunk.
-.PP
-All
-.I delta
-nodes whose numbers consist of
-.RI 2 n
-fields
-.RI ( n \(>=2)
-(e.g., 3.1.1.1, 2.1.2.2, etc.)
-are linked as follows.
-All nodes whose first
-.RI 2 n \-1
-number fields are identical are linked through the
-.B next
-field in order of increasing numbers.
-For each such sequence,
-the
-.I delta
-node whose number is identical to the first
-.RI 2 n \-2
-number fields of the deltas on that sequence is called the branchpoint.
-The
-.B branches
-field of a node contains a list of the
-numbers of the first nodes of all sequences for which it is a branchpoint.
-This list is ordered in increasing numbers.
-.LP
-The following diagram shows an example of an \*r file's organization.
-.if !\np \{\
-.nf
-.vs 12
-.ne 36
-.cs 1 20
-.eo
-
- Head
- |
- |
- v / \
- --------- / \
- / \ / \ | | / \ / \
- / \ / \ | 2.1 | / \ / \
- / \ / \ | | / \ / \
-/1.2.1.3\ /1.3.1.1\ | | /1.2.2.2\ /1.2.2.1.1.1\
---------- --------- --------- --------- -------------
- ^ ^ | ^ ^
- | | | | |
- | | v | |
- / \ | --------- / \ |
- / \ | \ 1.3 / / \ |
- / \ ---------\ / / \-----------
-/1.2.1.1\ \ / /1.2.2.1\
---------- \ / ---------
- ^ | ^
- | | |
- | v |
- | --------- |
- | \ 1.2 / |
- ----------------------\ /---------
- \ /
- \ /
- |
- |
- v
- ---------
- \ 1.1 /
- \ /
- \ /
- \ /
-
-.ec
-.cs 1
-.vs
-.fi
-.\}
-.if \np \{\
-.lf 232
-.PS 4.250i 3.812i
-.\" -2.0625 -4.25 1.75 0
-.\" 0.000i 4.250i 3.812i 0.000i
-.nr 00 \n(.u
-.nf
-.nr 0x 1
-\h'3.812i'
-.sp -1
-.lf 242
-\h'2.062i-(\w'Head'u/2u)'\v'0.125i-(0v/2u)+0v+0.22m'Head
-.sp -1
-\h'2.062i'\v'0.250i'\D'l0.000i 0.500i'
-.sp -1
-\h'2.087i'\v'0.650i'\D'l-0.025i 0.100i'
-.sp -1
-\h'2.062i'\v'0.750i'\D'l-0.025i -0.100i'
-.sp -1
-\h'1.688i'\v'1.250i'\D'l0.750i 0.000i'
-.sp -1
-\h'2.438i'\v'1.250i'\D'l0.000i -0.500i'
-.sp -1
-\h'2.438i'\v'0.750i'\D'l-0.750i 0.000i'
-.sp -1
-\h'1.688i'\v'0.750i'\D'l0.000i 0.500i'
-.sp -1
-.lf 244
-\h'2.062i-(\w'2.1'u/2u)'\v'1.000i-(0v/2u)+0v+0.22m'2.1
-.sp -1
-\h'2.062i'\v'1.250i'\D'l0.000i 0.500i'
-.sp -1
-\h'2.087i'\v'1.650i'\D'l-0.025i 0.100i'
-.sp -1
-\h'2.062i'\v'1.750i'\D'l-0.025i -0.100i'
-.sp -1
-.lf 246
-\h'2.062i-(\w'1.3'u/2u)'\v'2.000i-(1v/2u)+0v+0.22m'1.3
-.sp -1
-\h'2.062i'\v'2.250i'\D'l-0.375i -0.500i'
-.sp -1
-\h'1.688i'\v'1.750i'\D'l0.750i 0.000i'
-.sp -1
-\h'2.438i'\v'1.750i'\D'l-0.375i 0.500i'
-.sp -1
-\h'1.875i'\v'2.000i'\D'~-0.500i 0.000i 0.000i -0.500i'
-.sp -1
-\h'1.350i'\v'1.600i'\D'l0.025i -0.100i'
-.sp -1
-\h'1.375i'\v'1.500i'\D'l0.025i 0.100i'
-.sp -1
-.lf 249
-\h'1.375i-(\w'1.3.1.1'u/2u)'\v'1.250i-(1v/2u)+1v+0.22m'1.3.1.1
-.sp -1
-\h'1.375i'\v'1.000i'\D'l-0.375i 0.500i'
-.sp -1
-\h'1.000i'\v'1.500i'\D'l0.750i 0.000i'
-.sp -1
-\h'1.750i'\v'1.500i'\D'l-0.375i -0.500i'
-.sp -1
-\h'2.062i'\v'2.250i'\D'l0.000i 0.500i'
-.sp -1
-\h'2.087i'\v'2.650i'\D'l-0.025i 0.100i'
-.sp -1
-\h'2.062i'\v'2.750i'\D'l-0.025i -0.100i'
-.sp -1
-.lf 252
-\h'2.062i-(\w'1.2'u/2u)'\v'3.000i-(1v/2u)+0v+0.22m'1.2
-.sp -1
-\h'2.062i'\v'3.250i'\D'l-0.375i -0.500i'
-.sp -1
-\h'1.688i'\v'2.750i'\D'l0.750i 0.000i'
-.sp -1
-\h'2.438i'\v'2.750i'\D'l-0.375i 0.500i'
-.sp -1
-\h'1.875i'\v'3.000i'\D'~-0.500i 0.000i -0.500i 0.000i -0.500i 0.000i 0.000i -0.500i'
-.sp -1
-\h'0.350i'\v'2.600i'\D'l0.025i -0.100i'
-.sp -1
-\h'0.375i'\v'2.500i'\D'l0.025i 0.100i'
-.sp -1
-.lf 255
-\h'0.375i-(\w'1.2.1.1'u/2u)'\v'2.250i-(1v/2u)+1v+0.22m'1.2.1.1
-.sp -1
-\h'0.375i'\v'2.000i'\D'l-0.375i 0.500i'
-.sp -1
-\h'0.000i'\v'2.500i'\D'l0.750i 0.000i'
-.sp -1
-\h'0.750i'\v'2.500i'\D'l-0.375i -0.500i'
-.sp -1
-\h'0.375i'\v'2.000i'\D'l0.000i -0.500i'
-.sp -1
-\h'0.350i'\v'1.600i'\D'l0.025i -0.100i'
-.sp -1
-\h'0.375i'\v'1.500i'\D'l0.025i 0.100i'
-.sp -1
-.lf 257
-\h'0.375i-(\w'1.2.1.3'u/2u)'\v'1.250i-(1v/2u)+1v+0.22m'1.2.1.3
-.sp -1
-\h'0.375i'\v'1.000i'\D'l-0.375i 0.500i'
-.sp -1
-\h'0.000i'\v'1.500i'\D'l0.750i 0.000i'
-.sp -1
-\h'0.750i'\v'1.500i'\D'l-0.375i -0.500i'
-.sp -1
-\h'2.250i'\v'3.000i'\D'~0.500i 0.000i 0.000i -0.500i'
-.sp -1
-\h'2.725i'\v'2.600i'\D'l0.025i -0.100i'
-.sp -1
-\h'2.750i'\v'2.500i'\D'l0.025i 0.100i'
-.sp -1
-.lf 261
-\h'2.750i-(\w'1.2.2.1'u/2u)'\v'2.250i-(1v/2u)+1v+0.22m'1.2.2.1
-.sp -1
-\h'2.750i'\v'2.000i'\D'l-0.375i 0.500i'
-.sp -1
-\h'2.375i'\v'2.500i'\D'l0.750i 0.000i'
-.sp -1
-\h'3.125i'\v'2.500i'\D'l-0.375i -0.500i'
-.sp -1
-\h'2.938i'\v'2.250i'\D'~0.500i 0.000i 0.000i -0.500i 0.000i -0.500i'
-.sp -1
-\h'3.413i'\v'1.350i'\D'l0.025i -0.100i'
-.sp -1
-\h'3.438i'\v'1.250i'\D'l0.025i 0.100i'
-.sp -1
-.lf 264
-\h'3.438i-(\w'\s-21.2.2.1.1.1\s0'u/2u)'\v'1.000i-(1v/2u)+1v+0.22m'\s-21.2.2.1.1.1\s0
-.sp -1
-\h'3.438i'\v'0.750i'\D'l-0.375i 0.500i'
-.sp -1
-\h'3.062i'\v'1.250i'\D'l0.750i 0.000i'
-.sp -1
-\h'3.812i'\v'1.250i'\D'l-0.375i -0.500i'
-.sp -1
-\h'2.750i'\v'2.000i'\D'l0.000i -0.500i'
-.sp -1
-\h'2.725i'\v'1.600i'\D'l0.025i -0.100i'
-.sp -1
-\h'2.750i'\v'1.500i'\D'l0.025i 0.100i'
-.sp -1
-.lf 267
-\h'2.750i-(\w'1.2.2.2'u/2u)'\v'1.250i-(1v/2u)+1v+0.22m'1.2.2.2
-.sp -1
-\h'2.750i'\v'1.000i'\D'l-0.375i 0.500i'
-.sp -1
-\h'2.375i'\v'1.500i'\D'l0.750i 0.000i'
-.sp -1
-\h'3.125i'\v'1.500i'\D'l-0.375i -0.500i'
-.sp -1
-\h'2.062i'\v'3.250i'\D'l0.000i 0.500i'
-.sp -1
-\h'2.087i'\v'3.650i'\D'l-0.025i 0.100i'
-.sp -1
-\h'2.062i'\v'3.750i'\D'l-0.025i -0.100i'
-.sp -1
-.lf 270
-\h'2.062i-(\w'1.1'u/2u)'\v'4.000i-(1v/2u)+0v+0.22m'1.1
-.sp -1
-\h'2.062i'\v'4.250i'\D'l-0.375i -0.500i'
-.sp -1
-\h'1.688i'\v'3.750i'\D'l0.750i 0.000i'
-.sp -1
-\h'2.438i'\v'3.750i'\D'l-0.375i 0.500i'
-.sp -1
-.sp 4.250i+1
-.if \n(00 .fi
-.br
-.nr 0x 0
-.lf 271
-.PE
-.lf 272
-.\}
-.PP
-.SH IDENTIFICATION
-.de VL
-\\$2
-..
-Author: Walter F. Tichy,
-Purdue University, West Lafayette, IN, 47907.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert.
-.SH SEE ALSO
-rcsintro(1), ci(1), co(1), ident(1), rcs(1), rcsclean(1), rcsdiff(1),
-rcsmerge(1), rlog(1)
-.br
-Walter F. Tichy,
-\*r\*-A System for Version Control,
-.I "Software\*-Practice & Experience"
-.BR 15 ,
-7 (July 1985), 637-654.
diff --git a/gnu/usr.bin/rcs/rcs/rcsintro.1 b/gnu/usr.bin/rcs/rcs/rcsintro.1
deleted file mode 100644
index 715e03b..0000000
--- a/gnu/usr.bin/rcs/rcs/rcsintro.1
+++ /dev/null
@@ -1,302 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id$
-.ds r \&\s-1RCS\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.if !\n(.g \{\
-. if !\w|\*(lq| \{\
-. ds lq ``
-. if \w'\(lq' .ds lq "\(lq
-. \}
-. if !\w|\*(rq| \{\
-. ds rq ''
-. if \w'\(rq' .ds rq "\(rq
-. \}
-.\}
-.am SS
-.LP
-..
-.TH RCSINTRO 1 \*(Dt GNU
-.SH NAME
-rcsintro \- introduction to RCS commands
-.SH DESCRIPTION
-The Revision Control System (\*r) manages multiple revisions of files.
-\*r automates the storing, retrieval, logging, identification, and merging
-of revisions. \*r is useful for text that is revised frequently, for example
-programs, documentation, graphics, papers, and form letters.
-.PP
-The basic user interface is extremely simple. The novice only needs
-to learn two commands:
-.BR ci (1)
-and
-.BR co (1).
-.BR ci ,
-short for \*(lqcheck in\*(rq, deposits the contents of a
-file into an archival file called an \*r file. An \*r file
-contains all revisions of a particular file.
-.BR co ,
-short for \*(lqcheck out\*(rq, retrieves revisions from an \*r file.
-.SS "Functions of \*r"
-.IP \(bu
-Store and retrieve multiple revisions of text. \*r saves all old
-revisions in a space efficient way.
-Changes no longer destroy the original, because the
-previous revisions remain accessible. Revisions can be retrieved according to
-ranges of revision numbers, symbolic names, dates, authors, and
-states.
-.IP \(bu
-Maintain a complete history of changes.
-\*r logs all changes automatically.
-Besides the text of each revision, \*r stores the author, the date and time of
-check-in, and a log message summarizing the change.
-The logging makes it easy to find out
-what happened to a module, without having to compare
-source listings or having to track down colleagues.
-.IP \(bu
-Resolve access conflicts. When two or more programmers wish to
-modify the same revision, \*r alerts the programmers and prevents one
-modification from corrupting the other.
-.IP \(bu
-Maintain a tree of revisions. \*r can maintain separate lines of development
-for each module. It stores a tree structure that represents the
-ancestral relationships among revisions.
-.IP \(bu
-Merge revisions and resolve conflicts.
-Two separate lines of development of a module can be coalesced by merging.
-If the revisions to be merged affect the same sections of code, \*r alerts the
-user about the overlapping changes.
-.IP \(bu
-Control releases and configurations.
-Revisions can be assigned symbolic names
-and marked as released, stable, experimental, etc.
-With these facilities, configurations of modules can be
-described simply and directly.
-.IP \(bu
-Automatically identify each revision with name, revision number,
-creation time, author, etc.
-The identification is like a stamp that can be embedded at an appropriate place
-in the text of a revision.
-The identification makes it simple to determine which
-revisions of which modules make up a given configuration.
-.IP \(bu
-Minimize secondary storage. \*r needs little extra space for
-the revisions (only the differences). If intermediate revisions are
-deleted, the corresponding deltas are compressed accordingly.
-.SS "Getting Started with \*r"
-Suppose you have a file
-.B f.c
-that you wish to put under control of \*r.
-If you have not already done so, make an \*r directory with the command
-.IP
-.B "mkdir RCS"
-.LP
-Then invoke the check-in command
-.IP
-.B "ci f.c"
-.LP
-This command creates an \*r file in the
-.B RCS
-directory,
-stores
-.B f.c
-into it as revision 1.1, and
-deletes
-.BR f.c .
-It also asks you for a description. The description
-should be a synopsis of the contents of the file. All later check-in
-commands will ask you for a log entry, which should summarize the
-changes that you made.
-.PP
-Files in the \*r directory are called \*r files;
-the others are called working files.
-To get back the working file
-.B f.c
-in the previous example, use the check-out
-command
-.IP
-.B "co f.c"
-.LP
-This command extracts the latest revision from the \*r file
-and writes
-it into
-.BR f.c .
-If you want to edit
-.BR f.c ,
-you must lock it as you check it out with the command
-.IP
-.B "co \-l f.c"
-.LP
-You can now edit
-.BR f.c .
-.PP
-Suppose after some editing you want to know what changes that you have made.
-The command
-.IP
-.B "rcsdiff f.c"
-.LP
-tells you the difference between the most recently checked-in version
-and the working file.
-You can check the file back in by invoking
-.IP
-.B "ci f.c"
-.LP
-This increments the revision number properly.
-.PP
-If
-.B ci
-complains with the message
-.IP
-.BI "ci error: no lock set by " "your name"
-.LP
-then you have tried to check in a file even though you did not
-lock it when you checked it out.
-Of course, it is too late now to do the check-out with locking, because
-another check-out would
-overwrite your modifications. Instead, invoke
-.IP
-.B "rcs \-l f.c"
-.LP
-This command will lock the latest revision for you, unless somebody
-else got ahead of you already. In this case, you'll have to negotiate with
-that person.
-.PP
-Locking assures that you, and only you, can check in the next update, and
-avoids nasty problems if several people work on the same file.
-Even if a revision is locked, it can still be checked out for
-reading, compiling, etc. All that locking
-prevents is a
-.I "check-in"
-by anybody but the locker.
-.PP
-If your \*r file is private, i.e., if you are the only person who is going
-to deposit revisions into it, strict locking is not needed and you
-can turn it off.
-If strict locking is turned off,
-the owner of the \*r file need not have a lock for check-in; all others
-still do. Turning strict locking off and on is done with the commands
-.IP
-.BR "rcs \-U f.c" " and " "rcs \-L f.c"
-.LP
-If you don't want to clutter your working directory with \*r files, create
-a subdirectory called
-.B RCS
-in your working directory, and move all your \*r
-files there. \*r commands will look first into that directory to find
-needed files. All the commands discussed above will still work, without any
-modification.
-(Actually, pairs of \*r and working files can be specified in three ways:
-(a) both are given, (b) only the working file is given, (c) only the
-\*r file is given. Both \*r and working files may have arbitrary path prefixes;
-\*r commands pair them up intelligently.)
-.PP
-To avoid the deletion of the working file during check-in (in case you want to
-continue editing or compiling), invoke
-.IP
-.BR "ci \-l f.c" " or " "ci \-u f.c"
-.LP
-These commands check in
-.B f.c
-as usual, but perform an implicit
-check-out. The first form also locks the checked in revision, the second one
-doesn't. Thus, these options save you one check-out operation.
-The first form is useful if you want to continue editing,
-the second one if you just want to read the file.
-Both update the identification markers in your working file (see below).
-.PP
-You can give
-.B ci
-the number you want assigned to a checked in
-revision. Assume all your revisions were numbered 1.1, 1.2, 1.3, etc.,
-and you would like to start release 2.
-The command
-.IP
-.BR "ci \-r2 f.c" " or " "ci \-r2.1 f.c"
-.LP
-assigns the number 2.1 to the new revision.
-From then on,
-.B ci
-will number the subsequent revisions
-with 2.2, 2.3, etc. The corresponding
-.B co
-commands
-.IP
-.BR "co \-r2 f.c" " and " "co \-r2.1 f.c"
-.PP
-retrieve the latest revision numbered
-.RI 2. x
-and the revision 2.1,
-respectively.
-.B co
-without a revision number selects
-the latest revision on the
-.IR trunk ,
-i.e. the highest
-revision with a number consisting of two fields. Numbers with more than two
-fields are needed for branches.
-For example, to start a branch at revision 1.3, invoke
-.IP
-.B "ci \-r1.3.1 f.c"
-.LP
-This command starts a branch numbered 1 at revision 1.3, and assigns
-the number 1.3.1.1 to the new revision. For more information about
-branches, see
-.BR rcsfile (5).
-.SS "Automatic Identification"
-\*r can put special strings for identification into your source and object
-code. To obtain such identification, place the marker
-.IP
-.B "$\&Id$"
-.LP
-into your text, for instance inside a comment.
-\*r will replace this marker with a string of the form
-.IP
-.BI $\&Id: " filename revision date time author state " $
-.LP
-With such a marker on the first page of each module, you can
-always see with which revision you are working.
-\*r keeps the markers up to date automatically.
-To propagate the markers into your object code, simply put
-them into literal character strings. In C, this is done as follows:
-.IP
-.ft 3
-static char rcsid[] = \&"$\&Id$\&";
-.ft
-.LP
-The command
-.B ident
-extracts such markers from any file, even object code
-and dumps.
-Thus,
-.B ident
-lets you find out
-which revisions of which modules were used in a given program.
-.PP
-You may also find it useful to put the marker
-.B $\&Log$
-into your text, inside a comment. This marker accumulates
-the log messages that are requested during check-in.
-Thus, you can maintain the complete history of your file directly inside it.
-There are several additional identification markers; see
-.BR co (1)
-for
-details.
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991, 1992, 1993 Paul Eggert.
-.SH "SEE ALSO"
-ci(1), co(1), ident(1), rcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1), rlog(1)
-.br
-Walter F. Tichy,
-\*r\*-A System for Version Control,
-.I "Software\*-Practice & Experience"
-.BR 15 ,
-7 (July 1985), 637-654.
-.br
diff --git a/gnu/usr.bin/rcs/rcsclean/Makefile b/gnu/usr.bin/rcs/rcsclean/Makefile
deleted file mode 100644
index fe538a0..0000000
--- a/gnu/usr.bin/rcs/rcsclean/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG= rcsclean
-SRCS= rcsclean.c
-CFLAGS+= -I${.CURDIR}/../lib
-LDADD= ${LIBRCS}
-DPADD= ${LIBRCS}
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/rcs/rcsclean/rcsclean.1 b/gnu/usr.bin/rcs/rcsclean/rcsclean.1
deleted file mode 100644
index e671a5e..0000000
--- a/gnu/usr.bin/rcs/rcsclean/rcsclean.1
+++ /dev/null
@@ -1,203 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id$
-.ds r \&\s-1RCS\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.TH RCSCLEAN 1 \*(Dt GNU
-.SH NAME
-rcsclean \- clean up working files
-.SH SYNOPSIS
-.B rcsclean
-.RI [ options "] [ " file " .\|.\|. ]"
-.SH DESCRIPTION
-.B rcsclean
-removes files that are not being worked on.
-.B "rcsclean \-u"
-also unlocks and removes files that are being worked on
-but have not changed.
-.PP
-For each
-.I file
-given,
-.B rcsclean
-compares the working file and a revision in the corresponding
-\*r file. If it finds a difference, it does nothing.
-Otherwise, it first unlocks the revision if the
-.B \-u
-option is given,
-and then removes the working file
-unless the working file is writable and the revision is locked.
-It logs its actions by outputting the corresponding
-.B "rcs \-u"
-and
-.B "rm \-f"
-commands on the standard output.
-.PP
-Files are paired as explained in
-.BR ci (1).
-If no
-.I file
-is given, all working files in the current directory are cleaned.
-Pathnames matching an \*r suffix denote \*r files;
-all others denote working files.
-.PP
-The number of the revision to which the working file is compared
-may be attached to any of the options
-.BR \-n ,
-.BR \-q ,
-.BR \-r ,
-or
-.BR \-u .
-If no revision number is specified, then if the
-.B \-u
-option is given and the caller has one revision locked,
-.B rcsclean
-uses that revision; otherwise
-.B rcsclean
-uses the latest revision on the default branch, normally the root.
-.PP
-.B rcsclean
-is useful for
-.B clean
-targets in makefiles.
-See also
-.BR rcsdiff (1),
-which prints out the differences,
-and
-.BR ci (1),
-which
-normally reverts to the previous revision
-if a file was not changed.
-.SH OPTIONS
-.TP
-.BI \-k subst
-Use
-.I subst
-style keyword substitution when retrieving the revision for comparison.
-See
-.BR co (1)
-for details.
-.TP
-.BR \-n [\f2rev\fP]
-Do not actually remove any files or unlock any revisions.
-Using this option will tell you what
-.B rcsclean
-would do without actually doing it.
-.TP
-.BR \-q [\f2rev\fP]
-Do not log the actions taken on standard output.
-.TP
-.BR \-r [\f2rev\fP]
-This option has no effect other than specifying the revision for comparison.
-.TP
-.B \-T
-Preserve the modification time on the \*r file
-even if the \*r file changes because a lock is removed.
-This option can suppress extensive recompilation caused by a
-.BR make (1)
-dependency of some other copy of the working file on the \*r file.
-Use this option with care; it can suppress recompilation even when it is needed,
-i.e. when the lock removal
-would mean a change to keyword strings in the other working file.
-.TP
-.BR \-u [\f2rev\fP]
-Unlock the revision if it is locked and no difference is found.
-.TP
-.BI \-V
-Print \*r's version number.
-.TP
-.BI \-V n
-Emulate \*r version
-.IR n .
-See
-.BR co (1)
-for details.
-.TP
-.BI \-x "suffixes"
-Use
-.I suffixes
-to characterize \*r files.
-See
-.BR ci (1)
-for details.
-.TP
-.BI \-z zone
-Use
-.I zone
-as the time zone for keyword substitution;
-see
-.BR co (1)
-for details.
-.SH EXAMPLES
-.LP
-.RS
-.ft 3
-rcsclean *.c *.h
-.ft
-.RE
-.LP
-removes all working files ending in
-.B .c
-or
-.B .h
-that were not changed
-since their checkout.
-.LP
-.RS
-.ft 3
-rcsclean
-.ft
-.RE
-.LP
-removes all working files in the current directory
-that were not changed since their checkout.
-.SH FILES
-.B rcsclean
-accesses files much as
-.BR ci (1)
-does.
-.SH ENVIRONMENT
-.TP
-.B \s-1RCSINIT\s0
-options prepended to the argument list, separated by spaces.
-A backslash escapes spaces within an option.
-The
-.B \s-1RCSINIT\s0
-options are prepended to the argument lists of most \*r commands.
-Useful
-.B \s-1RCSINIT\s0
-options include
-.BR \-q ,
-.BR \-V ,
-.BR \-x ,
-and
-.BR \-z .
-.SH DIAGNOSTICS
-The exit status is zero if and only if all operations were successful.
-Missing working files and \*r files are silently ignored.
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991, 1992, 1993 Paul Eggert.
-.SH "SEE ALSO"
-ci(1), co(1), ident(1), rcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1), rlog(1),
-rcsfile(5)
-.br
-Walter F. Tichy,
-\*r\*-A System for Version Control,
-.I "Software\*-Practice & Experience"
-.BR 15 ,
-7 (July 1985), 637-654.
-.SH BUGS
-At least one
-.I file
-must be given in older Unix versions that
-do not provide the needed directory scanning operations.
-.br
diff --git a/gnu/usr.bin/rcs/rcsclean/rcsclean.c b/gnu/usr.bin/rcs/rcsclean/rcsclean.c
deleted file mode 100644
index c321270..0000000
--- a/gnu/usr.bin/rcs/rcsclean/rcsclean.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/* Clean up working files. */
-
-/* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#include "rcsbase.h"
-
-#if has_dirent
- static int get_directory P((char const*,char***));
-#endif
-
-static int unlock P((struct hshentry *));
-static void cleanup P((void));
-
-static RILE *workptr;
-static int exitstatus;
-
-mainProg(rcscleanId, "rcsclean", "$Id$")
-{
- static char const usage[] =
- "\nrcsclean: usage: rcsclean -ksubst -{nqru}[rev] -T -Vn -xsuff -zzone file ...";
-
- static struct buf revision;
-
- char *a, **newargv;
- char const *rev, *p;
- int dounlock, expmode, perform, unlocked, unlockflag, waslocked;
- int Ttimeflag;
- struct hshentries *deltas;
- struct hshentry *delta;
- struct stat workstat;
-
- setrid();
-
- expmode = -1;
- rev = 0;
- suffixes = X_DEFAULT;
- perform = true;
- unlockflag = false;
- Ttimeflag = false;
-
- argc = getRCSINIT(argc, argv, &newargv);
- argv = newargv;
- for (;;) {
- if (--argc < 1) {
-# if has_dirent
- argc = get_directory(".", &newargv);
- argv = newargv;
- break;
-# else
- faterror("no pathnames specified");
-# endif
- }
- a = *++argv;
- if (!*a || *a++ != '-')
- break;
- switch (*a++) {
- case 'k':
- if (0 <= expmode)
- redefined('k');
- if ((expmode = str2expmode(a)) < 0)
- goto unknown;
- break;
-
- case 'n':
- perform = false;
- goto handle_revision;
-
- case 'q':
- quietflag = true;
- /* fall into */
- case 'r':
- handle_revision:
- if (*a) {
- if (rev)
- warn("redefinition of revision number");
- rev = a;
- }
- break;
-
- case 'T':
- if (*a)
- goto unknown;
- Ttimeflag = true;
- break;
-
- case 'u':
- unlockflag = true;
- goto handle_revision;
-
- case 'V':
- setRCSversion(*argv);
- break;
-
- case 'x':
- suffixes = a;
- break;
-
- case 'z':
- zone_set(a);
- break;
-
- default:
- unknown:
- error("unknown option: %s%s", *argv, usage);
- }
- }
-
- dounlock = perform & unlockflag;
-
- if (nerror)
- cleanup();
- else
- for (; 0 < argc; cleanup(), ++argv, --argc) {
-
- ffree();
-
- if (!(
- 0 < pairnames(
- argc, argv,
- dounlock ? rcswriteopen : rcsreadopen,
- true, true
- ) &&
- (workptr = Iopen(workname, FOPEN_R_WORK, &workstat))
- ))
- continue;
-
- if (same_file(RCSstat, workstat, 0)) {
- rcserror("RCS file is the same as working file %s.",
- workname
- );
- continue;
- }
-
- gettree();
-
- p = 0;
- if (rev) {
- if (!fexpandsym(rev, &revision, workptr))
- continue;
- p = revision.string;
- } else if (Head)
- switch (unlockflag ? findlock(false,&delta) : 0) {
- default:
- continue;
- case 0:
- p = Dbranch ? Dbranch : "";
- break;
- case 1:
- p = delta->num;
- break;
- }
- delta = 0;
- deltas = 0; /* Keep lint happy. */
- if (p && !(delta = genrevs(p,(char*)0,(char*)0,(char*)0,&deltas)))
- continue;
-
- waslocked = delta && delta->lockedby;
- locker_expansion = unlock(delta);
- unlocked = locker_expansion & unlockflag;
- if (unlocked<waslocked && workstat.st_mode&(S_IWUSR|S_IWGRP|S_IWOTH))
- continue;
-
- if (unlocked && !checkaccesslist())
- continue;
-
- if (dorewrite(dounlock, unlocked) != 0)
- continue;
-
- if (0 <= expmode)
- Expand = expmode;
- else if (
- waslocked &&
- Expand == KEYVAL_EXPAND &&
- WORKMODE(RCSstat.st_mode,true) == workstat.st_mode
- )
- Expand = KEYVALLOCK_EXPAND;
-
- getdesc(false);
-
- if (
- !delta ? workstat.st_size!=0 :
- 0 < rcsfcmp(
- workptr, &workstat,
- buildrevision(deltas, delta, (FILE*)0, false),
- delta
- )
- )
- continue;
-
- if (quietflag < unlocked)
- aprintf(stdout, "rcs -u%s %s\n", delta->num, RCSname);
-
- if (perform & unlocked) {
- if_advise_access(deltas->first != delta, finptr, MADV_SEQUENTIAL);
- if (donerewrite(true,
- Ttimeflag ? RCSstat.st_mtime : (time_t)-1
- ) != 0)
- continue;
- }
-
- if (!quietflag)
- aprintf(stdout, "rm -f %s\n", workname);
- Izclose(&workptr);
- if (perform && un_link(workname) != 0)
- eerror(workname);
-
- }
-
- tempunlink();
- if (!quietflag)
- Ofclose(stdout);
- exitmain(exitstatus);
-}
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = EXIT_FAILURE;
- Izclose(&finptr);
- Izclose(&workptr);
- Ozclose(&fcopy);
- ORCSclose();
- dirtempunlink();
-}
-
-#if RCS_lint
-# define exiterr rcscleanExit
-#endif
- void
-exiterr()
-{
- ORCSerror();
- dirtempunlink();
- tempunlink();
- _exit(EXIT_FAILURE);
-}
-
- static int
-unlock(delta)
- struct hshentry *delta;
-{
- register struct rcslock **al, *l;
-
- if (delta && delta->lockedby && strcmp(getcaller(),delta->lockedby)==0)
- for (al = &Locks; (l = *al); al = &l->nextlock)
- if (l->delta == delta) {
- *al = l->nextlock;
- delta->lockedby = 0;
- return true;
- }
- return false;
-}
-
-#if has_dirent
- static int
-get_directory(dirname, aargv)
- char const *dirname;
- char ***aargv;
-/*
- * Put a vector of all DIRNAME's directory entries names into *AARGV.
- * Ignore names of RCS files.
- * Yield the number of entries found. Terminate the vector with 0.
- * Allocate the storage for the vector and entry names.
- * Do not sort the names. Do not include '.' and '..'.
- */
-{
- int i, entries = 0, entries_max = 64;
- size_t chars = 0, chars_max = 1024;
- size_t *offset = tnalloc(size_t, entries_max);
- char *a = tnalloc(char, chars_max), **p;
- DIR *d;
- struct dirent *e;
-
- if (!(d = opendir(dirname)))
- efaterror(dirname);
- while ((errno = 0, e = readdir(d))) {
- char const *en = e->d_name;
- size_t s = strlen(en) + 1;
- if (en[0]=='.' && (!en[1] || (en[1]=='.' && !en[2])))
- continue;
- if (rcssuffix(en))
- continue;
- while (chars_max < s + chars)
- a = trealloc(char, a, chars_max<<=1);
- if (entries == entries_max)
- offset = trealloc(size_t, offset, entries_max<<=1);
- offset[entries++] = chars;
- VOID strcpy(a+chars, en);
- chars += s;
- }
-# if void_closedir
-# define close_directory(d) (closedir(d), 0)
-# else
-# define close_directory(d) closedir(d)
-# endif
- if (errno || close_directory(d) != 0)
- efaterror(dirname);
- if (chars)
- a = trealloc(char, a, chars);
- else
- tfree(a);
- *aargv = p = tnalloc(char*, entries+1);
- for (i=0; i<entries; i++)
- *p++ = a + offset[i];
- *p = 0;
- tfree(offset);
- return entries;
-}
-#endif
diff --git a/gnu/usr.bin/rcs/rcsdiff/Makefile b/gnu/usr.bin/rcs/rcsdiff/Makefile
deleted file mode 100644
index 45ce23f..0000000
--- a/gnu/usr.bin/rcs/rcsdiff/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG= rcsdiff
-SRCS= rcsdiff.c
-CFLAGS+= -I${.CURDIR}/../lib
-LDADD= ${LIBRCS}
-DPADD= ${LIBRCS}
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/rcs/rcsdiff/rcsdiff.1 b/gnu/usr.bin/rcs/rcsdiff/rcsdiff.1
deleted file mode 100644
index 5dff7d9..0000000
--- a/gnu/usr.bin/rcs/rcsdiff/rcsdiff.1
+++ /dev/null
@@ -1,158 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id$
-.ds r \&\s-1RCS\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.TH RCSDIFF 1 \*(Dt GNU
-.SH NAME
-rcsdiff \- compare RCS revisions
-.SH SYNOPSIS
-.B rcsdiff
-[
-.BI \-k subst
-] [
-.B \-q
-] [
-.BI \-r rev1
-[
-.BI \-r rev2
-] ] [
-.B \-T
-] [
-.RI "\f3\-V\fP[" n ]
-] [
-.BI \-x suffixes
-] [
-.BI \-z zone
-] [
-.I "diff options"
-]
-.I "file .\|.\|."
-.SH DESCRIPTION
-.B rcsdiff
-runs
-.BR diff (1)
-to compare two revisions of each \*r file given.
-.PP
-Pathnames matching an \*r suffix denote \*r files;
-all others denote working files.
-Names are paired as explained in
-.BR ci (1).
-.PP
-The option
-.B \-q
-suppresses diagnostic output.
-Zero, one, or two revisions may be specified with
-.BR \-r .
-The option
-.BI \-k subst
-affects keyword substitution when extracting
-revisions, as described in
-.BR co (1);
-for example,
-.B "\-kk\ \-r1.1\ \-r1.2"
-ignores differences in keyword values when comparing revisions
-.B 1.1
-and
-.BR 1.2 .
-To avoid excess output from locker name substitution,
-.B \-kkvl
-is assumed if (1) at most one revision option is given,
-(2) no
-.B \-k
-option is given, (3)
-.B \-kkv
-is the default keyword substitution, and
-(4) the working file's mode would be produced by
-.BR "co\ \-l".
-See
-.BR co (1)
-for details
-about
-.BR \-T ,
-.BR \-V ,
-.B \-x
-and
-.BR \-z .
-Otherwise, all options of
-.BR diff (1)
-that apply to regular files are accepted, with the same meaning as for
-.BR diff .
-.PP
-If both
-.I rev1
-and
-.I rev2
-are omitted,
-.B rcsdiff
-compares the latest revision on the
-default branch (by default the trunk)
-with the contents of the corresponding working file. This is useful
-for determining what you changed since the last checkin.
-.PP
-If
-.I rev1
-is given, but
-.I rev2
-is omitted,
-.B rcsdiff
-compares revision
-.I rev1
-of the \*r file with
-the contents of the corresponding working file.
-.PP
-If both
-.I rev1
-and
-.I rev2
-are given,
-.B rcsdiff
-compares revisions
-.I rev1
-and
-.I rev2
-of the \*r file.
-.PP
-Both
-.I rev1
-and
-.I rev2
-may be given numerically or symbolically.
-.SH EXAMPLE
-The command
-.LP
-.B " rcsdiff f.c"
-.LP
-compares the latest revision on the default branch of the \*r file
-to the contents of the working file
-.BR f.c .
-.SH ENVIRONMENT
-.TP
-.B \s-1RCSINIT\s0
-options prepended to the argument list, separated by spaces.
-See
-.BR ci (1)
-for details.
-.SH DIAGNOSTICS
-Exit status is 0 for no differences during any comparison,
-1 for some differences, 2 for trouble.
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991, 1992, 1993 Paul Eggert.
-.SH "SEE ALSO"
-ci(1), co(1), diff(1), ident(1), rcs(1), rcsintro(1), rcsmerge(1), rlog(1)
-.br
-Walter F. Tichy,
-\*r\*-A System for Version Control,
-.I "Software\*-Practice & Experience"
-.BR 15 ,
-7 (July 1985), 637-654.
-.br
diff --git a/gnu/usr.bin/rcs/rcsdiff/rcsdiff.c b/gnu/usr.bin/rcs/rcsdiff/rcsdiff.c
deleted file mode 100644
index 371dd73..0000000
--- a/gnu/usr.bin/rcs/rcsdiff/rcsdiff.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/* Compare RCS revisions. */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.19 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.18 1995/06/01 16:23:43 eggert
- * (main): Pass "--binary" if -kb and if --binary makes a difference.
- * Don't treat + options specially.
- *
- * Revision 5.17 1994/03/17 14:05:48 eggert
- * Specify subprocess input via file descriptor, not file name. Remove lint.
- *
- * Revision 5.16 1993/11/09 17:40:15 eggert
- * -V now prints version on stdout and exits. Don't print usage twice.
- *
- * Revision 5.15 1993/11/03 17:42:27 eggert
- * Add -z. Ignore -T. Pass -Vn to `co'. Add Name keyword.
- * Put revision numbers in -c output. Improve quality of diagnostics.
- *
- * Revision 5.14 1992/07/28 16:12:44 eggert
- * Add -V. Use co -M for better dates with traditional diff -c.
- *
- * Revision 5.13 1992/02/17 23:02:23 eggert
- * Output more readable context diff headers.
- * Suppress needless checkout and comparison of identical revisions.
- *
- * Revision 5.12 1992/01/24 18:44:19 eggert
- * Add GNU diff 1.15.2's new options. lint -> RCS_lint
- *
- * Revision 5.11 1992/01/06 02:42:34 eggert
- * Update usage string.
- *
- * Revision 5.10 1991/10/07 17:32:46 eggert
- * Remove lint.
- *
- * Revision 5.9 1991/08/19 03:13:55 eggert
- * Add RCSINIT, -r$. Tune.
- *
- * Revision 5.8 1991/04/21 11:58:21 eggert
- * Add -x, RCSINIT, MS-DOS support.
- *
- * Revision 5.7 1990/12/13 06:54:07 eggert
- * GNU diff 1.15 has -u.
- *
- * Revision 5.6 1990/11/01 05:03:39 eggert
- * Remove unneeded setid check.
- *
- * Revision 5.5 1990/10/04 06:30:19 eggert
- * Accumulate exit status across files.
- *
- * Revision 5.4 1990/09/27 01:31:43 eggert
- * Yield 1, not EXIT_FAILURE, when diffs are found.
- *
- * Revision 5.3 1990/09/11 02:41:11 eggert
- * Simplify -kkvl test.
- *
- * Revision 5.2 1990/09/04 17:07:19 eggert
- * Diff's argv was too small by 1.
- *
- * Revision 5.1 1990/08/29 07:13:55 eggert
- * Add -kkvl.
- *
- * Revision 5.0 1990/08/22 08:12:46 eggert
- * Add -k, -V. Don't use access(). Add setuid support.
- * Remove compile-time limits; use malloc instead.
- * Don't pass arguments with leading '+' to diff; GNU DIFF treats them as options.
- * Add GNU diff's flags. Make lock and temp files faster and safer.
- * Ansify and Posixate.
- *
- * Revision 4.6 89/05/01 15:12:27 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.5 88/08/09 19:12:41 eggert
- * Use execv(), not system(); yield exit status like diff(1)s; allow cc -R.
- *
- * Revision 4.4 87/12/18 11:37:46 narten
- * changes Jay Lepreau made in the 4.3 BSD version, to add support for
- * "-i", "-w", and "-t" flags and to permit flags to be bundled together,
- * merged in.
- *
- * Revision 4.3 87/10/18 10:31:42 narten
- * Updating version numbers. Changes relative to 1.1 actually
- * relative to 4.1
- *
- * Revision 1.3 87/09/24 13:59:21 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:15 jenkins
- * Port to suns
- *
- * Revision 4.1 83/05/03 22:13:19 wft
- * Added default branch, option -q, exit status like diff.
- * Added fterror() to replace faterror().
- *
- * Revision 3.6 83/01/15 17:52:40 wft
- * Expanded mainprogram to handle multiple RCS files.
- *
- * Revision 3.5 83/01/06 09:33:45 wft
- * Fixed passing of -c (context) option to diff.
- *
- * Revision 3.4 82/12/24 15:28:38 wft
- * Added call to catchsig().
- *
- * Revision 3.3 82/12/10 16:08:17 wft
- * Corrected checking of return code from diff; improved error msgs.
- *
- * Revision 3.2 82/12/04 13:20:09 wft
- * replaced getdelta() with gettree(). Changed diagnostics.
- *
- * Revision 3.1 82/11/28 19:25:04 wft
- * Initial revision.
- *
- */
-#include "rcsbase.h"
-
-#if DIFF_L
-static char const *setup_label P((struct buf*,char const*,char const[datesize]));
-#endif
-static void cleanup P((void));
-
-static int exitstatus;
-static RILE *workptr;
-static struct stat workstat;
-
-mainProg(rcsdiffId, "rcsdiff", "$Id$")
-{
- static char const cmdusage[] =
- "\nrcsdiff usage: rcsdiff -ksubst -q -rrev1 [-rrev2] -Vn -xsuff -zzone [diff options] file ...";
-
- int revnums; /* counter for revision numbers given */
- char const *rev1, *rev2; /* revision numbers from command line */
- char const *xrev1, *xrev2; /* expanded revision numbers */
- char const *expandarg, *lexpandarg, *suffixarg, *versionarg, *zonearg;
-#if DIFF_L
- static struct buf labelbuf[2];
- int file_labels;
- char const **diff_label1, **diff_label2;
- char date2[datesize];
-#endif
- char const *cov[10 + !DIFF_L];
- char const **diffv, **diffp, **diffpend; /* argv for subsidiary diff */
- char const **pp, *p, *diffvstr;
- struct buf commarg;
- struct buf numericrev; /* expanded revision number */
- struct hshentries *gendeltas; /* deltas to be generated */
- struct hshentry * target;
- char *a, *dcp, **newargv;
- int no_diff_means_no_output;
- register c;
-
- exitstatus = DIFF_SUCCESS;
-
- bufautobegin(&commarg);
- bufautobegin(&numericrev);
- revnums = 0;
- rev1 = rev2 = xrev2 = 0;
-#if DIFF_L
- file_labels = 0;
-#endif
- expandarg = suffixarg = versionarg = zonearg = 0;
- no_diff_means_no_output = true;
- suffixes = X_DEFAULT;
-
- /*
- * Room for runv extra + args [+ --binary] [+ 2 labels]
- * + 1 file + 1 trailing null.
- */
- diffv = tnalloc(char const*, 1 + argc + !!OPEN_O_BINARY + 2*DIFF_L + 2);
- diffp = diffv + 1;
- *diffp++ = DIFF;
-
- argc = getRCSINIT(argc, argv, &newargv);
- argv = newargv;
- while (a = *++argv, 0<--argc && *a++=='-') {
- dcp = a;
- while ((c = *a++)) switch (c) {
- case 'r':
- switch (++revnums) {
- case 1: rev1=a; break;
- case 2: rev2=a; break;
- default: error("too many revision numbers");
- }
- goto option_handled;
- case '-': case 'D':
- no_diff_means_no_output = false;
- /* fall into */
- case 'C': case 'F': case 'I': case 'L': case 'W':
-#if DIFF_L
- if (c == 'L' && file_labels++ == 2)
- faterror("too many -L options");
-#endif
- *dcp++ = c;
- if (*a)
- do *dcp++ = *a++;
- while (*a);
- else {
- if (!--argc)
- faterror("-%c needs following argument%s",
- c, cmdusage
- );
- *diffp++ = *argv++;
- }
- break;
- case 'y':
- no_diff_means_no_output = false;
- /* fall into */
- case 'B': case 'H':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'h': case 'i': case 'n': case 'p':
- case 't': case 'u': case 'w':
- *dcp++ = c;
- break;
- case 'q':
- quietflag=true;
- break;
- case 'x':
- suffixarg = *argv;
- suffixes = *argv + 2;
- goto option_handled;
- case 'z':
- zonearg = *argv;
- zone_set(*argv + 2);
- goto option_handled;
- case 'T':
- /* Ignore -T, so that RCSINIT can contain -T. */
- if (*a)
- goto unknown;
- break;
- case 'V':
- versionarg = *argv;
- setRCSversion(versionarg);
- goto option_handled;
- case 'k':
- expandarg = *argv;
- if (0 <= str2expmode(expandarg+2))
- goto option_handled;
- /* fall into */
- default:
- unknown:
- error("unknown option: %s%s", *argv, cmdusage);
- };
- option_handled:
- if (dcp != *argv+1) {
- *dcp = 0;
- *diffp++ = *argv;
- }
- } /* end of option processing */
-
- for (pp = diffv+2, c = 0; pp<diffp; )
- c += strlen(*pp++) + 1;
- diffvstr = a = tnalloc(char, c + 1);
- for (pp = diffv+2; pp<diffp; ) {
- p = *pp++;
- *a++ = ' ';
- while ((*a = *p++))
- a++;
- }
- *a = 0;
-
-#if DIFF_L
- diff_label1 = diff_label2 = 0;
- if (file_labels < 2) {
- if (!file_labels)
- diff_label1 = diffp++;
- diff_label2 = diffp++;
- }
-#endif
- diffpend = diffp;
-
- cov[1] = CO;
- cov[2] = "-q";
-# if !DIFF_L
- cov[3] = "-M";
-# endif
-
- /* Now handle all pathnames. */
- if (nerror)
- cleanup();
- else if (argc < 1)
- faterror("no input file%s", cmdusage);
- else
- for (; 0 < argc; cleanup(), ++argv, --argc) {
- ffree();
-
- if (pairnames(argc, argv, rcsreadopen, true, false) <= 0)
- continue;
- diagnose("===================================================================\nRCS file: %s\n",RCSname);
- if (!rev2) {
- /* Make sure work file is readable, and get its status. */
- if (!(workptr = Iopen(workname, FOPEN_R_WORK, &workstat))) {
- eerror(workname);
- continue;
- }
- }
-
-
- gettree(); /* reads in the delta tree */
-
- if (!Head) {
- rcserror("no revisions present");
- continue;
- }
- if (revnums==0 || !*rev1)
- rev1 = Dbranch ? Dbranch : Head->num;
-
- if (!fexpandsym(rev1, &numericrev, workptr)) continue;
- if (!(target=genrevs(numericrev.string,(char *)0,(char *)0,(char *)0,&gendeltas))) continue;
- xrev1=target->num;
-#if DIFF_L
- if (diff_label1)
- *diff_label1 = setup_label(&labelbuf[0], target->num, target->date);
-#endif
-
- lexpandarg = expandarg;
- if (revnums==2) {
- if (!fexpandsym(
- *rev2 ? rev2 : Dbranch ? Dbranch : Head->num,
- &numericrev,
- workptr
- ))
- continue;
- if (!(target=genrevs(numericrev.string,(char *)0,(char *)0,(char *)0,&gendeltas))) continue;
- xrev2=target->num;
- if (no_diff_means_no_output && xrev1 == xrev2)
- continue;
- } else if (
- target->lockedby
- && !lexpandarg
- && Expand == KEYVAL_EXPAND
- && WORKMODE(RCSstat.st_mode,true) == workstat.st_mode
- )
- lexpandarg = "-kkvl";
- Izclose(&workptr);
-#if DIFF_L
- if (diff_label2)
- if (revnums == 2)
- *diff_label2 = setup_label(&labelbuf[1], target->num, target->date);
- else {
- time2date(workstat.st_mtime, date2);
- *diff_label2 = setup_label(&labelbuf[1], (char*)0, date2);
- }
-#endif
-
- diagnose("retrieving revision %s\n", xrev1);
- bufscpy(&commarg, "-p");
- bufscat(&commarg, rev1); /* not xrev1, for $Name's sake */
-
- pp = &cov[3 + !DIFF_L];
- *pp++ = commarg.string;
- if (lexpandarg) *pp++ = lexpandarg;
- if (suffixarg) *pp++ = suffixarg;
- if (versionarg) *pp++ = versionarg;
- if (zonearg) *pp++ = zonearg;
- *pp++ = RCSname;
- *pp = 0;
-
- diffp = diffpend;
-# if OPEN_O_BINARY
- if (Expand == BINARY_EXPAND)
- *diffp++ = "--binary";
-# endif
- diffp[0] = maketemp(0);
- if (runv(-1, diffp[0], cov)) {
- rcserror("co failed");
- continue;
- }
- if (!rev2) {
- diffp[1] = workname;
- if (*workname == '-') {
- char *dp = ftnalloc(char, strlen(workname)+3);
- diffp[1] = dp;
- *dp++ = '.';
- *dp++ = SLASH;
- VOID strcpy(dp, workname);
- }
- } else {
- diagnose("retrieving revision %s\n",xrev2);
- bufscpy(&commarg, "-p");
- bufscat(&commarg, rev2); /* not xrev2, for $Name's sake */
- cov[3 + !DIFF_L] = commarg.string;
- diffp[1] = maketemp(1);
- if (runv(-1, diffp[1], cov)) {
- rcserror("co failed");
- continue;
- }
- }
- if (!rev2)
- diagnose("diff%s -r%s %s\n", diffvstr, xrev1, workname);
- else
- diagnose("diff%s -r%s -r%s\n", diffvstr, xrev1, xrev2);
-
- diffp[2] = 0;
- switch (runv(-1, (char*)0, diffv)) {
- case DIFF_SUCCESS:
- break;
- case DIFF_FAILURE:
- if (exitstatus == DIFF_SUCCESS)
- exitstatus = DIFF_FAILURE;
- break;
- default:
- workerror("diff failed");
- }
- }
-
- tempunlink();
- exitmain(exitstatus);
-}
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = DIFF_TROUBLE;
- Izclose(&finptr);
- Izclose(&workptr);
-}
-
-#if RCS_lint
-# define exiterr rdiffExit
-#endif
- void
-exiterr()
-{
- tempunlink();
- _exit(DIFF_TROUBLE);
-}
-
-#if DIFF_L
- static char const *
-setup_label(b, num, date)
- struct buf *b;
- char const *num;
- char const date[datesize];
-{
- char *p;
- char datestr[datesize + zonelenmax];
- VOID date2str(date, datestr);
- bufalloc(b,
- strlen(workname)
- + sizeof datestr + 4
- + (num ? strlen(num) : 0)
- );
- p = b->string;
- if (num)
- VOID sprintf(p, "-L%s\t%s\t%s", workname, datestr, num);
- else
- VOID sprintf(p, "-L%s\t%s", workname, datestr);
- return p;
-}
-#endif
diff --git a/gnu/usr.bin/rcs/rcsfreeze/Makefile b/gnu/usr.bin/rcs/rcsfreeze/Makefile
deleted file mode 100644
index a71f9d7..0000000
--- a/gnu/usr.bin/rcs/rcsfreeze/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-MAN1= rcsfreeze.1
-
-afterinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/rcsfreeze.sh ${DESTDIR}${BINDIR}/rcsfreeze
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.1 b/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.1
deleted file mode 100644
index 69ca60b..0000000
--- a/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.1
+++ /dev/null
@@ -1,68 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id$
-.ds r \s-1RCS\s0
-.TH RCSFREEZE 1 \*(Dt GNU
-.SH NAME
-rcsfreeze \- freeze a configuration of sources checked in under RCS
-.SH SYNOPSIS
-.B rcsfreeze
-.RI [ "name" ]
-.SH DESCRIPTION
-.B rcsfreeze
-assigns a symbolic revision
-number to a set of \*r files that form a valid configuration.
-.PP
-The idea is to run
-.B rcsfreeze
-each time a new version is checked
-in. A unique symbolic name (\c
-.BI C_ number,
-where
-.I number
-is increased each time
-.B rcsfreeze
-is run) is then assigned to the most
-recent revision of each \*r file of the main trunk.
-.PP
-An optional
-.I name
-argument to
-.B rcsfreeze
-gives a symbolic name to the configuration.
-The unique identifier is still generated
-and is listed in the log file but it will not appear as
-part of the symbolic revision name in the actual \*r files.
-.PP
-A log message is requested from the user for future reference.
-.PP
-The shell script works only on all \*r files at one time.
-All changed files must be checked in already.
-Run
-.IR rcsclean (1)
-first and see whether any sources remain in the current directory.
-.SH FILES
-.TP
-.B RCS/.rcsfreeze.ver
-version number
-.TP
-.B RCS/.rcsfreeze.log
-log messages, most recent first
-.SH AUTHOR
-Stephan v. Bechtolsheim
-.SH "SEE ALSO"
-co(1), rcs(1), rcsclean(1), rlog(1)
-.SH BUGS
-.B rcsfreeze
-does not check whether any sources are checked out and modified.
-.PP
-Although both source file names and RCS file names are accepted,
-they are not paired as usual with RCS commands.
-.PP
-Error checking is rudimentary.
-.PP
-.B rcsfreeze
-is just an optional example shell script, and should not be taken too seriously.
-See \s-1CVS\s0 for a more complete solution.
diff --git a/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh b/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh
deleted file mode 100644
index 4c3945e..0000000
--- a/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh
+++ /dev/null
@@ -1,99 +0,0 @@
-#! /bin/sh
-
-# rcsfreeze - assign a symbolic revision number to a configuration of RCS files
-
-# $Id$
-
-# The idea is to run rcsfreeze each time a new version is checked
-# in. A unique symbolic revision number (C_[number], where number
-# is increased each time rcsfreeze is run) is then assigned to the most
-# recent revision of each RCS file of the main trunk.
-#
-# If the command is invoked with an argument, then this
-# argument is used as the symbolic name to freeze a configuration.
-# The unique identifier is still generated
-# and is listed in the log file but it will not appear as
-# part of the symbolic revision name in the actual RCS file.
-#
-# A log message is requested from the user which is saved for future
-# references.
-#
-# The shell script works only on all RCS files at one time.
-# It is important that all changed files are checked in (there are
-# no precautions against any error in this respect).
-# file names:
-# {RCS/}.rcsfreeze.ver version number
-# {RCS/}.rscfreeze.log log messages, most recent first
-
-PATH=/bin:/usr/bin:$PATH
-export PATH
-
-DATE=`LC_TIME=C date` || exit
-# Check whether we have an RCS subdirectory, so we can have the right
-# prefix for our paths.
-if test -d RCS
-then RCSDIR=RCS/ EXT=
-else RCSDIR= EXT=,v
-fi
-
-# Version number stuff, log message file
-VERSIONFILE=${RCSDIR}.rcsfreeze.ver
-LOGFILE=${RCSDIR}.rcsfreeze.log
-# Initialize, rcsfreeze never run before in the current directory
-test -r $VERSIONFILE || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit
-
-# Get Version number, increase it, write back to file.
-VERSIONNUMBER=`cat $VERSIONFILE` &&
-VERSIONNUMBER=`expr $VERSIONNUMBER + 1` &&
-echo $VERSIONNUMBER >$VERSIONFILE || exit
-
-# Symbolic Revision Number
-SYMREV=C_$VERSIONNUMBER
-# Allow the user to give a meaningful symbolic name to the revision.
-SYMREVNAME=${1-$SYMREV}
-echo >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\"
-rcsfreeze: symbolic revision number used: \"${SYMREVNAME}\"
-rcsfreeze: the two differ only when rcsfreeze invoked with argument
-rcsfreeze: give log message, summarizing changes (end with EOF or single '.')" \
- || exit
-
-# Stamp the logfile. Because we order the logfile the most recent
-# first we will have to save everything right now in a temporary file.
-TMPLOG=/tmp/rcsfrz$$
-trap 'rm -f $TMPLOG; exit 1' 1 2 13 15
-# Now ask for a log message, continously add to the log file
-(
- echo "Version: $SYMREVNAME($SYMREV), Date: $DATE
------------" || exit
- while read MESS
- do
- case $MESS in
- .) break
- esac
- echo " $MESS" || exit
- done
- echo "-----------
-" &&
- cat $LOGFILE
-) >$TMPLOG &&
-
-# combine old and new logfiles
-cp $TMPLOG $LOGFILE &&
-rm -f $TMPLOG &&
-
-# Now the real work begins by assigning a symbolic revision number
-# to each rcs file. Take the most recent version on the default branch.
-
-# If there are any .*,v files, throw them in too.
-# But ignore RCS/.* files that do not end in ,v.
-DOTFILES=
-for DOTFILE in ${RCSDIR}.*,v
-do
- if test -f "$DOTFILE"
- then
- DOTFILES="${RCSDIR}.*,v"
- break
- fi
-done
-
-exec rcs -q -n$SYMREVNAME: ${RCSDIR}*$EXT $DOTFILES
diff --git a/gnu/usr.bin/rcs/rcsmerge/Makefile b/gnu/usr.bin/rcs/rcsmerge/Makefile
deleted file mode 100644
index 9fd8afa..0000000
--- a/gnu/usr.bin/rcs/rcsmerge/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG= rcsmerge
-SRCS= rcsmerge.c
-CFLAGS+= -I${.CURDIR}/../lib
-LDADD= ${LIBRCS}
-DPADD= ${LIBRCS}
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/rcs/rcsmerge/rcsmerge.1 b/gnu/usr.bin/rcs/rcsmerge/rcsmerge.1
deleted file mode 100644
index d962c22..0000000
--- a/gnu/usr.bin/rcs/rcsmerge/rcsmerge.1
+++ /dev/null
@@ -1,189 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id$
-.ds r \&\s-1RCS\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.TH RCSMERGE 1 \*(Dt GNU
-.SH NAME
-rcsmerge \- merge RCS revisions
-.SH SYNOPSIS
-.B rcsmerge
-.RI [ options ] " file"
-.SH DESCRIPTION
-.B rcsmerge
-incorporates the changes between two revisions
-of an \*r file into the corresponding working file.
-.PP
-Pathnames matching an \*r suffix denote \*r files;
-all others denote working files.
-Names are paired as explained in
-.BR ci (1).
-.PP
-At least one revision must be specified with one of the options
-described below, usually
-.BR \-r .
-At most two revisions may be specified.
-If only one revision is specified, the latest
-revision on the default branch (normally the highest branch on the trunk)
-is assumed for the second revision.
-Revisions may be specified numerically or symbolically.
-.PP
-.B rcsmerge
-prints a warning if there are overlaps, and delimits
-the overlapping regions as explained in
-.BR merge (1).
-The command is useful for incorporating changes into a checked-out revision.
-.SH OPTIONS
-.TP
-.B \-A
-Output conflicts using the
-.B \-A
-style of
-.BR diff3 (1),
-if supported by
-.BR diff3 .
-This merges all changes leading from
-.I file2
-to
-.I file3
-into
-.IR file1 ,
-and generates the most verbose output.
-.TP
-\f3\-E\fP, \f3\-e\fP
-These options specify conflict styles that generate less information
-than
-.BR \-A .
-See
-.BR diff3 (1)
-for details.
-The default is
-.BR \-E .
-With
-.BR \-e ,
-.B rcsmerge
-does not warn about conflicts.
-.TP
-.BI \-k subst
-Use
-.I subst
-style keyword substitution.
-See
-.BR co (1)
-for details.
-For example,
-.B "\-kk\ \-r1.1\ \-r1.2"
-ignores differences in keyword values when merging the changes from
-.B 1.1
-to
-.BR 1.2 .
-It normally does not make sense to merge binary files as if they were text, so
-.B rcsmerge
-refuses to merge files if
-.B \-kb
-expansion is used.
-.TP
-.BR \-p [\f2rev\fP]
-Send the result to standard output instead of overwriting the working file.
-.TP
-.BR \-q [\f2rev\fP]
-Run quietly; do not print diagnostics.
-.TP
-.BR \-r [\f2rev\fP]
-Merge with respect to revision
-.IR rev .
-Here an empty
-.I rev
-stands for the latest revision on the default branch, normally the head.
-.TP
-.B \-T
-This option has no effect;
-it is present for compatibility with other \*r commands.
-.TP
-.BI \-V
-Print \*r's version number.
-.TP
-.BI \-V n
-Emulate \*r version
-.IR n .
-See
-.BR co (1)
-for details.
-.TP
-.BI \-x "suffixes"
-Use
-.I suffixes
-to characterize \*r files.
-See
-.BR ci (1)
-for details.
-.TP
-.BI \-z zone
-Use
-.I zone
-as the time zone for keyword substitution.
-See
-.BR co (1)
-for details.
-.SH EXAMPLES
-Suppose you have released revision 2.8 of
-.BR f.c .
-Assume
-furthermore that after you complete an unreleased revision 3.4, you receive
-updates to release 2.8 from someone else.
-To combine the updates to 2.8 and your changes between 2.8 and 3.4,
-put the updates to 2.8 into file f.c and execute
-.LP
-.B " rcsmerge \-p \-r2.8 \-r3.4 f.c >f.merged.c"
-.PP
-Then examine
-.BR f.merged.c .
-Alternatively, if you want to save the updates to 2.8 in the \*r file,
-check them in as revision 2.8.1.1 and execute
-.BR "co \-j":
-.LP
-.B " ci \-r2.8.1.1 f.c"
-.br
-.B " co \-r3.4 \-j2.8:2.8.1.1 f.c"
-.PP
-As another example, the following command undoes the changes
-between revision 2.4 and 2.8 in your currently checked out revision
-in
-.BR f.c .
-.LP
-.B " rcsmerge \-r2.8 \-r2.4 f.c"
-.PP
-Note the order of the arguments, and that
-.B f.c
-will be
-overwritten.
-.SH ENVIRONMENT
-.TP
-.B \s-1RCSINIT\s0
-options prepended to the argument list, separated by spaces.
-See
-.BR ci (1)
-for details.
-.SH DIAGNOSTICS
-Exit status is 0 for no overlaps, 1 for some overlaps, 2 for trouble.
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert.
-.SH "SEE ALSO"
-ci(1), co(1), ident(1), merge(1), rcs(1), rcsdiff(1), rcsintro(1), rlog(1),
-rcsfile(5)
-.br
-Walter F. Tichy,
-\*r\*-A System for Version Control,
-.I "Software\*-Practice & Experience"
-.BR 15 ,
-7 (July 1985), 637-654.
-.br
diff --git a/gnu/usr.bin/rcs/rcsmerge/rcsmerge.c b/gnu/usr.bin/rcs/rcsmerge/rcsmerge.c
deleted file mode 100644
index 7555343..0000000
--- a/gnu/usr.bin/rcs/rcsmerge/rcsmerge.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/* Merge RCS revisions. */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.15 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.14 1995/06/01 16:23:43 eggert
- * (main): Report an error if -kb, so don't worry about binary stdout.
- * Punctuate messages properly. Rewrite to avoid `goto end'.
- *
- * Revision 5.13 1994/03/17 14:05:48 eggert
- * Specify subprocess input via file descriptor, not file name. Remove lint.
- *
- * Revision 5.12 1993/11/09 17:40:15 eggert
- * -V now prints version on stdout and exits. Don't print usage twice.
- *
- * Revision 5.11 1993/11/03 17:42:27 eggert
- * Add -A, -E, -e, -z. Ignore -T. Allow up to three file labels.
- * Pass -Vn to `co'. Pass unexpanded revision name to `co', so that Name works.
- *
- * Revision 5.10 1992/07/28 16:12:44 eggert
- * Add -V.
- *
- * Revision 5.9 1992/01/24 18:44:19 eggert
- * lint -> RCS_lint
- *
- * Revision 5.8 1992/01/06 02:42:34 eggert
- * Update usage string.
- *
- * Revision 5.7 1991/11/20 17:58:09 eggert
- * Don't Iopen(f, "r+"); it's not portable.
- *
- * Revision 5.6 1991/08/19 03:13:55 eggert
- * Add -r$. Tune.
- *
- * Revision 5.5 1991/04/21 11:58:27 eggert
- * Add -x, RCSINIT, MS-DOS support.
- *
- * Revision 5.4 1991/02/25 07:12:43 eggert
- * Merging a revision to itself is no longer an error.
- *
- * Revision 5.3 1990/11/01 05:03:50 eggert
- * Remove unneeded setid check.
- *
- * Revision 5.2 1990/09/04 08:02:28 eggert
- * Check for I/O error when reading working file.
- *
- * Revision 5.1 1990/08/29 07:14:04 eggert
- * Add -q. Pass -L options to merge.
- *
- * Revision 5.0 1990/08/22 08:13:41 eggert
- * Propagate merge's exit status.
- * Remove compile-time limits; use malloc instead.
- * Make lock and temp files faster and safer. Ansify and Posixate. Add -V.
- * Don't use access(). Tune.
- *
- * Revision 4.5 89/05/01 15:13:16 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.4 88/08/09 19:13:13 eggert
- * Beware merging into a readonly file.
- * Beware merging a revision to itself (no change).
- * Use execv(), not system(); yield exit status like diff(1)'s.
- *
- * Revision 4.3 87/10/18 10:38:02 narten
- * Updating version numbers. Changes relative to version 1.1
- * actually relative to 4.1
- *
- * Revision 1.3 87/09/24 14:00:31 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:36 jenkins
- * Port to suns
- *
- * Revision 4.1 83/03/28 11:14:57 wft
- * Added handling of default branch.
- *
- * Revision 3.3 82/12/24 15:29:00 wft
- * Added call to catchsig().
- *
- * Revision 3.2 82/12/10 21:32:02 wft
- * Replaced getdelta() with gettree(); improved error messages.
- *
- * Revision 3.1 82/11/28 19:27:44 wft
- * Initial revision.
- *
- */
-#include "rcsbase.h"
-
-static char const co[] = CO;
-
-mainProg(rcsmergeId, "rcsmerge", "$Id$")
-{
- static char const cmdusage[] =
- "\nrcsmerge usage: rcsmerge -rrev1 [-rrev2] -ksubst -{pq}[rev] -Vn -xsuff -zzone file";
- static char const quietarg[] = "-q";
-
- register int i;
- char *a, **newargv;
- char const *arg[3];
- char const *rev[3], *xrev[3]; /*revision numbers*/
- char const *edarg, *expandarg, *suffixarg, *versionarg, *zonearg;
- int tostdout;
- int status;
- RILE *workptr;
- struct buf commarg;
- struct buf numericrev; /* holds expanded revision number */
- struct hshentries *gendeltas; /* deltas to be generated */
- struct hshentry * target;
-
- bufautobegin(&commarg);
- bufautobegin(&numericrev);
- edarg = rev[1] = rev[2] = 0;
- status = 0; /* Keep lint happy. */
- tostdout = false;
- expandarg = suffixarg = versionarg = zonearg = quietarg; /* no-op */
- suffixes = X_DEFAULT;
-
- argc = getRCSINIT(argc, argv, &newargv);
- argv = newargv;
- while (a = *++argv, 0<--argc && *a++=='-') {
- switch (*a++) {
- case 'p':
- tostdout=true;
- goto revno;
-
- case 'q':
- quietflag = true;
- revno:
- if (!*a)
- break;
- /* falls into -r */
- case 'r':
- if (!rev[1])
- rev[1] = a;
- else if (!rev[2])
- rev[2] = a;
- else
- error("too many revision numbers");
- break;
-
- case 'A': case 'E': case 'e':
- if (*a)
- goto unknown;
- edarg = *argv;
- break;
-
- case 'x':
- suffixarg = *argv;
- suffixes = a;
- break;
- case 'z':
- zonearg = *argv;
- zone_set(a);
- break;
- case 'T':
- /* Ignore -T, so that RCSINIT can contain -T. */
- if (*a)
- goto unknown;
- break;
- case 'V':
- versionarg = *argv;
- setRCSversion(versionarg);
- break;
-
- case 'k':
- expandarg = *argv;
- if (0 <= str2expmode(expandarg+2))
- break;
- /* fall into */
- default:
- unknown:
- error("unknown option: %s%s", *argv, cmdusage);
- };
- } /* end of option processing */
-
- if (!rev[1]) faterror("no base revision number given");
-
- /* Now handle all pathnames. */
-
- if (!nerror) {
- if (argc < 1)
- faterror("no input file%s", cmdusage);
- if (0 < pairnames(argc, argv, rcsreadopen, true, false)) {
-
- if (argc>2 || (argc==2 && argv[1]))
- warn("excess arguments ignored");
- if (Expand == BINARY_EXPAND)
- workerror("merging binary files");
- diagnose("RCS file: %s\n", RCSname);
- if (!(workptr = Iopen(workname, FOPEN_R_WORK, (struct stat*)0)))
- efaterror(workname);
-
- gettree(); /* reads in the delta tree */
-
- if (!Head) rcsfaterror("no revisions present");
-
- if (!*rev[1])
- rev[1] = Dbranch ? Dbranch : Head->num;
- if (fexpandsym(rev[1], &numericrev, workptr)
- && (target=genrevs(numericrev.string, (char *)0, (char *)0, (char*)0, &gendeltas))
- ) {
- xrev[1] = target->num;
- if (!rev[2] || !*rev[2])
- rev[2] = Dbranch ? Dbranch : Head->num;
- if (fexpandsym(rev[2], &numericrev, workptr)
- && (target=genrevs(numericrev.string, (char *)0, (char *)0, (char *)0, &gendeltas))
- ) {
- xrev[2] = target->num;
-
- if (strcmp(xrev[1],xrev[2]) == 0) {
- if (tostdout) {
- fastcopy(workptr, stdout);
- Ofclose(stdout);
- }
- } else {
- Izclose(&workptr);
-
- for (i=1; i<=2; i++) {
- diagnose("retrieving revision %s\n", xrev[i]);
- bufscpy(&commarg, "-p");
- bufscat(&commarg, rev[i]); /* not xrev[i], for $Name's sake */
- if (run(
- -1,
- /* Do not collide with merger.c maketemp(). */
- arg[i] = maketemp(i+2),
- co, quietarg, commarg.string,
- expandarg, suffixarg, versionarg, zonearg,
- RCSname, (char*)0
- ))
- rcsfaterror("co failed");
- }
- diagnose("Merging differences between %s and %s into %s%s\n",
- xrev[1], xrev[2], workname,
- tostdout?"; result to stdout":"");
-
- arg[0] = xrev[0] = workname;
- status = merge(tostdout, edarg, xrev, arg);
- }
- }
- }
-
- Izclose(&workptr);
- }
- }
- tempunlink();
- exitmain(nerror ? DIFF_TROUBLE : status);
-}
-
-#if RCS_lint
-# define exiterr rmergeExit
-#endif
- void
-exiterr()
-{
- tempunlink();
- _exit(DIFF_TROUBLE);
-}
diff --git a/gnu/usr.bin/rcs/rcstest b/gnu/usr.bin/rcs/rcstest
deleted file mode 100755
index 36b63e6..0000000
--- a/gnu/usr.bin/rcs/rcstest
+++ /dev/null
@@ -1,454 +0,0 @@
-#! /bin/sh
-
-# Test RCS's functions.
-# The RCS commands are searched for in the PATH as usual;
-# to test the working directory's commands, prepend . to your PATH.
-
-# Test RCS by creating files RCS/a.* and RCS/a.c.
-# If all goes well, output nothing, and remove the temporary files.
-# Otherwise, send a message to standard output.
-# Exit status is 0 if OK, 1 if an RCS bug is found, and 2 if scaffolding fails.
-# With the -v option, output more debugging info.
-
-# If diff outputs `No differences encountered' when comparing identical files,
-# then rcstest may also output these noise lines; ignore them.
-
-# The current directory and ./RCS must be readable, writable, and searchable.
-
-# $Id$
-
-
-# Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
-# Distributed under license by the Free Software Foundation, Inc.
-#
-# This file is part of RCS.
-#
-# RCS 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.
-#
-# RCS 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 RCS; see the file COPYING.
-# If not, write to the Free Software Foundation,
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Report problems and direct all questions to:
-#
-# rcs-bugs@cs.purdue.edu
-
-# The Makefile overrides the following defaults.
-: ${ALL_CFLAGS=-Dhas_conf_h}
-: ${CC=cc}
-: ${DIFF=diff}
-# : ${LDFLAGS=} ${LIBS=} tickles old shell bug
-
-CL="$CC $ALL_CFLAGS $LDFLAGS -o a.out"
-L=$LIBS
-
-RCSINIT=-x
-export RCSINIT
-
-SLASH=/
-RCSfile=RCS${SLASH}a.c
-RCS_alt=RCS${SLASH}a.d
-lockfile=RCS${SLASH}a._
-
-case $1 in
--v) q=; set -x;;
-'') q=-q;;
-*) echo >&2 "$0: usage: $0 [-v]"; exit 2
-esac
-
-if test -d RCS
-then rmdir=:
-else rmdir=rmdir; mkdir RCS || exit
-fi
-
-rm -f a.* $RCSfile $RCS_alt $lockfile &&
-echo 1.1 >a.11 &&
-echo 1.1.1.1 >a.3x1 &&
-echo 1.2 >a.12 || { echo "#initialization failed"; exit 2; }
-
-case "`$DIFF -c a.11 a.3x1`" in
-*!\ 1.1.1.1)
- diff="$DIFF -c";;
-*)
- echo "#warning: $DIFF -c does not work, so diagnostics may be cryptic"
- diff=$DIFF
-esac
-
-rcs -i -L -ta.11 $q a.c &&
-test -r $RCSfile || {
- echo "#rcs -i -L failed; perhaps RCS is not properly installed."
- exit 1
-}
-
-rlog a.c >/dev/null || { echo "#rlog failed on empty RCS file"; exit 1; }
-rm -f $RCSfile || exit 2
-
-cp a.11 a.c &&
-ci -ta.11 -mm $q a.c &&
-test -r $RCSfile &&
-rcs -L $q a.c || { echo "#ci+rcs -L failed"; exit 1; }
-test ! -f a.c || { echo "#ci did not remove working file"; exit 1; }
-for l in '' '-l'
-do
- co $l $q a.c &&
- test -f a.c || { echo '#co' $l did not create working file; exit 1; }
- $diff a.11 a.c || { echo '#ci' followed by co $l is not a no-op; exit 1; }
-done
-
-cp a.12 a.c &&
-ci -mm $q a.c &&
-co $q a.c &&
-$diff a.12 a.c || { echo "#ci+co failed"; exit 1; }
-
-rm -f a.c &&
-co -r1.1 $q a.c &&
-$diff a.11 a.c || { echo "#can't retrieve first revision"; exit 1; }
-
-rm -f a.c &&
-cp a.3x1 a.c &&
-ci -r1.1.1 -mm $q a.c &&
-co -r1.1.1.1 $q a.c &&
-$diff a.3x1 a.c || { echo "#branches failed"; exit 1; }
-
-rm -f a.c &&
-co -l $q a.c &&
-ci -f -mm $q a.c &&
-co -r1.3 $q a.c &&
-$diff a.12 a.c || { echo "#(co -l; ci -f) failed"; exit 1; }
-
-rm -f a.c &&
-co -l $q a.c &&
-echo 1.4 >a.c &&
-ci -l -mm $q a.c &&
-echo error >a.c &&
-ci -mm $q a.c || { echo "#ci -l failed"; exit 1; }
-
-rm -f a.c &&
-co -l $q a.c &&
-echo 1.5 >a.c &&
-ci -u -mm $q a.c &&
-test -r a.c || { echo "#ci -u didn't create a working file"; exit 1; }
-rm -f a.c &&
-echo error >a.c || exit 2
-ci -mm $q a.c 2>/dev/null && { echo "#ci -u didn't unlock the file"; exit 1; }
-
-rm -f a.c &&
-rcs -l $q a.c &&
-co -u $q a.c || { echo "#rcs -l + co -u failed"; exit 1; }
-rm -f a.c &&
-echo error >a.c || exit 2
-ci -mm $q a.c 2>/dev/null && { echo "#co -u didn't unlock the file"; exit 1; }
-
-rm -f a.c &&
-cp a.11 a.c &&
-co -f $q a.c || { echo "#co -f failed"; exit 1; }
-$diff a.11 a.c >/dev/null && { echo "#co -f had no effect"; exit 1; }
-
-co -p1.1 $q a.c >a.t &&
-$diff a.11 a.t || { echo "#co -p failed"; exit 1; }
-
-for n in n N
-do
- rm -f a.c &&
- co -l $q a.c &&
- echo $n >a.$n &&
- cp a.$n a.c &&
- ci -${n}n -mm $q a.c &&
- co -rn $q a.c &&
- $diff a.$n a.c || { echo "#ci -$n failed"; exit 1; }
-done
-
-case $LOGNAME in
-?*) me=$LOGNAME;;
-*)
- case $USER in
- ?*) me=$USER;;
- *)
- me=`who am i` || exit 2
- me=`echo "$me" | sed -e 's/ .*//' -e 's/.*!//'`
- case $me in
- '') echo >&2 "$0: cannot deduce user name"; exit 2
- esac
- esac
-esac
-
-
-# Get the date of the previous revision in UTC.
-date=`rlog -r a.c | sed -n '/^date: /{ s///; s/;.*//; p; q; }'` || exit
-case $date in
-[0-9][0-9][0-9]*[0-9]/[0-1][0-9]/[0-3][0-9]\ [0-2][0-9]:[0-5][0-9]:[0-6][0-9]);;
-*) echo >&2 "$0: $date: bad rlog date output"; exit 1
-esac
-PWD=`pwd` && export PWD &&
-rm -f a.c &&
-co -l $q a.c &&
-sed 's/@/$/g' >a.kv <<EOF
-@Author: w @
-@Date: $date @
-@Header: $PWD$SLASH$RCSfile 2.1 $date w s @
-@Id: a.c 2.1 $date w s @
-@Locker: @
- * @Log: a.c @
- * Revision 2.1 $date w
- * m
- *
-@Name: Oz @
-@RCSfile: a.c @
-@Revision: 2.1 @
-@Source: $PWD$SLASH$RCSfile @
-@State: s @
-EOF
-test $? = 0 &&
-sed 's/:.*\$/$/' a.kv >a.k &&
-sed -e 's/w s [$]/w s '"$me"' $/' -e 's/[$]Locker: /&'"$me/" a.kv >a.kvl &&
-sed s/Oz//g a.kv >a.e &&
-sed s/Oz/N/g a.kv >a.N &&
-sed -e '/\$/!d' -e 's/\$$/: old $/' a.k >a.o &&
-sed -e 's/\$[^ ]*: //' -e 's/ \$//' a.kv >a.v &&
-cp a.o a.c &&
-ci -d"$date" -nOz -ss -ww -u2.1 -mm $q a.c &&
-$diff a.kv a.c || { echo "#keyword expansion failed"; exit 1; }
-co -pOz -ko $q a.c >a.oo &&
-$diff a.o a.oo || { echo "#co -p -ko failed"; exit 1; }
-cp a.kv a.o && cp a.o a.b || exit 2
-rcs -oOz $q a.c &&
-rcs -l $q a.c &&
-ci -k -u $q a.c &&
-$diff a.kv a.c || { echo "#ci -k failed"; exit 1; }
-sed -n 's/^[^$]*\$/$/p' a.kv >a.i &&
-ident a.c >a.i1 &&
-sed -e 1d -e 's/^[ ]*//' a.i1 >a.i2 &&
-$diff a.i a.i2 || { echo "#ident failed"; exit 1; }
-
-rcs -i $q a.c 2>/dev/null && { echo "#rcs -i permitted existing file"; exit 1; }
-
-rm -f a.c &&
-co -l $q a.c &&
-echo 2.2 >a.c &&
-ci -mm $q a.c &&
-echo 1.1.1.2 >a.c &&
-rcs -l1.1.1 $q a.c &&
-ci -r1.1.1.2 -mm $q a.c &&
-rcs -b1.1.1 $q a.c &&
-test " `co -p $q a.c`" = ' 1.1.1.2' || { echo "#rcs -b1.1.1 failed"; exit 1; }
-rcs -b $q a.c &&
-test " `co -p $q a.c`" = ' 2.2' || { echo "#rcs -b failed"; exit 1; }
-
-echo 2.3 >a.c || exit 2
-rcs -U $q a.c || { echo "#rcs -U failed"; exit 1; }
-ci -mm $q a.c || { echo "#rcs -U didn't unset strict locking"; exit 1; }
-rcs -L $q a.c || { echo "#rcs -L failed"; exit 1; }
-echo error >a.c || exit 2
-ci -mm $q a.c 2>/dev/null && { echo "#ci retest failed"; exit 1; }
-
-rm -f a.c &&
-log0=`rlog -h a.c` &&
-co -l $q a.c &&
-ci -mm $q a.c &&
-log1=`rlog -h a.c` &&
-test " $log0" = " $log1" || { echo "#unchanged ci didn't revert"; exit 1; }
-
-rm -f a.c &&
-rcs -nN:1.1 $q a.c &&
-co -rN $q a.c &&
-$diff a.11 a.c || { echo "#rcs -n failed"; exit 1; }
-
-rm -f a.c &&
-rcs -NN:2.1 $q a.c &&
-co -rN $q a.c &&
-$diff a.N a.c || { echo "#rcs -N failed"; exit 1; }
-
-rm -f a.c &&
-co -l $q a.c &&
-echo ':::$''Log$' >a.c &&
-ci -u -mm $q a.c &&
-test " `sed '$!d' a.c`" = ' :::' || { echo "#comment leader failed"; exit 1; }
-
-rm -f a.c &&
-rcs -o2.2: $q a.c &&
-co $q a.c &&
-$diff a.e a.c || { echo "#rcs -o failed"; exit 1; }
-
-rcsdiff -r1.1 -rOz $q a.c >a.0
-case $? in
-1) ;;
-*) echo "#rcsdiff bad status"; exit 1
-esac
-$DIFF a.11 a.kv >a.1
-$diff a.0 a.1 || { echo "#rcsdiff failed"; exit 1; }
-
-rcs -l2.1 $q a.c || { echo "#rcs -l2.1 failed"; exit 1; }
-for i in b k kv kvl o v
-do
- rm -f a.c &&
- cp a.$i a.c &&
- rcsdiff -k$i -rOz $q a.c || { echo "#rcsdiff -k$i failed"; exit 1; }
-done
-co -p1.1 -ko $q a.c >a.t &&
-$diff a.11 a.t || { echo "#co -p1.1 -ko failed"; exit 1; }
-rcs -u2.1 $q a.c || { echo "#rcs -u2.1 failed"; exit 1; }
-
-rm -f a.c &&
-rcsclean $q a.c &&
-rcsclean -u $q a.c || { echo "#rcsclean botched a nonexistent file"; exit 1; }
-
-rm -f a.c &&
-co $q a.c &&
-rcsclean -n $q a.c &&
-rcsclean -n -u $q a.c &&
-test -f a.c || { echo "#rcsclean -n removed a file"; exit 1; }
-
-rm -f a.c &&
-co $q a.c &&
-rcsclean $q a.c &&
-test ! -f a.c || { echo "#rcsclean missed an unlocked file"; exit 1; }
-
-rm -f a.c &&
-co -l $q a.c &&
-rcsclean $q a.c &&
-test -f a.c || { echo "#rcsclean removed a locked file"; exit 1; }
-rcsclean -u $q a.c &&
-test ! -f a.c || {
- echo "#rcsclean -u missed an unchanged locked file"; exit 1;
-}
-
-rm -f a.c &&
-co -l $q a.c &&
-echo change >>a.c &&
-rcsclean $q a.c &&
-rcsclean $q -u a.c &&
-test -f a.c || { echo "#rcsclean removed a changed file"; exit 1; }
-
-rm -f a.c &&
-co -l $q a.c &&
-cat >a.c <<'EOF'
-2.2
-a
-b
-c
-d
-EOF
-test $? = 0 &&
-ci -l -mm $q a.c &&
-co -p2.2 $q a.c | sed -e s/2.2/2.3/ -e s/b/b1/ >a.c &&
-ci -l -mm $q a.c &&
-co -p2.2 $q a.c | sed -e s/2.2/new/ -e s/d/d1/ >a.c || exit 2
-cat >a.0 <<'EOF'
-2.3
-a
-b1
-c
-d1
-EOF
-cat >a.1 <<'EOF'
-<<<<<<< a.c
-new
-=======
-2.3
->>>>>>> 2.3
-a
-b1
-c
-d1
-EOF
-rcsmerge -E -r2.2 -r2.3 $q a.c
-case $? in
-0)
- if $diff a.0 a.c >/dev/null
- then echo "#warning: diff3 -E does not work, " \
- "so merge and rcsmerge ignore overlaps and suppress overlap lines."
- else
- $diff a.1 a.c || { echo "#rcsmerge failed (status 0)"; exit 1; }
- echo "#warning: The diff3 lib program exit status ignores overlaps," \
- "so rcsmerge does not warn about overlap lines that it generates."
- fi
- ;;
-1)
- $diff a.1 a.c || { echo "#rcsmerge failed (status 1)"; exit 1; }
- ;;
-*)
- echo "#rcsmerge bad status"; exit 1
-esac
-
-# Avoid `tr' if possible; it's not portable, and it can't handle null bytes.
-# Our substitute exclusive-ORs with '\n';
-# this ensures null bytes on output, which is even better than `tr',
-# since some diffs think a file is binary only if it contains null bytes.
-cat >a.c <<'EOF'
-#include <stdio.h>
-int main() {
- int c;
- while ((c=getchar()) != EOF)
- putchar(c ^ '\n');
- return 0;
-}
-EOF
-tr=tr
-if (rm -f a.exe a.out && $CL a.c $L >&2) >/dev/null 2>&1
-then
- if test -s a.out
- then tr=./a.out
- elif test -s a.exe
- then tr=./a.exe
- fi
-fi
-{
- co -p $q a.c | $tr '\012' '\200' >a.24 &&
- cp a.24 a.c &&
- ciOut=`(ci -l -mm $q a.c 2>&1)` &&
- case $ciOut in
- ?*) echo >&2 "$ciOut"
- esac &&
- co -p $q a.c | $tr '\200' '\012' >a.c &&
- rcsdiff -r2.3 $q a.c >/dev/null &&
-
- echo 2.5 >a.c &&
- ci -l -mm $q a.c &&
- cp a.24 a.c &&
- rcsdiff -r2.4 $q a.c >/dev/null
-} || echo "#warning: Traditional diff is used, so RCS is limited to text files."
-
-rcs -u -o2.4: $q a.c || { echo "#rcs -u -o failed"; exit 1; }
-
-rcs -i -Aa.c -t- $q a.d || { echo "#rcs -i -A failed"; exit 1; }
-
-rlog -r2.1 a.c >a.t &&
-grep '^checked in with -k' a.t >/dev/null &&
-sed '/^checked in with -k/d' a.t >a.u &&
-$diff - a.u <<EOF
-
-RCS file: $RCSfile
-Working file: a.c
-head: 2.3
-branch:
-locks: strict
-access list:
-symbolic names:
- N: 2.1
- Oz: 2.1
- n: 1.8
-keyword substitution: kv
-total revisions: 13; selected revisions: 1
-description:
-1.1
-----------------------------
-revision 2.1
-date: $date; author: w; state: s; lines: +14 -1
-=============================================================================
-EOF
-test $? = 0 || { echo "#rlog failed"; exit 1; }
-
-
-test ! -f $lockfile || { echo "#lock file not removed"; exit 1; }
-
-rm -f a.* $RCSfile $RCS_alt
-$rmdir RCS
diff --git a/gnu/usr.bin/rcs/rlog/Makefile b/gnu/usr.bin/rcs/rlog/Makefile
deleted file mode 100644
index bdbf68f..0000000
--- a/gnu/usr.bin/rcs/rlog/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG= rlog
-SRCS= rlog.c
-CFLAGS+= -I${.CURDIR}/../lib
-LDADD= ${LIBRCS}
-DPADD= ${LIBRCS}
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/rcs/rlog/rlog.1 b/gnu/usr.bin/rcs/rlog/rlog.1
deleted file mode 100644
index 953617c..0000000
--- a/gnu/usr.bin/rcs/rlog/rlog.1
+++ /dev/null
@@ -1,318 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id$
-.ds i \&\s-1ISO\s0
-.ds r \&\s-1RCS\s0
-.ds u \&\s-1UTC\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.TH RLOG 1 \*(Dt GNU
-.SH NAME
-rlog \- print log messages and other information about RCS files
-.SH SYNOPSIS
-.B rlog
-.RI [ " options " ] " file " .\|.\|.
-.SH DESCRIPTION
-.B rlog
-prints information about \*r files.
-.PP
-Pathnames matching an \*r suffix denote \*r files;
-all others denote working files.
-Names are paired as explained in
-.BR ci (1).
-.PP
-.B rlog
-prints the following information for each
-\*r file: \*r pathname, working pathname, head (i.e., the number
-of the latest revision on the trunk), default branch, access list, locks,
-symbolic names, suffix, total number of revisions,
-number of revisions selected for printing, and
-descriptive text. This is followed by entries for the selected revisions in
-reverse chronological order for each branch. For each revision,
-.B rlog
-prints revision number, author, date/time, state, number of
-lines added/deleted (with respect to the previous revision),
-locker of the revision (if any), and log message.
-All times are displayed in Coordinated Universal Time (\*u) by default;
-this can be overridden with
-.BR \-z .
-Without options,
-.B rlog
-prints complete information.
-The options below restrict this output.
-.nr n \w'\f3\-V\fP\f2n\fP'+2n-1/1n
-.ds n \nn
-.if \n(.g .if r an-tag-sep .ds n \w'\f3\-V\fP\f2n\fP'u+\n[an-tag-sep]u
-.TP \*n
-.B \-L
-Ignore \*r files that have no locks set.
-This is convenient in combination with
-.BR \-h ,
-.BR \-l ,
-and
-.BR \-R .
-.TP
-.B \-R
-Print only the name of the \*r file.
-This is convenient for translating a
-working pathname into an \*r pathname.
-.TP
-.BI \-v "[string]"
-Print only the working pathname and tip-revision.
-The optional string is prepended to the outputline.
-.TP
-.B \-h
-Print only the \*r pathname, working pathname, head,
-default branch, access list, locks,
-symbolic names, and suffix.
-.TP
-.B \-t
-Print the same as
-.BR \-h ,
-plus the descriptive text.
-.TP
-.B \-N
-Do not print the symbolic names.
-.TP
-.B \-b
-Print information about the revisions on the default branch, normally
-the highest branch on the trunk.
-.TP
-.BI \-d "dates"
-Print information about revisions with a checkin date/time in the ranges given by
-the semicolon-separated list of
-.IR dates .
-A range of the form
-.IB d1 < d2
-or
-.IB d2 > d1
-selects the revisions that were deposited between
-.I d1
-and
-.I d2
-exclusive.
-A range of the form
-.BI < d
-or
-.IB d >
-selects
-all revisions earlier than
-.IR d .
-A range of the form
-.IB d <
-or
-.BI > d
-selects
-all revisions dated later than
-.IR d .
-If
-.B <
-or
-.B >
-is followed by
-.B =
-then the ranges are inclusive, not exclusive.
-A range of the form
-.I d
-selects the single, latest revision dated
-.I d
-or earlier.
-The date/time strings
-.IR d ,
-.IR d1 ,
-and
-.I d2
-are in the free format explained in
-.BR co (1).
-Quoting is normally necessary, especially for
-.B <
-and
-.BR > .
-Note that the separator is
-a semicolon.
-.TP
-.BR \-l [\f2lockers\fP]
-Print information about locked revisions only.
-In addition, if the comma-separated list
-.I lockers
-of login names is given,
-ignore all locks other than those held by the
-.IR lockers .
-For example,
-.B "rlog\ \-L\ \-R\ \-lwft\ RCS/*"
-prints the name of \*r files locked by the user
-.BR wft .
-.TP
-.BR \-r [\f2revisions\fP]
-prints information about revisions given in the comma-separated list
-.I revisions
-of revisions and ranges.
-A range
-.IB rev1 : rev2
-means revisions
-.I rev1
-to
-.I rev2
-on the same branch,
-.BI : rev
-means revisions from the beginning of the branch up to and including
-.IR rev ,
-and
-.IB rev :
-means revisions starting with
-.I rev
-to the end of the branch containing
-.IR rev .
-An argument that is a branch means all
-revisions on that branch.
-A range of branches means all revisions
-on the branches in that range.
-A branch followed by a
-.B .\&
-means the latest revision in that branch.
-A bare
-.B \-r
-with no
-.I revisions
-means the latest revision on the default branch, normally the trunk.
-.TP
-.BI \-s states
-prints information about revisions whose state attributes match one of the
-states given in the comma-separated list
-.IR states .
-.TP
-.BR \-w [\f2logins\fP]
-prints information about revisions checked in by users with
-login names appearing in the comma-separated list
-.IR logins .
-If
-.I logins
-is omitted, the user's login is assumed.
-.TP
-.B \-T
-This option has no effect;
-it is present for compatibility with other \*r commands.
-.TP
-.BI \-V
-Print \*r's version number.
-.TP
-.BI \-V n
-Emulate \*r version
-.I n
-when generating logs.
-See
-.BR co (1)
-for more.
-.TP
-.BI \-x "suffixes"
-Use
-.I suffixes
-to characterize \*r files.
-See
-.BR ci (1)
-for details.
-.PP
-.B rlog
-prints the intersection of the revisions selected with
-the options
-.BR \-d ,
-.BR \-l ,
-.BR \-s ,
-and
-.BR \-w ,
-intersected
-with the union of the revisions selected by
-.B \-b
-and
-.BR \-r .
-.TP
-.BI \-z zone
-specifies the date output format,
-and specifies the default time zone for
-.I date
-in the
-.BI \-d dates
-option.
-The
-.I zone
-should be empty, a numeric \*u offset, or the special string
-.B LT
-for local time.
-The default is an empty
-.IR zone ,
-which uses the traditional \*r format of \*u without any time zone indication
-and with slashes separating the parts of the date;
-otherwise, times are output in \*i 8601 format with time zone indication.
-For example, if local time is January 11, 1990, 8pm Pacific Standard Time,
-eight hours west of \*u,
-then the time is output as follows:
-.RS
-.LP
-.RS
-.nf
-.ta \w'\f3\-z+05:30\fP 'u +\w'\f31990-01-11 09:30:00+05:30\fP 'u
-.ne 4
-\f2option\fP \f2time output\fP
-\f3\-z\fP \f31990/01/12 04:00:00\fP \f2(default)\fP
-\f3\-zLT\fP \f31990-01-11 20:00:00\-08\fP
-\f3\-z+05:30\fP \f31990-01-12 09:30:00+05:30\fP
-.ta 4n +4n +4n +4n
-.fi
-.RE
-.SH EXAMPLES
-.LP
-.nf
-.B " rlog \-L \-R RCS/*"
-.B " rlog \-L \-h RCS/*"
-.B " rlog \-L \-l RCS/*"
-.B " rlog RCS/*"
-.fi
-.LP
-The first command prints the names of all \*r files in the subdirectory
-.B RCS
-that have locks. The second command prints the headers of those files,
-and the third prints the headers plus the log messages of the locked revisions.
-The last command prints complete information.
-.SH ENVIRONMENT
-.TP
-.B \s-1RCSINIT\s0
-options prepended to the argument list, separated by spaces.
-See
-.BR ci (1)
-for details.
-.SH DIAGNOSTICS
-The exit status is zero if and only if all operations were successful.
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Manual Page Revision: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert.
-.SH "SEE ALSO"
-ci(1), co(1), ident(1), rcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1),
-rcsfile(5)
-.br
-Walter F. Tichy,
-\*r\*-A System for Version Control,
-.I "Software\*-Practice & Experience"
-.BR 15 ,
-7 (July 1985), 637-654.
-.SH BUGS
-The separator for revision ranges in the
-.B \-r
-option used to be
-.B \-
-instead of
-.BR : ,
-but this leads to confusion when symbolic names contain
-.BR \- .
-For backwards compatibility
-.B "rlog \-r"
-still supports the old
-.B \-
-separator, but it warns about this obsolete use.
-.br
diff --git a/gnu/usr.bin/rcs/rlog/rlog.c b/gnu/usr.bin/rcs/rlog/rlog.c
deleted file mode 100644
index 75e68c3..0000000
--- a/gnu/usr.bin/rcs/rlog/rlog.c
+++ /dev/null
@@ -1,1290 +0,0 @@
-/* Print log messages and other information about RCS files. */
-
-/* Copyright 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
-This file is part of RCS.
-
-RCS 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.
-
-RCS 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 RCS; see the file COPYING.
-If not, write to the Free Software Foundation,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * Revision 5.18 1995/06/16 06:19:24 eggert
- * Update FSF address.
- *
- * Revision 5.17 1995/06/01 16:23:43 eggert
- * (struct rcslockers): Renamed from `struct lockers'.
- * (getnumericrev): Return error indication instead of ignoring errors.
- * (main): Check it. Don't use dateform.
- * (recentdate, extdate): cmpnum -> cmpdate
- *
- * Revision 5.16 1994/04/13 16:30:34 eggert
- * Fix bug; `rlog -lxxx' inverted the sense of -l.
- *
- * Revision 5.15 1994/03/17 14:05:48 eggert
- * -d'<DATE' now excludes DATE; the new syntax -d'<=DATE' includes it.
- * Emulate -V4's white space generation more precisely.
- * Work around SVR4 stdio performance bug. Remove lint.
- *
- * Revision 5.14 1993/11/09 17:40:15 eggert
- * -V now prints version on stdout and exits.
- *
- * Revision 5.13 1993/11/03 17:42:27 eggert
- * Add -N, -z. Ignore -T.
- *
- * Revision 5.12 1992/07/28 16:12:44 eggert
- * Don't miss B.0 when handling branch B. Diagnose missing `,' in -r.
- * Add -V. Avoid `unsigned'. Statement macro names now end in _.
- *
- * Revision 5.11 1992/01/24 18:44:19 eggert
- * Don't duplicate unexpected_EOF's function. lint -> RCS_lint
- *
- * Revision 5.10 1992/01/06 02:42:34 eggert
- * Update usage string.
- * while (E) ; -> while (E) continue;
- *
- * Revision 5.9 1991/09/17 19:07:40 eggert
- * Getscript() didn't uncache partial lines.
- *
- * Revision 5.8 1991/08/19 03:13:55 eggert
- * Revision separator is `:', not `-'.
- * Check for missing and duplicate logs. Tune.
- * Permit log messages that do not end in newline (including empty logs).
- *
- * Revision 5.7 1991/04/21 11:58:31 eggert
- * Add -x, RCSINIT, MS-DOS support.
- *
- * Revision 5.6 1991/02/26 17:07:17 eggert
- * Survive RCS files with missing logs.
- * strsave -> str_save (DG/UX name clash)
- *
- * Revision 5.5 1990/11/01 05:03:55 eggert
- * Permit arbitrary data in logs and comment leaders.
- *
- * Revision 5.4 1990/10/04 06:30:22 eggert
- * Accumulate exit status across files.
- *
- * Revision 5.3 1990/09/11 02:41:16 eggert
- * Plug memory leak.
- *
- * Revision 5.2 1990/09/04 08:02:33 eggert
- * Count RCS lines better.
- *
- * Revision 5.0 1990/08/22 08:13:48 eggert
- * Remove compile-time limits; use malloc instead. Add setuid support.
- * Switch to GMT.
- * Report dates in long form, to warn about dates past 1999/12/31.
- * Change "added/del" message to make room for the longer dates.
- * Don't generate trailing white space. Add -V. Ansify and Posixate.
- *
- * Revision 4.7 89/05/01 15:13:48 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.6 88/08/09 19:13:28 eggert
- * Check for memory exhaustion; don't access freed storage.
- * Shrink stdio code size; remove lint.
- *
- * Revision 4.5 87/12/18 11:46:38 narten
- * more lint cleanups (Guy Harris)
- *
- * Revision 4.4 87/10/18 10:41:12 narten
- * Updating version numbers
- * Changes relative to 1.1 actually relative to 4.2
- *
- * Revision 1.3 87/09/24 14:01:10 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:45 jenkins
- * Port to suns
- *
- * Revision 4.2 83/12/05 09:18:09 wft
- * changed rewriteflag to external.
- *
- * Revision 4.1 83/05/11 16:16:55 wft
- * Added -b, updated getnumericrev() accordingly.
- * Replaced getpwuid() with getcaller().
- *
- * Revision 3.7 83/05/11 14:24:13 wft
- * Added options -L and -R;
- * Fixed selection bug with -l on multiple files.
- * Fixed error on dates of the form -d'>date' (rewrote getdatepair()).
- *
- * Revision 3.6 82/12/24 15:57:53 wft
- * shortened output format.
- *
- * Revision 3.5 82/12/08 21:45:26 wft
- * removed call to checkaccesslist(); used DATEFORM to format all dates;
- * removed unused variables.
- *
- * Revision 3.4 82/12/04 13:26:25 wft
- * Replaced getdelta() with gettree(); removed updating of field lockedby.
- *
- * Revision 3.3 82/12/03 14:08:20 wft
- * Replaced getlogin with getpwuid(), %02d with %.2d, fancydate with PRINTDATE.
- * Fixed printing of nil, removed printing of Suffix,
- * added shortcut if no revisions are printed, disambiguated struct members.
- *
- * Revision 3.2 82/10/18 21:09:06 wft
- * call to curdir replaced with getfullRCSname(),
- * fixed call to getlogin(), cosmetic changes on output,
- * changed conflicting long identifiers.
- *
- * Revision 3.1 82/10/13 16:07:56 wft
- * fixed type of variables receiving from getc() (char -> int).
- */
-
-
-
-#include "rcsbase.h"
-
-struct rcslockers { /* lockers in locker option; stored */
- char const * login; /* lockerlist */
- struct rcslockers * lockerlink;
- } ;
-
-struct stateattri { /* states in state option; stored in */
- char const * status; /* statelist */
- struct stateattri * nextstate;
- } ;
-
-struct authors { /* login names in author option; */
- char const * login; /* stored in authorlist */
- struct authors * nextauthor;
- } ;
-
-struct Revpairs{ /* revision or branch range in -r */
- int numfld; /* option; stored in revlist */
- char const * strtrev;
- char const * endrev;
- struct Revpairs * rnext;
- } ;
-
-struct Datepairs{ /* date range in -d option; stored in */
- struct Datepairs *dnext;
- char strtdate[datesize]; /* duelst and datelist */
- char enddate[datesize];
- char ne_date; /* datelist only; distinguishes < from <= */
- };
-
-static char extractdelta P((struct hshentry const*));
-static int checkrevpair P((char const*,char const*));
-static int extdate P((struct hshentry*));
-static int getnumericrev P((void));
-static struct hshentry const *readdeltalog P((void));
-static void cleanup P((void));
-static void exttree P((struct hshentry*));
-static void getauthor P((char*));
-static void getdatepair P((char*));
-static void getlocker P((char*));
-static void getrevpairs P((char*));
-static void getscript P((struct hshentry*));
-static void getstate P((char*));
-static void putabranch P((struct hshentry const*));
-static void putadelta P((struct hshentry const*,struct hshentry const*,int));
-static void putforest P((struct branchhead const*));
-static void putree P((struct hshentry const*));
-static void putrunk P((void));
-static void recentdate P((struct hshentry const*,struct Datepairs*));
-static void trunclocks P((void));
-
-static char const *insDelFormat;
-static int branchflag; /*set on -b */
-static int exitstatus;
-static int lockflag;
-static struct Datepairs *datelist, *duelst;
-static struct Revpairs *revlist, *Revlst;
-static struct authors *authorlist;
-static struct rcslockers *lockerlist;
-static struct stateattri *statelist;
-
-
-mainProg(rlogId, "rlog", "$Id$")
-{
- static char const cmdusage[] =
- "\nrlog usage: rlog -{bhLNRt} -v[string] -ddates -l[lockers] -r[revs] -sstates -Vn -w[logins] -xsuff -zzone file ...";
-
- register FILE *out;
- char *a, **newargv;
- struct Datepairs *currdate;
- char const *accessListString, *accessFormat;
- char const *headFormat, *symbolFormat;
- struct access const *curaccess;
- struct assoc const *curassoc;
- struct hshentry const *delta;
- struct rcslock const *currlock;
- int descflag, selectflag;
- int onlylockflag; /* print only files with locks */
- int onlyRCSflag; /* print only RCS pathname */
- int pre5;
- int shownames;
- int revno;
- int versionlist;
- char *vstring;
-
- descflag = selectflag = shownames = true;
- versionlist = onlylockflag = onlyRCSflag = false;
- vstring=0;
- out = stdout;
- suffixes = X_DEFAULT;
-
- argc = getRCSINIT(argc, argv, &newargv);
- argv = newargv;
- while (a = *++argv, 0<--argc && *a++=='-') {
- switch (*a++) {
-
- case 'L':
- onlylockflag = true;
- break;
-
- case 'N':
- shownames = false;
- break;
-
- case 'R':
- onlyRCSflag =true;
- break;
-
- case 'l':
- lockflag = true;
- getlocker(a);
- break;
-
- case 'b':
- branchflag = true;
- break;
-
- case 'r':
- getrevpairs(a);
- break;
-
- case 'd':
- getdatepair(a);
- break;
-
- case 's':
- getstate(a);
- break;
-
- case 'w':
- getauthor(a);
- break;
-
- case 'h':
- descflag = false;
- break;
-
- case 't':
- selectflag = false;
- break;
-
- case 'q':
- /* This has no effect; it's here for consistency. */
- quietflag = true;
- break;
-
- case 'x':
- suffixes = a;
- break;
-
- case 'z':
- zone_set(a);
- break;
-
- case 'T':
- /* Ignore -T, so that RCSINIT can contain -T. */
- if (*a)
- goto unknown;
- break;
-
- case 'V':
- setRCSversion(*argv);
- break;
-
- case 'v':
- versionlist = true;
- vstring = a;
- break;
-
- default:
- unknown:
- error("unknown option: %s%s", *argv, cmdusage);
-
- };
- } /* end of option processing */
-
- if (! (descflag|selectflag)) {
- warn("-t overrides -h.");
- descflag = true;
- }
-
- pre5 = RCSversion < VERSION(5);
- if (pre5) {
- accessListString = "\naccess list: ";
- accessFormat = " %s";
- headFormat = "RCS file: %s; Working file: %s\nhead: %s%s\nbranch: %s%s\nlocks: ";
- insDelFormat = " lines added/del: %ld/%ld";
- symbolFormat = " %s: %s;";
- } else {
- accessListString = "\naccess list:";
- accessFormat = "\n\t%s";
- headFormat = "RCS file: %s\nWorking file: %s\nhead:%s%s\nbranch:%s%s\nlocks:%s";
- insDelFormat = " lines: +%ld -%ld";
- symbolFormat = "\n\t%s: %s";
- }
-
- /* Now handle all pathnames. */
- if (nerror)
- cleanup();
- else if (argc < 1)
- faterror("no input file%s", cmdusage);
- else
- for (; 0 < argc; cleanup(), ++argv, --argc) {
- ffree();
-
- if (pairnames(argc, argv, rcsreadopen, true, false) <= 0)
- continue;
-
- /*
- * RCSname contains the name of the RCS file,
- * and finptr the file descriptor;
- * workname contains the name of the working file.
- */
-
- /* Keep only those locks given by -l. */
- if (lockflag)
- trunclocks();
-
- /* do nothing if -L is given and there are no locks*/
- if (onlylockflag && !Locks)
- continue;
-
- if ( versionlist ) {
- gettree();
- aprintf(out, "%s%s %s\n", vstring, workname, tiprev());
- continue;
- }
-
- if ( onlyRCSflag ) {
- aprintf(out, "%s\n", RCSname);
- continue;
- }
-
- gettree();
-
- if (!getnumericrev())
- continue;
-
- /*
- * Output the first character with putc, not printf.
- * Otherwise, an SVR4 stdio bug buffers output inefficiently.
- */
- aputc_('\n', out)
-
- /* print RCS pathname, working pathname and optional
- administrative information */
- /* could use getfullRCSname() here, but that is very slow */
- aprintf(out, headFormat, RCSname, workname,
- Head ? " " : "", Head ? Head->num : "",
- Dbranch ? " " : "", Dbranch ? Dbranch : "",
- StrictLocks ? " strict" : ""
- );
- currlock = Locks;
- while( currlock ) {
- aprintf(out, symbolFormat, currlock->login,
- currlock->delta->num);
- currlock = currlock->nextlock;
- }
- if (StrictLocks && pre5)
- aputs(" ; strict" + (Locks?3:0), out);
-
- aputs(accessListString, out); /* print access list */
- curaccess = AccessList;
- while(curaccess) {
- aprintf(out, accessFormat, curaccess->login);
- curaccess = curaccess->nextaccess;
- }
-
- if (shownames) {
- aputs("\nsymbolic names:", out); /* print symbolic names */
- for (curassoc=Symbols; curassoc; curassoc=curassoc->nextassoc)
- aprintf(out, symbolFormat, curassoc->symbol, curassoc->num);
- }
- if (pre5) {
- aputs("\ncomment leader: \"", out);
- awrite(Comment.string, Comment.size, out);
- afputc('\"', out);
- }
- if (!pre5 || Expand != KEYVAL_EXPAND)
- aprintf(out, "\nkeyword substitution: %s",
- expand_names[Expand]
- );
-
- aprintf(out, "\ntotal revisions: %d", TotalDeltas);
-
- revno = 0;
-
- if (Head && selectflag & descflag) {
-
- exttree(Head);
-
- /* get most recently date of the dates pointed by duelst */
- currdate = duelst;
- while( currdate) {
- VOID strcpy(currdate->strtdate, "0.0.0.0.0.0");
- recentdate(Head, currdate);
- currdate = currdate->dnext;
- }
-
- revno = extdate(Head);
-
- aprintf(out, ";\tselected revisions: %d", revno);
- }
-
- afputc('\n',out);
- if (descflag) {
- aputs("description:\n", out);
- getdesc(true);
- }
- if (revno) {
- while (! (delta = readdeltalog())->selector || --revno)
- continue;
- if (delta->next && countnumflds(delta->num)==2)
- /* Read through delta->next to get its insertlns. */
- while (readdeltalog() != delta->next)
- continue;
- putrunk();
- putree(Head);
- }
- aputs("----------------------------\n", out);
- aputs("=============================================================================\n",out);
- }
- Ofclose(out);
- exitmain(exitstatus);
-}
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = EXIT_FAILURE;
- Izclose(&finptr);
-}
-
-#if RCS_lint
-# define exiterr rlogExit
-#endif
- void
-exiterr()
-{
- _exit(EXIT_FAILURE);
-}
-
-
-
- static void
-putrunk()
-/* function: print revisions chosen, which are in trunk */
-
-{
- register struct hshentry const *ptr;
-
- for (ptr = Head; ptr; ptr = ptr->next)
- putadelta(ptr, ptr->next, true);
-}
-
-
-
- static void
-putree(root)
- struct hshentry const *root;
-/* function: print delta tree (not including trunk) in reverse
- order on each branch */
-
-{
- if (!root) return;
-
- putree(root->next);
-
- putforest(root->branches);
-}
-
-
-
-
- static void
-putforest(branchroot)
- struct branchhead const *branchroot;
-/* function: print branches that has the same direct ancestor */
-{
- if (!branchroot) return;
-
- putforest(branchroot->nextbranch);
-
- putabranch(branchroot->hsh);
- putree(branchroot->hsh);
-}
-
-
-
-
- static void
-putabranch(root)
- struct hshentry const *root;
-/* function : print one branch */
-
-{
- if (!root) return;
-
- putabranch(root->next);
-
- putadelta(root, root, false);
-}
-
-
-
-
-
- static void
-putadelta(node,editscript,trunk)
- register struct hshentry const *node, *editscript;
- int trunk;
-/* function: Print delta node if node->selector is set. */
-/* editscript indicates where the editscript is stored */
-/* trunk indicated whether this node is in trunk */
-{
- static char emptych[] = EMPTYLOG;
-
- register FILE *out;
- char const *s;
- size_t n;
- struct branchhead const *newbranch;
- struct buf branchnum;
- char datebuf[datesize + zonelenmax];
- int pre5 = RCSversion < VERSION(5);
-
- if (!node->selector)
- return;
-
- out = stdout;
- aprintf(out,
- "----------------------------\nrevision %s%s",
- node->num, pre5 ? " " : ""
- );
- if ( node->lockedby )
- aprintf(out, pre5+"\tlocked by: %s;", node->lockedby);
-
- aprintf(out, "\ndate: %s; author: %s; state: %s;",
- date2str(node->date, datebuf),
- node->author, node->state
- );
-
- if ( editscript )
- if(trunk)
- aprintf(out, insDelFormat,
- editscript->deletelns, editscript->insertlns);
- else
- aprintf(out, insDelFormat,
- editscript->insertlns, editscript->deletelns);
-
- newbranch = node->branches;
- if ( newbranch ) {
- bufautobegin(&branchnum);
- aputs("\nbranches:", out);
- while( newbranch ) {
- getbranchno(newbranch->hsh->num, &branchnum);
- aprintf(out, " %s;", branchnum.string);
- newbranch = newbranch->nextbranch;
- }
- bufautoend(&branchnum);
- }
-
- afputc('\n', out);
- s = node->log.string;
- if (!(n = node->log.size)) {
- s = emptych;
- n = sizeof(emptych)-1;
- }
- awrite(s, n, out);
- if (s[n-1] != '\n')
- afputc('\n', out);
-}
-
-
- static struct hshentry const *
-readdeltalog()
-/* Function : get the log message and skip the text of a deltatext node.
- * Return the delta found.
- * Assumes the current lexeme is not yet in nexttok; does not
- * advance nexttok.
- */
-{
- register struct hshentry * Delta;
- struct buf logbuf;
- struct cbuf cb;
-
- if (eoflex())
- fatserror("missing delta log");
- nextlex();
- if (!(Delta = getnum()))
- fatserror("delta number corrupted");
- getkeystring(Klog);
- if (Delta->log.string)
- fatserror("duplicate delta log");
- bufautobegin(&logbuf);
- cb = savestring(&logbuf);
- Delta->log = bufremember(&logbuf, cb.size);
-
- ignorephrases(Ktext);
- getkeystring(Ktext);
- Delta->insertlns = Delta->deletelns = 0;
- if ( Delta != Head)
- getscript(Delta);
- else
- readstring();
- return Delta;
-}
-
-
- static void
-getscript(Delta)
-struct hshentry * Delta;
-/* function: read edit script of Delta and count how many lines added */
-/* and deleted in the script */
-
-{
- int ed; /* editor command */
- declarecache;
- register RILE *fin;
- register int c;
- register long i;
- struct diffcmd dc;
-
- fin = finptr;
- setupcache(fin);
- initdiffcmd(&dc);
- while (0 <= (ed = getdiffcmd(fin,true,(FILE *)0,&dc)))
- if (!ed)
- Delta->deletelns += dc.nlines;
- else {
- /* skip scripted lines */
- i = dc.nlines;
- Delta->insertlns += i;
- cache(fin);
- do {
- for (;;) {
- cacheget_(c)
- switch (c) {
- default:
- continue;
- case SDELIM:
- cacheget_(c)
- if (c == SDELIM)
- continue;
- if (--i)
- unexpected_EOF();
- nextc = c;
- uncache(fin);
- return;
- case '\n':
- break;
- }
- break;
- }
- ++rcsline;
- } while (--i);
- uncache(fin);
- }
-}
-
-
-
-
-
-
-
- static void
-exttree(root)
-struct hshentry *root;
-/* function: select revisions , starting with root */
-
-{
- struct branchhead const *newbranch;
-
- if (!root) return;
-
- root->selector = extractdelta(root);
- root->log.string = 0;
- exttree(root->next);
-
- newbranch = root->branches;
- while( newbranch ) {
- exttree(newbranch->hsh);
- newbranch = newbranch->nextbranch;
- }
-}
-
-
-
-
- static void
-getlocker(argv)
-char * argv;
-/* function : get the login names of lockers from command line */
-/* and store in lockerlist. */
-
-{
- register char c;
- struct rcslockers *newlocker;
- argv--;
- while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';')
- continue;
- if ( c == '\0') {
- lockerlist = 0;
- return;
- }
-
- while( c != '\0' ) {
- newlocker = talloc(struct rcslockers);
- newlocker->lockerlink = lockerlist;
- newlocker->login = argv;
- lockerlist = newlocker;
- while ((c = *++argv) && c!=',' && c!=' ' && c!='\t' && c!='\n' && c!=';')
- continue;
- *argv = '\0';
- if ( c == '\0' ) return;
- while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';')
- continue;
- }
-}
-
-
-
- static void
-getauthor(argv)
-char *argv;
-/* function: get the author's name from command line */
-/* and store in authorlist */
-
-{
- register c;
- struct authors * newauthor;
-
- argv--;
- while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';')
- continue;
- if ( c == '\0' ) {
- authorlist = talloc(struct authors);
- authorlist->login = getusername(false);
- authorlist->nextauthor = 0;
- return;
- }
-
- while( c != '\0' ) {
- newauthor = talloc(struct authors);
- newauthor->nextauthor = authorlist;
- newauthor->login = argv;
- authorlist = newauthor;
- while ((c = *++argv) && c!=',' && c!=' ' && c!='\t' && c!='\n' && c!=';')
- continue;
- * argv = '\0';
- if ( c == '\0') return;
- while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';')
- continue;
- }
-}
-
-
-
-
- static void
-getstate(argv)
-char * argv;
-/* function : get the states of revisions from command line */
-/* and store in statelist */
-
-{
- register char c;
- struct stateattri *newstate;
-
- argv--;
- while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';')
- continue;
- if ( c == '\0'){
- error("missing state attributes after -s options");
- return;
- }
-
- while( c != '\0' ) {
- newstate = talloc(struct stateattri);
- newstate->nextstate = statelist;
- newstate->status = argv;
- statelist = newstate;
- while ((c = *++argv) && c!=',' && c!=' ' && c!='\t' && c!='\n' && c!=';')
- continue;
- *argv = '\0';
- if ( c == '\0' ) return;
- while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';')
- continue;
- }
-}
-
-
-
- static void
-trunclocks()
-/* Function: Truncate the list of locks to those that are held by the */
-/* id's on lockerlist. Do not truncate if lockerlist empty. */
-
-{
- struct rcslockers const *plocker;
- struct rcslock *p, **pp;
-
- if (!lockerlist) return;
-
- /* shorten Locks to those contained in lockerlist */
- for (pp = &Locks; (p = *pp); )
- for (plocker = lockerlist; ; )
- if (strcmp(plocker->login, p->login) == 0) {
- pp = &p->nextlock;
- break;
- } else if (!(plocker = plocker->lockerlink)) {
- *pp = p->nextlock;
- break;
- }
-}
-
-
-
- static void
-recentdate(root, pd)
- struct hshentry const *root;
- struct Datepairs *pd;
-/* function: Finds the delta that is closest to the cutoff date given by */
-/* pd among the revisions selected by exttree. */
-/* Successively narrows down the interval given by pd, */
-/* and sets the strtdate of pd to the date of the selected delta */
-{
- struct branchhead const *newbranch;
-
- if (!root) return;
- if (root->selector) {
- if ( cmpdate(root->date, pd->strtdate) >= 0 &&
- cmpdate(root->date, pd->enddate) <= 0)
- VOID strcpy(pd->strtdate, root->date);
- }
-
- recentdate(root->next, pd);
- newbranch = root->branches;
- while( newbranch) {
- recentdate(newbranch->hsh, pd);
- newbranch = newbranch->nextbranch;
- }
-}
-
-
-
-
-
-
- static int
-extdate(root)
-struct hshentry * root;
-/* function: select revisions which are in the date range specified */
-/* in duelst and datelist, start at root */
-/* Yield number of revisions selected, including those already selected. */
-{
- struct branchhead const *newbranch;
- struct Datepairs const *pdate;
- int revno, ne;
-
- if (!root)
- return 0;
-
- if ( datelist || duelst) {
- pdate = datelist;
- while( pdate ) {
- ne = pdate->ne_date;
- if (
- (!pdate->strtdate[0]
- || ne <= cmpdate(root->date, pdate->strtdate))
- &&
- (!pdate->enddate[0]
- || ne <= cmpdate(pdate->enddate, root->date))
- )
- break;
- pdate = pdate->dnext;
- }
- if (!pdate) {
- pdate = duelst;
- for (;;) {
- if (!pdate) {
- root->selector = false;
- break;
- }
- if (cmpdate(root->date, pdate->strtdate) == 0)
- break;
- pdate = pdate->dnext;
- }
- }
- }
- revno = root->selector + extdate(root->next);
-
- newbranch = root->branches;
- while( newbranch ) {
- revno += extdate(newbranch->hsh);
- newbranch = newbranch->nextbranch;
- }
- return revno;
-}
-
-
-
- static char
-extractdelta(pdelta)
- struct hshentry const *pdelta;
-/* function: compare information of pdelta to the authorlist, lockerlist,*/
-/* statelist, revlist and yield true if pdelta is selected. */
-
-{
- struct rcslock const *plock;
- struct stateattri const *pstate;
- struct authors const *pauthor;
- struct Revpairs const *prevision;
- int length;
-
- if ((pauthor = authorlist)) /* only certain authors wanted */
- while (strcmp(pauthor->login, pdelta->author) != 0)
- if (!(pauthor = pauthor->nextauthor))
- return false;
- if ((pstate = statelist)) /* only certain states wanted */
- while (strcmp(pstate->status, pdelta->state) != 0)
- if (!(pstate = pstate->nextstate))
- return false;
- if (lockflag) /* only locked revisions wanted */
- for (plock = Locks; ; plock = plock->nextlock)
- if (!plock)
- return false;
- else if (plock->delta == pdelta)
- break;
- if ((prevision = Revlst)) /* only certain revs or branches wanted */
- for (;;) {
- length = prevision->numfld;
- if (
- countnumflds(pdelta->num) == length+(length&1) &&
- 0 <= compartial(pdelta->num, prevision->strtrev, length) &&
- 0 <= compartial(prevision->endrev, pdelta->num, length)
- )
- break;
- if (!(prevision = prevision->rnext))
- return false;
- }
- return true;
-}
-
-
-
- static void
-getdatepair(argv)
- char * argv;
-/* function: get time range from command line and store in datelist if */
-/* a time range specified or in duelst if a time spot specified */
-
-{
- register char c;
- struct Datepairs * nextdate;
- char const * rawdate;
- int switchflag;
-
- argv--;
- while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';')
- continue;
- if ( c == '\0' ) {
- error("missing date/time after -d");
- return;
- }
-
- while( c != '\0' ) {
- switchflag = false;
- nextdate = talloc(struct Datepairs);
- if ( c == '<' ) { /* case: -d <date */
- c = *++argv;
- if (!(nextdate->ne_date = c!='='))
- c = *++argv;
- (nextdate->strtdate)[0] = '\0';
- } else if (c == '>') { /* case: -d'>date' */
- c = *++argv;
- if (!(nextdate->ne_date = c!='='))
- c = *++argv;
- (nextdate->enddate)[0] = '\0';
- switchflag = true;
- } else {
- rawdate = argv;
- while( c != '<' && c != '>' && c != ';' && c != '\0')
- c = *++argv;
- *argv = '\0';
- if ( c == '>' ) switchflag=true;
- str2date(rawdate,
- switchflag ? nextdate->enddate : nextdate->strtdate);
- if ( c == ';' || c == '\0') { /* case: -d date */
- VOID strcpy(nextdate->enddate,nextdate->strtdate);
- nextdate->dnext = duelst;
- duelst = nextdate;
- goto end;
- } else {
- /* case: -d date< or -d date>; see switchflag */
- int eq = argv[1]=='=';
- nextdate->ne_date = !eq;
- argv += eq;
- while ((c = *++argv) == ' ' || c=='\t' || c=='\n')
- continue;
- if ( c == ';' || c == '\0') {
- /* second date missing */
- if (switchflag)
- *nextdate->strtdate= '\0';
- else
- *nextdate->enddate= '\0';
- nextdate->dnext = datelist;
- datelist = nextdate;
- goto end;
- }
- }
- }
- rawdate = argv;
- while( c != '>' && c != '<' && c != ';' && c != '\0')
- c = *++argv;
- *argv = '\0';
- str2date(rawdate,
- switchflag ? nextdate->strtdate : nextdate->enddate);
- nextdate->dnext = datelist;
- datelist = nextdate;
- end:
- if (RCSversion < VERSION(5))
- nextdate->ne_date = 0;
- if ( c == '\0') return;
- while ((c = *++argv) == ';' || c == ' ' || c == '\t' || c =='\n')
- continue;
- }
-}
-
-
-
- static int
-getnumericrev()
-/* function: get the numeric name of revisions which stored in revlist */
-/* and then stored the numeric names in Revlst */
-/* if branchflag, also add default branch */
-
-{
- struct Revpairs * ptr, *pt;
- int n;
- struct buf s, e;
- char const *lrev;
- struct buf const *rstart, *rend;
-
- Revlst = 0;
- ptr = revlist;
- bufautobegin(&s);
- bufautobegin(&e);
- while( ptr ) {
- n = 0;
- rstart = &s;
- rend = &e;
-
- switch (ptr->numfld) {
-
- case 1: /* -rREV */
- if (!expandsym(ptr->strtrev, &s))
- goto freebufs;
- rend = &s;
- n = countnumflds(s.string);
- if (!n && (lrev = tiprev())) {
- bufscpy(&s, lrev);
- n = countnumflds(lrev);
- }
- break;
-
- case 2: /* -rREV: */
- if (!expandsym(ptr->strtrev, &s))
- goto freebufs;
- bufscpy(&e, s.string);
- n = countnumflds(s.string);
- (n<2 ? e.string : strrchr(e.string,'.'))[0] = 0;
- break;
-
- case 3: /* -r:REV */
- if (!expandsym(ptr->endrev, &e))
- goto freebufs;
- if ((n = countnumflds(e.string)) < 2)
- bufscpy(&s, ".0");
- else {
- bufscpy(&s, e.string);
- VOID strcpy(strrchr(s.string,'.'), ".0");
- }
- break;
-
- default: /* -rREV1:REV2 */
- if (!(
- expandsym(ptr->strtrev, &s)
- && expandsym(ptr->endrev, &e)
- && checkrevpair(s.string, e.string)
- ))
- goto freebufs;
- n = countnumflds(s.string);
- /* Swap if out of order. */
- if (compartial(s.string,e.string,n) > 0) {
- rstart = &e;
- rend = &s;
- }
- break;
- }
-
- if (n) {
- pt = ftalloc(struct Revpairs);
- pt->numfld = n;
- pt->strtrev = fstr_save(rstart->string);
- pt->endrev = fstr_save(rend->string);
- pt->rnext = Revlst;
- Revlst = pt;
- }
- ptr = ptr->rnext;
- }
- /* Now take care of branchflag */
- if (branchflag && (Dbranch||Head)) {
- pt = ftalloc(struct Revpairs);
- pt->strtrev = pt->endrev =
- Dbranch ? Dbranch : fstr_save(partialno(&s,Head->num,1));
- pt->rnext=Revlst; Revlst=pt;
- pt->numfld = countnumflds(pt->strtrev);
- }
-
- freebufs:
- bufautoend(&s);
- bufautoend(&e);
- return !ptr;
-}
-
-
-
- static int
-checkrevpair(num1,num2)
- char const *num1, *num2;
-/* function: check whether num1, num2 are legal pair,i.e.
- only the last field are different and have same number of
- fields( if length <= 2, may be different if first field) */
-
-{
- int length = countnumflds(num1);
-
- if (
- countnumflds(num2) != length
- || (2 < length && compartial(num1, num2, length-1) != 0)
- ) {
- rcserror("invalid branch or revision pair %s : %s", num1, num2);
- return false;
- }
-
- return true;
-}
-
-
-
- static void
-getrevpairs(argv)
-register char * argv;
-/* function: get revision or branch range from command line, and */
-/* store in revlist */
-
-{
- register char c;
- struct Revpairs * nextrevpair;
- int separator;
-
- c = *argv;
-
- /* Support old ambiguous '-' syntax; this will go away. */
- if (strchr(argv,':'))
- separator = ':';
- else {
- if (strchr(argv,'-') && VERSION(5) <= RCSversion)
- warn("`-' is obsolete in `-r%s'; use `:' instead", argv);
- separator = '-';
- }
-
- for (;;) {
- while (c==' ' || c=='\t' || c=='\n')
- c = *++argv;
- nextrevpair = talloc(struct Revpairs);
- nextrevpair->rnext = revlist;
- revlist = nextrevpair;
- nextrevpair->numfld = 1;
- nextrevpair->strtrev = argv;
- for (;; c = *++argv) {
- switch (c) {
- default:
- continue;
- case '\0': case ' ': case '\t': case '\n':
- case ',': case ';':
- break;
- case ':': case '-':
- if (c == separator)
- break;
- continue;
- }
- break;
- }
- *argv = '\0';
- while (c==' ' || c=='\t' || c=='\n')
- c = *++argv;
- if (c == separator) {
- while ((c = *++argv) == ' ' || c == '\t' || c =='\n')
- continue;
- nextrevpair->endrev = argv;
- for (;; c = *++argv) {
- switch (c) {
- default:
- continue;
- case '\0': case ' ': case '\t': case '\n':
- case ',': case ';':
- break;
- case ':': case '-':
- if (c == separator)
- break;
- continue;
- }
- break;
- }
- *argv = '\0';
- while (c==' ' || c=='\t' || c =='\n')
- c = *++argv;
- nextrevpair->numfld =
- !nextrevpair->endrev[0] ? 2 /* -rREV: */ :
- !nextrevpair->strtrev[0] ? 3 /* -r:REV */ :
- 4 /* -rREV1:REV2 */;
- }
- if (!c)
- break;
- else if (c==',' || c==';')
- c = *++argv;
- else
- error("missing `,' near `%c%s'", c, argv+1);
- }
-}
diff --git a/gnu/usr.bin/sdiff/Makefile b/gnu/usr.bin/sdiff/Makefile
deleted file mode 100644
index 9443fe5..0000000
--- a/gnu/usr.bin/sdiff/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# $Id: Makefile,v 1.7 1997/02/22 15:45:24 peter Exp $
-
-.PATH: ${.CURDIR}/../../../contrib/diff
-
-PROG= sdiff
-SRCS= sdiff.c getopt.c getopt1.c version.c
-
-# Important for ctype macros!
-CFLAGS+=-funsigned-char
-
-CFLAGS+=-I${.CURDIR}/../../../contrib/diff
-CFLAGS+=-DHAVE_CONFIG_H
-CFLAGS+=-DDIFF_PROGRAM=\"/usr/bin/diff\"
-CFLAGS+=-DDEFAULT_EDITOR_PROGRAM=\"/usr/bin/vi\"
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/sdiff/sdiff.1 b/gnu/usr.bin/sdiff/sdiff.1
deleted file mode 100644
index 8b7e88c..0000000
--- a/gnu/usr.bin/sdiff/sdiff.1
+++ /dev/null
@@ -1,198 +0,0 @@
-.TH SDIFF 1 "22sep1993" "GNU Tools" "GNU Tools"
-.SH NAME
-sdiff \- find differences between two files and merge interactively
-.SH SYNOPSIS
-.B sdiff
-.B -o
-outfile [options] from-file to-file
-.SH DESCRIPTION
-The
-.I sdiff
-command merges two files and interactively outputs the
-results to
-.IR outfile .
-
-If
-.I from-file
-is a directory and
-.I to-file
-is not,
-.I sdiff
-compares the file in
-.I from-file
-whose file name is that of
-.IR to-file ,
-and vice versa.
-.I from-file
-and
-.I to-file
-may not both be
-directories.
-
-.I sdiff
-options begin with
-.BR \- ,
-so normally
-.I from-file
-and
-.I to-file
-may not begin with
-.BR \- .
-However,
-.B \-\-
-as an
-argument by itself treats the remaining arguments as file names even if
-they begin with
-.BR \- .
-You may not use
-.B \-
-as an input file.
-
-.I sdiff
-without
-.B \-o
-(or
-.BR \-\-output )
-produces a
-side-by-side difference. This usage is obsolete; use
-.B "diff \-\-side\-by\-side"
-instead.
-.SS Options
-Below is a summary of all of the options that GNU
-.I sdiff
-accepts.
-Each option has two equivalent names, one of which is a single
-letter preceded by
-.BR \- ,
-and the other of which is a long name
-preceded by
-.BR \-\- .
-Multiple single letter options (unless they take
-an argument) can be combined into a single command line argument. Long
-named options can be abbreviated to any unique prefix of their name.
-.TP
-.B \-a
-Treat all files as text and compare them line-by-line, even if they
-do not appear to be text.
-.TP
-.B \-b
-Ignore changes in amount of white space.
-.TP
-.B \-B
-Ignore changes that just insert or delete blank lines.
-.TP
-.B \-d
-Change the algorithm to perhaps find a smaller set of changes. This
-makes
-.I sdiff
-slower (sometimes much slower).
-.TP
-.B \-H
-Use heuristics to speed handling of large files that have numerous
-scattered small changes.
-.TP
-.B \-\-expand\-tabs
-Expand tabs to spaces in the output, to preserve the alignment of tabs
-in the input files.
-.TP
-.B \-i
-Ignore changes in case; consider upper- and lower-case to be the same.
-.TP
-.BI "\-I " regexp
-Ignore changes that just insert or delete lines that match
-.IR regexp .
-.TP
-.B \-\-ignore\-all\-space
-Ignore white space when comparing lines.
-.TP
-.B \-\-ignore\-blank\-lines
-Ignore changes that just insert or delete blank lines.
-.TP
-.B \-\-ignore\-case
-Ignore changes in case; consider upper- and lower-case to be the same.
-.TP
-.BI \-\-ignore\-matching\-lines= regexp
-Ignore changes that just insert or delete lines that match
-.IR regexp .
-.TP
-.B \-\-ignore\-space\-change
-Ignore changes in amount of white space.
-.TP
-.B \-l
-.br
-.ns
-.TP
-.B \-\-left\-column
-Print only the left column of two common lines.
-.TP
-.B \-\-minimal
-Change the algorithm to perhaps find a smaller set of changes. This
-makes
-.I sdiff
-slower (sometimes much slower).
-.TP
-.BI "\-o " file
-.br
-.ns
-.TP
-.BI \-\-output= file
-Put merged output into
-.IR file .
-This option is required for merging.
-.TP
-.B \-s
-.br
-.ns
-.TP
-.B \-\-suppress\-common\-lines
-Do not print common lines.
-.TP
-.B \-\-speed\-large\-files
-Use heuristics to speed handling of large files that have numerous
-scattered small changes.
-.TP
-.B \-t
-Expand tabs to spaces in the output, to preserve the alignment of tabs
-in the input files.
-.TP
-.B \-\-text
-Treat all files as text and compare them line-by-line, even if they
-do not appear to be text.
-.TP
-.B \-v
-.br
-.ns
-.TP
-.B \-\-version
-Output the version number of
-.IR sdiff .
-.TP
-.BI "\-w " columns
-.br
-.ns
-.TP
-.BI \-\-width= columns
-Use an output width of
-.IR columns .
-Note that for historical reasons, this option is
-.B \-W
-in
-.IR diff ,
-.B \-w
-in
-.IR sdiff .
-.TP
-.B \-W
-Ignore horizontal white space when comparing lines.
-Note that for historical reasons, this option is
-.B \-w
-in
-.IR diff ,
-.B \-W
-in
-.IR sdiff .
-.SH SEE ALSO
-cmp(1), comm(1), diff(1), diff3(1).
-.SH DIAGNOSTICS
-An exit status of 0 means no differences were found, 1 means some
-differences were found, and 2 means trouble.
diff --git a/gnu/usr.bin/send-pr/COPYING b/gnu/usr.bin/send-pr/COPYING
deleted file mode 100644
index 515b6d3..0000000
--- a/gnu/usr.bin/send-pr/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-he GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/send-pr/Makefile b/gnu/usr.bin/send-pr/Makefile
deleted file mode 100644
index 842d65c..0000000
--- a/gnu/usr.bin/send-pr/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Makefile for building a standalone send-pr.
-#
-
-MAN1= send-pr.1
-SUBMITTERS= current-users
-RELEASE= `uname -rsm`
-RELEASE_EV!= uname -rsm
-CLEANFILES+= send-pr send-pr.el
-
-SUBDIR+= doc
-
-LINKS= ${BINDIR}/send-pr ${BINDIR}/sendbug
-MLINKS= send-pr.1 sendbug.1
-
-all: send-pr _SUBDIR
-
-send-pr: send-pr.sh Makefile
- sed -e 's,@DATADIR@,/etc,g' \
- -e 's/@DEFAULT_RELEASE@/$(RELEASE)/g' \
- -e 's/^SUBMITTER=.*/SUBMITTER=$(SUBMITTERS)/' \
- ${.ALLSRC:N*Makefile} > ${.TARGET}
-
-send-pr.el: send-pr-el.in Makefile
- sed -e 's,@DATADIR@,/etc,g' \
- -e 's/@DEFAULT_RELEASE@/$(RELEASE_EV)/g' \
- -e 's/"unknown"/"$(SUBMITTERS)"/g' \
- ${.ALLSRC:N*Makefile} > ${.TARGET}
-
-beforeinstall:
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- send-pr ${DESTDIR}${BINDIR}/send-pr
-
-# called from /usr/src/etc/Makefile
-etc-gnats-freefall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 0644 \
- ${.CURDIR}/categories ${DESTDIR}/etc/gnats/freefall
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/send-pr/README b/gnu/usr.bin/send-pr/README
deleted file mode 100644
index b479179..0000000
--- a/gnu/usr.bin/send-pr/README
+++ /dev/null
@@ -1,43 +0,0 @@
- send-pr - sends bug reports to a central support site
-
-`send-pr' uses electronic mail to submit support questions and
-software bugs to a central site. No piece of software is perfect, and
-software organizations understand this `send-pr' is designed to allow
-users who have problems to submit reports of these problems to sites
-responsible for supporting the software in question, in a defined form
-which can be read by an electronically managed database.
-
-`send-pr' is part of a suite of programs known collectively as GNATS,
-an acronym for Problem Report Management System. GNATS consists of
-several programs which, used in concert, formulate and partially
-administer a database of Problem Reports, or PRs, at a central support
-site. A PR goes through several states in its lifetime; GNATS tracks
-the PR and all information associated with it through each state and
-finally acts as an archive for PRs which have been resolved.
-
-The same engine can be used to submit bugs to any number of support
-sites by setting up aliases for each of them; `send-pr' error-checks
-each PR as it is sent to be sure that the category specified matches a
-category supported by the site in question.
-
-`send-pr' invokes an editor on a problem report template (after trying
-to fill in some fields with reasonable default values). When you exit
-the editor, `send-pr' sends the completed form to the support site.
-At the support site, the PR is assigned a unique number and is stored
-in the GNATS database according to its category and customer-id. GNATS
-automatically replies with an acknowledgement, citing the category and
-the PR number.
-
-See the Texinfo file `send-pr.texi' or the Info file `send-pr.info'
-for detailed installation and usage information.
-
-See the file MANIFEST for a list of the files which should have
-accompanied this distribution.
-
-See `send-pr.texi', `send-pr.info', or the file INSTALL for the
-installation procedure for `send-pr'.
-
-
-Copyright (c) 1993, Free Software Foundation, Inc.
-See the file COPYING for copyright information concerning this
-distribution and all its components.
diff --git a/gnu/usr.bin/send-pr/categories b/gnu/usr.bin/send-pr/categories
deleted file mode 100644
index ad9d26d..0000000
--- a/gnu/usr.bin/send-pr/categories
+++ /dev/null
@@ -1,9 +0,0 @@
-bin
-conf
-docs
-gnu
-i386
-kern
-misc
-ports
-sparc
diff --git a/gnu/usr.bin/send-pr/doc/Makefile b/gnu/usr.bin/send-pr/doc/Makefile
deleted file mode 100644
index 1de7064..0000000
--- a/gnu/usr.bin/send-pr/doc/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-INFO = send-pr
-INFOSECTION="System Utilities"
-
-.include <bsd.info.mk>
diff --git a/gnu/usr.bin/send-pr/doc/categ.texi b/gnu/usr.bin/send-pr/doc/categ.texi
deleted file mode 100644
index b02243e..0000000
--- a/gnu/usr.bin/send-pr/doc/categ.texi
+++ /dev/null
@@ -1,123 +0,0 @@
-@node Valid Categories
-@unnumberedsec Valid Categories
-@cindex valid categories
-@cindex example of a list of valid categories
-
-@table @code
-@item bfd
-@sc{gnu} binary file descriptor library.
-
-@item bifrabulator
-This one doesn't actually exist.
-
-@item binutils
-@sc{gnu} utilities for binary files (@code{ar}, @code{nm}, @code{size}@dots{}).
-
-@item bison
-@sc{gnu} parser generator.
-
-@item byacc
-Free parser generator.
-
-@item config
-Cygnus Support Software configuration and installation.
-
-@item cvs
-Concurrent Version System.
-
-@item diff
-@sc{gnu} @code{diff} program.
-
-@item doc
-Documentation and manuals.
-
-@item emacs
-@sc{gnu} Emacs editor and related functions.
-
-@item flex
-@sc{gnu} lexical analyzer.
-
-@item g++
-@sc{gnu} C++ compiler.
-
-@item gas
-@sc{gnu} assembler.
-
-@item gcc
-@sc{gnu} C compiler.
-
-@item gdb
-@sc{gnu} source code debugger.
-
-@item glob
-The filename globbing functions.
-
-@item gprof
-@sc{gnu} profiler.
-
-@item grep
-@sc{gnu} @code{grep} program.
-
-@item info
-@sc{gnu} @code{info} hypertext reader.
-
-@item ispell
-@sc{gnu} spelling checker.
-
-@item kerberos
-Kerberos authentication system.
-
-@item ld
-@sc{gnu} linker.
-
-@item libc
-Cygnus Support C Support Library.
-
-@item libg++
-@sc{gnu} C++ class library.
-
-@item libiberty
-@sc{gnu} @samp{libiberty} library.
-
-@item libm
-Cygnus Support C Math Library.
-
-@item make
-@sc{gnu} @code{make} program.
-
-@item makeinfo
-@sc{gnu} utility to build Info files from Texinfo documents.
-
-@item mas
-@sc{gnu} Motorola syntax assembler.
-
-@item newlib
-Cygnus Support C Support and Math Libraries.
-
-@item patch
-@sc{gnu} bug patch program.
-
-@item gnats
-@sc{gnu} Problem Report Management System.
-
-@item rcs
-Revision Control System.
-
-@item readline
-@sc{gnu} @code{readline} library.
-
-@item send-pr
-@sc{gnu} Problem Report submitting program.
-
-@item test
-Category to use when testing @code{send-pr}.
-
-@item texindex
-@sc{gnu} documentation indexing utility.
-
-@item texinfo
-@sc{gnu} documentation macros.
-
-@item other
-Anything which is not covered by the above categories.
-@end table
diff --git a/gnu/usr.bin/send-pr/doc/fields.texi b/gnu/usr.bin/send-pr/doc/fields.texi
deleted file mode 100644
index e8921d6..0000000
--- a/gnu/usr.bin/send-pr/doc/fields.texi
+++ /dev/null
@@ -1,518 +0,0 @@
-@node Fields
-@section Problem Report format
-@cindex Problem Report format
-@cindex format
-@cindex database similarities
-@cindex fields
-
-The format of a PR is designed to reflect the nature of @sc{gnats} as a
-database. Information is arranged into @dfn{fields}, and kept in
-individual records (Problem Reports).
-
-Problem Report fields are denoted by a keyword which begins with
-@samp{>} and ends with @samp{:}, as in @samp{>Confidential:}. Fields
-belong to one of three data types:
-
-@table @asis
-@cindex Problem Report data types
-@cindex @emph{Enumerated} data types
-@item @sc{Enumerated}
-One of a specific set of values, which vary according to the field. The
-value for each keyword must be on the same line as the keyword. These
-values are not configurable (yet).
-
-@ifset SENDPR
-For each @sc{Enumerated} keyword, the possible choices are listed in the
-@code{send-pr} template as a comment.
-@end ifset
-The following fields are @sc{Enumerated} format; see the descriptions of
-fields below for explanations of each field in detail:
-
-@smallexample
-@group
->Confidential: >Severity: >Priority:
->Class: >State: >Number:
-@end group
-@end smallexample
-
-@cindex @emph{Text} data types
-@item @sc{Text}
-One single line of text which must begin and end on the same line (i.e.,
-before a newline) as the keyword. See the descriptions of fields below
-for explanations of each field in detail. The following fields are
-@sc{Text} format:
-
-@smallexample
-@group
->Submitter-Id: >Originator: >Synopsis:
->Category: >Release: >Responsible:
->Arrival-Date:
-@end group
-@end smallexample
-
-@cindex @emph{MultiText} data types
-@item @sc{MultiText}
-Text of any length may occur in this field. @sc{MultiText} may span
-multiple lines and may also include blank lines. A @sc{MultiText} field
-ends only when another keyword appears. See the descriptions of fields
-below for explanations of each field in detail.
-
-The following fields are @sc{MultiText} format:
-
-@smallexample
-@group
->Organization: >Environment: >Description:
->How-To-Repeat: >Fix: >Audit-Trail:
->Unformatted:
-@end group
-@end smallexample
-
-@end table
-
-A Problem Report contains two different types of fields: @dfn{Mail
-Header} fields, which are used by the mail handler for delivery, and
-@dfn{Problem Report} fields, which contain information relevant to the
-Problem Report and its submitter. A Problem Report is essentially a
-specially formatted electronic mail message.
-
-@ifclear SENDPR
-@subheading Example Problem Report
-@end ifclear
-
-The following is an example Problem Report. Mail headers are at the
-top, followed by @sc{gnats} fields, which begin with @samp{>} and end
-with @samp{:}. The @samp{Subject:} line in the mail header and the
-@samp{>Synopsis:} field are usually duplicates of each other.
-
-@cindex sample Problem Report
-@cindex example Problem Report
-@cindex Problem Report template
-@cartouche
-@smallexample
-@group
-Message-Id: @var{message-id}
-Date: @var{date}
-From: @var{address}
-Reply-To: @var{address}
-To: @var{bug-address}
-Subject: @var{subject}
-
->Number: @var{gnats-id}
->Category: @var{category}
->Synopsis: @var{synopsis}
->Confidential: yes @emph{or} no
->Severity: critical, serious, @emph{or} non-critical
->Priority: high, medium @emph{or} low
->Responsible: @var{responsible}
->State: open, analyzed, suspended, feedback, @emph{or} closed
->Class: sw-bug, doc-bug, change-request, support,
-@ifset SENDPR
-@emph{or} duplicate
-@end ifset
-@ifclear SENDPR
-duplicate, @emph{or} mistaken
-@end ifclear
->Submitter-Id: @var{submitter-id}
->Arrival-Date: @var{date}
->Originator: @var{name}
->Organization: @var{organization}
->Release: @var{release}
->Environment:
- @var{environment}
->Description:
- @var{description}
->How-To-Repeat:
- @var{how-to-repeat}
->Fix:
- @var{fix}
->Audit-Trail:
-@var{appended-messages@dots{}}
-State-Changed-From-To: @var{from}-@var{to}
-State-Changed-When: @var{date}
-State-Changed-Why:
- @var{reason}
-Responsible-Changed-From-To: @var{from}-@var{to}
-Responsible-Changed-When: @var{date}
-Responsible-Changed-Why:
- @var{reason}
->Unformatted:
- @var{miscellaneous}
-@end group
-@end smallexample
-@end cartouche
-
-@menu
-* Mail header fields::
-* Problem Report fields::
-@end menu
-
-@c ----------------------
-@node Mail header fields
-@subsection Mail header fields
-@cindex mail header fields
-@cindex Internet standard RFC-822
-
-A Problem Report may contain any mail header field described in the
-Internet standard RFC-822. However, only the fields which identify the
-sender and the subject are required by @code{send-pr}:
-
-@table @code
-@cindex @code{To:} header
-@item To:
-The preconfigured mail address for the Support Site where the PR is to
-be sent, automatically supplied by @code{send-pr}.
-
-@cindex @code{Subject:} header
-@item Subject:
-A terse description of the problem. This field normally contains the
-same information as the @samp{>Synopsis:} field.
-
-@cindex @code{From:} header
-@item From:
-Usually supplied automatically by the originator's mailer; should
-contain the originator's electronic mail address.
-
-@cindex @code{Reply-To:} header
-@item Reply-To:
-A return address to which electronic replies can be sent; in most cases,
-the same address as the @code{From:} field.
-@end table
-
-@ifclear SENDPR
-@cindex @code{Received-By:} headers
-One of the configurable options for @sc{gnats} is whether or not to
-retain @w{@samp{Received-By:}} headers, which often consume a lot of
-space and are not often used. @xref{Local configuration,,Changing your
-local configuration}.
-@end ifclear
-
-@c ----------------------
-@node Problem Report fields
-@subsection Problem Report fields
-@cindex GNATS database fields
-@cindex field format
-
-@c FIXME - this node is loooooooooooooooong...
-
-@subheading Field descriptions
-
-The following fields are present whenever a PR is submitted via the
-program @code{send-pr}. @sc{gnats} adds additional fields when the PR
-arrives at the Support Site; explanations of these follow this list.
-
-@cindex fields - list
-@cindex GNATS fields - list
-@table @code
-@item >Submitter-Id:
-@cindex @code{Submitter-Id} field
-@cindex @code{>Submitter-Id:}
-(@sc{Text}) A unique identification code assigned by the Support Site.
-It is used to identify all Problem Reports coming from a particular
-site. (Submitters without a value for this field can invoke
-@code{send-pr} with the @samp{--request-id} option to apply for one from
-the support organization. Problem Reports from those not affiliated
-with the support organization should use the default value of @samp{net}
-for this field.)
-
-@item >Originator:
-@cindex @code{Originator} field
-@cindex @code{>Originator:}
-(@sc{Text}) Originator's real name. The default is the value of the
-originator's environment variable @code{NAME}.
-
-@item >Organization:
-@cindex @code{>Organization:}
-@cindex @code{Organization} field
-(@sc{MultiText}) The originator's organization. The default value is
-set with the variable @w{@code{DEFAULT_ORGANIZATION}} in the
-@ifclear SENDPR
-@file{config} file (@pxref{config,,The @code{config} file}).
-@end ifclear
-@ifset SENDPR
-@code{send-pr} shell script.
-@end ifset
-
-@item >Confidential:
-@cindex @code{Confidential} field
-@cindex @code{>Confidential:}
-@cindex confidentiality in PRs
-@cindex PR confidentiality
-(@sc{Enumerated}) Use of this field depends on the originator's
-relationship with the support organization; contractual agreements often
-have provisions for preserving confidentiality. Conversely, a lack of a
-contract often means that any data provided will not be considered
-confidential. Submitters should be advised to contact the support
-organization directly if this is an issue.
-
-If the originator's relationship to the support organization provides
-for confidentiality, then if the value of this field is @samp{yes} the
-support organization treats the PR as confidential; any code samples
-provided are not made publicly available (e.g., in regression test
-suites). The default value is @samp{yes}.
-
-@item >Synopsis:
-@cindex @code{Synopsis} field
-@cindex @code{>Synopsis:}
-(@sc{Text}) One-line summary of the problem. @w{@code{send-pr}} copies
-this information to the @samp{Subject:} line when you submit a Problem
-Report.
-
-@item >Severity:
-@cindex @code{Severity} field
-@cindex @code{>Severity:}
-(@sc{Enumerated}) The severity of the problem. Accepted values include:
-
-@table @code
-@cindex @emph{critical} severity problems
-@item critical
-The product, component or concept is completely non-operational or some
-essential functionality is missing. No workaround is known.
-
-@cindex @emph{serious} severity problems
-@item serious
-The product, component or concept is not working properly or significant
-functionality is missing. Problems that would otherwise be considered
-@samp{critical} are rated @samp{serious} when a workaround is known.
-
-@cindex @emph{non-critical} severity problems
-@item non-critical
-The product, component or concept is working in general, but lacks
-features, has irritating behavior, does something wrong, or doesn't
-match its documentation.
-@end table
-The default value is @samp{serious}.
-@sp 1
-
-@item >Priority:
-@cindex @code{Priority} field
-@cindex @code{>Priority:}
-(@sc{Enumerated}) How soon the originator requires a solution. Accepted
-values include:
-
-@table @code
-@cindex @emph{high} priority problems
-@item high
-A solution is needed as soon as possible.
-
-@cindex @emph{medium} priority problems
-@item medium
-The problem should be solved in the next release.
-
-@cindex @emph{low} priority problems
-@item low
-The problem should be solved in a future release.
-@end table
-@noindent
-The default value is @samp{medium}.
-@sp 1
-
-@item >Category:
-@cindex @code{Category} field
-@cindex @code{>Category:}
-(@sc{Text}) The name of the product, component or concept where
-the problem lies. The values for this field are defined by the Support
-Site.
-@ifclear SENDPR
-@xref{categories,,The @code{categories} file}, for details.
-@end ifclear
-
-@item >Class:
-@cindex @code{Class} field
-@cindex @code{>Class:}
-(@sc{Enumerated}) The class of a problem can be one of the following:
-
-@table @code
-@cindex @emph{sw-bug} class
-@item sw-bug
-A general product problem. (@samp{sw} stands for ``software''.)
-
-@cindex @emph{doc-bug} class
-@item doc-bug
-A problem with the documentation.
-
-@cindex @emph{change-request} class
-@item change-request
-A request for a change in behavior, etc.
-
-@cindex @emph{support} class
-@item support
-A support problem or question.
-
-@cindex @emph{duplicate} class
-@item duplicate (@var{pr-number})
-Duplicate PR. @var{pr-number} should be the number of the original PR.
-
-@ifclear SENDPR
-@cindex @emph{mistaken} class
-@item mistaken
-No problem, user error or misunderstanding. This value is valid only at
-the Support Site.
-@end ifclear
-@end table
-
-@noindent
-The default is @samp{sw-bug}.
-@sp 1
-
-@item >Release:
-@cindex @code{Release} field
-@cindex @code{>Release:}
-(@sc{Text}) Release or version number of the product, component or
-concept.
-
-@item >Environment:
-@cindex @code{Environment} field
-@cindex @code{>Environment:}
-(@sc{MultiText}) Description of the environment where the problem occured:
-machine architecture, operating system, host and target types,
-libraries, pathnames, etc.
-
-@item >Description:
-@cindex @code{Description} field
-@cindex @code{>Description:}
-(@sc{MultiText}) Precise description of the problem.
-
-@item >How-To-Repeat:
-@cindex @code{How-To-Repeat} field
-@cindex @code{>How-To-Repeat:}
-(@sc{MultiText}) Example code, input, or activities to reproduce the
-problem. The support organization uses example code both to reproduce
-the problem and to test whether the problem is fixed. Include all
-preconditions, inputs, outputs, conditions after the problem, and
-symptoms. Any additional important information should be included.
-Include all the details that would be necessary for someone else to
-recreate the problem reported, however obvious. Sometimes seemingly
-arbitrary or obvious information can point the way toward a solution.
-See also @ref{Helpful hints,,Helpful hints}.
-
-@item >Fix:
-@cindex @code{Fix} field
-@cindex @code{>Fix:}
-(@sc{MultiText}) A description of a solution to the problem, or a patch
-which solves the problem. (This field is most often filled in at the
-Support Site; we provide it to the submitter in case she has solved the
-problem.)
-
-@end table
-
-@noindent
-@sc{gnats} adds the following fields when the PR arrives at the Support
-Site:
-
-@table @code
-@cindex @code{Number} field
-@cindex @code{>Number:}
-@item >Number:
-(@sc{Enumerated}) The incremental identification number for this PR.
-@ifclear SENDPR
-This is included in the automated reply to the submitter (if that
-feature of @sc{gnats} is activated; @pxref{Local configuration,,Changing
-your local configuration}). It is also included in the copy of the PR
-that is sent to the maintainer.
-@end ifclear
-
-The @samp{>Number:} field is often paired with the @samp{>Category:}
-field as
-
-@smallexample
-@var{category}/@var{number}
-@end smallexample
-
-@noindent
-in subsequent email messages. This is for historical reasons, as well
-as because Problem Reports are stored in subdirectories which are named
-by category.
-
-@cindex @code{State} field
-@cindex @code{>State:}
-@item >State:
-(@sc{Enumerated}) The current state of the PR. Accepted values are:
-
-@table @code
-@item open
-The PR has been filed and the responsible person notified.
-
-@item analyzed
-The responsible person has analyzed the problem.
-
-@item feedback
-The problem has been solved, and the originator has been given a patch
-or other fix.
-
-@item closed
-The changes have been integrated, documented, and tested, and the
-originator has confirmed that the solution works.
-
-@item suspended
-Work on the problem has been postponed.
-@end table
-
-@noindent
-The initial state of a PR is @samp{open}. @xref{States,,States of
-Problem Reports}.
-
-@cindex @code{Responsible} field
-@cindex @code{>Responsible:}
-@item >Responsible:
-(@sc{Text}) The person responsible for this category.
-@ifclear SENDPR
-@sc{gnats} retrieves this information from the @file{categories} file
-(@pxref{categories,,The @code{categories} file}).
-@end ifclear
-
-@item >Arrival-Date:
-@cindex @code{>Arrival-Date:}
-@cindex @code{Arrival-Date} field
-(@sc{Text}) The time that this PR was received by @sc{gnats}. The date
-is provided automatically by @sc{gnats}.
-
-@item >Audit-Trail:
-@cindex @code{>Audit-Trail:}
-@cindex @code{Audit-Trail} field
-(@sc{MultiText}) Tracks related electronic mail as well as changes in
-the @samp{>State:} and @samp{>Responsible:} fields with the sub-fields:
-
-@table @code
-@cindex @code{State-Changed-<From>-<To>:} in @code{>Audit-Trail:}
-@item @w{State-Changed-<From>-<To>: @var{oldstate}>-<@var{newstate}}
-The old and new @samp{>State:} field values.
-
-@cindex @code{Responsible-Changed-<From>-<To>:} in @code{>Audit-Trail:}
-@item @w{Responsible-Changed-<From>-<To>: @var{oldresp}>-<@var{newresp}}
-The old and new @samp{>Responsible:} field values.
-
-@cindex @code{State-Changed-By:} in @code{>Audit-Trail:}
-@cindex @code{Responsible-Changed-By:} in @code{>Audit-Trail:}
-@item State-Changed-By: @var{name}
-@itemx Responsible-Changed-By: @var{name}
-The name of the maintainer who effected the change.
-
-@cindex @code{State-Changed-When:} in @code{>Audit-Trail:}
-@cindex @code{Responsible-Changed-When:} in @code{>Audit-Trail:}
-@item State-Changed-When: @var{timestamp}
-@itemx Responsible-Changed-When: @var{timestamp}
-The time the change was made.
-
-@cindex @code{State-Changed-Why:} in @code{>Audit-Trail:}
-@cindex @code{Responsible-Changed-Why:} in @code{>Audit-Trail:}
-@item State-Changed-Why: @var{reason@dots{}}
-@itemx Responsible-Changed-Why: @var{reason@dots{}}
-The reason for the change.
-@end table
-
-@noindent
-@cindex subsequent mail
-@cindex other mail
-@cindex appending PRs
-@cindex saving related mail
-@cindex related mail
-The @samp{>Audit-Trail:} field also contains any mail messages received
-by @sc{gnats} related to this PR, in the order received.
-
-@item >Unformatted:
-@cindex @code{>Unformatted:}
-@cindex @code{Unformatted} field
-(@sc{MultiText}) Any random text found outside the fields in the
-original Problem Report.
-@end table
-
diff --git a/gnu/usr.bin/send-pr/doc/s-usage.texi b/gnu/usr.bin/send-pr/doc/s-usage.texi
deleted file mode 100644
index ee51368..0000000
--- a/gnu/usr.bin/send-pr/doc/s-usage.texi
+++ /dev/null
@@ -1,522 +0,0 @@
-@c This is the usage section for send-pr. It is called as
-@c chapter (Invoking send-pr) by send-pr.texi, and also as
-@c section (Submitting Problem Reports) by gnats.texi (chapter/section
-@c identifiers are adjusted accordingly)
-
-@c FIXME! This still seems jumbled...
-
-You can invoke @code{send-pr} from a shell prompt or from within
-@sc{gnu} Emacs using @w{@samp{M-x send-pr}}.
-
-@menu
-* using send-pr:: Creating new Problem Reports
-* send-pr in Emacs:: Using send-pr from within Emacs
-* send-pr from the shell:: Invoking send-pr from the shell
-* Helpful hints::
-@end menu
-
-@node using send-pr
-@section Creating new Problem Reports
-
-@c FIXME - this is a long node
-Invoking @code{send-pr} presents a PR @dfn{template} with a number of
-fields already filled in. Complete the template as thoroughly as
-possible to make a useful bug report. Submit only one bug with each PR.
-
-@cindex template
-A template consists of three sections:
-
-@table @dfn
-@item Comments
-The top several lines of a blank template consist of a series of
-comments that provide some basic instructions for completing the Problem
-Report, as well as a list of valid entries for the @samp{>Category:}
-field. These comments are all preceded by the string @samp{SEND-PR:}
-and are erased automatically when the PR is submitted. The
-instructional comments within @samp{<} and @samp{>} are also removed.
-(Only these comments are removed; lines you provide that happen to have
-those characters in them, such as examples of shell-level redirection,
-are not affected.)
-
-@item Mail Header
-@code{send-pr} creates a standard mail header. @code{send-pr} completes
-all fields except the @samp{Subject:} line with default values.
-(@xref{Fields,,Problem Report format}.)
-
-@item @sc{gnats} fields
-These are the informational fields that @sc{gnats} uses to route your
-Problem Report to the responsible party for further action. They should
-be filled out as completely as possible. (@xref{Fields,,Problem Report
-format}. Also see @ref{Helpful hints,,Helpful hints}.)
-@end table
-
-@ifset SENDPR
-@noindent
-For examples of a Problem Report template and complete Problem Report,
-see @ref{An Example}.
-@end ifset
-
-The default template contains your preconfigured @samp{>Submitter-Id:}.
-@code{send-pr} attempts to determine values for the @samp{>Originator:}
-and @samp{>Organization:} fields (@pxref{Fields,,Problem Report
-format}). @code{send-pr} also attempts to find out some information
-about your system and architecture, and places this information in the
-@samp{>Environment:} field if it finds any.
-
-You may submit problem reports to different Support Sites from the
-default site by specifying the alternate site when you invoke
-@code{send-pr}. Each @code{site} has its own list of categories for
-which it accepts Problem Reports.
-@c FIXME! This should go in..
-@c For a list of sites to whom @code{send-pr} is configured to send
-@c Problem Reports, type @w{@samp{send-pr -S}}.
-@ifset SENDPR
-(@xref{default site,,Setting a default @var{site}}.)
-@end ifset
-
-@code{send-pr} also provides the mail header section of the template
-with default values in the @samp{To:}, @samp{From:}, and
-@samp{Reply-To:} fields. The @samp{Subject:} field is empty.
-
-The template begins with a comment section:
-
-@cindex template comment section
-@cindex comment section in the PR template
-@smallexample
-@group
-SEND-PR: -*- send-pr -*-
-SEND-PR: Lines starting with `SEND-PR' will be removed
-SEND-PR: automatically as well as all comments (the text
-SEND-PR: below enclosed in `<' and `>').
-SEND-PR:
-SEND-PR: Please consult the document `Reporting Problems
-SEND-PR: Using send-pr' if you are not sure how to fill out
-SEND-PR: a problem report.
-SEND-PR:
-SEND-PR: Choose from the following categories:
-@end group
-@end smallexample
-
-@noindent
-and also contains a list of valid @code{>Category:} values for the
-Support Site to whom you are submitting this Problem Report. One (and
-only one) of these values should be placed in the @code{>Category:}
-field.
-@ifset SENDPR
-A complete sample bug report, from template to completed PR, is shown in
-@ref{An Example}. For a complete list of valid categories, type
-@w{@samp{send-pr -L}} at your prompt. @xref{Valid Categories,,Valid
-Categories}, for a sample list of categories, .
-@end ifset
-
-@c FIXME.. this sounds awkward
-The mail header is just below the comment section. Fill out the
-@samp{Subject:} field, if it is not already completed using the value of
-@samp{>Synopsis:}. The other mail header fields contain default values.
-
-@cindex mail header section
-@smallexample
-@group
-To: @var{support-site}
-Subject: @emph{complete this field}
-From: @var{your-login}@@@var{your-site}
-Reply-To: @var{your-login}@@@var{your-site}
-X-send-pr-version: send-pr @value{VERSION}
-@end group
-@end smallexample
-
-@noindent
-where @var{support-site} is an alias for the Support Site you wish to
-submit this PR to.
-
-The rest of the template contains @sc{gnats} fields. Each field is
-either automatically completed with valid information (such as your
-@samp{>Submitter-Id:}) or contains a one-line instruction specifying the
-information that field requires in order to be correct. For example,
-the @samp{>Confidential:} field expects a value of @samp{yes} or
-@samp{no}, and the answer must fit on one line; similarly, the
-@samp{>Synopsis:} field expects a short synopsis of the problem, which
-must also fit on one line. Fill out the fields as completely as
-possible. @xref{Helpful hints,,Helpful hints}, for suggestions as to
-what kinds of information to include.
-
-In this example, words in @emph{italics} are filled in with
-pre-configured information:
-
-@cindex @code{send-pr} fields
-@smallexample
-@group
->Submitter-Id: @emph{your submitter-id}
->Originator: @emph{your name here}
->Organization:
- @emph{your organization}
->Confidential:<[ yes | no ] (one line)>
->Synopsis: <synopsis of the problem (one line)>
->Severity: <[non-critical | serious | critical](one line)>
->Priority: <[ low | medium | high ] (one line)>
->Category: <name of the product (one line)>
->Class: <[sw-bug | doc-bug | change-request | support]>
->Release: <release number or tag (one line)>
->Environment:
- <machine, os, target, libraries (multiple lines)>
-
->Description:
- <precise description of the problem (multiple lines)>
->How-To-Repeat:
- <code/input/activities to reproduce (multiple lines)>
->Fix:
- <how to correct or work around the problem, if known
- (multiple lines)>
-@end group
-@end smallexample
-
-@cindex @code{Submitter-Id} field
-@cindex @code{>Submitter-Id:}
-When you finish editing the Problem Report, @code{send-pr} mails it to
-the address named in the @samp{To:} field in the mail header.
-@code{send-pr} checks that the complete form contains a valid
-@samp{>Category:}.
-
-@ifset SENDPR
-Your copy of @code{send-pr} should have already been customized on
-installation to reflect your @samp{>Submitter-Id:}. (@xref{Installing
-send-pr, , Installing @code{send-pr} on your system}.) If you don't
-know your @samp{>Submitter-Id:}, you can request it using
-@w{@samp{send-pr --request-id}}. If your organization is not affiliated
-with the site you send Problem Reports to, a good generic
-@samp{>Submitter-Id:} to use is @samp{net}. @emph{NOTE:} If you are using
-send-pr to send problem reports to the FreeBSD Project, this version of
-send-pr already has a customer ID in it and you do not need to request a
-new one.
-@end ifset
-
-@cindex bad Problem Reports
-@cindex errors
-@cindex invalid Problem Reports
-If your PR has an invalid value in one of the @sc{Enumerated} fields
-(@pxref{Fields,,Problem Report format}), @code{send-pr} places the PR in
-a temporary file named @samp{/tmp/pbad@var{nnnn}} on your machine.
-@var{nnnn} is the process identification number given to your current
-@code{send-pr} session. If you are running @code{send-pr} from the
-shell, you are prompted as to whether or not you wish to try editing the
-same Problem Report again. If you are running @code{send-pr} from
-Emacs, the Problem Report is placed in the buffer
-@w{@samp{*send-pr-error*}}; you can edit this file and then submit it
-with
-
-@smallexample
-M-x gnats-submit-pr
-@end smallexample
-
-@cindex subsequent mail
-@cindex other mail
-@cindex appending PRs
-@cindex saving related mail
-@cindex related mail
-Any further mail concerning this Problem Report should be carbon-copied
-to the @sc{gnats} mailing address as well, with the category and
-identification number in the @samp{Subject:} line of the message.
-
-@smallexample
-Subject: Re: PR @var{category}/@var{gnats-id}: @var{original message subject}
-@end smallexample
-
-@noindent
-Messages which arrive with @samp{Subject:} lines of this form are
-automatically appended to the Problem Report in the @samp{>Audit-Trail:}
-field in the order received.
-
-@c ---------------------------------------------------------------
-@node send-pr in Emacs
-@section Using @code{send-pr} from within Emacs
-@cindex using @code{send-pr} from within Emacs
-@cindex @code{send-pr} within Emacs
-@cindex invoking @code{send-pr} from Emacs
-@cindex interactive interface
-
-You can use an interactive @code{send-pr} interface from within @sc{gnu}
-Emacs to fill out your Problem Report. We recommend that you
-familiarize yourself with Emacs before using this feature
-(@pxref{Introduction,,Introduction,emacs,GNU Emacs}).
-
-Call @code{send-pr} with @w{@samp{M-x send-pr}}.@footnote{If typing
-@w{@samp{M-x send-pr}} doesn't work, see your system administrator for
-help loading @code{send-pr} into Emacs.} @code{send-pr} responds with a
-Problem Report template preconfigured for the Support Site from which
-you received @code{send-pr}. (If you use @code{send-pr} locally, the
-default Support Site is probably your local site.)
-
-You may also submit problem reports to different Support Sites from the
-default site. To use this feature, invoke @code{send-pr} with
-
-@smallexample
-C-u M-x send-pr
-@end smallexample
-
-@code{send-pr} prompts you for the name of a @var{site}. @var{site} is
-an alias on your local machine which points to an alternate Support
-Site.
-
-@cindex Emacs
-@code{send-pr} displays the template and prompts you in the minibuffer
-with the line:
-@smallexample
->Category: other
-@end smallexample
-
-@noindent
-Delete the default value @samp{other} @emph{in the minibuffer} and
-replace it with the keyword corresponding to your problem (the list of
-valid categories is in the topmost section of the PR template). For
-example, if the problem you wish to report has to do with the @sc{gnu} C
-compiler, and your support organization accepts bugs submitted for this
-program under the category @samp{gcc}, delete @samp{other} and then type
-@w{@samp{gcc[@key{RET}]}}. @code{send-pr} replaces the line
-
-@smallexample
->Category: <name of the product (one line)>
-@end smallexample
-
-@noindent
-in the template with
-
-@smallexample
->Category: gcc
-@end smallexample
-
-@noindent
-and moves on to another field.
-
-@cindex completion in Emacs
-@cindex name completion in Emacs
-@w{@code{send-pr}} provides name completion in the minibuffer. For
-instance, you can also type @w{@samp{gc[@key{TAB}]}}, and @code{send-pr}
-attempts to complete the entry for you. Typing @w{@samp{g[@key{TAB}]}}
-may not have the same effect if several possible entries begin with
-@samp{g}. In that case @code{send-pr} cannot complete the entry because
-it cannot determine whether you mean @samp{gcc} or, for example,
-@samp{gdb}, if both of those are possible categories.
-@w{@code{send-pr}} continues to prompt you for a valid entry until you
-enter one.
-
-@w{@code{send-pr}} prompts you interactively to enter each field for
-which there is a range of specific choices. If you attempt to enter a
-value which is not in the range of acceptable entries, @code{send-pr}
-responds with @w{@samp{[No match]}} and allows you to change the entry
-until it contains an acceptable value. This avoids unusable information
-(at least in these fields) and also avoids typographical errors which
-could cause problems later.
-
-@code{send-pr} prompts you for the following fields:
-
-@c FIXME - should these go before the discussion on completion?
-@example
-@group
->Category:
->Confidential: (@emph{default}: no)
->Severity: (@emph{default}: serious)
->Priority: (@emph{default}: medium)
->Class: (@emph{default}: sw-bug)
->Release:
->Synopsis: (@emph{this value is copied to @code{Subject:}})
-@end group
-@end example
-
-@noindent
-After you complete these fields, @w{@code{send-pr}} places the cursor in
-the @samp{>Description:} field and displays the message
-
-@smallexample
-To send the problem report use: C-c C-c
-@end smallexample
-
-@noindent
-in the minibuffer. At this point, edit the file in the main buffer to
-reflect your specific problem, putting relevant information in the
-proper fields.
-@ifset SENDPR
-@xref{An Example}, for a sample Problem Report.
-@end ifset
-
-@w{@samp{send-pr}} provides a few key bindings to make moving
-around in a template buffer more simple:
-
-@table @code
-@item C-c C-f
-@itemx M-x change-field
-Changes the field under the cursor. @code{edit-pr} prompts you for a
-new value.
-
-@item M-C-b
-@itemx M-x gnats-backward-field
-Moves the cursor to the beginning of the value of the current field.
-
-@item M-C-f
-@itemx M-x gnats-forward-field
-Moves the cursor to the end of the value of the current field.
-
-@item M-p
-@itemx M-x gnats-previous-field
-Moves the cursor back one field to the beginning of the value of the
-previous field.
-
-@item M-n
-@itemx M-x gnats-next-field
-Moves the cursor forward one field to the beginning of the value of the
-next field.
-@end table
-
-@code{send-pr} takes over again when you type @samp{C-c C-c} to send the
-message. @code{send-pr} reports any errors in a separate buffer, which
-remains in existence until you send the PR properly (or, of course,
-until you explicitly kill the buffer).
-
-For detailed instructions on using Emacs, see
-@ref{Introduction,,,emacs,GNU Emacs}.
-
-@node send-pr from the shell
-@section Invoking @code{send-pr} from the shell
-@cindex command line options
-@cindex invoking @code{send-pr} from the shell
-@cindex shell invocation
-
-@c FIXME! Add [ -S ] right after [ -L ]...
-@smallexample
-send-pr [ @var{site} ]
- [ -f @var{problem-report} | --file @var{problem-report} ]
- [ -t @var{mail-address} | --to @var{mail-address} ]
- [ --request-id ]
- [ -L | --list ] [ -P | --print ]
- [ -V | --version] [ -h | --help ]
-@end smallexample
-
-@var{site} is an alias on your local machine which points to an address
-used by a Support Site. If this argument is not present, the default
-@var{site} is usually the site which you received @code{send-pr} from,
-or your local site if you use @sc{gnats} locally.
-@ifset SENDPR
-(@xref{default site,,Setting a default @var{site}}.)
-@end ifset
-
-Invoking @code{send-pr} with no options calls the editor named in your
-environment variable @code{EDITOR} on a default PR template. If the
-environment variable @code{PR_FORM} is set, its value is used as a file
-name which contains a valid template. If @code{PR_FORM} points to a
-missing or unreadable file, or if the file is empty, @code{send-pr}
-generates an error message and opens the editor on a default template.
-
-@table @code
-@item -f @var{problem-report}
-@itemx --file @var{problem-report}
-Specifies a file, @var{problem-report}, where a completed Problem Report
-already exists. @code{send-pr} sends the contents of the file without
-invoking an editor. If @var{problem-report} is @samp{-},
-@w{@code{send-pr}} reads from standard input.
-
-@item -t @var{mail-address}
-@itemx --to @var{mail-address}
-Sends the PR to @var{mail-address}. The default is preset when
-@code{send-pr} is configured. @emph{This option is not recommended};
-instead, use the argument @var{site} on the command line.
-
-@item --request-id
-Sends a request for a @code{>Submitter-Id:} to the Support Site.
-
-@item -L
-@item --list
-@cindex listing valid categories
-Prints the list of valid @code{>Category:} values on standard output.
-No mail is sent.
-
-@ignore
-@item -S
-@itemx --sites
-Displays a list of valid @var{site} values on standard output. No mail
-is sent.
-@end ignore
-
-@item -P
-@itemx --print
-Displays the PR template. If the variable @code{PR_FORM} is set in your
-environment, the file it specifies is printed. If @code{PR_FORM} is not
-set, @code{send-pr} prints the standard blank form. If the file
-specified by @code{PR_FORM} doesn't exist, @code{send-pr} displays an
-error message. No mail is sent.
-
-@item -V
-@itemx --version
-Displays the @code{send-pr} version number and a usage summary. No mail
-is sent.
-
-@item -h
-@itemx --help
-Displays a usage summary for @code{send-pr}. No mail is sent.
-@end table
-
-@node Helpful hints
-@section Helpful hints
-@cindex helpful hints
-@cindex Using and Porting GNU CC
-@cindex effective problem reporting
-@cindex kinds of helpful information
-@cindex information to submit
-@cindex Report all the facts!
-
-There is no orthodox standard for submitting effective bug reports,
-though you might do well to consult the section on submitting bugs for
-@sc{gnu} @code{gcc} in @ref{Bugs, , Reporting Bugs, gcc, Using and
-Porting GNU CC}, by Richard Stallman. This section contains
-instructions on what kinds of information to include and what kinds of
-mistakes to avoid.
-
-In general, common sense (assuming such an animal exists) dictates the
-kind of information that would be most helpful in tracking down and
-resolving problems in software.
-@itemize @bullet
-@item
-Include anything @emph{you} would want to know if you were looking at
-the report from the other end. There's no need to include every minute
-detail about your environment, although anything that might be different
-from someone else's environment should be included (your path, for
-instance).
-
-@item
-Narratives are often useful, given a certain degree of restraint. If a
-person responsible for a bug can see that A was executed, and then B and
-then C, knowing that sequence of events might trigger the realization of
-an intermediate step that was missing, or an extra step that might have
-changed the environment enough to cause a visible problem. Again,
-restraint is always in order (``I set the build running, went to get a
-cup of coffee (Columbian, cream but no sugar), talked to Sheila on the
-phone, and then THIS happened@dots{}'') but be sure to include anything
-relevant.
-
-@item
-Richard Stallman writes, ``The fundamental principle of reporting bugs
-usefully is this: @strong{report all the facts}. If you are not sure
-whether to state a fact or leave it out, state it!'' This holds true
-across all problem reporting systems, for computer software or social
-injustice or motorcycle maintenance. It is especially important in the
-software field due to the major differences seemingly insignificant
-changes can make (a changed variable, a missing semicolon, etc.).
-
-@item
-Submit only @emph{one} problem with each Problem Report. If you have
-multiple problems, use multiple PRs. This aids in tracking each problem
-and also in analyzing the problems associated with a given program.
-
-@item
-It never hurts to do a little research to find out if the bug you've
-found has already been reported. Most software releases contain lists
-of known bugs in the Release Notes which come with the software; see
-your system administrator if you don't have a copy of these.
-
-@item
-The more closely a PR adheres to the standard format, the less
-interaction is required by a database administrator to route the
-information to the proper place. Keep in mind that anything that
-requires human interaction also requires time that might be better spent
-in actually fixing the problem. It is therefore in everyone's best
-interest that the information contained in a PR be as correct as
-possible (in both format and content) at the time of submission.
-@end itemize
diff --git a/gnu/usr.bin/send-pr/doc/send-pr.texi b/gnu/usr.bin/send-pr/doc/send-pr.texi
deleted file mode 100644
index 4afba51..0000000
--- a/gnu/usr.bin/send-pr/doc/send-pr.texi
+++ /dev/null
@@ -1,657 +0,0 @@
-\input texinfo @c -*-texinfo-*-
-@setfilename send-pr.info
-@settitle Reporting Problems Using send-pr
-
-@setchapternewpage odd
-
-@include version.texi
-@set SENDPR
-
-@ifinfo
-@format
-START-INFO-DIR-ENTRY
-* send-pr: (send-pr). Reporting problems--using send-pr.
-END-INFO-DIR-ENTRY
-@end format
-@end ifinfo
-
-@ifinfo
-Copyright @copyright{} 1993 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-@ignore
-Permission is granted to process this file through TeX and print the
-results, provided the printed document carries a 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
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that
-the entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions.
-@end ifinfo
-
-@titlepage
-@finalout
-@title Reporting Problems
-@subtitle Using @code{send-pr}, version @value{VERSION}
-@subtitle October 1993
-@author Jeffrey M. Osier
-@author Cygnus Support
-@page
-
-@vskip 0pt plus 1filll
-
-Copyright @copyright{} 1993 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that
-the entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions.
-
-@end titlepage
-
-@c ---------------------------------------------------------------
-@node Top
-@top Overview
-@cindex foreword to @code{send-pr}
-@cindex overview to @code{send-pr}
-@cindex introduction to @code{send-pr}
-
-This manual documents @code{send-pr},
-@ifinfo
-version @value{VERSION},
-@end ifinfo
-which uses electronic mail to submit support questions and problem
-reports to a central Support Site. No body of work is perfect, and
-support organizations understand this; @code{send-pr} is designed to
-allow users who have problems to submit reports of these problems to
-sites responsible for supporting the products in question, in a defined
-form which can be read by an electronically managed database.
-
-@cindex GNATS
-@code{send-pr} is part of a suite of programs known collectively as
-@sc{gnats}, the @sc{gnu} Problem Report Management System. @sc{gnats}
-consists of several programs which, used in concert, formulate and
-partially administer a database of @dfn{Problem Reports}, or @dfn{PRs},
-at a central Support Site. A PR goes through several states in its
-lifetime; @sc{gnats} tracks the PR and all information associated with it
-through each state and finally acts as an archive for PRs which have
-been @dfn{closed}.
-
-Because @code{send-pr} exists as a shell (@file{/bin/sh}) script and as
-an Elisp file for use with @sc{gnu} Emacs, it can be used from any
-machine on your network which can run a shell script and/or Emacs.
-
-In general, you can use any editor and mailer to submit valid Problem
-Reports, as long as the format required by @sc{gnats} is preserved.
-@code{send-pr} automates the process, however, and ensures that certain
-fields necessary for automatic processing are present. @code{send-pr}
-is strongly recommended for all initial problem-oriented correspondence
-with your Support Site. The organization you submit Problem Reports to
-supplies an address to which further information can be sent; the person
-responsible for the category of the problem you report contacts you
-directly.
-
-@menu
-* send-pr in detail:: Details about send-pr and GNATS
-* Invoking send-pr:: Editing and sending PRs
-* An Example:: A working example
-* Installing send-pr:: Installing send-pr on your system
-* Index::
-@end menu
-
-@node send-pr in detail
-@chapter Details about send-pr and GNATS
-
-@cindex details about @code{send-pr}
-@cindex Problem Reports
-A @dfn{Problem Report} is a message that describes a problem you are
-having with a body of work. @code{send-pr} organizes this message into
-a form which can be understood and automatically processed by @sc{gnats},
-the @sc{gnu} Problem Report Management System. A Problem Report is
-organized into @dfn{fields} which contain data describing you, your
-organization, and the problem you are announcing (@pxref{Fields,,Problem
-Report format}). Problem Reports go through several defined states in
-their lifetimes, from @dfn{open} to @dfn{closed} (@pxref{States,,States
-of Problem Reports}).
-
-@menu
-* States:: States of Problem Reports
-* Fields:: Problem Report format
-@end menu
-
-@include states.texi
-
-@include fields.texi
-
-@node Invoking send-pr
-@chapter Editing and sending PRs
-@cindex editing and sending PRs
-@cindex sending PRs
-@cindex invoking send-pr
-@cindex using send-pr
-@cindex generating new PRs
-
-@include s-usage.texi
-
-@node An Example
-@chapter An Example
-@cindex an example
-@cindex example PR
-@cindex Cygnus Support
-@cindex GNU software support
-
-Cygnus Support in Mountain View, CA, uses @sc{gnats} and @code{send-pr}
-extensively for their support activities. As a support company, Cygnus
-finds problem tracking to be a crucial part of everyday business.
-Cygnus supports the @sc{gnu} compiling tools (including @sc{gnats} and
-@code{send-pr}) over several many platforms
-
-With each shipment of the Cygnus Support Developer's Kit, customers
-receive the latest version of @code{send-pr}, which contains an
-up-to-date listing of valid categories (values for the @code{>Category:}
-field). Using these tools, Cygnus' customers can communicate their
-problems to Cygnus effectively and receive automatic confirmation of
-receipt as well as notification of changes in the status of their
-reported problems. Much of Cygnus' support mechanism relies on
-electronic mail.
-
-As an example, let's pretend we're a customer of Cygnus Support, and
-that we're having a problem compiling some of our software using the
-@sc{gnu} C compiler, which Cygnus supports.
-
-Assume that we're getting an error in our @code{bifrabulator} program
-wherein the @samp{prestidigitation} routines don't match with the
-@samp{whatsitsname}. We've made sure we're following the rules of the
-program and checked the Release Notes from Cygnus and found that the bug
-isn't already known. In other words, we're pretty sure we've found a
-bug.
-
-@cindex Imaginary Software, Ltd.
-Our first step is to call @code{send-pr}. It really doesn't matter
-whether we use @code{send-pr} from the shell or from within Emacs.
-Indeed, if we use Emacs as a primary editor, calling @code{send-pr} from
-the shell is likely to start @code{send-pr} in an Emacs buffer anyway.
-So, since our company, @emph{Imaginary Software, Ltd.}, uses @sc{gnu}
-software extensively, we're pretty familiar with Emacs, so from within
-Emacs we type
-@smallexample
-M-x send-pr
-@end smallexample
-@noindent
-and we're greeted with the following screen:
-
-@cindex default PR template
-@cindex example of a default template
-@cindex blank PR template
-@cindex @code{bifrabulator}
-@cartouche
-@smallexample
-SEND-PR: -*- text -*-
-SEND-PR: Lines starting with `SEND-PR' will be removed
-SEND-PR: automatically as well as all comments (the text
-SEND-PR: below enclosed in `<' and `>').
-SEND-PR: Please consult the manual if you are not sure
-SEND-PR: how to fill out a problem report.
-SEND-PR:
-SEND-PR: Choose from the following categories:
-SEND-PR:
-SEND-PR: bfd binutils bison
-SEND-PR: byacc clib config cvs diff
-SEND-PR: doc emacs flex g++ gas
-SEND-PR: gcc gdb glob gprof grep
-SEND-PR: info ispell kerberos ld libg++
-SEND-PR: libiberty make makeinfo mas newlib
-SEND-PR: other patch rcs readline send-pr
-SEND-PR: test texindex texinfo texinfo.tex
-SEND-PR: bifrabulator <---@emph{note: this one is fake}
-SEND-PR:
-To: cygnus-bugs@@cygnus.com
-Subject:
-From: jeffrey@@imaginary.com
-Reply-To: jeffrey@@imaginary.com
-X-send-pr-version: send-pr @value{VERSION}
-
->Submitter-Id: imaginary
->Originator: Jeffrey Osier
->Organization:
-Imaginary Software, Ltd.
->Confidential: <[ yes | no ] (one line)>
->Synopsis: <synopsis of the problem (one line)>
->Severity: <[ non-critical | serious | critical ] (one line)>
->Priority: <[ low | medium | high ] (one line)>
->Category: <name of the product (one line)>
->Class: <[sw-bug|doc-bug|change-request|support](oneline)>
->Release: <release number or tag (one line)>
->Environment:
- <machine, os, target, libraries (multiple lines)>
-System: SunOS imaginary.com 4.1.1 1 sun4
-Architecture: sun4
-
->Description:
- <precise description of the problem (multiple lines)>
->How-To-Repeat:
- <code/input/activities to reproduce (multiple lines)>
->Fix:
-@iftex
-@hrule
-@end iftex
------Emacs: *send-pr* (send-pr Fill)----All------------------
-@iftex
-@hrule
-@end iftex
->Category: other[]
-@end smallexample
-@end cartouche
-@page
-We know from past experience that we need to set certain information into
-each field, so we compile all the information we know about our problem.
-We have some sample code which we know should work, even though it
-doesn't, so we'll include that. Below is the completed PR; we send this
-using @kbd{C-c C-c}. (The comments have been truncated).
-
-@cindex completed Problem Report
-@cindex example of a completed PR
-@cartouche
-@smallexample
-SEND-PR: Lines starting with `SEND-PR' will be removed
-SEND-PR: automatically as well as all comments (the text
-SEND-PR: @dots{}
-SEND-PR:
-To: cygnus-bugs@@cygnus.com
-Subject: bifrabulator routines don't match
-From: jeffrey@@imaginary.com
-Reply-To: jeffrey@@imaginary.com
-X-send-pr-version: send-pr @value{VERSION}
-
->Submitter-Id: imaginary
->Originator: Jeffrey Osier
->Organization:
-Imaginary Software, Ltd.
->Confidential: no
->Synopsis: bifrabulator routines don't match
->Severity: serious
->Priority: medium
->Category: bifrabulator
->Class: sw-bug
->Release: progressive-930101
->Environment:
-System: SunOS imaginary.com 4.1.1 1 sun4
-Architecture: sun4 (SPARC)
-
->Description:
- the following code I fed into the bifrabulator came back
- with a strange error. apparently, the prestidigitation
- routine doesn't match with the whatsitsname in all cases.
-
->How-To-Repeat:
- call the bifrabulator on the following code.
- @emph{code sample@dots{}}
-
->Fix:
-@iftex
-@hrule
-@end iftex
------Emacs: *send-pr* (send-pr Fill)----All------------------
-@iftex
-@hrule
-@end iftex
-To send the problem report use: C-c C-c
-@end smallexample
-@end cartouche
-
-We type @kbd{C-c C-c}, and off it goes. Now, we depend on Cygnus
-Support to figure out the answer to our problem.
-
-Soon afterward, we get the following message from Cygnus:
-
-@smallexample
-@group
-From: gnats (GNATS management)
-Sender: gnats-admin
-Reply-To: hacker@@cygnus.com
-To: jeffrey@@imaginary.com
-Subject: Re: bifrabulator/1425: routines don't match
-
-Thank you very much for your problem report.
-It has the internal identification: g++/1425.
-The individual assigned to look at your bug is: hacker
-(F.B. Hacker)
-
-Category: bifrabulator
-Responsible: hacker
-Synopsis: bifrabulator routines don't match
-Arrival-Date: Sat Feb 30 03:12:55 1993
-@end group
-@end smallexample
-
-@noindent
-This is our receipt that the bug has been accepted and forwarded to the
-responsible party.
-
-@noindent
-A while later, we get the analysis:
-
-@smallexample
-@group
-To: jeffrey@@imaginary.com
-From: hacker@@cygnus.com
-Subject: Re: bifrabulator/1425: routines don't match
-Reply-To: hacker@@cygnus.com
-
-Got your message, Jeff. It seems that the bifrabulator was
-confusing the prestidigitation routines with the realitychecker
-when lexically parsing the whatsitsname.
-
-I'm working on robustisizing the bifrabulator now.
-
-How about lunch next week?
---
-F.B. Hacker
-Cygnus Support, Mountain View, CA 415 903 1400
-#include <std-disclaimer.h>
-@end group
-@end smallexample
-
-@noindent
-About the same time, we get another message from Cygnus.
-
-@cindex state change example
-@cindex example of a state change
-@smallexample
-@group
-From: hacker@@cygnus.com
-To: jeffrey@@imaginary.com
-Subject: Re: bifrabulator/1425: doesn't match prestidig
-Reply-To: hacker@@cygnus.com
-
-
- `F.B. Hacker' changed the state to `analyzed'.
-
-State-Changed-From-To: open-analyzed
-State-Changed-By: hacker
-State-Changed-When: Fri Feb 31 1993 08:59:16 1993
-State-Changed-Why:
- figured out the problem, working on a patch this afternoon
---
-F.B. Hacker
-Cygnus Support, Mountain View, CA 415 903 1400
-#include <std-disclaimer.h>
-@end group
-@end smallexample
-
-@noindent
-The bug has now been analyzed, and Cygnus is working on a solution.
-
-@noindent
-Sometime later, we get more mail from F.B.:
-
-@smallexample
-@group
-To: jeffrey@@imaginary.com
-From: hacker@@cygnus.com
-Subject: Re: bifrabulator/1425: routines don't match
-Reply-To: hacker@@cygnus.com
-
-There's a patch now that you can ftp over and check out.
-
-Hey, that joke you sent me was great! The one about the
-strings walking into a bar... my boss laughed for an hour!
---
-F.B. Hacker
-Cygnus Support, Mountain View, CA 415 903 1400
-#include <std-disclaimer.h>
-@end group
-@end smallexample
-@sp 2
-@smallexample
-@group
-From: hacker@@cygnus.com
-To: jeffrey@@imaginary.com
-Subject: Re: bifrabulator/1425: doesn't match prestidig
-Reply-To: hacker@@cygnus.com
-
-
- `F.B. Hacker' changed the state to `feedback'.
-
-State-Changed-From-To: analyzed-feedback
-State-Changed-By: hacker
-State-Changed-When: Fri Feb 31 1993 23:43:16 1993
-State-Changed-Why:
- got the patch finished, notified Jeff at Imaginary Software
---
-F.B. Hacker
-Cygnus Support, Mountain View, CA 415 903 1400
-#include <std-disclaimer.h>
-@end group
-@end smallexample
-
-@noindent
-The bug has gone into @dfn{feedback} status now, until we get the patch,
-install it and test it. When everything tests well, we can mail F.B.
-back and tell him the bug's been fixed, and he can change the state of
-the PR from @dfn{feedback} to @dfn{closed}.
-
-Following is a list of valid @samp{>Category:} entries that are
-supported by Cygnus.
-
-@menu
-* Valid Categories::
-@end menu
-
-@c FIXME - is this list up to date?
-@include categ.texi
-
-@node Installing send-pr
-@appendix Installing @code{send-pr} on your system
-@cindex installation
-
-If you receive @code{send-pr} as part of a larger software distribution,
-it probably gets installed when the full distribution is installed. If
-you are using @sc{gnats} at your site as well, you must decide where
-@code{send-pr} sends Problem Reports by default; see @ref{default site,,
-Setting a default @var{site}}.
-
-@menu
-* installation:: installing `send-pr' by itself
-* default site:: setting a default site
-@end menu
-
-@node installation
-@section Installing @code{send-pr} by itself
-@cindex installation procedure
-
-Install @code{send-pr} by following these steps (you may need
-@code{root} access in order to change the @file{aliases} file and to
-install @code{send-pr}):
-
-@itemize @bullet
-@item
-Unpack the distribution into a directory which we refer to as
-@var{srcdir}.
-
-@item
-Edit the file @file{Makefile} to reflect local conventions.
-Specifically, you should edit the variable @samp{prefix} to alter the
-installation location. The default is @file{/usr/local}. All files are
-installed under @samp{prefix} (see below).
-
-@item @emph{Run}
-@smallexample
-make all install [ info ] [ install-info ] [ clean ]
-@end smallexample
-
-@noindent
-The targets mean the following:
-
-@table @code
-@item all
-Builds @code{send-pr} and @code{install-sid}
-
-@item install
-Installs the following:
-
-@table @code
-@item install-sid
-@itemx send-pr
-into @file{@var{prefix}/bin}
-
-@item send-pr.1
-into @file{@var{prefix}/man/man1}
-
-@item @var{site}
-the list of valid @var{categories} for the Support Site from which you
-received @code{send-pr}, installed as
-@w{@file{@var{prefix}/lib/gnats/@var{site}}}
-
-@item send-pr.el
-into @w{@file{@var{prefix}/lib/emacs/lisp}}@footnote{If your main Emacs
-lisp repository is in a different directory from this, substitute that
-directory for @w{@file{@var{prefix}/lib/emacs/lisp}}.}
-@end table
-
-@item info (@emph{optional})
-Builds @file{send-pr.info} from @file{send-pr.texi}@*
-@c FIXME - is this still true?
-(@file{send-pr.info} is included with this distribution)
-
-@item install-info (@emph{optional})
-Installs @file{send-pr.info} into @w{@file{@var{prefix}/info}}
-
-@item clean (@emph{optional})
-Removes all intermediary build files that can be rebuilt from source
-code
-@end table
-
-@item
-Run
-
-@smallexample
-install-sid @var{your-sid}
-@end smallexample
-
-@noindent
-where @var{your-sid} is the identification code you received with
-@w{@code{send-pr}}. @code{send-pr} automatically inserts this value
-into the template field @samp{>Submitter-Id:}. If you've downloaded
-@code{send-pr} from the Net, use @samp{net} for this value.
-
-@item
-Place the following line in
-@w{@file{@var{prefix}/lib/emacs/lisp/default.el}}, or instruct your
-users to place the following line in their @file{.emacs} files:
-
-@smallexample
-(autoload 'send-pr "send-pr" "Submit a Problem Report." t)
-@end smallexample
-
-@item
-Create a mail alias for the Support Site from which you received
-@code{send-pr}, and for every site with which you wish to use
-@code{send-pr} to communicate. Each alias must have a suffix of
-@samp{-gnats}. The Support Site(s) will provide the correct addresses
-where these aliases should point. For instance, edit your mail aliases
-file to contain something like:
-
-@smallexample
-# support sites; for use with send-pr
-cygnus-gnats: bugs@@cygnus.com # Cygnus Support
-bumblebee-gnats: bumblebugs@@bumblebee.com # Bumblebee Inc.
-mycompany-gnats: bugs@@my.company.com (@emph{if you use @sc{gnats} locally})
-@end smallexample
-
-@code{send-pr} automatically searches for these aliases when you type
-
-@smallexample
-send-pr cygnus
-send-pr bumblebee
-send-pr @var{site}@dots{}
-@end smallexample
-
-@noindent
-@code{send-pr} also uses @var{site} to determine the categories of
-problems accepted by the site in question by looking in
-
-@smallexample
-@var{prefix}/lib/gnats/@var{site}
-@end smallexample
-
-@end itemize
-
-@node default site
-@section Setting a default @var{site}
-@cindex default @var{site}
-@cindex setting a default @var{site}
-
-@code{send-pr} is capable of sending Problem Reports to any number of
-Support Sites, using mail aliases which have @samp{-gnats} appended them.
-@code{send-pr} automatically appends the suffix, so that when you type
-
-@smallexample
-send-pr @var{site}
-@end smallexample
-
-@noindent
-the Problem Report goes to the address noted in the @file{aliases} file
-as @w{@samp{@var{site}-gnats}}. You can do this in the Emacs version of
-@code{send-pr} by invoking the program with
-
-@smallexample
-C-u M-x send-pr
-@end smallexample
-
-@noindent
-You are prompted for @var{site}.
-
-@var{site} is also used to error-check the @samp{>Category:} field, as a
-precaution against sending mistaken information (and against sending
-information to the wrong site).
-
-You may also simply type
-
-@smallexample
-send-pr
-@end smallexample
-
-@noindent
-from the shell (or @w{@samp{M-x send-pr}} in Emacs), and the Problem
-Report you generate will be sent to the @var{site}, which is usually the
-site from which you received your distribution of @w{@code{send-pr}}.
-If you use @sc{gnats} at your own organization, the default is usually
-your local address for reporting problems.
-
-To change this, simply edit the file @file{Makefile} before installing
-and change the line
-
-@smallexample
-GNATS_SITE = @var{site}
-@end smallexample
-
-@noindent
-to reflect the site where you wish to send PRs by default.
-
-@c ---------------------------------------------------------------
-@node Index
-@unnumbered Index
-
-@printindex cp
-
-@c ---------------------------------------------------------------
-@contents
-@bye
diff --git a/gnu/usr.bin/send-pr/doc/states.texi b/gnu/usr.bin/send-pr/doc/states.texi
deleted file mode 100644
index 16ea890..0000000
--- a/gnu/usr.bin/send-pr/doc/states.texi
+++ /dev/null
@@ -1,53 +0,0 @@
-@node States
-@section States of Problem Reports
-
-@cindex life-cycle of a Problem Report
-@cindex states of Problem Reports
-@cindex Problem Report states
-@cindex automatic notification
-
-Each PR goes through a defined series of states between origination and
-closure. The originator of a PR receives notification automatically of
-any state changes.
-
-@table @dfn
-@cindex @emph{open} state
-@cindex initial state (@dfn{open})
-@cindex state---@dfn{open}
-@item open
-The initial state of a Problem Report. This means the PR has been filed
-and the responsible person(s) notified.
-
-@item analyzed
-@cindex @emph{analyzed} state
-@cindex state---@dfn{analyzed}
-The responsible person has analyzed the problem. The analysis should
-contain a preliminary evaluation of the problem and an estimate of the
-amount of time and resources necessary to solve the problem. It should
-also suggest possible workarounds.
-
-@item feedback
-@cindex @emph{feedback} state
-@cindex state---@dfn{feedback}
-The problem has been solved, and the originator has been given a patch
-or other fix. The PR remains in this state until the originator
-acknowledges that the solution works.
-
-@item closed
-@cindex @emph{closed} state
-@cindex state---@dfn{closed}
-@cindex final state (@dfn{closed})
-A Problem Report is closed (``the bug stops here'') only when any
-changes have been integrated, documented, and tested, and the submitter
-has confirmed the solution.
-
-@item suspended
-@cindex @emph{suspended} state
-@cindex state---@dfn{suspended}
-Work on the problem has been postponed. This happens if a timely
-solution is not possible or is not cost-effective at the present time.
-The PR continues to exist, though a solution is not being actively
-sought. If the problem cannot be solved at all, it should be closed
-rather than suspended.
-@end table
-
diff --git a/gnu/usr.bin/send-pr/doc/version.texi b/gnu/usr.bin/send-pr/doc/version.texi
deleted file mode 100644
index 7aff863..0000000
--- a/gnu/usr.bin/send-pr/doc/version.texi
+++ /dev/null
@@ -1 +0,0 @@
-@set VERSION 3.2
diff --git a/gnu/usr.bin/send-pr/install-sid.sh b/gnu/usr.bin/send-pr/install-sid.sh
deleted file mode 100755
index f7f24e5..0000000
--- a/gnu/usr.bin/send-pr/install-sid.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/sh
-# Drop in the SUBMITTER id into a site's installed send-pr script.
-# Copyright (C) 1993 Free Software Foundation, Inc.
-# Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
-# version written by Heinz G. Seidl (hgs@ide.com).
-#
-# This file is part of GNU GNATS.
-#
-# GNU GNATS 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.
-#
-# GNU GNATS 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 GNU GNATS; see the file COPYING. If not, write to
-# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-COMMAND=`echo $0 | sed -e 's,.*/,,g'`
-USAGE="Usage: $COMMAND [--install-dir=prefix] [--help] [--version] submitter-id"
-
-VERSION=3.2
-
-BINDIR=@BINDIR@
-
-SUBMITTER=
-TEMP=/tmp/sp$$
-
-if [ $# -eq 0 ]; then
- echo "$USAGE"
- exit 1
-fi
-
-while [ $# -gt 0 ]; do
- case "$1" in
- -install-dir=*|--install-dir=*|--install-di=*|--install-d=*|--install-=*|--install=*|--instal=*|--insta=*|--inst=*|--ins=*|--in=*|--i=*)
- I=`echo "$1" | sed 's/-*i[a-z\-]*=//'`
- BINDIR=$I/bin ;;
- --version) echo $COMMAND version $VERSION ; exit 1 ;;
- -*) echo "$USAGE" ; exit 1 ;;
- *) SUBMITTER=$1 ;;
- esac
- shift
-done
-
-path=`echo $0 | sed -e "s;${COMMAND};;"`
-
-[ -z "$path" ] && path=.
-
-if [ -f $BINDIR/send-pr ]; then
- SPPATH=$BINDIR/send-pr
-elif [ -f $path/send-pr ]; then
- SPPATH=$path/send-pr
-else
- echo "$COMMAND: cannot find \`$BINDIR/send-pr' or \`$path/send-pr'" >&2
- exit 1
-fi
-
-trap 'rm -f $TEMP ; exit 0' 0
-trap 'echo "$COM: Aborting ..."; rm -f $TEMP ; exit 1' 1 2 3 13 15
-
-sed -e "s/^SUBMITTER=.*/SUBMITTER=${SUBMITTER}/" $SPPATH > $TEMP
-
-if grep $SUBMITTER $TEMP > /dev/null; then
- cp $SPPATH $SPPATH.orig &&
- rm -f $SPPATH &&
- cp $TEMP $SPPATH &&
- chmod a+rx $SPPATH &&
- rm -f $TEMP $SPPATH.orig ||
- { echo "$COMMAND: unable to replace send-pr" >&2 ; exit 1; }
-else
- echo "$COMMAND: something went wrong when sed-ing the submitter into send-pr" >&2
- exit 1
-fi
-
-echo "$COMMAND: \`$SUBMITTER' is now the default submitter ID for send-pr"
-
-exit 0
diff --git a/gnu/usr.bin/send-pr/send-pr-el.in b/gnu/usr.bin/send-pr/send-pr-el.in
deleted file mode 100644
index 649dfd5..0000000
--- a/gnu/usr.bin/send-pr/send-pr-el.in
+++ /dev/null
@@ -1,744 +0,0 @@
-;;;; -*-emacs-lisp-*-
-;;;;---------------------------------------------------------------------------
-;;;; EMACS interface for send-pr (by Heinz G. Seidl, hgs@cygnus.com)
-;;;; Slightly hacked by Brendan Kehoe (brendan@cygnus.com).
-;;;;
-;;;; This file is part of the Problem Report Management System (GNATS)
-;;;; Copyright 1992, 1993 Cygnus Support
-;;;;
-;;;; 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 of the License, 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 Library General Public
-;;;; License along with this program; if not, write to the Free
-;;;; Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-;;;;
-;;;;---------------------------------------------------------------------------
-;;;;
-;;;; This file contains the EMACS interface to the Problem Report Management
-;;;; System (GNATS):
-;;;;
-;;;; - The `send-pr' command and the `send-pr-mode' for sending
-;;;; Problem Reports (PRs).
-;;;;
-;;;; For more information about how to send a PR see send-pr(1).
-;;;;
-;;;;---------------------------------------------------------------------------
-;;;;
-;;;; Configuration: the symbol `DEFAULT-RELEASE' can be replaced by
-;;;; site/release specific strings during the configuration/installation
-;;;; process.
-;;;;
-;;;; Install this file in your EMACS library directory.
-;;;;
-;;;;---------------------------------------------------------------------------
-
-(provide 'send-pr)
-
-;;;;---------------------------------------------------------------------------
-;;;; Customization: put the following forms into your default.el file
-;;;; (or into your .emacs)
-;;;;---------------------------------------------------------------------------
-
-;(autoload 'send-pr-mode "send-pr"
-; "Major mode for sending problem reports." t)
-
-;(autoload 'send-pr "send-pr"
-; "Command to create and send a problem report." t)
-
-;;;;---------------------------------------------------------------------------
-;;;; End of Customization Section
-;;;;---------------------------------------------------------------------------
-
-(autoload 'server-buffer-done "server")
-(defvar server-buffer-clients nil)
-(defvar mail-self-blind nil)
-(defvar mail-default-reply-to nil)
-
-(defconst send-pr::version "3.2")
-
-(defvar gnats:root "/home/gnats"
- "*The top of the tree containing the GNATS database.")
-
-;;;;---------------------------------------------------------------------------
-;;;; hooks
-;;;;---------------------------------------------------------------------------
-
-(defvar text-mode-hook nil) ; we define it here in case it's not defined
-(defvar send-pr-mode-hook text-mode-hook "Called when send-pr is invoked.")
-
-;;;;---------------------------------------------------------------------------
-;;;; Domains and default values for (some of) the Problem Report fields;
-;;;; constants and definitions.
-;;;;---------------------------------------------------------------------------
-
-(defconst gnats::emacs-19p
- (not (or (and (boundp 'epoch::version) epoch::version)
- (string-lessp emacs-version "19")))
- "Is this emacs v19?")
-
-;;; These may be changed during configuration/installation or by the individual
-;;; user in his/her .emacs file.
-;;;
-(defun gnats::get-config (var)
- (let ((shell-file-name "/bin/sh")
- (buf (generate-new-buffer " *GNATS config*"))
- ret)
- (save-excursion
- (set-buffer buf)
- (shell-command (concat ". " gnats:root "/gnats-adm/config; echo $" var )
- t)
- (if (looking-at "^\\.:\\|/bin/sh:\\|\n")
- (setq ret nil)
- (setq ret (buffer-substring (point-min) (- (point-max) 1)))))
- (kill-buffer buf)
- ret))
-
-;; const because it must match the script's value
-(defconst send-pr:datadir (or (gnats::get-config "DATADIR") "@DATADIR@")
- "*Where the `gnats' subdirectory containing category lists lives.")
-
-(defvar send-pr::sites nil
- "List of GNATS support sites; computed at runtime.")
-(defvar send-pr:default-site
- (or (gnats::get-config "GNATS_SITE") "freefall")
- "Default site to send bugs to.")
-(defvar send-pr:::site send-pr:default-site
- "The site to which a problem report is currently being submitted, or NIL
-if using the default site (buffer local).")
-
-(defvar send-pr:::categories nil
- "Buffer local list of available categories, derived at runtime from
-send-pr:::site and send-pr::category-alist.")
-(defvar send-pr::category-alist nil
- "Alist of GNATS support sites and the categories supported at each; computed
-at runtime.")
-
-;;; Ideally we would get all the following values from a central database
-;;; during runtime instead of having them here in the code.
-;;;
-(defconst send-pr::fields
- (` (("Category" send-pr::set-categories
- (, (or (gnats::get-config "DEFAULT_CATEGORY") nil)) enum)
- ("Class" (("sw-bug") ("doc-bug") ("change-request"))
- (, (or (gnats::get-config "DEFAULT_CONFIDENTIAL") 0)) enum)
- ("Confidential" (("yes") ("no"))
- (, (or (gnats::get-config "DEFAULT_CONFIDENTIAL") 1)) enum)
- ("Severity" (("non-critical") ("serious") ("critical"))
- (, (or (gnats::get-config "DEFAULT_SEVERITY") 1)) enum)
- ("Priority" (("low") ("medium") ("high"))
- (, (or (gnats::get-config "DEFAULT_PRIORITY") 1)) enum)
- ("Release" nil
- (, (or (gnats::get-config "DEFAULT_RELEASE") "@DEFAULT_RELEASE@"))
- text)
- ("Submitter-Id" nil
- (, (or (gnats::get-config "DEFAULT_SUBMITTER") "unknown"))
- text)
- ("Synopsis" nil nil text
- (lambda (a b c) (gnats::set-mail-field "Subject" c)))))
- "AList, keyed on the name of the field, of:
-1) The field name.
-2) The list of completions. This can be a list, a function to call, or nil.
-3) The default value.
-4) The type of the field.
-5) A sub-function to call when changed.")
-
-(defvar gnats::fields nil)
-
-(defmacro gnats::push (i l)
- (` (setq (, l) (cons (,@ (list i l))))))
-
-(defun send-pr::set-categories (&optional arg)
- "Get the list of categories for the current site out of
-send-pr::category-alist if there or from send-pr if not. With arg, force
-update."
- ;;
- (let ((entry (assoc send-pr:::site send-pr::category-alist)))
- (or (and entry (null arg))
- (let ((oldpr (getenv "GNATS_ROOT")) cats)
- (send-pr::set-sites arg)
- (setenv "GNATS_ROOT" gnats:root)
- (setq cats (gnats::get-value-from-shell
- "send-pr" "-CL" send-pr:::site))
- (setenv "GNATS_ROOT" oldpr)
- (if entry (setcdr entry cats)
- (setq entry (cons send-pr:::site cats))
- (gnats::push entry send-pr::category-alist))))
- (setq send-pr:::categories (cdr entry))))
-
-(defun send-pr::set-sites (&optional arg)
- "Get the list of sites (by listing the contents of DATADIR/gnats) and assign
-it to send-pr::sites. With arg, force update."
- (or (and (null arg) send-pr::sites)
- (progn
- (setq send-pr::sites nil)
- (mapcar
- (function
- (lambda (file)
- (or (memq t (mapcar (function (lambda (x) (string= x file)))
- '("." ".." "pr-edit" "pr-addr")))
- (not (file-readable-p file))
- (gnats::push (list (file-name-nondirectory file))
- send-pr::sites))))
- (directory-files (format "%s/gnats" send-pr:datadir) t))
- (setq send-pr::sites (reverse send-pr::sites)))))
-
-(defconst send-pr::pr-buffer-name "*send-pr*"
- "Name of the temporary buffer, where the problem report gets composed.")
-
-(defconst send-pr::err-buffer-name "*send-pr-error*"
- "Name of the temporary buffer, where send-pr error messages appear.")
-
-(defvar send-pr:::err-buffer nil
- "The error buffer used by the current PR buffer.")
-
-(defconst gnats::indent 17 "Indent for formatting the value.")
-
-;;;;---------------------------------------------------------------------------
-;;;; `send-pr' - command for creating and sending of problem reports
-;;;;---------------------------------------------------------------------------
-
-(fset 'send-pr 'send-pr:send-pr)
-(defun send-pr:send-pr (&optional site)
- "Create a buffer and read in the result of `send-pr -P'.
-When finished with editing the problem report use \\[send-pr:submit-pr]
-to send the PR with `send-pr -b -f -'."
- ;;
- (interactive
- (if current-prefix-arg
- (list (completing-read "Site: " (send-pr::set-sites 'recheck) nil t
- send-pr:default-site))))
- (or site (setq site send-pr:default-site))
- (let ((buf (get-buffer send-pr::pr-buffer-name)))
- (if (or (not buf)
- (progn (switch-to-buffer buf)
- (cond ((or (not (buffer-modified-p buf))
- (y-or-n-p "Erase previous problem report? "))
- (erase-buffer) t)
- (t nil))))
- (send-pr::start-up site))))
-
-(defun send-pr::start-up (site)
- (switch-to-buffer (get-buffer-create send-pr::pr-buffer-name))
- (setq default-directory (expand-file-name "~/"))
- (auto-save-mode auto-save-default)
- (let ((oldpr (getenv "GNATS_ROOT"))
- (case-fold-search nil))
- (setenv "GNATS_ROOT" gnats:root)
- (shell-command (concat "send-pr -P " site) t)
- (setenv "GNATS_ROOT" oldpr)
- (if (looking-at "send-pr:")
- (cond ((looking-at "send-pr: .* does not have a categories list")
- (setq send-pr::sites nil)
- (error "send-pr: the GNATS site %s does not have a categories list" site))
- (t (error (buffer-substring (point-min) (point-max)))))
- (save-excursion
- ;; Clear cruft inserted by bdamaged .cshrcs
- (re-search-forward "^SEND-PR:")
- (delete-region 1 (match-beginning 0)))))
- (set-buffer-modified-p nil)
- (send-pr:send-pr-mode)
- (setq send-pr:::site site)
- (send-pr::set-categories)
- (if (null send-pr:::categories)
- (progn
- (and send-pr:::err-buffer (kill-buffer send-pr:::err-buffer))
- (kill-buffer nil)
- (message "send-pr: no categories found"))
- (and mail-default-reply-to
- (gnats::set-mail-field "Reply-To" mail-default-reply-to))
- (and mail-self-blind
- (gnats::set-mail-field "BCC" (user-login-name)))
- (mapcar 'send-pr::maybe-change-field send-pr::fields)
- (gnats::position-on-field "Description")
- (message (substitute-command-keys
- "To send the problem report use: \\[send-pr:submit-pr]"))))
-
-(fset 'do-send-pr 'send-pr:submit-pr) ;backward compat
-(defun send-pr:submit-pr ()
- "Pipe the contents of the buffer *send-pr* to `send-pr -f -.' unless this
-buffer was loaded with emacsclient, in which case save the buffer and exit."
- ;;
- (interactive)
- (cond
- ((and (boundp 'server-buffer-clients)
- server-buffer-clients)
- (let ((buffer (current-buffer))
- (version-control nil) (buffer-backed-up nil))
- (save-buffer buffer)
- (kill-buffer buffer)
- (server-buffer-done buffer)))
- (t
- (or (and send-pr:::err-buffer
- (buffer-name send-pr:::err-buffer))
- (setq send-pr:::err-buffer
- (get-buffer-create send-pr::err-buffer-name)))
- (let ((err-buffer send-pr:::err-buffer) mesg ok)
- (save-excursion (set-buffer err-buffer) (erase-buffer))
- (message "running send-pr...")
- (let ((oldpr (getenv "GNATS_ROOT")))
- (setenv "GNATS_ROOT" gnats:root)
- (call-process-region (point-min) (point-max) "send-pr"
- nil err-buffer nil send-pr:::site
- "-b" "-f" "-")
- (setenv "GNATS_ROOT" oldpr))
- (message "running send-pr...done")
- ;; stupidly we cannot check the return value in EMACS 18.57, thus we need
- ;; this kluge to find out whether send-pr succeeded.
- (if (save-excursion
- (set-buffer err-buffer)
- (goto-char (point-min))
- (setq mesg (buffer-substring (point-min) (- (point-max) 1)))
- (search-forward "problem report sent" nil t))
- (progn (message mesg)
- (kill-buffer err-buffer)
- (delete-auto-save-file-if-necessary)
- (set-buffer-modified-p nil)
- (bury-buffer))
- (pop-to-buffer err-buffer))
- ))))
-
-;;;;---------------------------------------------------------------------------
-;;;; send-pr:send-pr-mode mode
-;;;;---------------------------------------------------------------------------
-
-(defvar send-pr-mode-map
- (let ((map (make-sparse-keymap)))
- (define-key map "\C-c\C-c" 'send-pr:submit-pr)
- (define-key map "\C-c\C-f" 'gnats:change-field)
- (define-key map "\M-n" 'gnats:next-field)
- (define-key map "\M-p" 'gnats:previous-field)
- (define-key map "\C-\M-f" 'gnats:forward-field)
- (define-key map "\C-\M-b" 'gnats:backward-field)
- map)
- "Keymap for send-pr mode.")
-
-(defconst gnats::keyword "^>\\([-a-zA-Z]+\\):")
-(defconst gnats::before-keyword "[ \t\n\f]*[\n\f]+>\\([-a-zA-Z]+\\):")
-(defconst gnats::after-keyword "^>\\([-a-zA-Z]+\\):[ \t\n\f]+")
-
-(fset 'send-pr-mode 'send-pr:send-pr-mode)
-(defun send-pr:send-pr-mode ()
- "Major mode for submitting problem reports.
-For information about the form see gnats(1) and send-pr(1).
-Special commands: \\{send-pr-mode-map}
-Turning on send-pr-mode calls the value of the variable send-pr-mode-hook,
-if it is not nil."
- (interactive)
- (gnats::patch-exec-path)
- (put 'send-pr:send-pr-mode 'mode-class 'special)
- (kill-all-local-variables)
- (setq major-mode 'send-pr:send-pr-mode)
- (setq mode-name "send-pr")
- (use-local-map send-pr-mode-map)
- (set-syntax-table text-mode-syntax-table)
- (setq local-abbrev-table text-mode-abbrev-table)
- (setq buffer-offer-save t)
- (make-local-variable 'send-pr:::site)
- (make-local-variable 'send-pr:::categories)
- (make-local-variable 'send-pr:::err-buffer)
- (make-local-variable 'paragraph-separate)
- (setq paragraph-separate (concat (default-value 'paragraph-separate)
- "\\|" gnats::keyword "[ \t\n\f]*$"))
- (make-local-variable 'paragraph-start)
- (setq paragraph-start (concat (default-value 'paragraph-start)
- "\\|" gnats::keyword))
- (run-hooks 'send-pr-mode-hook)
- t)
-
-;;;;---------------------------------------------------------------------------
-;;;; Functions to read and replace field values.
-;;;;---------------------------------------------------------------------------
-
-(defun gnats::position-on-field (field)
- (goto-char (point-min))
- (if (not (re-search-forward (concat "^>" field ":") nil t))
- (error "Field `>%s:' not found." field)
- (re-search-forward "[ \t\n\f]*")
- (if (looking-at gnats::keyword)
- (backward-char 1))
- t))
-
-(defun gnats::mail-position-on-field (field)
- (let (end
- (case-fold-search t))
- (goto-char (point-min))
- (re-search-forward "^$")
- (setq end (match-beginning 0))
- (goto-char (point-min))
- (if (not (re-search-forward (concat "^" field ":") end 'go-to-end))
- (insert field ": \n")
- (re-search-forward "[ \t\n\f]*"))
- (skip-chars-backward "\n")
- t))
-
-(defun gnats::field-contents (field &optional elem move)
- (let (pos)
- (unwind-protect
- (save-excursion
- (if (not (gnats::position-on-field field))
- nil
- (setq pos (point-marker))
- (if (or (looking-at "<.*>$") (eolp))
- t
- (looking-at ".*$") ; to set match-{beginning,end}
- (gnats::nth-word
- (buffer-substring (match-beginning 0) (match-end 0))
- elem))))
- (and move pos (goto-char pos)))))
-
-(defun gnats::functionp (thing)
- (or (and (symbolp thing) (fboundp thing))
- (and (listp thing) (eq (car thing) 'lambda))))
-
-(defun gnats::field-values (field)
- "Return the possible (known) values for field FIELD."
- (let* ((fields (if (eq major-mode 'gnats:gnats-mode) gnats::fields
- send-pr::fields))
- (thing (elt (assoc field fields) 1)))
- (cond ((gnats::functionp thing) (funcall thing))
- ((listp thing) thing)
- (t (error "ACK")))))
-
-(defun gnats::field-default (field)
- "Return the default value for field FIELD."
- (let* ((fields (if (eq major-mode 'gnats:gnats-mode) gnats::fields
- send-pr::fields))
- (thing (elt (assoc field fields) 2)))
- (cond ((stringp thing) thing)
- ((null thing) "")
- ((numberp thing) (car (elt (gnats::field-values field) thing)))
- ((gnats::functionp thing)
- (funcall thing (gnats::field-contents field)))
- ((eq thing t) (gnats::field-contents field))
- (t (error "ACK")))))
-
-(defun gnats::field-type (field)
- "Return the type of field FIELD."
- (let* ((fields (if (eq major-mode 'gnats:gnats-mode) gnats::fields
- send-pr::fields))
- (thing (elt (assoc field fields) 3)))
- thing))
-
-(defun gnats::field-action (field)
- "Return the extra handling function for field FIELD."
- (let* ((fields (if (eq major-mode 'gnats:gnats-mode) gnats::fields
- send-pr::fields))
- (thing (elt (assoc field fields) 4)))
- (cond ((null thing) 'ignore)
- ((gnats::functionp thing) thing)
- (t (error "ACK")))))
-
-;;;;---------------------------------------------------------------------------
-;;;; Point movement functions
-;;;;---------------------------------------------------------------------------
-
-(or (fboundp 'defsubst) (fset 'defsubst 'defun))
-
-(defun send-pr::maybe-change-field (field)
- (setq field (car field))
- (let ((thing (gnats::field-contents field)))
- (and thing (eq t thing)
- (not (eq 'multi-text (gnats::field-type field)))
- (gnats:change-field field))))
-
-(defun gnats:change-field (&optional field default)
- "Change the value of the field containing the cursor. With arg, ask the
-user for the field to change. From a program, the function takes optional
-arguments of the field to change and the default value to use."
- (interactive)
- (or field current-prefix-arg (setq field (gnats::current-field)))
- (or field
- (setq field
- (completing-read "Field: "
- (if (eq major-mode 'gnats:gnats-mode)
- gnats::fields
- send-pr::fields)
- nil t)))
- (gnats::position-on-field field)
- (sit-for 0)
- (let* ((old (gnats::field-contents field))
- new)
- (if (null old)
- (error "ACK")
- (let ((prompt (concat ">" field ": "))
- (domain (gnats::field-values field))
- (type (gnats::field-type field))
- (action (gnats::field-action field)))
- (or default (setq default (gnats::field-default field)))
- (setq new (if (eq type 'enum)
- (completing-read prompt domain nil t
- (if gnats::emacs-19p (cons default 0)
- default))
- (read-string prompt (if gnats::emacs-19p (cons default 1)
- default))))
- (gnats::set-field field new)
- (funcall action field old new)
- new))))
-
-(defun gnats::set-field (field value)
- (save-excursion
- (gnats::position-on-field field)
- (delete-horizontal-space)
- (looking-at ".*$")
- (replace-match
- (concat (make-string (- gnats::indent (length field) 2) ?\40 ) value) t)))
-
-(defun gnats::set-mail-field (field value)
- (save-excursion
- (gnats::mail-position-on-field field)
- (delete-horizontal-space)
- (looking-at ".*$")
- (replace-match (concat " " value) t)))
-
-(defun gnats::before-keyword (&optional where)
- "Returns t if point is in some white space before a keyword.
-If where is nil, then point is not changed; if where is t then point is moved
-to the beginning of the keyword, otherwise it is moved to the beginning
-of the white space it was in."
- ;;
- (if (looking-at gnats::before-keyword)
- (prog1 t
- (cond ((eq where t)
- (re-search-forward "^>") (backward-char))
- ((not (eq where nil))
- (re-search-backward "[^ \t\n\f]") (forward-char))))
- nil))
-
-(defun gnats::after-keyword (&optional where)
- "Returns t if point is in some white space after a keyword.
-If where is nil, then point is not changed; if where is t then point is moved
-to the beginning of the keyword, otherwise it is moved to the end of the white
-space it was in."
- ;;
- (if (gnats::looking-after gnats::after-keyword)
- (prog1 t
- (cond ((eq where t)
- (re-search-backward "^>"))
- ((not (eq where nil))
- (re-search-forward "[^ \t\n\f]") (backward-char))))
- nil))
-
-(defun gnats::in-keyword (&optional where)
- "Returns t if point is within a keyword.
-If where is nil, then point is not changed; if where is t then point is moved
-to the beginning of the keyword."
- ;;
- (let ((old-point (point-marker)))
- (beginning-of-line)
- (cond ((and (looking-at gnats::keyword)
- (< old-point (match-end 0)))
- (prog1 t
- (if (eq where t)
- t
- (goto-char old-point))))
- (t (goto-char old-point)
- nil))))
-
-(defun gnats::forward-bofield ()
- "Moves point to the beginning of a field. Assumes that point is in the
-keyword."
- ;;
- (if (re-search-forward "[ \t\n\f]+[^ \t\n\f]" (point-max) '-)
- (backward-char)
- t))
-
-(defun gnats::backward-eofield ()
- "Moves point to the end of a field. Assumes point is in the keyword."
- ;;
- (if (re-search-backward "[^ \t\n\f][ \t\n\f]+" (point-min) '-)
- (forward-char)
- t))
-
-(defun gnats::forward-eofield ()
- "Moves point to the end of a field. Assumes that point is in the field."
- ;;
- ;; look for the next field
- (if (re-search-forward gnats::keyword (point-max) '-)
- (progn (beginning-of-line) (gnats::backward-eofield))
- (re-search-backward "[^ \t\n\f][ \t\n\f]*" (point-min) '-)
- (forward-char)))
-
-(defun gnats::backward-bofield ()
- "Moves point to the beginning of a field. Assumes that point is in the
-field."
- ;;
- ;;look for previous field
- (if (re-search-backward gnats::keyword (point-min) '-)
- (gnats::forward-bofield)
- t))
-
-
-(defun gnats:forward-field ()
- "Move point forward to the end of the field or to the beginning of the next
-field."
- ;;
- (interactive)
- (if (or (gnats::before-keyword t) (gnats::in-keyword t)
- (gnats::after-keyword t))
- (gnats::forward-bofield)
- (gnats::forward-eofield)))
-
-(defun gnats:backward-field ()
- "Move point backward to the beginning/end of a field."
- ;;
- (interactive)
- (backward-char)
- (if (or (gnats::before-keyword t) (gnats::in-keyword t)
- (gnats::after-keyword t))
- (gnats::backward-eofield)
- (gnats::backward-bofield)))
-
-(defun gnats:next-field ()
- "Move point to the beginning of the next field."
- ;;
- (interactive)
- (if (or (gnats::before-keyword t) (gnats::in-keyword t)
- (gnats::after-keyword t))
- (gnats::forward-bofield)
- (if (re-search-forward gnats::keyword (point-max) '-)
- (gnats::forward-bofield)
- t)))
-
-(defun gnats:previous-field ()
- "Move point to the beginning of the previous field."
- ;;
- (interactive)
- (backward-char)
- (if (or (gnats::after-keyword t) (gnats::in-keyword t)
- (gnats::before-keyword t))
- (progn (re-search-backward gnats::keyword (point-min) '-)
- (gnats::forward-bofield))
- (gnats::backward-bofield)))
-
-(defun gnats:beginning-of-field ()
- "Move point to the beginning of the current field."
- (interactive)
- (cond ((gnats::in-keyword t)
- (gnats::forward-bofield))
- ((gnats::after-keyword 0))
- (t
- (gnats::backward-bofield))))
-
-(defun gnats::current-field ()
- (save-excursion
- (if (cond ((or (gnats::in-keyword t) (gnats::after-keyword t))
- (looking-at gnats::keyword))
- ((re-search-backward gnats::keyword nil t)))
- (buffer-substring (match-beginning 1) (match-end 1))
- nil)))
-
-;;;;---------------------------------------------------------------------------
-;;;; Support functions
-;;;;---------------------------------------------------------------------------
-
-(defun gnats::looking-after (regex)
- "Returns t if point is after regex."
- ;;
- (let* ((old-point (point))
- (start (if (eobp)
- old-point
- (forward-char) (point))))
- (cond ((re-search-backward regex (point-min) t)
- (goto-char old-point)
- (cond ((eq (match-end 0) start)
- t))))))
-
-(defun gnats::nth-word (string &optional elem)
- "Returns the elem-th word of the string.
-If elem is nil, then the first wort is returned, if elem is 0 then
-the whole string is returned."
- ;;
- (if (integerp elem)
- (cond ((eq elem 0) string)
- ((eq elem 1) (gnats::first-word string))
- ((equal string "") "")
- ((>= elem 2)
- (let ((i 0) (value ""))
- (setq string ; strip leading blanks
- (substring string (or (string-match "[^ \t]" string) 0)))
- (while (< i elem)
- (setq value
- (substring string 0
- (string-match "[ \t]*$\\|[ \t]+" string)))
- (setq string
- (substring string (match-end 0)))
- (setq i (+ i 1)))
- value)))
- (gnats::first-word string)))
-
-(defun gnats::first-word (string)
- (setq string
- (substring string (or (string-match "[^ \t]" string) 0)))
- (substring string 0 (string-match "[ \t]*$\\|[ \t]+" string)))
-
-;;;;---------------------------------------------------------------------------
-
-(defun gnats::patch-exec-path ()
- ;;
- "Replaces `//' by `/' in `exec-path'."
- ;;
- ;(make-local-variable 'exec-path)
- (let ((err-buffer (get-buffer-create " *gnats::patch-exec-path*"))
- (ret))
- (setq exec-path (save-excursion (set-buffer err-buffer)
- (prin1 exec-path err-buffer)
- (goto-char (point-min))
- (replace-string "//" "/")
- (goto-char (point-min))
- (setq ret (read err-buffer))
- (kill-buffer err-buffer)
- ret
- ))))
-
-(defun gnats::get-value-from-shell (&rest command)
- "Execute shell command to get a list of valid values for `variable'."
- ;;
- (let ((err-buffer (get-buffer-create " *gnats::get-value-from-shell*")))
- (save-excursion
- (set-buffer err-buffer)
- (unwind-protect
- (condition-case var
- (progn
- (apply 'call-process
- (car command) nil err-buffer nil (cdr command))
- (goto-char (point-min))
- (if (looking-at "[-a-z]+: ")
- (error (buffer-substring (point-min) (point-max))))
- (read err-buffer))
- (error nil))
- (kill-buffer err-buffer)))))
-
-(or (fboundp 'setenv)
- (defun setenv (variable &optional value)
- "Set the value of the environment variable named VARIABLE to VALUE.
-VARIABLE should be a string. VALUE is optional; if not provided or is
-`nil', the environment variable VARIABLE will be removed.
-This function works by modifying `process-environment'."
- (interactive "sSet environment variable: \nsSet %s to value: ")
- (if (string-match "=" variable)
- (error "Environment variable name `%s' contains `='" variable)
- (let ((pattern (concat "\\`" (regexp-quote (concat variable "="))))
- (case-fold-search nil)
- (scan process-environment))
- (while scan
- (cond
- ((string-match pattern (car scan))
- (if (eq nil value)
- (setq process-environment (delq (car scan)
- process-environment))
- (setcar scan (concat variable "=" value)))
- (setq scan nil))
- ((null (setq scan (cdr scan)))
- (setq process-environment
- (cons (concat variable "=" value)
- process-environment)))))))))
-
-;;;; end of send-pr.el
diff --git a/gnu/usr.bin/send-pr/send-pr.1 b/gnu/usr.bin/send-pr/send-pr.1
deleted file mode 100644
index dc8f50d..0000000
--- a/gnu/usr.bin/send-pr/send-pr.1
+++ /dev/null
@@ -1,246 +0,0 @@
-.\" -*- nroff -*-
-.\" ---------------------------------------------------------------------------
-.\" man page for send-pr (by Heinz G. Seidl, hgs@cygnus.com)
-.\" updated Feb 1993 for GNATS 3.00 by Jeffrey Osier, jeffrey@cygnus.com
-.\"
-.\" This file is part of the Problem Report Management System (GNATS)
-.\" Copyright 1992 Cygnus Support
-.\"
-.\" 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 of the License, 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 Library General Public
-.\" License along with this program; if not, write to the Free
-.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
-.\"
-.\" ---------------------------------------------------------------------------
-.nh
-.TH SEND-PR 1 3.2 "February 1993"
-.SH NAME
-send-pr \- send problem report (PR) to a central support site
-.SH SYNOPSIS
-.B send-pr
-[
-.I site
-]
-[
-.B \-f
-.I problem-report
-]
-[
-.B \-t
-.I mail-address
-]
-.br
-.in +0.8i
-[
-.B \-P
-]
-[
-.B \-L
-]
-[
-.B \-\-request-id
-]
-[
-.B \-v
-]
-.SH DESCRIPTION
-.B send-pr
-is a tool used to submit
-.I problem reports
-.\" SITE ADMINISTRATORS - change this if you use a local default
-(PRs) to a central support site. In most cases the correct
-.I site
-will be the default. This argument indicates the support site which
-is responsible for the category of problem involved. Some sites may
-use a local address as a default.
-.I site
-values are defined by using the
-.BR aliases (5).
-.LP
-.B send-pr
-invokes an editor on a problem report template (after trying to fill
-in some fields with reasonable default values). When you exit the
-editor,
-.B send-pr
-sends the completed form to the
-.I Problem Report Management System
-(\fBGNATS\fR) at a central support site. At the support site, the PR
-is assigned a unique number and is stored in the \fBGNATS\fR database
-according to its category and submitter-id. \fBGNATS\fR automatically
-replies with an acknowledgement, citing the category and the PR
-number.
-.LP
-To ensure that a PR is handled promptly, it should contain
-one of the available \fIcategories\fR to identify the
-problem area. (Use
-.B `send-pr -L'
-to see a list of categories.)
-.LP
-The more precise your problem description and the more complete your
-information, the faster your support team can solve your problems.
-.SH OPTIONS
-.TP
-.BI \-f " problem-report"
-specify a file (\fIproblem-report\fR) which already contains a
-complete problem report.
-.B send-pr
-sends the contents of the file without invoking the editor. If
-the value for
-.I problem-report
-is
-.BR `\|\-\|' ,
-then
-.B send-pr
-reads from standard input.
-.TP
-.BI \-t " mail-address"
-Change mail address at the support site for problem reports. The
-default
-.I mail-address
-is the address used for the default
-.IR site .
-Use the
-.I site
-argument rather than this option in nearly all cases.
-.TP
-.B \-P
-print the form specified by the environment variable
-.B PR_FORM
-on standard output. If
-.B PR_FORM
-is not set, print the standard blank PR template. No mail is sent.
-.TP
-.B -L
-print the list of available categories. No mail is sent.
-.TP
-.B \-\-request\-id
-sends mail to the default support site, or
-.I site
-if specified, with a request for your
-.IR submitter-id .
-If you are
-not affiliated with
-.IR site ,
-use a
-.I submitter-id
-of
-.BR net \|'.
-.TP
-.B \-v
-Display the
-.B send-pr
-version number.
-.LP
-Note: use
-.B send-pr
-to submit problem reports rather than mailing them directly. Using
-both the template and
-.B send-pr
-itself will help ensure all necessary information will reach the
-support site.
-.SH ENVIRONMENT
-The environment variable
-.B EDITOR
-specifies the editor to invoke on the template.
-.br
-default:
-.B vi
-.sp
-If the environment variable
-.B PR_FORM
-is set, then its value is used as the file name of the template for
-your problem-report editing session. You can use this to start with a
-partially completed form (for example, a form with the identification
-fields already completed).
-.SH "HOW TO FILL OUT A PROBLEM REPORT"
-Problem reports have to be in a particular form so that a program can
-easily manage them. Please remember the following guidelines:
-.IP \(bu 3m
-describe only
-.B one problem
-with each problem report.
-.IP \(bu 3m
-For follow-up mail, use the same subject line as the one in the automatic
-acknowledgement. It consists of category, PR number and the original synopsis
-line. This allows the support site to relate several mail messages to a
-particular PR and to record them automatically.
-.IP \(bu 3m
-Please try to be as accurate as possible in the subject and/or synopsis line.
-.IP \(bu 3m
-The subject and the synopsis line are not confidential. This is
-because open-bugs lists are compiled from them. Avoid confidential
-information there.
-.LP
-See the GNU
-.B Info
-file
-.B send-pr.info
-or the document \fIReporting Problems With send-pr\fR\ for detailed
-information on reporting problems
-.SH "HOW TO SUBMIT TEST CASES, CODE, ETC."
-Submit small code samples with the PR. Contact the support site for
-instructions on submitting larger test cases and problematic source
-code.
-.SH FILES
-.ta \w'/tmp/pbad$$ 'u
-/tmp/p$$ copy of PR used in editing session
-.br
-/tmp/pf$$ copy of empty PR form, for testing purposes
-.br
-/tmp/pbad$$ file for rejected PRs
-.SH EMACS USER INTERFACE
-An Emacs user interface for
-.B send-pr
-with completion of field values is part of the
-.B send-pr
-distribution (invoked with
-.BR "M-x send-pr" ).
-See the file
-.B send-pr.info
-or the ASCII file
-.B INSTALL
-in the top level directory of the distribution for configuration and
-installation information. The Emacs LISP template file is
-.B send-pr-el.in
-and is installed as
-.BR send-pr.el .
-.SH INSTALLATION AND CONFIGURATION
-See
-.B send-pr.info
-or
-.B INSTALL
-for installation instructions.
-.SH SEE ALSO
-.I Reporting Problems Using send-pr
-(also installed as the GNU Info file
-.BR send-pr.info ).
-.SH AUTHORS
-Jeffrey Osier, Brendan Kehoe, Jason Merrill, Heinz G. Seidl (Cygnus
-Support)
-.SH COPYING
-Copyright (c) 1992, 1993 Free Software Foundation, Inc.
-.PP
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-.PP
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-.PP
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
-
diff --git a/gnu/usr.bin/send-pr/send-pr.sh b/gnu/usr.bin/send-pr/send-pr.sh
deleted file mode 100644
index fb2f953..0000000
--- a/gnu/usr.bin/send-pr/send-pr.sh
+++ /dev/null
@@ -1,552 +0,0 @@
-#!/bin/sh
-# Submit a problem report to a GNATS site.
-# Copyright (C) 1993 Free Software Foundation, Inc.
-# Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
-# version written by Heinz G. Seidl (hgs@ide.com).
-#
-# This file is part of GNU GNATS.
-#
-# GNU GNATS 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.
-#
-# GNU GNATS 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 GNU GNATS; see the file COPYING. If not, write to
-# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: send-pr.sh,v 1.8 1997/02/22 15:48:14 peter Exp $
-
-# The version of this send-pr.
-VERSION=3.2
-
-# The submitter-id for your site.
-# "current-users" is the only allowable value for FreeBSD.
-SUBMITTER="current-users"
-
-# Where the GNATS directory lives, if at all.
-[ -z "$GNATS_ROOT" ] &&
-GNATS_ROOT=
-
-# The default mail address for PR submissions.
-GNATS_ADDR=FreeBSD-gnats-submit@freebsd.org
-
-# Where the gnats category tree lives.
-DATADIR=@DATADIR@
-
-# If we've been moved around, try using GCC_EXEC_PREFIX.
-[ ! -d $DATADIR/gnats -a -d "$GCC_EXEC_PREFIX" ] && DATADIR=@DATADIR@
-
-# The default release for this host.
-DEFAULT_RELEASE="@DEFAULT_RELEASE@"
-
-# The default organization.
-DEFAULT_ORGANIZATION=
-
-# The default site to look for.
-GNATS_SITE=freefall
-
-# Newer config information?
-[ -f ${GNATS_ROOT}/gnats-adm/config ] && . ${GNATS_ROOT}/gnats-adm/config
-
-# What mailer to use. This must come after the config file, since it is
-# host-dependent.
-MAIL_AGENT="/usr/sbin/sendmail -oi -t"
-
-ECHON=bsd
-
-if [ $ECHON = bsd ] ; then
- ECHON1="echo -n"
- ECHON2=
-elif [ $ECHON = sysv ] ; then
- ECHON1=echo
- ECHON2='\c'
-else
- ECHON1=echo
- ECHON2=
-fi
-
-#
-
-[ -z "$TMPDIR" ] && TMPDIR=/tmp
-
-TEMP=$TMPDIR/p$$
-BAD=$TMPDIR/pbad$$
-REF=$TMPDIR/pf$$
-
-if [ -z "$LOGNAME" -a -n "$USER" ]; then
- LOGNAME=$USER
-fi
-
-FROM="$LOGNAME"
-REPLY_TO="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
-
-# Find out the name of the originator of this PR.
-if [ -n "$NAME" ]; then
- ORIGINATOR="$NAME"
-elif [ -f $HOME/.fullname ]; then
- ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
-elif [ -f /bin/domainname ]; then
- if [ "`/bin/domainname`" != "" -a -f /usr/bin/ypcat ]; then
- # Must use temp file due to incompatibilities in quoting behavior
- # and to protect shell metacharacters in the expansion of $LOGNAME
- /usr/bin/ypcat passwd 2>/dev/null | cat - /etc/passwd | grep "^$LOGNAME:" |
- cut -f5 -d':' | sed -e 's/,.*//' > $TEMP
- ORIGINATOR="`cat $TEMP`"
- rm -f $TEMP
- fi
-fi
-
-if [ "$ORIGINATOR" = "" ]; then
- grep "^$LOGNAME:" /etc/passwd | cut -f5 -d':' | sed -e 's/,.*//' > $TEMP
- ORIGINATOR="`cat $TEMP`"
- rm -f $TEMP
-fi
-
-if [ -n "$ORGANIZATION" ]; then
- if [ -f "$ORGANIZATION" ]; then
- ORGANIZATION="`cat $ORGANIZATION`"
- fi
-else
- if [ -n "$DEFAULT_ORGANIZATION" ]; then
- ORGANIZATION="$DEFAULT_ORGANIZATION"
- elif [ -f $HOME/.organization ]; then
- ORGANIZATION="`cat $HOME/.organization`"
- fi
-fi
-
-# If they don't have a preferred editor set, then use
-if [ -z "$VISUAL" ]; then
- if [ -z "$EDITOR" ]; then
- EDIT=vi
- else
- EDIT="$EDITOR"
- fi
-else
- EDIT="$VISUAL"
-fi
-
-# Find out some information.
-SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
- ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
-ARCH=`[ -f /bin/arch ] && /bin/arch`
-MACHINE=`[ -f /bin/machine ] && /bin/machine`
-
-COMMAND=`echo $0 | sed -e 's,.*/,,'`
-USAGE="Usage: $COMMAND [-PVL] [-t address] [-f filename] [--request-id]
-[--version]"
-REMOVE=
-BATCH=
-
-while [ $# -gt 0 ]; do
- case "$1" in
- -r) ;; # Ignore for backward compat.
- -t | --to) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
- shift ; GNATS_ADDR="$1"
- EXPLICIT_GNATS_ADDR=true
- ;;
- -f | --file) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
- shift ; IN_FILE="$1"
- if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
- echo "$COMMAND: cannot read $IN_FILE"
- exit 1
- fi
- ;;
- -b | --batch) BATCH=true ;;
- -p | -P | --print) PRINT=true ;;
- -L | --list) FORMAT=norm ;;
- -l | -CL | --lisp) FORMAT=lisp ;;
- --request-id) REQUEST_ID=true ;;
- -h | --help) echo "$USAGE"; exit 0 ;;
- -V | --version) echo "$VERSION"; exit 0 ;;
- -*) echo "$USAGE" ; exit 1 ;;
- *) if [ -z "$USER_GNATS_SITE" ]; then
- if [ ! -r "$DATADIR/gnats/$1" ]; then
- echo "$COMMAND: the GNATS site $1 does not have a categories list."
- exit 1
- else
- # The site name is the alias they'll have to have created.
- USER_GNATS_SITE=$1
- fi
- else
- echo "$USAGE" ; exit 1
- fi
- ;;
- esac
- shift
-done
-
-if [ -n "$USER_GNATS_SITE" ]; then
- GNATS_SITE=$USER_GNATS_SITE
- GNATS_ADDR=$USER_GNATS_SITE-gnats
-fi
-
-if [ "$SUBMITTER" = "unknown" -a -z "$REQUEST_ID" -a -z "$IN_FILE" ]; then
- cat << '__EOF__'
-It seems that send-pr is not installed with your unique submitter-id.
-You need to run
-
- install-sid YOUR-SID
-
-where YOUR-SID is the identification code you received with `send-pr'.
-`send-pr' will automatically insert this value into the template field
-`>Submitter-Id'. If you've downloaded `send-pr' from the Net, use `net'
-for this value. If you do not know your id, run `send-pr --request-id' to
-get one from your support site.
-__EOF__
- exit 1
-fi
-
-if [ -r "$DATADIR/gnats/$GNATS_SITE" ]; then
- CATEGORIES=`grep -v '^#' $DATADIR/gnats/$GNATS_SITE | sort`
-else
- echo "$COMMAND: could not read $DATADIR/gnats/$GNATS_SITE for categories list."
- exit 1
-fi
-
-if [ -z "$CATEGORIES" ]; then
- echo "$COMMAND: the categories list for $GNATS_SITE was empty!"
- exit 1
-fi
-
-case "$FORMAT" in
- lisp) echo "$CATEGORIES" | \
- awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
- exit 0
- ;;
- norm) l=`echo "$CATEGORIES" | \
- awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
- END {print max + 1;}'`
- c=`expr 70 / $l`
- if [ $c -eq 0 ]; then c=1; fi
- echo "$CATEGORIES" | \
- awk 'BEGIN {print "Known categories:"; i = 0 }
- { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
- END { print ""; }'
- exit 0
- ;;
-esac
-
-CATEGORY_C=`echo "$CATEGORIES" | \
- awk 'BEGIN { ORS=""; print "<[ " }
- FNR > 1 { print " | " }
- { print }
- END { print " ]>" }`
-
-ORIGINATOR_C='<Name of the PR author (one line)>'
-ORGANIZATION_C='<Organization of PR author (multiple lines)>'
-CONFIDENTIAL_C='<[ yes | no ] (one line)>'
-SYNOPSIS_C='<Synopsis of the problem (one line)>'
-SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
-PRIORITY_C='<[ low | medium | high ] (one line)>'
-CLASS_C='<[ sw-bug | doc-bug | change-request ] (one line)>'
-RELEASE_C='<Release number or tag (one line)>'
-ENVIRONMENT_C='<Relevant environment information (multiple lines)>'
-DESCRIPTION_C='<Precise description of the problem (multiple lines)>'
-HOW_TO_REPEAT_C='<Code/input/activities to reproduce the problem (multiple lines)>'
-FIX_C='<How to correct or work around the problem, if known (multiple lines)>'
-
-# Catch some signals. ($xs kludge needed by Sun /bin/sh)
-xs=0
-trap 'rm -f $REF $TEMP; exit $xs' 0
-trap 'echo "$COMMAND: Aborting ..."; rm -f $REF $TEMP; xs=1; exit' 1 2 3 13 15
-
-# If they told us to use a specific file, then do so.
-if [ -n "$IN_FILE" ]; then
- if [ "$IN_FILE" = "-" ]; then
- # The PR is coming from the standard input.
- if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
- sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
- else
- cat > $TEMP
- fi
- else
- # Use the file they named.
- if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
- sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
- else
- cat $IN_FILE > $TEMP
- fi
- fi
-else
-
- if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
- # If their PR_FORM points to a bogus entry, then bail.
- if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
- echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
- sleep 1
- PRINT_INTERN=bad_prform
- fi
- fi
-
- if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
- cp $PR_FORM $TEMP ||
- ( echo "$COMMAND: could not copy $PR_FORM" ; xs=1; exit )
- else
- for file in $TEMP $REF ; do
- cat > $file << '__EOF__'
-SEND-PR: -*- send-pr -*-
-SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as
-SEND-PR: will all comments (text enclosed in `<' and `>').
-SEND-PR:
-SEND-PR: Please consult the send-pr man page `send-pr(1)' or the Texinfo
-SEND-PR: manual if you are not sure how to fill out a problem report.
-SEND-PR:
-SEND-PR: Note that the Synopsis field is mandatory. The Subject (for
-SEND-PR: the mail) will be made the same as Synopsis unless explicitly
-SEND-PR: changed.
-SEND-PR:
-SEND-PR: Choose from the following categories:
-SEND-PR:
-__EOF__
-
- # Format the categories so they fit onto lines.
- l=`echo "$CATEGORIES" | \
- awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
- END {print max + 1;}'`
- c=`expr 61 / $l`
- if [ $c -eq 0 ]; then c=1; fi
- echo "$CATEGORIES" | \
- awk 'BEGIN {printf "SEND-PR: "; i = 0 }
- { printf ("%-'$l'.'$l's", $0);
- if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
- END { printf "\nSEND-PR:\n"; }' >> $file
-
-
-
- cat >> $file << __EOF__
-To: $GNATS_ADDR
-Subject:
-From: $FROM
-Reply-To: $REPLY_TO
-X-send-pr-version: $VERSION
-
-
->Submitter-Id: $SUBMITTER
->Originator: $ORIGINATOR
->Organization: ${ORGANIZATION-$ORGANIZATION_C}
->Confidential: $CONFIDENTIAL_C
->Synopsis: $SYNOPSIS_C
->Severity: $SEVERITY_C
->Priority: $PRIORITY_C
->Category: $CATEGORY_C
->Release: ${DEFAULT_RELEASE-$RELEASE_C}
->Class: $CLASS_C
->Environment:
-
- $ENVIRONMENT_C
-
->Description:
-
- $DESCRIPTION_C
-
->How-To-Repeat:
-
- $HOW_TO_REPEAT_C
-
->Fix:
-
- $FIX_C
-
-__EOF__
-
- done
- fi
-
- if [ "$PRINT" = true -o "$PRINT_INTERN" = true ]; then
- cat $TEMP
- xs=0; exit
- fi
-
- chmod u+w $TEMP
- if [ -z "$REQUEST_ID" ]; then
- eval $EDIT $TEMP
- else
- ed -s $TEMP << '__EOF__'
-/^Subject/s/^Subject:.*/Subject: request for a customer id/
-/^>Category/s/^>Category:.*/>Category: send-pr/
-w
-q
-__EOF__
- fi
-
- if cmp -s $REF $TEMP ; then
- echo "$COMMAND: problem report not filled out, therefore not sent"
- xs=1; exit
- fi
-fi
-
-#
-# Check the enumeration fields
-
-# This is a "sed-subroutine" with one keyword parameter
-# (with workaround for Sun sed bug)
-#
-SED_CMD='
-/$PATTERN/{
-s|||
-s|<.*>||
-s|^[ ]*||
-s|[ ]*$||
-p
-q
-}'
-
-
-while [ -z "$REQUEST_ID" ]; do
- CNT=0
-
- # 1) Confidential
- #
- PATTERN=">Confidential:"
- CONFIDENTIAL=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
- case "$CONFIDENTIAL" in
- ""|yes|no) CNT=`expr $CNT + 1` ;;
- *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
- esac
- #
- # 2) Severity
- #
- PATTERN=">Severity:"
- SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
- case "$SEVERITY" in
- ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
- *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
- esac
- #
- # 3) Priority
- #
- PATTERN=">Priority:"
- PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
- case "$PRIORITY" in
- ""|low|medium|high) CNT=`expr $CNT + 1` ;;
- *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
- esac
- #
- # 4) Category
- #
- PATTERN=">Category:"
- CATEGORY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
- FOUND=
- for C in $CATEGORIES
- do
- if [ "$C" = "$CATEGORY" ]; then FOUND=true ; break ; fi
- done
- if [ -n "$FOUND" ]; then
- CNT=`expr $CNT + 1`
- else
- if [ -z "$CATEGORY" ]; then
- echo "$COMMAND: you must include a Category: field in your report."
- else
- echo "$COMMAND: \`$CATEGORY' is not a known category."
- fi
- fi
- #
- # 5) Class
- #
- PATTERN=">Class:"
- CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
- case "$CLASS" in
- ""|sw-bug|doc-bug|change-request) CNT=`expr $CNT + 1` ;;
- *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
- esac
-
- #
- # 6) Check that Synopsis is not empty
- #
- if grep "^>Synopsis:[ ]*${SYNOPSIS_C}\$" $TEMP > /dev/null
- then
- echo "$COMMAND: Synopsis must not be empty."
- else
- CNT=`expr $CNT + 1`
- fi
-
- [ $CNT -lt 6 -a -z "$BATCH" ] &&
- echo "Errors were found with the problem report."
-
- while true; do
- if [ -z "$BATCH" ]; then
- $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
- read input
- else
- if [ $CNT -eq 6 ]; then
- input=s
- else
- input=a
- fi
- fi
- case "$input" in
- a*)
- if [ -z "$BATCH" ]; then
- echo "$COMMAND: the problem report remains in $BAD and is not sent."
- mv $TEMP $BAD
- else
- echo "$COMMAND: the problem report is not sent."
- fi
- xs=1; exit
- ;;
- e*)
- eval $EDIT $TEMP
- continue 2
- ;;
- s*)
- break 2
- ;;
- esac
- done
-done
-
-#
-# Make sure the mail has got a Subject. If not, use the same as
-# in Synopsis.
-#
-
-if grep '^Subject:[ ]*$' $TEMP > /dev/null
-then
- SYNOPSIS=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ ]*//'`
- ed -s $TEMP << __EOF__
-/^Subject:/s/:.*\$/: $SYNOPSIS/
-w
-q
-__EOF__
-fi
-
-#
-# Remove comments and send the problem report
-# (we have to use patterns, where the comment contains regex chars)
-#
-# /^>Originator:/s;$ORIGINATOR;;
-sed -e "
-/^SEND-PR:/d
-/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
-/^>Confidential:/s;<.*>;;
-/^>Synopsis:/s;$SYNOPSIS_C;;
-/^>Severity:/s;<.*>;;
-/^>Priority:/s;<.*>;;
-/^>Category:/s;$CATEGORY_C;;
-/^>Class:/s;<.*>;;
-/^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
-/^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
-/^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
-/^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
-/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
-" $TEMP > $REF
-
-if $MAIL_AGENT < $REF; then
- echo "$COMMAND: problem report sent"
- xs=0; exit
-else
- echo "$COMMAND: mysterious mail failure."
- if [ -z "$BATCH" ]; then
- echo "$COMMAND: the problem report remains in $BAD and is not sent."
- mv $REF $BAD
- else
- echo "$COMMAND: the problem report is not sent."
- fi
- xs=1; exit
-fi
diff --git a/gnu/usr.bin/sort/COPYING b/gnu/usr.bin/sort/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/sort/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/sort/Makefile b/gnu/usr.bin/sort/Makefile
deleted file mode 100644
index 73d919c..0000000
--- a/gnu/usr.bin/sort/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-PROG= sort
-SRCS= sort.c error.c version.c long-options.c getopt.c getopt1.c xstrtod.c
-
-CFLAGS+=-I${.CURDIR} -DHAVE_CONFIG_H
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/sort/config.h b/gnu/usr.bin/sort/config.h
deleted file mode 100644
index 27f201bb..0000000
--- a/gnu/usr.bin/sort/config.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if on AIX 3.
- System headers sometimes define this.
- We just want to avoid a redefinition error message. */
-#ifndef _ALL_SOURCE
-/* #undef _ALL_SOURCE */
-#endif
-
-/* Define if using alloca.c. */
-/* #undef C_ALLOCA */
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
- This function is required for alloca.c support on those systems. */
-/* #undef CRAY_STACKSEG_END */
-
-/* Define if you have alloca, as a function or macro. */
-#define HAVE_ALLOCA 1
-
-/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
-/* #undef HAVE_ALLOCA_H */
-
-/* Define if you don't have vprintf but do have _doprnt. */
-/* #undef HAVE_DOPRNT */
-
-/* Define if the `long double' type works. */
-#define HAVE_LONG_DOUBLE 1
-
-/* Define if your struct stat has st_blksize. */
-#define HAVE_ST_BLKSIZE 1
-
-/* Define if you have the vprintf function. */
-#define HAVE_VPRINTF 1
-
-/* Define as __inline if that's what the C compiler calls it. */
-/* #undef inline */
-
-/* Define if on MINIX. */
-/* #undef _MINIX */
-
-/* Define to `long' if <sys/types.h> doesn't define. */
-/* #undef off_t */
-
-/* Define if the system does not provide POSIX.1 features except
- with this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define if you need to in order for stat and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define as the return type of signal handlers (int or void). */
-#define RETSIGTYPE void
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-/* #undef size_t */
-
-/* If using the C implementation of alloca, define 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
- */
-/* #undef STACK_DIRECTION */
-
-/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if your processor stores words with the most significant
- byte first (like Motorola and SPARC, unlike Intel and VAX). */
-/* #undef WORDS_BIGENDIAN */
-
-/* Define to 1 if ANSI function prototypes are usable. */
-#define PROTOTYPES 1
-
-/* Define to 1 if GNU regex should be used instead of GNU rx. */
-/* #undef WITH_REGEX */
-
-/* Define if you have the isascii function. */
-#define HAVE_ISASCII 1
-
-/* Define if you have the strchr function. */
-#define HAVE_STRCHR 1
-
-/* Define if you have the strerror function. */
-#define HAVE_STRERROR 1
-
-/* Define if you have the strrchr function. */
-#define HAVE_STRRCHR 1
-
-/* Define if you have the <dirent.h> header file. */
-#define HAVE_DIRENT_H 1
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define if you have the <ndir.h> header file. */
-/* #undef HAVE_NDIR_H */
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <sys/dir.h> header file. */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define if you have the <sys/ndir.h> header file. */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
diff --git a/gnu/usr.bin/sort/error.c b/gnu/usr.bin/sort/error.c
deleted file mode 100644
index 21a9ca4..0000000
--- a/gnu/usr.bin/sort/error.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* error.c -- error handler for noninteractive utilities
- Copyright (C) 1990, 91, 92, 93, 94, 95 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. */
-
-/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-
-#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
-# if __STDC__
-# include <stdarg.h>
-# define VA_START(args, lastarg) va_start(args, lastarg)
-# else
-# include <varargs.h>
-# define VA_START(args, lastarg) va_start(args)
-# endif
-#else
-# define va_alist a1, a2, a3, a4, a5, a6, a7, a8
-# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
-#endif
-
-#if STDC_HEADERS || _LIBC
-# include <stdlib.h>
-# include <string.h>
-#else
-void exit ();
-#endif
-
-/* This variable is incremented each time `error' is called. */
-unsigned int error_message_count;
-
-/* If NULL, error will flush stdout, then print on stderr the program
- name, a colon and a space. Otherwise, error will call this
- function without parameters instead. */
-void (*error_print_progname) () = NULL;
-
-#ifdef _LIBC
-#define program_name program_invocation_name
-#endif
-
-/* The calling program should define program_name and set it to the
- name of the executing program. */
-extern char *program_name;
-
-#if HAVE_STRERROR || _LIBC
-# ifndef strerror /* On some systems, strerror is a macro */
-char *strerror ();
-# endif
-#else
-static char *
-private_strerror (errnum)
- int errnum;
-{
- extern int sys_nerr;
-
- if (errnum > 0 && errnum <= sys_nerr)
- return sys_errlist[errnum];
- return "Unknown system error";
-}
-#define strerror private_strerror
-#endif
-
-/* Print the program name and error message MESSAGE, which is a printf-style
- format string with optional args.
- If ERRNUM is nonzero, print its corresponding system error message.
- Exit with status STATUS if it is nonzero. */
-/* VARARGS */
-
-void
-#if defined(VA_START) && __STDC__
-error (int status, int errnum, const char *message, ...)
-#else
-error (status, errnum, message, va_alist)
- int status;
- int errnum;
- char *message;
- va_dcl
-#endif
-{
-#ifdef VA_START
- va_list args;
-#endif
-
- if (error_print_progname)
- (*error_print_progname) ();
- else
- {
- fflush (stdout);
- fprintf (stderr, "%s: ", program_name);
- }
-
-#ifdef VA_START
- VA_START (args, message);
-# if HAVE_VPRINTF || _LIBC
- vfprintf (stderr, message, args);
-# else
- _doprnt (message, args, stderr);
-# endif
- va_end (args);
-#else
- fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif
-
- ++error_message_count;
-
- if (errnum)
- fprintf (stderr, ": %s", strerror (errnum));
- putc ('\n', stderr);
- fflush (stderr);
- if (status)
- exit (status);
-}
diff --git a/gnu/usr.bin/sort/error.h b/gnu/usr.bin/sort/error.h
deleted file mode 100644
index 481c54d..0000000
--- a/gnu/usr.bin/sort/error.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* error.h -- declaration for error-reporting function
- Copyright (C) 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef _error_h_
-#define _error_h_
-
-#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
-# define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
- are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __format__ format
-# define __printf__ printf
-# endif
-#endif
-
-#if __STDC__
-void error (int, int, const char *, ...) \
- __attribute__ ((__format__ (__printf__, 3, 4)));
-#else
-void error ();
-#endif
-
-/* This variable is incremented each time `error' is called. */
-extern unsigned int error_message_count;
-
-#endif /* _error_h_ */
diff --git a/gnu/usr.bin/sort/getopt.c b/gnu/usr.bin/sort/getopt.c
deleted file mode 100644
index 8bcf559..0000000
--- a/gnu/usr.bin/sort/getopt.c
+++ /dev/null
@@ -1,770 +0,0 @@
-/* Getopt for GNU.
- NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
- before changing it!
-
- Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95
- 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
- Ditto for AIX 3.2 and <stdlib.h>. */
-#ifndef _NO_PROTO
-#define _NO_PROTO
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#if !defined (__STDC__) || !__STDC__
-/* This is a separate conditional since some stdc systems
- reject `defined (const)'. */
-#ifndef const
-#define const
-#endif
-#endif
-
-#include <stdio.h>
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-/* Don't include stdlib.h for non-GNU C libraries because some of them
- contain conflicting prototypes for getopt. */
-#include <stdlib.h>
-#endif /* GNU C library. */
-
-#ifndef _
-/* This is for other GNU distributions with internationalized messages.
- When compiling libc, the _ macro is predefined. */
-#ifdef HAVE_LIBINTL_H
-# include <libintl.h>
-# define _(msgid) gettext (msgid)
-#else
-# define _(msgid) (msgid)
-#endif
-#endif
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- to intersperse the options with the other arguments.
-
- As `getopt' works, it permutes the elements of ARGV so that,
- when it is done, all the options precede everything else. Thus
- all application programs are extended to handle flexible argument order.
-
- Setting the environment variable POSIXLY_CORRECT disables permutation.
- Then the behavior is completely standard.
-
- GNU application programs can use a third alternative mode in which
- they can distinguish the relative order of options and other arguments. */
-
-#include "getopt.h"
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-char *optarg = NULL;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-/* XXX 1003.2 says this must be 1 before any call. */
-int optind = 0;
-
-/* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
-static char *nextchar;
-
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-int optopt = '?';
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
- If the caller did not specify anything,
- the default is REQUIRE_ORDER if the environment variable
- POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
- REQUIRE_ORDER means don't recognize them as options;
- stop option processing when the first non-option is seen.
- This is what Unix does.
- This mode of operation is selected by either setting the environment
- variable POSIXLY_CORRECT, or using `+' as the first character
- of the list of option characters.
-
- PERMUTE is the default. We permute the contents of ARGV as we scan,
- so that eventually all the non-options are at the end. This allows options
- to be given in any order, even with programs that were not written to
- expect this.
-
- RETURN_IN_ORDER is an option available to programs that were written
- to expect options and other ARGV-elements in any order and that care about
- the ordering of the two. We describe each non-option ARGV-element
- as if it were the argument of an option with character code 1.
- Using `-' as the first character of the list of option characters
- selects this mode of operation.
-
- The special argument `--' forces an end of option-scanning regardless
- of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return EOF with `optind' != ARGC. */
-
-static enum
-{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-/* Value of POSIXLY_CORRECT environment variable. */
-static char *posixly_correct;
-
-#ifdef __GNU_LIBRARY__
-/* We want to avoid inclusion of string.h with non-GNU libraries
- because there are many ways it can cause trouble.
- On some systems, it contains special magic macros that don't work
- in GCC. */
-#include <string.h>
-#define my_index strchr
-#else
-
-/* Avoid depending on library functions or files
- whose names are inconsistent. */
-
-char *getenv ();
-
-static char *
-my_index (str, chr)
- const char *str;
- int chr;
-{
- while (*str)
- {
- if (*str == chr)
- return (char *) str;
- str++;
- }
- return 0;
-}
-
-/* If using GCC, we can safely declare strlen this way.
- If not using GCC, it is ok not to declare it. */
-#ifdef __GNUC__
-/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
- That was relevant to code that was here before. */
-#if !defined (__STDC__) || !__STDC__
-/* gcc with -traditional declares the built-in strlen to return int,
- and has done so at least since version 2.4.5. -- rms. */
-extern int strlen (const char *);
-#endif /* not __STDC__ */
-#endif /* __GNUC__ */
-
-#endif /* not __GNU_LIBRARY__ */
-
-/* Handle permutation of arguments. */
-
-/* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
-static int first_nonopt;
-static int last_nonopt;
-
-/* Exchange two adjacent subsequences of ARGV.
- One subsequence is elements [first_nonopt,last_nonopt)
- which contains all the non-options that have been skipped so far.
- The other is elements [last_nonopt,optind), which contains all
- the options processed since those non-options were skipped.
-
- `first_nonopt' and `last_nonopt' are relocated so that they describe
- the new indices of the non-options in ARGV after they are moved. */
-
-static void
-exchange (argv)
- char **argv;
-{
- int bottom = first_nonopt;
- int middle = last_nonopt;
- int top = optind;
- char *tem;
-
- /* Exchange the shorter segment with the far end of the longer segment.
- That puts the shorter segment into the right place.
- It leaves the longer segment in the right place overall,
- but it consists of two parts that need to be swapped next. */
-
- while (top > middle && middle > bottom)
- {
- if (top - middle > middle - bottom)
- {
- /* Bottom segment is the short one. */
- int len = middle - bottom;
- register int i;
-
- /* Swap it with the top part of the top segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[top - (middle - bottom) + i];
- argv[top - (middle - bottom) + i] = tem;
- }
- /* Exclude the moved bottom segment from further swapping. */
- top -= len;
- }
- else
- {
- /* Top segment is the short one. */
- int len = top - middle;
- register int i;
-
- /* Swap it with the bottom part of the bottom segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[middle + i];
- argv[middle + i] = tem;
- }
- /* Exclude the moved top segment from further swapping. */
- bottom += len;
- }
- }
-
- /* Update records for the slots the non-options now occupy. */
-
- first_nonopt += (optind - last_nonopt);
- last_nonopt = optind;
-}
-
-/* Initialize the internal data when the first call is made. */
-
-static const char *
-_getopt_initialize (optstring)
- const char *optstring;
-{
- /* Start processing options with ARGV-element 1 (since ARGV-element 0
- is the program name); the sequence of previously skipped
- non-option ARGV-elements is empty. */
-
- first_nonopt = last_nonopt = optind = 1;
-
- nextchar = NULL;
-
- posixly_correct = getenv ("POSIXLY_CORRECT");
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-')
- {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- }
- else if (optstring[0] == '+')
- {
- ordering = REQUIRE_ORDER;
- ++optstring;
- }
- else if (posixly_correct != NULL)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
-
- return optstring;
-}
-
-/* Scan elements of ARGV (whose length is ARGC) for option characters
- given in OPTSTRING.
-
- If an element of ARGV starts with '-', and is not exactly "-" or "--",
- then it is an option element. The characters of this element
- (aside from the initial '-') are option characters. If `getopt'
- is called repeatedly, it returns successively each of the option characters
- from each of the option elements.
-
- If `getopt' finds another option character, it returns that character,
- updating `optind' and `nextchar' so that the next call to `getopt' can
- resume the scan with the following option character or ARGV-element.
-
- If there are no more option characters, `getopt' returns `EOF'.
- Then `optind' is the index in ARGV of the first ARGV-element
- that is not an option. (The ARGV-elements have been permuted
- so that those that are not options now come last.)
-
- OPTSTRING is a string containing the legitimate option characters.
- If an option character is seen that is not listed in OPTSTRING,
- return '?' after printing an error message. If you set `opterr' to
- zero, the error message is suppressed but we still return '?'.
-
- If a char in OPTSTRING is followed by a colon, that means it wants an arg,
- so the following text in the same ARGV-element, or the text of the following
- ARGV-element, is returned in `optarg'. Two colons mean an option that
- wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `optarg', otherwise `optarg' is set to zero.
-
- If OPTSTRING starts with `-' or `+', it requests different methods of
- handling the non-option ARGV-elements.
- See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
-
- Long-named options begin with `--' instead of `-'.
- Their names may be abbreviated as long as the abbreviation is unique
- or is an exact match for some defined option. If they have an
- argument, it follows the option name in the same ARGV-element, separated
- from the option name by a `=', or else the in next ARGV-element.
- When `getopt' finds a long-named option, it returns 0 if that option's
- `flag' field is nonzero, the value of the option's `val' field
- if the `flag' field is zero.
-
- The elements of ARGV aren't really const, because we permute them.
- But we pretend they're const in the prototype to be compatible
- with other systems.
-
- LONGOPTS is a vector of `struct option' terminated by an
- element containing a name which is zero.
-
- LONGIND returns the index in LONGOPT of the long-named option found.
- It is only valid when a long-named option has been found by the most
- recent call.
-
- If LONG_ONLY is nonzero, '-' as well as '--' can introduce
- long-named options. */
-
-int
-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
- int argc;
- char *const *argv;
- const char *optstring;
- const struct option *longopts;
- int *longind;
- int long_only;
-{
- optarg = NULL;
-
- if (optind == 0)
- {
- optstring = _getopt_initialize (optstring);
- optind = 1; /* Don't scan ARGV[0], the program name. */
- }
-
- if (nextchar == NULL || *nextchar == '\0')
- {
- /* Advance to the next ARGV-element. */
-
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < argc
- && (argv[optind][0] != '-' || argv[optind][1] == '\0'))
- optind++;
- last_nonopt = optind;
- }
-
- /* The special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp (argv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return EOF;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
- {
- if (ordering == REQUIRE_ORDER)
- return EOF;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- Skip the initial punctuation. */
-
- nextchar = (argv[optind] + 1
- + (longopts != NULL && argv[optind][1] == '-'));
- }
-
- /* Decode the current option-ARGV-element. */
-
- /* Check whether the ARGV-element is a long option.
-
- If long_only and the ARGV-element has the form "-f", where f is
- a valid short option, don't consider it an abbreviated form of
- a long option that starts with f. Otherwise there would be no
- way to give the -f short option.
-
- On the other hand, if there's a long option "fubar" and
- the ARGV-element is "-fu", do consider that an abbreviation of
- the long option, just like "--fu", and not "-f" with arg "u".
-
- This distinction seems to be the most useful approach. */
-
- if (longopts != NULL
- && (argv[optind][1] == '-'
- || (long_only && (argv[optind][2]
- || !my_index (optstring, argv[optind][1])))))
- {
- char *nameend;
- const struct option *p;
- const struct option *pfound = NULL;
- int exact = 0;
- int ambig = 0;
- int indfound;
- int option_index;
-
- for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
- /* Do nothing. */ ;
-
-#ifdef lint
- indfound = 0; /* Avoid spurious compiler warning. */
-#endif
-
- /* Test all long options for either exact match
- or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp (p->name, nextchar, nameend - nextchar))
- {
- if (nameend - nextchar == strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second or later nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- return '?';
- }
-
- if (pfound != NULL)
- {
- option_index = indfound;
- optind++;
- if (*nameend)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = nameend + 1;
- else
- {
- if (opterr)
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- _("%s: option `--%s' doesn't allow an argument\n"),
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- _("%s: option `%c%s' doesn't allow an argument\n"),
- argv[0], argv[optind - 1][0], pfound->name);
-
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr,
- _("%s: option `%s' requires an argument\n"),
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
-
- /* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
- || my_index (optstring, *nextchar) == NULL)
- {
- if (opterr)
- {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
- argv[0], argv[optind][0], nextchar);
- }
- nextchar = (char *) "";
- optind++;
- return '?';
- }
- }
-
- /* Look at and handle the next short option-character. */
-
- {
- char c = *nextchar++;
- char *temp = my_index (optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == '\0')
- ++optind;
-
- if (temp == NULL || c == ':')
- {
- if (opterr)
- {
- if (posixly_correct)
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, _("%s: illegal option -- %c\n"),
- argv[0], c);
- else
- fprintf (stderr, _("%s: invalid option -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- return '?';
- }
- if (temp[1] == ':')
- {
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = NULL;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr,
- _("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
- }
- return c;
- }
-}
-
-int
-getopt (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
-{
- return _getopt_internal (argc, argv, optstring,
- (const struct option *) 0,
- (int *) 0,
- 0);
-}
-
-#endif /* _LIBC or not __GNU_LIBRARY__. */
-
-#ifdef TEST
-
-/* Compile with -DTEST to make an executable for use in testing
- the above definition of `getopt'. */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
-
- c = getopt (argc, argv, "abc:d:0123456789");
- if (c == EOF)
- break;
-
- switch (c)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/usr.bin/sort/getopt.h b/gnu/usr.bin/sort/getopt.h
deleted file mode 100644
index 4ac33b7..0000000
--- a/gnu/usr.bin/sort/getopt.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Declarations for getopt.
- Copyright (C) 1989, 90, 91, 92, 93, 94 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef _GETOPT_H
-#define _GETOPT_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
-extern int opterr;
-
-/* Set to an option character which was unrecognized. */
-
-extern int optopt;
-
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
-struct option
-{
-#if defined (__STDC__) && __STDC__
- const char *name;
-#else
- char *name;
-#endif
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'. */
-
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
-
-#if defined (__STDC__) && __STDC__
-#ifdef __GNU_LIBRARY__
-/* Many other libraries have conflicting prototypes for getopt, with
- differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
-extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* __GNU_LIBRARY__ */
-extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-extern int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
-
-/* Internal only. Users should not call this directly. */
-extern int _getopt_internal (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
-#else /* not __STDC__ */
-extern int getopt ();
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-#endif /* __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GETOPT_H */
diff --git a/gnu/usr.bin/sort/getopt1.c b/gnu/usr.bin/sort/getopt1.c
deleted file mode 100644
index 4580211..0000000
--- a/gnu/usr.bin/sort/getopt1.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/* getopt_long and getopt_long_only entry points for GNU getopt.
- Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994
- 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "getopt.h"
-
-#if !defined (__STDC__) || !__STDC__
-/* This is a separate conditional since some stdc systems
- reject `defined (const)'. */
-#ifndef const
-#define const
-#endif
-#endif
-
-#include <stdio.h>
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-#include <stdlib.h>
-#else
-char *getenv ();
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-int
-getopt_long (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
-}
-
-/* Like getopt_long, but '-' as well as '--' can indicate a long option.
- If an option that starts with '-' (not '--') doesn't match a long option,
- but does match a short option, it is parsed as a short option
- instead. */
-
-int
-getopt_long_only (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
-}
-
-
-#endif /* _LIBC or not __GNU_LIBRARY__. */
-
-#ifdef TEST
-
-#include <stdio.h>
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
- int option_index = 0;
- static struct option long_options[] =
- {
- {"add", 1, 0, 0},
- {"append", 0, 0, 0},
- {"delete", 1, 0, 0},
- {"verbose", 0, 0, 0},
- {"create", 0, 0, 0},
- {"file", 1, 0, 0},
- {0, 0, 0, 0}
- };
-
- c = getopt_long (argc, argv, "abc:d:0123456789",
- long_options, &option_index);
- if (c == EOF)
- break;
-
- switch (c)
- {
- case 0:
- printf ("option %s", long_options[option_index].name);
- if (optarg)
- printf (" with arg %s", optarg);
- printf ("\n");
- break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case 'd':
- printf ("option d with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/usr.bin/sort/long-options.c b/gnu/usr.bin/sort/long-options.c
deleted file mode 100644
index dd7a8ca..0000000
--- a/gnu/usr.bin/sort/long-options.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Utility to accept --help and --version options as unobtrusively as possible.
- Copyright (C) 1993, 1994 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. */
-
-/* Jim Meyering (meyering@comco.com) */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <getopt.h>
-#include "long-options.h"
-
-static struct option const long_options[] =
-{
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {0, 0, 0, 0}
-};
-
-/* Process long options --help and --version, but only if argc == 2.
- Be careful not to gobble up `--'. */
-
-void
-parse_long_options (argc, argv, command_name, version_string, usage)
- int argc;
- char **argv;
- const char *command_name;
- const char *version_string;
- void (*usage)();
-{
- int c;
- int saved_opterr;
- int saved_optind;
-
- saved_opterr = opterr;
- saved_optind = optind;
-
- /* Don't print an error message for unrecognized options. */
- opterr = 0;
-
- if (argc == 2
- && (c = getopt_long (argc, argv, "+", long_options, (int *) 0)) != EOF)
- {
- switch (c)
- {
- case 'h':
- (*usage) (0);
-
- case 'v':
- printf ("%s - %s\n", command_name, version_string);
- exit (0);
-
- default:
- /* Don't process any other long-named options. */
- break;
- }
- }
-
- /* Restore previous value. */
- opterr = saved_opterr;
-
- /* Restore optind in case it has advanced past a leading `--'. */
- optind = saved_optind;
-}
diff --git a/gnu/usr.bin/sort/long-options.h b/gnu/usr.bin/sort/long-options.h
deleted file mode 100644
index 986a52d..0000000
--- a/gnu/usr.bin/sort/long-options.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#undef __P
-#if defined (__STDC__) && __STDC__
-#define __P(args) args
-#else
-#define __P(args) ()
-#endif
-
-void
- parse_long_options __P ((int _argc, char **_argv, const char *_command_name,
- const char *_version_string, void (*_usage) (int)));
diff --git a/gnu/usr.bin/sort/sort.1 b/gnu/usr.bin/sort/sort.1
deleted file mode 100644
index e9f4b1e..0000000
--- a/gnu/usr.bin/sort/sort.1
+++ /dev/null
@@ -1,231 +0,0 @@
-.TH SORT 1 "GNU Text Utilities" "FSF" \" -*- nroff -*-
-.SH NAME
-sort \- sort lines of text files
-.SH SYNOPSIS
-.B sort
-[\-cmus] [\-t separator] [\-o output-file] [\-T tempdir] [\-bdfiMnr]
-[+POS1 [\-POS2]] [\-k POS1[,POS2]] [file...]
-.br
-.B sort
-{\-\-help,\-\-version}
-.SH DESCRIPTION
-This manual page
-documents the GNU version of
-.BR sort .
-.B sort
-sorts, merges, or compares all the lines from the given files, or the standard
-input if no files are given. A file name of `-' means standard input.
-By default,
-.B sort
-writes the results to the standard output.
-.PP
-.B sort
-has three modes of operation: sort (the default), merge, and check for
-sortedness. The following options change the operation mode:
-.TP
-.I \-c
-Check whether the given files are already sorted: if they are not all
-sorted, print an error message and exit with a status of 1.
-.TP
-.I \-m
-Merge the given files by sorting them as a group. Each input file
-should already be individually sorted. It always works to sort
-instead of merge; merging is provided because it is faster, in the
-case where it works.
-.PP
-A pair of lines is compared as follows:
-if any key fields have been specified,
-.B sort
-compares each pair of fields, in the order specified on the command
-line, according to the associated ordering options, until a difference
-is found or no fields are left.
-.PP
-If any of the global options
-.I Mbdfinr
-are given but no key fields are
-specified,
-.B sort
-compares the entire lines according to the global options.
-.PP
-Finally, as a last resort when all keys compare equal
-(or if no ordering options were specified at all),
-.B sort
-compares the lines byte by byte in machine collating sequence.
-The last resort comparison honors the
-.I -r
-global option.
-The
-.I \-s
-(stable) option disables this last-resort comparison so that
-lines in which all fields compare equal are left in their original
-relative order. If no fields or global options are specified,
-.I \-s
-has no effect.
-.PP
-GNU
-.B sort
-has no limits on input line length or restrictions on bytes allowed
-within lines. In addition, if the final byte of an input file is not
-a newline, GNU
-.B sort
-silently supplies one.
-.PP
-If the environment variable
-.B TMPDIR
-is set,
-.B sort
-uses it as the directory in which to put temporary files instead of
-the default, /tmp. The
-.I "\-T tempdir"
-option is another way to select the directory for temporary files; it
-overrides the environment variable.
-.PP
-The following options affect the ordering of output lines. They may
-be specified globally or as part of a specific key field. If no key
-fields are specified, global options apply to comparison of entire
-lines; otherwise the global options are inherited by key fields that
-do not specify any special options of their own.
-.TP
-.I \-b
-Ignore leading blanks when finding sort keys in each line.
-.TP
-.I \-d
-Sort in `phone directory' order: ignore all characters except letters,
-digits and blanks when sorting.
-.TP
-.I \-f
-Fold lower case characters into the equivalent upper case characters
-when sorting so that, for example, `b' is sorted the same way `B' is.
-.TP
-.I \-i
-Ignore characters outside the ASCII range 040-0176 octal (inclusive)
-when sorting.
-.TP
-.I \-M
-An initial string, consisting of any amount of white space, followed
-by three letters abbreviating a month name, is folded to UPPER case
-and compared in the order `JAN' < `FEB' < ... < `DEC.' Invalid names
-compare low to valid names.
-.TP
-.I \-n
-Compare according to arithmetic value an initial numeric string
-consisting of optional white space, an optional \- sign, and zero or
-more digits, optionally followed by a decimal point and zero or more
-digits.
-.TP
-.I \-r
-Reverse the result of comparison, so that lines with greater key
-values appear earlier in the output instead of later.
-.PP
-Other options are:
-.TP
-.I "\-o output-file"
-Write output to
-.I output-file
-instead of to the standard output. If
-.I output-file
-is one of the input files,
-.B sort
-copies it to a temporary file before sorting and writing the output to
-.IR output-file .
-.TP
-.I "\-t separator"
-Use character
-.I separator
-as the field separator when finding the sort keys in each line. By
-default, fields are separated by the empty string between a
-non-whitespace character and a whitespace character. That is to say,
-given the input line ` foo bar',
-.B sort
-breaks it into fields ` foo' and ` bar'. The field separator is not
-considered to be part of either the field preceding or the field
-following it.
-.TP
-.I \-u
-For the default case or the
-.I \-m
-option, only output the first of a sequence of lines that compare
-equal. For the
-.I \-c
-option, check that no pair of consecutive lines compares equal.
-.TP
-.I "+POS1 [\-POS2]"
-Specify a field within each line to use as a sorting key. The field
-consists of the portion of the line starting at POS1 and up to (but
-not including) POS2 (or to the end of the line if POS2 is not given).
-The fields and character positions are numbered starting with 0.
-.TP
-.I "\-k POS1[,POS2]"
-An alternate syntax for specifying sorting keys.
-The fields and character positions are numbered starting with 1.
-.PP
-A position has the form \fIf\fP.\fIc\fP, where \fIf\fP is the number
-of the field to use and \fIc\fP is the number of the first character
-from the beginning of the field (for \fI+pos\fP) or from the end of
-the previous field (for \fI\-pos\fP). The .\fIc\fP part of a position
-may be omitted in which case it is taken to be the first character in
-the field. If the
-.I \-b
-option has been given, the .\fIc\fP part of a field specification is
-counted from the first nonblank character of the field (for
-\fI+pos\fP) or from the first nonblank character following the
-previous field (for \fI\-pos\fP).
-.PP
-A \fI+pos\fP or \fI-pos\fP argument may also have any of the option
-letters
-.I Mbdfinr
-appended to it, in which case the global ordering options are not used
-for that particular field. The
-.I \-b
-option may be independently attached to either or both of the
-\fI+pos\fP and \fI\-pos\fP parts of a field specification, and if it
-is inherited from the global options it will be attached to both.
-If a
-.I \-n
-or
-.I \-M
-option is used, thus implying a
-.I \-b
-option, the
-.I \-b
-option is taken to apply to both the \fI+pos\fP and the \fI\-pos\fP
-parts of a key specification. Keys may span multiple fields.
-.PP
-In addition, when GNU
-.B sort
-is invoked with exactly one argument, the following options are recognized:
-.TP
-.I "\-\-help"
-Print a usage message on standard output and exit successfully.
-.TP
-.I "\-\-version"
-Print version information on standard output then exit successfully.
-.SH COMPATIBILITY
-.PP
-Historical (BSD and System V) implementations of
-.B sort
-have differed in their interpretation of some options,
-particularly
-.IR \-b ,
-.IR \-f ,
-and
-.IR \-n .
-GNU sort follows the POSIX behavior, which is
-usually (but not always!) like the System V behavior.
-According to POSIX
-.I \-n
-no longer implies
-.IR \-b .
-For consistency,
-.I \-M
-has been changed in the same way.
-This may affect the meaning of character positions in field
-specifications in obscure cases.
-If this bites you the fix is to add an explicit
-.IR \-b .
-.SH BUGS
-The different meaning of field numbers depending
-on whether
-.I -k
-is used is confusing.
-It's all POSIX's fault!
diff --git a/gnu/usr.bin/sort/sort.c b/gnu/usr.bin/sort/sort.c
deleted file mode 100644
index 9457e94..0000000
--- a/gnu/usr.bin/sort/sort.c
+++ /dev/null
@@ -1,2178 +0,0 @@
-/* sort - sort lines of text (with all kinds of options).
- Copyright (C) 1988, 1991, 1992, 1993, 1994, 1995 Free Software Foundation
-
- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Written December 1988 by Mike Haertel.
- The author may be reached (Email) at the address mike@gnu.ai.mit.edu,
- or (US mail) as Mike Haertel c/o Free Software Foundation. */
-
-#include <config.h>
-
-/* Get isblank from GNU libc. */
-#define _GNU_SOURCE
-
-#include <sys/types.h>
-#include <signal.h>
-#include <stdio.h>
-#ifdef __FreeBSD__
-#include <locale.h>
-#endif
-#include "system.h"
-#include "version.h"
-#include "long-options.h"
-#include "error.h"
-#include "xstrtod.h"
-
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#else
-#ifndef UCHAR_MAX
-#define UCHAR_MAX 255
-#endif
-#endif
-#ifndef STDC_HEADERS
-char *malloc ();
-char *realloc ();
-void free ();
-#endif
-
-/* Undefine, to avoid warning about redefinition on some systems. */
-#undef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
-#define UCHAR_LIM (UCHAR_MAX + 1)
-#define UCHAR(c) ((unsigned char) (c))
-
-#ifndef DEFAULT_TMPDIR
-#define DEFAULT_TMPDIR "/tmp"
-#endif
-
-/* The kind of blanks for '-b' to skip in various options. */
-enum blanktype { bl_start, bl_end, bl_both };
-
-/* Lines are held in core as counted strings. */
-struct line
-{
- char *text; /* Text of the line. */
- int length; /* Length not including final newline. */
- char *keybeg; /* Start of first key. */
- char *keylim; /* Limit of first key. */
-};
-
-/* Arrays of lines. */
-struct lines
-{
- struct line *lines; /* Dynamically allocated array of lines. */
- int used; /* Number of slots used. */
- int alloc; /* Number of slots allocated. */
- int limit; /* Max number of slots to allocate. */
-};
-
-/* Input buffers. */
-struct buffer
-{
- char *buf; /* Dynamically allocated buffer. */
- int used; /* Number of bytes used. */
- int alloc; /* Number of bytes allocated. */
- int left; /* Number of bytes left after line parsing. */
-};
-
-struct keyfield
-{
- int sword; /* Zero-origin 'word' to start at. */
- int schar; /* Additional characters to skip. */
- int skipsblanks; /* Skip leading white space at start. */
- int eword; /* Zero-origin first word after field. */
- int echar; /* Additional characters in field. */
- int skipeblanks; /* Skip trailing white space at finish. */
- int *ignore; /* Boolean array of characters to ignore. */
- char *translate; /* Translation applied to characters. */
- int numeric; /* Flag for numeric comparison. Handle
- strings of digits with optional decimal
- point, but no exponential notation. */
- int general_numeric; /* Flag for general, numeric comparison.
- Handle numbers in exponential notation. */
- int month; /* Flag for comparison by month name. */
- int reverse; /* Reverse the sense of comparison. */
- struct keyfield *next; /* Next keyfield to try. */
-};
-
-struct month
-{
- char *name;
- int val;
-};
-
-/* The name this program was run with. */
-char *program_name;
-
-/* Table of digits. */
-static int digits[UCHAR_LIM];
-
-/* Table of white space. */
-static int blanks[UCHAR_LIM];
-
-/* Table of non-printing characters. */
-static int nonprinting[UCHAR_LIM];
-
-/* Table of non-dictionary characters (not letters, digits, or blanks). */
-static int nondictionary[UCHAR_LIM];
-
-/* Translation table folding lower case to upper. */
-static char fold_toupper[UCHAR_LIM];
-
-/* Table mapping 3-letter month names to integers.
- Alphabetic order allows binary search. */
-static struct month const monthtab[] =
-{
- {"APR", 4},
- {"AUG", 8},
- {"DEC", 12},
- {"FEB", 2},
- {"JAN", 1},
- {"JUL", 7},
- {"JUN", 6},
- {"MAR", 3},
- {"MAY", 5},
- {"NOV", 11},
- {"OCT", 10},
- {"SEP", 9}
-};
-
-/* During the merge phase, the number of files to merge at once. */
-#define NMERGE 16
-
-/* Initial buffer size for in core sorting. Will not grow unless a
- line longer than this is seen. */
-static int sortalloc = 512 * 1024;
-
-/* Initial buffer size for in core merge buffers. Bear in mind that
- up to NMERGE * mergealloc bytes may be allocated for merge buffers. */
-static int mergealloc = 16 * 1024;
-
-/* Guess of average line length. */
-static int linelength = 30;
-
-/* Maximum number of elements for the array(s) of struct line's, in bytes. */
-#define LINEALLOC (256 * 1024)
-
-/* Prefix for temporary file names. */
-static char *temp_file_prefix;
-
-/* Flag to reverse the order of all comparisons. */
-static int reverse;
-
-/* Flag for stable sort. This turns off the last ditch bytewise
- comparison of lines, and instead leaves lines in the same order
- they were read if all keys compare equal. */
-static int stable;
-
-/* Tab character separating fields. If NUL, then fields are separated
- by the empty string between a non-whitespace character and a whitespace
- character. */
-static char tab;
-
-/* Flag to remove consecutive duplicate lines from the output.
- Only the last of a sequence of equal lines will be output. */
-static int unique;
-
-/* Nonzero if any of the input files are the standard input. */
-static int have_read_stdin;
-
-/* Lists of key field comparisons to be tried. */
-static struct keyfield keyhead;
-
-#ifdef __FreeBSD__
-static int collates[UCHAR_LIM];
-
-#define COLLDIFF(A, B) (collates[UCHAR (A)] - collates[UCHAR (B)])
-
-static int
-collate_range_cmp (a, b)
- int a, b;
-{
- int r;
- static char s[2][2];
-
- if ((unsigned char)a == (unsigned char)b)
- return 0;
- s[0][0] = a;
- s[1][0] = b;
- if ((r = strcoll(s[0], s[1])) == 0)
- r = (unsigned char)a - (unsigned char)b;
- return r;
-}
-
-static int
-collcompare (const void *sa, const void *sb)
-{
- return collate_range_cmp (*((int *)sa), *((int *)sb));
-}
-
-static void
-init_collates(void)
-{
- register int i, j;
- int reverse[UCHAR_LIM];
-
- for (i = 0; i < UCHAR_LIM; i++)
- reverse[i] = i;
- qsort(reverse, UCHAR_LIM, sizeof(reverse[0]), collcompare);
- for (i = 0; i < UCHAR_LIM; i++) {
- for (j = 0; j < UCHAR_LIM; j++) {
- if (reverse[j] == i) {
- collates[i] = j;
- break;
- }
- }
- }
-}
-
-static int
-collcmp (const unsigned char *p1, const unsigned char *p2, size_t n)
-{
- int r;
-
- if (n != 0) {
- do {
- if ((r = COLLDIFF (*p1++, *p2++)) != 0)
- return r;
- } while (--n != 0);
- }
- return (0);
-}
-#endif
-
-static void
-usage (int status)
-{
- if (status != 0)
- fprintf (stderr, _("Try `%s --help' for more information.\n"),
- program_name);
- else
- {
- printf (_("\
-Usage: %s [OPTION]... [FILE]...\n\
-"),
- program_name);
- printf (_("\
-Write sorted concatenation of all FILE(s) to standard output.\n\
-\n\
- +POS1 [-POS2] start a key at POS1, end it before POS2\n\
- -M compare (unknown) < `JAN' < ... < `DEC', imply -b\n\
- -T DIRECT use DIRECT for temporary files, not $TMPDIR or %s\n\
- -b ignore leading blanks in sort fields or keys\n\
- -c check if given files already sorted, do not sort\n\
- -d consider only [a-zA-Z0-9 ] characters in keys\n\
- -f fold lower case to upper case characters in keys\n\
- -g compare according to general numerical value, imply -b\n\
- -i consider only [\\040-\\0176] characters in keys\n\
- -k POS1[,POS2] same as +POS1 [-POS2], but all positions counted from 1\n\
- -m merge already sorted files, do not sort\n\
- -n compare according to string numerical value, imply -b\n\
- -o FILE write result on FILE instead of standard output\n\
- -r reverse the result of comparisons\n\
- -s stabilize sort by disabling last resort comparison\n\
- -t SEP use SEParator instead of non- to whitespace transition\n\
- -u with -c, check for strict ordering\n\
- -u with -m, only output the first of an equal sequence\n\
- --help display this help and exit\n\
- --version output version information and exit\n\
-\n\
-POS is F[.C][OPTS], where F is the field number and C the character\n\
-position in the field, both counted from zero. OPTS is made up of one\n\
-or more of Mbdfinr, this effectively disable global -Mbdfinr settings\n\
-for that key. If no key given, use the entire line as key. With no\n\
-FILE, or when FILE is -, read standard input.\n\
-")
- , DEFAULT_TMPDIR);
- }
- exit (status);
-}
-
-/* The list of temporary files. */
-static struct tempnode
-{
- char *name;
- struct tempnode *next;
-} temphead;
-
-/* Clean up any remaining temporary files. */
-
-static void
-cleanup (void)
-{
- struct tempnode *node;
-
- for (node = temphead.next; node; node = node->next)
- unlink (node->name);
-}
-
-/* Allocate N bytes of memory dynamically, with error checking. */
-
-static char *
-xmalloc (unsigned int n)
-{
- char *p;
-
- p = malloc (n);
- if (p == 0)
- {
- error (0, 0, _("virtual memory exhausted"));
- cleanup ();
- exit (2);
- }
- 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. */
-
-static char *
-xrealloc (char *p, unsigned int n)
-{
- if (p == 0)
- return xmalloc (n);
- if (n == 0)
- {
- free (p);
- return 0;
- }
- p = realloc (p, n);
- if (p == 0)
- {
- error (0, 0, _("virtual memory exhausted"));
- cleanup ();
- exit (2);
- }
- return p;
-}
-
-static FILE *
-xtmpfopen (const char *file)
-{
- FILE *fp;
- int fd;
-
- fd = open (file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
- if (fd < 0 || (fp = fdopen (fd, "w")) == NULL)
- {
- error (0, errno, "%s", file);
- cleanup ();
- exit (2);
- }
-
- return fp;
-}
-
-static FILE *
-xfopen (const char *file, const char *how)
-{
- FILE *fp;
-
- if (strcmp (file, "-") == 0)
- {
- fp = stdin;
- }
- else
- {
- if ((fp = fopen (file, how)) == NULL)
- {
- error (0, errno, "%s", file);
- cleanup ();
- exit (2);
- }
- }
-
- if (fp == stdin)
- have_read_stdin = 1;
- return fp;
-}
-
-static void
-xfclose (FILE *fp)
-{
- if (fp == stdin)
- {
- /* Allow reading stdin from tty more than once. */
- if (feof (fp))
- clearerr (fp);
- }
- else if (fp == stdout)
- {
- if (fflush (fp) != 0)
- {
- error (0, errno, _("flushing file"));
- cleanup ();
- exit (2);
- }
- }
- else
- {
- if (fclose (fp) != 0)
- {
- error (0, errno, _("error closing file"));
- cleanup ();
- exit (2);
- }
- }
-}
-
-static void
-xfwrite (const char *buf, int size, int nelem, FILE *fp)
-{
- if (fwrite (buf, size, nelem, fp) != nelem)
- {
- error (0, errno, _("write error"));
- cleanup ();
- exit (2);
- }
-}
-
-/* Return a name for a temporary file. */
-
-static char *
-tempname (void)
-{
- static unsigned int seq;
- int len = strlen (temp_file_prefix);
- char *name = xmalloc (len + 1 + sizeof ("sort") - 1 + 5 + 5 + 1);
- struct tempnode *node;
-
- node = (struct tempnode *) xmalloc (sizeof (struct tempnode));
- sprintf (name,
- "%s%ssort%5.5d%5.5d",
- temp_file_prefix,
- (len && temp_file_prefix[len - 1] != '/') ? "/" : "",
- (unsigned int) getpid () & 0xffff, seq);
-
- /* Make sure that SEQ's value fits in 5 digits. */
- ++seq;
- if (seq >= 100000)
- seq = 0;
-
- node->name = name;
- node->next = temphead.next;
- temphead.next = node;
- return name;
-}
-
-/* Search through the list of temporary files for NAME;
- remove it if it is found on the list. */
-
-static void
-zaptemp (char *name)
-{
- struct tempnode *node, *temp;
-
- for (node = &temphead; node->next; node = node->next)
- if (!strcmp (name, node->next->name))
- break;
- if (node->next)
- {
- temp = node->next;
- unlink (temp->name);
- free (temp->name);
- node->next = temp->next;
- free ((char *) temp);
- }
-}
-
-/* Initialize the character class tables. */
-
-static void
-inittables (void)
-{
- int i;
-
- for (i = 0; i < UCHAR_LIM; ++i)
- {
- if (ISBLANK (i))
- blanks[i] = 1;
- if (ISDIGIT (i))
- digits[i] = 1;
- if (!ISPRINT (i))
- nonprinting[i] = 1;
- if (!ISALNUM (i) && !ISBLANK (i))
- nondictionary[i] = 1;
- if (ISLOWER (i))
- fold_toupper[i] = toupper (i);
- else
- fold_toupper[i] = i;
- }
-#ifdef __FreeBSD__
- init_collates();
-#endif
-}
-
-/* Initialize BUF, allocating ALLOC bytes initially. */
-
-static void
-initbuf (struct buffer *buf, int alloc)
-{
- buf->alloc = alloc;
- buf->buf = xmalloc (buf->alloc);
- buf->used = buf->left = 0;
-}
-
-/* Fill BUF reading from FP, moving buf->left bytes from the end
- of buf->buf to the beginning first. If EOF is reached and the
- file wasn't terminated by a newline, supply one. Return a count
- of bytes buffered. */
-
-static int
-fillbuf (struct buffer *buf, FILE *fp)
-{
- int cc;
-
- memmove (buf->buf, buf->buf + buf->used - buf->left, buf->left);
- buf->used = buf->left;
-
- while (!feof (fp) && (buf->used == 0 || !memchr (buf->buf, '\n', buf->used)))
- {
- if (buf->used == buf->alloc)
- {
- buf->alloc *= 2;
- buf->buf = xrealloc (buf->buf, buf->alloc);
- }
- cc = fread (buf->buf + buf->used, 1, buf->alloc - buf->used, fp);
- if (ferror (fp))
- {
- error (0, errno, _("read error"));
- cleanup ();
- exit (2);
- }
- buf->used += cc;
- }
-
- if (feof (fp) && buf->used && buf->buf[buf->used - 1] != '\n')
- {
- if (buf->used == buf->alloc)
- {
- buf->alloc *= 2;
- buf->buf = xrealloc (buf->buf, buf->alloc);
- }
- buf->buf[buf->used++] = '\n';
- }
-
- return buf->used;
-}
-
-/* Initialize LINES, allocating space for ALLOC lines initially.
- LIMIT is the maximum possible number of lines to allocate space
- for, ever. */
-
-static void
-initlines (struct lines *lines, int alloc, int limit)
-{
- lines->alloc = alloc;
- lines->lines = (struct line *) xmalloc (lines->alloc * sizeof (struct line));
- lines->used = 0;
- lines->limit = limit;
-}
-
-/* Return a pointer to the first character of the field specified
- by KEY in LINE. */
-
-static char *
-begfield (const struct line *line, const struct keyfield *key)
-{
- register char *ptr = line->text, *lim = ptr + line->length;
- register int sword = key->sword, schar = key->schar;
-
- if (tab)
- while (ptr < lim && sword--)
- {
- while (ptr < lim && *ptr != tab)
- ++ptr;
- if (ptr < lim)
- ++ptr;
- }
- else
- while (ptr < lim && sword--)
- {
- while (ptr < lim && blanks[UCHAR (*ptr)])
- ++ptr;
- while (ptr < lim && !blanks[UCHAR (*ptr)])
- ++ptr;
- }
-
- if (key->skipsblanks)
- while (ptr < lim && blanks[UCHAR (*ptr)])
- ++ptr;
-
- if (ptr + schar <= lim)
- ptr += schar;
- else
- ptr = lim;
-
- return ptr;
-}
-
-/* Return the limit of (a pointer to the first character after) the field
- in LINE specified by KEY. */
-
-static char *
-limfield (const struct line *line, const struct keyfield *key)
-{
- register char *ptr = line->text, *lim = ptr + line->length;
- register int eword = key->eword, echar = key->echar;
-
- /* Note: from the POSIX spec:
- The leading field separator itself is included in
- a field when -t is not used. FIXME: move this comment up... */
-
- /* Move PTR past EWORD fields or to one past the last byte on LINE,
- whichever comes first. If there are more than EWORD fields, leave
- PTR pointing at the beginning of the field having zero-based index,
- EWORD. If a delimiter character was specified (via -t), then that
- `beginning' is the first character following the delimiting TAB.
- Otherwise, leave PTR pointing at the first `blank' character after
- the preceding field. */
- if (tab)
- while (ptr < lim && eword--)
- {
- while (ptr < lim && *ptr != tab)
- ++ptr;
- if (ptr < lim && (eword || echar > 0))
- ++ptr;
- }
- else
- while (ptr < lim && eword--)
- {
- while (ptr < lim && blanks[UCHAR (*ptr)])
- ++ptr;
- while (ptr < lim && !blanks[UCHAR (*ptr)])
- ++ptr;
- }
-
- /* Make LIM point to the end of (one byte past) the current field. */
- if (tab)
- {
- char *newlim;
- newlim = memchr (ptr, tab, lim - ptr);
- if (newlim)
- lim = newlim;
- }
- else
- {
- char *newlim;
- newlim = ptr;
- while (newlim < lim && blanks[UCHAR (*newlim)])
- ++newlim;
- while (newlim < lim && !blanks[UCHAR (*newlim)])
- ++newlim;
- lim = newlim;
- }
-
- /* If we're skipping leading blanks, don't start counting characters
- until after skipping past any leading blanks. */
- if (key->skipsblanks)
- while (ptr < lim && blanks[UCHAR (*ptr)])
- ++ptr;
-
- /* Advance PTR by ECHAR (if possible), but no further than LIM. */
- if (ptr + echar <= lim)
- ptr += echar;
- else
- ptr = lim;
-
- return ptr;
-}
-
-/* FIXME */
-
-void
-trim_trailing_blanks (const char *a_start, char **a_end)
-{
- while (*a_end > a_start && blanks[UCHAR (*(*a_end - 1))])
- --(*a_end);
-}
-
-/* Find the lines in BUF, storing pointers and lengths in LINES.
- Also replace newlines in BUF with NULs. */
-
-static void
-findlines (struct buffer *buf, struct lines *lines)
-{
- register char *beg = buf->buf, *lim = buf->buf + buf->used, *ptr;
- struct keyfield *key = keyhead.next;
-
- lines->used = 0;
-
- while (beg < lim && (ptr = memchr (beg, '\n', lim - beg))
- && lines->used < lines->limit)
- {
- /* There are various places in the code that rely on a NUL
- being at the end of in-core lines; NULs inside the lines
- will not cause trouble, though. */
- *ptr = '\0';
-
- if (lines->used == lines->alloc)
- {
- lines->alloc *= 2;
- lines->lines = (struct line *)
- xrealloc ((char *) lines->lines,
- lines->alloc * sizeof (struct line));
- }
-
- lines->lines[lines->used].text = beg;
- lines->lines[lines->used].length = ptr - beg;
-
- /* Precompute the position of the first key for efficiency. */
- if (key)
- {
- if (key->eword >= 0)
- lines->lines[lines->used].keylim =
- limfield (&lines->lines[lines->used], key);
- else
- lines->lines[lines->used].keylim = ptr;
-
- if (key->sword >= 0)
- lines->lines[lines->used].keybeg =
- begfield (&lines->lines[lines->used], key);
- else
- {
- if (key->skipsblanks)
- while (blanks[UCHAR (*beg)])
- ++beg;
- lines->lines[lines->used].keybeg = beg;
- }
- if (key->skipeblanks)
- {
- trim_trailing_blanks (lines->lines[lines->used].keybeg,
- &lines->lines[lines->used].keylim);
- }
- }
- else
- {
- lines->lines[lines->used].keybeg = 0;
- lines->lines[lines->used].keylim = 0;
- }
-
- ++lines->used;
- beg = ptr + 1;
- }
-
- buf->left = lim - beg;
-}
-
-/* Compare strings A and B containing decimal fractions < 1. Each string
- should begin with a decimal point followed immediately by the digits
- of the fraction. Strings not of this form are considered to be zero. */
-
-static int
-fraccompare (register const char *a, register const char *b)
-{
- register tmpa = UCHAR (*a), tmpb = UCHAR (*b);
-
- if (tmpa == '.' && tmpb == '.')
- {
- do
- tmpa = UCHAR (*++a), tmpb = UCHAR (*++b);
- while (tmpa == tmpb && digits[tmpa]);
- if (digits[tmpa] && digits[tmpb])
- return tmpa - tmpb;
- if (digits[tmpa])
- {
- while (tmpa == '0')
- tmpa = UCHAR (*++a);
- if (digits[tmpa])
- return 1;
- return 0;
- }
- if (digits[tmpb])
- {
- while (tmpb == '0')
- tmpb = UCHAR (*++b);
- if (digits[tmpb])
- return -1;
- return 0;
- }
- return 0;
- }
- else if (tmpa == '.')
- {
- do
- tmpa = UCHAR (*++a);
- while (tmpa == '0');
- if (digits[tmpa])
- return 1;
- return 0;
- }
- else if (tmpb == '.')
- {
- do
- tmpb = UCHAR (*++b);
- while (tmpb == '0');
- if (digits[tmpb])
- return -1;
- return 0;
- }
- return 0;
-}
-
-/* Compare strings A and B as numbers without explicitly converting them to
- machine numbers. Comparatively slow for short strings, but asymptotically
- hideously fast. */
-
-static int
-numcompare (register const char *a, register const char *b)
-{
- register int tmpa, tmpb, loga, logb, tmp;
-
- tmpa = UCHAR (*a);
- tmpb = UCHAR (*b);
-
- while (blanks[tmpa])
- tmpa = UCHAR (*++a);
- while (blanks[tmpb])
- tmpb = UCHAR (*++b);
-
- if (tmpa == '-')
- {
- do
- tmpa = UCHAR (*++a);
- while (tmpa == '0');
- if (tmpb != '-')
- {
- if (tmpa == '.')
- do
- tmpa = UCHAR (*++a);
- while (tmpa == '0');
- if (digits[tmpa])
- return -1;
- while (tmpb == '0')
- tmpb = UCHAR (*++b);
- if (tmpb == '.')
- do
- tmpb = UCHAR (*++b);
- while (tmpb == '0');
- if (digits[tmpb])
- return -1;
- return 0;
- }
- do
- tmpb = UCHAR (*++b);
- while (tmpb == '0');
-
- while (tmpa == tmpb && digits[tmpa])
- tmpa = UCHAR (*++a), tmpb = UCHAR (*++b);
-
- if ((tmpa == '.' && !digits[tmpb]) || (tmpb == '.' && !digits[tmpa]))
- return -fraccompare (a, b);
-
- if (digits[tmpa])
- for (loga = 1; digits[UCHAR (*++a)]; ++loga)
- ;
- else
- loga = 0;
-
- if (digits[tmpb])
- for (logb = 1; digits[UCHAR (*++b)]; ++logb)
- ;
- else
- logb = 0;
-
- if ((tmp = logb - loga) != 0)
- return tmp;
-
- if (!loga)
- return 0;
-
-#ifdef __FreeBSD__
- return COLLDIFF (tmpb, tmpa);
-#else
- return tmpb - tmpa;
-#endif
- }
- else if (tmpb == '-')
- {
- do
- tmpb = UCHAR (*++b);
- while (tmpb == '0');
- if (tmpb == '.')
- do
- tmpb = UCHAR (*++b);
- while (tmpb == '0');
- if (digits[tmpb])
- return 1;
- while (tmpa == '0')
- tmpa = UCHAR (*++a);
- if (tmpa == '.')
- do
- tmpa = UCHAR (*++a);
- while (tmpa == '0');
- if (digits[tmpa])
- return 1;
- return 0;
- }
- else
- {
- while (tmpa == '0')
- tmpa = UCHAR (*++a);
- while (tmpb == '0')
- tmpb = UCHAR (*++b);
-
- while (tmpa == tmpb && digits[tmpa])
- tmpa = UCHAR (*++a), tmpb = UCHAR (*++b);
-
- if ((tmpa == '.' && !digits[tmpb]) || (tmpb == '.' && !digits[tmpa]))
- return fraccompare (a, b);
-
- if (digits[tmpa])
- for (loga = 1; digits[UCHAR (*++a)]; ++loga)
- ;
- else
- loga = 0;
-
- if (digits[tmpb])
- for (logb = 1; digits[UCHAR (*++b)]; ++logb)
- ;
- else
- logb = 0;
-
- if ((tmp = loga - logb) != 0)
- return tmp;
-
- if (!loga)
- return 0;
-
-#ifdef __FreeBSD__
- return COLLDIFF (tmpa, tmpb);
-#else
- return tmpa - tmpb;
-#endif
- }
-}
-
-static int
-general_numcompare (const char *sa, const char *sb)
-{
- double a, b;
- /* FIXME: add option to warn about failed conversions. */
- /* FIXME: maybe add option to try expensive FP conversion
- only if A and B can't be compared more cheaply/accurately. */
- if (xstrtod (sa, NULL, &a))
- {
- a = 0;
- }
- if (xstrtod (sb, NULL, &b))
- {
- b = 0;
- }
- return a == b ? 0 : a < b ? -1 : 1;
-}
-
-/* Return an integer <= 12 associated with month name S with length LEN,
- 0 if the name in S is not recognized. */
-
-static int
-getmonth (const char *s, int len)
-{
- char month[4];
- register int i, lo = 0, hi = 12;
-
- while (len > 0 && blanks[UCHAR(*s)])
- ++s, --len;
-
- if (len < 3)
- return 0;
-
- for (i = 0; i < 3; ++i)
- month[i] = fold_toupper[UCHAR (s[i])];
- month[3] = '\0';
-
- while (hi - lo > 1)
- if (strcmp (month, monthtab[(lo + hi) / 2].name) < 0)
- hi = (lo + hi) / 2;
- else
- lo = (lo + hi) / 2;
- if (!strcmp (month, monthtab[lo].name))
- return monthtab[lo].val;
- return 0;
-}
-
-/* Compare two lines A and B trying every key in sequence until there
- are no more keys or a difference is found. */
-
-static int
-keycompare (const struct line *a, const struct line *b)
-{
- register char *texta, *textb, *lima, *limb, *translate;
- register int *ignore;
- struct keyfield *key;
- int diff = 0, iter = 0, lena, lenb;
-
- for (key = keyhead.next; key; key = key->next, ++iter)
- {
- ignore = key->ignore;
- translate = key->translate;
-
- /* Find the beginning and limit of each field. */
- if (iter || a->keybeg == NULL || b->keybeg == NULL)
- {
- if (key->eword >= 0)
- lima = limfield (a, key), limb = limfield (b, key);
- else
- lima = a->text + a->length, limb = b->text + b->length;
-
- if (key->sword >= 0)
- texta = begfield (a, key), textb = begfield (b, key);
- else
- {
- texta = a->text, textb = b->text;
- if (key->skipsblanks)
- {
- while (texta < lima && blanks[UCHAR (*texta)])
- ++texta;
- while (textb < limb && blanks[UCHAR (*textb)])
- ++textb;
- }
- }
- }
- else
- {
- /* For the first iteration only, the key positions have
- been precomputed for us. */
- texta = a->keybeg, lima = a->keylim;
- textb = b->keybeg, limb = b->keylim;
- }
-
- /* Find the lengths. */
- lena = lima - texta, lenb = limb - textb;
- if (lena < 0)
- lena = 0;
- if (lenb < 0)
- lenb = 0;
-
- if (key->skipeblanks)
- {
- char *a_end = texta + lena;
- char *b_end = textb + lenb;
- trim_trailing_blanks (texta, &a_end);
- trim_trailing_blanks (textb, &b_end);
- lena = a_end - texta;
- lenb = b_end - textb;
- }
-
- /* Actually compare the fields. */
- if (key->numeric)
- {
- if (*lima || *limb)
- {
- char savea = *lima, saveb = *limb;
-
- *lima = *limb = '\0';
- diff = numcompare (texta, textb);
- *lima = savea, *limb = saveb;
- }
- else
- diff = numcompare (texta, textb);
-
- if (diff)
- return key->reverse ? -diff : diff;
- continue;
- }
- else if (key->general_numeric)
- {
- if (*lima || *limb)
- {
- char savea = *lima, saveb = *limb;
-
- *lima = *limb = '\0';
- diff = general_numcompare (texta, textb);
- *lima = savea, *limb = saveb;
- }
- else
- diff = general_numcompare (texta, textb);
-
- if (diff)
- return key->reverse ? -diff : diff;
- continue;
- }
- else if (key->month)
- {
- diff = getmonth (texta, lena) - getmonth (textb, lenb);
- if (diff)
- return key->reverse ? -diff : diff;
- continue;
- }
- else if (ignore && translate)
-
-#ifdef __FreeBSD__
-#define CMP_FUNC(A, B) COLLDIFF ((A), (B))
-#else
-#define CMP_FUNC(A, B) (A) - (B)
-#endif
-#define CMP_WITH_IGNORE(A, B) \
- do \
- { \
- while (texta < lima && textb < limb) \
- { \
- while (texta < lima && ignore[UCHAR (*texta)]) \
- ++texta; \
- while (textb < limb && ignore[UCHAR (*textb)]) \
- ++textb; \
- if (texta < lima && textb < limb) \
- { \
- if ((A) != (B)) \
- { \
- diff = CMP_FUNC((A), (B)); \
- break; \
- } \
- ++texta; \
- ++textb; \
- } \
- \
- if (texta == lima && textb < limb && !ignore[UCHAR (*textb)]) \
- diff = -1; \
- else if (texta < lima && textb == limb \
- && !ignore[UCHAR (*texta)]) \
- diff = 1; \
- } \
- \
- if (diff == 0) \
- { \
- while (texta < lima && ignore[UCHAR (*texta)]) \
- ++texta; \
- while (textb < limb && ignore[UCHAR (*textb)]) \
- ++textb; \
- \
- if (texta == lima && textb < limb) \
- diff = -1; \
- else if (texta < lima && textb == limb) \
- diff = 1; \
- } \
- /* Relative lengths are meaningless if characters were ignored. \
- Handling this case here avoids what might be an invalid length \
- comparison below. */ \
- if (diff == 0 && texta == lima && textb == limb) \
- return 0; \
- } \
- while (0)
-
- CMP_WITH_IGNORE (translate[UCHAR (*texta)], translate[UCHAR (*textb)]);
- else if (ignore)
- CMP_WITH_IGNORE (*texta, *textb);
- else if (translate)
- while (texta < lima && textb < limb)
- {
- if (translate[UCHAR (*texta++)] != translate[UCHAR (*textb++)])
- {
-#ifdef __FreeBSD__
- diff = COLLDIFF (translate[UCHAR (*--texta)],
- translate[UCHAR (*--textb)]);
-#else
- diff = (translate[UCHAR (*--texta)]
- - translate[UCHAR (*--textb)]);
-#endif
- break;
- }
- }
- else
-#ifdef __FreeBSD__
- diff = collcmp (texta, textb, min (lena, lenb));
-#else
- diff = memcmp (texta, textb, min (lena, lenb));
-#endif
-
- if (diff)
- return key->reverse ? -diff : diff;
- if ((diff = lena - lenb) != 0)
- return key->reverse ? -diff : diff;
- }
-
- return 0;
-}
-
-/* Compare two lines A and B, returning negative, zero, or positive
- depending on whether A compares less than, equal to, or greater than B. */
-
-static int
-compare (register const struct line *a, register const struct line *b)
-{
- int diff, tmpa, tmpb, mini;
-
- /* First try to compare on the specified keys (if any).
- The only two cases with no key at all are unadorned sort,
- and unadorned sort -r. */
- if (keyhead.next)
- {
- diff = keycompare (a, b);
- if (diff != 0)
- return diff;
- if (unique || stable)
- return 0;
- }
-
- /* If the keys all compare equal (or no keys were specified)
- fall through to the default byte-by-byte comparison. */
- tmpa = a->length, tmpb = b->length;
- mini = min (tmpa, tmpb);
- if (mini == 0)
- diff = tmpa - tmpb;
- else
- {
- char *ap = a->text, *bp = b->text;
-
-#ifdef __FreeBSD__
- diff = COLLDIFF (*ap, *bp);
-#else
- diff = UCHAR (*ap) - UCHAR (*bp);
-#endif
- if (diff == 0)
- {
-#ifdef __FreeBSD__
- diff = collcmp (ap, bp, mini);
-#else
- diff = memcmp (ap, bp, mini);
-#endif
- if (diff == 0)
- diff = tmpa - tmpb;
- }
- }
-
- return reverse ? -diff : diff;
-}
-
-/* Check that the lines read from the given FP come in order. Return
- 1 if they do and 0 if there is a disorder.
- FIXME: return number of first out-of-order line if not sorted. */
-
-static int
-checkfp (FILE *fp)
-{
- struct buffer buf; /* Input buffer. */
- struct lines lines; /* Lines scanned from the buffer. */
- struct line temp; /* Copy of previous line. */
- int cc; /* Character count. */
- int alloc, sorted = 1;
-
- initbuf (&buf, mergealloc);
- initlines (&lines, mergealloc / linelength + 1,
- LINEALLOC / ((NMERGE + NMERGE) * sizeof (struct line)));
- alloc = linelength;
- temp.text = xmalloc (alloc);
-
- cc = fillbuf (&buf, fp);
- if (cc == 0)
- goto finish;
-
- findlines (&buf, &lines);
-
- while (1)
- {
- struct line *prev_line; /* Pointer to previous line. */
- int cmp; /* Result of calling compare. */
- int i;
-
- /* Compare each line in the buffer with its successor. */
- for (i = 0; i < lines.used - 1; ++i)
- {
- cmp = compare (&lines.lines[i], &lines.lines[i + 1]);
- if ((unique && cmp >= 0) || (cmp > 0))
- {
- sorted = 0;
- goto finish;
- }
- }
-
- /* Save the last line of the buffer and refill the buffer. */
- prev_line = lines.lines + (lines.used - 1);
- if (prev_line->length > alloc)
- {
- while (prev_line->length + 1 > alloc)
- alloc *= 2;
- temp.text = xrealloc (temp.text, alloc);
- }
- memcpy (temp.text, prev_line->text, prev_line->length + 1);
- temp.length = prev_line->length;
- temp.keybeg = temp.text + (prev_line->keybeg - prev_line->text);
- temp.keylim = temp.text + (prev_line->keylim - prev_line->text);
-
- cc = fillbuf (&buf, fp);
- if (cc == 0)
- break;
-
- findlines (&buf, &lines);
- /* Make sure the line saved from the old buffer contents is
- less than or equal to the first line of the new buffer. */
- cmp = compare (&temp, &lines.lines[0]);
- if ((unique && cmp >= 0) || (cmp > 0))
- {
- sorted = 0;
- break;
- }
- }
-
-finish:
- xfclose (fp);
- free (buf.buf);
- free ((char *) lines.lines);
- free (temp.text);
- return sorted;
-}
-
-/* Merge lines from FPS onto OFP. NFPS cannot be greater than NMERGE.
- Close FPS before returning. */
-
-static void
-mergefps (FILE **fps, register int nfps, FILE *ofp)
-{
- struct buffer buffer[NMERGE]; /* Input buffers for each file. */
- struct lines lines[NMERGE]; /* Line tables for each buffer. */
- struct line saved; /* Saved line for unique check. */
- int savedflag = 0; /* True if there is a saved line. */
- int savealloc; /* Size allocated for the saved line. */
- int cur[NMERGE]; /* Current line in each line table. */
- int ord[NMERGE]; /* Table representing a permutation of fps,
- such that lines[ord[0]].lines[cur[ord[0]]]
- is the smallest line and will be next
- output. */
- register int i, j, t;
-
-#ifdef lint /* Suppress `used before initialized' warning. */
- savealloc = 0;
-#endif
-
- /* Allocate space for a saved line if necessary. */
- if (unique)
- {
- savealloc = linelength;
- saved.text = xmalloc (savealloc);
- }
-
- /* Read initial lines from each input file. */
- for (i = 0; i < nfps; ++i)
- {
- initbuf (&buffer[i], mergealloc);
- /* If a file is empty, eliminate it from future consideration. */
- while (i < nfps && !fillbuf (&buffer[i], fps[i]))
- {
- xfclose (fps[i]);
- --nfps;
- for (j = i; j < nfps; ++j)
- fps[j] = fps[j + 1];
- }
- if (i == nfps)
- free (buffer[i].buf);
- else
- {
- initlines (&lines[i], mergealloc / linelength + 1,
- LINEALLOC / ((NMERGE + NMERGE) * sizeof (struct line)));
- findlines (&buffer[i], &lines[i]);
- cur[i] = 0;
- }
- }
-
- /* Set up the ord table according to comparisons among input lines.
- Since this only reorders two items if one is strictly greater than
- the other, it is stable. */
- for (i = 0; i < nfps; ++i)
- ord[i] = i;
- for (i = 1; i < nfps; ++i)
- if (compare (&lines[ord[i - 1]].lines[cur[ord[i - 1]]],
- &lines[ord[i]].lines[cur[ord[i]]]) > 0)
- t = ord[i - 1], ord[i - 1] = ord[i], ord[i] = t, i = 0;
-
- /* Repeatedly output the smallest line until no input remains. */
- while (nfps)
- {
- /* If uniqified output is turned on, output only the first of
- an identical series of lines. */
- if (unique)
- {
- if (savedflag && compare (&saved, &lines[ord[0]].lines[cur[ord[0]]]))
- {
- xfwrite (saved.text, 1, saved.length, ofp);
- putc ('\n', ofp);
- savedflag = 0;
- }
- if (!savedflag)
- {
- if (savealloc < lines[ord[0]].lines[cur[ord[0]]].length + 1)
- {
- while (savealloc < lines[ord[0]].lines[cur[ord[0]]].length + 1)
- savealloc *= 2;
- saved.text = xrealloc (saved.text, savealloc);
- }
- saved.length = lines[ord[0]].lines[cur[ord[0]]].length;
- memcpy (saved.text, lines[ord[0]].lines[cur[ord[0]]].text,
- saved.length + 1);
- if (lines[ord[0]].lines[cur[ord[0]]].keybeg != NULL)
- {
- saved.keybeg = saved.text +
- (lines[ord[0]].lines[cur[ord[0]]].keybeg
- - lines[ord[0]].lines[cur[ord[0]]].text);
- }
- if (lines[ord[0]].lines[cur[ord[0]]].keylim != NULL)
- {
- saved.keylim = saved.text +
- (lines[ord[0]].lines[cur[ord[0]]].keylim
- - lines[ord[0]].lines[cur[ord[0]]].text);
- }
- savedflag = 1;
- }
- }
- else
- {
- xfwrite (lines[ord[0]].lines[cur[ord[0]]].text, 1,
- lines[ord[0]].lines[cur[ord[0]]].length, ofp);
- putc ('\n', ofp);
- }
-
- /* Check if we need to read more lines into core. */
- if (++cur[ord[0]] == lines[ord[0]].used)
- if (fillbuf (&buffer[ord[0]], fps[ord[0]]))
- {
- findlines (&buffer[ord[0]], &lines[ord[0]]);
- cur[ord[0]] = 0;
- }
- else
- {
- /* We reached EOF on fps[ord[0]]. */
- for (i = 1; i < nfps; ++i)
- if (ord[i] > ord[0])
- --ord[i];
- --nfps;
- xfclose (fps[ord[0]]);
- free (buffer[ord[0]].buf);
- free ((char *) lines[ord[0]].lines);
- for (i = ord[0]; i < nfps; ++i)
- {
- fps[i] = fps[i + 1];
- buffer[i] = buffer[i + 1];
- lines[i] = lines[i + 1];
- cur[i] = cur[i + 1];
- }
- for (i = 0; i < nfps; ++i)
- ord[i] = ord[i + 1];
- continue;
- }
-
- /* The new line just read in may be larger than other lines
- already in core; push it back in the queue until we encounter
- a line larger than it. */
- for (i = 1; i < nfps; ++i)
- {
- t = compare (&lines[ord[0]].lines[cur[ord[0]]],
- &lines[ord[i]].lines[cur[ord[i]]]);
- if (!t)
- t = ord[0] - ord[i];
- if (t < 0)
- break;
- }
- t = ord[0];
- for (j = 1; j < i; ++j)
- ord[j - 1] = ord[j];
- ord[i - 1] = t;
- }
-
- if (unique && savedflag)
- {
- xfwrite (saved.text, 1, saved.length, ofp);
- putc ('\n', ofp);
- free (saved.text);
- }
-}
-
-/* Sort the array LINES with NLINES members, using TEMP for temporary space. */
-
-static void
-sortlines (struct line *lines, int nlines, struct line *temp)
-{
- register struct line *lo, *hi, *t;
- register int nlo, nhi;
-
- if (nlines == 2)
- {
- if (compare (&lines[0], &lines[1]) > 0)
- *temp = lines[0], lines[0] = lines[1], lines[1] = *temp;
- return;
- }
-
- nlo = nlines / 2;
- lo = lines;
- nhi = nlines - nlo;
- hi = lines + nlo;
-
- if (nlo > 1)
- sortlines (lo, nlo, temp);
-
- if (nhi > 1)
- sortlines (hi, nhi, temp);
-
- t = temp;
-
- while (nlo && nhi)
- if (compare (lo, hi) <= 0)
- *t++ = *lo++, --nlo;
- else
- *t++ = *hi++, --nhi;
- while (nlo--)
- *t++ = *lo++;
-
- for (lo = lines, nlo = nlines - nhi, t = temp; nlo; --nlo)
- *lo++ = *t++;
-}
-
-/* Check that each of the NFILES FILES is ordered.
- Return a count of disordered files. */
-
-static int
-check (char **files, int nfiles)
-{
- int i, disorders = 0;
- FILE *fp;
-
- for (i = 0; i < nfiles; ++i)
- {
- fp = xfopen (files[i], "r");
- if (!checkfp (fp))
- {
- fprintf (stderr, _("%s: disorder on %s\n"), program_name, files[i]);
- ++disorders;
- }
- }
- return disorders;
-}
-
-/* Merge NFILES FILES onto OFP. */
-
-static void
-merge (char **files, int nfiles, FILE *ofp)
-{
- int i, j, t;
- char *temp;
- FILE *fps[NMERGE], *tfp;
-
- while (nfiles > NMERGE)
- {
- t = 0;
- for (i = 0; i < nfiles / NMERGE; ++i)
- {
- for (j = 0; j < NMERGE; ++j)
- fps[j] = xfopen (files[i * NMERGE + j], "r");
- tfp = xtmpfopen (temp = tempname ());
- mergefps (fps, NMERGE, tfp);
- xfclose (tfp);
- for (j = 0; j < NMERGE; ++j)
- zaptemp (files[i * NMERGE + j]);
- files[t++] = temp;
- }
- for (j = 0; j < nfiles % NMERGE; ++j)
- fps[j] = xfopen (files[i * NMERGE + j], "r");
- tfp = xtmpfopen (temp = tempname ());
- mergefps (fps, nfiles % NMERGE, tfp);
- xfclose (tfp);
- for (j = 0; j < nfiles % NMERGE; ++j)
- zaptemp (files[i * NMERGE + j]);
- files[t++] = temp;
- nfiles = t;
- }
-
- for (i = 0; i < nfiles; ++i)
- fps[i] = xfopen (files[i], "r");
- mergefps (fps, i, ofp);
- for (i = 0; i < nfiles; ++i)
- zaptemp (files[i]);
-}
-
-/* Sort NFILES FILES onto OFP. */
-
-static void
-sort (char **files, int nfiles, FILE *ofp)
-{
- struct buffer buf;
- struct lines lines;
- struct line *tmp;
- int i, ntmp;
- FILE *fp, *tfp;
- struct tempnode *node;
- int n_temp_files = 0;
- char **tempfiles;
-
- initbuf (&buf, sortalloc);
- initlines (&lines, sortalloc / linelength + 1,
- LINEALLOC / sizeof (struct line));
- ntmp = lines.alloc;
- tmp = (struct line *) xmalloc (ntmp * sizeof (struct line));
-
- while (nfiles--)
- {
- fp = xfopen (*files++, "r");
- while (fillbuf (&buf, fp))
- {
- findlines (&buf, &lines);
- if (lines.used > ntmp)
- {
- while (lines.used > ntmp)
- ntmp *= 2;
- tmp = (struct line *)
- xrealloc ((char *) tmp, ntmp * sizeof (struct line));
- }
- sortlines (lines.lines, lines.used, tmp);
- if (feof (fp) && !nfiles && !n_temp_files && !buf.left)
- tfp = ofp;
- else
- {
- ++n_temp_files;
- tfp = xtmpfopen (tempname ());
- }
- for (i = 0; i < lines.used; ++i)
- if (!unique || i == 0
- || compare (&lines.lines[i], &lines.lines[i - 1]))
- {
- xfwrite (lines.lines[i].text, 1, lines.lines[i].length, tfp);
- putc ('\n', tfp);
- }
- if (tfp != ofp)
- xfclose (tfp);
- }
- xfclose (fp);
- }
-
- free (buf.buf);
- free ((char *) lines.lines);
- free ((char *) tmp);
-
- if (n_temp_files)
- {
- tempfiles = (char **) xmalloc (n_temp_files * sizeof (char *));
- i = n_temp_files;
- for (node = temphead.next; i > 0; node = node->next)
- tempfiles[--i] = node->name;
- merge (tempfiles, n_temp_files, ofp);
- free ((char *) tempfiles);
- }
-}
-
-/* Insert key KEY at the end of the list (`keyhead'). */
-
-static void
-insertkey (struct keyfield *key)
-{
- struct keyfield *k = &keyhead;
-
- while (k->next)
- k = k->next;
- k->next = key;
- key->next = NULL;
-}
-
-static void
-badfieldspec (const char *s)
-{
- error (2, 0, _("invalid field specification `%s'"), s);
-}
-
-/* Handle interrupts and hangups. */
-
-static void
-sighandler (int sig)
-{
-#ifdef SA_INTERRUPT
- struct sigaction sigact;
-
- sigact.sa_handler = SIG_DFL;
- sigemptyset (&sigact.sa_mask);
- sigact.sa_flags = 0;
- sigaction (sig, &sigact, NULL);
-#else /* !SA_INTERRUPT */
- signal (sig, SIG_DFL);
-#endif /* SA_INTERRUPT */
- cleanup ();
- kill (getpid (), sig);
-}
-
-/* Set the ordering options for KEY specified in S.
- Return the address of the first character in S that
- is not a valid ordering option.
- BLANKTYPE is the kind of blanks that 'b' should skip. */
-
-static char *
-set_ordering (register const char *s, struct keyfield *key,
- enum blanktype blanktype)
-{
- while (*s)
- {
- switch (*s)
- {
- case 'b':
- if (blanktype == bl_start || blanktype == bl_both)
- key->skipsblanks = 1;
- if (blanktype == bl_end || blanktype == bl_both)
- key->skipeblanks = 1;
- break;
- case 'd':
- key->ignore = nondictionary;
- break;
- case 'f':
- key->translate = fold_toupper;
- break;
- case 'g':
- key->general_numeric = 1;
- break;
- case 'i':
- key->ignore = nonprinting;
- break;
- case 'M':
- key->month = 1;
- break;
- case 'n':
- key->numeric = 1;
- if (blanktype == bl_start || blanktype == bl_both)
- key->skipsblanks = 1;
- if (blanktype == bl_end || blanktype == bl_both)
- key->skipeblanks = 1;
- break;
- case 'r':
- key->reverse = 1;
- break;
- default:
- return (char *) s;
- }
- ++s;
- }
- return (char *) s;
-}
-
-void
-main (int argc, char **argv)
-{
- struct keyfield *key = NULL, gkey;
- char *s;
- int i, t, t2;
- int checkonly = 0, mergeonly = 0, nfiles = 0;
- char *minus = "-", *outfile = minus, **files, *tmp;
- FILE *ofp;
-#ifdef SA_INTERRUPT
- struct sigaction oldact, newact;
-#endif /* SA_INTERRUPT */
-
-#ifdef __FreeBSD__
- (void) setlocale(LC_ALL, "");
-#endif
- program_name = argv[0];
-
- parse_long_options (argc, argv, "sort", version_string, usage);
-
- have_read_stdin = 0;
- inittables ();
-
- temp_file_prefix = getenv ("TMPDIR");
- if (temp_file_prefix == NULL)
- temp_file_prefix = DEFAULT_TMPDIR;
-
-#ifdef SA_INTERRUPT
- newact.sa_handler = sighandler;
- sigemptyset (&newact.sa_mask);
- newact.sa_flags = 0;
-
- sigaction (SIGINT, NULL, &oldact);
- if (oldact.sa_handler != SIG_IGN)
- sigaction (SIGINT, &newact, NULL);
- sigaction (SIGHUP, NULL, &oldact);
- if (oldact.sa_handler != SIG_IGN)
- sigaction (SIGHUP, &newact, NULL);
- sigaction (SIGPIPE, NULL, &oldact);
- if (oldact.sa_handler != SIG_IGN)
- sigaction (SIGPIPE, &newact, NULL);
- sigaction (SIGTERM, NULL, &oldact);
- if (oldact.sa_handler != SIG_IGN)
- sigaction (SIGTERM, &newact, NULL);
-#else /* !SA_INTERRUPT */
- if (signal (SIGINT, SIG_IGN) != SIG_IGN)
- signal (SIGINT, sighandler);
- if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
- signal (SIGHUP, sighandler);
- if (signal (SIGPIPE, SIG_IGN) != SIG_IGN)
- signal (SIGPIPE, sighandler);
- if (signal (SIGTERM, SIG_IGN) != SIG_IGN)
- signal (SIGTERM, sighandler);
-#endif /* !SA_INTERRUPT */
-
- gkey.sword = gkey.eword = -1;
- gkey.ignore = NULL;
- gkey.translate = NULL;
- gkey.numeric = gkey.general_numeric = gkey.month = gkey.reverse = 0;
- gkey.skipsblanks = gkey.skipeblanks = 0;
-
- files = (char **) xmalloc (sizeof (char *) * argc);
-
- for (i = 1; i < argc; ++i)
- {
- if (argv[i][0] == '+')
- {
- if (key)
- insertkey (key);
- key = (struct keyfield *) xmalloc (sizeof (struct keyfield));
- key->eword = -1;
- key->ignore = NULL;
- key->translate = NULL;
- key->skipsblanks = key->skipeblanks = 0;
- key->numeric = key->general_numeric = key->month = key->reverse = 0;
- s = argv[i] + 1;
- if (! (digits[UCHAR (*s)] || (*s == '.' && digits[UCHAR (s[1])])))
- badfieldspec (argv[i]);
- for (t = 0; digits[UCHAR (*s)]; ++s)
- t = 10 * t + *s - '0';
- t2 = 0;
- if (*s == '.')
- for (++s; digits[UCHAR (*s)]; ++s)
- t2 = 10 * t2 + *s - '0';
- if (t2 || t)
- {
- key->sword = t;
- key->schar = t2;
- }
- else
- key->sword = -1;
- s = set_ordering (s, key, bl_start);
- if (*s)
- badfieldspec (argv[i]);
- }
- else if (argv[i][0] == '-' && argv[i][1])
- {
- s = argv[i] + 1;
- if (digits[UCHAR (*s)] || (*s == '.' && digits[UCHAR (s[1])]))
- {
- if (!key)
- usage (2);
- for (t = 0; digits[UCHAR (*s)]; ++s)
- t = t * 10 + *s - '0';
- t2 = 0;
- if (*s == '.')
- for (++s; digits[UCHAR (*s)]; ++s)
- t2 = t2 * 10 + *s - '0';
- key->eword = t;
- key->echar = t2;
- s = set_ordering (s, key, bl_end);
- if (*s)
- badfieldspec (argv[i]);
- insertkey (key);
- key = NULL;
- }
- else
- while (*s)
- {
- s = set_ordering (s, &gkey, bl_both);
- switch (*s)
- {
- case '\0':
- break;
- case 'c':
- checkonly = 1;
- break;
- case 'k':
- if (s[1])
- ++s;
- else
- {
- if (i == argc - 1)
- error (2, 0, _("option `-k' requires an argument"));
- else
- s = argv[++i];
- }
- if (key)
- insertkey (key);
- key = (struct keyfield *)
- xmalloc (sizeof (struct keyfield));
- key->eword = -1;
- key->ignore = NULL;
- key->translate = NULL;
- key->skipsblanks = key->skipeblanks = 0;
- key->numeric = key->month = key->reverse = 0;
- /* Get POS1. */
- if (!digits[UCHAR (*s)])
- badfieldspec (argv[i]);
- for (t = 0; digits[UCHAR (*s)]; ++s)
- t = 10 * t + *s - '0';
- if (t == 0)
- {
- /* Provoke with `sort -k0' */
- error (0, 0, _("the starting field number argument \
-to the `-k' option must be positive"));
- badfieldspec (argv[i]);
- }
- --t;
- t2 = 0;
- if (*s == '.')
- {
- if (!digits[UCHAR (s[1])])
- {
- /* Provoke with `sort -k1.' */
- error (0, 0, _("starting field spec has `.' but \
-lacks following character offset"));
- badfieldspec (argv[i]);
- }
- for (++s; digits[UCHAR (*s)]; ++s)
- t2 = 10 * t2 + *s - '0';
- if (t2 == 0)
- {
- /* Provoke with `sort -k1.0' */
- error (0, 0, _("starting field character offset \
-argument to the `-k' option\nmust be positive"));
- badfieldspec (argv[i]);
- }
- --t2;
- }
- if (t2 || t)
- {
- key->sword = t;
- key->schar = t2;
- }
- else
- key->sword = -1;
- s = set_ordering (s, key, bl_start);
- if (*s == 0)
- {
- key->eword = -1;
- key->echar = 0;
- }
- else if (*s != ',')
- badfieldspec (argv[i]);
- else if (*s == ',')
- {
- /* Skip over comma. */
- ++s;
- if (*s == 0)
- {
- /* Provoke with `sort -k1,' */
- error (0, 0, _("field specification has `,' but \
-lacks following field spec"));
- badfieldspec (argv[i]);
- }
- /* Get POS2. */
- for (t = 0; digits[UCHAR (*s)]; ++s)
- t = t * 10 + *s - '0';
- if (t == 0)
- {
- /* Provoke with `sort -k1,0' */
- error (0, 0, _("ending field number argument \
-to the `-k' option must be positive"));
- badfieldspec (argv[i]);
- }
- --t;
- t2 = 0;
- if (*s == '.')
- {
- if (!digits[UCHAR (s[1])])
- {
- /* Provoke with `sort -k1,1.' */
- error (0, 0, _("ending field spec has `.' \
-but lacks following character offset"));
- badfieldspec (argv[i]);
- }
- for (++s; digits[UCHAR (*s)]; ++s)
- t2 = t2 * 10 + *s - '0';
- }
- else
- {
- /* `-k 2,3' is equivalent to `+1 -3'. */
- ++t;
- }
- key->eword = t;
- key->echar = t2;
- s = set_ordering (s, key, bl_end);
- if (*s)
- badfieldspec (argv[i]);
- }
- insertkey (key);
- key = NULL;
- goto outer;
- case 'm':
- mergeonly = 1;
- break;
- case 'o':
- if (s[1])
- outfile = s + 1;
- else
- {
- if (i == argc - 1)
- error (2, 0, _("option `-o' requires an argument"));
- else
- outfile = argv[++i];
- }
- goto outer;
- case 's':
- stable = 1;
- break;
- case 't':
- if (s[1])
- tab = *++s;
- else if (i < argc - 1)
- {
- tab = *argv[++i];
- goto outer;
- }
- else
- error (2, 0, _("option `-t' requires an argument"));
- break;
- case 'T':
- if (s[1])
- temp_file_prefix = ++s;
- else
- {
- if (i < argc - 1)
- temp_file_prefix = argv[++i];
- else
- error (2, 0, _("option `-T' requires an argument"));
- }
- goto outer;
- /* break; */
- case 'u':
- unique = 1;
- break;
- case 'y':
- /* Accept and ignore e.g. -y0 for compatibility with
- Solaris 2. */
- goto outer;
- default:
- fprintf (stderr, _("%s: unrecognized option `-%c'\n"),
- argv[0], *s);
- usage (2);
- }
- if (*s)
- ++s;
- }
- }
- else /* Not an option. */
- {
- files[nfiles++] = argv[i];
- }
- outer:;
- }
-
- if (key)
- insertkey (key);
-
- /* Inheritance of global options to individual keys. */
- for (key = keyhead.next; key; key = key->next)
- if (!key->ignore && !key->translate && !key->skipsblanks && !key->reverse
- && !key->skipeblanks && !key->month && !key->numeric
- && !key->general_numeric)
- {
- key->ignore = gkey.ignore;
- key->translate = gkey.translate;
- key->skipsblanks = gkey.skipsblanks;
- key->skipeblanks = gkey.skipeblanks;
- key->month = gkey.month;
- key->numeric = gkey.numeric;
- key->general_numeric = gkey.general_numeric;
- key->reverse = gkey.reverse;
- }
-
- if (!keyhead.next && (gkey.ignore || gkey.translate || gkey.skipsblanks
- || gkey.skipeblanks || gkey.month || gkey.numeric
- || gkey.general_numeric))
- insertkey (&gkey);
- reverse = gkey.reverse;
-
- if (nfiles == 0)
- {
- nfiles = 1;
- files = &minus;
- }
-
- if (checkonly)
- exit (check (files, nfiles) != 0);
-
- if (strcmp (outfile, "-"))
- {
- struct stat outstat;
- if (stat (outfile, &outstat) == 0)
- {
- /* The following code prevents a race condition when
- people use the brain dead shell programming idiom:
- cat file | sort -o file
- This feature is provided for historical compatibility,
- but we strongly discourage ever relying on this in
- new shell programs. */
-
- /* Temporarily copy each input file that might be another name
- for the output file. When in doubt (e.g. a pipe), copy. */
- for (i = 0; i < nfiles; ++i)
- {
- char buf[8192];
- FILE *fp;
- int cc;
-
- if (S_ISREG (outstat.st_mode) && strcmp (outfile, files[i]))
- {
- struct stat instat;
- if ((strcmp (files[i], "-")
- ? stat (files[i], &instat)
- : fstat (fileno (stdin), &instat)) != 0)
- {
- error (0, errno, "%s", files[i]);
- cleanup ();
- exit (2);
- }
- if (S_ISREG (instat.st_mode)
- && (instat.st_ino != outstat.st_ino
- || instat.st_dev != outstat.st_dev))
- {
- /* We know the files are distinct. */
- continue;
- }
- }
-
- fp = xfopen (files[i], "r");
- tmp = tempname ();
- ofp = xtmpfopen (tmp);
- while ((cc = fread (buf, 1, sizeof buf, fp)) > 0)
- xfwrite (buf, 1, cc, ofp);
- if (ferror (fp))
- {
- error (0, errno, "%s", files[i]);
- cleanup ();
- exit (2);
- }
- xfclose (ofp);
- xfclose (fp);
- files[i] = tmp;
- }
- }
- ofp = xfopen (outfile, "w");
- }
- else
- ofp = stdout;
-
- if (mergeonly)
- merge (files, nfiles, ofp);
- else
- sort (files, nfiles, ofp);
- cleanup ();
-
- /* If we wait for the implicit flush on exit, and the parent process
- has closed stdout (e.g., exec >&- in a shell), then the output file
- winds up empty. I don't understand why. This is under SunOS,
- Solaris, Ultrix, and Irix. This premature fflush makes the output
- reappear. --karl@cs.umb.edu */
- if (fflush (ofp) < 0)
- error (1, errno, _("%s: write error"), outfile);
-
- if (have_read_stdin && fclose (stdin) == EOF)
- error (1, errno, outfile);
- if (ferror (stdout) || fclose (stdout) == EOF)
- error (1, errno, _("%s: write error"), outfile);
-
- exit (0);
-}
diff --git a/gnu/usr.bin/sort/system.h b/gnu/usr.bin/sort/system.h
deleted file mode 100644
index ed0b26b..0000000
--- a/gnu/usr.bin/sort/system.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/* system-dependent definitions for textutils programs.
- Copyright (C) 1989, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Include sys/types.h before this file. */
-
-#include <sys/stat.h>
-
-#ifdef STAT_MACROS_BROKEN
-#undef S_ISBLK
-#undef S_ISCHR
-#undef S_ISDIR
-#undef S_ISFIFO
-#undef S_ISLNK
-#undef S_ISMPB
-#undef S_ISMPC
-#undef S_ISNWK
-#undef S_ISREG
-#undef S_ISSOCK
-#endif /* STAT_MACROS_BROKEN. */
-
-#if !defined(S_ISBLK) && defined(S_IFBLK)
-#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
-#endif
-#if !defined(S_ISCHR) && defined(S_IFCHR)
-#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
-#endif
-#if !defined(S_ISDIR) && defined(S_IFDIR)
-#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-#endif
-#if !defined(S_ISREG) && defined(S_IFREG)
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#endif
-#if !defined(S_ISFIFO) && defined(S_IFIFO)
-#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
-#endif
-#if !defined(S_ISLNK) && defined(S_IFLNK)
-#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
-#endif
-#if !defined(S_ISSOCK) && defined(S_IFSOCK)
-#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
-#endif
-#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
-#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
-#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
-#endif
-#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
-#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
-#endif
-#if !defined(HAVE_MKFIFO)
-#define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifndef _POSIX_VERSION
-off_t lseek ();
-#endif
-
-#ifndef STDIN_FILENO
-#define STDIN_FILENO 0
-#endif
-
-#ifndef STDOUT_FILENO
-#define STDOUT_FILENO 1
-#endif
-
-#ifndef STDERR_FILENO
-#define STDERR_FILENO 2
-#endif
-
-/* Don't use bcopy! Use memmove if source and destination may overlap,
- memcpy otherwise. */
-
-#ifdef HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#else
-# include <strings.h>
-char *memchr ();
-#endif
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-char *getenv ();
-#endif
-
-#ifndef EXIT_FAILURE
-# define EXIT_FAILURE 1
-#endif
-
-#ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#include <sys/file.h>
-#endif
-
-#if !defined(SEEK_SET)
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
-#endif
-
-#ifndef _POSIX_SOURCE
-#include <sys/param.h>
-#endif
-
-/* Get or fake the disk device blocksize.
- Usually defined by sys/param.h (if at all). */
-#if !defined(DEV_BSIZE) && defined(BSIZE)
-#define DEV_BSIZE BSIZE
-#endif
-#if !defined(DEV_BSIZE) && defined(BBSIZE) /* SGI */
-#define DEV_BSIZE BBSIZE
-#endif
-#ifndef DEV_BSIZE
-#define DEV_BSIZE 4096
-#endif
-
-/* Extract or fake data from a `struct stat'.
- ST_BLKSIZE: Optimal I/O blocksize for the file, in bytes. */
-#ifndef HAVE_ST_BLKSIZE
-# define ST_BLKSIZE(statbuf) DEV_BSIZE
-#else /* HAVE_ST_BLKSIZE */
-/* Some systems, like Sequents, return st_blksize of 0 on pipes. */
-# define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \
- ? (statbuf).st_blksize : DEV_BSIZE)
-#endif /* HAVE_ST_BLKSIZE */
-
-#ifndef S_ISLNK
-#define lstat stat
-#endif
-
-#ifndef RETSIGTYPE
-#define RETSIGTYPE void
-#endif
-
-#include <ctype.h>
-
-#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
-#define ISASCII(c) 1
-#else
-#define ISASCII(c) isascii((unsigned char)c)
-#endif
-
-#ifdef isblank
-#define ISBLANK(c) (ISASCII (c) && isblank ((unsigned char)c))
-#else
-#define ISBLANK(c) ((c) == ' ' || (c) == '\t')
-#endif
-#ifdef isgraph
-#define ISGRAPH(c) (ISASCII (c) && isgraph ((unsigned char)c))
-#else
-#define ISGRAPH(c) (ISASCII (c) && isprint ((unsigned char)c) && !isspace ((unsigned char)c))
-#endif
-
-#define ISPRINT(c) (ISASCII (c) && isprint ((unsigned char)c))
-#define ISDIGIT(c) (ISASCII (c) && isdigit ((unsigned char)c))
-#define ISALNUM(c) (ISASCII (c) && isalnum ((unsigned char)c))
-#define ISALPHA(c) (ISASCII (c) && isalpha ((unsigned char)c))
-#define ISCNTRL(c) (ISASCII (c) && iscntrl ((unsigned char)c))
-#define ISLOWER(c) (ISASCII (c) && islower ((unsigned char)c))
-#define ISPUNCT(c) (ISASCII (c) && ispunct ((unsigned char)c))
-#define ISSPACE(c) (ISASCII (c) && isspace ((unsigned char)c))
-#define ISUPPER(c) (ISASCII (c) && isupper ((unsigned char)c))
-#define ISXDIGIT(c) (ISASCII (c) && isxdigit ((unsigned char)c))
-
-/* Disable string localization for the time being. */
-#undef _
-#define _(String) String
-
-#ifndef __P
-# if PROTOTYPES
-# define __P(Args) Args
-# else
-# define __P(Args) ()
-# endif
-#endif
diff --git a/gnu/usr.bin/sort/version.c b/gnu/usr.bin/sort/version.c
deleted file mode 100644
index 0289fcb..0000000
--- a/gnu/usr.bin/sort/version.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <config.h>
-#include "version.h"
-const char *version_string = "GNU textutils 1.14";
diff --git a/gnu/usr.bin/sort/version.h b/gnu/usr.bin/sort/version.h
deleted file mode 100644
index 63de4fd..0000000
--- a/gnu/usr.bin/sort/version.h
+++ /dev/null
@@ -1 +0,0 @@
-extern const char *version_string;
diff --git a/gnu/usr.bin/sort/xstrtod.c b/gnu/usr.bin/sort/xstrtod.c
deleted file mode 100644
index 838c5c4..0000000
--- a/gnu/usr.bin/sort/xstrtod.c
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-double strtod ();
-#endif
-
-#include <errno.h>
-#include <stdio.h>
-#include <limits.h>
-#include <ctype.h>
-#include "xstrtod.h"
-
-int
-xstrtod (str, ptr, result)
- const char *str;
- const char **ptr;
- double *result;
-{
- double val;
- char *terminator;
- int fail;
-
- fail = 0;
- errno = 0;
- val = strtod (str, &terminator);
-
- /* Having a non-zero terminator is an error only when PTR is NULL. */
- if (terminator == str || (ptr == NULL && *terminator != '\0'))
- fail = 1;
- else
- {
- /* Allow underflow (in which case strtod returns zero),
- but flag overflow as an error. */
- if (val != 0.0 && errno == ERANGE)
- fail = 1;
- }
-
- if (ptr != NULL)
- *ptr = terminator;
-
- *result = val;
- return fail;
-}
-
diff --git a/gnu/usr.bin/sort/xstrtod.h b/gnu/usr.bin/sort/xstrtod.h
deleted file mode 100644
index 15b85f4..0000000
--- a/gnu/usr.bin/sort/xstrtod.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef XSTRTOD_H
-#define XSTRTOD_H 1
-
-#ifndef __P
-# if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
-# define __P(args) args
-# else
-# define __P(args) ()
-# endif /* GCC. */
-#endif /* Not __P. */
-
-int
- xstrtod __P ((const char *str, const char **ptr, double *result));
-
-#endif /* XSTRTOD_H */
diff --git a/gnu/usr.bin/tar/COPYING b/gnu/usr.bin/tar/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/tar/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- 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 of the License, 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/tar/ChangeLog b/gnu/usr.bin/tar/ChangeLog
deleted file mode 100644
index a4717e9..0000000
--- a/gnu/usr.bin/tar/ChangeLog
+++ /dev/null
@@ -1,1738 +0,0 @@
-Sun Dec 14 07:47:44 1997 Peter Hawkins (peter@clari.net.au)
-
- * version.c: Released version 1.11.3.
-
- * implemented the -n / --norecurse option
-
-Thu Mar 25 13:32:40 1993 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * version.c: Released version 1.11.2.
-
- * Makefile.in (dist): Do the link differently; some of the
- files have changed filesystems which makes it more complex.
-
- * Makefile.in (dist, shar): Use gzip instead of compress.
-
- * create.c (dump_file): Test for curdev==-1, not curdev<0.
- Some losing NFS systems give negative device numbers
- sometimes.
-
-Thu Mar 25 11:55:15 1993 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
-
- * level-0, level-1 (TAR_PART1): Use `--block-size', not just
- `--block', which is now ambiguous.
-
-Wed Mar 24 22:12:51 1993 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
-
- * backup-specs (TAR): New variable.
-
- * level-0, level-1 (TAR_PART1): Get path of GNU tar from `TAR'
- variable, don't hardcode it.
-
-Sat Mar 20 00:20:05 1993 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
-
- * backup-specs (SLEEP_MESSAGE): put backslashes in front of nested
- double quotes.
-
- * level-0, level-1 (BACKUP_DIRS): Don't put in quotes.
- (LOGFILE): Use sed to construct name, not awk.
-
- * dump-remind (recipients): Replaced inefficient pipeline with a
- single, simple sed script.
- (volno): Deal with the possibility that VOLNO_FILE may not be
- created yet.
-
-Fri Mar 19 15:05:15 1993 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * backup-specs (VOLNO_FILE): Removed abusive comment by Noah.
-
- * buffer.c (new_volume): Write the global volume number to the
- volno file before running the info script, so that the script
- can look at it.
-
-Thu Mar 18 20:11:54 1993 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
-
- * Makefile.in (AUX): Include `dump-remind' in distribution.
-
- * backup-specs (SLEEP_MESSAGE): New variable.
- level-0, level-1: Use it instead of external `dont_touch' file.
-
- * level-0, level-1: Put most of the script in () and pipe
- everything from the subshell through tee -a $LOGFILE. Since you
- really want most of the output to go to the logfile anyway, and
- since all those pipelines were preventing one from getting the
- exit status of most commands, this seems like the right idea.
-
- * level-0, level-1 (LOGFILE): Use YYYY-MM-DD (all numeric) format
- for log file name, since that makes the file names sortable in a
- coherent way. Suffix should always be `level-n' where n is the
- dump level. level-0 script was just using `-full' instead.
-
- * level-0, level-1 (DUMP_LEVEL): New variable. Set to `0' or `1'
- in each script as appropriate.
-
- * level-0, level-1 (HOST): Renamed to `localhost' for clarity.
- (host): renamed to `remotehost' for clarity.
-
- * level-0, level-1 (startdate): New variable. Use it in Subject
- line of mailed report.
-
- * level-0, level-1: Fixed all instances where sed is called with a
- script on the command line to use `-e' option.
-
- * level-0, level-1: Don't try to call logfile.sed to filter
- LOGFILE. It's not distributed with tar and was never really used
- anyway.
-
- * level-0, level-1: Put quotes around most variable names (barring
- those that are known to intentionally contain text that should be
- expanded into multiple words, like `TAR_PART1').
-
- * level-0, level-1: Got rid of annoying trailing backslashes in awk
- scripts. They were gratuitous. Made them a little more readable
- by adding some whitespace.
-
-Wed Mar 17 10:30:58 1993 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * tar.c (describe, long_options): Changed --compress-block to
- --block-compress.
- (options): Fixed f_compress_block sanity check error message
- to give the correct name of the option.
-
-Tue Mar 16 14:52:40 1993 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * extract.c (extract_archive): case LF_DIR: Do chown when
- necessary. Don't bother jumping to set_filestat for
- f_modified; repeat the chmod code here. Replace `break',
- deleted on 2 September 1992.
-
- * tar.c (describe, long_options, options): Added gzip options
- and use-compress-program option.
- * tar.h: Added new compression options.
- * buffer.c (child_open, open_archive): Use new compression options.
-
- * create.c (start_header): Only mask off high bits when
- creating old-style archives.
- * list.c (decode_header): Mask off potentially misleading
- high bits from the mode when reading headers.
-
-Mon Mar 15 11:34:34 1993 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * extract.c (extract_archive): Put arguments in the right
- order for error message.
-
- * create.c (deal_with_sparse): if the last byte was null, we
- didn't write it out.
-
- * gnu.c, create.c, extract.c, diffarch.c, list.c throughout:
- Replace malloc calls with ck_malloc and realloc with ck_realloc.
-
- * tar.c (describe): Improve doc for -L.
-
- * tar.c (name_next): Don't apply exclusion to explicitly named
- files.
-
- * tar.c (long_options, describe): Added new-volume-script as
- an alias for info-script.
-
- * extract.c (extract_archive): LF_DUMPDIR case; misplaced paren.
-
- * extract.c (extract_archive): extract_file case, first if,
- include space for null in namelen computation.
-
- * extract.c (extract_sparse_file): Use value returned by write
- to properly create error message.
-
- * create.c (create_archive): Don't assume we have anything to
- dump.
-
- * buffer.c (open_archive): Set current_file_name for the
- volume header so that verbose listings work properly.
-
- * Makefile.in (realclean): Added getdate.c.
-
-Thu Jan 14 23:38:44 1993 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu)
-
- * tar.c: Include fnmatch.h after port.h to make sure we get our FNM_*
- (e.g. on HPUX 8).
-
-Tue Nov 24 08:30:54 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
-
- * tar.c (addname), gnu.c (read_dir_file): Use HAVE_GETCWD, not USG.
-
- * port.h, rmt.h: Use HAVE_STRING_H, not USG.
-
- * port.h: Add dir header decls.
- * create.c, gnu.c: Use SYSNDIR, SYSDIR, and NDIR
- instead of BSD42 and USG. Rename DP_NAMELEN to NLENGTH.
- Use `struct dirent' instead of `struct direct'.
- * create.c, gnu.c, tar.c: Remove dir header decls.
-
-Wed Nov 18 15:31:30 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
-
- * tar.c: Change FNM_TARPATH to FNM_LEADING_DIR to match change
- in fnmatch.[ch].
-
-Wed Oct 21 00:52:24 1992 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
-
- * level-0, level-1: put curly braces around variables for clarity.
-
- * backup-specs (DUMP_REMIND_SCRIPT): define it (but commented out
- so that distributed dump scripts won't use it by default).
- level-0, level-1 (TAR_PART1): use --info-script if
- DUMP_REMIND_SCRIPT is defined.
- dump-remind: new file (intended as an example).
-
-Thu Oct 15 03:33:28 1992 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
-
- * level-0, level-1: remove $LOGFILE.tmp files before exiting.
-
-Fri Oct 2 00:28:01 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
-
- * tar.c (describe): Fix some tab alignments.
-
- * Makefile.in (SRC3): Add getdate.c, for systems without bison/yacc
- (like MS-DOS).
-
- * diffarch.c (diff_sparse_files): Add missing arg to fprintf calls.
-
- * extract.c (extract_archive, restore_saved_dir_info),
- buffer.c (child_open), list.c (decode_header, print_header):
- Delete unused vars.
-
- * port.c [__MSDOS__]: Have strstr, rename, and mkdir. Don't
- define ck_pipe.
-
- * buffer.c, tar.c (init_volume_number, closeout_volume_number),
- create.c (write_long): Declare as void, not int, since they
- don't return a value.
-
-Thu Sep 24 00:06:02 1992 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu)
-
- * level-0, level-1 (TAR_PART1): remove --atime-preserve
- because of a total screw.
-
-Tue Sep 22 14:15:48 1992 Michael I Bushnell (mib@wookumz.gnu.ai.mit.edu)
-
- * buffer.c (close_archive): Removed leftover `break' from when
- this was a switch.
-
-Tue Sep 22 08:33:16 1992 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
-
- * create.c, port.h: indented #pragma directives with 1 space.
-
-Fri Sep 18 14:15:17 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * All source files: re indented using GNU indent.
-
- * rtapelib.c (__rmt_read): Only read the amount left in the
- buffer; otherwise a broken rmt server (which puts too much
- data out) could overwrite past our buffer.
-
-Thu Sep 17 14:08:58 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * create.c: Throughout, use struct utimbuf rather than array
- of longs.
-
- * configure.in: Check for getpwuid and getgrgid.
-
- * Makefile.in (SRC3, AUX): Move alloca.c to SRC3.
- (OBJ3): Add @ALLOCA@.
-
- * Makefile.in (getdate.c): Look in srcdir for getdate.y.
-
- * buffer.c (close_archive): We can't check WTERMSIG
- meaningfully unless we already know tha WIFSIGNALED is true.
- (There is no guarantee it WTERMSIG will return zero when
- WIFSIGNALED is false.)
- * port.c (rmdir, mkdir): Check WIFSIGNALED rather than
- WTERMSIG.
-
- * Makefile.in (getdate.c): Use $(YACC) instead of `yacc'.
-
-Tue Sep 15 14:49:48 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * version.c: Released version 1.11.1.
-
- * Makefile (AUX): Added NEWS.
-
- * Makefile.in (rmt): Added $(LIBS).
- * configure.in: Added tests for libraries needed on Solaris.
-
- * mangle.c (extract_mangle): Null terminate link name for
- losing archives missing it.
-
- * Makefile.in: added target and rule for getdate.c: getdate.y;
- some makes don't have one built in.
-
-Mon Sep 14 16:23:15 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * tar.c (options, main): Advise use of --help rather than
- +help.
-
- * create.c (write_long): Using hstat here is a Bad Idea, and
- totally unnecessary at that.
-
- * list.c (read_header): Compute both signed and normal
- checksums.
-
- * configure.in: Define BSD in the presence of /sdmach or
- /../../mach.
-
- * diffarch.c, buffer.c: Declare valloc as void* rather than
- char*.
-
- * Makefile.in: Don't install info files.
-
- * configure.in: Check for malloc was scrambled.
-
- * port.h: Undefine index and rindex if necessary; some
- string.h's define them for us.
-
- * tar.c (addname): Missing braces after if.
- * gnu.c (read_dir_file): Missing braces after if.
-
- * names.c: Add include of <stdio.h>,
-
- * create.c (start_header): Set current_file_name so that
- print_header (used for verbose create) works properly.
- (dump_file): Set current_link_name when setting up symlink
- and hardlink records.
-
-Fri Sep 11 01:05:52 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
-
- * fnmatch.[ch]: New files.
- * wildmat.c: File removed.
- * tar.c: Include fnmatch.h and use fnmatch instead of wildmat.
- * Makefile.in, makefile.pc: Replace wildmat.o(bj) with fnmatch.
-
-Thu Sep 10 23:19:30 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
-
- * buffer.c, tar.c: Remove redundant decls of getenv, rindex.
-
- * Makefile.in: Add uninstall target.
- Define libdir instead of hardcoding /etc for installing rmt.
-
-Thu Sep 10 13:06:03 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * list.c (read_header): On second thought, that doesn't work
- either, so just store the names in malloced areas. Sigh.
-
- * NEWS: New file.
- * README: Removed things that belong in NEWS; point to it.
-
- * list.c (read_header): current_file_name and
- current_link_name need to be set to the arrays in head rather
- than header; header is the actual read buffer and will change.
-
- * extract.c (extract_archive):
- * buffer.c (new_volume): `#' directives need to start in
- column 1.
-
-Thu Sep 10 06:09:18 1992 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
-
- * level-0, level-1 (TAR_PART1): put --atime-preserve inside quotes.
-
-Wed Sep 9 13:34:26 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * Makefile.in (AUX): Add getpagesize.h.
- (AUX): Comment out manuals.
- (all): Comment out dependency on tar.info.
-
- * version.c: Release of version 1.11.
-
- * level-0, level-1 (TAR_PART1): Use --atime-preserve.
-
- * Makefile, configure.in: Arrange to use local malloc on HP-UX.
-
- * port.h Use the canonical Autoconf chunk for alloca instead
- of just looking for gcc.
-
-Wed Sep 9 03:16:58 1992 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
-
- * port.h: If compiling with gcc, use __builtin_alloca.
-
-Tue Sep 8 16:13:41 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * extract.c: Removed long name support from here.
- * list.c (read_header): Understand and skip longname/longlink
- headers here. Names for current file are stored in new global
- variables. All source files except create.c changed to refer
- to current_file_name and current_link_name instead of fields
- directly from the current header.
-
-Thu Sep 3 12:41:08 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * create.c (write_long): New function.
- (dump_file): When writing link records or symlink records, use
- new write_long function instead of mangling when the link
- target is too long.
- (start_header): Use write_long instead of mangling for long
- names.
- * extract.c (saverec): Recognize LF_LONGNAME and LF_LONGLINK.
- (saverec): Throughout, use longname and longlink if they are set.
-
-Wed Sep 2 14:41:13 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * mangle.c: This is now deprecated; retain extract_mangle for
- backward compatability.
-
- * list.c (print_header): patch from Chris Arthur to prevent
- printing 0 when the gid or uid is null.
-
- * list.c (decode_header): patch from Chris Arthur to use the
- gid field when the gid is empty, and similarly for uid.
-
- * extract.c: saved_dir_info, saved_dir_info_head: new type and
- var.
- (extract_archive): When extracting directories, now save info
- in saved_dir_info_head.
- (restore_saved_dir_info): New function.
- * list.c (read_and): Call restore_saved_dir_info at the end of
- the run.
- This patch is from Chris Arthur (csa@pennies.sw.stratus.com).
-
-Mon Aug 31 15:39:55 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * create.c (create_archive): If there are no names specified,
- write nothing on the archive instead of dumping ".".
-
- * buffer.c (open_archive): Useful error message.
-
- * tar.c, tar.h: Recognize f_atime_preserve.
- * create.c (dump_file): Implement f_atime_preserve.
-
- * rmt.h (_remdev): Don't require /dev/ to be in remote archive
- names; obey new force-local flag.
- * tar.c, tar.h: Implement new force-local flag.
-
- * tar.c (describe): same-owner and same-order were confused.
-
- * create.c (dump_file): Check for toplevel had sense reversed.
-
- * buffer.c (new_archive): Don't free old_name...when these
- come from the command line, they aren't malloced, and it isn't
- important to save this trivial amount of memory.
-
- * tar.h: replace ar_file with ar_files, n_ar_files,
- cur_ar_files.
- * buffer.c (open_archive): multi-volume compressed archives
- never worked; give an appropriate error. Change open of
- ar_file to open of ar_files[0].
- (writeerror, readerror, flush_archive): use
- ar_files[cur_ar_file] instead of ar_file.
- (new_archive): Necessary changes to support ar_files.
- * tar.c (options): handle multiple tape drive arguments.
-
-Fri Aug 28 17:42:13 1992 Michael I Bushnell (mib@wookumz.gnu.ai.mit.edu)
-
- * list.c (decode_header), create.c (start_header), tar.h (TMAGIC):
- Undo djm's changes below; tar does not support the final
- Posix.1 format; it's bad to make it look like it does.
-
-Sun Jul 19 02:13:46 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
-
- * port.h: Try to prevent redefining major.
- * port.c: HAVE_BZERO -> minix. Fix a typo.
-
- * list.c (decode_header): Recognize the final POSIX.1 magic as
- well as the early draft magic for ustar.
- * create.c (start_header): Create a final POSIX.1 magic string
- instead of an early draft string for ustar.
- * tar.h (TMAGIC): Remove the trailing blanks.
-
- * rmt.c, rtapelib.c: Use POSIX and STDC headers if available.
- * rmt.h: Declare the external functions defined in rtapelib.c.
-
-Tue Jul 14 00:44:37 1992 David J. MacKenzie (djm@apple-gunkies.gnu.ai.mit.edu)
-
- * pathmax.h: New file.
- * port.h: Include it.
- * create.c (create_archive): Allocate PATH_MAX instead of
- NAME_MAX for temporary buffer so we don't have to figure out
- what NAME_MAX is (portably).
-
-Fri Jul 10 08:30:42 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * gnu.c (collect_and_sort_names): write_dir_file has no argument.
-
- * level-0, level-1: Avoid silly Sun awk lossage.
-
-Mon Jul 6 20:11:32 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
-
- * port.c (rename): If unlinking the source at the end fails,
- unlink the destination instead to avoid leaving a mess.
-
-Fri Jul 3 15:16:42 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
-
- * buffer.c, diffarch.c, update.c, rtapelib.c: Change NO_MTIO to
- HAVE_SYS_MTIO_H.
-
- * port.c, tar.h: Change FOO_MISSING to HAVE_FOO.
-
-Tue Jun 23 23:39:02 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
-
- * rmt.c: Add #ifdefs to work on ISC.
-
-Wed May 20 00:12:27 1992 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu)
-
- * port.h: Define major, minor, makedev if the system doesn't.
-
-Wed May 13 21:16:38 1992 Michael I Bushnell (mib@apple-gunkies.gnu.ai.mit.edu)
-
- * gnu.c (add_dir_name): Store legitimate value into
- dir_contents when get_dir_contents returns NULL.
-
-Thu May 7 23:44:35 1992 Michael I Bushnell (mib@apple-gunkies.gnu.ai.mit.edu)
-
- * gnu.c (add_dir_name): Check for return of NULL from get_dir_contents;
- see djm's change of Fri Jul 26 01:12:58 1991.
-
-Mon May 4 22:50:57 1992 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu)
-
- * tar.h: Make comments for option names say -- instead of +.
-
-Thu Apr 30 03:09:16 1992 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
-
- * level-1: Added `$' before VOLNO_FILE in definition of TAR_PART1.
- Added line to remove $VOLNO_FILE from any previous dump before
- starting.
-
- * level-0, level-1: Change long options to use `--' instead of `+'
- (support for `+' will go away soon)
-
-Wed Apr 29 14:23:10 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * tar.c, tar.t: Added +volno-file option.
- buffer.c: New functions init_volume_number,
- closeout_volume_number.
- tar.c (main): Call new functions in the right place.
-
- * buffer.c (fl_write, fl_read): Mod to allow losing tape
- drives which use short counts to indicate end of tape
- correctly handle the multi-tape stuff. The read half won't
- co-exist with f_reblock; there's no way to fix that, of
- course.
-
- * tar.c, tar.h: Added new option +show-omitted-dirs, from
- Karl Berry.
- list.c (read_and): Implemented show-omitted-dirs.
-
- * tar.c, tar.h: Added new option +checkpoint.
- buffer.c (fl_read, fl_write): Implemented +checkpoint lazily.
-
- * create.c (dump_file): Added toplevel argument; some devices
- can be negative, so the old method was bogus. All callers
- changed.
-
- * tar.c, tar.h: Added new option +ignore-failed-read.
- create.c (dump_file): Implemented +ignore-failed-read.
-
- * create.c (finish_sparse_file): Commented out debugging printf.
-
- * tar.c, tar.h: Added new option +remove-files to delete files
- after they are added to the archive.
- create.c (dump_file): Implemented +remove-files for
- everything but directories. I don't think they need it.
-
-Tue Apr 28 13:21:42 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * create.c: (dump_file): save_name needs to be set equal to p,
- not something inside the header, because the header changes at
- the first buffer flush.
-
-Fri Apr 24 10:41:13 1992 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * create.c: Djm incorrectly moved the include of port.h to
- precede the include of sys/file.h; restored.
-
- * tar.c (main): Cases CMD_EXTRACT and CMD_LIST: declare error
- string with const.
-
- * gnu.c (collect_and_sort_names): Leave if around
- write_dir_file in place.
-
-Wed Apr 22 02:16:14 1992 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu)
-
- * rtapelib.c: SIGTYPE -> RETSIGTYPE.
-
-Mon Mar 9 22:42:05 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
-
- * rtapelib.c: Reformat and make comments more complete.
- Rename a few variables for clarity.
-
-Thu Mar 5 14:07:34 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
-
- * tar.c (describe): Document long options as starting with --.
-
-Thu Jan 23 22:54:41 1992 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * tar.c (options): Check get_date return value for error indication.
-
-Tue Dec 24 00:03:03 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * tar.c, gnu.c, extract.c, create.c, port.h, rmt.h: Change
- POSIX ifdefs to HAVE_UNISTD_H and _POSIX_VERSION.
-
-Fri Dec 20 13:50:38 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * testpad.c (main): flush stderr so perror and fprintf
- cooperate right.
-
-Wed Dec 18 16:52:42 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * port.h: Check MAJOR_IN_MKDEV and MAJOR_IN_SYSMACROS to find
- where to get major, minor and makedev.
- * create.c, list.c, update.c: Don't check USG to include
- sys/sysmacros.h.
-
-Thu Dec 12 21:57:10 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * mangle.c (extract_mangle): Correctly null terminate name of
- link target.
-
-Thu Nov 21 07:44:18 1991 Michael I Bushnell (mib at nutrimat)
-
- * create.c (dump_file, at start of ISREG output loop): use
- filename from header instead of real name to make sure that we
- get the mangled version and not one that is too long and
- overflows buffers.
-
-Sat Nov 16 01:37:45 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * tar.h: Use new criteria for STDC version of msg.
-
-Sat Nov 2 21:31:57 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * create.c, gnu.c, tar.c: Use DIRENT instead of NDIR to select
- between dirent.h and ndir.h for USG.
-
- * port.c: Rename WANT_FOO to FOO_MISSING to make sharing code
- and configure script with other utilities easier. Use
- VPRINTF_MISSING and DOPRNT_MISSING instead of FOO_MSG to
- select error reporting routines.
-
-Thu Oct 17 20:19:02 1991 Michael I Bushnell (mib at churchy.gnu.ai.mit.edu)
-
- * level-0: Repair damage from previous mod: stdin to rsh must
- be the terminal or tar's questions lose.
-
-Sat Aug 31 15:05:27 1991 Noah Friedman (friedman at nutrimat.gnu.ai.mit.edu)
-
- * level-0: Fixed several syntax errors associated with
- stdout/stderr redirection.
- Made sure remote host executes commands from sh where redirection
- is necessary, since root's shell might be csh in some places and
- the redirect syntax differs.
-
-Thu Aug 29 00:54:01 1991 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * tar.c (long_options). Fixed info-script long option.
-
-Mon Aug 26 16:53:50 1991 David J. MacKenzie (djm at pogo.gnu.ai.mit.edu)
-
- * configure, Makefile.in: Only put $< in Makefiles if VPATH
- is being used, because older makes don't understand it.
-
-Mon Aug 19 01:47:57 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * create.c: Indent '#pragma alloca' so non-ANSI compilers
- don't choke on it.
-
-Wed Aug 14 14:10:43 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu)
-
- * list.c (UGSWIDTH): Increase from 11 (sort of like Unix tar) to
- 18, so that with normal user and group names of <= 8 chars,
- the columns never shift in a tar -t listing.
-
-Fri Aug 2 00:41:08 1991 David J. MacKenzie (djm at apple-gunkies)
-
- * Makefile.in (dist): Include texinfo.tex and tar.info*.
- (install): Install tar.info*.
- * configure: Set INSTALLDATA.
-
- * configure: Create config.status. Remove it and Makefile if
- interrupted while creating them.
-
- * configure: Check for +srcdir etc. arg and look for
- Makefile.in in that directory. Set VPATH if srcdir is not `.'.
- * Makefile.in: Add `prefix'.
- (tar.info): New target.
-
-Tue Jul 30 17:08:04 1991 David J. MacKenzie (djm at apple-gunkies)
-
- * configure: NEED_TZSET has become FTIME_MISSING.
-
-Mon Jul 29 19:23:10 1991 David J. MacKenzie (djm at wombat.gnu.ai.mit.edu)
-
- * port.c [F_CHSIZE]: Additional version.
-
-Sat Jul 27 22:27:47 1991 David J. MacKenzie (djm at wombat.gnu.ai.mit.edu)
-
- * rmt.h: Clean up ifdefs.
-
- * makefile.pc: Fix typo.
- port.h: Change MSDOS to __MSDOS__.
- [__MSDOS__]: Define off_t. Include io.h and not sys/param.h.
- [__TURBOC__]: Use void * and don't define const.
-
-Fri Jul 26 01:12:58 1991 David J. MacKenzie (djm at bleen)
-
- * buffer.c: Rename `eof' to `hit_eof' to avoid conflict with an
- MSDOS function.
- * gnu.c (get_dir_contents): Return NULL, not "\0\0\0\0", on error.
- * diffarch.c (diff_archive): Open files in binary mode.
- Don't use or free a non-malloc'd return value from get_dir_contents.
- * msd_dir.c [__TURBOC__]: Include stdlib.h.
- * rmt.h: lseek returns off_t, not long.
-
- * tar.c (describe): -X is +exclude-from, not +exclude.
- (names_notfound): Free memory only if amiga, not !unix.
-
- * tar.h, tar.c: Add +null option to make -T read
- null-terminated filenames (such as those produced by GNU find
- -print0), and disable -C option.
- This guarantees that odd filenames will get archived.
- * tar.c (read_name_from_file): New function.
- (name_next): Call it instead of fgets.
-
-Wed Jul 24 11:17:48 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * create.c [_AIX]: Declare alloca.
-
- * buffer.c (open_archive): Check for successful open before,
- not after, fstatting the fd.
-
-Tue Jul 23 20:51:31 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * configure: Only define BSD42 if sys/file.h exists.
- If alloca is missing and /usr/ucblib exists (SVR4), use it
- instead of -lPW.
-
- * port.h [!__STDC__]: #define const.
- * gnu.c (dirent_cmp): Fix args to agree with ANSI C prototype.
- * create.c: Declare ck_realloc.
- * gnu.c, diffarch.c: Move check for symlinks to after port.h include.
-
-Sat Jul 20 00:03:54 1991 David J. MacKenzie (djm at apple-gunkies)
-
- * msd_dir.[ch]: Use POSIX-style `struct dirent' instead of
- `struct direct'.
- * create.c, gnu.c, tar.c: Adjust callers.
-
-Thu Jul 18 00:05:01 1991 David J. MacKenzie (djm at bleen)
-
- * port.c (ck_malloc, ck_realloc): Return PTR, not char *.
- * gnu.c, create.c, tar.c: Fix decls.
-
- * port.c: Don't use the preprocessor to guess missing
- functions on Unix; let configure do it.
- [WANT_GETWD] (getwd): Function removed; not needed because
- getcwd is used if needed.
- * gnu.c, tar.c: Use getcwd if POSIX.
-
- * rtapelib.c: Use SIGTYPE instead of testing SIGNAL_VOID.
- Default to void (more common these days) instead of int.
-
- * tar.c, gnu.c, mangle.c: Remove VOIDSTAR defn. Use PTR instead.
- * port.h: Define PTR.
-
- * gnu.c, tar.c [__MSDOS__ || USG]: Remove incorrect getcwd
- decl; put correct one in port.h [!POSIX].
-
- * tar.c (describe): Print on stdout instead of stderr; it's
- not so much a usage message (since you have to ask for it
- explicitly) as on-line help, and you really need to be able to
- page it because it's more than a screen long.
-
- * Make #ifdefs for sys/file.h or fcntl.h, directory header,
- sys/mtio.h consistent between files. Use NO_MTIO instead of
- tricks with USG and HAVE_MTIO and NO_RMTIOCTL.
- * Move decls of ANSI C and POSIX functions to port.h and
- use standard headers to declare them if available
- [STDC_HEADERS or POSIX].
- * Add many missing function declarations and return types.
- * Some places used __MSDOS__, some MSDOS; standardize on __MSDOS__.
- * Change S_IF macros to S_IS for POSIX.
- * port.h: Define appropriate S_IS macros if missing.
- * port.h: Rename macros for testing exit status to conform to
- POSIX; use the system's versions if available [POSIX].
- * Use POSIX PATH_MAX and NAME_MAX instead of MAXPATHLEN and MAXNAMLEN.
- * port.h: Define PATH_MAX and NAME_MAX.
- * create.c, gnu.c, tar.c: Use ck_malloc and free instead of
- auto arrays of size PATH_MAX or NAME_MAX, since with pathconf
- they might not be constants.
- * Move all definitions of O_* to port.h to reduce redundancy.
- * Make all source files that now need to include port.h do so.
- * port.c: Remove #undefs of WANT_* so you can use -DWANT_*
- when compiling, instead of having to edit port.c.
- [WANT_DUMB_GET_DATE] (get_date): Function removed.
- Even systems without bison can get bison output and compile it.
- [WANT_STRING] (index, rindex, bcopy, bzero, bcmp): Functions
- removed; the translation is now done by macros in port.h.
- * wildmat.c (wildmat): Use POSIX.2 '!' instead of '^' to negate
- character classes.
-
-Mon Jul 15 13:47:45 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * testpad.c (main): Return type void.
-
- * port.c [WANT_STRING]: Don't include memory.h if NO_MEMORY_H.
-
- * create.c (dump_file) [AIX]: Fix typo, `allocate' for `alloca'.
- * gnu.c (collect_and_sort_names): Move misplaced brace out of #ifdef.
- From: Minh Tran-Le <TRANLE@intellicorp.com>.
-
- * configure: Also look in sys/signal.h for signal decl.
-
-Wed Jul 10 01:42:55 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * Rename rtape_server.c to rmt.c and rtape_lib.c to rtapelib.c.
-
- * configure, Makefile.in: $(INSTALLPROG) -> $(INSTALL).
-
-Tue Jul 9 01:38:37 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
-
- * Most files: Refer to GPL version 2.
- * COPYING: Use version 2.
-
- * port.c [__TURBOC__] (utime): New function.
-
- * xmalloc: New function (just calls ck_malloc), for alloca.c
- and bison.simple (in getdate.y output).
-
- * Makefile.in (AUX): Include alloca.c and tcexparg.c, a
- command line globber for Turbo C.
-
-Mon Jul 8 14:30:52 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu)
-
- * testpad.c: Open and write to testpad.h instead of stdout,
- because some MS-DOS makes (Borland's at least) can't do
- redirection in commands.
- * Makefile.in: Don't redirect testpad output.
-
-Mon Jul 8 12:56:35 1991 Michael I Bushnell (mib at churchy.gnu.ai.mit.edu)
-
- * buffer.c (fl_read): Missing \n in printf.
-
-Mon Jul 8 03:40:28 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu)
-
- * create.c, extract.c, gnu.c, diffarch.c, tar.c: Comment out
- unused variables.
-
- * tar.c (options): Cast get_date arg to VOIDSTAR instead of
- `struct timeb *', since on some non-BSD systems the latter is
- undefined.
-
-Sat Jul 6 04:53:14 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu)
-
- * Replace Makefile with configure, Makefile.in, and makefile.pc.
- Update README with current compilation instructions.
-
- * port.c [WANT_RENAME] (rename): New function.
-
-Wed Jul 3 18:10:52 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * testpad.c (main): Avoid warning from some compilers on array
- address.
-
- * rtape_server.c (sys_errlist): Should be declared extern.
-
-Mon Jul 1 14:14:06 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * Release of version 1.10; appropriate changes to README.
-
- * create.c: Removed printf's about sparse files.
-
- * Fix a misplaced quote in level-0 and change some >& into
- 2>&1.
-
-Fri Jun 21 23:04:31 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * list.c (skip_extended_headers): Userec was being called in
- the wrong place.
-
-Thu Jun 20 19:10:35 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu)
-
- * tar.h: Use ANSI prototypes for msg and msg_perror if
- STDC_MSG is defined, even if BSD42 is also.
-
- * Makefile: Replace DESTDIR with bindir.
- (install): Don't install tar.texinfo. There's no standard
- place for texinfo files, and /usr/local/man is inappropriate.
- Add TAGS, distclean, and realclean targets and SHELL= line.
-
- * version.c: Move old change history to bottom of ChangeLog.
-
-Wed Jun 12 12:43:58 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * rtape_lib.c (__rmt_write): #ifdef should reference
- SIGNAL_VOID, not USG.
-
-Wed Jun 5 14:57:11 1991 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * tar.c (name_match, addname): Ugly hack to handle -C without
- any files specified.
- tar.h (struct name): New field for ugly hack.
-
-Mon Jun 3 14:46:46 1991 Michael I Bushnell (mib@geech.gnu.ai.mit.edu)
-
- * testpad.c: New file to determine if we need special padding
- in struct header in tar.h.
-
- * tar.h (struct header): include padding if necessary, include
- testpad.h.
-
- * Makefile: rules to create testpad.h, etc.
-
-Wed May 22 16:02:35 1991 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu)
-
- * tar.c (options): -L takes an argument.
-
- * rtape_lib.c (__rmt_open): add /usr/bin/nsh to the list of
- remote shell programs.
-
- * create.c: define MAXPATHLEN if we don't get it from a system
- header file.
-
- * create.c (deal_with_sparse): return a real return value if
- we can't open the file.
-
- * tar.c (long_options): +newer takes an argument.
- (describe): fix printing in various trivial ways
-
-Tue May 21 17:15:19 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * tar.c (long_options): +get and +concatentate don't require arguments
-
-Mon May 20 15:55:30 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * create.c (write_eot): Don't try and write an EOF if we are
- already at one.
-
- * port.c (strstr): Looking for null string should return zero.
-
-Sun May 19 22:30:10 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * tar.c (options): -l doesn't take an argument
-
- * Makefile: minor fix for SGI 4D defines from torda@scum.ethz.ch
-
- * rtape_server.c (main.c): Suggested mod for 386/AIX from
- Minh Tran-Le. I'm suspicious about this one.
-
- * create.c (dump_file): Mods from Minh Tran-Le for hidden
- files on AIX.
- gnu.c (collect_and_sort_name, get_dir_contents): AIX hidden file mod.
-
- * tar.c: (name_next): Mod from David Taylor to allow -C inside
- a file list given to -T.
-
- * Makefile: Comment describing presence of USE_REXEC.
-
- * extract.c (extract_archive, case LF_SPARSE): zero check for
- last element on numbytes needs to look at value after
- converted from octal.
-
- * port.c: Don't always demand strstr, check for HAVE_STRSTR
- instead.
- Makefile: Comment describing presence of HAVE_STRSTR option.
-
-Sun May 19 18:39:48 1991 David J. MacKenzie (djm at churchy.gnu.ai.mit.edu)
-
- * port.c (get_date): Renamed from getdate, to avoid SVR4 conflict.
- * tar.c: Call get_date instead of getdate.
-
-Fri May 10 02:58:17 1991 Noah Friedman (friedman at nutrimat)
-
- * tar.c: added "\n\" to the end of some documentation strings
- where they were left off.
-
-Thu May 9 17:28:54 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * Makefile: added level-0, level-1, and backup-specs to AUX.
- * version.c: changed to 1.10 beta.
- * README: updated for 1.10 beta release.
-
-Tue Apr 2 12:04:54 1991 Michael I Bushnell (mib at godwin)
-
- * create.c (dump_file): HPUX's st_blocks is in 1024 byte units
- instead of 512 like the rest of the world, so I special cased
- it.
- * tar.c: Undo Noah's changes.
-
-Mon Apr 1 17:49:28 1991 Noah Friedman (friedman at wookumz.gnu.ai.mit.edu)
-
- (This ought to be temporary until things are fixed properly. )
-
- * tar.c: (struct option long_options): flag for "sparse" zero if
- compiling under hpux.
- tar.c: (functon options): case 'S' is a no-op if compiling under
- hpux.
-
-Sat Mar 30 12:20:41 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * tar.h: new variable tape_length.
-
- * tar.c (options): add new option +tape-length / -L.
-
- * buffer.c (fl_write): Turn #ifdef TEST code for limited tape
- length on always, for tape-length option.
-
- * create.c (dump_file): avoid apollo lossage where S_IFIFO == S_IFSOCK.
-
- * buffer.c: include regex.h
- * buffer.c (fl_read, open_archive): Use regex routines for
- volume header match.
- * xmalloc.c: removed file; wasn't necessary.
- * tar.c: (main) use ck_malloc instead of xmalloc.
-
-Thu Mar 28 04:05:05 1991 Noah Friedman (friedman at goldman)
-
- * regex.c, regex.o: New links.
- * tar.c: include regex.h.
- * Makefile (OBJ2): Add regex.o.
- (regex.o, tar.o): Depend on regex.h
- (SRC2, AUX): Add the new files.
-
-Sat Mar 23 15:39:42 1991 Noah Friedman (friedman at wookumz.gnu.ai.mit.edu)
-
- * Makefile: added default flags and options for compiling under
- hpux.
-
- * Added files alloca.c and xmalloc.c
-
-Sat Mar 23 14:35:31 1991 Michael I Bushnell (mib at geech.gnu.ai.mit.edu)
-
- * port.c: Define WANT_VALLOC in HPUX.
-
-Fri Mar 15 06:20:15 1991 David J. MacKenzie (djm at geech.ai.mit.edu)
-
- * rtape_lib.c: If USG and not HAVE_MTIO, define NO_RMTIOCTL
- automatically.
- (_rmt_rexec): Temporarily re-open stdin and stdout to
- /dev/tty, to guarantee that rexec() can prompt and read the
- login name and password from the user.
- From pascal@cnam.cnam.fr (Pascal Meheut).
- * Makefile: Mention -DUSE_REXEC.
-
-Fri Mar 8 20:15:11 1991 Michael I Bushnell (mib at wookumz.ai.mit.edu)
-
- * tar.h, Makefile: Makefile CPP macro HAVE_SIZE_T might be
- useful for some people.
-
- * gnu.c: lstat->stat define where appropriate
-
- * buffer.c (fl_write): keep track of amount written for +totals.
- * tar.c, tar.h: set flag f_totals from +totals option
- * tar.h (f_totals, tot_written): new variables
- * tar.c (main): print total written with CMD_CREATE
-
- * tar.c (main): return appropriate exit status
-
-Thu Jan 17 00:50:21 1991 David J. MacKenzie (djm at apple-gunkies)
-
- * port.c: Remove a spurious `+' between functions (a remnant
- of a context diff, apparently).
-
-Wed Jan 9 19:43:59 1991 Michael I Bushnell (mib at pogo.ai.mit.edu)
-
- * create.c (where_is_data): Rewritten to be better, and then
- #ifdef-ed out.
- (deal_with_sparse): Severly pruned. Now we write or don't
- write only complete blocks, not worrying about partial blocks.
- This simplifies calculations, removes bugs, and elides the
- second scan through the block. The first was zero_record, the
- second was where_is_data.
-
-Mon Jan 7 17:13:29 1991 Michael I Bushnell (mib at wookumz.ai.mit.edu)
-
- * create.c (deal_with_sparse): Second computation (for short
- reads) of numbytes increment had subtraction backwards.
- Need to handle calling where_is_data better when we did a
- short read (it might go past the end of the read), also, set
- sparsearray[...].offset in this case too.
-
-Fri Jan 4 12:24:38 EST 1991 Jay Fenlason (hack@ai.mit.edu)
-
- * buffer.c Return a special error code if the archive you're
- trying to read starts with a different label than the one specified
- on the command line.
-
-Wed Jan 2 12:05:21 EST 1991 Jay Fenlason (hack@ai.mit.edu)
-
- * gnu.c Prepend the current directory to the gnu_dumpfile, so that
- -C's won't affect where the output goes. (sigh.)
-
-Tue Dec 18 18:05:59 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * (gnu.c) Don't complain if the gnudumpfile we're reading info
- from doesn't exist.
-
- * create.c Write out gnudumpfile after finishing writing the archive.
-
- * tar.c Add +exclude FNAME, and make +exclude-from do what +exclude
- used to.
-
- Make +version an operation, not an option.
-
- add +confirmation alias for +interactive.
-
-Tue Dec 4 13:28:08 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * tar.c (check_exclude) Don't let MUMBLE match MUMBLE.c or fooMUMBLE
- but only foo/MUMBLE
-
- * Add the name mangler (mangle.c, plus changes to create.c and
- extract.c)
-
- * extract.c Three small patches from Chip Salzenberg
- (tct!chip@uunet.uu.net)
-
- Don't complain when extracting a link, IFF it already exists.
-
- Don't complain when extracting a directory IFF it already
- exists.
-
- Don't ad u+wx to directories when running as root.
-
- * gnu.c Some changes from Chip Salzenberg to make
- +listed-incremental work.
-
- * port.c Add the F_FREESP emulation of the ftruncate syscall.
-
-Wed Nov 21 15:57:07 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- Remove excess \n from lots of msg() calls.
-
-Mon Nov 19 14:09:43 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * tar.c Rename +volume to +label
-
-Fri Nov 16 15:43:44 1990 David J. MacKenzie (djm at apple-gunkies)
-
- * tar.c (describe): Include the default values for -b and -f
- (as set in the Makefile) in the message.
-
-Thu Nov 15 13:36:45 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * extract.c (extract_archive) Do the utime() call before the
- chmod() call, 'cuz some versons of utime() trash the file's mode
- bits.
-
- * list.c (read_and) Call do_something on volume headers and
- multivol files even if they don't match the names we're looking for,
- etc. . .
-
-Tue Nov 6 13:51:46 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * port.c (un-quote-string) Don't try to write a null
- if there's already one there.
-
-Thu Nov 1 14:58:57 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * buffer.c (new_volume) fflush(msg_file) before reading for
- confirmation on new volume. On EOF or error, print error msg and
- abort.
-
-Mon Oct 29 12:06:35 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * getdate.y Use new version of getdate().
-
- * tar.c (name_add) Use sizeof(char *) instead of sizeof(int)
-
- * README give the correct return address.
-
-Thu Oct 25 16:03:58 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- rtape_lib.c Change RMTIOCTL to NO_RMTIOCTL, so it is on by default.
-
- rmt.h Add _isrmt() #define for NO_REMOTE case.
-
- gnu.c Add forward reference for add_dir_name().
-
-Tue Oct 16 11:04:52 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- 1.09 New -G file implementation of gnu-dump stuff.
-
- * tar.c (name_add) Get the calls to ck_realloc and ck_malloc right.
-
-Thu Oct 11 11:23:38 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * gnu.c Fix A couple of typos.
-
-Wed Sep 19 13:35:03 1990 David J. MacKenzie (djm at apple-gunkies)
-
- * getdate.y [USG] (ftime): Use `daylight' unless
- DAYLIGHT_MISSING is defined.
-
-Mon Sep 17 18:04:21 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * gnu.c (gnu_restore) Don't use a passed char* for the
- file name, use skipcrud+head->header.name, just like everything
- else does. This means that gnu_restore will still work with
- small buffers, etc.
-
-Thu Sep 13 15:01:17 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * tar.c (add_exclude) Don't bus-error if the exclude file doesn't
- end with a newline.
-
-Sun Sep 9 22:35:27 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
-
- * Makefile (dist): Remove .fname when done.
-
-Thu Sep 6 12:48:58 EDT 1990 Jay Fenlason (hack@ai.mti.edu)
-
- * gnu.c (gnu_restore) Rember to skip_file() over the directory
- contents, even if we don't have to do anything with them.
-
- * create.c extract.c diffarch.c Free sparsearray after we're done
- with it.
-
-Tue Sep 4 10:18:50 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * Makefile Include gnu.c in dist
-
- * gnu.c move add_dir above read_dir_file so that cc doesn't complain
- about add_dir returning void.
-
-Sun Sep 2 20:46:34 1990 David J. MacKenzie (djm at apple-gunkies)
-
- * getdate.y: Declare some more functions and add storage
- classes where omitted to shut compiler up.
- [USG] (ftime): Don't use extern var `daylight'; appears that
- some systems don't have it.
-
-Wed Aug 29 00:05:06 1990 David J. MacKenzie (djm at apple-gunkies)
-
- * getdate.y (lookup): In the code that allows `Aug.' to be
- recognized as `Aug', don't chop off the final `.' from words
- like `a.m.', so they can be recognized.
-
-Thu Aug 16 11:34:07 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * buffer.c (open_archive) If -O, write verbosity to stderr
- instead of stdout.
-
-Fri Aug 10 12:29:28 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * getdate.y Handle an explicit DST in the input string.
- A dozen line patch from Per Foreby (perf@efd.lth.se).
-
-Mon Jul 16 13:05:11 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * tar.c rename -g -G +incremental, +listed-imcremental, etc.
-
-Fri Jul 13 14:10:33 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * tar.c Make +newer and +newer-mtime work according to their names.
-
- * gnu.c If +newer or +newer-mtime, use the time specified on the
- command line.
-
- * buffer.c, create.c Add test to see if dimwit is trying to
- archive the archive.
-
- * tar.c (long_options[]) re-ordered, so that groups of similar
- options are next to each other. . . I think.
-
- (describe) Modified to more closely reflect reality.
-
-Fri Jul 6 13:13:59 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * tar.c add compile-time option for SYS V (?) style
- tape-drive names /dev/rmt/{n}[lmh]
-
- * tar.c Fix getopt-style stuff so that -C always works correctly.
-
- * gnu.c, tar.c make filename to -G optional.
-
- * {all over}, replace some fprintf(stderr...) calls with calls
- to msg().
-
- * port.c Make -Dmumble_MSG option on command line override
- internal assumptions.
-
- * Makefile Mention -Dmumble_MSG options
-
-Fri Jul 6 02:35:31 1990 David J. MacKenzie (djm at apple-gunkies)
-
- * tar.c (options): Don't change `c' if it is 0, as getopt now
- handles that internally.
-
-Mon Jul 2 15:21:13 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * gnu.c (new file) Moved all the f_gnudump stuff here where we
- can keep track of it easier. Also made -G take a file name where it
- stores the inode information about directories so that we can
- detect moved directores.
-
- * create.c (dump_file) Changed slightly to work with the new
- f_gnudump.
-
- * tar.c Moved the f_gnudump stuff to gnu.c
-
- * tar.c, extract.c added the +do-chown option, which forces tar
- to always try to chown the created files to their original owners.
-
- * version.c New version 1.09
-
-Sun Jun 24 14:26:28 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
-
- * create.c: Change ifdefs for directory library header
- selection to be like the ones in tar.c.
- * Makefile [Xenix]: Link with -ldir to get the dirent.h
- directory library.
-
-Thu Jun 7 03:31:51 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
-
- * Makefile, buffer.c, diffarch.c: Change MTIO symbol to HAVE_MTIO
- because SCO Xenix defines 'MTIO' for an incompatible tape driver
- system in a file included by termio.h.
- * tar.h: Don't define size_t for Xenix.
-
-Tue Jun 5 11:38:00 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * create.c (dump_file) Only print the
- "... is on a different filesystem..." if f_verbose is on.
- also add a case for S_IFSOCK and treat it like a FIFO.
- (Not sure if that's the right thing to do or not, but it's better
- than all those Unknown File Type msgs.)
-
-Thu May 31 19:25:36 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * port.c Use #ifdef sparc instead of #ifdef SPARC since
- the lowercase version is defined, and the uppercase one isn't.
-
-Tue May 22 11:49:18 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * port.c (ck_malloc) if size==0 pretend size=1
- (ck_realloc) if(!ptr) call ck_malloc instead.
-
-Tue May 15 12:05:45 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * diffarch.c (diff_archive) If not f_absolute_paths, and attempt to
- open a file listed in the archive fails, try /filename also. This will
- allow diff to open the wrong file if both /filename and filename exist,
- but there's nothing we can do about that.
-
-Fri May 11 16:17:43 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * Makefile, Descripbe new -DMTIO option.
-
- * buffer.c diffarch.c Change ifdefs slightly, so that
- -DMTIO will include sys/mtio.h even if USG is defined.
- This is for HUPX and similar BSD/USG crossovers.
-
-Tue May 8 13:14:54 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
- * update.c (update_archive) Call reset_eof() when appropriate.
-
- * buffer.c (reset_eof) New function, that turns of EOF flag, and
- re-sets the ar_record and ar_last pointers. This will allow
- 'tar rf non-existant-file' to not core-dump.
-
-Fri May 4 14:05:31 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
-
- * tar.c: Recognize the +sparse option. It was documented, but
- only the short form (-S) was actually recognized.
-
-Tue Apr 17 21:34:14 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * create.c Don't access location 0 if ->dir_contents is null.
-
-Wed Apr 11 17:30:03 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * buffer.c (flush_archive, close_archive, new_volume) Always check
- the return value of rmtclose(), and only give a warning msg if it is
- <0. Some device drivers (including Sun floppy disk, and HP
- streaming tape) return -1 after an IO error (or something like that.)
-
-Fri Mar 23 00:06:30 1990 Jim Kingdon (kingdon at mole.ai.mit.edu)
-
- * tar.c (long_options): Make it so +append +extract +list +update
- +catenate and +delete don't take arguments.
-
-Mon Mar 12 13:33:53 EST 1990
-
- * buffer.c (open_archive, fl_write) Set the mtime of the volume
- header to the current time.
-
-Wed Mar 7 14:10:10 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * buffer.c Fix +compress-block A two character patch from
- Juha Sarlin (juha@tds.kth.se)
- Replace #ifdef __GNU__ with #ifdef __STDC__
- (new_volume) If open of new archive fails, ask again
- (Is probably user error.)
-
- * tar.c Replace #ifdef __GNU__ with #ifdef __STDC__
-
- * port.c Clean up #ifdef and #defines a bit.
- (quote_copy_string) Sometimes the malloc'd buffer
- would be up to two characters too short.
-
- * extract.c (extract_archive) Don't declare ind static.
-
- * create.c (dump_file) Don't declare index_offset static.
-
- * diffarch.c Remove diff_name variable, and always use
- head->header.name, which will always work, unlike diff_name, which
- becomes trash when the next block is read in.
-
-Thu Mar 1 13:43:30 EST 1990 Jay Fenlason (hack@wookumz.ai.mit.edu)
-
- * Makefile Mention the -NO_REMOTE option.
- * port.c Fix typo, and define WANT_FTRUNCATE on i386 machines.
-
-Mon Feb 26 17:44:53 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
-
- * getdate.y: Declare yylex and yyerror as static.
- #define yyparse to getdate_yyparse.
-
-Sun Feb 25 20:47:23 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
-
- * tar.c: Remove +old option, since it is a valid abbreviation of
- +old-archive, which does the same thing.
- (describe): A few small cleanups in message.
-
-Mon Feb 5 14:29:21 EST 1990 Jay Fenlason (hack@wookumz)
-
- * port.c define LOSING_MSG on sparc, since doprnt_msg doesn't work.
- Fix typo in #ifdef WANT_GETWD
-
-Fri Jan 26 16:11:20 EST 1990 Jay Fenlason (hack@wookumz)
-
- 1.08 Sparse file support added. Also various other features.
-
- * diffarch.c (compare_chunk) Include correct arguments in
- a call to fprintf() for an error msg.
- (compare_chunks, compare_dir) First argument is a long, not an int.
-
- * tar.c (options) Use tar variable (argv[0]) as the name to print
- in an error msg, instead of a constant "tar".
- (confirm) Use external variable char TTY_NAME[] for name of file
- to open for confirmation input.
-
- * buffer.c (new_volume) Ditto.
-
- * port.c Add declaration for TTY_NAME[].
-
- * rmt.h Add long declarations for lseek() and __rmt_lseek();
-
-Tue Jan 23 14:06:21 EST 1990 Jay Fenlason (hack@wookumz)
- * tar.c, create.c Create the +newer-mtime option, which is like
- +newer, but only looks for files whose mtime is newer than the
- given date.
-
- * rtape_lib.c Make *both* instances of signal-handler stuff use
- void (*foo)() on USG systems.
-
-Thu Jan 11 14:03:45 EST 1990 Jay Fenlason (hack@wookumz)
-
- * getdate.y Parse European dates of the form YYMMDD.
- In ftime() Init timezone by calling localtime(), and remember that
- timezone is in seconds, but we want timeb->timezone to be in minutes.
- This small patch from Joergen Haegg (jh@aahas.se)
-
- * rtape_lib.c (__rmt_open) Also look for /usr/bsd/rsh.
- Declare signal handler as returning void instead of int if USG is
- defined.
-
- * port.c Declare WANT_GETWD for SGI 4-D IRIS.
-
- * Makefile Include defines for SGI 4D version. There are a simple
- patch from Mike Muuss (mike@brl.mil).
-
- * buffer.c (fl_read) Work properly on broken Ultrix systems where
- read() returns -1 with errno==ENOSPC on end of tape. Correctly go
- on to the next volume if f_multivol.
-
- * list.c (list_archive,print_header) Flush msg_file after printing
- messages.
-
- * port.c Delete unused references to alloca().
- Don't crash if malloc() returns zero in quote_copy_string.
- Flush stderr in msg() and msg_perror().
-
- * tar.c Flush msg_file after printing confirmation msg.
-
-Wed Jan 10 01:58:46 1990 David J. MacKenzie (djm at hobbes.ai.mit.edu)
-
- * tar.c (main): Change -help option and references to it to +help,
- and remove suggestion to run info (which is unreleased, so not
- likely to be of any help).
-
-Tue Jan 9 16:16:00 EST 1990 Jay Fenlason (hack @wookumz)
-
- * create.c (dump_file) Close file descriptor if start_header()
- fails.
- (dump_file) Change test for ./ ness to not think that
- .{any character} is a ./ These are both trivial changes from
- Piercarlo "Peter" Grandi pcg%cs.aber.ac.uk@nsfnet-relay.ac.uk
-
- * diffarch.c (diff_init) Print correct number of bytes in error
- message.
-
-Tue Jan 9 03:19:49 1990 David J. MacKenzie (djm at hobbes.ai.mit.edu)
-
- * Makefile: Add comment at top noting that two source files also
- contain #defines that might need to be changed by hand.
-
- * create.c, diffarch.c, extract.c: Change L_SET to 0 in lseek
- calls, because only BSD defines it.
- * create.c (dump_file): Make sparse file checking code conditional
- on BSD42 because it uses st_blocks, which the other systems lack.
-
-Tue Jan 2 13:35:56 EST 1990 Jay Fenlason (hack@gnu)
-
- * port.c (quote_copy_string) Fix so it doesn't scramble memory if
- the last character is non-printable. A trivial fix from Kian-Tat Lim
- (ktl@wag240.caltech.edu).
-
-Tue Dec 19 11:19:37 1989 Jim Kingdon (kingdon at pogo)
-
- * port.c [BSD42]: Define DOPRNT_MSG.
- tar.h [BSD42]: Do not prototype msg{,_perror}.
-
-Fri Dec 8 11:02:47 EST 1989 Jay Fenlason (hack@gnu)
-
- * create.c (dump_file) Remove typo in msg.
-
-Fri Dec 1 19:26:47 1989 David J. MacKenzie (djm at trix)
-
- * Makefile: Remove comments referring to certain systems lacking
- getopt, since it is now provided always and needed by all systems.
-
- * port.c: Remove copy of getopt.c, as it is now linked in
- separately to always get the current version.
-
- * tar.c: Rename +cat-tars option to +catenate or +concatenate,
- and +local-filesystem to +one-file-system (preferred by rms
- and used in GNU cp for the same purpose).
- (describe): Reflect changes.
-
-Tue Nov 28 04:28:26 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu)
-
- * port.c: Move declaration of alloca into #else /* sparc */
- so it will compile on sparcs.
-
-Mon Nov 27 15:17:08 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu)
-
- * tar.c (options): Remove -version option (replaced by +version).
- (describe): Mention long options.
-
-Sat Nov 25 04:25:23 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu)
-
- * getoldopt.c (getoldopt): Make `opt_index' argument a pointer to
- an int, not char.
-
- * tar.c: Modify long options per rms's suggestions:
- Make preserve-permissions an alias for same-permissions.
- Make preserve-order an alias for same-order.
- Define preserve to mean both of those combined.
- Make old an alias for old-archive.
- Make portability an alias for old-archive, also.
- Rename sym-links to dereference.
- Rename gnudump to incremental.
- Rename filename to file.
- Make compare an alias for diff. Leave diff but prefer compare.
- Rename blocking-factor to block-size.
- Rename chdir to directory.
- Make uncompress an alias for compress.
- Rename confirm to interactive.
- Make get an alias for extract.
- Rename volume-header to volume.
-
- Also make +version an alias for -version.
-
- (options): Shorten code that interprets long options by using
- the equivalent short options' code. This also makes it tons
- easier to change the long options.
-
- (describe): Make usage message more internally consistent
- stylistically.
-
-Mon Nov 20 14:55:39 EST 1989 hack@ai.mit.edu
-
- * list.c (read_and) Call check_exclude() to see if the files
- should be skipped on extract or list.
-
-Thu Nov 9 18:59:32 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * buffer.c (fl_read): Fix typos in error message
- "tar EOF not on block boundary".
-
-Mon Oct 23 13:09:40 EDT 1989 (hack@ai.mit.edu)
-
- * tar.c (long_options[]) Add an option for blocked compression.
-
-Thu Oct 19 13:38:16 EDT 1989 (hack@ai.mit.edu)
-
- * buffer.c (writeerror) Print a more useful error msg.
-
-Wed Sep 27 18:33:41 EDT 1989 (hack@ai.mit.edu)
-
- * tar.c (main) Mention "tar -help" if the luser types a non-workable
- set of options.
-
-Mon Sep 11 15:03:29 EDT 1989 (hack@ai.mit.edu)
-
- * tar.c (options) Have -F correctly set info_script.
-
-Tue Aug 29 12:58:06 EDT 1989 (hack@ai.mit.edu)
-
- * Makefile Include ChangeLog in tar.tar and tar.tar.Z
-
-Mon Aug 28 17:42:24 EDT 1989 (hack@ai.mit.edu)
-
- * tar.c (options) Made -F imply -M
- Also remind tar that the -f option takes an argument!
-
- * Modified -F option to make it do what (I think) it
- should. e.g, if you say -F, tar won't send a msg to
- msg_file and wait for a <return> It'll just run the program
- it was given, and when the prog returns, the new tape had
- *better* be ready. . .
-
- * buffer.c (open_archive) Give error message and abort if
- the luser didn't give an archive name.
-
-Fri Aug 25 20:05:27 EDT 1989 Joy Kendall (jak at hobbes)
-
- * Added code to make a new option to run a specified script
- at the end of each tape in a multi-volume backup. Changed:
- tar.c: made new switch, -F, and new long-named option,
- "info-script". Code is where you would expect.
- tar.h: added flag f_run_script_at_end, and an extern char *
- called info_script, which optarg gets set to.
- buffer.c: line 1158 in new_volume(): if f_run_script_at_end
- is set, we give info_script to system(), otherwise we do
- what we've always done. **FIXME** I'm not sure if that's all
- that has to be done here.
-
-Thu Aug 24 10:09:38 EDT 1989 Joy Kendall (jak at spiff)
-(These changes made over the course of 6/89 - 8/89)
-
- * diffarch.c: diff_archive: Added switches for LF_SPARSE in the
- case statements that needed it. Also, skip any extended headers
- if we need to when we skip over a file. (need to change
- the bit about, if the size doesn't agree AND the file is NOT
- sparse, then there's a discrepancy, because I added another
- field to the header which should be able to deal with the
- sizes) If the file is sparse, call the added routine
- "diff_sparse_files" to compare. Also added routine
- "fill_in_sparse_array".
-
- * extract.c: extract_archive: added the switch LF_SPARSE
- to the case statement as needed, and code to treat the
- sparse file. At label "again_file", modified opening the
- file to see if we should have O_APPEND be one of the modes.
- Added code at label "extract_file" to call the new routine
- "extract_sparse_file" when we have an LF_SPARSE flag.
-
- Note: really should erase the commented-out code in there,
- because it's confusing.
-
- * update.c: made sure that if a file needed to be "skipped"
- over, it would check to see if the linkflag was sparse, and
- if so, would then make sure to skip over any "extended
- headers" that might come after the header itself. Do so by
- calling "skip_extended_headers".
-
- * create.c: create_archive: added code to detect a sparse
- file when in the long case statement. Added ways to detect
- extended headers, and label "extend" (ack! should get rid of
- that, is atrocious). Call the new routine "finish_sparse_file"
- if the linkflag is LF_SPARSE to write the info to the tape.
- Also added routines "init_sparsearray", "deal_with_sparse",
- "clear_buffer", "where_is_data", "zero_record", and
- "find_new_file_size".
-
- * tar.h: Added the #define's SPARSE_EXT_HDR and
- SPARSE_IN_HDR. Added the struct sparse and the struct
- sp_array. Added the linkflag LF_SPARSE. Changed the tar
- header in several ways:
- - added an array of struct sparse's SPARSE_IN_HDR long
- - added a char flag isextended
- - added a char string realsize to store the true
- size of a sparse file
- Added another choice to the union record called a
- struct extended_header, which is an array of 21 struct
- sparse's and a char isextended flag. Added flag
- f_sparse_file to list of flags.
-
- * tar.c: added long-named options to make tar compatible with
- getopt_long, changed Makefile.
-
-... ... .. ..:..:.. ... .... Jay Fenlason (hack@ai.mit.edu)
-
- 1.07 New version to go on beta tape with GCC 1.35
- Better USG support. Also support for __builtin_alloca
- if we're compiling with GCC.
- diffarch.c: Include the correct header files so MTIOCTOP
- is defined.
- tar.c: Don't print the verbose list of options unless
- given -help. The list of options is *way* too long.
-
- 1.06 Use STDC_MSG if __STDC__ defined
- ENXIO meand end-of-volume in archive (for the UNIX PC)
- Added break after volume-header case (line 440) extract.c
- Added patch from arnold@unix.cc.emory.edu to rtape_lib.c
- Added f_absolute_paths option.
- Deleted refereces to UN*X manual sections (dump(8), etc)
- Fixed to not core-dump on illegal options
- Modified msg_perror to call perror("") instead of perror(0)
- patch so -X - works
- Fixed tar.c so 'tar cf - -C dir' doesn't core-dump
- tar.c (name_match): Fixed to chdir() to the appropriate
- directory if the matching name's change_dir is set. This
- makes tar xv -C foo {files} work.
-
- 1.05 A fix to make confirm() work when the archive is on stdin
- include 'extern FILE *msg_file;' in pr_mkdir(), and fix
- tar.h to work with __STDC__
-
- Added to port.c: mkdir() ftruncate() Removed: lstat()
- Fixed -G to work with -X
- Another fix to tar.texinfo
- Changed tar.c to say argv[0]":you must specify exactly ...
- buffer.c: modified child_open() to keep tar from hanging when
- it is done reading/writing a compressed archive
- added fflush(msg_file) before printing error messages
- create.c: fixed to make link_names non-absolute
-
- 1.04 Added functions msg() and msg_perror() Modified all the
- files to call them. Also checked that all (I hope)
- calls to msg_perror() have a valid errno value
- (modified anno() to leave errno alone), etc
- Re-fixed the -X option. This time for sure. . .
- re-modified the msg stuff. flushed anno() completely
- Modified the directory stuff so it should work on sysV boxes
- added ftime() to getdate.y
- Fixed un_quote_string() so it won't wedge on \" Also fixed
- \ddd (like \123, etc)
- More fixes to tar.texinfo
-
- 1.03 Fixed buffer.c so 'tar tzf NON_EXISTENT_FILE' returns an error
- message instead of hanging forever
- More fixes to tar.texinfo
-
- 1.02 Fixed tar.c so 'tar -h' and 'tar -v' don't cause core dump
- Also fixed the 'usage' message to be more up-to-date.
- Fixed diffarch.c so verify should compile without MTIOCTOP
- defined
-
- 1.01 Fixed typoes in tar.texinfo
- Fixed a bug in the #define for rmtcreat()
- Fixed the -X option to not call realloc() of 0.
-
- Version 1.00: version.c added. -version option added
- Installed new version of the remote-tape library
- Added -help option
-
-Local Variables:
-mode: indented-text
-left-margin: 8
-version-control: never
-End:
diff --git a/gnu/usr.bin/tar/Makefile b/gnu/usr.bin/tar/Makefile
deleted file mode 100644
index 2bd1198..0000000
--- a/gnu/usr.bin/tar/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-PROG= tar
-SRCS= buffer.c create.c diffarch.c extract.c getdate.y \
- getoldopt.c getopt.c getopt1.c gnu.c list.c mangle.c names.c port.c \
- rtapelib.c tar.c update.c version.c
-CFLAGS+= -DRETSIGTYPE=void -DDIRENT=1 -DHAVE_SYS_MTIO_H=1 -DHAVE_UNISTD_H=1
-CFLAGS+= -DHAVE_GETGRGID=1 -DHAVE_GETPWUID=1 -DHAVE_STRING_H=1
-CFLAGS+= -DHAVE_LIMITS_H=1 -DHAVE_STRSTR=1 -DHAVE_VALLOC=1 -DHAVE_MKDIR=1
-CFLAGS+= -DHAVE_MKNOD=1 -DHAVE_RENAME=1 -DHAVE_FTRUNCATE=1 -DHAVE_GETCWD=1
-CFLAGS+= -DBSD42=1 -DHAVE_VPRINTF=1 -DNEEDPAD -I${.CURDIR}
-CFLAGS+= -DDEF_AR_FILE=\"/dev/rst0\" -DDEFBLOCKING=20
-CLEANFILES+=y.tab.h
-NOSHARED?=yes
-
-DPADD+= ${LIBGNUREGEX}
-LDADD+= -lgnuregex
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/tar/Makefile.gnu b/gnu/usr.bin/tar/Makefile.gnu
deleted file mode 100644
index f43f8ed..0000000
--- a/gnu/usr.bin/tar/Makefile.gnu
+++ /dev/null
@@ -1,185 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-# Un*x Makefile for GNU tar program.
-# Copyright (C) 1991, 1992, 1993 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.
-
-#### Start of system configuration section. ####
-
-srcdir = .
-VPATH = .
-
-# If you use gcc, you should either run the fixincludes script that
-# comes with it or else use gcc with the -traditional option. Otherwise
-# ioctl calls will be compiled incorrectly on some systems.
-CC = gcc
-YACC = bison -y
-INSTALL = /usr/local/bin/install -c
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_DATA = $(INSTALL) -m 644
-
-# Things you might add to DEFS:
-# -DSTDC_HEADERS If you have ANSI C headers and libraries.
-# -DHAVE_UNISTD_H If you have unistd.h.
-# -DHAVE_STRING_H If you don't have ANSI C headers but have string.h.
-# -DHAVE_LIMITS_H If you have limits.h.
-# -DBSD42 If you have sys/dir.h (unless you use -DPOSIX),
-# sys/file.h, and st_blocks in `struct stat'.
-# -DDIRENT If you have dirent.h.
-# -DSYSNDIR Old Xenix systems (sys/ndir.h).
-# -DSYSDIR Old BSD systems (sys/dir.h).
-# -DNDIR Old System V systems (ndir.h).
-# -DMAJOR_IN_MKDEV If major, minor, makedev defined in sys/mkdev.h.
-# -DMAJOR_IN_SYSMACROS If major, minor, makedev defined in sys/sysmacros.h.
-# -DRETSIGTYPE=int If your signal handlers return int, not void.
-# -DHAVE_SYS_MTIO_H If you have sys/mtio.h (magtape ioctls).
-# -DHAVE_SYS_GENTAPE_H If you have sys/gentape.h (ISC magtape ioctls).
-# -DHAVE_NETDB_H To use rexec for remote tape operations
-# instead of forking rsh or remsh.
-# -DNO_REMOTE If you have neither a remote shell nor rexec.
-# -DHAVE_VPRINTF If you have vprintf function.
-# -DHAVE_DOPRNT If you have _doprnt function (but lack vprintf).
-# -DHAVE_FTIME If you have ftime system call.
-# -DHAVE_STRSTR If you have strstr function.
-# -DHAVE_VALLOC If you have valloc function.
-# -DHAVE_MKDIR If you have mkdir and rmdir system calls.
-# -DHAVE_MKNOD If you have mknod system call.
-# -DHAVE_RENAME If you have rename system call.
-# -DHAVE_GETCWD If not POSIX.1 but have getcwd function.
-# -DHAVE_FTRUNCATE If you have ftruncate system call.
-# -DV7 On Version 7 Unix (not tested in a long time).
-# -DEMUL_OPEN3 If you lack a 3-argument version of open, and want
-# to emulate it with system calls you do have.
-# -DNO_OPEN3 If you lack the 3-argument open and want to
-# disable the tar -k option instead of emulating open.
-# -DXENIX If you have sys/inode.h and need it to be included.
-
-DEF_AR_FILE = /dev/rst0
-DEFBLOCKING = 20
-DEFS = -DRETSIGTYPE=void -DDIRENT=1 -DHAVE_SYS_MTIO_H=1 -DHAVE_UNISTD_H=1 -DHAVE_GETGRGID=1 -DHAVE_GETPWUID=1 -DHAVE_STRING_H=1 -DHAVE_LIMITS_H=1 -DHAVE_STRSTR=1 -DHAVE_VALLOC=1 -DHAVE_MKDIR=1 -DHAVE_MKNOD=1 -DHAVE_RENAME=1 -DHAVE_FTRUNCATE=1 -DHAVE_GETCWD=1 -DHAVE_VPRINTF=1 -DDEF_AR_FILE=\"$(DEF_AR_FILE)\" -DDEFBLOCKING=$(DEFBLOCKING)
-
-# Set this to rtapelib.o unless you defined NO_REMOTE, in which case
-# make it empty.
-RTAPELIB = rtapelib.o
-LIBS =
-
-CFLAGS = -g
-LDFLAGS = -g
-
-prefix = /usr/bin
-exec_prefix = $(prefix)
-
-# Prefix for each installed program, normally empty or `g'.
-binprefix =
-
-# The directory to install tar in.
-bindir = $(exec_prefix)/bin
-
-# Where to put the rmt executable.
-libdir = /sbin
-
-# The directory to install the info files in.
-infodir = $(prefix)/info
-
-#### End of system configuration section. ####
-
-SHELL = /bin/sh
-
-SRC1 = tar.c create.c extract.c buffer.c getoldopt.c update.c gnu.c mangle.c
-SRC2 = version.c list.c names.c diffarch.c port.c fnmatch.c getopt.c malloc.c
-SRC3 = getopt1.c regex.c getdate.y getdate.c alloca.c
-SRCS = $(SRC1) $(SRC2) $(SRC3)
-OBJ1 = tar.o create.o extract.o buffer.o getoldopt.o update.o gnu.o mangle.o
-OBJ2 = version.o list.o names.o diffarch.o port.o fnmatch.o getopt.o
-OBJ3 = getopt1.o regex.o getdate.o $(RTAPELIB)
-OBJS = $(OBJ1) $(OBJ2) $(OBJ3)
-AUX = README INSTALL NEWS COPYING ChangeLog Makefile.in makefile.pc \
- configure configure.in \
- tar.h fnmatch.h pathmax.h port.h open3.h getopt.h regex.h \
- rmt.h rmt.c rtapelib.c \
- msd_dir.h msd_dir.c tcexparg.c \
- level-0 level-1 backup-specs dump-remind getpagesize.h
-# tar.texinfo tar.info* texinfo.tex \
-
-all: tar rmt
-# tar.info
-
-.c.o:
- $(CC) -c $(CFLAGS) $(CPPFLAGS) $(DEFS) -I$(srcdir) -I. $<
-
-tar: $(OBJS)
- $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
-
-rmt: rmt.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(srcdir)/rmt.c $(LIBS)
-
-tar.info: tar.texinfo
- makeinfo $(srcdir)/tar.texinfo
-
-install: all
- $(INSTALL_PROGRAM) tar $(bindir)/$(binprefix)tar
- -test ! -f rmt || $(INSTALL_PROGRAM) rmt $(libdir)/rmt
-# for file in $(srcdir)/tar.info*; \
-# do $(INSTALL_DATA) $$file $(infodir)/$$file; \
-# done
-
-uninstall:
- rm -f $(bindir)/$(binprefix)tar $(infodir)/tar.info*
- -rm -f $(libdir)/rmt
-
-$(OBJS): tar.h pathmax.h port.h
-regex.o buffer.o tar.o: regex.h
-tar.o fnmatch.o: fnmatch.h
-
-getdate.c: getdate.y
- $(YACC) $(srcdir)/getdate.y
- mv y.tab.c getdate.c
-# getdate.y has 8 shift/reduce conflicts.
-
-TAGS: $(SRCS)
- etags $(SRCS)
-
-clean:
- rm -f *.o tar rmt core
-mostlyclean: clean
-
-distclean: clean
- rm -f Makefile config.status
-
-realclean: distclean
- rm -f TAGS *.info* getdate.c y.tab.c
-
-shar: $(SRCS) $(AUX)
- shar $(SRCS) $(AUX) | gzip > tar-`sed -e '/version_string/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q version.c`.shar.z
-
-dist: $(SRCS) $(AUX)
- echo tar-`sed -e '/version_string/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q version.c` > .fname
- -rm -rf `cat .fname`
- mkdir `cat .fname`
- for file in $(SRCS) $(AUX); do \
- ln $$file `cat .fname` || cp $$file `cat .fname`; done
- tar chzf `cat .fname`.tar.z `cat .fname`
- -rm -rf `cat .fname` .fname
-
-tar.zoo: $(SRCS) $(AUX)
- -rm -rf tmp.dir
- -mkdir tmp.dir
- -rm tar.zoo
- for X in $(SRCS) $(AUX) ; do echo $$X ; sed 's/$$/ /' $$X > tmp.dir/$$X ; done
- cd tmp.dir ; zoo aM ../tar.zoo *
- -rm -rf tmp.dir
-
-# Prevent GNU make v3 from overflowing arg limit on SysV.
-.NOEXPORT:
diff --git a/gnu/usr.bin/tar/README b/gnu/usr.bin/tar/README
deleted file mode 100644
index 4b577e7..0000000
--- a/gnu/usr.bin/tar/README
+++ /dev/null
@@ -1,40 +0,0 @@
-Hey! Emacs! Yo! This is -*- Text -*- !!!
-
-This GNU tar 1.11.2. Please send bug reports, etc., to
-bug-gnu-utils@prep.ai.mit.edu. This is a beta-test release. Please
-try it out. There is no manual; the release of version 1.12 will
-contain a manual.
-
-GNU tar is based heavily on John Gilmore's public domain tar, but with
-added features. The manual is currently being written.
-
-This distribution also includes rmt, the remote tape server (which
-normally must reside in /etc). The mt tape drive control program is
-in the GNU cpio distribution.
-
-See the file INSTALL for compilation and installation instructions for Unix.
-See the file NEWS for information on all that is new in this version
-of tar.
-
-makefile.pc is a makefile for Turbo C 2.0 on MS-DOS.
-
-Various people have been having problems using floppies on a NeXT. In
-order to have them work right, you need to kill the automounting
-program which tries to monut floppies as soon as they are added.
-
-If you want to do incremental dumps, use the distributed backup
-scripts. They are what we use at the FSF to do all our backups. Most
-importantly, do not use --incremental (-G) or --after-date (-N) or
---newer-mtime to do incremental dumps. The only option that works
-correctly for this purpose is --listed-incremental. (When extracting
-incremental dumps, use --incremental (-G).)
-
-If your system needs to link with -lPW to get alloca, but has
-rename in the C library (so HAVE_RENAME is defined), -lPW might
-give you an incorrect version of rename. On HP-UX this manifests
-itself as an undefined data symbol called "Error" when linking cp, ln,
-and mv. If this happens, use `ar x' to extract alloca.o from libPW.a
-and `ar rc' to put it in a library liballoca.a, and put that in LIBS
-instead of -lPW. This problem does not occur when using gcc, which
-has alloca built in.
-
diff --git a/gnu/usr.bin/tar/buffer.c b/gnu/usr.bin/tar/buffer.c
deleted file mode 100644
index eb7e3ef..0000000
--- a/gnu/usr.bin/tar/buffer.c
+++ /dev/null
@@ -1,1584 +0,0 @@
-/* Buffer management for tar.
- Copyright (C) 1988, 1992, 1993 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Buffer management for tar.
- *
- * Written by John Gilmore, ihnp4!hoptoad!gnu, on 25 August 1985.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-#include <sys/types.h> /* For non-Berkeley systems */
-#include <signal.h>
-#include <time.h>
-time_t time ();
-
-#ifdef HAVE_SYS_MTIO_H
-#include <sys/ioctl.h>
-#include <sys/mtio.h>
-#endif
-
-#ifdef BSD42
-#include <sys/file.h>
-#else
-#ifndef V7
-#include <fcntl.h>
-#endif
-#endif
-
-#ifdef __MSDOS__
-#include <process.h>
-#endif
-
-#ifdef XENIX
-#include <sys/inode.h>
-#endif
-
-#include "tar.h"
-#include "port.h"
-#include "rmt.h"
-#include "gnuregex.h"
-
-/* Either stdout or stderr: The thing we write messages (standard msgs, not
- errors) to. Stdout unless we're writing a pipe, in which case stderr */
-FILE *msg_file = stdout;
-
-#define STDIN 0 /* Standard input file descriptor */
-#define STDOUT 1 /* Standard output file descriptor */
-
-#define PREAD 0 /* Read file descriptor from pipe() */
-#define PWRITE 1 /* Write file descriptor from pipe() */
-
-#define MAGIC_STAT 105 /* Magic status returned by child, if
- it can't exec. We hope compress/sh
- never return this status! */
-
-void *valloc ();
-
-void writeerror ();
-void readerror ();
-
-void ck_pipe ();
-void ck_close ();
-
-int backspace_output ();
-extern void finish_header ();
-void flush_archive ();
-int isfile ();
-int new_volume ();
-void verify_volume ();
-extern void to_oct ();
-
-#ifndef __MSDOS__
-/* Obnoxious test to see if dimwit is trying to dump the archive */
-dev_t ar_dev;
-ino_t ar_ino;
-#endif
-
-/*
- * The record pointed to by save_rec should not be overlaid
- * when reading in a new tape block. Copy it to record_save_area first, and
- * change the pointer in *save_rec to point to record_save_area.
- * Saved_recno records the record number at the time of the save.
- * This is used by annofile() to print the record number of a file's
- * header record.
- */
-static union record **save_rec;
-union record record_save_area;
-static long saved_recno;
-
-/*
- * PID of child program, if f_compress or remote archive access.
- */
-static int childpid = 0;
-
-/*
- * Record number of the start of this block of records
- */
-long baserec;
-
-/*
- * Error recovery stuff
- */
-static int r_error_count;
-
-/*
- * Have we hit EOF yet?
- */
-static int hit_eof;
-
-/* Checkpointing counter */
-static int checkpoint;
-
-/* JF we're reading, but we just read the last record and its time to update */
-extern time_to_start_writing;
-int file_to_switch_to = -1; /* If remote update, close archive, and use
- this descriptor to write to */
-
-static int volno = 1; /* JF which volume of a multi-volume tape
- we're on */
-static int global_volno = 1; /* Volume number to print in external messages. */
-
-char *save_name = 0; /* Name of the file we are currently writing */
-long save_totsize; /* total size of file we are writing. Only
- valid if save_name is non_zero */
-long save_sizeleft; /* Where we are in the file we are writing.
- Only valid if save_name is non-zero */
-
-int write_archive_to_stdout;
-
-/* Used by fl_read and fl_write to store the real info about saved names */
-static char real_s_name[NAMSIZ];
-static long real_s_totsize;
-static long real_s_sizeleft;
-
-/* Reset the EOF flag (if set), and re-set ar_record, etc */
-
-void
-reset_eof ()
-{
- if (hit_eof)
- {
- hit_eof = 0;
- ar_record = ar_block;
- ar_last = ar_block + blocking;
- ar_reading = 0;
- }
-}
-
-/*
- * Return the location of the next available input or output record.
- * Return NULL for EOF. Once we have returned NULL, we just keep returning
- * it, to avoid accidentally going on to the next file on the "tape".
- */
-union record *
-findrec ()
-{
- if (ar_record == ar_last)
- {
- if (hit_eof)
- return (union record *) NULL; /* EOF */
- flush_archive ();
- if (ar_record == ar_last)
- {
- hit_eof++;
- return (union record *) NULL; /* EOF */
- }
- }
- return ar_record;
-}
-
-
-/*
- * Indicate that we have used all records up thru the argument.
- * (should the arg have an off-by-1? XXX FIXME)
- */
-void
-userec (rec)
- union record *rec;
-{
- while (rec >= ar_record)
- ar_record++;
- /*
- * Do NOT flush the archive here. If we do, the same
- * argument to userec() could mean the next record (if the
- * input block is exactly one record long), which is not what
- * is intended.
- */
- if (ar_record > ar_last)
- abort ();
-}
-
-
-/*
- * Return a pointer to the end of the current records buffer.
- * All the space between findrec() and endofrecs() is available
- * for filling with data, or taking data from.
- */
-union record *
-endofrecs ()
-{
- return ar_last;
-}
-
-
-/*
- * Duplicate a file descriptor into a certain slot.
- * Equivalent to BSD "dup2" with error reporting.
- */
-void
-dupto (from, to, msg)
- int from, to;
- char *msg;
-{
- int err;
-
- if (from != to)
- {
- err = close (to);
- if (err < 0 && errno != EBADF)
- {
- msg_perror ("Cannot close descriptor %d", to);
- exit (EX_SYSTEM);
- }
- err = dup (from);
- if (err != to)
- {
- msg_perror ("cannot dup %s", msg);
- exit (EX_SYSTEM);
- }
- ck_close (from);
- }
-}
-
-#ifdef __MSDOS__
-void
-child_open ()
-{
- fprintf (stderr, "MS-DOS %s can't use compressed or remote archives\n", tar);
- exit (EX_ARGSBAD);
-}
-
-#else
-void
-child_open ()
-{
- int pipe[2];
- int err = 0;
-
- int kidpipe[2];
- int kidchildpid;
-
-#define READ 0
-#define WRITE 1
-
- ck_pipe (pipe);
-
- childpid = fork ();
- if (childpid < 0)
- {
- msg_perror ("cannot fork");
- exit (EX_SYSTEM);
- }
- if (childpid > 0)
- {
- /* We're the parent. Clean up and be happy */
- /* This, at least, is easy */
-
- if (ar_reading)
- {
- f_reblock++;
- archive = pipe[READ];
- ck_close (pipe[WRITE]);
- }
- else
- {
- archive = pipe[WRITE];
- ck_close (pipe[READ]);
- }
- return;
- }
-
- /* We're the kid */
- if (ar_reading)
- {
- dupto (pipe[WRITE], STDOUT, "(child) pipe to stdout");
- ck_close (pipe[READ]);
- }
- else
- {
- dupto (pipe[READ], STDIN, "(child) pipe to stdin");
- ck_close (pipe[WRITE]);
- }
-
- /* We need a child tar only if
- 1: we're reading/writing stdin/out (to force reblocking)
- 2: the file is to be accessed by rmt (compress doesn't know how)
- 3: the file is not a plain file */
-#ifdef NO_REMOTE
- if (!(ar_files[0][0] == '-' && ar_files[0][1] == '\0') && isfile (ar_files[0]))
-#else
- if (!(ar_files[0][0] == '-' && ar_files[0][1] == '\0') && !_remdev (ar_files[0]) && isfile (ar_files[0]))
-#endif
- {
- /* We don't need a child tar. Open the archive */
- if (ar_reading)
- {
- archive = open (ar_files[0], O_RDONLY | O_BINARY, 0666);
- if (archive < 0)
- {
- msg_perror ("can't open archive %s", ar_files[0]);
- exit (EX_BADARCH);
- }
- dupto (archive, STDIN, "archive to stdin");
- /* close(archive); */
- }
- else
- {
- archive = creat (ar_files[0], 0666);
- if (archive < 0)
- {
- msg_perror ("can't open archive %s", ar_files[0]);
- exit (EX_BADARCH);
- }
- dupto (archive, STDOUT, "archive to stdout");
- /* close(archive); */
- }
- }
- else
- {
- /* We need a child tar */
- ck_pipe (kidpipe);
-
- kidchildpid = fork ();
- if (kidchildpid < 0)
- {
- msg_perror ("child can't fork");
- exit (EX_SYSTEM);
- }
-
- if (kidchildpid > 0)
- {
- /* About to exec compress: set up the files */
- if (ar_reading)
- {
- dupto (kidpipe[READ], STDIN, "((child)) pipe to stdin");
- ck_close (kidpipe[WRITE]);
- /* dup2(pipe[WRITE],STDOUT); */
- }
- else
- {
- /* dup2(pipe[READ],STDIN); */
- dupto (kidpipe[WRITE], STDOUT, "((child)) pipe to stdout");
- ck_close (kidpipe[READ]);
- }
- /* ck_close(pipe[READ]); */
- /* ck_close(pipe[WRITE]); */
- /* ck_close(kidpipe[READ]);
- ck_close(kidpipe[WRITE]); */
- }
- else
- {
- /* Grandchild. Do the right thing, namely sit here and
- read/write the archive, and feed stuff back to compress */
- tar = "tar (child)";
- if (ar_reading)
- {
- dupto (kidpipe[WRITE], STDOUT, "[child] pipe to stdout");
- ck_close (kidpipe[READ]);
- }
- else
- {
- dupto (kidpipe[READ], STDIN, "[child] pipe to stdin");
- ck_close (kidpipe[WRITE]);
- }
-
- if (ar_files[0][0] == '-' && ar_files[0][1] == '\0')
- {
- if (ar_reading)
- archive = STDIN;
- else
- archive = STDOUT;
- }
- else /* This can't happen if (ar_reading==2)
- archive = rmtopen(ar_files[0], O_RDWR|O_CREAT|O_BINARY, 0666);
- else */ if (ar_reading)
- archive = rmtopen (ar_files[0], O_RDONLY | O_BINARY, 0666);
- else
- archive = rmtcreat (ar_files[0], 0666);
-
- if (archive < 0)
- {
- msg_perror ("can't open archive %s", ar_files[0]);
- exit (EX_BADARCH);
- }
-
- if (ar_reading)
- {
- for (;;)
- {
- char *ptr;
- int max, count;
-
- r_error_count = 0;
- error_loop:
- err = rmtread (archive, ar_block->charptr, (int) (blocksize));
- if (err < 0)
- {
- readerror ();
- goto error_loop;
- }
- if (err == 0)
- break;
- ptr = ar_block->charptr;
- max = err;
- while (max)
- {
- count = (max < RECORDSIZE) ? max : RECORDSIZE;
- err = write (STDOUT, ptr, count);
- if (err != count)
- {
- if (err < 0)
- {
- msg_perror ("can't write to compression program");
- exit (EX_SYSTEM);
- }
- else
- msg ("write to compression program short %d bytes",
- count - err);
- count = (err < 0) ? 0 : err;
- }
- ptr += count;
- max -= count;
- }
- }
- }
- else
- {
- for (;;)
- {
- int n;
- char *ptr;
-
- n = blocksize;
- ptr = ar_block->charptr;
- while (n)
- {
- err = read (STDIN, ptr, (n < RECORDSIZE) ? n : RECORDSIZE);
- if (err <= 0)
- break;
- n -= err;
- ptr += err;
- }
- /* EOF */
- if (err == 0)
- {
- if (!f_compress_block)
- blocksize -= n;
- else
- bzero (ar_block->charptr + blocksize - n, n);
- err = rmtwrite (archive, ar_block->charptr, blocksize);
- if (err != (blocksize))
- writeerror (err);
- if (!f_compress_block)
- blocksize += n;
- break;
- }
- if (n)
- {
- msg_perror ("can't read from compression program");
- exit (EX_SYSTEM);
- }
- err = rmtwrite (archive, ar_block->charptr, (int) blocksize);
- if (err != blocksize)
- writeerror (err);
- }
- }
-
- /* close_archive(); */
- exit (0);
- }
- }
- /* So we should exec compress (-d) */
- if (ar_reading)
- execlp (f_compressprog, f_compressprog, "-d", (char *) 0);
- else
- execlp (f_compressprog, f_compressprog, (char *) 0);
- msg_perror ("can't exec %s", f_compressprog);
- _exit (EX_SYSTEM);
-}
-
-
-/* return non-zero if p is the name of a directory */
-int
-isfile (p)
- char *p;
-{
- struct stat stbuf;
-
- if (stat (p, &stbuf) < 0)
- return 1;
- if (S_ISREG (stbuf.st_mode))
- return 1;
- return 0;
-}
-
-#endif
-
-/*
- * Open an archive file. The argument specifies whether we are
- * reading or writing.
- */
-/* JF if the arg is 2, open for reading and writing. */
-void
-open_archive (reading)
- int reading;
-{
- msg_file = f_exstdout ? stderr : stdout;
-
- if (blocksize == 0)
- {
- msg ("invalid value for blocksize");
- exit (EX_ARGSBAD);
- }
-
- if (n_ar_files == 0)
- {
- msg ("No archive name given, what should I do?");
- exit (EX_BADARCH);
- }
-
- /*NOSTRICT*/
- if (f_multivol)
- {
- ar_block = (union record *) valloc ((unsigned) (blocksize + (2 * RECORDSIZE)));
- if (ar_block)
- ar_block += 2;
- }
- else
- ar_block = (union record *) valloc ((unsigned) blocksize);
- if (!ar_block)
- {
- msg ("could not allocate memory for blocking factor %d",
- blocking);
- exit (EX_ARGSBAD);
- }
-
- ar_record = ar_block;
- ar_last = ar_block + blocking;
- ar_reading = reading;
-
- if (f_multivol && f_verify)
- {
- msg ("cannot verify multi-volume archives");
- exit (EX_ARGSBAD);
- }
-
- if (f_compressprog)
- {
- if (reading == 2 || f_verify)
- {
- msg ("cannot update or verify compressed archives");
- exit (EX_ARGSBAD);
- }
- if (f_multivol)
- {
- msg ("cannot use multi-volume compressed archives");
- exit (EX_ARGSBAD);
- }
- child_open ();
- if (!reading && ar_files[0][0] == '-' && ar_files[0][1] == '\0')
- msg_file = stderr;
- /* child_open(rem_host, rem_file); */
- }
- else if (ar_files[0][0] == '-' && ar_files[0][1] == '\0')
- {
- f_reblock++; /* Could be a pipe, be safe */
- if (f_verify)
- {
- msg ("can't verify stdin/stdout archive");
- exit (EX_ARGSBAD);
- }
- if (reading == 2)
- {
- archive = STDIN;
- msg_file = stderr;
- write_archive_to_stdout++;
- }
- else if (reading)
- archive = STDIN;
- else
- {
- archive = STDOUT;
- msg_file = stderr;
- }
- }
- else if (reading == 2 || f_verify)
- {
- archive = rmtopen (ar_files[0], O_RDWR | O_CREAT | O_BINARY, 0666);
- }
- else if (reading)
- {
- archive = rmtopen (ar_files[0], O_RDONLY | O_BINARY, 0666);
- }
- else
- {
- archive = rmtcreat (ar_files[0], 0666);
- }
- if (archive < 0)
- {
- msg_perror ("can't open %s", ar_files[0]);
- exit (EX_BADARCH);
- }
-#ifndef __MSDOS__
- if (!_isrmt (archive))
- {
- struct stat tmp_stat;
-
- fstat (archive, &tmp_stat);
- if (S_ISREG (tmp_stat.st_mode))
- {
- ar_dev = tmp_stat.st_dev;
- ar_ino = tmp_stat.st_ino;
- }
- }
-#endif
-
-#ifdef __MSDOS__
- setmode (archive, O_BINARY);
-#endif
-
- if (reading)
- {
- ar_last = ar_block; /* Set up for 1st block = # 0 */
- (void) findrec (); /* Read it in, check for EOF */
-
- if (f_volhdr)
- {
- union record *head;
-#if 0
- char *ptr;
-
- if (f_multivol)
- {
- ptr = malloc (strlen (f_volhdr) + 20);
- sprintf (ptr, "%s Volume %d", f_volhdr, 1);
- }
- else
- ptr = f_volhdr;
-#endif
- head = findrec ();
- if (!head)
- {
- msg ("Archive not labelled to match %s", f_volhdr);
- exit (EX_BADVOL);
- }
- if (re_match (label_pattern, head->header.arch_name,
- strlen (head->header.arch_name), 0, 0) < 0)
- {
- msg ("Volume mismatch! %s!=%s", f_volhdr,
- head->header.arch_name);
- exit (EX_BADVOL);
- }
-#if 0
- if (strcmp (ptr, head->header.name))
- {
- msg ("Volume mismatch! %s!=%s", ptr, head->header.name);
- exit (EX_BADVOL);
- }
- if (ptr != f_volhdr)
- free (ptr);
-#endif
- }
- }
- else if (f_volhdr)
- {
- bzero ((void *) ar_block, RECORDSIZE);
- if (f_multivol)
- sprintf (ar_block->header.arch_name, "%s Volume 1", f_volhdr);
- else
- strcpy (ar_block->header.arch_name, f_volhdr);
- current_file_name = ar_block->header.arch_name;
- ar_block->header.linkflag = LF_VOLHDR;
- to_oct (time (0), 1 + 12, ar_block->header.mtime);
- finish_header (ar_block);
- /* ar_record++; */
- }
-}
-
-
-/*
- * Remember a union record * as pointing to something that we
- * need to keep when reading onward in the file. Only one such
- * thing can be remembered at once, and it only works when reading
- * an archive.
- *
- * We calculate "offset" then add it because some compilers end up
- * adding (baserec+ar_record), doing a 9-bit shift of baserec, then
- * subtracting ar_block from that, shifting it back, losing the top 9 bits.
- */
-void
-saverec (pointer)
- union record **pointer;
-{
- long offset;
-
- save_rec = pointer;
- offset = ar_record - ar_block;
- saved_recno = baserec + offset;
-}
-
-/*
- * Perform a write to flush the buffer.
- */
-
-/*send_buffer_to_file();
- if(new_volume) {
- deal_with_new_volume_stuff();
- send_buffer_to_file();
- }
- */
-
-void
-fl_write ()
-{
- int err;
- int copy_back;
- static long bytes_written = 0;
-
- if (f_checkpoint && !(++checkpoint % 10))
- msg ("Write checkpoint %d\n", checkpoint);
- if (tape_length && bytes_written >= tape_length * 1024)
- {
- errno = ENOSPC;
- err = 0;
- }
- else
- err = rmtwrite (archive, ar_block->charptr, (int) blocksize);
- if (err != blocksize && !f_multivol)
- writeerror (err);
- else if (f_totals)
- tot_written += blocksize;
-
- if (err > 0)
- bytes_written += err;
- if (err == blocksize)
- {
- if (f_multivol)
- {
- if (!save_name)
- {
- real_s_name[0] = '\0';
- real_s_totsize = 0;
- real_s_sizeleft = 0;
- return;
- }
-#ifdef __MSDOS__
- if (save_name[1] == ':')
- save_name += 2;
-#endif
- while (*save_name == '/')
- save_name++;
-
- strcpy (real_s_name, save_name);
- real_s_totsize = save_totsize;
- real_s_sizeleft = save_sizeleft;
- }
- return;
- }
-
- /* We're multivol Panic if we didn't get the right kind of response */
- /* ENXIO is for the UNIX PC */
- if (err < 0 && errno != ENOSPC && errno != EIO && errno != ENXIO)
- writeerror (err);
-
- /* If error indicates a short write, we just move to the next tape. */
-
- if (new_volume (0) < 0)
- return;
- bytes_written = 0;
- if (f_volhdr && real_s_name[0])
- {
- copy_back = 2;
- ar_block -= 2;
- }
- else if (f_volhdr || real_s_name[0])
- {
- copy_back = 1;
- ar_block--;
- }
- else
- copy_back = 0;
- if (f_volhdr)
- {
- bzero ((void *) ar_block, RECORDSIZE);
- sprintf (ar_block->header.arch_name, "%s Volume %d", f_volhdr, volno);
- to_oct (time (0), 1 + 12, ar_block->header.mtime);
- ar_block->header.linkflag = LF_VOLHDR;
- finish_header (ar_block);
- }
- if (real_s_name[0])
- {
- int tmp;
-
- if (f_volhdr)
- ar_block++;
- bzero ((void *) ar_block, RECORDSIZE);
- strcpy (ar_block->header.arch_name, real_s_name);
- ar_block->header.linkflag = LF_MULTIVOL;
- to_oct ((long) real_s_sizeleft, 1 + 12,
- ar_block->header.size);
- to_oct ((long) real_s_totsize - real_s_sizeleft,
- 1 + 12, ar_block->header.offset);
- tmp = f_verbose;
- f_verbose = 0;
- finish_header (ar_block);
- f_verbose = tmp;
- if (f_volhdr)
- ar_block--;
- }
-
- err = rmtwrite (archive, ar_block->charptr, (int) blocksize);
- if (err != blocksize)
- writeerror (err);
- else if (f_totals)
- tot_written += blocksize;
-
-
- bytes_written = blocksize;
- if (copy_back)
- {
- ar_block += copy_back;
- bcopy ((void *) (ar_block + blocking - copy_back),
- (void *) ar_record,
- copy_back * RECORDSIZE);
- ar_record += copy_back;
-
- if (real_s_sizeleft >= copy_back * RECORDSIZE)
- real_s_sizeleft -= copy_back * RECORDSIZE;
- else if ((real_s_sizeleft + RECORDSIZE - 1) / RECORDSIZE <= copy_back)
- real_s_name[0] = '\0';
- else
- {
-#ifdef __MSDOS__
- if (save_name[1] == ':')
- save_name += 2;
-#endif
- while (*save_name == '/')
- save_name++;
-
- strcpy (real_s_name, save_name);
- real_s_sizeleft = save_sizeleft;
- real_s_totsize = save_totsize;
- }
- copy_back = 0;
- }
-}
-
-/* Handle write errors on the archive. Write errors are always fatal */
-/* Hitting the end of a volume does not cause a write error unless the write
-* was the first block of the volume */
-
-void
-writeerror (err)
- int err;
-{
- if (err < 0)
- {
- msg_perror ("can't write to %s", ar_files[cur_ar_file]);
- exit (EX_BADARCH);
- }
- else
- {
- msg ("only wrote %u of %u bytes to %s", err, blocksize, ar_files[cur_ar_file]);
- exit (EX_BADARCH);
- }
-}
-
-/*
- * Handle read errors on the archive.
- *
- * If the read should be retried, readerror() returns to the caller.
- */
-void
-readerror ()
-{
-# define READ_ERROR_MAX 10
-
- read_error_flag++; /* Tell callers */
-
- msg_perror ("read error on %s", ar_files[cur_ar_file]);
-
- if (baserec == 0)
- {
- /* First block of tape. Probably stupidity error */
- exit (EX_BADARCH);
- }
-
- /*
- * Read error in mid archive. We retry up to READ_ERROR_MAX times
- * and then give up on reading the archive. We set read_error_flag
- * for our callers, so they can cope if they want.
- */
- if (r_error_count++ > READ_ERROR_MAX)
- {
- msg ("Too many errors, quitting.");
- exit (EX_BADARCH);
- }
- return;
-}
-
-
-/*
- * Perform a read to flush the buffer.
- */
-void
-fl_read ()
-{
- int err; /* Result from system call */
- int left; /* Bytes left */
- char *more; /* Pointer to next byte to read */
-
- if (f_checkpoint && !(++checkpoint % 10))
- msg ("Read checkpoint %d\n", checkpoint);
-
- /*
- * Clear the count of errors. This only applies to a single
- * call to fl_read. We leave read_error_flag alone; it is
- * only turned off by higher level software.
- */
- r_error_count = 0; /* Clear error count */
-
- /*
- * If we are about to wipe out a record that
- * somebody needs to keep, copy it out to a holding
- * area and adjust somebody's pointer to it.
- */
- if (save_rec &&
- *save_rec >= ar_record &&
- *save_rec < ar_last)
- {
- record_save_area = **save_rec;
- *save_rec = &record_save_area;
- }
- if (write_archive_to_stdout && baserec != 0)
- {
- err = rmtwrite (1, ar_block->charptr, blocksize);
- if (err != blocksize)
- writeerror (err);
- }
- if (f_multivol)
- {
- if (save_name)
- {
- if (save_name != real_s_name)
- {
-#ifdef __MSDOS__
- if (save_name[1] == ':')
- save_name += 2;
-#endif
- while (*save_name == '/')
- save_name++;
-
- strcpy (real_s_name, save_name);
- save_name = real_s_name;
- }
- real_s_totsize = save_totsize;
- real_s_sizeleft = save_sizeleft;
-
- }
- else
- {
- real_s_name[0] = '\0';
- real_s_totsize = 0;
- real_s_sizeleft = 0;
- }
- }
-
-error_loop:
- err = rmtread (archive, ar_block->charptr, (int) blocksize);
- if (err == blocksize)
- return;
-
- if ((err == 0 || (err < 0 && errno == ENOSPC) || (err > 0 && !f_reblock)) && f_multivol)
- {
- union record *head;
-
- try_volume:
- if (new_volume ((cmd_mode == CMD_APPEND || cmd_mode == CMD_CAT || cmd_mode == CMD_UPDATE) ? 2 : 1) < 0)
- return;
- vol_error:
- err = rmtread (archive, ar_block->charptr, (int) blocksize);
- if (err < 0)
- {
- readerror ();
- goto vol_error;
- }
- if (err != blocksize)
- goto short_read;
-
- head = ar_block;
-
- if (head->header.linkflag == LF_VOLHDR)
- {
- if (f_volhdr)
- {
-#if 0
- char *ptr;
-
- ptr = (char *) malloc (strlen (f_volhdr) + 20);
- sprintf (ptr, "%s Volume %d", f_volhdr, volno);
-#endif
- if (re_match (label_pattern, head->header.arch_name,
- strlen (head->header.arch_name),
- 0, 0) < 0)
- {
- msg ("Volume mismatch! %s!=%s", f_volhdr,
- head->header.arch_name);
- --volno;
- --global_volno;
- goto try_volume;
- }
-
-#if 0
- if (strcmp (ptr, head->header.name))
- {
- msg ("Volume mismatch! %s!=%s", ptr, head->header.name);
- --volno;
- --global_volno;
- free (ptr);
- goto try_volume;
- }
- free (ptr);
-#endif
- }
- if (f_verbose)
- fprintf (msg_file, "Reading %s\n", head->header.arch_name);
- head++;
- }
- else if (f_volhdr)
- {
- msg ("Warning: No volume header!");
- }
-
- if (real_s_name[0])
- {
- long from_oct ();
-
- if (head->header.linkflag != LF_MULTIVOL || strcmp (head->header.arch_name, real_s_name))
- {
- msg ("%s is not continued on this volume!", real_s_name);
- --volno;
- --global_volno;
- goto try_volume;
- }
- if (real_s_totsize != from_oct (1 + 12, head->header.size) + from_oct (1 + 12, head->header.offset))
- {
- msg ("%s is the wrong size (%ld!=%ld+%ld)",
- head->header.arch_name, save_totsize,
- from_oct (1 + 12, head->header.size),
- from_oct (1 + 12, head->header.offset));
- --volno;
- --global_volno;
- goto try_volume;
- }
- if (real_s_totsize - real_s_sizeleft != from_oct (1 + 12, head->header.offset))
- {
- msg ("This volume is out of sequence");
- --volno;
- --global_volno;
- goto try_volume;
- }
- head++;
- }
- ar_record = head;
- return;
- }
- else if (err < 0)
- {
- readerror ();
- goto error_loop; /* Try again */
- }
-
-short_read:
- more = ar_block->charptr + err;
- left = blocksize - err;
-
-again:
- if (0 == (((unsigned) left) % RECORDSIZE))
- {
- /* FIXME, for size=0, multi vol support */
- /* On the first block, warn about the problem */
- if (!f_reblock && baserec == 0 && f_verbose && err > 0)
- {
- /* msg("Blocksize = %d record%s",
- err / RECORDSIZE, (err > RECORDSIZE)? "s": "");*/
- msg ("Blocksize = %d records", err / RECORDSIZE);
- }
- ar_last = ar_block + ((unsigned) (blocksize - left)) / RECORDSIZE;
- return;
- }
- if (f_reblock)
- {
- /*
- * User warned us about this. Fix up.
- */
- if (left > 0)
- {
- error2loop:
- err = rmtread (archive, more, (int) left);
- if (err < 0)
- {
- readerror ();
- goto error2loop; /* Try again */
- }
- if (err == 0)
- {
- msg ("archive %s EOF not on block boundary", ar_files[cur_ar_file]);
- exit (EX_BADARCH);
- }
- left -= err;
- more += err;
- goto again;
- }
- }
- else
- {
- msg ("only read %d bytes from archive %s", err, ar_files[cur_ar_file]);
- exit (EX_BADARCH);
- }
-}
-
-
-/*
- * Flush the current buffer to/from the archive.
- */
-void
-flush_archive ()
-{
- int c;
-
- baserec += ar_last - ar_block;/* Keep track of block #s */
- ar_record = ar_block; /* Restore pointer to start */
- ar_last = ar_block + blocking;/* Restore pointer to end */
-
- if (ar_reading)
- {
- if (time_to_start_writing)
- {
- time_to_start_writing = 0;
- ar_reading = 0;
-
- if (file_to_switch_to >= 0)
- {
- if ((c = rmtclose (archive)) < 0)
- msg_perror ("Warning: can't close %s(%d,%d)", ar_files[cur_ar_file], archive, c);
-
- archive = file_to_switch_to;
- }
- else
- (void) backspace_output ();
- fl_write ();
- }
- else
- fl_read ();
- }
- else
- {
- fl_write ();
- }
-}
-
-/* Backspace the archive descriptor by one blocks worth.
- If its a tape, MTIOCTOP will work. If its something else,
- we try to seek on it. If we can't seek, we lose! */
-int
-backspace_output ()
-{
- long cur;
- /* int er; */
- extern char *output_start;
-
-#ifdef MTIOCTOP
- struct mtop t;
-
- t.mt_op = MTBSR;
- t.mt_count = 1;
- if ((rmtioctl (archive, MTIOCTOP, &t)) >= 0)
- return 1;
- if (errno == EIO && (rmtioctl (archive, MTIOCTOP, &t)) >= 0)
- return 1;
-#endif
-
- cur = rmtlseek (archive, 0L, 1);
- cur -= blocksize;
- /* Seek back to the beginning of this block and
- start writing there. */
-
- if (rmtlseek (archive, cur, 0) != cur)
- {
- /* Lseek failed. Try a different method */
- msg ("Couldn't backspace archive file. It may be unreadable without -i.");
- /* Replace the first part of the block with nulls */
- if (ar_block->charptr != output_start)
- bzero (ar_block->charptr, output_start - ar_block->charptr);
- return 2;
- }
- return 3;
-}
-
-
-/*
- * Close the archive file.
- */
-void
-close_archive ()
-{
- int child;
- int status;
- int c;
-
- if (time_to_start_writing || !ar_reading)
- flush_archive ();
- if (cmd_mode == CMD_DELETE)
- {
- off_t pos;
-
- pos = rmtlseek (archive, 0L, 1);
-#ifndef __MSDOS__
- (void) ftruncate (archive, pos);
-#else
- (void) rmtwrite (archive, "", 0);
-#endif
- }
- if (f_verify)
- verify_volume ();
-
- if ((c = rmtclose (archive)) < 0)
- msg_perror ("Warning: can't close %s(%d,%d)", ar_files[cur_ar_file], archive, c);
-
-#ifndef __MSDOS__
- if (childpid)
- {
- /*
- * Loop waiting for the right child to die, or for
- * no more kids.
- */
- while (((child = wait (&status)) != childpid) && child != -1)
- ;
-
- if (child != -1)
- {
- if (WIFSIGNALED (status))
- {
- /* SIGPIPE is OK, everything else is a problem. */
- if (WTERMSIG (status) != SIGPIPE)
- msg ("child died with signal %d%s", WTERMSIG (status),
- WIFCOREDUMPED (status) ? " (core dumped)" : "");
- }
- else
- {
- /* Child voluntarily terminated -- but why? */
- if (WEXITSTATUS (status) == MAGIC_STAT)
- {
- exit (EX_SYSTEM); /* Child had trouble */
- }
- if (WEXITSTATUS (status) == (SIGPIPE + 128))
- {
- /*
- * /bin/sh returns this if its child
- * dies with SIGPIPE. 'Sok.
- */
- /* Do nothing. */
- }
- else if (WEXITSTATUS (status))
- msg ("child returned status %d",
- WEXITSTATUS (status));
- }
- }
- }
-#endif /* __MSDOS__ */
-}
-
-
-#ifdef DONTDEF
-/*
- * Message management.
- *
- * anno writes a message prefix on stream (eg stdout, stderr).
- *
- * The specified prefix is normally output followed by a colon and a space.
- * However, if other command line options are set, more output can come
- * out, such as the record # within the archive.
- *
- * If the specified prefix is NULL, no output is produced unless the
- * command line option(s) are set.
- *
- * If the third argument is 1, the "saved" record # is used; if 0, the
- * "current" record # is used.
- */
-void
-anno (stream, prefix, savedp)
- FILE *stream;
- char *prefix;
- int savedp;
-{
-# define MAXANNO 50
- char buffer[MAXANNO]; /* Holds annorecment */
-# define ANNOWIDTH 13
- int space;
- long offset;
- int save_e;
-
- save_e = errno;
- /* Make sure previous output gets out in sequence */
- if (stream == stderr)
- fflush (stdout);
- if (f_sayblock)
- {
- if (prefix)
- {
- fputs (prefix, stream);
- putc (' ', stream);
- }
- offset = ar_record - ar_block;
- (void) sprintf (buffer, "rec %d: ",
- savedp ? saved_recno :
- baserec + offset);
- fputs (buffer, stream);
- space = ANNOWIDTH - strlen (buffer);
- if (space > 0)
- {
- fprintf (stream, "%*s", space, "");
- }
- }
- else if (prefix)
- {
- fputs (prefix, stream);
- fputs (": ", stream);
- }
- errno = save_e;
-}
-
-#endif
-
-/* Called to initialize the global volume number. */
-void
-init_volume_number ()
-{
- FILE *vf;
-
- vf = fopen (f_volno_file, "r");
- if (!vf && errno != ENOENT)
- msg_perror ("%s", f_volno_file);
-
- if (vf)
- {
- fscanf (vf, "%d", &global_volno);
- fclose (vf);
- }
-}
-
-/* Called to write out the closing global volume number. */
-void
-closeout_volume_number ()
-{
- FILE *vf;
-
- vf = fopen (f_volno_file, "w");
- if (!vf)
- msg_perror ("%s", f_volno_file);
- else
- {
- fprintf (vf, "%d\n", global_volno);
- fclose (vf);
- }
-}
-
-/* We've hit the end of the old volume. Close it and open the next one */
-/* Values for type: 0: writing 1: reading 2: updating */
-int
-new_volume (type)
- int type;
-{
- int c;
- char inbuf[80];
- char *p;
- static FILE *read_file = 0;
- extern int now_verifying;
- extern char TTY_NAME[];
- static int looped = 0;
-
- if (!read_file && !f_run_script_at_end)
- read_file = (archive == 0) ? fopen (TTY_NAME, "r") : stdin;
-
- if (now_verifying)
- return -1;
- if (f_verify)
- verify_volume ();
- if ((c = rmtclose (archive)) < 0)
- msg_perror ("Warning: can't close %s(%d,%d)", ar_files[cur_ar_file], archive, c);
-
- global_volno++;
- volno++;
- cur_ar_file++;
- if (cur_ar_file == n_ar_files)
- {
- cur_ar_file = 0;
- looped = 1;
- }
-
-tryagain:
- if (looped)
- {
- /* We have to prompt from now on. */
- if (f_run_script_at_end)
- {
- closeout_volume_number ();
- system (info_script);
- }
- else
- for (;;)
- {
- fprintf (msg_file, "\007Prepare volume #%d for %s and hit return: ", global_volno, ar_files[cur_ar_file]);
- fflush (msg_file);
- if (fgets (inbuf, sizeof (inbuf), read_file) == 0)
- {
- fprintf (msg_file, "EOF? What does that mean?");
- if (cmd_mode != CMD_EXTRACT && cmd_mode != CMD_LIST && cmd_mode != CMD_DIFF)
- msg ("Warning: Archive is INCOMPLETE!");
- exit (EX_BADARCH);
- }
- if (inbuf[0] == '\n' || inbuf[0] == 'y' || inbuf[0] == 'Y')
- break;
-
- switch (inbuf[0])
- {
- case '?':
- {
- fprintf (msg_file, "\
- n [name] Give a new filename for the next (and subsequent) volume(s)\n\
- q Abort tar\n\
- ! Spawn a subshell\n\
- ? Print this list\n");
- }
- break;
-
- case 'q': /* Quit */
- fprintf (msg_file, "No new volume; exiting.\n");
- if (cmd_mode != CMD_EXTRACT && cmd_mode != CMD_LIST && cmd_mode != CMD_DIFF)
- msg ("Warning: Archive is INCOMPLETE!");
- exit (EX_BADARCH);
-
- case 'n': /* Get new file name */
- {
- char *q, *r;
- static char *old_name;
-
- for (q = &inbuf[1]; *q == ' ' || *q == '\t'; q++)
- ;
- for (r = q; *r; r++)
- if (*r == '\n')
- *r = '\0';
- old_name = p = (char *) malloc ((unsigned) (strlen (q) + 2));
- if (p == 0)
- {
- msg ("Can't allocate memory for name");
- exit (EX_SYSTEM);
- }
- (void) strcpy (p, q);
- ar_files[cur_ar_file] = p;
- }
- break;
-
- case '!':
-#ifdef __MSDOS__
- spawnl (P_WAIT, getenv ("COMSPEC"), "-", 0);
-#else
- /* JF this needs work! */
- switch (fork ())
- {
- case -1:
- msg_perror ("can't fork!");
- break;
- case 0:
- p = getenv ("SHELL");
- if (p == 0)
- p = "/bin/sh";
- execlp (p, "-sh", "-i", 0);
- msg_perror ("can't exec a shell %s", p);
- _exit (55);
- default:
- wait (0);
- break;
- }
-#endif
- break;
- }
- }
- }
-
-
- if (type == 2 || f_verify)
- archive = rmtopen (ar_files[cur_ar_file], O_RDWR | O_CREAT, 0666);
- else if (type == 1)
- archive = rmtopen (ar_files[cur_ar_file], O_RDONLY, 0666);
- else if (type == 0)
- archive = rmtcreat (ar_files[cur_ar_file], 0666);
- else
- archive = -1;
-
- if (archive < 0)
- {
- msg_perror ("can't open %s", ar_files[cur_ar_file]);
- goto tryagain;
- }
-#ifdef __MSDOS__
- setmode (archive, O_BINARY);
-#endif
- return 0;
-}
-
-/* this is a useless function that takes a buffer returned by wantbytes
- and does nothing with it. If the function called by wantbytes returns
- an error indicator (non-zero), this function is called for the rest of
- the file.
- */
-int
-no_op (size, data)
- int size;
- char *data;
-{
- return 0;
-}
-
-/* Some other routine wants SIZE bytes in the archive. For each chunk of
- the archive, call FUNC with the size of the chunk, and the address of
- the chunk it can work with.
- */
-int
-wantbytes (size, func)
- long size;
- int (*func) ();
-{
- char *data;
- long data_size;
-
- while (size)
- {
- data = findrec ()->charptr;
- if (data == NULL)
- { /* Check it... */
- msg ("Unexpected EOF on archive file");
- return -1;
- }
- data_size = endofrecs ()->charptr - data;
- if (data_size > size)
- data_size = size;
- if ((*func) (data_size, data))
- func = no_op;
- userec ((union record *) (data + data_size - 1));
- size -= data_size;
- }
- return 0;
-}
diff --git a/gnu/usr.bin/tar/create.c b/gnu/usr.bin/tar/create.c
deleted file mode 100644
index 793dca2..0000000
--- a/gnu/usr.bin/tar/create.c
+++ /dev/null
@@ -1,1478 +0,0 @@
-/* Create a tar archive.
- Copyright (C) 1985, 1992, 1993 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Create a tar archive.
- *
- * Written 25 Aug 1985 by John Gilmore, ihnp4!hoptoad!gnu.
- */
-
-#ifdef _AIX
- #pragma alloca
-#endif
-#include <sys/types.h>
-#include <stdio.h>
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-
-#ifdef BSD42
-#include <sys/file.h>
-#else
-#ifndef V7
-#include <fcntl.h>
-#endif
-#endif
-
-#include "tar.h"
-#include "port.h"
-
-#ifndef __MSDOS__
-#include <pwd.h>
-#include <grp.h>
-#endif
-
-#if defined (_POSIX_VERSION)
-#include <utime.h>
-#else
-struct utimbuf
-{
- long actime;
- long modtime;
-};
-
-#endif
-
-extern struct stat hstat; /* Stat struct corresponding */
-
-#ifndef __MSDOS__
-extern dev_t ar_dev;
-extern ino_t ar_ino;
-#endif
-
-/* JF */
-extern struct name *gnu_list_name;
-
-/*
- * If there are no symbolic links, there is no lstat(). Use stat().
- */
-#ifndef S_ISLNK
-#define lstat stat
-#endif
-
-extern void print_header ();
-
-union record *start_header ();
-void blank_name_list ();
-int check_exclude ();
-PTR ck_malloc ();
-PTR ck_realloc ();
-void clear_buffer ();
-void close_archive ();
-void collect_and_sort_names ();
-int confirm ();
-int deal_with_sparse ();
-void find_new_file_size ();
-void finish_header ();
-int finish_sparse_file ();
-void finduname ();
-void findgname ();
-int is_dot_or_dotdot ();
-void open_archive ();
-char *name_next ();
-void name_close ();
-void to_oct ();
-void dump_file ();
-void write_dir_file ();
-void write_eot ();
-void write_long ();
-int zero_record ();
-
-/* This code moved from tar.h since create.c is the only file that cares
- about 'struct link's. This means that other files might not have to
- include sys/types.h any more. */
-
-struct link
- {
- struct link *next;
- dev_t dev;
- ino_t ino;
- short linkcount;
- char name[1];
- };
-
-struct link *linklist; /* Points to first link in list */
-
-static nolinks; /* Gets set if we run out of RAM */
-
-/*
- * "Scratch" space to store the information about a sparse file before
- * writing the info into the header or extended header
- */
-/* struct sp_array *sparsearray;*/
-
-/* number of elts storable in the sparsearray */
-/*int sparse_array_size = 10;*/
-
-void
-create_archive ()
-{
- register char *p;
- char *name_from_list ();
-
- open_archive (0); /* Open for writing */
-
- if (f_gnudump)
- {
- char *buf = ck_malloc (PATH_MAX);
- char *q, *bufp;
-
- collect_and_sort_names ();
-
- while (p = name_from_list ())
- dump_file (p, -1, 1);
- if(!f_dironly) {
- blank_name_list ();
- while (p = name_from_list ())
- {
- strcpy (buf, p);
- if (p[strlen (p) - 1] != '/')
- strcat (buf, "/");
- bufp = buf + strlen (buf);
- for (q = gnu_list_name->dir_contents; q && *q; q += strlen (q) + 1)
- {
- if (*q == 'Y')
- {
- strcpy (bufp, q + 1);
- dump_file (buf, -1, 1);
- }
- }
- }
- }
- free (buf);
- }
- else
- {
- while (p = name_next (1))
- dump_file (p, -1, 1);
- }
-
- write_eot ();
- close_archive ();
- if (f_gnudump)
- write_dir_file ();
- name_close ();
-}
-
-/*
- * Dump a single file. If it's a directory, recurse.
- * Result is 1 for success, 0 for failure.
- * Sets global "hstat" to stat() output for this file.
- */
-void
-dump_file (p, curdev, toplevel)
- char *p; /* File name to dump */
- int curdev; /* Device our parent dir was on */
- int toplevel; /* Whether we are a toplevel call */
-{
- union record *header;
- char type;
- extern char *save_name; /* JF for multi-volume support */
- extern long save_totsize;
- extern long save_sizeleft;
- union record *exhdr;
- char save_linkflag;
- extern time_t new_time;
- int critical_error = 0;
- struct utimbuf restore_times;
- /* int sparse_ind = 0;*/
-
-
- if (f_confirm && !confirm ("add", p))
- return;
-
- /*
- * Use stat if following (rather than dumping) 4.2BSD's
- * symbolic links. Otherwise, use lstat (which, on non-4.2
- * systems, is #define'd to stat anyway.
- */
-#ifdef STX_HIDDEN /* AIX */
- if (0 != f_follow_links ?
- statx (p, &hstat, STATSIZE, STX_HIDDEN) :
- statx (p, &hstat, STATSIZE, STX_HIDDEN | STX_LINK))
-#else
- if (0 != f_follow_links ? stat (p, &hstat) : lstat (p, &hstat))
-#endif
- {
- badperror:
- msg_perror ("can't add file %s", p);
- badfile:
- if (!f_ignore_failed_read || critical_error)
- errors++;
- return;
- }
-
- restore_times.actime = hstat.st_atime;
- restore_times.modtime = hstat.st_mtime;
-
-#ifdef S_ISHIDDEN
- if (S_ISHIDDEN (hstat.st_mode))
- {
- char *new = (char *) alloca (strlen (p) + 2);
- if (new)
- {
- strcpy (new, p);
- strcat (new, "@");
- p = new;
- }
- }
-#endif
-
- /* See if we only want new files, and check if this one is too old to
- put in the archive. */
- if (f_new_files
- && !f_gnudump
- && new_time > hstat.st_mtime
- && !S_ISDIR (hstat.st_mode)
- && (f_new_files > 1 || new_time > hstat.st_ctime))
- {
- if (curdev == -1)
- {
- msg ("%s: is unchanged; not dumped", p);
- }
- return;
- }
-
-#ifndef __MSDOS__
- /* See if we are trying to dump the archive */
- if (ar_dev && hstat.st_dev == ar_dev && hstat.st_ino == ar_ino)
- {
- msg ("%s is the archive; not dumped", p);
- return;
- }
-#endif
- /*
- * Check for multiple links.
- *
- * We maintain a list of all such files that we've written so
- * far. Any time we see another, we check the list and
- * avoid dumping the data again if we've done it once already.
- */
- if (hstat.st_nlink > 1
- && (S_ISREG (hstat.st_mode)
-#ifdef S_ISCTG
- || S_ISCTG (hstat.st_mode)
-#endif
-#ifdef S_ISCHR
- || S_ISCHR (hstat.st_mode)
-#endif
-#ifdef S_ISBLK
- || S_ISBLK (hstat.st_mode)
-#endif
-#ifdef S_ISFIFO
- || S_ISFIFO (hstat.st_mode)
-#endif
- ))
- {
- register struct link *lp;
-
- /* First quick and dirty. Hashing, etc later FIXME */
- for (lp = linklist; lp; lp = lp->next)
- {
- if (lp->ino == hstat.st_ino &&
- lp->dev == hstat.st_dev)
- {
- char *link_name = lp->name;
-
- /* We found a link. */
- while (!f_absolute_paths && *link_name == '/')
- {
- static int link_warn = 0;
-
- if (!link_warn)
- {
- msg ("Removing leading / from absolute links");
- link_warn++;
- }
- link_name++;
- }
- if (strlen(link_name) >= NAMSIZ)
- write_long (link_name, LF_LONGLINK);
- current_link_name = link_name;
-
- hstat.st_size = 0;
- header = start_header (p, &hstat);
- if (header == NULL)
- {
- critical_error = 1;
- goto badfile;
- }
- strncpy (header->header.arch_linkname,
- link_name, NAMSIZ);
-
- /* Force null truncated */
- header->header.arch_linkname[NAMSIZ - 1] = 0;
-
- header->header.linkflag = LF_LINK;
- finish_header (header);
- /* FIXME: Maybe remove from list after all links found? */
- if (f_remove_files)
- {
- if (unlink (p) == -1)
- msg_perror ("cannot remove %s", p);
- }
- return; /* We dumped it */
- }
- }
-
- /* Not found. Add it to the list of possible links. */
- lp = (struct link *) ck_malloc ((unsigned) (sizeof (struct link) + strlen (p)));
- if (!lp)
- {
- if (!nolinks)
- {
- msg (
- "no memory for links, they will be dumped as separate files");
- nolinks++;
- }
- }
- lp->ino = hstat.st_ino;
- lp->dev = hstat.st_dev;
- strcpy (lp->name, p);
- lp->next = linklist;
- linklist = lp;
- }
-
- /*
- * This is not a link to a previously dumped file, so dump it.
- */
- if (S_ISREG (hstat.st_mode)
-#ifdef S_ISCTG
- || S_ISCTG (hstat.st_mode)
-#endif
- )
- {
- int f; /* File descriptor */
- long bufsize, count;
- long sizeleft;
- register union record *start;
- int header_moved;
- char isextended = 0;
- int upperbound;
- /* int end_nulls = 0; */
-
- header_moved = 0;
-
-#ifdef BSD42
- if (f_sparse_files)
- {
- /*
- * JK - This is the test for sparseness: whether the
- * "size" of the file matches the number of blocks
- * allocated for it. If there is a smaller number
- * of blocks that would be necessary to accommodate
- * a file of this size, we have a sparse file, i.e.,
- * at least one of those records in the file is just
- * a useless hole.
- */
-#ifdef hpux /* Nice of HPUX to gratuitiously change it, huh? - mib */
- if (hstat.st_size - (hstat.st_blocks * 1024) > 1024)
-#else
- if (hstat.st_size - (hstat.st_blocks * RECORDSIZE) > RECORDSIZE)
-#endif
- {
- int filesize = hstat.st_size;
- register int i;
-
- header = start_header (p, &hstat);
- if (header == NULL)
- {
- critical_error = 1;
- goto badfile;
- }
- header->header.linkflag = LF_SPARSE;
- header_moved++;
-
- /*
- * Call the routine that figures out the
- * layout of the sparse file in question.
- * UPPERBOUND is the index of the last
- * element of the "sparsearray," i.e.,
- * the number of elements it needed to
- * describe the file.
- */
-
- upperbound = deal_with_sparse (p, header);
-
- /*
- * See if we'll need an extended header
- * later
- */
- if (upperbound > SPARSE_IN_HDR - 1)
- header->header.isextended++;
- /*
- * We store the "real" file size so
- * we can show that in case someone wants
- * to list the archive, i.e., tar tvf <file>.
- * It might be kind of disconcerting if the
- * shrunken file size was the one that showed
- * up.
- */
- to_oct ((long) hstat.st_size, 1 + 12,
- header->header.realsize);
-
- /*
- * This will be the new "size" of the
- * file, i.e., the size of the file
- * minus the records of holes that we're
- * skipping over.
- */
-
- find_new_file_size (&filesize, upperbound);
- hstat.st_size = filesize;
- to_oct ((long) filesize, 1 + 12,
- header->header.size);
- /* to_oct((long) end_nulls, 1+12,
- header->header.ending_blanks);*/
-
- for (i = 0; i < SPARSE_IN_HDR; i++)
- {
- if (!sparsearray[i].numbytes)
- break;
- to_oct (sparsearray[i].offset, 1 + 12,
- header->header.sp[i].offset);
- to_oct (sparsearray[i].numbytes, 1 + 12,
- header->header.sp[i].numbytes);
- }
-
- }
- }
-#else
- upperbound = SPARSE_IN_HDR - 1;
-#endif
-
- sizeleft = hstat.st_size;
- /* Don't bother opening empty, world readable files. */
- if (sizeleft > 0 || 0444 != (0444 & hstat.st_mode))
- {
- f = open (p, O_RDONLY | O_BINARY);
- if (f < 0)
- goto badperror;
- }
- else
- {
- f = -1;
- }
-
- /* If the file is sparse, we've already taken care of this */
- if (!header_moved)
- {
- header = start_header (p, &hstat);
- if (header == NULL)
- {
- if (f >= 0)
- (void) close (f);
- critical_error = 1;
- goto badfile;
- }
- }
-#ifdef S_ISCTG
- /* Mark contiguous files, if we support them */
- if (f_standard && S_ISCTG (hstat.st_mode))
- {
- header->header.linkflag = LF_CONTIG;
- }
-#endif
- isextended = header->header.isextended;
- save_linkflag = header->header.linkflag;
- finish_header (header);
- if (isextended)
- {
- /* int sum = 0;*/
- register int i;
- /* register union record *exhdr;*/
- /* int arraybound = SPARSE_EXT_HDR;*/
- /* static */ int index_offset = SPARSE_IN_HDR;
-
- extend:exhdr = findrec ();
-
- if (exhdr == NULL)
- {
- critical_error = 1;
- goto badfile;
- }
- bzero (exhdr->charptr, RECORDSIZE);
- for (i = 0; i < SPARSE_EXT_HDR; i++)
- {
- if (i + index_offset > upperbound)
- break;
- to_oct ((long) sparsearray[i + index_offset].numbytes,
- 1 + 12,
- exhdr->ext_hdr.sp[i].numbytes);
- to_oct ((long) sparsearray[i + index_offset].offset,
- 1 + 12,
- exhdr->ext_hdr.sp[i].offset);
- }
- userec (exhdr);
- /* sum += i;
- if (sum < upperbound)
- goto extend;*/
- if (index_offset + i <= upperbound)
- {
- index_offset += i;
- exhdr->ext_hdr.isextended++;
- goto extend;
- }
-
- }
- if (save_linkflag == LF_SPARSE)
- {
- if (finish_sparse_file (f, &sizeleft, (long) hstat.st_size, p))
- goto padit;
- }
- else
- while (sizeleft > 0)
- {
-
- if (f_multivol)
- {
- save_name = p;
- save_sizeleft = sizeleft;
- save_totsize = hstat.st_size;
- }
- start = findrec ();
-
- bufsize = endofrecs ()->charptr - start->charptr;
-
- if (sizeleft < bufsize)
- {
- /* Last read -- zero out area beyond */
- bufsize = (int) sizeleft;
- count = bufsize % RECORDSIZE;
- if (count)
- bzero (start->charptr + sizeleft,
- (int) (RECORDSIZE - count));
- }
- count = read (f, start->charptr, bufsize);
- if (count < 0)
- {
- msg_perror ("read error at byte %ld, reading\
- %d bytes, in file %s", (long) hstat.st_size - sizeleft, bufsize, p);
- goto padit;
- }
- sizeleft -= count;
-
- /* This is nonportable (the type of userec's arg). */
- userec (start + (count - 1) / RECORDSIZE);
-
- if (count == bufsize)
- continue;
- msg ("file %s shrunk by %d bytes, padding with zeros.", p, sizeleft);
- goto padit; /* Short read */
- }
-
- if (f_multivol)
- save_name = 0;
-
- if (f >= 0)
- (void) close (f);
-
- if (f_remove_files)
- {
- if (unlink (p) == -1)
- msg_perror ("cannot remove %s", p);
- }
- if (f_atime_preserve)
- utime (p, &restore_times);
- return;
-
- /*
- * File shrunk or gave error, pad out tape to match
- * the size we specified in the header.
- */
- padit:
- while (sizeleft > 0)
- {
- save_sizeleft = sizeleft;
- start = findrec ();
- bzero (start->charptr, RECORDSIZE);
- userec (start);
- sizeleft -= RECORDSIZE;
- }
- if (f_multivol)
- save_name = 0;
- if (f >= 0)
- (void) close (f);
- if (f_atime_preserve)
- utime (p, &restore_times);
- return;
- }
-
-#ifdef S_ISLNK
- else if (S_ISLNK (hstat.st_mode))
- {
- int size;
- char *buf = alloca (PATH_MAX + 1);
-
- size = readlink (p, buf, PATH_MAX + 1);
- if (size < 0)
- goto badperror;
- buf[size] = '\0';
- if (size >= NAMSIZ)
- write_long (buf, LF_LONGLINK);
- current_link_name = buf;
-
- hstat.st_size = 0; /* Force 0 size on symlink */
- header = start_header (p, &hstat);
- if (header == NULL)
- {
- critical_error = 1;
- goto badfile;
- }
- strncpy (header->header.arch_linkname, buf, NAMSIZ);
- header->header.arch_linkname[NAMSIZ - 1] = '\0';
- header->header.linkflag = LF_SYMLINK;
- finish_header (header); /* Nothing more to do to it */
- if (f_remove_files)
- {
- if (unlink (p) == -1)
- msg_perror ("cannot remove %s", p);
- }
- return;
- }
-#endif
-
- else if (S_ISDIR (hstat.st_mode))
- {
- register DIR *dirp;
- register struct dirent *d;
- char *namebuf;
- int buflen;
- register int len;
- int our_device = hstat.st_dev;
-
- /* Build new prototype name */
- len = strlen (p);
- buflen = len + NAMSIZ;
- namebuf = ck_malloc (buflen + 1);
- strncpy (namebuf, p, buflen);
- while (len >= 1 && '/' == namebuf[len - 1])
- len--; /* Delete trailing slashes */
- namebuf[len++] = '/'; /* Now add exactly one back */
- namebuf[len] = '\0'; /* Make sure null-terminated */
-
- /*
- * Output directory header record with permissions
- * FIXME, do this AFTER files, to avoid R/O dir problems?
- * If old archive format, don't write record at all.
- */
- if (!f_oldarch)
- {
- hstat.st_size = 0; /* Force 0 size on dir */
- /*
- * If people could really read standard archives,
- * this should be: (FIXME)
- header = start_header(f_standard? p: namebuf, &hstat);
- * but since they'd interpret LF_DIR records as
- * regular files, we'd better put the / on the name.
- */
- header = start_header (namebuf, &hstat);
- if (header == NULL)
- {
- critical_error = 1;
- goto badfile; /* eg name too long */
- }
-
- if (f_gnudump)
- header->header.linkflag = LF_DUMPDIR;
- else if (f_standard)
- header->header.linkflag = LF_DIR;
-
- /* If we're gnudumping, we aren't done yet so don't close it. */
- if (!f_gnudump)
- finish_header (header); /* Done with directory header */
- }
-
- if (f_gnudump)
- {
- int sizeleft;
- int totsize;
- int bufsize;
- union record *start;
- int count;
- char *buf, *p_buf;
-
- buf = gnu_list_name->dir_contents; /* FOO */
- totsize = 0;
- for (p_buf = buf; p_buf && *p_buf;)
- {
- int tmp;
-
- tmp = strlen (p_buf) + 1;
- totsize += tmp;
- p_buf += tmp;
- }
- totsize++;
- to_oct ((long) totsize, 1 + 12, header->header.size);
- finish_header (header);
- p_buf = buf;
- sizeleft = totsize;
- while (sizeleft > 0)
- {
- if (f_multivol)
- {
- save_name = p;
- save_sizeleft = sizeleft;
- save_totsize = totsize;
- }
- start = findrec ();
- bufsize = endofrecs ()->charptr - start->charptr;
- if (sizeleft < bufsize)
- {
- bufsize = sizeleft;
- count = bufsize % RECORDSIZE;
- if (count)
- bzero (start->charptr + sizeleft, RECORDSIZE - count);
- }
- bcopy (p_buf, start->charptr, bufsize);
- sizeleft -= bufsize;
- p_buf += bufsize;
- userec (start + (bufsize - 1) / RECORDSIZE);
- }
- if (f_multivol)
- save_name = 0;
- if (f_atime_preserve)
- utime (p, &restore_times);
- return;
- }
-
- /* Now output all the files in the directory */
- if (f_dironly)
- return; /* Unless the cmdline said not to */
- /*
- * See if we are crossing from one file system to another,
- * and avoid doing so if the user only wants to dump one file system.
- */
- if (f_local_filesys && !toplevel && curdev != hstat.st_dev)
- {
- if (f_verbose)
- msg ("%s: is on a different filesystem; not dumped", p);
- return;
- }
-
-
- errno = 0;
- dirp = opendir (p);
- if (!dirp)
- {
- if (errno)
- {
- msg_perror ("can't open directory %s", p);
- }
- else
- {
- msg ("error opening directory %s",
- p);
- }
- return;
- }
-
- /* Hack to remove "./" from the front of all the file names */
- if (len == 2 && namebuf[0] == '.' && namebuf[1] == '/')
- len = 0;
-
- /* Should speed this up by cd-ing into the dir, FIXME */
- while (NULL != (d = readdir (dirp)))
- {
- /* Skip . and .. */
- if (is_dot_or_dotdot (d->d_name))
- continue;
-
- if (NLENGTH (d) + len >= buflen)
- {
- buflen = len + NLENGTH (d);
- namebuf = ck_realloc (namebuf, buflen + 1);
- /* namebuf[len]='\0';
- msg("file name %s%s too long",
- namebuf, d->d_name);
- continue; */
- }
- strcpy (namebuf + len, d->d_name);
- if (f_exclude && check_exclude (namebuf))
- continue;
- dump_file (namebuf, our_device, 0);
- }
-
- closedir (dirp);
- free (namebuf);
- if (f_atime_preserve)
- utime (p, &restore_times);
- return;
- }
-
-#ifdef S_ISCHR
- else if (S_ISCHR (hstat.st_mode))
- {
- type = LF_CHR;
- }
-#endif
-
-#ifdef S_ISBLK
- else if (S_ISBLK (hstat.st_mode))
- {
- type = LF_BLK;
- }
-#endif
-
- /* Avoid screwy apollo lossage where S_IFIFO == S_IFSOCK */
-#if (_ISP__M68K == 0) && (_ISP__A88K == 0) && defined(S_ISFIFO)
- else if (S_ISFIFO (hstat.st_mode))
- {
- type = LF_FIFO;
- }
-#endif
-
-#ifdef S_ISSOCK
- else if (S_ISSOCK (hstat.st_mode))
- {
- type = LF_FIFO;
- }
-#endif
- else
- goto unknown;
-
- if (!f_standard)
- goto unknown;
-
- hstat.st_size = 0; /* Force 0 size */
- header = start_header (p, &hstat);
- if (header == NULL)
- {
- critical_error = 1;
- goto badfile; /* eg name too long */
- }
-
- header->header.linkflag = type;
-#if defined(S_IFBLK) || defined(S_IFCHR)
- if (type != LF_FIFO)
- {
- if (checked_to_oct ((long) major (hstat.st_rdev), 8,
- header->header.devmajor))
- {
- msg ("%s: major number too large; not dumped", p);
- critical_error = 1;
- goto badfile;
- }
- if (checked_to_oct ((long) minor (hstat.st_rdev), 8,
- header->header.devminor))
- {
- msg ("%s: minor number too large; not dumped", p);
- critical_error = 1;
- goto badfile;
- }
- }
-#endif
-
- finish_header (header);
- if (f_remove_files)
- {
- if (unlink (p) == -1)
- msg_perror ("cannot remove %s", p);
- }
- return;
-
-unknown:
- msg ("%s: Unknown file type; file ignored.", p);
-}
-
-int
-finish_sparse_file (fd, sizeleft, fullsize, name)
- int fd;
- long *sizeleft, fullsize;
- char *name;
-{
- union record *start;
- char tempbuf[RECORDSIZE];
- int bufsize, sparse_ind = 0, count;
- long pos;
- long nwritten = 0;
-
-
- while (*sizeleft > 0)
- {
- start = findrec ();
- bzero (start->charptr, RECORDSIZE);
- bufsize = sparsearray[sparse_ind].numbytes;
- if (!bufsize)
- { /* we blew it, maybe */
- msg ("Wrote %ld of %ld bytes to file %s",
- fullsize - *sizeleft, fullsize, name);
- break;
- }
- pos = lseek (fd, sparsearray[sparse_ind++].offset, 0);
- /*
- * If the number of bytes to be written here exceeds
- * the size of the temporary buffer, do it in steps.
- */
- while (bufsize > RECORDSIZE)
- {
- /* if (amt_read) {
- count = read(fd, start->charptr+amt_read, RECORDSIZE-amt_read);
- bufsize -= RECORDSIZE - amt_read;
- amt_read = 0;
- userec(start);
- start = findrec();
- bzero(start->charptr, RECORDSIZE);
- }*/
- /* store the data */
- count = read (fd, start->charptr, RECORDSIZE);
- if (count < 0)
- {
- msg_perror ("read error at byte %ld, reading %d bytes, in file %s",
- fullsize - *sizeleft, bufsize, name);
- return 1;
- }
- bufsize -= count;
- *sizeleft -= count;
- userec (start);
- nwritten += RECORDSIZE; /* XXX */
- start = findrec ();
- bzero (start->charptr, RECORDSIZE);
- }
-
-
- clear_buffer (tempbuf);
- count = read (fd, tempbuf, bufsize);
- bcopy (tempbuf, start->charptr, RECORDSIZE);
- if (count < 0)
- {
- msg_perror ("read error at byte %ld, reading %d bytes, in file %s",
- fullsize - *sizeleft, bufsize, name);
- return 1;
- }
- /* if (amt_read >= RECORDSIZE) {
- amt_read = 0;
- userec(start+(count-1)/RECORDSIZE);
- if (count != bufsize) {
- msg("file %s shrunk by %d bytes, padding with zeros.", name, sizeleft);
- return 1;
- }
- start = findrec();
- } else
- amt_read += bufsize;*/
- nwritten += count; /* XXX */
- *sizeleft -= count;
- userec (start);
-
- }
- free (sparsearray);
- /* printf ("Amount actually written is (I hope) %d.\n", nwritten); */
- /* userec(start+(count-1)/RECORDSIZE);*/
- return 0;
-
-}
-
-void
-init_sparsearray ()
-{
- register int i;
-
- sp_array_size = 10;
- /*
- * Make room for our scratch space -- initially is 10 elts long
- */
- sparsearray = (struct sp_array *) ck_malloc (sp_array_size * sizeof (struct sp_array));
- for (i = 0; i < sp_array_size; i++)
- {
- sparsearray[i].offset = 0;
- sparsearray[i].numbytes = 0;
- }
-}
-
-
-
-/*
- * Okay, we've got a sparse file on our hands -- now, what we need to do is
- * make a pass through the file and carefully note where any data is, i.e.,
- * we want to find how far into the file each instance of data is, and how
- * many bytes are there. We store this information in the sparsearray,
- * which will later be translated into header information. For now, we use
- * the sparsearray as convenient storage.
- *
- * As a side note, this routine is a mess. If I could have found a cleaner
- * way to do it, I would have. If anyone wants to find a nicer way to do
- * this, feel free.
- */
-
-/* There is little point in trimming small amounts of null data at the */
-/* head and tail of blocks -- it's ok if we only avoid dumping blocks */
-/* of complete null data */
-int
-deal_with_sparse (name, header, nulls_at_end)
- char *name;
- union record *header;
- int nulls_at_end;
-{
- long numbytes = 0;
- long offset = 0;
- /* long save_offset;*/
- int fd;
- /* int current_size = hstat.st_size;*/
- int sparse_ind = 0, cc;
- char buf[RECORDSIZE];
-#if 0
- int read_last_data = 0; /* did we just read the last record? */
-#endif
- int amidst_data = 0;
-
- header->header.isextended = 0;
- /*
- * Can't open the file -- this problem will be caught later on,
- * so just return.
- */
- if ((fd = open (name, O_RDONLY)) < 0)
- return 0;
-
- init_sparsearray ();
- clear_buffer (buf);
-
- while ((cc = read (fd, buf, sizeof buf)) != 0)
- {
-
- if (sparse_ind > sp_array_size - 1)
- {
-
- /*
- * realloc the scratch area, since we've run out of room --
- */
- sparsearray = (struct sp_array *)
- ck_realloc (sparsearray,
- 2 * sp_array_size * (sizeof (struct sp_array)));
- sp_array_size *= 2;
- }
- if (cc == sizeof buf)
- {
- if (zero_record (buf))
- {
- if (amidst_data)
- {
- sparsearray[sparse_ind++].numbytes
- = numbytes;
- amidst_data = 0;
- }
- }
- else
- { /* !zero_record(buf) */
- if (amidst_data)
- numbytes += cc;
- else
- {
- amidst_data = 1;
- numbytes = cc;
- sparsearray[sparse_ind].offset
- = offset;
- }
- }
- }
- else if (cc < sizeof buf)
- {
- /* This has to be the last bit of the file, so this */
- /* is somewhat shorter than the above. */
- if (!zero_record (buf))
- {
- if (!amidst_data)
- {
- amidst_data = 1;
- numbytes = cc;
- sparsearray[sparse_ind].offset
- = offset;
- }
- else
- numbytes += cc;
- }
- }
- offset += cc;
- clear_buffer (buf);
- }
- if (amidst_data)
- sparsearray[sparse_ind++].numbytes = numbytes;
- else
- {
- sparsearray[sparse_ind].offset = offset-1;
- sparsearray[sparse_ind++].numbytes = 1;
- }
- close (fd);
-
- return sparse_ind - 1;
-}
-
-/*
- * Just zeroes out the buffer so we don't confuse ourselves with leftover
- * data.
- */
-void
-clear_buffer (buf)
- char *buf;
-{
- register int i;
-
- for (i = 0; i < RECORDSIZE; i++)
- buf[i] = '\0';
-}
-
-#if 0 /* I'm leaving this as a monument to Joy Kendall, who wrote it -mib */
-/*
- * JK -
- * This routine takes a character array, and tells where within that array
- * the data can be found. It skips over any zeros, and sets the first
- * non-zero point in the array to be the "start", and continues until it
- * finds non-data again, which is marked as the "end." This routine is
- * mainly for 1) seeing how far into a file we must lseek to data, given
- * that we have a sparse file, and 2) determining the "real size" of the
- * file, i.e., the number of bytes in the sparse file that are data, as
- * opposed to the zeros we are trying to skip.
- */
-where_is_data (from, to, buffer)
- int *from, *to;
- char *buffer;
-{
- register int i = 0;
- register int save_to = *to;
- int amidst_data = 0;
-
-
- while (!buffer[i])
- i++;
- *from = i;
-
- if (*from < 16) /* don't bother */
- *from = 0;
- /* keep going to make sure there isn't more real
- data in this record */
- while (i < RECORDSIZE)
- {
- if (!buffer[i])
- {
- if (amidst_data)
- {
- save_to = i;
- amidst_data = 0;
- }
- i++;
- }
- else if (buffer[i])
- {
- if (!amidst_data)
- amidst_data = 1;
- i++;
- }
- }
- if (i == RECORDSIZE)
- *to = i;
- else
- *to = save_to;
-
-}
-
-#endif
-
-/* Note that this routine is only called if zero_record returned true */
-#if 0 /* But we actually don't need it at all. */
-where_is_data (from, to, buffer)
- int *from, *to;
- char *buffer;
-{
- char *fp, *tp;
-
- for (fp = buffer; !*fp; fp++)
- ;
- for (tp = buffer + RECORDSIZE - 1; !*tp; tp--)
- ;
- *from = fp - buffer;
- *to = tp - buffer + 1;
-}
-
-#endif
-
-
-
-/*
- * Takes a recordful of data and basically cruises through it to see if
- * it's made *entirely* of zeros, returning a 0 the instant it finds
- * something that is a non-zero, i.e., useful data.
- */
-int
-zero_record (buffer)
- char *buffer;
-{
- register int i;
-
- for (i = 0; i < RECORDSIZE; i++)
- if (buffer[i] != '\000')
- return 0;
- return 1;
-}
-
-void
-find_new_file_size (filesize, highest_index)
- int *filesize;
- int highest_index;
-{
- register int i;
-
- *filesize = 0;
- for (i = 0; sparsearray[i].numbytes && i <= highest_index; i++)
- *filesize += sparsearray[i].numbytes;
-}
-
-/*
- * Make a header block for the file name whose stat info is st .
- * Return header pointer for success, NULL if the name is too long.
- */
-union record *
-start_header (name, st)
- char *name;
- register struct stat *st;
-{
- register union record *header;
-
- if (strlen (name) >= NAMSIZ)
- write_long (name, LF_LONGNAME);
-
- header = (union record *) findrec ();
- bzero (header->charptr, sizeof (*header)); /* XXX speed up */
-
- /*
- * Check the file name and put it in the record.
- */
- if (!f_absolute_paths)
- {
- static int warned_once = 0;
-#ifdef __MSDOS__
- if (name[1] == ':')
- {
- name += 2;
- if (!warned_once++)
- msg ("Removing drive spec from names in the archive");
- }
-#endif
- while ('/' == *name)
- {
- name++; /* Force relative path */
- if (!warned_once++)
- msg ("Removing leading / from absolute path names in the archive.");
- }
- }
- current_file_name = name;
- strncpy (header->header.arch_name, name, NAMSIZ);
- header->header.arch_name[NAMSIZ - 1] = '\0';
-
- to_oct ((long) (f_oldarch ? (st->st_mode & 07777) : st->st_mode),
- 8, header->header.mode);
- to_oct ((long) st->st_uid, 8, header->header.uid);
- to_oct ((long) st->st_gid, 8, header->header.gid);
- to_oct ((long) st->st_size, 1 + 12, header->header.size);
- to_oct ((long) st->st_mtime, 1 + 12, header->header.mtime);
- /* header->header.linkflag is left as null */
- if (f_gnudump)
- {
- to_oct ((long) st->st_atime, 1 + 12, header->header.atime);
- to_oct ((long) st->st_ctime, 1 + 12, header->header.ctime);
- }
-
-#ifndef NONAMES
- /* Fill in new Unix Standard fields if desired. */
- if (f_standard)
- {
- header->header.linkflag = LF_NORMAL; /* New default */
- strcpy (header->header.magic, TMAGIC); /* Mark as Unix Std */
- finduname (header->header.uname, st->st_uid);
- findgname (header->header.gname, st->st_gid);
- }
-#endif
- return header;
-}
-
-/*
- * Finish off a filled-in header block and write it out.
- * We also print the file name and/or full info if verbose is on.
- */
-void
-finish_header (header)
- register union record *header;
-{
- register int i, sum;
- register char *p;
-
- bcopy (CHKBLANKS, header->header.chksum, sizeof (header->header.chksum));
-
- sum = 0;
- p = header->charptr;
- for (i = sizeof (*header); --i >= 0;)
- {
- /*
- * We can't use unsigned char here because of old compilers,
- * e.g. V7.
- */
- sum += 0xFF & *p++;
- }
-
- /*
- * Fill in the checksum field. It's formatted differently
- * from the other fields: it has [6] digits, a null, then a
- * space -- rather than digits, a space, then a null.
- * We use to_oct then write the null in over to_oct's space.
- * The final space is already there, from checksumming, and
- * to_oct doesn't modify it.
- *
- * This is a fast way to do:
- * (void) sprintf(header->header.chksum, "%6o", sum);
- */
- to_oct ((long) sum, 8, header->header.chksum);
- header->header.chksum[6] = '\0'; /* Zap the space */
-
- userec (header);
-
- if (f_verbose)
- {
- extern union record *head;/* Points to current tape header */
- extern int head_standard; /* Tape header is in ANSI format */
-
- /* These globals are parameters to print_header, sigh */
- head = header;
- /* hstat is already set up */
- head_standard = f_standard;
- print_header ();
- }
-
- return;
-}
-
-
-/*
- * Quick and dirty octal conversion.
- * Converts long "value" into a "digs"-digit field at "where",
- * including a trailing space and room for a null. "digs"==3 means
- * 1 digit, a space, and room for a null.
- *
- * We assume the trailing null is already there and don't fill it in.
- * This fact is used by start_header and finish_header, so don't change it!
- *
- * This should be equivalent to:
- * (void) sprintf(where, "%*lo ", digs-2, value);
- * except that sprintf fills in the trailing null and we don't.
- */
-void
-to_oct (value, digs, where)
- register long value;
- register int digs;
- register char *where;
-{
-
- --digs; /* Trailing null slot is left alone */
- where[--digs] = ' '; /* Put in the space, though */
-
- /* Produce the digits -- at least one */
- do
- {
- where[--digs] = '0' + (char) (value & 7); /* one octal digit */
- value >>= 3;
- }
- while (digs > 0 && value != 0);
-
- /* Leading spaces, if necessary */
- while (digs > 0)
- where[--digs] = ' ';
-
-}
-
-
-/*
- * Call to_oct (), then return nonzero iff the conversion failed.
- */
-int
-checked_to_oct (value, digs, where)
- register long value;
- register int digs;
- register char *where;
-{
- long from_oct ();
-
- to_oct (value, digs, where);
- return from_oct (digs, where) != value;
-}
-
-
-/*
- * Write the EOT record(s).
- * We actually zero at least one record, through the end of the block.
- * Old tar writes garbage after two zeroed records -- and PDtar used to.
- */
-void
-write_eot ()
-{
- union record *p;
- int bufsize;
-
- p = findrec ();
- if (p)
- {
- bufsize = endofrecs ()->charptr - p->charptr;
- bzero (p->charptr, bufsize);
- userec (p);
- }
-}
-
-/* Write a LF_LONGLINK or LF_LONGNAME record. */
-void
-write_long (p, type)
- char *p;
- char type;
-{
- int size = strlen (p) + 1;
- int bufsize;
- union record *header;
- struct stat foo;
-
-
- bzero (&foo, sizeof foo);
- foo.st_size = size;
-
- header = start_header ("././@LongLink", &foo);
- header->header.linkflag = type;
- finish_header (header);
-
- header = findrec ();
-
- bufsize = endofrecs ()->charptr - header->charptr;
-
- while (bufsize < size)
- {
- bcopy (p, header->charptr, bufsize);
- p += bufsize;
- size -= bufsize;
- userec (header + (bufsize - 1) / RECORDSIZE);
- header = findrec ();
- bufsize = endofrecs ()->charptr - header->charptr;
- }
- bcopy (p, header->charptr, size);
- bzero (header->charptr + size, bufsize - size);
- userec (header + (size - 1) / RECORDSIZE);
-}
diff --git a/gnu/usr.bin/tar/diffarch.c b/gnu/usr.bin/tar/diffarch.c
deleted file mode 100644
index ce47d9d..0000000
--- a/gnu/usr.bin/tar/diffarch.c
+++ /dev/null
@@ -1,759 +0,0 @@
-/* Diff files from a tar archive.
- Copyright (C) 1988, 1992, 1993 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Diff files from a tar archive.
- *
- * Written 30 April 1987 by John Gilmore, ihnp4!hoptoad!gnu.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-#include <sys/types.h>
-
-#ifdef BSD42
-#include <sys/file.h>
-#else
-#ifndef V7
-#include <fcntl.h>
-#endif
-#endif
-
-#ifdef HAVE_SYS_MTIO_H
-#include <sys/ioctl.h>
-#include <sys/mtio.h>
-#endif
-
-#include "tar.h"
-#include "port.h"
-#include "rmt.h"
-
-#ifndef S_ISLNK
-#define lstat stat
-#endif
-
-extern void *valloc ();
-
-extern union record *head; /* Points to current tape header */
-extern struct stat hstat; /* Stat struct corresponding */
-extern int head_standard; /* Tape header is in ANSI format */
-
-void decode_header ();
-void diff_sparse_files ();
-void fill_in_sparse_array ();
-void fl_read ();
-long from_oct ();
-int do_stat ();
-extern void print_header ();
-int read_header ();
-void saverec ();
-void sigh ();
-extern void skip_file ();
-extern void skip_extended_headers ();
-int wantbytes ();
-
-extern FILE *msg_file;
-
-int now_verifying = 0; /* Are we verifying at the moment? */
-
-int diff_fd; /* Descriptor of file we're diffing */
-
-char *diff_buf = 0; /* Pointer to area for reading
- file contents into */
-
-char *diff_dir; /* Directory contents for LF_DUMPDIR */
-
-int different = 0;
-
-/*struct sp_array *sparsearray;
-int sp_ar_size = 10;*/
-/*
- * Initialize for a diff operation
- */
-void
-diff_init ()
-{
- /*NOSTRICT*/
- diff_buf = (char *) valloc ((unsigned) blocksize);
- if (!diff_buf)
- {
- msg ("could not allocate memory for diff buffer of %d bytes",
- blocksize);
- exit (EX_ARGSBAD);
- }
-}
-
-/*
- * Diff a file against the archive.
- */
-void
-diff_archive ()
-{
- register char *data;
- int check, namelen;
- int err;
- long offset;
- struct stat filestat;
- int compare_chunk ();
- int compare_dir ();
- int no_op ();
-#ifndef __MSDOS__
- dev_t dev;
- ino_t ino;
-#endif
- char *get_dir_contents ();
- long from_oct ();
-
- errno = EPIPE; /* FIXME, remove perrors */
-
- saverec (&head); /* Make sure it sticks around */
- userec (head); /* And go past it in the archive */
- decode_header (head, &hstat, &head_standard, 1); /* Snarf fields */
-
- /* Print the record from 'head' and 'hstat' */
- if (f_verbose)
- {
- if (now_verifying)
- fprintf (msg_file, "Verify ");
- print_header ();
- }
-
- switch (head->header.linkflag)
- {
-
- default:
- msg ("Unknown file type '%c' for %s, diffed as normal file",
- head->header.linkflag, current_file_name);
- /* FALL THRU */
-
- case LF_OLDNORMAL:
- case LF_NORMAL:
- case LF_SPARSE:
- case LF_CONTIG:
- /*
- * Appears to be a file.
- * See if it's really a directory.
- */
- namelen = strlen (current_file_name) - 1;
- if (current_file_name[namelen] == '/')
- goto really_dir;
-
-
- if (do_stat (&filestat))
- {
- if (head->header.isextended)
- skip_extended_headers ();
- skip_file ((long) hstat.st_size);
- different++;
- goto quit;
- }
-
- if (!S_ISREG (filestat.st_mode))
- {
- fprintf (msg_file, "%s: not a regular file\n",
- current_file_name);
- skip_file ((long) hstat.st_size);
- different++;
- goto quit;
- }
-
- filestat.st_mode &= 07777;
- if (filestat.st_mode != hstat.st_mode)
- sigh ("mode");
- if (filestat.st_uid != hstat.st_uid)
- sigh ("uid");
- if (filestat.st_gid != hstat.st_gid)
- sigh ("gid");
- if (filestat.st_mtime != hstat.st_mtime)
- sigh ("mod time");
- if (head->header.linkflag != LF_SPARSE &&
- filestat.st_size != hstat.st_size)
- {
- sigh ("size");
- skip_file ((long) hstat.st_size);
- goto quit;
- }
-
- diff_fd = open (current_file_name, O_NDELAY | O_RDONLY | O_BINARY);
-
- if (diff_fd < 0 && !f_absolute_paths)
- {
- char tmpbuf[NAMSIZ + 2];
-
- tmpbuf[0] = '/';
- strcpy (&tmpbuf[1], current_file_name);
- diff_fd = open (tmpbuf, O_NDELAY | O_RDONLY);
- }
- if (diff_fd < 0)
- {
- msg_perror ("cannot open %s", current_file_name);
- if (head->header.isextended)
- skip_extended_headers ();
- skip_file ((long) hstat.st_size);
- different++;
- goto quit;
- }
- /*
- * Need to treat sparse files completely differently here.
- */
- if (head->header.linkflag == LF_SPARSE)
- diff_sparse_files (hstat.st_size);
- else
- wantbytes ((long) (hstat.st_size), compare_chunk);
-
- check = close (diff_fd);
- if (check < 0)
- msg_perror ("Error while closing %s", current_file_name);
-
- quit:
- break;
-
-#ifndef __MSDOS__
- case LF_LINK:
- if (do_stat (&filestat))
- break;
- dev = filestat.st_dev;
- ino = filestat.st_ino;
- err = stat (current_link_name, &filestat);
- if (err < 0)
- {
- if (errno == ENOENT)
- {
- fprintf (msg_file, "%s: does not exist\n", current_file_name);
- }
- else
- {
- msg_perror ("cannot stat file %s", current_file_name);
- }
- different++;
- break;
- }
- if (filestat.st_dev != dev || filestat.st_ino != ino)
- {
- fprintf (msg_file, "%s not linked to %s\n", current_file_name, current_link_name);
- break;
- }
- break;
-#endif
-
-#ifdef S_ISLNK
- case LF_SYMLINK:
- {
- char linkbuf[NAMSIZ + 3];
- check = readlink (current_file_name, linkbuf,
- (sizeof linkbuf) - 1);
-
- if (check < 0)
- {
- if (errno == ENOENT)
- {
- fprintf (msg_file,
- "%s: no such file or directory\n",
- current_file_name);
- }
- else
- {
- msg_perror ("cannot read link %s", current_file_name);
- }
- different++;
- break;
- }
-
- linkbuf[check] = '\0'; /* Null-terminate it */
- if (strncmp (current_link_name, linkbuf, check) != 0)
- {
- fprintf (msg_file, "%s: symlink differs\n",
- current_link_name);
- different++;
- }
- }
- break;
-#endif
-
-#ifdef S_IFCHR
- case LF_CHR:
- hstat.st_mode |= S_IFCHR;
- goto check_node;
-#endif
-
-#ifdef S_IFBLK
- /* If local system doesn't support block devices, use default case */
- case LF_BLK:
- hstat.st_mode |= S_IFBLK;
- goto check_node;
-#endif
-
-#ifdef S_ISFIFO
- /* If local system doesn't support FIFOs, use default case */
- case LF_FIFO:
-#ifdef S_IFIFO
- hstat.st_mode |= S_IFIFO;
-#endif
- hstat.st_rdev = 0; /* FIXME, do we need this? */
- goto check_node;
-#endif
-
- check_node:
- /* FIXME, deal with umask */
- if (do_stat (&filestat))
- break;
- if (hstat.st_rdev != filestat.st_rdev)
- {
- fprintf (msg_file, "%s: device numbers changed\n", current_file_name);
- different++;
- break;
- }
-#ifdef S_IFMT
- if (hstat.st_mode != filestat.st_mode)
-#else /* POSIX lossage */
- if ((hstat.st_mode & 07777) != (filestat.st_mode & 07777))
-#endif
- {
- fprintf (msg_file, "%s: mode or device-type changed\n", current_file_name);
- different++;
- break;
- }
- break;
-
- case LF_DUMPDIR:
- data = diff_dir = get_dir_contents (current_file_name, 0);
- if (data)
- {
- wantbytes ((long) (hstat.st_size), compare_dir);
- free (data);
- }
- else
- wantbytes ((long) (hstat.st_size), no_op);
- /* FALL THROUGH */
-
- case LF_DIR:
- /* Check for trailing / */
- namelen = strlen (current_file_name) - 1;
- really_dir:
- while (namelen && current_file_name[namelen] == '/')
- current_file_name[namelen--] = '\0'; /* Zap / */
-
- if (do_stat (&filestat))
- break;
- if (!S_ISDIR (filestat.st_mode))
- {
- fprintf (msg_file, "%s is no longer a directory\n", current_file_name);
- different++;
- break;
- }
- if ((filestat.st_mode & 07777) != (hstat.st_mode & 07777))
- sigh ("mode");
- break;
-
- case LF_VOLHDR:
- break;
-
- case LF_MULTIVOL:
- namelen = strlen (current_file_name) - 1;
- if (current_file_name[namelen] == '/')
- goto really_dir;
-
- if (do_stat (&filestat))
- break;
-
- if (!S_ISREG (filestat.st_mode))
- {
- fprintf (msg_file, "%s: not a regular file\n",
- current_file_name);
- skip_file ((long) hstat.st_size);
- different++;
- break;
- }
-
- filestat.st_mode &= 07777;
- offset = from_oct (1 + 12, head->header.offset);
- if (filestat.st_size != hstat.st_size + offset)
- {
- sigh ("size");
- skip_file ((long) hstat.st_size);
- different++;
- break;
- }
-
- diff_fd = open (current_file_name, O_NDELAY | O_RDONLY | O_BINARY);
-
- if (diff_fd < 0)
- {
- msg_perror ("cannot open file %s", current_file_name);
- skip_file ((long) hstat.st_size);
- different++;
- break;
- }
- err = lseek (diff_fd, offset, 0);
- if (err != offset)
- {
- msg_perror ("cannot seek to %ld in file %s", offset, current_file_name);
- different++;
- break;
- }
-
- wantbytes ((long) (hstat.st_size), compare_chunk);
-
- check = close (diff_fd);
- if (check < 0)
- {
- msg_perror ("Error while closing %s", current_file_name);
- }
- break;
-
- }
-
- /* We don't need to save it any longer. */
- saverec ((union record **) 0);/* Unsave it */
-}
-
-int
-compare_chunk (bytes, buffer)
- long bytes;
- char *buffer;
-{
- int err;
-
- err = read (diff_fd, diff_buf, bytes);
- if (err != bytes)
- {
- if (err < 0)
- {
- msg_perror ("can't read %s", current_file_name);
- }
- else
- {
- fprintf (msg_file, "%s: could only read %d of %d bytes\n", current_file_name, err, bytes);
- }
- different++;
- return -1;
- }
- if (bcmp (buffer, diff_buf, bytes))
- {
- fprintf (msg_file, "%s: data differs\n", current_file_name);
- different++;
- return -1;
- }
- return 0;
-}
-
-int
-compare_dir (bytes, buffer)
- long bytes;
- char *buffer;
-{
- if (bcmp (buffer, diff_dir, bytes))
- {
- fprintf (msg_file, "%s: data differs\n", current_file_name);
- different++;
- return -1;
- }
- diff_dir += bytes;
- return 0;
-}
-
-/*
- * Sigh about something that differs.
- */
-void
-sigh (what)
- char *what;
-{
-
- fprintf (msg_file, "%s: %s differs\n",
- current_file_name, what);
-}
-
-void
-verify_volume ()
-{
- int status;
-#ifdef MTIOCTOP
- struct mtop t;
- int er;
-#endif
-
- if (!diff_buf)
- diff_init ();
-#ifdef MTIOCTOP
- t.mt_op = MTBSF;
- t.mt_count = 1;
- if ((er = rmtioctl (archive, MTIOCTOP, &t)) < 0)
- {
- if (errno != EIO || (er = rmtioctl (archive, MTIOCTOP, &t)) < 0)
- {
-#endif
- if (rmtlseek (archive, 0L, 0) != 0)
- {
- /* Lseek failed. Try a different method */
- msg_perror ("Couldn't rewind archive file for verify");
- return;
- }
-#ifdef MTIOCTOP
- }
- }
-#endif
- ar_reading = 1;
- now_verifying = 1;
- fl_read ();
- for (;;)
- {
- status = read_header ();
- if (status == 0)
- {
- unsigned n;
-
- n = 0;
- do
- {
- n++;
- status = read_header ();
- }
- while (status == 0);
- msg ("VERIFY FAILURE: %d invalid header%s detected!", n, n == 1 ? "" : "s");
- }
- if (status == 2 || status == EOF)
- break;
- diff_archive ();
- }
- ar_reading = 0;
- now_verifying = 0;
-
-}
-
-int
-do_stat (statp)
- struct stat *statp;
-{
- int err;
-
- err = f_follow_links ? stat (current_file_name, statp) : lstat (current_file_name, statp);
- if (err < 0)
- {
- if (errno == ENOENT)
- {
- fprintf (msg_file, "%s: does not exist\n", current_file_name);
- }
- else
- msg_perror ("can't stat file %s", current_file_name);
- /* skip_file((long)hstat.st_size);
- different++;*/
- return 1;
- }
- else
- return 0;
-}
-
-/*
- * JK
- * Diff'ing a sparse file with its counterpart on the tar file is a
- * bit of a different story than a normal file. First, we must know
- * what areas of the file to skip through, i.e., we need to contruct
- * a sparsearray, which will hold all the information we need. We must
- * compare small amounts of data at a time as we find it.
- */
-
-void
-diff_sparse_files (filesize)
- int filesize;
-
-{
- int sparse_ind = 0;
- char *buf;
- int buf_size = RECORDSIZE;
- union record *datarec;
- int err;
- long numbytes;
- /* int amt_read = 0;*/
- int size = filesize;
-
- buf = (char *) ck_malloc (buf_size * sizeof (char));
-
- fill_in_sparse_array ();
-
-
- while (size > 0)
- {
- datarec = findrec ();
- if (!sparsearray[sparse_ind].numbytes)
- break;
-
- /*
- * 'numbytes' is nicer to write than
- * 'sparsearray[sparse_ind].numbytes' all the time ...
- */
- numbytes = sparsearray[sparse_ind].numbytes;
-
- lseek (diff_fd, sparsearray[sparse_ind].offset, 0);
- /*
- * take care to not run out of room in our buffer
- */
- while (buf_size < numbytes)
- {
- buf = (char *) ck_realloc (buf, buf_size * 2 * sizeof (char));
- buf_size *= 2;
- }
- while (numbytes > RECORDSIZE)
- {
- if ((err = read (diff_fd, buf, RECORDSIZE)) != RECORDSIZE)
- {
- if (err < 0)
- msg_perror ("can't read %s", current_file_name);
- else
- fprintf (msg_file, "%s: could only read %d of %d bytes\n",
- current_file_name, err, numbytes);
- break;
- }
- if (bcmp (buf, datarec->charptr, RECORDSIZE))
- {
- different++;
- break;
- }
- numbytes -= err;
- size -= err;
- userec (datarec);
- datarec = findrec ();
- }
- if ((err = read (diff_fd, buf, numbytes)) != numbytes)
- {
- if (err < 0)
- msg_perror ("can't read %s", current_file_name);
- else
- fprintf (msg_file, "%s: could only read %d of %d bytes\n",
- current_file_name, err, numbytes);
- break;
- }
-
- if (bcmp (buf, datarec->charptr, numbytes))
- {
- different++;
- break;
- }
- /* amt_read += numbytes;
- if (amt_read >= RECORDSIZE) {
- amt_read = 0;
- userec(datarec);
- datarec = findrec();
- }*/
- userec (datarec);
- sparse_ind++;
- size -= numbytes;
- }
- /*
- * if the number of bytes read isn't the
- * number of bytes supposedly in the file,
- * they're different
- */
- /* if (amt_read != filesize)
- different++;*/
- userec (datarec);
- free (sparsearray);
- if (different)
- fprintf (msg_file, "%s: data differs\n", current_file_name);
-
-}
-
-/*
- * JK
- * This routine should be used more often than it is ... look into
- * that. Anyhow, what it does is translate the sparse information
- * on the header, and in any subsequent extended headers, into an
- * array of structures with true numbers, as opposed to character
- * strings. It simply makes our life much easier, doing so many
- * comparisong and such.
- */
-void
-fill_in_sparse_array ()
-{
- int ind;
-
- /*
- * allocate space for our scratch space; it's initially
- * 10 elements long, but can change in this routine if
- * necessary
- */
- sp_array_size = 10;
- sparsearray = (struct sp_array *) ck_malloc (sp_array_size * sizeof (struct sp_array));
-
- /*
- * there are at most five of these structures in the header
- * itself; read these in first
- */
- for (ind = 0; ind < SPARSE_IN_HDR; ind++)
- {
- if (!head->header.sp[ind].numbytes)
- break;
- sparsearray[ind].offset =
- from_oct (1 + 12, head->header.sp[ind].offset);
- sparsearray[ind].numbytes =
- from_oct (1 + 12, head->header.sp[ind].numbytes);
- }
- /*
- * if the header's extended, we gotta read in exhdr's till
- * we're done
- */
- if (head->header.isextended)
- {
- /* how far into the sparsearray we are 'so far' */
- static int so_far_ind = SPARSE_IN_HDR;
- union record *exhdr;
-
- for (;;)
- {
- exhdr = findrec ();
- for (ind = 0; ind < SPARSE_EXT_HDR; ind++)
- {
- if (ind + so_far_ind > sp_array_size - 1)
- {
- /*
- * we just ran out of room in our
- * scratch area - realloc it
- */
- sparsearray = (struct sp_array *)
- ck_realloc (sparsearray,
- sp_array_size * 2 * sizeof (struct sp_array));
- sp_array_size *= 2;
- }
- /*
- * convert the character strings into longs
- */
- sparsearray[ind + so_far_ind].offset =
- from_oct (1 + 12, exhdr->ext_hdr.sp[ind].offset);
- sparsearray[ind + so_far_ind].numbytes =
- from_oct (1 + 12, exhdr->ext_hdr.sp[ind].numbytes);
- }
- /*
- * if this is the last extended header for this
- * file, we can stop
- */
- if (!exhdr->ext_hdr.isextended)
- break;
- else
- {
- so_far_ind += SPARSE_EXT_HDR;
- userec (exhdr);
- }
- }
- /* be sure to skip past the last one */
- userec (exhdr);
- }
-}
diff --git a/gnu/usr.bin/tar/extract.c b/gnu/usr.bin/tar/extract.c
deleted file mode 100644
index faf25ad..0000000
--- a/gnu/usr.bin/tar/extract.c
+++ /dev/null
@@ -1,946 +0,0 @@
-/* Extract files from a tar archive.
- Copyright (C) 1988, 1992, 1993 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Extract files from a tar archive.
- *
- * Written 19 Nov 1985 by John Gilmore, ihnp4!hoptoad!gnu.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-#include <sys/types.h>
-#include <time.h>
-time_t time ();
-
-#ifdef BSD42
-#include <sys/file.h>
-#else
-#ifndef V7
-#include <fcntl.h>
-#endif
-#endif
-
-#ifdef NO_OPEN3
-/* We need the #define's even though we don't use them. */
-#include "open3.h"
-#endif
-
-#ifdef EMUL_OPEN3
-/* Simulated 3-argument open for systems that don't have it */
-#include "open3.h"
-#endif
-
-#include "tar.h"
-#include "port.h"
-
-#if defined(_POSIX_VERSION)
-#include <utime.h>
-#else
-struct utimbuf
-{
- long actime;
- long modtime;
-};
-
-#endif
-
-extern FILE *msg_file;
-
-extern union record *head; /* Points to current tape header */
-extern struct stat hstat; /* Stat struct corresponding */
-extern int head_standard; /* Tape header is in ANSI format */
-
-extern char *save_name;
-extern long save_totsize;
-extern long save_sizeleft;
-
-int confirm ();
-void decode_header ();
-void extract_mangle ();
-void extract_sparse_file ();
-long from_oct ();
-void gnu_restore ();
-extern void print_header ();
-extern void skip_file ();
-extern void skip_extended_headers ();
-extern void pr_mkdir ();
-void saverec ();
-
-int make_dirs (); /* Makes required directories */
-
-static time_t now = 0; /* Current time */
-static we_are_root = 0; /* True if our effective uid == 0 */
-static int notumask = ~0; /* Masks out bits user doesn't want */
-
-/*
- * "Scratch" space to store the information about a sparse file before
- * writing the info into the header or extended header
- */
-/*struct sp_array *sparsearray;*/
-
-/* number of elts storable in the sparsearray */
-/*int sp_array_size = 10;*/
-
-struct saved_dir_info
-{
- char *path;
- int mode;
- int atime;
- int mtime;
- struct saved_dir_info *next;
-};
-
-struct saved_dir_info *saved_dir_info_head;
-
-/*
- * Set up to extract files.
- */
-void
-extr_init ()
-{
- int ourmask;
-
- now = time ((time_t *) 0);
- if (geteuid () == 0)
- we_are_root = 1;
-
- /*
- * We need to know our umask. But if f_use_protection is set,
- * leave our kernel umask at 0, and our "notumask" at ~0.
- */
- ourmask = umask (0); /* Read it */
- if (!f_use_protection)
- {
- (void) umask (ourmask); /* Set it back how it was */
- notumask = ~ourmask; /* Make umask override permissions */
- }
-}
-
-
-/*
- * Extract a file from the archive.
- */
-void
-extract_archive ()
-{
- register char *data;
- int fd, check, namelen, written, openflag;
- long size;
- struct utimbuf acc_upd_times;
- register int skipcrud;
- register int i;
- /* int sparse_ind = 0;*/
- union record *exhdr;
- struct saved_dir_info *tmp;
- /* int end_nulls; */
-
- saverec (&head); /* Make sure it sticks around */
- userec (head); /* And go past it in the archive */
- decode_header (head, &hstat, &head_standard, 1); /* Snarf fields */
-
- if ((f_confirm && !confirm ("extract", current_file_name)) ||
- (f_exstdout && head->header.linkflag != LF_OLDNORMAL &&
- head->header.linkflag != LF_NORMAL &&
- head->header.linkflag != LF_CONTIG))
- {
- if (head->header.isextended)
- skip_extended_headers ();
- skip_file ((long) hstat.st_size);
- saverec ((union record **) 0);
- return;
- }
-
- /* Print the record from 'head' and 'hstat' */
- if (f_verbose)
- print_header ();
-
- /*
- * Check for fully specified pathnames and other atrocities.
- *
- * Note, we can't just make a pointer to the new file name,
- * since saverec() might move the header and adjust "head".
- * We have to start from "head" every time we want to touch
- * the header record.
- */
- skipcrud = 0;
- while (!f_absolute_paths
- && '/' == current_file_name[skipcrud])
- {
- static int warned_once = 0;
-
- skipcrud++; /* Force relative path */
- if (!warned_once++)
- {
- msg ("Removing leading / from absolute path names in the archive.");
- }
- }
-
- switch (head->header.linkflag)
- {
-
- default:
- msg ("Unknown file type '%c' for %s, extracted as normal file",
- head->header.linkflag, skipcrud + current_file_name);
- /* FALL THRU */
-
- /*
- * JK - What we want to do if the file is sparse is loop through
- * the array of sparse structures in the header and read in
- * and translate the character strings representing 1) the offset
- * at which to write and 2) how many bytes to write into numbers,
- * which we store into the scratch array, "sparsearray". This
- * array makes our life easier the same way it did in creating
- * the tar file that had to deal with a sparse file.
- *
- * After we read in the first five (at most) sparse structures,
- * we check to see if the file has an extended header, i.e.,
- * if more sparse structures are needed to describe the contents
- * of the new file. If so, we read in the extended headers
- * and continue to store their contents into the sparsearray.
- */
- case LF_SPARSE:
- sp_array_size = 10;
- sparsearray = (struct sp_array *) ck_malloc (sp_array_size * sizeof (struct sp_array));
- for (i = 0; i < SPARSE_IN_HDR; i++)
- {
- sparsearray[i].offset =
- from_oct (1 + 12, head->header.sp[i].offset);
- sparsearray[i].numbytes =
- from_oct (1 + 12, head->header.sp[i].numbytes);
- if (!sparsearray[i].numbytes)
- break;
- }
-
- /* end_nulls = from_oct(1+12, head->header.ending_blanks);*/
-
- if (head->header.isextended)
- {
- /* read in the list of extended headers
- and translate them into the sparsearray
- as before */
-
- /* static */ int ind = SPARSE_IN_HDR;
-
- for (;;)
- {
-
- exhdr = findrec ();
- for (i = 0; i < SPARSE_EXT_HDR; i++)
- {
-
- if (i + ind > sp_array_size - 1)
- {
- /*
- * realloc the scratch area
- * since we've run out of room --
- */
- sparsearray = (struct sp_array *)
- ck_realloc (sparsearray,
- 2 * sp_array_size * (sizeof (struct sp_array)));
- sp_array_size *= 2;
- }
- if (!exhdr->ext_hdr.sp[i].numbytes)
- break;
- sparsearray[i + ind].offset =
- from_oct (1 + 12, exhdr->ext_hdr.sp[i].offset);
- sparsearray[i + ind].numbytes =
- from_oct (1 + 12, exhdr->ext_hdr.sp[i].numbytes);
- }
- if (!exhdr->ext_hdr.isextended)
- break;
- else
- {
- ind += SPARSE_EXT_HDR;
- userec (exhdr);
- }
- }
- userec (exhdr);
- }
-
- /* FALL THRU */
- case LF_OLDNORMAL:
- case LF_NORMAL:
- case LF_CONTIG:
- /*
- * Appears to be a file.
- * See if it's really a directory.
- */
- namelen = strlen (skipcrud + current_file_name) - 1;
- if (current_file_name[skipcrud + namelen] == '/')
- goto really_dir;
-
- /* FIXME, deal with protection issues */
- again_file:
- openflag = (f_keep ?
- O_BINARY | O_NDELAY | O_WRONLY | O_CREAT | O_EXCL :
- O_BINARY | O_NDELAY | O_WRONLY | O_CREAT | O_TRUNC)
- | ((head->header.linkflag == LF_SPARSE) ? 0 : O_APPEND);
- /*
- * JK - The last | is a kludge to solve the problem
- * the O_APPEND flag causes with files we are
- * trying to make sparse: when a file is opened
- * with O_APPEND, it writes to the last place
- * that something was written, thereby ignoring
- * any lseeks that we have done. We add this
- * extra condition to make it able to lseek when
- * a file is sparse, i.e., we don't open the new
- * file with this flag. (Grump -- this bug caused
- * me to waste a good deal of time, I might add)
- */
-
- if (f_exstdout)
- {
- fd = 1;
- goto extract_file;
- }
-
- if (f_unlink && !f_keep) {
- if (unlink(skipcrud + current_file_name) == -1)
- if (errno != ENOENT)
- msg_perror ("Could not unlink %s",
- skipcrud + current_file_name);
- }
-
-#ifdef O_CTG
- /*
- * Contiguous files (on the Masscomp) have to specify
- * the size in the open call that creates them.
- */
- if (head->header.linkflag == LF_CONTIG)
- fd = open ((longname ? longname : head->header.name)
- + skipcrud,
- openflag | O_CTG,
- hstat.st_mode, hstat.st_size);
- else
-#endif
- {
-#ifdef NO_OPEN3
- /*
- * On raw V7 we won't let them specify -k (f_keep), but
- * we just bull ahead and create the files.
- */
- fd = creat ((longname
- ? longname
- : head->header.name) + skipcrud,
- hstat.st_mode);
-#else
- /*
- * With 3-arg open(), we can do this up right.
- */
- fd = open (skipcrud + current_file_name,
- openflag, hstat.st_mode);
-#endif
- }
-
- if (fd < 0)
- {
- if (make_dirs (skipcrud + current_file_name))
- goto again_file;
- msg_perror ("Could not create file %s",
- skipcrud + current_file_name);
- if (head->header.isextended)
- skip_extended_headers ();
- skip_file ((long) hstat.st_size);
- goto quit;
- }
-
- extract_file:
- if (head->header.linkflag == LF_SPARSE)
- {
- char *name;
- int namelen;
-
- /*
- * Kludge alert. NAME is assigned to header.name
- * because during the extraction, the space that
- * contains the header will get scribbled on, and
- * the name will get munged, so any error messages
- * that happen to contain the filename will look
- * REAL interesting unless we do this.
- */
- namelen = strlen (skipcrud + current_file_name) + 1;
- name = (char *) ck_malloc ((sizeof (char)) * namelen);
- bcopy (skipcrud + current_file_name, name, namelen);
- size = hstat.st_size;
- extract_sparse_file (fd, &size, hstat.st_size, name);
- }
- else
- for (size = hstat.st_size;
- size > 0;
- size -= written)
- {
-
- /* long offset,
- numbytes;*/
-
- if (f_multivol)
- {
- save_name = current_file_name;
- save_totsize = hstat.st_size;
- save_sizeleft = size;
- }
-
- /*
- * Locate data, determine max length
- * writeable, write it, record that
- * we have used the data, then check
- * if the write worked.
- */
- data = findrec ()->charptr;
- if (data == NULL)
- { /* Check it... */
- msg ("Unexpected EOF on archive file");
- break;
- }
- /*
- * JK - If the file is sparse, use the sparsearray
- * that we created before to lseek into the new
- * file the proper amount, and to see how many
- * bytes we want to write at that position.
- */
- /* if (head->header.linkflag == LF_SPARSE) {
- off_t pos;
-
- pos = lseek(fd, (off_t) sparsearray[sparse_ind].offset, 0);
- printf("%d at %d\n", (int) pos, sparse_ind);
- written = sparsearray[sparse_ind++].numbytes;
- } else*/
- written = endofrecs ()->charptr - data;
- if (written > size)
- written = size;
- errno = 0;
- check = write (fd, data, written);
- /*
- * The following is in violation of strict
- * typing, since the arg to userec
- * should be a struct rec *. FIXME.
- */
- userec ((union record *) (data + written - 1));
- if (check == written)
- continue;
- /*
- * Error in writing to file.
- * Print it, skip to next file in archive.
- */
- if (check < 0)
- msg_perror ("couldn't write to file %s",
- skipcrud + current_file_name);
- else
- msg ("could only write %d of %d bytes to file %s",
- check, written, skipcrud + current_file_name);
- skip_file ((long) (size - written));
- break; /* Still do the close, mod time, chmod, etc */
- }
-
- if (f_multivol)
- save_name = 0;
-
- /* If writing to stdout, don't try to do anything
- to the filename; it doesn't exist, or we don't
- want to touch it anyway */
- if (f_exstdout)
- break;
-
- /* if (head->header.isextended) {
- register union record *exhdr;
- register int i;
-
- for (i = 0; i < 21; i++) {
- long offset;
-
- if (!exhdr->ext_hdr.sp[i].numbytes)
- break;
- offset = from_oct(1+12,
- exhdr->ext_hdr.sp[i].offset);
- written = from_oct(1+12,
- exhdr->ext_hdr.sp[i].numbytes);
- lseek(fd, offset, 0);
- check = write(fd, data, written);
- if (check == written) continue;
-
- }
-
-
- }*/
- check = close (fd);
- if (check < 0)
- {
- msg_perror ("Error while closing %s",
- skipcrud + current_file_name);
- }
-
-
- set_filestat:
-
- /*
- * If we are root, set the owner and group of the extracted
- * file. This does what is wanted both on real Unix and on
- * System V. If we are running as a user, we extract as that
- * user; if running as root, we extract as the original owner.
- */
- if (we_are_root || f_do_chown)
- {
- if (chown (skipcrud + current_file_name,
- hstat.st_uid, hstat.st_gid) < 0)
- {
- msg_perror ("cannot chown file %s to uid %d gid %d",
- skipcrud + current_file_name,
- hstat.st_uid, hstat.st_gid);
- }
- }
-
- /*
- * Set the modified time of the file.
- *
- * Note that we set the accessed time to "now", which
- * is really "the time we started extracting files".
- * unless f_gnudump is used, in which case .st_atime is used
- */
- if (!f_modified)
- {
- /* fixme if f_gnudump should set ctime too, but how? */
- if (f_gnudump)
- acc_upd_times.actime = hstat.st_atime;
- else
- acc_upd_times.actime = now; /* Accessed now */
- acc_upd_times.modtime = hstat.st_mtime; /* Mod'd */
- if (utime (skipcrud + current_file_name,
- &acc_upd_times) < 0)
- {
- msg_perror ("couldn't change access and modification times of %s", skipcrud + current_file_name);
- }
- }
- /* We do the utime before the chmod because some versions of
- utime are broken and trash the modes of the file. Since
- we then change the mode anyway, we don't care. . . */
-
- /*
- * If '-k' is not set, open() or creat() could have saved
- * the permission bits from a previously created file,
- * ignoring the ones we specified.
- * Even if -k is set, if the file has abnormal
- * mode bits, we must chmod since writing or chown() has
- * probably reset them.
- *
- * If -k is set, we know *we* created this file, so the mode
- * bits were set by our open(). If the file is "normal", we
- * skip the chmod. This works because we did umask(0) if -p
- * is set, so umask will have left the specified mode alone.
- */
- if ((!f_keep)
- || (hstat.st_mode & (S_ISUID | S_ISGID | S_ISVTX)))
- {
- if (chmod (skipcrud + current_file_name,
- notumask & (int) hstat.st_mode) < 0)
- {
- msg_perror ("cannot change mode of file %s to 0%o",
- skipcrud + current_file_name,
- notumask & (int) hstat.st_mode);
- }
- }
-
- quit:
- break;
-
- case LF_LINK:
- again_link:
- {
- struct stat st1, st2;
-
- if (f_unlink && !f_keep) {
- if (unlink(skipcrud + current_file_name) == -1)
- if (errno != ENOENT)
- msg_perror ("Could not unlink %s",
- skipcrud + current_file_name);
- }
-
- check = link (current_link_name, skipcrud + current_file_name);
-
- if (check == 0)
- break;
- if (make_dirs (skipcrud + current_file_name))
- goto again_link;
- if (f_gnudump && errno == EEXIST)
- break;
- if (stat (current_link_name, &st1) == 0
- && stat (current_file_name + skipcrud, &st2) == 0
- && st1.st_dev == st2.st_dev
- && st1.st_ino == st2.st_ino)
- break;
- msg_perror ("Could not link %s to %s",
- skipcrud + current_file_name,
- current_link_name);
- }
- break;
-
-#ifdef S_ISLNK
- case LF_SYMLINK:
- again_symlink:
- if (f_unlink && !f_keep) {
- if (unlink(skipcrud + current_file_name) == -1)
- if (errno != ENOENT)
- msg_perror ("Could not unlink %s",
- skipcrud + current_file_name);
- }
-
- check = symlink (current_link_name,
- skipcrud + current_file_name);
- /* FIXME, don't worry uid, gid, etc... */
- if (check == 0)
- break;
- if (make_dirs (current_file_name + skipcrud))
- goto again_symlink;
- msg_perror ("Could not create symlink to %s",
- current_link_name);
- break;
-#endif
-
-#ifdef S_IFCHR
- case LF_CHR:
- hstat.st_mode |= S_IFCHR;
- goto make_node;
-#endif
-
-#ifdef S_IFBLK
- case LF_BLK:
- hstat.st_mode |= S_IFBLK;
-#endif
-#if defined(S_IFCHR) || defined(S_IFBLK)
- make_node:
- if (f_unlink && !f_keep) {
- if (unlink(skipcrud + current_file_name) == -1)
- if (errno != ENOENT)
- msg_perror ("Could not unlink %s",
- skipcrud + current_file_name);
- }
-
- check = mknod (current_file_name + skipcrud,
- (int) hstat.st_mode, (int) hstat.st_rdev);
- if (check != 0)
- {
- if (make_dirs (skipcrud + current_file_name))
- goto make_node;
- msg_perror ("Could not make %s",
- current_file_name + skipcrud);
- break;
- };
- goto set_filestat;
-#endif
-
-#ifdef S_ISFIFO
- /* If local system doesn't support FIFOs, use default case */
- case LF_FIFO:
- make_fifo:
- if (f_unlink && !f_keep) {
- if (unlink(skipcrud + current_file_name) == -1)
- if (errno != ENOENT)
- msg_perror ("Could not unlink %s",
- skipcrud + current_file_name);
- }
-
- check = mkfifo (current_file_name + skipcrud,
- (int) hstat.st_mode);
- if (check != 0)
- {
- if (make_dirs (current_file_name + skipcrud))
- goto make_fifo;
- msg_perror ("Could not make %s",
- skipcrud + current_file_name);
- break;
- };
- goto set_filestat;
-#endif
-
- case LF_DIR:
- case LF_DUMPDIR:
- namelen = strlen (current_file_name + skipcrud) - 1;
- really_dir:
- /* Check for trailing /, and zap as many as we find. */
- while (namelen
- && current_file_name[skipcrud + namelen] == '/')
- current_file_name[skipcrud + namelen--] = '\0';
- if (f_gnudump)
- { /* Read the entry and delete files
- that aren't listed in the archive */
- gnu_restore (skipcrud);
-
- }
- else if (head->header.linkflag == LF_DUMPDIR)
- skip_file ((long) (hstat.st_size));
-
-
- again_dir:
- check = mkdir (skipcrud + current_file_name,
- (we_are_root ? 0 : 0300) | (int) hstat.st_mode);
- if (check != 0)
- {
- struct stat st1;
-
- if (make_dirs (skipcrud + current_file_name))
- goto again_dir;
- /* If we're trying to create '.', let it be. */
- if (current_file_name[skipcrud + namelen] == '.' &&
- (namelen == 0 ||
- current_file_name[skipcrud + namelen - 1] == '/'))
- goto check_perms;
- if (errno == EEXIST
- && stat (skipcrud + current_file_name, &st1) == 0
- && (S_ISDIR (st1.st_mode)))
- break;
- msg_perror ("Could not create directory %s", skipcrud + current_file_name);
- break;
- }
-
- check_perms:
- if (!we_are_root && 0300 != (0300 & (int) hstat.st_mode))
- {
- hstat.st_mode |= 0300;
- msg ("Added write and execute permission to directory %s",
- skipcrud + current_file_name);
- }
-
- /*
- * If we are root, set the owner and group of the extracted
- * file. This does what is wanted both on real Unix and on
- * System V. If we are running as a user, we extract as that
- * user; if running as root, we extract as the original owner.
- */
- if (we_are_root || f_do_chown)
- {
- if (chown (skipcrud + current_file_name,
- hstat.st_uid, hstat.st_gid) < 0)
- {
- msg_perror ("cannot chown file %s to uid %d gid %d",
- skipcrud + current_file_name,
- hstat.st_uid, hstat.st_gid);
- }
- }
-
- if (!f_modified)
- {
- tmp = ((struct saved_dir_info *)
- ck_malloc (sizeof (struct saved_dir_info)));
- tmp->path = (char *) ck_malloc (strlen (skipcrud
- + current_file_name) + 1);
- strcpy (tmp->path, skipcrud + current_file_name);
- tmp->mode = hstat.st_mode;
- tmp->atime = hstat.st_atime;
- tmp->mtime = hstat.st_mtime;
- tmp->next = saved_dir_info_head;
- saved_dir_info_head = tmp;
- }
- else
- {
- /* This functions exactly as the code for set_filestat above. */
- if ((!f_keep)
- || (hstat.st_mode & (S_ISUID | S_ISGID | S_ISVTX)))
- {
- if (chmod (skipcrud + current_file_name,
- notumask & (int) hstat.st_mode) < 0)
- {
- msg_perror ("cannot change mode of file %s to 0%o",
- skipcrud + current_file_name,
- notumask & (int) hstat.st_mode);
- }
- }
- }
- break;
-
- case LF_VOLHDR:
- if (f_verbose)
- {
- printf ("Reading %s\n", current_file_name);
- }
- break;
-
- case LF_NAMES:
- extract_mangle (head);
- break;
-
- case LF_MULTIVOL:
- msg ("Can't extract '%s'--file is continued from another volume\n", current_file_name);
- skip_file ((long) hstat.st_size);
- break;
-
- case LF_LONGNAME:
- case LF_LONGLINK:
- msg ("Visible long name error\n");
- skip_file ((long) hstat.st_size);
- break;
- }
-
- /* We don't need to save it any longer. */
- saverec ((union record **) 0);/* Unsave it */
-}
-
-/*
- * After a file/link/symlink/dir creation has failed, see if
- * it's because some required directory was not present, and if
- * so, create all required dirs.
- */
-int
-make_dirs (pathname)
- char *pathname;
-{
- char *p; /* Points into path */
- int madeone = 0; /* Did we do anything yet? */
- int save_errno = errno; /* Remember caller's errno */
- int check;
-
- if (errno != ENOENT)
- return 0; /* Not our problem */
-
- for (p = index (pathname, '/'); p != NULL; p = index (p + 1, '/'))
- {
- /* Avoid mkdir of empty string, if leading or double '/' */
- if (p == pathname || p[-1] == '/')
- continue;
- /* Avoid mkdir where last part of path is '.' */
- if (p[-1] == '.' && (p == pathname + 1 || p[-2] == '/'))
- continue;
- *p = 0; /* Truncate the path there */
- check = mkdir (pathname, 0777); /* Try to create it as a dir */
- if (check == 0)
- {
- /* Fix ownership */
- if (we_are_root)
- {
- if (chown (pathname, hstat.st_uid,
- hstat.st_gid) < 0)
- {
- msg_perror ("cannot change owner of %s to uid %d gid %d", pathname, hstat.st_uid, hstat.st_gid);
- }
- }
- pr_mkdir (pathname, p - pathname, notumask & 0777);
- madeone++; /* Remember if we made one */
- *p = '/';
- continue;
- }
- *p = '/';
- if (errno == EEXIST) /* Directory already exists */
- continue;
- /*
- * Some other error in the mkdir. We return to the caller.
- */
- break;
- }
-
- errno = save_errno; /* Restore caller's errno */
- return madeone; /* Tell them to retry if we made one */
-}
-
-void
-extract_sparse_file (fd, sizeleft, totalsize, name)
- int fd;
- long *sizeleft, totalsize;
- char *name;
-{
- /* register char *data;*/
- union record *datarec;
- int sparse_ind = 0;
- int written, count;
-
- /* assuming sizeleft is initially totalsize */
-
-
- while (*sizeleft > 0)
- {
- datarec = findrec ();
- if (datarec == NULL)
- {
- msg ("Unexpected EOF on archive file");
- return;
- }
- lseek (fd, sparsearray[sparse_ind].offset, 0);
- written = sparsearray[sparse_ind++].numbytes;
- while (written > RECORDSIZE)
- {
- count = write (fd, datarec->charptr, RECORDSIZE);
- if (count < 0)
- msg_perror ("couldn't write to file %s", name);
- written -= count;
- *sizeleft -= count;
- userec (datarec);
- datarec = findrec ();
- }
-
- count = write (fd, datarec->charptr, written);
-
- if (count < 0)
- {
- msg_perror ("couldn't write to file %s", name);
- }
- else if (count != written)
- {
- msg ("could only write %d of %d bytes to file %s", count,
- totalsize, name);
- skip_file ((long) (*sizeleft));
- }
-
- written -= count;
- *sizeleft -= count;
- userec (datarec);
- }
- free (sparsearray);
- /* if (end_nulls) {
- register int i;
-
- printf("%d\n", (int) end_nulls);
- for (i = 0; i < end_nulls; i++)
- write(fd, "\000", 1);
- }*/
- userec (datarec);
-}
-
-/* Set back the utime and mode for all the extracted directories. */
-void
-restore_saved_dir_info ()
-{
- struct utimbuf acc_upd_times;
-
- while (saved_dir_info_head != NULL)
- {
- /* fixme if f_gnudump should set ctime too, but how? */
- if (f_gnudump)
- acc_upd_times.actime = saved_dir_info_head->atime;
- else
- acc_upd_times.actime = now; /* Accessed now */
- acc_upd_times.modtime = saved_dir_info_head->mtime; /* Mod'd */
- if (utime (saved_dir_info_head->path, &acc_upd_times) < 0)
- {
- msg_perror ("couldn't change access and modification times of %s",
- saved_dir_info_head->path);
- }
- if ((!f_keep) || (saved_dir_info_head->mode & (S_ISUID | S_ISGID | S_ISVTX)))
- {
- if (chmod (saved_dir_info_head->path,
- notumask & saved_dir_info_head->mode) < 0)
- {
- msg_perror ("cannot change mode of file %s to 0%o",
- saved_dir_info_head->path,
- notumask & saved_dir_info_head->mode);
- }
- }
- saved_dir_info_head = saved_dir_info_head->next;
- }
-}
diff --git a/gnu/usr.bin/tar/getdate.y b/gnu/usr.bin/tar/getdate.y
deleted file mode 100644
index cc41577..0000000
--- a/gnu/usr.bin/tar/getdate.y
+++ /dev/null
@@ -1,970 +0,0 @@
-%{
-/* $Revision: 1.2 $
-**
-** Originally written by Steven M. Bellovin <smb@research.att.com> while
-** at the University of North Carolina at Chapel Hill. Later tweaked by
-** a couple of people on Usenet. Completely overhauled by Rich $alz
-** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
-** send any email to Rich.
-**
-** This grammar has eight shift/reduce conflicts.
-**
-** This code is in the public domain and has no copyright.
-*/
-/* SUPPRESS 287 on yaccpar_sccsid *//* Unusd static variable */
-/* SUPPRESS 288 on yyerrlab *//* Label unused */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#else
-#ifdef _AIX /* for Bison */
- #pragma alloca
-#else
-char *alloca ();
-#endif
-#endif
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-
-/* The code at the top of get_date which figures out the offset of the
- current time zone checks various CPP symbols to see if special
- tricks are need, but defaults to using the gettimeofday system call.
- Include <sys/time.h> if that will be used. */
-
-#if !defined (USG) && !defined (sgi) && !defined (__FreeBSD__)
-#include <sys/time.h>
-#endif
-
-#if defined(vms)
-
-#include <types.h>
-#include <time.h>
-
-#else
-
-#include <sys/types.h>
-
-#if defined(USG) || !defined(HAVE_FTIME)
-/*
-** If you need to do a tzset() call to set the
-** timezone, and don't have ftime().
-*/
-struct timeb {
- time_t time; /* Seconds since the epoch */
- unsigned short millitm; /* Field not used */
- short timezone;
- short dstflag; /* Field not used */
-};
-
-#else
-
-#include <sys/timeb.h>
-
-#endif /* defined(USG) && !defined(HAVE_FTIME) */
-
-#if defined(BSD4_2) || defined(BSD4_1C) || (defined (hp9000) && !defined (hpux))
-#include <sys/time.h>
-#else
-#if defined(_AIX)
-#include <sys/time.h>
-#endif
-#include <time.h>
-#endif /* defined(BSD4_2) */
-
-#endif /* defined(vms) */
-
-#if defined (STDC_HEADERS) || defined (USG)
-#include <string.h>
-#endif
-
-#if sgi
-#undef timezone
-#endif
-
-extern struct tm *localtime();
-
-#define yyparse getdate_yyparse
-#define yylex getdate_yylex
-#define yyerror getdate_yyerror
-
-#if !defined(lint) && !defined(SABER)
-static char RCS[] =
- "$Header: /home/ncvs/src/gnu/usr.bin/tar/getdate.y,v 1.2 1994/11/04 02:12:22 jkh Exp $";
-#endif /* !defined(lint) && !defined(SABER) */
-
-
-#define EPOCH 1970
-#define HOUR(x) ((time_t)(x) * 60)
-#define SECSPERDAY (24L * 60L * 60L)
-
-
-/*
-** An entry in the lexical lookup table.
-*/
-typedef struct _TABLE {
- char *name;
- int type;
- time_t value;
-} TABLE;
-
-
-/*
-** Daylight-savings mode: on, off, or not yet known.
-*/
-typedef enum _DSTMODE {
- DSTon, DSToff, DSTmaybe
-} DSTMODE;
-
-/*
-** Meridian: am, pm, or 24-hour style.
-*/
-typedef enum _MERIDIAN {
- MERam, MERpm, MER24
-} MERIDIAN;
-
-
-/*
-** Global variables. We could get rid of most of these by using a good
-** union as the yacc stack. (This routine was originally written before
-** yacc had the %union construct.) Maybe someday; right now we only use
-** the %union very rarely.
-*/
-static char *yyInput;
-static DSTMODE yyDSTmode;
-static time_t yyDayOrdinal;
-static time_t yyDayNumber;
-static int yyHaveDate;
-static int yyHaveDay;
-static int yyHaveRel;
-static int yyHaveTime;
-static int yyHaveZone;
-static time_t yyTimezone;
-static time_t yyDay;
-static time_t yyHour;
-static time_t yyMinutes;
-static time_t yyMonth;
-static time_t yySeconds;
-static time_t yyYear;
-static MERIDIAN yyMeridian;
-static time_t yyRelMonth;
-static time_t yyRelSeconds;
-
-%}
-
-%union {
- time_t Number;
- enum _MERIDIAN Meridian;
-}
-
-%token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
-%token tSEC_UNIT tSNUMBER tUNUMBER tZONE tDST
-
-%type <Number> tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT
-%type <Number> tSEC_UNIT tSNUMBER tUNUMBER tZONE
-%type <Meridian> tMERIDIAN o_merid
-
-%%
-
-spec : /* NULL */
- | spec item
- ;
-
-item : time {
- yyHaveTime++;
- }
- | zone {
- yyHaveZone++;
- }
- | date {
- yyHaveDate++;
- }
- | day {
- yyHaveDay++;
- }
- | rel {
- yyHaveRel++;
- }
- | number
- ;
-
-time : tUNUMBER tMERIDIAN {
- yyHour = $1;
- yyMinutes = 0;
- yySeconds = 0;
- yyMeridian = $2;
- }
- | tUNUMBER ':' tUNUMBER o_merid {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = 0;
- yyMeridian = $4;
- }
- | tUNUMBER ':' tUNUMBER tSNUMBER {
- yyHour = $1;
- yyMinutes = $3;
- yyMeridian = MER24;
- yyDSTmode = DSToff;
- yyTimezone = - ($4 % 100 + ($4 / 100) * 60);
- }
- | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = $5;
- yyMeridian = $6;
- }
- | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = $5;
- yyMeridian = MER24;
- yyDSTmode = DSToff;
- yyTimezone = - ($6 % 100 + ($6 / 100) * 60);
- }
- ;
-
-zone : tZONE {
- yyTimezone = $1;
- yyDSTmode = DSToff;
- }
- | tDAYZONE {
- yyTimezone = $1;
- yyDSTmode = DSTon;
- }
- |
- tZONE tDST {
- yyTimezone = $1;
- yyDSTmode = DSTon;
- }
- ;
-
-day : tDAY {
- yyDayOrdinal = 1;
- yyDayNumber = $1;
- }
- | tDAY ',' {
- yyDayOrdinal = 1;
- yyDayNumber = $1;
- }
- | tUNUMBER tDAY {
- yyDayOrdinal = $1;
- yyDayNumber = $2;
- }
- ;
-
-date : tUNUMBER '/' tUNUMBER {
- yyMonth = $1;
- yyDay = $3;
- }
- | tUNUMBER '/' tUNUMBER '/' tUNUMBER {
- yyMonth = $1;
- yyDay = $3;
- yyYear = $5;
- }
- | tUNUMBER tSNUMBER tSNUMBER {
- /* ISO 8601 format. yyyy-mm-dd. */
- yyYear = $1;
- yyMonth = -$2;
- yyDay = -$3;
- }
- | tMONTH tUNUMBER {
- yyMonth = $1;
- yyDay = $2;
- }
- | tMONTH tUNUMBER ',' tUNUMBER {
- yyMonth = $1;
- yyDay = $2;
- yyYear = $4;
- }
- | tUNUMBER tMONTH {
- yyMonth = $2;
- yyDay = $1;
- }
- | tUNUMBER tMONTH tUNUMBER {
- yyMonth = $2;
- yyDay = $1;
- yyYear = $3;
- }
- ;
-
-rel : relunit tAGO {
- yyRelSeconds = -yyRelSeconds;
- yyRelMonth = -yyRelMonth;
- }
- | relunit
- ;
-
-relunit : tUNUMBER tMINUTE_UNIT {
- yyRelSeconds += $1 * $2 * 60L;
- }
- | tSNUMBER tMINUTE_UNIT {
- yyRelSeconds += $1 * $2 * 60L;
- }
- | tMINUTE_UNIT {
- yyRelSeconds += $1 * 60L;
- }
- | tSNUMBER tSEC_UNIT {
- yyRelSeconds += $1;
- }
- | tUNUMBER tSEC_UNIT {
- yyRelSeconds += $1;
- }
- | tSEC_UNIT {
- yyRelSeconds++;
- }
- | tSNUMBER tMONTH_UNIT {
- yyRelMonth += $1 * $2;
- }
- | tUNUMBER tMONTH_UNIT {
- yyRelMonth += $1 * $2;
- }
- | tMONTH_UNIT {
- yyRelMonth += $1;
- }
- ;
-
-number : tUNUMBER {
- if (yyHaveTime && yyHaveDate && !yyHaveRel)
- yyYear = $1;
- else {
- if($1>10000) {
- time_t date_part;
-
- date_part= $1/10000;
- yyHaveDate++;
- yyDay= (date_part)%100;
- yyMonth= (date_part/100)%100;
- yyYear = date_part/10000;
- }
- yyHaveTime++;
- if ($1 < 100) {
- yyHour = $1;
- yyMinutes = 0;
- }
- else {
- yyHour = $1 / 100;
- yyMinutes = $1 % 100;
- }
- yySeconds = 0;
- yyMeridian = MER24;
- }
- }
- ;
-
-o_merid : /* NULL */ {
- $$ = MER24;
- }
- | tMERIDIAN {
- $$ = $1;
- }
- ;
-
-%%
-
-/* Month and day table. */
-static TABLE const MonthDayTable[] = {
- { "january", tMONTH, 1 },
- { "february", tMONTH, 2 },
- { "march", tMONTH, 3 },
- { "april", tMONTH, 4 },
- { "may", tMONTH, 5 },
- { "june", tMONTH, 6 },
- { "july", tMONTH, 7 },
- { "august", tMONTH, 8 },
- { "september", tMONTH, 9 },
- { "sept", tMONTH, 9 },
- { "october", tMONTH, 10 },
- { "november", tMONTH, 11 },
- { "december", tMONTH, 12 },
- { "sunday", tDAY, 0 },
- { "monday", tDAY, 1 },
- { "tuesday", tDAY, 2 },
- { "tues", tDAY, 2 },
- { "wednesday", tDAY, 3 },
- { "wednes", tDAY, 3 },
- { "thursday", tDAY, 4 },
- { "thur", tDAY, 4 },
- { "thurs", tDAY, 4 },
- { "friday", tDAY, 5 },
- { "saturday", tDAY, 6 },
- { NULL }
-};
-
-/* Time units table. */
-static TABLE const UnitsTable[] = {
- { "year", tMONTH_UNIT, 12 },
- { "month", tMONTH_UNIT, 1 },
- { "fortnight", tMINUTE_UNIT, 14 * 24 * 60 },
- { "week", tMINUTE_UNIT, 7 * 24 * 60 },
- { "day", tMINUTE_UNIT, 1 * 24 * 60 },
- { "hour", tMINUTE_UNIT, 60 },
- { "minute", tMINUTE_UNIT, 1 },
- { "min", tMINUTE_UNIT, 1 },
- { "second", tSEC_UNIT, 1 },
- { "sec", tSEC_UNIT, 1 },
- { NULL }
-};
-
-/* Assorted relative-time words. */
-static TABLE const OtherTable[] = {
- { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 },
- { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 },
- { "today", tMINUTE_UNIT, 0 },
- { "now", tMINUTE_UNIT, 0 },
- { "last", tUNUMBER, -1 },
- { "this", tMINUTE_UNIT, 0 },
- { "next", tUNUMBER, 2 },
- { "first", tUNUMBER, 1 },
-/* { "second", tUNUMBER, 2 }, */
- { "third", tUNUMBER, 3 },
- { "fourth", tUNUMBER, 4 },
- { "fifth", tUNUMBER, 5 },
- { "sixth", tUNUMBER, 6 },
- { "seventh", tUNUMBER, 7 },
- { "eighth", tUNUMBER, 8 },
- { "ninth", tUNUMBER, 9 },
- { "tenth", tUNUMBER, 10 },
- { "eleventh", tUNUMBER, 11 },
- { "twelfth", tUNUMBER, 12 },
- { "ago", tAGO, 1 },
- { NULL }
-};
-
-/* The timezone table. */
-/* Some of these are commented out because a time_t can't store a float. */
-static TABLE const TimezoneTable[] = {
- { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
- { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */
- { "utc", tZONE, HOUR( 0) },
- { "wet", tZONE, HOUR( 0) }, /* Western European */
- { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
- { "wat", tZONE, HOUR( 1) }, /* West Africa */
- { "at", tZONE, HOUR( 2) }, /* Azores */
-#if 0
- /* For completeness. BST is also British Summer, and GST is
- * also Guam Standard. */
- { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
- { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
-#endif
-#if 0
- { "nft", tZONE, HOUR(3.5) }, /* Newfoundland */
- { "nst", tZONE, HOUR(3.5) }, /* Newfoundland Standard */
- { "ndt", tDAYZONE, HOUR(3.5) }, /* Newfoundland Daylight */
-#endif
- { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
- { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
- { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
- { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
- { "cst", tZONE, HOUR( 6) }, /* Central Standard */
- { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
- { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
- { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
- { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
- { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
- { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
- { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
- { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
- { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */
- { "cat", tZONE, HOUR(10) }, /* Central Alaska */
- { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */
- { "nt", tZONE, HOUR(11) }, /* Nome */
- { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
- { "cet", tZONE, -HOUR(1) }, /* Central European */
- { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */
- { "met", tZONE, -HOUR(1) }, /* Middle European */
- { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
- { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
- { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
- { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
- { "fwt", tZONE, -HOUR(1) }, /* French Winter */
- { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
- { "eet", tZONE, -HOUR(2) }, /* Eastern Europe, USSR Zone 1 */
- { "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */
-#if 0
- { "it", tZONE, -HOUR(3.5) },/* Iran */
-#endif
- { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
- { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
-#if 0
- { "ist", tZONE, -HOUR(5.5) },/* Indian Standard */
-#endif
- { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
-#if 0
- /* For completeness. NST is also Newfoundland Stanard, and SST is
- * also Swedish Summer. */
- { "nst", tZONE, -HOUR(6.5) },/* North Sumatra */
- { "sst", tZONE, -HOUR(7) }, /* South Sumatra, USSR Zone 6 */
-#endif /* 0 */
- { "wast", tZONE, -HOUR(7) }, /* West Australian Standard */
- { "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */
-#if 0
- { "jt", tZONE, -HOUR(7.5) },/* Java (3pm in Cronusland!) */
-#endif
- { "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */
- { "jst", tZONE, -HOUR(9) }, /* Japan Standard, USSR Zone 8 */
-#if 0
- { "cast", tZONE, -HOUR(9.5) },/* Central Australian Standard */
- { "cadt", tDAYZONE, -HOUR(9.5) },/* Central Australian Daylight */
-#endif
- { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
- { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
- { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */
- { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
- { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
- { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
- { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
- { NULL }
-};
-
-/* Military timezone table. */
-static TABLE const MilitaryTable[] = {
- { "a", tZONE, HOUR( 1) },
- { "b", tZONE, HOUR( 2) },
- { "c", tZONE, HOUR( 3) },
- { "d", tZONE, HOUR( 4) },
- { "e", tZONE, HOUR( 5) },
- { "f", tZONE, HOUR( 6) },
- { "g", tZONE, HOUR( 7) },
- { "h", tZONE, HOUR( 8) },
- { "i", tZONE, HOUR( 9) },
- { "k", tZONE, HOUR( 10) },
- { "l", tZONE, HOUR( 11) },
- { "m", tZONE, HOUR( 12) },
- { "n", tZONE, HOUR(- 1) },
- { "o", tZONE, HOUR(- 2) },
- { "p", tZONE, HOUR(- 3) },
- { "q", tZONE, HOUR(- 4) },
- { "r", tZONE, HOUR(- 5) },
- { "s", tZONE, HOUR(- 6) },
- { "t", tZONE, HOUR(- 7) },
- { "u", tZONE, HOUR(- 8) },
- { "v", tZONE, HOUR(- 9) },
- { "w", tZONE, HOUR(-10) },
- { "x", tZONE, HOUR(-11) },
- { "y", tZONE, HOUR(-12) },
- { "z", tZONE, HOUR( 0) },
- { NULL }
-};
-
-
-
-
-/* ARGSUSED */
-static int
-yyerror(s)
- char *s;
-{
- return 0;
-}
-
-
-static time_t
-ToSeconds(Hours, Minutes, Seconds, Meridian)
- time_t Hours;
- time_t Minutes;
- time_t Seconds;
- MERIDIAN Meridian;
-{
- if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59)
- return -1;
- switch (Meridian) {
- case MER24:
- if (Hours < 0 || Hours > 23)
- return -1;
- return (Hours * 60L + Minutes) * 60L + Seconds;
- case MERam:
- if (Hours < 1 || Hours > 12)
- return -1;
- return (Hours * 60L + Minutes) * 60L + Seconds;
- case MERpm:
- if (Hours < 1 || Hours > 12)
- return -1;
- return ((Hours + 12) * 60L + Minutes) * 60L + Seconds;
- }
- /* NOTREACHED */
-}
-
-
-static time_t
-Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode)
- time_t Month;
- time_t Day;
- time_t Year;
- time_t Hours;
- time_t Minutes;
- time_t Seconds;
- MERIDIAN Meridian;
- DSTMODE DSTmode;
-{
- static int DaysInMonth[12] = {
- 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
- };
- time_t tod;
- time_t Julian;
- int i;
-
- if (Year < 0)
- Year = -Year;
- if (Year < 100)
- Year += 1900;
- DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
- ? 29 : 28;
- if (Year < EPOCH || Year > 1999
- || Month < 1 || Month > 12
- /* Lint fluff: "conversion from long may lose accuracy" */
- || Day < 1 || Day > DaysInMonth[(int)--Month])
- return -1;
-
- for (Julian = Day - 1, i = 0; i < Month; i++)
- Julian += DaysInMonth[i];
- for (i = EPOCH; i < Year; i++)
- Julian += 365 + (i % 4 == 0);
- Julian *= SECSPERDAY;
- Julian += yyTimezone * 60L;
- if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
- return -1;
- Julian += tod;
- if (DSTmode == DSTon
- || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst))
- Julian -= 60 * 60;
- return Julian;
-}
-
-
-static time_t
-DSTcorrect(Start, Future)
- time_t Start;
- time_t Future;
-{
- time_t StartDay;
- time_t FutureDay;
-
- StartDay = (localtime(&Start)->tm_hour + 1) % 24;
- FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
- return (Future - Start) + (StartDay - FutureDay) * 60L * 60L;
-}
-
-
-static time_t
-RelativeDate(Start, DayOrdinal, DayNumber)
- time_t Start;
- time_t DayOrdinal;
- time_t DayNumber;
-{
- struct tm *tm;
- time_t now;
-
- now = Start;
- tm = localtime(&now);
- now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7);
- now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1);
- return DSTcorrect(Start, now);
-}
-
-
-static time_t
-RelativeMonth(Start, RelMonth)
- time_t Start;
- time_t RelMonth;
-{
- struct tm *tm;
- time_t Month;
- time_t Year;
-
- if (RelMonth == 0)
- return 0;
- tm = localtime(&Start);
- Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
- Year = Month / 12;
- Month = Month % 12 + 1;
- return DSTcorrect(Start,
- Convert(Month, (time_t)tm->tm_mday, Year,
- (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
- MER24, DSTmaybe));
-}
-
-
-static int
-LookupWord(buff)
- char *buff;
-{
- register char *p;
- register char *q;
- register const TABLE *tp;
- int i;
- int abbrev;
-
- /* Make it lowercase. */
- for (p = buff; *p; p++)
- if (isupper(*p))
- *p = tolower(*p);
-
- if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) {
- yylval.Meridian = MERam;
- return tMERIDIAN;
- }
- if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) {
- yylval.Meridian = MERpm;
- return tMERIDIAN;
- }
-
- /* See if we have an abbreviation for a month. */
- if (strlen(buff) == 3)
- abbrev = 1;
- else if (strlen(buff) == 4 && buff[3] == '.') {
- abbrev = 1;
- buff[3] = '\0';
- }
- else
- abbrev = 0;
-
- for (tp = MonthDayTable; tp->name; tp++) {
- if (abbrev) {
- if (strncmp(buff, tp->name, 3) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
- else if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
-
- for (tp = TimezoneTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- if (strcmp(buff, "dst") == 0)
- return tDST;
-
- for (tp = UnitsTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- /* Strip off any plural and try the units table again. */
- i = strlen(buff) - 1;
- if (buff[i] == 's') {
- buff[i] = '\0';
- for (tp = UnitsTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- buff[i] = 's'; /* Put back for "this" in OtherTable. */
- }
-
- for (tp = OtherTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- /* Military timezones. */
- if (buff[1] == '\0' && isalpha(*buff)) {
- for (tp = MilitaryTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
-
- /* Drop out any periods and try the timezone table again. */
- for (i = 0, p = q = buff; *q; q++)
- if (*q != '.')
- *p++ = *q;
- else
- i++;
- *p = '\0';
- if (i)
- for (tp = TimezoneTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- return tID;
-}
-
-
-static int
-yylex()
-{
- register char c;
- register char *p;
- char buff[20];
- int Count;
- int sign;
-
- for ( ; ; ) {
- while (isspace(*yyInput))
- yyInput++;
-
- if (isdigit(c = *yyInput) || c == '-' || c == '+') {
- if (c == '-' || c == '+') {
- sign = c == '-' ? -1 : 1;
- if (!isdigit(*++yyInput))
- /* skip the '-' sign */
- continue;
- }
- else
- sign = 0;
- for (yylval.Number = 0; isdigit(c = *yyInput++); )
- yylval.Number = 10 * yylval.Number + c - '0';
- yyInput--;
- if (sign < 0)
- yylval.Number = -yylval.Number;
- return sign ? tSNUMBER : tUNUMBER;
- }
- if (isalpha(c)) {
- for (p = buff; isalpha(c = *yyInput++) || c == '.'; )
- if (p < &buff[sizeof buff - 1])
- *p++ = c;
- *p = '\0';
- yyInput--;
- return LookupWord(buff);
- }
- if (c != '(')
- return *yyInput++;
- Count = 0;
- do {
- c = *yyInput++;
- if (c == '\0')
- return c;
- if (c == '(')
- Count++;
- else if (c == ')')
- Count--;
- } while (Count > 0);
- }
-}
-
-
-time_t
-get_date(p, now)
- char *p;
- struct timeb *now;
-{
- struct tm *tm;
- struct timeb ftz;
- time_t Start;
- time_t tod;
-
- yyInput = p;
- if (now == NULL) {
- now = &ftz;
-#if !defined(HAVE_FTIME)
- (void)time(&ftz.time);
- /* Set the timezone global. */
- tzset();
- {
-#if sgi
- ftz.timezone = (int) _timezone / 60;
-#else /* not sgi */
-#ifdef __FreeBSD__
- ftz.timezone = 0;
-#else /* neither sgi nor 386BSD */
-#if defined (USG)
- extern time_t timezone;
-
- ftz.timezone = (int) timezone / 60;
-#else /* neither sgi nor 386BSD nor USG */
- struct timeval tv;
- struct timezone tz;
-
- gettimeofday (&tv, &tz);
- ftz.timezone = (int) tz.tz_minuteswest;
-#endif /* neither sgi nor 386BSD nor USG */
-#endif /* neither sgi nor 386BSD */
-#endif /* not sgi */
- }
-#else /* HAVE_FTIME */
- (void)ftime(&ftz);
-#endif /* HAVE_FTIME */
- }
-
- tm = localtime(&now->time);
- yyYear = tm->tm_year;
- yyMonth = tm->tm_mon + 1;
- yyDay = tm->tm_mday;
- yyTimezone = now->timezone;
- yyDSTmode = DSTmaybe;
- yyHour = 0;
- yyMinutes = 0;
- yySeconds = 0;
- yyMeridian = MER24;
- yyRelSeconds = 0;
- yyRelMonth = 0;
- yyHaveDate = 0;
- yyHaveDay = 0;
- yyHaveRel = 0;
- yyHaveTime = 0;
- yyHaveZone = 0;
-
- if (yyparse()
- || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1)
- return -1;
-
- if (yyHaveDate || yyHaveTime || yyHaveDay) {
- Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
- yyMeridian, yyDSTmode);
- if (Start < 0)
- return -1;
- }
- else {
- Start = now->time;
- if (!yyHaveRel)
- Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec;
- }
-
- Start += yyRelSeconds;
- Start += RelativeMonth(Start, yyRelMonth);
-
- if (yyHaveDay && !yyHaveDate) {
- tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber);
- Start += tod;
- }
-
- /* Have to do *something* with a legitimate -1 so it's distinguishable
- * from the error return value. (Alternately could set errno on error.) */
- return Start == -1 ? 0 : Start;
-}
-
-
-#if defined(TEST)
-
-/* ARGSUSED */
-main(ac, av)
- int ac;
- char *av[];
-{
- char buff[128];
- time_t d;
-
- (void)printf("Enter date, or blank line to exit.\n\t> ");
- (void)fflush(stdout);
- while (gets(buff) && buff[0]) {
- d = get_date(buff, (struct timeb *)NULL);
- if (d == -1)
- (void)printf("Bad format - couldn't convert.\n");
- else
- (void)printf("%s", ctime(&d));
- (void)printf("\t> ");
- (void)fflush(stdout);
- }
- exit(0);
- /* NOTREACHED */
-}
-#endif /* defined(TEST) */
diff --git a/gnu/usr.bin/tar/getoldopt.c b/gnu/usr.bin/tar/getoldopt.c
deleted file mode 100644
index 27511b9..0000000
--- a/gnu/usr.bin/tar/getoldopt.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Replacement for getopt() that can be used by tar.
- Copyright (C) 1988 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Plug-compatible replacement for getopt() for parsing tar-like
- * arguments. If the first argument begins with "-", it uses getopt;
- * otherwise, it uses the old rules used by tar, dump, and ps.
- *
- * Written 25 August 1985 by John Gilmore (ihnp4!hoptoad!gnu)
- */
-
-#include <stdio.h>
-#include "getopt.h"
-#include "tar.h" /* For msg() declaration if STDC_MSG. */
-#include <sys/types.h>
-#include "port.h"
-
-int
-getoldopt (argc, argv, optstring, long_options, opt_index)
- int argc;
- char **argv;
- char *optstring;
- struct option *long_options;
- int *opt_index;
-{
- extern char *optarg; /* Points to next arg */
- extern int optind; /* Global argv index */
- static char *key; /* Points to next keyletter */
- static char use_getopt; /* !=0 if argv[1][0] was '-' */
- char c;
- char *place;
-
- optarg = NULL;
-
- if (key == NULL)
- { /* First time */
- if (argc < 2)
- return EOF;
- key = argv[1];
- if ((*key == '-') || (*key == '+'))
- use_getopt++;
- else
- optind = 2;
- }
-
- if (use_getopt)
- return getopt_long (argc, argv, optstring,
- long_options, opt_index);
-
- c = *key++;
- if (c == '\0')
- {
- key--;
- return EOF;
- }
- place = index (optstring, c);
-
- if (place == NULL || c == ':')
- {
- msg ("unknown option %c", c);
- return ('?');
- }
-
- place++;
- if (*place == ':')
- {
- if (optind < argc)
- {
- optarg = argv[optind];
- optind++;
- }
- else
- {
- msg ("%c argument missing", c);
- return ('?');
- }
- }
-
- return (c);
-}
diff --git a/gnu/usr.bin/tar/getopt.c b/gnu/usr.bin/tar/getopt.c
deleted file mode 100644
index 6b8e3f2..0000000
--- a/gnu/usr.bin/tar/getopt.c
+++ /dev/null
@@ -1,712 +0,0 @@
-/* Getopt for GNU.
- NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
- before changing it!
-
- Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
- 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* NOTE!!! AIX requires this to be the first thing in the file.
- Do not put ANYTHING before it! */
-#if !defined (__GNUC__) && defined (_AIX)
- #pragma alloca
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not __GNUC__ */
-#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
-#include <alloca.h>
-#else
-#ifndef _AIX
-char *alloca ();
-#endif
-#endif /* alloca.h */
-#endif /* not __GNUC__ */
-
-#if !__STDC__ && !defined(const) && IN_GCC
-#define const
-#endif
-
-#include <stdio.h>
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-#undef alloca
-/* Don't include stdlib.h for non-GNU C libraries because some of them
- contain conflicting prototypes for getopt. */
-#include <stdlib.h>
-#else /* Not GNU C library. */
-#define __alloca alloca
-#endif /* GNU C library. */
-
-/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
- long-named option. Because this is not POSIX.2 compliant, it is
- being phased out. */
-/* #define GETOPT_COMPAT */
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- to intersperse the options with the other arguments.
-
- As `getopt' works, it permutes the elements of ARGV so that,
- when it is done, all the options precede everything else. Thus
- all application programs are extended to handle flexible argument order.
-
- Setting the environment variable POSIXLY_CORRECT disables permutation.
- Then the behavior is completely standard.
-
- GNU application programs can use a third alternative mode in which
- they can distinguish the relative order of options and other arguments. */
-
-#include "getopt.h"
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-char *optarg = 0;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-/* XXX 1003.2 says this must be 1 before any call. */
-int optind = 0;
-
-/* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
-static char *nextchar;
-
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-int optopt = '?';
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
- If the caller did not specify anything,
- the default is REQUIRE_ORDER if the environment variable
- POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
- REQUIRE_ORDER means don't recognize them as options;
- stop option processing when the first non-option is seen.
- This is what Unix does.
- This mode of operation is selected by either setting the environment
- variable POSIXLY_CORRECT, or using `+' as the first character
- of the list of option characters.
-
- PERMUTE is the default. We permute the contents of ARGV as we scan,
- so that eventually all the non-options are at the end. This allows options
- to be given in any order, even with programs that were not written to
- expect this.
-
- RETURN_IN_ORDER is an option available to programs that were written
- to expect options and other ARGV-elements in any order and that care about
- the ordering of the two. We describe each non-option ARGV-element
- as if it were the argument of an option with character code 1.
- Using `-' as the first character of the list of option characters
- selects this mode of operation.
-
- The special argument `--' forces an end of option-scanning regardless
- of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return EOF with `optind' != ARGC. */
-
-static enum
-{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-#ifdef __GNU_LIBRARY__
-/* We want to avoid inclusion of string.h with non-GNU libraries
- because there are many ways it can cause trouble.
- On some systems, it contains special magic macros that don't work
- in GCC. */
-#include <string.h>
-#define my_index strchr
-#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n))
-#else
-
-/* Avoid depending on library functions or files
- whose names are inconsistent. */
-
-char *getenv ();
-
-static char *
-my_index (string, chr)
- char *string;
- int chr;
-{
- while (*string)
- {
- if (*string == chr)
- return string;
- string++;
- }
- return 0;
-}
-
-static void
-my_bcopy (from, to, size)
- char *from, *to;
- int size;
-{
- int i;
- for (i = 0; i < size; i++)
- to[i] = from[i];
-}
-#endif /* GNU C library. */
-
-/* Handle permutation of arguments. */
-
-/* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
-static int first_nonopt;
-static int last_nonopt;
-
-/* Exchange two adjacent subsequences of ARGV.
- One subsequence is elements [first_nonopt,last_nonopt)
- which contains all the non-options that have been skipped so far.
- The other is elements [last_nonopt,optind), which contains all
- the options processed since those non-options were skipped.
-
- `first_nonopt' and `last_nonopt' are relocated so that they describe
- the new indices of the non-options in ARGV after they are moved. */
-
-static void
-exchange (argv)
- char **argv;
-{
- int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *);
- char **temp = (char **) __alloca (nonopts_size);
-
- /* Interchange the two blocks of data in ARGV. */
-
- my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size);
- my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt],
- (optind - last_nonopt) * sizeof (char *));
- my_bcopy ((char *) temp,
- (char *) &argv[first_nonopt + optind - last_nonopt],
- nonopts_size);
-
- /* Update records for the slots the non-options now occupy. */
-
- first_nonopt += (optind - last_nonopt);
- last_nonopt = optind;
-}
-
-/* Scan elements of ARGV (whose length is ARGC) for option characters
- given in OPTSTRING.
-
- If an element of ARGV starts with '-', and is not exactly "-" or "--",
- then it is an option element. The characters of this element
- (aside from the initial '-') are option characters. If `getopt'
- is called repeatedly, it returns successively each of the option characters
- from each of the option elements.
-
- If `getopt' finds another option character, it returns that character,
- updating `optind' and `nextchar' so that the next call to `getopt' can
- resume the scan with the following option character or ARGV-element.
-
- If there are no more option characters, `getopt' returns `EOF'.
- Then `optind' is the index in ARGV of the first ARGV-element
- that is not an option. (The ARGV-elements have been permuted
- so that those that are not options now come last.)
-
- OPTSTRING is a string containing the legitimate option characters.
- If an option character is seen that is not listed in OPTSTRING,
- return '?' after printing an error message. If you set `opterr' to
- zero, the error message is suppressed but we still return '?'.
-
- If a char in OPTSTRING is followed by a colon, that means it wants an arg,
- so the following text in the same ARGV-element, or the text of the following
- ARGV-element, is returned in `optarg'. Two colons mean an option that
- wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `optarg', otherwise `optarg' is set to zero.
-
- If OPTSTRING starts with `-' or `+', it requests different methods of
- handling the non-option ARGV-elements.
- See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
-
- Long-named options begin with `--' instead of `-'.
- Their names may be abbreviated as long as the abbreviation is unique
- or is an exact match for some defined option. If they have an
- argument, it follows the option name in the same ARGV-element, separated
- from the option name by a `=', or else the in next ARGV-element.
- When `getopt' finds a long-named option, it returns 0 if that option's
- `flag' field is nonzero, the value of the option's `val' field
- if the `flag' field is zero.
-
- The elements of ARGV aren't really const, because we permute them.
- But we pretend they're const in the prototype to be compatible
- with other systems.
-
- LONGOPTS is a vector of `struct option' terminated by an
- element containing a name which is zero.
-
- LONGIND returns the index in LONGOPT of the long-named option found.
- It is only valid when a long-named option has been found by the most
- recent call.
-
- If LONG_ONLY is nonzero, '-' as well as '--' can introduce
- long-named options. */
-
-int
-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
- int argc;
- char *const *argv;
- const char *optstring;
- const struct option *longopts;
- int *longind;
- int long_only;
-{
- int option_index;
-
- optarg = 0;
-
- /* Initialize the internal data when the first call is made.
- Start processing options with ARGV-element 1 (since ARGV-element 0
- is the program name); the sequence of previously skipped
- non-option ARGV-elements is empty. */
-
- if (optind == 0)
- {
- first_nonopt = last_nonopt = optind = 1;
-
- nextchar = NULL;
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-')
- {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- }
- else if (optstring[0] == '+')
- {
- ordering = REQUIRE_ORDER;
- ++optstring;
- }
- else if (getenv ("POSIXLY_CORRECT") != NULL)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
- }
-
- if (nextchar == NULL || *nextchar == '\0')
- {
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Now skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < argc
- && (argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- optind++;
- last_nonopt = optind;
- }
-
- /* Special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp (argv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return EOF;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- {
- if (ordering == REQUIRE_ORDER)
- return EOF;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- Start decoding its characters. */
-
- nextchar = (argv[optind] + 1
- + (longopts != NULL && argv[optind][1] == '-'));
- }
-
- if (longopts != NULL
- && ((argv[optind][0] == '-'
- && (argv[optind][1] == '-' || long_only))
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- ))
- {
- const struct option *p;
- char *s = nextchar;
- int exact = 0;
- int ambig = 0;
- const struct option *pfound = NULL;
- int indfound;
-
- while (*s && *s != '=')
- s++;
-
- /* Test all options for either exact match or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name;
- p++, option_index++)
- if (!strncmp (p->name, nextchar, s - nextchar))
- {
- if (s - nextchar == strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' is ambiguous\n",
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- return '?';
- }
-
- if (pfound != NULL)
- {
- option_index = indfound;
- optind++;
- if (*s)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = s + 1;
- else
- {
- if (opterr)
- {
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- "%s: option `--%s' doesn't allow an argument\n",
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- "%s: option `%c%s' doesn't allow an argument\n",
- argv[0], argv[optind - 1][0], pfound->name);
- }
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' requires an argument\n",
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- /* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- || my_index (optstring, *nextchar) == NULL)
- {
- if (opterr)
- {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf (stderr, "%s: unrecognized option `--%s'\n",
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf (stderr, "%s: unrecognized option `%c%s'\n",
- argv[0], argv[optind][0], nextchar);
- }
- nextchar = (char *) "";
- optind++;
- return '?';
- }
- }
-
- /* Look at and handle the next option-character. */
-
- {
- char c = *nextchar++;
- char *temp = my_index (optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == '\0')
- ++optind;
-
- if (temp == NULL || c == ':')
- {
- if (opterr)
- {
-#if 0
- if (c < 040 || c >= 0177)
- fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
- argv[0], c);
- else
- fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
-#else
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
-#endif
- }
- optopt = c;
- return '?';
- }
- if (temp[1] == ':')
- {
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = 0;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
-#if 0
- fprintf (stderr, "%s: option `-%c' requires an argument\n",
- argv[0], c);
-#else
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, "%s: option requires an argument -- %c\n",
- argv[0], c);
-#endif
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
- }
- return c;
- }
-}
-
-int
-getopt (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
-{
- return _getopt_internal (argc, argv, optstring,
- (const struct option *) 0,
- (int *) 0,
- 0);
-}
-
-#ifdef TEST
-
-/* Compile with -DTEST to make an executable for use in testing
- the above definition of `getopt'. */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
-
- c = getopt (argc, argv, "abc:d:0123456789");
- if (c == EOF)
- break;
-
- switch (c)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/usr.bin/tar/getopt.h b/gnu/usr.bin/tar/getopt.h
deleted file mode 100644
index f977e15..0000000
--- a/gnu/usr.bin/tar/getopt.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* Declarations for getopt.
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef _GETOPT_H
-#define _GETOPT_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
-extern int opterr;
-
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
-struct option
-{
-#if __STDC__
- const char *name;
-#else
- char *name;
-#endif
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'. */
-
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
-
-#if __STDC__
-#if defined(__GNU_LIBRARY__)
-/* Many other libraries have conflicting prototypes for getopt, with
- differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
-extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* not __GNU_LIBRARY__ */
-extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-extern int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
-
-/* Internal only. Users should not call this directly. */
-extern int _getopt_internal (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
-#else /* not __STDC__ */
-extern int getopt ();
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-#endif /* not __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GETOPT_H */
diff --git a/gnu/usr.bin/tar/getopt1.c b/gnu/usr.bin/tar/getopt1.c
deleted file mode 100644
index b2b23f2..0000000
--- a/gnu/usr.bin/tar/getopt1.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* Getopt for GNU.
- Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "getopt.h"
-
-#if !__STDC__ && !defined(const) && IN_GCC
-#define const
-#endif
-
-#include <stdio.h>
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-#include <stdlib.h>
-#else
-char *getenv ();
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-int
-getopt_long (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
-}
-
-/* Like getopt_long, but '-' as well as '--' can indicate a long option.
- If an option that starts with '-' (not '--') doesn't match a long option,
- but does match a short option, it is parsed as a short option
- instead. */
-
-int
-getopt_long_only (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
-}
-
-#ifdef TEST
-
-#include <stdio.h>
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
- int option_index = 0;
- static struct option long_options[] =
- {
- {"add", 1, 0, 0},
- {"append", 0, 0, 0},
- {"delete", 1, 0, 0},
- {"verbose", 0, 0, 0},
- {"create", 0, 0, 0},
- {"file", 1, 0, 0},
- {0, 0, 0, 0}
- };
-
- c = getopt_long (argc, argv, "abc:d:0123456789",
- long_options, &option_index);
- if (c == EOF)
- break;
-
- switch (c)
- {
- case 0:
- printf ("option %s", long_options[option_index].name);
- if (optarg)
- printf (" with arg %s", optarg);
- printf ("\n");
- break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case 'd':
- printf ("option d with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/gnu/usr.bin/tar/getpagesize.h b/gnu/usr.bin/tar/getpagesize.h
deleted file mode 100644
index 2d43f26..0000000
--- a/gnu/usr.bin/tar/getpagesize.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifdef BSD
-#ifndef BSD4_1
-#define HAVE_GETPAGESIZE
-#endif
-#endif
-
-#ifndef HAVE_GETPAGESIZE
-
-#ifdef VMS
-#define getpagesize() 512
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef _SC_PAGESIZE
-#define getpagesize() sysconf(_SC_PAGESIZE)
-#else
-
-#include <sys/param.h>
-
-#ifdef EXEC_PAGESIZE
-#define getpagesize() EXEC_PAGESIZE
-#else
-#ifdef NBPG
-#define getpagesize() NBPG * CLSIZE
-#ifndef CLSIZE
-#define CLSIZE 1
-#endif /* no CLSIZE */
-#else /* no NBPG */
-#define getpagesize() NBPC
-#endif /* no NBPG */
-#endif /* no EXEC_PAGESIZE */
-#endif /* no _SC_PAGESIZE */
-
-#endif /* not HAVE_GETPAGESIZE */
-
diff --git a/gnu/usr.bin/tar/gnu.c b/gnu/usr.bin/tar/gnu.c
deleted file mode 100644
index d3a0446..0000000
--- a/gnu/usr.bin/tar/gnu.c
+++ /dev/null
@@ -1,677 +0,0 @@
-/* GNU dump extensions to tar.
- Copyright (C) 1988, 1992, 1993 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <ctype.h>
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-#include <time.h>
-time_t time ();
-
-#include "tar.h"
-#include "port.h"
-
-#ifndef S_ISLNK
-#define lstat stat
-#endif
-
-extern time_t new_time;
-extern FILE *msg_file;
-
-void addname ();
-int check_exclude ();
-extern PTR ck_malloc ();
-extern PTR ck_realloc ();
-int confirm ();
-extern PTR init_buffer ();
-extern char *get_buffer ();
-int is_dot_or_dotdot ();
-extern void add_buffer ();
-extern void flush_buffer ();
-void name_gather ();
-int recursively_delete ();
-void skip_file ();
-char *un_quote_string ();
-
-extern char *new_name ();
-
-static void add_dir_name ();
-
-struct dirname
- {
- struct dirname *next;
- char *name;
- char *dir_text;
- int dev;
- int ino;
- int allnew;
- };
-static struct dirname *dir_list;
-static time_t this_time;
-
-void
-add_dir (name, dev, ino, text)
- char *name;
- char *text;
- dev_t dev;
- ino_t ino;
-{
- struct dirname *dp;
-
- dp = (struct dirname *) ck_malloc (sizeof (struct dirname));
- if (!dp)
- abort ();
- dp->next = dir_list;
- dir_list = dp;
- dp->dev = dev;
- dp->ino = ino;
- dp->name = ck_malloc (strlen (name) + 1);
- strcpy (dp->name, name);
- dp->dir_text = text;
- dp->allnew = 0;
-}
-
-void
-read_dir_file ()
-{
- int dev;
- int ino;
- char *strp;
- FILE *fp;
- char buf[512];
- static char *path = 0;
-
- if (path == 0)
- path = ck_malloc (PATH_MAX);
- time (&this_time);
- if (gnu_dumpfile[0] != '/')
- {
-#if defined(__MSDOS__) || defined(HAVE_GETCWD) || defined(_POSIX_VERSION)
- if (!getcwd (path, PATH_MAX))
- {
- msg ("Couldn't get current directory.");
- exit (EX_SYSTEM);
- }
-#else
- char *getwd ();
-
- if (!getwd (path))
- {
- msg ("Couldn't get current directory: %s", path);
- exit (EX_SYSTEM);
- }
-#endif
- /* If this doesn't fit, we're in serious trouble */
- strcat (path, "/");
- strcat (path, gnu_dumpfile);
- gnu_dumpfile = path;
- }
- fp = fopen (gnu_dumpfile, "r");
- if (fp == 0 && errno != ENOENT)
- {
- msg_perror ("Can't open %s", gnu_dumpfile);
- return;
- }
- if (!fp)
- return;
- fgets (buf, sizeof (buf), fp);
- if (!f_new_files)
- {
- f_new_files++;
- new_time = atol (buf);
- }
- while (fgets (buf, sizeof (buf), fp))
- {
- strp = &buf[strlen (buf)];
- if (strp[-1] == '\n')
- strp[-1] = '\0';
- strp = buf;
- dev = atol (strp);
- while (isdigit ((unsigned char) *strp))
- strp++;
- ino = atol (strp);
- while (isspace ((unsigned char) *strp))
- strp++;
- while (isdigit ((unsigned char) *strp))
- strp++;
- strp++;
- add_dir (un_quote_string (strp), dev, ino, (char *) 0);
- }
- fclose (fp);
-}
-
-void
-write_dir_file ()
-{
- FILE *fp;
- struct dirname *dp;
- char *str;
- extern char *quote_copy_string ();
-
- fp = fopen (gnu_dumpfile, "w");
- if (fp == 0)
- {
- msg_perror ("Can't write to %s", gnu_dumpfile);
- return;
- }
- fprintf (fp, "%lu\n", this_time);
- for (dp = dir_list; dp; dp = dp->next)
- {
- if (!dp->dir_text)
- continue;
- str = quote_copy_string (dp->name);
- if (str)
- {
- fprintf (fp, "%u %u %s\n", dp->dev, dp->ino, str);
- free (str);
- }
- else
- fprintf (fp, "%u %u %s\n", dp->dev, dp->ino, dp->name);
- }
- fclose (fp);
-}
-
-struct dirname *
-get_dir (name)
- char *name;
-{
- struct dirname *dp;
-
- for (dp = dir_list; dp; dp = dp->next)
- {
- if (!strcmp (dp->name, name))
- return dp;
- }
- return 0;
-}
-
-
-/* Collect all the names from argv[] (or whatever), then expand them into
- a directory tree, and put all the directories at the beginning. */
-void
-collect_and_sort_names ()
-{
- struct name *n, *n_next;
- int num_names;
- struct stat statbuf;
- int name_cmp ();
- char *merge_sort ();
-
- name_gather ();
-
- if (gnu_dumpfile)
- read_dir_file ();
- if (!namelist)
- addname (".");
- for (n = namelist; n; n = n_next)
- {
- n_next = n->next;
- if (n->found || n->dir_contents)
- continue;
- if (n->regexp) /* FIXME just skip regexps for now */
- continue;
- if (n->change_dir)
- if (chdir (n->change_dir) < 0)
- {
- msg_perror ("can't chdir to %s", n->change_dir);
- continue;
- }
-
-#ifdef AIX
- if (statx (n->name, &statbuf, STATSIZE, STX_HIDDEN | STX_LINK))
-#else
- if (lstat (n->name, &statbuf) < 0)
-#endif /* AIX */
- {
- msg_perror ("can't stat %s", n->name);
- continue;
- }
- if (S_ISDIR (statbuf.st_mode))
- {
- n->found++;
- add_dir_name (n->name, statbuf.st_dev);
- }
- }
-
- num_names = 0;
- for (n = namelist; n; n = n->next)
- num_names++;
- namelist = (struct name *) merge_sort ((PTR) namelist, num_names, (char *) (&(namelist->next)) - (char *) namelist, name_cmp);
-
- for (n = namelist; n; n = n->next)
- {
- n->found = 0;
- }
- if (gnu_dumpfile)
- write_dir_file ();
-}
-
-int
-name_cmp (n1, n2)
- struct name *n1, *n2;
-{
- if (n1->found)
- {
- if (n2->found)
- return strcmp (n1->name, n2->name);
- else
- return -1;
- }
- else if (n2->found)
- return 1;
- else
- return strcmp (n1->name, n2->name);
-}
-
-int
-dirent_cmp (p1, p2)
- const PTR p1;
- const PTR p2;
-{
- char *frst, *scnd;
-
- frst = (*(char **) p1) + 1;
- scnd = (*(char **) p2) + 1;
-
- return strcmp (frst, scnd);
-}
-
-char *
-get_dir_contents (p, device)
- char *p;
- int device;
-{
- DIR *dirp;
- register struct dirent *d;
- char *new_buf;
- char *namebuf;
- int bufsiz;
- int len;
- PTR the_buffer;
- char *buf;
- size_t n_strs;
- /* int n_size;*/
- char *p_buf;
- char **vec, **p_vec;
-
- extern int errno;
-
- errno = 0;
- dirp = opendir (p);
- bufsiz = strlen (p) + NAMSIZ;
- namebuf = ck_malloc (bufsiz + 2);
- if (!dirp)
- {
- if (errno)
- msg_perror ("can't open directory %s", p);
- else
- msg ("error opening directory %s", p);
- new_buf = NULL;
- }
- else
- {
- struct dirname *dp;
- int all_children;
-
- dp = get_dir (p);
- all_children = dp ? dp->allnew : 0;
- (void) strcpy (namebuf, p);
- if (p[strlen (p) - 1] != '/')
- (void) strcat (namebuf, "/");
- len = strlen (namebuf);
-
- the_buffer = init_buffer ();
- while (d = readdir (dirp))
- {
- struct stat hs;
-
- /* Skip . and .. */
- if (is_dot_or_dotdot (d->d_name))
- continue;
- if (NLENGTH (d) + len >= bufsiz)
- {
- bufsiz += NAMSIZ;
- namebuf = ck_realloc (namebuf, bufsiz + 2);
- }
- (void) strcpy (namebuf + len, d->d_name);
-#ifdef AIX
- if (0 != f_follow_links ?
- statx (namebuf, &hs, STATSIZE, STX_HIDDEN) :
- statx (namebuf, &hs, STATSIZE, STX_HIDDEN | STX_LINK))
-#else
- if (0 != f_follow_links ? stat (namebuf, &hs) : lstat (namebuf, &hs))
-#endif
- {
- msg_perror ("can't stat %s", namebuf);
- continue;
- }
- if ((f_local_filesys && device != hs.st_dev)
- || (f_exclude && check_exclude (namebuf)))
- add_buffer (the_buffer, "N", 1);
-#ifdef AIX
- else if (S_ISHIDDEN (hs.st_mode))
- {
- add_buffer (the_buffer, "D", 1);
- strcat (d->d_name, "A");
- d->d_namlen++;
- }
-#endif /* AIX */
- else if (S_ISDIR (hs.st_mode))
- {
- if (dp = get_dir (namebuf))
- {
- if (dp->dev != hs.st_dev
- || dp->ino != hs.st_ino)
- {
- if (f_verbose)
- msg ("directory %s has been renamed.", namebuf);
- dp->allnew = 1;
- dp->dev = hs.st_dev;
- dp->ino = hs.st_ino;
- }
- dp->dir_text = "";
- }
- else
- {
- if (f_verbose)
- msg ("Directory %s is new", namebuf);
- add_dir (namebuf, hs.st_dev, hs.st_ino, "");
- dp = get_dir (namebuf);
- dp->allnew = 1;
- }
- if (all_children)
- dp->allnew = 1;
-
- add_buffer (the_buffer, "D", 1);
- }
- else if (!all_children
- && f_new_files
- && new_time > hs.st_mtime
- && (f_new_files > 1
- || new_time > hs.st_ctime))
- add_buffer (the_buffer, "N", 1);
- else
- add_buffer (the_buffer, "Y", 1);
- add_buffer (the_buffer, d->d_name, (int) (NLENGTH (d) + 1));
- }
- add_buffer (the_buffer, "\000\000", 2);
- closedir (dirp);
-
- /* Well, we've read in the contents of the dir, now sort them */
- buf = get_buffer (the_buffer);
- if (buf[0] == '\0')
- {
- flush_buffer (the_buffer);
- new_buf = NULL;
- }
- else
- {
- n_strs = 0;
- for (p_buf = buf; *p_buf;)
- {
- int tmp;
-
- tmp = strlen (p_buf) + 1;
- n_strs++;
- p_buf += tmp;
- }
- vec = (char **) ck_malloc (sizeof (char *) * (n_strs + 1));
- for (p_vec = vec, p_buf = buf; *p_buf; p_buf += strlen (p_buf) + 1)
- *p_vec++ = p_buf;
- *p_vec = 0;
- qsort ((PTR) vec, n_strs, sizeof (char *), dirent_cmp);
- new_buf = (char *) ck_malloc (p_buf - buf + 2);
- for (p_vec = vec, p_buf = new_buf; *p_vec; p_vec++)
- {
- char *p_tmp;
-
- for (p_tmp = *p_vec; *p_buf++ = *p_tmp++;)
- ;
- }
- *p_buf++ = '\0';
- free (vec);
- flush_buffer (the_buffer);
- }
- }
- free (namebuf);
- return new_buf;
-}
-
-/* p is a directory. Add all the files in P to the namelist. If any of the
- files is a directory, recurse on the subdirectory. . . */
-static void
-add_dir_name (p, device)
- char *p;
- int device;
-{
- char *new_buf;
- char *p_buf;
-
- char *namebuf;
- int buflen;
- register int len;
- int sublen;
-
- /* PTR the_buffer;*/
-
- /* char *buf;*/
- /* char **vec,**p_vec;*/
- /* int n_strs,n_size;*/
-
- struct name *n;
-
- int dirent_cmp ();
-
- new_buf = get_dir_contents (p, device);
-
- for (n = namelist; n; n = n->next)
- {
- if (!strcmp (n->name, p))
- {
- n->dir_contents = new_buf ? new_buf : "\0\0\0\0";
- break;
- }
- }
-
- if (new_buf)
- {
- len = strlen (p);
- buflen = NAMSIZ <= len ? len + NAMSIZ : NAMSIZ;
- namebuf = ck_malloc (buflen + 1);
-
- (void) strcpy (namebuf, p);
- if (namebuf[len - 1] != '/')
- {
- namebuf[len++] = '/';
- namebuf[len] = '\0';
- }
- for (p_buf = new_buf; *p_buf; p_buf += sublen + 1)
- {
- sublen = strlen (p_buf);
- if (*p_buf == 'D')
- {
- if (len + sublen >= buflen)
- {
- buflen += NAMSIZ;
- namebuf = ck_realloc (namebuf, buflen + 1);
- }
- (void) strcpy (namebuf + len, p_buf + 1);
- addname (namebuf);
- add_dir_name (namebuf, device);
- }
- }
- free (namebuf);
- }
-}
-
-/* Returns non-zero if p is . or .. This could be a macro for speed. */
-int
-is_dot_or_dotdot (p)
- char *p;
-{
- return (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0')));
-}
-
-
-
-
-
-
-void
-gnu_restore (skipcrud)
- int skipcrud;
-{
- char *current_dir;
- /* int current_dir_length; */
-
- char *archive_dir;
- /* int archive_dir_length; */
- PTR the_buffer;
- char *p;
- DIR *dirp;
- struct dirent *d;
- char *cur, *arc;
- extern struct stat hstat; /* Stat struct corresponding */
- long size, copied;
- char *from, *to;
- extern union record *head;
-
- dirp = opendir (skipcrud + current_file_name);
-
- if (!dirp)
- {
- /* The directory doesn't exist now. It'll be created.
- In any case, we don't have to delete any files out
- of it */
- skip_file ((long) hstat.st_size);
- return;
- }
-
- the_buffer = init_buffer ();
- while (d = readdir (dirp))
- {
- if (is_dot_or_dotdot (d->d_name))
- continue;
-
- add_buffer (the_buffer, d->d_name, (int) (NLENGTH (d) + 1));
- }
- closedir (dirp);
- add_buffer (the_buffer, "", 1);
-
- current_dir = get_buffer (the_buffer);
- archive_dir = (char *) ck_malloc (hstat.st_size);
- if (archive_dir == 0)
- {
- msg ("Can't allocate %d bytes for restore", hstat.st_size);
- skip_file ((long) hstat.st_size);
- return;
- }
- to = archive_dir;
- for (size = hstat.st_size; size > 0; size -= copied)
- {
- from = findrec ()->charptr;
- if (!from)
- {
- msg ("Unexpected EOF in archive\n");
- break;
- }
- copied = endofrecs ()->charptr - from;
- if (copied > size)
- copied = size;
- bcopy ((PTR) from, (PTR) to, (int) copied);
- to += copied;
- userec ((union record *) (from + copied - 1));
- }
-
- for (cur = current_dir; *cur; cur += strlen (cur) + 1)
- {
- for (arc = archive_dir; *arc; arc += strlen (arc) + 1)
- {
- arc++;
- if (!strcmp (arc, cur))
- break;
- }
- if (*arc == '\0')
- {
- p = new_name (skipcrud + current_file_name, cur);
- if (f_confirm && !confirm ("delete", p))
- {
- free (p);
- continue;
- }
- if (f_verbose)
- fprintf (msg_file, "%s: deleting %s\n", tar, p);
- if (recursively_delete (p))
- {
- msg ("%s: Error while deleting %s\n", tar, p);
- }
- free (p);
- }
-
- }
- flush_buffer (the_buffer);
- free (archive_dir);
-}
-
-int
-recursively_delete (path)
- char *path;
-{
- struct stat sbuf;
- DIR *dirp;
- struct dirent *dp;
- char *path_buf;
- /* int path_len; */
-
-
- if (lstat (path, &sbuf) < 0)
- return 1;
- if (S_ISDIR (sbuf.st_mode))
- {
-
- /* path_len=strlen(path); */
- dirp = opendir (path);
- if (dirp == 0)
- return 1;
- while (dp = readdir (dirp))
- {
- if (is_dot_or_dotdot (dp->d_name))
- continue;
- path_buf = new_name (path, dp->d_name);
- if (recursively_delete (path_buf))
- {
- free (path_buf);
- closedir (dirp);
- return 1;
- }
- free (path_buf);
- }
- closedir (dirp);
-
- if (rmdir (path) < 0)
- return 1;
- return 0;
- }
- if (unlink (path) < 0)
- return 1;
- return 0;
-}
diff --git a/gnu/usr.bin/tar/list.c b/gnu/usr.bin/tar/list.c
deleted file mode 100644
index 79d2654..0000000
--- a/gnu/usr.bin/tar/list.c
+++ /dev/null
@@ -1,886 +0,0 @@
-/* List a tar archive.
- Copyright (C) 1988, 1992, 1993 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * List a tar archive.
- *
- * Also includes support routines for reading a tar archive.
- *
- * this version written 26 Aug 1985 by John Gilmore (ihnp4!hoptoad!gnu).
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-#include <time.h>
-
-#ifdef BSD42
-#include <sys/file.h>
-#else
-#ifndef V7
-#include <fcntl.h>
-#endif
-#endif
-
-#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
-
-#include "tar.h"
-#include "port.h"
-
-extern FILE *msg_file;
-
-long from_oct (); /* Decode octal number */
-void demode (); /* Print file mode */
-void restore_saved_dir_info ();
-PTR ck_malloc ();
-
-union record *head; /* Points to current archive header */
-struct stat hstat; /* Stat struct corresponding */
-int head_standard; /* Tape header is in ANSI format */
-
-int check_exclude ();
-void close_archive ();
-void decode_header ();
-int findgid ();
-int finduid ();
-void name_gather ();
-int name_match ();
-void names_notfound ();
-void open_archive ();
-void print_header ();
-int read_header ();
-void saverec ();
-void skip_file ();
-void skip_extended_headers ();
-
-extern char *quote_copy_string ();
-
-
-/*
- * Main loop for reading an archive.
- */
-void
-read_and (do_something)
- void (*do_something) ();
-{
- int status = 3; /* Initial status at start of archive */
- int prev_status;
- extern time_t new_time;
- char save_linkflag;
-
- name_gather (); /* Gather all the names */
- open_archive (1); /* Open for reading */
-
- for (;;)
- {
- prev_status = status;
- status = read_header ();
- /* check if the namelist got emptied during the course of reading */
- /* the tape, if so stop by setting status to EOF */
- if ((namelist == NULL) && nlpsfreed) {
- status = EOF;
- }
- switch (status)
- {
-
- case 1: /* Valid header */
- /* We should decode next field (mode) first... */
- /* Ensure incoming names are null terminated. */
-
- if (!name_match (current_file_name)
- || (f_new_files && hstat.st_mtime < new_time)
- || (f_exclude && check_exclude (current_file_name)))
- {
-
- int isextended = 0;
-
- if (head->header.linkflag == LF_VOLHDR
- || head->header.linkflag == LF_MULTIVOL
- || head->header.linkflag == LF_NAMES)
- {
- (*do_something) ();
- continue;
- }
- if (f_show_omitted_dirs
- && head->header.linkflag == LF_DIR)
- msg ("Omitting %s\n", current_file_name);
- /* Skip past it in the archive */
- if (head->header.isextended)
- isextended = 1;
- save_linkflag = head->header.linkflag;
- userec (head);
- if (isextended)
- {
- /* register union record *exhdr;
-
- for (;;) {
- exhdr = findrec();
- if (!exhdr->ext_hdr.isextended) {
- userec(exhdr);
- break;
- }
- }
- userec(exhdr);*/
- skip_extended_headers ();
- }
- /* Skip to the next header on the archive */
- if (save_linkflag != LF_DIR)
- skip_file ((long) hstat.st_size);
- continue;
-
- }
-
- (*do_something) ();
- continue;
-
- /*
- * If the previous header was good, tell them
- * that we are skipping bad ones.
- */
- case 0: /* Invalid header */
- userec (head);
- switch (prev_status)
- {
- case 3: /* Error on first record */
- msg ("Hmm, this doesn't look like a tar archive.");
- /* FALL THRU */
- case 2: /* Error after record of zeroes */
- case 1: /* Error after header rec */
- msg ("Skipping to next file header...");
- case 0: /* Error after error */
- break;
- }
- continue;
-
- case 2: /* Record of zeroes */
- userec (head);
- status = prev_status; /* If error after 0's */
- if (f_ignorez)
- continue;
- /* FALL THRU */
- case EOF: /* End of archive */
- break;
- }
- break;
- };
-
- restore_saved_dir_info ();
- close_archive ();
- names_notfound (); /* Print names not found */
-}
-
-
-/*
- * Print a header record, based on tar options.
- */
-void
-list_archive ()
-{
- extern char *save_name;
- int isextended = 0; /* Flag to remember if head is extended */
-
- /* Save the record */
- saverec (&head);
-
- /* Print the header record */
- if (f_verbose)
- {
- if (f_verbose > 1)
- decode_header (head, &hstat, &head_standard, 0);
- print_header ();
- }
-
- if (f_gnudump && head->header.linkflag == LF_DUMPDIR)
- {
- size_t size, written, check;
- char *data;
- extern long save_totsize;
- extern long save_sizeleft;
-
- userec (head);
- if (f_multivol)
- {
- save_name = current_file_name;
- save_totsize = hstat.st_size;
- }
- for (size = hstat.st_size; size > 0; size -= written)
- {
- if (f_multivol)
- save_sizeleft = size;
- data = findrec ()->charptr;
- if (data == NULL)
- {
- msg ("EOF in archive file?");
- break;
- }
- written = endofrecs ()->charptr - data;
- if (written > size)
- written = size;
- errno = 0;
- check = fwrite (data, sizeof (char), written, msg_file);
- userec ((union record *) (data + written - 1));
- if (check != written)
- {
- msg_perror ("only wrote %ld of %ld bytes to file %s", check, written, current_file_name);
- skip_file ((long) (size) - written);
- break;
- }
- }
- if (f_multivol)
- save_name = 0;
- saverec ((union record **) 0); /* Unsave it */
- fputc ('\n', msg_file);
- fflush (msg_file);
- return;
-
- }
- saverec ((union record **) 0);/* Unsave it */
- /* Check to see if we have an extended header to skip over also */
- if (head->header.isextended)
- isextended = 1;
-
- /* Skip past the header in the archive */
- userec (head);
-
- /*
- * If we needed to skip any extended headers, do so now, by
- * reading extended headers and skipping past them in the
- * archive.
- */
- if (isextended)
- {
- /* register union record *exhdr;
-
- for (;;) {
- exhdr = findrec();
-
- if (!exhdr->ext_hdr.isextended) {
- userec(exhdr);
- break;
- }
- userec(exhdr);
- }*/
- skip_extended_headers ();
- }
-
- if (f_multivol)
- save_name = current_file_name;
- /* Skip to the next header on the archive */
-
- skip_file ((long) hstat.st_size);
-
- if (f_multivol)
- save_name = 0;
-}
-
-
-/*
- * Read a record that's supposed to be a header record.
- * Return its address in "head", and if it is good, the file's
- * size in hstat.st_size.
- *
- * Return 1 for success, 0 if the checksum is bad, EOF on eof,
- * 2 for a record full of zeros (EOF marker).
- *
- * You must always userec(head) to skip past the header which this
- * routine reads.
- */
-int
-read_header ()
-{
- register int i;
- register long sum, signed_sum, recsum;
- register char *p;
- register union record *header;
- long from_oct ();
- char **longp;
- char *bp, *data;
- int size, written;
- static char *next_long_name, *next_long_link;
- char *name;
-
-recurse:
-
- header = findrec ();
- head = header; /* This is our current header */
- if (NULL == header)
- return EOF;
-
- recsum = from_oct (8, header->header.chksum);
-
- signed_sum = sum = 0;
- p = header->charptr;
- for (i = sizeof (*header); --i >= 0;)
- {
- /*
- * We can't use unsigned char here because of old compilers,
- * e.g. V7.
- */
- signed_sum += *p;
- sum += 0xFF & *p++;
- }
-
- /* Adjust checksum to count the "chksum" field as blanks. */
- for (i = sizeof (header->header.chksum); --i >= 0;)
- {
- sum -= 0xFF & header->header.chksum[i];
- signed_sum -= (char) header->header.chksum[i];
- }
- sum += ' ' * sizeof header->header.chksum;
- signed_sum += ' ' * sizeof header->header.chksum;
-
- if (sum == 8 * ' ')
- {
- /*
- * This is a zeroed record...whole record is 0's except
- * for the 8 blanks we faked for the checksum field.
- */
- return 2;
- }
-
- if (sum != recsum && signed_sum != recsum)
- return 0;
-
- /*
- * Good record. Decode file size and return.
- */
- if (header->header.linkflag == LF_LINK)
- hstat.st_size = 0; /* Links 0 size on tape */
- else
- hstat.st_size = from_oct (1 + 12, header->header.size);
-
- header->header.arch_name[NAMSIZ - 1] = '\0';
- if (header->header.linkflag == LF_LONGNAME
- || header->header.linkflag == LF_LONGLINK)
- {
- longp = ((header->header.linkflag == LF_LONGNAME)
- ? &next_long_name
- : &next_long_link);
-
- userec (header);
- if (*longp)
- free (*longp);
- bp = *longp = (char *) ck_malloc (hstat.st_size);
-
- for (size = hstat.st_size;
- size > 0;
- size -= written)
- {
- data = findrec ()->charptr;
- if (data == NULL)
- {
- msg ("Unexpected EOF on archive file");
- break;
- }
- written = endofrecs ()->charptr - data;
- if (written > size)
- written = size;
-
- bcopy (data, bp, written);
- bp += written;
- userec ((union record *) (data + written - 1));
- }
- goto recurse;
- }
- else
- {
- name = (next_long_name
- ? next_long_name
- : head->header.arch_name);
- if (current_file_name)
- free (current_file_name);
- current_file_name = ck_malloc (strlen (name) + 1);
- strcpy (current_file_name, name);
-
- name = (next_long_link
- ? next_long_link
- : head->header.arch_linkname);
- if (current_link_name)
- free (current_link_name);
- current_link_name = ck_malloc (strlen (name) + 1);
- strcpy (current_link_name, name);
-
- next_long_link = next_long_name = 0;
- return 1;
- }
-}
-
-
-/*
- * Decode things from a file header record into a "struct stat".
- * Also set "*stdp" to !=0 or ==0 depending whether header record is "Unix
- * Standard" tar format or regular old tar format.
- *
- * read_header() has already decoded the checksum and length, so we don't.
- *
- * If wantug != 0, we want the uid/group info decoded from Unix Standard
- * tapes (for extraction). If == 0, we are just printing anyway, so save time.
- *
- * decode_header should NOT be called twice for the same record, since the
- * two calls might use different "wantug" values and thus might end up with
- * different uid/gid for the two calls. If anybody wants the uid/gid they
- * should decode it first, and other callers should decode it without uid/gid
- * before calling a routine, e.g. print_header, that assumes decoded data.
- */
-void
-decode_header (header, st, stdp, wantug)
- register union record *header;
- register struct stat *st;
- int *stdp;
- int wantug;
-{
- long from_oct ();
-
- st->st_mode = from_oct (8, header->header.mode);
- st->st_mode &= 07777;
- st->st_mtime = from_oct (1 + 12, header->header.mtime);
- if (f_gnudump)
- {
- st->st_atime = from_oct (1 + 12, header->header.atime);
- st->st_ctime = from_oct (1 + 12, header->header.ctime);
- }
-
- if (0 == strcmp (header->header.magic, TMAGIC))
- {
- /* Unix Standard tar archive */
- *stdp = 1;
- if (wantug)
- {
-#ifdef NONAMES
- st->st_uid = from_oct (8, header->header.uid);
- st->st_gid = from_oct (8, header->header.gid);
-#else
- st->st_uid =
- (*header->header.uname
- ? finduid (header->header.uname)
- : from_oct (8, header->header.uid));
- st->st_gid =
- (*header->header.gname
- ? findgid (header->header.gname)
- : from_oct (8, header->header.gid));
-#endif
- }
-#if defined(S_IFBLK) || defined(S_IFCHR)
- switch (header->header.linkflag)
- {
- case LF_BLK:
- case LF_CHR:
- st->st_rdev = makedev (from_oct (8, header->header.devmajor),
- from_oct (8, header->header.devminor));
- }
-#endif
- }
- else
- {
- /* Old fashioned tar archive */
- *stdp = 0;
- st->st_uid = from_oct (8, header->header.uid);
- st->st_gid = from_oct (8, header->header.gid);
- st->st_rdev = 0;
- }
-}
-
-
-/*
- * Quick and dirty octal conversion.
- *
- * Result is -1 if the field is invalid (all blank, or nonoctal).
- */
-long
-from_oct (digs, where)
- register int digs;
- register char *where;
-{
- register long value;
-
- while (isspace ((unsigned char) *where))
- { /* Skip spaces */
- where++;
- if (--digs <= 0)
- return -1; /* All blank field */
- }
- value = 0;
- while (digs > 0 && isodigit (*where))
- { /* Scan til nonoctal */
- value = (value << 3) | (*where++ - '0');
- --digs;
- }
-
- if (digs > 0 && *where && !isspace ((unsigned char) *where))
- return -1; /* Ended on non-space/nul */
-
- return value;
-}
-
-
-/*
- * Actually print it.
- *
- * Plain and fancy file header block logging.
- * Non-verbose just prints the name, e.g. for "tar t" or "tar x".
- * This should just contain file names, so it can be fed back into tar
- * with xargs or the "-T" option. The verbose option can give a bunch
- * of info, one line per file. I doubt anybody tries to parse its
- * format, or if they do, they shouldn't. Unix tar is pretty random here
- * anyway.
- *
- * Note that print_header uses the globals <head>, <hstat>, and
- * <head_standard>, which must be set up in advance. This is not very clean
- * and should be cleaned up. FIXME.
- */
-#define UGSWIDTH 18 /* min width of User, group, size */
-/* UGSWIDTH of 18 means that with user and group names <= 8 chars the columns
- never shift during the listing. */
-#define DATEWIDTH 19 /* Last mod date */
-static int ugswidth = UGSWIDTH; /* Max width encountered so far */
-
-void
-print_header ()
-{
- char modes[11];
- char timestamp[80];
- char uform[11], gform[11]; /* These hold formatted ints */
- char *user, *group;
- char size[24]; /* Holds a formatted long or maj, min */
- time_t longie;
- int pad;
- char *name;
- extern long baserec;
-
- if (f_sayblock)
- fprintf (msg_file, "rec %10d: ", baserec + (ar_record - ar_block));
- /* annofile(msg_file, (char *)NULL); */
-
- if (f_verbose <= 1)
- {
- /* Just the fax, mam. */
- char *name;
-
- name = quote_copy_string (current_file_name);
- if (name == 0)
- name = current_file_name;
- fprintf (msg_file, "%s\n", name);
- if (name != current_file_name)
- free (name);
- }
- else
- {
- /* File type and modes */
- modes[0] = '?';
- switch (head->header.linkflag)
- {
- case LF_VOLHDR:
- modes[0] = 'V';
- break;
-
- case LF_MULTIVOL:
- modes[0] = 'M';
- break;
-
- case LF_NAMES:
- modes[0] = 'N';
- break;
-
- case LF_LONGNAME:
- case LF_LONGLINK:
- msg ("Visible longname error\n");
- break;
-
- case LF_SPARSE:
- case LF_NORMAL:
- case LF_OLDNORMAL:
- case LF_LINK:
- modes[0] = '-';
- if ('/' == current_file_name[strlen (current_file_name) - 1])
- modes[0] = 'd';
- break;
- case LF_DUMPDIR:
- modes[0] = 'd';
- break;
- case LF_DIR:
- modes[0] = 'd';
- break;
- case LF_SYMLINK:
- modes[0] = 'l';
- break;
- case LF_BLK:
- modes[0] = 'b';
- break;
- case LF_CHR:
- modes[0] = 'c';
- break;
- case LF_FIFO:
- modes[0] = 'p';
- break;
- case LF_CONTIG:
- modes[0] = 'C';
- break;
- }
-
- demode ((unsigned) hstat.st_mode, modes + 1);
-
- /* Timestamp */
- longie = hstat.st_mtime;
- strftime(timestamp, sizeof(timestamp), "%c", localtime(&longie));
- timestamp[16] = '\0';
- timestamp[24] = '\0';
-
- /* User and group names */
- if (*head->header.uname && head_standard)
- {
- user = head->header.uname;
- }
- else
- {
- user = uform;
- (void) sprintf (uform, "%d",
- from_oct (8, head->header.uid));
- }
- if (*head->header.gname && head_standard)
- {
- group = head->header.gname;
- }
- else
- {
- group = gform;
- (void) sprintf (gform, "%d",
- from_oct (8, head->header.gid));
- }
-
- /* Format the file size or major/minor device numbers */
- switch (head->header.linkflag)
- {
-#if defined(S_IFBLK) || defined(S_IFCHR)
- case LF_CHR:
- case LF_BLK:
- (void) sprintf (size, "%d,%d",
- major (hstat.st_rdev),
- minor (hstat.st_rdev));
- break;
-#endif
- case LF_SPARSE:
- (void) sprintf (size, "%ld",
- from_oct (1 + 12, head->header.realsize));
- break;
- default:
- (void) sprintf (size, "%ld", (long) hstat.st_size);
- }
-
- /* Figure out padding and print the whole line. */
- pad = strlen (user) + strlen (group) + strlen (size) + 1;
- if (pad > ugswidth)
- ugswidth = pad;
-
- name = quote_copy_string (current_file_name);
- if (!name)
- name = current_file_name;
- fprintf (msg_file, "%s %s/%s %*s%s %s %s %s",
- modes,
- user,
- group,
- ugswidth - pad,
- "",
- size,
- timestamp + 4, timestamp + 20,
- name);
-
- if (name != current_file_name)
- free (name);
- switch (head->header.linkflag)
- {
- case LF_SYMLINK:
- name = quote_copy_string (current_link_name);
- if (!name)
- name = current_link_name;
- fprintf (msg_file, " -> %s\n", name);
- if (name != current_link_name)
- free (name);
- break;
-
- case LF_LINK:
- name = quote_copy_string (current_link_name);
- if (!name)
- name = current_link_name;
- fprintf (msg_file, " link to %s\n", current_link_name);
- if (name != current_link_name)
- free (name);
- break;
-
- default:
- fprintf (msg_file, " unknown file type '%c'\n",
- head->header.linkflag);
- break;
-
- case LF_OLDNORMAL:
- case LF_NORMAL:
- case LF_SPARSE:
- case LF_CHR:
- case LF_BLK:
- case LF_DIR:
- case LF_FIFO:
- case LF_CONTIG:
- case LF_DUMPDIR:
- putc ('\n', msg_file);
- break;
-
- case LF_VOLHDR:
- fprintf (msg_file, "--Volume Header--\n");
- break;
-
- case LF_MULTIVOL:
- fprintf (msg_file, "--Continued at byte %ld--\n", from_oct (1 + 12, head->header.offset));
- break;
-
- case LF_NAMES:
- fprintf (msg_file, "--Mangled file names--\n");
- break;
- }
- }
- fflush (msg_file);
-}
-
-/*
- * Print a similar line when we make a directory automatically.
- */
-void
-pr_mkdir (pathname, length, mode)
- char *pathname;
- int length;
- int mode;
-{
- char modes[11];
- char *name;
- extern long baserec;
-
- if (f_verbose > 1)
- {
- /* File type and modes */
- modes[0] = 'd';
- demode ((unsigned) mode, modes + 1);
-
- if (f_sayblock)
- fprintf (msg_file, "rec %10d: ", baserec + (ar_record - ar_block));
- /* annofile(msg_file, (char *)NULL); */
- name = quote_copy_string (pathname);
- if (!name)
- name = pathname;
- fprintf (msg_file, "%s %*s %.*s\n",
- modes,
- ugswidth + DATEWIDTH,
- "Creating directory:",
- length,
- pathname);
- if (name != pathname)
- free (name);
- }
-}
-
-
-/*
- * Skip over <size> bytes of data in records in the archive.
- */
-void
-skip_file (size)
- register long size;
-{
- union record *x;
- extern long save_totsize;
- extern long save_sizeleft;
-
- if (f_multivol)
- {
- save_totsize = size;
- save_sizeleft = size;
- }
-
- while (size > 0)
- {
- x = findrec ();
- if (x == NULL)
- { /* Check it... */
- msg ("Unexpected EOF on archive file");
- exit (EX_BADARCH);
- }
- userec (x);
- size -= RECORDSIZE;
- if (f_multivol)
- save_sizeleft -= RECORDSIZE;
- }
-}
-
-void
-skip_extended_headers ()
-{
- register union record *exhdr;
-
- for (;;)
- {
- exhdr = findrec ();
- if (!exhdr->ext_hdr.isextended)
- {
- userec (exhdr);
- break;
- }
- userec (exhdr);
- }
-}
-
-/*
- * Decode the mode string from a stat entry into a 9-char string and a null.
- */
-void
-demode (mode, string)
- register unsigned mode;
- register char *string;
-{
- register unsigned mask;
- register char *rwx = "rwxrwxrwx";
-
- for (mask = 0400; mask != 0; mask >>= 1)
- {
- if (mode & mask)
- *string++ = *rwx++;
- else
- {
- *string++ = '-';
- rwx++;
- }
- }
-
- if (mode & S_ISUID)
- if (string[-7] == 'x')
- string[-7] = 's';
- else
- string[-7] = 'S';
- if (mode & S_ISGID)
- if (string[-4] == 'x')
- string[-4] = 's';
- else
- string[-4] = 'S';
- if (mode & S_ISVTX)
- if (string[-1] == 'x')
- string[-1] = 't';
- else
- string[-1] = 'T';
- *string = '\0';
-}
diff --git a/gnu/usr.bin/tar/mangle.c b/gnu/usr.bin/tar/mangle.c
deleted file mode 100644
index 6281684..0000000
--- a/gnu/usr.bin/tar/mangle.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/* mangle.c -- encode long filenames
- Copyright (C) 1988, 1992 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <time.h>
-time_t time ();
-
-#include "tar.h"
-#include "port.h"
-
-void add_buffer ();
-extern PTR ck_malloc ();
-void finish_header ();
-extern PTR init_buffer ();
-extern char *quote_copy_string ();
-extern char *get_buffer ();
-char *un_quote_string ();
-
-extern union record *start_header ();
-
-extern struct stat hstat; /* Stat struct corresponding */
-
-struct mangled
- {
- struct mangled *next;
- int type;
- char mangled[NAMSIZ];
- char *linked_to;
- char normal[1];
- };
-
-
-/* Should use a hash table, etc. . */
-struct mangled *first_mangle;
-int mangled_num = 0;
-
-#if 0 /* Deleted because there is now a better way to do all this */
-
-char *
-find_mangled (name)
- char *name;
-{
- struct mangled *munge;
-
- for (munge = first_mangle; munge; munge = munge->next)
- if (!strcmp (name, munge->normal))
- return munge->mangled;
- return 0;
-}
-
-
-#ifdef S_ISLNK
-void
-add_symlink_mangle (symlink, linkto, buffer)
- char *symlink;
- char *linkto;
- char *buffer;
-{
- struct mangled *munge, *kludge;
-
- munge = (struct mangled *) ck_malloc (sizeof (struct mangled) + strlen (symlink) + strlen (linkto) + 2);
- if (!first_mangle)
- first_mangle = munge;
- else
- {
- for (kludge = first_mangle; kludge->next; kludge = kludge->next)
- ;
- kludge->next = munge;
- }
- munge->type = 1;
- munge->next = 0;
- strcpy (munge->normal, symlink);
- munge->linked_to = munge->normal + strlen (symlink) + 1;
- strcpy (munge->linked_to, linkto);
- sprintf (munge->mangled, "@@MaNgLeD.%d", mangled_num++);
- strncpy (buffer, munge->mangled, NAMSIZ);
-}
-
-#endif
-
-void
-add_mangle (name, buffer)
- char *name;
- char *buffer;
-{
- struct mangled *munge, *kludge;
-
- munge = (struct mangled *) ck_malloc (sizeof (struct mangled) + strlen (name));
- if (!first_mangle)
- first_mangle = munge;
- else
- {
- for (kludge = first_mangle; kludge->next; kludge = kludge->next)
- ;
- kludge->next = munge;
- }
- munge->next = 0;
- munge->type = 0;
- strcpy (munge->normal, name);
- sprintf (munge->mangled, "@@MaNgLeD.%d", mangled_num++);
- strncpy (buffer, munge->mangled, NAMSIZ);
-}
-
-void
-write_mangled ()
-{
- struct mangled *munge;
- struct stat hstat;
- union record *header;
- char *ptr1, *ptr2;
- PTR the_buffer;
- int size;
- int bufsize;
-
- if (!first_mangle)
- return;
- the_buffer = init_buffer ();
- for (munge = first_mangle, size = 0; munge; munge = munge->next)
- {
- ptr1 = quote_copy_string (munge->normal);
- if (!ptr1)
- ptr1 = munge->normal;
- if (munge->type)
- {
- add_buffer (the_buffer, "Symlink ", 8);
- add_buffer (the_buffer, ptr1, strlen (ptr1));
- add_buffer (the_buffer, " to ", 4);
-
- if (ptr2 = quote_copy_string (munge->linked_to))
- {
- add_buffer (the_buffer, ptr2, strlen (ptr2));
- free (ptr2);
- }
- else
- add_buffer (the_buffer, munge->linked_to, strlen (munge->linked_to));
- }
- else
- {
- add_buffer (the_buffer, "Rename ", 7);
- add_buffer (the_buffer, munge->mangled, strlen (munge->mangled));
- add_buffer (the_buffer, " to ", 4);
- add_buffer (the_buffer, ptr1, strlen (ptr1));
- }
- add_buffer (the_buffer, "\n", 1);
- if (ptr1 != munge->normal)
- free (ptr1);
- }
-
- bzero (&hstat, sizeof (struct stat));
- hstat.st_atime = hstat.st_mtime = hstat.st_ctime = time (0);
- ptr1 = get_buffer (the_buffer);
- hstat.st_size = strlen (ptr1);
-
- header = start_header ("././@MaNgLeD_NaMeS", &hstat);
- header->header.linkflag = LF_NAMES;
- finish_header (header);
- size = hstat.st_size;
- header = findrec ();
- bufsize = endofrecs ()->charptr - header->charptr;
-
- while (bufsize < size)
- {
- bcopy (ptr1, header->charptr, bufsize);
- ptr1 += bufsize;
- size -= bufsize;
- userec (header + (bufsize - 1) / RECORDSIZE);
- header = findrec ();
- bufsize = endofrecs ()->charptr - header->charptr;
- }
- bcopy (ptr1, header->charptr, size);
- bzero (header->charptr + size, bufsize - size);
- userec (header + (size - 1) / RECORDSIZE);
-}
-
-#endif
-
-void
-extract_mangle (head)
- union record *head;
-{
- char *buf;
- char *fromtape;
- char *to;
- char *ptr, *ptrend;
- char *nam1, *nam1end;
- int size;
- int copied;
-
- size = hstat.st_size;
- buf = to = ck_malloc (size + 1);
- buf[size] = '\0';
- while (size > 0)
- {
- fromtape = findrec ()->charptr;
- if (fromtape == 0)
- {
- msg ("Unexpected EOF in mangled names!");
- return;
- }
- copied = endofrecs ()->charptr - fromtape;
- if (copied > size)
- copied = size;
- bcopy (fromtape, to, copied);
- to += copied;
- size -= copied;
- userec ((union record *) (fromtape + copied - 1));
- }
- for (ptr = buf; *ptr; ptr = ptrend)
- {
- ptrend = index (ptr, '\n');
- *ptrend++ = '\0';
-
- if (!strncmp (ptr, "Rename ", 7))
- {
- nam1 = ptr + 7;
- nam1end = index (nam1, ' ');
- while (strncmp (nam1end, " to ", 4))
- {
- nam1end++;
- nam1end = index (nam1end, ' ');
- }
- *nam1end = '\0';
- if (ptrend[-2] == '/')
- ptrend[-2] = '\0';
- un_quote_string (nam1end + 4);
- if (rename (nam1, nam1end + 4))
- msg_perror ("Can't rename %s to %s", nam1, nam1end + 4);
- else if (f_verbose)
- msg ("Renamed %s to %s", nam1, nam1end + 4);
- }
-#ifdef S_ISLNK
- else if (!strncmp (ptr, "Symlink ", 8))
- {
- nam1 = ptr + 8;
- nam1end = index (nam1, ' ');
- while (strncmp (nam1end, " to ", 4))
- {
- nam1end++;
- nam1end = index (nam1end, ' ');
- }
- *nam1end = '\0';
- un_quote_string (nam1);
- un_quote_string (nam1end + 4);
- if (symlink (nam1, nam1end + 4) && (unlink (nam1end + 4) || symlink (nam1, nam1end + 4)))
- msg_perror ("Can't symlink %s to %s", nam1, nam1end + 4);
- else if (f_verbose)
- msg ("Symlinkd %s to %s", nam1, nam1end + 4);
- }
-#endif
- else
- msg ("Unknown demangling command %s", ptr);
- }
-}
diff --git a/gnu/usr.bin/tar/msd_dir.h b/gnu/usr.bin/tar/msd_dir.h
deleted file mode 100644
index 06c7a64..0000000
--- a/gnu/usr.bin/tar/msd_dir.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * @(#)msd_dir.h 1.4 87/11/06 Public Domain.
- *
- * A public domain implementation of BSD directory routines for
- * MS-DOS. Written by Michael Rendell ({uunet,utai}michael@garfield),
- * August 1897
- */
-
-#define rewinddir(dirp) seekdir(dirp, 0L)
-
-#define MAXNAMLEN 12
-
-#ifdef __TURBOC__
-typedef int ino_t;
-typedef int dev_t;
-#endif
-
-struct dirent
- {
- ino_t d_ino; /* a bit of a farce */
- int d_reclen; /* more farce */
- int d_namlen; /* length of d_name */
- char d_name[MAXNAMLEN + 1]; /* garentee null termination */
- };
-
-struct _dircontents
- {
- char *_d_entry;
- struct _dircontents *_d_next;
- };
-
-typedef struct _dirdesc
- {
- int dd_id; /* uniquely identify each open directory */
- long dd_loc; /* where we are in directory entry is this */
- struct _dircontents *dd_contents; /* pointer to contents of dir */
- struct _dircontents *dd_cp; /* pointer to current position */
- } DIR;
-
-extern DIR *opendir ();
-extern struct dirent *readdir ();
-extern void seekdir ();
-extern long telldir ();
-extern void closedir ();
diff --git a/gnu/usr.bin/tar/names.c b/gnu/usr.bin/tar/names.c
deleted file mode 100644
index 0de6a88..0000000
--- a/gnu/usr.bin/tar/names.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* Look up user and/or group names.
- Copyright (C) 1988, 1992 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * Look up user and/or group names.
- *
- * This file should be modified for non-unix systems to do something
- * reasonable.
- */
-
-#include <sys/types.h>
-#include "tar.h"
-#include "port.h"
-
-#ifndef NONAMES
-/* Whole module goes away if NONAMES defined. Otherwise... */
-#include <stdio.h>
-#include <pwd.h>
-#include <grp.h>
-
-static int saveuid = -993;
-static char saveuname[TUNMLEN];
-static int my_uid = -993;
-
-static int savegid = -993;
-static char savegname[TGNMLEN];
-static int my_gid = -993;
-
-#define myuid ( my_uid < 0? (my_uid = getuid()): my_uid )
-#define mygid ( my_gid < 0? (my_gid = getgid()): my_gid )
-
-/*
- * Look up a user or group name from a uid/gid, maintaining a cache.
- * FIXME, for now it's a one-entry cache.
- * FIXME2, the "-993" is to reduce the chance of a hit on the first lookup.
- *
- * This is ifdef'd because on Suns, it drags in about 38K of "yellow
- * pages" code, roughly doubling the program size. Thanks guys.
- */
-void
-finduname (uname, uid)
- char uname[TUNMLEN];
- int uid;
-{
- struct passwd *pw;
-#ifndef HAVE_GETPWUID
- extern struct passwd *getpwuid ();
-#endif
-
- if (uid != saveuid)
- {
- saveuid = uid;
- saveuname[0] = '\0';
- pw = getpwuid (uid);
- if (pw)
- strncpy (saveuname, pw->pw_name, TUNMLEN);
- }
- strncpy (uname, saveuname, TUNMLEN);
-}
-
-int
-finduid (uname)
- char uname[TUNMLEN];
-{
- struct passwd *pw;
- extern struct passwd *getpwnam ();
-
- if (uname[0] != saveuname[0] /* Quick test w/o proc call */
- || 0 != strncmp (uname, saveuname, TUNMLEN))
- {
- strncpy (saveuname, uname, TUNMLEN);
- pw = getpwnam (uname);
- if (pw)
- {
- saveuid = pw->pw_uid;
- }
- else
- {
- saveuid = myuid;
- }
- }
- return saveuid;
-}
-
-
-void
-findgname (gname, gid)
- char gname[TGNMLEN];
- int gid;
-{
- struct group *gr;
-#ifndef HAVE_GETGRGID
- extern struct group *getgrgid ();
-#endif
-
- if (gid != savegid)
- {
- savegid = gid;
- savegname[0] = '\0';
- (void) setgrent ();
- gr = getgrgid (gid);
- if (gr)
- strncpy (savegname, gr->gr_name, TGNMLEN);
- }
- (void) strncpy (gname, savegname, TGNMLEN);
-}
-
-
-int
-findgid (gname)
- char gname[TUNMLEN];
-{
- struct group *gr;
- extern struct group *getgrnam ();
-
- if (gname[0] != savegname[0] /* Quick test w/o proc call */
- || 0 != strncmp (gname, savegname, TUNMLEN))
- {
- strncpy (savegname, gname, TUNMLEN);
- gr = getgrnam (gname);
- if (gr)
- {
- savegid = gr->gr_gid;
- }
- else
- {
- savegid = mygid;
- }
- }
- return savegid;
-}
-
-#endif
diff --git a/gnu/usr.bin/tar/open3.h b/gnu/usr.bin/tar/open3.h
deleted file mode 100644
index c1c0e59..0000000
--- a/gnu/usr.bin/tar/open3.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Defines for Sys V style 3-argument open call.
- Copyright (C) 1988 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * open3.h -- #defines for the various flags for the Sys V style 3-argument
- * open() call. On BSD or System 5, the system already has this in an
- * include file. This file is needed for V7 and MINIX systems for the
- * benefit of open3() in port.c, a routine that emulates the 3-argument
- * call using system calls available on V7/MINIX.
- *
- * This file is needed by PD tar even if we aren't using the
- * emulator, since the #defines for O_WRONLY, etc. are used in
- * a couple of places besides the open() calls, (e.g. in the assignment
- * to openflag in extract.c). We just #include this rather than
- * #ifdef them out.
- *
- * Written 6/10/87 by rmtodd@uokmax (Richard Todd).
- *
- * The names have been changed by John Gilmore, 31 July 1987, since
- * Richard called it "bsdopen", and really this change was introduced in
- * AT&T Unix systems before BSD picked it up.
- */
-
-/* Only one of the next three should be specified */
-#define O_RDONLY 0 /* only allow read */
-#define O_WRONLY 1 /* only allow write */
-#define O_RDWR 2 /* both are allowed */
-
-/* The rest of these can be OR-ed in to the above. */
-/*
- * O_NDELAY isn't implemented by the emulator. It's only useful (to tar) on
- * systems that have named pipes anyway; it prevents tar's hanging by
- * opening a named pipe. We #ifndef it because some systems already have
- * it defined.
- */
-#ifndef O_NDELAY
-#define O_NDELAY 4 /* don't block on opening devices that would
- * block on open -- ignored by emulator. */
-#endif
-#define O_CREAT 8 /* create file if needed */
-#define O_EXCL 16 /* file cannot already exist */
-#define O_TRUNC 32 /* truncate file on open */
-#define O_APPEND 64 /* always write at end of file -- ignored by emul */
-
-#ifdef EMUL_OPEN3
-/*
- * make emulation transparent to rest of file -- redirect all open() calls
- * to our routine
- */
-#define open open3
-#endif
diff --git a/gnu/usr.bin/tar/pathmax.h b/gnu/usr.bin/tar/pathmax.h
deleted file mode 100644
index aeba9f7..0000000
--- a/gnu/usr.bin/tar/pathmax.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Define PATH_MAX somehow. Requires sys/types.h.
- Copyright (C) 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef _PATHMAX_H
-#define _PATHMAX_H
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define
- PATH_MAX but might cause redefinition warnings when sys/param.h is
- later included (as on MORE/BSD 4.3). */
-#if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && defined(USG))
-#include <limits.h>
-#endif
-
-#ifndef _POSIX_PATH_MAX
-#define _POSIX_PATH_MAX 255
-#endif
-
-#if !defined(PATH_MAX) && defined(_PC_PATH_MAX)
-#define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX))
-#endif
-
-/* Don't include sys/param.h if it already has been. */
-#if !defined(PATH_MAX) && !defined(MAXPATHLEN) && !defined(__MSDOS__)
-#include <sys/param.h>
-#endif
-
-#if !defined(PATH_MAX) && defined(MAXPATHLEN)
-#define PATH_MAX MAXPATHLEN
-#endif
-
-#ifndef PATH_MAX
-#define PATH_MAX _POSIX_PATH_MAX
-#endif
-
-#endif /* _PATHMAX_H */
diff --git a/gnu/usr.bin/tar/port.c b/gnu/usr.bin/tar/port.c
deleted file mode 100644
index c163245..0000000
--- a/gnu/usr.bin/tar/port.c
+++ /dev/null
@@ -1,1256 +0,0 @@
-/* Supporting routines which may sometimes be missing.
- Copyright (C) 1988, 1992 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-
-#ifdef BSD42
-#include <sys/file.h>
-#else
-#ifndef V7
-#include <fcntl.h>
-#endif
-#endif
-
-#include "tar.h"
-#include "port.h"
-
-extern long baserec;
-
-/* All machine-dependent #ifdefs should appear here, instead of
- being scattered through the file. For UN*X systems, it is better to
- figure out what is needed in the configure script, for most of the
- features. */
-
-#ifdef __MSDOS__
-char TTY_NAME[] = "con";
-#define HAVE_STRSTR
-#define HAVE_RENAME
-#define HAVE_MKDIR
-#else
-char TTY_NAME[] = "/dev/tty";
-#endif
-
-/* End of system-dependent #ifdefs */
-
-
-#ifndef HAVE_VALLOC
-/*
- * valloc() does a malloc() on a page boundary. On some systems,
- * this can make large block I/O more efficient.
- */
-char *
-valloc (size)
- unsigned size;
-{
- return (malloc (size));
-}
-
-#endif /* !HAVE_VALLOC */
-
-#ifndef HAVE_MKDIR
-/*
- * Written by Robert Rother, Mariah Corporation, August 1985.
- *
- * If you want it, it's yours. All I ask in return is that if you
- * figure out how to do this in a Bourne Shell script you send me
- * a copy.
- * sdcsvax!rmr or rmr@uscd
- *
- * Severely hacked over by John Gilmore to make a 4.2BSD compatible
- * subroutine. 11Mar86; hoptoad!gnu
- *
- * Modified by rmtodd@uokmax 6-28-87 -- when making an already existing dir,
- * subroutine didn't return EEXIST. It does now.
- */
-
-/*
- * Make a directory.
- */
-int
-mkdir (dpath, dmode)
- char *dpath;
- int dmode;
-{
- int cpid, status;
- struct stat statbuf;
-
- if (stat (dpath, &statbuf) == 0)
- {
- errno = EEXIST; /* Stat worked, so it already exists */
- return -1;
- }
-
- /* If stat fails for a reason other than non-existence, return error */
- if (errno != ENOENT)
- return -1;
-
- switch (cpid = fork ())
- {
-
- case -1: /* Error in fork() */
- return (-1); /* Errno is set already */
-
- case 0: /* Child process */
- /*
- * Cheap hack to set mode of new directory. Since this
- * child process is going away anyway, we zap its umask.
- * FIXME, this won't suffice to set SUID, SGID, etc. on this
- * directory. Does anybody care?
- */
- status = umask (0); /* Get current umask */
- status = umask (status | (0777 & ~dmode)); /* Set for mkdir */
- execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
- _exit (-1); /* Can't exec /bin/mkdir */
-
- default: /* Parent process */
- while (cpid != wait (&status)); /* Wait for kid to finish */
- }
-
- if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0)
- {
- errno = EIO; /* We don't know why, but */
- return -1; /* /bin/mkdir failed */
- }
-
- return 0;
-}
-
-int
-rmdir (dpath)
- char *dpath;
-{
- int cpid, status;
- struct stat statbuf;
-
- if (stat (dpath, &statbuf) != 0)
- {
- /* Stat just set errno. We don't have to */
- return -1;
- }
-
- switch (cpid = fork ())
- {
-
- case -1: /* Error in fork() */
- return (-1); /* Errno is set already */
-
- case 0: /* Child process */
- execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
- _exit (-1); /* Can't exec /bin/mkdir */
-
- default: /* Parent process */
- while (cpid != wait (&status)); /* Wait for kid to finish */
- }
-
- if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0)
- {
- errno = EIO; /* We don't know why, but */
- return -1; /* /bin/mkdir failed */
- }
-
- return 0;
-}
-
-#endif /* !HAVE_MKDIR */
-
-#ifndef HAVE_RENAME
-/* Rename file FROM to file TO.
- Return 0 if successful, -1 if not. */
-
-int
-rename (from, to)
- char *from;
- char *to;
-{
- struct stat from_stats;
-
- if (stat (from, &from_stats))
- return -1;
-
- if (unlink (to) && errno != ENOENT)
- return -1;
-
- if (link (from, to))
- return -1;
-
- if (unlink (from) && errno != ENOENT)
- {
- unlink (to);
- return -1;
- }
-
- return 0;
-}
-
-#endif /* !HAVE_RENAME */
-
-#ifdef minix
-/* Minix has bcopy but not bzero, and no memset. Thanks, Andy. */
-void
-bzero (s1, n)
- register char *s1;
- register int n;
-{
- while (n--)
- *s1++ = '\0';
-}
-
-/* It also has no bcmp() */
-int
-bcmp (s1, s2, n)
- register char *s1, *s2;
- register int n;
-{
- for (; n--; ++s1, ++s2)
- {
- if (*s1 != *s2)
- return *s1 - *s2;
- }
- return 0;
-}
-
-/*
- * Groan, Minix doesn't have execlp either!
- *
- * execlp(file,arg0,arg1...argn,(char *)NULL)
- * exec a program, automatically searching for the program through
- * all the directories on the PATH.
- *
- * This version is naive about variable argument lists, it assumes
- * a straightforward C calling sequence. If your system has odd stacks
- * *and* doesn't have execlp, YOU get to fix it.
- */
-int
-execlp (filename, arg0)
- char *filename, *arg0;
-{
- register char *p, *path;
- register char *fnbuffer;
- char **argstart = &arg0;
- struct stat statbuf;
- extern char **environ;
-
- if ((p = getenv ("PATH")) == NULL)
- {
- /* couldn't find path variable -- try to exec given filename */
- return execve (filename, argstart, environ);
- }
-
- /*
- * make a place to build the filename. We malloc larger than we
- * need, but we know it will fit in this.
- */
- fnbuffer = malloc (strlen (p) + 1 + strlen (filename));
- if (fnbuffer == NULL)
- {
- errno = ENOMEM;
- return -1;
- }
-
- /*
- * try each component of the path to see if the file's there
- * and executable.
- */
- for (path = p; path; path = p)
- {
- /* construct full path name to try */
- if ((p = index (path, ':')) == NULL)
- {
- strcpy (fnbuffer, path);
- }
- else
- {
- strncpy (fnbuffer, path, p - path);
- fnbuffer[p - path] = '\0';
- p++; /* Skip : for next time */
- }
- if (strlen (fnbuffer) != 0)
- strcat (fnbuffer, "/");
- strcat (fnbuffer, filename);
-
- /* check to see if file is there and is a normal file */
- if (stat (fnbuffer, &statbuf) < 0)
- {
- if (errno == ENOENT)
- continue; /* file not there,keep on looking */
- else
- goto fail; /* failed for some reason, return */
- }
- if (!S_ISREG (statbuf.st_mode))
- continue;
-
- if (execve (fnbuffer, argstart, environ) < 0
- && errno != ENOENT
- && errno != ENOEXEC)
- {
- /* failed, for some other reason besides "file
- * not found" or "not a.out format"
- */
- goto fail;
- }
-
- /*
- * If we got error ENOEXEC, the file is executable but is
- * not an object file. Try to execute it as a shell script,
- * returning error if we can't execute /bin/sh.
- *
- * FIXME, this code is broken in several ways. Shell
- * scripts should not in general be executed by the user's
- * SHELL variable program. On more mature systems, the
- * script can specify with #!/bin/whatever. Also, this
- * code clobbers argstart[-1] if the exec of the shell
- * fails.
- */
- if (errno == ENOEXEC)
- {
- char *shell;
-
- /* Try to execute command "sh arg0 arg1 ..." */
- if ((shell = getenv ("SHELL")) == NULL)
- shell = "/bin/sh";
- argstart[-1] = shell;
- argstart[0] = fnbuffer;
- execve (shell, &argstart[-1], environ);
- goto fail; /* Exec didn't work */
- }
-
- /*
- * If we succeeded, the execve() doesn't return, so we
- * can only be here is if the file hasn't been found yet.
- * Try the next place on the path.
- */
- }
-
- /* all attempts failed to locate the file. Give up. */
- errno = ENOENT;
-
-fail:
- free (fnbuffer);
- return -1;
-}
-
-#endif /* minix */
-
-
-#ifdef EMUL_OPEN3
-#include "open3.h"
-/*
- * open3 -- routine to emulate the 3-argument open system
- * call that is present in most modern Unix systems.
- * This version attempts to support all the flag bits except for O_NDELAY
- * and O_APPEND, which are silently ignored. The emulation is not as efficient
- * as the real thing (at worst, 4 system calls instead of one), but there's
- * not much I can do about that.
- *
- * Written 6/10/87 by rmtodd@uokmax
- *
- * open3(path, flag, mode)
- * Attempts to open the file specified by
- * the given pathname. The following flag bits (#defined in tar.h)
- * specify options to the routine:
- * O_RDONLY file open for read only
- * O_WRONLY file open for write only
- * O_RDWR file open for both read & write
- * (Needless to say, you should only specify one of the above).
- * O_CREAT file is created with specified mode if it needs to be.
- * O_TRUNC if file exists, it is truncated to 0 bytes
- * O_EXCL used with O_CREAT--routine returns error if file exists
- * Function returns file descriptor if successful, -1 and errno if not.
- */
-
-/*
- * array to give arguments to access for various modes
- * FIXME, this table depends on the specific integer values of O_XXX,
- * and also contains integers (args to 'access') that should be #define's.
- */
-static int modes[] =
-{
- 04, /* O_RDONLY */
- 02, /* O_WRONLY */
- 06, /* O_RDWR */
- 06, /* invalid but we'd better cope -- O_WRONLY+O_RDWR */
-};
-
-/* Shut off the automatic emulation of open(), we'll need it. */
-#undef open
-
-int
-open3 (path, flags, mode)
- char *path;
- int flags, mode;
-{
- int exists = 1;
- int call_creat = 0;
- int fd;
- /*
- * We actually do the work by calling the open() or creat() system
- * call, depending on the flags. Call_creat is true if we will use
- * creat(), false if we will use open().
- */
-
- /*
- * See if the file exists and is accessible in the requested mode.
- *
- * Strictly speaking we shouldn't be using access, since access checks
- * against real uid, and the open call should check against euid.
- * Most cases real uid == euid, so it won't matter. FIXME.
- * FIXME, the construction "flags & 3" and the modes table depends
- * on the specific integer values of the O_XXX #define's. Foo!
- */
- if (access (path, modes[flags & 3]) < 0)
- {
- if (errno == ENOENT)
- {
- /* the file does not exist */
- exists = 0;
- }
- else
- {
- /* probably permission violation */
- if (flags & O_EXCL)
- {
- /* Oops, the file exists, we didn't want it. */
- /* No matter what the error, claim EEXIST. */
- errno = EEXIST;
- }
- return -1;
- }
- }
-
- /* if we have the O_CREAT bit set, check for O_EXCL */
- if (flags & O_CREAT)
- {
- if ((flags & O_EXCL) && exists)
- {
- /* Oops, the file exists and we didn't want it to. */
- errno = EEXIST;
- return -1;
- }
- /*
- * If the file doesn't exist, be sure to call creat() so that
- * it will be created with the proper mode.
- */
- if (!exists)
- call_creat = 1;
- }
- else
- {
- /* If O_CREAT isn't set and the file doesn't exist, error. */
- if (!exists)
- {
- errno = ENOENT;
- return -1;
- }
- }
-
- /*
- * If the O_TRUNC flag is set and the file exists, we want to call
- * creat() anyway, since creat() guarantees that the file will be
- * truncated and open()-for-writing doesn't.
- * (If the file doesn't exist, we're calling creat() anyway and the
- * file will be created with zero length.)
- */
- if ((flags & O_TRUNC) && exists)
- call_creat = 1;
- /* actually do the call */
- if (call_creat)
- {
- /*
- * call creat. May have to close and reopen the file if we
- * want O_RDONLY or O_RDWR access -- creat() only gives
- * O_WRONLY.
- */
- fd = creat (path, mode);
- if (fd < 0 || (flags & O_WRONLY))
- return fd;
- if (close (fd) < 0)
- return -1;
- /* Fall out to reopen the file we've created */
- }
-
- /*
- * calling old open, we strip most of the new flags just in case.
- */
- return open (path, flags & (O_RDONLY | O_WRONLY | O_RDWR | O_BINARY));
-}
-
-#endif /* EMUL_OPEN3 */
-
-#ifndef HAVE_MKNOD
-#ifdef __MSDOS__
-typedef int dev_t;
-#endif
-/* Fake mknod by complaining */
-int
-mknod (path, mode, dev)
- char *path;
- unsigned short mode;
- dev_t dev;
-{
- int fd;
-
- errno = ENXIO; /* No such device or address */
- return -1; /* Just give an error */
-}
-
-/* Fake links by copying */
-int
-link (path1, path2)
- char *path1;
- char *path2;
-{
- char buf[256];
- int ifd, ofd;
- int nrbytes;
- int nwbytes;
-
- fprintf (stderr, "%s: %s: cannot link to %s, copying instead\n",
- tar, path1, path2);
- if ((ifd = open (path1, O_RDONLY | O_BINARY)) < 0)
- return -1;
- if ((ofd = creat (path2, 0666)) < 0)
- return -1;
- setmode (ofd, O_BINARY);
- while ((nrbytes = read (ifd, buf, sizeof (buf))) > 0)
- {
- if ((nwbytes = write (ofd, buf, nrbytes)) != nrbytes)
- {
- nrbytes = -1;
- break;
- }
- }
- /* Note use of "|" rather than "||" below: we want to close
- * the files even if an error occurs.
- */
- if ((nrbytes < 0) | (0 != close (ifd)) | (0 != close (ofd)))
- {
- unlink (path2);
- return -1;
- }
- return 0;
-}
-
-/* everyone owns everything on MS-DOS (or is it no one owns anything?) */
-int
-chown (path, uid, gid)
- char *path;
- int uid;
- int gid;
-{
- return 0;
-}
-
-int
-geteuid ()
-{
- return 0;
-}
-
-#endif /* !HAVE_MKNOD */
-
-#ifdef __TURBOC__
-#include <time.h>
-#include <fcntl.h>
-#include <io.h>
-
-struct utimbuf
-{
- time_t actime; /* Access time. */
- time_t modtime; /* Modification time. */
-};
-
-int
-utime (char *filename, struct utimbuf *utb)
-{
- struct tm *tm;
- struct ftime filetime;
- time_t when;
- int fd;
- int status;
-
- if (utb == 0)
- when = time (0);
- else
- when = utb->modtime;
-
- fd = _open (filename, O_RDWR);
- if (fd == -1)
- return -1;
-
- tm = localtime (&when);
- if (tm->tm_year < 80)
- filetime.ft_year = 0;
- else
- filetime.ft_year = tm->tm_year - 80;
- filetime.ft_month = tm->tm_mon + 1;
- filetime.ft_day = tm->tm_mday;
- if (tm->tm_hour < 0)
- filetime.ft_hour = 0;
- else
- filetime.ft_hour = tm->tm_hour;
- filetime.ft_min = tm->tm_min;
- filetime.ft_tsec = tm->tm_sec / 2;
-
- status = setftime (fd, &filetime);
- _close (fd);
- return status;
-}
-
-#endif /* __TURBOC__ */
-
-/* Stash argv[0] here so panic will know what the program is called */
-char *myname = 0;
-
-void
-panic (s)
- char *s;
-{
- if (myname)
- fprintf (stderr, "%s:", myname);
- fprintf (stderr, s);
- putc ('\n', stderr);
- exit (12);
-}
-
-
-PTR
-ck_malloc (size)
- size_t size;
-{
- PTR ret;
-
- if (!size)
- size++;
- ret = malloc (size);
- if (ret == 0)
- panic ("Couldn't allocate memory");
- return ret;
-}
-
-/* Used by alloca.c and bison.simple. */
-char *
-xmalloc (size)
- size_t size;
-{
- return (char *) ck_malloc (size);
-}
-
-PTR
-ck_realloc (ptr, size)
- PTR ptr;
- size_t size;
-{
- PTR ret;
-
- if (!ptr)
- ret = ck_malloc (size);
- else
- ret = realloc (ptr, size);
- if (ret == 0)
- panic ("Couldn't re-allocate memory");
- return ret;
-}
-
-/* Implement a variable sized buffer of 'stuff'. We don't know what it is,
- nor do we care, as long as it doesn't mind being aligned on a char boundry.
- */
-
-struct buffer
- {
- int allocated;
- int length;
- char *b;
- };
-
-#define MIN_ALLOCATE 50
-
-char *
-init_buffer ()
-{
- struct buffer *b;
-
- b = (struct buffer *) ck_malloc (sizeof (struct buffer));
- b->allocated = MIN_ALLOCATE;
- b->b = (char *) ck_malloc (MIN_ALLOCATE);
- b->length = 0;
- return (char *) b;
-}
-
-void
-flush_buffer (bb)
- char *bb;
-{
- struct buffer *b;
-
- b = (struct buffer *) bb;
- free (b->b);
- b->b = 0;
- b->allocated = 0;
- b->length = 0;
- free ((void *) b);
-}
-
-void
-add_buffer (bb, p, n)
- char *bb;
- char *p;
- int n;
-{
- struct buffer *b;
-
- b = (struct buffer *) bb;
- if (b->length + n > b->allocated)
- {
- b->allocated = b->length + n + MIN_ALLOCATE;
- b->b = (char *) ck_realloc (b->b, b->allocated);
- }
- bcopy (p, b->b + b->length, n);
- b->length += n;
-}
-
-char *
-get_buffer (bb)
- char *bb;
-{
- struct buffer *b;
-
- b = (struct buffer *) bb;
- return b->b;
-}
-
-char *
-merge_sort (list, n, off, cmp)
- char *list;
- int (*cmp) ();
- unsigned n;
- int off;
-{
- char *ret;
-
- char *alist, *blist;
- unsigned alength, blength;
-
- char *tptr;
- int tmp;
- char **prev;
-#define NEXTOF(ptr) (* ((char **)(((char *)(ptr))+off) ) )
- if (n == 1)
- return list;
- if (n == 2)
- {
- if ((*cmp) (list, NEXTOF (list)) > 0)
- {
- ret = NEXTOF (list);
- NEXTOF (ret) = list;
- NEXTOF (list) = 0;
- return ret;
- }
- return list;
- }
- alist = list;
- alength = (n + 1) / 2;
- blength = n / 2;
- for (tptr = list, tmp = (n - 1) / 2; tmp; tptr = NEXTOF (tptr), tmp--)
- ;
- blist = NEXTOF (tptr);
- NEXTOF (tptr) = 0;
-
- alist = merge_sort (alist, alength, off, cmp);
- blist = merge_sort (blist, blength, off, cmp);
- prev = &ret;
- for (; alist && blist;)
- {
- if ((*cmp) (alist, blist) < 0)
- {
- tptr = NEXTOF (alist);
- *prev = alist;
- prev = &(NEXTOF (alist));
- alist = tptr;
- }
- else
- {
- tptr = NEXTOF (blist);
- *prev = blist;
- prev = &(NEXTOF (blist));
- blist = tptr;
- }
- }
- if (alist)
- *prev = alist;
- else
- *prev = blist;
-
- return ret;
-}
-
-void
-ck_close (fd)
- int fd;
-{
- if (close (fd) < 0)
- {
- msg_perror ("can't close a file #%d", fd);
- exit (EX_SYSTEM);
- }
-}
-
-#include <ctype.h>
-
-/* Quote_copy_string is like quote_string, but instead of modifying the
- string in place, it malloc-s a copy of the string, and returns that.
- If the string does not have to be quoted, it returns the NULL string.
- The allocated copy can, of course, be freed with free() after the
- caller is done with it.
- */
-char *
-quote_copy_string (string)
- char *string;
-{
- char *from_here;
- char *to_there = 0;
- char *copy_buf = 0;
- int c;
- int copying = 0;
-
- from_here = string;
- while (*from_here)
- {
- c = *from_here++ & 0xFF;
- if (c == '\\')
- {
- if (!copying)
- {
- int n;
-
- n = (from_here - string) - 1;
- copying++;
- copy_buf = (char *) malloc (n + 5 + strlen (from_here) * 4);
- if (!copy_buf)
- return 0;
- bcopy (string, copy_buf, n);
- to_there = copy_buf + n;
- }
- *to_there++ = '\\';
- *to_there++ = '\\';
- }
- else if (isprint (c))
- {
- if (copying)
- *to_there++ = c;
- }
- else
- {
- if (!copying)
- {
- int n;
-
- n = (from_here - string) - 1;
- copying++;
- copy_buf = (char *) malloc (n + 5 + strlen (from_here) * 4);
- if (!copy_buf)
- return 0;
- bcopy (string, copy_buf, n);
- to_there = copy_buf + n;
- }
- *to_there++ = '\\';
- if (c == '\n')
- *to_there++ = 'n';
- else if (c == '\t')
- *to_there++ = 't';
- else if (c == '\f')
- *to_there++ = 'f';
- else if (c == '\b')
- *to_there++ = 'b';
- else if (c == '\r')
- *to_there++ = 'r';
- else if (c == '\177')
- *to_there++ = '?';
- else
- {
- to_there[0] = (c >> 6) + '0';
- to_there[1] = ((c >> 3) & 07) + '0';
- to_there[2] = (c & 07) + '0';
- to_there += 3;
- }
- }
- }
- if (copying)
- {
- *to_there = '\0';
- return copy_buf;
- }
- return (char *) 0;
-}
-
-
-/* Un_quote_string takes a quoted c-string (like those produced by
- quote_string or quote_copy_string and turns it back into the
- un-quoted original. This is done in place.
- */
-
-/* There is no un-quote-copy-string. Write it yourself */
-
-char *
-un_quote_string (string)
- char *string;
-{
- char *ret;
- char *from_here;
- char *to_there;
- int tmp;
-
- ret = string;
- to_there = string;
- from_here = string;
- while (*from_here)
- {
- if (*from_here != '\\')
- {
- if (from_here != to_there)
- *to_there++ = *from_here++;
- else
- from_here++, to_there++;
- continue;
- }
- switch (*++from_here)
- {
- case '\\':
- *to_there++ = *from_here++;
- break;
- case 'n':
- *to_there++ = '\n';
- from_here++;
- break;
- case 't':
- *to_there++ = '\t';
- from_here++;
- break;
- case 'f':
- *to_there++ = '\f';
- from_here++;
- break;
- case 'b':
- *to_there++ = '\b';
- from_here++;
- break;
- case 'r':
- *to_there++ = '\r';
- from_here++;
- break;
- case '?':
- *to_there++ = 0177;
- from_here++;
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- tmp = *from_here - '0';
- from_here++;
- if (*from_here < '0' || *from_here > '7')
- {
- *to_there++ = tmp;
- break;
- }
- tmp = tmp * 8 + *from_here - '0';
- from_here++;
- if (*from_here < '0' || *from_here > '7')
- {
- *to_there++ = tmp;
- break;
- }
- tmp = tmp * 8 + *from_here - '0';
- from_here++;
- *to_there = tmp;
- break;
- default:
- ret = 0;
- *to_there++ = '\\';
- *to_there++ = *from_here++;
- break;
- }
- }
- if (*to_there)
- *to_there++ = '\0';
- return ret;
-}
-
-#ifndef __MSDOS__
-void
-ck_pipe (pipes)
- int *pipes;
-{
- if (pipe (pipes) < 0)
- {
- msg_perror ("can't open a pipe");
- exit (EX_SYSTEM);
- }
-}
-#endif /* !__MSDOS__ */
-
-#ifndef HAVE_STRSTR
-/*
- * strstr - find first occurrence of wanted in s
- */
-
-char * /* found string, or NULL if none */
-strstr (s, wanted)
- char *s;
- char *wanted;
-{
- register char *scan;
- register size_t len;
- register char firstc;
-
- if (*wanted == '\0')
- return (char *) 0;
- /*
- * The odd placement of the two tests is so "" is findable.
- * Also, we inline the first char for speed.
- * The ++ on scan has been moved down for optimization.
- */
- firstc = *wanted;
- len = strlen (wanted);
- for (scan = s; *scan != firstc || strncmp (scan, wanted, len) != 0;)
- if (*scan++ == '\0')
- return (char *) 0;
- return scan;
-}
-
-#endif /* !HAVE_STRSTR */
-
-#ifndef HAVE_FTRUNCATE
-
-#ifdef F_CHSIZE
-int
-ftruncate (fd, length)
- int fd;
- off_t length;
-{
- return fcntl (fd, F_CHSIZE, length);
-}
-
-#else /* !F_CHSIZE */
-#ifdef F_FREESP
-/* code courtesy of William Kucharski, kucharsk@Solbourne.com */
-
-int
-ftruncate (fd, length)
- int fd; /* file descriptor */
- off_t length; /* length to set file to */
-{
- struct flock fl;
-
- fl.l_whence = 0;
- fl.l_len = 0;
- fl.l_start = length;
- fl.l_type = F_WRLCK; /* write lock on file space */
-
- /*
- * This relies on the UNDOCUMENTED F_FREESP argument to
- * fcntl(2), which truncates the file so that it ends at the
- * position indicated by fl.l_start.
- *
- * Will minor miracles never cease?
- */
-
- if (fcntl (fd, F_FREESP, &fl) < 0)
- return -1;
-
- return 0;
-}
-
-#else /* !F_FREESP */
-
-int
-ftruncate (fd, length)
- int fd;
- off_t length;
-{
- errno = EIO;
- return -1;
-}
-
-#endif /* !F_FREESP */
-#endif /* !F_CHSIZE */
-#endif /* !HAVE_FTRUNCATE */
-
-
-extern FILE *msg_file;
-
-#if defined (HAVE_VPRINTF) && __STDC__
-#include <stdarg.h>
-
-void
-msg (char *str,...)
-{
- va_list args;
-
- va_start (args, str);
- fflush (msg_file);
- fprintf (stderr, "%s: ", tar);
- if (f_sayblock)
- fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block));
- vfprintf (stderr, str, args);
- va_end (args);
- putc ('\n', stderr);
- fflush (stderr);
-}
-
-void
-msg_perror (char *str,...)
-{
- va_list args;
- int save_e;
-
- save_e = errno;
- fflush (msg_file);
- fprintf (stderr, "%s: ", tar);
- if (f_sayblock)
- fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block));
- va_start (args, str);
- vfprintf (stderr, str, args);
- va_end (args);
- errno = save_e;
- perror (" ");
- fflush (stderr);
-}
-
-#endif /* HAVE_VPRINTF and __STDC__ */
-
-#if defined(HAVE_VPRINTF) && !__STDC__
-#include <varargs.h>
-void
-msg (str, va_alist)
- char *str;
- va_dcl
-{
- va_list args;
-
- fflush (msg_file);
- fprintf (stderr, "%s: ", tar);
- if (f_sayblock)
- fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block));
- va_start (args);
- vfprintf (stderr, str, args);
- va_end (args);
- putc ('\n', stderr);
- fflush (stderr);
-}
-
-void
-msg_perror (str, va_alist)
- char *str;
- va_dcl
-{
- va_list args;
- int save_e;
-
- save_e = errno;
- fflush (msg_file);
- fprintf (stderr, "%s: ", tar);
- if (f_sayblock)
- fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block));
- va_start (args);
- vfprintf (stderr, str, args);
- va_end (args);
- errno = save_e;
- perror (" ");
- fflush (stderr);
-}
-
-#endif /* HAVE_VPRINTF and not __STDC__ */
-
-#if !defined(HAVE_VPRINTF) && defined(HAVE_DOPRNT)
-void
-msg (str, args)
- char *str;
- int args;
-{
- fflush (msg_file);
- fprintf (stderr, "%s: ", tar);
- if (f_sayblock)
- fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block));
- _doprnt (str, &args, stderr);
- putc ('\n', stderr);
- fflush (stderr);
-}
-
-void
-msg_perror (str, args)
- char *str;
- int args;
-{
- int save_e;
-
- save_e = errno;
- fflush (msg_file);
- fprintf (stderr, "%s: ", tar);
- if (f_sayblock)
- fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block));
- _doprnt (str, &args, stderr);
- errno = save_e;
- perror (" ");
- fflush (stderr);
-}
-
-#endif /* !HAVE_VPRINTF and HAVE_DOPRNT */
-
-#if !defined(HAVE_VPRINTF) && !defined(HAVE_DOPRNT)
-void
-msg (str, a1, a2, a3, a4, a5, a6)
- char *str;
-{
- fflush (msg_file);
- fprintf (stderr, "%s: ", tar);
- if (f_sayblock)
- fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block));
- fprintf (stderr, str, a1, a2, a3, a4, a5, a6);
- putc ('\n', stderr);
- fflush (stderr);
-}
-
-void
-msg_perror (str, a1, a2, a3, a4, a5, a6)
- char *str;
-{
- int save_e;
-
- save_e = errno;
- fflush (msg_file);
- fprintf (stderr, "%s: ", tar);
- if (f_sayblock)
- fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block));
- fprintf (stderr, str, a1, a2, a3, a4, a5, a6);
- fprintf (stderr, ": ");
- errno = save_e;
- perror (" ");
-}
-
-#endif /* !HAVE_VPRINTF and !HAVE_DOPRNT */
diff --git a/gnu/usr.bin/tar/port.h b/gnu/usr.bin/tar/port.h
deleted file mode 100644
index 4e65a9a..0000000
--- a/gnu/usr.bin/tar/port.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/* Portability declarations. Requires sys/types.h.
- Copyright (C) 1988, 1992 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* AIX requires this to be the first thing in the file. */
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not __GNUC__ */
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#else /* not HAVE_ALLOCA_H */
-#ifdef _AIX
- #pragma alloca
-#else /* not _AIX */
-char *alloca ();
-#endif /* not _AIX */
-#endif /* not HAVE_ALLOCA_H */
-#endif /* not __GNUC__ */
-
-#include "pathmax.h"
-
-#ifdef _POSIX_VERSION
-#include <sys/wait.h>
-#else /* !_POSIX_VERSION */
-#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
-#define WIFSIGNALED(w) (((w) & 0xff) != 0x7f && ((w) & 0xff) != 0)
-#define WIFEXITED(w) (((w) & 0xff) == 0)
-
-#define WSTOPSIG(w) (((w) >> 8) & 0xff)
-#define WTERMSIG(w) ((w) & 0x7f)
-#define WEXITSTATUS(w) (((w) >> 8) & 0xff)
-#endif /* _POSIX_VERSION */
-
-/* nonstandard */
-#ifndef WIFCOREDUMPED
-#define WIFCOREDUMPED(w) (((w) & 0x80) != 0)
-#endif
-
-#ifdef __MSDOS__
-/* missing things from sys/stat.h */
-#define S_ISUID 0
-#define S_ISGID 0
-#define S_ISVTX 0
-
-/* device stuff */
-#define makedev(ma, mi) ((ma << 8) | mi)
-#define major(dev) (dev)
-#define minor(dev) (dev)
-typedef long off_t;
-#endif /* __MSDOS__ */
-
-#if defined(__STDC__) || defined(__TURBOC__)
-#define PTR void *
-#else
-#define PTR char *
-#define const
-#endif
-
-/* Since major is a function on SVR4, we can't just use `ifndef major'. */
-#ifdef major /* Might be defined in sys/types.h. */
-#define HAVE_MAJOR
-#endif
-
-#if !defined(HAVE_MAJOR) && defined(MAJOR_IN_MKDEV)
-#include <sys/mkdev.h>
-#define HAVE_MAJOR
-#endif
-
-#if !defined(HAVE_MAJOR) && defined(MAJOR_IN_SYSMACROS)
-#include <sys/sysmacros.h>
-#define HAVE_MAJOR
-#endif
-
-#ifndef HAVE_MAJOR
-#define major(dev) (((dev) >> 8) & 0xff)
-#define minor(dev) ((dev) & 0xff)
-#define makedev(maj, min) (((maj) << 8) | (min))
-#endif
-#undef HAVE_MAJOR
-
-#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
-#include <string.h>
-#if !defined(__MSDOS__) && !defined(STDC_HEADERS)
-#include <memory.h>
-#endif
-#ifdef index
-#undef index
-#endif
-#ifdef rindex
-#undef rindex
-#endif
-#define index strchr
-#define rindex strrchr
-#define bcopy(s, d, n) memcpy(d, s, n)
-#define bzero(s, n) memset(s, 0, n)
-#define bcmp memcmp
-#else
-#include <strings.h>
-#endif
-
-#if defined(STDC_HEADERS)
-#include <stdlib.h>
-#else
-char *malloc (), *realloc ();
-char *getenv ();
-#endif
-
-#ifndef _POSIX_VERSION
-#ifdef __MSDOS__
-#include <io.h>
-#else /* !__MSDOS__ */
-off_t lseek ();
-#endif /* !__MSDOS__ */
-char *getcwd ();
-#endif /* !_POSIX_VERSION */
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-#ifndef O_CREAT
-#define O_CREAT 0
-#endif
-#ifndef O_NDELAY
-#define O_NDELAY 0
-#endif
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
-#ifndef O_RDWR
-#define O_RDWR 2
-#endif
-
-#include <sys/stat.h>
-#ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */
-#define mode_t unsigned short
-#endif
-#if !defined(S_ISBLK) && defined(S_IFBLK)
-#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
-#endif
-#if !defined(S_ISCHR) && defined(S_IFCHR)
-#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
-#endif
-#if !defined(S_ISDIR) && defined(S_IFDIR)
-#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-#endif
-#if !defined(S_ISREG) && defined(S_IFREG)
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#endif
-#if !defined(S_ISFIFO) && defined(S_IFIFO)
-#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
-#define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
-#endif
-#if !defined(S_ISLNK) && defined(S_IFLNK)
-#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
-#endif
-#if !defined(S_ISSOCK) && defined(S_IFSOCK)
-#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
-#endif
-#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
-#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
-#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
-#endif
-#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
-#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
-#endif
-#if !defined(S_ISCTG) && defined(S_IFCTG) /* contiguous file */
-#define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG)
-#endif
-#if !defined(S_ISVTX)
-#define S_ISVTX 0001000
-#endif
-
-#ifdef __MSDOS__
-#include "msd_dir.h"
-#define NLENGTH(direct) ((direct)->d_namlen)
-
-#else /* not __MSDOS__ */
-
-#if defined(DIRENT) || defined(_POSIX_VERSION)
-#include <dirent.h>
-#define NLENGTH(direct) (strlen((direct)->d_name))
-#else /* not (DIRENT or _POSIX_VERSION) */
-#define dirent direct
-#define NLENGTH(direct) ((direct)->d_namlen)
-#ifdef SYSNDIR
-#include <sys/ndir.h>
-#endif /* SYSNDIR */
-#ifdef SYSDIR
-#include <sys/dir.h>
-#endif /* SYSDIR */
-#ifdef NDIR
-#include <ndir.h>
-#endif /* NDIR */
-#endif /* DIRENT or _POSIX_VERSION */
-
-#endif /* not __MSDOS__ */
diff --git a/gnu/usr.bin/tar/rmt.h b/gnu/usr.bin/tar/rmt.h
deleted file mode 100644
index 2155223..0000000
--- a/gnu/usr.bin/tar/rmt.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Definitions for communicating with a remote tape drive.
- Copyright (C) 1988, 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if !defined(_POSIX_VERSION)
-#ifdef __MSDOS__
-#include <io.h>
-#else /* !__MSDOS__ */
-extern off_t lseek ();
-#endif /* __MSDOS__ */
-#endif /* _POSIX_VERSION */
-
-#ifdef NO_REMOTE
-#define _isrmt(f) 0
-#define rmtopen open
-#define rmtaccess access
-#define rmtstat stat
-#define rmtcreat creat
-#define rmtlstat lstat
-#define rmtread read
-#define rmtwrite write
-#define rmtlseek lseek
-#define rmtclose close
-#define rmtioctl ioctl
-#define rmtdup dup
-#define rmtfstat fstat
-#define rmtfcntl fcntl
-#define rmtisatty isatty
-
-#else /* !NO_REMOTE */
-
-#define __REM_BIAS 128
-#define RMTIOCTL
-
-#ifndef O_CREAT
-#define O_CREAT 01000
-#endif
-
-extern char *__rmt_path;
-
-#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
-#include <string.h>
-#ifndef index
-#define index strchr
-#endif
-#else
-extern char *index ();
-#endif
-
-#define _remdev(path) (!f_force_local && (__rmt_path=index(path, ':')))
-#define _isrmt(fd) ((fd) >= __REM_BIAS)
-
-#define rmtopen(path,oflag,mode) (_remdev(path) ? __rmt_open(path, oflag, mode, __REM_BIAS) : open(path, oflag, mode))
-#define rmtaccess(path, amode) (_remdev(path) ? 0 : access(path, amode))
-#define rmtstat(path, buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : stat(path, buf))
-#define rmtcreat(path, mode) (_remdev(path) ? __rmt_open (path, 1 | O_CREAT, mode, __REM_BIAS) : creat(path, mode))
-#define rmtlstat(path,buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : lstat(path,buf))
-
-#define rmtread(fd, buf, n) (_isrmt(fd) ? __rmt_read(fd - __REM_BIAS, buf, n) : read(fd, buf, n))
-#define rmtwrite(fd, buf, n) (_isrmt(fd) ? __rmt_write(fd - __REM_BIAS, buf, n) : write(fd, buf, n))
-#define rmtlseek(fd, off, wh) (_isrmt(fd) ? __rmt_lseek(fd - __REM_BIAS, off, wh) : lseek(fd, off, wh))
-#define rmtclose(fd) (_isrmt(fd) ? __rmt_close(fd - __REM_BIAS) : close(fd))
-#ifdef RMTIOCTL
-#define rmtioctl(fd,req,arg) (_isrmt(fd) ? __rmt_ioctl(fd - __REM_BIAS, req, arg) : ioctl(fd, req, arg))
-#else
-#define rmtioctl(fd,req,arg) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : ioctl(fd, req, arg))
-#endif
-#define rmtdup(fd) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : dup(fd))
-#define rmtfstat(fd, buf) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fstat(fd, buf))
-#define rmtfcntl(fd,cmd,arg) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fcntl (fd, cmd, arg))
-#define rmtisatty(fd) (_isrmt(fd) ? 0 : isatty(fd))
-
-#undef RMTIOCTL
-
-int __rmt_open ();
-int __rmt_close ();
-int __rmt_read ();
-int __rmt_write ();
-long __rmt_lseek ();
-int __rmt_ioctl ();
-#endif /* !NO_REMOTE */
diff --git a/gnu/usr.bin/tar/rtapelib.c b/gnu/usr.bin/tar/rtapelib.c
deleted file mode 100644
index 0c23b06..0000000
--- a/gnu/usr.bin/tar/rtapelib.c
+++ /dev/null
@@ -1,570 +0,0 @@
-/* Functions for communicating with a remote tape drive.
- Copyright (C) 1988, 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* The man page rmt(8) for /etc/rmt documents the remote mag tape
- protocol which rdump and rrestore use. Unfortunately, the man
- page is *WRONG*. The author of the routines I'm including originally
- wrote his code just based on the man page, and it didn't work, so he
- went to the rdump source to figure out why. The only thing he had to
- change was to check for the 'F' return code in addition to the 'E',
- and to separate the various arguments with \n instead of a space. I
- personally don't think that this is much of a problem, but I wanted to
- point it out. -- Arnold Robbins
-
- Originally written by Jeff Lee, modified some by Arnold Robbins.
- Redone as a library that can replace open, read, write, etc., by
- Fred Fish, with some additional work by Arnold Robbins.
- Modified to make all rmtXXX calls into macros for speed by Jay Fenlason.
- Use -DHAVE_NETDB_H for rexec code, courtesy of Dan Kegel, srs!dan. */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-
-#ifdef HAVE_SYS_MTIO_H
-#include <sys/ioctl.h>
-#include <sys/mtio.h>
-#endif
-
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-
-#include <errno.h>
-#include <setjmp.h>
-#include <sys/stat.h>
-
-#ifndef errno
-extern int errno;
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef STDC_HEADERS
-#include <string.h>
-#include <stdlib.h>
-#endif
-
-/* Maximum size of a fully qualified host name. */
-#define MAXHOSTLEN 257
-
-/* Size of buffers for reading and writing commands to rmt.
- (An arbitrary limit.) */
-#define CMDBUFSIZE 64
-
-#ifndef RETSIGTYPE
-#define RETSIGTYPE void
-#endif
-
-/* Maximum number of simultaneous remote tape connections.
- (Another arbitrary limit.) */
-#define MAXUNIT 4
-
-/* Return the parent's read side of remote tape connection FILDES. */
-#define READ(fildes) (from_rmt[fildes][0])
-
-/* Return the parent's write side of remote tape connection FILDES. */
-#define WRITE(fildes) (to_rmt[fildes][1])
-
-/* The pipes for receiving data from remote tape drives. */
-static int from_rmt[MAXUNIT][2] =
-{-1, -1, -1, -1, -1, -1, -1, -1};
-
-/* The pipes for sending data to remote tape drives. */
-static int to_rmt[MAXUNIT][2] =
-{-1, -1, -1, -1, -1, -1, -1, -1};
-
-/* Temporary variable used by macros in rmt.h. */
-char *__rmt_path;
-
-/* Close remote tape connection FILDES. */
-
-static void
-_rmt_shutdown (fildes)
- int fildes;
-{
- close (READ (fildes));
- close (WRITE (fildes));
- READ (fildes) = -1;
- WRITE (fildes) = -1;
-}
-
-/* Attempt to perform the remote tape command specified in BUF
- on remote tape connection FILDES.
- Return 0 if successful, -1 on error. */
-
-static int
-command (fildes, buf)
- int fildes;
- char *buf;
-{
- register int buflen;
- RETSIGTYPE (*pipe_handler) ();
-
- /* Save the current pipe handler and try to make the request. */
-
- pipe_handler = signal (SIGPIPE, SIG_IGN);
- buflen = strlen (buf);
- if (write (WRITE (fildes), buf, buflen) == buflen)
- {
- signal (SIGPIPE, pipe_handler);
- return 0;
- }
-
- /* Something went wrong. Close down and go home. */
-
- signal (SIGPIPE, pipe_handler);
- _rmt_shutdown (fildes);
- errno = EIO;
- return -1;
-}
-
-/* Read and return the status from remote tape connection FILDES.
- If an error occurred, return -1 and set errno. */
-
-static int
-status (fildes)
- int fildes;
-{
- int i;
- char c, *cp;
- char buffer[CMDBUFSIZE];
-
- /* Read the reply command line. */
-
- for (i = 0, cp = buffer; i < CMDBUFSIZE; i++, cp++)
- {
- if (read (READ (fildes), cp, 1) != 1)
- {
- _rmt_shutdown (fildes);
- errno = EIO;
- return -1;
- }
- if (*cp == '\n')
- {
- *cp = '\0';
- break;
- }
- }
-
- if (i == CMDBUFSIZE)
- {
- _rmt_shutdown (fildes);
- errno = EIO;
- return -1;
- }
-
- /* Check the return status. */
-
- for (cp = buffer; *cp; cp++)
- if (*cp != ' ')
- break;
-
- if (*cp == 'E' || *cp == 'F')
- {
- errno = atoi (cp + 1);
- /* Skip the error message line. */
- while (read (READ (fildes), &c, 1) == 1)
- if (c == '\n')
- break;
-
- if (*cp == 'F')
- _rmt_shutdown (fildes);
-
- return -1;
- }
-
- /* Check for mis-synced pipes. */
-
- if (*cp != 'A')
- {
- _rmt_shutdown (fildes);
- errno = EIO;
- return -1;
- }
-
- /* Got an `A' (success) response. */
- return atoi (cp + 1);
-}
-
-#ifdef HAVE_NETDB_H
-/* Execute /etc/rmt as user USER on remote system HOST using rexec.
- Return a file descriptor of a bidirectional socket for stdin and stdout.
- If USER is NULL, or an empty string, use the current username.
-
- By default, this code is not used, since it requires that
- the user have a .netrc file in his/her home directory, or that the
- application designer be willing to have rexec prompt for login and
- password info. This may be unacceptable, and .rhosts files for use
- with rsh are much more common on BSD systems. */
-
-static int
-_rmt_rexec (host, user)
- char *host;
- char *user;
-{
- struct servent *rexecserv;
- int save_stdin = dup (fileno (stdin));
- int save_stdout = dup (fileno (stdout));
- int tape_fd; /* Return value. */
-
- /* When using cpio -o < filename, stdin is no longer the tty.
- But the rexec subroutine reads the login and the passwd on stdin,
- to allow remote execution of the command.
- So, reopen stdin and stdout on /dev/tty before the rexec and
- give them back their original value after. */
- if (freopen ("/dev/tty", "r", stdin) == NULL)
- freopen ("/dev/null", "r", stdin);
- if (freopen ("/dev/tty", "w", stdout) == NULL)
- freopen ("/dev/null", "w", stdout);
-
- rexecserv = getservbyname ("exec", "tcp");
- if (NULL == rexecserv)
- {
- fprintf (stderr, "exec/tcp: service not available");
- exit (1);
- }
- if (user != NULL && *user == '\0')
- user = NULL;
- tape_fd = rexec (&host, rexecserv->s_port, user, NULL,
- "/etc/rmt", (int *) NULL);
- fclose (stdin);
- fdopen (save_stdin, "r");
- fclose (stdout);
- fdopen (save_stdout, "w");
-
- return tape_fd;
-}
-
-#endif /* HAVE_NETDB_H */
-
-/* Open a magtape device on the system specified in PATH, as the given user.
- PATH has the form `[user@]system:/dev/????'.
- If COMPAT is defined, it can also have the form `system[.user]:/dev/????'.
-
- OFLAG is O_RDONLY, O_WRONLY, etc.
- MODE is ignored; 0666 is always used.
-
- If successful, return the remote tape pipe number plus BIAS.
- On error, return -1. */
-
-int
-__rmt_open (path, oflag, mode, bias)
- char *path;
- int oflag;
- int mode;
- int bias;
-{
- int i, rc;
- char buffer[CMDBUFSIZE]; /* Command buffer. */
- char system[MAXHOSTLEN]; /* The remote host name. */
- char device[CMDBUFSIZE]; /* The remote device name. */
- char login[CMDBUFSIZE]; /* The remote user name. */
- char *sys, *dev, *user; /* For copying into the above buffers. */
-
- sys = system;
- dev = device;
- user = login;
-
- /* Find an unused pair of file descriptors. */
-
- for (i = 0; i < MAXUNIT; i++)
- if (READ (i) == -1 && WRITE (i) == -1)
- break;
-
- if (i == MAXUNIT)
- {
- errno = EMFILE;
- return -1;
- }
-
- /* Pull apart the system and device, and optional user.
- Don't munge the original string. */
-
- while (*path != '@'
-#ifdef COMPAT
- && *path != '.'
-#endif
- && *path != ':')
- {
- *sys++ = *path++;
- }
- *sys = '\0';
- path++;
-
- if (*(path - 1) == '@')
- {
- /* Saw user part of user@host. Start over. */
- strcpy (user, system);
- sys = system;
- while (*path != ':')
- {
- *sys++ = *path++;
- }
- *sys = '\0';
- path++;
- }
-#ifdef COMPAT
- else if (*(path - 1) == '.')
- {
- while (*path != ':')
- {
- *user++ = *path++;
- }
- *user = '\0';
- path++;
- }
-#endif
- else
- *user = '\0';
-
- while (*path)
- {
- *dev++ = *path++;
- }
- *dev = '\0';
-
-#ifdef HAVE_NETDB_H
- /* Execute the remote command using rexec. */
- READ (i) = WRITE (i) = _rmt_rexec (system, login);
- if (READ (i) < 0)
- return -1;
-#else /* !HAVE_NETDB_H */
- /* Set up the pipes for the `rsh' command, and fork. */
-
- if (pipe (to_rmt[i]) == -1 || pipe (from_rmt[i]) == -1)
- return -1;
-
- rc = fork ();
- if (rc == -1)
- return -1;
-
- if (rc == 0)
- {
- /* Child. */
- close (0);
- dup (to_rmt[i][0]);
- close (to_rmt[i][0]);
- close (to_rmt[i][1]);
-
- close (1);
- dup (from_rmt[i][1]);
- close (from_rmt[i][0]);
- close (from_rmt[i][1]);
-
- setuid (getuid ());
- setgid (getgid ());
-
- if (*login)
- {
- execl ("/usr/bin/rsh", "rsh", "-l", login, system,
- "/etc/rmt", (char *) 0);
- execlp ("rsh", "rsh", "-l", login, system,
- "/etc/rmt", (char *) 0);
- }
- else
- {
- execl ("/usr/bin/rsh", "rsh", system,
- "/etc/rmt", (char *) 0);
- execlp ("rsh", "rsh", system,
- "/etc/rmt", (char *) 0);
- }
-
- /* Bad problems if we get here. */
-
- perror ("cannot execute remote shell");
- _exit (1);
- }
-
- /* Parent. */
- close (to_rmt[i][0]);
- close (from_rmt[i][1]);
-#endif /* !HAVE_NETDB_H */
-
- /* Attempt to open the tape device. */
-
- sprintf (buffer, "O%s\n%d\n", device, oflag);
- if (command (i, buffer) == -1 || status (i) == -1)
- return -1;
-
- return i + bias;
-}
-
-/* Close remote tape connection FILDES and shut down.
- Return 0 if successful, -1 on error. */
-
-int
-__rmt_close (fildes)
- int fildes;
-{
- int rc;
-
- if (command (fildes, "C\n") == -1)
- return -1;
-
- rc = status (fildes);
- _rmt_shutdown (fildes);
- return rc;
-}
-
-/* Read up to NBYTE bytes into BUF from remote tape connection FILDES.
- Return the number of bytes read on success, -1 on error. */
-
-int
-__rmt_read (fildes, buf, nbyte)
- int fildes;
- char *buf;
- unsigned int nbyte;
-{
- int rc, i;
- char buffer[CMDBUFSIZE];
-
- sprintf (buffer, "R%d\n", nbyte);
- if (command (fildes, buffer) == -1 || (rc = status (fildes)) == -1)
- return -1;
-
- for (i = 0; i < rc; i += nbyte, buf += nbyte)
- {
- nbyte = read (READ (fildes), buf, rc - i);
- if (nbyte <= 0)
- {
- _rmt_shutdown (fildes);
- errno = EIO;
- return -1;
- }
- }
-
- return rc;
-}
-
-/* Write NBYTE bytes from BUF to remote tape connection FILDES.
- Return the number of bytes written on success, -1 on error. */
-
-int
-__rmt_write (fildes, buf, nbyte)
- int fildes;
- char *buf;
- unsigned int nbyte;
-{
- char buffer[CMDBUFSIZE];
- RETSIGTYPE (*pipe_handler) ();
-
- sprintf (buffer, "W%d\n", nbyte);
- if (command (fildes, buffer) == -1)
- return -1;
-
- pipe_handler = signal (SIGPIPE, SIG_IGN);
- if (write (WRITE (fildes), buf, nbyte) == nbyte)
- {
- signal (SIGPIPE, pipe_handler);
- return status (fildes);
- }
-
- /* Write error. */
- signal (SIGPIPE, pipe_handler);
- _rmt_shutdown (fildes);
- errno = EIO;
- return -1;
-}
-
-/* Perform an imitation lseek operation on remote tape connection FILDES.
- Return the new file offset if successful, -1 if on error. */
-
-long
-__rmt_lseek (fildes, offset, whence)
- int fildes;
- long offset;
- int whence;
-{
- char buffer[CMDBUFSIZE];
-
- sprintf (buffer, "L%ld\n%d\n", offset, whence);
- if (command (fildes, buffer) == -1)
- return -1;
-
- return status (fildes);
-}
-
-/* Perform a raw tape operation on remote tape connection FILDES.
- Return the results of the ioctl, or -1 on error. */
-
-#ifdef MTIOCTOP
-int
-__rmt_ioctl (fildes, op, arg)
- int fildes, op;
- char *arg;
-{
- char c;
- int rc, cnt;
- char buffer[CMDBUFSIZE];
-
- switch (op)
- {
- default:
- errno = EINVAL;
- return -1;
-
- case MTIOCTOP:
- /* MTIOCTOP is the easy one. Nothing is transfered in binary. */
- sprintf (buffer, "I%d\n%d\n", ((struct mtop *) arg)->mt_op,
- ((struct mtop *) arg)->mt_count);
- if (command (fildes, buffer) == -1)
- return -1;
- return status (fildes); /* Return the count. */
-
- case MTIOCGET:
- /* Grab the status and read it directly into the structure.
- This assumes that the status buffer is not padded
- and that 2 shorts fit in a long without any word
- alignment problems; i.e., the whole struct is contiguous.
- NOTE - this is probably NOT a good assumption. */
-
- if (command (fildes, "S") == -1 || (rc = status (fildes)) == -1)
- return -1;
-
- for (; rc > 0; rc -= cnt, arg += cnt)
- {
- cnt = read (READ (fildes), arg, rc);
- if (cnt <= 0)
- {
- _rmt_shutdown (fildes);
- errno = EIO;
- return -1;
- }
- }
-
- /* Check for byte position. mt_type is a small integer field
- (normally) so we will check its magnitude. If it is larger than
- 256, we will assume that the bytes are swapped and go through
- and reverse all the bytes. */
-
- if (((struct mtget *) arg)->mt_type < 256)
- return 0;
-
- for (cnt = 0; cnt < rc; cnt += 2)
- {
- c = arg[cnt];
- arg[cnt] = arg[cnt + 1];
- arg[cnt + 1] = c;
- }
-
- return 0;
- }
-}
-
-#endif
diff --git a/gnu/usr.bin/tar/tar.1 b/gnu/usr.bin/tar/tar.1
deleted file mode 100644
index 0ca74fa..0000000
--- a/gnu/usr.bin/tar/tar.1
+++ /dev/null
@@ -1,434 +0,0 @@
-.\" Copyright (c) 1991, 1992, 1993 Free Software Foundation -*- nroff -*-
-.\" See /usr/src/gnu/COPYING for conditions of redistribution
-.\"
-.\" Written by John F. Woods <jfw@jfwhome.funhouse.com>
-.\" Updated by Robert Eckardt <roberte@mep.ruhr-uni-bochum.de>
-.\"
-.\" $Id: tar.1,v 1.6 1996/08/13 00:13:49 chuckr Exp $
-.\"
-.Dd 25 August 1997
-.Os FreeBSD
-.Dt TAR 1
-.Sh NAME
-.Nm tar
-.Nd
-tape archiver; manipulate "tar" archive files
-.Sh SYNOPSIS
-.Nm tar
-.Op [-] Ns Ar bundled-options
-.Op Ar gnu-style-flags
-.Op Ar tarfile
-.Op Ar blocksize
-.Op Ar exclude-file
-.Op Ar filenames
-.Op Fl C Ar directory-name
-.Sh DESCRIPTION
-.Nm Tar
-is short for
-.Dq tape archiver,
-so named for historical reasons; the
-.Nm
-program creates, adds files to, or extracts files from an archive file
-in
-.Dq tar
-format, called a
-.Ar tarfile .
-A tarfile is often a magnetic tape, but can be a floppy diskette or any
-regular disk file.
-.Pp
-The first argument word of the
-.Nm
-command line is usually a command word of bundled function and modifier
-letters, optionally preceded by a dash;
-it must contain exactly one function letter from the set
-.Cm A ,
-.Cm c ,
-.Cm d ,
-.Cm r ,
-.Cm t ,
-.Cm u ,
-.Cm x ,
-for append, create, difference, replace, table of contents, update, and
-extract (further described below). The command word can also contain other
-function modifiers described below, some of which will take arguments from
-the command line in the order they are specified in the command word (review
-the EXAMPLES section). Functions and function modifiers can also be specified
-with the GNU argument convention (preceded by two dashes, one function or
-modifier per word. Command-line arguments that specify files to
-add to, extract from, or list from an archive may be given as shell
-pattern matching strings.
-.Sh FUNCTIONS
-Exactly one of the following functions must be specified.
-.Pp
-.Bl -tag -width "--concatenate" -compact
-.It Fl A
-.It Fl -catenate
-.It Fl "-concatenate"
-Append the contents of named file, which must itself be a tar archive,
-to the end of the archive (erasing the old end-of-archive block).
-This has the effect of adding the files contained in the named file to
-the first archive, rather than adding the second archive as an element
-of the first.
-.Em Note:
-This option requires a rewritable tarfile,
-and therefore does not work on quarter-inch cartridge tapes.
-.It Fl c
-.It Fl -create
-Create a new archive (or truncates an old one) and writes the named files
-to it.
-.It Fl d
-.It Fl -diff
-.It Fl -compare
-Find differences between files in the archive and corresponding files in
-the file system.
-.It Fl -delete
-Delete named files from the archive (Does not work on quarter-inch tapes).
-.It Fl r
-.It Fl -append
-Append files to the end of an archive (Does not work on quarter-inch tapes).
-.It Fl t
-.It Fl -list
-List the contents of an archive; if filename arguments are given, only those
-files are listed, otherwise the entire table of contents is listed.
-.It Fl u
-.It Fl -update
-Append the named files if the on-disk version has a modification date
-more recent than their copy in the archive (if any). Does not work on
-quarter-inch tapes.
-.It Fl x
-.It Fl -extract
-.It Fl -get
-Extract files from an archive. The owner, modification time, and file
-permissions are restored, if possible. If no
-.Ar file
-arguments are given, extract all the files in the archive. If a
-.Ar filename
-argument matches the name of a directory on the tape, that directory and
-its contents are extracted (as well as all directories under that directory).
-If the archive contains multiple entries corresponding to the same file
-(see the
-.Fl -append
-command above), the last one extracted will overwrite all earlier versions.
-.El
-.Sh OPTIONS
-The other options to
-.Nm
-may be combined arbitrarily; single-letter options may be bundled in with
-the command word. Verbose options which take arguments will be
-followed by the argument; single-letter options will consume
-successive command line arguments (see the
-.Sx EXAMPLES
-below).
-.Pp
-.Bl -tag -width "--preserve-permissions" -compact
-.It Fl -help
-Prints a message listing and briefly describing all the command
-options to
-.Nm tar.
-.It Fl -atime-preserve
-Restore the access times on files which are written to tape (note that
-this will change the inode-change time!).
-.It Fl b
-.It Fl -block-size Ar number
-Sets the block size for reading or writing to
-.Ar number
-* 512-byte blocks.
-.It Fl B
-.It Fl -read-full-blocks
-Re-assemble short reads into full blocks (for reading 4.2BSD pipes).
-.It Fl C Ar directory
-.It Fl -directory Ar directory
-Change to
-.Ar directory
-for extraction.
-.It Fl -checkpoint
-Print number of buffer reads/writes while reading/writing the archive.
-.It Fl f Ar [hostname:]file
-.It Fl -file Ar [hostname:]file
-Read or write the specified
-.Ar file
-(default is /dev/rst0). If a
-.Ar hostname
-is specified,
-.Nm
-will use
-.Xr rmt 8
-to read or write the specified
-.Ar file
-on a remote machine. "-" may be used is a filename, for reading
-or writing to/from stdin/stdout.
-.It Fl -force-local
-Archive file is local even if it has a colon
-.It Fl F Ar file
-.It Fl -info-script Ar file
-.It Fl -new-volume-script Ar file
-Run a script at the end of each archive volume (implies
-.Fl M ) .
-.It Fl -fast-read
-Stop after all non-wildcard extraction targets have been found
-in the archive.
-.It Fl G
-.It Fl -incremental
-Create/list/extract old GNU-format incremental backup.
-.It Fl g Ar file
-.It Fl -listed-incremental Ar file
-Create/list/extract new GNU-format incremental backup.
-.It Fl h
-.It Fl -dereference
-Don't write symlinks as symlinks; write the data of the files they name.
-.It Fl i
-.It Fl -ignore-zeros
-Ignore blocks of zeroes in archive (usually means End-Of-File).
-.It Fl -ignore-failed-read
-Don't exit with non-zero status on unreadable files.
-.It Fl k
-.It Fl -keep-old-files
-Keep files which already exist on disk; don't overwrite them from the archive.
-.It Fl K Ar file
-.It Fl -starting-file Ar file
-Begin at
-.Ar file
-in the archive.
-.It Fl l
-.It Fl -one-file-system
-Stay in local filesystem when creating an archive (do not cross mount
-points).
-.It Fl L Ar number
-.It Fl -tape-length Ar number
-Change tapes after writing
-.Ar number
-* 1024 bytes.
-.It Fl m
-.It Fl -modification-time
-Don't extract file modified time.
-.It Fl M
-.It Fl -multi-volume
-Create/list/extract multi-volume archive.
-.It Fl n
-.It Fl -norecurse
-Don't recurse into subdirectories when creating.
-.It Fl -volno-file Ar file
-File name with volume number to start with.
-.It Fl N Ar date
-.It Fl -after-date Ar date
-.It Fl -newer Ar date
-Only store files with creation time newer than
-.Ar date .
-.It Fl -newer-mtime Ar date
-Only store files with modifiction time newer than
-.Ar date .
-.It Fl o
-.It Fl -old-archive
-.It Fl -portability
-Write a V7 format archive, rather than POSIX format.
-.It Fl O
-.It Fl -to-stdout
-Extract files to standard output.
-.It Fl p
-.It Fl -same-permissions
-.It Fl -preserve-permissions
-Extract all protection information.
-.It Fl -preserve
-Has the effect of
-.Fl p s.
-.It Fl P
-.It Fl -absolute-paths
-Don't strip leading `/' from file names.
-.It Fl R
-.It Fl -record-number
-Show record number within archive with each message.
-.It Fl -remove-files
-Remove files after adding them to the archive.
-.It Fl s
-.It Fl -same-order
-.It Fl -preserve-order
-List of names to extract is sorted to match archive.
-.It Fl -show-omitted-dirs
-Show directories which were omitted while processing the archive.
-.It Fl S
-.It Fl -sparse
-Handle "sparse" files efficiently.
-.It Fl T Ar file
-.It Fl -files-from Ar file
-Get names of files to extract or create from
-.Ar file ,
-one per line.
-.It Fl -null
-Modifies behavior of
-.Fl T
-to expect null-terminated names; disables
-.Fl C.
-.It Fl -totals
-Prints total bytes written with
-.Fl -create.
-.It Fl v
-.It Fl -verbose
-Lists files written to archive with
-.Fl -create
-or extracted with
-.Fl -extract;
-lists file protection information along with file names with
-.Fl -list.
-.It Fl V Ar volume-name
-.It Fl -label Ar volume-name
-Create archive with the given
-.Ar volume-name .
-.It Fl -version
-Print
-.Nm tar
-program version number.
-.It Fl w
-.It Fl -interactive
-.It Fl -confirmation
-Ask for confirmation for every action.
-.It Fl W
-.It Fl -verify
-Attempt to verify the archive after writing it.
-.It Fl -exclude Ar pattern
-Exclude files matching the
-.Ar pattern
-(don't extract them, don't add them, don't list them).
-.It Fl X Ar file
-.It Fl -exclude-from Ar file
-Exclude files listed in
-.Ar file .
-.It Fl Z
-.It Fl -compress
-.It Fl -uncompress
-Filter the archive through
-.Xr compress 1 .
-.It Fl z
-.It Fl -gzip
-.It Fl -gunzip
-Filter the archive through
-.Xr gzip 1 .
-.It Fl -use-compress-program Ar program
-Filter the archive through
-.Ar program
-(which must accept
-.Fl d
-to mean ``decompress'').
-.It Fl -block-compress
-Block the output of compression program for tapes or floppies
-(otherwise writes will be of odd length, which device drivers may reject).
-.It Fl [0-7][lmh]
-Specify tape drive and density.
-.It Fl -unlink
-Unlink files before creating them.
-.El
-.Sh EXAMPLES
-To create an archive on tape drive /dev/rst0 with a block size of 20
-blocks, containing files named "bert" and "ernie", you can enter
-.Dl tar cfb /dev/rst0 20 bert ernie
-or
-.Dl tar\ --create\ --file\ /dev/rst0\ --block-size\ 20\ bert\ ernie
-Note that the
-.Fl f
-and
-.Fl b
-flags both require arguments, which they take from the command line in
-the order they were listed in the command word.
-.Pp
-Because /dev/rst0 is the default device, and 20 is the default block
-size, the above example could have simply been
-.Dl tar c bert ernie
-.Pp
-To extract all the C sources and headers from an archive named
-"backup.tar", type
-.Dl tar xf backup.tar '*.[ch]'
-Note that the pattern must be quoted to prevent the shell from
-attempting to expand it according the files in the current working
-directory (the shell does not have access to the list of files in
-the archive, of course).
-.Pp
-To move file hierarchies, use a command line like this:
-.Bd -literal
-tar -cf - -C srcdir . | tar xpf - -C destdir
-.Ed
-.Pp
-To create a compressed archive on diskette, using gzip, use a command-line like
-.Dl tar --block-compress -z -c -v -f /dev/rfd1a -b 36 tar/
-.Pp
-Note that you cannot mix bundled flags and --style flags; you can use
-single-letter flags in the manner above, rather than having to type
-.Dl tar --block-compress --gzip --verbose --file /dev/rfd1a --block-size 20 tar/
-.Pp
-The above-created diskette can be listed with
-.Dl tar tvfbz /dev/rfd1a 36
-.Pp
-To join two tar archives into a single archive, use
-.Dl tar Af archive1.tar archive2.tar
-which will add the files contained in archive2.tar onto the end of
-archive1.tar (note that this can't be done by simply typing
-.Dl cat archive2.tar >> archive1.tar
-because of the end-of-file block at the end of a tar archive).
-.Pp
-To archive all files from the directory srcdir, which were modified
-after Feb. 9th 1997, 13:00 h, use
-.Dl tar\ -c\ -f\ backup.tar\ --newer-mtime\ 'Feb\ 9\ 13:15\ 1997'\ srcdir/
-.Pp
-Other possible time specifications are '02/09/97 13:15',
-'1997-02-09 13:15', '13:15 9 Feb 1997', '9 Feb 1997 13:15',
-'Feb. 9, 1997 1:15pm', '09-Feb', '3 weeks ago' or 'May first Sunday'.
-To specify the correct time zone use either e.g. `13:15 CEST' or `13:15+200'.
-
-.Sh ENVIRONMENT
-The
-.Nm tar
-program examines the following environment variables.
-.Bl -tag -width "POSIXLY-CORRECT"
-.It POSIXLY-CORRECT
-Normally,
-.Nm tar
-will process flag arguments that appear in the file list.
-If set in the environment, this causes
-.Nm tar
-to consider the first
-non-flag argument to terminate flag processing, as per the POSIX specification.
-.It SHELL
-In interactive mode, a permissible response to the prompt is to
-request to spawn a subshell, which will be "/bin/sh" unless the SHELL variable
-is set.
-.It TAPE
-Changes tar's default tape drive (which is still overridden by the
-.Fl f
-flag).
-.El
-.Sh FILES
-.Bl -tag -width "/dev/rst0"
-.It Pa /dev/rst0
-The default tape drive.
-.El
-.\" This next request is for sections 1, 6, 7 & 8 only
-.\" (command return values (to shell) and fprintf/stderr type diagnostics)
-.\" .Sh DIAGNOSTICS
-.Sh SEE ALSO
-.Xr compress 1 ,
-.Xr gzip 1 ,
-.Xr pax 1 ,
-.Xr ft 8 ,
-.Xr rmt 8
-.\" .Sh STANDARDS
-.Sh HISTORY
-The tar format has a rich history, dating back to Sixth Edition UNIX.
-The current implementation of
-.Nm tar
-is the GNU implementation, which
-originated as the public-domain tar written by John Gilmore.
-.Sh AUTHORS
-A cast of thousands, including [as listed in the ChangeLog file in the
-source] John Gilmore (author of original public
-domain version), Jay Fenlason (first GNU author), Joy Kendall, Jim
-Kingdon, David J. MacKenzie, Michael I Bushnell, Noah Friedman, and
-innumerable others who have contributed fixes and additions.
-
-Man page obtained by the FreeBSD group from the NetBSD 1.0 release.
-.Sh BUGS
-The
-.Fl C
-feature does not work like historical tar programs, and is probably
-untrustworthy.
-.Pp
-The -A command should work to join an arbitrary number of tar archives
-together, but it does not; attempting to do so leaves the
-end-of-archive blocks in place for the second and subsequent archives.
diff --git a/gnu/usr.bin/tar/tar.c b/gnu/usr.bin/tar/tar.c
deleted file mode 100644
index 9b7f745..0000000
--- a/gnu/usr.bin/tar/tar.c
+++ /dev/null
@@ -1,1560 +0,0 @@
-/* Tar -- a tape archiver.
- Copyright (C) 1988, 1992, 1993 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/*
- * A tar (tape archiver) program.
- *
- * Written by John Gilmore, ihnp4!hoptoad!gnu, starting 25 Aug 85.
- */
-
-#include <stdio.h>
-#include <sys/types.h> /* Needed for typedefs in tar.h */
-#ifdef __FreeBSD__
-#include <locale.h>
-#endif
-#include "getopt.h"
-
-/*
- * The following causes "tar.h" to produce definitions of all the
- * global variables, rather than just "extern" declarations of them.
- */
-#define TAR_EXTERN /**/
-#include "tar.h"
-
-#include "port.h"
-#include "gnuregex.h"
-#include <fnmatch.h>
-
-/*
- * We should use a conversion routine that does reasonable error
- * checking -- atoi doesn't. For now, punt. FIXME.
- */
-#define intconv atoi
-PTR ck_malloc ();
-PTR ck_realloc ();
-extern int getoldopt ();
-extern void read_and ();
-extern void list_archive ();
-extern void extract_archive ();
-extern void diff_archive ();
-extern void create_archive ();
-extern void update_archive ();
-extern void junk_archive ();
-extern void init_volume_number ();
-extern void closeout_volume_number ();
-
-/* JF */
-extern time_t get_date ();
-
-time_t new_time;
-
-static FILE *namef; /* File to read names from */
-static char **n_argv; /* Argv used by name routines */
-static int n_argc; /* Argc used by name routines */
-static char **n_ind; /* Store an array of names */
-static int n_indalloc; /* How big is the array? */
-static int n_indused; /* How many entries does it have? */
-static int n_indscan; /* How many of the entries have we scanned? */
-
-
-extern FILE *msg_file;
-
-int check_exclude ();
-void add_exclude ();
-void add_exclude_file ();
-void addname ();
-void describe ();
-void diff_init ();
-void extr_init ();
-int is_regex ();
-void name_add ();
-void name_init ();
-void options ();
-char *un_quote_string ();
-int nlpsfreed = 0;
-
-#ifndef S_ISLNK
-#define lstat stat
-#endif
-
-#ifndef DEFBLOCKING
-#define DEFBLOCKING 20
-#endif
-
-#ifndef DEF_AR_FILE
-#define DEF_AR_FILE "tar.out"
-#endif
-
-/* For long options that unconditionally set a single flag, we have getopt
- do it. For the others, we share the code for the equivalent short
- named option, the name of which is stored in the otherwise-unused `val'
- field of the `struct option'; for long options that have no equivalent
- short option, we use nongraphic characters as pseudo short option
- characters, starting (for no particular reason) with character 10. */
-
-struct option long_options[] =
-{
- {"create", 0, 0, 'c'},
- {"append", 0, 0, 'r'},
- {"extract", 0, 0, 'x'},
- {"get", 0, 0, 'x'},
- {"list", 0, 0, 't'},
- {"update", 0, 0, 'u'},
- {"catenate", 0, 0, 'A'},
- {"concatenate", 0, 0, 'A'},
- {"compare", 0, 0, 'd'},
- {"diff", 0, 0, 'd'},
- {"delete", 0, 0, 14},
- {"help", 0, 0, 12},
-
- {"null", 0, 0, 16},
- {"directory", 1, 0, 'C'},
- {"record-number", 0, &f_sayblock, 1},
- {"files-from", 1, 0, 'T'},
- {"label", 1, 0, 'V'},
- {"exclude-from", 1, 0, 'X'},
- {"exclude", 1, 0, 15},
- {"file", 1, 0, 'f'},
- {"block-size", 1, 0, 'b'},
- {"version", 0, 0, 11},
- {"verbose", 0, 0, 'v'},
- {"totals", 0, &f_totals, 1},
-
- {"read-full-blocks", 0, &f_reblock, 1},
- {"starting-file", 1, 0, 'K'},
- {"to-stdout", 0, &f_exstdout, 1},
- {"ignore-zeros", 0, &f_ignorez, 1},
- {"keep-old-files", 0, 0, 'k'},
- {"same-permissions", 0, &f_use_protection, 1},
- {"preserve-permissions", 0, &f_use_protection, 1},
- {"modification-time", 0, &f_modified, 1},
- {"preserve", 0, 0, 10},
- {"same-order", 0, &f_sorted_names, 1},
- {"same-owner", 0, &f_do_chown, 1},
- {"preserve-order", 0, &f_sorted_names, 1},
-
- {"newer", 1, 0, 'N'},
- {"after-date", 1, 0, 'N'},
- {"newer-mtime", 1, 0, 13},
- {"incremental", 0, 0, 'G'},
- {"listed-incremental", 1, 0, 'g'},
- {"multi-volume", 0, &f_multivol, 1},
- {"info-script", 1, 0, 'F'},
- {"new-volume-script", 1, 0, 'F'},
- {"absolute-paths", 0, &f_absolute_paths, 1},
- {"interactive", 0, &f_confirm, 1},
- {"confirmation", 0, &f_confirm, 1},
-
- {"verify", 0, &f_verify, 1},
- {"dereference", 0, &f_follow_links, 1},
- {"one-file-system", 0, &f_local_filesys, 1},
- {"old-archive", 0, 0, 'o'},
- {"portability", 0, 0, 'o'},
- {"compress", 0, 0, 'Z'},
- {"uncompress", 0, 0, 'Z'},
- {"block-compress", 0, &f_compress_block, 1},
- {"gzip", 0, 0, 'z'},
- {"ungzip", 0, 0, 'z'},
- {"use-compress-program", 1, 0, 18},
-
-
- {"same-permissions", 0, &f_use_protection, 1},
- {"sparse", 0, &f_sparse_files, 1},
- {"tape-length", 1, 0, 'L'},
- {"remove-files", 0, &f_remove_files, 1},
- {"ignore-failed-read", 0, &f_ignore_failed_read, 1},
- {"checkpoint", 0, &f_checkpoint, 1},
- {"show-omitted-dirs", 0, &f_show_omitted_dirs, 1},
- {"volno-file", 1, 0, 17},
- {"force-local", 0, &f_force_local, 1},
- {"atime-preserve", 0, &f_atime_preserve, 1},
-
- {"unlink", 0, &f_unlink, 1},
- {"fast-read", 0, &f_fast_read, 1},
- {"norecurse", 0, 0, 'n'},
-
- {0, 0, 0, 0}
-};
-
-/*
- * Main routine for tar.
- */
-void
-main (argc, argv)
- int argc;
- char **argv;
-{
- extern char version_string[];
-
-#ifdef __FreeBSD__
- (void) setlocale (LC_ALL, "");
-#endif
-
- tar = argv[0]; /* JF: was "tar" Set program name */
- filename_terminator = '\n';
- errors = 0;
-
- options (argc, argv);
-
- if (!n_argv)
- name_init (argc, argv);
-
- if (f_volno_file)
- init_volume_number ();
-
- switch (cmd_mode)
- {
- case CMD_CAT:
- case CMD_UPDATE:
- case CMD_APPEND:
- update_archive ();
- break;
- case CMD_DELETE:
- junk_archive ();
- break;
- case CMD_CREATE:
- create_archive ();
- if (f_totals)
- fprintf (stderr, "Total bytes written: %d\n", tot_written);
- break;
- case CMD_EXTRACT:
- if (f_volhdr)
- {
- const char *err;
- label_pattern = (struct re_pattern_buffer *)
- ck_malloc (sizeof *label_pattern);
- err = re_compile_pattern (f_volhdr, strlen (f_volhdr),
- label_pattern);
- if (err)
- {
- fprintf (stderr, "Bad regular expression: %s\n",
- err);
- errors++;
- break;
- }
-
- }
- extr_init ();
- read_and (extract_archive);
- break;
- case CMD_LIST:
- if (f_volhdr)
- {
- const char *err;
- label_pattern = (struct re_pattern_buffer *)
- ck_malloc (sizeof *label_pattern);
- err = re_compile_pattern (f_volhdr, strlen (f_volhdr),
- label_pattern);
- if (err)
- {
- fprintf (stderr, "Bad regular expression: %s\n",
- err);
- errors++;
- break;
- }
- }
- read_and (list_archive);
-#if 0
- if (!errors)
- errors = different;
-#endif
- break;
- case CMD_DIFF:
- diff_init ();
- read_and (diff_archive);
- break;
- case CMD_VERSION:
- fprintf (stderr, "%s\n", version_string);
- break;
- case CMD_NONE:
- msg ("you must specify exactly one of the r, c, t, x, or d options\n");
- fprintf (stderr, "For more information, type ``%s --help''.\n", tar);
- exit (EX_ARGSBAD);
- }
- if (f_volno_file)
- closeout_volume_number ();
- exit (errors ? EX_ARGSBAD : 0); /* FIXME (should be EX_NONDESCRIPT) */
- /* NOTREACHED */
-}
-
-
-/*
- * Parse the options for tar.
- */
-void
-options (argc, argv)
- int argc;
- char **argv;
-{
- register int c; /* Option letter */
- int ind = -1;
-
- /* Set default option values */
- blocking = DEFBLOCKING; /* From Makefile */
- ar_files = (char **) ck_malloc (sizeof (char *) * 10);
- ar_files_len = 10;
- n_ar_files = 0;
- cur_ar_file = 0;
-
- /* Parse options */
- while ((c = getoldopt (argc, argv,
- "-01234567Ab:BcC:df:F:g:GhikK:lL:mMnN:oOpPrRsStT:uvV:wWxX:zZ",
- long_options, &ind)) != EOF)
- {
- switch (c)
- {
- case 0: /* long options that set a single flag */
- break;
- case 1:
- /* File name or non-parsed option */
- name_add (optarg);
- break;
- case 'C':
- name_add ("-C");
- name_add (optarg);
- break;
- case 10: /* preserve */
- f_use_protection = f_sorted_names = 1;
- break;
- case 11:
- if (cmd_mode != CMD_NONE)
- goto badopt;
- cmd_mode = CMD_VERSION;
- break;
- case 12: /* help */
- printf ("This is GNU tar, the tape archiving program.\n");
- describe ();
- exit (1);
- case 13:
- f_new_files++;
- goto get_newer;
-
- case 14: /* Delete in the archive */
- if (cmd_mode != CMD_NONE)
- goto badopt;
- cmd_mode = CMD_DELETE;
- break;
-
- case 15:
- f_exclude++;
- add_exclude (optarg);
- break;
-
- case 16: /* -T reads null terminated filenames. */
- filename_terminator = '\0';
- break;
-
- case 17:
- f_volno_file = optarg;
- break;
-
- case 18:
- if (f_compressprog)
- {
- msg ("Only one compression option permitted\n");
- exit (EX_ARGSBAD);
- }
- f_compressprog = optarg;
- break;
-
- case 'g': /* We are making a GNU dump; save
- directories at the beginning of
- the archive, and include in each
- directory its contents */
- if (f_oldarch)
- goto badopt;
- f_gnudump++;
- gnu_dumpfile = optarg;
- break;
-
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- {
- /* JF this'll have to be modified for other
- systems, of course! */
- int d, add;
- static char buf[50];
-
- d = getoldopt (argc, argv, "lmh");
-#ifdef MAYBEDEF
- sprintf (buf, "/dev/rmt/%d%c", c, d);
-#else
-#ifndef LOW_NUM
-#define LOW_NUM 0
-#define MID_NUM 8
-#define HGH_NUM 16
-#endif
- if (d == 'l')
- add = LOW_NUM;
- else if (d == 'm')
- add = MID_NUM;
- else if (d == 'h')
- add = HGH_NUM;
- else
- goto badopt;
-
- sprintf (buf, "/dev/rmt%d", add + c - '0');
-#endif
- if (n_ar_files == ar_files_len)
- ar_files
- = (char **)
- ck_malloc (sizeof (char *)
- * (ar_files_len *= 2));
- ar_files[n_ar_files++] = buf;
- }
- break;
-
- case 'A': /* Arguments are tar files,
- just cat them onto the end
- of the archive. */
- if (cmd_mode != CMD_NONE)
- goto badopt;
- cmd_mode = CMD_CAT;
- break;
-
- case 'b': /* Set blocking factor */
- blocking = intconv (optarg);
- break;
-
- case 'B': /* Try to reblock input */
- f_reblock++; /* For reading 4.2BSD pipes */
- break;
-
- case 'c': /* Create an archive */
- if (cmd_mode != CMD_NONE)
- goto badopt;
- cmd_mode = CMD_CREATE;
- break;
-
-#if 0
- case 'C':
- if (chdir (optarg) < 0)
- msg_perror ("Can't change directory to %d", optarg);
- break;
-#endif
-
- case 'd': /* Find difference tape/disk */
- if (cmd_mode != CMD_NONE)
- goto badopt;
- cmd_mode = CMD_DIFF;
- break;
-
- case 'f': /* Use ar_file for the archive */
- if (n_ar_files == ar_files_len)
- ar_files
- = (char **) ck_malloc (sizeof (char *)
- * (ar_files_len *= 2));
-
- ar_files[n_ar_files++] = optarg;
- break;
-
- case 'F':
- /* Since -F is only useful with -M , make it implied */
- f_run_script_at_end++;/* run this script at the end */
- info_script = optarg; /* of each tape */
- f_multivol++;
- break;
-
- case 'G': /* We are making a GNU dump; save
- directories at the beginning of
- the archive, and include in each
- directory its contents */
- if (f_oldarch)
- goto badopt;
- f_gnudump++;
- gnu_dumpfile = 0;
- break;
-
- case 'h':
- f_follow_links++; /* follow symbolic links */
- break;
-
- case 'i':
- f_ignorez++; /* Ignore zero records (eofs) */
- /*
- * This can't be the default, because Unix tar
- * writes two records of zeros, then pads out the
- * block with garbage.
- */
- break;
-
- case 'k': /* Don't overwrite files */
-#ifdef NO_OPEN3
- msg ("can't keep old files on this system");
- exit (EX_ARGSBAD);
-#else
- f_keep++;
-#endif
- break;
-
- case 'K':
- f_startfile++;
- addname (optarg);
- break;
-
- case 'l': /* When dumping directories, don't
- dump files/subdirectories that are
- on other filesystems. */
- f_local_filesys++;
- break;
-
- case 'L':
- tape_length = intconv (optarg);
- f_multivol++;
- break;
- case 'm':
- f_modified++;
- break;
-
- case 'M': /* Make Multivolume archive:
- When we can't write any more
- into the archive, re-open it,
- and continue writing */
- f_multivol++;
- break;
-
- case 'n': /* don't recurse into subdirectories */
- if (f_oldarch)
- goto badopt;
- f_dironly++;
- break;
-
- case 'N': /* Only write files newer than X */
- get_newer:
- f_new_files++;
- new_time = get_date (optarg, (PTR) 0);
- if (new_time == (time_t) - 1)
- {
- msg ("invalid date format `%s'", optarg);
- exit (EX_ARGSBAD);
- }
- break;
-
- case 'o': /* Generate old archive */
- if (f_gnudump || f_dironly )
- goto badopt;
- f_oldarch++;
- break;
-
- case 'O':
- f_exstdout++;
- break;
-
- case 'p':
- f_use_protection++;
- break;
-
- case 'P':
- f_absolute_paths++;
- break;
-
- case 'r': /* Append files to the archive */
- if (cmd_mode != CMD_NONE)
- goto badopt;
- cmd_mode = CMD_APPEND;
- break;
-
- case 'R':
- f_sayblock++; /* Print block #s for debug */
- break; /* of bad tar archives */
-
- case 's':
- f_sorted_names++; /* Names to extr are sorted */
- break;
-
- case 'S': /* deal with sparse files */
- f_sparse_files++;
- break;
- case 't':
- if (cmd_mode != CMD_NONE)
- goto badopt;
- cmd_mode = CMD_LIST;
- f_verbose++; /* "t" output == "cv" or "xv" */
- break;
-
- case 'T':
- name_file = optarg;
- f_namefile++;
- break;
-
- case 'u': /* Append files to the archive that
- aren't there, or are newer than the
- copy in the archive */
- if (cmd_mode != CMD_NONE)
- goto badopt;
- cmd_mode = CMD_UPDATE;
- break;
-
- case 'v':
- f_verbose++;
- break;
-
- case 'V':
- f_volhdr = optarg;
- break;
-
- case 'w':
- f_confirm++;
- break;
-
- case 'W':
- f_verify++;
- break;
-
- case 'x': /* Extract files from the archive */
- if (cmd_mode != CMD_NONE)
- goto badopt;
- cmd_mode = CMD_EXTRACT;
- break;
-
- case 'X':
- f_exclude++;
- add_exclude_file (optarg);
- break;
-
- case 'z':
- if (f_compressprog)
- {
- msg ("Only one compression option permitted\n");
- exit (EX_ARGSBAD);
- }
- f_compressprog = "gzip";
- break;
-
- case 'Z':
- if (f_compressprog)
- {
- msg ("Only one compression option permitted\n");
- exit (EX_ARGSBAD);
- }
- f_compressprog = "compress";
- break;
-
- case '?':
- badopt:
- msg ("Unknown option. Use '%s --help' for a complete list of options.", tar);
- exit (EX_ARGSBAD);
-
- }
- }
-
- blocksize = blocking * RECORDSIZE;
- if (n_ar_files == 0)
- {
- n_ar_files = 1;
- ar_files[0] = getenv ("TAPE"); /* From environment, or */
- if (ar_files[0] == 0)
- ar_files[0] = DEF_AR_FILE; /* From Makefile */
- }
- if (n_ar_files > 1 && !f_multivol)
- {
- msg ("Multiple archive files requires --multi-volume\n");
- exit (EX_ARGSBAD);
- }
- if (f_compress_block && !f_compressprog)
- {
- msg ("You must use a compression option (--gzip, --compress\n\
-or --use-compress-program) with --block-compress.\n");
- exit (EX_ARGSBAD);
- }
-}
-
-
-/*
- * Print as much help as the user's gonna get.
- *
- * We have to sprinkle in the KLUDGE lines because too many compilers
- * cannot handle character strings longer than about 512 bytes. Yuk!
- * In particular, MS-DOS and Xenix MSC and PDP-11 V7 Unix have this
- * problem.
- */
-void
-describe ()
-{
- puts ("choose one of the following:");
- fputs ("\
--A, --catenate,\n\
- --concatenate append tar files to an archive\n\
--c, --create create a new archive\n\
--d, --diff,\n\
- --compare find differences between archive and file system\n\
---delete delete from the archive (not for use on mag tapes!)\n\
--r, --append append files to the end of an archive\n\
--t, --list list the contents of an archive\n\
--u, --update only append files that are newer than copy in archive\n\
--x, --extract,\n\
- --get extract files from an archive\n", stdout);
-
- fprintf (stdout, "\
-Other options:\n\
---atime-preserve don't change access times on dumped files\n\
--b, --block-size N block size of Nx512 bytes (default N=%d)\n", DEFBLOCKING);
- fputs ("\
--B, --read-full-blocks reblock as we read (for reading 4.2BSD pipes)\n\
--C, --directory DIR change to directory DIR\n\
---checkpoint print number of buffer reads/writes\n\
-", stdout); /* KLUDGE */
- fprintf (stdout, "\
--f, --file [HOSTNAME:]F use archive file or device F (default %s)\n",
- DEF_AR_FILE);
- fputs ("\
---force-local archive file is local even if it has a colon\n\
--F, --info-script F\n\
- --new-volume-script F run script at end of each tape (implies -M)\n\
--G, --incremental create/list/extract old GNU-format incremental backup\n\
--g, --listed-incremental F create/list/extract new GNU-format incremental backup\n\
--h, --dereference don't dump symlinks; dump the files they point to\n\
--i, --ignore-zeros ignore blocks of zeros in archive (normally mean EOF)\n\
---ignore-failed-read don't exit with non-zero status on unreadable files\n\
--k, --keep-old-files keep existing files; don't overwrite them from archive\n\
--K, --starting-file F begin at file F in the archive\n\
--l, --one-file-system stay in local file system when creating an archive\n\
--L, --tape-length N change tapes after writing N*1024 bytes\n\
-", stdout); /* KLUDGE */
- fputs ("\
--m, --modification-time don't extract file modified time\n\
--M, --multi-volume create/list/extract multi-volume archive\n\
--n, --norecurse don't recurse into subdircectories\n\
---volno-file F use volume number to start with from file F\n\
--N, --after-date DATE,\n\
- --newer DATE only store files with creation time newer than DATE\n\
---newer-mtime DATE only store files with modification time newer than DATE\n\
--o, --old-archive,\n\
- --portability write a V7 format archive, rather than ANSI format\n\
--O, --to-stdout extract files to standard output\n\
--p, --same-permissions,\n\
- --preserve-permissions extract all protection information\n\
--P, --absolute-paths don't strip leading `/'s from file names\n\
---preserve like -p -s\n\
-", stdout); /* KLUDGE */
- fputs ("\
--R, --record-number show record number within archive with each message\n\
---remove-files remove files after adding them to the archive\n\
--s, --same-order,\n\
- --preserve-order list of names to extract is sorted to match archive\n\
---same-owner create extracted files with the same ownership \n\
---show-omitted-dirs show omitted directories while processing the archive.\n\
--S, --sparse handle sparse files efficiently\n\
--T, --files-from F get names to extract or create from file F\n\
---null -T reads null-terminated names, disable -C\n\
---totals print total bytes written with --create\n\
--v, --verbose verbosely list files processed\n\
--V, --label NAME create archive with volume name NAME\n\
---version print tar program version number\n\
--w, --interactive,\n\
- --confirmation ask for confirmation for every action\n\
-", stdout); /* KLUDGE */
- fputs ("\
--W, --verify attempt to verify the archive after writing it\n\
---exclude FILE exclude file FILE\n\
--X, --exclude-from FILE exclude files listed in FILE\n\
--Z, --compress,\n\
- --uncompress filter the archive through compress\n\
--z, --gzip,\n\
- --ungzip filter the archive through gzip\n\
---use-compress-program PROG\n\
- filter the archive through PROG (which must accept -d)\n\
---block-compress block the output of compression program for tapes\n\
--[0-7][lmh] specify drive and density\n\
---unlink unlink files before creating them\n\
---fast-read stop after desired names in archive have been found\n\
-", stdout);
-}
-
-void
-name_add (name)
- char *name;
-{
- if (n_indalloc == n_indused)
- {
- n_indalloc += 10;
- n_ind = (char **) (n_indused ? ck_realloc (n_ind, n_indalloc * sizeof (char *)): ck_malloc (n_indalloc * sizeof (char *)));
- }
- n_ind[n_indused++] = name;
-}
-
-/*
- * Set up to gather file names for tar.
- *
- * They can either come from stdin or from argv.
- */
-void
-name_init (argc, argv)
- int argc;
- char **argv;
-{
-
- if (f_namefile)
- {
- if (optind < argc)
- {
- msg ("too many args with -T option");
- exit (EX_ARGSBAD);
- }
- if (!strcmp (name_file, "-"))
- {
- namef = stdin;
- }
- else
- {
- namef = fopen (name_file, "r");
- if (namef == NULL)
- {
- msg_perror ("can't open file %s", name_file);
- exit (EX_BADFILE);
- }
- }
- }
- else
- {
- /* Get file names from argv, after options. */
- n_argc = argc;
- n_argv = argv;
- }
-}
-
-/* Read the next filename read from STREAM and null-terminate it.
- Put it into BUFFER, reallocating and adjusting *PBUFFER_SIZE if necessary.
- Return the new value for BUFFER, or NULL at end of file. */
-
-char *
-read_name_from_file (buffer, pbuffer_size, stream)
- char *buffer;
- size_t *pbuffer_size;
- FILE *stream;
-{
- register int c;
- register int indx = 0;
- register size_t buffer_size = *pbuffer_size;
-
- while ((c = getc (stream)) != EOF && c != filename_terminator)
- {
- if (indx == buffer_size)
- {
- buffer_size += NAMSIZ;
- buffer = ck_realloc (buffer, buffer_size + 2);
- }
- buffer[indx++] = c;
- }
- if (indx == 0 && c == EOF)
- return NULL;
- if (indx == buffer_size)
- {
- buffer_size += NAMSIZ;
- buffer = ck_realloc (buffer, buffer_size + 2);
- }
- buffer[indx] = '\0';
- *pbuffer_size = buffer_size;
- return buffer;
-}
-
-/*
- * Get the next name from argv or the name file.
- *
- * Result is in static storage and can't be relied upon across two calls.
- *
- * If CHANGE_DIRS is non-zero, treat a filename of the form "-C" as
- * meaning that the next filename is the name of a directory to change to.
- * If `filename_terminator' is '\0', CHANGE_DIRS is effectively always 0.
- */
-
-char *
-name_next (change_dirs)
- int change_dirs;
-{
- static char *buffer; /* Holding pattern */
- static int buffer_siz;
- register char *p;
- register char *q = 0;
- register int next_name_is_dir = 0;
- extern char *un_quote_string ();
-
- if (buffer_siz == 0)
- {
- buffer = ck_malloc (NAMSIZ + 2);
- buffer_siz = NAMSIZ;
- }
- if (filename_terminator == '\0')
- change_dirs = 0;
-tryagain:
- if (namef == NULL)
- {
- if (n_indscan < n_indused)
- p = n_ind[n_indscan++];
- else if (optind < n_argc)
- /* Names come from argv, after options */
- p = n_argv[optind++];
- else
- {
- if (q)
- msg ("Missing filename after -C");
- return NULL;
- }
-
- /* JF trivial support for -C option. I don't know if
- chdir'ing at this point is dangerous or not.
- It seems to work, which is all I ask. */
- if (change_dirs && !q && p[0] == '-' && p[1] == 'C' && p[2] == '\0')
- {
- q = p;
- goto tryagain;
- }
- if (q)
- {
- if (chdir (p) < 0)
- msg_perror ("Can't chdir to %s", p);
- q = 0;
- goto tryagain;
- }
- /* End of JF quick -C hack */
-
-#if 0
- if (f_exclude && check_exclude (p))
- goto tryagain;
-#endif
- return un_quote_string (p);
- }
- while (p = read_name_from_file (buffer, &buffer_siz, namef))
- {
- buffer = p;
- if (*p == '\0')
- continue; /* Ignore empty lines. */
- q = p + strlen (p) - 1;
- while (q > p && *q == '/')/* Zap trailing "/"s. */
- *q-- = '\0';
- if (change_dirs && next_name_is_dir == 0
- && p[0] == '-' && p[1] == 'C' && p[2] == '\0')
- {
- next_name_is_dir = 1;
- goto tryagain;
- }
- if (next_name_is_dir)
- {
- if (chdir (p) < 0)
- msg_perror ("Can't change to directory %s", p);
- next_name_is_dir = 0;
- goto tryagain;
- }
-#if 0
- if (f_exclude && check_exclude (p))
- goto tryagain;
-#endif
- return un_quote_string (p);
- }
- return NULL;
-}
-
-
-/*
- * Close the name file, if any.
- */
-void
-name_close ()
-{
-
- if (namef != NULL && namef != stdin)
- fclose (namef);
-}
-
-
-/*
- * Gather names in a list for scanning.
- * Could hash them later if we really care.
- *
- * If the names are already sorted to match the archive, we just
- * read them one by one. name_gather reads the first one, and it
- * is called by name_match as appropriate to read the next ones.
- * At EOF, the last name read is just left in the buffer.
- * This option lets users of small machines extract an arbitrary
- * number of files by doing "tar t" and editing down the list of files.
- */
-void
-name_gather ()
-{
- register char *p;
- static struct name *namebuf; /* One-name buffer */
- static namelen;
- static char *chdir_name;
-
- if (f_sorted_names)
- {
- if (!namelen)
- {
- namelen = NAMSIZ;
- namebuf = (struct name *) ck_malloc (sizeof (struct name) + NAMSIZ);
- }
- p = name_next (0);
- if (p)
- {
- if (*p == '-' && p[1] == 'C' && p[2] == '\0')
- {
- p = name_next (0);
- chdir_name = p ? strdup(p) : p;
- p = name_next (0);
- if (!chdir_name)
- {
- msg ("Missing file name after -C");
- exit (EX_ARGSBAD);
- }
- namebuf->change_dir = chdir_name;
- }
- namebuf->length = strlen (p);
- if (namebuf->length >= namelen)
- {
- namebuf = (struct name *) ck_realloc (namebuf, sizeof (struct name) + namebuf->length);
- namelen = namebuf->length;
- }
- strncpy (namebuf->name, p, namebuf->length);
- namebuf->name[namebuf->length] = 0;
- namebuf->next = (struct name *) NULL;
- namebuf->found = 0;
- namelist = namebuf;
- namelast = namelist;
- }
- return;
- }
-
- /* Non sorted names -- read them all in */
- while (p = name_next (0))
- addname (p);
-}
-
-/*
- * Add a name to the namelist.
- */
-void
-addname (name)
- char *name; /* pointer to name */
-{
- register int i; /* Length of string */
- register struct name *p; /* Current struct pointer */
- static char *chdir_name;
- char *new_name ();
-
- if (name[0] == '-' && name[1] == 'C' && name[2] == '\0')
- {
- name = name_next (0);
- chdir_name = name ? strdup(name) : name;
- name = name_next (0);
- if (!chdir_name)
- {
- msg ("Missing file name after -C");
- exit (EX_ARGSBAD);
- }
- if (chdir_name[0] != '/')
- {
- char *path = ck_malloc (PATH_MAX);
-#if defined(__MSDOS__) || defined(HAVE_GETCWD) || defined(_POSIX_VERSION)
- if (!getcwd (path, PATH_MAX))
- {
- msg ("Couldn't get current directory.");
- exit (EX_SYSTEM);
- }
-#else
- char *getwd ();
-
- if (!getwd (path))
- {
- msg ("Couldn't get current directory: %s", path);
- exit (EX_SYSTEM);
- }
-#endif
- chdir_name = new_name (path, chdir_name);
- free (path);
- }
- }
-
- if (name)
- {
- i = strlen (name);
- /*NOSTRICT*/
- p = (struct name *) malloc ((unsigned) (sizeof (struct name) + i));
- }
- else
- p = (struct name *) malloc ((unsigned) (sizeof (struct name)));
- if (!p)
- {
- if (name)
- msg ("cannot allocate mem for name '%s'.", name);
- else
- msg ("cannot allocate mem for chdir record.");
- exit (EX_SYSTEM);
- }
- p->next = (struct name *) NULL;
- if (name)
- {
- p->fake = 0;
- p->length = i;
- strncpy (p->name, name, i);
- p->name[i] = '\0'; /* Null term */
- }
- else
- p->fake = 1;
- p->found = 0;
- p->regexp = 0; /* Assume not a regular expression */
- p->firstch = 1; /* Assume first char is literal */
- p->change_dir = chdir_name;
- p->dir_contents = 0; /* JF */
- if (name)
- {
- if (index (name, '*') || index (name, '[') || index (name, '?'))
- {
- p->regexp = 1; /* No, it's a regexp */
- if (name[0] == '*' || name[0] == '[' || name[0] == '?')
- p->firstch = 0; /* Not even 1st char literal */
- }
- }
-
- if (namelast)
- namelast->next = p;
- namelast = p;
- if (!namelist)
- namelist = p;
-}
-
-/*
- * Return nonzero if name P (from an archive) matches any name from
- * the namelist, zero if not.
- */
-int
-name_match (p)
- register char *p;
-{
- register struct name *nlp;
- struct name *tmpnlp;
- register int len;
-
-again:
- if (0 == (nlp = namelist)) /* Empty namelist is easy */
- return 1;
- if (nlp->fake)
- {
- if (nlp->change_dir && chdir (nlp->change_dir))
- msg_perror ("Can't change to directory %s", nlp->change_dir);
- namelist = 0;
- return 1;
- }
- len = strlen (p);
- for (; nlp != 0; nlp = nlp->next)
- {
- /* If first chars don't match, quick skip */
- if (nlp->firstch && nlp->name[0] != p[0])
- continue;
-
- /* Regular expressions (shell globbing, actually). */
- if (nlp->regexp)
- {
- if (fnmatch (nlp->name, p, FNM_LEADING_DIR) == 0)
- {
- nlp->found = 1; /* Remember it matched */
- if (f_startfile)
- {
- free ((void *) namelist);
- namelist = 0;
- }
- if (nlp->change_dir && chdir (nlp->change_dir))
- msg_perror ("Can't change to directory %s", nlp->change_dir);
- return 1; /* We got a match */
- }
- continue;
- }
-
- /* Plain Old Strings */
- if (nlp->length <= len /* Archive len >= specified */
- && (p[nlp->length] == '\0' || p[nlp->length] == '/')
- /* Full match on file/dirname */
- && strncmp (p, nlp->name, nlp->length) == 0) /* Name compare */
- {
- nlp->found = 1; /* Remember it matched */
- if (f_startfile)
- {
- free ((void *) namelist);
- namelist = 0;
- }
- if (nlp->change_dir && chdir (nlp->change_dir))
- msg_perror ("Can't change to directory %s", nlp->change_dir);
- if (f_fast_read) {
- if (strcmp(p, nlp->name) == 0) {
- /* remove the current entry, since we found a match */
- /* use brute force, this code is a mess anyway */
- if (namelist->next == NULL) {
- /* the list contains one element */
- free(namelist);
- namelist = NULL;
- } else {
- if (nlp == namelist) {
- /* the first element is the one */
- tmpnlp = namelist->next;
- free(namelist);
- namelist = tmpnlp;
- } else {
- tmpnlp = namelist;
- while (tmpnlp->next != nlp) {
- tmpnlp = tmpnlp->next;
- }
- tmpnlp->next = nlp->next;
- free(nlp);
- }
- }
- /* set a boolean to decide wether we started with a */
- /* non-empty namelist, that was emptied */
- nlpsfreed = 1;
- }
- }
- return 1; /* We got a match */
-
- }
- }
-
- /*
- * Filename from archive not found in namelist.
- * If we have the whole namelist here, just return 0.
- * Otherwise, read the next name in and compare it.
- * If this was the last name, namelist->found will remain on.
- * If not, we loop to compare the newly read name.
- */
- if (f_sorted_names && namelist->found)
- {
- name_gather (); /* Read one more */
- if (!namelist->found)
- goto again;
- }
- return 0;
-}
-
-
-/*
- * Print the names of things in the namelist that were not matched.
- */
-void
-names_notfound ()
-{
- register struct name *nlp, *next;
- register char *p;
-
- for (nlp = namelist; nlp != 0; nlp = next)
- {
- next = nlp->next;
- if (!nlp->found)
- msg ("%s not found in archive", nlp->name);
-
- /*
- * We could free() the list, but the process is about
- * to die anyway, so save some CPU time. Amigas and
- * other similarly broken software will need to waste
- * the time, though.
- */
-#ifdef amiga
- if (!f_sorted_names)
- free (nlp);
-#endif
- }
- namelist = (struct name *) NULL;
- namelast = (struct name *) NULL;
-
- if (f_sorted_names)
- {
- while (0 != (p = name_next (1)))
- msg ("%s not found in archive", p);
- }
-}
-
-/* These next routines were created by JF */
-
-void
-name_expand ()
-{
- ;
-}
-
-/* This is like name_match(), except that it returns a pointer to the name
- it matched, and doesn't set ->found The caller will have to do that
- if it wants to. Oh, and if the namelist is empty, it returns 0, unlike
- name_match(), which returns TRUE */
-
-struct name *
-name_scan (p)
- register char *p;
-{
- register struct name *nlp;
- register int len;
-
-again:
- if (0 == (nlp = namelist)) /* Empty namelist is easy */
- return 0;
- len = strlen (p);
- for (; nlp != 0; nlp = nlp->next)
- {
- /* If first chars don't match, quick skip */
- if (nlp->firstch && nlp->name[0] != p[0])
- continue;
-
- /* Regular expressions */
- if (nlp->regexp)
- {
- if (fnmatch (nlp->name, p, FNM_LEADING_DIR) == 0)
- return nlp; /* We got a match */
- continue;
- }
-
- /* Plain Old Strings */
- if (nlp->length <= len /* Archive len >= specified */
- && (p[nlp->length] == '\0' || p[nlp->length] == '/')
- /* Full match on file/dirname */
- && strncmp (p, nlp->name, nlp->length) == 0) /* Name compare */
- return nlp; /* We got a match */
- }
-
- /*
- * Filename from archive not found in namelist.
- * If we have the whole namelist here, just return 0.
- * Otherwise, read the next name in and compare it.
- * If this was the last name, namelist->found will remain on.
- * If not, we loop to compare the newly read name.
- */
- if (f_sorted_names && namelist->found)
- {
- name_gather (); /* Read one more */
- if (!namelist->found)
- goto again;
- }
- return (struct name *) 0;
-}
-
-/* This returns a name from the namelist which doesn't have ->found set.
- It sets ->found before returning, so successive calls will find and return
- all the non-found names in the namelist */
-
-struct name *gnu_list_name;
-
-char *
-name_from_list ()
-{
- if (!gnu_list_name)
- gnu_list_name = namelist;
- while (gnu_list_name && gnu_list_name->found)
- gnu_list_name = gnu_list_name->next;
- if (gnu_list_name)
- {
- gnu_list_name->found++;
- if (gnu_list_name->change_dir)
- if (chdir (gnu_list_name->change_dir) < 0)
- msg_perror ("can't chdir to %s", gnu_list_name->change_dir);
- return gnu_list_name->name;
- }
- return (char *) 0;
-}
-
-void
-blank_name_list ()
-{
- struct name *n;
-
- gnu_list_name = 0;
- for (n = namelist; n; n = n->next)
- n->found = 0;
-}
-
-char *
-new_name (path, name)
- char *path, *name;
-{
- char *path_buf;
-
- path_buf = (char *) malloc (strlen (path) + strlen (name) + 2);
- if (path_buf == 0)
- {
- msg ("Can't allocate memory for name '%s/%s", path, name);
- exit (EX_SYSTEM);
- }
- (void) sprintf (path_buf, "%s/%s", path, name);
- return path_buf;
-}
-
-/* returns non-zero if the luser typed 'y' or 'Y', zero otherwise. */
-
-int
-confirm (action, file)
- char *action, *file;
-{
- int c, nl;
- static FILE *confirm_file = 0;
- extern FILE *msg_file;
- extern char TTY_NAME[];
-
- fprintf (msg_file, "%s %s?", action, file);
- fflush (msg_file);
- if (!confirm_file)
- {
- confirm_file = (archive == 0) ? fopen (TTY_NAME, "r") : stdin;
- if (!confirm_file)
- {
- msg ("Can't read confirmation from user");
- exit (EX_SYSTEM);
- }
- }
- c = getc (confirm_file);
- for (nl = c; nl != '\n' && nl != EOF; nl = getc (confirm_file))
- ;
- return (c == 'y' || c == 'Y');
-}
-
-char *x_buffer = 0;
-int size_x_buffer;
-int free_x_buffer;
-
-char **exclude = 0;
-int size_exclude = 0;
-int free_exclude = 0;
-
-char **re_exclude = 0;
-int size_re_exclude = 0;
-int free_re_exclude = 0;
-
-void
-add_exclude (name)
- char *name;
-{
- /* char *rname;*/
- /* char **tmp_ptr;*/
- int size_buf;
-
- un_quote_string (name);
- size_buf = strlen (name);
-
- if (x_buffer == 0)
- {
- x_buffer = (char *) ck_malloc (size_buf + 1024);
- free_x_buffer = 1024;
- }
- else if (free_x_buffer <= size_buf)
- {
- char *old_x_buffer;
- char **tmp_ptr;
-
- old_x_buffer = x_buffer;
- x_buffer = (char *) ck_realloc (x_buffer, size_x_buffer + 1024);
- free_x_buffer = 1024;
- for (tmp_ptr = exclude; tmp_ptr < exclude + size_exclude; tmp_ptr++)
- *tmp_ptr = x_buffer + ((*tmp_ptr) - old_x_buffer);
- for (tmp_ptr = re_exclude; tmp_ptr < re_exclude + size_re_exclude; tmp_ptr++)
- *tmp_ptr = x_buffer + ((*tmp_ptr) - old_x_buffer);
- }
-
- if (is_regex (name))
- {
- if (free_re_exclude == 0)
- {
- re_exclude = (char **) (re_exclude ? ck_realloc (re_exclude, (size_re_exclude + 32) * sizeof (char *)): ck_malloc (sizeof (char *) * 32));
- free_re_exclude += 32;
- }
- re_exclude[size_re_exclude] = x_buffer + size_x_buffer;
- size_re_exclude++;
- free_re_exclude--;
- }
- else
- {
- if (free_exclude == 0)
- {
- exclude = (char **) (exclude ? ck_realloc (exclude, (size_exclude + 32) * sizeof (char *)): ck_malloc (sizeof (char *) * 32));
- free_exclude += 32;
- }
- exclude[size_exclude] = x_buffer + size_x_buffer;
- size_exclude++;
- free_exclude--;
- }
- strcpy (x_buffer + size_x_buffer, name);
- size_x_buffer += size_buf + 1;
- free_x_buffer -= size_buf + 1;
-}
-
-void
-add_exclude_file (file)
- char *file;
-{
- FILE *fp;
- char buf[1024];
-
- if (strcmp (file, "-"))
- fp = fopen (file, "r");
- else
- /* Let's hope the person knows what they're doing. */
- /* Using -X - -T - -f - will get you *REALLY* strange
- results. . . */
- fp = stdin;
-
- if (!fp)
- {
- msg_perror ("can't open %s", file);
- exit (2);
- }
- while (fgets (buf, 1024, fp))
- {
- /* int size_buf;*/
- char *end_str;
-
- end_str = rindex (buf, '\n');
- if (end_str)
- *end_str = '\0';
- add_exclude (buf);
-
- }
- fclose (fp);
-}
-
-int
-is_regex (str)
- char *str;
-{
- return index (str, '*') || index (str, '[') || index (str, '?');
-}
-
-/* Returns non-zero if the file 'name' should not be added/extracted */
-int
-check_exclude (name)
- char *name;
-{
- int n;
- char *str;
- extern char *strstr ();
-
- for (n = 0; n < size_re_exclude; n++)
- {
- if (fnmatch (re_exclude[n], name, FNM_LEADING_DIR) == 0)
- return 1;
- }
- for (n = 0; n < size_exclude; n++)
- {
- /* Accept the output from strstr only if it is the last
- part of the string. There is certainly a faster way to
- do this. . . */
- if ((str = strstr (name, exclude[n]))
- && (str == name || str[-1] == '/')
- && str[strlen (exclude[n])] == '\0')
- return 1;
- }
- return 0;
-}
diff --git a/gnu/usr.bin/tar/tar.h b/gnu/usr.bin/tar/tar.h
deleted file mode 100644
index 63558b6..0000000
--- a/gnu/usr.bin/tar/tar.h
+++ /dev/null
@@ -1,295 +0,0 @@
-/* Declarations for tar archives.
- Copyright (C) 1988, 1992, 1993 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* major() and minor() macros (among other things) defined here for hpux */
-#ifdef hpux
-#include <sys/mknod.h>
-#endif
-
-/*
- * Kludge for handling systems that can't cope with multiple
- * external definitions of a variable. In ONE routine (tar.c),
- * we #define TAR_EXTERN to null; here, we set it to "extern" if
- * it is not already set.
- */
-#ifndef TAR_EXTERN
-#define TAR_EXTERN extern
-#endif
-
-/*
- * Header block on tape.
- *
- * I'm going to use traditional DP naming conventions here.
- * A "block" is a big chunk of stuff that we do I/O on.
- * A "record" is a piece of info that we care about.
- * Typically many "record"s fit into a "block".
- */
-#define RECORDSIZE 512
-#define NAMSIZ 100
-#define TUNMLEN 32
-#define TGNMLEN 32
-#define SPARSE_EXT_HDR 21
-#define SPARSE_IN_HDR 4
-
-struct sparse
- {
- char offset[12];
- char numbytes[12];
- };
-
-struct sp_array
- {
- int offset;
- int numbytes;
- };
-
-union record
- {
- char charptr[RECORDSIZE];
- struct header
- {
- char arch_name[NAMSIZ];
- char mode[8];
- char uid[8];
- char gid[8];
- char size[12];
- char mtime[12];
- char chksum[8];
- char linkflag;
- char arch_linkname[NAMSIZ];
- char magic[8];
- char uname[TUNMLEN];
- char gname[TGNMLEN];
- char devmajor[8];
- char devminor[8];
- /* these following fields were added by JF for gnu */
- /* and are NOT standard */
- char atime[12];
- char ctime[12];
- char offset[12];
- char longnames[4];
-#ifdef NEEDPAD
- char pad;
-#endif
- struct sparse sp[SPARSE_IN_HDR];
- char isextended;
- char realsize[12]; /* true size of the sparse file */
- /* char ending_blanks[12];*//* number of nulls at the
- end of the file, if any */
- }
- header;
- struct extended_header
- {
- struct sparse sp[21];
- char isextended;
- }
- ext_hdr;
- };
-
-/* The checksum field is filled with this while the checksum is computed. */
-#define CHKBLANKS " " /* 8 blanks, no null */
-
-/* The magic field is filled with this if uname and gname are valid. */
-#define TMAGIC "ustar " /* 7 chars and a null */
-
-/* The linkflag defines the type of file */
-#define LF_OLDNORMAL '\0' /* Normal disk file, Unix compat */
-#define LF_NORMAL '0' /* Normal disk file */
-#define LF_LINK '1' /* Link to previously dumped file */
-#define LF_SYMLINK '2' /* Symbolic link */
-#define LF_CHR '3' /* Character special file */
-#define LF_BLK '4' /* Block special file */
-#define LF_DIR '5' /* Directory */
-#define LF_FIFO '6' /* FIFO special file */
-#define LF_CONTIG '7' /* Contiguous file */
-/* Further link types may be defined later. */
-
-/* Note that the standards committee allows only capital A through
- capital Z for user-defined expansion. This means that defining something
- as, say '8' is a *bad* idea. */
-#define LF_DUMPDIR 'D' /* This is a dir entry that contains
- the names of files that were in
- the dir at the time the dump
- was made */
-#define LF_LONGLINK 'K' /* Identifies the NEXT file on the tape
- as having a long linkname */
-#define LF_LONGNAME 'L' /* Identifies the NEXT file on the tape
- as having a long name. */
-#define LF_MULTIVOL 'M' /* This is the continuation
- of a file that began on another
- volume */
-#define LF_NAMES 'N' /* For storing filenames that didn't
- fit in 100 characters */
-#define LF_SPARSE 'S' /* This is for sparse files */
-#define LF_VOLHDR 'V' /* This file is a tape/volume header */
-/* Ignore it on extraction */
-
-/*
- * Exit codes from the "tar" program
- */
-#define EX_SUCCESS 0 /* success! */
-#define EX_ARGSBAD 1 /* invalid args */
-#define EX_BADFILE 2 /* invalid filename */
-#define EX_BADARCH 3 /* bad archive */
-#define EX_SYSTEM 4 /* system gave unexpected error */
-#define EX_BADVOL 5 /* Special error code means
- Tape volume doesn't match the one
- specified on the command line */
-
-/*
- * Global variables
- */
-TAR_EXTERN union record *ar_block; /* Start of block of archive */
-TAR_EXTERN union record *ar_record; /* Current record of archive */
-TAR_EXTERN union record *ar_last; /* Last+1 record of archive block */
-TAR_EXTERN char ar_reading; /* 0 writing, !0 reading archive */
-TAR_EXTERN int blocking; /* Size of each block, in records */
-TAR_EXTERN int blocksize; /* Size of each block, in bytes */
-TAR_EXTERN char *info_script; /* Script to run at end of each tape change */
-TAR_EXTERN char *name_file; /* File containing names to work on */
-TAR_EXTERN char filename_terminator; /* \n or \0. */
-TAR_EXTERN char *tar; /* Name of this program */
-TAR_EXTERN struct sp_array *sparsearray; /* Pointer to the start of the scratch space */
-TAR_EXTERN int sp_array_size; /* Initial size of the sparsearray */
-TAR_EXTERN int tot_written; /* Total written to output */
-TAR_EXTERN struct re_pattern_buffer
- *label_pattern; /* compiled regex for extract label */
-TAR_EXTERN char **ar_files; /* list of tape drive names */
-TAR_EXTERN int n_ar_files; /* number of tape drive names */
-TAR_EXTERN int cur_ar_file; /* tape drive currently being used */
-TAR_EXTERN int ar_files_len; /* malloced size of ar_files */
-TAR_EXTERN char *current_file_name, *current_link_name;
-
-/*
- * Flags from the command line
- */
-TAR_EXTERN int cmd_mode;
-#define CMD_NONE 0
-#define CMD_CAT 1 /* -A */
-#define CMD_CREATE 2 /* -c */
-#define CMD_DIFF 3 /* -d */
-#define CMD_APPEND 4 /* -r */
-#define CMD_LIST 5 /* -t */
-#define CMD_UPDATE 6 /* -u */
-#define CMD_EXTRACT 7 /* -x */
-#define CMD_DELETE 8 /* -D */
-#define CMD_VERSION 9 /* --version */
-
-
-TAR_EXTERN int f_reblock; /* -B */
-TAR_EXTERN int f_dironly; /* -n ... PH */
-TAR_EXTERN int f_run_script_at_end; /* -F */
-TAR_EXTERN int f_gnudump; /* -G */
-TAR_EXTERN int f_follow_links; /* -h */
-TAR_EXTERN int f_ignorez; /* -i */
-TAR_EXTERN int f_keep; /* -k */
-TAR_EXTERN int f_startfile; /* -K */
-TAR_EXTERN int f_local_filesys; /* -l */
-TAR_EXTERN int tape_length; /* -L */
-TAR_EXTERN int f_modified; /* -m */
-TAR_EXTERN int f_multivol; /* -M */
-TAR_EXTERN int f_new_files; /* -N */
-TAR_EXTERN int f_oldarch; /* -o */
-TAR_EXTERN int f_exstdout; /* -O */
-TAR_EXTERN int f_use_protection;/* -p */
-TAR_EXTERN int f_absolute_paths;/* -P */
-TAR_EXTERN int f_sayblock; /* -R */
-TAR_EXTERN int f_sorted_names; /* -s */
-TAR_EXTERN int f_sparse_files; /* -S ... JK */
-TAR_EXTERN int f_namefile; /* -T */
-TAR_EXTERN int f_verbose; /* -v */
-TAR_EXTERN char *f_volhdr; /* -V */
-TAR_EXTERN int f_confirm; /* -w */
-TAR_EXTERN int f_verify; /* -W */
-TAR_EXTERN int f_exclude; /* -X */
-TAR_EXTERN char *f_compressprog; /* -z and -Z */
-TAR_EXTERN int f_do_chown; /* --do-chown */
-TAR_EXTERN int f_totals; /* --totals */
-TAR_EXTERN int f_remove_files; /* --remove-files */
-TAR_EXTERN int f_ignore_failed_read; /* --ignore-failed-read */
-TAR_EXTERN int f_checkpoint; /* --checkpoint */
-TAR_EXTERN int f_show_omitted_dirs; /* --show-omitted-dirs */
-TAR_EXTERN char *f_volno_file; /* --volno-file */
-TAR_EXTERN int f_force_local; /* --force-local */
-TAR_EXTERN int f_atime_preserve;/* --atime-preserve */
-TAR_EXTERN int f_compress_block; /* --compress-block */
-TAR_EXTERN int f_unlink; /* --unlink */
-TAR_EXTERN int f_fast_read; /* --fast-read */
-
-/*
- * We default to Unix Standard format rather than 4.2BSD tar format.
- * The code can actually produce all three:
- * f_standard ANSI standard
- * f_oldarch V7
- * neither 4.2BSD
- * but we don't bother, since 4.2BSD can read ANSI standard format anyway.
- * The only advantage to the "neither" option is that we can cmp our
- * output to the output of 4.2BSD tar, for debugging.
- */
-#define f_standard (!f_oldarch)
-
-/*
- * Structure for keeping track of filenames and lists thereof.
- */
-struct name
- {
- struct name *next;
- short length; /* cached strlen(name) */
- char found; /* A matching file has been found */
- char firstch; /* First char is literally matched */
- char regexp; /* This name is a regexp, not literal */
- char *change_dir; /* JF set with the -C option */
- char *dir_contents; /* JF for f_gnudump */
- char fake; /* dummy entry */
- char name[1];
- };
-
-TAR_EXTERN struct name *namelist; /* Points to first name in list */
-TAR_EXTERN struct name *namelast; /* Points to last name in list */
-
-TAR_EXTERN int archive; /* File descriptor for archive file */
-TAR_EXTERN int errors; /* # of files in error */
-
-TAR_EXTERN char *gnu_dumpfile;
-
-/*
- * Error recovery stuff
- */
-TAR_EXTERN char read_error_flag;
-
-/*
- * global boolean, see name_match in tar.c
- */
-extern int nlpsfreed;
-
-/*
- * Declarations of functions available to the world.
- */
-union record *findrec ();
-void userec ();
-union record *endofrecs ();
-void anno ();
-
-#if defined (HAVE_VPRINTF) && __STDC__
-void msg (char *,...);
-void msg_perror (char *,...);
-#else
-void msg ();
-void msg_perror ();
-#endif
diff --git a/gnu/usr.bin/tar/update.c b/gnu/usr.bin/tar/update.c
deleted file mode 100644
index a64317c..0000000
--- a/gnu/usr.bin/tar/update.c
+++ /dev/null
@@ -1,585 +0,0 @@
-/* Update a tar archive.
- Copyright (C) 1988, 1992 Free Software Foundation
-
-This file is part of GNU Tar.
-
-GNU Tar 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.
-
-GNU Tar 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 GNU Tar; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* JF implement the 'r' 'u' and 'A' options for tar. */
-/* The 'A' option is my own invention: It means that the file-names are
- tar files, and they should simply be appended to the end of the archive.
- No attempt is made to block the reads from the args; if they're on raw
- tape or something like that, it'll probably lose. . . */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-
-#ifdef HAVE_SYS_MTIO_H
-#include <sys/ioctl.h>
-#include <sys/mtio.h>
-#endif
-
-#ifdef BSD42
-#include <sys/file.h>
-#else
-#ifndef V7
-#include <fcntl.h>
-#endif
-#endif
-
-#ifndef __MSDOS__
-#include <pwd.h>
-#include <grp.h>
-#endif
-
-#define STDIN 0
-#define STDOUT 1
-
-#include "tar.h"
-#include "port.h"
-#include "rmt.h"
-
-int time_to_start_writing = 0; /* We've hit the end of the old stuff,
- and its time to start writing new stuff
- to the tape. This involves seeking
- back one block and re-writing the current
- block (which has been changed). */
-
-char *output_start; /* Pointer to where we started to write in
- the first block we write out. This is used
- if we can't backspace the output and have
- to null out the first part of the block */
-
-extern void skip_file ();
-extern void skip_extended_headers ();
-
-extern union record *head;
-extern struct stat hstat;
-
-void append_file ();
-void close_archive ();
-int confirm ();
-void decode_header ();
-void fl_read ();
-void fl_write ();
-void flush_archive ();
-int move_arch ();
-struct name *name_scan ();
-char *name_from_list ();
-void name_expand ();
-void name_gather ();
-void names_notfound ();
-void open_archive ();
-int read_header ();
-void reset_eof ();
-void write_block ();
-void write_eot ();
-
-/* Implement the 'r' (add files to end of archive), and 'u' (add files to
- end of archive if they arent there, or are more up to date than the
- version in the archive.) commands.*/
-void
-update_archive ()
-{
- int found_end = 0;
- int status = 3;
- int prev_status;
- char *p;
- struct name *name;
- extern void dump_file ();
-
- name_gather ();
- if (cmd_mode == CMD_UPDATE)
- name_expand ();
- open_archive (2); /* Open for updating */
-
- do
- {
- prev_status = status;
- status = read_header ();
- switch (status)
- {
- case EOF:
- found_end = 1;
- break;
-
- case 0: /* A bad record */
- userec (head);
- switch (prev_status)
- {
- case 3:
- msg ("This doesn't look like a tar archive.");
- /* FALL THROUGH */
- case 2:
- case 1:
- msg ("Skipping to next header");
- case 0:
- break;
- }
- break;
-
- /* A good record */
- case 1:
- /* printf("File %s\n",head->header.name); */
- /* head->header.name[NAMSIZ-1]='\0'; */
- if (cmd_mode == CMD_UPDATE && (name = name_scan (current_file_name)))
- {
-
- /* struct stat hstat; */
- struct stat nstat;
- int head_standard;
-
- decode_header (head, &hstat, &head_standard, 0);
- if (stat (current_file_name, &nstat) < 0)
- {
- msg_perror ("can't stat %s:", current_file_name);
- }
- else
- {
- if (hstat.st_mtime >= nstat.st_mtime)
- name->found++;
- }
- }
- userec (head);
- if (head->header.isextended)
- skip_extended_headers ();
- skip_file ((long) hstat.st_size);
- break;
-
- case 2:
- ar_record = head;
- found_end = 1;
- break;
- }
- }
- while (!found_end);
-
- reset_eof ();
- time_to_start_writing = 1;
- output_start = ar_record->charptr;
-
- while (p = name_from_list ())
- {
- if (f_confirm && !confirm ("add", p))
- continue;
- if (cmd_mode == CMD_CAT)
- append_file (p);
- else
- dump_file (p, -1, 1);
- }
-
- write_eot ();
- close_archive ();
- names_notfound ();
-}
-
-/* Catenate file p to the archive without creating a header for it. It had
- better be a tar file or the archive is screwed */
-
-void
-append_file (p)
- char *p;
-{
- int fd;
- struct stat statbuf;
- long bytes_left;
- union record *start;
- long bufsiz, count;
-
- if (0 != stat (p, &statbuf) || (fd = open (p, O_RDONLY | O_BINARY)) < 0)
- {
- msg_perror ("can't open file %s", p);
- errors++;
- return;
- }
-
- bytes_left = statbuf.st_size;
-
- while (bytes_left > 0)
- {
- start = findrec ();
- bufsiz = endofrecs ()->charptr - start->charptr;
- if (bytes_left < bufsiz)
- {
- bufsiz = bytes_left;
- count = bufsiz % RECORDSIZE;
- if (count)
- bzero (start->charptr + bytes_left, (int) (RECORDSIZE - count));
- }
- count = read (fd, start->charptr, bufsiz);
- if (count < 0)
- {
- msg_perror ("read error at byte %ld reading %d bytes in file %s", statbuf.st_size - bytes_left, bufsiz, p);
- exit (EX_ARGSBAD); /* FOO */
- }
- bytes_left -= count;
- userec (start + (count - 1) / RECORDSIZE);
- if (count != bufsiz)
- {
- msg ("%s: file shrunk by %d bytes, yark!", p, bytes_left);
- abort ();
- }
- }
- (void) close (fd);
-}
-
-#ifdef DONTDEF
-bprint (fp, buf, num)
- FILE *fp;
- char *buf;
-{
- int c;
-
- if (num == 0 || num == -1)
- return;
- fputs (" '", fp);
- while (num--)
- {
- c = *buf++;
- if (c == '\\')
- fputs ("\\\\", fp);
- else if (c >= ' ' && c <= '~')
- putc (c, fp);
- else
- switch (c)
- {
- case '\n':
- fputs ("\\n", fp);
- break;
- case '\r':
- fputs ("\\r", fp);
- break;
- case '\b':
- fputs ("\\b", fp);
- break;
- case '\0':
- /* fputs("\\-",fp); */
- break;
- default:
- fprintf (fp, "\\%03o", c);
- break;
- }
- }
- fputs ("'\n", fp);
-}
-
-#endif
-
-int number_of_blocks_read = 0;
-
-int number_of_new_records = 0;
-int number_of_records_needed = 0;
-
-union record *new_block = 0;
-union record *save_block = 0;
-
-void
-junk_archive ()
-{
- int found_stuff = 0;
- int status = 3;
- int prev_status;
- struct name *name;
-
- /* int dummy_head; */
- int number_of_records_to_skip = 0;
- int number_of_records_to_keep = 0;
- int number_of_kept_records_in_block;
- int sub_status;
- extern int write_archive_to_stdout;
-
- /* fprintf(stderr,"Junk files\n"); */
- name_gather ();
- open_archive (2);
-
- while (!found_stuff)
- {
- prev_status = status;
- status = read_header ();
- switch (status)
- {
- case EOF:
- found_stuff = 1;
- break;
-
- case 0:
- userec (head);
- switch (prev_status)
- {
- case 3:
- msg ("This doesn't look like a tar archive.");
- /* FALL THROUGH */
- case 2:
- case 1:
- msg ("Skipping to next header");
- /* FALL THROUGH */
- case 0:
- break;
- }
- break;
-
- case 1:
- /* head->header.name[NAMSIZ-1] = '\0'; */
- /* fprintf(stderr,"file %s\n",head->header.name); */
- if ((name = name_scan (current_file_name)) == (struct name *) 0)
- {
- userec (head);
- /* fprintf(stderr,"Skip %ld\n",(long)(hstat.st_size)); */
- if (head->header.isextended)
- skip_extended_headers ();
- skip_file ((long) (hstat.st_size));
- break;
- }
- name->found = 1;
- found_stuff = 2;
- break;
-
- case 2:
- found_stuff = 1;
- break;
- }
- }
- /* fprintf(stderr,"Out of first loop\n"); */
-
- if (found_stuff != 2)
- {
- write_eot ();
- close_archive ();
- names_notfound ();
- return;
- }
-
- if (write_archive_to_stdout)
- write_archive_to_stdout = 0;
- new_block = (union record *) malloc (blocksize);
- if (new_block == 0)
- {
- msg ("Can't allocate secondary block of %d bytes", blocksize);
- exit (EX_SYSTEM);
- }
-
- /* Save away records before this one in this block */
- number_of_new_records = ar_record - ar_block;
- number_of_records_needed = blocking - number_of_new_records;
- if (number_of_new_records)
- bcopy ((void *) ar_block, (void *) new_block, (number_of_new_records) * RECORDSIZE);
-
- /* fprintf(stderr,"Saved %d recs, need %d more\n",number_of_new_records,number_of_records_needed); */
- userec (head);
- if (head->header.isextended)
- skip_extended_headers ();
- skip_file ((long) (hstat.st_size));
- found_stuff = 0;
- /* goto flush_file; */
-
- for (;;)
- {
- /* Fill in a block */
- /* another_file: */
- if (ar_record == ar_last)
- {
- /* fprintf(stderr,"New block\n"); */
- flush_archive ();
- number_of_blocks_read++;
- }
- sub_status = read_header ();
- /* fprintf(stderr,"Header type %d\n",sub_status); */
-
- if (sub_status == 2 && f_ignorez)
- {
- userec (head);
- continue;
- }
- if (sub_status == EOF || sub_status == 2)
- {
- found_stuff = 1;
- bzero (new_block[number_of_new_records].charptr, RECORDSIZE * number_of_records_needed);
- number_of_new_records += number_of_records_needed;
- number_of_records_needed = 0;
- write_block (0);
- break;
- }
-
- if (sub_status == 0)
- {
- msg ("Deleting non-header from archive.");
- userec (head);
- continue;
- }
-
- /* Found another header. Yipee! */
- /* head->header.name[NAMSIZ-1] = '\0'; */
- /* fprintf(stderr,"File %s ",head->header.name); */
- if (name = name_scan (current_file_name))
- {
- name->found = 1;
- /* fprintf(stderr,"Flush it\n"); */
- /* flush_file: */
- /* decode_header(head,&hstat,&dummy_head,0); */
- userec (head);
- number_of_records_to_skip = (hstat.st_size + RECORDSIZE - 1) / RECORDSIZE;
- /* fprintf(stderr,"Flushing %d recs from %s\n",number_of_records_to_skip,head->header.name); */
-
- while (ar_last - ar_record <= number_of_records_to_skip)
- {
-
- /* fprintf(stderr,"Block: %d <= %d ",ar_last-ar_record,number_of_records_to_skip); */
- number_of_records_to_skip -= (ar_last - ar_record);
- flush_archive ();
- number_of_blocks_read++;
- /* fprintf(stderr,"Block %d left\n",number_of_records_to_skip); */
- }
- ar_record += number_of_records_to_skip;
- /* fprintf(stderr,"Final %d\n",number_of_records_to_skip); */
- number_of_records_to_skip = 0;
- continue;
- }
-
- /* copy_header: */
- new_block[number_of_new_records] = *head;
- number_of_new_records++;
- number_of_records_needed--;
- number_of_records_to_keep = (hstat.st_size + RECORDSIZE - 1) / RECORDSIZE;
- userec (head);
- if (number_of_records_needed == 0)
- write_block (1);
- /* copy_data: */
- number_of_kept_records_in_block = ar_last - ar_record;
- if (number_of_kept_records_in_block > number_of_records_to_keep)
- number_of_kept_records_in_block = number_of_records_to_keep;
-
- /* fprintf(stderr,"Need %d kept_in %d keep %d\n",blocking,number_of_kept_records_in_block,number_of_records_to_keep); */
-
- while (number_of_records_to_keep)
- {
- int n;
-
- if (ar_record == ar_last)
- {
- /* fprintf(stderr,"Flush. . .\n"); */
- fl_read ();
- number_of_blocks_read++;
- ar_record = ar_block;
- number_of_kept_records_in_block = blocking;
- if (number_of_kept_records_in_block > number_of_records_to_keep)
- number_of_kept_records_in_block = number_of_records_to_keep;
- }
- n = number_of_kept_records_in_block;
- if (n > number_of_records_needed)
- n = number_of_records_needed;
-
- /* fprintf(stderr,"Copying %d\n",n); */
- bcopy ((void *) ar_record, (void *) (new_block + number_of_new_records), n * RECORDSIZE);
- number_of_new_records += n;
- number_of_records_needed -= n;
- ar_record += n;
- number_of_records_to_keep -= n;
- number_of_kept_records_in_block -= n;
- /* fprintf(stderr,"Now new %d need %d keep %d keep_in %d rec %d/%d\n",
- number_of_new_records,number_of_records_needed,number_of_records_to_keep,
- number_of_kept_records_in_block,ar_record-ar_block,ar_last-ar_block); */
-
- if (number_of_records_needed == 0)
- {
- write_block (1);
- }
- }
- }
-
- write_eot ();
- close_archive ();
- names_notfound ();
-}
-
-void
-write_block (f)
- int f;
-{
- /* fprintf(stderr,"Write block\n"); */
- /* We've filled out a block. Write it out. */
-
- /* Backspace back to where we started. . . */
- if (archive != STDIN)
- (void) move_arch (-(number_of_blocks_read + 1));
-
- save_block = ar_block;
- ar_block = new_block;
-
- if (archive == STDIN)
- archive = STDOUT;
- fl_write ();
-
- if (archive == STDOUT)
- archive = STDIN;
- ar_block = save_block;
-
- if (f)
- {
- /* Move the tape head back to where we were */
- if (archive != STDIN)
- (void) move_arch (number_of_blocks_read);
- number_of_blocks_read--;
- }
-
- number_of_records_needed = blocking;
- number_of_new_records = 0;
-}
-
-/* Move archive descriptor by n blocks worth. If n is positive we move
- forward, else we move negative. If its a tape, MTIOCTOP had better
- work. If its something else, we try to seek on it. If we can't
- seek, we lose! */
-int
-move_arch (n)
- int n;
-{
- long cur;
-
-#ifdef MTIOCTOP
- struct mtop t;
- int er;
-
- if (n > 0)
- {
- t.mt_op = MTFSR;
- t.mt_count = n;
- }
- else
- {
- t.mt_op = MTBSR;
- t.mt_count = -n;
- }
- if ((er = rmtioctl (archive, MTIOCTOP, &t)) >= 0)
- return 1;
- if (errno == EIO && (er = rmtioctl (archive, MTIOCTOP, &t)) >= 0)
- return 1;
-#endif
-
- cur = rmtlseek (archive, 0L, 1);
- cur += blocksize * n;
-
- /* fprintf(stderr,"Fore to %x\n",cur); */
- if (rmtlseek (archive, cur, 0) != cur)
- {
- /* Lseek failed. Try a different method */
- msg ("Couldn't re-position archive file.");
- exit (EX_BADARCH);
- }
- return 3;
-}
diff --git a/gnu/usr.bin/tar/version.c b/gnu/usr.bin/tar/version.c
deleted file mode 100644
index c556158..0000000
--- a/gnu/usr.bin/tar/version.c
+++ /dev/null
@@ -1 +0,0 @@
-char version_string[] = "GNU tar version 1.11.3";
diff --git a/gnu/usr.bin/texinfo/Makefile b/gnu/usr.bin/texinfo/Makefile
deleted file mode 100644
index f1539d5..0000000
--- a/gnu/usr.bin/texinfo/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# $Id$
-#
-
-SUBDIR= libtxi makeinfo info install-info doc
-
-.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/texinfo/Makefile.inc b/gnu/usr.bin/texinfo/Makefile.inc
deleted file mode 100644
index 5ee8874..0000000
--- a/gnu/usr.bin/texinfo/Makefile.inc
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id$
-
-TXIDIR= ${.CURDIR}/../../../../contrib/texinfo
-
-.if exists(${.OBJDIR}/../libtxi)
-LIBTXI= ${.OBJDIR}/../libtxi/libtxi.a
-.else
-LIBTXI= ${.CURDIR}/../libtxi/libtxi.a
-.endif
-
-.include "../../Makefile.inc"
diff --git a/gnu/usr.bin/texinfo/doc/Makefile b/gnu/usr.bin/texinfo/doc/Makefile
deleted file mode 100644
index 3416ad3..0000000
--- a/gnu/usr.bin/texinfo/doc/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Id$
-
-INFO= texinfo info info-stnd makeinfo
-
-.include <bsd.info.mk>
-
-.PATH: ${TXIDIR} ${TXIDIR}/info ${TXIDIR}/makeinfo
diff --git a/gnu/usr.bin/texinfo/info/Makefile b/gnu/usr.bin/texinfo/info/Makefile
deleted file mode 100644
index 2ba6f06..0000000
--- a/gnu/usr.bin/texinfo/info/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-# $Id$
-
-PROG= info
-
-SRCS= dir.c display.c doc.c echo_area.c filesys.c info-utils.c info.c infodoc.c infomap.c
-SRCS+= m-x.c nodes.c search.c session.c signals.c terminal.c tilde.c window.c indices.c
-SRCS+= xmalloc.c nodemenu.c footnotes.c dribble.c variables.c gc.c man.c clib.c
-
-CFLAGS+= -DHANDLE_MAN_PAGES -DNAMED_FUNCTIONS=1
-CFLAGS+= -DDEFAULT_INFOPATH=\"${INFODIR}:/usr/local/info:.\"
-CFLAGS+= -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_STRINGS_H=1 -DHAVE_STRING_H=1
-CFLAGS+= -DHAVE_VARARGS_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_FCNTL_H=1 -DHAVE_SYS_FILE_H=1
-CFLAGS+= -DHAVE_ALLOCA=1 -DHAVE_SETVBUF=1 -DHAVE_GETCWD=1 -DHAVE_MEMSET=1 -DHAVE_BZERO=1
-CFLAGS+= -DHAVE_STRCHR=1 -DHAVE_STRCASECMP=1 -DHAVE_VFPRINTF=1 -DHAVE_VSPRINTF=1 -DHAVE_STRERROR=1
-CFLAGS+= -DHAVE_SIGPROCMASK=1 -DHAVE_SIGSETMASK=1 -I${TXIDIR}/libtxi
-
-DPADD= ${LIBTERMCAP} ${LIBTXI}
-LDADD= -ltermcap ${LIBTXI}
-
-.include <bsd.prog.mk>
-
-.PATH: ${TXIDIR}/info
diff --git a/gnu/usr.bin/texinfo/install-info/Makefile b/gnu/usr.bin/texinfo/install-info/Makefile
deleted file mode 100644
index e233f5d..0000000
--- a/gnu/usr.bin/texinfo/install-info/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# $Id: Makefile,v 1.6 1997/04/07 16:52:45 bde Exp $
-
-PROG= install-info
-
-CFLAGS+= -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_STRINGS_H=1 -DHAVE_STRING_H=1
-CFLAGS+= -DHAVE_VARARGS_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_ALLOCA=1
-CFLAGS+= -DHAVE_SETVBUF=1 -DHAVE_GETCWD=1 -DHAVE_MEMSET=1 -DHAVE_BZERO=1 -DHAVE_STRCHR=1
-CFLAGS+= -DHAVE_STRCASECMP=1 -DHAVE_VFPRINTF=1 -DHAVE_VSPRINTF=1 -DHAVE_STRERROR=1 -DHAVE_SIGPROCMASK=1
-CFLAGS+= -DHAVE_SIGSETMASK=1 -I${TXIDIR}/libtxi
-
-DPADD= ${LIBTXI}
-LDADD= ${LIBTXI}
-
-.include <bsd.prog.mk>
-
-.PATH: ${TXIDIR}/util
diff --git a/gnu/usr.bin/texinfo/install-info/install-info.1 b/gnu/usr.bin/texinfo/install-info/install-info.1
deleted file mode 100644
index dffddbc..0000000
--- a/gnu/usr.bin/texinfo/install-info/install-info.1
+++ /dev/null
@@ -1,55 +0,0 @@
-.\"
-.\" Copyright (c) 1997 David E. O'Brien (obrien@FreeBSD.org)
-.\"
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS 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.
-.\"
-.\" $Id$
-.\"
-.\" .TH install-info 1
-.Dd August 29, 1997
-.Dt INSTALL-INFO 1
-.Os BSD
-.Sh NAME
-.Nm install-info
-.Nd edits info/dir file for the GNU info hypertext system
-.Sh SYNOPSIS
-.Nm install-info
-.Ar program.info info/dir
-.Sh DESCRIPTION
-.Nm
-is often used within the FreeBSD ports collection.
-.Sh FILES
-/usr/share/info/dir
-/usr/local/info/dir
-.I F
-.Sh SEE ALSO
-.Xr info 1
-.Sh DIAGNOSTICS
-none.
-.Sh BUGS
-none known.
-.Sh AUTHORS
-This man page has been written by David O'Brien (obrien@NUXI.com)
-.\" .Sh HISTORY
-.\" .Nm
-.\" appeared in FreeBSD 2.1.
diff --git a/gnu/usr.bin/texinfo/libtxi/Makefile b/gnu/usr.bin/texinfo/libtxi/Makefile
deleted file mode 100644
index 73a3713..0000000
--- a/gnu/usr.bin/texinfo/libtxi/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id$
-
-LIB= txi
-INTERNALLIB= true
-INTERNALSTATICLIB= true
-
-SRCS= getopt.c getopt1.c
-
-.include <bsd.lib.mk>
-
-.PATH: ${TXIDIR}/libtxi
diff --git a/gnu/usr.bin/texinfo/makeinfo/Makefile b/gnu/usr.bin/texinfo/makeinfo/Makefile
deleted file mode 100644
index a539894..0000000
--- a/gnu/usr.bin/texinfo/makeinfo/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# $Id$
-
-PROG= makeinfo
-NOMAN= yes
-SRCS= makeinfo.c multi.c
-
-CFLAGS+= -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_STRINGS_H=1 -DHAVE_STRING_H=1
-CFLAGS+= -DHAVE_VARARGS_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_ALLOCA=1
-CFLAGS+= -DHAVE_SETVBUF=1 -DHAVE_GETCWD=1 -DHAVE_MEMSET=1 -DHAVE_BZERO=1 -DHAVE_STRCHR=1
-CFLAGS+= -DHAVE_STRCASECMP=1 -DHAVE_VFPRINTF=1 -DHAVE_VSPRINTF=1 -DHAVE_STRERROR=1 -DHAVE_SIGPROCMASK=1
-CFLAGS+= -DHAVE_SIGSETMASK=1 -I${TXIDIR}/libtxi
-
-DPADD= ${LIBTXI}
-LDADD= ${LIBTXI}
-
-.include <bsd.prog.mk>
-
-.PATH: $(TXIDIR)/makeinfo
diff --git a/gnu/usr.sbin/Makefile b/gnu/usr.sbin/Makefile
deleted file mode 100644
index 980b234..0000000
--- a/gnu/usr.sbin/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-
-
-SUBDIR=
-
-.include <bsd.subdir.mk>
diff --git a/gnu/usr.sbin/Makefile.inc b/gnu/usr.sbin/Makefile.inc
deleted file mode 100644
index 1fa8c0e..0000000
--- a/gnu/usr.sbin/Makefile.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-# $Id$
-
-BINDIR?= /usr/sbin
OpenPOWER on IntegriCloud